From a21fc50739926011c56bb30b47999d83bf7462e1 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 29 Jul 2025 14:21:14 +0000 Subject: [PATCH 01/68] feat(client): ensure compat with proguard --- README.md | 6 + .../META-INF/proguard/orb-kotlin-core.pro | 32 +++++ orb-kotlin-proguard-test/build.gradle.kts | 74 +++++++++++ .../api/proguard/ProGuardCompatibilityTest.kt | 122 ++++++++++++++++++ orb-kotlin-proguard-test/test.pro | 5 + settings.gradle.kts | 1 + 6 files changed, 240 insertions(+) create mode 100644 orb-kotlin-core/src/main/resources/META-INF/proguard/orb-kotlin-core.pro create mode 100644 orb-kotlin-proguard-test/build.gradle.kts create mode 100644 orb-kotlin-proguard-test/src/test/kotlin/com/withorb/api/proguard/ProGuardCompatibilityTest.kt create mode 100644 orb-kotlin-proguard-test/test.pro diff --git a/README.md b/README.md index a0e454c5b..1b9acb245 100644 --- a/README.md +++ b/README.md @@ -312,6 +312,12 @@ both of which will raise an error if the signature is invalid. Note that the `body` parameter must be the raw JSON string sent from the server (do not parse it first). The `.unwrap()` method can parse this JSON for you. +## ProGuard and R8 + +Although the SDK uses reflection, it is still usable with [ProGuard](https://github.com/Guardsquare/proguard) and [R8](https://developer.android.com/topic/performance/app-optimization/enable-app-optimization) because `orb-kotlin-core` is published with a [configuration file](orb-kotlin-core/src/main/resources/META-INF/proguard/orb-kotlin-core.pro) containing [keep rules](https://www.guardsquare.com/manual/configuration/usage). + +ProGuard and R8 should automatically detect and use the published rules, but you can also manually copy the keep rules if necessary. + ## Jackson The SDK depends on [Jackson](https://github.com/FasterXML/jackson) for JSON serialization/deserialization. It is compatible with version 2.13.4 or higher, but depends on version 2.18.2 by default. diff --git a/orb-kotlin-core/src/main/resources/META-INF/proguard/orb-kotlin-core.pro b/orb-kotlin-core/src/main/resources/META-INF/proguard/orb-kotlin-core.pro new file mode 100644 index 000000000..51aa2ec2e --- /dev/null +++ b/orb-kotlin-core/src/main/resources/META-INF/proguard/orb-kotlin-core.pro @@ -0,0 +1,32 @@ +# Jackson uses reflection and depends heavily on runtime attributes. +-keepattributes + +# Jackson uses Kotlin reflection utilities, which themselves use reflection to access things. +-keep class kotlin.reflect.** { *; } +-keep class kotlin.Metadata { *; } + +# Jackson uses reflection to access enum members (e.g. via `java.lang.Class.getEnumConstants()`). +-keepclassmembers class com.fasterxml.jackson.** extends java.lang.Enum { + ; + public static **[] values(); + public static ** valueOf(java.lang.String); +} + +# Jackson uses reflection to access annotation members. +-keepclassmembers @interface com.fasterxml.jackson.annotation.** { + *; +} + +# Jackson uses reflection to access the default constructors of serializers and deserializers. +-keepclassmembers class * extends com.withorb.api.core.BaseSerializer { + (); +} +-keepclassmembers class * extends com.withorb.api.core.BaseDeserializer { + (); +} + +# Jackson uses reflection to serialize and deserialize our classes based on their constructors and annotated members. +-keepclassmembers class com.withorb.api.** { + (...); + @com.fasterxml.jackson.annotation.* *; +} \ No newline at end of file diff --git a/orb-kotlin-proguard-test/build.gradle.kts b/orb-kotlin-proguard-test/build.gradle.kts new file mode 100644 index 000000000..e1e7d57b7 --- /dev/null +++ b/orb-kotlin-proguard-test/build.gradle.kts @@ -0,0 +1,74 @@ +plugins { + id("orb.kotlin") + id("com.gradleup.shadow") version "8.3.8" +} + +buildscript { + dependencies { + classpath("com.guardsquare:proguard-gradle:7.4.2") + } +} + +dependencies { + testImplementation(project(":orb-kotlin")) + testImplementation(kotlin("test")) + testImplementation("org.junit.jupiter:junit-jupiter-api:5.9.3") + testImplementation("org.assertj:assertj-core:3.25.3") + testImplementation("com.fasterxml.jackson.module:jackson-module-kotlin:2.13.4") + testImplementation("org.junit.platform:junit-platform-console:1.10.1") +} + +tasks.shadowJar { + from(sourceSets.test.get().output) + configurations = listOf(project.configurations.testRuntimeClasspath.get()) +} + +val proguardJarPath = "${layout.buildDirectory.get()}/libs/${project.name}-${project.version}-proguard.jar" +val proguardJar by tasks.registering(proguard.gradle.ProGuardTask::class) { + group = "verification" + dependsOn(tasks.shadowJar) + notCompatibleWithConfigurationCache("ProGuard") + + injars(tasks.shadowJar) + outjars(proguardJarPath) + printmapping("${layout.buildDirectory.get()}/proguard-mapping.txt") + + verbose() + dontwarn() + + val javaHome = System.getProperty("java.home") + if (System.getProperty("java.version").startsWith("1.")) { + // Before Java 9, the runtime classes were packaged in a single jar file. + libraryjars("$javaHome/lib/rt.jar") + } else { + // As of Java 9, the runtime classes are packaged in modular jmod files. + libraryjars( + // Filters must be specified first, as a map. + mapOf("jarfilter" to "!**.jar", "filter" to "!module-info.class"), + "$javaHome/jmods/java.base.jmod" + ) + } + + configuration("./test.pro") + configuration("../orb-kotlin-core/src/main/resources/META-INF/proguard/orb-kotlin-core.pro") +} + +val testProGuard by tasks.registering(JavaExec::class) { + group = "verification" + dependsOn(proguardJar) + notCompatibleWithConfigurationCache("ProGuard") + + mainClass.set("org.junit.platform.console.ConsoleLauncher") + classpath = files(proguardJarPath) + args = listOf( + "--classpath", proguardJarPath, + "--scan-classpath", + "--details", "verbose", + ) +} + +tasks.test { + dependsOn(testProGuard) + // We defer to the tests run via the ProGuard JAR. + enabled = false +} diff --git a/orb-kotlin-proguard-test/src/test/kotlin/com/withorb/api/proguard/ProGuardCompatibilityTest.kt b/orb-kotlin-proguard-test/src/test/kotlin/com/withorb/api/proguard/ProGuardCompatibilityTest.kt new file mode 100644 index 000000000..62d52724f --- /dev/null +++ b/orb-kotlin-proguard-test/src/test/kotlin/com/withorb/api/proguard/ProGuardCompatibilityTest.kt @@ -0,0 +1,122 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.proguard + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.withorb.api.client.okhttp.OrbOkHttpClient +import com.withorb.api.core.jsonMapper +import com.withorb.api.models.AccountingProviderConfig +import com.withorb.api.models.BillingCycleRelativeDate +import com.withorb.api.models.Discount +import com.withorb.api.models.PercentageDiscount +import com.withorb.api.models.TransformPriceFilter +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.BeforeAll +import org.junit.jupiter.api.Test + +internal class ProGuardCompatibilityTest { + + companion object { + + @BeforeAll + @JvmStatic + fun setUp() { + // To debug that we're using the right JAR. + val jarPath = this::class.java.getProtectionDomain().codeSource.location + println("JAR being used: $jarPath") + } + } + + @Test + fun proguardRules() { + val rulesFile = + javaClass.classLoader.getResourceAsStream("META-INF/proguard/orb-kotlin-core.pro") + + assertThat(rulesFile).isNotNull() + } + + @Test + fun client() { + val client = OrbOkHttpClient.builder().apiKey("My API Key").build() + + assertThat(client).isNotNull() + assertThat(client.topLevel()).isNotNull() + assertThat(client.beta()).isNotNull() + assertThat(client.coupons()).isNotNull() + assertThat(client.creditNotes()).isNotNull() + assertThat(client.customers()).isNotNull() + assertThat(client.events()).isNotNull() + assertThat(client.invoiceLineItems()).isNotNull() + assertThat(client.invoices()).isNotNull() + assertThat(client.items()).isNotNull() + assertThat(client.metrics()).isNotNull() + assertThat(client.plans()).isNotNull() + assertThat(client.prices()).isNotNull() + assertThat(client.subscriptions()).isNotNull() + assertThat(client.alerts()).isNotNull() + assertThat(client.dimensionalPriceGroups()).isNotNull() + assertThat(client.subscriptionChanges()).isNotNull() + } + + @Test + fun accountingProviderConfigRoundtrip() { + val jsonMapper = jsonMapper() + val accountingProviderConfig = + AccountingProviderConfig.builder() + .externalProviderId("external_provider_id") + .providerType("provider_type") + .build() + + val roundtrippedAccountingProviderConfig = + jsonMapper.readValue( + jsonMapper.writeValueAsString(accountingProviderConfig), + jacksonTypeRef(), + ) + + assertThat(roundtrippedAccountingProviderConfig).isEqualTo(accountingProviderConfig) + } + + @Test + fun discountRoundtrip() { + val jsonMapper = jsonMapper() + val discount = + Discount.ofPercentage( + PercentageDiscount.builder() + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .addFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) + .reason("reason") + .build() + ) + + val roundtrippedDiscount = + jsonMapper.readValue( + jsonMapper.writeValueAsString(discount), + jacksonTypeRef(), + ) + + assertThat(roundtrippedDiscount).isEqualTo(discount) + } + + @Test + fun billingCycleRelativeDateRoundtrip() { + val jsonMapper = jsonMapper() + val billingCycleRelativeDate = BillingCycleRelativeDate.START_OF_TERM + + val roundtrippedBillingCycleRelativeDate = + jsonMapper.readValue( + jsonMapper.writeValueAsString(billingCycleRelativeDate), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBillingCycleRelativeDate).isEqualTo(billingCycleRelativeDate) + } +} diff --git a/orb-kotlin-proguard-test/test.pro b/orb-kotlin-proguard-test/test.pro new file mode 100644 index 000000000..a07f408f5 --- /dev/null +++ b/orb-kotlin-proguard-test/test.pro @@ -0,0 +1,5 @@ +# Specify the entrypoint where ProGuard starts to determine what's reachable. +-keep class com.withorb.api.proguard.** { *; } + +# For the testing framework. +-keep class org.junit.** { *; } \ No newline at end of file diff --git a/settings.gradle.kts b/settings.gradle.kts index 5bb85382d..d3e094a05 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -3,4 +3,5 @@ rootProject.name = "orb-kotlin-root" include("orb-kotlin") include("orb-kotlin-client-okhttp") include("orb-kotlin-core") +include("orb-kotlin-proguard-test") include("orb-kotlin-example") From 6bf3387e9efe151b2db48c51a454f4ac9abb03e1 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 29 Jul 2025 11:54:16 +0000 Subject: [PATCH 02/68] feat: add retryable exception --- README.md | 2 + .../api/core/http/RetryingHttpClient.kt | 8 ++- .../api/errors/OrbRetryableException.kt | 13 ++++ .../api/core/http/RetryingHttpClientTest.kt | 72 +++++++++++++++++++ 4 files changed, 92 insertions(+), 3 deletions(-) create mode 100644 orb-kotlin-core/src/main/kotlin/com/withorb/api/errors/OrbRetryableException.kt diff --git a/README.md b/README.md index 1b9acb245..a831d6dd1 100644 --- a/README.md +++ b/README.md @@ -229,6 +229,8 @@ The SDK throws custom unchecked exception types: - [`OrbIoException`](orb-kotlin-core/src/main/kotlin/com/withorb/api/errors/OrbIoException.kt): I/O networking errors. +- [`OrbRetryableException`](orb-kotlin-core/src/main/kotlin/com/withorb/api/errors/OrbRetryableException.kt): Generic error indicating a failure that could be retried by the client. + - [`OrbInvalidDataException`](orb-kotlin-core/src/main/kotlin/com/withorb/api/errors/OrbInvalidDataException.kt): Failure to interpret successfully parsed data. For example, when accessing a property that's supposed to be required, but the API unexpectedly omitted it from the response. - [`OrbException`](orb-kotlin-core/src/main/kotlin/com/withorb/api/errors/OrbException.kt): Base class for all exceptions. Most errors will result in one of the previously mentioned ones, but completely generic errors may be thrown using the base class. diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/core/http/RetryingHttpClient.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/core/http/RetryingHttpClient.kt index 738ddfbae..fd18082fc 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/core/http/RetryingHttpClient.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/core/http/RetryingHttpClient.kt @@ -3,6 +3,7 @@ package com.withorb.api.core.http import com.withorb.api.core.RequestOptions import com.withorb.api.core.checkRequired import com.withorb.api.errors.OrbIoException +import com.withorb.api.errors.OrbRetryableException import java.io.IOException import java.time.Clock import java.time.Duration @@ -159,9 +160,10 @@ private constructor( } private fun shouldRetry(throwable: Throwable): Boolean = - // Only retry IOException and OrbIoException, other exceptions are not intended to be - // retried. - throwable is IOException || throwable is OrbIoException + // Only retry known retryable exceptions, other exceptions are not intended to be retried. + throwable is IOException || + throwable is OrbIoException || + throwable is OrbRetryableException private fun getRetryBackoffDuration(retries: Int, response: HttpResponse?): Duration { // About the Retry-After header: diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/errors/OrbRetryableException.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/errors/OrbRetryableException.kt new file mode 100644 index 000000000..b775d950b --- /dev/null +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/errors/OrbRetryableException.kt @@ -0,0 +1,13 @@ +package com.withorb.api.errors + +/** + * Exception that indicates a transient error that can be retried. + * + * When this exception is thrown during an HTTP request, the SDK will automatically retry the + * request up to the maximum number of retries. + * + * @param message A descriptive error message + * @param cause The underlying cause of this exception, if any + */ +class OrbRetryableException constructor(message: String? = null, cause: Throwable? = null) : + OrbException(message, cause) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/core/http/RetryingHttpClientTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/core/http/RetryingHttpClientTest.kt index b6bb4a629..263929503 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/core/http/RetryingHttpClientTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/core/http/RetryingHttpClientTest.kt @@ -6,6 +6,7 @@ import com.github.tomakehurst.wiremock.junit5.WireMockTest import com.github.tomakehurst.wiremock.stubbing.Scenario import com.withorb.api.client.okhttp.OkHttpClient import com.withorb.api.core.RequestOptions +import com.withorb.api.errors.OrbRetryableException import java.io.InputStream import java.time.Duration import kotlinx.coroutines.runBlocking @@ -250,6 +251,77 @@ internal class RetryingHttpClientTest { assertNoResponseLeaks() } + @ParameterizedTest + @ValueSource(booleans = [false, true]) + fun execute_withRetryableException(async: Boolean) { + stubFor(post(urlPathEqualTo("/something")).willReturn(ok())) + + var callCount = 0 + val failingHttpClient = + object : HttpClient { + override fun execute( + request: HttpRequest, + requestOptions: RequestOptions, + ): HttpResponse { + callCount++ + if (callCount == 1) { + throw OrbRetryableException("Simulated retryable failure") + } + return httpClient.execute(request, requestOptions) + } + + override suspend fun executeAsync( + request: HttpRequest, + requestOptions: RequestOptions, + ): HttpResponse { + callCount++ + if (callCount == 1) { + throw OrbRetryableException("Simulated retryable failure") + } + return httpClient.executeAsync(request, requestOptions) + } + + override fun close() = httpClient.close() + } + + val retryingClient = + RetryingHttpClient.builder() + .httpClient(failingHttpClient) + .maxRetries(2) + .sleeper( + object : RetryingHttpClient.Sleeper { + + override fun sleep(duration: Duration) {} + + override suspend fun sleepAsync(duration: Duration) {} + } + ) + .build() + + val response = + retryingClient.execute( + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(baseUrl) + .addPathSegment("something") + .build(), + async, + ) + + assertThat(response.statusCode()).isEqualTo(200) + verify( + 1, + postRequestedFor(urlPathEqualTo("/something")) + .withHeader("x-stainless-retry-count", equalTo("1")), + ) + verify( + 0, + postRequestedFor(urlPathEqualTo("/something")) + .withHeader("x-stainless-retry-count", equalTo("0")), + ) + assertNoResponseLeaks() + } + private fun retryingHttpClientBuilder() = RetryingHttpClient.builder() .httpClient(httpClient) From 4d46e6201e6bf0a1963f05e3982ecc97bcb9519c Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 31 Jul 2025 21:07:09 +0000 Subject: [PATCH 03/68] fix(client): r8 support --- .../META-INF/proguard/orb-kotlin-core.pro | 16 ++++---- orb-kotlin-proguard-test/build.gradle.kts | 40 ++++++++++++++++--- .../api/proguard/ProGuardCompatibilityTest.kt | 17 ++++++-- orb-kotlin-proguard-test/test.pro | 5 ++- 4 files changed, 61 insertions(+), 17 deletions(-) diff --git a/orb-kotlin-core/src/main/resources/META-INF/proguard/orb-kotlin-core.pro b/orb-kotlin-core/src/main/resources/META-INF/proguard/orb-kotlin-core.pro index 51aa2ec2e..ac5f62da4 100644 --- a/orb-kotlin-core/src/main/resources/META-INF/proguard/orb-kotlin-core.pro +++ b/orb-kotlin-core/src/main/resources/META-INF/proguard/orb-kotlin-core.pro @@ -1,5 +1,5 @@ # Jackson uses reflection and depends heavily on runtime attributes. --keepattributes +-keepattributes Exceptions,InnerClasses,Signature,Deprecated,*Annotation* # Jackson uses Kotlin reflection utilities, which themselves use reflection to access things. -keep class kotlin.reflect.** { *; } @@ -17,13 +17,13 @@ *; } -# Jackson uses reflection to access the default constructors of serializers and deserializers. --keepclassmembers class * extends com.withorb.api.core.BaseSerializer { - (); -} --keepclassmembers class * extends com.withorb.api.core.BaseDeserializer { - (); -} +# Jackson uses reified type information to serialize and deserialize our classes (via `TypeReference`). +-keep class com.fasterxml.jackson.core.type.TypeReference { *; } +-keep class * extends com.fasterxml.jackson.core.type.TypeReference { *; } + +# Jackson uses reflection to access our class serializers and deserializers. +-keep @com.fasterxml.jackson.databind.annotation.JsonSerialize class com.withorb.api.** { *; } +-keep @com.fasterxml.jackson.databind.annotation.JsonDeserialize class com.withorb.api.** { *; } # Jackson uses reflection to serialize and deserialize our classes based on their constructors and annotated members. -keepclassmembers class com.withorb.api.** { diff --git a/orb-kotlin-proguard-test/build.gradle.kts b/orb-kotlin-proguard-test/build.gradle.kts index e1e7d57b7..e607615df 100644 --- a/orb-kotlin-proguard-test/build.gradle.kts +++ b/orb-kotlin-proguard-test/build.gradle.kts @@ -4,8 +4,13 @@ plugins { } buildscript { + repositories { + google() + } + dependencies { classpath("com.guardsquare:proguard-gradle:7.4.2") + classpath("com.android.tools:r8:8.3.37") } } @@ -15,7 +20,6 @@ dependencies { testImplementation("org.junit.jupiter:junit-jupiter-api:5.9.3") testImplementation("org.assertj:assertj-core:3.25.3") testImplementation("com.fasterxml.jackson.module:jackson-module-kotlin:2.13.4") - testImplementation("org.junit.platform:junit-platform-console:1.10.1") } tasks.shadowJar { @@ -58,17 +62,43 @@ val testProGuard by tasks.registering(JavaExec::class) { dependsOn(proguardJar) notCompatibleWithConfigurationCache("ProGuard") - mainClass.set("org.junit.platform.console.ConsoleLauncher") + mainClass.set("com.withorb.api.proguard.ProGuardCompatibilityTest") classpath = files(proguardJarPath) +} + +val r8JarPath = "${layout.buildDirectory.get()}/libs/${project.name}-${project.version}-r8.jar" +val r8Jar by tasks.registering(JavaExec::class) { + group = "verification" + dependsOn(tasks.shadowJar) + notCompatibleWithConfigurationCache("R8") + + mainClass.set("com.android.tools.r8.R8") + classpath = buildscript.configurations["classpath"] + args = listOf( - "--classpath", proguardJarPath, - "--scan-classpath", - "--details", "verbose", + "--release", + "--classfile", + "--output", r8JarPath, + "--lib", System.getProperty("java.home"), + "--pg-conf", "./test.pro", + "--pg-conf", "../orb-kotlin-core/src/main/resources/META-INF/proguard/orb-kotlin-core.pro", + "--pg-map-output", "${layout.buildDirectory.get()}/r8-mapping.txt", + tasks.shadowJar.get().archiveFile.get().asFile.absolutePath, ) } +val testR8 by tasks.registering(JavaExec::class) { + group = "verification" + dependsOn(r8Jar) + notCompatibleWithConfigurationCache("R8") + + mainClass.set("com.withorb.api.proguard.ProGuardCompatibilityTest") + classpath = files(r8JarPath) +} + tasks.test { dependsOn(testProGuard) + dependsOn(testR8) // We defer to the tests run via the ProGuard JAR. enabled = false } diff --git a/orb-kotlin-proguard-test/src/test/kotlin/com/withorb/api/proguard/ProGuardCompatibilityTest.kt b/orb-kotlin-proguard-test/src/test/kotlin/com/withorb/api/proguard/ProGuardCompatibilityTest.kt index 62d52724f..bb4ebfe00 100644 --- a/orb-kotlin-proguard-test/src/test/kotlin/com/withorb/api/proguard/ProGuardCompatibilityTest.kt +++ b/orb-kotlin-proguard-test/src/test/kotlin/com/withorb/api/proguard/ProGuardCompatibilityTest.kt @@ -10,20 +10,31 @@ import com.withorb.api.models.BillingCycleRelativeDate import com.withorb.api.models.Discount import com.withorb.api.models.PercentageDiscount import com.withorb.api.models.TransformPriceFilter +import kotlin.reflect.full.memberFunctions +import kotlin.reflect.jvm.javaMethod import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.BeforeAll import org.junit.jupiter.api.Test internal class ProGuardCompatibilityTest { companion object { - @BeforeAll @JvmStatic - fun setUp() { + fun main(args: Array) { // To debug that we're using the right JAR. val jarPath = this::class.java.getProtectionDomain().codeSource.location println("JAR being used: $jarPath") + + // We have to manually run the test methods instead of using the JUnit runner because it + // seems impossible to get working with R8. + val test = ProGuardCompatibilityTest() + test::class + .memberFunctions + .asSequence() + .filter { function -> + function.javaMethod?.isAnnotationPresent(Test::class.java) == true + } + .forEach { it.call(test) } } } diff --git a/orb-kotlin-proguard-test/test.pro b/orb-kotlin-proguard-test/test.pro index a07f408f5..da8a12644 100644 --- a/orb-kotlin-proguard-test/test.pro +++ b/orb-kotlin-proguard-test/test.pro @@ -2,4 +2,7 @@ -keep class com.withorb.api.proguard.** { *; } # For the testing framework. --keep class org.junit.** { *; } \ No newline at end of file +-keep class org.junit.** { *; } + +# Many warnings don't apply for our testing purposes. +-dontwarn \ No newline at end of file From ba337ee683dea8296441855e1c5583c86bfa7f04 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 31 Jul 2025 23:30:30 +0000 Subject: [PATCH 04/68] chore(internal): reduce proguard ci logging --- orb-kotlin-proguard-test/build.gradle.kts | 1 - 1 file changed, 1 deletion(-) diff --git a/orb-kotlin-proguard-test/build.gradle.kts b/orb-kotlin-proguard-test/build.gradle.kts index e607615df..4ba289076 100644 --- a/orb-kotlin-proguard-test/build.gradle.kts +++ b/orb-kotlin-proguard-test/build.gradle.kts @@ -37,7 +37,6 @@ val proguardJar by tasks.registering(proguard.gradle.ProGuardTask::class) { outjars(proguardJarPath) printmapping("${layout.buildDirectory.get()}/proguard-mapping.txt") - verbose() dontwarn() val javaHome = System.getProperty("java.home") From c9b431af1e09f27dd08de5d1b247b72f70d160ae Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 31 Jul 2025 23:46:11 +0000 Subject: [PATCH 05/68] chore(internal): bump ci test timeout --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 97699ccc4..53c50fd84 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,7 +14,7 @@ on: jobs: lint: - timeout-minutes: 10 + timeout-minutes: 15 name: lint runs-on: ${{ github.repository == 'stainless-sdks/orb-kotlin' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }} if: github.event_name == 'push' || github.event.pull_request.head.repo.fork @@ -37,7 +37,7 @@ jobs: - name: Run lints run: ./scripts/lint test: - timeout-minutes: 10 + timeout-minutes: 15 name: test runs-on: ${{ github.repository == 'stainless-sdks/orb-kotlin' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }} if: github.event_name == 'push' || github.event.pull_request.head.repo.fork From 337955ab0f454ad941e67b026769a9167f1f854e Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 29 Aug 2025 18:01:19 +0000 Subject: [PATCH 06/68] codegen metadata --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index c03739d1c..69ee938b4 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 118 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-4f31d46f5ba187fc4d702c9f9f1573dacb891edbd086f935707578d7c4f5fed8.yml openapi_spec_hash: 25b1019f20a47b8af665aae5f8fd0025 -config_hash: 5135e9237207028f293049a77428c775 +config_hash: d8a0d696f3250ab096fac87b6b0eab53 From d06f6564fcaeaf124295a7cc5db061e7092e4771 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 29 Aug 2025 18:29:58 +0000 Subject: [PATCH 07/68] chore(internal): codegen related update --- .github/workflows/ci.yml | 25 + .github/workflows/publish-sonatype.yml | 2 +- .gitignore | 2 +- build.gradle.kts | 12 + buildSrc/build.gradle.kts | 1 - buildSrc/src/main/kotlin/orb.java.gradle.kts | 94 +- .../src/main/kotlin/orb.kotlin.gradle.kts | 82 +- gradle.properties | 7 +- .../withorb/api/client/OrbClientAsyncImpl.kt | 2 +- .../com/withorb/api/client/OrbClientImpl.kt | 2 +- .../com/withorb/api/core/ClientOptions.kt | 18 + .../core/PhantomReachableExecutorService.kt | 58 + .../kotlin/com/withorb/api/core/Timeout.kt | 8 +- .../main/kotlin/com/withorb/api/core/Utils.kt | 17 + .../api/models/AccountingProviderConfig.kt | 11 +- .../kotlin/com/withorb/api/models/Address.kt | 15 +- .../com/withorb/api/models/AddressInput.kt | 15 +- .../withorb/api/models/AdjustmentInterval.kt | 31 +- .../com/withorb/api/models/AffectedBlock.kt | 12 +- .../com/withorb/api/models/AggregatedCost.kt | 21 +- .../kotlin/com/withorb/api/models/Alert.kt | 65 +- .../models/AlertCreateForCustomerParams.kt | 23 +- .../AlertCreateForExternalCustomerParams.kt | 23 +- .../AlertCreateForSubscriptionParams.kt | 23 +- .../withorb/api/models/AlertDisableParams.kt | 16 +- .../withorb/api/models/AlertEnableParams.kt | 16 +- .../com/withorb/api/models/AlertListPage.kt | 7 +- .../withorb/api/models/AlertListPageAsync.kt | 7 +- .../api/models/AlertListPageResponse.kt | 11 +- .../com/withorb/api/models/AlertListParams.kt | 28 +- .../withorb/api/models/AlertRetrieveParams.kt | 7 +- .../withorb/api/models/AlertUpdateParams.kt | 15 +- .../com/withorb/api/models/Allocation.kt | 12 +- .../api/models/AmendmentLedgerEntry.kt | 45 +- .../com/withorb/api/models/AmountDiscount.kt | 23 +- .../api/models/AmountDiscountInterval.kt | 25 +- .../api/models/BetaCreatePlanVersionParams.kt | 256 +- ...taExternalPlanIdCreatePlanVersionParams.kt | 256 +- ...etaExternalPlanIdFetchPlanVersionParams.kt | 9 +- ...ternalPlanIdSetDefaultPlanVersionParams.kt | 15 +- .../api/models/BetaFetchPlanVersionParams.kt | 9 +- .../models/BetaSetDefaultPlanVersionParams.kt | 15 +- .../com/withorb/api/models/BillableMetric.kt | 21 +- .../withorb/api/models/BillableMetricTiny.kt | 6 +- .../models/BillingCycleAnchorConfiguration.kt | 8 +- .../api/models/BillingCycleConfiguration.kt | 9 +- .../api/models/BillingCycleRelativeDate.kt | 2 +- .../com/withorb/api/models/BpsConfig.kt | 7 +- .../kotlin/com/withorb/api/models/BpsTier.kt | 13 +- .../com/withorb/api/models/BulkBpsConfig.kt | 6 +- .../com/withorb/api/models/BulkBpsTier.kt | 12 +- .../com/withorb/api/models/BulkConfig.kt | 6 +- .../kotlin/com/withorb/api/models/BulkTier.kt | 11 +- .../models/ChangedSubscriptionResources.kt | 19 +- .../withorb/api/models/ConversionRateTier.kt | 12 +- .../api/models/ConversionRateTieredConfig.kt | 6 +- .../api/models/ConversionRateUnitConfig.kt | 6 +- .../kotlin/com/withorb/api/models/Coupon.kt | 29 +- .../withorb/api/models/CouponArchiveParams.kt | 9 +- .../withorb/api/models/CouponCreateParams.kt | 52 +- .../withorb/api/models/CouponFetchParams.kt | 7 +- .../com/withorb/api/models/CouponListPage.kt | 7 +- .../withorb/api/models/CouponListPageAsync.kt | 7 +- .../api/models/CouponListPageResponse.kt | 11 +- .../withorb/api/models/CouponListParams.kt | 18 +- .../withorb/api/models/CouponRedemption.kt | 12 +- .../api/models/CouponSubscriptionListPage.kt | 7 +- .../models/CouponSubscriptionListPageAsync.kt | 7 +- .../models/CouponSubscriptionListParams.kt | 10 +- .../models/CreditBlockExpiryLedgerEntry.kt | 45 +- .../com/withorb/api/models/CreditNote.kt | 167 +- .../api/models/CreditNoteCreateParams.kt | 36 +- .../api/models/CreditNoteFetchParams.kt | 8 +- .../withorb/api/models/CreditNoteListPage.kt | 7 +- .../api/models/CreditNoteListPageAsync.kt | 7 +- .../api/models/CreditNoteListPageResponse.kt | 11 +- .../api/models/CreditNoteListParams.kt | 22 +- .../com/withorb/api/models/CreditNoteTiny.kt | 6 +- .../withorb/api/models/CustomExpiration.kt | 9 +- .../kotlin/com/withorb/api/models/Customer.kt | 98 +- .../CustomerBalanceTransactionCreateParams.kt | 23 +- ...ustomerBalanceTransactionCreateResponse.kt | 35 +- .../CustomerBalanceTransactionListPage.kt | 7 +- ...CustomerBalanceTransactionListPageAsync.kt | 7 +- ...tomerBalanceTransactionListPageResponse.kt | 11 +- .../CustomerBalanceTransactionListParams.kt | 24 +- .../CustomerBalanceTransactionListResponse.kt | 35 +- .../CustomerCostListByExternalIdParams.kt | 22 +- .../CustomerCostListByExternalIdResponse.kt | 6 +- .../api/models/CustomerCostListParams.kt | 22 +- .../api/models/CustomerCostListResponse.kt | 6 +- .../api/models/CustomerCreateParams.kt | 69 +- ...editLedgerCreateEntryByExternalIdParams.kt | 193 +- ...itLedgerCreateEntryByExternalIdResponse.kt | 20 +- .../CustomerCreditLedgerCreateEntryParams.kt | 193 +- ...CustomerCreditLedgerCreateEntryResponse.kt | 20 +- ...ustomerCreditLedgerListByExternalIdPage.kt | 7 +- ...erCreditLedgerListByExternalIdPageAsync.kt | 7 +- ...reditLedgerListByExternalIdPageResponse.kt | 11 +- ...tomerCreditLedgerListByExternalIdParams.kt | 36 +- ...merCreditLedgerListByExternalIdResponse.kt | 20 +- .../models/CustomerCreditLedgerListPage.kt | 7 +- .../CustomerCreditLedgerListPageAsync.kt | 7 +- .../CustomerCreditLedgerListPageResponse.kt | 11 +- .../models/CustomerCreditLedgerListParams.kt | 36 +- .../CustomerCreditLedgerListResponse.kt | 20 +- .../CustomerCreditListByExternalIdPage.kt | 7 +- ...CustomerCreditListByExternalIdPageAsync.kt | 7 +- ...tomerCreditListByExternalIdPageResponse.kt | 11 +- .../CustomerCreditListByExternalIdParams.kt | 20 +- .../CustomerCreditListByExternalIdResponse.kt | 27 +- .../api/models/CustomerCreditListPage.kt | 7 +- .../api/models/CustomerCreditListPageAsync.kt | 7 +- .../models/CustomerCreditListPageResponse.kt | 11 +- .../api/models/CustomerCreditListParams.kt | 20 +- .../api/models/CustomerCreditListResponse.kt | 27 +- ...omerCreditTopUpCreateByExternalIdParams.kt | 57 +- ...erCreditTopUpCreateByExternalIdResponse.kt | 29 +- .../models/CustomerCreditTopUpCreateParams.kt | 57 +- .../CustomerCreditTopUpCreateResponse.kt | 29 +- ...omerCreditTopUpDeleteByExternalIdParams.kt | 16 +- .../models/CustomerCreditTopUpDeleteParams.kt | 16 +- ...CustomerCreditTopUpListByExternalIdPage.kt | 7 +- ...merCreditTopUpListByExternalIdPageAsync.kt | 7 +- ...CreditTopUpListByExternalIdPageResponse.kt | 11 +- ...stomerCreditTopUpListByExternalIdParams.kt | 10 +- ...omerCreditTopUpListByExternalIdResponse.kt | 29 +- .../api/models/CustomerCreditTopUpListPage.kt | 7 +- .../CustomerCreditTopUpListPageAsync.kt | 7 +- .../CustomerCreditTopUpListPageResponse.kt | 11 +- .../models/CustomerCreditTopUpListParams.kt | 10 +- .../models/CustomerCreditTopUpListResponse.kt | 29 +- .../api/models/CustomerDeleteParams.kt | 9 +- .../models/CustomerFetchByExternalIdParams.kt | 8 +- .../withorb/api/models/CustomerFetchParams.kt | 8 +- .../api/models/CustomerHierarchyConfig.kt | 11 +- .../withorb/api/models/CustomerListPage.kt | 7 +- .../api/models/CustomerListPageAsync.kt | 7 +- .../api/models/CustomerListPageResponse.kt | 11 +- .../withorb/api/models/CustomerListParams.kt | 22 +- .../withorb/api/models/CustomerMinified.kt | 7 +- ...dsFromGatewayByExternalCustomerIdParams.kt | 14 +- ...omerSyncPaymentMethodsFromGatewayParams.kt | 9 +- .../com/withorb/api/models/CustomerTaxId.kt | 12 +- .../CustomerUpdateByExternalIdParams.kt | 68 +- .../api/models/CustomerUpdateParams.kt | 69 +- .../api/models/DecrementLedgerEntry.kt | 51 +- .../models/DimensionalPriceConfiguration.kt | 11 +- .../api/models/DimensionalPriceGroup.kt | 27 +- .../DimensionalPriceGroupCreateParams.kt | 34 +- ...alDimensionalPriceGroupIdRetrieveParams.kt | 8 +- ...rnalDimensionalPriceGroupIdUpdateParams.kt | 29 +- .../models/DimensionalPriceGroupListPage.kt | 7 +- .../DimensionalPriceGroupListPageAsync.kt | 7 +- .../models/DimensionalPriceGroupListParams.kt | 9 +- .../DimensionalPriceGroupRetrieveParams.kt | 8 +- .../DimensionalPriceGroupUpdateParams.kt | 24 +- .../api/models/DimensionalPriceGroups.kt | 11 +- .../kotlin/com/withorb/api/models/Discount.kt | 8 +- .../withorb/api/models/DiscountOverride.kt | 21 +- .../withorb/api/models/EvaluatePriceGroup.kt | 19 +- .../api/models/EventBackfillCloseParams.kt | 9 +- .../api/models/EventBackfillCloseResponse.kt | 35 +- .../api/models/EventBackfillCreateParams.kt | 34 +- .../api/models/EventBackfillCreateResponse.kt | 35 +- .../api/models/EventBackfillFetchParams.kt | 8 +- .../api/models/EventBackfillFetchResponse.kt | 35 +- .../api/models/EventBackfillListPage.kt | 7 +- .../api/models/EventBackfillListPageAsync.kt | 7 +- .../models/EventBackfillListPageResponse.kt | 11 +- .../api/models/EventBackfillListParams.kt | 9 +- .../api/models/EventBackfillListResponse.kt | 35 +- .../api/models/EventBackfillRevertParams.kt | 9 +- .../api/models/EventBackfillRevertResponse.kt | 35 +- .../api/models/EventDeprecateParams.kt | 9 +- .../api/models/EventDeprecateResponse.kt | 6 +- .../withorb/api/models/EventIngestParams.kt | 43 +- .../withorb/api/models/EventIngestResponse.kt | 33 +- .../withorb/api/models/EventSearchParams.kt | 19 +- .../withorb/api/models/EventSearchResponse.kt | 35 +- .../withorb/api/models/EventUpdateParams.kt | 36 +- .../withorb/api/models/EventUpdateResponse.kt | 6 +- .../api/models/EventVolumeListParams.kt | 18 +- .../com/withorb/api/models/EventVolumes.kt | 18 +- .../api/models/ExpirationChangeLedgerEntry.kt | 47 +- .../models/FixedFeeQuantityScheduleEntry.kt | 13 +- .../api/models/FixedFeeQuantityTransition.kt | 12 +- .../api/models/IncrementLedgerEntry.kt | 47 +- .../kotlin/com/withorb/api/models/Invoice.kt | 277 +- .../withorb/api/models/InvoiceCreateParams.kt | 69 +- .../withorb/api/models/InvoiceFetchParams.kt | 7 +- .../api/models/InvoiceFetchUpcomingParams.kt | 8 +- .../models/InvoiceFetchUpcomingResponse.kt | 277 +- .../withorb/api/models/InvoiceIssueParams.kt | 15 +- .../api/models/InvoiceLevelDiscount.kt | 7 +- .../api/models/InvoiceLineItemCreateParams.kt | 30 +- .../models/InvoiceLineItemCreateResponse.kt | 72 +- .../com/withorb/api/models/InvoiceListPage.kt | 7 +- .../api/models/InvoiceListPageAsync.kt | 7 +- .../api/models/InvoiceListPageResponse.kt | 11 +- .../withorb/api/models/InvoiceListParams.kt | 52 +- .../api/models/InvoiceMarkPaidParams.kt | 21 +- .../withorb/api/models/InvoicePayParams.kt | 9 +- .../com/withorb/api/models/InvoiceTiny.kt | 6 +- .../withorb/api/models/InvoiceUpdateParams.kt | 19 +- .../withorb/api/models/InvoiceVoidParams.kt | 9 +- .../kotlin/com/withorb/api/models/Item.kt | 31 +- .../withorb/api/models/ItemArchiveParams.kt | 9 +- .../withorb/api/models/ItemCreateParams.kt | 18 +- .../com/withorb/api/models/ItemFetchParams.kt | 7 +- .../com/withorb/api/models/ItemListPage.kt | 7 +- .../withorb/api/models/ItemListPageAsync.kt | 7 +- .../api/models/ItemListPageResponse.kt | 11 +- .../com/withorb/api/models/ItemListParams.kt | 9 +- .../kotlin/com/withorb/api/models/ItemSlim.kt | 7 +- .../withorb/api/models/ItemUpdateParams.kt | 38 +- .../com/withorb/api/models/MatrixConfig.kt | 12 +- .../withorb/api/models/MatrixSubLineItem.kt | 17 +- .../com/withorb/api/models/MatrixValue.kt | 11 +- .../api/models/MatrixWithAllocationConfig.kt | 13 +- .../kotlin/com/withorb/api/models/Maximum.kt | 12 +- .../com/withorb/api/models/MaximumInterval.kt | 21 +- .../withorb/api/models/MetricCreateParams.kt | 25 +- .../withorb/api/models/MetricFetchParams.kt | 7 +- .../com/withorb/api/models/MetricListPage.kt | 7 +- .../withorb/api/models/MetricListPageAsync.kt | 7 +- .../api/models/MetricListPageResponse.kt | 11 +- .../withorb/api/models/MetricListParams.kt | 22 +- .../withorb/api/models/MetricUpdateParams.kt | 19 +- .../kotlin/com/withorb/api/models/Minimum.kt | 12 +- .../com/withorb/api/models/MinimumInterval.kt | 21 +- .../MonetaryAmountDiscountAdjustment.kt | 31 +- .../api/models/MonetaryMaximumAdjustment.kt | 31 +- .../api/models/MonetaryMinimumAdjustment.kt | 33 +- .../MonetaryPercentageDiscountAdjustment.kt | 31 +- .../models/MonetaryUsageDiscountAdjustment.kt | 31 +- .../withorb/api/models/MutatedSubscription.kt | 80 +- .../models/NewAccountingSyncConfiguration.kt | 11 +- .../withorb/api/models/NewAllocationPrice.kt | 23 +- .../withorb/api/models/NewAmountDiscount.kt | 35 +- .../api/models/NewAvalaraTaxConfiguration.kt | 14 +- .../models/NewBillingCycleConfiguration.kt | 9 +- .../NewDimensionalPriceConfiguration.kt | 17 +- .../withorb/api/models/NewFloatingBpsPrice.kt | 57 +- .../api/models/NewFloatingBulkBpsPrice.kt | 57 +- .../api/models/NewFloatingBulkPrice.kt | 57 +- .../NewFloatingBulkWithProrationPrice.kt | 62 +- .../NewFloatingCumulativeGroupedBulkPrice.kt | 62 +- .../NewFloatingGroupedAllocationPrice.kt | 62 +- .../NewFloatingGroupedTieredPackagePrice.kt | 62 +- .../models/NewFloatingGroupedTieredPrice.kt | 62 +- ...wFloatingGroupedWithMeteredMinimumPrice.kt | 62 +- ...FloatingGroupedWithProratedMinimumPrice.kt | 62 +- .../api/models/NewFloatingMatrixPrice.kt | 57 +- .../NewFloatingMatrixWithAllocationPrice.kt | 57 +- .../NewFloatingMatrixWithDisplayNamePrice.kt | 62 +- .../NewFloatingMaxGroupTieredPackagePrice.kt | 62 +- .../api/models/NewFloatingPackagePrice.kt | 57 +- .../NewFloatingPackageWithAllocationPrice.kt | 62 +- ...ingScalableMatrixWithTieredPricingPrice.kt | 62 +- ...atingScalableMatrixWithUnitPricingPrice.kt | 62 +- .../NewFloatingThresholdTotalAmountPrice.kt | 62 +- .../api/models/NewFloatingTieredBpsPrice.kt | 57 +- .../models/NewFloatingTieredPackagePrice.kt | 62 +- ...ewFloatingTieredPackageWithMinimumPrice.kt | 62 +- .../api/models/NewFloatingTieredPrice.kt | 57 +- .../NewFloatingTieredWithMinimumPrice.kt | 62 +- .../NewFloatingTieredWithProrationPrice.kt | 62 +- .../api/models/NewFloatingUnitPrice.kt | 57 +- .../models/NewFloatingUnitWithPercentPrice.kt | 62 +- .../NewFloatingUnitWithProrationPrice.kt | 62 +- .../com/withorb/api/models/NewMaximum.kt | 35 +- .../com/withorb/api/models/NewMinimum.kt | 37 +- .../api/models/NewPercentageDiscount.kt | 35 +- .../com/withorb/api/models/NewPlanBpsPrice.kt | 59 +- .../withorb/api/models/NewPlanBulkBpsPrice.kt | 59 +- .../withorb/api/models/NewPlanBulkPrice.kt | 59 +- .../models/NewPlanBulkWithProrationPrice.kt | 64 +- .../NewPlanCumulativeGroupedBulkPrice.kt | 64 +- .../models/NewPlanGroupedAllocationPrice.kt | 64 +- .../NewPlanGroupedTieredPackagePrice.kt | 64 +- .../api/models/NewPlanGroupedTieredPrice.kt | 64 +- .../NewPlanGroupedWithMeteredMinimumPrice.kt | 64 +- .../NewPlanGroupedWithProratedMinimumPrice.kt | 64 +- .../withorb/api/models/NewPlanMatrixPrice.kt | 59 +- .../NewPlanMatrixWithAllocationPrice.kt | 59 +- .../NewPlanMatrixWithDisplayNamePrice.kt | 64 +- .../NewPlanMaxGroupTieredPackagePrice.kt | 64 +- .../withorb/api/models/NewPlanPackagePrice.kt | 59 +- .../NewPlanPackageWithAllocationPrice.kt | 64 +- ...lanScalableMatrixWithTieredPricingPrice.kt | 64 +- ...wPlanScalableMatrixWithUnitPricingPrice.kt | 64 +- .../NewPlanThresholdTotalAmountPrice.kt | 64 +- .../models/NewPlanTierWithProrationPrice.kt | 64 +- .../api/models/NewPlanTieredBpsPrice.kt | 59 +- .../api/models/NewPlanTieredPackagePrice.kt | 64 +- .../NewPlanTieredPackageWithMinimumPrice.kt | 64 +- .../withorb/api/models/NewPlanTieredPrice.kt | 59 +- .../models/NewPlanTieredWithMinimumPrice.kt | 64 +- .../withorb/api/models/NewPlanUnitPrice.kt | 59 +- .../api/models/NewPlanUnitWithPercentPrice.kt | 64 +- .../models/NewPlanUnitWithProrationPrice.kt | 64 +- .../api/models/NewReportingConfiguration.kt | 6 +- .../api/models/NewSphereConfiguration.kt | 9 +- .../api/models/NewSubscriptionBpsPrice.kt | 59 +- .../api/models/NewSubscriptionBulkBpsPrice.kt | 59 +- .../api/models/NewSubscriptionBulkPrice.kt | 59 +- .../NewSubscriptionBulkWithProrationPrice.kt | 64 +- ...wSubscriptionCumulativeGroupedBulkPrice.kt | 64 +- .../NewSubscriptionGroupedAllocationPrice.kt | 64 +- ...ewSubscriptionGroupedTieredPackagePrice.kt | 64 +- .../NewSubscriptionGroupedTieredPrice.kt | 64 +- ...scriptionGroupedWithMeteredMinimumPrice.kt | 64 +- ...criptionGroupedWithProratedMinimumPrice.kt | 64 +- .../api/models/NewSubscriptionMatrixPrice.kt | 59 +- ...ewSubscriptionMatrixWithAllocationPrice.kt | 59 +- ...wSubscriptionMatrixWithDisplayNamePrice.kt | 64 +- ...wSubscriptionMaxGroupTieredPackagePrice.kt | 64 +- .../api/models/NewSubscriptionPackagePrice.kt | 59 +- ...wSubscriptionPackageWithAllocationPrice.kt | 64 +- ...ionScalableMatrixWithTieredPricingPrice.kt | 64 +- ...ptionScalableMatrixWithUnitPricingPrice.kt | 64 +- ...ewSubscriptionThresholdTotalAmountPrice.kt | 64 +- .../NewSubscriptionTierWithProrationPrice.kt | 64 +- .../models/NewSubscriptionTieredBpsPrice.kt | 59 +- .../NewSubscriptionTieredPackagePrice.kt | 64 +- ...bscriptionTieredPackageWithMinimumPrice.kt | 64 +- .../api/models/NewSubscriptionTieredPrice.kt | 59 +- .../NewSubscriptionTieredWithMinimumPrice.kt | 64 +- .../api/models/NewSubscriptionUnitPrice.kt | 59 +- .../NewSubscriptionUnitWithPercentPrice.kt | 64 +- .../NewSubscriptionUnitWithProrationPrice.kt | 64 +- .../api/models/NewTaxJarConfiguration.kt | 9 +- .../withorb/api/models/NewUsageDiscount.kt | 35 +- .../withorb/api/models/OtherSubLineItem.kt | 16 +- .../com/withorb/api/models/PackageConfig.kt | 11 +- .../withorb/api/models/PaginationMetadata.kt | 7 +- .../com/withorb/api/models/PerPriceCost.kt | 14 +- .../withorb/api/models/PercentageDiscount.kt | 23 +- .../api/models/PercentageDiscountInterval.kt | 25 +- .../kotlin/com/withorb/api/models/Plan.kt | 147 +- .../withorb/api/models/PlanCreateParams.kt | 164 +- .../models/PlanExternalPlanIdFetchParams.kt | 8 +- .../models/PlanExternalPlanIdUpdateParams.kt | 24 +- .../com/withorb/api/models/PlanFetchParams.kt | 7 +- .../com/withorb/api/models/PlanListPage.kt | 7 +- .../withorb/api/models/PlanListPageAsync.kt | 7 +- .../api/models/PlanListPageResponse.kt | 11 +- .../com/withorb/api/models/PlanListParams.kt | 26 +- .../PlanPhaseAmountDiscountAdjustment.kt | 31 +- .../api/models/PlanPhaseMaximumAdjustment.kt | 31 +- .../api/models/PlanPhaseMinimumAdjustment.kt | 33 +- .../PlanPhasePercentageDiscountAdjustment.kt | 31 +- .../PlanPhaseUsageDiscountAdjustment.kt | 31 +- .../withorb/api/models/PlanUpdateParams.kt | 24 +- .../com/withorb/api/models/PlanVersion.kt | 24 +- .../withorb/api/models/PlanVersionPhase.kt | 17 +- .../kotlin/com/withorb/api/models/Price.kt | 2398 ++++++++++++++--- .../withorb/api/models/PriceCreateParams.kt | 69 +- .../api/models/PriceEvaluateMultipleParams.kt | 111 +- .../models/PriceEvaluateMultipleResponse.kt | 27 +- .../withorb/api/models/PriceEvaluateParams.kt | 34 +- .../PriceEvaluatePreviewEventsParams.kt | 138 +- .../PriceEvaluatePreviewEventsResponse.kt | 27 +- .../api/models/PriceEvaluateResponse.kt | 6 +- .../models/PriceExternalPriceIdFetchParams.kt | 8 +- .../PriceExternalPriceIdUpdateParams.kt | 19 +- .../withorb/api/models/PriceFetchParams.kt | 7 +- .../com/withorb/api/models/PriceInterval.kt | 31 +- .../com/withorb/api/models/PriceListPage.kt | 7 +- .../withorb/api/models/PriceListPageAsync.kt | 7 +- .../api/models/PriceListPageResponse.kt | 11 +- .../com/withorb/api/models/PriceListParams.kt | 9 +- .../withorb/api/models/PriceUpdateParams.kt | 19 +- .../withorb/api/models/SubLineItemGrouping.kt | 7 +- .../api/models/SubLineItemMatrixConfig.kt | 6 +- .../com/withorb/api/models/Subscription.kt | 78 +- .../api/models/SubscriptionCancelParams.kt | 30 +- .../models/SubscriptionChangeApplyParams.kt | 20 +- .../models/SubscriptionChangeApplyResponse.kt | 25 +- .../models/SubscriptionChangeCancelParams.kt | 14 +- .../SubscriptionChangeCancelResponse.kt | 25 +- .../api/models/SubscriptionChangeMinified.kt | 6 +- .../SubscriptionChangeRetrieveParams.kt | 8 +- .../SubscriptionChangeRetrieveResponse.kt | 25 +- .../api/models/SubscriptionCreateParams.kt | 344 ++- .../models/SubscriptionFetchCostsParams.kt | 22 +- .../models/SubscriptionFetchCostsResponse.kt | 6 +- .../api/models/SubscriptionFetchParams.kt | 8 +- .../models/SubscriptionFetchSchedulePage.kt | 7 +- .../SubscriptionFetchSchedulePageAsync.kt | 7 +- .../SubscriptionFetchSchedulePageResponse.kt | 11 +- .../models/SubscriptionFetchScheduleParams.kt | 24 +- .../SubscriptionFetchScheduleResponse.kt | 25 +- .../models/SubscriptionFetchUsageParams.kt | 36 +- .../api/models/SubscriptionListPage.kt | 7 +- .../api/models/SubscriptionListPageAsync.kt | 7 +- .../api/models/SubscriptionListParams.kt | 30 +- .../api/models/SubscriptionMinified.kt | 6 +- .../SubscriptionPriceIntervalsParams.kt | 300 ++- .../models/SubscriptionRedeemCouponParams.kt | 34 +- .../SubscriptionSchedulePlanChangeParams.kt | 329 ++- .../api/models/SubscriptionTrialInfo.kt | 6 +- .../models/SubscriptionTriggerPhaseParams.kt | 20 +- ...ubscriptionUnscheduleCancellationParams.kt | 14 +- ...UnscheduleFixedFeeQuantityUpdatesParams.kt | 15 +- ...ptionUnschedulePendingPlanChangesParams.kt | 14 +- ...ubscriptionUpdateFixedFeeQuantityParams.kt | 34 +- .../api/models/SubscriptionUpdateParams.kt | 36 +- .../models/SubscriptionUpdateTrialParams.kt | 28 +- .../withorb/api/models/SubscriptionUsage.kt | 101 +- .../com/withorb/api/models/Subscriptions.kt | 11 +- .../com/withorb/api/models/TaxAmount.kt | 12 +- .../com/withorb/api/models/Threshold.kt | 6 +- .../kotlin/com/withorb/api/models/Tier.kt | 12 +- .../com/withorb/api/models/TierConfig.kt | 12 +- .../com/withorb/api/models/TierSubLineItem.kt | 17 +- .../com/withorb/api/models/TieredBpsConfig.kt | 6 +- .../com/withorb/api/models/TieredConfig.kt | 6 +- .../api/models/TieredConversionRateConfig.kt | 13 +- .../withorb/api/models/TopLevelPingParams.kt | 6 +- .../api/models/TopLevelPingResponse.kt | 6 +- .../api/models/TopUpInvoiceSettings.kt | 13 +- .../api/models/TransformPriceFilter.kt | 16 +- .../com/withorb/api/models/TrialDiscount.kt | 25 +- .../com/withorb/api/models/UnitConfig.kt | 6 +- .../api/models/UnitConversionRateConfig.kt | 13 +- .../com/withorb/api/models/UsageDiscount.kt | 23 +- .../api/models/UsageDiscountInterval.kt | 25 +- .../api/models/VoidInitiatedLedgerEntry.kt | 51 +- .../com/withorb/api/models/VoidLedgerEntry.kt | 49 +- orb-kotlin-example/build.gradle.kts | 2 +- orb-kotlin-proguard-test/build.gradle.kts | 2 - orb-kotlin-proguard-test/test.pro | 1 + scripts/build | 8 + scripts/format | 9 +- scripts/lint | 9 +- scripts/mock | 4 +- scripts/test | 4 +- settings.gradle.kts | 17 +- 440 files changed, 13741 insertions(+), 3521 deletions(-) create mode 100644 orb-kotlin-core/src/main/kotlin/com/withorb/api/core/PhantomReachableExecutorService.kt create mode 100755 scripts/build diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 53c50fd84..2faf62100 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -36,6 +36,31 @@ jobs: - name: Run lints run: ./scripts/lint + + build: + timeout-minutes: 15 + name: build + runs-on: ${{ github.repository == 'stainless-sdks/orb-kotlin' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }} + if: github.event_name == 'push' || github.event.pull_request.head.repo.fork + + steps: + - uses: actions/checkout@v4 + + - name: Set up Java + uses: actions/setup-java@v4 + with: + distribution: temurin + java-version: | + 8 + 21 + cache: gradle + + - name: Set up Gradle + uses: gradle/actions/setup-gradle@v4 + + - name: Build SDK + run: ./scripts/build + test: timeout-minutes: 15 name: test diff --git a/.github/workflows/publish-sonatype.yml b/.github/workflows/publish-sonatype.yml index 0265f1b1c..25e2ac851 100644 --- a/.github/workflows/publish-sonatype.yml +++ b/.github/workflows/publish-sonatype.yml @@ -33,7 +33,7 @@ jobs: export -- GPG_SIGNING_KEY_ID printenv -- GPG_SIGNING_KEY | gpg --batch --passphrase-fd 3 --import 3<<< "$GPG_SIGNING_PASSWORD" GPG_SIGNING_KEY_ID="$(gpg --with-colons --list-keys | awk -F : -- '/^pub:/ { getline; print "0x" substr($10, length($10) - 7) }')" - ./gradlew publishAndReleaseToMavenCentral -Dorg.gradle.jvmargs="-Xmx8g" --stacktrace -PmavenCentralUsername="$SONATYPE_USERNAME" -PmavenCentralPassword="$SONATYPE_PASSWORD" --no-configuration-cache + ./gradlew publishAndReleaseToMavenCentral --stacktrace -PmavenCentralUsername="$SONATYPE_USERNAME" -PmavenCentralPassword="$SONATYPE_PASSWORD" --no-configuration-cache env: SONATYPE_USERNAME: ${{ secrets.ORB_SONATYPE_USERNAME || secrets.SONATYPE_USERNAME }} SONATYPE_PASSWORD: ${{ secrets.ORB_SONATYPE_PASSWORD || secrets.SONATYPE_PASSWORD }} diff --git a/.gitignore b/.gitignore index 4e81838d6..b1346e6d1 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,6 @@ .gradle .idea .kotlin -build +build/ codegen.log kls_database.db diff --git a/build.gradle.kts b/build.gradle.kts index 26526fba0..81989492b 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -2,3 +2,15 @@ allprojects { group = "com.withorb.api" version = "1.11.0" // x-release-please-version } + +subprojects { + // These are populated with dependencies by `buildSrc` scripts. + tasks.register("format") { + group = "Verification" + description = "Formats all source files." + } + tasks.register("lint") { + group = "Verification" + description = "Verifies all source files are formatted." + } +} diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts index 778c89de5..c6dc92ec5 100644 --- a/buildSrc/build.gradle.kts +++ b/buildSrc/build.gradle.kts @@ -10,7 +10,6 @@ repositories { } dependencies { - implementation("com.diffplug.spotless:spotless-plugin-gradle:7.0.2") implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.20") implementation("com.vanniktech:gradle-maven-publish-plugin:0.28.0") } diff --git a/buildSrc/src/main/kotlin/orb.java.gradle.kts b/buildSrc/src/main/kotlin/orb.java.gradle.kts index dfbacb86e..70fc33f41 100644 --- a/buildSrc/src/main/kotlin/orb.java.gradle.kts +++ b/buildSrc/src/main/kotlin/orb.java.gradle.kts @@ -1,24 +1,13 @@ -import com.diffplug.gradle.spotless.SpotlessExtension import org.gradle.api.tasks.testing.logging.TestExceptionFormat plugins { `java-library` - id("com.diffplug.spotless") } repositories { mavenCentral() } -configure { - java { - importOrder() - removeUnusedImports() - palantirJavaFormat() - toggleOffOn() - } -} - java { toolchain { languageVersion.set(JavaLanguageVersion.of(21)) @@ -53,3 +42,86 @@ tasks.withType().configureEach { exceptionFormat = TestExceptionFormat.FULL } } + +val palantir by configurations.creating +dependencies { + palantir("com.palantir.javaformat:palantir-java-format:2.73.0") +} + +fun registerPalantir( + name: String, + description: String, +) { + val javaName = "${name}Java" + tasks.register(javaName) { + group = "Verification" + this.description = description + + classpath = palantir + mainClass = "com.palantir.javaformat.java.Main" + + // Avoid an `IllegalAccessError` on Java 9+. + jvmArgs( + "--add-exports", "jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED", + "--add-exports", "jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED", + "--add-exports", "jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED", + "--add-exports", "jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED", + "--add-exports", "jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED", + ) + + // Use paths relative to the current module. + val argumentFile = + project.layout.buildDirectory.file("palantir-$name-args.txt").get().asFile + val lastRunTimeFile = + project.layout.buildDirectory.file("palantir-$name-last-run.txt").get().asFile + + // Read the time when this task was last executed for this module (if ever). + val lastRunTime = lastRunTimeFile.takeIf { it.exists() }?.readText()?.toLongOrNull() ?: 0L + + // Use a `fileTree` relative to the module's source directory. + val javaFiles = project.fileTree("src") { include("**/*.java") } + + // Determine if any files need to be formatted or linted and continue only if there is at least + // one file. + onlyIf { javaFiles.any { it.lastModified() > lastRunTime } } + + inputs.files(javaFiles) + + doFirst { + // Create the argument file and set the preferred formatting style. + argumentFile.parentFile.mkdirs() + argumentFile.writeText("--palantir\n") + + if (name == "lint") { + // For lint, do a dry run, so no files are modified. Set the exit code to 1 (instead of + // the default 0) if any files need to be formatted, indicating that linting has failed. + argumentFile.appendText("--dry-run\n") + argumentFile.appendText("--set-exit-if-changed\n") + } else { + // `--dry-run` and `--replace` (for in-place formatting) are mutually exclusive. + argumentFile.appendText("--replace\n") + } + + // Write the modified files to the argument file. + javaFiles.filter { it.lastModified() > lastRunTime } + .forEach { argumentFile.appendText("${it.absolutePath}\n") } + } + + doLast { + // Record the last execution time for later up-to-date checking. + lastRunTimeFile.writeText(System.currentTimeMillis().toString()) + } + + // Pass the argument file using the @ symbol + args = listOf("@${argumentFile.absolutePath}") + + outputs.upToDateWhen { javaFiles.none { it.lastModified() > lastRunTime } } + } + + tasks.named(name) { + dependsOn(tasks.named(javaName)) + } +} + +registerPalantir(name = "format", description = "Formats all Java source files.") +registerPalantir(name = "lint", description = "Verifies all Java source files are formatted.") diff --git a/buildSrc/src/main/kotlin/orb.kotlin.gradle.kts b/buildSrc/src/main/kotlin/orb.kotlin.gradle.kts index 2d4a5c55c..b908b3bed 100644 --- a/buildSrc/src/main/kotlin/orb.kotlin.gradle.kts +++ b/buildSrc/src/main/kotlin/orb.kotlin.gradle.kts @@ -1,4 +1,3 @@ -import com.diffplug.gradle.spotless.SpotlessExtension import org.jetbrains.kotlin.gradle.dsl.JvmTarget import org.jetbrains.kotlin.gradle.dsl.KotlinVersion @@ -7,6 +6,10 @@ plugins { kotlin("jvm") } +repositories { + mavenCentral() +} + kotlin { jvmToolchain { languageVersion.set(JavaLanguageVersion.of(21)) @@ -27,14 +30,77 @@ kotlin { } } -configure { - kotlin { - ktfmt().kotlinlangStyle() - toggleOffOn() - } -} - tasks.withType().configureEach { systemProperty("junit.jupiter.execution.parallel.enabled", true) systemProperty("junit.jupiter.execution.parallel.mode.default", "concurrent") } + +val ktfmt by configurations.creating +dependencies { + ktfmt("com.facebook:ktfmt:0.56") +} + +fun registerKtfmt( + name: String, + description: String, +) { + val kotlinName = "${name}Kotlin" + tasks.register(kotlinName) { + group = "Verification" + this.description = description + + classpath = ktfmt + mainClass = "com.facebook.ktfmt.cli.Main" + + // Use paths relative to the current module. + val argumentFile = project.layout.buildDirectory.file("ktfmt-$name-args.txt").get().asFile + val lastRunTimeFile = + project.layout.buildDirectory.file("ktfmt-$name-last-run.txt").get().asFile + + // Read the time when this task was last executed for this module (if ever). + val lastRunTime = lastRunTimeFile.takeIf { it.exists() }?.readText()?.toLongOrNull() ?: 0L + + // Use a `fileTree` relative to the module's source directory. + val kotlinFiles = project.fileTree("src") { include("**/*.kt") } + + // Determine if any files need to be formatted or linted and continue only if there is at least + // one file (otherwise Ktfmt will fail). + onlyIf { kotlinFiles.any { it.lastModified() > lastRunTime } } + + inputs.files(kotlinFiles) + + doFirst { + // Create the argument file and set the preferred formatting style. + argumentFile.parentFile.mkdirs() + argumentFile.writeText("--kotlinlang-style\n") + + if (name == "lint") { + // For lint, do a dry run, so no files are modified. Set the exit code to 1 (instead of + // the default 0) if any files need to be formatted, indicating that linting has failed. + argumentFile.appendText("--dry-run\n") + argumentFile.appendText("--set-exit-if-changed\n") + } + + // Write the modified files to the argument file. + kotlinFiles.filter { it.lastModified() > lastRunTime } + .forEach { argumentFile.appendText("${it.absolutePath}\n") } + } + + doLast { + // Record the last execution time for later up-to-date checking. + lastRunTimeFile.writeText(System.currentTimeMillis().toString()) + } + + // Pass the argument file using the @ symbol + args = listOf("@${argumentFile.absolutePath}") + + outputs.upToDateWhen { kotlinFiles.none { it.lastModified() > lastRunTime } } + } + + tasks.named(name) { + dependsOn(tasks.named(kotlinName)) + } +} + +registerKtfmt(name = "format", description = "Formats all Kotlin source files.") +registerKtfmt(name = "lint", description = "Verifies all Kotlin source files are formatted.") diff --git a/gradle.properties b/gradle.properties index ff76593f6..6680f9ce9 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,12 +4,13 @@ org.gradle.parallel=true org.gradle.daemon=false # These options improve our compilation and test performance. They are inherited by the Kotlin daemon. org.gradle.jvmargs=\ - -Xms1g \ - -Xmx4g \ + -Xms2g \ + -Xmx8g \ -XX:+UseParallelGC \ -XX:InitialCodeCacheSize=256m \ -XX:ReservedCodeCacheSize=1G \ - -XX:MetaspaceSize=256m \ + -XX:MetaspaceSize=512m \ + -XX:MaxMetaspaceSize=2G \ -XX:TieredStopAtLevel=1 \ -XX:GCTimeRatio=4 \ -XX:CICompilerCount=4 \ diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/client/OrbClientAsyncImpl.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/client/OrbClientAsyncImpl.kt index f8e4e3018..33eade7ef 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/client/OrbClientAsyncImpl.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/client/OrbClientAsyncImpl.kt @@ -152,7 +152,7 @@ class OrbClientAsyncImpl(private val clientOptions: ClientOptions) : OrbClientAs override fun subscriptionChanges(): SubscriptionChangeServiceAsync = subscriptionChanges - override fun close() = clientOptions.httpClient.close() + override fun close() = clientOptions.close() class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : OrbClientAsync.WithRawResponse { diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/client/OrbClientImpl.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/client/OrbClientImpl.kt index c5937e469..3d8a11b6e 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/client/OrbClientImpl.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/client/OrbClientImpl.kt @@ -145,7 +145,7 @@ class OrbClientImpl(private val clientOptions: ClientOptions) : OrbClient { override fun subscriptionChanges(): SubscriptionChangeService = subscriptionChanges - override fun close() = clientOptions.httpClient.close() + override fun close() = clientOptions.close() class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : OrbClient.WithRawResponse { diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/core/ClientOptions.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/core/ClientOptions.kt index b18610e24..705f9308c 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/core/ClientOptions.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/core/ClientOptions.kt @@ -19,6 +19,8 @@ private constructor( * The HTTP client to use in the SDK. * * Use the one published in `orb-kotlin-client-okhttp` or implement your own. + * + * This class takes ownership of the client and closes it when closed. */ val httpClient: HttpClient, /** @@ -156,6 +158,8 @@ private constructor( * The HTTP client to use in the SDK. * * Use the one published in `orb-kotlin-client-okhttp` or implement your own. + * + * This class takes ownership of the client and closes it when closed. */ fun httpClient(httpClient: HttpClient) = apply { this.httpClient = PhantomReachableClosingHttpClient(httpClient) @@ -405,4 +409,18 @@ private constructor( ) } } + + /** + * Closes these client options, relinquishing any underlying resources. + * + * This is purposefully not inherited from [AutoCloseable] because the client options are + * long-lived and usually should not be synchronously closed via try-with-resources. + * + * It's also usually not necessary to call this method at all. the default client automatically + * releases threads and connections if they remain idle, but if you are writing an application + * that needs to aggressively release unused resources, then you may call this method. + */ + fun close() { + httpClient.close() + } } diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/core/PhantomReachableExecutorService.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/core/PhantomReachableExecutorService.kt new file mode 100644 index 000000000..b4617be28 --- /dev/null +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/core/PhantomReachableExecutorService.kt @@ -0,0 +1,58 @@ +package com.withorb.api.core + +import java.util.concurrent.Callable +import java.util.concurrent.ExecutorService +import java.util.concurrent.Future +import java.util.concurrent.TimeUnit + +/** + * A delegating wrapper around an [ExecutorService] that shuts it down once it's only phantom + * reachable. + * + * This class ensures the [ExecutorService] is shut down even if the user forgets to do it. + */ +internal class PhantomReachableExecutorService(private val executorService: ExecutorService) : + ExecutorService { + init { + closeWhenPhantomReachable(this) { executorService.shutdown() } + } + + override fun execute(command: Runnable) = executorService.execute(command) + + override fun shutdown() = executorService.shutdown() + + override fun shutdownNow(): MutableList = executorService.shutdownNow() + + override fun isShutdown(): Boolean = executorService.isShutdown + + override fun isTerminated(): Boolean = executorService.isTerminated + + override fun awaitTermination(timeout: Long, unit: TimeUnit): Boolean = + executorService.awaitTermination(timeout, unit) + + override fun submit(task: Callable): Future = executorService.submit(task) + + override fun submit(task: Runnable, result: T): Future = + executorService.submit(task, result) + + override fun submit(task: Runnable): Future<*> = executorService.submit(task) + + override fun invokeAll( + tasks: MutableCollection> + ): MutableList> = executorService.invokeAll(tasks) + + override fun invokeAll( + tasks: MutableCollection>, + timeout: Long, + unit: TimeUnit, + ): MutableList> = executorService.invokeAll(tasks, timeout, unit) + + override fun invokeAny(tasks: MutableCollection>): T = + executorService.invokeAny(tasks) + + override fun invokeAny( + tasks: MutableCollection>, + timeout: Long, + unit: TimeUnit, + ): T = executorService.invokeAny(tasks, timeout, unit) +} diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/core/Timeout.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/core/Timeout.kt index e5ed8356e..aa60df127 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/core/Timeout.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/core/Timeout.kt @@ -141,10 +141,14 @@ private constructor( return true } - return /* spotless:off */ other is Timeout && connect == other.connect && read == other.read && write == other.write && request == other.request /* spotless:on */ + return other is Timeout && + connect == other.connect && + read == other.read && + write == other.write && + request == other.request } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(connect, read, write, request) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(connect, read, write, request) override fun toString() = "Timeout{connect=$connect, read=$read, write=$write, request=$request}" diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/core/Utils.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/core/Utils.kt index 41ae5d3c4..597e7de7f 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/core/Utils.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/core/Utils.kt @@ -6,6 +6,7 @@ import com.withorb.api.core.http.Headers import com.withorb.api.errors.OrbInvalidDataException import java.util.Collections import java.util.SortedMap +import java.util.concurrent.locks.Lock internal fun T?.getOrThrow(name: String): T = this ?: throw OrbInvalidDataException("`${name}` is not present") @@ -87,3 +88,19 @@ internal fun Headers.getRequiredHeader(name: String): String = values(name).firstOrNull() ?: throw OrbInvalidDataException("Could not find $name header") internal interface Enum + +/** + * Executes a suspending block of code while holding this lock. + * + * @param T the return type of the action + * @param action the suspending function to execute while holding the lock + * @return the result of executing the action + */ +internal suspend fun Lock.withLockAsync(action: suspend () -> T): T { + lock() + return try { + action() + } finally { + unlock() + } +} diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/AccountingProviderConfig.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/AccountingProviderConfig.kt index c88d31918..6f0112ce8 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/AccountingProviderConfig.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/AccountingProviderConfig.kt @@ -203,12 +203,15 @@ private constructor( return true } - return /* spotless:off */ other is AccountingProviderConfig && externalProviderId == other.externalProviderId && providerType == other.providerType && additionalProperties == other.additionalProperties /* spotless:on */ + return other is AccountingProviderConfig && + externalProviderId == other.externalProviderId && + providerType == other.providerType && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(externalProviderId, providerType, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash(externalProviderId, providerType, additionalProperties) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Address.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Address.kt index 61ba0c965..5ea66523f 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Address.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Address.kt @@ -318,12 +318,19 @@ private constructor( return true } - return /* spotless:off */ other is Address && city == other.city && country == other.country && line1 == other.line1 && line2 == other.line2 && postalCode == other.postalCode && state == other.state && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Address && + city == other.city && + country == other.country && + line1 == other.line1 && + line2 == other.line2 && + postalCode == other.postalCode && + state == other.state && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(city, country, line1, line2, postalCode, state, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash(city, country, line1, line2, postalCode, state, additionalProperties) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/AddressInput.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/AddressInput.kt index b833dff70..2aa876645 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/AddressInput.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/AddressInput.kt @@ -293,12 +293,19 @@ private constructor( return true } - return /* spotless:off */ other is AddressInput && city == other.city && country == other.country && line1 == other.line1 && line2 == other.line2 && postalCode == other.postalCode && state == other.state && additionalProperties == other.additionalProperties /* spotless:on */ + return other is AddressInput && + city == other.city && + country == other.country && + line1 == other.line1 && + line2 == other.line2 && + postalCode == other.postalCode && + state == other.state && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(city, country, line1, line2, postalCode, state, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash(city, country, line1, line2, postalCode, state, additionalProperties) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/AdjustmentInterval.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/AdjustmentInterval.kt index fde27ce87..00de333b1 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/AdjustmentInterval.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/AdjustmentInterval.kt @@ -501,10 +501,16 @@ private constructor( return true } - return /* spotless:off */ other is Adjustment && usageDiscount == other.usageDiscount && amountDiscount == other.amountDiscount && percentageDiscount == other.percentageDiscount && minimum == other.minimum && maximum == other.maximum /* spotless:on */ + return other is Adjustment && + usageDiscount == other.usageDiscount && + amountDiscount == other.amountDiscount && + percentageDiscount == other.percentageDiscount && + minimum == other.minimum && + maximum == other.maximum } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(usageDiscount, amountDiscount, percentageDiscount, minimum, maximum) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash(usageDiscount, amountDiscount, percentageDiscount, minimum, maximum) override fun toString(): String = when { @@ -638,12 +644,25 @@ private constructor( return true } - return /* spotless:off */ other is AdjustmentInterval && id == other.id && adjustment == other.adjustment && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && endDate == other.endDate && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ + return other is AdjustmentInterval && + id == other.id && + adjustment == other.adjustment && + appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && + endDate == other.endDate && + startDate == other.startDate && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, adjustment, appliesToPriceIntervalIds, endDate, startDate, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + id, + adjustment, + appliesToPriceIntervalIds, + endDate, + startDate, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/AffectedBlock.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/AffectedBlock.kt index 11b10c291..49e3f7acb 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/AffectedBlock.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/AffectedBlock.kt @@ -236,12 +236,16 @@ private constructor( return true } - return /* spotless:off */ other is AffectedBlock && id == other.id && expiryDate == other.expiryDate && perUnitCostBasis == other.perUnitCostBasis && additionalProperties == other.additionalProperties /* spotless:on */ + return other is AffectedBlock && + id == other.id && + expiryDate == other.expiryDate && + perUnitCostBasis == other.perUnitCostBasis && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, expiryDate, perUnitCostBasis, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash(id, expiryDate, perUnitCostBasis, additionalProperties) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/AggregatedCost.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/AggregatedCost.kt index 1ed38a320..fa60381c2 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/AggregatedCost.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/AggregatedCost.kt @@ -327,12 +327,25 @@ private constructor( return true } - return /* spotless:off */ other is AggregatedCost && perPriceCosts == other.perPriceCosts && subtotal == other.subtotal && timeframeEnd == other.timeframeEnd && timeframeStart == other.timeframeStart && total == other.total && additionalProperties == other.additionalProperties /* spotless:on */ + return other is AggregatedCost && + perPriceCosts == other.perPriceCosts && + subtotal == other.subtotal && + timeframeEnd == other.timeframeEnd && + timeframeStart == other.timeframeStart && + total == other.total && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(perPriceCosts, subtotal, timeframeEnd, timeframeStart, total, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + perPriceCosts, + subtotal, + timeframeEnd, + timeframeStart, + total, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Alert.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Alert.kt index 08a5ca1fc..fe13e7cdd 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Alert.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Alert.kt @@ -724,12 +724,12 @@ private constructor( return true } - return /* spotless:off */ other is Metric && id == other.id && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Metric && + id == other.id && + additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(id, additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1001,12 +1001,17 @@ private constructor( return true } - return /* spotless:off */ other is Plan && id == other.id && externalPlanId == other.externalPlanId && name == other.name && planVersion == other.planVersion && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Plan && + id == other.id && + externalPlanId == other.externalPlanId && + name == other.name && + planVersion == other.planVersion && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, externalPlanId, name, planVersion, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash(id, externalPlanId, name, planVersion, additionalProperties) + } override fun hashCode(): Int = hashCode @@ -1149,7 +1154,7 @@ private constructor( return true } - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + return other is Type && value == other.value } override fun hashCode() = value.hashCode() @@ -1349,12 +1354,15 @@ private constructor( return true } - return /* spotless:off */ other is BalanceAlertStatus && inAlert == other.inAlert && thresholdValue == other.thresholdValue && additionalProperties == other.additionalProperties /* spotless:on */ + return other is BalanceAlertStatus && + inAlert == other.inAlert && + thresholdValue == other.thresholdValue && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(inAlert, thresholdValue, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash(inAlert, thresholdValue, additionalProperties) + } override fun hashCode(): Int = hashCode @@ -1367,12 +1375,37 @@ private constructor( return true } - return /* spotless:off */ other is Alert && id == other.id && createdAt == other.createdAt && currency == other.currency && customer == other.customer && enabled == other.enabled && metric == other.metric && plan == other.plan && subscription == other.subscription && thresholds == other.thresholds && type == other.type && balanceAlertStatus == other.balanceAlertStatus && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Alert && + id == other.id && + createdAt == other.createdAt && + currency == other.currency && + customer == other.customer && + enabled == other.enabled && + metric == other.metric && + plan == other.plan && + subscription == other.subscription && + thresholds == other.thresholds && + type == other.type && + balanceAlertStatus == other.balanceAlertStatus && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, createdAt, currency, customer, enabled, metric, plan, subscription, thresholds, type, balanceAlertStatus, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + id, + createdAt, + currency, + customer, + enabled, + metric, + plan, + subscription, + thresholds, + type, + balanceAlertStatus, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/AlertCreateForCustomerParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/AlertCreateForCustomerParams.kt index 5caf6d7e4..eca8723ac 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/AlertCreateForCustomerParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/AlertCreateForCustomerParams.kt @@ -566,12 +566,16 @@ private constructor( return true } - return /* spotless:off */ other is Body && currency == other.currency && type == other.type && thresholds == other.thresholds && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Body && + currency == other.currency && + type == other.type && + thresholds == other.thresholds && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(currency, type, thresholds, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash(currency, type, thresholds, additionalProperties) + } override fun hashCode(): Int = hashCode @@ -702,7 +706,7 @@ private constructor( return true } - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + return other is Type && value == other.value } override fun hashCode() = value.hashCode() @@ -715,10 +719,15 @@ private constructor( return true } - return /* spotless:off */ other is AlertCreateForCustomerParams && customerId == other.customerId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return other is AlertCreateForCustomerParams && + customerId == other.customerId && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(customerId, body, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash(customerId, body, additionalHeaders, additionalQueryParams) override fun toString() = "AlertCreateForCustomerParams{customerId=$customerId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/AlertCreateForExternalCustomerParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/AlertCreateForExternalCustomerParams.kt index 0a34fcc70..c5069db66 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/AlertCreateForExternalCustomerParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/AlertCreateForExternalCustomerParams.kt @@ -572,12 +572,16 @@ private constructor( return true } - return /* spotless:off */ other is Body && currency == other.currency && type == other.type && thresholds == other.thresholds && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Body && + currency == other.currency && + type == other.type && + thresholds == other.thresholds && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(currency, type, thresholds, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash(currency, type, thresholds, additionalProperties) + } override fun hashCode(): Int = hashCode @@ -708,7 +712,7 @@ private constructor( return true } - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + return other is Type && value == other.value } override fun hashCode() = value.hashCode() @@ -721,10 +725,15 @@ private constructor( return true } - return /* spotless:off */ other is AlertCreateForExternalCustomerParams && externalCustomerId == other.externalCustomerId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return other is AlertCreateForExternalCustomerParams && + externalCustomerId == other.externalCustomerId && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(externalCustomerId, body, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash(externalCustomerId, body, additionalHeaders, additionalQueryParams) override fun toString() = "AlertCreateForExternalCustomerParams{externalCustomerId=$externalCustomerId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/AlertCreateForSubscriptionParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/AlertCreateForSubscriptionParams.kt index 04771b7cc..380352c36 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/AlertCreateForSubscriptionParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/AlertCreateForSubscriptionParams.kt @@ -572,12 +572,16 @@ private constructor( return true } - return /* spotless:off */ other is Body && thresholds == other.thresholds && type == other.type && metricId == other.metricId && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Body && + thresholds == other.thresholds && + type == other.type && + metricId == other.metricId && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(thresholds, type, metricId, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash(thresholds, type, metricId, additionalProperties) + } override fun hashCode(): Int = hashCode @@ -702,7 +706,7 @@ private constructor( return true } - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + return other is Type && value == other.value } override fun hashCode() = value.hashCode() @@ -715,10 +719,15 @@ private constructor( return true } - return /* spotless:off */ other is AlertCreateForSubscriptionParams && subscriptionId == other.subscriptionId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return other is AlertCreateForSubscriptionParams && + subscriptionId == other.subscriptionId && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(subscriptionId, body, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash(subscriptionId, body, additionalHeaders, additionalQueryParams) override fun toString() = "AlertCreateForSubscriptionParams{subscriptionId=$subscriptionId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/AlertDisableParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/AlertDisableParams.kt index 6dc4a86e2..11e03283a 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/AlertDisableParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/AlertDisableParams.kt @@ -229,10 +229,22 @@ private constructor( return true } - return /* spotless:off */ other is AlertDisableParams && alertConfigurationId == other.alertConfigurationId && subscriptionId == other.subscriptionId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return other is AlertDisableParams && + alertConfigurationId == other.alertConfigurationId && + subscriptionId == other.subscriptionId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(alertConfigurationId, subscriptionId, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash( + alertConfigurationId, + subscriptionId, + additionalHeaders, + additionalQueryParams, + additionalBodyProperties, + ) override fun toString() = "AlertDisableParams{alertConfigurationId=$alertConfigurationId, subscriptionId=$subscriptionId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/AlertEnableParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/AlertEnableParams.kt index a57c1d49c..d92459458 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/AlertEnableParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/AlertEnableParams.kt @@ -229,10 +229,22 @@ private constructor( return true } - return /* spotless:off */ other is AlertEnableParams && alertConfigurationId == other.alertConfigurationId && subscriptionId == other.subscriptionId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return other is AlertEnableParams && + alertConfigurationId == other.alertConfigurationId && + subscriptionId == other.subscriptionId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(alertConfigurationId, subscriptionId, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash( + alertConfigurationId, + subscriptionId, + additionalHeaders, + additionalQueryParams, + additionalBodyProperties, + ) override fun toString() = "AlertEnableParams{alertConfigurationId=$alertConfigurationId, subscriptionId=$subscriptionId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/AlertListPage.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/AlertListPage.kt index 684d17838..66c75b6b5 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/AlertListPage.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/AlertListPage.kt @@ -119,10 +119,13 @@ private constructor( return true } - return /* spotless:off */ other is AlertListPage && service == other.service && params == other.params && response == other.response /* spotless:on */ + return other is AlertListPage && + service == other.service && + params == other.params && + response == other.response } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, params, response) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(service, params, response) override fun toString() = "AlertListPage{service=$service, params=$params, response=$response}" } diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/AlertListPageAsync.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/AlertListPageAsync.kt index e4e0ec4ba..1376c6cdf 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/AlertListPageAsync.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/AlertListPageAsync.kt @@ -119,10 +119,13 @@ private constructor( return true } - return /* spotless:off */ other is AlertListPageAsync && service == other.service && params == other.params && response == other.response /* spotless:on */ + return other is AlertListPageAsync && + service == other.service && + params == other.params && + response == other.response } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, params, response) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(service, params, response) override fun toString() = "AlertListPageAsync{service=$service, params=$params, response=$response}" diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/AlertListPageResponse.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/AlertListPageResponse.kt index 7921cc09f..74c818258 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/AlertListPageResponse.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/AlertListPageResponse.kt @@ -214,12 +214,15 @@ private constructor( return true } - return /* spotless:off */ other is AlertListPageResponse && data == other.data && paginationMetadata == other.paginationMetadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is AlertListPageResponse && + data == other.data && + paginationMetadata == other.paginationMetadata && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(data, paginationMetadata, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash(data, paginationMetadata, additionalProperties) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/AlertListParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/AlertListParams.kt index 5adbae16b..2e9758e18 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/AlertListParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/AlertListParams.kt @@ -291,10 +291,34 @@ private constructor( return true } - return /* spotless:off */ other is AlertListParams && createdAtGt == other.createdAtGt && createdAtGte == other.createdAtGte && createdAtLt == other.createdAtLt && createdAtLte == other.createdAtLte && cursor == other.cursor && customerId == other.customerId && externalCustomerId == other.externalCustomerId && limit == other.limit && subscriptionId == other.subscriptionId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return other is AlertListParams && + createdAtGt == other.createdAtGt && + createdAtGte == other.createdAtGte && + createdAtLt == other.createdAtLt && + createdAtLte == other.createdAtLte && + cursor == other.cursor && + customerId == other.customerId && + externalCustomerId == other.externalCustomerId && + limit == other.limit && + subscriptionId == other.subscriptionId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(createdAtGt, createdAtGte, createdAtLt, createdAtLte, cursor, customerId, externalCustomerId, limit, subscriptionId, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash( + createdAtGt, + createdAtGte, + createdAtLt, + createdAtLte, + cursor, + customerId, + externalCustomerId, + limit, + subscriptionId, + additionalHeaders, + additionalQueryParams, + ) override fun toString() = "AlertListParams{createdAtGt=$createdAtGt, createdAtGte=$createdAtGte, createdAtLt=$createdAtLt, createdAtLte=$createdAtLte, cursor=$cursor, customerId=$customerId, externalCustomerId=$externalCustomerId, limit=$limit, subscriptionId=$subscriptionId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/AlertRetrieveParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/AlertRetrieveParams.kt index aa8516268..2a465a67b 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/AlertRetrieveParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/AlertRetrieveParams.kt @@ -170,10 +170,13 @@ private constructor( return true } - return /* spotless:off */ other is AlertRetrieveParams && alertId == other.alertId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return other is AlertRetrieveParams && + alertId == other.alertId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(alertId, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(alertId, additionalHeaders, additionalQueryParams) override fun toString() = "AlertRetrieveParams{alertId=$alertId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/AlertUpdateParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/AlertUpdateParams.kt index 9c3d35214..e2572f113 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/AlertUpdateParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/AlertUpdateParams.kt @@ -430,12 +430,12 @@ private constructor( return true } - return /* spotless:off */ other is Body && thresholds == other.thresholds && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Body && + thresholds == other.thresholds && + additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(thresholds, additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -448,10 +448,15 @@ private constructor( return true } - return /* spotless:off */ other is AlertUpdateParams && alertConfigurationId == other.alertConfigurationId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return other is AlertUpdateParams && + alertConfigurationId == other.alertConfigurationId && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(alertConfigurationId, body, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash(alertConfigurationId, body, additionalHeaders, additionalQueryParams) override fun toString() = "AlertUpdateParams{alertConfigurationId=$alertConfigurationId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Allocation.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Allocation.kt index 4cea3f8d3..77c2ccb5b 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Allocation.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Allocation.kt @@ -235,12 +235,16 @@ private constructor( return true } - return /* spotless:off */ other is Allocation && allowsRollover == other.allowsRollover && currency == other.currency && customExpiration == other.customExpiration && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Allocation && + allowsRollover == other.allowsRollover && + currency == other.currency && + customExpiration == other.customExpiration && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(allowsRollover, currency, customExpiration, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash(allowsRollover, currency, customExpiration, additionalProperties) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/AmendmentLedgerEntry.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/AmendmentLedgerEntry.kt index 518f4f6d7..467678df1 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/AmendmentLedgerEntry.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/AmendmentLedgerEntry.kt @@ -735,7 +735,7 @@ private constructor( return true } - return /* spotless:off */ other is EntryStatus && value == other.value /* spotless:on */ + return other is EntryStatus && value == other.value } override fun hashCode() = value.hashCode() @@ -855,7 +855,7 @@ private constructor( return true } - return /* spotless:off */ other is EntryType && value == other.value /* spotless:on */ + return other is EntryType && value == other.value } override fun hashCode() = value.hashCode() @@ -955,12 +955,10 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -972,12 +970,41 @@ private constructor( return true } - return /* spotless:off */ other is AmendmentLedgerEntry && id == other.id && amount == other.amount && createdAt == other.createdAt && creditBlock == other.creditBlock && currency == other.currency && customer == other.customer && description == other.description && endingBalance == other.endingBalance && entryStatus == other.entryStatus && entryType == other.entryType && ledgerSequenceNumber == other.ledgerSequenceNumber && metadata == other.metadata && startingBalance == other.startingBalance && additionalProperties == other.additionalProperties /* spotless:on */ + return other is AmendmentLedgerEntry && + id == other.id && + amount == other.amount && + createdAt == other.createdAt && + creditBlock == other.creditBlock && + currency == other.currency && + customer == other.customer && + description == other.description && + endingBalance == other.endingBalance && + entryStatus == other.entryStatus && + entryType == other.entryType && + ledgerSequenceNumber == other.ledgerSequenceNumber && + metadata == other.metadata && + startingBalance == other.startingBalance && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, amount, createdAt, creditBlock, currency, customer, description, endingBalance, entryStatus, entryType, ledgerSequenceNumber, metadata, startingBalance, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + id, + amount, + createdAt, + creditBlock, + currency, + customer, + description, + endingBalance, + entryStatus, + entryType, + ledgerSequenceNumber, + metadata, + startingBalance, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/AmountDiscount.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/AmountDiscount.kt index 6fbf2c402..c386552e8 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/AmountDiscount.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/AmountDiscount.kt @@ -455,7 +455,7 @@ private constructor( return true } - return /* spotless:off */ other is DiscountType && value == other.value /* spotless:on */ + return other is DiscountType && value == other.value } override fun hashCode() = value.hashCode() @@ -468,12 +468,25 @@ private constructor( return true } - return /* spotless:off */ other is AmountDiscount && amountDiscount == other.amountDiscount && discountType == other.discountType && appliesToPriceIds == other.appliesToPriceIds && filters == other.filters && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ + return other is AmountDiscount && + amountDiscount == other.amountDiscount && + discountType == other.discountType && + appliesToPriceIds == other.appliesToPriceIds && + filters == other.filters && + reason == other.reason && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(amountDiscount, discountType, appliesToPriceIds, filters, reason, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + amountDiscount, + discountType, + appliesToPriceIds, + filters, + reason, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/AmountDiscountInterval.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/AmountDiscountInterval.kt index 87da187c2..d8b903e3d 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/AmountDiscountInterval.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/AmountDiscountInterval.kt @@ -516,7 +516,7 @@ private constructor( return true } - return /* spotless:off */ other is DiscountType && value == other.value /* spotless:on */ + return other is DiscountType && value == other.value } override fun hashCode() = value.hashCode() @@ -529,12 +529,27 @@ private constructor( return true } - return /* spotless:off */ other is AmountDiscountInterval && amountDiscount == other.amountDiscount && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && discountType == other.discountType && endDate == other.endDate && filters == other.filters && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ + return other is AmountDiscountInterval && + amountDiscount == other.amountDiscount && + appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && + discountType == other.discountType && + endDate == other.endDate && + filters == other.filters && + startDate == other.startDate && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(amountDiscount, appliesToPriceIntervalIds, discountType, endDate, filters, startDate, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + amountDiscount, + appliesToPriceIntervalIds, + discountType, + endDate, + filters, + startDate, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BetaCreatePlanVersionParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BetaCreatePlanVersionParams.kt index 1b81c066b..db4dd0f68 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BetaCreatePlanVersionParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BetaCreatePlanVersionParams.kt @@ -1074,12 +1074,31 @@ private constructor( return true } - return /* spotless:off */ other is Body && version == other.version && addAdjustments == other.addAdjustments && addPrices == other.addPrices && removeAdjustments == other.removeAdjustments && removePrices == other.removePrices && replaceAdjustments == other.replaceAdjustments && replacePrices == other.replacePrices && setAsDefault == other.setAsDefault && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Body && + version == other.version && + addAdjustments == other.addAdjustments && + addPrices == other.addPrices && + removeAdjustments == other.removeAdjustments && + removePrices == other.removePrices && + replaceAdjustments == other.replaceAdjustments && + replacePrices == other.replacePrices && + setAsDefault == other.setAsDefault && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(version, addAdjustments, addPrices, removeAdjustments, removePrices, replaceAdjustments, replacePrices, setAsDefault, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + version, + addAdjustments, + addPrices, + removeAdjustments, + removePrices, + replaceAdjustments, + replacePrices, + setAsDefault, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode @@ -1505,10 +1524,16 @@ private constructor( return true } - return /* spotless:off */ other is Adjustment && percentageDiscount == other.percentageDiscount && usageDiscount == other.usageDiscount && amountDiscount == other.amountDiscount && minimum == other.minimum && maximum == other.maximum /* spotless:on */ + return other is Adjustment && + percentageDiscount == other.percentageDiscount && + usageDiscount == other.usageDiscount && + amountDiscount == other.amountDiscount && + minimum == other.minimum && + maximum == other.maximum } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(percentageDiscount, usageDiscount, amountDiscount, minimum, maximum) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash(percentageDiscount, usageDiscount, amountDiscount, minimum, maximum) override fun toString(): String = when { @@ -1633,12 +1658,15 @@ private constructor( return true } - return /* spotless:off */ other is AddAdjustment && adjustment == other.adjustment && planPhaseOrder == other.planPhaseOrder && additionalProperties == other.additionalProperties /* spotless:on */ + return other is AddAdjustment && + adjustment == other.adjustment && + planPhaseOrder == other.planPhaseOrder && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(adjustment, planPhaseOrder, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash(adjustment, planPhaseOrder, additionalProperties) + } override fun hashCode(): Int = hashCode @@ -2571,10 +2599,68 @@ private constructor( return true } - return /* spotless:off */ other is Price && unit == other.unit && package_ == other.package_ && matrix == other.matrix && tiered == other.tiered && tieredBps == other.tieredBps && bps == other.bps && bulkBps == other.bulkBps && bulk == other.bulk && thresholdTotalAmount == other.thresholdTotalAmount && tieredPackage == other.tieredPackage && tieredWithMinimum == other.tieredWithMinimum && unitWithPercent == other.unitWithPercent && packageWithAllocation == other.packageWithAllocation && tieredWithProration == other.tieredWithProration && unitWithProration == other.unitWithProration && groupedAllocation == other.groupedAllocation && groupedWithProratedMinimum == other.groupedWithProratedMinimum && groupedWithMeteredMinimum == other.groupedWithMeteredMinimum && matrixWithDisplayName == other.matrixWithDisplayName && bulkWithProration == other.bulkWithProration && groupedTieredPackage == other.groupedTieredPackage && maxGroupTieredPackage == other.maxGroupTieredPackage && scalableMatrixWithUnitPricing == other.scalableMatrixWithUnitPricing && scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && cumulativeGroupedBulk == other.cumulativeGroupedBulk && tieredPackageWithMinimum == other.tieredPackageWithMinimum && matrixWithAllocation == other.matrixWithAllocation && groupedTiered == other.groupedTiered /* spotless:on */ + return other is Price && + unit == other.unit && + package_ == other.package_ && + matrix == other.matrix && + tiered == other.tiered && + tieredBps == other.tieredBps && + bps == other.bps && + bulkBps == other.bulkBps && + bulk == other.bulk && + thresholdTotalAmount == other.thresholdTotalAmount && + tieredPackage == other.tieredPackage && + tieredWithMinimum == other.tieredWithMinimum && + unitWithPercent == other.unitWithPercent && + packageWithAllocation == other.packageWithAllocation && + tieredWithProration == other.tieredWithProration && + unitWithProration == other.unitWithProration && + groupedAllocation == other.groupedAllocation && + groupedWithProratedMinimum == other.groupedWithProratedMinimum && + groupedWithMeteredMinimum == other.groupedWithMeteredMinimum && + matrixWithDisplayName == other.matrixWithDisplayName && + bulkWithProration == other.bulkWithProration && + groupedTieredPackage == other.groupedTieredPackage && + maxGroupTieredPackage == other.maxGroupTieredPackage && + scalableMatrixWithUnitPricing == other.scalableMatrixWithUnitPricing && + scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && + cumulativeGroupedBulk == other.cumulativeGroupedBulk && + tieredPackageWithMinimum == other.tieredPackageWithMinimum && + matrixWithAllocation == other.matrixWithAllocation && + groupedTiered == other.groupedTiered } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, package_, matrix, tiered, tieredBps, bps, bulkBps, bulk, thresholdTotalAmount, tieredPackage, tieredWithMinimum, unitWithPercent, packageWithAllocation, tieredWithProration, unitWithProration, groupedAllocation, groupedWithProratedMinimum, groupedWithMeteredMinimum, matrixWithDisplayName, bulkWithProration, groupedTieredPackage, maxGroupTieredPackage, scalableMatrixWithUnitPricing, scalableMatrixWithTieredPricing, cumulativeGroupedBulk, tieredPackageWithMinimum, matrixWithAllocation, groupedTiered) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash( + unit, + package_, + matrix, + tiered, + tieredBps, + bps, + bulkBps, + bulk, + thresholdTotalAmount, + tieredPackage, + tieredWithMinimum, + unitWithPercent, + packageWithAllocation, + tieredWithProration, + unitWithProration, + groupedAllocation, + groupedWithProratedMinimum, + groupedWithMeteredMinimum, + matrixWithDisplayName, + bulkWithProration, + groupedTieredPackage, + maxGroupTieredPackage, + scalableMatrixWithUnitPricing, + scalableMatrixWithTieredPricing, + cumulativeGroupedBulk, + tieredPackageWithMinimum, + matrixWithAllocation, + groupedTiered, + ) override fun toString(): String = when { @@ -3080,12 +3166,16 @@ private constructor( return true } - return /* spotless:off */ other is AddPrice && allocationPrice == other.allocationPrice && planPhaseOrder == other.planPhaseOrder && price == other.price && additionalProperties == other.additionalProperties /* spotless:on */ + return other is AddPrice && + allocationPrice == other.allocationPrice && + planPhaseOrder == other.planPhaseOrder && + price == other.price && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(allocationPrice, planPhaseOrder, price, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash(allocationPrice, planPhaseOrder, price, additionalProperties) + } override fun hashCode(): Int = hashCode @@ -3294,12 +3384,15 @@ private constructor( return true } - return /* spotless:off */ other is RemoveAdjustment && adjustmentId == other.adjustmentId && planPhaseOrder == other.planPhaseOrder && additionalProperties == other.additionalProperties /* spotless:on */ + return other is RemoveAdjustment && + adjustmentId == other.adjustmentId && + planPhaseOrder == other.planPhaseOrder && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(adjustmentId, planPhaseOrder, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash(adjustmentId, planPhaseOrder, additionalProperties) + } override fun hashCode(): Int = hashCode @@ -3501,12 +3594,15 @@ private constructor( return true } - return /* spotless:off */ other is RemovePrice && priceId == other.priceId && planPhaseOrder == other.planPhaseOrder && additionalProperties == other.additionalProperties /* spotless:on */ + return other is RemovePrice && + priceId == other.priceId && + planPhaseOrder == other.planPhaseOrder && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(priceId, planPhaseOrder, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash(priceId, planPhaseOrder, additionalProperties) + } override fun hashCode(): Int = hashCode @@ -3977,10 +4073,16 @@ private constructor( return true } - return /* spotless:off */ other is Adjustment && percentageDiscount == other.percentageDiscount && usageDiscount == other.usageDiscount && amountDiscount == other.amountDiscount && minimum == other.minimum && maximum == other.maximum /* spotless:on */ + return other is Adjustment && + percentageDiscount == other.percentageDiscount && + usageDiscount == other.usageDiscount && + amountDiscount == other.amountDiscount && + minimum == other.minimum && + maximum == other.maximum } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(percentageDiscount, usageDiscount, amountDiscount, minimum, maximum) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash(percentageDiscount, usageDiscount, amountDiscount, minimum, maximum) override fun toString(): String = when { @@ -4105,12 +4207,16 @@ private constructor( return true } - return /* spotless:off */ other is ReplaceAdjustment && adjustment == other.adjustment && replacesAdjustmentId == other.replacesAdjustmentId && planPhaseOrder == other.planPhaseOrder && additionalProperties == other.additionalProperties /* spotless:on */ + return other is ReplaceAdjustment && + adjustment == other.adjustment && + replacesAdjustmentId == other.replacesAdjustmentId && + planPhaseOrder == other.planPhaseOrder && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(adjustment, replacesAdjustmentId, planPhaseOrder, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash(adjustment, replacesAdjustmentId, planPhaseOrder, additionalProperties) + } override fun hashCode(): Int = hashCode @@ -5099,10 +5205,68 @@ private constructor( return true } - return /* spotless:off */ other is Price && unit == other.unit && package_ == other.package_ && matrix == other.matrix && tiered == other.tiered && tieredBps == other.tieredBps && bps == other.bps && bulkBps == other.bulkBps && bulk == other.bulk && thresholdTotalAmount == other.thresholdTotalAmount && tieredPackage == other.tieredPackage && tieredWithMinimum == other.tieredWithMinimum && unitWithPercent == other.unitWithPercent && packageWithAllocation == other.packageWithAllocation && tieredWithProration == other.tieredWithProration && unitWithProration == other.unitWithProration && groupedAllocation == other.groupedAllocation && groupedWithProratedMinimum == other.groupedWithProratedMinimum && groupedWithMeteredMinimum == other.groupedWithMeteredMinimum && matrixWithDisplayName == other.matrixWithDisplayName && bulkWithProration == other.bulkWithProration && groupedTieredPackage == other.groupedTieredPackage && maxGroupTieredPackage == other.maxGroupTieredPackage && scalableMatrixWithUnitPricing == other.scalableMatrixWithUnitPricing && scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && cumulativeGroupedBulk == other.cumulativeGroupedBulk && tieredPackageWithMinimum == other.tieredPackageWithMinimum && matrixWithAllocation == other.matrixWithAllocation && groupedTiered == other.groupedTiered /* spotless:on */ + return other is Price && + unit == other.unit && + package_ == other.package_ && + matrix == other.matrix && + tiered == other.tiered && + tieredBps == other.tieredBps && + bps == other.bps && + bulkBps == other.bulkBps && + bulk == other.bulk && + thresholdTotalAmount == other.thresholdTotalAmount && + tieredPackage == other.tieredPackage && + tieredWithMinimum == other.tieredWithMinimum && + unitWithPercent == other.unitWithPercent && + packageWithAllocation == other.packageWithAllocation && + tieredWithProration == other.tieredWithProration && + unitWithProration == other.unitWithProration && + groupedAllocation == other.groupedAllocation && + groupedWithProratedMinimum == other.groupedWithProratedMinimum && + groupedWithMeteredMinimum == other.groupedWithMeteredMinimum && + matrixWithDisplayName == other.matrixWithDisplayName && + bulkWithProration == other.bulkWithProration && + groupedTieredPackage == other.groupedTieredPackage && + maxGroupTieredPackage == other.maxGroupTieredPackage && + scalableMatrixWithUnitPricing == other.scalableMatrixWithUnitPricing && + scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && + cumulativeGroupedBulk == other.cumulativeGroupedBulk && + tieredPackageWithMinimum == other.tieredPackageWithMinimum && + matrixWithAllocation == other.matrixWithAllocation && + groupedTiered == other.groupedTiered } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, package_, matrix, tiered, tieredBps, bps, bulkBps, bulk, thresholdTotalAmount, tieredPackage, tieredWithMinimum, unitWithPercent, packageWithAllocation, tieredWithProration, unitWithProration, groupedAllocation, groupedWithProratedMinimum, groupedWithMeteredMinimum, matrixWithDisplayName, bulkWithProration, groupedTieredPackage, maxGroupTieredPackage, scalableMatrixWithUnitPricing, scalableMatrixWithTieredPricing, cumulativeGroupedBulk, tieredPackageWithMinimum, matrixWithAllocation, groupedTiered) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash( + unit, + package_, + matrix, + tiered, + tieredBps, + bps, + bulkBps, + bulk, + thresholdTotalAmount, + tieredPackage, + tieredWithMinimum, + unitWithPercent, + packageWithAllocation, + tieredWithProration, + unitWithProration, + groupedAllocation, + groupedWithProratedMinimum, + groupedWithMeteredMinimum, + matrixWithDisplayName, + bulkWithProration, + groupedTieredPackage, + maxGroupTieredPackage, + scalableMatrixWithUnitPricing, + scalableMatrixWithTieredPricing, + cumulativeGroupedBulk, + tieredPackageWithMinimum, + matrixWithAllocation, + groupedTiered, + ) override fun toString(): String = when { @@ -5608,12 +5772,23 @@ private constructor( return true } - return /* spotless:off */ other is ReplacePrice && replacesPriceId == other.replacesPriceId && allocationPrice == other.allocationPrice && planPhaseOrder == other.planPhaseOrder && price == other.price && additionalProperties == other.additionalProperties /* spotless:on */ + return other is ReplacePrice && + replacesPriceId == other.replacesPriceId && + allocationPrice == other.allocationPrice && + planPhaseOrder == other.planPhaseOrder && + price == other.price && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(replacesPriceId, allocationPrice, planPhaseOrder, price, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + replacesPriceId, + allocationPrice, + planPhaseOrder, + price, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode @@ -5626,10 +5801,15 @@ private constructor( return true } - return /* spotless:off */ other is BetaCreatePlanVersionParams && planId == other.planId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return other is BetaCreatePlanVersionParams && + planId == other.planId && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(planId, body, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash(planId, body, additionalHeaders, additionalQueryParams) override fun toString() = "BetaCreatePlanVersionParams{planId=$planId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BetaExternalPlanIdCreatePlanVersionParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BetaExternalPlanIdCreatePlanVersionParams.kt index 22b25ab0c..f6b46cb04 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BetaExternalPlanIdCreatePlanVersionParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BetaExternalPlanIdCreatePlanVersionParams.kt @@ -1079,12 +1079,31 @@ private constructor( return true } - return /* spotless:off */ other is Body && version == other.version && addAdjustments == other.addAdjustments && addPrices == other.addPrices && removeAdjustments == other.removeAdjustments && removePrices == other.removePrices && replaceAdjustments == other.replaceAdjustments && replacePrices == other.replacePrices && setAsDefault == other.setAsDefault && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Body && + version == other.version && + addAdjustments == other.addAdjustments && + addPrices == other.addPrices && + removeAdjustments == other.removeAdjustments && + removePrices == other.removePrices && + replaceAdjustments == other.replaceAdjustments && + replacePrices == other.replacePrices && + setAsDefault == other.setAsDefault && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(version, addAdjustments, addPrices, removeAdjustments, removePrices, replaceAdjustments, replacePrices, setAsDefault, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + version, + addAdjustments, + addPrices, + removeAdjustments, + removePrices, + replaceAdjustments, + replacePrices, + setAsDefault, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode @@ -1510,10 +1529,16 @@ private constructor( return true } - return /* spotless:off */ other is Adjustment && percentageDiscount == other.percentageDiscount && usageDiscount == other.usageDiscount && amountDiscount == other.amountDiscount && minimum == other.minimum && maximum == other.maximum /* spotless:on */ + return other is Adjustment && + percentageDiscount == other.percentageDiscount && + usageDiscount == other.usageDiscount && + amountDiscount == other.amountDiscount && + minimum == other.minimum && + maximum == other.maximum } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(percentageDiscount, usageDiscount, amountDiscount, minimum, maximum) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash(percentageDiscount, usageDiscount, amountDiscount, minimum, maximum) override fun toString(): String = when { @@ -1638,12 +1663,15 @@ private constructor( return true } - return /* spotless:off */ other is AddAdjustment && adjustment == other.adjustment && planPhaseOrder == other.planPhaseOrder && additionalProperties == other.additionalProperties /* spotless:on */ + return other is AddAdjustment && + adjustment == other.adjustment && + planPhaseOrder == other.planPhaseOrder && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(adjustment, planPhaseOrder, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash(adjustment, planPhaseOrder, additionalProperties) + } override fun hashCode(): Int = hashCode @@ -2576,10 +2604,68 @@ private constructor( return true } - return /* spotless:off */ other is Price && unit == other.unit && package_ == other.package_ && matrix == other.matrix && tiered == other.tiered && tieredBps == other.tieredBps && bps == other.bps && bulkBps == other.bulkBps && bulk == other.bulk && thresholdTotalAmount == other.thresholdTotalAmount && tieredPackage == other.tieredPackage && tieredWithMinimum == other.tieredWithMinimum && unitWithPercent == other.unitWithPercent && packageWithAllocation == other.packageWithAllocation && tieredWithProration == other.tieredWithProration && unitWithProration == other.unitWithProration && groupedAllocation == other.groupedAllocation && groupedWithProratedMinimum == other.groupedWithProratedMinimum && groupedWithMeteredMinimum == other.groupedWithMeteredMinimum && matrixWithDisplayName == other.matrixWithDisplayName && bulkWithProration == other.bulkWithProration && groupedTieredPackage == other.groupedTieredPackage && maxGroupTieredPackage == other.maxGroupTieredPackage && scalableMatrixWithUnitPricing == other.scalableMatrixWithUnitPricing && scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && cumulativeGroupedBulk == other.cumulativeGroupedBulk && tieredPackageWithMinimum == other.tieredPackageWithMinimum && matrixWithAllocation == other.matrixWithAllocation && groupedTiered == other.groupedTiered /* spotless:on */ + return other is Price && + unit == other.unit && + package_ == other.package_ && + matrix == other.matrix && + tiered == other.tiered && + tieredBps == other.tieredBps && + bps == other.bps && + bulkBps == other.bulkBps && + bulk == other.bulk && + thresholdTotalAmount == other.thresholdTotalAmount && + tieredPackage == other.tieredPackage && + tieredWithMinimum == other.tieredWithMinimum && + unitWithPercent == other.unitWithPercent && + packageWithAllocation == other.packageWithAllocation && + tieredWithProration == other.tieredWithProration && + unitWithProration == other.unitWithProration && + groupedAllocation == other.groupedAllocation && + groupedWithProratedMinimum == other.groupedWithProratedMinimum && + groupedWithMeteredMinimum == other.groupedWithMeteredMinimum && + matrixWithDisplayName == other.matrixWithDisplayName && + bulkWithProration == other.bulkWithProration && + groupedTieredPackage == other.groupedTieredPackage && + maxGroupTieredPackage == other.maxGroupTieredPackage && + scalableMatrixWithUnitPricing == other.scalableMatrixWithUnitPricing && + scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && + cumulativeGroupedBulk == other.cumulativeGroupedBulk && + tieredPackageWithMinimum == other.tieredPackageWithMinimum && + matrixWithAllocation == other.matrixWithAllocation && + groupedTiered == other.groupedTiered } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, package_, matrix, tiered, tieredBps, bps, bulkBps, bulk, thresholdTotalAmount, tieredPackage, tieredWithMinimum, unitWithPercent, packageWithAllocation, tieredWithProration, unitWithProration, groupedAllocation, groupedWithProratedMinimum, groupedWithMeteredMinimum, matrixWithDisplayName, bulkWithProration, groupedTieredPackage, maxGroupTieredPackage, scalableMatrixWithUnitPricing, scalableMatrixWithTieredPricing, cumulativeGroupedBulk, tieredPackageWithMinimum, matrixWithAllocation, groupedTiered) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash( + unit, + package_, + matrix, + tiered, + tieredBps, + bps, + bulkBps, + bulk, + thresholdTotalAmount, + tieredPackage, + tieredWithMinimum, + unitWithPercent, + packageWithAllocation, + tieredWithProration, + unitWithProration, + groupedAllocation, + groupedWithProratedMinimum, + groupedWithMeteredMinimum, + matrixWithDisplayName, + bulkWithProration, + groupedTieredPackage, + maxGroupTieredPackage, + scalableMatrixWithUnitPricing, + scalableMatrixWithTieredPricing, + cumulativeGroupedBulk, + tieredPackageWithMinimum, + matrixWithAllocation, + groupedTiered, + ) override fun toString(): String = when { @@ -3085,12 +3171,16 @@ private constructor( return true } - return /* spotless:off */ other is AddPrice && allocationPrice == other.allocationPrice && planPhaseOrder == other.planPhaseOrder && price == other.price && additionalProperties == other.additionalProperties /* spotless:on */ + return other is AddPrice && + allocationPrice == other.allocationPrice && + planPhaseOrder == other.planPhaseOrder && + price == other.price && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(allocationPrice, planPhaseOrder, price, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash(allocationPrice, planPhaseOrder, price, additionalProperties) + } override fun hashCode(): Int = hashCode @@ -3299,12 +3389,15 @@ private constructor( return true } - return /* spotless:off */ other is RemoveAdjustment && adjustmentId == other.adjustmentId && planPhaseOrder == other.planPhaseOrder && additionalProperties == other.additionalProperties /* spotless:on */ + return other is RemoveAdjustment && + adjustmentId == other.adjustmentId && + planPhaseOrder == other.planPhaseOrder && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(adjustmentId, planPhaseOrder, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash(adjustmentId, planPhaseOrder, additionalProperties) + } override fun hashCode(): Int = hashCode @@ -3506,12 +3599,15 @@ private constructor( return true } - return /* spotless:off */ other is RemovePrice && priceId == other.priceId && planPhaseOrder == other.planPhaseOrder && additionalProperties == other.additionalProperties /* spotless:on */ + return other is RemovePrice && + priceId == other.priceId && + planPhaseOrder == other.planPhaseOrder && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(priceId, planPhaseOrder, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash(priceId, planPhaseOrder, additionalProperties) + } override fun hashCode(): Int = hashCode @@ -3982,10 +4078,16 @@ private constructor( return true } - return /* spotless:off */ other is Adjustment && percentageDiscount == other.percentageDiscount && usageDiscount == other.usageDiscount && amountDiscount == other.amountDiscount && minimum == other.minimum && maximum == other.maximum /* spotless:on */ + return other is Adjustment && + percentageDiscount == other.percentageDiscount && + usageDiscount == other.usageDiscount && + amountDiscount == other.amountDiscount && + minimum == other.minimum && + maximum == other.maximum } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(percentageDiscount, usageDiscount, amountDiscount, minimum, maximum) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash(percentageDiscount, usageDiscount, amountDiscount, minimum, maximum) override fun toString(): String = when { @@ -4110,12 +4212,16 @@ private constructor( return true } - return /* spotless:off */ other is ReplaceAdjustment && adjustment == other.adjustment && replacesAdjustmentId == other.replacesAdjustmentId && planPhaseOrder == other.planPhaseOrder && additionalProperties == other.additionalProperties /* spotless:on */ + return other is ReplaceAdjustment && + adjustment == other.adjustment && + replacesAdjustmentId == other.replacesAdjustmentId && + planPhaseOrder == other.planPhaseOrder && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(adjustment, replacesAdjustmentId, planPhaseOrder, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash(adjustment, replacesAdjustmentId, planPhaseOrder, additionalProperties) + } override fun hashCode(): Int = hashCode @@ -5104,10 +5210,68 @@ private constructor( return true } - return /* spotless:off */ other is Price && unit == other.unit && package_ == other.package_ && matrix == other.matrix && tiered == other.tiered && tieredBps == other.tieredBps && bps == other.bps && bulkBps == other.bulkBps && bulk == other.bulk && thresholdTotalAmount == other.thresholdTotalAmount && tieredPackage == other.tieredPackage && tieredWithMinimum == other.tieredWithMinimum && unitWithPercent == other.unitWithPercent && packageWithAllocation == other.packageWithAllocation && tieredWithProration == other.tieredWithProration && unitWithProration == other.unitWithProration && groupedAllocation == other.groupedAllocation && groupedWithProratedMinimum == other.groupedWithProratedMinimum && groupedWithMeteredMinimum == other.groupedWithMeteredMinimum && matrixWithDisplayName == other.matrixWithDisplayName && bulkWithProration == other.bulkWithProration && groupedTieredPackage == other.groupedTieredPackage && maxGroupTieredPackage == other.maxGroupTieredPackage && scalableMatrixWithUnitPricing == other.scalableMatrixWithUnitPricing && scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && cumulativeGroupedBulk == other.cumulativeGroupedBulk && tieredPackageWithMinimum == other.tieredPackageWithMinimum && matrixWithAllocation == other.matrixWithAllocation && groupedTiered == other.groupedTiered /* spotless:on */ + return other is Price && + unit == other.unit && + package_ == other.package_ && + matrix == other.matrix && + tiered == other.tiered && + tieredBps == other.tieredBps && + bps == other.bps && + bulkBps == other.bulkBps && + bulk == other.bulk && + thresholdTotalAmount == other.thresholdTotalAmount && + tieredPackage == other.tieredPackage && + tieredWithMinimum == other.tieredWithMinimum && + unitWithPercent == other.unitWithPercent && + packageWithAllocation == other.packageWithAllocation && + tieredWithProration == other.tieredWithProration && + unitWithProration == other.unitWithProration && + groupedAllocation == other.groupedAllocation && + groupedWithProratedMinimum == other.groupedWithProratedMinimum && + groupedWithMeteredMinimum == other.groupedWithMeteredMinimum && + matrixWithDisplayName == other.matrixWithDisplayName && + bulkWithProration == other.bulkWithProration && + groupedTieredPackage == other.groupedTieredPackage && + maxGroupTieredPackage == other.maxGroupTieredPackage && + scalableMatrixWithUnitPricing == other.scalableMatrixWithUnitPricing && + scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && + cumulativeGroupedBulk == other.cumulativeGroupedBulk && + tieredPackageWithMinimum == other.tieredPackageWithMinimum && + matrixWithAllocation == other.matrixWithAllocation && + groupedTiered == other.groupedTiered } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, package_, matrix, tiered, tieredBps, bps, bulkBps, bulk, thresholdTotalAmount, tieredPackage, tieredWithMinimum, unitWithPercent, packageWithAllocation, tieredWithProration, unitWithProration, groupedAllocation, groupedWithProratedMinimum, groupedWithMeteredMinimum, matrixWithDisplayName, bulkWithProration, groupedTieredPackage, maxGroupTieredPackage, scalableMatrixWithUnitPricing, scalableMatrixWithTieredPricing, cumulativeGroupedBulk, tieredPackageWithMinimum, matrixWithAllocation, groupedTiered) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash( + unit, + package_, + matrix, + tiered, + tieredBps, + bps, + bulkBps, + bulk, + thresholdTotalAmount, + tieredPackage, + tieredWithMinimum, + unitWithPercent, + packageWithAllocation, + tieredWithProration, + unitWithProration, + groupedAllocation, + groupedWithProratedMinimum, + groupedWithMeteredMinimum, + matrixWithDisplayName, + bulkWithProration, + groupedTieredPackage, + maxGroupTieredPackage, + scalableMatrixWithUnitPricing, + scalableMatrixWithTieredPricing, + cumulativeGroupedBulk, + tieredPackageWithMinimum, + matrixWithAllocation, + groupedTiered, + ) override fun toString(): String = when { @@ -5613,12 +5777,23 @@ private constructor( return true } - return /* spotless:off */ other is ReplacePrice && replacesPriceId == other.replacesPriceId && allocationPrice == other.allocationPrice && planPhaseOrder == other.planPhaseOrder && price == other.price && additionalProperties == other.additionalProperties /* spotless:on */ + return other is ReplacePrice && + replacesPriceId == other.replacesPriceId && + allocationPrice == other.allocationPrice && + planPhaseOrder == other.planPhaseOrder && + price == other.price && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(replacesPriceId, allocationPrice, planPhaseOrder, price, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + replacesPriceId, + allocationPrice, + planPhaseOrder, + price, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode @@ -5631,10 +5806,15 @@ private constructor( return true } - return /* spotless:off */ other is BetaExternalPlanIdCreatePlanVersionParams && externalPlanId == other.externalPlanId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return other is BetaExternalPlanIdCreatePlanVersionParams && + externalPlanId == other.externalPlanId && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(externalPlanId, body, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash(externalPlanId, body, additionalHeaders, additionalQueryParams) override fun toString() = "BetaExternalPlanIdCreatePlanVersionParams{externalPlanId=$externalPlanId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BetaExternalPlanIdFetchPlanVersionParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BetaExternalPlanIdFetchPlanVersionParams.kt index c93bb24c0..fd405f5f1 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BetaExternalPlanIdFetchPlanVersionParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BetaExternalPlanIdFetchPlanVersionParams.kt @@ -207,10 +207,15 @@ private constructor( return true } - return /* spotless:off */ other is BetaExternalPlanIdFetchPlanVersionParams && externalPlanId == other.externalPlanId && version == other.version && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return other is BetaExternalPlanIdFetchPlanVersionParams && + externalPlanId == other.externalPlanId && + version == other.version && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(externalPlanId, version, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash(externalPlanId, version, additionalHeaders, additionalQueryParams) override fun toString() = "BetaExternalPlanIdFetchPlanVersionParams{externalPlanId=$externalPlanId, version=$version, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BetaExternalPlanIdSetDefaultPlanVersionParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BetaExternalPlanIdSetDefaultPlanVersionParams.kt index 0f0c8b3e4..d51060f57 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BetaExternalPlanIdSetDefaultPlanVersionParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BetaExternalPlanIdSetDefaultPlanVersionParams.kt @@ -406,12 +406,12 @@ private constructor( return true } - return /* spotless:off */ other is Body && version == other.version && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Body && + version == other.version && + additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(version, additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -424,10 +424,15 @@ private constructor( return true } - return /* spotless:off */ other is BetaExternalPlanIdSetDefaultPlanVersionParams && externalPlanId == other.externalPlanId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return other is BetaExternalPlanIdSetDefaultPlanVersionParams && + externalPlanId == other.externalPlanId && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(externalPlanId, body, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash(externalPlanId, body, additionalHeaders, additionalQueryParams) override fun toString() = "BetaExternalPlanIdSetDefaultPlanVersionParams{externalPlanId=$externalPlanId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BetaFetchPlanVersionParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BetaFetchPlanVersionParams.kt index 836177224..1fbe3ca70 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BetaFetchPlanVersionParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BetaFetchPlanVersionParams.kt @@ -202,10 +202,15 @@ private constructor( return true } - return /* spotless:off */ other is BetaFetchPlanVersionParams && planId == other.planId && version == other.version && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return other is BetaFetchPlanVersionParams && + planId == other.planId && + version == other.version && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(planId, version, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash(planId, version, additionalHeaders, additionalQueryParams) override fun toString() = "BetaFetchPlanVersionParams{planId=$planId, version=$version, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BetaSetDefaultPlanVersionParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BetaSetDefaultPlanVersionParams.kt index bfc05e1ab..d0323da90 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BetaSetDefaultPlanVersionParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BetaSetDefaultPlanVersionParams.kt @@ -403,12 +403,12 @@ private constructor( return true } - return /* spotless:off */ other is Body && version == other.version && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Body && + version == other.version && + additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(version, additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -421,10 +421,15 @@ private constructor( return true } - return /* spotless:off */ other is BetaSetDefaultPlanVersionParams && planId == other.planId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return other is BetaSetDefaultPlanVersionParams && + planId == other.planId && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(planId, body, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash(planId, body, additionalHeaders, additionalQueryParams) override fun toString() = "BetaSetDefaultPlanVersionParams{planId=$planId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BillableMetric.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BillableMetric.kt index 02ae5a7b6..e5cb8020d 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BillableMetric.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BillableMetric.kt @@ -430,12 +430,10 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -564,7 +562,7 @@ private constructor( return true } - return /* spotless:off */ other is Status && value == other.value /* spotless:on */ + return other is Status && value == other.value } override fun hashCode() = value.hashCode() @@ -577,12 +575,19 @@ private constructor( return true } - return /* spotless:off */ other is BillableMetric && id == other.id && description == other.description && item == other.item && metadata == other.metadata && name == other.name && status == other.status && additionalProperties == other.additionalProperties /* spotless:on */ + return other is BillableMetric && + id == other.id && + description == other.description && + item == other.item && + metadata == other.metadata && + name == other.name && + status == other.status && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, description, item, metadata, name, status, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash(id, description, item, metadata, name, status, additionalProperties) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BillableMetricTiny.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BillableMetricTiny.kt index b71eba9ae..985f4e6ae 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BillableMetricTiny.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BillableMetricTiny.kt @@ -151,12 +151,12 @@ private constructor( return true } - return /* spotless:off */ other is BillableMetricTiny && id == other.id && additionalProperties == other.additionalProperties /* spotless:on */ + return other is BillableMetricTiny && + id == other.id && + additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(id, additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BillingCycleAnchorConfiguration.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BillingCycleAnchorConfiguration.kt index 47d780bc2..6e531ce23 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BillingCycleAnchorConfiguration.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BillingCycleAnchorConfiguration.kt @@ -256,12 +256,14 @@ private constructor( return true } - return /* spotless:off */ other is BillingCycleAnchorConfiguration && day == other.day && month == other.month && year == other.year && additionalProperties == other.additionalProperties /* spotless:on */ + return other is BillingCycleAnchorConfiguration && + day == other.day && + month == other.month && + year == other.year && + additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(day, month, year, additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BillingCycleConfiguration.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BillingCycleConfiguration.kt index 4b4fc2146..63235a347 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BillingCycleConfiguration.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BillingCycleConfiguration.kt @@ -308,7 +308,7 @@ private constructor( return true } - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ + return other is DurationUnit && value == other.value } override fun hashCode() = value.hashCode() @@ -321,12 +321,13 @@ private constructor( return true } - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ + return other is BillingCycleConfiguration && + duration == other.duration && + durationUnit == other.durationUnit && + additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BillingCycleRelativeDate.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BillingCycleRelativeDate.kt index a6e739553..91a529ae6 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BillingCycleRelativeDate.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BillingCycleRelativeDate.kt @@ -127,7 +127,7 @@ private constructor(private val value: JsonField) : Enum { return true } - return /* spotless:off */ other is BillingCycleRelativeDate && value == other.value /* spotless:on */ + return other is BillingCycleRelativeDate && value == other.value } override fun hashCode() = value.hashCode() diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BpsConfig.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BpsConfig.kt index c9be1d3ef..ed1d95218 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BpsConfig.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BpsConfig.kt @@ -198,12 +198,13 @@ private constructor( return true } - return /* spotless:off */ other is BpsConfig && bps == other.bps && perUnitMaximum == other.perUnitMaximum && additionalProperties == other.additionalProperties /* spotless:on */ + return other is BpsConfig && + bps == other.bps && + perUnitMaximum == other.perUnitMaximum && + additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(bps, perUnitMaximum, additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BpsTier.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BpsTier.kt index 3dd3ebd7e..c00795cd7 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BpsTier.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BpsTier.kt @@ -282,12 +282,17 @@ private constructor( return true } - return /* spotless:off */ other is BpsTier && bps == other.bps && minimumAmount == other.minimumAmount && maximumAmount == other.maximumAmount && perUnitMaximum == other.perUnitMaximum && additionalProperties == other.additionalProperties /* spotless:on */ + return other is BpsTier && + bps == other.bps && + minimumAmount == other.minimumAmount && + maximumAmount == other.maximumAmount && + perUnitMaximum == other.perUnitMaximum && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(bps, minimumAmount, maximumAmount, perUnitMaximum, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash(bps, minimumAmount, maximumAmount, perUnitMaximum, additionalProperties) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BulkBpsConfig.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BulkBpsConfig.kt index dc54babdf..9dff18f20 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BulkBpsConfig.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BulkBpsConfig.kt @@ -178,12 +178,12 @@ private constructor( return true } - return /* spotless:off */ other is BulkBpsConfig && tiers == other.tiers && additionalProperties == other.additionalProperties /* spotless:on */ + return other is BulkBpsConfig && + tiers == other.tiers && + additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(tiers, additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BulkBpsTier.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BulkBpsTier.kt index 14a34cfd2..2b2d6c3bf 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BulkBpsTier.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BulkBpsTier.kt @@ -240,12 +240,16 @@ private constructor( return true } - return /* spotless:off */ other is BulkBpsTier && bps == other.bps && maximumAmount == other.maximumAmount && perUnitMaximum == other.perUnitMaximum && additionalProperties == other.additionalProperties /* spotless:on */ + return other is BulkBpsTier && + bps == other.bps && + maximumAmount == other.maximumAmount && + perUnitMaximum == other.perUnitMaximum && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(bps, maximumAmount, perUnitMaximum, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash(bps, maximumAmount, perUnitMaximum, additionalProperties) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BulkConfig.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BulkConfig.kt index bf2086016..7cbe4a050 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BulkConfig.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BulkConfig.kt @@ -172,12 +172,12 @@ private constructor( return true } - return /* spotless:off */ other is BulkConfig && tiers == other.tiers && additionalProperties == other.additionalProperties /* spotless:on */ + return other is BulkConfig && + tiers == other.tiers && + additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(tiers, additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BulkTier.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BulkTier.kt index f3a6f8ee6..33ea995d9 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BulkTier.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BulkTier.kt @@ -208,12 +208,15 @@ private constructor( return true } - return /* spotless:off */ other is BulkTier && unitAmount == other.unitAmount && maximumUnits == other.maximumUnits && additionalProperties == other.additionalProperties /* spotless:on */ + return other is BulkTier && + unitAmount == other.unitAmount && + maximumUnits == other.maximumUnits && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(unitAmount, maximumUnits, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash(unitAmount, maximumUnits, additionalProperties) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/ChangedSubscriptionResources.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/ChangedSubscriptionResources.kt index 640e10adb..11c95eec3 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/ChangedSubscriptionResources.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/ChangedSubscriptionResources.kt @@ -351,12 +351,23 @@ private constructor( return true } - return /* spotless:off */ other is ChangedSubscriptionResources && createdCreditNotes == other.createdCreditNotes && createdInvoices == other.createdInvoices && voidedCreditNotes == other.voidedCreditNotes && voidedInvoices == other.voidedInvoices && additionalProperties == other.additionalProperties /* spotless:on */ + return other is ChangedSubscriptionResources && + createdCreditNotes == other.createdCreditNotes && + createdInvoices == other.createdInvoices && + voidedCreditNotes == other.voidedCreditNotes && + voidedInvoices == other.voidedInvoices && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(createdCreditNotes, createdInvoices, voidedCreditNotes, voidedInvoices, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + createdCreditNotes, + createdInvoices, + voidedCreditNotes, + voidedInvoices, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/ConversionRateTier.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/ConversionRateTier.kt index e03a1fc89..33dc047f5 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/ConversionRateTier.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/ConversionRateTier.kt @@ -237,12 +237,16 @@ private constructor( return true } - return /* spotless:off */ other is ConversionRateTier && firstUnit == other.firstUnit && unitAmount == other.unitAmount && lastUnit == other.lastUnit && additionalProperties == other.additionalProperties /* spotless:on */ + return other is ConversionRateTier && + firstUnit == other.firstUnit && + unitAmount == other.unitAmount && + lastUnit == other.lastUnit && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(firstUnit, unitAmount, lastUnit, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash(firstUnit, unitAmount, lastUnit, additionalProperties) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/ConversionRateTieredConfig.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/ConversionRateTieredConfig.kt index 0e156090a..cfd6a2c16 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/ConversionRateTieredConfig.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/ConversionRateTieredConfig.kt @@ -174,12 +174,12 @@ private constructor( return true } - return /* spotless:off */ other is ConversionRateTieredConfig && tiers == other.tiers && additionalProperties == other.additionalProperties /* spotless:on */ + return other is ConversionRateTieredConfig && + tiers == other.tiers && + additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(tiers, additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/ConversionRateUnitConfig.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/ConversionRateUnitConfig.kt index bd0c37b04..e32462932 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/ConversionRateUnitConfig.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/ConversionRateUnitConfig.kt @@ -160,12 +160,12 @@ private constructor( return true } - return /* spotless:off */ other is ConversionRateUnitConfig && unitAmount == other.unitAmount && additionalProperties == other.additionalProperties /* spotless:on */ + return other is ConversionRateUnitConfig && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(unitAmount, additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Coupon.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Coupon.kt index 25904bba7..d3a0ba2fc 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Coupon.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Coupon.kt @@ -573,10 +573,10 @@ private constructor( return true } - return /* spotless:off */ other is Discount && percentage == other.percentage && amount == other.amount /* spotless:on */ + return other is Discount && percentage == other.percentage && amount == other.amount } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(percentage, amount) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(percentage, amount) override fun toString(): String = when { @@ -662,12 +662,29 @@ private constructor( return true } - return /* spotless:off */ other is Coupon && id == other.id && archivedAt == other.archivedAt && discount == other.discount && durationInMonths == other.durationInMonths && maxRedemptions == other.maxRedemptions && redemptionCode == other.redemptionCode && timesRedeemed == other.timesRedeemed && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Coupon && + id == other.id && + archivedAt == other.archivedAt && + discount == other.discount && + durationInMonths == other.durationInMonths && + maxRedemptions == other.maxRedemptions && + redemptionCode == other.redemptionCode && + timesRedeemed == other.timesRedeemed && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, archivedAt, discount, durationInMonths, maxRedemptions, redemptionCode, timesRedeemed, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + id, + archivedAt, + discount, + durationInMonths, + maxRedemptions, + redemptionCode, + timesRedeemed, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CouponArchiveParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CouponArchiveParams.kt index bc3854184..e7efcb1ab 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CouponArchiveParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CouponArchiveParams.kt @@ -211,10 +211,15 @@ private constructor( return true } - return /* spotless:off */ other is CouponArchiveParams && couponId == other.couponId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return other is CouponArchiveParams && + couponId == other.couponId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(couponId, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash(couponId, additionalHeaders, additionalQueryParams, additionalBodyProperties) override fun toString() = "CouponArchiveParams{couponId=$couponId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CouponCreateParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CouponCreateParams.kt index e3ae258a6..c9c164517 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CouponCreateParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CouponCreateParams.kt @@ -722,12 +722,23 @@ private constructor( return true } - return /* spotless:off */ other is Body && discount == other.discount && redemptionCode == other.redemptionCode && durationInMonths == other.durationInMonths && maxRedemptions == other.maxRedemptions && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Body && + discount == other.discount && + redemptionCode == other.redemptionCode && + durationInMonths == other.durationInMonths && + maxRedemptions == other.maxRedemptions && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(discount, redemptionCode, durationInMonths, maxRedemptions, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + discount, + redemptionCode, + durationInMonths, + maxRedemptions, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode @@ -816,10 +827,10 @@ private constructor( return true } - return /* spotless:off */ other is Discount && percentage == other.percentage && amount == other.amount /* spotless:on */ + return other is Discount && percentage == other.percentage && amount == other.amount } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(percentage, amount) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(percentage, amount) override fun toString(): String = when { @@ -1095,12 +1106,15 @@ private constructor( return true } - return /* spotless:off */ other is Percentage && discountType == other.discountType && percentageDiscount == other.percentageDiscount && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Percentage && + discountType == other.discountType && + percentageDiscount == other.percentageDiscount && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(discountType, percentageDiscount, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash(discountType, percentageDiscount, additionalProperties) + } override fun hashCode(): Int = hashCode @@ -1304,12 +1318,15 @@ private constructor( return true } - return /* spotless:off */ other is Amount && amountDiscount == other.amountDiscount && discountType == other.discountType && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Amount && + amountDiscount == other.amountDiscount && + discountType == other.discountType && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(amountDiscount, discountType, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash(amountDiscount, discountType, additionalProperties) + } override fun hashCode(): Int = hashCode @@ -1323,10 +1340,13 @@ private constructor( return true } - return /* spotless:off */ other is CouponCreateParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return other is CouponCreateParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(body, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) override fun toString() = "CouponCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CouponFetchParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CouponFetchParams.kt index 54557cea0..380e74269 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CouponFetchParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CouponFetchParams.kt @@ -173,10 +173,13 @@ private constructor( return true } - return /* spotless:off */ other is CouponFetchParams && couponId == other.couponId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return other is CouponFetchParams && + couponId == other.couponId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(couponId, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(couponId, additionalHeaders, additionalQueryParams) override fun toString() = "CouponFetchParams{couponId=$couponId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CouponListPage.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CouponListPage.kt index 8eeaffd9d..e48df727c 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CouponListPage.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CouponListPage.kt @@ -119,10 +119,13 @@ private constructor( return true } - return /* spotless:off */ other is CouponListPage && service == other.service && params == other.params && response == other.response /* spotless:on */ + return other is CouponListPage && + service == other.service && + params == other.params && + response == other.response } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, params, response) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(service, params, response) override fun toString() = "CouponListPage{service=$service, params=$params, response=$response}" } diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CouponListPageAsync.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CouponListPageAsync.kt index 9e7497a43..417b6176b 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CouponListPageAsync.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CouponListPageAsync.kt @@ -119,10 +119,13 @@ private constructor( return true } - return /* spotless:off */ other is CouponListPageAsync && service == other.service && params == other.params && response == other.response /* spotless:on */ + return other is CouponListPageAsync && + service == other.service && + params == other.params && + response == other.response } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, params, response) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(service, params, response) override fun toString() = "CouponListPageAsync{service=$service, params=$params, response=$response}" diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CouponListPageResponse.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CouponListPageResponse.kt index 9d84e15ec..be79cf3a3 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CouponListPageResponse.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CouponListPageResponse.kt @@ -214,12 +214,15 @@ private constructor( return true } - return /* spotless:off */ other is CouponListPageResponse && data == other.data && paginationMetadata == other.paginationMetadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is CouponListPageResponse && + data == other.data && + paginationMetadata == other.paginationMetadata && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(data, paginationMetadata, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash(data, paginationMetadata, additionalProperties) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CouponListParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CouponListParams.kt index 1e438a68f..2af9ee208 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CouponListParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CouponListParams.kt @@ -237,10 +237,24 @@ private constructor( return true } - return /* spotless:off */ other is CouponListParams && cursor == other.cursor && limit == other.limit && redemptionCode == other.redemptionCode && showArchived == other.showArchived && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return other is CouponListParams && + cursor == other.cursor && + limit == other.limit && + redemptionCode == other.redemptionCode && + showArchived == other.showArchived && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(cursor, limit, redemptionCode, showArchived, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash( + cursor, + limit, + redemptionCode, + showArchived, + additionalHeaders, + additionalQueryParams, + ) override fun toString() = "CouponListParams{cursor=$cursor, limit=$limit, redemptionCode=$redemptionCode, showArchived=$showArchived, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CouponRedemption.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CouponRedemption.kt index 44b037e7f..5090071d0 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CouponRedemption.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CouponRedemption.kt @@ -228,12 +228,16 @@ private constructor( return true } - return /* spotless:off */ other is CouponRedemption && couponId == other.couponId && endDate == other.endDate && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ + return other is CouponRedemption && + couponId == other.couponId && + endDate == other.endDate && + startDate == other.startDate && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(couponId, endDate, startDate, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash(couponId, endDate, startDate, additionalProperties) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CouponSubscriptionListPage.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CouponSubscriptionListPage.kt index bfe0a3671..e5c64b119 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CouponSubscriptionListPage.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CouponSubscriptionListPage.kt @@ -119,10 +119,13 @@ private constructor( return true } - return /* spotless:off */ other is CouponSubscriptionListPage && service == other.service && params == other.params && response == other.response /* spotless:on */ + return other is CouponSubscriptionListPage && + service == other.service && + params == other.params && + response == other.response } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, params, response) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(service, params, response) override fun toString() = "CouponSubscriptionListPage{service=$service, params=$params, response=$response}" diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CouponSubscriptionListPageAsync.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CouponSubscriptionListPageAsync.kt index 4beaa02a5..cadbc8b8e 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CouponSubscriptionListPageAsync.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CouponSubscriptionListPageAsync.kt @@ -122,10 +122,13 @@ private constructor( return true } - return /* spotless:off */ other is CouponSubscriptionListPageAsync && service == other.service && params == other.params && response == other.response /* spotless:on */ + return other is CouponSubscriptionListPageAsync && + service == other.service && + params == other.params && + response == other.response } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, params, response) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(service, params, response) override fun toString() = "CouponSubscriptionListPageAsync{service=$service, params=$params, response=$response}" diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CouponSubscriptionListParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CouponSubscriptionListParams.kt index fc1c974a6..5f371a1d9 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CouponSubscriptionListParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CouponSubscriptionListParams.kt @@ -221,10 +221,16 @@ private constructor( return true } - return /* spotless:off */ other is CouponSubscriptionListParams && couponId == other.couponId && cursor == other.cursor && limit == other.limit && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return other is CouponSubscriptionListParams && + couponId == other.couponId && + cursor == other.cursor && + limit == other.limit && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(couponId, cursor, limit, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash(couponId, cursor, limit, additionalHeaders, additionalQueryParams) override fun toString() = "CouponSubscriptionListParams{couponId=$couponId, cursor=$cursor, limit=$limit, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CreditBlockExpiryLedgerEntry.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CreditBlockExpiryLedgerEntry.kt index 1c75e5ef4..feb6de526 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CreditBlockExpiryLedgerEntry.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CreditBlockExpiryLedgerEntry.kt @@ -735,7 +735,7 @@ private constructor( return true } - return /* spotless:off */ other is EntryStatus && value == other.value /* spotless:on */ + return other is EntryStatus && value == other.value } override fun hashCode() = value.hashCode() @@ -855,7 +855,7 @@ private constructor( return true } - return /* spotless:off */ other is EntryType && value == other.value /* spotless:on */ + return other is EntryType && value == other.value } override fun hashCode() = value.hashCode() @@ -955,12 +955,10 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -972,12 +970,41 @@ private constructor( return true } - return /* spotless:off */ other is CreditBlockExpiryLedgerEntry && id == other.id && amount == other.amount && createdAt == other.createdAt && creditBlock == other.creditBlock && currency == other.currency && customer == other.customer && description == other.description && endingBalance == other.endingBalance && entryStatus == other.entryStatus && entryType == other.entryType && ledgerSequenceNumber == other.ledgerSequenceNumber && metadata == other.metadata && startingBalance == other.startingBalance && additionalProperties == other.additionalProperties /* spotless:on */ + return other is CreditBlockExpiryLedgerEntry && + id == other.id && + amount == other.amount && + createdAt == other.createdAt && + creditBlock == other.creditBlock && + currency == other.currency && + customer == other.customer && + description == other.description && + endingBalance == other.endingBalance && + entryStatus == other.entryStatus && + entryType == other.entryType && + ledgerSequenceNumber == other.ledgerSequenceNumber && + metadata == other.metadata && + startingBalance == other.startingBalance && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, amount, createdAt, creditBlock, currency, customer, description, endingBalance, entryStatus, entryType, ledgerSequenceNumber, metadata, startingBalance, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + id, + amount, + createdAt, + creditBlock, + currency, + customer, + description, + endingBalance, + entryStatus, + entryType, + ledgerSequenceNumber, + metadata, + startingBalance, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CreditNote.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CreditNote.kt index f03dbe503..a98a7f892 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CreditNote.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CreditNote.kt @@ -1843,7 +1843,7 @@ private constructor( return true } - return /* spotless:off */ other is DiscountType && value == other.value /* spotless:on */ + return other is DiscountType && value == other.value } override fun hashCode() = value.hashCode() @@ -1856,13 +1856,30 @@ private constructor( return true } - return /* spotless:off */ other is Discount && id == other.id && amountApplied == other.amountApplied && appliesToPriceIds == other.appliesToPriceIds && discountType == other.discountType && percentageDiscount == other.percentageDiscount && amountDiscount == other.amountDiscount && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Discount && + id == other.id && + amountApplied == other.amountApplied && + appliesToPriceIds == other.appliesToPriceIds && + discountType == other.discountType && + percentageDiscount == other.percentageDiscount && + amountDiscount == other.amountDiscount && + reason == other.reason && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + amountApplied, + appliesToPriceIds, + discountType, + percentageDiscount, + amountDiscount, + reason, + additionalProperties, + ) } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, amountApplied, appliesToPriceIds, discountType, percentageDiscount, amountDiscount, reason, additionalProperties) } - /* spotless:on */ - override fun hashCode(): Int = hashCode override fun toString() = @@ -1874,12 +1891,35 @@ private constructor( return true } - return /* spotless:off */ other is LineItem && id == other.id && amount == other.amount && itemId == other.itemId && name == other.name && quantity == other.quantity && subtotal == other.subtotal && taxAmounts == other.taxAmounts && discounts == other.discounts && endTimeExclusive == other.endTimeExclusive && startTimeInclusive == other.startTimeInclusive && additionalProperties == other.additionalProperties /* spotless:on */ + return other is LineItem && + id == other.id && + amount == other.amount && + itemId == other.itemId && + name == other.name && + quantity == other.quantity && + subtotal == other.subtotal && + taxAmounts == other.taxAmounts && + discounts == other.discounts && + endTimeExclusive == other.endTimeExclusive && + startTimeInclusive == other.startTimeInclusive && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, amount, itemId, name, quantity, subtotal, taxAmounts, discounts, endTimeExclusive, startTimeInclusive, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + id, + amount, + itemId, + name, + quantity, + subtotal, + taxAmounts, + discounts, + endTimeExclusive, + startTimeInclusive, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode @@ -2318,7 +2358,7 @@ private constructor( return true } - return /* spotless:off */ other is DiscountType && value == other.value /* spotless:on */ + return other is DiscountType && value == other.value } override fun hashCode() = value.hashCode() @@ -2505,12 +2545,13 @@ private constructor( return true } - return /* spotless:off */ other is AppliesToPrice && id == other.id && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ + return other is AppliesToPrice && + id == other.id && + name == other.name && + additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(id, name, additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -2523,12 +2564,25 @@ private constructor( return true } - return /* spotless:off */ other is MaximumAmountAdjustment && amountApplied == other.amountApplied && discountType == other.discountType && percentageDiscount == other.percentageDiscount && appliesToPrices == other.appliesToPrices && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ + return other is MaximumAmountAdjustment && + amountApplied == other.amountApplied && + discountType == other.discountType && + percentageDiscount == other.percentageDiscount && + appliesToPrices == other.appliesToPrices && + reason == other.reason && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(amountApplied, discountType, percentageDiscount, appliesToPrices, reason, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + amountApplied, + discountType, + percentageDiscount, + appliesToPrices, + reason, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode @@ -2664,7 +2718,7 @@ private constructor( return true } - return /* spotless:off */ other is Reason && value == other.value /* spotless:on */ + return other is Reason && value == other.value } override fun hashCode() = value.hashCode() @@ -2788,7 +2842,7 @@ private constructor( return true } - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + return other is Type && value == other.value } override fun hashCode() = value.hashCode() @@ -3226,7 +3280,7 @@ private constructor( return true } - return /* spotless:off */ other is DiscountType && value == other.value /* spotless:on */ + return other is DiscountType && value == other.value } override fun hashCode() = value.hashCode() @@ -3413,12 +3467,13 @@ private constructor( return true } - return /* spotless:off */ other is AppliesToPrice && id == other.id && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ + return other is AppliesToPrice && + id == other.id && + name == other.name && + additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(id, name, additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -3431,12 +3486,25 @@ private constructor( return true } - return /* spotless:off */ other is Discount && amountApplied == other.amountApplied && discountType == other.discountType && percentageDiscount == other.percentageDiscount && appliesToPrices == other.appliesToPrices && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Discount && + amountApplied == other.amountApplied && + discountType == other.discountType && + percentageDiscount == other.percentageDiscount && + appliesToPrices == other.appliesToPrices && + reason == other.reason && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(amountApplied, discountType, percentageDiscount, appliesToPrices, reason, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + amountApplied, + discountType, + percentageDiscount, + appliesToPrices, + reason, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode @@ -3449,12 +3517,47 @@ private constructor( return true } - return /* spotless:off */ other is CreditNote && id == other.id && createdAt == other.createdAt && creditNoteNumber == other.creditNoteNumber && creditNotePdf == other.creditNotePdf && customer == other.customer && invoiceId == other.invoiceId && lineItems == other.lineItems && maximumAmountAdjustment == other.maximumAmountAdjustment && memo == other.memo && minimumAmountRefunded == other.minimumAmountRefunded && reason == other.reason && subtotal == other.subtotal && total == other.total && type == other.type && voidedAt == other.voidedAt && discounts == other.discounts && additionalProperties == other.additionalProperties /* spotless:on */ + return other is CreditNote && + id == other.id && + createdAt == other.createdAt && + creditNoteNumber == other.creditNoteNumber && + creditNotePdf == other.creditNotePdf && + customer == other.customer && + invoiceId == other.invoiceId && + lineItems == other.lineItems && + maximumAmountAdjustment == other.maximumAmountAdjustment && + memo == other.memo && + minimumAmountRefunded == other.minimumAmountRefunded && + reason == other.reason && + subtotal == other.subtotal && + total == other.total && + type == other.type && + voidedAt == other.voidedAt && + discounts == other.discounts && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, createdAt, creditNoteNumber, creditNotePdf, customer, invoiceId, lineItems, maximumAmountAdjustment, memo, minimumAmountRefunded, reason, subtotal, total, type, voidedAt, discounts, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + id, + createdAt, + creditNoteNumber, + creditNotePdf, + customer, + invoiceId, + lineItems, + maximumAmountAdjustment, + memo, + minimumAmountRefunded, + reason, + subtotal, + total, + type, + voidedAt, + discounts, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CreditNoteCreateParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CreditNoteCreateParams.kt index b7f9ccade..5c0c74029 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CreditNoteCreateParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CreditNoteCreateParams.kt @@ -720,12 +720,18 @@ private constructor( return true } - return /* spotless:off */ other is Body && lineItems == other.lineItems && reason == other.reason && endDate == other.endDate && memo == other.memo && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Body && + lineItems == other.lineItems && + reason == other.reason && + endDate == other.endDate && + memo == other.memo && + startDate == other.startDate && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(lineItems, reason, endDate, memo, startDate, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash(lineItems, reason, endDate, memo, startDate, additionalProperties) + } override fun hashCode(): Int = hashCode @@ -1012,12 +1018,17 @@ private constructor( return true } - return /* spotless:off */ other is LineItem && amount == other.amount && invoiceLineItemId == other.invoiceLineItemId && endDate == other.endDate && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ + return other is LineItem && + amount == other.amount && + invoiceLineItemId == other.invoiceLineItemId && + endDate == other.endDate && + startDate == other.startDate && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(amount, invoiceLineItemId, endDate, startDate, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash(amount, invoiceLineItemId, endDate, startDate, additionalProperties) + } override fun hashCode(): Int = hashCode @@ -1154,7 +1165,7 @@ private constructor( return true } - return /* spotless:off */ other is Reason && value == other.value /* spotless:on */ + return other is Reason && value == other.value } override fun hashCode() = value.hashCode() @@ -1167,10 +1178,13 @@ private constructor( return true } - return /* spotless:off */ other is CreditNoteCreateParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return other is CreditNoteCreateParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(body, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) override fun toString() = "CreditNoteCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CreditNoteFetchParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CreditNoteFetchParams.kt index 04ad4dc72..080b9f54b 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CreditNoteFetchParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CreditNoteFetchParams.kt @@ -177,10 +177,14 @@ private constructor( return true } - return /* spotless:off */ other is CreditNoteFetchParams && creditNoteId == other.creditNoteId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return other is CreditNoteFetchParams && + creditNoteId == other.creditNoteId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(creditNoteId, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash(creditNoteId, additionalHeaders, additionalQueryParams) override fun toString() = "CreditNoteFetchParams{creditNoteId=$creditNoteId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CreditNoteListPage.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CreditNoteListPage.kt index 652b36fb4..34179c748 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CreditNoteListPage.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CreditNoteListPage.kt @@ -119,10 +119,13 @@ private constructor( return true } - return /* spotless:off */ other is CreditNoteListPage && service == other.service && params == other.params && response == other.response /* spotless:on */ + return other is CreditNoteListPage && + service == other.service && + params == other.params && + response == other.response } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, params, response) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(service, params, response) override fun toString() = "CreditNoteListPage{service=$service, params=$params, response=$response}" diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CreditNoteListPageAsync.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CreditNoteListPageAsync.kt index 8c7838267..ed3a64b33 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CreditNoteListPageAsync.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CreditNoteListPageAsync.kt @@ -119,10 +119,13 @@ private constructor( return true } - return /* spotless:off */ other is CreditNoteListPageAsync && service == other.service && params == other.params && response == other.response /* spotless:on */ + return other is CreditNoteListPageAsync && + service == other.service && + params == other.params && + response == other.response } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, params, response) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(service, params, response) override fun toString() = "CreditNoteListPageAsync{service=$service, params=$params, response=$response}" diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CreditNoteListPageResponse.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CreditNoteListPageResponse.kt index fc18270fe..c65672853 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CreditNoteListPageResponse.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CreditNoteListPageResponse.kt @@ -214,12 +214,15 @@ private constructor( return true } - return /* spotless:off */ other is CreditNoteListPageResponse && data == other.data && paginationMetadata == other.paginationMetadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is CreditNoteListPageResponse && + data == other.data && + paginationMetadata == other.paginationMetadata && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(data, paginationMetadata, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash(data, paginationMetadata, additionalProperties) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CreditNoteListParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CreditNoteListParams.kt index 4c21de8ef..d23b2afc3 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CreditNoteListParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CreditNoteListParams.kt @@ -250,10 +250,28 @@ private constructor( return true } - return /* spotless:off */ other is CreditNoteListParams && createdAtGt == other.createdAtGt && createdAtGte == other.createdAtGte && createdAtLt == other.createdAtLt && createdAtLte == other.createdAtLte && cursor == other.cursor && limit == other.limit && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return other is CreditNoteListParams && + createdAtGt == other.createdAtGt && + createdAtGte == other.createdAtGte && + createdAtLt == other.createdAtLt && + createdAtLte == other.createdAtLte && + cursor == other.cursor && + limit == other.limit && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(createdAtGt, createdAtGte, createdAtLt, createdAtLte, cursor, limit, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash( + createdAtGt, + createdAtGte, + createdAtLt, + createdAtLte, + cursor, + limit, + additionalHeaders, + additionalQueryParams, + ) override fun toString() = "CreditNoteListParams{createdAtGt=$createdAtGt, createdAtGte=$createdAtGte, createdAtLt=$createdAtLt, createdAtLte=$createdAtLte, cursor=$cursor, limit=$limit, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CreditNoteTiny.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CreditNoteTiny.kt index c2cbd8985..d4c875ce8 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CreditNoteTiny.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CreditNoteTiny.kt @@ -154,12 +154,12 @@ private constructor( return true } - return /* spotless:off */ other is CreditNoteTiny && id == other.id && additionalProperties == other.additionalProperties /* spotless:on */ + return other is CreditNoteTiny && + id == other.id && + additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(id, additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomExpiration.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomExpiration.kt index d98093cb6..e2a79a9c8 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomExpiration.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomExpiration.kt @@ -308,7 +308,7 @@ private constructor( return true } - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ + return other is DurationUnit && value == other.value } override fun hashCode() = value.hashCode() @@ -321,12 +321,13 @@ private constructor( return true } - return /* spotless:off */ other is CustomExpiration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ + return other is CustomExpiration && + duration == other.duration && + durationUnit == other.durationUnit && + additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Customer.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Customer.kt index c91f7576f..cdd3b82d9 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Customer.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Customer.kt @@ -1535,12 +1535,13 @@ private constructor( return true } - return /* spotless:off */ other is Hierarchy && children == other.children && parent == other.parent && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Hierarchy && + children == other.children && + parent == other.parent && + additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(children, parent, additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1640,12 +1641,10 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1794,7 +1793,7 @@ private constructor( return true } - return /* spotless:off */ other is PaymentProvider && value == other.value /* spotless:on */ + return other is PaymentProvider && value == other.value } override fun hashCode() = value.hashCode() @@ -2315,7 +2314,7 @@ private constructor( return true } - return /* spotless:off */ other is ProviderType && value == other.value /* spotless:on */ + return other is ProviderType && value == other.value } override fun hashCode() = value.hashCode() @@ -2328,12 +2327,15 @@ private constructor( return true } - return /* spotless:off */ other is AccountingProvider && externalProviderId == other.externalProviderId && providerType == other.providerType && additionalProperties == other.additionalProperties /* spotless:on */ + return other is AccountingProvider && + externalProviderId == other.externalProviderId && + providerType == other.providerType && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(externalProviderId, providerType, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash(externalProviderId, providerType, additionalProperties) + } override fun hashCode(): Int = hashCode @@ -2346,12 +2348,15 @@ private constructor( return true } - return /* spotless:off */ other is AccountingSyncConfiguration && accountingProviders == other.accountingProviders && excluded == other.excluded && additionalProperties == other.additionalProperties /* spotless:on */ + return other is AccountingSyncConfiguration && + accountingProviders == other.accountingProviders && + excluded == other.excluded && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(accountingProviders, excluded, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash(accountingProviders, excluded, additionalProperties) + } override fun hashCode(): Int = hashCode @@ -2500,12 +2505,12 @@ private constructor( return true } - return /* spotless:off */ other is ReportingConfiguration && exempt == other.exempt && additionalProperties == other.additionalProperties /* spotless:on */ + return other is ReportingConfiguration && + exempt == other.exempt && + additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(exempt, additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -2518,12 +2523,59 @@ private constructor( return true } - return /* spotless:off */ other is Customer && id == other.id && additionalEmails == other.additionalEmails && autoCollection == other.autoCollection && balance == other.balance && billingAddress == other.billingAddress && createdAt == other.createdAt && currency == other.currency && email == other.email && emailDelivery == other.emailDelivery && exemptFromAutomatedTax == other.exemptFromAutomatedTax && externalCustomerId == other.externalCustomerId && hierarchy == other.hierarchy && metadata == other.metadata && name == other.name && paymentProvider == other.paymentProvider && paymentProviderId == other.paymentProviderId && portalUrl == other.portalUrl && shippingAddress == other.shippingAddress && taxId == other.taxId && timezone == other.timezone && accountingSyncConfiguration == other.accountingSyncConfiguration && reportingConfiguration == other.reportingConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Customer && + id == other.id && + additionalEmails == other.additionalEmails && + autoCollection == other.autoCollection && + balance == other.balance && + billingAddress == other.billingAddress && + createdAt == other.createdAt && + currency == other.currency && + email == other.email && + emailDelivery == other.emailDelivery && + exemptFromAutomatedTax == other.exemptFromAutomatedTax && + externalCustomerId == other.externalCustomerId && + hierarchy == other.hierarchy && + metadata == other.metadata && + name == other.name && + paymentProvider == other.paymentProvider && + paymentProviderId == other.paymentProviderId && + portalUrl == other.portalUrl && + shippingAddress == other.shippingAddress && + taxId == other.taxId && + timezone == other.timezone && + accountingSyncConfiguration == other.accountingSyncConfiguration && + reportingConfiguration == other.reportingConfiguration && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, additionalEmails, autoCollection, balance, billingAddress, createdAt, currency, email, emailDelivery, exemptFromAutomatedTax, externalCustomerId, hierarchy, metadata, name, paymentProvider, paymentProviderId, portalUrl, shippingAddress, taxId, timezone, accountingSyncConfiguration, reportingConfiguration, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + id, + additionalEmails, + autoCollection, + balance, + billingAddress, + createdAt, + currency, + email, + emailDelivery, + exemptFromAutomatedTax, + externalCustomerId, + hierarchy, + metadata, + name, + paymentProvider, + paymentProviderId, + portalUrl, + shippingAddress, + taxId, + timezone, + accountingSyncConfiguration, + reportingConfiguration, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionCreateParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionCreateParams.kt index badcd4d5a..b080f30b0 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionCreateParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionCreateParams.kt @@ -528,12 +528,16 @@ private constructor( return true } - return /* spotless:off */ other is Body && amount == other.amount && type == other.type && description == other.description && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Body && + amount == other.amount && + type == other.type && + description == other.description && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(amount, type, description, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash(amount, type, description, additionalProperties) + } override fun hashCode(): Int = hashCode @@ -657,7 +661,7 @@ private constructor( return true } - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + return other is Type && value == other.value } override fun hashCode() = value.hashCode() @@ -670,10 +674,15 @@ private constructor( return true } - return /* spotless:off */ other is CustomerBalanceTransactionCreateParams && customerId == other.customerId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return other is CustomerBalanceTransactionCreateParams && + customerId == other.customerId && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(customerId, body, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash(customerId, body, additionalHeaders, additionalQueryParams) override fun toString() = "CustomerBalanceTransactionCreateParams{customerId=$customerId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionCreateResponse.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionCreateResponse.kt index 16d3914ce..f6e728472 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionCreateResponse.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionCreateResponse.kt @@ -670,7 +670,7 @@ private constructor( return true } - return /* spotless:off */ other is Action && value == other.value /* spotless:on */ + return other is Action && value == other.value } override fun hashCode() = value.hashCode() @@ -794,7 +794,7 @@ private constructor( return true } - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + return other is Type && value == other.value } override fun hashCode() = value.hashCode() @@ -807,12 +807,35 @@ private constructor( return true } - return /* spotless:off */ other is CustomerBalanceTransactionCreateResponse && id == other.id && action == other.action && amount == other.amount && createdAt == other.createdAt && creditNote == other.creditNote && description == other.description && endingBalance == other.endingBalance && invoice == other.invoice && startingBalance == other.startingBalance && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return other is CustomerBalanceTransactionCreateResponse && + id == other.id && + action == other.action && + amount == other.amount && + createdAt == other.createdAt && + creditNote == other.creditNote && + description == other.description && + endingBalance == other.endingBalance && + invoice == other.invoice && + startingBalance == other.startingBalance && + type == other.type && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, action, amount, createdAt, creditNote, description, endingBalance, invoice, startingBalance, type, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + id, + action, + amount, + createdAt, + creditNote, + description, + endingBalance, + invoice, + startingBalance, + type, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionListPage.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionListPage.kt index 2dd6f1756..e6d8312be 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionListPage.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionListPage.kt @@ -126,10 +126,13 @@ private constructor( return true } - return /* spotless:off */ other is CustomerBalanceTransactionListPage && service == other.service && params == other.params && response == other.response /* spotless:on */ + return other is CustomerBalanceTransactionListPage && + service == other.service && + params == other.params && + response == other.response } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, params, response) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(service, params, response) override fun toString() = "CustomerBalanceTransactionListPage{service=$service, params=$params, response=$response}" diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionListPageAsync.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionListPageAsync.kt index fff662d2f..582659d15 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionListPageAsync.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionListPageAsync.kt @@ -129,10 +129,13 @@ private constructor( return true } - return /* spotless:off */ other is CustomerBalanceTransactionListPageAsync && service == other.service && params == other.params && response == other.response /* spotless:on */ + return other is CustomerBalanceTransactionListPageAsync && + service == other.service && + params == other.params && + response == other.response } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, params, response) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(service, params, response) override fun toString() = "CustomerBalanceTransactionListPageAsync{service=$service, params=$params, response=$response}" diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionListPageResponse.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionListPageResponse.kt index 7987a76f5..36e8cd899 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionListPageResponse.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionListPageResponse.kt @@ -222,12 +222,15 @@ private constructor( return true } - return /* spotless:off */ other is CustomerBalanceTransactionListPageResponse && data == other.data && paginationMetadata == other.paginationMetadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is CustomerBalanceTransactionListPageResponse && + data == other.data && + paginationMetadata == other.paginationMetadata && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(data, paginationMetadata, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash(data, paginationMetadata, additionalProperties) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionListParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionListParams.kt index b65b6f9b4..e0553b567 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionListParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionListParams.kt @@ -293,10 +293,30 @@ private constructor( return true } - return /* spotless:off */ other is CustomerBalanceTransactionListParams && customerId == other.customerId && cursor == other.cursor && limit == other.limit && operationTimeGt == other.operationTimeGt && operationTimeGte == other.operationTimeGte && operationTimeLt == other.operationTimeLt && operationTimeLte == other.operationTimeLte && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return other is CustomerBalanceTransactionListParams && + customerId == other.customerId && + cursor == other.cursor && + limit == other.limit && + operationTimeGt == other.operationTimeGt && + operationTimeGte == other.operationTimeGte && + operationTimeLt == other.operationTimeLt && + operationTimeLte == other.operationTimeLte && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(customerId, cursor, limit, operationTimeGt, operationTimeGte, operationTimeLt, operationTimeLte, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash( + customerId, + cursor, + limit, + operationTimeGt, + operationTimeGte, + operationTimeLt, + operationTimeLte, + additionalHeaders, + additionalQueryParams, + ) override fun toString() = "CustomerBalanceTransactionListParams{customerId=$customerId, cursor=$cursor, limit=$limit, operationTimeGt=$operationTimeGt, operationTimeGte=$operationTimeGte, operationTimeLt=$operationTimeLt, operationTimeLte=$operationTimeLte, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionListResponse.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionListResponse.kt index 2ab9cbc7a..bbccd5e74 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionListResponse.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionListResponse.kt @@ -670,7 +670,7 @@ private constructor( return true } - return /* spotless:off */ other is Action && value == other.value /* spotless:on */ + return other is Action && value == other.value } override fun hashCode() = value.hashCode() @@ -794,7 +794,7 @@ private constructor( return true } - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + return other is Type && value == other.value } override fun hashCode() = value.hashCode() @@ -807,12 +807,35 @@ private constructor( return true } - return /* spotless:off */ other is CustomerBalanceTransactionListResponse && id == other.id && action == other.action && amount == other.amount && createdAt == other.createdAt && creditNote == other.creditNote && description == other.description && endingBalance == other.endingBalance && invoice == other.invoice && startingBalance == other.startingBalance && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return other is CustomerBalanceTransactionListResponse && + id == other.id && + action == other.action && + amount == other.amount && + createdAt == other.createdAt && + creditNote == other.creditNote && + description == other.description && + endingBalance == other.endingBalance && + invoice == other.invoice && + startingBalance == other.startingBalance && + type == other.type && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, action, amount, createdAt, creditNote, description, endingBalance, invoice, startingBalance, type, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + id, + action, + amount, + createdAt, + creditNote, + description, + endingBalance, + invoice, + startingBalance, + type, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCostListByExternalIdParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCostListByExternalIdParams.kt index aae999d1a..38fa906b9 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCostListByExternalIdParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCostListByExternalIdParams.kt @@ -473,7 +473,7 @@ private constructor( return true } - return /* spotless:off */ other is ViewMode && value == other.value /* spotless:on */ + return other is ViewMode && value == other.value } override fun hashCode() = value.hashCode() @@ -486,10 +486,26 @@ private constructor( return true } - return /* spotless:off */ other is CustomerCostListByExternalIdParams && externalCustomerId == other.externalCustomerId && currency == other.currency && timeframeEnd == other.timeframeEnd && timeframeStart == other.timeframeStart && viewMode == other.viewMode && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return other is CustomerCostListByExternalIdParams && + externalCustomerId == other.externalCustomerId && + currency == other.currency && + timeframeEnd == other.timeframeEnd && + timeframeStart == other.timeframeStart && + viewMode == other.viewMode && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(externalCustomerId, currency, timeframeEnd, timeframeStart, viewMode, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash( + externalCustomerId, + currency, + timeframeEnd, + timeframeStart, + viewMode, + additionalHeaders, + additionalQueryParams, + ) override fun toString() = "CustomerCostListByExternalIdParams{externalCustomerId=$externalCustomerId, currency=$currency, timeframeEnd=$timeframeEnd, timeframeStart=$timeframeStart, viewMode=$viewMode, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCostListByExternalIdResponse.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCostListByExternalIdResponse.kt index de75479c2..272e34f1c 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCostListByExternalIdResponse.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCostListByExternalIdResponse.kt @@ -177,12 +177,12 @@ private constructor( return true } - return /* spotless:off */ other is CustomerCostListByExternalIdResponse && data == other.data && additionalProperties == other.additionalProperties /* spotless:on */ + return other is CustomerCostListByExternalIdResponse && + data == other.data && + additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(data, additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCostListParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCostListParams.kt index edf6865d9..33b8c0034 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCostListParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCostListParams.kt @@ -466,7 +466,7 @@ private constructor( return true } - return /* spotless:off */ other is ViewMode && value == other.value /* spotless:on */ + return other is ViewMode && value == other.value } override fun hashCode() = value.hashCode() @@ -479,10 +479,26 @@ private constructor( return true } - return /* spotless:off */ other is CustomerCostListParams && customerId == other.customerId && currency == other.currency && timeframeEnd == other.timeframeEnd && timeframeStart == other.timeframeStart && viewMode == other.viewMode && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return other is CustomerCostListParams && + customerId == other.customerId && + currency == other.currency && + timeframeEnd == other.timeframeEnd && + timeframeStart == other.timeframeStart && + viewMode == other.viewMode && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(customerId, currency, timeframeEnd, timeframeStart, viewMode, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash( + customerId, + currency, + timeframeEnd, + timeframeStart, + viewMode, + additionalHeaders, + additionalQueryParams, + ) override fun toString() = "CustomerCostListParams{customerId=$customerId, currency=$currency, timeframeEnd=$timeframeEnd, timeframeStart=$timeframeStart, viewMode=$viewMode, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCostListResponse.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCostListResponse.kt index cc4bc15b1..aadfd81e2 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCostListResponse.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCostListResponse.kt @@ -173,12 +173,12 @@ private constructor( return true } - return /* spotless:off */ other is CustomerCostListResponse && data == other.data && additionalProperties == other.additionalProperties /* spotless:on */ + return other is CustomerCostListResponse && + data == other.data && + additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(data, additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreateParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreateParams.kt index 6184c5dcb..5beb136ab 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreateParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreateParams.kt @@ -2424,13 +2424,52 @@ private constructor( return true } - return /* spotless:off */ other is Body && email == other.email && name == other.name && accountingSyncConfiguration == other.accountingSyncConfiguration && additionalEmails == other.additionalEmails && autoCollection == other.autoCollection && billingAddress == other.billingAddress && currency == other.currency && emailDelivery == other.emailDelivery && externalCustomerId == other.externalCustomerId && hierarchy == other.hierarchy && metadata == other.metadata && paymentProvider == other.paymentProvider && paymentProviderId == other.paymentProviderId && reportingConfiguration == other.reportingConfiguration && shippingAddress == other.shippingAddress && taxConfiguration == other.taxConfiguration && taxId == other.taxId && timezone == other.timezone && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Body && + email == other.email && + name == other.name && + accountingSyncConfiguration == other.accountingSyncConfiguration && + additionalEmails == other.additionalEmails && + autoCollection == other.autoCollection && + billingAddress == other.billingAddress && + currency == other.currency && + emailDelivery == other.emailDelivery && + externalCustomerId == other.externalCustomerId && + hierarchy == other.hierarchy && + metadata == other.metadata && + paymentProvider == other.paymentProvider && + paymentProviderId == other.paymentProviderId && + reportingConfiguration == other.reportingConfiguration && + shippingAddress == other.shippingAddress && + taxConfiguration == other.taxConfiguration && + taxId == other.taxId && + timezone == other.timezone && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + email, + name, + accountingSyncConfiguration, + additionalEmails, + autoCollection, + billingAddress, + currency, + emailDelivery, + externalCustomerId, + hierarchy, + metadata, + paymentProvider, + paymentProviderId, + reportingConfiguration, + shippingAddress, + taxConfiguration, + taxId, + timezone, + additionalProperties, + ) } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(email, name, accountingSyncConfiguration, additionalEmails, autoCollection, billingAddress, currency, emailDelivery, externalCustomerId, hierarchy, metadata, paymentProvider, paymentProviderId, reportingConfiguration, shippingAddress, taxConfiguration, taxId, timezone, additionalProperties) } - /* spotless:on */ - override fun hashCode(): Int = hashCode override fun toString() = @@ -2529,12 +2568,10 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -2683,7 +2720,7 @@ private constructor( return true } - return /* spotless:off */ other is PaymentProvider && value == other.value /* spotless:on */ + return other is PaymentProvider && value == other.value } override fun hashCode() = value.hashCode() @@ -2787,10 +2824,13 @@ private constructor( return true } - return /* spotless:off */ other is TaxConfiguration && avalara == other.avalara && taxjar == other.taxjar && sphere == other.sphere /* spotless:on */ + return other is TaxConfiguration && + avalara == other.avalara && + taxjar == other.taxjar && + sphere == other.sphere } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(avalara, taxjar, sphere) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(avalara, taxjar, sphere) override fun toString(): String = when { @@ -2888,10 +2928,13 @@ private constructor( return true } - return /* spotless:off */ other is CustomerCreateParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return other is CustomerCreateParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(body, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) override fun toString() = "CustomerCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdParams.kt index 790745c85..5421e637c 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdParams.kt @@ -498,10 +498,16 @@ private constructor( return true } - return /* spotless:off */ other is Body && increment == other.increment && decrement == other.decrement && expirationChange == other.expirationChange && void == other.void && amendment == other.amendment /* spotless:on */ + return other is Body && + increment == other.increment && + decrement == other.decrement && + expirationChange == other.expirationChange && + void == other.void && + amendment == other.amendment } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(increment, decrement, expirationChange, void, amendment) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash(increment, decrement, expirationChange, void, amendment) override fun toString(): String = when { @@ -1570,10 +1576,12 @@ private constructor( return true } - return /* spotless:off */ other is InvoiceDate && date == other.date && dateTime == other.dateTime /* spotless:on */ + return other is InvoiceDate && + date == other.date && + dateTime == other.dateTime } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(date, dateTime) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(date, dateTime) override fun toString(): String = when { @@ -1669,12 +1677,25 @@ private constructor( return true } - return /* spotless:off */ other is InvoiceSettings && autoCollection == other.autoCollection && netTerms == other.netTerms && invoiceDate == other.invoiceDate && memo == other.memo && requireSuccessfulPayment == other.requireSuccessfulPayment && additionalProperties == other.additionalProperties /* spotless:on */ + return other is InvoiceSettings && + autoCollection == other.autoCollection && + netTerms == other.netTerms && + invoiceDate == other.invoiceDate && + memo == other.memo && + requireSuccessfulPayment == other.requireSuccessfulPayment && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(autoCollection, netTerms, invoiceDate, memo, requireSuccessfulPayment, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + autoCollection, + netTerms, + invoiceDate, + memo, + requireSuccessfulPayment, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode @@ -1779,12 +1800,10 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1796,12 +1815,33 @@ private constructor( return true } - return /* spotless:off */ other is Increment && amount == other.amount && entryType == other.entryType && currency == other.currency && description == other.description && effectiveDate == other.effectiveDate && expiryDate == other.expiryDate && invoiceSettings == other.invoiceSettings && metadata == other.metadata && perUnitCostBasis == other.perUnitCostBasis && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Increment && + amount == other.amount && + entryType == other.entryType && + currency == other.currency && + description == other.description && + effectiveDate == other.effectiveDate && + expiryDate == other.expiryDate && + invoiceSettings == other.invoiceSettings && + metadata == other.metadata && + perUnitCostBasis == other.perUnitCostBasis && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(amount, entryType, currency, description, effectiveDate, expiryDate, invoiceSettings, metadata, perUnitCostBasis, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + amount, + entryType, + currency, + description, + effectiveDate, + expiryDate, + invoiceSettings, + metadata, + perUnitCostBasis, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode @@ -2226,12 +2266,10 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -2243,12 +2281,25 @@ private constructor( return true } - return /* spotless:off */ other is Decrement && amount == other.amount && entryType == other.entryType && currency == other.currency && description == other.description && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Decrement && + amount == other.amount && + entryType == other.entryType && + currency == other.currency && + description == other.description && + metadata == other.metadata && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(amount, entryType, currency, description, metadata, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + amount, + entryType, + currency, + description, + metadata, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode @@ -2821,12 +2872,10 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -2838,12 +2887,31 @@ private constructor( return true } - return /* spotless:off */ other is ExpirationChange && entryType == other.entryType && targetExpiryDate == other.targetExpiryDate && amount == other.amount && blockId == other.blockId && currency == other.currency && description == other.description && expiryDate == other.expiryDate && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is ExpirationChange && + entryType == other.entryType && + targetExpiryDate == other.targetExpiryDate && + amount == other.amount && + blockId == other.blockId && + currency == other.currency && + description == other.description && + expiryDate == other.expiryDate && + metadata == other.metadata && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(entryType, targetExpiryDate, amount, blockId, currency, description, expiryDate, metadata, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + entryType, + targetExpiryDate, + amount, + blockId, + currency, + description, + expiryDate, + metadata, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode @@ -3358,12 +3426,10 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -3487,7 +3553,7 @@ private constructor( return true } - return /* spotless:off */ other is VoidReason && value == other.value /* spotless:on */ + return other is VoidReason && value == other.value } override fun hashCode() = value.hashCode() @@ -3500,12 +3566,29 @@ private constructor( return true } - return /* spotless:off */ other is Void && amount == other.amount && blockId == other.blockId && entryType == other.entryType && currency == other.currency && description == other.description && metadata == other.metadata && voidReason == other.voidReason && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Void && + amount == other.amount && + blockId == other.blockId && + entryType == other.entryType && + currency == other.currency && + description == other.description && + metadata == other.metadata && + voidReason == other.voidReason && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(amount, blockId, entryType, currency, description, metadata, voidReason, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + amount, + blockId, + entryType, + currency, + description, + metadata, + voidReason, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode @@ -3969,12 +4052,10 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -3986,12 +4067,27 @@ private constructor( return true } - return /* spotless:off */ other is Amendment && amount == other.amount && blockId == other.blockId && entryType == other.entryType && currency == other.currency && description == other.description && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Amendment && + amount == other.amount && + blockId == other.blockId && + entryType == other.entryType && + currency == other.currency && + description == other.description && + metadata == other.metadata && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(amount, blockId, entryType, currency, description, metadata, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + amount, + blockId, + entryType, + currency, + description, + metadata, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode @@ -4005,10 +4101,15 @@ private constructor( return true } - return /* spotless:off */ other is CustomerCreditLedgerCreateEntryByExternalIdParams && externalCustomerId == other.externalCustomerId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return other is CustomerCreditLedgerCreateEntryByExternalIdParams && + externalCustomerId == other.externalCustomerId && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(externalCustomerId, body, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash(externalCustomerId, body, additionalHeaders, additionalQueryParams) override fun toString() = "CustomerCreditLedgerCreateEntryByExternalIdParams{externalCustomerId=$externalCustomerId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdResponse.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdResponse.kt index d26af9036..1d93f593f 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdResponse.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdResponse.kt @@ -178,10 +178,26 @@ private constructor( return true } - return /* spotless:off */ other is CustomerCreditLedgerCreateEntryByExternalIdResponse && increment == other.increment && decrement == other.decrement && expirationChange == other.expirationChange && creditBlockExpiry == other.creditBlockExpiry && void == other.void && voidInitiated == other.voidInitiated && amendment == other.amendment /* spotless:on */ + return other is CustomerCreditLedgerCreateEntryByExternalIdResponse && + increment == other.increment && + decrement == other.decrement && + expirationChange == other.expirationChange && + creditBlockExpiry == other.creditBlockExpiry && + void == other.void && + voidInitiated == other.voidInitiated && + amendment == other.amendment } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(increment, decrement, expirationChange, creditBlockExpiry, void, voidInitiated, amendment) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash( + increment, + decrement, + expirationChange, + creditBlockExpiry, + void, + voidInitiated, + amendment, + ) override fun toString(): String = when { diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryParams.kt index d59142cc8..6fbbb9e34 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryParams.kt @@ -493,10 +493,16 @@ private constructor( return true } - return /* spotless:off */ other is Body && increment == other.increment && decrement == other.decrement && expirationChange == other.expirationChange && void == other.void && amendment == other.amendment /* spotless:on */ + return other is Body && + increment == other.increment && + decrement == other.decrement && + expirationChange == other.expirationChange && + void == other.void && + amendment == other.amendment } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(increment, decrement, expirationChange, void, amendment) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash(increment, decrement, expirationChange, void, amendment) override fun toString(): String = when { @@ -1565,10 +1571,12 @@ private constructor( return true } - return /* spotless:off */ other is InvoiceDate && date == other.date && dateTime == other.dateTime /* spotless:on */ + return other is InvoiceDate && + date == other.date && + dateTime == other.dateTime } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(date, dateTime) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(date, dateTime) override fun toString(): String = when { @@ -1664,12 +1672,25 @@ private constructor( return true } - return /* spotless:off */ other is InvoiceSettings && autoCollection == other.autoCollection && netTerms == other.netTerms && invoiceDate == other.invoiceDate && memo == other.memo && requireSuccessfulPayment == other.requireSuccessfulPayment && additionalProperties == other.additionalProperties /* spotless:on */ + return other is InvoiceSettings && + autoCollection == other.autoCollection && + netTerms == other.netTerms && + invoiceDate == other.invoiceDate && + memo == other.memo && + requireSuccessfulPayment == other.requireSuccessfulPayment && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(autoCollection, netTerms, invoiceDate, memo, requireSuccessfulPayment, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + autoCollection, + netTerms, + invoiceDate, + memo, + requireSuccessfulPayment, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode @@ -1774,12 +1795,10 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1791,12 +1810,33 @@ private constructor( return true } - return /* spotless:off */ other is Increment && amount == other.amount && entryType == other.entryType && currency == other.currency && description == other.description && effectiveDate == other.effectiveDate && expiryDate == other.expiryDate && invoiceSettings == other.invoiceSettings && metadata == other.metadata && perUnitCostBasis == other.perUnitCostBasis && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Increment && + amount == other.amount && + entryType == other.entryType && + currency == other.currency && + description == other.description && + effectiveDate == other.effectiveDate && + expiryDate == other.expiryDate && + invoiceSettings == other.invoiceSettings && + metadata == other.metadata && + perUnitCostBasis == other.perUnitCostBasis && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(amount, entryType, currency, description, effectiveDate, expiryDate, invoiceSettings, metadata, perUnitCostBasis, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + amount, + entryType, + currency, + description, + effectiveDate, + expiryDate, + invoiceSettings, + metadata, + perUnitCostBasis, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode @@ -2221,12 +2261,10 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -2238,12 +2276,25 @@ private constructor( return true } - return /* spotless:off */ other is Decrement && amount == other.amount && entryType == other.entryType && currency == other.currency && description == other.description && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Decrement && + amount == other.amount && + entryType == other.entryType && + currency == other.currency && + description == other.description && + metadata == other.metadata && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(amount, entryType, currency, description, metadata, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + amount, + entryType, + currency, + description, + metadata, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode @@ -2816,12 +2867,10 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -2833,12 +2882,31 @@ private constructor( return true } - return /* spotless:off */ other is ExpirationChange && entryType == other.entryType && targetExpiryDate == other.targetExpiryDate && amount == other.amount && blockId == other.blockId && currency == other.currency && description == other.description && expiryDate == other.expiryDate && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is ExpirationChange && + entryType == other.entryType && + targetExpiryDate == other.targetExpiryDate && + amount == other.amount && + blockId == other.blockId && + currency == other.currency && + description == other.description && + expiryDate == other.expiryDate && + metadata == other.metadata && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(entryType, targetExpiryDate, amount, blockId, currency, description, expiryDate, metadata, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + entryType, + targetExpiryDate, + amount, + blockId, + currency, + description, + expiryDate, + metadata, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode @@ -3353,12 +3421,10 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -3482,7 +3548,7 @@ private constructor( return true } - return /* spotless:off */ other is VoidReason && value == other.value /* spotless:on */ + return other is VoidReason && value == other.value } override fun hashCode() = value.hashCode() @@ -3495,12 +3561,29 @@ private constructor( return true } - return /* spotless:off */ other is Void && amount == other.amount && blockId == other.blockId && entryType == other.entryType && currency == other.currency && description == other.description && metadata == other.metadata && voidReason == other.voidReason && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Void && + amount == other.amount && + blockId == other.blockId && + entryType == other.entryType && + currency == other.currency && + description == other.description && + metadata == other.metadata && + voidReason == other.voidReason && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(amount, blockId, entryType, currency, description, metadata, voidReason, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + amount, + blockId, + entryType, + currency, + description, + metadata, + voidReason, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode @@ -3964,12 +4047,10 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -3981,12 +4062,27 @@ private constructor( return true } - return /* spotless:off */ other is Amendment && amount == other.amount && blockId == other.blockId && entryType == other.entryType && currency == other.currency && description == other.description && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Amendment && + amount == other.amount && + blockId == other.blockId && + entryType == other.entryType && + currency == other.currency && + description == other.description && + metadata == other.metadata && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(amount, blockId, entryType, currency, description, metadata, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + amount, + blockId, + entryType, + currency, + description, + metadata, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode @@ -4000,10 +4096,15 @@ private constructor( return true } - return /* spotless:off */ other is CustomerCreditLedgerCreateEntryParams && customerId == other.customerId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return other is CustomerCreditLedgerCreateEntryParams && + customerId == other.customerId && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(customerId, body, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash(customerId, body, additionalHeaders, additionalQueryParams) override fun toString() = "CustomerCreditLedgerCreateEntryParams{customerId=$customerId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryResponse.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryResponse.kt index 3be0c9ae4..a7f4523af 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryResponse.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryResponse.kt @@ -178,10 +178,26 @@ private constructor( return true } - return /* spotless:off */ other is CustomerCreditLedgerCreateEntryResponse && increment == other.increment && decrement == other.decrement && expirationChange == other.expirationChange && creditBlockExpiry == other.creditBlockExpiry && void == other.void && voidInitiated == other.voidInitiated && amendment == other.amendment /* spotless:on */ + return other is CustomerCreditLedgerCreateEntryResponse && + increment == other.increment && + decrement == other.decrement && + expirationChange == other.expirationChange && + creditBlockExpiry == other.creditBlockExpiry && + void == other.void && + voidInitiated == other.voidInitiated && + amendment == other.amendment } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(increment, decrement, expirationChange, creditBlockExpiry, void, voidInitiated, amendment) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash( + increment, + decrement, + expirationChange, + creditBlockExpiry, + void, + voidInitiated, + amendment, + ) override fun toString(): String = when { diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdPage.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdPage.kt index 2d92b28e5..1e9f4a442 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdPage.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdPage.kt @@ -130,10 +130,13 @@ private constructor( return true } - return /* spotless:off */ other is CustomerCreditLedgerListByExternalIdPage && service == other.service && params == other.params && response == other.response /* spotless:on */ + return other is CustomerCreditLedgerListByExternalIdPage && + service == other.service && + params == other.params && + response == other.response } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, params, response) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(service, params, response) override fun toString() = "CustomerCreditLedgerListByExternalIdPage{service=$service, params=$params, response=$response}" diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdPageAsync.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdPageAsync.kt index 0d01458ba..d2cd4e7a0 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdPageAsync.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdPageAsync.kt @@ -132,10 +132,13 @@ private constructor( return true } - return /* spotless:off */ other is CustomerCreditLedgerListByExternalIdPageAsync && service == other.service && params == other.params && response == other.response /* spotless:on */ + return other is CustomerCreditLedgerListByExternalIdPageAsync && + service == other.service && + params == other.params && + response == other.response } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, params, response) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(service, params, response) override fun toString() = "CustomerCreditLedgerListByExternalIdPageAsync{service=$service, params=$params, response=$response}" diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdPageResponse.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdPageResponse.kt index a248895d3..da019361d 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdPageResponse.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdPageResponse.kt @@ -278,12 +278,15 @@ private constructor( return true } - return /* spotless:off */ other is CustomerCreditLedgerListByExternalIdPageResponse && data == other.data && paginationMetadata == other.paginationMetadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is CustomerCreditLedgerListByExternalIdPageResponse && + data == other.data && + paginationMetadata == other.paginationMetadata && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(data, paginationMetadata, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash(data, paginationMetadata, additionalProperties) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdParams.kt index a4ac857d0..7ed1acdbe 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdParams.kt @@ -501,7 +501,7 @@ private constructor( return true } - return /* spotless:off */ other is EntryStatus && value == other.value /* spotless:on */ + return other is EntryStatus && value == other.value } override fun hashCode() = value.hashCode() @@ -657,7 +657,7 @@ private constructor( return true } - return /* spotless:off */ other is EntryType && value == other.value /* spotless:on */ + return other is EntryType && value == other.value } override fun hashCode() = value.hashCode() @@ -670,10 +670,38 @@ private constructor( return true } - return /* spotless:off */ other is CustomerCreditLedgerListByExternalIdParams && externalCustomerId == other.externalCustomerId && createdAtGt == other.createdAtGt && createdAtGte == other.createdAtGte && createdAtLt == other.createdAtLt && createdAtLte == other.createdAtLte && currency == other.currency && cursor == other.cursor && entryStatus == other.entryStatus && entryType == other.entryType && limit == other.limit && minimumAmount == other.minimumAmount && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return other is CustomerCreditLedgerListByExternalIdParams && + externalCustomerId == other.externalCustomerId && + createdAtGt == other.createdAtGt && + createdAtGte == other.createdAtGte && + createdAtLt == other.createdAtLt && + createdAtLte == other.createdAtLte && + currency == other.currency && + cursor == other.cursor && + entryStatus == other.entryStatus && + entryType == other.entryType && + limit == other.limit && + minimumAmount == other.minimumAmount && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(externalCustomerId, createdAtGt, createdAtGte, createdAtLt, createdAtLte, currency, cursor, entryStatus, entryType, limit, minimumAmount, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash( + externalCustomerId, + createdAtGt, + createdAtGte, + createdAtLt, + createdAtLte, + currency, + cursor, + entryStatus, + entryType, + limit, + minimumAmount, + additionalHeaders, + additionalQueryParams, + ) override fun toString() = "CustomerCreditLedgerListByExternalIdParams{externalCustomerId=$externalCustomerId, createdAtGt=$createdAtGt, createdAtGte=$createdAtGte, createdAtLt=$createdAtLt, createdAtLte=$createdAtLte, currency=$currency, cursor=$cursor, entryStatus=$entryStatus, entryType=$entryType, limit=$limit, minimumAmount=$minimumAmount, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdResponse.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdResponse.kt index cf48ff33d..21d3a3eba 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdResponse.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdResponse.kt @@ -178,10 +178,26 @@ private constructor( return true } - return /* spotless:off */ other is CustomerCreditLedgerListByExternalIdResponse && increment == other.increment && decrement == other.decrement && expirationChange == other.expirationChange && creditBlockExpiry == other.creditBlockExpiry && void == other.void && voidInitiated == other.voidInitiated && amendment == other.amendment /* spotless:on */ + return other is CustomerCreditLedgerListByExternalIdResponse && + increment == other.increment && + decrement == other.decrement && + expirationChange == other.expirationChange && + creditBlockExpiry == other.creditBlockExpiry && + void == other.void && + voidInitiated == other.voidInitiated && + amendment == other.amendment } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(increment, decrement, expirationChange, creditBlockExpiry, void, voidInitiated, amendment) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash( + increment, + decrement, + expirationChange, + creditBlockExpiry, + void, + voidInitiated, + amendment, + ) override fun toString(): String = when { diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListPage.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListPage.kt index c7aa09d43..fd056d355 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListPage.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListPage.kt @@ -122,10 +122,13 @@ private constructor( return true } - return /* spotless:off */ other is CustomerCreditLedgerListPage && service == other.service && params == other.params && response == other.response /* spotless:on */ + return other is CustomerCreditLedgerListPage && + service == other.service && + params == other.params && + response == other.response } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, params, response) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(service, params, response) override fun toString() = "CustomerCreditLedgerListPage{service=$service, params=$params, response=$response}" diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListPageAsync.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListPageAsync.kt index 1011f5706..3ba390fc5 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListPageAsync.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListPageAsync.kt @@ -125,10 +125,13 @@ private constructor( return true } - return /* spotless:off */ other is CustomerCreditLedgerListPageAsync && service == other.service && params == other.params && response == other.response /* spotless:on */ + return other is CustomerCreditLedgerListPageAsync && + service == other.service && + params == other.params && + response == other.response } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, params, response) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(service, params, response) override fun toString() = "CustomerCreditLedgerListPageAsync{service=$service, params=$params, response=$response}" diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListPageResponse.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListPageResponse.kt index 30af421fe..9a4ce4176 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListPageResponse.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListPageResponse.kt @@ -267,12 +267,15 @@ private constructor( return true } - return /* spotless:off */ other is CustomerCreditLedgerListPageResponse && data == other.data && paginationMetadata == other.paginationMetadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is CustomerCreditLedgerListPageResponse && + data == other.data && + paginationMetadata == other.paginationMetadata && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(data, paginationMetadata, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash(data, paginationMetadata, additionalProperties) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListParams.kt index 89edeba4c..bc2fa9d24 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListParams.kt @@ -495,7 +495,7 @@ private constructor( return true } - return /* spotless:off */ other is EntryStatus && value == other.value /* spotless:on */ + return other is EntryStatus && value == other.value } override fun hashCode() = value.hashCode() @@ -651,7 +651,7 @@ private constructor( return true } - return /* spotless:off */ other is EntryType && value == other.value /* spotless:on */ + return other is EntryType && value == other.value } override fun hashCode() = value.hashCode() @@ -664,10 +664,38 @@ private constructor( return true } - return /* spotless:off */ other is CustomerCreditLedgerListParams && customerId == other.customerId && createdAtGt == other.createdAtGt && createdAtGte == other.createdAtGte && createdAtLt == other.createdAtLt && createdAtLte == other.createdAtLte && currency == other.currency && cursor == other.cursor && entryStatus == other.entryStatus && entryType == other.entryType && limit == other.limit && minimumAmount == other.minimumAmount && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return other is CustomerCreditLedgerListParams && + customerId == other.customerId && + createdAtGt == other.createdAtGt && + createdAtGte == other.createdAtGte && + createdAtLt == other.createdAtLt && + createdAtLte == other.createdAtLte && + currency == other.currency && + cursor == other.cursor && + entryStatus == other.entryStatus && + entryType == other.entryType && + limit == other.limit && + minimumAmount == other.minimumAmount && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(customerId, createdAtGt, createdAtGte, createdAtLt, createdAtLte, currency, cursor, entryStatus, entryType, limit, minimumAmount, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash( + customerId, + createdAtGt, + createdAtGte, + createdAtLt, + createdAtLte, + currency, + cursor, + entryStatus, + entryType, + limit, + minimumAmount, + additionalHeaders, + additionalQueryParams, + ) override fun toString() = "CustomerCreditLedgerListParams{customerId=$customerId, createdAtGt=$createdAtGt, createdAtGte=$createdAtGte, createdAtLt=$createdAtLt, createdAtLte=$createdAtLte, currency=$currency, cursor=$cursor, entryStatus=$entryStatus, entryType=$entryType, limit=$limit, minimumAmount=$minimumAmount, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListResponse.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListResponse.kt index 324a61d6f..1312dde4d 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListResponse.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListResponse.kt @@ -178,10 +178,26 @@ private constructor( return true } - return /* spotless:off */ other is CustomerCreditLedgerListResponse && increment == other.increment && decrement == other.decrement && expirationChange == other.expirationChange && creditBlockExpiry == other.creditBlockExpiry && void == other.void && voidInitiated == other.voidInitiated && amendment == other.amendment /* spotless:on */ + return other is CustomerCreditLedgerListResponse && + increment == other.increment && + decrement == other.decrement && + expirationChange == other.expirationChange && + creditBlockExpiry == other.creditBlockExpiry && + void == other.void && + voidInitiated == other.voidInitiated && + amendment == other.amendment } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(increment, decrement, expirationChange, creditBlockExpiry, void, voidInitiated, amendment) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash( + increment, + decrement, + expirationChange, + creditBlockExpiry, + void, + voidInitiated, + amendment, + ) override fun toString(): String = when { diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdPage.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdPage.kt index ebaa10011..aa2f0bc9b 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdPage.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdPage.kt @@ -127,10 +127,13 @@ private constructor( return true } - return /* spotless:off */ other is CustomerCreditListByExternalIdPage && service == other.service && params == other.params && response == other.response /* spotless:on */ + return other is CustomerCreditListByExternalIdPage && + service == other.service && + params == other.params && + response == other.response } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, params, response) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(service, params, response) override fun toString() = "CustomerCreditListByExternalIdPage{service=$service, params=$params, response=$response}" diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdPageAsync.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdPageAsync.kt index dc8e1ff83..9f7acb88d 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdPageAsync.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdPageAsync.kt @@ -129,10 +129,13 @@ private constructor( return true } - return /* spotless:off */ other is CustomerCreditListByExternalIdPageAsync && service == other.service && params == other.params && response == other.response /* spotless:on */ + return other is CustomerCreditListByExternalIdPageAsync && + service == other.service && + params == other.params && + response == other.response } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, params, response) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(service, params, response) override fun toString() = "CustomerCreditListByExternalIdPageAsync{service=$service, params=$params, response=$response}" diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdPageResponse.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdPageResponse.kt index f13939a8c..fe4444ead 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdPageResponse.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdPageResponse.kt @@ -222,12 +222,15 @@ private constructor( return true } - return /* spotless:off */ other is CustomerCreditListByExternalIdPageResponse && data == other.data && paginationMetadata == other.paginationMetadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is CustomerCreditListByExternalIdPageResponse && + data == other.data && + paginationMetadata == other.paginationMetadata && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(data, paginationMetadata, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash(data, paginationMetadata, additionalProperties) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdParams.kt index 2dc457a3f..eef95cfd7 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdParams.kt @@ -267,10 +267,26 @@ private constructor( return true } - return /* spotless:off */ other is CustomerCreditListByExternalIdParams && externalCustomerId == other.externalCustomerId && currency == other.currency && cursor == other.cursor && includeAllBlocks == other.includeAllBlocks && limit == other.limit && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return other is CustomerCreditListByExternalIdParams && + externalCustomerId == other.externalCustomerId && + currency == other.currency && + cursor == other.cursor && + includeAllBlocks == other.includeAllBlocks && + limit == other.limit && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(externalCustomerId, currency, cursor, includeAllBlocks, limit, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash( + externalCustomerId, + currency, + cursor, + includeAllBlocks, + limit, + additionalHeaders, + additionalQueryParams, + ) override fun toString() = "CustomerCreditListByExternalIdParams{externalCustomerId=$externalCustomerId, currency=$currency, cursor=$cursor, includeAllBlocks=$includeAllBlocks, limit=$limit, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdResponse.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdResponse.kt index 01ae4cb75..97f093015 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdResponse.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdResponse.kt @@ -515,7 +515,7 @@ private constructor( return true } - return /* spotless:off */ other is Status && value == other.value /* spotless:on */ + return other is Status && value == other.value } override fun hashCode() = value.hashCode() @@ -528,12 +528,29 @@ private constructor( return true } - return /* spotless:off */ other is CustomerCreditListByExternalIdResponse && id == other.id && balance == other.balance && effectiveDate == other.effectiveDate && expiryDate == other.expiryDate && maximumInitialBalance == other.maximumInitialBalance && perUnitCostBasis == other.perUnitCostBasis && status == other.status && additionalProperties == other.additionalProperties /* spotless:on */ + return other is CustomerCreditListByExternalIdResponse && + id == other.id && + balance == other.balance && + effectiveDate == other.effectiveDate && + expiryDate == other.expiryDate && + maximumInitialBalance == other.maximumInitialBalance && + perUnitCostBasis == other.perUnitCostBasis && + status == other.status && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, balance, effectiveDate, expiryDate, maximumInitialBalance, perUnitCostBasis, status, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + id, + balance, + effectiveDate, + expiryDate, + maximumInitialBalance, + perUnitCostBasis, + status, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListPage.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListPage.kt index e032eaead..55e947864 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListPage.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListPage.kt @@ -120,10 +120,13 @@ private constructor( return true } - return /* spotless:off */ other is CustomerCreditListPage && service == other.service && params == other.params && response == other.response /* spotless:on */ + return other is CustomerCreditListPage && + service == other.service && + params == other.params && + response == other.response } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, params, response) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(service, params, response) override fun toString() = "CustomerCreditListPage{service=$service, params=$params, response=$response}" diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListPageAsync.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListPageAsync.kt index 8ac48dd15..32f6b48bc 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListPageAsync.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListPageAsync.kt @@ -120,10 +120,13 @@ private constructor( return true } - return /* spotless:off */ other is CustomerCreditListPageAsync && service == other.service && params == other.params && response == other.response /* spotless:on */ + return other is CustomerCreditListPageAsync && + service == other.service && + params == other.params && + response == other.response } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, params, response) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(service, params, response) override fun toString() = "CustomerCreditListPageAsync{service=$service, params=$params, response=$response}" diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListPageResponse.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListPageResponse.kt index 5271b0e11..cc4d3f143 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListPageResponse.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListPageResponse.kt @@ -220,12 +220,15 @@ private constructor( return true } - return /* spotless:off */ other is CustomerCreditListPageResponse && data == other.data && paginationMetadata == other.paginationMetadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is CustomerCreditListPageResponse && + data == other.data && + paginationMetadata == other.paginationMetadata && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(data, paginationMetadata, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash(data, paginationMetadata, additionalProperties) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListParams.kt index 32af494c1..0920dd6f5 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListParams.kt @@ -259,10 +259,26 @@ private constructor( return true } - return /* spotless:off */ other is CustomerCreditListParams && customerId == other.customerId && currency == other.currency && cursor == other.cursor && includeAllBlocks == other.includeAllBlocks && limit == other.limit && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return other is CustomerCreditListParams && + customerId == other.customerId && + currency == other.currency && + cursor == other.cursor && + includeAllBlocks == other.includeAllBlocks && + limit == other.limit && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(customerId, currency, cursor, includeAllBlocks, limit, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash( + customerId, + currency, + cursor, + includeAllBlocks, + limit, + additionalHeaders, + additionalQueryParams, + ) override fun toString() = "CustomerCreditListParams{customerId=$customerId, currency=$currency, cursor=$cursor, includeAllBlocks=$includeAllBlocks, limit=$limit, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListResponse.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListResponse.kt index 3cd166182..4c8617e4b 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListResponse.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListResponse.kt @@ -511,7 +511,7 @@ private constructor( return true } - return /* spotless:off */ other is Status && value == other.value /* spotless:on */ + return other is Status && value == other.value } override fun hashCode() = value.hashCode() @@ -524,12 +524,29 @@ private constructor( return true } - return /* spotless:off */ other is CustomerCreditListResponse && id == other.id && balance == other.balance && effectiveDate == other.effectiveDate && expiryDate == other.expiryDate && maximumInitialBalance == other.maximumInitialBalance && perUnitCostBasis == other.perUnitCostBasis && status == other.status && additionalProperties == other.additionalProperties /* spotless:on */ + return other is CustomerCreditListResponse && + id == other.id && + balance == other.balance && + effectiveDate == other.effectiveDate && + expiryDate == other.expiryDate && + maximumInitialBalance == other.maximumInitialBalance && + perUnitCostBasis == other.perUnitCostBasis && + status == other.status && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, balance, effectiveDate, expiryDate, maximumInitialBalance, perUnitCostBasis, status, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + id, + balance, + effectiveDate, + expiryDate, + maximumInitialBalance, + perUnitCostBasis, + status, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpCreateByExternalIdParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpCreateByExternalIdParams.kt index 1d7a68302..82bd83504 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpCreateByExternalIdParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpCreateByExternalIdParams.kt @@ -977,12 +977,31 @@ private constructor( return true } - return /* spotless:off */ other is Body && amount == other.amount && currency == other.currency && invoiceSettings == other.invoiceSettings && perUnitCostBasis == other.perUnitCostBasis && threshold == other.threshold && activeFrom == other.activeFrom && expiresAfter == other.expiresAfter && expiresAfterUnit == other.expiresAfterUnit && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Body && + amount == other.amount && + currency == other.currency && + invoiceSettings == other.invoiceSettings && + perUnitCostBasis == other.perUnitCostBasis && + threshold == other.threshold && + activeFrom == other.activeFrom && + expiresAfter == other.expiresAfter && + expiresAfterUnit == other.expiresAfterUnit && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(amount, currency, invoiceSettings, perUnitCostBasis, threshold, activeFrom, expiresAfter, expiresAfterUnit, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + amount, + currency, + invoiceSettings, + perUnitCostBasis, + threshold, + activeFrom, + expiresAfter, + expiresAfterUnit, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode @@ -1272,12 +1291,23 @@ private constructor( return true } - return /* spotless:off */ other is InvoiceSettings && autoCollection == other.autoCollection && netTerms == other.netTerms && memo == other.memo && requireSuccessfulPayment == other.requireSuccessfulPayment && additionalProperties == other.additionalProperties /* spotless:on */ + return other is InvoiceSettings && + autoCollection == other.autoCollection && + netTerms == other.netTerms && + memo == other.memo && + requireSuccessfulPayment == other.requireSuccessfulPayment && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(autoCollection, netTerms, memo, requireSuccessfulPayment, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + autoCollection, + netTerms, + memo, + requireSuccessfulPayment, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode @@ -1406,7 +1436,7 @@ private constructor( return true } - return /* spotless:off */ other is ExpiresAfterUnit && value == other.value /* spotless:on */ + return other is ExpiresAfterUnit && value == other.value } override fun hashCode() = value.hashCode() @@ -1419,10 +1449,15 @@ private constructor( return true } - return /* spotless:off */ other is CustomerCreditTopUpCreateByExternalIdParams && externalCustomerId == other.externalCustomerId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return other is CustomerCreditTopUpCreateByExternalIdParams && + externalCustomerId == other.externalCustomerId && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(externalCustomerId, body, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash(externalCustomerId, body, additionalHeaders, additionalQueryParams) override fun toString() = "CustomerCreditTopUpCreateByExternalIdParams{externalCustomerId=$externalCustomerId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpCreateByExternalIdResponse.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpCreateByExternalIdResponse.kt index 9ef08c81f..065786212 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpCreateByExternalIdResponse.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpCreateByExternalIdResponse.kt @@ -579,7 +579,7 @@ private constructor( return true } - return /* spotless:off */ other is ExpiresAfterUnit && value == other.value /* spotless:on */ + return other is ExpiresAfterUnit && value == other.value } override fun hashCode() = value.hashCode() @@ -592,12 +592,31 @@ private constructor( return true } - return /* spotless:off */ other is CustomerCreditTopUpCreateByExternalIdResponse && id == other.id && amount == other.amount && currency == other.currency && invoiceSettings == other.invoiceSettings && perUnitCostBasis == other.perUnitCostBasis && threshold == other.threshold && expiresAfter == other.expiresAfter && expiresAfterUnit == other.expiresAfterUnit && additionalProperties == other.additionalProperties /* spotless:on */ + return other is CustomerCreditTopUpCreateByExternalIdResponse && + id == other.id && + amount == other.amount && + currency == other.currency && + invoiceSettings == other.invoiceSettings && + perUnitCostBasis == other.perUnitCostBasis && + threshold == other.threshold && + expiresAfter == other.expiresAfter && + expiresAfterUnit == other.expiresAfterUnit && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, amount, currency, invoiceSettings, perUnitCostBasis, threshold, expiresAfter, expiresAfterUnit, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + id, + amount, + currency, + invoiceSettings, + perUnitCostBasis, + threshold, + expiresAfter, + expiresAfterUnit, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpCreateParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpCreateParams.kt index 511102afe..1e3c579a3 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpCreateParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpCreateParams.kt @@ -973,12 +973,31 @@ private constructor( return true } - return /* spotless:off */ other is Body && amount == other.amount && currency == other.currency && invoiceSettings == other.invoiceSettings && perUnitCostBasis == other.perUnitCostBasis && threshold == other.threshold && activeFrom == other.activeFrom && expiresAfter == other.expiresAfter && expiresAfterUnit == other.expiresAfterUnit && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Body && + amount == other.amount && + currency == other.currency && + invoiceSettings == other.invoiceSettings && + perUnitCostBasis == other.perUnitCostBasis && + threshold == other.threshold && + activeFrom == other.activeFrom && + expiresAfter == other.expiresAfter && + expiresAfterUnit == other.expiresAfterUnit && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(amount, currency, invoiceSettings, perUnitCostBasis, threshold, activeFrom, expiresAfter, expiresAfterUnit, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + amount, + currency, + invoiceSettings, + perUnitCostBasis, + threshold, + activeFrom, + expiresAfter, + expiresAfterUnit, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode @@ -1268,12 +1287,23 @@ private constructor( return true } - return /* spotless:off */ other is InvoiceSettings && autoCollection == other.autoCollection && netTerms == other.netTerms && memo == other.memo && requireSuccessfulPayment == other.requireSuccessfulPayment && additionalProperties == other.additionalProperties /* spotless:on */ + return other is InvoiceSettings && + autoCollection == other.autoCollection && + netTerms == other.netTerms && + memo == other.memo && + requireSuccessfulPayment == other.requireSuccessfulPayment && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(autoCollection, netTerms, memo, requireSuccessfulPayment, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + autoCollection, + netTerms, + memo, + requireSuccessfulPayment, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode @@ -1402,7 +1432,7 @@ private constructor( return true } - return /* spotless:off */ other is ExpiresAfterUnit && value == other.value /* spotless:on */ + return other is ExpiresAfterUnit && value == other.value } override fun hashCode() = value.hashCode() @@ -1415,10 +1445,15 @@ private constructor( return true } - return /* spotless:off */ other is CustomerCreditTopUpCreateParams && customerId == other.customerId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return other is CustomerCreditTopUpCreateParams && + customerId == other.customerId && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(customerId, body, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash(customerId, body, additionalHeaders, additionalQueryParams) override fun toString() = "CustomerCreditTopUpCreateParams{customerId=$customerId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpCreateResponse.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpCreateResponse.kt index ad517a80a..d76a547b4 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpCreateResponse.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpCreateResponse.kt @@ -577,7 +577,7 @@ private constructor( return true } - return /* spotless:off */ other is ExpiresAfterUnit && value == other.value /* spotless:on */ + return other is ExpiresAfterUnit && value == other.value } override fun hashCode() = value.hashCode() @@ -590,12 +590,31 @@ private constructor( return true } - return /* spotless:off */ other is CustomerCreditTopUpCreateResponse && id == other.id && amount == other.amount && currency == other.currency && invoiceSettings == other.invoiceSettings && perUnitCostBasis == other.perUnitCostBasis && threshold == other.threshold && expiresAfter == other.expiresAfter && expiresAfterUnit == other.expiresAfterUnit && additionalProperties == other.additionalProperties /* spotless:on */ + return other is CustomerCreditTopUpCreateResponse && + id == other.id && + amount == other.amount && + currency == other.currency && + invoiceSettings == other.invoiceSettings && + perUnitCostBasis == other.perUnitCostBasis && + threshold == other.threshold && + expiresAfter == other.expiresAfter && + expiresAfterUnit == other.expiresAfterUnit && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, amount, currency, invoiceSettings, perUnitCostBasis, threshold, expiresAfter, expiresAfterUnit, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + id, + amount, + currency, + invoiceSettings, + perUnitCostBasis, + threshold, + expiresAfter, + expiresAfterUnit, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpDeleteByExternalIdParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpDeleteByExternalIdParams.kt index 3e1522016..ae27c66c7 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpDeleteByExternalIdParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpDeleteByExternalIdParams.kt @@ -240,10 +240,22 @@ private constructor( return true } - return /* spotless:off */ other is CustomerCreditTopUpDeleteByExternalIdParams && externalCustomerId == other.externalCustomerId && topUpId == other.topUpId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return other is CustomerCreditTopUpDeleteByExternalIdParams && + externalCustomerId == other.externalCustomerId && + topUpId == other.topUpId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(externalCustomerId, topUpId, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash( + externalCustomerId, + topUpId, + additionalHeaders, + additionalQueryParams, + additionalBodyProperties, + ) override fun toString() = "CustomerCreditTopUpDeleteByExternalIdParams{externalCustomerId=$externalCustomerId, topUpId=$topUpId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpDeleteParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpDeleteParams.kt index 28ad8d205..63196684b 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpDeleteParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpDeleteParams.kt @@ -236,10 +236,22 @@ private constructor( return true } - return /* spotless:off */ other is CustomerCreditTopUpDeleteParams && customerId == other.customerId && topUpId == other.topUpId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return other is CustomerCreditTopUpDeleteParams && + customerId == other.customerId && + topUpId == other.topUpId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(customerId, topUpId, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash( + customerId, + topUpId, + additionalHeaders, + additionalQueryParams, + additionalBodyProperties, + ) override fun toString() = "CustomerCreditTopUpDeleteParams{customerId=$customerId, topUpId=$topUpId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListByExternalIdPage.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListByExternalIdPage.kt index d489a15aa..194e98bf7 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListByExternalIdPage.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListByExternalIdPage.kt @@ -130,10 +130,13 @@ private constructor( return true } - return /* spotless:off */ other is CustomerCreditTopUpListByExternalIdPage && service == other.service && params == other.params && response == other.response /* spotless:on */ + return other is CustomerCreditTopUpListByExternalIdPage && + service == other.service && + params == other.params && + response == other.response } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, params, response) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(service, params, response) override fun toString() = "CustomerCreditTopUpListByExternalIdPage{service=$service, params=$params, response=$response}" diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListByExternalIdPageAsync.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListByExternalIdPageAsync.kt index 283a6192e..8d6ba039b 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListByExternalIdPageAsync.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListByExternalIdPageAsync.kt @@ -132,10 +132,13 @@ private constructor( return true } - return /* spotless:off */ other is CustomerCreditTopUpListByExternalIdPageAsync && service == other.service && params == other.params && response == other.response /* spotless:on */ + return other is CustomerCreditTopUpListByExternalIdPageAsync && + service == other.service && + params == other.params && + response == other.response } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, params, response) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(service, params, response) override fun toString() = "CustomerCreditTopUpListByExternalIdPageAsync{service=$service, params=$params, response=$response}" diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListByExternalIdPageResponse.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListByExternalIdPageResponse.kt index ef7def9e6..d24512049 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListByExternalIdPageResponse.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListByExternalIdPageResponse.kt @@ -224,12 +224,15 @@ private constructor( return true } - return /* spotless:off */ other is CustomerCreditTopUpListByExternalIdPageResponse && data == other.data && paginationMetadata == other.paginationMetadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is CustomerCreditTopUpListByExternalIdPageResponse && + data == other.data && + paginationMetadata == other.paginationMetadata && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(data, paginationMetadata, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash(data, paginationMetadata, additionalProperties) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListByExternalIdParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListByExternalIdParams.kt index 91ece0dc1..87e7b7aaa 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListByExternalIdParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListByExternalIdParams.kt @@ -223,10 +223,16 @@ private constructor( return true } - return /* spotless:off */ other is CustomerCreditTopUpListByExternalIdParams && externalCustomerId == other.externalCustomerId && cursor == other.cursor && limit == other.limit && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return other is CustomerCreditTopUpListByExternalIdParams && + externalCustomerId == other.externalCustomerId && + cursor == other.cursor && + limit == other.limit && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(externalCustomerId, cursor, limit, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash(externalCustomerId, cursor, limit, additionalHeaders, additionalQueryParams) override fun toString() = "CustomerCreditTopUpListByExternalIdParams{externalCustomerId=$externalCustomerId, cursor=$cursor, limit=$limit, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListByExternalIdResponse.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListByExternalIdResponse.kt index 38917df56..2715c1ab3 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListByExternalIdResponse.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListByExternalIdResponse.kt @@ -578,7 +578,7 @@ private constructor( return true } - return /* spotless:off */ other is ExpiresAfterUnit && value == other.value /* spotless:on */ + return other is ExpiresAfterUnit && value == other.value } override fun hashCode() = value.hashCode() @@ -591,12 +591,31 @@ private constructor( return true } - return /* spotless:off */ other is CustomerCreditTopUpListByExternalIdResponse && id == other.id && amount == other.amount && currency == other.currency && invoiceSettings == other.invoiceSettings && perUnitCostBasis == other.perUnitCostBasis && threshold == other.threshold && expiresAfter == other.expiresAfter && expiresAfterUnit == other.expiresAfterUnit && additionalProperties == other.additionalProperties /* spotless:on */ + return other is CustomerCreditTopUpListByExternalIdResponse && + id == other.id && + amount == other.amount && + currency == other.currency && + invoiceSettings == other.invoiceSettings && + perUnitCostBasis == other.perUnitCostBasis && + threshold == other.threshold && + expiresAfter == other.expiresAfter && + expiresAfterUnit == other.expiresAfterUnit && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, amount, currency, invoiceSettings, perUnitCostBasis, threshold, expiresAfter, expiresAfterUnit, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + id, + amount, + currency, + invoiceSettings, + perUnitCostBasis, + threshold, + expiresAfter, + expiresAfterUnit, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListPage.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListPage.kt index db9b2978e..fd626521a 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListPage.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListPage.kt @@ -122,10 +122,13 @@ private constructor( return true } - return /* spotless:off */ other is CustomerCreditTopUpListPage && service == other.service && params == other.params && response == other.response /* spotless:on */ + return other is CustomerCreditTopUpListPage && + service == other.service && + params == other.params && + response == other.response } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, params, response) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(service, params, response) override fun toString() = "CustomerCreditTopUpListPage{service=$service, params=$params, response=$response}" diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListPageAsync.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListPageAsync.kt index 06908ff0a..f0f0163cf 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListPageAsync.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListPageAsync.kt @@ -125,10 +125,13 @@ private constructor( return true } - return /* spotless:off */ other is CustomerCreditTopUpListPageAsync && service == other.service && params == other.params && response == other.response /* spotless:on */ + return other is CustomerCreditTopUpListPageAsync && + service == other.service && + params == other.params && + response == other.response } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, params, response) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(service, params, response) override fun toString() = "CustomerCreditTopUpListPageAsync{service=$service, params=$params, response=$response}" diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListPageResponse.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListPageResponse.kt index ff5436023..4682a91f0 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListPageResponse.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListPageResponse.kt @@ -222,12 +222,15 @@ private constructor( return true } - return /* spotless:off */ other is CustomerCreditTopUpListPageResponse && data == other.data && paginationMetadata == other.paginationMetadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is CustomerCreditTopUpListPageResponse && + data == other.data && + paginationMetadata == other.paginationMetadata && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(data, paginationMetadata, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash(data, paginationMetadata, additionalProperties) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListParams.kt index 6a4506d4b..070e21d87 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListParams.kt @@ -217,10 +217,16 @@ private constructor( return true } - return /* spotless:off */ other is CustomerCreditTopUpListParams && customerId == other.customerId && cursor == other.cursor && limit == other.limit && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return other is CustomerCreditTopUpListParams && + customerId == other.customerId && + cursor == other.cursor && + limit == other.limit && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(customerId, cursor, limit, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash(customerId, cursor, limit, additionalHeaders, additionalQueryParams) override fun toString() = "CustomerCreditTopUpListParams{customerId=$customerId, cursor=$cursor, limit=$limit, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListResponse.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListResponse.kt index 9e04ca9a4..56bce2465 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListResponse.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListResponse.kt @@ -577,7 +577,7 @@ private constructor( return true } - return /* spotless:off */ other is ExpiresAfterUnit && value == other.value /* spotless:on */ + return other is ExpiresAfterUnit && value == other.value } override fun hashCode() = value.hashCode() @@ -590,12 +590,31 @@ private constructor( return true } - return /* spotless:off */ other is CustomerCreditTopUpListResponse && id == other.id && amount == other.amount && currency == other.currency && invoiceSettings == other.invoiceSettings && perUnitCostBasis == other.perUnitCostBasis && threshold == other.threshold && expiresAfter == other.expiresAfter && expiresAfterUnit == other.expiresAfterUnit && additionalProperties == other.additionalProperties /* spotless:on */ + return other is CustomerCreditTopUpListResponse && + id == other.id && + amount == other.amount && + currency == other.currency && + invoiceSettings == other.invoiceSettings && + perUnitCostBasis == other.perUnitCostBasis && + threshold == other.threshold && + expiresAfter == other.expiresAfter && + expiresAfterUnit == other.expiresAfterUnit && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, amount, currency, invoiceSettings, perUnitCostBasis, threshold, expiresAfter, expiresAfterUnit, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + id, + amount, + currency, + invoiceSettings, + perUnitCostBasis, + threshold, + expiresAfter, + expiresAfterUnit, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerDeleteParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerDeleteParams.kt index 167cac20f..2641e0913 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerDeleteParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerDeleteParams.kt @@ -218,10 +218,15 @@ private constructor( return true } - return /* spotless:off */ other is CustomerDeleteParams && customerId == other.customerId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return other is CustomerDeleteParams && + customerId == other.customerId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(customerId, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash(customerId, additionalHeaders, additionalQueryParams, additionalBodyProperties) override fun toString() = "CustomerDeleteParams{customerId=$customerId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerFetchByExternalIdParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerFetchByExternalIdParams.kt index 42b0d7acc..ab49748ce 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerFetchByExternalIdParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerFetchByExternalIdParams.kt @@ -187,10 +187,14 @@ private constructor( return true } - return /* spotless:off */ other is CustomerFetchByExternalIdParams && externalCustomerId == other.externalCustomerId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return other is CustomerFetchByExternalIdParams && + externalCustomerId == other.externalCustomerId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(externalCustomerId, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash(externalCustomerId, additionalHeaders, additionalQueryParams) override fun toString() = "CustomerFetchByExternalIdParams{externalCustomerId=$externalCustomerId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerFetchParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerFetchParams.kt index 1762f05fa..fb3900bf2 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerFetchParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerFetchParams.kt @@ -179,10 +179,14 @@ private constructor( return true } - return /* spotless:off */ other is CustomerFetchParams && customerId == other.customerId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return other is CustomerFetchParams && + customerId == other.customerId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(customerId, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash(customerId, additionalHeaders, additionalQueryParams) override fun toString() = "CustomerFetchParams{customerId=$customerId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerHierarchyConfig.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerHierarchyConfig.kt index b26ee4da3..cf699aa71 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerHierarchyConfig.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerHierarchyConfig.kt @@ -215,12 +215,15 @@ private constructor( return true } - return /* spotless:off */ other is CustomerHierarchyConfig && childCustomerIds == other.childCustomerIds && parentCustomerId == other.parentCustomerId && additionalProperties == other.additionalProperties /* spotless:on */ + return other is CustomerHierarchyConfig && + childCustomerIds == other.childCustomerIds && + parentCustomerId == other.parentCustomerId && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(childCustomerIds, parentCustomerId, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash(childCustomerIds, parentCustomerId, additionalProperties) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerListPage.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerListPage.kt index 389df12cc..9420603cc 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerListPage.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerListPage.kt @@ -119,10 +119,13 @@ private constructor( return true } - return /* spotless:off */ other is CustomerListPage && service == other.service && params == other.params && response == other.response /* spotless:on */ + return other is CustomerListPage && + service == other.service && + params == other.params && + response == other.response } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, params, response) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(service, params, response) override fun toString() = "CustomerListPage{service=$service, params=$params, response=$response}" diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerListPageAsync.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerListPageAsync.kt index 671a631b4..e26b9fe5c 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerListPageAsync.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerListPageAsync.kt @@ -119,10 +119,13 @@ private constructor( return true } - return /* spotless:off */ other is CustomerListPageAsync && service == other.service && params == other.params && response == other.response /* spotless:on */ + return other is CustomerListPageAsync && + service == other.service && + params == other.params && + response == other.response } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, params, response) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(service, params, response) override fun toString() = "CustomerListPageAsync{service=$service, params=$params, response=$response}" diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerListPageResponse.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerListPageResponse.kt index d6adc698a..7e514fb09 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerListPageResponse.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerListPageResponse.kt @@ -214,12 +214,15 @@ private constructor( return true } - return /* spotless:off */ other is CustomerListPageResponse && data == other.data && paginationMetadata == other.paginationMetadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is CustomerListPageResponse && + data == other.data && + paginationMetadata == other.paginationMetadata && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(data, paginationMetadata, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash(data, paginationMetadata, additionalProperties) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerListParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerListParams.kt index b3766665a..3578309e5 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerListParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerListParams.kt @@ -252,10 +252,28 @@ private constructor( return true } - return /* spotless:off */ other is CustomerListParams && createdAtGt == other.createdAtGt && createdAtGte == other.createdAtGte && createdAtLt == other.createdAtLt && createdAtLte == other.createdAtLte && cursor == other.cursor && limit == other.limit && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return other is CustomerListParams && + createdAtGt == other.createdAtGt && + createdAtGte == other.createdAtGte && + createdAtLt == other.createdAtLt && + createdAtLte == other.createdAtLte && + cursor == other.cursor && + limit == other.limit && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(createdAtGt, createdAtGte, createdAtLt, createdAtLte, cursor, limit, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash( + createdAtGt, + createdAtGte, + createdAtLt, + createdAtLte, + cursor, + limit, + additionalHeaders, + additionalQueryParams, + ) override fun toString() = "CustomerListParams{createdAtGt=$createdAtGt, createdAtGte=$createdAtGte, createdAtLt=$createdAtLt, createdAtLte=$createdAtLte, cursor=$cursor, limit=$limit, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerMinified.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerMinified.kt index b73a05d52..7305e46e5 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerMinified.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerMinified.kt @@ -195,12 +195,13 @@ private constructor( return true } - return /* spotless:off */ other is CustomerMinified && id == other.id && externalCustomerId == other.externalCustomerId && additionalProperties == other.additionalProperties /* spotless:on */ + return other is CustomerMinified && + id == other.id && + externalCustomerId == other.externalCustomerId && + additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(id, externalCustomerId, additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerSyncPaymentMethodsFromGatewayByExternalCustomerIdParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerSyncPaymentMethodsFromGatewayByExternalCustomerIdParams.kt index 2bf8e319b..0ae98d514 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerSyncPaymentMethodsFromGatewayByExternalCustomerIdParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerSyncPaymentMethodsFromGatewayByExternalCustomerIdParams.kt @@ -233,10 +233,20 @@ private constructor( return true } - return /* spotless:off */ other is CustomerSyncPaymentMethodsFromGatewayByExternalCustomerIdParams && externalCustomerId == other.externalCustomerId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return other is CustomerSyncPaymentMethodsFromGatewayByExternalCustomerIdParams && + externalCustomerId == other.externalCustomerId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(externalCustomerId, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash( + externalCustomerId, + additionalHeaders, + additionalQueryParams, + additionalBodyProperties, + ) override fun toString() = "CustomerSyncPaymentMethodsFromGatewayByExternalCustomerIdParams{externalCustomerId=$externalCustomerId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerSyncPaymentMethodsFromGatewayParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerSyncPaymentMethodsFromGatewayParams.kt index e5e741654..b805d0740 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerSyncPaymentMethodsFromGatewayParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerSyncPaymentMethodsFromGatewayParams.kt @@ -222,10 +222,15 @@ private constructor( return true } - return /* spotless:off */ other is CustomerSyncPaymentMethodsFromGatewayParams && customerId == other.customerId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return other is CustomerSyncPaymentMethodsFromGatewayParams && + customerId == other.customerId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(customerId, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash(customerId, additionalHeaders, additionalQueryParams, additionalBodyProperties) override fun toString() = "CustomerSyncPaymentMethodsFromGatewayParams{customerId=$customerId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerTaxId.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerTaxId.kt index 567bcf539..e1e66410d 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerTaxId.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerTaxId.kt @@ -1136,7 +1136,7 @@ private constructor( return true } - return /* spotless:off */ other is Country && value == other.value /* spotless:on */ + return other is Country && value == other.value } override fun hashCode() = value.hashCode() @@ -1908,7 +1908,7 @@ private constructor( return true } - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + return other is Type && value == other.value } override fun hashCode() = value.hashCode() @@ -1921,12 +1921,14 @@ private constructor( return true } - return /* spotless:off */ other is CustomerTaxId && country == other.country && type == other.type && value == other.value && additionalProperties == other.additionalProperties /* spotless:on */ + return other is CustomerTaxId && + country == other.country && + type == other.type && + value == other.value && + additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(country, type, value, additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerUpdateByExternalIdParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerUpdateByExternalIdParams.kt index 92b67ef6c..db0bb6310 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerUpdateByExternalIdParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerUpdateByExternalIdParams.kt @@ -2340,13 +2340,50 @@ private constructor( return true } - return /* spotless:off */ other is Body && accountingSyncConfiguration == other.accountingSyncConfiguration && additionalEmails == other.additionalEmails && autoCollection == other.autoCollection && billingAddress == other.billingAddress && currency == other.currency && email == other.email && emailDelivery == other.emailDelivery && externalCustomerId == other.externalCustomerId && hierarchy == other.hierarchy && metadata == other.metadata && name == other.name && paymentProvider == other.paymentProvider && paymentProviderId == other.paymentProviderId && reportingConfiguration == other.reportingConfiguration && shippingAddress == other.shippingAddress && taxConfiguration == other.taxConfiguration && taxId == other.taxId && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Body && + accountingSyncConfiguration == other.accountingSyncConfiguration && + additionalEmails == other.additionalEmails && + autoCollection == other.autoCollection && + billingAddress == other.billingAddress && + currency == other.currency && + email == other.email && + emailDelivery == other.emailDelivery && + externalCustomerId == other.externalCustomerId && + hierarchy == other.hierarchy && + metadata == other.metadata && + name == other.name && + paymentProvider == other.paymentProvider && + paymentProviderId == other.paymentProviderId && + reportingConfiguration == other.reportingConfiguration && + shippingAddress == other.shippingAddress && + taxConfiguration == other.taxConfiguration && + taxId == other.taxId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + accountingSyncConfiguration, + additionalEmails, + autoCollection, + billingAddress, + currency, + email, + emailDelivery, + externalCustomerId, + hierarchy, + metadata, + name, + paymentProvider, + paymentProviderId, + reportingConfiguration, + shippingAddress, + taxConfiguration, + taxId, + additionalProperties, + ) } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(accountingSyncConfiguration, additionalEmails, autoCollection, billingAddress, currency, email, emailDelivery, externalCustomerId, hierarchy, metadata, name, paymentProvider, paymentProviderId, reportingConfiguration, shippingAddress, taxConfiguration, taxId, additionalProperties) } - /* spotless:on */ - override fun hashCode(): Int = hashCode override fun toString() = @@ -2445,12 +2482,10 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -2602,7 +2637,7 @@ private constructor( return true } - return /* spotless:off */ other is PaymentProvider && value == other.value /* spotless:on */ + return other is PaymentProvider && value == other.value } override fun hashCode() = value.hashCode() @@ -2706,10 +2741,13 @@ private constructor( return true } - return /* spotless:off */ other is TaxConfiguration && avalara == other.avalara && taxjar == other.taxjar && sphere == other.sphere /* spotless:on */ + return other is TaxConfiguration && + avalara == other.avalara && + taxjar == other.taxjar && + sphere == other.sphere } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(avalara, taxjar, sphere) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(avalara, taxjar, sphere) override fun toString(): String = when { @@ -2807,10 +2845,14 @@ private constructor( return true } - return /* spotless:off */ other is CustomerUpdateByExternalIdParams && id == other.id && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return other is CustomerUpdateByExternalIdParams && + id == other.id && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(id, body, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(id, body, additionalHeaders, additionalQueryParams) override fun toString() = "CustomerUpdateByExternalIdParams{id=$id, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerUpdateParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerUpdateParams.kt index 971c8ffec..a13046ffd 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerUpdateParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerUpdateParams.kt @@ -2336,13 +2336,50 @@ private constructor( return true } - return /* spotless:off */ other is Body && accountingSyncConfiguration == other.accountingSyncConfiguration && additionalEmails == other.additionalEmails && autoCollection == other.autoCollection && billingAddress == other.billingAddress && currency == other.currency && email == other.email && emailDelivery == other.emailDelivery && externalCustomerId == other.externalCustomerId && hierarchy == other.hierarchy && metadata == other.metadata && name == other.name && paymentProvider == other.paymentProvider && paymentProviderId == other.paymentProviderId && reportingConfiguration == other.reportingConfiguration && shippingAddress == other.shippingAddress && taxConfiguration == other.taxConfiguration && taxId == other.taxId && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Body && + accountingSyncConfiguration == other.accountingSyncConfiguration && + additionalEmails == other.additionalEmails && + autoCollection == other.autoCollection && + billingAddress == other.billingAddress && + currency == other.currency && + email == other.email && + emailDelivery == other.emailDelivery && + externalCustomerId == other.externalCustomerId && + hierarchy == other.hierarchy && + metadata == other.metadata && + name == other.name && + paymentProvider == other.paymentProvider && + paymentProviderId == other.paymentProviderId && + reportingConfiguration == other.reportingConfiguration && + shippingAddress == other.shippingAddress && + taxConfiguration == other.taxConfiguration && + taxId == other.taxId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + accountingSyncConfiguration, + additionalEmails, + autoCollection, + billingAddress, + currency, + email, + emailDelivery, + externalCustomerId, + hierarchy, + metadata, + name, + paymentProvider, + paymentProviderId, + reportingConfiguration, + shippingAddress, + taxConfiguration, + taxId, + additionalProperties, + ) } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(accountingSyncConfiguration, additionalEmails, autoCollection, billingAddress, currency, email, emailDelivery, externalCustomerId, hierarchy, metadata, name, paymentProvider, paymentProviderId, reportingConfiguration, shippingAddress, taxConfiguration, taxId, additionalProperties) } - /* spotless:on */ - override fun hashCode(): Int = hashCode override fun toString() = @@ -2441,12 +2478,10 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -2598,7 +2633,7 @@ private constructor( return true } - return /* spotless:off */ other is PaymentProvider && value == other.value /* spotless:on */ + return other is PaymentProvider && value == other.value } override fun hashCode() = value.hashCode() @@ -2702,10 +2737,13 @@ private constructor( return true } - return /* spotless:off */ other is TaxConfiguration && avalara == other.avalara && taxjar == other.taxjar && sphere == other.sphere /* spotless:on */ + return other is TaxConfiguration && + avalara == other.avalara && + taxjar == other.taxjar && + sphere == other.sphere } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(avalara, taxjar, sphere) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(avalara, taxjar, sphere) override fun toString(): String = when { @@ -2803,10 +2841,15 @@ private constructor( return true } - return /* spotless:off */ other is CustomerUpdateParams && customerId == other.customerId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return other is CustomerUpdateParams && + customerId == other.customerId && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(customerId, body, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash(customerId, body, additionalHeaders, additionalQueryParams) override fun toString() = "CustomerUpdateParams{customerId=$customerId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/DecrementLedgerEntry.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/DecrementLedgerEntry.kt index f91c0c80f..1ec2a430e 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/DecrementLedgerEntry.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/DecrementLedgerEntry.kt @@ -829,7 +829,7 @@ private constructor( return true } - return /* spotless:off */ other is EntryStatus && value == other.value /* spotless:on */ + return other is EntryStatus && value == other.value } override fun hashCode() = value.hashCode() @@ -949,7 +949,7 @@ private constructor( return true } - return /* spotless:off */ other is EntryType && value == other.value /* spotless:on */ + return other is EntryType && value == other.value } override fun hashCode() = value.hashCode() @@ -1049,12 +1049,10 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1066,12 +1064,47 @@ private constructor( return true } - return /* spotless:off */ other is DecrementLedgerEntry && id == other.id && amount == other.amount && createdAt == other.createdAt && creditBlock == other.creditBlock && currency == other.currency && customer == other.customer && description == other.description && endingBalance == other.endingBalance && entryStatus == other.entryStatus && entryType == other.entryType && ledgerSequenceNumber == other.ledgerSequenceNumber && metadata == other.metadata && startingBalance == other.startingBalance && eventId == other.eventId && invoiceId == other.invoiceId && priceId == other.priceId && additionalProperties == other.additionalProperties /* spotless:on */ + return other is DecrementLedgerEntry && + id == other.id && + amount == other.amount && + createdAt == other.createdAt && + creditBlock == other.creditBlock && + currency == other.currency && + customer == other.customer && + description == other.description && + endingBalance == other.endingBalance && + entryStatus == other.entryStatus && + entryType == other.entryType && + ledgerSequenceNumber == other.ledgerSequenceNumber && + metadata == other.metadata && + startingBalance == other.startingBalance && + eventId == other.eventId && + invoiceId == other.invoiceId && + priceId == other.priceId && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, amount, createdAt, creditBlock, currency, customer, description, endingBalance, entryStatus, entryType, ledgerSequenceNumber, metadata, startingBalance, eventId, invoiceId, priceId, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + id, + amount, + createdAt, + creditBlock, + currency, + customer, + description, + endingBalance, + entryStatus, + entryType, + ledgerSequenceNumber, + metadata, + startingBalance, + eventId, + invoiceId, + priceId, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceConfiguration.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceConfiguration.kt index 592151d5a..0cd09de02 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceConfiguration.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceConfiguration.kt @@ -221,12 +221,15 @@ private constructor( return true } - return /* spotless:off */ other is DimensionalPriceConfiguration && dimensionValues == other.dimensionValues && dimensionalPriceGroupId == other.dimensionalPriceGroupId && additionalProperties == other.additionalProperties /* spotless:on */ + return other is DimensionalPriceConfiguration && + dimensionValues == other.dimensionValues && + dimensionalPriceGroupId == other.dimensionalPriceGroupId && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(dimensionValues, dimensionalPriceGroupId, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash(dimensionValues, dimensionalPriceGroupId, additionalProperties) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroup.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroup.kt index 7cb9c7e5a..15f9aa955 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroup.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroup.kt @@ -481,12 +481,10 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -498,12 +496,27 @@ private constructor( return true } - return /* spotless:off */ other is DimensionalPriceGroup && id == other.id && billableMetricId == other.billableMetricId && dimensions == other.dimensions && externalDimensionalPriceGroupId == other.externalDimensionalPriceGroupId && metadata == other.metadata && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ + return other is DimensionalPriceGroup && + id == other.id && + billableMetricId == other.billableMetricId && + dimensions == other.dimensions && + externalDimensionalPriceGroupId == other.externalDimensionalPriceGroupId && + metadata == other.metadata && + name == other.name && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, billableMetricId, dimensions, externalDimensionalPriceGroupId, metadata, name, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + id, + billableMetricId, + dimensions, + externalDimensionalPriceGroupId, + metadata, + name, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroupCreateParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroupCreateParams.kt index ba42ad8ba..78c7b70e0 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroupCreateParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroupCreateParams.kt @@ -714,13 +714,26 @@ private constructor( return true } - return /* spotless:off */ other is Body && billableMetricId == other.billableMetricId && dimensions == other.dimensions && name == other.name && externalDimensionalPriceGroupId == other.externalDimensionalPriceGroupId && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Body && + billableMetricId == other.billableMetricId && + dimensions == other.dimensions && + name == other.name && + externalDimensionalPriceGroupId == other.externalDimensionalPriceGroupId && + metadata == other.metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + billableMetricId, + dimensions, + name, + externalDimensionalPriceGroupId, + metadata, + additionalProperties, + ) } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(billableMetricId, dimensions, name, externalDimensionalPriceGroupId, metadata, additionalProperties) } - /* spotless:on */ - override fun hashCode(): Int = hashCode override fun toString() = @@ -819,12 +832,10 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -836,10 +847,13 @@ private constructor( return true } - return /* spotless:off */ other is DimensionalPriceGroupCreateParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return other is DimensionalPriceGroupCreateParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(body, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) override fun toString() = "DimensionalPriceGroupCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroupExternalDimensionalPriceGroupIdRetrieveParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroupExternalDimensionalPriceGroupIdRetrieveParams.kt index 8477f874c..e6db24899 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroupExternalDimensionalPriceGroupIdRetrieveParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroupExternalDimensionalPriceGroupIdRetrieveParams.kt @@ -191,10 +191,14 @@ private constructor( return true } - return /* spotless:off */ other is DimensionalPriceGroupExternalDimensionalPriceGroupIdRetrieveParams && externalDimensionalPriceGroupId == other.externalDimensionalPriceGroupId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return other is DimensionalPriceGroupExternalDimensionalPriceGroupIdRetrieveParams && + externalDimensionalPriceGroupId == other.externalDimensionalPriceGroupId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(externalDimensionalPriceGroupId, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash(externalDimensionalPriceGroupId, additionalHeaders, additionalQueryParams) override fun toString() = "DimensionalPriceGroupExternalDimensionalPriceGroupIdRetrieveParams{externalDimensionalPriceGroupId=$externalDimensionalPriceGroupId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroupExternalDimensionalPriceGroupIdUpdateParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroupExternalDimensionalPriceGroupIdUpdateParams.kt index c1170b681..1febf873a 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroupExternalDimensionalPriceGroupIdUpdateParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroupExternalDimensionalPriceGroupIdUpdateParams.kt @@ -505,12 +505,15 @@ private constructor( return true } - return /* spotless:off */ other is Body && bodyExternalDimensionalPriceGroupId == other.bodyExternalDimensionalPriceGroupId && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Body && + bodyExternalDimensionalPriceGroupId == other.bodyExternalDimensionalPriceGroupId && + metadata == other.metadata && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(bodyExternalDimensionalPriceGroupId, metadata, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash(bodyExternalDimensionalPriceGroupId, metadata, additionalProperties) + } override fun hashCode(): Int = hashCode @@ -610,12 +613,10 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -627,10 +628,20 @@ private constructor( return true } - return /* spotless:off */ other is DimensionalPriceGroupExternalDimensionalPriceGroupIdUpdateParams && pathExternalDimensionalPriceGroupId == other.pathExternalDimensionalPriceGroupId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return other is DimensionalPriceGroupExternalDimensionalPriceGroupIdUpdateParams && + pathExternalDimensionalPriceGroupId == other.pathExternalDimensionalPriceGroupId && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(pathExternalDimensionalPriceGroupId, body, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash( + pathExternalDimensionalPriceGroupId, + body, + additionalHeaders, + additionalQueryParams, + ) override fun toString() = "DimensionalPriceGroupExternalDimensionalPriceGroupIdUpdateParams{pathExternalDimensionalPriceGroupId=$pathExternalDimensionalPriceGroupId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroupListPage.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroupListPage.kt index 553b0012d..c4c1c79b2 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroupListPage.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroupListPage.kt @@ -120,10 +120,13 @@ private constructor( return true } - return /* spotless:off */ other is DimensionalPriceGroupListPage && service == other.service && params == other.params && response == other.response /* spotless:on */ + return other is DimensionalPriceGroupListPage && + service == other.service && + params == other.params && + response == other.response } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, params, response) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(service, params, response) override fun toString() = "DimensionalPriceGroupListPage{service=$service, params=$params, response=$response}" diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroupListPageAsync.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroupListPageAsync.kt index 612c000a9..5eed83c49 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroupListPageAsync.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroupListPageAsync.kt @@ -122,10 +122,13 @@ private constructor( return true } - return /* spotless:off */ other is DimensionalPriceGroupListPageAsync && service == other.service && params == other.params && response == other.response /* spotless:on */ + return other is DimensionalPriceGroupListPageAsync && + service == other.service && + params == other.params && + response == other.response } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, params, response) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(service, params, response) override fun toString() = "DimensionalPriceGroupListPageAsync{service=$service, params=$params, response=$response}" diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroupListParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroupListParams.kt index effb098e0..1bd7e151f 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroupListParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroupListParams.kt @@ -205,10 +205,15 @@ private constructor( return true } - return /* spotless:off */ other is DimensionalPriceGroupListParams && cursor == other.cursor && limit == other.limit && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return other is DimensionalPriceGroupListParams && + cursor == other.cursor && + limit == other.limit && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(cursor, limit, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash(cursor, limit, additionalHeaders, additionalQueryParams) override fun toString() = "DimensionalPriceGroupListParams{cursor=$cursor, limit=$limit, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroupRetrieveParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroupRetrieveParams.kt index b56f6a904..fb45e6a94 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroupRetrieveParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroupRetrieveParams.kt @@ -182,10 +182,14 @@ private constructor( return true } - return /* spotless:off */ other is DimensionalPriceGroupRetrieveParams && dimensionalPriceGroupId == other.dimensionalPriceGroupId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return other is DimensionalPriceGroupRetrieveParams && + dimensionalPriceGroupId == other.dimensionalPriceGroupId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(dimensionalPriceGroupId, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash(dimensionalPriceGroupId, additionalHeaders, additionalQueryParams) override fun toString() = "DimensionalPriceGroupRetrieveParams{dimensionalPriceGroupId=$dimensionalPriceGroupId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroupUpdateParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroupUpdateParams.kt index 4908fc88a..a82c3b3c1 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroupUpdateParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroupUpdateParams.kt @@ -487,12 +487,15 @@ private constructor( return true } - return /* spotless:off */ other is Body && externalDimensionalPriceGroupId == other.externalDimensionalPriceGroupId && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Body && + externalDimensionalPriceGroupId == other.externalDimensionalPriceGroupId && + metadata == other.metadata && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(externalDimensionalPriceGroupId, metadata, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash(externalDimensionalPriceGroupId, metadata, additionalProperties) + } override fun hashCode(): Int = hashCode @@ -592,12 +595,10 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -609,10 +610,15 @@ private constructor( return true } - return /* spotless:off */ other is DimensionalPriceGroupUpdateParams && dimensionalPriceGroupId == other.dimensionalPriceGroupId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return other is DimensionalPriceGroupUpdateParams && + dimensionalPriceGroupId == other.dimensionalPriceGroupId && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(dimensionalPriceGroupId, body, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash(dimensionalPriceGroupId, body, additionalHeaders, additionalQueryParams) override fun toString() = "DimensionalPriceGroupUpdateParams{dimensionalPriceGroupId=$dimensionalPriceGroupId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroups.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroups.kt index ceaad174d..75d7344f2 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroups.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroups.kt @@ -216,12 +216,15 @@ private constructor( return true } - return /* spotless:off */ other is DimensionalPriceGroups && data == other.data && paginationMetadata == other.paginationMetadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is DimensionalPriceGroups && + data == other.data && + paginationMetadata == other.paginationMetadata && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(data, paginationMetadata, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash(data, paginationMetadata, additionalProperties) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Discount.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Discount.kt index a80419648..7b5d6a307 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Discount.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Discount.kt @@ -124,10 +124,14 @@ private constructor( return true } - return /* spotless:off */ other is Discount && percentage == other.percentage && trial == other.trial && usage == other.usage && amount == other.amount /* spotless:on */ + return other is Discount && + percentage == other.percentage && + trial == other.trial && + usage == other.usage && + amount == other.amount } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(percentage, trial, usage, amount) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(percentage, trial, usage, amount) override fun toString(): String = when { diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/DiscountOverride.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/DiscountOverride.kt index d72ff9f70..a7bd9e31d 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/DiscountOverride.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/DiscountOverride.kt @@ -425,7 +425,7 @@ private constructor( return true } - return /* spotless:off */ other is DiscountType && value == other.value /* spotless:on */ + return other is DiscountType && value == other.value } override fun hashCode() = value.hashCode() @@ -438,12 +438,23 @@ private constructor( return true } - return /* spotless:off */ other is DiscountOverride && discountType == other.discountType && amountDiscount == other.amountDiscount && percentageDiscount == other.percentageDiscount && usageDiscount == other.usageDiscount && additionalProperties == other.additionalProperties /* spotless:on */ + return other is DiscountOverride && + discountType == other.discountType && + amountDiscount == other.amountDiscount && + percentageDiscount == other.percentageDiscount && + usageDiscount == other.usageDiscount && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(discountType, amountDiscount, percentageDiscount, usageDiscount, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + discountType, + amountDiscount, + percentageDiscount, + usageDiscount, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EvaluatePriceGroup.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EvaluatePriceGroup.kt index a489efb54..6c92a6a59 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EvaluatePriceGroup.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EvaluatePriceGroup.kt @@ -354,10 +354,13 @@ private constructor( return true } - return /* spotless:off */ other is GroupingValue && string == other.string && double == other.double && boolean == other.boolean /* spotless:on */ + return other is GroupingValue && + string == other.string && + double == other.double && + boolean == other.boolean } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(string, double, boolean) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(string, double, boolean) override fun toString(): String = when { @@ -460,12 +463,16 @@ private constructor( return true } - return /* spotless:off */ other is EvaluatePriceGroup && amount == other.amount && groupingValues == other.groupingValues && quantity == other.quantity && additionalProperties == other.additionalProperties /* spotless:on */ + return other is EvaluatePriceGroup && + amount == other.amount && + groupingValues == other.groupingValues && + quantity == other.quantity && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(amount, groupingValues, quantity, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash(amount, groupingValues, quantity, additionalProperties) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventBackfillCloseParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventBackfillCloseParams.kt index bc6cfa91b..6422d31a3 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventBackfillCloseParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventBackfillCloseParams.kt @@ -212,10 +212,15 @@ private constructor( return true } - return /* spotless:off */ other is EventBackfillCloseParams && backfillId == other.backfillId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return other is EventBackfillCloseParams && + backfillId == other.backfillId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(backfillId, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash(backfillId, additionalHeaders, additionalQueryParams, additionalBodyProperties) override fun toString() = "EventBackfillCloseParams{backfillId=$backfillId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventBackfillCloseResponse.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventBackfillCloseResponse.kt index 7a7bca5bc..74a8023df 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventBackfillCloseResponse.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventBackfillCloseResponse.kt @@ -716,7 +716,7 @@ private constructor( return true } - return /* spotless:off */ other is Status && value == other.value /* spotless:on */ + return other is Status && value == other.value } override fun hashCode() = value.hashCode() @@ -729,12 +729,37 @@ private constructor( return true } - return /* spotless:off */ other is EventBackfillCloseResponse && id == other.id && closeTime == other.closeTime && createdAt == other.createdAt && customerId == other.customerId && eventsIngested == other.eventsIngested && replaceExistingEvents == other.replaceExistingEvents && revertedAt == other.revertedAt && status == other.status && timeframeEnd == other.timeframeEnd && timeframeStart == other.timeframeStart && deprecationFilter == other.deprecationFilter && additionalProperties == other.additionalProperties /* spotless:on */ + return other is EventBackfillCloseResponse && + id == other.id && + closeTime == other.closeTime && + createdAt == other.createdAt && + customerId == other.customerId && + eventsIngested == other.eventsIngested && + replaceExistingEvents == other.replaceExistingEvents && + revertedAt == other.revertedAt && + status == other.status && + timeframeEnd == other.timeframeEnd && + timeframeStart == other.timeframeStart && + deprecationFilter == other.deprecationFilter && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, closeTime, createdAt, customerId, eventsIngested, replaceExistingEvents, revertedAt, status, timeframeEnd, timeframeStart, deprecationFilter, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + id, + closeTime, + createdAt, + customerId, + eventsIngested, + replaceExistingEvents, + revertedAt, + status, + timeframeEnd, + timeframeStart, + deprecationFilter, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventBackfillCreateParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventBackfillCreateParams.kt index a479bcb58..589bb587c 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventBackfillCreateParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventBackfillCreateParams.kt @@ -940,13 +940,30 @@ private constructor( return true } - return /* spotless:off */ other is Body && timeframeEnd == other.timeframeEnd && timeframeStart == other.timeframeStart && closeTime == other.closeTime && customerId == other.customerId && deprecationFilter == other.deprecationFilter && externalCustomerId == other.externalCustomerId && replaceExistingEvents == other.replaceExistingEvents && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Body && + timeframeEnd == other.timeframeEnd && + timeframeStart == other.timeframeStart && + closeTime == other.closeTime && + customerId == other.customerId && + deprecationFilter == other.deprecationFilter && + externalCustomerId == other.externalCustomerId && + replaceExistingEvents == other.replaceExistingEvents && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + timeframeEnd, + timeframeStart, + closeTime, + customerId, + deprecationFilter, + externalCustomerId, + replaceExistingEvents, + additionalProperties, + ) } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(timeframeEnd, timeframeStart, closeTime, customerId, deprecationFilter, externalCustomerId, replaceExistingEvents, additionalProperties) } - /* spotless:on */ - override fun hashCode(): Int = hashCode override fun toString() = @@ -958,10 +975,13 @@ private constructor( return true } - return /* spotless:off */ other is EventBackfillCreateParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return other is EventBackfillCreateParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(body, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) override fun toString() = "EventBackfillCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventBackfillCreateResponse.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventBackfillCreateResponse.kt index 416fd2f0e..0bd9c59d5 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventBackfillCreateResponse.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventBackfillCreateResponse.kt @@ -716,7 +716,7 @@ private constructor( return true } - return /* spotless:off */ other is Status && value == other.value /* spotless:on */ + return other is Status && value == other.value } override fun hashCode() = value.hashCode() @@ -729,12 +729,37 @@ private constructor( return true } - return /* spotless:off */ other is EventBackfillCreateResponse && id == other.id && closeTime == other.closeTime && createdAt == other.createdAt && customerId == other.customerId && eventsIngested == other.eventsIngested && replaceExistingEvents == other.replaceExistingEvents && revertedAt == other.revertedAt && status == other.status && timeframeEnd == other.timeframeEnd && timeframeStart == other.timeframeStart && deprecationFilter == other.deprecationFilter && additionalProperties == other.additionalProperties /* spotless:on */ + return other is EventBackfillCreateResponse && + id == other.id && + closeTime == other.closeTime && + createdAt == other.createdAt && + customerId == other.customerId && + eventsIngested == other.eventsIngested && + replaceExistingEvents == other.replaceExistingEvents && + revertedAt == other.revertedAt && + status == other.status && + timeframeEnd == other.timeframeEnd && + timeframeStart == other.timeframeStart && + deprecationFilter == other.deprecationFilter && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, closeTime, createdAt, customerId, eventsIngested, replaceExistingEvents, revertedAt, status, timeframeEnd, timeframeStart, deprecationFilter, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + id, + closeTime, + createdAt, + customerId, + eventsIngested, + replaceExistingEvents, + revertedAt, + status, + timeframeEnd, + timeframeStart, + deprecationFilter, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventBackfillFetchParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventBackfillFetchParams.kt index 7e249c345..b06db7b15 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventBackfillFetchParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventBackfillFetchParams.kt @@ -174,10 +174,14 @@ private constructor( return true } - return /* spotless:off */ other is EventBackfillFetchParams && backfillId == other.backfillId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return other is EventBackfillFetchParams && + backfillId == other.backfillId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(backfillId, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash(backfillId, additionalHeaders, additionalQueryParams) override fun toString() = "EventBackfillFetchParams{backfillId=$backfillId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventBackfillFetchResponse.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventBackfillFetchResponse.kt index ae45dd763..1fbb32e43 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventBackfillFetchResponse.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventBackfillFetchResponse.kt @@ -716,7 +716,7 @@ private constructor( return true } - return /* spotless:off */ other is Status && value == other.value /* spotless:on */ + return other is Status && value == other.value } override fun hashCode() = value.hashCode() @@ -729,12 +729,37 @@ private constructor( return true } - return /* spotless:off */ other is EventBackfillFetchResponse && id == other.id && closeTime == other.closeTime && createdAt == other.createdAt && customerId == other.customerId && eventsIngested == other.eventsIngested && replaceExistingEvents == other.replaceExistingEvents && revertedAt == other.revertedAt && status == other.status && timeframeEnd == other.timeframeEnd && timeframeStart == other.timeframeStart && deprecationFilter == other.deprecationFilter && additionalProperties == other.additionalProperties /* spotless:on */ + return other is EventBackfillFetchResponse && + id == other.id && + closeTime == other.closeTime && + createdAt == other.createdAt && + customerId == other.customerId && + eventsIngested == other.eventsIngested && + replaceExistingEvents == other.replaceExistingEvents && + revertedAt == other.revertedAt && + status == other.status && + timeframeEnd == other.timeframeEnd && + timeframeStart == other.timeframeStart && + deprecationFilter == other.deprecationFilter && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, closeTime, createdAt, customerId, eventsIngested, replaceExistingEvents, revertedAt, status, timeframeEnd, timeframeStart, deprecationFilter, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + id, + closeTime, + createdAt, + customerId, + eventsIngested, + replaceExistingEvents, + revertedAt, + status, + timeframeEnd, + timeframeStart, + deprecationFilter, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventBackfillListPage.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventBackfillListPage.kt index a6cb91ee2..83a32431b 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventBackfillListPage.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventBackfillListPage.kt @@ -120,10 +120,13 @@ private constructor( return true } - return /* spotless:off */ other is EventBackfillListPage && service == other.service && params == other.params && response == other.response /* spotless:on */ + return other is EventBackfillListPage && + service == other.service && + params == other.params && + response == other.response } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, params, response) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(service, params, response) override fun toString() = "EventBackfillListPage{service=$service, params=$params, response=$response}" diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventBackfillListPageAsync.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventBackfillListPageAsync.kt index 33df64f50..d959578fb 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventBackfillListPageAsync.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventBackfillListPageAsync.kt @@ -120,10 +120,13 @@ private constructor( return true } - return /* spotless:off */ other is EventBackfillListPageAsync && service == other.service && params == other.params && response == other.response /* spotless:on */ + return other is EventBackfillListPageAsync && + service == other.service && + params == other.params && + response == other.response } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, params, response) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(service, params, response) override fun toString() = "EventBackfillListPageAsync{service=$service, params=$params, response=$response}" diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventBackfillListPageResponse.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventBackfillListPageResponse.kt index 506edb374..0a9442c5e 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventBackfillListPageResponse.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventBackfillListPageResponse.kt @@ -219,12 +219,15 @@ private constructor( return true } - return /* spotless:off */ other is EventBackfillListPageResponse && data == other.data && paginationMetadata == other.paginationMetadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is EventBackfillListPageResponse && + data == other.data && + paginationMetadata == other.paginationMetadata && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(data, paginationMetadata, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash(data, paginationMetadata, additionalProperties) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventBackfillListParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventBackfillListParams.kt index 67225c207..ed7ec4453 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventBackfillListParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventBackfillListParams.kt @@ -207,10 +207,15 @@ private constructor( return true } - return /* spotless:off */ other is EventBackfillListParams && cursor == other.cursor && limit == other.limit && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return other is EventBackfillListParams && + cursor == other.cursor && + limit == other.limit && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(cursor, limit, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash(cursor, limit, additionalHeaders, additionalQueryParams) override fun toString() = "EventBackfillListParams{cursor=$cursor, limit=$limit, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventBackfillListResponse.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventBackfillListResponse.kt index 5114a2ed0..f0347cd2b 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventBackfillListResponse.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventBackfillListResponse.kt @@ -716,7 +716,7 @@ private constructor( return true } - return /* spotless:off */ other is Status && value == other.value /* spotless:on */ + return other is Status && value == other.value } override fun hashCode() = value.hashCode() @@ -729,12 +729,37 @@ private constructor( return true } - return /* spotless:off */ other is EventBackfillListResponse && id == other.id && closeTime == other.closeTime && createdAt == other.createdAt && customerId == other.customerId && eventsIngested == other.eventsIngested && replaceExistingEvents == other.replaceExistingEvents && revertedAt == other.revertedAt && status == other.status && timeframeEnd == other.timeframeEnd && timeframeStart == other.timeframeStart && deprecationFilter == other.deprecationFilter && additionalProperties == other.additionalProperties /* spotless:on */ + return other is EventBackfillListResponse && + id == other.id && + closeTime == other.closeTime && + createdAt == other.createdAt && + customerId == other.customerId && + eventsIngested == other.eventsIngested && + replaceExistingEvents == other.replaceExistingEvents && + revertedAt == other.revertedAt && + status == other.status && + timeframeEnd == other.timeframeEnd && + timeframeStart == other.timeframeStart && + deprecationFilter == other.deprecationFilter && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, closeTime, createdAt, customerId, eventsIngested, replaceExistingEvents, revertedAt, status, timeframeEnd, timeframeStart, deprecationFilter, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + id, + closeTime, + createdAt, + customerId, + eventsIngested, + replaceExistingEvents, + revertedAt, + status, + timeframeEnd, + timeframeStart, + deprecationFilter, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventBackfillRevertParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventBackfillRevertParams.kt index c68eb0043..3452518f5 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventBackfillRevertParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventBackfillRevertParams.kt @@ -217,10 +217,15 @@ private constructor( return true } - return /* spotless:off */ other is EventBackfillRevertParams && backfillId == other.backfillId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return other is EventBackfillRevertParams && + backfillId == other.backfillId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(backfillId, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash(backfillId, additionalHeaders, additionalQueryParams, additionalBodyProperties) override fun toString() = "EventBackfillRevertParams{backfillId=$backfillId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventBackfillRevertResponse.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventBackfillRevertResponse.kt index 7c0a2f451..d057db10c 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventBackfillRevertResponse.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventBackfillRevertResponse.kt @@ -716,7 +716,7 @@ private constructor( return true } - return /* spotless:off */ other is Status && value == other.value /* spotless:on */ + return other is Status && value == other.value } override fun hashCode() = value.hashCode() @@ -729,12 +729,37 @@ private constructor( return true } - return /* spotless:off */ other is EventBackfillRevertResponse && id == other.id && closeTime == other.closeTime && createdAt == other.createdAt && customerId == other.customerId && eventsIngested == other.eventsIngested && replaceExistingEvents == other.replaceExistingEvents && revertedAt == other.revertedAt && status == other.status && timeframeEnd == other.timeframeEnd && timeframeStart == other.timeframeStart && deprecationFilter == other.deprecationFilter && additionalProperties == other.additionalProperties /* spotless:on */ + return other is EventBackfillRevertResponse && + id == other.id && + closeTime == other.closeTime && + createdAt == other.createdAt && + customerId == other.customerId && + eventsIngested == other.eventsIngested && + replaceExistingEvents == other.replaceExistingEvents && + revertedAt == other.revertedAt && + status == other.status && + timeframeEnd == other.timeframeEnd && + timeframeStart == other.timeframeStart && + deprecationFilter == other.deprecationFilter && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, closeTime, createdAt, customerId, eventsIngested, replaceExistingEvents, revertedAt, status, timeframeEnd, timeframeStart, deprecationFilter, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + id, + closeTime, + createdAt, + customerId, + eventsIngested, + replaceExistingEvents, + revertedAt, + status, + timeframeEnd, + timeframeStart, + deprecationFilter, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventDeprecateParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventDeprecateParams.kt index cf6b8d855..64487a783 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventDeprecateParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventDeprecateParams.kt @@ -240,10 +240,15 @@ private constructor( return true } - return /* spotless:off */ other is EventDeprecateParams && eventId == other.eventId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return other is EventDeprecateParams && + eventId == other.eventId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(eventId, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash(eventId, additionalHeaders, additionalQueryParams, additionalBodyProperties) override fun toString() = "EventDeprecateParams{eventId=$eventId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventDeprecateResponse.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventDeprecateResponse.kt index c4f29d91b..3613faf98 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventDeprecateResponse.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventDeprecateResponse.kt @@ -158,12 +158,12 @@ private constructor( return true } - return /* spotless:off */ other is EventDeprecateResponse && deprecated == other.deprecated && additionalProperties == other.additionalProperties /* spotless:on */ + return other is EventDeprecateResponse && + deprecated == other.deprecated && + additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(deprecated, additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventIngestParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventIngestParams.kt index 6b006ad4c..19f2c65d4 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventIngestParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventIngestParams.kt @@ -632,12 +632,12 @@ private constructor( return true } - return /* spotless:off */ other is Body && events == other.events && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Body && + events == other.events && + additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(events, additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1114,12 +1114,10 @@ private constructor( return true } - return /* spotless:off */ other is Properties && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Properties && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1131,12 +1129,27 @@ private constructor( return true } - return /* spotless:off */ other is Event && eventName == other.eventName && idempotencyKey == other.idempotencyKey && properties == other.properties && timestamp == other.timestamp && customerId == other.customerId && externalCustomerId == other.externalCustomerId && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Event && + eventName == other.eventName && + idempotencyKey == other.idempotencyKey && + properties == other.properties && + timestamp == other.timestamp && + customerId == other.customerId && + externalCustomerId == other.externalCustomerId && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(eventName, idempotencyKey, properties, timestamp, customerId, externalCustomerId, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + eventName, + idempotencyKey, + properties, + timestamp, + customerId, + externalCustomerId, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode @@ -1149,10 +1162,16 @@ private constructor( return true } - return /* spotless:off */ other is EventIngestParams && backfillId == other.backfillId && debug == other.debug && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return other is EventIngestParams && + backfillId == other.backfillId && + debug == other.debug && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(backfillId, debug, body, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash(backfillId, debug, body, additionalHeaders, additionalQueryParams) override fun toString() = "EventIngestParams{backfillId=$backfillId, debug=$debug, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventIngestResponse.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventIngestResponse.kt index 7af6e9e95..49baff79d 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventIngestResponse.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventIngestResponse.kt @@ -429,12 +429,15 @@ private constructor( return true } - return /* spotless:off */ other is ValidationFailed && idempotencyKey == other.idempotencyKey && validationErrors == other.validationErrors && additionalProperties == other.additionalProperties /* spotless:on */ + return other is ValidationFailed && + idempotencyKey == other.idempotencyKey && + validationErrors == other.validationErrors && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(idempotencyKey, validationErrors, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash(idempotencyKey, validationErrors, additionalProperties) + } override fun hashCode(): Int = hashCode @@ -656,12 +659,15 @@ private constructor( return true } - return /* spotless:off */ other is Debug && duplicate == other.duplicate && ingested == other.ingested && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Debug && + duplicate == other.duplicate && + ingested == other.ingested && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duplicate, ingested, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash(duplicate, ingested, additionalProperties) + } override fun hashCode(): Int = hashCode @@ -674,12 +680,15 @@ private constructor( return true } - return /* spotless:off */ other is EventIngestResponse && validationFailed == other.validationFailed && debug == other.debug && additionalProperties == other.additionalProperties /* spotless:on */ + return other is EventIngestResponse && + validationFailed == other.validationFailed && + debug == other.debug && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(validationFailed, debug, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash(validationFailed, debug, additionalProperties) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventSearchParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventSearchParams.kt index cb30d5f25..1588735c1 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventSearchParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventSearchParams.kt @@ -601,12 +601,16 @@ private constructor( return true } - return /* spotless:off */ other is Body && eventIds == other.eventIds && timeframeEnd == other.timeframeEnd && timeframeStart == other.timeframeStart && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Body && + eventIds == other.eventIds && + timeframeEnd == other.timeframeEnd && + timeframeStart == other.timeframeStart && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(eventIds, timeframeEnd, timeframeStart, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash(eventIds, timeframeEnd, timeframeStart, additionalProperties) + } override fun hashCode(): Int = hashCode @@ -619,10 +623,13 @@ private constructor( return true } - return /* spotless:off */ other is EventSearchParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return other is EventSearchParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(body, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) override fun toString() = "EventSearchParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventSearchResponse.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventSearchResponse.kt index 345449896..2afcf1f1c 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventSearchResponse.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventSearchResponse.kt @@ -678,12 +678,10 @@ private constructor( return true } - return /* spotless:off */ other is Properties && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Properties && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -695,12 +693,29 @@ private constructor( return true } - return /* spotless:off */ other is Data && id == other.id && customerId == other.customerId && deprecated == other.deprecated && eventName == other.eventName && externalCustomerId == other.externalCustomerId && properties == other.properties && timestamp == other.timestamp && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Data && + id == other.id && + customerId == other.customerId && + deprecated == other.deprecated && + eventName == other.eventName && + externalCustomerId == other.externalCustomerId && + properties == other.properties && + timestamp == other.timestamp && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, customerId, deprecated, eventName, externalCustomerId, properties, timestamp, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + id, + customerId, + deprecated, + eventName, + externalCustomerId, + properties, + timestamp, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode @@ -713,12 +728,12 @@ private constructor( return true } - return /* spotless:off */ other is EventSearchResponse && data == other.data && additionalProperties == other.additionalProperties /* spotless:on */ + return other is EventSearchResponse && + data == other.data && + additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(data, additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventUpdateParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventUpdateParams.kt index c6d9a4cc4..2cc0207d1 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventUpdateParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventUpdateParams.kt @@ -750,13 +750,26 @@ private constructor( return true } - return /* spotless:off */ other is Body && eventName == other.eventName && properties == other.properties && timestamp == other.timestamp && customerId == other.customerId && externalCustomerId == other.externalCustomerId && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Body && + eventName == other.eventName && + properties == other.properties && + timestamp == other.timestamp && + customerId == other.customerId && + externalCustomerId == other.externalCustomerId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + eventName, + properties, + timestamp, + customerId, + externalCustomerId, + additionalProperties, + ) } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(eventName, properties, timestamp, customerId, externalCustomerId, additionalProperties) } - /* spotless:on */ - override fun hashCode(): Int = hashCode override fun toString() = @@ -854,12 +867,10 @@ private constructor( return true } - return /* spotless:off */ other is Properties && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Properties && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -871,10 +882,15 @@ private constructor( return true } - return /* spotless:off */ other is EventUpdateParams && eventId == other.eventId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return other is EventUpdateParams && + eventId == other.eventId && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(eventId, body, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash(eventId, body, additionalHeaders, additionalQueryParams) override fun toString() = "EventUpdateParams{eventId=$eventId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventUpdateResponse.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventUpdateResponse.kt index a52c6758c..3ebe8cc8e 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventUpdateResponse.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventUpdateResponse.kt @@ -157,12 +157,12 @@ private constructor( return true } - return /* spotless:off */ other is EventUpdateResponse && amended == other.amended && additionalProperties == other.additionalProperties /* spotless:on */ + return other is EventUpdateResponse && + amended == other.amended && + additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(amended, additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventVolumeListParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventVolumeListParams.kt index be3b48b47..2dd9ac120 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventVolumeListParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventVolumeListParams.kt @@ -274,10 +274,24 @@ private constructor( return true } - return /* spotless:off */ other is EventVolumeListParams && timeframeStart == other.timeframeStart && cursor == other.cursor && limit == other.limit && timeframeEnd == other.timeframeEnd && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return other is EventVolumeListParams && + timeframeStart == other.timeframeStart && + cursor == other.cursor && + limit == other.limit && + timeframeEnd == other.timeframeEnd && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(timeframeStart, cursor, limit, timeframeEnd, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash( + timeframeStart, + cursor, + limit, + timeframeEnd, + additionalHeaders, + additionalQueryParams, + ) override fun toString() = "EventVolumeListParams{timeframeStart=$timeframeStart, cursor=$cursor, limit=$limit, timeframeEnd=$timeframeEnd, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventVolumes.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventVolumes.kt index df99171a2..8c1340f69 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventVolumes.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventVolumes.kt @@ -397,12 +397,16 @@ private constructor( return true } - return /* spotless:off */ other is Data && count == other.count && timeframeEnd == other.timeframeEnd && timeframeStart == other.timeframeStart && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Data && + count == other.count && + timeframeEnd == other.timeframeEnd && + timeframeStart == other.timeframeStart && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(count, timeframeEnd, timeframeStart, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash(count, timeframeEnd, timeframeStart, additionalProperties) + } override fun hashCode(): Int = hashCode @@ -415,12 +419,12 @@ private constructor( return true } - return /* spotless:off */ other is EventVolumes && data == other.data && additionalProperties == other.additionalProperties /* spotless:on */ + return other is EventVolumes && + data == other.data && + additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(data, additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/ExpirationChangeLedgerEntry.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/ExpirationChangeLedgerEntry.kt index 13fd30d5a..7cdf2354e 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/ExpirationChangeLedgerEntry.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/ExpirationChangeLedgerEntry.kt @@ -778,7 +778,7 @@ private constructor( return true } - return /* spotless:off */ other is EntryStatus && value == other.value /* spotless:on */ + return other is EntryStatus && value == other.value } override fun hashCode() = value.hashCode() @@ -898,7 +898,7 @@ private constructor( return true } - return /* spotless:off */ other is EntryType && value == other.value /* spotless:on */ + return other is EntryType && value == other.value } override fun hashCode() = value.hashCode() @@ -998,12 +998,10 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1015,12 +1013,43 @@ private constructor( return true } - return /* spotless:off */ other is ExpirationChangeLedgerEntry && id == other.id && amount == other.amount && createdAt == other.createdAt && creditBlock == other.creditBlock && currency == other.currency && customer == other.customer && description == other.description && endingBalance == other.endingBalance && entryStatus == other.entryStatus && entryType == other.entryType && ledgerSequenceNumber == other.ledgerSequenceNumber && metadata == other.metadata && newBlockExpiryDate == other.newBlockExpiryDate && startingBalance == other.startingBalance && additionalProperties == other.additionalProperties /* spotless:on */ + return other is ExpirationChangeLedgerEntry && + id == other.id && + amount == other.amount && + createdAt == other.createdAt && + creditBlock == other.creditBlock && + currency == other.currency && + customer == other.customer && + description == other.description && + endingBalance == other.endingBalance && + entryStatus == other.entryStatus && + entryType == other.entryType && + ledgerSequenceNumber == other.ledgerSequenceNumber && + metadata == other.metadata && + newBlockExpiryDate == other.newBlockExpiryDate && + startingBalance == other.startingBalance && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, amount, createdAt, creditBlock, currency, customer, description, endingBalance, entryStatus, entryType, ledgerSequenceNumber, metadata, newBlockExpiryDate, startingBalance, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + id, + amount, + createdAt, + creditBlock, + currency, + customer, + description, + endingBalance, + entryStatus, + entryType, + ledgerSequenceNumber, + metadata, + newBlockExpiryDate, + startingBalance, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/FixedFeeQuantityScheduleEntry.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/FixedFeeQuantityScheduleEntry.kt index b43e4800f..b78c08073 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/FixedFeeQuantityScheduleEntry.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/FixedFeeQuantityScheduleEntry.kt @@ -261,12 +261,17 @@ private constructor( return true } - return /* spotless:off */ other is FixedFeeQuantityScheduleEntry && endDate == other.endDate && priceId == other.priceId && quantity == other.quantity && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ + return other is FixedFeeQuantityScheduleEntry && + endDate == other.endDate && + priceId == other.priceId && + quantity == other.quantity && + startDate == other.startDate && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(endDate, priceId, quantity, startDate, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash(endDate, priceId, quantity, startDate, additionalProperties) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/FixedFeeQuantityTransition.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/FixedFeeQuantityTransition.kt index f747d988f..1f40f7693 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/FixedFeeQuantityTransition.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/FixedFeeQuantityTransition.kt @@ -228,12 +228,16 @@ private constructor( return true } - return /* spotless:off */ other is FixedFeeQuantityTransition && effectiveDate == other.effectiveDate && priceId == other.priceId && quantity == other.quantity && additionalProperties == other.additionalProperties /* spotless:on */ + return other is FixedFeeQuantityTransition && + effectiveDate == other.effectiveDate && + priceId == other.priceId && + quantity == other.quantity && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(effectiveDate, priceId, quantity, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash(effectiveDate, priceId, quantity, additionalProperties) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/IncrementLedgerEntry.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/IncrementLedgerEntry.kt index 53e6f762f..2dbd5b4da 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/IncrementLedgerEntry.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/IncrementLedgerEntry.kt @@ -790,7 +790,7 @@ private constructor( return true } - return /* spotless:off */ other is EntryStatus && value == other.value /* spotless:on */ + return other is EntryStatus && value == other.value } override fun hashCode() = value.hashCode() @@ -910,7 +910,7 @@ private constructor( return true } - return /* spotless:off */ other is EntryType && value == other.value /* spotless:on */ + return other is EntryType && value == other.value } override fun hashCode() = value.hashCode() @@ -1010,12 +1010,10 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1027,12 +1025,43 @@ private constructor( return true } - return /* spotless:off */ other is IncrementLedgerEntry && id == other.id && amount == other.amount && createdAt == other.createdAt && creditBlock == other.creditBlock && currency == other.currency && customer == other.customer && description == other.description && endingBalance == other.endingBalance && entryStatus == other.entryStatus && entryType == other.entryType && ledgerSequenceNumber == other.ledgerSequenceNumber && metadata == other.metadata && startingBalance == other.startingBalance && createdInvoices == other.createdInvoices && additionalProperties == other.additionalProperties /* spotless:on */ + return other is IncrementLedgerEntry && + id == other.id && + amount == other.amount && + createdAt == other.createdAt && + creditBlock == other.creditBlock && + currency == other.currency && + customer == other.customer && + description == other.description && + endingBalance == other.endingBalance && + entryStatus == other.entryStatus && + entryType == other.entryType && + ledgerSequenceNumber == other.ledgerSequenceNumber && + metadata == other.metadata && + startingBalance == other.startingBalance && + createdInvoices == other.createdInvoices && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, amount, createdAt, creditBlock, currency, customer, description, endingBalance, entryStatus, entryType, ledgerSequenceNumber, metadata, startingBalance, createdInvoices, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + id, + amount, + createdAt, + creditBlock, + currency, + customer, + description, + endingBalance, + entryStatus, + entryType, + ledgerSequenceNumber, + metadata, + startingBalance, + createdInvoices, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Invoice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Invoice.kt index 6ae5a30b2..1471b9d15 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Invoice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Invoice.kt @@ -2543,12 +2543,23 @@ private constructor( return true } - return /* spotless:off */ other is AutoCollection && enabled == other.enabled && nextAttemptAt == other.nextAttemptAt && numAttempts == other.numAttempts && previouslyAttemptedAt == other.previouslyAttemptedAt && additionalProperties == other.additionalProperties /* spotless:on */ + return other is AutoCollection && + enabled == other.enabled && + nextAttemptAt == other.nextAttemptAt && + numAttempts == other.numAttempts && + previouslyAttemptedAt == other.previouslyAttemptedAt && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(enabled, nextAttemptAt, numAttempts, previouslyAttemptedAt, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + enabled, + nextAttemptAt, + numAttempts, + previouslyAttemptedAt, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode @@ -2918,12 +2929,29 @@ private constructor( return true } - return /* spotless:off */ other is CreditNote && id == other.id && creditNoteNumber == other.creditNoteNumber && memo == other.memo && reason == other.reason && total == other.total && type == other.type && voidedAt == other.voidedAt && additionalProperties == other.additionalProperties /* spotless:on */ + return other is CreditNote && + id == other.id && + creditNoteNumber == other.creditNoteNumber && + memo == other.memo && + reason == other.reason && + total == other.total && + type == other.type && + voidedAt == other.voidedAt && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, creditNoteNumber, memo, reason, total, type, voidedAt, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + id, + creditNoteNumber, + memo, + reason, + total, + type, + voidedAt, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode @@ -3602,7 +3630,7 @@ private constructor( return true } - return /* spotless:off */ other is Action && value == other.value /* spotless:on */ + return other is Action && value == other.value } override fun hashCode() = value.hashCode() @@ -3727,7 +3755,7 @@ private constructor( return true } - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + return other is Type && value == other.value } override fun hashCode() = value.hashCode() @@ -3740,12 +3768,35 @@ private constructor( return true } - return /* spotless:off */ other is CustomerBalanceTransaction && id == other.id && action == other.action && amount == other.amount && createdAt == other.createdAt && creditNote == other.creditNote && description == other.description && endingBalance == other.endingBalance && invoice == other.invoice && startingBalance == other.startingBalance && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return other is CustomerBalanceTransaction && + id == other.id && + action == other.action && + amount == other.amount && + createdAt == other.createdAt && + creditNote == other.creditNote && + description == other.description && + endingBalance == other.endingBalance && + invoice == other.invoice && + startingBalance == other.startingBalance && + type == other.type && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, action, amount, createdAt, creditNote, description, endingBalance, invoice, startingBalance, type, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + id, + action, + amount, + createdAt, + creditNote, + description, + endingBalance, + invoice, + startingBalance, + type, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode @@ -3879,7 +3930,7 @@ private constructor( return true } - return /* spotless:off */ other is InvoiceSource && value == other.value /* spotless:on */ + return other is InvoiceSource && value == other.value } override fun hashCode() = value.hashCode() @@ -5408,10 +5459,16 @@ private constructor( return true } - return /* spotless:off */ other is Adjustment && usageDiscount == other.usageDiscount && amountDiscount == other.amountDiscount && percentageDiscount == other.percentageDiscount && minimum == other.minimum && maximum == other.maximum /* spotless:on */ + return other is Adjustment && + usageDiscount == other.usageDiscount && + amountDiscount == other.amountDiscount && + percentageDiscount == other.percentageDiscount && + minimum == other.minimum && + maximum == other.maximum } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(usageDiscount, amountDiscount, percentageDiscount, minimum, maximum) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash(usageDiscount, amountDiscount, percentageDiscount, minimum, maximum) override fun toString(): String = when { @@ -5637,10 +5694,13 @@ private constructor( return true } - return /* spotless:off */ other is SubLineItem && matrix == other.matrix && tier == other.tier && null_ == other.null_ /* spotless:on */ + return other is SubLineItem && + matrix == other.matrix && + tier == other.tier && + null_ == other.null_ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(matrix, tier, null_) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(matrix, tier, null_) override fun toString(): String = when { @@ -5738,12 +5798,59 @@ private constructor( return true } - return /* spotless:off */ other is LineItem && id == other.id && adjustedSubtotal == other.adjustedSubtotal && adjustments == other.adjustments && amount == other.amount && creditsApplied == other.creditsApplied && discount == other.discount && endDate == other.endDate && filter == other.filter && grouping == other.grouping && maximum == other.maximum && maximumAmount == other.maximumAmount && minimum == other.minimum && minimumAmount == other.minimumAmount && name == other.name && partiallyInvoicedAmount == other.partiallyInvoicedAmount && price == other.price && quantity == other.quantity && startDate == other.startDate && subLineItems == other.subLineItems && subtotal == other.subtotal && taxAmounts == other.taxAmounts && usageCustomerIds == other.usageCustomerIds && additionalProperties == other.additionalProperties /* spotless:on */ + return other is LineItem && + id == other.id && + adjustedSubtotal == other.adjustedSubtotal && + adjustments == other.adjustments && + amount == other.amount && + creditsApplied == other.creditsApplied && + discount == other.discount && + endDate == other.endDate && + filter == other.filter && + grouping == other.grouping && + maximum == other.maximum && + maximumAmount == other.maximumAmount && + minimum == other.minimum && + minimumAmount == other.minimumAmount && + name == other.name && + partiallyInvoicedAmount == other.partiallyInvoicedAmount && + price == other.price && + quantity == other.quantity && + startDate == other.startDate && + subLineItems == other.subLineItems && + subtotal == other.subtotal && + taxAmounts == other.taxAmounts && + usageCustomerIds == other.usageCustomerIds && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, adjustedSubtotal, adjustments, amount, creditsApplied, discount, endDate, filter, grouping, maximum, maximumAmount, minimum, minimumAmount, name, partiallyInvoicedAmount, price, quantity, startDate, subLineItems, subtotal, taxAmounts, usageCustomerIds, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + id, + adjustedSubtotal, + adjustments, + amount, + creditsApplied, + discount, + endDate, + filter, + grouping, + maximum, + maximumAmount, + minimum, + minimumAmount, + name, + partiallyInvoicedAmount, + price, + quantity, + startDate, + subLineItems, + subtotal, + taxAmounts, + usageCustomerIds, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode @@ -5843,12 +5950,10 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -6324,7 +6429,7 @@ private constructor( return true } - return /* spotless:off */ other is PaymentProvider && value == other.value /* spotless:on */ + return other is PaymentProvider && value == other.value } override fun hashCode() = value.hashCode() @@ -6337,12 +6442,27 @@ private constructor( return true } - return /* spotless:off */ other is PaymentAttempt && id == other.id && amount == other.amount && createdAt == other.createdAt && paymentProvider == other.paymentProvider && paymentProviderId == other.paymentProviderId && succeeded == other.succeeded && additionalProperties == other.additionalProperties /* spotless:on */ + return other is PaymentAttempt && + id == other.id && + amount == other.amount && + createdAt == other.createdAt && + paymentProvider == other.paymentProvider && + paymentProviderId == other.paymentProviderId && + succeeded == other.succeeded && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, amount, createdAt, paymentProvider, paymentProviderId, succeeded, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + id, + amount, + createdAt, + paymentProvider, + paymentProviderId, + succeeded, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode @@ -6484,7 +6604,7 @@ private constructor( return true } - return /* spotless:off */ other is Status && value == other.value /* spotless:on */ + return other is Status && value == other.value } override fun hashCode() = value.hashCode() @@ -6497,12 +6617,97 @@ private constructor( return true } - return /* spotless:off */ other is Invoice && id == other.id && amountDue == other.amountDue && autoCollection == other.autoCollection && billingAddress == other.billingAddress && createdAt == other.createdAt && creditNotes == other.creditNotes && currency == other.currency && customer == other.customer && customerBalanceTransactions == other.customerBalanceTransactions && customerTaxId == other.customerTaxId && discount == other.discount && discounts == other.discounts && dueDate == other.dueDate && eligibleToIssueAt == other.eligibleToIssueAt && hostedInvoiceUrl == other.hostedInvoiceUrl && invoiceDate == other.invoiceDate && invoiceNumber == other.invoiceNumber && invoicePdf == other.invoicePdf && invoiceSource == other.invoiceSource && issueFailedAt == other.issueFailedAt && issuedAt == other.issuedAt && lineItems == other.lineItems && maximum == other.maximum && maximumAmount == other.maximumAmount && memo == other.memo && metadata == other.metadata && minimum == other.minimum && minimumAmount == other.minimumAmount && paidAt == other.paidAt && paymentAttempts == other.paymentAttempts && paymentFailedAt == other.paymentFailedAt && paymentStartedAt == other.paymentStartedAt && scheduledIssueAt == other.scheduledIssueAt && shippingAddress == other.shippingAddress && status == other.status && subscription == other.subscription && subtotal == other.subtotal && syncFailedAt == other.syncFailedAt && total == other.total && voidedAt == other.voidedAt && willAutoIssue == other.willAutoIssue && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Invoice && + id == other.id && + amountDue == other.amountDue && + autoCollection == other.autoCollection && + billingAddress == other.billingAddress && + createdAt == other.createdAt && + creditNotes == other.creditNotes && + currency == other.currency && + customer == other.customer && + customerBalanceTransactions == other.customerBalanceTransactions && + customerTaxId == other.customerTaxId && + discount == other.discount && + discounts == other.discounts && + dueDate == other.dueDate && + eligibleToIssueAt == other.eligibleToIssueAt && + hostedInvoiceUrl == other.hostedInvoiceUrl && + invoiceDate == other.invoiceDate && + invoiceNumber == other.invoiceNumber && + invoicePdf == other.invoicePdf && + invoiceSource == other.invoiceSource && + issueFailedAt == other.issueFailedAt && + issuedAt == other.issuedAt && + lineItems == other.lineItems && + maximum == other.maximum && + maximumAmount == other.maximumAmount && + memo == other.memo && + metadata == other.metadata && + minimum == other.minimum && + minimumAmount == other.minimumAmount && + paidAt == other.paidAt && + paymentAttempts == other.paymentAttempts && + paymentFailedAt == other.paymentFailedAt && + paymentStartedAt == other.paymentStartedAt && + scheduledIssueAt == other.scheduledIssueAt && + shippingAddress == other.shippingAddress && + status == other.status && + subscription == other.subscription && + subtotal == other.subtotal && + syncFailedAt == other.syncFailedAt && + total == other.total && + voidedAt == other.voidedAt && + willAutoIssue == other.willAutoIssue && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, amountDue, autoCollection, billingAddress, createdAt, creditNotes, currency, customer, customerBalanceTransactions, customerTaxId, discount, discounts, dueDate, eligibleToIssueAt, hostedInvoiceUrl, invoiceDate, invoiceNumber, invoicePdf, invoiceSource, issueFailedAt, issuedAt, lineItems, maximum, maximumAmount, memo, metadata, minimum, minimumAmount, paidAt, paymentAttempts, paymentFailedAt, paymentStartedAt, scheduledIssueAt, shippingAddress, status, subscription, subtotal, syncFailedAt, total, voidedAt, willAutoIssue, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + id, + amountDue, + autoCollection, + billingAddress, + createdAt, + creditNotes, + currency, + customer, + customerBalanceTransactions, + customerTaxId, + discount, + discounts, + dueDate, + eligibleToIssueAt, + hostedInvoiceUrl, + invoiceDate, + invoiceNumber, + invoicePdf, + invoiceSource, + issueFailedAt, + issuedAt, + lineItems, + maximum, + maximumAmount, + memo, + metadata, + minimum, + minimumAmount, + paidAt, + paymentAttempts, + paymentFailedAt, + paymentStartedAt, + scheduledIssueAt, + shippingAddress, + status, + subscription, + subtotal, + syncFailedAt, + total, + voidedAt, + willAutoIssue, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceCreateParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceCreateParams.kt index 92db04fc8..5dfacfffa 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceCreateParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceCreateParams.kt @@ -1208,12 +1208,35 @@ private constructor( return true } - return /* spotless:off */ other is Body && currency == other.currency && invoiceDate == other.invoiceDate && lineItems == other.lineItems && customerId == other.customerId && discount == other.discount && externalCustomerId == other.externalCustomerId && memo == other.memo && metadata == other.metadata && netTerms == other.netTerms && willAutoIssue == other.willAutoIssue && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Body && + currency == other.currency && + invoiceDate == other.invoiceDate && + lineItems == other.lineItems && + customerId == other.customerId && + discount == other.discount && + externalCustomerId == other.externalCustomerId && + memo == other.memo && + metadata == other.metadata && + netTerms == other.netTerms && + willAutoIssue == other.willAutoIssue && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(currency, invoiceDate, lineItems, customerId, discount, externalCustomerId, memo, metadata, netTerms, willAutoIssue, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + currency, + invoiceDate, + lineItems, + customerId, + discount, + externalCustomerId, + memo, + metadata, + netTerms, + willAutoIssue, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode @@ -1701,7 +1724,7 @@ private constructor( return true } - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + return other is ModelType && value == other.value } override fun hashCode() = value.hashCode() @@ -1714,12 +1737,29 @@ private constructor( return true } - return /* spotless:off */ other is LineItem && endDate == other.endDate && itemId == other.itemId && modelType == other.modelType && name == other.name && quantity == other.quantity && startDate == other.startDate && unitConfig == other.unitConfig && additionalProperties == other.additionalProperties /* spotless:on */ + return other is LineItem && + endDate == other.endDate && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + quantity == other.quantity && + startDate == other.startDate && + unitConfig == other.unitConfig && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(endDate, itemId, modelType, name, quantity, startDate, unitConfig, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + endDate, + itemId, + modelType, + name, + quantity, + startDate, + unitConfig, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode @@ -1819,12 +1859,10 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1836,10 +1874,13 @@ private constructor( return true } - return /* spotless:off */ other is InvoiceCreateParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return other is InvoiceCreateParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(body, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) override fun toString() = "InvoiceCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceFetchParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceFetchParams.kt index cd4aa98ec..4cbff9b06 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceFetchParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceFetchParams.kt @@ -170,10 +170,13 @@ private constructor( return true } - return /* spotless:off */ other is InvoiceFetchParams && invoiceId == other.invoiceId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return other is InvoiceFetchParams && + invoiceId == other.invoiceId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(invoiceId, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(invoiceId, additionalHeaders, additionalQueryParams) override fun toString() = "InvoiceFetchParams{invoiceId=$invoiceId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceFetchUpcomingParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceFetchUpcomingParams.kt index 84ef1e721..943c0f66d 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceFetchUpcomingParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceFetchUpcomingParams.kt @@ -190,10 +190,14 @@ private constructor( return true } - return /* spotless:off */ other is InvoiceFetchUpcomingParams && subscriptionId == other.subscriptionId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return other is InvoiceFetchUpcomingParams && + subscriptionId == other.subscriptionId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(subscriptionId, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash(subscriptionId, additionalHeaders, additionalQueryParams) override fun toString() = "InvoiceFetchUpcomingParams{subscriptionId=$subscriptionId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceFetchUpcomingResponse.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceFetchUpcomingResponse.kt index 6a4a0e2b2..fbdb74d89 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceFetchUpcomingResponse.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceFetchUpcomingResponse.kt @@ -2537,12 +2537,23 @@ private constructor( return true } - return /* spotless:off */ other is AutoCollection && enabled == other.enabled && nextAttemptAt == other.nextAttemptAt && numAttempts == other.numAttempts && previouslyAttemptedAt == other.previouslyAttemptedAt && additionalProperties == other.additionalProperties /* spotless:on */ + return other is AutoCollection && + enabled == other.enabled && + nextAttemptAt == other.nextAttemptAt && + numAttempts == other.numAttempts && + previouslyAttemptedAt == other.previouslyAttemptedAt && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(enabled, nextAttemptAt, numAttempts, previouslyAttemptedAt, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + enabled, + nextAttemptAt, + numAttempts, + previouslyAttemptedAt, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode @@ -2912,12 +2923,29 @@ private constructor( return true } - return /* spotless:off */ other is CreditNote && id == other.id && creditNoteNumber == other.creditNoteNumber && memo == other.memo && reason == other.reason && total == other.total && type == other.type && voidedAt == other.voidedAt && additionalProperties == other.additionalProperties /* spotless:on */ + return other is CreditNote && + id == other.id && + creditNoteNumber == other.creditNoteNumber && + memo == other.memo && + reason == other.reason && + total == other.total && + type == other.type && + voidedAt == other.voidedAt && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, creditNoteNumber, memo, reason, total, type, voidedAt, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + id, + creditNoteNumber, + memo, + reason, + total, + type, + voidedAt, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode @@ -3596,7 +3624,7 @@ private constructor( return true } - return /* spotless:off */ other is Action && value == other.value /* spotless:on */ + return other is Action && value == other.value } override fun hashCode() = value.hashCode() @@ -3721,7 +3749,7 @@ private constructor( return true } - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + return other is Type && value == other.value } override fun hashCode() = value.hashCode() @@ -3734,12 +3762,35 @@ private constructor( return true } - return /* spotless:off */ other is CustomerBalanceTransaction && id == other.id && action == other.action && amount == other.amount && createdAt == other.createdAt && creditNote == other.creditNote && description == other.description && endingBalance == other.endingBalance && invoice == other.invoice && startingBalance == other.startingBalance && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return other is CustomerBalanceTransaction && + id == other.id && + action == other.action && + amount == other.amount && + createdAt == other.createdAt && + creditNote == other.creditNote && + description == other.description && + endingBalance == other.endingBalance && + invoice == other.invoice && + startingBalance == other.startingBalance && + type == other.type && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, action, amount, createdAt, creditNote, description, endingBalance, invoice, startingBalance, type, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + id, + action, + amount, + createdAt, + creditNote, + description, + endingBalance, + invoice, + startingBalance, + type, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode @@ -3873,7 +3924,7 @@ private constructor( return true } - return /* spotless:off */ other is InvoiceSource && value == other.value /* spotless:on */ + return other is InvoiceSource && value == other.value } override fun hashCode() = value.hashCode() @@ -5402,10 +5453,16 @@ private constructor( return true } - return /* spotless:off */ other is Adjustment && usageDiscount == other.usageDiscount && amountDiscount == other.amountDiscount && percentageDiscount == other.percentageDiscount && minimum == other.minimum && maximum == other.maximum /* spotless:on */ + return other is Adjustment && + usageDiscount == other.usageDiscount && + amountDiscount == other.amountDiscount && + percentageDiscount == other.percentageDiscount && + minimum == other.minimum && + maximum == other.maximum } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(usageDiscount, amountDiscount, percentageDiscount, minimum, maximum) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash(usageDiscount, amountDiscount, percentageDiscount, minimum, maximum) override fun toString(): String = when { @@ -5631,10 +5688,13 @@ private constructor( return true } - return /* spotless:off */ other is SubLineItem && matrix == other.matrix && tier == other.tier && null_ == other.null_ /* spotless:on */ + return other is SubLineItem && + matrix == other.matrix && + tier == other.tier && + null_ == other.null_ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(matrix, tier, null_) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(matrix, tier, null_) override fun toString(): String = when { @@ -5732,12 +5792,59 @@ private constructor( return true } - return /* spotless:off */ other is LineItem && id == other.id && adjustedSubtotal == other.adjustedSubtotal && adjustments == other.adjustments && amount == other.amount && creditsApplied == other.creditsApplied && discount == other.discount && endDate == other.endDate && filter == other.filter && grouping == other.grouping && maximum == other.maximum && maximumAmount == other.maximumAmount && minimum == other.minimum && minimumAmount == other.minimumAmount && name == other.name && partiallyInvoicedAmount == other.partiallyInvoicedAmount && price == other.price && quantity == other.quantity && startDate == other.startDate && subLineItems == other.subLineItems && subtotal == other.subtotal && taxAmounts == other.taxAmounts && usageCustomerIds == other.usageCustomerIds && additionalProperties == other.additionalProperties /* spotless:on */ + return other is LineItem && + id == other.id && + adjustedSubtotal == other.adjustedSubtotal && + adjustments == other.adjustments && + amount == other.amount && + creditsApplied == other.creditsApplied && + discount == other.discount && + endDate == other.endDate && + filter == other.filter && + grouping == other.grouping && + maximum == other.maximum && + maximumAmount == other.maximumAmount && + minimum == other.minimum && + minimumAmount == other.minimumAmount && + name == other.name && + partiallyInvoicedAmount == other.partiallyInvoicedAmount && + price == other.price && + quantity == other.quantity && + startDate == other.startDate && + subLineItems == other.subLineItems && + subtotal == other.subtotal && + taxAmounts == other.taxAmounts && + usageCustomerIds == other.usageCustomerIds && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, adjustedSubtotal, adjustments, amount, creditsApplied, discount, endDate, filter, grouping, maximum, maximumAmount, minimum, minimumAmount, name, partiallyInvoicedAmount, price, quantity, startDate, subLineItems, subtotal, taxAmounts, usageCustomerIds, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + id, + adjustedSubtotal, + adjustments, + amount, + creditsApplied, + discount, + endDate, + filter, + grouping, + maximum, + maximumAmount, + minimum, + minimumAmount, + name, + partiallyInvoicedAmount, + price, + quantity, + startDate, + subLineItems, + subtotal, + taxAmounts, + usageCustomerIds, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode @@ -5837,12 +5944,10 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -6318,7 +6423,7 @@ private constructor( return true } - return /* spotless:off */ other is PaymentProvider && value == other.value /* spotless:on */ + return other is PaymentProvider && value == other.value } override fun hashCode() = value.hashCode() @@ -6331,12 +6436,27 @@ private constructor( return true } - return /* spotless:off */ other is PaymentAttempt && id == other.id && amount == other.amount && createdAt == other.createdAt && paymentProvider == other.paymentProvider && paymentProviderId == other.paymentProviderId && succeeded == other.succeeded && additionalProperties == other.additionalProperties /* spotless:on */ + return other is PaymentAttempt && + id == other.id && + amount == other.amount && + createdAt == other.createdAt && + paymentProvider == other.paymentProvider && + paymentProviderId == other.paymentProviderId && + succeeded == other.succeeded && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, amount, createdAt, paymentProvider, paymentProviderId, succeeded, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + id, + amount, + createdAt, + paymentProvider, + paymentProviderId, + succeeded, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode @@ -6478,7 +6598,7 @@ private constructor( return true } - return /* spotless:off */ other is Status && value == other.value /* spotless:on */ + return other is Status && value == other.value } override fun hashCode() = value.hashCode() @@ -6491,12 +6611,97 @@ private constructor( return true } - return /* spotless:off */ other is InvoiceFetchUpcomingResponse && id == other.id && amountDue == other.amountDue && autoCollection == other.autoCollection && billingAddress == other.billingAddress && createdAt == other.createdAt && creditNotes == other.creditNotes && currency == other.currency && customer == other.customer && customerBalanceTransactions == other.customerBalanceTransactions && customerTaxId == other.customerTaxId && discount == other.discount && discounts == other.discounts && dueDate == other.dueDate && eligibleToIssueAt == other.eligibleToIssueAt && hostedInvoiceUrl == other.hostedInvoiceUrl && invoiceNumber == other.invoiceNumber && invoicePdf == other.invoicePdf && invoiceSource == other.invoiceSource && issueFailedAt == other.issueFailedAt && issuedAt == other.issuedAt && lineItems == other.lineItems && maximum == other.maximum && maximumAmount == other.maximumAmount && memo == other.memo && metadata == other.metadata && minimum == other.minimum && minimumAmount == other.minimumAmount && paidAt == other.paidAt && paymentAttempts == other.paymentAttempts && paymentFailedAt == other.paymentFailedAt && paymentStartedAt == other.paymentStartedAt && scheduledIssueAt == other.scheduledIssueAt && shippingAddress == other.shippingAddress && status == other.status && subscription == other.subscription && subtotal == other.subtotal && syncFailedAt == other.syncFailedAt && targetDate == other.targetDate && total == other.total && voidedAt == other.voidedAt && willAutoIssue == other.willAutoIssue && additionalProperties == other.additionalProperties /* spotless:on */ + return other is InvoiceFetchUpcomingResponse && + id == other.id && + amountDue == other.amountDue && + autoCollection == other.autoCollection && + billingAddress == other.billingAddress && + createdAt == other.createdAt && + creditNotes == other.creditNotes && + currency == other.currency && + customer == other.customer && + customerBalanceTransactions == other.customerBalanceTransactions && + customerTaxId == other.customerTaxId && + discount == other.discount && + discounts == other.discounts && + dueDate == other.dueDate && + eligibleToIssueAt == other.eligibleToIssueAt && + hostedInvoiceUrl == other.hostedInvoiceUrl && + invoiceNumber == other.invoiceNumber && + invoicePdf == other.invoicePdf && + invoiceSource == other.invoiceSource && + issueFailedAt == other.issueFailedAt && + issuedAt == other.issuedAt && + lineItems == other.lineItems && + maximum == other.maximum && + maximumAmount == other.maximumAmount && + memo == other.memo && + metadata == other.metadata && + minimum == other.minimum && + minimumAmount == other.minimumAmount && + paidAt == other.paidAt && + paymentAttempts == other.paymentAttempts && + paymentFailedAt == other.paymentFailedAt && + paymentStartedAt == other.paymentStartedAt && + scheduledIssueAt == other.scheduledIssueAt && + shippingAddress == other.shippingAddress && + status == other.status && + subscription == other.subscription && + subtotal == other.subtotal && + syncFailedAt == other.syncFailedAt && + targetDate == other.targetDate && + total == other.total && + voidedAt == other.voidedAt && + willAutoIssue == other.willAutoIssue && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, amountDue, autoCollection, billingAddress, createdAt, creditNotes, currency, customer, customerBalanceTransactions, customerTaxId, discount, discounts, dueDate, eligibleToIssueAt, hostedInvoiceUrl, invoiceNumber, invoicePdf, invoiceSource, issueFailedAt, issuedAt, lineItems, maximum, maximumAmount, memo, metadata, minimum, minimumAmount, paidAt, paymentAttempts, paymentFailedAt, paymentStartedAt, scheduledIssueAt, shippingAddress, status, subscription, subtotal, syncFailedAt, targetDate, total, voidedAt, willAutoIssue, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + id, + amountDue, + autoCollection, + billingAddress, + createdAt, + creditNotes, + currency, + customer, + customerBalanceTransactions, + customerTaxId, + discount, + discounts, + dueDate, + eligibleToIssueAt, + hostedInvoiceUrl, + invoiceNumber, + invoicePdf, + invoiceSource, + issueFailedAt, + issuedAt, + lineItems, + maximum, + maximumAmount, + memo, + metadata, + minimum, + minimumAmount, + paidAt, + paymentAttempts, + paymentFailedAt, + paymentStartedAt, + scheduledIssueAt, + shippingAddress, + status, + subscription, + subtotal, + syncFailedAt, + targetDate, + total, + voidedAt, + willAutoIssue, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceIssueParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceIssueParams.kt index 268bc23fc..32bddb49f 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceIssueParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceIssueParams.kt @@ -397,12 +397,12 @@ private constructor( return true } - return /* spotless:off */ other is Body && synchronous == other.synchronous && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Body && + synchronous == other.synchronous && + additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(synchronous, additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -415,10 +415,15 @@ private constructor( return true } - return /* spotless:off */ other is InvoiceIssueParams && invoiceId == other.invoiceId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return other is InvoiceIssueParams && + invoiceId == other.invoiceId && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(invoiceId, body, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash(invoiceId, body, additionalHeaders, additionalQueryParams) override fun toString() = "InvoiceIssueParams{invoiceId=$invoiceId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceLevelDiscount.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceLevelDiscount.kt index be57db54f..239c2a8ba 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceLevelDiscount.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceLevelDiscount.kt @@ -110,10 +110,13 @@ private constructor( return true } - return /* spotless:off */ other is InvoiceLevelDiscount && percentage == other.percentage && amount == other.amount && trial == other.trial /* spotless:on */ + return other is InvoiceLevelDiscount && + percentage == other.percentage && + amount == other.amount && + trial == other.trial } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(percentage, amount, trial) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(percentage, amount, trial) override fun toString(): String = when { diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceLineItemCreateParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceLineItemCreateParams.kt index 354721a8a..0accc2cf6 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceLineItemCreateParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceLineItemCreateParams.kt @@ -735,12 +735,27 @@ private constructor( return true } - return /* spotless:off */ other is Body && amount == other.amount && endDate == other.endDate && invoiceId == other.invoiceId && name == other.name && quantity == other.quantity && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Body && + amount == other.amount && + endDate == other.endDate && + invoiceId == other.invoiceId && + name == other.name && + quantity == other.quantity && + startDate == other.startDate && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(amount, endDate, invoiceId, name, quantity, startDate, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + amount, + endDate, + invoiceId, + name, + quantity, + startDate, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode @@ -753,10 +768,13 @@ private constructor( return true } - return /* spotless:off */ other is InvoiceLineItemCreateParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return other is InvoiceLineItemCreateParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(body, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) override fun toString() = "InvoiceLineItemCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceLineItemCreateResponse.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceLineItemCreateResponse.kt index e5923615c..6a013311e 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceLineItemCreateResponse.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceLineItemCreateResponse.kt @@ -1500,10 +1500,16 @@ private constructor( return true } - return /* spotless:off */ other is Adjustment && usageDiscount == other.usageDiscount && amountDiscount == other.amountDiscount && percentageDiscount == other.percentageDiscount && minimum == other.minimum && maximum == other.maximum /* spotless:on */ + return other is Adjustment && + usageDiscount == other.usageDiscount && + amountDiscount == other.amountDiscount && + percentageDiscount == other.percentageDiscount && + minimum == other.minimum && + maximum == other.maximum } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(usageDiscount, amountDiscount, percentageDiscount, minimum, maximum) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash(usageDiscount, amountDiscount, percentageDiscount, minimum, maximum) override fun toString(): String = when { @@ -1725,10 +1731,13 @@ private constructor( return true } - return /* spotless:off */ other is SubLineItem && matrix == other.matrix && tier == other.tier && null_ == other.null_ /* spotless:on */ + return other is SubLineItem && + matrix == other.matrix && + tier == other.tier && + null_ == other.null_ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(matrix, tier, null_) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(matrix, tier, null_) override fun toString(): String = when { @@ -1826,12 +1835,59 @@ private constructor( return true } - return /* spotless:off */ other is InvoiceLineItemCreateResponse && id == other.id && adjustedSubtotal == other.adjustedSubtotal && adjustments == other.adjustments && amount == other.amount && creditsApplied == other.creditsApplied && discount == other.discount && endDate == other.endDate && filter == other.filter && grouping == other.grouping && maximum == other.maximum && maximumAmount == other.maximumAmount && minimum == other.minimum && minimumAmount == other.minimumAmount && name == other.name && partiallyInvoicedAmount == other.partiallyInvoicedAmount && price == other.price && quantity == other.quantity && startDate == other.startDate && subLineItems == other.subLineItems && subtotal == other.subtotal && taxAmounts == other.taxAmounts && usageCustomerIds == other.usageCustomerIds && additionalProperties == other.additionalProperties /* spotless:on */ + return other is InvoiceLineItemCreateResponse && + id == other.id && + adjustedSubtotal == other.adjustedSubtotal && + adjustments == other.adjustments && + amount == other.amount && + creditsApplied == other.creditsApplied && + discount == other.discount && + endDate == other.endDate && + filter == other.filter && + grouping == other.grouping && + maximum == other.maximum && + maximumAmount == other.maximumAmount && + minimum == other.minimum && + minimumAmount == other.minimumAmount && + name == other.name && + partiallyInvoicedAmount == other.partiallyInvoicedAmount && + price == other.price && + quantity == other.quantity && + startDate == other.startDate && + subLineItems == other.subLineItems && + subtotal == other.subtotal && + taxAmounts == other.taxAmounts && + usageCustomerIds == other.usageCustomerIds && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, adjustedSubtotal, adjustments, amount, creditsApplied, discount, endDate, filter, grouping, maximum, maximumAmount, minimum, minimumAmount, name, partiallyInvoicedAmount, price, quantity, startDate, subLineItems, subtotal, taxAmounts, usageCustomerIds, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + id, + adjustedSubtotal, + adjustments, + amount, + creditsApplied, + discount, + endDate, + filter, + grouping, + maximum, + maximumAmount, + minimum, + minimumAmount, + name, + partiallyInvoicedAmount, + price, + quantity, + startDate, + subLineItems, + subtotal, + taxAmounts, + usageCustomerIds, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceListPage.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceListPage.kt index 062cc6fcc..6f5e36bb2 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceListPage.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceListPage.kt @@ -119,10 +119,13 @@ private constructor( return true } - return /* spotless:off */ other is InvoiceListPage && service == other.service && params == other.params && response == other.response /* spotless:on */ + return other is InvoiceListPage && + service == other.service && + params == other.params && + response == other.response } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, params, response) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(service, params, response) override fun toString() = "InvoiceListPage{service=$service, params=$params, response=$response}" diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceListPageAsync.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceListPageAsync.kt index 9ce9fa8fe..6eb0c571f 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceListPageAsync.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceListPageAsync.kt @@ -119,10 +119,13 @@ private constructor( return true } - return /* spotless:off */ other is InvoiceListPageAsync && service == other.service && params == other.params && response == other.response /* spotless:on */ + return other is InvoiceListPageAsync && + service == other.service && + params == other.params && + response == other.response } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, params, response) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(service, params, response) override fun toString() = "InvoiceListPageAsync{service=$service, params=$params, response=$response}" diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceListPageResponse.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceListPageResponse.kt index 85152dbab..fcb1cf666 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceListPageResponse.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceListPageResponse.kt @@ -214,12 +214,15 @@ private constructor( return true } - return /* spotless:off */ other is InvoiceListPageResponse && data == other.data && paginationMetadata == other.paginationMetadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is InvoiceListPageResponse && + data == other.data && + paginationMetadata == other.paginationMetadata && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(data, paginationMetadata, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash(data, paginationMetadata, additionalProperties) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceListParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceListParams.kt index d37d6701b..eee133137 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceListParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceListParams.kt @@ -529,7 +529,7 @@ private constructor( return true } - return /* spotless:off */ other is DateType && value == other.value /* spotless:on */ + return other is DateType && value == other.value } override fun hashCode() = value.hashCode() @@ -671,7 +671,7 @@ private constructor( return true } - return /* spotless:off */ other is Status && value == other.value /* spotless:on */ + return other is Status && value == other.value } override fun hashCode() = value.hashCode() @@ -684,10 +684,54 @@ private constructor( return true } - return /* spotless:off */ other is InvoiceListParams && amount == other.amount && amountGt == other.amountGt && amountLt == other.amountLt && cursor == other.cursor && customerId == other.customerId && dateType == other.dateType && dueDate == other.dueDate && dueDateWindow == other.dueDateWindow && dueDateGt == other.dueDateGt && dueDateLt == other.dueDateLt && externalCustomerId == other.externalCustomerId && invoiceDateGt == other.invoiceDateGt && invoiceDateGte == other.invoiceDateGte && invoiceDateLt == other.invoiceDateLt && invoiceDateLte == other.invoiceDateLte && isRecurring == other.isRecurring && limit == other.limit && status == other.status && subscriptionId == other.subscriptionId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return other is InvoiceListParams && + amount == other.amount && + amountGt == other.amountGt && + amountLt == other.amountLt && + cursor == other.cursor && + customerId == other.customerId && + dateType == other.dateType && + dueDate == other.dueDate && + dueDateWindow == other.dueDateWindow && + dueDateGt == other.dueDateGt && + dueDateLt == other.dueDateLt && + externalCustomerId == other.externalCustomerId && + invoiceDateGt == other.invoiceDateGt && + invoiceDateGte == other.invoiceDateGte && + invoiceDateLt == other.invoiceDateLt && + invoiceDateLte == other.invoiceDateLte && + isRecurring == other.isRecurring && + limit == other.limit && + status == other.status && + subscriptionId == other.subscriptionId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(amount, amountGt, amountLt, cursor, customerId, dateType, dueDate, dueDateWindow, dueDateGt, dueDateLt, externalCustomerId, invoiceDateGt, invoiceDateGte, invoiceDateLt, invoiceDateLte, isRecurring, limit, status, subscriptionId, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash( + amount, + amountGt, + amountLt, + cursor, + customerId, + dateType, + dueDate, + dueDateWindow, + dueDateGt, + dueDateLt, + externalCustomerId, + invoiceDateGt, + invoiceDateGte, + invoiceDateLt, + invoiceDateLte, + isRecurring, + limit, + status, + subscriptionId, + additionalHeaders, + additionalQueryParams, + ) override fun toString() = "InvoiceListParams{amount=$amount, amountGt=$amountGt, amountLt=$amountLt, cursor=$cursor, customerId=$customerId, dateType=$dateType, dueDate=$dueDate, dueDateWindow=$dueDateWindow, dueDateGt=$dueDateGt, dueDateLt=$dueDateLt, externalCustomerId=$externalCustomerId, invoiceDateGt=$invoiceDateGt, invoiceDateGte=$invoiceDateGte, invoiceDateLt=$invoiceDateLt, invoiceDateLte=$invoiceDateLte, isRecurring=$isRecurring, limit=$limit, status=$status, subscriptionId=$subscriptionId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceMarkPaidParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceMarkPaidParams.kt index 510fbd2bf..e9b4b2ee5 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceMarkPaidParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceMarkPaidParams.kt @@ -545,12 +545,16 @@ private constructor( return true } - return /* spotless:off */ other is Body && paymentReceivedDate == other.paymentReceivedDate && externalId == other.externalId && notes == other.notes && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Body && + paymentReceivedDate == other.paymentReceivedDate && + externalId == other.externalId && + notes == other.notes && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(paymentReceivedDate, externalId, notes, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash(paymentReceivedDate, externalId, notes, additionalProperties) + } override fun hashCode(): Int = hashCode @@ -563,10 +567,15 @@ private constructor( return true } - return /* spotless:off */ other is InvoiceMarkPaidParams && invoiceId == other.invoiceId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return other is InvoiceMarkPaidParams && + invoiceId == other.invoiceId && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(invoiceId, body, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash(invoiceId, body, additionalHeaders, additionalQueryParams) override fun toString() = "InvoiceMarkPaidParams{invoiceId=$invoiceId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoicePayParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoicePayParams.kt index a2829e29a..f5a43a3c0 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoicePayParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoicePayParams.kt @@ -210,10 +210,15 @@ private constructor( return true } - return /* spotless:off */ other is InvoicePayParams && invoiceId == other.invoiceId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return other is InvoicePayParams && + invoiceId == other.invoiceId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(invoiceId, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash(invoiceId, additionalHeaders, additionalQueryParams, additionalBodyProperties) override fun toString() = "InvoicePayParams{invoiceId=$invoiceId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceTiny.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceTiny.kt index fe9aca2eb..5bab311e2 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceTiny.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceTiny.kt @@ -154,12 +154,12 @@ private constructor( return true } - return /* spotless:off */ other is InvoiceTiny && id == other.id && additionalProperties == other.additionalProperties /* spotless:on */ + return other is InvoiceTiny && + id == other.id && + additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(id, additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceUpdateParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceUpdateParams.kt index 922ff203b..03d6a0db1 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceUpdateParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceUpdateParams.kt @@ -390,12 +390,12 @@ private constructor( return true } - return /* spotless:off */ other is Body && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Body && + metadata == other.metadata && + additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(metadata, additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -495,12 +495,10 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -512,10 +510,15 @@ private constructor( return true } - return /* spotless:off */ other is InvoiceUpdateParams && invoiceId == other.invoiceId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return other is InvoiceUpdateParams && + invoiceId == other.invoiceId && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(invoiceId, body, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash(invoiceId, body, additionalHeaders, additionalQueryParams) override fun toString() = "InvoiceUpdateParams{invoiceId=$invoiceId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceVoidParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceVoidParams.kt index 698e19ff8..0a0b2be6d 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceVoidParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceVoidParams.kt @@ -217,10 +217,15 @@ private constructor( return true } - return /* spotless:off */ other is InvoiceVoidParams && invoiceId == other.invoiceId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return other is InvoiceVoidParams && + invoiceId == other.invoiceId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(invoiceId, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash(invoiceId, additionalHeaders, additionalQueryParams, additionalBodyProperties) override fun toString() = "InvoiceVoidParams{invoiceId=$invoiceId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Item.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Item.kt index 42f2b8103..0249ae5f1 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Item.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Item.kt @@ -666,7 +666,7 @@ private constructor( return true } - return /* spotless:off */ other is ExternalConnectionName && value == other.value /* spotless:on */ + return other is ExternalConnectionName && value == other.value } override fun hashCode() = value.hashCode() @@ -679,12 +679,15 @@ private constructor( return true } - return /* spotless:off */ other is ExternalConnection && externalConnectionName == other.externalConnectionName && externalEntityId == other.externalEntityId && additionalProperties == other.additionalProperties /* spotless:on */ + return other is ExternalConnection && + externalConnectionName == other.externalConnectionName && + externalEntityId == other.externalEntityId && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(externalConnectionName, externalEntityId, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash(externalConnectionName, externalEntityId, additionalProperties) + } override fun hashCode(): Int = hashCode @@ -784,12 +787,10 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -801,12 +802,18 @@ private constructor( return true } - return /* spotless:off */ other is Item && id == other.id && createdAt == other.createdAt && externalConnections == other.externalConnections && metadata == other.metadata && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Item && + id == other.id && + createdAt == other.createdAt && + externalConnections == other.externalConnections && + metadata == other.metadata && + name == other.name && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, createdAt, externalConnections, metadata, name, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash(id, createdAt, externalConnections, metadata, name, additionalProperties) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/ItemArchiveParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/ItemArchiveParams.kt index f86d8901e..b290bf41d 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/ItemArchiveParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/ItemArchiveParams.kt @@ -207,10 +207,15 @@ private constructor( return true } - return /* spotless:off */ other is ItemArchiveParams && itemId == other.itemId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return other is ItemArchiveParams && + itemId == other.itemId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(itemId, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash(itemId, additionalHeaders, additionalQueryParams, additionalBodyProperties) override fun toString() = "ItemArchiveParams{itemId=$itemId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/ItemCreateParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/ItemCreateParams.kt index 910cccfbc..6c0150e71 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/ItemCreateParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/ItemCreateParams.kt @@ -453,12 +453,13 @@ private constructor( return true } - return /* spotless:off */ other is Body && name == other.name && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Body && + name == other.name && + metadata == other.metadata && + additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(name, metadata, additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -558,12 +559,10 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -575,10 +574,13 @@ private constructor( return true } - return /* spotless:off */ other is ItemCreateParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return other is ItemCreateParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(body, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) override fun toString() = "ItemCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/ItemFetchParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/ItemFetchParams.kt index 5765f1056..0c82eb745 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/ItemFetchParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/ItemFetchParams.kt @@ -170,10 +170,13 @@ private constructor( return true } - return /* spotless:off */ other is ItemFetchParams && itemId == other.itemId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return other is ItemFetchParams && + itemId == other.itemId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(itemId, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(itemId, additionalHeaders, additionalQueryParams) override fun toString() = "ItemFetchParams{itemId=$itemId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/ItemListPage.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/ItemListPage.kt index 9f427baae..a6f7625e2 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/ItemListPage.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/ItemListPage.kt @@ -119,10 +119,13 @@ private constructor( return true } - return /* spotless:off */ other is ItemListPage && service == other.service && params == other.params && response == other.response /* spotless:on */ + return other is ItemListPage && + service == other.service && + params == other.params && + response == other.response } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, params, response) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(service, params, response) override fun toString() = "ItemListPage{service=$service, params=$params, response=$response}" } diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/ItemListPageAsync.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/ItemListPageAsync.kt index 1bdd94422..6e297d4dd 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/ItemListPageAsync.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/ItemListPageAsync.kt @@ -119,10 +119,13 @@ private constructor( return true } - return /* spotless:off */ other is ItemListPageAsync && service == other.service && params == other.params && response == other.response /* spotless:on */ + return other is ItemListPageAsync && + service == other.service && + params == other.params && + response == other.response } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, params, response) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(service, params, response) override fun toString() = "ItemListPageAsync{service=$service, params=$params, response=$response}" diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/ItemListPageResponse.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/ItemListPageResponse.kt index 35073a67d..71d2063ce 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/ItemListPageResponse.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/ItemListPageResponse.kt @@ -213,12 +213,15 @@ private constructor( return true } - return /* spotless:off */ other is ItemListPageResponse && data == other.data && paginationMetadata == other.paginationMetadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is ItemListPageResponse && + data == other.data && + paginationMetadata == other.paginationMetadata && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(data, paginationMetadata, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash(data, paginationMetadata, additionalProperties) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/ItemListParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/ItemListParams.kt index f01b923af..c6f2cd86b 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/ItemListParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/ItemListParams.kt @@ -195,10 +195,15 @@ private constructor( return true } - return /* spotless:off */ other is ItemListParams && cursor == other.cursor && limit == other.limit && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return other is ItemListParams && + cursor == other.cursor && + limit == other.limit && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(cursor, limit, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash(cursor, limit, additionalHeaders, additionalQueryParams) override fun toString() = "ItemListParams{cursor=$cursor, limit=$limit, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/ItemSlim.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/ItemSlim.kt index a4885ceec..ffa37fdd9 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/ItemSlim.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/ItemSlim.kt @@ -186,12 +186,13 @@ private constructor( return true } - return /* spotless:off */ other is ItemSlim && id == other.id && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ + return other is ItemSlim && + id == other.id && + name == other.name && + additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(id, name, additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/ItemUpdateParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/ItemUpdateParams.kt index 696133f47..854f01c7e 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/ItemUpdateParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/ItemUpdateParams.kt @@ -543,12 +543,16 @@ private constructor( return true } - return /* spotless:off */ other is Body && externalConnections == other.externalConnections && metadata == other.metadata && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Body && + externalConnections == other.externalConnections && + metadata == other.metadata && + name == other.name && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(externalConnections, metadata, name, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash(externalConnections, metadata, name, additionalProperties) + } override fun hashCode(): Int = hashCode @@ -898,7 +902,7 @@ private constructor( return true } - return /* spotless:off */ other is ExternalConnectionName && value == other.value /* spotless:on */ + return other is ExternalConnectionName && value == other.value } override fun hashCode() = value.hashCode() @@ -911,12 +915,15 @@ private constructor( return true } - return /* spotless:off */ other is ExternalConnection && externalConnectionName == other.externalConnectionName && externalEntityId == other.externalEntityId && additionalProperties == other.additionalProperties /* spotless:on */ + return other is ExternalConnection && + externalConnectionName == other.externalConnectionName && + externalEntityId == other.externalEntityId && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(externalConnectionName, externalEntityId, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash(externalConnectionName, externalEntityId, additionalProperties) + } override fun hashCode(): Int = hashCode @@ -1016,12 +1023,10 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1033,10 +1038,15 @@ private constructor( return true } - return /* spotless:off */ other is ItemUpdateParams && itemId == other.itemId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return other is ItemUpdateParams && + itemId == other.itemId && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(itemId, body, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash(itemId, body, additionalHeaders, additionalQueryParams) override fun toString() = "ItemUpdateParams{itemId=$itemId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MatrixConfig.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MatrixConfig.kt index 932687735..03efe2165 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MatrixConfig.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MatrixConfig.kt @@ -277,12 +277,16 @@ private constructor( return true } - return /* spotless:off */ other is MatrixConfig && defaultUnitAmount == other.defaultUnitAmount && dimensions == other.dimensions && matrixValues == other.matrixValues && additionalProperties == other.additionalProperties /* spotless:on */ + return other is MatrixConfig && + defaultUnitAmount == other.defaultUnitAmount && + dimensions == other.dimensions && + matrixValues == other.matrixValues && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(defaultUnitAmount, dimensions, matrixValues, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash(defaultUnitAmount, dimensions, matrixValues, additionalProperties) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MatrixSubLineItem.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MatrixSubLineItem.kt index 286f3280f..a43c4e064 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MatrixSubLineItem.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MatrixSubLineItem.kt @@ -437,7 +437,7 @@ private constructor( return true } - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + return other is Type && value == other.value } override fun hashCode() = value.hashCode() @@ -450,12 +450,19 @@ private constructor( return true } - return /* spotless:off */ other is MatrixSubLineItem && amount == other.amount && grouping == other.grouping && matrixConfig == other.matrixConfig && name == other.name && quantity == other.quantity && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return other is MatrixSubLineItem && + amount == other.amount && + grouping == other.grouping && + matrixConfig == other.matrixConfig && + name == other.name && + quantity == other.quantity && + type == other.type && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(amount, grouping, matrixConfig, name, quantity, type, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash(amount, grouping, matrixConfig, name, quantity, type, additionalProperties) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MatrixValue.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MatrixValue.kt index 19ebff2d4..8b8a473b6 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MatrixValue.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MatrixValue.kt @@ -224,12 +224,15 @@ private constructor( return true } - return /* spotless:off */ other is MatrixValue && dimensionValues == other.dimensionValues && unitAmount == other.unitAmount && additionalProperties == other.additionalProperties /* spotless:on */ + return other is MatrixValue && + dimensionValues == other.dimensionValues && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(dimensionValues, unitAmount, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash(dimensionValues, unitAmount, additionalProperties) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MatrixWithAllocationConfig.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MatrixWithAllocationConfig.kt index 303d93f9e..588a20d74 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MatrixWithAllocationConfig.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MatrixWithAllocationConfig.kt @@ -315,12 +315,17 @@ private constructor( return true } - return /* spotless:off */ other is MatrixWithAllocationConfig && allocation == other.allocation && defaultUnitAmount == other.defaultUnitAmount && dimensions == other.dimensions && matrixValues == other.matrixValues && additionalProperties == other.additionalProperties /* spotless:on */ + return other is MatrixWithAllocationConfig && + allocation == other.allocation && + defaultUnitAmount == other.defaultUnitAmount && + dimensions == other.dimensions && + matrixValues == other.matrixValues && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(allocation, defaultUnitAmount, dimensions, matrixValues, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash(allocation, defaultUnitAmount, dimensions, matrixValues, additionalProperties) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Maximum.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Maximum.kt index 423b60087..6c3f797f0 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Maximum.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Maximum.kt @@ -286,12 +286,16 @@ private constructor( return true } - return /* spotless:off */ other is Maximum && appliesToPriceIds == other.appliesToPriceIds && filters == other.filters && maximumAmount == other.maximumAmount && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Maximum && + appliesToPriceIds == other.appliesToPriceIds && + filters == other.filters && + maximumAmount == other.maximumAmount && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(appliesToPriceIds, filters, maximumAmount, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash(appliesToPriceIds, filters, maximumAmount, additionalProperties) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MaximumInterval.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MaximumInterval.kt index c5c74cfff..024f2110f 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MaximumInterval.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MaximumInterval.kt @@ -364,12 +364,25 @@ private constructor( return true } - return /* spotless:off */ other is MaximumInterval && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && endDate == other.endDate && filters == other.filters && maximumAmount == other.maximumAmount && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ + return other is MaximumInterval && + appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && + endDate == other.endDate && + filters == other.filters && + maximumAmount == other.maximumAmount && + startDate == other.startDate && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(appliesToPriceIntervalIds, endDate, filters, maximumAmount, startDate, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + appliesToPriceIntervalIds, + endDate, + filters, + maximumAmount, + startDate, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MetricCreateParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MetricCreateParams.kt index dab95c7e6..ee54ab4d3 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MetricCreateParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MetricCreateParams.kt @@ -669,12 +669,18 @@ private constructor( return true } - return /* spotless:off */ other is Body && description == other.description && itemId == other.itemId && name == other.name && sql == other.sql && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Body && + description == other.description && + itemId == other.itemId && + name == other.name && + sql == other.sql && + metadata == other.metadata && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(description, itemId, name, sql, metadata, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash(description, itemId, name, sql, metadata, additionalProperties) + } override fun hashCode(): Int = hashCode @@ -774,12 +780,10 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -791,10 +795,13 @@ private constructor( return true } - return /* spotless:off */ other is MetricCreateParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return other is MetricCreateParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(body, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) override fun toString() = "MetricCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MetricFetchParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MetricFetchParams.kt index 697769d5d..8d7795d10 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MetricFetchParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MetricFetchParams.kt @@ -173,10 +173,13 @@ private constructor( return true } - return /* spotless:off */ other is MetricFetchParams && metricId == other.metricId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return other is MetricFetchParams && + metricId == other.metricId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(metricId, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(metricId, additionalHeaders, additionalQueryParams) override fun toString() = "MetricFetchParams{metricId=$metricId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MetricListPage.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MetricListPage.kt index 03d7a1a97..4131e61f0 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MetricListPage.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MetricListPage.kt @@ -119,10 +119,13 @@ private constructor( return true } - return /* spotless:off */ other is MetricListPage && service == other.service && params == other.params && response == other.response /* spotless:on */ + return other is MetricListPage && + service == other.service && + params == other.params && + response == other.response } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, params, response) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(service, params, response) override fun toString() = "MetricListPage{service=$service, params=$params, response=$response}" } diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MetricListPageAsync.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MetricListPageAsync.kt index b28125cfd..787683c1e 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MetricListPageAsync.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MetricListPageAsync.kt @@ -119,10 +119,13 @@ private constructor( return true } - return /* spotless:off */ other is MetricListPageAsync && service == other.service && params == other.params && response == other.response /* spotless:on */ + return other is MetricListPageAsync && + service == other.service && + params == other.params && + response == other.response } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, params, response) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(service, params, response) override fun toString() = "MetricListPageAsync{service=$service, params=$params, response=$response}" diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MetricListPageResponse.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MetricListPageResponse.kt index d1a1f0b53..ccccf45aa 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MetricListPageResponse.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MetricListPageResponse.kt @@ -216,12 +216,15 @@ private constructor( return true } - return /* spotless:off */ other is MetricListPageResponse && data == other.data && paginationMetadata == other.paginationMetadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is MetricListPageResponse && + data == other.data && + paginationMetadata == other.paginationMetadata && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(data, paginationMetadata, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash(data, paginationMetadata, additionalProperties) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MetricListParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MetricListParams.kt index 64cc64834..67b5a9301 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MetricListParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MetricListParams.kt @@ -249,10 +249,28 @@ private constructor( return true } - return /* spotless:off */ other is MetricListParams && createdAtGt == other.createdAtGt && createdAtGte == other.createdAtGte && createdAtLt == other.createdAtLt && createdAtLte == other.createdAtLte && cursor == other.cursor && limit == other.limit && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return other is MetricListParams && + createdAtGt == other.createdAtGt && + createdAtGte == other.createdAtGte && + createdAtLt == other.createdAtLt && + createdAtLte == other.createdAtLte && + cursor == other.cursor && + limit == other.limit && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(createdAtGt, createdAtGte, createdAtLt, createdAtLte, cursor, limit, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash( + createdAtGt, + createdAtGte, + createdAtLt, + createdAtLte, + cursor, + limit, + additionalHeaders, + additionalQueryParams, + ) override fun toString() = "MetricListParams{createdAtGt=$createdAtGt, createdAtGte=$createdAtGte, createdAtLt=$createdAtLt, createdAtLte=$createdAtLte, cursor=$cursor, limit=$limit, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MetricUpdateParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MetricUpdateParams.kt index dc46caa59..2cf32a02c 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MetricUpdateParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MetricUpdateParams.kt @@ -386,12 +386,12 @@ private constructor( return true } - return /* spotless:off */ other is Body && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Body && + metadata == other.metadata && + additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(metadata, additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -491,12 +491,10 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -508,10 +506,15 @@ private constructor( return true } - return /* spotless:off */ other is MetricUpdateParams && metricId == other.metricId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return other is MetricUpdateParams && + metricId == other.metricId && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(metricId, body, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash(metricId, body, additionalHeaders, additionalQueryParams) override fun toString() = "MetricUpdateParams{metricId=$metricId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Minimum.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Minimum.kt index a8b25ca5d..e6c1a9e84 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Minimum.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Minimum.kt @@ -286,12 +286,16 @@ private constructor( return true } - return /* spotless:off */ other is Minimum && appliesToPriceIds == other.appliesToPriceIds && filters == other.filters && minimumAmount == other.minimumAmount && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Minimum && + appliesToPriceIds == other.appliesToPriceIds && + filters == other.filters && + minimumAmount == other.minimumAmount && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(appliesToPriceIds, filters, minimumAmount, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash(appliesToPriceIds, filters, minimumAmount, additionalProperties) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MinimumInterval.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MinimumInterval.kt index 41d3eba0b..4f6929321 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MinimumInterval.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MinimumInterval.kt @@ -364,12 +364,25 @@ private constructor( return true } - return /* spotless:off */ other is MinimumInterval && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && endDate == other.endDate && filters == other.filters && minimumAmount == other.minimumAmount && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ + return other is MinimumInterval && + appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && + endDate == other.endDate && + filters == other.filters && + minimumAmount == other.minimumAmount && + startDate == other.startDate && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(appliesToPriceIntervalIds, endDate, filters, minimumAmount, startDate, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + appliesToPriceIntervalIds, + endDate, + filters, + minimumAmount, + startDate, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MonetaryAmountDiscountAdjustment.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MonetaryAmountDiscountAdjustment.kt index 6a2a36ca6..26ffd6e64 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MonetaryAmountDiscountAdjustment.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MonetaryAmountDiscountAdjustment.kt @@ -647,7 +647,7 @@ private constructor( return true } - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ + return other is AdjustmentType && value == other.value } override fun hashCode() = value.hashCode() @@ -660,12 +660,33 @@ private constructor( return true } - return /* spotless:off */ other is MonetaryAmountDiscountAdjustment && id == other.id && adjustmentType == other.adjustmentType && amount == other.amount && amountDiscount == other.amountDiscount && appliesToPriceIds == other.appliesToPriceIds && filters == other.filters && isInvoiceLevel == other.isInvoiceLevel && reason == other.reason && replacesAdjustmentId == other.replacesAdjustmentId && additionalProperties == other.additionalProperties /* spotless:on */ + return other is MonetaryAmountDiscountAdjustment && + id == other.id && + adjustmentType == other.adjustmentType && + amount == other.amount && + amountDiscount == other.amountDiscount && + appliesToPriceIds == other.appliesToPriceIds && + filters == other.filters && + isInvoiceLevel == other.isInvoiceLevel && + reason == other.reason && + replacesAdjustmentId == other.replacesAdjustmentId && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, adjustmentType, amount, amountDiscount, appliesToPriceIds, filters, isInvoiceLevel, reason, replacesAdjustmentId, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + id, + adjustmentType, + amount, + amountDiscount, + appliesToPriceIds, + filters, + isInvoiceLevel, + reason, + replacesAdjustmentId, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MonetaryMaximumAdjustment.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MonetaryMaximumAdjustment.kt index 40e9abcb9..63e2620bb 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MonetaryMaximumAdjustment.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MonetaryMaximumAdjustment.kt @@ -644,7 +644,7 @@ private constructor( return true } - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ + return other is AdjustmentType && value == other.value } override fun hashCode() = value.hashCode() @@ -657,12 +657,33 @@ private constructor( return true } - return /* spotless:off */ other is MonetaryMaximumAdjustment && id == other.id && adjustmentType == other.adjustmentType && amount == other.amount && appliesToPriceIds == other.appliesToPriceIds && filters == other.filters && isInvoiceLevel == other.isInvoiceLevel && maximumAmount == other.maximumAmount && reason == other.reason && replacesAdjustmentId == other.replacesAdjustmentId && additionalProperties == other.additionalProperties /* spotless:on */ + return other is MonetaryMaximumAdjustment && + id == other.id && + adjustmentType == other.adjustmentType && + amount == other.amount && + appliesToPriceIds == other.appliesToPriceIds && + filters == other.filters && + isInvoiceLevel == other.isInvoiceLevel && + maximumAmount == other.maximumAmount && + reason == other.reason && + replacesAdjustmentId == other.replacesAdjustmentId && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, adjustmentType, amount, appliesToPriceIds, filters, isInvoiceLevel, maximumAmount, reason, replacesAdjustmentId, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + id, + adjustmentType, + amount, + appliesToPriceIds, + filters, + isInvoiceLevel, + maximumAmount, + reason, + replacesAdjustmentId, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MonetaryMinimumAdjustment.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MonetaryMinimumAdjustment.kt index aafbac05b..cc8a75af1 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MonetaryMinimumAdjustment.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MonetaryMinimumAdjustment.kt @@ -680,7 +680,7 @@ private constructor( return true } - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ + return other is AdjustmentType && value == other.value } override fun hashCode() = value.hashCode() @@ -693,12 +693,35 @@ private constructor( return true } - return /* spotless:off */ other is MonetaryMinimumAdjustment && id == other.id && adjustmentType == other.adjustmentType && amount == other.amount && appliesToPriceIds == other.appliesToPriceIds && filters == other.filters && isInvoiceLevel == other.isInvoiceLevel && itemId == other.itemId && minimumAmount == other.minimumAmount && reason == other.reason && replacesAdjustmentId == other.replacesAdjustmentId && additionalProperties == other.additionalProperties /* spotless:on */ + return other is MonetaryMinimumAdjustment && + id == other.id && + adjustmentType == other.adjustmentType && + amount == other.amount && + appliesToPriceIds == other.appliesToPriceIds && + filters == other.filters && + isInvoiceLevel == other.isInvoiceLevel && + itemId == other.itemId && + minimumAmount == other.minimumAmount && + reason == other.reason && + replacesAdjustmentId == other.replacesAdjustmentId && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, adjustmentType, amount, appliesToPriceIds, filters, isInvoiceLevel, itemId, minimumAmount, reason, replacesAdjustmentId, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + id, + adjustmentType, + amount, + appliesToPriceIds, + filters, + isInvoiceLevel, + itemId, + minimumAmount, + reason, + replacesAdjustmentId, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MonetaryPercentageDiscountAdjustment.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MonetaryPercentageDiscountAdjustment.kt index 13afbfa84..bb33573a4 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MonetaryPercentageDiscountAdjustment.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MonetaryPercentageDiscountAdjustment.kt @@ -650,7 +650,7 @@ private constructor( return true } - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ + return other is AdjustmentType && value == other.value } override fun hashCode() = value.hashCode() @@ -663,12 +663,33 @@ private constructor( return true } - return /* spotless:off */ other is MonetaryPercentageDiscountAdjustment && id == other.id && adjustmentType == other.adjustmentType && amount == other.amount && appliesToPriceIds == other.appliesToPriceIds && filters == other.filters && isInvoiceLevel == other.isInvoiceLevel && percentageDiscount == other.percentageDiscount && reason == other.reason && replacesAdjustmentId == other.replacesAdjustmentId && additionalProperties == other.additionalProperties /* spotless:on */ + return other is MonetaryPercentageDiscountAdjustment && + id == other.id && + adjustmentType == other.adjustmentType && + amount == other.amount && + appliesToPriceIds == other.appliesToPriceIds && + filters == other.filters && + isInvoiceLevel == other.isInvoiceLevel && + percentageDiscount == other.percentageDiscount && + reason == other.reason && + replacesAdjustmentId == other.replacesAdjustmentId && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, adjustmentType, amount, appliesToPriceIds, filters, isInvoiceLevel, percentageDiscount, reason, replacesAdjustmentId, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + id, + adjustmentType, + amount, + appliesToPriceIds, + filters, + isInvoiceLevel, + percentageDiscount, + reason, + replacesAdjustmentId, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MonetaryUsageDiscountAdjustment.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MonetaryUsageDiscountAdjustment.kt index c6aef48d8..2b63e1d1b 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MonetaryUsageDiscountAdjustment.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MonetaryUsageDiscountAdjustment.kt @@ -647,7 +647,7 @@ private constructor( return true } - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ + return other is AdjustmentType && value == other.value } override fun hashCode() = value.hashCode() @@ -660,12 +660,33 @@ private constructor( return true } - return /* spotless:off */ other is MonetaryUsageDiscountAdjustment && id == other.id && adjustmentType == other.adjustmentType && amount == other.amount && appliesToPriceIds == other.appliesToPriceIds && filters == other.filters && isInvoiceLevel == other.isInvoiceLevel && reason == other.reason && replacesAdjustmentId == other.replacesAdjustmentId && usageDiscount == other.usageDiscount && additionalProperties == other.additionalProperties /* spotless:on */ + return other is MonetaryUsageDiscountAdjustment && + id == other.id && + adjustmentType == other.adjustmentType && + amount == other.amount && + appliesToPriceIds == other.appliesToPriceIds && + filters == other.filters && + isInvoiceLevel == other.isInvoiceLevel && + reason == other.reason && + replacesAdjustmentId == other.replacesAdjustmentId && + usageDiscount == other.usageDiscount && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, adjustmentType, amount, appliesToPriceIds, filters, isInvoiceLevel, reason, replacesAdjustmentId, usageDiscount, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + id, + adjustmentType, + amount, + appliesToPriceIds, + filters, + isInvoiceLevel, + reason, + replacesAdjustmentId, + usageDiscount, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MutatedSubscription.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MutatedSubscription.kt index acc7e01f3..3392c7225 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MutatedSubscription.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MutatedSubscription.kt @@ -1628,10 +1628,13 @@ private constructor( return true } - return /* spotless:off */ other is DiscountInterval && amount == other.amount && percentage == other.percentage && usage == other.usage /* spotless:on */ + return other is DiscountInterval && + amount == other.amount && + percentage == other.percentage && + usage == other.usage } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(amount, percentage, usage) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(amount, percentage, usage) override fun toString(): String = when { @@ -1817,12 +1820,10 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1951,7 +1952,7 @@ private constructor( return true } - return /* spotless:off */ other is Status && value == other.value /* spotless:on */ + return other is Status && value == other.value } override fun hashCode() = value.hashCode() @@ -1964,12 +1965,71 @@ private constructor( return true } - return /* spotless:off */ other is MutatedSubscription && id == other.id && activePlanPhaseOrder == other.activePlanPhaseOrder && adjustmentIntervals == other.adjustmentIntervals && autoCollection == other.autoCollection && billingCycleAnchorConfiguration == other.billingCycleAnchorConfiguration && billingCycleDay == other.billingCycleDay && createdAt == other.createdAt && currentBillingPeriodEndDate == other.currentBillingPeriodEndDate && currentBillingPeriodStartDate == other.currentBillingPeriodStartDate && customer == other.customer && defaultInvoiceMemo == other.defaultInvoiceMemo && discountIntervals == other.discountIntervals && endDate == other.endDate && fixedFeeQuantitySchedule == other.fixedFeeQuantitySchedule && invoicingThreshold == other.invoicingThreshold && maximumIntervals == other.maximumIntervals && metadata == other.metadata && minimumIntervals == other.minimumIntervals && name == other.name && netTerms == other.netTerms && pendingSubscriptionChange == other.pendingSubscriptionChange && plan == other.plan && priceIntervals == other.priceIntervals && redeemedCoupon == other.redeemedCoupon && startDate == other.startDate && status == other.status && trialInfo == other.trialInfo && changedResources == other.changedResources && additionalProperties == other.additionalProperties /* spotless:on */ + return other is MutatedSubscription && + id == other.id && + activePlanPhaseOrder == other.activePlanPhaseOrder && + adjustmentIntervals == other.adjustmentIntervals && + autoCollection == other.autoCollection && + billingCycleAnchorConfiguration == other.billingCycleAnchorConfiguration && + billingCycleDay == other.billingCycleDay && + createdAt == other.createdAt && + currentBillingPeriodEndDate == other.currentBillingPeriodEndDate && + currentBillingPeriodStartDate == other.currentBillingPeriodStartDate && + customer == other.customer && + defaultInvoiceMemo == other.defaultInvoiceMemo && + discountIntervals == other.discountIntervals && + endDate == other.endDate && + fixedFeeQuantitySchedule == other.fixedFeeQuantitySchedule && + invoicingThreshold == other.invoicingThreshold && + maximumIntervals == other.maximumIntervals && + metadata == other.metadata && + minimumIntervals == other.minimumIntervals && + name == other.name && + netTerms == other.netTerms && + pendingSubscriptionChange == other.pendingSubscriptionChange && + plan == other.plan && + priceIntervals == other.priceIntervals && + redeemedCoupon == other.redeemedCoupon && + startDate == other.startDate && + status == other.status && + trialInfo == other.trialInfo && + changedResources == other.changedResources && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, activePlanPhaseOrder, adjustmentIntervals, autoCollection, billingCycleAnchorConfiguration, billingCycleDay, createdAt, currentBillingPeriodEndDate, currentBillingPeriodStartDate, customer, defaultInvoiceMemo, discountIntervals, endDate, fixedFeeQuantitySchedule, invoicingThreshold, maximumIntervals, metadata, minimumIntervals, name, netTerms, pendingSubscriptionChange, plan, priceIntervals, redeemedCoupon, startDate, status, trialInfo, changedResources, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + id, + activePlanPhaseOrder, + adjustmentIntervals, + autoCollection, + billingCycleAnchorConfiguration, + billingCycleDay, + createdAt, + currentBillingPeriodEndDate, + currentBillingPeriodStartDate, + customer, + defaultInvoiceMemo, + discountIntervals, + endDate, + fixedFeeQuantitySchedule, + invoicingThreshold, + maximumIntervals, + metadata, + minimumIntervals, + name, + netTerms, + pendingSubscriptionChange, + plan, + priceIntervals, + redeemedCoupon, + startDate, + status, + trialInfo, + changedResources, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewAccountingSyncConfiguration.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewAccountingSyncConfiguration.kt index 54752ed21..5268983e0 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewAccountingSyncConfiguration.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewAccountingSyncConfiguration.kt @@ -208,12 +208,15 @@ private constructor( return true } - return /* spotless:off */ other is NewAccountingSyncConfiguration && accountingProviders == other.accountingProviders && excluded == other.excluded && additionalProperties == other.additionalProperties /* spotless:on */ + return other is NewAccountingSyncConfiguration && + accountingProviders == other.accountingProviders && + excluded == other.excluded && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(accountingProviders, excluded, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash(accountingProviders, excluded, additionalProperties) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewAllocationPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewAllocationPrice.kt index d9c14a4bb..bb8b5808d 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewAllocationPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewAllocationPrice.kt @@ -459,7 +459,7 @@ private constructor( return true } - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + return other is Cadence && value == other.value } override fun hashCode() = value.hashCode() @@ -472,12 +472,25 @@ private constructor( return true } - return /* spotless:off */ other is NewAllocationPrice && amount == other.amount && cadence == other.cadence && currency == other.currency && customExpiration == other.customExpiration && expiresAtEndOfCadence == other.expiresAtEndOfCadence && additionalProperties == other.additionalProperties /* spotless:on */ + return other is NewAllocationPrice && + amount == other.amount && + cadence == other.cadence && + currency == other.currency && + customExpiration == other.customExpiration && + expiresAtEndOfCadence == other.expiresAtEndOfCadence && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(amount, cadence, currency, customExpiration, expiresAtEndOfCadence, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + amount, + cadence, + currency, + customExpiration, + expiresAtEndOfCadence, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewAmountDiscount.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewAmountDiscount.kt index 8c31385b8..c384b3181 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewAmountDiscount.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewAmountDiscount.kt @@ -639,7 +639,7 @@ private constructor( return true } - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ + return other is AdjustmentType && value == other.value } override fun hashCode() = value.hashCode() @@ -758,7 +758,7 @@ private constructor( return true } - return /* spotless:off */ other is AppliesToAll && value == other.value /* spotless:on */ + return other is AppliesToAll && value == other.value } override fun hashCode() = value.hashCode() @@ -903,7 +903,7 @@ private constructor( return true } - return /* spotless:off */ other is PriceType && value == other.value /* spotless:on */ + return other is PriceType && value == other.value } override fun hashCode() = value.hashCode() @@ -916,12 +916,33 @@ private constructor( return true } - return /* spotless:off */ other is NewAmountDiscount && adjustmentType == other.adjustmentType && amountDiscount == other.amountDiscount && appliesToAll == other.appliesToAll && appliesToItemIds == other.appliesToItemIds && appliesToPriceIds == other.appliesToPriceIds && currency == other.currency && filters == other.filters && isInvoiceLevel == other.isInvoiceLevel && priceType == other.priceType && additionalProperties == other.additionalProperties /* spotless:on */ + return other is NewAmountDiscount && + adjustmentType == other.adjustmentType && + amountDiscount == other.amountDiscount && + appliesToAll == other.appliesToAll && + appliesToItemIds == other.appliesToItemIds && + appliesToPriceIds == other.appliesToPriceIds && + currency == other.currency && + filters == other.filters && + isInvoiceLevel == other.isInvoiceLevel && + priceType == other.priceType && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(adjustmentType, amountDiscount, appliesToAll, appliesToItemIds, appliesToPriceIds, currency, filters, isInvoiceLevel, priceType, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + adjustmentType, + amountDiscount, + appliesToAll, + appliesToItemIds, + appliesToPriceIds, + currency, + filters, + isInvoiceLevel, + priceType, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewAvalaraTaxConfiguration.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewAvalaraTaxConfiguration.kt index 624a24029..1ae5e7ea8 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewAvalaraTaxConfiguration.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewAvalaraTaxConfiguration.kt @@ -345,7 +345,7 @@ private constructor( return true } - return /* spotless:off */ other is TaxProvider && value == other.value /* spotless:on */ + return other is TaxProvider && value == other.value } override fun hashCode() = value.hashCode() @@ -358,12 +358,16 @@ private constructor( return true } - return /* spotless:off */ other is NewAvalaraTaxConfiguration && taxExempt == other.taxExempt && taxProvider == other.taxProvider && taxExemptionCode == other.taxExemptionCode && additionalProperties == other.additionalProperties /* spotless:on */ + return other is NewAvalaraTaxConfiguration && + taxExempt == other.taxExempt && + taxProvider == other.taxProvider && + taxExemptionCode == other.taxExemptionCode && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(taxExempt, taxProvider, taxExemptionCode, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash(taxExempt, taxProvider, taxExemptionCode, additionalProperties) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewBillingCycleConfiguration.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewBillingCycleConfiguration.kt index ba9d80876..7ddb38a6b 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewBillingCycleConfiguration.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewBillingCycleConfiguration.kt @@ -315,7 +315,7 @@ private constructor( return true } - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ + return other is DurationUnit && value == other.value } override fun hashCode() = value.hashCode() @@ -328,12 +328,13 @@ private constructor( return true } - return /* spotless:off */ other is NewBillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ + return other is NewBillingCycleConfiguration && + duration == other.duration && + durationUnit == other.durationUnit && + additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewDimensionalPriceConfiguration.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewDimensionalPriceConfiguration.kt index 8217d528d..c83f14fcd 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewDimensionalPriceConfiguration.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewDimensionalPriceConfiguration.kt @@ -277,12 +277,21 @@ private constructor( return true } - return /* spotless:off */ other is NewDimensionalPriceConfiguration && dimensionValues == other.dimensionValues && dimensionalPriceGroupId == other.dimensionalPriceGroupId && externalDimensionalPriceGroupId == other.externalDimensionalPriceGroupId && additionalProperties == other.additionalProperties /* spotless:on */ + return other is NewDimensionalPriceConfiguration && + dimensionValues == other.dimensionValues && + dimensionalPriceGroupId == other.dimensionalPriceGroupId && + externalDimensionalPriceGroupId == other.externalDimensionalPriceGroupId && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(dimensionValues, dimensionalPriceGroupId, externalDimensionalPriceGroupId, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + dimensionValues, + dimensionalPriceGroupId, + externalDimensionalPriceGroupId, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingBpsPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingBpsPrice.kt index 28a6d0f00..8bb3ecb21 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingBpsPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingBpsPrice.kt @@ -1044,7 +1044,7 @@ private constructor( return true } - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + return other is Cadence && value == other.value } override fun hashCode() = value.hashCode() @@ -1164,7 +1164,7 @@ private constructor( return true } - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + return other is ModelType && value == other.value } override fun hashCode() = value.hashCode() @@ -1254,10 +1254,10 @@ private constructor( return true } - return /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ + return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(unit, tiered) override fun toString(): String = when { @@ -1433,12 +1433,10 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1450,12 +1448,49 @@ private constructor( return true } - return /* spotless:off */ other is NewFloatingBpsPrice && bpsConfig == other.bpsConfig && cadence == other.cadence && currency == other.currency && itemId == other.itemId && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && conversionRateConfig == other.conversionRateConfig && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is NewFloatingBpsPrice && + bpsConfig == other.bpsConfig && + cadence == other.cadence && + currency == other.currency && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(bpsConfig, cadence, currency, itemId, modelType, name, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, conversionRateConfig, dimensionalPriceConfiguration, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + bpsConfig, + cadence, + currency, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingBulkBpsPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingBulkBpsPrice.kt index 3fb542240..12e38ee2d 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingBulkBpsPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingBulkBpsPrice.kt @@ -1048,7 +1048,7 @@ private constructor( return true } - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + return other is Cadence && value == other.value } override fun hashCode() = value.hashCode() @@ -1168,7 +1168,7 @@ private constructor( return true } - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + return other is ModelType && value == other.value } override fun hashCode() = value.hashCode() @@ -1258,10 +1258,10 @@ private constructor( return true } - return /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ + return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(unit, tiered) override fun toString(): String = when { @@ -1437,12 +1437,10 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1454,12 +1452,49 @@ private constructor( return true } - return /* spotless:off */ other is NewFloatingBulkBpsPrice && bulkBpsConfig == other.bulkBpsConfig && cadence == other.cadence && currency == other.currency && itemId == other.itemId && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && conversionRateConfig == other.conversionRateConfig && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is NewFloatingBulkBpsPrice && + bulkBpsConfig == other.bulkBpsConfig && + cadence == other.cadence && + currency == other.currency && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(bulkBpsConfig, cadence, currency, itemId, modelType, name, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, conversionRateConfig, dimensionalPriceConfiguration, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + bulkBpsConfig, + cadence, + currency, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingBulkPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingBulkPrice.kt index f74a94ee1..79f76a669 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingBulkPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingBulkPrice.kt @@ -1046,7 +1046,7 @@ private constructor( return true } - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + return other is Cadence && value == other.value } override fun hashCode() = value.hashCode() @@ -1166,7 +1166,7 @@ private constructor( return true } - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + return other is ModelType && value == other.value } override fun hashCode() = value.hashCode() @@ -1256,10 +1256,10 @@ private constructor( return true } - return /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ + return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(unit, tiered) override fun toString(): String = when { @@ -1435,12 +1435,10 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1452,12 +1450,49 @@ private constructor( return true } - return /* spotless:off */ other is NewFloatingBulkPrice && bulkConfig == other.bulkConfig && cadence == other.cadence && currency == other.currency && itemId == other.itemId && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && conversionRateConfig == other.conversionRateConfig && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is NewFloatingBulkPrice && + bulkConfig == other.bulkConfig && + cadence == other.cadence && + currency == other.currency && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(bulkConfig, cadence, currency, itemId, modelType, name, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, conversionRateConfig, dimensionalPriceConfiguration, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + bulkConfig, + cadence, + currency, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingBulkWithProrationPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingBulkWithProrationPrice.kt index 582cd8575..605202314 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingBulkWithProrationPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingBulkWithProrationPrice.kt @@ -1007,12 +1007,11 @@ private constructor( return true } - return /* spotless:off */ other is BulkWithProrationConfig && additionalProperties == other.additionalProperties /* spotless:on */ + return other is BulkWithProrationConfig && + additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1161,7 +1160,7 @@ private constructor( return true } - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + return other is Cadence && value == other.value } override fun hashCode() = value.hashCode() @@ -1281,7 +1280,7 @@ private constructor( return true } - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + return other is ModelType && value == other.value } override fun hashCode() = value.hashCode() @@ -1371,10 +1370,10 @@ private constructor( return true } - return /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ + return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(unit, tiered) override fun toString(): String = when { @@ -1550,12 +1549,10 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1567,12 +1564,49 @@ private constructor( return true } - return /* spotless:off */ other is NewFloatingBulkWithProrationPrice && bulkWithProrationConfig == other.bulkWithProrationConfig && cadence == other.cadence && currency == other.currency && itemId == other.itemId && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && conversionRateConfig == other.conversionRateConfig && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is NewFloatingBulkWithProrationPrice && + bulkWithProrationConfig == other.bulkWithProrationConfig && + cadence == other.cadence && + currency == other.currency && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(bulkWithProrationConfig, cadence, currency, itemId, modelType, name, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, conversionRateConfig, dimensionalPriceConfiguration, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + bulkWithProrationConfig, + cadence, + currency, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingCumulativeGroupedBulkPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingCumulativeGroupedBulkPrice.kt index 0b53ff59f..7d109ab50 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingCumulativeGroupedBulkPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingCumulativeGroupedBulkPrice.kt @@ -1060,7 +1060,7 @@ private constructor( return true } - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + return other is Cadence && value == other.value } override fun hashCode() = value.hashCode() @@ -1160,12 +1160,11 @@ private constructor( return true } - return /* spotless:off */ other is CumulativeGroupedBulkConfig && additionalProperties == other.additionalProperties /* spotless:on */ + return other is CumulativeGroupedBulkConfig && + additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1285,7 +1284,7 @@ private constructor( return true } - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + return other is ModelType && value == other.value } override fun hashCode() = value.hashCode() @@ -1375,10 +1374,10 @@ private constructor( return true } - return /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ + return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(unit, tiered) override fun toString(): String = when { @@ -1554,12 +1553,10 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1571,12 +1568,49 @@ private constructor( return true } - return /* spotless:off */ other is NewFloatingCumulativeGroupedBulkPrice && cadence == other.cadence && cumulativeGroupedBulkConfig == other.cumulativeGroupedBulkConfig && currency == other.currency && itemId == other.itemId && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && conversionRateConfig == other.conversionRateConfig && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is NewFloatingCumulativeGroupedBulkPrice && + cadence == other.cadence && + cumulativeGroupedBulkConfig == other.cumulativeGroupedBulkConfig && + currency == other.currency && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, cumulativeGroupedBulkConfig, currency, itemId, modelType, name, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, conversionRateConfig, dimensionalPriceConfiguration, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + cadence, + cumulativeGroupedBulkConfig, + currency, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingGroupedAllocationPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingGroupedAllocationPrice.kt index 7b811d709..58db54a70 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingGroupedAllocationPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingGroupedAllocationPrice.kt @@ -1058,7 +1058,7 @@ private constructor( return true } - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + return other is Cadence && value == other.value } override fun hashCode() = value.hashCode() @@ -1156,12 +1156,11 @@ private constructor( return true } - return /* spotless:off */ other is GroupedAllocationConfig && additionalProperties == other.additionalProperties /* spotless:on */ + return other is GroupedAllocationConfig && + additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1281,7 +1280,7 @@ private constructor( return true } - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + return other is ModelType && value == other.value } override fun hashCode() = value.hashCode() @@ -1371,10 +1370,10 @@ private constructor( return true } - return /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ + return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(unit, tiered) override fun toString(): String = when { @@ -1550,12 +1549,10 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1567,12 +1564,49 @@ private constructor( return true } - return /* spotless:off */ other is NewFloatingGroupedAllocationPrice && cadence == other.cadence && currency == other.currency && groupedAllocationConfig == other.groupedAllocationConfig && itemId == other.itemId && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && conversionRateConfig == other.conversionRateConfig && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is NewFloatingGroupedAllocationPrice && + cadence == other.cadence && + currency == other.currency && + groupedAllocationConfig == other.groupedAllocationConfig && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, currency, groupedAllocationConfig, itemId, modelType, name, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, conversionRateConfig, dimensionalPriceConfiguration, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + cadence, + currency, + groupedAllocationConfig, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingGroupedTieredPackagePrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingGroupedTieredPackagePrice.kt index ef90ef15b..1459230ba 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingGroupedTieredPackagePrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingGroupedTieredPackagePrice.kt @@ -1060,7 +1060,7 @@ private constructor( return true } - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + return other is Cadence && value == other.value } override fun hashCode() = value.hashCode() @@ -1160,12 +1160,11 @@ private constructor( return true } - return /* spotless:off */ other is GroupedTieredPackageConfig && additionalProperties == other.additionalProperties /* spotless:on */ + return other is GroupedTieredPackageConfig && + additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1285,7 +1284,7 @@ private constructor( return true } - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + return other is ModelType && value == other.value } override fun hashCode() = value.hashCode() @@ -1375,10 +1374,10 @@ private constructor( return true } - return /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ + return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(unit, tiered) override fun toString(): String = when { @@ -1554,12 +1553,10 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1571,12 +1568,49 @@ private constructor( return true } - return /* spotless:off */ other is NewFloatingGroupedTieredPackagePrice && cadence == other.cadence && currency == other.currency && groupedTieredPackageConfig == other.groupedTieredPackageConfig && itemId == other.itemId && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && conversionRateConfig == other.conversionRateConfig && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is NewFloatingGroupedTieredPackagePrice && + cadence == other.cadence && + currency == other.currency && + groupedTieredPackageConfig == other.groupedTieredPackageConfig && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, currency, groupedTieredPackageConfig, itemId, modelType, name, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, conversionRateConfig, dimensionalPriceConfiguration, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + cadence, + currency, + groupedTieredPackageConfig, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingGroupedTieredPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingGroupedTieredPrice.kt index e5124542b..439ad9232 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingGroupedTieredPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingGroupedTieredPrice.kt @@ -1053,7 +1053,7 @@ private constructor( return true } - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + return other is Cadence && value == other.value } override fun hashCode() = value.hashCode() @@ -1149,12 +1149,11 @@ private constructor( return true } - return /* spotless:off */ other is GroupedTieredConfig && additionalProperties == other.additionalProperties /* spotless:on */ + return other is GroupedTieredConfig && + additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1273,7 +1272,7 @@ private constructor( return true } - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + return other is ModelType && value == other.value } override fun hashCode() = value.hashCode() @@ -1363,10 +1362,10 @@ private constructor( return true } - return /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ + return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(unit, tiered) override fun toString(): String = when { @@ -1542,12 +1541,10 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1559,12 +1556,49 @@ private constructor( return true } - return /* spotless:off */ other is NewFloatingGroupedTieredPrice && cadence == other.cadence && currency == other.currency && groupedTieredConfig == other.groupedTieredConfig && itemId == other.itemId && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && conversionRateConfig == other.conversionRateConfig && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is NewFloatingGroupedTieredPrice && + cadence == other.cadence && + currency == other.currency && + groupedTieredConfig == other.groupedTieredConfig && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, currency, groupedTieredConfig, itemId, modelType, name, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, conversionRateConfig, dimensionalPriceConfiguration, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + cadence, + currency, + groupedTieredConfig, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingGroupedWithMeteredMinimumPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingGroupedWithMeteredMinimumPrice.kt index b267b1928..7d08fa962 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingGroupedWithMeteredMinimumPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingGroupedWithMeteredMinimumPrice.kt @@ -1063,7 +1063,7 @@ private constructor( return true } - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + return other is Cadence && value == other.value } override fun hashCode() = value.hashCode() @@ -1164,12 +1164,11 @@ private constructor( return true } - return /* spotless:off */ other is GroupedWithMeteredMinimumConfig && additionalProperties == other.additionalProperties /* spotless:on */ + return other is GroupedWithMeteredMinimumConfig && + additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1289,7 +1288,7 @@ private constructor( return true } - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + return other is ModelType && value == other.value } override fun hashCode() = value.hashCode() @@ -1379,10 +1378,10 @@ private constructor( return true } - return /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ + return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(unit, tiered) override fun toString(): String = when { @@ -1558,12 +1557,10 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1575,12 +1572,49 @@ private constructor( return true } - return /* spotless:off */ other is NewFloatingGroupedWithMeteredMinimumPrice && cadence == other.cadence && currency == other.currency && groupedWithMeteredMinimumConfig == other.groupedWithMeteredMinimumConfig && itemId == other.itemId && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && conversionRateConfig == other.conversionRateConfig && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is NewFloatingGroupedWithMeteredMinimumPrice && + cadence == other.cadence && + currency == other.currency && + groupedWithMeteredMinimumConfig == other.groupedWithMeteredMinimumConfig && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, currency, groupedWithMeteredMinimumConfig, itemId, modelType, name, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, conversionRateConfig, dimensionalPriceConfiguration, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + cadence, + currency, + groupedWithMeteredMinimumConfig, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingGroupedWithProratedMinimumPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingGroupedWithProratedMinimumPrice.kt index a21a6d231..915ec4bf3 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingGroupedWithProratedMinimumPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingGroupedWithProratedMinimumPrice.kt @@ -1063,7 +1063,7 @@ private constructor( return true } - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + return other is Cadence && value == other.value } override fun hashCode() = value.hashCode() @@ -1164,12 +1164,11 @@ private constructor( return true } - return /* spotless:off */ other is GroupedWithProratedMinimumConfig && additionalProperties == other.additionalProperties /* spotless:on */ + return other is GroupedWithProratedMinimumConfig && + additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1289,7 +1288,7 @@ private constructor( return true } - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + return other is ModelType && value == other.value } override fun hashCode() = value.hashCode() @@ -1379,10 +1378,10 @@ private constructor( return true } - return /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ + return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(unit, tiered) override fun toString(): String = when { @@ -1558,12 +1557,10 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1575,12 +1572,49 @@ private constructor( return true } - return /* spotless:off */ other is NewFloatingGroupedWithProratedMinimumPrice && cadence == other.cadence && currency == other.currency && groupedWithProratedMinimumConfig == other.groupedWithProratedMinimumConfig && itemId == other.itemId && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && conversionRateConfig == other.conversionRateConfig && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is NewFloatingGroupedWithProratedMinimumPrice && + cadence == other.cadence && + currency == other.currency && + groupedWithProratedMinimumConfig == other.groupedWithProratedMinimumConfig && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, currency, groupedWithProratedMinimumConfig, itemId, modelType, name, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, conversionRateConfig, dimensionalPriceConfiguration, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + cadence, + currency, + groupedWithProratedMinimumConfig, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingMatrixPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingMatrixPrice.kt index e7484599c..497fbaf52 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingMatrixPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingMatrixPrice.kt @@ -1048,7 +1048,7 @@ private constructor( return true } - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + return other is Cadence && value == other.value } override fun hashCode() = value.hashCode() @@ -1168,7 +1168,7 @@ private constructor( return true } - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + return other is ModelType && value == other.value } override fun hashCode() = value.hashCode() @@ -1258,10 +1258,10 @@ private constructor( return true } - return /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ + return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(unit, tiered) override fun toString(): String = when { @@ -1437,12 +1437,10 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1454,12 +1452,49 @@ private constructor( return true } - return /* spotless:off */ other is NewFloatingMatrixPrice && cadence == other.cadence && currency == other.currency && itemId == other.itemId && matrixConfig == other.matrixConfig && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && conversionRateConfig == other.conversionRateConfig && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is NewFloatingMatrixPrice && + cadence == other.cadence && + currency == other.currency && + itemId == other.itemId && + matrixConfig == other.matrixConfig && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, currency, itemId, matrixConfig, modelType, name, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, conversionRateConfig, dimensionalPriceConfiguration, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + cadence, + currency, + itemId, + matrixConfig, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingMatrixWithAllocationPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingMatrixWithAllocationPrice.kt index 489c43007..8c018c0b1 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingMatrixWithAllocationPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingMatrixWithAllocationPrice.kt @@ -1060,7 +1060,7 @@ private constructor( return true } - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + return other is Cadence && value == other.value } override fun hashCode() = value.hashCode() @@ -1180,7 +1180,7 @@ private constructor( return true } - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + return other is ModelType && value == other.value } override fun hashCode() = value.hashCode() @@ -1270,10 +1270,10 @@ private constructor( return true } - return /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ + return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(unit, tiered) override fun toString(): String = when { @@ -1449,12 +1449,10 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1466,12 +1464,49 @@ private constructor( return true } - return /* spotless:off */ other is NewFloatingMatrixWithAllocationPrice && cadence == other.cadence && currency == other.currency && itemId == other.itemId && matrixWithAllocationConfig == other.matrixWithAllocationConfig && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && conversionRateConfig == other.conversionRateConfig && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is NewFloatingMatrixWithAllocationPrice && + cadence == other.cadence && + currency == other.currency && + itemId == other.itemId && + matrixWithAllocationConfig == other.matrixWithAllocationConfig && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, currency, itemId, matrixWithAllocationConfig, modelType, name, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, conversionRateConfig, dimensionalPriceConfiguration, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + cadence, + currency, + itemId, + matrixWithAllocationConfig, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingMatrixWithDisplayNamePrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingMatrixWithDisplayNamePrice.kt index 8b1806a21..91e8dca2d 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingMatrixWithDisplayNamePrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingMatrixWithDisplayNamePrice.kt @@ -1060,7 +1060,7 @@ private constructor( return true } - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + return other is Cadence && value == other.value } override fun hashCode() = value.hashCode() @@ -1160,12 +1160,11 @@ private constructor( return true } - return /* spotless:off */ other is MatrixWithDisplayNameConfig && additionalProperties == other.additionalProperties /* spotless:on */ + return other is MatrixWithDisplayNameConfig && + additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1285,7 +1284,7 @@ private constructor( return true } - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + return other is ModelType && value == other.value } override fun hashCode() = value.hashCode() @@ -1375,10 +1374,10 @@ private constructor( return true } - return /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ + return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(unit, tiered) override fun toString(): String = when { @@ -1554,12 +1553,10 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1571,12 +1568,49 @@ private constructor( return true } - return /* spotless:off */ other is NewFloatingMatrixWithDisplayNamePrice && cadence == other.cadence && currency == other.currency && itemId == other.itemId && matrixWithDisplayNameConfig == other.matrixWithDisplayNameConfig && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && conversionRateConfig == other.conversionRateConfig && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is NewFloatingMatrixWithDisplayNamePrice && + cadence == other.cadence && + currency == other.currency && + itemId == other.itemId && + matrixWithDisplayNameConfig == other.matrixWithDisplayNameConfig && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, currency, itemId, matrixWithDisplayNameConfig, modelType, name, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, conversionRateConfig, dimensionalPriceConfiguration, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + cadence, + currency, + itemId, + matrixWithDisplayNameConfig, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingMaxGroupTieredPackagePrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingMaxGroupTieredPackagePrice.kt index 481716158..b2e13658d 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingMaxGroupTieredPackagePrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingMaxGroupTieredPackagePrice.kt @@ -1060,7 +1060,7 @@ private constructor( return true } - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + return other is Cadence && value == other.value } override fun hashCode() = value.hashCode() @@ -1160,12 +1160,11 @@ private constructor( return true } - return /* spotless:off */ other is MaxGroupTieredPackageConfig && additionalProperties == other.additionalProperties /* spotless:on */ + return other is MaxGroupTieredPackageConfig && + additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1285,7 +1284,7 @@ private constructor( return true } - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + return other is ModelType && value == other.value } override fun hashCode() = value.hashCode() @@ -1375,10 +1374,10 @@ private constructor( return true } - return /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ + return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(unit, tiered) override fun toString(): String = when { @@ -1554,12 +1553,10 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1571,12 +1568,49 @@ private constructor( return true } - return /* spotless:off */ other is NewFloatingMaxGroupTieredPackagePrice && cadence == other.cadence && currency == other.currency && itemId == other.itemId && maxGroupTieredPackageConfig == other.maxGroupTieredPackageConfig && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && conversionRateConfig == other.conversionRateConfig && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is NewFloatingMaxGroupTieredPackagePrice && + cadence == other.cadence && + currency == other.currency && + itemId == other.itemId && + maxGroupTieredPackageConfig == other.maxGroupTieredPackageConfig && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, currency, itemId, maxGroupTieredPackageConfig, modelType, name, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, conversionRateConfig, dimensionalPriceConfiguration, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + cadence, + currency, + itemId, + maxGroupTieredPackageConfig, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingPackagePrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingPackagePrice.kt index e711b9849..ce425f3df 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingPackagePrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingPackagePrice.kt @@ -1048,7 +1048,7 @@ private constructor( return true } - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + return other is Cadence && value == other.value } override fun hashCode() = value.hashCode() @@ -1168,7 +1168,7 @@ private constructor( return true } - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + return other is ModelType && value == other.value } override fun hashCode() = value.hashCode() @@ -1258,10 +1258,10 @@ private constructor( return true } - return /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ + return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(unit, tiered) override fun toString(): String = when { @@ -1437,12 +1437,10 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1454,12 +1452,49 @@ private constructor( return true } - return /* spotless:off */ other is NewFloatingPackagePrice && cadence == other.cadence && currency == other.currency && itemId == other.itemId && modelType == other.modelType && name == other.name && packageConfig == other.packageConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && conversionRateConfig == other.conversionRateConfig && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is NewFloatingPackagePrice && + cadence == other.cadence && + currency == other.currency && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + packageConfig == other.packageConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, currency, itemId, modelType, name, packageConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, conversionRateConfig, dimensionalPriceConfiguration, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + cadence, + currency, + itemId, + modelType, + name, + packageConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingPackageWithAllocationPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingPackageWithAllocationPrice.kt index f2d69841a..50335e1c2 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingPackageWithAllocationPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingPackageWithAllocationPrice.kt @@ -1060,7 +1060,7 @@ private constructor( return true } - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + return other is Cadence && value == other.value } override fun hashCode() = value.hashCode() @@ -1180,7 +1180,7 @@ private constructor( return true } - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + return other is ModelType && value == other.value } override fun hashCode() = value.hashCode() @@ -1280,12 +1280,11 @@ private constructor( return true } - return /* spotless:off */ other is PackageWithAllocationConfig && additionalProperties == other.additionalProperties /* spotless:on */ + return other is PackageWithAllocationConfig && + additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1375,10 +1374,10 @@ private constructor( return true } - return /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ + return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(unit, tiered) override fun toString(): String = when { @@ -1554,12 +1553,10 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1571,12 +1568,49 @@ private constructor( return true } - return /* spotless:off */ other is NewFloatingPackageWithAllocationPrice && cadence == other.cadence && currency == other.currency && itemId == other.itemId && modelType == other.modelType && name == other.name && packageWithAllocationConfig == other.packageWithAllocationConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && conversionRateConfig == other.conversionRateConfig && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is NewFloatingPackageWithAllocationPrice && + cadence == other.cadence && + currency == other.currency && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + packageWithAllocationConfig == other.packageWithAllocationConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, currency, itemId, modelType, name, packageWithAllocationConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, conversionRateConfig, dimensionalPriceConfiguration, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + cadence, + currency, + itemId, + modelType, + name, + packageWithAllocationConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingScalableMatrixWithTieredPricingPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingScalableMatrixWithTieredPricingPrice.kt index f82bafef1..7a89c980d 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingScalableMatrixWithTieredPricingPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingScalableMatrixWithTieredPricingPrice.kt @@ -1078,7 +1078,7 @@ private constructor( return true } - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + return other is Cadence && value == other.value } override fun hashCode() = value.hashCode() @@ -1198,7 +1198,7 @@ private constructor( return true } - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + return other is ModelType && value == other.value } override fun hashCode() = value.hashCode() @@ -1300,12 +1300,11 @@ private constructor( return true } - return /* spotless:off */ other is ScalableMatrixWithTieredPricingConfig && additionalProperties == other.additionalProperties /* spotless:on */ + return other is ScalableMatrixWithTieredPricingConfig && + additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1395,10 +1394,10 @@ private constructor( return true } - return /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ + return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(unit, tiered) override fun toString(): String = when { @@ -1574,12 +1573,10 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1591,12 +1588,49 @@ private constructor( return true } - return /* spotless:off */ other is NewFloatingScalableMatrixWithTieredPricingPrice && cadence == other.cadence && currency == other.currency && itemId == other.itemId && modelType == other.modelType && name == other.name && scalableMatrixWithTieredPricingConfig == other.scalableMatrixWithTieredPricingConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && conversionRateConfig == other.conversionRateConfig && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is NewFloatingScalableMatrixWithTieredPricingPrice && + cadence == other.cadence && + currency == other.currency && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + scalableMatrixWithTieredPricingConfig == other.scalableMatrixWithTieredPricingConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, currency, itemId, modelType, name, scalableMatrixWithTieredPricingConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, conversionRateConfig, dimensionalPriceConfiguration, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + cadence, + currency, + itemId, + modelType, + name, + scalableMatrixWithTieredPricingConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingScalableMatrixWithUnitPricingPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingScalableMatrixWithUnitPricingPrice.kt index 2c85cf5f8..0313943f6 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingScalableMatrixWithUnitPricingPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingScalableMatrixWithUnitPricingPrice.kt @@ -1069,7 +1069,7 @@ private constructor( return true } - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + return other is Cadence && value == other.value } override fun hashCode() = value.hashCode() @@ -1189,7 +1189,7 @@ private constructor( return true } - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + return other is ModelType && value == other.value } override fun hashCode() = value.hashCode() @@ -1291,12 +1291,11 @@ private constructor( return true } - return /* spotless:off */ other is ScalableMatrixWithUnitPricingConfig && additionalProperties == other.additionalProperties /* spotless:on */ + return other is ScalableMatrixWithUnitPricingConfig && + additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1386,10 +1385,10 @@ private constructor( return true } - return /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ + return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(unit, tiered) override fun toString(): String = when { @@ -1565,12 +1564,10 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1582,12 +1579,49 @@ private constructor( return true } - return /* spotless:off */ other is NewFloatingScalableMatrixWithUnitPricingPrice && cadence == other.cadence && currency == other.currency && itemId == other.itemId && modelType == other.modelType && name == other.name && scalableMatrixWithUnitPricingConfig == other.scalableMatrixWithUnitPricingConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && conversionRateConfig == other.conversionRateConfig && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is NewFloatingScalableMatrixWithUnitPricingPrice && + cadence == other.cadence && + currency == other.currency && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + scalableMatrixWithUnitPricingConfig == other.scalableMatrixWithUnitPricingConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, currency, itemId, modelType, name, scalableMatrixWithUnitPricingConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, conversionRateConfig, dimensionalPriceConfiguration, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + cadence, + currency, + itemId, + modelType, + name, + scalableMatrixWithUnitPricingConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingThresholdTotalAmountPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingThresholdTotalAmountPrice.kt index fdb7ca53f..0632badbc 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingThresholdTotalAmountPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingThresholdTotalAmountPrice.kt @@ -1060,7 +1060,7 @@ private constructor( return true } - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + return other is Cadence && value == other.value } override fun hashCode() = value.hashCode() @@ -1180,7 +1180,7 @@ private constructor( return true } - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + return other is ModelType && value == other.value } override fun hashCode() = value.hashCode() @@ -1280,12 +1280,11 @@ private constructor( return true } - return /* spotless:off */ other is ThresholdTotalAmountConfig && additionalProperties == other.additionalProperties /* spotless:on */ + return other is ThresholdTotalAmountConfig && + additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1375,10 +1374,10 @@ private constructor( return true } - return /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ + return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(unit, tiered) override fun toString(): String = when { @@ -1554,12 +1553,10 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1571,12 +1568,49 @@ private constructor( return true } - return /* spotless:off */ other is NewFloatingThresholdTotalAmountPrice && cadence == other.cadence && currency == other.currency && itemId == other.itemId && modelType == other.modelType && name == other.name && thresholdTotalAmountConfig == other.thresholdTotalAmountConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && conversionRateConfig == other.conversionRateConfig && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is NewFloatingThresholdTotalAmountPrice && + cadence == other.cadence && + currency == other.currency && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + thresholdTotalAmountConfig == other.thresholdTotalAmountConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, currency, itemId, modelType, name, thresholdTotalAmountConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, conversionRateConfig, dimensionalPriceConfiguration, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + cadence, + currency, + itemId, + modelType, + name, + thresholdTotalAmountConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredBpsPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredBpsPrice.kt index 085b42ca2..976db66d1 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredBpsPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredBpsPrice.kt @@ -1049,7 +1049,7 @@ private constructor( return true } - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + return other is Cadence && value == other.value } override fun hashCode() = value.hashCode() @@ -1169,7 +1169,7 @@ private constructor( return true } - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + return other is ModelType && value == other.value } override fun hashCode() = value.hashCode() @@ -1259,10 +1259,10 @@ private constructor( return true } - return /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ + return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(unit, tiered) override fun toString(): String = when { @@ -1438,12 +1438,10 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1455,12 +1453,49 @@ private constructor( return true } - return /* spotless:off */ other is NewFloatingTieredBpsPrice && cadence == other.cadence && currency == other.currency && itemId == other.itemId && modelType == other.modelType && name == other.name && tieredBpsConfig == other.tieredBpsConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && conversionRateConfig == other.conversionRateConfig && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is NewFloatingTieredBpsPrice && + cadence == other.cadence && + currency == other.currency && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + tieredBpsConfig == other.tieredBpsConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, currency, itemId, modelType, name, tieredBpsConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, conversionRateConfig, dimensionalPriceConfiguration, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + cadence, + currency, + itemId, + modelType, + name, + tieredBpsConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredPackagePrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredPackagePrice.kt index 5eb5a458f..be0a54f7c 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredPackagePrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredPackagePrice.kt @@ -1053,7 +1053,7 @@ private constructor( return true } - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + return other is Cadence && value == other.value } override fun hashCode() = value.hashCode() @@ -1173,7 +1173,7 @@ private constructor( return true } - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + return other is ModelType && value == other.value } override fun hashCode() = value.hashCode() @@ -1269,12 +1269,11 @@ private constructor( return true } - return /* spotless:off */ other is TieredPackageConfig && additionalProperties == other.additionalProperties /* spotless:on */ + return other is TieredPackageConfig && + additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1363,10 +1362,10 @@ private constructor( return true } - return /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ + return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(unit, tiered) override fun toString(): String = when { @@ -1542,12 +1541,10 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1559,12 +1556,49 @@ private constructor( return true } - return /* spotless:off */ other is NewFloatingTieredPackagePrice && cadence == other.cadence && currency == other.currency && itemId == other.itemId && modelType == other.modelType && name == other.name && tieredPackageConfig == other.tieredPackageConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && conversionRateConfig == other.conversionRateConfig && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is NewFloatingTieredPackagePrice && + cadence == other.cadence && + currency == other.currency && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + tieredPackageConfig == other.tieredPackageConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, currency, itemId, modelType, name, tieredPackageConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, conversionRateConfig, dimensionalPriceConfiguration, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + cadence, + currency, + itemId, + modelType, + name, + tieredPackageConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredPackageWithMinimumPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredPackageWithMinimumPrice.kt index 8054907fc..0fa7d9f4b 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredPackageWithMinimumPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredPackageWithMinimumPrice.kt @@ -1063,7 +1063,7 @@ private constructor( return true } - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + return other is Cadence && value == other.value } override fun hashCode() = value.hashCode() @@ -1183,7 +1183,7 @@ private constructor( return true } - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + return other is ModelType && value == other.value } override fun hashCode() = value.hashCode() @@ -1284,12 +1284,11 @@ private constructor( return true } - return /* spotless:off */ other is TieredPackageWithMinimumConfig && additionalProperties == other.additionalProperties /* spotless:on */ + return other is TieredPackageWithMinimumConfig && + additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1379,10 +1378,10 @@ private constructor( return true } - return /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ + return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(unit, tiered) override fun toString(): String = when { @@ -1558,12 +1557,10 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1575,12 +1572,49 @@ private constructor( return true } - return /* spotless:off */ other is NewFloatingTieredPackageWithMinimumPrice && cadence == other.cadence && currency == other.currency && itemId == other.itemId && modelType == other.modelType && name == other.name && tieredPackageWithMinimumConfig == other.tieredPackageWithMinimumConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && conversionRateConfig == other.conversionRateConfig && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is NewFloatingTieredPackageWithMinimumPrice && + cadence == other.cadence && + currency == other.currency && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + tieredPackageWithMinimumConfig == other.tieredPackageWithMinimumConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, currency, itemId, modelType, name, tieredPackageWithMinimumConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, conversionRateConfig, dimensionalPriceConfiguration, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + cadence, + currency, + itemId, + modelType, + name, + tieredPackageWithMinimumConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredPrice.kt index ce86b9aa7..6ad24e00b 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredPrice.kt @@ -1048,7 +1048,7 @@ private constructor( return true } - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + return other is Cadence && value == other.value } override fun hashCode() = value.hashCode() @@ -1168,7 +1168,7 @@ private constructor( return true } - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + return other is ModelType && value == other.value } override fun hashCode() = value.hashCode() @@ -1258,10 +1258,10 @@ private constructor( return true } - return /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ + return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(unit, tiered) override fun toString(): String = when { @@ -1437,12 +1437,10 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1454,12 +1452,49 @@ private constructor( return true } - return /* spotless:off */ other is NewFloatingTieredPrice && cadence == other.cadence && currency == other.currency && itemId == other.itemId && modelType == other.modelType && name == other.name && tieredConfig == other.tieredConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && conversionRateConfig == other.conversionRateConfig && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is NewFloatingTieredPrice && + cadence == other.cadence && + currency == other.currency && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + tieredConfig == other.tieredConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, currency, itemId, modelType, name, tieredConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, conversionRateConfig, dimensionalPriceConfiguration, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + cadence, + currency, + itemId, + modelType, + name, + tieredConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredWithMinimumPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredWithMinimumPrice.kt index 0ef8be3c8..fbc50c8d1 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredWithMinimumPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredWithMinimumPrice.kt @@ -1058,7 +1058,7 @@ private constructor( return true } - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + return other is Cadence && value == other.value } override fun hashCode() = value.hashCode() @@ -1178,7 +1178,7 @@ private constructor( return true } - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + return other is ModelType && value == other.value } override fun hashCode() = value.hashCode() @@ -1276,12 +1276,11 @@ private constructor( return true } - return /* spotless:off */ other is TieredWithMinimumConfig && additionalProperties == other.additionalProperties /* spotless:on */ + return other is TieredWithMinimumConfig && + additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1371,10 +1370,10 @@ private constructor( return true } - return /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ + return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(unit, tiered) override fun toString(): String = when { @@ -1550,12 +1549,10 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1567,12 +1564,49 @@ private constructor( return true } - return /* spotless:off */ other is NewFloatingTieredWithMinimumPrice && cadence == other.cadence && currency == other.currency && itemId == other.itemId && modelType == other.modelType && name == other.name && tieredWithMinimumConfig == other.tieredWithMinimumConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && conversionRateConfig == other.conversionRateConfig && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is NewFloatingTieredWithMinimumPrice && + cadence == other.cadence && + currency == other.currency && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + tieredWithMinimumConfig == other.tieredWithMinimumConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, currency, itemId, modelType, name, tieredWithMinimumConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, conversionRateConfig, dimensionalPriceConfiguration, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + cadence, + currency, + itemId, + modelType, + name, + tieredWithMinimumConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredWithProrationPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredWithProrationPrice.kt index 0aa206ab4..8a92a0e7d 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredWithProrationPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredWithProrationPrice.kt @@ -1060,7 +1060,7 @@ private constructor( return true } - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + return other is Cadence && value == other.value } override fun hashCode() = value.hashCode() @@ -1180,7 +1180,7 @@ private constructor( return true } - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + return other is ModelType && value == other.value } override fun hashCode() = value.hashCode() @@ -1279,12 +1279,11 @@ private constructor( return true } - return /* spotless:off */ other is TieredWithProrationConfig && additionalProperties == other.additionalProperties /* spotless:on */ + return other is TieredWithProrationConfig && + additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1374,10 +1373,10 @@ private constructor( return true } - return /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ + return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(unit, tiered) override fun toString(): String = when { @@ -1553,12 +1552,10 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1570,12 +1567,49 @@ private constructor( return true } - return /* spotless:off */ other is NewFloatingTieredWithProrationPrice && cadence == other.cadence && currency == other.currency && itemId == other.itemId && modelType == other.modelType && name == other.name && tieredWithProrationConfig == other.tieredWithProrationConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && conversionRateConfig == other.conversionRateConfig && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is NewFloatingTieredWithProrationPrice && + cadence == other.cadence && + currency == other.currency && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + tieredWithProrationConfig == other.tieredWithProrationConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, currency, itemId, modelType, name, tieredWithProrationConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, conversionRateConfig, dimensionalPriceConfiguration, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + cadence, + currency, + itemId, + modelType, + name, + tieredWithProrationConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingUnitPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingUnitPrice.kt index 804237ad4..f11f502f3 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingUnitPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingUnitPrice.kt @@ -1046,7 +1046,7 @@ private constructor( return true } - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + return other is Cadence && value == other.value } override fun hashCode() = value.hashCode() @@ -1166,7 +1166,7 @@ private constructor( return true } - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + return other is ModelType && value == other.value } override fun hashCode() = value.hashCode() @@ -1256,10 +1256,10 @@ private constructor( return true } - return /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ + return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(unit, tiered) override fun toString(): String = when { @@ -1435,12 +1435,10 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1452,12 +1450,49 @@ private constructor( return true } - return /* spotless:off */ other is NewFloatingUnitPrice && cadence == other.cadence && currency == other.currency && itemId == other.itemId && modelType == other.modelType && name == other.name && unitConfig == other.unitConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && conversionRateConfig == other.conversionRateConfig && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is NewFloatingUnitPrice && + cadence == other.cadence && + currency == other.currency && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + unitConfig == other.unitConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, currency, itemId, modelType, name, unitConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, conversionRateConfig, dimensionalPriceConfiguration, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + cadence, + currency, + itemId, + modelType, + name, + unitConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingUnitWithPercentPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingUnitWithPercentPrice.kt index 99a34682d..e918c14f3 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingUnitWithPercentPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingUnitWithPercentPrice.kt @@ -1057,7 +1057,7 @@ private constructor( return true } - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + return other is Cadence && value == other.value } override fun hashCode() = value.hashCode() @@ -1177,7 +1177,7 @@ private constructor( return true } - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + return other is ModelType && value == other.value } override fun hashCode() = value.hashCode() @@ -1275,12 +1275,11 @@ private constructor( return true } - return /* spotless:off */ other is UnitWithPercentConfig && additionalProperties == other.additionalProperties /* spotless:on */ + return other is UnitWithPercentConfig && + additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1370,10 +1369,10 @@ private constructor( return true } - return /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ + return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(unit, tiered) override fun toString(): String = when { @@ -1549,12 +1548,10 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1566,12 +1563,49 @@ private constructor( return true } - return /* spotless:off */ other is NewFloatingUnitWithPercentPrice && cadence == other.cadence && currency == other.currency && itemId == other.itemId && modelType == other.modelType && name == other.name && unitWithPercentConfig == other.unitWithPercentConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && conversionRateConfig == other.conversionRateConfig && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is NewFloatingUnitWithPercentPrice && + cadence == other.cadence && + currency == other.currency && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + unitWithPercentConfig == other.unitWithPercentConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, currency, itemId, modelType, name, unitWithPercentConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, conversionRateConfig, dimensionalPriceConfiguration, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + cadence, + currency, + itemId, + modelType, + name, + unitWithPercentConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingUnitWithProrationPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingUnitWithProrationPrice.kt index 18b115c99..691084d83 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingUnitWithProrationPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingUnitWithProrationPrice.kt @@ -1058,7 +1058,7 @@ private constructor( return true } - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + return other is Cadence && value == other.value } override fun hashCode() = value.hashCode() @@ -1178,7 +1178,7 @@ private constructor( return true } - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + return other is ModelType && value == other.value } override fun hashCode() = value.hashCode() @@ -1276,12 +1276,11 @@ private constructor( return true } - return /* spotless:off */ other is UnitWithProrationConfig && additionalProperties == other.additionalProperties /* spotless:on */ + return other is UnitWithProrationConfig && + additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1371,10 +1370,10 @@ private constructor( return true } - return /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ + return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(unit, tiered) override fun toString(): String = when { @@ -1550,12 +1549,10 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1567,12 +1564,49 @@ private constructor( return true } - return /* spotless:off */ other is NewFloatingUnitWithProrationPrice && cadence == other.cadence && currency == other.currency && itemId == other.itemId && modelType == other.modelType && name == other.name && unitWithProrationConfig == other.unitWithProrationConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && conversionRateConfig == other.conversionRateConfig && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is NewFloatingUnitWithProrationPrice && + cadence == other.cadence && + currency == other.currency && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + unitWithProrationConfig == other.unitWithProrationConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, currency, itemId, modelType, name, unitWithProrationConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, conversionRateConfig, dimensionalPriceConfiguration, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + cadence, + currency, + itemId, + modelType, + name, + unitWithProrationConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewMaximum.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewMaximum.kt index 7253a46a8..2cbea1804 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewMaximum.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewMaximum.kt @@ -639,7 +639,7 @@ private constructor( return true } - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ + return other is AdjustmentType && value == other.value } override fun hashCode() = value.hashCode() @@ -758,7 +758,7 @@ private constructor( return true } - return /* spotless:off */ other is AppliesToAll && value == other.value /* spotless:on */ + return other is AppliesToAll && value == other.value } override fun hashCode() = value.hashCode() @@ -903,7 +903,7 @@ private constructor( return true } - return /* spotless:off */ other is PriceType && value == other.value /* spotless:on */ + return other is PriceType && value == other.value } override fun hashCode() = value.hashCode() @@ -916,12 +916,33 @@ private constructor( return true } - return /* spotless:off */ other is NewMaximum && adjustmentType == other.adjustmentType && maximumAmount == other.maximumAmount && appliesToAll == other.appliesToAll && appliesToItemIds == other.appliesToItemIds && appliesToPriceIds == other.appliesToPriceIds && currency == other.currency && filters == other.filters && isInvoiceLevel == other.isInvoiceLevel && priceType == other.priceType && additionalProperties == other.additionalProperties /* spotless:on */ + return other is NewMaximum && + adjustmentType == other.adjustmentType && + maximumAmount == other.maximumAmount && + appliesToAll == other.appliesToAll && + appliesToItemIds == other.appliesToItemIds && + appliesToPriceIds == other.appliesToPriceIds && + currency == other.currency && + filters == other.filters && + isInvoiceLevel == other.isInvoiceLevel && + priceType == other.priceType && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(adjustmentType, maximumAmount, appliesToAll, appliesToItemIds, appliesToPriceIds, currency, filters, isInvoiceLevel, priceType, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + adjustmentType, + maximumAmount, + appliesToAll, + appliesToItemIds, + appliesToPriceIds, + currency, + filters, + isInvoiceLevel, + priceType, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewMinimum.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewMinimum.kt index 60d82f071..7a4c87fda 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewMinimum.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewMinimum.kt @@ -675,7 +675,7 @@ private constructor( return true } - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ + return other is AdjustmentType && value == other.value } override fun hashCode() = value.hashCode() @@ -794,7 +794,7 @@ private constructor( return true } - return /* spotless:off */ other is AppliesToAll && value == other.value /* spotless:on */ + return other is AppliesToAll && value == other.value } override fun hashCode() = value.hashCode() @@ -939,7 +939,7 @@ private constructor( return true } - return /* spotless:off */ other is PriceType && value == other.value /* spotless:on */ + return other is PriceType && value == other.value } override fun hashCode() = value.hashCode() @@ -952,12 +952,35 @@ private constructor( return true } - return /* spotless:off */ other is NewMinimum && adjustmentType == other.adjustmentType && itemId == other.itemId && minimumAmount == other.minimumAmount && appliesToAll == other.appliesToAll && appliesToItemIds == other.appliesToItemIds && appliesToPriceIds == other.appliesToPriceIds && currency == other.currency && filters == other.filters && isInvoiceLevel == other.isInvoiceLevel && priceType == other.priceType && additionalProperties == other.additionalProperties /* spotless:on */ + return other is NewMinimum && + adjustmentType == other.adjustmentType && + itemId == other.itemId && + minimumAmount == other.minimumAmount && + appliesToAll == other.appliesToAll && + appliesToItemIds == other.appliesToItemIds && + appliesToPriceIds == other.appliesToPriceIds && + currency == other.currency && + filters == other.filters && + isInvoiceLevel == other.isInvoiceLevel && + priceType == other.priceType && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(adjustmentType, itemId, minimumAmount, appliesToAll, appliesToItemIds, appliesToPriceIds, currency, filters, isInvoiceLevel, priceType, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + adjustmentType, + itemId, + minimumAmount, + appliesToAll, + appliesToItemIds, + appliesToPriceIds, + currency, + filters, + isInvoiceLevel, + priceType, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPercentageDiscount.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPercentageDiscount.kt index a5f87cc4e..32ba4e4ba 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPercentageDiscount.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPercentageDiscount.kt @@ -641,7 +641,7 @@ private constructor( return true } - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ + return other is AdjustmentType && value == other.value } override fun hashCode() = value.hashCode() @@ -760,7 +760,7 @@ private constructor( return true } - return /* spotless:off */ other is AppliesToAll && value == other.value /* spotless:on */ + return other is AppliesToAll && value == other.value } override fun hashCode() = value.hashCode() @@ -905,7 +905,7 @@ private constructor( return true } - return /* spotless:off */ other is PriceType && value == other.value /* spotless:on */ + return other is PriceType && value == other.value } override fun hashCode() = value.hashCode() @@ -918,12 +918,33 @@ private constructor( return true } - return /* spotless:off */ other is NewPercentageDiscount && adjustmentType == other.adjustmentType && percentageDiscount == other.percentageDiscount && appliesToAll == other.appliesToAll && appliesToItemIds == other.appliesToItemIds && appliesToPriceIds == other.appliesToPriceIds && currency == other.currency && filters == other.filters && isInvoiceLevel == other.isInvoiceLevel && priceType == other.priceType && additionalProperties == other.additionalProperties /* spotless:on */ + return other is NewPercentageDiscount && + adjustmentType == other.adjustmentType && + percentageDiscount == other.percentageDiscount && + appliesToAll == other.appliesToAll && + appliesToItemIds == other.appliesToItemIds && + appliesToPriceIds == other.appliesToPriceIds && + currency == other.currency && + filters == other.filters && + isInvoiceLevel == other.isInvoiceLevel && + priceType == other.priceType && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(adjustmentType, percentageDiscount, appliesToAll, appliesToItemIds, appliesToPriceIds, currency, filters, isInvoiceLevel, priceType, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + adjustmentType, + percentageDiscount, + appliesToAll, + appliesToItemIds, + appliesToPriceIds, + currency, + filters, + isInvoiceLevel, + priceType, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanBpsPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanBpsPrice.kt index 8a2ae2166..583994055 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanBpsPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanBpsPrice.kt @@ -1089,7 +1089,7 @@ private constructor( return true } - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + return other is Cadence && value == other.value } override fun hashCode() = value.hashCode() @@ -1209,7 +1209,7 @@ private constructor( return true } - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + return other is ModelType && value == other.value } override fun hashCode() = value.hashCode() @@ -1299,10 +1299,10 @@ private constructor( return true } - return /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ + return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(unit, tiered) override fun toString(): String = when { @@ -1478,12 +1478,10 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1495,12 +1493,51 @@ private constructor( return true } - return /* spotless:off */ other is NewPlanBpsPrice && bpsConfig == other.bpsConfig && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && conversionRateConfig == other.conversionRateConfig && currency == other.currency && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + return other is NewPlanBpsPrice && + bpsConfig == other.bpsConfig && + cadence == other.cadence && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(bpsConfig, cadence, itemId, modelType, name, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, conversionRateConfig, currency, dimensionalPriceConfiguration, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, referenceId, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + bpsConfig, + cadence, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanBulkBpsPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanBulkBpsPrice.kt index 8ae0a3c71..4e610cb30 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanBulkBpsPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanBulkBpsPrice.kt @@ -1093,7 +1093,7 @@ private constructor( return true } - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + return other is Cadence && value == other.value } override fun hashCode() = value.hashCode() @@ -1213,7 +1213,7 @@ private constructor( return true } - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + return other is ModelType && value == other.value } override fun hashCode() = value.hashCode() @@ -1303,10 +1303,10 @@ private constructor( return true } - return /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ + return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(unit, tiered) override fun toString(): String = when { @@ -1482,12 +1482,10 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1499,12 +1497,51 @@ private constructor( return true } - return /* spotless:off */ other is NewPlanBulkBpsPrice && bulkBpsConfig == other.bulkBpsConfig && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && conversionRateConfig == other.conversionRateConfig && currency == other.currency && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + return other is NewPlanBulkBpsPrice && + bulkBpsConfig == other.bulkBpsConfig && + cadence == other.cadence && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(bulkBpsConfig, cadence, itemId, modelType, name, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, conversionRateConfig, currency, dimensionalPriceConfiguration, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, referenceId, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + bulkBpsConfig, + cadence, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanBulkPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanBulkPrice.kt index e127022ba..2580aaac7 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanBulkPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanBulkPrice.kt @@ -1091,7 +1091,7 @@ private constructor( return true } - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + return other is Cadence && value == other.value } override fun hashCode() = value.hashCode() @@ -1211,7 +1211,7 @@ private constructor( return true } - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + return other is ModelType && value == other.value } override fun hashCode() = value.hashCode() @@ -1301,10 +1301,10 @@ private constructor( return true } - return /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ + return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(unit, tiered) override fun toString(): String = when { @@ -1480,12 +1480,10 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1497,12 +1495,51 @@ private constructor( return true } - return /* spotless:off */ other is NewPlanBulkPrice && bulkConfig == other.bulkConfig && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && conversionRateConfig == other.conversionRateConfig && currency == other.currency && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + return other is NewPlanBulkPrice && + bulkConfig == other.bulkConfig && + cadence == other.cadence && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(bulkConfig, cadence, itemId, modelType, name, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, conversionRateConfig, currency, dimensionalPriceConfiguration, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, referenceId, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + bulkConfig, + cadence, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanBulkWithProrationPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanBulkWithProrationPrice.kt index d82290f0b..1794a499d 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanBulkWithProrationPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanBulkWithProrationPrice.kt @@ -1048,12 +1048,11 @@ private constructor( return true } - return /* spotless:off */ other is BulkWithProrationConfig && additionalProperties == other.additionalProperties /* spotless:on */ + return other is BulkWithProrationConfig && + additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1202,7 +1201,7 @@ private constructor( return true } - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + return other is Cadence && value == other.value } override fun hashCode() = value.hashCode() @@ -1322,7 +1321,7 @@ private constructor( return true } - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + return other is ModelType && value == other.value } override fun hashCode() = value.hashCode() @@ -1412,10 +1411,10 @@ private constructor( return true } - return /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ + return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(unit, tiered) override fun toString(): String = when { @@ -1591,12 +1590,10 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1608,12 +1605,51 @@ private constructor( return true } - return /* spotless:off */ other is NewPlanBulkWithProrationPrice && bulkWithProrationConfig == other.bulkWithProrationConfig && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && conversionRateConfig == other.conversionRateConfig && currency == other.currency && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + return other is NewPlanBulkWithProrationPrice && + bulkWithProrationConfig == other.bulkWithProrationConfig && + cadence == other.cadence && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(bulkWithProrationConfig, cadence, itemId, modelType, name, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, conversionRateConfig, currency, dimensionalPriceConfiguration, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, referenceId, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + bulkWithProrationConfig, + cadence, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanCumulativeGroupedBulkPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanCumulativeGroupedBulkPrice.kt index ba612ba57..f3d71fc66 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanCumulativeGroupedBulkPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanCumulativeGroupedBulkPrice.kt @@ -1104,7 +1104,7 @@ private constructor( return true } - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + return other is Cadence && value == other.value } override fun hashCode() = value.hashCode() @@ -1204,12 +1204,11 @@ private constructor( return true } - return /* spotless:off */ other is CumulativeGroupedBulkConfig && additionalProperties == other.additionalProperties /* spotless:on */ + return other is CumulativeGroupedBulkConfig && + additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1329,7 +1328,7 @@ private constructor( return true } - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + return other is ModelType && value == other.value } override fun hashCode() = value.hashCode() @@ -1419,10 +1418,10 @@ private constructor( return true } - return /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ + return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(unit, tiered) override fun toString(): String = when { @@ -1598,12 +1597,10 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1615,12 +1612,51 @@ private constructor( return true } - return /* spotless:off */ other is NewPlanCumulativeGroupedBulkPrice && cadence == other.cadence && cumulativeGroupedBulkConfig == other.cumulativeGroupedBulkConfig && itemId == other.itemId && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && conversionRateConfig == other.conversionRateConfig && currency == other.currency && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + return other is NewPlanCumulativeGroupedBulkPrice && + cadence == other.cadence && + cumulativeGroupedBulkConfig == other.cumulativeGroupedBulkConfig && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, cumulativeGroupedBulkConfig, itemId, modelType, name, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, conversionRateConfig, currency, dimensionalPriceConfiguration, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, referenceId, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + cadence, + cumulativeGroupedBulkConfig, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanGroupedAllocationPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanGroupedAllocationPrice.kt index 1283f2ca8..fa806ed9d 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanGroupedAllocationPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanGroupedAllocationPrice.kt @@ -1099,7 +1099,7 @@ private constructor( return true } - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + return other is Cadence && value == other.value } override fun hashCode() = value.hashCode() @@ -1197,12 +1197,11 @@ private constructor( return true } - return /* spotless:off */ other is GroupedAllocationConfig && additionalProperties == other.additionalProperties /* spotless:on */ + return other is GroupedAllocationConfig && + additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1322,7 +1321,7 @@ private constructor( return true } - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + return other is ModelType && value == other.value } override fun hashCode() = value.hashCode() @@ -1412,10 +1411,10 @@ private constructor( return true } - return /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ + return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(unit, tiered) override fun toString(): String = when { @@ -1591,12 +1590,10 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1608,12 +1605,51 @@ private constructor( return true } - return /* spotless:off */ other is NewPlanGroupedAllocationPrice && cadence == other.cadence && groupedAllocationConfig == other.groupedAllocationConfig && itemId == other.itemId && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && conversionRateConfig == other.conversionRateConfig && currency == other.currency && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + return other is NewPlanGroupedAllocationPrice && + cadence == other.cadence && + groupedAllocationConfig == other.groupedAllocationConfig && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, groupedAllocationConfig, itemId, modelType, name, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, conversionRateConfig, currency, dimensionalPriceConfiguration, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, referenceId, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + cadence, + groupedAllocationConfig, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanGroupedTieredPackagePrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanGroupedTieredPackagePrice.kt index c7e737456..5a9972cb5 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanGroupedTieredPackagePrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanGroupedTieredPackagePrice.kt @@ -1104,7 +1104,7 @@ private constructor( return true } - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + return other is Cadence && value == other.value } override fun hashCode() = value.hashCode() @@ -1204,12 +1204,11 @@ private constructor( return true } - return /* spotless:off */ other is GroupedTieredPackageConfig && additionalProperties == other.additionalProperties /* spotless:on */ + return other is GroupedTieredPackageConfig && + additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1329,7 +1328,7 @@ private constructor( return true } - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + return other is ModelType && value == other.value } override fun hashCode() = value.hashCode() @@ -1419,10 +1418,10 @@ private constructor( return true } - return /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ + return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(unit, tiered) override fun toString(): String = when { @@ -1598,12 +1597,10 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1615,12 +1612,51 @@ private constructor( return true } - return /* spotless:off */ other is NewPlanGroupedTieredPackagePrice && cadence == other.cadence && groupedTieredPackageConfig == other.groupedTieredPackageConfig && itemId == other.itemId && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && conversionRateConfig == other.conversionRateConfig && currency == other.currency && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + return other is NewPlanGroupedTieredPackagePrice && + cadence == other.cadence && + groupedTieredPackageConfig == other.groupedTieredPackageConfig && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, groupedTieredPackageConfig, itemId, modelType, name, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, conversionRateConfig, currency, dimensionalPriceConfiguration, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, referenceId, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + cadence, + groupedTieredPackageConfig, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanGroupedTieredPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanGroupedTieredPrice.kt index ec9a01fb6..e3eb1ecf9 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanGroupedTieredPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanGroupedTieredPrice.kt @@ -1096,7 +1096,7 @@ private constructor( return true } - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + return other is Cadence && value == other.value } override fun hashCode() = value.hashCode() @@ -1192,12 +1192,11 @@ private constructor( return true } - return /* spotless:off */ other is GroupedTieredConfig && additionalProperties == other.additionalProperties /* spotless:on */ + return other is GroupedTieredConfig && + additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1316,7 +1315,7 @@ private constructor( return true } - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + return other is ModelType && value == other.value } override fun hashCode() = value.hashCode() @@ -1406,10 +1405,10 @@ private constructor( return true } - return /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ + return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(unit, tiered) override fun toString(): String = when { @@ -1585,12 +1584,10 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1602,12 +1599,51 @@ private constructor( return true } - return /* spotless:off */ other is NewPlanGroupedTieredPrice && cadence == other.cadence && groupedTieredConfig == other.groupedTieredConfig && itemId == other.itemId && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && conversionRateConfig == other.conversionRateConfig && currency == other.currency && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + return other is NewPlanGroupedTieredPrice && + cadence == other.cadence && + groupedTieredConfig == other.groupedTieredConfig && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, groupedTieredConfig, itemId, modelType, name, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, conversionRateConfig, currency, dimensionalPriceConfiguration, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, referenceId, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + cadence, + groupedTieredConfig, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanGroupedWithMeteredMinimumPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanGroupedWithMeteredMinimumPrice.kt index 4ded74694..d4635d572 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanGroupedWithMeteredMinimumPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanGroupedWithMeteredMinimumPrice.kt @@ -1108,7 +1108,7 @@ private constructor( return true } - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + return other is Cadence && value == other.value } override fun hashCode() = value.hashCode() @@ -1209,12 +1209,11 @@ private constructor( return true } - return /* spotless:off */ other is GroupedWithMeteredMinimumConfig && additionalProperties == other.additionalProperties /* spotless:on */ + return other is GroupedWithMeteredMinimumConfig && + additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1334,7 +1333,7 @@ private constructor( return true } - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + return other is ModelType && value == other.value } override fun hashCode() = value.hashCode() @@ -1424,10 +1423,10 @@ private constructor( return true } - return /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ + return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(unit, tiered) override fun toString(): String = when { @@ -1603,12 +1602,10 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1620,12 +1617,51 @@ private constructor( return true } - return /* spotless:off */ other is NewPlanGroupedWithMeteredMinimumPrice && cadence == other.cadence && groupedWithMeteredMinimumConfig == other.groupedWithMeteredMinimumConfig && itemId == other.itemId && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && conversionRateConfig == other.conversionRateConfig && currency == other.currency && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + return other is NewPlanGroupedWithMeteredMinimumPrice && + cadence == other.cadence && + groupedWithMeteredMinimumConfig == other.groupedWithMeteredMinimumConfig && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, groupedWithMeteredMinimumConfig, itemId, modelType, name, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, conversionRateConfig, currency, dimensionalPriceConfiguration, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, referenceId, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + cadence, + groupedWithMeteredMinimumConfig, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanGroupedWithProratedMinimumPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanGroupedWithProratedMinimumPrice.kt index 9c0d45e81..93240a2bc 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanGroupedWithProratedMinimumPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanGroupedWithProratedMinimumPrice.kt @@ -1108,7 +1108,7 @@ private constructor( return true } - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + return other is Cadence && value == other.value } override fun hashCode() = value.hashCode() @@ -1209,12 +1209,11 @@ private constructor( return true } - return /* spotless:off */ other is GroupedWithProratedMinimumConfig && additionalProperties == other.additionalProperties /* spotless:on */ + return other is GroupedWithProratedMinimumConfig && + additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1334,7 +1333,7 @@ private constructor( return true } - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + return other is ModelType && value == other.value } override fun hashCode() = value.hashCode() @@ -1424,10 +1423,10 @@ private constructor( return true } - return /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ + return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(unit, tiered) override fun toString(): String = when { @@ -1603,12 +1602,10 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1620,12 +1617,51 @@ private constructor( return true } - return /* spotless:off */ other is NewPlanGroupedWithProratedMinimumPrice && cadence == other.cadence && groupedWithProratedMinimumConfig == other.groupedWithProratedMinimumConfig && itemId == other.itemId && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && conversionRateConfig == other.conversionRateConfig && currency == other.currency && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + return other is NewPlanGroupedWithProratedMinimumPrice && + cadence == other.cadence && + groupedWithProratedMinimumConfig == other.groupedWithProratedMinimumConfig && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, groupedWithProratedMinimumConfig, itemId, modelType, name, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, conversionRateConfig, currency, dimensionalPriceConfiguration, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, referenceId, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + cadence, + groupedWithProratedMinimumConfig, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanMatrixPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanMatrixPrice.kt index f68a5680a..0e27c274c 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanMatrixPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanMatrixPrice.kt @@ -1093,7 +1093,7 @@ private constructor( return true } - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + return other is Cadence && value == other.value } override fun hashCode() = value.hashCode() @@ -1213,7 +1213,7 @@ private constructor( return true } - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + return other is ModelType && value == other.value } override fun hashCode() = value.hashCode() @@ -1303,10 +1303,10 @@ private constructor( return true } - return /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ + return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(unit, tiered) override fun toString(): String = when { @@ -1482,12 +1482,10 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1499,12 +1497,51 @@ private constructor( return true } - return /* spotless:off */ other is NewPlanMatrixPrice && cadence == other.cadence && itemId == other.itemId && matrixConfig == other.matrixConfig && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && conversionRateConfig == other.conversionRateConfig && currency == other.currency && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + return other is NewPlanMatrixPrice && + cadence == other.cadence && + itemId == other.itemId && + matrixConfig == other.matrixConfig && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, itemId, matrixConfig, modelType, name, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, conversionRateConfig, currency, dimensionalPriceConfiguration, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, referenceId, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + matrixConfig, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanMatrixWithAllocationPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanMatrixWithAllocationPrice.kt index c11a920b3..4882354a6 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanMatrixWithAllocationPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanMatrixWithAllocationPrice.kt @@ -1104,7 +1104,7 @@ private constructor( return true } - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + return other is Cadence && value == other.value } override fun hashCode() = value.hashCode() @@ -1224,7 +1224,7 @@ private constructor( return true } - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + return other is ModelType && value == other.value } override fun hashCode() = value.hashCode() @@ -1314,10 +1314,10 @@ private constructor( return true } - return /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ + return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(unit, tiered) override fun toString(): String = when { @@ -1493,12 +1493,10 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1510,12 +1508,51 @@ private constructor( return true } - return /* spotless:off */ other is NewPlanMatrixWithAllocationPrice && cadence == other.cadence && itemId == other.itemId && matrixWithAllocationConfig == other.matrixWithAllocationConfig && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && conversionRateConfig == other.conversionRateConfig && currency == other.currency && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + return other is NewPlanMatrixWithAllocationPrice && + cadence == other.cadence && + itemId == other.itemId && + matrixWithAllocationConfig == other.matrixWithAllocationConfig && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, itemId, matrixWithAllocationConfig, modelType, name, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, conversionRateConfig, currency, dimensionalPriceConfiguration, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, referenceId, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + matrixWithAllocationConfig, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanMatrixWithDisplayNamePrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanMatrixWithDisplayNamePrice.kt index d638f8e2a..5a586d8bc 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanMatrixWithDisplayNamePrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanMatrixWithDisplayNamePrice.kt @@ -1104,7 +1104,7 @@ private constructor( return true } - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + return other is Cadence && value == other.value } override fun hashCode() = value.hashCode() @@ -1204,12 +1204,11 @@ private constructor( return true } - return /* spotless:off */ other is MatrixWithDisplayNameConfig && additionalProperties == other.additionalProperties /* spotless:on */ + return other is MatrixWithDisplayNameConfig && + additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1329,7 +1328,7 @@ private constructor( return true } - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + return other is ModelType && value == other.value } override fun hashCode() = value.hashCode() @@ -1419,10 +1418,10 @@ private constructor( return true } - return /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ + return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(unit, tiered) override fun toString(): String = when { @@ -1598,12 +1597,10 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1615,12 +1612,51 @@ private constructor( return true } - return /* spotless:off */ other is NewPlanMatrixWithDisplayNamePrice && cadence == other.cadence && itemId == other.itemId && matrixWithDisplayNameConfig == other.matrixWithDisplayNameConfig && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && conversionRateConfig == other.conversionRateConfig && currency == other.currency && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + return other is NewPlanMatrixWithDisplayNamePrice && + cadence == other.cadence && + itemId == other.itemId && + matrixWithDisplayNameConfig == other.matrixWithDisplayNameConfig && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, itemId, matrixWithDisplayNameConfig, modelType, name, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, conversionRateConfig, currency, dimensionalPriceConfiguration, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, referenceId, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + matrixWithDisplayNameConfig, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanMaxGroupTieredPackagePrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanMaxGroupTieredPackagePrice.kt index 14349ec29..a9a1d06cb 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanMaxGroupTieredPackagePrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanMaxGroupTieredPackagePrice.kt @@ -1104,7 +1104,7 @@ private constructor( return true } - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + return other is Cadence && value == other.value } override fun hashCode() = value.hashCode() @@ -1204,12 +1204,11 @@ private constructor( return true } - return /* spotless:off */ other is MaxGroupTieredPackageConfig && additionalProperties == other.additionalProperties /* spotless:on */ + return other is MaxGroupTieredPackageConfig && + additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1329,7 +1328,7 @@ private constructor( return true } - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + return other is ModelType && value == other.value } override fun hashCode() = value.hashCode() @@ -1419,10 +1418,10 @@ private constructor( return true } - return /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ + return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(unit, tiered) override fun toString(): String = when { @@ -1598,12 +1597,10 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1615,12 +1612,51 @@ private constructor( return true } - return /* spotless:off */ other is NewPlanMaxGroupTieredPackagePrice && cadence == other.cadence && itemId == other.itemId && maxGroupTieredPackageConfig == other.maxGroupTieredPackageConfig && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && conversionRateConfig == other.conversionRateConfig && currency == other.currency && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + return other is NewPlanMaxGroupTieredPackagePrice && + cadence == other.cadence && + itemId == other.itemId && + maxGroupTieredPackageConfig == other.maxGroupTieredPackageConfig && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, itemId, maxGroupTieredPackageConfig, modelType, name, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, conversionRateConfig, currency, dimensionalPriceConfiguration, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, referenceId, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + maxGroupTieredPackageConfig, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanPackagePrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanPackagePrice.kt index 7ddce003b..4404ca0dc 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanPackagePrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanPackagePrice.kt @@ -1093,7 +1093,7 @@ private constructor( return true } - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + return other is Cadence && value == other.value } override fun hashCode() = value.hashCode() @@ -1213,7 +1213,7 @@ private constructor( return true } - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + return other is ModelType && value == other.value } override fun hashCode() = value.hashCode() @@ -1303,10 +1303,10 @@ private constructor( return true } - return /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ + return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(unit, tiered) override fun toString(): String = when { @@ -1482,12 +1482,10 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1499,12 +1497,51 @@ private constructor( return true } - return /* spotless:off */ other is NewPlanPackagePrice && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && packageConfig == other.packageConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && conversionRateConfig == other.conversionRateConfig && currency == other.currency && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + return other is NewPlanPackagePrice && + cadence == other.cadence && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + packageConfig == other.packageConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, itemId, modelType, name, packageConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, conversionRateConfig, currency, dimensionalPriceConfiguration, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, referenceId, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + modelType, + name, + packageConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanPackageWithAllocationPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanPackageWithAllocationPrice.kt index 1d379d287..c3d3be813 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanPackageWithAllocationPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanPackageWithAllocationPrice.kt @@ -1104,7 +1104,7 @@ private constructor( return true } - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + return other is Cadence && value == other.value } override fun hashCode() = value.hashCode() @@ -1224,7 +1224,7 @@ private constructor( return true } - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + return other is ModelType && value == other.value } override fun hashCode() = value.hashCode() @@ -1324,12 +1324,11 @@ private constructor( return true } - return /* spotless:off */ other is PackageWithAllocationConfig && additionalProperties == other.additionalProperties /* spotless:on */ + return other is PackageWithAllocationConfig && + additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1419,10 +1418,10 @@ private constructor( return true } - return /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ + return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(unit, tiered) override fun toString(): String = when { @@ -1598,12 +1597,10 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1615,12 +1612,51 @@ private constructor( return true } - return /* spotless:off */ other is NewPlanPackageWithAllocationPrice && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && packageWithAllocationConfig == other.packageWithAllocationConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && conversionRateConfig == other.conversionRateConfig && currency == other.currency && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + return other is NewPlanPackageWithAllocationPrice && + cadence == other.cadence && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + packageWithAllocationConfig == other.packageWithAllocationConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, itemId, modelType, name, packageWithAllocationConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, conversionRateConfig, currency, dimensionalPriceConfiguration, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, referenceId, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + modelType, + name, + packageWithAllocationConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanScalableMatrixWithTieredPricingPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanScalableMatrixWithTieredPricingPrice.kt index 43854c725..15e1563c4 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanScalableMatrixWithTieredPricingPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanScalableMatrixWithTieredPricingPrice.kt @@ -1120,7 +1120,7 @@ private constructor( return true } - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + return other is Cadence && value == other.value } override fun hashCode() = value.hashCode() @@ -1240,7 +1240,7 @@ private constructor( return true } - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + return other is ModelType && value == other.value } override fun hashCode() = value.hashCode() @@ -1342,12 +1342,11 @@ private constructor( return true } - return /* spotless:off */ other is ScalableMatrixWithTieredPricingConfig && additionalProperties == other.additionalProperties /* spotless:on */ + return other is ScalableMatrixWithTieredPricingConfig && + additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1437,10 +1436,10 @@ private constructor( return true } - return /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ + return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(unit, tiered) override fun toString(): String = when { @@ -1616,12 +1615,10 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1633,12 +1630,51 @@ private constructor( return true } - return /* spotless:off */ other is NewPlanScalableMatrixWithTieredPricingPrice && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && scalableMatrixWithTieredPricingConfig == other.scalableMatrixWithTieredPricingConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && conversionRateConfig == other.conversionRateConfig && currency == other.currency && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + return other is NewPlanScalableMatrixWithTieredPricingPrice && + cadence == other.cadence && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + scalableMatrixWithTieredPricingConfig == other.scalableMatrixWithTieredPricingConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, itemId, modelType, name, scalableMatrixWithTieredPricingConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, conversionRateConfig, currency, dimensionalPriceConfiguration, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, referenceId, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + modelType, + name, + scalableMatrixWithTieredPricingConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanScalableMatrixWithUnitPricingPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanScalableMatrixWithUnitPricingPrice.kt index f4f08764f..9b8f540a1 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanScalableMatrixWithUnitPricingPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanScalableMatrixWithUnitPricingPrice.kt @@ -1112,7 +1112,7 @@ private constructor( return true } - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + return other is Cadence && value == other.value } override fun hashCode() = value.hashCode() @@ -1232,7 +1232,7 @@ private constructor( return true } - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + return other is ModelType && value == other.value } override fun hashCode() = value.hashCode() @@ -1334,12 +1334,11 @@ private constructor( return true } - return /* spotless:off */ other is ScalableMatrixWithUnitPricingConfig && additionalProperties == other.additionalProperties /* spotless:on */ + return other is ScalableMatrixWithUnitPricingConfig && + additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1429,10 +1428,10 @@ private constructor( return true } - return /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ + return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(unit, tiered) override fun toString(): String = when { @@ -1608,12 +1607,10 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1625,12 +1622,51 @@ private constructor( return true } - return /* spotless:off */ other is NewPlanScalableMatrixWithUnitPricingPrice && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && scalableMatrixWithUnitPricingConfig == other.scalableMatrixWithUnitPricingConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && conversionRateConfig == other.conversionRateConfig && currency == other.currency && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + return other is NewPlanScalableMatrixWithUnitPricingPrice && + cadence == other.cadence && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + scalableMatrixWithUnitPricingConfig == other.scalableMatrixWithUnitPricingConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, itemId, modelType, name, scalableMatrixWithUnitPricingConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, conversionRateConfig, currency, dimensionalPriceConfiguration, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, referenceId, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + modelType, + name, + scalableMatrixWithUnitPricingConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanThresholdTotalAmountPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanThresholdTotalAmountPrice.kt index 79b909ae6..ec6c68ce5 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanThresholdTotalAmountPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanThresholdTotalAmountPrice.kt @@ -1104,7 +1104,7 @@ private constructor( return true } - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + return other is Cadence && value == other.value } override fun hashCode() = value.hashCode() @@ -1224,7 +1224,7 @@ private constructor( return true } - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + return other is ModelType && value == other.value } override fun hashCode() = value.hashCode() @@ -1324,12 +1324,11 @@ private constructor( return true } - return /* spotless:off */ other is ThresholdTotalAmountConfig && additionalProperties == other.additionalProperties /* spotless:on */ + return other is ThresholdTotalAmountConfig && + additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1419,10 +1418,10 @@ private constructor( return true } - return /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ + return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(unit, tiered) override fun toString(): String = when { @@ -1598,12 +1597,10 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1615,12 +1612,51 @@ private constructor( return true } - return /* spotless:off */ other is NewPlanThresholdTotalAmountPrice && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && thresholdTotalAmountConfig == other.thresholdTotalAmountConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && conversionRateConfig == other.conversionRateConfig && currency == other.currency && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + return other is NewPlanThresholdTotalAmountPrice && + cadence == other.cadence && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + thresholdTotalAmountConfig == other.thresholdTotalAmountConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, itemId, modelType, name, thresholdTotalAmountConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, conversionRateConfig, currency, dimensionalPriceConfiguration, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, referenceId, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + modelType, + name, + thresholdTotalAmountConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanTierWithProrationPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanTierWithProrationPrice.kt index e782385d8..53911e4b4 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanTierWithProrationPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanTierWithProrationPrice.kt @@ -1099,7 +1099,7 @@ private constructor( return true } - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + return other is Cadence && value == other.value } override fun hashCode() = value.hashCode() @@ -1219,7 +1219,7 @@ private constructor( return true } - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + return other is ModelType && value == other.value } override fun hashCode() = value.hashCode() @@ -1318,12 +1318,11 @@ private constructor( return true } - return /* spotless:off */ other is TieredWithProrationConfig && additionalProperties == other.additionalProperties /* spotless:on */ + return other is TieredWithProrationConfig && + additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1413,10 +1412,10 @@ private constructor( return true } - return /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ + return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(unit, tiered) override fun toString(): String = when { @@ -1592,12 +1591,10 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1609,12 +1606,51 @@ private constructor( return true } - return /* spotless:off */ other is NewPlanTierWithProrationPrice && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && tieredWithProrationConfig == other.tieredWithProrationConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && conversionRateConfig == other.conversionRateConfig && currency == other.currency && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + return other is NewPlanTierWithProrationPrice && + cadence == other.cadence && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + tieredWithProrationConfig == other.tieredWithProrationConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, itemId, modelType, name, tieredWithProrationConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, conversionRateConfig, currency, dimensionalPriceConfiguration, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, referenceId, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + modelType, + name, + tieredWithProrationConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanTieredBpsPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanTieredBpsPrice.kt index edca5a4dc..b53f55648 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanTieredBpsPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanTieredBpsPrice.kt @@ -1094,7 +1094,7 @@ private constructor( return true } - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + return other is Cadence && value == other.value } override fun hashCode() = value.hashCode() @@ -1214,7 +1214,7 @@ private constructor( return true } - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + return other is ModelType && value == other.value } override fun hashCode() = value.hashCode() @@ -1304,10 +1304,10 @@ private constructor( return true } - return /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ + return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(unit, tiered) override fun toString(): String = when { @@ -1483,12 +1483,10 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1500,12 +1498,51 @@ private constructor( return true } - return /* spotless:off */ other is NewPlanTieredBpsPrice && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && tieredBpsConfig == other.tieredBpsConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && conversionRateConfig == other.conversionRateConfig && currency == other.currency && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + return other is NewPlanTieredBpsPrice && + cadence == other.cadence && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + tieredBpsConfig == other.tieredBpsConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, itemId, modelType, name, tieredBpsConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, conversionRateConfig, currency, dimensionalPriceConfiguration, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, referenceId, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + modelType, + name, + tieredBpsConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanTieredPackagePrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanTieredPackagePrice.kt index 413f6a1b9..c72ee82e3 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanTieredPackagePrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanTieredPackagePrice.kt @@ -1096,7 +1096,7 @@ private constructor( return true } - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + return other is Cadence && value == other.value } override fun hashCode() = value.hashCode() @@ -1216,7 +1216,7 @@ private constructor( return true } - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + return other is ModelType && value == other.value } override fun hashCode() = value.hashCode() @@ -1312,12 +1312,11 @@ private constructor( return true } - return /* spotless:off */ other is TieredPackageConfig && additionalProperties == other.additionalProperties /* spotless:on */ + return other is TieredPackageConfig && + additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1406,10 +1405,10 @@ private constructor( return true } - return /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ + return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(unit, tiered) override fun toString(): String = when { @@ -1585,12 +1584,10 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1602,12 +1599,51 @@ private constructor( return true } - return /* spotless:off */ other is NewPlanTieredPackagePrice && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && tieredPackageConfig == other.tieredPackageConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && conversionRateConfig == other.conversionRateConfig && currency == other.currency && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + return other is NewPlanTieredPackagePrice && + cadence == other.cadence && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + tieredPackageConfig == other.tieredPackageConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, itemId, modelType, name, tieredPackageConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, conversionRateConfig, currency, dimensionalPriceConfiguration, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, referenceId, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + modelType, + name, + tieredPackageConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanTieredPackageWithMinimumPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanTieredPackageWithMinimumPrice.kt index fd381ddb0..5a9e48a73 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanTieredPackageWithMinimumPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanTieredPackageWithMinimumPrice.kt @@ -1108,7 +1108,7 @@ private constructor( return true } - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + return other is Cadence && value == other.value } override fun hashCode() = value.hashCode() @@ -1228,7 +1228,7 @@ private constructor( return true } - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + return other is ModelType && value == other.value } override fun hashCode() = value.hashCode() @@ -1329,12 +1329,11 @@ private constructor( return true } - return /* spotless:off */ other is TieredPackageWithMinimumConfig && additionalProperties == other.additionalProperties /* spotless:on */ + return other is TieredPackageWithMinimumConfig && + additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1424,10 +1423,10 @@ private constructor( return true } - return /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ + return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(unit, tiered) override fun toString(): String = when { @@ -1603,12 +1602,10 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1620,12 +1617,51 @@ private constructor( return true } - return /* spotless:off */ other is NewPlanTieredPackageWithMinimumPrice && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && tieredPackageWithMinimumConfig == other.tieredPackageWithMinimumConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && conversionRateConfig == other.conversionRateConfig && currency == other.currency && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + return other is NewPlanTieredPackageWithMinimumPrice && + cadence == other.cadence && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + tieredPackageWithMinimumConfig == other.tieredPackageWithMinimumConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, itemId, modelType, name, tieredPackageWithMinimumConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, conversionRateConfig, currency, dimensionalPriceConfiguration, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, referenceId, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + modelType, + name, + tieredPackageWithMinimumConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanTieredPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanTieredPrice.kt index 61f5e5388..52e7eca1d 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanTieredPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanTieredPrice.kt @@ -1093,7 +1093,7 @@ private constructor( return true } - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + return other is Cadence && value == other.value } override fun hashCode() = value.hashCode() @@ -1213,7 +1213,7 @@ private constructor( return true } - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + return other is ModelType && value == other.value } override fun hashCode() = value.hashCode() @@ -1303,10 +1303,10 @@ private constructor( return true } - return /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ + return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(unit, tiered) override fun toString(): String = when { @@ -1482,12 +1482,10 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1499,12 +1497,51 @@ private constructor( return true } - return /* spotless:off */ other is NewPlanTieredPrice && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && tieredConfig == other.tieredConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && conversionRateConfig == other.conversionRateConfig && currency == other.currency && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + return other is NewPlanTieredPrice && + cadence == other.cadence && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + tieredConfig == other.tieredConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, itemId, modelType, name, tieredConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, conversionRateConfig, currency, dimensionalPriceConfiguration, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, referenceId, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + modelType, + name, + tieredConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanTieredWithMinimumPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanTieredWithMinimumPrice.kt index 6b129bc02..afdd7828c 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanTieredWithMinimumPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanTieredWithMinimumPrice.kt @@ -1099,7 +1099,7 @@ private constructor( return true } - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + return other is Cadence && value == other.value } override fun hashCode() = value.hashCode() @@ -1219,7 +1219,7 @@ private constructor( return true } - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + return other is ModelType && value == other.value } override fun hashCode() = value.hashCode() @@ -1317,12 +1317,11 @@ private constructor( return true } - return /* spotless:off */ other is TieredWithMinimumConfig && additionalProperties == other.additionalProperties /* spotless:on */ + return other is TieredWithMinimumConfig && + additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1412,10 +1411,10 @@ private constructor( return true } - return /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ + return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(unit, tiered) override fun toString(): String = when { @@ -1591,12 +1590,10 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1608,12 +1605,51 @@ private constructor( return true } - return /* spotless:off */ other is NewPlanTieredWithMinimumPrice && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && tieredWithMinimumConfig == other.tieredWithMinimumConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && conversionRateConfig == other.conversionRateConfig && currency == other.currency && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + return other is NewPlanTieredWithMinimumPrice && + cadence == other.cadence && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + tieredWithMinimumConfig == other.tieredWithMinimumConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, itemId, modelType, name, tieredWithMinimumConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, conversionRateConfig, currency, dimensionalPriceConfiguration, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, referenceId, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + modelType, + name, + tieredWithMinimumConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanUnitPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanUnitPrice.kt index c6482b259..d09a2df64 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanUnitPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanUnitPrice.kt @@ -1091,7 +1091,7 @@ private constructor( return true } - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + return other is Cadence && value == other.value } override fun hashCode() = value.hashCode() @@ -1211,7 +1211,7 @@ private constructor( return true } - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + return other is ModelType && value == other.value } override fun hashCode() = value.hashCode() @@ -1301,10 +1301,10 @@ private constructor( return true } - return /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ + return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(unit, tiered) override fun toString(): String = when { @@ -1480,12 +1480,10 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1497,12 +1495,51 @@ private constructor( return true } - return /* spotless:off */ other is NewPlanUnitPrice && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && unitConfig == other.unitConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && conversionRateConfig == other.conversionRateConfig && currency == other.currency && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + return other is NewPlanUnitPrice && + cadence == other.cadence && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + unitConfig == other.unitConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, itemId, modelType, name, unitConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, conversionRateConfig, currency, dimensionalPriceConfiguration, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, referenceId, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + modelType, + name, + unitConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanUnitWithPercentPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanUnitWithPercentPrice.kt index e6fbc8c88..e6a081ab0 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanUnitWithPercentPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanUnitWithPercentPrice.kt @@ -1097,7 +1097,7 @@ private constructor( return true } - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + return other is Cadence && value == other.value } override fun hashCode() = value.hashCode() @@ -1217,7 +1217,7 @@ private constructor( return true } - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + return other is ModelType && value == other.value } override fun hashCode() = value.hashCode() @@ -1315,12 +1315,11 @@ private constructor( return true } - return /* spotless:off */ other is UnitWithPercentConfig && additionalProperties == other.additionalProperties /* spotless:on */ + return other is UnitWithPercentConfig && + additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1410,10 +1409,10 @@ private constructor( return true } - return /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ + return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(unit, tiered) override fun toString(): String = when { @@ -1589,12 +1588,10 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1606,12 +1603,51 @@ private constructor( return true } - return /* spotless:off */ other is NewPlanUnitWithPercentPrice && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && unitWithPercentConfig == other.unitWithPercentConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && conversionRateConfig == other.conversionRateConfig && currency == other.currency && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + return other is NewPlanUnitWithPercentPrice && + cadence == other.cadence && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + unitWithPercentConfig == other.unitWithPercentConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, itemId, modelType, name, unitWithPercentConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, conversionRateConfig, currency, dimensionalPriceConfiguration, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, referenceId, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + modelType, + name, + unitWithPercentConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanUnitWithProrationPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanUnitWithProrationPrice.kt index 172894d71..98890f475 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanUnitWithProrationPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanUnitWithProrationPrice.kt @@ -1099,7 +1099,7 @@ private constructor( return true } - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + return other is Cadence && value == other.value } override fun hashCode() = value.hashCode() @@ -1219,7 +1219,7 @@ private constructor( return true } - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + return other is ModelType && value == other.value } override fun hashCode() = value.hashCode() @@ -1317,12 +1317,11 @@ private constructor( return true } - return /* spotless:off */ other is UnitWithProrationConfig && additionalProperties == other.additionalProperties /* spotless:on */ + return other is UnitWithProrationConfig && + additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1412,10 +1411,10 @@ private constructor( return true } - return /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ + return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(unit, tiered) override fun toString(): String = when { @@ -1591,12 +1590,10 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1608,12 +1605,51 @@ private constructor( return true } - return /* spotless:off */ other is NewPlanUnitWithProrationPrice && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && unitWithProrationConfig == other.unitWithProrationConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && conversionRateConfig == other.conversionRateConfig && currency == other.currency && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + return other is NewPlanUnitWithProrationPrice && + cadence == other.cadence && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + unitWithProrationConfig == other.unitWithProrationConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, itemId, modelType, name, unitWithProrationConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, conversionRateConfig, currency, dimensionalPriceConfiguration, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, referenceId, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + modelType, + name, + unitWithProrationConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewReportingConfiguration.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewReportingConfiguration.kt index 930dc6867..13166ace1 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewReportingConfiguration.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewReportingConfiguration.kt @@ -154,12 +154,12 @@ private constructor( return true } - return /* spotless:off */ other is NewReportingConfiguration && exempt == other.exempt && additionalProperties == other.additionalProperties /* spotless:on */ + return other is NewReportingConfiguration && + exempt == other.exempt && + additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(exempt, additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSphereConfiguration.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSphereConfiguration.kt index 35d237880..15ebd33e8 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSphereConfiguration.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSphereConfiguration.kt @@ -305,7 +305,7 @@ private constructor( return true } - return /* spotless:off */ other is TaxProvider && value == other.value /* spotless:on */ + return other is TaxProvider && value == other.value } override fun hashCode() = value.hashCode() @@ -318,12 +318,13 @@ private constructor( return true } - return /* spotless:off */ other is NewSphereConfiguration && taxExempt == other.taxExempt && taxProvider == other.taxProvider && additionalProperties == other.additionalProperties /* spotless:on */ + return other is NewSphereConfiguration && + taxExempt == other.taxExempt && + taxProvider == other.taxProvider && + additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(taxExempt, taxProvider, additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionBpsPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionBpsPrice.kt index 125217d4d..ed3826f8a 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionBpsPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionBpsPrice.kt @@ -1089,7 +1089,7 @@ private constructor( return true } - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + return other is Cadence && value == other.value } override fun hashCode() = value.hashCode() @@ -1209,7 +1209,7 @@ private constructor( return true } - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + return other is ModelType && value == other.value } override fun hashCode() = value.hashCode() @@ -1299,10 +1299,10 @@ private constructor( return true } - return /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ + return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(unit, tiered) override fun toString(): String = when { @@ -1478,12 +1478,10 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1495,12 +1493,51 @@ private constructor( return true } - return /* spotless:off */ other is NewSubscriptionBpsPrice && bpsConfig == other.bpsConfig && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && conversionRateConfig == other.conversionRateConfig && currency == other.currency && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + return other is NewSubscriptionBpsPrice && + bpsConfig == other.bpsConfig && + cadence == other.cadence && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(bpsConfig, cadence, itemId, modelType, name, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, conversionRateConfig, currency, dimensionalPriceConfiguration, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, referenceId, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + bpsConfig, + cadence, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionBulkBpsPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionBulkBpsPrice.kt index 518ea20f4..6b3444985 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionBulkBpsPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionBulkBpsPrice.kt @@ -1094,7 +1094,7 @@ private constructor( return true } - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + return other is Cadence && value == other.value } override fun hashCode() = value.hashCode() @@ -1214,7 +1214,7 @@ private constructor( return true } - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + return other is ModelType && value == other.value } override fun hashCode() = value.hashCode() @@ -1304,10 +1304,10 @@ private constructor( return true } - return /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ + return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(unit, tiered) override fun toString(): String = when { @@ -1483,12 +1483,10 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1500,12 +1498,51 @@ private constructor( return true } - return /* spotless:off */ other is NewSubscriptionBulkBpsPrice && bulkBpsConfig == other.bulkBpsConfig && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && conversionRateConfig == other.conversionRateConfig && currency == other.currency && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + return other is NewSubscriptionBulkBpsPrice && + bulkBpsConfig == other.bulkBpsConfig && + cadence == other.cadence && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(bulkBpsConfig, cadence, itemId, modelType, name, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, conversionRateConfig, currency, dimensionalPriceConfiguration, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, referenceId, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + bulkBpsConfig, + cadence, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionBulkPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionBulkPrice.kt index 4fa9b17b0..6bd67fcc1 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionBulkPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionBulkPrice.kt @@ -1091,7 +1091,7 @@ private constructor( return true } - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + return other is Cadence && value == other.value } override fun hashCode() = value.hashCode() @@ -1211,7 +1211,7 @@ private constructor( return true } - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + return other is ModelType && value == other.value } override fun hashCode() = value.hashCode() @@ -1301,10 +1301,10 @@ private constructor( return true } - return /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ + return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(unit, tiered) override fun toString(): String = when { @@ -1480,12 +1480,10 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1497,12 +1495,51 @@ private constructor( return true } - return /* spotless:off */ other is NewSubscriptionBulkPrice && bulkConfig == other.bulkConfig && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && conversionRateConfig == other.conversionRateConfig && currency == other.currency && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + return other is NewSubscriptionBulkPrice && + bulkConfig == other.bulkConfig && + cadence == other.cadence && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(bulkConfig, cadence, itemId, modelType, name, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, conversionRateConfig, currency, dimensionalPriceConfiguration, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, referenceId, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + bulkConfig, + cadence, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionBulkWithProrationPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionBulkWithProrationPrice.kt index fddea7912..1aade5342 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionBulkWithProrationPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionBulkWithProrationPrice.kt @@ -1053,12 +1053,11 @@ private constructor( return true } - return /* spotless:off */ other is BulkWithProrationConfig && additionalProperties == other.additionalProperties /* spotless:on */ + return other is BulkWithProrationConfig && + additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1207,7 +1206,7 @@ private constructor( return true } - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + return other is Cadence && value == other.value } override fun hashCode() = value.hashCode() @@ -1327,7 +1326,7 @@ private constructor( return true } - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + return other is ModelType && value == other.value } override fun hashCode() = value.hashCode() @@ -1417,10 +1416,10 @@ private constructor( return true } - return /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ + return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(unit, tiered) override fun toString(): String = when { @@ -1596,12 +1595,10 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1613,12 +1610,51 @@ private constructor( return true } - return /* spotless:off */ other is NewSubscriptionBulkWithProrationPrice && bulkWithProrationConfig == other.bulkWithProrationConfig && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && conversionRateConfig == other.conversionRateConfig && currency == other.currency && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + return other is NewSubscriptionBulkWithProrationPrice && + bulkWithProrationConfig == other.bulkWithProrationConfig && + cadence == other.cadence && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(bulkWithProrationConfig, cadence, itemId, modelType, name, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, conversionRateConfig, currency, dimensionalPriceConfiguration, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, referenceId, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + bulkWithProrationConfig, + cadence, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionCumulativeGroupedBulkPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionCumulativeGroupedBulkPrice.kt index 02a96c175..21eb24b3a 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionCumulativeGroupedBulkPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionCumulativeGroupedBulkPrice.kt @@ -1105,7 +1105,7 @@ private constructor( return true } - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + return other is Cadence && value == other.value } override fun hashCode() = value.hashCode() @@ -1205,12 +1205,11 @@ private constructor( return true } - return /* spotless:off */ other is CumulativeGroupedBulkConfig && additionalProperties == other.additionalProperties /* spotless:on */ + return other is CumulativeGroupedBulkConfig && + additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1330,7 +1329,7 @@ private constructor( return true } - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + return other is ModelType && value == other.value } override fun hashCode() = value.hashCode() @@ -1420,10 +1419,10 @@ private constructor( return true } - return /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ + return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(unit, tiered) override fun toString(): String = when { @@ -1599,12 +1598,10 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1616,12 +1613,51 @@ private constructor( return true } - return /* spotless:off */ other is NewSubscriptionCumulativeGroupedBulkPrice && cadence == other.cadence && cumulativeGroupedBulkConfig == other.cumulativeGroupedBulkConfig && itemId == other.itemId && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && conversionRateConfig == other.conversionRateConfig && currency == other.currency && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + return other is NewSubscriptionCumulativeGroupedBulkPrice && + cadence == other.cadence && + cumulativeGroupedBulkConfig == other.cumulativeGroupedBulkConfig && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, cumulativeGroupedBulkConfig, itemId, modelType, name, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, conversionRateConfig, currency, dimensionalPriceConfiguration, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, referenceId, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + cadence, + cumulativeGroupedBulkConfig, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionGroupedAllocationPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionGroupedAllocationPrice.kt index d8bc0308f..ca07438cc 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionGroupedAllocationPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionGroupedAllocationPrice.kt @@ -1104,7 +1104,7 @@ private constructor( return true } - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + return other is Cadence && value == other.value } override fun hashCode() = value.hashCode() @@ -1202,12 +1202,11 @@ private constructor( return true } - return /* spotless:off */ other is GroupedAllocationConfig && additionalProperties == other.additionalProperties /* spotless:on */ + return other is GroupedAllocationConfig && + additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1327,7 +1326,7 @@ private constructor( return true } - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + return other is ModelType && value == other.value } override fun hashCode() = value.hashCode() @@ -1417,10 +1416,10 @@ private constructor( return true } - return /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ + return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(unit, tiered) override fun toString(): String = when { @@ -1596,12 +1595,10 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1613,12 +1610,51 @@ private constructor( return true } - return /* spotless:off */ other is NewSubscriptionGroupedAllocationPrice && cadence == other.cadence && groupedAllocationConfig == other.groupedAllocationConfig && itemId == other.itemId && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && conversionRateConfig == other.conversionRateConfig && currency == other.currency && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + return other is NewSubscriptionGroupedAllocationPrice && + cadence == other.cadence && + groupedAllocationConfig == other.groupedAllocationConfig && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, groupedAllocationConfig, itemId, modelType, name, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, conversionRateConfig, currency, dimensionalPriceConfiguration, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, referenceId, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + cadence, + groupedAllocationConfig, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionGroupedTieredPackagePrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionGroupedTieredPackagePrice.kt index 55b9cd6cf..eec34db96 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionGroupedTieredPackagePrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionGroupedTieredPackagePrice.kt @@ -1105,7 +1105,7 @@ private constructor( return true } - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + return other is Cadence && value == other.value } override fun hashCode() = value.hashCode() @@ -1205,12 +1205,11 @@ private constructor( return true } - return /* spotless:off */ other is GroupedTieredPackageConfig && additionalProperties == other.additionalProperties /* spotless:on */ + return other is GroupedTieredPackageConfig && + additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1330,7 +1329,7 @@ private constructor( return true } - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + return other is ModelType && value == other.value } override fun hashCode() = value.hashCode() @@ -1420,10 +1419,10 @@ private constructor( return true } - return /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ + return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(unit, tiered) override fun toString(): String = when { @@ -1599,12 +1598,10 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1616,12 +1613,51 @@ private constructor( return true } - return /* spotless:off */ other is NewSubscriptionGroupedTieredPackagePrice && cadence == other.cadence && groupedTieredPackageConfig == other.groupedTieredPackageConfig && itemId == other.itemId && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && conversionRateConfig == other.conversionRateConfig && currency == other.currency && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + return other is NewSubscriptionGroupedTieredPackagePrice && + cadence == other.cadence && + groupedTieredPackageConfig == other.groupedTieredPackageConfig && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, groupedTieredPackageConfig, itemId, modelType, name, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, conversionRateConfig, currency, dimensionalPriceConfiguration, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, referenceId, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + cadence, + groupedTieredPackageConfig, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionGroupedTieredPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionGroupedTieredPrice.kt index da2ae3613..d5e5f0828 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionGroupedTieredPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionGroupedTieredPrice.kt @@ -1102,7 +1102,7 @@ private constructor( return true } - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + return other is Cadence && value == other.value } override fun hashCode() = value.hashCode() @@ -1198,12 +1198,11 @@ private constructor( return true } - return /* spotless:off */ other is GroupedTieredConfig && additionalProperties == other.additionalProperties /* spotless:on */ + return other is GroupedTieredConfig && + additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1322,7 +1321,7 @@ private constructor( return true } - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + return other is ModelType && value == other.value } override fun hashCode() = value.hashCode() @@ -1412,10 +1411,10 @@ private constructor( return true } - return /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ + return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(unit, tiered) override fun toString(): String = when { @@ -1591,12 +1590,10 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1608,12 +1605,51 @@ private constructor( return true } - return /* spotless:off */ other is NewSubscriptionGroupedTieredPrice && cadence == other.cadence && groupedTieredConfig == other.groupedTieredConfig && itemId == other.itemId && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && conversionRateConfig == other.conversionRateConfig && currency == other.currency && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + return other is NewSubscriptionGroupedTieredPrice && + cadence == other.cadence && + groupedTieredConfig == other.groupedTieredConfig && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, groupedTieredConfig, itemId, modelType, name, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, conversionRateConfig, currency, dimensionalPriceConfiguration, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, referenceId, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + cadence, + groupedTieredConfig, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionGroupedWithMeteredMinimumPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionGroupedWithMeteredMinimumPrice.kt index a48c6e80c..7609e791a 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionGroupedWithMeteredMinimumPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionGroupedWithMeteredMinimumPrice.kt @@ -1110,7 +1110,7 @@ private constructor( return true } - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + return other is Cadence && value == other.value } override fun hashCode() = value.hashCode() @@ -1211,12 +1211,11 @@ private constructor( return true } - return /* spotless:off */ other is GroupedWithMeteredMinimumConfig && additionalProperties == other.additionalProperties /* spotless:on */ + return other is GroupedWithMeteredMinimumConfig && + additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1336,7 +1335,7 @@ private constructor( return true } - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + return other is ModelType && value == other.value } override fun hashCode() = value.hashCode() @@ -1426,10 +1425,10 @@ private constructor( return true } - return /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ + return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(unit, tiered) override fun toString(): String = when { @@ -1605,12 +1604,10 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1622,12 +1619,51 @@ private constructor( return true } - return /* spotless:off */ other is NewSubscriptionGroupedWithMeteredMinimumPrice && cadence == other.cadence && groupedWithMeteredMinimumConfig == other.groupedWithMeteredMinimumConfig && itemId == other.itemId && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && conversionRateConfig == other.conversionRateConfig && currency == other.currency && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + return other is NewSubscriptionGroupedWithMeteredMinimumPrice && + cadence == other.cadence && + groupedWithMeteredMinimumConfig == other.groupedWithMeteredMinimumConfig && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, groupedWithMeteredMinimumConfig, itemId, modelType, name, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, conversionRateConfig, currency, dimensionalPriceConfiguration, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, referenceId, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + cadence, + groupedWithMeteredMinimumConfig, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionGroupedWithProratedMinimumPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionGroupedWithProratedMinimumPrice.kt index f436c3d88..557402b67 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionGroupedWithProratedMinimumPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionGroupedWithProratedMinimumPrice.kt @@ -1110,7 +1110,7 @@ private constructor( return true } - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + return other is Cadence && value == other.value } override fun hashCode() = value.hashCode() @@ -1211,12 +1211,11 @@ private constructor( return true } - return /* spotless:off */ other is GroupedWithProratedMinimumConfig && additionalProperties == other.additionalProperties /* spotless:on */ + return other is GroupedWithProratedMinimumConfig && + additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1336,7 +1335,7 @@ private constructor( return true } - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + return other is ModelType && value == other.value } override fun hashCode() = value.hashCode() @@ -1426,10 +1425,10 @@ private constructor( return true } - return /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ + return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(unit, tiered) override fun toString(): String = when { @@ -1605,12 +1604,10 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1622,12 +1619,51 @@ private constructor( return true } - return /* spotless:off */ other is NewSubscriptionGroupedWithProratedMinimumPrice && cadence == other.cadence && groupedWithProratedMinimumConfig == other.groupedWithProratedMinimumConfig && itemId == other.itemId && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && conversionRateConfig == other.conversionRateConfig && currency == other.currency && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + return other is NewSubscriptionGroupedWithProratedMinimumPrice && + cadence == other.cadence && + groupedWithProratedMinimumConfig == other.groupedWithProratedMinimumConfig && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, groupedWithProratedMinimumConfig, itemId, modelType, name, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, conversionRateConfig, currency, dimensionalPriceConfiguration, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, referenceId, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + cadence, + groupedWithProratedMinimumConfig, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionMatrixPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionMatrixPrice.kt index c16e7160e..9ab94dc99 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionMatrixPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionMatrixPrice.kt @@ -1093,7 +1093,7 @@ private constructor( return true } - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + return other is Cadence && value == other.value } override fun hashCode() = value.hashCode() @@ -1213,7 +1213,7 @@ private constructor( return true } - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + return other is ModelType && value == other.value } override fun hashCode() = value.hashCode() @@ -1303,10 +1303,10 @@ private constructor( return true } - return /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ + return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(unit, tiered) override fun toString(): String = when { @@ -1482,12 +1482,10 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1499,12 +1497,51 @@ private constructor( return true } - return /* spotless:off */ other is NewSubscriptionMatrixPrice && cadence == other.cadence && itemId == other.itemId && matrixConfig == other.matrixConfig && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && conversionRateConfig == other.conversionRateConfig && currency == other.currency && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + return other is NewSubscriptionMatrixPrice && + cadence == other.cadence && + itemId == other.itemId && + matrixConfig == other.matrixConfig && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, itemId, matrixConfig, modelType, name, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, conversionRateConfig, currency, dimensionalPriceConfiguration, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, referenceId, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + matrixConfig, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionMatrixWithAllocationPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionMatrixWithAllocationPrice.kt index 82577468e..640070d3d 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionMatrixWithAllocationPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionMatrixWithAllocationPrice.kt @@ -1105,7 +1105,7 @@ private constructor( return true } - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + return other is Cadence && value == other.value } override fun hashCode() = value.hashCode() @@ -1225,7 +1225,7 @@ private constructor( return true } - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + return other is ModelType && value == other.value } override fun hashCode() = value.hashCode() @@ -1315,10 +1315,10 @@ private constructor( return true } - return /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ + return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(unit, tiered) override fun toString(): String = when { @@ -1494,12 +1494,10 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1511,12 +1509,51 @@ private constructor( return true } - return /* spotless:off */ other is NewSubscriptionMatrixWithAllocationPrice && cadence == other.cadence && itemId == other.itemId && matrixWithAllocationConfig == other.matrixWithAllocationConfig && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && conversionRateConfig == other.conversionRateConfig && currency == other.currency && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + return other is NewSubscriptionMatrixWithAllocationPrice && + cadence == other.cadence && + itemId == other.itemId && + matrixWithAllocationConfig == other.matrixWithAllocationConfig && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, itemId, matrixWithAllocationConfig, modelType, name, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, conversionRateConfig, currency, dimensionalPriceConfiguration, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, referenceId, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + matrixWithAllocationConfig, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionMatrixWithDisplayNamePrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionMatrixWithDisplayNamePrice.kt index 54bb66c10..0187af06f 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionMatrixWithDisplayNamePrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionMatrixWithDisplayNamePrice.kt @@ -1105,7 +1105,7 @@ private constructor( return true } - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + return other is Cadence && value == other.value } override fun hashCode() = value.hashCode() @@ -1205,12 +1205,11 @@ private constructor( return true } - return /* spotless:off */ other is MatrixWithDisplayNameConfig && additionalProperties == other.additionalProperties /* spotless:on */ + return other is MatrixWithDisplayNameConfig && + additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1330,7 +1329,7 @@ private constructor( return true } - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + return other is ModelType && value == other.value } override fun hashCode() = value.hashCode() @@ -1420,10 +1419,10 @@ private constructor( return true } - return /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ + return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(unit, tiered) override fun toString(): String = when { @@ -1599,12 +1598,10 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1616,12 +1613,51 @@ private constructor( return true } - return /* spotless:off */ other is NewSubscriptionMatrixWithDisplayNamePrice && cadence == other.cadence && itemId == other.itemId && matrixWithDisplayNameConfig == other.matrixWithDisplayNameConfig && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && conversionRateConfig == other.conversionRateConfig && currency == other.currency && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + return other is NewSubscriptionMatrixWithDisplayNamePrice && + cadence == other.cadence && + itemId == other.itemId && + matrixWithDisplayNameConfig == other.matrixWithDisplayNameConfig && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, itemId, matrixWithDisplayNameConfig, modelType, name, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, conversionRateConfig, currency, dimensionalPriceConfiguration, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, referenceId, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + matrixWithDisplayNameConfig, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionMaxGroupTieredPackagePrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionMaxGroupTieredPackagePrice.kt index a0d371c4e..ffdb6c1f3 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionMaxGroupTieredPackagePrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionMaxGroupTieredPackagePrice.kt @@ -1105,7 +1105,7 @@ private constructor( return true } - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + return other is Cadence && value == other.value } override fun hashCode() = value.hashCode() @@ -1205,12 +1205,11 @@ private constructor( return true } - return /* spotless:off */ other is MaxGroupTieredPackageConfig && additionalProperties == other.additionalProperties /* spotless:on */ + return other is MaxGroupTieredPackageConfig && + additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1330,7 +1329,7 @@ private constructor( return true } - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + return other is ModelType && value == other.value } override fun hashCode() = value.hashCode() @@ -1420,10 +1419,10 @@ private constructor( return true } - return /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ + return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(unit, tiered) override fun toString(): String = when { @@ -1599,12 +1598,10 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1616,12 +1613,51 @@ private constructor( return true } - return /* spotless:off */ other is NewSubscriptionMaxGroupTieredPackagePrice && cadence == other.cadence && itemId == other.itemId && maxGroupTieredPackageConfig == other.maxGroupTieredPackageConfig && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && conversionRateConfig == other.conversionRateConfig && currency == other.currency && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + return other is NewSubscriptionMaxGroupTieredPackagePrice && + cadence == other.cadence && + itemId == other.itemId && + maxGroupTieredPackageConfig == other.maxGroupTieredPackageConfig && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, itemId, maxGroupTieredPackageConfig, modelType, name, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, conversionRateConfig, currency, dimensionalPriceConfiguration, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, referenceId, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + maxGroupTieredPackageConfig, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionPackagePrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionPackagePrice.kt index 00ee6e275..5d5c39be8 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionPackagePrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionPackagePrice.kt @@ -1094,7 +1094,7 @@ private constructor( return true } - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + return other is Cadence && value == other.value } override fun hashCode() = value.hashCode() @@ -1214,7 +1214,7 @@ private constructor( return true } - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + return other is ModelType && value == other.value } override fun hashCode() = value.hashCode() @@ -1304,10 +1304,10 @@ private constructor( return true } - return /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ + return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(unit, tiered) override fun toString(): String = when { @@ -1483,12 +1483,10 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1500,12 +1498,51 @@ private constructor( return true } - return /* spotless:off */ other is NewSubscriptionPackagePrice && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && packageConfig == other.packageConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && conversionRateConfig == other.conversionRateConfig && currency == other.currency && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + return other is NewSubscriptionPackagePrice && + cadence == other.cadence && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + packageConfig == other.packageConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, itemId, modelType, name, packageConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, conversionRateConfig, currency, dimensionalPriceConfiguration, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, referenceId, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + modelType, + name, + packageConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionPackageWithAllocationPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionPackageWithAllocationPrice.kt index 8a41dd903..fab066b26 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionPackageWithAllocationPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionPackageWithAllocationPrice.kt @@ -1105,7 +1105,7 @@ private constructor( return true } - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + return other is Cadence && value == other.value } override fun hashCode() = value.hashCode() @@ -1225,7 +1225,7 @@ private constructor( return true } - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + return other is ModelType && value == other.value } override fun hashCode() = value.hashCode() @@ -1325,12 +1325,11 @@ private constructor( return true } - return /* spotless:off */ other is PackageWithAllocationConfig && additionalProperties == other.additionalProperties /* spotless:on */ + return other is PackageWithAllocationConfig && + additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1420,10 +1419,10 @@ private constructor( return true } - return /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ + return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(unit, tiered) override fun toString(): String = when { @@ -1599,12 +1598,10 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1616,12 +1613,51 @@ private constructor( return true } - return /* spotless:off */ other is NewSubscriptionPackageWithAllocationPrice && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && packageWithAllocationConfig == other.packageWithAllocationConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && conversionRateConfig == other.conversionRateConfig && currency == other.currency && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + return other is NewSubscriptionPackageWithAllocationPrice && + cadence == other.cadence && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + packageWithAllocationConfig == other.packageWithAllocationConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, itemId, modelType, name, packageWithAllocationConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, conversionRateConfig, currency, dimensionalPriceConfiguration, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, referenceId, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + modelType, + name, + packageWithAllocationConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionScalableMatrixWithTieredPricingPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionScalableMatrixWithTieredPricingPrice.kt index 345dc9ffc..406ce7950 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionScalableMatrixWithTieredPricingPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionScalableMatrixWithTieredPricingPrice.kt @@ -1126,7 +1126,7 @@ private constructor( return true } - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + return other is Cadence && value == other.value } override fun hashCode() = value.hashCode() @@ -1246,7 +1246,7 @@ private constructor( return true } - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + return other is ModelType && value == other.value } override fun hashCode() = value.hashCode() @@ -1348,12 +1348,11 @@ private constructor( return true } - return /* spotless:off */ other is ScalableMatrixWithTieredPricingConfig && additionalProperties == other.additionalProperties /* spotless:on */ + return other is ScalableMatrixWithTieredPricingConfig && + additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1443,10 +1442,10 @@ private constructor( return true } - return /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ + return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(unit, tiered) override fun toString(): String = when { @@ -1622,12 +1621,10 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1639,12 +1636,51 @@ private constructor( return true } - return /* spotless:off */ other is NewSubscriptionScalableMatrixWithTieredPricingPrice && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && scalableMatrixWithTieredPricingConfig == other.scalableMatrixWithTieredPricingConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && conversionRateConfig == other.conversionRateConfig && currency == other.currency && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + return other is NewSubscriptionScalableMatrixWithTieredPricingPrice && + cadence == other.cadence && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + scalableMatrixWithTieredPricingConfig == other.scalableMatrixWithTieredPricingConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, itemId, modelType, name, scalableMatrixWithTieredPricingConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, conversionRateConfig, currency, dimensionalPriceConfiguration, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, referenceId, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + modelType, + name, + scalableMatrixWithTieredPricingConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionScalableMatrixWithUnitPricingPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionScalableMatrixWithUnitPricingPrice.kt index 151d8647e..0c1f21392 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionScalableMatrixWithUnitPricingPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionScalableMatrixWithUnitPricingPrice.kt @@ -1118,7 +1118,7 @@ private constructor( return true } - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + return other is Cadence && value == other.value } override fun hashCode() = value.hashCode() @@ -1238,7 +1238,7 @@ private constructor( return true } - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + return other is ModelType && value == other.value } override fun hashCode() = value.hashCode() @@ -1340,12 +1340,11 @@ private constructor( return true } - return /* spotless:off */ other is ScalableMatrixWithUnitPricingConfig && additionalProperties == other.additionalProperties /* spotless:on */ + return other is ScalableMatrixWithUnitPricingConfig && + additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1435,10 +1434,10 @@ private constructor( return true } - return /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ + return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(unit, tiered) override fun toString(): String = when { @@ -1614,12 +1613,10 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1631,12 +1628,51 @@ private constructor( return true } - return /* spotless:off */ other is NewSubscriptionScalableMatrixWithUnitPricingPrice && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && scalableMatrixWithUnitPricingConfig == other.scalableMatrixWithUnitPricingConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && conversionRateConfig == other.conversionRateConfig && currency == other.currency && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + return other is NewSubscriptionScalableMatrixWithUnitPricingPrice && + cadence == other.cadence && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + scalableMatrixWithUnitPricingConfig == other.scalableMatrixWithUnitPricingConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, itemId, modelType, name, scalableMatrixWithUnitPricingConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, conversionRateConfig, currency, dimensionalPriceConfiguration, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, referenceId, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + modelType, + name, + scalableMatrixWithUnitPricingConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionThresholdTotalAmountPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionThresholdTotalAmountPrice.kt index 13b71260b..62a2f89a4 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionThresholdTotalAmountPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionThresholdTotalAmountPrice.kt @@ -1105,7 +1105,7 @@ private constructor( return true } - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + return other is Cadence && value == other.value } override fun hashCode() = value.hashCode() @@ -1225,7 +1225,7 @@ private constructor( return true } - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + return other is ModelType && value == other.value } override fun hashCode() = value.hashCode() @@ -1325,12 +1325,11 @@ private constructor( return true } - return /* spotless:off */ other is ThresholdTotalAmountConfig && additionalProperties == other.additionalProperties /* spotless:on */ + return other is ThresholdTotalAmountConfig && + additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1420,10 +1419,10 @@ private constructor( return true } - return /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ + return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(unit, tiered) override fun toString(): String = when { @@ -1599,12 +1598,10 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1616,12 +1613,51 @@ private constructor( return true } - return /* spotless:off */ other is NewSubscriptionThresholdTotalAmountPrice && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && thresholdTotalAmountConfig == other.thresholdTotalAmountConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && conversionRateConfig == other.conversionRateConfig && currency == other.currency && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + return other is NewSubscriptionThresholdTotalAmountPrice && + cadence == other.cadence && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + thresholdTotalAmountConfig == other.thresholdTotalAmountConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, itemId, modelType, name, thresholdTotalAmountConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, conversionRateConfig, currency, dimensionalPriceConfiguration, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, referenceId, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + modelType, + name, + thresholdTotalAmountConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTierWithProrationPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTierWithProrationPrice.kt index 80b5ce661..4eb6b13d4 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTierWithProrationPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTierWithProrationPrice.kt @@ -1105,7 +1105,7 @@ private constructor( return true } - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + return other is Cadence && value == other.value } override fun hashCode() = value.hashCode() @@ -1225,7 +1225,7 @@ private constructor( return true } - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + return other is ModelType && value == other.value } override fun hashCode() = value.hashCode() @@ -1324,12 +1324,11 @@ private constructor( return true } - return /* spotless:off */ other is TieredWithProrationConfig && additionalProperties == other.additionalProperties /* spotless:on */ + return other is TieredWithProrationConfig && + additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1419,10 +1418,10 @@ private constructor( return true } - return /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ + return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(unit, tiered) override fun toString(): String = when { @@ -1598,12 +1597,10 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1615,12 +1612,51 @@ private constructor( return true } - return /* spotless:off */ other is NewSubscriptionTierWithProrationPrice && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && tieredWithProrationConfig == other.tieredWithProrationConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && conversionRateConfig == other.conversionRateConfig && currency == other.currency && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + return other is NewSubscriptionTierWithProrationPrice && + cadence == other.cadence && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + tieredWithProrationConfig == other.tieredWithProrationConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, itemId, modelType, name, tieredWithProrationConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, conversionRateConfig, currency, dimensionalPriceConfiguration, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, referenceId, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + modelType, + name, + tieredWithProrationConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTieredBpsPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTieredBpsPrice.kt index 6bec4f3e7..ad7c43e10 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTieredBpsPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTieredBpsPrice.kt @@ -1096,7 +1096,7 @@ private constructor( return true } - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + return other is Cadence && value == other.value } override fun hashCode() = value.hashCode() @@ -1216,7 +1216,7 @@ private constructor( return true } - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + return other is ModelType && value == other.value } override fun hashCode() = value.hashCode() @@ -1306,10 +1306,10 @@ private constructor( return true } - return /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ + return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(unit, tiered) override fun toString(): String = when { @@ -1485,12 +1485,10 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1502,12 +1500,51 @@ private constructor( return true } - return /* spotless:off */ other is NewSubscriptionTieredBpsPrice && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && tieredBpsConfig == other.tieredBpsConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && conversionRateConfig == other.conversionRateConfig && currency == other.currency && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + return other is NewSubscriptionTieredBpsPrice && + cadence == other.cadence && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + tieredBpsConfig == other.tieredBpsConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, itemId, modelType, name, tieredBpsConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, conversionRateConfig, currency, dimensionalPriceConfiguration, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, referenceId, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + modelType, + name, + tieredBpsConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTieredPackagePrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTieredPackagePrice.kt index b5c4640cc..19987b473 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTieredPackagePrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTieredPackagePrice.kt @@ -1102,7 +1102,7 @@ private constructor( return true } - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + return other is Cadence && value == other.value } override fun hashCode() = value.hashCode() @@ -1222,7 +1222,7 @@ private constructor( return true } - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + return other is ModelType && value == other.value } override fun hashCode() = value.hashCode() @@ -1318,12 +1318,11 @@ private constructor( return true } - return /* spotless:off */ other is TieredPackageConfig && additionalProperties == other.additionalProperties /* spotless:on */ + return other is TieredPackageConfig && + additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1412,10 +1411,10 @@ private constructor( return true } - return /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ + return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(unit, tiered) override fun toString(): String = when { @@ -1591,12 +1590,10 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1608,12 +1605,51 @@ private constructor( return true } - return /* spotless:off */ other is NewSubscriptionTieredPackagePrice && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && tieredPackageConfig == other.tieredPackageConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && conversionRateConfig == other.conversionRateConfig && currency == other.currency && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + return other is NewSubscriptionTieredPackagePrice && + cadence == other.cadence && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + tieredPackageConfig == other.tieredPackageConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, itemId, modelType, name, tieredPackageConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, conversionRateConfig, currency, dimensionalPriceConfiguration, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, referenceId, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + modelType, + name, + tieredPackageConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTieredPackageWithMinimumPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTieredPackageWithMinimumPrice.kt index 45e1564bb..19a979f56 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTieredPackageWithMinimumPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTieredPackageWithMinimumPrice.kt @@ -1109,7 +1109,7 @@ private constructor( return true } - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + return other is Cadence && value == other.value } override fun hashCode() = value.hashCode() @@ -1229,7 +1229,7 @@ private constructor( return true } - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + return other is ModelType && value == other.value } override fun hashCode() = value.hashCode() @@ -1330,12 +1330,11 @@ private constructor( return true } - return /* spotless:off */ other is TieredPackageWithMinimumConfig && additionalProperties == other.additionalProperties /* spotless:on */ + return other is TieredPackageWithMinimumConfig && + additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1425,10 +1424,10 @@ private constructor( return true } - return /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ + return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(unit, tiered) override fun toString(): String = when { @@ -1604,12 +1603,10 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1621,12 +1618,51 @@ private constructor( return true } - return /* spotless:off */ other is NewSubscriptionTieredPackageWithMinimumPrice && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && tieredPackageWithMinimumConfig == other.tieredPackageWithMinimumConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && conversionRateConfig == other.conversionRateConfig && currency == other.currency && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + return other is NewSubscriptionTieredPackageWithMinimumPrice && + cadence == other.cadence && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + tieredPackageWithMinimumConfig == other.tieredPackageWithMinimumConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, itemId, modelType, name, tieredPackageWithMinimumConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, conversionRateConfig, currency, dimensionalPriceConfiguration, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, referenceId, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + modelType, + name, + tieredPackageWithMinimumConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTieredPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTieredPrice.kt index 414480efc..9bde6107e 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTieredPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTieredPrice.kt @@ -1093,7 +1093,7 @@ private constructor( return true } - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + return other is Cadence && value == other.value } override fun hashCode() = value.hashCode() @@ -1213,7 +1213,7 @@ private constructor( return true } - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + return other is ModelType && value == other.value } override fun hashCode() = value.hashCode() @@ -1303,10 +1303,10 @@ private constructor( return true } - return /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ + return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(unit, tiered) override fun toString(): String = when { @@ -1482,12 +1482,10 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1499,12 +1497,51 @@ private constructor( return true } - return /* spotless:off */ other is NewSubscriptionTieredPrice && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && tieredConfig == other.tieredConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && conversionRateConfig == other.conversionRateConfig && currency == other.currency && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + return other is NewSubscriptionTieredPrice && + cadence == other.cadence && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + tieredConfig == other.tieredConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, itemId, modelType, name, tieredConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, conversionRateConfig, currency, dimensionalPriceConfiguration, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, referenceId, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + modelType, + name, + tieredConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTieredWithMinimumPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTieredWithMinimumPrice.kt index 702371998..41536a33e 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTieredWithMinimumPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTieredWithMinimumPrice.kt @@ -1104,7 +1104,7 @@ private constructor( return true } - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + return other is Cadence && value == other.value } override fun hashCode() = value.hashCode() @@ -1224,7 +1224,7 @@ private constructor( return true } - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + return other is ModelType && value == other.value } override fun hashCode() = value.hashCode() @@ -1322,12 +1322,11 @@ private constructor( return true } - return /* spotless:off */ other is TieredWithMinimumConfig && additionalProperties == other.additionalProperties /* spotless:on */ + return other is TieredWithMinimumConfig && + additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1417,10 +1416,10 @@ private constructor( return true } - return /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ + return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(unit, tiered) override fun toString(): String = when { @@ -1596,12 +1595,10 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1613,12 +1610,51 @@ private constructor( return true } - return /* spotless:off */ other is NewSubscriptionTieredWithMinimumPrice && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && tieredWithMinimumConfig == other.tieredWithMinimumConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && conversionRateConfig == other.conversionRateConfig && currency == other.currency && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + return other is NewSubscriptionTieredWithMinimumPrice && + cadence == other.cadence && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + tieredWithMinimumConfig == other.tieredWithMinimumConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, itemId, modelType, name, tieredWithMinimumConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, conversionRateConfig, currency, dimensionalPriceConfiguration, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, referenceId, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + modelType, + name, + tieredWithMinimumConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionUnitPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionUnitPrice.kt index 840dacf40..50447c0b7 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionUnitPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionUnitPrice.kt @@ -1091,7 +1091,7 @@ private constructor( return true } - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + return other is Cadence && value == other.value } override fun hashCode() = value.hashCode() @@ -1211,7 +1211,7 @@ private constructor( return true } - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + return other is ModelType && value == other.value } override fun hashCode() = value.hashCode() @@ -1301,10 +1301,10 @@ private constructor( return true } - return /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ + return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(unit, tiered) override fun toString(): String = when { @@ -1480,12 +1480,10 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1497,12 +1495,51 @@ private constructor( return true } - return /* spotless:off */ other is NewSubscriptionUnitPrice && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && unitConfig == other.unitConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && conversionRateConfig == other.conversionRateConfig && currency == other.currency && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + return other is NewSubscriptionUnitPrice && + cadence == other.cadence && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + unitConfig == other.unitConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, itemId, modelType, name, unitConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, conversionRateConfig, currency, dimensionalPriceConfiguration, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, referenceId, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + modelType, + name, + unitConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionUnitWithPercentPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionUnitWithPercentPrice.kt index 3a8818bae..ddbda8241 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionUnitWithPercentPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionUnitWithPercentPrice.kt @@ -1103,7 +1103,7 @@ private constructor( return true } - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + return other is Cadence && value == other.value } override fun hashCode() = value.hashCode() @@ -1223,7 +1223,7 @@ private constructor( return true } - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + return other is ModelType && value == other.value } override fun hashCode() = value.hashCode() @@ -1321,12 +1321,11 @@ private constructor( return true } - return /* spotless:off */ other is UnitWithPercentConfig && additionalProperties == other.additionalProperties /* spotless:on */ + return other is UnitWithPercentConfig && + additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1416,10 +1415,10 @@ private constructor( return true } - return /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ + return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(unit, tiered) override fun toString(): String = when { @@ -1595,12 +1594,10 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1612,12 +1609,51 @@ private constructor( return true } - return /* spotless:off */ other is NewSubscriptionUnitWithPercentPrice && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && unitWithPercentConfig == other.unitWithPercentConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && conversionRateConfig == other.conversionRateConfig && currency == other.currency && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + return other is NewSubscriptionUnitWithPercentPrice && + cadence == other.cadence && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + unitWithPercentConfig == other.unitWithPercentConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, itemId, modelType, name, unitWithPercentConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, conversionRateConfig, currency, dimensionalPriceConfiguration, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, referenceId, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + modelType, + name, + unitWithPercentConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionUnitWithProrationPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionUnitWithProrationPrice.kt index a2de6191f..e7587c852 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionUnitWithProrationPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionUnitWithProrationPrice.kt @@ -1104,7 +1104,7 @@ private constructor( return true } - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + return other is Cadence && value == other.value } override fun hashCode() = value.hashCode() @@ -1224,7 +1224,7 @@ private constructor( return true } - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + return other is ModelType && value == other.value } override fun hashCode() = value.hashCode() @@ -1322,12 +1322,11 @@ private constructor( return true } - return /* spotless:off */ other is UnitWithProrationConfig && additionalProperties == other.additionalProperties /* spotless:on */ + return other is UnitWithProrationConfig && + additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1417,10 +1416,10 @@ private constructor( return true } - return /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ + return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(unit, tiered) override fun toString(): String = when { @@ -1596,12 +1595,10 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1613,12 +1610,51 @@ private constructor( return true } - return /* spotless:off */ other is NewSubscriptionUnitWithProrationPrice && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && unitWithProrationConfig == other.unitWithProrationConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && conversionRateConfig == other.conversionRateConfig && currency == other.currency && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + return other is NewSubscriptionUnitWithProrationPrice && + cadence == other.cadence && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + unitWithProrationConfig == other.unitWithProrationConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, itemId, modelType, name, unitWithProrationConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, conversionRateConfig, currency, dimensionalPriceConfiguration, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, referenceId, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + modelType, + name, + unitWithProrationConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewTaxJarConfiguration.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewTaxJarConfiguration.kt index 9dfceac00..1065e973b 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewTaxJarConfiguration.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewTaxJarConfiguration.kt @@ -305,7 +305,7 @@ private constructor( return true } - return /* spotless:off */ other is TaxProvider && value == other.value /* spotless:on */ + return other is TaxProvider && value == other.value } override fun hashCode() = value.hashCode() @@ -318,12 +318,13 @@ private constructor( return true } - return /* spotless:off */ other is NewTaxJarConfiguration && taxExempt == other.taxExempt && taxProvider == other.taxProvider && additionalProperties == other.additionalProperties /* spotless:on */ + return other is NewTaxJarConfiguration && + taxExempt == other.taxExempt && + taxProvider == other.taxProvider && + additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(taxExempt, taxProvider, additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewUsageDiscount.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewUsageDiscount.kt index 9e4cc672f..9a9f0af1a 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewUsageDiscount.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewUsageDiscount.kt @@ -639,7 +639,7 @@ private constructor( return true } - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ + return other is AdjustmentType && value == other.value } override fun hashCode() = value.hashCode() @@ -758,7 +758,7 @@ private constructor( return true } - return /* spotless:off */ other is AppliesToAll && value == other.value /* spotless:on */ + return other is AppliesToAll && value == other.value } override fun hashCode() = value.hashCode() @@ -903,7 +903,7 @@ private constructor( return true } - return /* spotless:off */ other is PriceType && value == other.value /* spotless:on */ + return other is PriceType && value == other.value } override fun hashCode() = value.hashCode() @@ -916,12 +916,33 @@ private constructor( return true } - return /* spotless:off */ other is NewUsageDiscount && adjustmentType == other.adjustmentType && usageDiscount == other.usageDiscount && appliesToAll == other.appliesToAll && appliesToItemIds == other.appliesToItemIds && appliesToPriceIds == other.appliesToPriceIds && currency == other.currency && filters == other.filters && isInvoiceLevel == other.isInvoiceLevel && priceType == other.priceType && additionalProperties == other.additionalProperties /* spotless:on */ + return other is NewUsageDiscount && + adjustmentType == other.adjustmentType && + usageDiscount == other.usageDiscount && + appliesToAll == other.appliesToAll && + appliesToItemIds == other.appliesToItemIds && + appliesToPriceIds == other.appliesToPriceIds && + currency == other.currency && + filters == other.filters && + isInvoiceLevel == other.isInvoiceLevel && + priceType == other.priceType && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(adjustmentType, usageDiscount, appliesToAll, appliesToItemIds, appliesToPriceIds, currency, filters, isInvoiceLevel, priceType, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + adjustmentType, + usageDiscount, + appliesToAll, + appliesToItemIds, + appliesToPriceIds, + currency, + filters, + isInvoiceLevel, + priceType, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/OtherSubLineItem.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/OtherSubLineItem.kt index 250397b06..ddc75ff26 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/OtherSubLineItem.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/OtherSubLineItem.kt @@ -397,7 +397,7 @@ private constructor( return true } - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + return other is Type && value == other.value } override fun hashCode() = value.hashCode() @@ -410,12 +410,18 @@ private constructor( return true } - return /* spotless:off */ other is OtherSubLineItem && amount == other.amount && grouping == other.grouping && name == other.name && quantity == other.quantity && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return other is OtherSubLineItem && + amount == other.amount && + grouping == other.grouping && + name == other.name && + quantity == other.quantity && + type == other.type && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(amount, grouping, name, quantity, type, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash(amount, grouping, name, quantity, type, additionalProperties) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PackageConfig.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PackageConfig.kt index 057b6f074..5c64d7386 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PackageConfig.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PackageConfig.kt @@ -207,12 +207,15 @@ private constructor( return true } - return /* spotless:off */ other is PackageConfig && packageAmount == other.packageAmount && packageSize == other.packageSize && additionalProperties == other.additionalProperties /* spotless:on */ + return other is PackageConfig && + packageAmount == other.packageAmount && + packageSize == other.packageSize && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(packageAmount, packageSize, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash(packageAmount, packageSize, additionalProperties) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PaginationMetadata.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PaginationMetadata.kt index 5f538e0f6..37436bee7 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PaginationMetadata.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PaginationMetadata.kt @@ -189,12 +189,13 @@ private constructor( return true } - return /* spotless:off */ other is PaginationMetadata && hasMore == other.hasMore && nextCursor == other.nextCursor && additionalProperties == other.additionalProperties /* spotless:on */ + return other is PaginationMetadata && + hasMore == other.hasMore && + nextCursor == other.nextCursor && + additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(hasMore, nextCursor, additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PerPriceCost.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PerPriceCost.kt index dcaf60afa..402288370 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PerPriceCost.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PerPriceCost.kt @@ -435,12 +435,18 @@ private constructor( return true } - return /* spotless:off */ other is PerPriceCost && price == other.price && priceId == other.priceId && subtotal == other.subtotal && total == other.total && quantity == other.quantity && additionalProperties == other.additionalProperties /* spotless:on */ + return other is PerPriceCost && + price == other.price && + priceId == other.priceId && + subtotal == other.subtotal && + total == other.total && + quantity == other.quantity && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(price, priceId, subtotal, total, quantity, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash(price, priceId, subtotal, total, quantity, additionalProperties) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PercentageDiscount.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PercentageDiscount.kt index b3814b637..7d4c3727d 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PercentageDiscount.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PercentageDiscount.kt @@ -457,7 +457,7 @@ private constructor( return true } - return /* spotless:off */ other is DiscountType && value == other.value /* spotless:on */ + return other is DiscountType && value == other.value } override fun hashCode() = value.hashCode() @@ -470,12 +470,25 @@ private constructor( return true } - return /* spotless:off */ other is PercentageDiscount && discountType == other.discountType && percentageDiscount == other.percentageDiscount && appliesToPriceIds == other.appliesToPriceIds && filters == other.filters && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ + return other is PercentageDiscount && + discountType == other.discountType && + percentageDiscount == other.percentageDiscount && + appliesToPriceIds == other.appliesToPriceIds && + filters == other.filters && + reason == other.reason && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(discountType, percentageDiscount, appliesToPriceIds, filters, reason, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + discountType, + percentageDiscount, + appliesToPriceIds, + filters, + reason, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PercentageDiscountInterval.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PercentageDiscountInterval.kt index 4e2da7a8d..24a15d96c 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PercentageDiscountInterval.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PercentageDiscountInterval.kt @@ -518,7 +518,7 @@ private constructor( return true } - return /* spotless:off */ other is DiscountType && value == other.value /* spotless:on */ + return other is DiscountType && value == other.value } override fun hashCode() = value.hashCode() @@ -531,12 +531,27 @@ private constructor( return true } - return /* spotless:off */ other is PercentageDiscountInterval && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && discountType == other.discountType && endDate == other.endDate && filters == other.filters && percentageDiscount == other.percentageDiscount && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ + return other is PercentageDiscountInterval && + appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && + discountType == other.discountType && + endDate == other.endDate && + filters == other.filters && + percentageDiscount == other.percentageDiscount && + startDate == other.startDate && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(appliesToPriceIntervalIds, discountType, endDate, filters, percentageDiscount, startDate, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + appliesToPriceIntervalIds, + discountType, + endDate, + filters, + percentageDiscount, + startDate, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Plan.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Plan.kt index b927fa4ca..e7d5a55cc 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Plan.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Plan.kt @@ -1522,10 +1522,16 @@ private constructor( return true } - return /* spotless:off */ other is Adjustment && usageDiscount == other.usageDiscount && amountDiscount == other.amountDiscount && percentageDiscount == other.percentageDiscount && minimum == other.minimum && maximum == other.maximum /* spotless:on */ + return other is Adjustment && + usageDiscount == other.usageDiscount && + amountDiscount == other.amountDiscount && + percentageDiscount == other.percentageDiscount && + minimum == other.minimum && + maximum == other.maximum } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(usageDiscount, amountDiscount, percentageDiscount, minimum, maximum) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash(usageDiscount, amountDiscount, percentageDiscount, minimum, maximum) override fun toString(): String = when { @@ -1879,12 +1885,16 @@ private constructor( return true } - return /* spotless:off */ other is BasePlan && id == other.id && externalPlanId == other.externalPlanId && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ + return other is BasePlan && + id == other.id && + externalPlanId == other.externalPlanId && + name == other.name && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, externalPlanId, name, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash(id, externalPlanId, name, additionalProperties) + } override fun hashCode(): Int = hashCode @@ -1984,12 +1994,10 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -2728,7 +2736,7 @@ private constructor( return true } - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ + return other is DurationUnit && value == other.value } override fun hashCode() = value.hashCode() @@ -2741,12 +2749,37 @@ private constructor( return true } - return /* spotless:off */ other is PlanPhase && id == other.id && description == other.description && discount == other.discount && duration == other.duration && durationUnit == other.durationUnit && maximum == other.maximum && maximumAmount == other.maximumAmount && minimum == other.minimum && minimumAmount == other.minimumAmount && name == other.name && order == other.order && additionalProperties == other.additionalProperties /* spotless:on */ + return other is PlanPhase && + id == other.id && + description == other.description && + discount == other.discount && + duration == other.duration && + durationUnit == other.durationUnit && + maximum == other.maximum && + maximumAmount == other.maximumAmount && + minimum == other.minimum && + minimumAmount == other.minimumAmount && + name == other.name && + order == other.order && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, description, discount, duration, durationUnit, maximum, maximumAmount, minimum, minimumAmount, name, order, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + id, + description, + discount, + duration, + durationUnit, + maximum, + maximumAmount, + minimum, + minimumAmount, + name, + order, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode @@ -2968,12 +3001,16 @@ private constructor( return true } - return /* spotless:off */ other is Product && id == other.id && createdAt == other.createdAt && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Product && + id == other.id && + createdAt == other.createdAt && + name == other.name && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, createdAt, name, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash(id, createdAt, name, additionalProperties) + } override fun hashCode(): Int = hashCode @@ -3103,7 +3140,7 @@ private constructor( return true } - return /* spotless:off */ other is Status && value == other.value /* spotless:on */ + return other is Status && value == other.value } override fun hashCode() = value.hashCode() @@ -3416,7 +3453,7 @@ private constructor( return true } - return /* spotless:off */ other is TrialPeriodUnit && value == other.value /* spotless:on */ + return other is TrialPeriodUnit && value == other.value } override fun hashCode() = value.hashCode() @@ -3429,12 +3466,15 @@ private constructor( return true } - return /* spotless:off */ other is TrialConfig && trialPeriod == other.trialPeriod && trialPeriodUnit == other.trialPeriodUnit && additionalProperties == other.additionalProperties /* spotless:on */ + return other is TrialConfig && + trialPeriod == other.trialPeriod && + trialPeriodUnit == other.trialPeriodUnit && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(trialPeriod, trialPeriodUnit, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash(trialPeriod, trialPeriodUnit, additionalProperties) + } override fun hashCode(): Int = hashCode @@ -3447,12 +3487,63 @@ private constructor( return true } - return /* spotless:off */ other is Plan && id == other.id && adjustments == other.adjustments && basePlan == other.basePlan && basePlanId == other.basePlanId && createdAt == other.createdAt && currency == other.currency && defaultInvoiceMemo == other.defaultInvoiceMemo && description == other.description && discount == other.discount && externalPlanId == other.externalPlanId && invoicingCurrency == other.invoicingCurrency && maximum == other.maximum && maximumAmount == other.maximumAmount && metadata == other.metadata && minimum == other.minimum && minimumAmount == other.minimumAmount && name == other.name && netTerms == other.netTerms && planPhases == other.planPhases && prices == other.prices && product == other.product && status == other.status && trialConfig == other.trialConfig && version == other.version && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Plan && + id == other.id && + adjustments == other.adjustments && + basePlan == other.basePlan && + basePlanId == other.basePlanId && + createdAt == other.createdAt && + currency == other.currency && + defaultInvoiceMemo == other.defaultInvoiceMemo && + description == other.description && + discount == other.discount && + externalPlanId == other.externalPlanId && + invoicingCurrency == other.invoicingCurrency && + maximum == other.maximum && + maximumAmount == other.maximumAmount && + metadata == other.metadata && + minimum == other.minimum && + minimumAmount == other.minimumAmount && + name == other.name && + netTerms == other.netTerms && + planPhases == other.planPhases && + prices == other.prices && + product == other.product && + status == other.status && + trialConfig == other.trialConfig && + version == other.version && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, adjustments, basePlan, basePlanId, createdAt, currency, defaultInvoiceMemo, description, discount, externalPlanId, invoicingCurrency, maximum, maximumAmount, metadata, minimum, minimumAmount, name, netTerms, planPhases, prices, product, status, trialConfig, version, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + id, + adjustments, + basePlan, + basePlanId, + createdAt, + currency, + defaultInvoiceMemo, + description, + discount, + externalPlanId, + invoicingCurrency, + maximum, + maximumAmount, + metadata, + minimum, + minimumAmount, + name, + netTerms, + planPhases, + prices, + product, + status, + trialConfig, + version, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanCreateParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanCreateParams.kt index 0c947274b..81a74e599 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanCreateParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanCreateParams.kt @@ -1125,12 +1125,35 @@ private constructor( return true } - return /* spotless:off */ other is Body && currency == other.currency && name == other.name && prices == other.prices && adjustments == other.adjustments && defaultInvoiceMemo == other.defaultInvoiceMemo && externalPlanId == other.externalPlanId && metadata == other.metadata && netTerms == other.netTerms && planPhases == other.planPhases && status == other.status && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Body && + currency == other.currency && + name == other.name && + prices == other.prices && + adjustments == other.adjustments && + defaultInvoiceMemo == other.defaultInvoiceMemo && + externalPlanId == other.externalPlanId && + metadata == other.metadata && + netTerms == other.netTerms && + planPhases == other.planPhases && + status == other.status && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(currency, name, prices, adjustments, defaultInvoiceMemo, externalPlanId, metadata, netTerms, planPhases, status, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + currency, + name, + prices, + adjustments, + defaultInvoiceMemo, + externalPlanId, + metadata, + netTerms, + planPhases, + status, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode @@ -2070,10 +2093,68 @@ private constructor( return true } - return /* spotless:off */ other is InnerPrice && unit == other.unit && package_ == other.package_ && matrix == other.matrix && tiered == other.tiered && tieredBps == other.tieredBps && bps == other.bps && bulkBps == other.bulkBps && bulk == other.bulk && thresholdTotalAmount == other.thresholdTotalAmount && tieredPackage == other.tieredPackage && tieredWithMinimum == other.tieredWithMinimum && unitWithPercent == other.unitWithPercent && packageWithAllocation == other.packageWithAllocation && tieredWithProration == other.tieredWithProration && unitWithProration == other.unitWithProration && groupedAllocation == other.groupedAllocation && groupedWithProratedMinimum == other.groupedWithProratedMinimum && groupedWithMeteredMinimum == other.groupedWithMeteredMinimum && matrixWithDisplayName == other.matrixWithDisplayName && bulkWithProration == other.bulkWithProration && groupedTieredPackage == other.groupedTieredPackage && maxGroupTieredPackage == other.maxGroupTieredPackage && scalableMatrixWithUnitPricing == other.scalableMatrixWithUnitPricing && scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && cumulativeGroupedBulk == other.cumulativeGroupedBulk && tieredPackageWithMinimum == other.tieredPackageWithMinimum && matrixWithAllocation == other.matrixWithAllocation && groupedTiered == other.groupedTiered /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, package_, matrix, tiered, tieredBps, bps, bulkBps, bulk, thresholdTotalAmount, tieredPackage, tieredWithMinimum, unitWithPercent, packageWithAllocation, tieredWithProration, unitWithProration, groupedAllocation, groupedWithProratedMinimum, groupedWithMeteredMinimum, matrixWithDisplayName, bulkWithProration, groupedTieredPackage, maxGroupTieredPackage, scalableMatrixWithUnitPricing, scalableMatrixWithTieredPricing, cumulativeGroupedBulk, tieredPackageWithMinimum, matrixWithAllocation, groupedTiered) /* spotless:on */ + return other is InnerPrice && + unit == other.unit && + package_ == other.package_ && + matrix == other.matrix && + tiered == other.tiered && + tieredBps == other.tieredBps && + bps == other.bps && + bulkBps == other.bulkBps && + bulk == other.bulk && + thresholdTotalAmount == other.thresholdTotalAmount && + tieredPackage == other.tieredPackage && + tieredWithMinimum == other.tieredWithMinimum && + unitWithPercent == other.unitWithPercent && + packageWithAllocation == other.packageWithAllocation && + tieredWithProration == other.tieredWithProration && + unitWithProration == other.unitWithProration && + groupedAllocation == other.groupedAllocation && + groupedWithProratedMinimum == other.groupedWithProratedMinimum && + groupedWithMeteredMinimum == other.groupedWithMeteredMinimum && + matrixWithDisplayName == other.matrixWithDisplayName && + bulkWithProration == other.bulkWithProration && + groupedTieredPackage == other.groupedTieredPackage && + maxGroupTieredPackage == other.maxGroupTieredPackage && + scalableMatrixWithUnitPricing == other.scalableMatrixWithUnitPricing && + scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && + cumulativeGroupedBulk == other.cumulativeGroupedBulk && + tieredPackageWithMinimum == other.tieredPackageWithMinimum && + matrixWithAllocation == other.matrixWithAllocation && + groupedTiered == other.groupedTiered + } + + override fun hashCode(): Int = + Objects.hash( + unit, + package_, + matrix, + tiered, + tieredBps, + bps, + bulkBps, + bulk, + thresholdTotalAmount, + tieredPackage, + tieredWithMinimum, + unitWithPercent, + packageWithAllocation, + tieredWithProration, + unitWithProration, + groupedAllocation, + groupedWithProratedMinimum, + groupedWithMeteredMinimum, + matrixWithDisplayName, + bulkWithProration, + groupedTieredPackage, + maxGroupTieredPackage, + scalableMatrixWithUnitPricing, + scalableMatrixWithTieredPricing, + cumulativeGroupedBulk, + tieredPackageWithMinimum, + matrixWithAllocation, + groupedTiered, + ) override fun toString(): String = when { @@ -2587,12 +2668,16 @@ private constructor( return true } - return /* spotless:off */ other is Price && allocationPrice == other.allocationPrice && planPhaseOrder == other.planPhaseOrder && price == other.price && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Price && + allocationPrice == other.allocationPrice && + planPhaseOrder == other.planPhaseOrder && + price == other.price && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(allocationPrice, planPhaseOrder, price, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash(allocationPrice, planPhaseOrder, price, additionalProperties) + } override fun hashCode(): Int = hashCode @@ -3021,10 +3106,16 @@ private constructor( return true } - return /* spotless:off */ other is InnerAdjustment && percentageDiscount == other.percentageDiscount && usageDiscount == other.usageDiscount && amountDiscount == other.amountDiscount && minimum == other.minimum && maximum == other.maximum /* spotless:on */ + return other is InnerAdjustment && + percentageDiscount == other.percentageDiscount && + usageDiscount == other.usageDiscount && + amountDiscount == other.amountDiscount && + minimum == other.minimum && + maximum == other.maximum } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(percentageDiscount, usageDiscount, amountDiscount, minimum, maximum) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash(percentageDiscount, usageDiscount, amountDiscount, minimum, maximum) override fun toString(): String = when { @@ -3150,12 +3241,15 @@ private constructor( return true } - return /* spotless:off */ other is Adjustment && adjustment == other.adjustment && planPhaseOrder == other.planPhaseOrder && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Adjustment && + adjustment == other.adjustment && + planPhaseOrder == other.planPhaseOrder && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(adjustment, planPhaseOrder, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash(adjustment, planPhaseOrder, additionalProperties) + } override fun hashCode(): Int = hashCode @@ -3255,12 +3349,10 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -3682,7 +3774,7 @@ private constructor( return true } - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ + return other is DurationUnit && value == other.value } override fun hashCode() = value.hashCode() @@ -3695,12 +3787,23 @@ private constructor( return true } - return /* spotless:off */ other is PlanPhase && order == other.order && alignBillingWithPhaseStartDate == other.alignBillingWithPhaseStartDate && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ + return other is PlanPhase && + order == other.order && + alignBillingWithPhaseStartDate == other.alignBillingWithPhaseStartDate && + duration == other.duration && + durationUnit == other.durationUnit && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(order, alignBillingWithPhaseStartDate, duration, durationUnit, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + order, + alignBillingWithPhaseStartDate, + duration, + durationUnit, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode @@ -3828,7 +3931,7 @@ private constructor( return true } - return /* spotless:off */ other is Status && value == other.value /* spotless:on */ + return other is Status && value == other.value } override fun hashCode() = value.hashCode() @@ -3841,10 +3944,13 @@ private constructor( return true } - return /* spotless:off */ other is PlanCreateParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return other is PlanCreateParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(body, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) override fun toString() = "PlanCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanExternalPlanIdFetchParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanExternalPlanIdFetchParams.kt index d42b1ddcb..5c4ff453e 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanExternalPlanIdFetchParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanExternalPlanIdFetchParams.kt @@ -192,10 +192,14 @@ private constructor( return true } - return /* spotless:off */ other is PlanExternalPlanIdFetchParams && externalPlanId == other.externalPlanId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return other is PlanExternalPlanIdFetchParams && + externalPlanId == other.externalPlanId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(externalPlanId, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash(externalPlanId, additionalHeaders, additionalQueryParams) override fun toString() = "PlanExternalPlanIdFetchParams{externalPlanId=$externalPlanId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanExternalPlanIdUpdateParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanExternalPlanIdUpdateParams.kt index 3f5aea0d2..0893ed42f 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanExternalPlanIdUpdateParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanExternalPlanIdUpdateParams.kt @@ -474,12 +474,15 @@ private constructor( return true } - return /* spotless:off */ other is Body && externalPlanId == other.externalPlanId && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Body && + externalPlanId == other.externalPlanId && + metadata == other.metadata && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(externalPlanId, metadata, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash(externalPlanId, metadata, additionalProperties) + } override fun hashCode(): Int = hashCode @@ -579,12 +582,10 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -596,10 +597,15 @@ private constructor( return true } - return /* spotless:off */ other is PlanExternalPlanIdUpdateParams && otherExternalPlanId == other.otherExternalPlanId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return other is PlanExternalPlanIdUpdateParams && + otherExternalPlanId == other.otherExternalPlanId && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(otherExternalPlanId, body, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash(otherExternalPlanId, body, additionalHeaders, additionalQueryParams) override fun toString() = "PlanExternalPlanIdUpdateParams{otherExternalPlanId=$otherExternalPlanId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanFetchParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanFetchParams.kt index 007da8808..46ee62501 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanFetchParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanFetchParams.kt @@ -186,10 +186,13 @@ private constructor( return true } - return /* spotless:off */ other is PlanFetchParams && planId == other.planId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return other is PlanFetchParams && + planId == other.planId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(planId, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(planId, additionalHeaders, additionalQueryParams) override fun toString() = "PlanFetchParams{planId=$planId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanListPage.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanListPage.kt index 02e4dcd5a..a33ff764e 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanListPage.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanListPage.kt @@ -119,10 +119,13 @@ private constructor( return true } - return /* spotless:off */ other is PlanListPage && service == other.service && params == other.params && response == other.response /* spotless:on */ + return other is PlanListPage && + service == other.service && + params == other.params && + response == other.response } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, params, response) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(service, params, response) override fun toString() = "PlanListPage{service=$service, params=$params, response=$response}" } diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanListPageAsync.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanListPageAsync.kt index 523b3130f..100c10444 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanListPageAsync.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanListPageAsync.kt @@ -119,10 +119,13 @@ private constructor( return true } - return /* spotless:off */ other is PlanListPageAsync && service == other.service && params == other.params && response == other.response /* spotless:on */ + return other is PlanListPageAsync && + service == other.service && + params == other.params && + response == other.response } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, params, response) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(service, params, response) override fun toString() = "PlanListPageAsync{service=$service, params=$params, response=$response}" diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanListPageResponse.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanListPageResponse.kt index 630f21637..1e3b0b692 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanListPageResponse.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanListPageResponse.kt @@ -213,12 +213,15 @@ private constructor( return true } - return /* spotless:off */ other is PlanListPageResponse && data == other.data && paginationMetadata == other.paginationMetadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is PlanListPageResponse && + data == other.data && + paginationMetadata == other.paginationMetadata && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(data, paginationMetadata, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash(data, paginationMetadata, additionalProperties) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanListParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanListParams.kt index 62d4b447d..0f6b672b5 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanListParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanListParams.kt @@ -384,7 +384,7 @@ private constructor( return true } - return /* spotless:off */ other is Status && value == other.value /* spotless:on */ + return other is Status && value == other.value } override fun hashCode() = value.hashCode() @@ -397,10 +397,30 @@ private constructor( return true } - return /* spotless:off */ other is PlanListParams && createdAtGt == other.createdAtGt && createdAtGte == other.createdAtGte && createdAtLt == other.createdAtLt && createdAtLte == other.createdAtLte && cursor == other.cursor && limit == other.limit && status == other.status && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return other is PlanListParams && + createdAtGt == other.createdAtGt && + createdAtGte == other.createdAtGte && + createdAtLt == other.createdAtLt && + createdAtLte == other.createdAtLte && + cursor == other.cursor && + limit == other.limit && + status == other.status && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(createdAtGt, createdAtGte, createdAtLt, createdAtLte, cursor, limit, status, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash( + createdAtGt, + createdAtGte, + createdAtLt, + createdAtLte, + cursor, + limit, + status, + additionalHeaders, + additionalQueryParams, + ) override fun toString() = "PlanListParams{createdAtGt=$createdAtGt, createdAtGte=$createdAtGte, createdAtLt=$createdAtLt, createdAtLte=$createdAtLte, cursor=$cursor, limit=$limit, status=$status, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanPhaseAmountDiscountAdjustment.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanPhaseAmountDiscountAdjustment.kt index 4bebe864d..7c02925e3 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanPhaseAmountDiscountAdjustment.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanPhaseAmountDiscountAdjustment.kt @@ -662,7 +662,7 @@ private constructor( return true } - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ + return other is AdjustmentType && value == other.value } override fun hashCode() = value.hashCode() @@ -675,12 +675,33 @@ private constructor( return true } - return /* spotless:off */ other is PlanPhaseAmountDiscountAdjustment && id == other.id && adjustmentType == other.adjustmentType && amountDiscount == other.amountDiscount && appliesToPriceIds == other.appliesToPriceIds && filters == other.filters && isInvoiceLevel == other.isInvoiceLevel && planPhaseOrder == other.planPhaseOrder && reason == other.reason && replacesAdjustmentId == other.replacesAdjustmentId && additionalProperties == other.additionalProperties /* spotless:on */ + return other is PlanPhaseAmountDiscountAdjustment && + id == other.id && + adjustmentType == other.adjustmentType && + amountDiscount == other.amountDiscount && + appliesToPriceIds == other.appliesToPriceIds && + filters == other.filters && + isInvoiceLevel == other.isInvoiceLevel && + planPhaseOrder == other.planPhaseOrder && + reason == other.reason && + replacesAdjustmentId == other.replacesAdjustmentId && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, adjustmentType, amountDiscount, appliesToPriceIds, filters, isInvoiceLevel, planPhaseOrder, reason, replacesAdjustmentId, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + id, + adjustmentType, + amountDiscount, + appliesToPriceIds, + filters, + isInvoiceLevel, + planPhaseOrder, + reason, + replacesAdjustmentId, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanPhaseMaximumAdjustment.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanPhaseMaximumAdjustment.kt index dcbdb5231..54556ac56 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanPhaseMaximumAdjustment.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanPhaseMaximumAdjustment.kt @@ -659,7 +659,7 @@ private constructor( return true } - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ + return other is AdjustmentType && value == other.value } override fun hashCode() = value.hashCode() @@ -672,12 +672,33 @@ private constructor( return true } - return /* spotless:off */ other is PlanPhaseMaximumAdjustment && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && filters == other.filters && isInvoiceLevel == other.isInvoiceLevel && maximumAmount == other.maximumAmount && planPhaseOrder == other.planPhaseOrder && reason == other.reason && replacesAdjustmentId == other.replacesAdjustmentId && additionalProperties == other.additionalProperties /* spotless:on */ + return other is PlanPhaseMaximumAdjustment && + id == other.id && + adjustmentType == other.adjustmentType && + appliesToPriceIds == other.appliesToPriceIds && + filters == other.filters && + isInvoiceLevel == other.isInvoiceLevel && + maximumAmount == other.maximumAmount && + planPhaseOrder == other.planPhaseOrder && + reason == other.reason && + replacesAdjustmentId == other.replacesAdjustmentId && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, adjustmentType, appliesToPriceIds, filters, isInvoiceLevel, maximumAmount, planPhaseOrder, reason, replacesAdjustmentId, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + id, + adjustmentType, + appliesToPriceIds, + filters, + isInvoiceLevel, + maximumAmount, + planPhaseOrder, + reason, + replacesAdjustmentId, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanPhaseMinimumAdjustment.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanPhaseMinimumAdjustment.kt index 36f5f56a9..d369460be 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanPhaseMinimumAdjustment.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanPhaseMinimumAdjustment.kt @@ -695,7 +695,7 @@ private constructor( return true } - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ + return other is AdjustmentType && value == other.value } override fun hashCode() = value.hashCode() @@ -708,12 +708,35 @@ private constructor( return true } - return /* spotless:off */ other is PlanPhaseMinimumAdjustment && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && filters == other.filters && isInvoiceLevel == other.isInvoiceLevel && itemId == other.itemId && minimumAmount == other.minimumAmount && planPhaseOrder == other.planPhaseOrder && reason == other.reason && replacesAdjustmentId == other.replacesAdjustmentId && additionalProperties == other.additionalProperties /* spotless:on */ + return other is PlanPhaseMinimumAdjustment && + id == other.id && + adjustmentType == other.adjustmentType && + appliesToPriceIds == other.appliesToPriceIds && + filters == other.filters && + isInvoiceLevel == other.isInvoiceLevel && + itemId == other.itemId && + minimumAmount == other.minimumAmount && + planPhaseOrder == other.planPhaseOrder && + reason == other.reason && + replacesAdjustmentId == other.replacesAdjustmentId && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, adjustmentType, appliesToPriceIds, filters, isInvoiceLevel, itemId, minimumAmount, planPhaseOrder, reason, replacesAdjustmentId, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + id, + adjustmentType, + appliesToPriceIds, + filters, + isInvoiceLevel, + itemId, + minimumAmount, + planPhaseOrder, + reason, + replacesAdjustmentId, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanPhasePercentageDiscountAdjustment.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanPhasePercentageDiscountAdjustment.kt index 9b68a4fae..46b39d299 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanPhasePercentageDiscountAdjustment.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanPhasePercentageDiscountAdjustment.kt @@ -665,7 +665,7 @@ private constructor( return true } - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ + return other is AdjustmentType && value == other.value } override fun hashCode() = value.hashCode() @@ -678,12 +678,33 @@ private constructor( return true } - return /* spotless:off */ other is PlanPhasePercentageDiscountAdjustment && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && filters == other.filters && isInvoiceLevel == other.isInvoiceLevel && percentageDiscount == other.percentageDiscount && planPhaseOrder == other.planPhaseOrder && reason == other.reason && replacesAdjustmentId == other.replacesAdjustmentId && additionalProperties == other.additionalProperties /* spotless:on */ + return other is PlanPhasePercentageDiscountAdjustment && + id == other.id && + adjustmentType == other.adjustmentType && + appliesToPriceIds == other.appliesToPriceIds && + filters == other.filters && + isInvoiceLevel == other.isInvoiceLevel && + percentageDiscount == other.percentageDiscount && + planPhaseOrder == other.planPhaseOrder && + reason == other.reason && + replacesAdjustmentId == other.replacesAdjustmentId && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, adjustmentType, appliesToPriceIds, filters, isInvoiceLevel, percentageDiscount, planPhaseOrder, reason, replacesAdjustmentId, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + id, + adjustmentType, + appliesToPriceIds, + filters, + isInvoiceLevel, + percentageDiscount, + planPhaseOrder, + reason, + replacesAdjustmentId, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanPhaseUsageDiscountAdjustment.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanPhaseUsageDiscountAdjustment.kt index 62d4c5876..494efe62d 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanPhaseUsageDiscountAdjustment.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanPhaseUsageDiscountAdjustment.kt @@ -662,7 +662,7 @@ private constructor( return true } - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ + return other is AdjustmentType && value == other.value } override fun hashCode() = value.hashCode() @@ -675,12 +675,33 @@ private constructor( return true } - return /* spotless:off */ other is PlanPhaseUsageDiscountAdjustment && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && filters == other.filters && isInvoiceLevel == other.isInvoiceLevel && planPhaseOrder == other.planPhaseOrder && reason == other.reason && replacesAdjustmentId == other.replacesAdjustmentId && usageDiscount == other.usageDiscount && additionalProperties == other.additionalProperties /* spotless:on */ + return other is PlanPhaseUsageDiscountAdjustment && + id == other.id && + adjustmentType == other.adjustmentType && + appliesToPriceIds == other.appliesToPriceIds && + filters == other.filters && + isInvoiceLevel == other.isInvoiceLevel && + planPhaseOrder == other.planPhaseOrder && + reason == other.reason && + replacesAdjustmentId == other.replacesAdjustmentId && + usageDiscount == other.usageDiscount && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, adjustmentType, appliesToPriceIds, filters, isInvoiceLevel, planPhaseOrder, reason, replacesAdjustmentId, usageDiscount, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + id, + adjustmentType, + appliesToPriceIds, + filters, + isInvoiceLevel, + planPhaseOrder, + reason, + replacesAdjustmentId, + usageDiscount, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanUpdateParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanUpdateParams.kt index bdd4fea44..8cbd6facf 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanUpdateParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanUpdateParams.kt @@ -469,12 +469,15 @@ private constructor( return true } - return /* spotless:off */ other is Body && externalPlanId == other.externalPlanId && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Body && + externalPlanId == other.externalPlanId && + metadata == other.metadata && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(externalPlanId, metadata, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash(externalPlanId, metadata, additionalProperties) + } override fun hashCode(): Int = hashCode @@ -574,12 +577,10 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -591,10 +592,15 @@ private constructor( return true } - return /* spotless:off */ other is PlanUpdateParams && planId == other.planId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return other is PlanUpdateParams && + planId == other.planId && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(planId, body, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash(planId, body, additionalHeaders, additionalQueryParams) override fun toString() = "PlanUpdateParams{planId=$planId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanVersion.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanVersion.kt index 2b7770f7e..210e33308 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanVersion.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanVersion.kt @@ -671,10 +671,16 @@ private constructor( return true } - return /* spotless:off */ other is Adjustment && usageDiscount == other.usageDiscount && amountDiscount == other.amountDiscount && percentageDiscount == other.percentageDiscount && minimum == other.minimum && maximum == other.maximum /* spotless:on */ + return other is Adjustment && + usageDiscount == other.usageDiscount && + amountDiscount == other.amountDiscount && + percentageDiscount == other.percentageDiscount && + minimum == other.minimum && + maximum == other.maximum } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(usageDiscount, amountDiscount, percentageDiscount, minimum, maximum) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash(usageDiscount, amountDiscount, percentageDiscount, minimum, maximum) override fun toString(): String = when { @@ -808,12 +814,18 @@ private constructor( return true } - return /* spotless:off */ other is PlanVersion && adjustments == other.adjustments && createdAt == other.createdAt && planPhases == other.planPhases && prices == other.prices && version == other.version && additionalProperties == other.additionalProperties /* spotless:on */ + return other is PlanVersion && + adjustments == other.adjustments && + createdAt == other.createdAt && + planPhases == other.planPhases && + prices == other.prices && + version == other.version && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(adjustments, createdAt, planPhases, prices, version, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash(adjustments, createdAt, planPhases, prices, version, additionalProperties) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanVersionPhase.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanVersionPhase.kt index f89d6bcb5..86f58dfff 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanVersionPhase.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanVersionPhase.kt @@ -476,7 +476,7 @@ private constructor( return true } - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ + return other is DurationUnit && value == other.value } override fun hashCode() = value.hashCode() @@ -489,12 +489,19 @@ private constructor( return true } - return /* spotless:off */ other is PlanVersionPhase && id == other.id && description == other.description && duration == other.duration && durationUnit == other.durationUnit && name == other.name && order == other.order && additionalProperties == other.additionalProperties /* spotless:on */ + return other is PlanVersionPhase && + id == other.id && + description == other.description && + duration == other.duration && + durationUnit == other.durationUnit && + name == other.name && + order == other.order && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, description, duration, durationUnit, name, order, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash(id, description, duration, durationUnit, name, order, additionalProperties) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Price.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Price.kt index 52870871c..eaffb51a8 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Price.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Price.kt @@ -576,10 +576,70 @@ private constructor( return true } - return /* spotless:off */ other is Price && unit == other.unit && package_ == other.package_ && matrix == other.matrix && tiered == other.tiered && tieredBps == other.tieredBps && bps == other.bps && bulkBps == other.bulkBps && bulk == other.bulk && thresholdTotalAmount == other.thresholdTotalAmount && tieredPackage == other.tieredPackage && groupedTiered == other.groupedTiered && tieredWithMinimum == other.tieredWithMinimum && tieredPackageWithMinimum == other.tieredPackageWithMinimum && packageWithAllocation == other.packageWithAllocation && unitWithPercent == other.unitWithPercent && matrixWithAllocation == other.matrixWithAllocation && tieredWithProration == other.tieredWithProration && unitWithProration == other.unitWithProration && groupedAllocation == other.groupedAllocation && groupedWithProratedMinimum == other.groupedWithProratedMinimum && groupedWithMeteredMinimum == other.groupedWithMeteredMinimum && matrixWithDisplayName == other.matrixWithDisplayName && bulkWithProration == other.bulkWithProration && groupedTieredPackage == other.groupedTieredPackage && maxGroupTieredPackage == other.maxGroupTieredPackage && scalableMatrixWithUnitPricing == other.scalableMatrixWithUnitPricing && scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && cumulativeGroupedBulk == other.cumulativeGroupedBulk && groupedWithMinMaxThresholds == other.groupedWithMinMaxThresholds /* spotless:on */ + return other is Price && + unit == other.unit && + package_ == other.package_ && + matrix == other.matrix && + tiered == other.tiered && + tieredBps == other.tieredBps && + bps == other.bps && + bulkBps == other.bulkBps && + bulk == other.bulk && + thresholdTotalAmount == other.thresholdTotalAmount && + tieredPackage == other.tieredPackage && + groupedTiered == other.groupedTiered && + tieredWithMinimum == other.tieredWithMinimum && + tieredPackageWithMinimum == other.tieredPackageWithMinimum && + packageWithAllocation == other.packageWithAllocation && + unitWithPercent == other.unitWithPercent && + matrixWithAllocation == other.matrixWithAllocation && + tieredWithProration == other.tieredWithProration && + unitWithProration == other.unitWithProration && + groupedAllocation == other.groupedAllocation && + groupedWithProratedMinimum == other.groupedWithProratedMinimum && + groupedWithMeteredMinimum == other.groupedWithMeteredMinimum && + matrixWithDisplayName == other.matrixWithDisplayName && + bulkWithProration == other.bulkWithProration && + groupedTieredPackage == other.groupedTieredPackage && + maxGroupTieredPackage == other.maxGroupTieredPackage && + scalableMatrixWithUnitPricing == other.scalableMatrixWithUnitPricing && + scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && + cumulativeGroupedBulk == other.cumulativeGroupedBulk && + groupedWithMinMaxThresholds == other.groupedWithMinMaxThresholds } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, package_, matrix, tiered, tieredBps, bps, bulkBps, bulk, thresholdTotalAmount, tieredPackage, groupedTiered, tieredWithMinimum, tieredPackageWithMinimum, packageWithAllocation, unitWithPercent, matrixWithAllocation, tieredWithProration, unitWithProration, groupedAllocation, groupedWithProratedMinimum, groupedWithMeteredMinimum, matrixWithDisplayName, bulkWithProration, groupedTieredPackage, maxGroupTieredPackage, scalableMatrixWithUnitPricing, scalableMatrixWithTieredPricing, cumulativeGroupedBulk, groupedWithMinMaxThresholds) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash( + unit, + package_, + matrix, + tiered, + tieredBps, + bps, + bulkBps, + bulk, + thresholdTotalAmount, + tieredPackage, + groupedTiered, + tieredWithMinimum, + tieredPackageWithMinimum, + packageWithAllocation, + unitWithPercent, + matrixWithAllocation, + tieredWithProration, + unitWithProration, + groupedAllocation, + groupedWithProratedMinimum, + groupedWithMeteredMinimum, + matrixWithDisplayName, + bulkWithProration, + groupedTieredPackage, + maxGroupTieredPackage, + scalableMatrixWithUnitPricing, + scalableMatrixWithTieredPricing, + cumulativeGroupedBulk, + groupedWithMinMaxThresholds, + ) override fun toString(): String = when { @@ -2455,7 +2515,7 @@ private constructor( return true } - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + return other is Cadence && value == other.value } override fun hashCode() = value.hashCode() @@ -2545,10 +2605,10 @@ private constructor( return true } - return /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ + return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(unit, tiered) override fun toString(): String = when { @@ -2732,12 +2792,10 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -2865,7 +2923,7 @@ private constructor( return true } - return /* spotless:off */ other is PriceType && value == other.value /* spotless:on */ + return other is PriceType && value == other.value } override fun hashCode() = value.hashCode() @@ -2878,13 +2936,68 @@ private constructor( return true } - return /* spotless:off */ other is Unit && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && conversionRate == other.conversionRate && conversionRateConfig == other.conversionRateConfig && createdAt == other.createdAt && creditAllocation == other.creditAllocation && currency == other.currency && discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maximum == other.maximum && maximumAmount == other.maximumAmount && metadata == other.metadata && minimum == other.minimum && minimumAmount == other.minimumAmount && modelType == other.modelType && name == other.name && planPhaseOrder == other.planPhaseOrder && priceType == other.priceType && replacesPriceId == other.replacesPriceId && unitConfig == other.unitConfig && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Unit && + id == other.id && + billableMetric == other.billableMetric && + billingCycleConfiguration == other.billingCycleConfiguration && + cadence == other.cadence && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + createdAt == other.createdAt && + creditAllocation == other.creditAllocation && + currency == other.currency && + discount == other.discount && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + item == other.item && + maximum == other.maximum && + maximumAmount == other.maximumAmount && + metadata == other.metadata && + minimum == other.minimum && + minimumAmount == other.minimumAmount && + modelType == other.modelType && + name == other.name && + planPhaseOrder == other.planPhaseOrder && + priceType == other.priceType && + replacesPriceId == other.replacesPriceId && + unitConfig == other.unitConfig && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + billableMetric, + billingCycleConfiguration, + cadence, + conversionRate, + conversionRateConfig, + createdAt, + creditAllocation, + currency, + discount, + externalPriceId, + fixedPriceQuantity, + invoicingCycleConfiguration, + item, + maximum, + maximumAmount, + metadata, + minimum, + minimumAmount, + modelType, + name, + planPhaseOrder, + priceType, + replacesPriceId, + unitConfig, + dimensionalPriceConfiguration, + additionalProperties, + ) } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, billableMetric, billingCycleConfiguration, cadence, conversionRate, conversionRateConfig, createdAt, creditAllocation, currency, discount, externalPriceId, fixedPriceQuantity, invoicingCycleConfiguration, item, maximum, maximumAmount, metadata, minimum, minimumAmount, modelType, name, planPhaseOrder, priceType, replacesPriceId, unitConfig, dimensionalPriceConfiguration, additionalProperties) } - /* spotless:on */ - override fun hashCode(): Int = hashCode override fun toString() = @@ -4345,7 +4458,7 @@ private constructor( return true } - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + return other is Cadence && value == other.value } override fun hashCode() = value.hashCode() @@ -4435,10 +4548,10 @@ private constructor( return true } - return /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ + return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(unit, tiered) override fun toString(): String = when { @@ -4622,12 +4735,10 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -4755,7 +4866,7 @@ private constructor( return true } - return /* spotless:off */ other is PriceType && value == other.value /* spotless:on */ + return other is PriceType && value == other.value } override fun hashCode() = value.hashCode() @@ -4768,13 +4879,68 @@ private constructor( return true } - return /* spotless:off */ other is Package && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && conversionRate == other.conversionRate && conversionRateConfig == other.conversionRateConfig && createdAt == other.createdAt && creditAllocation == other.creditAllocation && currency == other.currency && discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maximum == other.maximum && maximumAmount == other.maximumAmount && metadata == other.metadata && minimum == other.minimum && minimumAmount == other.minimumAmount && modelType == other.modelType && name == other.name && packageConfig == other.packageConfig && planPhaseOrder == other.planPhaseOrder && priceType == other.priceType && replacesPriceId == other.replacesPriceId && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Package && + id == other.id && + billableMetric == other.billableMetric && + billingCycleConfiguration == other.billingCycleConfiguration && + cadence == other.cadence && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + createdAt == other.createdAt && + creditAllocation == other.creditAllocation && + currency == other.currency && + discount == other.discount && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + item == other.item && + maximum == other.maximum && + maximumAmount == other.maximumAmount && + metadata == other.metadata && + minimum == other.minimum && + minimumAmount == other.minimumAmount && + modelType == other.modelType && + name == other.name && + packageConfig == other.packageConfig && + planPhaseOrder == other.planPhaseOrder && + priceType == other.priceType && + replacesPriceId == other.replacesPriceId && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + billableMetric, + billingCycleConfiguration, + cadence, + conversionRate, + conversionRateConfig, + createdAt, + creditAllocation, + currency, + discount, + externalPriceId, + fixedPriceQuantity, + invoicingCycleConfiguration, + item, + maximum, + maximumAmount, + metadata, + minimum, + minimumAmount, + modelType, + name, + packageConfig, + planPhaseOrder, + priceType, + replacesPriceId, + dimensionalPriceConfiguration, + additionalProperties, + ) } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, billableMetric, billingCycleConfiguration, cadence, conversionRate, conversionRateConfig, createdAt, creditAllocation, currency, discount, externalPriceId, fixedPriceQuantity, invoicingCycleConfiguration, item, maximum, maximumAmount, metadata, minimum, minimumAmount, modelType, name, packageConfig, planPhaseOrder, priceType, replacesPriceId, dimensionalPriceConfiguration, additionalProperties) } - /* spotless:on */ - override fun hashCode(): Int = hashCode override fun toString() = @@ -6234,7 +6400,7 @@ private constructor( return true } - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + return other is Cadence && value == other.value } override fun hashCode() = value.hashCode() @@ -6324,10 +6490,10 @@ private constructor( return true } - return /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ + return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(unit, tiered) override fun toString(): String = when { @@ -6511,12 +6677,10 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -6644,7 +6808,7 @@ private constructor( return true } - return /* spotless:off */ other is PriceType && value == other.value /* spotless:on */ + return other is PriceType && value == other.value } override fun hashCode() = value.hashCode() @@ -6657,13 +6821,68 @@ private constructor( return true } - return /* spotless:off */ other is Matrix && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && conversionRate == other.conversionRate && conversionRateConfig == other.conversionRateConfig && createdAt == other.createdAt && creditAllocation == other.creditAllocation && currency == other.currency && discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && matrixConfig == other.matrixConfig && maximum == other.maximum && maximumAmount == other.maximumAmount && metadata == other.metadata && minimum == other.minimum && minimumAmount == other.minimumAmount && modelType == other.modelType && name == other.name && planPhaseOrder == other.planPhaseOrder && priceType == other.priceType && replacesPriceId == other.replacesPriceId && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Matrix && + id == other.id && + billableMetric == other.billableMetric && + billingCycleConfiguration == other.billingCycleConfiguration && + cadence == other.cadence && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + createdAt == other.createdAt && + creditAllocation == other.creditAllocation && + currency == other.currency && + discount == other.discount && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + item == other.item && + matrixConfig == other.matrixConfig && + maximum == other.maximum && + maximumAmount == other.maximumAmount && + metadata == other.metadata && + minimum == other.minimum && + minimumAmount == other.minimumAmount && + modelType == other.modelType && + name == other.name && + planPhaseOrder == other.planPhaseOrder && + priceType == other.priceType && + replacesPriceId == other.replacesPriceId && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + billableMetric, + billingCycleConfiguration, + cadence, + conversionRate, + conversionRateConfig, + createdAt, + creditAllocation, + currency, + discount, + externalPriceId, + fixedPriceQuantity, + invoicingCycleConfiguration, + item, + matrixConfig, + maximum, + maximumAmount, + metadata, + minimum, + minimumAmount, + modelType, + name, + planPhaseOrder, + priceType, + replacesPriceId, + dimensionalPriceConfiguration, + additionalProperties, + ) } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, billableMetric, billingCycleConfiguration, cadence, conversionRate, conversionRateConfig, createdAt, creditAllocation, currency, discount, externalPriceId, fixedPriceQuantity, invoicingCycleConfiguration, item, matrixConfig, maximum, maximumAmount, metadata, minimum, minimumAmount, modelType, name, planPhaseOrder, priceType, replacesPriceId, dimensionalPriceConfiguration, additionalProperties) } - /* spotless:on */ - override fun hashCode(): Int = hashCode override fun toString() = @@ -8123,7 +8342,7 @@ private constructor( return true } - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + return other is Cadence && value == other.value } override fun hashCode() = value.hashCode() @@ -8213,10 +8432,10 @@ private constructor( return true } - return /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ + return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(unit, tiered) override fun toString(): String = when { @@ -8400,12 +8619,10 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -8533,7 +8750,7 @@ private constructor( return true } - return /* spotless:off */ other is PriceType && value == other.value /* spotless:on */ + return other is PriceType && value == other.value } override fun hashCode() = value.hashCode() @@ -8546,13 +8763,68 @@ private constructor( return true } - return /* spotless:off */ other is Tiered && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && conversionRate == other.conversionRate && conversionRateConfig == other.conversionRateConfig && createdAt == other.createdAt && creditAllocation == other.creditAllocation && currency == other.currency && discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maximum == other.maximum && maximumAmount == other.maximumAmount && metadata == other.metadata && minimum == other.minimum && minimumAmount == other.minimumAmount && modelType == other.modelType && name == other.name && planPhaseOrder == other.planPhaseOrder && priceType == other.priceType && replacesPriceId == other.replacesPriceId && tieredConfig == other.tieredConfig && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Tiered && + id == other.id && + billableMetric == other.billableMetric && + billingCycleConfiguration == other.billingCycleConfiguration && + cadence == other.cadence && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + createdAt == other.createdAt && + creditAllocation == other.creditAllocation && + currency == other.currency && + discount == other.discount && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + item == other.item && + maximum == other.maximum && + maximumAmount == other.maximumAmount && + metadata == other.metadata && + minimum == other.minimum && + minimumAmount == other.minimumAmount && + modelType == other.modelType && + name == other.name && + planPhaseOrder == other.planPhaseOrder && + priceType == other.priceType && + replacesPriceId == other.replacesPriceId && + tieredConfig == other.tieredConfig && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + billableMetric, + billingCycleConfiguration, + cadence, + conversionRate, + conversionRateConfig, + createdAt, + creditAllocation, + currency, + discount, + externalPriceId, + fixedPriceQuantity, + invoicingCycleConfiguration, + item, + maximum, + maximumAmount, + metadata, + minimum, + minimumAmount, + modelType, + name, + planPhaseOrder, + priceType, + replacesPriceId, + tieredConfig, + dimensionalPriceConfiguration, + additionalProperties, + ) } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, billableMetric, billingCycleConfiguration, cadence, conversionRate, conversionRateConfig, createdAt, creditAllocation, currency, discount, externalPriceId, fixedPriceQuantity, invoicingCycleConfiguration, item, maximum, maximumAmount, metadata, minimum, minimumAmount, modelType, name, planPhaseOrder, priceType, replacesPriceId, tieredConfig, dimensionalPriceConfiguration, additionalProperties) } - /* spotless:on */ - override fun hashCode(): Int = hashCode override fun toString() = @@ -10013,7 +10285,7 @@ private constructor( return true } - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + return other is Cadence && value == other.value } override fun hashCode() = value.hashCode() @@ -10103,10 +10375,10 @@ private constructor( return true } - return /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ + return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(unit, tiered) override fun toString(): String = when { @@ -10290,12 +10562,10 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -10423,7 +10693,7 @@ private constructor( return true } - return /* spotless:off */ other is PriceType && value == other.value /* spotless:on */ + return other is PriceType && value == other.value } override fun hashCode() = value.hashCode() @@ -10436,13 +10706,68 @@ private constructor( return true } - return /* spotless:off */ other is TieredBps && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && conversionRate == other.conversionRate && conversionRateConfig == other.conversionRateConfig && createdAt == other.createdAt && creditAllocation == other.creditAllocation && currency == other.currency && discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maximum == other.maximum && maximumAmount == other.maximumAmount && metadata == other.metadata && minimum == other.minimum && minimumAmount == other.minimumAmount && modelType == other.modelType && name == other.name && planPhaseOrder == other.planPhaseOrder && priceType == other.priceType && replacesPriceId == other.replacesPriceId && tieredBpsConfig == other.tieredBpsConfig && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ + return other is TieredBps && + id == other.id && + billableMetric == other.billableMetric && + billingCycleConfiguration == other.billingCycleConfiguration && + cadence == other.cadence && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + createdAt == other.createdAt && + creditAllocation == other.creditAllocation && + currency == other.currency && + discount == other.discount && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + item == other.item && + maximum == other.maximum && + maximumAmount == other.maximumAmount && + metadata == other.metadata && + minimum == other.minimum && + minimumAmount == other.minimumAmount && + modelType == other.modelType && + name == other.name && + planPhaseOrder == other.planPhaseOrder && + priceType == other.priceType && + replacesPriceId == other.replacesPriceId && + tieredBpsConfig == other.tieredBpsConfig && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + billableMetric, + billingCycleConfiguration, + cadence, + conversionRate, + conversionRateConfig, + createdAt, + creditAllocation, + currency, + discount, + externalPriceId, + fixedPriceQuantity, + invoicingCycleConfiguration, + item, + maximum, + maximumAmount, + metadata, + minimum, + minimumAmount, + modelType, + name, + planPhaseOrder, + priceType, + replacesPriceId, + tieredBpsConfig, + dimensionalPriceConfiguration, + additionalProperties, + ) } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, billableMetric, billingCycleConfiguration, cadence, conversionRate, conversionRateConfig, createdAt, creditAllocation, currency, discount, externalPriceId, fixedPriceQuantity, invoicingCycleConfiguration, item, maximum, maximumAmount, metadata, minimum, minimumAmount, modelType, name, planPhaseOrder, priceType, replacesPriceId, tieredBpsConfig, dimensionalPriceConfiguration, additionalProperties) } - /* spotless:on */ - override fun hashCode(): Int = hashCode override fun toString() = @@ -11899,7 +12224,7 @@ private constructor( return true } - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + return other is Cadence && value == other.value } override fun hashCode() = value.hashCode() @@ -11989,10 +12314,10 @@ private constructor( return true } - return /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ + return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(unit, tiered) override fun toString(): String = when { @@ -12176,12 +12501,10 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -12309,7 +12632,7 @@ private constructor( return true } - return /* spotless:off */ other is PriceType && value == other.value /* spotless:on */ + return other is PriceType && value == other.value } override fun hashCode() = value.hashCode() @@ -12322,13 +12645,68 @@ private constructor( return true } - return /* spotless:off */ other is Bps && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && bpsConfig == other.bpsConfig && cadence == other.cadence && conversionRate == other.conversionRate && conversionRateConfig == other.conversionRateConfig && createdAt == other.createdAt && creditAllocation == other.creditAllocation && currency == other.currency && discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maximum == other.maximum && maximumAmount == other.maximumAmount && metadata == other.metadata && minimum == other.minimum && minimumAmount == other.minimumAmount && modelType == other.modelType && name == other.name && planPhaseOrder == other.planPhaseOrder && priceType == other.priceType && replacesPriceId == other.replacesPriceId && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Bps && + id == other.id && + billableMetric == other.billableMetric && + billingCycleConfiguration == other.billingCycleConfiguration && + bpsConfig == other.bpsConfig && + cadence == other.cadence && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + createdAt == other.createdAt && + creditAllocation == other.creditAllocation && + currency == other.currency && + discount == other.discount && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + item == other.item && + maximum == other.maximum && + maximumAmount == other.maximumAmount && + metadata == other.metadata && + minimum == other.minimum && + minimumAmount == other.minimumAmount && + modelType == other.modelType && + name == other.name && + planPhaseOrder == other.planPhaseOrder && + priceType == other.priceType && + replacesPriceId == other.replacesPriceId && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + billableMetric, + billingCycleConfiguration, + bpsConfig, + cadence, + conversionRate, + conversionRateConfig, + createdAt, + creditAllocation, + currency, + discount, + externalPriceId, + fixedPriceQuantity, + invoicingCycleConfiguration, + item, + maximum, + maximumAmount, + metadata, + minimum, + minimumAmount, + modelType, + name, + planPhaseOrder, + priceType, + replacesPriceId, + dimensionalPriceConfiguration, + additionalProperties, + ) } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, billableMetric, billingCycleConfiguration, bpsConfig, cadence, conversionRate, conversionRateConfig, createdAt, creditAllocation, currency, discount, externalPriceId, fixedPriceQuantity, invoicingCycleConfiguration, item, maximum, maximumAmount, metadata, minimum, minimumAmount, modelType, name, planPhaseOrder, priceType, replacesPriceId, dimensionalPriceConfiguration, additionalProperties) } - /* spotless:on */ - override fun hashCode(): Int = hashCode override fun toString() = @@ -13789,7 +14167,7 @@ private constructor( return true } - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + return other is Cadence && value == other.value } override fun hashCode() = value.hashCode() @@ -13879,10 +14257,10 @@ private constructor( return true } - return /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ + return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(unit, tiered) override fun toString(): String = when { @@ -14066,12 +14444,10 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -14199,7 +14575,7 @@ private constructor( return true } - return /* spotless:off */ other is PriceType && value == other.value /* spotless:on */ + return other is PriceType && value == other.value } override fun hashCode() = value.hashCode() @@ -14212,13 +14588,68 @@ private constructor( return true } - return /* spotless:off */ other is BulkBps && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && bulkBpsConfig == other.bulkBpsConfig && cadence == other.cadence && conversionRate == other.conversionRate && conversionRateConfig == other.conversionRateConfig && createdAt == other.createdAt && creditAllocation == other.creditAllocation && currency == other.currency && discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maximum == other.maximum && maximumAmount == other.maximumAmount && metadata == other.metadata && minimum == other.minimum && minimumAmount == other.minimumAmount && modelType == other.modelType && name == other.name && planPhaseOrder == other.planPhaseOrder && priceType == other.priceType && replacesPriceId == other.replacesPriceId && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ + return other is BulkBps && + id == other.id && + billableMetric == other.billableMetric && + billingCycleConfiguration == other.billingCycleConfiguration && + bulkBpsConfig == other.bulkBpsConfig && + cadence == other.cadence && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + createdAt == other.createdAt && + creditAllocation == other.creditAllocation && + currency == other.currency && + discount == other.discount && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + item == other.item && + maximum == other.maximum && + maximumAmount == other.maximumAmount && + metadata == other.metadata && + minimum == other.minimum && + minimumAmount == other.minimumAmount && + modelType == other.modelType && + name == other.name && + planPhaseOrder == other.planPhaseOrder && + priceType == other.priceType && + replacesPriceId == other.replacesPriceId && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + billableMetric, + billingCycleConfiguration, + bulkBpsConfig, + cadence, + conversionRate, + conversionRateConfig, + createdAt, + creditAllocation, + currency, + discount, + externalPriceId, + fixedPriceQuantity, + invoicingCycleConfiguration, + item, + maximum, + maximumAmount, + metadata, + minimum, + minimumAmount, + modelType, + name, + planPhaseOrder, + priceType, + replacesPriceId, + dimensionalPriceConfiguration, + additionalProperties, + ) } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, billableMetric, billingCycleConfiguration, bulkBpsConfig, cadence, conversionRate, conversionRateConfig, createdAt, creditAllocation, currency, discount, externalPriceId, fixedPriceQuantity, invoicingCycleConfiguration, item, maximum, maximumAmount, metadata, minimum, minimumAmount, modelType, name, planPhaseOrder, priceType, replacesPriceId, dimensionalPriceConfiguration, additionalProperties) } - /* spotless:on */ - override fun hashCode(): Int = hashCode override fun toString() = @@ -15677,7 +16108,7 @@ private constructor( return true } - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + return other is Cadence && value == other.value } override fun hashCode() = value.hashCode() @@ -15767,10 +16198,10 @@ private constructor( return true } - return /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ + return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(unit, tiered) override fun toString(): String = when { @@ -15954,12 +16385,10 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -16087,7 +16516,7 @@ private constructor( return true } - return /* spotless:off */ other is PriceType && value == other.value /* spotless:on */ + return other is PriceType && value == other.value } override fun hashCode() = value.hashCode() @@ -16100,13 +16529,68 @@ private constructor( return true } - return /* spotless:off */ other is Bulk && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && bulkConfig == other.bulkConfig && cadence == other.cadence && conversionRate == other.conversionRate && conversionRateConfig == other.conversionRateConfig && createdAt == other.createdAt && creditAllocation == other.creditAllocation && currency == other.currency && discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maximum == other.maximum && maximumAmount == other.maximumAmount && metadata == other.metadata && minimum == other.minimum && minimumAmount == other.minimumAmount && modelType == other.modelType && name == other.name && planPhaseOrder == other.planPhaseOrder && priceType == other.priceType && replacesPriceId == other.replacesPriceId && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Bulk && + id == other.id && + billableMetric == other.billableMetric && + billingCycleConfiguration == other.billingCycleConfiguration && + bulkConfig == other.bulkConfig && + cadence == other.cadence && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + createdAt == other.createdAt && + creditAllocation == other.creditAllocation && + currency == other.currency && + discount == other.discount && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + item == other.item && + maximum == other.maximum && + maximumAmount == other.maximumAmount && + metadata == other.metadata && + minimum == other.minimum && + minimumAmount == other.minimumAmount && + modelType == other.modelType && + name == other.name && + planPhaseOrder == other.planPhaseOrder && + priceType == other.priceType && + replacesPriceId == other.replacesPriceId && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + billableMetric, + billingCycleConfiguration, + bulkConfig, + cadence, + conversionRate, + conversionRateConfig, + createdAt, + creditAllocation, + currency, + discount, + externalPriceId, + fixedPriceQuantity, + invoicingCycleConfiguration, + item, + maximum, + maximumAmount, + metadata, + minimum, + minimumAmount, + modelType, + name, + planPhaseOrder, + priceType, + replacesPriceId, + dimensionalPriceConfiguration, + additionalProperties, + ) } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, billableMetric, billingCycleConfiguration, bulkConfig, cadence, conversionRate, conversionRateConfig, createdAt, creditAllocation, currency, discount, externalPriceId, fixedPriceQuantity, invoicingCycleConfiguration, item, maximum, maximumAmount, metadata, minimum, minimumAmount, modelType, name, planPhaseOrder, priceType, replacesPriceId, dimensionalPriceConfiguration, additionalProperties) } - /* spotless:on */ - override fun hashCode(): Int = hashCode override fun toString() = @@ -17569,7 +18053,7 @@ private constructor( return true } - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + return other is Cadence && value == other.value } override fun hashCode() = value.hashCode() @@ -17659,10 +18143,10 @@ private constructor( return true } - return /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ + return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(unit, tiered) override fun toString(): String = when { @@ -17846,12 +18330,10 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -17979,7 +18461,7 @@ private constructor( return true } - return /* spotless:off */ other is PriceType && value == other.value /* spotless:on */ + return other is PriceType && value == other.value } override fun hashCode() = value.hashCode() @@ -18082,12 +18564,11 @@ private constructor( return true } - return /* spotless:off */ other is ThresholdTotalAmountConfig && additionalProperties == other.additionalProperties /* spotless:on */ + return other is ThresholdTotalAmountConfig && + additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -18100,13 +18581,68 @@ private constructor( return true } - return /* spotless:off */ other is ThresholdTotalAmount && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && conversionRate == other.conversionRate && conversionRateConfig == other.conversionRateConfig && createdAt == other.createdAt && creditAllocation == other.creditAllocation && currency == other.currency && discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maximum == other.maximum && maximumAmount == other.maximumAmount && metadata == other.metadata && minimum == other.minimum && minimumAmount == other.minimumAmount && modelType == other.modelType && name == other.name && planPhaseOrder == other.planPhaseOrder && priceType == other.priceType && replacesPriceId == other.replacesPriceId && thresholdTotalAmountConfig == other.thresholdTotalAmountConfig && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ + return other is ThresholdTotalAmount && + id == other.id && + billableMetric == other.billableMetric && + billingCycleConfiguration == other.billingCycleConfiguration && + cadence == other.cadence && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + createdAt == other.createdAt && + creditAllocation == other.creditAllocation && + currency == other.currency && + discount == other.discount && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + item == other.item && + maximum == other.maximum && + maximumAmount == other.maximumAmount && + metadata == other.metadata && + minimum == other.minimum && + minimumAmount == other.minimumAmount && + modelType == other.modelType && + name == other.name && + planPhaseOrder == other.planPhaseOrder && + priceType == other.priceType && + replacesPriceId == other.replacesPriceId && + thresholdTotalAmountConfig == other.thresholdTotalAmountConfig && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + billableMetric, + billingCycleConfiguration, + cadence, + conversionRate, + conversionRateConfig, + createdAt, + creditAllocation, + currency, + discount, + externalPriceId, + fixedPriceQuantity, + invoicingCycleConfiguration, + item, + maximum, + maximumAmount, + metadata, + minimum, + minimumAmount, + modelType, + name, + planPhaseOrder, + priceType, + replacesPriceId, + thresholdTotalAmountConfig, + dimensionalPriceConfiguration, + additionalProperties, + ) } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, billableMetric, billingCycleConfiguration, cadence, conversionRate, conversionRateConfig, createdAt, creditAllocation, currency, discount, externalPriceId, fixedPriceQuantity, invoicingCycleConfiguration, item, maximum, maximumAmount, metadata, minimum, minimumAmount, modelType, name, planPhaseOrder, priceType, replacesPriceId, thresholdTotalAmountConfig, dimensionalPriceConfiguration, additionalProperties) } - /* spotless:on */ - override fun hashCode(): Int = hashCode override fun toString() = @@ -19568,7 +20104,7 @@ private constructor( return true } - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + return other is Cadence && value == other.value } override fun hashCode() = value.hashCode() @@ -19658,10 +20194,10 @@ private constructor( return true } - return /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ + return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(unit, tiered) override fun toString(): String = when { @@ -19845,12 +20381,10 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -19978,7 +20512,7 @@ private constructor( return true } - return /* spotless:off */ other is PriceType && value == other.value /* spotless:on */ + return other is PriceType && value == other.value } override fun hashCode() = value.hashCode() @@ -20079,12 +20613,11 @@ private constructor( return true } - return /* spotless:off */ other is TieredPackageConfig && additionalProperties == other.additionalProperties /* spotless:on */ + return other is TieredPackageConfig && + additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -20097,13 +20630,68 @@ private constructor( return true } - return /* spotless:off */ other is TieredPackage && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && conversionRate == other.conversionRate && conversionRateConfig == other.conversionRateConfig && createdAt == other.createdAt && creditAllocation == other.creditAllocation && currency == other.currency && discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maximum == other.maximum && maximumAmount == other.maximumAmount && metadata == other.metadata && minimum == other.minimum && minimumAmount == other.minimumAmount && modelType == other.modelType && name == other.name && planPhaseOrder == other.planPhaseOrder && priceType == other.priceType && replacesPriceId == other.replacesPriceId && tieredPackageConfig == other.tieredPackageConfig && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ + return other is TieredPackage && + id == other.id && + billableMetric == other.billableMetric && + billingCycleConfiguration == other.billingCycleConfiguration && + cadence == other.cadence && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + createdAt == other.createdAt && + creditAllocation == other.creditAllocation && + currency == other.currency && + discount == other.discount && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + item == other.item && + maximum == other.maximum && + maximumAmount == other.maximumAmount && + metadata == other.metadata && + minimum == other.minimum && + minimumAmount == other.minimumAmount && + modelType == other.modelType && + name == other.name && + planPhaseOrder == other.planPhaseOrder && + priceType == other.priceType && + replacesPriceId == other.replacesPriceId && + tieredPackageConfig == other.tieredPackageConfig && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + billableMetric, + billingCycleConfiguration, + cadence, + conversionRate, + conversionRateConfig, + createdAt, + creditAllocation, + currency, + discount, + externalPriceId, + fixedPriceQuantity, + invoicingCycleConfiguration, + item, + maximum, + maximumAmount, + metadata, + minimum, + minimumAmount, + modelType, + name, + planPhaseOrder, + priceType, + replacesPriceId, + tieredPackageConfig, + dimensionalPriceConfiguration, + additionalProperties, + ) } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, billableMetric, billingCycleConfiguration, cadence, conversionRate, conversionRateConfig, createdAt, creditAllocation, currency, discount, externalPriceId, fixedPriceQuantity, invoicingCycleConfiguration, item, maximum, maximumAmount, metadata, minimum, minimumAmount, modelType, name, planPhaseOrder, priceType, replacesPriceId, tieredPackageConfig, dimensionalPriceConfiguration, additionalProperties) } - /* spotless:on */ - override fun hashCode(): Int = hashCode override fun toString() = @@ -21565,7 +22153,7 @@ private constructor( return true } - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + return other is Cadence && value == other.value } override fun hashCode() = value.hashCode() @@ -21655,10 +22243,10 @@ private constructor( return true } - return /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ + return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(unit, tiered) override fun toString(): String = when { @@ -21840,12 +22428,11 @@ private constructor( return true } - return /* spotless:off */ other is GroupedTieredConfig && additionalProperties == other.additionalProperties /* spotless:on */ + return other is GroupedTieredConfig && + additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -21948,12 +22535,10 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -22081,7 +22666,7 @@ private constructor( return true } - return /* spotless:off */ other is PriceType && value == other.value /* spotless:on */ + return other is PriceType && value == other.value } override fun hashCode() = value.hashCode() @@ -22094,13 +22679,68 @@ private constructor( return true } - return /* spotless:off */ other is GroupedTiered && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && conversionRate == other.conversionRate && conversionRateConfig == other.conversionRateConfig && createdAt == other.createdAt && creditAllocation == other.creditAllocation && currency == other.currency && discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && groupedTieredConfig == other.groupedTieredConfig && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maximum == other.maximum && maximumAmount == other.maximumAmount && metadata == other.metadata && minimum == other.minimum && minimumAmount == other.minimumAmount && modelType == other.modelType && name == other.name && planPhaseOrder == other.planPhaseOrder && priceType == other.priceType && replacesPriceId == other.replacesPriceId && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ + return other is GroupedTiered && + id == other.id && + billableMetric == other.billableMetric && + billingCycleConfiguration == other.billingCycleConfiguration && + cadence == other.cadence && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + createdAt == other.createdAt && + creditAllocation == other.creditAllocation && + currency == other.currency && + discount == other.discount && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + groupedTieredConfig == other.groupedTieredConfig && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + item == other.item && + maximum == other.maximum && + maximumAmount == other.maximumAmount && + metadata == other.metadata && + minimum == other.minimum && + minimumAmount == other.minimumAmount && + modelType == other.modelType && + name == other.name && + planPhaseOrder == other.planPhaseOrder && + priceType == other.priceType && + replacesPriceId == other.replacesPriceId && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + billableMetric, + billingCycleConfiguration, + cadence, + conversionRate, + conversionRateConfig, + createdAt, + creditAllocation, + currency, + discount, + externalPriceId, + fixedPriceQuantity, + groupedTieredConfig, + invoicingCycleConfiguration, + item, + maximum, + maximumAmount, + metadata, + minimum, + minimumAmount, + modelType, + name, + planPhaseOrder, + priceType, + replacesPriceId, + dimensionalPriceConfiguration, + additionalProperties, + ) } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, billableMetric, billingCycleConfiguration, cadence, conversionRate, conversionRateConfig, createdAt, creditAllocation, currency, discount, externalPriceId, fixedPriceQuantity, groupedTieredConfig, invoicingCycleConfiguration, item, maximum, maximumAmount, metadata, minimum, minimumAmount, modelType, name, planPhaseOrder, priceType, replacesPriceId, dimensionalPriceConfiguration, additionalProperties) } - /* spotless:on */ - override fun hashCode(): Int = hashCode override fun toString() = @@ -23562,7 +24202,7 @@ private constructor( return true } - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + return other is Cadence && value == other.value } override fun hashCode() = value.hashCode() @@ -23652,10 +24292,10 @@ private constructor( return true } - return /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ + return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(unit, tiered) override fun toString(): String = when { @@ -23839,12 +24479,10 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -23972,7 +24610,7 @@ private constructor( return true } - return /* spotless:off */ other is PriceType && value == other.value /* spotless:on */ + return other is PriceType && value == other.value } override fun hashCode() = value.hashCode() @@ -24075,12 +24713,11 @@ private constructor( return true } - return /* spotless:off */ other is TieredWithMinimumConfig && additionalProperties == other.additionalProperties /* spotless:on */ + return other is TieredWithMinimumConfig && + additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -24093,13 +24730,68 @@ private constructor( return true } - return /* spotless:off */ other is TieredWithMinimum && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && conversionRate == other.conversionRate && conversionRateConfig == other.conversionRateConfig && createdAt == other.createdAt && creditAllocation == other.creditAllocation && currency == other.currency && discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maximum == other.maximum && maximumAmount == other.maximumAmount && metadata == other.metadata && minimum == other.minimum && minimumAmount == other.minimumAmount && modelType == other.modelType && name == other.name && planPhaseOrder == other.planPhaseOrder && priceType == other.priceType && replacesPriceId == other.replacesPriceId && tieredWithMinimumConfig == other.tieredWithMinimumConfig && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ + return other is TieredWithMinimum && + id == other.id && + billableMetric == other.billableMetric && + billingCycleConfiguration == other.billingCycleConfiguration && + cadence == other.cadence && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + createdAt == other.createdAt && + creditAllocation == other.creditAllocation && + currency == other.currency && + discount == other.discount && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + item == other.item && + maximum == other.maximum && + maximumAmount == other.maximumAmount && + metadata == other.metadata && + minimum == other.minimum && + minimumAmount == other.minimumAmount && + modelType == other.modelType && + name == other.name && + planPhaseOrder == other.planPhaseOrder && + priceType == other.priceType && + replacesPriceId == other.replacesPriceId && + tieredWithMinimumConfig == other.tieredWithMinimumConfig && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + billableMetric, + billingCycleConfiguration, + cadence, + conversionRate, + conversionRateConfig, + createdAt, + creditAllocation, + currency, + discount, + externalPriceId, + fixedPriceQuantity, + invoicingCycleConfiguration, + item, + maximum, + maximumAmount, + metadata, + minimum, + minimumAmount, + modelType, + name, + planPhaseOrder, + priceType, + replacesPriceId, + tieredWithMinimumConfig, + dimensionalPriceConfiguration, + additionalProperties, + ) } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, billableMetric, billingCycleConfiguration, cadence, conversionRate, conversionRateConfig, createdAt, creditAllocation, currency, discount, externalPriceId, fixedPriceQuantity, invoicingCycleConfiguration, item, maximum, maximumAmount, metadata, minimum, minimumAmount, modelType, name, planPhaseOrder, priceType, replacesPriceId, tieredWithMinimumConfig, dimensionalPriceConfiguration, additionalProperties) } - /* spotless:on */ - override fun hashCode(): Int = hashCode override fun toString() = @@ -25569,7 +26261,7 @@ private constructor( return true } - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + return other is Cadence && value == other.value } override fun hashCode() = value.hashCode() @@ -25659,10 +26351,10 @@ private constructor( return true } - return /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ + return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(unit, tiered) override fun toString(): String = when { @@ -25846,12 +26538,10 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -25979,7 +26669,7 @@ private constructor( return true } - return /* spotless:off */ other is PriceType && value == other.value /* spotless:on */ + return other is PriceType && value == other.value } override fun hashCode() = value.hashCode() @@ -26083,12 +26773,11 @@ private constructor( return true } - return /* spotless:off */ other is TieredPackageWithMinimumConfig && additionalProperties == other.additionalProperties /* spotless:on */ + return other is TieredPackageWithMinimumConfig && + additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -26101,13 +26790,68 @@ private constructor( return true } - return /* spotless:off */ other is TieredPackageWithMinimum && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && conversionRate == other.conversionRate && conversionRateConfig == other.conversionRateConfig && createdAt == other.createdAt && creditAllocation == other.creditAllocation && currency == other.currency && discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maximum == other.maximum && maximumAmount == other.maximumAmount && metadata == other.metadata && minimum == other.minimum && minimumAmount == other.minimumAmount && modelType == other.modelType && name == other.name && planPhaseOrder == other.planPhaseOrder && priceType == other.priceType && replacesPriceId == other.replacesPriceId && tieredPackageWithMinimumConfig == other.tieredPackageWithMinimumConfig && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ + return other is TieredPackageWithMinimum && + id == other.id && + billableMetric == other.billableMetric && + billingCycleConfiguration == other.billingCycleConfiguration && + cadence == other.cadence && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + createdAt == other.createdAt && + creditAllocation == other.creditAllocation && + currency == other.currency && + discount == other.discount && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + item == other.item && + maximum == other.maximum && + maximumAmount == other.maximumAmount && + metadata == other.metadata && + minimum == other.minimum && + minimumAmount == other.minimumAmount && + modelType == other.modelType && + name == other.name && + planPhaseOrder == other.planPhaseOrder && + priceType == other.priceType && + replacesPriceId == other.replacesPriceId && + tieredPackageWithMinimumConfig == other.tieredPackageWithMinimumConfig && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + billableMetric, + billingCycleConfiguration, + cadence, + conversionRate, + conversionRateConfig, + createdAt, + creditAllocation, + currency, + discount, + externalPriceId, + fixedPriceQuantity, + invoicingCycleConfiguration, + item, + maximum, + maximumAmount, + metadata, + minimum, + minimumAmount, + modelType, + name, + planPhaseOrder, + priceType, + replacesPriceId, + tieredPackageWithMinimumConfig, + dimensionalPriceConfiguration, + additionalProperties, + ) } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, billableMetric, billingCycleConfiguration, cadence, conversionRate, conversionRateConfig, createdAt, creditAllocation, currency, discount, externalPriceId, fixedPriceQuantity, invoicingCycleConfiguration, item, maximum, maximumAmount, metadata, minimum, minimumAmount, modelType, name, planPhaseOrder, priceType, replacesPriceId, tieredPackageWithMinimumConfig, dimensionalPriceConfiguration, additionalProperties) } - /* spotless:on */ - override fun hashCode(): Int = hashCode override fun toString() = @@ -27571,7 +28315,7 @@ private constructor( return true } - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + return other is Cadence && value == other.value } override fun hashCode() = value.hashCode() @@ -27661,10 +28405,10 @@ private constructor( return true } - return /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ + return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(unit, tiered) override fun toString(): String = when { @@ -27848,12 +28592,10 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -27956,12 +28698,11 @@ private constructor( return true } - return /* spotless:off */ other is PackageWithAllocationConfig && additionalProperties == other.additionalProperties /* spotless:on */ + return other is PackageWithAllocationConfig && + additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -28090,7 +28831,7 @@ private constructor( return true } - return /* spotless:off */ other is PriceType && value == other.value /* spotless:on */ + return other is PriceType && value == other.value } override fun hashCode() = value.hashCode() @@ -28103,13 +28844,68 @@ private constructor( return true } - return /* spotless:off */ other is PackageWithAllocation && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && conversionRate == other.conversionRate && conversionRateConfig == other.conversionRateConfig && createdAt == other.createdAt && creditAllocation == other.creditAllocation && currency == other.currency && discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maximum == other.maximum && maximumAmount == other.maximumAmount && metadata == other.metadata && minimum == other.minimum && minimumAmount == other.minimumAmount && modelType == other.modelType && name == other.name && packageWithAllocationConfig == other.packageWithAllocationConfig && planPhaseOrder == other.planPhaseOrder && priceType == other.priceType && replacesPriceId == other.replacesPriceId && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ + return other is PackageWithAllocation && + id == other.id && + billableMetric == other.billableMetric && + billingCycleConfiguration == other.billingCycleConfiguration && + cadence == other.cadence && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + createdAt == other.createdAt && + creditAllocation == other.creditAllocation && + currency == other.currency && + discount == other.discount && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + item == other.item && + maximum == other.maximum && + maximumAmount == other.maximumAmount && + metadata == other.metadata && + minimum == other.minimum && + minimumAmount == other.minimumAmount && + modelType == other.modelType && + name == other.name && + packageWithAllocationConfig == other.packageWithAllocationConfig && + planPhaseOrder == other.planPhaseOrder && + priceType == other.priceType && + replacesPriceId == other.replacesPriceId && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + billableMetric, + billingCycleConfiguration, + cadence, + conversionRate, + conversionRateConfig, + createdAt, + creditAllocation, + currency, + discount, + externalPriceId, + fixedPriceQuantity, + invoicingCycleConfiguration, + item, + maximum, + maximumAmount, + metadata, + minimum, + minimumAmount, + modelType, + name, + packageWithAllocationConfig, + planPhaseOrder, + priceType, + replacesPriceId, + dimensionalPriceConfiguration, + additionalProperties, + ) } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, billableMetric, billingCycleConfiguration, cadence, conversionRate, conversionRateConfig, createdAt, creditAllocation, currency, discount, externalPriceId, fixedPriceQuantity, invoicingCycleConfiguration, item, maximum, maximumAmount, metadata, minimum, minimumAmount, modelType, name, packageWithAllocationConfig, planPhaseOrder, priceType, replacesPriceId, dimensionalPriceConfiguration, additionalProperties) } - /* spotless:on */ - override fun hashCode(): Int = hashCode override fun toString() = @@ -29572,7 +30368,7 @@ private constructor( return true } - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + return other is Cadence && value == other.value } override fun hashCode() = value.hashCode() @@ -29662,10 +30458,10 @@ private constructor( return true } - return /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ + return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(unit, tiered) override fun toString(): String = when { @@ -29849,12 +30645,10 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -29982,7 +30776,7 @@ private constructor( return true } - return /* spotless:off */ other is PriceType && value == other.value /* spotless:on */ + return other is PriceType && value == other.value } override fun hashCode() = value.hashCode() @@ -30084,12 +30878,11 @@ private constructor( return true } - return /* spotless:off */ other is UnitWithPercentConfig && additionalProperties == other.additionalProperties /* spotless:on */ + return other is UnitWithPercentConfig && + additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -30102,13 +30895,68 @@ private constructor( return true } - return /* spotless:off */ other is UnitWithPercent && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && conversionRate == other.conversionRate && conversionRateConfig == other.conversionRateConfig && createdAt == other.createdAt && creditAllocation == other.creditAllocation && currency == other.currency && discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maximum == other.maximum && maximumAmount == other.maximumAmount && metadata == other.metadata && minimum == other.minimum && minimumAmount == other.minimumAmount && modelType == other.modelType && name == other.name && planPhaseOrder == other.planPhaseOrder && priceType == other.priceType && replacesPriceId == other.replacesPriceId && unitWithPercentConfig == other.unitWithPercentConfig && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ + return other is UnitWithPercent && + id == other.id && + billableMetric == other.billableMetric && + billingCycleConfiguration == other.billingCycleConfiguration && + cadence == other.cadence && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + createdAt == other.createdAt && + creditAllocation == other.creditAllocation && + currency == other.currency && + discount == other.discount && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + item == other.item && + maximum == other.maximum && + maximumAmount == other.maximumAmount && + metadata == other.metadata && + minimum == other.minimum && + minimumAmount == other.minimumAmount && + modelType == other.modelType && + name == other.name && + planPhaseOrder == other.planPhaseOrder && + priceType == other.priceType && + replacesPriceId == other.replacesPriceId && + unitWithPercentConfig == other.unitWithPercentConfig && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + billableMetric, + billingCycleConfiguration, + cadence, + conversionRate, + conversionRateConfig, + createdAt, + creditAllocation, + currency, + discount, + externalPriceId, + fixedPriceQuantity, + invoicingCycleConfiguration, + item, + maximum, + maximumAmount, + metadata, + minimum, + minimumAmount, + modelType, + name, + planPhaseOrder, + priceType, + replacesPriceId, + unitWithPercentConfig, + dimensionalPriceConfiguration, + additionalProperties, + ) } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, billableMetric, billingCycleConfiguration, cadence, conversionRate, conversionRateConfig, createdAt, creditAllocation, currency, discount, externalPriceId, fixedPriceQuantity, invoicingCycleConfiguration, item, maximum, maximumAmount, metadata, minimum, minimumAmount, modelType, name, planPhaseOrder, priceType, replacesPriceId, unitWithPercentConfig, dimensionalPriceConfiguration, additionalProperties) } - /* spotless:on */ - override fun hashCode(): Int = hashCode override fun toString() = @@ -31571,7 +32419,7 @@ private constructor( return true } - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + return other is Cadence && value == other.value } override fun hashCode() = value.hashCode() @@ -31661,10 +32509,10 @@ private constructor( return true } - return /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ + return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(unit, tiered) override fun toString(): String = when { @@ -31848,12 +32696,10 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -31981,7 +32827,7 @@ private constructor( return true } - return /* spotless:off */ other is PriceType && value == other.value /* spotless:on */ + return other is PriceType && value == other.value } override fun hashCode() = value.hashCode() @@ -31994,13 +32840,68 @@ private constructor( return true } - return /* spotless:off */ other is MatrixWithAllocation && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && conversionRate == other.conversionRate && conversionRateConfig == other.conversionRateConfig && createdAt == other.createdAt && creditAllocation == other.creditAllocation && currency == other.currency && discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && matrixWithAllocationConfig == other.matrixWithAllocationConfig && maximum == other.maximum && maximumAmount == other.maximumAmount && metadata == other.metadata && minimum == other.minimum && minimumAmount == other.minimumAmount && modelType == other.modelType && name == other.name && planPhaseOrder == other.planPhaseOrder && priceType == other.priceType && replacesPriceId == other.replacesPriceId && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ + return other is MatrixWithAllocation && + id == other.id && + billableMetric == other.billableMetric && + billingCycleConfiguration == other.billingCycleConfiguration && + cadence == other.cadence && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + createdAt == other.createdAt && + creditAllocation == other.creditAllocation && + currency == other.currency && + discount == other.discount && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + item == other.item && + matrixWithAllocationConfig == other.matrixWithAllocationConfig && + maximum == other.maximum && + maximumAmount == other.maximumAmount && + metadata == other.metadata && + minimum == other.minimum && + minimumAmount == other.minimumAmount && + modelType == other.modelType && + name == other.name && + planPhaseOrder == other.planPhaseOrder && + priceType == other.priceType && + replacesPriceId == other.replacesPriceId && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + billableMetric, + billingCycleConfiguration, + cadence, + conversionRate, + conversionRateConfig, + createdAt, + creditAllocation, + currency, + discount, + externalPriceId, + fixedPriceQuantity, + invoicingCycleConfiguration, + item, + matrixWithAllocationConfig, + maximum, + maximumAmount, + metadata, + minimum, + minimumAmount, + modelType, + name, + planPhaseOrder, + priceType, + replacesPriceId, + dimensionalPriceConfiguration, + additionalProperties, + ) } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, billableMetric, billingCycleConfiguration, cadence, conversionRate, conversionRateConfig, createdAt, creditAllocation, currency, discount, externalPriceId, fixedPriceQuantity, invoicingCycleConfiguration, item, matrixWithAllocationConfig, maximum, maximumAmount, metadata, minimum, minimumAmount, modelType, name, planPhaseOrder, priceType, replacesPriceId, dimensionalPriceConfiguration, additionalProperties) } - /* spotless:on */ - override fun hashCode(): Int = hashCode override fun toString() = @@ -33463,7 +34364,7 @@ private constructor( return true } - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + return other is Cadence && value == other.value } override fun hashCode() = value.hashCode() @@ -33553,10 +34454,10 @@ private constructor( return true } - return /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ + return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(unit, tiered) override fun toString(): String = when { @@ -33740,12 +34641,10 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -33873,7 +34772,7 @@ private constructor( return true } - return /* spotless:off */ other is PriceType && value == other.value /* spotless:on */ + return other is PriceType && value == other.value } override fun hashCode() = value.hashCode() @@ -33976,12 +34875,11 @@ private constructor( return true } - return /* spotless:off */ other is TieredWithProrationConfig && additionalProperties == other.additionalProperties /* spotless:on */ + return other is TieredWithProrationConfig && + additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -33994,13 +34892,68 @@ private constructor( return true } - return /* spotless:off */ other is TieredWithProration && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && conversionRate == other.conversionRate && conversionRateConfig == other.conversionRateConfig && createdAt == other.createdAt && creditAllocation == other.creditAllocation && currency == other.currency && discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maximum == other.maximum && maximumAmount == other.maximumAmount && metadata == other.metadata && minimum == other.minimum && minimumAmount == other.minimumAmount && modelType == other.modelType && name == other.name && planPhaseOrder == other.planPhaseOrder && priceType == other.priceType && replacesPriceId == other.replacesPriceId && tieredWithProrationConfig == other.tieredWithProrationConfig && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ + return other is TieredWithProration && + id == other.id && + billableMetric == other.billableMetric && + billingCycleConfiguration == other.billingCycleConfiguration && + cadence == other.cadence && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + createdAt == other.createdAt && + creditAllocation == other.creditAllocation && + currency == other.currency && + discount == other.discount && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + item == other.item && + maximum == other.maximum && + maximumAmount == other.maximumAmount && + metadata == other.metadata && + minimum == other.minimum && + minimumAmount == other.minimumAmount && + modelType == other.modelType && + name == other.name && + planPhaseOrder == other.planPhaseOrder && + priceType == other.priceType && + replacesPriceId == other.replacesPriceId && + tieredWithProrationConfig == other.tieredWithProrationConfig && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + billableMetric, + billingCycleConfiguration, + cadence, + conversionRate, + conversionRateConfig, + createdAt, + creditAllocation, + currency, + discount, + externalPriceId, + fixedPriceQuantity, + invoicingCycleConfiguration, + item, + maximum, + maximumAmount, + metadata, + minimum, + minimumAmount, + modelType, + name, + planPhaseOrder, + priceType, + replacesPriceId, + tieredWithProrationConfig, + dimensionalPriceConfiguration, + additionalProperties, + ) } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, billableMetric, billingCycleConfiguration, cadence, conversionRate, conversionRateConfig, createdAt, creditAllocation, currency, discount, externalPriceId, fixedPriceQuantity, invoicingCycleConfiguration, item, maximum, maximumAmount, metadata, minimum, minimumAmount, modelType, name, planPhaseOrder, priceType, replacesPriceId, tieredWithProrationConfig, dimensionalPriceConfiguration, additionalProperties) } - /* spotless:on */ - override fun hashCode(): Int = hashCode override fun toString() = @@ -35462,7 +36415,7 @@ private constructor( return true } - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + return other is Cadence && value == other.value } override fun hashCode() = value.hashCode() @@ -35552,10 +36505,10 @@ private constructor( return true } - return /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ + return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(unit, tiered) override fun toString(): String = when { @@ -35739,12 +36692,10 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -35872,7 +36823,7 @@ private constructor( return true } - return /* spotless:off */ other is PriceType && value == other.value /* spotless:on */ + return other is PriceType && value == other.value } override fun hashCode() = value.hashCode() @@ -35975,12 +36926,11 @@ private constructor( return true } - return /* spotless:off */ other is UnitWithProrationConfig && additionalProperties == other.additionalProperties /* spotless:on */ + return other is UnitWithProrationConfig && + additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -35993,13 +36943,68 @@ private constructor( return true } - return /* spotless:off */ other is UnitWithProration && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && conversionRate == other.conversionRate && conversionRateConfig == other.conversionRateConfig && createdAt == other.createdAt && creditAllocation == other.creditAllocation && currency == other.currency && discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maximum == other.maximum && maximumAmount == other.maximumAmount && metadata == other.metadata && minimum == other.minimum && minimumAmount == other.minimumAmount && modelType == other.modelType && name == other.name && planPhaseOrder == other.planPhaseOrder && priceType == other.priceType && replacesPriceId == other.replacesPriceId && unitWithProrationConfig == other.unitWithProrationConfig && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ + return other is UnitWithProration && + id == other.id && + billableMetric == other.billableMetric && + billingCycleConfiguration == other.billingCycleConfiguration && + cadence == other.cadence && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + createdAt == other.createdAt && + creditAllocation == other.creditAllocation && + currency == other.currency && + discount == other.discount && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + item == other.item && + maximum == other.maximum && + maximumAmount == other.maximumAmount && + metadata == other.metadata && + minimum == other.minimum && + minimumAmount == other.minimumAmount && + modelType == other.modelType && + name == other.name && + planPhaseOrder == other.planPhaseOrder && + priceType == other.priceType && + replacesPriceId == other.replacesPriceId && + unitWithProrationConfig == other.unitWithProrationConfig && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + billableMetric, + billingCycleConfiguration, + cadence, + conversionRate, + conversionRateConfig, + createdAt, + creditAllocation, + currency, + discount, + externalPriceId, + fixedPriceQuantity, + invoicingCycleConfiguration, + item, + maximum, + maximumAmount, + metadata, + minimum, + minimumAmount, + modelType, + name, + planPhaseOrder, + priceType, + replacesPriceId, + unitWithProrationConfig, + dimensionalPriceConfiguration, + additionalProperties, + ) } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, billableMetric, billingCycleConfiguration, cadence, conversionRate, conversionRateConfig, createdAt, creditAllocation, currency, discount, externalPriceId, fixedPriceQuantity, invoicingCycleConfiguration, item, maximum, maximumAmount, metadata, minimum, minimumAmount, modelType, name, planPhaseOrder, priceType, replacesPriceId, unitWithProrationConfig, dimensionalPriceConfiguration, additionalProperties) } - /* spotless:on */ - override fun hashCode(): Int = hashCode override fun toString() = @@ -37461,7 +38466,7 @@ private constructor( return true } - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + return other is Cadence && value == other.value } override fun hashCode() = value.hashCode() @@ -37551,10 +38556,10 @@ private constructor( return true } - return /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ + return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(unit, tiered) override fun toString(): String = when { @@ -37738,12 +38743,11 @@ private constructor( return true } - return /* spotless:off */ other is GroupedAllocationConfig && additionalProperties == other.additionalProperties /* spotless:on */ + return other is GroupedAllocationConfig && + additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -37846,12 +38850,10 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -37979,7 +38981,7 @@ private constructor( return true } - return /* spotless:off */ other is PriceType && value == other.value /* spotless:on */ + return other is PriceType && value == other.value } override fun hashCode() = value.hashCode() @@ -37992,13 +38994,68 @@ private constructor( return true } - return /* spotless:off */ other is GroupedAllocation && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && conversionRate == other.conversionRate && conversionRateConfig == other.conversionRateConfig && createdAt == other.createdAt && creditAllocation == other.creditAllocation && currency == other.currency && discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && groupedAllocationConfig == other.groupedAllocationConfig && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maximum == other.maximum && maximumAmount == other.maximumAmount && metadata == other.metadata && minimum == other.minimum && minimumAmount == other.minimumAmount && modelType == other.modelType && name == other.name && planPhaseOrder == other.planPhaseOrder && priceType == other.priceType && replacesPriceId == other.replacesPriceId && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ + return other is GroupedAllocation && + id == other.id && + billableMetric == other.billableMetric && + billingCycleConfiguration == other.billingCycleConfiguration && + cadence == other.cadence && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + createdAt == other.createdAt && + creditAllocation == other.creditAllocation && + currency == other.currency && + discount == other.discount && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + groupedAllocationConfig == other.groupedAllocationConfig && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + item == other.item && + maximum == other.maximum && + maximumAmount == other.maximumAmount && + metadata == other.metadata && + minimum == other.minimum && + minimumAmount == other.minimumAmount && + modelType == other.modelType && + name == other.name && + planPhaseOrder == other.planPhaseOrder && + priceType == other.priceType && + replacesPriceId == other.replacesPriceId && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + billableMetric, + billingCycleConfiguration, + cadence, + conversionRate, + conversionRateConfig, + createdAt, + creditAllocation, + currency, + discount, + externalPriceId, + fixedPriceQuantity, + groupedAllocationConfig, + invoicingCycleConfiguration, + item, + maximum, + maximumAmount, + metadata, + minimum, + minimumAmount, + modelType, + name, + planPhaseOrder, + priceType, + replacesPriceId, + dimensionalPriceConfiguration, + additionalProperties, + ) } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, billableMetric, billingCycleConfiguration, cadence, conversionRate, conversionRateConfig, createdAt, creditAllocation, currency, discount, externalPriceId, fixedPriceQuantity, groupedAllocationConfig, invoicingCycleConfiguration, item, maximum, maximumAmount, metadata, minimum, minimumAmount, modelType, name, planPhaseOrder, priceType, replacesPriceId, dimensionalPriceConfiguration, additionalProperties) } - /* spotless:on */ - override fun hashCode(): Int = hashCode override fun toString() = @@ -39474,7 +40531,7 @@ private constructor( return true } - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + return other is Cadence && value == other.value } override fun hashCode() = value.hashCode() @@ -39564,10 +40621,10 @@ private constructor( return true } - return /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ + return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(unit, tiered) override fun toString(): String = when { @@ -39753,12 +40810,11 @@ private constructor( return true } - return /* spotless:off */ other is GroupedWithProratedMinimumConfig && additionalProperties == other.additionalProperties /* spotless:on */ + return other is GroupedWithProratedMinimumConfig && + additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -39861,12 +40917,10 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -39994,7 +41048,7 @@ private constructor( return true } - return /* spotless:off */ other is PriceType && value == other.value /* spotless:on */ + return other is PriceType && value == other.value } override fun hashCode() = value.hashCode() @@ -40007,13 +41061,68 @@ private constructor( return true } - return /* spotless:off */ other is GroupedWithProratedMinimum && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && conversionRate == other.conversionRate && conversionRateConfig == other.conversionRateConfig && createdAt == other.createdAt && creditAllocation == other.creditAllocation && currency == other.currency && discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && groupedWithProratedMinimumConfig == other.groupedWithProratedMinimumConfig && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maximum == other.maximum && maximumAmount == other.maximumAmount && metadata == other.metadata && minimum == other.minimum && minimumAmount == other.minimumAmount && modelType == other.modelType && name == other.name && planPhaseOrder == other.planPhaseOrder && priceType == other.priceType && replacesPriceId == other.replacesPriceId && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ + return other is GroupedWithProratedMinimum && + id == other.id && + billableMetric == other.billableMetric && + billingCycleConfiguration == other.billingCycleConfiguration && + cadence == other.cadence && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + createdAt == other.createdAt && + creditAllocation == other.creditAllocation && + currency == other.currency && + discount == other.discount && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + groupedWithProratedMinimumConfig == other.groupedWithProratedMinimumConfig && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + item == other.item && + maximum == other.maximum && + maximumAmount == other.maximumAmount && + metadata == other.metadata && + minimum == other.minimum && + minimumAmount == other.minimumAmount && + modelType == other.modelType && + name == other.name && + planPhaseOrder == other.planPhaseOrder && + priceType == other.priceType && + replacesPriceId == other.replacesPriceId && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + billableMetric, + billingCycleConfiguration, + cadence, + conversionRate, + conversionRateConfig, + createdAt, + creditAllocation, + currency, + discount, + externalPriceId, + fixedPriceQuantity, + groupedWithProratedMinimumConfig, + invoicingCycleConfiguration, + item, + maximum, + maximumAmount, + metadata, + minimum, + minimumAmount, + modelType, + name, + planPhaseOrder, + priceType, + replacesPriceId, + dimensionalPriceConfiguration, + additionalProperties, + ) } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, billableMetric, billingCycleConfiguration, cadence, conversionRate, conversionRateConfig, createdAt, creditAllocation, currency, discount, externalPriceId, fixedPriceQuantity, groupedWithProratedMinimumConfig, invoicingCycleConfiguration, item, maximum, maximumAmount, metadata, minimum, minimumAmount, modelType, name, planPhaseOrder, priceType, replacesPriceId, dimensionalPriceConfiguration, additionalProperties) } - /* spotless:on */ - override fun hashCode(): Int = hashCode override fun toString() = @@ -41488,7 +42597,7 @@ private constructor( return true } - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + return other is Cadence && value == other.value } override fun hashCode() = value.hashCode() @@ -41578,10 +42687,10 @@ private constructor( return true } - return /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ + return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(unit, tiered) override fun toString(): String = when { @@ -41767,12 +42876,11 @@ private constructor( return true } - return /* spotless:off */ other is GroupedWithMeteredMinimumConfig && additionalProperties == other.additionalProperties /* spotless:on */ + return other is GroupedWithMeteredMinimumConfig && + additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -41875,12 +42983,10 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -42008,7 +43114,7 @@ private constructor( return true } - return /* spotless:off */ other is PriceType && value == other.value /* spotless:on */ + return other is PriceType && value == other.value } override fun hashCode() = value.hashCode() @@ -42021,13 +43127,68 @@ private constructor( return true } - return /* spotless:off */ other is GroupedWithMeteredMinimum && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && conversionRate == other.conversionRate && conversionRateConfig == other.conversionRateConfig && createdAt == other.createdAt && creditAllocation == other.creditAllocation && currency == other.currency && discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && groupedWithMeteredMinimumConfig == other.groupedWithMeteredMinimumConfig && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maximum == other.maximum && maximumAmount == other.maximumAmount && metadata == other.metadata && minimum == other.minimum && minimumAmount == other.minimumAmount && modelType == other.modelType && name == other.name && planPhaseOrder == other.planPhaseOrder && priceType == other.priceType && replacesPriceId == other.replacesPriceId && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ + return other is GroupedWithMeteredMinimum && + id == other.id && + billableMetric == other.billableMetric && + billingCycleConfiguration == other.billingCycleConfiguration && + cadence == other.cadence && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + createdAt == other.createdAt && + creditAllocation == other.creditAllocation && + currency == other.currency && + discount == other.discount && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + groupedWithMeteredMinimumConfig == other.groupedWithMeteredMinimumConfig && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + item == other.item && + maximum == other.maximum && + maximumAmount == other.maximumAmount && + metadata == other.metadata && + minimum == other.minimum && + minimumAmount == other.minimumAmount && + modelType == other.modelType && + name == other.name && + planPhaseOrder == other.planPhaseOrder && + priceType == other.priceType && + replacesPriceId == other.replacesPriceId && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + billableMetric, + billingCycleConfiguration, + cadence, + conversionRate, + conversionRateConfig, + createdAt, + creditAllocation, + currency, + discount, + externalPriceId, + fixedPriceQuantity, + groupedWithMeteredMinimumConfig, + invoicingCycleConfiguration, + item, + maximum, + maximumAmount, + metadata, + minimum, + minimumAmount, + modelType, + name, + planPhaseOrder, + priceType, + replacesPriceId, + dimensionalPriceConfiguration, + additionalProperties, + ) } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, billableMetric, billingCycleConfiguration, cadence, conversionRate, conversionRateConfig, createdAt, creditAllocation, currency, discount, externalPriceId, fixedPriceQuantity, groupedWithMeteredMinimumConfig, invoicingCycleConfiguration, item, maximum, maximumAmount, metadata, minimum, minimumAmount, modelType, name, planPhaseOrder, priceType, replacesPriceId, dimensionalPriceConfiguration, additionalProperties) } - /* spotless:on */ - override fun hashCode(): Int = hashCode override fun toString() = @@ -43491,7 +44652,7 @@ private constructor( return true } - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + return other is Cadence && value == other.value } override fun hashCode() = value.hashCode() @@ -43581,10 +44742,10 @@ private constructor( return true } - return /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ + return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(unit, tiered) override fun toString(): String = when { @@ -43769,12 +44930,11 @@ private constructor( return true } - return /* spotless:off */ other is MatrixWithDisplayNameConfig && additionalProperties == other.additionalProperties /* spotless:on */ + return other is MatrixWithDisplayNameConfig && + additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -43877,12 +45037,10 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -44010,7 +45168,7 @@ private constructor( return true } - return /* spotless:off */ other is PriceType && value == other.value /* spotless:on */ + return other is PriceType && value == other.value } override fun hashCode() = value.hashCode() @@ -44023,13 +45181,68 @@ private constructor( return true } - return /* spotless:off */ other is MatrixWithDisplayName && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && conversionRate == other.conversionRate && conversionRateConfig == other.conversionRateConfig && createdAt == other.createdAt && creditAllocation == other.creditAllocation && currency == other.currency && discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && matrixWithDisplayNameConfig == other.matrixWithDisplayNameConfig && maximum == other.maximum && maximumAmount == other.maximumAmount && metadata == other.metadata && minimum == other.minimum && minimumAmount == other.minimumAmount && modelType == other.modelType && name == other.name && planPhaseOrder == other.planPhaseOrder && priceType == other.priceType && replacesPriceId == other.replacesPriceId && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ + return other is MatrixWithDisplayName && + id == other.id && + billableMetric == other.billableMetric && + billingCycleConfiguration == other.billingCycleConfiguration && + cadence == other.cadence && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + createdAt == other.createdAt && + creditAllocation == other.creditAllocation && + currency == other.currency && + discount == other.discount && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + item == other.item && + matrixWithDisplayNameConfig == other.matrixWithDisplayNameConfig && + maximum == other.maximum && + maximumAmount == other.maximumAmount && + metadata == other.metadata && + minimum == other.minimum && + minimumAmount == other.minimumAmount && + modelType == other.modelType && + name == other.name && + planPhaseOrder == other.planPhaseOrder && + priceType == other.priceType && + replacesPriceId == other.replacesPriceId && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + billableMetric, + billingCycleConfiguration, + cadence, + conversionRate, + conversionRateConfig, + createdAt, + creditAllocation, + currency, + discount, + externalPriceId, + fixedPriceQuantity, + invoicingCycleConfiguration, + item, + matrixWithDisplayNameConfig, + maximum, + maximumAmount, + metadata, + minimum, + minimumAmount, + modelType, + name, + planPhaseOrder, + priceType, + replacesPriceId, + dimensionalPriceConfiguration, + additionalProperties, + ) } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, billableMetric, billingCycleConfiguration, cadence, conversionRate, conversionRateConfig, createdAt, creditAllocation, currency, discount, externalPriceId, fixedPriceQuantity, invoicingCycleConfiguration, item, matrixWithDisplayNameConfig, maximum, maximumAmount, metadata, minimum, minimumAmount, modelType, name, planPhaseOrder, priceType, replacesPriceId, dimensionalPriceConfiguration, additionalProperties) } - /* spotless:on */ - override fun hashCode(): Int = hashCode override fun toString() = @@ -45442,12 +46655,11 @@ private constructor( return true } - return /* spotless:off */ other is BulkWithProrationConfig && additionalProperties == other.additionalProperties /* spotless:on */ + return other is BulkWithProrationConfig && + additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -45599,7 +46811,7 @@ private constructor( return true } - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + return other is Cadence && value == other.value } override fun hashCode() = value.hashCode() @@ -45689,10 +46901,10 @@ private constructor( return true } - return /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ + return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(unit, tiered) override fun toString(): String = when { @@ -45876,12 +47088,10 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -46009,7 +47219,7 @@ private constructor( return true } - return /* spotless:off */ other is PriceType && value == other.value /* spotless:on */ + return other is PriceType && value == other.value } override fun hashCode() = value.hashCode() @@ -46022,13 +47232,68 @@ private constructor( return true } - return /* spotless:off */ other is BulkWithProration && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && bulkWithProrationConfig == other.bulkWithProrationConfig && cadence == other.cadence && conversionRate == other.conversionRate && conversionRateConfig == other.conversionRateConfig && createdAt == other.createdAt && creditAllocation == other.creditAllocation && currency == other.currency && discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maximum == other.maximum && maximumAmount == other.maximumAmount && metadata == other.metadata && minimum == other.minimum && minimumAmount == other.minimumAmount && modelType == other.modelType && name == other.name && planPhaseOrder == other.planPhaseOrder && priceType == other.priceType && replacesPriceId == other.replacesPriceId && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ + return other is BulkWithProration && + id == other.id && + billableMetric == other.billableMetric && + billingCycleConfiguration == other.billingCycleConfiguration && + bulkWithProrationConfig == other.bulkWithProrationConfig && + cadence == other.cadence && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + createdAt == other.createdAt && + creditAllocation == other.creditAllocation && + currency == other.currency && + discount == other.discount && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + item == other.item && + maximum == other.maximum && + maximumAmount == other.maximumAmount && + metadata == other.metadata && + minimum == other.minimum && + minimumAmount == other.minimumAmount && + modelType == other.modelType && + name == other.name && + planPhaseOrder == other.planPhaseOrder && + priceType == other.priceType && + replacesPriceId == other.replacesPriceId && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + billableMetric, + billingCycleConfiguration, + bulkWithProrationConfig, + cadence, + conversionRate, + conversionRateConfig, + createdAt, + creditAllocation, + currency, + discount, + externalPriceId, + fixedPriceQuantity, + invoicingCycleConfiguration, + item, + maximum, + maximumAmount, + metadata, + minimum, + minimumAmount, + modelType, + name, + planPhaseOrder, + priceType, + replacesPriceId, + dimensionalPriceConfiguration, + additionalProperties, + ) } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, billableMetric, billingCycleConfiguration, bulkWithProrationConfig, cadence, conversionRate, conversionRateConfig, createdAt, creditAllocation, currency, discount, externalPriceId, fixedPriceQuantity, invoicingCycleConfiguration, item, maximum, maximumAmount, metadata, minimum, minimumAmount, modelType, name, planPhaseOrder, priceType, replacesPriceId, dimensionalPriceConfiguration, additionalProperties) } - /* spotless:on */ - override fun hashCode(): Int = hashCode override fun toString() = @@ -47491,7 +48756,7 @@ private constructor( return true } - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + return other is Cadence && value == other.value } override fun hashCode() = value.hashCode() @@ -47581,10 +48846,10 @@ private constructor( return true } - return /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ + return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(unit, tiered) override fun toString(): String = when { @@ -47768,12 +49033,11 @@ private constructor( return true } - return /* spotless:off */ other is GroupedTieredPackageConfig && additionalProperties == other.additionalProperties /* spotless:on */ + return other is GroupedTieredPackageConfig && + additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -47876,12 +49140,10 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -48009,7 +49271,7 @@ private constructor( return true } - return /* spotless:off */ other is PriceType && value == other.value /* spotless:on */ + return other is PriceType && value == other.value } override fun hashCode() = value.hashCode() @@ -48022,13 +49284,68 @@ private constructor( return true } - return /* spotless:off */ other is GroupedTieredPackage && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && conversionRate == other.conversionRate && conversionRateConfig == other.conversionRateConfig && createdAt == other.createdAt && creditAllocation == other.creditAllocation && currency == other.currency && discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && groupedTieredPackageConfig == other.groupedTieredPackageConfig && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maximum == other.maximum && maximumAmount == other.maximumAmount && metadata == other.metadata && minimum == other.minimum && minimumAmount == other.minimumAmount && modelType == other.modelType && name == other.name && planPhaseOrder == other.planPhaseOrder && priceType == other.priceType && replacesPriceId == other.replacesPriceId && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ + return other is GroupedTieredPackage && + id == other.id && + billableMetric == other.billableMetric && + billingCycleConfiguration == other.billingCycleConfiguration && + cadence == other.cadence && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + createdAt == other.createdAt && + creditAllocation == other.creditAllocation && + currency == other.currency && + discount == other.discount && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + groupedTieredPackageConfig == other.groupedTieredPackageConfig && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + item == other.item && + maximum == other.maximum && + maximumAmount == other.maximumAmount && + metadata == other.metadata && + minimum == other.minimum && + minimumAmount == other.minimumAmount && + modelType == other.modelType && + name == other.name && + planPhaseOrder == other.planPhaseOrder && + priceType == other.priceType && + replacesPriceId == other.replacesPriceId && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + billableMetric, + billingCycleConfiguration, + cadence, + conversionRate, + conversionRateConfig, + createdAt, + creditAllocation, + currency, + discount, + externalPriceId, + fixedPriceQuantity, + groupedTieredPackageConfig, + invoicingCycleConfiguration, + item, + maximum, + maximumAmount, + metadata, + minimum, + minimumAmount, + modelType, + name, + planPhaseOrder, + priceType, + replacesPriceId, + dimensionalPriceConfiguration, + additionalProperties, + ) } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, billableMetric, billingCycleConfiguration, cadence, conversionRate, conversionRateConfig, createdAt, creditAllocation, currency, discount, externalPriceId, fixedPriceQuantity, groupedTieredPackageConfig, invoicingCycleConfiguration, item, maximum, maximumAmount, metadata, minimum, minimumAmount, modelType, name, planPhaseOrder, priceType, replacesPriceId, dimensionalPriceConfiguration, additionalProperties) } - /* spotless:on */ - override fun hashCode(): Int = hashCode override fun toString() = @@ -49492,7 +50809,7 @@ private constructor( return true } - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + return other is Cadence && value == other.value } override fun hashCode() = value.hashCode() @@ -49582,10 +50899,10 @@ private constructor( return true } - return /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ + return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(unit, tiered) override fun toString(): String = when { @@ -49770,12 +51087,11 @@ private constructor( return true } - return /* spotless:off */ other is MaxGroupTieredPackageConfig && additionalProperties == other.additionalProperties /* spotless:on */ + return other is MaxGroupTieredPackageConfig && + additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -49878,12 +51194,10 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -50011,7 +51325,7 @@ private constructor( return true } - return /* spotless:off */ other is PriceType && value == other.value /* spotless:on */ + return other is PriceType && value == other.value } override fun hashCode() = value.hashCode() @@ -50024,13 +51338,68 @@ private constructor( return true } - return /* spotless:off */ other is MaxGroupTieredPackage && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && conversionRate == other.conversionRate && conversionRateConfig == other.conversionRateConfig && createdAt == other.createdAt && creditAllocation == other.creditAllocation && currency == other.currency && discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maxGroupTieredPackageConfig == other.maxGroupTieredPackageConfig && maximum == other.maximum && maximumAmount == other.maximumAmount && metadata == other.metadata && minimum == other.minimum && minimumAmount == other.minimumAmount && modelType == other.modelType && name == other.name && planPhaseOrder == other.planPhaseOrder && priceType == other.priceType && replacesPriceId == other.replacesPriceId && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ + return other is MaxGroupTieredPackage && + id == other.id && + billableMetric == other.billableMetric && + billingCycleConfiguration == other.billingCycleConfiguration && + cadence == other.cadence && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + createdAt == other.createdAt && + creditAllocation == other.creditAllocation && + currency == other.currency && + discount == other.discount && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + item == other.item && + maxGroupTieredPackageConfig == other.maxGroupTieredPackageConfig && + maximum == other.maximum && + maximumAmount == other.maximumAmount && + metadata == other.metadata && + minimum == other.minimum && + minimumAmount == other.minimumAmount && + modelType == other.modelType && + name == other.name && + planPhaseOrder == other.planPhaseOrder && + priceType == other.priceType && + replacesPriceId == other.replacesPriceId && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + billableMetric, + billingCycleConfiguration, + cadence, + conversionRate, + conversionRateConfig, + createdAt, + creditAllocation, + currency, + discount, + externalPriceId, + fixedPriceQuantity, + invoicingCycleConfiguration, + item, + maxGroupTieredPackageConfig, + maximum, + maximumAmount, + metadata, + minimum, + minimumAmount, + modelType, + name, + planPhaseOrder, + priceType, + replacesPriceId, + dimensionalPriceConfiguration, + additionalProperties, + ) } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, billableMetric, billingCycleConfiguration, cadence, conversionRate, conversionRateConfig, createdAt, creditAllocation, currency, discount, externalPriceId, fixedPriceQuantity, invoicingCycleConfiguration, item, maxGroupTieredPackageConfig, maximum, maximumAmount, metadata, minimum, minimumAmount, modelType, name, planPhaseOrder, priceType, replacesPriceId, dimensionalPriceConfiguration, additionalProperties) } - /* spotless:on */ - override fun hashCode(): Int = hashCode override fun toString() = @@ -51517,7 +52886,7 @@ private constructor( return true } - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + return other is Cadence && value == other.value } override fun hashCode() = value.hashCode() @@ -51607,10 +52976,10 @@ private constructor( return true } - return /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ + return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(unit, tiered) override fun toString(): String = when { @@ -51794,12 +53163,10 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -51927,7 +53294,7 @@ private constructor( return true } - return /* spotless:off */ other is PriceType && value == other.value /* spotless:on */ + return other is PriceType && value == other.value } override fun hashCode() = value.hashCode() @@ -52032,12 +53399,11 @@ private constructor( return true } - return /* spotless:off */ other is ScalableMatrixWithUnitPricingConfig && additionalProperties == other.additionalProperties /* spotless:on */ + return other is ScalableMatrixWithUnitPricingConfig && + additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -52050,13 +53416,68 @@ private constructor( return true } - return /* spotless:off */ other is ScalableMatrixWithUnitPricing && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && conversionRate == other.conversionRate && conversionRateConfig == other.conversionRateConfig && createdAt == other.createdAt && creditAllocation == other.creditAllocation && currency == other.currency && discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maximum == other.maximum && maximumAmount == other.maximumAmount && metadata == other.metadata && minimum == other.minimum && minimumAmount == other.minimumAmount && modelType == other.modelType && name == other.name && planPhaseOrder == other.planPhaseOrder && priceType == other.priceType && replacesPriceId == other.replacesPriceId && scalableMatrixWithUnitPricingConfig == other.scalableMatrixWithUnitPricingConfig && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ + return other is ScalableMatrixWithUnitPricing && + id == other.id && + billableMetric == other.billableMetric && + billingCycleConfiguration == other.billingCycleConfiguration && + cadence == other.cadence && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + createdAt == other.createdAt && + creditAllocation == other.creditAllocation && + currency == other.currency && + discount == other.discount && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + item == other.item && + maximum == other.maximum && + maximumAmount == other.maximumAmount && + metadata == other.metadata && + minimum == other.minimum && + minimumAmount == other.minimumAmount && + modelType == other.modelType && + name == other.name && + planPhaseOrder == other.planPhaseOrder && + priceType == other.priceType && + replacesPriceId == other.replacesPriceId && + scalableMatrixWithUnitPricingConfig == other.scalableMatrixWithUnitPricingConfig && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + billableMetric, + billingCycleConfiguration, + cadence, + conversionRate, + conversionRateConfig, + createdAt, + creditAllocation, + currency, + discount, + externalPriceId, + fixedPriceQuantity, + invoicingCycleConfiguration, + item, + maximum, + maximumAmount, + metadata, + minimum, + minimumAmount, + modelType, + name, + planPhaseOrder, + priceType, + replacesPriceId, + scalableMatrixWithUnitPricingConfig, + dimensionalPriceConfiguration, + additionalProperties, + ) } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, billableMetric, billingCycleConfiguration, cadence, conversionRate, conversionRateConfig, createdAt, creditAllocation, currency, discount, externalPriceId, fixedPriceQuantity, invoicingCycleConfiguration, item, maximum, maximumAmount, metadata, minimum, minimumAmount, modelType, name, planPhaseOrder, priceType, replacesPriceId, scalableMatrixWithUnitPricingConfig, dimensionalPriceConfiguration, additionalProperties) } - /* spotless:on */ - override fun hashCode(): Int = hashCode override fun toString() = @@ -53545,7 +54966,7 @@ private constructor( return true } - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + return other is Cadence && value == other.value } override fun hashCode() = value.hashCode() @@ -53635,10 +55056,10 @@ private constructor( return true } - return /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ + return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(unit, tiered) override fun toString(): String = when { @@ -53822,12 +55243,10 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -53955,7 +55374,7 @@ private constructor( return true } - return /* spotless:off */ other is PriceType && value == other.value /* spotless:on */ + return other is PriceType && value == other.value } override fun hashCode() = value.hashCode() @@ -54060,12 +55479,11 @@ private constructor( return true } - return /* spotless:off */ other is ScalableMatrixWithTieredPricingConfig && additionalProperties == other.additionalProperties /* spotless:on */ + return other is ScalableMatrixWithTieredPricingConfig && + additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -54078,13 +55496,69 @@ private constructor( return true } - return /* spotless:off */ other is ScalableMatrixWithTieredPricing && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && conversionRate == other.conversionRate && conversionRateConfig == other.conversionRateConfig && createdAt == other.createdAt && creditAllocation == other.creditAllocation && currency == other.currency && discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maximum == other.maximum && maximumAmount == other.maximumAmount && metadata == other.metadata && minimum == other.minimum && minimumAmount == other.minimumAmount && modelType == other.modelType && name == other.name && planPhaseOrder == other.planPhaseOrder && priceType == other.priceType && replacesPriceId == other.replacesPriceId && scalableMatrixWithTieredPricingConfig == other.scalableMatrixWithTieredPricingConfig && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ + return other is ScalableMatrixWithTieredPricing && + id == other.id && + billableMetric == other.billableMetric && + billingCycleConfiguration == other.billingCycleConfiguration && + cadence == other.cadence && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + createdAt == other.createdAt && + creditAllocation == other.creditAllocation && + currency == other.currency && + discount == other.discount && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + item == other.item && + maximum == other.maximum && + maximumAmount == other.maximumAmount && + metadata == other.metadata && + minimum == other.minimum && + minimumAmount == other.minimumAmount && + modelType == other.modelType && + name == other.name && + planPhaseOrder == other.planPhaseOrder && + priceType == other.priceType && + replacesPriceId == other.replacesPriceId && + scalableMatrixWithTieredPricingConfig == + other.scalableMatrixWithTieredPricingConfig && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + billableMetric, + billingCycleConfiguration, + cadence, + conversionRate, + conversionRateConfig, + createdAt, + creditAllocation, + currency, + discount, + externalPriceId, + fixedPriceQuantity, + invoicingCycleConfiguration, + item, + maximum, + maximumAmount, + metadata, + minimum, + minimumAmount, + modelType, + name, + planPhaseOrder, + priceType, + replacesPriceId, + scalableMatrixWithTieredPricingConfig, + dimensionalPriceConfiguration, + additionalProperties, + ) } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, billableMetric, billingCycleConfiguration, cadence, conversionRate, conversionRateConfig, createdAt, creditAllocation, currency, discount, externalPriceId, fixedPriceQuantity, invoicingCycleConfiguration, item, maximum, maximumAmount, metadata, minimum, minimumAmount, modelType, name, planPhaseOrder, priceType, replacesPriceId, scalableMatrixWithTieredPricingConfig, dimensionalPriceConfiguration, additionalProperties) } - /* spotless:on */ - override fun hashCode(): Int = hashCode override fun toString() = @@ -55548,7 +57022,7 @@ private constructor( return true } - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + return other is Cadence && value == other.value } override fun hashCode() = value.hashCode() @@ -55638,10 +57112,10 @@ private constructor( return true } - return /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ + return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(unit, tiered) override fun toString(): String = when { @@ -55826,12 +57300,11 @@ private constructor( return true } - return /* spotless:off */ other is CumulativeGroupedBulkConfig && additionalProperties == other.additionalProperties /* spotless:on */ + return other is CumulativeGroupedBulkConfig && + additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -55934,12 +57407,10 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -56067,7 +57538,7 @@ private constructor( return true } - return /* spotless:off */ other is PriceType && value == other.value /* spotless:on */ + return other is PriceType && value == other.value } override fun hashCode() = value.hashCode() @@ -56080,13 +57551,68 @@ private constructor( return true } - return /* spotless:off */ other is CumulativeGroupedBulk && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && conversionRate == other.conversionRate && conversionRateConfig == other.conversionRateConfig && createdAt == other.createdAt && creditAllocation == other.creditAllocation && cumulativeGroupedBulkConfig == other.cumulativeGroupedBulkConfig && currency == other.currency && discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maximum == other.maximum && maximumAmount == other.maximumAmount && metadata == other.metadata && minimum == other.minimum && minimumAmount == other.minimumAmount && modelType == other.modelType && name == other.name && planPhaseOrder == other.planPhaseOrder && priceType == other.priceType && replacesPriceId == other.replacesPriceId && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ + return other is CumulativeGroupedBulk && + id == other.id && + billableMetric == other.billableMetric && + billingCycleConfiguration == other.billingCycleConfiguration && + cadence == other.cadence && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + createdAt == other.createdAt && + creditAllocation == other.creditAllocation && + cumulativeGroupedBulkConfig == other.cumulativeGroupedBulkConfig && + currency == other.currency && + discount == other.discount && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + item == other.item && + maximum == other.maximum && + maximumAmount == other.maximumAmount && + metadata == other.metadata && + minimum == other.minimum && + minimumAmount == other.minimumAmount && + modelType == other.modelType && + name == other.name && + planPhaseOrder == other.planPhaseOrder && + priceType == other.priceType && + replacesPriceId == other.replacesPriceId && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + billableMetric, + billingCycleConfiguration, + cadence, + conversionRate, + conversionRateConfig, + createdAt, + creditAllocation, + cumulativeGroupedBulkConfig, + currency, + discount, + externalPriceId, + fixedPriceQuantity, + invoicingCycleConfiguration, + item, + maximum, + maximumAmount, + metadata, + minimum, + minimumAmount, + modelType, + name, + planPhaseOrder, + priceType, + replacesPriceId, + dimensionalPriceConfiguration, + additionalProperties, + ) } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, billableMetric, billingCycleConfiguration, cadence, conversionRate, conversionRateConfig, createdAt, creditAllocation, cumulativeGroupedBulkConfig, currency, discount, externalPriceId, fixedPriceQuantity, invoicingCycleConfiguration, item, maximum, maximumAmount, metadata, minimum, minimumAmount, modelType, name, planPhaseOrder, priceType, replacesPriceId, dimensionalPriceConfiguration, additionalProperties) } - /* spotless:on */ - override fun hashCode(): Int = hashCode override fun toString() = @@ -57563,7 +59089,7 @@ private constructor( return true } - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + return other is Cadence && value == other.value } override fun hashCode() = value.hashCode() @@ -57653,10 +59179,10 @@ private constructor( return true } - return /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ + return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(unit, tiered) override fun toString(): String = when { @@ -57842,12 +59368,11 @@ private constructor( return true } - return /* spotless:off */ other is GroupedWithMinMaxThresholdsConfig && additionalProperties == other.additionalProperties /* spotless:on */ + return other is GroupedWithMinMaxThresholdsConfig && + additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -57950,12 +59475,10 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -58083,7 +59606,7 @@ private constructor( return true } - return /* spotless:off */ other is PriceType && value == other.value /* spotless:on */ + return other is PriceType && value == other.value } override fun hashCode() = value.hashCode() @@ -58096,13 +59619,68 @@ private constructor( return true } - return /* spotless:off */ other is GroupedWithMinMaxThresholds && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && conversionRate == other.conversionRate && conversionRateConfig == other.conversionRateConfig && createdAt == other.createdAt && creditAllocation == other.creditAllocation && currency == other.currency && discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && groupedWithMinMaxThresholdsConfig == other.groupedWithMinMaxThresholdsConfig && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maximum == other.maximum && maximumAmount == other.maximumAmount && metadata == other.metadata && minimum == other.minimum && minimumAmount == other.minimumAmount && modelType == other.modelType && name == other.name && planPhaseOrder == other.planPhaseOrder && priceType == other.priceType && replacesPriceId == other.replacesPriceId && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ + return other is GroupedWithMinMaxThresholds && + id == other.id && + billableMetric == other.billableMetric && + billingCycleConfiguration == other.billingCycleConfiguration && + cadence == other.cadence && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + createdAt == other.createdAt && + creditAllocation == other.creditAllocation && + currency == other.currency && + discount == other.discount && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + groupedWithMinMaxThresholdsConfig == other.groupedWithMinMaxThresholdsConfig && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + item == other.item && + maximum == other.maximum && + maximumAmount == other.maximumAmount && + metadata == other.metadata && + minimum == other.minimum && + minimumAmount == other.minimumAmount && + modelType == other.modelType && + name == other.name && + planPhaseOrder == other.planPhaseOrder && + priceType == other.priceType && + replacesPriceId == other.replacesPriceId && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + billableMetric, + billingCycleConfiguration, + cadence, + conversionRate, + conversionRateConfig, + createdAt, + creditAllocation, + currency, + discount, + externalPriceId, + fixedPriceQuantity, + groupedWithMinMaxThresholdsConfig, + invoicingCycleConfiguration, + item, + maximum, + maximumAmount, + metadata, + minimum, + minimumAmount, + modelType, + name, + planPhaseOrder, + priceType, + replacesPriceId, + dimensionalPriceConfiguration, + additionalProperties, + ) } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, billableMetric, billingCycleConfiguration, cadence, conversionRate, conversionRateConfig, createdAt, creditAllocation, currency, discount, externalPriceId, fixedPriceQuantity, groupedWithMinMaxThresholdsConfig, invoicingCycleConfiguration, item, maximum, maximumAmount, metadata, minimum, minimumAmount, modelType, name, planPhaseOrder, priceType, replacesPriceId, dimensionalPriceConfiguration, additionalProperties) } - /* spotless:on */ - override fun hashCode(): Int = hashCode override fun toString() = diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceCreateParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceCreateParams.kt index c4d7ff65e..b00d87250 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceCreateParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceCreateParams.kt @@ -883,10 +883,68 @@ private constructor( return true } - return /* spotless:off */ other is Body && unit == other.unit && package_ == other.package_ && matrix == other.matrix && matrixWithAllocation == other.matrixWithAllocation && tiered == other.tiered && tieredBps == other.tieredBps && bps == other.bps && bulkBps == other.bulkBps && bulk == other.bulk && thresholdTotalAmount == other.thresholdTotalAmount && tieredPackage == other.tieredPackage && groupedTiered == other.groupedTiered && maxGroupTieredPackage == other.maxGroupTieredPackage && tieredWithMinimum == other.tieredWithMinimum && packageWithAllocation == other.packageWithAllocation && tieredPackageWithMinimum == other.tieredPackageWithMinimum && unitWithPercent == other.unitWithPercent && tieredWithProration == other.tieredWithProration && unitWithProration == other.unitWithProration && groupedAllocation == other.groupedAllocation && groupedWithProratedMinimum == other.groupedWithProratedMinimum && groupedWithMeteredMinimum == other.groupedWithMeteredMinimum && matrixWithDisplayName == other.matrixWithDisplayName && bulkWithProration == other.bulkWithProration && groupedTieredPackage == other.groupedTieredPackage && scalableMatrixWithUnitPricing == other.scalableMatrixWithUnitPricing && scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && cumulativeGroupedBulk == other.cumulativeGroupedBulk /* spotless:on */ + return other is Body && + unit == other.unit && + package_ == other.package_ && + matrix == other.matrix && + matrixWithAllocation == other.matrixWithAllocation && + tiered == other.tiered && + tieredBps == other.tieredBps && + bps == other.bps && + bulkBps == other.bulkBps && + bulk == other.bulk && + thresholdTotalAmount == other.thresholdTotalAmount && + tieredPackage == other.tieredPackage && + groupedTiered == other.groupedTiered && + maxGroupTieredPackage == other.maxGroupTieredPackage && + tieredWithMinimum == other.tieredWithMinimum && + packageWithAllocation == other.packageWithAllocation && + tieredPackageWithMinimum == other.tieredPackageWithMinimum && + unitWithPercent == other.unitWithPercent && + tieredWithProration == other.tieredWithProration && + unitWithProration == other.unitWithProration && + groupedAllocation == other.groupedAllocation && + groupedWithProratedMinimum == other.groupedWithProratedMinimum && + groupedWithMeteredMinimum == other.groupedWithMeteredMinimum && + matrixWithDisplayName == other.matrixWithDisplayName && + bulkWithProration == other.bulkWithProration && + groupedTieredPackage == other.groupedTieredPackage && + scalableMatrixWithUnitPricing == other.scalableMatrixWithUnitPricing && + scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && + cumulativeGroupedBulk == other.cumulativeGroupedBulk } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, package_, matrix, matrixWithAllocation, tiered, tieredBps, bps, bulkBps, bulk, thresholdTotalAmount, tieredPackage, groupedTiered, maxGroupTieredPackage, tieredWithMinimum, packageWithAllocation, tieredPackageWithMinimum, unitWithPercent, tieredWithProration, unitWithProration, groupedAllocation, groupedWithProratedMinimum, groupedWithMeteredMinimum, matrixWithDisplayName, bulkWithProration, groupedTieredPackage, scalableMatrixWithUnitPricing, scalableMatrixWithTieredPricing, cumulativeGroupedBulk) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash( + unit, + package_, + matrix, + matrixWithAllocation, + tiered, + tieredBps, + bps, + bulkBps, + bulk, + thresholdTotalAmount, + tieredPackage, + groupedTiered, + maxGroupTieredPackage, + tieredWithMinimum, + packageWithAllocation, + tieredPackageWithMinimum, + unitWithPercent, + tieredWithProration, + unitWithProration, + groupedAllocation, + groupedWithProratedMinimum, + groupedWithMeteredMinimum, + matrixWithDisplayName, + bulkWithProration, + groupedTieredPackage, + scalableMatrixWithUnitPricing, + scalableMatrixWithTieredPricing, + cumulativeGroupedBulk, + ) override fun toString(): String = when { @@ -1384,10 +1442,13 @@ private constructor( return true } - return /* spotless:off */ other is PriceCreateParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return other is PriceCreateParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(body, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) override fun toString() = "PriceCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceEvaluateMultipleParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceEvaluateMultipleParams.kt index 329c84a66..d41c3376d 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceEvaluateMultipleParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceEvaluateMultipleParams.kt @@ -758,12 +758,25 @@ private constructor( return true } - return /* spotless:off */ other is Body && timeframeEnd == other.timeframeEnd && timeframeStart == other.timeframeStart && customerId == other.customerId && externalCustomerId == other.externalCustomerId && priceEvaluations == other.priceEvaluations && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Body && + timeframeEnd == other.timeframeEnd && + timeframeStart == other.timeframeStart && + customerId == other.customerId && + externalCustomerId == other.externalCustomerId && + priceEvaluations == other.priceEvaluations && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(timeframeEnd, timeframeStart, customerId, externalCustomerId, priceEvaluations, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + timeframeEnd, + timeframeStart, + customerId, + externalCustomerId, + priceEvaluations, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode @@ -1803,10 +1816,68 @@ private constructor( return true } - return /* spotless:off */ other is Price && unit == other.unit && package_ == other.package_ && matrix == other.matrix && matrixWithAllocation == other.matrixWithAllocation && tiered == other.tiered && tieredBps == other.tieredBps && bps == other.bps && bulkBps == other.bulkBps && bulk == other.bulk && thresholdTotalAmount == other.thresholdTotalAmount && tieredPackage == other.tieredPackage && groupedTiered == other.groupedTiered && maxGroupTieredPackage == other.maxGroupTieredPackage && tieredWithMinimum == other.tieredWithMinimum && packageWithAllocation == other.packageWithAllocation && tieredPackageWithMinimum == other.tieredPackageWithMinimum && unitWithPercent == other.unitWithPercent && tieredWithProration == other.tieredWithProration && unitWithProration == other.unitWithProration && groupedAllocation == other.groupedAllocation && groupedWithProratedMinimum == other.groupedWithProratedMinimum && groupedWithMeteredMinimum == other.groupedWithMeteredMinimum && matrixWithDisplayName == other.matrixWithDisplayName && bulkWithProration == other.bulkWithProration && groupedTieredPackage == other.groupedTieredPackage && scalableMatrixWithUnitPricing == other.scalableMatrixWithUnitPricing && scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && cumulativeGroupedBulk == other.cumulativeGroupedBulk /* spotless:on */ + return other is Price && + unit == other.unit && + package_ == other.package_ && + matrix == other.matrix && + matrixWithAllocation == other.matrixWithAllocation && + tiered == other.tiered && + tieredBps == other.tieredBps && + bps == other.bps && + bulkBps == other.bulkBps && + bulk == other.bulk && + thresholdTotalAmount == other.thresholdTotalAmount && + tieredPackage == other.tieredPackage && + groupedTiered == other.groupedTiered && + maxGroupTieredPackage == other.maxGroupTieredPackage && + tieredWithMinimum == other.tieredWithMinimum && + packageWithAllocation == other.packageWithAllocation && + tieredPackageWithMinimum == other.tieredPackageWithMinimum && + unitWithPercent == other.unitWithPercent && + tieredWithProration == other.tieredWithProration && + unitWithProration == other.unitWithProration && + groupedAllocation == other.groupedAllocation && + groupedWithProratedMinimum == other.groupedWithProratedMinimum && + groupedWithMeteredMinimum == other.groupedWithMeteredMinimum && + matrixWithDisplayName == other.matrixWithDisplayName && + bulkWithProration == other.bulkWithProration && + groupedTieredPackage == other.groupedTieredPackage && + scalableMatrixWithUnitPricing == other.scalableMatrixWithUnitPricing && + scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && + cumulativeGroupedBulk == other.cumulativeGroupedBulk } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, package_, matrix, matrixWithAllocation, tiered, tieredBps, bps, bulkBps, bulk, thresholdTotalAmount, tieredPackage, groupedTiered, maxGroupTieredPackage, tieredWithMinimum, packageWithAllocation, tieredPackageWithMinimum, unitWithPercent, tieredWithProration, unitWithProration, groupedAllocation, groupedWithProratedMinimum, groupedWithMeteredMinimum, matrixWithDisplayName, bulkWithProration, groupedTieredPackage, scalableMatrixWithUnitPricing, scalableMatrixWithTieredPricing, cumulativeGroupedBulk) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash( + unit, + package_, + matrix, + matrixWithAllocation, + tiered, + tieredBps, + bps, + bulkBps, + bulk, + thresholdTotalAmount, + tieredPackage, + groupedTiered, + maxGroupTieredPackage, + tieredWithMinimum, + packageWithAllocation, + tieredPackageWithMinimum, + unitWithPercent, + tieredWithProration, + unitWithProration, + groupedAllocation, + groupedWithProratedMinimum, + groupedWithMeteredMinimum, + matrixWithDisplayName, + bulkWithProration, + groupedTieredPackage, + scalableMatrixWithUnitPricing, + scalableMatrixWithTieredPricing, + cumulativeGroupedBulk, + ) override fun toString(): String = when { @@ -2321,12 +2392,25 @@ private constructor( return true } - return /* spotless:off */ other is PriceEvaluation && externalPriceId == other.externalPriceId && filter == other.filter && groupingKeys == other.groupingKeys && price == other.price && priceId == other.priceId && additionalProperties == other.additionalProperties /* spotless:on */ + return other is PriceEvaluation && + externalPriceId == other.externalPriceId && + filter == other.filter && + groupingKeys == other.groupingKeys && + price == other.price && + priceId == other.priceId && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(externalPriceId, filter, groupingKeys, price, priceId, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + externalPriceId, + filter, + groupingKeys, + price, + priceId, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode @@ -2339,10 +2423,13 @@ private constructor( return true } - return /* spotless:off */ other is PriceEvaluateMultipleParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return other is PriceEvaluateMultipleParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(body, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) override fun toString() = "PriceEvaluateMultipleParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceEvaluateMultipleResponse.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceEvaluateMultipleResponse.kt index 23021b7b0..2f3cd01b9 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceEvaluateMultipleResponse.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceEvaluateMultipleResponse.kt @@ -494,12 +494,25 @@ private constructor( return true } - return /* spotless:off */ other is Data && currency == other.currency && priceGroups == other.priceGroups && externalPriceId == other.externalPriceId && inlinePriceIndex == other.inlinePriceIndex && priceId == other.priceId && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Data && + currency == other.currency && + priceGroups == other.priceGroups && + externalPriceId == other.externalPriceId && + inlinePriceIndex == other.inlinePriceIndex && + priceId == other.priceId && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(currency, priceGroups, externalPriceId, inlinePriceIndex, priceId, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + currency, + priceGroups, + externalPriceId, + inlinePriceIndex, + priceId, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode @@ -512,12 +525,12 @@ private constructor( return true } - return /* spotless:off */ other is PriceEvaluateMultipleResponse && data == other.data && additionalProperties == other.additionalProperties /* spotless:on */ + return other is PriceEvaluateMultipleResponse && + data == other.data && + additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(data, additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceEvaluateParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceEvaluateParams.kt index 6e168fc51..57b24f069 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceEvaluateParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceEvaluateParams.kt @@ -831,13 +831,28 @@ private constructor( return true } - return /* spotless:off */ other is Body && timeframeEnd == other.timeframeEnd && timeframeStart == other.timeframeStart && customerId == other.customerId && externalCustomerId == other.externalCustomerId && filter == other.filter && groupingKeys == other.groupingKeys && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Body && + timeframeEnd == other.timeframeEnd && + timeframeStart == other.timeframeStart && + customerId == other.customerId && + externalCustomerId == other.externalCustomerId && + filter == other.filter && + groupingKeys == other.groupingKeys && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + timeframeEnd, + timeframeStart, + customerId, + externalCustomerId, + filter, + groupingKeys, + additionalProperties, + ) } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(timeframeEnd, timeframeStart, customerId, externalCustomerId, filter, groupingKeys, additionalProperties) } - /* spotless:on */ - override fun hashCode(): Int = hashCode override fun toString() = @@ -849,10 +864,15 @@ private constructor( return true } - return /* spotless:off */ other is PriceEvaluateParams && priceId == other.priceId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return other is PriceEvaluateParams && + priceId == other.priceId && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(priceId, body, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash(priceId, body, additionalHeaders, additionalQueryParams) override fun toString() = "PriceEvaluateParams{priceId=$priceId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceEvaluatePreviewEventsParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceEvaluatePreviewEventsParams.kt index a1a78f24c..df2f52779 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceEvaluatePreviewEventsParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceEvaluatePreviewEventsParams.kt @@ -837,12 +837,27 @@ private constructor( return true } - return /* spotless:off */ other is Body && timeframeEnd == other.timeframeEnd && timeframeStart == other.timeframeStart && customerId == other.customerId && events == other.events && externalCustomerId == other.externalCustomerId && priceEvaluations == other.priceEvaluations && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Body && + timeframeEnd == other.timeframeEnd && + timeframeStart == other.timeframeStart && + customerId == other.customerId && + events == other.events && + externalCustomerId == other.externalCustomerId && + priceEvaluations == other.priceEvaluations && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(timeframeEnd, timeframeStart, customerId, events, externalCustomerId, priceEvaluations, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + timeframeEnd, + timeframeStart, + customerId, + events, + externalCustomerId, + priceEvaluations, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode @@ -1262,12 +1277,10 @@ private constructor( return true } - return /* spotless:off */ other is Properties && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Properties && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1279,12 +1292,25 @@ private constructor( return true } - return /* spotless:off */ other is Event && eventName == other.eventName && properties == other.properties && timestamp == other.timestamp && customerId == other.customerId && externalCustomerId == other.externalCustomerId && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Event && + eventName == other.eventName && + properties == other.properties && + timestamp == other.timestamp && + customerId == other.customerId && + externalCustomerId == other.externalCustomerId && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(eventName, properties, timestamp, customerId, externalCustomerId, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + eventName, + properties, + timestamp, + customerId, + externalCustomerId, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode @@ -2324,10 +2350,68 @@ private constructor( return true } - return /* spotless:off */ other is Price && unit == other.unit && package_ == other.package_ && matrix == other.matrix && matrixWithAllocation == other.matrixWithAllocation && tiered == other.tiered && tieredBps == other.tieredBps && bps == other.bps && bulkBps == other.bulkBps && bulk == other.bulk && thresholdTotalAmount == other.thresholdTotalAmount && tieredPackage == other.tieredPackage && groupedTiered == other.groupedTiered && maxGroupTieredPackage == other.maxGroupTieredPackage && tieredWithMinimum == other.tieredWithMinimum && packageWithAllocation == other.packageWithAllocation && tieredPackageWithMinimum == other.tieredPackageWithMinimum && unitWithPercent == other.unitWithPercent && tieredWithProration == other.tieredWithProration && unitWithProration == other.unitWithProration && groupedAllocation == other.groupedAllocation && groupedWithProratedMinimum == other.groupedWithProratedMinimum && groupedWithMeteredMinimum == other.groupedWithMeteredMinimum && matrixWithDisplayName == other.matrixWithDisplayName && bulkWithProration == other.bulkWithProration && groupedTieredPackage == other.groupedTieredPackage && scalableMatrixWithUnitPricing == other.scalableMatrixWithUnitPricing && scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && cumulativeGroupedBulk == other.cumulativeGroupedBulk /* spotless:on */ + return other is Price && + unit == other.unit && + package_ == other.package_ && + matrix == other.matrix && + matrixWithAllocation == other.matrixWithAllocation && + tiered == other.tiered && + tieredBps == other.tieredBps && + bps == other.bps && + bulkBps == other.bulkBps && + bulk == other.bulk && + thresholdTotalAmount == other.thresholdTotalAmount && + tieredPackage == other.tieredPackage && + groupedTiered == other.groupedTiered && + maxGroupTieredPackage == other.maxGroupTieredPackage && + tieredWithMinimum == other.tieredWithMinimum && + packageWithAllocation == other.packageWithAllocation && + tieredPackageWithMinimum == other.tieredPackageWithMinimum && + unitWithPercent == other.unitWithPercent && + tieredWithProration == other.tieredWithProration && + unitWithProration == other.unitWithProration && + groupedAllocation == other.groupedAllocation && + groupedWithProratedMinimum == other.groupedWithProratedMinimum && + groupedWithMeteredMinimum == other.groupedWithMeteredMinimum && + matrixWithDisplayName == other.matrixWithDisplayName && + bulkWithProration == other.bulkWithProration && + groupedTieredPackage == other.groupedTieredPackage && + scalableMatrixWithUnitPricing == other.scalableMatrixWithUnitPricing && + scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && + cumulativeGroupedBulk == other.cumulativeGroupedBulk } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, package_, matrix, matrixWithAllocation, tiered, tieredBps, bps, bulkBps, bulk, thresholdTotalAmount, tieredPackage, groupedTiered, maxGroupTieredPackage, tieredWithMinimum, packageWithAllocation, tieredPackageWithMinimum, unitWithPercent, tieredWithProration, unitWithProration, groupedAllocation, groupedWithProratedMinimum, groupedWithMeteredMinimum, matrixWithDisplayName, bulkWithProration, groupedTieredPackage, scalableMatrixWithUnitPricing, scalableMatrixWithTieredPricing, cumulativeGroupedBulk) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash( + unit, + package_, + matrix, + matrixWithAllocation, + tiered, + tieredBps, + bps, + bulkBps, + bulk, + thresholdTotalAmount, + tieredPackage, + groupedTiered, + maxGroupTieredPackage, + tieredWithMinimum, + packageWithAllocation, + tieredPackageWithMinimum, + unitWithPercent, + tieredWithProration, + unitWithProration, + groupedAllocation, + groupedWithProratedMinimum, + groupedWithMeteredMinimum, + matrixWithDisplayName, + bulkWithProration, + groupedTieredPackage, + scalableMatrixWithUnitPricing, + scalableMatrixWithTieredPricing, + cumulativeGroupedBulk, + ) override fun toString(): String = when { @@ -2842,12 +2926,25 @@ private constructor( return true } - return /* spotless:off */ other is PriceEvaluation && externalPriceId == other.externalPriceId && filter == other.filter && groupingKeys == other.groupingKeys && price == other.price && priceId == other.priceId && additionalProperties == other.additionalProperties /* spotless:on */ + return other is PriceEvaluation && + externalPriceId == other.externalPriceId && + filter == other.filter && + groupingKeys == other.groupingKeys && + price == other.price && + priceId == other.priceId && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(externalPriceId, filter, groupingKeys, price, priceId, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + externalPriceId, + filter, + groupingKeys, + price, + priceId, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode @@ -2860,10 +2957,13 @@ private constructor( return true } - return /* spotless:off */ other is PriceEvaluatePreviewEventsParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return other is PriceEvaluatePreviewEventsParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(body, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) override fun toString() = "PriceEvaluatePreviewEventsParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceEvaluatePreviewEventsResponse.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceEvaluatePreviewEventsResponse.kt index c29906967..0c26cd8b1 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceEvaluatePreviewEventsResponse.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceEvaluatePreviewEventsResponse.kt @@ -496,12 +496,25 @@ private constructor( return true } - return /* spotless:off */ other is Data && currency == other.currency && priceGroups == other.priceGroups && externalPriceId == other.externalPriceId && inlinePriceIndex == other.inlinePriceIndex && priceId == other.priceId && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Data && + currency == other.currency && + priceGroups == other.priceGroups && + externalPriceId == other.externalPriceId && + inlinePriceIndex == other.inlinePriceIndex && + priceId == other.priceId && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(currency, priceGroups, externalPriceId, inlinePriceIndex, priceId, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + currency, + priceGroups, + externalPriceId, + inlinePriceIndex, + priceId, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode @@ -514,12 +527,12 @@ private constructor( return true } - return /* spotless:off */ other is PriceEvaluatePreviewEventsResponse && data == other.data && additionalProperties == other.additionalProperties /* spotless:on */ + return other is PriceEvaluatePreviewEventsResponse && + data == other.data && + additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(data, additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceEvaluateResponse.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceEvaluateResponse.kt index f99cc331d..4e7398a99 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceEvaluateResponse.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceEvaluateResponse.kt @@ -173,12 +173,12 @@ private constructor( return true } - return /* spotless:off */ other is PriceEvaluateResponse && data == other.data && additionalProperties == other.additionalProperties /* spotless:on */ + return other is PriceEvaluateResponse && + data == other.data && + additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(data, additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceExternalPriceIdFetchParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceExternalPriceIdFetchParams.kt index cbfbf3315..242c6f86b 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceExternalPriceIdFetchParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceExternalPriceIdFetchParams.kt @@ -185,10 +185,14 @@ private constructor( return true } - return /* spotless:off */ other is PriceExternalPriceIdFetchParams && externalPriceId == other.externalPriceId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return other is PriceExternalPriceIdFetchParams && + externalPriceId == other.externalPriceId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(externalPriceId, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash(externalPriceId, additionalHeaders, additionalQueryParams) override fun toString() = "PriceExternalPriceIdFetchParams{externalPriceId=$externalPriceId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceExternalPriceIdUpdateParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceExternalPriceIdUpdateParams.kt index 9ae4c6efa..d88c0e717 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceExternalPriceIdUpdateParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceExternalPriceIdUpdateParams.kt @@ -393,12 +393,12 @@ private constructor( return true } - return /* spotless:off */ other is Body && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Body && + metadata == other.metadata && + additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(metadata, additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -498,12 +498,10 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -515,10 +513,15 @@ private constructor( return true } - return /* spotless:off */ other is PriceExternalPriceIdUpdateParams && externalPriceId == other.externalPriceId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return other is PriceExternalPriceIdUpdateParams && + externalPriceId == other.externalPriceId && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(externalPriceId, body, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash(externalPriceId, body, additionalHeaders, additionalQueryParams) override fun toString() = "PriceExternalPriceIdUpdateParams{externalPriceId=$externalPriceId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceFetchParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceFetchParams.kt index 4bc7493fa..2dc891c00 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceFetchParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceFetchParams.kt @@ -170,10 +170,13 @@ private constructor( return true } - return /* spotless:off */ other is PriceFetchParams && priceId == other.priceId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return other is PriceFetchParams && + priceId == other.priceId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(priceId, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(priceId, additionalHeaders, additionalQueryParams) override fun toString() = "PriceFetchParams{priceId=$priceId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceInterval.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceInterval.kt index 5e7f032c2..63efc3dad 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceInterval.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceInterval.kt @@ -759,12 +759,35 @@ private constructor( return true } - return /* spotless:off */ other is PriceInterval && id == other.id && billingCycleDay == other.billingCycleDay && currentBillingPeriodEndDate == other.currentBillingPeriodEndDate && currentBillingPeriodStartDate == other.currentBillingPeriodStartDate && endDate == other.endDate && filter == other.filter && fixedFeeQuantityTransitions == other.fixedFeeQuantityTransitions && price == other.price && startDate == other.startDate && usageCustomerIds == other.usageCustomerIds && additionalProperties == other.additionalProperties /* spotless:on */ + return other is PriceInterval && + id == other.id && + billingCycleDay == other.billingCycleDay && + currentBillingPeriodEndDate == other.currentBillingPeriodEndDate && + currentBillingPeriodStartDate == other.currentBillingPeriodStartDate && + endDate == other.endDate && + filter == other.filter && + fixedFeeQuantityTransitions == other.fixedFeeQuantityTransitions && + price == other.price && + startDate == other.startDate && + usageCustomerIds == other.usageCustomerIds && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, billingCycleDay, currentBillingPeriodEndDate, currentBillingPeriodStartDate, endDate, filter, fixedFeeQuantityTransitions, price, startDate, usageCustomerIds, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + id, + billingCycleDay, + currentBillingPeriodEndDate, + currentBillingPeriodStartDate, + endDate, + filter, + fixedFeeQuantityTransitions, + price, + startDate, + usageCustomerIds, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceListPage.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceListPage.kt index b19828ad9..c2f41ce9c 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceListPage.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceListPage.kt @@ -119,10 +119,13 @@ private constructor( return true } - return /* spotless:off */ other is PriceListPage && service == other.service && params == other.params && response == other.response /* spotless:on */ + return other is PriceListPage && + service == other.service && + params == other.params && + response == other.response } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, params, response) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(service, params, response) override fun toString() = "PriceListPage{service=$service, params=$params, response=$response}" } diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceListPageAsync.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceListPageAsync.kt index 8309ab8db..5f0df3759 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceListPageAsync.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceListPageAsync.kt @@ -119,10 +119,13 @@ private constructor( return true } - return /* spotless:off */ other is PriceListPageAsync && service == other.service && params == other.params && response == other.response /* spotless:on */ + return other is PriceListPageAsync && + service == other.service && + params == other.params && + response == other.response } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, params, response) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(service, params, response) override fun toString() = "PriceListPageAsync{service=$service, params=$params, response=$response}" diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceListPageResponse.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceListPageResponse.kt index 36c714258..853e2cc8d 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceListPageResponse.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceListPageResponse.kt @@ -354,12 +354,15 @@ private constructor( return true } - return /* spotless:off */ other is PriceListPageResponse && data == other.data && paginationMetadata == other.paginationMetadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is PriceListPageResponse && + data == other.data && + paginationMetadata == other.paginationMetadata && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(data, paginationMetadata, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash(data, paginationMetadata, additionalProperties) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceListParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceListParams.kt index 7a2ff0656..7680106d9 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceListParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceListParams.kt @@ -198,10 +198,15 @@ private constructor( return true } - return /* spotless:off */ other is PriceListParams && cursor == other.cursor && limit == other.limit && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return other is PriceListParams && + cursor == other.cursor && + limit == other.limit && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(cursor, limit, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash(cursor, limit, additionalHeaders, additionalQueryParams) override fun toString() = "PriceListParams{cursor=$cursor, limit=$limit, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceUpdateParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceUpdateParams.kt index d20558d61..837a11fd9 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceUpdateParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceUpdateParams.kt @@ -386,12 +386,12 @@ private constructor( return true } - return /* spotless:off */ other is Body && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Body && + metadata == other.metadata && + additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(metadata, additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -491,12 +491,10 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -508,10 +506,15 @@ private constructor( return true } - return /* spotless:off */ other is PriceUpdateParams && priceId == other.priceId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return other is PriceUpdateParams && + priceId == other.priceId && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(priceId, body, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash(priceId, body, additionalHeaders, additionalQueryParams) override fun toString() = "PriceUpdateParams{priceId=$priceId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubLineItemGrouping.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubLineItemGrouping.kt index 17edb202d..ff20d0f47 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubLineItemGrouping.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubLineItemGrouping.kt @@ -189,12 +189,13 @@ private constructor( return true } - return /* spotless:off */ other is SubLineItemGrouping && key == other.key && value == other.value && additionalProperties == other.additionalProperties /* spotless:on */ + return other is SubLineItemGrouping && + key == other.key && + value == other.value && + additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(key, value, additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubLineItemMatrixConfig.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubLineItemMatrixConfig.kt index 34f0cef2d..3aedd4de2 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubLineItemMatrixConfig.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubLineItemMatrixConfig.kt @@ -180,12 +180,12 @@ private constructor( return true } - return /* spotless:off */ other is SubLineItemMatrixConfig && dimensionValues == other.dimensionValues && additionalProperties == other.additionalProperties /* spotless:on */ + return other is SubLineItemMatrixConfig && + dimensionValues == other.dimensionValues && + additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(dimensionValues, additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Subscription.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Subscription.kt index 60528e901..7f49cc517 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Subscription.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Subscription.kt @@ -1595,10 +1595,13 @@ private constructor( return true } - return /* spotless:off */ other is DiscountInterval && amount == other.amount && percentage == other.percentage && usage == other.usage /* spotless:on */ + return other is DiscountInterval && + amount == other.amount && + percentage == other.percentage && + usage == other.usage } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(amount, percentage, usage) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(amount, percentage, usage) override fun toString(): String = when { @@ -1784,12 +1787,10 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1918,7 +1919,7 @@ private constructor( return true } - return /* spotless:off */ other is Status && value == other.value /* spotless:on */ + return other is Status && value == other.value } override fun hashCode() = value.hashCode() @@ -1931,12 +1932,69 @@ private constructor( return true } - return /* spotless:off */ other is Subscription && id == other.id && activePlanPhaseOrder == other.activePlanPhaseOrder && adjustmentIntervals == other.adjustmentIntervals && autoCollection == other.autoCollection && billingCycleAnchorConfiguration == other.billingCycleAnchorConfiguration && billingCycleDay == other.billingCycleDay && createdAt == other.createdAt && currentBillingPeriodEndDate == other.currentBillingPeriodEndDate && currentBillingPeriodStartDate == other.currentBillingPeriodStartDate && customer == other.customer && defaultInvoiceMemo == other.defaultInvoiceMemo && discountIntervals == other.discountIntervals && endDate == other.endDate && fixedFeeQuantitySchedule == other.fixedFeeQuantitySchedule && invoicingThreshold == other.invoicingThreshold && maximumIntervals == other.maximumIntervals && metadata == other.metadata && minimumIntervals == other.minimumIntervals && name == other.name && netTerms == other.netTerms && pendingSubscriptionChange == other.pendingSubscriptionChange && plan == other.plan && priceIntervals == other.priceIntervals && redeemedCoupon == other.redeemedCoupon && startDate == other.startDate && status == other.status && trialInfo == other.trialInfo && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Subscription && + id == other.id && + activePlanPhaseOrder == other.activePlanPhaseOrder && + adjustmentIntervals == other.adjustmentIntervals && + autoCollection == other.autoCollection && + billingCycleAnchorConfiguration == other.billingCycleAnchorConfiguration && + billingCycleDay == other.billingCycleDay && + createdAt == other.createdAt && + currentBillingPeriodEndDate == other.currentBillingPeriodEndDate && + currentBillingPeriodStartDate == other.currentBillingPeriodStartDate && + customer == other.customer && + defaultInvoiceMemo == other.defaultInvoiceMemo && + discountIntervals == other.discountIntervals && + endDate == other.endDate && + fixedFeeQuantitySchedule == other.fixedFeeQuantitySchedule && + invoicingThreshold == other.invoicingThreshold && + maximumIntervals == other.maximumIntervals && + metadata == other.metadata && + minimumIntervals == other.minimumIntervals && + name == other.name && + netTerms == other.netTerms && + pendingSubscriptionChange == other.pendingSubscriptionChange && + plan == other.plan && + priceIntervals == other.priceIntervals && + redeemedCoupon == other.redeemedCoupon && + startDate == other.startDate && + status == other.status && + trialInfo == other.trialInfo && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, activePlanPhaseOrder, adjustmentIntervals, autoCollection, billingCycleAnchorConfiguration, billingCycleDay, createdAt, currentBillingPeriodEndDate, currentBillingPeriodStartDate, customer, defaultInvoiceMemo, discountIntervals, endDate, fixedFeeQuantitySchedule, invoicingThreshold, maximumIntervals, metadata, minimumIntervals, name, netTerms, pendingSubscriptionChange, plan, priceIntervals, redeemedCoupon, startDate, status, trialInfo, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + id, + activePlanPhaseOrder, + adjustmentIntervals, + autoCollection, + billingCycleAnchorConfiguration, + billingCycleDay, + createdAt, + currentBillingPeriodEndDate, + currentBillingPeriodStartDate, + customer, + defaultInvoiceMemo, + discountIntervals, + endDate, + fixedFeeQuantitySchedule, + invoicingThreshold, + maximumIntervals, + metadata, + minimumIntervals, + name, + netTerms, + pendingSubscriptionChange, + plan, + priceIntervals, + redeemedCoupon, + startDate, + status, + trialInfo, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionCancelParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionCancelParams.kt index 6810cd1da..d03a14d6e 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionCancelParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionCancelParams.kt @@ -648,13 +648,22 @@ private constructor( return true } - return /* spotless:off */ other is Body && cancelOption == other.cancelOption && allowInvoiceCreditOrVoid == other.allowInvoiceCreditOrVoid && cancellationDate == other.cancellationDate && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Body && + cancelOption == other.cancelOption && + allowInvoiceCreditOrVoid == other.allowInvoiceCreditOrVoid && + cancellationDate == other.cancellationDate && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cancelOption, + allowInvoiceCreditOrVoid, + cancellationDate, + additionalProperties, + ) } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cancelOption, allowInvoiceCreditOrVoid, cancellationDate, additionalProperties) } - /* spotless:on */ - override fun hashCode(): Int = hashCode override fun toString() = @@ -787,7 +796,7 @@ private constructor( return true } - return /* spotless:off */ other is CancelOption && value == other.value /* spotless:on */ + return other is CancelOption && value == other.value } override fun hashCode() = value.hashCode() @@ -800,10 +809,15 @@ private constructor( return true } - return /* spotless:off */ other is SubscriptionCancelParams && subscriptionId == other.subscriptionId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return other is SubscriptionCancelParams && + subscriptionId == other.subscriptionId && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(subscriptionId, body, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash(subscriptionId, body, additionalHeaders, additionalQueryParams) override fun toString() = "SubscriptionCancelParams{subscriptionId=$subscriptionId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionChangeApplyParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionChangeApplyParams.kt index b4e1d8218..a267e2a0f 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionChangeApplyParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionChangeApplyParams.kt @@ -460,12 +460,15 @@ private constructor( return true } - return /* spotless:off */ other is Body && description == other.description && previouslyCollectedAmount == other.previouslyCollectedAmount && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Body && + description == other.description && + previouslyCollectedAmount == other.previouslyCollectedAmount && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(description, previouslyCollectedAmount, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash(description, previouslyCollectedAmount, additionalProperties) + } override fun hashCode(): Int = hashCode @@ -478,10 +481,15 @@ private constructor( return true } - return /* spotless:off */ other is SubscriptionChangeApplyParams && subscriptionChangeId == other.subscriptionChangeId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return other is SubscriptionChangeApplyParams && + subscriptionChangeId == other.subscriptionChangeId && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(subscriptionChangeId, body, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash(subscriptionChangeId, body, additionalHeaders, additionalQueryParams) override fun toString() = "SubscriptionChangeApplyParams{subscriptionChangeId=$subscriptionChangeId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionChangeApplyResponse.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionChangeApplyResponse.kt index 511cf30c2..2b1bbd9a5 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionChangeApplyResponse.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionChangeApplyResponse.kt @@ -476,7 +476,7 @@ private constructor( return true } - return /* spotless:off */ other is Status && value == other.value /* spotless:on */ + return other is Status && value == other.value } override fun hashCode() = value.hashCode() @@ -489,12 +489,27 @@ private constructor( return true } - return /* spotless:off */ other is SubscriptionChangeApplyResponse && id == other.id && expirationTime == other.expirationTime && status == other.status && subscription == other.subscription && appliedAt == other.appliedAt && cancelledAt == other.cancelledAt && additionalProperties == other.additionalProperties /* spotless:on */ + return other is SubscriptionChangeApplyResponse && + id == other.id && + expirationTime == other.expirationTime && + status == other.status && + subscription == other.subscription && + appliedAt == other.appliedAt && + cancelledAt == other.cancelledAt && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, expirationTime, status, subscription, appliedAt, cancelledAt, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + id, + expirationTime, + status, + subscription, + appliedAt, + cancelledAt, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionChangeCancelParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionChangeCancelParams.kt index 581cedb61..46e8aa5f4 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionChangeCancelParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionChangeCancelParams.kt @@ -217,10 +217,20 @@ private constructor( return true } - return /* spotless:off */ other is SubscriptionChangeCancelParams && subscriptionChangeId == other.subscriptionChangeId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return other is SubscriptionChangeCancelParams && + subscriptionChangeId == other.subscriptionChangeId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(subscriptionChangeId, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash( + subscriptionChangeId, + additionalHeaders, + additionalQueryParams, + additionalBodyProperties, + ) override fun toString() = "SubscriptionChangeCancelParams{subscriptionChangeId=$subscriptionChangeId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionChangeCancelResponse.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionChangeCancelResponse.kt index b9410635d..4ec329113 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionChangeCancelResponse.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionChangeCancelResponse.kt @@ -476,7 +476,7 @@ private constructor( return true } - return /* spotless:off */ other is Status && value == other.value /* spotless:on */ + return other is Status && value == other.value } override fun hashCode() = value.hashCode() @@ -489,12 +489,27 @@ private constructor( return true } - return /* spotless:off */ other is SubscriptionChangeCancelResponse && id == other.id && expirationTime == other.expirationTime && status == other.status && subscription == other.subscription && appliedAt == other.appliedAt && cancelledAt == other.cancelledAt && additionalProperties == other.additionalProperties /* spotless:on */ + return other is SubscriptionChangeCancelResponse && + id == other.id && + expirationTime == other.expirationTime && + status == other.status && + subscription == other.subscription && + appliedAt == other.appliedAt && + cancelledAt == other.cancelledAt && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, expirationTime, status, subscription, appliedAt, cancelledAt, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + id, + expirationTime, + status, + subscription, + appliedAt, + cancelledAt, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionChangeMinified.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionChangeMinified.kt index 5c84d2659..36a7d285f 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionChangeMinified.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionChangeMinified.kt @@ -151,12 +151,12 @@ private constructor( return true } - return /* spotless:off */ other is SubscriptionChangeMinified && id == other.id && additionalProperties == other.additionalProperties /* spotless:on */ + return other is SubscriptionChangeMinified && + id == other.id && + additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(id, additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionChangeRetrieveParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionChangeRetrieveParams.kt index 4be798700..0be99bdeb 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionChangeRetrieveParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionChangeRetrieveParams.kt @@ -189,10 +189,14 @@ private constructor( return true } - return /* spotless:off */ other is SubscriptionChangeRetrieveParams && subscriptionChangeId == other.subscriptionChangeId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return other is SubscriptionChangeRetrieveParams && + subscriptionChangeId == other.subscriptionChangeId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(subscriptionChangeId, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash(subscriptionChangeId, additionalHeaders, additionalQueryParams) override fun toString() = "SubscriptionChangeRetrieveParams{subscriptionChangeId=$subscriptionChangeId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionChangeRetrieveResponse.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionChangeRetrieveResponse.kt index 0c9dc6815..661823286 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionChangeRetrieveResponse.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionChangeRetrieveResponse.kt @@ -476,7 +476,7 @@ private constructor( return true } - return /* spotless:off */ other is Status && value == other.value /* spotless:on */ + return other is Status && value == other.value } override fun hashCode() = value.hashCode() @@ -489,12 +489,27 @@ private constructor( return true } - return /* spotless:off */ other is SubscriptionChangeRetrieveResponse && id == other.id && expirationTime == other.expirationTime && status == other.status && subscription == other.subscription && appliedAt == other.appliedAt && cancelledAt == other.cancelledAt && additionalProperties == other.additionalProperties /* spotless:on */ + return other is SubscriptionChangeRetrieveResponse && + id == other.id && + expirationTime == other.expirationTime && + status == other.status && + subscription == other.subscription && + appliedAt == other.appliedAt && + cancelledAt == other.cancelledAt && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, expirationTime, status, subscription, appliedAt, cancelledAt, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + id, + expirationTime, + status, + subscription, + appliedAt, + cancelledAt, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionCreateParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionCreateParams.kt index 64cec9a04..e1658ee73 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionCreateParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionCreateParams.kt @@ -3376,12 +3376,82 @@ private constructor( return true } - return /* spotless:off */ other is Body && addAdjustments == other.addAdjustments && addPrices == other.addPrices && alignBillingWithSubscriptionStartDate == other.alignBillingWithSubscriptionStartDate && autoCollection == other.autoCollection && awsRegion == other.awsRegion && billingCycleAnchorConfiguration == other.billingCycleAnchorConfiguration && couponRedemptionCode == other.couponRedemptionCode && creditsOverageRate == other.creditsOverageRate && currency == other.currency && customerId == other.customerId && defaultInvoiceMemo == other.defaultInvoiceMemo && endDate == other.endDate && externalCustomerId == other.externalCustomerId && externalMarketplace == other.externalMarketplace && externalMarketplaceReportingId == other.externalMarketplaceReportingId && externalPlanId == other.externalPlanId && filter == other.filter && initialPhaseOrder == other.initialPhaseOrder && invoicingThreshold == other.invoicingThreshold && metadata == other.metadata && name == other.name && netTerms == other.netTerms && perCreditOverageAmount == other.perCreditOverageAmount && planId == other.planId && planVersionNumber == other.planVersionNumber && priceOverrides == other.priceOverrides && removeAdjustments == other.removeAdjustments && removePrices == other.removePrices && replaceAdjustments == other.replaceAdjustments && replacePrices == other.replacePrices && startDate == other.startDate && trialDurationDays == other.trialDurationDays && usageCustomerIds == other.usageCustomerIds && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Body && + addAdjustments == other.addAdjustments && + addPrices == other.addPrices && + alignBillingWithSubscriptionStartDate == + other.alignBillingWithSubscriptionStartDate && + autoCollection == other.autoCollection && + awsRegion == other.awsRegion && + billingCycleAnchorConfiguration == other.billingCycleAnchorConfiguration && + couponRedemptionCode == other.couponRedemptionCode && + creditsOverageRate == other.creditsOverageRate && + currency == other.currency && + customerId == other.customerId && + defaultInvoiceMemo == other.defaultInvoiceMemo && + endDate == other.endDate && + externalCustomerId == other.externalCustomerId && + externalMarketplace == other.externalMarketplace && + externalMarketplaceReportingId == other.externalMarketplaceReportingId && + externalPlanId == other.externalPlanId && + filter == other.filter && + initialPhaseOrder == other.initialPhaseOrder && + invoicingThreshold == other.invoicingThreshold && + metadata == other.metadata && + name == other.name && + netTerms == other.netTerms && + perCreditOverageAmount == other.perCreditOverageAmount && + planId == other.planId && + planVersionNumber == other.planVersionNumber && + priceOverrides == other.priceOverrides && + removeAdjustments == other.removeAdjustments && + removePrices == other.removePrices && + replaceAdjustments == other.replaceAdjustments && + replacePrices == other.replacePrices && + startDate == other.startDate && + trialDurationDays == other.trialDurationDays && + usageCustomerIds == other.usageCustomerIds && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(addAdjustments, addPrices, alignBillingWithSubscriptionStartDate, autoCollection, awsRegion, billingCycleAnchorConfiguration, couponRedemptionCode, creditsOverageRate, currency, customerId, defaultInvoiceMemo, endDate, externalCustomerId, externalMarketplace, externalMarketplaceReportingId, externalPlanId, filter, initialPhaseOrder, invoicingThreshold, metadata, name, netTerms, perCreditOverageAmount, planId, planVersionNumber, priceOverrides, removeAdjustments, removePrices, replaceAdjustments, replacePrices, startDate, trialDurationDays, usageCustomerIds, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + addAdjustments, + addPrices, + alignBillingWithSubscriptionStartDate, + autoCollection, + awsRegion, + billingCycleAnchorConfiguration, + couponRedemptionCode, + creditsOverageRate, + currency, + customerId, + defaultInvoiceMemo, + endDate, + externalCustomerId, + externalMarketplace, + externalMarketplaceReportingId, + externalPlanId, + filter, + initialPhaseOrder, + invoicingThreshold, + metadata, + name, + netTerms, + perCreditOverageAmount, + planId, + planVersionNumber, + priceOverrides, + removeAdjustments, + removePrices, + replaceAdjustments, + replacePrices, + startDate, + trialDurationDays, + usageCustomerIds, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode @@ -3895,10 +3965,16 @@ private constructor( return true } - return /* spotless:off */ other is Adjustment && percentageDiscount == other.percentageDiscount && usageDiscount == other.usageDiscount && amountDiscount == other.amountDiscount && minimum == other.minimum && maximum == other.maximum /* spotless:on */ + return other is Adjustment && + percentageDiscount == other.percentageDiscount && + usageDiscount == other.usageDiscount && + amountDiscount == other.amountDiscount && + minimum == other.minimum && + maximum == other.maximum } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(percentageDiscount, usageDiscount, amountDiscount, minimum, maximum) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash(percentageDiscount, usageDiscount, amountDiscount, minimum, maximum) override fun toString(): String = when { @@ -4023,12 +4099,17 @@ private constructor( return true } - return /* spotless:off */ other is AddAdjustment && adjustment == other.adjustment && endDate == other.endDate && planPhaseOrder == other.planPhaseOrder && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ + return other is AddAdjustment && + adjustment == other.adjustment && + endDate == other.endDate && + planPhaseOrder == other.planPhaseOrder && + startDate == other.startDate && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(adjustment, endDate, planPhaseOrder, startDate, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash(adjustment, endDate, planPhaseOrder, startDate, additionalProperties) + } override fun hashCode(): Int = hashCode @@ -5327,10 +5408,68 @@ private constructor( return true } - return /* spotless:off */ other is Price && unit == other.unit && package_ == other.package_ && matrix == other.matrix && tiered == other.tiered && tieredBps == other.tieredBps && bps == other.bps && bulkBps == other.bulkBps && bulk == other.bulk && thresholdTotalAmount == other.thresholdTotalAmount && tieredPackage == other.tieredPackage && tieredWithMinimum == other.tieredWithMinimum && unitWithPercent == other.unitWithPercent && packageWithAllocation == other.packageWithAllocation && tieredWithProration == other.tieredWithProration && unitWithProration == other.unitWithProration && groupedAllocation == other.groupedAllocation && groupedWithProratedMinimum == other.groupedWithProratedMinimum && bulkWithProration == other.bulkWithProration && scalableMatrixWithUnitPricing == other.scalableMatrixWithUnitPricing && scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && cumulativeGroupedBulk == other.cumulativeGroupedBulk && maxGroupTieredPackage == other.maxGroupTieredPackage && groupedWithMeteredMinimum == other.groupedWithMeteredMinimum && matrixWithDisplayName == other.matrixWithDisplayName && groupedTieredPackage == other.groupedTieredPackage && matrixWithAllocation == other.matrixWithAllocation && tieredPackageWithMinimum == other.tieredPackageWithMinimum && groupedTiered == other.groupedTiered /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, package_, matrix, tiered, tieredBps, bps, bulkBps, bulk, thresholdTotalAmount, tieredPackage, tieredWithMinimum, unitWithPercent, packageWithAllocation, tieredWithProration, unitWithProration, groupedAllocation, groupedWithProratedMinimum, bulkWithProration, scalableMatrixWithUnitPricing, scalableMatrixWithTieredPricing, cumulativeGroupedBulk, maxGroupTieredPackage, groupedWithMeteredMinimum, matrixWithDisplayName, groupedTieredPackage, matrixWithAllocation, tieredPackageWithMinimum, groupedTiered) /* spotless:on */ + return other is Price && + unit == other.unit && + package_ == other.package_ && + matrix == other.matrix && + tiered == other.tiered && + tieredBps == other.tieredBps && + bps == other.bps && + bulkBps == other.bulkBps && + bulk == other.bulk && + thresholdTotalAmount == other.thresholdTotalAmount && + tieredPackage == other.tieredPackage && + tieredWithMinimum == other.tieredWithMinimum && + unitWithPercent == other.unitWithPercent && + packageWithAllocation == other.packageWithAllocation && + tieredWithProration == other.tieredWithProration && + unitWithProration == other.unitWithProration && + groupedAllocation == other.groupedAllocation && + groupedWithProratedMinimum == other.groupedWithProratedMinimum && + bulkWithProration == other.bulkWithProration && + scalableMatrixWithUnitPricing == other.scalableMatrixWithUnitPricing && + scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && + cumulativeGroupedBulk == other.cumulativeGroupedBulk && + maxGroupTieredPackage == other.maxGroupTieredPackage && + groupedWithMeteredMinimum == other.groupedWithMeteredMinimum && + matrixWithDisplayName == other.matrixWithDisplayName && + groupedTieredPackage == other.groupedTieredPackage && + matrixWithAllocation == other.matrixWithAllocation && + tieredPackageWithMinimum == other.tieredPackageWithMinimum && + groupedTiered == other.groupedTiered + } + + override fun hashCode(): Int = + Objects.hash( + unit, + package_, + matrix, + tiered, + tieredBps, + bps, + bulkBps, + bulk, + thresholdTotalAmount, + tieredPackage, + tieredWithMinimum, + unitWithPercent, + packageWithAllocation, + tieredWithProration, + unitWithProration, + groupedAllocation, + groupedWithProratedMinimum, + bulkWithProration, + scalableMatrixWithUnitPricing, + scalableMatrixWithTieredPricing, + cumulativeGroupedBulk, + maxGroupTieredPackage, + groupedWithMeteredMinimum, + matrixWithDisplayName, + groupedTieredPackage, + matrixWithAllocation, + tieredPackageWithMinimum, + groupedTiered, + ) override fun toString(): String = when { @@ -5873,12 +6012,35 @@ private constructor( return true } - return /* spotless:off */ other is AddPrice && allocationPrice == other.allocationPrice && discounts == other.discounts && endDate == other.endDate && externalPriceId == other.externalPriceId && maximumAmount == other.maximumAmount && minimumAmount == other.minimumAmount && planPhaseOrder == other.planPhaseOrder && price == other.price && priceId == other.priceId && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ + return other is AddPrice && + allocationPrice == other.allocationPrice && + discounts == other.discounts && + endDate == other.endDate && + externalPriceId == other.externalPriceId && + maximumAmount == other.maximumAmount && + minimumAmount == other.minimumAmount && + planPhaseOrder == other.planPhaseOrder && + price == other.price && + priceId == other.priceId && + startDate == other.startDate && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(allocationPrice, discounts, endDate, externalPriceId, maximumAmount, minimumAmount, planPhaseOrder, price, priceId, startDate, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + allocationPrice, + discounts, + endDate, + externalPriceId, + maximumAmount, + minimumAmount, + planPhaseOrder, + price, + priceId, + startDate, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode @@ -6014,7 +6176,7 @@ private constructor( return true } - return /* spotless:off */ other is ExternalMarketplace && value == other.value /* spotless:on */ + return other is ExternalMarketplace && value == other.value } override fun hashCode() = value.hashCode() @@ -6114,12 +6276,10 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -6277,12 +6437,12 @@ private constructor( return true } - return /* spotless:off */ other is RemoveAdjustment && adjustmentId == other.adjustmentId && additionalProperties == other.additionalProperties /* spotless:on */ + return other is RemoveAdjustment && + adjustmentId == other.adjustmentId && + additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(adjustmentId, additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -6459,12 +6619,15 @@ private constructor( return true } - return /* spotless:off */ other is RemovePrice && externalPriceId == other.externalPriceId && priceId == other.priceId && additionalProperties == other.additionalProperties /* spotless:on */ + return other is RemovePrice && + externalPriceId == other.externalPriceId && + priceId == other.priceId && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(externalPriceId, priceId, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash(externalPriceId, priceId, additionalProperties) + } override fun hashCode(): Int = hashCode @@ -6886,10 +7049,16 @@ private constructor( return true } - return /* spotless:off */ other is Adjustment && percentageDiscount == other.percentageDiscount && usageDiscount == other.usageDiscount && amountDiscount == other.amountDiscount && minimum == other.minimum && maximum == other.maximum /* spotless:on */ + return other is Adjustment && + percentageDiscount == other.percentageDiscount && + usageDiscount == other.usageDiscount && + amountDiscount == other.amountDiscount && + minimum == other.minimum && + maximum == other.maximum } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(percentageDiscount, usageDiscount, amountDiscount, minimum, maximum) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash(percentageDiscount, usageDiscount, amountDiscount, minimum, maximum) override fun toString(): String = when { @@ -7014,12 +7183,15 @@ private constructor( return true } - return /* spotless:off */ other is ReplaceAdjustment && adjustment == other.adjustment && replacesAdjustmentId == other.replacesAdjustmentId && additionalProperties == other.additionalProperties /* spotless:on */ + return other is ReplaceAdjustment && + adjustment == other.adjustment && + replacesAdjustmentId == other.replacesAdjustmentId && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(adjustment, replacesAdjustmentId, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash(adjustment, replacesAdjustmentId, additionalProperties) + } override fun hashCode(): Int = hashCode @@ -8288,10 +8460,68 @@ private constructor( return true } - return /* spotless:off */ other is Price && unit == other.unit && package_ == other.package_ && matrix == other.matrix && tiered == other.tiered && tieredBps == other.tieredBps && bps == other.bps && bulkBps == other.bulkBps && bulk == other.bulk && thresholdTotalAmount == other.thresholdTotalAmount && tieredPackage == other.tieredPackage && tieredWithMinimum == other.tieredWithMinimum && unitWithPercent == other.unitWithPercent && packageWithAllocation == other.packageWithAllocation && tieredWithProration == other.tieredWithProration && unitWithProration == other.unitWithProration && groupedAllocation == other.groupedAllocation && groupedWithProratedMinimum == other.groupedWithProratedMinimum && bulkWithProration == other.bulkWithProration && scalableMatrixWithUnitPricing == other.scalableMatrixWithUnitPricing && scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && cumulativeGroupedBulk == other.cumulativeGroupedBulk && maxGroupTieredPackage == other.maxGroupTieredPackage && groupedWithMeteredMinimum == other.groupedWithMeteredMinimum && matrixWithDisplayName == other.matrixWithDisplayName && groupedTieredPackage == other.groupedTieredPackage && matrixWithAllocation == other.matrixWithAllocation && tieredPackageWithMinimum == other.tieredPackageWithMinimum && groupedTiered == other.groupedTiered /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, package_, matrix, tiered, tieredBps, bps, bulkBps, bulk, thresholdTotalAmount, tieredPackage, tieredWithMinimum, unitWithPercent, packageWithAllocation, tieredWithProration, unitWithProration, groupedAllocation, groupedWithProratedMinimum, bulkWithProration, scalableMatrixWithUnitPricing, scalableMatrixWithTieredPricing, cumulativeGroupedBulk, maxGroupTieredPackage, groupedWithMeteredMinimum, matrixWithDisplayName, groupedTieredPackage, matrixWithAllocation, tieredPackageWithMinimum, groupedTiered) /* spotless:on */ + return other is Price && + unit == other.unit && + package_ == other.package_ && + matrix == other.matrix && + tiered == other.tiered && + tieredBps == other.tieredBps && + bps == other.bps && + bulkBps == other.bulkBps && + bulk == other.bulk && + thresholdTotalAmount == other.thresholdTotalAmount && + tieredPackage == other.tieredPackage && + tieredWithMinimum == other.tieredWithMinimum && + unitWithPercent == other.unitWithPercent && + packageWithAllocation == other.packageWithAllocation && + tieredWithProration == other.tieredWithProration && + unitWithProration == other.unitWithProration && + groupedAllocation == other.groupedAllocation && + groupedWithProratedMinimum == other.groupedWithProratedMinimum && + bulkWithProration == other.bulkWithProration && + scalableMatrixWithUnitPricing == other.scalableMatrixWithUnitPricing && + scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && + cumulativeGroupedBulk == other.cumulativeGroupedBulk && + maxGroupTieredPackage == other.maxGroupTieredPackage && + groupedWithMeteredMinimum == other.groupedWithMeteredMinimum && + matrixWithDisplayName == other.matrixWithDisplayName && + groupedTieredPackage == other.groupedTieredPackage && + matrixWithAllocation == other.matrixWithAllocation && + tieredPackageWithMinimum == other.tieredPackageWithMinimum && + groupedTiered == other.groupedTiered + } + + override fun hashCode(): Int = + Objects.hash( + unit, + package_, + matrix, + tiered, + tieredBps, + bps, + bulkBps, + bulk, + thresholdTotalAmount, + tieredPackage, + tieredWithMinimum, + unitWithPercent, + packageWithAllocation, + tieredWithProration, + unitWithProration, + groupedAllocation, + groupedWithProratedMinimum, + bulkWithProration, + scalableMatrixWithUnitPricing, + scalableMatrixWithTieredPricing, + cumulativeGroupedBulk, + maxGroupTieredPackage, + groupedWithMeteredMinimum, + matrixWithDisplayName, + groupedTieredPackage, + matrixWithAllocation, + tieredPackageWithMinimum, + groupedTiered, + ) override fun toString(): String = when { @@ -8834,12 +9064,33 @@ private constructor( return true } - return /* spotless:off */ other is ReplacePrice && replacesPriceId == other.replacesPriceId && allocationPrice == other.allocationPrice && discounts == other.discounts && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && maximumAmount == other.maximumAmount && minimumAmount == other.minimumAmount && price == other.price && priceId == other.priceId && additionalProperties == other.additionalProperties /* spotless:on */ + return other is ReplacePrice && + replacesPriceId == other.replacesPriceId && + allocationPrice == other.allocationPrice && + discounts == other.discounts && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + maximumAmount == other.maximumAmount && + minimumAmount == other.minimumAmount && + price == other.price && + priceId == other.priceId && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(replacesPriceId, allocationPrice, discounts, externalPriceId, fixedPriceQuantity, maximumAmount, minimumAmount, price, priceId, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + replacesPriceId, + allocationPrice, + discounts, + externalPriceId, + fixedPriceQuantity, + maximumAmount, + minimumAmount, + price, + priceId, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode @@ -8852,10 +9103,13 @@ private constructor( return true } - return /* spotless:off */ other is SubscriptionCreateParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return other is SubscriptionCreateParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(body, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) override fun toString() = "SubscriptionCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchCostsParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchCostsParams.kt index 2ac4a2cb6..9c151623c 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchCostsParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchCostsParams.kt @@ -371,7 +371,7 @@ private constructor( return true } - return /* spotless:off */ other is ViewMode && value == other.value /* spotless:on */ + return other is ViewMode && value == other.value } override fun hashCode() = value.hashCode() @@ -384,10 +384,26 @@ private constructor( return true } - return /* spotless:off */ other is SubscriptionFetchCostsParams && subscriptionId == other.subscriptionId && currency == other.currency && timeframeEnd == other.timeframeEnd && timeframeStart == other.timeframeStart && viewMode == other.viewMode && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return other is SubscriptionFetchCostsParams && + subscriptionId == other.subscriptionId && + currency == other.currency && + timeframeEnd == other.timeframeEnd && + timeframeStart == other.timeframeStart && + viewMode == other.viewMode && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(subscriptionId, currency, timeframeEnd, timeframeStart, viewMode, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash( + subscriptionId, + currency, + timeframeEnd, + timeframeStart, + viewMode, + additionalHeaders, + additionalQueryParams, + ) override fun toString() = "SubscriptionFetchCostsParams{subscriptionId=$subscriptionId, currency=$currency, timeframeEnd=$timeframeEnd, timeframeStart=$timeframeStart, viewMode=$viewMode, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchCostsResponse.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchCostsResponse.kt index 02f45d24e..1b901fc72 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchCostsResponse.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchCostsResponse.kt @@ -175,12 +175,12 @@ private constructor( return true } - return /* spotless:off */ other is SubscriptionFetchCostsResponse && data == other.data && additionalProperties == other.additionalProperties /* spotless:on */ + return other is SubscriptionFetchCostsResponse && + data == other.data && + additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(data, additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchParams.kt index 0ed84f6e4..dca86f00b 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchParams.kt @@ -177,10 +177,14 @@ private constructor( return true } - return /* spotless:off */ other is SubscriptionFetchParams && subscriptionId == other.subscriptionId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return other is SubscriptionFetchParams && + subscriptionId == other.subscriptionId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(subscriptionId, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash(subscriptionId, additionalHeaders, additionalQueryParams) override fun toString() = "SubscriptionFetchParams{subscriptionId=$subscriptionId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchSchedulePage.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchSchedulePage.kt index 376368aa8..628bd204e 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchSchedulePage.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchSchedulePage.kt @@ -123,10 +123,13 @@ private constructor( return true } - return /* spotless:off */ other is SubscriptionFetchSchedulePage && service == other.service && params == other.params && response == other.response /* spotless:on */ + return other is SubscriptionFetchSchedulePage && + service == other.service && + params == other.params && + response == other.response } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, params, response) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(service, params, response) override fun toString() = "SubscriptionFetchSchedulePage{service=$service, params=$params, response=$response}" diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchSchedulePageAsync.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchSchedulePageAsync.kt index 655260487..a9bd226c1 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchSchedulePageAsync.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchSchedulePageAsync.kt @@ -125,10 +125,13 @@ private constructor( return true } - return /* spotless:off */ other is SubscriptionFetchSchedulePageAsync && service == other.service && params == other.params && response == other.response /* spotless:on */ + return other is SubscriptionFetchSchedulePageAsync && + service == other.service && + params == other.params && + response == other.response } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, params, response) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(service, params, response) override fun toString() = "SubscriptionFetchSchedulePageAsync{service=$service, params=$params, response=$response}" diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchSchedulePageResponse.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchSchedulePageResponse.kt index 09bd08c90..58a19fe19 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchSchedulePageResponse.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchSchedulePageResponse.kt @@ -222,12 +222,15 @@ private constructor( return true } - return /* spotless:off */ other is SubscriptionFetchSchedulePageResponse && data == other.data && paginationMetadata == other.paginationMetadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is SubscriptionFetchSchedulePageResponse && + data == other.data && + paginationMetadata == other.paginationMetadata && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(data, paginationMetadata, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash(data, paginationMetadata, additionalProperties) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchScheduleParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchScheduleParams.kt index 4fd3e45a8..9b07a0b3f 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchScheduleParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchScheduleParams.kt @@ -269,10 +269,30 @@ private constructor( return true } - return /* spotless:off */ other is SubscriptionFetchScheduleParams && subscriptionId == other.subscriptionId && cursor == other.cursor && limit == other.limit && startDateGt == other.startDateGt && startDateGte == other.startDateGte && startDateLt == other.startDateLt && startDateLte == other.startDateLte && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return other is SubscriptionFetchScheduleParams && + subscriptionId == other.subscriptionId && + cursor == other.cursor && + limit == other.limit && + startDateGt == other.startDateGt && + startDateGte == other.startDateGte && + startDateLt == other.startDateLt && + startDateLte == other.startDateLte && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(subscriptionId, cursor, limit, startDateGt, startDateGte, startDateLt, startDateLte, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash( + subscriptionId, + cursor, + limit, + startDateGt, + startDateGte, + startDateLt, + startDateLte, + additionalHeaders, + additionalQueryParams, + ) override fun toString() = "SubscriptionFetchScheduleParams{subscriptionId=$subscriptionId, cursor=$cursor, limit=$limit, startDateGt=$startDateGt, startDateGte=$startDateGte, startDateLt=$startDateLt, startDateLte=$startDateLte, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchScheduleResponse.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchScheduleResponse.kt index 51d255a21..04aa641ed 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchScheduleResponse.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchScheduleResponse.kt @@ -488,12 +488,16 @@ private constructor( return true } - return /* spotless:off */ other is Plan && id == other.id && externalPlanId == other.externalPlanId && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Plan && + id == other.id && + externalPlanId == other.externalPlanId && + name == other.name && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, externalPlanId, name, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash(id, externalPlanId, name, additionalProperties) + } override fun hashCode(): Int = hashCode @@ -506,12 +510,17 @@ private constructor( return true } - return /* spotless:off */ other is SubscriptionFetchScheduleResponse && createdAt == other.createdAt && endDate == other.endDate && plan == other.plan && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ + return other is SubscriptionFetchScheduleResponse && + createdAt == other.createdAt && + endDate == other.endDate && + plan == other.plan && + startDate == other.startDate && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(createdAt, endDate, plan, startDate, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash(createdAt, endDate, plan, startDate, additionalProperties) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchUsageParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchUsageParams.kt index 190aa3cef..5df20f4f7 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchUsageParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchUsageParams.kt @@ -605,7 +605,7 @@ private constructor( return true } - return /* spotless:off */ other is Granularity && value == other.value /* spotless:on */ + return other is Granularity && value == other.value } override fun hashCode() = value.hashCode() @@ -734,7 +734,7 @@ private constructor( return true } - return /* spotless:off */ other is ViewMode && value == other.value /* spotless:on */ + return other is ViewMode && value == other.value } override fun hashCode() = value.hashCode() @@ -747,10 +747,38 @@ private constructor( return true } - return /* spotless:off */ other is SubscriptionFetchUsageParams && subscriptionId == other.subscriptionId && billableMetricId == other.billableMetricId && firstDimensionKey == other.firstDimensionKey && firstDimensionValue == other.firstDimensionValue && granularity == other.granularity && groupBy == other.groupBy && secondDimensionKey == other.secondDimensionKey && secondDimensionValue == other.secondDimensionValue && timeframeEnd == other.timeframeEnd && timeframeStart == other.timeframeStart && viewMode == other.viewMode && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return other is SubscriptionFetchUsageParams && + subscriptionId == other.subscriptionId && + billableMetricId == other.billableMetricId && + firstDimensionKey == other.firstDimensionKey && + firstDimensionValue == other.firstDimensionValue && + granularity == other.granularity && + groupBy == other.groupBy && + secondDimensionKey == other.secondDimensionKey && + secondDimensionValue == other.secondDimensionValue && + timeframeEnd == other.timeframeEnd && + timeframeStart == other.timeframeStart && + viewMode == other.viewMode && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(subscriptionId, billableMetricId, firstDimensionKey, firstDimensionValue, granularity, groupBy, secondDimensionKey, secondDimensionValue, timeframeEnd, timeframeStart, viewMode, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash( + subscriptionId, + billableMetricId, + firstDimensionKey, + firstDimensionValue, + granularity, + groupBy, + secondDimensionKey, + secondDimensionValue, + timeframeEnd, + timeframeStart, + viewMode, + additionalHeaders, + additionalQueryParams, + ) override fun toString() = "SubscriptionFetchUsageParams{subscriptionId=$subscriptionId, billableMetricId=$billableMetricId, firstDimensionKey=$firstDimensionKey, firstDimensionValue=$firstDimensionValue, granularity=$granularity, groupBy=$groupBy, secondDimensionKey=$secondDimensionKey, secondDimensionValue=$secondDimensionValue, timeframeEnd=$timeframeEnd, timeframeStart=$timeframeStart, viewMode=$viewMode, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionListPage.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionListPage.kt index 85a804ebc..4fca6dbd5 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionListPage.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionListPage.kt @@ -119,10 +119,13 @@ private constructor( return true } - return /* spotless:off */ other is SubscriptionListPage && service == other.service && params == other.params && response == other.response /* spotless:on */ + return other is SubscriptionListPage && + service == other.service && + params == other.params && + response == other.response } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, params, response) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(service, params, response) override fun toString() = "SubscriptionListPage{service=$service, params=$params, response=$response}" diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionListPageAsync.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionListPageAsync.kt index 32008ea0d..7f054402d 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionListPageAsync.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionListPageAsync.kt @@ -119,10 +119,13 @@ private constructor( return true } - return /* spotless:off */ other is SubscriptionListPageAsync && service == other.service && params == other.params && response == other.response /* spotless:on */ + return other is SubscriptionListPageAsync && + service == other.service && + params == other.params && + response == other.response } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, params, response) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(service, params, response) override fun toString() = "SubscriptionListPageAsync{service=$service, params=$params, response=$response}" diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionListParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionListParams.kt index d37b26257..1a4a2561e 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionListParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionListParams.kt @@ -427,7 +427,7 @@ private constructor( return true } - return /* spotless:off */ other is Status && value == other.value /* spotless:on */ + return other is Status && value == other.value } override fun hashCode() = value.hashCode() @@ -440,10 +440,34 @@ private constructor( return true } - return /* spotless:off */ other is SubscriptionListParams && createdAtGt == other.createdAtGt && createdAtGte == other.createdAtGte && createdAtLt == other.createdAtLt && createdAtLte == other.createdAtLte && cursor == other.cursor && customerId == other.customerId && externalCustomerId == other.externalCustomerId && limit == other.limit && status == other.status && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return other is SubscriptionListParams && + createdAtGt == other.createdAtGt && + createdAtGte == other.createdAtGte && + createdAtLt == other.createdAtLt && + createdAtLte == other.createdAtLte && + cursor == other.cursor && + customerId == other.customerId && + externalCustomerId == other.externalCustomerId && + limit == other.limit && + status == other.status && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(createdAtGt, createdAtGte, createdAtLt, createdAtLte, cursor, customerId, externalCustomerId, limit, status, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash( + createdAtGt, + createdAtGte, + createdAtLt, + createdAtLte, + cursor, + customerId, + externalCustomerId, + limit, + status, + additionalHeaders, + additionalQueryParams, + ) override fun toString() = "SubscriptionListParams{createdAtGt=$createdAtGt, createdAtGte=$createdAtGte, createdAtLt=$createdAtLt, createdAtLte=$createdAtLte, cursor=$cursor, customerId=$customerId, externalCustomerId=$externalCustomerId, limit=$limit, status=$status, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionMinified.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionMinified.kt index a9a65caa1..682241e20 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionMinified.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionMinified.kt @@ -151,12 +151,12 @@ private constructor( return true } - return /* spotless:off */ other is SubscriptionMinified && id == other.id && additionalProperties == other.additionalProperties /* spotless:on */ + return other is SubscriptionMinified && + id == other.id && + additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(id, additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsParams.kt index b16b1d100..2337bc5bd 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsParams.kt @@ -860,12 +860,25 @@ private constructor( return true } - return /* spotless:off */ other is Body && add == other.add && addAdjustments == other.addAdjustments && allowInvoiceCreditOrVoid == other.allowInvoiceCreditOrVoid && edit == other.edit && editAdjustments == other.editAdjustments && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Body && + add == other.add && + addAdjustments == other.addAdjustments && + allowInvoiceCreditOrVoid == other.allowInvoiceCreditOrVoid && + edit == other.edit && + editAdjustments == other.editAdjustments && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(add, addAdjustments, allowInvoiceCreditOrVoid, edit, editAdjustments, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + add, + addAdjustments, + allowInvoiceCreditOrVoid, + edit, + editAdjustments, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode @@ -1852,10 +1865,12 @@ private constructor( return true } - return /* spotless:off */ other is StartDate && dateTime == other.dateTime && billingCycleRelative == other.billingCycleRelative /* spotless:on */ + return other is StartDate && + dateTime == other.dateTime && + billingCycleRelative == other.billingCycleRelative } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(dateTime, billingCycleRelative) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(dateTime, billingCycleRelative) override fun toString(): String = when { @@ -2041,10 +2056,13 @@ private constructor( return true } - return /* spotless:off */ other is Discount && amount == other.amount && percentage == other.percentage && usage == other.usage /* spotless:on */ + return other is Discount && + amount == other.amount && + percentage == other.percentage && + usage == other.usage } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(amount, percentage, usage) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(amount, percentage, usage) override fun toString(): String = when { @@ -2335,12 +2353,15 @@ private constructor( return true } - return /* spotless:off */ other is Amount && amountDiscount == other.amountDiscount && discountType == other.discountType && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Amount && + amountDiscount == other.amountDiscount && + discountType == other.discountType && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(amountDiscount, discountType, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash(amountDiscount, discountType, additionalProperties) + } override fun hashCode(): Int = hashCode @@ -2552,12 +2573,15 @@ private constructor( return true } - return /* spotless:off */ other is Percentage && discountType == other.discountType && percentageDiscount == other.percentageDiscount && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Percentage && + discountType == other.discountType && + percentageDiscount == other.percentageDiscount && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(discountType, percentageDiscount, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash(discountType, percentageDiscount, additionalProperties) + } override fun hashCode(): Int = hashCode @@ -2768,12 +2792,15 @@ private constructor( return true } - return /* spotless:off */ other is Usage && discountType == other.discountType && usageDiscount == other.usageDiscount && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Usage && + discountType == other.discountType && + usageDiscount == other.usageDiscount && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(discountType, usageDiscount, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash(discountType, usageDiscount, additionalProperties) + } override fun hashCode(): Int = hashCode @@ -2871,10 +2898,12 @@ private constructor( return true } - return /* spotless:off */ other is EndDate && dateTime == other.dateTime && billingCycleRelative == other.billingCycleRelative /* spotless:on */ + return other is EndDate && + dateTime == other.dateTime && + billingCycleRelative == other.billingCycleRelative } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(dateTime, billingCycleRelative) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(dateTime, billingCycleRelative) override fun toString(): String = when { @@ -3164,12 +3193,15 @@ private constructor( return true } - return /* spotless:off */ other is FixedFeeQuantityTransition && effectiveDate == other.effectiveDate && quantity == other.quantity && additionalProperties == other.additionalProperties /* spotless:on */ + return other is FixedFeeQuantityTransition && + effectiveDate == other.effectiveDate && + quantity == other.quantity && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(effectiveDate, quantity, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash(effectiveDate, quantity, additionalProperties) + } override fun hashCode(): Int = hashCode @@ -3762,10 +3794,68 @@ private constructor( return true } - return /* spotless:off */ other is Price && unit == other.unit && package_ == other.package_ && matrix == other.matrix && matrixWithAllocation == other.matrixWithAllocation && tiered == other.tiered && tieredBps == other.tieredBps && bps == other.bps && bulkBps == other.bulkBps && bulk == other.bulk && thresholdTotalAmount == other.thresholdTotalAmount && tieredPackage == other.tieredPackage && groupedTiered == other.groupedTiered && maxGroupTieredPackage == other.maxGroupTieredPackage && tieredWithMinimum == other.tieredWithMinimum && packageWithAllocation == other.packageWithAllocation && tieredPackageWithMinimum == other.tieredPackageWithMinimum && unitWithPercent == other.unitWithPercent && tieredWithProration == other.tieredWithProration && unitWithProration == other.unitWithProration && groupedAllocation == other.groupedAllocation && groupedWithProratedMinimum == other.groupedWithProratedMinimum && groupedWithMeteredMinimum == other.groupedWithMeteredMinimum && matrixWithDisplayName == other.matrixWithDisplayName && bulkWithProration == other.bulkWithProration && groupedTieredPackage == other.groupedTieredPackage && scalableMatrixWithUnitPricing == other.scalableMatrixWithUnitPricing && scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && cumulativeGroupedBulk == other.cumulativeGroupedBulk /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, package_, matrix, matrixWithAllocation, tiered, tieredBps, bps, bulkBps, bulk, thresholdTotalAmount, tieredPackage, groupedTiered, maxGroupTieredPackage, tieredWithMinimum, packageWithAllocation, tieredPackageWithMinimum, unitWithPercent, tieredWithProration, unitWithProration, groupedAllocation, groupedWithProratedMinimum, groupedWithMeteredMinimum, matrixWithDisplayName, bulkWithProration, groupedTieredPackage, scalableMatrixWithUnitPricing, scalableMatrixWithTieredPricing, cumulativeGroupedBulk) /* spotless:on */ + return other is Price && + unit == other.unit && + package_ == other.package_ && + matrix == other.matrix && + matrixWithAllocation == other.matrixWithAllocation && + tiered == other.tiered && + tieredBps == other.tieredBps && + bps == other.bps && + bulkBps == other.bulkBps && + bulk == other.bulk && + thresholdTotalAmount == other.thresholdTotalAmount && + tieredPackage == other.tieredPackage && + groupedTiered == other.groupedTiered && + maxGroupTieredPackage == other.maxGroupTieredPackage && + tieredWithMinimum == other.tieredWithMinimum && + packageWithAllocation == other.packageWithAllocation && + tieredPackageWithMinimum == other.tieredPackageWithMinimum && + unitWithPercent == other.unitWithPercent && + tieredWithProration == other.tieredWithProration && + unitWithProration == other.unitWithProration && + groupedAllocation == other.groupedAllocation && + groupedWithProratedMinimum == other.groupedWithProratedMinimum && + groupedWithMeteredMinimum == other.groupedWithMeteredMinimum && + matrixWithDisplayName == other.matrixWithDisplayName && + bulkWithProration == other.bulkWithProration && + groupedTieredPackage == other.groupedTieredPackage && + scalableMatrixWithUnitPricing == other.scalableMatrixWithUnitPricing && + scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && + cumulativeGroupedBulk == other.cumulativeGroupedBulk + } + + override fun hashCode(): Int = + Objects.hash( + unit, + package_, + matrix, + matrixWithAllocation, + tiered, + tieredBps, + bps, + bulkBps, + bulk, + thresholdTotalAmount, + tieredPackage, + groupedTiered, + maxGroupTieredPackage, + tieredWithMinimum, + packageWithAllocation, + tieredPackageWithMinimum, + unitWithPercent, + tieredWithProration, + unitWithProration, + groupedAllocation, + groupedWithProratedMinimum, + groupedWithMeteredMinimum, + matrixWithDisplayName, + bulkWithProration, + groupedTieredPackage, + scalableMatrixWithUnitPricing, + scalableMatrixWithTieredPricing, + cumulativeGroupedBulk, + ) override fun toString(): String = when { @@ -4280,12 +4370,39 @@ private constructor( return true } - return /* spotless:off */ other is Add && startDate == other.startDate && allocationPrice == other.allocationPrice && discounts == other.discounts && endDate == other.endDate && externalPriceId == other.externalPriceId && filter == other.filter && fixedFeeQuantityTransitions == other.fixedFeeQuantityTransitions && maximumAmount == other.maximumAmount && minimumAmount == other.minimumAmount && price == other.price && priceId == other.priceId && usageCustomerIds == other.usageCustomerIds && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Add && + startDate == other.startDate && + allocationPrice == other.allocationPrice && + discounts == other.discounts && + endDate == other.endDate && + externalPriceId == other.externalPriceId && + filter == other.filter && + fixedFeeQuantityTransitions == other.fixedFeeQuantityTransitions && + maximumAmount == other.maximumAmount && + minimumAmount == other.minimumAmount && + price == other.price && + priceId == other.priceId && + usageCustomerIds == other.usageCustomerIds && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(startDate, allocationPrice, discounts, endDate, externalPriceId, filter, fixedFeeQuantityTransitions, maximumAmount, minimumAmount, price, priceId, usageCustomerIds, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + startDate, + allocationPrice, + discounts, + endDate, + externalPriceId, + filter, + fixedFeeQuantityTransitions, + maximumAmount, + minimumAmount, + price, + priceId, + usageCustomerIds, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode @@ -4772,10 +4889,16 @@ private constructor( return true } - return /* spotless:off */ other is Adjustment && percentageDiscount == other.percentageDiscount && usageDiscount == other.usageDiscount && amountDiscount == other.amountDiscount && minimum == other.minimum && maximum == other.maximum /* spotless:on */ + return other is Adjustment && + percentageDiscount == other.percentageDiscount && + usageDiscount == other.usageDiscount && + amountDiscount == other.amountDiscount && + minimum == other.minimum && + maximum == other.maximum } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(percentageDiscount, usageDiscount, amountDiscount, minimum, maximum) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash(percentageDiscount, usageDiscount, amountDiscount, minimum, maximum) override fun toString(): String = when { @@ -4986,10 +5109,12 @@ private constructor( return true } - return /* spotless:off */ other is StartDate && dateTime == other.dateTime && billingCycleRelative == other.billingCycleRelative /* spotless:on */ + return other is StartDate && + dateTime == other.dateTime && + billingCycleRelative == other.billingCycleRelative } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(dateTime, billingCycleRelative) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(dateTime, billingCycleRelative) override fun toString(): String = when { @@ -5171,10 +5296,12 @@ private constructor( return true } - return /* spotless:off */ other is EndDate && dateTime == other.dateTime && billingCycleRelative == other.billingCycleRelative /* spotless:on */ + return other is EndDate && + dateTime == other.dateTime && + billingCycleRelative == other.billingCycleRelative } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(dateTime, billingCycleRelative) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(dateTime, billingCycleRelative) override fun toString(): String = when { @@ -5270,12 +5397,16 @@ private constructor( return true } - return /* spotless:off */ other is AddAdjustment && adjustment == other.adjustment && startDate == other.startDate && endDate == other.endDate && additionalProperties == other.additionalProperties /* spotless:on */ + return other is AddAdjustment && + adjustment == other.adjustment && + startDate == other.startDate && + endDate == other.endDate && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(adjustment, startDate, endDate, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash(adjustment, startDate, endDate, additionalProperties) + } override fun hashCode(): Int = hashCode @@ -5863,10 +5994,12 @@ private constructor( return true } - return /* spotless:off */ other is EndDate && dateTime == other.dateTime && billingCycleRelative == other.billingCycleRelative /* spotless:on */ + return other is EndDate && + dateTime == other.dateTime && + billingCycleRelative == other.billingCycleRelative } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(dateTime, billingCycleRelative) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(dateTime, billingCycleRelative) override fun toString(): String = when { @@ -6156,12 +6289,15 @@ private constructor( return true } - return /* spotless:off */ other is FixedFeeQuantityTransition && effectiveDate == other.effectiveDate && quantity == other.quantity && additionalProperties == other.additionalProperties /* spotless:on */ + return other is FixedFeeQuantityTransition && + effectiveDate == other.effectiveDate && + quantity == other.quantity && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(effectiveDate, quantity, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash(effectiveDate, quantity, additionalProperties) + } override fun hashCode(): Int = hashCode @@ -6258,10 +6394,12 @@ private constructor( return true } - return /* spotless:off */ other is StartDate && dateTime == other.dateTime && billingCycleRelative == other.billingCycleRelative /* spotless:on */ + return other is StartDate && + dateTime == other.dateTime && + billingCycleRelative == other.billingCycleRelative } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(dateTime, billingCycleRelative) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(dateTime, billingCycleRelative) override fun toString(): String = when { @@ -6357,12 +6495,29 @@ private constructor( return true } - return /* spotless:off */ other is Edit && priceIntervalId == other.priceIntervalId && billingCycleDay == other.billingCycleDay && endDate == other.endDate && filter == other.filter && fixedFeeQuantityTransitions == other.fixedFeeQuantityTransitions && startDate == other.startDate && usageCustomerIds == other.usageCustomerIds && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Edit && + priceIntervalId == other.priceIntervalId && + billingCycleDay == other.billingCycleDay && + endDate == other.endDate && + filter == other.filter && + fixedFeeQuantityTransitions == other.fixedFeeQuantityTransitions && + startDate == other.startDate && + usageCustomerIds == other.usageCustomerIds && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(priceIntervalId, billingCycleDay, endDate, filter, fixedFeeQuantityTransitions, startDate, usageCustomerIds, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + priceIntervalId, + billingCycleDay, + endDate, + filter, + fixedFeeQuantityTransitions, + startDate, + usageCustomerIds, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode @@ -6710,10 +6865,12 @@ private constructor( return true } - return /* spotless:off */ other is EndDate && dateTime == other.dateTime && billingCycleRelative == other.billingCycleRelative /* spotless:on */ + return other is EndDate && + dateTime == other.dateTime && + billingCycleRelative == other.billingCycleRelative } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(dateTime, billingCycleRelative) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(dateTime, billingCycleRelative) override fun toString(): String = when { @@ -6893,10 +7050,12 @@ private constructor( return true } - return /* spotless:off */ other is StartDate && dateTime == other.dateTime && billingCycleRelative == other.billingCycleRelative /* spotless:on */ + return other is StartDate && + dateTime == other.dateTime && + billingCycleRelative == other.billingCycleRelative } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(dateTime, billingCycleRelative) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(dateTime, billingCycleRelative) override fun toString(): String = when { @@ -6992,12 +7151,16 @@ private constructor( return true } - return /* spotless:off */ other is EditAdjustment && adjustmentIntervalId == other.adjustmentIntervalId && endDate == other.endDate && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ + return other is EditAdjustment && + adjustmentIntervalId == other.adjustmentIntervalId && + endDate == other.endDate && + startDate == other.startDate && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(adjustmentIntervalId, endDate, startDate, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash(adjustmentIntervalId, endDate, startDate, additionalProperties) + } override fun hashCode(): Int = hashCode @@ -7010,10 +7173,15 @@ private constructor( return true } - return /* spotless:off */ other is SubscriptionPriceIntervalsParams && subscriptionId == other.subscriptionId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return other is SubscriptionPriceIntervalsParams && + subscriptionId == other.subscriptionId && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(subscriptionId, body, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash(subscriptionId, body, additionalHeaders, additionalQueryParams) override fun toString() = "SubscriptionPriceIntervalsParams{subscriptionId=$subscriptionId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionRedeemCouponParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionRedeemCouponParams.kt index 28eebd84e..4d9141ea5 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionRedeemCouponParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionRedeemCouponParams.kt @@ -736,13 +736,26 @@ private constructor( return true } - return /* spotless:off */ other is Body && changeOption == other.changeOption && allowInvoiceCreditOrVoid == other.allowInvoiceCreditOrVoid && changeDate == other.changeDate && couponId == other.couponId && couponRedemptionCode == other.couponRedemptionCode && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Body && + changeOption == other.changeOption && + allowInvoiceCreditOrVoid == other.allowInvoiceCreditOrVoid && + changeDate == other.changeDate && + couponId == other.couponId && + couponRedemptionCode == other.couponRedemptionCode && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + changeOption, + allowInvoiceCreditOrVoid, + changeDate, + couponId, + couponRedemptionCode, + additionalProperties, + ) } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(changeOption, allowInvoiceCreditOrVoid, changeDate, couponId, couponRedemptionCode, additionalProperties) } - /* spotless:on */ - override fun hashCode(): Int = hashCode override fun toString() = @@ -874,7 +887,7 @@ private constructor( return true } - return /* spotless:off */ other is ChangeOption && value == other.value /* spotless:on */ + return other is ChangeOption && value == other.value } override fun hashCode() = value.hashCode() @@ -887,10 +900,15 @@ private constructor( return true } - return /* spotless:off */ other is SubscriptionRedeemCouponParams && subscriptionId == other.subscriptionId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return other is SubscriptionRedeemCouponParams && + subscriptionId == other.subscriptionId && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(subscriptionId, body, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash(subscriptionId, body, additionalHeaders, additionalQueryParams) override fun toString() = "SubscriptionRedeemCouponParams{subscriptionId=$subscriptionId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionSchedulePlanChangeParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionSchedulePlanChangeParams.kt index dc69f8776..018a0602b 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionSchedulePlanChangeParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionSchedulePlanChangeParams.kt @@ -2917,12 +2917,67 @@ private constructor( return true } - return /* spotless:off */ other is Body && changeOption == other.changeOption && addAdjustments == other.addAdjustments && addPrices == other.addPrices && alignBillingWithPlanChangeDate == other.alignBillingWithPlanChangeDate && autoCollection == other.autoCollection && billingCycleAlignment == other.billingCycleAlignment && billingCycleAnchorConfiguration == other.billingCycleAnchorConfiguration && changeDate == other.changeDate && couponRedemptionCode == other.couponRedemptionCode && creditsOverageRate == other.creditsOverageRate && defaultInvoiceMemo == other.defaultInvoiceMemo && externalPlanId == other.externalPlanId && filter == other.filter && initialPhaseOrder == other.initialPhaseOrder && invoicingThreshold == other.invoicingThreshold && netTerms == other.netTerms && perCreditOverageAmount == other.perCreditOverageAmount && planId == other.planId && planVersionNumber == other.planVersionNumber && priceOverrides == other.priceOverrides && removeAdjustments == other.removeAdjustments && removePrices == other.removePrices && replaceAdjustments == other.replaceAdjustments && replacePrices == other.replacePrices && trialDurationDays == other.trialDurationDays && usageCustomerIds == other.usageCustomerIds && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Body && + changeOption == other.changeOption && + addAdjustments == other.addAdjustments && + addPrices == other.addPrices && + alignBillingWithPlanChangeDate == other.alignBillingWithPlanChangeDate && + autoCollection == other.autoCollection && + billingCycleAlignment == other.billingCycleAlignment && + billingCycleAnchorConfiguration == other.billingCycleAnchorConfiguration && + changeDate == other.changeDate && + couponRedemptionCode == other.couponRedemptionCode && + creditsOverageRate == other.creditsOverageRate && + defaultInvoiceMemo == other.defaultInvoiceMemo && + externalPlanId == other.externalPlanId && + filter == other.filter && + initialPhaseOrder == other.initialPhaseOrder && + invoicingThreshold == other.invoicingThreshold && + netTerms == other.netTerms && + perCreditOverageAmount == other.perCreditOverageAmount && + planId == other.planId && + planVersionNumber == other.planVersionNumber && + priceOverrides == other.priceOverrides && + removeAdjustments == other.removeAdjustments && + removePrices == other.removePrices && + replaceAdjustments == other.replaceAdjustments && + replacePrices == other.replacePrices && + trialDurationDays == other.trialDurationDays && + usageCustomerIds == other.usageCustomerIds && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(changeOption, addAdjustments, addPrices, alignBillingWithPlanChangeDate, autoCollection, billingCycleAlignment, billingCycleAnchorConfiguration, changeDate, couponRedemptionCode, creditsOverageRate, defaultInvoiceMemo, externalPlanId, filter, initialPhaseOrder, invoicingThreshold, netTerms, perCreditOverageAmount, planId, planVersionNumber, priceOverrides, removeAdjustments, removePrices, replaceAdjustments, replacePrices, trialDurationDays, usageCustomerIds, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + changeOption, + addAdjustments, + addPrices, + alignBillingWithPlanChangeDate, + autoCollection, + billingCycleAlignment, + billingCycleAnchorConfiguration, + changeDate, + couponRedemptionCode, + creditsOverageRate, + defaultInvoiceMemo, + externalPlanId, + filter, + initialPhaseOrder, + invoicingThreshold, + netTerms, + perCreditOverageAmount, + planId, + planVersionNumber, + priceOverrides, + removeAdjustments, + removePrices, + replaceAdjustments, + replacePrices, + trialDurationDays, + usageCustomerIds, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode @@ -3055,7 +3110,7 @@ private constructor( return true } - return /* spotless:off */ other is ChangeOption && value == other.value /* spotless:on */ + return other is ChangeOption && value == other.value } override fun hashCode() = value.hashCode() @@ -3569,10 +3624,16 @@ private constructor( return true } - return /* spotless:off */ other is Adjustment && percentageDiscount == other.percentageDiscount && usageDiscount == other.usageDiscount && amountDiscount == other.amountDiscount && minimum == other.minimum && maximum == other.maximum /* spotless:on */ + return other is Adjustment && + percentageDiscount == other.percentageDiscount && + usageDiscount == other.usageDiscount && + amountDiscount == other.amountDiscount && + minimum == other.minimum && + maximum == other.maximum } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(percentageDiscount, usageDiscount, amountDiscount, minimum, maximum) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash(percentageDiscount, usageDiscount, amountDiscount, minimum, maximum) override fun toString(): String = when { @@ -3697,12 +3758,17 @@ private constructor( return true } - return /* spotless:off */ other is AddAdjustment && adjustment == other.adjustment && endDate == other.endDate && planPhaseOrder == other.planPhaseOrder && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ + return other is AddAdjustment && + adjustment == other.adjustment && + endDate == other.endDate && + planPhaseOrder == other.planPhaseOrder && + startDate == other.startDate && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(adjustment, endDate, planPhaseOrder, startDate, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash(adjustment, endDate, planPhaseOrder, startDate, additionalProperties) + } override fun hashCode(): Int = hashCode @@ -5001,10 +5067,68 @@ private constructor( return true } - return /* spotless:off */ other is Price && unit == other.unit && package_ == other.package_ && matrix == other.matrix && tiered == other.tiered && tieredBps == other.tieredBps && bps == other.bps && bulkBps == other.bulkBps && bulk == other.bulk && thresholdTotalAmount == other.thresholdTotalAmount && tieredPackage == other.tieredPackage && tieredWithMinimum == other.tieredWithMinimum && unitWithPercent == other.unitWithPercent && packageWithAllocation == other.packageWithAllocation && tieredWithProration == other.tieredWithProration && unitWithProration == other.unitWithProration && groupedAllocation == other.groupedAllocation && groupedWithProratedMinimum == other.groupedWithProratedMinimum && bulkWithProration == other.bulkWithProration && scalableMatrixWithUnitPricing == other.scalableMatrixWithUnitPricing && scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && cumulativeGroupedBulk == other.cumulativeGroupedBulk && maxGroupTieredPackage == other.maxGroupTieredPackage && groupedWithMeteredMinimum == other.groupedWithMeteredMinimum && matrixWithDisplayName == other.matrixWithDisplayName && groupedTieredPackage == other.groupedTieredPackage && matrixWithAllocation == other.matrixWithAllocation && tieredPackageWithMinimum == other.tieredPackageWithMinimum && groupedTiered == other.groupedTiered /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, package_, matrix, tiered, tieredBps, bps, bulkBps, bulk, thresholdTotalAmount, tieredPackage, tieredWithMinimum, unitWithPercent, packageWithAllocation, tieredWithProration, unitWithProration, groupedAllocation, groupedWithProratedMinimum, bulkWithProration, scalableMatrixWithUnitPricing, scalableMatrixWithTieredPricing, cumulativeGroupedBulk, maxGroupTieredPackage, groupedWithMeteredMinimum, matrixWithDisplayName, groupedTieredPackage, matrixWithAllocation, tieredPackageWithMinimum, groupedTiered) /* spotless:on */ + return other is Price && + unit == other.unit && + package_ == other.package_ && + matrix == other.matrix && + tiered == other.tiered && + tieredBps == other.tieredBps && + bps == other.bps && + bulkBps == other.bulkBps && + bulk == other.bulk && + thresholdTotalAmount == other.thresholdTotalAmount && + tieredPackage == other.tieredPackage && + tieredWithMinimum == other.tieredWithMinimum && + unitWithPercent == other.unitWithPercent && + packageWithAllocation == other.packageWithAllocation && + tieredWithProration == other.tieredWithProration && + unitWithProration == other.unitWithProration && + groupedAllocation == other.groupedAllocation && + groupedWithProratedMinimum == other.groupedWithProratedMinimum && + bulkWithProration == other.bulkWithProration && + scalableMatrixWithUnitPricing == other.scalableMatrixWithUnitPricing && + scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && + cumulativeGroupedBulk == other.cumulativeGroupedBulk && + maxGroupTieredPackage == other.maxGroupTieredPackage && + groupedWithMeteredMinimum == other.groupedWithMeteredMinimum && + matrixWithDisplayName == other.matrixWithDisplayName && + groupedTieredPackage == other.groupedTieredPackage && + matrixWithAllocation == other.matrixWithAllocation && + tieredPackageWithMinimum == other.tieredPackageWithMinimum && + groupedTiered == other.groupedTiered + } + + override fun hashCode(): Int = + Objects.hash( + unit, + package_, + matrix, + tiered, + tieredBps, + bps, + bulkBps, + bulk, + thresholdTotalAmount, + tieredPackage, + tieredWithMinimum, + unitWithPercent, + packageWithAllocation, + tieredWithProration, + unitWithProration, + groupedAllocation, + groupedWithProratedMinimum, + bulkWithProration, + scalableMatrixWithUnitPricing, + scalableMatrixWithTieredPricing, + cumulativeGroupedBulk, + maxGroupTieredPackage, + groupedWithMeteredMinimum, + matrixWithDisplayName, + groupedTieredPackage, + matrixWithAllocation, + tieredPackageWithMinimum, + groupedTiered, + ) override fun toString(): String = when { @@ -5547,12 +5671,35 @@ private constructor( return true } - return /* spotless:off */ other is AddPrice && allocationPrice == other.allocationPrice && discounts == other.discounts && endDate == other.endDate && externalPriceId == other.externalPriceId && maximumAmount == other.maximumAmount && minimumAmount == other.minimumAmount && planPhaseOrder == other.planPhaseOrder && price == other.price && priceId == other.priceId && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ + return other is AddPrice && + allocationPrice == other.allocationPrice && + discounts == other.discounts && + endDate == other.endDate && + externalPriceId == other.externalPriceId && + maximumAmount == other.maximumAmount && + minimumAmount == other.minimumAmount && + planPhaseOrder == other.planPhaseOrder && + price == other.price && + priceId == other.priceId && + startDate == other.startDate && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(allocationPrice, discounts, endDate, externalPriceId, maximumAmount, minimumAmount, planPhaseOrder, price, priceId, startDate, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + allocationPrice, + discounts, + endDate, + externalPriceId, + maximumAmount, + minimumAmount, + planPhaseOrder, + price, + priceId, + startDate, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode @@ -5692,7 +5839,7 @@ private constructor( return true } - return /* spotless:off */ other is BillingCycleAlignment && value == other.value /* spotless:on */ + return other is BillingCycleAlignment && value == other.value } override fun hashCode() = value.hashCode() @@ -5851,12 +5998,12 @@ private constructor( return true } - return /* spotless:off */ other is RemoveAdjustment && adjustmentId == other.adjustmentId && additionalProperties == other.additionalProperties /* spotless:on */ + return other is RemoveAdjustment && + adjustmentId == other.adjustmentId && + additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(adjustmentId, additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -6033,12 +6180,15 @@ private constructor( return true } - return /* spotless:off */ other is RemovePrice && externalPriceId == other.externalPriceId && priceId == other.priceId && additionalProperties == other.additionalProperties /* spotless:on */ + return other is RemovePrice && + externalPriceId == other.externalPriceId && + priceId == other.priceId && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(externalPriceId, priceId, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash(externalPriceId, priceId, additionalProperties) + } override fun hashCode(): Int = hashCode @@ -6460,10 +6610,16 @@ private constructor( return true } - return /* spotless:off */ other is Adjustment && percentageDiscount == other.percentageDiscount && usageDiscount == other.usageDiscount && amountDiscount == other.amountDiscount && minimum == other.minimum && maximum == other.maximum /* spotless:on */ + return other is Adjustment && + percentageDiscount == other.percentageDiscount && + usageDiscount == other.usageDiscount && + amountDiscount == other.amountDiscount && + minimum == other.minimum && + maximum == other.maximum } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(percentageDiscount, usageDiscount, amountDiscount, minimum, maximum) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash(percentageDiscount, usageDiscount, amountDiscount, minimum, maximum) override fun toString(): String = when { @@ -6588,12 +6744,15 @@ private constructor( return true } - return /* spotless:off */ other is ReplaceAdjustment && adjustment == other.adjustment && replacesAdjustmentId == other.replacesAdjustmentId && additionalProperties == other.additionalProperties /* spotless:on */ + return other is ReplaceAdjustment && + adjustment == other.adjustment && + replacesAdjustmentId == other.replacesAdjustmentId && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(adjustment, replacesAdjustmentId, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash(adjustment, replacesAdjustmentId, additionalProperties) + } override fun hashCode(): Int = hashCode @@ -7862,10 +8021,68 @@ private constructor( return true } - return /* spotless:off */ other is Price && unit == other.unit && package_ == other.package_ && matrix == other.matrix && tiered == other.tiered && tieredBps == other.tieredBps && bps == other.bps && bulkBps == other.bulkBps && bulk == other.bulk && thresholdTotalAmount == other.thresholdTotalAmount && tieredPackage == other.tieredPackage && tieredWithMinimum == other.tieredWithMinimum && unitWithPercent == other.unitWithPercent && packageWithAllocation == other.packageWithAllocation && tieredWithProration == other.tieredWithProration && unitWithProration == other.unitWithProration && groupedAllocation == other.groupedAllocation && groupedWithProratedMinimum == other.groupedWithProratedMinimum && bulkWithProration == other.bulkWithProration && scalableMatrixWithUnitPricing == other.scalableMatrixWithUnitPricing && scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && cumulativeGroupedBulk == other.cumulativeGroupedBulk && maxGroupTieredPackage == other.maxGroupTieredPackage && groupedWithMeteredMinimum == other.groupedWithMeteredMinimum && matrixWithDisplayName == other.matrixWithDisplayName && groupedTieredPackage == other.groupedTieredPackage && matrixWithAllocation == other.matrixWithAllocation && tieredPackageWithMinimum == other.tieredPackageWithMinimum && groupedTiered == other.groupedTiered /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, package_, matrix, tiered, tieredBps, bps, bulkBps, bulk, thresholdTotalAmount, tieredPackage, tieredWithMinimum, unitWithPercent, packageWithAllocation, tieredWithProration, unitWithProration, groupedAllocation, groupedWithProratedMinimum, bulkWithProration, scalableMatrixWithUnitPricing, scalableMatrixWithTieredPricing, cumulativeGroupedBulk, maxGroupTieredPackage, groupedWithMeteredMinimum, matrixWithDisplayName, groupedTieredPackage, matrixWithAllocation, tieredPackageWithMinimum, groupedTiered) /* spotless:on */ + return other is Price && + unit == other.unit && + package_ == other.package_ && + matrix == other.matrix && + tiered == other.tiered && + tieredBps == other.tieredBps && + bps == other.bps && + bulkBps == other.bulkBps && + bulk == other.bulk && + thresholdTotalAmount == other.thresholdTotalAmount && + tieredPackage == other.tieredPackage && + tieredWithMinimum == other.tieredWithMinimum && + unitWithPercent == other.unitWithPercent && + packageWithAllocation == other.packageWithAllocation && + tieredWithProration == other.tieredWithProration && + unitWithProration == other.unitWithProration && + groupedAllocation == other.groupedAllocation && + groupedWithProratedMinimum == other.groupedWithProratedMinimum && + bulkWithProration == other.bulkWithProration && + scalableMatrixWithUnitPricing == other.scalableMatrixWithUnitPricing && + scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && + cumulativeGroupedBulk == other.cumulativeGroupedBulk && + maxGroupTieredPackage == other.maxGroupTieredPackage && + groupedWithMeteredMinimum == other.groupedWithMeteredMinimum && + matrixWithDisplayName == other.matrixWithDisplayName && + groupedTieredPackage == other.groupedTieredPackage && + matrixWithAllocation == other.matrixWithAllocation && + tieredPackageWithMinimum == other.tieredPackageWithMinimum && + groupedTiered == other.groupedTiered + } + + override fun hashCode(): Int = + Objects.hash( + unit, + package_, + matrix, + tiered, + tieredBps, + bps, + bulkBps, + bulk, + thresholdTotalAmount, + tieredPackage, + tieredWithMinimum, + unitWithPercent, + packageWithAllocation, + tieredWithProration, + unitWithProration, + groupedAllocation, + groupedWithProratedMinimum, + bulkWithProration, + scalableMatrixWithUnitPricing, + scalableMatrixWithTieredPricing, + cumulativeGroupedBulk, + maxGroupTieredPackage, + groupedWithMeteredMinimum, + matrixWithDisplayName, + groupedTieredPackage, + matrixWithAllocation, + tieredPackageWithMinimum, + groupedTiered, + ) override fun toString(): String = when { @@ -8408,12 +8625,33 @@ private constructor( return true } - return /* spotless:off */ other is ReplacePrice && replacesPriceId == other.replacesPriceId && allocationPrice == other.allocationPrice && discounts == other.discounts && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && maximumAmount == other.maximumAmount && minimumAmount == other.minimumAmount && price == other.price && priceId == other.priceId && additionalProperties == other.additionalProperties /* spotless:on */ + return other is ReplacePrice && + replacesPriceId == other.replacesPriceId && + allocationPrice == other.allocationPrice && + discounts == other.discounts && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + maximumAmount == other.maximumAmount && + minimumAmount == other.minimumAmount && + price == other.price && + priceId == other.priceId && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(replacesPriceId, allocationPrice, discounts, externalPriceId, fixedPriceQuantity, maximumAmount, minimumAmount, price, priceId, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + replacesPriceId, + allocationPrice, + discounts, + externalPriceId, + fixedPriceQuantity, + maximumAmount, + minimumAmount, + price, + priceId, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode @@ -8426,10 +8664,15 @@ private constructor( return true } - return /* spotless:off */ other is SubscriptionSchedulePlanChangeParams && subscriptionId == other.subscriptionId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return other is SubscriptionSchedulePlanChangeParams && + subscriptionId == other.subscriptionId && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(subscriptionId, body, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash(subscriptionId, body, additionalHeaders, additionalQueryParams) override fun toString() = "SubscriptionSchedulePlanChangeParams{subscriptionId=$subscriptionId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionTrialInfo.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionTrialInfo.kt index 0b3f517a6..ba59760f7 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionTrialInfo.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionTrialInfo.kt @@ -158,12 +158,12 @@ private constructor( return true } - return /* spotless:off */ other is SubscriptionTrialInfo && endDate == other.endDate && additionalProperties == other.additionalProperties /* spotless:on */ + return other is SubscriptionTrialInfo && + endDate == other.endDate && + additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(endDate, additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionTriggerPhaseParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionTriggerPhaseParams.kt index 4f94f92fd..7500185ab 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionTriggerPhaseParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionTriggerPhaseParams.kt @@ -495,12 +495,15 @@ private constructor( return true } - return /* spotless:off */ other is Body && allowInvoiceCreditOrVoid == other.allowInvoiceCreditOrVoid && effectiveDate == other.effectiveDate && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Body && + allowInvoiceCreditOrVoid == other.allowInvoiceCreditOrVoid && + effectiveDate == other.effectiveDate && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(allowInvoiceCreditOrVoid, effectiveDate, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash(allowInvoiceCreditOrVoid, effectiveDate, additionalProperties) + } override fun hashCode(): Int = hashCode @@ -513,10 +516,15 @@ private constructor( return true } - return /* spotless:off */ other is SubscriptionTriggerPhaseParams && subscriptionId == other.subscriptionId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return other is SubscriptionTriggerPhaseParams && + subscriptionId == other.subscriptionId && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(subscriptionId, body, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash(subscriptionId, body, additionalHeaders, additionalQueryParams) override fun toString() = "SubscriptionTriggerPhaseParams{subscriptionId=$subscriptionId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionUnscheduleCancellationParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionUnscheduleCancellationParams.kt index 2b0176c8b..b956b9b28 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionUnscheduleCancellationParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionUnscheduleCancellationParams.kt @@ -221,10 +221,20 @@ private constructor( return true } - return /* spotless:off */ other is SubscriptionUnscheduleCancellationParams && subscriptionId == other.subscriptionId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return other is SubscriptionUnscheduleCancellationParams && + subscriptionId == other.subscriptionId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(subscriptionId, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash( + subscriptionId, + additionalHeaders, + additionalQueryParams, + additionalBodyProperties, + ) override fun toString() = "SubscriptionUnscheduleCancellationParams{subscriptionId=$subscriptionId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionUnscheduleFixedFeeQuantityUpdatesParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionUnscheduleFixedFeeQuantityUpdatesParams.kt index 181d72d21..ca0b4a719 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionUnscheduleFixedFeeQuantityUpdatesParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionUnscheduleFixedFeeQuantityUpdatesParams.kt @@ -407,12 +407,12 @@ private constructor( return true } - return /* spotless:off */ other is Body && priceId == other.priceId && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Body && + priceId == other.priceId && + additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(priceId, additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -425,10 +425,15 @@ private constructor( return true } - return /* spotless:off */ other is SubscriptionUnscheduleFixedFeeQuantityUpdatesParams && subscriptionId == other.subscriptionId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return other is SubscriptionUnscheduleFixedFeeQuantityUpdatesParams && + subscriptionId == other.subscriptionId && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(subscriptionId, body, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash(subscriptionId, body, additionalHeaders, additionalQueryParams) override fun toString() = "SubscriptionUnscheduleFixedFeeQuantityUpdatesParams{subscriptionId=$subscriptionId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionUnschedulePendingPlanChangesParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionUnschedulePendingPlanChangesParams.kt index 4afad67ff..37af8f2a7 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionUnschedulePendingPlanChangesParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionUnschedulePendingPlanChangesParams.kt @@ -220,10 +220,20 @@ private constructor( return true } - return /* spotless:off */ other is SubscriptionUnschedulePendingPlanChangesParams && subscriptionId == other.subscriptionId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return other is SubscriptionUnschedulePendingPlanChangesParams && + subscriptionId == other.subscriptionId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(subscriptionId, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash( + subscriptionId, + additionalHeaders, + additionalQueryParams, + additionalBodyProperties, + ) override fun toString() = "SubscriptionUnschedulePendingPlanChangesParams{subscriptionId=$subscriptionId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionUpdateFixedFeeQuantityParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionUpdateFixedFeeQuantityParams.kt index ae6df52d5..6fd2f305f 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionUpdateFixedFeeQuantityParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionUpdateFixedFeeQuantityParams.kt @@ -759,13 +759,26 @@ private constructor( return true } - return /* spotless:off */ other is Body && priceId == other.priceId && quantity == other.quantity && allowInvoiceCreditOrVoid == other.allowInvoiceCreditOrVoid && changeOption == other.changeOption && effectiveDate == other.effectiveDate && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Body && + priceId == other.priceId && + quantity == other.quantity && + allowInvoiceCreditOrVoid == other.allowInvoiceCreditOrVoid && + changeOption == other.changeOption && + effectiveDate == other.effectiveDate && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + priceId, + quantity, + allowInvoiceCreditOrVoid, + changeOption, + effectiveDate, + additionalProperties, + ) } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(priceId, quantity, allowInvoiceCreditOrVoid, changeOption, effectiveDate, additionalProperties) } - /* spotless:on */ - override fun hashCode(): Int = hashCode override fun toString() = @@ -902,7 +915,7 @@ private constructor( return true } - return /* spotless:off */ other is ChangeOption && value == other.value /* spotless:on */ + return other is ChangeOption && value == other.value } override fun hashCode() = value.hashCode() @@ -915,10 +928,15 @@ private constructor( return true } - return /* spotless:off */ other is SubscriptionUpdateFixedFeeQuantityParams && subscriptionId == other.subscriptionId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return other is SubscriptionUpdateFixedFeeQuantityParams && + subscriptionId == other.subscriptionId && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(subscriptionId, body, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash(subscriptionId, body, additionalHeaders, additionalQueryParams) override fun toString() = "SubscriptionUpdateFixedFeeQuantityParams{subscriptionId=$subscriptionId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionUpdateParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionUpdateParams.kt index e7f2475b4..200c4a543 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionUpdateParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionUpdateParams.kt @@ -754,13 +754,26 @@ private constructor( return true } - return /* spotless:off */ other is Body && autoCollection == other.autoCollection && defaultInvoiceMemo == other.defaultInvoiceMemo && invoicingThreshold == other.invoicingThreshold && metadata == other.metadata && netTerms == other.netTerms && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Body && + autoCollection == other.autoCollection && + defaultInvoiceMemo == other.defaultInvoiceMemo && + invoicingThreshold == other.invoicingThreshold && + metadata == other.metadata && + netTerms == other.netTerms && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + autoCollection, + defaultInvoiceMemo, + invoicingThreshold, + metadata, + netTerms, + additionalProperties, + ) } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(autoCollection, defaultInvoiceMemo, invoicingThreshold, metadata, netTerms, additionalProperties) } - /* spotless:on */ - override fun hashCode(): Int = hashCode override fun toString() = @@ -859,12 +872,10 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -876,10 +887,15 @@ private constructor( return true } - return /* spotless:off */ other is SubscriptionUpdateParams && subscriptionId == other.subscriptionId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return other is SubscriptionUpdateParams && + subscriptionId == other.subscriptionId && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(subscriptionId, body, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash(subscriptionId, body, additionalHeaders, additionalQueryParams) override fun toString() = "SubscriptionUpdateParams{subscriptionId=$subscriptionId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionUpdateTrialParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionUpdateTrialParams.kt index ed565f827..fdde9ae03 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionUpdateTrialParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionUpdateTrialParams.kt @@ -541,12 +541,15 @@ private constructor( return true } - return /* spotless:off */ other is Body && trialEndDate == other.trialEndDate && shift == other.shift && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Body && + trialEndDate == other.trialEndDate && + shift == other.shift && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(trialEndDate, shift, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash(trialEndDate, shift, additionalProperties) + } override fun hashCode(): Int = hashCode @@ -638,10 +641,12 @@ private constructor( return true } - return /* spotless:off */ other is TrialEndDate && offsetDateTime == other.offsetDateTime && unionMember1 == other.unionMember1 /* spotless:on */ + return other is TrialEndDate && + offsetDateTime == other.offsetDateTime && + unionMember1 == other.unionMember1 } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(offsetDateTime, unionMember1) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(offsetDateTime, unionMember1) override fun toString(): String = when { @@ -846,7 +851,7 @@ private constructor( return true } - return /* spotless:off */ other is UnionMember1 && value == other.value /* spotless:on */ + return other is UnionMember1 && value == other.value } override fun hashCode() = value.hashCode() @@ -860,10 +865,15 @@ private constructor( return true } - return /* spotless:off */ other is SubscriptionUpdateTrialParams && subscriptionId == other.subscriptionId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return other is SubscriptionUpdateTrialParams && + subscriptionId == other.subscriptionId && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(subscriptionId, body, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash(subscriptionId, body, additionalHeaders, additionalQueryParams) override fun toString() = "SubscriptionUpdateTrialParams{subscriptionId=$subscriptionId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionUsage.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionUsage.kt index d92e4d587..90290ccaa 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionUsage.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionUsage.kt @@ -111,10 +111,12 @@ private constructor( return true } - return /* spotless:off */ other is SubscriptionUsage && ungrouped == other.ungrouped && grouped == other.grouped /* spotless:on */ + return other is SubscriptionUsage && + ungrouped == other.ungrouped && + grouped == other.grouped } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(ungrouped, grouped) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(ungrouped, grouped) override fun toString(): String = when { @@ -772,12 +774,13 @@ private constructor( return true } - return /* spotless:off */ other is BillableMetric && id == other.id && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ + return other is BillableMetric && + id == other.id && + name == other.name && + additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(id, name, additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1020,12 +1023,16 @@ private constructor( return true } - return /* spotless:off */ other is Usage && quantity == other.quantity && timeframeEnd == other.timeframeEnd && timeframeStart == other.timeframeStart && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Usage && + quantity == other.quantity && + timeframeEnd == other.timeframeEnd && + timeframeStart == other.timeframeStart && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(quantity, timeframeEnd, timeframeStart, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash(quantity, timeframeEnd, timeframeStart, additionalProperties) + } override fun hashCode(): Int = hashCode @@ -1154,7 +1161,7 @@ private constructor( return true } - return /* spotless:off */ other is ViewMode && value == other.value /* spotless:on */ + return other is ViewMode && value == other.value } override fun hashCode() = value.hashCode() @@ -1167,12 +1174,16 @@ private constructor( return true } - return /* spotless:off */ other is Data && billableMetric == other.billableMetric && usage == other.usage && viewMode == other.viewMode && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Data && + billableMetric == other.billableMetric && + usage == other.usage && + viewMode == other.viewMode && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(billableMetric, usage, viewMode, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash(billableMetric, usage, viewMode, additionalProperties) + } override fun hashCode(): Int = hashCode @@ -1185,12 +1196,12 @@ private constructor( return true } - return /* spotless:off */ other is UngroupedSubscriptionUsage && data == other.data && additionalProperties == other.additionalProperties /* spotless:on */ + return other is UngroupedSubscriptionUsage && + data == other.data && + additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(data, additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1848,12 +1859,13 @@ private constructor( return true } - return /* spotless:off */ other is BillableMetric && id == other.id && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ + return other is BillableMetric && + id == other.id && + name == other.name && + additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(id, name, additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -2056,12 +2068,15 @@ private constructor( return true } - return /* spotless:off */ other is MetricGroup && propertyKey == other.propertyKey && propertyValue == other.propertyValue && additionalProperties == other.additionalProperties /* spotless:on */ + return other is MetricGroup && + propertyKey == other.propertyKey && + propertyValue == other.propertyValue && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(propertyKey, propertyValue, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash(propertyKey, propertyValue, additionalProperties) + } override fun hashCode(): Int = hashCode @@ -2304,12 +2319,16 @@ private constructor( return true } - return /* spotless:off */ other is Usage && quantity == other.quantity && timeframeEnd == other.timeframeEnd && timeframeStart == other.timeframeStart && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Usage && + quantity == other.quantity && + timeframeEnd == other.timeframeEnd && + timeframeStart == other.timeframeStart && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(quantity, timeframeEnd, timeframeStart, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash(quantity, timeframeEnd, timeframeStart, additionalProperties) + } override fun hashCode(): Int = hashCode @@ -2438,7 +2457,7 @@ private constructor( return true } - return /* spotless:off */ other is ViewMode && value == other.value /* spotless:on */ + return other is ViewMode && value == other.value } override fun hashCode() = value.hashCode() @@ -2451,12 +2470,17 @@ private constructor( return true } - return /* spotless:off */ other is Data && billableMetric == other.billableMetric && metricGroup == other.metricGroup && usage == other.usage && viewMode == other.viewMode && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Data && + billableMetric == other.billableMetric && + metricGroup == other.metricGroup && + usage == other.usage && + viewMode == other.viewMode && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(billableMetric, metricGroup, usage, viewMode, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash(billableMetric, metricGroup, usage, viewMode, additionalProperties) + } override fun hashCode(): Int = hashCode @@ -2469,12 +2493,15 @@ private constructor( return true } - return /* spotless:off */ other is GroupedSubscriptionUsage && data == other.data && paginationMetadata == other.paginationMetadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is GroupedSubscriptionUsage && + data == other.data && + paginationMetadata == other.paginationMetadata && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(data, paginationMetadata, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash(data, paginationMetadata, additionalProperties) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Subscriptions.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Subscriptions.kt index 399ea5b05..66a15fdb9 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Subscriptions.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Subscriptions.kt @@ -216,12 +216,15 @@ private constructor( return true } - return /* spotless:off */ other is Subscriptions && data == other.data && paginationMetadata == other.paginationMetadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Subscriptions && + data == other.data && + paginationMetadata == other.paginationMetadata && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(data, paginationMetadata, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash(data, paginationMetadata, additionalProperties) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/TaxAmount.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/TaxAmount.kt index 64a24bf74..76025a6fd 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/TaxAmount.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/TaxAmount.kt @@ -246,12 +246,16 @@ private constructor( return true } - return /* spotless:off */ other is TaxAmount && amount == other.amount && taxRateDescription == other.taxRateDescription && taxRatePercentage == other.taxRatePercentage && additionalProperties == other.additionalProperties /* spotless:on */ + return other is TaxAmount && + amount == other.amount && + taxRateDescription == other.taxRateDescription && + taxRatePercentage == other.taxRatePercentage && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(amount, taxRateDescription, taxRatePercentage, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash(amount, taxRateDescription, taxRatePercentage, additionalProperties) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Threshold.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Threshold.kt index 3b4c7853b..7ea71ba27 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Threshold.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Threshold.kt @@ -160,12 +160,12 @@ private constructor( return true } - return /* spotless:off */ other is Threshold && value == other.value && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Threshold && + value == other.value && + additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(value, additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Tier.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Tier.kt index 1aeee742f..87680845d 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Tier.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Tier.kt @@ -237,12 +237,16 @@ private constructor( return true } - return /* spotless:off */ other is Tier && firstUnit == other.firstUnit && unitAmount == other.unitAmount && lastUnit == other.lastUnit && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Tier && + firstUnit == other.firstUnit && + unitAmount == other.unitAmount && + lastUnit == other.lastUnit && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(firstUnit, unitAmount, lastUnit, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash(firstUnit, unitAmount, lastUnit, additionalProperties) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/TierConfig.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/TierConfig.kt index a331ed3f7..9e9448b13 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/TierConfig.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/TierConfig.kt @@ -230,12 +230,16 @@ private constructor( return true } - return /* spotless:off */ other is TierConfig && firstUnit == other.firstUnit && lastUnit == other.lastUnit && unitAmount == other.unitAmount && additionalProperties == other.additionalProperties /* spotless:on */ + return other is TierConfig && + firstUnit == other.firstUnit && + lastUnit == other.lastUnit && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(firstUnit, lastUnit, unitAmount, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash(firstUnit, lastUnit, unitAmount, additionalProperties) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/TierSubLineItem.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/TierSubLineItem.kt index 05b1a9ede..b69858b8c 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/TierSubLineItem.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/TierSubLineItem.kt @@ -434,7 +434,7 @@ private constructor( return true } - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + return other is Type && value == other.value } override fun hashCode() = value.hashCode() @@ -447,12 +447,19 @@ private constructor( return true } - return /* spotless:off */ other is TierSubLineItem && amount == other.amount && grouping == other.grouping && name == other.name && quantity == other.quantity && tierConfig == other.tierConfig && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return other is TierSubLineItem && + amount == other.amount && + grouping == other.grouping && + name == other.name && + quantity == other.quantity && + tierConfig == other.tierConfig && + type == other.type && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(amount, grouping, name, quantity, tierConfig, type, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash(amount, grouping, name, quantity, tierConfig, type, additionalProperties) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/TieredBpsConfig.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/TieredBpsConfig.kt index d71fdf064..4e80e5049 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/TieredBpsConfig.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/TieredBpsConfig.kt @@ -172,12 +172,12 @@ private constructor( return true } - return /* spotless:off */ other is TieredBpsConfig && tiers == other.tiers && additionalProperties == other.additionalProperties /* spotless:on */ + return other is TieredBpsConfig && + tiers == other.tiers && + additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(tiers, additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/TieredConfig.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/TieredConfig.kt index 030f133bf..3e91cf412 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/TieredConfig.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/TieredConfig.kt @@ -172,12 +172,12 @@ private constructor( return true } - return /* spotless:off */ other is TieredConfig && tiers == other.tiers && additionalProperties == other.additionalProperties /* spotless:on */ + return other is TieredConfig && + tiers == other.tiers && + additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(tiers, additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/TieredConversionRateConfig.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/TieredConversionRateConfig.kt index 8af22ee18..cdfaa4420 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/TieredConversionRateConfig.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/TieredConversionRateConfig.kt @@ -315,7 +315,7 @@ private constructor( return true } - return /* spotless:off */ other is ConversionRateType && value == other.value /* spotless:on */ + return other is ConversionRateType && value == other.value } override fun hashCode() = value.hashCode() @@ -328,12 +328,15 @@ private constructor( return true } - return /* spotless:off */ other is TieredConversionRateConfig && conversionRateType == other.conversionRateType && tieredConfig == other.tieredConfig && additionalProperties == other.additionalProperties /* spotless:on */ + return other is TieredConversionRateConfig && + conversionRateType == other.conversionRateType && + tieredConfig == other.tieredConfig && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(conversionRateType, tieredConfig, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash(conversionRateType, tieredConfig, additionalProperties) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/TopLevelPingParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/TopLevelPingParams.kt index 8c5904188..954802fdd 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/TopLevelPingParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/TopLevelPingParams.kt @@ -163,10 +163,12 @@ private constructor( return true } - return /* spotless:off */ other is TopLevelPingParams && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return other is TopLevelPingParams && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(additionalHeaders, additionalQueryParams) override fun toString() = "TopLevelPingParams{additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/TopLevelPingResponse.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/TopLevelPingResponse.kt index 68145b423..5d0ef4811 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/TopLevelPingResponse.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/TopLevelPingResponse.kt @@ -154,12 +154,12 @@ private constructor( return true } - return /* spotless:off */ other is TopLevelPingResponse && response == other.response && additionalProperties == other.additionalProperties /* spotless:on */ + return other is TopLevelPingResponse && + response == other.response && + additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(response, additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/TopUpInvoiceSettings.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/TopUpInvoiceSettings.kt index 9be36f269..f0f83be14 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/TopUpInvoiceSettings.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/TopUpInvoiceSettings.kt @@ -290,12 +290,17 @@ private constructor( return true } - return /* spotless:off */ other is TopUpInvoiceSettings && autoCollection == other.autoCollection && netTerms == other.netTerms && memo == other.memo && requireSuccessfulPayment == other.requireSuccessfulPayment && additionalProperties == other.additionalProperties /* spotless:on */ + return other is TopUpInvoiceSettings && + autoCollection == other.autoCollection && + netTerms == other.netTerms && + memo == other.memo && + requireSuccessfulPayment == other.requireSuccessfulPayment && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(autoCollection, netTerms, memo, requireSuccessfulPayment, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash(autoCollection, netTerms, memo, requireSuccessfulPayment, additionalProperties) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/TransformPriceFilter.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/TransformPriceFilter.kt index c179d5c2f..18b88e1d7 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/TransformPriceFilter.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/TransformPriceFilter.kt @@ -377,7 +377,7 @@ private constructor( return true } - return /* spotless:off */ other is Field && value == other.value /* spotless:on */ + return other is Field && value == other.value } override fun hashCode() = value.hashCode() @@ -502,7 +502,7 @@ private constructor( return true } - return /* spotless:off */ other is Operator && value == other.value /* spotless:on */ + return other is Operator && value == other.value } override fun hashCode() = value.hashCode() @@ -515,12 +515,16 @@ private constructor( return true } - return /* spotless:off */ other is TransformPriceFilter && field == other.field && operator == other.operator && values == other.values && additionalProperties == other.additionalProperties /* spotless:on */ + return other is TransformPriceFilter && + field == other.field && + operator == other.operator && + values == other.values && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(field, operator, values, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash(field, operator, values, additionalProperties) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/TrialDiscount.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/TrialDiscount.kt index e4d8717da..e4ea852ed 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/TrialDiscount.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/TrialDiscount.kt @@ -514,7 +514,7 @@ private constructor( return true } - return /* spotless:off */ other is DiscountType && value == other.value /* spotless:on */ + return other is DiscountType && value == other.value } override fun hashCode() = value.hashCode() @@ -527,12 +527,27 @@ private constructor( return true } - return /* spotless:off */ other is TrialDiscount && discountType == other.discountType && appliesToPriceIds == other.appliesToPriceIds && filters == other.filters && reason == other.reason && trialAmountDiscount == other.trialAmountDiscount && trialPercentageDiscount == other.trialPercentageDiscount && additionalProperties == other.additionalProperties /* spotless:on */ + return other is TrialDiscount && + discountType == other.discountType && + appliesToPriceIds == other.appliesToPriceIds && + filters == other.filters && + reason == other.reason && + trialAmountDiscount == other.trialAmountDiscount && + trialPercentageDiscount == other.trialPercentageDiscount && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(discountType, appliesToPriceIds, filters, reason, trialAmountDiscount, trialPercentageDiscount, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + discountType, + appliesToPriceIds, + filters, + reason, + trialAmountDiscount, + trialPercentageDiscount, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/UnitConfig.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/UnitConfig.kt index 11d558d38..8de72ac8b 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/UnitConfig.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/UnitConfig.kt @@ -157,12 +157,12 @@ private constructor( return true } - return /* spotless:off */ other is UnitConfig && unitAmount == other.unitAmount && additionalProperties == other.additionalProperties /* spotless:on */ + return other is UnitConfig && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(unitAmount, additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/UnitConversionRateConfig.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/UnitConversionRateConfig.kt index 5e1df6b81..137b5b655 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/UnitConversionRateConfig.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/UnitConversionRateConfig.kt @@ -314,7 +314,7 @@ private constructor( return true } - return /* spotless:off */ other is ConversionRateType && value == other.value /* spotless:on */ + return other is ConversionRateType && value == other.value } override fun hashCode() = value.hashCode() @@ -327,12 +327,15 @@ private constructor( return true } - return /* spotless:off */ other is UnitConversionRateConfig && conversionRateType == other.conversionRateType && unitConfig == other.unitConfig && additionalProperties == other.additionalProperties /* spotless:on */ + return other is UnitConversionRateConfig && + conversionRateType == other.conversionRateType && + unitConfig == other.unitConfig && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(conversionRateType, unitConfig, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash(conversionRateType, unitConfig, additionalProperties) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/UsageDiscount.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/UsageDiscount.kt index 8d51d9793..7a022de7a 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/UsageDiscount.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/UsageDiscount.kt @@ -458,7 +458,7 @@ private constructor( return true } - return /* spotless:off */ other is DiscountType && value == other.value /* spotless:on */ + return other is DiscountType && value == other.value } override fun hashCode() = value.hashCode() @@ -471,12 +471,25 @@ private constructor( return true } - return /* spotless:off */ other is UsageDiscount && discountType == other.discountType && usageDiscount == other.usageDiscount && appliesToPriceIds == other.appliesToPriceIds && filters == other.filters && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ + return other is UsageDiscount && + discountType == other.discountType && + usageDiscount == other.usageDiscount && + appliesToPriceIds == other.appliesToPriceIds && + filters == other.filters && + reason == other.reason && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(discountType, usageDiscount, appliesToPriceIds, filters, reason, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + discountType, + usageDiscount, + appliesToPriceIds, + filters, + reason, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/UsageDiscountInterval.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/UsageDiscountInterval.kt index cc3fc79d3..bb9acdb0c 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/UsageDiscountInterval.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/UsageDiscountInterval.kt @@ -519,7 +519,7 @@ private constructor( return true } - return /* spotless:off */ other is DiscountType && value == other.value /* spotless:on */ + return other is DiscountType && value == other.value } override fun hashCode() = value.hashCode() @@ -532,12 +532,27 @@ private constructor( return true } - return /* spotless:off */ other is UsageDiscountInterval && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && discountType == other.discountType && endDate == other.endDate && filters == other.filters && startDate == other.startDate && usageDiscount == other.usageDiscount && additionalProperties == other.additionalProperties /* spotless:on */ + return other is UsageDiscountInterval && + appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && + discountType == other.discountType && + endDate == other.endDate && + filters == other.filters && + startDate == other.startDate && + usageDiscount == other.usageDiscount && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(appliesToPriceIntervalIds, discountType, endDate, filters, startDate, usageDiscount, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + appliesToPriceIntervalIds, + discountType, + endDate, + filters, + startDate, + usageDiscount, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/VoidInitiatedLedgerEntry.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/VoidInitiatedLedgerEntry.kt index ad9d2a45b..76713a0c3 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/VoidInitiatedLedgerEntry.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/VoidInitiatedLedgerEntry.kt @@ -850,7 +850,7 @@ private constructor( return true } - return /* spotless:off */ other is EntryStatus && value == other.value /* spotless:on */ + return other is EntryStatus && value == other.value } override fun hashCode() = value.hashCode() @@ -970,7 +970,7 @@ private constructor( return true } - return /* spotless:off */ other is EntryType && value == other.value /* spotless:on */ + return other is EntryType && value == other.value } override fun hashCode() = value.hashCode() @@ -1070,12 +1070,10 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1087,12 +1085,47 @@ private constructor( return true } - return /* spotless:off */ other is VoidInitiatedLedgerEntry && id == other.id && amount == other.amount && createdAt == other.createdAt && creditBlock == other.creditBlock && currency == other.currency && customer == other.customer && description == other.description && endingBalance == other.endingBalance && entryStatus == other.entryStatus && entryType == other.entryType && ledgerSequenceNumber == other.ledgerSequenceNumber && metadata == other.metadata && newBlockExpiryDate == other.newBlockExpiryDate && startingBalance == other.startingBalance && voidAmount == other.voidAmount && voidReason == other.voidReason && additionalProperties == other.additionalProperties /* spotless:on */ + return other is VoidInitiatedLedgerEntry && + id == other.id && + amount == other.amount && + createdAt == other.createdAt && + creditBlock == other.creditBlock && + currency == other.currency && + customer == other.customer && + description == other.description && + endingBalance == other.endingBalance && + entryStatus == other.entryStatus && + entryType == other.entryType && + ledgerSequenceNumber == other.ledgerSequenceNumber && + metadata == other.metadata && + newBlockExpiryDate == other.newBlockExpiryDate && + startingBalance == other.startingBalance && + voidAmount == other.voidAmount && + voidReason == other.voidReason && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, amount, createdAt, creditBlock, currency, customer, description, endingBalance, entryStatus, entryType, ledgerSequenceNumber, metadata, newBlockExpiryDate, startingBalance, voidAmount, voidReason, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + id, + amount, + createdAt, + creditBlock, + currency, + customer, + description, + endingBalance, + entryStatus, + entryType, + ledgerSequenceNumber, + metadata, + newBlockExpiryDate, + startingBalance, + voidAmount, + voidReason, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/VoidLedgerEntry.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/VoidLedgerEntry.kt index a55ba790c..7435195a7 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/VoidLedgerEntry.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/VoidLedgerEntry.kt @@ -807,7 +807,7 @@ private constructor( return true } - return /* spotless:off */ other is EntryStatus && value == other.value /* spotless:on */ + return other is EntryStatus && value == other.value } override fun hashCode() = value.hashCode() @@ -927,7 +927,7 @@ private constructor( return true } - return /* spotless:off */ other is EntryType && value == other.value /* spotless:on */ + return other is EntryType && value == other.value } override fun hashCode() = value.hashCode() @@ -1027,12 +1027,10 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1044,12 +1042,45 @@ private constructor( return true } - return /* spotless:off */ other is VoidLedgerEntry && id == other.id && amount == other.amount && createdAt == other.createdAt && creditBlock == other.creditBlock && currency == other.currency && customer == other.customer && description == other.description && endingBalance == other.endingBalance && entryStatus == other.entryStatus && entryType == other.entryType && ledgerSequenceNumber == other.ledgerSequenceNumber && metadata == other.metadata && startingBalance == other.startingBalance && voidAmount == other.voidAmount && voidReason == other.voidReason && additionalProperties == other.additionalProperties /* spotless:on */ + return other is VoidLedgerEntry && + id == other.id && + amount == other.amount && + createdAt == other.createdAt && + creditBlock == other.creditBlock && + currency == other.currency && + customer == other.customer && + description == other.description && + endingBalance == other.endingBalance && + entryStatus == other.entryStatus && + entryType == other.entryType && + ledgerSequenceNumber == other.ledgerSequenceNumber && + metadata == other.metadata && + startingBalance == other.startingBalance && + voidAmount == other.voidAmount && + voidReason == other.voidReason && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, amount, createdAt, creditBlock, currency, customer, description, endingBalance, entryStatus, entryType, ledgerSequenceNumber, metadata, startingBalance, voidAmount, voidReason, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + id, + amount, + createdAt, + creditBlock, + currency, + customer, + description, + endingBalance, + entryStatus, + entryType, + ledgerSequenceNumber, + metadata, + startingBalance, + voidAmount, + voidReason, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode diff --git a/orb-kotlin-example/build.gradle.kts b/orb-kotlin-example/build.gradle.kts index 1bbc9e978..693f55aa4 100644 --- a/orb-kotlin-example/build.gradle.kts +++ b/orb-kotlin-example/build.gradle.kts @@ -9,7 +9,7 @@ dependencies { application { // Use `./gradlew :orb-kotlin-example:run` to run `Main` - // Use `./gradlew :orb-kotlin-example:run -Dexample=Something` to run `SomethingExample` + // Use `./gradlew :orb-kotlin-example:run -Pexample=Something` to run `SomethingExample` mainClass = "com.withorb.api.example.${ if (project.hasProperty("example")) "${project.property("example")}ExampleKt" diff --git a/orb-kotlin-proguard-test/build.gradle.kts b/orb-kotlin-proguard-test/build.gradle.kts index 4ba289076..fdb3abe1a 100644 --- a/orb-kotlin-proguard-test/build.gradle.kts +++ b/orb-kotlin-proguard-test/build.gradle.kts @@ -37,8 +37,6 @@ val proguardJar by tasks.registering(proguard.gradle.ProGuardTask::class) { outjars(proguardJarPath) printmapping("${layout.buildDirectory.get()}/proguard-mapping.txt") - dontwarn() - val javaHome = System.getProperty("java.home") if (System.getProperty("java.version").startsWith("1.")) { // Before Java 9, the runtime classes were packaged in a single jar file. diff --git a/orb-kotlin-proguard-test/test.pro b/orb-kotlin-proguard-test/test.pro index da8a12644..bda3f4002 100644 --- a/orb-kotlin-proguard-test/test.pro +++ b/orb-kotlin-proguard-test/test.pro @@ -5,4 +5,5 @@ -keep class org.junit.** { *; } # Many warnings don't apply for our testing purposes. +-dontnote -dontwarn \ No newline at end of file diff --git a/scripts/build b/scripts/build new file mode 100755 index 000000000..f40634826 --- /dev/null +++ b/scripts/build @@ -0,0 +1,8 @@ +#!/usr/bin/env bash + +set -e + +cd "$(dirname "$0")/.." + +echo "==> Building classes" +./gradlew build testClasses -x test diff --git a/scripts/format b/scripts/format index 456a69db9..9e294b973 100755 --- a/scripts/format +++ b/scripts/format @@ -4,5 +4,10 @@ set -e cd "$(dirname "$0")/.." -echo "==> Running spotlessApply" -./gradlew spotlessApply +if command -v ktfmt &> /dev/null; then + echo "==> Running ktfmt" + find . -name "*.kt" -not -path "./buildSrc/build/*" -print0 | xargs -0 -r ktfmt --kotlinlang-style "$@" +else + echo "==> Running gradlew format" + ./gradlew format +fi diff --git a/scripts/lint b/scripts/lint index e3a5f5e24..5837798cf 100755 --- a/scripts/lint +++ b/scripts/lint @@ -4,5 +4,10 @@ set -e cd "$(dirname "$0")/.." -echo "==> Build classes" -./gradlew build testClasses -x test +if command -v ktfmt &> /dev/null; then + echo "==> Checking ktfmt" + ./scripts/format --dry-run --set-exit-if-changed +else + echo "==> Running gradlew lint" + ./gradlew lint +fi diff --git a/scripts/mock b/scripts/mock index d2814ae6a..0b28f6ea2 100755 --- a/scripts/mock +++ b/scripts/mock @@ -21,7 +21,7 @@ echo "==> Starting mock server with URL ${URL}" # Run prism mock on the given spec if [ "$1" == "--daemon" ]; then - npm exec --package=@stainless-api/prism-cli@5.8.5 -- prism mock "$URL" &> .prism.log & + npm exec --package=@stainless-api/prism-cli@5.15.0 -- prism mock "$URL" &> .prism.log & # Wait for server to come online echo -n "Waiting for server" @@ -37,5 +37,5 @@ if [ "$1" == "--daemon" ]; then echo else - npm exec --package=@stainless-api/prism-cli@5.8.5 -- prism mock "$URL" + npm exec --package=@stainless-api/prism-cli@5.15.0 -- prism mock "$URL" fi diff --git a/scripts/test b/scripts/test index 6b750a74e..047bc1dbb 100755 --- a/scripts/test +++ b/scripts/test @@ -43,7 +43,7 @@ elif ! prism_is_running ; then echo -e "To run the server, pass in the path or url of your OpenAPI" echo -e "spec to the prism command:" echo - echo -e " \$ ${YELLOW}npm exec --package=@stoplight/prism-cli@~5.3.2 -- prism mock path/to/your.openapi.yml${NC}" + echo -e " \$ ${YELLOW}npm exec --package=@stainless-api/prism-cli@5.15.0 -- prism mock path/to/your.openapi.yml${NC}" echo exit 1 @@ -53,4 +53,4 @@ else fi echo "==> Running tests" -./gradlew test +./gradlew test "$@" diff --git a/settings.gradle.kts b/settings.gradle.kts index d3e094a05..bf84b730f 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -1,7 +1,14 @@ rootProject.name = "orb-kotlin-root" -include("orb-kotlin") -include("orb-kotlin-client-okhttp") -include("orb-kotlin-core") -include("orb-kotlin-proguard-test") -include("orb-kotlin-example") +val projectNames = rootDir.listFiles() + ?.asSequence() + .orEmpty() + .filter { file -> + file.isDirectory && + file.name.startsWith("orb-kotlin") && + file.listFiles()?.asSequence().orEmpty().any { it.name == "build.gradle.kts" } + } + .map { it.name } + .toList() +println("projects: $projectNames") +projectNames.forEach { include(it) } From 32b35124936f5fea58bf91d92313b242f0d56e97 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 2 Sep 2025 19:57:22 +0000 Subject: [PATCH 08/68] feat(api)!: define shared model ConversionRateConfig `ConversionRateConfig` is defined in lots of places in the SDK. This commit extracts it to a shared model to reduce code duplication. Its new location is `orb-java-core/src/main/kotlin/com/withorb/api/models/ConversionRateConfig.kt` --- .stats.yml | 2 +- .../api/models/ConversionRateConfig.kt | 183 + .../withorb/api/models/NewFloatingBpsPrice.kt | 179 - .../api/models/NewFloatingBulkBpsPrice.kt | 179 - .../api/models/NewFloatingBulkPrice.kt | 179 - .../NewFloatingBulkWithProrationPrice.kt | 179 - .../NewFloatingCumulativeGroupedBulkPrice.kt | 179 - .../NewFloatingGroupedAllocationPrice.kt | 179 - .../NewFloatingGroupedTieredPackagePrice.kt | 179 - .../models/NewFloatingGroupedTieredPrice.kt | 179 - ...wFloatingGroupedWithMeteredMinimumPrice.kt | 179 - ...FloatingGroupedWithProratedMinimumPrice.kt | 179 - .../api/models/NewFloatingMatrixPrice.kt | 179 - .../NewFloatingMatrixWithAllocationPrice.kt | 179 - .../NewFloatingMatrixWithDisplayNamePrice.kt | 179 - .../NewFloatingMaxGroupTieredPackagePrice.kt | 179 - .../api/models/NewFloatingPackagePrice.kt | 179 - .../NewFloatingPackageWithAllocationPrice.kt | 179 - ...ingScalableMatrixWithTieredPricingPrice.kt | 179 - ...atingScalableMatrixWithUnitPricingPrice.kt | 179 - .../NewFloatingThresholdTotalAmountPrice.kt | 179 - .../api/models/NewFloatingTieredBpsPrice.kt | 179 - .../models/NewFloatingTieredPackagePrice.kt | 179 - ...ewFloatingTieredPackageWithMinimumPrice.kt | 179 - .../api/models/NewFloatingTieredPrice.kt | 179 - .../NewFloatingTieredWithMinimumPrice.kt | 179 - .../NewFloatingTieredWithProrationPrice.kt | 179 - .../api/models/NewFloatingUnitPrice.kt | 179 - .../models/NewFloatingUnitWithPercentPrice.kt | 179 - .../NewFloatingUnitWithProrationPrice.kt | 179 - .../com/withorb/api/models/NewPlanBpsPrice.kt | 179 - .../withorb/api/models/NewPlanBulkBpsPrice.kt | 179 - .../withorb/api/models/NewPlanBulkPrice.kt | 179 - .../models/NewPlanBulkWithProrationPrice.kt | 179 - .../NewPlanCumulativeGroupedBulkPrice.kt | 179 - .../models/NewPlanGroupedAllocationPrice.kt | 179 - .../NewPlanGroupedTieredPackagePrice.kt | 179 - .../api/models/NewPlanGroupedTieredPrice.kt | 179 - .../NewPlanGroupedWithMeteredMinimumPrice.kt | 179 - .../NewPlanGroupedWithProratedMinimumPrice.kt | 179 - .../withorb/api/models/NewPlanMatrixPrice.kt | 179 - .../NewPlanMatrixWithAllocationPrice.kt | 179 - .../NewPlanMatrixWithDisplayNamePrice.kt | 179 - .../NewPlanMaxGroupTieredPackagePrice.kt | 179 - .../withorb/api/models/NewPlanPackagePrice.kt | 179 - .../NewPlanPackageWithAllocationPrice.kt | 179 - ...lanScalableMatrixWithTieredPricingPrice.kt | 179 - ...wPlanScalableMatrixWithUnitPricingPrice.kt | 179 - .../NewPlanThresholdTotalAmountPrice.kt | 179 - .../models/NewPlanTierWithProrationPrice.kt | 179 - .../api/models/NewPlanTieredBpsPrice.kt | 179 - .../api/models/NewPlanTieredPackagePrice.kt | 179 - .../NewPlanTieredPackageWithMinimumPrice.kt | 179 - .../withorb/api/models/NewPlanTieredPrice.kt | 179 - .../models/NewPlanTieredWithMinimumPrice.kt | 179 - .../withorb/api/models/NewPlanUnitPrice.kt | 179 - .../api/models/NewPlanUnitWithPercentPrice.kt | 179 - .../models/NewPlanUnitWithProrationPrice.kt | 179 - .../api/models/NewSubscriptionBpsPrice.kt | 179 - .../api/models/NewSubscriptionBulkBpsPrice.kt | 179 - .../api/models/NewSubscriptionBulkPrice.kt | 179 - .../NewSubscriptionBulkWithProrationPrice.kt | 179 - ...wSubscriptionCumulativeGroupedBulkPrice.kt | 179 - .../NewSubscriptionGroupedAllocationPrice.kt | 179 - ...ewSubscriptionGroupedTieredPackagePrice.kt | 179 - .../NewSubscriptionGroupedTieredPrice.kt | 179 - ...scriptionGroupedWithMeteredMinimumPrice.kt | 179 - ...criptionGroupedWithProratedMinimumPrice.kt | 179 - .../api/models/NewSubscriptionMatrixPrice.kt | 179 - ...ewSubscriptionMatrixWithAllocationPrice.kt | 179 - ...wSubscriptionMatrixWithDisplayNamePrice.kt | 179 - ...wSubscriptionMaxGroupTieredPackagePrice.kt | 179 - .../api/models/NewSubscriptionPackagePrice.kt | 179 - ...wSubscriptionPackageWithAllocationPrice.kt | 179 - ...ionScalableMatrixWithTieredPricingPrice.kt | 179 - ...ptionScalableMatrixWithUnitPricingPrice.kt | 179 - ...ewSubscriptionThresholdTotalAmountPrice.kt | 179 - .../NewSubscriptionTierWithProrationPrice.kt | 179 - .../models/NewSubscriptionTieredBpsPrice.kt | 179 - .../NewSubscriptionTieredPackagePrice.kt | 179 - ...bscriptionTieredPackageWithMinimumPrice.kt | 179 - .../api/models/NewSubscriptionTieredPrice.kt | 179 - .../NewSubscriptionTieredWithMinimumPrice.kt | 179 - .../api/models/NewSubscriptionUnitPrice.kt | 179 - .../NewSubscriptionUnitWithPercentPrice.kt | 179 - .../NewSubscriptionUnitWithProrationPrice.kt | 179 - .../kotlin/com/withorb/api/models/Price.kt | 5810 ++--------------- .../api/models/ConversionRateConfigTest.kt | 124 + .../api/models/NewFloatingBpsPriceTest.kt | 2 +- .../api/models/NewFloatingBulkBpsPriceTest.kt | 2 +- .../api/models/NewFloatingBulkPriceTest.kt | 2 +- .../NewFloatingBulkWithProrationPriceTest.kt | 2 +- ...wFloatingCumulativeGroupedBulkPriceTest.kt | 2 +- .../NewFloatingGroupedAllocationPriceTest.kt | 2 +- ...ewFloatingGroupedTieredPackagePriceTest.kt | 2 +- .../NewFloatingGroupedTieredPriceTest.kt | 2 +- ...atingGroupedWithMeteredMinimumPriceTest.kt | 2 +- ...tingGroupedWithProratedMinimumPriceTest.kt | 2 +- .../api/models/NewFloatingMatrixPriceTest.kt | 2 +- ...ewFloatingMatrixWithAllocationPriceTest.kt | 2 +- ...wFloatingMatrixWithDisplayNamePriceTest.kt | 2 +- ...wFloatingMaxGroupTieredPackagePriceTest.kt | 2 +- .../api/models/NewFloatingPackagePriceTest.kt | 2 +- ...wFloatingPackageWithAllocationPriceTest.kt | 2 +- ...calableMatrixWithTieredPricingPriceTest.kt | 2 +- ...gScalableMatrixWithUnitPricingPriceTest.kt | 2 +- ...ewFloatingThresholdTotalAmountPriceTest.kt | 2 +- .../models/NewFloatingTieredBpsPriceTest.kt | 2 +- .../NewFloatingTieredPackagePriceTest.kt | 2 +- ...oatingTieredPackageWithMinimumPriceTest.kt | 2 +- .../api/models/NewFloatingTieredPriceTest.kt | 2 +- .../NewFloatingTieredWithMinimumPriceTest.kt | 2 +- ...NewFloatingTieredWithProrationPriceTest.kt | 2 +- .../api/models/NewFloatingUnitPriceTest.kt | 2 +- .../NewFloatingUnitWithPercentPriceTest.kt | 2 +- .../NewFloatingUnitWithProrationPriceTest.kt | 2 +- .../withorb/api/models/NewPlanBpsPriceTest.kt | 2 +- .../api/models/NewPlanBulkBpsPriceTest.kt | 2 +- .../api/models/NewPlanBulkPriceTest.kt | 2 +- .../NewPlanBulkWithProrationPriceTest.kt | 2 +- .../NewPlanCumulativeGroupedBulkPriceTest.kt | 2 +- .../NewPlanGroupedAllocationPriceTest.kt | 2 +- .../NewPlanGroupedTieredPackagePriceTest.kt | 2 +- .../models/NewPlanGroupedTieredPriceTest.kt | 2 +- ...wPlanGroupedWithMeteredMinimumPriceTest.kt | 2 +- ...PlanGroupedWithProratedMinimumPriceTest.kt | 2 +- .../api/models/NewPlanMatrixPriceTest.kt | 2 +- .../NewPlanMatrixWithAllocationPriceTest.kt | 2 +- .../NewPlanMatrixWithDisplayNamePriceTest.kt | 2 +- .../NewPlanMaxGroupTieredPackagePriceTest.kt | 2 +- .../api/models/NewPlanPackagePriceTest.kt | 2 +- .../NewPlanPackageWithAllocationPriceTest.kt | 2 +- ...calableMatrixWithTieredPricingPriceTest.kt | 2 +- ...nScalableMatrixWithUnitPricingPriceTest.kt | 2 +- .../NewPlanThresholdTotalAmountPriceTest.kt | 2 +- .../NewPlanTierWithProrationPriceTest.kt | 2 +- .../api/models/NewPlanTieredBpsPriceTest.kt | 2 +- .../models/NewPlanTieredPackagePriceTest.kt | 2 +- ...ewPlanTieredPackageWithMinimumPriceTest.kt | 2 +- .../api/models/NewPlanTieredPriceTest.kt | 2 +- .../NewPlanTieredWithMinimumPriceTest.kt | 2 +- .../api/models/NewPlanUnitPriceTest.kt | 2 +- .../models/NewPlanUnitWithPercentPriceTest.kt | 2 +- .../NewPlanUnitWithProrationPriceTest.kt | 2 +- .../api/models/NewSubscriptionBpsPriceTest.kt | 2 +- .../models/NewSubscriptionBulkBpsPriceTest.kt | 2 +- .../models/NewSubscriptionBulkPriceTest.kt | 2 +- ...wSubscriptionBulkWithProrationPriceTest.kt | 2 +- ...scriptionCumulativeGroupedBulkPriceTest.kt | 2 +- ...wSubscriptionGroupedAllocationPriceTest.kt | 2 +- ...bscriptionGroupedTieredPackagePriceTest.kt | 2 +- .../NewSubscriptionGroupedTieredPriceTest.kt | 2 +- ...ptionGroupedWithMeteredMinimumPriceTest.kt | 2 +- ...tionGroupedWithProratedMinimumPriceTest.kt | 2 +- .../models/NewSubscriptionMatrixPriceTest.kt | 2 +- ...bscriptionMatrixWithAllocationPriceTest.kt | 2 +- ...scriptionMatrixWithDisplayNamePriceTest.kt | 2 +- ...scriptionMaxGroupTieredPackagePriceTest.kt | 2 +- .../models/NewSubscriptionPackagePriceTest.kt | 2 +- ...scriptionPackageWithAllocationPriceTest.kt | 2 +- ...calableMatrixWithTieredPricingPriceTest.kt | 2 +- ...nScalableMatrixWithUnitPricingPriceTest.kt | 2 +- ...bscriptionThresholdTotalAmountPriceTest.kt | 2 +- ...wSubscriptionTierWithProrationPriceTest.kt | 2 +- .../NewSubscriptionTieredBpsPriceTest.kt | 2 +- .../NewSubscriptionTieredPackagePriceTest.kt | 2 +- ...iptionTieredPackageWithMinimumPriceTest.kt | 2 +- .../models/NewSubscriptionTieredPriceTest.kt | 2 +- ...wSubscriptionTieredWithMinimumPriceTest.kt | 2 +- .../models/NewSubscriptionUnitPriceTest.kt | 2 +- ...NewSubscriptionUnitWithPercentPriceTest.kt | 2 +- ...wSubscriptionUnitWithProrationPriceTest.kt | 2 +- .../api/proguard/ProGuardCompatibilityTest.kt | 36 +- 173 files changed, 788 insertions(+), 20571 deletions(-) create mode 100644 orb-kotlin-core/src/main/kotlin/com/withorb/api/models/ConversionRateConfig.kt create mode 100644 orb-kotlin-core/src/test/kotlin/com/withorb/api/models/ConversionRateConfigTest.kt diff --git a/.stats.yml b/.stats.yml index 69ee938b4..3fc0331e8 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 118 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-4f31d46f5ba187fc4d702c9f9f1573dacb891edbd086f935707578d7c4f5fed8.yml openapi_spec_hash: 25b1019f20a47b8af665aae5f8fd0025 -config_hash: d8a0d696f3250ab096fac87b6b0eab53 +config_hash: be9350529b910ec14bff0a30cd74a185 diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/ConversionRateConfig.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/ConversionRateConfig.kt new file mode 100644 index 000000000..fb442be2a --- /dev/null +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/ConversionRateConfig.kt @@ -0,0 +1,183 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.withorb.api.core.BaseDeserializer +import com.withorb.api.core.BaseSerializer +import com.withorb.api.core.JsonValue +import com.withorb.api.core.getOrThrow +import com.withorb.api.errors.OrbInvalidDataException +import java.util.Objects + +@JsonDeserialize(using = ConversionRateConfig.Deserializer::class) +@JsonSerialize(using = ConversionRateConfig.Serializer::class) +class ConversionRateConfig +private constructor( + private val unit: UnitConversionRateConfig? = null, + private val tiered: TieredConversionRateConfig? = null, + private val _json: JsonValue? = null, +) { + + fun unit(): UnitConversionRateConfig? = unit + + fun tiered(): TieredConversionRateConfig? = tiered + + fun isUnit(): Boolean = unit != null + + fun isTiered(): Boolean = tiered != null + + fun asUnit(): UnitConversionRateConfig = unit.getOrThrow("unit") + + fun asTiered(): TieredConversionRateConfig = tiered.getOrThrow("tiered") + + fun _json(): JsonValue? = _json + + fun accept(visitor: Visitor): T = + when { + unit != null -> visitor.visitUnit(unit) + tiered != null -> visitor.visitTiered(tiered) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): ConversionRateConfig = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitUnit(unit: UnitConversionRateConfig) { + unit.validate() + } + + override fun visitTiered(tiered: TieredConversionRateConfig) { + tiered.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitUnit(unit: UnitConversionRateConfig) = unit.validity() + + override fun visitTiered(tiered: TieredConversionRateConfig) = tiered.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered + } + + override fun hashCode(): Int = Objects.hash(unit, tiered) + + override fun toString(): String = + when { + unit != null -> "ConversionRateConfig{unit=$unit}" + tiered != null -> "ConversionRateConfig{tiered=$tiered}" + _json != null -> "ConversionRateConfig{_unknown=$_json}" + else -> throw IllegalStateException("Invalid ConversionRateConfig") + } + + companion object { + + fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) + + fun ofTiered(tiered: TieredConversionRateConfig) = ConversionRateConfig(tiered = tiered) + } + + /** + * An interface that defines how to map each variant of [ConversionRateConfig] to a value of + * type [T]. + */ + interface Visitor { + + fun visitUnit(unit: UnitConversionRateConfig): T + + fun visitTiered(tiered: TieredConversionRateConfig): T + + /** + * Maps an unknown variant of [ConversionRateConfig] to a value of type [T]. + * + * An instance of [ConversionRateConfig] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For example, if the SDK is + * on an older version than the API, then the API may respond with new variants that the SDK + * is unaware of. + * + * @throws OrbInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw OrbInvalidDataException("Unknown ConversionRateConfig: $json") + } + } + + internal class Deserializer : + BaseDeserializer(ConversionRateConfig::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): ConversionRateConfig { + val json = JsonValue.fromJsonNode(node) + val conversionRateType = json.asObject()?.get("conversion_rate_type")?.asString() + + when (conversionRateType) { + "unit" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + ConversionRateConfig(unit = it, _json = json) + } ?: ConversionRateConfig(_json = json) + } + "tiered" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + ConversionRateConfig(tiered = it, _json = json) + } ?: ConversionRateConfig(_json = json) + } + } + + return ConversionRateConfig(_json = json) + } + } + + internal class Serializer : BaseSerializer(ConversionRateConfig::class) { + + override fun serialize( + value: ConversionRateConfig, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.unit != null -> generator.writeObject(value.unit) + value.tiered != null -> generator.writeObject(value.tiered) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid ConversionRateConfig") + } + } + } +} diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingBpsPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingBpsPrice.kt index 8bb3ecb21..813376b21 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingBpsPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingBpsPrice.kt @@ -6,22 +6,12 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.withorb.api.core.BaseDeserializer -import com.withorb.api.core.BaseSerializer import com.withorb.api.core.Enum import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.checkRequired -import com.withorb.api.core.getOrThrow import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import java.util.Collections @@ -1172,175 +1162,6 @@ private constructor( override fun toString() = value.toString() } - /** The configuration for the rate of the price currency to the invoicing currency. */ - @JsonDeserialize(using = ConversionRateConfig.Deserializer::class) - @JsonSerialize(using = ConversionRateConfig.Serializer::class) - class ConversionRateConfig - private constructor( - private val unit: UnitConversionRateConfig? = null, - private val tiered: TieredConversionRateConfig? = null, - private val _json: JsonValue? = null, - ) { - - fun unit(): UnitConversionRateConfig? = unit - - fun tiered(): TieredConversionRateConfig? = tiered - - fun isUnit(): Boolean = unit != null - - fun isTiered(): Boolean = tiered != null - - fun asUnit(): UnitConversionRateConfig = unit.getOrThrow("unit") - - fun asTiered(): TieredConversionRateConfig = tiered.getOrThrow("tiered") - - fun _json(): JsonValue? = _json - - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): ConversionRateConfig = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) { - unit.validate() - } - - override fun visitTiered(tiered: TieredConversionRateConfig) { - tiered.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) = unit.validity() - - override fun visitTiered(tiered: TieredConversionRateConfig) = tiered.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered - } - - override fun hashCode(): Int = Objects.hash(unit, tiered) - - override fun toString(): String = - when { - unit != null -> "ConversionRateConfig{unit=$unit}" - tiered != null -> "ConversionRateConfig{tiered=$tiered}" - _json != null -> "ConversionRateConfig{_unknown=$_json}" - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - - companion object { - - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - fun ofTiered(tiered: TieredConversionRateConfig) = ConversionRateConfig(tiered = tiered) - } - - /** - * An interface that defines how to map each variant of [ConversionRateConfig] to a value of - * type [T]. - */ - interface Visitor { - - fun visitUnit(unit: UnitConversionRateConfig): T - - fun visitTiered(tiered: TieredConversionRateConfig): T - - /** - * Maps an unknown variant of [ConversionRateConfig] to a value of type [T]. - * - * An instance of [ConversionRateConfig] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if the SDK - * is on an older version than the API, then the API may respond with new variants that - * the SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown ConversionRateConfig: $json") - } - } - - internal class Deserializer : - BaseDeserializer(ConversionRateConfig::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): ConversionRateConfig { - val json = JsonValue.fromJsonNode(node) - val conversionRateType = json.asObject()?.get("conversion_rate_type")?.asString() - - when (conversionRateType) { - "unit" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(unit = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - "tiered" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(tiered = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - } - - return ConversionRateConfig(_json = json) - } - } - - internal class Serializer : - BaseSerializer(ConversionRateConfig::class) { - - override fun serialize( - value: ConversionRateConfig, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unit != null -> generator.writeObject(value.unit) - value.tiered != null -> generator.writeObject(value.tiered) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - } - } - } - /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingBulkBpsPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingBulkBpsPrice.kt index 12e38ee2d..0fd429c63 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingBulkBpsPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingBulkBpsPrice.kt @@ -6,22 +6,12 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.withorb.api.core.BaseDeserializer -import com.withorb.api.core.BaseSerializer import com.withorb.api.core.Enum import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.checkRequired -import com.withorb.api.core.getOrThrow import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import java.util.Collections @@ -1176,175 +1166,6 @@ private constructor( override fun toString() = value.toString() } - /** The configuration for the rate of the price currency to the invoicing currency. */ - @JsonDeserialize(using = ConversionRateConfig.Deserializer::class) - @JsonSerialize(using = ConversionRateConfig.Serializer::class) - class ConversionRateConfig - private constructor( - private val unit: UnitConversionRateConfig? = null, - private val tiered: TieredConversionRateConfig? = null, - private val _json: JsonValue? = null, - ) { - - fun unit(): UnitConversionRateConfig? = unit - - fun tiered(): TieredConversionRateConfig? = tiered - - fun isUnit(): Boolean = unit != null - - fun isTiered(): Boolean = tiered != null - - fun asUnit(): UnitConversionRateConfig = unit.getOrThrow("unit") - - fun asTiered(): TieredConversionRateConfig = tiered.getOrThrow("tiered") - - fun _json(): JsonValue? = _json - - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): ConversionRateConfig = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) { - unit.validate() - } - - override fun visitTiered(tiered: TieredConversionRateConfig) { - tiered.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) = unit.validity() - - override fun visitTiered(tiered: TieredConversionRateConfig) = tiered.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered - } - - override fun hashCode(): Int = Objects.hash(unit, tiered) - - override fun toString(): String = - when { - unit != null -> "ConversionRateConfig{unit=$unit}" - tiered != null -> "ConversionRateConfig{tiered=$tiered}" - _json != null -> "ConversionRateConfig{_unknown=$_json}" - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - - companion object { - - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - fun ofTiered(tiered: TieredConversionRateConfig) = ConversionRateConfig(tiered = tiered) - } - - /** - * An interface that defines how to map each variant of [ConversionRateConfig] to a value of - * type [T]. - */ - interface Visitor { - - fun visitUnit(unit: UnitConversionRateConfig): T - - fun visitTiered(tiered: TieredConversionRateConfig): T - - /** - * Maps an unknown variant of [ConversionRateConfig] to a value of type [T]. - * - * An instance of [ConversionRateConfig] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if the SDK - * is on an older version than the API, then the API may respond with new variants that - * the SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown ConversionRateConfig: $json") - } - } - - internal class Deserializer : - BaseDeserializer(ConversionRateConfig::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): ConversionRateConfig { - val json = JsonValue.fromJsonNode(node) - val conversionRateType = json.asObject()?.get("conversion_rate_type")?.asString() - - when (conversionRateType) { - "unit" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(unit = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - "tiered" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(tiered = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - } - - return ConversionRateConfig(_json = json) - } - } - - internal class Serializer : - BaseSerializer(ConversionRateConfig::class) { - - override fun serialize( - value: ConversionRateConfig, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unit != null -> generator.writeObject(value.unit) - value.tiered != null -> generator.writeObject(value.tiered) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - } - } - } - /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingBulkPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingBulkPrice.kt index 79f76a669..e6768ee6a 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingBulkPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingBulkPrice.kt @@ -6,22 +6,12 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.withorb.api.core.BaseDeserializer -import com.withorb.api.core.BaseSerializer import com.withorb.api.core.Enum import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.checkRequired -import com.withorb.api.core.getOrThrow import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import java.util.Collections @@ -1174,175 +1164,6 @@ private constructor( override fun toString() = value.toString() } - /** The configuration for the rate of the price currency to the invoicing currency. */ - @JsonDeserialize(using = ConversionRateConfig.Deserializer::class) - @JsonSerialize(using = ConversionRateConfig.Serializer::class) - class ConversionRateConfig - private constructor( - private val unit: UnitConversionRateConfig? = null, - private val tiered: TieredConversionRateConfig? = null, - private val _json: JsonValue? = null, - ) { - - fun unit(): UnitConversionRateConfig? = unit - - fun tiered(): TieredConversionRateConfig? = tiered - - fun isUnit(): Boolean = unit != null - - fun isTiered(): Boolean = tiered != null - - fun asUnit(): UnitConversionRateConfig = unit.getOrThrow("unit") - - fun asTiered(): TieredConversionRateConfig = tiered.getOrThrow("tiered") - - fun _json(): JsonValue? = _json - - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): ConversionRateConfig = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) { - unit.validate() - } - - override fun visitTiered(tiered: TieredConversionRateConfig) { - tiered.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) = unit.validity() - - override fun visitTiered(tiered: TieredConversionRateConfig) = tiered.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered - } - - override fun hashCode(): Int = Objects.hash(unit, tiered) - - override fun toString(): String = - when { - unit != null -> "ConversionRateConfig{unit=$unit}" - tiered != null -> "ConversionRateConfig{tiered=$tiered}" - _json != null -> "ConversionRateConfig{_unknown=$_json}" - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - - companion object { - - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - fun ofTiered(tiered: TieredConversionRateConfig) = ConversionRateConfig(tiered = tiered) - } - - /** - * An interface that defines how to map each variant of [ConversionRateConfig] to a value of - * type [T]. - */ - interface Visitor { - - fun visitUnit(unit: UnitConversionRateConfig): T - - fun visitTiered(tiered: TieredConversionRateConfig): T - - /** - * Maps an unknown variant of [ConversionRateConfig] to a value of type [T]. - * - * An instance of [ConversionRateConfig] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if the SDK - * is on an older version than the API, then the API may respond with new variants that - * the SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown ConversionRateConfig: $json") - } - } - - internal class Deserializer : - BaseDeserializer(ConversionRateConfig::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): ConversionRateConfig { - val json = JsonValue.fromJsonNode(node) - val conversionRateType = json.asObject()?.get("conversion_rate_type")?.asString() - - when (conversionRateType) { - "unit" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(unit = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - "tiered" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(tiered = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - } - - return ConversionRateConfig(_json = json) - } - } - - internal class Serializer : - BaseSerializer(ConversionRateConfig::class) { - - override fun serialize( - value: ConversionRateConfig, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unit != null -> generator.writeObject(value.unit) - value.tiered != null -> generator.writeObject(value.tiered) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - } - } - } - /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingBulkWithProrationPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingBulkWithProrationPrice.kt index 605202314..056c655c1 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingBulkWithProrationPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingBulkWithProrationPrice.kt @@ -6,22 +6,12 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.withorb.api.core.BaseDeserializer -import com.withorb.api.core.BaseSerializer import com.withorb.api.core.Enum import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.checkRequired -import com.withorb.api.core.getOrThrow import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import java.util.Collections @@ -1288,175 +1278,6 @@ private constructor( override fun toString() = value.toString() } - /** The configuration for the rate of the price currency to the invoicing currency. */ - @JsonDeserialize(using = ConversionRateConfig.Deserializer::class) - @JsonSerialize(using = ConversionRateConfig.Serializer::class) - class ConversionRateConfig - private constructor( - private val unit: UnitConversionRateConfig? = null, - private val tiered: TieredConversionRateConfig? = null, - private val _json: JsonValue? = null, - ) { - - fun unit(): UnitConversionRateConfig? = unit - - fun tiered(): TieredConversionRateConfig? = tiered - - fun isUnit(): Boolean = unit != null - - fun isTiered(): Boolean = tiered != null - - fun asUnit(): UnitConversionRateConfig = unit.getOrThrow("unit") - - fun asTiered(): TieredConversionRateConfig = tiered.getOrThrow("tiered") - - fun _json(): JsonValue? = _json - - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): ConversionRateConfig = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) { - unit.validate() - } - - override fun visitTiered(tiered: TieredConversionRateConfig) { - tiered.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) = unit.validity() - - override fun visitTiered(tiered: TieredConversionRateConfig) = tiered.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered - } - - override fun hashCode(): Int = Objects.hash(unit, tiered) - - override fun toString(): String = - when { - unit != null -> "ConversionRateConfig{unit=$unit}" - tiered != null -> "ConversionRateConfig{tiered=$tiered}" - _json != null -> "ConversionRateConfig{_unknown=$_json}" - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - - companion object { - - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - fun ofTiered(tiered: TieredConversionRateConfig) = ConversionRateConfig(tiered = tiered) - } - - /** - * An interface that defines how to map each variant of [ConversionRateConfig] to a value of - * type [T]. - */ - interface Visitor { - - fun visitUnit(unit: UnitConversionRateConfig): T - - fun visitTiered(tiered: TieredConversionRateConfig): T - - /** - * Maps an unknown variant of [ConversionRateConfig] to a value of type [T]. - * - * An instance of [ConversionRateConfig] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if the SDK - * is on an older version than the API, then the API may respond with new variants that - * the SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown ConversionRateConfig: $json") - } - } - - internal class Deserializer : - BaseDeserializer(ConversionRateConfig::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): ConversionRateConfig { - val json = JsonValue.fromJsonNode(node) - val conversionRateType = json.asObject()?.get("conversion_rate_type")?.asString() - - when (conversionRateType) { - "unit" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(unit = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - "tiered" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(tiered = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - } - - return ConversionRateConfig(_json = json) - } - } - - internal class Serializer : - BaseSerializer(ConversionRateConfig::class) { - - override fun serialize( - value: ConversionRateConfig, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unit != null -> generator.writeObject(value.unit) - value.tiered != null -> generator.writeObject(value.tiered) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - } - } - } - /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingCumulativeGroupedBulkPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingCumulativeGroupedBulkPrice.kt index 7d109ab50..eea158ef4 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingCumulativeGroupedBulkPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingCumulativeGroupedBulkPrice.kt @@ -6,22 +6,12 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.withorb.api.core.BaseDeserializer -import com.withorb.api.core.BaseSerializer import com.withorb.api.core.Enum import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.checkRequired -import com.withorb.api.core.getOrThrow import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import java.util.Collections @@ -1292,175 +1282,6 @@ private constructor( override fun toString() = value.toString() } - /** The configuration for the rate of the price currency to the invoicing currency. */ - @JsonDeserialize(using = ConversionRateConfig.Deserializer::class) - @JsonSerialize(using = ConversionRateConfig.Serializer::class) - class ConversionRateConfig - private constructor( - private val unit: UnitConversionRateConfig? = null, - private val tiered: TieredConversionRateConfig? = null, - private val _json: JsonValue? = null, - ) { - - fun unit(): UnitConversionRateConfig? = unit - - fun tiered(): TieredConversionRateConfig? = tiered - - fun isUnit(): Boolean = unit != null - - fun isTiered(): Boolean = tiered != null - - fun asUnit(): UnitConversionRateConfig = unit.getOrThrow("unit") - - fun asTiered(): TieredConversionRateConfig = tiered.getOrThrow("tiered") - - fun _json(): JsonValue? = _json - - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): ConversionRateConfig = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) { - unit.validate() - } - - override fun visitTiered(tiered: TieredConversionRateConfig) { - tiered.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) = unit.validity() - - override fun visitTiered(tiered: TieredConversionRateConfig) = tiered.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered - } - - override fun hashCode(): Int = Objects.hash(unit, tiered) - - override fun toString(): String = - when { - unit != null -> "ConversionRateConfig{unit=$unit}" - tiered != null -> "ConversionRateConfig{tiered=$tiered}" - _json != null -> "ConversionRateConfig{_unknown=$_json}" - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - - companion object { - - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - fun ofTiered(tiered: TieredConversionRateConfig) = ConversionRateConfig(tiered = tiered) - } - - /** - * An interface that defines how to map each variant of [ConversionRateConfig] to a value of - * type [T]. - */ - interface Visitor { - - fun visitUnit(unit: UnitConversionRateConfig): T - - fun visitTiered(tiered: TieredConversionRateConfig): T - - /** - * Maps an unknown variant of [ConversionRateConfig] to a value of type [T]. - * - * An instance of [ConversionRateConfig] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if the SDK - * is on an older version than the API, then the API may respond with new variants that - * the SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown ConversionRateConfig: $json") - } - } - - internal class Deserializer : - BaseDeserializer(ConversionRateConfig::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): ConversionRateConfig { - val json = JsonValue.fromJsonNode(node) - val conversionRateType = json.asObject()?.get("conversion_rate_type")?.asString() - - when (conversionRateType) { - "unit" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(unit = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - "tiered" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(tiered = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - } - - return ConversionRateConfig(_json = json) - } - } - - internal class Serializer : - BaseSerializer(ConversionRateConfig::class) { - - override fun serialize( - value: ConversionRateConfig, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unit != null -> generator.writeObject(value.unit) - value.tiered != null -> generator.writeObject(value.tiered) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - } - } - } - /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingGroupedAllocationPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingGroupedAllocationPrice.kt index 58db54a70..dcf5aee14 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingGroupedAllocationPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingGroupedAllocationPrice.kt @@ -6,22 +6,12 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.withorb.api.core.BaseDeserializer -import com.withorb.api.core.BaseSerializer import com.withorb.api.core.Enum import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.checkRequired -import com.withorb.api.core.getOrThrow import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import java.util.Collections @@ -1288,175 +1278,6 @@ private constructor( override fun toString() = value.toString() } - /** The configuration for the rate of the price currency to the invoicing currency. */ - @JsonDeserialize(using = ConversionRateConfig.Deserializer::class) - @JsonSerialize(using = ConversionRateConfig.Serializer::class) - class ConversionRateConfig - private constructor( - private val unit: UnitConversionRateConfig? = null, - private val tiered: TieredConversionRateConfig? = null, - private val _json: JsonValue? = null, - ) { - - fun unit(): UnitConversionRateConfig? = unit - - fun tiered(): TieredConversionRateConfig? = tiered - - fun isUnit(): Boolean = unit != null - - fun isTiered(): Boolean = tiered != null - - fun asUnit(): UnitConversionRateConfig = unit.getOrThrow("unit") - - fun asTiered(): TieredConversionRateConfig = tiered.getOrThrow("tiered") - - fun _json(): JsonValue? = _json - - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): ConversionRateConfig = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) { - unit.validate() - } - - override fun visitTiered(tiered: TieredConversionRateConfig) { - tiered.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) = unit.validity() - - override fun visitTiered(tiered: TieredConversionRateConfig) = tiered.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered - } - - override fun hashCode(): Int = Objects.hash(unit, tiered) - - override fun toString(): String = - when { - unit != null -> "ConversionRateConfig{unit=$unit}" - tiered != null -> "ConversionRateConfig{tiered=$tiered}" - _json != null -> "ConversionRateConfig{_unknown=$_json}" - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - - companion object { - - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - fun ofTiered(tiered: TieredConversionRateConfig) = ConversionRateConfig(tiered = tiered) - } - - /** - * An interface that defines how to map each variant of [ConversionRateConfig] to a value of - * type [T]. - */ - interface Visitor { - - fun visitUnit(unit: UnitConversionRateConfig): T - - fun visitTiered(tiered: TieredConversionRateConfig): T - - /** - * Maps an unknown variant of [ConversionRateConfig] to a value of type [T]. - * - * An instance of [ConversionRateConfig] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if the SDK - * is on an older version than the API, then the API may respond with new variants that - * the SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown ConversionRateConfig: $json") - } - } - - internal class Deserializer : - BaseDeserializer(ConversionRateConfig::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): ConversionRateConfig { - val json = JsonValue.fromJsonNode(node) - val conversionRateType = json.asObject()?.get("conversion_rate_type")?.asString() - - when (conversionRateType) { - "unit" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(unit = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - "tiered" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(tiered = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - } - - return ConversionRateConfig(_json = json) - } - } - - internal class Serializer : - BaseSerializer(ConversionRateConfig::class) { - - override fun serialize( - value: ConversionRateConfig, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unit != null -> generator.writeObject(value.unit) - value.tiered != null -> generator.writeObject(value.tiered) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - } - } - } - /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingGroupedTieredPackagePrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingGroupedTieredPackagePrice.kt index 1459230ba..aa339ce45 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingGroupedTieredPackagePrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingGroupedTieredPackagePrice.kt @@ -6,22 +6,12 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.withorb.api.core.BaseDeserializer -import com.withorb.api.core.BaseSerializer import com.withorb.api.core.Enum import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.checkRequired -import com.withorb.api.core.getOrThrow import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import java.util.Collections @@ -1292,175 +1282,6 @@ private constructor( override fun toString() = value.toString() } - /** The configuration for the rate of the price currency to the invoicing currency. */ - @JsonDeserialize(using = ConversionRateConfig.Deserializer::class) - @JsonSerialize(using = ConversionRateConfig.Serializer::class) - class ConversionRateConfig - private constructor( - private val unit: UnitConversionRateConfig? = null, - private val tiered: TieredConversionRateConfig? = null, - private val _json: JsonValue? = null, - ) { - - fun unit(): UnitConversionRateConfig? = unit - - fun tiered(): TieredConversionRateConfig? = tiered - - fun isUnit(): Boolean = unit != null - - fun isTiered(): Boolean = tiered != null - - fun asUnit(): UnitConversionRateConfig = unit.getOrThrow("unit") - - fun asTiered(): TieredConversionRateConfig = tiered.getOrThrow("tiered") - - fun _json(): JsonValue? = _json - - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): ConversionRateConfig = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) { - unit.validate() - } - - override fun visitTiered(tiered: TieredConversionRateConfig) { - tiered.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) = unit.validity() - - override fun visitTiered(tiered: TieredConversionRateConfig) = tiered.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered - } - - override fun hashCode(): Int = Objects.hash(unit, tiered) - - override fun toString(): String = - when { - unit != null -> "ConversionRateConfig{unit=$unit}" - tiered != null -> "ConversionRateConfig{tiered=$tiered}" - _json != null -> "ConversionRateConfig{_unknown=$_json}" - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - - companion object { - - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - fun ofTiered(tiered: TieredConversionRateConfig) = ConversionRateConfig(tiered = tiered) - } - - /** - * An interface that defines how to map each variant of [ConversionRateConfig] to a value of - * type [T]. - */ - interface Visitor { - - fun visitUnit(unit: UnitConversionRateConfig): T - - fun visitTiered(tiered: TieredConversionRateConfig): T - - /** - * Maps an unknown variant of [ConversionRateConfig] to a value of type [T]. - * - * An instance of [ConversionRateConfig] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if the SDK - * is on an older version than the API, then the API may respond with new variants that - * the SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown ConversionRateConfig: $json") - } - } - - internal class Deserializer : - BaseDeserializer(ConversionRateConfig::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): ConversionRateConfig { - val json = JsonValue.fromJsonNode(node) - val conversionRateType = json.asObject()?.get("conversion_rate_type")?.asString() - - when (conversionRateType) { - "unit" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(unit = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - "tiered" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(tiered = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - } - - return ConversionRateConfig(_json = json) - } - } - - internal class Serializer : - BaseSerializer(ConversionRateConfig::class) { - - override fun serialize( - value: ConversionRateConfig, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unit != null -> generator.writeObject(value.unit) - value.tiered != null -> generator.writeObject(value.tiered) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - } - } - } - /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingGroupedTieredPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingGroupedTieredPrice.kt index 439ad9232..ca8637ba5 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingGroupedTieredPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingGroupedTieredPrice.kt @@ -6,22 +6,12 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.withorb.api.core.BaseDeserializer -import com.withorb.api.core.BaseSerializer import com.withorb.api.core.Enum import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.checkRequired -import com.withorb.api.core.getOrThrow import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import java.util.Collections @@ -1280,175 +1270,6 @@ private constructor( override fun toString() = value.toString() } - /** The configuration for the rate of the price currency to the invoicing currency. */ - @JsonDeserialize(using = ConversionRateConfig.Deserializer::class) - @JsonSerialize(using = ConversionRateConfig.Serializer::class) - class ConversionRateConfig - private constructor( - private val unit: UnitConversionRateConfig? = null, - private val tiered: TieredConversionRateConfig? = null, - private val _json: JsonValue? = null, - ) { - - fun unit(): UnitConversionRateConfig? = unit - - fun tiered(): TieredConversionRateConfig? = tiered - - fun isUnit(): Boolean = unit != null - - fun isTiered(): Boolean = tiered != null - - fun asUnit(): UnitConversionRateConfig = unit.getOrThrow("unit") - - fun asTiered(): TieredConversionRateConfig = tiered.getOrThrow("tiered") - - fun _json(): JsonValue? = _json - - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): ConversionRateConfig = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) { - unit.validate() - } - - override fun visitTiered(tiered: TieredConversionRateConfig) { - tiered.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) = unit.validity() - - override fun visitTiered(tiered: TieredConversionRateConfig) = tiered.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered - } - - override fun hashCode(): Int = Objects.hash(unit, tiered) - - override fun toString(): String = - when { - unit != null -> "ConversionRateConfig{unit=$unit}" - tiered != null -> "ConversionRateConfig{tiered=$tiered}" - _json != null -> "ConversionRateConfig{_unknown=$_json}" - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - - companion object { - - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - fun ofTiered(tiered: TieredConversionRateConfig) = ConversionRateConfig(tiered = tiered) - } - - /** - * An interface that defines how to map each variant of [ConversionRateConfig] to a value of - * type [T]. - */ - interface Visitor { - - fun visitUnit(unit: UnitConversionRateConfig): T - - fun visitTiered(tiered: TieredConversionRateConfig): T - - /** - * Maps an unknown variant of [ConversionRateConfig] to a value of type [T]. - * - * An instance of [ConversionRateConfig] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if the SDK - * is on an older version than the API, then the API may respond with new variants that - * the SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown ConversionRateConfig: $json") - } - } - - internal class Deserializer : - BaseDeserializer(ConversionRateConfig::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): ConversionRateConfig { - val json = JsonValue.fromJsonNode(node) - val conversionRateType = json.asObject()?.get("conversion_rate_type")?.asString() - - when (conversionRateType) { - "unit" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(unit = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - "tiered" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(tiered = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - } - - return ConversionRateConfig(_json = json) - } - } - - internal class Serializer : - BaseSerializer(ConversionRateConfig::class) { - - override fun serialize( - value: ConversionRateConfig, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unit != null -> generator.writeObject(value.unit) - value.tiered != null -> generator.writeObject(value.tiered) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - } - } - } - /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingGroupedWithMeteredMinimumPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingGroupedWithMeteredMinimumPrice.kt index 7d08fa962..af7fd6221 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingGroupedWithMeteredMinimumPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingGroupedWithMeteredMinimumPrice.kt @@ -6,22 +6,12 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.withorb.api.core.BaseDeserializer -import com.withorb.api.core.BaseSerializer import com.withorb.api.core.Enum import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.checkRequired -import com.withorb.api.core.getOrThrow import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import java.util.Collections @@ -1296,175 +1286,6 @@ private constructor( override fun toString() = value.toString() } - /** The configuration for the rate of the price currency to the invoicing currency. */ - @JsonDeserialize(using = ConversionRateConfig.Deserializer::class) - @JsonSerialize(using = ConversionRateConfig.Serializer::class) - class ConversionRateConfig - private constructor( - private val unit: UnitConversionRateConfig? = null, - private val tiered: TieredConversionRateConfig? = null, - private val _json: JsonValue? = null, - ) { - - fun unit(): UnitConversionRateConfig? = unit - - fun tiered(): TieredConversionRateConfig? = tiered - - fun isUnit(): Boolean = unit != null - - fun isTiered(): Boolean = tiered != null - - fun asUnit(): UnitConversionRateConfig = unit.getOrThrow("unit") - - fun asTiered(): TieredConversionRateConfig = tiered.getOrThrow("tiered") - - fun _json(): JsonValue? = _json - - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): ConversionRateConfig = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) { - unit.validate() - } - - override fun visitTiered(tiered: TieredConversionRateConfig) { - tiered.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) = unit.validity() - - override fun visitTiered(tiered: TieredConversionRateConfig) = tiered.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered - } - - override fun hashCode(): Int = Objects.hash(unit, tiered) - - override fun toString(): String = - when { - unit != null -> "ConversionRateConfig{unit=$unit}" - tiered != null -> "ConversionRateConfig{tiered=$tiered}" - _json != null -> "ConversionRateConfig{_unknown=$_json}" - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - - companion object { - - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - fun ofTiered(tiered: TieredConversionRateConfig) = ConversionRateConfig(tiered = tiered) - } - - /** - * An interface that defines how to map each variant of [ConversionRateConfig] to a value of - * type [T]. - */ - interface Visitor { - - fun visitUnit(unit: UnitConversionRateConfig): T - - fun visitTiered(tiered: TieredConversionRateConfig): T - - /** - * Maps an unknown variant of [ConversionRateConfig] to a value of type [T]. - * - * An instance of [ConversionRateConfig] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if the SDK - * is on an older version than the API, then the API may respond with new variants that - * the SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown ConversionRateConfig: $json") - } - } - - internal class Deserializer : - BaseDeserializer(ConversionRateConfig::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): ConversionRateConfig { - val json = JsonValue.fromJsonNode(node) - val conversionRateType = json.asObject()?.get("conversion_rate_type")?.asString() - - when (conversionRateType) { - "unit" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(unit = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - "tiered" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(tiered = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - } - - return ConversionRateConfig(_json = json) - } - } - - internal class Serializer : - BaseSerializer(ConversionRateConfig::class) { - - override fun serialize( - value: ConversionRateConfig, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unit != null -> generator.writeObject(value.unit) - value.tiered != null -> generator.writeObject(value.tiered) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - } - } - } - /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingGroupedWithProratedMinimumPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingGroupedWithProratedMinimumPrice.kt index 915ec4bf3..eb04b2c67 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingGroupedWithProratedMinimumPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingGroupedWithProratedMinimumPrice.kt @@ -6,22 +6,12 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.withorb.api.core.BaseDeserializer -import com.withorb.api.core.BaseSerializer import com.withorb.api.core.Enum import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.checkRequired -import com.withorb.api.core.getOrThrow import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import java.util.Collections @@ -1296,175 +1286,6 @@ private constructor( override fun toString() = value.toString() } - /** The configuration for the rate of the price currency to the invoicing currency. */ - @JsonDeserialize(using = ConversionRateConfig.Deserializer::class) - @JsonSerialize(using = ConversionRateConfig.Serializer::class) - class ConversionRateConfig - private constructor( - private val unit: UnitConversionRateConfig? = null, - private val tiered: TieredConversionRateConfig? = null, - private val _json: JsonValue? = null, - ) { - - fun unit(): UnitConversionRateConfig? = unit - - fun tiered(): TieredConversionRateConfig? = tiered - - fun isUnit(): Boolean = unit != null - - fun isTiered(): Boolean = tiered != null - - fun asUnit(): UnitConversionRateConfig = unit.getOrThrow("unit") - - fun asTiered(): TieredConversionRateConfig = tiered.getOrThrow("tiered") - - fun _json(): JsonValue? = _json - - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): ConversionRateConfig = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) { - unit.validate() - } - - override fun visitTiered(tiered: TieredConversionRateConfig) { - tiered.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) = unit.validity() - - override fun visitTiered(tiered: TieredConversionRateConfig) = tiered.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered - } - - override fun hashCode(): Int = Objects.hash(unit, tiered) - - override fun toString(): String = - when { - unit != null -> "ConversionRateConfig{unit=$unit}" - tiered != null -> "ConversionRateConfig{tiered=$tiered}" - _json != null -> "ConversionRateConfig{_unknown=$_json}" - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - - companion object { - - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - fun ofTiered(tiered: TieredConversionRateConfig) = ConversionRateConfig(tiered = tiered) - } - - /** - * An interface that defines how to map each variant of [ConversionRateConfig] to a value of - * type [T]. - */ - interface Visitor { - - fun visitUnit(unit: UnitConversionRateConfig): T - - fun visitTiered(tiered: TieredConversionRateConfig): T - - /** - * Maps an unknown variant of [ConversionRateConfig] to a value of type [T]. - * - * An instance of [ConversionRateConfig] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if the SDK - * is on an older version than the API, then the API may respond with new variants that - * the SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown ConversionRateConfig: $json") - } - } - - internal class Deserializer : - BaseDeserializer(ConversionRateConfig::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): ConversionRateConfig { - val json = JsonValue.fromJsonNode(node) - val conversionRateType = json.asObject()?.get("conversion_rate_type")?.asString() - - when (conversionRateType) { - "unit" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(unit = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - "tiered" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(tiered = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - } - - return ConversionRateConfig(_json = json) - } - } - - internal class Serializer : - BaseSerializer(ConversionRateConfig::class) { - - override fun serialize( - value: ConversionRateConfig, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unit != null -> generator.writeObject(value.unit) - value.tiered != null -> generator.writeObject(value.tiered) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - } - } - } - /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingMatrixPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingMatrixPrice.kt index 497fbaf52..146cca862 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingMatrixPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingMatrixPrice.kt @@ -6,22 +6,12 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.withorb.api.core.BaseDeserializer -import com.withorb.api.core.BaseSerializer import com.withorb.api.core.Enum import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.checkRequired -import com.withorb.api.core.getOrThrow import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import java.util.Collections @@ -1176,175 +1166,6 @@ private constructor( override fun toString() = value.toString() } - /** The configuration for the rate of the price currency to the invoicing currency. */ - @JsonDeserialize(using = ConversionRateConfig.Deserializer::class) - @JsonSerialize(using = ConversionRateConfig.Serializer::class) - class ConversionRateConfig - private constructor( - private val unit: UnitConversionRateConfig? = null, - private val tiered: TieredConversionRateConfig? = null, - private val _json: JsonValue? = null, - ) { - - fun unit(): UnitConversionRateConfig? = unit - - fun tiered(): TieredConversionRateConfig? = tiered - - fun isUnit(): Boolean = unit != null - - fun isTiered(): Boolean = tiered != null - - fun asUnit(): UnitConversionRateConfig = unit.getOrThrow("unit") - - fun asTiered(): TieredConversionRateConfig = tiered.getOrThrow("tiered") - - fun _json(): JsonValue? = _json - - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): ConversionRateConfig = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) { - unit.validate() - } - - override fun visitTiered(tiered: TieredConversionRateConfig) { - tiered.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) = unit.validity() - - override fun visitTiered(tiered: TieredConversionRateConfig) = tiered.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered - } - - override fun hashCode(): Int = Objects.hash(unit, tiered) - - override fun toString(): String = - when { - unit != null -> "ConversionRateConfig{unit=$unit}" - tiered != null -> "ConversionRateConfig{tiered=$tiered}" - _json != null -> "ConversionRateConfig{_unknown=$_json}" - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - - companion object { - - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - fun ofTiered(tiered: TieredConversionRateConfig) = ConversionRateConfig(tiered = tiered) - } - - /** - * An interface that defines how to map each variant of [ConversionRateConfig] to a value of - * type [T]. - */ - interface Visitor { - - fun visitUnit(unit: UnitConversionRateConfig): T - - fun visitTiered(tiered: TieredConversionRateConfig): T - - /** - * Maps an unknown variant of [ConversionRateConfig] to a value of type [T]. - * - * An instance of [ConversionRateConfig] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if the SDK - * is on an older version than the API, then the API may respond with new variants that - * the SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown ConversionRateConfig: $json") - } - } - - internal class Deserializer : - BaseDeserializer(ConversionRateConfig::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): ConversionRateConfig { - val json = JsonValue.fromJsonNode(node) - val conversionRateType = json.asObject()?.get("conversion_rate_type")?.asString() - - when (conversionRateType) { - "unit" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(unit = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - "tiered" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(tiered = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - } - - return ConversionRateConfig(_json = json) - } - } - - internal class Serializer : - BaseSerializer(ConversionRateConfig::class) { - - override fun serialize( - value: ConversionRateConfig, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unit != null -> generator.writeObject(value.unit) - value.tiered != null -> generator.writeObject(value.tiered) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - } - } - } - /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingMatrixWithAllocationPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingMatrixWithAllocationPrice.kt index 8c018c0b1..6bb525f1b 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingMatrixWithAllocationPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingMatrixWithAllocationPrice.kt @@ -6,22 +6,12 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.withorb.api.core.BaseDeserializer -import com.withorb.api.core.BaseSerializer import com.withorb.api.core.Enum import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.checkRequired -import com.withorb.api.core.getOrThrow import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import java.util.Collections @@ -1188,175 +1178,6 @@ private constructor( override fun toString() = value.toString() } - /** The configuration for the rate of the price currency to the invoicing currency. */ - @JsonDeserialize(using = ConversionRateConfig.Deserializer::class) - @JsonSerialize(using = ConversionRateConfig.Serializer::class) - class ConversionRateConfig - private constructor( - private val unit: UnitConversionRateConfig? = null, - private val tiered: TieredConversionRateConfig? = null, - private val _json: JsonValue? = null, - ) { - - fun unit(): UnitConversionRateConfig? = unit - - fun tiered(): TieredConversionRateConfig? = tiered - - fun isUnit(): Boolean = unit != null - - fun isTiered(): Boolean = tiered != null - - fun asUnit(): UnitConversionRateConfig = unit.getOrThrow("unit") - - fun asTiered(): TieredConversionRateConfig = tiered.getOrThrow("tiered") - - fun _json(): JsonValue? = _json - - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): ConversionRateConfig = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) { - unit.validate() - } - - override fun visitTiered(tiered: TieredConversionRateConfig) { - tiered.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) = unit.validity() - - override fun visitTiered(tiered: TieredConversionRateConfig) = tiered.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered - } - - override fun hashCode(): Int = Objects.hash(unit, tiered) - - override fun toString(): String = - when { - unit != null -> "ConversionRateConfig{unit=$unit}" - tiered != null -> "ConversionRateConfig{tiered=$tiered}" - _json != null -> "ConversionRateConfig{_unknown=$_json}" - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - - companion object { - - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - fun ofTiered(tiered: TieredConversionRateConfig) = ConversionRateConfig(tiered = tiered) - } - - /** - * An interface that defines how to map each variant of [ConversionRateConfig] to a value of - * type [T]. - */ - interface Visitor { - - fun visitUnit(unit: UnitConversionRateConfig): T - - fun visitTiered(tiered: TieredConversionRateConfig): T - - /** - * Maps an unknown variant of [ConversionRateConfig] to a value of type [T]. - * - * An instance of [ConversionRateConfig] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if the SDK - * is on an older version than the API, then the API may respond with new variants that - * the SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown ConversionRateConfig: $json") - } - } - - internal class Deserializer : - BaseDeserializer(ConversionRateConfig::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): ConversionRateConfig { - val json = JsonValue.fromJsonNode(node) - val conversionRateType = json.asObject()?.get("conversion_rate_type")?.asString() - - when (conversionRateType) { - "unit" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(unit = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - "tiered" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(tiered = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - } - - return ConversionRateConfig(_json = json) - } - } - - internal class Serializer : - BaseSerializer(ConversionRateConfig::class) { - - override fun serialize( - value: ConversionRateConfig, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unit != null -> generator.writeObject(value.unit) - value.tiered != null -> generator.writeObject(value.tiered) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - } - } - } - /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingMatrixWithDisplayNamePrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingMatrixWithDisplayNamePrice.kt index 91e8dca2d..55d03bd70 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingMatrixWithDisplayNamePrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingMatrixWithDisplayNamePrice.kt @@ -6,22 +6,12 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.withorb.api.core.BaseDeserializer -import com.withorb.api.core.BaseSerializer import com.withorb.api.core.Enum import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.checkRequired -import com.withorb.api.core.getOrThrow import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import java.util.Collections @@ -1292,175 +1282,6 @@ private constructor( override fun toString() = value.toString() } - /** The configuration for the rate of the price currency to the invoicing currency. */ - @JsonDeserialize(using = ConversionRateConfig.Deserializer::class) - @JsonSerialize(using = ConversionRateConfig.Serializer::class) - class ConversionRateConfig - private constructor( - private val unit: UnitConversionRateConfig? = null, - private val tiered: TieredConversionRateConfig? = null, - private val _json: JsonValue? = null, - ) { - - fun unit(): UnitConversionRateConfig? = unit - - fun tiered(): TieredConversionRateConfig? = tiered - - fun isUnit(): Boolean = unit != null - - fun isTiered(): Boolean = tiered != null - - fun asUnit(): UnitConversionRateConfig = unit.getOrThrow("unit") - - fun asTiered(): TieredConversionRateConfig = tiered.getOrThrow("tiered") - - fun _json(): JsonValue? = _json - - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): ConversionRateConfig = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) { - unit.validate() - } - - override fun visitTiered(tiered: TieredConversionRateConfig) { - tiered.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) = unit.validity() - - override fun visitTiered(tiered: TieredConversionRateConfig) = tiered.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered - } - - override fun hashCode(): Int = Objects.hash(unit, tiered) - - override fun toString(): String = - when { - unit != null -> "ConversionRateConfig{unit=$unit}" - tiered != null -> "ConversionRateConfig{tiered=$tiered}" - _json != null -> "ConversionRateConfig{_unknown=$_json}" - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - - companion object { - - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - fun ofTiered(tiered: TieredConversionRateConfig) = ConversionRateConfig(tiered = tiered) - } - - /** - * An interface that defines how to map each variant of [ConversionRateConfig] to a value of - * type [T]. - */ - interface Visitor { - - fun visitUnit(unit: UnitConversionRateConfig): T - - fun visitTiered(tiered: TieredConversionRateConfig): T - - /** - * Maps an unknown variant of [ConversionRateConfig] to a value of type [T]. - * - * An instance of [ConversionRateConfig] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if the SDK - * is on an older version than the API, then the API may respond with new variants that - * the SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown ConversionRateConfig: $json") - } - } - - internal class Deserializer : - BaseDeserializer(ConversionRateConfig::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): ConversionRateConfig { - val json = JsonValue.fromJsonNode(node) - val conversionRateType = json.asObject()?.get("conversion_rate_type")?.asString() - - when (conversionRateType) { - "unit" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(unit = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - "tiered" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(tiered = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - } - - return ConversionRateConfig(_json = json) - } - } - - internal class Serializer : - BaseSerializer(ConversionRateConfig::class) { - - override fun serialize( - value: ConversionRateConfig, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unit != null -> generator.writeObject(value.unit) - value.tiered != null -> generator.writeObject(value.tiered) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - } - } - } - /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingMaxGroupTieredPackagePrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingMaxGroupTieredPackagePrice.kt index b2e13658d..c61dc9fba 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingMaxGroupTieredPackagePrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingMaxGroupTieredPackagePrice.kt @@ -6,22 +6,12 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.withorb.api.core.BaseDeserializer -import com.withorb.api.core.BaseSerializer import com.withorb.api.core.Enum import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.checkRequired -import com.withorb.api.core.getOrThrow import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import java.util.Collections @@ -1292,175 +1282,6 @@ private constructor( override fun toString() = value.toString() } - /** The configuration for the rate of the price currency to the invoicing currency. */ - @JsonDeserialize(using = ConversionRateConfig.Deserializer::class) - @JsonSerialize(using = ConversionRateConfig.Serializer::class) - class ConversionRateConfig - private constructor( - private val unit: UnitConversionRateConfig? = null, - private val tiered: TieredConversionRateConfig? = null, - private val _json: JsonValue? = null, - ) { - - fun unit(): UnitConversionRateConfig? = unit - - fun tiered(): TieredConversionRateConfig? = tiered - - fun isUnit(): Boolean = unit != null - - fun isTiered(): Boolean = tiered != null - - fun asUnit(): UnitConversionRateConfig = unit.getOrThrow("unit") - - fun asTiered(): TieredConversionRateConfig = tiered.getOrThrow("tiered") - - fun _json(): JsonValue? = _json - - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): ConversionRateConfig = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) { - unit.validate() - } - - override fun visitTiered(tiered: TieredConversionRateConfig) { - tiered.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) = unit.validity() - - override fun visitTiered(tiered: TieredConversionRateConfig) = tiered.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered - } - - override fun hashCode(): Int = Objects.hash(unit, tiered) - - override fun toString(): String = - when { - unit != null -> "ConversionRateConfig{unit=$unit}" - tiered != null -> "ConversionRateConfig{tiered=$tiered}" - _json != null -> "ConversionRateConfig{_unknown=$_json}" - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - - companion object { - - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - fun ofTiered(tiered: TieredConversionRateConfig) = ConversionRateConfig(tiered = tiered) - } - - /** - * An interface that defines how to map each variant of [ConversionRateConfig] to a value of - * type [T]. - */ - interface Visitor { - - fun visitUnit(unit: UnitConversionRateConfig): T - - fun visitTiered(tiered: TieredConversionRateConfig): T - - /** - * Maps an unknown variant of [ConversionRateConfig] to a value of type [T]. - * - * An instance of [ConversionRateConfig] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if the SDK - * is on an older version than the API, then the API may respond with new variants that - * the SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown ConversionRateConfig: $json") - } - } - - internal class Deserializer : - BaseDeserializer(ConversionRateConfig::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): ConversionRateConfig { - val json = JsonValue.fromJsonNode(node) - val conversionRateType = json.asObject()?.get("conversion_rate_type")?.asString() - - when (conversionRateType) { - "unit" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(unit = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - "tiered" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(tiered = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - } - - return ConversionRateConfig(_json = json) - } - } - - internal class Serializer : - BaseSerializer(ConversionRateConfig::class) { - - override fun serialize( - value: ConversionRateConfig, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unit != null -> generator.writeObject(value.unit) - value.tiered != null -> generator.writeObject(value.tiered) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - } - } - } - /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingPackagePrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingPackagePrice.kt index ce425f3df..6c203872f 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingPackagePrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingPackagePrice.kt @@ -6,22 +6,12 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.withorb.api.core.BaseDeserializer -import com.withorb.api.core.BaseSerializer import com.withorb.api.core.Enum import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.checkRequired -import com.withorb.api.core.getOrThrow import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import java.util.Collections @@ -1176,175 +1166,6 @@ private constructor( override fun toString() = value.toString() } - /** The configuration for the rate of the price currency to the invoicing currency. */ - @JsonDeserialize(using = ConversionRateConfig.Deserializer::class) - @JsonSerialize(using = ConversionRateConfig.Serializer::class) - class ConversionRateConfig - private constructor( - private val unit: UnitConversionRateConfig? = null, - private val tiered: TieredConversionRateConfig? = null, - private val _json: JsonValue? = null, - ) { - - fun unit(): UnitConversionRateConfig? = unit - - fun tiered(): TieredConversionRateConfig? = tiered - - fun isUnit(): Boolean = unit != null - - fun isTiered(): Boolean = tiered != null - - fun asUnit(): UnitConversionRateConfig = unit.getOrThrow("unit") - - fun asTiered(): TieredConversionRateConfig = tiered.getOrThrow("tiered") - - fun _json(): JsonValue? = _json - - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): ConversionRateConfig = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) { - unit.validate() - } - - override fun visitTiered(tiered: TieredConversionRateConfig) { - tiered.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) = unit.validity() - - override fun visitTiered(tiered: TieredConversionRateConfig) = tiered.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered - } - - override fun hashCode(): Int = Objects.hash(unit, tiered) - - override fun toString(): String = - when { - unit != null -> "ConversionRateConfig{unit=$unit}" - tiered != null -> "ConversionRateConfig{tiered=$tiered}" - _json != null -> "ConversionRateConfig{_unknown=$_json}" - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - - companion object { - - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - fun ofTiered(tiered: TieredConversionRateConfig) = ConversionRateConfig(tiered = tiered) - } - - /** - * An interface that defines how to map each variant of [ConversionRateConfig] to a value of - * type [T]. - */ - interface Visitor { - - fun visitUnit(unit: UnitConversionRateConfig): T - - fun visitTiered(tiered: TieredConversionRateConfig): T - - /** - * Maps an unknown variant of [ConversionRateConfig] to a value of type [T]. - * - * An instance of [ConversionRateConfig] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if the SDK - * is on an older version than the API, then the API may respond with new variants that - * the SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown ConversionRateConfig: $json") - } - } - - internal class Deserializer : - BaseDeserializer(ConversionRateConfig::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): ConversionRateConfig { - val json = JsonValue.fromJsonNode(node) - val conversionRateType = json.asObject()?.get("conversion_rate_type")?.asString() - - when (conversionRateType) { - "unit" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(unit = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - "tiered" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(tiered = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - } - - return ConversionRateConfig(_json = json) - } - } - - internal class Serializer : - BaseSerializer(ConversionRateConfig::class) { - - override fun serialize( - value: ConversionRateConfig, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unit != null -> generator.writeObject(value.unit) - value.tiered != null -> generator.writeObject(value.tiered) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - } - } - } - /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingPackageWithAllocationPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingPackageWithAllocationPrice.kt index 50335e1c2..a593271f5 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingPackageWithAllocationPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingPackageWithAllocationPrice.kt @@ -6,22 +6,12 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.withorb.api.core.BaseDeserializer -import com.withorb.api.core.BaseSerializer import com.withorb.api.core.Enum import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.checkRequired -import com.withorb.api.core.getOrThrow import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import java.util.Collections @@ -1292,175 +1282,6 @@ private constructor( "PackageWithAllocationConfig{additionalProperties=$additionalProperties}" } - /** The configuration for the rate of the price currency to the invoicing currency. */ - @JsonDeserialize(using = ConversionRateConfig.Deserializer::class) - @JsonSerialize(using = ConversionRateConfig.Serializer::class) - class ConversionRateConfig - private constructor( - private val unit: UnitConversionRateConfig? = null, - private val tiered: TieredConversionRateConfig? = null, - private val _json: JsonValue? = null, - ) { - - fun unit(): UnitConversionRateConfig? = unit - - fun tiered(): TieredConversionRateConfig? = tiered - - fun isUnit(): Boolean = unit != null - - fun isTiered(): Boolean = tiered != null - - fun asUnit(): UnitConversionRateConfig = unit.getOrThrow("unit") - - fun asTiered(): TieredConversionRateConfig = tiered.getOrThrow("tiered") - - fun _json(): JsonValue? = _json - - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): ConversionRateConfig = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) { - unit.validate() - } - - override fun visitTiered(tiered: TieredConversionRateConfig) { - tiered.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) = unit.validity() - - override fun visitTiered(tiered: TieredConversionRateConfig) = tiered.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered - } - - override fun hashCode(): Int = Objects.hash(unit, tiered) - - override fun toString(): String = - when { - unit != null -> "ConversionRateConfig{unit=$unit}" - tiered != null -> "ConversionRateConfig{tiered=$tiered}" - _json != null -> "ConversionRateConfig{_unknown=$_json}" - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - - companion object { - - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - fun ofTiered(tiered: TieredConversionRateConfig) = ConversionRateConfig(tiered = tiered) - } - - /** - * An interface that defines how to map each variant of [ConversionRateConfig] to a value of - * type [T]. - */ - interface Visitor { - - fun visitUnit(unit: UnitConversionRateConfig): T - - fun visitTiered(tiered: TieredConversionRateConfig): T - - /** - * Maps an unknown variant of [ConversionRateConfig] to a value of type [T]. - * - * An instance of [ConversionRateConfig] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if the SDK - * is on an older version than the API, then the API may respond with new variants that - * the SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown ConversionRateConfig: $json") - } - } - - internal class Deserializer : - BaseDeserializer(ConversionRateConfig::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): ConversionRateConfig { - val json = JsonValue.fromJsonNode(node) - val conversionRateType = json.asObject()?.get("conversion_rate_type")?.asString() - - when (conversionRateType) { - "unit" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(unit = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - "tiered" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(tiered = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - } - - return ConversionRateConfig(_json = json) - } - } - - internal class Serializer : - BaseSerializer(ConversionRateConfig::class) { - - override fun serialize( - value: ConversionRateConfig, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unit != null -> generator.writeObject(value.unit) - value.tiered != null -> generator.writeObject(value.tiered) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - } - } - } - /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingScalableMatrixWithTieredPricingPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingScalableMatrixWithTieredPricingPrice.kt index 7a89c980d..981236464 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingScalableMatrixWithTieredPricingPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingScalableMatrixWithTieredPricingPrice.kt @@ -6,22 +6,12 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.withorb.api.core.BaseDeserializer -import com.withorb.api.core.BaseSerializer import com.withorb.api.core.Enum import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.checkRequired -import com.withorb.api.core.getOrThrow import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import java.util.Collections @@ -1312,175 +1302,6 @@ private constructor( "ScalableMatrixWithTieredPricingConfig{additionalProperties=$additionalProperties}" } - /** The configuration for the rate of the price currency to the invoicing currency. */ - @JsonDeserialize(using = ConversionRateConfig.Deserializer::class) - @JsonSerialize(using = ConversionRateConfig.Serializer::class) - class ConversionRateConfig - private constructor( - private val unit: UnitConversionRateConfig? = null, - private val tiered: TieredConversionRateConfig? = null, - private val _json: JsonValue? = null, - ) { - - fun unit(): UnitConversionRateConfig? = unit - - fun tiered(): TieredConversionRateConfig? = tiered - - fun isUnit(): Boolean = unit != null - - fun isTiered(): Boolean = tiered != null - - fun asUnit(): UnitConversionRateConfig = unit.getOrThrow("unit") - - fun asTiered(): TieredConversionRateConfig = tiered.getOrThrow("tiered") - - fun _json(): JsonValue? = _json - - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): ConversionRateConfig = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) { - unit.validate() - } - - override fun visitTiered(tiered: TieredConversionRateConfig) { - tiered.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) = unit.validity() - - override fun visitTiered(tiered: TieredConversionRateConfig) = tiered.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered - } - - override fun hashCode(): Int = Objects.hash(unit, tiered) - - override fun toString(): String = - when { - unit != null -> "ConversionRateConfig{unit=$unit}" - tiered != null -> "ConversionRateConfig{tiered=$tiered}" - _json != null -> "ConversionRateConfig{_unknown=$_json}" - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - - companion object { - - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - fun ofTiered(tiered: TieredConversionRateConfig) = ConversionRateConfig(tiered = tiered) - } - - /** - * An interface that defines how to map each variant of [ConversionRateConfig] to a value of - * type [T]. - */ - interface Visitor { - - fun visitUnit(unit: UnitConversionRateConfig): T - - fun visitTiered(tiered: TieredConversionRateConfig): T - - /** - * Maps an unknown variant of [ConversionRateConfig] to a value of type [T]. - * - * An instance of [ConversionRateConfig] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if the SDK - * is on an older version than the API, then the API may respond with new variants that - * the SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown ConversionRateConfig: $json") - } - } - - internal class Deserializer : - BaseDeserializer(ConversionRateConfig::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): ConversionRateConfig { - val json = JsonValue.fromJsonNode(node) - val conversionRateType = json.asObject()?.get("conversion_rate_type")?.asString() - - when (conversionRateType) { - "unit" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(unit = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - "tiered" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(tiered = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - } - - return ConversionRateConfig(_json = json) - } - } - - internal class Serializer : - BaseSerializer(ConversionRateConfig::class) { - - override fun serialize( - value: ConversionRateConfig, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unit != null -> generator.writeObject(value.unit) - value.tiered != null -> generator.writeObject(value.tiered) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - } - } - } - /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingScalableMatrixWithUnitPricingPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingScalableMatrixWithUnitPricingPrice.kt index 0313943f6..31f555d72 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingScalableMatrixWithUnitPricingPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingScalableMatrixWithUnitPricingPrice.kt @@ -6,22 +6,12 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.withorb.api.core.BaseDeserializer -import com.withorb.api.core.BaseSerializer import com.withorb.api.core.Enum import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.checkRequired -import com.withorb.api.core.getOrThrow import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import java.util.Collections @@ -1303,175 +1293,6 @@ private constructor( "ScalableMatrixWithUnitPricingConfig{additionalProperties=$additionalProperties}" } - /** The configuration for the rate of the price currency to the invoicing currency. */ - @JsonDeserialize(using = ConversionRateConfig.Deserializer::class) - @JsonSerialize(using = ConversionRateConfig.Serializer::class) - class ConversionRateConfig - private constructor( - private val unit: UnitConversionRateConfig? = null, - private val tiered: TieredConversionRateConfig? = null, - private val _json: JsonValue? = null, - ) { - - fun unit(): UnitConversionRateConfig? = unit - - fun tiered(): TieredConversionRateConfig? = tiered - - fun isUnit(): Boolean = unit != null - - fun isTiered(): Boolean = tiered != null - - fun asUnit(): UnitConversionRateConfig = unit.getOrThrow("unit") - - fun asTiered(): TieredConversionRateConfig = tiered.getOrThrow("tiered") - - fun _json(): JsonValue? = _json - - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): ConversionRateConfig = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) { - unit.validate() - } - - override fun visitTiered(tiered: TieredConversionRateConfig) { - tiered.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) = unit.validity() - - override fun visitTiered(tiered: TieredConversionRateConfig) = tiered.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered - } - - override fun hashCode(): Int = Objects.hash(unit, tiered) - - override fun toString(): String = - when { - unit != null -> "ConversionRateConfig{unit=$unit}" - tiered != null -> "ConversionRateConfig{tiered=$tiered}" - _json != null -> "ConversionRateConfig{_unknown=$_json}" - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - - companion object { - - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - fun ofTiered(tiered: TieredConversionRateConfig) = ConversionRateConfig(tiered = tiered) - } - - /** - * An interface that defines how to map each variant of [ConversionRateConfig] to a value of - * type [T]. - */ - interface Visitor { - - fun visitUnit(unit: UnitConversionRateConfig): T - - fun visitTiered(tiered: TieredConversionRateConfig): T - - /** - * Maps an unknown variant of [ConversionRateConfig] to a value of type [T]. - * - * An instance of [ConversionRateConfig] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if the SDK - * is on an older version than the API, then the API may respond with new variants that - * the SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown ConversionRateConfig: $json") - } - } - - internal class Deserializer : - BaseDeserializer(ConversionRateConfig::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): ConversionRateConfig { - val json = JsonValue.fromJsonNode(node) - val conversionRateType = json.asObject()?.get("conversion_rate_type")?.asString() - - when (conversionRateType) { - "unit" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(unit = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - "tiered" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(tiered = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - } - - return ConversionRateConfig(_json = json) - } - } - - internal class Serializer : - BaseSerializer(ConversionRateConfig::class) { - - override fun serialize( - value: ConversionRateConfig, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unit != null -> generator.writeObject(value.unit) - value.tiered != null -> generator.writeObject(value.tiered) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - } - } - } - /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingThresholdTotalAmountPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingThresholdTotalAmountPrice.kt index 0632badbc..1fdcd6ec3 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingThresholdTotalAmountPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingThresholdTotalAmountPrice.kt @@ -6,22 +6,12 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.withorb.api.core.BaseDeserializer -import com.withorb.api.core.BaseSerializer import com.withorb.api.core.Enum import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.checkRequired -import com.withorb.api.core.getOrThrow import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import java.util.Collections @@ -1292,175 +1282,6 @@ private constructor( "ThresholdTotalAmountConfig{additionalProperties=$additionalProperties}" } - /** The configuration for the rate of the price currency to the invoicing currency. */ - @JsonDeserialize(using = ConversionRateConfig.Deserializer::class) - @JsonSerialize(using = ConversionRateConfig.Serializer::class) - class ConversionRateConfig - private constructor( - private val unit: UnitConversionRateConfig? = null, - private val tiered: TieredConversionRateConfig? = null, - private val _json: JsonValue? = null, - ) { - - fun unit(): UnitConversionRateConfig? = unit - - fun tiered(): TieredConversionRateConfig? = tiered - - fun isUnit(): Boolean = unit != null - - fun isTiered(): Boolean = tiered != null - - fun asUnit(): UnitConversionRateConfig = unit.getOrThrow("unit") - - fun asTiered(): TieredConversionRateConfig = tiered.getOrThrow("tiered") - - fun _json(): JsonValue? = _json - - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): ConversionRateConfig = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) { - unit.validate() - } - - override fun visitTiered(tiered: TieredConversionRateConfig) { - tiered.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) = unit.validity() - - override fun visitTiered(tiered: TieredConversionRateConfig) = tiered.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered - } - - override fun hashCode(): Int = Objects.hash(unit, tiered) - - override fun toString(): String = - when { - unit != null -> "ConversionRateConfig{unit=$unit}" - tiered != null -> "ConversionRateConfig{tiered=$tiered}" - _json != null -> "ConversionRateConfig{_unknown=$_json}" - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - - companion object { - - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - fun ofTiered(tiered: TieredConversionRateConfig) = ConversionRateConfig(tiered = tiered) - } - - /** - * An interface that defines how to map each variant of [ConversionRateConfig] to a value of - * type [T]. - */ - interface Visitor { - - fun visitUnit(unit: UnitConversionRateConfig): T - - fun visitTiered(tiered: TieredConversionRateConfig): T - - /** - * Maps an unknown variant of [ConversionRateConfig] to a value of type [T]. - * - * An instance of [ConversionRateConfig] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if the SDK - * is on an older version than the API, then the API may respond with new variants that - * the SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown ConversionRateConfig: $json") - } - } - - internal class Deserializer : - BaseDeserializer(ConversionRateConfig::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): ConversionRateConfig { - val json = JsonValue.fromJsonNode(node) - val conversionRateType = json.asObject()?.get("conversion_rate_type")?.asString() - - when (conversionRateType) { - "unit" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(unit = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - "tiered" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(tiered = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - } - - return ConversionRateConfig(_json = json) - } - } - - internal class Serializer : - BaseSerializer(ConversionRateConfig::class) { - - override fun serialize( - value: ConversionRateConfig, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unit != null -> generator.writeObject(value.unit) - value.tiered != null -> generator.writeObject(value.tiered) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - } - } - } - /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredBpsPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredBpsPrice.kt index 976db66d1..c8b790bdf 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredBpsPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredBpsPrice.kt @@ -6,22 +6,12 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.withorb.api.core.BaseDeserializer -import com.withorb.api.core.BaseSerializer import com.withorb.api.core.Enum import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.checkRequired -import com.withorb.api.core.getOrThrow import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import java.util.Collections @@ -1177,175 +1167,6 @@ private constructor( override fun toString() = value.toString() } - /** The configuration for the rate of the price currency to the invoicing currency. */ - @JsonDeserialize(using = ConversionRateConfig.Deserializer::class) - @JsonSerialize(using = ConversionRateConfig.Serializer::class) - class ConversionRateConfig - private constructor( - private val unit: UnitConversionRateConfig? = null, - private val tiered: TieredConversionRateConfig? = null, - private val _json: JsonValue? = null, - ) { - - fun unit(): UnitConversionRateConfig? = unit - - fun tiered(): TieredConversionRateConfig? = tiered - - fun isUnit(): Boolean = unit != null - - fun isTiered(): Boolean = tiered != null - - fun asUnit(): UnitConversionRateConfig = unit.getOrThrow("unit") - - fun asTiered(): TieredConversionRateConfig = tiered.getOrThrow("tiered") - - fun _json(): JsonValue? = _json - - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): ConversionRateConfig = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) { - unit.validate() - } - - override fun visitTiered(tiered: TieredConversionRateConfig) { - tiered.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) = unit.validity() - - override fun visitTiered(tiered: TieredConversionRateConfig) = tiered.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered - } - - override fun hashCode(): Int = Objects.hash(unit, tiered) - - override fun toString(): String = - when { - unit != null -> "ConversionRateConfig{unit=$unit}" - tiered != null -> "ConversionRateConfig{tiered=$tiered}" - _json != null -> "ConversionRateConfig{_unknown=$_json}" - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - - companion object { - - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - fun ofTiered(tiered: TieredConversionRateConfig) = ConversionRateConfig(tiered = tiered) - } - - /** - * An interface that defines how to map each variant of [ConversionRateConfig] to a value of - * type [T]. - */ - interface Visitor { - - fun visitUnit(unit: UnitConversionRateConfig): T - - fun visitTiered(tiered: TieredConversionRateConfig): T - - /** - * Maps an unknown variant of [ConversionRateConfig] to a value of type [T]. - * - * An instance of [ConversionRateConfig] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if the SDK - * is on an older version than the API, then the API may respond with new variants that - * the SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown ConversionRateConfig: $json") - } - } - - internal class Deserializer : - BaseDeserializer(ConversionRateConfig::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): ConversionRateConfig { - val json = JsonValue.fromJsonNode(node) - val conversionRateType = json.asObject()?.get("conversion_rate_type")?.asString() - - when (conversionRateType) { - "unit" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(unit = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - "tiered" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(tiered = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - } - - return ConversionRateConfig(_json = json) - } - } - - internal class Serializer : - BaseSerializer(ConversionRateConfig::class) { - - override fun serialize( - value: ConversionRateConfig, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unit != null -> generator.writeObject(value.unit) - value.tiered != null -> generator.writeObject(value.tiered) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - } - } - } - /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredPackagePrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredPackagePrice.kt index be0a54f7c..219be74ae 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredPackagePrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredPackagePrice.kt @@ -6,22 +6,12 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.withorb.api.core.BaseDeserializer -import com.withorb.api.core.BaseSerializer import com.withorb.api.core.Enum import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.checkRequired -import com.withorb.api.core.getOrThrow import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import java.util.Collections @@ -1280,175 +1270,6 @@ private constructor( override fun toString() = "TieredPackageConfig{additionalProperties=$additionalProperties}" } - /** The configuration for the rate of the price currency to the invoicing currency. */ - @JsonDeserialize(using = ConversionRateConfig.Deserializer::class) - @JsonSerialize(using = ConversionRateConfig.Serializer::class) - class ConversionRateConfig - private constructor( - private val unit: UnitConversionRateConfig? = null, - private val tiered: TieredConversionRateConfig? = null, - private val _json: JsonValue? = null, - ) { - - fun unit(): UnitConversionRateConfig? = unit - - fun tiered(): TieredConversionRateConfig? = tiered - - fun isUnit(): Boolean = unit != null - - fun isTiered(): Boolean = tiered != null - - fun asUnit(): UnitConversionRateConfig = unit.getOrThrow("unit") - - fun asTiered(): TieredConversionRateConfig = tiered.getOrThrow("tiered") - - fun _json(): JsonValue? = _json - - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): ConversionRateConfig = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) { - unit.validate() - } - - override fun visitTiered(tiered: TieredConversionRateConfig) { - tiered.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) = unit.validity() - - override fun visitTiered(tiered: TieredConversionRateConfig) = tiered.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered - } - - override fun hashCode(): Int = Objects.hash(unit, tiered) - - override fun toString(): String = - when { - unit != null -> "ConversionRateConfig{unit=$unit}" - tiered != null -> "ConversionRateConfig{tiered=$tiered}" - _json != null -> "ConversionRateConfig{_unknown=$_json}" - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - - companion object { - - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - fun ofTiered(tiered: TieredConversionRateConfig) = ConversionRateConfig(tiered = tiered) - } - - /** - * An interface that defines how to map each variant of [ConversionRateConfig] to a value of - * type [T]. - */ - interface Visitor { - - fun visitUnit(unit: UnitConversionRateConfig): T - - fun visitTiered(tiered: TieredConversionRateConfig): T - - /** - * Maps an unknown variant of [ConversionRateConfig] to a value of type [T]. - * - * An instance of [ConversionRateConfig] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if the SDK - * is on an older version than the API, then the API may respond with new variants that - * the SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown ConversionRateConfig: $json") - } - } - - internal class Deserializer : - BaseDeserializer(ConversionRateConfig::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): ConversionRateConfig { - val json = JsonValue.fromJsonNode(node) - val conversionRateType = json.asObject()?.get("conversion_rate_type")?.asString() - - when (conversionRateType) { - "unit" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(unit = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - "tiered" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(tiered = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - } - - return ConversionRateConfig(_json = json) - } - } - - internal class Serializer : - BaseSerializer(ConversionRateConfig::class) { - - override fun serialize( - value: ConversionRateConfig, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unit != null -> generator.writeObject(value.unit) - value.tiered != null -> generator.writeObject(value.tiered) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - } - } - } - /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredPackageWithMinimumPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredPackageWithMinimumPrice.kt index 0fa7d9f4b..2d3895f26 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredPackageWithMinimumPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredPackageWithMinimumPrice.kt @@ -6,22 +6,12 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.withorb.api.core.BaseDeserializer -import com.withorb.api.core.BaseSerializer import com.withorb.api.core.Enum import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.checkRequired -import com.withorb.api.core.getOrThrow import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import java.util.Collections @@ -1296,175 +1286,6 @@ private constructor( "TieredPackageWithMinimumConfig{additionalProperties=$additionalProperties}" } - /** The configuration for the rate of the price currency to the invoicing currency. */ - @JsonDeserialize(using = ConversionRateConfig.Deserializer::class) - @JsonSerialize(using = ConversionRateConfig.Serializer::class) - class ConversionRateConfig - private constructor( - private val unit: UnitConversionRateConfig? = null, - private val tiered: TieredConversionRateConfig? = null, - private val _json: JsonValue? = null, - ) { - - fun unit(): UnitConversionRateConfig? = unit - - fun tiered(): TieredConversionRateConfig? = tiered - - fun isUnit(): Boolean = unit != null - - fun isTiered(): Boolean = tiered != null - - fun asUnit(): UnitConversionRateConfig = unit.getOrThrow("unit") - - fun asTiered(): TieredConversionRateConfig = tiered.getOrThrow("tiered") - - fun _json(): JsonValue? = _json - - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): ConversionRateConfig = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) { - unit.validate() - } - - override fun visitTiered(tiered: TieredConversionRateConfig) { - tiered.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) = unit.validity() - - override fun visitTiered(tiered: TieredConversionRateConfig) = tiered.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered - } - - override fun hashCode(): Int = Objects.hash(unit, tiered) - - override fun toString(): String = - when { - unit != null -> "ConversionRateConfig{unit=$unit}" - tiered != null -> "ConversionRateConfig{tiered=$tiered}" - _json != null -> "ConversionRateConfig{_unknown=$_json}" - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - - companion object { - - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - fun ofTiered(tiered: TieredConversionRateConfig) = ConversionRateConfig(tiered = tiered) - } - - /** - * An interface that defines how to map each variant of [ConversionRateConfig] to a value of - * type [T]. - */ - interface Visitor { - - fun visitUnit(unit: UnitConversionRateConfig): T - - fun visitTiered(tiered: TieredConversionRateConfig): T - - /** - * Maps an unknown variant of [ConversionRateConfig] to a value of type [T]. - * - * An instance of [ConversionRateConfig] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if the SDK - * is on an older version than the API, then the API may respond with new variants that - * the SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown ConversionRateConfig: $json") - } - } - - internal class Deserializer : - BaseDeserializer(ConversionRateConfig::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): ConversionRateConfig { - val json = JsonValue.fromJsonNode(node) - val conversionRateType = json.asObject()?.get("conversion_rate_type")?.asString() - - when (conversionRateType) { - "unit" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(unit = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - "tiered" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(tiered = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - } - - return ConversionRateConfig(_json = json) - } - } - - internal class Serializer : - BaseSerializer(ConversionRateConfig::class) { - - override fun serialize( - value: ConversionRateConfig, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unit != null -> generator.writeObject(value.unit) - value.tiered != null -> generator.writeObject(value.tiered) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - } - } - } - /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredPrice.kt index 6ad24e00b..a81bac049 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredPrice.kt @@ -6,22 +6,12 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.withorb.api.core.BaseDeserializer -import com.withorb.api.core.BaseSerializer import com.withorb.api.core.Enum import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.checkRequired -import com.withorb.api.core.getOrThrow import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import java.util.Collections @@ -1176,175 +1166,6 @@ private constructor( override fun toString() = value.toString() } - /** The configuration for the rate of the price currency to the invoicing currency. */ - @JsonDeserialize(using = ConversionRateConfig.Deserializer::class) - @JsonSerialize(using = ConversionRateConfig.Serializer::class) - class ConversionRateConfig - private constructor( - private val unit: UnitConversionRateConfig? = null, - private val tiered: TieredConversionRateConfig? = null, - private val _json: JsonValue? = null, - ) { - - fun unit(): UnitConversionRateConfig? = unit - - fun tiered(): TieredConversionRateConfig? = tiered - - fun isUnit(): Boolean = unit != null - - fun isTiered(): Boolean = tiered != null - - fun asUnit(): UnitConversionRateConfig = unit.getOrThrow("unit") - - fun asTiered(): TieredConversionRateConfig = tiered.getOrThrow("tiered") - - fun _json(): JsonValue? = _json - - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): ConversionRateConfig = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) { - unit.validate() - } - - override fun visitTiered(tiered: TieredConversionRateConfig) { - tiered.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) = unit.validity() - - override fun visitTiered(tiered: TieredConversionRateConfig) = tiered.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered - } - - override fun hashCode(): Int = Objects.hash(unit, tiered) - - override fun toString(): String = - when { - unit != null -> "ConversionRateConfig{unit=$unit}" - tiered != null -> "ConversionRateConfig{tiered=$tiered}" - _json != null -> "ConversionRateConfig{_unknown=$_json}" - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - - companion object { - - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - fun ofTiered(tiered: TieredConversionRateConfig) = ConversionRateConfig(tiered = tiered) - } - - /** - * An interface that defines how to map each variant of [ConversionRateConfig] to a value of - * type [T]. - */ - interface Visitor { - - fun visitUnit(unit: UnitConversionRateConfig): T - - fun visitTiered(tiered: TieredConversionRateConfig): T - - /** - * Maps an unknown variant of [ConversionRateConfig] to a value of type [T]. - * - * An instance of [ConversionRateConfig] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if the SDK - * is on an older version than the API, then the API may respond with new variants that - * the SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown ConversionRateConfig: $json") - } - } - - internal class Deserializer : - BaseDeserializer(ConversionRateConfig::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): ConversionRateConfig { - val json = JsonValue.fromJsonNode(node) - val conversionRateType = json.asObject()?.get("conversion_rate_type")?.asString() - - when (conversionRateType) { - "unit" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(unit = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - "tiered" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(tiered = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - } - - return ConversionRateConfig(_json = json) - } - } - - internal class Serializer : - BaseSerializer(ConversionRateConfig::class) { - - override fun serialize( - value: ConversionRateConfig, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unit != null -> generator.writeObject(value.unit) - value.tiered != null -> generator.writeObject(value.tiered) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - } - } - } - /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredWithMinimumPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredWithMinimumPrice.kt index fbc50c8d1..7536c9c30 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredWithMinimumPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredWithMinimumPrice.kt @@ -6,22 +6,12 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.withorb.api.core.BaseDeserializer -import com.withorb.api.core.BaseSerializer import com.withorb.api.core.Enum import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.checkRequired -import com.withorb.api.core.getOrThrow import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import java.util.Collections @@ -1288,175 +1278,6 @@ private constructor( "TieredWithMinimumConfig{additionalProperties=$additionalProperties}" } - /** The configuration for the rate of the price currency to the invoicing currency. */ - @JsonDeserialize(using = ConversionRateConfig.Deserializer::class) - @JsonSerialize(using = ConversionRateConfig.Serializer::class) - class ConversionRateConfig - private constructor( - private val unit: UnitConversionRateConfig? = null, - private val tiered: TieredConversionRateConfig? = null, - private val _json: JsonValue? = null, - ) { - - fun unit(): UnitConversionRateConfig? = unit - - fun tiered(): TieredConversionRateConfig? = tiered - - fun isUnit(): Boolean = unit != null - - fun isTiered(): Boolean = tiered != null - - fun asUnit(): UnitConversionRateConfig = unit.getOrThrow("unit") - - fun asTiered(): TieredConversionRateConfig = tiered.getOrThrow("tiered") - - fun _json(): JsonValue? = _json - - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): ConversionRateConfig = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) { - unit.validate() - } - - override fun visitTiered(tiered: TieredConversionRateConfig) { - tiered.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) = unit.validity() - - override fun visitTiered(tiered: TieredConversionRateConfig) = tiered.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered - } - - override fun hashCode(): Int = Objects.hash(unit, tiered) - - override fun toString(): String = - when { - unit != null -> "ConversionRateConfig{unit=$unit}" - tiered != null -> "ConversionRateConfig{tiered=$tiered}" - _json != null -> "ConversionRateConfig{_unknown=$_json}" - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - - companion object { - - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - fun ofTiered(tiered: TieredConversionRateConfig) = ConversionRateConfig(tiered = tiered) - } - - /** - * An interface that defines how to map each variant of [ConversionRateConfig] to a value of - * type [T]. - */ - interface Visitor { - - fun visitUnit(unit: UnitConversionRateConfig): T - - fun visitTiered(tiered: TieredConversionRateConfig): T - - /** - * Maps an unknown variant of [ConversionRateConfig] to a value of type [T]. - * - * An instance of [ConversionRateConfig] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if the SDK - * is on an older version than the API, then the API may respond with new variants that - * the SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown ConversionRateConfig: $json") - } - } - - internal class Deserializer : - BaseDeserializer(ConversionRateConfig::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): ConversionRateConfig { - val json = JsonValue.fromJsonNode(node) - val conversionRateType = json.asObject()?.get("conversion_rate_type")?.asString() - - when (conversionRateType) { - "unit" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(unit = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - "tiered" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(tiered = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - } - - return ConversionRateConfig(_json = json) - } - } - - internal class Serializer : - BaseSerializer(ConversionRateConfig::class) { - - override fun serialize( - value: ConversionRateConfig, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unit != null -> generator.writeObject(value.unit) - value.tiered != null -> generator.writeObject(value.tiered) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - } - } - } - /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredWithProrationPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredWithProrationPrice.kt index 8a92a0e7d..94864ca08 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredWithProrationPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredWithProrationPrice.kt @@ -6,22 +6,12 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.withorb.api.core.BaseDeserializer -import com.withorb.api.core.BaseSerializer import com.withorb.api.core.Enum import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.checkRequired -import com.withorb.api.core.getOrThrow import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import java.util.Collections @@ -1291,175 +1281,6 @@ private constructor( "TieredWithProrationConfig{additionalProperties=$additionalProperties}" } - /** The configuration for the rate of the price currency to the invoicing currency. */ - @JsonDeserialize(using = ConversionRateConfig.Deserializer::class) - @JsonSerialize(using = ConversionRateConfig.Serializer::class) - class ConversionRateConfig - private constructor( - private val unit: UnitConversionRateConfig? = null, - private val tiered: TieredConversionRateConfig? = null, - private val _json: JsonValue? = null, - ) { - - fun unit(): UnitConversionRateConfig? = unit - - fun tiered(): TieredConversionRateConfig? = tiered - - fun isUnit(): Boolean = unit != null - - fun isTiered(): Boolean = tiered != null - - fun asUnit(): UnitConversionRateConfig = unit.getOrThrow("unit") - - fun asTiered(): TieredConversionRateConfig = tiered.getOrThrow("tiered") - - fun _json(): JsonValue? = _json - - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): ConversionRateConfig = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) { - unit.validate() - } - - override fun visitTiered(tiered: TieredConversionRateConfig) { - tiered.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) = unit.validity() - - override fun visitTiered(tiered: TieredConversionRateConfig) = tiered.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered - } - - override fun hashCode(): Int = Objects.hash(unit, tiered) - - override fun toString(): String = - when { - unit != null -> "ConversionRateConfig{unit=$unit}" - tiered != null -> "ConversionRateConfig{tiered=$tiered}" - _json != null -> "ConversionRateConfig{_unknown=$_json}" - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - - companion object { - - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - fun ofTiered(tiered: TieredConversionRateConfig) = ConversionRateConfig(tiered = tiered) - } - - /** - * An interface that defines how to map each variant of [ConversionRateConfig] to a value of - * type [T]. - */ - interface Visitor { - - fun visitUnit(unit: UnitConversionRateConfig): T - - fun visitTiered(tiered: TieredConversionRateConfig): T - - /** - * Maps an unknown variant of [ConversionRateConfig] to a value of type [T]. - * - * An instance of [ConversionRateConfig] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if the SDK - * is on an older version than the API, then the API may respond with new variants that - * the SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown ConversionRateConfig: $json") - } - } - - internal class Deserializer : - BaseDeserializer(ConversionRateConfig::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): ConversionRateConfig { - val json = JsonValue.fromJsonNode(node) - val conversionRateType = json.asObject()?.get("conversion_rate_type")?.asString() - - when (conversionRateType) { - "unit" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(unit = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - "tiered" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(tiered = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - } - - return ConversionRateConfig(_json = json) - } - } - - internal class Serializer : - BaseSerializer(ConversionRateConfig::class) { - - override fun serialize( - value: ConversionRateConfig, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unit != null -> generator.writeObject(value.unit) - value.tiered != null -> generator.writeObject(value.tiered) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - } - } - } - /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingUnitPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingUnitPrice.kt index f11f502f3..2788716f7 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingUnitPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingUnitPrice.kt @@ -6,22 +6,12 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.withorb.api.core.BaseDeserializer -import com.withorb.api.core.BaseSerializer import com.withorb.api.core.Enum import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.checkRequired -import com.withorb.api.core.getOrThrow import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import java.util.Collections @@ -1174,175 +1164,6 @@ private constructor( override fun toString() = value.toString() } - /** The configuration for the rate of the price currency to the invoicing currency. */ - @JsonDeserialize(using = ConversionRateConfig.Deserializer::class) - @JsonSerialize(using = ConversionRateConfig.Serializer::class) - class ConversionRateConfig - private constructor( - private val unit: UnitConversionRateConfig? = null, - private val tiered: TieredConversionRateConfig? = null, - private val _json: JsonValue? = null, - ) { - - fun unit(): UnitConversionRateConfig? = unit - - fun tiered(): TieredConversionRateConfig? = tiered - - fun isUnit(): Boolean = unit != null - - fun isTiered(): Boolean = tiered != null - - fun asUnit(): UnitConversionRateConfig = unit.getOrThrow("unit") - - fun asTiered(): TieredConversionRateConfig = tiered.getOrThrow("tiered") - - fun _json(): JsonValue? = _json - - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): ConversionRateConfig = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) { - unit.validate() - } - - override fun visitTiered(tiered: TieredConversionRateConfig) { - tiered.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) = unit.validity() - - override fun visitTiered(tiered: TieredConversionRateConfig) = tiered.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered - } - - override fun hashCode(): Int = Objects.hash(unit, tiered) - - override fun toString(): String = - when { - unit != null -> "ConversionRateConfig{unit=$unit}" - tiered != null -> "ConversionRateConfig{tiered=$tiered}" - _json != null -> "ConversionRateConfig{_unknown=$_json}" - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - - companion object { - - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - fun ofTiered(tiered: TieredConversionRateConfig) = ConversionRateConfig(tiered = tiered) - } - - /** - * An interface that defines how to map each variant of [ConversionRateConfig] to a value of - * type [T]. - */ - interface Visitor { - - fun visitUnit(unit: UnitConversionRateConfig): T - - fun visitTiered(tiered: TieredConversionRateConfig): T - - /** - * Maps an unknown variant of [ConversionRateConfig] to a value of type [T]. - * - * An instance of [ConversionRateConfig] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if the SDK - * is on an older version than the API, then the API may respond with new variants that - * the SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown ConversionRateConfig: $json") - } - } - - internal class Deserializer : - BaseDeserializer(ConversionRateConfig::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): ConversionRateConfig { - val json = JsonValue.fromJsonNode(node) - val conversionRateType = json.asObject()?.get("conversion_rate_type")?.asString() - - when (conversionRateType) { - "unit" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(unit = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - "tiered" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(tiered = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - } - - return ConversionRateConfig(_json = json) - } - } - - internal class Serializer : - BaseSerializer(ConversionRateConfig::class) { - - override fun serialize( - value: ConversionRateConfig, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unit != null -> generator.writeObject(value.unit) - value.tiered != null -> generator.writeObject(value.tiered) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - } - } - } - /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingUnitWithPercentPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingUnitWithPercentPrice.kt index e918c14f3..447a23413 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingUnitWithPercentPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingUnitWithPercentPrice.kt @@ -6,22 +6,12 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.withorb.api.core.BaseDeserializer -import com.withorb.api.core.BaseSerializer import com.withorb.api.core.Enum import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.checkRequired -import com.withorb.api.core.getOrThrow import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import java.util.Collections @@ -1287,175 +1277,6 @@ private constructor( "UnitWithPercentConfig{additionalProperties=$additionalProperties}" } - /** The configuration for the rate of the price currency to the invoicing currency. */ - @JsonDeserialize(using = ConversionRateConfig.Deserializer::class) - @JsonSerialize(using = ConversionRateConfig.Serializer::class) - class ConversionRateConfig - private constructor( - private val unit: UnitConversionRateConfig? = null, - private val tiered: TieredConversionRateConfig? = null, - private val _json: JsonValue? = null, - ) { - - fun unit(): UnitConversionRateConfig? = unit - - fun tiered(): TieredConversionRateConfig? = tiered - - fun isUnit(): Boolean = unit != null - - fun isTiered(): Boolean = tiered != null - - fun asUnit(): UnitConversionRateConfig = unit.getOrThrow("unit") - - fun asTiered(): TieredConversionRateConfig = tiered.getOrThrow("tiered") - - fun _json(): JsonValue? = _json - - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): ConversionRateConfig = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) { - unit.validate() - } - - override fun visitTiered(tiered: TieredConversionRateConfig) { - tiered.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) = unit.validity() - - override fun visitTiered(tiered: TieredConversionRateConfig) = tiered.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered - } - - override fun hashCode(): Int = Objects.hash(unit, tiered) - - override fun toString(): String = - when { - unit != null -> "ConversionRateConfig{unit=$unit}" - tiered != null -> "ConversionRateConfig{tiered=$tiered}" - _json != null -> "ConversionRateConfig{_unknown=$_json}" - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - - companion object { - - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - fun ofTiered(tiered: TieredConversionRateConfig) = ConversionRateConfig(tiered = tiered) - } - - /** - * An interface that defines how to map each variant of [ConversionRateConfig] to a value of - * type [T]. - */ - interface Visitor { - - fun visitUnit(unit: UnitConversionRateConfig): T - - fun visitTiered(tiered: TieredConversionRateConfig): T - - /** - * Maps an unknown variant of [ConversionRateConfig] to a value of type [T]. - * - * An instance of [ConversionRateConfig] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if the SDK - * is on an older version than the API, then the API may respond with new variants that - * the SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown ConversionRateConfig: $json") - } - } - - internal class Deserializer : - BaseDeserializer(ConversionRateConfig::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): ConversionRateConfig { - val json = JsonValue.fromJsonNode(node) - val conversionRateType = json.asObject()?.get("conversion_rate_type")?.asString() - - when (conversionRateType) { - "unit" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(unit = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - "tiered" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(tiered = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - } - - return ConversionRateConfig(_json = json) - } - } - - internal class Serializer : - BaseSerializer(ConversionRateConfig::class) { - - override fun serialize( - value: ConversionRateConfig, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unit != null -> generator.writeObject(value.unit) - value.tiered != null -> generator.writeObject(value.tiered) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - } - } - } - /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingUnitWithProrationPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingUnitWithProrationPrice.kt index 691084d83..15e3d39a0 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingUnitWithProrationPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingUnitWithProrationPrice.kt @@ -6,22 +6,12 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.withorb.api.core.BaseDeserializer -import com.withorb.api.core.BaseSerializer import com.withorb.api.core.Enum import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.checkRequired -import com.withorb.api.core.getOrThrow import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import java.util.Collections @@ -1288,175 +1278,6 @@ private constructor( "UnitWithProrationConfig{additionalProperties=$additionalProperties}" } - /** The configuration for the rate of the price currency to the invoicing currency. */ - @JsonDeserialize(using = ConversionRateConfig.Deserializer::class) - @JsonSerialize(using = ConversionRateConfig.Serializer::class) - class ConversionRateConfig - private constructor( - private val unit: UnitConversionRateConfig? = null, - private val tiered: TieredConversionRateConfig? = null, - private val _json: JsonValue? = null, - ) { - - fun unit(): UnitConversionRateConfig? = unit - - fun tiered(): TieredConversionRateConfig? = tiered - - fun isUnit(): Boolean = unit != null - - fun isTiered(): Boolean = tiered != null - - fun asUnit(): UnitConversionRateConfig = unit.getOrThrow("unit") - - fun asTiered(): TieredConversionRateConfig = tiered.getOrThrow("tiered") - - fun _json(): JsonValue? = _json - - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): ConversionRateConfig = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) { - unit.validate() - } - - override fun visitTiered(tiered: TieredConversionRateConfig) { - tiered.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) = unit.validity() - - override fun visitTiered(tiered: TieredConversionRateConfig) = tiered.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered - } - - override fun hashCode(): Int = Objects.hash(unit, tiered) - - override fun toString(): String = - when { - unit != null -> "ConversionRateConfig{unit=$unit}" - tiered != null -> "ConversionRateConfig{tiered=$tiered}" - _json != null -> "ConversionRateConfig{_unknown=$_json}" - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - - companion object { - - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - fun ofTiered(tiered: TieredConversionRateConfig) = ConversionRateConfig(tiered = tiered) - } - - /** - * An interface that defines how to map each variant of [ConversionRateConfig] to a value of - * type [T]. - */ - interface Visitor { - - fun visitUnit(unit: UnitConversionRateConfig): T - - fun visitTiered(tiered: TieredConversionRateConfig): T - - /** - * Maps an unknown variant of [ConversionRateConfig] to a value of type [T]. - * - * An instance of [ConversionRateConfig] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if the SDK - * is on an older version than the API, then the API may respond with new variants that - * the SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown ConversionRateConfig: $json") - } - } - - internal class Deserializer : - BaseDeserializer(ConversionRateConfig::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): ConversionRateConfig { - val json = JsonValue.fromJsonNode(node) - val conversionRateType = json.asObject()?.get("conversion_rate_type")?.asString() - - when (conversionRateType) { - "unit" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(unit = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - "tiered" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(tiered = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - } - - return ConversionRateConfig(_json = json) - } - } - - internal class Serializer : - BaseSerializer(ConversionRateConfig::class) { - - override fun serialize( - value: ConversionRateConfig, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unit != null -> generator.writeObject(value.unit) - value.tiered != null -> generator.writeObject(value.tiered) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - } - } - } - /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanBpsPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanBpsPrice.kt index 583994055..bf906f1c4 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanBpsPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanBpsPrice.kt @@ -6,22 +6,12 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.withorb.api.core.BaseDeserializer -import com.withorb.api.core.BaseSerializer import com.withorb.api.core.Enum import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.checkRequired -import com.withorb.api.core.getOrThrow import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import java.util.Collections @@ -1217,175 +1207,6 @@ private constructor( override fun toString() = value.toString() } - /** The configuration for the rate of the price currency to the invoicing currency. */ - @JsonDeserialize(using = ConversionRateConfig.Deserializer::class) - @JsonSerialize(using = ConversionRateConfig.Serializer::class) - class ConversionRateConfig - private constructor( - private val unit: UnitConversionRateConfig? = null, - private val tiered: TieredConversionRateConfig? = null, - private val _json: JsonValue? = null, - ) { - - fun unit(): UnitConversionRateConfig? = unit - - fun tiered(): TieredConversionRateConfig? = tiered - - fun isUnit(): Boolean = unit != null - - fun isTiered(): Boolean = tiered != null - - fun asUnit(): UnitConversionRateConfig = unit.getOrThrow("unit") - - fun asTiered(): TieredConversionRateConfig = tiered.getOrThrow("tiered") - - fun _json(): JsonValue? = _json - - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): ConversionRateConfig = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) { - unit.validate() - } - - override fun visitTiered(tiered: TieredConversionRateConfig) { - tiered.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) = unit.validity() - - override fun visitTiered(tiered: TieredConversionRateConfig) = tiered.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered - } - - override fun hashCode(): Int = Objects.hash(unit, tiered) - - override fun toString(): String = - when { - unit != null -> "ConversionRateConfig{unit=$unit}" - tiered != null -> "ConversionRateConfig{tiered=$tiered}" - _json != null -> "ConversionRateConfig{_unknown=$_json}" - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - - companion object { - - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - fun ofTiered(tiered: TieredConversionRateConfig) = ConversionRateConfig(tiered = tiered) - } - - /** - * An interface that defines how to map each variant of [ConversionRateConfig] to a value of - * type [T]. - */ - interface Visitor { - - fun visitUnit(unit: UnitConversionRateConfig): T - - fun visitTiered(tiered: TieredConversionRateConfig): T - - /** - * Maps an unknown variant of [ConversionRateConfig] to a value of type [T]. - * - * An instance of [ConversionRateConfig] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if the SDK - * is on an older version than the API, then the API may respond with new variants that - * the SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown ConversionRateConfig: $json") - } - } - - internal class Deserializer : - BaseDeserializer(ConversionRateConfig::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): ConversionRateConfig { - val json = JsonValue.fromJsonNode(node) - val conversionRateType = json.asObject()?.get("conversion_rate_type")?.asString() - - when (conversionRateType) { - "unit" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(unit = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - "tiered" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(tiered = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - } - - return ConversionRateConfig(_json = json) - } - } - - internal class Serializer : - BaseSerializer(ConversionRateConfig::class) { - - override fun serialize( - value: ConversionRateConfig, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unit != null -> generator.writeObject(value.unit) - value.tiered != null -> generator.writeObject(value.tiered) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - } - } - } - /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanBulkBpsPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanBulkBpsPrice.kt index 4e610cb30..fd537fdbc 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanBulkBpsPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanBulkBpsPrice.kt @@ -6,22 +6,12 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.withorb.api.core.BaseDeserializer -import com.withorb.api.core.BaseSerializer import com.withorb.api.core.Enum import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.checkRequired -import com.withorb.api.core.getOrThrow import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import java.util.Collections @@ -1221,175 +1211,6 @@ private constructor( override fun toString() = value.toString() } - /** The configuration for the rate of the price currency to the invoicing currency. */ - @JsonDeserialize(using = ConversionRateConfig.Deserializer::class) - @JsonSerialize(using = ConversionRateConfig.Serializer::class) - class ConversionRateConfig - private constructor( - private val unit: UnitConversionRateConfig? = null, - private val tiered: TieredConversionRateConfig? = null, - private val _json: JsonValue? = null, - ) { - - fun unit(): UnitConversionRateConfig? = unit - - fun tiered(): TieredConversionRateConfig? = tiered - - fun isUnit(): Boolean = unit != null - - fun isTiered(): Boolean = tiered != null - - fun asUnit(): UnitConversionRateConfig = unit.getOrThrow("unit") - - fun asTiered(): TieredConversionRateConfig = tiered.getOrThrow("tiered") - - fun _json(): JsonValue? = _json - - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): ConversionRateConfig = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) { - unit.validate() - } - - override fun visitTiered(tiered: TieredConversionRateConfig) { - tiered.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) = unit.validity() - - override fun visitTiered(tiered: TieredConversionRateConfig) = tiered.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered - } - - override fun hashCode(): Int = Objects.hash(unit, tiered) - - override fun toString(): String = - when { - unit != null -> "ConversionRateConfig{unit=$unit}" - tiered != null -> "ConversionRateConfig{tiered=$tiered}" - _json != null -> "ConversionRateConfig{_unknown=$_json}" - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - - companion object { - - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - fun ofTiered(tiered: TieredConversionRateConfig) = ConversionRateConfig(tiered = tiered) - } - - /** - * An interface that defines how to map each variant of [ConversionRateConfig] to a value of - * type [T]. - */ - interface Visitor { - - fun visitUnit(unit: UnitConversionRateConfig): T - - fun visitTiered(tiered: TieredConversionRateConfig): T - - /** - * Maps an unknown variant of [ConversionRateConfig] to a value of type [T]. - * - * An instance of [ConversionRateConfig] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if the SDK - * is on an older version than the API, then the API may respond with new variants that - * the SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown ConversionRateConfig: $json") - } - } - - internal class Deserializer : - BaseDeserializer(ConversionRateConfig::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): ConversionRateConfig { - val json = JsonValue.fromJsonNode(node) - val conversionRateType = json.asObject()?.get("conversion_rate_type")?.asString() - - when (conversionRateType) { - "unit" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(unit = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - "tiered" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(tiered = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - } - - return ConversionRateConfig(_json = json) - } - } - - internal class Serializer : - BaseSerializer(ConversionRateConfig::class) { - - override fun serialize( - value: ConversionRateConfig, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unit != null -> generator.writeObject(value.unit) - value.tiered != null -> generator.writeObject(value.tiered) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - } - } - } - /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanBulkPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanBulkPrice.kt index 2580aaac7..036869299 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanBulkPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanBulkPrice.kt @@ -6,22 +6,12 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.withorb.api.core.BaseDeserializer -import com.withorb.api.core.BaseSerializer import com.withorb.api.core.Enum import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.checkRequired -import com.withorb.api.core.getOrThrow import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import java.util.Collections @@ -1219,175 +1209,6 @@ private constructor( override fun toString() = value.toString() } - /** The configuration for the rate of the price currency to the invoicing currency. */ - @JsonDeserialize(using = ConversionRateConfig.Deserializer::class) - @JsonSerialize(using = ConversionRateConfig.Serializer::class) - class ConversionRateConfig - private constructor( - private val unit: UnitConversionRateConfig? = null, - private val tiered: TieredConversionRateConfig? = null, - private val _json: JsonValue? = null, - ) { - - fun unit(): UnitConversionRateConfig? = unit - - fun tiered(): TieredConversionRateConfig? = tiered - - fun isUnit(): Boolean = unit != null - - fun isTiered(): Boolean = tiered != null - - fun asUnit(): UnitConversionRateConfig = unit.getOrThrow("unit") - - fun asTiered(): TieredConversionRateConfig = tiered.getOrThrow("tiered") - - fun _json(): JsonValue? = _json - - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): ConversionRateConfig = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) { - unit.validate() - } - - override fun visitTiered(tiered: TieredConversionRateConfig) { - tiered.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) = unit.validity() - - override fun visitTiered(tiered: TieredConversionRateConfig) = tiered.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered - } - - override fun hashCode(): Int = Objects.hash(unit, tiered) - - override fun toString(): String = - when { - unit != null -> "ConversionRateConfig{unit=$unit}" - tiered != null -> "ConversionRateConfig{tiered=$tiered}" - _json != null -> "ConversionRateConfig{_unknown=$_json}" - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - - companion object { - - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - fun ofTiered(tiered: TieredConversionRateConfig) = ConversionRateConfig(tiered = tiered) - } - - /** - * An interface that defines how to map each variant of [ConversionRateConfig] to a value of - * type [T]. - */ - interface Visitor { - - fun visitUnit(unit: UnitConversionRateConfig): T - - fun visitTiered(tiered: TieredConversionRateConfig): T - - /** - * Maps an unknown variant of [ConversionRateConfig] to a value of type [T]. - * - * An instance of [ConversionRateConfig] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if the SDK - * is on an older version than the API, then the API may respond with new variants that - * the SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown ConversionRateConfig: $json") - } - } - - internal class Deserializer : - BaseDeserializer(ConversionRateConfig::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): ConversionRateConfig { - val json = JsonValue.fromJsonNode(node) - val conversionRateType = json.asObject()?.get("conversion_rate_type")?.asString() - - when (conversionRateType) { - "unit" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(unit = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - "tiered" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(tiered = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - } - - return ConversionRateConfig(_json = json) - } - } - - internal class Serializer : - BaseSerializer(ConversionRateConfig::class) { - - override fun serialize( - value: ConversionRateConfig, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unit != null -> generator.writeObject(value.unit) - value.tiered != null -> generator.writeObject(value.tiered) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - } - } - } - /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanBulkWithProrationPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanBulkWithProrationPrice.kt index 1794a499d..feb8f7230 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanBulkWithProrationPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanBulkWithProrationPrice.kt @@ -6,22 +6,12 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.withorb.api.core.BaseDeserializer -import com.withorb.api.core.BaseSerializer import com.withorb.api.core.Enum import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.checkRequired -import com.withorb.api.core.getOrThrow import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import java.util.Collections @@ -1329,175 +1319,6 @@ private constructor( override fun toString() = value.toString() } - /** The configuration for the rate of the price currency to the invoicing currency. */ - @JsonDeserialize(using = ConversionRateConfig.Deserializer::class) - @JsonSerialize(using = ConversionRateConfig.Serializer::class) - class ConversionRateConfig - private constructor( - private val unit: UnitConversionRateConfig? = null, - private val tiered: TieredConversionRateConfig? = null, - private val _json: JsonValue? = null, - ) { - - fun unit(): UnitConversionRateConfig? = unit - - fun tiered(): TieredConversionRateConfig? = tiered - - fun isUnit(): Boolean = unit != null - - fun isTiered(): Boolean = tiered != null - - fun asUnit(): UnitConversionRateConfig = unit.getOrThrow("unit") - - fun asTiered(): TieredConversionRateConfig = tiered.getOrThrow("tiered") - - fun _json(): JsonValue? = _json - - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): ConversionRateConfig = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) { - unit.validate() - } - - override fun visitTiered(tiered: TieredConversionRateConfig) { - tiered.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) = unit.validity() - - override fun visitTiered(tiered: TieredConversionRateConfig) = tiered.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered - } - - override fun hashCode(): Int = Objects.hash(unit, tiered) - - override fun toString(): String = - when { - unit != null -> "ConversionRateConfig{unit=$unit}" - tiered != null -> "ConversionRateConfig{tiered=$tiered}" - _json != null -> "ConversionRateConfig{_unknown=$_json}" - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - - companion object { - - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - fun ofTiered(tiered: TieredConversionRateConfig) = ConversionRateConfig(tiered = tiered) - } - - /** - * An interface that defines how to map each variant of [ConversionRateConfig] to a value of - * type [T]. - */ - interface Visitor { - - fun visitUnit(unit: UnitConversionRateConfig): T - - fun visitTiered(tiered: TieredConversionRateConfig): T - - /** - * Maps an unknown variant of [ConversionRateConfig] to a value of type [T]. - * - * An instance of [ConversionRateConfig] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if the SDK - * is on an older version than the API, then the API may respond with new variants that - * the SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown ConversionRateConfig: $json") - } - } - - internal class Deserializer : - BaseDeserializer(ConversionRateConfig::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): ConversionRateConfig { - val json = JsonValue.fromJsonNode(node) - val conversionRateType = json.asObject()?.get("conversion_rate_type")?.asString() - - when (conversionRateType) { - "unit" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(unit = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - "tiered" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(tiered = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - } - - return ConversionRateConfig(_json = json) - } - } - - internal class Serializer : - BaseSerializer(ConversionRateConfig::class) { - - override fun serialize( - value: ConversionRateConfig, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unit != null -> generator.writeObject(value.unit) - value.tiered != null -> generator.writeObject(value.tiered) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - } - } - } - /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanCumulativeGroupedBulkPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanCumulativeGroupedBulkPrice.kt index f3d71fc66..e491d8f73 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanCumulativeGroupedBulkPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanCumulativeGroupedBulkPrice.kt @@ -6,22 +6,12 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.withorb.api.core.BaseDeserializer -import com.withorb.api.core.BaseSerializer import com.withorb.api.core.Enum import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.checkRequired -import com.withorb.api.core.getOrThrow import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import java.util.Collections @@ -1336,175 +1326,6 @@ private constructor( override fun toString() = value.toString() } - /** The configuration for the rate of the price currency to the invoicing currency. */ - @JsonDeserialize(using = ConversionRateConfig.Deserializer::class) - @JsonSerialize(using = ConversionRateConfig.Serializer::class) - class ConversionRateConfig - private constructor( - private val unit: UnitConversionRateConfig? = null, - private val tiered: TieredConversionRateConfig? = null, - private val _json: JsonValue? = null, - ) { - - fun unit(): UnitConversionRateConfig? = unit - - fun tiered(): TieredConversionRateConfig? = tiered - - fun isUnit(): Boolean = unit != null - - fun isTiered(): Boolean = tiered != null - - fun asUnit(): UnitConversionRateConfig = unit.getOrThrow("unit") - - fun asTiered(): TieredConversionRateConfig = tiered.getOrThrow("tiered") - - fun _json(): JsonValue? = _json - - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): ConversionRateConfig = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) { - unit.validate() - } - - override fun visitTiered(tiered: TieredConversionRateConfig) { - tiered.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) = unit.validity() - - override fun visitTiered(tiered: TieredConversionRateConfig) = tiered.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered - } - - override fun hashCode(): Int = Objects.hash(unit, tiered) - - override fun toString(): String = - when { - unit != null -> "ConversionRateConfig{unit=$unit}" - tiered != null -> "ConversionRateConfig{tiered=$tiered}" - _json != null -> "ConversionRateConfig{_unknown=$_json}" - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - - companion object { - - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - fun ofTiered(tiered: TieredConversionRateConfig) = ConversionRateConfig(tiered = tiered) - } - - /** - * An interface that defines how to map each variant of [ConversionRateConfig] to a value of - * type [T]. - */ - interface Visitor { - - fun visitUnit(unit: UnitConversionRateConfig): T - - fun visitTiered(tiered: TieredConversionRateConfig): T - - /** - * Maps an unknown variant of [ConversionRateConfig] to a value of type [T]. - * - * An instance of [ConversionRateConfig] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if the SDK - * is on an older version than the API, then the API may respond with new variants that - * the SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown ConversionRateConfig: $json") - } - } - - internal class Deserializer : - BaseDeserializer(ConversionRateConfig::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): ConversionRateConfig { - val json = JsonValue.fromJsonNode(node) - val conversionRateType = json.asObject()?.get("conversion_rate_type")?.asString() - - when (conversionRateType) { - "unit" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(unit = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - "tiered" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(tiered = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - } - - return ConversionRateConfig(_json = json) - } - } - - internal class Serializer : - BaseSerializer(ConversionRateConfig::class) { - - override fun serialize( - value: ConversionRateConfig, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unit != null -> generator.writeObject(value.unit) - value.tiered != null -> generator.writeObject(value.tiered) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - } - } - } - /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanGroupedAllocationPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanGroupedAllocationPrice.kt index fa806ed9d..49561abbc 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanGroupedAllocationPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanGroupedAllocationPrice.kt @@ -6,22 +6,12 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.withorb.api.core.BaseDeserializer -import com.withorb.api.core.BaseSerializer import com.withorb.api.core.Enum import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.checkRequired -import com.withorb.api.core.getOrThrow import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import java.util.Collections @@ -1329,175 +1319,6 @@ private constructor( override fun toString() = value.toString() } - /** The configuration for the rate of the price currency to the invoicing currency. */ - @JsonDeserialize(using = ConversionRateConfig.Deserializer::class) - @JsonSerialize(using = ConversionRateConfig.Serializer::class) - class ConversionRateConfig - private constructor( - private val unit: UnitConversionRateConfig? = null, - private val tiered: TieredConversionRateConfig? = null, - private val _json: JsonValue? = null, - ) { - - fun unit(): UnitConversionRateConfig? = unit - - fun tiered(): TieredConversionRateConfig? = tiered - - fun isUnit(): Boolean = unit != null - - fun isTiered(): Boolean = tiered != null - - fun asUnit(): UnitConversionRateConfig = unit.getOrThrow("unit") - - fun asTiered(): TieredConversionRateConfig = tiered.getOrThrow("tiered") - - fun _json(): JsonValue? = _json - - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): ConversionRateConfig = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) { - unit.validate() - } - - override fun visitTiered(tiered: TieredConversionRateConfig) { - tiered.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) = unit.validity() - - override fun visitTiered(tiered: TieredConversionRateConfig) = tiered.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered - } - - override fun hashCode(): Int = Objects.hash(unit, tiered) - - override fun toString(): String = - when { - unit != null -> "ConversionRateConfig{unit=$unit}" - tiered != null -> "ConversionRateConfig{tiered=$tiered}" - _json != null -> "ConversionRateConfig{_unknown=$_json}" - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - - companion object { - - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - fun ofTiered(tiered: TieredConversionRateConfig) = ConversionRateConfig(tiered = tiered) - } - - /** - * An interface that defines how to map each variant of [ConversionRateConfig] to a value of - * type [T]. - */ - interface Visitor { - - fun visitUnit(unit: UnitConversionRateConfig): T - - fun visitTiered(tiered: TieredConversionRateConfig): T - - /** - * Maps an unknown variant of [ConversionRateConfig] to a value of type [T]. - * - * An instance of [ConversionRateConfig] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if the SDK - * is on an older version than the API, then the API may respond with new variants that - * the SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown ConversionRateConfig: $json") - } - } - - internal class Deserializer : - BaseDeserializer(ConversionRateConfig::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): ConversionRateConfig { - val json = JsonValue.fromJsonNode(node) - val conversionRateType = json.asObject()?.get("conversion_rate_type")?.asString() - - when (conversionRateType) { - "unit" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(unit = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - "tiered" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(tiered = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - } - - return ConversionRateConfig(_json = json) - } - } - - internal class Serializer : - BaseSerializer(ConversionRateConfig::class) { - - override fun serialize( - value: ConversionRateConfig, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unit != null -> generator.writeObject(value.unit) - value.tiered != null -> generator.writeObject(value.tiered) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - } - } - } - /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanGroupedTieredPackagePrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanGroupedTieredPackagePrice.kt index 5a9972cb5..fd07cea0b 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanGroupedTieredPackagePrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanGroupedTieredPackagePrice.kt @@ -6,22 +6,12 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.withorb.api.core.BaseDeserializer -import com.withorb.api.core.BaseSerializer import com.withorb.api.core.Enum import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.checkRequired -import com.withorb.api.core.getOrThrow import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import java.util.Collections @@ -1336,175 +1326,6 @@ private constructor( override fun toString() = value.toString() } - /** The configuration for the rate of the price currency to the invoicing currency. */ - @JsonDeserialize(using = ConversionRateConfig.Deserializer::class) - @JsonSerialize(using = ConversionRateConfig.Serializer::class) - class ConversionRateConfig - private constructor( - private val unit: UnitConversionRateConfig? = null, - private val tiered: TieredConversionRateConfig? = null, - private val _json: JsonValue? = null, - ) { - - fun unit(): UnitConversionRateConfig? = unit - - fun tiered(): TieredConversionRateConfig? = tiered - - fun isUnit(): Boolean = unit != null - - fun isTiered(): Boolean = tiered != null - - fun asUnit(): UnitConversionRateConfig = unit.getOrThrow("unit") - - fun asTiered(): TieredConversionRateConfig = tiered.getOrThrow("tiered") - - fun _json(): JsonValue? = _json - - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): ConversionRateConfig = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) { - unit.validate() - } - - override fun visitTiered(tiered: TieredConversionRateConfig) { - tiered.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) = unit.validity() - - override fun visitTiered(tiered: TieredConversionRateConfig) = tiered.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered - } - - override fun hashCode(): Int = Objects.hash(unit, tiered) - - override fun toString(): String = - when { - unit != null -> "ConversionRateConfig{unit=$unit}" - tiered != null -> "ConversionRateConfig{tiered=$tiered}" - _json != null -> "ConversionRateConfig{_unknown=$_json}" - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - - companion object { - - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - fun ofTiered(tiered: TieredConversionRateConfig) = ConversionRateConfig(tiered = tiered) - } - - /** - * An interface that defines how to map each variant of [ConversionRateConfig] to a value of - * type [T]. - */ - interface Visitor { - - fun visitUnit(unit: UnitConversionRateConfig): T - - fun visitTiered(tiered: TieredConversionRateConfig): T - - /** - * Maps an unknown variant of [ConversionRateConfig] to a value of type [T]. - * - * An instance of [ConversionRateConfig] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if the SDK - * is on an older version than the API, then the API may respond with new variants that - * the SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown ConversionRateConfig: $json") - } - } - - internal class Deserializer : - BaseDeserializer(ConversionRateConfig::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): ConversionRateConfig { - val json = JsonValue.fromJsonNode(node) - val conversionRateType = json.asObject()?.get("conversion_rate_type")?.asString() - - when (conversionRateType) { - "unit" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(unit = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - "tiered" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(tiered = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - } - - return ConversionRateConfig(_json = json) - } - } - - internal class Serializer : - BaseSerializer(ConversionRateConfig::class) { - - override fun serialize( - value: ConversionRateConfig, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unit != null -> generator.writeObject(value.unit) - value.tiered != null -> generator.writeObject(value.tiered) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - } - } - } - /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanGroupedTieredPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanGroupedTieredPrice.kt index e3eb1ecf9..27977218e 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanGroupedTieredPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanGroupedTieredPrice.kt @@ -6,22 +6,12 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.withorb.api.core.BaseDeserializer -import com.withorb.api.core.BaseSerializer import com.withorb.api.core.Enum import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.checkRequired -import com.withorb.api.core.getOrThrow import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import java.util.Collections @@ -1323,175 +1313,6 @@ private constructor( override fun toString() = value.toString() } - /** The configuration for the rate of the price currency to the invoicing currency. */ - @JsonDeserialize(using = ConversionRateConfig.Deserializer::class) - @JsonSerialize(using = ConversionRateConfig.Serializer::class) - class ConversionRateConfig - private constructor( - private val unit: UnitConversionRateConfig? = null, - private val tiered: TieredConversionRateConfig? = null, - private val _json: JsonValue? = null, - ) { - - fun unit(): UnitConversionRateConfig? = unit - - fun tiered(): TieredConversionRateConfig? = tiered - - fun isUnit(): Boolean = unit != null - - fun isTiered(): Boolean = tiered != null - - fun asUnit(): UnitConversionRateConfig = unit.getOrThrow("unit") - - fun asTiered(): TieredConversionRateConfig = tiered.getOrThrow("tiered") - - fun _json(): JsonValue? = _json - - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): ConversionRateConfig = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) { - unit.validate() - } - - override fun visitTiered(tiered: TieredConversionRateConfig) { - tiered.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) = unit.validity() - - override fun visitTiered(tiered: TieredConversionRateConfig) = tiered.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered - } - - override fun hashCode(): Int = Objects.hash(unit, tiered) - - override fun toString(): String = - when { - unit != null -> "ConversionRateConfig{unit=$unit}" - tiered != null -> "ConversionRateConfig{tiered=$tiered}" - _json != null -> "ConversionRateConfig{_unknown=$_json}" - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - - companion object { - - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - fun ofTiered(tiered: TieredConversionRateConfig) = ConversionRateConfig(tiered = tiered) - } - - /** - * An interface that defines how to map each variant of [ConversionRateConfig] to a value of - * type [T]. - */ - interface Visitor { - - fun visitUnit(unit: UnitConversionRateConfig): T - - fun visitTiered(tiered: TieredConversionRateConfig): T - - /** - * Maps an unknown variant of [ConversionRateConfig] to a value of type [T]. - * - * An instance of [ConversionRateConfig] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if the SDK - * is on an older version than the API, then the API may respond with new variants that - * the SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown ConversionRateConfig: $json") - } - } - - internal class Deserializer : - BaseDeserializer(ConversionRateConfig::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): ConversionRateConfig { - val json = JsonValue.fromJsonNode(node) - val conversionRateType = json.asObject()?.get("conversion_rate_type")?.asString() - - when (conversionRateType) { - "unit" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(unit = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - "tiered" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(tiered = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - } - - return ConversionRateConfig(_json = json) - } - } - - internal class Serializer : - BaseSerializer(ConversionRateConfig::class) { - - override fun serialize( - value: ConversionRateConfig, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unit != null -> generator.writeObject(value.unit) - value.tiered != null -> generator.writeObject(value.tiered) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - } - } - } - /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanGroupedWithMeteredMinimumPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanGroupedWithMeteredMinimumPrice.kt index d4635d572..7a4d8f17c 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanGroupedWithMeteredMinimumPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanGroupedWithMeteredMinimumPrice.kt @@ -6,22 +6,12 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.withorb.api.core.BaseDeserializer -import com.withorb.api.core.BaseSerializer import com.withorb.api.core.Enum import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.checkRequired -import com.withorb.api.core.getOrThrow import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import java.util.Collections @@ -1341,175 +1331,6 @@ private constructor( override fun toString() = value.toString() } - /** The configuration for the rate of the price currency to the invoicing currency. */ - @JsonDeserialize(using = ConversionRateConfig.Deserializer::class) - @JsonSerialize(using = ConversionRateConfig.Serializer::class) - class ConversionRateConfig - private constructor( - private val unit: UnitConversionRateConfig? = null, - private val tiered: TieredConversionRateConfig? = null, - private val _json: JsonValue? = null, - ) { - - fun unit(): UnitConversionRateConfig? = unit - - fun tiered(): TieredConversionRateConfig? = tiered - - fun isUnit(): Boolean = unit != null - - fun isTiered(): Boolean = tiered != null - - fun asUnit(): UnitConversionRateConfig = unit.getOrThrow("unit") - - fun asTiered(): TieredConversionRateConfig = tiered.getOrThrow("tiered") - - fun _json(): JsonValue? = _json - - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): ConversionRateConfig = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) { - unit.validate() - } - - override fun visitTiered(tiered: TieredConversionRateConfig) { - tiered.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) = unit.validity() - - override fun visitTiered(tiered: TieredConversionRateConfig) = tiered.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered - } - - override fun hashCode(): Int = Objects.hash(unit, tiered) - - override fun toString(): String = - when { - unit != null -> "ConversionRateConfig{unit=$unit}" - tiered != null -> "ConversionRateConfig{tiered=$tiered}" - _json != null -> "ConversionRateConfig{_unknown=$_json}" - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - - companion object { - - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - fun ofTiered(tiered: TieredConversionRateConfig) = ConversionRateConfig(tiered = tiered) - } - - /** - * An interface that defines how to map each variant of [ConversionRateConfig] to a value of - * type [T]. - */ - interface Visitor { - - fun visitUnit(unit: UnitConversionRateConfig): T - - fun visitTiered(tiered: TieredConversionRateConfig): T - - /** - * Maps an unknown variant of [ConversionRateConfig] to a value of type [T]. - * - * An instance of [ConversionRateConfig] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if the SDK - * is on an older version than the API, then the API may respond with new variants that - * the SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown ConversionRateConfig: $json") - } - } - - internal class Deserializer : - BaseDeserializer(ConversionRateConfig::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): ConversionRateConfig { - val json = JsonValue.fromJsonNode(node) - val conversionRateType = json.asObject()?.get("conversion_rate_type")?.asString() - - when (conversionRateType) { - "unit" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(unit = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - "tiered" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(tiered = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - } - - return ConversionRateConfig(_json = json) - } - } - - internal class Serializer : - BaseSerializer(ConversionRateConfig::class) { - - override fun serialize( - value: ConversionRateConfig, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unit != null -> generator.writeObject(value.unit) - value.tiered != null -> generator.writeObject(value.tiered) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - } - } - } - /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanGroupedWithProratedMinimumPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanGroupedWithProratedMinimumPrice.kt index 93240a2bc..0d648d2af 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanGroupedWithProratedMinimumPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanGroupedWithProratedMinimumPrice.kt @@ -6,22 +6,12 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.withorb.api.core.BaseDeserializer -import com.withorb.api.core.BaseSerializer import com.withorb.api.core.Enum import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.checkRequired -import com.withorb.api.core.getOrThrow import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import java.util.Collections @@ -1341,175 +1331,6 @@ private constructor( override fun toString() = value.toString() } - /** The configuration for the rate of the price currency to the invoicing currency. */ - @JsonDeserialize(using = ConversionRateConfig.Deserializer::class) - @JsonSerialize(using = ConversionRateConfig.Serializer::class) - class ConversionRateConfig - private constructor( - private val unit: UnitConversionRateConfig? = null, - private val tiered: TieredConversionRateConfig? = null, - private val _json: JsonValue? = null, - ) { - - fun unit(): UnitConversionRateConfig? = unit - - fun tiered(): TieredConversionRateConfig? = tiered - - fun isUnit(): Boolean = unit != null - - fun isTiered(): Boolean = tiered != null - - fun asUnit(): UnitConversionRateConfig = unit.getOrThrow("unit") - - fun asTiered(): TieredConversionRateConfig = tiered.getOrThrow("tiered") - - fun _json(): JsonValue? = _json - - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): ConversionRateConfig = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) { - unit.validate() - } - - override fun visitTiered(tiered: TieredConversionRateConfig) { - tiered.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) = unit.validity() - - override fun visitTiered(tiered: TieredConversionRateConfig) = tiered.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered - } - - override fun hashCode(): Int = Objects.hash(unit, tiered) - - override fun toString(): String = - when { - unit != null -> "ConversionRateConfig{unit=$unit}" - tiered != null -> "ConversionRateConfig{tiered=$tiered}" - _json != null -> "ConversionRateConfig{_unknown=$_json}" - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - - companion object { - - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - fun ofTiered(tiered: TieredConversionRateConfig) = ConversionRateConfig(tiered = tiered) - } - - /** - * An interface that defines how to map each variant of [ConversionRateConfig] to a value of - * type [T]. - */ - interface Visitor { - - fun visitUnit(unit: UnitConversionRateConfig): T - - fun visitTiered(tiered: TieredConversionRateConfig): T - - /** - * Maps an unknown variant of [ConversionRateConfig] to a value of type [T]. - * - * An instance of [ConversionRateConfig] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if the SDK - * is on an older version than the API, then the API may respond with new variants that - * the SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown ConversionRateConfig: $json") - } - } - - internal class Deserializer : - BaseDeserializer(ConversionRateConfig::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): ConversionRateConfig { - val json = JsonValue.fromJsonNode(node) - val conversionRateType = json.asObject()?.get("conversion_rate_type")?.asString() - - when (conversionRateType) { - "unit" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(unit = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - "tiered" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(tiered = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - } - - return ConversionRateConfig(_json = json) - } - } - - internal class Serializer : - BaseSerializer(ConversionRateConfig::class) { - - override fun serialize( - value: ConversionRateConfig, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unit != null -> generator.writeObject(value.unit) - value.tiered != null -> generator.writeObject(value.tiered) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - } - } - } - /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanMatrixPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanMatrixPrice.kt index 0e27c274c..661efba19 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanMatrixPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanMatrixPrice.kt @@ -6,22 +6,12 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.withorb.api.core.BaseDeserializer -import com.withorb.api.core.BaseSerializer import com.withorb.api.core.Enum import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.checkRequired -import com.withorb.api.core.getOrThrow import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import java.util.Collections @@ -1221,175 +1211,6 @@ private constructor( override fun toString() = value.toString() } - /** The configuration for the rate of the price currency to the invoicing currency. */ - @JsonDeserialize(using = ConversionRateConfig.Deserializer::class) - @JsonSerialize(using = ConversionRateConfig.Serializer::class) - class ConversionRateConfig - private constructor( - private val unit: UnitConversionRateConfig? = null, - private val tiered: TieredConversionRateConfig? = null, - private val _json: JsonValue? = null, - ) { - - fun unit(): UnitConversionRateConfig? = unit - - fun tiered(): TieredConversionRateConfig? = tiered - - fun isUnit(): Boolean = unit != null - - fun isTiered(): Boolean = tiered != null - - fun asUnit(): UnitConversionRateConfig = unit.getOrThrow("unit") - - fun asTiered(): TieredConversionRateConfig = tiered.getOrThrow("tiered") - - fun _json(): JsonValue? = _json - - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): ConversionRateConfig = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) { - unit.validate() - } - - override fun visitTiered(tiered: TieredConversionRateConfig) { - tiered.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) = unit.validity() - - override fun visitTiered(tiered: TieredConversionRateConfig) = tiered.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered - } - - override fun hashCode(): Int = Objects.hash(unit, tiered) - - override fun toString(): String = - when { - unit != null -> "ConversionRateConfig{unit=$unit}" - tiered != null -> "ConversionRateConfig{tiered=$tiered}" - _json != null -> "ConversionRateConfig{_unknown=$_json}" - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - - companion object { - - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - fun ofTiered(tiered: TieredConversionRateConfig) = ConversionRateConfig(tiered = tiered) - } - - /** - * An interface that defines how to map each variant of [ConversionRateConfig] to a value of - * type [T]. - */ - interface Visitor { - - fun visitUnit(unit: UnitConversionRateConfig): T - - fun visitTiered(tiered: TieredConversionRateConfig): T - - /** - * Maps an unknown variant of [ConversionRateConfig] to a value of type [T]. - * - * An instance of [ConversionRateConfig] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if the SDK - * is on an older version than the API, then the API may respond with new variants that - * the SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown ConversionRateConfig: $json") - } - } - - internal class Deserializer : - BaseDeserializer(ConversionRateConfig::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): ConversionRateConfig { - val json = JsonValue.fromJsonNode(node) - val conversionRateType = json.asObject()?.get("conversion_rate_type")?.asString() - - when (conversionRateType) { - "unit" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(unit = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - "tiered" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(tiered = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - } - - return ConversionRateConfig(_json = json) - } - } - - internal class Serializer : - BaseSerializer(ConversionRateConfig::class) { - - override fun serialize( - value: ConversionRateConfig, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unit != null -> generator.writeObject(value.unit) - value.tiered != null -> generator.writeObject(value.tiered) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - } - } - } - /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanMatrixWithAllocationPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanMatrixWithAllocationPrice.kt index 4882354a6..16f02371f 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanMatrixWithAllocationPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanMatrixWithAllocationPrice.kt @@ -6,22 +6,12 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.withorb.api.core.BaseDeserializer -import com.withorb.api.core.BaseSerializer import com.withorb.api.core.Enum import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.checkRequired -import com.withorb.api.core.getOrThrow import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import java.util.Collections @@ -1232,175 +1222,6 @@ private constructor( override fun toString() = value.toString() } - /** The configuration for the rate of the price currency to the invoicing currency. */ - @JsonDeserialize(using = ConversionRateConfig.Deserializer::class) - @JsonSerialize(using = ConversionRateConfig.Serializer::class) - class ConversionRateConfig - private constructor( - private val unit: UnitConversionRateConfig? = null, - private val tiered: TieredConversionRateConfig? = null, - private val _json: JsonValue? = null, - ) { - - fun unit(): UnitConversionRateConfig? = unit - - fun tiered(): TieredConversionRateConfig? = tiered - - fun isUnit(): Boolean = unit != null - - fun isTiered(): Boolean = tiered != null - - fun asUnit(): UnitConversionRateConfig = unit.getOrThrow("unit") - - fun asTiered(): TieredConversionRateConfig = tiered.getOrThrow("tiered") - - fun _json(): JsonValue? = _json - - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): ConversionRateConfig = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) { - unit.validate() - } - - override fun visitTiered(tiered: TieredConversionRateConfig) { - tiered.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) = unit.validity() - - override fun visitTiered(tiered: TieredConversionRateConfig) = tiered.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered - } - - override fun hashCode(): Int = Objects.hash(unit, tiered) - - override fun toString(): String = - when { - unit != null -> "ConversionRateConfig{unit=$unit}" - tiered != null -> "ConversionRateConfig{tiered=$tiered}" - _json != null -> "ConversionRateConfig{_unknown=$_json}" - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - - companion object { - - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - fun ofTiered(tiered: TieredConversionRateConfig) = ConversionRateConfig(tiered = tiered) - } - - /** - * An interface that defines how to map each variant of [ConversionRateConfig] to a value of - * type [T]. - */ - interface Visitor { - - fun visitUnit(unit: UnitConversionRateConfig): T - - fun visitTiered(tiered: TieredConversionRateConfig): T - - /** - * Maps an unknown variant of [ConversionRateConfig] to a value of type [T]. - * - * An instance of [ConversionRateConfig] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if the SDK - * is on an older version than the API, then the API may respond with new variants that - * the SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown ConversionRateConfig: $json") - } - } - - internal class Deserializer : - BaseDeserializer(ConversionRateConfig::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): ConversionRateConfig { - val json = JsonValue.fromJsonNode(node) - val conversionRateType = json.asObject()?.get("conversion_rate_type")?.asString() - - when (conversionRateType) { - "unit" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(unit = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - "tiered" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(tiered = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - } - - return ConversionRateConfig(_json = json) - } - } - - internal class Serializer : - BaseSerializer(ConversionRateConfig::class) { - - override fun serialize( - value: ConversionRateConfig, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unit != null -> generator.writeObject(value.unit) - value.tiered != null -> generator.writeObject(value.tiered) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - } - } - } - /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanMatrixWithDisplayNamePrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanMatrixWithDisplayNamePrice.kt index 5a586d8bc..0c59c7801 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanMatrixWithDisplayNamePrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanMatrixWithDisplayNamePrice.kt @@ -6,22 +6,12 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.withorb.api.core.BaseDeserializer -import com.withorb.api.core.BaseSerializer import com.withorb.api.core.Enum import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.checkRequired -import com.withorb.api.core.getOrThrow import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import java.util.Collections @@ -1336,175 +1326,6 @@ private constructor( override fun toString() = value.toString() } - /** The configuration for the rate of the price currency to the invoicing currency. */ - @JsonDeserialize(using = ConversionRateConfig.Deserializer::class) - @JsonSerialize(using = ConversionRateConfig.Serializer::class) - class ConversionRateConfig - private constructor( - private val unit: UnitConversionRateConfig? = null, - private val tiered: TieredConversionRateConfig? = null, - private val _json: JsonValue? = null, - ) { - - fun unit(): UnitConversionRateConfig? = unit - - fun tiered(): TieredConversionRateConfig? = tiered - - fun isUnit(): Boolean = unit != null - - fun isTiered(): Boolean = tiered != null - - fun asUnit(): UnitConversionRateConfig = unit.getOrThrow("unit") - - fun asTiered(): TieredConversionRateConfig = tiered.getOrThrow("tiered") - - fun _json(): JsonValue? = _json - - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): ConversionRateConfig = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) { - unit.validate() - } - - override fun visitTiered(tiered: TieredConversionRateConfig) { - tiered.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) = unit.validity() - - override fun visitTiered(tiered: TieredConversionRateConfig) = tiered.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered - } - - override fun hashCode(): Int = Objects.hash(unit, tiered) - - override fun toString(): String = - when { - unit != null -> "ConversionRateConfig{unit=$unit}" - tiered != null -> "ConversionRateConfig{tiered=$tiered}" - _json != null -> "ConversionRateConfig{_unknown=$_json}" - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - - companion object { - - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - fun ofTiered(tiered: TieredConversionRateConfig) = ConversionRateConfig(tiered = tiered) - } - - /** - * An interface that defines how to map each variant of [ConversionRateConfig] to a value of - * type [T]. - */ - interface Visitor { - - fun visitUnit(unit: UnitConversionRateConfig): T - - fun visitTiered(tiered: TieredConversionRateConfig): T - - /** - * Maps an unknown variant of [ConversionRateConfig] to a value of type [T]. - * - * An instance of [ConversionRateConfig] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if the SDK - * is on an older version than the API, then the API may respond with new variants that - * the SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown ConversionRateConfig: $json") - } - } - - internal class Deserializer : - BaseDeserializer(ConversionRateConfig::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): ConversionRateConfig { - val json = JsonValue.fromJsonNode(node) - val conversionRateType = json.asObject()?.get("conversion_rate_type")?.asString() - - when (conversionRateType) { - "unit" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(unit = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - "tiered" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(tiered = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - } - - return ConversionRateConfig(_json = json) - } - } - - internal class Serializer : - BaseSerializer(ConversionRateConfig::class) { - - override fun serialize( - value: ConversionRateConfig, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unit != null -> generator.writeObject(value.unit) - value.tiered != null -> generator.writeObject(value.tiered) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - } - } - } - /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanMaxGroupTieredPackagePrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanMaxGroupTieredPackagePrice.kt index a9a1d06cb..6db67a12b 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanMaxGroupTieredPackagePrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanMaxGroupTieredPackagePrice.kt @@ -6,22 +6,12 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.withorb.api.core.BaseDeserializer -import com.withorb.api.core.BaseSerializer import com.withorb.api.core.Enum import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.checkRequired -import com.withorb.api.core.getOrThrow import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import java.util.Collections @@ -1336,175 +1326,6 @@ private constructor( override fun toString() = value.toString() } - /** The configuration for the rate of the price currency to the invoicing currency. */ - @JsonDeserialize(using = ConversionRateConfig.Deserializer::class) - @JsonSerialize(using = ConversionRateConfig.Serializer::class) - class ConversionRateConfig - private constructor( - private val unit: UnitConversionRateConfig? = null, - private val tiered: TieredConversionRateConfig? = null, - private val _json: JsonValue? = null, - ) { - - fun unit(): UnitConversionRateConfig? = unit - - fun tiered(): TieredConversionRateConfig? = tiered - - fun isUnit(): Boolean = unit != null - - fun isTiered(): Boolean = tiered != null - - fun asUnit(): UnitConversionRateConfig = unit.getOrThrow("unit") - - fun asTiered(): TieredConversionRateConfig = tiered.getOrThrow("tiered") - - fun _json(): JsonValue? = _json - - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): ConversionRateConfig = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) { - unit.validate() - } - - override fun visitTiered(tiered: TieredConversionRateConfig) { - tiered.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) = unit.validity() - - override fun visitTiered(tiered: TieredConversionRateConfig) = tiered.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered - } - - override fun hashCode(): Int = Objects.hash(unit, tiered) - - override fun toString(): String = - when { - unit != null -> "ConversionRateConfig{unit=$unit}" - tiered != null -> "ConversionRateConfig{tiered=$tiered}" - _json != null -> "ConversionRateConfig{_unknown=$_json}" - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - - companion object { - - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - fun ofTiered(tiered: TieredConversionRateConfig) = ConversionRateConfig(tiered = tiered) - } - - /** - * An interface that defines how to map each variant of [ConversionRateConfig] to a value of - * type [T]. - */ - interface Visitor { - - fun visitUnit(unit: UnitConversionRateConfig): T - - fun visitTiered(tiered: TieredConversionRateConfig): T - - /** - * Maps an unknown variant of [ConversionRateConfig] to a value of type [T]. - * - * An instance of [ConversionRateConfig] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if the SDK - * is on an older version than the API, then the API may respond with new variants that - * the SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown ConversionRateConfig: $json") - } - } - - internal class Deserializer : - BaseDeserializer(ConversionRateConfig::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): ConversionRateConfig { - val json = JsonValue.fromJsonNode(node) - val conversionRateType = json.asObject()?.get("conversion_rate_type")?.asString() - - when (conversionRateType) { - "unit" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(unit = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - "tiered" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(tiered = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - } - - return ConversionRateConfig(_json = json) - } - } - - internal class Serializer : - BaseSerializer(ConversionRateConfig::class) { - - override fun serialize( - value: ConversionRateConfig, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unit != null -> generator.writeObject(value.unit) - value.tiered != null -> generator.writeObject(value.tiered) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - } - } - } - /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanPackagePrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanPackagePrice.kt index 4404ca0dc..35a1795ff 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanPackagePrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanPackagePrice.kt @@ -6,22 +6,12 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.withorb.api.core.BaseDeserializer -import com.withorb.api.core.BaseSerializer import com.withorb.api.core.Enum import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.checkRequired -import com.withorb.api.core.getOrThrow import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import java.util.Collections @@ -1221,175 +1211,6 @@ private constructor( override fun toString() = value.toString() } - /** The configuration for the rate of the price currency to the invoicing currency. */ - @JsonDeserialize(using = ConversionRateConfig.Deserializer::class) - @JsonSerialize(using = ConversionRateConfig.Serializer::class) - class ConversionRateConfig - private constructor( - private val unit: UnitConversionRateConfig? = null, - private val tiered: TieredConversionRateConfig? = null, - private val _json: JsonValue? = null, - ) { - - fun unit(): UnitConversionRateConfig? = unit - - fun tiered(): TieredConversionRateConfig? = tiered - - fun isUnit(): Boolean = unit != null - - fun isTiered(): Boolean = tiered != null - - fun asUnit(): UnitConversionRateConfig = unit.getOrThrow("unit") - - fun asTiered(): TieredConversionRateConfig = tiered.getOrThrow("tiered") - - fun _json(): JsonValue? = _json - - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): ConversionRateConfig = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) { - unit.validate() - } - - override fun visitTiered(tiered: TieredConversionRateConfig) { - tiered.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) = unit.validity() - - override fun visitTiered(tiered: TieredConversionRateConfig) = tiered.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered - } - - override fun hashCode(): Int = Objects.hash(unit, tiered) - - override fun toString(): String = - when { - unit != null -> "ConversionRateConfig{unit=$unit}" - tiered != null -> "ConversionRateConfig{tiered=$tiered}" - _json != null -> "ConversionRateConfig{_unknown=$_json}" - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - - companion object { - - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - fun ofTiered(tiered: TieredConversionRateConfig) = ConversionRateConfig(tiered = tiered) - } - - /** - * An interface that defines how to map each variant of [ConversionRateConfig] to a value of - * type [T]. - */ - interface Visitor { - - fun visitUnit(unit: UnitConversionRateConfig): T - - fun visitTiered(tiered: TieredConversionRateConfig): T - - /** - * Maps an unknown variant of [ConversionRateConfig] to a value of type [T]. - * - * An instance of [ConversionRateConfig] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if the SDK - * is on an older version than the API, then the API may respond with new variants that - * the SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown ConversionRateConfig: $json") - } - } - - internal class Deserializer : - BaseDeserializer(ConversionRateConfig::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): ConversionRateConfig { - val json = JsonValue.fromJsonNode(node) - val conversionRateType = json.asObject()?.get("conversion_rate_type")?.asString() - - when (conversionRateType) { - "unit" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(unit = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - "tiered" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(tiered = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - } - - return ConversionRateConfig(_json = json) - } - } - - internal class Serializer : - BaseSerializer(ConversionRateConfig::class) { - - override fun serialize( - value: ConversionRateConfig, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unit != null -> generator.writeObject(value.unit) - value.tiered != null -> generator.writeObject(value.tiered) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - } - } - } - /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanPackageWithAllocationPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanPackageWithAllocationPrice.kt index c3d3be813..634948f22 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanPackageWithAllocationPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanPackageWithAllocationPrice.kt @@ -6,22 +6,12 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.withorb.api.core.BaseDeserializer -import com.withorb.api.core.BaseSerializer import com.withorb.api.core.Enum import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.checkRequired -import com.withorb.api.core.getOrThrow import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import java.util.Collections @@ -1336,175 +1326,6 @@ private constructor( "PackageWithAllocationConfig{additionalProperties=$additionalProperties}" } - /** The configuration for the rate of the price currency to the invoicing currency. */ - @JsonDeserialize(using = ConversionRateConfig.Deserializer::class) - @JsonSerialize(using = ConversionRateConfig.Serializer::class) - class ConversionRateConfig - private constructor( - private val unit: UnitConversionRateConfig? = null, - private val tiered: TieredConversionRateConfig? = null, - private val _json: JsonValue? = null, - ) { - - fun unit(): UnitConversionRateConfig? = unit - - fun tiered(): TieredConversionRateConfig? = tiered - - fun isUnit(): Boolean = unit != null - - fun isTiered(): Boolean = tiered != null - - fun asUnit(): UnitConversionRateConfig = unit.getOrThrow("unit") - - fun asTiered(): TieredConversionRateConfig = tiered.getOrThrow("tiered") - - fun _json(): JsonValue? = _json - - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): ConversionRateConfig = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) { - unit.validate() - } - - override fun visitTiered(tiered: TieredConversionRateConfig) { - tiered.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) = unit.validity() - - override fun visitTiered(tiered: TieredConversionRateConfig) = tiered.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered - } - - override fun hashCode(): Int = Objects.hash(unit, tiered) - - override fun toString(): String = - when { - unit != null -> "ConversionRateConfig{unit=$unit}" - tiered != null -> "ConversionRateConfig{tiered=$tiered}" - _json != null -> "ConversionRateConfig{_unknown=$_json}" - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - - companion object { - - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - fun ofTiered(tiered: TieredConversionRateConfig) = ConversionRateConfig(tiered = tiered) - } - - /** - * An interface that defines how to map each variant of [ConversionRateConfig] to a value of - * type [T]. - */ - interface Visitor { - - fun visitUnit(unit: UnitConversionRateConfig): T - - fun visitTiered(tiered: TieredConversionRateConfig): T - - /** - * Maps an unknown variant of [ConversionRateConfig] to a value of type [T]. - * - * An instance of [ConversionRateConfig] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if the SDK - * is on an older version than the API, then the API may respond with new variants that - * the SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown ConversionRateConfig: $json") - } - } - - internal class Deserializer : - BaseDeserializer(ConversionRateConfig::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): ConversionRateConfig { - val json = JsonValue.fromJsonNode(node) - val conversionRateType = json.asObject()?.get("conversion_rate_type")?.asString() - - when (conversionRateType) { - "unit" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(unit = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - "tiered" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(tiered = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - } - - return ConversionRateConfig(_json = json) - } - } - - internal class Serializer : - BaseSerializer(ConversionRateConfig::class) { - - override fun serialize( - value: ConversionRateConfig, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unit != null -> generator.writeObject(value.unit) - value.tiered != null -> generator.writeObject(value.tiered) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - } - } - } - /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanScalableMatrixWithTieredPricingPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanScalableMatrixWithTieredPricingPrice.kt index 15e1563c4..ef3604f00 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanScalableMatrixWithTieredPricingPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanScalableMatrixWithTieredPricingPrice.kt @@ -6,22 +6,12 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.withorb.api.core.BaseDeserializer -import com.withorb.api.core.BaseSerializer import com.withorb.api.core.Enum import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.checkRequired -import com.withorb.api.core.getOrThrow import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import java.util.Collections @@ -1354,175 +1344,6 @@ private constructor( "ScalableMatrixWithTieredPricingConfig{additionalProperties=$additionalProperties}" } - /** The configuration for the rate of the price currency to the invoicing currency. */ - @JsonDeserialize(using = ConversionRateConfig.Deserializer::class) - @JsonSerialize(using = ConversionRateConfig.Serializer::class) - class ConversionRateConfig - private constructor( - private val unit: UnitConversionRateConfig? = null, - private val tiered: TieredConversionRateConfig? = null, - private val _json: JsonValue? = null, - ) { - - fun unit(): UnitConversionRateConfig? = unit - - fun tiered(): TieredConversionRateConfig? = tiered - - fun isUnit(): Boolean = unit != null - - fun isTiered(): Boolean = tiered != null - - fun asUnit(): UnitConversionRateConfig = unit.getOrThrow("unit") - - fun asTiered(): TieredConversionRateConfig = tiered.getOrThrow("tiered") - - fun _json(): JsonValue? = _json - - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): ConversionRateConfig = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) { - unit.validate() - } - - override fun visitTiered(tiered: TieredConversionRateConfig) { - tiered.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) = unit.validity() - - override fun visitTiered(tiered: TieredConversionRateConfig) = tiered.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered - } - - override fun hashCode(): Int = Objects.hash(unit, tiered) - - override fun toString(): String = - when { - unit != null -> "ConversionRateConfig{unit=$unit}" - tiered != null -> "ConversionRateConfig{tiered=$tiered}" - _json != null -> "ConversionRateConfig{_unknown=$_json}" - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - - companion object { - - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - fun ofTiered(tiered: TieredConversionRateConfig) = ConversionRateConfig(tiered = tiered) - } - - /** - * An interface that defines how to map each variant of [ConversionRateConfig] to a value of - * type [T]. - */ - interface Visitor { - - fun visitUnit(unit: UnitConversionRateConfig): T - - fun visitTiered(tiered: TieredConversionRateConfig): T - - /** - * Maps an unknown variant of [ConversionRateConfig] to a value of type [T]. - * - * An instance of [ConversionRateConfig] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if the SDK - * is on an older version than the API, then the API may respond with new variants that - * the SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown ConversionRateConfig: $json") - } - } - - internal class Deserializer : - BaseDeserializer(ConversionRateConfig::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): ConversionRateConfig { - val json = JsonValue.fromJsonNode(node) - val conversionRateType = json.asObject()?.get("conversion_rate_type")?.asString() - - when (conversionRateType) { - "unit" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(unit = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - "tiered" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(tiered = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - } - - return ConversionRateConfig(_json = json) - } - } - - internal class Serializer : - BaseSerializer(ConversionRateConfig::class) { - - override fun serialize( - value: ConversionRateConfig, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unit != null -> generator.writeObject(value.unit) - value.tiered != null -> generator.writeObject(value.tiered) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - } - } - } - /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanScalableMatrixWithUnitPricingPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanScalableMatrixWithUnitPricingPrice.kt index 9b8f540a1..7aaf64ca6 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanScalableMatrixWithUnitPricingPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanScalableMatrixWithUnitPricingPrice.kt @@ -6,22 +6,12 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.withorb.api.core.BaseDeserializer -import com.withorb.api.core.BaseSerializer import com.withorb.api.core.Enum import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.checkRequired -import com.withorb.api.core.getOrThrow import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import java.util.Collections @@ -1346,175 +1336,6 @@ private constructor( "ScalableMatrixWithUnitPricingConfig{additionalProperties=$additionalProperties}" } - /** The configuration for the rate of the price currency to the invoicing currency. */ - @JsonDeserialize(using = ConversionRateConfig.Deserializer::class) - @JsonSerialize(using = ConversionRateConfig.Serializer::class) - class ConversionRateConfig - private constructor( - private val unit: UnitConversionRateConfig? = null, - private val tiered: TieredConversionRateConfig? = null, - private val _json: JsonValue? = null, - ) { - - fun unit(): UnitConversionRateConfig? = unit - - fun tiered(): TieredConversionRateConfig? = tiered - - fun isUnit(): Boolean = unit != null - - fun isTiered(): Boolean = tiered != null - - fun asUnit(): UnitConversionRateConfig = unit.getOrThrow("unit") - - fun asTiered(): TieredConversionRateConfig = tiered.getOrThrow("tiered") - - fun _json(): JsonValue? = _json - - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): ConversionRateConfig = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) { - unit.validate() - } - - override fun visitTiered(tiered: TieredConversionRateConfig) { - tiered.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) = unit.validity() - - override fun visitTiered(tiered: TieredConversionRateConfig) = tiered.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered - } - - override fun hashCode(): Int = Objects.hash(unit, tiered) - - override fun toString(): String = - when { - unit != null -> "ConversionRateConfig{unit=$unit}" - tiered != null -> "ConversionRateConfig{tiered=$tiered}" - _json != null -> "ConversionRateConfig{_unknown=$_json}" - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - - companion object { - - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - fun ofTiered(tiered: TieredConversionRateConfig) = ConversionRateConfig(tiered = tiered) - } - - /** - * An interface that defines how to map each variant of [ConversionRateConfig] to a value of - * type [T]. - */ - interface Visitor { - - fun visitUnit(unit: UnitConversionRateConfig): T - - fun visitTiered(tiered: TieredConversionRateConfig): T - - /** - * Maps an unknown variant of [ConversionRateConfig] to a value of type [T]. - * - * An instance of [ConversionRateConfig] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if the SDK - * is on an older version than the API, then the API may respond with new variants that - * the SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown ConversionRateConfig: $json") - } - } - - internal class Deserializer : - BaseDeserializer(ConversionRateConfig::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): ConversionRateConfig { - val json = JsonValue.fromJsonNode(node) - val conversionRateType = json.asObject()?.get("conversion_rate_type")?.asString() - - when (conversionRateType) { - "unit" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(unit = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - "tiered" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(tiered = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - } - - return ConversionRateConfig(_json = json) - } - } - - internal class Serializer : - BaseSerializer(ConversionRateConfig::class) { - - override fun serialize( - value: ConversionRateConfig, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unit != null -> generator.writeObject(value.unit) - value.tiered != null -> generator.writeObject(value.tiered) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - } - } - } - /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanThresholdTotalAmountPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanThresholdTotalAmountPrice.kt index ec6c68ce5..161bf9ccc 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanThresholdTotalAmountPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanThresholdTotalAmountPrice.kt @@ -6,22 +6,12 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.withorb.api.core.BaseDeserializer -import com.withorb.api.core.BaseSerializer import com.withorb.api.core.Enum import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.checkRequired -import com.withorb.api.core.getOrThrow import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import java.util.Collections @@ -1336,175 +1326,6 @@ private constructor( "ThresholdTotalAmountConfig{additionalProperties=$additionalProperties}" } - /** The configuration for the rate of the price currency to the invoicing currency. */ - @JsonDeserialize(using = ConversionRateConfig.Deserializer::class) - @JsonSerialize(using = ConversionRateConfig.Serializer::class) - class ConversionRateConfig - private constructor( - private val unit: UnitConversionRateConfig? = null, - private val tiered: TieredConversionRateConfig? = null, - private val _json: JsonValue? = null, - ) { - - fun unit(): UnitConversionRateConfig? = unit - - fun tiered(): TieredConversionRateConfig? = tiered - - fun isUnit(): Boolean = unit != null - - fun isTiered(): Boolean = tiered != null - - fun asUnit(): UnitConversionRateConfig = unit.getOrThrow("unit") - - fun asTiered(): TieredConversionRateConfig = tiered.getOrThrow("tiered") - - fun _json(): JsonValue? = _json - - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): ConversionRateConfig = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) { - unit.validate() - } - - override fun visitTiered(tiered: TieredConversionRateConfig) { - tiered.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) = unit.validity() - - override fun visitTiered(tiered: TieredConversionRateConfig) = tiered.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered - } - - override fun hashCode(): Int = Objects.hash(unit, tiered) - - override fun toString(): String = - when { - unit != null -> "ConversionRateConfig{unit=$unit}" - tiered != null -> "ConversionRateConfig{tiered=$tiered}" - _json != null -> "ConversionRateConfig{_unknown=$_json}" - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - - companion object { - - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - fun ofTiered(tiered: TieredConversionRateConfig) = ConversionRateConfig(tiered = tiered) - } - - /** - * An interface that defines how to map each variant of [ConversionRateConfig] to a value of - * type [T]. - */ - interface Visitor { - - fun visitUnit(unit: UnitConversionRateConfig): T - - fun visitTiered(tiered: TieredConversionRateConfig): T - - /** - * Maps an unknown variant of [ConversionRateConfig] to a value of type [T]. - * - * An instance of [ConversionRateConfig] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if the SDK - * is on an older version than the API, then the API may respond with new variants that - * the SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown ConversionRateConfig: $json") - } - } - - internal class Deserializer : - BaseDeserializer(ConversionRateConfig::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): ConversionRateConfig { - val json = JsonValue.fromJsonNode(node) - val conversionRateType = json.asObject()?.get("conversion_rate_type")?.asString() - - when (conversionRateType) { - "unit" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(unit = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - "tiered" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(tiered = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - } - - return ConversionRateConfig(_json = json) - } - } - - internal class Serializer : - BaseSerializer(ConversionRateConfig::class) { - - override fun serialize( - value: ConversionRateConfig, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unit != null -> generator.writeObject(value.unit) - value.tiered != null -> generator.writeObject(value.tiered) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - } - } - } - /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanTierWithProrationPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanTierWithProrationPrice.kt index 53911e4b4..18497940a 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanTierWithProrationPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanTierWithProrationPrice.kt @@ -6,22 +6,12 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.withorb.api.core.BaseDeserializer -import com.withorb.api.core.BaseSerializer import com.withorb.api.core.Enum import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.checkRequired -import com.withorb.api.core.getOrThrow import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import java.util.Collections @@ -1330,175 +1320,6 @@ private constructor( "TieredWithProrationConfig{additionalProperties=$additionalProperties}" } - /** The configuration for the rate of the price currency to the invoicing currency. */ - @JsonDeserialize(using = ConversionRateConfig.Deserializer::class) - @JsonSerialize(using = ConversionRateConfig.Serializer::class) - class ConversionRateConfig - private constructor( - private val unit: UnitConversionRateConfig? = null, - private val tiered: TieredConversionRateConfig? = null, - private val _json: JsonValue? = null, - ) { - - fun unit(): UnitConversionRateConfig? = unit - - fun tiered(): TieredConversionRateConfig? = tiered - - fun isUnit(): Boolean = unit != null - - fun isTiered(): Boolean = tiered != null - - fun asUnit(): UnitConversionRateConfig = unit.getOrThrow("unit") - - fun asTiered(): TieredConversionRateConfig = tiered.getOrThrow("tiered") - - fun _json(): JsonValue? = _json - - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): ConversionRateConfig = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) { - unit.validate() - } - - override fun visitTiered(tiered: TieredConversionRateConfig) { - tiered.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) = unit.validity() - - override fun visitTiered(tiered: TieredConversionRateConfig) = tiered.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered - } - - override fun hashCode(): Int = Objects.hash(unit, tiered) - - override fun toString(): String = - when { - unit != null -> "ConversionRateConfig{unit=$unit}" - tiered != null -> "ConversionRateConfig{tiered=$tiered}" - _json != null -> "ConversionRateConfig{_unknown=$_json}" - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - - companion object { - - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - fun ofTiered(tiered: TieredConversionRateConfig) = ConversionRateConfig(tiered = tiered) - } - - /** - * An interface that defines how to map each variant of [ConversionRateConfig] to a value of - * type [T]. - */ - interface Visitor { - - fun visitUnit(unit: UnitConversionRateConfig): T - - fun visitTiered(tiered: TieredConversionRateConfig): T - - /** - * Maps an unknown variant of [ConversionRateConfig] to a value of type [T]. - * - * An instance of [ConversionRateConfig] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if the SDK - * is on an older version than the API, then the API may respond with new variants that - * the SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown ConversionRateConfig: $json") - } - } - - internal class Deserializer : - BaseDeserializer(ConversionRateConfig::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): ConversionRateConfig { - val json = JsonValue.fromJsonNode(node) - val conversionRateType = json.asObject()?.get("conversion_rate_type")?.asString() - - when (conversionRateType) { - "unit" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(unit = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - "tiered" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(tiered = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - } - - return ConversionRateConfig(_json = json) - } - } - - internal class Serializer : - BaseSerializer(ConversionRateConfig::class) { - - override fun serialize( - value: ConversionRateConfig, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unit != null -> generator.writeObject(value.unit) - value.tiered != null -> generator.writeObject(value.tiered) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - } - } - } - /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanTieredBpsPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanTieredBpsPrice.kt index b53f55648..55cbd708b 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanTieredBpsPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanTieredBpsPrice.kt @@ -6,22 +6,12 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.withorb.api.core.BaseDeserializer -import com.withorb.api.core.BaseSerializer import com.withorb.api.core.Enum import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.checkRequired -import com.withorb.api.core.getOrThrow import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import java.util.Collections @@ -1222,175 +1212,6 @@ private constructor( override fun toString() = value.toString() } - /** The configuration for the rate of the price currency to the invoicing currency. */ - @JsonDeserialize(using = ConversionRateConfig.Deserializer::class) - @JsonSerialize(using = ConversionRateConfig.Serializer::class) - class ConversionRateConfig - private constructor( - private val unit: UnitConversionRateConfig? = null, - private val tiered: TieredConversionRateConfig? = null, - private val _json: JsonValue? = null, - ) { - - fun unit(): UnitConversionRateConfig? = unit - - fun tiered(): TieredConversionRateConfig? = tiered - - fun isUnit(): Boolean = unit != null - - fun isTiered(): Boolean = tiered != null - - fun asUnit(): UnitConversionRateConfig = unit.getOrThrow("unit") - - fun asTiered(): TieredConversionRateConfig = tiered.getOrThrow("tiered") - - fun _json(): JsonValue? = _json - - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): ConversionRateConfig = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) { - unit.validate() - } - - override fun visitTiered(tiered: TieredConversionRateConfig) { - tiered.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) = unit.validity() - - override fun visitTiered(tiered: TieredConversionRateConfig) = tiered.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered - } - - override fun hashCode(): Int = Objects.hash(unit, tiered) - - override fun toString(): String = - when { - unit != null -> "ConversionRateConfig{unit=$unit}" - tiered != null -> "ConversionRateConfig{tiered=$tiered}" - _json != null -> "ConversionRateConfig{_unknown=$_json}" - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - - companion object { - - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - fun ofTiered(tiered: TieredConversionRateConfig) = ConversionRateConfig(tiered = tiered) - } - - /** - * An interface that defines how to map each variant of [ConversionRateConfig] to a value of - * type [T]. - */ - interface Visitor { - - fun visitUnit(unit: UnitConversionRateConfig): T - - fun visitTiered(tiered: TieredConversionRateConfig): T - - /** - * Maps an unknown variant of [ConversionRateConfig] to a value of type [T]. - * - * An instance of [ConversionRateConfig] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if the SDK - * is on an older version than the API, then the API may respond with new variants that - * the SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown ConversionRateConfig: $json") - } - } - - internal class Deserializer : - BaseDeserializer(ConversionRateConfig::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): ConversionRateConfig { - val json = JsonValue.fromJsonNode(node) - val conversionRateType = json.asObject()?.get("conversion_rate_type")?.asString() - - when (conversionRateType) { - "unit" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(unit = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - "tiered" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(tiered = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - } - - return ConversionRateConfig(_json = json) - } - } - - internal class Serializer : - BaseSerializer(ConversionRateConfig::class) { - - override fun serialize( - value: ConversionRateConfig, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unit != null -> generator.writeObject(value.unit) - value.tiered != null -> generator.writeObject(value.tiered) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - } - } - } - /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanTieredPackagePrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanTieredPackagePrice.kt index c72ee82e3..6cbd86c32 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanTieredPackagePrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanTieredPackagePrice.kt @@ -6,22 +6,12 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.withorb.api.core.BaseDeserializer -import com.withorb.api.core.BaseSerializer import com.withorb.api.core.Enum import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.checkRequired -import com.withorb.api.core.getOrThrow import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import java.util.Collections @@ -1323,175 +1313,6 @@ private constructor( override fun toString() = "TieredPackageConfig{additionalProperties=$additionalProperties}" } - /** The configuration for the rate of the price currency to the invoicing currency. */ - @JsonDeserialize(using = ConversionRateConfig.Deserializer::class) - @JsonSerialize(using = ConversionRateConfig.Serializer::class) - class ConversionRateConfig - private constructor( - private val unit: UnitConversionRateConfig? = null, - private val tiered: TieredConversionRateConfig? = null, - private val _json: JsonValue? = null, - ) { - - fun unit(): UnitConversionRateConfig? = unit - - fun tiered(): TieredConversionRateConfig? = tiered - - fun isUnit(): Boolean = unit != null - - fun isTiered(): Boolean = tiered != null - - fun asUnit(): UnitConversionRateConfig = unit.getOrThrow("unit") - - fun asTiered(): TieredConversionRateConfig = tiered.getOrThrow("tiered") - - fun _json(): JsonValue? = _json - - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): ConversionRateConfig = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) { - unit.validate() - } - - override fun visitTiered(tiered: TieredConversionRateConfig) { - tiered.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) = unit.validity() - - override fun visitTiered(tiered: TieredConversionRateConfig) = tiered.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered - } - - override fun hashCode(): Int = Objects.hash(unit, tiered) - - override fun toString(): String = - when { - unit != null -> "ConversionRateConfig{unit=$unit}" - tiered != null -> "ConversionRateConfig{tiered=$tiered}" - _json != null -> "ConversionRateConfig{_unknown=$_json}" - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - - companion object { - - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - fun ofTiered(tiered: TieredConversionRateConfig) = ConversionRateConfig(tiered = tiered) - } - - /** - * An interface that defines how to map each variant of [ConversionRateConfig] to a value of - * type [T]. - */ - interface Visitor { - - fun visitUnit(unit: UnitConversionRateConfig): T - - fun visitTiered(tiered: TieredConversionRateConfig): T - - /** - * Maps an unknown variant of [ConversionRateConfig] to a value of type [T]. - * - * An instance of [ConversionRateConfig] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if the SDK - * is on an older version than the API, then the API may respond with new variants that - * the SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown ConversionRateConfig: $json") - } - } - - internal class Deserializer : - BaseDeserializer(ConversionRateConfig::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): ConversionRateConfig { - val json = JsonValue.fromJsonNode(node) - val conversionRateType = json.asObject()?.get("conversion_rate_type")?.asString() - - when (conversionRateType) { - "unit" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(unit = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - "tiered" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(tiered = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - } - - return ConversionRateConfig(_json = json) - } - } - - internal class Serializer : - BaseSerializer(ConversionRateConfig::class) { - - override fun serialize( - value: ConversionRateConfig, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unit != null -> generator.writeObject(value.unit) - value.tiered != null -> generator.writeObject(value.tiered) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - } - } - } - /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanTieredPackageWithMinimumPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanTieredPackageWithMinimumPrice.kt index 5a9e48a73..98db828b0 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanTieredPackageWithMinimumPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanTieredPackageWithMinimumPrice.kt @@ -6,22 +6,12 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.withorb.api.core.BaseDeserializer -import com.withorb.api.core.BaseSerializer import com.withorb.api.core.Enum import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.checkRequired -import com.withorb.api.core.getOrThrow import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import java.util.Collections @@ -1341,175 +1331,6 @@ private constructor( "TieredPackageWithMinimumConfig{additionalProperties=$additionalProperties}" } - /** The configuration for the rate of the price currency to the invoicing currency. */ - @JsonDeserialize(using = ConversionRateConfig.Deserializer::class) - @JsonSerialize(using = ConversionRateConfig.Serializer::class) - class ConversionRateConfig - private constructor( - private val unit: UnitConversionRateConfig? = null, - private val tiered: TieredConversionRateConfig? = null, - private val _json: JsonValue? = null, - ) { - - fun unit(): UnitConversionRateConfig? = unit - - fun tiered(): TieredConversionRateConfig? = tiered - - fun isUnit(): Boolean = unit != null - - fun isTiered(): Boolean = tiered != null - - fun asUnit(): UnitConversionRateConfig = unit.getOrThrow("unit") - - fun asTiered(): TieredConversionRateConfig = tiered.getOrThrow("tiered") - - fun _json(): JsonValue? = _json - - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): ConversionRateConfig = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) { - unit.validate() - } - - override fun visitTiered(tiered: TieredConversionRateConfig) { - tiered.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) = unit.validity() - - override fun visitTiered(tiered: TieredConversionRateConfig) = tiered.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered - } - - override fun hashCode(): Int = Objects.hash(unit, tiered) - - override fun toString(): String = - when { - unit != null -> "ConversionRateConfig{unit=$unit}" - tiered != null -> "ConversionRateConfig{tiered=$tiered}" - _json != null -> "ConversionRateConfig{_unknown=$_json}" - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - - companion object { - - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - fun ofTiered(tiered: TieredConversionRateConfig) = ConversionRateConfig(tiered = tiered) - } - - /** - * An interface that defines how to map each variant of [ConversionRateConfig] to a value of - * type [T]. - */ - interface Visitor { - - fun visitUnit(unit: UnitConversionRateConfig): T - - fun visitTiered(tiered: TieredConversionRateConfig): T - - /** - * Maps an unknown variant of [ConversionRateConfig] to a value of type [T]. - * - * An instance of [ConversionRateConfig] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if the SDK - * is on an older version than the API, then the API may respond with new variants that - * the SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown ConversionRateConfig: $json") - } - } - - internal class Deserializer : - BaseDeserializer(ConversionRateConfig::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): ConversionRateConfig { - val json = JsonValue.fromJsonNode(node) - val conversionRateType = json.asObject()?.get("conversion_rate_type")?.asString() - - when (conversionRateType) { - "unit" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(unit = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - "tiered" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(tiered = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - } - - return ConversionRateConfig(_json = json) - } - } - - internal class Serializer : - BaseSerializer(ConversionRateConfig::class) { - - override fun serialize( - value: ConversionRateConfig, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unit != null -> generator.writeObject(value.unit) - value.tiered != null -> generator.writeObject(value.tiered) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - } - } - } - /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanTieredPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanTieredPrice.kt index 52e7eca1d..0a312f614 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanTieredPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanTieredPrice.kt @@ -6,22 +6,12 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.withorb.api.core.BaseDeserializer -import com.withorb.api.core.BaseSerializer import com.withorb.api.core.Enum import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.checkRequired -import com.withorb.api.core.getOrThrow import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import java.util.Collections @@ -1221,175 +1211,6 @@ private constructor( override fun toString() = value.toString() } - /** The configuration for the rate of the price currency to the invoicing currency. */ - @JsonDeserialize(using = ConversionRateConfig.Deserializer::class) - @JsonSerialize(using = ConversionRateConfig.Serializer::class) - class ConversionRateConfig - private constructor( - private val unit: UnitConversionRateConfig? = null, - private val tiered: TieredConversionRateConfig? = null, - private val _json: JsonValue? = null, - ) { - - fun unit(): UnitConversionRateConfig? = unit - - fun tiered(): TieredConversionRateConfig? = tiered - - fun isUnit(): Boolean = unit != null - - fun isTiered(): Boolean = tiered != null - - fun asUnit(): UnitConversionRateConfig = unit.getOrThrow("unit") - - fun asTiered(): TieredConversionRateConfig = tiered.getOrThrow("tiered") - - fun _json(): JsonValue? = _json - - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): ConversionRateConfig = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) { - unit.validate() - } - - override fun visitTiered(tiered: TieredConversionRateConfig) { - tiered.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) = unit.validity() - - override fun visitTiered(tiered: TieredConversionRateConfig) = tiered.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered - } - - override fun hashCode(): Int = Objects.hash(unit, tiered) - - override fun toString(): String = - when { - unit != null -> "ConversionRateConfig{unit=$unit}" - tiered != null -> "ConversionRateConfig{tiered=$tiered}" - _json != null -> "ConversionRateConfig{_unknown=$_json}" - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - - companion object { - - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - fun ofTiered(tiered: TieredConversionRateConfig) = ConversionRateConfig(tiered = tiered) - } - - /** - * An interface that defines how to map each variant of [ConversionRateConfig] to a value of - * type [T]. - */ - interface Visitor { - - fun visitUnit(unit: UnitConversionRateConfig): T - - fun visitTiered(tiered: TieredConversionRateConfig): T - - /** - * Maps an unknown variant of [ConversionRateConfig] to a value of type [T]. - * - * An instance of [ConversionRateConfig] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if the SDK - * is on an older version than the API, then the API may respond with new variants that - * the SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown ConversionRateConfig: $json") - } - } - - internal class Deserializer : - BaseDeserializer(ConversionRateConfig::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): ConversionRateConfig { - val json = JsonValue.fromJsonNode(node) - val conversionRateType = json.asObject()?.get("conversion_rate_type")?.asString() - - when (conversionRateType) { - "unit" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(unit = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - "tiered" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(tiered = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - } - - return ConversionRateConfig(_json = json) - } - } - - internal class Serializer : - BaseSerializer(ConversionRateConfig::class) { - - override fun serialize( - value: ConversionRateConfig, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unit != null -> generator.writeObject(value.unit) - value.tiered != null -> generator.writeObject(value.tiered) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - } - } - } - /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanTieredWithMinimumPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanTieredWithMinimumPrice.kt index afdd7828c..46f83bf7e 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanTieredWithMinimumPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanTieredWithMinimumPrice.kt @@ -6,22 +6,12 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.withorb.api.core.BaseDeserializer -import com.withorb.api.core.BaseSerializer import com.withorb.api.core.Enum import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.checkRequired -import com.withorb.api.core.getOrThrow import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import java.util.Collections @@ -1329,175 +1319,6 @@ private constructor( "TieredWithMinimumConfig{additionalProperties=$additionalProperties}" } - /** The configuration for the rate of the price currency to the invoicing currency. */ - @JsonDeserialize(using = ConversionRateConfig.Deserializer::class) - @JsonSerialize(using = ConversionRateConfig.Serializer::class) - class ConversionRateConfig - private constructor( - private val unit: UnitConversionRateConfig? = null, - private val tiered: TieredConversionRateConfig? = null, - private val _json: JsonValue? = null, - ) { - - fun unit(): UnitConversionRateConfig? = unit - - fun tiered(): TieredConversionRateConfig? = tiered - - fun isUnit(): Boolean = unit != null - - fun isTiered(): Boolean = tiered != null - - fun asUnit(): UnitConversionRateConfig = unit.getOrThrow("unit") - - fun asTiered(): TieredConversionRateConfig = tiered.getOrThrow("tiered") - - fun _json(): JsonValue? = _json - - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): ConversionRateConfig = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) { - unit.validate() - } - - override fun visitTiered(tiered: TieredConversionRateConfig) { - tiered.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) = unit.validity() - - override fun visitTiered(tiered: TieredConversionRateConfig) = tiered.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered - } - - override fun hashCode(): Int = Objects.hash(unit, tiered) - - override fun toString(): String = - when { - unit != null -> "ConversionRateConfig{unit=$unit}" - tiered != null -> "ConversionRateConfig{tiered=$tiered}" - _json != null -> "ConversionRateConfig{_unknown=$_json}" - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - - companion object { - - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - fun ofTiered(tiered: TieredConversionRateConfig) = ConversionRateConfig(tiered = tiered) - } - - /** - * An interface that defines how to map each variant of [ConversionRateConfig] to a value of - * type [T]. - */ - interface Visitor { - - fun visitUnit(unit: UnitConversionRateConfig): T - - fun visitTiered(tiered: TieredConversionRateConfig): T - - /** - * Maps an unknown variant of [ConversionRateConfig] to a value of type [T]. - * - * An instance of [ConversionRateConfig] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if the SDK - * is on an older version than the API, then the API may respond with new variants that - * the SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown ConversionRateConfig: $json") - } - } - - internal class Deserializer : - BaseDeserializer(ConversionRateConfig::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): ConversionRateConfig { - val json = JsonValue.fromJsonNode(node) - val conversionRateType = json.asObject()?.get("conversion_rate_type")?.asString() - - when (conversionRateType) { - "unit" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(unit = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - "tiered" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(tiered = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - } - - return ConversionRateConfig(_json = json) - } - } - - internal class Serializer : - BaseSerializer(ConversionRateConfig::class) { - - override fun serialize( - value: ConversionRateConfig, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unit != null -> generator.writeObject(value.unit) - value.tiered != null -> generator.writeObject(value.tiered) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - } - } - } - /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanUnitPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanUnitPrice.kt index d09a2df64..2dc6fd602 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanUnitPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanUnitPrice.kt @@ -6,22 +6,12 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.withorb.api.core.BaseDeserializer -import com.withorb.api.core.BaseSerializer import com.withorb.api.core.Enum import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.checkRequired -import com.withorb.api.core.getOrThrow import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import java.util.Collections @@ -1219,175 +1209,6 @@ private constructor( override fun toString() = value.toString() } - /** The configuration for the rate of the price currency to the invoicing currency. */ - @JsonDeserialize(using = ConversionRateConfig.Deserializer::class) - @JsonSerialize(using = ConversionRateConfig.Serializer::class) - class ConversionRateConfig - private constructor( - private val unit: UnitConversionRateConfig? = null, - private val tiered: TieredConversionRateConfig? = null, - private val _json: JsonValue? = null, - ) { - - fun unit(): UnitConversionRateConfig? = unit - - fun tiered(): TieredConversionRateConfig? = tiered - - fun isUnit(): Boolean = unit != null - - fun isTiered(): Boolean = tiered != null - - fun asUnit(): UnitConversionRateConfig = unit.getOrThrow("unit") - - fun asTiered(): TieredConversionRateConfig = tiered.getOrThrow("tiered") - - fun _json(): JsonValue? = _json - - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): ConversionRateConfig = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) { - unit.validate() - } - - override fun visitTiered(tiered: TieredConversionRateConfig) { - tiered.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) = unit.validity() - - override fun visitTiered(tiered: TieredConversionRateConfig) = tiered.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered - } - - override fun hashCode(): Int = Objects.hash(unit, tiered) - - override fun toString(): String = - when { - unit != null -> "ConversionRateConfig{unit=$unit}" - tiered != null -> "ConversionRateConfig{tiered=$tiered}" - _json != null -> "ConversionRateConfig{_unknown=$_json}" - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - - companion object { - - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - fun ofTiered(tiered: TieredConversionRateConfig) = ConversionRateConfig(tiered = tiered) - } - - /** - * An interface that defines how to map each variant of [ConversionRateConfig] to a value of - * type [T]. - */ - interface Visitor { - - fun visitUnit(unit: UnitConversionRateConfig): T - - fun visitTiered(tiered: TieredConversionRateConfig): T - - /** - * Maps an unknown variant of [ConversionRateConfig] to a value of type [T]. - * - * An instance of [ConversionRateConfig] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if the SDK - * is on an older version than the API, then the API may respond with new variants that - * the SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown ConversionRateConfig: $json") - } - } - - internal class Deserializer : - BaseDeserializer(ConversionRateConfig::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): ConversionRateConfig { - val json = JsonValue.fromJsonNode(node) - val conversionRateType = json.asObject()?.get("conversion_rate_type")?.asString() - - when (conversionRateType) { - "unit" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(unit = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - "tiered" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(tiered = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - } - - return ConversionRateConfig(_json = json) - } - } - - internal class Serializer : - BaseSerializer(ConversionRateConfig::class) { - - override fun serialize( - value: ConversionRateConfig, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unit != null -> generator.writeObject(value.unit) - value.tiered != null -> generator.writeObject(value.tiered) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - } - } - } - /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanUnitWithPercentPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanUnitWithPercentPrice.kt index e6a081ab0..8e9d67e67 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanUnitWithPercentPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanUnitWithPercentPrice.kt @@ -6,22 +6,12 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.withorb.api.core.BaseDeserializer -import com.withorb.api.core.BaseSerializer import com.withorb.api.core.Enum import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.checkRequired -import com.withorb.api.core.getOrThrow import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import java.util.Collections @@ -1327,175 +1317,6 @@ private constructor( "UnitWithPercentConfig{additionalProperties=$additionalProperties}" } - /** The configuration for the rate of the price currency to the invoicing currency. */ - @JsonDeserialize(using = ConversionRateConfig.Deserializer::class) - @JsonSerialize(using = ConversionRateConfig.Serializer::class) - class ConversionRateConfig - private constructor( - private val unit: UnitConversionRateConfig? = null, - private val tiered: TieredConversionRateConfig? = null, - private val _json: JsonValue? = null, - ) { - - fun unit(): UnitConversionRateConfig? = unit - - fun tiered(): TieredConversionRateConfig? = tiered - - fun isUnit(): Boolean = unit != null - - fun isTiered(): Boolean = tiered != null - - fun asUnit(): UnitConversionRateConfig = unit.getOrThrow("unit") - - fun asTiered(): TieredConversionRateConfig = tiered.getOrThrow("tiered") - - fun _json(): JsonValue? = _json - - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): ConversionRateConfig = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) { - unit.validate() - } - - override fun visitTiered(tiered: TieredConversionRateConfig) { - tiered.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) = unit.validity() - - override fun visitTiered(tiered: TieredConversionRateConfig) = tiered.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered - } - - override fun hashCode(): Int = Objects.hash(unit, tiered) - - override fun toString(): String = - when { - unit != null -> "ConversionRateConfig{unit=$unit}" - tiered != null -> "ConversionRateConfig{tiered=$tiered}" - _json != null -> "ConversionRateConfig{_unknown=$_json}" - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - - companion object { - - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - fun ofTiered(tiered: TieredConversionRateConfig) = ConversionRateConfig(tiered = tiered) - } - - /** - * An interface that defines how to map each variant of [ConversionRateConfig] to a value of - * type [T]. - */ - interface Visitor { - - fun visitUnit(unit: UnitConversionRateConfig): T - - fun visitTiered(tiered: TieredConversionRateConfig): T - - /** - * Maps an unknown variant of [ConversionRateConfig] to a value of type [T]. - * - * An instance of [ConversionRateConfig] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if the SDK - * is on an older version than the API, then the API may respond with new variants that - * the SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown ConversionRateConfig: $json") - } - } - - internal class Deserializer : - BaseDeserializer(ConversionRateConfig::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): ConversionRateConfig { - val json = JsonValue.fromJsonNode(node) - val conversionRateType = json.asObject()?.get("conversion_rate_type")?.asString() - - when (conversionRateType) { - "unit" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(unit = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - "tiered" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(tiered = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - } - - return ConversionRateConfig(_json = json) - } - } - - internal class Serializer : - BaseSerializer(ConversionRateConfig::class) { - - override fun serialize( - value: ConversionRateConfig, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unit != null -> generator.writeObject(value.unit) - value.tiered != null -> generator.writeObject(value.tiered) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - } - } - } - /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanUnitWithProrationPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanUnitWithProrationPrice.kt index 98890f475..e3c420a6a 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanUnitWithProrationPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanUnitWithProrationPrice.kt @@ -6,22 +6,12 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.withorb.api.core.BaseDeserializer -import com.withorb.api.core.BaseSerializer import com.withorb.api.core.Enum import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.checkRequired -import com.withorb.api.core.getOrThrow import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import java.util.Collections @@ -1329,175 +1319,6 @@ private constructor( "UnitWithProrationConfig{additionalProperties=$additionalProperties}" } - /** The configuration for the rate of the price currency to the invoicing currency. */ - @JsonDeserialize(using = ConversionRateConfig.Deserializer::class) - @JsonSerialize(using = ConversionRateConfig.Serializer::class) - class ConversionRateConfig - private constructor( - private val unit: UnitConversionRateConfig? = null, - private val tiered: TieredConversionRateConfig? = null, - private val _json: JsonValue? = null, - ) { - - fun unit(): UnitConversionRateConfig? = unit - - fun tiered(): TieredConversionRateConfig? = tiered - - fun isUnit(): Boolean = unit != null - - fun isTiered(): Boolean = tiered != null - - fun asUnit(): UnitConversionRateConfig = unit.getOrThrow("unit") - - fun asTiered(): TieredConversionRateConfig = tiered.getOrThrow("tiered") - - fun _json(): JsonValue? = _json - - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): ConversionRateConfig = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) { - unit.validate() - } - - override fun visitTiered(tiered: TieredConversionRateConfig) { - tiered.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) = unit.validity() - - override fun visitTiered(tiered: TieredConversionRateConfig) = tiered.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered - } - - override fun hashCode(): Int = Objects.hash(unit, tiered) - - override fun toString(): String = - when { - unit != null -> "ConversionRateConfig{unit=$unit}" - tiered != null -> "ConversionRateConfig{tiered=$tiered}" - _json != null -> "ConversionRateConfig{_unknown=$_json}" - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - - companion object { - - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - fun ofTiered(tiered: TieredConversionRateConfig) = ConversionRateConfig(tiered = tiered) - } - - /** - * An interface that defines how to map each variant of [ConversionRateConfig] to a value of - * type [T]. - */ - interface Visitor { - - fun visitUnit(unit: UnitConversionRateConfig): T - - fun visitTiered(tiered: TieredConversionRateConfig): T - - /** - * Maps an unknown variant of [ConversionRateConfig] to a value of type [T]. - * - * An instance of [ConversionRateConfig] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if the SDK - * is on an older version than the API, then the API may respond with new variants that - * the SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown ConversionRateConfig: $json") - } - } - - internal class Deserializer : - BaseDeserializer(ConversionRateConfig::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): ConversionRateConfig { - val json = JsonValue.fromJsonNode(node) - val conversionRateType = json.asObject()?.get("conversion_rate_type")?.asString() - - when (conversionRateType) { - "unit" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(unit = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - "tiered" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(tiered = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - } - - return ConversionRateConfig(_json = json) - } - } - - internal class Serializer : - BaseSerializer(ConversionRateConfig::class) { - - override fun serialize( - value: ConversionRateConfig, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unit != null -> generator.writeObject(value.unit) - value.tiered != null -> generator.writeObject(value.tiered) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - } - } - } - /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionBpsPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionBpsPrice.kt index ed3826f8a..4aac376b1 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionBpsPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionBpsPrice.kt @@ -6,22 +6,12 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.withorb.api.core.BaseDeserializer -import com.withorb.api.core.BaseSerializer import com.withorb.api.core.Enum import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.checkRequired -import com.withorb.api.core.getOrThrow import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import java.util.Collections @@ -1217,175 +1207,6 @@ private constructor( override fun toString() = value.toString() } - /** The configuration for the rate of the price currency to the invoicing currency. */ - @JsonDeserialize(using = ConversionRateConfig.Deserializer::class) - @JsonSerialize(using = ConversionRateConfig.Serializer::class) - class ConversionRateConfig - private constructor( - private val unit: UnitConversionRateConfig? = null, - private val tiered: TieredConversionRateConfig? = null, - private val _json: JsonValue? = null, - ) { - - fun unit(): UnitConversionRateConfig? = unit - - fun tiered(): TieredConversionRateConfig? = tiered - - fun isUnit(): Boolean = unit != null - - fun isTiered(): Boolean = tiered != null - - fun asUnit(): UnitConversionRateConfig = unit.getOrThrow("unit") - - fun asTiered(): TieredConversionRateConfig = tiered.getOrThrow("tiered") - - fun _json(): JsonValue? = _json - - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): ConversionRateConfig = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) { - unit.validate() - } - - override fun visitTiered(tiered: TieredConversionRateConfig) { - tiered.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) = unit.validity() - - override fun visitTiered(tiered: TieredConversionRateConfig) = tiered.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered - } - - override fun hashCode(): Int = Objects.hash(unit, tiered) - - override fun toString(): String = - when { - unit != null -> "ConversionRateConfig{unit=$unit}" - tiered != null -> "ConversionRateConfig{tiered=$tiered}" - _json != null -> "ConversionRateConfig{_unknown=$_json}" - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - - companion object { - - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - fun ofTiered(tiered: TieredConversionRateConfig) = ConversionRateConfig(tiered = tiered) - } - - /** - * An interface that defines how to map each variant of [ConversionRateConfig] to a value of - * type [T]. - */ - interface Visitor { - - fun visitUnit(unit: UnitConversionRateConfig): T - - fun visitTiered(tiered: TieredConversionRateConfig): T - - /** - * Maps an unknown variant of [ConversionRateConfig] to a value of type [T]. - * - * An instance of [ConversionRateConfig] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if the SDK - * is on an older version than the API, then the API may respond with new variants that - * the SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown ConversionRateConfig: $json") - } - } - - internal class Deserializer : - BaseDeserializer(ConversionRateConfig::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): ConversionRateConfig { - val json = JsonValue.fromJsonNode(node) - val conversionRateType = json.asObject()?.get("conversion_rate_type")?.asString() - - when (conversionRateType) { - "unit" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(unit = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - "tiered" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(tiered = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - } - - return ConversionRateConfig(_json = json) - } - } - - internal class Serializer : - BaseSerializer(ConversionRateConfig::class) { - - override fun serialize( - value: ConversionRateConfig, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unit != null -> generator.writeObject(value.unit) - value.tiered != null -> generator.writeObject(value.tiered) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - } - } - } - /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionBulkBpsPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionBulkBpsPrice.kt index 6b3444985..70c2758d7 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionBulkBpsPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionBulkBpsPrice.kt @@ -6,22 +6,12 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.withorb.api.core.BaseDeserializer -import com.withorb.api.core.BaseSerializer import com.withorb.api.core.Enum import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.checkRequired -import com.withorb.api.core.getOrThrow import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import java.util.Collections @@ -1222,175 +1212,6 @@ private constructor( override fun toString() = value.toString() } - /** The configuration for the rate of the price currency to the invoicing currency. */ - @JsonDeserialize(using = ConversionRateConfig.Deserializer::class) - @JsonSerialize(using = ConversionRateConfig.Serializer::class) - class ConversionRateConfig - private constructor( - private val unit: UnitConversionRateConfig? = null, - private val tiered: TieredConversionRateConfig? = null, - private val _json: JsonValue? = null, - ) { - - fun unit(): UnitConversionRateConfig? = unit - - fun tiered(): TieredConversionRateConfig? = tiered - - fun isUnit(): Boolean = unit != null - - fun isTiered(): Boolean = tiered != null - - fun asUnit(): UnitConversionRateConfig = unit.getOrThrow("unit") - - fun asTiered(): TieredConversionRateConfig = tiered.getOrThrow("tiered") - - fun _json(): JsonValue? = _json - - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): ConversionRateConfig = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) { - unit.validate() - } - - override fun visitTiered(tiered: TieredConversionRateConfig) { - tiered.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) = unit.validity() - - override fun visitTiered(tiered: TieredConversionRateConfig) = tiered.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered - } - - override fun hashCode(): Int = Objects.hash(unit, tiered) - - override fun toString(): String = - when { - unit != null -> "ConversionRateConfig{unit=$unit}" - tiered != null -> "ConversionRateConfig{tiered=$tiered}" - _json != null -> "ConversionRateConfig{_unknown=$_json}" - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - - companion object { - - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - fun ofTiered(tiered: TieredConversionRateConfig) = ConversionRateConfig(tiered = tiered) - } - - /** - * An interface that defines how to map each variant of [ConversionRateConfig] to a value of - * type [T]. - */ - interface Visitor { - - fun visitUnit(unit: UnitConversionRateConfig): T - - fun visitTiered(tiered: TieredConversionRateConfig): T - - /** - * Maps an unknown variant of [ConversionRateConfig] to a value of type [T]. - * - * An instance of [ConversionRateConfig] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if the SDK - * is on an older version than the API, then the API may respond with new variants that - * the SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown ConversionRateConfig: $json") - } - } - - internal class Deserializer : - BaseDeserializer(ConversionRateConfig::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): ConversionRateConfig { - val json = JsonValue.fromJsonNode(node) - val conversionRateType = json.asObject()?.get("conversion_rate_type")?.asString() - - when (conversionRateType) { - "unit" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(unit = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - "tiered" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(tiered = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - } - - return ConversionRateConfig(_json = json) - } - } - - internal class Serializer : - BaseSerializer(ConversionRateConfig::class) { - - override fun serialize( - value: ConversionRateConfig, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unit != null -> generator.writeObject(value.unit) - value.tiered != null -> generator.writeObject(value.tiered) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - } - } - } - /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionBulkPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionBulkPrice.kt index 6bd67fcc1..8a5648595 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionBulkPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionBulkPrice.kt @@ -6,22 +6,12 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.withorb.api.core.BaseDeserializer -import com.withorb.api.core.BaseSerializer import com.withorb.api.core.Enum import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.checkRequired -import com.withorb.api.core.getOrThrow import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import java.util.Collections @@ -1219,175 +1209,6 @@ private constructor( override fun toString() = value.toString() } - /** The configuration for the rate of the price currency to the invoicing currency. */ - @JsonDeserialize(using = ConversionRateConfig.Deserializer::class) - @JsonSerialize(using = ConversionRateConfig.Serializer::class) - class ConversionRateConfig - private constructor( - private val unit: UnitConversionRateConfig? = null, - private val tiered: TieredConversionRateConfig? = null, - private val _json: JsonValue? = null, - ) { - - fun unit(): UnitConversionRateConfig? = unit - - fun tiered(): TieredConversionRateConfig? = tiered - - fun isUnit(): Boolean = unit != null - - fun isTiered(): Boolean = tiered != null - - fun asUnit(): UnitConversionRateConfig = unit.getOrThrow("unit") - - fun asTiered(): TieredConversionRateConfig = tiered.getOrThrow("tiered") - - fun _json(): JsonValue? = _json - - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): ConversionRateConfig = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) { - unit.validate() - } - - override fun visitTiered(tiered: TieredConversionRateConfig) { - tiered.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) = unit.validity() - - override fun visitTiered(tiered: TieredConversionRateConfig) = tiered.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered - } - - override fun hashCode(): Int = Objects.hash(unit, tiered) - - override fun toString(): String = - when { - unit != null -> "ConversionRateConfig{unit=$unit}" - tiered != null -> "ConversionRateConfig{tiered=$tiered}" - _json != null -> "ConversionRateConfig{_unknown=$_json}" - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - - companion object { - - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - fun ofTiered(tiered: TieredConversionRateConfig) = ConversionRateConfig(tiered = tiered) - } - - /** - * An interface that defines how to map each variant of [ConversionRateConfig] to a value of - * type [T]. - */ - interface Visitor { - - fun visitUnit(unit: UnitConversionRateConfig): T - - fun visitTiered(tiered: TieredConversionRateConfig): T - - /** - * Maps an unknown variant of [ConversionRateConfig] to a value of type [T]. - * - * An instance of [ConversionRateConfig] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if the SDK - * is on an older version than the API, then the API may respond with new variants that - * the SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown ConversionRateConfig: $json") - } - } - - internal class Deserializer : - BaseDeserializer(ConversionRateConfig::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): ConversionRateConfig { - val json = JsonValue.fromJsonNode(node) - val conversionRateType = json.asObject()?.get("conversion_rate_type")?.asString() - - when (conversionRateType) { - "unit" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(unit = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - "tiered" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(tiered = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - } - - return ConversionRateConfig(_json = json) - } - } - - internal class Serializer : - BaseSerializer(ConversionRateConfig::class) { - - override fun serialize( - value: ConversionRateConfig, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unit != null -> generator.writeObject(value.unit) - value.tiered != null -> generator.writeObject(value.tiered) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - } - } - } - /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionBulkWithProrationPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionBulkWithProrationPrice.kt index 1aade5342..4a8bfcc50 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionBulkWithProrationPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionBulkWithProrationPrice.kt @@ -6,22 +6,12 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.withorb.api.core.BaseDeserializer -import com.withorb.api.core.BaseSerializer import com.withorb.api.core.Enum import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.checkRequired -import com.withorb.api.core.getOrThrow import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import java.util.Collections @@ -1334,175 +1324,6 @@ private constructor( override fun toString() = value.toString() } - /** The configuration for the rate of the price currency to the invoicing currency. */ - @JsonDeserialize(using = ConversionRateConfig.Deserializer::class) - @JsonSerialize(using = ConversionRateConfig.Serializer::class) - class ConversionRateConfig - private constructor( - private val unit: UnitConversionRateConfig? = null, - private val tiered: TieredConversionRateConfig? = null, - private val _json: JsonValue? = null, - ) { - - fun unit(): UnitConversionRateConfig? = unit - - fun tiered(): TieredConversionRateConfig? = tiered - - fun isUnit(): Boolean = unit != null - - fun isTiered(): Boolean = tiered != null - - fun asUnit(): UnitConversionRateConfig = unit.getOrThrow("unit") - - fun asTiered(): TieredConversionRateConfig = tiered.getOrThrow("tiered") - - fun _json(): JsonValue? = _json - - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): ConversionRateConfig = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) { - unit.validate() - } - - override fun visitTiered(tiered: TieredConversionRateConfig) { - tiered.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) = unit.validity() - - override fun visitTiered(tiered: TieredConversionRateConfig) = tiered.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered - } - - override fun hashCode(): Int = Objects.hash(unit, tiered) - - override fun toString(): String = - when { - unit != null -> "ConversionRateConfig{unit=$unit}" - tiered != null -> "ConversionRateConfig{tiered=$tiered}" - _json != null -> "ConversionRateConfig{_unknown=$_json}" - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - - companion object { - - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - fun ofTiered(tiered: TieredConversionRateConfig) = ConversionRateConfig(tiered = tiered) - } - - /** - * An interface that defines how to map each variant of [ConversionRateConfig] to a value of - * type [T]. - */ - interface Visitor { - - fun visitUnit(unit: UnitConversionRateConfig): T - - fun visitTiered(tiered: TieredConversionRateConfig): T - - /** - * Maps an unknown variant of [ConversionRateConfig] to a value of type [T]. - * - * An instance of [ConversionRateConfig] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if the SDK - * is on an older version than the API, then the API may respond with new variants that - * the SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown ConversionRateConfig: $json") - } - } - - internal class Deserializer : - BaseDeserializer(ConversionRateConfig::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): ConversionRateConfig { - val json = JsonValue.fromJsonNode(node) - val conversionRateType = json.asObject()?.get("conversion_rate_type")?.asString() - - when (conversionRateType) { - "unit" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(unit = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - "tiered" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(tiered = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - } - - return ConversionRateConfig(_json = json) - } - } - - internal class Serializer : - BaseSerializer(ConversionRateConfig::class) { - - override fun serialize( - value: ConversionRateConfig, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unit != null -> generator.writeObject(value.unit) - value.tiered != null -> generator.writeObject(value.tiered) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - } - } - } - /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionCumulativeGroupedBulkPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionCumulativeGroupedBulkPrice.kt index 21eb24b3a..793384cd9 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionCumulativeGroupedBulkPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionCumulativeGroupedBulkPrice.kt @@ -6,22 +6,12 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.withorb.api.core.BaseDeserializer -import com.withorb.api.core.BaseSerializer import com.withorb.api.core.Enum import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.checkRequired -import com.withorb.api.core.getOrThrow import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import java.util.Collections @@ -1337,175 +1327,6 @@ private constructor( override fun toString() = value.toString() } - /** The configuration for the rate of the price currency to the invoicing currency. */ - @JsonDeserialize(using = ConversionRateConfig.Deserializer::class) - @JsonSerialize(using = ConversionRateConfig.Serializer::class) - class ConversionRateConfig - private constructor( - private val unit: UnitConversionRateConfig? = null, - private val tiered: TieredConversionRateConfig? = null, - private val _json: JsonValue? = null, - ) { - - fun unit(): UnitConversionRateConfig? = unit - - fun tiered(): TieredConversionRateConfig? = tiered - - fun isUnit(): Boolean = unit != null - - fun isTiered(): Boolean = tiered != null - - fun asUnit(): UnitConversionRateConfig = unit.getOrThrow("unit") - - fun asTiered(): TieredConversionRateConfig = tiered.getOrThrow("tiered") - - fun _json(): JsonValue? = _json - - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): ConversionRateConfig = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) { - unit.validate() - } - - override fun visitTiered(tiered: TieredConversionRateConfig) { - tiered.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) = unit.validity() - - override fun visitTiered(tiered: TieredConversionRateConfig) = tiered.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered - } - - override fun hashCode(): Int = Objects.hash(unit, tiered) - - override fun toString(): String = - when { - unit != null -> "ConversionRateConfig{unit=$unit}" - tiered != null -> "ConversionRateConfig{tiered=$tiered}" - _json != null -> "ConversionRateConfig{_unknown=$_json}" - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - - companion object { - - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - fun ofTiered(tiered: TieredConversionRateConfig) = ConversionRateConfig(tiered = tiered) - } - - /** - * An interface that defines how to map each variant of [ConversionRateConfig] to a value of - * type [T]. - */ - interface Visitor { - - fun visitUnit(unit: UnitConversionRateConfig): T - - fun visitTiered(tiered: TieredConversionRateConfig): T - - /** - * Maps an unknown variant of [ConversionRateConfig] to a value of type [T]. - * - * An instance of [ConversionRateConfig] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if the SDK - * is on an older version than the API, then the API may respond with new variants that - * the SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown ConversionRateConfig: $json") - } - } - - internal class Deserializer : - BaseDeserializer(ConversionRateConfig::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): ConversionRateConfig { - val json = JsonValue.fromJsonNode(node) - val conversionRateType = json.asObject()?.get("conversion_rate_type")?.asString() - - when (conversionRateType) { - "unit" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(unit = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - "tiered" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(tiered = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - } - - return ConversionRateConfig(_json = json) - } - } - - internal class Serializer : - BaseSerializer(ConversionRateConfig::class) { - - override fun serialize( - value: ConversionRateConfig, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unit != null -> generator.writeObject(value.unit) - value.tiered != null -> generator.writeObject(value.tiered) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - } - } - } - /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionGroupedAllocationPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionGroupedAllocationPrice.kt index ca07438cc..24505a30b 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionGroupedAllocationPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionGroupedAllocationPrice.kt @@ -6,22 +6,12 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.withorb.api.core.BaseDeserializer -import com.withorb.api.core.BaseSerializer import com.withorb.api.core.Enum import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.checkRequired -import com.withorb.api.core.getOrThrow import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import java.util.Collections @@ -1334,175 +1324,6 @@ private constructor( override fun toString() = value.toString() } - /** The configuration for the rate of the price currency to the invoicing currency. */ - @JsonDeserialize(using = ConversionRateConfig.Deserializer::class) - @JsonSerialize(using = ConversionRateConfig.Serializer::class) - class ConversionRateConfig - private constructor( - private val unit: UnitConversionRateConfig? = null, - private val tiered: TieredConversionRateConfig? = null, - private val _json: JsonValue? = null, - ) { - - fun unit(): UnitConversionRateConfig? = unit - - fun tiered(): TieredConversionRateConfig? = tiered - - fun isUnit(): Boolean = unit != null - - fun isTiered(): Boolean = tiered != null - - fun asUnit(): UnitConversionRateConfig = unit.getOrThrow("unit") - - fun asTiered(): TieredConversionRateConfig = tiered.getOrThrow("tiered") - - fun _json(): JsonValue? = _json - - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): ConversionRateConfig = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) { - unit.validate() - } - - override fun visitTiered(tiered: TieredConversionRateConfig) { - tiered.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) = unit.validity() - - override fun visitTiered(tiered: TieredConversionRateConfig) = tiered.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered - } - - override fun hashCode(): Int = Objects.hash(unit, tiered) - - override fun toString(): String = - when { - unit != null -> "ConversionRateConfig{unit=$unit}" - tiered != null -> "ConversionRateConfig{tiered=$tiered}" - _json != null -> "ConversionRateConfig{_unknown=$_json}" - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - - companion object { - - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - fun ofTiered(tiered: TieredConversionRateConfig) = ConversionRateConfig(tiered = tiered) - } - - /** - * An interface that defines how to map each variant of [ConversionRateConfig] to a value of - * type [T]. - */ - interface Visitor { - - fun visitUnit(unit: UnitConversionRateConfig): T - - fun visitTiered(tiered: TieredConversionRateConfig): T - - /** - * Maps an unknown variant of [ConversionRateConfig] to a value of type [T]. - * - * An instance of [ConversionRateConfig] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if the SDK - * is on an older version than the API, then the API may respond with new variants that - * the SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown ConversionRateConfig: $json") - } - } - - internal class Deserializer : - BaseDeserializer(ConversionRateConfig::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): ConversionRateConfig { - val json = JsonValue.fromJsonNode(node) - val conversionRateType = json.asObject()?.get("conversion_rate_type")?.asString() - - when (conversionRateType) { - "unit" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(unit = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - "tiered" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(tiered = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - } - - return ConversionRateConfig(_json = json) - } - } - - internal class Serializer : - BaseSerializer(ConversionRateConfig::class) { - - override fun serialize( - value: ConversionRateConfig, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unit != null -> generator.writeObject(value.unit) - value.tiered != null -> generator.writeObject(value.tiered) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - } - } - } - /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionGroupedTieredPackagePrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionGroupedTieredPackagePrice.kt index eec34db96..92d1725a3 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionGroupedTieredPackagePrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionGroupedTieredPackagePrice.kt @@ -6,22 +6,12 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.withorb.api.core.BaseDeserializer -import com.withorb.api.core.BaseSerializer import com.withorb.api.core.Enum import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.checkRequired -import com.withorb.api.core.getOrThrow import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import java.util.Collections @@ -1337,175 +1327,6 @@ private constructor( override fun toString() = value.toString() } - /** The configuration for the rate of the price currency to the invoicing currency. */ - @JsonDeserialize(using = ConversionRateConfig.Deserializer::class) - @JsonSerialize(using = ConversionRateConfig.Serializer::class) - class ConversionRateConfig - private constructor( - private val unit: UnitConversionRateConfig? = null, - private val tiered: TieredConversionRateConfig? = null, - private val _json: JsonValue? = null, - ) { - - fun unit(): UnitConversionRateConfig? = unit - - fun tiered(): TieredConversionRateConfig? = tiered - - fun isUnit(): Boolean = unit != null - - fun isTiered(): Boolean = tiered != null - - fun asUnit(): UnitConversionRateConfig = unit.getOrThrow("unit") - - fun asTiered(): TieredConversionRateConfig = tiered.getOrThrow("tiered") - - fun _json(): JsonValue? = _json - - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): ConversionRateConfig = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) { - unit.validate() - } - - override fun visitTiered(tiered: TieredConversionRateConfig) { - tiered.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) = unit.validity() - - override fun visitTiered(tiered: TieredConversionRateConfig) = tiered.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered - } - - override fun hashCode(): Int = Objects.hash(unit, tiered) - - override fun toString(): String = - when { - unit != null -> "ConversionRateConfig{unit=$unit}" - tiered != null -> "ConversionRateConfig{tiered=$tiered}" - _json != null -> "ConversionRateConfig{_unknown=$_json}" - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - - companion object { - - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - fun ofTiered(tiered: TieredConversionRateConfig) = ConversionRateConfig(tiered = tiered) - } - - /** - * An interface that defines how to map each variant of [ConversionRateConfig] to a value of - * type [T]. - */ - interface Visitor { - - fun visitUnit(unit: UnitConversionRateConfig): T - - fun visitTiered(tiered: TieredConversionRateConfig): T - - /** - * Maps an unknown variant of [ConversionRateConfig] to a value of type [T]. - * - * An instance of [ConversionRateConfig] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if the SDK - * is on an older version than the API, then the API may respond with new variants that - * the SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown ConversionRateConfig: $json") - } - } - - internal class Deserializer : - BaseDeserializer(ConversionRateConfig::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): ConversionRateConfig { - val json = JsonValue.fromJsonNode(node) - val conversionRateType = json.asObject()?.get("conversion_rate_type")?.asString() - - when (conversionRateType) { - "unit" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(unit = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - "tiered" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(tiered = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - } - - return ConversionRateConfig(_json = json) - } - } - - internal class Serializer : - BaseSerializer(ConversionRateConfig::class) { - - override fun serialize( - value: ConversionRateConfig, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unit != null -> generator.writeObject(value.unit) - value.tiered != null -> generator.writeObject(value.tiered) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - } - } - } - /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionGroupedTieredPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionGroupedTieredPrice.kt index d5e5f0828..a18b5613a 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionGroupedTieredPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionGroupedTieredPrice.kt @@ -6,22 +6,12 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.withorb.api.core.BaseDeserializer -import com.withorb.api.core.BaseSerializer import com.withorb.api.core.Enum import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.checkRequired -import com.withorb.api.core.getOrThrow import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import java.util.Collections @@ -1329,175 +1319,6 @@ private constructor( override fun toString() = value.toString() } - /** The configuration for the rate of the price currency to the invoicing currency. */ - @JsonDeserialize(using = ConversionRateConfig.Deserializer::class) - @JsonSerialize(using = ConversionRateConfig.Serializer::class) - class ConversionRateConfig - private constructor( - private val unit: UnitConversionRateConfig? = null, - private val tiered: TieredConversionRateConfig? = null, - private val _json: JsonValue? = null, - ) { - - fun unit(): UnitConversionRateConfig? = unit - - fun tiered(): TieredConversionRateConfig? = tiered - - fun isUnit(): Boolean = unit != null - - fun isTiered(): Boolean = tiered != null - - fun asUnit(): UnitConversionRateConfig = unit.getOrThrow("unit") - - fun asTiered(): TieredConversionRateConfig = tiered.getOrThrow("tiered") - - fun _json(): JsonValue? = _json - - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): ConversionRateConfig = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) { - unit.validate() - } - - override fun visitTiered(tiered: TieredConversionRateConfig) { - tiered.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) = unit.validity() - - override fun visitTiered(tiered: TieredConversionRateConfig) = tiered.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered - } - - override fun hashCode(): Int = Objects.hash(unit, tiered) - - override fun toString(): String = - when { - unit != null -> "ConversionRateConfig{unit=$unit}" - tiered != null -> "ConversionRateConfig{tiered=$tiered}" - _json != null -> "ConversionRateConfig{_unknown=$_json}" - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - - companion object { - - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - fun ofTiered(tiered: TieredConversionRateConfig) = ConversionRateConfig(tiered = tiered) - } - - /** - * An interface that defines how to map each variant of [ConversionRateConfig] to a value of - * type [T]. - */ - interface Visitor { - - fun visitUnit(unit: UnitConversionRateConfig): T - - fun visitTiered(tiered: TieredConversionRateConfig): T - - /** - * Maps an unknown variant of [ConversionRateConfig] to a value of type [T]. - * - * An instance of [ConversionRateConfig] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if the SDK - * is on an older version than the API, then the API may respond with new variants that - * the SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown ConversionRateConfig: $json") - } - } - - internal class Deserializer : - BaseDeserializer(ConversionRateConfig::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): ConversionRateConfig { - val json = JsonValue.fromJsonNode(node) - val conversionRateType = json.asObject()?.get("conversion_rate_type")?.asString() - - when (conversionRateType) { - "unit" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(unit = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - "tiered" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(tiered = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - } - - return ConversionRateConfig(_json = json) - } - } - - internal class Serializer : - BaseSerializer(ConversionRateConfig::class) { - - override fun serialize( - value: ConversionRateConfig, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unit != null -> generator.writeObject(value.unit) - value.tiered != null -> generator.writeObject(value.tiered) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - } - } - } - /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionGroupedWithMeteredMinimumPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionGroupedWithMeteredMinimumPrice.kt index 7609e791a..adf0df789 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionGroupedWithMeteredMinimumPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionGroupedWithMeteredMinimumPrice.kt @@ -6,22 +6,12 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.withorb.api.core.BaseDeserializer -import com.withorb.api.core.BaseSerializer import com.withorb.api.core.Enum import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.checkRequired -import com.withorb.api.core.getOrThrow import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import java.util.Collections @@ -1343,175 +1333,6 @@ private constructor( override fun toString() = value.toString() } - /** The configuration for the rate of the price currency to the invoicing currency. */ - @JsonDeserialize(using = ConversionRateConfig.Deserializer::class) - @JsonSerialize(using = ConversionRateConfig.Serializer::class) - class ConversionRateConfig - private constructor( - private val unit: UnitConversionRateConfig? = null, - private val tiered: TieredConversionRateConfig? = null, - private val _json: JsonValue? = null, - ) { - - fun unit(): UnitConversionRateConfig? = unit - - fun tiered(): TieredConversionRateConfig? = tiered - - fun isUnit(): Boolean = unit != null - - fun isTiered(): Boolean = tiered != null - - fun asUnit(): UnitConversionRateConfig = unit.getOrThrow("unit") - - fun asTiered(): TieredConversionRateConfig = tiered.getOrThrow("tiered") - - fun _json(): JsonValue? = _json - - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): ConversionRateConfig = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) { - unit.validate() - } - - override fun visitTiered(tiered: TieredConversionRateConfig) { - tiered.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) = unit.validity() - - override fun visitTiered(tiered: TieredConversionRateConfig) = tiered.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered - } - - override fun hashCode(): Int = Objects.hash(unit, tiered) - - override fun toString(): String = - when { - unit != null -> "ConversionRateConfig{unit=$unit}" - tiered != null -> "ConversionRateConfig{tiered=$tiered}" - _json != null -> "ConversionRateConfig{_unknown=$_json}" - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - - companion object { - - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - fun ofTiered(tiered: TieredConversionRateConfig) = ConversionRateConfig(tiered = tiered) - } - - /** - * An interface that defines how to map each variant of [ConversionRateConfig] to a value of - * type [T]. - */ - interface Visitor { - - fun visitUnit(unit: UnitConversionRateConfig): T - - fun visitTiered(tiered: TieredConversionRateConfig): T - - /** - * Maps an unknown variant of [ConversionRateConfig] to a value of type [T]. - * - * An instance of [ConversionRateConfig] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if the SDK - * is on an older version than the API, then the API may respond with new variants that - * the SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown ConversionRateConfig: $json") - } - } - - internal class Deserializer : - BaseDeserializer(ConversionRateConfig::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): ConversionRateConfig { - val json = JsonValue.fromJsonNode(node) - val conversionRateType = json.asObject()?.get("conversion_rate_type")?.asString() - - when (conversionRateType) { - "unit" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(unit = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - "tiered" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(tiered = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - } - - return ConversionRateConfig(_json = json) - } - } - - internal class Serializer : - BaseSerializer(ConversionRateConfig::class) { - - override fun serialize( - value: ConversionRateConfig, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unit != null -> generator.writeObject(value.unit) - value.tiered != null -> generator.writeObject(value.tiered) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - } - } - } - /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionGroupedWithProratedMinimumPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionGroupedWithProratedMinimumPrice.kt index 557402b67..314744fd6 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionGroupedWithProratedMinimumPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionGroupedWithProratedMinimumPrice.kt @@ -6,22 +6,12 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.withorb.api.core.BaseDeserializer -import com.withorb.api.core.BaseSerializer import com.withorb.api.core.Enum import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.checkRequired -import com.withorb.api.core.getOrThrow import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import java.util.Collections @@ -1343,175 +1333,6 @@ private constructor( override fun toString() = value.toString() } - /** The configuration for the rate of the price currency to the invoicing currency. */ - @JsonDeserialize(using = ConversionRateConfig.Deserializer::class) - @JsonSerialize(using = ConversionRateConfig.Serializer::class) - class ConversionRateConfig - private constructor( - private val unit: UnitConversionRateConfig? = null, - private val tiered: TieredConversionRateConfig? = null, - private val _json: JsonValue? = null, - ) { - - fun unit(): UnitConversionRateConfig? = unit - - fun tiered(): TieredConversionRateConfig? = tiered - - fun isUnit(): Boolean = unit != null - - fun isTiered(): Boolean = tiered != null - - fun asUnit(): UnitConversionRateConfig = unit.getOrThrow("unit") - - fun asTiered(): TieredConversionRateConfig = tiered.getOrThrow("tiered") - - fun _json(): JsonValue? = _json - - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): ConversionRateConfig = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) { - unit.validate() - } - - override fun visitTiered(tiered: TieredConversionRateConfig) { - tiered.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) = unit.validity() - - override fun visitTiered(tiered: TieredConversionRateConfig) = tiered.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered - } - - override fun hashCode(): Int = Objects.hash(unit, tiered) - - override fun toString(): String = - when { - unit != null -> "ConversionRateConfig{unit=$unit}" - tiered != null -> "ConversionRateConfig{tiered=$tiered}" - _json != null -> "ConversionRateConfig{_unknown=$_json}" - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - - companion object { - - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - fun ofTiered(tiered: TieredConversionRateConfig) = ConversionRateConfig(tiered = tiered) - } - - /** - * An interface that defines how to map each variant of [ConversionRateConfig] to a value of - * type [T]. - */ - interface Visitor { - - fun visitUnit(unit: UnitConversionRateConfig): T - - fun visitTiered(tiered: TieredConversionRateConfig): T - - /** - * Maps an unknown variant of [ConversionRateConfig] to a value of type [T]. - * - * An instance of [ConversionRateConfig] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if the SDK - * is on an older version than the API, then the API may respond with new variants that - * the SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown ConversionRateConfig: $json") - } - } - - internal class Deserializer : - BaseDeserializer(ConversionRateConfig::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): ConversionRateConfig { - val json = JsonValue.fromJsonNode(node) - val conversionRateType = json.asObject()?.get("conversion_rate_type")?.asString() - - when (conversionRateType) { - "unit" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(unit = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - "tiered" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(tiered = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - } - - return ConversionRateConfig(_json = json) - } - } - - internal class Serializer : - BaseSerializer(ConversionRateConfig::class) { - - override fun serialize( - value: ConversionRateConfig, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unit != null -> generator.writeObject(value.unit) - value.tiered != null -> generator.writeObject(value.tiered) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - } - } - } - /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionMatrixPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionMatrixPrice.kt index 9ab94dc99..256b98784 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionMatrixPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionMatrixPrice.kt @@ -6,22 +6,12 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.withorb.api.core.BaseDeserializer -import com.withorb.api.core.BaseSerializer import com.withorb.api.core.Enum import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.checkRequired -import com.withorb.api.core.getOrThrow import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import java.util.Collections @@ -1221,175 +1211,6 @@ private constructor( override fun toString() = value.toString() } - /** The configuration for the rate of the price currency to the invoicing currency. */ - @JsonDeserialize(using = ConversionRateConfig.Deserializer::class) - @JsonSerialize(using = ConversionRateConfig.Serializer::class) - class ConversionRateConfig - private constructor( - private val unit: UnitConversionRateConfig? = null, - private val tiered: TieredConversionRateConfig? = null, - private val _json: JsonValue? = null, - ) { - - fun unit(): UnitConversionRateConfig? = unit - - fun tiered(): TieredConversionRateConfig? = tiered - - fun isUnit(): Boolean = unit != null - - fun isTiered(): Boolean = tiered != null - - fun asUnit(): UnitConversionRateConfig = unit.getOrThrow("unit") - - fun asTiered(): TieredConversionRateConfig = tiered.getOrThrow("tiered") - - fun _json(): JsonValue? = _json - - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): ConversionRateConfig = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) { - unit.validate() - } - - override fun visitTiered(tiered: TieredConversionRateConfig) { - tiered.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) = unit.validity() - - override fun visitTiered(tiered: TieredConversionRateConfig) = tiered.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered - } - - override fun hashCode(): Int = Objects.hash(unit, tiered) - - override fun toString(): String = - when { - unit != null -> "ConversionRateConfig{unit=$unit}" - tiered != null -> "ConversionRateConfig{tiered=$tiered}" - _json != null -> "ConversionRateConfig{_unknown=$_json}" - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - - companion object { - - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - fun ofTiered(tiered: TieredConversionRateConfig) = ConversionRateConfig(tiered = tiered) - } - - /** - * An interface that defines how to map each variant of [ConversionRateConfig] to a value of - * type [T]. - */ - interface Visitor { - - fun visitUnit(unit: UnitConversionRateConfig): T - - fun visitTiered(tiered: TieredConversionRateConfig): T - - /** - * Maps an unknown variant of [ConversionRateConfig] to a value of type [T]. - * - * An instance of [ConversionRateConfig] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if the SDK - * is on an older version than the API, then the API may respond with new variants that - * the SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown ConversionRateConfig: $json") - } - } - - internal class Deserializer : - BaseDeserializer(ConversionRateConfig::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): ConversionRateConfig { - val json = JsonValue.fromJsonNode(node) - val conversionRateType = json.asObject()?.get("conversion_rate_type")?.asString() - - when (conversionRateType) { - "unit" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(unit = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - "tiered" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(tiered = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - } - - return ConversionRateConfig(_json = json) - } - } - - internal class Serializer : - BaseSerializer(ConversionRateConfig::class) { - - override fun serialize( - value: ConversionRateConfig, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unit != null -> generator.writeObject(value.unit) - value.tiered != null -> generator.writeObject(value.tiered) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - } - } - } - /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionMatrixWithAllocationPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionMatrixWithAllocationPrice.kt index 640070d3d..aa280bd87 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionMatrixWithAllocationPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionMatrixWithAllocationPrice.kt @@ -6,22 +6,12 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.withorb.api.core.BaseDeserializer -import com.withorb.api.core.BaseSerializer import com.withorb.api.core.Enum import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.checkRequired -import com.withorb.api.core.getOrThrow import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import java.util.Collections @@ -1233,175 +1223,6 @@ private constructor( override fun toString() = value.toString() } - /** The configuration for the rate of the price currency to the invoicing currency. */ - @JsonDeserialize(using = ConversionRateConfig.Deserializer::class) - @JsonSerialize(using = ConversionRateConfig.Serializer::class) - class ConversionRateConfig - private constructor( - private val unit: UnitConversionRateConfig? = null, - private val tiered: TieredConversionRateConfig? = null, - private val _json: JsonValue? = null, - ) { - - fun unit(): UnitConversionRateConfig? = unit - - fun tiered(): TieredConversionRateConfig? = tiered - - fun isUnit(): Boolean = unit != null - - fun isTiered(): Boolean = tiered != null - - fun asUnit(): UnitConversionRateConfig = unit.getOrThrow("unit") - - fun asTiered(): TieredConversionRateConfig = tiered.getOrThrow("tiered") - - fun _json(): JsonValue? = _json - - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): ConversionRateConfig = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) { - unit.validate() - } - - override fun visitTiered(tiered: TieredConversionRateConfig) { - tiered.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) = unit.validity() - - override fun visitTiered(tiered: TieredConversionRateConfig) = tiered.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered - } - - override fun hashCode(): Int = Objects.hash(unit, tiered) - - override fun toString(): String = - when { - unit != null -> "ConversionRateConfig{unit=$unit}" - tiered != null -> "ConversionRateConfig{tiered=$tiered}" - _json != null -> "ConversionRateConfig{_unknown=$_json}" - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - - companion object { - - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - fun ofTiered(tiered: TieredConversionRateConfig) = ConversionRateConfig(tiered = tiered) - } - - /** - * An interface that defines how to map each variant of [ConversionRateConfig] to a value of - * type [T]. - */ - interface Visitor { - - fun visitUnit(unit: UnitConversionRateConfig): T - - fun visitTiered(tiered: TieredConversionRateConfig): T - - /** - * Maps an unknown variant of [ConversionRateConfig] to a value of type [T]. - * - * An instance of [ConversionRateConfig] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if the SDK - * is on an older version than the API, then the API may respond with new variants that - * the SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown ConversionRateConfig: $json") - } - } - - internal class Deserializer : - BaseDeserializer(ConversionRateConfig::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): ConversionRateConfig { - val json = JsonValue.fromJsonNode(node) - val conversionRateType = json.asObject()?.get("conversion_rate_type")?.asString() - - when (conversionRateType) { - "unit" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(unit = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - "tiered" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(tiered = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - } - - return ConversionRateConfig(_json = json) - } - } - - internal class Serializer : - BaseSerializer(ConversionRateConfig::class) { - - override fun serialize( - value: ConversionRateConfig, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unit != null -> generator.writeObject(value.unit) - value.tiered != null -> generator.writeObject(value.tiered) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - } - } - } - /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionMatrixWithDisplayNamePrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionMatrixWithDisplayNamePrice.kt index 0187af06f..ea2bd5ab1 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionMatrixWithDisplayNamePrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionMatrixWithDisplayNamePrice.kt @@ -6,22 +6,12 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.withorb.api.core.BaseDeserializer -import com.withorb.api.core.BaseSerializer import com.withorb.api.core.Enum import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.checkRequired -import com.withorb.api.core.getOrThrow import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import java.util.Collections @@ -1337,175 +1327,6 @@ private constructor( override fun toString() = value.toString() } - /** The configuration for the rate of the price currency to the invoicing currency. */ - @JsonDeserialize(using = ConversionRateConfig.Deserializer::class) - @JsonSerialize(using = ConversionRateConfig.Serializer::class) - class ConversionRateConfig - private constructor( - private val unit: UnitConversionRateConfig? = null, - private val tiered: TieredConversionRateConfig? = null, - private val _json: JsonValue? = null, - ) { - - fun unit(): UnitConversionRateConfig? = unit - - fun tiered(): TieredConversionRateConfig? = tiered - - fun isUnit(): Boolean = unit != null - - fun isTiered(): Boolean = tiered != null - - fun asUnit(): UnitConversionRateConfig = unit.getOrThrow("unit") - - fun asTiered(): TieredConversionRateConfig = tiered.getOrThrow("tiered") - - fun _json(): JsonValue? = _json - - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): ConversionRateConfig = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) { - unit.validate() - } - - override fun visitTiered(tiered: TieredConversionRateConfig) { - tiered.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) = unit.validity() - - override fun visitTiered(tiered: TieredConversionRateConfig) = tiered.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered - } - - override fun hashCode(): Int = Objects.hash(unit, tiered) - - override fun toString(): String = - when { - unit != null -> "ConversionRateConfig{unit=$unit}" - tiered != null -> "ConversionRateConfig{tiered=$tiered}" - _json != null -> "ConversionRateConfig{_unknown=$_json}" - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - - companion object { - - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - fun ofTiered(tiered: TieredConversionRateConfig) = ConversionRateConfig(tiered = tiered) - } - - /** - * An interface that defines how to map each variant of [ConversionRateConfig] to a value of - * type [T]. - */ - interface Visitor { - - fun visitUnit(unit: UnitConversionRateConfig): T - - fun visitTiered(tiered: TieredConversionRateConfig): T - - /** - * Maps an unknown variant of [ConversionRateConfig] to a value of type [T]. - * - * An instance of [ConversionRateConfig] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if the SDK - * is on an older version than the API, then the API may respond with new variants that - * the SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown ConversionRateConfig: $json") - } - } - - internal class Deserializer : - BaseDeserializer(ConversionRateConfig::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): ConversionRateConfig { - val json = JsonValue.fromJsonNode(node) - val conversionRateType = json.asObject()?.get("conversion_rate_type")?.asString() - - when (conversionRateType) { - "unit" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(unit = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - "tiered" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(tiered = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - } - - return ConversionRateConfig(_json = json) - } - } - - internal class Serializer : - BaseSerializer(ConversionRateConfig::class) { - - override fun serialize( - value: ConversionRateConfig, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unit != null -> generator.writeObject(value.unit) - value.tiered != null -> generator.writeObject(value.tiered) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - } - } - } - /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionMaxGroupTieredPackagePrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionMaxGroupTieredPackagePrice.kt index ffdb6c1f3..65c838439 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionMaxGroupTieredPackagePrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionMaxGroupTieredPackagePrice.kt @@ -6,22 +6,12 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.withorb.api.core.BaseDeserializer -import com.withorb.api.core.BaseSerializer import com.withorb.api.core.Enum import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.checkRequired -import com.withorb.api.core.getOrThrow import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import java.util.Collections @@ -1337,175 +1327,6 @@ private constructor( override fun toString() = value.toString() } - /** The configuration for the rate of the price currency to the invoicing currency. */ - @JsonDeserialize(using = ConversionRateConfig.Deserializer::class) - @JsonSerialize(using = ConversionRateConfig.Serializer::class) - class ConversionRateConfig - private constructor( - private val unit: UnitConversionRateConfig? = null, - private val tiered: TieredConversionRateConfig? = null, - private val _json: JsonValue? = null, - ) { - - fun unit(): UnitConversionRateConfig? = unit - - fun tiered(): TieredConversionRateConfig? = tiered - - fun isUnit(): Boolean = unit != null - - fun isTiered(): Boolean = tiered != null - - fun asUnit(): UnitConversionRateConfig = unit.getOrThrow("unit") - - fun asTiered(): TieredConversionRateConfig = tiered.getOrThrow("tiered") - - fun _json(): JsonValue? = _json - - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): ConversionRateConfig = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) { - unit.validate() - } - - override fun visitTiered(tiered: TieredConversionRateConfig) { - tiered.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) = unit.validity() - - override fun visitTiered(tiered: TieredConversionRateConfig) = tiered.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered - } - - override fun hashCode(): Int = Objects.hash(unit, tiered) - - override fun toString(): String = - when { - unit != null -> "ConversionRateConfig{unit=$unit}" - tiered != null -> "ConversionRateConfig{tiered=$tiered}" - _json != null -> "ConversionRateConfig{_unknown=$_json}" - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - - companion object { - - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - fun ofTiered(tiered: TieredConversionRateConfig) = ConversionRateConfig(tiered = tiered) - } - - /** - * An interface that defines how to map each variant of [ConversionRateConfig] to a value of - * type [T]. - */ - interface Visitor { - - fun visitUnit(unit: UnitConversionRateConfig): T - - fun visitTiered(tiered: TieredConversionRateConfig): T - - /** - * Maps an unknown variant of [ConversionRateConfig] to a value of type [T]. - * - * An instance of [ConversionRateConfig] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if the SDK - * is on an older version than the API, then the API may respond with new variants that - * the SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown ConversionRateConfig: $json") - } - } - - internal class Deserializer : - BaseDeserializer(ConversionRateConfig::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): ConversionRateConfig { - val json = JsonValue.fromJsonNode(node) - val conversionRateType = json.asObject()?.get("conversion_rate_type")?.asString() - - when (conversionRateType) { - "unit" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(unit = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - "tiered" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(tiered = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - } - - return ConversionRateConfig(_json = json) - } - } - - internal class Serializer : - BaseSerializer(ConversionRateConfig::class) { - - override fun serialize( - value: ConversionRateConfig, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unit != null -> generator.writeObject(value.unit) - value.tiered != null -> generator.writeObject(value.tiered) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - } - } - } - /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionPackagePrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionPackagePrice.kt index 5d5c39be8..ec79cb3a8 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionPackagePrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionPackagePrice.kt @@ -6,22 +6,12 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.withorb.api.core.BaseDeserializer -import com.withorb.api.core.BaseSerializer import com.withorb.api.core.Enum import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.checkRequired -import com.withorb.api.core.getOrThrow import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import java.util.Collections @@ -1222,175 +1212,6 @@ private constructor( override fun toString() = value.toString() } - /** The configuration for the rate of the price currency to the invoicing currency. */ - @JsonDeserialize(using = ConversionRateConfig.Deserializer::class) - @JsonSerialize(using = ConversionRateConfig.Serializer::class) - class ConversionRateConfig - private constructor( - private val unit: UnitConversionRateConfig? = null, - private val tiered: TieredConversionRateConfig? = null, - private val _json: JsonValue? = null, - ) { - - fun unit(): UnitConversionRateConfig? = unit - - fun tiered(): TieredConversionRateConfig? = tiered - - fun isUnit(): Boolean = unit != null - - fun isTiered(): Boolean = tiered != null - - fun asUnit(): UnitConversionRateConfig = unit.getOrThrow("unit") - - fun asTiered(): TieredConversionRateConfig = tiered.getOrThrow("tiered") - - fun _json(): JsonValue? = _json - - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): ConversionRateConfig = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) { - unit.validate() - } - - override fun visitTiered(tiered: TieredConversionRateConfig) { - tiered.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) = unit.validity() - - override fun visitTiered(tiered: TieredConversionRateConfig) = tiered.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered - } - - override fun hashCode(): Int = Objects.hash(unit, tiered) - - override fun toString(): String = - when { - unit != null -> "ConversionRateConfig{unit=$unit}" - tiered != null -> "ConversionRateConfig{tiered=$tiered}" - _json != null -> "ConversionRateConfig{_unknown=$_json}" - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - - companion object { - - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - fun ofTiered(tiered: TieredConversionRateConfig) = ConversionRateConfig(tiered = tiered) - } - - /** - * An interface that defines how to map each variant of [ConversionRateConfig] to a value of - * type [T]. - */ - interface Visitor { - - fun visitUnit(unit: UnitConversionRateConfig): T - - fun visitTiered(tiered: TieredConversionRateConfig): T - - /** - * Maps an unknown variant of [ConversionRateConfig] to a value of type [T]. - * - * An instance of [ConversionRateConfig] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if the SDK - * is on an older version than the API, then the API may respond with new variants that - * the SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown ConversionRateConfig: $json") - } - } - - internal class Deserializer : - BaseDeserializer(ConversionRateConfig::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): ConversionRateConfig { - val json = JsonValue.fromJsonNode(node) - val conversionRateType = json.asObject()?.get("conversion_rate_type")?.asString() - - when (conversionRateType) { - "unit" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(unit = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - "tiered" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(tiered = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - } - - return ConversionRateConfig(_json = json) - } - } - - internal class Serializer : - BaseSerializer(ConversionRateConfig::class) { - - override fun serialize( - value: ConversionRateConfig, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unit != null -> generator.writeObject(value.unit) - value.tiered != null -> generator.writeObject(value.tiered) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - } - } - } - /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionPackageWithAllocationPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionPackageWithAllocationPrice.kt index fab066b26..9d07625c6 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionPackageWithAllocationPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionPackageWithAllocationPrice.kt @@ -6,22 +6,12 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.withorb.api.core.BaseDeserializer -import com.withorb.api.core.BaseSerializer import com.withorb.api.core.Enum import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.checkRequired -import com.withorb.api.core.getOrThrow import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import java.util.Collections @@ -1337,175 +1327,6 @@ private constructor( "PackageWithAllocationConfig{additionalProperties=$additionalProperties}" } - /** The configuration for the rate of the price currency to the invoicing currency. */ - @JsonDeserialize(using = ConversionRateConfig.Deserializer::class) - @JsonSerialize(using = ConversionRateConfig.Serializer::class) - class ConversionRateConfig - private constructor( - private val unit: UnitConversionRateConfig? = null, - private val tiered: TieredConversionRateConfig? = null, - private val _json: JsonValue? = null, - ) { - - fun unit(): UnitConversionRateConfig? = unit - - fun tiered(): TieredConversionRateConfig? = tiered - - fun isUnit(): Boolean = unit != null - - fun isTiered(): Boolean = tiered != null - - fun asUnit(): UnitConversionRateConfig = unit.getOrThrow("unit") - - fun asTiered(): TieredConversionRateConfig = tiered.getOrThrow("tiered") - - fun _json(): JsonValue? = _json - - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): ConversionRateConfig = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) { - unit.validate() - } - - override fun visitTiered(tiered: TieredConversionRateConfig) { - tiered.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) = unit.validity() - - override fun visitTiered(tiered: TieredConversionRateConfig) = tiered.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered - } - - override fun hashCode(): Int = Objects.hash(unit, tiered) - - override fun toString(): String = - when { - unit != null -> "ConversionRateConfig{unit=$unit}" - tiered != null -> "ConversionRateConfig{tiered=$tiered}" - _json != null -> "ConversionRateConfig{_unknown=$_json}" - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - - companion object { - - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - fun ofTiered(tiered: TieredConversionRateConfig) = ConversionRateConfig(tiered = tiered) - } - - /** - * An interface that defines how to map each variant of [ConversionRateConfig] to a value of - * type [T]. - */ - interface Visitor { - - fun visitUnit(unit: UnitConversionRateConfig): T - - fun visitTiered(tiered: TieredConversionRateConfig): T - - /** - * Maps an unknown variant of [ConversionRateConfig] to a value of type [T]. - * - * An instance of [ConversionRateConfig] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if the SDK - * is on an older version than the API, then the API may respond with new variants that - * the SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown ConversionRateConfig: $json") - } - } - - internal class Deserializer : - BaseDeserializer(ConversionRateConfig::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): ConversionRateConfig { - val json = JsonValue.fromJsonNode(node) - val conversionRateType = json.asObject()?.get("conversion_rate_type")?.asString() - - when (conversionRateType) { - "unit" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(unit = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - "tiered" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(tiered = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - } - - return ConversionRateConfig(_json = json) - } - } - - internal class Serializer : - BaseSerializer(ConversionRateConfig::class) { - - override fun serialize( - value: ConversionRateConfig, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unit != null -> generator.writeObject(value.unit) - value.tiered != null -> generator.writeObject(value.tiered) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - } - } - } - /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionScalableMatrixWithTieredPricingPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionScalableMatrixWithTieredPricingPrice.kt index 406ce7950..74e3e1485 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionScalableMatrixWithTieredPricingPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionScalableMatrixWithTieredPricingPrice.kt @@ -6,22 +6,12 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.withorb.api.core.BaseDeserializer -import com.withorb.api.core.BaseSerializer import com.withorb.api.core.Enum import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.checkRequired -import com.withorb.api.core.getOrThrow import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import java.util.Collections @@ -1360,175 +1350,6 @@ private constructor( "ScalableMatrixWithTieredPricingConfig{additionalProperties=$additionalProperties}" } - /** The configuration for the rate of the price currency to the invoicing currency. */ - @JsonDeserialize(using = ConversionRateConfig.Deserializer::class) - @JsonSerialize(using = ConversionRateConfig.Serializer::class) - class ConversionRateConfig - private constructor( - private val unit: UnitConversionRateConfig? = null, - private val tiered: TieredConversionRateConfig? = null, - private val _json: JsonValue? = null, - ) { - - fun unit(): UnitConversionRateConfig? = unit - - fun tiered(): TieredConversionRateConfig? = tiered - - fun isUnit(): Boolean = unit != null - - fun isTiered(): Boolean = tiered != null - - fun asUnit(): UnitConversionRateConfig = unit.getOrThrow("unit") - - fun asTiered(): TieredConversionRateConfig = tiered.getOrThrow("tiered") - - fun _json(): JsonValue? = _json - - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): ConversionRateConfig = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) { - unit.validate() - } - - override fun visitTiered(tiered: TieredConversionRateConfig) { - tiered.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) = unit.validity() - - override fun visitTiered(tiered: TieredConversionRateConfig) = tiered.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered - } - - override fun hashCode(): Int = Objects.hash(unit, tiered) - - override fun toString(): String = - when { - unit != null -> "ConversionRateConfig{unit=$unit}" - tiered != null -> "ConversionRateConfig{tiered=$tiered}" - _json != null -> "ConversionRateConfig{_unknown=$_json}" - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - - companion object { - - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - fun ofTiered(tiered: TieredConversionRateConfig) = ConversionRateConfig(tiered = tiered) - } - - /** - * An interface that defines how to map each variant of [ConversionRateConfig] to a value of - * type [T]. - */ - interface Visitor { - - fun visitUnit(unit: UnitConversionRateConfig): T - - fun visitTiered(tiered: TieredConversionRateConfig): T - - /** - * Maps an unknown variant of [ConversionRateConfig] to a value of type [T]. - * - * An instance of [ConversionRateConfig] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if the SDK - * is on an older version than the API, then the API may respond with new variants that - * the SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown ConversionRateConfig: $json") - } - } - - internal class Deserializer : - BaseDeserializer(ConversionRateConfig::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): ConversionRateConfig { - val json = JsonValue.fromJsonNode(node) - val conversionRateType = json.asObject()?.get("conversion_rate_type")?.asString() - - when (conversionRateType) { - "unit" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(unit = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - "tiered" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(tiered = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - } - - return ConversionRateConfig(_json = json) - } - } - - internal class Serializer : - BaseSerializer(ConversionRateConfig::class) { - - override fun serialize( - value: ConversionRateConfig, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unit != null -> generator.writeObject(value.unit) - value.tiered != null -> generator.writeObject(value.tiered) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - } - } - } - /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionScalableMatrixWithUnitPricingPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionScalableMatrixWithUnitPricingPrice.kt index 0c1f21392..fd608668e 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionScalableMatrixWithUnitPricingPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionScalableMatrixWithUnitPricingPrice.kt @@ -6,22 +6,12 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.withorb.api.core.BaseDeserializer -import com.withorb.api.core.BaseSerializer import com.withorb.api.core.Enum import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.checkRequired -import com.withorb.api.core.getOrThrow import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import java.util.Collections @@ -1352,175 +1342,6 @@ private constructor( "ScalableMatrixWithUnitPricingConfig{additionalProperties=$additionalProperties}" } - /** The configuration for the rate of the price currency to the invoicing currency. */ - @JsonDeserialize(using = ConversionRateConfig.Deserializer::class) - @JsonSerialize(using = ConversionRateConfig.Serializer::class) - class ConversionRateConfig - private constructor( - private val unit: UnitConversionRateConfig? = null, - private val tiered: TieredConversionRateConfig? = null, - private val _json: JsonValue? = null, - ) { - - fun unit(): UnitConversionRateConfig? = unit - - fun tiered(): TieredConversionRateConfig? = tiered - - fun isUnit(): Boolean = unit != null - - fun isTiered(): Boolean = tiered != null - - fun asUnit(): UnitConversionRateConfig = unit.getOrThrow("unit") - - fun asTiered(): TieredConversionRateConfig = tiered.getOrThrow("tiered") - - fun _json(): JsonValue? = _json - - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): ConversionRateConfig = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) { - unit.validate() - } - - override fun visitTiered(tiered: TieredConversionRateConfig) { - tiered.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) = unit.validity() - - override fun visitTiered(tiered: TieredConversionRateConfig) = tiered.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered - } - - override fun hashCode(): Int = Objects.hash(unit, tiered) - - override fun toString(): String = - when { - unit != null -> "ConversionRateConfig{unit=$unit}" - tiered != null -> "ConversionRateConfig{tiered=$tiered}" - _json != null -> "ConversionRateConfig{_unknown=$_json}" - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - - companion object { - - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - fun ofTiered(tiered: TieredConversionRateConfig) = ConversionRateConfig(tiered = tiered) - } - - /** - * An interface that defines how to map each variant of [ConversionRateConfig] to a value of - * type [T]. - */ - interface Visitor { - - fun visitUnit(unit: UnitConversionRateConfig): T - - fun visitTiered(tiered: TieredConversionRateConfig): T - - /** - * Maps an unknown variant of [ConversionRateConfig] to a value of type [T]. - * - * An instance of [ConversionRateConfig] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if the SDK - * is on an older version than the API, then the API may respond with new variants that - * the SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown ConversionRateConfig: $json") - } - } - - internal class Deserializer : - BaseDeserializer(ConversionRateConfig::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): ConversionRateConfig { - val json = JsonValue.fromJsonNode(node) - val conversionRateType = json.asObject()?.get("conversion_rate_type")?.asString() - - when (conversionRateType) { - "unit" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(unit = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - "tiered" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(tiered = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - } - - return ConversionRateConfig(_json = json) - } - } - - internal class Serializer : - BaseSerializer(ConversionRateConfig::class) { - - override fun serialize( - value: ConversionRateConfig, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unit != null -> generator.writeObject(value.unit) - value.tiered != null -> generator.writeObject(value.tiered) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - } - } - } - /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionThresholdTotalAmountPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionThresholdTotalAmountPrice.kt index 62a2f89a4..55cc0573a 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionThresholdTotalAmountPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionThresholdTotalAmountPrice.kt @@ -6,22 +6,12 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.withorb.api.core.BaseDeserializer -import com.withorb.api.core.BaseSerializer import com.withorb.api.core.Enum import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.checkRequired -import com.withorb.api.core.getOrThrow import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import java.util.Collections @@ -1337,175 +1327,6 @@ private constructor( "ThresholdTotalAmountConfig{additionalProperties=$additionalProperties}" } - /** The configuration for the rate of the price currency to the invoicing currency. */ - @JsonDeserialize(using = ConversionRateConfig.Deserializer::class) - @JsonSerialize(using = ConversionRateConfig.Serializer::class) - class ConversionRateConfig - private constructor( - private val unit: UnitConversionRateConfig? = null, - private val tiered: TieredConversionRateConfig? = null, - private val _json: JsonValue? = null, - ) { - - fun unit(): UnitConversionRateConfig? = unit - - fun tiered(): TieredConversionRateConfig? = tiered - - fun isUnit(): Boolean = unit != null - - fun isTiered(): Boolean = tiered != null - - fun asUnit(): UnitConversionRateConfig = unit.getOrThrow("unit") - - fun asTiered(): TieredConversionRateConfig = tiered.getOrThrow("tiered") - - fun _json(): JsonValue? = _json - - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): ConversionRateConfig = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) { - unit.validate() - } - - override fun visitTiered(tiered: TieredConversionRateConfig) { - tiered.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) = unit.validity() - - override fun visitTiered(tiered: TieredConversionRateConfig) = tiered.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered - } - - override fun hashCode(): Int = Objects.hash(unit, tiered) - - override fun toString(): String = - when { - unit != null -> "ConversionRateConfig{unit=$unit}" - tiered != null -> "ConversionRateConfig{tiered=$tiered}" - _json != null -> "ConversionRateConfig{_unknown=$_json}" - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - - companion object { - - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - fun ofTiered(tiered: TieredConversionRateConfig) = ConversionRateConfig(tiered = tiered) - } - - /** - * An interface that defines how to map each variant of [ConversionRateConfig] to a value of - * type [T]. - */ - interface Visitor { - - fun visitUnit(unit: UnitConversionRateConfig): T - - fun visitTiered(tiered: TieredConversionRateConfig): T - - /** - * Maps an unknown variant of [ConversionRateConfig] to a value of type [T]. - * - * An instance of [ConversionRateConfig] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if the SDK - * is on an older version than the API, then the API may respond with new variants that - * the SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown ConversionRateConfig: $json") - } - } - - internal class Deserializer : - BaseDeserializer(ConversionRateConfig::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): ConversionRateConfig { - val json = JsonValue.fromJsonNode(node) - val conversionRateType = json.asObject()?.get("conversion_rate_type")?.asString() - - when (conversionRateType) { - "unit" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(unit = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - "tiered" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(tiered = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - } - - return ConversionRateConfig(_json = json) - } - } - - internal class Serializer : - BaseSerializer(ConversionRateConfig::class) { - - override fun serialize( - value: ConversionRateConfig, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unit != null -> generator.writeObject(value.unit) - value.tiered != null -> generator.writeObject(value.tiered) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - } - } - } - /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTierWithProrationPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTierWithProrationPrice.kt index 4eb6b13d4..4719c7d2f 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTierWithProrationPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTierWithProrationPrice.kt @@ -6,22 +6,12 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.withorb.api.core.BaseDeserializer -import com.withorb.api.core.BaseSerializer import com.withorb.api.core.Enum import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.checkRequired -import com.withorb.api.core.getOrThrow import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import java.util.Collections @@ -1336,175 +1326,6 @@ private constructor( "TieredWithProrationConfig{additionalProperties=$additionalProperties}" } - /** The configuration for the rate of the price currency to the invoicing currency. */ - @JsonDeserialize(using = ConversionRateConfig.Deserializer::class) - @JsonSerialize(using = ConversionRateConfig.Serializer::class) - class ConversionRateConfig - private constructor( - private val unit: UnitConversionRateConfig? = null, - private val tiered: TieredConversionRateConfig? = null, - private val _json: JsonValue? = null, - ) { - - fun unit(): UnitConversionRateConfig? = unit - - fun tiered(): TieredConversionRateConfig? = tiered - - fun isUnit(): Boolean = unit != null - - fun isTiered(): Boolean = tiered != null - - fun asUnit(): UnitConversionRateConfig = unit.getOrThrow("unit") - - fun asTiered(): TieredConversionRateConfig = tiered.getOrThrow("tiered") - - fun _json(): JsonValue? = _json - - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): ConversionRateConfig = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) { - unit.validate() - } - - override fun visitTiered(tiered: TieredConversionRateConfig) { - tiered.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) = unit.validity() - - override fun visitTiered(tiered: TieredConversionRateConfig) = tiered.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered - } - - override fun hashCode(): Int = Objects.hash(unit, tiered) - - override fun toString(): String = - when { - unit != null -> "ConversionRateConfig{unit=$unit}" - tiered != null -> "ConversionRateConfig{tiered=$tiered}" - _json != null -> "ConversionRateConfig{_unknown=$_json}" - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - - companion object { - - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - fun ofTiered(tiered: TieredConversionRateConfig) = ConversionRateConfig(tiered = tiered) - } - - /** - * An interface that defines how to map each variant of [ConversionRateConfig] to a value of - * type [T]. - */ - interface Visitor { - - fun visitUnit(unit: UnitConversionRateConfig): T - - fun visitTiered(tiered: TieredConversionRateConfig): T - - /** - * Maps an unknown variant of [ConversionRateConfig] to a value of type [T]. - * - * An instance of [ConversionRateConfig] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if the SDK - * is on an older version than the API, then the API may respond with new variants that - * the SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown ConversionRateConfig: $json") - } - } - - internal class Deserializer : - BaseDeserializer(ConversionRateConfig::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): ConversionRateConfig { - val json = JsonValue.fromJsonNode(node) - val conversionRateType = json.asObject()?.get("conversion_rate_type")?.asString() - - when (conversionRateType) { - "unit" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(unit = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - "tiered" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(tiered = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - } - - return ConversionRateConfig(_json = json) - } - } - - internal class Serializer : - BaseSerializer(ConversionRateConfig::class) { - - override fun serialize( - value: ConversionRateConfig, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unit != null -> generator.writeObject(value.unit) - value.tiered != null -> generator.writeObject(value.tiered) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - } - } - } - /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTieredBpsPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTieredBpsPrice.kt index ad7c43e10..e6fa5099a 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTieredBpsPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTieredBpsPrice.kt @@ -6,22 +6,12 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.withorb.api.core.BaseDeserializer -import com.withorb.api.core.BaseSerializer import com.withorb.api.core.Enum import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.checkRequired -import com.withorb.api.core.getOrThrow import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import java.util.Collections @@ -1224,175 +1214,6 @@ private constructor( override fun toString() = value.toString() } - /** The configuration for the rate of the price currency to the invoicing currency. */ - @JsonDeserialize(using = ConversionRateConfig.Deserializer::class) - @JsonSerialize(using = ConversionRateConfig.Serializer::class) - class ConversionRateConfig - private constructor( - private val unit: UnitConversionRateConfig? = null, - private val tiered: TieredConversionRateConfig? = null, - private val _json: JsonValue? = null, - ) { - - fun unit(): UnitConversionRateConfig? = unit - - fun tiered(): TieredConversionRateConfig? = tiered - - fun isUnit(): Boolean = unit != null - - fun isTiered(): Boolean = tiered != null - - fun asUnit(): UnitConversionRateConfig = unit.getOrThrow("unit") - - fun asTiered(): TieredConversionRateConfig = tiered.getOrThrow("tiered") - - fun _json(): JsonValue? = _json - - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): ConversionRateConfig = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) { - unit.validate() - } - - override fun visitTiered(tiered: TieredConversionRateConfig) { - tiered.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) = unit.validity() - - override fun visitTiered(tiered: TieredConversionRateConfig) = tiered.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered - } - - override fun hashCode(): Int = Objects.hash(unit, tiered) - - override fun toString(): String = - when { - unit != null -> "ConversionRateConfig{unit=$unit}" - tiered != null -> "ConversionRateConfig{tiered=$tiered}" - _json != null -> "ConversionRateConfig{_unknown=$_json}" - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - - companion object { - - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - fun ofTiered(tiered: TieredConversionRateConfig) = ConversionRateConfig(tiered = tiered) - } - - /** - * An interface that defines how to map each variant of [ConversionRateConfig] to a value of - * type [T]. - */ - interface Visitor { - - fun visitUnit(unit: UnitConversionRateConfig): T - - fun visitTiered(tiered: TieredConversionRateConfig): T - - /** - * Maps an unknown variant of [ConversionRateConfig] to a value of type [T]. - * - * An instance of [ConversionRateConfig] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if the SDK - * is on an older version than the API, then the API may respond with new variants that - * the SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown ConversionRateConfig: $json") - } - } - - internal class Deserializer : - BaseDeserializer(ConversionRateConfig::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): ConversionRateConfig { - val json = JsonValue.fromJsonNode(node) - val conversionRateType = json.asObject()?.get("conversion_rate_type")?.asString() - - when (conversionRateType) { - "unit" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(unit = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - "tiered" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(tiered = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - } - - return ConversionRateConfig(_json = json) - } - } - - internal class Serializer : - BaseSerializer(ConversionRateConfig::class) { - - override fun serialize( - value: ConversionRateConfig, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unit != null -> generator.writeObject(value.unit) - value.tiered != null -> generator.writeObject(value.tiered) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - } - } - } - /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTieredPackagePrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTieredPackagePrice.kt index 19987b473..bdd628241 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTieredPackagePrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTieredPackagePrice.kt @@ -6,22 +6,12 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.withorb.api.core.BaseDeserializer -import com.withorb.api.core.BaseSerializer import com.withorb.api.core.Enum import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.checkRequired -import com.withorb.api.core.getOrThrow import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import java.util.Collections @@ -1329,175 +1319,6 @@ private constructor( override fun toString() = "TieredPackageConfig{additionalProperties=$additionalProperties}" } - /** The configuration for the rate of the price currency to the invoicing currency. */ - @JsonDeserialize(using = ConversionRateConfig.Deserializer::class) - @JsonSerialize(using = ConversionRateConfig.Serializer::class) - class ConversionRateConfig - private constructor( - private val unit: UnitConversionRateConfig? = null, - private val tiered: TieredConversionRateConfig? = null, - private val _json: JsonValue? = null, - ) { - - fun unit(): UnitConversionRateConfig? = unit - - fun tiered(): TieredConversionRateConfig? = tiered - - fun isUnit(): Boolean = unit != null - - fun isTiered(): Boolean = tiered != null - - fun asUnit(): UnitConversionRateConfig = unit.getOrThrow("unit") - - fun asTiered(): TieredConversionRateConfig = tiered.getOrThrow("tiered") - - fun _json(): JsonValue? = _json - - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): ConversionRateConfig = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) { - unit.validate() - } - - override fun visitTiered(tiered: TieredConversionRateConfig) { - tiered.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) = unit.validity() - - override fun visitTiered(tiered: TieredConversionRateConfig) = tiered.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered - } - - override fun hashCode(): Int = Objects.hash(unit, tiered) - - override fun toString(): String = - when { - unit != null -> "ConversionRateConfig{unit=$unit}" - tiered != null -> "ConversionRateConfig{tiered=$tiered}" - _json != null -> "ConversionRateConfig{_unknown=$_json}" - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - - companion object { - - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - fun ofTiered(tiered: TieredConversionRateConfig) = ConversionRateConfig(tiered = tiered) - } - - /** - * An interface that defines how to map each variant of [ConversionRateConfig] to a value of - * type [T]. - */ - interface Visitor { - - fun visitUnit(unit: UnitConversionRateConfig): T - - fun visitTiered(tiered: TieredConversionRateConfig): T - - /** - * Maps an unknown variant of [ConversionRateConfig] to a value of type [T]. - * - * An instance of [ConversionRateConfig] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if the SDK - * is on an older version than the API, then the API may respond with new variants that - * the SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown ConversionRateConfig: $json") - } - } - - internal class Deserializer : - BaseDeserializer(ConversionRateConfig::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): ConversionRateConfig { - val json = JsonValue.fromJsonNode(node) - val conversionRateType = json.asObject()?.get("conversion_rate_type")?.asString() - - when (conversionRateType) { - "unit" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(unit = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - "tiered" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(tiered = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - } - - return ConversionRateConfig(_json = json) - } - } - - internal class Serializer : - BaseSerializer(ConversionRateConfig::class) { - - override fun serialize( - value: ConversionRateConfig, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unit != null -> generator.writeObject(value.unit) - value.tiered != null -> generator.writeObject(value.tiered) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - } - } - } - /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTieredPackageWithMinimumPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTieredPackageWithMinimumPrice.kt index 19a979f56..e4aad85c8 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTieredPackageWithMinimumPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTieredPackageWithMinimumPrice.kt @@ -6,22 +6,12 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.withorb.api.core.BaseDeserializer -import com.withorb.api.core.BaseSerializer import com.withorb.api.core.Enum import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.checkRequired -import com.withorb.api.core.getOrThrow import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import java.util.Collections @@ -1342,175 +1332,6 @@ private constructor( "TieredPackageWithMinimumConfig{additionalProperties=$additionalProperties}" } - /** The configuration for the rate of the price currency to the invoicing currency. */ - @JsonDeserialize(using = ConversionRateConfig.Deserializer::class) - @JsonSerialize(using = ConversionRateConfig.Serializer::class) - class ConversionRateConfig - private constructor( - private val unit: UnitConversionRateConfig? = null, - private val tiered: TieredConversionRateConfig? = null, - private val _json: JsonValue? = null, - ) { - - fun unit(): UnitConversionRateConfig? = unit - - fun tiered(): TieredConversionRateConfig? = tiered - - fun isUnit(): Boolean = unit != null - - fun isTiered(): Boolean = tiered != null - - fun asUnit(): UnitConversionRateConfig = unit.getOrThrow("unit") - - fun asTiered(): TieredConversionRateConfig = tiered.getOrThrow("tiered") - - fun _json(): JsonValue? = _json - - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): ConversionRateConfig = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) { - unit.validate() - } - - override fun visitTiered(tiered: TieredConversionRateConfig) { - tiered.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) = unit.validity() - - override fun visitTiered(tiered: TieredConversionRateConfig) = tiered.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered - } - - override fun hashCode(): Int = Objects.hash(unit, tiered) - - override fun toString(): String = - when { - unit != null -> "ConversionRateConfig{unit=$unit}" - tiered != null -> "ConversionRateConfig{tiered=$tiered}" - _json != null -> "ConversionRateConfig{_unknown=$_json}" - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - - companion object { - - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - fun ofTiered(tiered: TieredConversionRateConfig) = ConversionRateConfig(tiered = tiered) - } - - /** - * An interface that defines how to map each variant of [ConversionRateConfig] to a value of - * type [T]. - */ - interface Visitor { - - fun visitUnit(unit: UnitConversionRateConfig): T - - fun visitTiered(tiered: TieredConversionRateConfig): T - - /** - * Maps an unknown variant of [ConversionRateConfig] to a value of type [T]. - * - * An instance of [ConversionRateConfig] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if the SDK - * is on an older version than the API, then the API may respond with new variants that - * the SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown ConversionRateConfig: $json") - } - } - - internal class Deserializer : - BaseDeserializer(ConversionRateConfig::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): ConversionRateConfig { - val json = JsonValue.fromJsonNode(node) - val conversionRateType = json.asObject()?.get("conversion_rate_type")?.asString() - - when (conversionRateType) { - "unit" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(unit = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - "tiered" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(tiered = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - } - - return ConversionRateConfig(_json = json) - } - } - - internal class Serializer : - BaseSerializer(ConversionRateConfig::class) { - - override fun serialize( - value: ConversionRateConfig, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unit != null -> generator.writeObject(value.unit) - value.tiered != null -> generator.writeObject(value.tiered) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - } - } - } - /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTieredPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTieredPrice.kt index 9bde6107e..13636f668 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTieredPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTieredPrice.kt @@ -6,22 +6,12 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.withorb.api.core.BaseDeserializer -import com.withorb.api.core.BaseSerializer import com.withorb.api.core.Enum import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.checkRequired -import com.withorb.api.core.getOrThrow import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import java.util.Collections @@ -1221,175 +1211,6 @@ private constructor( override fun toString() = value.toString() } - /** The configuration for the rate of the price currency to the invoicing currency. */ - @JsonDeserialize(using = ConversionRateConfig.Deserializer::class) - @JsonSerialize(using = ConversionRateConfig.Serializer::class) - class ConversionRateConfig - private constructor( - private val unit: UnitConversionRateConfig? = null, - private val tiered: TieredConversionRateConfig? = null, - private val _json: JsonValue? = null, - ) { - - fun unit(): UnitConversionRateConfig? = unit - - fun tiered(): TieredConversionRateConfig? = tiered - - fun isUnit(): Boolean = unit != null - - fun isTiered(): Boolean = tiered != null - - fun asUnit(): UnitConversionRateConfig = unit.getOrThrow("unit") - - fun asTiered(): TieredConversionRateConfig = tiered.getOrThrow("tiered") - - fun _json(): JsonValue? = _json - - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): ConversionRateConfig = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) { - unit.validate() - } - - override fun visitTiered(tiered: TieredConversionRateConfig) { - tiered.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) = unit.validity() - - override fun visitTiered(tiered: TieredConversionRateConfig) = tiered.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered - } - - override fun hashCode(): Int = Objects.hash(unit, tiered) - - override fun toString(): String = - when { - unit != null -> "ConversionRateConfig{unit=$unit}" - tiered != null -> "ConversionRateConfig{tiered=$tiered}" - _json != null -> "ConversionRateConfig{_unknown=$_json}" - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - - companion object { - - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - fun ofTiered(tiered: TieredConversionRateConfig) = ConversionRateConfig(tiered = tiered) - } - - /** - * An interface that defines how to map each variant of [ConversionRateConfig] to a value of - * type [T]. - */ - interface Visitor { - - fun visitUnit(unit: UnitConversionRateConfig): T - - fun visitTiered(tiered: TieredConversionRateConfig): T - - /** - * Maps an unknown variant of [ConversionRateConfig] to a value of type [T]. - * - * An instance of [ConversionRateConfig] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if the SDK - * is on an older version than the API, then the API may respond with new variants that - * the SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown ConversionRateConfig: $json") - } - } - - internal class Deserializer : - BaseDeserializer(ConversionRateConfig::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): ConversionRateConfig { - val json = JsonValue.fromJsonNode(node) - val conversionRateType = json.asObject()?.get("conversion_rate_type")?.asString() - - when (conversionRateType) { - "unit" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(unit = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - "tiered" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(tiered = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - } - - return ConversionRateConfig(_json = json) - } - } - - internal class Serializer : - BaseSerializer(ConversionRateConfig::class) { - - override fun serialize( - value: ConversionRateConfig, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unit != null -> generator.writeObject(value.unit) - value.tiered != null -> generator.writeObject(value.tiered) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - } - } - } - /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTieredWithMinimumPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTieredWithMinimumPrice.kt index 41536a33e..151fb24bc 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTieredWithMinimumPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTieredWithMinimumPrice.kt @@ -6,22 +6,12 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.withorb.api.core.BaseDeserializer -import com.withorb.api.core.BaseSerializer import com.withorb.api.core.Enum import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.checkRequired -import com.withorb.api.core.getOrThrow import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import java.util.Collections @@ -1334,175 +1324,6 @@ private constructor( "TieredWithMinimumConfig{additionalProperties=$additionalProperties}" } - /** The configuration for the rate of the price currency to the invoicing currency. */ - @JsonDeserialize(using = ConversionRateConfig.Deserializer::class) - @JsonSerialize(using = ConversionRateConfig.Serializer::class) - class ConversionRateConfig - private constructor( - private val unit: UnitConversionRateConfig? = null, - private val tiered: TieredConversionRateConfig? = null, - private val _json: JsonValue? = null, - ) { - - fun unit(): UnitConversionRateConfig? = unit - - fun tiered(): TieredConversionRateConfig? = tiered - - fun isUnit(): Boolean = unit != null - - fun isTiered(): Boolean = tiered != null - - fun asUnit(): UnitConversionRateConfig = unit.getOrThrow("unit") - - fun asTiered(): TieredConversionRateConfig = tiered.getOrThrow("tiered") - - fun _json(): JsonValue? = _json - - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): ConversionRateConfig = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) { - unit.validate() - } - - override fun visitTiered(tiered: TieredConversionRateConfig) { - tiered.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) = unit.validity() - - override fun visitTiered(tiered: TieredConversionRateConfig) = tiered.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered - } - - override fun hashCode(): Int = Objects.hash(unit, tiered) - - override fun toString(): String = - when { - unit != null -> "ConversionRateConfig{unit=$unit}" - tiered != null -> "ConversionRateConfig{tiered=$tiered}" - _json != null -> "ConversionRateConfig{_unknown=$_json}" - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - - companion object { - - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - fun ofTiered(tiered: TieredConversionRateConfig) = ConversionRateConfig(tiered = tiered) - } - - /** - * An interface that defines how to map each variant of [ConversionRateConfig] to a value of - * type [T]. - */ - interface Visitor { - - fun visitUnit(unit: UnitConversionRateConfig): T - - fun visitTiered(tiered: TieredConversionRateConfig): T - - /** - * Maps an unknown variant of [ConversionRateConfig] to a value of type [T]. - * - * An instance of [ConversionRateConfig] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if the SDK - * is on an older version than the API, then the API may respond with new variants that - * the SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown ConversionRateConfig: $json") - } - } - - internal class Deserializer : - BaseDeserializer(ConversionRateConfig::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): ConversionRateConfig { - val json = JsonValue.fromJsonNode(node) - val conversionRateType = json.asObject()?.get("conversion_rate_type")?.asString() - - when (conversionRateType) { - "unit" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(unit = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - "tiered" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(tiered = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - } - - return ConversionRateConfig(_json = json) - } - } - - internal class Serializer : - BaseSerializer(ConversionRateConfig::class) { - - override fun serialize( - value: ConversionRateConfig, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unit != null -> generator.writeObject(value.unit) - value.tiered != null -> generator.writeObject(value.tiered) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - } - } - } - /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionUnitPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionUnitPrice.kt index 50447c0b7..7368807a2 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionUnitPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionUnitPrice.kt @@ -6,22 +6,12 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.withorb.api.core.BaseDeserializer -import com.withorb.api.core.BaseSerializer import com.withorb.api.core.Enum import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.checkRequired -import com.withorb.api.core.getOrThrow import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import java.util.Collections @@ -1219,175 +1209,6 @@ private constructor( override fun toString() = value.toString() } - /** The configuration for the rate of the price currency to the invoicing currency. */ - @JsonDeserialize(using = ConversionRateConfig.Deserializer::class) - @JsonSerialize(using = ConversionRateConfig.Serializer::class) - class ConversionRateConfig - private constructor( - private val unit: UnitConversionRateConfig? = null, - private val tiered: TieredConversionRateConfig? = null, - private val _json: JsonValue? = null, - ) { - - fun unit(): UnitConversionRateConfig? = unit - - fun tiered(): TieredConversionRateConfig? = tiered - - fun isUnit(): Boolean = unit != null - - fun isTiered(): Boolean = tiered != null - - fun asUnit(): UnitConversionRateConfig = unit.getOrThrow("unit") - - fun asTiered(): TieredConversionRateConfig = tiered.getOrThrow("tiered") - - fun _json(): JsonValue? = _json - - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): ConversionRateConfig = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) { - unit.validate() - } - - override fun visitTiered(tiered: TieredConversionRateConfig) { - tiered.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) = unit.validity() - - override fun visitTiered(tiered: TieredConversionRateConfig) = tiered.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered - } - - override fun hashCode(): Int = Objects.hash(unit, tiered) - - override fun toString(): String = - when { - unit != null -> "ConversionRateConfig{unit=$unit}" - tiered != null -> "ConversionRateConfig{tiered=$tiered}" - _json != null -> "ConversionRateConfig{_unknown=$_json}" - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - - companion object { - - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - fun ofTiered(tiered: TieredConversionRateConfig) = ConversionRateConfig(tiered = tiered) - } - - /** - * An interface that defines how to map each variant of [ConversionRateConfig] to a value of - * type [T]. - */ - interface Visitor { - - fun visitUnit(unit: UnitConversionRateConfig): T - - fun visitTiered(tiered: TieredConversionRateConfig): T - - /** - * Maps an unknown variant of [ConversionRateConfig] to a value of type [T]. - * - * An instance of [ConversionRateConfig] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if the SDK - * is on an older version than the API, then the API may respond with new variants that - * the SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown ConversionRateConfig: $json") - } - } - - internal class Deserializer : - BaseDeserializer(ConversionRateConfig::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): ConversionRateConfig { - val json = JsonValue.fromJsonNode(node) - val conversionRateType = json.asObject()?.get("conversion_rate_type")?.asString() - - when (conversionRateType) { - "unit" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(unit = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - "tiered" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(tiered = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - } - - return ConversionRateConfig(_json = json) - } - } - - internal class Serializer : - BaseSerializer(ConversionRateConfig::class) { - - override fun serialize( - value: ConversionRateConfig, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unit != null -> generator.writeObject(value.unit) - value.tiered != null -> generator.writeObject(value.tiered) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - } - } - } - /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionUnitWithPercentPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionUnitWithPercentPrice.kt index ddbda8241..2a46bbc80 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionUnitWithPercentPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionUnitWithPercentPrice.kt @@ -6,22 +6,12 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.withorb.api.core.BaseDeserializer -import com.withorb.api.core.BaseSerializer import com.withorb.api.core.Enum import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.checkRequired -import com.withorb.api.core.getOrThrow import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import java.util.Collections @@ -1333,175 +1323,6 @@ private constructor( "UnitWithPercentConfig{additionalProperties=$additionalProperties}" } - /** The configuration for the rate of the price currency to the invoicing currency. */ - @JsonDeserialize(using = ConversionRateConfig.Deserializer::class) - @JsonSerialize(using = ConversionRateConfig.Serializer::class) - class ConversionRateConfig - private constructor( - private val unit: UnitConversionRateConfig? = null, - private val tiered: TieredConversionRateConfig? = null, - private val _json: JsonValue? = null, - ) { - - fun unit(): UnitConversionRateConfig? = unit - - fun tiered(): TieredConversionRateConfig? = tiered - - fun isUnit(): Boolean = unit != null - - fun isTiered(): Boolean = tiered != null - - fun asUnit(): UnitConversionRateConfig = unit.getOrThrow("unit") - - fun asTiered(): TieredConversionRateConfig = tiered.getOrThrow("tiered") - - fun _json(): JsonValue? = _json - - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): ConversionRateConfig = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) { - unit.validate() - } - - override fun visitTiered(tiered: TieredConversionRateConfig) { - tiered.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) = unit.validity() - - override fun visitTiered(tiered: TieredConversionRateConfig) = tiered.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered - } - - override fun hashCode(): Int = Objects.hash(unit, tiered) - - override fun toString(): String = - when { - unit != null -> "ConversionRateConfig{unit=$unit}" - tiered != null -> "ConversionRateConfig{tiered=$tiered}" - _json != null -> "ConversionRateConfig{_unknown=$_json}" - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - - companion object { - - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - fun ofTiered(tiered: TieredConversionRateConfig) = ConversionRateConfig(tiered = tiered) - } - - /** - * An interface that defines how to map each variant of [ConversionRateConfig] to a value of - * type [T]. - */ - interface Visitor { - - fun visitUnit(unit: UnitConversionRateConfig): T - - fun visitTiered(tiered: TieredConversionRateConfig): T - - /** - * Maps an unknown variant of [ConversionRateConfig] to a value of type [T]. - * - * An instance of [ConversionRateConfig] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if the SDK - * is on an older version than the API, then the API may respond with new variants that - * the SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown ConversionRateConfig: $json") - } - } - - internal class Deserializer : - BaseDeserializer(ConversionRateConfig::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): ConversionRateConfig { - val json = JsonValue.fromJsonNode(node) - val conversionRateType = json.asObject()?.get("conversion_rate_type")?.asString() - - when (conversionRateType) { - "unit" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(unit = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - "tiered" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(tiered = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - } - - return ConversionRateConfig(_json = json) - } - } - - internal class Serializer : - BaseSerializer(ConversionRateConfig::class) { - - override fun serialize( - value: ConversionRateConfig, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unit != null -> generator.writeObject(value.unit) - value.tiered != null -> generator.writeObject(value.tiered) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - } - } - } - /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionUnitWithProrationPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionUnitWithProrationPrice.kt index e7587c852..6087625cd 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionUnitWithProrationPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionUnitWithProrationPrice.kt @@ -6,22 +6,12 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.withorb.api.core.BaseDeserializer -import com.withorb.api.core.BaseSerializer import com.withorb.api.core.Enum import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.checkRequired -import com.withorb.api.core.getOrThrow import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import java.util.Collections @@ -1334,175 +1324,6 @@ private constructor( "UnitWithProrationConfig{additionalProperties=$additionalProperties}" } - /** The configuration for the rate of the price currency to the invoicing currency. */ - @JsonDeserialize(using = ConversionRateConfig.Deserializer::class) - @JsonSerialize(using = ConversionRateConfig.Serializer::class) - class ConversionRateConfig - private constructor( - private val unit: UnitConversionRateConfig? = null, - private val tiered: TieredConversionRateConfig? = null, - private val _json: JsonValue? = null, - ) { - - fun unit(): UnitConversionRateConfig? = unit - - fun tiered(): TieredConversionRateConfig? = tiered - - fun isUnit(): Boolean = unit != null - - fun isTiered(): Boolean = tiered != null - - fun asUnit(): UnitConversionRateConfig = unit.getOrThrow("unit") - - fun asTiered(): TieredConversionRateConfig = tiered.getOrThrow("tiered") - - fun _json(): JsonValue? = _json - - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): ConversionRateConfig = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) { - unit.validate() - } - - override fun visitTiered(tiered: TieredConversionRateConfig) { - tiered.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) = unit.validity() - - override fun visitTiered(tiered: TieredConversionRateConfig) = tiered.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered - } - - override fun hashCode(): Int = Objects.hash(unit, tiered) - - override fun toString(): String = - when { - unit != null -> "ConversionRateConfig{unit=$unit}" - tiered != null -> "ConversionRateConfig{tiered=$tiered}" - _json != null -> "ConversionRateConfig{_unknown=$_json}" - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - - companion object { - - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - fun ofTiered(tiered: TieredConversionRateConfig) = ConversionRateConfig(tiered = tiered) - } - - /** - * An interface that defines how to map each variant of [ConversionRateConfig] to a value of - * type [T]. - */ - interface Visitor { - - fun visitUnit(unit: UnitConversionRateConfig): T - - fun visitTiered(tiered: TieredConversionRateConfig): T - - /** - * Maps an unknown variant of [ConversionRateConfig] to a value of type [T]. - * - * An instance of [ConversionRateConfig] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if the SDK - * is on an older version than the API, then the API may respond with new variants that - * the SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown ConversionRateConfig: $json") - } - } - - internal class Deserializer : - BaseDeserializer(ConversionRateConfig::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): ConversionRateConfig { - val json = JsonValue.fromJsonNode(node) - val conversionRateType = json.asObject()?.get("conversion_rate_type")?.asString() - - when (conversionRateType) { - "unit" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(unit = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - "tiered" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(tiered = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - } - - return ConversionRateConfig(_json = json) - } - } - - internal class Serializer : - BaseSerializer(ConversionRateConfig::class) { - - override fun serialize( - value: ConversionRateConfig, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unit != null -> generator.writeObject(value.unit) - value.tiered != null -> generator.writeObject(value.tiered) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - } - } - } - /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Price.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Price.kt index eaffb51a8..7f45ffc61 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Price.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Price.kt @@ -2523,180 +2523,6 @@ private constructor( override fun toString() = value.toString() } - @JsonDeserialize(using = ConversionRateConfig.Deserializer::class) - @JsonSerialize(using = ConversionRateConfig.Serializer::class) - class ConversionRateConfig - private constructor( - private val unit: UnitConversionRateConfig? = null, - private val tiered: TieredConversionRateConfig? = null, - private val _json: JsonValue? = null, - ) { - - fun unit(): UnitConversionRateConfig? = unit - - fun tiered(): TieredConversionRateConfig? = tiered - - fun isUnit(): Boolean = unit != null - - fun isTiered(): Boolean = tiered != null - - fun asUnit(): UnitConversionRateConfig = unit.getOrThrow("unit") - - fun asTiered(): TieredConversionRateConfig = tiered.getOrThrow("tiered") - - fun _json(): JsonValue? = _json - - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): ConversionRateConfig = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) { - unit.validate() - } - - override fun visitTiered(tiered: TieredConversionRateConfig) { - tiered.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) = unit.validity() - - override fun visitTiered(tiered: TieredConversionRateConfig) = - tiered.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered - } - - override fun hashCode(): Int = Objects.hash(unit, tiered) - - override fun toString(): String = - when { - unit != null -> "ConversionRateConfig{unit=$unit}" - tiered != null -> "ConversionRateConfig{tiered=$tiered}" - _json != null -> "ConversionRateConfig{_unknown=$_json}" - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - - companion object { - - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - fun ofTiered(tiered: TieredConversionRateConfig) = - ConversionRateConfig(tiered = tiered) - } - - /** - * An interface that defines how to map each variant of [ConversionRateConfig] to a - * value of type [T]. - */ - interface Visitor { - - fun visitUnit(unit: UnitConversionRateConfig): T - - fun visitTiered(tiered: TieredConversionRateConfig): T - - /** - * Maps an unknown variant of [ConversionRateConfig] to a value of type [T]. - * - * An instance of [ConversionRateConfig] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if the - * SDK is on an older version than the API, then the API may respond with new - * variants that the SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown ConversionRateConfig: $json") - } - } - - internal class Deserializer : - BaseDeserializer(ConversionRateConfig::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): ConversionRateConfig { - val json = JsonValue.fromJsonNode(node) - val conversionRateType = - json.asObject()?.get("conversion_rate_type")?.asString() - - when (conversionRateType) { - "unit" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(unit = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - "tiered" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { ConversionRateConfig(tiered = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - } - - return ConversionRateConfig(_json = json) - } - } - - internal class Serializer : - BaseSerializer(ConversionRateConfig::class) { - - override fun serialize( - value: ConversionRateConfig, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unit != null -> generator.writeObject(value.unit) - value.tiered != null -> generator.writeObject(value.tiered) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - } - } - } - /** * User specified key-value pairs for the resource. If not present, this defaults to an * empty dictionary. Individual keys can be removed by setting the value to `null`, and the @@ -4466,180 +4292,6 @@ private constructor( override fun toString() = value.toString() } - @JsonDeserialize(using = ConversionRateConfig.Deserializer::class) - @JsonSerialize(using = ConversionRateConfig.Serializer::class) - class ConversionRateConfig - private constructor( - private val unit: UnitConversionRateConfig? = null, - private val tiered: TieredConversionRateConfig? = null, - private val _json: JsonValue? = null, - ) { - - fun unit(): UnitConversionRateConfig? = unit - - fun tiered(): TieredConversionRateConfig? = tiered - - fun isUnit(): Boolean = unit != null - - fun isTiered(): Boolean = tiered != null - - fun asUnit(): UnitConversionRateConfig = unit.getOrThrow("unit") - - fun asTiered(): TieredConversionRateConfig = tiered.getOrThrow("tiered") - - fun _json(): JsonValue? = _json - - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): ConversionRateConfig = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) { - unit.validate() - } - - override fun visitTiered(tiered: TieredConversionRateConfig) { - tiered.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) = unit.validity() - - override fun visitTiered(tiered: TieredConversionRateConfig) = - tiered.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered - } - - override fun hashCode(): Int = Objects.hash(unit, tiered) - - override fun toString(): String = - when { - unit != null -> "ConversionRateConfig{unit=$unit}" - tiered != null -> "ConversionRateConfig{tiered=$tiered}" - _json != null -> "ConversionRateConfig{_unknown=$_json}" - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - - companion object { - - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - fun ofTiered(tiered: TieredConversionRateConfig) = - ConversionRateConfig(tiered = tiered) - } - - /** - * An interface that defines how to map each variant of [ConversionRateConfig] to a - * value of type [T]. - */ - interface Visitor { - - fun visitUnit(unit: UnitConversionRateConfig): T - - fun visitTiered(tiered: TieredConversionRateConfig): T - - /** - * Maps an unknown variant of [ConversionRateConfig] to a value of type [T]. - * - * An instance of [ConversionRateConfig] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if the - * SDK is on an older version than the API, then the API may respond with new - * variants that the SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown ConversionRateConfig: $json") - } - } - - internal class Deserializer : - BaseDeserializer(ConversionRateConfig::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): ConversionRateConfig { - val json = JsonValue.fromJsonNode(node) - val conversionRateType = - json.asObject()?.get("conversion_rate_type")?.asString() - - when (conversionRateType) { - "unit" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(unit = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - "tiered" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { ConversionRateConfig(tiered = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - } - - return ConversionRateConfig(_json = json) - } - } - - internal class Serializer : - BaseSerializer(ConversionRateConfig::class) { - - override fun serialize( - value: ConversionRateConfig, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unit != null -> generator.writeObject(value.unit) - value.tiered != null -> generator.writeObject(value.tiered) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - } - } - } - /** * User specified key-value pairs for the resource. If not present, this defaults to an * empty dictionary. Individual keys can be removed by setting the value to `null`, and the @@ -6408,180 +6060,6 @@ private constructor( override fun toString() = value.toString() } - @JsonDeserialize(using = ConversionRateConfig.Deserializer::class) - @JsonSerialize(using = ConversionRateConfig.Serializer::class) - class ConversionRateConfig - private constructor( - private val unit: UnitConversionRateConfig? = null, - private val tiered: TieredConversionRateConfig? = null, - private val _json: JsonValue? = null, - ) { - - fun unit(): UnitConversionRateConfig? = unit - - fun tiered(): TieredConversionRateConfig? = tiered - - fun isUnit(): Boolean = unit != null - - fun isTiered(): Boolean = tiered != null - - fun asUnit(): UnitConversionRateConfig = unit.getOrThrow("unit") - - fun asTiered(): TieredConversionRateConfig = tiered.getOrThrow("tiered") - - fun _json(): JsonValue? = _json - - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): ConversionRateConfig = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) { - unit.validate() - } - - override fun visitTiered(tiered: TieredConversionRateConfig) { - tiered.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) = unit.validity() - - override fun visitTiered(tiered: TieredConversionRateConfig) = - tiered.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered - } - - override fun hashCode(): Int = Objects.hash(unit, tiered) - - override fun toString(): String = - when { - unit != null -> "ConversionRateConfig{unit=$unit}" - tiered != null -> "ConversionRateConfig{tiered=$tiered}" - _json != null -> "ConversionRateConfig{_unknown=$_json}" - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - - companion object { - - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - fun ofTiered(tiered: TieredConversionRateConfig) = - ConversionRateConfig(tiered = tiered) - } - - /** - * An interface that defines how to map each variant of [ConversionRateConfig] to a - * value of type [T]. - */ - interface Visitor { - - fun visitUnit(unit: UnitConversionRateConfig): T - - fun visitTiered(tiered: TieredConversionRateConfig): T - - /** - * Maps an unknown variant of [ConversionRateConfig] to a value of type [T]. - * - * An instance of [ConversionRateConfig] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if the - * SDK is on an older version than the API, then the API may respond with new - * variants that the SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown ConversionRateConfig: $json") - } - } - - internal class Deserializer : - BaseDeserializer(ConversionRateConfig::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): ConversionRateConfig { - val json = JsonValue.fromJsonNode(node) - val conversionRateType = - json.asObject()?.get("conversion_rate_type")?.asString() - - when (conversionRateType) { - "unit" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(unit = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - "tiered" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { ConversionRateConfig(tiered = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - } - - return ConversionRateConfig(_json = json) - } - } - - internal class Serializer : - BaseSerializer(ConversionRateConfig::class) { - - override fun serialize( - value: ConversionRateConfig, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unit != null -> generator.writeObject(value.unit) - value.tiered != null -> generator.writeObject(value.tiered) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - } - } - } - /** * User specified key-value pairs for the resource. If not present, this defaults to an * empty dictionary. Individual keys can be removed by setting the value to `null`, and the @@ -8350,180 +7828,6 @@ private constructor( override fun toString() = value.toString() } - @JsonDeserialize(using = ConversionRateConfig.Deserializer::class) - @JsonSerialize(using = ConversionRateConfig.Serializer::class) - class ConversionRateConfig - private constructor( - private val unit: UnitConversionRateConfig? = null, - private val tiered: TieredConversionRateConfig? = null, - private val _json: JsonValue? = null, - ) { - - fun unit(): UnitConversionRateConfig? = unit - - fun tiered(): TieredConversionRateConfig? = tiered - - fun isUnit(): Boolean = unit != null - - fun isTiered(): Boolean = tiered != null - - fun asUnit(): UnitConversionRateConfig = unit.getOrThrow("unit") - - fun asTiered(): TieredConversionRateConfig = tiered.getOrThrow("tiered") - - fun _json(): JsonValue? = _json - - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): ConversionRateConfig = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) { - unit.validate() - } - - override fun visitTiered(tiered: TieredConversionRateConfig) { - tiered.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) = unit.validity() - - override fun visitTiered(tiered: TieredConversionRateConfig) = - tiered.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered - } - - override fun hashCode(): Int = Objects.hash(unit, tiered) - - override fun toString(): String = - when { - unit != null -> "ConversionRateConfig{unit=$unit}" - tiered != null -> "ConversionRateConfig{tiered=$tiered}" - _json != null -> "ConversionRateConfig{_unknown=$_json}" - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - - companion object { - - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - fun ofTiered(tiered: TieredConversionRateConfig) = - ConversionRateConfig(tiered = tiered) - } - - /** - * An interface that defines how to map each variant of [ConversionRateConfig] to a - * value of type [T]. - */ - interface Visitor { - - fun visitUnit(unit: UnitConversionRateConfig): T - - fun visitTiered(tiered: TieredConversionRateConfig): T - - /** - * Maps an unknown variant of [ConversionRateConfig] to a value of type [T]. - * - * An instance of [ConversionRateConfig] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if the - * SDK is on an older version than the API, then the API may respond with new - * variants that the SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown ConversionRateConfig: $json") - } - } - - internal class Deserializer : - BaseDeserializer(ConversionRateConfig::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): ConversionRateConfig { - val json = JsonValue.fromJsonNode(node) - val conversionRateType = - json.asObject()?.get("conversion_rate_type")?.asString() - - when (conversionRateType) { - "unit" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(unit = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - "tiered" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { ConversionRateConfig(tiered = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - } - - return ConversionRateConfig(_json = json) - } - } - - internal class Serializer : - BaseSerializer(ConversionRateConfig::class) { - - override fun serialize( - value: ConversionRateConfig, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unit != null -> generator.writeObject(value.unit) - value.tiered != null -> generator.writeObject(value.tiered) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - } - } - } - /** * User specified key-value pairs for the resource. If not present, this defaults to an * empty dictionary. Individual keys can be removed by setting the value to `null`, and the @@ -10293,180 +9597,6 @@ private constructor( override fun toString() = value.toString() } - @JsonDeserialize(using = ConversionRateConfig.Deserializer::class) - @JsonSerialize(using = ConversionRateConfig.Serializer::class) - class ConversionRateConfig - private constructor( - private val unit: UnitConversionRateConfig? = null, - private val tiered: TieredConversionRateConfig? = null, - private val _json: JsonValue? = null, - ) { - - fun unit(): UnitConversionRateConfig? = unit - - fun tiered(): TieredConversionRateConfig? = tiered - - fun isUnit(): Boolean = unit != null - - fun isTiered(): Boolean = tiered != null - - fun asUnit(): UnitConversionRateConfig = unit.getOrThrow("unit") - - fun asTiered(): TieredConversionRateConfig = tiered.getOrThrow("tiered") - - fun _json(): JsonValue? = _json - - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): ConversionRateConfig = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) { - unit.validate() - } - - override fun visitTiered(tiered: TieredConversionRateConfig) { - tiered.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) = unit.validity() - - override fun visitTiered(tiered: TieredConversionRateConfig) = - tiered.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered - } - - override fun hashCode(): Int = Objects.hash(unit, tiered) - - override fun toString(): String = - when { - unit != null -> "ConversionRateConfig{unit=$unit}" - tiered != null -> "ConversionRateConfig{tiered=$tiered}" - _json != null -> "ConversionRateConfig{_unknown=$_json}" - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - - companion object { - - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - fun ofTiered(tiered: TieredConversionRateConfig) = - ConversionRateConfig(tiered = tiered) - } - - /** - * An interface that defines how to map each variant of [ConversionRateConfig] to a - * value of type [T]. - */ - interface Visitor { - - fun visitUnit(unit: UnitConversionRateConfig): T - - fun visitTiered(tiered: TieredConversionRateConfig): T - - /** - * Maps an unknown variant of [ConversionRateConfig] to a value of type [T]. - * - * An instance of [ConversionRateConfig] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if the - * SDK is on an older version than the API, then the API may respond with new - * variants that the SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown ConversionRateConfig: $json") - } - } - - internal class Deserializer : - BaseDeserializer(ConversionRateConfig::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): ConversionRateConfig { - val json = JsonValue.fromJsonNode(node) - val conversionRateType = - json.asObject()?.get("conversion_rate_type")?.asString() - - when (conversionRateType) { - "unit" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(unit = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - "tiered" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { ConversionRateConfig(tiered = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - } - - return ConversionRateConfig(_json = json) - } - } - - internal class Serializer : - BaseSerializer(ConversionRateConfig::class) { - - override fun serialize( - value: ConversionRateConfig, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unit != null -> generator.writeObject(value.unit) - value.tiered != null -> generator.writeObject(value.tiered) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - } - } - } - /** * User specified key-value pairs for the resource. If not present, this defaults to an * empty dictionary. Individual keys can be removed by setting the value to `null`, and the @@ -12232,180 +11362,6 @@ private constructor( override fun toString() = value.toString() } - @JsonDeserialize(using = ConversionRateConfig.Deserializer::class) - @JsonSerialize(using = ConversionRateConfig.Serializer::class) - class ConversionRateConfig - private constructor( - private val unit: UnitConversionRateConfig? = null, - private val tiered: TieredConversionRateConfig? = null, - private val _json: JsonValue? = null, - ) { - - fun unit(): UnitConversionRateConfig? = unit - - fun tiered(): TieredConversionRateConfig? = tiered - - fun isUnit(): Boolean = unit != null - - fun isTiered(): Boolean = tiered != null - - fun asUnit(): UnitConversionRateConfig = unit.getOrThrow("unit") - - fun asTiered(): TieredConversionRateConfig = tiered.getOrThrow("tiered") - - fun _json(): JsonValue? = _json - - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): ConversionRateConfig = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) { - unit.validate() - } - - override fun visitTiered(tiered: TieredConversionRateConfig) { - tiered.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) = unit.validity() - - override fun visitTiered(tiered: TieredConversionRateConfig) = - tiered.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered - } - - override fun hashCode(): Int = Objects.hash(unit, tiered) - - override fun toString(): String = - when { - unit != null -> "ConversionRateConfig{unit=$unit}" - tiered != null -> "ConversionRateConfig{tiered=$tiered}" - _json != null -> "ConversionRateConfig{_unknown=$_json}" - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - - companion object { - - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - fun ofTiered(tiered: TieredConversionRateConfig) = - ConversionRateConfig(tiered = tiered) - } - - /** - * An interface that defines how to map each variant of [ConversionRateConfig] to a - * value of type [T]. - */ - interface Visitor { - - fun visitUnit(unit: UnitConversionRateConfig): T - - fun visitTiered(tiered: TieredConversionRateConfig): T - - /** - * Maps an unknown variant of [ConversionRateConfig] to a value of type [T]. - * - * An instance of [ConversionRateConfig] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if the - * SDK is on an older version than the API, then the API may respond with new - * variants that the SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown ConversionRateConfig: $json") - } - } - - internal class Deserializer : - BaseDeserializer(ConversionRateConfig::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): ConversionRateConfig { - val json = JsonValue.fromJsonNode(node) - val conversionRateType = - json.asObject()?.get("conversion_rate_type")?.asString() - - when (conversionRateType) { - "unit" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(unit = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - "tiered" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { ConversionRateConfig(tiered = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - } - - return ConversionRateConfig(_json = json) - } - } - - internal class Serializer : - BaseSerializer(ConversionRateConfig::class) { - - override fun serialize( - value: ConversionRateConfig, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unit != null -> generator.writeObject(value.unit) - value.tiered != null -> generator.writeObject(value.tiered) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - } - } - } - /** * User specified key-value pairs for the resource. If not present, this defaults to an * empty dictionary. Individual keys can be removed by setting the value to `null`, and the @@ -14175,180 +13131,6 @@ private constructor( override fun toString() = value.toString() } - @JsonDeserialize(using = ConversionRateConfig.Deserializer::class) - @JsonSerialize(using = ConversionRateConfig.Serializer::class) - class ConversionRateConfig - private constructor( - private val unit: UnitConversionRateConfig? = null, - private val tiered: TieredConversionRateConfig? = null, - private val _json: JsonValue? = null, - ) { - - fun unit(): UnitConversionRateConfig? = unit - - fun tiered(): TieredConversionRateConfig? = tiered - - fun isUnit(): Boolean = unit != null - - fun isTiered(): Boolean = tiered != null - - fun asUnit(): UnitConversionRateConfig = unit.getOrThrow("unit") - - fun asTiered(): TieredConversionRateConfig = tiered.getOrThrow("tiered") - - fun _json(): JsonValue? = _json - - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): ConversionRateConfig = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) { - unit.validate() - } - - override fun visitTiered(tiered: TieredConversionRateConfig) { - tiered.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) = unit.validity() - - override fun visitTiered(tiered: TieredConversionRateConfig) = - tiered.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered - } - - override fun hashCode(): Int = Objects.hash(unit, tiered) - - override fun toString(): String = - when { - unit != null -> "ConversionRateConfig{unit=$unit}" - tiered != null -> "ConversionRateConfig{tiered=$tiered}" - _json != null -> "ConversionRateConfig{_unknown=$_json}" - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - - companion object { - - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - fun ofTiered(tiered: TieredConversionRateConfig) = - ConversionRateConfig(tiered = tiered) - } - - /** - * An interface that defines how to map each variant of [ConversionRateConfig] to a - * value of type [T]. - */ - interface Visitor { - - fun visitUnit(unit: UnitConversionRateConfig): T - - fun visitTiered(tiered: TieredConversionRateConfig): T - - /** - * Maps an unknown variant of [ConversionRateConfig] to a value of type [T]. - * - * An instance of [ConversionRateConfig] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if the - * SDK is on an older version than the API, then the API may respond with new - * variants that the SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown ConversionRateConfig: $json") - } - } - - internal class Deserializer : - BaseDeserializer(ConversionRateConfig::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): ConversionRateConfig { - val json = JsonValue.fromJsonNode(node) - val conversionRateType = - json.asObject()?.get("conversion_rate_type")?.asString() - - when (conversionRateType) { - "unit" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(unit = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - "tiered" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { ConversionRateConfig(tiered = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - } - - return ConversionRateConfig(_json = json) - } - } - - internal class Serializer : - BaseSerializer(ConversionRateConfig::class) { - - override fun serialize( - value: ConversionRateConfig, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unit != null -> generator.writeObject(value.unit) - value.tiered != null -> generator.writeObject(value.tiered) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - } - } - } - /** * User specified key-value pairs for the resource. If not present, this defaults to an * empty dictionary. Individual keys can be removed by setting the value to `null`, and the @@ -16116,180 +14898,6 @@ private constructor( override fun toString() = value.toString() } - @JsonDeserialize(using = ConversionRateConfig.Deserializer::class) - @JsonSerialize(using = ConversionRateConfig.Serializer::class) - class ConversionRateConfig - private constructor( - private val unit: UnitConversionRateConfig? = null, - private val tiered: TieredConversionRateConfig? = null, - private val _json: JsonValue? = null, - ) { - - fun unit(): UnitConversionRateConfig? = unit - - fun tiered(): TieredConversionRateConfig? = tiered - - fun isUnit(): Boolean = unit != null - - fun isTiered(): Boolean = tiered != null - - fun asUnit(): UnitConversionRateConfig = unit.getOrThrow("unit") - - fun asTiered(): TieredConversionRateConfig = tiered.getOrThrow("tiered") - - fun _json(): JsonValue? = _json - - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): ConversionRateConfig = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) { - unit.validate() - } - - override fun visitTiered(tiered: TieredConversionRateConfig) { - tiered.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) = unit.validity() - - override fun visitTiered(tiered: TieredConversionRateConfig) = - tiered.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered - } - - override fun hashCode(): Int = Objects.hash(unit, tiered) - - override fun toString(): String = - when { - unit != null -> "ConversionRateConfig{unit=$unit}" - tiered != null -> "ConversionRateConfig{tiered=$tiered}" - _json != null -> "ConversionRateConfig{_unknown=$_json}" - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - - companion object { - - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - fun ofTiered(tiered: TieredConversionRateConfig) = - ConversionRateConfig(tiered = tiered) - } - - /** - * An interface that defines how to map each variant of [ConversionRateConfig] to a - * value of type [T]. - */ - interface Visitor { - - fun visitUnit(unit: UnitConversionRateConfig): T - - fun visitTiered(tiered: TieredConversionRateConfig): T - - /** - * Maps an unknown variant of [ConversionRateConfig] to a value of type [T]. - * - * An instance of [ConversionRateConfig] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if the - * SDK is on an older version than the API, then the API may respond with new - * variants that the SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown ConversionRateConfig: $json") - } - } - - internal class Deserializer : - BaseDeserializer(ConversionRateConfig::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): ConversionRateConfig { - val json = JsonValue.fromJsonNode(node) - val conversionRateType = - json.asObject()?.get("conversion_rate_type")?.asString() - - when (conversionRateType) { - "unit" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(unit = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - "tiered" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { ConversionRateConfig(tiered = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - } - - return ConversionRateConfig(_json = json) - } - } - - internal class Serializer : - BaseSerializer(ConversionRateConfig::class) { - - override fun serialize( - value: ConversionRateConfig, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unit != null -> generator.writeObject(value.unit) - value.tiered != null -> generator.writeObject(value.tiered) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - } - } - } - /** * User specified key-value pairs for the resource. If not present, this defaults to an * empty dictionary. Individual keys can be removed by setting the value to `null`, and the @@ -18061,180 +16669,6 @@ private constructor( override fun toString() = value.toString() } - @JsonDeserialize(using = ConversionRateConfig.Deserializer::class) - @JsonSerialize(using = ConversionRateConfig.Serializer::class) - class ConversionRateConfig - private constructor( - private val unit: UnitConversionRateConfig? = null, - private val tiered: TieredConversionRateConfig? = null, - private val _json: JsonValue? = null, - ) { - - fun unit(): UnitConversionRateConfig? = unit - - fun tiered(): TieredConversionRateConfig? = tiered - - fun isUnit(): Boolean = unit != null - - fun isTiered(): Boolean = tiered != null - - fun asUnit(): UnitConversionRateConfig = unit.getOrThrow("unit") - - fun asTiered(): TieredConversionRateConfig = tiered.getOrThrow("tiered") - - fun _json(): JsonValue? = _json - - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): ConversionRateConfig = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) { - unit.validate() - } - - override fun visitTiered(tiered: TieredConversionRateConfig) { - tiered.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) = unit.validity() - - override fun visitTiered(tiered: TieredConversionRateConfig) = - tiered.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered - } - - override fun hashCode(): Int = Objects.hash(unit, tiered) - - override fun toString(): String = - when { - unit != null -> "ConversionRateConfig{unit=$unit}" - tiered != null -> "ConversionRateConfig{tiered=$tiered}" - _json != null -> "ConversionRateConfig{_unknown=$_json}" - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - - companion object { - - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - fun ofTiered(tiered: TieredConversionRateConfig) = - ConversionRateConfig(tiered = tiered) - } - - /** - * An interface that defines how to map each variant of [ConversionRateConfig] to a - * value of type [T]. - */ - interface Visitor { - - fun visitUnit(unit: UnitConversionRateConfig): T - - fun visitTiered(tiered: TieredConversionRateConfig): T - - /** - * Maps an unknown variant of [ConversionRateConfig] to a value of type [T]. - * - * An instance of [ConversionRateConfig] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if the - * SDK is on an older version than the API, then the API may respond with new - * variants that the SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown ConversionRateConfig: $json") - } - } - - internal class Deserializer : - BaseDeserializer(ConversionRateConfig::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): ConversionRateConfig { - val json = JsonValue.fromJsonNode(node) - val conversionRateType = - json.asObject()?.get("conversion_rate_type")?.asString() - - when (conversionRateType) { - "unit" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(unit = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - "tiered" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { ConversionRateConfig(tiered = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - } - - return ConversionRateConfig(_json = json) - } - } - - internal class Serializer : - BaseSerializer(ConversionRateConfig::class) { - - override fun serialize( - value: ConversionRateConfig, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unit != null -> generator.writeObject(value.unit) - value.tiered != null -> generator.writeObject(value.tiered) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - } - } - } - /** * User specified key-value pairs for the resource. If not present, this defaults to an * empty dictionary. Individual keys can be removed by setting the value to `null`, and the @@ -20112,180 +18546,6 @@ private constructor( override fun toString() = value.toString() } - @JsonDeserialize(using = ConversionRateConfig.Deserializer::class) - @JsonSerialize(using = ConversionRateConfig.Serializer::class) - class ConversionRateConfig - private constructor( - private val unit: UnitConversionRateConfig? = null, - private val tiered: TieredConversionRateConfig? = null, - private val _json: JsonValue? = null, - ) { - - fun unit(): UnitConversionRateConfig? = unit - - fun tiered(): TieredConversionRateConfig? = tiered - - fun isUnit(): Boolean = unit != null - - fun isTiered(): Boolean = tiered != null - - fun asUnit(): UnitConversionRateConfig = unit.getOrThrow("unit") - - fun asTiered(): TieredConversionRateConfig = tiered.getOrThrow("tiered") - - fun _json(): JsonValue? = _json - - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): ConversionRateConfig = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) { - unit.validate() - } - - override fun visitTiered(tiered: TieredConversionRateConfig) { - tiered.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) = unit.validity() - - override fun visitTiered(tiered: TieredConversionRateConfig) = - tiered.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered - } - - override fun hashCode(): Int = Objects.hash(unit, tiered) - - override fun toString(): String = - when { - unit != null -> "ConversionRateConfig{unit=$unit}" - tiered != null -> "ConversionRateConfig{tiered=$tiered}" - _json != null -> "ConversionRateConfig{_unknown=$_json}" - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - - companion object { - - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - fun ofTiered(tiered: TieredConversionRateConfig) = - ConversionRateConfig(tiered = tiered) - } - - /** - * An interface that defines how to map each variant of [ConversionRateConfig] to a - * value of type [T]. - */ - interface Visitor { - - fun visitUnit(unit: UnitConversionRateConfig): T - - fun visitTiered(tiered: TieredConversionRateConfig): T - - /** - * Maps an unknown variant of [ConversionRateConfig] to a value of type [T]. - * - * An instance of [ConversionRateConfig] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if the - * SDK is on an older version than the API, then the API may respond with new - * variants that the SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown ConversionRateConfig: $json") - } - } - - internal class Deserializer : - BaseDeserializer(ConversionRateConfig::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): ConversionRateConfig { - val json = JsonValue.fromJsonNode(node) - val conversionRateType = - json.asObject()?.get("conversion_rate_type")?.asString() - - when (conversionRateType) { - "unit" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(unit = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - "tiered" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { ConversionRateConfig(tiered = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - } - - return ConversionRateConfig(_json = json) - } - } - - internal class Serializer : - BaseSerializer(ConversionRateConfig::class) { - - override fun serialize( - value: ConversionRateConfig, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unit != null -> generator.writeObject(value.unit) - value.tiered != null -> generator.writeObject(value.tiered) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - } - } - } - /** * User specified key-value pairs for the resource. If not present, this defaults to an * empty dictionary. Individual keys can be removed by setting the value to `null`, and the @@ -22161,54 +20421,74 @@ private constructor( override fun toString() = value.toString() } - @JsonDeserialize(using = ConversionRateConfig.Deserializer::class) - @JsonSerialize(using = ConversionRateConfig.Serializer::class) - class ConversionRateConfig + class GroupedTieredConfig + @JsonCreator private constructor( - private val unit: UnitConversionRateConfig? = null, - private val tiered: TieredConversionRateConfig? = null, - private val _json: JsonValue? = null, + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map ) { - fun unit(): UnitConversionRateConfig? = unit + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties - fun tiered(): TieredConversionRateConfig? = tiered + fun toBuilder() = Builder().from(this) - fun isUnit(): Boolean = unit != null + companion object { - fun isTiered(): Boolean = tiered != null + /** + * Returns a mutable builder for constructing an instance of [GroupedTieredConfig]. + */ + fun builder() = Builder() + } - fun asUnit(): UnitConversionRateConfig = unit.getOrThrow("unit") + /** A builder for [GroupedTieredConfig]. */ + class Builder internal constructor() { - fun asTiered(): TieredConversionRateConfig = tiered.getOrThrow("tiered") + private var additionalProperties: MutableMap = mutableMapOf() - fun _json(): JsonValue? = _json + internal fun from(groupedTieredConfig: GroupedTieredConfig) = apply { + additionalProperties = groupedTieredConfig.additionalProperties.toMutableMap() + } - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - else -> visitor.unknown(_json) + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [GroupedTieredConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): GroupedTieredConfig = + GroupedTieredConfig(additionalProperties.toImmutable()) + } + private var validated: Boolean = false - fun validate(): ConversionRateConfig = apply { + fun validate(): GroupedTieredConfig = apply { if (validated) { return@apply } - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) { - unit.validate() - } - - override fun visitTiered(tiered: TieredConversionRateConfig) { - tiered.validate() - } - } - ) validated = true } @@ -22227,115 +20507,31 @@ private constructor( * Used for best match union deserialization. */ internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) = unit.validity() - - override fun visitTiered(tiered: TieredConversionRateConfig) = - tiered.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered - } - - override fun hashCode(): Int = Objects.hash(unit, tiered) - - override fun toString(): String = - when { - unit != null -> "ConversionRateConfig{unit=$unit}" - tiered != null -> "ConversionRateConfig{tiered=$tiered}" - _json != null -> "ConversionRateConfig{_unknown=$_json}" - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - - companion object { - - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - fun ofTiered(tiered: TieredConversionRateConfig) = - ConversionRateConfig(tiered = tiered) + return other is GroupedTieredConfig && + additionalProperties == other.additionalProperties } - /** - * An interface that defines how to map each variant of [ConversionRateConfig] to a - * value of type [T]. - */ - interface Visitor { - - fun visitUnit(unit: UnitConversionRateConfig): T - - fun visitTiered(tiered: TieredConversionRateConfig): T - - /** - * Maps an unknown variant of [ConversionRateConfig] to a value of type [T]. - * - * An instance of [ConversionRateConfig] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if the - * SDK is on an older version than the API, then the API may respond with new - * variants that the SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown ConversionRateConfig: $json") - } - } - - internal class Deserializer : - BaseDeserializer(ConversionRateConfig::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): ConversionRateConfig { - val json = JsonValue.fromJsonNode(node) - val conversionRateType = - json.asObject()?.get("conversion_rate_type")?.asString() - - when (conversionRateType) { - "unit" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(unit = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - "tiered" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { ConversionRateConfig(tiered = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - } - - return ConversionRateConfig(_json = json) - } - } + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - internal class Serializer : - BaseSerializer(ConversionRateConfig::class) { + override fun hashCode(): Int = hashCode - override fun serialize( - value: ConversionRateConfig, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unit != null -> generator.writeObject(value.unit) - value.tiered != null -> generator.writeObject(value.tiered) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - } - } + override fun toString() = + "GroupedTieredConfig{additionalProperties=$additionalProperties}" } - class GroupedTieredConfig + /** + * User specified key-value pairs for the resource. If not present, this defaults to an + * empty dictionary. Individual keys can be removed by setting the value to `null`, and the + * entire metadata mapping can be cleared by setting `metadata` to `null`. + */ + class Metadata @JsonCreator private constructor( @com.fasterxml.jackson.annotation.JsonValue @@ -22350,127 +20546,17 @@ private constructor( companion object { - /** - * Returns a mutable builder for constructing an instance of [GroupedTieredConfig]. - */ + /** Returns a mutable builder for constructing an instance of [Metadata]. */ fun builder() = Builder() } - /** A builder for [GroupedTieredConfig]. */ + /** A builder for [Metadata]. */ class Builder internal constructor() { private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(groupedTieredConfig: GroupedTieredConfig) = apply { - additionalProperties = groupedTieredConfig.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [GroupedTieredConfig]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): GroupedTieredConfig = - GroupedTieredConfig(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): GroupedTieredConfig = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is GroupedTieredConfig && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "GroupedTieredConfig{additionalProperties=$additionalProperties}" - } - - /** - * User specified key-value pairs for the resource. If not present, this defaults to an - * empty dictionary. Individual keys can be removed by setting the value to `null`, and the - * entire metadata mapping can be cleared by setting `metadata` to `null`. - */ - class Metadata - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Metadata]. */ - fun builder() = Builder() - } - - /** A builder for [Metadata]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(metadata: Metadata) = apply { - additionalProperties = metadata.additionalProperties.toMutableMap() + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() } fun additionalProperties(additionalProperties: Map) = apply { @@ -24210,180 +22296,6 @@ private constructor( override fun toString() = value.toString() } - @JsonDeserialize(using = ConversionRateConfig.Deserializer::class) - @JsonSerialize(using = ConversionRateConfig.Serializer::class) - class ConversionRateConfig - private constructor( - private val unit: UnitConversionRateConfig? = null, - private val tiered: TieredConversionRateConfig? = null, - private val _json: JsonValue? = null, - ) { - - fun unit(): UnitConversionRateConfig? = unit - - fun tiered(): TieredConversionRateConfig? = tiered - - fun isUnit(): Boolean = unit != null - - fun isTiered(): Boolean = tiered != null - - fun asUnit(): UnitConversionRateConfig = unit.getOrThrow("unit") - - fun asTiered(): TieredConversionRateConfig = tiered.getOrThrow("tiered") - - fun _json(): JsonValue? = _json - - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): ConversionRateConfig = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) { - unit.validate() - } - - override fun visitTiered(tiered: TieredConversionRateConfig) { - tiered.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) = unit.validity() - - override fun visitTiered(tiered: TieredConversionRateConfig) = - tiered.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered - } - - override fun hashCode(): Int = Objects.hash(unit, tiered) - - override fun toString(): String = - when { - unit != null -> "ConversionRateConfig{unit=$unit}" - tiered != null -> "ConversionRateConfig{tiered=$tiered}" - _json != null -> "ConversionRateConfig{_unknown=$_json}" - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - - companion object { - - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - fun ofTiered(tiered: TieredConversionRateConfig) = - ConversionRateConfig(tiered = tiered) - } - - /** - * An interface that defines how to map each variant of [ConversionRateConfig] to a - * value of type [T]. - */ - interface Visitor { - - fun visitUnit(unit: UnitConversionRateConfig): T - - fun visitTiered(tiered: TieredConversionRateConfig): T - - /** - * Maps an unknown variant of [ConversionRateConfig] to a value of type [T]. - * - * An instance of [ConversionRateConfig] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if the - * SDK is on an older version than the API, then the API may respond with new - * variants that the SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown ConversionRateConfig: $json") - } - } - - internal class Deserializer : - BaseDeserializer(ConversionRateConfig::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): ConversionRateConfig { - val json = JsonValue.fromJsonNode(node) - val conversionRateType = - json.asObject()?.get("conversion_rate_type")?.asString() - - when (conversionRateType) { - "unit" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(unit = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - "tiered" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { ConversionRateConfig(tiered = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - } - - return ConversionRateConfig(_json = json) - } - } - - internal class Serializer : - BaseSerializer(ConversionRateConfig::class) { - - override fun serialize( - value: ConversionRateConfig, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unit != null -> generator.writeObject(value.unit) - value.tiered != null -> generator.writeObject(value.tiered) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - } - } - } - /** * User specified key-value pairs for the resource. If not present, this defaults to an * empty dictionary. Individual keys can be removed by setting the value to `null`, and the @@ -26269,180 +24181,6 @@ private constructor( override fun toString() = value.toString() } - @JsonDeserialize(using = ConversionRateConfig.Deserializer::class) - @JsonSerialize(using = ConversionRateConfig.Serializer::class) - class ConversionRateConfig - private constructor( - private val unit: UnitConversionRateConfig? = null, - private val tiered: TieredConversionRateConfig? = null, - private val _json: JsonValue? = null, - ) { - - fun unit(): UnitConversionRateConfig? = unit - - fun tiered(): TieredConversionRateConfig? = tiered - - fun isUnit(): Boolean = unit != null - - fun isTiered(): Boolean = tiered != null - - fun asUnit(): UnitConversionRateConfig = unit.getOrThrow("unit") - - fun asTiered(): TieredConversionRateConfig = tiered.getOrThrow("tiered") - - fun _json(): JsonValue? = _json - - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): ConversionRateConfig = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) { - unit.validate() - } - - override fun visitTiered(tiered: TieredConversionRateConfig) { - tiered.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) = unit.validity() - - override fun visitTiered(tiered: TieredConversionRateConfig) = - tiered.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered - } - - override fun hashCode(): Int = Objects.hash(unit, tiered) - - override fun toString(): String = - when { - unit != null -> "ConversionRateConfig{unit=$unit}" - tiered != null -> "ConversionRateConfig{tiered=$tiered}" - _json != null -> "ConversionRateConfig{_unknown=$_json}" - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - - companion object { - - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - fun ofTiered(tiered: TieredConversionRateConfig) = - ConversionRateConfig(tiered = tiered) - } - - /** - * An interface that defines how to map each variant of [ConversionRateConfig] to a - * value of type [T]. - */ - interface Visitor { - - fun visitUnit(unit: UnitConversionRateConfig): T - - fun visitTiered(tiered: TieredConversionRateConfig): T - - /** - * Maps an unknown variant of [ConversionRateConfig] to a value of type [T]. - * - * An instance of [ConversionRateConfig] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if the - * SDK is on an older version than the API, then the API may respond with new - * variants that the SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown ConversionRateConfig: $json") - } - } - - internal class Deserializer : - BaseDeserializer(ConversionRateConfig::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): ConversionRateConfig { - val json = JsonValue.fromJsonNode(node) - val conversionRateType = - json.asObject()?.get("conversion_rate_type")?.asString() - - when (conversionRateType) { - "unit" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(unit = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - "tiered" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { ConversionRateConfig(tiered = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - } - - return ConversionRateConfig(_json = json) - } - } - - internal class Serializer : - BaseSerializer(ConversionRateConfig::class) { - - override fun serialize( - value: ConversionRateConfig, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unit != null -> generator.writeObject(value.unit) - value.tiered != null -> generator.writeObject(value.tiered) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - } - } - } - /** * User specified key-value pairs for the resource. If not present, this defaults to an * empty dictionary. Individual keys can be removed by setting the value to `null`, and the @@ -28323,180 +26061,6 @@ private constructor( override fun toString() = value.toString() } - @JsonDeserialize(using = ConversionRateConfig.Deserializer::class) - @JsonSerialize(using = ConversionRateConfig.Serializer::class) - class ConversionRateConfig - private constructor( - private val unit: UnitConversionRateConfig? = null, - private val tiered: TieredConversionRateConfig? = null, - private val _json: JsonValue? = null, - ) { - - fun unit(): UnitConversionRateConfig? = unit - - fun tiered(): TieredConversionRateConfig? = tiered - - fun isUnit(): Boolean = unit != null - - fun isTiered(): Boolean = tiered != null - - fun asUnit(): UnitConversionRateConfig = unit.getOrThrow("unit") - - fun asTiered(): TieredConversionRateConfig = tiered.getOrThrow("tiered") - - fun _json(): JsonValue? = _json - - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): ConversionRateConfig = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) { - unit.validate() - } - - override fun visitTiered(tiered: TieredConversionRateConfig) { - tiered.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) = unit.validity() - - override fun visitTiered(tiered: TieredConversionRateConfig) = - tiered.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered - } - - override fun hashCode(): Int = Objects.hash(unit, tiered) - - override fun toString(): String = - when { - unit != null -> "ConversionRateConfig{unit=$unit}" - tiered != null -> "ConversionRateConfig{tiered=$tiered}" - _json != null -> "ConversionRateConfig{_unknown=$_json}" - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - - companion object { - - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - fun ofTiered(tiered: TieredConversionRateConfig) = - ConversionRateConfig(tiered = tiered) - } - - /** - * An interface that defines how to map each variant of [ConversionRateConfig] to a - * value of type [T]. - */ - interface Visitor { - - fun visitUnit(unit: UnitConversionRateConfig): T - - fun visitTiered(tiered: TieredConversionRateConfig): T - - /** - * Maps an unknown variant of [ConversionRateConfig] to a value of type [T]. - * - * An instance of [ConversionRateConfig] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if the - * SDK is on an older version than the API, then the API may respond with new - * variants that the SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown ConversionRateConfig: $json") - } - } - - internal class Deserializer : - BaseDeserializer(ConversionRateConfig::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): ConversionRateConfig { - val json = JsonValue.fromJsonNode(node) - val conversionRateType = - json.asObject()?.get("conversion_rate_type")?.asString() - - when (conversionRateType) { - "unit" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(unit = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - "tiered" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { ConversionRateConfig(tiered = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - } - - return ConversionRateConfig(_json = json) - } - } - - internal class Serializer : - BaseSerializer(ConversionRateConfig::class) { - - override fun serialize( - value: ConversionRateConfig, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unit != null -> generator.writeObject(value.unit) - value.tiered != null -> generator.writeObject(value.tiered) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - } - } - } - /** * User specified key-value pairs for the resource. If not present, this defaults to an * empty dictionary. Individual keys can be removed by setting the value to `null`, and the @@ -30376,54 +27940,76 @@ private constructor( override fun toString() = value.toString() } - @JsonDeserialize(using = ConversionRateConfig.Deserializer::class) - @JsonSerialize(using = ConversionRateConfig.Serializer::class) - class ConversionRateConfig + /** + * User specified key-value pairs for the resource. If not present, this defaults to an + * empty dictionary. Individual keys can be removed by setting the value to `null`, and the + * entire metadata mapping can be cleared by setting `metadata` to `null`. + */ + class Metadata + @JsonCreator private constructor( - private val unit: UnitConversionRateConfig? = null, - private val tiered: TieredConversionRateConfig? = null, - private val _json: JsonValue? = null, + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map ) { - fun unit(): UnitConversionRateConfig? = unit + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties - fun tiered(): TieredConversionRateConfig? = tiered + fun toBuilder() = Builder().from(this) - fun isUnit(): Boolean = unit != null + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } - fun isTiered(): Boolean = tiered != null + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun asUnit(): UnitConversionRateConfig = unit.getOrThrow("unit") + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun asTiered(): TieredConversionRateConfig = tiered.getOrThrow("tiered") + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun _json(): JsonValue? = _json + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - else -> visitor.unknown(_json) + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + private var validated: Boolean = false - fun validate(): ConversionRateConfig = apply { + fun validate(): Metadata = apply { if (validated) { return@apply } - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) { - unit.validate() - } - - override fun visitTiered(tiered: TieredConversionRateConfig) { - tiered.validate() - } - } - ) validated = true } @@ -30442,120 +28028,153 @@ private constructor( * Used for best match union deserialization. */ internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) = unit.validity() - - override fun visitTiered(tiered: TieredConversionRateConfig) = - tiered.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered + return other is Metadata && additionalProperties == other.additionalProperties } - override fun hashCode(): Int = Objects.hash(unit, tiered) + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - override fun toString(): String = - when { - unit != null -> "ConversionRateConfig{unit=$unit}" - tiered != null -> "ConversionRateConfig{tiered=$tiered}" - _json != null -> "ConversionRateConfig{_unknown=$_json}" - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + class PriceType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value companion object { - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) + val USAGE_PRICE = of("usage_price") - fun ofTiered(tiered: TieredConversionRateConfig) = - ConversionRateConfig(tiered = tiered) + val FIXED_PRICE = of("fixed_price") + + fun of(value: String) = PriceType(JsonField.of(value)) + } + + /** An enum containing [PriceType]'s known values. */ + enum class Known { + USAGE_PRICE, + FIXED_PRICE, } /** - * An interface that defines how to map each variant of [ConversionRateConfig] to a - * value of type [T]. + * An enum containing [PriceType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [PriceType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. */ - interface Visitor { + enum class Value { + USAGE_PRICE, + FIXED_PRICE, + /** + * An enum member indicating that [PriceType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } - fun visitUnit(unit: UnitConversionRateConfig): T + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + USAGE_PRICE -> Value.USAGE_PRICE + FIXED_PRICE -> Value.FIXED_PRICE + else -> Value._UNKNOWN + } - fun visitTiered(tiered: TieredConversionRateConfig): T + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + USAGE_PRICE -> Known.USAGE_PRICE + FIXED_PRICE -> Known.FIXED_PRICE + else -> throw OrbInvalidDataException("Unknown PriceType: $value") + } - /** - * Maps an unknown variant of [ConversionRateConfig] to a value of type [T]. - * - * An instance of [ConversionRateConfig] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if the - * SDK is on an older version than the API, then the API may respond with new - * variants that the SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown ConversionRateConfig: $json") - } - } - - internal class Deserializer : - BaseDeserializer(ConversionRateConfig::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): ConversionRateConfig { - val json = JsonValue.fromJsonNode(node) - val conversionRateType = - json.asObject()?.get("conversion_rate_type")?.asString() - - when (conversionRateType) { - "unit" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(unit = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - "tiered" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { ConversionRateConfig(tiered = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - } + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") - return ConversionRateConfig(_json = json) + private var validated: Boolean = false + + fun validate(): PriceType = apply { + if (validated) { + return@apply } + + known() + validated = true } - internal class Serializer : - BaseSerializer(ConversionRateConfig::class) { + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - override fun serialize( - value: ConversionRateConfig, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unit != null -> generator.writeObject(value.unit) - value.tiered != null -> generator.writeObject(value.tiered) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } + + return other is PriceType && value == other.value } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() } - /** - * User specified key-value pairs for the resource. If not present, this defaults to an - * empty dictionary. Individual keys can be removed by setting the value to `null`, and the - * entire metadata mapping can be cleared by setting `metadata` to `null`. - */ - class Metadata + class UnitWithPercentConfig @JsonCreator private constructor( @com.fasterxml.jackson.annotation.JsonValue @@ -30570,249 +28189,20 @@ private constructor( companion object { - /** Returns a mutable builder for constructing an instance of [Metadata]. */ + /** + * Returns a mutable builder for constructing an instance of + * [UnitWithPercentConfig]. + */ fun builder() = Builder() } - /** A builder for [Metadata]. */ + /** A builder for [UnitWithPercentConfig]. */ class Builder internal constructor() { private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(metadata: Metadata) = apply { - additionalProperties = metadata.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Metadata]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Metadata && additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - class PriceType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - val USAGE_PRICE = of("usage_price") - - val FIXED_PRICE = of("fixed_price") - - fun of(value: String) = PriceType(JsonField.of(value)) - } - - /** An enum containing [PriceType]'s known values. */ - enum class Known { - USAGE_PRICE, - FIXED_PRICE, - } - - /** - * An enum containing [PriceType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [PriceType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - USAGE_PRICE, - FIXED_PRICE, - /** - * An enum member indicating that [PriceType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - USAGE_PRICE -> Value.USAGE_PRICE - FIXED_PRICE -> Value.FIXED_PRICE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - USAGE_PRICE -> Known.USAGE_PRICE - FIXED_PRICE -> Known.FIXED_PRICE - else -> throw OrbInvalidDataException("Unknown PriceType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString() ?: throw OrbInvalidDataException("Value is not a String") - - private var validated: Boolean = false - - fun validate(): PriceType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is PriceType && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class UnitWithPercentConfig - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [UnitWithPercentConfig]. - */ - fun builder() = Builder() - } - - /** A builder for [UnitWithPercentConfig]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(unitWithPercentConfig: UnitWithPercentConfig) = apply { - additionalProperties = unitWithPercentConfig.additionalProperties.toMutableMap() + internal fun from(unitWithPercentConfig: UnitWithPercentConfig) = apply { + additionalProperties = unitWithPercentConfig.additionalProperties.toMutableMap() } fun additionalProperties(additionalProperties: Map) = apply { @@ -32427,180 +29817,6 @@ private constructor( override fun toString() = value.toString() } - @JsonDeserialize(using = ConversionRateConfig.Deserializer::class) - @JsonSerialize(using = ConversionRateConfig.Serializer::class) - class ConversionRateConfig - private constructor( - private val unit: UnitConversionRateConfig? = null, - private val tiered: TieredConversionRateConfig? = null, - private val _json: JsonValue? = null, - ) { - - fun unit(): UnitConversionRateConfig? = unit - - fun tiered(): TieredConversionRateConfig? = tiered - - fun isUnit(): Boolean = unit != null - - fun isTiered(): Boolean = tiered != null - - fun asUnit(): UnitConversionRateConfig = unit.getOrThrow("unit") - - fun asTiered(): TieredConversionRateConfig = tiered.getOrThrow("tiered") - - fun _json(): JsonValue? = _json - - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): ConversionRateConfig = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) { - unit.validate() - } - - override fun visitTiered(tiered: TieredConversionRateConfig) { - tiered.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) = unit.validity() - - override fun visitTiered(tiered: TieredConversionRateConfig) = - tiered.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered - } - - override fun hashCode(): Int = Objects.hash(unit, tiered) - - override fun toString(): String = - when { - unit != null -> "ConversionRateConfig{unit=$unit}" - tiered != null -> "ConversionRateConfig{tiered=$tiered}" - _json != null -> "ConversionRateConfig{_unknown=$_json}" - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - - companion object { - - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - fun ofTiered(tiered: TieredConversionRateConfig) = - ConversionRateConfig(tiered = tiered) - } - - /** - * An interface that defines how to map each variant of [ConversionRateConfig] to a - * value of type [T]. - */ - interface Visitor { - - fun visitUnit(unit: UnitConversionRateConfig): T - - fun visitTiered(tiered: TieredConversionRateConfig): T - - /** - * Maps an unknown variant of [ConversionRateConfig] to a value of type [T]. - * - * An instance of [ConversionRateConfig] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if the - * SDK is on an older version than the API, then the API may respond with new - * variants that the SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown ConversionRateConfig: $json") - } - } - - internal class Deserializer : - BaseDeserializer(ConversionRateConfig::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): ConversionRateConfig { - val json = JsonValue.fromJsonNode(node) - val conversionRateType = - json.asObject()?.get("conversion_rate_type")?.asString() - - when (conversionRateType) { - "unit" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(unit = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - "tiered" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { ConversionRateConfig(tiered = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - } - - return ConversionRateConfig(_json = json) - } - } - - internal class Serializer : - BaseSerializer(ConversionRateConfig::class) { - - override fun serialize( - value: ConversionRateConfig, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unit != null -> generator.writeObject(value.unit) - value.tiered != null -> generator.writeObject(value.tiered) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - } - } - } - /** * User specified key-value pairs for the resource. If not present, this defaults to an * empty dictionary. Individual keys can be removed by setting the value to `null`, and the @@ -34372,180 +31588,6 @@ private constructor( override fun toString() = value.toString() } - @JsonDeserialize(using = ConversionRateConfig.Deserializer::class) - @JsonSerialize(using = ConversionRateConfig.Serializer::class) - class ConversionRateConfig - private constructor( - private val unit: UnitConversionRateConfig? = null, - private val tiered: TieredConversionRateConfig? = null, - private val _json: JsonValue? = null, - ) { - - fun unit(): UnitConversionRateConfig? = unit - - fun tiered(): TieredConversionRateConfig? = tiered - - fun isUnit(): Boolean = unit != null - - fun isTiered(): Boolean = tiered != null - - fun asUnit(): UnitConversionRateConfig = unit.getOrThrow("unit") - - fun asTiered(): TieredConversionRateConfig = tiered.getOrThrow("tiered") - - fun _json(): JsonValue? = _json - - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): ConversionRateConfig = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) { - unit.validate() - } - - override fun visitTiered(tiered: TieredConversionRateConfig) { - tiered.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) = unit.validity() - - override fun visitTiered(tiered: TieredConversionRateConfig) = - tiered.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered - } - - override fun hashCode(): Int = Objects.hash(unit, tiered) - - override fun toString(): String = - when { - unit != null -> "ConversionRateConfig{unit=$unit}" - tiered != null -> "ConversionRateConfig{tiered=$tiered}" - _json != null -> "ConversionRateConfig{_unknown=$_json}" - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - - companion object { - - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - fun ofTiered(tiered: TieredConversionRateConfig) = - ConversionRateConfig(tiered = tiered) - } - - /** - * An interface that defines how to map each variant of [ConversionRateConfig] to a - * value of type [T]. - */ - interface Visitor { - - fun visitUnit(unit: UnitConversionRateConfig): T - - fun visitTiered(tiered: TieredConversionRateConfig): T - - /** - * Maps an unknown variant of [ConversionRateConfig] to a value of type [T]. - * - * An instance of [ConversionRateConfig] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if the - * SDK is on an older version than the API, then the API may respond with new - * variants that the SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown ConversionRateConfig: $json") - } - } - - internal class Deserializer : - BaseDeserializer(ConversionRateConfig::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): ConversionRateConfig { - val json = JsonValue.fromJsonNode(node) - val conversionRateType = - json.asObject()?.get("conversion_rate_type")?.asString() - - when (conversionRateType) { - "unit" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(unit = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - "tiered" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { ConversionRateConfig(tiered = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - } - - return ConversionRateConfig(_json = json) - } - } - - internal class Serializer : - BaseSerializer(ConversionRateConfig::class) { - - override fun serialize( - value: ConversionRateConfig, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unit != null -> generator.writeObject(value.unit) - value.tiered != null -> generator.writeObject(value.tiered) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - } - } - } - /** * User specified key-value pairs for the resource. If not present, this defaults to an * empty dictionary. Individual keys can be removed by setting the value to `null`, and the @@ -36423,180 +33465,6 @@ private constructor( override fun toString() = value.toString() } - @JsonDeserialize(using = ConversionRateConfig.Deserializer::class) - @JsonSerialize(using = ConversionRateConfig.Serializer::class) - class ConversionRateConfig - private constructor( - private val unit: UnitConversionRateConfig? = null, - private val tiered: TieredConversionRateConfig? = null, - private val _json: JsonValue? = null, - ) { - - fun unit(): UnitConversionRateConfig? = unit - - fun tiered(): TieredConversionRateConfig? = tiered - - fun isUnit(): Boolean = unit != null - - fun isTiered(): Boolean = tiered != null - - fun asUnit(): UnitConversionRateConfig = unit.getOrThrow("unit") - - fun asTiered(): TieredConversionRateConfig = tiered.getOrThrow("tiered") - - fun _json(): JsonValue? = _json - - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): ConversionRateConfig = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) { - unit.validate() - } - - override fun visitTiered(tiered: TieredConversionRateConfig) { - tiered.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) = unit.validity() - - override fun visitTiered(tiered: TieredConversionRateConfig) = - tiered.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered - } - - override fun hashCode(): Int = Objects.hash(unit, tiered) - - override fun toString(): String = - when { - unit != null -> "ConversionRateConfig{unit=$unit}" - tiered != null -> "ConversionRateConfig{tiered=$tiered}" - _json != null -> "ConversionRateConfig{_unknown=$_json}" - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - - companion object { - - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - fun ofTiered(tiered: TieredConversionRateConfig) = - ConversionRateConfig(tiered = tiered) - } - - /** - * An interface that defines how to map each variant of [ConversionRateConfig] to a - * value of type [T]. - */ - interface Visitor { - - fun visitUnit(unit: UnitConversionRateConfig): T - - fun visitTiered(tiered: TieredConversionRateConfig): T - - /** - * Maps an unknown variant of [ConversionRateConfig] to a value of type [T]. - * - * An instance of [ConversionRateConfig] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if the - * SDK is on an older version than the API, then the API may respond with new - * variants that the SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown ConversionRateConfig: $json") - } - } - - internal class Deserializer : - BaseDeserializer(ConversionRateConfig::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): ConversionRateConfig { - val json = JsonValue.fromJsonNode(node) - val conversionRateType = - json.asObject()?.get("conversion_rate_type")?.asString() - - when (conversionRateType) { - "unit" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(unit = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - "tiered" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { ConversionRateConfig(tiered = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - } - - return ConversionRateConfig(_json = json) - } - } - - internal class Serializer : - BaseSerializer(ConversionRateConfig::class) { - - override fun serialize( - value: ConversionRateConfig, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unit != null -> generator.writeObject(value.unit) - value.tiered != null -> generator.writeObject(value.tiered) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - } - } - } - /** * User specified key-value pairs for the resource. If not present, this defaults to an * empty dictionary. Individual keys can be removed by setting the value to `null`, and the @@ -38474,54 +35342,76 @@ private constructor( override fun toString() = value.toString() } - @JsonDeserialize(using = ConversionRateConfig.Deserializer::class) - @JsonSerialize(using = ConversionRateConfig.Serializer::class) - class ConversionRateConfig + class GroupedAllocationConfig + @JsonCreator private constructor( - private val unit: UnitConversionRateConfig? = null, - private val tiered: TieredConversionRateConfig? = null, - private val _json: JsonValue? = null, + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map ) { - fun unit(): UnitConversionRateConfig? = unit + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { - fun tiered(): TieredConversionRateConfig? = tiered + /** + * Returns a mutable builder for constructing an instance of + * [GroupedAllocationConfig]. + */ + fun builder() = Builder() + } - fun isUnit(): Boolean = unit != null + /** A builder for [GroupedAllocationConfig]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(groupedAllocationConfig: GroupedAllocationConfig) = apply { + additionalProperties = + groupedAllocationConfig.additionalProperties.toMutableMap() + } - fun isTiered(): Boolean = tiered != null + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun asUnit(): UnitConversionRateConfig = unit.getOrThrow("unit") + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun asTiered(): TieredConversionRateConfig = tiered.getOrThrow("tiered") + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun _json(): JsonValue? = _json + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - else -> visitor.unknown(_json) + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [GroupedAllocationConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): GroupedAllocationConfig = + GroupedAllocationConfig(additionalProperties.toImmutable()) + } + private var validated: Boolean = false - fun validate(): ConversionRateConfig = apply { + fun validate(): GroupedAllocationConfig = apply { if (validated) { return@apply } - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) { - unit.validate() - } - - override fun visitTiered(tiered: TieredConversionRateConfig) { - tiered.validate() - } - } - ) validated = true } @@ -38540,115 +35430,31 @@ private constructor( * Used for best match union deserialization. */ internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) = unit.validity() - - override fun visitTiered(tiered: TieredConversionRateConfig) = - tiered.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered - } - - override fun hashCode(): Int = Objects.hash(unit, tiered) - - override fun toString(): String = - when { - unit != null -> "ConversionRateConfig{unit=$unit}" - tiered != null -> "ConversionRateConfig{tiered=$tiered}" - _json != null -> "ConversionRateConfig{_unknown=$_json}" - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - - companion object { - - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - fun ofTiered(tiered: TieredConversionRateConfig) = - ConversionRateConfig(tiered = tiered) + return other is GroupedAllocationConfig && + additionalProperties == other.additionalProperties } - /** - * An interface that defines how to map each variant of [ConversionRateConfig] to a - * value of type [T]. - */ - interface Visitor { - - fun visitUnit(unit: UnitConversionRateConfig): T - - fun visitTiered(tiered: TieredConversionRateConfig): T - - /** - * Maps an unknown variant of [ConversionRateConfig] to a value of type [T]. - * - * An instance of [ConversionRateConfig] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if the - * SDK is on an older version than the API, then the API may respond with new - * variants that the SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown ConversionRateConfig: $json") - } - } - - internal class Deserializer : - BaseDeserializer(ConversionRateConfig::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): ConversionRateConfig { - val json = JsonValue.fromJsonNode(node) - val conversionRateType = - json.asObject()?.get("conversion_rate_type")?.asString() - - when (conversionRateType) { - "unit" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(unit = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - "tiered" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { ConversionRateConfig(tiered = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - } - - return ConversionRateConfig(_json = json) - } - } + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - internal class Serializer : - BaseSerializer(ConversionRateConfig::class) { + override fun hashCode(): Int = hashCode - override fun serialize( - value: ConversionRateConfig, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unit != null -> generator.writeObject(value.unit) - value.tiered != null -> generator.writeObject(value.tiered) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - } - } + override fun toString() = + "GroupedAllocationConfig{additionalProperties=$additionalProperties}" } - class GroupedAllocationConfig + /** + * User specified key-value pairs for the resource. If not present, this defaults to an + * empty dictionary. Individual keys can be removed by setting the value to `null`, and the + * entire metadata mapping can be cleared by setting `metadata` to `null`. + */ + class Metadata @JsonCreator private constructor( @com.fasterxml.jackson.annotation.JsonValue @@ -38663,129 +35469,17 @@ private constructor( companion object { - /** - * Returns a mutable builder for constructing an instance of - * [GroupedAllocationConfig]. - */ + /** Returns a mutable builder for constructing an instance of [Metadata]. */ fun builder() = Builder() } - /** A builder for [GroupedAllocationConfig]. */ + /** A builder for [Metadata]. */ class Builder internal constructor() { private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(groupedAllocationConfig: GroupedAllocationConfig) = apply { - additionalProperties = - groupedAllocationConfig.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [GroupedAllocationConfig]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): GroupedAllocationConfig = - GroupedAllocationConfig(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): GroupedAllocationConfig = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is GroupedAllocationConfig && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "GroupedAllocationConfig{additionalProperties=$additionalProperties}" - } - - /** - * User specified key-value pairs for the resource. If not present, this defaults to an - * empty dictionary. Individual keys can be removed by setting the value to `null`, and the - * entire metadata mapping can be cleared by setting `metadata` to `null`. - */ - class Metadata - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Metadata]. */ - fun builder() = Builder() - } - - /** A builder for [Metadata]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(metadata: Metadata) = apply { - additionalProperties = metadata.additionalProperties.toMutableMap() + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() } fun additionalProperties(additionalProperties: Map) = apply { @@ -40539,180 +37233,6 @@ private constructor( override fun toString() = value.toString() } - @JsonDeserialize(using = ConversionRateConfig.Deserializer::class) - @JsonSerialize(using = ConversionRateConfig.Serializer::class) - class ConversionRateConfig - private constructor( - private val unit: UnitConversionRateConfig? = null, - private val tiered: TieredConversionRateConfig? = null, - private val _json: JsonValue? = null, - ) { - - fun unit(): UnitConversionRateConfig? = unit - - fun tiered(): TieredConversionRateConfig? = tiered - - fun isUnit(): Boolean = unit != null - - fun isTiered(): Boolean = tiered != null - - fun asUnit(): UnitConversionRateConfig = unit.getOrThrow("unit") - - fun asTiered(): TieredConversionRateConfig = tiered.getOrThrow("tiered") - - fun _json(): JsonValue? = _json - - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): ConversionRateConfig = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) { - unit.validate() - } - - override fun visitTiered(tiered: TieredConversionRateConfig) { - tiered.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) = unit.validity() - - override fun visitTiered(tiered: TieredConversionRateConfig) = - tiered.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered - } - - override fun hashCode(): Int = Objects.hash(unit, tiered) - - override fun toString(): String = - when { - unit != null -> "ConversionRateConfig{unit=$unit}" - tiered != null -> "ConversionRateConfig{tiered=$tiered}" - _json != null -> "ConversionRateConfig{_unknown=$_json}" - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - - companion object { - - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - fun ofTiered(tiered: TieredConversionRateConfig) = - ConversionRateConfig(tiered = tiered) - } - - /** - * An interface that defines how to map each variant of [ConversionRateConfig] to a - * value of type [T]. - */ - interface Visitor { - - fun visitUnit(unit: UnitConversionRateConfig): T - - fun visitTiered(tiered: TieredConversionRateConfig): T - - /** - * Maps an unknown variant of [ConversionRateConfig] to a value of type [T]. - * - * An instance of [ConversionRateConfig] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if the - * SDK is on an older version than the API, then the API may respond with new - * variants that the SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown ConversionRateConfig: $json") - } - } - - internal class Deserializer : - BaseDeserializer(ConversionRateConfig::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): ConversionRateConfig { - val json = JsonValue.fromJsonNode(node) - val conversionRateType = - json.asObject()?.get("conversion_rate_type")?.asString() - - when (conversionRateType) { - "unit" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(unit = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - "tiered" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { ConversionRateConfig(tiered = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - } - - return ConversionRateConfig(_json = json) - } - } - - internal class Serializer : - BaseSerializer(ConversionRateConfig::class) { - - override fun serialize( - value: ConversionRateConfig, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unit != null -> generator.writeObject(value.unit) - value.tiered != null -> generator.writeObject(value.tiered) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - } - } - } - class GroupedWithProratedMinimumConfig @JsonCreator private constructor( @@ -42605,180 +39125,6 @@ private constructor( override fun toString() = value.toString() } - @JsonDeserialize(using = ConversionRateConfig.Deserializer::class) - @JsonSerialize(using = ConversionRateConfig.Serializer::class) - class ConversionRateConfig - private constructor( - private val unit: UnitConversionRateConfig? = null, - private val tiered: TieredConversionRateConfig? = null, - private val _json: JsonValue? = null, - ) { - - fun unit(): UnitConversionRateConfig? = unit - - fun tiered(): TieredConversionRateConfig? = tiered - - fun isUnit(): Boolean = unit != null - - fun isTiered(): Boolean = tiered != null - - fun asUnit(): UnitConversionRateConfig = unit.getOrThrow("unit") - - fun asTiered(): TieredConversionRateConfig = tiered.getOrThrow("tiered") - - fun _json(): JsonValue? = _json - - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): ConversionRateConfig = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) { - unit.validate() - } - - override fun visitTiered(tiered: TieredConversionRateConfig) { - tiered.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) = unit.validity() - - override fun visitTiered(tiered: TieredConversionRateConfig) = - tiered.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered - } - - override fun hashCode(): Int = Objects.hash(unit, tiered) - - override fun toString(): String = - when { - unit != null -> "ConversionRateConfig{unit=$unit}" - tiered != null -> "ConversionRateConfig{tiered=$tiered}" - _json != null -> "ConversionRateConfig{_unknown=$_json}" - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - - companion object { - - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - fun ofTiered(tiered: TieredConversionRateConfig) = - ConversionRateConfig(tiered = tiered) - } - - /** - * An interface that defines how to map each variant of [ConversionRateConfig] to a - * value of type [T]. - */ - interface Visitor { - - fun visitUnit(unit: UnitConversionRateConfig): T - - fun visitTiered(tiered: TieredConversionRateConfig): T - - /** - * Maps an unknown variant of [ConversionRateConfig] to a value of type [T]. - * - * An instance of [ConversionRateConfig] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if the - * SDK is on an older version than the API, then the API may respond with new - * variants that the SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown ConversionRateConfig: $json") - } - } - - internal class Deserializer : - BaseDeserializer(ConversionRateConfig::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): ConversionRateConfig { - val json = JsonValue.fromJsonNode(node) - val conversionRateType = - json.asObject()?.get("conversion_rate_type")?.asString() - - when (conversionRateType) { - "unit" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(unit = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - "tiered" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { ConversionRateConfig(tiered = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - } - - return ConversionRateConfig(_json = json) - } - } - - internal class Serializer : - BaseSerializer(ConversionRateConfig::class) { - - override fun serialize( - value: ConversionRateConfig, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unit != null -> generator.writeObject(value.unit) - value.tiered != null -> generator.writeObject(value.tiered) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - } - } - } - class GroupedWithMeteredMinimumConfig @JsonCreator private constructor( @@ -44660,180 +41006,6 @@ private constructor( override fun toString() = value.toString() } - @JsonDeserialize(using = ConversionRateConfig.Deserializer::class) - @JsonSerialize(using = ConversionRateConfig.Serializer::class) - class ConversionRateConfig - private constructor( - private val unit: UnitConversionRateConfig? = null, - private val tiered: TieredConversionRateConfig? = null, - private val _json: JsonValue? = null, - ) { - - fun unit(): UnitConversionRateConfig? = unit - - fun tiered(): TieredConversionRateConfig? = tiered - - fun isUnit(): Boolean = unit != null - - fun isTiered(): Boolean = tiered != null - - fun asUnit(): UnitConversionRateConfig = unit.getOrThrow("unit") - - fun asTiered(): TieredConversionRateConfig = tiered.getOrThrow("tiered") - - fun _json(): JsonValue? = _json - - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): ConversionRateConfig = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) { - unit.validate() - } - - override fun visitTiered(tiered: TieredConversionRateConfig) { - tiered.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) = unit.validity() - - override fun visitTiered(tiered: TieredConversionRateConfig) = - tiered.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered - } - - override fun hashCode(): Int = Objects.hash(unit, tiered) - - override fun toString(): String = - when { - unit != null -> "ConversionRateConfig{unit=$unit}" - tiered != null -> "ConversionRateConfig{tiered=$tiered}" - _json != null -> "ConversionRateConfig{_unknown=$_json}" - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - - companion object { - - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - fun ofTiered(tiered: TieredConversionRateConfig) = - ConversionRateConfig(tiered = tiered) - } - - /** - * An interface that defines how to map each variant of [ConversionRateConfig] to a - * value of type [T]. - */ - interface Visitor { - - fun visitUnit(unit: UnitConversionRateConfig): T - - fun visitTiered(tiered: TieredConversionRateConfig): T - - /** - * Maps an unknown variant of [ConversionRateConfig] to a value of type [T]. - * - * An instance of [ConversionRateConfig] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if the - * SDK is on an older version than the API, then the API may respond with new - * variants that the SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown ConversionRateConfig: $json") - } - } - - internal class Deserializer : - BaseDeserializer(ConversionRateConfig::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): ConversionRateConfig { - val json = JsonValue.fromJsonNode(node) - val conversionRateType = - json.asObject()?.get("conversion_rate_type")?.asString() - - when (conversionRateType) { - "unit" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(unit = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - "tiered" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { ConversionRateConfig(tiered = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - } - - return ConversionRateConfig(_json = json) - } - } - - internal class Serializer : - BaseSerializer(ConversionRateConfig::class) { - - override fun serialize( - value: ConversionRateConfig, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unit != null -> generator.writeObject(value.unit) - value.tiered != null -> generator.writeObject(value.tiered) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - } - } - } - class MatrixWithDisplayNameConfig @JsonCreator private constructor( @@ -46819,180 +42991,6 @@ private constructor( override fun toString() = value.toString() } - @JsonDeserialize(using = ConversionRateConfig.Deserializer::class) - @JsonSerialize(using = ConversionRateConfig.Serializer::class) - class ConversionRateConfig - private constructor( - private val unit: UnitConversionRateConfig? = null, - private val tiered: TieredConversionRateConfig? = null, - private val _json: JsonValue? = null, - ) { - - fun unit(): UnitConversionRateConfig? = unit - - fun tiered(): TieredConversionRateConfig? = tiered - - fun isUnit(): Boolean = unit != null - - fun isTiered(): Boolean = tiered != null - - fun asUnit(): UnitConversionRateConfig = unit.getOrThrow("unit") - - fun asTiered(): TieredConversionRateConfig = tiered.getOrThrow("tiered") - - fun _json(): JsonValue? = _json - - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): ConversionRateConfig = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) { - unit.validate() - } - - override fun visitTiered(tiered: TieredConversionRateConfig) { - tiered.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) = unit.validity() - - override fun visitTiered(tiered: TieredConversionRateConfig) = - tiered.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered - } - - override fun hashCode(): Int = Objects.hash(unit, tiered) - - override fun toString(): String = - when { - unit != null -> "ConversionRateConfig{unit=$unit}" - tiered != null -> "ConversionRateConfig{tiered=$tiered}" - _json != null -> "ConversionRateConfig{_unknown=$_json}" - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - - companion object { - - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - fun ofTiered(tiered: TieredConversionRateConfig) = - ConversionRateConfig(tiered = tiered) - } - - /** - * An interface that defines how to map each variant of [ConversionRateConfig] to a - * value of type [T]. - */ - interface Visitor { - - fun visitUnit(unit: UnitConversionRateConfig): T - - fun visitTiered(tiered: TieredConversionRateConfig): T - - /** - * Maps an unknown variant of [ConversionRateConfig] to a value of type [T]. - * - * An instance of [ConversionRateConfig] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if the - * SDK is on an older version than the API, then the API may respond with new - * variants that the SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown ConversionRateConfig: $json") - } - } - - internal class Deserializer : - BaseDeserializer(ConversionRateConfig::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): ConversionRateConfig { - val json = JsonValue.fromJsonNode(node) - val conversionRateType = - json.asObject()?.get("conversion_rate_type")?.asString() - - when (conversionRateType) { - "unit" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(unit = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - "tiered" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { ConversionRateConfig(tiered = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - } - - return ConversionRateConfig(_json = json) - } - } - - internal class Serializer : - BaseSerializer(ConversionRateConfig::class) { - - override fun serialize( - value: ConversionRateConfig, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unit != null -> generator.writeObject(value.unit) - value.tiered != null -> generator.writeObject(value.tiered) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - } - } - } - /** * User specified key-value pairs for the resource. If not present, this defaults to an * empty dictionary. Individual keys can be removed by setting the value to `null`, and the @@ -48764,54 +44762,76 @@ private constructor( override fun toString() = value.toString() } - @JsonDeserialize(using = ConversionRateConfig.Deserializer::class) - @JsonSerialize(using = ConversionRateConfig.Serializer::class) - class ConversionRateConfig + class GroupedTieredPackageConfig + @JsonCreator private constructor( - private val unit: UnitConversionRateConfig? = null, - private val tiered: TieredConversionRateConfig? = null, - private val _json: JsonValue? = null, + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map ) { - fun unit(): UnitConversionRateConfig? = unit + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { - fun tiered(): TieredConversionRateConfig? = tiered + /** + * Returns a mutable builder for constructing an instance of + * [GroupedTieredPackageConfig]. + */ + fun builder() = Builder() + } - fun isUnit(): Boolean = unit != null + /** A builder for [GroupedTieredPackageConfig]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(groupedTieredPackageConfig: GroupedTieredPackageConfig) = apply { + additionalProperties = + groupedTieredPackageConfig.additionalProperties.toMutableMap() + } - fun isTiered(): Boolean = tiered != null + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun asUnit(): UnitConversionRateConfig = unit.getOrThrow("unit") + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun asTiered(): TieredConversionRateConfig = tiered.getOrThrow("tiered") + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun _json(): JsonValue? = _json + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - else -> visitor.unknown(_json) + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [GroupedTieredPackageConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): GroupedTieredPackageConfig = + GroupedTieredPackageConfig(additionalProperties.toImmutable()) + } + private var validated: Boolean = false - fun validate(): ConversionRateConfig = apply { + fun validate(): GroupedTieredPackageConfig = apply { if (validated) { return@apply } - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) { - unit.validate() - } - - override fun visitTiered(tiered: TieredConversionRateConfig) { - tiered.validate() - } - } - ) validated = true } @@ -48830,115 +44850,31 @@ private constructor( * Used for best match union deserialization. */ internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) = unit.validity() - - override fun visitTiered(tiered: TieredConversionRateConfig) = - tiered.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered - } - - override fun hashCode(): Int = Objects.hash(unit, tiered) - - override fun toString(): String = - when { - unit != null -> "ConversionRateConfig{unit=$unit}" - tiered != null -> "ConversionRateConfig{tiered=$tiered}" - _json != null -> "ConversionRateConfig{_unknown=$_json}" - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - - companion object { - - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - fun ofTiered(tiered: TieredConversionRateConfig) = - ConversionRateConfig(tiered = tiered) + return other is GroupedTieredPackageConfig && + additionalProperties == other.additionalProperties } - /** - * An interface that defines how to map each variant of [ConversionRateConfig] to a - * value of type [T]. - */ - interface Visitor { - - fun visitUnit(unit: UnitConversionRateConfig): T - - fun visitTiered(tiered: TieredConversionRateConfig): T - - /** - * Maps an unknown variant of [ConversionRateConfig] to a value of type [T]. - * - * An instance of [ConversionRateConfig] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if the - * SDK is on an older version than the API, then the API may respond with new - * variants that the SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown ConversionRateConfig: $json") - } - } - - internal class Deserializer : - BaseDeserializer(ConversionRateConfig::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): ConversionRateConfig { - val json = JsonValue.fromJsonNode(node) - val conversionRateType = - json.asObject()?.get("conversion_rate_type")?.asString() - - when (conversionRateType) { - "unit" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(unit = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - "tiered" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { ConversionRateConfig(tiered = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - } - - return ConversionRateConfig(_json = json) - } - } + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - internal class Serializer : - BaseSerializer(ConversionRateConfig::class) { + override fun hashCode(): Int = hashCode - override fun serialize( - value: ConversionRateConfig, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unit != null -> generator.writeObject(value.unit) - value.tiered != null -> generator.writeObject(value.tiered) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - } - } + override fun toString() = + "GroupedTieredPackageConfig{additionalProperties=$additionalProperties}" } - class GroupedTieredPackageConfig + /** + * User specified key-value pairs for the resource. If not present, this defaults to an + * empty dictionary. Individual keys can be removed by setting the value to `null`, and the + * entire metadata mapping can be cleared by setting `metadata` to `null`. + */ + class Metadata @JsonCreator private constructor( @com.fasterxml.jackson.annotation.JsonValue @@ -48953,129 +44889,17 @@ private constructor( companion object { - /** - * Returns a mutable builder for constructing an instance of - * [GroupedTieredPackageConfig]. - */ + /** Returns a mutable builder for constructing an instance of [Metadata]. */ fun builder() = Builder() } - /** A builder for [GroupedTieredPackageConfig]. */ + /** A builder for [Metadata]. */ class Builder internal constructor() { private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(groupedTieredPackageConfig: GroupedTieredPackageConfig) = apply { - additionalProperties = - groupedTieredPackageConfig.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [GroupedTieredPackageConfig]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): GroupedTieredPackageConfig = - GroupedTieredPackageConfig(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): GroupedTieredPackageConfig = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is GroupedTieredPackageConfig && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "GroupedTieredPackageConfig{additionalProperties=$additionalProperties}" - } - - /** - * User specified key-value pairs for the resource. If not present, this defaults to an - * empty dictionary. Individual keys can be removed by setting the value to `null`, and the - * entire metadata mapping can be cleared by setting `metadata` to `null`. - */ - class Metadata - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Metadata]. */ - fun builder() = Builder() - } - - /** A builder for [Metadata]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(metadata: Metadata) = apply { - additionalProperties = metadata.additionalProperties.toMutableMap() + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() } fun additionalProperties(additionalProperties: Map) = apply { @@ -50817,180 +46641,6 @@ private constructor( override fun toString() = value.toString() } - @JsonDeserialize(using = ConversionRateConfig.Deserializer::class) - @JsonSerialize(using = ConversionRateConfig.Serializer::class) - class ConversionRateConfig - private constructor( - private val unit: UnitConversionRateConfig? = null, - private val tiered: TieredConversionRateConfig? = null, - private val _json: JsonValue? = null, - ) { - - fun unit(): UnitConversionRateConfig? = unit - - fun tiered(): TieredConversionRateConfig? = tiered - - fun isUnit(): Boolean = unit != null - - fun isTiered(): Boolean = tiered != null - - fun asUnit(): UnitConversionRateConfig = unit.getOrThrow("unit") - - fun asTiered(): TieredConversionRateConfig = tiered.getOrThrow("tiered") - - fun _json(): JsonValue? = _json - - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): ConversionRateConfig = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) { - unit.validate() - } - - override fun visitTiered(tiered: TieredConversionRateConfig) { - tiered.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) = unit.validity() - - override fun visitTiered(tiered: TieredConversionRateConfig) = - tiered.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered - } - - override fun hashCode(): Int = Objects.hash(unit, tiered) - - override fun toString(): String = - when { - unit != null -> "ConversionRateConfig{unit=$unit}" - tiered != null -> "ConversionRateConfig{tiered=$tiered}" - _json != null -> "ConversionRateConfig{_unknown=$_json}" - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - - companion object { - - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - fun ofTiered(tiered: TieredConversionRateConfig) = - ConversionRateConfig(tiered = tiered) - } - - /** - * An interface that defines how to map each variant of [ConversionRateConfig] to a - * value of type [T]. - */ - interface Visitor { - - fun visitUnit(unit: UnitConversionRateConfig): T - - fun visitTiered(tiered: TieredConversionRateConfig): T - - /** - * Maps an unknown variant of [ConversionRateConfig] to a value of type [T]. - * - * An instance of [ConversionRateConfig] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if the - * SDK is on an older version than the API, then the API may respond with new - * variants that the SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown ConversionRateConfig: $json") - } - } - - internal class Deserializer : - BaseDeserializer(ConversionRateConfig::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): ConversionRateConfig { - val json = JsonValue.fromJsonNode(node) - val conversionRateType = - json.asObject()?.get("conversion_rate_type")?.asString() - - when (conversionRateType) { - "unit" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(unit = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - "tiered" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { ConversionRateConfig(tiered = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - } - - return ConversionRateConfig(_json = json) - } - } - - internal class Serializer : - BaseSerializer(ConversionRateConfig::class) { - - override fun serialize( - value: ConversionRateConfig, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unit != null -> generator.writeObject(value.unit) - value.tiered != null -> generator.writeObject(value.tiered) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - } - } - } - class MaxGroupTieredPackageConfig @JsonCreator private constructor( @@ -52894,180 +48544,6 @@ private constructor( override fun toString() = value.toString() } - @JsonDeserialize(using = ConversionRateConfig.Deserializer::class) - @JsonSerialize(using = ConversionRateConfig.Serializer::class) - class ConversionRateConfig - private constructor( - private val unit: UnitConversionRateConfig? = null, - private val tiered: TieredConversionRateConfig? = null, - private val _json: JsonValue? = null, - ) { - - fun unit(): UnitConversionRateConfig? = unit - - fun tiered(): TieredConversionRateConfig? = tiered - - fun isUnit(): Boolean = unit != null - - fun isTiered(): Boolean = tiered != null - - fun asUnit(): UnitConversionRateConfig = unit.getOrThrow("unit") - - fun asTiered(): TieredConversionRateConfig = tiered.getOrThrow("tiered") - - fun _json(): JsonValue? = _json - - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): ConversionRateConfig = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) { - unit.validate() - } - - override fun visitTiered(tiered: TieredConversionRateConfig) { - tiered.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) = unit.validity() - - override fun visitTiered(tiered: TieredConversionRateConfig) = - tiered.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered - } - - override fun hashCode(): Int = Objects.hash(unit, tiered) - - override fun toString(): String = - when { - unit != null -> "ConversionRateConfig{unit=$unit}" - tiered != null -> "ConversionRateConfig{tiered=$tiered}" - _json != null -> "ConversionRateConfig{_unknown=$_json}" - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - - companion object { - - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - fun ofTiered(tiered: TieredConversionRateConfig) = - ConversionRateConfig(tiered = tiered) - } - - /** - * An interface that defines how to map each variant of [ConversionRateConfig] to a - * value of type [T]. - */ - interface Visitor { - - fun visitUnit(unit: UnitConversionRateConfig): T - - fun visitTiered(tiered: TieredConversionRateConfig): T - - /** - * Maps an unknown variant of [ConversionRateConfig] to a value of type [T]. - * - * An instance of [ConversionRateConfig] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if the - * SDK is on an older version than the API, then the API may respond with new - * variants that the SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown ConversionRateConfig: $json") - } - } - - internal class Deserializer : - BaseDeserializer(ConversionRateConfig::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): ConversionRateConfig { - val json = JsonValue.fromJsonNode(node) - val conversionRateType = - json.asObject()?.get("conversion_rate_type")?.asString() - - when (conversionRateType) { - "unit" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(unit = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - "tiered" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { ConversionRateConfig(tiered = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - } - - return ConversionRateConfig(_json = json) - } - } - - internal class Serializer : - BaseSerializer(ConversionRateConfig::class) { - - override fun serialize( - value: ConversionRateConfig, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unit != null -> generator.writeObject(value.unit) - value.tiered != null -> generator.writeObject(value.tiered) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - } - } - } - /** * User specified key-value pairs for the resource. If not present, this defaults to an * empty dictionary. Individual keys can be removed by setting the value to `null`, and the @@ -54974,180 +50450,6 @@ private constructor( override fun toString() = value.toString() } - @JsonDeserialize(using = ConversionRateConfig.Deserializer::class) - @JsonSerialize(using = ConversionRateConfig.Serializer::class) - class ConversionRateConfig - private constructor( - private val unit: UnitConversionRateConfig? = null, - private val tiered: TieredConversionRateConfig? = null, - private val _json: JsonValue? = null, - ) { - - fun unit(): UnitConversionRateConfig? = unit - - fun tiered(): TieredConversionRateConfig? = tiered - - fun isUnit(): Boolean = unit != null - - fun isTiered(): Boolean = tiered != null - - fun asUnit(): UnitConversionRateConfig = unit.getOrThrow("unit") - - fun asTiered(): TieredConversionRateConfig = tiered.getOrThrow("tiered") - - fun _json(): JsonValue? = _json - - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): ConversionRateConfig = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) { - unit.validate() - } - - override fun visitTiered(tiered: TieredConversionRateConfig) { - tiered.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) = unit.validity() - - override fun visitTiered(tiered: TieredConversionRateConfig) = - tiered.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered - } - - override fun hashCode(): Int = Objects.hash(unit, tiered) - - override fun toString(): String = - when { - unit != null -> "ConversionRateConfig{unit=$unit}" - tiered != null -> "ConversionRateConfig{tiered=$tiered}" - _json != null -> "ConversionRateConfig{_unknown=$_json}" - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - - companion object { - - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - fun ofTiered(tiered: TieredConversionRateConfig) = - ConversionRateConfig(tiered = tiered) - } - - /** - * An interface that defines how to map each variant of [ConversionRateConfig] to a - * value of type [T]. - */ - interface Visitor { - - fun visitUnit(unit: UnitConversionRateConfig): T - - fun visitTiered(tiered: TieredConversionRateConfig): T - - /** - * Maps an unknown variant of [ConversionRateConfig] to a value of type [T]. - * - * An instance of [ConversionRateConfig] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if the - * SDK is on an older version than the API, then the API may respond with new - * variants that the SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown ConversionRateConfig: $json") - } - } - - internal class Deserializer : - BaseDeserializer(ConversionRateConfig::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): ConversionRateConfig { - val json = JsonValue.fromJsonNode(node) - val conversionRateType = - json.asObject()?.get("conversion_rate_type")?.asString() - - when (conversionRateType) { - "unit" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(unit = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - "tiered" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { ConversionRateConfig(tiered = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - } - - return ConversionRateConfig(_json = json) - } - } - - internal class Serializer : - BaseSerializer(ConversionRateConfig::class) { - - override fun serialize( - value: ConversionRateConfig, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unit != null -> generator.writeObject(value.unit) - value.tiered != null -> generator.writeObject(value.tiered) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - } - } - } - /** * User specified key-value pairs for the resource. If not present, this defaults to an * empty dictionary. Individual keys can be removed by setting the value to `null`, and the @@ -57030,180 +52332,6 @@ private constructor( override fun toString() = value.toString() } - @JsonDeserialize(using = ConversionRateConfig.Deserializer::class) - @JsonSerialize(using = ConversionRateConfig.Serializer::class) - class ConversionRateConfig - private constructor( - private val unit: UnitConversionRateConfig? = null, - private val tiered: TieredConversionRateConfig? = null, - private val _json: JsonValue? = null, - ) { - - fun unit(): UnitConversionRateConfig? = unit - - fun tiered(): TieredConversionRateConfig? = tiered - - fun isUnit(): Boolean = unit != null - - fun isTiered(): Boolean = tiered != null - - fun asUnit(): UnitConversionRateConfig = unit.getOrThrow("unit") - - fun asTiered(): TieredConversionRateConfig = tiered.getOrThrow("tiered") - - fun _json(): JsonValue? = _json - - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): ConversionRateConfig = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) { - unit.validate() - } - - override fun visitTiered(tiered: TieredConversionRateConfig) { - tiered.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) = unit.validity() - - override fun visitTiered(tiered: TieredConversionRateConfig) = - tiered.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered - } - - override fun hashCode(): Int = Objects.hash(unit, tiered) - - override fun toString(): String = - when { - unit != null -> "ConversionRateConfig{unit=$unit}" - tiered != null -> "ConversionRateConfig{tiered=$tiered}" - _json != null -> "ConversionRateConfig{_unknown=$_json}" - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - - companion object { - - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - fun ofTiered(tiered: TieredConversionRateConfig) = - ConversionRateConfig(tiered = tiered) - } - - /** - * An interface that defines how to map each variant of [ConversionRateConfig] to a - * value of type [T]. - */ - interface Visitor { - - fun visitUnit(unit: UnitConversionRateConfig): T - - fun visitTiered(tiered: TieredConversionRateConfig): T - - /** - * Maps an unknown variant of [ConversionRateConfig] to a value of type [T]. - * - * An instance of [ConversionRateConfig] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if the - * SDK is on an older version than the API, then the API may respond with new - * variants that the SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown ConversionRateConfig: $json") - } - } - - internal class Deserializer : - BaseDeserializer(ConversionRateConfig::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): ConversionRateConfig { - val json = JsonValue.fromJsonNode(node) - val conversionRateType = - json.asObject()?.get("conversion_rate_type")?.asString() - - when (conversionRateType) { - "unit" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(unit = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - "tiered" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { ConversionRateConfig(tiered = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - } - - return ConversionRateConfig(_json = json) - } - } - - internal class Serializer : - BaseSerializer(ConversionRateConfig::class) { - - override fun serialize( - value: ConversionRateConfig, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unit != null -> generator.writeObject(value.unit) - value.tiered != null -> generator.writeObject(value.tiered) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - } - } - } - class CumulativeGroupedBulkConfig @JsonCreator private constructor( @@ -59097,180 +54225,6 @@ private constructor( override fun toString() = value.toString() } - @JsonDeserialize(using = ConversionRateConfig.Deserializer::class) - @JsonSerialize(using = ConversionRateConfig.Serializer::class) - class ConversionRateConfig - private constructor( - private val unit: UnitConversionRateConfig? = null, - private val tiered: TieredConversionRateConfig? = null, - private val _json: JsonValue? = null, - ) { - - fun unit(): UnitConversionRateConfig? = unit - - fun tiered(): TieredConversionRateConfig? = tiered - - fun isUnit(): Boolean = unit != null - - fun isTiered(): Boolean = tiered != null - - fun asUnit(): UnitConversionRateConfig = unit.getOrThrow("unit") - - fun asTiered(): TieredConversionRateConfig = tiered.getOrThrow("tiered") - - fun _json(): JsonValue? = _json - - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): ConversionRateConfig = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) { - unit.validate() - } - - override fun visitTiered(tiered: TieredConversionRateConfig) { - tiered.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) = unit.validity() - - override fun visitTiered(tiered: TieredConversionRateConfig) = - tiered.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ConversionRateConfig && unit == other.unit && tiered == other.tiered - } - - override fun hashCode(): Int = Objects.hash(unit, tiered) - - override fun toString(): String = - when { - unit != null -> "ConversionRateConfig{unit=$unit}" - tiered != null -> "ConversionRateConfig{tiered=$tiered}" - _json != null -> "ConversionRateConfig{_unknown=$_json}" - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - - companion object { - - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - fun ofTiered(tiered: TieredConversionRateConfig) = - ConversionRateConfig(tiered = tiered) - } - - /** - * An interface that defines how to map each variant of [ConversionRateConfig] to a - * value of type [T]. - */ - interface Visitor { - - fun visitUnit(unit: UnitConversionRateConfig): T - - fun visitTiered(tiered: TieredConversionRateConfig): T - - /** - * Maps an unknown variant of [ConversionRateConfig] to a value of type [T]. - * - * An instance of [ConversionRateConfig] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if the - * SDK is on an older version than the API, then the API may respond with new - * variants that the SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown ConversionRateConfig: $json") - } - } - - internal class Deserializer : - BaseDeserializer(ConversionRateConfig::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): ConversionRateConfig { - val json = JsonValue.fromJsonNode(node) - val conversionRateType = - json.asObject()?.get("conversion_rate_type")?.asString() - - when (conversionRateType) { - "unit" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ConversionRateConfig(unit = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - "tiered" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { ConversionRateConfig(tiered = it, _json = json) } - ?: ConversionRateConfig(_json = json) - } - } - - return ConversionRateConfig(_json = json) - } - } - - internal class Serializer : - BaseSerializer(ConversionRateConfig::class) { - - override fun serialize( - value: ConversionRateConfig, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unit != null -> generator.writeObject(value.unit) - value.tiered != null -> generator.writeObject(value.tiered) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ConversionRateConfig") - } - } - } - } - class GroupedWithMinMaxThresholdsConfig @JsonCreator private constructor( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/ConversionRateConfigTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/ConversionRateConfigTest.kt new file mode 100644 index 000000000..cd6b8912e --- /dev/null +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/ConversionRateConfigTest.kt @@ -0,0 +1,124 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.withorb.api.core.JsonValue +import com.withorb.api.core.jsonMapper +import com.withorb.api.errors.OrbInvalidDataException +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.assertThrows +import org.junit.jupiter.params.ParameterizedTest +import org.junit.jupiter.params.provider.EnumSource + +internal class ConversionRateConfigTest { + + @Test + fun ofUnit() { + val unit = + UnitConversionRateConfig.builder() + .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + .unitConfig(ConversionRateUnitConfig.builder().unitAmount("unit_amount").build()) + .build() + + val conversionRateConfig = ConversionRateConfig.ofUnit(unit) + + assertThat(conversionRateConfig.unit()).isEqualTo(unit) + assertThat(conversionRateConfig.tiered()).isNull() + } + + @Test + fun ofUnitRoundtrip() { + val jsonMapper = jsonMapper() + val conversionRateConfig = + ConversionRateConfig.ofUnit( + UnitConversionRateConfig.builder() + .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + .unitConfig( + ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() + ) + .build() + ) + + val roundtrippedConversionRateConfig = + jsonMapper.readValue( + jsonMapper.writeValueAsString(conversionRateConfig), + jacksonTypeRef(), + ) + + assertThat(roundtrippedConversionRateConfig).isEqualTo(conversionRateConfig) + } + + @Test + fun ofTiered() { + val tiered = + TieredConversionRateConfig.builder() + .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + .tieredConfig( + ConversionRateTieredConfig.builder() + .addTier( + ConversionRateTier.builder() + .firstUnit(0.0) + .unitAmount("unit_amount") + .lastUnit(0.0) + .build() + ) + .build() + ) + .build() + + val conversionRateConfig = ConversionRateConfig.ofTiered(tiered) + + assertThat(conversionRateConfig.unit()).isNull() + assertThat(conversionRateConfig.tiered()).isEqualTo(tiered) + } + + @Test + fun ofTieredRoundtrip() { + val jsonMapper = jsonMapper() + val conversionRateConfig = + ConversionRateConfig.ofTiered( + TieredConversionRateConfig.builder() + .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + .tieredConfig( + ConversionRateTieredConfig.builder() + .addTier( + ConversionRateTier.builder() + .firstUnit(0.0) + .unitAmount("unit_amount") + .lastUnit(0.0) + .build() + ) + .build() + ) + .build() + ) + + val roundtrippedConversionRateConfig = + jsonMapper.readValue( + jsonMapper.writeValueAsString(conversionRateConfig), + jacksonTypeRef(), + ) + + assertThat(roundtrippedConversionRateConfig).isEqualTo(conversionRateConfig) + } + + enum class IncompatibleJsonShapeTestCase(val value: JsonValue) { + BOOLEAN(JsonValue.from(false)), + STRING(JsonValue.from("invalid")), + INTEGER(JsonValue.from(-1)), + FLOAT(JsonValue.from(3.14)), + ARRAY(JsonValue.from(listOf("invalid", "array"))), + } + + @ParameterizedTest + @EnumSource + fun incompatibleJsonShapeDeserializesToUnknown(testCase: IncompatibleJsonShapeTestCase) { + val conversionRateConfig = + jsonMapper().convertValue(testCase.value, jacksonTypeRef()) + + val e = assertThrows { conversionRateConfig.validate() } + assertThat(e).hasMessageStartingWith("Unknown ") + } +} diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingBpsPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingBpsPriceTest.kt index 402181b76..2bb24ae85 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingBpsPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingBpsPriceTest.kt @@ -74,7 +74,7 @@ internal class NewFloatingBpsPriceTest { assertThat(newFloatingBpsPrice.conversionRate()).isEqualTo(0.0) assertThat(newFloatingBpsPrice.conversionRateConfig()) .isEqualTo( - NewFloatingBpsPrice.ConversionRateConfig.ofUnit( + ConversionRateConfig.ofUnit( UnitConversionRateConfig.builder() .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) .unitConfig( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingBulkBpsPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingBulkBpsPriceTest.kt index 2a1e26faf..357688377 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingBulkBpsPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingBulkBpsPriceTest.kt @@ -96,7 +96,7 @@ internal class NewFloatingBulkBpsPriceTest { assertThat(newFloatingBulkBpsPrice.conversionRate()).isEqualTo(0.0) assertThat(newFloatingBulkBpsPrice.conversionRateConfig()) .isEqualTo( - NewFloatingBulkBpsPrice.ConversionRateConfig.ofUnit( + ConversionRateConfig.ofUnit( UnitConversionRateConfig.builder() .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) .unitConfig( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingBulkPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingBulkPriceTest.kt index 62455b517..f5e6f0403 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingBulkPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingBulkPriceTest.kt @@ -84,7 +84,7 @@ internal class NewFloatingBulkPriceTest { assertThat(newFloatingBulkPrice.conversionRate()).isEqualTo(0.0) assertThat(newFloatingBulkPrice.conversionRateConfig()) .isEqualTo( - NewFloatingBulkPrice.ConversionRateConfig.ofUnit( + ConversionRateConfig.ofUnit( UnitConversionRateConfig.builder() .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) .unitConfig( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingBulkWithProrationPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingBulkWithProrationPriceTest.kt index 4e63b73b5..fcae04997 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingBulkWithProrationPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingBulkWithProrationPriceTest.kt @@ -85,7 +85,7 @@ internal class NewFloatingBulkWithProrationPriceTest { assertThat(newFloatingBulkWithProrationPrice.conversionRate()).isEqualTo(0.0) assertThat(newFloatingBulkWithProrationPrice.conversionRateConfig()) .isEqualTo( - NewFloatingBulkWithProrationPrice.ConversionRateConfig.ofUnit( + ConversionRateConfig.ofUnit( UnitConversionRateConfig.builder() .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) .unitConfig( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingCumulativeGroupedBulkPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingCumulativeGroupedBulkPriceTest.kt index ba7b242cc..b62bbfe86 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingCumulativeGroupedBulkPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingCumulativeGroupedBulkPriceTest.kt @@ -85,7 +85,7 @@ internal class NewFloatingCumulativeGroupedBulkPriceTest { assertThat(newFloatingCumulativeGroupedBulkPrice.conversionRate()).isEqualTo(0.0) assertThat(newFloatingCumulativeGroupedBulkPrice.conversionRateConfig()) .isEqualTo( - NewFloatingCumulativeGroupedBulkPrice.ConversionRateConfig.ofUnit( + ConversionRateConfig.ofUnit( UnitConversionRateConfig.builder() .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) .unitConfig( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingGroupedAllocationPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingGroupedAllocationPriceTest.kt index 268c406ad..ddfc001a7 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingGroupedAllocationPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingGroupedAllocationPriceTest.kt @@ -85,7 +85,7 @@ internal class NewFloatingGroupedAllocationPriceTest { assertThat(newFloatingGroupedAllocationPrice.conversionRate()).isEqualTo(0.0) assertThat(newFloatingGroupedAllocationPrice.conversionRateConfig()) .isEqualTo( - NewFloatingGroupedAllocationPrice.ConversionRateConfig.ofUnit( + ConversionRateConfig.ofUnit( UnitConversionRateConfig.builder() .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) .unitConfig( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingGroupedTieredPackagePriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingGroupedTieredPackagePriceTest.kt index 38ff8f11f..d72265739 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingGroupedTieredPackagePriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingGroupedTieredPackagePriceTest.kt @@ -85,7 +85,7 @@ internal class NewFloatingGroupedTieredPackagePriceTest { assertThat(newFloatingGroupedTieredPackagePrice.conversionRate()).isEqualTo(0.0) assertThat(newFloatingGroupedTieredPackagePrice.conversionRateConfig()) .isEqualTo( - NewFloatingGroupedTieredPackagePrice.ConversionRateConfig.ofUnit( + ConversionRateConfig.ofUnit( UnitConversionRateConfig.builder() .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) .unitConfig( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingGroupedTieredPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingGroupedTieredPriceTest.kt index bfa46363a..5bf01cc90 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingGroupedTieredPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingGroupedTieredPriceTest.kt @@ -84,7 +84,7 @@ internal class NewFloatingGroupedTieredPriceTest { assertThat(newFloatingGroupedTieredPrice.conversionRate()).isEqualTo(0.0) assertThat(newFloatingGroupedTieredPrice.conversionRateConfig()) .isEqualTo( - NewFloatingGroupedTieredPrice.ConversionRateConfig.ofUnit( + ConversionRateConfig.ofUnit( UnitConversionRateConfig.builder() .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) .unitConfig( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingGroupedWithMeteredMinimumPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingGroupedWithMeteredMinimumPriceTest.kt index 8fe4853f4..43b4ebb13 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingGroupedWithMeteredMinimumPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingGroupedWithMeteredMinimumPriceTest.kt @@ -90,7 +90,7 @@ internal class NewFloatingGroupedWithMeteredMinimumPriceTest { assertThat(newFloatingGroupedWithMeteredMinimumPrice.conversionRate()).isEqualTo(0.0) assertThat(newFloatingGroupedWithMeteredMinimumPrice.conversionRateConfig()) .isEqualTo( - NewFloatingGroupedWithMeteredMinimumPrice.ConversionRateConfig.ofUnit( + ConversionRateConfig.ofUnit( UnitConversionRateConfig.builder() .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) .unitConfig( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingGroupedWithProratedMinimumPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingGroupedWithProratedMinimumPriceTest.kt index beecb65bd..80baa9fa2 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingGroupedWithProratedMinimumPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingGroupedWithProratedMinimumPriceTest.kt @@ -92,7 +92,7 @@ internal class NewFloatingGroupedWithProratedMinimumPriceTest { assertThat(newFloatingGroupedWithProratedMinimumPrice.conversionRate()).isEqualTo(0.0) assertThat(newFloatingGroupedWithProratedMinimumPrice.conversionRateConfig()) .isEqualTo( - NewFloatingGroupedWithProratedMinimumPrice.ConversionRateConfig.ofUnit( + ConversionRateConfig.ofUnit( UnitConversionRateConfig.builder() .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) .unitConfig( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingMatrixPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingMatrixPriceTest.kt index 0c105fd7d..c0acf01a6 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingMatrixPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingMatrixPriceTest.kt @@ -98,7 +98,7 @@ internal class NewFloatingMatrixPriceTest { assertThat(newFloatingMatrixPrice.conversionRate()).isEqualTo(0.0) assertThat(newFloatingMatrixPrice.conversionRateConfig()) .isEqualTo( - NewFloatingMatrixPrice.ConversionRateConfig.ofUnit( + ConversionRateConfig.ofUnit( UnitConversionRateConfig.builder() .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) .unitConfig( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingMatrixWithAllocationPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingMatrixWithAllocationPriceTest.kt index 8e30b3be0..1fc48df96 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingMatrixWithAllocationPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingMatrixWithAllocationPriceTest.kt @@ -101,7 +101,7 @@ internal class NewFloatingMatrixWithAllocationPriceTest { assertThat(newFloatingMatrixWithAllocationPrice.conversionRate()).isEqualTo(0.0) assertThat(newFloatingMatrixWithAllocationPrice.conversionRateConfig()) .isEqualTo( - NewFloatingMatrixWithAllocationPrice.ConversionRateConfig.ofUnit( + ConversionRateConfig.ofUnit( UnitConversionRateConfig.builder() .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) .unitConfig( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingMatrixWithDisplayNamePriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingMatrixWithDisplayNamePriceTest.kt index 622a93f47..3a87f45b3 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingMatrixWithDisplayNamePriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingMatrixWithDisplayNamePriceTest.kt @@ -85,7 +85,7 @@ internal class NewFloatingMatrixWithDisplayNamePriceTest { assertThat(newFloatingMatrixWithDisplayNamePrice.conversionRate()).isEqualTo(0.0) assertThat(newFloatingMatrixWithDisplayNamePrice.conversionRateConfig()) .isEqualTo( - NewFloatingMatrixWithDisplayNamePrice.ConversionRateConfig.ofUnit( + ConversionRateConfig.ofUnit( UnitConversionRateConfig.builder() .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) .unitConfig( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingMaxGroupTieredPackagePriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingMaxGroupTieredPackagePriceTest.kt index c3cef3cba..4842737b8 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingMaxGroupTieredPackagePriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingMaxGroupTieredPackagePriceTest.kt @@ -85,7 +85,7 @@ internal class NewFloatingMaxGroupTieredPackagePriceTest { assertThat(newFloatingMaxGroupTieredPackagePrice.conversionRate()).isEqualTo(0.0) assertThat(newFloatingMaxGroupTieredPackagePrice.conversionRateConfig()) .isEqualTo( - NewFloatingMaxGroupTieredPackagePrice.ConversionRateConfig.ofUnit( + ConversionRateConfig.ofUnit( UnitConversionRateConfig.builder() .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) .unitConfig( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingPackagePriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingPackagePriceTest.kt index 0f5972689..fb0a6dcad 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingPackagePriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingPackagePriceTest.kt @@ -80,7 +80,7 @@ internal class NewFloatingPackagePriceTest { assertThat(newFloatingPackagePrice.conversionRate()).isEqualTo(0.0) assertThat(newFloatingPackagePrice.conversionRateConfig()) .isEqualTo( - NewFloatingPackagePrice.ConversionRateConfig.ofUnit( + ConversionRateConfig.ofUnit( UnitConversionRateConfig.builder() .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) .unitConfig( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingPackageWithAllocationPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingPackageWithAllocationPriceTest.kt index 0dbd1ccbc..90a5dd2c2 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingPackageWithAllocationPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingPackageWithAllocationPriceTest.kt @@ -85,7 +85,7 @@ internal class NewFloatingPackageWithAllocationPriceTest { assertThat(newFloatingPackageWithAllocationPrice.conversionRate()).isEqualTo(0.0) assertThat(newFloatingPackageWithAllocationPrice.conversionRateConfig()) .isEqualTo( - NewFloatingPackageWithAllocationPrice.ConversionRateConfig.ofUnit( + ConversionRateConfig.ofUnit( UnitConversionRateConfig.builder() .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) .unitConfig( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingScalableMatrixWithTieredPricingPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingScalableMatrixWithTieredPricingPriceTest.kt index dddcaca46..0dee6df5e 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingScalableMatrixWithTieredPricingPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingScalableMatrixWithTieredPricingPriceTest.kt @@ -99,7 +99,7 @@ internal class NewFloatingScalableMatrixWithTieredPricingPriceTest { assertThat(newFloatingScalableMatrixWithTieredPricingPrice.conversionRate()).isEqualTo(0.0) assertThat(newFloatingScalableMatrixWithTieredPricingPrice.conversionRateConfig()) .isEqualTo( - NewFloatingScalableMatrixWithTieredPricingPrice.ConversionRateConfig.ofUnit( + ConversionRateConfig.ofUnit( UnitConversionRateConfig.builder() .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) .unitConfig( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingScalableMatrixWithUnitPricingPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingScalableMatrixWithUnitPricingPriceTest.kt index 5b4615121..6bfe37e36 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingScalableMatrixWithUnitPricingPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingScalableMatrixWithUnitPricingPriceTest.kt @@ -96,7 +96,7 @@ internal class NewFloatingScalableMatrixWithUnitPricingPriceTest { assertThat(newFloatingScalableMatrixWithUnitPricingPrice.conversionRate()).isEqualTo(0.0) assertThat(newFloatingScalableMatrixWithUnitPricingPrice.conversionRateConfig()) .isEqualTo( - NewFloatingScalableMatrixWithUnitPricingPrice.ConversionRateConfig.ofUnit( + ConversionRateConfig.ofUnit( UnitConversionRateConfig.builder() .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) .unitConfig( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingThresholdTotalAmountPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingThresholdTotalAmountPriceTest.kt index 19391f580..67dc54605 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingThresholdTotalAmountPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingThresholdTotalAmountPriceTest.kt @@ -85,7 +85,7 @@ internal class NewFloatingThresholdTotalAmountPriceTest { assertThat(newFloatingThresholdTotalAmountPrice.conversionRate()).isEqualTo(0.0) assertThat(newFloatingThresholdTotalAmountPrice.conversionRateConfig()) .isEqualTo( - NewFloatingThresholdTotalAmountPrice.ConversionRateConfig.ofUnit( + ConversionRateConfig.ofUnit( UnitConversionRateConfig.builder() .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) .unitConfig( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingTieredBpsPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingTieredBpsPriceTest.kt index d4c737c4b..3f70d6b05 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingTieredBpsPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingTieredBpsPriceTest.kt @@ -98,7 +98,7 @@ internal class NewFloatingTieredBpsPriceTest { assertThat(newFloatingTieredBpsPrice.conversionRate()).isEqualTo(0.0) assertThat(newFloatingTieredBpsPrice.conversionRateConfig()) .isEqualTo( - NewFloatingTieredBpsPrice.ConversionRateConfig.ofUnit( + ConversionRateConfig.ofUnit( UnitConversionRateConfig.builder() .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) .unitConfig( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingTieredPackagePriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingTieredPackagePriceTest.kt index 831424b33..e9c8fc8ee 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingTieredPackagePriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingTieredPackagePriceTest.kt @@ -84,7 +84,7 @@ internal class NewFloatingTieredPackagePriceTest { assertThat(newFloatingTieredPackagePrice.conversionRate()).isEqualTo(0.0) assertThat(newFloatingTieredPackagePrice.conversionRateConfig()) .isEqualTo( - NewFloatingTieredPackagePrice.ConversionRateConfig.ofUnit( + ConversionRateConfig.ofUnit( UnitConversionRateConfig.builder() .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) .unitConfig( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingTieredPackageWithMinimumPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingTieredPackageWithMinimumPriceTest.kt index 8499014e2..d687100a0 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingTieredPackageWithMinimumPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingTieredPackageWithMinimumPriceTest.kt @@ -90,7 +90,7 @@ internal class NewFloatingTieredPackageWithMinimumPriceTest { assertThat(newFloatingTieredPackageWithMinimumPrice.conversionRate()).isEqualTo(0.0) assertThat(newFloatingTieredPackageWithMinimumPrice.conversionRateConfig()) .isEqualTo( - NewFloatingTieredPackageWithMinimumPrice.ConversionRateConfig.ofUnit( + ConversionRateConfig.ofUnit( UnitConversionRateConfig.builder() .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) .unitConfig( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingTieredPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingTieredPriceTest.kt index 0ed7ba70f..7f537d1c5 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingTieredPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingTieredPriceTest.kt @@ -96,7 +96,7 @@ internal class NewFloatingTieredPriceTest { assertThat(newFloatingTieredPrice.conversionRate()).isEqualTo(0.0) assertThat(newFloatingTieredPrice.conversionRateConfig()) .isEqualTo( - NewFloatingTieredPrice.ConversionRateConfig.ofUnit( + ConversionRateConfig.ofUnit( UnitConversionRateConfig.builder() .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) .unitConfig( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingTieredWithMinimumPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingTieredWithMinimumPriceTest.kt index 5a52045cd..26fba3368 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingTieredWithMinimumPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingTieredWithMinimumPriceTest.kt @@ -85,7 +85,7 @@ internal class NewFloatingTieredWithMinimumPriceTest { assertThat(newFloatingTieredWithMinimumPrice.conversionRate()).isEqualTo(0.0) assertThat(newFloatingTieredWithMinimumPrice.conversionRateConfig()) .isEqualTo( - NewFloatingTieredWithMinimumPrice.ConversionRateConfig.ofUnit( + ConversionRateConfig.ofUnit( UnitConversionRateConfig.builder() .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) .unitConfig( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingTieredWithProrationPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingTieredWithProrationPriceTest.kt index 9bebd954b..f251344a1 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingTieredWithProrationPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingTieredWithProrationPriceTest.kt @@ -85,7 +85,7 @@ internal class NewFloatingTieredWithProrationPriceTest { assertThat(newFloatingTieredWithProrationPrice.conversionRate()).isEqualTo(0.0) assertThat(newFloatingTieredWithProrationPrice.conversionRateConfig()) .isEqualTo( - NewFloatingTieredWithProrationPrice.ConversionRateConfig.ofUnit( + ConversionRateConfig.ofUnit( UnitConversionRateConfig.builder() .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) .unitConfig( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingUnitPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingUnitPriceTest.kt index d6bd5c35e..e5ecea168 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingUnitPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingUnitPriceTest.kt @@ -74,7 +74,7 @@ internal class NewFloatingUnitPriceTest { assertThat(newFloatingUnitPrice.conversionRate()).isEqualTo(0.0) assertThat(newFloatingUnitPrice.conversionRateConfig()) .isEqualTo( - NewFloatingUnitPrice.ConversionRateConfig.ofUnit( + ConversionRateConfig.ofUnit( UnitConversionRateConfig.builder() .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) .unitConfig( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingUnitWithPercentPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingUnitWithPercentPriceTest.kt index 754a70b63..a7ce0b825 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingUnitWithPercentPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingUnitWithPercentPriceTest.kt @@ -85,7 +85,7 @@ internal class NewFloatingUnitWithPercentPriceTest { assertThat(newFloatingUnitWithPercentPrice.conversionRate()).isEqualTo(0.0) assertThat(newFloatingUnitWithPercentPrice.conversionRateConfig()) .isEqualTo( - NewFloatingUnitWithPercentPrice.ConversionRateConfig.ofUnit( + ConversionRateConfig.ofUnit( UnitConversionRateConfig.builder() .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) .unitConfig( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingUnitWithProrationPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingUnitWithProrationPriceTest.kt index 9f8934888..77e29580c 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingUnitWithProrationPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingUnitWithProrationPriceTest.kt @@ -85,7 +85,7 @@ internal class NewFloatingUnitWithProrationPriceTest { assertThat(newFloatingUnitWithProrationPrice.conversionRate()).isEqualTo(0.0) assertThat(newFloatingUnitWithProrationPrice.conversionRateConfig()) .isEqualTo( - NewFloatingUnitWithProrationPrice.ConversionRateConfig.ofUnit( + ConversionRateConfig.ofUnit( UnitConversionRateConfig.builder() .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) .unitConfig( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanBpsPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanBpsPriceTest.kt index 3a93cf0f9..b62038621 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanBpsPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanBpsPriceTest.kt @@ -74,7 +74,7 @@ internal class NewPlanBpsPriceTest { assertThat(newPlanBpsPrice.conversionRate()).isEqualTo(0.0) assertThat(newPlanBpsPrice.conversionRateConfig()) .isEqualTo( - NewPlanBpsPrice.ConversionRateConfig.ofUnit( + ConversionRateConfig.ofUnit( UnitConversionRateConfig.builder() .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) .unitConfig( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanBulkBpsPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanBulkBpsPriceTest.kt index 4be6b39eb..960f6e487 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanBulkBpsPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanBulkBpsPriceTest.kt @@ -95,7 +95,7 @@ internal class NewPlanBulkBpsPriceTest { assertThat(newPlanBulkBpsPrice.conversionRate()).isEqualTo(0.0) assertThat(newPlanBulkBpsPrice.conversionRateConfig()) .isEqualTo( - NewPlanBulkBpsPrice.ConversionRateConfig.ofUnit( + ConversionRateConfig.ofUnit( UnitConversionRateConfig.builder() .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) .unitConfig( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanBulkPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanBulkPriceTest.kt index ec0255a00..0157cd364 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanBulkPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanBulkPriceTest.kt @@ -84,7 +84,7 @@ internal class NewPlanBulkPriceTest { assertThat(newPlanBulkPrice.conversionRate()).isEqualTo(0.0) assertThat(newPlanBulkPrice.conversionRateConfig()) .isEqualTo( - NewPlanBulkPrice.ConversionRateConfig.ofUnit( + ConversionRateConfig.ofUnit( UnitConversionRateConfig.builder() .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) .unitConfig( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanBulkWithProrationPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanBulkWithProrationPriceTest.kt index 5c1ebdcde..e1eb61503 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanBulkWithProrationPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanBulkWithProrationPriceTest.kt @@ -84,7 +84,7 @@ internal class NewPlanBulkWithProrationPriceTest { assertThat(newPlanBulkWithProrationPrice.conversionRate()).isEqualTo(0.0) assertThat(newPlanBulkWithProrationPrice.conversionRateConfig()) .isEqualTo( - NewPlanBulkWithProrationPrice.ConversionRateConfig.ofUnit( + ConversionRateConfig.ofUnit( UnitConversionRateConfig.builder() .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) .unitConfig( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanCumulativeGroupedBulkPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanCumulativeGroupedBulkPriceTest.kt index 7f43ec232..1e4b0cfa8 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanCumulativeGroupedBulkPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanCumulativeGroupedBulkPriceTest.kt @@ -85,7 +85,7 @@ internal class NewPlanCumulativeGroupedBulkPriceTest { assertThat(newPlanCumulativeGroupedBulkPrice.conversionRate()).isEqualTo(0.0) assertThat(newPlanCumulativeGroupedBulkPrice.conversionRateConfig()) .isEqualTo( - NewPlanCumulativeGroupedBulkPrice.ConversionRateConfig.ofUnit( + ConversionRateConfig.ofUnit( UnitConversionRateConfig.builder() .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) .unitConfig( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanGroupedAllocationPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanGroupedAllocationPriceTest.kt index 00c1fff8d..24a383615 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanGroupedAllocationPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanGroupedAllocationPriceTest.kt @@ -84,7 +84,7 @@ internal class NewPlanGroupedAllocationPriceTest { assertThat(newPlanGroupedAllocationPrice.conversionRate()).isEqualTo(0.0) assertThat(newPlanGroupedAllocationPrice.conversionRateConfig()) .isEqualTo( - NewPlanGroupedAllocationPrice.ConversionRateConfig.ofUnit( + ConversionRateConfig.ofUnit( UnitConversionRateConfig.builder() .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) .unitConfig( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanGroupedTieredPackagePriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanGroupedTieredPackagePriceTest.kt index d47d0e64e..a51b98f34 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanGroupedTieredPackagePriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanGroupedTieredPackagePriceTest.kt @@ -85,7 +85,7 @@ internal class NewPlanGroupedTieredPackagePriceTest { assertThat(newPlanGroupedTieredPackagePrice.conversionRate()).isEqualTo(0.0) assertThat(newPlanGroupedTieredPackagePrice.conversionRateConfig()) .isEqualTo( - NewPlanGroupedTieredPackagePrice.ConversionRateConfig.ofUnit( + ConversionRateConfig.ofUnit( UnitConversionRateConfig.builder() .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) .unitConfig( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanGroupedTieredPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanGroupedTieredPriceTest.kt index afb68b4b3..8e512fffe 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanGroupedTieredPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanGroupedTieredPriceTest.kt @@ -84,7 +84,7 @@ internal class NewPlanGroupedTieredPriceTest { assertThat(newPlanGroupedTieredPrice.conversionRate()).isEqualTo(0.0) assertThat(newPlanGroupedTieredPrice.conversionRateConfig()) .isEqualTo( - NewPlanGroupedTieredPrice.ConversionRateConfig.ofUnit( + ConversionRateConfig.ofUnit( UnitConversionRateConfig.builder() .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) .unitConfig( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanGroupedWithMeteredMinimumPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanGroupedWithMeteredMinimumPriceTest.kt index 188173c72..450e7b9a8 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanGroupedWithMeteredMinimumPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanGroupedWithMeteredMinimumPriceTest.kt @@ -87,7 +87,7 @@ internal class NewPlanGroupedWithMeteredMinimumPriceTest { assertThat(newPlanGroupedWithMeteredMinimumPrice.conversionRate()).isEqualTo(0.0) assertThat(newPlanGroupedWithMeteredMinimumPrice.conversionRateConfig()) .isEqualTo( - NewPlanGroupedWithMeteredMinimumPrice.ConversionRateConfig.ofUnit( + ConversionRateConfig.ofUnit( UnitConversionRateConfig.builder() .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) .unitConfig( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanGroupedWithProratedMinimumPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanGroupedWithProratedMinimumPriceTest.kt index 16cf684c3..e36cfcbb2 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanGroupedWithProratedMinimumPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanGroupedWithProratedMinimumPriceTest.kt @@ -90,7 +90,7 @@ internal class NewPlanGroupedWithProratedMinimumPriceTest { assertThat(newPlanGroupedWithProratedMinimumPrice.conversionRate()).isEqualTo(0.0) assertThat(newPlanGroupedWithProratedMinimumPrice.conversionRateConfig()) .isEqualTo( - NewPlanGroupedWithProratedMinimumPrice.ConversionRateConfig.ofUnit( + ConversionRateConfig.ofUnit( UnitConversionRateConfig.builder() .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) .unitConfig( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanMatrixPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanMatrixPriceTest.kt index a297dc9ca..19ac3b71e 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanMatrixPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanMatrixPriceTest.kt @@ -96,7 +96,7 @@ internal class NewPlanMatrixPriceTest { assertThat(newPlanMatrixPrice.conversionRate()).isEqualTo(0.0) assertThat(newPlanMatrixPrice.conversionRateConfig()) .isEqualTo( - NewPlanMatrixPrice.ConversionRateConfig.ofUnit( + ConversionRateConfig.ofUnit( UnitConversionRateConfig.builder() .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) .unitConfig( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanMatrixWithAllocationPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanMatrixWithAllocationPriceTest.kt index 039250405..e31012642 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanMatrixWithAllocationPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanMatrixWithAllocationPriceTest.kt @@ -101,7 +101,7 @@ internal class NewPlanMatrixWithAllocationPriceTest { assertThat(newPlanMatrixWithAllocationPrice.conversionRate()).isEqualTo(0.0) assertThat(newPlanMatrixWithAllocationPrice.conversionRateConfig()) .isEqualTo( - NewPlanMatrixWithAllocationPrice.ConversionRateConfig.ofUnit( + ConversionRateConfig.ofUnit( UnitConversionRateConfig.builder() .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) .unitConfig( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanMatrixWithDisplayNamePriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanMatrixWithDisplayNamePriceTest.kt index abeb70f32..310d40633 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanMatrixWithDisplayNamePriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanMatrixWithDisplayNamePriceTest.kt @@ -85,7 +85,7 @@ internal class NewPlanMatrixWithDisplayNamePriceTest { assertThat(newPlanMatrixWithDisplayNamePrice.conversionRate()).isEqualTo(0.0) assertThat(newPlanMatrixWithDisplayNamePrice.conversionRateConfig()) .isEqualTo( - NewPlanMatrixWithDisplayNamePrice.ConversionRateConfig.ofUnit( + ConversionRateConfig.ofUnit( UnitConversionRateConfig.builder() .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) .unitConfig( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanMaxGroupTieredPackagePriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanMaxGroupTieredPackagePriceTest.kt index f2c577f5f..a4adeec7c 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanMaxGroupTieredPackagePriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanMaxGroupTieredPackagePriceTest.kt @@ -85,7 +85,7 @@ internal class NewPlanMaxGroupTieredPackagePriceTest { assertThat(newPlanMaxGroupTieredPackagePrice.conversionRate()).isEqualTo(0.0) assertThat(newPlanMaxGroupTieredPackagePrice.conversionRateConfig()) .isEqualTo( - NewPlanMaxGroupTieredPackagePrice.ConversionRateConfig.ofUnit( + ConversionRateConfig.ofUnit( UnitConversionRateConfig.builder() .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) .unitConfig( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanPackagePriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanPackagePriceTest.kt index bd18e0007..a2d8d797c 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanPackagePriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanPackagePriceTest.kt @@ -78,7 +78,7 @@ internal class NewPlanPackagePriceTest { assertThat(newPlanPackagePrice.conversionRate()).isEqualTo(0.0) assertThat(newPlanPackagePrice.conversionRateConfig()) .isEqualTo( - NewPlanPackagePrice.ConversionRateConfig.ofUnit( + ConversionRateConfig.ofUnit( UnitConversionRateConfig.builder() .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) .unitConfig( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanPackageWithAllocationPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanPackageWithAllocationPriceTest.kt index d296806fe..df2ec42bf 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanPackageWithAllocationPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanPackageWithAllocationPriceTest.kt @@ -85,7 +85,7 @@ internal class NewPlanPackageWithAllocationPriceTest { assertThat(newPlanPackageWithAllocationPrice.conversionRate()).isEqualTo(0.0) assertThat(newPlanPackageWithAllocationPrice.conversionRateConfig()) .isEqualTo( - NewPlanPackageWithAllocationPrice.ConversionRateConfig.ofUnit( + ConversionRateConfig.ofUnit( UnitConversionRateConfig.builder() .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) .unitConfig( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanScalableMatrixWithTieredPricingPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanScalableMatrixWithTieredPricingPriceTest.kt index a31a1007f..005a88a70 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanScalableMatrixWithTieredPricingPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanScalableMatrixWithTieredPricingPriceTest.kt @@ -96,7 +96,7 @@ internal class NewPlanScalableMatrixWithTieredPricingPriceTest { assertThat(newPlanScalableMatrixWithTieredPricingPrice.conversionRate()).isEqualTo(0.0) assertThat(newPlanScalableMatrixWithTieredPricingPrice.conversionRateConfig()) .isEqualTo( - NewPlanScalableMatrixWithTieredPricingPrice.ConversionRateConfig.ofUnit( + ConversionRateConfig.ofUnit( UnitConversionRateConfig.builder() .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) .unitConfig( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanScalableMatrixWithUnitPricingPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanScalableMatrixWithUnitPricingPriceTest.kt index e7df79b43..a91769877 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanScalableMatrixWithUnitPricingPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanScalableMatrixWithUnitPricingPriceTest.kt @@ -93,7 +93,7 @@ internal class NewPlanScalableMatrixWithUnitPricingPriceTest { assertThat(newPlanScalableMatrixWithUnitPricingPrice.conversionRate()).isEqualTo(0.0) assertThat(newPlanScalableMatrixWithUnitPricingPrice.conversionRateConfig()) .isEqualTo( - NewPlanScalableMatrixWithUnitPricingPrice.ConversionRateConfig.ofUnit( + ConversionRateConfig.ofUnit( UnitConversionRateConfig.builder() .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) .unitConfig( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanThresholdTotalAmountPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanThresholdTotalAmountPriceTest.kt index 112d43a25..50ae1807f 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanThresholdTotalAmountPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanThresholdTotalAmountPriceTest.kt @@ -85,7 +85,7 @@ internal class NewPlanThresholdTotalAmountPriceTest { assertThat(newPlanThresholdTotalAmountPrice.conversionRate()).isEqualTo(0.0) assertThat(newPlanThresholdTotalAmountPrice.conversionRateConfig()) .isEqualTo( - NewPlanThresholdTotalAmountPrice.ConversionRateConfig.ofUnit( + ConversionRateConfig.ofUnit( UnitConversionRateConfig.builder() .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) .unitConfig( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanTierWithProrationPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanTierWithProrationPriceTest.kt index 7afcceec8..99ad6c06d 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanTierWithProrationPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanTierWithProrationPriceTest.kt @@ -84,7 +84,7 @@ internal class NewPlanTierWithProrationPriceTest { assertThat(newPlanTierWithProrationPrice.conversionRate()).isEqualTo(0.0) assertThat(newPlanTierWithProrationPrice.conversionRateConfig()) .isEqualTo( - NewPlanTierWithProrationPrice.ConversionRateConfig.ofUnit( + ConversionRateConfig.ofUnit( UnitConversionRateConfig.builder() .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) .unitConfig( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanTieredBpsPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanTieredBpsPriceTest.kt index 8b1b16fa9..e395f40dd 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanTieredBpsPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanTieredBpsPriceTest.kt @@ -97,7 +97,7 @@ internal class NewPlanTieredBpsPriceTest { assertThat(newPlanTieredBpsPrice.conversionRate()).isEqualTo(0.0) assertThat(newPlanTieredBpsPrice.conversionRateConfig()) .isEqualTo( - NewPlanTieredBpsPrice.ConversionRateConfig.ofUnit( + ConversionRateConfig.ofUnit( UnitConversionRateConfig.builder() .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) .unitConfig( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanTieredPackagePriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanTieredPackagePriceTest.kt index 0fe80bd26..8afa74012 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanTieredPackagePriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanTieredPackagePriceTest.kt @@ -84,7 +84,7 @@ internal class NewPlanTieredPackagePriceTest { assertThat(newPlanTieredPackagePrice.conversionRate()).isEqualTo(0.0) assertThat(newPlanTieredPackagePrice.conversionRateConfig()) .isEqualTo( - NewPlanTieredPackagePrice.ConversionRateConfig.ofUnit( + ConversionRateConfig.ofUnit( UnitConversionRateConfig.builder() .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) .unitConfig( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanTieredPackageWithMinimumPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanTieredPackageWithMinimumPriceTest.kt index 7e2402b67..31154f1f0 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanTieredPackageWithMinimumPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanTieredPackageWithMinimumPriceTest.kt @@ -87,7 +87,7 @@ internal class NewPlanTieredPackageWithMinimumPriceTest { assertThat(newPlanTieredPackageWithMinimumPrice.conversionRate()).isEqualTo(0.0) assertThat(newPlanTieredPackageWithMinimumPrice.conversionRateConfig()) .isEqualTo( - NewPlanTieredPackageWithMinimumPrice.ConversionRateConfig.ofUnit( + ConversionRateConfig.ofUnit( UnitConversionRateConfig.builder() .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) .unitConfig( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanTieredPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanTieredPriceTest.kt index a11adcc5b..f734797fc 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanTieredPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanTieredPriceTest.kt @@ -94,7 +94,7 @@ internal class NewPlanTieredPriceTest { assertThat(newPlanTieredPrice.conversionRate()).isEqualTo(0.0) assertThat(newPlanTieredPrice.conversionRateConfig()) .isEqualTo( - NewPlanTieredPrice.ConversionRateConfig.ofUnit( + ConversionRateConfig.ofUnit( UnitConversionRateConfig.builder() .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) .unitConfig( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanTieredWithMinimumPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanTieredWithMinimumPriceTest.kt index d02a76ed5..03317d225 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanTieredWithMinimumPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanTieredWithMinimumPriceTest.kt @@ -84,7 +84,7 @@ internal class NewPlanTieredWithMinimumPriceTest { assertThat(newPlanTieredWithMinimumPrice.conversionRate()).isEqualTo(0.0) assertThat(newPlanTieredWithMinimumPrice.conversionRateConfig()) .isEqualTo( - NewPlanTieredWithMinimumPrice.ConversionRateConfig.ofUnit( + ConversionRateConfig.ofUnit( UnitConversionRateConfig.builder() .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) .unitConfig( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanUnitPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanUnitPriceTest.kt index acd68b19c..ba6443d6a 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanUnitPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanUnitPriceTest.kt @@ -74,7 +74,7 @@ internal class NewPlanUnitPriceTest { assertThat(newPlanUnitPrice.conversionRate()).isEqualTo(0.0) assertThat(newPlanUnitPrice.conversionRateConfig()) .isEqualTo( - NewPlanUnitPrice.ConversionRateConfig.ofUnit( + ConversionRateConfig.ofUnit( UnitConversionRateConfig.builder() .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) .unitConfig( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanUnitWithPercentPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanUnitWithPercentPriceTest.kt index e63af8296..2af2acfb9 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanUnitWithPercentPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanUnitWithPercentPriceTest.kt @@ -84,7 +84,7 @@ internal class NewPlanUnitWithPercentPriceTest { assertThat(newPlanUnitWithPercentPrice.conversionRate()).isEqualTo(0.0) assertThat(newPlanUnitWithPercentPrice.conversionRateConfig()) .isEqualTo( - NewPlanUnitWithPercentPrice.ConversionRateConfig.ofUnit( + ConversionRateConfig.ofUnit( UnitConversionRateConfig.builder() .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) .unitConfig( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanUnitWithProrationPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanUnitWithProrationPriceTest.kt index da5b14d78..1f018915c 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanUnitWithProrationPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanUnitWithProrationPriceTest.kt @@ -84,7 +84,7 @@ internal class NewPlanUnitWithProrationPriceTest { assertThat(newPlanUnitWithProrationPrice.conversionRate()).isEqualTo(0.0) assertThat(newPlanUnitWithProrationPrice.conversionRateConfig()) .isEqualTo( - NewPlanUnitWithProrationPrice.ConversionRateConfig.ofUnit( + ConversionRateConfig.ofUnit( UnitConversionRateConfig.builder() .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) .unitConfig( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionBpsPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionBpsPriceTest.kt index 52bd33636..052414ec2 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionBpsPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionBpsPriceTest.kt @@ -76,7 +76,7 @@ internal class NewSubscriptionBpsPriceTest { assertThat(newSubscriptionBpsPrice.conversionRate()).isEqualTo(0.0) assertThat(newSubscriptionBpsPrice.conversionRateConfig()) .isEqualTo( - NewSubscriptionBpsPrice.ConversionRateConfig.ofUnit( + ConversionRateConfig.ofUnit( UnitConversionRateConfig.builder() .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) .unitConfig( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionBulkBpsPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionBulkBpsPriceTest.kt index 40cce68a7..4816a40ce 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionBulkBpsPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionBulkBpsPriceTest.kt @@ -96,7 +96,7 @@ internal class NewSubscriptionBulkBpsPriceTest { assertThat(newSubscriptionBulkBpsPrice.conversionRate()).isEqualTo(0.0) assertThat(newSubscriptionBulkBpsPrice.conversionRateConfig()) .isEqualTo( - NewSubscriptionBulkBpsPrice.ConversionRateConfig.ofUnit( + ConversionRateConfig.ofUnit( UnitConversionRateConfig.builder() .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) .unitConfig( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionBulkPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionBulkPriceTest.kt index c5f480a5f..80ee67f14 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionBulkPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionBulkPriceTest.kt @@ -86,7 +86,7 @@ internal class NewSubscriptionBulkPriceTest { assertThat(newSubscriptionBulkPrice.conversionRate()).isEqualTo(0.0) assertThat(newSubscriptionBulkPrice.conversionRateConfig()) .isEqualTo( - NewSubscriptionBulkPrice.ConversionRateConfig.ofUnit( + ConversionRateConfig.ofUnit( UnitConversionRateConfig.builder() .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) .unitConfig( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionBulkWithProrationPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionBulkWithProrationPriceTest.kt index ecca5f90f..2fd55e653 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionBulkWithProrationPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionBulkWithProrationPriceTest.kt @@ -85,7 +85,7 @@ internal class NewSubscriptionBulkWithProrationPriceTest { assertThat(newSubscriptionBulkWithProrationPrice.conversionRate()).isEqualTo(0.0) assertThat(newSubscriptionBulkWithProrationPrice.conversionRateConfig()) .isEqualTo( - NewSubscriptionBulkWithProrationPrice.ConversionRateConfig.ofUnit( + ConversionRateConfig.ofUnit( UnitConversionRateConfig.builder() .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) .unitConfig( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionCumulativeGroupedBulkPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionCumulativeGroupedBulkPriceTest.kt index 9c7f12de1..77219cf57 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionCumulativeGroupedBulkPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionCumulativeGroupedBulkPriceTest.kt @@ -87,7 +87,7 @@ internal class NewSubscriptionCumulativeGroupedBulkPriceTest { assertThat(newSubscriptionCumulativeGroupedBulkPrice.conversionRate()).isEqualTo(0.0) assertThat(newSubscriptionCumulativeGroupedBulkPrice.conversionRateConfig()) .isEqualTo( - NewSubscriptionCumulativeGroupedBulkPrice.ConversionRateConfig.ofUnit( + ConversionRateConfig.ofUnit( UnitConversionRateConfig.builder() .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) .unitConfig( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionGroupedAllocationPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionGroupedAllocationPriceTest.kt index f5df29519..aaaa79790 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionGroupedAllocationPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionGroupedAllocationPriceTest.kt @@ -85,7 +85,7 @@ internal class NewSubscriptionGroupedAllocationPriceTest { assertThat(newSubscriptionGroupedAllocationPrice.conversionRate()).isEqualTo(0.0) assertThat(newSubscriptionGroupedAllocationPrice.conversionRateConfig()) .isEqualTo( - NewSubscriptionGroupedAllocationPrice.ConversionRateConfig.ofUnit( + ConversionRateConfig.ofUnit( UnitConversionRateConfig.builder() .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) .unitConfig( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionGroupedTieredPackagePriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionGroupedTieredPackagePriceTest.kt index cd83b46b2..aa4f448e7 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionGroupedTieredPackagePriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionGroupedTieredPackagePriceTest.kt @@ -87,7 +87,7 @@ internal class NewSubscriptionGroupedTieredPackagePriceTest { assertThat(newSubscriptionGroupedTieredPackagePrice.conversionRate()).isEqualTo(0.0) assertThat(newSubscriptionGroupedTieredPackagePrice.conversionRateConfig()) .isEqualTo( - NewSubscriptionGroupedTieredPackagePrice.ConversionRateConfig.ofUnit( + ConversionRateConfig.ofUnit( UnitConversionRateConfig.builder() .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) .unitConfig( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionGroupedTieredPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionGroupedTieredPriceTest.kt index a23cffc54..7d31e884e 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionGroupedTieredPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionGroupedTieredPriceTest.kt @@ -85,7 +85,7 @@ internal class NewSubscriptionGroupedTieredPriceTest { assertThat(newSubscriptionGroupedTieredPrice.conversionRate()).isEqualTo(0.0) assertThat(newSubscriptionGroupedTieredPrice.conversionRateConfig()) .isEqualTo( - NewSubscriptionGroupedTieredPrice.ConversionRateConfig.ofUnit( + ConversionRateConfig.ofUnit( UnitConversionRateConfig.builder() .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) .unitConfig( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionGroupedWithMeteredMinimumPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionGroupedWithMeteredMinimumPriceTest.kt index 3a88cf7ca..f465f4cb0 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionGroupedWithMeteredMinimumPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionGroupedWithMeteredMinimumPriceTest.kt @@ -92,7 +92,7 @@ internal class NewSubscriptionGroupedWithMeteredMinimumPriceTest { assertThat(newSubscriptionGroupedWithMeteredMinimumPrice.conversionRate()).isEqualTo(0.0) assertThat(newSubscriptionGroupedWithMeteredMinimumPrice.conversionRateConfig()) .isEqualTo( - NewSubscriptionGroupedWithMeteredMinimumPrice.ConversionRateConfig.ofUnit( + ConversionRateConfig.ofUnit( UnitConversionRateConfig.builder() .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) .unitConfig( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionGroupedWithProratedMinimumPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionGroupedWithProratedMinimumPriceTest.kt index 9ba6f6b16..3eae9f908 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionGroupedWithProratedMinimumPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionGroupedWithProratedMinimumPriceTest.kt @@ -95,7 +95,7 @@ internal class NewSubscriptionGroupedWithProratedMinimumPriceTest { assertThat(newSubscriptionGroupedWithProratedMinimumPrice.conversionRate()).isEqualTo(0.0) assertThat(newSubscriptionGroupedWithProratedMinimumPrice.conversionRateConfig()) .isEqualTo( - NewSubscriptionGroupedWithProratedMinimumPrice.ConversionRateConfig.ofUnit( + ConversionRateConfig.ofUnit( UnitConversionRateConfig.builder() .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) .unitConfig( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionMatrixPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionMatrixPriceTest.kt index e9493b446..25d87020d 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionMatrixPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionMatrixPriceTest.kt @@ -98,7 +98,7 @@ internal class NewSubscriptionMatrixPriceTest { assertThat(newSubscriptionMatrixPrice.conversionRate()).isEqualTo(0.0) assertThat(newSubscriptionMatrixPrice.conversionRateConfig()) .isEqualTo( - NewSubscriptionMatrixPrice.ConversionRateConfig.ofUnit( + ConversionRateConfig.ofUnit( UnitConversionRateConfig.builder() .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) .unitConfig( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionMatrixWithAllocationPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionMatrixWithAllocationPriceTest.kt index 62c2de376..f249a99f0 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionMatrixWithAllocationPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionMatrixWithAllocationPriceTest.kt @@ -103,7 +103,7 @@ internal class NewSubscriptionMatrixWithAllocationPriceTest { assertThat(newSubscriptionMatrixWithAllocationPrice.conversionRate()).isEqualTo(0.0) assertThat(newSubscriptionMatrixWithAllocationPrice.conversionRateConfig()) .isEqualTo( - NewSubscriptionMatrixWithAllocationPrice.ConversionRateConfig.ofUnit( + ConversionRateConfig.ofUnit( UnitConversionRateConfig.builder() .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) .unitConfig( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionMatrixWithDisplayNamePriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionMatrixWithDisplayNamePriceTest.kt index 71d7eb7bf..8ce5ca5f6 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionMatrixWithDisplayNamePriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionMatrixWithDisplayNamePriceTest.kt @@ -87,7 +87,7 @@ internal class NewSubscriptionMatrixWithDisplayNamePriceTest { assertThat(newSubscriptionMatrixWithDisplayNamePrice.conversionRate()).isEqualTo(0.0) assertThat(newSubscriptionMatrixWithDisplayNamePrice.conversionRateConfig()) .isEqualTo( - NewSubscriptionMatrixWithDisplayNamePrice.ConversionRateConfig.ofUnit( + ConversionRateConfig.ofUnit( UnitConversionRateConfig.builder() .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) .unitConfig( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionMaxGroupTieredPackagePriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionMaxGroupTieredPackagePriceTest.kt index 5f18dafca..f36b33ed9 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionMaxGroupTieredPackagePriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionMaxGroupTieredPackagePriceTest.kt @@ -87,7 +87,7 @@ internal class NewSubscriptionMaxGroupTieredPackagePriceTest { assertThat(newSubscriptionMaxGroupTieredPackagePrice.conversionRate()).isEqualTo(0.0) assertThat(newSubscriptionMaxGroupTieredPackagePrice.conversionRateConfig()) .isEqualTo( - NewSubscriptionMaxGroupTieredPackagePrice.ConversionRateConfig.ofUnit( + ConversionRateConfig.ofUnit( UnitConversionRateConfig.builder() .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) .unitConfig( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionPackagePriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionPackagePriceTest.kt index 7d90a6764..f3d9051f2 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionPackagePriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionPackagePriceTest.kt @@ -80,7 +80,7 @@ internal class NewSubscriptionPackagePriceTest { assertThat(newSubscriptionPackagePrice.conversionRate()).isEqualTo(0.0) assertThat(newSubscriptionPackagePrice.conversionRateConfig()) .isEqualTo( - NewSubscriptionPackagePrice.ConversionRateConfig.ofUnit( + ConversionRateConfig.ofUnit( UnitConversionRateConfig.builder() .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) .unitConfig( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionPackageWithAllocationPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionPackageWithAllocationPriceTest.kt index b3fa7171b..3c37f47eb 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionPackageWithAllocationPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionPackageWithAllocationPriceTest.kt @@ -87,7 +87,7 @@ internal class NewSubscriptionPackageWithAllocationPriceTest { assertThat(newSubscriptionPackageWithAllocationPrice.conversionRate()).isEqualTo(0.0) assertThat(newSubscriptionPackageWithAllocationPrice.conversionRateConfig()) .isEqualTo( - NewSubscriptionPackageWithAllocationPrice.ConversionRateConfig.ofUnit( + ConversionRateConfig.ofUnit( UnitConversionRateConfig.builder() .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) .unitConfig( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionScalableMatrixWithTieredPricingPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionScalableMatrixWithTieredPricingPriceTest.kt index a305938f4..bc283c763 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionScalableMatrixWithTieredPricingPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionScalableMatrixWithTieredPricingPriceTest.kt @@ -102,7 +102,7 @@ internal class NewSubscriptionScalableMatrixWithTieredPricingPriceTest { .isEqualTo(0.0) assertThat(newSubscriptionScalableMatrixWithTieredPricingPrice.conversionRateConfig()) .isEqualTo( - NewSubscriptionScalableMatrixWithTieredPricingPrice.ConversionRateConfig.ofUnit( + ConversionRateConfig.ofUnit( UnitConversionRateConfig.builder() .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) .unitConfig( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionScalableMatrixWithUnitPricingPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionScalableMatrixWithUnitPricingPriceTest.kt index 054343a55..c9f70db92 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionScalableMatrixWithUnitPricingPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionScalableMatrixWithUnitPricingPriceTest.kt @@ -100,7 +100,7 @@ internal class NewSubscriptionScalableMatrixWithUnitPricingPriceTest { .isEqualTo(0.0) assertThat(newSubscriptionScalableMatrixWithUnitPricingPrice.conversionRateConfig()) .isEqualTo( - NewSubscriptionScalableMatrixWithUnitPricingPrice.ConversionRateConfig.ofUnit( + ConversionRateConfig.ofUnit( UnitConversionRateConfig.builder() .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) .unitConfig( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionThresholdTotalAmountPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionThresholdTotalAmountPriceTest.kt index f265a8b1e..1efd55765 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionThresholdTotalAmountPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionThresholdTotalAmountPriceTest.kt @@ -87,7 +87,7 @@ internal class NewSubscriptionThresholdTotalAmountPriceTest { assertThat(newSubscriptionThresholdTotalAmountPrice.conversionRate()).isEqualTo(0.0) assertThat(newSubscriptionThresholdTotalAmountPrice.conversionRateConfig()) .isEqualTo( - NewSubscriptionThresholdTotalAmountPrice.ConversionRateConfig.ofUnit( + ConversionRateConfig.ofUnit( UnitConversionRateConfig.builder() .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) .unitConfig( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionTierWithProrationPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionTierWithProrationPriceTest.kt index 7c9e21217..e79ecec2e 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionTierWithProrationPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionTierWithProrationPriceTest.kt @@ -85,7 +85,7 @@ internal class NewSubscriptionTierWithProrationPriceTest { assertThat(newSubscriptionTierWithProrationPrice.conversionRate()).isEqualTo(0.0) assertThat(newSubscriptionTierWithProrationPrice.conversionRateConfig()) .isEqualTo( - NewSubscriptionTierWithProrationPrice.ConversionRateConfig.ofUnit( + ConversionRateConfig.ofUnit( UnitConversionRateConfig.builder() .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) .unitConfig( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionTieredBpsPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionTieredBpsPriceTest.kt index 7a98653c4..d04a8b7ca 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionTieredBpsPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionTieredBpsPriceTest.kt @@ -98,7 +98,7 @@ internal class NewSubscriptionTieredBpsPriceTest { assertThat(newSubscriptionTieredBpsPrice.conversionRate()).isEqualTo(0.0) assertThat(newSubscriptionTieredBpsPrice.conversionRateConfig()) .isEqualTo( - NewSubscriptionTieredBpsPrice.ConversionRateConfig.ofUnit( + ConversionRateConfig.ofUnit( UnitConversionRateConfig.builder() .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) .unitConfig( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionTieredPackagePriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionTieredPackagePriceTest.kt index d14d25327..3ba77b0a3 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionTieredPackagePriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionTieredPackagePriceTest.kt @@ -85,7 +85,7 @@ internal class NewSubscriptionTieredPackagePriceTest { assertThat(newSubscriptionTieredPackagePrice.conversionRate()).isEqualTo(0.0) assertThat(newSubscriptionTieredPackagePrice.conversionRateConfig()) .isEqualTo( - NewSubscriptionTieredPackagePrice.ConversionRateConfig.ofUnit( + ConversionRateConfig.ofUnit( UnitConversionRateConfig.builder() .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) .unitConfig( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionTieredPackageWithMinimumPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionTieredPackageWithMinimumPriceTest.kt index a7f589d0d..4f5c3525a 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionTieredPackageWithMinimumPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionTieredPackageWithMinimumPriceTest.kt @@ -92,7 +92,7 @@ internal class NewSubscriptionTieredPackageWithMinimumPriceTest { assertThat(newSubscriptionTieredPackageWithMinimumPrice.conversionRate()).isEqualTo(0.0) assertThat(newSubscriptionTieredPackageWithMinimumPrice.conversionRateConfig()) .isEqualTo( - NewSubscriptionTieredPackageWithMinimumPrice.ConversionRateConfig.ofUnit( + ConversionRateConfig.ofUnit( UnitConversionRateConfig.builder() .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) .unitConfig( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionTieredPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionTieredPriceTest.kt index 54e509149..0228c35ea 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionTieredPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionTieredPriceTest.kt @@ -96,7 +96,7 @@ internal class NewSubscriptionTieredPriceTest { assertThat(newSubscriptionTieredPrice.conversionRate()).isEqualTo(0.0) assertThat(newSubscriptionTieredPrice.conversionRateConfig()) .isEqualTo( - NewSubscriptionTieredPrice.ConversionRateConfig.ofUnit( + ConversionRateConfig.ofUnit( UnitConversionRateConfig.builder() .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) .unitConfig( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionTieredWithMinimumPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionTieredWithMinimumPriceTest.kt index 258e05776..31d129161 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionTieredWithMinimumPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionTieredWithMinimumPriceTest.kt @@ -85,7 +85,7 @@ internal class NewSubscriptionTieredWithMinimumPriceTest { assertThat(newSubscriptionTieredWithMinimumPrice.conversionRate()).isEqualTo(0.0) assertThat(newSubscriptionTieredWithMinimumPrice.conversionRateConfig()) .isEqualTo( - NewSubscriptionTieredWithMinimumPrice.ConversionRateConfig.ofUnit( + ConversionRateConfig.ofUnit( UnitConversionRateConfig.builder() .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) .unitConfig( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionUnitPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionUnitPriceTest.kt index c45afd67c..8d1121afc 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionUnitPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionUnitPriceTest.kt @@ -76,7 +76,7 @@ internal class NewSubscriptionUnitPriceTest { assertThat(newSubscriptionUnitPrice.conversionRate()).isEqualTo(0.0) assertThat(newSubscriptionUnitPrice.conversionRateConfig()) .isEqualTo( - NewSubscriptionUnitPrice.ConversionRateConfig.ofUnit( + ConversionRateConfig.ofUnit( UnitConversionRateConfig.builder() .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) .unitConfig( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionUnitWithPercentPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionUnitWithPercentPriceTest.kt index 93df74627..300e7a20d 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionUnitWithPercentPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionUnitWithPercentPriceTest.kt @@ -85,7 +85,7 @@ internal class NewSubscriptionUnitWithPercentPriceTest { assertThat(newSubscriptionUnitWithPercentPrice.conversionRate()).isEqualTo(0.0) assertThat(newSubscriptionUnitWithPercentPrice.conversionRateConfig()) .isEqualTo( - NewSubscriptionUnitWithPercentPrice.ConversionRateConfig.ofUnit( + ConversionRateConfig.ofUnit( UnitConversionRateConfig.builder() .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) .unitConfig( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionUnitWithProrationPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionUnitWithProrationPriceTest.kt index b33dafb45..a92b95bb2 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionUnitWithProrationPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionUnitWithProrationPriceTest.kt @@ -85,7 +85,7 @@ internal class NewSubscriptionUnitWithProrationPriceTest { assertThat(newSubscriptionUnitWithProrationPrice.conversionRate()).isEqualTo(0.0) assertThat(newSubscriptionUnitWithProrationPrice.conversionRateConfig()) .isEqualTo( - NewSubscriptionUnitWithProrationPrice.ConversionRateConfig.ofUnit( + ConversionRateConfig.ofUnit( UnitConversionRateConfig.builder() .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) .unitConfig( diff --git a/orb-kotlin-proguard-test/src/test/kotlin/com/withorb/api/proguard/ProGuardCompatibilityTest.kt b/orb-kotlin-proguard-test/src/test/kotlin/com/withorb/api/proguard/ProGuardCompatibilityTest.kt index bb4ebfe00..74be89c60 100644 --- a/orb-kotlin-proguard-test/src/test/kotlin/com/withorb/api/proguard/ProGuardCompatibilityTest.kt +++ b/orb-kotlin-proguard-test/src/test/kotlin/com/withorb/api/proguard/ProGuardCompatibilityTest.kt @@ -7,9 +7,9 @@ import com.withorb.api.client.okhttp.OrbOkHttpClient import com.withorb.api.core.jsonMapper import com.withorb.api.models.AccountingProviderConfig import com.withorb.api.models.BillingCycleRelativeDate -import com.withorb.api.models.Discount -import com.withorb.api.models.PercentageDiscount -import com.withorb.api.models.TransformPriceFilter +import com.withorb.api.models.ConversionRateConfig +import com.withorb.api.models.ConversionRateUnitConfig +import com.withorb.api.models.UnitConversionRateConfig import kotlin.reflect.full.memberFunctions import kotlin.reflect.jvm.javaMethod import org.assertj.core.api.Assertions.assertThat @@ -88,33 +88,25 @@ internal class ProGuardCompatibilityTest { } @Test - fun discountRoundtrip() { + fun conversionRateConfigRoundtrip() { val jsonMapper = jsonMapper() - val discount = - Discount.ofPercentage( - PercentageDiscount.builder() - .discountType(PercentageDiscount.DiscountType.PERCENTAGE) - .percentageDiscount(0.15) - .addAppliesToPriceId("h74gfhdjvn7ujokd") - .addAppliesToPriceId("7hfgtgjnbvc3ujkl") - .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) - .addValue("string") - .build() + val conversionRateConfig = + ConversionRateConfig.ofUnit( + UnitConversionRateConfig.builder() + .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + .unitConfig( + ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() ) - .reason("reason") .build() ) - val roundtrippedDiscount = + val roundtrippedConversionRateConfig = jsonMapper.readValue( - jsonMapper.writeValueAsString(discount), - jacksonTypeRef(), + jsonMapper.writeValueAsString(conversionRateConfig), + jacksonTypeRef(), ) - assertThat(roundtrippedDiscount).isEqualTo(discount) + assertThat(roundtrippedConversionRateConfig).isEqualTo(conversionRateConfig) } @Test From d43255b2f3030d1575c1c88898e1e1be202a13b6 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 2 Sep 2025 23:43:25 +0000 Subject: [PATCH 09/68] feat(api): api update --- .stats.yml | 4 +- .../com/withorb/api/models/AlertListParams.kt | 2 +- .../api/models/BetaCreatePlanVersionParams.kt | 10197 ++++++++++--- ...taExternalPlanIdCreatePlanVersionParams.kt | 10197 ++++++++++--- .../com/withorb/api/models/BpsConfig.kt | 213 - .../kotlin/com/withorb/api/models/BpsTier.kt | 301 - .../com/withorb/api/models/BulkBpsConfig.kt | 192 - .../com/withorb/api/models/BulkBpsTier.kt | 258 - .../kotlin/com/withorb/api/models/Customer.kt | 60 +- ...ustomerBalanceTransactionCreateResponse.kt | 6 + .../CustomerBalanceTransactionListResponse.kt | 6 + .../api/models/CustomerCreateParams.kt | 106 +- ...editLedgerCreateEntryByExternalIdParams.kt | 256 +- .../CustomerCreditLedgerCreateEntryParams.kt | 256 +- ...tomerCreditLedgerListByExternalIdParams.kt | 2 +- .../models/CustomerCreditLedgerListParams.kt | 2 +- .../CustomerUpdateByExternalIdParams.kt | 108 +- .../api/models/CustomerUpdateParams.kt | 108 +- .../DimensionalPriceGroupCreateParams.kt | 2 +- .../api/models/EventBackfillCreateParams.kt | 4 +- .../kotlin/com/withorb/api/models/Invoice.kt | 71 +- .../withorb/api/models/InvoiceCreateParams.kt | 319 +- .../models/InvoiceFetchUpcomingResponse.kt | 71 +- .../models/InvoiceLineItemCreateResponse.kt | 16 +- .../api/models/InvoiceMarkPaidParams.kt | 4 +- .../withorb/api/models/InvoiceUpdateParams.kt | 379 +- .../withorb/api/models/InvoiceVoidParams.kt | 2 +- .../MonetaryAmountDiscountAdjustment.kt | 6 +- .../api/models/MonetaryMaximumAdjustment.kt | 6 +- .../api/models/MonetaryMinimumAdjustment.kt | 6 +- .../MonetaryPercentageDiscountAdjustment.kt | 6 +- .../models/MonetaryUsageDiscountAdjustment.kt | 6 +- .../withorb/api/models/NewFloatingBpsPrice.kt | 1320 -- .../api/models/NewFloatingBulkBpsPrice.kt | 1324 -- .../api/models/NewFloatingTieredBpsPrice.kt | 1325 -- .../com/withorb/api/models/NewPlanBpsPrice.kt | 1367 -- .../withorb/api/models/NewPlanBulkBpsPrice.kt | 1371 -- .../api/models/NewPlanTieredBpsPrice.kt | 1372 -- .../api/models/NewSubscriptionBpsPrice.kt | 1367 -- .../api/models/NewSubscriptionBulkBpsPrice.kt | 1372 -- .../models/NewSubscriptionTieredBpsPrice.kt | 1374 -- .../com/withorb/api/models/PerPriceCost.kt | 12 +- .../kotlin/com/withorb/api/models/Plan.kt | 12 +- .../withorb/api/models/PlanCreateParams.kt | 3219 ++++- .../PlanPhaseAmountDiscountAdjustment.kt | 6 +- .../api/models/PlanPhaseMaximumAdjustment.kt | 6 +- .../api/models/PlanPhaseMinimumAdjustment.kt | 6 +- .../PlanPhasePercentageDiscountAdjustment.kt | 6 +- .../PlanPhaseUsageDiscountAdjustment.kt | 6 +- .../com/withorb/api/models/PlanVersion.kt | 12 +- .../kotlin/com/withorb/api/models/Price.kt | 11816 +++++++--------- .../withorb/api/models/PriceCreateParams.kt | 3050 +++- .../api/models/PriceEvaluateMultipleParams.kt | 3117 +++- .../PriceEvaluatePreviewEventsParams.kt | 3117 +++- .../com/withorb/api/models/PriceInterval.kt | 12 +- .../api/models/PriceListPageResponse.kt | 12 +- .../api/models/SubscriptionCreateParams.kt | 11024 ++++++++++---- .../SubscriptionPriceIntervalsParams.kt | 3872 ++++- .../SubscriptionSchedulePlanChangeParams.kt | 10892 ++++++++++---- .../com/withorb/api/models/TieredBpsConfig.kt | 186 - .../api/services/async/AlertServiceAsync.kt | 4 +- .../DimensionalPriceGroupServiceAsync.kt | 2 +- .../api/services/async/InvoiceServiceAsync.kt | 8 +- .../async/SubscriptionServiceAsync.kt | 4 +- .../customers/credits/LedgerServiceAsync.kt | 4 +- .../async/events/BackfillServiceAsync.kt | 2 +- .../api/services/blocking/AlertService.kt | 4 +- .../blocking/DimensionalPriceGroupService.kt | 2 +- .../api/services/blocking/InvoiceService.kt | 8 +- .../services/blocking/SubscriptionService.kt | 4 +- .../customers/credits/LedgerService.kt | 4 +- .../blocking/events/BackfillService.kt | 2 +- .../withorb/api/models/AggregatedCostTest.kt | 21 + .../com/withorb/api/models/BpsConfigTest.kt | 33 - .../com/withorb/api/models/BpsTierTest.kt | 44 - .../withorb/api/models/BulkBpsConfigTest.kt | 57 - .../com/withorb/api/models/BulkBpsTierTest.kt | 44 - .../ChangedSubscriptionResourcesTest.kt | 60 + ...ustomerCostListByExternalIdResponseTest.kt | 21 + .../models/CustomerCostListResponseTest.kt | 21 + .../api/models/CustomerCreateParamsTest.kt | 3 + ...LedgerCreateEntryByExternalIdParamsTest.kt | 3 + ...dgerCreateEntryByExternalIdResponseTest.kt | 22 + ...stomerCreditLedgerCreateEntryParamsTest.kt | 3 + ...omerCreditLedgerCreateEntryResponseTest.kt | 22 + ...tLedgerListByExternalIdPageResponseTest.kt | 36 + ...reditLedgerListByExternalIdResponseTest.kt | 22 + ...ustomerCreditLedgerListPageResponseTest.kt | 36 + .../CustomerCreditLedgerListResponseTest.kt | 22 + .../models/CustomerListPageResponseTest.kt | 3 + .../com/withorb/api/models/CustomerTest.kt | 3 + .../CustomerUpdateByExternalIdParamsTest.kt | 3 + .../api/models/CustomerUpdateParamsTest.kt | 3 + .../api/models/IncrementLedgerEntryTest.kt | 30 + .../api/models/InvoiceCreateParamsTest.kt | 4 + .../InvoiceFetchUpcomingResponseTest.kt | 30 + .../InvoiceLineItemCreateResponseTest.kt | 21 + .../api/models/InvoiceListPageResponseTest.kt | 30 + .../com/withorb/api/models/InvoiceTest.kt | 30 + .../api/models/InvoiceUpdateParamsTest.kt | 8 + .../api/models/MutatedSubscriptionTest.kt | 117 + .../api/models/NewFloatingBpsPriceTest.kt | 166 - .../api/models/NewFloatingBulkBpsPriceTest.kt | 198 - .../models/NewFloatingTieredBpsPriceTest.kt | 201 - .../withorb/api/models/NewPlanBpsPriceTest.kt | 169 - .../api/models/NewPlanBulkBpsPriceTest.kt | 200 - .../api/models/NewPlanTieredBpsPriceTest.kt | 203 - .../api/models/NewSubscriptionBpsPriceTest.kt | 171 - .../models/NewSubscriptionBulkBpsPriceTest.kt | 201 - .../NewSubscriptionTieredBpsPriceTest.kt | 205 - .../withorb/api/models/PerPriceCostTest.kt | 21 + .../api/models/PlanListPageResponseTest.kt | 21 + .../kotlin/com/withorb/api/models/PlanTest.kt | 21 + .../com/withorb/api/models/PlanVersionTest.kt | 21 + .../withorb/api/models/PriceIntervalTest.kt | 21 + .../api/models/PriceListPageResponseTest.kt | 21 + .../com/withorb/api/models/PriceTest.kt | 1780 ++- .../SubscriptionChangeApplyResponseTest.kt | 139 + .../SubscriptionChangeCancelResponseTest.kt | 139 + .../SubscriptionChangeRetrieveResponseTest.kt | 139 + .../SubscriptionFetchCostsResponseTest.kt | 21 + .../SubscriptionPriceIntervalsParamsTest.kt | 9 +- .../withorb/api/models/SubscriptionTest.kt | 45 + .../withorb/api/models/SubscriptionsTest.kt | 45 + .../withorb/api/models/TieredBpsConfigTest.kt | 60 - .../withorb/api/services/ErrorHandlingTest.kt | 17 + .../withorb/api/services/ServiceParamsTest.kt | 1 + .../async/CustomerServiceAsyncTest.kt | 3 + .../services/async/InvoiceServiceAsyncTest.kt | 3 + .../async/SubscriptionServiceAsyncTest.kt | 3 +- .../credits/LedgerServiceAsyncTest.kt | 2 + .../services/blocking/CustomerServiceTest.kt | 3 + .../services/blocking/InvoiceServiceTest.kt | 3 + .../blocking/SubscriptionServiceTest.kt | 3 +- .../customers/credits/LedgerServiceTest.kt | 2 + 135 files changed, 57737 insertions(+), 33067 deletions(-) delete mode 100644 orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BpsConfig.kt delete mode 100644 orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BpsTier.kt delete mode 100644 orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BulkBpsConfig.kt delete mode 100644 orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BulkBpsTier.kt delete mode 100644 orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingBpsPrice.kt delete mode 100644 orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingBulkBpsPrice.kt delete mode 100644 orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredBpsPrice.kt delete mode 100644 orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanBpsPrice.kt delete mode 100644 orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanBulkBpsPrice.kt delete mode 100644 orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanTieredBpsPrice.kt delete mode 100644 orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionBpsPrice.kt delete mode 100644 orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionBulkBpsPrice.kt delete mode 100644 orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTieredBpsPrice.kt delete mode 100644 orb-kotlin-core/src/main/kotlin/com/withorb/api/models/TieredBpsConfig.kt delete mode 100644 orb-kotlin-core/src/test/kotlin/com/withorb/api/models/BpsConfigTest.kt delete mode 100644 orb-kotlin-core/src/test/kotlin/com/withorb/api/models/BpsTierTest.kt delete mode 100644 orb-kotlin-core/src/test/kotlin/com/withorb/api/models/BulkBpsConfigTest.kt delete mode 100644 orb-kotlin-core/src/test/kotlin/com/withorb/api/models/BulkBpsTierTest.kt delete mode 100644 orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingBpsPriceTest.kt delete mode 100644 orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingBulkBpsPriceTest.kt delete mode 100644 orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingTieredBpsPriceTest.kt delete mode 100644 orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanBpsPriceTest.kt delete mode 100644 orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanBulkBpsPriceTest.kt delete mode 100644 orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanTieredBpsPriceTest.kt delete mode 100644 orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionBpsPriceTest.kt delete mode 100644 orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionBulkBpsPriceTest.kt delete mode 100644 orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionTieredBpsPriceTest.kt delete mode 100644 orb-kotlin-core/src/test/kotlin/com/withorb/api/models/TieredBpsConfigTest.kt diff --git a/.stats.yml b/.stats.yml index 3fc0331e8..a2f42b369 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 118 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-4f31d46f5ba187fc4d702c9f9f1573dacb891edbd086f935707578d7c4f5fed8.yml -openapi_spec_hash: 25b1019f20a47b8af665aae5f8fd0025 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-6b2550b95f82872b3825619c109352352b9c92281c8b2470fce158e971142881.yml +openapi_spec_hash: 379df18de1af6a9d0b50d3653aab4d44 config_hash: be9350529b910ec14bff0a30cd74a185 diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/AlertListParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/AlertListParams.kt index 2e9758e18..fb18cf24b 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/AlertListParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/AlertListParams.kt @@ -14,7 +14,7 @@ import java.util.Objects * * The request must specify one of `customer_id`, `external_customer_id`, or `subscription_id`. * - * If querying by subscripion_id, the endpoint will return the subscription level alerts as well as + * If querying by subscription_id, the endpoint will return the subscription level alerts as well as * the plan level alerts associated with the subscription. * * The list of alerts is ordered starting from the most recently created alert. This endpoint diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BetaCreatePlanVersionParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BetaCreatePlanVersionParams.kt index db4dd0f68..8ec318fab 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BetaCreatePlanVersionParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BetaCreatePlanVersionParams.kt @@ -15,6 +15,7 @@ import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import com.withorb.api.core.BaseDeserializer import com.withorb.api.core.BaseSerializer +import com.withorb.api.core.Enum import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing @@ -1838,15 +1839,6 @@ private constructor( /** Alias for calling [price] with `Price.ofTiered(tiered)`. */ fun price(tiered: NewPlanTieredPrice) = price(Price.ofTiered(tiered)) - /** Alias for calling [price] with `Price.ofTieredBps(tieredBps)`. */ - fun price(tieredBps: NewPlanTieredBpsPrice) = price(Price.ofTieredBps(tieredBps)) - - /** Alias for calling [price] with `Price.ofBps(bps)`. */ - fun price(bps: NewPlanBpsPrice) = price(Price.ofBps(bps)) - - /** Alias for calling [price] with `Price.ofBulkBps(bulkBps)`. */ - fun price(bulkBps: NewPlanBulkBpsPrice) = price(Price.ofBulkBps(bulkBps)) - /** Alias for calling [price] with `Price.ofBulk(bulk)`. */ fun price(bulk: NewPlanBulkPrice) = price(Price.ofBulk(bulk)) @@ -1903,6 +1895,13 @@ private constructor( fun price(groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice) = price(Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)) + /** + * Alias for calling [price] with + * `Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)`. + */ + fun price(groupedWithMinMaxThresholds: Price.GroupedWithMinMaxThresholds) = + price(Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)) + /** * Alias for calling [price] with * `Price.ofMatrixWithDisplayName(matrixWithDisplayName)`. @@ -1966,6 +1965,9 @@ private constructor( fun price(groupedTiered: NewPlanGroupedTieredPrice) = price(Price.ofGroupedTiered(groupedTiered)) + /** Alias for calling [price] with `Price.ofMinimum(minimum)`. */ + fun price(minimum: Price.Minimum) = price(Price.ofMinimum(minimum)) + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -2040,9 +2042,6 @@ private constructor( private val package_: NewPlanPackagePrice? = null, private val matrix: NewPlanMatrixPrice? = null, private val tiered: NewPlanTieredPrice? = null, - private val tieredBps: NewPlanTieredBpsPrice? = null, - private val bps: NewPlanBpsPrice? = null, - private val bulkBps: NewPlanBulkBpsPrice? = null, private val bulk: NewPlanBulkPrice? = null, private val thresholdTotalAmount: NewPlanThresholdTotalAmountPrice? = null, private val tieredPackage: NewPlanTieredPackagePrice? = null, @@ -2054,6 +2053,7 @@ private constructor( private val groupedAllocation: NewPlanGroupedAllocationPrice? = null, private val groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice? = null, private val groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice? = null, + private val groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds? = null, private val matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice? = null, private val bulkWithProration: NewPlanBulkWithProrationPrice? = null, private val groupedTieredPackage: NewPlanGroupedTieredPackagePrice? = null, @@ -2067,6 +2067,7 @@ private constructor( private val tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice? = null, private val matrixWithAllocation: NewPlanMatrixWithAllocationPrice? = null, private val groupedTiered: NewPlanGroupedTieredPrice? = null, + private val minimum: Minimum? = null, private val _json: JsonValue? = null, ) { @@ -2078,12 +2079,6 @@ private constructor( fun tiered(): NewPlanTieredPrice? = tiered - fun tieredBps(): NewPlanTieredBpsPrice? = tieredBps - - fun bps(): NewPlanBpsPrice? = bps - - fun bulkBps(): NewPlanBulkBpsPrice? = bulkBps - fun bulk(): NewPlanBulkPrice? = bulk fun thresholdTotalAmount(): NewPlanThresholdTotalAmountPrice? = thresholdTotalAmount @@ -2108,6 +2103,9 @@ private constructor( fun groupedWithMeteredMinimum(): NewPlanGroupedWithMeteredMinimumPrice? = groupedWithMeteredMinimum + fun groupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds? = + groupedWithMinMaxThresholds + fun matrixWithDisplayName(): NewPlanMatrixWithDisplayNamePrice? = matrixWithDisplayName fun bulkWithProration(): NewPlanBulkWithProrationPrice? = bulkWithProration @@ -2131,6 +2129,8 @@ private constructor( fun groupedTiered(): NewPlanGroupedTieredPrice? = groupedTiered + fun minimum(): Minimum? = minimum + fun isUnit(): Boolean = unit != null fun isPackage(): Boolean = package_ != null @@ -2139,12 +2139,6 @@ private constructor( fun isTiered(): Boolean = tiered != null - fun isTieredBps(): Boolean = tieredBps != null - - fun isBps(): Boolean = bps != null - - fun isBulkBps(): Boolean = bulkBps != null - fun isBulk(): Boolean = bulk != null fun isThresholdTotalAmount(): Boolean = thresholdTotalAmount != null @@ -2167,6 +2161,8 @@ private constructor( fun isGroupedWithMeteredMinimum(): Boolean = groupedWithMeteredMinimum != null + fun isGroupedWithMinMaxThresholds(): Boolean = groupedWithMinMaxThresholds != null + fun isMatrixWithDisplayName(): Boolean = matrixWithDisplayName != null fun isBulkWithProration(): Boolean = bulkWithProration != null @@ -2188,6 +2184,8 @@ private constructor( fun isGroupedTiered(): Boolean = groupedTiered != null + fun isMinimum(): Boolean = minimum != null + fun asUnit(): NewPlanUnitPrice = unit.getOrThrow("unit") fun asPackage(): NewPlanPackagePrice = package_.getOrThrow("package_") @@ -2196,12 +2194,6 @@ private constructor( fun asTiered(): NewPlanTieredPrice = tiered.getOrThrow("tiered") - fun asTieredBps(): NewPlanTieredBpsPrice = tieredBps.getOrThrow("tieredBps") - - fun asBps(): NewPlanBpsPrice = bps.getOrThrow("bps") - - fun asBulkBps(): NewPlanBulkBpsPrice = bulkBps.getOrThrow("bulkBps") - fun asBulk(): NewPlanBulkPrice = bulk.getOrThrow("bulk") fun asThresholdTotalAmount(): NewPlanThresholdTotalAmountPrice = @@ -2234,6 +2226,9 @@ private constructor( fun asGroupedWithMeteredMinimum(): NewPlanGroupedWithMeteredMinimumPrice = groupedWithMeteredMinimum.getOrThrow("groupedWithMeteredMinimum") + fun asGroupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds = + groupedWithMinMaxThresholds.getOrThrow("groupedWithMinMaxThresholds") + fun asMatrixWithDisplayName(): NewPlanMatrixWithDisplayNamePrice = matrixWithDisplayName.getOrThrow("matrixWithDisplayName") @@ -2264,6 +2259,8 @@ private constructor( fun asGroupedTiered(): NewPlanGroupedTieredPrice = groupedTiered.getOrThrow("groupedTiered") + fun asMinimum(): Minimum = minimum.getOrThrow("minimum") + fun _json(): JsonValue? = _json fun accept(visitor: Visitor): T = @@ -2272,9 +2269,6 @@ private constructor( package_ != null -> visitor.visitPackage(package_) matrix != null -> visitor.visitMatrix(matrix) tiered != null -> visitor.visitTiered(tiered) - tieredBps != null -> visitor.visitTieredBps(tieredBps) - bps != null -> visitor.visitBps(bps) - bulkBps != null -> visitor.visitBulkBps(bulkBps) bulk != null -> visitor.visitBulk(bulk) thresholdTotalAmount != null -> visitor.visitThresholdTotalAmount(thresholdTotalAmount) @@ -2291,6 +2285,8 @@ private constructor( visitor.visitGroupedWithProratedMinimum(groupedWithProratedMinimum) groupedWithMeteredMinimum != null -> visitor.visitGroupedWithMeteredMinimum(groupedWithMeteredMinimum) + groupedWithMinMaxThresholds != null -> + visitor.visitGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds) matrixWithDisplayName != null -> visitor.visitMatrixWithDisplayName(matrixWithDisplayName) bulkWithProration != null -> visitor.visitBulkWithProration(bulkWithProration) @@ -2311,6 +2307,7 @@ private constructor( matrixWithAllocation != null -> visitor.visitMatrixWithAllocation(matrixWithAllocation) groupedTiered != null -> visitor.visitGroupedTiered(groupedTiered) + minimum != null -> visitor.visitMinimum(minimum) else -> visitor.unknown(_json) } @@ -2339,18 +2336,6 @@ private constructor( tiered.validate() } - override fun visitTieredBps(tieredBps: NewPlanTieredBpsPrice) { - tieredBps.validate() - } - - override fun visitBps(bps: NewPlanBpsPrice) { - bps.validate() - } - - override fun visitBulkBps(bulkBps: NewPlanBulkBpsPrice) { - bulkBps.validate() - } - override fun visitBulk(bulk: NewPlanBulkPrice) { bulk.validate() } @@ -2413,6 +2398,12 @@ private constructor( groupedWithMeteredMinimum.validate() } + override fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) { + groupedWithMinMaxThresholds.validate() + } + override fun visitMatrixWithDisplayName( matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice ) { @@ -2471,6 +2462,10 @@ private constructor( override fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) { groupedTiered.validate() } + + override fun visitMinimum(minimum: Minimum) { + minimum.validate() + } } ) validated = true @@ -2502,13 +2497,6 @@ private constructor( override fun visitTiered(tiered: NewPlanTieredPrice) = tiered.validity() - override fun visitTieredBps(tieredBps: NewPlanTieredBpsPrice) = - tieredBps.validity() - - override fun visitBps(bps: NewPlanBpsPrice) = bps.validity() - - override fun visitBulkBps(bulkBps: NewPlanBulkBpsPrice) = bulkBps.validity() - override fun visitBulk(bulk: NewPlanBulkPrice) = bulk.validity() override fun visitThresholdTotalAmount( @@ -2550,6 +2538,10 @@ private constructor( groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice ) = groupedWithMeteredMinimum.validity() + override fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) = groupedWithMinMaxThresholds.validity() + override fun visitMatrixWithDisplayName( matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice ) = matrixWithDisplayName.validity() @@ -2590,6 +2582,8 @@ private constructor( override fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) = groupedTiered.validity() + override fun visitMinimum(minimum: Minimum) = minimum.validity() + override fun unknown(json: JsonValue?) = 0 } ) @@ -2604,9 +2598,6 @@ private constructor( package_ == other.package_ && matrix == other.matrix && tiered == other.tiered && - tieredBps == other.tieredBps && - bps == other.bps && - bulkBps == other.bulkBps && bulk == other.bulk && thresholdTotalAmount == other.thresholdTotalAmount && tieredPackage == other.tieredPackage && @@ -2618,6 +2609,7 @@ private constructor( groupedAllocation == other.groupedAllocation && groupedWithProratedMinimum == other.groupedWithProratedMinimum && groupedWithMeteredMinimum == other.groupedWithMeteredMinimum && + groupedWithMinMaxThresholds == other.groupedWithMinMaxThresholds && matrixWithDisplayName == other.matrixWithDisplayName && bulkWithProration == other.bulkWithProration && groupedTieredPackage == other.groupedTieredPackage && @@ -2627,7 +2619,8 @@ private constructor( cumulativeGroupedBulk == other.cumulativeGroupedBulk && tieredPackageWithMinimum == other.tieredPackageWithMinimum && matrixWithAllocation == other.matrixWithAllocation && - groupedTiered == other.groupedTiered + groupedTiered == other.groupedTiered && + minimum == other.minimum } override fun hashCode(): Int = @@ -2636,9 +2629,6 @@ private constructor( package_, matrix, tiered, - tieredBps, - bps, - bulkBps, bulk, thresholdTotalAmount, tieredPackage, @@ -2650,6 +2640,7 @@ private constructor( groupedAllocation, groupedWithProratedMinimum, groupedWithMeteredMinimum, + groupedWithMinMaxThresholds, matrixWithDisplayName, bulkWithProration, groupedTieredPackage, @@ -2660,6 +2651,7 @@ private constructor( tieredPackageWithMinimum, matrixWithAllocation, groupedTiered, + minimum, ) override fun toString(): String = @@ -2668,9 +2660,6 @@ private constructor( package_ != null -> "Price{package_=$package_}" matrix != null -> "Price{matrix=$matrix}" tiered != null -> "Price{tiered=$tiered}" - tieredBps != null -> "Price{tieredBps=$tieredBps}" - bps != null -> "Price{bps=$bps}" - bulkBps != null -> "Price{bulkBps=$bulkBps}" bulk != null -> "Price{bulk=$bulk}" thresholdTotalAmount != null -> "Price{thresholdTotalAmount=$thresholdTotalAmount}" @@ -2686,6 +2675,8 @@ private constructor( "Price{groupedWithProratedMinimum=$groupedWithProratedMinimum}" groupedWithMeteredMinimum != null -> "Price{groupedWithMeteredMinimum=$groupedWithMeteredMinimum}" + groupedWithMinMaxThresholds != null -> + "Price{groupedWithMinMaxThresholds=$groupedWithMinMaxThresholds}" matrixWithDisplayName != null -> "Price{matrixWithDisplayName=$matrixWithDisplayName}" bulkWithProration != null -> "Price{bulkWithProration=$bulkWithProration}" @@ -2704,6 +2695,7 @@ private constructor( matrixWithAllocation != null -> "Price{matrixWithAllocation=$matrixWithAllocation}" groupedTiered != null -> "Price{groupedTiered=$groupedTiered}" + minimum != null -> "Price{minimum=$minimum}" _json != null -> "Price{_unknown=$_json}" else -> throw IllegalStateException("Invalid Price") } @@ -2718,12 +2710,6 @@ private constructor( fun ofTiered(tiered: NewPlanTieredPrice) = Price(tiered = tiered) - fun ofTieredBps(tieredBps: NewPlanTieredBpsPrice) = Price(tieredBps = tieredBps) - - fun ofBps(bps: NewPlanBpsPrice) = Price(bps = bps) - - fun ofBulkBps(bulkBps: NewPlanBulkBpsPrice) = Price(bulkBps = bulkBps) - fun ofBulk(bulk: NewPlanBulkPrice) = Price(bulk = bulk) fun ofThresholdTotalAmount(thresholdTotalAmount: NewPlanThresholdTotalAmountPrice) = @@ -2759,6 +2745,10 @@ private constructor( groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice ) = Price(groupedWithMeteredMinimum = groupedWithMeteredMinimum) + fun ofGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) = Price(groupedWithMinMaxThresholds = groupedWithMinMaxThresholds) + fun ofMatrixWithDisplayName( matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice ) = Price(matrixWithDisplayName = matrixWithDisplayName) @@ -2794,6 +2784,8 @@ private constructor( fun ofGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) = Price(groupedTiered = groupedTiered) + + fun ofMinimum(minimum: Minimum) = Price(minimum = minimum) } /** @@ -2809,12 +2801,6 @@ private constructor( fun visitTiered(tiered: NewPlanTieredPrice): T - fun visitTieredBps(tieredBps: NewPlanTieredBpsPrice): T - - fun visitBps(bps: NewPlanBpsPrice): T - - fun visitBulkBps(bulkBps: NewPlanBulkBpsPrice): T - fun visitBulk(bulk: NewPlanBulkPrice): T fun visitThresholdTotalAmount( @@ -2845,6 +2831,10 @@ private constructor( groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice ): T + fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ): T + fun visitMatrixWithDisplayName( matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice ): T @@ -2881,6 +2871,8 @@ private constructor( fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice): T + fun visitMinimum(minimum: Minimum): T + /** * Maps an unknown variant of [Price] to a value of type [T]. * @@ -2922,19 +2914,6 @@ private constructor( Price(tiered = it, _json = json) } ?: Price(_json = json) } - "tiered_bps" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(tieredBps = it, _json = json) } ?: Price(_json = json) - } - "bps" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(bps = it, _json = json) - } ?: Price(_json = json) - } - "bulk_bps" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(bulkBps = it, _json = json) } ?: Price(_json = json) - } "bulk" -> { return tryDeserialize(node, jacksonTypeRef())?.let { Price(bulk = it, _json = json) @@ -3017,6 +2996,14 @@ private constructor( ?.let { Price(groupedWithMeteredMinimum = it, _json = json) } ?: Price(_json = json) } + "grouped_with_min_max_thresholds" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedWithMinMaxThresholds = it, _json = json) } + ?: Price(_json = json) + } "matrix_with_display_name" -> { return tryDeserialize( node, @@ -3094,6 +3081,11 @@ private constructor( ?.let { Price(groupedTiered = it, _json = json) } ?: Price(_json = json) } + "minimum" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(minimum = it, _json = json) + } ?: Price(_json = json) + } } return Price(_json = json) @@ -3112,9 +3104,6 @@ private constructor( value.package_ != null -> generator.writeObject(value.package_) value.matrix != null -> generator.writeObject(value.matrix) value.tiered != null -> generator.writeObject(value.tiered) - value.tieredBps != null -> generator.writeObject(value.tieredBps) - value.bps != null -> generator.writeObject(value.bps) - value.bulkBps != null -> generator.writeObject(value.bulkBps) value.bulk != null -> generator.writeObject(value.bulk) value.thresholdTotalAmount != null -> generator.writeObject(value.thresholdTotalAmount) @@ -3135,6 +3124,8 @@ private constructor( generator.writeObject(value.groupedWithProratedMinimum) value.groupedWithMeteredMinimum != null -> generator.writeObject(value.groupedWithMeteredMinimum) + value.groupedWithMinMaxThresholds != null -> + generator.writeObject(value.groupedWithMinMaxThresholds) value.matrixWithDisplayName != null -> generator.writeObject(value.matrixWithDisplayName) value.bulkWithProration != null -> @@ -3154,1117 +3145,3108 @@ private constructor( value.matrixWithAllocation != null -> generator.writeObject(value.matrixWithAllocation) value.groupedTiered != null -> generator.writeObject(value.groupedTiered) + value.minimum != null -> generator.writeObject(value.minimum) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid Price") } } } - } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + class GroupedWithMinMaxThresholds + private constructor( + private val cadence: JsonField, + private val groupedWithMinMaxThresholdsConfig: + JsonField, + private val itemId: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("grouped_with_min_max_thresholds_config") + @ExcludeMissing + groupedWithMinMaxThresholdsConfig: + JsonField = + JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + groupedWithMinMaxThresholdsConfig, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + mutableMapOf(), + ) - return other is AddPrice && - allocationPrice == other.allocationPrice && - planPhaseOrder == other.planPhaseOrder && - price == other.price && - additionalProperties == other.additionalProperties - } + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") - private val hashCode: Int by lazy { - Objects.hash(allocationPrice, planPhaseOrder, price, additionalProperties) - } + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupedWithMinMaxThresholdsConfig(): GroupedWithMinMaxThresholdsConfig = + groupedWithMinMaxThresholdsConfig.getRequired( + "grouped_with_min_max_thresholds_config" + ) - override fun hashCode(): Int = hashCode + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") - override fun toString() = - "AddPrice{allocationPrice=$allocationPrice, planPhaseOrder=$planPhaseOrder, price=$price, additionalProperties=$additionalProperties}" - } + /** + * Expected to always return the following: + * ```kotlin + * JsonValue.from("grouped_with_min_max_thresholds") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType - class RemoveAdjustment - private constructor( - private val adjustmentId: JsonField, - private val planPhaseOrder: JsonField, - private val additionalProperties: MutableMap, - ) { + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") - @JsonCreator - private constructor( - @JsonProperty("adjustment_id") - @ExcludeMissing - adjustmentId: JsonField = JsonMissing.of(), - @JsonProperty("plan_phase_order") - @ExcludeMissing - planPhaseOrder: JsonField = JsonMissing.of(), - ) : this(adjustmentId, planPhaseOrder, mutableMapOf()) + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = billableMetricId.getNullable("billable_metric_id") - /** - * The id of the adjustment to remove from on the plan. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun adjustmentId(): String = adjustmentId.getRequired("adjustment_id") + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") - /** - * The phase to remove this adjustment from. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun planPhaseOrder(): Long? = planPhaseOrder.getNullable("plan_phase_order") + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") - /** - * Returns the raw JSON value of [adjustmentId]. - * - * Unlike [adjustmentId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("adjustment_id") - @ExcludeMissing - fun _adjustmentId(): JsonField = adjustmentId + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") - /** - * Returns the raw JSON value of [planPhaseOrder]. - * - * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("plan_phase_order") - @ExcludeMissing - fun _planPhaseOrder(): JsonField = planPhaseOrder + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") - fun toBuilder() = Builder().from(this) + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") - companion object { + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") - /** - * Returns a mutable builder for constructing an instance of [RemoveAdjustment]. - * - * The following fields are required: - * ```kotlin - * .adjustmentId() - * ``` - */ - fun builder() = Builder() - } + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + invoiceGroupingKey.getNullable("invoice_grouping_key") - /** A builder for [RemoveAdjustment]. */ - class Builder internal constructor() { + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - private var adjustmentId: JsonField? = null - private var planPhaseOrder: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") - internal fun from(removeAdjustment: RemoveAdjustment) = apply { - adjustmentId = removeAdjustment.adjustmentId - planPhaseOrder = removeAdjustment.planPhaseOrder - additionalProperties = removeAdjustment.additionalProperties.toMutableMap() - } + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") - /** The id of the adjustment to remove from on the plan. */ - fun adjustmentId(adjustmentId: String) = adjustmentId(JsonField.of(adjustmentId)) + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence - /** - * Sets [Builder.adjustmentId] to an arbitrary JSON value. - * - * You should usually call [Builder.adjustmentId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun adjustmentId(adjustmentId: JsonField) = apply { - this.adjustmentId = adjustmentId - } + /** + * Returns the raw JSON value of [groupedWithMinMaxThresholdsConfig]. + * + * Unlike [groupedWithMinMaxThresholdsConfig], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("grouped_with_min_max_thresholds_config") + @ExcludeMissing + fun _groupedWithMinMaxThresholdsConfig(): + JsonField = groupedWithMinMaxThresholdsConfig - /** The phase to remove this adjustment from. */ - fun planPhaseOrder(planPhaseOrder: Long?) = - planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - /** - * Alias for [Builder.planPhaseOrder]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - /** - * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. - * - * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun planPhaseOrder(planPhaseOrder: JsonField) = apply { - this.planPhaseOrder = planPhaseOrder - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig - /** - * Returns an immutable instance of [RemoveAdjustment]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```kotlin - * .adjustmentId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): RemoveAdjustment = - RemoveAdjustment( - checkRequired("adjustmentId", adjustmentId), - planPhaseOrder, - additionalProperties.toMutableMap(), - ) - } + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency - private var validated: Boolean = false + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration - fun validate(): RemoveAdjustment = apply { - if (validated) { - return@apply - } + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId - adjustmentId() - planPhaseOrder() - validated = true - } + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (if (adjustmentId.asKnown() == null) 0 else 1) + - (if (planPhaseOrder.asKnown() == null) 0 else 1) + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata - return other is RemoveAdjustment && - adjustmentId == other.adjustmentId && - planPhaseOrder == other.planPhaseOrder && - additionalProperties == other.additionalProperties - } + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId - private val hashCode: Int by lazy { - Objects.hash(adjustmentId, planPhaseOrder, additionalProperties) - } + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - override fun hashCode(): Int = hashCode + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [GroupedWithMinMaxThresholds]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .groupedWithMinMaxThresholdsConfig() + * .itemId() + * .name() + * ``` + */ + fun builder() = Builder() + } - override fun toString() = - "RemoveAdjustment{adjustmentId=$adjustmentId, planPhaseOrder=$planPhaseOrder, additionalProperties=$additionalProperties}" - } + /** A builder for [GroupedWithMinMaxThresholds]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var groupedWithMinMaxThresholdsConfig: + JsonField? = + null + private var itemId: JsonField? = null + private var modelType: JsonValue = + JsonValue.from("grouped_with_min_max_thresholds") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds) = + apply { + cadence = groupedWithMinMaxThresholds.cadence + groupedWithMinMaxThresholdsConfig = + groupedWithMinMaxThresholds.groupedWithMinMaxThresholdsConfig + itemId = groupedWithMinMaxThresholds.itemId + modelType = groupedWithMinMaxThresholds.modelType + name = groupedWithMinMaxThresholds.name + billableMetricId = groupedWithMinMaxThresholds.billableMetricId + billedInAdvance = groupedWithMinMaxThresholds.billedInAdvance + billingCycleConfiguration = + groupedWithMinMaxThresholds.billingCycleConfiguration + conversionRate = groupedWithMinMaxThresholds.conversionRate + conversionRateConfig = groupedWithMinMaxThresholds.conversionRateConfig + currency = groupedWithMinMaxThresholds.currency + dimensionalPriceConfiguration = + groupedWithMinMaxThresholds.dimensionalPriceConfiguration + externalPriceId = groupedWithMinMaxThresholds.externalPriceId + fixedPriceQuantity = groupedWithMinMaxThresholds.fixedPriceQuantity + invoiceGroupingKey = groupedWithMinMaxThresholds.invoiceGroupingKey + invoicingCycleConfiguration = + groupedWithMinMaxThresholds.invoicingCycleConfiguration + metadata = groupedWithMinMaxThresholds.metadata + referenceId = groupedWithMinMaxThresholds.referenceId + additionalProperties = + groupedWithMinMaxThresholds.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + fun groupedWithMinMaxThresholdsConfig( + groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + ) = + groupedWithMinMaxThresholdsConfig( + JsonField.of(groupedWithMinMaxThresholdsConfig) + ) - class RemovePrice - private constructor( - private val priceId: JsonField, - private val planPhaseOrder: JsonField, - private val additionalProperties: MutableMap, - ) { + /** + * Sets [Builder.groupedWithMinMaxThresholdsConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.groupedWithMinMaxThresholdsConfig] with a + * well-typed [GroupedWithMinMaxThresholdsConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun groupedWithMinMaxThresholdsConfig( + groupedWithMinMaxThresholdsConfig: + JsonField + ) = apply { + this.groupedWithMinMaxThresholdsConfig = groupedWithMinMaxThresholdsConfig + } - @JsonCreator - private constructor( - @JsonProperty("price_id") @ExcludeMissing priceId: JsonField = JsonMissing.of(), - @JsonProperty("plan_phase_order") - @ExcludeMissing - planPhaseOrder: JsonField = JsonMissing.of(), - ) : this(priceId, planPhaseOrder, mutableMapOf()) + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("grouped_with_min_max_thresholds") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } - /** - * The id of the price to remove from the plan. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun priceId(): String = priceId.getRequired("price_id") + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } - /** - * The phase to remove this price from. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun planPhaseOrder(): Long? = planPhaseOrder.getNullable("plan_phase_order") + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } - /** - * Returns the raw JSON value of [priceId]. - * - * Unlike [priceId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) - /** - * Returns the raw JSON value of [planPhaseOrder]. - * - * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("plan_phase_order") - @ExcludeMissing - fun _planPhaseOrder(): JsonField = planPhaseOrder + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } - fun toBuilder() = Builder().from(this) + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } - companion object { + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } - /** - * Returns a mutable builder for constructing an instance of [RemovePrice]. - * - * The following fields are required: - * ```kotlin - * .priceId() - * ``` - */ - fun builder() = Builder() - } + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) - /** A builder for [RemovePrice]. */ - class Builder internal constructor() { + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } - private var priceId: JsonField? = null - private var planPhaseOrder: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - internal fun from(removePrice: RemovePrice) = apply { - priceId = removePrice.priceId - planPhaseOrder = removePrice.planPhaseOrder - additionalProperties = removePrice.additionalProperties.toMutableMap() - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** The id of the price to remove from the plan. */ - fun priceId(priceId: String) = priceId(JsonField.of(priceId)) + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - /** - * Sets [Builder.priceId] to an arbitrary JSON value. - * - * You should usually call [Builder.priceId] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun priceId(priceId: JsonField) = apply { this.priceId = priceId } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - /** The phase to remove this price from. */ - fun planPhaseOrder(planPhaseOrder: Long?) = - planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - /** - * Alias for [Builder.planPhaseOrder]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + /** + * Returns an immutable instance of [GroupedWithMinMaxThresholds]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .groupedWithMinMaxThresholdsConfig() + * .itemId() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedWithMinMaxThresholds = + GroupedWithMinMaxThresholds( + checkRequired("cadence", cadence), + checkRequired( + "groupedWithMinMaxThresholdsConfig", + groupedWithMinMaxThresholdsConfig, + ), + checkRequired("itemId", itemId), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } - /** - * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. - * - * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun planPhaseOrder(planPhaseOrder: JsonField) = apply { - this.planPhaseOrder = planPhaseOrder - } + private var validated: Boolean = false - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun validate(): GroupedWithMinMaxThresholds = apply { + if (validated) { + return@apply + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + cadence().validate() + groupedWithMinMaxThresholdsConfig().validate() + itemId() + _modelType().let { + if (it != JsonValue.from("grouped_with_min_max_thresholds")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + metadata()?.validate() + referenceId() + validated = true + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (groupedWithMinMaxThresholdsConfig.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + modelType.let { + if (it == JsonValue.from("grouped_with_min_max_thresholds")) 1 else 0 + } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } - /** - * Returns an immutable instance of [RemovePrice]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```kotlin - * .priceId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): RemovePrice = - RemovePrice( - checkRequired("priceId", priceId), - planPhaseOrder, - additionalProperties.toMutableMap(), - ) - } + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } - private var validated: Boolean = false + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } - fun validate(): RemovePrice = apply { - if (validated) { - return@apply - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - priceId() - planPhaseOrder() - validated = true - } + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (if (priceId.asKnown() == null) 0 else 1) + - (if (planPhaseOrder.asKnown() == null) 0 else 1) + return other is Cadence && value == other.value + } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + override fun hashCode() = value.hashCode() - return other is RemovePrice && - priceId == other.priceId && - planPhaseOrder == other.planPhaseOrder && - additionalProperties == other.additionalProperties - } + override fun toString() = value.toString() + } - private val hashCode: Int by lazy { - Objects.hash(priceId, planPhaseOrder, additionalProperties) - } + class GroupedWithMinMaxThresholdsConfig + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { - override fun hashCode(): Int = hashCode + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties - override fun toString() = - "RemovePrice{priceId=$priceId, planPhaseOrder=$planPhaseOrder, additionalProperties=$additionalProperties}" - } + fun toBuilder() = Builder().from(this) - class ReplaceAdjustment - private constructor( - private val adjustment: JsonField, - private val replacesAdjustmentId: JsonField, - private val planPhaseOrder: JsonField, - private val additionalProperties: MutableMap, - ) { + companion object { - @JsonCreator - private constructor( - @JsonProperty("adjustment") - @ExcludeMissing - adjustment: JsonField = JsonMissing.of(), - @JsonProperty("replaces_adjustment_id") - @ExcludeMissing - replacesAdjustmentId: JsonField = JsonMissing.of(), - @JsonProperty("plan_phase_order") - @ExcludeMissing - planPhaseOrder: JsonField = JsonMissing.of(), - ) : this(adjustment, replacesAdjustmentId, planPhaseOrder, mutableMapOf()) + /** + * Returns a mutable builder for constructing an instance of + * [GroupedWithMinMaxThresholdsConfig]. + */ + fun builder() = Builder() + } - /** - * The definition of a new adjustment to create and add to the plan. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun adjustment(): Adjustment = adjustment.getRequired("adjustment") + /** A builder for [GroupedWithMinMaxThresholdsConfig]. */ + class Builder internal constructor() { - /** - * The id of the adjustment on the plan to replace in the plan. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun replacesAdjustmentId(): String = - replacesAdjustmentId.getRequired("replaces_adjustment_id") + private var additionalProperties: MutableMap = + mutableMapOf() - /** - * The phase to replace this adjustment from. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun planPhaseOrder(): Long? = planPhaseOrder.getNullable("plan_phase_order") + internal fun from( + groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + ) = apply { + additionalProperties = + groupedWithMinMaxThresholdsConfig.additionalProperties + .toMutableMap() + } - /** - * Returns the raw JSON value of [adjustment]. - * - * Unlike [adjustment], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("adjustment") - @ExcludeMissing - fun _adjustment(): JsonField = adjustment + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** - * Returns the raw JSON value of [replacesAdjustmentId]. - * - * Unlike [replacesAdjustmentId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("replaces_adjustment_id") - @ExcludeMissing - fun _replacesAdjustmentId(): JsonField = replacesAdjustmentId + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * Returns the raw JSON value of [planPhaseOrder]. - * - * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("plan_phase_order") - @ExcludeMissing - fun _planPhaseOrder(): JsonField = planPhaseOrder + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - fun toBuilder() = Builder().from(this) + /** + * Returns an immutable instance of [GroupedWithMinMaxThresholdsConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): GroupedWithMinMaxThresholdsConfig = + GroupedWithMinMaxThresholdsConfig(additionalProperties.toImmutable()) + } - companion object { + private var validated: Boolean = false - /** - * Returns a mutable builder for constructing an instance of [ReplaceAdjustment]. - * - * The following fields are required: - * ```kotlin - * .adjustment() - * .replacesAdjustmentId() - * ``` - */ - fun builder() = Builder() - } + fun validate(): GroupedWithMinMaxThresholdsConfig = apply { + if (validated) { + return@apply + } - /** A builder for [ReplaceAdjustment]. */ - class Builder internal constructor() { + validated = true + } - private var adjustment: JsonField? = null - private var replacesAdjustmentId: JsonField? = null - private var planPhaseOrder: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - internal fun from(replaceAdjustment: ReplaceAdjustment) = apply { - adjustment = replaceAdjustment.adjustment - replacesAdjustmentId = replaceAdjustment.replacesAdjustmentId - planPhaseOrder = replaceAdjustment.planPhaseOrder - additionalProperties = replaceAdjustment.additionalProperties.toMutableMap() - } + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } - /** The definition of a new adjustment to create and add to the plan. */ - fun adjustment(adjustment: Adjustment) = adjustment(JsonField.of(adjustment)) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * Sets [Builder.adjustment] to an arbitrary JSON value. - * - * You should usually call [Builder.adjustment] with a well-typed [Adjustment] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun adjustment(adjustment: JsonField) = apply { - this.adjustment = adjustment - } + return other is GroupedWithMinMaxThresholdsConfig && + additionalProperties == other.additionalProperties + } - /** - * Alias for calling [adjustment] with - * `Adjustment.ofPercentageDiscount(percentageDiscount)`. - */ - fun adjustment(percentageDiscount: NewPercentageDiscount) = - adjustment(Adjustment.ofPercentageDiscount(percentageDiscount)) + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /** - * Alias for calling [adjustment] with the following: - * ```kotlin - * NewPercentageDiscount.builder() - * .adjustmentType(NewPercentageDiscount.AdjustmentType.PERCENTAGE_DISCOUNT) - * .percentageDiscount(percentageDiscount) - * .build() - * ``` - */ - fun percentageDiscountAdjustment(percentageDiscount: Double) = - adjustment( - NewPercentageDiscount.builder() - .adjustmentType(NewPercentageDiscount.AdjustmentType.PERCENTAGE_DISCOUNT) - .percentageDiscount(percentageDiscount) - .build() - ) + override fun hashCode(): Int = hashCode - /** Alias for calling [adjustment] with `Adjustment.ofUsageDiscount(usageDiscount)`. */ - fun adjustment(usageDiscount: NewUsageDiscount) = - adjustment(Adjustment.ofUsageDiscount(usageDiscount)) + override fun toString() = + "GroupedWithMinMaxThresholdsConfig{additionalProperties=$additionalProperties}" + } - /** - * Alias for calling [adjustment] with the following: - * ```kotlin - * NewUsageDiscount.builder() - * .adjustmentType(NewUsageDiscount.AdjustmentType.USAGE_DISCOUNT) - * .usageDiscount(usageDiscount) - * .build() - * ``` - */ - fun usageDiscountAdjustment(usageDiscount: Double) = - adjustment( - NewUsageDiscount.builder() - .adjustmentType(NewUsageDiscount.AdjustmentType.USAGE_DISCOUNT) - .usageDiscount(usageDiscount) - .build() - ) + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { - /** - * Alias for calling [adjustment] with `Adjustment.ofAmountDiscount(amountDiscount)`. - */ - fun adjustment(amountDiscount: NewAmountDiscount) = - adjustment(Adjustment.ofAmountDiscount(amountDiscount)) + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties - /** - * Alias for calling [adjustment] with the following: - * ```kotlin - * NewAmountDiscount.builder() - * .adjustmentType(NewAmountDiscount.AdjustmentType.AMOUNT_DISCOUNT) - * .amountDiscount(amountDiscount) - * .build() - * ``` - */ - fun amountDiscountAdjustment(amountDiscount: String) = - adjustment( - NewAmountDiscount.builder() - .adjustmentType(NewAmountDiscount.AdjustmentType.AMOUNT_DISCOUNT) - .amountDiscount(amountDiscount) - .build() - ) + fun toBuilder() = Builder().from(this) - /** Alias for calling [adjustment] with `Adjustment.ofMinimum(minimum)`. */ - fun adjustment(minimum: NewMinimum) = adjustment(Adjustment.ofMinimum(minimum)) + companion object { - /** Alias for calling [adjustment] with `Adjustment.ofMaximum(maximum)`. */ - fun adjustment(maximum: NewMaximum) = adjustment(Adjustment.ofMaximum(maximum)) + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } - /** - * Alias for calling [adjustment] with the following: - * ```kotlin - * NewMaximum.builder() - * .adjustmentType(NewMaximum.AdjustmentType.MAXIMUM) - * .maximumAmount(maximumAmount) - * .build() - * ``` - */ - fun maximumAdjustment(maximumAmount: String) = - adjustment( - NewMaximum.builder() - .adjustmentType(NewMaximum.AdjustmentType.MAXIMUM) - .maximumAmount(maximumAmount) - .build() - ) + /** A builder for [Metadata]. */ + class Builder internal constructor() { - /** The id of the adjustment on the plan to replace in the plan. */ - fun replacesAdjustmentId(replacesAdjustmentId: String) = - replacesAdjustmentId(JsonField.of(replacesAdjustmentId)) + private var additionalProperties: MutableMap = + mutableMapOf() - /** - * Sets [Builder.replacesAdjustmentId] to an arbitrary JSON value. - * - * You should usually call [Builder.replacesAdjustmentId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun replacesAdjustmentId(replacesAdjustmentId: JsonField) = apply { - this.replacesAdjustmentId = replacesAdjustmentId - } + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } - /** The phase to replace this adjustment from. */ - fun planPhaseOrder(planPhaseOrder: Long?) = - planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** - * Alias for [Builder.planPhaseOrder]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. - * - * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun planPhaseOrder(planPhaseOrder: JsonField) = apply { - this.planPhaseOrder = planPhaseOrder - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + private var validated: Boolean = false - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun validate(): Metadata = apply { + if (validated) { + return@apply + } - /** - * Returns an immutable instance of [ReplaceAdjustment]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```kotlin - * .adjustment() - * .replacesAdjustmentId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): ReplaceAdjustment = - ReplaceAdjustment( - checkRequired("adjustment", adjustment), - checkRequired("replacesAdjustmentId", replacesAdjustmentId), - planPhaseOrder, - additionalProperties.toMutableMap(), - ) - } + validated = true + } - private var validated: Boolean = false + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - fun validate(): ReplaceAdjustment = apply { - if (validated) { - return@apply - } + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } - adjustment().validate() - replacesAdjustmentId() - planPhaseOrder() - validated = true - } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + return other is Metadata && + additionalProperties == other.additionalProperties + } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (adjustment.asKnown()?.validity() ?: 0) + - (if (replacesAdjustmentId.asKnown() == null) 0 else 1) + - (if (planPhaseOrder.asKnown() == null) 0 else 1) + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /** The definition of a new adjustment to create and add to the plan. */ - @JsonDeserialize(using = Adjustment.Deserializer::class) - @JsonSerialize(using = Adjustment.Serializer::class) - class Adjustment - private constructor( - private val percentageDiscount: NewPercentageDiscount? = null, - private val usageDiscount: NewUsageDiscount? = null, - private val amountDiscount: NewAmountDiscount? = null, - private val minimum: NewMinimum? = null, - private val maximum: NewMaximum? = null, - private val _json: JsonValue? = null, - ) { + override fun hashCode(): Int = hashCode - fun percentageDiscount(): NewPercentageDiscount? = percentageDiscount + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } - fun usageDiscount(): NewUsageDiscount? = usageDiscount + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun amountDiscount(): NewAmountDiscount? = amountDiscount + return other is GroupedWithMinMaxThresholds && + cadence == other.cadence && + groupedWithMinMaxThresholdsConfig == + other.groupedWithMinMaxThresholdsConfig && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } - fun minimum(): NewMinimum? = minimum + private val hashCode: Int by lazy { + Objects.hash( + cadence, + groupedWithMinMaxThresholdsConfig, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties, + ) + } - fun maximum(): NewMaximum? = maximum + override fun hashCode(): Int = hashCode - fun isPercentageDiscount(): Boolean = percentageDiscount != null + override fun toString() = + "GroupedWithMinMaxThresholds{cadence=$cadence, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } - fun isUsageDiscount(): Boolean = usageDiscount != null + class Minimum + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val minimumConfig: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("minimum_config") + @ExcludeMissing + minimumConfig: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + minimumConfig, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + mutableMapOf(), + ) - fun isAmountDiscount(): Boolean = amountDiscount != null + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") - fun isMinimum(): Boolean = minimum != null + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") - fun isMaximum(): Boolean = maximum != null + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun minimumConfig(): MinimumConfig = minimumConfig.getRequired("minimum_config") - fun asPercentageDiscount(): NewPercentageDiscount = - percentageDiscount.getOrThrow("percentageDiscount") + /** + * Expected to always return the following: + * ```kotlin + * JsonValue.from("minimum") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType - fun asUsageDiscount(): NewUsageDiscount = usageDiscount.getOrThrow("usageDiscount") + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") - fun asAmountDiscount(): NewAmountDiscount = amountDiscount.getOrThrow("amountDiscount") + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = billableMetricId.getNullable("billable_metric_id") - fun asMinimum(): NewMinimum = minimum.getOrThrow("minimum") + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") - fun asMaximum(): NewMaximum = maximum.getOrThrow("maximum") + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") - fun _json(): JsonValue? = _json + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") - fun accept(visitor: Visitor): T = - when { - percentageDiscount != null -> - visitor.visitPercentageDiscount(percentageDiscount) - usageDiscount != null -> visitor.visitUsageDiscount(usageDiscount) - amountDiscount != null -> visitor.visitAmountDiscount(amountDiscount) - minimum != null -> visitor.visitMinimum(minimum) - maximum != null -> visitor.visitMaximum(maximum) - else -> visitor.unknown(_json) - } + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") - private var validated: Boolean = false + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") - fun validate(): Adjustment = apply { - if (validated) { - return@apply - } + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") - accept( - object : Visitor { - override fun visitPercentageDiscount( - percentageDiscount: NewPercentageDiscount - ) { - percentageDiscount.validate() - } + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") - override fun visitUsageDiscount(usageDiscount: NewUsageDiscount) { - usageDiscount.validate() - } + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") - override fun visitAmountDiscount(amountDiscount: NewAmountDiscount) { - amountDiscount.validate() - } + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + invoiceGroupingKey.getNullable("invoice_grouping_key") - override fun visitMinimum(minimum: NewMinimum) { - minimum.validate() - } + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - override fun visitMaximum(maximum: NewMaximum) { - maximum.validate() - } - } - ) - validated = true - } + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [minimumConfig]. + * + * Unlike [minimumConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("minimum_config") + @ExcludeMissing + fun _minimumConfig(): JsonField = minimumConfig + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitPercentageDiscount( - percentageDiscount: NewPercentageDiscount - ) = percentageDiscount.validity() + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Minimum]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .minimumConfig() + * .name() + * ``` + */ + fun builder() = Builder() + } - override fun visitUsageDiscount(usageDiscount: NewUsageDiscount) = - usageDiscount.validity() + /** A builder for [Minimum]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var minimumConfig: JsonField? = null + private var modelType: JsonValue = JsonValue.from("minimum") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(minimum: Minimum) = apply { + cadence = minimum.cadence + itemId = minimum.itemId + minimumConfig = minimum.minimumConfig + modelType = minimum.modelType + name = minimum.name + billableMetricId = minimum.billableMetricId + billedInAdvance = minimum.billedInAdvance + billingCycleConfiguration = minimum.billingCycleConfiguration + conversionRate = minimum.conversionRate + conversionRateConfig = minimum.conversionRateConfig + currency = minimum.currency + dimensionalPriceConfiguration = minimum.dimensionalPriceConfiguration + externalPriceId = minimum.externalPriceId + fixedPriceQuantity = minimum.fixedPriceQuantity + invoiceGroupingKey = minimum.invoiceGroupingKey + invoicingCycleConfiguration = minimum.invoicingCycleConfiguration + metadata = minimum.metadata + referenceId = minimum.referenceId + additionalProperties = minimum.additionalProperties.toMutableMap() + } - override fun visitAmountDiscount(amountDiscount: NewAmountDiscount) = - amountDiscount.validity() + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun minimumConfig(minimumConfig: MinimumConfig) = + minimumConfig(JsonField.of(minimumConfig)) + + /** + * Sets [Builder.minimumConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumConfig] with a well-typed + * [MinimumConfig] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun minimumConfig(minimumConfig: JsonField) = apply { + this.minimumConfig = minimumConfig + } - override fun visitMinimum(minimum: NewMinimum) = minimum.validity() + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("minimum") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } - override fun visitMaximum(maximum: NewMaximum) = maximum.validity() + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } - override fun unknown(json: JsonValue?) = 0 + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate } - ) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) - return other is Adjustment && - percentageDiscount == other.percentageDiscount && - usageDiscount == other.usageDiscount && - amountDiscount == other.amountDiscount && - minimum == other.minimum && - maximum == other.maximum - } + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) - override fun hashCode(): Int = - Objects.hash(percentageDiscount, usageDiscount, amountDiscount, minimum, maximum) + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) - override fun toString(): String = - when { - percentageDiscount != null -> - "Adjustment{percentageDiscount=$percentageDiscount}" - usageDiscount != null -> "Adjustment{usageDiscount=$usageDiscount}" - amountDiscount != null -> "Adjustment{amountDiscount=$amountDiscount}" - minimum != null -> "Adjustment{minimum=$minimum}" - maximum != null -> "Adjustment{maximum=$maximum}" - _json != null -> "Adjustment{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Adjustment") - } + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } - companion object { + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } - fun ofPercentageDiscount(percentageDiscount: NewPercentageDiscount) = - Adjustment(percentageDiscount = percentageDiscount) + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } - fun ofUsageDiscount(usageDiscount: NewUsageDiscount) = - Adjustment(usageDiscount = usageDiscount) + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) - fun ofAmountDiscount(amountDiscount: NewAmountDiscount) = - Adjustment(amountDiscount = amountDiscount) + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } - fun ofMinimum(minimum: NewMinimum) = Adjustment(minimum = minimum) + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun ofMaximum(maximum: NewMaximum) = Adjustment(maximum = maximum) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * An interface that defines how to map each variant of [Adjustment] to a value of type - * [T]. - */ - interface Visitor { + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun visitPercentageDiscount(percentageDiscount: NewPercentageDiscount): T + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun visitUsageDiscount(usageDiscount: NewUsageDiscount): T + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - fun visitAmountDiscount(amountDiscount: NewAmountDiscount): T + /** + * Returns an immutable instance of [Minimum]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .minimumConfig() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Minimum = + Minimum( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("minimumConfig", minimumConfig), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } - fun visitMinimum(minimum: NewMinimum): T + private var validated: Boolean = false - fun visitMaximum(maximum: NewMaximum): T + fun validate(): Minimum = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + minimumConfig().validate() + _modelType().let { + if (it != JsonValue.from("minimum")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } /** - * Maps an unknown variant of [Adjustment] to a value of type [T]. - * - * An instance of [Adjustment] can contain an unknown variant if it was deserialized - * from data that doesn't match any known variant. For example, if the SDK is on an - * older version than the API, then the API may respond with new variants that the - * SDK is unaware of. + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * @throws OrbInvalidDataException in the default implementation. + * Used for best match union deserialization. */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown Adjustment: $json") - } - } + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + (minimumConfig.asKnown()?.validity() ?: 0) + + modelType.let { if (it == JsonValue.from("minimum")) 1 else 0 } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } - internal class Deserializer : BaseDeserializer(Adjustment::class) { + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } - override fun ObjectCodec.deserialize(node: JsonNode): Adjustment { - val json = JsonValue.fromJsonNode(node) - val adjustmentType = json.asObject()?.get("adjustment_type")?.asString() + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } - when (adjustmentType) { - "percentage_discount" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Adjustment(percentageDiscount = it, _json = json) } - ?: Adjustment(_json = json) - } - "usage_discount" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(usageDiscount = it, _json = json) - } ?: Adjustment(_json = json) - } - "amount_discount" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(amountDiscount = it, _json = json) - } ?: Adjustment(_json = json) - } - "minimum" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(minimum = it, _json = json) - } ?: Adjustment(_json = json) + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false } - "maximum" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(maximum = it, _json = json) - } ?: Adjustment(_json = json) + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } + + return other is Cadence && value == other.value } - return Adjustment(_json = json) - } - } + override fun hashCode() = value.hashCode() - internal class Serializer : BaseSerializer(Adjustment::class) { + override fun toString() = value.toString() + } - override fun serialize( - value: Adjustment, - generator: JsonGenerator, - provider: SerializerProvider, + class MinimumConfig + private constructor( + private val minimumAmount: JsonField, + private val prorated: JsonField, + private val additionalProperties: MutableMap, ) { - when { - value.percentageDiscount != null -> - generator.writeObject(value.percentageDiscount) - value.usageDiscount != null -> generator.writeObject(value.usageDiscount) - value.amountDiscount != null -> generator.writeObject(value.amountDiscount) - value.minimum != null -> generator.writeObject(value.minimum) - value.maximum != null -> generator.writeObject(value.maximum) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Adjustment") + + @JsonCreator + private constructor( + @JsonProperty("minimum_amount") + @ExcludeMissing + minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("prorated") + @ExcludeMissing + prorated: JsonField = JsonMissing.of(), + ) : this(minimumAmount, prorated, mutableMapOf()) + + /** + * The minimum amount to apply + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") + + /** + * By default, subtotals from minimum composite prices are prorated based on the + * service period. Set to false to disable proration. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun prorated(): Boolean? = prorated.getNullable("prorated") + + /** + * Returns the raw JSON value of [minimumAmount]. + * + * Unlike [minimumAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount + + /** + * Returns the raw JSON value of [prorated]. + * + * Unlike [prorated], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("prorated") + @ExcludeMissing + fun _prorated(): JsonField = prorated + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) } - } - } - } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [MinimumConfig]. + * + * The following fields are required: + * ```kotlin + * .minimumAmount() + * ``` + */ + fun builder() = Builder() + } - return other is ReplaceAdjustment && - adjustment == other.adjustment && - replacesAdjustmentId == other.replacesAdjustmentId && - planPhaseOrder == other.planPhaseOrder && - additionalProperties == other.additionalProperties - } + /** A builder for [MinimumConfig]. */ + class Builder internal constructor() { + + private var minimumAmount: JsonField? = null + private var prorated: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(minimumConfig: MinimumConfig) = apply { + minimumAmount = minimumConfig.minimumAmount + prorated = minimumConfig.prorated + additionalProperties = minimumConfig.additionalProperties.toMutableMap() + } + + /** The minimum amount to apply */ + fun minimumAmount(minimumAmount: String) = + minimumAmount(JsonField.of(minimumAmount)) + + /** + * Sets [Builder.minimumAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumAmount] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount + } + + /** + * By default, subtotals from minimum composite prices are prorated based on + * the service period. Set to false to disable proration. + */ + fun prorated(prorated: Boolean?) = prorated(JsonField.ofNullable(prorated)) + + /** + * Alias for [Builder.prorated]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun prorated(prorated: Boolean) = prorated(prorated as Boolean?) + + /** + * Sets [Builder.prorated] to an arbitrary JSON value. + * + * You should usually call [Builder.prorated] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun prorated(prorated: JsonField) = apply { + this.prorated = prorated + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [MinimumConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .minimumAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MinimumConfig = + MinimumConfig( + checkRequired("minimumAmount", minimumAmount), + prorated, + additionalProperties.toMutableMap(), + ) + } - private val hashCode: Int by lazy { - Objects.hash(adjustment, replacesAdjustmentId, planPhaseOrder, additionalProperties) + private var validated: Boolean = false + + fun validate(): MinimumConfig = apply { + if (validated) { + return@apply + } + + minimumAmount() + prorated() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (minimumAmount.asKnown() == null) 0 else 1) + + (if (prorated.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MinimumConfig && + minimumAmount == other.minimumAmount && + prorated == other.prorated && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(minimumAmount, prorated, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MinimumConfig{minimumAmount=$minimumAmount, prorated=$prorated, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Minimum && + cadence == other.cadence && + itemId == other.itemId && + minimumConfig == other.minimumConfig && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + minimumConfig, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Minimum{cadence=$cadence, itemId=$itemId, minimumConfig=$minimumConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AddPrice && + allocationPrice == other.allocationPrice && + planPhaseOrder == other.planPhaseOrder && + price == other.price && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(allocationPrice, planPhaseOrder, price, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "ReplaceAdjustment{adjustment=$adjustment, replacesAdjustmentId=$replacesAdjustmentId, planPhaseOrder=$planPhaseOrder, additionalProperties=$additionalProperties}" + "AddPrice{allocationPrice=$allocationPrice, planPhaseOrder=$planPhaseOrder, price=$price, additionalProperties=$additionalProperties}" } - class ReplacePrice + class RemoveAdjustment private constructor( - private val replacesPriceId: JsonField, - private val allocationPrice: JsonField, + private val adjustmentId: JsonField, private val planPhaseOrder: JsonField, - private val price: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("replaces_price_id") - @ExcludeMissing - replacesPriceId: JsonField = JsonMissing.of(), - @JsonProperty("allocation_price") + @JsonProperty("adjustment_id") @ExcludeMissing - allocationPrice: JsonField = JsonMissing.of(), + adjustmentId: JsonField = JsonMissing.of(), @JsonProperty("plan_phase_order") @ExcludeMissing planPhaseOrder: JsonField = JsonMissing.of(), - @JsonProperty("price") @ExcludeMissing price: JsonField = JsonMissing.of(), - ) : this(replacesPriceId, allocationPrice, planPhaseOrder, price, mutableMapOf()) + ) : this(adjustmentId, planPhaseOrder, mutableMapOf()) /** - * The id of the price on the plan to replace in the plan. + * The id of the adjustment to remove from on the plan. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ - fun replacesPriceId(): String = replacesPriceId.getRequired("replaces_price_id") - - /** - * The allocation price to add to the plan. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun allocationPrice(): NewAllocationPrice? = allocationPrice.getNullable("allocation_price") + fun adjustmentId(): String = adjustmentId.getRequired("adjustment_id") /** - * The phase to replace this price from. + * The phase to remove this adjustment from. * * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -4272,32 +6254,14 @@ private constructor( fun planPhaseOrder(): Long? = planPhaseOrder.getNullable("plan_phase_order") /** - * The price to add to the plan - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun price(): Price? = price.getNullable("price") - - /** - * Returns the raw JSON value of [replacesPriceId]. - * - * Unlike [replacesPriceId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("replaces_price_id") - @ExcludeMissing - fun _replacesPriceId(): JsonField = replacesPriceId - - /** - * Returns the raw JSON value of [allocationPrice]. + * Returns the raw JSON value of [adjustmentId]. * - * Unlike [allocationPrice], this method doesn't throw if the JSON field has an unexpected + * Unlike [adjustmentId], this method doesn't throw if the JSON field has an unexpected * type. */ - @JsonProperty("allocation_price") + @JsonProperty("adjustment_id") @ExcludeMissing - fun _allocationPrice(): JsonField = allocationPrice + fun _adjustmentId(): JsonField = adjustmentId /** * Returns the raw JSON value of [planPhaseOrder]. @@ -4309,13 +6273,6 @@ private constructor( @ExcludeMissing fun _planPhaseOrder(): JsonField = planPhaseOrder - /** - * Returns the raw JSON value of [price]. - * - * Unlike [price], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("price") @ExcludeMissing fun _price(): JsonField = price - @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -4331,64 +6288,44 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [ReplacePrice]. + * Returns a mutable builder for constructing an instance of [RemoveAdjustment]. * * The following fields are required: * ```kotlin - * .replacesPriceId() + * .adjustmentId() * ``` */ fun builder() = Builder() } - /** A builder for [ReplacePrice]. */ + /** A builder for [RemoveAdjustment]. */ class Builder internal constructor() { - private var replacesPriceId: JsonField? = null - private var allocationPrice: JsonField = JsonMissing.of() + private var adjustmentId: JsonField? = null private var planPhaseOrder: JsonField = JsonMissing.of() - private var price: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(replacePrice: ReplacePrice) = apply { - replacesPriceId = replacePrice.replacesPriceId - allocationPrice = replacePrice.allocationPrice - planPhaseOrder = replacePrice.planPhaseOrder - price = replacePrice.price - additionalProperties = replacePrice.additionalProperties.toMutableMap() + internal fun from(removeAdjustment: RemoveAdjustment) = apply { + adjustmentId = removeAdjustment.adjustmentId + planPhaseOrder = removeAdjustment.planPhaseOrder + additionalProperties = removeAdjustment.additionalProperties.toMutableMap() } - /** The id of the price on the plan to replace in the plan. */ - fun replacesPriceId(replacesPriceId: String) = - replacesPriceId(JsonField.of(replacesPriceId)) + /** The id of the adjustment to remove from on the plan. */ + fun adjustmentId(adjustmentId: String) = adjustmentId(JsonField.of(adjustmentId)) /** - * Sets [Builder.replacesPriceId] to an arbitrary JSON value. + * Sets [Builder.adjustmentId] to an arbitrary JSON value. * - * You should usually call [Builder.replacesPriceId] with a well-typed [String] value + * You should usually call [Builder.adjustmentId] with a well-typed [String] value * instead. This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun replacesPriceId(replacesPriceId: JsonField) = apply { - this.replacesPriceId = replacesPriceId - } - - /** The allocation price to add to the plan. */ - fun allocationPrice(allocationPrice: NewAllocationPrice?) = - allocationPrice(JsonField.ofNullable(allocationPrice)) - - /** - * Sets [Builder.allocationPrice] to an arbitrary JSON value. - * - * You should usually call [Builder.allocationPrice] with a well-typed - * [NewAllocationPrice] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun allocationPrice(allocationPrice: JsonField) = apply { - this.allocationPrice = allocationPrice + fun adjustmentId(adjustmentId: JsonField) = apply { + this.adjustmentId = adjustmentId } - /** The phase to replace this price from. */ + /** The phase to remove this adjustment from. */ fun planPhaseOrder(planPhaseOrder: Long?) = planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) @@ -4410,157 +6347,215 @@ private constructor( this.planPhaseOrder = planPhaseOrder } - /** The price to add to the plan */ - fun price(price: Price?) = price(JsonField.ofNullable(price)) - - /** - * Sets [Builder.price] to an arbitrary JSON value. - * - * You should usually call [Builder.price] with a well-typed [Price] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun price(price: JsonField) = apply { this.price = price } - - /** Alias for calling [price] with `Price.ofUnit(unit)`. */ - fun price(unit: NewPlanUnitPrice) = price(Price.ofUnit(unit)) - - /** Alias for calling [price] with `Price.ofPackage(package_)`. */ - fun price(package_: NewPlanPackagePrice) = price(Price.ofPackage(package_)) - - /** Alias for calling [price] with `Price.ofMatrix(matrix)`. */ - fun price(matrix: NewPlanMatrixPrice) = price(Price.ofMatrix(matrix)) - - /** Alias for calling [price] with `Price.ofTiered(tiered)`. */ - fun price(tiered: NewPlanTieredPrice) = price(Price.ofTiered(tiered)) + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** Alias for calling [price] with `Price.ofTieredBps(tieredBps)`. */ - fun price(tieredBps: NewPlanTieredBpsPrice) = price(Price.ofTieredBps(tieredBps)) + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** Alias for calling [price] with `Price.ofBps(bps)`. */ - fun price(bps: NewPlanBpsPrice) = price(Price.ofBps(bps)) + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - /** Alias for calling [price] with `Price.ofBulkBps(bulkBps)`. */ - fun price(bulkBps: NewPlanBulkBpsPrice) = price(Price.ofBulkBps(bulkBps)) + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - /** Alias for calling [price] with `Price.ofBulk(bulk)`. */ - fun price(bulk: NewPlanBulkPrice) = price(Price.ofBulk(bulk)) + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } /** - * Alias for calling [price] with `Price.ofThresholdTotalAmount(thresholdTotalAmount)`. + * Returns an immutable instance of [RemoveAdjustment]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .adjustmentId() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ - fun price(thresholdTotalAmount: NewPlanThresholdTotalAmountPrice) = - price(Price.ofThresholdTotalAmount(thresholdTotalAmount)) + fun build(): RemoveAdjustment = + RemoveAdjustment( + checkRequired("adjustmentId", adjustmentId), + planPhaseOrder, + additionalProperties.toMutableMap(), + ) + } - /** Alias for calling [price] with `Price.ofTieredPackage(tieredPackage)`. */ - fun price(tieredPackage: NewPlanTieredPackagePrice) = - price(Price.ofTieredPackage(tieredPackage)) + private var validated: Boolean = false - /** Alias for calling [price] with `Price.ofTieredWithMinimum(tieredWithMinimum)`. */ - fun price(tieredWithMinimum: NewPlanTieredWithMinimumPrice) = - price(Price.ofTieredWithMinimum(tieredWithMinimum)) + fun validate(): RemoveAdjustment = apply { + if (validated) { + return@apply + } - /** Alias for calling [price] with `Price.ofUnitWithPercent(unitWithPercent)`. */ - fun price(unitWithPercent: NewPlanUnitWithPercentPrice) = - price(Price.ofUnitWithPercent(unitWithPercent)) + adjustmentId() + planPhaseOrder() + validated = true + } - /** - * Alias for calling [price] with - * `Price.ofPackageWithAllocation(packageWithAllocation)`. - */ - fun price(packageWithAllocation: NewPlanPackageWithAllocationPrice) = - price(Price.ofPackageWithAllocation(packageWithAllocation)) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - /** - * Alias for calling [price] with `Price.ofTieredWithProration(tieredWithProration)`. - */ - fun price(tieredWithProration: NewPlanTierWithProrationPrice) = - price(Price.ofTieredWithProration(tieredWithProration)) + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (adjustmentId.asKnown() == null) 0 else 1) + + (if (planPhaseOrder.asKnown() == null) 0 else 1) - /** Alias for calling [price] with `Price.ofUnitWithProration(unitWithProration)`. */ - fun price(unitWithProration: NewPlanUnitWithProrationPrice) = - price(Price.ofUnitWithProration(unitWithProration)) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** Alias for calling [price] with `Price.ofGroupedAllocation(groupedAllocation)`. */ - fun price(groupedAllocation: NewPlanGroupedAllocationPrice) = - price(Price.ofGroupedAllocation(groupedAllocation)) + return other is RemoveAdjustment && + adjustmentId == other.adjustmentId && + planPhaseOrder == other.planPhaseOrder && + additionalProperties == other.additionalProperties + } - /** - * Alias for calling [price] with - * `Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)`. - */ - fun price(groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice) = - price(Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)) + private val hashCode: Int by lazy { + Objects.hash(adjustmentId, planPhaseOrder, additionalProperties) + } - /** - * Alias for calling [price] with - * `Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)`. - */ - fun price(groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice) = - price(Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)) + override fun hashCode(): Int = hashCode - /** - * Alias for calling [price] with - * `Price.ofMatrixWithDisplayName(matrixWithDisplayName)`. - */ - fun price(matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice) = - price(Price.ofMatrixWithDisplayName(matrixWithDisplayName)) + override fun toString() = + "RemoveAdjustment{adjustmentId=$adjustmentId, planPhaseOrder=$planPhaseOrder, additionalProperties=$additionalProperties}" + } - /** Alias for calling [price] with `Price.ofBulkWithProration(bulkWithProration)`. */ - fun price(bulkWithProration: NewPlanBulkWithProrationPrice) = - price(Price.ofBulkWithProration(bulkWithProration)) + class RemovePrice + private constructor( + private val priceId: JsonField, + private val planPhaseOrder: JsonField, + private val additionalProperties: MutableMap, + ) { - /** - * Alias for calling [price] with `Price.ofGroupedTieredPackage(groupedTieredPackage)`. - */ - fun price(groupedTieredPackage: NewPlanGroupedTieredPackagePrice) = - price(Price.ofGroupedTieredPackage(groupedTieredPackage)) + @JsonCreator + private constructor( + @JsonProperty("price_id") @ExcludeMissing priceId: JsonField = JsonMissing.of(), + @JsonProperty("plan_phase_order") + @ExcludeMissing + planPhaseOrder: JsonField = JsonMissing.of(), + ) : this(priceId, planPhaseOrder, mutableMapOf()) - /** - * Alias for calling [price] with - * `Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)`. - */ - fun price(maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice) = - price(Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)) + /** + * The id of the price to remove from the plan. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun priceId(): String = priceId.getRequired("price_id") - /** - * Alias for calling [price] with - * `Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)`. - */ - fun price(scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice) = - price(Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)) + /** + * The phase to remove this price from. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun planPhaseOrder(): Long? = planPhaseOrder.getNullable("plan_phase_order") + + /** + * Returns the raw JSON value of [priceId]. + * + * Unlike [priceId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId + + /** + * Returns the raw JSON value of [planPhaseOrder]. + * + * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { /** - * Alias for calling [price] with - * `Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)`. + * Returns a mutable builder for constructing an instance of [RemovePrice]. + * + * The following fields are required: + * ```kotlin + * .priceId() + * ``` */ - fun price( - scalableMatrixWithTieredPricing: NewPlanScalableMatrixWithTieredPricingPrice - ) = price(Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)) + fun builder() = Builder() + } + + /** A builder for [RemovePrice]. */ + class Builder internal constructor() { + + private var priceId: JsonField? = null + private var planPhaseOrder: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(removePrice: RemovePrice) = apply { + priceId = removePrice.priceId + planPhaseOrder = removePrice.planPhaseOrder + additionalProperties = removePrice.additionalProperties.toMutableMap() + } + + /** The id of the price to remove from the plan. */ + fun priceId(priceId: String) = priceId(JsonField.of(priceId)) /** - * Alias for calling [price] with - * `Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)`. + * Sets [Builder.priceId] to an arbitrary JSON value. + * + * You should usually call [Builder.priceId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun price(cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice) = - price(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) + fun priceId(priceId: JsonField) = apply { this.priceId = priceId } + + /** The phase to remove this price from. */ + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) /** - * Alias for calling [price] with - * `Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)`. + * Alias for [Builder.planPhaseOrder]. + * + * This unboxed primitive overload exists for backwards compatibility. */ - fun price(tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice) = - price(Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)) + fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) /** - * Alias for calling [price] with `Price.ofMatrixWithAllocation(matrixWithAllocation)`. + * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. + * + * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun price(matrixWithAllocation: NewPlanMatrixWithAllocationPrice) = - price(Price.ofMatrixWithAllocation(matrixWithAllocation)) - - /** Alias for calling [price] with `Price.ofGroupedTiered(groupedTiered)`. */ - fun price(groupedTiered: NewPlanGroupedTieredPrice) = - price(Price.ofGroupedTiered(groupedTiered)) + fun planPhaseOrder(planPhaseOrder: JsonField) = apply { + this.planPhaseOrder = planPhaseOrder + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -4582,38 +6577,34 @@ private constructor( } /** - * Returns an immutable instance of [ReplacePrice]. + * Returns an immutable instance of [RemovePrice]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```kotlin - * .replacesPriceId() + * .priceId() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): ReplacePrice = - ReplacePrice( - checkRequired("replacesPriceId", replacesPriceId), - allocationPrice, + fun build(): RemovePrice = + RemovePrice( + checkRequired("priceId", priceId), planPhaseOrder, - price, additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): ReplacePrice = apply { + fun validate(): RemovePrice = apply { if (validated) { return@apply } - replacesPriceId() - allocationPrice()?.validate() + priceId() planPhaseOrder() - price()?.validate() validated = true } @@ -4632,1138 +6623,5220 @@ private constructor( * Used for best match union deserialization. */ internal fun validity(): Int = - (if (replacesPriceId.asKnown() == null) 0 else 1) + - (allocationPrice.asKnown()?.validity() ?: 0) + - (if (planPhaseOrder.asKnown() == null) 0 else 1) + - (price.asKnown()?.validity() ?: 0) + (if (priceId.asKnown() == null) 0 else 1) + + (if (planPhaseOrder.asKnown() == null) 0 else 1) - /** The price to add to the plan */ - @JsonDeserialize(using = Price.Deserializer::class) - @JsonSerialize(using = Price.Serializer::class) - class Price - private constructor( - private val unit: NewPlanUnitPrice? = null, - private val package_: NewPlanPackagePrice? = null, - private val matrix: NewPlanMatrixPrice? = null, - private val tiered: NewPlanTieredPrice? = null, - private val tieredBps: NewPlanTieredBpsPrice? = null, - private val bps: NewPlanBpsPrice? = null, - private val bulkBps: NewPlanBulkBpsPrice? = null, - private val bulk: NewPlanBulkPrice? = null, - private val thresholdTotalAmount: NewPlanThresholdTotalAmountPrice? = null, - private val tieredPackage: NewPlanTieredPackagePrice? = null, - private val tieredWithMinimum: NewPlanTieredWithMinimumPrice? = null, - private val unitWithPercent: NewPlanUnitWithPercentPrice? = null, - private val packageWithAllocation: NewPlanPackageWithAllocationPrice? = null, - private val tieredWithProration: NewPlanTierWithProrationPrice? = null, - private val unitWithProration: NewPlanUnitWithProrationPrice? = null, - private val groupedAllocation: NewPlanGroupedAllocationPrice? = null, - private val groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice? = null, - private val groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice? = null, - private val matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice? = null, - private val bulkWithProration: NewPlanBulkWithProrationPrice? = null, - private val groupedTieredPackage: NewPlanGroupedTieredPackagePrice? = null, - private val maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice? = null, - private val scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice? = - null, - private val scalableMatrixWithTieredPricing: - NewPlanScalableMatrixWithTieredPricingPrice? = - null, - private val cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice? = null, - private val tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice? = null, - private val matrixWithAllocation: NewPlanMatrixWithAllocationPrice? = null, - private val groupedTiered: NewPlanGroupedTieredPrice? = null, - private val _json: JsonValue? = null, - ) { - - fun unit(): NewPlanUnitPrice? = unit + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun package_(): NewPlanPackagePrice? = package_ + return other is RemovePrice && + priceId == other.priceId && + planPhaseOrder == other.planPhaseOrder && + additionalProperties == other.additionalProperties + } - fun matrix(): NewPlanMatrixPrice? = matrix + private val hashCode: Int by lazy { + Objects.hash(priceId, planPhaseOrder, additionalProperties) + } - fun tiered(): NewPlanTieredPrice? = tiered + override fun hashCode(): Int = hashCode - fun tieredBps(): NewPlanTieredBpsPrice? = tieredBps + override fun toString() = + "RemovePrice{priceId=$priceId, planPhaseOrder=$planPhaseOrder, additionalProperties=$additionalProperties}" + } - fun bps(): NewPlanBpsPrice? = bps + class ReplaceAdjustment + private constructor( + private val adjustment: JsonField, + private val replacesAdjustmentId: JsonField, + private val planPhaseOrder: JsonField, + private val additionalProperties: MutableMap, + ) { - fun bulkBps(): NewPlanBulkBpsPrice? = bulkBps + @JsonCreator + private constructor( + @JsonProperty("adjustment") + @ExcludeMissing + adjustment: JsonField = JsonMissing.of(), + @JsonProperty("replaces_adjustment_id") + @ExcludeMissing + replacesAdjustmentId: JsonField = JsonMissing.of(), + @JsonProperty("plan_phase_order") + @ExcludeMissing + planPhaseOrder: JsonField = JsonMissing.of(), + ) : this(adjustment, replacesAdjustmentId, planPhaseOrder, mutableMapOf()) - fun bulk(): NewPlanBulkPrice? = bulk + /** + * The definition of a new adjustment to create and add to the plan. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun adjustment(): Adjustment = adjustment.getRequired("adjustment") - fun thresholdTotalAmount(): NewPlanThresholdTotalAmountPrice? = thresholdTotalAmount + /** + * The id of the adjustment on the plan to replace in the plan. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun replacesAdjustmentId(): String = + replacesAdjustmentId.getRequired("replaces_adjustment_id") - fun tieredPackage(): NewPlanTieredPackagePrice? = tieredPackage + /** + * The phase to replace this adjustment from. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun planPhaseOrder(): Long? = planPhaseOrder.getNullable("plan_phase_order") - fun tieredWithMinimum(): NewPlanTieredWithMinimumPrice? = tieredWithMinimum + /** + * Returns the raw JSON value of [adjustment]. + * + * Unlike [adjustment], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("adjustment") + @ExcludeMissing + fun _adjustment(): JsonField = adjustment - fun unitWithPercent(): NewPlanUnitWithPercentPrice? = unitWithPercent + /** + * Returns the raw JSON value of [replacesAdjustmentId]. + * + * Unlike [replacesAdjustmentId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("replaces_adjustment_id") + @ExcludeMissing + fun _replacesAdjustmentId(): JsonField = replacesAdjustmentId - fun packageWithAllocation(): NewPlanPackageWithAllocationPrice? = packageWithAllocation + /** + * Returns the raw JSON value of [planPhaseOrder]. + * + * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder - fun tieredWithProration(): NewPlanTierWithProrationPrice? = tieredWithProration + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - fun unitWithProration(): NewPlanUnitWithProrationPrice? = unitWithProration + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - fun groupedAllocation(): NewPlanGroupedAllocationPrice? = groupedAllocation + fun toBuilder() = Builder().from(this) - fun groupedWithProratedMinimum(): NewPlanGroupedWithProratedMinimumPrice? = - groupedWithProratedMinimum + companion object { - fun groupedWithMeteredMinimum(): NewPlanGroupedWithMeteredMinimumPrice? = - groupedWithMeteredMinimum + /** + * Returns a mutable builder for constructing an instance of [ReplaceAdjustment]. + * + * The following fields are required: + * ```kotlin + * .adjustment() + * .replacesAdjustmentId() + * ``` + */ + fun builder() = Builder() + } - fun matrixWithDisplayName(): NewPlanMatrixWithDisplayNamePrice? = matrixWithDisplayName + /** A builder for [ReplaceAdjustment]. */ + class Builder internal constructor() { - fun bulkWithProration(): NewPlanBulkWithProrationPrice? = bulkWithProration + private var adjustment: JsonField? = null + private var replacesAdjustmentId: JsonField? = null + private var planPhaseOrder: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - fun groupedTieredPackage(): NewPlanGroupedTieredPackagePrice? = groupedTieredPackage + internal fun from(replaceAdjustment: ReplaceAdjustment) = apply { + adjustment = replaceAdjustment.adjustment + replacesAdjustmentId = replaceAdjustment.replacesAdjustmentId + planPhaseOrder = replaceAdjustment.planPhaseOrder + additionalProperties = replaceAdjustment.additionalProperties.toMutableMap() + } - fun maxGroupTieredPackage(): NewPlanMaxGroupTieredPackagePrice? = maxGroupTieredPackage + /** The definition of a new adjustment to create and add to the plan. */ + fun adjustment(adjustment: Adjustment) = adjustment(JsonField.of(adjustment)) - fun scalableMatrixWithUnitPricing(): NewPlanScalableMatrixWithUnitPricingPrice? = - scalableMatrixWithUnitPricing + /** + * Sets [Builder.adjustment] to an arbitrary JSON value. + * + * You should usually call [Builder.adjustment] with a well-typed [Adjustment] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun adjustment(adjustment: JsonField) = apply { + this.adjustment = adjustment + } - fun scalableMatrixWithTieredPricing(): NewPlanScalableMatrixWithTieredPricingPrice? = - scalableMatrixWithTieredPricing + /** + * Alias for calling [adjustment] with + * `Adjustment.ofPercentageDiscount(percentageDiscount)`. + */ + fun adjustment(percentageDiscount: NewPercentageDiscount) = + adjustment(Adjustment.ofPercentageDiscount(percentageDiscount)) - fun cumulativeGroupedBulk(): NewPlanCumulativeGroupedBulkPrice? = cumulativeGroupedBulk + /** + * Alias for calling [adjustment] with the following: + * ```kotlin + * NewPercentageDiscount.builder() + * .adjustmentType(NewPercentageDiscount.AdjustmentType.PERCENTAGE_DISCOUNT) + * .percentageDiscount(percentageDiscount) + * .build() + * ``` + */ + fun percentageDiscountAdjustment(percentageDiscount: Double) = + adjustment( + NewPercentageDiscount.builder() + .adjustmentType(NewPercentageDiscount.AdjustmentType.PERCENTAGE_DISCOUNT) + .percentageDiscount(percentageDiscount) + .build() + ) - fun tieredPackageWithMinimum(): NewPlanTieredPackageWithMinimumPrice? = - tieredPackageWithMinimum + /** Alias for calling [adjustment] with `Adjustment.ofUsageDiscount(usageDiscount)`. */ + fun adjustment(usageDiscount: NewUsageDiscount) = + adjustment(Adjustment.ofUsageDiscount(usageDiscount)) - fun matrixWithAllocation(): NewPlanMatrixWithAllocationPrice? = matrixWithAllocation + /** + * Alias for calling [adjustment] with the following: + * ```kotlin + * NewUsageDiscount.builder() + * .adjustmentType(NewUsageDiscount.AdjustmentType.USAGE_DISCOUNT) + * .usageDiscount(usageDiscount) + * .build() + * ``` + */ + fun usageDiscountAdjustment(usageDiscount: Double) = + adjustment( + NewUsageDiscount.builder() + .adjustmentType(NewUsageDiscount.AdjustmentType.USAGE_DISCOUNT) + .usageDiscount(usageDiscount) + .build() + ) - fun groupedTiered(): NewPlanGroupedTieredPrice? = groupedTiered + /** + * Alias for calling [adjustment] with `Adjustment.ofAmountDiscount(amountDiscount)`. + */ + fun adjustment(amountDiscount: NewAmountDiscount) = + adjustment(Adjustment.ofAmountDiscount(amountDiscount)) - fun isUnit(): Boolean = unit != null + /** + * Alias for calling [adjustment] with the following: + * ```kotlin + * NewAmountDiscount.builder() + * .adjustmentType(NewAmountDiscount.AdjustmentType.AMOUNT_DISCOUNT) + * .amountDiscount(amountDiscount) + * .build() + * ``` + */ + fun amountDiscountAdjustment(amountDiscount: String) = + adjustment( + NewAmountDiscount.builder() + .adjustmentType(NewAmountDiscount.AdjustmentType.AMOUNT_DISCOUNT) + .amountDiscount(amountDiscount) + .build() + ) - fun isPackage(): Boolean = package_ != null + /** Alias for calling [adjustment] with `Adjustment.ofMinimum(minimum)`. */ + fun adjustment(minimum: NewMinimum) = adjustment(Adjustment.ofMinimum(minimum)) - fun isMatrix(): Boolean = matrix != null + /** Alias for calling [adjustment] with `Adjustment.ofMaximum(maximum)`. */ + fun adjustment(maximum: NewMaximum) = adjustment(Adjustment.ofMaximum(maximum)) - fun isTiered(): Boolean = tiered != null + /** + * Alias for calling [adjustment] with the following: + * ```kotlin + * NewMaximum.builder() + * .adjustmentType(NewMaximum.AdjustmentType.MAXIMUM) + * .maximumAmount(maximumAmount) + * .build() + * ``` + */ + fun maximumAdjustment(maximumAmount: String) = + adjustment( + NewMaximum.builder() + .adjustmentType(NewMaximum.AdjustmentType.MAXIMUM) + .maximumAmount(maximumAmount) + .build() + ) - fun isTieredBps(): Boolean = tieredBps != null + /** The id of the adjustment on the plan to replace in the plan. */ + fun replacesAdjustmentId(replacesAdjustmentId: String) = + replacesAdjustmentId(JsonField.of(replacesAdjustmentId)) - fun isBps(): Boolean = bps != null + /** + * Sets [Builder.replacesAdjustmentId] to an arbitrary JSON value. + * + * You should usually call [Builder.replacesAdjustmentId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun replacesAdjustmentId(replacesAdjustmentId: JsonField) = apply { + this.replacesAdjustmentId = replacesAdjustmentId + } - fun isBulkBps(): Boolean = bulkBps != null + /** The phase to replace this adjustment from. */ + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) - fun isBulk(): Boolean = bulk != null + /** + * Alias for [Builder.planPhaseOrder]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) - fun isThresholdTotalAmount(): Boolean = thresholdTotalAmount != null + /** + * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. + * + * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun planPhaseOrder(planPhaseOrder: JsonField) = apply { + this.planPhaseOrder = planPhaseOrder + } - fun isTieredPackage(): Boolean = tieredPackage != null + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun isTieredWithMinimum(): Boolean = tieredWithMinimum != null + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun isUnitWithPercent(): Boolean = unitWithPercent != null + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun isPackageWithAllocation(): Boolean = packageWithAllocation != null + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - fun isTieredWithProration(): Boolean = tieredWithProration != null + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - fun isUnitWithProration(): Boolean = unitWithProration != null + /** + * Returns an immutable instance of [ReplaceAdjustment]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .adjustment() + * .replacesAdjustmentId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ReplaceAdjustment = + ReplaceAdjustment( + checkRequired("adjustment", adjustment), + checkRequired("replacesAdjustmentId", replacesAdjustmentId), + planPhaseOrder, + additionalProperties.toMutableMap(), + ) + } - fun isGroupedAllocation(): Boolean = groupedAllocation != null + private var validated: Boolean = false - fun isGroupedWithProratedMinimum(): Boolean = groupedWithProratedMinimum != null + fun validate(): ReplaceAdjustment = apply { + if (validated) { + return@apply + } - fun isGroupedWithMeteredMinimum(): Boolean = groupedWithMeteredMinimum != null + adjustment().validate() + replacesAdjustmentId() + planPhaseOrder() + validated = true + } - fun isMatrixWithDisplayName(): Boolean = matrixWithDisplayName != null + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - fun isBulkWithProration(): Boolean = bulkWithProration != null + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (adjustment.asKnown()?.validity() ?: 0) + + (if (replacesAdjustmentId.asKnown() == null) 0 else 1) + + (if (planPhaseOrder.asKnown() == null) 0 else 1) - fun isGroupedTieredPackage(): Boolean = groupedTieredPackage != null + /** The definition of a new adjustment to create and add to the plan. */ + @JsonDeserialize(using = Adjustment.Deserializer::class) + @JsonSerialize(using = Adjustment.Serializer::class) + class Adjustment + private constructor( + private val percentageDiscount: NewPercentageDiscount? = null, + private val usageDiscount: NewUsageDiscount? = null, + private val amountDiscount: NewAmountDiscount? = null, + private val minimum: NewMinimum? = null, + private val maximum: NewMaximum? = null, + private val _json: JsonValue? = null, + ) { - fun isMaxGroupTieredPackage(): Boolean = maxGroupTieredPackage != null + fun percentageDiscount(): NewPercentageDiscount? = percentageDiscount - fun isScalableMatrixWithUnitPricing(): Boolean = scalableMatrixWithUnitPricing != null + fun usageDiscount(): NewUsageDiscount? = usageDiscount - fun isScalableMatrixWithTieredPricing(): Boolean = - scalableMatrixWithTieredPricing != null + fun amountDiscount(): NewAmountDiscount? = amountDiscount - fun isCumulativeGroupedBulk(): Boolean = cumulativeGroupedBulk != null + fun minimum(): NewMinimum? = minimum - fun isTieredPackageWithMinimum(): Boolean = tieredPackageWithMinimum != null + fun maximum(): NewMaximum? = maximum - fun isMatrixWithAllocation(): Boolean = matrixWithAllocation != null + fun isPercentageDiscount(): Boolean = percentageDiscount != null - fun isGroupedTiered(): Boolean = groupedTiered != null + fun isUsageDiscount(): Boolean = usageDiscount != null - fun asUnit(): NewPlanUnitPrice = unit.getOrThrow("unit") + fun isAmountDiscount(): Boolean = amountDiscount != null - fun asPackage(): NewPlanPackagePrice = package_.getOrThrow("package_") + fun isMinimum(): Boolean = minimum != null - fun asMatrix(): NewPlanMatrixPrice = matrix.getOrThrow("matrix") + fun isMaximum(): Boolean = maximum != null - fun asTiered(): NewPlanTieredPrice = tiered.getOrThrow("tiered") + fun asPercentageDiscount(): NewPercentageDiscount = + percentageDiscount.getOrThrow("percentageDiscount") - fun asTieredBps(): NewPlanTieredBpsPrice = tieredBps.getOrThrow("tieredBps") + fun asUsageDiscount(): NewUsageDiscount = usageDiscount.getOrThrow("usageDiscount") - fun asBps(): NewPlanBpsPrice = bps.getOrThrow("bps") + fun asAmountDiscount(): NewAmountDiscount = amountDiscount.getOrThrow("amountDiscount") - fun asBulkBps(): NewPlanBulkBpsPrice = bulkBps.getOrThrow("bulkBps") + fun asMinimum(): NewMinimum = minimum.getOrThrow("minimum") - fun asBulk(): NewPlanBulkPrice = bulk.getOrThrow("bulk") + fun asMaximum(): NewMaximum = maximum.getOrThrow("maximum") - fun asThresholdTotalAmount(): NewPlanThresholdTotalAmountPrice = - thresholdTotalAmount.getOrThrow("thresholdTotalAmount") + fun _json(): JsonValue? = _json - fun asTieredPackage(): NewPlanTieredPackagePrice = - tieredPackage.getOrThrow("tieredPackage") + fun accept(visitor: Visitor): T = + when { + percentageDiscount != null -> + visitor.visitPercentageDiscount(percentageDiscount) + usageDiscount != null -> visitor.visitUsageDiscount(usageDiscount) + amountDiscount != null -> visitor.visitAmountDiscount(amountDiscount) + minimum != null -> visitor.visitMinimum(minimum) + maximum != null -> visitor.visitMaximum(maximum) + else -> visitor.unknown(_json) + } - fun asTieredWithMinimum(): NewPlanTieredWithMinimumPrice = - tieredWithMinimum.getOrThrow("tieredWithMinimum") + private var validated: Boolean = false - fun asUnitWithPercent(): NewPlanUnitWithPercentPrice = - unitWithPercent.getOrThrow("unitWithPercent") + fun validate(): Adjustment = apply { + if (validated) { + return@apply + } - fun asPackageWithAllocation(): NewPlanPackageWithAllocationPrice = - packageWithAllocation.getOrThrow("packageWithAllocation") + accept( + object : Visitor { + override fun visitPercentageDiscount( + percentageDiscount: NewPercentageDiscount + ) { + percentageDiscount.validate() + } - fun asTieredWithProration(): NewPlanTierWithProrationPrice = - tieredWithProration.getOrThrow("tieredWithProration") + override fun visitUsageDiscount(usageDiscount: NewUsageDiscount) { + usageDiscount.validate() + } - fun asUnitWithProration(): NewPlanUnitWithProrationPrice = - unitWithProration.getOrThrow("unitWithProration") + override fun visitAmountDiscount(amountDiscount: NewAmountDiscount) { + amountDiscount.validate() + } - fun asGroupedAllocation(): NewPlanGroupedAllocationPrice = - groupedAllocation.getOrThrow("groupedAllocation") + override fun visitMinimum(minimum: NewMinimum) { + minimum.validate() + } - fun asGroupedWithProratedMinimum(): NewPlanGroupedWithProratedMinimumPrice = - groupedWithProratedMinimum.getOrThrow("groupedWithProratedMinimum") + override fun visitMaximum(maximum: NewMaximum) { + maximum.validate() + } + } + ) + validated = true + } - fun asGroupedWithMeteredMinimum(): NewPlanGroupedWithMeteredMinimumPrice = - groupedWithMeteredMinimum.getOrThrow("groupedWithMeteredMinimum") + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - fun asMatrixWithDisplayName(): NewPlanMatrixWithDisplayNamePrice = - matrixWithDisplayName.getOrThrow("matrixWithDisplayName") + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitPercentageDiscount( + percentageDiscount: NewPercentageDiscount + ) = percentageDiscount.validity() - fun asBulkWithProration(): NewPlanBulkWithProrationPrice = - bulkWithProration.getOrThrow("bulkWithProration") + override fun visitUsageDiscount(usageDiscount: NewUsageDiscount) = + usageDiscount.validity() - fun asGroupedTieredPackage(): NewPlanGroupedTieredPackagePrice = - groupedTieredPackage.getOrThrow("groupedTieredPackage") + override fun visitAmountDiscount(amountDiscount: NewAmountDiscount) = + amountDiscount.validity() - fun asMaxGroupTieredPackage(): NewPlanMaxGroupTieredPackagePrice = - maxGroupTieredPackage.getOrThrow("maxGroupTieredPackage") + override fun visitMinimum(minimum: NewMinimum) = minimum.validity() - fun asScalableMatrixWithUnitPricing(): NewPlanScalableMatrixWithUnitPricingPrice = - scalableMatrixWithUnitPricing.getOrThrow("scalableMatrixWithUnitPricing") - - fun asScalableMatrixWithTieredPricing(): NewPlanScalableMatrixWithTieredPricingPrice = - scalableMatrixWithTieredPricing.getOrThrow("scalableMatrixWithTieredPricing") - - fun asCumulativeGroupedBulk(): NewPlanCumulativeGroupedBulkPrice = - cumulativeGroupedBulk.getOrThrow("cumulativeGroupedBulk") + override fun visitMaximum(maximum: NewMaximum) = maximum.validity() - fun asTieredPackageWithMinimum(): NewPlanTieredPackageWithMinimumPrice = - tieredPackageWithMinimum.getOrThrow("tieredPackageWithMinimum") + override fun unknown(json: JsonValue?) = 0 + } + ) - fun asMatrixWithAllocation(): NewPlanMatrixWithAllocationPrice = - matrixWithAllocation.getOrThrow("matrixWithAllocation") + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun asGroupedTiered(): NewPlanGroupedTieredPrice = - groupedTiered.getOrThrow("groupedTiered") + return other is Adjustment && + percentageDiscount == other.percentageDiscount && + usageDiscount == other.usageDiscount && + amountDiscount == other.amountDiscount && + minimum == other.minimum && + maximum == other.maximum + } - fun _json(): JsonValue? = _json + override fun hashCode(): Int = + Objects.hash(percentageDiscount, usageDiscount, amountDiscount, minimum, maximum) - fun accept(visitor: Visitor): T = + override fun toString(): String = when { - unit != null -> visitor.visitUnit(unit) - package_ != null -> visitor.visitPackage(package_) - matrix != null -> visitor.visitMatrix(matrix) - tiered != null -> visitor.visitTiered(tiered) - tieredBps != null -> visitor.visitTieredBps(tieredBps) - bps != null -> visitor.visitBps(bps) - bulkBps != null -> visitor.visitBulkBps(bulkBps) - bulk != null -> visitor.visitBulk(bulk) - thresholdTotalAmount != null -> - visitor.visitThresholdTotalAmount(thresholdTotalAmount) - tieredPackage != null -> visitor.visitTieredPackage(tieredPackage) - tieredWithMinimum != null -> visitor.visitTieredWithMinimum(tieredWithMinimum) - unitWithPercent != null -> visitor.visitUnitWithPercent(unitWithPercent) - packageWithAllocation != null -> - visitor.visitPackageWithAllocation(packageWithAllocation) - tieredWithProration != null -> - visitor.visitTieredWithProration(tieredWithProration) - unitWithProration != null -> visitor.visitUnitWithProration(unitWithProration) - groupedAllocation != null -> visitor.visitGroupedAllocation(groupedAllocation) - groupedWithProratedMinimum != null -> - visitor.visitGroupedWithProratedMinimum(groupedWithProratedMinimum) - groupedWithMeteredMinimum != null -> - visitor.visitGroupedWithMeteredMinimum(groupedWithMeteredMinimum) - matrixWithDisplayName != null -> - visitor.visitMatrixWithDisplayName(matrixWithDisplayName) - bulkWithProration != null -> visitor.visitBulkWithProration(bulkWithProration) - groupedTieredPackage != null -> - visitor.visitGroupedTieredPackage(groupedTieredPackage) - maxGroupTieredPackage != null -> - visitor.visitMaxGroupTieredPackage(maxGroupTieredPackage) - scalableMatrixWithUnitPricing != null -> - visitor.visitScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing) - scalableMatrixWithTieredPricing != null -> - visitor.visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing - ) - cumulativeGroupedBulk != null -> - visitor.visitCumulativeGroupedBulk(cumulativeGroupedBulk) - tieredPackageWithMinimum != null -> - visitor.visitTieredPackageWithMinimum(tieredPackageWithMinimum) - matrixWithAllocation != null -> - visitor.visitMatrixWithAllocation(matrixWithAllocation) - groupedTiered != null -> visitor.visitGroupedTiered(groupedTiered) - else -> visitor.unknown(_json) + percentageDiscount != null -> + "Adjustment{percentageDiscount=$percentageDiscount}" + usageDiscount != null -> "Adjustment{usageDiscount=$usageDiscount}" + amountDiscount != null -> "Adjustment{amountDiscount=$amountDiscount}" + minimum != null -> "Adjustment{minimum=$minimum}" + maximum != null -> "Adjustment{maximum=$maximum}" + _json != null -> "Adjustment{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Adjustment") } - private var validated: Boolean = false + companion object { - fun validate(): Price = apply { - if (validated) { - return@apply - } + fun ofPercentageDiscount(percentageDiscount: NewPercentageDiscount) = + Adjustment(percentageDiscount = percentageDiscount) - accept( - object : Visitor { - override fun visitUnit(unit: NewPlanUnitPrice) { - unit.validate() - } + fun ofUsageDiscount(usageDiscount: NewUsageDiscount) = + Adjustment(usageDiscount = usageDiscount) - override fun visitPackage(package_: NewPlanPackagePrice) { - package_.validate() - } + fun ofAmountDiscount(amountDiscount: NewAmountDiscount) = + Adjustment(amountDiscount = amountDiscount) - override fun visitMatrix(matrix: NewPlanMatrixPrice) { - matrix.validate() - } + fun ofMinimum(minimum: NewMinimum) = Adjustment(minimum = minimum) - override fun visitTiered(tiered: NewPlanTieredPrice) { - tiered.validate() - } + fun ofMaximum(maximum: NewMaximum) = Adjustment(maximum = maximum) + } - override fun visitTieredBps(tieredBps: NewPlanTieredBpsPrice) { - tieredBps.validate() - } + /** + * An interface that defines how to map each variant of [Adjustment] to a value of type + * [T]. + */ + interface Visitor { - override fun visitBps(bps: NewPlanBpsPrice) { - bps.validate() - } + fun visitPercentageDiscount(percentageDiscount: NewPercentageDiscount): T - override fun visitBulkBps(bulkBps: NewPlanBulkBpsPrice) { - bulkBps.validate() - } + fun visitUsageDiscount(usageDiscount: NewUsageDiscount): T - override fun visitBulk(bulk: NewPlanBulkPrice) { - bulk.validate() - } + fun visitAmountDiscount(amountDiscount: NewAmountDiscount): T - override fun visitThresholdTotalAmount( - thresholdTotalAmount: NewPlanThresholdTotalAmountPrice - ) { - thresholdTotalAmount.validate() - } + fun visitMinimum(minimum: NewMinimum): T - override fun visitTieredPackage(tieredPackage: NewPlanTieredPackagePrice) { - tieredPackage.validate() - } + fun visitMaximum(maximum: NewMaximum): T - override fun visitTieredWithMinimum( - tieredWithMinimum: NewPlanTieredWithMinimumPrice - ) { - tieredWithMinimum.validate() - } + /** + * Maps an unknown variant of [Adjustment] to a value of type [T]. + * + * An instance of [Adjustment] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the + * SDK is unaware of. + * + * @throws OrbInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw OrbInvalidDataException("Unknown Adjustment: $json") + } + } - override fun visitUnitWithPercent( - unitWithPercent: NewPlanUnitWithPercentPrice - ) { - unitWithPercent.validate() - } + internal class Deserializer : BaseDeserializer(Adjustment::class) { - override fun visitPackageWithAllocation( - packageWithAllocation: NewPlanPackageWithAllocationPrice - ) { - packageWithAllocation.validate() - } + override fun ObjectCodec.deserialize(node: JsonNode): Adjustment { + val json = JsonValue.fromJsonNode(node) + val adjustmentType = json.asObject()?.get("adjustment_type")?.asString() - override fun visitTieredWithProration( - tieredWithProration: NewPlanTierWithProrationPrice - ) { - tieredWithProration.validate() + when (adjustmentType) { + "percentage_discount" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Adjustment(percentageDiscount = it, _json = json) } + ?: Adjustment(_json = json) } - - override fun visitUnitWithProration( - unitWithProration: NewPlanUnitWithProrationPrice - ) { - unitWithProration.validate() + "usage_discount" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(usageDiscount = it, _json = json) + } ?: Adjustment(_json = json) } - - override fun visitGroupedAllocation( - groupedAllocation: NewPlanGroupedAllocationPrice - ) { - groupedAllocation.validate() + "amount_discount" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(amountDiscount = it, _json = json) + } ?: Adjustment(_json = json) } - - override fun visitGroupedWithProratedMinimum( - groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice - ) { - groupedWithProratedMinimum.validate() + "minimum" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(minimum = it, _json = json) + } ?: Adjustment(_json = json) } - - override fun visitGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice - ) { - groupedWithMeteredMinimum.validate() + "maximum" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(maximum = it, _json = json) + } ?: Adjustment(_json = json) } + } - override fun visitMatrixWithDisplayName( - matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice - ) { - matrixWithDisplayName.validate() - } + return Adjustment(_json = json) + } + } - override fun visitBulkWithProration( - bulkWithProration: NewPlanBulkWithProrationPrice - ) { - bulkWithProration.validate() - } + internal class Serializer : BaseSerializer(Adjustment::class) { - override fun visitGroupedTieredPackage( - groupedTieredPackage: NewPlanGroupedTieredPackagePrice - ) { - groupedTieredPackage.validate() - } + override fun serialize( + value: Adjustment, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.percentageDiscount != null -> + generator.writeObject(value.percentageDiscount) + value.usageDiscount != null -> generator.writeObject(value.usageDiscount) + value.amountDiscount != null -> generator.writeObject(value.amountDiscount) + value.minimum != null -> generator.writeObject(value.minimum) + value.maximum != null -> generator.writeObject(value.maximum) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Adjustment") + } + } + } + } - override fun visitMaxGroupTieredPackage( - maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice - ) { - maxGroupTieredPackage.validate() - } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - override fun visitScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice - ) { - scalableMatrixWithUnitPricing.validate() - } + return other is ReplaceAdjustment && + adjustment == other.adjustment && + replacesAdjustmentId == other.replacesAdjustmentId && + planPhaseOrder == other.planPhaseOrder && + additionalProperties == other.additionalProperties + } - override fun visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: - NewPlanScalableMatrixWithTieredPricingPrice - ) { - scalableMatrixWithTieredPricing.validate() - } + private val hashCode: Int by lazy { + Objects.hash(adjustment, replacesAdjustmentId, planPhaseOrder, additionalProperties) + } - override fun visitCumulativeGroupedBulk( - cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice - ) { - cumulativeGroupedBulk.validate() - } + override fun hashCode(): Int = hashCode - override fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice - ) { - tieredPackageWithMinimum.validate() - } + override fun toString() = + "ReplaceAdjustment{adjustment=$adjustment, replacesAdjustmentId=$replacesAdjustmentId, planPhaseOrder=$planPhaseOrder, additionalProperties=$additionalProperties}" + } - override fun visitMatrixWithAllocation( - matrixWithAllocation: NewPlanMatrixWithAllocationPrice - ) { - matrixWithAllocation.validate() - } + class ReplacePrice + private constructor( + private val replacesPriceId: JsonField, + private val allocationPrice: JsonField, + private val planPhaseOrder: JsonField, + private val price: JsonField, + private val additionalProperties: MutableMap, + ) { - override fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) { - groupedTiered.validate() - } - } - ) - validated = true - } + @JsonCreator + private constructor( + @JsonProperty("replaces_price_id") + @ExcludeMissing + replacesPriceId: JsonField = JsonMissing.of(), + @JsonProperty("allocation_price") + @ExcludeMissing + allocationPrice: JsonField = JsonMissing.of(), + @JsonProperty("plan_phase_order") + @ExcludeMissing + planPhaseOrder: JsonField = JsonMissing.of(), + @JsonProperty("price") @ExcludeMissing price: JsonField = JsonMissing.of(), + ) : this(replacesPriceId, allocationPrice, planPhaseOrder, price, mutableMapOf()) - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** + * The id of the price on the plan to replace in the plan. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun replacesPriceId(): String = replacesPriceId.getRequired("replaces_price_id") - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: NewPlanUnitPrice) = unit.validity() + /** + * The allocation price to add to the plan. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun allocationPrice(): NewAllocationPrice? = allocationPrice.getNullable("allocation_price") - override fun visitPackage(package_: NewPlanPackagePrice) = - package_.validity() + /** + * The phase to replace this price from. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun planPhaseOrder(): Long? = planPhaseOrder.getNullable("plan_phase_order") - override fun visitMatrix(matrix: NewPlanMatrixPrice) = matrix.validity() + /** + * The price to add to the plan + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun price(): Price? = price.getNullable("price") - override fun visitTiered(tiered: NewPlanTieredPrice) = tiered.validity() + /** + * Returns the raw JSON value of [replacesPriceId]. + * + * Unlike [replacesPriceId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("replaces_price_id") + @ExcludeMissing + fun _replacesPriceId(): JsonField = replacesPriceId - override fun visitTieredBps(tieredBps: NewPlanTieredBpsPrice) = - tieredBps.validity() + /** + * Returns the raw JSON value of [allocationPrice]. + * + * Unlike [allocationPrice], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("allocation_price") + @ExcludeMissing + fun _allocationPrice(): JsonField = allocationPrice - override fun visitBps(bps: NewPlanBpsPrice) = bps.validity() + /** + * Returns the raw JSON value of [planPhaseOrder]. + * + * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder - override fun visitBulkBps(bulkBps: NewPlanBulkBpsPrice) = bulkBps.validity() + /** + * Returns the raw JSON value of [price]. + * + * Unlike [price], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("price") @ExcludeMissing fun _price(): JsonField = price - override fun visitBulk(bulk: NewPlanBulkPrice) = bulk.validity() + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - override fun visitThresholdTotalAmount( - thresholdTotalAmount: NewPlanThresholdTotalAmountPrice - ) = thresholdTotalAmount.validity() + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - override fun visitTieredPackage(tieredPackage: NewPlanTieredPackagePrice) = - tieredPackage.validity() + fun toBuilder() = Builder().from(this) - override fun visitTieredWithMinimum( - tieredWithMinimum: NewPlanTieredWithMinimumPrice - ) = tieredWithMinimum.validity() + companion object { - override fun visitUnitWithPercent( - unitWithPercent: NewPlanUnitWithPercentPrice - ) = unitWithPercent.validity() + /** + * Returns a mutable builder for constructing an instance of [ReplacePrice]. + * + * The following fields are required: + * ```kotlin + * .replacesPriceId() + * ``` + */ + fun builder() = Builder() + } - override fun visitPackageWithAllocation( - packageWithAllocation: NewPlanPackageWithAllocationPrice - ) = packageWithAllocation.validity() + /** A builder for [ReplacePrice]. */ + class Builder internal constructor() { - override fun visitTieredWithProration( - tieredWithProration: NewPlanTierWithProrationPrice - ) = tieredWithProration.validity() + private var replacesPriceId: JsonField? = null + private var allocationPrice: JsonField = JsonMissing.of() + private var planPhaseOrder: JsonField = JsonMissing.of() + private var price: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - override fun visitUnitWithProration( - unitWithProration: NewPlanUnitWithProrationPrice - ) = unitWithProration.validity() + internal fun from(replacePrice: ReplacePrice) = apply { + replacesPriceId = replacePrice.replacesPriceId + allocationPrice = replacePrice.allocationPrice + planPhaseOrder = replacePrice.planPhaseOrder + price = replacePrice.price + additionalProperties = replacePrice.additionalProperties.toMutableMap() + } - override fun visitGroupedAllocation( - groupedAllocation: NewPlanGroupedAllocationPrice - ) = groupedAllocation.validity() + /** The id of the price on the plan to replace in the plan. */ + fun replacesPriceId(replacesPriceId: String) = + replacesPriceId(JsonField.of(replacesPriceId)) - override fun visitGroupedWithProratedMinimum( - groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice - ) = groupedWithProratedMinimum.validity() + /** + * Sets [Builder.replacesPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.replacesPriceId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun replacesPriceId(replacesPriceId: JsonField) = apply { + this.replacesPriceId = replacesPriceId + } - override fun visitGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice - ) = groupedWithMeteredMinimum.validity() + /** The allocation price to add to the plan. */ + fun allocationPrice(allocationPrice: NewAllocationPrice?) = + allocationPrice(JsonField.ofNullable(allocationPrice)) - override fun visitMatrixWithDisplayName( - matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice - ) = matrixWithDisplayName.validity() + /** + * Sets [Builder.allocationPrice] to an arbitrary JSON value. + * + * You should usually call [Builder.allocationPrice] with a well-typed + * [NewAllocationPrice] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun allocationPrice(allocationPrice: JsonField) = apply { + this.allocationPrice = allocationPrice + } - override fun visitBulkWithProration( - bulkWithProration: NewPlanBulkWithProrationPrice - ) = bulkWithProration.validity() + /** The phase to replace this price from. */ + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) - override fun visitGroupedTieredPackage( - groupedTieredPackage: NewPlanGroupedTieredPackagePrice - ) = groupedTieredPackage.validity() + /** + * Alias for [Builder.planPhaseOrder]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) - override fun visitMaxGroupTieredPackage( - maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice - ) = maxGroupTieredPackage.validity() + /** + * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. + * + * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun planPhaseOrder(planPhaseOrder: JsonField) = apply { + this.planPhaseOrder = planPhaseOrder + } - override fun visitScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice - ) = scalableMatrixWithUnitPricing.validity() + /** The price to add to the plan */ + fun price(price: Price?) = price(JsonField.ofNullable(price)) - override fun visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: - NewPlanScalableMatrixWithTieredPricingPrice - ) = scalableMatrixWithTieredPricing.validity() + /** + * Sets [Builder.price] to an arbitrary JSON value. + * + * You should usually call [Builder.price] with a well-typed [Price] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun price(price: JsonField) = apply { this.price = price } - override fun visitCumulativeGroupedBulk( - cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice - ) = cumulativeGroupedBulk.validity() + /** Alias for calling [price] with `Price.ofUnit(unit)`. */ + fun price(unit: NewPlanUnitPrice) = price(Price.ofUnit(unit)) - override fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice - ) = tieredPackageWithMinimum.validity() + /** Alias for calling [price] with `Price.ofPackage(package_)`. */ + fun price(package_: NewPlanPackagePrice) = price(Price.ofPackage(package_)) - override fun visitMatrixWithAllocation( - matrixWithAllocation: NewPlanMatrixWithAllocationPrice - ) = matrixWithAllocation.validity() + /** Alias for calling [price] with `Price.ofMatrix(matrix)`. */ + fun price(matrix: NewPlanMatrixPrice) = price(Price.ofMatrix(matrix)) - override fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) = - groupedTiered.validity() + /** Alias for calling [price] with `Price.ofTiered(tiered)`. */ + fun price(tiered: NewPlanTieredPrice) = price(Price.ofTiered(tiered)) - override fun unknown(json: JsonValue?) = 0 - } - ) + /** Alias for calling [price] with `Price.ofBulk(bulk)`. */ + fun price(bulk: NewPlanBulkPrice) = price(Price.ofBulk(bulk)) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * Alias for calling [price] with `Price.ofThresholdTotalAmount(thresholdTotalAmount)`. + */ + fun price(thresholdTotalAmount: NewPlanThresholdTotalAmountPrice) = + price(Price.ofThresholdTotalAmount(thresholdTotalAmount)) - return other is Price && - unit == other.unit && - package_ == other.package_ && - matrix == other.matrix && - tiered == other.tiered && - tieredBps == other.tieredBps && - bps == other.bps && - bulkBps == other.bulkBps && - bulk == other.bulk && - thresholdTotalAmount == other.thresholdTotalAmount && - tieredPackage == other.tieredPackage && - tieredWithMinimum == other.tieredWithMinimum && - unitWithPercent == other.unitWithPercent && - packageWithAllocation == other.packageWithAllocation && - tieredWithProration == other.tieredWithProration && - unitWithProration == other.unitWithProration && - groupedAllocation == other.groupedAllocation && - groupedWithProratedMinimum == other.groupedWithProratedMinimum && - groupedWithMeteredMinimum == other.groupedWithMeteredMinimum && - matrixWithDisplayName == other.matrixWithDisplayName && - bulkWithProration == other.bulkWithProration && - groupedTieredPackage == other.groupedTieredPackage && - maxGroupTieredPackage == other.maxGroupTieredPackage && - scalableMatrixWithUnitPricing == other.scalableMatrixWithUnitPricing && - scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && - cumulativeGroupedBulk == other.cumulativeGroupedBulk && - tieredPackageWithMinimum == other.tieredPackageWithMinimum && - matrixWithAllocation == other.matrixWithAllocation && - groupedTiered == other.groupedTiered - } + /** Alias for calling [price] with `Price.ofTieredPackage(tieredPackage)`. */ + fun price(tieredPackage: NewPlanTieredPackagePrice) = + price(Price.ofTieredPackage(tieredPackage)) - override fun hashCode(): Int = - Objects.hash( - unit, - package_, - matrix, - tiered, - tieredBps, - bps, - bulkBps, - bulk, - thresholdTotalAmount, - tieredPackage, - tieredWithMinimum, - unitWithPercent, - packageWithAllocation, - tieredWithProration, - unitWithProration, - groupedAllocation, - groupedWithProratedMinimum, - groupedWithMeteredMinimum, - matrixWithDisplayName, - bulkWithProration, - groupedTieredPackage, - maxGroupTieredPackage, - scalableMatrixWithUnitPricing, - scalableMatrixWithTieredPricing, - cumulativeGroupedBulk, - tieredPackageWithMinimum, - matrixWithAllocation, - groupedTiered, - ) + /** Alias for calling [price] with `Price.ofTieredWithMinimum(tieredWithMinimum)`. */ + fun price(tieredWithMinimum: NewPlanTieredWithMinimumPrice) = + price(Price.ofTieredWithMinimum(tieredWithMinimum)) - override fun toString(): String = - when { - unit != null -> "Price{unit=$unit}" - package_ != null -> "Price{package_=$package_}" - matrix != null -> "Price{matrix=$matrix}" - tiered != null -> "Price{tiered=$tiered}" - tieredBps != null -> "Price{tieredBps=$tieredBps}" - bps != null -> "Price{bps=$bps}" - bulkBps != null -> "Price{bulkBps=$bulkBps}" - bulk != null -> "Price{bulk=$bulk}" - thresholdTotalAmount != null -> - "Price{thresholdTotalAmount=$thresholdTotalAmount}" - tieredPackage != null -> "Price{tieredPackage=$tieredPackage}" - tieredWithMinimum != null -> "Price{tieredWithMinimum=$tieredWithMinimum}" - unitWithPercent != null -> "Price{unitWithPercent=$unitWithPercent}" - packageWithAllocation != null -> - "Price{packageWithAllocation=$packageWithAllocation}" - tieredWithProration != null -> "Price{tieredWithProration=$tieredWithProration}" - unitWithProration != null -> "Price{unitWithProration=$unitWithProration}" - groupedAllocation != null -> "Price{groupedAllocation=$groupedAllocation}" - groupedWithProratedMinimum != null -> - "Price{groupedWithProratedMinimum=$groupedWithProratedMinimum}" - groupedWithMeteredMinimum != null -> - "Price{groupedWithMeteredMinimum=$groupedWithMeteredMinimum}" - matrixWithDisplayName != null -> - "Price{matrixWithDisplayName=$matrixWithDisplayName}" - bulkWithProration != null -> "Price{bulkWithProration=$bulkWithProration}" - groupedTieredPackage != null -> - "Price{groupedTieredPackage=$groupedTieredPackage}" - maxGroupTieredPackage != null -> - "Price{maxGroupTieredPackage=$maxGroupTieredPackage}" - scalableMatrixWithUnitPricing != null -> - "Price{scalableMatrixWithUnitPricing=$scalableMatrixWithUnitPricing}" - scalableMatrixWithTieredPricing != null -> - "Price{scalableMatrixWithTieredPricing=$scalableMatrixWithTieredPricing}" - cumulativeGroupedBulk != null -> - "Price{cumulativeGroupedBulk=$cumulativeGroupedBulk}" - tieredPackageWithMinimum != null -> - "Price{tieredPackageWithMinimum=$tieredPackageWithMinimum}" - matrixWithAllocation != null -> - "Price{matrixWithAllocation=$matrixWithAllocation}" - groupedTiered != null -> "Price{groupedTiered=$groupedTiered}" - _json != null -> "Price{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Price") - } + /** Alias for calling [price] with `Price.ofUnitWithPercent(unitWithPercent)`. */ + fun price(unitWithPercent: NewPlanUnitWithPercentPrice) = + price(Price.ofUnitWithPercent(unitWithPercent)) - companion object { + /** + * Alias for calling [price] with + * `Price.ofPackageWithAllocation(packageWithAllocation)`. + */ + fun price(packageWithAllocation: NewPlanPackageWithAllocationPrice) = + price(Price.ofPackageWithAllocation(packageWithAllocation)) - fun ofUnit(unit: NewPlanUnitPrice) = Price(unit = unit) + /** + * Alias for calling [price] with `Price.ofTieredWithProration(tieredWithProration)`. + */ + fun price(tieredWithProration: NewPlanTierWithProrationPrice) = + price(Price.ofTieredWithProration(tieredWithProration)) - fun ofPackage(package_: NewPlanPackagePrice) = Price(package_ = package_) + /** Alias for calling [price] with `Price.ofUnitWithProration(unitWithProration)`. */ + fun price(unitWithProration: NewPlanUnitWithProrationPrice) = + price(Price.ofUnitWithProration(unitWithProration)) - fun ofMatrix(matrix: NewPlanMatrixPrice) = Price(matrix = matrix) + /** Alias for calling [price] with `Price.ofGroupedAllocation(groupedAllocation)`. */ + fun price(groupedAllocation: NewPlanGroupedAllocationPrice) = + price(Price.ofGroupedAllocation(groupedAllocation)) - fun ofTiered(tiered: NewPlanTieredPrice) = Price(tiered = tiered) + /** + * Alias for calling [price] with + * `Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)`. + */ + fun price(groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice) = + price(Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)) - fun ofTieredBps(tieredBps: NewPlanTieredBpsPrice) = Price(tieredBps = tieredBps) + /** + * Alias for calling [price] with + * `Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)`. + */ + fun price(groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice) = + price(Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)) - fun ofBps(bps: NewPlanBpsPrice) = Price(bps = bps) + /** + * Alias for calling [price] with + * `Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)`. + */ + fun price(groupedWithMinMaxThresholds: Price.GroupedWithMinMaxThresholds) = + price(Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)) - fun ofBulkBps(bulkBps: NewPlanBulkBpsPrice) = Price(bulkBps = bulkBps) + /** + * Alias for calling [price] with + * `Price.ofMatrixWithDisplayName(matrixWithDisplayName)`. + */ + fun price(matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice) = + price(Price.ofMatrixWithDisplayName(matrixWithDisplayName)) - fun ofBulk(bulk: NewPlanBulkPrice) = Price(bulk = bulk) + /** Alias for calling [price] with `Price.ofBulkWithProration(bulkWithProration)`. */ + fun price(bulkWithProration: NewPlanBulkWithProrationPrice) = + price(Price.ofBulkWithProration(bulkWithProration)) - fun ofThresholdTotalAmount(thresholdTotalAmount: NewPlanThresholdTotalAmountPrice) = - Price(thresholdTotalAmount = thresholdTotalAmount) + /** + * Alias for calling [price] with `Price.ofGroupedTieredPackage(groupedTieredPackage)`. + */ + fun price(groupedTieredPackage: NewPlanGroupedTieredPackagePrice) = + price(Price.ofGroupedTieredPackage(groupedTieredPackage)) - fun ofTieredPackage(tieredPackage: NewPlanTieredPackagePrice) = - Price(tieredPackage = tieredPackage) + /** + * Alias for calling [price] with + * `Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)`. + */ + fun price(maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice) = + price(Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)) - fun ofTieredWithMinimum(tieredWithMinimum: NewPlanTieredWithMinimumPrice) = - Price(tieredWithMinimum = tieredWithMinimum) + /** + * Alias for calling [price] with + * `Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)`. + */ + fun price(scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice) = + price(Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)) - fun ofUnitWithPercent(unitWithPercent: NewPlanUnitWithPercentPrice) = - Price(unitWithPercent = unitWithPercent) + /** + * Alias for calling [price] with + * `Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)`. + */ + fun price( + scalableMatrixWithTieredPricing: NewPlanScalableMatrixWithTieredPricingPrice + ) = price(Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)) - fun ofPackageWithAllocation( - packageWithAllocation: NewPlanPackageWithAllocationPrice - ) = Price(packageWithAllocation = packageWithAllocation) - - fun ofTieredWithProration(tieredWithProration: NewPlanTierWithProrationPrice) = - Price(tieredWithProration = tieredWithProration) + /** + * Alias for calling [price] with + * `Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)`. + */ + fun price(cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice) = + price(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) - fun ofUnitWithProration(unitWithProration: NewPlanUnitWithProrationPrice) = - Price(unitWithProration = unitWithProration) + /** + * Alias for calling [price] with + * `Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)`. + */ + fun price(tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice) = + price(Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)) - fun ofGroupedAllocation(groupedAllocation: NewPlanGroupedAllocationPrice) = - Price(groupedAllocation = groupedAllocation) + /** + * Alias for calling [price] with `Price.ofMatrixWithAllocation(matrixWithAllocation)`. + */ + fun price(matrixWithAllocation: NewPlanMatrixWithAllocationPrice) = + price(Price.ofMatrixWithAllocation(matrixWithAllocation)) - fun ofGroupedWithProratedMinimum( - groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice - ) = Price(groupedWithProratedMinimum = groupedWithProratedMinimum) + /** Alias for calling [price] with `Price.ofGroupedTiered(groupedTiered)`. */ + fun price(groupedTiered: NewPlanGroupedTieredPrice) = + price(Price.ofGroupedTiered(groupedTiered)) - fun ofGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice - ) = Price(groupedWithMeteredMinimum = groupedWithMeteredMinimum) + /** Alias for calling [price] with `Price.ofMinimum(minimum)`. */ + fun price(minimum: Price.Minimum) = price(Price.ofMinimum(minimum)) - fun ofMatrixWithDisplayName( - matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice - ) = Price(matrixWithDisplayName = matrixWithDisplayName) + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun ofBulkWithProration(bulkWithProration: NewPlanBulkWithProrationPrice) = - Price(bulkWithProration = bulkWithProration) + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun ofGroupedTieredPackage(groupedTieredPackage: NewPlanGroupedTieredPackagePrice) = - Price(groupedTieredPackage = groupedTieredPackage) + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun ofMaxGroupTieredPackage( - maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice - ) = Price(maxGroupTieredPackage = maxGroupTieredPackage) + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - fun ofScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice - ) = Price(scalableMatrixWithUnitPricing = scalableMatrixWithUnitPricing) + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - fun ofScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: NewPlanScalableMatrixWithTieredPricingPrice - ) = Price(scalableMatrixWithTieredPricing = scalableMatrixWithTieredPricing) + /** + * Returns an immutable instance of [ReplacePrice]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .replacesPriceId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ReplacePrice = + ReplacePrice( + checkRequired("replacesPriceId", replacesPriceId), + allocationPrice, + planPhaseOrder, + price, + additionalProperties.toMutableMap(), + ) + } - fun ofCumulativeGroupedBulk( - cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice - ) = Price(cumulativeGroupedBulk = cumulativeGroupedBulk) + private var validated: Boolean = false - fun ofTieredPackageWithMinimum( - tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice - ) = Price(tieredPackageWithMinimum = tieredPackageWithMinimum) + fun validate(): ReplacePrice = apply { + if (validated) { + return@apply + } - fun ofMatrixWithAllocation(matrixWithAllocation: NewPlanMatrixWithAllocationPrice) = - Price(matrixWithAllocation = matrixWithAllocation) + replacesPriceId() + allocationPrice()?.validate() + planPhaseOrder() + price()?.validate() + validated = true + } - fun ofGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) = - Price(groupedTiered = groupedTiered) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false } - /** - * An interface that defines how to map each variant of [Price] to a value of type [T]. - */ - interface Visitor { + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (replacesPriceId.asKnown() == null) 0 else 1) + + (allocationPrice.asKnown()?.validity() ?: 0) + + (if (planPhaseOrder.asKnown() == null) 0 else 1) + + (price.asKnown()?.validity() ?: 0) - fun visitUnit(unit: NewPlanUnitPrice): T + /** The price to add to the plan */ + @JsonDeserialize(using = Price.Deserializer::class) + @JsonSerialize(using = Price.Serializer::class) + class Price + private constructor( + private val unit: NewPlanUnitPrice? = null, + private val package_: NewPlanPackagePrice? = null, + private val matrix: NewPlanMatrixPrice? = null, + private val tiered: NewPlanTieredPrice? = null, + private val bulk: NewPlanBulkPrice? = null, + private val thresholdTotalAmount: NewPlanThresholdTotalAmountPrice? = null, + private val tieredPackage: NewPlanTieredPackagePrice? = null, + private val tieredWithMinimum: NewPlanTieredWithMinimumPrice? = null, + private val unitWithPercent: NewPlanUnitWithPercentPrice? = null, + private val packageWithAllocation: NewPlanPackageWithAllocationPrice? = null, + private val tieredWithProration: NewPlanTierWithProrationPrice? = null, + private val unitWithProration: NewPlanUnitWithProrationPrice? = null, + private val groupedAllocation: NewPlanGroupedAllocationPrice? = null, + private val groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice? = null, + private val groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice? = null, + private val groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds? = null, + private val matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice? = null, + private val bulkWithProration: NewPlanBulkWithProrationPrice? = null, + private val groupedTieredPackage: NewPlanGroupedTieredPackagePrice? = null, + private val maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice? = null, + private val scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice? = + null, + private val scalableMatrixWithTieredPricing: + NewPlanScalableMatrixWithTieredPricingPrice? = + null, + private val cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice? = null, + private val tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice? = null, + private val matrixWithAllocation: NewPlanMatrixWithAllocationPrice? = null, + private val groupedTiered: NewPlanGroupedTieredPrice? = null, + private val minimum: Minimum? = null, + private val _json: JsonValue? = null, + ) { - fun visitPackage(package_: NewPlanPackagePrice): T + fun unit(): NewPlanUnitPrice? = unit - fun visitMatrix(matrix: NewPlanMatrixPrice): T + fun package_(): NewPlanPackagePrice? = package_ - fun visitTiered(tiered: NewPlanTieredPrice): T + fun matrix(): NewPlanMatrixPrice? = matrix - fun visitTieredBps(tieredBps: NewPlanTieredBpsPrice): T + fun tiered(): NewPlanTieredPrice? = tiered - fun visitBps(bps: NewPlanBpsPrice): T + fun bulk(): NewPlanBulkPrice? = bulk - fun visitBulkBps(bulkBps: NewPlanBulkBpsPrice): T + fun thresholdTotalAmount(): NewPlanThresholdTotalAmountPrice? = thresholdTotalAmount - fun visitBulk(bulk: NewPlanBulkPrice): T + fun tieredPackage(): NewPlanTieredPackagePrice? = tieredPackage - fun visitThresholdTotalAmount( - thresholdTotalAmount: NewPlanThresholdTotalAmountPrice - ): T + fun tieredWithMinimum(): NewPlanTieredWithMinimumPrice? = tieredWithMinimum - fun visitTieredPackage(tieredPackage: NewPlanTieredPackagePrice): T + fun unitWithPercent(): NewPlanUnitWithPercentPrice? = unitWithPercent - fun visitTieredWithMinimum(tieredWithMinimum: NewPlanTieredWithMinimumPrice): T + fun packageWithAllocation(): NewPlanPackageWithAllocationPrice? = packageWithAllocation - fun visitUnitWithPercent(unitWithPercent: NewPlanUnitWithPercentPrice): T + fun tieredWithProration(): NewPlanTierWithProrationPrice? = tieredWithProration - fun visitPackageWithAllocation( - packageWithAllocation: NewPlanPackageWithAllocationPrice - ): T + fun unitWithProration(): NewPlanUnitWithProrationPrice? = unitWithProration - fun visitTieredWithProration(tieredWithProration: NewPlanTierWithProrationPrice): T + fun groupedAllocation(): NewPlanGroupedAllocationPrice? = groupedAllocation - fun visitUnitWithProration(unitWithProration: NewPlanUnitWithProrationPrice): T + fun groupedWithProratedMinimum(): NewPlanGroupedWithProratedMinimumPrice? = + groupedWithProratedMinimum - fun visitGroupedAllocation(groupedAllocation: NewPlanGroupedAllocationPrice): T + fun groupedWithMeteredMinimum(): NewPlanGroupedWithMeteredMinimumPrice? = + groupedWithMeteredMinimum - fun visitGroupedWithProratedMinimum( - groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice - ): T + fun groupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds? = + groupedWithMinMaxThresholds - fun visitGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice - ): T + fun matrixWithDisplayName(): NewPlanMatrixWithDisplayNamePrice? = matrixWithDisplayName - fun visitMatrixWithDisplayName( - matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice - ): T + fun bulkWithProration(): NewPlanBulkWithProrationPrice? = bulkWithProration - fun visitBulkWithProration(bulkWithProration: NewPlanBulkWithProrationPrice): T + fun groupedTieredPackage(): NewPlanGroupedTieredPackagePrice? = groupedTieredPackage - fun visitGroupedTieredPackage( - groupedTieredPackage: NewPlanGroupedTieredPackagePrice - ): T + fun maxGroupTieredPackage(): NewPlanMaxGroupTieredPackagePrice? = maxGroupTieredPackage - fun visitMaxGroupTieredPackage( - maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice - ): T + fun scalableMatrixWithUnitPricing(): NewPlanScalableMatrixWithUnitPricingPrice? = + scalableMatrixWithUnitPricing - fun visitScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice - ): T + fun scalableMatrixWithTieredPricing(): NewPlanScalableMatrixWithTieredPricingPrice? = + scalableMatrixWithTieredPricing - fun visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: NewPlanScalableMatrixWithTieredPricingPrice - ): T + fun cumulativeGroupedBulk(): NewPlanCumulativeGroupedBulkPrice? = cumulativeGroupedBulk - fun visitCumulativeGroupedBulk( - cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice - ): T + fun tieredPackageWithMinimum(): NewPlanTieredPackageWithMinimumPrice? = + tieredPackageWithMinimum - fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice - ): T + fun matrixWithAllocation(): NewPlanMatrixWithAllocationPrice? = matrixWithAllocation - fun visitMatrixWithAllocation( - matrixWithAllocation: NewPlanMatrixWithAllocationPrice - ): T + fun groupedTiered(): NewPlanGroupedTieredPrice? = groupedTiered - fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice): T + fun minimum(): Minimum? = minimum - /** - * Maps an unknown variant of [Price] to a value of type [T]. - * - * An instance of [Price] can contain an unknown variant if it was deserialized from - * data that doesn't match any known variant. For example, if the SDK is on an older - * version than the API, then the API may respond with new variants that the SDK is - * unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown Price: $json") - } - } + fun isUnit(): Boolean = unit != null - internal class Deserializer : BaseDeserializer(Price::class) { + fun isPackage(): Boolean = package_ != null + + fun isMatrix(): Boolean = matrix != null + + fun isTiered(): Boolean = tiered != null + + fun isBulk(): Boolean = bulk != null + + fun isThresholdTotalAmount(): Boolean = thresholdTotalAmount != null + + fun isTieredPackage(): Boolean = tieredPackage != null + + fun isTieredWithMinimum(): Boolean = tieredWithMinimum != null + + fun isUnitWithPercent(): Boolean = unitWithPercent != null + + fun isPackageWithAllocation(): Boolean = packageWithAllocation != null + + fun isTieredWithProration(): Boolean = tieredWithProration != null + + fun isUnitWithProration(): Boolean = unitWithProration != null + + fun isGroupedAllocation(): Boolean = groupedAllocation != null + + fun isGroupedWithProratedMinimum(): Boolean = groupedWithProratedMinimum != null + + fun isGroupedWithMeteredMinimum(): Boolean = groupedWithMeteredMinimum != null + + fun isGroupedWithMinMaxThresholds(): Boolean = groupedWithMinMaxThresholds != null + + fun isMatrixWithDisplayName(): Boolean = matrixWithDisplayName != null + + fun isBulkWithProration(): Boolean = bulkWithProration != null + + fun isGroupedTieredPackage(): Boolean = groupedTieredPackage != null + + fun isMaxGroupTieredPackage(): Boolean = maxGroupTieredPackage != null + + fun isScalableMatrixWithUnitPricing(): Boolean = scalableMatrixWithUnitPricing != null + + fun isScalableMatrixWithTieredPricing(): Boolean = + scalableMatrixWithTieredPricing != null + + fun isCumulativeGroupedBulk(): Boolean = cumulativeGroupedBulk != null + + fun isTieredPackageWithMinimum(): Boolean = tieredPackageWithMinimum != null + + fun isMatrixWithAllocation(): Boolean = matrixWithAllocation != null + + fun isGroupedTiered(): Boolean = groupedTiered != null + + fun isMinimum(): Boolean = minimum != null + + fun asUnit(): NewPlanUnitPrice = unit.getOrThrow("unit") + + fun asPackage(): NewPlanPackagePrice = package_.getOrThrow("package_") + + fun asMatrix(): NewPlanMatrixPrice = matrix.getOrThrow("matrix") + + fun asTiered(): NewPlanTieredPrice = tiered.getOrThrow("tiered") + + fun asBulk(): NewPlanBulkPrice = bulk.getOrThrow("bulk") + + fun asThresholdTotalAmount(): NewPlanThresholdTotalAmountPrice = + thresholdTotalAmount.getOrThrow("thresholdTotalAmount") + + fun asTieredPackage(): NewPlanTieredPackagePrice = + tieredPackage.getOrThrow("tieredPackage") + + fun asTieredWithMinimum(): NewPlanTieredWithMinimumPrice = + tieredWithMinimum.getOrThrow("tieredWithMinimum") + + fun asUnitWithPercent(): NewPlanUnitWithPercentPrice = + unitWithPercent.getOrThrow("unitWithPercent") + + fun asPackageWithAllocation(): NewPlanPackageWithAllocationPrice = + packageWithAllocation.getOrThrow("packageWithAllocation") + + fun asTieredWithProration(): NewPlanTierWithProrationPrice = + tieredWithProration.getOrThrow("tieredWithProration") + + fun asUnitWithProration(): NewPlanUnitWithProrationPrice = + unitWithProration.getOrThrow("unitWithProration") + + fun asGroupedAllocation(): NewPlanGroupedAllocationPrice = + groupedAllocation.getOrThrow("groupedAllocation") + + fun asGroupedWithProratedMinimum(): NewPlanGroupedWithProratedMinimumPrice = + groupedWithProratedMinimum.getOrThrow("groupedWithProratedMinimum") + + fun asGroupedWithMeteredMinimum(): NewPlanGroupedWithMeteredMinimumPrice = + groupedWithMeteredMinimum.getOrThrow("groupedWithMeteredMinimum") + + fun asGroupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds = + groupedWithMinMaxThresholds.getOrThrow("groupedWithMinMaxThresholds") + + fun asMatrixWithDisplayName(): NewPlanMatrixWithDisplayNamePrice = + matrixWithDisplayName.getOrThrow("matrixWithDisplayName") + + fun asBulkWithProration(): NewPlanBulkWithProrationPrice = + bulkWithProration.getOrThrow("bulkWithProration") + + fun asGroupedTieredPackage(): NewPlanGroupedTieredPackagePrice = + groupedTieredPackage.getOrThrow("groupedTieredPackage") + + fun asMaxGroupTieredPackage(): NewPlanMaxGroupTieredPackagePrice = + maxGroupTieredPackage.getOrThrow("maxGroupTieredPackage") + + fun asScalableMatrixWithUnitPricing(): NewPlanScalableMatrixWithUnitPricingPrice = + scalableMatrixWithUnitPricing.getOrThrow("scalableMatrixWithUnitPricing") + + fun asScalableMatrixWithTieredPricing(): NewPlanScalableMatrixWithTieredPricingPrice = + scalableMatrixWithTieredPricing.getOrThrow("scalableMatrixWithTieredPricing") + + fun asCumulativeGroupedBulk(): NewPlanCumulativeGroupedBulkPrice = + cumulativeGroupedBulk.getOrThrow("cumulativeGroupedBulk") + + fun asTieredPackageWithMinimum(): NewPlanTieredPackageWithMinimumPrice = + tieredPackageWithMinimum.getOrThrow("tieredPackageWithMinimum") + + fun asMatrixWithAllocation(): NewPlanMatrixWithAllocationPrice = + matrixWithAllocation.getOrThrow("matrixWithAllocation") + + fun asGroupedTiered(): NewPlanGroupedTieredPrice = + groupedTiered.getOrThrow("groupedTiered") + + fun asMinimum(): Minimum = minimum.getOrThrow("minimum") + + fun _json(): JsonValue? = _json + + fun accept(visitor: Visitor): T = + when { + unit != null -> visitor.visitUnit(unit) + package_ != null -> visitor.visitPackage(package_) + matrix != null -> visitor.visitMatrix(matrix) + tiered != null -> visitor.visitTiered(tiered) + bulk != null -> visitor.visitBulk(bulk) + thresholdTotalAmount != null -> + visitor.visitThresholdTotalAmount(thresholdTotalAmount) + tieredPackage != null -> visitor.visitTieredPackage(tieredPackage) + tieredWithMinimum != null -> visitor.visitTieredWithMinimum(tieredWithMinimum) + unitWithPercent != null -> visitor.visitUnitWithPercent(unitWithPercent) + packageWithAllocation != null -> + visitor.visitPackageWithAllocation(packageWithAllocation) + tieredWithProration != null -> + visitor.visitTieredWithProration(tieredWithProration) + unitWithProration != null -> visitor.visitUnitWithProration(unitWithProration) + groupedAllocation != null -> visitor.visitGroupedAllocation(groupedAllocation) + groupedWithProratedMinimum != null -> + visitor.visitGroupedWithProratedMinimum(groupedWithProratedMinimum) + groupedWithMeteredMinimum != null -> + visitor.visitGroupedWithMeteredMinimum(groupedWithMeteredMinimum) + groupedWithMinMaxThresholds != null -> + visitor.visitGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds) + matrixWithDisplayName != null -> + visitor.visitMatrixWithDisplayName(matrixWithDisplayName) + bulkWithProration != null -> visitor.visitBulkWithProration(bulkWithProration) + groupedTieredPackage != null -> + visitor.visitGroupedTieredPackage(groupedTieredPackage) + maxGroupTieredPackage != null -> + visitor.visitMaxGroupTieredPackage(maxGroupTieredPackage) + scalableMatrixWithUnitPricing != null -> + visitor.visitScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing) + scalableMatrixWithTieredPricing != null -> + visitor.visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing + ) + cumulativeGroupedBulk != null -> + visitor.visitCumulativeGroupedBulk(cumulativeGroupedBulk) + tieredPackageWithMinimum != null -> + visitor.visitTieredPackageWithMinimum(tieredPackageWithMinimum) + matrixWithAllocation != null -> + visitor.visitMatrixWithAllocation(matrixWithAllocation) + groupedTiered != null -> visitor.visitGroupedTiered(groupedTiered) + minimum != null -> visitor.visitMinimum(minimum) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Price = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitUnit(unit: NewPlanUnitPrice) { + unit.validate() + } + + override fun visitPackage(package_: NewPlanPackagePrice) { + package_.validate() + } + + override fun visitMatrix(matrix: NewPlanMatrixPrice) { + matrix.validate() + } + + override fun visitTiered(tiered: NewPlanTieredPrice) { + tiered.validate() + } + + override fun visitBulk(bulk: NewPlanBulkPrice) { + bulk.validate() + } + + override fun visitThresholdTotalAmount( + thresholdTotalAmount: NewPlanThresholdTotalAmountPrice + ) { + thresholdTotalAmount.validate() + } + + override fun visitTieredPackage(tieredPackage: NewPlanTieredPackagePrice) { + tieredPackage.validate() + } + + override fun visitTieredWithMinimum( + tieredWithMinimum: NewPlanTieredWithMinimumPrice + ) { + tieredWithMinimum.validate() + } + + override fun visitUnitWithPercent( + unitWithPercent: NewPlanUnitWithPercentPrice + ) { + unitWithPercent.validate() + } + + override fun visitPackageWithAllocation( + packageWithAllocation: NewPlanPackageWithAllocationPrice + ) { + packageWithAllocation.validate() + } + + override fun visitTieredWithProration( + tieredWithProration: NewPlanTierWithProrationPrice + ) { + tieredWithProration.validate() + } + + override fun visitUnitWithProration( + unitWithProration: NewPlanUnitWithProrationPrice + ) { + unitWithProration.validate() + } + + override fun visitGroupedAllocation( + groupedAllocation: NewPlanGroupedAllocationPrice + ) { + groupedAllocation.validate() + } + + override fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice + ) { + groupedWithProratedMinimum.validate() + } + + override fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice + ) { + groupedWithMeteredMinimum.validate() + } + + override fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) { + groupedWithMinMaxThresholds.validate() + } + + override fun visitMatrixWithDisplayName( + matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice + ) { + matrixWithDisplayName.validate() + } + + override fun visitBulkWithProration( + bulkWithProration: NewPlanBulkWithProrationPrice + ) { + bulkWithProration.validate() + } + + override fun visitGroupedTieredPackage( + groupedTieredPackage: NewPlanGroupedTieredPackagePrice + ) { + groupedTieredPackage.validate() + } + + override fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice + ) { + maxGroupTieredPackage.validate() + } + + override fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice + ) { + scalableMatrixWithUnitPricing.validate() + } + + override fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: + NewPlanScalableMatrixWithTieredPricingPrice + ) { + scalableMatrixWithTieredPricing.validate() + } + + override fun visitCumulativeGroupedBulk( + cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice + ) { + cumulativeGroupedBulk.validate() + } + + override fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice + ) { + tieredPackageWithMinimum.validate() + } + + override fun visitMatrixWithAllocation( + matrixWithAllocation: NewPlanMatrixWithAllocationPrice + ) { + matrixWithAllocation.validate() + } + + override fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) { + groupedTiered.validate() + } + + override fun visitMinimum(minimum: Minimum) { + minimum.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitUnit(unit: NewPlanUnitPrice) = unit.validity() + + override fun visitPackage(package_: NewPlanPackagePrice) = + package_.validity() + + override fun visitMatrix(matrix: NewPlanMatrixPrice) = matrix.validity() + + override fun visitTiered(tiered: NewPlanTieredPrice) = tiered.validity() + + override fun visitBulk(bulk: NewPlanBulkPrice) = bulk.validity() + + override fun visitThresholdTotalAmount( + thresholdTotalAmount: NewPlanThresholdTotalAmountPrice + ) = thresholdTotalAmount.validity() + + override fun visitTieredPackage(tieredPackage: NewPlanTieredPackagePrice) = + tieredPackage.validity() + + override fun visitTieredWithMinimum( + tieredWithMinimum: NewPlanTieredWithMinimumPrice + ) = tieredWithMinimum.validity() + + override fun visitUnitWithPercent( + unitWithPercent: NewPlanUnitWithPercentPrice + ) = unitWithPercent.validity() + + override fun visitPackageWithAllocation( + packageWithAllocation: NewPlanPackageWithAllocationPrice + ) = packageWithAllocation.validity() + + override fun visitTieredWithProration( + tieredWithProration: NewPlanTierWithProrationPrice + ) = tieredWithProration.validity() + + override fun visitUnitWithProration( + unitWithProration: NewPlanUnitWithProrationPrice + ) = unitWithProration.validity() + + override fun visitGroupedAllocation( + groupedAllocation: NewPlanGroupedAllocationPrice + ) = groupedAllocation.validity() + + override fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice + ) = groupedWithProratedMinimum.validity() + + override fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice + ) = groupedWithMeteredMinimum.validity() + + override fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) = groupedWithMinMaxThresholds.validity() + + override fun visitMatrixWithDisplayName( + matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice + ) = matrixWithDisplayName.validity() + + override fun visitBulkWithProration( + bulkWithProration: NewPlanBulkWithProrationPrice + ) = bulkWithProration.validity() + + override fun visitGroupedTieredPackage( + groupedTieredPackage: NewPlanGroupedTieredPackagePrice + ) = groupedTieredPackage.validity() + + override fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice + ) = maxGroupTieredPackage.validity() + + override fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice + ) = scalableMatrixWithUnitPricing.validity() + + override fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: + NewPlanScalableMatrixWithTieredPricingPrice + ) = scalableMatrixWithTieredPricing.validity() + + override fun visitCumulativeGroupedBulk( + cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice + ) = cumulativeGroupedBulk.validity() + + override fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice + ) = tieredPackageWithMinimum.validity() + + override fun visitMatrixWithAllocation( + matrixWithAllocation: NewPlanMatrixWithAllocationPrice + ) = matrixWithAllocation.validity() + + override fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) = + groupedTiered.validity() + + override fun visitMinimum(minimum: Minimum) = minimum.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Price && + unit == other.unit && + package_ == other.package_ && + matrix == other.matrix && + tiered == other.tiered && + bulk == other.bulk && + thresholdTotalAmount == other.thresholdTotalAmount && + tieredPackage == other.tieredPackage && + tieredWithMinimum == other.tieredWithMinimum && + unitWithPercent == other.unitWithPercent && + packageWithAllocation == other.packageWithAllocation && + tieredWithProration == other.tieredWithProration && + unitWithProration == other.unitWithProration && + groupedAllocation == other.groupedAllocation && + groupedWithProratedMinimum == other.groupedWithProratedMinimum && + groupedWithMeteredMinimum == other.groupedWithMeteredMinimum && + groupedWithMinMaxThresholds == other.groupedWithMinMaxThresholds && + matrixWithDisplayName == other.matrixWithDisplayName && + bulkWithProration == other.bulkWithProration && + groupedTieredPackage == other.groupedTieredPackage && + maxGroupTieredPackage == other.maxGroupTieredPackage && + scalableMatrixWithUnitPricing == other.scalableMatrixWithUnitPricing && + scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && + cumulativeGroupedBulk == other.cumulativeGroupedBulk && + tieredPackageWithMinimum == other.tieredPackageWithMinimum && + matrixWithAllocation == other.matrixWithAllocation && + groupedTiered == other.groupedTiered && + minimum == other.minimum + } + + override fun hashCode(): Int = + Objects.hash( + unit, + package_, + matrix, + tiered, + bulk, + thresholdTotalAmount, + tieredPackage, + tieredWithMinimum, + unitWithPercent, + packageWithAllocation, + tieredWithProration, + unitWithProration, + groupedAllocation, + groupedWithProratedMinimum, + groupedWithMeteredMinimum, + groupedWithMinMaxThresholds, + matrixWithDisplayName, + bulkWithProration, + groupedTieredPackage, + maxGroupTieredPackage, + scalableMatrixWithUnitPricing, + scalableMatrixWithTieredPricing, + cumulativeGroupedBulk, + tieredPackageWithMinimum, + matrixWithAllocation, + groupedTiered, + minimum, + ) + + override fun toString(): String = + when { + unit != null -> "Price{unit=$unit}" + package_ != null -> "Price{package_=$package_}" + matrix != null -> "Price{matrix=$matrix}" + tiered != null -> "Price{tiered=$tiered}" + bulk != null -> "Price{bulk=$bulk}" + thresholdTotalAmount != null -> + "Price{thresholdTotalAmount=$thresholdTotalAmount}" + tieredPackage != null -> "Price{tieredPackage=$tieredPackage}" + tieredWithMinimum != null -> "Price{tieredWithMinimum=$tieredWithMinimum}" + unitWithPercent != null -> "Price{unitWithPercent=$unitWithPercent}" + packageWithAllocation != null -> + "Price{packageWithAllocation=$packageWithAllocation}" + tieredWithProration != null -> "Price{tieredWithProration=$tieredWithProration}" + unitWithProration != null -> "Price{unitWithProration=$unitWithProration}" + groupedAllocation != null -> "Price{groupedAllocation=$groupedAllocation}" + groupedWithProratedMinimum != null -> + "Price{groupedWithProratedMinimum=$groupedWithProratedMinimum}" + groupedWithMeteredMinimum != null -> + "Price{groupedWithMeteredMinimum=$groupedWithMeteredMinimum}" + groupedWithMinMaxThresholds != null -> + "Price{groupedWithMinMaxThresholds=$groupedWithMinMaxThresholds}" + matrixWithDisplayName != null -> + "Price{matrixWithDisplayName=$matrixWithDisplayName}" + bulkWithProration != null -> "Price{bulkWithProration=$bulkWithProration}" + groupedTieredPackage != null -> + "Price{groupedTieredPackage=$groupedTieredPackage}" + maxGroupTieredPackage != null -> + "Price{maxGroupTieredPackage=$maxGroupTieredPackage}" + scalableMatrixWithUnitPricing != null -> + "Price{scalableMatrixWithUnitPricing=$scalableMatrixWithUnitPricing}" + scalableMatrixWithTieredPricing != null -> + "Price{scalableMatrixWithTieredPricing=$scalableMatrixWithTieredPricing}" + cumulativeGroupedBulk != null -> + "Price{cumulativeGroupedBulk=$cumulativeGroupedBulk}" + tieredPackageWithMinimum != null -> + "Price{tieredPackageWithMinimum=$tieredPackageWithMinimum}" + matrixWithAllocation != null -> + "Price{matrixWithAllocation=$matrixWithAllocation}" + groupedTiered != null -> "Price{groupedTiered=$groupedTiered}" + minimum != null -> "Price{minimum=$minimum}" + _json != null -> "Price{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Price") + } + + companion object { + + fun ofUnit(unit: NewPlanUnitPrice) = Price(unit = unit) + + fun ofPackage(package_: NewPlanPackagePrice) = Price(package_ = package_) + + fun ofMatrix(matrix: NewPlanMatrixPrice) = Price(matrix = matrix) + + fun ofTiered(tiered: NewPlanTieredPrice) = Price(tiered = tiered) + + fun ofBulk(bulk: NewPlanBulkPrice) = Price(bulk = bulk) + + fun ofThresholdTotalAmount(thresholdTotalAmount: NewPlanThresholdTotalAmountPrice) = + Price(thresholdTotalAmount = thresholdTotalAmount) + + fun ofTieredPackage(tieredPackage: NewPlanTieredPackagePrice) = + Price(tieredPackage = tieredPackage) + + fun ofTieredWithMinimum(tieredWithMinimum: NewPlanTieredWithMinimumPrice) = + Price(tieredWithMinimum = tieredWithMinimum) + + fun ofUnitWithPercent(unitWithPercent: NewPlanUnitWithPercentPrice) = + Price(unitWithPercent = unitWithPercent) + + fun ofPackageWithAllocation( + packageWithAllocation: NewPlanPackageWithAllocationPrice + ) = Price(packageWithAllocation = packageWithAllocation) + + fun ofTieredWithProration(tieredWithProration: NewPlanTierWithProrationPrice) = + Price(tieredWithProration = tieredWithProration) + + fun ofUnitWithProration(unitWithProration: NewPlanUnitWithProrationPrice) = + Price(unitWithProration = unitWithProration) + + fun ofGroupedAllocation(groupedAllocation: NewPlanGroupedAllocationPrice) = + Price(groupedAllocation = groupedAllocation) + + fun ofGroupedWithProratedMinimum( + groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice + ) = Price(groupedWithProratedMinimum = groupedWithProratedMinimum) + + fun ofGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice + ) = Price(groupedWithMeteredMinimum = groupedWithMeteredMinimum) + + fun ofGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) = Price(groupedWithMinMaxThresholds = groupedWithMinMaxThresholds) + + fun ofMatrixWithDisplayName( + matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice + ) = Price(matrixWithDisplayName = matrixWithDisplayName) + + fun ofBulkWithProration(bulkWithProration: NewPlanBulkWithProrationPrice) = + Price(bulkWithProration = bulkWithProration) + + fun ofGroupedTieredPackage(groupedTieredPackage: NewPlanGroupedTieredPackagePrice) = + Price(groupedTieredPackage = groupedTieredPackage) + + fun ofMaxGroupTieredPackage( + maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice + ) = Price(maxGroupTieredPackage = maxGroupTieredPackage) + + fun ofScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice + ) = Price(scalableMatrixWithUnitPricing = scalableMatrixWithUnitPricing) + + fun ofScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: NewPlanScalableMatrixWithTieredPricingPrice + ) = Price(scalableMatrixWithTieredPricing = scalableMatrixWithTieredPricing) + + fun ofCumulativeGroupedBulk( + cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice + ) = Price(cumulativeGroupedBulk = cumulativeGroupedBulk) + + fun ofTieredPackageWithMinimum( + tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice + ) = Price(tieredPackageWithMinimum = tieredPackageWithMinimum) + + fun ofMatrixWithAllocation(matrixWithAllocation: NewPlanMatrixWithAllocationPrice) = + Price(matrixWithAllocation = matrixWithAllocation) + + fun ofGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) = + Price(groupedTiered = groupedTiered) + + fun ofMinimum(minimum: Minimum) = Price(minimum = minimum) + } + + /** + * An interface that defines how to map each variant of [Price] to a value of type [T]. + */ + interface Visitor { + + fun visitUnit(unit: NewPlanUnitPrice): T + + fun visitPackage(package_: NewPlanPackagePrice): T + + fun visitMatrix(matrix: NewPlanMatrixPrice): T + + fun visitTiered(tiered: NewPlanTieredPrice): T + + fun visitBulk(bulk: NewPlanBulkPrice): T + + fun visitThresholdTotalAmount( + thresholdTotalAmount: NewPlanThresholdTotalAmountPrice + ): T + + fun visitTieredPackage(tieredPackage: NewPlanTieredPackagePrice): T + + fun visitTieredWithMinimum(tieredWithMinimum: NewPlanTieredWithMinimumPrice): T + + fun visitUnitWithPercent(unitWithPercent: NewPlanUnitWithPercentPrice): T + + fun visitPackageWithAllocation( + packageWithAllocation: NewPlanPackageWithAllocationPrice + ): T + + fun visitTieredWithProration(tieredWithProration: NewPlanTierWithProrationPrice): T + + fun visitUnitWithProration(unitWithProration: NewPlanUnitWithProrationPrice): T + + fun visitGroupedAllocation(groupedAllocation: NewPlanGroupedAllocationPrice): T + + fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice + ): T + + fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice + ): T + + fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ): T + + fun visitMatrixWithDisplayName( + matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice + ): T + + fun visitBulkWithProration(bulkWithProration: NewPlanBulkWithProrationPrice): T + + fun visitGroupedTieredPackage( + groupedTieredPackage: NewPlanGroupedTieredPackagePrice + ): T + + fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice + ): T + + fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice + ): T + + fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: NewPlanScalableMatrixWithTieredPricingPrice + ): T + + fun visitCumulativeGroupedBulk( + cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice + ): T + + fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice + ): T + + fun visitMatrixWithAllocation( + matrixWithAllocation: NewPlanMatrixWithAllocationPrice + ): T + + fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice): T + + fun visitMinimum(minimum: Minimum): T + + /** + * Maps an unknown variant of [Price] to a value of type [T]. + * + * An instance of [Price] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is + * unaware of. + * + * @throws OrbInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw OrbInvalidDataException("Unknown Price: $json") + } + } + + internal class Deserializer : BaseDeserializer(Price::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Price { + val json = JsonValue.fromJsonNode(node) + val modelType = json.asObject()?.get("model_type")?.asString() + + when (modelType) { + "unit" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(unit = it, _json = json) + } ?: Price(_json = json) + } + "package" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(package_ = it, _json = json) } ?: Price(_json = json) + } + "matrix" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(matrix = it, _json = json) + } ?: Price(_json = json) + } + "tiered" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(tiered = it, _json = json) + } ?: Price(_json = json) + } + "bulk" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(bulk = it, _json = json) + } ?: Price(_json = json) + } + "threshold_total_amount" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(thresholdTotalAmount = it, _json = json) } + ?: Price(_json = json) + } + "tiered_package" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(tieredPackage = it, _json = json) } + ?: Price(_json = json) + } + "tiered_with_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(tieredWithMinimum = it, _json = json) } + ?: Price(_json = json) + } + "unit_with_percent" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(unitWithPercent = it, _json = json) } + ?: Price(_json = json) + } + "package_with_allocation" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(packageWithAllocation = it, _json = json) } + ?: Price(_json = json) + } + "tiered_with_proration" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(tieredWithProration = it, _json = json) } + ?: Price(_json = json) + } + "unit_with_proration" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(unitWithProration = it, _json = json) } + ?: Price(_json = json) + } + "grouped_allocation" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedAllocation = it, _json = json) } + ?: Price(_json = json) + } + "grouped_with_prorated_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedWithProratedMinimum = it, _json = json) } + ?: Price(_json = json) + } + "grouped_with_metered_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedWithMeteredMinimum = it, _json = json) } + ?: Price(_json = json) + } + "grouped_with_min_max_thresholds" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedWithMinMaxThresholds = it, _json = json) } + ?: Price(_json = json) + } + "matrix_with_display_name" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(matrixWithDisplayName = it, _json = json) } + ?: Price(_json = json) + } + "bulk_with_proration" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(bulkWithProration = it, _json = json) } + ?: Price(_json = json) + } + "grouped_tiered_package" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedTieredPackage = it, _json = json) } + ?: Price(_json = json) + } + "max_group_tiered_package" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(maxGroupTieredPackage = it, _json = json) } + ?: Price(_json = json) + } + "scalable_matrix_with_unit_pricing" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(scalableMatrixWithUnitPricing = it, _json = json) } + ?: Price(_json = json) + } + "scalable_matrix_with_tiered_pricing" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(scalableMatrixWithTieredPricing = it, _json = json) } + ?: Price(_json = json) + } + "cumulative_grouped_bulk" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(cumulativeGroupedBulk = it, _json = json) } + ?: Price(_json = json) + } + "tiered_package_with_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(tieredPackageWithMinimum = it, _json = json) } + ?: Price(_json = json) + } + "matrix_with_allocation" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(matrixWithAllocation = it, _json = json) } + ?: Price(_json = json) + } + "grouped_tiered" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(groupedTiered = it, _json = json) } + ?: Price(_json = json) + } + "minimum" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(minimum = it, _json = json) + } ?: Price(_json = json) + } + } + + return Price(_json = json) + } + } + + internal class Serializer : BaseSerializer(Price::class) { + + override fun serialize( + value: Price, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.unit != null -> generator.writeObject(value.unit) + value.package_ != null -> generator.writeObject(value.package_) + value.matrix != null -> generator.writeObject(value.matrix) + value.tiered != null -> generator.writeObject(value.tiered) + value.bulk != null -> generator.writeObject(value.bulk) + value.thresholdTotalAmount != null -> + generator.writeObject(value.thresholdTotalAmount) + value.tieredPackage != null -> generator.writeObject(value.tieredPackage) + value.tieredWithMinimum != null -> + generator.writeObject(value.tieredWithMinimum) + value.unitWithPercent != null -> + generator.writeObject(value.unitWithPercent) + value.packageWithAllocation != null -> + generator.writeObject(value.packageWithAllocation) + value.tieredWithProration != null -> + generator.writeObject(value.tieredWithProration) + value.unitWithProration != null -> + generator.writeObject(value.unitWithProration) + value.groupedAllocation != null -> + generator.writeObject(value.groupedAllocation) + value.groupedWithProratedMinimum != null -> + generator.writeObject(value.groupedWithProratedMinimum) + value.groupedWithMeteredMinimum != null -> + generator.writeObject(value.groupedWithMeteredMinimum) + value.groupedWithMinMaxThresholds != null -> + generator.writeObject(value.groupedWithMinMaxThresholds) + value.matrixWithDisplayName != null -> + generator.writeObject(value.matrixWithDisplayName) + value.bulkWithProration != null -> + generator.writeObject(value.bulkWithProration) + value.groupedTieredPackage != null -> + generator.writeObject(value.groupedTieredPackage) + value.maxGroupTieredPackage != null -> + generator.writeObject(value.maxGroupTieredPackage) + value.scalableMatrixWithUnitPricing != null -> + generator.writeObject(value.scalableMatrixWithUnitPricing) + value.scalableMatrixWithTieredPricing != null -> + generator.writeObject(value.scalableMatrixWithTieredPricing) + value.cumulativeGroupedBulk != null -> + generator.writeObject(value.cumulativeGroupedBulk) + value.tieredPackageWithMinimum != null -> + generator.writeObject(value.tieredPackageWithMinimum) + value.matrixWithAllocation != null -> + generator.writeObject(value.matrixWithAllocation) + value.groupedTiered != null -> generator.writeObject(value.groupedTiered) + value.minimum != null -> generator.writeObject(value.minimum) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Price") + } + } + } - override fun ObjectCodec.deserialize(node: JsonNode): Price { - val json = JsonValue.fromJsonNode(node) - val modelType = json.asObject()?.get("model_type")?.asString() + class GroupedWithMinMaxThresholds + private constructor( + private val cadence: JsonField, + private val groupedWithMinMaxThresholdsConfig: + JsonField, + private val itemId: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("grouped_with_min_max_thresholds_config") + @ExcludeMissing + groupedWithMinMaxThresholdsConfig: + JsonField = + JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + groupedWithMinMaxThresholdsConfig, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + mutableMapOf(), + ) - when (modelType) { - "unit" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(unit = it, _json = json) - } ?: Price(_json = json) + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupedWithMinMaxThresholdsConfig(): GroupedWithMinMaxThresholdsConfig = + groupedWithMinMaxThresholdsConfig.getRequired( + "grouped_with_min_max_thresholds_config" + ) + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * Expected to always return the following: + * ```kotlin + * JsonValue.from("grouped_with_min_max_thresholds") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = billableMetricId.getNullable("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + invoiceGroupingKey.getNullable("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [groupedWithMinMaxThresholdsConfig]. + * + * Unlike [groupedWithMinMaxThresholdsConfig], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("grouped_with_min_max_thresholds_config") + @ExcludeMissing + fun _groupedWithMinMaxThresholdsConfig(): + JsonField = groupedWithMinMaxThresholdsConfig + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [GroupedWithMinMaxThresholds]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .groupedWithMinMaxThresholdsConfig() + * .itemId() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [GroupedWithMinMaxThresholds]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var groupedWithMinMaxThresholdsConfig: + JsonField? = + null + private var itemId: JsonField? = null + private var modelType: JsonValue = + JsonValue.from("grouped_with_min_max_thresholds") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds) = + apply { + cadence = groupedWithMinMaxThresholds.cadence + groupedWithMinMaxThresholdsConfig = + groupedWithMinMaxThresholds.groupedWithMinMaxThresholdsConfig + itemId = groupedWithMinMaxThresholds.itemId + modelType = groupedWithMinMaxThresholds.modelType + name = groupedWithMinMaxThresholds.name + billableMetricId = groupedWithMinMaxThresholds.billableMetricId + billedInAdvance = groupedWithMinMaxThresholds.billedInAdvance + billingCycleConfiguration = + groupedWithMinMaxThresholds.billingCycleConfiguration + conversionRate = groupedWithMinMaxThresholds.conversionRate + conversionRateConfig = groupedWithMinMaxThresholds.conversionRateConfig + currency = groupedWithMinMaxThresholds.currency + dimensionalPriceConfiguration = + groupedWithMinMaxThresholds.dimensionalPriceConfiguration + externalPriceId = groupedWithMinMaxThresholds.externalPriceId + fixedPriceQuantity = groupedWithMinMaxThresholds.fixedPriceQuantity + invoiceGroupingKey = groupedWithMinMaxThresholds.invoiceGroupingKey + invoicingCycleConfiguration = + groupedWithMinMaxThresholds.invoicingCycleConfiguration + metadata = groupedWithMinMaxThresholds.metadata + referenceId = groupedWithMinMaxThresholds.referenceId + additionalProperties = + groupedWithMinMaxThresholds.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + fun groupedWithMinMaxThresholdsConfig( + groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + ) = + groupedWithMinMaxThresholdsConfig( + JsonField.of(groupedWithMinMaxThresholdsConfig) + ) + + /** + * Sets [Builder.groupedWithMinMaxThresholdsConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.groupedWithMinMaxThresholdsConfig] with a + * well-typed [GroupedWithMinMaxThresholdsConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun groupedWithMinMaxThresholdsConfig( + groupedWithMinMaxThresholdsConfig: + JsonField + ) = apply { + this.groupedWithMinMaxThresholdsConfig = groupedWithMinMaxThresholdsConfig + } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("grouped_with_min_max_thresholds") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) } - "package" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(package_ = it, _json = json) } ?: Price(_json = json) + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [GroupedWithMinMaxThresholds]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .groupedWithMinMaxThresholdsConfig() + * .itemId() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedWithMinMaxThresholds = + GroupedWithMinMaxThresholds( + checkRequired("cadence", cadence), + checkRequired( + "groupedWithMinMaxThresholdsConfig", + groupedWithMinMaxThresholdsConfig, + ), + checkRequired("itemId", itemId), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GroupedWithMinMaxThresholds = apply { + if (validated) { + return@apply + } + + cadence().validate() + groupedWithMinMaxThresholdsConfig().validate() + itemId() + _modelType().let { + if (it != JsonValue.from("grouped_with_min_max_thresholds")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") } - "matrix" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(matrix = it, _json = json) - } ?: Price(_json = json) + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (groupedWithMinMaxThresholdsConfig.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + modelType.let { + if (it == JsonValue.from("grouped_with_min_max_thresholds")) 1 else 0 + } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class GroupedWithMinMaxThresholdsConfig + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [GroupedWithMinMaxThresholdsConfig]. + */ + fun builder() = Builder() + } + + /** A builder for [GroupedWithMinMaxThresholdsConfig]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from( + groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + ) = apply { + additionalProperties = + groupedWithMinMaxThresholdsConfig.additionalProperties + .toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [GroupedWithMinMaxThresholdsConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): GroupedWithMinMaxThresholdsConfig = + GroupedWithMinMaxThresholdsConfig(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): GroupedWithMinMaxThresholdsConfig = apply { + if (validated) { + return@apply } - "tiered" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(tiered = it, _json = json) - } ?: Price(_json = json) + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false } - "tiered_bps" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(tieredBps = it, _json = json) } ?: Price(_json = json) + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() } - "bps" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(bps = it, _json = json) - } ?: Price(_json = json) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - "bulk_bps" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(bulkBps = it, _json = json) } ?: Price(_json = json) + + return other is GroupedWithMinMaxThresholdsConfig && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedWithMinMaxThresholdsConfig{additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() } - "bulk" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(bulk = it, _json = json) - } ?: Price(_json = json) + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) } - "threshold_total_amount" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(thresholdTotalAmount = it, _json = json) } - ?: Price(_json = json) + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) } - "tiered_package" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(tieredPackage = it, _json = json) } - ?: Price(_json = json) + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) } - "tiered_with_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(tieredWithMinimum = it, _json = json) } - ?: Price(_json = json) + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply } - "unit_with_percent" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(unitWithPercent = it, _json = json) } - ?: Price(_json = json) + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false } - "package_with_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(packageWithAllocation = it, _json = json) } - ?: Price(_json = json) + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() } - "tiered_with_proration" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(tieredWithProration = it, _json = json) } - ?: Price(_json = json) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - "unit_with_proration" -> { - return tryDeserialize( - node, - jacksonTypeRef(), + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedWithMinMaxThresholds && + cadence == other.cadence && + groupedWithMinMaxThresholdsConfig == + other.groupedWithMinMaxThresholdsConfig && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + groupedWithMinMaxThresholdsConfig, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedWithMinMaxThresholds{cadence=$cadence, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class Minimum + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val minimumConfig: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("minimum_config") + @ExcludeMissing + minimumConfig: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + minimumConfig, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun minimumConfig(): MinimumConfig = minimumConfig.getRequired("minimum_config") + + /** + * Expected to always return the following: + * ```kotlin + * JsonValue.from("minimum") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = billableMetricId.getNullable("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + invoiceGroupingKey.getNullable("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [minimumConfig]. + * + * Unlike [minimumConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("minimum_config") + @ExcludeMissing + fun _minimumConfig(): JsonField = minimumConfig + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Minimum]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .minimumConfig() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Minimum]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var minimumConfig: JsonField? = null + private var modelType: JsonValue = JsonValue.from("minimum") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(minimum: Minimum) = apply { + cadence = minimum.cadence + itemId = minimum.itemId + minimumConfig = minimum.minimumConfig + modelType = minimum.modelType + name = minimum.name + billableMetricId = minimum.billableMetricId + billedInAdvance = minimum.billedInAdvance + billingCycleConfiguration = minimum.billingCycleConfiguration + conversionRate = minimum.conversionRate + conversionRateConfig = minimum.conversionRateConfig + currency = minimum.currency + dimensionalPriceConfiguration = minimum.dimensionalPriceConfiguration + externalPriceId = minimum.externalPriceId + fixedPriceQuantity = minimum.fixedPriceQuantity + invoiceGroupingKey = minimum.invoiceGroupingKey + invoicingCycleConfiguration = minimum.invoicingCycleConfiguration + metadata = minimum.metadata + referenceId = minimum.referenceId + additionalProperties = minimum.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun minimumConfig(minimumConfig: MinimumConfig) = + minimumConfig(JsonField.of(minimumConfig)) + + /** + * Sets [Builder.minimumConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumConfig] with a well-typed + * [MinimumConfig] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun minimumConfig(minimumConfig: JsonField) = apply { + this.minimumConfig = minimumConfig + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("minimum") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT ) - ?.let { Price(unitWithProration = it, _json = json) } - ?: Price(_json = json) - } - "grouped_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED ) - ?.let { Price(groupedAllocation = it, _json = json) } - ?: Price(_json = json) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) } - "grouped_with_prorated_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedWithProratedMinimum = it, _json = json) } - ?: Price(_json = json) + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Minimum]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .minimumConfig() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Minimum = + Minimum( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("minimumConfig", minimumConfig), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Minimum = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + minimumConfig().validate() + _modelType().let { + if (it != JsonValue.from("minimum")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") } - "grouped_with_metered_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedWithMeteredMinimum = it, _json = json) } - ?: Price(_json = json) + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + (minimumConfig.asKnown()?.validity() ?: 0) + + modelType.let { if (it == JsonValue.from("minimum")) 1 else 0 } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false } - "matrix_with_display_name" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(matrixWithDisplayName = it, _json = json) } - ?: Price(_json = json) + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - "bulk_with_proration" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(bulkWithProration = it, _json = json) } - ?: Price(_json = json) + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class MinimumConfig + private constructor( + private val minimumAmount: JsonField, + private val prorated: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("minimum_amount") + @ExcludeMissing + minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("prorated") + @ExcludeMissing + prorated: JsonField = JsonMissing.of(), + ) : this(minimumAmount, prorated, mutableMapOf()) + + /** + * The minimum amount to apply + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") + + /** + * By default, subtotals from minimum composite prices are prorated based on the + * service period. Set to false to disable proration. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun prorated(): Boolean? = prorated.getNullable("prorated") + + /** + * Returns the raw JSON value of [minimumAmount]. + * + * Unlike [minimumAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount + + /** + * Returns the raw JSON value of [prorated]. + * + * Unlike [prorated], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("prorated") + @ExcludeMissing + fun _prorated(): JsonField = prorated + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [MinimumConfig]. + * + * The following fields are required: + * ```kotlin + * .minimumAmount() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [MinimumConfig]. */ + class Builder internal constructor() { + + private var minimumAmount: JsonField? = null + private var prorated: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(minimumConfig: MinimumConfig) = apply { + minimumAmount = minimumConfig.minimumAmount + prorated = minimumConfig.prorated + additionalProperties = minimumConfig.additionalProperties.toMutableMap() + } + + /** The minimum amount to apply */ + fun minimumAmount(minimumAmount: String) = + minimumAmount(JsonField.of(minimumAmount)) + + /** + * Sets [Builder.minimumAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumAmount] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount + } + + /** + * By default, subtotals from minimum composite prices are prorated based on + * the service period. Set to false to disable proration. + */ + fun prorated(prorated: Boolean?) = prorated(JsonField.ofNullable(prorated)) + + /** + * Alias for [Builder.prorated]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun prorated(prorated: Boolean) = prorated(prorated as Boolean?) + + /** + * Sets [Builder.prorated] to an arbitrary JSON value. + * + * You should usually call [Builder.prorated] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun prorated(prorated: JsonField) = apply { + this.prorated = prorated + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [MinimumConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .minimumAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MinimumConfig = + MinimumConfig( + checkRequired("minimumAmount", minimumAmount), + prorated, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MinimumConfig = apply { + if (validated) { + return@apply } - "grouped_tiered_package" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedTieredPackage = it, _json = json) } - ?: Price(_json = json) + + minimumAmount() + prorated() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (minimumAmount.asKnown() == null) 0 else 1) + + (if (prorated.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MinimumConfig && + minimumAmount == other.minimumAmount && + prorated == other.prorated && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(minimumAmount, prorated, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MinimumConfig{minimumAmount=$minimumAmount, prorated=$prorated, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() } - "max_group_tiered_package" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(maxGroupTieredPackage = it, _json = json) } - ?: Price(_json = json) + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) } - "scalable_matrix_with_unit_pricing" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(scalableMatrixWithUnitPricing = it, _json = json) } - ?: Price(_json = json) + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) } - "scalable_matrix_with_tiered_pricing" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(scalableMatrixWithTieredPricing = it, _json = json) } - ?: Price(_json = json) + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) } - "cumulative_grouped_bulk" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(cumulativeGroupedBulk = it, _json = json) } - ?: Price(_json = json) + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply } - "tiered_package_with_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(tieredPackageWithMinimum = it, _json = json) } - ?: Price(_json = json) + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false } - "matrix_with_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(matrixWithAllocation = it, _json = json) } - ?: Price(_json = json) + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() } - "grouped_tiered" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(groupedTiered = it, _json = json) } - ?: Price(_json = json) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } + + return other is Metadata && + additionalProperties == other.additionalProperties } - return Price(_json = json) - } - } + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - internal class Serializer : BaseSerializer(Price::class) { + override fun hashCode(): Int = hashCode - override fun serialize( - value: Price, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unit != null -> generator.writeObject(value.unit) - value.package_ != null -> generator.writeObject(value.package_) - value.matrix != null -> generator.writeObject(value.matrix) - value.tiered != null -> generator.writeObject(value.tiered) - value.tieredBps != null -> generator.writeObject(value.tieredBps) - value.bps != null -> generator.writeObject(value.bps) - value.bulkBps != null -> generator.writeObject(value.bulkBps) - value.bulk != null -> generator.writeObject(value.bulk) - value.thresholdTotalAmount != null -> - generator.writeObject(value.thresholdTotalAmount) - value.tieredPackage != null -> generator.writeObject(value.tieredPackage) - value.tieredWithMinimum != null -> - generator.writeObject(value.tieredWithMinimum) - value.unitWithPercent != null -> - generator.writeObject(value.unitWithPercent) - value.packageWithAllocation != null -> - generator.writeObject(value.packageWithAllocation) - value.tieredWithProration != null -> - generator.writeObject(value.tieredWithProration) - value.unitWithProration != null -> - generator.writeObject(value.unitWithProration) - value.groupedAllocation != null -> - generator.writeObject(value.groupedAllocation) - value.groupedWithProratedMinimum != null -> - generator.writeObject(value.groupedWithProratedMinimum) - value.groupedWithMeteredMinimum != null -> - generator.writeObject(value.groupedWithMeteredMinimum) - value.matrixWithDisplayName != null -> - generator.writeObject(value.matrixWithDisplayName) - value.bulkWithProration != null -> - generator.writeObject(value.bulkWithProration) - value.groupedTieredPackage != null -> - generator.writeObject(value.groupedTieredPackage) - value.maxGroupTieredPackage != null -> - generator.writeObject(value.maxGroupTieredPackage) - value.scalableMatrixWithUnitPricing != null -> - generator.writeObject(value.scalableMatrixWithUnitPricing) - value.scalableMatrixWithTieredPricing != null -> - generator.writeObject(value.scalableMatrixWithTieredPricing) - value.cumulativeGroupedBulk != null -> - generator.writeObject(value.cumulativeGroupedBulk) - value.tieredPackageWithMinimum != null -> - generator.writeObject(value.tieredPackageWithMinimum) - value.matrixWithAllocation != null -> - generator.writeObject(value.matrixWithAllocation) - value.groupedTiered != null -> generator.writeObject(value.groupedTiered) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Price") + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } + + return other is Minimum && + cadence == other.cadence && + itemId == other.itemId && + minimumConfig == other.minimumConfig && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + minimumConfig, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Minimum{cadence=$cadence, itemId=$itemId, minimumConfig=$minimumConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } } diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BetaExternalPlanIdCreatePlanVersionParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BetaExternalPlanIdCreatePlanVersionParams.kt index f6b46cb04..0c5f4b666 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BetaExternalPlanIdCreatePlanVersionParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BetaExternalPlanIdCreatePlanVersionParams.kt @@ -15,6 +15,7 @@ import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import com.withorb.api.core.BaseDeserializer import com.withorb.api.core.BaseSerializer +import com.withorb.api.core.Enum import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing @@ -1843,15 +1844,6 @@ private constructor( /** Alias for calling [price] with `Price.ofTiered(tiered)`. */ fun price(tiered: NewPlanTieredPrice) = price(Price.ofTiered(tiered)) - /** Alias for calling [price] with `Price.ofTieredBps(tieredBps)`. */ - fun price(tieredBps: NewPlanTieredBpsPrice) = price(Price.ofTieredBps(tieredBps)) - - /** Alias for calling [price] with `Price.ofBps(bps)`. */ - fun price(bps: NewPlanBpsPrice) = price(Price.ofBps(bps)) - - /** Alias for calling [price] with `Price.ofBulkBps(bulkBps)`. */ - fun price(bulkBps: NewPlanBulkBpsPrice) = price(Price.ofBulkBps(bulkBps)) - /** Alias for calling [price] with `Price.ofBulk(bulk)`. */ fun price(bulk: NewPlanBulkPrice) = price(Price.ofBulk(bulk)) @@ -1908,6 +1900,13 @@ private constructor( fun price(groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice) = price(Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)) + /** + * Alias for calling [price] with + * `Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)`. + */ + fun price(groupedWithMinMaxThresholds: Price.GroupedWithMinMaxThresholds) = + price(Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)) + /** * Alias for calling [price] with * `Price.ofMatrixWithDisplayName(matrixWithDisplayName)`. @@ -1971,6 +1970,9 @@ private constructor( fun price(groupedTiered: NewPlanGroupedTieredPrice) = price(Price.ofGroupedTiered(groupedTiered)) + /** Alias for calling [price] with `Price.ofMinimum(minimum)`. */ + fun price(minimum: Price.Minimum) = price(Price.ofMinimum(minimum)) + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -2045,9 +2047,6 @@ private constructor( private val package_: NewPlanPackagePrice? = null, private val matrix: NewPlanMatrixPrice? = null, private val tiered: NewPlanTieredPrice? = null, - private val tieredBps: NewPlanTieredBpsPrice? = null, - private val bps: NewPlanBpsPrice? = null, - private val bulkBps: NewPlanBulkBpsPrice? = null, private val bulk: NewPlanBulkPrice? = null, private val thresholdTotalAmount: NewPlanThresholdTotalAmountPrice? = null, private val tieredPackage: NewPlanTieredPackagePrice? = null, @@ -2059,6 +2058,7 @@ private constructor( private val groupedAllocation: NewPlanGroupedAllocationPrice? = null, private val groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice? = null, private val groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice? = null, + private val groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds? = null, private val matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice? = null, private val bulkWithProration: NewPlanBulkWithProrationPrice? = null, private val groupedTieredPackage: NewPlanGroupedTieredPackagePrice? = null, @@ -2072,6 +2072,7 @@ private constructor( private val tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice? = null, private val matrixWithAllocation: NewPlanMatrixWithAllocationPrice? = null, private val groupedTiered: NewPlanGroupedTieredPrice? = null, + private val minimum: Minimum? = null, private val _json: JsonValue? = null, ) { @@ -2083,12 +2084,6 @@ private constructor( fun tiered(): NewPlanTieredPrice? = tiered - fun tieredBps(): NewPlanTieredBpsPrice? = tieredBps - - fun bps(): NewPlanBpsPrice? = bps - - fun bulkBps(): NewPlanBulkBpsPrice? = bulkBps - fun bulk(): NewPlanBulkPrice? = bulk fun thresholdTotalAmount(): NewPlanThresholdTotalAmountPrice? = thresholdTotalAmount @@ -2113,6 +2108,9 @@ private constructor( fun groupedWithMeteredMinimum(): NewPlanGroupedWithMeteredMinimumPrice? = groupedWithMeteredMinimum + fun groupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds? = + groupedWithMinMaxThresholds + fun matrixWithDisplayName(): NewPlanMatrixWithDisplayNamePrice? = matrixWithDisplayName fun bulkWithProration(): NewPlanBulkWithProrationPrice? = bulkWithProration @@ -2136,6 +2134,8 @@ private constructor( fun groupedTiered(): NewPlanGroupedTieredPrice? = groupedTiered + fun minimum(): Minimum? = minimum + fun isUnit(): Boolean = unit != null fun isPackage(): Boolean = package_ != null @@ -2144,12 +2144,6 @@ private constructor( fun isTiered(): Boolean = tiered != null - fun isTieredBps(): Boolean = tieredBps != null - - fun isBps(): Boolean = bps != null - - fun isBulkBps(): Boolean = bulkBps != null - fun isBulk(): Boolean = bulk != null fun isThresholdTotalAmount(): Boolean = thresholdTotalAmount != null @@ -2172,6 +2166,8 @@ private constructor( fun isGroupedWithMeteredMinimum(): Boolean = groupedWithMeteredMinimum != null + fun isGroupedWithMinMaxThresholds(): Boolean = groupedWithMinMaxThresholds != null + fun isMatrixWithDisplayName(): Boolean = matrixWithDisplayName != null fun isBulkWithProration(): Boolean = bulkWithProration != null @@ -2193,6 +2189,8 @@ private constructor( fun isGroupedTiered(): Boolean = groupedTiered != null + fun isMinimum(): Boolean = minimum != null + fun asUnit(): NewPlanUnitPrice = unit.getOrThrow("unit") fun asPackage(): NewPlanPackagePrice = package_.getOrThrow("package_") @@ -2201,12 +2199,6 @@ private constructor( fun asTiered(): NewPlanTieredPrice = tiered.getOrThrow("tiered") - fun asTieredBps(): NewPlanTieredBpsPrice = tieredBps.getOrThrow("tieredBps") - - fun asBps(): NewPlanBpsPrice = bps.getOrThrow("bps") - - fun asBulkBps(): NewPlanBulkBpsPrice = bulkBps.getOrThrow("bulkBps") - fun asBulk(): NewPlanBulkPrice = bulk.getOrThrow("bulk") fun asThresholdTotalAmount(): NewPlanThresholdTotalAmountPrice = @@ -2239,6 +2231,9 @@ private constructor( fun asGroupedWithMeteredMinimum(): NewPlanGroupedWithMeteredMinimumPrice = groupedWithMeteredMinimum.getOrThrow("groupedWithMeteredMinimum") + fun asGroupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds = + groupedWithMinMaxThresholds.getOrThrow("groupedWithMinMaxThresholds") + fun asMatrixWithDisplayName(): NewPlanMatrixWithDisplayNamePrice = matrixWithDisplayName.getOrThrow("matrixWithDisplayName") @@ -2269,6 +2264,8 @@ private constructor( fun asGroupedTiered(): NewPlanGroupedTieredPrice = groupedTiered.getOrThrow("groupedTiered") + fun asMinimum(): Minimum = minimum.getOrThrow("minimum") + fun _json(): JsonValue? = _json fun accept(visitor: Visitor): T = @@ -2277,9 +2274,6 @@ private constructor( package_ != null -> visitor.visitPackage(package_) matrix != null -> visitor.visitMatrix(matrix) tiered != null -> visitor.visitTiered(tiered) - tieredBps != null -> visitor.visitTieredBps(tieredBps) - bps != null -> visitor.visitBps(bps) - bulkBps != null -> visitor.visitBulkBps(bulkBps) bulk != null -> visitor.visitBulk(bulk) thresholdTotalAmount != null -> visitor.visitThresholdTotalAmount(thresholdTotalAmount) @@ -2296,6 +2290,8 @@ private constructor( visitor.visitGroupedWithProratedMinimum(groupedWithProratedMinimum) groupedWithMeteredMinimum != null -> visitor.visitGroupedWithMeteredMinimum(groupedWithMeteredMinimum) + groupedWithMinMaxThresholds != null -> + visitor.visitGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds) matrixWithDisplayName != null -> visitor.visitMatrixWithDisplayName(matrixWithDisplayName) bulkWithProration != null -> visitor.visitBulkWithProration(bulkWithProration) @@ -2316,6 +2312,7 @@ private constructor( matrixWithAllocation != null -> visitor.visitMatrixWithAllocation(matrixWithAllocation) groupedTiered != null -> visitor.visitGroupedTiered(groupedTiered) + minimum != null -> visitor.visitMinimum(minimum) else -> visitor.unknown(_json) } @@ -2344,18 +2341,6 @@ private constructor( tiered.validate() } - override fun visitTieredBps(tieredBps: NewPlanTieredBpsPrice) { - tieredBps.validate() - } - - override fun visitBps(bps: NewPlanBpsPrice) { - bps.validate() - } - - override fun visitBulkBps(bulkBps: NewPlanBulkBpsPrice) { - bulkBps.validate() - } - override fun visitBulk(bulk: NewPlanBulkPrice) { bulk.validate() } @@ -2418,6 +2403,12 @@ private constructor( groupedWithMeteredMinimum.validate() } + override fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) { + groupedWithMinMaxThresholds.validate() + } + override fun visitMatrixWithDisplayName( matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice ) { @@ -2476,6 +2467,10 @@ private constructor( override fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) { groupedTiered.validate() } + + override fun visitMinimum(minimum: Minimum) { + minimum.validate() + } } ) validated = true @@ -2507,13 +2502,6 @@ private constructor( override fun visitTiered(tiered: NewPlanTieredPrice) = tiered.validity() - override fun visitTieredBps(tieredBps: NewPlanTieredBpsPrice) = - tieredBps.validity() - - override fun visitBps(bps: NewPlanBpsPrice) = bps.validity() - - override fun visitBulkBps(bulkBps: NewPlanBulkBpsPrice) = bulkBps.validity() - override fun visitBulk(bulk: NewPlanBulkPrice) = bulk.validity() override fun visitThresholdTotalAmount( @@ -2555,6 +2543,10 @@ private constructor( groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice ) = groupedWithMeteredMinimum.validity() + override fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) = groupedWithMinMaxThresholds.validity() + override fun visitMatrixWithDisplayName( matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice ) = matrixWithDisplayName.validity() @@ -2595,6 +2587,8 @@ private constructor( override fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) = groupedTiered.validity() + override fun visitMinimum(minimum: Minimum) = minimum.validity() + override fun unknown(json: JsonValue?) = 0 } ) @@ -2609,9 +2603,6 @@ private constructor( package_ == other.package_ && matrix == other.matrix && tiered == other.tiered && - tieredBps == other.tieredBps && - bps == other.bps && - bulkBps == other.bulkBps && bulk == other.bulk && thresholdTotalAmount == other.thresholdTotalAmount && tieredPackage == other.tieredPackage && @@ -2623,6 +2614,7 @@ private constructor( groupedAllocation == other.groupedAllocation && groupedWithProratedMinimum == other.groupedWithProratedMinimum && groupedWithMeteredMinimum == other.groupedWithMeteredMinimum && + groupedWithMinMaxThresholds == other.groupedWithMinMaxThresholds && matrixWithDisplayName == other.matrixWithDisplayName && bulkWithProration == other.bulkWithProration && groupedTieredPackage == other.groupedTieredPackage && @@ -2632,7 +2624,8 @@ private constructor( cumulativeGroupedBulk == other.cumulativeGroupedBulk && tieredPackageWithMinimum == other.tieredPackageWithMinimum && matrixWithAllocation == other.matrixWithAllocation && - groupedTiered == other.groupedTiered + groupedTiered == other.groupedTiered && + minimum == other.minimum } override fun hashCode(): Int = @@ -2641,9 +2634,6 @@ private constructor( package_, matrix, tiered, - tieredBps, - bps, - bulkBps, bulk, thresholdTotalAmount, tieredPackage, @@ -2655,6 +2645,7 @@ private constructor( groupedAllocation, groupedWithProratedMinimum, groupedWithMeteredMinimum, + groupedWithMinMaxThresholds, matrixWithDisplayName, bulkWithProration, groupedTieredPackage, @@ -2665,6 +2656,7 @@ private constructor( tieredPackageWithMinimum, matrixWithAllocation, groupedTiered, + minimum, ) override fun toString(): String = @@ -2673,9 +2665,6 @@ private constructor( package_ != null -> "Price{package_=$package_}" matrix != null -> "Price{matrix=$matrix}" tiered != null -> "Price{tiered=$tiered}" - tieredBps != null -> "Price{tieredBps=$tieredBps}" - bps != null -> "Price{bps=$bps}" - bulkBps != null -> "Price{bulkBps=$bulkBps}" bulk != null -> "Price{bulk=$bulk}" thresholdTotalAmount != null -> "Price{thresholdTotalAmount=$thresholdTotalAmount}" @@ -2691,6 +2680,8 @@ private constructor( "Price{groupedWithProratedMinimum=$groupedWithProratedMinimum}" groupedWithMeteredMinimum != null -> "Price{groupedWithMeteredMinimum=$groupedWithMeteredMinimum}" + groupedWithMinMaxThresholds != null -> + "Price{groupedWithMinMaxThresholds=$groupedWithMinMaxThresholds}" matrixWithDisplayName != null -> "Price{matrixWithDisplayName=$matrixWithDisplayName}" bulkWithProration != null -> "Price{bulkWithProration=$bulkWithProration}" @@ -2709,6 +2700,7 @@ private constructor( matrixWithAllocation != null -> "Price{matrixWithAllocation=$matrixWithAllocation}" groupedTiered != null -> "Price{groupedTiered=$groupedTiered}" + minimum != null -> "Price{minimum=$minimum}" _json != null -> "Price{_unknown=$_json}" else -> throw IllegalStateException("Invalid Price") } @@ -2723,12 +2715,6 @@ private constructor( fun ofTiered(tiered: NewPlanTieredPrice) = Price(tiered = tiered) - fun ofTieredBps(tieredBps: NewPlanTieredBpsPrice) = Price(tieredBps = tieredBps) - - fun ofBps(bps: NewPlanBpsPrice) = Price(bps = bps) - - fun ofBulkBps(bulkBps: NewPlanBulkBpsPrice) = Price(bulkBps = bulkBps) - fun ofBulk(bulk: NewPlanBulkPrice) = Price(bulk = bulk) fun ofThresholdTotalAmount(thresholdTotalAmount: NewPlanThresholdTotalAmountPrice) = @@ -2764,6 +2750,10 @@ private constructor( groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice ) = Price(groupedWithMeteredMinimum = groupedWithMeteredMinimum) + fun ofGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) = Price(groupedWithMinMaxThresholds = groupedWithMinMaxThresholds) + fun ofMatrixWithDisplayName( matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice ) = Price(matrixWithDisplayName = matrixWithDisplayName) @@ -2799,6 +2789,8 @@ private constructor( fun ofGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) = Price(groupedTiered = groupedTiered) + + fun ofMinimum(minimum: Minimum) = Price(minimum = minimum) } /** @@ -2814,12 +2806,6 @@ private constructor( fun visitTiered(tiered: NewPlanTieredPrice): T - fun visitTieredBps(tieredBps: NewPlanTieredBpsPrice): T - - fun visitBps(bps: NewPlanBpsPrice): T - - fun visitBulkBps(bulkBps: NewPlanBulkBpsPrice): T - fun visitBulk(bulk: NewPlanBulkPrice): T fun visitThresholdTotalAmount( @@ -2850,6 +2836,10 @@ private constructor( groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice ): T + fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ): T + fun visitMatrixWithDisplayName( matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice ): T @@ -2886,6 +2876,8 @@ private constructor( fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice): T + fun visitMinimum(minimum: Minimum): T + /** * Maps an unknown variant of [Price] to a value of type [T]. * @@ -2927,19 +2919,6 @@ private constructor( Price(tiered = it, _json = json) } ?: Price(_json = json) } - "tiered_bps" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(tieredBps = it, _json = json) } ?: Price(_json = json) - } - "bps" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(bps = it, _json = json) - } ?: Price(_json = json) - } - "bulk_bps" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(bulkBps = it, _json = json) } ?: Price(_json = json) - } "bulk" -> { return tryDeserialize(node, jacksonTypeRef())?.let { Price(bulk = it, _json = json) @@ -3022,6 +3001,14 @@ private constructor( ?.let { Price(groupedWithMeteredMinimum = it, _json = json) } ?: Price(_json = json) } + "grouped_with_min_max_thresholds" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedWithMinMaxThresholds = it, _json = json) } + ?: Price(_json = json) + } "matrix_with_display_name" -> { return tryDeserialize( node, @@ -3099,6 +3086,11 @@ private constructor( ?.let { Price(groupedTiered = it, _json = json) } ?: Price(_json = json) } + "minimum" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(minimum = it, _json = json) + } ?: Price(_json = json) + } } return Price(_json = json) @@ -3117,9 +3109,6 @@ private constructor( value.package_ != null -> generator.writeObject(value.package_) value.matrix != null -> generator.writeObject(value.matrix) value.tiered != null -> generator.writeObject(value.tiered) - value.tieredBps != null -> generator.writeObject(value.tieredBps) - value.bps != null -> generator.writeObject(value.bps) - value.bulkBps != null -> generator.writeObject(value.bulkBps) value.bulk != null -> generator.writeObject(value.bulk) value.thresholdTotalAmount != null -> generator.writeObject(value.thresholdTotalAmount) @@ -3140,6 +3129,8 @@ private constructor( generator.writeObject(value.groupedWithProratedMinimum) value.groupedWithMeteredMinimum != null -> generator.writeObject(value.groupedWithMeteredMinimum) + value.groupedWithMinMaxThresholds != null -> + generator.writeObject(value.groupedWithMinMaxThresholds) value.matrixWithDisplayName != null -> generator.writeObject(value.matrixWithDisplayName) value.bulkWithProration != null -> @@ -3159,1117 +3150,3108 @@ private constructor( value.matrixWithAllocation != null -> generator.writeObject(value.matrixWithAllocation) value.groupedTiered != null -> generator.writeObject(value.groupedTiered) + value.minimum != null -> generator.writeObject(value.minimum) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid Price") } } } - } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + class GroupedWithMinMaxThresholds + private constructor( + private val cadence: JsonField, + private val groupedWithMinMaxThresholdsConfig: + JsonField, + private val itemId: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("grouped_with_min_max_thresholds_config") + @ExcludeMissing + groupedWithMinMaxThresholdsConfig: + JsonField = + JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + groupedWithMinMaxThresholdsConfig, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + mutableMapOf(), + ) - return other is AddPrice && - allocationPrice == other.allocationPrice && - planPhaseOrder == other.planPhaseOrder && - price == other.price && - additionalProperties == other.additionalProperties - } + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") - private val hashCode: Int by lazy { - Objects.hash(allocationPrice, planPhaseOrder, price, additionalProperties) - } + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupedWithMinMaxThresholdsConfig(): GroupedWithMinMaxThresholdsConfig = + groupedWithMinMaxThresholdsConfig.getRequired( + "grouped_with_min_max_thresholds_config" + ) - override fun hashCode(): Int = hashCode + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") - override fun toString() = - "AddPrice{allocationPrice=$allocationPrice, planPhaseOrder=$planPhaseOrder, price=$price, additionalProperties=$additionalProperties}" - } + /** + * Expected to always return the following: + * ```kotlin + * JsonValue.from("grouped_with_min_max_thresholds") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType - class RemoveAdjustment - private constructor( - private val adjustmentId: JsonField, - private val planPhaseOrder: JsonField, - private val additionalProperties: MutableMap, - ) { + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") - @JsonCreator - private constructor( - @JsonProperty("adjustment_id") - @ExcludeMissing - adjustmentId: JsonField = JsonMissing.of(), - @JsonProperty("plan_phase_order") - @ExcludeMissing - planPhaseOrder: JsonField = JsonMissing.of(), - ) : this(adjustmentId, planPhaseOrder, mutableMapOf()) + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = billableMetricId.getNullable("billable_metric_id") - /** - * The id of the adjustment to remove from on the plan. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun adjustmentId(): String = adjustmentId.getRequired("adjustment_id") + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") - /** - * The phase to remove this adjustment from. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun planPhaseOrder(): Long? = planPhaseOrder.getNullable("plan_phase_order") + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") - /** - * Returns the raw JSON value of [adjustmentId]. - * - * Unlike [adjustmentId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("adjustment_id") - @ExcludeMissing - fun _adjustmentId(): JsonField = adjustmentId + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") - /** - * Returns the raw JSON value of [planPhaseOrder]. - * - * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("plan_phase_order") - @ExcludeMissing - fun _planPhaseOrder(): JsonField = planPhaseOrder + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") - fun toBuilder() = Builder().from(this) + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") - companion object { + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") - /** - * Returns a mutable builder for constructing an instance of [RemoveAdjustment]. - * - * The following fields are required: - * ```kotlin - * .adjustmentId() - * ``` - */ - fun builder() = Builder() - } + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + invoiceGroupingKey.getNullable("invoice_grouping_key") - /** A builder for [RemoveAdjustment]. */ - class Builder internal constructor() { + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - private var adjustmentId: JsonField? = null - private var planPhaseOrder: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") - internal fun from(removeAdjustment: RemoveAdjustment) = apply { - adjustmentId = removeAdjustment.adjustmentId - planPhaseOrder = removeAdjustment.planPhaseOrder - additionalProperties = removeAdjustment.additionalProperties.toMutableMap() - } + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") - /** The id of the adjustment to remove from on the plan. */ - fun adjustmentId(adjustmentId: String) = adjustmentId(JsonField.of(adjustmentId)) + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence - /** - * Sets [Builder.adjustmentId] to an arbitrary JSON value. - * - * You should usually call [Builder.adjustmentId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun adjustmentId(adjustmentId: JsonField) = apply { - this.adjustmentId = adjustmentId - } + /** + * Returns the raw JSON value of [groupedWithMinMaxThresholdsConfig]. + * + * Unlike [groupedWithMinMaxThresholdsConfig], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("grouped_with_min_max_thresholds_config") + @ExcludeMissing + fun _groupedWithMinMaxThresholdsConfig(): + JsonField = groupedWithMinMaxThresholdsConfig - /** The phase to remove this adjustment from. */ - fun planPhaseOrder(planPhaseOrder: Long?) = - planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - /** - * Alias for [Builder.planPhaseOrder]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - /** - * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. - * - * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun planPhaseOrder(planPhaseOrder: JsonField) = apply { - this.planPhaseOrder = planPhaseOrder - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig - /** - * Returns an immutable instance of [RemoveAdjustment]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```kotlin - * .adjustmentId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): RemoveAdjustment = - RemoveAdjustment( - checkRequired("adjustmentId", adjustmentId), - planPhaseOrder, - additionalProperties.toMutableMap(), - ) - } + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency - private var validated: Boolean = false + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration - fun validate(): RemoveAdjustment = apply { - if (validated) { - return@apply - } + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId - adjustmentId() - planPhaseOrder() - validated = true - } + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (if (adjustmentId.asKnown() == null) 0 else 1) + - (if (planPhaseOrder.asKnown() == null) 0 else 1) + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata - return other is RemoveAdjustment && - adjustmentId == other.adjustmentId && - planPhaseOrder == other.planPhaseOrder && - additionalProperties == other.additionalProperties - } + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId - private val hashCode: Int by lazy { - Objects.hash(adjustmentId, planPhaseOrder, additionalProperties) - } + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - override fun hashCode(): Int = hashCode + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [GroupedWithMinMaxThresholds]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .groupedWithMinMaxThresholdsConfig() + * .itemId() + * .name() + * ``` + */ + fun builder() = Builder() + } - override fun toString() = - "RemoveAdjustment{adjustmentId=$adjustmentId, planPhaseOrder=$planPhaseOrder, additionalProperties=$additionalProperties}" - } + /** A builder for [GroupedWithMinMaxThresholds]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var groupedWithMinMaxThresholdsConfig: + JsonField? = + null + private var itemId: JsonField? = null + private var modelType: JsonValue = + JsonValue.from("grouped_with_min_max_thresholds") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds) = + apply { + cadence = groupedWithMinMaxThresholds.cadence + groupedWithMinMaxThresholdsConfig = + groupedWithMinMaxThresholds.groupedWithMinMaxThresholdsConfig + itemId = groupedWithMinMaxThresholds.itemId + modelType = groupedWithMinMaxThresholds.modelType + name = groupedWithMinMaxThresholds.name + billableMetricId = groupedWithMinMaxThresholds.billableMetricId + billedInAdvance = groupedWithMinMaxThresholds.billedInAdvance + billingCycleConfiguration = + groupedWithMinMaxThresholds.billingCycleConfiguration + conversionRate = groupedWithMinMaxThresholds.conversionRate + conversionRateConfig = groupedWithMinMaxThresholds.conversionRateConfig + currency = groupedWithMinMaxThresholds.currency + dimensionalPriceConfiguration = + groupedWithMinMaxThresholds.dimensionalPriceConfiguration + externalPriceId = groupedWithMinMaxThresholds.externalPriceId + fixedPriceQuantity = groupedWithMinMaxThresholds.fixedPriceQuantity + invoiceGroupingKey = groupedWithMinMaxThresholds.invoiceGroupingKey + invoicingCycleConfiguration = + groupedWithMinMaxThresholds.invoicingCycleConfiguration + metadata = groupedWithMinMaxThresholds.metadata + referenceId = groupedWithMinMaxThresholds.referenceId + additionalProperties = + groupedWithMinMaxThresholds.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + fun groupedWithMinMaxThresholdsConfig( + groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + ) = + groupedWithMinMaxThresholdsConfig( + JsonField.of(groupedWithMinMaxThresholdsConfig) + ) - class RemovePrice - private constructor( - private val priceId: JsonField, - private val planPhaseOrder: JsonField, - private val additionalProperties: MutableMap, - ) { + /** + * Sets [Builder.groupedWithMinMaxThresholdsConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.groupedWithMinMaxThresholdsConfig] with a + * well-typed [GroupedWithMinMaxThresholdsConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun groupedWithMinMaxThresholdsConfig( + groupedWithMinMaxThresholdsConfig: + JsonField + ) = apply { + this.groupedWithMinMaxThresholdsConfig = groupedWithMinMaxThresholdsConfig + } - @JsonCreator - private constructor( - @JsonProperty("price_id") @ExcludeMissing priceId: JsonField = JsonMissing.of(), - @JsonProperty("plan_phase_order") - @ExcludeMissing - planPhaseOrder: JsonField = JsonMissing.of(), - ) : this(priceId, planPhaseOrder, mutableMapOf()) + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("grouped_with_min_max_thresholds") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } - /** - * The id of the price to remove from the plan. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun priceId(): String = priceId.getRequired("price_id") + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } - /** - * The phase to remove this price from. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun planPhaseOrder(): Long? = planPhaseOrder.getNullable("plan_phase_order") + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } - /** - * Returns the raw JSON value of [priceId]. - * - * Unlike [priceId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) - /** - * Returns the raw JSON value of [planPhaseOrder]. - * - * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("plan_phase_order") - @ExcludeMissing - fun _planPhaseOrder(): JsonField = planPhaseOrder + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } - fun toBuilder() = Builder().from(this) + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } - companion object { + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } - /** - * Returns a mutable builder for constructing an instance of [RemovePrice]. - * - * The following fields are required: - * ```kotlin - * .priceId() - * ``` - */ - fun builder() = Builder() - } + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) - /** A builder for [RemovePrice]. */ - class Builder internal constructor() { + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } - private var priceId: JsonField? = null - private var planPhaseOrder: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - internal fun from(removePrice: RemovePrice) = apply { - priceId = removePrice.priceId - planPhaseOrder = removePrice.planPhaseOrder - additionalProperties = removePrice.additionalProperties.toMutableMap() - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** The id of the price to remove from the plan. */ - fun priceId(priceId: String) = priceId(JsonField.of(priceId)) + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - /** - * Sets [Builder.priceId] to an arbitrary JSON value. - * - * You should usually call [Builder.priceId] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun priceId(priceId: JsonField) = apply { this.priceId = priceId } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - /** The phase to remove this price from. */ - fun planPhaseOrder(planPhaseOrder: Long?) = - planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - /** - * Alias for [Builder.planPhaseOrder]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + /** + * Returns an immutable instance of [GroupedWithMinMaxThresholds]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .groupedWithMinMaxThresholdsConfig() + * .itemId() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedWithMinMaxThresholds = + GroupedWithMinMaxThresholds( + checkRequired("cadence", cadence), + checkRequired( + "groupedWithMinMaxThresholdsConfig", + groupedWithMinMaxThresholdsConfig, + ), + checkRequired("itemId", itemId), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } - /** - * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. - * - * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun planPhaseOrder(planPhaseOrder: JsonField) = apply { - this.planPhaseOrder = planPhaseOrder - } + private var validated: Boolean = false - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun validate(): GroupedWithMinMaxThresholds = apply { + if (validated) { + return@apply + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + cadence().validate() + groupedWithMinMaxThresholdsConfig().validate() + itemId() + _modelType().let { + if (it != JsonValue.from("grouped_with_min_max_thresholds")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + metadata()?.validate() + referenceId() + validated = true + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (groupedWithMinMaxThresholdsConfig.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + modelType.let { + if (it == JsonValue.from("grouped_with_min_max_thresholds")) 1 else 0 + } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } - /** - * Returns an immutable instance of [RemovePrice]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```kotlin - * .priceId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): RemovePrice = - RemovePrice( - checkRequired("priceId", priceId), - planPhaseOrder, - additionalProperties.toMutableMap(), - ) - } + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } - private var validated: Boolean = false + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } - fun validate(): RemovePrice = apply { - if (validated) { - return@apply - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - priceId() - planPhaseOrder() - validated = true - } + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (if (priceId.asKnown() == null) 0 else 1) + - (if (planPhaseOrder.asKnown() == null) 0 else 1) + return other is Cadence && value == other.value + } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + override fun hashCode() = value.hashCode() - return other is RemovePrice && - priceId == other.priceId && - planPhaseOrder == other.planPhaseOrder && - additionalProperties == other.additionalProperties - } + override fun toString() = value.toString() + } - private val hashCode: Int by lazy { - Objects.hash(priceId, planPhaseOrder, additionalProperties) - } + class GroupedWithMinMaxThresholdsConfig + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { - override fun hashCode(): Int = hashCode + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties - override fun toString() = - "RemovePrice{priceId=$priceId, planPhaseOrder=$planPhaseOrder, additionalProperties=$additionalProperties}" - } + fun toBuilder() = Builder().from(this) - class ReplaceAdjustment - private constructor( - private val adjustment: JsonField, - private val replacesAdjustmentId: JsonField, - private val planPhaseOrder: JsonField, - private val additionalProperties: MutableMap, - ) { + companion object { - @JsonCreator - private constructor( - @JsonProperty("adjustment") - @ExcludeMissing - adjustment: JsonField = JsonMissing.of(), - @JsonProperty("replaces_adjustment_id") - @ExcludeMissing - replacesAdjustmentId: JsonField = JsonMissing.of(), - @JsonProperty("plan_phase_order") - @ExcludeMissing - planPhaseOrder: JsonField = JsonMissing.of(), - ) : this(adjustment, replacesAdjustmentId, planPhaseOrder, mutableMapOf()) + /** + * Returns a mutable builder for constructing an instance of + * [GroupedWithMinMaxThresholdsConfig]. + */ + fun builder() = Builder() + } - /** - * The definition of a new adjustment to create and add to the plan. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun adjustment(): Adjustment = adjustment.getRequired("adjustment") + /** A builder for [GroupedWithMinMaxThresholdsConfig]. */ + class Builder internal constructor() { - /** - * The id of the adjustment on the plan to replace in the plan. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun replacesAdjustmentId(): String = - replacesAdjustmentId.getRequired("replaces_adjustment_id") + private var additionalProperties: MutableMap = + mutableMapOf() - /** - * The phase to replace this adjustment from. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun planPhaseOrder(): Long? = planPhaseOrder.getNullable("plan_phase_order") + internal fun from( + groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + ) = apply { + additionalProperties = + groupedWithMinMaxThresholdsConfig.additionalProperties + .toMutableMap() + } - /** - * Returns the raw JSON value of [adjustment]. - * - * Unlike [adjustment], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("adjustment") - @ExcludeMissing - fun _adjustment(): JsonField = adjustment + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** - * Returns the raw JSON value of [replacesAdjustmentId]. - * - * Unlike [replacesAdjustmentId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("replaces_adjustment_id") - @ExcludeMissing - fun _replacesAdjustmentId(): JsonField = replacesAdjustmentId + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * Returns the raw JSON value of [planPhaseOrder]. - * - * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("plan_phase_order") - @ExcludeMissing - fun _planPhaseOrder(): JsonField = planPhaseOrder + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - fun toBuilder() = Builder().from(this) + /** + * Returns an immutable instance of [GroupedWithMinMaxThresholdsConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): GroupedWithMinMaxThresholdsConfig = + GroupedWithMinMaxThresholdsConfig(additionalProperties.toImmutable()) + } - companion object { + private var validated: Boolean = false - /** - * Returns a mutable builder for constructing an instance of [ReplaceAdjustment]. - * - * The following fields are required: - * ```kotlin - * .adjustment() - * .replacesAdjustmentId() - * ``` - */ - fun builder() = Builder() - } + fun validate(): GroupedWithMinMaxThresholdsConfig = apply { + if (validated) { + return@apply + } - /** A builder for [ReplaceAdjustment]. */ - class Builder internal constructor() { + validated = true + } - private var adjustment: JsonField? = null - private var replacesAdjustmentId: JsonField? = null - private var planPhaseOrder: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - internal fun from(replaceAdjustment: ReplaceAdjustment) = apply { - adjustment = replaceAdjustment.adjustment - replacesAdjustmentId = replaceAdjustment.replacesAdjustmentId - planPhaseOrder = replaceAdjustment.planPhaseOrder - additionalProperties = replaceAdjustment.additionalProperties.toMutableMap() - } + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } - /** The definition of a new adjustment to create and add to the plan. */ - fun adjustment(adjustment: Adjustment) = adjustment(JsonField.of(adjustment)) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * Sets [Builder.adjustment] to an arbitrary JSON value. - * - * You should usually call [Builder.adjustment] with a well-typed [Adjustment] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun adjustment(adjustment: JsonField) = apply { - this.adjustment = adjustment - } + return other is GroupedWithMinMaxThresholdsConfig && + additionalProperties == other.additionalProperties + } - /** - * Alias for calling [adjustment] with - * `Adjustment.ofPercentageDiscount(percentageDiscount)`. - */ - fun adjustment(percentageDiscount: NewPercentageDiscount) = - adjustment(Adjustment.ofPercentageDiscount(percentageDiscount)) + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /** - * Alias for calling [adjustment] with the following: - * ```kotlin - * NewPercentageDiscount.builder() - * .adjustmentType(NewPercentageDiscount.AdjustmentType.PERCENTAGE_DISCOUNT) - * .percentageDiscount(percentageDiscount) - * .build() - * ``` - */ - fun percentageDiscountAdjustment(percentageDiscount: Double) = - adjustment( - NewPercentageDiscount.builder() - .adjustmentType(NewPercentageDiscount.AdjustmentType.PERCENTAGE_DISCOUNT) - .percentageDiscount(percentageDiscount) - .build() - ) + override fun hashCode(): Int = hashCode - /** Alias for calling [adjustment] with `Adjustment.ofUsageDiscount(usageDiscount)`. */ - fun adjustment(usageDiscount: NewUsageDiscount) = - adjustment(Adjustment.ofUsageDiscount(usageDiscount)) + override fun toString() = + "GroupedWithMinMaxThresholdsConfig{additionalProperties=$additionalProperties}" + } - /** - * Alias for calling [adjustment] with the following: - * ```kotlin - * NewUsageDiscount.builder() - * .adjustmentType(NewUsageDiscount.AdjustmentType.USAGE_DISCOUNT) - * .usageDiscount(usageDiscount) - * .build() - * ``` - */ - fun usageDiscountAdjustment(usageDiscount: Double) = - adjustment( - NewUsageDiscount.builder() - .adjustmentType(NewUsageDiscount.AdjustmentType.USAGE_DISCOUNT) - .usageDiscount(usageDiscount) - .build() - ) + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { - /** - * Alias for calling [adjustment] with `Adjustment.ofAmountDiscount(amountDiscount)`. - */ - fun adjustment(amountDiscount: NewAmountDiscount) = - adjustment(Adjustment.ofAmountDiscount(amountDiscount)) + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties - /** - * Alias for calling [adjustment] with the following: - * ```kotlin - * NewAmountDiscount.builder() - * .adjustmentType(NewAmountDiscount.AdjustmentType.AMOUNT_DISCOUNT) - * .amountDiscount(amountDiscount) - * .build() - * ``` - */ - fun amountDiscountAdjustment(amountDiscount: String) = - adjustment( - NewAmountDiscount.builder() - .adjustmentType(NewAmountDiscount.AdjustmentType.AMOUNT_DISCOUNT) - .amountDiscount(amountDiscount) - .build() - ) + fun toBuilder() = Builder().from(this) - /** Alias for calling [adjustment] with `Adjustment.ofMinimum(minimum)`. */ - fun adjustment(minimum: NewMinimum) = adjustment(Adjustment.ofMinimum(minimum)) + companion object { - /** Alias for calling [adjustment] with `Adjustment.ofMaximum(maximum)`. */ - fun adjustment(maximum: NewMaximum) = adjustment(Adjustment.ofMaximum(maximum)) + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } - /** - * Alias for calling [adjustment] with the following: - * ```kotlin - * NewMaximum.builder() - * .adjustmentType(NewMaximum.AdjustmentType.MAXIMUM) - * .maximumAmount(maximumAmount) - * .build() - * ``` - */ - fun maximumAdjustment(maximumAmount: String) = - adjustment( - NewMaximum.builder() - .adjustmentType(NewMaximum.AdjustmentType.MAXIMUM) - .maximumAmount(maximumAmount) - .build() - ) + /** A builder for [Metadata]. */ + class Builder internal constructor() { - /** The id of the adjustment on the plan to replace in the plan. */ - fun replacesAdjustmentId(replacesAdjustmentId: String) = - replacesAdjustmentId(JsonField.of(replacesAdjustmentId)) + private var additionalProperties: MutableMap = + mutableMapOf() - /** - * Sets [Builder.replacesAdjustmentId] to an arbitrary JSON value. - * - * You should usually call [Builder.replacesAdjustmentId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun replacesAdjustmentId(replacesAdjustmentId: JsonField) = apply { - this.replacesAdjustmentId = replacesAdjustmentId - } + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } - /** The phase to replace this adjustment from. */ - fun planPhaseOrder(planPhaseOrder: Long?) = - planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** - * Alias for [Builder.planPhaseOrder]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. - * - * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun planPhaseOrder(planPhaseOrder: JsonField) = apply { - this.planPhaseOrder = planPhaseOrder - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + private var validated: Boolean = false - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun validate(): Metadata = apply { + if (validated) { + return@apply + } - /** - * Returns an immutable instance of [ReplaceAdjustment]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```kotlin - * .adjustment() - * .replacesAdjustmentId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): ReplaceAdjustment = - ReplaceAdjustment( - checkRequired("adjustment", adjustment), - checkRequired("replacesAdjustmentId", replacesAdjustmentId), - planPhaseOrder, - additionalProperties.toMutableMap(), - ) - } + validated = true + } - private var validated: Boolean = false + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - fun validate(): ReplaceAdjustment = apply { - if (validated) { - return@apply - } + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } - adjustment().validate() - replacesAdjustmentId() - planPhaseOrder() - validated = true - } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + return other is Metadata && + additionalProperties == other.additionalProperties + } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (adjustment.asKnown()?.validity() ?: 0) + - (if (replacesAdjustmentId.asKnown() == null) 0 else 1) + - (if (planPhaseOrder.asKnown() == null) 0 else 1) + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /** The definition of a new adjustment to create and add to the plan. */ - @JsonDeserialize(using = Adjustment.Deserializer::class) - @JsonSerialize(using = Adjustment.Serializer::class) - class Adjustment - private constructor( - private val percentageDiscount: NewPercentageDiscount? = null, - private val usageDiscount: NewUsageDiscount? = null, - private val amountDiscount: NewAmountDiscount? = null, - private val minimum: NewMinimum? = null, - private val maximum: NewMaximum? = null, - private val _json: JsonValue? = null, - ) { + override fun hashCode(): Int = hashCode - fun percentageDiscount(): NewPercentageDiscount? = percentageDiscount + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } - fun usageDiscount(): NewUsageDiscount? = usageDiscount + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun amountDiscount(): NewAmountDiscount? = amountDiscount + return other is GroupedWithMinMaxThresholds && + cadence == other.cadence && + groupedWithMinMaxThresholdsConfig == + other.groupedWithMinMaxThresholdsConfig && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } - fun minimum(): NewMinimum? = minimum + private val hashCode: Int by lazy { + Objects.hash( + cadence, + groupedWithMinMaxThresholdsConfig, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties, + ) + } - fun maximum(): NewMaximum? = maximum + override fun hashCode(): Int = hashCode - fun isPercentageDiscount(): Boolean = percentageDiscount != null + override fun toString() = + "GroupedWithMinMaxThresholds{cadence=$cadence, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } - fun isUsageDiscount(): Boolean = usageDiscount != null + class Minimum + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val minimumConfig: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("minimum_config") + @ExcludeMissing + minimumConfig: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + minimumConfig, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + mutableMapOf(), + ) - fun isAmountDiscount(): Boolean = amountDiscount != null + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") - fun isMinimum(): Boolean = minimum != null + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") - fun isMaximum(): Boolean = maximum != null + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun minimumConfig(): MinimumConfig = minimumConfig.getRequired("minimum_config") - fun asPercentageDiscount(): NewPercentageDiscount = - percentageDiscount.getOrThrow("percentageDiscount") + /** + * Expected to always return the following: + * ```kotlin + * JsonValue.from("minimum") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType - fun asUsageDiscount(): NewUsageDiscount = usageDiscount.getOrThrow("usageDiscount") + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") - fun asAmountDiscount(): NewAmountDiscount = amountDiscount.getOrThrow("amountDiscount") + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = billableMetricId.getNullable("billable_metric_id") - fun asMinimum(): NewMinimum = minimum.getOrThrow("minimum") + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") - fun asMaximum(): NewMaximum = maximum.getOrThrow("maximum") + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") - fun _json(): JsonValue? = _json + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") - fun accept(visitor: Visitor): T = - when { - percentageDiscount != null -> - visitor.visitPercentageDiscount(percentageDiscount) - usageDiscount != null -> visitor.visitUsageDiscount(usageDiscount) - amountDiscount != null -> visitor.visitAmountDiscount(amountDiscount) - minimum != null -> visitor.visitMinimum(minimum) - maximum != null -> visitor.visitMaximum(maximum) - else -> visitor.unknown(_json) - } + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") - private var validated: Boolean = false + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") - fun validate(): Adjustment = apply { - if (validated) { - return@apply - } + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") - accept( - object : Visitor { - override fun visitPercentageDiscount( - percentageDiscount: NewPercentageDiscount - ) { - percentageDiscount.validate() - } + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") - override fun visitUsageDiscount(usageDiscount: NewUsageDiscount) { - usageDiscount.validate() - } + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") - override fun visitAmountDiscount(amountDiscount: NewAmountDiscount) { - amountDiscount.validate() - } + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + invoiceGroupingKey.getNullable("invoice_grouping_key") - override fun visitMinimum(minimum: NewMinimum) { - minimum.validate() - } + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - override fun visitMaximum(maximum: NewMaximum) { - maximum.validate() - } - } - ) - validated = true - } + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [minimumConfig]. + * + * Unlike [minimumConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("minimum_config") + @ExcludeMissing + fun _minimumConfig(): JsonField = minimumConfig + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitPercentageDiscount( - percentageDiscount: NewPercentageDiscount - ) = percentageDiscount.validity() + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Minimum]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .minimumConfig() + * .name() + * ``` + */ + fun builder() = Builder() + } - override fun visitUsageDiscount(usageDiscount: NewUsageDiscount) = - usageDiscount.validity() + /** A builder for [Minimum]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var minimumConfig: JsonField? = null + private var modelType: JsonValue = JsonValue.from("minimum") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(minimum: Minimum) = apply { + cadence = minimum.cadence + itemId = minimum.itemId + minimumConfig = minimum.minimumConfig + modelType = minimum.modelType + name = minimum.name + billableMetricId = minimum.billableMetricId + billedInAdvance = minimum.billedInAdvance + billingCycleConfiguration = minimum.billingCycleConfiguration + conversionRate = minimum.conversionRate + conversionRateConfig = minimum.conversionRateConfig + currency = minimum.currency + dimensionalPriceConfiguration = minimum.dimensionalPriceConfiguration + externalPriceId = minimum.externalPriceId + fixedPriceQuantity = minimum.fixedPriceQuantity + invoiceGroupingKey = minimum.invoiceGroupingKey + invoicingCycleConfiguration = minimum.invoicingCycleConfiguration + metadata = minimum.metadata + referenceId = minimum.referenceId + additionalProperties = minimum.additionalProperties.toMutableMap() + } - override fun visitAmountDiscount(amountDiscount: NewAmountDiscount) = - amountDiscount.validity() + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun minimumConfig(minimumConfig: MinimumConfig) = + minimumConfig(JsonField.of(minimumConfig)) + + /** + * Sets [Builder.minimumConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumConfig] with a well-typed + * [MinimumConfig] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun minimumConfig(minimumConfig: JsonField) = apply { + this.minimumConfig = minimumConfig + } - override fun visitMinimum(minimum: NewMinimum) = minimum.validity() + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("minimum") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } - override fun visitMaximum(maximum: NewMaximum) = maximum.validity() + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } - override fun unknown(json: JsonValue?) = 0 + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate } - ) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) - return other is Adjustment && - percentageDiscount == other.percentageDiscount && - usageDiscount == other.usageDiscount && - amountDiscount == other.amountDiscount && - minimum == other.minimum && - maximum == other.maximum - } + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) - override fun hashCode(): Int = - Objects.hash(percentageDiscount, usageDiscount, amountDiscount, minimum, maximum) + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) - override fun toString(): String = - when { - percentageDiscount != null -> - "Adjustment{percentageDiscount=$percentageDiscount}" - usageDiscount != null -> "Adjustment{usageDiscount=$usageDiscount}" - amountDiscount != null -> "Adjustment{amountDiscount=$amountDiscount}" - minimum != null -> "Adjustment{minimum=$minimum}" - maximum != null -> "Adjustment{maximum=$maximum}" - _json != null -> "Adjustment{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Adjustment") - } + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } - companion object { + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } - fun ofPercentageDiscount(percentageDiscount: NewPercentageDiscount) = - Adjustment(percentageDiscount = percentageDiscount) + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } - fun ofUsageDiscount(usageDiscount: NewUsageDiscount) = - Adjustment(usageDiscount = usageDiscount) + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) - fun ofAmountDiscount(amountDiscount: NewAmountDiscount) = - Adjustment(amountDiscount = amountDiscount) + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } - fun ofMinimum(minimum: NewMinimum) = Adjustment(minimum = minimum) + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun ofMaximum(maximum: NewMaximum) = Adjustment(maximum = maximum) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * An interface that defines how to map each variant of [Adjustment] to a value of type - * [T]. - */ - interface Visitor { + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun visitPercentageDiscount(percentageDiscount: NewPercentageDiscount): T + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun visitUsageDiscount(usageDiscount: NewUsageDiscount): T + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - fun visitAmountDiscount(amountDiscount: NewAmountDiscount): T + /** + * Returns an immutable instance of [Minimum]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .minimumConfig() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Minimum = + Minimum( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("minimumConfig", minimumConfig), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } - fun visitMinimum(minimum: NewMinimum): T + private var validated: Boolean = false - fun visitMaximum(maximum: NewMaximum): T + fun validate(): Minimum = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + minimumConfig().validate() + _modelType().let { + if (it != JsonValue.from("minimum")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } /** - * Maps an unknown variant of [Adjustment] to a value of type [T]. - * - * An instance of [Adjustment] can contain an unknown variant if it was deserialized - * from data that doesn't match any known variant. For example, if the SDK is on an - * older version than the API, then the API may respond with new variants that the - * SDK is unaware of. + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * @throws OrbInvalidDataException in the default implementation. + * Used for best match union deserialization. */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown Adjustment: $json") - } - } + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + (minimumConfig.asKnown()?.validity() ?: 0) + + modelType.let { if (it == JsonValue.from("minimum")) 1 else 0 } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } - internal class Deserializer : BaseDeserializer(Adjustment::class) { + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } - override fun ObjectCodec.deserialize(node: JsonNode): Adjustment { - val json = JsonValue.fromJsonNode(node) - val adjustmentType = json.asObject()?.get("adjustment_type")?.asString() + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } - when (adjustmentType) { - "percentage_discount" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Adjustment(percentageDiscount = it, _json = json) } - ?: Adjustment(_json = json) - } - "usage_discount" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(usageDiscount = it, _json = json) - } ?: Adjustment(_json = json) - } - "amount_discount" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(amountDiscount = it, _json = json) - } ?: Adjustment(_json = json) - } - "minimum" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(minimum = it, _json = json) - } ?: Adjustment(_json = json) + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false } - "maximum" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(maximum = it, _json = json) - } ?: Adjustment(_json = json) + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } + + return other is Cadence && value == other.value } - return Adjustment(_json = json) - } - } + override fun hashCode() = value.hashCode() - internal class Serializer : BaseSerializer(Adjustment::class) { + override fun toString() = value.toString() + } - override fun serialize( - value: Adjustment, - generator: JsonGenerator, - provider: SerializerProvider, + class MinimumConfig + private constructor( + private val minimumAmount: JsonField, + private val prorated: JsonField, + private val additionalProperties: MutableMap, ) { - when { - value.percentageDiscount != null -> - generator.writeObject(value.percentageDiscount) - value.usageDiscount != null -> generator.writeObject(value.usageDiscount) - value.amountDiscount != null -> generator.writeObject(value.amountDiscount) - value.minimum != null -> generator.writeObject(value.minimum) - value.maximum != null -> generator.writeObject(value.maximum) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Adjustment") + + @JsonCreator + private constructor( + @JsonProperty("minimum_amount") + @ExcludeMissing + minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("prorated") + @ExcludeMissing + prorated: JsonField = JsonMissing.of(), + ) : this(minimumAmount, prorated, mutableMapOf()) + + /** + * The minimum amount to apply + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") + + /** + * By default, subtotals from minimum composite prices are prorated based on the + * service period. Set to false to disable proration. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun prorated(): Boolean? = prorated.getNullable("prorated") + + /** + * Returns the raw JSON value of [minimumAmount]. + * + * Unlike [minimumAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount + + /** + * Returns the raw JSON value of [prorated]. + * + * Unlike [prorated], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("prorated") + @ExcludeMissing + fun _prorated(): JsonField = prorated + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) } - } - } - } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [MinimumConfig]. + * + * The following fields are required: + * ```kotlin + * .minimumAmount() + * ``` + */ + fun builder() = Builder() + } - return other is ReplaceAdjustment && - adjustment == other.adjustment && - replacesAdjustmentId == other.replacesAdjustmentId && - planPhaseOrder == other.planPhaseOrder && - additionalProperties == other.additionalProperties - } + /** A builder for [MinimumConfig]. */ + class Builder internal constructor() { + + private var minimumAmount: JsonField? = null + private var prorated: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(minimumConfig: MinimumConfig) = apply { + minimumAmount = minimumConfig.minimumAmount + prorated = minimumConfig.prorated + additionalProperties = minimumConfig.additionalProperties.toMutableMap() + } + + /** The minimum amount to apply */ + fun minimumAmount(minimumAmount: String) = + minimumAmount(JsonField.of(minimumAmount)) + + /** + * Sets [Builder.minimumAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumAmount] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount + } + + /** + * By default, subtotals from minimum composite prices are prorated based on + * the service period. Set to false to disable proration. + */ + fun prorated(prorated: Boolean?) = prorated(JsonField.ofNullable(prorated)) + + /** + * Alias for [Builder.prorated]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun prorated(prorated: Boolean) = prorated(prorated as Boolean?) + + /** + * Sets [Builder.prorated] to an arbitrary JSON value. + * + * You should usually call [Builder.prorated] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun prorated(prorated: JsonField) = apply { + this.prorated = prorated + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [MinimumConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .minimumAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MinimumConfig = + MinimumConfig( + checkRequired("minimumAmount", minimumAmount), + prorated, + additionalProperties.toMutableMap(), + ) + } - private val hashCode: Int by lazy { - Objects.hash(adjustment, replacesAdjustmentId, planPhaseOrder, additionalProperties) + private var validated: Boolean = false + + fun validate(): MinimumConfig = apply { + if (validated) { + return@apply + } + + minimumAmount() + prorated() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (minimumAmount.asKnown() == null) 0 else 1) + + (if (prorated.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MinimumConfig && + minimumAmount == other.minimumAmount && + prorated == other.prorated && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(minimumAmount, prorated, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MinimumConfig{minimumAmount=$minimumAmount, prorated=$prorated, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Minimum && + cadence == other.cadence && + itemId == other.itemId && + minimumConfig == other.minimumConfig && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + minimumConfig, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Minimum{cadence=$cadence, itemId=$itemId, minimumConfig=$minimumConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AddPrice && + allocationPrice == other.allocationPrice && + planPhaseOrder == other.planPhaseOrder && + price == other.price && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(allocationPrice, planPhaseOrder, price, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "ReplaceAdjustment{adjustment=$adjustment, replacesAdjustmentId=$replacesAdjustmentId, planPhaseOrder=$planPhaseOrder, additionalProperties=$additionalProperties}" + "AddPrice{allocationPrice=$allocationPrice, planPhaseOrder=$planPhaseOrder, price=$price, additionalProperties=$additionalProperties}" } - class ReplacePrice + class RemoveAdjustment private constructor( - private val replacesPriceId: JsonField, - private val allocationPrice: JsonField, + private val adjustmentId: JsonField, private val planPhaseOrder: JsonField, - private val price: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("replaces_price_id") - @ExcludeMissing - replacesPriceId: JsonField = JsonMissing.of(), - @JsonProperty("allocation_price") + @JsonProperty("adjustment_id") @ExcludeMissing - allocationPrice: JsonField = JsonMissing.of(), + adjustmentId: JsonField = JsonMissing.of(), @JsonProperty("plan_phase_order") @ExcludeMissing planPhaseOrder: JsonField = JsonMissing.of(), - @JsonProperty("price") @ExcludeMissing price: JsonField = JsonMissing.of(), - ) : this(replacesPriceId, allocationPrice, planPhaseOrder, price, mutableMapOf()) + ) : this(adjustmentId, planPhaseOrder, mutableMapOf()) /** - * The id of the price on the plan to replace in the plan. + * The id of the adjustment to remove from on the plan. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ - fun replacesPriceId(): String = replacesPriceId.getRequired("replaces_price_id") - - /** - * The allocation price to add to the plan. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun allocationPrice(): NewAllocationPrice? = allocationPrice.getNullable("allocation_price") + fun adjustmentId(): String = adjustmentId.getRequired("adjustment_id") /** - * The phase to replace this price from. + * The phase to remove this adjustment from. * * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -4277,32 +6259,14 @@ private constructor( fun planPhaseOrder(): Long? = planPhaseOrder.getNullable("plan_phase_order") /** - * The price to add to the plan - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun price(): Price? = price.getNullable("price") - - /** - * Returns the raw JSON value of [replacesPriceId]. - * - * Unlike [replacesPriceId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("replaces_price_id") - @ExcludeMissing - fun _replacesPriceId(): JsonField = replacesPriceId - - /** - * Returns the raw JSON value of [allocationPrice]. + * Returns the raw JSON value of [adjustmentId]. * - * Unlike [allocationPrice], this method doesn't throw if the JSON field has an unexpected + * Unlike [adjustmentId], this method doesn't throw if the JSON field has an unexpected * type. */ - @JsonProperty("allocation_price") + @JsonProperty("adjustment_id") @ExcludeMissing - fun _allocationPrice(): JsonField = allocationPrice + fun _adjustmentId(): JsonField = adjustmentId /** * Returns the raw JSON value of [planPhaseOrder]. @@ -4314,13 +6278,6 @@ private constructor( @ExcludeMissing fun _planPhaseOrder(): JsonField = planPhaseOrder - /** - * Returns the raw JSON value of [price]. - * - * Unlike [price], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("price") @ExcludeMissing fun _price(): JsonField = price - @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -4336,64 +6293,44 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [ReplacePrice]. + * Returns a mutable builder for constructing an instance of [RemoveAdjustment]. * * The following fields are required: * ```kotlin - * .replacesPriceId() + * .adjustmentId() * ``` */ fun builder() = Builder() } - /** A builder for [ReplacePrice]. */ + /** A builder for [RemoveAdjustment]. */ class Builder internal constructor() { - private var replacesPriceId: JsonField? = null - private var allocationPrice: JsonField = JsonMissing.of() + private var adjustmentId: JsonField? = null private var planPhaseOrder: JsonField = JsonMissing.of() - private var price: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(replacePrice: ReplacePrice) = apply { - replacesPriceId = replacePrice.replacesPriceId - allocationPrice = replacePrice.allocationPrice - planPhaseOrder = replacePrice.planPhaseOrder - price = replacePrice.price - additionalProperties = replacePrice.additionalProperties.toMutableMap() + internal fun from(removeAdjustment: RemoveAdjustment) = apply { + adjustmentId = removeAdjustment.adjustmentId + planPhaseOrder = removeAdjustment.planPhaseOrder + additionalProperties = removeAdjustment.additionalProperties.toMutableMap() } - /** The id of the price on the plan to replace in the plan. */ - fun replacesPriceId(replacesPriceId: String) = - replacesPriceId(JsonField.of(replacesPriceId)) + /** The id of the adjustment to remove from on the plan. */ + fun adjustmentId(adjustmentId: String) = adjustmentId(JsonField.of(adjustmentId)) /** - * Sets [Builder.replacesPriceId] to an arbitrary JSON value. + * Sets [Builder.adjustmentId] to an arbitrary JSON value. * - * You should usually call [Builder.replacesPriceId] with a well-typed [String] value + * You should usually call [Builder.adjustmentId] with a well-typed [String] value * instead. This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun replacesPriceId(replacesPriceId: JsonField) = apply { - this.replacesPriceId = replacesPriceId - } - - /** The allocation price to add to the plan. */ - fun allocationPrice(allocationPrice: NewAllocationPrice?) = - allocationPrice(JsonField.ofNullable(allocationPrice)) - - /** - * Sets [Builder.allocationPrice] to an arbitrary JSON value. - * - * You should usually call [Builder.allocationPrice] with a well-typed - * [NewAllocationPrice] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun allocationPrice(allocationPrice: JsonField) = apply { - this.allocationPrice = allocationPrice + fun adjustmentId(adjustmentId: JsonField) = apply { + this.adjustmentId = adjustmentId } - /** The phase to replace this price from. */ + /** The phase to remove this adjustment from. */ fun planPhaseOrder(planPhaseOrder: Long?) = planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) @@ -4415,157 +6352,215 @@ private constructor( this.planPhaseOrder = planPhaseOrder } - /** The price to add to the plan */ - fun price(price: Price?) = price(JsonField.ofNullable(price)) - - /** - * Sets [Builder.price] to an arbitrary JSON value. - * - * You should usually call [Builder.price] with a well-typed [Price] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun price(price: JsonField) = apply { this.price = price } - - /** Alias for calling [price] with `Price.ofUnit(unit)`. */ - fun price(unit: NewPlanUnitPrice) = price(Price.ofUnit(unit)) - - /** Alias for calling [price] with `Price.ofPackage(package_)`. */ - fun price(package_: NewPlanPackagePrice) = price(Price.ofPackage(package_)) - - /** Alias for calling [price] with `Price.ofMatrix(matrix)`. */ - fun price(matrix: NewPlanMatrixPrice) = price(Price.ofMatrix(matrix)) - - /** Alias for calling [price] with `Price.ofTiered(tiered)`. */ - fun price(tiered: NewPlanTieredPrice) = price(Price.ofTiered(tiered)) + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** Alias for calling [price] with `Price.ofTieredBps(tieredBps)`. */ - fun price(tieredBps: NewPlanTieredBpsPrice) = price(Price.ofTieredBps(tieredBps)) + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** Alias for calling [price] with `Price.ofBps(bps)`. */ - fun price(bps: NewPlanBpsPrice) = price(Price.ofBps(bps)) + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - /** Alias for calling [price] with `Price.ofBulkBps(bulkBps)`. */ - fun price(bulkBps: NewPlanBulkBpsPrice) = price(Price.ofBulkBps(bulkBps)) + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - /** Alias for calling [price] with `Price.ofBulk(bulk)`. */ - fun price(bulk: NewPlanBulkPrice) = price(Price.ofBulk(bulk)) + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } /** - * Alias for calling [price] with `Price.ofThresholdTotalAmount(thresholdTotalAmount)`. + * Returns an immutable instance of [RemoveAdjustment]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .adjustmentId() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ - fun price(thresholdTotalAmount: NewPlanThresholdTotalAmountPrice) = - price(Price.ofThresholdTotalAmount(thresholdTotalAmount)) + fun build(): RemoveAdjustment = + RemoveAdjustment( + checkRequired("adjustmentId", adjustmentId), + planPhaseOrder, + additionalProperties.toMutableMap(), + ) + } - /** Alias for calling [price] with `Price.ofTieredPackage(tieredPackage)`. */ - fun price(tieredPackage: NewPlanTieredPackagePrice) = - price(Price.ofTieredPackage(tieredPackage)) + private var validated: Boolean = false - /** Alias for calling [price] with `Price.ofTieredWithMinimum(tieredWithMinimum)`. */ - fun price(tieredWithMinimum: NewPlanTieredWithMinimumPrice) = - price(Price.ofTieredWithMinimum(tieredWithMinimum)) + fun validate(): RemoveAdjustment = apply { + if (validated) { + return@apply + } - /** Alias for calling [price] with `Price.ofUnitWithPercent(unitWithPercent)`. */ - fun price(unitWithPercent: NewPlanUnitWithPercentPrice) = - price(Price.ofUnitWithPercent(unitWithPercent)) + adjustmentId() + planPhaseOrder() + validated = true + } - /** - * Alias for calling [price] with - * `Price.ofPackageWithAllocation(packageWithAllocation)`. - */ - fun price(packageWithAllocation: NewPlanPackageWithAllocationPrice) = - price(Price.ofPackageWithAllocation(packageWithAllocation)) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - /** - * Alias for calling [price] with `Price.ofTieredWithProration(tieredWithProration)`. - */ - fun price(tieredWithProration: NewPlanTierWithProrationPrice) = - price(Price.ofTieredWithProration(tieredWithProration)) + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (adjustmentId.asKnown() == null) 0 else 1) + + (if (planPhaseOrder.asKnown() == null) 0 else 1) - /** Alias for calling [price] with `Price.ofUnitWithProration(unitWithProration)`. */ - fun price(unitWithProration: NewPlanUnitWithProrationPrice) = - price(Price.ofUnitWithProration(unitWithProration)) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** Alias for calling [price] with `Price.ofGroupedAllocation(groupedAllocation)`. */ - fun price(groupedAllocation: NewPlanGroupedAllocationPrice) = - price(Price.ofGroupedAllocation(groupedAllocation)) + return other is RemoveAdjustment && + adjustmentId == other.adjustmentId && + planPhaseOrder == other.planPhaseOrder && + additionalProperties == other.additionalProperties + } - /** - * Alias for calling [price] with - * `Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)`. - */ - fun price(groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice) = - price(Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)) + private val hashCode: Int by lazy { + Objects.hash(adjustmentId, planPhaseOrder, additionalProperties) + } - /** - * Alias for calling [price] with - * `Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)`. - */ - fun price(groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice) = - price(Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)) + override fun hashCode(): Int = hashCode - /** - * Alias for calling [price] with - * `Price.ofMatrixWithDisplayName(matrixWithDisplayName)`. - */ - fun price(matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice) = - price(Price.ofMatrixWithDisplayName(matrixWithDisplayName)) + override fun toString() = + "RemoveAdjustment{adjustmentId=$adjustmentId, planPhaseOrder=$planPhaseOrder, additionalProperties=$additionalProperties}" + } - /** Alias for calling [price] with `Price.ofBulkWithProration(bulkWithProration)`. */ - fun price(bulkWithProration: NewPlanBulkWithProrationPrice) = - price(Price.ofBulkWithProration(bulkWithProration)) + class RemovePrice + private constructor( + private val priceId: JsonField, + private val planPhaseOrder: JsonField, + private val additionalProperties: MutableMap, + ) { - /** - * Alias for calling [price] with `Price.ofGroupedTieredPackage(groupedTieredPackage)`. - */ - fun price(groupedTieredPackage: NewPlanGroupedTieredPackagePrice) = - price(Price.ofGroupedTieredPackage(groupedTieredPackage)) + @JsonCreator + private constructor( + @JsonProperty("price_id") @ExcludeMissing priceId: JsonField = JsonMissing.of(), + @JsonProperty("plan_phase_order") + @ExcludeMissing + planPhaseOrder: JsonField = JsonMissing.of(), + ) : this(priceId, planPhaseOrder, mutableMapOf()) - /** - * Alias for calling [price] with - * `Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)`. - */ - fun price(maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice) = - price(Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)) + /** + * The id of the price to remove from the plan. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun priceId(): String = priceId.getRequired("price_id") - /** - * Alias for calling [price] with - * `Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)`. - */ - fun price(scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice) = - price(Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)) + /** + * The phase to remove this price from. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun planPhaseOrder(): Long? = planPhaseOrder.getNullable("plan_phase_order") + + /** + * Returns the raw JSON value of [priceId]. + * + * Unlike [priceId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId + + /** + * Returns the raw JSON value of [planPhaseOrder]. + * + * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { /** - * Alias for calling [price] with - * `Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)`. + * Returns a mutable builder for constructing an instance of [RemovePrice]. + * + * The following fields are required: + * ```kotlin + * .priceId() + * ``` */ - fun price( - scalableMatrixWithTieredPricing: NewPlanScalableMatrixWithTieredPricingPrice - ) = price(Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)) + fun builder() = Builder() + } + + /** A builder for [RemovePrice]. */ + class Builder internal constructor() { + + private var priceId: JsonField? = null + private var planPhaseOrder: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(removePrice: RemovePrice) = apply { + priceId = removePrice.priceId + planPhaseOrder = removePrice.planPhaseOrder + additionalProperties = removePrice.additionalProperties.toMutableMap() + } + + /** The id of the price to remove from the plan. */ + fun priceId(priceId: String) = priceId(JsonField.of(priceId)) /** - * Alias for calling [price] with - * `Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)`. + * Sets [Builder.priceId] to an arbitrary JSON value. + * + * You should usually call [Builder.priceId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun price(cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice) = - price(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) + fun priceId(priceId: JsonField) = apply { this.priceId = priceId } + + /** The phase to remove this price from. */ + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) /** - * Alias for calling [price] with - * `Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)`. + * Alias for [Builder.planPhaseOrder]. + * + * This unboxed primitive overload exists for backwards compatibility. */ - fun price(tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice) = - price(Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)) + fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) /** - * Alias for calling [price] with `Price.ofMatrixWithAllocation(matrixWithAllocation)`. + * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. + * + * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun price(matrixWithAllocation: NewPlanMatrixWithAllocationPrice) = - price(Price.ofMatrixWithAllocation(matrixWithAllocation)) - - /** Alias for calling [price] with `Price.ofGroupedTiered(groupedTiered)`. */ - fun price(groupedTiered: NewPlanGroupedTieredPrice) = - price(Price.ofGroupedTiered(groupedTiered)) + fun planPhaseOrder(planPhaseOrder: JsonField) = apply { + this.planPhaseOrder = planPhaseOrder + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -4587,38 +6582,34 @@ private constructor( } /** - * Returns an immutable instance of [ReplacePrice]. + * Returns an immutable instance of [RemovePrice]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```kotlin - * .replacesPriceId() + * .priceId() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): ReplacePrice = - ReplacePrice( - checkRequired("replacesPriceId", replacesPriceId), - allocationPrice, + fun build(): RemovePrice = + RemovePrice( + checkRequired("priceId", priceId), planPhaseOrder, - price, additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): ReplacePrice = apply { + fun validate(): RemovePrice = apply { if (validated) { return@apply } - replacesPriceId() - allocationPrice()?.validate() + priceId() planPhaseOrder() - price()?.validate() validated = true } @@ -4637,1138 +6628,5220 @@ private constructor( * Used for best match union deserialization. */ internal fun validity(): Int = - (if (replacesPriceId.asKnown() == null) 0 else 1) + - (allocationPrice.asKnown()?.validity() ?: 0) + - (if (planPhaseOrder.asKnown() == null) 0 else 1) + - (price.asKnown()?.validity() ?: 0) + (if (priceId.asKnown() == null) 0 else 1) + + (if (planPhaseOrder.asKnown() == null) 0 else 1) - /** The price to add to the plan */ - @JsonDeserialize(using = Price.Deserializer::class) - @JsonSerialize(using = Price.Serializer::class) - class Price - private constructor( - private val unit: NewPlanUnitPrice? = null, - private val package_: NewPlanPackagePrice? = null, - private val matrix: NewPlanMatrixPrice? = null, - private val tiered: NewPlanTieredPrice? = null, - private val tieredBps: NewPlanTieredBpsPrice? = null, - private val bps: NewPlanBpsPrice? = null, - private val bulkBps: NewPlanBulkBpsPrice? = null, - private val bulk: NewPlanBulkPrice? = null, - private val thresholdTotalAmount: NewPlanThresholdTotalAmountPrice? = null, - private val tieredPackage: NewPlanTieredPackagePrice? = null, - private val tieredWithMinimum: NewPlanTieredWithMinimumPrice? = null, - private val unitWithPercent: NewPlanUnitWithPercentPrice? = null, - private val packageWithAllocation: NewPlanPackageWithAllocationPrice? = null, - private val tieredWithProration: NewPlanTierWithProrationPrice? = null, - private val unitWithProration: NewPlanUnitWithProrationPrice? = null, - private val groupedAllocation: NewPlanGroupedAllocationPrice? = null, - private val groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice? = null, - private val groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice? = null, - private val matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice? = null, - private val bulkWithProration: NewPlanBulkWithProrationPrice? = null, - private val groupedTieredPackage: NewPlanGroupedTieredPackagePrice? = null, - private val maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice? = null, - private val scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice? = - null, - private val scalableMatrixWithTieredPricing: - NewPlanScalableMatrixWithTieredPricingPrice? = - null, - private val cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice? = null, - private val tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice? = null, - private val matrixWithAllocation: NewPlanMatrixWithAllocationPrice? = null, - private val groupedTiered: NewPlanGroupedTieredPrice? = null, - private val _json: JsonValue? = null, - ) { - - fun unit(): NewPlanUnitPrice? = unit + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun package_(): NewPlanPackagePrice? = package_ + return other is RemovePrice && + priceId == other.priceId && + planPhaseOrder == other.planPhaseOrder && + additionalProperties == other.additionalProperties + } - fun matrix(): NewPlanMatrixPrice? = matrix + private val hashCode: Int by lazy { + Objects.hash(priceId, planPhaseOrder, additionalProperties) + } - fun tiered(): NewPlanTieredPrice? = tiered + override fun hashCode(): Int = hashCode - fun tieredBps(): NewPlanTieredBpsPrice? = tieredBps + override fun toString() = + "RemovePrice{priceId=$priceId, planPhaseOrder=$planPhaseOrder, additionalProperties=$additionalProperties}" + } - fun bps(): NewPlanBpsPrice? = bps + class ReplaceAdjustment + private constructor( + private val adjustment: JsonField, + private val replacesAdjustmentId: JsonField, + private val planPhaseOrder: JsonField, + private val additionalProperties: MutableMap, + ) { - fun bulkBps(): NewPlanBulkBpsPrice? = bulkBps + @JsonCreator + private constructor( + @JsonProperty("adjustment") + @ExcludeMissing + adjustment: JsonField = JsonMissing.of(), + @JsonProperty("replaces_adjustment_id") + @ExcludeMissing + replacesAdjustmentId: JsonField = JsonMissing.of(), + @JsonProperty("plan_phase_order") + @ExcludeMissing + planPhaseOrder: JsonField = JsonMissing.of(), + ) : this(adjustment, replacesAdjustmentId, planPhaseOrder, mutableMapOf()) - fun bulk(): NewPlanBulkPrice? = bulk + /** + * The definition of a new adjustment to create and add to the plan. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun adjustment(): Adjustment = adjustment.getRequired("adjustment") - fun thresholdTotalAmount(): NewPlanThresholdTotalAmountPrice? = thresholdTotalAmount + /** + * The id of the adjustment on the plan to replace in the plan. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun replacesAdjustmentId(): String = + replacesAdjustmentId.getRequired("replaces_adjustment_id") - fun tieredPackage(): NewPlanTieredPackagePrice? = tieredPackage + /** + * The phase to replace this adjustment from. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun planPhaseOrder(): Long? = planPhaseOrder.getNullable("plan_phase_order") - fun tieredWithMinimum(): NewPlanTieredWithMinimumPrice? = tieredWithMinimum + /** + * Returns the raw JSON value of [adjustment]. + * + * Unlike [adjustment], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("adjustment") + @ExcludeMissing + fun _adjustment(): JsonField = adjustment - fun unitWithPercent(): NewPlanUnitWithPercentPrice? = unitWithPercent + /** + * Returns the raw JSON value of [replacesAdjustmentId]. + * + * Unlike [replacesAdjustmentId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("replaces_adjustment_id") + @ExcludeMissing + fun _replacesAdjustmentId(): JsonField = replacesAdjustmentId - fun packageWithAllocation(): NewPlanPackageWithAllocationPrice? = packageWithAllocation + /** + * Returns the raw JSON value of [planPhaseOrder]. + * + * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder - fun tieredWithProration(): NewPlanTierWithProrationPrice? = tieredWithProration + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - fun unitWithProration(): NewPlanUnitWithProrationPrice? = unitWithProration + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - fun groupedAllocation(): NewPlanGroupedAllocationPrice? = groupedAllocation + fun toBuilder() = Builder().from(this) - fun groupedWithProratedMinimum(): NewPlanGroupedWithProratedMinimumPrice? = - groupedWithProratedMinimum + companion object { - fun groupedWithMeteredMinimum(): NewPlanGroupedWithMeteredMinimumPrice? = - groupedWithMeteredMinimum + /** + * Returns a mutable builder for constructing an instance of [ReplaceAdjustment]. + * + * The following fields are required: + * ```kotlin + * .adjustment() + * .replacesAdjustmentId() + * ``` + */ + fun builder() = Builder() + } - fun matrixWithDisplayName(): NewPlanMatrixWithDisplayNamePrice? = matrixWithDisplayName + /** A builder for [ReplaceAdjustment]. */ + class Builder internal constructor() { - fun bulkWithProration(): NewPlanBulkWithProrationPrice? = bulkWithProration + private var adjustment: JsonField? = null + private var replacesAdjustmentId: JsonField? = null + private var planPhaseOrder: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - fun groupedTieredPackage(): NewPlanGroupedTieredPackagePrice? = groupedTieredPackage + internal fun from(replaceAdjustment: ReplaceAdjustment) = apply { + adjustment = replaceAdjustment.adjustment + replacesAdjustmentId = replaceAdjustment.replacesAdjustmentId + planPhaseOrder = replaceAdjustment.planPhaseOrder + additionalProperties = replaceAdjustment.additionalProperties.toMutableMap() + } - fun maxGroupTieredPackage(): NewPlanMaxGroupTieredPackagePrice? = maxGroupTieredPackage + /** The definition of a new adjustment to create and add to the plan. */ + fun adjustment(adjustment: Adjustment) = adjustment(JsonField.of(adjustment)) - fun scalableMatrixWithUnitPricing(): NewPlanScalableMatrixWithUnitPricingPrice? = - scalableMatrixWithUnitPricing + /** + * Sets [Builder.adjustment] to an arbitrary JSON value. + * + * You should usually call [Builder.adjustment] with a well-typed [Adjustment] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun adjustment(adjustment: JsonField) = apply { + this.adjustment = adjustment + } - fun scalableMatrixWithTieredPricing(): NewPlanScalableMatrixWithTieredPricingPrice? = - scalableMatrixWithTieredPricing + /** + * Alias for calling [adjustment] with + * `Adjustment.ofPercentageDiscount(percentageDiscount)`. + */ + fun adjustment(percentageDiscount: NewPercentageDiscount) = + adjustment(Adjustment.ofPercentageDiscount(percentageDiscount)) - fun cumulativeGroupedBulk(): NewPlanCumulativeGroupedBulkPrice? = cumulativeGroupedBulk + /** + * Alias for calling [adjustment] with the following: + * ```kotlin + * NewPercentageDiscount.builder() + * .adjustmentType(NewPercentageDiscount.AdjustmentType.PERCENTAGE_DISCOUNT) + * .percentageDiscount(percentageDiscount) + * .build() + * ``` + */ + fun percentageDiscountAdjustment(percentageDiscount: Double) = + adjustment( + NewPercentageDiscount.builder() + .adjustmentType(NewPercentageDiscount.AdjustmentType.PERCENTAGE_DISCOUNT) + .percentageDiscount(percentageDiscount) + .build() + ) - fun tieredPackageWithMinimum(): NewPlanTieredPackageWithMinimumPrice? = - tieredPackageWithMinimum + /** Alias for calling [adjustment] with `Adjustment.ofUsageDiscount(usageDiscount)`. */ + fun adjustment(usageDiscount: NewUsageDiscount) = + adjustment(Adjustment.ofUsageDiscount(usageDiscount)) - fun matrixWithAllocation(): NewPlanMatrixWithAllocationPrice? = matrixWithAllocation + /** + * Alias for calling [adjustment] with the following: + * ```kotlin + * NewUsageDiscount.builder() + * .adjustmentType(NewUsageDiscount.AdjustmentType.USAGE_DISCOUNT) + * .usageDiscount(usageDiscount) + * .build() + * ``` + */ + fun usageDiscountAdjustment(usageDiscount: Double) = + adjustment( + NewUsageDiscount.builder() + .adjustmentType(NewUsageDiscount.AdjustmentType.USAGE_DISCOUNT) + .usageDiscount(usageDiscount) + .build() + ) - fun groupedTiered(): NewPlanGroupedTieredPrice? = groupedTiered + /** + * Alias for calling [adjustment] with `Adjustment.ofAmountDiscount(amountDiscount)`. + */ + fun adjustment(amountDiscount: NewAmountDiscount) = + adjustment(Adjustment.ofAmountDiscount(amountDiscount)) - fun isUnit(): Boolean = unit != null + /** + * Alias for calling [adjustment] with the following: + * ```kotlin + * NewAmountDiscount.builder() + * .adjustmentType(NewAmountDiscount.AdjustmentType.AMOUNT_DISCOUNT) + * .amountDiscount(amountDiscount) + * .build() + * ``` + */ + fun amountDiscountAdjustment(amountDiscount: String) = + adjustment( + NewAmountDiscount.builder() + .adjustmentType(NewAmountDiscount.AdjustmentType.AMOUNT_DISCOUNT) + .amountDiscount(amountDiscount) + .build() + ) - fun isPackage(): Boolean = package_ != null + /** Alias for calling [adjustment] with `Adjustment.ofMinimum(minimum)`. */ + fun adjustment(minimum: NewMinimum) = adjustment(Adjustment.ofMinimum(minimum)) - fun isMatrix(): Boolean = matrix != null + /** Alias for calling [adjustment] with `Adjustment.ofMaximum(maximum)`. */ + fun adjustment(maximum: NewMaximum) = adjustment(Adjustment.ofMaximum(maximum)) - fun isTiered(): Boolean = tiered != null + /** + * Alias for calling [adjustment] with the following: + * ```kotlin + * NewMaximum.builder() + * .adjustmentType(NewMaximum.AdjustmentType.MAXIMUM) + * .maximumAmount(maximumAmount) + * .build() + * ``` + */ + fun maximumAdjustment(maximumAmount: String) = + adjustment( + NewMaximum.builder() + .adjustmentType(NewMaximum.AdjustmentType.MAXIMUM) + .maximumAmount(maximumAmount) + .build() + ) - fun isTieredBps(): Boolean = tieredBps != null + /** The id of the adjustment on the plan to replace in the plan. */ + fun replacesAdjustmentId(replacesAdjustmentId: String) = + replacesAdjustmentId(JsonField.of(replacesAdjustmentId)) - fun isBps(): Boolean = bps != null + /** + * Sets [Builder.replacesAdjustmentId] to an arbitrary JSON value. + * + * You should usually call [Builder.replacesAdjustmentId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun replacesAdjustmentId(replacesAdjustmentId: JsonField) = apply { + this.replacesAdjustmentId = replacesAdjustmentId + } - fun isBulkBps(): Boolean = bulkBps != null + /** The phase to replace this adjustment from. */ + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) - fun isBulk(): Boolean = bulk != null + /** + * Alias for [Builder.planPhaseOrder]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) - fun isThresholdTotalAmount(): Boolean = thresholdTotalAmount != null + /** + * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. + * + * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun planPhaseOrder(planPhaseOrder: JsonField) = apply { + this.planPhaseOrder = planPhaseOrder + } - fun isTieredPackage(): Boolean = tieredPackage != null + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun isTieredWithMinimum(): Boolean = tieredWithMinimum != null + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun isUnitWithPercent(): Boolean = unitWithPercent != null + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun isPackageWithAllocation(): Boolean = packageWithAllocation != null + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - fun isTieredWithProration(): Boolean = tieredWithProration != null + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - fun isUnitWithProration(): Boolean = unitWithProration != null + /** + * Returns an immutable instance of [ReplaceAdjustment]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .adjustment() + * .replacesAdjustmentId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ReplaceAdjustment = + ReplaceAdjustment( + checkRequired("adjustment", adjustment), + checkRequired("replacesAdjustmentId", replacesAdjustmentId), + planPhaseOrder, + additionalProperties.toMutableMap(), + ) + } - fun isGroupedAllocation(): Boolean = groupedAllocation != null + private var validated: Boolean = false - fun isGroupedWithProratedMinimum(): Boolean = groupedWithProratedMinimum != null + fun validate(): ReplaceAdjustment = apply { + if (validated) { + return@apply + } - fun isGroupedWithMeteredMinimum(): Boolean = groupedWithMeteredMinimum != null + adjustment().validate() + replacesAdjustmentId() + planPhaseOrder() + validated = true + } - fun isMatrixWithDisplayName(): Boolean = matrixWithDisplayName != null + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - fun isBulkWithProration(): Boolean = bulkWithProration != null + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (adjustment.asKnown()?.validity() ?: 0) + + (if (replacesAdjustmentId.asKnown() == null) 0 else 1) + + (if (planPhaseOrder.asKnown() == null) 0 else 1) - fun isGroupedTieredPackage(): Boolean = groupedTieredPackage != null + /** The definition of a new adjustment to create and add to the plan. */ + @JsonDeserialize(using = Adjustment.Deserializer::class) + @JsonSerialize(using = Adjustment.Serializer::class) + class Adjustment + private constructor( + private val percentageDiscount: NewPercentageDiscount? = null, + private val usageDiscount: NewUsageDiscount? = null, + private val amountDiscount: NewAmountDiscount? = null, + private val minimum: NewMinimum? = null, + private val maximum: NewMaximum? = null, + private val _json: JsonValue? = null, + ) { - fun isMaxGroupTieredPackage(): Boolean = maxGroupTieredPackage != null + fun percentageDiscount(): NewPercentageDiscount? = percentageDiscount - fun isScalableMatrixWithUnitPricing(): Boolean = scalableMatrixWithUnitPricing != null + fun usageDiscount(): NewUsageDiscount? = usageDiscount - fun isScalableMatrixWithTieredPricing(): Boolean = - scalableMatrixWithTieredPricing != null + fun amountDiscount(): NewAmountDiscount? = amountDiscount - fun isCumulativeGroupedBulk(): Boolean = cumulativeGroupedBulk != null + fun minimum(): NewMinimum? = minimum - fun isTieredPackageWithMinimum(): Boolean = tieredPackageWithMinimum != null + fun maximum(): NewMaximum? = maximum - fun isMatrixWithAllocation(): Boolean = matrixWithAllocation != null + fun isPercentageDiscount(): Boolean = percentageDiscount != null - fun isGroupedTiered(): Boolean = groupedTiered != null + fun isUsageDiscount(): Boolean = usageDiscount != null - fun asUnit(): NewPlanUnitPrice = unit.getOrThrow("unit") + fun isAmountDiscount(): Boolean = amountDiscount != null - fun asPackage(): NewPlanPackagePrice = package_.getOrThrow("package_") + fun isMinimum(): Boolean = minimum != null - fun asMatrix(): NewPlanMatrixPrice = matrix.getOrThrow("matrix") + fun isMaximum(): Boolean = maximum != null - fun asTiered(): NewPlanTieredPrice = tiered.getOrThrow("tiered") + fun asPercentageDiscount(): NewPercentageDiscount = + percentageDiscount.getOrThrow("percentageDiscount") - fun asTieredBps(): NewPlanTieredBpsPrice = tieredBps.getOrThrow("tieredBps") + fun asUsageDiscount(): NewUsageDiscount = usageDiscount.getOrThrow("usageDiscount") - fun asBps(): NewPlanBpsPrice = bps.getOrThrow("bps") + fun asAmountDiscount(): NewAmountDiscount = amountDiscount.getOrThrow("amountDiscount") - fun asBulkBps(): NewPlanBulkBpsPrice = bulkBps.getOrThrow("bulkBps") + fun asMinimum(): NewMinimum = minimum.getOrThrow("minimum") - fun asBulk(): NewPlanBulkPrice = bulk.getOrThrow("bulk") + fun asMaximum(): NewMaximum = maximum.getOrThrow("maximum") - fun asThresholdTotalAmount(): NewPlanThresholdTotalAmountPrice = - thresholdTotalAmount.getOrThrow("thresholdTotalAmount") + fun _json(): JsonValue? = _json - fun asTieredPackage(): NewPlanTieredPackagePrice = - tieredPackage.getOrThrow("tieredPackage") + fun accept(visitor: Visitor): T = + when { + percentageDiscount != null -> + visitor.visitPercentageDiscount(percentageDiscount) + usageDiscount != null -> visitor.visitUsageDiscount(usageDiscount) + amountDiscount != null -> visitor.visitAmountDiscount(amountDiscount) + minimum != null -> visitor.visitMinimum(minimum) + maximum != null -> visitor.visitMaximum(maximum) + else -> visitor.unknown(_json) + } - fun asTieredWithMinimum(): NewPlanTieredWithMinimumPrice = - tieredWithMinimum.getOrThrow("tieredWithMinimum") + private var validated: Boolean = false - fun asUnitWithPercent(): NewPlanUnitWithPercentPrice = - unitWithPercent.getOrThrow("unitWithPercent") + fun validate(): Adjustment = apply { + if (validated) { + return@apply + } - fun asPackageWithAllocation(): NewPlanPackageWithAllocationPrice = - packageWithAllocation.getOrThrow("packageWithAllocation") + accept( + object : Visitor { + override fun visitPercentageDiscount( + percentageDiscount: NewPercentageDiscount + ) { + percentageDiscount.validate() + } - fun asTieredWithProration(): NewPlanTierWithProrationPrice = - tieredWithProration.getOrThrow("tieredWithProration") + override fun visitUsageDiscount(usageDiscount: NewUsageDiscount) { + usageDiscount.validate() + } - fun asUnitWithProration(): NewPlanUnitWithProrationPrice = - unitWithProration.getOrThrow("unitWithProration") + override fun visitAmountDiscount(amountDiscount: NewAmountDiscount) { + amountDiscount.validate() + } - fun asGroupedAllocation(): NewPlanGroupedAllocationPrice = - groupedAllocation.getOrThrow("groupedAllocation") + override fun visitMinimum(minimum: NewMinimum) { + minimum.validate() + } - fun asGroupedWithProratedMinimum(): NewPlanGroupedWithProratedMinimumPrice = - groupedWithProratedMinimum.getOrThrow("groupedWithProratedMinimum") + override fun visitMaximum(maximum: NewMaximum) { + maximum.validate() + } + } + ) + validated = true + } - fun asGroupedWithMeteredMinimum(): NewPlanGroupedWithMeteredMinimumPrice = - groupedWithMeteredMinimum.getOrThrow("groupedWithMeteredMinimum") + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - fun asMatrixWithDisplayName(): NewPlanMatrixWithDisplayNamePrice = - matrixWithDisplayName.getOrThrow("matrixWithDisplayName") + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitPercentageDiscount( + percentageDiscount: NewPercentageDiscount + ) = percentageDiscount.validity() - fun asBulkWithProration(): NewPlanBulkWithProrationPrice = - bulkWithProration.getOrThrow("bulkWithProration") + override fun visitUsageDiscount(usageDiscount: NewUsageDiscount) = + usageDiscount.validity() - fun asGroupedTieredPackage(): NewPlanGroupedTieredPackagePrice = - groupedTieredPackage.getOrThrow("groupedTieredPackage") + override fun visitAmountDiscount(amountDiscount: NewAmountDiscount) = + amountDiscount.validity() - fun asMaxGroupTieredPackage(): NewPlanMaxGroupTieredPackagePrice = - maxGroupTieredPackage.getOrThrow("maxGroupTieredPackage") + override fun visitMinimum(minimum: NewMinimum) = minimum.validity() - fun asScalableMatrixWithUnitPricing(): NewPlanScalableMatrixWithUnitPricingPrice = - scalableMatrixWithUnitPricing.getOrThrow("scalableMatrixWithUnitPricing") - - fun asScalableMatrixWithTieredPricing(): NewPlanScalableMatrixWithTieredPricingPrice = - scalableMatrixWithTieredPricing.getOrThrow("scalableMatrixWithTieredPricing") - - fun asCumulativeGroupedBulk(): NewPlanCumulativeGroupedBulkPrice = - cumulativeGroupedBulk.getOrThrow("cumulativeGroupedBulk") + override fun visitMaximum(maximum: NewMaximum) = maximum.validity() - fun asTieredPackageWithMinimum(): NewPlanTieredPackageWithMinimumPrice = - tieredPackageWithMinimum.getOrThrow("tieredPackageWithMinimum") + override fun unknown(json: JsonValue?) = 0 + } + ) - fun asMatrixWithAllocation(): NewPlanMatrixWithAllocationPrice = - matrixWithAllocation.getOrThrow("matrixWithAllocation") + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun asGroupedTiered(): NewPlanGroupedTieredPrice = - groupedTiered.getOrThrow("groupedTiered") + return other is Adjustment && + percentageDiscount == other.percentageDiscount && + usageDiscount == other.usageDiscount && + amountDiscount == other.amountDiscount && + minimum == other.minimum && + maximum == other.maximum + } - fun _json(): JsonValue? = _json + override fun hashCode(): Int = + Objects.hash(percentageDiscount, usageDiscount, amountDiscount, minimum, maximum) - fun accept(visitor: Visitor): T = + override fun toString(): String = when { - unit != null -> visitor.visitUnit(unit) - package_ != null -> visitor.visitPackage(package_) - matrix != null -> visitor.visitMatrix(matrix) - tiered != null -> visitor.visitTiered(tiered) - tieredBps != null -> visitor.visitTieredBps(tieredBps) - bps != null -> visitor.visitBps(bps) - bulkBps != null -> visitor.visitBulkBps(bulkBps) - bulk != null -> visitor.visitBulk(bulk) - thresholdTotalAmount != null -> - visitor.visitThresholdTotalAmount(thresholdTotalAmount) - tieredPackage != null -> visitor.visitTieredPackage(tieredPackage) - tieredWithMinimum != null -> visitor.visitTieredWithMinimum(tieredWithMinimum) - unitWithPercent != null -> visitor.visitUnitWithPercent(unitWithPercent) - packageWithAllocation != null -> - visitor.visitPackageWithAllocation(packageWithAllocation) - tieredWithProration != null -> - visitor.visitTieredWithProration(tieredWithProration) - unitWithProration != null -> visitor.visitUnitWithProration(unitWithProration) - groupedAllocation != null -> visitor.visitGroupedAllocation(groupedAllocation) - groupedWithProratedMinimum != null -> - visitor.visitGroupedWithProratedMinimum(groupedWithProratedMinimum) - groupedWithMeteredMinimum != null -> - visitor.visitGroupedWithMeteredMinimum(groupedWithMeteredMinimum) - matrixWithDisplayName != null -> - visitor.visitMatrixWithDisplayName(matrixWithDisplayName) - bulkWithProration != null -> visitor.visitBulkWithProration(bulkWithProration) - groupedTieredPackage != null -> - visitor.visitGroupedTieredPackage(groupedTieredPackage) - maxGroupTieredPackage != null -> - visitor.visitMaxGroupTieredPackage(maxGroupTieredPackage) - scalableMatrixWithUnitPricing != null -> - visitor.visitScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing) - scalableMatrixWithTieredPricing != null -> - visitor.visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing - ) - cumulativeGroupedBulk != null -> - visitor.visitCumulativeGroupedBulk(cumulativeGroupedBulk) - tieredPackageWithMinimum != null -> - visitor.visitTieredPackageWithMinimum(tieredPackageWithMinimum) - matrixWithAllocation != null -> - visitor.visitMatrixWithAllocation(matrixWithAllocation) - groupedTiered != null -> visitor.visitGroupedTiered(groupedTiered) - else -> visitor.unknown(_json) + percentageDiscount != null -> + "Adjustment{percentageDiscount=$percentageDiscount}" + usageDiscount != null -> "Adjustment{usageDiscount=$usageDiscount}" + amountDiscount != null -> "Adjustment{amountDiscount=$amountDiscount}" + minimum != null -> "Adjustment{minimum=$minimum}" + maximum != null -> "Adjustment{maximum=$maximum}" + _json != null -> "Adjustment{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Adjustment") } - private var validated: Boolean = false + companion object { - fun validate(): Price = apply { - if (validated) { - return@apply - } + fun ofPercentageDiscount(percentageDiscount: NewPercentageDiscount) = + Adjustment(percentageDiscount = percentageDiscount) - accept( - object : Visitor { - override fun visitUnit(unit: NewPlanUnitPrice) { - unit.validate() - } + fun ofUsageDiscount(usageDiscount: NewUsageDiscount) = + Adjustment(usageDiscount = usageDiscount) - override fun visitPackage(package_: NewPlanPackagePrice) { - package_.validate() - } + fun ofAmountDiscount(amountDiscount: NewAmountDiscount) = + Adjustment(amountDiscount = amountDiscount) - override fun visitMatrix(matrix: NewPlanMatrixPrice) { - matrix.validate() - } + fun ofMinimum(minimum: NewMinimum) = Adjustment(minimum = minimum) - override fun visitTiered(tiered: NewPlanTieredPrice) { - tiered.validate() - } + fun ofMaximum(maximum: NewMaximum) = Adjustment(maximum = maximum) + } - override fun visitTieredBps(tieredBps: NewPlanTieredBpsPrice) { - tieredBps.validate() - } + /** + * An interface that defines how to map each variant of [Adjustment] to a value of type + * [T]. + */ + interface Visitor { - override fun visitBps(bps: NewPlanBpsPrice) { - bps.validate() - } + fun visitPercentageDiscount(percentageDiscount: NewPercentageDiscount): T - override fun visitBulkBps(bulkBps: NewPlanBulkBpsPrice) { - bulkBps.validate() - } + fun visitUsageDiscount(usageDiscount: NewUsageDiscount): T - override fun visitBulk(bulk: NewPlanBulkPrice) { - bulk.validate() - } + fun visitAmountDiscount(amountDiscount: NewAmountDiscount): T - override fun visitThresholdTotalAmount( - thresholdTotalAmount: NewPlanThresholdTotalAmountPrice - ) { - thresholdTotalAmount.validate() - } + fun visitMinimum(minimum: NewMinimum): T - override fun visitTieredPackage(tieredPackage: NewPlanTieredPackagePrice) { - tieredPackage.validate() - } + fun visitMaximum(maximum: NewMaximum): T - override fun visitTieredWithMinimum( - tieredWithMinimum: NewPlanTieredWithMinimumPrice - ) { - tieredWithMinimum.validate() - } + /** + * Maps an unknown variant of [Adjustment] to a value of type [T]. + * + * An instance of [Adjustment] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the + * SDK is unaware of. + * + * @throws OrbInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw OrbInvalidDataException("Unknown Adjustment: $json") + } + } - override fun visitUnitWithPercent( - unitWithPercent: NewPlanUnitWithPercentPrice - ) { - unitWithPercent.validate() - } + internal class Deserializer : BaseDeserializer(Adjustment::class) { - override fun visitPackageWithAllocation( - packageWithAllocation: NewPlanPackageWithAllocationPrice - ) { - packageWithAllocation.validate() - } + override fun ObjectCodec.deserialize(node: JsonNode): Adjustment { + val json = JsonValue.fromJsonNode(node) + val adjustmentType = json.asObject()?.get("adjustment_type")?.asString() - override fun visitTieredWithProration( - tieredWithProration: NewPlanTierWithProrationPrice - ) { - tieredWithProration.validate() + when (adjustmentType) { + "percentage_discount" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Adjustment(percentageDiscount = it, _json = json) } + ?: Adjustment(_json = json) } - - override fun visitUnitWithProration( - unitWithProration: NewPlanUnitWithProrationPrice - ) { - unitWithProration.validate() + "usage_discount" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(usageDiscount = it, _json = json) + } ?: Adjustment(_json = json) } - - override fun visitGroupedAllocation( - groupedAllocation: NewPlanGroupedAllocationPrice - ) { - groupedAllocation.validate() + "amount_discount" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(amountDiscount = it, _json = json) + } ?: Adjustment(_json = json) } - - override fun visitGroupedWithProratedMinimum( - groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice - ) { - groupedWithProratedMinimum.validate() + "minimum" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(minimum = it, _json = json) + } ?: Adjustment(_json = json) } - - override fun visitGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice - ) { - groupedWithMeteredMinimum.validate() + "maximum" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(maximum = it, _json = json) + } ?: Adjustment(_json = json) } + } - override fun visitMatrixWithDisplayName( - matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice - ) { - matrixWithDisplayName.validate() - } + return Adjustment(_json = json) + } + } - override fun visitBulkWithProration( - bulkWithProration: NewPlanBulkWithProrationPrice - ) { - bulkWithProration.validate() - } + internal class Serializer : BaseSerializer(Adjustment::class) { - override fun visitGroupedTieredPackage( - groupedTieredPackage: NewPlanGroupedTieredPackagePrice - ) { - groupedTieredPackage.validate() - } + override fun serialize( + value: Adjustment, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.percentageDiscount != null -> + generator.writeObject(value.percentageDiscount) + value.usageDiscount != null -> generator.writeObject(value.usageDiscount) + value.amountDiscount != null -> generator.writeObject(value.amountDiscount) + value.minimum != null -> generator.writeObject(value.minimum) + value.maximum != null -> generator.writeObject(value.maximum) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Adjustment") + } + } + } + } - override fun visitMaxGroupTieredPackage( - maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice - ) { - maxGroupTieredPackage.validate() - } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - override fun visitScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice - ) { - scalableMatrixWithUnitPricing.validate() - } + return other is ReplaceAdjustment && + adjustment == other.adjustment && + replacesAdjustmentId == other.replacesAdjustmentId && + planPhaseOrder == other.planPhaseOrder && + additionalProperties == other.additionalProperties + } - override fun visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: - NewPlanScalableMatrixWithTieredPricingPrice - ) { - scalableMatrixWithTieredPricing.validate() - } + private val hashCode: Int by lazy { + Objects.hash(adjustment, replacesAdjustmentId, planPhaseOrder, additionalProperties) + } - override fun visitCumulativeGroupedBulk( - cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice - ) { - cumulativeGroupedBulk.validate() - } + override fun hashCode(): Int = hashCode - override fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice - ) { - tieredPackageWithMinimum.validate() - } + override fun toString() = + "ReplaceAdjustment{adjustment=$adjustment, replacesAdjustmentId=$replacesAdjustmentId, planPhaseOrder=$planPhaseOrder, additionalProperties=$additionalProperties}" + } - override fun visitMatrixWithAllocation( - matrixWithAllocation: NewPlanMatrixWithAllocationPrice - ) { - matrixWithAllocation.validate() - } + class ReplacePrice + private constructor( + private val replacesPriceId: JsonField, + private val allocationPrice: JsonField, + private val planPhaseOrder: JsonField, + private val price: JsonField, + private val additionalProperties: MutableMap, + ) { - override fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) { - groupedTiered.validate() - } - } - ) - validated = true - } + @JsonCreator + private constructor( + @JsonProperty("replaces_price_id") + @ExcludeMissing + replacesPriceId: JsonField = JsonMissing.of(), + @JsonProperty("allocation_price") + @ExcludeMissing + allocationPrice: JsonField = JsonMissing.of(), + @JsonProperty("plan_phase_order") + @ExcludeMissing + planPhaseOrder: JsonField = JsonMissing.of(), + @JsonProperty("price") @ExcludeMissing price: JsonField = JsonMissing.of(), + ) : this(replacesPriceId, allocationPrice, planPhaseOrder, price, mutableMapOf()) - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** + * The id of the price on the plan to replace in the plan. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun replacesPriceId(): String = replacesPriceId.getRequired("replaces_price_id") - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: NewPlanUnitPrice) = unit.validity() + /** + * The allocation price to add to the plan. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun allocationPrice(): NewAllocationPrice? = allocationPrice.getNullable("allocation_price") - override fun visitPackage(package_: NewPlanPackagePrice) = - package_.validity() + /** + * The phase to replace this price from. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun planPhaseOrder(): Long? = planPhaseOrder.getNullable("plan_phase_order") - override fun visitMatrix(matrix: NewPlanMatrixPrice) = matrix.validity() + /** + * The price to add to the plan + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun price(): Price? = price.getNullable("price") - override fun visitTiered(tiered: NewPlanTieredPrice) = tiered.validity() + /** + * Returns the raw JSON value of [replacesPriceId]. + * + * Unlike [replacesPriceId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("replaces_price_id") + @ExcludeMissing + fun _replacesPriceId(): JsonField = replacesPriceId - override fun visitTieredBps(tieredBps: NewPlanTieredBpsPrice) = - tieredBps.validity() + /** + * Returns the raw JSON value of [allocationPrice]. + * + * Unlike [allocationPrice], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("allocation_price") + @ExcludeMissing + fun _allocationPrice(): JsonField = allocationPrice - override fun visitBps(bps: NewPlanBpsPrice) = bps.validity() + /** + * Returns the raw JSON value of [planPhaseOrder]. + * + * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder - override fun visitBulkBps(bulkBps: NewPlanBulkBpsPrice) = bulkBps.validity() + /** + * Returns the raw JSON value of [price]. + * + * Unlike [price], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("price") @ExcludeMissing fun _price(): JsonField = price - override fun visitBulk(bulk: NewPlanBulkPrice) = bulk.validity() + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - override fun visitThresholdTotalAmount( - thresholdTotalAmount: NewPlanThresholdTotalAmountPrice - ) = thresholdTotalAmount.validity() + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - override fun visitTieredPackage(tieredPackage: NewPlanTieredPackagePrice) = - tieredPackage.validity() + fun toBuilder() = Builder().from(this) - override fun visitTieredWithMinimum( - tieredWithMinimum: NewPlanTieredWithMinimumPrice - ) = tieredWithMinimum.validity() + companion object { - override fun visitUnitWithPercent( - unitWithPercent: NewPlanUnitWithPercentPrice - ) = unitWithPercent.validity() + /** + * Returns a mutable builder for constructing an instance of [ReplacePrice]. + * + * The following fields are required: + * ```kotlin + * .replacesPriceId() + * ``` + */ + fun builder() = Builder() + } - override fun visitPackageWithAllocation( - packageWithAllocation: NewPlanPackageWithAllocationPrice - ) = packageWithAllocation.validity() + /** A builder for [ReplacePrice]. */ + class Builder internal constructor() { - override fun visitTieredWithProration( - tieredWithProration: NewPlanTierWithProrationPrice - ) = tieredWithProration.validity() + private var replacesPriceId: JsonField? = null + private var allocationPrice: JsonField = JsonMissing.of() + private var planPhaseOrder: JsonField = JsonMissing.of() + private var price: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - override fun visitUnitWithProration( - unitWithProration: NewPlanUnitWithProrationPrice - ) = unitWithProration.validity() + internal fun from(replacePrice: ReplacePrice) = apply { + replacesPriceId = replacePrice.replacesPriceId + allocationPrice = replacePrice.allocationPrice + planPhaseOrder = replacePrice.planPhaseOrder + price = replacePrice.price + additionalProperties = replacePrice.additionalProperties.toMutableMap() + } - override fun visitGroupedAllocation( - groupedAllocation: NewPlanGroupedAllocationPrice - ) = groupedAllocation.validity() + /** The id of the price on the plan to replace in the plan. */ + fun replacesPriceId(replacesPriceId: String) = + replacesPriceId(JsonField.of(replacesPriceId)) - override fun visitGroupedWithProratedMinimum( - groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice - ) = groupedWithProratedMinimum.validity() + /** + * Sets [Builder.replacesPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.replacesPriceId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun replacesPriceId(replacesPriceId: JsonField) = apply { + this.replacesPriceId = replacesPriceId + } - override fun visitGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice - ) = groupedWithMeteredMinimum.validity() + /** The allocation price to add to the plan. */ + fun allocationPrice(allocationPrice: NewAllocationPrice?) = + allocationPrice(JsonField.ofNullable(allocationPrice)) - override fun visitMatrixWithDisplayName( - matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice - ) = matrixWithDisplayName.validity() + /** + * Sets [Builder.allocationPrice] to an arbitrary JSON value. + * + * You should usually call [Builder.allocationPrice] with a well-typed + * [NewAllocationPrice] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun allocationPrice(allocationPrice: JsonField) = apply { + this.allocationPrice = allocationPrice + } - override fun visitBulkWithProration( - bulkWithProration: NewPlanBulkWithProrationPrice - ) = bulkWithProration.validity() + /** The phase to replace this price from. */ + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) - override fun visitGroupedTieredPackage( - groupedTieredPackage: NewPlanGroupedTieredPackagePrice - ) = groupedTieredPackage.validity() + /** + * Alias for [Builder.planPhaseOrder]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) - override fun visitMaxGroupTieredPackage( - maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice - ) = maxGroupTieredPackage.validity() + /** + * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. + * + * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun planPhaseOrder(planPhaseOrder: JsonField) = apply { + this.planPhaseOrder = planPhaseOrder + } - override fun visitScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice - ) = scalableMatrixWithUnitPricing.validity() + /** The price to add to the plan */ + fun price(price: Price?) = price(JsonField.ofNullable(price)) - override fun visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: - NewPlanScalableMatrixWithTieredPricingPrice - ) = scalableMatrixWithTieredPricing.validity() + /** + * Sets [Builder.price] to an arbitrary JSON value. + * + * You should usually call [Builder.price] with a well-typed [Price] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun price(price: JsonField) = apply { this.price = price } - override fun visitCumulativeGroupedBulk( - cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice - ) = cumulativeGroupedBulk.validity() + /** Alias for calling [price] with `Price.ofUnit(unit)`. */ + fun price(unit: NewPlanUnitPrice) = price(Price.ofUnit(unit)) - override fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice - ) = tieredPackageWithMinimum.validity() + /** Alias for calling [price] with `Price.ofPackage(package_)`. */ + fun price(package_: NewPlanPackagePrice) = price(Price.ofPackage(package_)) - override fun visitMatrixWithAllocation( - matrixWithAllocation: NewPlanMatrixWithAllocationPrice - ) = matrixWithAllocation.validity() + /** Alias for calling [price] with `Price.ofMatrix(matrix)`. */ + fun price(matrix: NewPlanMatrixPrice) = price(Price.ofMatrix(matrix)) - override fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) = - groupedTiered.validity() + /** Alias for calling [price] with `Price.ofTiered(tiered)`. */ + fun price(tiered: NewPlanTieredPrice) = price(Price.ofTiered(tiered)) - override fun unknown(json: JsonValue?) = 0 - } - ) + /** Alias for calling [price] with `Price.ofBulk(bulk)`. */ + fun price(bulk: NewPlanBulkPrice) = price(Price.ofBulk(bulk)) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * Alias for calling [price] with `Price.ofThresholdTotalAmount(thresholdTotalAmount)`. + */ + fun price(thresholdTotalAmount: NewPlanThresholdTotalAmountPrice) = + price(Price.ofThresholdTotalAmount(thresholdTotalAmount)) - return other is Price && - unit == other.unit && - package_ == other.package_ && - matrix == other.matrix && - tiered == other.tiered && - tieredBps == other.tieredBps && - bps == other.bps && - bulkBps == other.bulkBps && - bulk == other.bulk && - thresholdTotalAmount == other.thresholdTotalAmount && - tieredPackage == other.tieredPackage && - tieredWithMinimum == other.tieredWithMinimum && - unitWithPercent == other.unitWithPercent && - packageWithAllocation == other.packageWithAllocation && - tieredWithProration == other.tieredWithProration && - unitWithProration == other.unitWithProration && - groupedAllocation == other.groupedAllocation && - groupedWithProratedMinimum == other.groupedWithProratedMinimum && - groupedWithMeteredMinimum == other.groupedWithMeteredMinimum && - matrixWithDisplayName == other.matrixWithDisplayName && - bulkWithProration == other.bulkWithProration && - groupedTieredPackage == other.groupedTieredPackage && - maxGroupTieredPackage == other.maxGroupTieredPackage && - scalableMatrixWithUnitPricing == other.scalableMatrixWithUnitPricing && - scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && - cumulativeGroupedBulk == other.cumulativeGroupedBulk && - tieredPackageWithMinimum == other.tieredPackageWithMinimum && - matrixWithAllocation == other.matrixWithAllocation && - groupedTiered == other.groupedTiered - } + /** Alias for calling [price] with `Price.ofTieredPackage(tieredPackage)`. */ + fun price(tieredPackage: NewPlanTieredPackagePrice) = + price(Price.ofTieredPackage(tieredPackage)) - override fun hashCode(): Int = - Objects.hash( - unit, - package_, - matrix, - tiered, - tieredBps, - bps, - bulkBps, - bulk, - thresholdTotalAmount, - tieredPackage, - tieredWithMinimum, - unitWithPercent, - packageWithAllocation, - tieredWithProration, - unitWithProration, - groupedAllocation, - groupedWithProratedMinimum, - groupedWithMeteredMinimum, - matrixWithDisplayName, - bulkWithProration, - groupedTieredPackage, - maxGroupTieredPackage, - scalableMatrixWithUnitPricing, - scalableMatrixWithTieredPricing, - cumulativeGroupedBulk, - tieredPackageWithMinimum, - matrixWithAllocation, - groupedTiered, - ) + /** Alias for calling [price] with `Price.ofTieredWithMinimum(tieredWithMinimum)`. */ + fun price(tieredWithMinimum: NewPlanTieredWithMinimumPrice) = + price(Price.ofTieredWithMinimum(tieredWithMinimum)) - override fun toString(): String = - when { - unit != null -> "Price{unit=$unit}" - package_ != null -> "Price{package_=$package_}" - matrix != null -> "Price{matrix=$matrix}" - tiered != null -> "Price{tiered=$tiered}" - tieredBps != null -> "Price{tieredBps=$tieredBps}" - bps != null -> "Price{bps=$bps}" - bulkBps != null -> "Price{bulkBps=$bulkBps}" - bulk != null -> "Price{bulk=$bulk}" - thresholdTotalAmount != null -> - "Price{thresholdTotalAmount=$thresholdTotalAmount}" - tieredPackage != null -> "Price{tieredPackage=$tieredPackage}" - tieredWithMinimum != null -> "Price{tieredWithMinimum=$tieredWithMinimum}" - unitWithPercent != null -> "Price{unitWithPercent=$unitWithPercent}" - packageWithAllocation != null -> - "Price{packageWithAllocation=$packageWithAllocation}" - tieredWithProration != null -> "Price{tieredWithProration=$tieredWithProration}" - unitWithProration != null -> "Price{unitWithProration=$unitWithProration}" - groupedAllocation != null -> "Price{groupedAllocation=$groupedAllocation}" - groupedWithProratedMinimum != null -> - "Price{groupedWithProratedMinimum=$groupedWithProratedMinimum}" - groupedWithMeteredMinimum != null -> - "Price{groupedWithMeteredMinimum=$groupedWithMeteredMinimum}" - matrixWithDisplayName != null -> - "Price{matrixWithDisplayName=$matrixWithDisplayName}" - bulkWithProration != null -> "Price{bulkWithProration=$bulkWithProration}" - groupedTieredPackage != null -> - "Price{groupedTieredPackage=$groupedTieredPackage}" - maxGroupTieredPackage != null -> - "Price{maxGroupTieredPackage=$maxGroupTieredPackage}" - scalableMatrixWithUnitPricing != null -> - "Price{scalableMatrixWithUnitPricing=$scalableMatrixWithUnitPricing}" - scalableMatrixWithTieredPricing != null -> - "Price{scalableMatrixWithTieredPricing=$scalableMatrixWithTieredPricing}" - cumulativeGroupedBulk != null -> - "Price{cumulativeGroupedBulk=$cumulativeGroupedBulk}" - tieredPackageWithMinimum != null -> - "Price{tieredPackageWithMinimum=$tieredPackageWithMinimum}" - matrixWithAllocation != null -> - "Price{matrixWithAllocation=$matrixWithAllocation}" - groupedTiered != null -> "Price{groupedTiered=$groupedTiered}" - _json != null -> "Price{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Price") - } + /** Alias for calling [price] with `Price.ofUnitWithPercent(unitWithPercent)`. */ + fun price(unitWithPercent: NewPlanUnitWithPercentPrice) = + price(Price.ofUnitWithPercent(unitWithPercent)) - companion object { + /** + * Alias for calling [price] with + * `Price.ofPackageWithAllocation(packageWithAllocation)`. + */ + fun price(packageWithAllocation: NewPlanPackageWithAllocationPrice) = + price(Price.ofPackageWithAllocation(packageWithAllocation)) - fun ofUnit(unit: NewPlanUnitPrice) = Price(unit = unit) + /** + * Alias for calling [price] with `Price.ofTieredWithProration(tieredWithProration)`. + */ + fun price(tieredWithProration: NewPlanTierWithProrationPrice) = + price(Price.ofTieredWithProration(tieredWithProration)) - fun ofPackage(package_: NewPlanPackagePrice) = Price(package_ = package_) + /** Alias for calling [price] with `Price.ofUnitWithProration(unitWithProration)`. */ + fun price(unitWithProration: NewPlanUnitWithProrationPrice) = + price(Price.ofUnitWithProration(unitWithProration)) - fun ofMatrix(matrix: NewPlanMatrixPrice) = Price(matrix = matrix) + /** Alias for calling [price] with `Price.ofGroupedAllocation(groupedAllocation)`. */ + fun price(groupedAllocation: NewPlanGroupedAllocationPrice) = + price(Price.ofGroupedAllocation(groupedAllocation)) - fun ofTiered(tiered: NewPlanTieredPrice) = Price(tiered = tiered) + /** + * Alias for calling [price] with + * `Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)`. + */ + fun price(groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice) = + price(Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)) - fun ofTieredBps(tieredBps: NewPlanTieredBpsPrice) = Price(tieredBps = tieredBps) + /** + * Alias for calling [price] with + * `Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)`. + */ + fun price(groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice) = + price(Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)) - fun ofBps(bps: NewPlanBpsPrice) = Price(bps = bps) + /** + * Alias for calling [price] with + * `Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)`. + */ + fun price(groupedWithMinMaxThresholds: Price.GroupedWithMinMaxThresholds) = + price(Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)) - fun ofBulkBps(bulkBps: NewPlanBulkBpsPrice) = Price(bulkBps = bulkBps) + /** + * Alias for calling [price] with + * `Price.ofMatrixWithDisplayName(matrixWithDisplayName)`. + */ + fun price(matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice) = + price(Price.ofMatrixWithDisplayName(matrixWithDisplayName)) - fun ofBulk(bulk: NewPlanBulkPrice) = Price(bulk = bulk) + /** Alias for calling [price] with `Price.ofBulkWithProration(bulkWithProration)`. */ + fun price(bulkWithProration: NewPlanBulkWithProrationPrice) = + price(Price.ofBulkWithProration(bulkWithProration)) - fun ofThresholdTotalAmount(thresholdTotalAmount: NewPlanThresholdTotalAmountPrice) = - Price(thresholdTotalAmount = thresholdTotalAmount) + /** + * Alias for calling [price] with `Price.ofGroupedTieredPackage(groupedTieredPackage)`. + */ + fun price(groupedTieredPackage: NewPlanGroupedTieredPackagePrice) = + price(Price.ofGroupedTieredPackage(groupedTieredPackage)) - fun ofTieredPackage(tieredPackage: NewPlanTieredPackagePrice) = - Price(tieredPackage = tieredPackage) + /** + * Alias for calling [price] with + * `Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)`. + */ + fun price(maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice) = + price(Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)) - fun ofTieredWithMinimum(tieredWithMinimum: NewPlanTieredWithMinimumPrice) = - Price(tieredWithMinimum = tieredWithMinimum) + /** + * Alias for calling [price] with + * `Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)`. + */ + fun price(scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice) = + price(Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)) - fun ofUnitWithPercent(unitWithPercent: NewPlanUnitWithPercentPrice) = - Price(unitWithPercent = unitWithPercent) + /** + * Alias for calling [price] with + * `Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)`. + */ + fun price( + scalableMatrixWithTieredPricing: NewPlanScalableMatrixWithTieredPricingPrice + ) = price(Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)) - fun ofPackageWithAllocation( - packageWithAllocation: NewPlanPackageWithAllocationPrice - ) = Price(packageWithAllocation = packageWithAllocation) - - fun ofTieredWithProration(tieredWithProration: NewPlanTierWithProrationPrice) = - Price(tieredWithProration = tieredWithProration) + /** + * Alias for calling [price] with + * `Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)`. + */ + fun price(cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice) = + price(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) - fun ofUnitWithProration(unitWithProration: NewPlanUnitWithProrationPrice) = - Price(unitWithProration = unitWithProration) + /** + * Alias for calling [price] with + * `Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)`. + */ + fun price(tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice) = + price(Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)) - fun ofGroupedAllocation(groupedAllocation: NewPlanGroupedAllocationPrice) = - Price(groupedAllocation = groupedAllocation) + /** + * Alias for calling [price] with `Price.ofMatrixWithAllocation(matrixWithAllocation)`. + */ + fun price(matrixWithAllocation: NewPlanMatrixWithAllocationPrice) = + price(Price.ofMatrixWithAllocation(matrixWithAllocation)) - fun ofGroupedWithProratedMinimum( - groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice - ) = Price(groupedWithProratedMinimum = groupedWithProratedMinimum) + /** Alias for calling [price] with `Price.ofGroupedTiered(groupedTiered)`. */ + fun price(groupedTiered: NewPlanGroupedTieredPrice) = + price(Price.ofGroupedTiered(groupedTiered)) - fun ofGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice - ) = Price(groupedWithMeteredMinimum = groupedWithMeteredMinimum) + /** Alias for calling [price] with `Price.ofMinimum(minimum)`. */ + fun price(minimum: Price.Minimum) = price(Price.ofMinimum(minimum)) - fun ofMatrixWithDisplayName( - matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice - ) = Price(matrixWithDisplayName = matrixWithDisplayName) + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun ofBulkWithProration(bulkWithProration: NewPlanBulkWithProrationPrice) = - Price(bulkWithProration = bulkWithProration) + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun ofGroupedTieredPackage(groupedTieredPackage: NewPlanGroupedTieredPackagePrice) = - Price(groupedTieredPackage = groupedTieredPackage) + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun ofMaxGroupTieredPackage( - maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice - ) = Price(maxGroupTieredPackage = maxGroupTieredPackage) + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - fun ofScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice - ) = Price(scalableMatrixWithUnitPricing = scalableMatrixWithUnitPricing) + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - fun ofScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: NewPlanScalableMatrixWithTieredPricingPrice - ) = Price(scalableMatrixWithTieredPricing = scalableMatrixWithTieredPricing) + /** + * Returns an immutable instance of [ReplacePrice]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .replacesPriceId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ReplacePrice = + ReplacePrice( + checkRequired("replacesPriceId", replacesPriceId), + allocationPrice, + planPhaseOrder, + price, + additionalProperties.toMutableMap(), + ) + } - fun ofCumulativeGroupedBulk( - cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice - ) = Price(cumulativeGroupedBulk = cumulativeGroupedBulk) + private var validated: Boolean = false - fun ofTieredPackageWithMinimum( - tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice - ) = Price(tieredPackageWithMinimum = tieredPackageWithMinimum) + fun validate(): ReplacePrice = apply { + if (validated) { + return@apply + } - fun ofMatrixWithAllocation(matrixWithAllocation: NewPlanMatrixWithAllocationPrice) = - Price(matrixWithAllocation = matrixWithAllocation) + replacesPriceId() + allocationPrice()?.validate() + planPhaseOrder() + price()?.validate() + validated = true + } - fun ofGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) = - Price(groupedTiered = groupedTiered) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false } - /** - * An interface that defines how to map each variant of [Price] to a value of type [T]. - */ - interface Visitor { + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (replacesPriceId.asKnown() == null) 0 else 1) + + (allocationPrice.asKnown()?.validity() ?: 0) + + (if (planPhaseOrder.asKnown() == null) 0 else 1) + + (price.asKnown()?.validity() ?: 0) - fun visitUnit(unit: NewPlanUnitPrice): T + /** The price to add to the plan */ + @JsonDeserialize(using = Price.Deserializer::class) + @JsonSerialize(using = Price.Serializer::class) + class Price + private constructor( + private val unit: NewPlanUnitPrice? = null, + private val package_: NewPlanPackagePrice? = null, + private val matrix: NewPlanMatrixPrice? = null, + private val tiered: NewPlanTieredPrice? = null, + private val bulk: NewPlanBulkPrice? = null, + private val thresholdTotalAmount: NewPlanThresholdTotalAmountPrice? = null, + private val tieredPackage: NewPlanTieredPackagePrice? = null, + private val tieredWithMinimum: NewPlanTieredWithMinimumPrice? = null, + private val unitWithPercent: NewPlanUnitWithPercentPrice? = null, + private val packageWithAllocation: NewPlanPackageWithAllocationPrice? = null, + private val tieredWithProration: NewPlanTierWithProrationPrice? = null, + private val unitWithProration: NewPlanUnitWithProrationPrice? = null, + private val groupedAllocation: NewPlanGroupedAllocationPrice? = null, + private val groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice? = null, + private val groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice? = null, + private val groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds? = null, + private val matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice? = null, + private val bulkWithProration: NewPlanBulkWithProrationPrice? = null, + private val groupedTieredPackage: NewPlanGroupedTieredPackagePrice? = null, + private val maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice? = null, + private val scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice? = + null, + private val scalableMatrixWithTieredPricing: + NewPlanScalableMatrixWithTieredPricingPrice? = + null, + private val cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice? = null, + private val tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice? = null, + private val matrixWithAllocation: NewPlanMatrixWithAllocationPrice? = null, + private val groupedTiered: NewPlanGroupedTieredPrice? = null, + private val minimum: Minimum? = null, + private val _json: JsonValue? = null, + ) { - fun visitPackage(package_: NewPlanPackagePrice): T + fun unit(): NewPlanUnitPrice? = unit - fun visitMatrix(matrix: NewPlanMatrixPrice): T + fun package_(): NewPlanPackagePrice? = package_ - fun visitTiered(tiered: NewPlanTieredPrice): T + fun matrix(): NewPlanMatrixPrice? = matrix - fun visitTieredBps(tieredBps: NewPlanTieredBpsPrice): T + fun tiered(): NewPlanTieredPrice? = tiered - fun visitBps(bps: NewPlanBpsPrice): T + fun bulk(): NewPlanBulkPrice? = bulk - fun visitBulkBps(bulkBps: NewPlanBulkBpsPrice): T + fun thresholdTotalAmount(): NewPlanThresholdTotalAmountPrice? = thresholdTotalAmount - fun visitBulk(bulk: NewPlanBulkPrice): T + fun tieredPackage(): NewPlanTieredPackagePrice? = tieredPackage - fun visitThresholdTotalAmount( - thresholdTotalAmount: NewPlanThresholdTotalAmountPrice - ): T + fun tieredWithMinimum(): NewPlanTieredWithMinimumPrice? = tieredWithMinimum - fun visitTieredPackage(tieredPackage: NewPlanTieredPackagePrice): T + fun unitWithPercent(): NewPlanUnitWithPercentPrice? = unitWithPercent - fun visitTieredWithMinimum(tieredWithMinimum: NewPlanTieredWithMinimumPrice): T + fun packageWithAllocation(): NewPlanPackageWithAllocationPrice? = packageWithAllocation - fun visitUnitWithPercent(unitWithPercent: NewPlanUnitWithPercentPrice): T + fun tieredWithProration(): NewPlanTierWithProrationPrice? = tieredWithProration - fun visitPackageWithAllocation( - packageWithAllocation: NewPlanPackageWithAllocationPrice - ): T + fun unitWithProration(): NewPlanUnitWithProrationPrice? = unitWithProration - fun visitTieredWithProration(tieredWithProration: NewPlanTierWithProrationPrice): T + fun groupedAllocation(): NewPlanGroupedAllocationPrice? = groupedAllocation - fun visitUnitWithProration(unitWithProration: NewPlanUnitWithProrationPrice): T + fun groupedWithProratedMinimum(): NewPlanGroupedWithProratedMinimumPrice? = + groupedWithProratedMinimum - fun visitGroupedAllocation(groupedAllocation: NewPlanGroupedAllocationPrice): T + fun groupedWithMeteredMinimum(): NewPlanGroupedWithMeteredMinimumPrice? = + groupedWithMeteredMinimum - fun visitGroupedWithProratedMinimum( - groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice - ): T + fun groupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds? = + groupedWithMinMaxThresholds - fun visitGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice - ): T + fun matrixWithDisplayName(): NewPlanMatrixWithDisplayNamePrice? = matrixWithDisplayName - fun visitMatrixWithDisplayName( - matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice - ): T + fun bulkWithProration(): NewPlanBulkWithProrationPrice? = bulkWithProration - fun visitBulkWithProration(bulkWithProration: NewPlanBulkWithProrationPrice): T + fun groupedTieredPackage(): NewPlanGroupedTieredPackagePrice? = groupedTieredPackage - fun visitGroupedTieredPackage( - groupedTieredPackage: NewPlanGroupedTieredPackagePrice - ): T + fun maxGroupTieredPackage(): NewPlanMaxGroupTieredPackagePrice? = maxGroupTieredPackage - fun visitMaxGroupTieredPackage( - maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice - ): T + fun scalableMatrixWithUnitPricing(): NewPlanScalableMatrixWithUnitPricingPrice? = + scalableMatrixWithUnitPricing - fun visitScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice - ): T + fun scalableMatrixWithTieredPricing(): NewPlanScalableMatrixWithTieredPricingPrice? = + scalableMatrixWithTieredPricing - fun visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: NewPlanScalableMatrixWithTieredPricingPrice - ): T + fun cumulativeGroupedBulk(): NewPlanCumulativeGroupedBulkPrice? = cumulativeGroupedBulk - fun visitCumulativeGroupedBulk( - cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice - ): T + fun tieredPackageWithMinimum(): NewPlanTieredPackageWithMinimumPrice? = + tieredPackageWithMinimum - fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice - ): T + fun matrixWithAllocation(): NewPlanMatrixWithAllocationPrice? = matrixWithAllocation - fun visitMatrixWithAllocation( - matrixWithAllocation: NewPlanMatrixWithAllocationPrice - ): T + fun groupedTiered(): NewPlanGroupedTieredPrice? = groupedTiered - fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice): T + fun minimum(): Minimum? = minimum - /** - * Maps an unknown variant of [Price] to a value of type [T]. - * - * An instance of [Price] can contain an unknown variant if it was deserialized from - * data that doesn't match any known variant. For example, if the SDK is on an older - * version than the API, then the API may respond with new variants that the SDK is - * unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown Price: $json") - } - } + fun isUnit(): Boolean = unit != null - internal class Deserializer : BaseDeserializer(Price::class) { + fun isPackage(): Boolean = package_ != null + + fun isMatrix(): Boolean = matrix != null + + fun isTiered(): Boolean = tiered != null + + fun isBulk(): Boolean = bulk != null + + fun isThresholdTotalAmount(): Boolean = thresholdTotalAmount != null + + fun isTieredPackage(): Boolean = tieredPackage != null + + fun isTieredWithMinimum(): Boolean = tieredWithMinimum != null + + fun isUnitWithPercent(): Boolean = unitWithPercent != null + + fun isPackageWithAllocation(): Boolean = packageWithAllocation != null + + fun isTieredWithProration(): Boolean = tieredWithProration != null + + fun isUnitWithProration(): Boolean = unitWithProration != null + + fun isGroupedAllocation(): Boolean = groupedAllocation != null + + fun isGroupedWithProratedMinimum(): Boolean = groupedWithProratedMinimum != null + + fun isGroupedWithMeteredMinimum(): Boolean = groupedWithMeteredMinimum != null + + fun isGroupedWithMinMaxThresholds(): Boolean = groupedWithMinMaxThresholds != null + + fun isMatrixWithDisplayName(): Boolean = matrixWithDisplayName != null + + fun isBulkWithProration(): Boolean = bulkWithProration != null + + fun isGroupedTieredPackage(): Boolean = groupedTieredPackage != null + + fun isMaxGroupTieredPackage(): Boolean = maxGroupTieredPackage != null + + fun isScalableMatrixWithUnitPricing(): Boolean = scalableMatrixWithUnitPricing != null + + fun isScalableMatrixWithTieredPricing(): Boolean = + scalableMatrixWithTieredPricing != null + + fun isCumulativeGroupedBulk(): Boolean = cumulativeGroupedBulk != null + + fun isTieredPackageWithMinimum(): Boolean = tieredPackageWithMinimum != null + + fun isMatrixWithAllocation(): Boolean = matrixWithAllocation != null + + fun isGroupedTiered(): Boolean = groupedTiered != null + + fun isMinimum(): Boolean = minimum != null + + fun asUnit(): NewPlanUnitPrice = unit.getOrThrow("unit") + + fun asPackage(): NewPlanPackagePrice = package_.getOrThrow("package_") + + fun asMatrix(): NewPlanMatrixPrice = matrix.getOrThrow("matrix") + + fun asTiered(): NewPlanTieredPrice = tiered.getOrThrow("tiered") + + fun asBulk(): NewPlanBulkPrice = bulk.getOrThrow("bulk") + + fun asThresholdTotalAmount(): NewPlanThresholdTotalAmountPrice = + thresholdTotalAmount.getOrThrow("thresholdTotalAmount") + + fun asTieredPackage(): NewPlanTieredPackagePrice = + tieredPackage.getOrThrow("tieredPackage") + + fun asTieredWithMinimum(): NewPlanTieredWithMinimumPrice = + tieredWithMinimum.getOrThrow("tieredWithMinimum") + + fun asUnitWithPercent(): NewPlanUnitWithPercentPrice = + unitWithPercent.getOrThrow("unitWithPercent") + + fun asPackageWithAllocation(): NewPlanPackageWithAllocationPrice = + packageWithAllocation.getOrThrow("packageWithAllocation") + + fun asTieredWithProration(): NewPlanTierWithProrationPrice = + tieredWithProration.getOrThrow("tieredWithProration") + + fun asUnitWithProration(): NewPlanUnitWithProrationPrice = + unitWithProration.getOrThrow("unitWithProration") + + fun asGroupedAllocation(): NewPlanGroupedAllocationPrice = + groupedAllocation.getOrThrow("groupedAllocation") + + fun asGroupedWithProratedMinimum(): NewPlanGroupedWithProratedMinimumPrice = + groupedWithProratedMinimum.getOrThrow("groupedWithProratedMinimum") + + fun asGroupedWithMeteredMinimum(): NewPlanGroupedWithMeteredMinimumPrice = + groupedWithMeteredMinimum.getOrThrow("groupedWithMeteredMinimum") + + fun asGroupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds = + groupedWithMinMaxThresholds.getOrThrow("groupedWithMinMaxThresholds") + + fun asMatrixWithDisplayName(): NewPlanMatrixWithDisplayNamePrice = + matrixWithDisplayName.getOrThrow("matrixWithDisplayName") + + fun asBulkWithProration(): NewPlanBulkWithProrationPrice = + bulkWithProration.getOrThrow("bulkWithProration") + + fun asGroupedTieredPackage(): NewPlanGroupedTieredPackagePrice = + groupedTieredPackage.getOrThrow("groupedTieredPackage") + + fun asMaxGroupTieredPackage(): NewPlanMaxGroupTieredPackagePrice = + maxGroupTieredPackage.getOrThrow("maxGroupTieredPackage") + + fun asScalableMatrixWithUnitPricing(): NewPlanScalableMatrixWithUnitPricingPrice = + scalableMatrixWithUnitPricing.getOrThrow("scalableMatrixWithUnitPricing") + + fun asScalableMatrixWithTieredPricing(): NewPlanScalableMatrixWithTieredPricingPrice = + scalableMatrixWithTieredPricing.getOrThrow("scalableMatrixWithTieredPricing") + + fun asCumulativeGroupedBulk(): NewPlanCumulativeGroupedBulkPrice = + cumulativeGroupedBulk.getOrThrow("cumulativeGroupedBulk") + + fun asTieredPackageWithMinimum(): NewPlanTieredPackageWithMinimumPrice = + tieredPackageWithMinimum.getOrThrow("tieredPackageWithMinimum") + + fun asMatrixWithAllocation(): NewPlanMatrixWithAllocationPrice = + matrixWithAllocation.getOrThrow("matrixWithAllocation") + + fun asGroupedTiered(): NewPlanGroupedTieredPrice = + groupedTiered.getOrThrow("groupedTiered") + + fun asMinimum(): Minimum = minimum.getOrThrow("minimum") + + fun _json(): JsonValue? = _json + + fun accept(visitor: Visitor): T = + when { + unit != null -> visitor.visitUnit(unit) + package_ != null -> visitor.visitPackage(package_) + matrix != null -> visitor.visitMatrix(matrix) + tiered != null -> visitor.visitTiered(tiered) + bulk != null -> visitor.visitBulk(bulk) + thresholdTotalAmount != null -> + visitor.visitThresholdTotalAmount(thresholdTotalAmount) + tieredPackage != null -> visitor.visitTieredPackage(tieredPackage) + tieredWithMinimum != null -> visitor.visitTieredWithMinimum(tieredWithMinimum) + unitWithPercent != null -> visitor.visitUnitWithPercent(unitWithPercent) + packageWithAllocation != null -> + visitor.visitPackageWithAllocation(packageWithAllocation) + tieredWithProration != null -> + visitor.visitTieredWithProration(tieredWithProration) + unitWithProration != null -> visitor.visitUnitWithProration(unitWithProration) + groupedAllocation != null -> visitor.visitGroupedAllocation(groupedAllocation) + groupedWithProratedMinimum != null -> + visitor.visitGroupedWithProratedMinimum(groupedWithProratedMinimum) + groupedWithMeteredMinimum != null -> + visitor.visitGroupedWithMeteredMinimum(groupedWithMeteredMinimum) + groupedWithMinMaxThresholds != null -> + visitor.visitGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds) + matrixWithDisplayName != null -> + visitor.visitMatrixWithDisplayName(matrixWithDisplayName) + bulkWithProration != null -> visitor.visitBulkWithProration(bulkWithProration) + groupedTieredPackage != null -> + visitor.visitGroupedTieredPackage(groupedTieredPackage) + maxGroupTieredPackage != null -> + visitor.visitMaxGroupTieredPackage(maxGroupTieredPackage) + scalableMatrixWithUnitPricing != null -> + visitor.visitScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing) + scalableMatrixWithTieredPricing != null -> + visitor.visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing + ) + cumulativeGroupedBulk != null -> + visitor.visitCumulativeGroupedBulk(cumulativeGroupedBulk) + tieredPackageWithMinimum != null -> + visitor.visitTieredPackageWithMinimum(tieredPackageWithMinimum) + matrixWithAllocation != null -> + visitor.visitMatrixWithAllocation(matrixWithAllocation) + groupedTiered != null -> visitor.visitGroupedTiered(groupedTiered) + minimum != null -> visitor.visitMinimum(minimum) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Price = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitUnit(unit: NewPlanUnitPrice) { + unit.validate() + } + + override fun visitPackage(package_: NewPlanPackagePrice) { + package_.validate() + } + + override fun visitMatrix(matrix: NewPlanMatrixPrice) { + matrix.validate() + } + + override fun visitTiered(tiered: NewPlanTieredPrice) { + tiered.validate() + } + + override fun visitBulk(bulk: NewPlanBulkPrice) { + bulk.validate() + } + + override fun visitThresholdTotalAmount( + thresholdTotalAmount: NewPlanThresholdTotalAmountPrice + ) { + thresholdTotalAmount.validate() + } + + override fun visitTieredPackage(tieredPackage: NewPlanTieredPackagePrice) { + tieredPackage.validate() + } + + override fun visitTieredWithMinimum( + tieredWithMinimum: NewPlanTieredWithMinimumPrice + ) { + tieredWithMinimum.validate() + } + + override fun visitUnitWithPercent( + unitWithPercent: NewPlanUnitWithPercentPrice + ) { + unitWithPercent.validate() + } + + override fun visitPackageWithAllocation( + packageWithAllocation: NewPlanPackageWithAllocationPrice + ) { + packageWithAllocation.validate() + } + + override fun visitTieredWithProration( + tieredWithProration: NewPlanTierWithProrationPrice + ) { + tieredWithProration.validate() + } + + override fun visitUnitWithProration( + unitWithProration: NewPlanUnitWithProrationPrice + ) { + unitWithProration.validate() + } + + override fun visitGroupedAllocation( + groupedAllocation: NewPlanGroupedAllocationPrice + ) { + groupedAllocation.validate() + } + + override fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice + ) { + groupedWithProratedMinimum.validate() + } + + override fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice + ) { + groupedWithMeteredMinimum.validate() + } + + override fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) { + groupedWithMinMaxThresholds.validate() + } + + override fun visitMatrixWithDisplayName( + matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice + ) { + matrixWithDisplayName.validate() + } + + override fun visitBulkWithProration( + bulkWithProration: NewPlanBulkWithProrationPrice + ) { + bulkWithProration.validate() + } + + override fun visitGroupedTieredPackage( + groupedTieredPackage: NewPlanGroupedTieredPackagePrice + ) { + groupedTieredPackage.validate() + } + + override fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice + ) { + maxGroupTieredPackage.validate() + } + + override fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice + ) { + scalableMatrixWithUnitPricing.validate() + } + + override fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: + NewPlanScalableMatrixWithTieredPricingPrice + ) { + scalableMatrixWithTieredPricing.validate() + } + + override fun visitCumulativeGroupedBulk( + cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice + ) { + cumulativeGroupedBulk.validate() + } + + override fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice + ) { + tieredPackageWithMinimum.validate() + } + + override fun visitMatrixWithAllocation( + matrixWithAllocation: NewPlanMatrixWithAllocationPrice + ) { + matrixWithAllocation.validate() + } + + override fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) { + groupedTiered.validate() + } + + override fun visitMinimum(minimum: Minimum) { + minimum.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitUnit(unit: NewPlanUnitPrice) = unit.validity() + + override fun visitPackage(package_: NewPlanPackagePrice) = + package_.validity() + + override fun visitMatrix(matrix: NewPlanMatrixPrice) = matrix.validity() + + override fun visitTiered(tiered: NewPlanTieredPrice) = tiered.validity() + + override fun visitBulk(bulk: NewPlanBulkPrice) = bulk.validity() + + override fun visitThresholdTotalAmount( + thresholdTotalAmount: NewPlanThresholdTotalAmountPrice + ) = thresholdTotalAmount.validity() + + override fun visitTieredPackage(tieredPackage: NewPlanTieredPackagePrice) = + tieredPackage.validity() + + override fun visitTieredWithMinimum( + tieredWithMinimum: NewPlanTieredWithMinimumPrice + ) = tieredWithMinimum.validity() + + override fun visitUnitWithPercent( + unitWithPercent: NewPlanUnitWithPercentPrice + ) = unitWithPercent.validity() + + override fun visitPackageWithAllocation( + packageWithAllocation: NewPlanPackageWithAllocationPrice + ) = packageWithAllocation.validity() + + override fun visitTieredWithProration( + tieredWithProration: NewPlanTierWithProrationPrice + ) = tieredWithProration.validity() + + override fun visitUnitWithProration( + unitWithProration: NewPlanUnitWithProrationPrice + ) = unitWithProration.validity() + + override fun visitGroupedAllocation( + groupedAllocation: NewPlanGroupedAllocationPrice + ) = groupedAllocation.validity() + + override fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice + ) = groupedWithProratedMinimum.validity() + + override fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice + ) = groupedWithMeteredMinimum.validity() + + override fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) = groupedWithMinMaxThresholds.validity() + + override fun visitMatrixWithDisplayName( + matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice + ) = matrixWithDisplayName.validity() + + override fun visitBulkWithProration( + bulkWithProration: NewPlanBulkWithProrationPrice + ) = bulkWithProration.validity() + + override fun visitGroupedTieredPackage( + groupedTieredPackage: NewPlanGroupedTieredPackagePrice + ) = groupedTieredPackage.validity() + + override fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice + ) = maxGroupTieredPackage.validity() + + override fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice + ) = scalableMatrixWithUnitPricing.validity() + + override fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: + NewPlanScalableMatrixWithTieredPricingPrice + ) = scalableMatrixWithTieredPricing.validity() + + override fun visitCumulativeGroupedBulk( + cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice + ) = cumulativeGroupedBulk.validity() + + override fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice + ) = tieredPackageWithMinimum.validity() + + override fun visitMatrixWithAllocation( + matrixWithAllocation: NewPlanMatrixWithAllocationPrice + ) = matrixWithAllocation.validity() + + override fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) = + groupedTiered.validity() + + override fun visitMinimum(minimum: Minimum) = minimum.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Price && + unit == other.unit && + package_ == other.package_ && + matrix == other.matrix && + tiered == other.tiered && + bulk == other.bulk && + thresholdTotalAmount == other.thresholdTotalAmount && + tieredPackage == other.tieredPackage && + tieredWithMinimum == other.tieredWithMinimum && + unitWithPercent == other.unitWithPercent && + packageWithAllocation == other.packageWithAllocation && + tieredWithProration == other.tieredWithProration && + unitWithProration == other.unitWithProration && + groupedAllocation == other.groupedAllocation && + groupedWithProratedMinimum == other.groupedWithProratedMinimum && + groupedWithMeteredMinimum == other.groupedWithMeteredMinimum && + groupedWithMinMaxThresholds == other.groupedWithMinMaxThresholds && + matrixWithDisplayName == other.matrixWithDisplayName && + bulkWithProration == other.bulkWithProration && + groupedTieredPackage == other.groupedTieredPackage && + maxGroupTieredPackage == other.maxGroupTieredPackage && + scalableMatrixWithUnitPricing == other.scalableMatrixWithUnitPricing && + scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && + cumulativeGroupedBulk == other.cumulativeGroupedBulk && + tieredPackageWithMinimum == other.tieredPackageWithMinimum && + matrixWithAllocation == other.matrixWithAllocation && + groupedTiered == other.groupedTiered && + minimum == other.minimum + } + + override fun hashCode(): Int = + Objects.hash( + unit, + package_, + matrix, + tiered, + bulk, + thresholdTotalAmount, + tieredPackage, + tieredWithMinimum, + unitWithPercent, + packageWithAllocation, + tieredWithProration, + unitWithProration, + groupedAllocation, + groupedWithProratedMinimum, + groupedWithMeteredMinimum, + groupedWithMinMaxThresholds, + matrixWithDisplayName, + bulkWithProration, + groupedTieredPackage, + maxGroupTieredPackage, + scalableMatrixWithUnitPricing, + scalableMatrixWithTieredPricing, + cumulativeGroupedBulk, + tieredPackageWithMinimum, + matrixWithAllocation, + groupedTiered, + minimum, + ) + + override fun toString(): String = + when { + unit != null -> "Price{unit=$unit}" + package_ != null -> "Price{package_=$package_}" + matrix != null -> "Price{matrix=$matrix}" + tiered != null -> "Price{tiered=$tiered}" + bulk != null -> "Price{bulk=$bulk}" + thresholdTotalAmount != null -> + "Price{thresholdTotalAmount=$thresholdTotalAmount}" + tieredPackage != null -> "Price{tieredPackage=$tieredPackage}" + tieredWithMinimum != null -> "Price{tieredWithMinimum=$tieredWithMinimum}" + unitWithPercent != null -> "Price{unitWithPercent=$unitWithPercent}" + packageWithAllocation != null -> + "Price{packageWithAllocation=$packageWithAllocation}" + tieredWithProration != null -> "Price{tieredWithProration=$tieredWithProration}" + unitWithProration != null -> "Price{unitWithProration=$unitWithProration}" + groupedAllocation != null -> "Price{groupedAllocation=$groupedAllocation}" + groupedWithProratedMinimum != null -> + "Price{groupedWithProratedMinimum=$groupedWithProratedMinimum}" + groupedWithMeteredMinimum != null -> + "Price{groupedWithMeteredMinimum=$groupedWithMeteredMinimum}" + groupedWithMinMaxThresholds != null -> + "Price{groupedWithMinMaxThresholds=$groupedWithMinMaxThresholds}" + matrixWithDisplayName != null -> + "Price{matrixWithDisplayName=$matrixWithDisplayName}" + bulkWithProration != null -> "Price{bulkWithProration=$bulkWithProration}" + groupedTieredPackage != null -> + "Price{groupedTieredPackage=$groupedTieredPackage}" + maxGroupTieredPackage != null -> + "Price{maxGroupTieredPackage=$maxGroupTieredPackage}" + scalableMatrixWithUnitPricing != null -> + "Price{scalableMatrixWithUnitPricing=$scalableMatrixWithUnitPricing}" + scalableMatrixWithTieredPricing != null -> + "Price{scalableMatrixWithTieredPricing=$scalableMatrixWithTieredPricing}" + cumulativeGroupedBulk != null -> + "Price{cumulativeGroupedBulk=$cumulativeGroupedBulk}" + tieredPackageWithMinimum != null -> + "Price{tieredPackageWithMinimum=$tieredPackageWithMinimum}" + matrixWithAllocation != null -> + "Price{matrixWithAllocation=$matrixWithAllocation}" + groupedTiered != null -> "Price{groupedTiered=$groupedTiered}" + minimum != null -> "Price{minimum=$minimum}" + _json != null -> "Price{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Price") + } + + companion object { + + fun ofUnit(unit: NewPlanUnitPrice) = Price(unit = unit) + + fun ofPackage(package_: NewPlanPackagePrice) = Price(package_ = package_) + + fun ofMatrix(matrix: NewPlanMatrixPrice) = Price(matrix = matrix) + + fun ofTiered(tiered: NewPlanTieredPrice) = Price(tiered = tiered) + + fun ofBulk(bulk: NewPlanBulkPrice) = Price(bulk = bulk) + + fun ofThresholdTotalAmount(thresholdTotalAmount: NewPlanThresholdTotalAmountPrice) = + Price(thresholdTotalAmount = thresholdTotalAmount) + + fun ofTieredPackage(tieredPackage: NewPlanTieredPackagePrice) = + Price(tieredPackage = tieredPackage) + + fun ofTieredWithMinimum(tieredWithMinimum: NewPlanTieredWithMinimumPrice) = + Price(tieredWithMinimum = tieredWithMinimum) + + fun ofUnitWithPercent(unitWithPercent: NewPlanUnitWithPercentPrice) = + Price(unitWithPercent = unitWithPercent) + + fun ofPackageWithAllocation( + packageWithAllocation: NewPlanPackageWithAllocationPrice + ) = Price(packageWithAllocation = packageWithAllocation) + + fun ofTieredWithProration(tieredWithProration: NewPlanTierWithProrationPrice) = + Price(tieredWithProration = tieredWithProration) + + fun ofUnitWithProration(unitWithProration: NewPlanUnitWithProrationPrice) = + Price(unitWithProration = unitWithProration) + + fun ofGroupedAllocation(groupedAllocation: NewPlanGroupedAllocationPrice) = + Price(groupedAllocation = groupedAllocation) + + fun ofGroupedWithProratedMinimum( + groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice + ) = Price(groupedWithProratedMinimum = groupedWithProratedMinimum) + + fun ofGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice + ) = Price(groupedWithMeteredMinimum = groupedWithMeteredMinimum) + + fun ofGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) = Price(groupedWithMinMaxThresholds = groupedWithMinMaxThresholds) + + fun ofMatrixWithDisplayName( + matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice + ) = Price(matrixWithDisplayName = matrixWithDisplayName) + + fun ofBulkWithProration(bulkWithProration: NewPlanBulkWithProrationPrice) = + Price(bulkWithProration = bulkWithProration) + + fun ofGroupedTieredPackage(groupedTieredPackage: NewPlanGroupedTieredPackagePrice) = + Price(groupedTieredPackage = groupedTieredPackage) + + fun ofMaxGroupTieredPackage( + maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice + ) = Price(maxGroupTieredPackage = maxGroupTieredPackage) + + fun ofScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice + ) = Price(scalableMatrixWithUnitPricing = scalableMatrixWithUnitPricing) + + fun ofScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: NewPlanScalableMatrixWithTieredPricingPrice + ) = Price(scalableMatrixWithTieredPricing = scalableMatrixWithTieredPricing) + + fun ofCumulativeGroupedBulk( + cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice + ) = Price(cumulativeGroupedBulk = cumulativeGroupedBulk) + + fun ofTieredPackageWithMinimum( + tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice + ) = Price(tieredPackageWithMinimum = tieredPackageWithMinimum) + + fun ofMatrixWithAllocation(matrixWithAllocation: NewPlanMatrixWithAllocationPrice) = + Price(matrixWithAllocation = matrixWithAllocation) + + fun ofGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) = + Price(groupedTiered = groupedTiered) + + fun ofMinimum(minimum: Minimum) = Price(minimum = minimum) + } + + /** + * An interface that defines how to map each variant of [Price] to a value of type [T]. + */ + interface Visitor { + + fun visitUnit(unit: NewPlanUnitPrice): T + + fun visitPackage(package_: NewPlanPackagePrice): T + + fun visitMatrix(matrix: NewPlanMatrixPrice): T + + fun visitTiered(tiered: NewPlanTieredPrice): T + + fun visitBulk(bulk: NewPlanBulkPrice): T + + fun visitThresholdTotalAmount( + thresholdTotalAmount: NewPlanThresholdTotalAmountPrice + ): T + + fun visitTieredPackage(tieredPackage: NewPlanTieredPackagePrice): T + + fun visitTieredWithMinimum(tieredWithMinimum: NewPlanTieredWithMinimumPrice): T + + fun visitUnitWithPercent(unitWithPercent: NewPlanUnitWithPercentPrice): T + + fun visitPackageWithAllocation( + packageWithAllocation: NewPlanPackageWithAllocationPrice + ): T + + fun visitTieredWithProration(tieredWithProration: NewPlanTierWithProrationPrice): T + + fun visitUnitWithProration(unitWithProration: NewPlanUnitWithProrationPrice): T + + fun visitGroupedAllocation(groupedAllocation: NewPlanGroupedAllocationPrice): T + + fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice + ): T + + fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice + ): T + + fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ): T + + fun visitMatrixWithDisplayName( + matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice + ): T + + fun visitBulkWithProration(bulkWithProration: NewPlanBulkWithProrationPrice): T + + fun visitGroupedTieredPackage( + groupedTieredPackage: NewPlanGroupedTieredPackagePrice + ): T + + fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice + ): T + + fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice + ): T + + fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: NewPlanScalableMatrixWithTieredPricingPrice + ): T + + fun visitCumulativeGroupedBulk( + cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice + ): T + + fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice + ): T + + fun visitMatrixWithAllocation( + matrixWithAllocation: NewPlanMatrixWithAllocationPrice + ): T + + fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice): T + + fun visitMinimum(minimum: Minimum): T + + /** + * Maps an unknown variant of [Price] to a value of type [T]. + * + * An instance of [Price] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is + * unaware of. + * + * @throws OrbInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw OrbInvalidDataException("Unknown Price: $json") + } + } + + internal class Deserializer : BaseDeserializer(Price::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Price { + val json = JsonValue.fromJsonNode(node) + val modelType = json.asObject()?.get("model_type")?.asString() + + when (modelType) { + "unit" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(unit = it, _json = json) + } ?: Price(_json = json) + } + "package" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(package_ = it, _json = json) } ?: Price(_json = json) + } + "matrix" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(matrix = it, _json = json) + } ?: Price(_json = json) + } + "tiered" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(tiered = it, _json = json) + } ?: Price(_json = json) + } + "bulk" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(bulk = it, _json = json) + } ?: Price(_json = json) + } + "threshold_total_amount" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(thresholdTotalAmount = it, _json = json) } + ?: Price(_json = json) + } + "tiered_package" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(tieredPackage = it, _json = json) } + ?: Price(_json = json) + } + "tiered_with_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(tieredWithMinimum = it, _json = json) } + ?: Price(_json = json) + } + "unit_with_percent" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(unitWithPercent = it, _json = json) } + ?: Price(_json = json) + } + "package_with_allocation" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(packageWithAllocation = it, _json = json) } + ?: Price(_json = json) + } + "tiered_with_proration" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(tieredWithProration = it, _json = json) } + ?: Price(_json = json) + } + "unit_with_proration" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(unitWithProration = it, _json = json) } + ?: Price(_json = json) + } + "grouped_allocation" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedAllocation = it, _json = json) } + ?: Price(_json = json) + } + "grouped_with_prorated_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedWithProratedMinimum = it, _json = json) } + ?: Price(_json = json) + } + "grouped_with_metered_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedWithMeteredMinimum = it, _json = json) } + ?: Price(_json = json) + } + "grouped_with_min_max_thresholds" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedWithMinMaxThresholds = it, _json = json) } + ?: Price(_json = json) + } + "matrix_with_display_name" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(matrixWithDisplayName = it, _json = json) } + ?: Price(_json = json) + } + "bulk_with_proration" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(bulkWithProration = it, _json = json) } + ?: Price(_json = json) + } + "grouped_tiered_package" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedTieredPackage = it, _json = json) } + ?: Price(_json = json) + } + "max_group_tiered_package" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(maxGroupTieredPackage = it, _json = json) } + ?: Price(_json = json) + } + "scalable_matrix_with_unit_pricing" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(scalableMatrixWithUnitPricing = it, _json = json) } + ?: Price(_json = json) + } + "scalable_matrix_with_tiered_pricing" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(scalableMatrixWithTieredPricing = it, _json = json) } + ?: Price(_json = json) + } + "cumulative_grouped_bulk" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(cumulativeGroupedBulk = it, _json = json) } + ?: Price(_json = json) + } + "tiered_package_with_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(tieredPackageWithMinimum = it, _json = json) } + ?: Price(_json = json) + } + "matrix_with_allocation" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(matrixWithAllocation = it, _json = json) } + ?: Price(_json = json) + } + "grouped_tiered" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(groupedTiered = it, _json = json) } + ?: Price(_json = json) + } + "minimum" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(minimum = it, _json = json) + } ?: Price(_json = json) + } + } + + return Price(_json = json) + } + } + + internal class Serializer : BaseSerializer(Price::class) { + + override fun serialize( + value: Price, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.unit != null -> generator.writeObject(value.unit) + value.package_ != null -> generator.writeObject(value.package_) + value.matrix != null -> generator.writeObject(value.matrix) + value.tiered != null -> generator.writeObject(value.tiered) + value.bulk != null -> generator.writeObject(value.bulk) + value.thresholdTotalAmount != null -> + generator.writeObject(value.thresholdTotalAmount) + value.tieredPackage != null -> generator.writeObject(value.tieredPackage) + value.tieredWithMinimum != null -> + generator.writeObject(value.tieredWithMinimum) + value.unitWithPercent != null -> + generator.writeObject(value.unitWithPercent) + value.packageWithAllocation != null -> + generator.writeObject(value.packageWithAllocation) + value.tieredWithProration != null -> + generator.writeObject(value.tieredWithProration) + value.unitWithProration != null -> + generator.writeObject(value.unitWithProration) + value.groupedAllocation != null -> + generator.writeObject(value.groupedAllocation) + value.groupedWithProratedMinimum != null -> + generator.writeObject(value.groupedWithProratedMinimum) + value.groupedWithMeteredMinimum != null -> + generator.writeObject(value.groupedWithMeteredMinimum) + value.groupedWithMinMaxThresholds != null -> + generator.writeObject(value.groupedWithMinMaxThresholds) + value.matrixWithDisplayName != null -> + generator.writeObject(value.matrixWithDisplayName) + value.bulkWithProration != null -> + generator.writeObject(value.bulkWithProration) + value.groupedTieredPackage != null -> + generator.writeObject(value.groupedTieredPackage) + value.maxGroupTieredPackage != null -> + generator.writeObject(value.maxGroupTieredPackage) + value.scalableMatrixWithUnitPricing != null -> + generator.writeObject(value.scalableMatrixWithUnitPricing) + value.scalableMatrixWithTieredPricing != null -> + generator.writeObject(value.scalableMatrixWithTieredPricing) + value.cumulativeGroupedBulk != null -> + generator.writeObject(value.cumulativeGroupedBulk) + value.tieredPackageWithMinimum != null -> + generator.writeObject(value.tieredPackageWithMinimum) + value.matrixWithAllocation != null -> + generator.writeObject(value.matrixWithAllocation) + value.groupedTiered != null -> generator.writeObject(value.groupedTiered) + value.minimum != null -> generator.writeObject(value.minimum) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Price") + } + } + } - override fun ObjectCodec.deserialize(node: JsonNode): Price { - val json = JsonValue.fromJsonNode(node) - val modelType = json.asObject()?.get("model_type")?.asString() + class GroupedWithMinMaxThresholds + private constructor( + private val cadence: JsonField, + private val groupedWithMinMaxThresholdsConfig: + JsonField, + private val itemId: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("grouped_with_min_max_thresholds_config") + @ExcludeMissing + groupedWithMinMaxThresholdsConfig: + JsonField = + JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + groupedWithMinMaxThresholdsConfig, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + mutableMapOf(), + ) - when (modelType) { - "unit" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(unit = it, _json = json) - } ?: Price(_json = json) + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupedWithMinMaxThresholdsConfig(): GroupedWithMinMaxThresholdsConfig = + groupedWithMinMaxThresholdsConfig.getRequired( + "grouped_with_min_max_thresholds_config" + ) + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * Expected to always return the following: + * ```kotlin + * JsonValue.from("grouped_with_min_max_thresholds") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = billableMetricId.getNullable("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + invoiceGroupingKey.getNullable("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [groupedWithMinMaxThresholdsConfig]. + * + * Unlike [groupedWithMinMaxThresholdsConfig], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("grouped_with_min_max_thresholds_config") + @ExcludeMissing + fun _groupedWithMinMaxThresholdsConfig(): + JsonField = groupedWithMinMaxThresholdsConfig + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [GroupedWithMinMaxThresholds]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .groupedWithMinMaxThresholdsConfig() + * .itemId() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [GroupedWithMinMaxThresholds]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var groupedWithMinMaxThresholdsConfig: + JsonField? = + null + private var itemId: JsonField? = null + private var modelType: JsonValue = + JsonValue.from("grouped_with_min_max_thresholds") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds) = + apply { + cadence = groupedWithMinMaxThresholds.cadence + groupedWithMinMaxThresholdsConfig = + groupedWithMinMaxThresholds.groupedWithMinMaxThresholdsConfig + itemId = groupedWithMinMaxThresholds.itemId + modelType = groupedWithMinMaxThresholds.modelType + name = groupedWithMinMaxThresholds.name + billableMetricId = groupedWithMinMaxThresholds.billableMetricId + billedInAdvance = groupedWithMinMaxThresholds.billedInAdvance + billingCycleConfiguration = + groupedWithMinMaxThresholds.billingCycleConfiguration + conversionRate = groupedWithMinMaxThresholds.conversionRate + conversionRateConfig = groupedWithMinMaxThresholds.conversionRateConfig + currency = groupedWithMinMaxThresholds.currency + dimensionalPriceConfiguration = + groupedWithMinMaxThresholds.dimensionalPriceConfiguration + externalPriceId = groupedWithMinMaxThresholds.externalPriceId + fixedPriceQuantity = groupedWithMinMaxThresholds.fixedPriceQuantity + invoiceGroupingKey = groupedWithMinMaxThresholds.invoiceGroupingKey + invoicingCycleConfiguration = + groupedWithMinMaxThresholds.invoicingCycleConfiguration + metadata = groupedWithMinMaxThresholds.metadata + referenceId = groupedWithMinMaxThresholds.referenceId + additionalProperties = + groupedWithMinMaxThresholds.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + fun groupedWithMinMaxThresholdsConfig( + groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + ) = + groupedWithMinMaxThresholdsConfig( + JsonField.of(groupedWithMinMaxThresholdsConfig) + ) + + /** + * Sets [Builder.groupedWithMinMaxThresholdsConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.groupedWithMinMaxThresholdsConfig] with a + * well-typed [GroupedWithMinMaxThresholdsConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun groupedWithMinMaxThresholdsConfig( + groupedWithMinMaxThresholdsConfig: + JsonField + ) = apply { + this.groupedWithMinMaxThresholdsConfig = groupedWithMinMaxThresholdsConfig + } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("grouped_with_min_max_thresholds") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) } - "package" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(package_ = it, _json = json) } ?: Price(_json = json) + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [GroupedWithMinMaxThresholds]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .groupedWithMinMaxThresholdsConfig() + * .itemId() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedWithMinMaxThresholds = + GroupedWithMinMaxThresholds( + checkRequired("cadence", cadence), + checkRequired( + "groupedWithMinMaxThresholdsConfig", + groupedWithMinMaxThresholdsConfig, + ), + checkRequired("itemId", itemId), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GroupedWithMinMaxThresholds = apply { + if (validated) { + return@apply + } + + cadence().validate() + groupedWithMinMaxThresholdsConfig().validate() + itemId() + _modelType().let { + if (it != JsonValue.from("grouped_with_min_max_thresholds")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") } - "matrix" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(matrix = it, _json = json) - } ?: Price(_json = json) + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (groupedWithMinMaxThresholdsConfig.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + modelType.let { + if (it == JsonValue.from("grouped_with_min_max_thresholds")) 1 else 0 + } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class GroupedWithMinMaxThresholdsConfig + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [GroupedWithMinMaxThresholdsConfig]. + */ + fun builder() = Builder() + } + + /** A builder for [GroupedWithMinMaxThresholdsConfig]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from( + groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + ) = apply { + additionalProperties = + groupedWithMinMaxThresholdsConfig.additionalProperties + .toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [GroupedWithMinMaxThresholdsConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): GroupedWithMinMaxThresholdsConfig = + GroupedWithMinMaxThresholdsConfig(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): GroupedWithMinMaxThresholdsConfig = apply { + if (validated) { + return@apply } - "tiered" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(tiered = it, _json = json) - } ?: Price(_json = json) + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false } - "tiered_bps" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(tieredBps = it, _json = json) } ?: Price(_json = json) + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() } - "bps" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(bps = it, _json = json) - } ?: Price(_json = json) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - "bulk_bps" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(bulkBps = it, _json = json) } ?: Price(_json = json) + + return other is GroupedWithMinMaxThresholdsConfig && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedWithMinMaxThresholdsConfig{additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() } - "bulk" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(bulk = it, _json = json) - } ?: Price(_json = json) + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) } - "threshold_total_amount" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(thresholdTotalAmount = it, _json = json) } - ?: Price(_json = json) + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) } - "tiered_package" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(tieredPackage = it, _json = json) } - ?: Price(_json = json) + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) } - "tiered_with_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(tieredWithMinimum = it, _json = json) } - ?: Price(_json = json) + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply } - "unit_with_percent" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(unitWithPercent = it, _json = json) } - ?: Price(_json = json) + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false } - "package_with_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(packageWithAllocation = it, _json = json) } - ?: Price(_json = json) + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() } - "tiered_with_proration" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(tieredWithProration = it, _json = json) } - ?: Price(_json = json) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - "unit_with_proration" -> { - return tryDeserialize( - node, - jacksonTypeRef(), + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedWithMinMaxThresholds && + cadence == other.cadence && + groupedWithMinMaxThresholdsConfig == + other.groupedWithMinMaxThresholdsConfig && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + groupedWithMinMaxThresholdsConfig, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedWithMinMaxThresholds{cadence=$cadence, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class Minimum + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val minimumConfig: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("minimum_config") + @ExcludeMissing + minimumConfig: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + minimumConfig, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun minimumConfig(): MinimumConfig = minimumConfig.getRequired("minimum_config") + + /** + * Expected to always return the following: + * ```kotlin + * JsonValue.from("minimum") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = billableMetricId.getNullable("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + invoiceGroupingKey.getNullable("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [minimumConfig]. + * + * Unlike [minimumConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("minimum_config") + @ExcludeMissing + fun _minimumConfig(): JsonField = minimumConfig + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Minimum]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .minimumConfig() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Minimum]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var minimumConfig: JsonField? = null + private var modelType: JsonValue = JsonValue.from("minimum") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(minimum: Minimum) = apply { + cadence = minimum.cadence + itemId = minimum.itemId + minimumConfig = minimum.minimumConfig + modelType = minimum.modelType + name = minimum.name + billableMetricId = minimum.billableMetricId + billedInAdvance = minimum.billedInAdvance + billingCycleConfiguration = minimum.billingCycleConfiguration + conversionRate = minimum.conversionRate + conversionRateConfig = minimum.conversionRateConfig + currency = minimum.currency + dimensionalPriceConfiguration = minimum.dimensionalPriceConfiguration + externalPriceId = minimum.externalPriceId + fixedPriceQuantity = minimum.fixedPriceQuantity + invoiceGroupingKey = minimum.invoiceGroupingKey + invoicingCycleConfiguration = minimum.invoicingCycleConfiguration + metadata = minimum.metadata + referenceId = minimum.referenceId + additionalProperties = minimum.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun minimumConfig(minimumConfig: MinimumConfig) = + minimumConfig(JsonField.of(minimumConfig)) + + /** + * Sets [Builder.minimumConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumConfig] with a well-typed + * [MinimumConfig] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun minimumConfig(minimumConfig: JsonField) = apply { + this.minimumConfig = minimumConfig + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("minimum") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT ) - ?.let { Price(unitWithProration = it, _json = json) } - ?: Price(_json = json) - } - "grouped_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED ) - ?.let { Price(groupedAllocation = it, _json = json) } - ?: Price(_json = json) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) } - "grouped_with_prorated_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedWithProratedMinimum = it, _json = json) } - ?: Price(_json = json) + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Minimum]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .minimumConfig() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Minimum = + Minimum( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("minimumConfig", minimumConfig), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Minimum = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + minimumConfig().validate() + _modelType().let { + if (it != JsonValue.from("minimum")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") } - "grouped_with_metered_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedWithMeteredMinimum = it, _json = json) } - ?: Price(_json = json) + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + (minimumConfig.asKnown()?.validity() ?: 0) + + modelType.let { if (it == JsonValue.from("minimum")) 1 else 0 } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false } - "matrix_with_display_name" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(matrixWithDisplayName = it, _json = json) } - ?: Price(_json = json) + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - "bulk_with_proration" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(bulkWithProration = it, _json = json) } - ?: Price(_json = json) + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class MinimumConfig + private constructor( + private val minimumAmount: JsonField, + private val prorated: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("minimum_amount") + @ExcludeMissing + minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("prorated") + @ExcludeMissing + prorated: JsonField = JsonMissing.of(), + ) : this(minimumAmount, prorated, mutableMapOf()) + + /** + * The minimum amount to apply + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") + + /** + * By default, subtotals from minimum composite prices are prorated based on the + * service period. Set to false to disable proration. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun prorated(): Boolean? = prorated.getNullable("prorated") + + /** + * Returns the raw JSON value of [minimumAmount]. + * + * Unlike [minimumAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount + + /** + * Returns the raw JSON value of [prorated]. + * + * Unlike [prorated], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("prorated") + @ExcludeMissing + fun _prorated(): JsonField = prorated + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [MinimumConfig]. + * + * The following fields are required: + * ```kotlin + * .minimumAmount() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [MinimumConfig]. */ + class Builder internal constructor() { + + private var minimumAmount: JsonField? = null + private var prorated: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(minimumConfig: MinimumConfig) = apply { + minimumAmount = minimumConfig.minimumAmount + prorated = minimumConfig.prorated + additionalProperties = minimumConfig.additionalProperties.toMutableMap() + } + + /** The minimum amount to apply */ + fun minimumAmount(minimumAmount: String) = + minimumAmount(JsonField.of(minimumAmount)) + + /** + * Sets [Builder.minimumAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumAmount] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount + } + + /** + * By default, subtotals from minimum composite prices are prorated based on + * the service period. Set to false to disable proration. + */ + fun prorated(prorated: Boolean?) = prorated(JsonField.ofNullable(prorated)) + + /** + * Alias for [Builder.prorated]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun prorated(prorated: Boolean) = prorated(prorated as Boolean?) + + /** + * Sets [Builder.prorated] to an arbitrary JSON value. + * + * You should usually call [Builder.prorated] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun prorated(prorated: JsonField) = apply { + this.prorated = prorated + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [MinimumConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .minimumAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MinimumConfig = + MinimumConfig( + checkRequired("minimumAmount", minimumAmount), + prorated, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MinimumConfig = apply { + if (validated) { + return@apply } - "grouped_tiered_package" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedTieredPackage = it, _json = json) } - ?: Price(_json = json) + + minimumAmount() + prorated() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (minimumAmount.asKnown() == null) 0 else 1) + + (if (prorated.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MinimumConfig && + minimumAmount == other.minimumAmount && + prorated == other.prorated && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(minimumAmount, prorated, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MinimumConfig{minimumAmount=$minimumAmount, prorated=$prorated, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() } - "max_group_tiered_package" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(maxGroupTieredPackage = it, _json = json) } - ?: Price(_json = json) + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) } - "scalable_matrix_with_unit_pricing" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(scalableMatrixWithUnitPricing = it, _json = json) } - ?: Price(_json = json) + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) } - "scalable_matrix_with_tiered_pricing" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(scalableMatrixWithTieredPricing = it, _json = json) } - ?: Price(_json = json) + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) } - "cumulative_grouped_bulk" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(cumulativeGroupedBulk = it, _json = json) } - ?: Price(_json = json) + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply } - "tiered_package_with_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(tieredPackageWithMinimum = it, _json = json) } - ?: Price(_json = json) + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false } - "matrix_with_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(matrixWithAllocation = it, _json = json) } - ?: Price(_json = json) + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() } - "grouped_tiered" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(groupedTiered = it, _json = json) } - ?: Price(_json = json) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } + + return other is Metadata && + additionalProperties == other.additionalProperties } - return Price(_json = json) - } - } + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - internal class Serializer : BaseSerializer(Price::class) { + override fun hashCode(): Int = hashCode - override fun serialize( - value: Price, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unit != null -> generator.writeObject(value.unit) - value.package_ != null -> generator.writeObject(value.package_) - value.matrix != null -> generator.writeObject(value.matrix) - value.tiered != null -> generator.writeObject(value.tiered) - value.tieredBps != null -> generator.writeObject(value.tieredBps) - value.bps != null -> generator.writeObject(value.bps) - value.bulkBps != null -> generator.writeObject(value.bulkBps) - value.bulk != null -> generator.writeObject(value.bulk) - value.thresholdTotalAmount != null -> - generator.writeObject(value.thresholdTotalAmount) - value.tieredPackage != null -> generator.writeObject(value.tieredPackage) - value.tieredWithMinimum != null -> - generator.writeObject(value.tieredWithMinimum) - value.unitWithPercent != null -> - generator.writeObject(value.unitWithPercent) - value.packageWithAllocation != null -> - generator.writeObject(value.packageWithAllocation) - value.tieredWithProration != null -> - generator.writeObject(value.tieredWithProration) - value.unitWithProration != null -> - generator.writeObject(value.unitWithProration) - value.groupedAllocation != null -> - generator.writeObject(value.groupedAllocation) - value.groupedWithProratedMinimum != null -> - generator.writeObject(value.groupedWithProratedMinimum) - value.groupedWithMeteredMinimum != null -> - generator.writeObject(value.groupedWithMeteredMinimum) - value.matrixWithDisplayName != null -> - generator.writeObject(value.matrixWithDisplayName) - value.bulkWithProration != null -> - generator.writeObject(value.bulkWithProration) - value.groupedTieredPackage != null -> - generator.writeObject(value.groupedTieredPackage) - value.maxGroupTieredPackage != null -> - generator.writeObject(value.maxGroupTieredPackage) - value.scalableMatrixWithUnitPricing != null -> - generator.writeObject(value.scalableMatrixWithUnitPricing) - value.scalableMatrixWithTieredPricing != null -> - generator.writeObject(value.scalableMatrixWithTieredPricing) - value.cumulativeGroupedBulk != null -> - generator.writeObject(value.cumulativeGroupedBulk) - value.tieredPackageWithMinimum != null -> - generator.writeObject(value.tieredPackageWithMinimum) - value.matrixWithAllocation != null -> - generator.writeObject(value.matrixWithAllocation) - value.groupedTiered != null -> generator.writeObject(value.groupedTiered) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Price") + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } + + return other is Minimum && + cadence == other.cadence && + itemId == other.itemId && + minimumConfig == other.minimumConfig && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + minimumConfig, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Minimum{cadence=$cadence, itemId=$itemId, minimumConfig=$minimumConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } } diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BpsConfig.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BpsConfig.kt deleted file mode 100644 index ed1d95218..000000000 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BpsConfig.kt +++ /dev/null @@ -1,213 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.withorb.api.models - -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import com.withorb.api.core.ExcludeMissing -import com.withorb.api.core.JsonField -import com.withorb.api.core.JsonMissing -import com.withorb.api.core.JsonValue -import com.withorb.api.core.checkRequired -import com.withorb.api.errors.OrbInvalidDataException -import java.util.Collections -import java.util.Objects - -class BpsConfig -private constructor( - private val bps: JsonField, - private val perUnitMaximum: JsonField, - private val additionalProperties: MutableMap, -) { - - @JsonCreator - private constructor( - @JsonProperty("bps") @ExcludeMissing bps: JsonField = JsonMissing.of(), - @JsonProperty("per_unit_maximum") - @ExcludeMissing - perUnitMaximum: JsonField = JsonMissing.of(), - ) : this(bps, perUnitMaximum, mutableMapOf()) - - /** - * Basis point take rate per event - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly - * missing or null (e.g. if the server responded with an unexpected value). - */ - fun bps(): Double = bps.getRequired("bps") - - /** - * Optional currency amount maximum to cap spend per event - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - fun perUnitMaximum(): String? = perUnitMaximum.getNullable("per_unit_maximum") - - /** - * Returns the raw JSON value of [bps]. - * - * Unlike [bps], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("bps") @ExcludeMissing fun _bps(): JsonField = bps - - /** - * Returns the raw JSON value of [perUnitMaximum]. - * - * Unlike [perUnitMaximum], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("per_unit_maximum") - @ExcludeMissing - fun _perUnitMaximum(): JsonField = perUnitMaximum - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [BpsConfig]. - * - * The following fields are required: - * ```kotlin - * .bps() - * ``` - */ - fun builder() = Builder() - } - - /** A builder for [BpsConfig]. */ - class Builder internal constructor() { - - private var bps: JsonField? = null - private var perUnitMaximum: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(bpsConfig: BpsConfig) = apply { - bps = bpsConfig.bps - perUnitMaximum = bpsConfig.perUnitMaximum - additionalProperties = bpsConfig.additionalProperties.toMutableMap() - } - - /** Basis point take rate per event */ - fun bps(bps: Double) = bps(JsonField.of(bps)) - - /** - * Sets [Builder.bps] to an arbitrary JSON value. - * - * You should usually call [Builder.bps] with a well-typed [Double] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun bps(bps: JsonField) = apply { this.bps = bps } - - /** Optional currency amount maximum to cap spend per event */ - fun perUnitMaximum(perUnitMaximum: String?) = - perUnitMaximum(JsonField.ofNullable(perUnitMaximum)) - - /** - * Sets [Builder.perUnitMaximum] to an arbitrary JSON value. - * - * You should usually call [Builder.perUnitMaximum] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun perUnitMaximum(perUnitMaximum: JsonField) = apply { - this.perUnitMaximum = perUnitMaximum - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [BpsConfig]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```kotlin - * .bps() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): BpsConfig = - BpsConfig( - checkRequired("bps", bps), - perUnitMaximum, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): BpsConfig = apply { - if (validated) { - return@apply - } - - bps() - perUnitMaximum() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (if (bps.asKnown() == null) 0 else 1) + (if (perUnitMaximum.asKnown() == null) 0 else 1) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is BpsConfig && - bps == other.bps && - perUnitMaximum == other.perUnitMaximum && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(bps, perUnitMaximum, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BpsConfig{bps=$bps, perUnitMaximum=$perUnitMaximum, additionalProperties=$additionalProperties}" -} diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BpsTier.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BpsTier.kt deleted file mode 100644 index c00795cd7..000000000 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BpsTier.kt +++ /dev/null @@ -1,301 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.withorb.api.models - -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import com.withorb.api.core.ExcludeMissing -import com.withorb.api.core.JsonField -import com.withorb.api.core.JsonMissing -import com.withorb.api.core.JsonValue -import com.withorb.api.core.checkRequired -import com.withorb.api.errors.OrbInvalidDataException -import java.util.Collections -import java.util.Objects - -class BpsTier -private constructor( - private val bps: JsonField, - private val minimumAmount: JsonField, - private val maximumAmount: JsonField, - private val perUnitMaximum: JsonField, - private val additionalProperties: MutableMap, -) { - - @JsonCreator - private constructor( - @JsonProperty("bps") @ExcludeMissing bps: JsonField = JsonMissing.of(), - @JsonProperty("minimum_amount") - @ExcludeMissing - minimumAmount: JsonField = JsonMissing.of(), - @JsonProperty("maximum_amount") - @ExcludeMissing - maximumAmount: JsonField = JsonMissing.of(), - @JsonProperty("per_unit_maximum") - @ExcludeMissing - perUnitMaximum: JsonField = JsonMissing.of(), - ) : this(bps, minimumAmount, maximumAmount, perUnitMaximum, mutableMapOf()) - - /** - * Per-event basis point rate - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly - * missing or null (e.g. if the server responded with an unexpected value). - */ - fun bps(): Double = bps.getRequired("bps") - - /** - * Exclusive tier starting value - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly - * missing or null (e.g. if the server responded with an unexpected value). - */ - fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") - - /** - * Inclusive tier ending value - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - fun maximumAmount(): String? = maximumAmount.getNullable("maximum_amount") - - /** - * Per unit maximum to charge - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - fun perUnitMaximum(): String? = perUnitMaximum.getNullable("per_unit_maximum") - - /** - * Returns the raw JSON value of [bps]. - * - * Unlike [bps], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("bps") @ExcludeMissing fun _bps(): JsonField = bps - - /** - * Returns the raw JSON value of [minimumAmount]. - * - * Unlike [minimumAmount], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("minimum_amount") - @ExcludeMissing - fun _minimumAmount(): JsonField = minimumAmount - - /** - * Returns the raw JSON value of [maximumAmount]. - * - * Unlike [maximumAmount], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("maximum_amount") - @ExcludeMissing - fun _maximumAmount(): JsonField = maximumAmount - - /** - * Returns the raw JSON value of [perUnitMaximum]. - * - * Unlike [perUnitMaximum], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("per_unit_maximum") - @ExcludeMissing - fun _perUnitMaximum(): JsonField = perUnitMaximum - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [BpsTier]. - * - * The following fields are required: - * ```kotlin - * .bps() - * .minimumAmount() - * ``` - */ - fun builder() = Builder() - } - - /** A builder for [BpsTier]. */ - class Builder internal constructor() { - - private var bps: JsonField? = null - private var minimumAmount: JsonField? = null - private var maximumAmount: JsonField = JsonMissing.of() - private var perUnitMaximum: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(bpsTier: BpsTier) = apply { - bps = bpsTier.bps - minimumAmount = bpsTier.minimumAmount - maximumAmount = bpsTier.maximumAmount - perUnitMaximum = bpsTier.perUnitMaximum - additionalProperties = bpsTier.additionalProperties.toMutableMap() - } - - /** Per-event basis point rate */ - fun bps(bps: Double) = bps(JsonField.of(bps)) - - /** - * Sets [Builder.bps] to an arbitrary JSON value. - * - * You should usually call [Builder.bps] with a well-typed [Double] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun bps(bps: JsonField) = apply { this.bps = bps } - - /** Exclusive tier starting value */ - fun minimumAmount(minimumAmount: String) = minimumAmount(JsonField.of(minimumAmount)) - - /** - * Sets [Builder.minimumAmount] to an arbitrary JSON value. - * - * You should usually call [Builder.minimumAmount] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun minimumAmount(minimumAmount: JsonField) = apply { - this.minimumAmount = minimumAmount - } - - /** Inclusive tier ending value */ - fun maximumAmount(maximumAmount: String?) = - maximumAmount(JsonField.ofNullable(maximumAmount)) - - /** - * Sets [Builder.maximumAmount] to an arbitrary JSON value. - * - * You should usually call [Builder.maximumAmount] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun maximumAmount(maximumAmount: JsonField) = apply { - this.maximumAmount = maximumAmount - } - - /** Per unit maximum to charge */ - fun perUnitMaximum(perUnitMaximum: String?) = - perUnitMaximum(JsonField.ofNullable(perUnitMaximum)) - - /** - * Sets [Builder.perUnitMaximum] to an arbitrary JSON value. - * - * You should usually call [Builder.perUnitMaximum] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun perUnitMaximum(perUnitMaximum: JsonField) = apply { - this.perUnitMaximum = perUnitMaximum - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [BpsTier]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```kotlin - * .bps() - * .minimumAmount() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): BpsTier = - BpsTier( - checkRequired("bps", bps), - checkRequired("minimumAmount", minimumAmount), - maximumAmount, - perUnitMaximum, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): BpsTier = apply { - if (validated) { - return@apply - } - - bps() - minimumAmount() - maximumAmount() - perUnitMaximum() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (if (bps.asKnown() == null) 0 else 1) + - (if (minimumAmount.asKnown() == null) 0 else 1) + - (if (maximumAmount.asKnown() == null) 0 else 1) + - (if (perUnitMaximum.asKnown() == null) 0 else 1) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is BpsTier && - bps == other.bps && - minimumAmount == other.minimumAmount && - maximumAmount == other.maximumAmount && - perUnitMaximum == other.perUnitMaximum && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(bps, minimumAmount, maximumAmount, perUnitMaximum, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BpsTier{bps=$bps, minimumAmount=$minimumAmount, maximumAmount=$maximumAmount, perUnitMaximum=$perUnitMaximum, additionalProperties=$additionalProperties}" -} diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BulkBpsConfig.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BulkBpsConfig.kt deleted file mode 100644 index 9dff18f20..000000000 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BulkBpsConfig.kt +++ /dev/null @@ -1,192 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.withorb.api.models - -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import com.withorb.api.core.ExcludeMissing -import com.withorb.api.core.JsonField -import com.withorb.api.core.JsonMissing -import com.withorb.api.core.JsonValue -import com.withorb.api.core.checkKnown -import com.withorb.api.core.checkRequired -import com.withorb.api.core.toImmutable -import com.withorb.api.errors.OrbInvalidDataException -import java.util.Collections -import java.util.Objects - -class BulkBpsConfig -private constructor( - private val tiers: JsonField>, - private val additionalProperties: MutableMap, -) { - - @JsonCreator - private constructor( - @JsonProperty("tiers") - @ExcludeMissing - tiers: JsonField> = JsonMissing.of() - ) : this(tiers, mutableMapOf()) - - /** - * Tiers for a bulk BPS pricing model where all usage is aggregated to a single tier based on - * total volume - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly - * missing or null (e.g. if the server responded with an unexpected value). - */ - fun tiers(): List = tiers.getRequired("tiers") - - /** - * Returns the raw JSON value of [tiers]. - * - * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("tiers") @ExcludeMissing fun _tiers(): JsonField> = tiers - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [BulkBpsConfig]. - * - * The following fields are required: - * ```kotlin - * .tiers() - * ``` - */ - fun builder() = Builder() - } - - /** A builder for [BulkBpsConfig]. */ - class Builder internal constructor() { - - private var tiers: JsonField>? = null - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(bulkBpsConfig: BulkBpsConfig) = apply { - tiers = bulkBpsConfig.tiers.map { it.toMutableList() } - additionalProperties = bulkBpsConfig.additionalProperties.toMutableMap() - } - - /** - * Tiers for a bulk BPS pricing model where all usage is aggregated to a single tier based - * on total volume - */ - fun tiers(tiers: List) = tiers(JsonField.of(tiers)) - - /** - * Sets [Builder.tiers] to an arbitrary JSON value. - * - * You should usually call [Builder.tiers] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun tiers(tiers: JsonField>) = apply { - this.tiers = tiers.map { it.toMutableList() } - } - - /** - * Adds a single [BulkBpsTier] to [tiers]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addTier(tier: BulkBpsTier) = apply { - tiers = - (tiers ?: JsonField.of(mutableListOf())).also { checkKnown("tiers", it).add(tier) } - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [BulkBpsConfig]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```kotlin - * .tiers() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): BulkBpsConfig = - BulkBpsConfig( - checkRequired("tiers", tiers).map { it.toImmutable() }, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): BulkBpsConfig = apply { - if (validated) { - return@apply - } - - tiers().forEach { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = (tiers.asKnown()?.sumOf { it.validity().toInt() } ?: 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is BulkBpsConfig && - tiers == other.tiers && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(tiers, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BulkBpsConfig{tiers=$tiers, additionalProperties=$additionalProperties}" -} diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BulkBpsTier.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BulkBpsTier.kt deleted file mode 100644 index 2b2d6c3bf..000000000 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BulkBpsTier.kt +++ /dev/null @@ -1,258 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.withorb.api.models - -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import com.withorb.api.core.ExcludeMissing -import com.withorb.api.core.JsonField -import com.withorb.api.core.JsonMissing -import com.withorb.api.core.JsonValue -import com.withorb.api.core.checkRequired -import com.withorb.api.errors.OrbInvalidDataException -import java.util.Collections -import java.util.Objects - -class BulkBpsTier -private constructor( - private val bps: JsonField, - private val maximumAmount: JsonField, - private val perUnitMaximum: JsonField, - private val additionalProperties: MutableMap, -) { - - @JsonCreator - private constructor( - @JsonProperty("bps") @ExcludeMissing bps: JsonField = JsonMissing.of(), - @JsonProperty("maximum_amount") - @ExcludeMissing - maximumAmount: JsonField = JsonMissing.of(), - @JsonProperty("per_unit_maximum") - @ExcludeMissing - perUnitMaximum: JsonField = JsonMissing.of(), - ) : this(bps, maximumAmount, perUnitMaximum, mutableMapOf()) - - /** - * Basis points to rate on - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly - * missing or null (e.g. if the server responded with an unexpected value). - */ - fun bps(): Double = bps.getRequired("bps") - - /** - * Upper bound for tier - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - fun maximumAmount(): String? = maximumAmount.getNullable("maximum_amount") - - /** - * The maximum amount to charge for any one event - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - fun perUnitMaximum(): String? = perUnitMaximum.getNullable("per_unit_maximum") - - /** - * Returns the raw JSON value of [bps]. - * - * Unlike [bps], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("bps") @ExcludeMissing fun _bps(): JsonField = bps - - /** - * Returns the raw JSON value of [maximumAmount]. - * - * Unlike [maximumAmount], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("maximum_amount") - @ExcludeMissing - fun _maximumAmount(): JsonField = maximumAmount - - /** - * Returns the raw JSON value of [perUnitMaximum]. - * - * Unlike [perUnitMaximum], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("per_unit_maximum") - @ExcludeMissing - fun _perUnitMaximum(): JsonField = perUnitMaximum - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [BulkBpsTier]. - * - * The following fields are required: - * ```kotlin - * .bps() - * ``` - */ - fun builder() = Builder() - } - - /** A builder for [BulkBpsTier]. */ - class Builder internal constructor() { - - private var bps: JsonField? = null - private var maximumAmount: JsonField = JsonMissing.of() - private var perUnitMaximum: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(bulkBpsTier: BulkBpsTier) = apply { - bps = bulkBpsTier.bps - maximumAmount = bulkBpsTier.maximumAmount - perUnitMaximum = bulkBpsTier.perUnitMaximum - additionalProperties = bulkBpsTier.additionalProperties.toMutableMap() - } - - /** Basis points to rate on */ - fun bps(bps: Double) = bps(JsonField.of(bps)) - - /** - * Sets [Builder.bps] to an arbitrary JSON value. - * - * You should usually call [Builder.bps] with a well-typed [Double] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun bps(bps: JsonField) = apply { this.bps = bps } - - /** Upper bound for tier */ - fun maximumAmount(maximumAmount: String?) = - maximumAmount(JsonField.ofNullable(maximumAmount)) - - /** - * Sets [Builder.maximumAmount] to an arbitrary JSON value. - * - * You should usually call [Builder.maximumAmount] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun maximumAmount(maximumAmount: JsonField) = apply { - this.maximumAmount = maximumAmount - } - - /** The maximum amount to charge for any one event */ - fun perUnitMaximum(perUnitMaximum: String?) = - perUnitMaximum(JsonField.ofNullable(perUnitMaximum)) - - /** - * Sets [Builder.perUnitMaximum] to an arbitrary JSON value. - * - * You should usually call [Builder.perUnitMaximum] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun perUnitMaximum(perUnitMaximum: JsonField) = apply { - this.perUnitMaximum = perUnitMaximum - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [BulkBpsTier]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```kotlin - * .bps() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): BulkBpsTier = - BulkBpsTier( - checkRequired("bps", bps), - maximumAmount, - perUnitMaximum, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): BulkBpsTier = apply { - if (validated) { - return@apply - } - - bps() - maximumAmount() - perUnitMaximum() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (if (bps.asKnown() == null) 0 else 1) + - (if (maximumAmount.asKnown() == null) 0 else 1) + - (if (perUnitMaximum.asKnown() == null) 0 else 1) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is BulkBpsTier && - bps == other.bps && - maximumAmount == other.maximumAmount && - perUnitMaximum == other.perUnitMaximum && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(bps, maximumAmount, perUnitMaximum, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BulkBpsTier{bps=$bps, maximumAmount=$maximumAmount, perUnitMaximum=$perUnitMaximum, additionalProperties=$additionalProperties}" -} diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Customer.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Customer.kt index cdd3b82d9..b353a5f48 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Customer.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Customer.kt @@ -42,6 +42,7 @@ private constructor( private val id: JsonField, private val additionalEmails: JsonField>, private val autoCollection: JsonField, + private val autoIssuance: JsonField, private val balance: JsonField, private val billingAddress: JsonField
, private val createdAt: JsonField, @@ -73,6 +74,9 @@ private constructor( @JsonProperty("auto_collection") @ExcludeMissing autoCollection: JsonField = JsonMissing.of(), + @JsonProperty("auto_issuance") + @ExcludeMissing + autoIssuance: JsonField = JsonMissing.of(), @JsonProperty("balance") @ExcludeMissing balance: JsonField = JsonMissing.of(), @JsonProperty("billing_address") @ExcludeMissing @@ -118,6 +122,7 @@ private constructor( id, additionalEmails, autoCollection, + autoIssuance, balance, billingAddress, createdAt, @@ -158,6 +163,16 @@ private constructor( */ fun autoCollection(): Boolean = autoCollection.getRequired("auto_collection") + /** + * Whether invoices for this customer should be automatically issued. If true, invoices will be + * automatically issued. If false, invoices will require manual approval. If null, inherits the + * account-level setting. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun autoIssuance(): Boolean? = autoIssuance.getNullable("auto_issuance") + /** * The customer's current balance in their currency. * @@ -472,6 +487,15 @@ private constructor( @ExcludeMissing fun _autoCollection(): JsonField = autoCollection + /** + * Returns the raw JSON value of [autoIssuance]. + * + * Unlike [autoIssuance], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("auto_issuance") + @ExcludeMissing + fun _autoIssuance(): JsonField = autoIssuance + /** * Returns the raw JSON value of [balance]. * @@ -653,6 +677,7 @@ private constructor( * .id() * .additionalEmails() * .autoCollection() + * .autoIssuance() * .balance() * .billingAddress() * .createdAt() @@ -681,6 +706,7 @@ private constructor( private var id: JsonField? = null private var additionalEmails: JsonField>? = null private var autoCollection: JsonField? = null + private var autoIssuance: JsonField? = null private var balance: JsonField? = null private var billingAddress: JsonField
? = null private var createdAt: JsonField? = null @@ -707,6 +733,7 @@ private constructor( id = customer.id additionalEmails = customer.additionalEmails.map { it.toMutableList() } autoCollection = customer.autoCollection + autoIssuance = customer.autoIssuance balance = customer.balance billingAddress = customer.billingAddress createdAt = customer.createdAt @@ -778,6 +805,31 @@ private constructor( this.autoCollection = autoCollection } + /** + * Whether invoices for this customer should be automatically issued. If true, invoices will + * be automatically issued. If false, invoices will require manual approval. If null, + * inherits the account-level setting. + */ + fun autoIssuance(autoIssuance: Boolean?) = autoIssuance(JsonField.ofNullable(autoIssuance)) + + /** + * Alias for [Builder.autoIssuance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun autoIssuance(autoIssuance: Boolean) = autoIssuance(autoIssuance as Boolean?) + + /** + * Sets [Builder.autoIssuance] to an arbitrary JSON value. + * + * You should usually call [Builder.autoIssuance] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun autoIssuance(autoIssuance: JsonField) = apply { + this.autoIssuance = autoIssuance + } + /** The customer's current balance in their currency. */ fun balance(balance: String) = balance(JsonField.of(balance)) @@ -1221,6 +1273,7 @@ private constructor( * .id() * .additionalEmails() * .autoCollection() + * .autoIssuance() * .balance() * .billingAddress() * .createdAt() @@ -1247,6 +1300,7 @@ private constructor( checkRequired("id", id), checkRequired("additionalEmails", additionalEmails).map { it.toImmutable() }, checkRequired("autoCollection", autoCollection), + checkRequired("autoIssuance", autoIssuance), checkRequired("balance", balance), checkRequired("billingAddress", billingAddress), checkRequired("createdAt", createdAt), @@ -1280,6 +1334,7 @@ private constructor( id() additionalEmails() autoCollection() + autoIssuance() balance() billingAddress()?.validate() createdAt() @@ -1319,6 +1374,7 @@ private constructor( (if (id.asKnown() == null) 0 else 1) + (additionalEmails.asKnown()?.size ?: 0) + (if (autoCollection.asKnown() == null) 0 else 1) + + (if (autoIssuance.asKnown() == null) 0 else 1) + (if (balance.asKnown() == null) 0 else 1) + (billingAddress.asKnown()?.validity() ?: 0) + (if (createdAt.asKnown() == null) 0 else 1) + @@ -2527,6 +2583,7 @@ private constructor( id == other.id && additionalEmails == other.additionalEmails && autoCollection == other.autoCollection && + autoIssuance == other.autoIssuance && balance == other.balance && billingAddress == other.billingAddress && createdAt == other.createdAt && @@ -2554,6 +2611,7 @@ private constructor( id, additionalEmails, autoCollection, + autoIssuance, balance, billingAddress, createdAt, @@ -2580,5 +2638,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Customer{id=$id, additionalEmails=$additionalEmails, autoCollection=$autoCollection, balance=$balance, billingAddress=$billingAddress, createdAt=$createdAt, currency=$currency, email=$email, emailDelivery=$emailDelivery, exemptFromAutomatedTax=$exemptFromAutomatedTax, externalCustomerId=$externalCustomerId, hierarchy=$hierarchy, metadata=$metadata, name=$name, paymentProvider=$paymentProvider, paymentProviderId=$paymentProviderId, portalUrl=$portalUrl, shippingAddress=$shippingAddress, taxId=$taxId, timezone=$timezone, accountingSyncConfiguration=$accountingSyncConfiguration, reportingConfiguration=$reportingConfiguration, additionalProperties=$additionalProperties}" + "Customer{id=$id, additionalEmails=$additionalEmails, autoCollection=$autoCollection, autoIssuance=$autoIssuance, balance=$balance, billingAddress=$billingAddress, createdAt=$createdAt, currency=$currency, email=$email, emailDelivery=$emailDelivery, exemptFromAutomatedTax=$exemptFromAutomatedTax, externalCustomerId=$externalCustomerId, hierarchy=$hierarchy, metadata=$metadata, name=$name, paymentProvider=$paymentProvider, paymentProviderId=$paymentProviderId, portalUrl=$portalUrl, shippingAddress=$shippingAddress, taxId=$taxId, timezone=$timezone, accountingSyncConfiguration=$accountingSyncConfiguration, reportingConfiguration=$reportingConfiguration, additionalProperties=$additionalProperties}" } diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionCreateResponse.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionCreateResponse.kt index f6e728472..7dbc64468 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionCreateResponse.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionCreateResponse.kt @@ -544,6 +544,8 @@ private constructor( val EXTERNAL_PAYMENT = of("external_payment") + val SMALL_INVOICE_CARRYOVER = of("small_invoice_carryover") + fun of(value: String) = Action(JsonField.of(value)) } @@ -558,6 +560,7 @@ private constructor( CREDIT_NOTE_VOIDED, OVERPAYMENT_REFUND, EXTERNAL_PAYMENT, + SMALL_INVOICE_CARRYOVER, } /** @@ -579,6 +582,7 @@ private constructor( CREDIT_NOTE_VOIDED, OVERPAYMENT_REFUND, EXTERNAL_PAYMENT, + SMALL_INVOICE_CARRYOVER, /** An enum member indicating that [Action] was instantiated with an unknown value. */ _UNKNOWN, } @@ -601,6 +605,7 @@ private constructor( CREDIT_NOTE_VOIDED -> Value.CREDIT_NOTE_VOIDED OVERPAYMENT_REFUND -> Value.OVERPAYMENT_REFUND EXTERNAL_PAYMENT -> Value.EXTERNAL_PAYMENT + SMALL_INVOICE_CARRYOVER -> Value.SMALL_INVOICE_CARRYOVER else -> Value._UNKNOWN } @@ -623,6 +628,7 @@ private constructor( CREDIT_NOTE_VOIDED -> Known.CREDIT_NOTE_VOIDED OVERPAYMENT_REFUND -> Known.OVERPAYMENT_REFUND EXTERNAL_PAYMENT -> Known.EXTERNAL_PAYMENT + SMALL_INVOICE_CARRYOVER -> Known.SMALL_INVOICE_CARRYOVER else -> throw OrbInvalidDataException("Unknown Action: $value") } diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionListResponse.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionListResponse.kt index bbccd5e74..4172434b7 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionListResponse.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionListResponse.kt @@ -544,6 +544,8 @@ private constructor( val EXTERNAL_PAYMENT = of("external_payment") + val SMALL_INVOICE_CARRYOVER = of("small_invoice_carryover") + fun of(value: String) = Action(JsonField.of(value)) } @@ -558,6 +560,7 @@ private constructor( CREDIT_NOTE_VOIDED, OVERPAYMENT_REFUND, EXTERNAL_PAYMENT, + SMALL_INVOICE_CARRYOVER, } /** @@ -579,6 +582,7 @@ private constructor( CREDIT_NOTE_VOIDED, OVERPAYMENT_REFUND, EXTERNAL_PAYMENT, + SMALL_INVOICE_CARRYOVER, /** An enum member indicating that [Action] was instantiated with an unknown value. */ _UNKNOWN, } @@ -601,6 +605,7 @@ private constructor( CREDIT_NOTE_VOIDED -> Value.CREDIT_NOTE_VOIDED OVERPAYMENT_REFUND -> Value.OVERPAYMENT_REFUND EXTERNAL_PAYMENT -> Value.EXTERNAL_PAYMENT + SMALL_INVOICE_CARRYOVER -> Value.SMALL_INVOICE_CARRYOVER else -> Value._UNKNOWN } @@ -623,6 +628,7 @@ private constructor( CREDIT_NOTE_VOIDED -> Known.CREDIT_NOTE_VOIDED OVERPAYMENT_REFUND -> Known.OVERPAYMENT_REFUND EXTERNAL_PAYMENT -> Known.EXTERNAL_PAYMENT + SMALL_INVOICE_CARRYOVER -> Known.SMALL_INVOICE_CARRYOVER else -> throw OrbInvalidDataException("Unknown Action: $value") } diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreateParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreateParams.kt index 5beb136ab..e0d2fc7a7 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreateParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreateParams.kt @@ -93,6 +93,17 @@ private constructor( */ fun autoCollection(): Boolean? = body.autoCollection() + /** + * Used to determine if invoices for this customer will be automatically issued. If true, + * invoices will be automatically issued. If false, invoices will require manual approval. If + * `null` is specified, the customer's auto issuance setting will be inherited from the + * account-level setting. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun autoIssuance(): Boolean? = body.autoIssuance() + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server * responded with an unexpected value). @@ -376,6 +387,13 @@ private constructor( */ fun _autoCollection(): JsonField = body._autoCollection() + /** + * Returns the raw JSON value of [autoIssuance]. + * + * Unlike [autoIssuance], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _autoIssuance(): JsonField = body._autoIssuance() + /** * Returns the raw JSON value of [billingAddress]. * @@ -616,6 +634,32 @@ private constructor( body.autoCollection(autoCollection) } + /** + * Used to determine if invoices for this customer will be automatically issued. If true, + * invoices will be automatically issued. If false, invoices will require manual approval. + * If `null` is specified, the customer's auto issuance setting will be inherited from the + * account-level setting. + */ + fun autoIssuance(autoIssuance: Boolean?) = apply { body.autoIssuance(autoIssuance) } + + /** + * Alias for [Builder.autoIssuance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun autoIssuance(autoIssuance: Boolean) = autoIssuance(autoIssuance as Boolean?) + + /** + * Sets [Builder.autoIssuance] to an arbitrary JSON value. + * + * You should usually call [Builder.autoIssuance] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun autoIssuance(autoIssuance: JsonField) = apply { + body.autoIssuance(autoIssuance) + } + fun billingAddress(billingAddress: AddressInput?) = apply { body.billingAddress(billingAddress) } @@ -1175,6 +1219,7 @@ private constructor( private val accountingSyncConfiguration: JsonField, private val additionalEmails: JsonField>, private val autoCollection: JsonField, + private val autoIssuance: JsonField, private val billingAddress: JsonField, private val currency: JsonField, private val emailDelivery: JsonField, @@ -1205,6 +1250,9 @@ private constructor( @JsonProperty("auto_collection") @ExcludeMissing autoCollection: JsonField = JsonMissing.of(), + @JsonProperty("auto_issuance") + @ExcludeMissing + autoIssuance: JsonField = JsonMissing.of(), @JsonProperty("billing_address") @ExcludeMissing billingAddress: JsonField = JsonMissing.of(), @@ -1248,6 +1296,7 @@ private constructor( accountingSyncConfiguration, additionalEmails, autoCollection, + autoIssuance, billingAddress, currency, emailDelivery, @@ -1307,6 +1356,17 @@ private constructor( */ fun autoCollection(): Boolean? = autoCollection.getNullable("auto_collection") + /** + * Used to determine if invoices for this customer will be automatically issued. If true, + * invoices will be automatically issued. If false, invoices will require manual approval. + * If `null` is specified, the customer's auto issuance setting will be inherited from the + * account-level setting. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun autoIssuance(): Boolean? = autoIssuance.getNullable("auto_issuance") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -1599,6 +1659,16 @@ private constructor( @ExcludeMissing fun _autoCollection(): JsonField = autoCollection + /** + * Returns the raw JSON value of [autoIssuance]. + * + * Unlike [autoIssuance], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("auto_issuance") + @ExcludeMissing + fun _autoIssuance(): JsonField = autoIssuance + /** * Returns the raw JSON value of [billingAddress]. * @@ -1751,6 +1821,7 @@ private constructor( JsonMissing.of() private var additionalEmails: JsonField>? = null private var autoCollection: JsonField = JsonMissing.of() + private var autoIssuance: JsonField = JsonMissing.of() private var billingAddress: JsonField = JsonMissing.of() private var currency: JsonField = JsonMissing.of() private var emailDelivery: JsonField = JsonMissing.of() @@ -1773,6 +1844,7 @@ private constructor( accountingSyncConfiguration = body.accountingSyncConfiguration additionalEmails = body.additionalEmails.map { it.toMutableList() } autoCollection = body.autoCollection + autoIssuance = body.autoIssuance billingAddress = body.billingAddress currency = body.currency emailDelivery = body.emailDelivery @@ -1888,6 +1960,33 @@ private constructor( this.autoCollection = autoCollection } + /** + * Used to determine if invoices for this customer will be automatically issued. If + * true, invoices will be automatically issued. If false, invoices will require manual + * approval. If `null` is specified, the customer's auto issuance setting will be + * inherited from the account-level setting. + */ + fun autoIssuance(autoIssuance: Boolean?) = + autoIssuance(JsonField.ofNullable(autoIssuance)) + + /** + * Alias for [Builder.autoIssuance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun autoIssuance(autoIssuance: Boolean) = autoIssuance(autoIssuance as Boolean?) + + /** + * Sets [Builder.autoIssuance] to an arbitrary JSON value. + * + * You should usually call [Builder.autoIssuance] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun autoIssuance(autoIssuance: JsonField) = apply { + this.autoIssuance = autoIssuance + } + fun billingAddress(billingAddress: AddressInput?) = billingAddress(JsonField.ofNullable(billingAddress)) @@ -2340,6 +2439,7 @@ private constructor( accountingSyncConfiguration, (additionalEmails ?: JsonMissing.of()).map { it.toImmutable() }, autoCollection, + autoIssuance, billingAddress, currency, emailDelivery, @@ -2369,6 +2469,7 @@ private constructor( accountingSyncConfiguration()?.validate() additionalEmails() autoCollection() + autoIssuance() billingAddress()?.validate() currency() emailDelivery() @@ -2405,6 +2506,7 @@ private constructor( (accountingSyncConfiguration.asKnown()?.validity() ?: 0) + (additionalEmails.asKnown()?.size ?: 0) + (if (autoCollection.asKnown() == null) 0 else 1) + + (if (autoIssuance.asKnown() == null) 0 else 1) + (billingAddress.asKnown()?.validity() ?: 0) + (if (currency.asKnown() == null) 0 else 1) + (if (emailDelivery.asKnown() == null) 0 else 1) + @@ -2430,6 +2532,7 @@ private constructor( accountingSyncConfiguration == other.accountingSyncConfiguration && additionalEmails == other.additionalEmails && autoCollection == other.autoCollection && + autoIssuance == other.autoIssuance && billingAddress == other.billingAddress && currency == other.currency && emailDelivery == other.emailDelivery && @@ -2453,6 +2556,7 @@ private constructor( accountingSyncConfiguration, additionalEmails, autoCollection, + autoIssuance, billingAddress, currency, emailDelivery, @@ -2473,7 +2577,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Body{email=$email, name=$name, accountingSyncConfiguration=$accountingSyncConfiguration, additionalEmails=$additionalEmails, autoCollection=$autoCollection, billingAddress=$billingAddress, currency=$currency, emailDelivery=$emailDelivery, externalCustomerId=$externalCustomerId, hierarchy=$hierarchy, metadata=$metadata, paymentProvider=$paymentProvider, paymentProviderId=$paymentProviderId, reportingConfiguration=$reportingConfiguration, shippingAddress=$shippingAddress, taxConfiguration=$taxConfiguration, taxId=$taxId, timezone=$timezone, additionalProperties=$additionalProperties}" + "Body{email=$email, name=$name, accountingSyncConfiguration=$accountingSyncConfiguration, additionalEmails=$additionalEmails, autoCollection=$autoCollection, autoIssuance=$autoIssuance, billingAddress=$billingAddress, currency=$currency, emailDelivery=$emailDelivery, externalCustomerId=$externalCustomerId, hierarchy=$hierarchy, metadata=$metadata, paymentProvider=$paymentProvider, paymentProviderId=$paymentProviderId, reportingConfiguration=$reportingConfiguration, shippingAddress=$shippingAddress, taxConfiguration=$taxConfiguration, taxId=$taxId, timezone=$timezone, additionalProperties=$additionalProperties}" } /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdParams.kt index 5421e637c..12dc1f1c6 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdParams.kt @@ -1141,6 +1141,7 @@ private constructor( private constructor( private val autoCollection: JsonField, private val netTerms: JsonField, + private val customDueDate: JsonField, private val invoiceDate: JsonField, private val memo: JsonField, private val requireSuccessfulPayment: JsonField, @@ -1155,6 +1156,9 @@ private constructor( @JsonProperty("net_terms") @ExcludeMissing netTerms: JsonField = JsonMissing.of(), + @JsonProperty("custom_due_date") + @ExcludeMissing + customDueDate: JsonField = JsonMissing.of(), @JsonProperty("invoice_date") @ExcludeMissing invoiceDate: JsonField = JsonMissing.of(), @@ -1167,6 +1171,7 @@ private constructor( ) : this( autoCollection, netTerms, + customDueDate, invoiceDate, memo, requireSuccessfulPayment, @@ -1184,15 +1189,26 @@ private constructor( fun autoCollection(): Boolean = autoCollection.getRequired("auto_collection") /** - * The net terms determines the difference between the invoice date and the issue - * date for the invoice. If you intend the invoice to be due on issue, set this - * to 0. + * The net terms determines the due date of the invoice. Due date is calculated + * based on the invoice or issuance date, depending on the account's configured due + * date calculation method. A value of '0' here represents that the invoice is due + * on issue, whereas a value of '30' represents that the customer has 30 days to pay + * the invoice. Do not set this field if you want to set a custom due date. * * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ fun netTerms(): Long? = netTerms.getNullable("net_terms") + /** + * An optional custom due date for the invoice. If not set, the due date will be + * calculated based on the `net_terms` value. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun customDueDate(): CustomDueDate? = customDueDate.getNullable("custom_due_date") + /** * An ISO 8601 format date that denotes when this invoice should be dated in the * customer's timezone. If not provided, the invoice date will default to the credit @@ -1241,6 +1257,16 @@ private constructor( @ExcludeMissing fun _netTerms(): JsonField = netTerms + /** + * Returns the raw JSON value of [customDueDate]. + * + * Unlike [customDueDate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("custom_due_date") + @ExcludeMissing + fun _customDueDate(): JsonField = customDueDate + /** * Returns the raw JSON value of [invoiceDate]. * @@ -1300,6 +1326,7 @@ private constructor( private var autoCollection: JsonField? = null private var netTerms: JsonField? = null + private var customDueDate: JsonField = JsonMissing.of() private var invoiceDate: JsonField = JsonMissing.of() private var memo: JsonField = JsonMissing.of() private var requireSuccessfulPayment: JsonField = JsonMissing.of() @@ -1308,6 +1335,7 @@ private constructor( internal fun from(invoiceSettings: InvoiceSettings) = apply { autoCollection = invoiceSettings.autoCollection netTerms = invoiceSettings.netTerms + customDueDate = invoiceSettings.customDueDate invoiceDate = invoiceSettings.invoiceDate memo = invoiceSettings.memo requireSuccessfulPayment = invoiceSettings.requireSuccessfulPayment @@ -1333,9 +1361,12 @@ private constructor( } /** - * The net terms determines the difference between the invoice date and the - * issue date for the invoice. If you intend the invoice to be due on issue, set - * this to 0. + * The net terms determines the due date of the invoice. Due date is calculated + * based on the invoice or issuance date, depending on the account's configured + * due date calculation method. A value of '0' here represents that the invoice + * is due on issue, whereas a value of '30' represents that the customer has 30 + * days to pay the invoice. Do not set this field if you want to set a custom + * due date. */ fun netTerms(netTerms: Long?) = netTerms(JsonField.ofNullable(netTerms)) @@ -1355,6 +1386,33 @@ private constructor( */ fun netTerms(netTerms: JsonField) = apply { this.netTerms = netTerms } + /** + * An optional custom due date for the invoice. If not set, the due date will be + * calculated based on the `net_terms` value. + */ + fun customDueDate(customDueDate: CustomDueDate?) = + customDueDate(JsonField.ofNullable(customDueDate)) + + /** + * Sets [Builder.customDueDate] to an arbitrary JSON value. + * + * You should usually call [Builder.customDueDate] with a well-typed + * [CustomDueDate] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun customDueDate(customDueDate: JsonField) = apply { + this.customDueDate = customDueDate + } + + /** Alias for calling [customDueDate] with `CustomDueDate.ofDate(date)`. */ + fun customDueDate(date: LocalDate) = customDueDate(CustomDueDate.ofDate(date)) + + /** + * Alias for calling [customDueDate] with `CustomDueDate.ofDateTime(dateTime)`. + */ + fun customDueDate(dateTime: OffsetDateTime) = + customDueDate(CustomDueDate.ofDateTime(dateTime)) + /** * An ISO 8601 format date that denotes when this invoice should be dated in the * customer's timezone. If not provided, the invoice date will default to the @@ -1451,6 +1509,7 @@ private constructor( InvoiceSettings( checkRequired("autoCollection", autoCollection), checkRequired("netTerms", netTerms), + customDueDate, invoiceDate, memo, requireSuccessfulPayment, @@ -1467,6 +1526,7 @@ private constructor( autoCollection() netTerms() + customDueDate()?.validate() invoiceDate()?.validate() memo() requireSuccessfulPayment() @@ -1490,10 +1550,190 @@ private constructor( internal fun validity(): Int = (if (autoCollection.asKnown() == null) 0 else 1) + (if (netTerms.asKnown() == null) 0 else 1) + + (customDueDate.asKnown()?.validity() ?: 0) + (invoiceDate.asKnown()?.validity() ?: 0) + (if (memo.asKnown() == null) 0 else 1) + (if (requireSuccessfulPayment.asKnown() == null) 0 else 1) + /** + * An optional custom due date for the invoice. If not set, the due date will be + * calculated based on the `net_terms` value. + */ + @JsonDeserialize(using = CustomDueDate.Deserializer::class) + @JsonSerialize(using = CustomDueDate.Serializer::class) + class CustomDueDate + private constructor( + private val date: LocalDate? = null, + private val dateTime: OffsetDateTime? = null, + private val _json: JsonValue? = null, + ) { + + fun date(): LocalDate? = date + + fun dateTime(): OffsetDateTime? = dateTime + + fun isDate(): Boolean = date != null + + fun isDateTime(): Boolean = dateTime != null + + fun asDate(): LocalDate = date.getOrThrow("date") + + fun asDateTime(): OffsetDateTime = dateTime.getOrThrow("dateTime") + + fun _json(): JsonValue? = _json + + fun accept(visitor: Visitor): T = + when { + date != null -> visitor.visitDate(date) + dateTime != null -> visitor.visitDateTime(dateTime) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): CustomDueDate = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitDate(date: LocalDate) {} + + override fun visitDateTime(dateTime: OffsetDateTime) {} + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitDate(date: LocalDate) = 1 + + override fun visitDateTime(dateTime: OffsetDateTime) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CustomDueDate && + date == other.date && + dateTime == other.dateTime + } + + override fun hashCode(): Int = Objects.hash(date, dateTime) + + override fun toString(): String = + when { + date != null -> "CustomDueDate{date=$date}" + dateTime != null -> "CustomDueDate{dateTime=$dateTime}" + _json != null -> "CustomDueDate{_unknown=$_json}" + else -> throw IllegalStateException("Invalid CustomDueDate") + } + + companion object { + + fun ofDate(date: LocalDate) = CustomDueDate(date = date) + + fun ofDateTime(dateTime: OffsetDateTime) = + CustomDueDate(dateTime = dateTime) + } + + /** + * An interface that defines how to map each variant of [CustomDueDate] to a + * value of type [T]. + */ + interface Visitor { + + fun visitDate(date: LocalDate): T + + fun visitDateTime(dateTime: OffsetDateTime): T + + /** + * Maps an unknown variant of [CustomDueDate] to a value of type [T]. + * + * An instance of [CustomDueDate] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For example, + * if the SDK is on an older version than the API, then the API may respond + * with new variants that the SDK is unaware of. + * + * @throws OrbInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw OrbInvalidDataException("Unknown CustomDueDate: $json") + } + } + + internal class Deserializer : + BaseDeserializer(CustomDueDate::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): CustomDueDate { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + CustomDueDate(date = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef()) + ?.let { CustomDueDate(dateTime = it, _json = json) }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely + // incompatible with all the possible variants (e.g. deserializing + // from object). + 0 -> CustomDueDate(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then + // use the first completely valid match, or simply the first match + // if none are completely valid. + else -> + bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : + BaseSerializer(CustomDueDate::class) { + + override fun serialize( + value: CustomDueDate, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.date != null -> generator.writeObject(value.date) + value.dateTime != null -> generator.writeObject(value.dateTime) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid CustomDueDate") + } + } + } + } + /** * An ISO 8601 format date that denotes when this invoice should be dated in the * customer's timezone. If not provided, the invoice date will default to the credit @@ -1680,6 +1920,7 @@ private constructor( return other is InvoiceSettings && autoCollection == other.autoCollection && netTerms == other.netTerms && + customDueDate == other.customDueDate && invoiceDate == other.invoiceDate && memo == other.memo && requireSuccessfulPayment == other.requireSuccessfulPayment && @@ -1690,6 +1931,7 @@ private constructor( Objects.hash( autoCollection, netTerms, + customDueDate, invoiceDate, memo, requireSuccessfulPayment, @@ -1700,7 +1942,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "InvoiceSettings{autoCollection=$autoCollection, netTerms=$netTerms, invoiceDate=$invoiceDate, memo=$memo, requireSuccessfulPayment=$requireSuccessfulPayment, additionalProperties=$additionalProperties}" + "InvoiceSettings{autoCollection=$autoCollection, netTerms=$netTerms, customDueDate=$customDueDate, invoiceDate=$invoiceDate, memo=$memo, requireSuccessfulPayment=$requireSuccessfulPayment, additionalProperties=$additionalProperties}" } /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryParams.kt index 6fbbb9e34..c3cfe9bef 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryParams.kt @@ -1136,6 +1136,7 @@ private constructor( private constructor( private val autoCollection: JsonField, private val netTerms: JsonField, + private val customDueDate: JsonField, private val invoiceDate: JsonField, private val memo: JsonField, private val requireSuccessfulPayment: JsonField, @@ -1150,6 +1151,9 @@ private constructor( @JsonProperty("net_terms") @ExcludeMissing netTerms: JsonField = JsonMissing.of(), + @JsonProperty("custom_due_date") + @ExcludeMissing + customDueDate: JsonField = JsonMissing.of(), @JsonProperty("invoice_date") @ExcludeMissing invoiceDate: JsonField = JsonMissing.of(), @@ -1162,6 +1166,7 @@ private constructor( ) : this( autoCollection, netTerms, + customDueDate, invoiceDate, memo, requireSuccessfulPayment, @@ -1179,15 +1184,26 @@ private constructor( fun autoCollection(): Boolean = autoCollection.getRequired("auto_collection") /** - * The net terms determines the difference between the invoice date and the issue - * date for the invoice. If you intend the invoice to be due on issue, set this - * to 0. + * The net terms determines the due date of the invoice. Due date is calculated + * based on the invoice or issuance date, depending on the account's configured due + * date calculation method. A value of '0' here represents that the invoice is due + * on issue, whereas a value of '30' represents that the customer has 30 days to pay + * the invoice. Do not set this field if you want to set a custom due date. * * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ fun netTerms(): Long? = netTerms.getNullable("net_terms") + /** + * An optional custom due date for the invoice. If not set, the due date will be + * calculated based on the `net_terms` value. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun customDueDate(): CustomDueDate? = customDueDate.getNullable("custom_due_date") + /** * An ISO 8601 format date that denotes when this invoice should be dated in the * customer's timezone. If not provided, the invoice date will default to the credit @@ -1236,6 +1252,16 @@ private constructor( @ExcludeMissing fun _netTerms(): JsonField = netTerms + /** + * Returns the raw JSON value of [customDueDate]. + * + * Unlike [customDueDate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("custom_due_date") + @ExcludeMissing + fun _customDueDate(): JsonField = customDueDate + /** * Returns the raw JSON value of [invoiceDate]. * @@ -1295,6 +1321,7 @@ private constructor( private var autoCollection: JsonField? = null private var netTerms: JsonField? = null + private var customDueDate: JsonField = JsonMissing.of() private var invoiceDate: JsonField = JsonMissing.of() private var memo: JsonField = JsonMissing.of() private var requireSuccessfulPayment: JsonField = JsonMissing.of() @@ -1303,6 +1330,7 @@ private constructor( internal fun from(invoiceSettings: InvoiceSettings) = apply { autoCollection = invoiceSettings.autoCollection netTerms = invoiceSettings.netTerms + customDueDate = invoiceSettings.customDueDate invoiceDate = invoiceSettings.invoiceDate memo = invoiceSettings.memo requireSuccessfulPayment = invoiceSettings.requireSuccessfulPayment @@ -1328,9 +1356,12 @@ private constructor( } /** - * The net terms determines the difference between the invoice date and the - * issue date for the invoice. If you intend the invoice to be due on issue, set - * this to 0. + * The net terms determines the due date of the invoice. Due date is calculated + * based on the invoice or issuance date, depending on the account's configured + * due date calculation method. A value of '0' here represents that the invoice + * is due on issue, whereas a value of '30' represents that the customer has 30 + * days to pay the invoice. Do not set this field if you want to set a custom + * due date. */ fun netTerms(netTerms: Long?) = netTerms(JsonField.ofNullable(netTerms)) @@ -1350,6 +1381,33 @@ private constructor( */ fun netTerms(netTerms: JsonField) = apply { this.netTerms = netTerms } + /** + * An optional custom due date for the invoice. If not set, the due date will be + * calculated based on the `net_terms` value. + */ + fun customDueDate(customDueDate: CustomDueDate?) = + customDueDate(JsonField.ofNullable(customDueDate)) + + /** + * Sets [Builder.customDueDate] to an arbitrary JSON value. + * + * You should usually call [Builder.customDueDate] with a well-typed + * [CustomDueDate] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun customDueDate(customDueDate: JsonField) = apply { + this.customDueDate = customDueDate + } + + /** Alias for calling [customDueDate] with `CustomDueDate.ofDate(date)`. */ + fun customDueDate(date: LocalDate) = customDueDate(CustomDueDate.ofDate(date)) + + /** + * Alias for calling [customDueDate] with `CustomDueDate.ofDateTime(dateTime)`. + */ + fun customDueDate(dateTime: OffsetDateTime) = + customDueDate(CustomDueDate.ofDateTime(dateTime)) + /** * An ISO 8601 format date that denotes when this invoice should be dated in the * customer's timezone. If not provided, the invoice date will default to the @@ -1446,6 +1504,7 @@ private constructor( InvoiceSettings( checkRequired("autoCollection", autoCollection), checkRequired("netTerms", netTerms), + customDueDate, invoiceDate, memo, requireSuccessfulPayment, @@ -1462,6 +1521,7 @@ private constructor( autoCollection() netTerms() + customDueDate()?.validate() invoiceDate()?.validate() memo() requireSuccessfulPayment() @@ -1485,10 +1545,190 @@ private constructor( internal fun validity(): Int = (if (autoCollection.asKnown() == null) 0 else 1) + (if (netTerms.asKnown() == null) 0 else 1) + + (customDueDate.asKnown()?.validity() ?: 0) + (invoiceDate.asKnown()?.validity() ?: 0) + (if (memo.asKnown() == null) 0 else 1) + (if (requireSuccessfulPayment.asKnown() == null) 0 else 1) + /** + * An optional custom due date for the invoice. If not set, the due date will be + * calculated based on the `net_terms` value. + */ + @JsonDeserialize(using = CustomDueDate.Deserializer::class) + @JsonSerialize(using = CustomDueDate.Serializer::class) + class CustomDueDate + private constructor( + private val date: LocalDate? = null, + private val dateTime: OffsetDateTime? = null, + private val _json: JsonValue? = null, + ) { + + fun date(): LocalDate? = date + + fun dateTime(): OffsetDateTime? = dateTime + + fun isDate(): Boolean = date != null + + fun isDateTime(): Boolean = dateTime != null + + fun asDate(): LocalDate = date.getOrThrow("date") + + fun asDateTime(): OffsetDateTime = dateTime.getOrThrow("dateTime") + + fun _json(): JsonValue? = _json + + fun accept(visitor: Visitor): T = + when { + date != null -> visitor.visitDate(date) + dateTime != null -> visitor.visitDateTime(dateTime) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): CustomDueDate = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitDate(date: LocalDate) {} + + override fun visitDateTime(dateTime: OffsetDateTime) {} + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitDate(date: LocalDate) = 1 + + override fun visitDateTime(dateTime: OffsetDateTime) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CustomDueDate && + date == other.date && + dateTime == other.dateTime + } + + override fun hashCode(): Int = Objects.hash(date, dateTime) + + override fun toString(): String = + when { + date != null -> "CustomDueDate{date=$date}" + dateTime != null -> "CustomDueDate{dateTime=$dateTime}" + _json != null -> "CustomDueDate{_unknown=$_json}" + else -> throw IllegalStateException("Invalid CustomDueDate") + } + + companion object { + + fun ofDate(date: LocalDate) = CustomDueDate(date = date) + + fun ofDateTime(dateTime: OffsetDateTime) = + CustomDueDate(dateTime = dateTime) + } + + /** + * An interface that defines how to map each variant of [CustomDueDate] to a + * value of type [T]. + */ + interface Visitor { + + fun visitDate(date: LocalDate): T + + fun visitDateTime(dateTime: OffsetDateTime): T + + /** + * Maps an unknown variant of [CustomDueDate] to a value of type [T]. + * + * An instance of [CustomDueDate] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For example, + * if the SDK is on an older version than the API, then the API may respond + * with new variants that the SDK is unaware of. + * + * @throws OrbInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw OrbInvalidDataException("Unknown CustomDueDate: $json") + } + } + + internal class Deserializer : + BaseDeserializer(CustomDueDate::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): CustomDueDate { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + CustomDueDate(date = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef()) + ?.let { CustomDueDate(dateTime = it, _json = json) }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely + // incompatible with all the possible variants (e.g. deserializing + // from object). + 0 -> CustomDueDate(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then + // use the first completely valid match, or simply the first match + // if none are completely valid. + else -> + bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : + BaseSerializer(CustomDueDate::class) { + + override fun serialize( + value: CustomDueDate, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.date != null -> generator.writeObject(value.date) + value.dateTime != null -> generator.writeObject(value.dateTime) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid CustomDueDate") + } + } + } + } + /** * An ISO 8601 format date that denotes when this invoice should be dated in the * customer's timezone. If not provided, the invoice date will default to the credit @@ -1675,6 +1915,7 @@ private constructor( return other is InvoiceSettings && autoCollection == other.autoCollection && netTerms == other.netTerms && + customDueDate == other.customDueDate && invoiceDate == other.invoiceDate && memo == other.memo && requireSuccessfulPayment == other.requireSuccessfulPayment && @@ -1685,6 +1926,7 @@ private constructor( Objects.hash( autoCollection, netTerms, + customDueDate, invoiceDate, memo, requireSuccessfulPayment, @@ -1695,7 +1937,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "InvoiceSettings{autoCollection=$autoCollection, netTerms=$netTerms, invoiceDate=$invoiceDate, memo=$memo, requireSuccessfulPayment=$requireSuccessfulPayment, additionalProperties=$additionalProperties}" + "InvoiceSettings{autoCollection=$autoCollection, netTerms=$netTerms, customDueDate=$customDueDate, invoiceDate=$invoiceDate, memo=$memo, requireSuccessfulPayment=$requireSuccessfulPayment, additionalProperties=$additionalProperties}" } /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdParams.kt index 7ed1acdbe..8fffec10b 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdParams.kt @@ -66,7 +66,7 @@ import java.util.Objects * * Note that for this entry type, `starting_balance` will equal `ending_balance`, and the `amount` * represents the balance transferred. The credit block linked to the ledger entry is the source - * credit block from which there was an expiration change + * credit block from which there was an expiration change. * * ## Credits expiry * diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListParams.kt index bc2fa9d24..e976557b7 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListParams.kt @@ -66,7 +66,7 @@ import java.util.Objects * * Note that for this entry type, `starting_balance` will equal `ending_balance`, and the `amount` * represents the balance transferred. The credit block linked to the ledger entry is the source - * credit block from which there was an expiration change + * credit block from which there was an expiration change. * * ## Credits expiry * diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerUpdateByExternalIdParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerUpdateByExternalIdParams.kt index db0bb6310..014421728 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerUpdateByExternalIdParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerUpdateByExternalIdParams.kt @@ -71,6 +71,17 @@ private constructor( */ fun autoCollection(): Boolean? = body.autoCollection() + /** + * Used to determine if invoices for this customer will be automatically issued. If true, + * invoices will be automatically issued. If false, invoices will require manual approval.If + * `null` is specified, the customer's auto issuance setting will be inherited from the + * account-level setting. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun autoIssuance(): Boolean? = body.autoIssuance() + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server * responded with an unexpected value). @@ -350,6 +361,13 @@ private constructor( */ fun _autoCollection(): JsonField = body._autoCollection() + /** + * Returns the raw JSON value of [autoIssuance]. + * + * Unlike [autoIssuance], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _autoIssuance(): JsonField = body._autoIssuance() + /** * Returns the raw JSON value of [billingAddress]. * @@ -501,8 +519,8 @@ private constructor( * - [accountingSyncConfiguration] * - [additionalEmails] * - [autoCollection] + * - [autoIssuance] * - [billingAddress] - * - [currency] * - etc. */ fun body(body: Body) = apply { this.body = body.toBuilder() } @@ -575,6 +593,32 @@ private constructor( body.autoCollection(autoCollection) } + /** + * Used to determine if invoices for this customer will be automatically issued. If true, + * invoices will be automatically issued. If false, invoices will require manual approval.If + * `null` is specified, the customer's auto issuance setting will be inherited from the + * account-level setting. + */ + fun autoIssuance(autoIssuance: Boolean?) = apply { body.autoIssuance(autoIssuance) } + + /** + * Alias for [Builder.autoIssuance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun autoIssuance(autoIssuance: Boolean) = autoIssuance(autoIssuance as Boolean?) + + /** + * Sets [Builder.autoIssuance] to an arbitrary JSON value. + * + * You should usually call [Builder.autoIssuance] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun autoIssuance(autoIssuance: JsonField) = apply { + body.autoIssuance(autoIssuance) + } + fun billingAddress(billingAddress: AddressInput?) = apply { body.billingAddress(billingAddress) } @@ -1142,6 +1186,7 @@ private constructor( private val accountingSyncConfiguration: JsonField, private val additionalEmails: JsonField>, private val autoCollection: JsonField, + private val autoIssuance: JsonField, private val billingAddress: JsonField, private val currency: JsonField, private val email: JsonField, @@ -1171,6 +1216,9 @@ private constructor( @JsonProperty("auto_collection") @ExcludeMissing autoCollection: JsonField = JsonMissing.of(), + @JsonProperty("auto_issuance") + @ExcludeMissing + autoIssuance: JsonField = JsonMissing.of(), @JsonProperty("billing_address") @ExcludeMissing billingAddress: JsonField = JsonMissing.of(), @@ -1213,6 +1261,7 @@ private constructor( accountingSyncConfiguration, additionalEmails, autoCollection, + autoIssuance, billingAddress, currency, email, @@ -1256,6 +1305,17 @@ private constructor( */ fun autoCollection(): Boolean? = autoCollection.getNullable("auto_collection") + /** + * Used to determine if invoices for this customer will be automatically issued. If true, + * invoices will be automatically issued. If false, invoices will require manual approval.If + * `null` is specified, the customer's auto issuance setting will be inherited from the + * account-level setting. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun autoIssuance(): Boolean? = autoIssuance.getNullable("auto_issuance") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -1544,6 +1604,16 @@ private constructor( @ExcludeMissing fun _autoCollection(): JsonField = autoCollection + /** + * Returns the raw JSON value of [autoIssuance]. + * + * Unlike [autoIssuance], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("auto_issuance") + @ExcludeMissing + fun _autoIssuance(): JsonField = autoIssuance + /** * Returns the raw JSON value of [billingAddress]. * @@ -1693,6 +1763,7 @@ private constructor( JsonMissing.of() private var additionalEmails: JsonField>? = null private var autoCollection: JsonField = JsonMissing.of() + private var autoIssuance: JsonField = JsonMissing.of() private var billingAddress: JsonField = JsonMissing.of() private var currency: JsonField = JsonMissing.of() private var email: JsonField = JsonMissing.of() @@ -1714,6 +1785,7 @@ private constructor( accountingSyncConfiguration = body.accountingSyncConfiguration additionalEmails = body.additionalEmails.map { it.toMutableList() } autoCollection = body.autoCollection + autoIssuance = body.autoIssuance billingAddress = body.billingAddress currency = body.currency email = body.email @@ -1802,6 +1874,33 @@ private constructor( this.autoCollection = autoCollection } + /** + * Used to determine if invoices for this customer will be automatically issued. If + * true, invoices will be automatically issued. If false, invoices will require manual + * approval.If `null` is specified, the customer's auto issuance setting will be + * inherited from the account-level setting. + */ + fun autoIssuance(autoIssuance: Boolean?) = + autoIssuance(JsonField.ofNullable(autoIssuance)) + + /** + * Alias for [Builder.autoIssuance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun autoIssuance(autoIssuance: Boolean) = autoIssuance(autoIssuance as Boolean?) + + /** + * Sets [Builder.autoIssuance] to an arbitrary JSON value. + * + * You should usually call [Builder.autoIssuance] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun autoIssuance(autoIssuance: JsonField) = apply { + this.autoIssuance = autoIssuance + } + fun billingAddress(billingAddress: AddressInput?) = billingAddress(JsonField.ofNullable(billingAddress)) @@ -2257,6 +2356,7 @@ private constructor( accountingSyncConfiguration, (additionalEmails ?: JsonMissing.of()).map { it.toImmutable() }, autoCollection, + autoIssuance, billingAddress, currency, email, @@ -2285,6 +2385,7 @@ private constructor( accountingSyncConfiguration()?.validate() additionalEmails() autoCollection() + autoIssuance() billingAddress()?.validate() currency() email() @@ -2320,6 +2421,7 @@ private constructor( (accountingSyncConfiguration.asKnown()?.validity() ?: 0) + (additionalEmails.asKnown()?.size ?: 0) + (if (autoCollection.asKnown() == null) 0 else 1) + + (if (autoIssuance.asKnown() == null) 0 else 1) + (billingAddress.asKnown()?.validity() ?: 0) + (if (currency.asKnown() == null) 0 else 1) + (if (email.asKnown() == null) 0 else 1) + @@ -2344,6 +2446,7 @@ private constructor( accountingSyncConfiguration == other.accountingSyncConfiguration && additionalEmails == other.additionalEmails && autoCollection == other.autoCollection && + autoIssuance == other.autoIssuance && billingAddress == other.billingAddress && currency == other.currency && email == other.email && @@ -2366,6 +2469,7 @@ private constructor( accountingSyncConfiguration, additionalEmails, autoCollection, + autoIssuance, billingAddress, currency, email, @@ -2387,7 +2491,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Body{accountingSyncConfiguration=$accountingSyncConfiguration, additionalEmails=$additionalEmails, autoCollection=$autoCollection, billingAddress=$billingAddress, currency=$currency, email=$email, emailDelivery=$emailDelivery, externalCustomerId=$externalCustomerId, hierarchy=$hierarchy, metadata=$metadata, name=$name, paymentProvider=$paymentProvider, paymentProviderId=$paymentProviderId, reportingConfiguration=$reportingConfiguration, shippingAddress=$shippingAddress, taxConfiguration=$taxConfiguration, taxId=$taxId, additionalProperties=$additionalProperties}" + "Body{accountingSyncConfiguration=$accountingSyncConfiguration, additionalEmails=$additionalEmails, autoCollection=$autoCollection, autoIssuance=$autoIssuance, billingAddress=$billingAddress, currency=$currency, email=$email, emailDelivery=$emailDelivery, externalCustomerId=$externalCustomerId, hierarchy=$hierarchy, metadata=$metadata, name=$name, paymentProvider=$paymentProvider, paymentProviderId=$paymentProviderId, reportingConfiguration=$reportingConfiguration, shippingAddress=$shippingAddress, taxConfiguration=$taxConfiguration, taxId=$taxId, additionalProperties=$additionalProperties}" } /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerUpdateParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerUpdateParams.kt index a13046ffd..52b8cd556 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerUpdateParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerUpdateParams.kt @@ -72,6 +72,17 @@ private constructor( */ fun autoCollection(): Boolean? = body.autoCollection() + /** + * Used to determine if invoices for this customer will be automatically issued. If true, + * invoices will be automatically issued. If false, invoices will require manual approval.If + * `null` is specified, the customer's auto issuance setting will be inherited from the + * account-level setting. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun autoIssuance(): Boolean? = body.autoIssuance() + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server * responded with an unexpected value). @@ -351,6 +362,13 @@ private constructor( */ fun _autoCollection(): JsonField = body._autoCollection() + /** + * Returns the raw JSON value of [autoIssuance]. + * + * Unlike [autoIssuance], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _autoIssuance(): JsonField = body._autoIssuance() + /** * Returns the raw JSON value of [billingAddress]. * @@ -497,8 +515,8 @@ private constructor( * - [accountingSyncConfiguration] * - [additionalEmails] * - [autoCollection] + * - [autoIssuance] * - [billingAddress] - * - [currency] * - etc. */ fun body(body: Body) = apply { this.body = body.toBuilder() } @@ -571,6 +589,32 @@ private constructor( body.autoCollection(autoCollection) } + /** + * Used to determine if invoices for this customer will be automatically issued. If true, + * invoices will be automatically issued. If false, invoices will require manual approval.If + * `null` is specified, the customer's auto issuance setting will be inherited from the + * account-level setting. + */ + fun autoIssuance(autoIssuance: Boolean?) = apply { body.autoIssuance(autoIssuance) } + + /** + * Alias for [Builder.autoIssuance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun autoIssuance(autoIssuance: Boolean) = autoIssuance(autoIssuance as Boolean?) + + /** + * Sets [Builder.autoIssuance] to an arbitrary JSON value. + * + * You should usually call [Builder.autoIssuance] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun autoIssuance(autoIssuance: JsonField) = apply { + body.autoIssuance(autoIssuance) + } + fun billingAddress(billingAddress: AddressInput?) = apply { body.billingAddress(billingAddress) } @@ -1138,6 +1182,7 @@ private constructor( private val accountingSyncConfiguration: JsonField, private val additionalEmails: JsonField>, private val autoCollection: JsonField, + private val autoIssuance: JsonField, private val billingAddress: JsonField, private val currency: JsonField, private val email: JsonField, @@ -1167,6 +1212,9 @@ private constructor( @JsonProperty("auto_collection") @ExcludeMissing autoCollection: JsonField = JsonMissing.of(), + @JsonProperty("auto_issuance") + @ExcludeMissing + autoIssuance: JsonField = JsonMissing.of(), @JsonProperty("billing_address") @ExcludeMissing billingAddress: JsonField = JsonMissing.of(), @@ -1209,6 +1257,7 @@ private constructor( accountingSyncConfiguration, additionalEmails, autoCollection, + autoIssuance, billingAddress, currency, email, @@ -1252,6 +1301,17 @@ private constructor( */ fun autoCollection(): Boolean? = autoCollection.getNullable("auto_collection") + /** + * Used to determine if invoices for this customer will be automatically issued. If true, + * invoices will be automatically issued. If false, invoices will require manual approval.If + * `null` is specified, the customer's auto issuance setting will be inherited from the + * account-level setting. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun autoIssuance(): Boolean? = autoIssuance.getNullable("auto_issuance") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -1540,6 +1600,16 @@ private constructor( @ExcludeMissing fun _autoCollection(): JsonField = autoCollection + /** + * Returns the raw JSON value of [autoIssuance]. + * + * Unlike [autoIssuance], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("auto_issuance") + @ExcludeMissing + fun _autoIssuance(): JsonField = autoIssuance + /** * Returns the raw JSON value of [billingAddress]. * @@ -1689,6 +1759,7 @@ private constructor( JsonMissing.of() private var additionalEmails: JsonField>? = null private var autoCollection: JsonField = JsonMissing.of() + private var autoIssuance: JsonField = JsonMissing.of() private var billingAddress: JsonField = JsonMissing.of() private var currency: JsonField = JsonMissing.of() private var email: JsonField = JsonMissing.of() @@ -1710,6 +1781,7 @@ private constructor( accountingSyncConfiguration = body.accountingSyncConfiguration additionalEmails = body.additionalEmails.map { it.toMutableList() } autoCollection = body.autoCollection + autoIssuance = body.autoIssuance billingAddress = body.billingAddress currency = body.currency email = body.email @@ -1798,6 +1870,33 @@ private constructor( this.autoCollection = autoCollection } + /** + * Used to determine if invoices for this customer will be automatically issued. If + * true, invoices will be automatically issued. If false, invoices will require manual + * approval.If `null` is specified, the customer's auto issuance setting will be + * inherited from the account-level setting. + */ + fun autoIssuance(autoIssuance: Boolean?) = + autoIssuance(JsonField.ofNullable(autoIssuance)) + + /** + * Alias for [Builder.autoIssuance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun autoIssuance(autoIssuance: Boolean) = autoIssuance(autoIssuance as Boolean?) + + /** + * Sets [Builder.autoIssuance] to an arbitrary JSON value. + * + * You should usually call [Builder.autoIssuance] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun autoIssuance(autoIssuance: JsonField) = apply { + this.autoIssuance = autoIssuance + } + fun billingAddress(billingAddress: AddressInput?) = billingAddress(JsonField.ofNullable(billingAddress)) @@ -2253,6 +2352,7 @@ private constructor( accountingSyncConfiguration, (additionalEmails ?: JsonMissing.of()).map { it.toImmutable() }, autoCollection, + autoIssuance, billingAddress, currency, email, @@ -2281,6 +2381,7 @@ private constructor( accountingSyncConfiguration()?.validate() additionalEmails() autoCollection() + autoIssuance() billingAddress()?.validate() currency() email() @@ -2316,6 +2417,7 @@ private constructor( (accountingSyncConfiguration.asKnown()?.validity() ?: 0) + (additionalEmails.asKnown()?.size ?: 0) + (if (autoCollection.asKnown() == null) 0 else 1) + + (if (autoIssuance.asKnown() == null) 0 else 1) + (billingAddress.asKnown()?.validity() ?: 0) + (if (currency.asKnown() == null) 0 else 1) + (if (email.asKnown() == null) 0 else 1) + @@ -2340,6 +2442,7 @@ private constructor( accountingSyncConfiguration == other.accountingSyncConfiguration && additionalEmails == other.additionalEmails && autoCollection == other.autoCollection && + autoIssuance == other.autoIssuance && billingAddress == other.billingAddress && currency == other.currency && email == other.email && @@ -2362,6 +2465,7 @@ private constructor( accountingSyncConfiguration, additionalEmails, autoCollection, + autoIssuance, billingAddress, currency, email, @@ -2383,7 +2487,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Body{accountingSyncConfiguration=$accountingSyncConfiguration, additionalEmails=$additionalEmails, autoCollection=$autoCollection, billingAddress=$billingAddress, currency=$currency, email=$email, emailDelivery=$emailDelivery, externalCustomerId=$externalCustomerId, hierarchy=$hierarchy, metadata=$metadata, name=$name, paymentProvider=$paymentProvider, paymentProviderId=$paymentProviderId, reportingConfiguration=$reportingConfiguration, shippingAddress=$shippingAddress, taxConfiguration=$taxConfiguration, taxId=$taxId, additionalProperties=$additionalProperties}" + "Body{accountingSyncConfiguration=$accountingSyncConfiguration, additionalEmails=$additionalEmails, autoCollection=$autoCollection, autoIssuance=$autoIssuance, billingAddress=$billingAddress, currency=$currency, email=$email, emailDelivery=$emailDelivery, externalCustomerId=$externalCustomerId, hierarchy=$hierarchy, metadata=$metadata, name=$name, paymentProvider=$paymentProvider, paymentProviderId=$paymentProviderId, reportingConfiguration=$reportingConfiguration, shippingAddress=$shippingAddress, taxConfiguration=$taxConfiguration, taxId=$taxId, additionalProperties=$additionalProperties}" } /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroupCreateParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroupCreateParams.kt index 78c7b70e0..981b62372 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroupCreateParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroupCreateParams.kt @@ -22,7 +22,7 @@ import java.util.Objects /** * A dimensional price group is used to partition the result of a billable metric by a set of - * dimensions. Prices in a price group must specify the parition used to derive their usage. + * dimensions. Prices in a price group must specify the partition used to derive their usage. * * For example, suppose we have a billable metric that measures the number of widgets used and we * want to charge differently depending on the color of the widget. We can create a price group with diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventBackfillCreateParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventBackfillCreateParams.kt index 589bb587c..a27f555ed 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventBackfillCreateParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventBackfillCreateParams.kt @@ -43,8 +43,8 @@ import java.util.Objects * for that customer. If neither is specified, the backfill will affect all customers. * * When `replace_existing_events` is `true`, this indicates that existing events in the timeframe - * should no longer be counted towards invoiced usage. In this scenario, the parameter `filter` can - * be optionally added which enables filtering using + * should no longer be counted towards invoiced usage. In this scenario, the parameter + * `deprecation_filter` can be optionally added which enables filtering using * [computed properties](/extensibility/advanced-metrics#computed-properties). The expressiveness of * computed properties allows you to deprecate existing events based on both a period of time and * specific property values. diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Invoice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Invoice.kt index 1471b9d15..b23046bd3 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Invoice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Invoice.kt @@ -3501,6 +3501,8 @@ private constructor( val EXTERNAL_PAYMENT = of("external_payment") + val SMALL_INVOICE_CARRYOVER = of("small_invoice_carryover") + fun of(value: String) = Action(JsonField.of(value)) } @@ -3515,6 +3517,7 @@ private constructor( CREDIT_NOTE_VOIDED, OVERPAYMENT_REFUND, EXTERNAL_PAYMENT, + SMALL_INVOICE_CARRYOVER, } /** @@ -3536,6 +3539,7 @@ private constructor( CREDIT_NOTE_VOIDED, OVERPAYMENT_REFUND, EXTERNAL_PAYMENT, + SMALL_INVOICE_CARRYOVER, /** * An enum member indicating that [Action] was instantiated with an unknown value. */ @@ -3560,6 +3564,7 @@ private constructor( CREDIT_NOTE_VOIDED -> Value.CREDIT_NOTE_VOIDED OVERPAYMENT_REFUND -> Value.OVERPAYMENT_REFUND EXTERNAL_PAYMENT -> Value.EXTERNAL_PAYMENT + SMALL_INVOICE_CARRYOVER -> Value.SMALL_INVOICE_CARRYOVER else -> Value._UNKNOWN } @@ -3583,6 +3588,7 @@ private constructor( CREDIT_NOTE_VOIDED -> Known.CREDIT_NOTE_VOIDED OVERPAYMENT_REFUND -> Known.OVERPAYMENT_REFUND EXTERNAL_PAYMENT -> Known.EXTERNAL_PAYMENT + SMALL_INVOICE_CARRYOVER -> Known.SMALL_INVOICE_CARRYOVER else -> throw OrbInvalidDataException("Unknown Action: $value") } @@ -4217,7 +4223,7 @@ private constructor( fun subLineItems(): List = subLineItems.getRequired("sub_line_items") /** - * The line amount before before any adjustments. + * The line amount before any adjustments. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). @@ -4900,15 +4906,6 @@ private constructor( /** Alias for calling [price] with `Price.ofTiered(tiered)`. */ fun price(tiered: Price.Tiered) = price(Price.ofTiered(tiered)) - /** Alias for calling [price] with `Price.ofTieredBps(tieredBps)`. */ - fun price(tieredBps: Price.TieredBps) = price(Price.ofTieredBps(tieredBps)) - - /** Alias for calling [price] with `Price.ofBps(bps)`. */ - fun price(bps: Price.Bps) = price(Price.ofBps(bps)) - - /** Alias for calling [price] with `Price.ofBulkBps(bulkBps)`. */ - fun price(bulkBps: Price.BulkBps) = price(Price.ofBulkBps(bulkBps)) - /** Alias for calling [price] with `Price.ofBulk(bulk)`. */ fun price(bulk: Price.Bulk) = price(Price.ofBulk(bulk)) @@ -5034,6 +5031,9 @@ private constructor( fun price(groupedWithMinMaxThresholds: Price.GroupedWithMinMaxThresholds) = price(Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)) + /** Alias for calling [price] with `Price.ofMinimum(minimum)`. */ + fun price(minimum: Price.Minimum) = price(Price.ofMinimum(minimum)) + /** Either the fixed fee quantity or the usage during the service period. */ fun quantity(quantity: Double) = quantity(JsonField.of(quantity)) @@ -5100,7 +5100,7 @@ private constructor( /** Alias for calling [addSubLineItem] with `SubLineItem.ofNull(null_)`. */ fun addSubLineItem(null_: OtherSubLineItem) = addSubLineItem(SubLineItem.ofNull(null_)) - /** The line amount before before any adjustments. */ + /** The line amount before any adjustments. */ fun subtotal(subtotal: String) = subtotal(JsonField.of(subtotal)) /** @@ -5967,6 +5967,7 @@ private constructor( private val createdAt: JsonField, private val paymentProvider: JsonField, private val paymentProviderId: JsonField, + private val receiptPdf: JsonField, private val succeeded: JsonField, private val additionalProperties: MutableMap, ) { @@ -5984,6 +5985,9 @@ private constructor( @JsonProperty("payment_provider_id") @ExcludeMissing paymentProviderId: JsonField = JsonMissing.of(), + @JsonProperty("receipt_pdf") + @ExcludeMissing + receiptPdf: JsonField = JsonMissing.of(), @JsonProperty("succeeded") @ExcludeMissing succeeded: JsonField = JsonMissing.of(), @@ -5993,6 +5997,7 @@ private constructor( createdAt, paymentProvider, paymentProviderId, + receiptPdf, succeeded, mutableMapOf(), ) @@ -6037,6 +6042,15 @@ private constructor( */ fun paymentProviderId(): String? = paymentProviderId.getNullable("payment_provider_id") + /** + * URL to the downloadable PDF version of the receipt. This field will be `null` for payment + * attempts that did not succeed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun receiptPdf(): String? = receiptPdf.getNullable("receipt_pdf") + /** * Whether the payment attempt succeeded. * @@ -6088,6 +6102,15 @@ private constructor( @ExcludeMissing fun _paymentProviderId(): JsonField = paymentProviderId + /** + * Returns the raw JSON value of [receiptPdf]. + * + * Unlike [receiptPdf], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("receipt_pdf") + @ExcludeMissing + fun _receiptPdf(): JsonField = receiptPdf + /** * Returns the raw JSON value of [succeeded]. * @@ -6119,6 +6142,7 @@ private constructor( * .createdAt() * .paymentProvider() * .paymentProviderId() + * .receiptPdf() * .succeeded() * ``` */ @@ -6133,6 +6157,7 @@ private constructor( private var createdAt: JsonField? = null private var paymentProvider: JsonField? = null private var paymentProviderId: JsonField? = null + private var receiptPdf: JsonField? = null private var succeeded: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -6142,6 +6167,7 @@ private constructor( createdAt = paymentAttempt.createdAt paymentProvider = paymentAttempt.paymentProvider paymentProviderId = paymentAttempt.paymentProviderId + receiptPdf = paymentAttempt.receiptPdf succeeded = paymentAttempt.succeeded additionalProperties = paymentAttempt.additionalProperties.toMutableMap() } @@ -6214,6 +6240,21 @@ private constructor( this.paymentProviderId = paymentProviderId } + /** + * URL to the downloadable PDF version of the receipt. This field will be `null` for + * payment attempts that did not succeed. + */ + fun receiptPdf(receiptPdf: String?) = receiptPdf(JsonField.ofNullable(receiptPdf)) + + /** + * Sets [Builder.receiptPdf] to an arbitrary JSON value. + * + * You should usually call [Builder.receiptPdf] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun receiptPdf(receiptPdf: JsonField) = apply { this.receiptPdf = receiptPdf } + /** Whether the payment attempt succeeded. */ fun succeeded(succeeded: Boolean) = succeeded(JsonField.of(succeeded)) @@ -6257,6 +6298,7 @@ private constructor( * .createdAt() * .paymentProvider() * .paymentProviderId() + * .receiptPdf() * .succeeded() * ``` * @@ -6269,6 +6311,7 @@ private constructor( checkRequired("createdAt", createdAt), checkRequired("paymentProvider", paymentProvider), checkRequired("paymentProviderId", paymentProviderId), + checkRequired("receiptPdf", receiptPdf), checkRequired("succeeded", succeeded), additionalProperties.toMutableMap(), ) @@ -6286,6 +6329,7 @@ private constructor( createdAt() paymentProvider()?.validate() paymentProviderId() + receiptPdf() succeeded() validated = true } @@ -6310,6 +6354,7 @@ private constructor( (if (createdAt.asKnown() == null) 0 else 1) + (paymentProvider.asKnown()?.validity() ?: 0) + (if (paymentProviderId.asKnown() == null) 0 else 1) + + (if (receiptPdf.asKnown() == null) 0 else 1) + (if (succeeded.asKnown() == null) 0 else 1) /** The payment provider that attempted to collect the payment. */ @@ -6448,6 +6493,7 @@ private constructor( createdAt == other.createdAt && paymentProvider == other.paymentProvider && paymentProviderId == other.paymentProviderId && + receiptPdf == other.receiptPdf && succeeded == other.succeeded && additionalProperties == other.additionalProperties } @@ -6459,6 +6505,7 @@ private constructor( createdAt, paymentProvider, paymentProviderId, + receiptPdf, succeeded, additionalProperties, ) @@ -6467,7 +6514,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "PaymentAttempt{id=$id, amount=$amount, createdAt=$createdAt, paymentProvider=$paymentProvider, paymentProviderId=$paymentProviderId, succeeded=$succeeded, additionalProperties=$additionalProperties}" + "PaymentAttempt{id=$id, amount=$amount, createdAt=$createdAt, paymentProvider=$paymentProvider, paymentProviderId=$paymentProviderId, receiptPdf=$receiptPdf, succeeded=$succeeded, additionalProperties=$additionalProperties}" } class Status @JsonCreator private constructor(private val value: JsonField) : Enum { diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceCreateParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceCreateParams.kt index 5dfacfffa..7d666218b 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceCreateParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceCreateParams.kt @@ -6,14 +6,25 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.withorb.api.core.BaseDeserializer +import com.withorb.api.core.BaseSerializer import com.withorb.api.core.Enum import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.Params +import com.withorb.api.core.allMaxBy import com.withorb.api.core.checkKnown import com.withorb.api.core.checkRequired +import com.withorb.api.core.getOrThrow import com.withorb.api.core.http.Headers import com.withorb.api.core.http.QueryParams import com.withorb.api.core.toImmutable @@ -71,6 +82,15 @@ private constructor( */ fun discount(): Discount? = body.discount() + /** + * An optional custom due date for the invoice. If not set, the due date will be calculated + * based on the `net_terms` value. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun dueDate(): DueDate? = body.dueDate() + /** * The `external_customer_id` of the `Customer` to create this invoice for. One of `customer_id` * and `external_customer_id` are required. @@ -81,7 +101,8 @@ private constructor( fun externalCustomerId(): String? = body.externalCustomerId() /** - * An optional memo to attach to the invoice. + * An optional memo to attach to the invoice. If no memo is provided, we will attach the default + * memo * * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server * responded with an unexpected value). @@ -99,9 +120,11 @@ private constructor( fun metadata(): Metadata? = body.metadata() /** - * Determines the difference between the invoice issue date for subscription invoices as the - * date that they are due. A value of '0' here represents that the invoice is due on issue, - * whereas a value of 30 represents that the customer has 30 days to pay the invoice. + * The net terms determines the due date of the invoice. Due date is calculated based on the + * invoice or issuance date, depending on the account's configured due date calculation method. + * A value of '0' here represents that the invoice is due on issue, whereas a value of '30' + * represents that the customer has 30 days to pay the invoice. Do not set this field if you + * want to set a custom due date. * * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server * responded with an unexpected value). @@ -152,6 +175,13 @@ private constructor( */ fun _discount(): JsonField = body._discount() + /** + * Returns the raw JSON value of [dueDate]. + * + * Unlike [dueDate], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _dueDate(): JsonField = body._dueDate() + /** * Returns the raw JSON value of [externalCustomerId]. * @@ -362,6 +392,26 @@ private constructor( */ fun amountDiscount(amountDiscount: String) = apply { body.amountDiscount(amountDiscount) } + /** + * An optional custom due date for the invoice. If not set, the due date will be calculated + * based on the `net_terms` value. + */ + fun dueDate(dueDate: DueDate?) = apply { body.dueDate(dueDate) } + + /** + * Sets [Builder.dueDate] to an arbitrary JSON value. + * + * You should usually call [Builder.dueDate] with a well-typed [DueDate] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun dueDate(dueDate: JsonField) = apply { body.dueDate(dueDate) } + + /** Alias for calling [dueDate] with `DueDate.ofDate(date)`. */ + fun dueDate(date: LocalDate) = apply { body.dueDate(date) } + + /** Alias for calling [dueDate] with `DueDate.ofDateTime(dateTime)`. */ + fun dueDate(dateTime: OffsetDateTime) = apply { body.dueDate(dateTime) } + /** * The `external_customer_id` of the `Customer` to create this invoice for. One of * `customer_id` and `external_customer_id` are required. @@ -381,7 +431,10 @@ private constructor( body.externalCustomerId(externalCustomerId) } - /** An optional memo to attach to the invoice. */ + /** + * An optional memo to attach to the invoice. If no memo is provided, we will attach the + * default memo + */ fun memo(memo: String?) = apply { body.memo(memo) } /** @@ -409,9 +462,11 @@ private constructor( fun metadata(metadata: JsonField) = apply { body.metadata(metadata) } /** - * Determines the difference between the invoice issue date for subscription invoices as the - * date that they are due. A value of '0' here represents that the invoice is due on issue, - * whereas a value of 30 represents that the customer has 30 days to pay the invoice. + * The net terms determines the due date of the invoice. Due date is calculated based on the + * invoice or issuance date, depending on the account's configured due date calculation + * method. A value of '0' here represents that the invoice is due on issue, whereas a value + * of '30' represents that the customer has 30 days to pay the invoice. Do not set this + * field if you want to set a custom due date. */ fun netTerms(netTerms: Long?) = apply { body.netTerms(netTerms) } @@ -599,6 +654,7 @@ private constructor( private val lineItems: JsonField>, private val customerId: JsonField, private val discount: JsonField, + private val dueDate: JsonField, private val externalCustomerId: JsonField, private val memo: JsonField, private val metadata: JsonField, @@ -624,6 +680,9 @@ private constructor( @JsonProperty("discount") @ExcludeMissing discount: JsonField = JsonMissing.of(), + @JsonProperty("due_date") + @ExcludeMissing + dueDate: JsonField = JsonMissing.of(), @JsonProperty("external_customer_id") @ExcludeMissing externalCustomerId: JsonField = JsonMissing.of(), @@ -641,6 +700,7 @@ private constructor( lineItems, customerId, discount, + dueDate, externalCustomerId, memo, metadata, @@ -689,6 +749,15 @@ private constructor( */ fun discount(): Discount? = discount.getNullable("discount") + /** + * An optional custom due date for the invoice. If not set, the due date will be calculated + * based on the `net_terms` value. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun dueDate(): DueDate? = dueDate.getNullable("due_date") + /** * The `external_customer_id` of the `Customer` to create this invoice for. One of * `customer_id` and `external_customer_id` are required. @@ -699,7 +768,8 @@ private constructor( fun externalCustomerId(): String? = externalCustomerId.getNullable("external_customer_id") /** - * An optional memo to attach to the invoice. + * An optional memo to attach to the invoice. If no memo is provided, we will attach the + * default memo * * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -717,9 +787,11 @@ private constructor( fun metadata(): Metadata? = metadata.getNullable("metadata") /** - * Determines the difference between the invoice issue date for subscription invoices as the - * date that they are due. A value of '0' here represents that the invoice is due on issue, - * whereas a value of 30 represents that the customer has 30 days to pay the invoice. + * The net terms determines the due date of the invoice. Due date is calculated based on the + * invoice or issuance date, depending on the account's configured due date calculation + * method. A value of '0' here represents that the invoice is due on issue, whereas a value + * of '30' represents that the customer has 30 days to pay the invoice. Do not set this + * field if you want to set a custom due date. * * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -776,6 +848,13 @@ private constructor( */ @JsonProperty("discount") @ExcludeMissing fun _discount(): JsonField = discount + /** + * Returns the raw JSON value of [dueDate]. + * + * Unlike [dueDate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("due_date") @ExcludeMissing fun _dueDate(): JsonField = dueDate + /** * Returns the raw JSON value of [externalCustomerId]. * @@ -852,6 +931,7 @@ private constructor( private var lineItems: JsonField>? = null private var customerId: JsonField = JsonMissing.of() private var discount: JsonField = JsonMissing.of() + private var dueDate: JsonField = JsonMissing.of() private var externalCustomerId: JsonField = JsonMissing.of() private var memo: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() @@ -865,6 +945,7 @@ private constructor( lineItems = body.lineItems.map { it.toMutableList() } customerId = body.customerId discount = body.discount + dueDate = body.dueDate externalCustomerId = body.externalCustomerId memo = body.memo metadata = body.metadata @@ -1021,6 +1102,27 @@ private constructor( .build() ) + /** + * An optional custom due date for the invoice. If not set, the due date will be + * calculated based on the `net_terms` value. + */ + fun dueDate(dueDate: DueDate?) = dueDate(JsonField.ofNullable(dueDate)) + + /** + * Sets [Builder.dueDate] to an arbitrary JSON value. + * + * You should usually call [Builder.dueDate] with a well-typed [DueDate] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun dueDate(dueDate: JsonField) = apply { this.dueDate = dueDate } + + /** Alias for calling [dueDate] with `DueDate.ofDate(date)`. */ + fun dueDate(date: LocalDate) = dueDate(DueDate.ofDate(date)) + + /** Alias for calling [dueDate] with `DueDate.ofDateTime(dateTime)`. */ + fun dueDate(dateTime: OffsetDateTime) = dueDate(DueDate.ofDateTime(dateTime)) + /** * The `external_customer_id` of the `Customer` to create this invoice for. One of * `customer_id` and `external_customer_id` are required. @@ -1039,7 +1141,10 @@ private constructor( this.externalCustomerId = externalCustomerId } - /** An optional memo to attach to the invoice. */ + /** + * An optional memo to attach to the invoice. If no memo is provided, we will attach the + * default memo + */ fun memo(memo: String?) = memo(JsonField.ofNullable(memo)) /** @@ -1068,10 +1173,11 @@ private constructor( fun metadata(metadata: JsonField) = apply { this.metadata = metadata } /** - * Determines the difference between the invoice issue date for subscription invoices as - * the date that they are due. A value of '0' here represents that the invoice is due on - * issue, whereas a value of 30 represents that the customer has 30 days to pay the - * invoice. + * The net terms determines the due date of the invoice. Due date is calculated based on + * the invoice or issuance date, depending on the account's configured due date + * calculation method. A value of '0' here represents that the invoice is due on issue, + * whereas a value of '30' represents that the customer has 30 days to pay the invoice. + * Do not set this field if you want to set a custom due date. */ fun netTerms(netTerms: Long?) = netTerms(JsonField.ofNullable(netTerms)) @@ -1148,6 +1254,7 @@ private constructor( checkRequired("lineItems", lineItems).map { it.toImmutable() }, customerId, discount, + dueDate, externalCustomerId, memo, metadata, @@ -1169,6 +1276,7 @@ private constructor( lineItems().forEach { it.validate() } customerId() discount()?.validate() + dueDate()?.validate() externalCustomerId() memo() metadata()?.validate() @@ -1197,6 +1305,7 @@ private constructor( (lineItems.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + (if (customerId.asKnown() == null) 0 else 1) + (discount.asKnown()?.validity() ?: 0) + + (dueDate.asKnown()?.validity() ?: 0) + (if (externalCustomerId.asKnown() == null) 0 else 1) + (if (memo.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) + @@ -1214,6 +1323,7 @@ private constructor( lineItems == other.lineItems && customerId == other.customerId && discount == other.discount && + dueDate == other.dueDate && externalCustomerId == other.externalCustomerId && memo == other.memo && metadata == other.metadata && @@ -1229,6 +1339,7 @@ private constructor( lineItems, customerId, discount, + dueDate, externalCustomerId, memo, metadata, @@ -1241,7 +1352,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Body{currency=$currency, invoiceDate=$invoiceDate, lineItems=$lineItems, customerId=$customerId, discount=$discount, externalCustomerId=$externalCustomerId, memo=$memo, metadata=$metadata, netTerms=$netTerms, willAutoIssue=$willAutoIssue, additionalProperties=$additionalProperties}" + "Body{currency=$currency, invoiceDate=$invoiceDate, lineItems=$lineItems, customerId=$customerId, discount=$discount, dueDate=$dueDate, externalCustomerId=$externalCustomerId, memo=$memo, metadata=$metadata, netTerms=$netTerms, willAutoIssue=$willAutoIssue, additionalProperties=$additionalProperties}" } class LineItem @@ -1767,6 +1878,178 @@ private constructor( "LineItem{endDate=$endDate, itemId=$itemId, modelType=$modelType, name=$name, quantity=$quantity, startDate=$startDate, unitConfig=$unitConfig, additionalProperties=$additionalProperties}" } + /** + * An optional custom due date for the invoice. If not set, the due date will be calculated + * based on the `net_terms` value. + */ + @JsonDeserialize(using = DueDate.Deserializer::class) + @JsonSerialize(using = DueDate.Serializer::class) + class DueDate + private constructor( + private val date: LocalDate? = null, + private val dateTime: OffsetDateTime? = null, + private val _json: JsonValue? = null, + ) { + + fun date(): LocalDate? = date + + fun dateTime(): OffsetDateTime? = dateTime + + fun isDate(): Boolean = date != null + + fun isDateTime(): Boolean = dateTime != null + + fun asDate(): LocalDate = date.getOrThrow("date") + + fun asDateTime(): OffsetDateTime = dateTime.getOrThrow("dateTime") + + fun _json(): JsonValue? = _json + + fun accept(visitor: Visitor): T = + when { + date != null -> visitor.visitDate(date) + dateTime != null -> visitor.visitDateTime(dateTime) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): DueDate = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitDate(date: LocalDate) {} + + override fun visitDateTime(dateTime: OffsetDateTime) {} + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitDate(date: LocalDate) = 1 + + override fun visitDateTime(dateTime: OffsetDateTime) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is DueDate && date == other.date && dateTime == other.dateTime + } + + override fun hashCode(): Int = Objects.hash(date, dateTime) + + override fun toString(): String = + when { + date != null -> "DueDate{date=$date}" + dateTime != null -> "DueDate{dateTime=$dateTime}" + _json != null -> "DueDate{_unknown=$_json}" + else -> throw IllegalStateException("Invalid DueDate") + } + + companion object { + + fun ofDate(date: LocalDate) = DueDate(date = date) + + fun ofDateTime(dateTime: OffsetDateTime) = DueDate(dateTime = dateTime) + } + + /** + * An interface that defines how to map each variant of [DueDate] to a value of type [T]. + */ + interface Visitor { + + fun visitDate(date: LocalDate): T + + fun visitDateTime(dateTime: OffsetDateTime): T + + /** + * Maps an unknown variant of [DueDate] to a value of type [T]. + * + * An instance of [DueDate] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is + * unaware of. + * + * @throws OrbInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw OrbInvalidDataException("Unknown DueDate: $json") + } + } + + internal class Deserializer : BaseDeserializer(DueDate::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): DueDate { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + DueDate(date = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + DueDate(dateTime = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with + // all the possible variants (e.g. deserializing from object). + 0 -> DueDate(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely + // valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(DueDate::class) { + + override fun serialize( + value: DueDate, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.date != null -> generator.writeObject(value.date) + value.dateTime != null -> generator.writeObject(value.dateTime) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid DueDate") + } + } + } + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceFetchUpcomingResponse.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceFetchUpcomingResponse.kt index fbdb74d89..c233b6e74 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceFetchUpcomingResponse.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceFetchUpcomingResponse.kt @@ -3495,6 +3495,8 @@ private constructor( val EXTERNAL_PAYMENT = of("external_payment") + val SMALL_INVOICE_CARRYOVER = of("small_invoice_carryover") + fun of(value: String) = Action(JsonField.of(value)) } @@ -3509,6 +3511,7 @@ private constructor( CREDIT_NOTE_VOIDED, OVERPAYMENT_REFUND, EXTERNAL_PAYMENT, + SMALL_INVOICE_CARRYOVER, } /** @@ -3530,6 +3533,7 @@ private constructor( CREDIT_NOTE_VOIDED, OVERPAYMENT_REFUND, EXTERNAL_PAYMENT, + SMALL_INVOICE_CARRYOVER, /** * An enum member indicating that [Action] was instantiated with an unknown value. */ @@ -3554,6 +3558,7 @@ private constructor( CREDIT_NOTE_VOIDED -> Value.CREDIT_NOTE_VOIDED OVERPAYMENT_REFUND -> Value.OVERPAYMENT_REFUND EXTERNAL_PAYMENT -> Value.EXTERNAL_PAYMENT + SMALL_INVOICE_CARRYOVER -> Value.SMALL_INVOICE_CARRYOVER else -> Value._UNKNOWN } @@ -3577,6 +3582,7 @@ private constructor( CREDIT_NOTE_VOIDED -> Known.CREDIT_NOTE_VOIDED OVERPAYMENT_REFUND -> Known.OVERPAYMENT_REFUND EXTERNAL_PAYMENT -> Known.EXTERNAL_PAYMENT + SMALL_INVOICE_CARRYOVER -> Known.SMALL_INVOICE_CARRYOVER else -> throw OrbInvalidDataException("Unknown Action: $value") } @@ -4211,7 +4217,7 @@ private constructor( fun subLineItems(): List = subLineItems.getRequired("sub_line_items") /** - * The line amount before before any adjustments. + * The line amount before any adjustments. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). @@ -4894,15 +4900,6 @@ private constructor( /** Alias for calling [price] with `Price.ofTiered(tiered)`. */ fun price(tiered: Price.Tiered) = price(Price.ofTiered(tiered)) - /** Alias for calling [price] with `Price.ofTieredBps(tieredBps)`. */ - fun price(tieredBps: Price.TieredBps) = price(Price.ofTieredBps(tieredBps)) - - /** Alias for calling [price] with `Price.ofBps(bps)`. */ - fun price(bps: Price.Bps) = price(Price.ofBps(bps)) - - /** Alias for calling [price] with `Price.ofBulkBps(bulkBps)`. */ - fun price(bulkBps: Price.BulkBps) = price(Price.ofBulkBps(bulkBps)) - /** Alias for calling [price] with `Price.ofBulk(bulk)`. */ fun price(bulk: Price.Bulk) = price(Price.ofBulk(bulk)) @@ -5028,6 +5025,9 @@ private constructor( fun price(groupedWithMinMaxThresholds: Price.GroupedWithMinMaxThresholds) = price(Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)) + /** Alias for calling [price] with `Price.ofMinimum(minimum)`. */ + fun price(minimum: Price.Minimum) = price(Price.ofMinimum(minimum)) + /** Either the fixed fee quantity or the usage during the service period. */ fun quantity(quantity: Double) = quantity(JsonField.of(quantity)) @@ -5094,7 +5094,7 @@ private constructor( /** Alias for calling [addSubLineItem] with `SubLineItem.ofNull(null_)`. */ fun addSubLineItem(null_: OtherSubLineItem) = addSubLineItem(SubLineItem.ofNull(null_)) - /** The line amount before before any adjustments. */ + /** The line amount before any adjustments. */ fun subtotal(subtotal: String) = subtotal(JsonField.of(subtotal)) /** @@ -5961,6 +5961,7 @@ private constructor( private val createdAt: JsonField, private val paymentProvider: JsonField, private val paymentProviderId: JsonField, + private val receiptPdf: JsonField, private val succeeded: JsonField, private val additionalProperties: MutableMap, ) { @@ -5978,6 +5979,9 @@ private constructor( @JsonProperty("payment_provider_id") @ExcludeMissing paymentProviderId: JsonField = JsonMissing.of(), + @JsonProperty("receipt_pdf") + @ExcludeMissing + receiptPdf: JsonField = JsonMissing.of(), @JsonProperty("succeeded") @ExcludeMissing succeeded: JsonField = JsonMissing.of(), @@ -5987,6 +5991,7 @@ private constructor( createdAt, paymentProvider, paymentProviderId, + receiptPdf, succeeded, mutableMapOf(), ) @@ -6031,6 +6036,15 @@ private constructor( */ fun paymentProviderId(): String? = paymentProviderId.getNullable("payment_provider_id") + /** + * URL to the downloadable PDF version of the receipt. This field will be `null` for payment + * attempts that did not succeed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun receiptPdf(): String? = receiptPdf.getNullable("receipt_pdf") + /** * Whether the payment attempt succeeded. * @@ -6082,6 +6096,15 @@ private constructor( @ExcludeMissing fun _paymentProviderId(): JsonField = paymentProviderId + /** + * Returns the raw JSON value of [receiptPdf]. + * + * Unlike [receiptPdf], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("receipt_pdf") + @ExcludeMissing + fun _receiptPdf(): JsonField = receiptPdf + /** * Returns the raw JSON value of [succeeded]. * @@ -6113,6 +6136,7 @@ private constructor( * .createdAt() * .paymentProvider() * .paymentProviderId() + * .receiptPdf() * .succeeded() * ``` */ @@ -6127,6 +6151,7 @@ private constructor( private var createdAt: JsonField? = null private var paymentProvider: JsonField? = null private var paymentProviderId: JsonField? = null + private var receiptPdf: JsonField? = null private var succeeded: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -6136,6 +6161,7 @@ private constructor( createdAt = paymentAttempt.createdAt paymentProvider = paymentAttempt.paymentProvider paymentProviderId = paymentAttempt.paymentProviderId + receiptPdf = paymentAttempt.receiptPdf succeeded = paymentAttempt.succeeded additionalProperties = paymentAttempt.additionalProperties.toMutableMap() } @@ -6208,6 +6234,21 @@ private constructor( this.paymentProviderId = paymentProviderId } + /** + * URL to the downloadable PDF version of the receipt. This field will be `null` for + * payment attempts that did not succeed. + */ + fun receiptPdf(receiptPdf: String?) = receiptPdf(JsonField.ofNullable(receiptPdf)) + + /** + * Sets [Builder.receiptPdf] to an arbitrary JSON value. + * + * You should usually call [Builder.receiptPdf] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun receiptPdf(receiptPdf: JsonField) = apply { this.receiptPdf = receiptPdf } + /** Whether the payment attempt succeeded. */ fun succeeded(succeeded: Boolean) = succeeded(JsonField.of(succeeded)) @@ -6251,6 +6292,7 @@ private constructor( * .createdAt() * .paymentProvider() * .paymentProviderId() + * .receiptPdf() * .succeeded() * ``` * @@ -6263,6 +6305,7 @@ private constructor( checkRequired("createdAt", createdAt), checkRequired("paymentProvider", paymentProvider), checkRequired("paymentProviderId", paymentProviderId), + checkRequired("receiptPdf", receiptPdf), checkRequired("succeeded", succeeded), additionalProperties.toMutableMap(), ) @@ -6280,6 +6323,7 @@ private constructor( createdAt() paymentProvider()?.validate() paymentProviderId() + receiptPdf() succeeded() validated = true } @@ -6304,6 +6348,7 @@ private constructor( (if (createdAt.asKnown() == null) 0 else 1) + (paymentProvider.asKnown()?.validity() ?: 0) + (if (paymentProviderId.asKnown() == null) 0 else 1) + + (if (receiptPdf.asKnown() == null) 0 else 1) + (if (succeeded.asKnown() == null) 0 else 1) /** The payment provider that attempted to collect the payment. */ @@ -6442,6 +6487,7 @@ private constructor( createdAt == other.createdAt && paymentProvider == other.paymentProvider && paymentProviderId == other.paymentProviderId && + receiptPdf == other.receiptPdf && succeeded == other.succeeded && additionalProperties == other.additionalProperties } @@ -6453,6 +6499,7 @@ private constructor( createdAt, paymentProvider, paymentProviderId, + receiptPdf, succeeded, additionalProperties, ) @@ -6461,7 +6508,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "PaymentAttempt{id=$id, amount=$amount, createdAt=$createdAt, paymentProvider=$paymentProvider, paymentProviderId=$paymentProviderId, succeeded=$succeeded, additionalProperties=$additionalProperties}" + "PaymentAttempt{id=$id, amount=$amount, createdAt=$createdAt, paymentProvider=$paymentProvider, paymentProviderId=$paymentProviderId, receiptPdf=$receiptPdf, succeeded=$succeeded, additionalProperties=$additionalProperties}" } class Status @JsonCreator private constructor(private val value: JsonField) : Enum { diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceLineItemCreateResponse.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceLineItemCreateResponse.kt index 6a013311e..2b32b5ef3 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceLineItemCreateResponse.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceLineItemCreateResponse.kt @@ -298,7 +298,7 @@ private constructor( fun subLineItems(): List = subLineItems.getRequired("sub_line_items") /** - * The line amount before before any adjustments. + * The line amount before any adjustments. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). @@ -963,15 +963,6 @@ private constructor( /** Alias for calling [price] with `Price.ofTiered(tiered)`. */ fun price(tiered: Price.Tiered) = price(Price.ofTiered(tiered)) - /** Alias for calling [price] with `Price.ofTieredBps(tieredBps)`. */ - fun price(tieredBps: Price.TieredBps) = price(Price.ofTieredBps(tieredBps)) - - /** Alias for calling [price] with `Price.ofBps(bps)`. */ - fun price(bps: Price.Bps) = price(Price.ofBps(bps)) - - /** Alias for calling [price] with `Price.ofBulkBps(bulkBps)`. */ - fun price(bulkBps: Price.BulkBps) = price(Price.ofBulkBps(bulkBps)) - /** Alias for calling [price] with `Price.ofBulk(bulk)`. */ fun price(bulk: Price.Bulk) = price(Price.ofBulk(bulk)) @@ -1083,6 +1074,9 @@ private constructor( fun price(groupedWithMinMaxThresholds: Price.GroupedWithMinMaxThresholds) = price(Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)) + /** Alias for calling [price] with `Price.ofMinimum(minimum)`. */ + fun price(minimum: Price.Minimum) = price(Price.ofMinimum(minimum)) + /** Either the fixed fee quantity or the usage during the service period. */ fun quantity(quantity: Double) = quantity(JsonField.of(quantity)) @@ -1144,7 +1138,7 @@ private constructor( /** Alias for calling [addSubLineItem] with `SubLineItem.ofNull(null_)`. */ fun addSubLineItem(null_: OtherSubLineItem) = addSubLineItem(SubLineItem.ofNull(null_)) - /** The line amount before before any adjustments. */ + /** The line amount before any adjustments. */ fun subtotal(subtotal: String) = subtotal(JsonField.of(subtotal)) /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceMarkPaidParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceMarkPaidParams.kt index e9b4b2ee5..46a2b356d 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceMarkPaidParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceMarkPaidParams.kt @@ -20,8 +20,8 @@ import java.util.Collections import java.util.Objects /** - * This endpoint allows an invoice's status to be set the `paid` status. This can only be done to - * invoices that are in the `issued` status. + * This endpoint allows an invoice's status to be set to the `paid` status. This can only be done to + * invoices that are in the `issued` or `synced` status. */ class InvoiceMarkPaidParams private constructor( diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceUpdateParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceUpdateParams.kt index 03d6a0db1..8e1b4a1f7 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceUpdateParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceUpdateParams.kt @@ -6,15 +6,28 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.withorb.api.core.BaseDeserializer +import com.withorb.api.core.BaseSerializer import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.Params +import com.withorb.api.core.allMaxBy +import com.withorb.api.core.getOrThrow import com.withorb.api.core.http.Headers import com.withorb.api.core.http.QueryParams import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException +import java.time.LocalDate +import java.time.OffsetDateTime import java.util.Collections import java.util.Objects @@ -36,6 +49,15 @@ private constructor( fun invoiceId(): String? = invoiceId + /** + * An optional custom due date for the invoice. If not set, the due date will be calculated + * based on the `net_terms` value. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun dueDate(): DueDate? = body.dueDate() + /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to @@ -46,6 +68,25 @@ private constructor( */ fun metadata(): Metadata? = body.metadata() + /** + * The net terms determines the due date of the invoice. Due date is calculated based on the + * invoice or issuance date, depending on the account's configured due date calculation method. + * A value of '0' here represents that the invoice is due on issue, whereas a value of '30' + * represents that the customer has 30 days to pay the invoice. Do not set this field if you + * want to set a custom due date. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun netTerms(): Long? = body.netTerms() + + /** + * Returns the raw JSON value of [dueDate]. + * + * Unlike [dueDate], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _dueDate(): JsonField = body._dueDate() + /** * Returns the raw JSON value of [metadata]. * @@ -53,6 +94,13 @@ private constructor( */ fun _metadata(): JsonField = body._metadata() + /** + * Returns the raw JSON value of [netTerms]. + * + * Unlike [netTerms], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _netTerms(): JsonField = body._netTerms() + fun _additionalBodyProperties(): Map = body._additionalProperties() /** Additional headers to send with the request. */ @@ -93,10 +141,32 @@ private constructor( * * This is generally only useful if you are already constructing the body separately. * Otherwise, it's more convenient to use the top-level setters instead: + * - [dueDate] * - [metadata] + * - [netTerms] */ fun body(body: Body) = apply { this.body = body.toBuilder() } + /** + * An optional custom due date for the invoice. If not set, the due date will be calculated + * based on the `net_terms` value. + */ + fun dueDate(dueDate: DueDate?) = apply { body.dueDate(dueDate) } + + /** + * Sets [Builder.dueDate] to an arbitrary JSON value. + * + * You should usually call [Builder.dueDate] with a well-typed [DueDate] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun dueDate(dueDate: JsonField) = apply { body.dueDate(dueDate) } + + /** Alias for calling [dueDate] with `DueDate.ofDate(date)`. */ + fun dueDate(date: LocalDate) = apply { body.dueDate(date) } + + /** Alias for calling [dueDate] with `DueDate.ofDateTime(dateTime)`. */ + fun dueDate(dateTime: OffsetDateTime) = apply { body.dueDate(dateTime) } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -113,6 +183,30 @@ private constructor( */ fun metadata(metadata: JsonField) = apply { body.metadata(metadata) } + /** + * The net terms determines the due date of the invoice. Due date is calculated based on the + * invoice or issuance date, depending on the account's configured due date calculation + * method. A value of '0' here represents that the invoice is due on issue, whereas a value + * of '30' represents that the customer has 30 days to pay the invoice. Do not set this + * field if you want to set a custom due date. + */ + fun netTerms(netTerms: Long?) = apply { body.netTerms(netTerms) } + + /** + * Alias for [Builder.netTerms]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun netTerms(netTerms: Long) = netTerms(netTerms as Long?) + + /** + * Sets [Builder.netTerms] to an arbitrary JSON value. + * + * You should usually call [Builder.netTerms] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun netTerms(netTerms: JsonField) = apply { body.netTerms(netTerms) } + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { body.additionalProperties(additionalBodyProperties) } @@ -258,16 +352,31 @@ private constructor( class Body private constructor( + private val dueDate: JsonField, private val metadata: JsonField, + private val netTerms: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( + @JsonProperty("due_date") + @ExcludeMissing + dueDate: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing - metadata: JsonField = JsonMissing.of() - ) : this(metadata, mutableMapOf()) + metadata: JsonField = JsonMissing.of(), + @JsonProperty("net_terms") @ExcludeMissing netTerms: JsonField = JsonMissing.of(), + ) : this(dueDate, metadata, netTerms, mutableMapOf()) + + /** + * An optional custom due date for the invoice. If not set, the due date will be calculated + * based on the `net_terms` value. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun dueDate(): DueDate? = dueDate.getNullable("due_date") /** * User-specified key/value pairs for the resource. Individual keys can be removed by @@ -279,6 +388,25 @@ private constructor( */ fun metadata(): Metadata? = metadata.getNullable("metadata") + /** + * The net terms determines the due date of the invoice. Due date is calculated based on the + * invoice or issuance date, depending on the account's configured due date calculation + * method. A value of '0' here represents that the invoice is due on issue, whereas a value + * of '30' represents that the customer has 30 days to pay the invoice. Do not set this + * field if you want to set a custom due date. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun netTerms(): Long? = netTerms.getNullable("net_terms") + + /** + * Returns the raw JSON value of [dueDate]. + * + * Unlike [dueDate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("due_date") @ExcludeMissing fun _dueDate(): JsonField = dueDate + /** * Returns the raw JSON value of [metadata]. * @@ -286,6 +414,13 @@ private constructor( */ @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + /** + * Returns the raw JSON value of [netTerms]. + * + * Unlike [netTerms], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("net_terms") @ExcludeMissing fun _netTerms(): JsonField = netTerms + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -307,14 +442,39 @@ private constructor( /** A builder for [Body]. */ class Builder internal constructor() { + private var dueDate: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() + private var netTerms: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() internal fun from(body: Body) = apply { + dueDate = body.dueDate metadata = body.metadata + netTerms = body.netTerms additionalProperties = body.additionalProperties.toMutableMap() } + /** + * An optional custom due date for the invoice. If not set, the due date will be + * calculated based on the `net_terms` value. + */ + fun dueDate(dueDate: DueDate?) = dueDate(JsonField.ofNullable(dueDate)) + + /** + * Sets [Builder.dueDate] to an arbitrary JSON value. + * + * You should usually call [Builder.dueDate] with a well-typed [DueDate] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun dueDate(dueDate: JsonField) = apply { this.dueDate = dueDate } + + /** Alias for calling [dueDate] with `DueDate.ofDate(date)`. */ + fun dueDate(date: LocalDate) = dueDate(DueDate.ofDate(date)) + + /** Alias for calling [dueDate] with `DueDate.ofDateTime(dateTime)`. */ + fun dueDate(dateTime: OffsetDateTime) = dueDate(DueDate.ofDateTime(dateTime)) + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by @@ -331,6 +491,31 @@ private constructor( */ fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + /** + * The net terms determines the due date of the invoice. Due date is calculated based on + * the invoice or issuance date, depending on the account's configured due date + * calculation method. A value of '0' here represents that the invoice is due on issue, + * whereas a value of '30' represents that the customer has 30 days to pay the invoice. + * Do not set this field if you want to set a custom due date. + */ + fun netTerms(netTerms: Long?) = netTerms(JsonField.ofNullable(netTerms)) + + /** + * Alias for [Builder.netTerms]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun netTerms(netTerms: Long) = netTerms(netTerms as Long?) + + /** + * Sets [Builder.netTerms] to an arbitrary JSON value. + * + * You should usually call [Builder.netTerms] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun netTerms(netTerms: JsonField) = apply { this.netTerms = netTerms } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -355,7 +540,8 @@ private constructor( * * Further updates to this [Builder] will not mutate the returned instance. */ - fun build(): Body = Body(metadata, additionalProperties.toMutableMap()) + fun build(): Body = + Body(dueDate, metadata, netTerms, additionalProperties.toMutableMap()) } private var validated: Boolean = false @@ -365,7 +551,9 @@ private constructor( return@apply } + dueDate()?.validate() metadata()?.validate() + netTerms() validated = true } @@ -383,7 +571,10 @@ private constructor( * * Used for best match union deserialization. */ - internal fun validity(): Int = (metadata.asKnown()?.validity() ?: 0) + internal fun validity(): Int = + (dueDate.asKnown()?.validity() ?: 0) + + (metadata.asKnown()?.validity() ?: 0) + + (if (netTerms.asKnown() == null) 0 else 1) override fun equals(other: Any?): Boolean { if (this === other) { @@ -391,16 +582,192 @@ private constructor( } return other is Body && + dueDate == other.dueDate && metadata == other.metadata && + netTerms == other.netTerms && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(metadata, additionalProperties) } + private val hashCode: Int by lazy { + Objects.hash(dueDate, metadata, netTerms, additionalProperties) + } override fun hashCode(): Int = hashCode override fun toString() = - "Body{metadata=$metadata, additionalProperties=$additionalProperties}" + "Body{dueDate=$dueDate, metadata=$metadata, netTerms=$netTerms, additionalProperties=$additionalProperties}" + } + + /** + * An optional custom due date for the invoice. If not set, the due date will be calculated + * based on the `net_terms` value. + */ + @JsonDeserialize(using = DueDate.Deserializer::class) + @JsonSerialize(using = DueDate.Serializer::class) + class DueDate + private constructor( + private val date: LocalDate? = null, + private val dateTime: OffsetDateTime? = null, + private val _json: JsonValue? = null, + ) { + + fun date(): LocalDate? = date + + fun dateTime(): OffsetDateTime? = dateTime + + fun isDate(): Boolean = date != null + + fun isDateTime(): Boolean = dateTime != null + + fun asDate(): LocalDate = date.getOrThrow("date") + + fun asDateTime(): OffsetDateTime = dateTime.getOrThrow("dateTime") + + fun _json(): JsonValue? = _json + + fun accept(visitor: Visitor): T = + when { + date != null -> visitor.visitDate(date) + dateTime != null -> visitor.visitDateTime(dateTime) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): DueDate = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitDate(date: LocalDate) {} + + override fun visitDateTime(dateTime: OffsetDateTime) {} + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitDate(date: LocalDate) = 1 + + override fun visitDateTime(dateTime: OffsetDateTime) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is DueDate && date == other.date && dateTime == other.dateTime + } + + override fun hashCode(): Int = Objects.hash(date, dateTime) + + override fun toString(): String = + when { + date != null -> "DueDate{date=$date}" + dateTime != null -> "DueDate{dateTime=$dateTime}" + _json != null -> "DueDate{_unknown=$_json}" + else -> throw IllegalStateException("Invalid DueDate") + } + + companion object { + + fun ofDate(date: LocalDate) = DueDate(date = date) + + fun ofDateTime(dateTime: OffsetDateTime) = DueDate(dateTime = dateTime) + } + + /** + * An interface that defines how to map each variant of [DueDate] to a value of type [T]. + */ + interface Visitor { + + fun visitDate(date: LocalDate): T + + fun visitDateTime(dateTime: OffsetDateTime): T + + /** + * Maps an unknown variant of [DueDate] to a value of type [T]. + * + * An instance of [DueDate] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is + * unaware of. + * + * @throws OrbInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw OrbInvalidDataException("Unknown DueDate: $json") + } + } + + internal class Deserializer : BaseDeserializer(DueDate::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): DueDate { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + DueDate(date = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + DueDate(dateTime = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with + // all the possible variants (e.g. deserializing from object). + 0 -> DueDate(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely + // valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(DueDate::class) { + + override fun serialize( + value: DueDate, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.date != null -> generator.writeObject(value.date) + value.dateTime != null -> generator.writeObject(value.dateTime) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid DueDate") + } + } + } } /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceVoidParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceVoidParams.kt index 0a0b2be6d..45f8a7d15 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceVoidParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceVoidParams.kt @@ -10,7 +10,7 @@ import com.withorb.api.core.toImmutable import java.util.Objects /** - * This endpoint allows an invoice's status to be set the `void` status. This can only be done to + * This endpoint allows an invoice's status to be set to the `void` status. This can only be done to * invoices that are in the `issued` status. * * If the associated invoice has used the customer balance to change the amount due, the customer diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MonetaryAmountDiscountAdjustment.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MonetaryAmountDiscountAdjustment.kt index 26ffd6e64..f7de6d732 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MonetaryAmountDiscountAdjustment.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MonetaryAmountDiscountAdjustment.kt @@ -115,7 +115,7 @@ private constructor( fun filters(): List = filters.getRequired("filters") /** - * True for adjustments that apply to an entire invocice, false for adjustments that apply to + * True for adjustments that apply to an entire invoice, false for adjustments that apply to * only one price. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly @@ -391,8 +391,8 @@ private constructor( } /** - * True for adjustments that apply to an entire invocice, false for adjustments that apply - * to only one price. + * True for adjustments that apply to an entire invoice, false for adjustments that apply to + * only one price. */ fun isInvoiceLevel(isInvoiceLevel: Boolean) = isInvoiceLevel(JsonField.of(isInvoiceLevel)) diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MonetaryMaximumAdjustment.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MonetaryMaximumAdjustment.kt index 63e2620bb..55b70f78d 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MonetaryMaximumAdjustment.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MonetaryMaximumAdjustment.kt @@ -106,7 +106,7 @@ private constructor( fun filters(): List = filters.getRequired("filters") /** - * True for adjustments that apply to an entire invocice, false for adjustments that apply to + * True for adjustments that apply to an entire invoice, false for adjustments that apply to * only one price. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly @@ -371,8 +371,8 @@ private constructor( } /** - * True for adjustments that apply to an entire invocice, false for adjustments that apply - * to only one price. + * True for adjustments that apply to an entire invoice, false for adjustments that apply to + * only one price. */ fun isInvoiceLevel(isInvoiceLevel: Boolean) = isInvoiceLevel(JsonField.of(isInvoiceLevel)) diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MonetaryMinimumAdjustment.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MonetaryMinimumAdjustment.kt index cc8a75af1..3589f5606 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MonetaryMinimumAdjustment.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MonetaryMinimumAdjustment.kt @@ -109,7 +109,7 @@ private constructor( fun filters(): List = filters.getRequired("filters") /** - * True for adjustments that apply to an entire invocice, false for adjustments that apply to + * True for adjustments that apply to an entire invoice, false for adjustments that apply to * only one price. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly @@ -392,8 +392,8 @@ private constructor( } /** - * True for adjustments that apply to an entire invocice, false for adjustments that apply - * to only one price. + * True for adjustments that apply to an entire invoice, false for adjustments that apply to + * only one price. */ fun isInvoiceLevel(isInvoiceLevel: Boolean) = isInvoiceLevel(JsonField.of(isInvoiceLevel)) diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MonetaryPercentageDiscountAdjustment.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MonetaryPercentageDiscountAdjustment.kt index bb33573a4..e88a208f4 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MonetaryPercentageDiscountAdjustment.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MonetaryPercentageDiscountAdjustment.kt @@ -106,7 +106,7 @@ private constructor( fun filters(): List = filters.getRequired("filters") /** - * True for adjustments that apply to an entire invocice, false for adjustments that apply to + * True for adjustments that apply to an entire invoice, false for adjustments that apply to * only one price. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly @@ -376,8 +376,8 @@ private constructor( } /** - * True for adjustments that apply to an entire invocice, false for adjustments that apply - * to only one price. + * True for adjustments that apply to an entire invoice, false for adjustments that apply to + * only one price. */ fun isInvoiceLevel(isInvoiceLevel: Boolean) = isInvoiceLevel(JsonField.of(isInvoiceLevel)) diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MonetaryUsageDiscountAdjustment.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MonetaryUsageDiscountAdjustment.kt index 2b63e1d1b..b18464077 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MonetaryUsageDiscountAdjustment.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MonetaryUsageDiscountAdjustment.kt @@ -106,7 +106,7 @@ private constructor( fun filters(): List = filters.getRequired("filters") /** - * True for adjustments that apply to an entire invocice, false for adjustments that apply to + * True for adjustments that apply to an entire invoice, false for adjustments that apply to * only one price. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly @@ -374,8 +374,8 @@ private constructor( } /** - * True for adjustments that apply to an entire invocice, false for adjustments that apply - * to only one price. + * True for adjustments that apply to an entire invoice, false for adjustments that apply to + * only one price. */ fun isInvoiceLevel(isInvoiceLevel: Boolean) = isInvoiceLevel(JsonField.of(isInvoiceLevel)) diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingBpsPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingBpsPrice.kt deleted file mode 100644 index 813376b21..000000000 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingBpsPrice.kt +++ /dev/null @@ -1,1320 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.withorb.api.models - -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import com.withorb.api.core.Enum -import com.withorb.api.core.ExcludeMissing -import com.withorb.api.core.JsonField -import com.withorb.api.core.JsonMissing -import com.withorb.api.core.JsonValue -import com.withorb.api.core.checkRequired -import com.withorb.api.core.toImmutable -import com.withorb.api.errors.OrbInvalidDataException -import java.util.Collections -import java.util.Objects - -class NewFloatingBpsPrice -private constructor( - private val bpsConfig: JsonField, - private val cadence: JsonField, - private val currency: JsonField, - private val itemId: JsonField, - private val modelType: JsonField, - private val name: JsonField, - private val billableMetricId: JsonField, - private val billedInAdvance: JsonField, - private val billingCycleConfiguration: JsonField, - private val conversionRate: JsonField, - private val conversionRateConfig: JsonField, - private val dimensionalPriceConfiguration: JsonField, - private val externalPriceId: JsonField, - private val fixedPriceQuantity: JsonField, - private val invoiceGroupingKey: JsonField, - private val invoicingCycleConfiguration: JsonField, - private val metadata: JsonField, - private val additionalProperties: MutableMap, -) { - - @JsonCreator - private constructor( - @JsonProperty("bps_config") - @ExcludeMissing - bpsConfig: JsonField = JsonMissing.of(), - @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), - @JsonProperty("currency") @ExcludeMissing currency: JsonField = JsonMissing.of(), - @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - modelType: JsonField = JsonMissing.of(), - @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - billingCycleConfiguration: JsonField = JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("conversion_rate_config") - @ExcludeMissing - conversionRateConfig: JsonField = JsonMissing.of(), - @JsonProperty("dimensional_price_configuration") - @ExcludeMissing - dimensionalPriceConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - invoicingCycleConfiguration: JsonField = JsonMissing.of(), - @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), - ) : this( - bpsConfig, - cadence, - currency, - itemId, - modelType, - name, - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - conversionRateConfig, - dimensionalPriceConfiguration, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - mutableMapOf(), - ) - - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly - * missing or null (e.g. if the server responded with an unexpected value). - */ - fun bpsConfig(): BpsConfig = bpsConfig.getRequired("bps_config") - - /** - * The cadence to bill for this price on. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly - * missing or null (e.g. if the server responded with an unexpected value). - */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - /** - * An ISO 4217 currency string for which this price is billed in. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly - * missing or null (e.g. if the server responded with an unexpected value). - */ - fun currency(): String = currency.getRequired("currency") - - /** - * The id of the item the price will be associated with. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly - * missing or null (e.g. if the server responded with an unexpected value). - */ - fun itemId(): String = itemId.getRequired("item_id") - - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly - * missing or null (e.g. if the server responded with an unexpected value). - */ - fun modelType(): ModelType = modelType.getRequired("model_type") - - /** - * The name of the price. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly - * missing or null (e.g. if the server responded with an unexpected value). - */ - fun name(): String = name.getRequired("name") - - /** - * The id of the billable metric for the price. Only needed if the price is usage-based. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - fun billableMetricId(): String? = billableMetricId.getNullable("billable_metric_id") - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this is true, - * and in-arrears if this is false. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") - - /** - * For custom cadence: specifies the duration of the billing period in days or months. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - fun billingCycleConfiguration(): NewBillingCycleConfiguration? = - billingCycleConfiguration.getNullable("billing_cycle_configuration") - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") - - /** - * The configuration for the rate of the price currency to the invoicing currency. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - fun conversionRateConfig(): ConversionRateConfig? = - conversionRateConfig.getNullable("conversion_rate_config") - - /** - * For dimensional price: specifies a price group and dimension values - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = - dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") - - /** - * An alias for the price. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") - - /** - * If the Price represents a fixed cost, this represents the quantity of units applied. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - fun fixedPriceQuantity(): Double? = fixedPriceQuantity.getNullable("fixed_price_quantity") - - /** - * The property used to group this price on an invoice - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - fun invoiceGroupingKey(): String? = invoiceGroupingKey.getNullable("invoice_grouping_key") - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. If - * unspecified, a single invoice is produced per billing cycle. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by setting - * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to - * `null`. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - fun metadata(): Metadata? = metadata.getNullable("metadata") - - /** - * Returns the raw JSON value of [bpsConfig]. - * - * Unlike [bpsConfig], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("bps_config") @ExcludeMissing fun _bpsConfig(): JsonField = bpsConfig - - /** - * Returns the raw JSON value of [cadence]. - * - * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence - - /** - * Returns the raw JSON value of [currency]. - * - * Unlike [currency], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - - /** - * Returns the raw JSON value of [itemId]. - * - * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - /** - * Returns the raw JSON value of [modelType]. - * - * Unlike [modelType], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonField = modelType - - /** - * Returns the raw JSON value of [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - /** - * Returns the raw JSON value of [billableMetricId]. - * - * Unlike [billableMetricId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = billableMetricId - - /** - * Returns the raw JSON value of [billedInAdvance]. - * - * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance - - /** - * Returns the raw JSON value of [billingCycleConfiguration]. - * - * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** - * Returns the raw JSON value of [conversionRate]. - * - * Unlike [conversionRate], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** - * Returns the raw JSON value of [conversionRateConfig]. - * - * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("conversion_rate_config") - @ExcludeMissing - fun _conversionRateConfig(): JsonField = conversionRateConfig - - /** - * Returns the raw JSON value of [dimensionalPriceConfiguration]. - * - * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("dimensional_price_configuration") - @ExcludeMissing - fun _dimensionalPriceConfiguration(): JsonField = - dimensionalPriceConfiguration - - /** - * Returns the raw JSON value of [externalPriceId]. - * - * Unlike [externalPriceId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * Returns the raw JSON value of [fixedPriceQuantity]. - * - * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** - * Returns the raw JSON value of [invoiceGroupingKey]. - * - * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Returns the raw JSON value of [invoicingCycleConfiguration]. - * - * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * Returns the raw JSON value of [metadata]. - * - * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [NewFloatingBpsPrice]. - * - * The following fields are required: - * ```kotlin - * .bpsConfig() - * .cadence() - * .currency() - * .itemId() - * .modelType() - * .name() - * ``` - */ - fun builder() = Builder() - } - - /** A builder for [NewFloatingBpsPrice]. */ - class Builder internal constructor() { - - private var bpsConfig: JsonField? = null - private var cadence: JsonField? = null - private var currency: JsonField? = null - private var itemId: JsonField? = null - private var modelType: JsonField? = null - private var name: JsonField? = null - private var billableMetricId: JsonField = JsonMissing.of() - private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var conversionRateConfig: JsonField = JsonMissing.of() - private var dimensionalPriceConfiguration: JsonField = - JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(newFloatingBpsPrice: NewFloatingBpsPrice) = apply { - bpsConfig = newFloatingBpsPrice.bpsConfig - cadence = newFloatingBpsPrice.cadence - currency = newFloatingBpsPrice.currency - itemId = newFloatingBpsPrice.itemId - modelType = newFloatingBpsPrice.modelType - name = newFloatingBpsPrice.name - billableMetricId = newFloatingBpsPrice.billableMetricId - billedInAdvance = newFloatingBpsPrice.billedInAdvance - billingCycleConfiguration = newFloatingBpsPrice.billingCycleConfiguration - conversionRate = newFloatingBpsPrice.conversionRate - conversionRateConfig = newFloatingBpsPrice.conversionRateConfig - dimensionalPriceConfiguration = newFloatingBpsPrice.dimensionalPriceConfiguration - externalPriceId = newFloatingBpsPrice.externalPriceId - fixedPriceQuantity = newFloatingBpsPrice.fixedPriceQuantity - invoiceGroupingKey = newFloatingBpsPrice.invoiceGroupingKey - invoicingCycleConfiguration = newFloatingBpsPrice.invoicingCycleConfiguration - metadata = newFloatingBpsPrice.metadata - additionalProperties = newFloatingBpsPrice.additionalProperties.toMutableMap() - } - - fun bpsConfig(bpsConfig: BpsConfig) = bpsConfig(JsonField.of(bpsConfig)) - - /** - * Sets [Builder.bpsConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.bpsConfig] with a well-typed [BpsConfig] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun bpsConfig(bpsConfig: JsonField) = apply { this.bpsConfig = bpsConfig } - - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** - * Sets [Builder.cadence] to an arbitrary JSON value. - * - * You should usually call [Builder.cadence] with a well-typed [Cadence] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - - /** An ISO 4217 currency string for which this price is billed in. */ - fun currency(currency: String) = currency(JsonField.of(currency)) - - /** - * Sets [Builder.currency] to an arbitrary JSON value. - * - * You should usually call [Builder.currency] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } - - /** The id of the item the price will be associated with. */ - fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - - /** - * Sets [Builder.itemId] to an arbitrary JSON value. - * - * You should usually call [Builder.itemId] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - - /** - * Sets [Builder.modelType] to an arbitrary JSON value. - * - * You should usually call [Builder.modelType] with a well-typed [ModelType] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun modelType(modelType: JsonField) = apply { this.modelType = modelType } - - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) - - /** - * Sets [Builder.name] to an arbitrary JSON value. - * - * You should usually call [Builder.name] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun name(name: JsonField) = apply { this.name = name } - - /** The id of the billable metric for the price. Only needed if the price is usage-based. */ - fun billableMetricId(billableMetricId: String?) = - billableMetricId(JsonField.ofNullable(billableMetricId)) - - /** - * Sets [Builder.billableMetricId] to an arbitrary JSON value. - * - * You should usually call [Builder.billableMetricId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun billableMetricId(billableMetricId: JsonField) = apply { - this.billableMetricId = billableMetricId - } - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this is - * true, and in-arrears if this is false. - */ - fun billedInAdvance(billedInAdvance: Boolean?) = - billedInAdvance(JsonField.ofNullable(billedInAdvance)) - - /** - * Alias for [Builder.billedInAdvance]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun billedInAdvance(billedInAdvance: Boolean) = billedInAdvance(billedInAdvance as Boolean?) - - /** - * Sets [Builder.billedInAdvance] to an arbitrary JSON value. - * - * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun billedInAdvance(billedInAdvance: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** For custom cadence: specifies the duration of the billing period in days or months. */ - fun billingCycleConfiguration(billingCycleConfiguration: NewBillingCycleConfiguration?) = - billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - - /** - * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.billingCycleConfiguration] with a well-typed - * [NewBillingCycleConfiguration] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: JsonField - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double?) = - conversionRate(JsonField.ofNullable(conversionRate)) - - /** - * Alias for [Builder.conversionRate]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) - - /** - * Sets [Builder.conversionRate] to an arbitrary JSON value. - * - * You should usually call [Builder.conversionRate] with a well-typed [Double] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** The configuration for the rate of the price currency to the invoicing currency. */ - fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = - conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) - - /** - * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.conversionRateConfig] with a well-typed - * [ConversionRateConfig] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun conversionRateConfig(conversionRateConfig: JsonField) = apply { - this.conversionRateConfig = conversionRateConfig - } - - /** Alias for calling [conversionRateConfig] with `ConversionRateConfig.ofUnit(unit)`. */ - fun conversionRateConfig(unit: UnitConversionRateConfig) = - conversionRateConfig(ConversionRateConfig.ofUnit(unit)) - - /** - * Alias for calling [conversionRateConfig] with the following: - * ```kotlin - * UnitConversionRateConfig.builder() - * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) - * .unitConfig(unitConfig) - * .build() - * ``` - */ - fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = - conversionRateConfig( - UnitConversionRateConfig.builder() - .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) - .unitConfig(unitConfig) - .build() - ) - - /** - * Alias for calling [conversionRateConfig] with `ConversionRateConfig.ofTiered(tiered)`. - */ - fun conversionRateConfig(tiered: TieredConversionRateConfig) = - conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) - - /** - * Alias for calling [conversionRateConfig] with the following: - * ```kotlin - * TieredConversionRateConfig.builder() - * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) - * .tieredConfig(tieredConfig) - * .build() - * ``` - */ - fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = - conversionRateConfig( - TieredConversionRateConfig.builder() - .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) - .tieredConfig(tieredConfig) - .build() - ) - - /** For dimensional price: specifies a price group and dimension values */ - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? - ) = dimensionalPriceConfiguration(JsonField.ofNullable(dimensionalPriceConfiguration)) - - /** - * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.dimensionalPriceConfiguration] with a well-typed - * [NewDimensionalPriceConfiguration] value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: JsonField - ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** - * Sets [Builder.externalPriceId] to an arbitrary JSON value. - * - * You should usually call [Builder.externalPriceId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun externalPriceId(externalPriceId: JsonField) = apply { - this.externalPriceId = externalPriceId - } - - /** If the Price represents a fixed cost, this represents the quantity of units applied. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = - fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) - - /** - * Alias for [Builder.fixedPriceQuantity]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. - * - * You should usually call [Builder.fixedPriceQuantity] with a well-typed [Double] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = - invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) - - /** - * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. - * - * You should usually call [Builder.invoiceGroupingKey] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { - this.invoiceGroupingKey = invoiceGroupingKey - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. If - * unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: NewBillingCycleConfiguration? - ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) - - /** - * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.invoicingCycleConfiguration] with a well-typed - * [NewBillingCycleConfiguration] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by - * setting the value to `null`, and the entire metadata mapping can be cleared by setting - * `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * Sets [Builder.metadata] to an arbitrary JSON value. - * - * You should usually call [Builder.metadata] with a well-typed [Metadata] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [NewFloatingBpsPrice]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```kotlin - * .bpsConfig() - * .cadence() - * .currency() - * .itemId() - * .modelType() - * .name() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): NewFloatingBpsPrice = - NewFloatingBpsPrice( - checkRequired("bpsConfig", bpsConfig), - checkRequired("cadence", cadence), - checkRequired("currency", currency), - checkRequired("itemId", itemId), - checkRequired("modelType", modelType), - checkRequired("name", name), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - conversionRateConfig, - dimensionalPriceConfiguration, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): NewFloatingBpsPrice = apply { - if (validated) { - return@apply - } - - bpsConfig().validate() - cadence().validate() - currency() - itemId() - modelType().validate() - name() - billableMetricId() - billedInAdvance() - billingCycleConfiguration()?.validate() - conversionRate() - conversionRateConfig()?.validate() - dimensionalPriceConfiguration()?.validate() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration()?.validate() - metadata()?.validate() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (bpsConfig.asKnown()?.validity() ?: 0) + - (cadence.asKnown()?.validity() ?: 0) + - (if (currency.asKnown() == null) 0 else 1) + - (if (itemId.asKnown() == null) 0 else 1) + - (modelType.asKnown()?.validity() ?: 0) + - (if (name.asKnown() == null) 0 else 1) + - (if (billableMetricId.asKnown() == null) 0 else 1) + - (if (billedInAdvance.asKnown() == null) 0 else 1) + - (billingCycleConfiguration.asKnown()?.validity() ?: 0) + - (if (conversionRate.asKnown() == null) 0 else 1) + - (conversionRateConfig.asKnown()?.validity() ?: 0) + - (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + - (if (externalPriceId.asKnown() == null) 0 else 1) + - (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + - (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + - (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + - (metadata.asKnown()?.validity() ?: 0) - - /** The cadence to bill for this price on. */ - class Cadence @JsonCreator private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API may respond with new members that the SDK is - * unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - val ANNUAL = of("annual") - - val SEMI_ANNUAL = of("semi_annual") - - val MONTHLY = of("monthly") - - val QUARTERLY = of("quarterly") - - val ONE_TIME = of("one_time") - - val CUSTOM = of("custom") - - fun of(value: String) = Cadence(JsonField.of(value)) - } - - /** An enum containing [Cadence]'s known values. */ - enum class Known { - ANNUAL, - SEMI_ANNUAL, - MONTHLY, - QUARTERLY, - ONE_TIME, - CUSTOM, - } - - /** - * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Cadence] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if the - * SDK is on an older version than the API, then the API may respond with new members that - * the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - ANNUAL, - SEMI_ANNUAL, - MONTHLY, - QUARTERLY, - ONE_TIME, - CUSTOM, - /** An enum member indicating that [Cadence] was instantiated with an unknown value. */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you want - * to throw for the unknown case. - */ - fun value(): Value = - when (this) { - ANNUAL -> Value.ANNUAL - SEMI_ANNUAL -> Value.SEMI_ANNUAL - MONTHLY -> Value.MONTHLY - QUARTERLY -> Value.QUARTERLY - ONE_TIME -> Value.ONE_TIME - CUSTOM -> Value.CUSTOM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and don't - * want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known member. - */ - fun known(): Known = - when (this) { - ANNUAL -> Known.ANNUAL - SEMI_ANNUAL -> Known.SEMI_ANNUAL - MONTHLY -> Known.MONTHLY - QUARTERLY -> Known.QUARTERLY - ONE_TIME -> Known.ONE_TIME - CUSTOM -> Known.CUSTOM - else -> throw OrbInvalidDataException("Unknown Cadence: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the expected - * primitive type. - */ - fun asString(): String = - _value().asString() ?: throw OrbInvalidDataException("Value is not a String") - - private var validated: Boolean = false - - fun validate(): Cadence = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Cadence && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class ModelType @JsonCreator private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API may respond with new members that the SDK is - * unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - val BPS = of("bps") - - fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - BPS - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if the - * SDK is on an older version than the API, then the API may respond with new members that - * the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - BPS, - /** - * An enum member indicating that [ModelType] was instantiated with an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you want - * to throw for the unknown case. - */ - fun value(): Value = - when (this) { - BPS -> Value.BPS - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and don't - * want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known member. - */ - fun known(): Known = - when (this) { - BPS -> Known.BPS - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the expected - * primitive type. - */ - fun asString(): String = - _value().asString() ?: throw OrbInvalidDataException("Value is not a String") - - private var validated: Boolean = false - - fun validate(): ModelType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ModelType && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by setting - * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to - * `null`. - */ - class Metadata - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Metadata]. */ - fun builder() = Builder() - } - - /** A builder for [Metadata]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(metadata: Metadata) = apply { - additionalProperties = metadata.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Metadata]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Metadata && additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is NewFloatingBpsPrice && - bpsConfig == other.bpsConfig && - cadence == other.cadence && - currency == other.currency && - itemId == other.itemId && - modelType == other.modelType && - name == other.name && - billableMetricId == other.billableMetricId && - billedInAdvance == other.billedInAdvance && - billingCycleConfiguration == other.billingCycleConfiguration && - conversionRate == other.conversionRate && - conversionRateConfig == other.conversionRateConfig && - dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && - externalPriceId == other.externalPriceId && - fixedPriceQuantity == other.fixedPriceQuantity && - invoiceGroupingKey == other.invoiceGroupingKey && - invoicingCycleConfiguration == other.invoicingCycleConfiguration && - metadata == other.metadata && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - bpsConfig, - cadence, - currency, - itemId, - modelType, - name, - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - conversionRateConfig, - dimensionalPriceConfiguration, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewFloatingBpsPrice{bpsConfig=$bpsConfig, cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" -} diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingBulkBpsPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingBulkBpsPrice.kt deleted file mode 100644 index 0fd429c63..000000000 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingBulkBpsPrice.kt +++ /dev/null @@ -1,1324 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.withorb.api.models - -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import com.withorb.api.core.Enum -import com.withorb.api.core.ExcludeMissing -import com.withorb.api.core.JsonField -import com.withorb.api.core.JsonMissing -import com.withorb.api.core.JsonValue -import com.withorb.api.core.checkRequired -import com.withorb.api.core.toImmutable -import com.withorb.api.errors.OrbInvalidDataException -import java.util.Collections -import java.util.Objects - -class NewFloatingBulkBpsPrice -private constructor( - private val bulkBpsConfig: JsonField, - private val cadence: JsonField, - private val currency: JsonField, - private val itemId: JsonField, - private val modelType: JsonField, - private val name: JsonField, - private val billableMetricId: JsonField, - private val billedInAdvance: JsonField, - private val billingCycleConfiguration: JsonField, - private val conversionRate: JsonField, - private val conversionRateConfig: JsonField, - private val dimensionalPriceConfiguration: JsonField, - private val externalPriceId: JsonField, - private val fixedPriceQuantity: JsonField, - private val invoiceGroupingKey: JsonField, - private val invoicingCycleConfiguration: JsonField, - private val metadata: JsonField, - private val additionalProperties: MutableMap, -) { - - @JsonCreator - private constructor( - @JsonProperty("bulk_bps_config") - @ExcludeMissing - bulkBpsConfig: JsonField = JsonMissing.of(), - @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), - @JsonProperty("currency") @ExcludeMissing currency: JsonField = JsonMissing.of(), - @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - modelType: JsonField = JsonMissing.of(), - @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - billingCycleConfiguration: JsonField = JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("conversion_rate_config") - @ExcludeMissing - conversionRateConfig: JsonField = JsonMissing.of(), - @JsonProperty("dimensional_price_configuration") - @ExcludeMissing - dimensionalPriceConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - invoicingCycleConfiguration: JsonField = JsonMissing.of(), - @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), - ) : this( - bulkBpsConfig, - cadence, - currency, - itemId, - modelType, - name, - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - conversionRateConfig, - dimensionalPriceConfiguration, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - mutableMapOf(), - ) - - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly - * missing or null (e.g. if the server responded with an unexpected value). - */ - fun bulkBpsConfig(): BulkBpsConfig = bulkBpsConfig.getRequired("bulk_bps_config") - - /** - * The cadence to bill for this price on. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly - * missing or null (e.g. if the server responded with an unexpected value). - */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - /** - * An ISO 4217 currency string for which this price is billed in. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly - * missing or null (e.g. if the server responded with an unexpected value). - */ - fun currency(): String = currency.getRequired("currency") - - /** - * The id of the item the price will be associated with. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly - * missing or null (e.g. if the server responded with an unexpected value). - */ - fun itemId(): String = itemId.getRequired("item_id") - - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly - * missing or null (e.g. if the server responded with an unexpected value). - */ - fun modelType(): ModelType = modelType.getRequired("model_type") - - /** - * The name of the price. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly - * missing or null (e.g. if the server responded with an unexpected value). - */ - fun name(): String = name.getRequired("name") - - /** - * The id of the billable metric for the price. Only needed if the price is usage-based. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - fun billableMetricId(): String? = billableMetricId.getNullable("billable_metric_id") - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this is true, - * and in-arrears if this is false. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") - - /** - * For custom cadence: specifies the duration of the billing period in days or months. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - fun billingCycleConfiguration(): NewBillingCycleConfiguration? = - billingCycleConfiguration.getNullable("billing_cycle_configuration") - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") - - /** - * The configuration for the rate of the price currency to the invoicing currency. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - fun conversionRateConfig(): ConversionRateConfig? = - conversionRateConfig.getNullable("conversion_rate_config") - - /** - * For dimensional price: specifies a price group and dimension values - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = - dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") - - /** - * An alias for the price. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") - - /** - * If the Price represents a fixed cost, this represents the quantity of units applied. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - fun fixedPriceQuantity(): Double? = fixedPriceQuantity.getNullable("fixed_price_quantity") - - /** - * The property used to group this price on an invoice - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - fun invoiceGroupingKey(): String? = invoiceGroupingKey.getNullable("invoice_grouping_key") - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. If - * unspecified, a single invoice is produced per billing cycle. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by setting - * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to - * `null`. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - fun metadata(): Metadata? = metadata.getNullable("metadata") - - /** - * Returns the raw JSON value of [bulkBpsConfig]. - * - * Unlike [bulkBpsConfig], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("bulk_bps_config") - @ExcludeMissing - fun _bulkBpsConfig(): JsonField = bulkBpsConfig - - /** - * Returns the raw JSON value of [cadence]. - * - * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence - - /** - * Returns the raw JSON value of [currency]. - * - * Unlike [currency], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - - /** - * Returns the raw JSON value of [itemId]. - * - * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - /** - * Returns the raw JSON value of [modelType]. - * - * Unlike [modelType], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonField = modelType - - /** - * Returns the raw JSON value of [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - /** - * Returns the raw JSON value of [billableMetricId]. - * - * Unlike [billableMetricId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = billableMetricId - - /** - * Returns the raw JSON value of [billedInAdvance]. - * - * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance - - /** - * Returns the raw JSON value of [billingCycleConfiguration]. - * - * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** - * Returns the raw JSON value of [conversionRate]. - * - * Unlike [conversionRate], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** - * Returns the raw JSON value of [conversionRateConfig]. - * - * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("conversion_rate_config") - @ExcludeMissing - fun _conversionRateConfig(): JsonField = conversionRateConfig - - /** - * Returns the raw JSON value of [dimensionalPriceConfiguration]. - * - * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("dimensional_price_configuration") - @ExcludeMissing - fun _dimensionalPriceConfiguration(): JsonField = - dimensionalPriceConfiguration - - /** - * Returns the raw JSON value of [externalPriceId]. - * - * Unlike [externalPriceId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * Returns the raw JSON value of [fixedPriceQuantity]. - * - * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** - * Returns the raw JSON value of [invoiceGroupingKey]. - * - * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Returns the raw JSON value of [invoicingCycleConfiguration]. - * - * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * Returns the raw JSON value of [metadata]. - * - * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [NewFloatingBulkBpsPrice]. - * - * The following fields are required: - * ```kotlin - * .bulkBpsConfig() - * .cadence() - * .currency() - * .itemId() - * .modelType() - * .name() - * ``` - */ - fun builder() = Builder() - } - - /** A builder for [NewFloatingBulkBpsPrice]. */ - class Builder internal constructor() { - - private var bulkBpsConfig: JsonField? = null - private var cadence: JsonField? = null - private var currency: JsonField? = null - private var itemId: JsonField? = null - private var modelType: JsonField? = null - private var name: JsonField? = null - private var billableMetricId: JsonField = JsonMissing.of() - private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var conversionRateConfig: JsonField = JsonMissing.of() - private var dimensionalPriceConfiguration: JsonField = - JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(newFloatingBulkBpsPrice: NewFloatingBulkBpsPrice) = apply { - bulkBpsConfig = newFloatingBulkBpsPrice.bulkBpsConfig - cadence = newFloatingBulkBpsPrice.cadence - currency = newFloatingBulkBpsPrice.currency - itemId = newFloatingBulkBpsPrice.itemId - modelType = newFloatingBulkBpsPrice.modelType - name = newFloatingBulkBpsPrice.name - billableMetricId = newFloatingBulkBpsPrice.billableMetricId - billedInAdvance = newFloatingBulkBpsPrice.billedInAdvance - billingCycleConfiguration = newFloatingBulkBpsPrice.billingCycleConfiguration - conversionRate = newFloatingBulkBpsPrice.conversionRate - conversionRateConfig = newFloatingBulkBpsPrice.conversionRateConfig - dimensionalPriceConfiguration = newFloatingBulkBpsPrice.dimensionalPriceConfiguration - externalPriceId = newFloatingBulkBpsPrice.externalPriceId - fixedPriceQuantity = newFloatingBulkBpsPrice.fixedPriceQuantity - invoiceGroupingKey = newFloatingBulkBpsPrice.invoiceGroupingKey - invoicingCycleConfiguration = newFloatingBulkBpsPrice.invoicingCycleConfiguration - metadata = newFloatingBulkBpsPrice.metadata - additionalProperties = newFloatingBulkBpsPrice.additionalProperties.toMutableMap() - } - - fun bulkBpsConfig(bulkBpsConfig: BulkBpsConfig) = bulkBpsConfig(JsonField.of(bulkBpsConfig)) - - /** - * Sets [Builder.bulkBpsConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.bulkBpsConfig] with a well-typed [BulkBpsConfig] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun bulkBpsConfig(bulkBpsConfig: JsonField) = apply { - this.bulkBpsConfig = bulkBpsConfig - } - - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** - * Sets [Builder.cadence] to an arbitrary JSON value. - * - * You should usually call [Builder.cadence] with a well-typed [Cadence] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - - /** An ISO 4217 currency string for which this price is billed in. */ - fun currency(currency: String) = currency(JsonField.of(currency)) - - /** - * Sets [Builder.currency] to an arbitrary JSON value. - * - * You should usually call [Builder.currency] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } - - /** The id of the item the price will be associated with. */ - fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - - /** - * Sets [Builder.itemId] to an arbitrary JSON value. - * - * You should usually call [Builder.itemId] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - - /** - * Sets [Builder.modelType] to an arbitrary JSON value. - * - * You should usually call [Builder.modelType] with a well-typed [ModelType] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun modelType(modelType: JsonField) = apply { this.modelType = modelType } - - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) - - /** - * Sets [Builder.name] to an arbitrary JSON value. - * - * You should usually call [Builder.name] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun name(name: JsonField) = apply { this.name = name } - - /** The id of the billable metric for the price. Only needed if the price is usage-based. */ - fun billableMetricId(billableMetricId: String?) = - billableMetricId(JsonField.ofNullable(billableMetricId)) - - /** - * Sets [Builder.billableMetricId] to an arbitrary JSON value. - * - * You should usually call [Builder.billableMetricId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun billableMetricId(billableMetricId: JsonField) = apply { - this.billableMetricId = billableMetricId - } - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this is - * true, and in-arrears if this is false. - */ - fun billedInAdvance(billedInAdvance: Boolean?) = - billedInAdvance(JsonField.ofNullable(billedInAdvance)) - - /** - * Alias for [Builder.billedInAdvance]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun billedInAdvance(billedInAdvance: Boolean) = billedInAdvance(billedInAdvance as Boolean?) - - /** - * Sets [Builder.billedInAdvance] to an arbitrary JSON value. - * - * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun billedInAdvance(billedInAdvance: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** For custom cadence: specifies the duration of the billing period in days or months. */ - fun billingCycleConfiguration(billingCycleConfiguration: NewBillingCycleConfiguration?) = - billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - - /** - * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.billingCycleConfiguration] with a well-typed - * [NewBillingCycleConfiguration] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: JsonField - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double?) = - conversionRate(JsonField.ofNullable(conversionRate)) - - /** - * Alias for [Builder.conversionRate]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) - - /** - * Sets [Builder.conversionRate] to an arbitrary JSON value. - * - * You should usually call [Builder.conversionRate] with a well-typed [Double] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** The configuration for the rate of the price currency to the invoicing currency. */ - fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = - conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) - - /** - * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.conversionRateConfig] with a well-typed - * [ConversionRateConfig] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun conversionRateConfig(conversionRateConfig: JsonField) = apply { - this.conversionRateConfig = conversionRateConfig - } - - /** Alias for calling [conversionRateConfig] with `ConversionRateConfig.ofUnit(unit)`. */ - fun conversionRateConfig(unit: UnitConversionRateConfig) = - conversionRateConfig(ConversionRateConfig.ofUnit(unit)) - - /** - * Alias for calling [conversionRateConfig] with the following: - * ```kotlin - * UnitConversionRateConfig.builder() - * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) - * .unitConfig(unitConfig) - * .build() - * ``` - */ - fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = - conversionRateConfig( - UnitConversionRateConfig.builder() - .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) - .unitConfig(unitConfig) - .build() - ) - - /** - * Alias for calling [conversionRateConfig] with `ConversionRateConfig.ofTiered(tiered)`. - */ - fun conversionRateConfig(tiered: TieredConversionRateConfig) = - conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) - - /** - * Alias for calling [conversionRateConfig] with the following: - * ```kotlin - * TieredConversionRateConfig.builder() - * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) - * .tieredConfig(tieredConfig) - * .build() - * ``` - */ - fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = - conversionRateConfig( - TieredConversionRateConfig.builder() - .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) - .tieredConfig(tieredConfig) - .build() - ) - - /** For dimensional price: specifies a price group and dimension values */ - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? - ) = dimensionalPriceConfiguration(JsonField.ofNullable(dimensionalPriceConfiguration)) - - /** - * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.dimensionalPriceConfiguration] with a well-typed - * [NewDimensionalPriceConfiguration] value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: JsonField - ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** - * Sets [Builder.externalPriceId] to an arbitrary JSON value. - * - * You should usually call [Builder.externalPriceId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun externalPriceId(externalPriceId: JsonField) = apply { - this.externalPriceId = externalPriceId - } - - /** If the Price represents a fixed cost, this represents the quantity of units applied. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = - fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) - - /** - * Alias for [Builder.fixedPriceQuantity]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. - * - * You should usually call [Builder.fixedPriceQuantity] with a well-typed [Double] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = - invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) - - /** - * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. - * - * You should usually call [Builder.invoiceGroupingKey] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { - this.invoiceGroupingKey = invoiceGroupingKey - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. If - * unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: NewBillingCycleConfiguration? - ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) - - /** - * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.invoicingCycleConfiguration] with a well-typed - * [NewBillingCycleConfiguration] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by - * setting the value to `null`, and the entire metadata mapping can be cleared by setting - * `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * Sets [Builder.metadata] to an arbitrary JSON value. - * - * You should usually call [Builder.metadata] with a well-typed [Metadata] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [NewFloatingBulkBpsPrice]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```kotlin - * .bulkBpsConfig() - * .cadence() - * .currency() - * .itemId() - * .modelType() - * .name() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): NewFloatingBulkBpsPrice = - NewFloatingBulkBpsPrice( - checkRequired("bulkBpsConfig", bulkBpsConfig), - checkRequired("cadence", cadence), - checkRequired("currency", currency), - checkRequired("itemId", itemId), - checkRequired("modelType", modelType), - checkRequired("name", name), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - conversionRateConfig, - dimensionalPriceConfiguration, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): NewFloatingBulkBpsPrice = apply { - if (validated) { - return@apply - } - - bulkBpsConfig().validate() - cadence().validate() - currency() - itemId() - modelType().validate() - name() - billableMetricId() - billedInAdvance() - billingCycleConfiguration()?.validate() - conversionRate() - conversionRateConfig()?.validate() - dimensionalPriceConfiguration()?.validate() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration()?.validate() - metadata()?.validate() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (bulkBpsConfig.asKnown()?.validity() ?: 0) + - (cadence.asKnown()?.validity() ?: 0) + - (if (currency.asKnown() == null) 0 else 1) + - (if (itemId.asKnown() == null) 0 else 1) + - (modelType.asKnown()?.validity() ?: 0) + - (if (name.asKnown() == null) 0 else 1) + - (if (billableMetricId.asKnown() == null) 0 else 1) + - (if (billedInAdvance.asKnown() == null) 0 else 1) + - (billingCycleConfiguration.asKnown()?.validity() ?: 0) + - (if (conversionRate.asKnown() == null) 0 else 1) + - (conversionRateConfig.asKnown()?.validity() ?: 0) + - (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + - (if (externalPriceId.asKnown() == null) 0 else 1) + - (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + - (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + - (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + - (metadata.asKnown()?.validity() ?: 0) - - /** The cadence to bill for this price on. */ - class Cadence @JsonCreator private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API may respond with new members that the SDK is - * unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - val ANNUAL = of("annual") - - val SEMI_ANNUAL = of("semi_annual") - - val MONTHLY = of("monthly") - - val QUARTERLY = of("quarterly") - - val ONE_TIME = of("one_time") - - val CUSTOM = of("custom") - - fun of(value: String) = Cadence(JsonField.of(value)) - } - - /** An enum containing [Cadence]'s known values. */ - enum class Known { - ANNUAL, - SEMI_ANNUAL, - MONTHLY, - QUARTERLY, - ONE_TIME, - CUSTOM, - } - - /** - * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Cadence] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if the - * SDK is on an older version than the API, then the API may respond with new members that - * the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - ANNUAL, - SEMI_ANNUAL, - MONTHLY, - QUARTERLY, - ONE_TIME, - CUSTOM, - /** An enum member indicating that [Cadence] was instantiated with an unknown value. */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you want - * to throw for the unknown case. - */ - fun value(): Value = - when (this) { - ANNUAL -> Value.ANNUAL - SEMI_ANNUAL -> Value.SEMI_ANNUAL - MONTHLY -> Value.MONTHLY - QUARTERLY -> Value.QUARTERLY - ONE_TIME -> Value.ONE_TIME - CUSTOM -> Value.CUSTOM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and don't - * want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known member. - */ - fun known(): Known = - when (this) { - ANNUAL -> Known.ANNUAL - SEMI_ANNUAL -> Known.SEMI_ANNUAL - MONTHLY -> Known.MONTHLY - QUARTERLY -> Known.QUARTERLY - ONE_TIME -> Known.ONE_TIME - CUSTOM -> Known.CUSTOM - else -> throw OrbInvalidDataException("Unknown Cadence: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the expected - * primitive type. - */ - fun asString(): String = - _value().asString() ?: throw OrbInvalidDataException("Value is not a String") - - private var validated: Boolean = false - - fun validate(): Cadence = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Cadence && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class ModelType @JsonCreator private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API may respond with new members that the SDK is - * unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - val BULK_BPS = of("bulk_bps") - - fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - BULK_BPS - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if the - * SDK is on an older version than the API, then the API may respond with new members that - * the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - BULK_BPS, - /** - * An enum member indicating that [ModelType] was instantiated with an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you want - * to throw for the unknown case. - */ - fun value(): Value = - when (this) { - BULK_BPS -> Value.BULK_BPS - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and don't - * want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known member. - */ - fun known(): Known = - when (this) { - BULK_BPS -> Known.BULK_BPS - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the expected - * primitive type. - */ - fun asString(): String = - _value().asString() ?: throw OrbInvalidDataException("Value is not a String") - - private var validated: Boolean = false - - fun validate(): ModelType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ModelType && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by setting - * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to - * `null`. - */ - class Metadata - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Metadata]. */ - fun builder() = Builder() - } - - /** A builder for [Metadata]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(metadata: Metadata) = apply { - additionalProperties = metadata.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Metadata]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Metadata && additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is NewFloatingBulkBpsPrice && - bulkBpsConfig == other.bulkBpsConfig && - cadence == other.cadence && - currency == other.currency && - itemId == other.itemId && - modelType == other.modelType && - name == other.name && - billableMetricId == other.billableMetricId && - billedInAdvance == other.billedInAdvance && - billingCycleConfiguration == other.billingCycleConfiguration && - conversionRate == other.conversionRate && - conversionRateConfig == other.conversionRateConfig && - dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && - externalPriceId == other.externalPriceId && - fixedPriceQuantity == other.fixedPriceQuantity && - invoiceGroupingKey == other.invoiceGroupingKey && - invoicingCycleConfiguration == other.invoicingCycleConfiguration && - metadata == other.metadata && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - bulkBpsConfig, - cadence, - currency, - itemId, - modelType, - name, - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - conversionRateConfig, - dimensionalPriceConfiguration, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewFloatingBulkBpsPrice{bulkBpsConfig=$bulkBpsConfig, cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" -} diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredBpsPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredBpsPrice.kt deleted file mode 100644 index c8b790bdf..000000000 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredBpsPrice.kt +++ /dev/null @@ -1,1325 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.withorb.api.models - -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import com.withorb.api.core.Enum -import com.withorb.api.core.ExcludeMissing -import com.withorb.api.core.JsonField -import com.withorb.api.core.JsonMissing -import com.withorb.api.core.JsonValue -import com.withorb.api.core.checkRequired -import com.withorb.api.core.toImmutable -import com.withorb.api.errors.OrbInvalidDataException -import java.util.Collections -import java.util.Objects - -class NewFloatingTieredBpsPrice -private constructor( - private val cadence: JsonField, - private val currency: JsonField, - private val itemId: JsonField, - private val modelType: JsonField, - private val name: JsonField, - private val tieredBpsConfig: JsonField, - private val billableMetricId: JsonField, - private val billedInAdvance: JsonField, - private val billingCycleConfiguration: JsonField, - private val conversionRate: JsonField, - private val conversionRateConfig: JsonField, - private val dimensionalPriceConfiguration: JsonField, - private val externalPriceId: JsonField, - private val fixedPriceQuantity: JsonField, - private val invoiceGroupingKey: JsonField, - private val invoicingCycleConfiguration: JsonField, - private val metadata: JsonField, - private val additionalProperties: MutableMap, -) { - - @JsonCreator - private constructor( - @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), - @JsonProperty("currency") @ExcludeMissing currency: JsonField = JsonMissing.of(), - @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - modelType: JsonField = JsonMissing.of(), - @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("tiered_bps_config") - @ExcludeMissing - tieredBpsConfig: JsonField = JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - billingCycleConfiguration: JsonField = JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("conversion_rate_config") - @ExcludeMissing - conversionRateConfig: JsonField = JsonMissing.of(), - @JsonProperty("dimensional_price_configuration") - @ExcludeMissing - dimensionalPriceConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - invoicingCycleConfiguration: JsonField = JsonMissing.of(), - @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), - ) : this( - cadence, - currency, - itemId, - modelType, - name, - tieredBpsConfig, - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - conversionRateConfig, - dimensionalPriceConfiguration, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - mutableMapOf(), - ) - - /** - * The cadence to bill for this price on. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly - * missing or null (e.g. if the server responded with an unexpected value). - */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - /** - * An ISO 4217 currency string for which this price is billed in. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly - * missing or null (e.g. if the server responded with an unexpected value). - */ - fun currency(): String = currency.getRequired("currency") - - /** - * The id of the item the price will be associated with. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly - * missing or null (e.g. if the server responded with an unexpected value). - */ - fun itemId(): String = itemId.getRequired("item_id") - - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly - * missing or null (e.g. if the server responded with an unexpected value). - */ - fun modelType(): ModelType = modelType.getRequired("model_type") - - /** - * The name of the price. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly - * missing or null (e.g. if the server responded with an unexpected value). - */ - fun name(): String = name.getRequired("name") - - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly - * missing or null (e.g. if the server responded with an unexpected value). - */ - fun tieredBpsConfig(): TieredBpsConfig = tieredBpsConfig.getRequired("tiered_bps_config") - - /** - * The id of the billable metric for the price. Only needed if the price is usage-based. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - fun billableMetricId(): String? = billableMetricId.getNullable("billable_metric_id") - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this is true, - * and in-arrears if this is false. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") - - /** - * For custom cadence: specifies the duration of the billing period in days or months. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - fun billingCycleConfiguration(): NewBillingCycleConfiguration? = - billingCycleConfiguration.getNullable("billing_cycle_configuration") - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") - - /** - * The configuration for the rate of the price currency to the invoicing currency. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - fun conversionRateConfig(): ConversionRateConfig? = - conversionRateConfig.getNullable("conversion_rate_config") - - /** - * For dimensional price: specifies a price group and dimension values - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = - dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") - - /** - * An alias for the price. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") - - /** - * If the Price represents a fixed cost, this represents the quantity of units applied. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - fun fixedPriceQuantity(): Double? = fixedPriceQuantity.getNullable("fixed_price_quantity") - - /** - * The property used to group this price on an invoice - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - fun invoiceGroupingKey(): String? = invoiceGroupingKey.getNullable("invoice_grouping_key") - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. If - * unspecified, a single invoice is produced per billing cycle. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by setting - * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to - * `null`. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - fun metadata(): Metadata? = metadata.getNullable("metadata") - - /** - * Returns the raw JSON value of [cadence]. - * - * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence - - /** - * Returns the raw JSON value of [currency]. - * - * Unlike [currency], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - - /** - * Returns the raw JSON value of [itemId]. - * - * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - /** - * Returns the raw JSON value of [modelType]. - * - * Unlike [modelType], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonField = modelType - - /** - * Returns the raw JSON value of [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - /** - * Returns the raw JSON value of [tieredBpsConfig]. - * - * Unlike [tieredBpsConfig], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("tiered_bps_config") - @ExcludeMissing - fun _tieredBpsConfig(): JsonField = tieredBpsConfig - - /** - * Returns the raw JSON value of [billableMetricId]. - * - * Unlike [billableMetricId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = billableMetricId - - /** - * Returns the raw JSON value of [billedInAdvance]. - * - * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance - - /** - * Returns the raw JSON value of [billingCycleConfiguration]. - * - * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** - * Returns the raw JSON value of [conversionRate]. - * - * Unlike [conversionRate], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** - * Returns the raw JSON value of [conversionRateConfig]. - * - * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("conversion_rate_config") - @ExcludeMissing - fun _conversionRateConfig(): JsonField = conversionRateConfig - - /** - * Returns the raw JSON value of [dimensionalPriceConfiguration]. - * - * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("dimensional_price_configuration") - @ExcludeMissing - fun _dimensionalPriceConfiguration(): JsonField = - dimensionalPriceConfiguration - - /** - * Returns the raw JSON value of [externalPriceId]. - * - * Unlike [externalPriceId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * Returns the raw JSON value of [fixedPriceQuantity]. - * - * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** - * Returns the raw JSON value of [invoiceGroupingKey]. - * - * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Returns the raw JSON value of [invoicingCycleConfiguration]. - * - * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * Returns the raw JSON value of [metadata]. - * - * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [NewFloatingTieredBpsPrice]. - * - * The following fields are required: - * ```kotlin - * .cadence() - * .currency() - * .itemId() - * .modelType() - * .name() - * .tieredBpsConfig() - * ``` - */ - fun builder() = Builder() - } - - /** A builder for [NewFloatingTieredBpsPrice]. */ - class Builder internal constructor() { - - private var cadence: JsonField? = null - private var currency: JsonField? = null - private var itemId: JsonField? = null - private var modelType: JsonField? = null - private var name: JsonField? = null - private var tieredBpsConfig: JsonField? = null - private var billableMetricId: JsonField = JsonMissing.of() - private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var conversionRateConfig: JsonField = JsonMissing.of() - private var dimensionalPriceConfiguration: JsonField = - JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(newFloatingTieredBpsPrice: NewFloatingTieredBpsPrice) = apply { - cadence = newFloatingTieredBpsPrice.cadence - currency = newFloatingTieredBpsPrice.currency - itemId = newFloatingTieredBpsPrice.itemId - modelType = newFloatingTieredBpsPrice.modelType - name = newFloatingTieredBpsPrice.name - tieredBpsConfig = newFloatingTieredBpsPrice.tieredBpsConfig - billableMetricId = newFloatingTieredBpsPrice.billableMetricId - billedInAdvance = newFloatingTieredBpsPrice.billedInAdvance - billingCycleConfiguration = newFloatingTieredBpsPrice.billingCycleConfiguration - conversionRate = newFloatingTieredBpsPrice.conversionRate - conversionRateConfig = newFloatingTieredBpsPrice.conversionRateConfig - dimensionalPriceConfiguration = newFloatingTieredBpsPrice.dimensionalPriceConfiguration - externalPriceId = newFloatingTieredBpsPrice.externalPriceId - fixedPriceQuantity = newFloatingTieredBpsPrice.fixedPriceQuantity - invoiceGroupingKey = newFloatingTieredBpsPrice.invoiceGroupingKey - invoicingCycleConfiguration = newFloatingTieredBpsPrice.invoicingCycleConfiguration - metadata = newFloatingTieredBpsPrice.metadata - additionalProperties = newFloatingTieredBpsPrice.additionalProperties.toMutableMap() - } - - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** - * Sets [Builder.cadence] to an arbitrary JSON value. - * - * You should usually call [Builder.cadence] with a well-typed [Cadence] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - - /** An ISO 4217 currency string for which this price is billed in. */ - fun currency(currency: String) = currency(JsonField.of(currency)) - - /** - * Sets [Builder.currency] to an arbitrary JSON value. - * - * You should usually call [Builder.currency] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } - - /** The id of the item the price will be associated with. */ - fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - - /** - * Sets [Builder.itemId] to an arbitrary JSON value. - * - * You should usually call [Builder.itemId] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - - /** - * Sets [Builder.modelType] to an arbitrary JSON value. - * - * You should usually call [Builder.modelType] with a well-typed [ModelType] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun modelType(modelType: JsonField) = apply { this.modelType = modelType } - - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) - - /** - * Sets [Builder.name] to an arbitrary JSON value. - * - * You should usually call [Builder.name] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun name(name: JsonField) = apply { this.name = name } - - fun tieredBpsConfig(tieredBpsConfig: TieredBpsConfig) = - tieredBpsConfig(JsonField.of(tieredBpsConfig)) - - /** - * Sets [Builder.tieredBpsConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.tieredBpsConfig] with a well-typed [TieredBpsConfig] - * value instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun tieredBpsConfig(tieredBpsConfig: JsonField) = apply { - this.tieredBpsConfig = tieredBpsConfig - } - - /** The id of the billable metric for the price. Only needed if the price is usage-based. */ - fun billableMetricId(billableMetricId: String?) = - billableMetricId(JsonField.ofNullable(billableMetricId)) - - /** - * Sets [Builder.billableMetricId] to an arbitrary JSON value. - * - * You should usually call [Builder.billableMetricId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun billableMetricId(billableMetricId: JsonField) = apply { - this.billableMetricId = billableMetricId - } - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this is - * true, and in-arrears if this is false. - */ - fun billedInAdvance(billedInAdvance: Boolean?) = - billedInAdvance(JsonField.ofNullable(billedInAdvance)) - - /** - * Alias for [Builder.billedInAdvance]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun billedInAdvance(billedInAdvance: Boolean) = billedInAdvance(billedInAdvance as Boolean?) - - /** - * Sets [Builder.billedInAdvance] to an arbitrary JSON value. - * - * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun billedInAdvance(billedInAdvance: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** For custom cadence: specifies the duration of the billing period in days or months. */ - fun billingCycleConfiguration(billingCycleConfiguration: NewBillingCycleConfiguration?) = - billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - - /** - * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.billingCycleConfiguration] with a well-typed - * [NewBillingCycleConfiguration] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: JsonField - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double?) = - conversionRate(JsonField.ofNullable(conversionRate)) - - /** - * Alias for [Builder.conversionRate]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) - - /** - * Sets [Builder.conversionRate] to an arbitrary JSON value. - * - * You should usually call [Builder.conversionRate] with a well-typed [Double] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** The configuration for the rate of the price currency to the invoicing currency. */ - fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = - conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) - - /** - * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.conversionRateConfig] with a well-typed - * [ConversionRateConfig] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun conversionRateConfig(conversionRateConfig: JsonField) = apply { - this.conversionRateConfig = conversionRateConfig - } - - /** Alias for calling [conversionRateConfig] with `ConversionRateConfig.ofUnit(unit)`. */ - fun conversionRateConfig(unit: UnitConversionRateConfig) = - conversionRateConfig(ConversionRateConfig.ofUnit(unit)) - - /** - * Alias for calling [conversionRateConfig] with the following: - * ```kotlin - * UnitConversionRateConfig.builder() - * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) - * .unitConfig(unitConfig) - * .build() - * ``` - */ - fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = - conversionRateConfig( - UnitConversionRateConfig.builder() - .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) - .unitConfig(unitConfig) - .build() - ) - - /** - * Alias for calling [conversionRateConfig] with `ConversionRateConfig.ofTiered(tiered)`. - */ - fun conversionRateConfig(tiered: TieredConversionRateConfig) = - conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) - - /** - * Alias for calling [conversionRateConfig] with the following: - * ```kotlin - * TieredConversionRateConfig.builder() - * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) - * .tieredConfig(tieredConfig) - * .build() - * ``` - */ - fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = - conversionRateConfig( - TieredConversionRateConfig.builder() - .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) - .tieredConfig(tieredConfig) - .build() - ) - - /** For dimensional price: specifies a price group and dimension values */ - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? - ) = dimensionalPriceConfiguration(JsonField.ofNullable(dimensionalPriceConfiguration)) - - /** - * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.dimensionalPriceConfiguration] with a well-typed - * [NewDimensionalPriceConfiguration] value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: JsonField - ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** - * Sets [Builder.externalPriceId] to an arbitrary JSON value. - * - * You should usually call [Builder.externalPriceId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun externalPriceId(externalPriceId: JsonField) = apply { - this.externalPriceId = externalPriceId - } - - /** If the Price represents a fixed cost, this represents the quantity of units applied. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = - fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) - - /** - * Alias for [Builder.fixedPriceQuantity]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. - * - * You should usually call [Builder.fixedPriceQuantity] with a well-typed [Double] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = - invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) - - /** - * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. - * - * You should usually call [Builder.invoiceGroupingKey] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { - this.invoiceGroupingKey = invoiceGroupingKey - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. If - * unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: NewBillingCycleConfiguration? - ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) - - /** - * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.invoicingCycleConfiguration] with a well-typed - * [NewBillingCycleConfiguration] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by - * setting the value to `null`, and the entire metadata mapping can be cleared by setting - * `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * Sets [Builder.metadata] to an arbitrary JSON value. - * - * You should usually call [Builder.metadata] with a well-typed [Metadata] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [NewFloatingTieredBpsPrice]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```kotlin - * .cadence() - * .currency() - * .itemId() - * .modelType() - * .name() - * .tieredBpsConfig() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): NewFloatingTieredBpsPrice = - NewFloatingTieredBpsPrice( - checkRequired("cadence", cadence), - checkRequired("currency", currency), - checkRequired("itemId", itemId), - checkRequired("modelType", modelType), - checkRequired("name", name), - checkRequired("tieredBpsConfig", tieredBpsConfig), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - conversionRateConfig, - dimensionalPriceConfiguration, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): NewFloatingTieredBpsPrice = apply { - if (validated) { - return@apply - } - - cadence().validate() - currency() - itemId() - modelType().validate() - name() - tieredBpsConfig().validate() - billableMetricId() - billedInAdvance() - billingCycleConfiguration()?.validate() - conversionRate() - conversionRateConfig()?.validate() - dimensionalPriceConfiguration()?.validate() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration()?.validate() - metadata()?.validate() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (cadence.asKnown()?.validity() ?: 0) + - (if (currency.asKnown() == null) 0 else 1) + - (if (itemId.asKnown() == null) 0 else 1) + - (modelType.asKnown()?.validity() ?: 0) + - (if (name.asKnown() == null) 0 else 1) + - (tieredBpsConfig.asKnown()?.validity() ?: 0) + - (if (billableMetricId.asKnown() == null) 0 else 1) + - (if (billedInAdvance.asKnown() == null) 0 else 1) + - (billingCycleConfiguration.asKnown()?.validity() ?: 0) + - (if (conversionRate.asKnown() == null) 0 else 1) + - (conversionRateConfig.asKnown()?.validity() ?: 0) + - (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + - (if (externalPriceId.asKnown() == null) 0 else 1) + - (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + - (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + - (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + - (metadata.asKnown()?.validity() ?: 0) - - /** The cadence to bill for this price on. */ - class Cadence @JsonCreator private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API may respond with new members that the SDK is - * unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - val ANNUAL = of("annual") - - val SEMI_ANNUAL = of("semi_annual") - - val MONTHLY = of("monthly") - - val QUARTERLY = of("quarterly") - - val ONE_TIME = of("one_time") - - val CUSTOM = of("custom") - - fun of(value: String) = Cadence(JsonField.of(value)) - } - - /** An enum containing [Cadence]'s known values. */ - enum class Known { - ANNUAL, - SEMI_ANNUAL, - MONTHLY, - QUARTERLY, - ONE_TIME, - CUSTOM, - } - - /** - * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Cadence] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if the - * SDK is on an older version than the API, then the API may respond with new members that - * the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - ANNUAL, - SEMI_ANNUAL, - MONTHLY, - QUARTERLY, - ONE_TIME, - CUSTOM, - /** An enum member indicating that [Cadence] was instantiated with an unknown value. */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you want - * to throw for the unknown case. - */ - fun value(): Value = - when (this) { - ANNUAL -> Value.ANNUAL - SEMI_ANNUAL -> Value.SEMI_ANNUAL - MONTHLY -> Value.MONTHLY - QUARTERLY -> Value.QUARTERLY - ONE_TIME -> Value.ONE_TIME - CUSTOM -> Value.CUSTOM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and don't - * want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known member. - */ - fun known(): Known = - when (this) { - ANNUAL -> Known.ANNUAL - SEMI_ANNUAL -> Known.SEMI_ANNUAL - MONTHLY -> Known.MONTHLY - QUARTERLY -> Known.QUARTERLY - ONE_TIME -> Known.ONE_TIME - CUSTOM -> Known.CUSTOM - else -> throw OrbInvalidDataException("Unknown Cadence: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the expected - * primitive type. - */ - fun asString(): String = - _value().asString() ?: throw OrbInvalidDataException("Value is not a String") - - private var validated: Boolean = false - - fun validate(): Cadence = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Cadence && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class ModelType @JsonCreator private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API may respond with new members that the SDK is - * unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - val TIERED_BPS = of("tiered_bps") - - fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - TIERED_BPS - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if the - * SDK is on an older version than the API, then the API may respond with new members that - * the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - TIERED_BPS, - /** - * An enum member indicating that [ModelType] was instantiated with an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you want - * to throw for the unknown case. - */ - fun value(): Value = - when (this) { - TIERED_BPS -> Value.TIERED_BPS - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and don't - * want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known member. - */ - fun known(): Known = - when (this) { - TIERED_BPS -> Known.TIERED_BPS - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the expected - * primitive type. - */ - fun asString(): String = - _value().asString() ?: throw OrbInvalidDataException("Value is not a String") - - private var validated: Boolean = false - - fun validate(): ModelType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ModelType && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by setting - * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to - * `null`. - */ - class Metadata - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Metadata]. */ - fun builder() = Builder() - } - - /** A builder for [Metadata]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(metadata: Metadata) = apply { - additionalProperties = metadata.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Metadata]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Metadata && additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is NewFloatingTieredBpsPrice && - cadence == other.cadence && - currency == other.currency && - itemId == other.itemId && - modelType == other.modelType && - name == other.name && - tieredBpsConfig == other.tieredBpsConfig && - billableMetricId == other.billableMetricId && - billedInAdvance == other.billedInAdvance && - billingCycleConfiguration == other.billingCycleConfiguration && - conversionRate == other.conversionRate && - conversionRateConfig == other.conversionRateConfig && - dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && - externalPriceId == other.externalPriceId && - fixedPriceQuantity == other.fixedPriceQuantity && - invoiceGroupingKey == other.invoiceGroupingKey && - invoicingCycleConfiguration == other.invoicingCycleConfiguration && - metadata == other.metadata && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - cadence, - currency, - itemId, - modelType, - name, - tieredBpsConfig, - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - conversionRateConfig, - dimensionalPriceConfiguration, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewFloatingTieredBpsPrice{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, tieredBpsConfig=$tieredBpsConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" -} diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanBpsPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanBpsPrice.kt deleted file mode 100644 index bf906f1c4..000000000 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanBpsPrice.kt +++ /dev/null @@ -1,1367 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.withorb.api.models - -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import com.withorb.api.core.Enum -import com.withorb.api.core.ExcludeMissing -import com.withorb.api.core.JsonField -import com.withorb.api.core.JsonMissing -import com.withorb.api.core.JsonValue -import com.withorb.api.core.checkRequired -import com.withorb.api.core.toImmutable -import com.withorb.api.errors.OrbInvalidDataException -import java.util.Collections -import java.util.Objects - -class NewPlanBpsPrice -private constructor( - private val bpsConfig: JsonField, - private val cadence: JsonField, - private val itemId: JsonField, - private val modelType: JsonField, - private val name: JsonField, - private val billableMetricId: JsonField, - private val billedInAdvance: JsonField, - private val billingCycleConfiguration: JsonField, - private val conversionRate: JsonField, - private val conversionRateConfig: JsonField, - private val currency: JsonField, - private val dimensionalPriceConfiguration: JsonField, - private val externalPriceId: JsonField, - private val fixedPriceQuantity: JsonField, - private val invoiceGroupingKey: JsonField, - private val invoicingCycleConfiguration: JsonField, - private val metadata: JsonField, - private val referenceId: JsonField, - private val additionalProperties: MutableMap, -) { - - @JsonCreator - private constructor( - @JsonProperty("bps_config") - @ExcludeMissing - bpsConfig: JsonField = JsonMissing.of(), - @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), - @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - modelType: JsonField = JsonMissing.of(), - @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - billingCycleConfiguration: JsonField = JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("conversion_rate_config") - @ExcludeMissing - conversionRateConfig: JsonField = JsonMissing.of(), - @JsonProperty("currency") @ExcludeMissing currency: JsonField = JsonMissing.of(), - @JsonProperty("dimensional_price_configuration") - @ExcludeMissing - dimensionalPriceConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - invoicingCycleConfiguration: JsonField = JsonMissing.of(), - @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), - @JsonProperty("reference_id") - @ExcludeMissing - referenceId: JsonField = JsonMissing.of(), - ) : this( - bpsConfig, - cadence, - itemId, - modelType, - name, - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - conversionRateConfig, - currency, - dimensionalPriceConfiguration, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - mutableMapOf(), - ) - - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly - * missing or null (e.g. if the server responded with an unexpected value). - */ - fun bpsConfig(): BpsConfig = bpsConfig.getRequired("bps_config") - - /** - * The cadence to bill for this price on. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly - * missing or null (e.g. if the server responded with an unexpected value). - */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - /** - * The id of the item the price will be associated with. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly - * missing or null (e.g. if the server responded with an unexpected value). - */ - fun itemId(): String = itemId.getRequired("item_id") - - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly - * missing or null (e.g. if the server responded with an unexpected value). - */ - fun modelType(): ModelType = modelType.getRequired("model_type") - - /** - * The name of the price. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly - * missing or null (e.g. if the server responded with an unexpected value). - */ - fun name(): String = name.getRequired("name") - - /** - * The id of the billable metric for the price. Only needed if the price is usage-based. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - fun billableMetricId(): String? = billableMetricId.getNullable("billable_metric_id") - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this is true, - * and in-arrears if this is false. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") - - /** - * For custom cadence: specifies the duration of the billing period in days or months. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - fun billingCycleConfiguration(): NewBillingCycleConfiguration? = - billingCycleConfiguration.getNullable("billing_cycle_configuration") - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") - - /** - * The configuration for the rate of the price currency to the invoicing currency. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - fun conversionRateConfig(): ConversionRateConfig? = - conversionRateConfig.getNullable("conversion_rate_config") - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this price is - * billed. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - fun currency(): String? = currency.getNullable("currency") - - /** - * For dimensional price: specifies a price group and dimension values - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = - dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") - - /** - * An alias for the price. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") - - /** - * If the Price represents a fixed cost, this represents the quantity of units applied. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - fun fixedPriceQuantity(): Double? = fixedPriceQuantity.getNullable("fixed_price_quantity") - - /** - * The property used to group this price on an invoice - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - fun invoiceGroupingKey(): String? = invoiceGroupingKey.getNullable("invoice_grouping_key") - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. If - * unspecified, a single invoice is produced per billing cycle. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by setting - * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to - * `null`. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - fun metadata(): Metadata? = metadata.getNullable("metadata") - - /** - * A transient ID that can be used to reference this price when adding adjustments in the same - * API call. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - fun referenceId(): String? = referenceId.getNullable("reference_id") - - /** - * Returns the raw JSON value of [bpsConfig]. - * - * Unlike [bpsConfig], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("bps_config") @ExcludeMissing fun _bpsConfig(): JsonField = bpsConfig - - /** - * Returns the raw JSON value of [cadence]. - * - * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence - - /** - * Returns the raw JSON value of [itemId]. - * - * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - /** - * Returns the raw JSON value of [modelType]. - * - * Unlike [modelType], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonField = modelType - - /** - * Returns the raw JSON value of [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - /** - * Returns the raw JSON value of [billableMetricId]. - * - * Unlike [billableMetricId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = billableMetricId - - /** - * Returns the raw JSON value of [billedInAdvance]. - * - * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance - - /** - * Returns the raw JSON value of [billingCycleConfiguration]. - * - * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** - * Returns the raw JSON value of [conversionRate]. - * - * Unlike [conversionRate], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** - * Returns the raw JSON value of [conversionRateConfig]. - * - * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("conversion_rate_config") - @ExcludeMissing - fun _conversionRateConfig(): JsonField = conversionRateConfig - - /** - * Returns the raw JSON value of [currency]. - * - * Unlike [currency], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - - /** - * Returns the raw JSON value of [dimensionalPriceConfiguration]. - * - * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("dimensional_price_configuration") - @ExcludeMissing - fun _dimensionalPriceConfiguration(): JsonField = - dimensionalPriceConfiguration - - /** - * Returns the raw JSON value of [externalPriceId]. - * - * Unlike [externalPriceId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * Returns the raw JSON value of [fixedPriceQuantity]. - * - * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** - * Returns the raw JSON value of [invoiceGroupingKey]. - * - * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Returns the raw JSON value of [invoicingCycleConfiguration]. - * - * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * Returns the raw JSON value of [metadata]. - * - * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata - - /** - * Returns the raw JSON value of [referenceId]. - * - * Unlike [referenceId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("reference_id") - @ExcludeMissing - fun _referenceId(): JsonField = referenceId - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [NewPlanBpsPrice]. - * - * The following fields are required: - * ```kotlin - * .bpsConfig() - * .cadence() - * .itemId() - * .modelType() - * .name() - * ``` - */ - fun builder() = Builder() - } - - /** A builder for [NewPlanBpsPrice]. */ - class Builder internal constructor() { - - private var bpsConfig: JsonField? = null - private var cadence: JsonField? = null - private var itemId: JsonField? = null - private var modelType: JsonField? = null - private var name: JsonField? = null - private var billableMetricId: JsonField = JsonMissing.of() - private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var conversionRateConfig: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var dimensionalPriceConfiguration: JsonField = - JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var referenceId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(newPlanBpsPrice: NewPlanBpsPrice) = apply { - bpsConfig = newPlanBpsPrice.bpsConfig - cadence = newPlanBpsPrice.cadence - itemId = newPlanBpsPrice.itemId - modelType = newPlanBpsPrice.modelType - name = newPlanBpsPrice.name - billableMetricId = newPlanBpsPrice.billableMetricId - billedInAdvance = newPlanBpsPrice.billedInAdvance - billingCycleConfiguration = newPlanBpsPrice.billingCycleConfiguration - conversionRate = newPlanBpsPrice.conversionRate - conversionRateConfig = newPlanBpsPrice.conversionRateConfig - currency = newPlanBpsPrice.currency - dimensionalPriceConfiguration = newPlanBpsPrice.dimensionalPriceConfiguration - externalPriceId = newPlanBpsPrice.externalPriceId - fixedPriceQuantity = newPlanBpsPrice.fixedPriceQuantity - invoiceGroupingKey = newPlanBpsPrice.invoiceGroupingKey - invoicingCycleConfiguration = newPlanBpsPrice.invoicingCycleConfiguration - metadata = newPlanBpsPrice.metadata - referenceId = newPlanBpsPrice.referenceId - additionalProperties = newPlanBpsPrice.additionalProperties.toMutableMap() - } - - fun bpsConfig(bpsConfig: BpsConfig) = bpsConfig(JsonField.of(bpsConfig)) - - /** - * Sets [Builder.bpsConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.bpsConfig] with a well-typed [BpsConfig] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun bpsConfig(bpsConfig: JsonField) = apply { this.bpsConfig = bpsConfig } - - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** - * Sets [Builder.cadence] to an arbitrary JSON value. - * - * You should usually call [Builder.cadence] with a well-typed [Cadence] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - - /** The id of the item the price will be associated with. */ - fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - - /** - * Sets [Builder.itemId] to an arbitrary JSON value. - * - * You should usually call [Builder.itemId] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - - /** - * Sets [Builder.modelType] to an arbitrary JSON value. - * - * You should usually call [Builder.modelType] with a well-typed [ModelType] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun modelType(modelType: JsonField) = apply { this.modelType = modelType } - - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) - - /** - * Sets [Builder.name] to an arbitrary JSON value. - * - * You should usually call [Builder.name] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun name(name: JsonField) = apply { this.name = name } - - /** The id of the billable metric for the price. Only needed if the price is usage-based. */ - fun billableMetricId(billableMetricId: String?) = - billableMetricId(JsonField.ofNullable(billableMetricId)) - - /** - * Sets [Builder.billableMetricId] to an arbitrary JSON value. - * - * You should usually call [Builder.billableMetricId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun billableMetricId(billableMetricId: JsonField) = apply { - this.billableMetricId = billableMetricId - } - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this is - * true, and in-arrears if this is false. - */ - fun billedInAdvance(billedInAdvance: Boolean?) = - billedInAdvance(JsonField.ofNullable(billedInAdvance)) - - /** - * Alias for [Builder.billedInAdvance]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun billedInAdvance(billedInAdvance: Boolean) = billedInAdvance(billedInAdvance as Boolean?) - - /** - * Sets [Builder.billedInAdvance] to an arbitrary JSON value. - * - * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun billedInAdvance(billedInAdvance: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** For custom cadence: specifies the duration of the billing period in days or months. */ - fun billingCycleConfiguration(billingCycleConfiguration: NewBillingCycleConfiguration?) = - billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - - /** - * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.billingCycleConfiguration] with a well-typed - * [NewBillingCycleConfiguration] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: JsonField - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double?) = - conversionRate(JsonField.ofNullable(conversionRate)) - - /** - * Alias for [Builder.conversionRate]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) - - /** - * Sets [Builder.conversionRate] to an arbitrary JSON value. - * - * You should usually call [Builder.conversionRate] with a well-typed [Double] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** The configuration for the rate of the price currency to the invoicing currency. */ - fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = - conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) - - /** - * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.conversionRateConfig] with a well-typed - * [ConversionRateConfig] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun conversionRateConfig(conversionRateConfig: JsonField) = apply { - this.conversionRateConfig = conversionRateConfig - } - - /** Alias for calling [conversionRateConfig] with `ConversionRateConfig.ofUnit(unit)`. */ - fun conversionRateConfig(unit: UnitConversionRateConfig) = - conversionRateConfig(ConversionRateConfig.ofUnit(unit)) - - /** - * Alias for calling [conversionRateConfig] with the following: - * ```kotlin - * UnitConversionRateConfig.builder() - * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) - * .unitConfig(unitConfig) - * .build() - * ``` - */ - fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = - conversionRateConfig( - UnitConversionRateConfig.builder() - .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) - .unitConfig(unitConfig) - .build() - ) - - /** - * Alias for calling [conversionRateConfig] with `ConversionRateConfig.ofTiered(tiered)`. - */ - fun conversionRateConfig(tiered: TieredConversionRateConfig) = - conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) - - /** - * Alias for calling [conversionRateConfig] with the following: - * ```kotlin - * TieredConversionRateConfig.builder() - * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) - * .tieredConfig(tieredConfig) - * .build() - * ``` - */ - fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = - conversionRateConfig( - TieredConversionRateConfig.builder() - .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) - .tieredConfig(tieredConfig) - .build() - ) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this price is - * billed. - */ - fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) - - /** - * Sets [Builder.currency] to an arbitrary JSON value. - * - * You should usually call [Builder.currency] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } - - /** For dimensional price: specifies a price group and dimension values */ - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? - ) = dimensionalPriceConfiguration(JsonField.ofNullable(dimensionalPriceConfiguration)) - - /** - * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.dimensionalPriceConfiguration] with a well-typed - * [NewDimensionalPriceConfiguration] value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: JsonField - ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** - * Sets [Builder.externalPriceId] to an arbitrary JSON value. - * - * You should usually call [Builder.externalPriceId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun externalPriceId(externalPriceId: JsonField) = apply { - this.externalPriceId = externalPriceId - } - - /** If the Price represents a fixed cost, this represents the quantity of units applied. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = - fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) - - /** - * Alias for [Builder.fixedPriceQuantity]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. - * - * You should usually call [Builder.fixedPriceQuantity] with a well-typed [Double] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = - invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) - - /** - * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. - * - * You should usually call [Builder.invoiceGroupingKey] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { - this.invoiceGroupingKey = invoiceGroupingKey - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. If - * unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: NewBillingCycleConfiguration? - ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) - - /** - * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.invoicingCycleConfiguration] with a well-typed - * [NewBillingCycleConfiguration] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by - * setting the value to `null`, and the entire metadata mapping can be cleared by setting - * `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * Sets [Builder.metadata] to an arbitrary JSON value. - * - * You should usually call [Builder.metadata] with a well-typed [Metadata] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - - /** - * A transient ID that can be used to reference this price when adding adjustments in the - * same API call. - */ - fun referenceId(referenceId: String?) = referenceId(JsonField.ofNullable(referenceId)) - - /** - * Sets [Builder.referenceId] to an arbitrary JSON value. - * - * You should usually call [Builder.referenceId] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun referenceId(referenceId: JsonField) = apply { this.referenceId = referenceId } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [NewPlanBpsPrice]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```kotlin - * .bpsConfig() - * .cadence() - * .itemId() - * .modelType() - * .name() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): NewPlanBpsPrice = - NewPlanBpsPrice( - checkRequired("bpsConfig", bpsConfig), - checkRequired("cadence", cadence), - checkRequired("itemId", itemId), - checkRequired("modelType", modelType), - checkRequired("name", name), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - conversionRateConfig, - currency, - dimensionalPriceConfiguration, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): NewPlanBpsPrice = apply { - if (validated) { - return@apply - } - - bpsConfig().validate() - cadence().validate() - itemId() - modelType().validate() - name() - billableMetricId() - billedInAdvance() - billingCycleConfiguration()?.validate() - conversionRate() - conversionRateConfig()?.validate() - currency() - dimensionalPriceConfiguration()?.validate() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration()?.validate() - metadata()?.validate() - referenceId() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (bpsConfig.asKnown()?.validity() ?: 0) + - (cadence.asKnown()?.validity() ?: 0) + - (if (itemId.asKnown() == null) 0 else 1) + - (modelType.asKnown()?.validity() ?: 0) + - (if (name.asKnown() == null) 0 else 1) + - (if (billableMetricId.asKnown() == null) 0 else 1) + - (if (billedInAdvance.asKnown() == null) 0 else 1) + - (billingCycleConfiguration.asKnown()?.validity() ?: 0) + - (if (conversionRate.asKnown() == null) 0 else 1) + - (conversionRateConfig.asKnown()?.validity() ?: 0) + - (if (currency.asKnown() == null) 0 else 1) + - (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + - (if (externalPriceId.asKnown() == null) 0 else 1) + - (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + - (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + - (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + - (metadata.asKnown()?.validity() ?: 0) + - (if (referenceId.asKnown() == null) 0 else 1) - - /** The cadence to bill for this price on. */ - class Cadence @JsonCreator private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API may respond with new members that the SDK is - * unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - val ANNUAL = of("annual") - - val SEMI_ANNUAL = of("semi_annual") - - val MONTHLY = of("monthly") - - val QUARTERLY = of("quarterly") - - val ONE_TIME = of("one_time") - - val CUSTOM = of("custom") - - fun of(value: String) = Cadence(JsonField.of(value)) - } - - /** An enum containing [Cadence]'s known values. */ - enum class Known { - ANNUAL, - SEMI_ANNUAL, - MONTHLY, - QUARTERLY, - ONE_TIME, - CUSTOM, - } - - /** - * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Cadence] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if the - * SDK is on an older version than the API, then the API may respond with new members that - * the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - ANNUAL, - SEMI_ANNUAL, - MONTHLY, - QUARTERLY, - ONE_TIME, - CUSTOM, - /** An enum member indicating that [Cadence] was instantiated with an unknown value. */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you want - * to throw for the unknown case. - */ - fun value(): Value = - when (this) { - ANNUAL -> Value.ANNUAL - SEMI_ANNUAL -> Value.SEMI_ANNUAL - MONTHLY -> Value.MONTHLY - QUARTERLY -> Value.QUARTERLY - ONE_TIME -> Value.ONE_TIME - CUSTOM -> Value.CUSTOM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and don't - * want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known member. - */ - fun known(): Known = - when (this) { - ANNUAL -> Known.ANNUAL - SEMI_ANNUAL -> Known.SEMI_ANNUAL - MONTHLY -> Known.MONTHLY - QUARTERLY -> Known.QUARTERLY - ONE_TIME -> Known.ONE_TIME - CUSTOM -> Known.CUSTOM - else -> throw OrbInvalidDataException("Unknown Cadence: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the expected - * primitive type. - */ - fun asString(): String = - _value().asString() ?: throw OrbInvalidDataException("Value is not a String") - - private var validated: Boolean = false - - fun validate(): Cadence = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Cadence && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class ModelType @JsonCreator private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API may respond with new members that the SDK is - * unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - val BPS = of("bps") - - fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - BPS - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if the - * SDK is on an older version than the API, then the API may respond with new members that - * the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - BPS, - /** - * An enum member indicating that [ModelType] was instantiated with an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you want - * to throw for the unknown case. - */ - fun value(): Value = - when (this) { - BPS -> Value.BPS - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and don't - * want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known member. - */ - fun known(): Known = - when (this) { - BPS -> Known.BPS - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the expected - * primitive type. - */ - fun asString(): String = - _value().asString() ?: throw OrbInvalidDataException("Value is not a String") - - private var validated: Boolean = false - - fun validate(): ModelType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ModelType && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by setting - * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to - * `null`. - */ - class Metadata - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Metadata]. */ - fun builder() = Builder() - } - - /** A builder for [Metadata]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(metadata: Metadata) = apply { - additionalProperties = metadata.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Metadata]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Metadata && additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is NewPlanBpsPrice && - bpsConfig == other.bpsConfig && - cadence == other.cadence && - itemId == other.itemId && - modelType == other.modelType && - name == other.name && - billableMetricId == other.billableMetricId && - billedInAdvance == other.billedInAdvance && - billingCycleConfiguration == other.billingCycleConfiguration && - conversionRate == other.conversionRate && - conversionRateConfig == other.conversionRateConfig && - currency == other.currency && - dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && - externalPriceId == other.externalPriceId && - fixedPriceQuantity == other.fixedPriceQuantity && - invoiceGroupingKey == other.invoiceGroupingKey && - invoicingCycleConfiguration == other.invoicingCycleConfiguration && - metadata == other.metadata && - referenceId == other.referenceId && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - bpsConfig, - cadence, - itemId, - modelType, - name, - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - conversionRateConfig, - currency, - dimensionalPriceConfiguration, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewPlanBpsPrice{bpsConfig=$bpsConfig, cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" -} diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanBulkBpsPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanBulkBpsPrice.kt deleted file mode 100644 index fd537fdbc..000000000 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanBulkBpsPrice.kt +++ /dev/null @@ -1,1371 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.withorb.api.models - -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import com.withorb.api.core.Enum -import com.withorb.api.core.ExcludeMissing -import com.withorb.api.core.JsonField -import com.withorb.api.core.JsonMissing -import com.withorb.api.core.JsonValue -import com.withorb.api.core.checkRequired -import com.withorb.api.core.toImmutable -import com.withorb.api.errors.OrbInvalidDataException -import java.util.Collections -import java.util.Objects - -class NewPlanBulkBpsPrice -private constructor( - private val bulkBpsConfig: JsonField, - private val cadence: JsonField, - private val itemId: JsonField, - private val modelType: JsonField, - private val name: JsonField, - private val billableMetricId: JsonField, - private val billedInAdvance: JsonField, - private val billingCycleConfiguration: JsonField, - private val conversionRate: JsonField, - private val conversionRateConfig: JsonField, - private val currency: JsonField, - private val dimensionalPriceConfiguration: JsonField, - private val externalPriceId: JsonField, - private val fixedPriceQuantity: JsonField, - private val invoiceGroupingKey: JsonField, - private val invoicingCycleConfiguration: JsonField, - private val metadata: JsonField, - private val referenceId: JsonField, - private val additionalProperties: MutableMap, -) { - - @JsonCreator - private constructor( - @JsonProperty("bulk_bps_config") - @ExcludeMissing - bulkBpsConfig: JsonField = JsonMissing.of(), - @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), - @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - modelType: JsonField = JsonMissing.of(), - @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - billingCycleConfiguration: JsonField = JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("conversion_rate_config") - @ExcludeMissing - conversionRateConfig: JsonField = JsonMissing.of(), - @JsonProperty("currency") @ExcludeMissing currency: JsonField = JsonMissing.of(), - @JsonProperty("dimensional_price_configuration") - @ExcludeMissing - dimensionalPriceConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - invoicingCycleConfiguration: JsonField = JsonMissing.of(), - @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), - @JsonProperty("reference_id") - @ExcludeMissing - referenceId: JsonField = JsonMissing.of(), - ) : this( - bulkBpsConfig, - cadence, - itemId, - modelType, - name, - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - conversionRateConfig, - currency, - dimensionalPriceConfiguration, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - mutableMapOf(), - ) - - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly - * missing or null (e.g. if the server responded with an unexpected value). - */ - fun bulkBpsConfig(): BulkBpsConfig = bulkBpsConfig.getRequired("bulk_bps_config") - - /** - * The cadence to bill for this price on. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly - * missing or null (e.g. if the server responded with an unexpected value). - */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - /** - * The id of the item the price will be associated with. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly - * missing or null (e.g. if the server responded with an unexpected value). - */ - fun itemId(): String = itemId.getRequired("item_id") - - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly - * missing or null (e.g. if the server responded with an unexpected value). - */ - fun modelType(): ModelType = modelType.getRequired("model_type") - - /** - * The name of the price. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly - * missing or null (e.g. if the server responded with an unexpected value). - */ - fun name(): String = name.getRequired("name") - - /** - * The id of the billable metric for the price. Only needed if the price is usage-based. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - fun billableMetricId(): String? = billableMetricId.getNullable("billable_metric_id") - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this is true, - * and in-arrears if this is false. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") - - /** - * For custom cadence: specifies the duration of the billing period in days or months. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - fun billingCycleConfiguration(): NewBillingCycleConfiguration? = - billingCycleConfiguration.getNullable("billing_cycle_configuration") - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") - - /** - * The configuration for the rate of the price currency to the invoicing currency. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - fun conversionRateConfig(): ConversionRateConfig? = - conversionRateConfig.getNullable("conversion_rate_config") - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this price is - * billed. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - fun currency(): String? = currency.getNullable("currency") - - /** - * For dimensional price: specifies a price group and dimension values - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = - dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") - - /** - * An alias for the price. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") - - /** - * If the Price represents a fixed cost, this represents the quantity of units applied. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - fun fixedPriceQuantity(): Double? = fixedPriceQuantity.getNullable("fixed_price_quantity") - - /** - * The property used to group this price on an invoice - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - fun invoiceGroupingKey(): String? = invoiceGroupingKey.getNullable("invoice_grouping_key") - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. If - * unspecified, a single invoice is produced per billing cycle. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by setting - * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to - * `null`. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - fun metadata(): Metadata? = metadata.getNullable("metadata") - - /** - * A transient ID that can be used to reference this price when adding adjustments in the same - * API call. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - fun referenceId(): String? = referenceId.getNullable("reference_id") - - /** - * Returns the raw JSON value of [bulkBpsConfig]. - * - * Unlike [bulkBpsConfig], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("bulk_bps_config") - @ExcludeMissing - fun _bulkBpsConfig(): JsonField = bulkBpsConfig - - /** - * Returns the raw JSON value of [cadence]. - * - * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence - - /** - * Returns the raw JSON value of [itemId]. - * - * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - /** - * Returns the raw JSON value of [modelType]. - * - * Unlike [modelType], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonField = modelType - - /** - * Returns the raw JSON value of [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - /** - * Returns the raw JSON value of [billableMetricId]. - * - * Unlike [billableMetricId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = billableMetricId - - /** - * Returns the raw JSON value of [billedInAdvance]. - * - * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance - - /** - * Returns the raw JSON value of [billingCycleConfiguration]. - * - * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** - * Returns the raw JSON value of [conversionRate]. - * - * Unlike [conversionRate], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** - * Returns the raw JSON value of [conversionRateConfig]. - * - * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("conversion_rate_config") - @ExcludeMissing - fun _conversionRateConfig(): JsonField = conversionRateConfig - - /** - * Returns the raw JSON value of [currency]. - * - * Unlike [currency], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - - /** - * Returns the raw JSON value of [dimensionalPriceConfiguration]. - * - * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("dimensional_price_configuration") - @ExcludeMissing - fun _dimensionalPriceConfiguration(): JsonField = - dimensionalPriceConfiguration - - /** - * Returns the raw JSON value of [externalPriceId]. - * - * Unlike [externalPriceId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * Returns the raw JSON value of [fixedPriceQuantity]. - * - * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** - * Returns the raw JSON value of [invoiceGroupingKey]. - * - * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Returns the raw JSON value of [invoicingCycleConfiguration]. - * - * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * Returns the raw JSON value of [metadata]. - * - * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata - - /** - * Returns the raw JSON value of [referenceId]. - * - * Unlike [referenceId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("reference_id") - @ExcludeMissing - fun _referenceId(): JsonField = referenceId - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [NewPlanBulkBpsPrice]. - * - * The following fields are required: - * ```kotlin - * .bulkBpsConfig() - * .cadence() - * .itemId() - * .modelType() - * .name() - * ``` - */ - fun builder() = Builder() - } - - /** A builder for [NewPlanBulkBpsPrice]. */ - class Builder internal constructor() { - - private var bulkBpsConfig: JsonField? = null - private var cadence: JsonField? = null - private var itemId: JsonField? = null - private var modelType: JsonField? = null - private var name: JsonField? = null - private var billableMetricId: JsonField = JsonMissing.of() - private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var conversionRateConfig: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var dimensionalPriceConfiguration: JsonField = - JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var referenceId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(newPlanBulkBpsPrice: NewPlanBulkBpsPrice) = apply { - bulkBpsConfig = newPlanBulkBpsPrice.bulkBpsConfig - cadence = newPlanBulkBpsPrice.cadence - itemId = newPlanBulkBpsPrice.itemId - modelType = newPlanBulkBpsPrice.modelType - name = newPlanBulkBpsPrice.name - billableMetricId = newPlanBulkBpsPrice.billableMetricId - billedInAdvance = newPlanBulkBpsPrice.billedInAdvance - billingCycleConfiguration = newPlanBulkBpsPrice.billingCycleConfiguration - conversionRate = newPlanBulkBpsPrice.conversionRate - conversionRateConfig = newPlanBulkBpsPrice.conversionRateConfig - currency = newPlanBulkBpsPrice.currency - dimensionalPriceConfiguration = newPlanBulkBpsPrice.dimensionalPriceConfiguration - externalPriceId = newPlanBulkBpsPrice.externalPriceId - fixedPriceQuantity = newPlanBulkBpsPrice.fixedPriceQuantity - invoiceGroupingKey = newPlanBulkBpsPrice.invoiceGroupingKey - invoicingCycleConfiguration = newPlanBulkBpsPrice.invoicingCycleConfiguration - metadata = newPlanBulkBpsPrice.metadata - referenceId = newPlanBulkBpsPrice.referenceId - additionalProperties = newPlanBulkBpsPrice.additionalProperties.toMutableMap() - } - - fun bulkBpsConfig(bulkBpsConfig: BulkBpsConfig) = bulkBpsConfig(JsonField.of(bulkBpsConfig)) - - /** - * Sets [Builder.bulkBpsConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.bulkBpsConfig] with a well-typed [BulkBpsConfig] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun bulkBpsConfig(bulkBpsConfig: JsonField) = apply { - this.bulkBpsConfig = bulkBpsConfig - } - - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** - * Sets [Builder.cadence] to an arbitrary JSON value. - * - * You should usually call [Builder.cadence] with a well-typed [Cadence] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - - /** The id of the item the price will be associated with. */ - fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - - /** - * Sets [Builder.itemId] to an arbitrary JSON value. - * - * You should usually call [Builder.itemId] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - - /** - * Sets [Builder.modelType] to an arbitrary JSON value. - * - * You should usually call [Builder.modelType] with a well-typed [ModelType] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun modelType(modelType: JsonField) = apply { this.modelType = modelType } - - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) - - /** - * Sets [Builder.name] to an arbitrary JSON value. - * - * You should usually call [Builder.name] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun name(name: JsonField) = apply { this.name = name } - - /** The id of the billable metric for the price. Only needed if the price is usage-based. */ - fun billableMetricId(billableMetricId: String?) = - billableMetricId(JsonField.ofNullable(billableMetricId)) - - /** - * Sets [Builder.billableMetricId] to an arbitrary JSON value. - * - * You should usually call [Builder.billableMetricId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun billableMetricId(billableMetricId: JsonField) = apply { - this.billableMetricId = billableMetricId - } - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this is - * true, and in-arrears if this is false. - */ - fun billedInAdvance(billedInAdvance: Boolean?) = - billedInAdvance(JsonField.ofNullable(billedInAdvance)) - - /** - * Alias for [Builder.billedInAdvance]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun billedInAdvance(billedInAdvance: Boolean) = billedInAdvance(billedInAdvance as Boolean?) - - /** - * Sets [Builder.billedInAdvance] to an arbitrary JSON value. - * - * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun billedInAdvance(billedInAdvance: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** For custom cadence: specifies the duration of the billing period in days or months. */ - fun billingCycleConfiguration(billingCycleConfiguration: NewBillingCycleConfiguration?) = - billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - - /** - * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.billingCycleConfiguration] with a well-typed - * [NewBillingCycleConfiguration] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: JsonField - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double?) = - conversionRate(JsonField.ofNullable(conversionRate)) - - /** - * Alias for [Builder.conversionRate]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) - - /** - * Sets [Builder.conversionRate] to an arbitrary JSON value. - * - * You should usually call [Builder.conversionRate] with a well-typed [Double] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** The configuration for the rate of the price currency to the invoicing currency. */ - fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = - conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) - - /** - * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.conversionRateConfig] with a well-typed - * [ConversionRateConfig] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun conversionRateConfig(conversionRateConfig: JsonField) = apply { - this.conversionRateConfig = conversionRateConfig - } - - /** Alias for calling [conversionRateConfig] with `ConversionRateConfig.ofUnit(unit)`. */ - fun conversionRateConfig(unit: UnitConversionRateConfig) = - conversionRateConfig(ConversionRateConfig.ofUnit(unit)) - - /** - * Alias for calling [conversionRateConfig] with the following: - * ```kotlin - * UnitConversionRateConfig.builder() - * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) - * .unitConfig(unitConfig) - * .build() - * ``` - */ - fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = - conversionRateConfig( - UnitConversionRateConfig.builder() - .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) - .unitConfig(unitConfig) - .build() - ) - - /** - * Alias for calling [conversionRateConfig] with `ConversionRateConfig.ofTiered(tiered)`. - */ - fun conversionRateConfig(tiered: TieredConversionRateConfig) = - conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) - - /** - * Alias for calling [conversionRateConfig] with the following: - * ```kotlin - * TieredConversionRateConfig.builder() - * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) - * .tieredConfig(tieredConfig) - * .build() - * ``` - */ - fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = - conversionRateConfig( - TieredConversionRateConfig.builder() - .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) - .tieredConfig(tieredConfig) - .build() - ) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this price is - * billed. - */ - fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) - - /** - * Sets [Builder.currency] to an arbitrary JSON value. - * - * You should usually call [Builder.currency] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } - - /** For dimensional price: specifies a price group and dimension values */ - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? - ) = dimensionalPriceConfiguration(JsonField.ofNullable(dimensionalPriceConfiguration)) - - /** - * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.dimensionalPriceConfiguration] with a well-typed - * [NewDimensionalPriceConfiguration] value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: JsonField - ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** - * Sets [Builder.externalPriceId] to an arbitrary JSON value. - * - * You should usually call [Builder.externalPriceId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun externalPriceId(externalPriceId: JsonField) = apply { - this.externalPriceId = externalPriceId - } - - /** If the Price represents a fixed cost, this represents the quantity of units applied. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = - fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) - - /** - * Alias for [Builder.fixedPriceQuantity]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. - * - * You should usually call [Builder.fixedPriceQuantity] with a well-typed [Double] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = - invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) - - /** - * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. - * - * You should usually call [Builder.invoiceGroupingKey] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { - this.invoiceGroupingKey = invoiceGroupingKey - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. If - * unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: NewBillingCycleConfiguration? - ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) - - /** - * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.invoicingCycleConfiguration] with a well-typed - * [NewBillingCycleConfiguration] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by - * setting the value to `null`, and the entire metadata mapping can be cleared by setting - * `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * Sets [Builder.metadata] to an arbitrary JSON value. - * - * You should usually call [Builder.metadata] with a well-typed [Metadata] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - - /** - * A transient ID that can be used to reference this price when adding adjustments in the - * same API call. - */ - fun referenceId(referenceId: String?) = referenceId(JsonField.ofNullable(referenceId)) - - /** - * Sets [Builder.referenceId] to an arbitrary JSON value. - * - * You should usually call [Builder.referenceId] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun referenceId(referenceId: JsonField) = apply { this.referenceId = referenceId } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [NewPlanBulkBpsPrice]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```kotlin - * .bulkBpsConfig() - * .cadence() - * .itemId() - * .modelType() - * .name() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): NewPlanBulkBpsPrice = - NewPlanBulkBpsPrice( - checkRequired("bulkBpsConfig", bulkBpsConfig), - checkRequired("cadence", cadence), - checkRequired("itemId", itemId), - checkRequired("modelType", modelType), - checkRequired("name", name), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - conversionRateConfig, - currency, - dimensionalPriceConfiguration, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): NewPlanBulkBpsPrice = apply { - if (validated) { - return@apply - } - - bulkBpsConfig().validate() - cadence().validate() - itemId() - modelType().validate() - name() - billableMetricId() - billedInAdvance() - billingCycleConfiguration()?.validate() - conversionRate() - conversionRateConfig()?.validate() - currency() - dimensionalPriceConfiguration()?.validate() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration()?.validate() - metadata()?.validate() - referenceId() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (bulkBpsConfig.asKnown()?.validity() ?: 0) + - (cadence.asKnown()?.validity() ?: 0) + - (if (itemId.asKnown() == null) 0 else 1) + - (modelType.asKnown()?.validity() ?: 0) + - (if (name.asKnown() == null) 0 else 1) + - (if (billableMetricId.asKnown() == null) 0 else 1) + - (if (billedInAdvance.asKnown() == null) 0 else 1) + - (billingCycleConfiguration.asKnown()?.validity() ?: 0) + - (if (conversionRate.asKnown() == null) 0 else 1) + - (conversionRateConfig.asKnown()?.validity() ?: 0) + - (if (currency.asKnown() == null) 0 else 1) + - (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + - (if (externalPriceId.asKnown() == null) 0 else 1) + - (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + - (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + - (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + - (metadata.asKnown()?.validity() ?: 0) + - (if (referenceId.asKnown() == null) 0 else 1) - - /** The cadence to bill for this price on. */ - class Cadence @JsonCreator private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API may respond with new members that the SDK is - * unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - val ANNUAL = of("annual") - - val SEMI_ANNUAL = of("semi_annual") - - val MONTHLY = of("monthly") - - val QUARTERLY = of("quarterly") - - val ONE_TIME = of("one_time") - - val CUSTOM = of("custom") - - fun of(value: String) = Cadence(JsonField.of(value)) - } - - /** An enum containing [Cadence]'s known values. */ - enum class Known { - ANNUAL, - SEMI_ANNUAL, - MONTHLY, - QUARTERLY, - ONE_TIME, - CUSTOM, - } - - /** - * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Cadence] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if the - * SDK is on an older version than the API, then the API may respond with new members that - * the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - ANNUAL, - SEMI_ANNUAL, - MONTHLY, - QUARTERLY, - ONE_TIME, - CUSTOM, - /** An enum member indicating that [Cadence] was instantiated with an unknown value. */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you want - * to throw for the unknown case. - */ - fun value(): Value = - when (this) { - ANNUAL -> Value.ANNUAL - SEMI_ANNUAL -> Value.SEMI_ANNUAL - MONTHLY -> Value.MONTHLY - QUARTERLY -> Value.QUARTERLY - ONE_TIME -> Value.ONE_TIME - CUSTOM -> Value.CUSTOM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and don't - * want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known member. - */ - fun known(): Known = - when (this) { - ANNUAL -> Known.ANNUAL - SEMI_ANNUAL -> Known.SEMI_ANNUAL - MONTHLY -> Known.MONTHLY - QUARTERLY -> Known.QUARTERLY - ONE_TIME -> Known.ONE_TIME - CUSTOM -> Known.CUSTOM - else -> throw OrbInvalidDataException("Unknown Cadence: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the expected - * primitive type. - */ - fun asString(): String = - _value().asString() ?: throw OrbInvalidDataException("Value is not a String") - - private var validated: Boolean = false - - fun validate(): Cadence = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Cadence && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class ModelType @JsonCreator private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API may respond with new members that the SDK is - * unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - val BULK_BPS = of("bulk_bps") - - fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - BULK_BPS - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if the - * SDK is on an older version than the API, then the API may respond with new members that - * the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - BULK_BPS, - /** - * An enum member indicating that [ModelType] was instantiated with an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you want - * to throw for the unknown case. - */ - fun value(): Value = - when (this) { - BULK_BPS -> Value.BULK_BPS - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and don't - * want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known member. - */ - fun known(): Known = - when (this) { - BULK_BPS -> Known.BULK_BPS - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the expected - * primitive type. - */ - fun asString(): String = - _value().asString() ?: throw OrbInvalidDataException("Value is not a String") - - private var validated: Boolean = false - - fun validate(): ModelType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ModelType && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by setting - * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to - * `null`. - */ - class Metadata - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Metadata]. */ - fun builder() = Builder() - } - - /** A builder for [Metadata]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(metadata: Metadata) = apply { - additionalProperties = metadata.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Metadata]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Metadata && additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is NewPlanBulkBpsPrice && - bulkBpsConfig == other.bulkBpsConfig && - cadence == other.cadence && - itemId == other.itemId && - modelType == other.modelType && - name == other.name && - billableMetricId == other.billableMetricId && - billedInAdvance == other.billedInAdvance && - billingCycleConfiguration == other.billingCycleConfiguration && - conversionRate == other.conversionRate && - conversionRateConfig == other.conversionRateConfig && - currency == other.currency && - dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && - externalPriceId == other.externalPriceId && - fixedPriceQuantity == other.fixedPriceQuantity && - invoiceGroupingKey == other.invoiceGroupingKey && - invoicingCycleConfiguration == other.invoicingCycleConfiguration && - metadata == other.metadata && - referenceId == other.referenceId && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - bulkBpsConfig, - cadence, - itemId, - modelType, - name, - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - conversionRateConfig, - currency, - dimensionalPriceConfiguration, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewPlanBulkBpsPrice{bulkBpsConfig=$bulkBpsConfig, cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" -} diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanTieredBpsPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanTieredBpsPrice.kt deleted file mode 100644 index 55cbd708b..000000000 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanTieredBpsPrice.kt +++ /dev/null @@ -1,1372 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.withorb.api.models - -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import com.withorb.api.core.Enum -import com.withorb.api.core.ExcludeMissing -import com.withorb.api.core.JsonField -import com.withorb.api.core.JsonMissing -import com.withorb.api.core.JsonValue -import com.withorb.api.core.checkRequired -import com.withorb.api.core.toImmutable -import com.withorb.api.errors.OrbInvalidDataException -import java.util.Collections -import java.util.Objects - -class NewPlanTieredBpsPrice -private constructor( - private val cadence: JsonField, - private val itemId: JsonField, - private val modelType: JsonField, - private val name: JsonField, - private val tieredBpsConfig: JsonField, - private val billableMetricId: JsonField, - private val billedInAdvance: JsonField, - private val billingCycleConfiguration: JsonField, - private val conversionRate: JsonField, - private val conversionRateConfig: JsonField, - private val currency: JsonField, - private val dimensionalPriceConfiguration: JsonField, - private val externalPriceId: JsonField, - private val fixedPriceQuantity: JsonField, - private val invoiceGroupingKey: JsonField, - private val invoicingCycleConfiguration: JsonField, - private val metadata: JsonField, - private val referenceId: JsonField, - private val additionalProperties: MutableMap, -) { - - @JsonCreator - private constructor( - @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), - @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - modelType: JsonField = JsonMissing.of(), - @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("tiered_bps_config") - @ExcludeMissing - tieredBpsConfig: JsonField = JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - billingCycleConfiguration: JsonField = JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("conversion_rate_config") - @ExcludeMissing - conversionRateConfig: JsonField = JsonMissing.of(), - @JsonProperty("currency") @ExcludeMissing currency: JsonField = JsonMissing.of(), - @JsonProperty("dimensional_price_configuration") - @ExcludeMissing - dimensionalPriceConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - invoicingCycleConfiguration: JsonField = JsonMissing.of(), - @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), - @JsonProperty("reference_id") - @ExcludeMissing - referenceId: JsonField = JsonMissing.of(), - ) : this( - cadence, - itemId, - modelType, - name, - tieredBpsConfig, - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - conversionRateConfig, - currency, - dimensionalPriceConfiguration, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - mutableMapOf(), - ) - - /** - * The cadence to bill for this price on. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly - * missing or null (e.g. if the server responded with an unexpected value). - */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - /** - * The id of the item the price will be associated with. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly - * missing or null (e.g. if the server responded with an unexpected value). - */ - fun itemId(): String = itemId.getRequired("item_id") - - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly - * missing or null (e.g. if the server responded with an unexpected value). - */ - fun modelType(): ModelType = modelType.getRequired("model_type") - - /** - * The name of the price. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly - * missing or null (e.g. if the server responded with an unexpected value). - */ - fun name(): String = name.getRequired("name") - - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly - * missing or null (e.g. if the server responded with an unexpected value). - */ - fun tieredBpsConfig(): TieredBpsConfig = tieredBpsConfig.getRequired("tiered_bps_config") - - /** - * The id of the billable metric for the price. Only needed if the price is usage-based. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - fun billableMetricId(): String? = billableMetricId.getNullable("billable_metric_id") - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this is true, - * and in-arrears if this is false. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") - - /** - * For custom cadence: specifies the duration of the billing period in days or months. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - fun billingCycleConfiguration(): NewBillingCycleConfiguration? = - billingCycleConfiguration.getNullable("billing_cycle_configuration") - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") - - /** - * The configuration for the rate of the price currency to the invoicing currency. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - fun conversionRateConfig(): ConversionRateConfig? = - conversionRateConfig.getNullable("conversion_rate_config") - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this price is - * billed. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - fun currency(): String? = currency.getNullable("currency") - - /** - * For dimensional price: specifies a price group and dimension values - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = - dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") - - /** - * An alias for the price. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") - - /** - * If the Price represents a fixed cost, this represents the quantity of units applied. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - fun fixedPriceQuantity(): Double? = fixedPriceQuantity.getNullable("fixed_price_quantity") - - /** - * The property used to group this price on an invoice - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - fun invoiceGroupingKey(): String? = invoiceGroupingKey.getNullable("invoice_grouping_key") - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. If - * unspecified, a single invoice is produced per billing cycle. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by setting - * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to - * `null`. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - fun metadata(): Metadata? = metadata.getNullable("metadata") - - /** - * A transient ID that can be used to reference this price when adding adjustments in the same - * API call. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - fun referenceId(): String? = referenceId.getNullable("reference_id") - - /** - * Returns the raw JSON value of [cadence]. - * - * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence - - /** - * Returns the raw JSON value of [itemId]. - * - * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - /** - * Returns the raw JSON value of [modelType]. - * - * Unlike [modelType], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonField = modelType - - /** - * Returns the raw JSON value of [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - /** - * Returns the raw JSON value of [tieredBpsConfig]. - * - * Unlike [tieredBpsConfig], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("tiered_bps_config") - @ExcludeMissing - fun _tieredBpsConfig(): JsonField = tieredBpsConfig - - /** - * Returns the raw JSON value of [billableMetricId]. - * - * Unlike [billableMetricId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = billableMetricId - - /** - * Returns the raw JSON value of [billedInAdvance]. - * - * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance - - /** - * Returns the raw JSON value of [billingCycleConfiguration]. - * - * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** - * Returns the raw JSON value of [conversionRate]. - * - * Unlike [conversionRate], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** - * Returns the raw JSON value of [conversionRateConfig]. - * - * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("conversion_rate_config") - @ExcludeMissing - fun _conversionRateConfig(): JsonField = conversionRateConfig - - /** - * Returns the raw JSON value of [currency]. - * - * Unlike [currency], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - - /** - * Returns the raw JSON value of [dimensionalPriceConfiguration]. - * - * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("dimensional_price_configuration") - @ExcludeMissing - fun _dimensionalPriceConfiguration(): JsonField = - dimensionalPriceConfiguration - - /** - * Returns the raw JSON value of [externalPriceId]. - * - * Unlike [externalPriceId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * Returns the raw JSON value of [fixedPriceQuantity]. - * - * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** - * Returns the raw JSON value of [invoiceGroupingKey]. - * - * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Returns the raw JSON value of [invoicingCycleConfiguration]. - * - * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * Returns the raw JSON value of [metadata]. - * - * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata - - /** - * Returns the raw JSON value of [referenceId]. - * - * Unlike [referenceId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("reference_id") - @ExcludeMissing - fun _referenceId(): JsonField = referenceId - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [NewPlanTieredBpsPrice]. - * - * The following fields are required: - * ```kotlin - * .cadence() - * .itemId() - * .modelType() - * .name() - * .tieredBpsConfig() - * ``` - */ - fun builder() = Builder() - } - - /** A builder for [NewPlanTieredBpsPrice]. */ - class Builder internal constructor() { - - private var cadence: JsonField? = null - private var itemId: JsonField? = null - private var modelType: JsonField? = null - private var name: JsonField? = null - private var tieredBpsConfig: JsonField? = null - private var billableMetricId: JsonField = JsonMissing.of() - private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var conversionRateConfig: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var dimensionalPriceConfiguration: JsonField = - JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var referenceId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(newPlanTieredBpsPrice: NewPlanTieredBpsPrice) = apply { - cadence = newPlanTieredBpsPrice.cadence - itemId = newPlanTieredBpsPrice.itemId - modelType = newPlanTieredBpsPrice.modelType - name = newPlanTieredBpsPrice.name - tieredBpsConfig = newPlanTieredBpsPrice.tieredBpsConfig - billableMetricId = newPlanTieredBpsPrice.billableMetricId - billedInAdvance = newPlanTieredBpsPrice.billedInAdvance - billingCycleConfiguration = newPlanTieredBpsPrice.billingCycleConfiguration - conversionRate = newPlanTieredBpsPrice.conversionRate - conversionRateConfig = newPlanTieredBpsPrice.conversionRateConfig - currency = newPlanTieredBpsPrice.currency - dimensionalPriceConfiguration = newPlanTieredBpsPrice.dimensionalPriceConfiguration - externalPriceId = newPlanTieredBpsPrice.externalPriceId - fixedPriceQuantity = newPlanTieredBpsPrice.fixedPriceQuantity - invoiceGroupingKey = newPlanTieredBpsPrice.invoiceGroupingKey - invoicingCycleConfiguration = newPlanTieredBpsPrice.invoicingCycleConfiguration - metadata = newPlanTieredBpsPrice.metadata - referenceId = newPlanTieredBpsPrice.referenceId - additionalProperties = newPlanTieredBpsPrice.additionalProperties.toMutableMap() - } - - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** - * Sets [Builder.cadence] to an arbitrary JSON value. - * - * You should usually call [Builder.cadence] with a well-typed [Cadence] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - - /** The id of the item the price will be associated with. */ - fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - - /** - * Sets [Builder.itemId] to an arbitrary JSON value. - * - * You should usually call [Builder.itemId] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - - /** - * Sets [Builder.modelType] to an arbitrary JSON value. - * - * You should usually call [Builder.modelType] with a well-typed [ModelType] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun modelType(modelType: JsonField) = apply { this.modelType = modelType } - - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) - - /** - * Sets [Builder.name] to an arbitrary JSON value. - * - * You should usually call [Builder.name] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun name(name: JsonField) = apply { this.name = name } - - fun tieredBpsConfig(tieredBpsConfig: TieredBpsConfig) = - tieredBpsConfig(JsonField.of(tieredBpsConfig)) - - /** - * Sets [Builder.tieredBpsConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.tieredBpsConfig] with a well-typed [TieredBpsConfig] - * value instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun tieredBpsConfig(tieredBpsConfig: JsonField) = apply { - this.tieredBpsConfig = tieredBpsConfig - } - - /** The id of the billable metric for the price. Only needed if the price is usage-based. */ - fun billableMetricId(billableMetricId: String?) = - billableMetricId(JsonField.ofNullable(billableMetricId)) - - /** - * Sets [Builder.billableMetricId] to an arbitrary JSON value. - * - * You should usually call [Builder.billableMetricId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun billableMetricId(billableMetricId: JsonField) = apply { - this.billableMetricId = billableMetricId - } - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this is - * true, and in-arrears if this is false. - */ - fun billedInAdvance(billedInAdvance: Boolean?) = - billedInAdvance(JsonField.ofNullable(billedInAdvance)) - - /** - * Alias for [Builder.billedInAdvance]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun billedInAdvance(billedInAdvance: Boolean) = billedInAdvance(billedInAdvance as Boolean?) - - /** - * Sets [Builder.billedInAdvance] to an arbitrary JSON value. - * - * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun billedInAdvance(billedInAdvance: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** For custom cadence: specifies the duration of the billing period in days or months. */ - fun billingCycleConfiguration(billingCycleConfiguration: NewBillingCycleConfiguration?) = - billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - - /** - * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.billingCycleConfiguration] with a well-typed - * [NewBillingCycleConfiguration] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: JsonField - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double?) = - conversionRate(JsonField.ofNullable(conversionRate)) - - /** - * Alias for [Builder.conversionRate]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) - - /** - * Sets [Builder.conversionRate] to an arbitrary JSON value. - * - * You should usually call [Builder.conversionRate] with a well-typed [Double] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** The configuration for the rate of the price currency to the invoicing currency. */ - fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = - conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) - - /** - * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.conversionRateConfig] with a well-typed - * [ConversionRateConfig] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun conversionRateConfig(conversionRateConfig: JsonField) = apply { - this.conversionRateConfig = conversionRateConfig - } - - /** Alias for calling [conversionRateConfig] with `ConversionRateConfig.ofUnit(unit)`. */ - fun conversionRateConfig(unit: UnitConversionRateConfig) = - conversionRateConfig(ConversionRateConfig.ofUnit(unit)) - - /** - * Alias for calling [conversionRateConfig] with the following: - * ```kotlin - * UnitConversionRateConfig.builder() - * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) - * .unitConfig(unitConfig) - * .build() - * ``` - */ - fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = - conversionRateConfig( - UnitConversionRateConfig.builder() - .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) - .unitConfig(unitConfig) - .build() - ) - - /** - * Alias for calling [conversionRateConfig] with `ConversionRateConfig.ofTiered(tiered)`. - */ - fun conversionRateConfig(tiered: TieredConversionRateConfig) = - conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) - - /** - * Alias for calling [conversionRateConfig] with the following: - * ```kotlin - * TieredConversionRateConfig.builder() - * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) - * .tieredConfig(tieredConfig) - * .build() - * ``` - */ - fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = - conversionRateConfig( - TieredConversionRateConfig.builder() - .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) - .tieredConfig(tieredConfig) - .build() - ) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this price is - * billed. - */ - fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) - - /** - * Sets [Builder.currency] to an arbitrary JSON value. - * - * You should usually call [Builder.currency] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } - - /** For dimensional price: specifies a price group and dimension values */ - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? - ) = dimensionalPriceConfiguration(JsonField.ofNullable(dimensionalPriceConfiguration)) - - /** - * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.dimensionalPriceConfiguration] with a well-typed - * [NewDimensionalPriceConfiguration] value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: JsonField - ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** - * Sets [Builder.externalPriceId] to an arbitrary JSON value. - * - * You should usually call [Builder.externalPriceId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun externalPriceId(externalPriceId: JsonField) = apply { - this.externalPriceId = externalPriceId - } - - /** If the Price represents a fixed cost, this represents the quantity of units applied. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = - fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) - - /** - * Alias for [Builder.fixedPriceQuantity]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. - * - * You should usually call [Builder.fixedPriceQuantity] with a well-typed [Double] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = - invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) - - /** - * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. - * - * You should usually call [Builder.invoiceGroupingKey] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { - this.invoiceGroupingKey = invoiceGroupingKey - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. If - * unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: NewBillingCycleConfiguration? - ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) - - /** - * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.invoicingCycleConfiguration] with a well-typed - * [NewBillingCycleConfiguration] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by - * setting the value to `null`, and the entire metadata mapping can be cleared by setting - * `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * Sets [Builder.metadata] to an arbitrary JSON value. - * - * You should usually call [Builder.metadata] with a well-typed [Metadata] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - - /** - * A transient ID that can be used to reference this price when adding adjustments in the - * same API call. - */ - fun referenceId(referenceId: String?) = referenceId(JsonField.ofNullable(referenceId)) - - /** - * Sets [Builder.referenceId] to an arbitrary JSON value. - * - * You should usually call [Builder.referenceId] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun referenceId(referenceId: JsonField) = apply { this.referenceId = referenceId } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [NewPlanTieredBpsPrice]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```kotlin - * .cadence() - * .itemId() - * .modelType() - * .name() - * .tieredBpsConfig() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): NewPlanTieredBpsPrice = - NewPlanTieredBpsPrice( - checkRequired("cadence", cadence), - checkRequired("itemId", itemId), - checkRequired("modelType", modelType), - checkRequired("name", name), - checkRequired("tieredBpsConfig", tieredBpsConfig), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - conversionRateConfig, - currency, - dimensionalPriceConfiguration, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): NewPlanTieredBpsPrice = apply { - if (validated) { - return@apply - } - - cadence().validate() - itemId() - modelType().validate() - name() - tieredBpsConfig().validate() - billableMetricId() - billedInAdvance() - billingCycleConfiguration()?.validate() - conversionRate() - conversionRateConfig()?.validate() - currency() - dimensionalPriceConfiguration()?.validate() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration()?.validate() - metadata()?.validate() - referenceId() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (cadence.asKnown()?.validity() ?: 0) + - (if (itemId.asKnown() == null) 0 else 1) + - (modelType.asKnown()?.validity() ?: 0) + - (if (name.asKnown() == null) 0 else 1) + - (tieredBpsConfig.asKnown()?.validity() ?: 0) + - (if (billableMetricId.asKnown() == null) 0 else 1) + - (if (billedInAdvance.asKnown() == null) 0 else 1) + - (billingCycleConfiguration.asKnown()?.validity() ?: 0) + - (if (conversionRate.asKnown() == null) 0 else 1) + - (conversionRateConfig.asKnown()?.validity() ?: 0) + - (if (currency.asKnown() == null) 0 else 1) + - (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + - (if (externalPriceId.asKnown() == null) 0 else 1) + - (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + - (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + - (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + - (metadata.asKnown()?.validity() ?: 0) + - (if (referenceId.asKnown() == null) 0 else 1) - - /** The cadence to bill for this price on. */ - class Cadence @JsonCreator private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API may respond with new members that the SDK is - * unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - val ANNUAL = of("annual") - - val SEMI_ANNUAL = of("semi_annual") - - val MONTHLY = of("monthly") - - val QUARTERLY = of("quarterly") - - val ONE_TIME = of("one_time") - - val CUSTOM = of("custom") - - fun of(value: String) = Cadence(JsonField.of(value)) - } - - /** An enum containing [Cadence]'s known values. */ - enum class Known { - ANNUAL, - SEMI_ANNUAL, - MONTHLY, - QUARTERLY, - ONE_TIME, - CUSTOM, - } - - /** - * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Cadence] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if the - * SDK is on an older version than the API, then the API may respond with new members that - * the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - ANNUAL, - SEMI_ANNUAL, - MONTHLY, - QUARTERLY, - ONE_TIME, - CUSTOM, - /** An enum member indicating that [Cadence] was instantiated with an unknown value. */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you want - * to throw for the unknown case. - */ - fun value(): Value = - when (this) { - ANNUAL -> Value.ANNUAL - SEMI_ANNUAL -> Value.SEMI_ANNUAL - MONTHLY -> Value.MONTHLY - QUARTERLY -> Value.QUARTERLY - ONE_TIME -> Value.ONE_TIME - CUSTOM -> Value.CUSTOM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and don't - * want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known member. - */ - fun known(): Known = - when (this) { - ANNUAL -> Known.ANNUAL - SEMI_ANNUAL -> Known.SEMI_ANNUAL - MONTHLY -> Known.MONTHLY - QUARTERLY -> Known.QUARTERLY - ONE_TIME -> Known.ONE_TIME - CUSTOM -> Known.CUSTOM - else -> throw OrbInvalidDataException("Unknown Cadence: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the expected - * primitive type. - */ - fun asString(): String = - _value().asString() ?: throw OrbInvalidDataException("Value is not a String") - - private var validated: Boolean = false - - fun validate(): Cadence = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Cadence && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class ModelType @JsonCreator private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API may respond with new members that the SDK is - * unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - val TIERED_BPS = of("tiered_bps") - - fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - TIERED_BPS - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if the - * SDK is on an older version than the API, then the API may respond with new members that - * the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - TIERED_BPS, - /** - * An enum member indicating that [ModelType] was instantiated with an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you want - * to throw for the unknown case. - */ - fun value(): Value = - when (this) { - TIERED_BPS -> Value.TIERED_BPS - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and don't - * want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known member. - */ - fun known(): Known = - when (this) { - TIERED_BPS -> Known.TIERED_BPS - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the expected - * primitive type. - */ - fun asString(): String = - _value().asString() ?: throw OrbInvalidDataException("Value is not a String") - - private var validated: Boolean = false - - fun validate(): ModelType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ModelType && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by setting - * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to - * `null`. - */ - class Metadata - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Metadata]. */ - fun builder() = Builder() - } - - /** A builder for [Metadata]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(metadata: Metadata) = apply { - additionalProperties = metadata.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Metadata]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Metadata && additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is NewPlanTieredBpsPrice && - cadence == other.cadence && - itemId == other.itemId && - modelType == other.modelType && - name == other.name && - tieredBpsConfig == other.tieredBpsConfig && - billableMetricId == other.billableMetricId && - billedInAdvance == other.billedInAdvance && - billingCycleConfiguration == other.billingCycleConfiguration && - conversionRate == other.conversionRate && - conversionRateConfig == other.conversionRateConfig && - currency == other.currency && - dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && - externalPriceId == other.externalPriceId && - fixedPriceQuantity == other.fixedPriceQuantity && - invoiceGroupingKey == other.invoiceGroupingKey && - invoicingCycleConfiguration == other.invoicingCycleConfiguration && - metadata == other.metadata && - referenceId == other.referenceId && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - cadence, - itemId, - modelType, - name, - tieredBpsConfig, - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - conversionRateConfig, - currency, - dimensionalPriceConfiguration, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewPlanTieredBpsPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredBpsConfig=$tieredBpsConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" -} diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionBpsPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionBpsPrice.kt deleted file mode 100644 index 4aac376b1..000000000 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionBpsPrice.kt +++ /dev/null @@ -1,1367 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.withorb.api.models - -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import com.withorb.api.core.Enum -import com.withorb.api.core.ExcludeMissing -import com.withorb.api.core.JsonField -import com.withorb.api.core.JsonMissing -import com.withorb.api.core.JsonValue -import com.withorb.api.core.checkRequired -import com.withorb.api.core.toImmutable -import com.withorb.api.errors.OrbInvalidDataException -import java.util.Collections -import java.util.Objects - -class NewSubscriptionBpsPrice -private constructor( - private val bpsConfig: JsonField, - private val cadence: JsonField, - private val itemId: JsonField, - private val modelType: JsonField, - private val name: JsonField, - private val billableMetricId: JsonField, - private val billedInAdvance: JsonField, - private val billingCycleConfiguration: JsonField, - private val conversionRate: JsonField, - private val conversionRateConfig: JsonField, - private val currency: JsonField, - private val dimensionalPriceConfiguration: JsonField, - private val externalPriceId: JsonField, - private val fixedPriceQuantity: JsonField, - private val invoiceGroupingKey: JsonField, - private val invoicingCycleConfiguration: JsonField, - private val metadata: JsonField, - private val referenceId: JsonField, - private val additionalProperties: MutableMap, -) { - - @JsonCreator - private constructor( - @JsonProperty("bps_config") - @ExcludeMissing - bpsConfig: JsonField = JsonMissing.of(), - @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), - @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - modelType: JsonField = JsonMissing.of(), - @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - billingCycleConfiguration: JsonField = JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("conversion_rate_config") - @ExcludeMissing - conversionRateConfig: JsonField = JsonMissing.of(), - @JsonProperty("currency") @ExcludeMissing currency: JsonField = JsonMissing.of(), - @JsonProperty("dimensional_price_configuration") - @ExcludeMissing - dimensionalPriceConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - invoicingCycleConfiguration: JsonField = JsonMissing.of(), - @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), - @JsonProperty("reference_id") - @ExcludeMissing - referenceId: JsonField = JsonMissing.of(), - ) : this( - bpsConfig, - cadence, - itemId, - modelType, - name, - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - conversionRateConfig, - currency, - dimensionalPriceConfiguration, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - mutableMapOf(), - ) - - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly - * missing or null (e.g. if the server responded with an unexpected value). - */ - fun bpsConfig(): BpsConfig = bpsConfig.getRequired("bps_config") - - /** - * The cadence to bill for this price on. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly - * missing or null (e.g. if the server responded with an unexpected value). - */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - /** - * The id of the item the price will be associated with. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly - * missing or null (e.g. if the server responded with an unexpected value). - */ - fun itemId(): String = itemId.getRequired("item_id") - - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly - * missing or null (e.g. if the server responded with an unexpected value). - */ - fun modelType(): ModelType = modelType.getRequired("model_type") - - /** - * The name of the price. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly - * missing or null (e.g. if the server responded with an unexpected value). - */ - fun name(): String = name.getRequired("name") - - /** - * The id of the billable metric for the price. Only needed if the price is usage-based. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - fun billableMetricId(): String? = billableMetricId.getNullable("billable_metric_id") - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this is true, - * and in-arrears if this is false. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") - - /** - * For custom cadence: specifies the duration of the billing period in days or months. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - fun billingCycleConfiguration(): NewBillingCycleConfiguration? = - billingCycleConfiguration.getNullable("billing_cycle_configuration") - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") - - /** - * The configuration for the rate of the price currency to the invoicing currency. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - fun conversionRateConfig(): ConversionRateConfig? = - conversionRateConfig.getNullable("conversion_rate_config") - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this price is - * billed. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - fun currency(): String? = currency.getNullable("currency") - - /** - * For dimensional price: specifies a price group and dimension values - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = - dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") - - /** - * An alias for the price. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") - - /** - * If the Price represents a fixed cost, this represents the quantity of units applied. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - fun fixedPriceQuantity(): Double? = fixedPriceQuantity.getNullable("fixed_price_quantity") - - /** - * The property used to group this price on an invoice - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - fun invoiceGroupingKey(): String? = invoiceGroupingKey.getNullable("invoice_grouping_key") - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. If - * unspecified, a single invoice is produced per billing cycle. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by setting - * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to - * `null`. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - fun metadata(): Metadata? = metadata.getNullable("metadata") - - /** - * A transient ID that can be used to reference this price when adding adjustments in the same - * API call. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - fun referenceId(): String? = referenceId.getNullable("reference_id") - - /** - * Returns the raw JSON value of [bpsConfig]. - * - * Unlike [bpsConfig], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("bps_config") @ExcludeMissing fun _bpsConfig(): JsonField = bpsConfig - - /** - * Returns the raw JSON value of [cadence]. - * - * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence - - /** - * Returns the raw JSON value of [itemId]. - * - * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - /** - * Returns the raw JSON value of [modelType]. - * - * Unlike [modelType], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonField = modelType - - /** - * Returns the raw JSON value of [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - /** - * Returns the raw JSON value of [billableMetricId]. - * - * Unlike [billableMetricId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = billableMetricId - - /** - * Returns the raw JSON value of [billedInAdvance]. - * - * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance - - /** - * Returns the raw JSON value of [billingCycleConfiguration]. - * - * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** - * Returns the raw JSON value of [conversionRate]. - * - * Unlike [conversionRate], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** - * Returns the raw JSON value of [conversionRateConfig]. - * - * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("conversion_rate_config") - @ExcludeMissing - fun _conversionRateConfig(): JsonField = conversionRateConfig - - /** - * Returns the raw JSON value of [currency]. - * - * Unlike [currency], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - - /** - * Returns the raw JSON value of [dimensionalPriceConfiguration]. - * - * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("dimensional_price_configuration") - @ExcludeMissing - fun _dimensionalPriceConfiguration(): JsonField = - dimensionalPriceConfiguration - - /** - * Returns the raw JSON value of [externalPriceId]. - * - * Unlike [externalPriceId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * Returns the raw JSON value of [fixedPriceQuantity]. - * - * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** - * Returns the raw JSON value of [invoiceGroupingKey]. - * - * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Returns the raw JSON value of [invoicingCycleConfiguration]. - * - * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * Returns the raw JSON value of [metadata]. - * - * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata - - /** - * Returns the raw JSON value of [referenceId]. - * - * Unlike [referenceId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("reference_id") - @ExcludeMissing - fun _referenceId(): JsonField = referenceId - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [NewSubscriptionBpsPrice]. - * - * The following fields are required: - * ```kotlin - * .bpsConfig() - * .cadence() - * .itemId() - * .modelType() - * .name() - * ``` - */ - fun builder() = Builder() - } - - /** A builder for [NewSubscriptionBpsPrice]. */ - class Builder internal constructor() { - - private var bpsConfig: JsonField? = null - private var cadence: JsonField? = null - private var itemId: JsonField? = null - private var modelType: JsonField? = null - private var name: JsonField? = null - private var billableMetricId: JsonField = JsonMissing.of() - private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var conversionRateConfig: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var dimensionalPriceConfiguration: JsonField = - JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var referenceId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(newSubscriptionBpsPrice: NewSubscriptionBpsPrice) = apply { - bpsConfig = newSubscriptionBpsPrice.bpsConfig - cadence = newSubscriptionBpsPrice.cadence - itemId = newSubscriptionBpsPrice.itemId - modelType = newSubscriptionBpsPrice.modelType - name = newSubscriptionBpsPrice.name - billableMetricId = newSubscriptionBpsPrice.billableMetricId - billedInAdvance = newSubscriptionBpsPrice.billedInAdvance - billingCycleConfiguration = newSubscriptionBpsPrice.billingCycleConfiguration - conversionRate = newSubscriptionBpsPrice.conversionRate - conversionRateConfig = newSubscriptionBpsPrice.conversionRateConfig - currency = newSubscriptionBpsPrice.currency - dimensionalPriceConfiguration = newSubscriptionBpsPrice.dimensionalPriceConfiguration - externalPriceId = newSubscriptionBpsPrice.externalPriceId - fixedPriceQuantity = newSubscriptionBpsPrice.fixedPriceQuantity - invoiceGroupingKey = newSubscriptionBpsPrice.invoiceGroupingKey - invoicingCycleConfiguration = newSubscriptionBpsPrice.invoicingCycleConfiguration - metadata = newSubscriptionBpsPrice.metadata - referenceId = newSubscriptionBpsPrice.referenceId - additionalProperties = newSubscriptionBpsPrice.additionalProperties.toMutableMap() - } - - fun bpsConfig(bpsConfig: BpsConfig) = bpsConfig(JsonField.of(bpsConfig)) - - /** - * Sets [Builder.bpsConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.bpsConfig] with a well-typed [BpsConfig] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun bpsConfig(bpsConfig: JsonField) = apply { this.bpsConfig = bpsConfig } - - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** - * Sets [Builder.cadence] to an arbitrary JSON value. - * - * You should usually call [Builder.cadence] with a well-typed [Cadence] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - - /** The id of the item the price will be associated with. */ - fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - - /** - * Sets [Builder.itemId] to an arbitrary JSON value. - * - * You should usually call [Builder.itemId] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - - /** - * Sets [Builder.modelType] to an arbitrary JSON value. - * - * You should usually call [Builder.modelType] with a well-typed [ModelType] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun modelType(modelType: JsonField) = apply { this.modelType = modelType } - - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) - - /** - * Sets [Builder.name] to an arbitrary JSON value. - * - * You should usually call [Builder.name] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun name(name: JsonField) = apply { this.name = name } - - /** The id of the billable metric for the price. Only needed if the price is usage-based. */ - fun billableMetricId(billableMetricId: String?) = - billableMetricId(JsonField.ofNullable(billableMetricId)) - - /** - * Sets [Builder.billableMetricId] to an arbitrary JSON value. - * - * You should usually call [Builder.billableMetricId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun billableMetricId(billableMetricId: JsonField) = apply { - this.billableMetricId = billableMetricId - } - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this is - * true, and in-arrears if this is false. - */ - fun billedInAdvance(billedInAdvance: Boolean?) = - billedInAdvance(JsonField.ofNullable(billedInAdvance)) - - /** - * Alias for [Builder.billedInAdvance]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun billedInAdvance(billedInAdvance: Boolean) = billedInAdvance(billedInAdvance as Boolean?) - - /** - * Sets [Builder.billedInAdvance] to an arbitrary JSON value. - * - * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun billedInAdvance(billedInAdvance: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** For custom cadence: specifies the duration of the billing period in days or months. */ - fun billingCycleConfiguration(billingCycleConfiguration: NewBillingCycleConfiguration?) = - billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - - /** - * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.billingCycleConfiguration] with a well-typed - * [NewBillingCycleConfiguration] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: JsonField - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double?) = - conversionRate(JsonField.ofNullable(conversionRate)) - - /** - * Alias for [Builder.conversionRate]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) - - /** - * Sets [Builder.conversionRate] to an arbitrary JSON value. - * - * You should usually call [Builder.conversionRate] with a well-typed [Double] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** The configuration for the rate of the price currency to the invoicing currency. */ - fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = - conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) - - /** - * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.conversionRateConfig] with a well-typed - * [ConversionRateConfig] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun conversionRateConfig(conversionRateConfig: JsonField) = apply { - this.conversionRateConfig = conversionRateConfig - } - - /** Alias for calling [conversionRateConfig] with `ConversionRateConfig.ofUnit(unit)`. */ - fun conversionRateConfig(unit: UnitConversionRateConfig) = - conversionRateConfig(ConversionRateConfig.ofUnit(unit)) - - /** - * Alias for calling [conversionRateConfig] with the following: - * ```kotlin - * UnitConversionRateConfig.builder() - * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) - * .unitConfig(unitConfig) - * .build() - * ``` - */ - fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = - conversionRateConfig( - UnitConversionRateConfig.builder() - .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) - .unitConfig(unitConfig) - .build() - ) - - /** - * Alias for calling [conversionRateConfig] with `ConversionRateConfig.ofTiered(tiered)`. - */ - fun conversionRateConfig(tiered: TieredConversionRateConfig) = - conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) - - /** - * Alias for calling [conversionRateConfig] with the following: - * ```kotlin - * TieredConversionRateConfig.builder() - * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) - * .tieredConfig(tieredConfig) - * .build() - * ``` - */ - fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = - conversionRateConfig( - TieredConversionRateConfig.builder() - .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) - .tieredConfig(tieredConfig) - .build() - ) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this price is - * billed. - */ - fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) - - /** - * Sets [Builder.currency] to an arbitrary JSON value. - * - * You should usually call [Builder.currency] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } - - /** For dimensional price: specifies a price group and dimension values */ - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? - ) = dimensionalPriceConfiguration(JsonField.ofNullable(dimensionalPriceConfiguration)) - - /** - * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.dimensionalPriceConfiguration] with a well-typed - * [NewDimensionalPriceConfiguration] value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: JsonField - ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** - * Sets [Builder.externalPriceId] to an arbitrary JSON value. - * - * You should usually call [Builder.externalPriceId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun externalPriceId(externalPriceId: JsonField) = apply { - this.externalPriceId = externalPriceId - } - - /** If the Price represents a fixed cost, this represents the quantity of units applied. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = - fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) - - /** - * Alias for [Builder.fixedPriceQuantity]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. - * - * You should usually call [Builder.fixedPriceQuantity] with a well-typed [Double] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = - invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) - - /** - * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. - * - * You should usually call [Builder.invoiceGroupingKey] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { - this.invoiceGroupingKey = invoiceGroupingKey - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. If - * unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: NewBillingCycleConfiguration? - ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) - - /** - * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.invoicingCycleConfiguration] with a well-typed - * [NewBillingCycleConfiguration] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by - * setting the value to `null`, and the entire metadata mapping can be cleared by setting - * `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * Sets [Builder.metadata] to an arbitrary JSON value. - * - * You should usually call [Builder.metadata] with a well-typed [Metadata] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - - /** - * A transient ID that can be used to reference this price when adding adjustments in the - * same API call. - */ - fun referenceId(referenceId: String?) = referenceId(JsonField.ofNullable(referenceId)) - - /** - * Sets [Builder.referenceId] to an arbitrary JSON value. - * - * You should usually call [Builder.referenceId] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun referenceId(referenceId: JsonField) = apply { this.referenceId = referenceId } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [NewSubscriptionBpsPrice]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```kotlin - * .bpsConfig() - * .cadence() - * .itemId() - * .modelType() - * .name() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): NewSubscriptionBpsPrice = - NewSubscriptionBpsPrice( - checkRequired("bpsConfig", bpsConfig), - checkRequired("cadence", cadence), - checkRequired("itemId", itemId), - checkRequired("modelType", modelType), - checkRequired("name", name), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - conversionRateConfig, - currency, - dimensionalPriceConfiguration, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): NewSubscriptionBpsPrice = apply { - if (validated) { - return@apply - } - - bpsConfig().validate() - cadence().validate() - itemId() - modelType().validate() - name() - billableMetricId() - billedInAdvance() - billingCycleConfiguration()?.validate() - conversionRate() - conversionRateConfig()?.validate() - currency() - dimensionalPriceConfiguration()?.validate() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration()?.validate() - metadata()?.validate() - referenceId() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (bpsConfig.asKnown()?.validity() ?: 0) + - (cadence.asKnown()?.validity() ?: 0) + - (if (itemId.asKnown() == null) 0 else 1) + - (modelType.asKnown()?.validity() ?: 0) + - (if (name.asKnown() == null) 0 else 1) + - (if (billableMetricId.asKnown() == null) 0 else 1) + - (if (billedInAdvance.asKnown() == null) 0 else 1) + - (billingCycleConfiguration.asKnown()?.validity() ?: 0) + - (if (conversionRate.asKnown() == null) 0 else 1) + - (conversionRateConfig.asKnown()?.validity() ?: 0) + - (if (currency.asKnown() == null) 0 else 1) + - (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + - (if (externalPriceId.asKnown() == null) 0 else 1) + - (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + - (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + - (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + - (metadata.asKnown()?.validity() ?: 0) + - (if (referenceId.asKnown() == null) 0 else 1) - - /** The cadence to bill for this price on. */ - class Cadence @JsonCreator private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API may respond with new members that the SDK is - * unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - val ANNUAL = of("annual") - - val SEMI_ANNUAL = of("semi_annual") - - val MONTHLY = of("monthly") - - val QUARTERLY = of("quarterly") - - val ONE_TIME = of("one_time") - - val CUSTOM = of("custom") - - fun of(value: String) = Cadence(JsonField.of(value)) - } - - /** An enum containing [Cadence]'s known values. */ - enum class Known { - ANNUAL, - SEMI_ANNUAL, - MONTHLY, - QUARTERLY, - ONE_TIME, - CUSTOM, - } - - /** - * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Cadence] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if the - * SDK is on an older version than the API, then the API may respond with new members that - * the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - ANNUAL, - SEMI_ANNUAL, - MONTHLY, - QUARTERLY, - ONE_TIME, - CUSTOM, - /** An enum member indicating that [Cadence] was instantiated with an unknown value. */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you want - * to throw for the unknown case. - */ - fun value(): Value = - when (this) { - ANNUAL -> Value.ANNUAL - SEMI_ANNUAL -> Value.SEMI_ANNUAL - MONTHLY -> Value.MONTHLY - QUARTERLY -> Value.QUARTERLY - ONE_TIME -> Value.ONE_TIME - CUSTOM -> Value.CUSTOM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and don't - * want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known member. - */ - fun known(): Known = - when (this) { - ANNUAL -> Known.ANNUAL - SEMI_ANNUAL -> Known.SEMI_ANNUAL - MONTHLY -> Known.MONTHLY - QUARTERLY -> Known.QUARTERLY - ONE_TIME -> Known.ONE_TIME - CUSTOM -> Known.CUSTOM - else -> throw OrbInvalidDataException("Unknown Cadence: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the expected - * primitive type. - */ - fun asString(): String = - _value().asString() ?: throw OrbInvalidDataException("Value is not a String") - - private var validated: Boolean = false - - fun validate(): Cadence = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Cadence && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class ModelType @JsonCreator private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API may respond with new members that the SDK is - * unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - val BPS = of("bps") - - fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - BPS - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if the - * SDK is on an older version than the API, then the API may respond with new members that - * the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - BPS, - /** - * An enum member indicating that [ModelType] was instantiated with an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you want - * to throw for the unknown case. - */ - fun value(): Value = - when (this) { - BPS -> Value.BPS - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and don't - * want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known member. - */ - fun known(): Known = - when (this) { - BPS -> Known.BPS - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the expected - * primitive type. - */ - fun asString(): String = - _value().asString() ?: throw OrbInvalidDataException("Value is not a String") - - private var validated: Boolean = false - - fun validate(): ModelType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ModelType && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by setting - * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to - * `null`. - */ - class Metadata - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Metadata]. */ - fun builder() = Builder() - } - - /** A builder for [Metadata]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(metadata: Metadata) = apply { - additionalProperties = metadata.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Metadata]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Metadata && additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is NewSubscriptionBpsPrice && - bpsConfig == other.bpsConfig && - cadence == other.cadence && - itemId == other.itemId && - modelType == other.modelType && - name == other.name && - billableMetricId == other.billableMetricId && - billedInAdvance == other.billedInAdvance && - billingCycleConfiguration == other.billingCycleConfiguration && - conversionRate == other.conversionRate && - conversionRateConfig == other.conversionRateConfig && - currency == other.currency && - dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && - externalPriceId == other.externalPriceId && - fixedPriceQuantity == other.fixedPriceQuantity && - invoiceGroupingKey == other.invoiceGroupingKey && - invoicingCycleConfiguration == other.invoicingCycleConfiguration && - metadata == other.metadata && - referenceId == other.referenceId && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - bpsConfig, - cadence, - itemId, - modelType, - name, - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - conversionRateConfig, - currency, - dimensionalPriceConfiguration, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewSubscriptionBpsPrice{bpsConfig=$bpsConfig, cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" -} diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionBulkBpsPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionBulkBpsPrice.kt deleted file mode 100644 index 70c2758d7..000000000 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionBulkBpsPrice.kt +++ /dev/null @@ -1,1372 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.withorb.api.models - -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import com.withorb.api.core.Enum -import com.withorb.api.core.ExcludeMissing -import com.withorb.api.core.JsonField -import com.withorb.api.core.JsonMissing -import com.withorb.api.core.JsonValue -import com.withorb.api.core.checkRequired -import com.withorb.api.core.toImmutable -import com.withorb.api.errors.OrbInvalidDataException -import java.util.Collections -import java.util.Objects - -class NewSubscriptionBulkBpsPrice -private constructor( - private val bulkBpsConfig: JsonField, - private val cadence: JsonField, - private val itemId: JsonField, - private val modelType: JsonField, - private val name: JsonField, - private val billableMetricId: JsonField, - private val billedInAdvance: JsonField, - private val billingCycleConfiguration: JsonField, - private val conversionRate: JsonField, - private val conversionRateConfig: JsonField, - private val currency: JsonField, - private val dimensionalPriceConfiguration: JsonField, - private val externalPriceId: JsonField, - private val fixedPriceQuantity: JsonField, - private val invoiceGroupingKey: JsonField, - private val invoicingCycleConfiguration: JsonField, - private val metadata: JsonField, - private val referenceId: JsonField, - private val additionalProperties: MutableMap, -) { - - @JsonCreator - private constructor( - @JsonProperty("bulk_bps_config") - @ExcludeMissing - bulkBpsConfig: JsonField = JsonMissing.of(), - @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), - @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - modelType: JsonField = JsonMissing.of(), - @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - billingCycleConfiguration: JsonField = JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("conversion_rate_config") - @ExcludeMissing - conversionRateConfig: JsonField = JsonMissing.of(), - @JsonProperty("currency") @ExcludeMissing currency: JsonField = JsonMissing.of(), - @JsonProperty("dimensional_price_configuration") - @ExcludeMissing - dimensionalPriceConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - invoicingCycleConfiguration: JsonField = JsonMissing.of(), - @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), - @JsonProperty("reference_id") - @ExcludeMissing - referenceId: JsonField = JsonMissing.of(), - ) : this( - bulkBpsConfig, - cadence, - itemId, - modelType, - name, - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - conversionRateConfig, - currency, - dimensionalPriceConfiguration, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - mutableMapOf(), - ) - - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly - * missing or null (e.g. if the server responded with an unexpected value). - */ - fun bulkBpsConfig(): BulkBpsConfig = bulkBpsConfig.getRequired("bulk_bps_config") - - /** - * The cadence to bill for this price on. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly - * missing or null (e.g. if the server responded with an unexpected value). - */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - /** - * The id of the item the price will be associated with. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly - * missing or null (e.g. if the server responded with an unexpected value). - */ - fun itemId(): String = itemId.getRequired("item_id") - - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly - * missing or null (e.g. if the server responded with an unexpected value). - */ - fun modelType(): ModelType = modelType.getRequired("model_type") - - /** - * The name of the price. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly - * missing or null (e.g. if the server responded with an unexpected value). - */ - fun name(): String = name.getRequired("name") - - /** - * The id of the billable metric for the price. Only needed if the price is usage-based. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - fun billableMetricId(): String? = billableMetricId.getNullable("billable_metric_id") - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this is true, - * and in-arrears if this is false. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") - - /** - * For custom cadence: specifies the duration of the billing period in days or months. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - fun billingCycleConfiguration(): NewBillingCycleConfiguration? = - billingCycleConfiguration.getNullable("billing_cycle_configuration") - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") - - /** - * The configuration for the rate of the price currency to the invoicing currency. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - fun conversionRateConfig(): ConversionRateConfig? = - conversionRateConfig.getNullable("conversion_rate_config") - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this price is - * billed. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - fun currency(): String? = currency.getNullable("currency") - - /** - * For dimensional price: specifies a price group and dimension values - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = - dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") - - /** - * An alias for the price. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") - - /** - * If the Price represents a fixed cost, this represents the quantity of units applied. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - fun fixedPriceQuantity(): Double? = fixedPriceQuantity.getNullable("fixed_price_quantity") - - /** - * The property used to group this price on an invoice - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - fun invoiceGroupingKey(): String? = invoiceGroupingKey.getNullable("invoice_grouping_key") - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. If - * unspecified, a single invoice is produced per billing cycle. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by setting - * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to - * `null`. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - fun metadata(): Metadata? = metadata.getNullable("metadata") - - /** - * A transient ID that can be used to reference this price when adding adjustments in the same - * API call. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - fun referenceId(): String? = referenceId.getNullable("reference_id") - - /** - * Returns the raw JSON value of [bulkBpsConfig]. - * - * Unlike [bulkBpsConfig], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("bulk_bps_config") - @ExcludeMissing - fun _bulkBpsConfig(): JsonField = bulkBpsConfig - - /** - * Returns the raw JSON value of [cadence]. - * - * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence - - /** - * Returns the raw JSON value of [itemId]. - * - * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - /** - * Returns the raw JSON value of [modelType]. - * - * Unlike [modelType], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonField = modelType - - /** - * Returns the raw JSON value of [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - /** - * Returns the raw JSON value of [billableMetricId]. - * - * Unlike [billableMetricId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = billableMetricId - - /** - * Returns the raw JSON value of [billedInAdvance]. - * - * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance - - /** - * Returns the raw JSON value of [billingCycleConfiguration]. - * - * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** - * Returns the raw JSON value of [conversionRate]. - * - * Unlike [conversionRate], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** - * Returns the raw JSON value of [conversionRateConfig]. - * - * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("conversion_rate_config") - @ExcludeMissing - fun _conversionRateConfig(): JsonField = conversionRateConfig - - /** - * Returns the raw JSON value of [currency]. - * - * Unlike [currency], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - - /** - * Returns the raw JSON value of [dimensionalPriceConfiguration]. - * - * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("dimensional_price_configuration") - @ExcludeMissing - fun _dimensionalPriceConfiguration(): JsonField = - dimensionalPriceConfiguration - - /** - * Returns the raw JSON value of [externalPriceId]. - * - * Unlike [externalPriceId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * Returns the raw JSON value of [fixedPriceQuantity]. - * - * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** - * Returns the raw JSON value of [invoiceGroupingKey]. - * - * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Returns the raw JSON value of [invoicingCycleConfiguration]. - * - * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * Returns the raw JSON value of [metadata]. - * - * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata - - /** - * Returns the raw JSON value of [referenceId]. - * - * Unlike [referenceId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("reference_id") - @ExcludeMissing - fun _referenceId(): JsonField = referenceId - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [NewSubscriptionBulkBpsPrice]. - * - * The following fields are required: - * ```kotlin - * .bulkBpsConfig() - * .cadence() - * .itemId() - * .modelType() - * .name() - * ``` - */ - fun builder() = Builder() - } - - /** A builder for [NewSubscriptionBulkBpsPrice]. */ - class Builder internal constructor() { - - private var bulkBpsConfig: JsonField? = null - private var cadence: JsonField? = null - private var itemId: JsonField? = null - private var modelType: JsonField? = null - private var name: JsonField? = null - private var billableMetricId: JsonField = JsonMissing.of() - private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var conversionRateConfig: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var dimensionalPriceConfiguration: JsonField = - JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var referenceId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(newSubscriptionBulkBpsPrice: NewSubscriptionBulkBpsPrice) = apply { - bulkBpsConfig = newSubscriptionBulkBpsPrice.bulkBpsConfig - cadence = newSubscriptionBulkBpsPrice.cadence - itemId = newSubscriptionBulkBpsPrice.itemId - modelType = newSubscriptionBulkBpsPrice.modelType - name = newSubscriptionBulkBpsPrice.name - billableMetricId = newSubscriptionBulkBpsPrice.billableMetricId - billedInAdvance = newSubscriptionBulkBpsPrice.billedInAdvance - billingCycleConfiguration = newSubscriptionBulkBpsPrice.billingCycleConfiguration - conversionRate = newSubscriptionBulkBpsPrice.conversionRate - conversionRateConfig = newSubscriptionBulkBpsPrice.conversionRateConfig - currency = newSubscriptionBulkBpsPrice.currency - dimensionalPriceConfiguration = - newSubscriptionBulkBpsPrice.dimensionalPriceConfiguration - externalPriceId = newSubscriptionBulkBpsPrice.externalPriceId - fixedPriceQuantity = newSubscriptionBulkBpsPrice.fixedPriceQuantity - invoiceGroupingKey = newSubscriptionBulkBpsPrice.invoiceGroupingKey - invoicingCycleConfiguration = newSubscriptionBulkBpsPrice.invoicingCycleConfiguration - metadata = newSubscriptionBulkBpsPrice.metadata - referenceId = newSubscriptionBulkBpsPrice.referenceId - additionalProperties = newSubscriptionBulkBpsPrice.additionalProperties.toMutableMap() - } - - fun bulkBpsConfig(bulkBpsConfig: BulkBpsConfig) = bulkBpsConfig(JsonField.of(bulkBpsConfig)) - - /** - * Sets [Builder.bulkBpsConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.bulkBpsConfig] with a well-typed [BulkBpsConfig] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun bulkBpsConfig(bulkBpsConfig: JsonField) = apply { - this.bulkBpsConfig = bulkBpsConfig - } - - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** - * Sets [Builder.cadence] to an arbitrary JSON value. - * - * You should usually call [Builder.cadence] with a well-typed [Cadence] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - - /** The id of the item the price will be associated with. */ - fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - - /** - * Sets [Builder.itemId] to an arbitrary JSON value. - * - * You should usually call [Builder.itemId] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - - /** - * Sets [Builder.modelType] to an arbitrary JSON value. - * - * You should usually call [Builder.modelType] with a well-typed [ModelType] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun modelType(modelType: JsonField) = apply { this.modelType = modelType } - - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) - - /** - * Sets [Builder.name] to an arbitrary JSON value. - * - * You should usually call [Builder.name] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun name(name: JsonField) = apply { this.name = name } - - /** The id of the billable metric for the price. Only needed if the price is usage-based. */ - fun billableMetricId(billableMetricId: String?) = - billableMetricId(JsonField.ofNullable(billableMetricId)) - - /** - * Sets [Builder.billableMetricId] to an arbitrary JSON value. - * - * You should usually call [Builder.billableMetricId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun billableMetricId(billableMetricId: JsonField) = apply { - this.billableMetricId = billableMetricId - } - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this is - * true, and in-arrears if this is false. - */ - fun billedInAdvance(billedInAdvance: Boolean?) = - billedInAdvance(JsonField.ofNullable(billedInAdvance)) - - /** - * Alias for [Builder.billedInAdvance]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun billedInAdvance(billedInAdvance: Boolean) = billedInAdvance(billedInAdvance as Boolean?) - - /** - * Sets [Builder.billedInAdvance] to an arbitrary JSON value. - * - * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun billedInAdvance(billedInAdvance: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** For custom cadence: specifies the duration of the billing period in days or months. */ - fun billingCycleConfiguration(billingCycleConfiguration: NewBillingCycleConfiguration?) = - billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - - /** - * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.billingCycleConfiguration] with a well-typed - * [NewBillingCycleConfiguration] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: JsonField - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double?) = - conversionRate(JsonField.ofNullable(conversionRate)) - - /** - * Alias for [Builder.conversionRate]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) - - /** - * Sets [Builder.conversionRate] to an arbitrary JSON value. - * - * You should usually call [Builder.conversionRate] with a well-typed [Double] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** The configuration for the rate of the price currency to the invoicing currency. */ - fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = - conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) - - /** - * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.conversionRateConfig] with a well-typed - * [ConversionRateConfig] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun conversionRateConfig(conversionRateConfig: JsonField) = apply { - this.conversionRateConfig = conversionRateConfig - } - - /** Alias for calling [conversionRateConfig] with `ConversionRateConfig.ofUnit(unit)`. */ - fun conversionRateConfig(unit: UnitConversionRateConfig) = - conversionRateConfig(ConversionRateConfig.ofUnit(unit)) - - /** - * Alias for calling [conversionRateConfig] with the following: - * ```kotlin - * UnitConversionRateConfig.builder() - * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) - * .unitConfig(unitConfig) - * .build() - * ``` - */ - fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = - conversionRateConfig( - UnitConversionRateConfig.builder() - .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) - .unitConfig(unitConfig) - .build() - ) - - /** - * Alias for calling [conversionRateConfig] with `ConversionRateConfig.ofTiered(tiered)`. - */ - fun conversionRateConfig(tiered: TieredConversionRateConfig) = - conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) - - /** - * Alias for calling [conversionRateConfig] with the following: - * ```kotlin - * TieredConversionRateConfig.builder() - * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) - * .tieredConfig(tieredConfig) - * .build() - * ``` - */ - fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = - conversionRateConfig( - TieredConversionRateConfig.builder() - .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) - .tieredConfig(tieredConfig) - .build() - ) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this price is - * billed. - */ - fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) - - /** - * Sets [Builder.currency] to an arbitrary JSON value. - * - * You should usually call [Builder.currency] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } - - /** For dimensional price: specifies a price group and dimension values */ - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? - ) = dimensionalPriceConfiguration(JsonField.ofNullable(dimensionalPriceConfiguration)) - - /** - * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.dimensionalPriceConfiguration] with a well-typed - * [NewDimensionalPriceConfiguration] value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: JsonField - ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** - * Sets [Builder.externalPriceId] to an arbitrary JSON value. - * - * You should usually call [Builder.externalPriceId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun externalPriceId(externalPriceId: JsonField) = apply { - this.externalPriceId = externalPriceId - } - - /** If the Price represents a fixed cost, this represents the quantity of units applied. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = - fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) - - /** - * Alias for [Builder.fixedPriceQuantity]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. - * - * You should usually call [Builder.fixedPriceQuantity] with a well-typed [Double] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = - invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) - - /** - * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. - * - * You should usually call [Builder.invoiceGroupingKey] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { - this.invoiceGroupingKey = invoiceGroupingKey - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. If - * unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: NewBillingCycleConfiguration? - ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) - - /** - * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.invoicingCycleConfiguration] with a well-typed - * [NewBillingCycleConfiguration] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by - * setting the value to `null`, and the entire metadata mapping can be cleared by setting - * `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * Sets [Builder.metadata] to an arbitrary JSON value. - * - * You should usually call [Builder.metadata] with a well-typed [Metadata] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - - /** - * A transient ID that can be used to reference this price when adding adjustments in the - * same API call. - */ - fun referenceId(referenceId: String?) = referenceId(JsonField.ofNullable(referenceId)) - - /** - * Sets [Builder.referenceId] to an arbitrary JSON value. - * - * You should usually call [Builder.referenceId] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun referenceId(referenceId: JsonField) = apply { this.referenceId = referenceId } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [NewSubscriptionBulkBpsPrice]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```kotlin - * .bulkBpsConfig() - * .cadence() - * .itemId() - * .modelType() - * .name() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): NewSubscriptionBulkBpsPrice = - NewSubscriptionBulkBpsPrice( - checkRequired("bulkBpsConfig", bulkBpsConfig), - checkRequired("cadence", cadence), - checkRequired("itemId", itemId), - checkRequired("modelType", modelType), - checkRequired("name", name), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - conversionRateConfig, - currency, - dimensionalPriceConfiguration, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): NewSubscriptionBulkBpsPrice = apply { - if (validated) { - return@apply - } - - bulkBpsConfig().validate() - cadence().validate() - itemId() - modelType().validate() - name() - billableMetricId() - billedInAdvance() - billingCycleConfiguration()?.validate() - conversionRate() - conversionRateConfig()?.validate() - currency() - dimensionalPriceConfiguration()?.validate() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration()?.validate() - metadata()?.validate() - referenceId() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (bulkBpsConfig.asKnown()?.validity() ?: 0) + - (cadence.asKnown()?.validity() ?: 0) + - (if (itemId.asKnown() == null) 0 else 1) + - (modelType.asKnown()?.validity() ?: 0) + - (if (name.asKnown() == null) 0 else 1) + - (if (billableMetricId.asKnown() == null) 0 else 1) + - (if (billedInAdvance.asKnown() == null) 0 else 1) + - (billingCycleConfiguration.asKnown()?.validity() ?: 0) + - (if (conversionRate.asKnown() == null) 0 else 1) + - (conversionRateConfig.asKnown()?.validity() ?: 0) + - (if (currency.asKnown() == null) 0 else 1) + - (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + - (if (externalPriceId.asKnown() == null) 0 else 1) + - (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + - (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + - (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + - (metadata.asKnown()?.validity() ?: 0) + - (if (referenceId.asKnown() == null) 0 else 1) - - /** The cadence to bill for this price on. */ - class Cadence @JsonCreator private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API may respond with new members that the SDK is - * unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - val ANNUAL = of("annual") - - val SEMI_ANNUAL = of("semi_annual") - - val MONTHLY = of("monthly") - - val QUARTERLY = of("quarterly") - - val ONE_TIME = of("one_time") - - val CUSTOM = of("custom") - - fun of(value: String) = Cadence(JsonField.of(value)) - } - - /** An enum containing [Cadence]'s known values. */ - enum class Known { - ANNUAL, - SEMI_ANNUAL, - MONTHLY, - QUARTERLY, - ONE_TIME, - CUSTOM, - } - - /** - * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Cadence] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if the - * SDK is on an older version than the API, then the API may respond with new members that - * the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - ANNUAL, - SEMI_ANNUAL, - MONTHLY, - QUARTERLY, - ONE_TIME, - CUSTOM, - /** An enum member indicating that [Cadence] was instantiated with an unknown value. */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you want - * to throw for the unknown case. - */ - fun value(): Value = - when (this) { - ANNUAL -> Value.ANNUAL - SEMI_ANNUAL -> Value.SEMI_ANNUAL - MONTHLY -> Value.MONTHLY - QUARTERLY -> Value.QUARTERLY - ONE_TIME -> Value.ONE_TIME - CUSTOM -> Value.CUSTOM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and don't - * want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known member. - */ - fun known(): Known = - when (this) { - ANNUAL -> Known.ANNUAL - SEMI_ANNUAL -> Known.SEMI_ANNUAL - MONTHLY -> Known.MONTHLY - QUARTERLY -> Known.QUARTERLY - ONE_TIME -> Known.ONE_TIME - CUSTOM -> Known.CUSTOM - else -> throw OrbInvalidDataException("Unknown Cadence: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the expected - * primitive type. - */ - fun asString(): String = - _value().asString() ?: throw OrbInvalidDataException("Value is not a String") - - private var validated: Boolean = false - - fun validate(): Cadence = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Cadence && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class ModelType @JsonCreator private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API may respond with new members that the SDK is - * unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - val BULK_BPS = of("bulk_bps") - - fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - BULK_BPS - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if the - * SDK is on an older version than the API, then the API may respond with new members that - * the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - BULK_BPS, - /** - * An enum member indicating that [ModelType] was instantiated with an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you want - * to throw for the unknown case. - */ - fun value(): Value = - when (this) { - BULK_BPS -> Value.BULK_BPS - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and don't - * want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known member. - */ - fun known(): Known = - when (this) { - BULK_BPS -> Known.BULK_BPS - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the expected - * primitive type. - */ - fun asString(): String = - _value().asString() ?: throw OrbInvalidDataException("Value is not a String") - - private var validated: Boolean = false - - fun validate(): ModelType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ModelType && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by setting - * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to - * `null`. - */ - class Metadata - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Metadata]. */ - fun builder() = Builder() - } - - /** A builder for [Metadata]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(metadata: Metadata) = apply { - additionalProperties = metadata.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Metadata]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Metadata && additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is NewSubscriptionBulkBpsPrice && - bulkBpsConfig == other.bulkBpsConfig && - cadence == other.cadence && - itemId == other.itemId && - modelType == other.modelType && - name == other.name && - billableMetricId == other.billableMetricId && - billedInAdvance == other.billedInAdvance && - billingCycleConfiguration == other.billingCycleConfiguration && - conversionRate == other.conversionRate && - conversionRateConfig == other.conversionRateConfig && - currency == other.currency && - dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && - externalPriceId == other.externalPriceId && - fixedPriceQuantity == other.fixedPriceQuantity && - invoiceGroupingKey == other.invoiceGroupingKey && - invoicingCycleConfiguration == other.invoicingCycleConfiguration && - metadata == other.metadata && - referenceId == other.referenceId && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - bulkBpsConfig, - cadence, - itemId, - modelType, - name, - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - conversionRateConfig, - currency, - dimensionalPriceConfiguration, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewSubscriptionBulkBpsPrice{bulkBpsConfig=$bulkBpsConfig, cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" -} diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTieredBpsPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTieredBpsPrice.kt deleted file mode 100644 index e6fa5099a..000000000 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTieredBpsPrice.kt +++ /dev/null @@ -1,1374 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.withorb.api.models - -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import com.withorb.api.core.Enum -import com.withorb.api.core.ExcludeMissing -import com.withorb.api.core.JsonField -import com.withorb.api.core.JsonMissing -import com.withorb.api.core.JsonValue -import com.withorb.api.core.checkRequired -import com.withorb.api.core.toImmutable -import com.withorb.api.errors.OrbInvalidDataException -import java.util.Collections -import java.util.Objects - -class NewSubscriptionTieredBpsPrice -private constructor( - private val cadence: JsonField, - private val itemId: JsonField, - private val modelType: JsonField, - private val name: JsonField, - private val tieredBpsConfig: JsonField, - private val billableMetricId: JsonField, - private val billedInAdvance: JsonField, - private val billingCycleConfiguration: JsonField, - private val conversionRate: JsonField, - private val conversionRateConfig: JsonField, - private val currency: JsonField, - private val dimensionalPriceConfiguration: JsonField, - private val externalPriceId: JsonField, - private val fixedPriceQuantity: JsonField, - private val invoiceGroupingKey: JsonField, - private val invoicingCycleConfiguration: JsonField, - private val metadata: JsonField, - private val referenceId: JsonField, - private val additionalProperties: MutableMap, -) { - - @JsonCreator - private constructor( - @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), - @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - modelType: JsonField = JsonMissing.of(), - @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("tiered_bps_config") - @ExcludeMissing - tieredBpsConfig: JsonField = JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - billingCycleConfiguration: JsonField = JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("conversion_rate_config") - @ExcludeMissing - conversionRateConfig: JsonField = JsonMissing.of(), - @JsonProperty("currency") @ExcludeMissing currency: JsonField = JsonMissing.of(), - @JsonProperty("dimensional_price_configuration") - @ExcludeMissing - dimensionalPriceConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - invoicingCycleConfiguration: JsonField = JsonMissing.of(), - @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), - @JsonProperty("reference_id") - @ExcludeMissing - referenceId: JsonField = JsonMissing.of(), - ) : this( - cadence, - itemId, - modelType, - name, - tieredBpsConfig, - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - conversionRateConfig, - currency, - dimensionalPriceConfiguration, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - mutableMapOf(), - ) - - /** - * The cadence to bill for this price on. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly - * missing or null (e.g. if the server responded with an unexpected value). - */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - /** - * The id of the item the price will be associated with. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly - * missing or null (e.g. if the server responded with an unexpected value). - */ - fun itemId(): String = itemId.getRequired("item_id") - - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly - * missing or null (e.g. if the server responded with an unexpected value). - */ - fun modelType(): ModelType = modelType.getRequired("model_type") - - /** - * The name of the price. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly - * missing or null (e.g. if the server responded with an unexpected value). - */ - fun name(): String = name.getRequired("name") - - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly - * missing or null (e.g. if the server responded with an unexpected value). - */ - fun tieredBpsConfig(): TieredBpsConfig = tieredBpsConfig.getRequired("tiered_bps_config") - - /** - * The id of the billable metric for the price. Only needed if the price is usage-based. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - fun billableMetricId(): String? = billableMetricId.getNullable("billable_metric_id") - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this is true, - * and in-arrears if this is false. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") - - /** - * For custom cadence: specifies the duration of the billing period in days or months. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - fun billingCycleConfiguration(): NewBillingCycleConfiguration? = - billingCycleConfiguration.getNullable("billing_cycle_configuration") - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") - - /** - * The configuration for the rate of the price currency to the invoicing currency. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - fun conversionRateConfig(): ConversionRateConfig? = - conversionRateConfig.getNullable("conversion_rate_config") - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this price is - * billed. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - fun currency(): String? = currency.getNullable("currency") - - /** - * For dimensional price: specifies a price group and dimension values - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = - dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") - - /** - * An alias for the price. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") - - /** - * If the Price represents a fixed cost, this represents the quantity of units applied. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - fun fixedPriceQuantity(): Double? = fixedPriceQuantity.getNullable("fixed_price_quantity") - - /** - * The property used to group this price on an invoice - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - fun invoiceGroupingKey(): String? = invoiceGroupingKey.getNullable("invoice_grouping_key") - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. If - * unspecified, a single invoice is produced per billing cycle. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by setting - * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to - * `null`. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - fun metadata(): Metadata? = metadata.getNullable("metadata") - - /** - * A transient ID that can be used to reference this price when adding adjustments in the same - * API call. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - fun referenceId(): String? = referenceId.getNullable("reference_id") - - /** - * Returns the raw JSON value of [cadence]. - * - * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence - - /** - * Returns the raw JSON value of [itemId]. - * - * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - /** - * Returns the raw JSON value of [modelType]. - * - * Unlike [modelType], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonField = modelType - - /** - * Returns the raw JSON value of [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - /** - * Returns the raw JSON value of [tieredBpsConfig]. - * - * Unlike [tieredBpsConfig], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("tiered_bps_config") - @ExcludeMissing - fun _tieredBpsConfig(): JsonField = tieredBpsConfig - - /** - * Returns the raw JSON value of [billableMetricId]. - * - * Unlike [billableMetricId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = billableMetricId - - /** - * Returns the raw JSON value of [billedInAdvance]. - * - * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance - - /** - * Returns the raw JSON value of [billingCycleConfiguration]. - * - * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** - * Returns the raw JSON value of [conversionRate]. - * - * Unlike [conversionRate], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** - * Returns the raw JSON value of [conversionRateConfig]. - * - * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("conversion_rate_config") - @ExcludeMissing - fun _conversionRateConfig(): JsonField = conversionRateConfig - - /** - * Returns the raw JSON value of [currency]. - * - * Unlike [currency], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - - /** - * Returns the raw JSON value of [dimensionalPriceConfiguration]. - * - * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("dimensional_price_configuration") - @ExcludeMissing - fun _dimensionalPriceConfiguration(): JsonField = - dimensionalPriceConfiguration - - /** - * Returns the raw JSON value of [externalPriceId]. - * - * Unlike [externalPriceId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * Returns the raw JSON value of [fixedPriceQuantity]. - * - * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** - * Returns the raw JSON value of [invoiceGroupingKey]. - * - * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Returns the raw JSON value of [invoicingCycleConfiguration]. - * - * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * Returns the raw JSON value of [metadata]. - * - * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata - - /** - * Returns the raw JSON value of [referenceId]. - * - * Unlike [referenceId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("reference_id") - @ExcludeMissing - fun _referenceId(): JsonField = referenceId - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [NewSubscriptionTieredBpsPrice]. - * - * The following fields are required: - * ```kotlin - * .cadence() - * .itemId() - * .modelType() - * .name() - * .tieredBpsConfig() - * ``` - */ - fun builder() = Builder() - } - - /** A builder for [NewSubscriptionTieredBpsPrice]. */ - class Builder internal constructor() { - - private var cadence: JsonField? = null - private var itemId: JsonField? = null - private var modelType: JsonField? = null - private var name: JsonField? = null - private var tieredBpsConfig: JsonField? = null - private var billableMetricId: JsonField = JsonMissing.of() - private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var conversionRateConfig: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var dimensionalPriceConfiguration: JsonField = - JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var referenceId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(newSubscriptionTieredBpsPrice: NewSubscriptionTieredBpsPrice) = apply { - cadence = newSubscriptionTieredBpsPrice.cadence - itemId = newSubscriptionTieredBpsPrice.itemId - modelType = newSubscriptionTieredBpsPrice.modelType - name = newSubscriptionTieredBpsPrice.name - tieredBpsConfig = newSubscriptionTieredBpsPrice.tieredBpsConfig - billableMetricId = newSubscriptionTieredBpsPrice.billableMetricId - billedInAdvance = newSubscriptionTieredBpsPrice.billedInAdvance - billingCycleConfiguration = newSubscriptionTieredBpsPrice.billingCycleConfiguration - conversionRate = newSubscriptionTieredBpsPrice.conversionRate - conversionRateConfig = newSubscriptionTieredBpsPrice.conversionRateConfig - currency = newSubscriptionTieredBpsPrice.currency - dimensionalPriceConfiguration = - newSubscriptionTieredBpsPrice.dimensionalPriceConfiguration - externalPriceId = newSubscriptionTieredBpsPrice.externalPriceId - fixedPriceQuantity = newSubscriptionTieredBpsPrice.fixedPriceQuantity - invoiceGroupingKey = newSubscriptionTieredBpsPrice.invoiceGroupingKey - invoicingCycleConfiguration = newSubscriptionTieredBpsPrice.invoicingCycleConfiguration - metadata = newSubscriptionTieredBpsPrice.metadata - referenceId = newSubscriptionTieredBpsPrice.referenceId - additionalProperties = newSubscriptionTieredBpsPrice.additionalProperties.toMutableMap() - } - - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** - * Sets [Builder.cadence] to an arbitrary JSON value. - * - * You should usually call [Builder.cadence] with a well-typed [Cadence] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - - /** The id of the item the price will be associated with. */ - fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - - /** - * Sets [Builder.itemId] to an arbitrary JSON value. - * - * You should usually call [Builder.itemId] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - - /** - * Sets [Builder.modelType] to an arbitrary JSON value. - * - * You should usually call [Builder.modelType] with a well-typed [ModelType] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun modelType(modelType: JsonField) = apply { this.modelType = modelType } - - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) - - /** - * Sets [Builder.name] to an arbitrary JSON value. - * - * You should usually call [Builder.name] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun name(name: JsonField) = apply { this.name = name } - - fun tieredBpsConfig(tieredBpsConfig: TieredBpsConfig) = - tieredBpsConfig(JsonField.of(tieredBpsConfig)) - - /** - * Sets [Builder.tieredBpsConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.tieredBpsConfig] with a well-typed [TieredBpsConfig] - * value instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun tieredBpsConfig(tieredBpsConfig: JsonField) = apply { - this.tieredBpsConfig = tieredBpsConfig - } - - /** The id of the billable metric for the price. Only needed if the price is usage-based. */ - fun billableMetricId(billableMetricId: String?) = - billableMetricId(JsonField.ofNullable(billableMetricId)) - - /** - * Sets [Builder.billableMetricId] to an arbitrary JSON value. - * - * You should usually call [Builder.billableMetricId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun billableMetricId(billableMetricId: JsonField) = apply { - this.billableMetricId = billableMetricId - } - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this is - * true, and in-arrears if this is false. - */ - fun billedInAdvance(billedInAdvance: Boolean?) = - billedInAdvance(JsonField.ofNullable(billedInAdvance)) - - /** - * Alias for [Builder.billedInAdvance]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun billedInAdvance(billedInAdvance: Boolean) = billedInAdvance(billedInAdvance as Boolean?) - - /** - * Sets [Builder.billedInAdvance] to an arbitrary JSON value. - * - * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun billedInAdvance(billedInAdvance: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** For custom cadence: specifies the duration of the billing period in days or months. */ - fun billingCycleConfiguration(billingCycleConfiguration: NewBillingCycleConfiguration?) = - billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - - /** - * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.billingCycleConfiguration] with a well-typed - * [NewBillingCycleConfiguration] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: JsonField - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double?) = - conversionRate(JsonField.ofNullable(conversionRate)) - - /** - * Alias for [Builder.conversionRate]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) - - /** - * Sets [Builder.conversionRate] to an arbitrary JSON value. - * - * You should usually call [Builder.conversionRate] with a well-typed [Double] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** The configuration for the rate of the price currency to the invoicing currency. */ - fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = - conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) - - /** - * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.conversionRateConfig] with a well-typed - * [ConversionRateConfig] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun conversionRateConfig(conversionRateConfig: JsonField) = apply { - this.conversionRateConfig = conversionRateConfig - } - - /** Alias for calling [conversionRateConfig] with `ConversionRateConfig.ofUnit(unit)`. */ - fun conversionRateConfig(unit: UnitConversionRateConfig) = - conversionRateConfig(ConversionRateConfig.ofUnit(unit)) - - /** - * Alias for calling [conversionRateConfig] with the following: - * ```kotlin - * UnitConversionRateConfig.builder() - * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) - * .unitConfig(unitConfig) - * .build() - * ``` - */ - fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = - conversionRateConfig( - UnitConversionRateConfig.builder() - .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) - .unitConfig(unitConfig) - .build() - ) - - /** - * Alias for calling [conversionRateConfig] with `ConversionRateConfig.ofTiered(tiered)`. - */ - fun conversionRateConfig(tiered: TieredConversionRateConfig) = - conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) - - /** - * Alias for calling [conversionRateConfig] with the following: - * ```kotlin - * TieredConversionRateConfig.builder() - * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) - * .tieredConfig(tieredConfig) - * .build() - * ``` - */ - fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = - conversionRateConfig( - TieredConversionRateConfig.builder() - .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) - .tieredConfig(tieredConfig) - .build() - ) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this price is - * billed. - */ - fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) - - /** - * Sets [Builder.currency] to an arbitrary JSON value. - * - * You should usually call [Builder.currency] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } - - /** For dimensional price: specifies a price group and dimension values */ - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? - ) = dimensionalPriceConfiguration(JsonField.ofNullable(dimensionalPriceConfiguration)) - - /** - * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.dimensionalPriceConfiguration] with a well-typed - * [NewDimensionalPriceConfiguration] value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: JsonField - ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** - * Sets [Builder.externalPriceId] to an arbitrary JSON value. - * - * You should usually call [Builder.externalPriceId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun externalPriceId(externalPriceId: JsonField) = apply { - this.externalPriceId = externalPriceId - } - - /** If the Price represents a fixed cost, this represents the quantity of units applied. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = - fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) - - /** - * Alias for [Builder.fixedPriceQuantity]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. - * - * You should usually call [Builder.fixedPriceQuantity] with a well-typed [Double] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = - invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) - - /** - * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. - * - * You should usually call [Builder.invoiceGroupingKey] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { - this.invoiceGroupingKey = invoiceGroupingKey - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. If - * unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: NewBillingCycleConfiguration? - ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) - - /** - * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.invoicingCycleConfiguration] with a well-typed - * [NewBillingCycleConfiguration] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by - * setting the value to `null`, and the entire metadata mapping can be cleared by setting - * `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * Sets [Builder.metadata] to an arbitrary JSON value. - * - * You should usually call [Builder.metadata] with a well-typed [Metadata] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - - /** - * A transient ID that can be used to reference this price when adding adjustments in the - * same API call. - */ - fun referenceId(referenceId: String?) = referenceId(JsonField.ofNullable(referenceId)) - - /** - * Sets [Builder.referenceId] to an arbitrary JSON value. - * - * You should usually call [Builder.referenceId] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun referenceId(referenceId: JsonField) = apply { this.referenceId = referenceId } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [NewSubscriptionTieredBpsPrice]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```kotlin - * .cadence() - * .itemId() - * .modelType() - * .name() - * .tieredBpsConfig() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): NewSubscriptionTieredBpsPrice = - NewSubscriptionTieredBpsPrice( - checkRequired("cadence", cadence), - checkRequired("itemId", itemId), - checkRequired("modelType", modelType), - checkRequired("name", name), - checkRequired("tieredBpsConfig", tieredBpsConfig), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - conversionRateConfig, - currency, - dimensionalPriceConfiguration, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): NewSubscriptionTieredBpsPrice = apply { - if (validated) { - return@apply - } - - cadence().validate() - itemId() - modelType().validate() - name() - tieredBpsConfig().validate() - billableMetricId() - billedInAdvance() - billingCycleConfiguration()?.validate() - conversionRate() - conversionRateConfig()?.validate() - currency() - dimensionalPriceConfiguration()?.validate() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration()?.validate() - metadata()?.validate() - referenceId() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (cadence.asKnown()?.validity() ?: 0) + - (if (itemId.asKnown() == null) 0 else 1) + - (modelType.asKnown()?.validity() ?: 0) + - (if (name.asKnown() == null) 0 else 1) + - (tieredBpsConfig.asKnown()?.validity() ?: 0) + - (if (billableMetricId.asKnown() == null) 0 else 1) + - (if (billedInAdvance.asKnown() == null) 0 else 1) + - (billingCycleConfiguration.asKnown()?.validity() ?: 0) + - (if (conversionRate.asKnown() == null) 0 else 1) + - (conversionRateConfig.asKnown()?.validity() ?: 0) + - (if (currency.asKnown() == null) 0 else 1) + - (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + - (if (externalPriceId.asKnown() == null) 0 else 1) + - (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + - (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + - (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + - (metadata.asKnown()?.validity() ?: 0) + - (if (referenceId.asKnown() == null) 0 else 1) - - /** The cadence to bill for this price on. */ - class Cadence @JsonCreator private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API may respond with new members that the SDK is - * unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - val ANNUAL = of("annual") - - val SEMI_ANNUAL = of("semi_annual") - - val MONTHLY = of("monthly") - - val QUARTERLY = of("quarterly") - - val ONE_TIME = of("one_time") - - val CUSTOM = of("custom") - - fun of(value: String) = Cadence(JsonField.of(value)) - } - - /** An enum containing [Cadence]'s known values. */ - enum class Known { - ANNUAL, - SEMI_ANNUAL, - MONTHLY, - QUARTERLY, - ONE_TIME, - CUSTOM, - } - - /** - * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Cadence] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if the - * SDK is on an older version than the API, then the API may respond with new members that - * the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - ANNUAL, - SEMI_ANNUAL, - MONTHLY, - QUARTERLY, - ONE_TIME, - CUSTOM, - /** An enum member indicating that [Cadence] was instantiated with an unknown value. */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you want - * to throw for the unknown case. - */ - fun value(): Value = - when (this) { - ANNUAL -> Value.ANNUAL - SEMI_ANNUAL -> Value.SEMI_ANNUAL - MONTHLY -> Value.MONTHLY - QUARTERLY -> Value.QUARTERLY - ONE_TIME -> Value.ONE_TIME - CUSTOM -> Value.CUSTOM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and don't - * want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known member. - */ - fun known(): Known = - when (this) { - ANNUAL -> Known.ANNUAL - SEMI_ANNUAL -> Known.SEMI_ANNUAL - MONTHLY -> Known.MONTHLY - QUARTERLY -> Known.QUARTERLY - ONE_TIME -> Known.ONE_TIME - CUSTOM -> Known.CUSTOM - else -> throw OrbInvalidDataException("Unknown Cadence: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the expected - * primitive type. - */ - fun asString(): String = - _value().asString() ?: throw OrbInvalidDataException("Value is not a String") - - private var validated: Boolean = false - - fun validate(): Cadence = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Cadence && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class ModelType @JsonCreator private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API may respond with new members that the SDK is - * unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - val TIERED_BPS = of("tiered_bps") - - fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - TIERED_BPS - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if the - * SDK is on an older version than the API, then the API may respond with new members that - * the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - TIERED_BPS, - /** - * An enum member indicating that [ModelType] was instantiated with an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you want - * to throw for the unknown case. - */ - fun value(): Value = - when (this) { - TIERED_BPS -> Value.TIERED_BPS - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and don't - * want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known member. - */ - fun known(): Known = - when (this) { - TIERED_BPS -> Known.TIERED_BPS - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the expected - * primitive type. - */ - fun asString(): String = - _value().asString() ?: throw OrbInvalidDataException("Value is not a String") - - private var validated: Boolean = false - - fun validate(): ModelType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ModelType && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by setting - * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to - * `null`. - */ - class Metadata - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Metadata]. */ - fun builder() = Builder() - } - - /** A builder for [Metadata]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(metadata: Metadata) = apply { - additionalProperties = metadata.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Metadata]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Metadata && additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is NewSubscriptionTieredBpsPrice && - cadence == other.cadence && - itemId == other.itemId && - modelType == other.modelType && - name == other.name && - tieredBpsConfig == other.tieredBpsConfig && - billableMetricId == other.billableMetricId && - billedInAdvance == other.billedInAdvance && - billingCycleConfiguration == other.billingCycleConfiguration && - conversionRate == other.conversionRate && - conversionRateConfig == other.conversionRateConfig && - currency == other.currency && - dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && - externalPriceId == other.externalPriceId && - fixedPriceQuantity == other.fixedPriceQuantity && - invoiceGroupingKey == other.invoiceGroupingKey && - invoicingCycleConfiguration == other.invoicingCycleConfiguration && - metadata == other.metadata && - referenceId == other.referenceId && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - cadence, - itemId, - modelType, - name, - tieredBpsConfig, - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - conversionRateConfig, - currency, - dimensionalPriceConfiguration, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewSubscriptionTieredBpsPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredBpsConfig=$tieredBpsConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" -} diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PerPriceCost.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PerPriceCost.kt index 402288370..631e88a88 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PerPriceCost.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PerPriceCost.kt @@ -179,15 +179,6 @@ private constructor( /** Alias for calling [price] with `Price.ofTiered(tiered)`. */ fun price(tiered: Price.Tiered) = price(Price.ofTiered(tiered)) - /** Alias for calling [price] with `Price.ofTieredBps(tieredBps)`. */ - fun price(tieredBps: Price.TieredBps) = price(Price.ofTieredBps(tieredBps)) - - /** Alias for calling [price] with `Price.ofBps(bps)`. */ - fun price(bps: Price.Bps) = price(Price.ofBps(bps)) - - /** Alias for calling [price] with `Price.ofBulkBps(bulkBps)`. */ - fun price(bulkBps: Price.BulkBps) = price(Price.ofBulkBps(bulkBps)) - /** Alias for calling [price] with `Price.ofBulk(bulk)`. */ fun price(bulk: Price.Bulk) = price(Price.ofBulk(bulk)) @@ -299,6 +290,9 @@ private constructor( fun price(groupedWithMinMaxThresholds: Price.GroupedWithMinMaxThresholds) = price(Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)) + /** Alias for calling [price] with `Price.ofMinimum(minimum)`. */ + fun price(minimum: Price.Minimum) = price(Price.ofMinimum(minimum)) + /** The price the cost is associated with */ fun priceId(priceId: String) = priceId(JsonField.of(priceId)) diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Plan.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Plan.kt index e7d5a55cc..e7c11dde6 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Plan.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Plan.kt @@ -1054,15 +1054,6 @@ private constructor( /** Alias for calling [addPrice] with `Price.ofTiered(tiered)`. */ fun addPrice(tiered: Price.Tiered) = addPrice(Price.ofTiered(tiered)) - /** Alias for calling [addPrice] with `Price.ofTieredBps(tieredBps)`. */ - fun addPrice(tieredBps: Price.TieredBps) = addPrice(Price.ofTieredBps(tieredBps)) - - /** Alias for calling [addPrice] with `Price.ofBps(bps)`. */ - fun addPrice(bps: Price.Bps) = addPrice(Price.ofBps(bps)) - - /** Alias for calling [addPrice] with `Price.ofBulkBps(bulkBps)`. */ - fun addPrice(bulkBps: Price.BulkBps) = addPrice(Price.ofBulkBps(bulkBps)) - /** Alias for calling [addPrice] with `Price.ofBulk(bulk)`. */ fun addPrice(bulk: Price.Bulk) = addPrice(Price.ofBulk(bulk)) @@ -1182,6 +1173,9 @@ private constructor( fun addPrice(groupedWithMinMaxThresholds: Price.GroupedWithMinMaxThresholds) = addPrice(Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)) + /** Alias for calling [addPrice] with `Price.ofMinimum(minimum)`. */ + fun addPrice(minimum: Price.Minimum) = addPrice(Price.ofMinimum(minimum)) + fun product(product: Product) = product(JsonField.of(product)) /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanCreateParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanCreateParams.kt index 81a74e599..e0303df01 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanCreateParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanCreateParams.kt @@ -1325,15 +1325,6 @@ private constructor( /** Alias for calling [price] with `InnerPrice.ofTiered(tiered)`. */ fun price(tiered: NewPlanTieredPrice) = price(InnerPrice.ofTiered(tiered)) - /** Alias for calling [price] with `InnerPrice.ofTieredBps(tieredBps)`. */ - fun price(tieredBps: NewPlanTieredBpsPrice) = price(InnerPrice.ofTieredBps(tieredBps)) - - /** Alias for calling [price] with `InnerPrice.ofBps(bps)`. */ - fun price(bps: NewPlanBpsPrice) = price(InnerPrice.ofBps(bps)) - - /** Alias for calling [price] with `InnerPrice.ofBulkBps(bulkBps)`. */ - fun price(bulkBps: NewPlanBulkBpsPrice) = price(InnerPrice.ofBulkBps(bulkBps)) - /** Alias for calling [price] with `InnerPrice.ofBulk(bulk)`. */ fun price(bulk: NewPlanBulkPrice) = price(InnerPrice.ofBulk(bulk)) @@ -1398,6 +1389,13 @@ private constructor( fun price(groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice) = price(InnerPrice.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)) + /** + * Alias for calling [price] with + * `InnerPrice.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)`. + */ + fun price(groupedWithMinMaxThresholds: InnerPrice.GroupedWithMinMaxThresholds) = + price(InnerPrice.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)) + /** * Alias for calling [price] with * `InnerPrice.ofMatrixWithDisplayName(matrixWithDisplayName)`. @@ -1465,6 +1463,9 @@ private constructor( fun price(groupedTiered: NewPlanGroupedTieredPrice) = price(InnerPrice.ofGroupedTiered(groupedTiered)) + /** Alias for calling [price] with `InnerPrice.ofMinimum(minimum)`. */ + fun price(minimum: InnerPrice.Minimum) = price(InnerPrice.ofMinimum(minimum)) + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -1534,9 +1535,6 @@ private constructor( private val package_: NewPlanPackagePrice? = null, private val matrix: NewPlanMatrixPrice? = null, private val tiered: NewPlanTieredPrice? = null, - private val tieredBps: NewPlanTieredBpsPrice? = null, - private val bps: NewPlanBpsPrice? = null, - private val bulkBps: NewPlanBulkBpsPrice? = null, private val bulk: NewPlanBulkPrice? = null, private val thresholdTotalAmount: NewPlanThresholdTotalAmountPrice? = null, private val tieredPackage: NewPlanTieredPackagePrice? = null, @@ -1548,6 +1546,7 @@ private constructor( private val groupedAllocation: NewPlanGroupedAllocationPrice? = null, private val groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice? = null, private val groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice? = null, + private val groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds? = null, private val matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice? = null, private val bulkWithProration: NewPlanBulkWithProrationPrice? = null, private val groupedTieredPackage: NewPlanGroupedTieredPackagePrice? = null, @@ -1561,6 +1560,7 @@ private constructor( private val tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice? = null, private val matrixWithAllocation: NewPlanMatrixWithAllocationPrice? = null, private val groupedTiered: NewPlanGroupedTieredPrice? = null, + private val minimum: Minimum? = null, private val _json: JsonValue? = null, ) { @@ -1572,12 +1572,6 @@ private constructor( fun tiered(): NewPlanTieredPrice? = tiered - fun tieredBps(): NewPlanTieredBpsPrice? = tieredBps - - fun bps(): NewPlanBpsPrice? = bps - - fun bulkBps(): NewPlanBulkBpsPrice? = bulkBps - fun bulk(): NewPlanBulkPrice? = bulk fun thresholdTotalAmount(): NewPlanThresholdTotalAmountPrice? = thresholdTotalAmount @@ -1602,6 +1596,9 @@ private constructor( fun groupedWithMeteredMinimum(): NewPlanGroupedWithMeteredMinimumPrice? = groupedWithMeteredMinimum + fun groupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds? = + groupedWithMinMaxThresholds + fun matrixWithDisplayName(): NewPlanMatrixWithDisplayNamePrice? = matrixWithDisplayName fun bulkWithProration(): NewPlanBulkWithProrationPrice? = bulkWithProration @@ -1625,6 +1622,8 @@ private constructor( fun groupedTiered(): NewPlanGroupedTieredPrice? = groupedTiered + fun minimum(): Minimum? = minimum + fun isUnit(): Boolean = unit != null fun isPackage(): Boolean = package_ != null @@ -1633,12 +1632,6 @@ private constructor( fun isTiered(): Boolean = tiered != null - fun isTieredBps(): Boolean = tieredBps != null - - fun isBps(): Boolean = bps != null - - fun isBulkBps(): Boolean = bulkBps != null - fun isBulk(): Boolean = bulk != null fun isThresholdTotalAmount(): Boolean = thresholdTotalAmount != null @@ -1661,6 +1654,8 @@ private constructor( fun isGroupedWithMeteredMinimum(): Boolean = groupedWithMeteredMinimum != null + fun isGroupedWithMinMaxThresholds(): Boolean = groupedWithMinMaxThresholds != null + fun isMatrixWithDisplayName(): Boolean = matrixWithDisplayName != null fun isBulkWithProration(): Boolean = bulkWithProration != null @@ -1682,6 +1677,8 @@ private constructor( fun isGroupedTiered(): Boolean = groupedTiered != null + fun isMinimum(): Boolean = minimum != null + fun asUnit(): NewPlanUnitPrice = unit.getOrThrow("unit") fun asPackage(): NewPlanPackagePrice = package_.getOrThrow("package_") @@ -1690,12 +1687,6 @@ private constructor( fun asTiered(): NewPlanTieredPrice = tiered.getOrThrow("tiered") - fun asTieredBps(): NewPlanTieredBpsPrice = tieredBps.getOrThrow("tieredBps") - - fun asBps(): NewPlanBpsPrice = bps.getOrThrow("bps") - - fun asBulkBps(): NewPlanBulkBpsPrice = bulkBps.getOrThrow("bulkBps") - fun asBulk(): NewPlanBulkPrice = bulk.getOrThrow("bulk") fun asThresholdTotalAmount(): NewPlanThresholdTotalAmountPrice = @@ -1728,6 +1719,9 @@ private constructor( fun asGroupedWithMeteredMinimum(): NewPlanGroupedWithMeteredMinimumPrice = groupedWithMeteredMinimum.getOrThrow("groupedWithMeteredMinimum") + fun asGroupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds = + groupedWithMinMaxThresholds.getOrThrow("groupedWithMinMaxThresholds") + fun asMatrixWithDisplayName(): NewPlanMatrixWithDisplayNamePrice = matrixWithDisplayName.getOrThrow("matrixWithDisplayName") @@ -1758,6 +1752,8 @@ private constructor( fun asGroupedTiered(): NewPlanGroupedTieredPrice = groupedTiered.getOrThrow("groupedTiered") + fun asMinimum(): Minimum = minimum.getOrThrow("minimum") + fun _json(): JsonValue? = _json fun accept(visitor: Visitor): T = @@ -1766,9 +1762,6 @@ private constructor( package_ != null -> visitor.visitPackage(package_) matrix != null -> visitor.visitMatrix(matrix) tiered != null -> visitor.visitTiered(tiered) - tieredBps != null -> visitor.visitTieredBps(tieredBps) - bps != null -> visitor.visitBps(bps) - bulkBps != null -> visitor.visitBulkBps(bulkBps) bulk != null -> visitor.visitBulk(bulk) thresholdTotalAmount != null -> visitor.visitThresholdTotalAmount(thresholdTotalAmount) @@ -1785,6 +1778,8 @@ private constructor( visitor.visitGroupedWithProratedMinimum(groupedWithProratedMinimum) groupedWithMeteredMinimum != null -> visitor.visitGroupedWithMeteredMinimum(groupedWithMeteredMinimum) + groupedWithMinMaxThresholds != null -> + visitor.visitGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds) matrixWithDisplayName != null -> visitor.visitMatrixWithDisplayName(matrixWithDisplayName) bulkWithProration != null -> visitor.visitBulkWithProration(bulkWithProration) @@ -1805,6 +1800,7 @@ private constructor( matrixWithAllocation != null -> visitor.visitMatrixWithAllocation(matrixWithAllocation) groupedTiered != null -> visitor.visitGroupedTiered(groupedTiered) + minimum != null -> visitor.visitMinimum(minimum) else -> visitor.unknown(_json) } @@ -1833,18 +1829,6 @@ private constructor( tiered.validate() } - override fun visitTieredBps(tieredBps: NewPlanTieredBpsPrice) { - tieredBps.validate() - } - - override fun visitBps(bps: NewPlanBpsPrice) { - bps.validate() - } - - override fun visitBulkBps(bulkBps: NewPlanBulkBpsPrice) { - bulkBps.validate() - } - override fun visitBulk(bulk: NewPlanBulkPrice) { bulk.validate() } @@ -1907,6 +1891,12 @@ private constructor( groupedWithMeteredMinimum.validate() } + override fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) { + groupedWithMinMaxThresholds.validate() + } + override fun visitMatrixWithDisplayName( matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice ) { @@ -1965,6 +1955,10 @@ private constructor( override fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) { groupedTiered.validate() } + + override fun visitMinimum(minimum: Minimum) { + minimum.validate() + } } ) validated = true @@ -1996,13 +1990,6 @@ private constructor( override fun visitTiered(tiered: NewPlanTieredPrice) = tiered.validity() - override fun visitTieredBps(tieredBps: NewPlanTieredBpsPrice) = - tieredBps.validity() - - override fun visitBps(bps: NewPlanBpsPrice) = bps.validity() - - override fun visitBulkBps(bulkBps: NewPlanBulkBpsPrice) = bulkBps.validity() - override fun visitBulk(bulk: NewPlanBulkPrice) = bulk.validity() override fun visitThresholdTotalAmount( @@ -2044,6 +2031,10 @@ private constructor( groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice ) = groupedWithMeteredMinimum.validity() + override fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) = groupedWithMinMaxThresholds.validity() + override fun visitMatrixWithDisplayName( matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice ) = matrixWithDisplayName.validity() @@ -2084,6 +2075,8 @@ private constructor( override fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) = groupedTiered.validity() + override fun visitMinimum(minimum: Minimum) = minimum.validity() + override fun unknown(json: JsonValue?) = 0 } ) @@ -2098,9 +2091,6 @@ private constructor( package_ == other.package_ && matrix == other.matrix && tiered == other.tiered && - tieredBps == other.tieredBps && - bps == other.bps && - bulkBps == other.bulkBps && bulk == other.bulk && thresholdTotalAmount == other.thresholdTotalAmount && tieredPackage == other.tieredPackage && @@ -2112,6 +2102,7 @@ private constructor( groupedAllocation == other.groupedAllocation && groupedWithProratedMinimum == other.groupedWithProratedMinimum && groupedWithMeteredMinimum == other.groupedWithMeteredMinimum && + groupedWithMinMaxThresholds == other.groupedWithMinMaxThresholds && matrixWithDisplayName == other.matrixWithDisplayName && bulkWithProration == other.bulkWithProration && groupedTieredPackage == other.groupedTieredPackage && @@ -2121,7 +2112,8 @@ private constructor( cumulativeGroupedBulk == other.cumulativeGroupedBulk && tieredPackageWithMinimum == other.tieredPackageWithMinimum && matrixWithAllocation == other.matrixWithAllocation && - groupedTiered == other.groupedTiered + groupedTiered == other.groupedTiered && + minimum == other.minimum } override fun hashCode(): Int = @@ -2130,9 +2122,6 @@ private constructor( package_, matrix, tiered, - tieredBps, - bps, - bulkBps, bulk, thresholdTotalAmount, tieredPackage, @@ -2144,6 +2133,7 @@ private constructor( groupedAllocation, groupedWithProratedMinimum, groupedWithMeteredMinimum, + groupedWithMinMaxThresholds, matrixWithDisplayName, bulkWithProration, groupedTieredPackage, @@ -2154,6 +2144,7 @@ private constructor( tieredPackageWithMinimum, matrixWithAllocation, groupedTiered, + minimum, ) override fun toString(): String = @@ -2162,9 +2153,6 @@ private constructor( package_ != null -> "InnerPrice{package_=$package_}" matrix != null -> "InnerPrice{matrix=$matrix}" tiered != null -> "InnerPrice{tiered=$tiered}" - tieredBps != null -> "InnerPrice{tieredBps=$tieredBps}" - bps != null -> "InnerPrice{bps=$bps}" - bulkBps != null -> "InnerPrice{bulkBps=$bulkBps}" bulk != null -> "InnerPrice{bulk=$bulk}" thresholdTotalAmount != null -> "InnerPrice{thresholdTotalAmount=$thresholdTotalAmount}" @@ -2181,6 +2169,8 @@ private constructor( "InnerPrice{groupedWithProratedMinimum=$groupedWithProratedMinimum}" groupedWithMeteredMinimum != null -> "InnerPrice{groupedWithMeteredMinimum=$groupedWithMeteredMinimum}" + groupedWithMinMaxThresholds != null -> + "InnerPrice{groupedWithMinMaxThresholds=$groupedWithMinMaxThresholds}" matrixWithDisplayName != null -> "InnerPrice{matrixWithDisplayName=$matrixWithDisplayName}" bulkWithProration != null -> "InnerPrice{bulkWithProration=$bulkWithProration}" @@ -2199,6 +2189,7 @@ private constructor( matrixWithAllocation != null -> "InnerPrice{matrixWithAllocation=$matrixWithAllocation}" groupedTiered != null -> "InnerPrice{groupedTiered=$groupedTiered}" + minimum != null -> "InnerPrice{minimum=$minimum}" _json != null -> "InnerPrice{_unknown=$_json}" else -> throw IllegalStateException("Invalid InnerPrice") } @@ -2213,13 +2204,6 @@ private constructor( fun ofTiered(tiered: NewPlanTieredPrice) = InnerPrice(tiered = tiered) - fun ofTieredBps(tieredBps: NewPlanTieredBpsPrice) = - InnerPrice(tieredBps = tieredBps) - - fun ofBps(bps: NewPlanBpsPrice) = InnerPrice(bps = bps) - - fun ofBulkBps(bulkBps: NewPlanBulkBpsPrice) = InnerPrice(bulkBps = bulkBps) - fun ofBulk(bulk: NewPlanBulkPrice) = InnerPrice(bulk = bulk) fun ofThresholdTotalAmount(thresholdTotalAmount: NewPlanThresholdTotalAmountPrice) = @@ -2255,6 +2239,10 @@ private constructor( groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice ) = InnerPrice(groupedWithMeteredMinimum = groupedWithMeteredMinimum) + fun ofGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) = InnerPrice(groupedWithMinMaxThresholds = groupedWithMinMaxThresholds) + fun ofMatrixWithDisplayName( matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice ) = InnerPrice(matrixWithDisplayName = matrixWithDisplayName) @@ -2290,6 +2278,8 @@ private constructor( fun ofGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) = InnerPrice(groupedTiered = groupedTiered) + + fun ofMinimum(minimum: Minimum) = InnerPrice(minimum = minimum) } /** @@ -2306,12 +2296,6 @@ private constructor( fun visitTiered(tiered: NewPlanTieredPrice): T - fun visitTieredBps(tieredBps: NewPlanTieredBpsPrice): T - - fun visitBps(bps: NewPlanBpsPrice): T - - fun visitBulkBps(bulkBps: NewPlanBulkBpsPrice): T - fun visitBulk(bulk: NewPlanBulkPrice): T fun visitThresholdTotalAmount( @@ -2342,6 +2326,10 @@ private constructor( groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice ): T + fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ): T + fun visitMatrixWithDisplayName( matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice ): T @@ -2378,6 +2366,8 @@ private constructor( fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice): T + fun visitMinimum(minimum: Minimum): T + /** * Maps an unknown variant of [InnerPrice] to a value of type [T]. * @@ -2420,21 +2410,6 @@ private constructor( InnerPrice(tiered = it, _json = json) } ?: InnerPrice(_json = json) } - "tiered_bps" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { InnerPrice(tieredBps = it, _json = json) } - ?: InnerPrice(_json = json) - } - "bps" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - InnerPrice(bps = it, _json = json) - } ?: InnerPrice(_json = json) - } - "bulk_bps" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { InnerPrice(bulkBps = it, _json = json) } - ?: InnerPrice(_json = json) - } "bulk" -> { return tryDeserialize(node, jacksonTypeRef())?.let { InnerPrice(bulk = it, _json = json) @@ -2517,6 +2492,14 @@ private constructor( ?.let { InnerPrice(groupedWithMeteredMinimum = it, _json = json) } ?: InnerPrice(_json = json) } + "grouped_with_min_max_thresholds" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { InnerPrice(groupedWithMinMaxThresholds = it, _json = json) } + ?: InnerPrice(_json = json) + } "matrix_with_display_name" -> { return tryDeserialize( node, @@ -2596,6 +2579,11 @@ private constructor( ?.let { InnerPrice(groupedTiered = it, _json = json) } ?: InnerPrice(_json = json) } + "minimum" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + InnerPrice(minimum = it, _json = json) + } ?: InnerPrice(_json = json) + } } return InnerPrice(_json = json) @@ -2614,9 +2602,6 @@ private constructor( value.package_ != null -> generator.writeObject(value.package_) value.matrix != null -> generator.writeObject(value.matrix) value.tiered != null -> generator.writeObject(value.tiered) - value.tieredBps != null -> generator.writeObject(value.tieredBps) - value.bps != null -> generator.writeObject(value.bps) - value.bulkBps != null -> generator.writeObject(value.bulkBps) value.bulk != null -> generator.writeObject(value.bulk) value.thresholdTotalAmount != null -> generator.writeObject(value.thresholdTotalAmount) @@ -2637,6 +2622,8 @@ private constructor( generator.writeObject(value.groupedWithProratedMinimum) value.groupedWithMeteredMinimum != null -> generator.writeObject(value.groupedWithMeteredMinimum) + value.groupedWithMinMaxThresholds != null -> + generator.writeObject(value.groupedWithMinMaxThresholds) value.matrixWithDisplayName != null -> generator.writeObject(value.matrixWithDisplayName) value.bulkWithProration != null -> @@ -2656,11 +2643,3057 @@ private constructor( value.matrixWithAllocation != null -> generator.writeObject(value.matrixWithAllocation) value.groupedTiered != null -> generator.writeObject(value.groupedTiered) + value.minimum != null -> generator.writeObject(value.minimum) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid InnerPrice") } } } + + class GroupedWithMinMaxThresholds + private constructor( + private val cadence: JsonField, + private val groupedWithMinMaxThresholdsConfig: + JsonField, + private val itemId: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("grouped_with_min_max_thresholds_config") + @ExcludeMissing + groupedWithMinMaxThresholdsConfig: + JsonField = + JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + groupedWithMinMaxThresholdsConfig, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupedWithMinMaxThresholdsConfig(): GroupedWithMinMaxThresholdsConfig = + groupedWithMinMaxThresholdsConfig.getRequired( + "grouped_with_min_max_thresholds_config" + ) + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * Expected to always return the following: + * ```kotlin + * JsonValue.from("grouped_with_min_max_thresholds") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = billableMetricId.getNullable("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + invoiceGroupingKey.getNullable("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [groupedWithMinMaxThresholdsConfig]. + * + * Unlike [groupedWithMinMaxThresholdsConfig], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("grouped_with_min_max_thresholds_config") + @ExcludeMissing + fun _groupedWithMinMaxThresholdsConfig(): + JsonField = groupedWithMinMaxThresholdsConfig + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [GroupedWithMinMaxThresholds]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .groupedWithMinMaxThresholdsConfig() + * .itemId() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [GroupedWithMinMaxThresholds]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var groupedWithMinMaxThresholdsConfig: + JsonField? = + null + private var itemId: JsonField? = null + private var modelType: JsonValue = + JsonValue.from("grouped_with_min_max_thresholds") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds) = + apply { + cadence = groupedWithMinMaxThresholds.cadence + groupedWithMinMaxThresholdsConfig = + groupedWithMinMaxThresholds.groupedWithMinMaxThresholdsConfig + itemId = groupedWithMinMaxThresholds.itemId + modelType = groupedWithMinMaxThresholds.modelType + name = groupedWithMinMaxThresholds.name + billableMetricId = groupedWithMinMaxThresholds.billableMetricId + billedInAdvance = groupedWithMinMaxThresholds.billedInAdvance + billingCycleConfiguration = + groupedWithMinMaxThresholds.billingCycleConfiguration + conversionRate = groupedWithMinMaxThresholds.conversionRate + conversionRateConfig = groupedWithMinMaxThresholds.conversionRateConfig + currency = groupedWithMinMaxThresholds.currency + dimensionalPriceConfiguration = + groupedWithMinMaxThresholds.dimensionalPriceConfiguration + externalPriceId = groupedWithMinMaxThresholds.externalPriceId + fixedPriceQuantity = groupedWithMinMaxThresholds.fixedPriceQuantity + invoiceGroupingKey = groupedWithMinMaxThresholds.invoiceGroupingKey + invoicingCycleConfiguration = + groupedWithMinMaxThresholds.invoicingCycleConfiguration + metadata = groupedWithMinMaxThresholds.metadata + referenceId = groupedWithMinMaxThresholds.referenceId + additionalProperties = + groupedWithMinMaxThresholds.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + fun groupedWithMinMaxThresholdsConfig( + groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + ) = + groupedWithMinMaxThresholdsConfig( + JsonField.of(groupedWithMinMaxThresholdsConfig) + ) + + /** + * Sets [Builder.groupedWithMinMaxThresholdsConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.groupedWithMinMaxThresholdsConfig] with a + * well-typed [GroupedWithMinMaxThresholdsConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun groupedWithMinMaxThresholdsConfig( + groupedWithMinMaxThresholdsConfig: + JsonField + ) = apply { + this.groupedWithMinMaxThresholdsConfig = groupedWithMinMaxThresholdsConfig + } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("grouped_with_min_max_thresholds") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [GroupedWithMinMaxThresholds]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .groupedWithMinMaxThresholdsConfig() + * .itemId() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedWithMinMaxThresholds = + GroupedWithMinMaxThresholds( + checkRequired("cadence", cadence), + checkRequired( + "groupedWithMinMaxThresholdsConfig", + groupedWithMinMaxThresholdsConfig, + ), + checkRequired("itemId", itemId), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GroupedWithMinMaxThresholds = apply { + if (validated) { + return@apply + } + + cadence().validate() + groupedWithMinMaxThresholdsConfig().validate() + itemId() + _modelType().let { + if (it != JsonValue.from("grouped_with_min_max_thresholds")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (groupedWithMinMaxThresholdsConfig.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + modelType.let { + if (it == JsonValue.from("grouped_with_min_max_thresholds")) 1 else 0 + } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class GroupedWithMinMaxThresholdsConfig + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [GroupedWithMinMaxThresholdsConfig]. + */ + fun builder() = Builder() + } + + /** A builder for [GroupedWithMinMaxThresholdsConfig]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from( + groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + ) = apply { + additionalProperties = + groupedWithMinMaxThresholdsConfig.additionalProperties + .toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [GroupedWithMinMaxThresholdsConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): GroupedWithMinMaxThresholdsConfig = + GroupedWithMinMaxThresholdsConfig(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): GroupedWithMinMaxThresholdsConfig = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedWithMinMaxThresholdsConfig && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedWithMinMaxThresholdsConfig{additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedWithMinMaxThresholds && + cadence == other.cadence && + groupedWithMinMaxThresholdsConfig == + other.groupedWithMinMaxThresholdsConfig && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + groupedWithMinMaxThresholdsConfig, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedWithMinMaxThresholds{cadence=$cadence, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class Minimum + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val minimumConfig: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("minimum_config") + @ExcludeMissing + minimumConfig: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + minimumConfig, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun minimumConfig(): MinimumConfig = minimumConfig.getRequired("minimum_config") + + /** + * Expected to always return the following: + * ```kotlin + * JsonValue.from("minimum") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = billableMetricId.getNullable("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + invoiceGroupingKey.getNullable("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [minimumConfig]. + * + * Unlike [minimumConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("minimum_config") + @ExcludeMissing + fun _minimumConfig(): JsonField = minimumConfig + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Minimum]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .minimumConfig() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Minimum]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var minimumConfig: JsonField? = null + private var modelType: JsonValue = JsonValue.from("minimum") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(minimum: Minimum) = apply { + cadence = minimum.cadence + itemId = minimum.itemId + minimumConfig = minimum.minimumConfig + modelType = minimum.modelType + name = minimum.name + billableMetricId = minimum.billableMetricId + billedInAdvance = minimum.billedInAdvance + billingCycleConfiguration = minimum.billingCycleConfiguration + conversionRate = minimum.conversionRate + conversionRateConfig = minimum.conversionRateConfig + currency = minimum.currency + dimensionalPriceConfiguration = minimum.dimensionalPriceConfiguration + externalPriceId = minimum.externalPriceId + fixedPriceQuantity = minimum.fixedPriceQuantity + invoiceGroupingKey = minimum.invoiceGroupingKey + invoicingCycleConfiguration = minimum.invoicingCycleConfiguration + metadata = minimum.metadata + referenceId = minimum.referenceId + additionalProperties = minimum.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun minimumConfig(minimumConfig: MinimumConfig) = + minimumConfig(JsonField.of(minimumConfig)) + + /** + * Sets [Builder.minimumConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumConfig] with a well-typed + * [MinimumConfig] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun minimumConfig(minimumConfig: JsonField) = apply { + this.minimumConfig = minimumConfig + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("minimum") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Minimum]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .minimumConfig() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Minimum = + Minimum( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("minimumConfig", minimumConfig), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Minimum = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + minimumConfig().validate() + _modelType().let { + if (it != JsonValue.from("minimum")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + (minimumConfig.asKnown()?.validity() ?: 0) + + modelType.let { if (it == JsonValue.from("minimum")) 1 else 0 } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class MinimumConfig + private constructor( + private val minimumAmount: JsonField, + private val prorated: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("minimum_amount") + @ExcludeMissing + minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("prorated") + @ExcludeMissing + prorated: JsonField = JsonMissing.of(), + ) : this(minimumAmount, prorated, mutableMapOf()) + + /** + * The minimum amount to apply + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") + + /** + * By default, subtotals from minimum composite prices are prorated based on the + * service period. Set to false to disable proration. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun prorated(): Boolean? = prorated.getNullable("prorated") + + /** + * Returns the raw JSON value of [minimumAmount]. + * + * Unlike [minimumAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount + + /** + * Returns the raw JSON value of [prorated]. + * + * Unlike [prorated], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("prorated") + @ExcludeMissing + fun _prorated(): JsonField = prorated + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [MinimumConfig]. + * + * The following fields are required: + * ```kotlin + * .minimumAmount() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [MinimumConfig]. */ + class Builder internal constructor() { + + private var minimumAmount: JsonField? = null + private var prorated: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(minimumConfig: MinimumConfig) = apply { + minimumAmount = minimumConfig.minimumAmount + prorated = minimumConfig.prorated + additionalProperties = minimumConfig.additionalProperties.toMutableMap() + } + + /** The minimum amount to apply */ + fun minimumAmount(minimumAmount: String) = + minimumAmount(JsonField.of(minimumAmount)) + + /** + * Sets [Builder.minimumAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumAmount] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount + } + + /** + * By default, subtotals from minimum composite prices are prorated based on + * the service period. Set to false to disable proration. + */ + fun prorated(prorated: Boolean?) = prorated(JsonField.ofNullable(prorated)) + + /** + * Alias for [Builder.prorated]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun prorated(prorated: Boolean) = prorated(prorated as Boolean?) + + /** + * Sets [Builder.prorated] to an arbitrary JSON value. + * + * You should usually call [Builder.prorated] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun prorated(prorated: JsonField) = apply { + this.prorated = prorated + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [MinimumConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .minimumAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MinimumConfig = + MinimumConfig( + checkRequired("minimumAmount", minimumAmount), + prorated, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MinimumConfig = apply { + if (validated) { + return@apply + } + + minimumAmount() + prorated() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (minimumAmount.asKnown() == null) 0 else 1) + + (if (prorated.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MinimumConfig && + minimumAmount == other.minimumAmount && + prorated == other.prorated && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(minimumAmount, prorated, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MinimumConfig{minimumAmount=$minimumAmount, prorated=$prorated, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Minimum && + cadence == other.cadence && + itemId == other.itemId && + minimumConfig == other.minimumConfig && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + minimumConfig, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Minimum{cadence=$cadence, itemId=$itemId, minimumConfig=$minimumConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } } override fun equals(other: Any?): Boolean { diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanPhaseAmountDiscountAdjustment.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanPhaseAmountDiscountAdjustment.kt index 7c02925e3..8f456cf9c 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanPhaseAmountDiscountAdjustment.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanPhaseAmountDiscountAdjustment.kt @@ -109,7 +109,7 @@ private constructor( fun filters(): List = filters.getRequired("filters") /** - * True for adjustments that apply to an entire invocice, false for adjustments that apply to + * True for adjustments that apply to an entire invoice, false for adjustments that apply to * only one price. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly @@ -384,8 +384,8 @@ private constructor( } /** - * True for adjustments that apply to an entire invocice, false for adjustments that apply - * to only one price. + * True for adjustments that apply to an entire invoice, false for adjustments that apply to + * only one price. */ fun isInvoiceLevel(isInvoiceLevel: Boolean) = isInvoiceLevel(JsonField.of(isInvoiceLevel)) diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanPhaseMaximumAdjustment.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanPhaseMaximumAdjustment.kt index 54556ac56..e53659954 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanPhaseMaximumAdjustment.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanPhaseMaximumAdjustment.kt @@ -100,7 +100,7 @@ private constructor( fun filters(): List = filters.getRequired("filters") /** - * True for adjustments that apply to an entire invocice, false for adjustments that apply to + * True for adjustments that apply to an entire invoice, false for adjustments that apply to * only one price. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly @@ -364,8 +364,8 @@ private constructor( } /** - * True for adjustments that apply to an entire invocice, false for adjustments that apply - * to only one price. + * True for adjustments that apply to an entire invoice, false for adjustments that apply to + * only one price. */ fun isInvoiceLevel(isInvoiceLevel: Boolean) = isInvoiceLevel(JsonField.of(isInvoiceLevel)) diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanPhaseMinimumAdjustment.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanPhaseMinimumAdjustment.kt index d369460be..074926d15 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanPhaseMinimumAdjustment.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanPhaseMinimumAdjustment.kt @@ -103,7 +103,7 @@ private constructor( fun filters(): List = filters.getRequired("filters") /** - * True for adjustments that apply to an entire invocice, false for adjustments that apply to + * True for adjustments that apply to an entire invoice, false for adjustments that apply to * only one price. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly @@ -385,8 +385,8 @@ private constructor( } /** - * True for adjustments that apply to an entire invocice, false for adjustments that apply - * to only one price. + * True for adjustments that apply to an entire invoice, false for adjustments that apply to + * only one price. */ fun isInvoiceLevel(isInvoiceLevel: Boolean) = isInvoiceLevel(JsonField.of(isInvoiceLevel)) diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanPhasePercentageDiscountAdjustment.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanPhasePercentageDiscountAdjustment.kt index 46b39d299..9d4ca23ba 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanPhasePercentageDiscountAdjustment.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanPhasePercentageDiscountAdjustment.kt @@ -100,7 +100,7 @@ private constructor( fun filters(): List = filters.getRequired("filters") /** - * True for adjustments that apply to an entire invocice, false for adjustments that apply to + * True for adjustments that apply to an entire invoice, false for adjustments that apply to * only one price. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly @@ -369,8 +369,8 @@ private constructor( } /** - * True for adjustments that apply to an entire invocice, false for adjustments that apply - * to only one price. + * True for adjustments that apply to an entire invoice, false for adjustments that apply to + * only one price. */ fun isInvoiceLevel(isInvoiceLevel: Boolean) = isInvoiceLevel(JsonField.of(isInvoiceLevel)) diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanPhaseUsageDiscountAdjustment.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanPhaseUsageDiscountAdjustment.kt index 494efe62d..056db50d8 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanPhaseUsageDiscountAdjustment.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanPhaseUsageDiscountAdjustment.kt @@ -100,7 +100,7 @@ private constructor( fun filters(): List = filters.getRequired("filters") /** - * True for adjustments that apply to an entire invocice, false for adjustments that apply to + * True for adjustments that apply to an entire invoice, false for adjustments that apply to * only one price. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly @@ -367,8 +367,8 @@ private constructor( } /** - * True for adjustments that apply to an entire invocice, false for adjustments that apply - * to only one price. + * True for adjustments that apply to an entire invoice, false for adjustments that apply to + * only one price. */ fun isInvoiceLevel(isInvoiceLevel: Boolean) = isInvoiceLevel(JsonField.of(isInvoiceLevel)) diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanVersion.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanVersion.kt index 210e33308..3f238974b 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanVersion.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanVersion.kt @@ -312,15 +312,6 @@ private constructor( /** Alias for calling [addPrice] with `Price.ofTiered(tiered)`. */ fun addPrice(tiered: Price.Tiered) = addPrice(Price.ofTiered(tiered)) - /** Alias for calling [addPrice] with `Price.ofTieredBps(tieredBps)`. */ - fun addPrice(tieredBps: Price.TieredBps) = addPrice(Price.ofTieredBps(tieredBps)) - - /** Alias for calling [addPrice] with `Price.ofBps(bps)`. */ - fun addPrice(bps: Price.Bps) = addPrice(Price.ofBps(bps)) - - /** Alias for calling [addPrice] with `Price.ofBulkBps(bulkBps)`. */ - fun addPrice(bulkBps: Price.BulkBps) = addPrice(Price.ofBulkBps(bulkBps)) - /** Alias for calling [addPrice] with `Price.ofBulk(bulk)`. */ fun addPrice(bulk: Price.Bulk) = addPrice(Price.ofBulk(bulk)) @@ -440,6 +431,9 @@ private constructor( fun addPrice(groupedWithMinMaxThresholds: Price.GroupedWithMinMaxThresholds) = addPrice(Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)) + /** Alias for calling [addPrice] with `Price.ofMinimum(minimum)`. */ + fun addPrice(minimum: Price.Minimum) = addPrice(Price.ofMinimum(minimum)) + fun version(version: Long) = version(JsonField.of(version)) /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Price.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Price.kt index 7f45ffc61..67957ac5d 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Price.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Price.kt @@ -20,6 +20,7 @@ import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue +import com.withorb.api.core.checkKnown import com.withorb.api.core.checkRequired import com.withorb.api.core.getOrThrow import com.withorb.api.core.toImmutable @@ -49,9 +50,6 @@ private constructor( private val package_: Package? = null, private val matrix: Matrix? = null, private val tiered: Tiered? = null, - private val tieredBps: TieredBps? = null, - private val bps: Bps? = null, - private val bulkBps: BulkBps? = null, private val bulk: Bulk? = null, private val thresholdTotalAmount: ThresholdTotalAmount? = null, private val tieredPackage: TieredPackage? = null, @@ -74,6 +72,7 @@ private constructor( private val scalableMatrixWithTieredPricing: ScalableMatrixWithTieredPricing? = null, private val cumulativeGroupedBulk: CumulativeGroupedBulk? = null, private val groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds? = null, + private val minimum: Minimum? = null, private val _json: JsonValue? = null, ) { @@ -85,12 +84,6 @@ private constructor( fun tiered(): Tiered? = tiered - fun tieredBps(): TieredBps? = tieredBps - - fun bps(): Bps? = bps - - fun bulkBps(): BulkBps? = bulkBps - fun bulk(): Bulk? = bulk fun thresholdTotalAmount(): ThresholdTotalAmount? = thresholdTotalAmount @@ -137,6 +130,8 @@ private constructor( fun groupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds? = groupedWithMinMaxThresholds + fun minimum(): Minimum? = minimum + fun isUnit(): Boolean = unit != null fun isPackage(): Boolean = package_ != null @@ -145,12 +140,6 @@ private constructor( fun isTiered(): Boolean = tiered != null - fun isTieredBps(): Boolean = tieredBps != null - - fun isBps(): Boolean = bps != null - - fun isBulkBps(): Boolean = bulkBps != null - fun isBulk(): Boolean = bulk != null fun isThresholdTotalAmount(): Boolean = thresholdTotalAmount != null @@ -195,6 +184,8 @@ private constructor( fun isGroupedWithMinMaxThresholds(): Boolean = groupedWithMinMaxThresholds != null + fun isMinimum(): Boolean = minimum != null + fun asUnit(): Unit = unit.getOrThrow("unit") fun asPackage(): Package = package_.getOrThrow("package_") @@ -203,12 +194,6 @@ private constructor( fun asTiered(): Tiered = tiered.getOrThrow("tiered") - fun asTieredBps(): TieredBps = tieredBps.getOrThrow("tieredBps") - - fun asBps(): Bps = bps.getOrThrow("bps") - - fun asBulkBps(): BulkBps = bulkBps.getOrThrow("bulkBps") - fun asBulk(): Bulk = bulk.getOrThrow("bulk") fun asThresholdTotalAmount(): ThresholdTotalAmount = @@ -267,6 +252,8 @@ private constructor( fun asGroupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds = groupedWithMinMaxThresholds.getOrThrow("groupedWithMinMaxThresholds") + fun asMinimum(): Minimum = minimum.getOrThrow("minimum") + fun _json(): JsonValue? = _json fun accept(visitor: Visitor): T = @@ -275,9 +262,6 @@ private constructor( package_ != null -> visitor.visitPackage(package_) matrix != null -> visitor.visitMatrix(matrix) tiered != null -> visitor.visitTiered(tiered) - tieredBps != null -> visitor.visitTieredBps(tieredBps) - bps != null -> visitor.visitBps(bps) - bulkBps != null -> visitor.visitBulkBps(bulkBps) bulk != null -> visitor.visitBulk(bulk) thresholdTotalAmount != null -> visitor.visitThresholdTotalAmount(thresholdTotalAmount) tieredPackage != null -> visitor.visitTieredPackage(tieredPackage) @@ -310,6 +294,7 @@ private constructor( visitor.visitCumulativeGroupedBulk(cumulativeGroupedBulk) groupedWithMinMaxThresholds != null -> visitor.visitGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds) + minimum != null -> visitor.visitMinimum(minimum) else -> visitor.unknown(_json) } @@ -338,18 +323,6 @@ private constructor( tiered.validate() } - override fun visitTieredBps(tieredBps: TieredBps) { - tieredBps.validate() - } - - override fun visitBps(bps: Bps) { - bps.validate() - } - - override fun visitBulkBps(bulkBps: BulkBps) { - bulkBps.validate() - } - override fun visitBulk(bulk: Bulk) { bulk.validate() } @@ -457,6 +430,10 @@ private constructor( ) { groupedWithMinMaxThresholds.validate() } + + override fun visitMinimum(minimum: Minimum) { + minimum.validate() + } } ) validated = true @@ -486,12 +463,6 @@ private constructor( override fun visitTiered(tiered: Tiered) = tiered.validity() - override fun visitTieredBps(tieredBps: TieredBps) = tieredBps.validity() - - override fun visitBps(bps: Bps) = bps.validity() - - override fun visitBulkBps(bulkBps: BulkBps) = bulkBps.validity() - override fun visitBulk(bulk: Bulk) = bulk.validity() override fun visitThresholdTotalAmount(thresholdTotalAmount: ThresholdTotalAmount) = @@ -567,6 +538,8 @@ private constructor( groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds ) = groupedWithMinMaxThresholds.validity() + override fun visitMinimum(minimum: Minimum) = minimum.validity() + override fun unknown(json: JsonValue?) = 0 } ) @@ -581,9 +554,6 @@ private constructor( package_ == other.package_ && matrix == other.matrix && tiered == other.tiered && - tieredBps == other.tieredBps && - bps == other.bps && - bulkBps == other.bulkBps && bulk == other.bulk && thresholdTotalAmount == other.thresholdTotalAmount && tieredPackage == other.tieredPackage && @@ -605,7 +575,8 @@ private constructor( scalableMatrixWithUnitPricing == other.scalableMatrixWithUnitPricing && scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && cumulativeGroupedBulk == other.cumulativeGroupedBulk && - groupedWithMinMaxThresholds == other.groupedWithMinMaxThresholds + groupedWithMinMaxThresholds == other.groupedWithMinMaxThresholds && + minimum == other.minimum } override fun hashCode(): Int = @@ -614,9 +585,6 @@ private constructor( package_, matrix, tiered, - tieredBps, - bps, - bulkBps, bulk, thresholdTotalAmount, tieredPackage, @@ -639,6 +607,7 @@ private constructor( scalableMatrixWithTieredPricing, cumulativeGroupedBulk, groupedWithMinMaxThresholds, + minimum, ) override fun toString(): String = @@ -647,9 +616,6 @@ private constructor( package_ != null -> "Price{package_=$package_}" matrix != null -> "Price{matrix=$matrix}" tiered != null -> "Price{tiered=$tiered}" - tieredBps != null -> "Price{tieredBps=$tieredBps}" - bps != null -> "Price{bps=$bps}" - bulkBps != null -> "Price{bulkBps=$bulkBps}" bulk != null -> "Price{bulk=$bulk}" thresholdTotalAmount != null -> "Price{thresholdTotalAmount=$thresholdTotalAmount}" tieredPackage != null -> "Price{tieredPackage=$tieredPackage}" @@ -678,6 +644,7 @@ private constructor( cumulativeGroupedBulk != null -> "Price{cumulativeGroupedBulk=$cumulativeGroupedBulk}" groupedWithMinMaxThresholds != null -> "Price{groupedWithMinMaxThresholds=$groupedWithMinMaxThresholds}" + minimum != null -> "Price{minimum=$minimum}" _json != null -> "Price{_unknown=$_json}" else -> throw IllegalStateException("Invalid Price") } @@ -692,12 +659,6 @@ private constructor( fun ofTiered(tiered: Tiered) = Price(tiered = tiered) - fun ofTieredBps(tieredBps: TieredBps) = Price(tieredBps = tieredBps) - - fun ofBps(bps: Bps) = Price(bps = bps) - - fun ofBulkBps(bulkBps: BulkBps) = Price(bulkBps = bulkBps) - fun ofBulk(bulk: Bulk) = Price(bulk = bulk) fun ofThresholdTotalAmount(thresholdTotalAmount: ThresholdTotalAmount) = @@ -763,6 +724,8 @@ private constructor( fun ofGroupedWithMinMaxThresholds( groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds ) = Price(groupedWithMinMaxThresholds = groupedWithMinMaxThresholds) + + fun ofMinimum(minimum: Minimum) = Price(minimum = minimum) } /** An interface that defines how to map each variant of [Price] to a value of type [T]. */ @@ -776,12 +739,6 @@ private constructor( fun visitTiered(tiered: Tiered): T - fun visitTieredBps(tieredBps: TieredBps): T - - fun visitBps(bps: Bps): T - - fun visitBulkBps(bulkBps: BulkBps): T - fun visitBulk(bulk: Bulk): T fun visitThresholdTotalAmount(thresholdTotalAmount: ThresholdTotalAmount): T @@ -834,6 +791,8 @@ private constructor( groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds ): T + fun visitMinimum(minimum: Minimum): T + /** * Maps an unknown variant of [Price] to a value of type [T]. * @@ -875,21 +834,6 @@ private constructor( Price(tiered = it, _json = json) } ?: Price(_json = json) } - "tiered_bps" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(tieredBps = it, _json = json) - } ?: Price(_json = json) - } - "bps" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(bps = it, _json = json) - } ?: Price(_json = json) - } - "bulk_bps" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(bulkBps = it, _json = json) - } ?: Price(_json = json) - } "bulk" -> { return tryDeserialize(node, jacksonTypeRef())?.let { Price(bulk = it, _json = json) @@ -1000,6 +944,11 @@ private constructor( ?.let { Price(groupedWithMinMaxThresholds = it, _json = json) } ?: Price(_json = json) } + "minimum" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(minimum = it, _json = json) + } ?: Price(_json = json) + } } return Price(_json = json) @@ -1018,9 +967,6 @@ private constructor( value.package_ != null -> generator.writeObject(value.package_) value.matrix != null -> generator.writeObject(value.matrix) value.tiered != null -> generator.writeObject(value.tiered) - value.tieredBps != null -> generator.writeObject(value.tieredBps) - value.bps != null -> generator.writeObject(value.bps) - value.bulkBps != null -> generator.writeObject(value.bulkBps) value.bulk != null -> generator.writeObject(value.bulk) value.thresholdTotalAmount != null -> generator.writeObject(value.thresholdTotalAmount) @@ -1057,6 +1003,7 @@ private constructor( generator.writeObject(value.cumulativeGroupedBulk) value.groupedWithMinMaxThresholds != null -> generator.writeObject(value.groupedWithMinMaxThresholds) + value.minimum != null -> generator.writeObject(value.minimum) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid Price") } @@ -1069,6 +1016,7 @@ private constructor( private val billableMetric: JsonField, private val billingCycleConfiguration: JsonField, private val cadence: JsonField, + private val compositePriceFilters: JsonField>, private val conversionRate: JsonField, private val conversionRateConfig: JsonField, private val createdAt: JsonField, @@ -1104,6 +1052,9 @@ private constructor( @ExcludeMissing billingCycleConfiguration: JsonField = JsonMissing.of(), @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), + @JsonProperty("composite_price_filters") + @ExcludeMissing + compositePriceFilters: JsonField> = JsonMissing.of(), @JsonProperty("conversion_rate") @ExcludeMissing conversionRate: JsonField = JsonMissing.of(), @@ -1166,6 +1117,7 @@ private constructor( billableMetric, billingCycleConfiguration, cadence, + compositePriceFilters, conversionRate, conversionRateConfig, createdAt, @@ -1216,6 +1168,13 @@ private constructor( */ fun cadence(): Cadence = cadence.getRequired("cadence") + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun compositePriceFilters(): List? = + compositePriceFilters.getNullable("composite_price_filters") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -1400,6 +1359,16 @@ private constructor( */ @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence + /** + * Returns the raw JSON value of [compositePriceFilters]. + * + * Unlike [compositePriceFilters], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("composite_price_filters") + @ExcludeMissing + fun _compositePriceFilters(): JsonField> = compositePriceFilters + /** * Returns the raw JSON value of [conversionRate]. * @@ -1622,6 +1591,7 @@ private constructor( * .billableMetric() * .billingCycleConfiguration() * .cadence() + * .compositePriceFilters() * .conversionRate() * .conversionRateConfig() * .createdAt() @@ -1654,6 +1624,7 @@ private constructor( private var billableMetric: JsonField? = null private var billingCycleConfiguration: JsonField? = null private var cadence: JsonField? = null + private var compositePriceFilters: JsonField>? = null private var conversionRate: JsonField? = null private var conversionRateConfig: JsonField? = null private var createdAt: JsonField? = null @@ -1684,6 +1655,7 @@ private constructor( billableMetric = unit.billableMetric billingCycleConfiguration = unit.billingCycleConfiguration cadence = unit.cadence + compositePriceFilters = unit.compositePriceFilters.map { it.toMutableList() } conversionRate = unit.conversionRate conversionRateConfig = unit.conversionRateConfig createdAt = unit.createdAt @@ -1759,6 +1731,34 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + fun compositePriceFilters(compositePriceFilters: List?) = + compositePriceFilters(JsonField.ofNullable(compositePriceFilters)) + + /** + * Sets [Builder.compositePriceFilters] to an arbitrary JSON value. + * + * You should usually call [Builder.compositePriceFilters] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun compositePriceFilters( + compositePriceFilters: JsonField> + ) = apply { + this.compositePriceFilters = compositePriceFilters.map { it.toMutableList() } + } + + /** + * Adds a single [TransformPriceFilter] to [compositePriceFilters]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addCompositePriceFilter(compositePriceFilter: TransformPriceFilter) = apply { + compositePriceFilters = + (compositePriceFilters ?: JsonField.of(mutableListOf())).also { + checkKnown("compositePriceFilters", it).add(compositePriceFilter) + } + } + fun conversionRate(conversionRate: Double?) = conversionRate(JsonField.ofNullable(conversionRate)) @@ -2233,6 +2233,7 @@ private constructor( * .billableMetric() * .billingCycleConfiguration() * .cadence() + * .compositePriceFilters() * .conversionRate() * .conversionRateConfig() * .createdAt() @@ -2263,6 +2264,9 @@ private constructor( checkRequired("billableMetric", billableMetric), checkRequired("billingCycleConfiguration", billingCycleConfiguration), checkRequired("cadence", cadence), + checkRequired("compositePriceFilters", compositePriceFilters).map { + it.toImmutable() + }, checkRequired("conversionRate", conversionRate), checkRequired("conversionRateConfig", conversionRateConfig), checkRequired("createdAt", createdAt), @@ -2300,6 +2304,7 @@ private constructor( billableMetric()?.validate() billingCycleConfiguration().validate() cadence().validate() + compositePriceFilters()?.forEach { it.validate() } conversionRate() conversionRateConfig()?.validate() createdAt() @@ -2348,6 +2353,7 @@ private constructor( (billableMetric.asKnown()?.validity() ?: 0) + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + (cadence.asKnown()?.validity() ?: 0) + + (compositePriceFilters.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + (if (conversionRate.asKnown() == null) 0 else 1) + (conversionRateConfig.asKnown()?.validity() ?: 0) + (if (createdAt.asKnown() == null) 0 else 1) + @@ -2767,6 +2773,7 @@ private constructor( billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && + compositePriceFilters == other.compositePriceFilters && conversionRate == other.conversionRate && conversionRateConfig == other.conversionRateConfig && createdAt == other.createdAt && @@ -2798,6 +2805,7 @@ private constructor( billableMetric, billingCycleConfiguration, cadence, + compositePriceFilters, conversionRate, conversionRateConfig, createdAt, @@ -2827,7 +2835,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Unit{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, unitConfig=$unitConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "Unit{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, unitConfig=$unitConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" } class Package @@ -2836,6 +2844,7 @@ private constructor( private val billableMetric: JsonField, private val billingCycleConfiguration: JsonField, private val cadence: JsonField, + private val compositePriceFilters: JsonField>, private val conversionRate: JsonField, private val conversionRateConfig: JsonField, private val createdAt: JsonField, @@ -2871,6 +2880,9 @@ private constructor( @ExcludeMissing billingCycleConfiguration: JsonField = JsonMissing.of(), @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), + @JsonProperty("composite_price_filters") + @ExcludeMissing + compositePriceFilters: JsonField> = JsonMissing.of(), @JsonProperty("conversion_rate") @ExcludeMissing conversionRate: JsonField = JsonMissing.of(), @@ -2933,6 +2945,7 @@ private constructor( billableMetric, billingCycleConfiguration, cadence, + compositePriceFilters, conversionRate, conversionRateConfig, createdAt, @@ -2983,6 +2996,13 @@ private constructor( */ fun cadence(): Cadence = cadence.getRequired("cadence") + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun compositePriceFilters(): List? = + compositePriceFilters.getNullable("composite_price_filters") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -3167,6 +3187,16 @@ private constructor( */ @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence + /** + * Returns the raw JSON value of [compositePriceFilters]. + * + * Unlike [compositePriceFilters], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("composite_price_filters") + @ExcludeMissing + fun _compositePriceFilters(): JsonField> = compositePriceFilters + /** * Returns the raw JSON value of [conversionRate]. * @@ -3390,6 +3420,7 @@ private constructor( * .billableMetric() * .billingCycleConfiguration() * .cadence() + * .compositePriceFilters() * .conversionRate() * .conversionRateConfig() * .createdAt() @@ -3422,6 +3453,7 @@ private constructor( private var billableMetric: JsonField? = null private var billingCycleConfiguration: JsonField? = null private var cadence: JsonField? = null + private var compositePriceFilters: JsonField>? = null private var conversionRate: JsonField? = null private var conversionRateConfig: JsonField? = null private var createdAt: JsonField? = null @@ -3452,6 +3484,7 @@ private constructor( billableMetric = package_.billableMetric billingCycleConfiguration = package_.billingCycleConfiguration cadence = package_.cadence + compositePriceFilters = package_.compositePriceFilters.map { it.toMutableList() } conversionRate = package_.conversionRate conversionRateConfig = package_.conversionRateConfig createdAt = package_.createdAt @@ -3527,6 +3560,34 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + fun compositePriceFilters(compositePriceFilters: List?) = + compositePriceFilters(JsonField.ofNullable(compositePriceFilters)) + + /** + * Sets [Builder.compositePriceFilters] to an arbitrary JSON value. + * + * You should usually call [Builder.compositePriceFilters] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun compositePriceFilters( + compositePriceFilters: JsonField> + ) = apply { + this.compositePriceFilters = compositePriceFilters.map { it.toMutableList() } + } + + /** + * Adds a single [TransformPriceFilter] to [compositePriceFilters]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addCompositePriceFilter(compositePriceFilter: TransformPriceFilter) = apply { + compositePriceFilters = + (compositePriceFilters ?: JsonField.of(mutableListOf())).also { + checkKnown("compositePriceFilters", it).add(compositePriceFilter) + } + } + fun conversionRate(conversionRate: Double?) = conversionRate(JsonField.ofNullable(conversionRate)) @@ -4002,6 +4063,7 @@ private constructor( * .billableMetric() * .billingCycleConfiguration() * .cadence() + * .compositePriceFilters() * .conversionRate() * .conversionRateConfig() * .createdAt() @@ -4032,6 +4094,9 @@ private constructor( checkRequired("billableMetric", billableMetric), checkRequired("billingCycleConfiguration", billingCycleConfiguration), checkRequired("cadence", cadence), + checkRequired("compositePriceFilters", compositePriceFilters).map { + it.toImmutable() + }, checkRequired("conversionRate", conversionRate), checkRequired("conversionRateConfig", conversionRateConfig), checkRequired("createdAt", createdAt), @@ -4069,6 +4134,7 @@ private constructor( billableMetric()?.validate() billingCycleConfiguration().validate() cadence().validate() + compositePriceFilters()?.forEach { it.validate() } conversionRate() conversionRateConfig()?.validate() createdAt() @@ -4117,6 +4183,7 @@ private constructor( (billableMetric.asKnown()?.validity() ?: 0) + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + (cadence.asKnown()?.validity() ?: 0) + + (compositePriceFilters.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + (if (conversionRate.asKnown() == null) 0 else 1) + (conversionRateConfig.asKnown()?.validity() ?: 0) + (if (createdAt.asKnown() == null) 0 else 1) + @@ -4536,6 +4603,7 @@ private constructor( billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && + compositePriceFilters == other.compositePriceFilters && conversionRate == other.conversionRate && conversionRateConfig == other.conversionRateConfig && createdAt == other.createdAt && @@ -4567,6 +4635,7 @@ private constructor( billableMetric, billingCycleConfiguration, cadence, + compositePriceFilters, conversionRate, conversionRateConfig, createdAt, @@ -4596,7 +4665,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Package{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, packageConfig=$packageConfig, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "Package{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, packageConfig=$packageConfig, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" } class Matrix @@ -4605,6 +4674,7 @@ private constructor( private val billableMetric: JsonField, private val billingCycleConfiguration: JsonField, private val cadence: JsonField, + private val compositePriceFilters: JsonField>, private val conversionRate: JsonField, private val conversionRateConfig: JsonField, private val createdAt: JsonField, @@ -4640,6 +4710,9 @@ private constructor( @ExcludeMissing billingCycleConfiguration: JsonField = JsonMissing.of(), @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), + @JsonProperty("composite_price_filters") + @ExcludeMissing + compositePriceFilters: JsonField> = JsonMissing.of(), @JsonProperty("conversion_rate") @ExcludeMissing conversionRate: JsonField = JsonMissing.of(), @@ -4702,6 +4775,7 @@ private constructor( billableMetric, billingCycleConfiguration, cadence, + compositePriceFilters, conversionRate, conversionRateConfig, createdAt, @@ -4752,6 +4826,13 @@ private constructor( */ fun cadence(): Cadence = cadence.getRequired("cadence") + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun compositePriceFilters(): List? = + compositePriceFilters.getNullable("composite_price_filters") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -4936,6 +5017,16 @@ private constructor( */ @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence + /** + * Returns the raw JSON value of [compositePriceFilters]. + * + * Unlike [compositePriceFilters], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("composite_price_filters") + @ExcludeMissing + fun _compositePriceFilters(): JsonField> = compositePriceFilters + /** * Returns the raw JSON value of [conversionRate]. * @@ -5159,6 +5250,7 @@ private constructor( * .billableMetric() * .billingCycleConfiguration() * .cadence() + * .compositePriceFilters() * .conversionRate() * .conversionRateConfig() * .createdAt() @@ -5191,6 +5283,7 @@ private constructor( private var billableMetric: JsonField? = null private var billingCycleConfiguration: JsonField? = null private var cadence: JsonField? = null + private var compositePriceFilters: JsonField>? = null private var conversionRate: JsonField? = null private var conversionRateConfig: JsonField? = null private var createdAt: JsonField? = null @@ -5221,6 +5314,7 @@ private constructor( billableMetric = matrix.billableMetric billingCycleConfiguration = matrix.billingCycleConfiguration cadence = matrix.cadence + compositePriceFilters = matrix.compositePriceFilters.map { it.toMutableList() } conversionRate = matrix.conversionRate conversionRateConfig = matrix.conversionRateConfig createdAt = matrix.createdAt @@ -5296,6 +5390,34 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + fun compositePriceFilters(compositePriceFilters: List?) = + compositePriceFilters(JsonField.ofNullable(compositePriceFilters)) + + /** + * Sets [Builder.compositePriceFilters] to an arbitrary JSON value. + * + * You should usually call [Builder.compositePriceFilters] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun compositePriceFilters( + compositePriceFilters: JsonField> + ) = apply { + this.compositePriceFilters = compositePriceFilters.map { it.toMutableList() } + } + + /** + * Adds a single [TransformPriceFilter] to [compositePriceFilters]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addCompositePriceFilter(compositePriceFilter: TransformPriceFilter) = apply { + compositePriceFilters = + (compositePriceFilters ?: JsonField.of(mutableListOf())).also { + checkKnown("compositePriceFilters", it).add(compositePriceFilter) + } + } + fun conversionRate(conversionRate: Double?) = conversionRate(JsonField.ofNullable(conversionRate)) @@ -5770,6 +5892,7 @@ private constructor( * .billableMetric() * .billingCycleConfiguration() * .cadence() + * .compositePriceFilters() * .conversionRate() * .conversionRateConfig() * .createdAt() @@ -5800,6 +5923,9 @@ private constructor( checkRequired("billableMetric", billableMetric), checkRequired("billingCycleConfiguration", billingCycleConfiguration), checkRequired("cadence", cadence), + checkRequired("compositePriceFilters", compositePriceFilters).map { + it.toImmutable() + }, checkRequired("conversionRate", conversionRate), checkRequired("conversionRateConfig", conversionRateConfig), checkRequired("createdAt", createdAt), @@ -5837,6 +5963,7 @@ private constructor( billableMetric()?.validate() billingCycleConfiguration().validate() cadence().validate() + compositePriceFilters()?.forEach { it.validate() } conversionRate() conversionRateConfig()?.validate() createdAt() @@ -5885,6 +6012,7 @@ private constructor( (billableMetric.asKnown()?.validity() ?: 0) + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + (cadence.asKnown()?.validity() ?: 0) + + (compositePriceFilters.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + (if (conversionRate.asKnown() == null) 0 else 1) + (conversionRateConfig.asKnown()?.validity() ?: 0) + (if (createdAt.asKnown() == null) 0 else 1) + @@ -6304,6 +6432,7 @@ private constructor( billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && + compositePriceFilters == other.compositePriceFilters && conversionRate == other.conversionRate && conversionRateConfig == other.conversionRateConfig && createdAt == other.createdAt && @@ -6335,6 +6464,7 @@ private constructor( billableMetric, billingCycleConfiguration, cadence, + compositePriceFilters, conversionRate, conversionRateConfig, createdAt, @@ -6364,7 +6494,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Matrix{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, matrixConfig=$matrixConfig, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "Matrix{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, matrixConfig=$matrixConfig, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" } class Tiered @@ -6373,6 +6503,7 @@ private constructor( private val billableMetric: JsonField, private val billingCycleConfiguration: JsonField, private val cadence: JsonField, + private val compositePriceFilters: JsonField>, private val conversionRate: JsonField, private val conversionRateConfig: JsonField, private val createdAt: JsonField, @@ -6408,6 +6539,9 @@ private constructor( @ExcludeMissing billingCycleConfiguration: JsonField = JsonMissing.of(), @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), + @JsonProperty("composite_price_filters") + @ExcludeMissing + compositePriceFilters: JsonField> = JsonMissing.of(), @JsonProperty("conversion_rate") @ExcludeMissing conversionRate: JsonField = JsonMissing.of(), @@ -6470,6 +6604,7 @@ private constructor( billableMetric, billingCycleConfiguration, cadence, + compositePriceFilters, conversionRate, conversionRateConfig, createdAt, @@ -6520,6 +6655,13 @@ private constructor( */ fun cadence(): Cadence = cadence.getRequired("cadence") + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun compositePriceFilters(): List? = + compositePriceFilters.getNullable("composite_price_filters") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -6704,6 +6846,16 @@ private constructor( */ @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence + /** + * Returns the raw JSON value of [compositePriceFilters]. + * + * Unlike [compositePriceFilters], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("composite_price_filters") + @ExcludeMissing + fun _compositePriceFilters(): JsonField> = compositePriceFilters + /** * Returns the raw JSON value of [conversionRate]. * @@ -6927,6 +7079,7 @@ private constructor( * .billableMetric() * .billingCycleConfiguration() * .cadence() + * .compositePriceFilters() * .conversionRate() * .conversionRateConfig() * .createdAt() @@ -6959,6 +7112,7 @@ private constructor( private var billableMetric: JsonField? = null private var billingCycleConfiguration: JsonField? = null private var cadence: JsonField? = null + private var compositePriceFilters: JsonField>? = null private var conversionRate: JsonField? = null private var conversionRateConfig: JsonField? = null private var createdAt: JsonField? = null @@ -6989,6 +7143,7 @@ private constructor( billableMetric = tiered.billableMetric billingCycleConfiguration = tiered.billingCycleConfiguration cadence = tiered.cadence + compositePriceFilters = tiered.compositePriceFilters.map { it.toMutableList() } conversionRate = tiered.conversionRate conversionRateConfig = tiered.conversionRateConfig createdAt = tiered.createdAt @@ -7064,6 +7219,34 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + fun compositePriceFilters(compositePriceFilters: List?) = + compositePriceFilters(JsonField.ofNullable(compositePriceFilters)) + + /** + * Sets [Builder.compositePriceFilters] to an arbitrary JSON value. + * + * You should usually call [Builder.compositePriceFilters] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun compositePriceFilters( + compositePriceFilters: JsonField> + ) = apply { + this.compositePriceFilters = compositePriceFilters.map { it.toMutableList() } + } + + /** + * Adds a single [TransformPriceFilter] to [compositePriceFilters]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addCompositePriceFilter(compositePriceFilter: TransformPriceFilter) = apply { + compositePriceFilters = + (compositePriceFilters ?: JsonField.of(mutableListOf())).also { + checkKnown("compositePriceFilters", it).add(compositePriceFilter) + } + } + fun conversionRate(conversionRate: Double?) = conversionRate(JsonField.ofNullable(conversionRate)) @@ -7538,6 +7721,7 @@ private constructor( * .billableMetric() * .billingCycleConfiguration() * .cadence() + * .compositePriceFilters() * .conversionRate() * .conversionRateConfig() * .createdAt() @@ -7568,6 +7752,9 @@ private constructor( checkRequired("billableMetric", billableMetric), checkRequired("billingCycleConfiguration", billingCycleConfiguration), checkRequired("cadence", cadence), + checkRequired("compositePriceFilters", compositePriceFilters).map { + it.toImmutable() + }, checkRequired("conversionRate", conversionRate), checkRequired("conversionRateConfig", conversionRateConfig), checkRequired("createdAt", createdAt), @@ -7605,6 +7792,7 @@ private constructor( billableMetric()?.validate() billingCycleConfiguration().validate() cadence().validate() + compositePriceFilters()?.forEach { it.validate() } conversionRate() conversionRateConfig()?.validate() createdAt() @@ -7653,6 +7841,7 @@ private constructor( (billableMetric.asKnown()?.validity() ?: 0) + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + (cadence.asKnown()?.validity() ?: 0) + + (compositePriceFilters.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + (if (conversionRate.asKnown() == null) 0 else 1) + (conversionRateConfig.asKnown()?.validity() ?: 0) + (if (createdAt.asKnown() == null) 0 else 1) + @@ -8072,6 +8261,7 @@ private constructor( billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && + compositePriceFilters == other.compositePriceFilters && conversionRate == other.conversionRate && conversionRateConfig == other.conversionRateConfig && createdAt == other.createdAt && @@ -8103,6 +8293,7 @@ private constructor( billableMetric, billingCycleConfiguration, cadence, + compositePriceFilters, conversionRate, conversionRateConfig, createdAt, @@ -8132,15 +8323,17 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Tiered{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, tieredConfig=$tieredConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "Tiered{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, tieredConfig=$tieredConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" } - class TieredBps + class Bulk private constructor( private val id: JsonField, private val billableMetric: JsonField, private val billingCycleConfiguration: JsonField, + private val bulkConfig: JsonField, private val cadence: JsonField, + private val compositePriceFilters: JsonField>, private val conversionRate: JsonField, private val conversionRateConfig: JsonField, private val createdAt: JsonField, @@ -8161,7 +8354,6 @@ private constructor( private val planPhaseOrder: JsonField, private val priceType: JsonField, private val replacesPriceId: JsonField, - private val tieredBpsConfig: JsonField, private val dimensionalPriceConfiguration: JsonField, private val additionalProperties: MutableMap, ) { @@ -8175,7 +8367,13 @@ private constructor( @JsonProperty("billing_cycle_configuration") @ExcludeMissing billingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("bulk_config") + @ExcludeMissing + bulkConfig: JsonField = JsonMissing.of(), @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), + @JsonProperty("composite_price_filters") + @ExcludeMissing + compositePriceFilters: JsonField> = JsonMissing.of(), @JsonProperty("conversion_rate") @ExcludeMissing conversionRate: JsonField = JsonMissing.of(), @@ -8226,9 +8424,6 @@ private constructor( @JsonProperty("replaces_price_id") @ExcludeMissing replacesPriceId: JsonField = JsonMissing.of(), - @JsonProperty("tiered_bps_config") - @ExcludeMissing - tieredBpsConfig: JsonField = JsonMissing.of(), @JsonProperty("dimensional_price_configuration") @ExcludeMissing dimensionalPriceConfiguration: JsonField = @@ -8237,7 +8432,9 @@ private constructor( id, billableMetric, billingCycleConfiguration, + bulkConfig, cadence, + compositePriceFilters, conversionRate, conversionRateConfig, createdAt, @@ -8258,7 +8455,6 @@ private constructor( planPhaseOrder, priceType, replacesPriceId, - tieredBpsConfig, dimensionalPriceConfiguration, mutableMapOf(), ) @@ -8282,12 +8478,25 @@ private constructor( fun billingCycleConfiguration(): BillingCycleConfiguration = billingCycleConfiguration.getRequired("billing_cycle_configuration") + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun bulkConfig(): BulkConfig = bulkConfig.getRequired("bulk_config") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ fun cadence(): Cadence = cadence.getRequired("cadence") + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun compositePriceFilters(): List? = + compositePriceFilters.getNullable("composite_price_filters") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -8389,7 +8598,7 @@ private constructor( /** * Expected to always return the following: * ```kotlin - * JsonValue.from("tiered_bps") + * JsonValue.from("bulk") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -8424,12 +8633,6 @@ private constructor( */ fun replacesPriceId(): String? = replacesPriceId.getNullable("replaces_price_id") - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun tieredBpsConfig(): TieredBpsConfig = tieredBpsConfig.getRequired("tiered_bps_config") - /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -8465,6 +8668,15 @@ private constructor( fun _billingCycleConfiguration(): JsonField = billingCycleConfiguration + /** + * Returns the raw JSON value of [bulkConfig]. + * + * Unlike [bulkConfig], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("bulk_config") + @ExcludeMissing + fun _bulkConfig(): JsonField = bulkConfig + /** * Returns the raw JSON value of [cadence]. * @@ -8472,6 +8684,16 @@ private constructor( */ @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence + /** + * Returns the raw JSON value of [compositePriceFilters]. + * + * Unlike [compositePriceFilters], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("composite_price_filters") + @ExcludeMissing + fun _compositePriceFilters(): JsonField> = compositePriceFilters + /** * Returns the raw JSON value of [conversionRate]. * @@ -8651,16 +8873,6 @@ private constructor( @ExcludeMissing fun _replacesPriceId(): JsonField = replacesPriceId - /** - * Returns the raw JSON value of [tieredBpsConfig]. - * - * Unlike [tieredBpsConfig], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("tiered_bps_config") - @ExcludeMissing - fun _tieredBpsConfig(): JsonField = tieredBpsConfig - /** * Returns the raw JSON value of [dimensionalPriceConfiguration]. * @@ -8687,14 +8899,16 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [TieredBps]. + * Returns a mutable builder for constructing an instance of [Bulk]. * * The following fields are required: * ```kotlin * .id() * .billableMetric() * .billingCycleConfiguration() + * .bulkConfig() * .cadence() + * .compositePriceFilters() * .conversionRate() * .conversionRateConfig() * .createdAt() @@ -8714,19 +8928,20 @@ private constructor( * .planPhaseOrder() * .priceType() * .replacesPriceId() - * .tieredBpsConfig() * ``` */ fun builder() = Builder() } - /** A builder for [TieredBps]. */ + /** A builder for [Bulk]. */ class Builder internal constructor() { private var id: JsonField? = null private var billableMetric: JsonField? = null private var billingCycleConfiguration: JsonField? = null + private var bulkConfig: JsonField? = null private var cadence: JsonField? = null + private var compositePriceFilters: JsonField>? = null private var conversionRate: JsonField? = null private var conversionRateConfig: JsonField? = null private var createdAt: JsonField? = null @@ -8742,44 +8957,44 @@ private constructor( private var metadata: JsonField? = null private var minimum: JsonField? = null private var minimumAmount: JsonField? = null - private var modelType: JsonValue = JsonValue.from("tiered_bps") + private var modelType: JsonValue = JsonValue.from("bulk") private var name: JsonField? = null private var planPhaseOrder: JsonField? = null private var priceType: JsonField? = null private var replacesPriceId: JsonField? = null - private var tieredBpsConfig: JsonField? = null private var dimensionalPriceConfiguration: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(tieredBps: TieredBps) = apply { - id = tieredBps.id - billableMetric = tieredBps.billableMetric - billingCycleConfiguration = tieredBps.billingCycleConfiguration - cadence = tieredBps.cadence - conversionRate = tieredBps.conversionRate - conversionRateConfig = tieredBps.conversionRateConfig - createdAt = tieredBps.createdAt - creditAllocation = tieredBps.creditAllocation - currency = tieredBps.currency - discount = tieredBps.discount - externalPriceId = tieredBps.externalPriceId - fixedPriceQuantity = tieredBps.fixedPriceQuantity - invoicingCycleConfiguration = tieredBps.invoicingCycleConfiguration - item = tieredBps.item - maximum = tieredBps.maximum - maximumAmount = tieredBps.maximumAmount - metadata = tieredBps.metadata - minimum = tieredBps.minimum - minimumAmount = tieredBps.minimumAmount - modelType = tieredBps.modelType - name = tieredBps.name - planPhaseOrder = tieredBps.planPhaseOrder - priceType = tieredBps.priceType - replacesPriceId = tieredBps.replacesPriceId - tieredBpsConfig = tieredBps.tieredBpsConfig - dimensionalPriceConfiguration = tieredBps.dimensionalPriceConfiguration - additionalProperties = tieredBps.additionalProperties.toMutableMap() + internal fun from(bulk: Bulk) = apply { + id = bulk.id + billableMetric = bulk.billableMetric + billingCycleConfiguration = bulk.billingCycleConfiguration + bulkConfig = bulk.bulkConfig + cadence = bulk.cadence + compositePriceFilters = bulk.compositePriceFilters.map { it.toMutableList() } + conversionRate = bulk.conversionRate + conversionRateConfig = bulk.conversionRateConfig + createdAt = bulk.createdAt + creditAllocation = bulk.creditAllocation + currency = bulk.currency + discount = bulk.discount + externalPriceId = bulk.externalPriceId + fixedPriceQuantity = bulk.fixedPriceQuantity + invoicingCycleConfiguration = bulk.invoicingCycleConfiguration + item = bulk.item + maximum = bulk.maximum + maximumAmount = bulk.maximumAmount + metadata = bulk.metadata + minimum = bulk.minimum + minimumAmount = bulk.minimumAmount + modelType = bulk.modelType + name = bulk.name + planPhaseOrder = bulk.planPhaseOrder + priceType = bulk.priceType + replacesPriceId = bulk.replacesPriceId + dimensionalPriceConfiguration = bulk.dimensionalPriceConfiguration + additionalProperties = bulk.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) @@ -8821,6 +9036,19 @@ private constructor( billingCycleConfiguration: JsonField ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + fun bulkConfig(bulkConfig: BulkConfig) = bulkConfig(JsonField.of(bulkConfig)) + + /** + * Sets [Builder.bulkConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.bulkConfig] with a well-typed [BulkConfig] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun bulkConfig(bulkConfig: JsonField) = apply { + this.bulkConfig = bulkConfig + } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) /** @@ -8832,6 +9060,34 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + fun compositePriceFilters(compositePriceFilters: List?) = + compositePriceFilters(JsonField.ofNullable(compositePriceFilters)) + + /** + * Sets [Builder.compositePriceFilters] to an arbitrary JSON value. + * + * You should usually call [Builder.compositePriceFilters] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun compositePriceFilters( + compositePriceFilters: JsonField> + ) = apply { + this.compositePriceFilters = compositePriceFilters.map { it.toMutableList() } + } + + /** + * Adds a single [TransformPriceFilter] to [compositePriceFilters]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addCompositePriceFilter(compositePriceFilter: TransformPriceFilter) = apply { + compositePriceFilters = + (compositePriceFilters ?: JsonField.of(mutableListOf())).also { + checkKnown("compositePriceFilters", it).add(compositePriceFilter) + } + } + fun conversionRate(conversionRate: Double?) = conversionRate(JsonField.ofNullable(conversionRate)) @@ -9179,7 +9435,7 @@ private constructor( * It is usually unnecessary to call this method because the field defaults to the * following: * ```kotlin - * JsonValue.from("tiered_bps") + * JsonValue.from("bulk") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -9248,20 +9504,6 @@ private constructor( this.replacesPriceId = replacesPriceId } - fun tieredBpsConfig(tieredBpsConfig: TieredBpsConfig) = - tieredBpsConfig(JsonField.of(tieredBpsConfig)) - - /** - * Sets [Builder.tieredBpsConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.tieredBpsConfig] with a well-typed [TieredBpsConfig] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun tieredBpsConfig(tieredBpsConfig: JsonField) = apply { - this.tieredBpsConfig = tieredBpsConfig - } - fun dimensionalPriceConfiguration( dimensionalPriceConfiguration: DimensionalPriceConfiguration? ) = dimensionalPriceConfiguration(JsonField.ofNullable(dimensionalPriceConfiguration)) @@ -9297,7 +9539,7 @@ private constructor( } /** - * Returns an immutable instance of [TieredBps]. + * Returns an immutable instance of [Bulk]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -9306,7 +9548,9 @@ private constructor( * .id() * .billableMetric() * .billingCycleConfiguration() + * .bulkConfig() * .cadence() + * .compositePriceFilters() * .conversionRate() * .conversionRateConfig() * .createdAt() @@ -9326,17 +9570,20 @@ private constructor( * .planPhaseOrder() * .priceType() * .replacesPriceId() - * .tieredBpsConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): TieredBps = - TieredBps( + fun build(): Bulk = + Bulk( checkRequired("id", id), checkRequired("billableMetric", billableMetric), checkRequired("billingCycleConfiguration", billingCycleConfiguration), + checkRequired("bulkConfig", bulkConfig), checkRequired("cadence", cadence), + checkRequired("compositePriceFilters", compositePriceFilters).map { + it.toImmutable() + }, checkRequired("conversionRate", conversionRate), checkRequired("conversionRateConfig", conversionRateConfig), checkRequired("createdAt", createdAt), @@ -9357,7 +9604,6 @@ private constructor( checkRequired("planPhaseOrder", planPhaseOrder), checkRequired("priceType", priceType), checkRequired("replacesPriceId", replacesPriceId), - checkRequired("tieredBpsConfig", tieredBpsConfig), dimensionalPriceConfiguration, additionalProperties.toMutableMap(), ) @@ -9365,7 +9611,7 @@ private constructor( private var validated: Boolean = false - fun validate(): TieredBps = apply { + fun validate(): Bulk = apply { if (validated) { return@apply } @@ -9373,7 +9619,9 @@ private constructor( id() billableMetric()?.validate() billingCycleConfiguration().validate() + bulkConfig().validate() cadence().validate() + compositePriceFilters()?.forEach { it.validate() } conversionRate() conversionRateConfig()?.validate() createdAt() @@ -9390,7 +9638,7 @@ private constructor( minimum()?.validate() minimumAmount() _modelType().let { - if (it != JsonValue.from("tiered_bps")) { + if (it != JsonValue.from("bulk")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } @@ -9398,7 +9646,6 @@ private constructor( planPhaseOrder() priceType().validate() replacesPriceId() - tieredBpsConfig().validate() dimensionalPriceConfiguration()?.validate() validated = true } @@ -9421,7 +9668,9 @@ private constructor( (if (id.asKnown() == null) 0 else 1) + (billableMetric.asKnown()?.validity() ?: 0) + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (bulkConfig.asKnown()?.validity() ?: 0) + (cadence.asKnown()?.validity() ?: 0) + + (compositePriceFilters.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + (if (conversionRate.asKnown() == null) 0 else 1) + (conversionRateConfig.asKnown()?.validity() ?: 0) + (if (createdAt.asKnown() == null) 0 else 1) + @@ -9437,12 +9686,11 @@ private constructor( (metadata.asKnown()?.validity() ?: 0) + (minimum.asKnown()?.validity() ?: 0) + (if (minimumAmount.asKnown() == null) 0 else 1) + - modelType.let { if (it == JsonValue.from("tiered_bps")) 1 else 0 } + + modelType.let { if (it == JsonValue.from("bulk")) 1 else 0 } + (if (name.asKnown() == null) 0 else 1) + (if (planPhaseOrder.asKnown() == null) 0 else 1) + (priceType.asKnown()?.validity() ?: 0) + (if (replacesPriceId.asKnown() == null) 0 else 1) + - (tieredBpsConfig.asKnown()?.validity() ?: 0) + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) class Cadence @JsonCreator private constructor(private val value: JsonField) : @@ -9836,11 +10084,13 @@ private constructor( return true } - return other is TieredBps && + return other is Bulk && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && + bulkConfig == other.bulkConfig && cadence == other.cadence && + compositePriceFilters == other.compositePriceFilters && conversionRate == other.conversionRate && conversionRateConfig == other.conversionRateConfig && createdAt == other.createdAt && @@ -9861,7 +10111,6 @@ private constructor( planPhaseOrder == other.planPhaseOrder && priceType == other.priceType && replacesPriceId == other.replacesPriceId && - tieredBpsConfig == other.tieredBpsConfig && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties } @@ -9871,7 +10120,9 @@ private constructor( id, billableMetric, billingCycleConfiguration, + bulkConfig, cadence, + compositePriceFilters, conversionRate, conversionRateConfig, createdAt, @@ -9892,7 +10143,6 @@ private constructor( planPhaseOrder, priceType, replacesPriceId, - tieredBpsConfig, dimensionalPriceConfiguration, additionalProperties, ) @@ -9901,16 +10151,16 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "TieredBps{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, tieredBpsConfig=$tieredBpsConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "Bulk{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, bulkConfig=$bulkConfig, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" } - class Bps + class ThresholdTotalAmount private constructor( private val id: JsonField, private val billableMetric: JsonField, private val billingCycleConfiguration: JsonField, - private val bpsConfig: JsonField, private val cadence: JsonField, + private val compositePriceFilters: JsonField>, private val conversionRate: JsonField, private val conversionRateConfig: JsonField, private val createdAt: JsonField, @@ -9931,6 +10181,7 @@ private constructor( private val planPhaseOrder: JsonField, private val priceType: JsonField, private val replacesPriceId: JsonField, + private val thresholdTotalAmountConfig: JsonField, private val dimensionalPriceConfiguration: JsonField, private val additionalProperties: MutableMap, ) { @@ -9944,10 +10195,10 @@ private constructor( @JsonProperty("billing_cycle_configuration") @ExcludeMissing billingCycleConfiguration: JsonField = JsonMissing.of(), - @JsonProperty("bps_config") - @ExcludeMissing - bpsConfig: JsonField = JsonMissing.of(), @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), + @JsonProperty("composite_price_filters") + @ExcludeMissing + compositePriceFilters: JsonField> = JsonMissing.of(), @JsonProperty("conversion_rate") @ExcludeMissing conversionRate: JsonField = JsonMissing.of(), @@ -9998,6 +10249,9 @@ private constructor( @JsonProperty("replaces_price_id") @ExcludeMissing replacesPriceId: JsonField = JsonMissing.of(), + @JsonProperty("threshold_total_amount_config") + @ExcludeMissing + thresholdTotalAmountConfig: JsonField = JsonMissing.of(), @JsonProperty("dimensional_price_configuration") @ExcludeMissing dimensionalPriceConfiguration: JsonField = @@ -10006,8 +10260,8 @@ private constructor( id, billableMetric, billingCycleConfiguration, - bpsConfig, cadence, + compositePriceFilters, conversionRate, conversionRateConfig, createdAt, @@ -10028,6 +10282,7 @@ private constructor( planPhaseOrder, priceType, replacesPriceId, + thresholdTotalAmountConfig, dimensionalPriceConfiguration, mutableMapOf(), ) @@ -10055,13 +10310,14 @@ private constructor( * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ - fun bpsConfig(): BpsConfig = bpsConfig.getRequired("bps_config") + fun cadence(): Cadence = cadence.getRequired("cadence") /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ - fun cadence(): Cadence = cadence.getRequired("cadence") + fun compositePriceFilters(): List? = + compositePriceFilters.getNullable("composite_price_filters") /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the @@ -10164,7 +10420,7 @@ private constructor( /** * Expected to always return the following: * ```kotlin - * JsonValue.from("bps") + * JsonValue.from("threshold_total_amount") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -10199,6 +10455,13 @@ private constructor( */ fun replacesPriceId(): String? = replacesPriceId.getNullable("replaces_price_id") + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun thresholdTotalAmountConfig(): ThresholdTotalAmountConfig = + thresholdTotalAmountConfig.getRequired("threshold_total_amount_config") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -10235,20 +10498,21 @@ private constructor( billingCycleConfiguration /** - * Returns the raw JSON value of [bpsConfig]. + * Returns the raw JSON value of [cadence]. * - * Unlike [bpsConfig], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("bps_config") - @ExcludeMissing - fun _bpsConfig(): JsonField = bpsConfig + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence /** - * Returns the raw JSON value of [cadence]. + * Returns the raw JSON value of [compositePriceFilters]. * - * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [compositePriceFilters], this method doesn't throw if the JSON field has an + * unexpected type. */ - @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence + @JsonProperty("composite_price_filters") + @ExcludeMissing + fun _compositePriceFilters(): JsonField> = compositePriceFilters /** * Returns the raw JSON value of [conversionRate]. @@ -10429,6 +10693,17 @@ private constructor( @ExcludeMissing fun _replacesPriceId(): JsonField = replacesPriceId + /** + * Returns the raw JSON value of [thresholdTotalAmountConfig]. + * + * Unlike [thresholdTotalAmountConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("threshold_total_amount_config") + @ExcludeMissing + fun _thresholdTotalAmountConfig(): JsonField = + thresholdTotalAmountConfig + /** * Returns the raw JSON value of [dimensionalPriceConfiguration]. * @@ -10455,15 +10730,15 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [Bps]. + * Returns a mutable builder for constructing an instance of [ThresholdTotalAmount]. * * The following fields are required: * ```kotlin * .id() * .billableMetric() * .billingCycleConfiguration() - * .bpsConfig() * .cadence() + * .compositePriceFilters() * .conversionRate() * .conversionRateConfig() * .createdAt() @@ -10483,19 +10758,20 @@ private constructor( * .planPhaseOrder() * .priceType() * .replacesPriceId() + * .thresholdTotalAmountConfig() * ``` */ fun builder() = Builder() } - /** A builder for [Bps]. */ + /** A builder for [ThresholdTotalAmount]. */ class Builder internal constructor() { private var id: JsonField? = null private var billableMetric: JsonField? = null private var billingCycleConfiguration: JsonField? = null - private var bpsConfig: JsonField? = null private var cadence: JsonField? = null + private var compositePriceFilters: JsonField>? = null private var conversionRate: JsonField? = null private var conversionRateConfig: JsonField? = null private var createdAt: JsonField? = null @@ -10511,43 +10787,46 @@ private constructor( private var metadata: JsonField? = null private var minimum: JsonField? = null private var minimumAmount: JsonField? = null - private var modelType: JsonValue = JsonValue.from("bps") + private var modelType: JsonValue = JsonValue.from("threshold_total_amount") private var name: JsonField? = null private var planPhaseOrder: JsonField? = null private var priceType: JsonField? = null private var replacesPriceId: JsonField? = null + private var thresholdTotalAmountConfig: JsonField? = null private var dimensionalPriceConfiguration: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(bps: Bps) = apply { - id = bps.id - billableMetric = bps.billableMetric - billingCycleConfiguration = bps.billingCycleConfiguration - bpsConfig = bps.bpsConfig - cadence = bps.cadence - conversionRate = bps.conversionRate - conversionRateConfig = bps.conversionRateConfig - createdAt = bps.createdAt - creditAllocation = bps.creditAllocation - currency = bps.currency - discount = bps.discount - externalPriceId = bps.externalPriceId - fixedPriceQuantity = bps.fixedPriceQuantity - invoicingCycleConfiguration = bps.invoicingCycleConfiguration - item = bps.item - maximum = bps.maximum - maximumAmount = bps.maximumAmount - metadata = bps.metadata - minimum = bps.minimum - minimumAmount = bps.minimumAmount - modelType = bps.modelType - name = bps.name - planPhaseOrder = bps.planPhaseOrder - priceType = bps.priceType - replacesPriceId = bps.replacesPriceId - dimensionalPriceConfiguration = bps.dimensionalPriceConfiguration - additionalProperties = bps.additionalProperties.toMutableMap() + internal fun from(thresholdTotalAmount: ThresholdTotalAmount) = apply { + id = thresholdTotalAmount.id + billableMetric = thresholdTotalAmount.billableMetric + billingCycleConfiguration = thresholdTotalAmount.billingCycleConfiguration + cadence = thresholdTotalAmount.cadence + compositePriceFilters = + thresholdTotalAmount.compositePriceFilters.map { it.toMutableList() } + conversionRate = thresholdTotalAmount.conversionRate + conversionRateConfig = thresholdTotalAmount.conversionRateConfig + createdAt = thresholdTotalAmount.createdAt + creditAllocation = thresholdTotalAmount.creditAllocation + currency = thresholdTotalAmount.currency + discount = thresholdTotalAmount.discount + externalPriceId = thresholdTotalAmount.externalPriceId + fixedPriceQuantity = thresholdTotalAmount.fixedPriceQuantity + invoicingCycleConfiguration = thresholdTotalAmount.invoicingCycleConfiguration + item = thresholdTotalAmount.item + maximum = thresholdTotalAmount.maximum + maximumAmount = thresholdTotalAmount.maximumAmount + metadata = thresholdTotalAmount.metadata + minimum = thresholdTotalAmount.minimum + minimumAmount = thresholdTotalAmount.minimumAmount + modelType = thresholdTotalAmount.modelType + name = thresholdTotalAmount.name + planPhaseOrder = thresholdTotalAmount.planPhaseOrder + priceType = thresholdTotalAmount.priceType + replacesPriceId = thresholdTotalAmount.replacesPriceId + thresholdTotalAmountConfig = thresholdTotalAmount.thresholdTotalAmountConfig + dimensionalPriceConfiguration = thresholdTotalAmount.dimensionalPriceConfiguration + additionalProperties = thresholdTotalAmount.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) @@ -10589,17 +10868,6 @@ private constructor( billingCycleConfiguration: JsonField ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } - fun bpsConfig(bpsConfig: BpsConfig) = bpsConfig(JsonField.of(bpsConfig)) - - /** - * Sets [Builder.bpsConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.bpsConfig] with a well-typed [BpsConfig] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun bpsConfig(bpsConfig: JsonField) = apply { this.bpsConfig = bpsConfig } - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) /** @@ -10611,6 +10879,34 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + fun compositePriceFilters(compositePriceFilters: List?) = + compositePriceFilters(JsonField.ofNullable(compositePriceFilters)) + + /** + * Sets [Builder.compositePriceFilters] to an arbitrary JSON value. + * + * You should usually call [Builder.compositePriceFilters] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun compositePriceFilters( + compositePriceFilters: JsonField> + ) = apply { + this.compositePriceFilters = compositePriceFilters.map { it.toMutableList() } + } + + /** + * Adds a single [TransformPriceFilter] to [compositePriceFilters]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addCompositePriceFilter(compositePriceFilter: TransformPriceFilter) = apply { + compositePriceFilters = + (compositePriceFilters ?: JsonField.of(mutableListOf())).also { + checkKnown("compositePriceFilters", it).add(compositePriceFilter) + } + } + fun conversionRate(conversionRate: Double?) = conversionRate(JsonField.ofNullable(conversionRate)) @@ -10958,7 +11254,7 @@ private constructor( * It is usually unnecessary to call this method because the field defaults to the * following: * ```kotlin - * JsonValue.from("bps") + * JsonValue.from("threshold_total_amount") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -11027,6 +11323,20 @@ private constructor( this.replacesPriceId = replacesPriceId } + fun thresholdTotalAmountConfig(thresholdTotalAmountConfig: ThresholdTotalAmountConfig) = + thresholdTotalAmountConfig(JsonField.of(thresholdTotalAmountConfig)) + + /** + * Sets [Builder.thresholdTotalAmountConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.thresholdTotalAmountConfig] with a well-typed + * [ThresholdTotalAmountConfig] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun thresholdTotalAmountConfig( + thresholdTotalAmountConfig: JsonField + ) = apply { this.thresholdTotalAmountConfig = thresholdTotalAmountConfig } + fun dimensionalPriceConfiguration( dimensionalPriceConfiguration: DimensionalPriceConfiguration? ) = dimensionalPriceConfiguration(JsonField.ofNullable(dimensionalPriceConfiguration)) @@ -11062,7 +11372,7 @@ private constructor( } /** - * Returns an immutable instance of [Bps]. + * Returns an immutable instance of [ThresholdTotalAmount]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -11071,8 +11381,8 @@ private constructor( * .id() * .billableMetric() * .billingCycleConfiguration() - * .bpsConfig() * .cadence() + * .compositePriceFilters() * .conversionRate() * .conversionRateConfig() * .createdAt() @@ -11092,17 +11402,20 @@ private constructor( * .planPhaseOrder() * .priceType() * .replacesPriceId() + * .thresholdTotalAmountConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): Bps = - Bps( + fun build(): ThresholdTotalAmount = + ThresholdTotalAmount( checkRequired("id", id), checkRequired("billableMetric", billableMetric), checkRequired("billingCycleConfiguration", billingCycleConfiguration), - checkRequired("bpsConfig", bpsConfig), checkRequired("cadence", cadence), + checkRequired("compositePriceFilters", compositePriceFilters).map { + it.toImmutable() + }, checkRequired("conversionRate", conversionRate), checkRequired("conversionRateConfig", conversionRateConfig), checkRequired("createdAt", createdAt), @@ -11123,6 +11436,7 @@ private constructor( checkRequired("planPhaseOrder", planPhaseOrder), checkRequired("priceType", priceType), checkRequired("replacesPriceId", replacesPriceId), + checkRequired("thresholdTotalAmountConfig", thresholdTotalAmountConfig), dimensionalPriceConfiguration, additionalProperties.toMutableMap(), ) @@ -11130,7 +11444,7 @@ private constructor( private var validated: Boolean = false - fun validate(): Bps = apply { + fun validate(): ThresholdTotalAmount = apply { if (validated) { return@apply } @@ -11138,8 +11452,8 @@ private constructor( id() billableMetric()?.validate() billingCycleConfiguration().validate() - bpsConfig().validate() cadence().validate() + compositePriceFilters()?.forEach { it.validate() } conversionRate() conversionRateConfig()?.validate() createdAt() @@ -11156,7 +11470,7 @@ private constructor( minimum()?.validate() minimumAmount() _modelType().let { - if (it != JsonValue.from("bps")) { + if (it != JsonValue.from("threshold_total_amount")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } @@ -11164,6 +11478,7 @@ private constructor( planPhaseOrder() priceType().validate() replacesPriceId() + thresholdTotalAmountConfig().validate() dimensionalPriceConfiguration()?.validate() validated = true } @@ -11186,8 +11501,8 @@ private constructor( (if (id.asKnown() == null) 0 else 1) + (billableMetric.asKnown()?.validity() ?: 0) + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + - (bpsConfig.asKnown()?.validity() ?: 0) + (cadence.asKnown()?.validity() ?: 0) + + (compositePriceFilters.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + (if (conversionRate.asKnown() == null) 0 else 1) + (conversionRateConfig.asKnown()?.validity() ?: 0) + (if (createdAt.asKnown() == null) 0 else 1) + @@ -11203,11 +11518,12 @@ private constructor( (metadata.asKnown()?.validity() ?: 0) + (minimum.asKnown()?.validity() ?: 0) + (if (minimumAmount.asKnown() == null) 0 else 1) + - modelType.let { if (it == JsonValue.from("bps")) 1 else 0 } + + modelType.let { if (it == JsonValue.from("threshold_total_amount")) 1 else 0 } + (if (name.asKnown() == null) 0 else 1) + (if (planPhaseOrder.asKnown() == null) 0 else 1) + (priceType.asKnown()?.validity() ?: 0) + (if (replacesPriceId.asKnown() == null) 0 else 1) + + (thresholdTotalAmountConfig.asKnown()?.validity() ?: 0) + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) class Cadence @JsonCreator private constructor(private val value: JsonField) : @@ -11596,17 +11912,124 @@ private constructor( override fun toString() = value.toString() } + class ThresholdTotalAmountConfig + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [ThresholdTotalAmountConfig]. + */ + fun builder() = Builder() + } + + /** A builder for [ThresholdTotalAmountConfig]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(thresholdTotalAmountConfig: ThresholdTotalAmountConfig) = apply { + additionalProperties = + thresholdTotalAmountConfig.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ThresholdTotalAmountConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ThresholdTotalAmountConfig = + ThresholdTotalAmountConfig(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): ThresholdTotalAmountConfig = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ThresholdTotalAmountConfig && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ThresholdTotalAmountConfig{additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is Bps && + return other is ThresholdTotalAmount && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && - bpsConfig == other.bpsConfig && cadence == other.cadence && + compositePriceFilters == other.compositePriceFilters && conversionRate == other.conversionRate && conversionRateConfig == other.conversionRateConfig && createdAt == other.createdAt && @@ -11627,6 +12050,7 @@ private constructor( planPhaseOrder == other.planPhaseOrder && priceType == other.priceType && replacesPriceId == other.replacesPriceId && + thresholdTotalAmountConfig == other.thresholdTotalAmountConfig && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties } @@ -11636,8 +12060,8 @@ private constructor( id, billableMetric, billingCycleConfiguration, - bpsConfig, cadence, + compositePriceFilters, conversionRate, conversionRateConfig, createdAt, @@ -11658,6 +12082,7 @@ private constructor( planPhaseOrder, priceType, replacesPriceId, + thresholdTotalAmountConfig, dimensionalPriceConfiguration, additionalProperties, ) @@ -11666,16 +12091,16 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Bps{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, bpsConfig=$bpsConfig, cadence=$cadence, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "ThresholdTotalAmount{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, thresholdTotalAmountConfig=$thresholdTotalAmountConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" } - class BulkBps + class TieredPackage private constructor( private val id: JsonField, private val billableMetric: JsonField, private val billingCycleConfiguration: JsonField, - private val bulkBpsConfig: JsonField, private val cadence: JsonField, + private val compositePriceFilters: JsonField>, private val conversionRate: JsonField, private val conversionRateConfig: JsonField, private val createdAt: JsonField, @@ -11696,6 +12121,7 @@ private constructor( private val planPhaseOrder: JsonField, private val priceType: JsonField, private val replacesPriceId: JsonField, + private val tieredPackageConfig: JsonField, private val dimensionalPriceConfiguration: JsonField, private val additionalProperties: MutableMap, ) { @@ -11709,10 +12135,10 @@ private constructor( @JsonProperty("billing_cycle_configuration") @ExcludeMissing billingCycleConfiguration: JsonField = JsonMissing.of(), - @JsonProperty("bulk_bps_config") - @ExcludeMissing - bulkBpsConfig: JsonField = JsonMissing.of(), @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), + @JsonProperty("composite_price_filters") + @ExcludeMissing + compositePriceFilters: JsonField> = JsonMissing.of(), @JsonProperty("conversion_rate") @ExcludeMissing conversionRate: JsonField = JsonMissing.of(), @@ -11763,6 +12189,9 @@ private constructor( @JsonProperty("replaces_price_id") @ExcludeMissing replacesPriceId: JsonField = JsonMissing.of(), + @JsonProperty("tiered_package_config") + @ExcludeMissing + tieredPackageConfig: JsonField = JsonMissing.of(), @JsonProperty("dimensional_price_configuration") @ExcludeMissing dimensionalPriceConfiguration: JsonField = @@ -11771,8 +12200,8 @@ private constructor( id, billableMetric, billingCycleConfiguration, - bulkBpsConfig, cadence, + compositePriceFilters, conversionRate, conversionRateConfig, createdAt, @@ -11793,6 +12222,7 @@ private constructor( planPhaseOrder, priceType, replacesPriceId, + tieredPackageConfig, dimensionalPriceConfiguration, mutableMapOf(), ) @@ -11820,13 +12250,14 @@ private constructor( * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ - fun bulkBpsConfig(): BulkBpsConfig = bulkBpsConfig.getRequired("bulk_bps_config") + fun cadence(): Cadence = cadence.getRequired("cadence") /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ - fun cadence(): Cadence = cadence.getRequired("cadence") + fun compositePriceFilters(): List? = + compositePriceFilters.getNullable("composite_price_filters") /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the @@ -11929,7 +12360,7 @@ private constructor( /** * Expected to always return the following: * ```kotlin - * JsonValue.from("bulk_bps") + * JsonValue.from("tiered_package") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -11964,6 +12395,13 @@ private constructor( */ fun replacesPriceId(): String? = replacesPriceId.getNullable("replaces_price_id") + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun tieredPackageConfig(): TieredPackageConfig = + tieredPackageConfig.getRequired("tiered_package_config") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -12000,21 +12438,21 @@ private constructor( billingCycleConfiguration /** - * Returns the raw JSON value of [bulkBpsConfig]. + * Returns the raw JSON value of [cadence]. * - * Unlike [bulkBpsConfig], this method doesn't throw if the JSON field has an unexpected - * type. + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("bulk_bps_config") - @ExcludeMissing - fun _bulkBpsConfig(): JsonField = bulkBpsConfig + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence /** - * Returns the raw JSON value of [cadence]. + * Returns the raw JSON value of [compositePriceFilters]. * - * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [compositePriceFilters], this method doesn't throw if the JSON field has an + * unexpected type. */ - @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence + @JsonProperty("composite_price_filters") + @ExcludeMissing + fun _compositePriceFilters(): JsonField> = compositePriceFilters /** * Returns the raw JSON value of [conversionRate]. @@ -12195,6 +12633,16 @@ private constructor( @ExcludeMissing fun _replacesPriceId(): JsonField = replacesPriceId + /** + * Returns the raw JSON value of [tieredPackageConfig]. + * + * Unlike [tieredPackageConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("tiered_package_config") + @ExcludeMissing + fun _tieredPackageConfig(): JsonField = tieredPackageConfig + /** * Returns the raw JSON value of [dimensionalPriceConfiguration]. * @@ -12221,15 +12669,15 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [BulkBps]. + * Returns a mutable builder for constructing an instance of [TieredPackage]. * * The following fields are required: * ```kotlin * .id() * .billableMetric() * .billingCycleConfiguration() - * .bulkBpsConfig() * .cadence() + * .compositePriceFilters() * .conversionRate() * .conversionRateConfig() * .createdAt() @@ -12249,19 +12697,20 @@ private constructor( * .planPhaseOrder() * .priceType() * .replacesPriceId() + * .tieredPackageConfig() * ``` */ fun builder() = Builder() } - /** A builder for [BulkBps]. */ + /** A builder for [TieredPackage]. */ class Builder internal constructor() { private var id: JsonField? = null private var billableMetric: JsonField? = null private var billingCycleConfiguration: JsonField? = null - private var bulkBpsConfig: JsonField? = null private var cadence: JsonField? = null + private var compositePriceFilters: JsonField>? = null private var conversionRate: JsonField? = null private var conversionRateConfig: JsonField? = null private var createdAt: JsonField? = null @@ -12277,43 +12726,46 @@ private constructor( private var metadata: JsonField? = null private var minimum: JsonField? = null private var minimumAmount: JsonField? = null - private var modelType: JsonValue = JsonValue.from("bulk_bps") + private var modelType: JsonValue = JsonValue.from("tiered_package") private var name: JsonField? = null private var planPhaseOrder: JsonField? = null private var priceType: JsonField? = null private var replacesPriceId: JsonField? = null + private var tieredPackageConfig: JsonField? = null private var dimensionalPriceConfiguration: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(bulkBps: BulkBps) = apply { - id = bulkBps.id - billableMetric = bulkBps.billableMetric - billingCycleConfiguration = bulkBps.billingCycleConfiguration - bulkBpsConfig = bulkBps.bulkBpsConfig - cadence = bulkBps.cadence - conversionRate = bulkBps.conversionRate - conversionRateConfig = bulkBps.conversionRateConfig - createdAt = bulkBps.createdAt - creditAllocation = bulkBps.creditAllocation - currency = bulkBps.currency - discount = bulkBps.discount - externalPriceId = bulkBps.externalPriceId - fixedPriceQuantity = bulkBps.fixedPriceQuantity - invoicingCycleConfiguration = bulkBps.invoicingCycleConfiguration - item = bulkBps.item - maximum = bulkBps.maximum - maximumAmount = bulkBps.maximumAmount - metadata = bulkBps.metadata - minimum = bulkBps.minimum - minimumAmount = bulkBps.minimumAmount - modelType = bulkBps.modelType - name = bulkBps.name - planPhaseOrder = bulkBps.planPhaseOrder - priceType = bulkBps.priceType - replacesPriceId = bulkBps.replacesPriceId - dimensionalPriceConfiguration = bulkBps.dimensionalPriceConfiguration - additionalProperties = bulkBps.additionalProperties.toMutableMap() + internal fun from(tieredPackage: TieredPackage) = apply { + id = tieredPackage.id + billableMetric = tieredPackage.billableMetric + billingCycleConfiguration = tieredPackage.billingCycleConfiguration + cadence = tieredPackage.cadence + compositePriceFilters = + tieredPackage.compositePriceFilters.map { it.toMutableList() } + conversionRate = tieredPackage.conversionRate + conversionRateConfig = tieredPackage.conversionRateConfig + createdAt = tieredPackage.createdAt + creditAllocation = tieredPackage.creditAllocation + currency = tieredPackage.currency + discount = tieredPackage.discount + externalPriceId = tieredPackage.externalPriceId + fixedPriceQuantity = tieredPackage.fixedPriceQuantity + invoicingCycleConfiguration = tieredPackage.invoicingCycleConfiguration + item = tieredPackage.item + maximum = tieredPackage.maximum + maximumAmount = tieredPackage.maximumAmount + metadata = tieredPackage.metadata + minimum = tieredPackage.minimum + minimumAmount = tieredPackage.minimumAmount + modelType = tieredPackage.modelType + name = tieredPackage.name + planPhaseOrder = tieredPackage.planPhaseOrder + priceType = tieredPackage.priceType + replacesPriceId = tieredPackage.replacesPriceId + tieredPackageConfig = tieredPackage.tieredPackageConfig + dimensionalPriceConfiguration = tieredPackage.dimensionalPriceConfiguration + additionalProperties = tieredPackage.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) @@ -12355,20 +12807,6 @@ private constructor( billingCycleConfiguration: JsonField ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } - fun bulkBpsConfig(bulkBpsConfig: BulkBpsConfig) = - bulkBpsConfig(JsonField.of(bulkBpsConfig)) - - /** - * Sets [Builder.bulkBpsConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.bulkBpsConfig] with a well-typed [BulkBpsConfig] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun bulkBpsConfig(bulkBpsConfig: JsonField) = apply { - this.bulkBpsConfig = bulkBpsConfig - } - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) /** @@ -12380,6 +12818,34 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + fun compositePriceFilters(compositePriceFilters: List?) = + compositePriceFilters(JsonField.ofNullable(compositePriceFilters)) + + /** + * Sets [Builder.compositePriceFilters] to an arbitrary JSON value. + * + * You should usually call [Builder.compositePriceFilters] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun compositePriceFilters( + compositePriceFilters: JsonField> + ) = apply { + this.compositePriceFilters = compositePriceFilters.map { it.toMutableList() } + } + + /** + * Adds a single [TransformPriceFilter] to [compositePriceFilters]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addCompositePriceFilter(compositePriceFilter: TransformPriceFilter) = apply { + compositePriceFilters = + (compositePriceFilters ?: JsonField.of(mutableListOf())).also { + checkKnown("compositePriceFilters", it).add(compositePriceFilter) + } + } + fun conversionRate(conversionRate: Double?) = conversionRate(JsonField.ofNullable(conversionRate)) @@ -12727,7 +13193,7 @@ private constructor( * It is usually unnecessary to call this method because the field defaults to the * following: * ```kotlin - * JsonValue.from("bulk_bps") + * JsonValue.from("tiered_package") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -12796,6 +13262,20 @@ private constructor( this.replacesPriceId = replacesPriceId } + fun tieredPackageConfig(tieredPackageConfig: TieredPackageConfig) = + tieredPackageConfig(JsonField.of(tieredPackageConfig)) + + /** + * Sets [Builder.tieredPackageConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.tieredPackageConfig] with a well-typed + * [TieredPackageConfig] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun tieredPackageConfig(tieredPackageConfig: JsonField) = apply { + this.tieredPackageConfig = tieredPackageConfig + } + fun dimensionalPriceConfiguration( dimensionalPriceConfiguration: DimensionalPriceConfiguration? ) = dimensionalPriceConfiguration(JsonField.ofNullable(dimensionalPriceConfiguration)) @@ -12831,7 +13311,7 @@ private constructor( } /** - * Returns an immutable instance of [BulkBps]. + * Returns an immutable instance of [TieredPackage]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -12840,8 +13320,8 @@ private constructor( * .id() * .billableMetric() * .billingCycleConfiguration() - * .bulkBpsConfig() * .cadence() + * .compositePriceFilters() * .conversionRate() * .conversionRateConfig() * .createdAt() @@ -12861,17 +13341,20 @@ private constructor( * .planPhaseOrder() * .priceType() * .replacesPriceId() + * .tieredPackageConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): BulkBps = - BulkBps( + fun build(): TieredPackage = + TieredPackage( checkRequired("id", id), checkRequired("billableMetric", billableMetric), checkRequired("billingCycleConfiguration", billingCycleConfiguration), - checkRequired("bulkBpsConfig", bulkBpsConfig), checkRequired("cadence", cadence), + checkRequired("compositePriceFilters", compositePriceFilters).map { + it.toImmutable() + }, checkRequired("conversionRate", conversionRate), checkRequired("conversionRateConfig", conversionRateConfig), checkRequired("createdAt", createdAt), @@ -12892,6 +13375,7 @@ private constructor( checkRequired("planPhaseOrder", planPhaseOrder), checkRequired("priceType", priceType), checkRequired("replacesPriceId", replacesPriceId), + checkRequired("tieredPackageConfig", tieredPackageConfig), dimensionalPriceConfiguration, additionalProperties.toMutableMap(), ) @@ -12899,7 +13383,7 @@ private constructor( private var validated: Boolean = false - fun validate(): BulkBps = apply { + fun validate(): TieredPackage = apply { if (validated) { return@apply } @@ -12907,8 +13391,8 @@ private constructor( id() billableMetric()?.validate() billingCycleConfiguration().validate() - bulkBpsConfig().validate() cadence().validate() + compositePriceFilters()?.forEach { it.validate() } conversionRate() conversionRateConfig()?.validate() createdAt() @@ -12925,7 +13409,7 @@ private constructor( minimum()?.validate() minimumAmount() _modelType().let { - if (it != JsonValue.from("bulk_bps")) { + if (it != JsonValue.from("tiered_package")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } @@ -12933,6 +13417,7 @@ private constructor( planPhaseOrder() priceType().validate() replacesPriceId() + tieredPackageConfig().validate() dimensionalPriceConfiguration()?.validate() validated = true } @@ -12955,8 +13440,8 @@ private constructor( (if (id.asKnown() == null) 0 else 1) + (billableMetric.asKnown()?.validity() ?: 0) + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + - (bulkBpsConfig.asKnown()?.validity() ?: 0) + (cadence.asKnown()?.validity() ?: 0) + + (compositePriceFilters.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + (if (conversionRate.asKnown() == null) 0 else 1) + (conversionRateConfig.asKnown()?.validity() ?: 0) + (if (createdAt.asKnown() == null) 0 else 1) + @@ -12972,11 +13457,12 @@ private constructor( (metadata.asKnown()?.validity() ?: 0) + (minimum.asKnown()?.validity() ?: 0) + (if (minimumAmount.asKnown() == null) 0 else 1) + - modelType.let { if (it == JsonValue.from("bulk_bps")) 1 else 0 } + + modelType.let { if (it == JsonValue.from("tiered_package")) 1 else 0 } + (if (name.asKnown() == null) 0 else 1) + (if (planPhaseOrder.asKnown() == null) 0 else 1) + (priceType.asKnown()?.validity() ?: 0) + (if (replacesPriceId.asKnown() == null) 0 else 1) + + (tieredPackageConfig.asKnown()?.validity() ?: 0) + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) class Cadence @JsonCreator private constructor(private val value: JsonField) : @@ -13365,17 +13851,122 @@ private constructor( override fun toString() = value.toString() } + class TieredPackageConfig + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [TieredPackageConfig]. + */ + fun builder() = Builder() + } + + /** A builder for [TieredPackageConfig]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(tieredPackageConfig: TieredPackageConfig) = apply { + additionalProperties = tieredPackageConfig.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [TieredPackageConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): TieredPackageConfig = + TieredPackageConfig(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): TieredPackageConfig = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TieredPackageConfig && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TieredPackageConfig{additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is BulkBps && + return other is TieredPackage && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && - bulkBpsConfig == other.bulkBpsConfig && cadence == other.cadence && + compositePriceFilters == other.compositePriceFilters && conversionRate == other.conversionRate && conversionRateConfig == other.conversionRateConfig && createdAt == other.createdAt && @@ -13396,6 +13987,7 @@ private constructor( planPhaseOrder == other.planPhaseOrder && priceType == other.priceType && replacesPriceId == other.replacesPriceId && + tieredPackageConfig == other.tieredPackageConfig && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties } @@ -13405,8 +13997,8 @@ private constructor( id, billableMetric, billingCycleConfiguration, - bulkBpsConfig, cadence, + compositePriceFilters, conversionRate, conversionRateConfig, createdAt, @@ -13427,6 +14019,7 @@ private constructor( planPhaseOrder, priceType, replacesPriceId, + tieredPackageConfig, dimensionalPriceConfiguration, additionalProperties, ) @@ -13435,16 +14028,16 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "BulkBps{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, bulkBpsConfig=$bulkBpsConfig, cadence=$cadence, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "TieredPackage{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, tieredPackageConfig=$tieredPackageConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" } - class Bulk + class GroupedTiered private constructor( private val id: JsonField, private val billableMetric: JsonField, private val billingCycleConfiguration: JsonField, - private val bulkConfig: JsonField, private val cadence: JsonField, + private val compositePriceFilters: JsonField>, private val conversionRate: JsonField, private val conversionRateConfig: JsonField, private val createdAt: JsonField, @@ -13453,6 +14046,7 @@ private constructor( private val discount: JsonField, private val externalPriceId: JsonField, private val fixedPriceQuantity: JsonField, + private val groupedTieredConfig: JsonField, private val invoicingCycleConfiguration: JsonField, private val item: JsonField, private val maximum: JsonField, @@ -13478,10 +14072,10 @@ private constructor( @JsonProperty("billing_cycle_configuration") @ExcludeMissing billingCycleConfiguration: JsonField = JsonMissing.of(), - @JsonProperty("bulk_config") - @ExcludeMissing - bulkConfig: JsonField = JsonMissing.of(), @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), + @JsonProperty("composite_price_filters") + @ExcludeMissing + compositePriceFilters: JsonField> = JsonMissing.of(), @JsonProperty("conversion_rate") @ExcludeMissing conversionRate: JsonField = JsonMissing.of(), @@ -13506,6 +14100,9 @@ private constructor( @JsonProperty("fixed_price_quantity") @ExcludeMissing fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("grouped_tiered_config") + @ExcludeMissing + groupedTieredConfig: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), @@ -13540,8 +14137,8 @@ private constructor( id, billableMetric, billingCycleConfiguration, - bulkConfig, cadence, + compositePriceFilters, conversionRate, conversionRateConfig, createdAt, @@ -13550,6 +14147,7 @@ private constructor( discount, externalPriceId, fixedPriceQuantity, + groupedTieredConfig, invoicingCycleConfiguration, item, maximum, @@ -13589,13 +14187,14 @@ private constructor( * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ - fun bulkConfig(): BulkConfig = bulkConfig.getRequired("bulk_config") + fun cadence(): Cadence = cadence.getRequired("cadence") /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ - fun cadence(): Cadence = cadence.getRequired("cadence") + fun compositePriceFilters(): List? = + compositePriceFilters.getNullable("composite_price_filters") /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the @@ -13646,6 +14245,13 @@ private constructor( */ fun fixedPriceQuantity(): Double? = fixedPriceQuantity.getNullable("fixed_price_quantity") + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun groupedTieredConfig(): GroupedTieredConfig = + groupedTieredConfig.getRequired("grouped_tiered_config") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -13698,7 +14304,7 @@ private constructor( /** * Expected to always return the following: * ```kotlin - * JsonValue.from("bulk") + * JsonValue.from("grouped_tiered") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -13769,20 +14375,21 @@ private constructor( billingCycleConfiguration /** - * Returns the raw JSON value of [bulkConfig]. + * Returns the raw JSON value of [cadence]. * - * Unlike [bulkConfig], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("bulk_config") - @ExcludeMissing - fun _bulkConfig(): JsonField = bulkConfig + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence /** - * Returns the raw JSON value of [cadence]. + * Returns the raw JSON value of [compositePriceFilters]. * - * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [compositePriceFilters], this method doesn't throw if the JSON field has an + * unexpected type. */ - @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence + @JsonProperty("composite_price_filters") + @ExcludeMissing + fun _compositePriceFilters(): JsonField> = compositePriceFilters /** * Returns the raw JSON value of [conversionRate]. @@ -13860,6 +14467,16 @@ private constructor( @ExcludeMissing fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + /** + * Returns the raw JSON value of [groupedTieredConfig]. + * + * Unlike [groupedTieredConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouped_tiered_config") + @ExcludeMissing + fun _groupedTieredConfig(): JsonField = groupedTieredConfig + /** * Returns the raw JSON value of [invoicingCycleConfiguration]. * @@ -13989,15 +14606,15 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [Bulk]. + * Returns a mutable builder for constructing an instance of [GroupedTiered]. * * The following fields are required: * ```kotlin * .id() * .billableMetric() * .billingCycleConfiguration() - * .bulkConfig() * .cadence() + * .compositePriceFilters() * .conversionRate() * .conversionRateConfig() * .createdAt() @@ -14006,6 +14623,7 @@ private constructor( * .discount() * .externalPriceId() * .fixedPriceQuantity() + * .groupedTieredConfig() * .invoicingCycleConfiguration() * .item() * .maximum() @@ -14022,14 +14640,14 @@ private constructor( fun builder() = Builder() } - /** A builder for [Bulk]. */ + /** A builder for [GroupedTiered]. */ class Builder internal constructor() { private var id: JsonField? = null private var billableMetric: JsonField? = null private var billingCycleConfiguration: JsonField? = null - private var bulkConfig: JsonField? = null private var cadence: JsonField? = null + private var compositePriceFilters: JsonField>? = null private var conversionRate: JsonField? = null private var conversionRateConfig: JsonField? = null private var createdAt: JsonField? = null @@ -14038,6 +14656,7 @@ private constructor( private var discount: JsonField? = null private var externalPriceId: JsonField? = null private var fixedPriceQuantity: JsonField? = null + private var groupedTieredConfig: JsonField? = null private var invoicingCycleConfiguration: JsonField? = null private var item: JsonField? = null private var maximum: JsonField? = null @@ -14045,7 +14664,7 @@ private constructor( private var metadata: JsonField? = null private var minimum: JsonField? = null private var minimumAmount: JsonField? = null - private var modelType: JsonValue = JsonValue.from("bulk") + private var modelType: JsonValue = JsonValue.from("grouped_tiered") private var name: JsonField? = null private var planPhaseOrder: JsonField? = null private var priceType: JsonField? = null @@ -14054,34 +14673,36 @@ private constructor( JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(bulk: Bulk) = apply { - id = bulk.id - billableMetric = bulk.billableMetric - billingCycleConfiguration = bulk.billingCycleConfiguration - bulkConfig = bulk.bulkConfig - cadence = bulk.cadence - conversionRate = bulk.conversionRate - conversionRateConfig = bulk.conversionRateConfig - createdAt = bulk.createdAt - creditAllocation = bulk.creditAllocation - currency = bulk.currency - discount = bulk.discount - externalPriceId = bulk.externalPriceId - fixedPriceQuantity = bulk.fixedPriceQuantity - invoicingCycleConfiguration = bulk.invoicingCycleConfiguration - item = bulk.item - maximum = bulk.maximum - maximumAmount = bulk.maximumAmount - metadata = bulk.metadata - minimum = bulk.minimum - minimumAmount = bulk.minimumAmount - modelType = bulk.modelType - name = bulk.name - planPhaseOrder = bulk.planPhaseOrder - priceType = bulk.priceType - replacesPriceId = bulk.replacesPriceId - dimensionalPriceConfiguration = bulk.dimensionalPriceConfiguration - additionalProperties = bulk.additionalProperties.toMutableMap() + internal fun from(groupedTiered: GroupedTiered) = apply { + id = groupedTiered.id + billableMetric = groupedTiered.billableMetric + billingCycleConfiguration = groupedTiered.billingCycleConfiguration + cadence = groupedTiered.cadence + compositePriceFilters = + groupedTiered.compositePriceFilters.map { it.toMutableList() } + conversionRate = groupedTiered.conversionRate + conversionRateConfig = groupedTiered.conversionRateConfig + createdAt = groupedTiered.createdAt + creditAllocation = groupedTiered.creditAllocation + currency = groupedTiered.currency + discount = groupedTiered.discount + externalPriceId = groupedTiered.externalPriceId + fixedPriceQuantity = groupedTiered.fixedPriceQuantity + groupedTieredConfig = groupedTiered.groupedTieredConfig + invoicingCycleConfiguration = groupedTiered.invoicingCycleConfiguration + item = groupedTiered.item + maximum = groupedTiered.maximum + maximumAmount = groupedTiered.maximumAmount + metadata = groupedTiered.metadata + minimum = groupedTiered.minimum + minimumAmount = groupedTiered.minimumAmount + modelType = groupedTiered.modelType + name = groupedTiered.name + planPhaseOrder = groupedTiered.planPhaseOrder + priceType = groupedTiered.priceType + replacesPriceId = groupedTiered.replacesPriceId + dimensionalPriceConfiguration = groupedTiered.dimensionalPriceConfiguration + additionalProperties = groupedTiered.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) @@ -14123,19 +14744,6 @@ private constructor( billingCycleConfiguration: JsonField ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } - fun bulkConfig(bulkConfig: BulkConfig) = bulkConfig(JsonField.of(bulkConfig)) - - /** - * Sets [Builder.bulkConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.bulkConfig] with a well-typed [BulkConfig] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun bulkConfig(bulkConfig: JsonField) = apply { - this.bulkConfig = bulkConfig - } - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) /** @@ -14147,6 +14755,34 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + fun compositePriceFilters(compositePriceFilters: List?) = + compositePriceFilters(JsonField.ofNullable(compositePriceFilters)) + + /** + * Sets [Builder.compositePriceFilters] to an arbitrary JSON value. + * + * You should usually call [Builder.compositePriceFilters] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun compositePriceFilters( + compositePriceFilters: JsonField> + ) = apply { + this.compositePriceFilters = compositePriceFilters.map { it.toMutableList() } + } + + /** + * Adds a single [TransformPriceFilter] to [compositePriceFilters]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addCompositePriceFilter(compositePriceFilter: TransformPriceFilter) = apply { + compositePriceFilters = + (compositePriceFilters ?: JsonField.of(mutableListOf())).also { + checkKnown("compositePriceFilters", it).add(compositePriceFilter) + } + } + fun conversionRate(conversionRate: Double?) = conversionRate(JsonField.ofNullable(conversionRate)) @@ -14388,6 +15024,20 @@ private constructor( this.fixedPriceQuantity = fixedPriceQuantity } + fun groupedTieredConfig(groupedTieredConfig: GroupedTieredConfig) = + groupedTieredConfig(JsonField.of(groupedTieredConfig)) + + /** + * Sets [Builder.groupedTieredConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.groupedTieredConfig] with a well-typed + * [GroupedTieredConfig] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun groupedTieredConfig(groupedTieredConfig: JsonField) = apply { + this.groupedTieredConfig = groupedTieredConfig + } + fun invoicingCycleConfiguration( invoicingCycleConfiguration: BillingCycleConfiguration? ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) @@ -14494,7 +15144,7 @@ private constructor( * It is usually unnecessary to call this method because the field defaults to the * following: * ```kotlin - * JsonValue.from("bulk") + * JsonValue.from("grouped_tiered") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -14598,7 +15248,7 @@ private constructor( } /** - * Returns an immutable instance of [Bulk]. + * Returns an immutable instance of [GroupedTiered]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -14607,8 +15257,8 @@ private constructor( * .id() * .billableMetric() * .billingCycleConfiguration() - * .bulkConfig() * .cadence() + * .compositePriceFilters() * .conversionRate() * .conversionRateConfig() * .createdAt() @@ -14617,6 +15267,7 @@ private constructor( * .discount() * .externalPriceId() * .fixedPriceQuantity() + * .groupedTieredConfig() * .invoicingCycleConfiguration() * .item() * .maximum() @@ -14632,13 +15283,15 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): Bulk = - Bulk( + fun build(): GroupedTiered = + GroupedTiered( checkRequired("id", id), checkRequired("billableMetric", billableMetric), checkRequired("billingCycleConfiguration", billingCycleConfiguration), - checkRequired("bulkConfig", bulkConfig), checkRequired("cadence", cadence), + checkRequired("compositePriceFilters", compositePriceFilters).map { + it.toImmutable() + }, checkRequired("conversionRate", conversionRate), checkRequired("conversionRateConfig", conversionRateConfig), checkRequired("createdAt", createdAt), @@ -14647,6 +15300,7 @@ private constructor( checkRequired("discount", discount), checkRequired("externalPriceId", externalPriceId), checkRequired("fixedPriceQuantity", fixedPriceQuantity), + checkRequired("groupedTieredConfig", groupedTieredConfig), checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), checkRequired("item", item), checkRequired("maximum", maximum), @@ -14666,7 +15320,7 @@ private constructor( private var validated: Boolean = false - fun validate(): Bulk = apply { + fun validate(): GroupedTiered = apply { if (validated) { return@apply } @@ -14674,8 +15328,8 @@ private constructor( id() billableMetric()?.validate() billingCycleConfiguration().validate() - bulkConfig().validate() cadence().validate() + compositePriceFilters()?.forEach { it.validate() } conversionRate() conversionRateConfig()?.validate() createdAt() @@ -14684,6 +15338,7 @@ private constructor( discount()?.validate() externalPriceId() fixedPriceQuantity() + groupedTieredConfig().validate() invoicingCycleConfiguration()?.validate() item().validate() maximum()?.validate() @@ -14692,7 +15347,7 @@ private constructor( minimum()?.validate() minimumAmount() _modelType().let { - if (it != JsonValue.from("bulk")) { + if (it != JsonValue.from("grouped_tiered")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } @@ -14722,8 +15377,8 @@ private constructor( (if (id.asKnown() == null) 0 else 1) + (billableMetric.asKnown()?.validity() ?: 0) + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + - (bulkConfig.asKnown()?.validity() ?: 0) + (cadence.asKnown()?.validity() ?: 0) + + (compositePriceFilters.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + (if (conversionRate.asKnown() == null) 0 else 1) + (conversionRateConfig.asKnown()?.validity() ?: 0) + (if (createdAt.asKnown() == null) 0 else 1) + @@ -14732,6 +15387,7 @@ private constructor( (discount.asKnown()?.validity() ?: 0) + (if (externalPriceId.asKnown() == null) 0 else 1) + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (groupedTieredConfig.asKnown()?.validity() ?: 0) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + (item.asKnown()?.validity() ?: 0) + (maximum.asKnown()?.validity() ?: 0) + @@ -14739,7 +15395,7 @@ private constructor( (metadata.asKnown()?.validity() ?: 0) + (minimum.asKnown()?.validity() ?: 0) + (if (minimumAmount.asKnown() == null) 0 else 1) + - modelType.let { if (it == JsonValue.from("bulk")) 1 else 0 } + + modelType.let { if (it == JsonValue.from("grouped_tiered")) 1 else 0 } + (if (name.asKnown() == null) 0 else 1) + (if (planPhaseOrder.asKnown() == null) 0 else 1) + (priceType.asKnown()?.validity() ?: 0) + @@ -14898,6 +15554,111 @@ private constructor( override fun toString() = value.toString() } + class GroupedTieredConfig + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [GroupedTieredConfig]. + */ + fun builder() = Builder() + } + + /** A builder for [GroupedTieredConfig]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(groupedTieredConfig: GroupedTieredConfig) = apply { + additionalProperties = groupedTieredConfig.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [GroupedTieredConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): GroupedTieredConfig = + GroupedTieredConfig(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): GroupedTieredConfig = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedTieredConfig && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedTieredConfig{additionalProperties=$additionalProperties}" + } + /** * User specified key-value pairs for the resource. If not present, this defaults to an * empty dictionary. Individual keys can be removed by setting the value to `null`, and the @@ -15137,12 +15898,12 @@ private constructor( return true } - return other is Bulk && + return other is GroupedTiered && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && - bulkConfig == other.bulkConfig && cadence == other.cadence && + compositePriceFilters == other.compositePriceFilters && conversionRate == other.conversionRate && conversionRateConfig == other.conversionRateConfig && createdAt == other.createdAt && @@ -15151,6 +15912,7 @@ private constructor( discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && + groupedTieredConfig == other.groupedTieredConfig && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maximum == other.maximum && @@ -15172,8 +15934,8 @@ private constructor( id, billableMetric, billingCycleConfiguration, - bulkConfig, cadence, + compositePriceFilters, conversionRate, conversionRateConfig, createdAt, @@ -15182,6 +15944,7 @@ private constructor( discount, externalPriceId, fixedPriceQuantity, + groupedTieredConfig, invoicingCycleConfiguration, item, maximum, @@ -15202,15 +15965,16 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Bulk{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, bulkConfig=$bulkConfig, cadence=$cadence, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "GroupedTiered{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, groupedTieredConfig=$groupedTieredConfig, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" } - class ThresholdTotalAmount + class TieredWithMinimum private constructor( private val id: JsonField, private val billableMetric: JsonField, private val billingCycleConfiguration: JsonField, private val cadence: JsonField, + private val compositePriceFilters: JsonField>, private val conversionRate: JsonField, private val conversionRateConfig: JsonField, private val createdAt: JsonField, @@ -15231,7 +15995,7 @@ private constructor( private val planPhaseOrder: JsonField, private val priceType: JsonField, private val replacesPriceId: JsonField, - private val thresholdTotalAmountConfig: JsonField, + private val tieredWithMinimumConfig: JsonField, private val dimensionalPriceConfiguration: JsonField, private val additionalProperties: MutableMap, ) { @@ -15246,6 +16010,9 @@ private constructor( @ExcludeMissing billingCycleConfiguration: JsonField = JsonMissing.of(), @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), + @JsonProperty("composite_price_filters") + @ExcludeMissing + compositePriceFilters: JsonField> = JsonMissing.of(), @JsonProperty("conversion_rate") @ExcludeMissing conversionRate: JsonField = JsonMissing.of(), @@ -15296,9 +16063,9 @@ private constructor( @JsonProperty("replaces_price_id") @ExcludeMissing replacesPriceId: JsonField = JsonMissing.of(), - @JsonProperty("threshold_total_amount_config") + @JsonProperty("tiered_with_minimum_config") @ExcludeMissing - thresholdTotalAmountConfig: JsonField = JsonMissing.of(), + tieredWithMinimumConfig: JsonField = JsonMissing.of(), @JsonProperty("dimensional_price_configuration") @ExcludeMissing dimensionalPriceConfiguration: JsonField = @@ -15308,6 +16075,7 @@ private constructor( billableMetric, billingCycleConfiguration, cadence, + compositePriceFilters, conversionRate, conversionRateConfig, createdAt, @@ -15328,7 +16096,7 @@ private constructor( planPhaseOrder, priceType, replacesPriceId, - thresholdTotalAmountConfig, + tieredWithMinimumConfig, dimensionalPriceConfiguration, mutableMapOf(), ) @@ -15358,6 +16126,13 @@ private constructor( */ fun cadence(): Cadence = cadence.getRequired("cadence") + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun compositePriceFilters(): List? = + compositePriceFilters.getNullable("composite_price_filters") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -15459,7 +16234,7 @@ private constructor( /** * Expected to always return the following: * ```kotlin - * JsonValue.from("threshold_total_amount") + * JsonValue.from("tiered_with_minimum") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -15498,8 +16273,8 @@ private constructor( * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ - fun thresholdTotalAmountConfig(): ThresholdTotalAmountConfig = - thresholdTotalAmountConfig.getRequired("threshold_total_amount_config") + fun tieredWithMinimumConfig(): TieredWithMinimumConfig = + tieredWithMinimumConfig.getRequired("tiered_with_minimum_config") /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the @@ -15543,6 +16318,16 @@ private constructor( */ @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence + /** + * Returns the raw JSON value of [compositePriceFilters]. + * + * Unlike [compositePriceFilters], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("composite_price_filters") + @ExcludeMissing + fun _compositePriceFilters(): JsonField> = compositePriceFilters + /** * Returns the raw JSON value of [conversionRate]. * @@ -15723,15 +16508,14 @@ private constructor( fun _replacesPriceId(): JsonField = replacesPriceId /** - * Returns the raw JSON value of [thresholdTotalAmountConfig]. + * Returns the raw JSON value of [tieredWithMinimumConfig]. * - * Unlike [thresholdTotalAmountConfig], this method doesn't throw if the JSON field has an + * Unlike [tieredWithMinimumConfig], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("threshold_total_amount_config") + @JsonProperty("tiered_with_minimum_config") @ExcludeMissing - fun _thresholdTotalAmountConfig(): JsonField = - thresholdTotalAmountConfig + fun _tieredWithMinimumConfig(): JsonField = tieredWithMinimumConfig /** * Returns the raw JSON value of [dimensionalPriceConfiguration]. @@ -15759,7 +16543,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [ThresholdTotalAmount]. + * Returns a mutable builder for constructing an instance of [TieredWithMinimum]. * * The following fields are required: * ```kotlin @@ -15767,6 +16551,7 @@ private constructor( * .billableMetric() * .billingCycleConfiguration() * .cadence() + * .compositePriceFilters() * .conversionRate() * .conversionRateConfig() * .createdAt() @@ -15786,19 +16571,20 @@ private constructor( * .planPhaseOrder() * .priceType() * .replacesPriceId() - * .thresholdTotalAmountConfig() + * .tieredWithMinimumConfig() * ``` */ fun builder() = Builder() } - /** A builder for [ThresholdTotalAmount]. */ + /** A builder for [TieredWithMinimum]. */ class Builder internal constructor() { private var id: JsonField? = null private var billableMetric: JsonField? = null private var billingCycleConfiguration: JsonField? = null private var cadence: JsonField? = null + private var compositePriceFilters: JsonField>? = null private var conversionRate: JsonField? = null private var conversionRateConfig: JsonField? = null private var createdAt: JsonField? = null @@ -15814,44 +16600,46 @@ private constructor( private var metadata: JsonField? = null private var minimum: JsonField? = null private var minimumAmount: JsonField? = null - private var modelType: JsonValue = JsonValue.from("threshold_total_amount") + private var modelType: JsonValue = JsonValue.from("tiered_with_minimum") private var name: JsonField? = null private var planPhaseOrder: JsonField? = null private var priceType: JsonField? = null private var replacesPriceId: JsonField? = null - private var thresholdTotalAmountConfig: JsonField? = null + private var tieredWithMinimumConfig: JsonField? = null private var dimensionalPriceConfiguration: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(thresholdTotalAmount: ThresholdTotalAmount) = apply { - id = thresholdTotalAmount.id - billableMetric = thresholdTotalAmount.billableMetric - billingCycleConfiguration = thresholdTotalAmount.billingCycleConfiguration - cadence = thresholdTotalAmount.cadence - conversionRate = thresholdTotalAmount.conversionRate - conversionRateConfig = thresholdTotalAmount.conversionRateConfig - createdAt = thresholdTotalAmount.createdAt - creditAllocation = thresholdTotalAmount.creditAllocation - currency = thresholdTotalAmount.currency - discount = thresholdTotalAmount.discount - externalPriceId = thresholdTotalAmount.externalPriceId - fixedPriceQuantity = thresholdTotalAmount.fixedPriceQuantity - invoicingCycleConfiguration = thresholdTotalAmount.invoicingCycleConfiguration - item = thresholdTotalAmount.item - maximum = thresholdTotalAmount.maximum - maximumAmount = thresholdTotalAmount.maximumAmount - metadata = thresholdTotalAmount.metadata - minimum = thresholdTotalAmount.minimum - minimumAmount = thresholdTotalAmount.minimumAmount - modelType = thresholdTotalAmount.modelType - name = thresholdTotalAmount.name - planPhaseOrder = thresholdTotalAmount.planPhaseOrder - priceType = thresholdTotalAmount.priceType - replacesPriceId = thresholdTotalAmount.replacesPriceId - thresholdTotalAmountConfig = thresholdTotalAmount.thresholdTotalAmountConfig - dimensionalPriceConfiguration = thresholdTotalAmount.dimensionalPriceConfiguration - additionalProperties = thresholdTotalAmount.additionalProperties.toMutableMap() + internal fun from(tieredWithMinimum: TieredWithMinimum) = apply { + id = tieredWithMinimum.id + billableMetric = tieredWithMinimum.billableMetric + billingCycleConfiguration = tieredWithMinimum.billingCycleConfiguration + cadence = tieredWithMinimum.cadence + compositePriceFilters = + tieredWithMinimum.compositePriceFilters.map { it.toMutableList() } + conversionRate = tieredWithMinimum.conversionRate + conversionRateConfig = tieredWithMinimum.conversionRateConfig + createdAt = tieredWithMinimum.createdAt + creditAllocation = tieredWithMinimum.creditAllocation + currency = tieredWithMinimum.currency + discount = tieredWithMinimum.discount + externalPriceId = tieredWithMinimum.externalPriceId + fixedPriceQuantity = tieredWithMinimum.fixedPriceQuantity + invoicingCycleConfiguration = tieredWithMinimum.invoicingCycleConfiguration + item = tieredWithMinimum.item + maximum = tieredWithMinimum.maximum + maximumAmount = tieredWithMinimum.maximumAmount + metadata = tieredWithMinimum.metadata + minimum = tieredWithMinimum.minimum + minimumAmount = tieredWithMinimum.minimumAmount + modelType = tieredWithMinimum.modelType + name = tieredWithMinimum.name + planPhaseOrder = tieredWithMinimum.planPhaseOrder + priceType = tieredWithMinimum.priceType + replacesPriceId = tieredWithMinimum.replacesPriceId + tieredWithMinimumConfig = tieredWithMinimum.tieredWithMinimumConfig + dimensionalPriceConfiguration = tieredWithMinimum.dimensionalPriceConfiguration + additionalProperties = tieredWithMinimum.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) @@ -15904,6 +16692,34 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + fun compositePriceFilters(compositePriceFilters: List?) = + compositePriceFilters(JsonField.ofNullable(compositePriceFilters)) + + /** + * Sets [Builder.compositePriceFilters] to an arbitrary JSON value. + * + * You should usually call [Builder.compositePriceFilters] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun compositePriceFilters( + compositePriceFilters: JsonField> + ) = apply { + this.compositePriceFilters = compositePriceFilters.map { it.toMutableList() } + } + + /** + * Adds a single [TransformPriceFilter] to [compositePriceFilters]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addCompositePriceFilter(compositePriceFilter: TransformPriceFilter) = apply { + compositePriceFilters = + (compositePriceFilters ?: JsonField.of(mutableListOf())).also { + checkKnown("compositePriceFilters", it).add(compositePriceFilter) + } + } + fun conversionRate(conversionRate: Double?) = conversionRate(JsonField.ofNullable(conversionRate)) @@ -16251,7 +17067,7 @@ private constructor( * It is usually unnecessary to call this method because the field defaults to the * following: * ```kotlin - * JsonValue.from("threshold_total_amount") + * JsonValue.from("tiered_with_minimum") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -16320,19 +17136,19 @@ private constructor( this.replacesPriceId = replacesPriceId } - fun thresholdTotalAmountConfig(thresholdTotalAmountConfig: ThresholdTotalAmountConfig) = - thresholdTotalAmountConfig(JsonField.of(thresholdTotalAmountConfig)) + fun tieredWithMinimumConfig(tieredWithMinimumConfig: TieredWithMinimumConfig) = + tieredWithMinimumConfig(JsonField.of(tieredWithMinimumConfig)) /** - * Sets [Builder.thresholdTotalAmountConfig] to an arbitrary JSON value. + * Sets [Builder.tieredWithMinimumConfig] to an arbitrary JSON value. * - * You should usually call [Builder.thresholdTotalAmountConfig] with a well-typed - * [ThresholdTotalAmountConfig] value instead. This method is primarily for setting the + * You should usually call [Builder.tieredWithMinimumConfig] with a well-typed + * [TieredWithMinimumConfig] value instead. This method is primarily for setting the * field to an undocumented or not yet supported value. */ - fun thresholdTotalAmountConfig( - thresholdTotalAmountConfig: JsonField - ) = apply { this.thresholdTotalAmountConfig = thresholdTotalAmountConfig } + fun tieredWithMinimumConfig( + tieredWithMinimumConfig: JsonField + ) = apply { this.tieredWithMinimumConfig = tieredWithMinimumConfig } fun dimensionalPriceConfiguration( dimensionalPriceConfiguration: DimensionalPriceConfiguration? @@ -16369,7 +17185,7 @@ private constructor( } /** - * Returns an immutable instance of [ThresholdTotalAmount]. + * Returns an immutable instance of [TieredWithMinimum]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -16379,6 +17195,7 @@ private constructor( * .billableMetric() * .billingCycleConfiguration() * .cadence() + * .compositePriceFilters() * .conversionRate() * .conversionRateConfig() * .createdAt() @@ -16398,17 +17215,20 @@ private constructor( * .planPhaseOrder() * .priceType() * .replacesPriceId() - * .thresholdTotalAmountConfig() + * .tieredWithMinimumConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): ThresholdTotalAmount = - ThresholdTotalAmount( + fun build(): TieredWithMinimum = + TieredWithMinimum( checkRequired("id", id), checkRequired("billableMetric", billableMetric), checkRequired("billingCycleConfiguration", billingCycleConfiguration), checkRequired("cadence", cadence), + checkRequired("compositePriceFilters", compositePriceFilters).map { + it.toImmutable() + }, checkRequired("conversionRate", conversionRate), checkRequired("conversionRateConfig", conversionRateConfig), checkRequired("createdAt", createdAt), @@ -16429,7 +17249,7 @@ private constructor( checkRequired("planPhaseOrder", planPhaseOrder), checkRequired("priceType", priceType), checkRequired("replacesPriceId", replacesPriceId), - checkRequired("thresholdTotalAmountConfig", thresholdTotalAmountConfig), + checkRequired("tieredWithMinimumConfig", tieredWithMinimumConfig), dimensionalPriceConfiguration, additionalProperties.toMutableMap(), ) @@ -16437,7 +17257,7 @@ private constructor( private var validated: Boolean = false - fun validate(): ThresholdTotalAmount = apply { + fun validate(): TieredWithMinimum = apply { if (validated) { return@apply } @@ -16446,6 +17266,7 @@ private constructor( billableMetric()?.validate() billingCycleConfiguration().validate() cadence().validate() + compositePriceFilters()?.forEach { it.validate() } conversionRate() conversionRateConfig()?.validate() createdAt() @@ -16462,7 +17283,7 @@ private constructor( minimum()?.validate() minimumAmount() _modelType().let { - if (it != JsonValue.from("threshold_total_amount")) { + if (it != JsonValue.from("tiered_with_minimum")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } @@ -16470,7 +17291,7 @@ private constructor( planPhaseOrder() priceType().validate() replacesPriceId() - thresholdTotalAmountConfig().validate() + tieredWithMinimumConfig().validate() dimensionalPriceConfiguration()?.validate() validated = true } @@ -16494,6 +17315,7 @@ private constructor( (billableMetric.asKnown()?.validity() ?: 0) + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + (cadence.asKnown()?.validity() ?: 0) + + (compositePriceFilters.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + (if (conversionRate.asKnown() == null) 0 else 1) + (conversionRateConfig.asKnown()?.validity() ?: 0) + (if (createdAt.asKnown() == null) 0 else 1) + @@ -16509,12 +17331,12 @@ private constructor( (metadata.asKnown()?.validity() ?: 0) + (minimum.asKnown()?.validity() ?: 0) + (if (minimumAmount.asKnown() == null) 0 else 1) + - modelType.let { if (it == JsonValue.from("threshold_total_amount")) 1 else 0 } + + modelType.let { if (it == JsonValue.from("tiered_with_minimum")) 1 else 0 } + (if (name.asKnown() == null) 0 else 1) + (if (planPhaseOrder.asKnown() == null) 0 else 1) + (priceType.asKnown()?.validity() ?: 0) + (if (replacesPriceId.asKnown() == null) 0 else 1) + - (thresholdTotalAmountConfig.asKnown()?.validity() ?: 0) + + (tieredWithMinimumConfig.asKnown()?.validity() ?: 0) + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) class Cadence @JsonCreator private constructor(private val value: JsonField) : @@ -16903,7 +17725,7 @@ private constructor( override fun toString() = value.toString() } - class ThresholdTotalAmountConfig + class TieredWithMinimumConfig @JsonCreator private constructor( @com.fasterxml.jackson.annotation.JsonValue @@ -16920,19 +17742,19 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [ThresholdTotalAmountConfig]. + * [TieredWithMinimumConfig]. */ fun builder() = Builder() } - /** A builder for [ThresholdTotalAmountConfig]. */ + /** A builder for [TieredWithMinimumConfig]. */ class Builder internal constructor() { private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(thresholdTotalAmountConfig: ThresholdTotalAmountConfig) = apply { + internal fun from(tieredWithMinimumConfig: TieredWithMinimumConfig) = apply { additionalProperties = - thresholdTotalAmountConfig.additionalProperties.toMutableMap() + tieredWithMinimumConfig.additionalProperties.toMutableMap() } fun additionalProperties(additionalProperties: Map) = apply { @@ -16958,17 +17780,17 @@ private constructor( } /** - * Returns an immutable instance of [ThresholdTotalAmountConfig]. + * Returns an immutable instance of [TieredWithMinimumConfig]. * * Further updates to this [Builder] will not mutate the returned instance. */ - fun build(): ThresholdTotalAmountConfig = - ThresholdTotalAmountConfig(additionalProperties.toImmutable()) + fun build(): TieredWithMinimumConfig = + TieredWithMinimumConfig(additionalProperties.toImmutable()) } private var validated: Boolean = false - fun validate(): ThresholdTotalAmountConfig = apply { + fun validate(): TieredWithMinimumConfig = apply { if (validated) { return@apply } @@ -16998,7 +17820,7 @@ private constructor( return true } - return other is ThresholdTotalAmountConfig && + return other is TieredWithMinimumConfig && additionalProperties == other.additionalProperties } @@ -17007,7 +17829,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "ThresholdTotalAmountConfig{additionalProperties=$additionalProperties}" + "TieredWithMinimumConfig{additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { @@ -17015,11 +17837,12 @@ private constructor( return true } - return other is ThresholdTotalAmount && + return other is TieredWithMinimum && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && + compositePriceFilters == other.compositePriceFilters && conversionRate == other.conversionRate && conversionRateConfig == other.conversionRateConfig && createdAt == other.createdAt && @@ -17040,7 +17863,7 @@ private constructor( planPhaseOrder == other.planPhaseOrder && priceType == other.priceType && replacesPriceId == other.replacesPriceId && - thresholdTotalAmountConfig == other.thresholdTotalAmountConfig && + tieredWithMinimumConfig == other.tieredWithMinimumConfig && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties } @@ -17051,6 +17874,7 @@ private constructor( billableMetric, billingCycleConfiguration, cadence, + compositePriceFilters, conversionRate, conversionRateConfig, createdAt, @@ -17071,7 +17895,7 @@ private constructor( planPhaseOrder, priceType, replacesPriceId, - thresholdTotalAmountConfig, + tieredWithMinimumConfig, dimensionalPriceConfiguration, additionalProperties, ) @@ -17080,15 +17904,16 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "ThresholdTotalAmount{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, thresholdTotalAmountConfig=$thresholdTotalAmountConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "TieredWithMinimum{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, tieredWithMinimumConfig=$tieredWithMinimumConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" } - class TieredPackage + class TieredPackageWithMinimum private constructor( private val id: JsonField, private val billableMetric: JsonField, private val billingCycleConfiguration: JsonField, private val cadence: JsonField, + private val compositePriceFilters: JsonField>, private val conversionRate: JsonField, private val conversionRateConfig: JsonField, private val createdAt: JsonField, @@ -17109,7 +17934,7 @@ private constructor( private val planPhaseOrder: JsonField, private val priceType: JsonField, private val replacesPriceId: JsonField, - private val tieredPackageConfig: JsonField, + private val tieredPackageWithMinimumConfig: JsonField, private val dimensionalPriceConfiguration: JsonField, private val additionalProperties: MutableMap, ) { @@ -17124,6 +17949,9 @@ private constructor( @ExcludeMissing billingCycleConfiguration: JsonField = JsonMissing.of(), @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), + @JsonProperty("composite_price_filters") + @ExcludeMissing + compositePriceFilters: JsonField> = JsonMissing.of(), @JsonProperty("conversion_rate") @ExcludeMissing conversionRate: JsonField = JsonMissing.of(), @@ -17174,9 +18002,10 @@ private constructor( @JsonProperty("replaces_price_id") @ExcludeMissing replacesPriceId: JsonField = JsonMissing.of(), - @JsonProperty("tiered_package_config") + @JsonProperty("tiered_package_with_minimum_config") @ExcludeMissing - tieredPackageConfig: JsonField = JsonMissing.of(), + tieredPackageWithMinimumConfig: JsonField = + JsonMissing.of(), @JsonProperty("dimensional_price_configuration") @ExcludeMissing dimensionalPriceConfiguration: JsonField = @@ -17186,6 +18015,7 @@ private constructor( billableMetric, billingCycleConfiguration, cadence, + compositePriceFilters, conversionRate, conversionRateConfig, createdAt, @@ -17206,7 +18036,7 @@ private constructor( planPhaseOrder, priceType, replacesPriceId, - tieredPackageConfig, + tieredPackageWithMinimumConfig, dimensionalPriceConfiguration, mutableMapOf(), ) @@ -17236,6 +18066,13 @@ private constructor( */ fun cadence(): Cadence = cadence.getRequired("cadence") + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun compositePriceFilters(): List? = + compositePriceFilters.getNullable("composite_price_filters") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -17337,7 +18174,7 @@ private constructor( /** * Expected to always return the following: * ```kotlin - * JsonValue.from("tiered_package") + * JsonValue.from("tiered_package_with_minimum") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -17376,8 +18213,8 @@ private constructor( * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ - fun tieredPackageConfig(): TieredPackageConfig = - tieredPackageConfig.getRequired("tiered_package_config") + fun tieredPackageWithMinimumConfig(): TieredPackageWithMinimumConfig = + tieredPackageWithMinimumConfig.getRequired("tiered_package_with_minimum_config") /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the @@ -17421,6 +18258,16 @@ private constructor( */ @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence + /** + * Returns the raw JSON value of [compositePriceFilters]. + * + * Unlike [compositePriceFilters], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("composite_price_filters") + @ExcludeMissing + fun _compositePriceFilters(): JsonField> = compositePriceFilters + /** * Returns the raw JSON value of [conversionRate]. * @@ -17601,14 +18448,15 @@ private constructor( fun _replacesPriceId(): JsonField = replacesPriceId /** - * Returns the raw JSON value of [tieredPackageConfig]. + * Returns the raw JSON value of [tieredPackageWithMinimumConfig]. * - * Unlike [tieredPackageConfig], this method doesn't throw if the JSON field has an - * unexpected type. + * Unlike [tieredPackageWithMinimumConfig], this method doesn't throw if the JSON field has + * an unexpected type. */ - @JsonProperty("tiered_package_config") + @JsonProperty("tiered_package_with_minimum_config") @ExcludeMissing - fun _tieredPackageConfig(): JsonField = tieredPackageConfig + fun _tieredPackageWithMinimumConfig(): JsonField = + tieredPackageWithMinimumConfig /** * Returns the raw JSON value of [dimensionalPriceConfiguration]. @@ -17636,7 +18484,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [TieredPackage]. + * Returns a mutable builder for constructing an instance of [TieredPackageWithMinimum]. * * The following fields are required: * ```kotlin @@ -17644,6 +18492,7 @@ private constructor( * .billableMetric() * .billingCycleConfiguration() * .cadence() + * .compositePriceFilters() * .conversionRate() * .conversionRateConfig() * .createdAt() @@ -17663,19 +18512,20 @@ private constructor( * .planPhaseOrder() * .priceType() * .replacesPriceId() - * .tieredPackageConfig() + * .tieredPackageWithMinimumConfig() * ``` */ fun builder() = Builder() } - /** A builder for [TieredPackage]. */ + /** A builder for [TieredPackageWithMinimum]. */ class Builder internal constructor() { private var id: JsonField? = null private var billableMetric: JsonField? = null private var billingCycleConfiguration: JsonField? = null private var cadence: JsonField? = null + private var compositePriceFilters: JsonField>? = null private var conversionRate: JsonField? = null private var conversionRateConfig: JsonField? = null private var createdAt: JsonField? = null @@ -17691,44 +18541,49 @@ private constructor( private var metadata: JsonField? = null private var minimum: JsonField? = null private var minimumAmount: JsonField? = null - private var modelType: JsonValue = JsonValue.from("tiered_package") + private var modelType: JsonValue = JsonValue.from("tiered_package_with_minimum") private var name: JsonField? = null private var planPhaseOrder: JsonField? = null private var priceType: JsonField? = null private var replacesPriceId: JsonField? = null - private var tieredPackageConfig: JsonField? = null + private var tieredPackageWithMinimumConfig: JsonField? = + null private var dimensionalPriceConfiguration: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(tieredPackage: TieredPackage) = apply { - id = tieredPackage.id - billableMetric = tieredPackage.billableMetric - billingCycleConfiguration = tieredPackage.billingCycleConfiguration - cadence = tieredPackage.cadence - conversionRate = tieredPackage.conversionRate - conversionRateConfig = tieredPackage.conversionRateConfig - createdAt = tieredPackage.createdAt - creditAllocation = tieredPackage.creditAllocation - currency = tieredPackage.currency - discount = tieredPackage.discount - externalPriceId = tieredPackage.externalPriceId - fixedPriceQuantity = tieredPackage.fixedPriceQuantity - invoicingCycleConfiguration = tieredPackage.invoicingCycleConfiguration - item = tieredPackage.item - maximum = tieredPackage.maximum - maximumAmount = tieredPackage.maximumAmount - metadata = tieredPackage.metadata - minimum = tieredPackage.minimum - minimumAmount = tieredPackage.minimumAmount - modelType = tieredPackage.modelType - name = tieredPackage.name - planPhaseOrder = tieredPackage.planPhaseOrder - priceType = tieredPackage.priceType - replacesPriceId = tieredPackage.replacesPriceId - tieredPackageConfig = tieredPackage.tieredPackageConfig - dimensionalPriceConfiguration = tieredPackage.dimensionalPriceConfiguration - additionalProperties = tieredPackage.additionalProperties.toMutableMap() + internal fun from(tieredPackageWithMinimum: TieredPackageWithMinimum) = apply { + id = tieredPackageWithMinimum.id + billableMetric = tieredPackageWithMinimum.billableMetric + billingCycleConfiguration = tieredPackageWithMinimum.billingCycleConfiguration + cadence = tieredPackageWithMinimum.cadence + compositePriceFilters = + tieredPackageWithMinimum.compositePriceFilters.map { it.toMutableList() } + conversionRate = tieredPackageWithMinimum.conversionRate + conversionRateConfig = tieredPackageWithMinimum.conversionRateConfig + createdAt = tieredPackageWithMinimum.createdAt + creditAllocation = tieredPackageWithMinimum.creditAllocation + currency = tieredPackageWithMinimum.currency + discount = tieredPackageWithMinimum.discount + externalPriceId = tieredPackageWithMinimum.externalPriceId + fixedPriceQuantity = tieredPackageWithMinimum.fixedPriceQuantity + invoicingCycleConfiguration = tieredPackageWithMinimum.invoicingCycleConfiguration + item = tieredPackageWithMinimum.item + maximum = tieredPackageWithMinimum.maximum + maximumAmount = tieredPackageWithMinimum.maximumAmount + metadata = tieredPackageWithMinimum.metadata + minimum = tieredPackageWithMinimum.minimum + minimumAmount = tieredPackageWithMinimum.minimumAmount + modelType = tieredPackageWithMinimum.modelType + name = tieredPackageWithMinimum.name + planPhaseOrder = tieredPackageWithMinimum.planPhaseOrder + priceType = tieredPackageWithMinimum.priceType + replacesPriceId = tieredPackageWithMinimum.replacesPriceId + tieredPackageWithMinimumConfig = + tieredPackageWithMinimum.tieredPackageWithMinimumConfig + dimensionalPriceConfiguration = + tieredPackageWithMinimum.dimensionalPriceConfiguration + additionalProperties = tieredPackageWithMinimum.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) @@ -17781,6 +18636,34 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + fun compositePriceFilters(compositePriceFilters: List?) = + compositePriceFilters(JsonField.ofNullable(compositePriceFilters)) + + /** + * Sets [Builder.compositePriceFilters] to an arbitrary JSON value. + * + * You should usually call [Builder.compositePriceFilters] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun compositePriceFilters( + compositePriceFilters: JsonField> + ) = apply { + this.compositePriceFilters = compositePriceFilters.map { it.toMutableList() } + } + + /** + * Adds a single [TransformPriceFilter] to [compositePriceFilters]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addCompositePriceFilter(compositePriceFilter: TransformPriceFilter) = apply { + compositePriceFilters = + (compositePriceFilters ?: JsonField.of(mutableListOf())).also { + checkKnown("compositePriceFilters", it).add(compositePriceFilter) + } + } + fun conversionRate(conversionRate: Double?) = conversionRate(JsonField.ofNullable(conversionRate)) @@ -18128,7 +19011,7 @@ private constructor( * It is usually unnecessary to call this method because the field defaults to the * following: * ```kotlin - * JsonValue.from("tiered_package") + * JsonValue.from("tiered_package_with_minimum") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -18197,19 +19080,20 @@ private constructor( this.replacesPriceId = replacesPriceId } - fun tieredPackageConfig(tieredPackageConfig: TieredPackageConfig) = - tieredPackageConfig(JsonField.of(tieredPackageConfig)) + fun tieredPackageWithMinimumConfig( + tieredPackageWithMinimumConfig: TieredPackageWithMinimumConfig + ) = tieredPackageWithMinimumConfig(JsonField.of(tieredPackageWithMinimumConfig)) /** - * Sets [Builder.tieredPackageConfig] to an arbitrary JSON value. + * Sets [Builder.tieredPackageWithMinimumConfig] to an arbitrary JSON value. * - * You should usually call [Builder.tieredPackageConfig] with a well-typed - * [TieredPackageConfig] value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. + * You should usually call [Builder.tieredPackageWithMinimumConfig] with a well-typed + * [TieredPackageWithMinimumConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. */ - fun tieredPackageConfig(tieredPackageConfig: JsonField) = apply { - this.tieredPackageConfig = tieredPackageConfig - } + fun tieredPackageWithMinimumConfig( + tieredPackageWithMinimumConfig: JsonField + ) = apply { this.tieredPackageWithMinimumConfig = tieredPackageWithMinimumConfig } fun dimensionalPriceConfiguration( dimensionalPriceConfiguration: DimensionalPriceConfiguration? @@ -18246,7 +19130,7 @@ private constructor( } /** - * Returns an immutable instance of [TieredPackage]. + * Returns an immutable instance of [TieredPackageWithMinimum]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -18256,6 +19140,7 @@ private constructor( * .billableMetric() * .billingCycleConfiguration() * .cadence() + * .compositePriceFilters() * .conversionRate() * .conversionRateConfig() * .createdAt() @@ -18275,17 +19160,20 @@ private constructor( * .planPhaseOrder() * .priceType() * .replacesPriceId() - * .tieredPackageConfig() + * .tieredPackageWithMinimumConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): TieredPackage = - TieredPackage( + fun build(): TieredPackageWithMinimum = + TieredPackageWithMinimum( checkRequired("id", id), checkRequired("billableMetric", billableMetric), checkRequired("billingCycleConfiguration", billingCycleConfiguration), checkRequired("cadence", cadence), + checkRequired("compositePriceFilters", compositePriceFilters).map { + it.toImmutable() + }, checkRequired("conversionRate", conversionRate), checkRequired("conversionRateConfig", conversionRateConfig), checkRequired("createdAt", createdAt), @@ -18306,7 +19194,7 @@ private constructor( checkRequired("planPhaseOrder", planPhaseOrder), checkRequired("priceType", priceType), checkRequired("replacesPriceId", replacesPriceId), - checkRequired("tieredPackageConfig", tieredPackageConfig), + checkRequired("tieredPackageWithMinimumConfig", tieredPackageWithMinimumConfig), dimensionalPriceConfiguration, additionalProperties.toMutableMap(), ) @@ -18314,7 +19202,7 @@ private constructor( private var validated: Boolean = false - fun validate(): TieredPackage = apply { + fun validate(): TieredPackageWithMinimum = apply { if (validated) { return@apply } @@ -18323,6 +19211,7 @@ private constructor( billableMetric()?.validate() billingCycleConfiguration().validate() cadence().validate() + compositePriceFilters()?.forEach { it.validate() } conversionRate() conversionRateConfig()?.validate() createdAt() @@ -18339,7 +19228,7 @@ private constructor( minimum()?.validate() minimumAmount() _modelType().let { - if (it != JsonValue.from("tiered_package")) { + if (it != JsonValue.from("tiered_package_with_minimum")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } @@ -18347,7 +19236,7 @@ private constructor( planPhaseOrder() priceType().validate() replacesPriceId() - tieredPackageConfig().validate() + tieredPackageWithMinimumConfig().validate() dimensionalPriceConfiguration()?.validate() validated = true } @@ -18371,6 +19260,7 @@ private constructor( (billableMetric.asKnown()?.validity() ?: 0) + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + (cadence.asKnown()?.validity() ?: 0) + + (compositePriceFilters.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + (if (conversionRate.asKnown() == null) 0 else 1) + (conversionRateConfig.asKnown()?.validity() ?: 0) + (if (createdAt.asKnown() == null) 0 else 1) + @@ -18386,12 +19276,14 @@ private constructor( (metadata.asKnown()?.validity() ?: 0) + (minimum.asKnown()?.validity() ?: 0) + (if (minimumAmount.asKnown() == null) 0 else 1) + - modelType.let { if (it == JsonValue.from("tiered_package")) 1 else 0 } + + modelType.let { + if (it == JsonValue.from("tiered_package_with_minimum")) 1 else 0 + } + (if (name.asKnown() == null) 0 else 1) + (if (planPhaseOrder.asKnown() == null) 0 else 1) + (priceType.asKnown()?.validity() ?: 0) + (if (replacesPriceId.asKnown() == null) 0 else 1) + - (tieredPackageConfig.asKnown()?.validity() ?: 0) + + (tieredPackageWithMinimumConfig.asKnown()?.validity() ?: 0) + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) class Cadence @JsonCreator private constructor(private val value: JsonField) : @@ -18780,7 +19672,7 @@ private constructor( override fun toString() = value.toString() } - class TieredPackageConfig + class TieredPackageWithMinimumConfig @JsonCreator private constructor( @com.fasterxml.jackson.annotation.JsonValue @@ -18796,19 +19688,22 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [TieredPackageConfig]. + * Returns a mutable builder for constructing an instance of + * [TieredPackageWithMinimumConfig]. */ fun builder() = Builder() } - /** A builder for [TieredPackageConfig]. */ + /** A builder for [TieredPackageWithMinimumConfig]. */ class Builder internal constructor() { private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(tieredPackageConfig: TieredPackageConfig) = apply { - additionalProperties = tieredPackageConfig.additionalProperties.toMutableMap() - } + internal fun from(tieredPackageWithMinimumConfig: TieredPackageWithMinimumConfig) = + apply { + additionalProperties = + tieredPackageWithMinimumConfig.additionalProperties.toMutableMap() + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -18833,17 +19728,17 @@ private constructor( } /** - * Returns an immutable instance of [TieredPackageConfig]. + * Returns an immutable instance of [TieredPackageWithMinimumConfig]. * * Further updates to this [Builder] will not mutate the returned instance. */ - fun build(): TieredPackageConfig = - TieredPackageConfig(additionalProperties.toImmutable()) + fun build(): TieredPackageWithMinimumConfig = + TieredPackageWithMinimumConfig(additionalProperties.toImmutable()) } private var validated: Boolean = false - fun validate(): TieredPackageConfig = apply { + fun validate(): TieredPackageWithMinimumConfig = apply { if (validated) { return@apply } @@ -18873,7 +19768,7 @@ private constructor( return true } - return other is TieredPackageConfig && + return other is TieredPackageWithMinimumConfig && additionalProperties == other.additionalProperties } @@ -18882,7 +19777,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "TieredPackageConfig{additionalProperties=$additionalProperties}" + "TieredPackageWithMinimumConfig{additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { @@ -18890,11 +19785,12 @@ private constructor( return true } - return other is TieredPackage && + return other is TieredPackageWithMinimum && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && + compositePriceFilters == other.compositePriceFilters && conversionRate == other.conversionRate && conversionRateConfig == other.conversionRateConfig && createdAt == other.createdAt && @@ -18915,7 +19811,7 @@ private constructor( planPhaseOrder == other.planPhaseOrder && priceType == other.priceType && replacesPriceId == other.replacesPriceId && - tieredPackageConfig == other.tieredPackageConfig && + tieredPackageWithMinimumConfig == other.tieredPackageWithMinimumConfig && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties } @@ -18926,6 +19822,7 @@ private constructor( billableMetric, billingCycleConfiguration, cadence, + compositePriceFilters, conversionRate, conversionRateConfig, createdAt, @@ -18946,7 +19843,7 @@ private constructor( planPhaseOrder, priceType, replacesPriceId, - tieredPackageConfig, + tieredPackageWithMinimumConfig, dimensionalPriceConfiguration, additionalProperties, ) @@ -18955,15 +19852,16 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "TieredPackage{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, tieredPackageConfig=$tieredPackageConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "TieredPackageWithMinimum{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, tieredPackageWithMinimumConfig=$tieredPackageWithMinimumConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" } - class GroupedTiered + class PackageWithAllocation private constructor( private val id: JsonField, private val billableMetric: JsonField, private val billingCycleConfiguration: JsonField, private val cadence: JsonField, + private val compositePriceFilters: JsonField>, private val conversionRate: JsonField, private val conversionRateConfig: JsonField, private val createdAt: JsonField, @@ -18972,7 +19870,6 @@ private constructor( private val discount: JsonField, private val externalPriceId: JsonField, private val fixedPriceQuantity: JsonField, - private val groupedTieredConfig: JsonField, private val invoicingCycleConfiguration: JsonField, private val item: JsonField, private val maximum: JsonField, @@ -18982,6 +19879,7 @@ private constructor( private val minimumAmount: JsonField, private val modelType: JsonValue, private val name: JsonField, + private val packageWithAllocationConfig: JsonField, private val planPhaseOrder: JsonField, private val priceType: JsonField, private val replacesPriceId: JsonField, @@ -18999,6 +19897,9 @@ private constructor( @ExcludeMissing billingCycleConfiguration: JsonField = JsonMissing.of(), @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), + @JsonProperty("composite_price_filters") + @ExcludeMissing + compositePriceFilters: JsonField> = JsonMissing.of(), @JsonProperty("conversion_rate") @ExcludeMissing conversionRate: JsonField = JsonMissing.of(), @@ -19023,9 +19924,6 @@ private constructor( @JsonProperty("fixed_price_quantity") @ExcludeMissing fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("grouped_tiered_config") - @ExcludeMissing - groupedTieredConfig: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), @@ -19043,6 +19941,9 @@ private constructor( minimumAmount: JsonField = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("package_with_allocation_config") + @ExcludeMissing + packageWithAllocationConfig: JsonField = JsonMissing.of(), @JsonProperty("plan_phase_order") @ExcludeMissing planPhaseOrder: JsonField = JsonMissing.of(), @@ -19061,6 +19962,7 @@ private constructor( billableMetric, billingCycleConfiguration, cadence, + compositePriceFilters, conversionRate, conversionRateConfig, createdAt, @@ -19069,7 +19971,6 @@ private constructor( discount, externalPriceId, fixedPriceQuantity, - groupedTieredConfig, invoicingCycleConfiguration, item, maximum, @@ -19079,6 +19980,7 @@ private constructor( minimumAmount, modelType, name, + packageWithAllocationConfig, planPhaseOrder, priceType, replacesPriceId, @@ -19111,6 +20013,13 @@ private constructor( */ fun cadence(): Cadence = cadence.getRequired("cadence") + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun compositePriceFilters(): List? = + compositePriceFilters.getNullable("composite_price_filters") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -19160,13 +20069,6 @@ private constructor( */ fun fixedPriceQuantity(): Double? = fixedPriceQuantity.getNullable("fixed_price_quantity") - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun groupedTieredConfig(): GroupedTieredConfig = - groupedTieredConfig.getRequired("grouped_tiered_config") - /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -19219,7 +20121,7 @@ private constructor( /** * Expected to always return the following: * ```kotlin - * JsonValue.from("grouped_tiered") + * JsonValue.from("package_with_allocation") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -19233,6 +20135,13 @@ private constructor( */ fun name(): String = name.getRequired("name") + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun packageWithAllocationConfig(): PackageWithAllocationConfig = + packageWithAllocationConfig.getRequired("package_with_allocation_config") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -19296,6 +20205,16 @@ private constructor( */ @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence + /** + * Returns the raw JSON value of [compositePriceFilters]. + * + * Unlike [compositePriceFilters], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("composite_price_filters") + @ExcludeMissing + fun _compositePriceFilters(): JsonField> = compositePriceFilters + /** * Returns the raw JSON value of [conversionRate]. * @@ -19372,16 +20291,6 @@ private constructor( @ExcludeMissing fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - /** - * Returns the raw JSON value of [groupedTieredConfig]. - * - * Unlike [groupedTieredConfig], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("grouped_tiered_config") - @ExcludeMissing - fun _groupedTieredConfig(): JsonField = groupedTieredConfig - /** * Returns the raw JSON value of [invoicingCycleConfiguration]. * @@ -19456,6 +20365,17 @@ private constructor( */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + /** + * Returns the raw JSON value of [packageWithAllocationConfig]. + * + * Unlike [packageWithAllocationConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("package_with_allocation_config") + @ExcludeMissing + fun _packageWithAllocationConfig(): JsonField = + packageWithAllocationConfig + /** * Returns the raw JSON value of [planPhaseOrder]. * @@ -19511,7 +20431,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [GroupedTiered]. + * Returns a mutable builder for constructing an instance of [PackageWithAllocation]. * * The following fields are required: * ```kotlin @@ -19519,6 +20439,7 @@ private constructor( * .billableMetric() * .billingCycleConfiguration() * .cadence() + * .compositePriceFilters() * .conversionRate() * .conversionRateConfig() * .createdAt() @@ -19527,7 +20448,6 @@ private constructor( * .discount() * .externalPriceId() * .fixedPriceQuantity() - * .groupedTieredConfig() * .invoicingCycleConfiguration() * .item() * .maximum() @@ -19536,6 +20456,7 @@ private constructor( * .minimum() * .minimumAmount() * .name() + * .packageWithAllocationConfig() * .planPhaseOrder() * .priceType() * .replacesPriceId() @@ -19544,13 +20465,14 @@ private constructor( fun builder() = Builder() } - /** A builder for [GroupedTiered]. */ + /** A builder for [PackageWithAllocation]. */ class Builder internal constructor() { private var id: JsonField? = null private var billableMetric: JsonField? = null private var billingCycleConfiguration: JsonField? = null private var cadence: JsonField? = null + private var compositePriceFilters: JsonField>? = null private var conversionRate: JsonField? = null private var conversionRateConfig: JsonField? = null private var createdAt: JsonField? = null @@ -19559,7 +20481,6 @@ private constructor( private var discount: JsonField? = null private var externalPriceId: JsonField? = null private var fixedPriceQuantity: JsonField? = null - private var groupedTieredConfig: JsonField? = null private var invoicingCycleConfiguration: JsonField? = null private var item: JsonField? = null private var maximum: JsonField? = null @@ -19567,8 +20488,9 @@ private constructor( private var metadata: JsonField? = null private var minimum: JsonField? = null private var minimumAmount: JsonField? = null - private var modelType: JsonValue = JsonValue.from("grouped_tiered") + private var modelType: JsonValue = JsonValue.from("package_with_allocation") private var name: JsonField? = null + private var packageWithAllocationConfig: JsonField? = null private var planPhaseOrder: JsonField? = null private var priceType: JsonField? = null private var replacesPriceId: JsonField? = null @@ -19576,34 +20498,36 @@ private constructor( JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(groupedTiered: GroupedTiered) = apply { - id = groupedTiered.id - billableMetric = groupedTiered.billableMetric - billingCycleConfiguration = groupedTiered.billingCycleConfiguration - cadence = groupedTiered.cadence - conversionRate = groupedTiered.conversionRate - conversionRateConfig = groupedTiered.conversionRateConfig - createdAt = groupedTiered.createdAt - creditAllocation = groupedTiered.creditAllocation - currency = groupedTiered.currency - discount = groupedTiered.discount - externalPriceId = groupedTiered.externalPriceId - fixedPriceQuantity = groupedTiered.fixedPriceQuantity - groupedTieredConfig = groupedTiered.groupedTieredConfig - invoicingCycleConfiguration = groupedTiered.invoicingCycleConfiguration - item = groupedTiered.item - maximum = groupedTiered.maximum - maximumAmount = groupedTiered.maximumAmount - metadata = groupedTiered.metadata - minimum = groupedTiered.minimum - minimumAmount = groupedTiered.minimumAmount - modelType = groupedTiered.modelType - name = groupedTiered.name - planPhaseOrder = groupedTiered.planPhaseOrder - priceType = groupedTiered.priceType - replacesPriceId = groupedTiered.replacesPriceId - dimensionalPriceConfiguration = groupedTiered.dimensionalPriceConfiguration - additionalProperties = groupedTiered.additionalProperties.toMutableMap() + internal fun from(packageWithAllocation: PackageWithAllocation) = apply { + id = packageWithAllocation.id + billableMetric = packageWithAllocation.billableMetric + billingCycleConfiguration = packageWithAllocation.billingCycleConfiguration + cadence = packageWithAllocation.cadence + compositePriceFilters = + packageWithAllocation.compositePriceFilters.map { it.toMutableList() } + conversionRate = packageWithAllocation.conversionRate + conversionRateConfig = packageWithAllocation.conversionRateConfig + createdAt = packageWithAllocation.createdAt + creditAllocation = packageWithAllocation.creditAllocation + currency = packageWithAllocation.currency + discount = packageWithAllocation.discount + externalPriceId = packageWithAllocation.externalPriceId + fixedPriceQuantity = packageWithAllocation.fixedPriceQuantity + invoicingCycleConfiguration = packageWithAllocation.invoicingCycleConfiguration + item = packageWithAllocation.item + maximum = packageWithAllocation.maximum + maximumAmount = packageWithAllocation.maximumAmount + metadata = packageWithAllocation.metadata + minimum = packageWithAllocation.minimum + minimumAmount = packageWithAllocation.minimumAmount + modelType = packageWithAllocation.modelType + name = packageWithAllocation.name + packageWithAllocationConfig = packageWithAllocation.packageWithAllocationConfig + planPhaseOrder = packageWithAllocation.planPhaseOrder + priceType = packageWithAllocation.priceType + replacesPriceId = packageWithAllocation.replacesPriceId + dimensionalPriceConfiguration = packageWithAllocation.dimensionalPriceConfiguration + additionalProperties = packageWithAllocation.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) @@ -19656,6 +20580,34 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + fun compositePriceFilters(compositePriceFilters: List?) = + compositePriceFilters(JsonField.ofNullable(compositePriceFilters)) + + /** + * Sets [Builder.compositePriceFilters] to an arbitrary JSON value. + * + * You should usually call [Builder.compositePriceFilters] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun compositePriceFilters( + compositePriceFilters: JsonField> + ) = apply { + this.compositePriceFilters = compositePriceFilters.map { it.toMutableList() } + } + + /** + * Adds a single [TransformPriceFilter] to [compositePriceFilters]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addCompositePriceFilter(compositePriceFilter: TransformPriceFilter) = apply { + compositePriceFilters = + (compositePriceFilters ?: JsonField.of(mutableListOf())).also { + checkKnown("compositePriceFilters", it).add(compositePriceFilter) + } + } + fun conversionRate(conversionRate: Double?) = conversionRate(JsonField.ofNullable(conversionRate)) @@ -19897,20 +20849,6 @@ private constructor( this.fixedPriceQuantity = fixedPriceQuantity } - fun groupedTieredConfig(groupedTieredConfig: GroupedTieredConfig) = - groupedTieredConfig(JsonField.of(groupedTieredConfig)) - - /** - * Sets [Builder.groupedTieredConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.groupedTieredConfig] with a well-typed - * [GroupedTieredConfig] value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. - */ - fun groupedTieredConfig(groupedTieredConfig: JsonField) = apply { - this.groupedTieredConfig = groupedTieredConfig - } - fun invoicingCycleConfiguration( invoicingCycleConfiguration: BillingCycleConfiguration? ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) @@ -20017,7 +20955,7 @@ private constructor( * It is usually unnecessary to call this method because the field defaults to the * following: * ```kotlin - * JsonValue.from("grouped_tiered") + * JsonValue.from("package_with_allocation") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -20036,6 +20974,21 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } + fun packageWithAllocationConfig( + packageWithAllocationConfig: PackageWithAllocationConfig + ) = packageWithAllocationConfig(JsonField.of(packageWithAllocationConfig)) + + /** + * Sets [Builder.packageWithAllocationConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.packageWithAllocationConfig] with a well-typed + * [PackageWithAllocationConfig] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun packageWithAllocationConfig( + packageWithAllocationConfig: JsonField + ) = apply { this.packageWithAllocationConfig = packageWithAllocationConfig } + fun planPhaseOrder(planPhaseOrder: Long?) = planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) @@ -20121,7 +21074,7 @@ private constructor( } /** - * Returns an immutable instance of [GroupedTiered]. + * Returns an immutable instance of [PackageWithAllocation]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -20131,6 +21084,7 @@ private constructor( * .billableMetric() * .billingCycleConfiguration() * .cadence() + * .compositePriceFilters() * .conversionRate() * .conversionRateConfig() * .createdAt() @@ -20139,7 +21093,6 @@ private constructor( * .discount() * .externalPriceId() * .fixedPriceQuantity() - * .groupedTieredConfig() * .invoicingCycleConfiguration() * .item() * .maximum() @@ -20148,6 +21101,7 @@ private constructor( * .minimum() * .minimumAmount() * .name() + * .packageWithAllocationConfig() * .planPhaseOrder() * .priceType() * .replacesPriceId() @@ -20155,12 +21109,15 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): GroupedTiered = - GroupedTiered( + fun build(): PackageWithAllocation = + PackageWithAllocation( checkRequired("id", id), checkRequired("billableMetric", billableMetric), checkRequired("billingCycleConfiguration", billingCycleConfiguration), checkRequired("cadence", cadence), + checkRequired("compositePriceFilters", compositePriceFilters).map { + it.toImmutable() + }, checkRequired("conversionRate", conversionRate), checkRequired("conversionRateConfig", conversionRateConfig), checkRequired("createdAt", createdAt), @@ -20169,7 +21126,6 @@ private constructor( checkRequired("discount", discount), checkRequired("externalPriceId", externalPriceId), checkRequired("fixedPriceQuantity", fixedPriceQuantity), - checkRequired("groupedTieredConfig", groupedTieredConfig), checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), checkRequired("item", item), checkRequired("maximum", maximum), @@ -20179,6 +21135,7 @@ private constructor( checkRequired("minimumAmount", minimumAmount), modelType, checkRequired("name", name), + checkRequired("packageWithAllocationConfig", packageWithAllocationConfig), checkRequired("planPhaseOrder", planPhaseOrder), checkRequired("priceType", priceType), checkRequired("replacesPriceId", replacesPriceId), @@ -20189,7 +21146,7 @@ private constructor( private var validated: Boolean = false - fun validate(): GroupedTiered = apply { + fun validate(): PackageWithAllocation = apply { if (validated) { return@apply } @@ -20198,6 +21155,7 @@ private constructor( billableMetric()?.validate() billingCycleConfiguration().validate() cadence().validate() + compositePriceFilters()?.forEach { it.validate() } conversionRate() conversionRateConfig()?.validate() createdAt() @@ -20206,7 +21164,6 @@ private constructor( discount()?.validate() externalPriceId() fixedPriceQuantity() - groupedTieredConfig().validate() invoicingCycleConfiguration()?.validate() item().validate() maximum()?.validate() @@ -20215,11 +21172,12 @@ private constructor( minimum()?.validate() minimumAmount() _modelType().let { - if (it != JsonValue.from("grouped_tiered")) { + if (it != JsonValue.from("package_with_allocation")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } name() + packageWithAllocationConfig().validate() planPhaseOrder() priceType().validate() replacesPriceId() @@ -20246,6 +21204,7 @@ private constructor( (billableMetric.asKnown()?.validity() ?: 0) + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + (cadence.asKnown()?.validity() ?: 0) + + (compositePriceFilters.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + (if (conversionRate.asKnown() == null) 0 else 1) + (conversionRateConfig.asKnown()?.validity() ?: 0) + (if (createdAt.asKnown() == null) 0 else 1) + @@ -20254,7 +21213,6 @@ private constructor( (discount.asKnown()?.validity() ?: 0) + (if (externalPriceId.asKnown() == null) 0 else 1) + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + - (groupedTieredConfig.asKnown()?.validity() ?: 0) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + (item.asKnown()?.validity() ?: 0) + (maximum.asKnown()?.validity() ?: 0) + @@ -20262,8 +21220,9 @@ private constructor( (metadata.asKnown()?.validity() ?: 0) + (minimum.asKnown()?.validity() ?: 0) + (if (minimumAmount.asKnown() == null) 0 else 1) + - modelType.let { if (it == JsonValue.from("grouped_tiered")) 1 else 0 } + + modelType.let { if (it == JsonValue.from("package_with_allocation")) 1 else 0 } + (if (name.asKnown() == null) 0 else 1) + + (packageWithAllocationConfig.asKnown()?.validity() ?: 0) + (if (planPhaseOrder.asKnown() == null) 0 else 1) + (priceType.asKnown()?.validity() ?: 0) + (if (replacesPriceId.asKnown() == null) 0 else 1) + @@ -20421,7 +21380,12 @@ private constructor( override fun toString() = value.toString() } - class GroupedTieredConfig + /** + * User specified key-value pairs for the resource. If not present, this defaults to an + * empty dictionary. Individual keys can be removed by setting the value to `null`, and the + * entire metadata mapping can be cleared by setting `metadata` to `null`. + */ + class Metadata @JsonCreator private constructor( @com.fasterxml.jackson.annotation.JsonValue @@ -20436,19 +21400,17 @@ private constructor( companion object { - /** - * Returns a mutable builder for constructing an instance of [GroupedTieredConfig]. - */ + /** Returns a mutable builder for constructing an instance of [Metadata]. */ fun builder() = Builder() } - /** A builder for [GroupedTieredConfig]. */ + /** A builder for [Metadata]. */ class Builder internal constructor() { private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(groupedTieredConfig: GroupedTieredConfig) = apply { - additionalProperties = groupedTieredConfig.additionalProperties.toMutableMap() + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() } fun additionalProperties(additionalProperties: Map) = apply { @@ -20474,17 +21436,16 @@ private constructor( } /** - * Returns an immutable instance of [GroupedTieredConfig]. + * Returns an immutable instance of [Metadata]. * * Further updates to this [Builder] will not mutate the returned instance. */ - fun build(): GroupedTieredConfig = - GroupedTieredConfig(additionalProperties.toImmutable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } private var validated: Boolean = false - fun validate(): GroupedTieredConfig = apply { + fun validate(): Metadata = apply { if (validated) { return@apply } @@ -20514,24 +21475,17 @@ private constructor( return true } - return other is GroupedTieredConfig && - additionalProperties == other.additionalProperties + return other is Metadata && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { Objects.hash(additionalProperties) } override fun hashCode(): Int = hashCode - override fun toString() = - "GroupedTieredConfig{additionalProperties=$additionalProperties}" + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" } - /** - * User specified key-value pairs for the resource. If not present, this defaults to an - * empty dictionary. Individual keys can be removed by setting the value to `null`, and the - * entire metadata mapping can be cleared by setting `metadata` to `null`. - */ - class Metadata + class PackageWithAllocationConfig @JsonCreator private constructor( @com.fasterxml.jackson.annotation.JsonValue @@ -20546,18 +21500,23 @@ private constructor( companion object { - /** Returns a mutable builder for constructing an instance of [Metadata]. */ + /** + * Returns a mutable builder for constructing an instance of + * [PackageWithAllocationConfig]. + */ fun builder() = Builder() } - /** A builder for [Metadata]. */ + /** A builder for [PackageWithAllocationConfig]. */ class Builder internal constructor() { private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(metadata: Metadata) = apply { - additionalProperties = metadata.additionalProperties.toMutableMap() - } + internal fun from(packageWithAllocationConfig: PackageWithAllocationConfig) = + apply { + additionalProperties = + packageWithAllocationConfig.additionalProperties.toMutableMap() + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -20582,16 +21541,17 @@ private constructor( } /** - * Returns an immutable instance of [Metadata]. + * Returns an immutable instance of [PackageWithAllocationConfig]. * * Further updates to this [Builder] will not mutate the returned instance. */ - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + fun build(): PackageWithAllocationConfig = + PackageWithAllocationConfig(additionalProperties.toImmutable()) } private var validated: Boolean = false - fun validate(): Metadata = apply { + fun validate(): PackageWithAllocationConfig = apply { if (validated) { return@apply } @@ -20621,14 +21581,16 @@ private constructor( return true } - return other is Metadata && additionalProperties == other.additionalProperties + return other is PackageWithAllocationConfig && + additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { Objects.hash(additionalProperties) } override fun hashCode(): Int = hashCode - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + override fun toString() = + "PackageWithAllocationConfig{additionalProperties=$additionalProperties}" } class PriceType @JsonCreator private constructor(private val value: JsonField) : @@ -20765,11 +21727,12 @@ private constructor( return true } - return other is GroupedTiered && + return other is PackageWithAllocation && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && + compositePriceFilters == other.compositePriceFilters && conversionRate == other.conversionRate && conversionRateConfig == other.conversionRateConfig && createdAt == other.createdAt && @@ -20778,7 +21741,6 @@ private constructor( discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && - groupedTieredConfig == other.groupedTieredConfig && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maximum == other.maximum && @@ -20788,6 +21750,7 @@ private constructor( minimumAmount == other.minimumAmount && modelType == other.modelType && name == other.name && + packageWithAllocationConfig == other.packageWithAllocationConfig && planPhaseOrder == other.planPhaseOrder && priceType == other.priceType && replacesPriceId == other.replacesPriceId && @@ -20801,6 +21764,7 @@ private constructor( billableMetric, billingCycleConfiguration, cadence, + compositePriceFilters, conversionRate, conversionRateConfig, createdAt, @@ -20809,7 +21773,6 @@ private constructor( discount, externalPriceId, fixedPriceQuantity, - groupedTieredConfig, invoicingCycleConfiguration, item, maximum, @@ -20819,6 +21782,7 @@ private constructor( minimumAmount, modelType, name, + packageWithAllocationConfig, planPhaseOrder, priceType, replacesPriceId, @@ -20830,15 +21794,16 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "GroupedTiered{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, groupedTieredConfig=$groupedTieredConfig, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "PackageWithAllocation{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, packageWithAllocationConfig=$packageWithAllocationConfig, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" } - class TieredWithMinimum + class UnitWithPercent private constructor( private val id: JsonField, private val billableMetric: JsonField, private val billingCycleConfiguration: JsonField, private val cadence: JsonField, + private val compositePriceFilters: JsonField>, private val conversionRate: JsonField, private val conversionRateConfig: JsonField, private val createdAt: JsonField, @@ -20859,7 +21824,7 @@ private constructor( private val planPhaseOrder: JsonField, private val priceType: JsonField, private val replacesPriceId: JsonField, - private val tieredWithMinimumConfig: JsonField, + private val unitWithPercentConfig: JsonField, private val dimensionalPriceConfiguration: JsonField, private val additionalProperties: MutableMap, ) { @@ -20874,6 +21839,9 @@ private constructor( @ExcludeMissing billingCycleConfiguration: JsonField = JsonMissing.of(), @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), + @JsonProperty("composite_price_filters") + @ExcludeMissing + compositePriceFilters: JsonField> = JsonMissing.of(), @JsonProperty("conversion_rate") @ExcludeMissing conversionRate: JsonField = JsonMissing.of(), @@ -20924,9 +21892,9 @@ private constructor( @JsonProperty("replaces_price_id") @ExcludeMissing replacesPriceId: JsonField = JsonMissing.of(), - @JsonProperty("tiered_with_minimum_config") + @JsonProperty("unit_with_percent_config") @ExcludeMissing - tieredWithMinimumConfig: JsonField = JsonMissing.of(), + unitWithPercentConfig: JsonField = JsonMissing.of(), @JsonProperty("dimensional_price_configuration") @ExcludeMissing dimensionalPriceConfiguration: JsonField = @@ -20936,6 +21904,7 @@ private constructor( billableMetric, billingCycleConfiguration, cadence, + compositePriceFilters, conversionRate, conversionRateConfig, createdAt, @@ -20956,7 +21925,7 @@ private constructor( planPhaseOrder, priceType, replacesPriceId, - tieredWithMinimumConfig, + unitWithPercentConfig, dimensionalPriceConfiguration, mutableMapOf(), ) @@ -20986,6 +21955,13 @@ private constructor( */ fun cadence(): Cadence = cadence.getRequired("cadence") + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun compositePriceFilters(): List? = + compositePriceFilters.getNullable("composite_price_filters") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -21087,7 +22063,7 @@ private constructor( /** * Expected to always return the following: * ```kotlin - * JsonValue.from("tiered_with_minimum") + * JsonValue.from("unit_with_percent") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -21126,8 +22102,8 @@ private constructor( * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ - fun tieredWithMinimumConfig(): TieredWithMinimumConfig = - tieredWithMinimumConfig.getRequired("tiered_with_minimum_config") + fun unitWithPercentConfig(): UnitWithPercentConfig = + unitWithPercentConfig.getRequired("unit_with_percent_config") /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the @@ -21171,6 +22147,16 @@ private constructor( */ @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence + /** + * Returns the raw JSON value of [compositePriceFilters]. + * + * Unlike [compositePriceFilters], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("composite_price_filters") + @ExcludeMissing + fun _compositePriceFilters(): JsonField> = compositePriceFilters + /** * Returns the raw JSON value of [conversionRate]. * @@ -21351,14 +22337,14 @@ private constructor( fun _replacesPriceId(): JsonField = replacesPriceId /** - * Returns the raw JSON value of [tieredWithMinimumConfig]. + * Returns the raw JSON value of [unitWithPercentConfig]. * - * Unlike [tieredWithMinimumConfig], this method doesn't throw if the JSON field has an + * Unlike [unitWithPercentConfig], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("tiered_with_minimum_config") + @JsonProperty("unit_with_percent_config") @ExcludeMissing - fun _tieredWithMinimumConfig(): JsonField = tieredWithMinimumConfig + fun _unitWithPercentConfig(): JsonField = unitWithPercentConfig /** * Returns the raw JSON value of [dimensionalPriceConfiguration]. @@ -21386,7 +22372,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [TieredWithMinimum]. + * Returns a mutable builder for constructing an instance of [UnitWithPercent]. * * The following fields are required: * ```kotlin @@ -21394,6 +22380,7 @@ private constructor( * .billableMetric() * .billingCycleConfiguration() * .cadence() + * .compositePriceFilters() * .conversionRate() * .conversionRateConfig() * .createdAt() @@ -21413,19 +22400,20 @@ private constructor( * .planPhaseOrder() * .priceType() * .replacesPriceId() - * .tieredWithMinimumConfig() + * .unitWithPercentConfig() * ``` */ fun builder() = Builder() } - /** A builder for [TieredWithMinimum]. */ + /** A builder for [UnitWithPercent]. */ class Builder internal constructor() { private var id: JsonField? = null private var billableMetric: JsonField? = null private var billingCycleConfiguration: JsonField? = null private var cadence: JsonField? = null + private var compositePriceFilters: JsonField>? = null private var conversionRate: JsonField? = null private var conversionRateConfig: JsonField? = null private var createdAt: JsonField? = null @@ -21441,44 +22429,46 @@ private constructor( private var metadata: JsonField? = null private var minimum: JsonField? = null private var minimumAmount: JsonField? = null - private var modelType: JsonValue = JsonValue.from("tiered_with_minimum") + private var modelType: JsonValue = JsonValue.from("unit_with_percent") private var name: JsonField? = null private var planPhaseOrder: JsonField? = null private var priceType: JsonField? = null private var replacesPriceId: JsonField? = null - private var tieredWithMinimumConfig: JsonField? = null + private var unitWithPercentConfig: JsonField? = null private var dimensionalPriceConfiguration: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(tieredWithMinimum: TieredWithMinimum) = apply { - id = tieredWithMinimum.id - billableMetric = tieredWithMinimum.billableMetric - billingCycleConfiguration = tieredWithMinimum.billingCycleConfiguration - cadence = tieredWithMinimum.cadence - conversionRate = tieredWithMinimum.conversionRate - conversionRateConfig = tieredWithMinimum.conversionRateConfig - createdAt = tieredWithMinimum.createdAt - creditAllocation = tieredWithMinimum.creditAllocation - currency = tieredWithMinimum.currency - discount = tieredWithMinimum.discount - externalPriceId = tieredWithMinimum.externalPriceId - fixedPriceQuantity = tieredWithMinimum.fixedPriceQuantity - invoicingCycleConfiguration = tieredWithMinimum.invoicingCycleConfiguration - item = tieredWithMinimum.item - maximum = tieredWithMinimum.maximum - maximumAmount = tieredWithMinimum.maximumAmount - metadata = tieredWithMinimum.metadata - minimum = tieredWithMinimum.minimum - minimumAmount = tieredWithMinimum.minimumAmount - modelType = tieredWithMinimum.modelType - name = tieredWithMinimum.name - planPhaseOrder = tieredWithMinimum.planPhaseOrder - priceType = tieredWithMinimum.priceType - replacesPriceId = tieredWithMinimum.replacesPriceId - tieredWithMinimumConfig = tieredWithMinimum.tieredWithMinimumConfig - dimensionalPriceConfiguration = tieredWithMinimum.dimensionalPriceConfiguration - additionalProperties = tieredWithMinimum.additionalProperties.toMutableMap() + internal fun from(unitWithPercent: UnitWithPercent) = apply { + id = unitWithPercent.id + billableMetric = unitWithPercent.billableMetric + billingCycleConfiguration = unitWithPercent.billingCycleConfiguration + cadence = unitWithPercent.cadence + compositePriceFilters = + unitWithPercent.compositePriceFilters.map { it.toMutableList() } + conversionRate = unitWithPercent.conversionRate + conversionRateConfig = unitWithPercent.conversionRateConfig + createdAt = unitWithPercent.createdAt + creditAllocation = unitWithPercent.creditAllocation + currency = unitWithPercent.currency + discount = unitWithPercent.discount + externalPriceId = unitWithPercent.externalPriceId + fixedPriceQuantity = unitWithPercent.fixedPriceQuantity + invoicingCycleConfiguration = unitWithPercent.invoicingCycleConfiguration + item = unitWithPercent.item + maximum = unitWithPercent.maximum + maximumAmount = unitWithPercent.maximumAmount + metadata = unitWithPercent.metadata + minimum = unitWithPercent.minimum + minimumAmount = unitWithPercent.minimumAmount + modelType = unitWithPercent.modelType + name = unitWithPercent.name + planPhaseOrder = unitWithPercent.planPhaseOrder + priceType = unitWithPercent.priceType + replacesPriceId = unitWithPercent.replacesPriceId + unitWithPercentConfig = unitWithPercent.unitWithPercentConfig + dimensionalPriceConfiguration = unitWithPercent.dimensionalPriceConfiguration + additionalProperties = unitWithPercent.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) @@ -21531,6 +22521,34 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + fun compositePriceFilters(compositePriceFilters: List?) = + compositePriceFilters(JsonField.ofNullable(compositePriceFilters)) + + /** + * Sets [Builder.compositePriceFilters] to an arbitrary JSON value. + * + * You should usually call [Builder.compositePriceFilters] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun compositePriceFilters( + compositePriceFilters: JsonField> + ) = apply { + this.compositePriceFilters = compositePriceFilters.map { it.toMutableList() } + } + + /** + * Adds a single [TransformPriceFilter] to [compositePriceFilters]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addCompositePriceFilter(compositePriceFilter: TransformPriceFilter) = apply { + compositePriceFilters = + (compositePriceFilters ?: JsonField.of(mutableListOf())).also { + checkKnown("compositePriceFilters", it).add(compositePriceFilter) + } + } + fun conversionRate(conversionRate: Double?) = conversionRate(JsonField.ofNullable(conversionRate)) @@ -21878,7 +22896,7 @@ private constructor( * It is usually unnecessary to call this method because the field defaults to the * following: * ```kotlin - * JsonValue.from("tiered_with_minimum") + * JsonValue.from("unit_with_percent") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -21947,19 +22965,20 @@ private constructor( this.replacesPriceId = replacesPriceId } - fun tieredWithMinimumConfig(tieredWithMinimumConfig: TieredWithMinimumConfig) = - tieredWithMinimumConfig(JsonField.of(tieredWithMinimumConfig)) + fun unitWithPercentConfig(unitWithPercentConfig: UnitWithPercentConfig) = + unitWithPercentConfig(JsonField.of(unitWithPercentConfig)) /** - * Sets [Builder.tieredWithMinimumConfig] to an arbitrary JSON value. + * Sets [Builder.unitWithPercentConfig] to an arbitrary JSON value. * - * You should usually call [Builder.tieredWithMinimumConfig] with a well-typed - * [TieredWithMinimumConfig] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * You should usually call [Builder.unitWithPercentConfig] with a well-typed + * [UnitWithPercentConfig] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. */ - fun tieredWithMinimumConfig( - tieredWithMinimumConfig: JsonField - ) = apply { this.tieredWithMinimumConfig = tieredWithMinimumConfig } + fun unitWithPercentConfig(unitWithPercentConfig: JsonField) = + apply { + this.unitWithPercentConfig = unitWithPercentConfig + } fun dimensionalPriceConfiguration( dimensionalPriceConfiguration: DimensionalPriceConfiguration? @@ -21996,7 +23015,7 @@ private constructor( } /** - * Returns an immutable instance of [TieredWithMinimum]. + * Returns an immutable instance of [UnitWithPercent]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -22006,6 +23025,7 @@ private constructor( * .billableMetric() * .billingCycleConfiguration() * .cadence() + * .compositePriceFilters() * .conversionRate() * .conversionRateConfig() * .createdAt() @@ -22025,17 +23045,20 @@ private constructor( * .planPhaseOrder() * .priceType() * .replacesPriceId() - * .tieredWithMinimumConfig() + * .unitWithPercentConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): TieredWithMinimum = - TieredWithMinimum( + fun build(): UnitWithPercent = + UnitWithPercent( checkRequired("id", id), checkRequired("billableMetric", billableMetric), checkRequired("billingCycleConfiguration", billingCycleConfiguration), checkRequired("cadence", cadence), + checkRequired("compositePriceFilters", compositePriceFilters).map { + it.toImmutable() + }, checkRequired("conversionRate", conversionRate), checkRequired("conversionRateConfig", conversionRateConfig), checkRequired("createdAt", createdAt), @@ -22056,7 +23079,7 @@ private constructor( checkRequired("planPhaseOrder", planPhaseOrder), checkRequired("priceType", priceType), checkRequired("replacesPriceId", replacesPriceId), - checkRequired("tieredWithMinimumConfig", tieredWithMinimumConfig), + checkRequired("unitWithPercentConfig", unitWithPercentConfig), dimensionalPriceConfiguration, additionalProperties.toMutableMap(), ) @@ -22064,7 +23087,7 @@ private constructor( private var validated: Boolean = false - fun validate(): TieredWithMinimum = apply { + fun validate(): UnitWithPercent = apply { if (validated) { return@apply } @@ -22073,6 +23096,7 @@ private constructor( billableMetric()?.validate() billingCycleConfiguration().validate() cadence().validate() + compositePriceFilters()?.forEach { it.validate() } conversionRate() conversionRateConfig()?.validate() createdAt() @@ -22089,7 +23113,7 @@ private constructor( minimum()?.validate() minimumAmount() _modelType().let { - if (it != JsonValue.from("tiered_with_minimum")) { + if (it != JsonValue.from("unit_with_percent")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } @@ -22097,7 +23121,7 @@ private constructor( planPhaseOrder() priceType().validate() replacesPriceId() - tieredWithMinimumConfig().validate() + unitWithPercentConfig().validate() dimensionalPriceConfiguration()?.validate() validated = true } @@ -22121,6 +23145,7 @@ private constructor( (billableMetric.asKnown()?.validity() ?: 0) + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + (cadence.asKnown()?.validity() ?: 0) + + (compositePriceFilters.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + (if (conversionRate.asKnown() == null) 0 else 1) + (conversionRateConfig.asKnown()?.validity() ?: 0) + (if (createdAt.asKnown() == null) 0 else 1) + @@ -22136,12 +23161,12 @@ private constructor( (metadata.asKnown()?.validity() ?: 0) + (minimum.asKnown()?.validity() ?: 0) + (if (minimumAmount.asKnown() == null) 0 else 1) + - modelType.let { if (it == JsonValue.from("tiered_with_minimum")) 1 else 0 } + + modelType.let { if (it == JsonValue.from("unit_with_percent")) 1 else 0 } + (if (name.asKnown() == null) 0 else 1) + (if (planPhaseOrder.asKnown() == null) 0 else 1) + (priceType.asKnown()?.validity() ?: 0) + (if (replacesPriceId.asKnown() == null) 0 else 1) + - (tieredWithMinimumConfig.asKnown()?.validity() ?: 0) + + (unitWithPercentConfig.asKnown()?.validity() ?: 0) + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) class Cadence @JsonCreator private constructor(private val value: JsonField) : @@ -22530,7 +23555,7 @@ private constructor( override fun toString() = value.toString() } - class TieredWithMinimumConfig + class UnitWithPercentConfig @JsonCreator private constructor( @com.fasterxml.jackson.annotation.JsonValue @@ -22547,19 +23572,18 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [TieredWithMinimumConfig]. + * [UnitWithPercentConfig]. */ fun builder() = Builder() } - /** A builder for [TieredWithMinimumConfig]. */ + /** A builder for [UnitWithPercentConfig]. */ class Builder internal constructor() { private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(tieredWithMinimumConfig: TieredWithMinimumConfig) = apply { - additionalProperties = - tieredWithMinimumConfig.additionalProperties.toMutableMap() + internal fun from(unitWithPercentConfig: UnitWithPercentConfig) = apply { + additionalProperties = unitWithPercentConfig.additionalProperties.toMutableMap() } fun additionalProperties(additionalProperties: Map) = apply { @@ -22585,17 +23609,17 @@ private constructor( } /** - * Returns an immutable instance of [TieredWithMinimumConfig]. + * Returns an immutable instance of [UnitWithPercentConfig]. * * Further updates to this [Builder] will not mutate the returned instance. */ - fun build(): TieredWithMinimumConfig = - TieredWithMinimumConfig(additionalProperties.toImmutable()) + fun build(): UnitWithPercentConfig = + UnitWithPercentConfig(additionalProperties.toImmutable()) } private var validated: Boolean = false - fun validate(): TieredWithMinimumConfig = apply { + fun validate(): UnitWithPercentConfig = apply { if (validated) { return@apply } @@ -22625,7 +23649,7 @@ private constructor( return true } - return other is TieredWithMinimumConfig && + return other is UnitWithPercentConfig && additionalProperties == other.additionalProperties } @@ -22634,7 +23658,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "TieredWithMinimumConfig{additionalProperties=$additionalProperties}" + "UnitWithPercentConfig{additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { @@ -22642,11 +23666,12 @@ private constructor( return true } - return other is TieredWithMinimum && + return other is UnitWithPercent && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && + compositePriceFilters == other.compositePriceFilters && conversionRate == other.conversionRate && conversionRateConfig == other.conversionRateConfig && createdAt == other.createdAt && @@ -22667,7 +23692,7 @@ private constructor( planPhaseOrder == other.planPhaseOrder && priceType == other.priceType && replacesPriceId == other.replacesPriceId && - tieredWithMinimumConfig == other.tieredWithMinimumConfig && + unitWithPercentConfig == other.unitWithPercentConfig && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties } @@ -22678,6 +23703,7 @@ private constructor( billableMetric, billingCycleConfiguration, cadence, + compositePriceFilters, conversionRate, conversionRateConfig, createdAt, @@ -22698,7 +23724,7 @@ private constructor( planPhaseOrder, priceType, replacesPriceId, - tieredWithMinimumConfig, + unitWithPercentConfig, dimensionalPriceConfiguration, additionalProperties, ) @@ -22707,15 +23733,16 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "TieredWithMinimum{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, tieredWithMinimumConfig=$tieredWithMinimumConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "UnitWithPercent{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, unitWithPercentConfig=$unitWithPercentConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" } - class TieredPackageWithMinimum + class MatrixWithAllocation private constructor( private val id: JsonField, private val billableMetric: JsonField, private val billingCycleConfiguration: JsonField, private val cadence: JsonField, + private val compositePriceFilters: JsonField>, private val conversionRate: JsonField, private val conversionRateConfig: JsonField, private val createdAt: JsonField, @@ -22726,6 +23753,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoicingCycleConfiguration: JsonField, private val item: JsonField, + private val matrixWithAllocationConfig: JsonField, private val maximum: JsonField, private val maximumAmount: JsonField, private val metadata: JsonField, @@ -22736,7 +23764,6 @@ private constructor( private val planPhaseOrder: JsonField, private val priceType: JsonField, private val replacesPriceId: JsonField, - private val tieredPackageWithMinimumConfig: JsonField, private val dimensionalPriceConfiguration: JsonField, private val additionalProperties: MutableMap, ) { @@ -22751,6 +23778,9 @@ private constructor( @ExcludeMissing billingCycleConfiguration: JsonField = JsonMissing.of(), @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), + @JsonProperty("composite_price_filters") + @ExcludeMissing + compositePriceFilters: JsonField> = JsonMissing.of(), @JsonProperty("conversion_rate") @ExcludeMissing conversionRate: JsonField = JsonMissing.of(), @@ -22779,6 +23809,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), @JsonProperty("item") @ExcludeMissing item: JsonField = JsonMissing.of(), + @JsonProperty("matrix_with_allocation_config") + @ExcludeMissing + matrixWithAllocationConfig: JsonField = JsonMissing.of(), @JsonProperty("maximum") @ExcludeMissing maximum: JsonField = JsonMissing.of(), @JsonProperty("maximum_amount") @ExcludeMissing @@ -22801,10 +23834,6 @@ private constructor( @JsonProperty("replaces_price_id") @ExcludeMissing replacesPriceId: JsonField = JsonMissing.of(), - @JsonProperty("tiered_package_with_minimum_config") - @ExcludeMissing - tieredPackageWithMinimumConfig: JsonField = - JsonMissing.of(), @JsonProperty("dimensional_price_configuration") @ExcludeMissing dimensionalPriceConfiguration: JsonField = @@ -22814,6 +23843,7 @@ private constructor( billableMetric, billingCycleConfiguration, cadence, + compositePriceFilters, conversionRate, conversionRateConfig, createdAt, @@ -22824,6 +23854,7 @@ private constructor( fixedPriceQuantity, invoicingCycleConfiguration, item, + matrixWithAllocationConfig, maximum, maximumAmount, metadata, @@ -22834,7 +23865,6 @@ private constructor( planPhaseOrder, priceType, replacesPriceId, - tieredPackageWithMinimumConfig, dimensionalPriceConfiguration, mutableMapOf(), ) @@ -22864,6 +23894,13 @@ private constructor( */ fun cadence(): Cadence = cadence.getRequired("cadence") + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun compositePriceFilters(): List? = + compositePriceFilters.getNullable("composite_price_filters") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -22926,6 +23963,13 @@ private constructor( */ fun item(): ItemSlim = item.getRequired("item") + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun matrixWithAllocationConfig(): MatrixWithAllocationConfig = + matrixWithAllocationConfig.getRequired("matrix_with_allocation_config") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -22965,7 +24009,7 @@ private constructor( /** * Expected to always return the following: * ```kotlin - * JsonValue.from("tiered_package_with_minimum") + * JsonValue.from("matrix_with_allocation") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -23000,13 +24044,6 @@ private constructor( */ fun replacesPriceId(): String? = replacesPriceId.getNullable("replaces_price_id") - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun tieredPackageWithMinimumConfig(): TieredPackageWithMinimumConfig = - tieredPackageWithMinimumConfig.getRequired("tiered_package_with_minimum_config") - /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -23049,6 +24086,16 @@ private constructor( */ @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence + /** + * Returns the raw JSON value of [compositePriceFilters]. + * + * Unlike [compositePriceFilters], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("composite_price_filters") + @ExcludeMissing + fun _compositePriceFilters(): JsonField> = compositePriceFilters + /** * Returns the raw JSON value of [conversionRate]. * @@ -23143,6 +24190,17 @@ private constructor( */ @JsonProperty("item") @ExcludeMissing fun _item(): JsonField = item + /** + * Returns the raw JSON value of [matrixWithAllocationConfig]. + * + * Unlike [matrixWithAllocationConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("matrix_with_allocation_config") + @ExcludeMissing + fun _matrixWithAllocationConfig(): JsonField = + matrixWithAllocationConfig + /** * Returns the raw JSON value of [maximum]. * @@ -23228,17 +24286,6 @@ private constructor( @ExcludeMissing fun _replacesPriceId(): JsonField = replacesPriceId - /** - * Returns the raw JSON value of [tieredPackageWithMinimumConfig]. - * - * Unlike [tieredPackageWithMinimumConfig], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("tiered_package_with_minimum_config") - @ExcludeMissing - fun _tieredPackageWithMinimumConfig(): JsonField = - tieredPackageWithMinimumConfig - /** * Returns the raw JSON value of [dimensionalPriceConfiguration]. * @@ -23265,7 +24312,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [TieredPackageWithMinimum]. + * Returns a mutable builder for constructing an instance of [MatrixWithAllocation]. * * The following fields are required: * ```kotlin @@ -23273,6 +24320,7 @@ private constructor( * .billableMetric() * .billingCycleConfiguration() * .cadence() + * .compositePriceFilters() * .conversionRate() * .conversionRateConfig() * .createdAt() @@ -23283,6 +24331,7 @@ private constructor( * .fixedPriceQuantity() * .invoicingCycleConfiguration() * .item() + * .matrixWithAllocationConfig() * .maximum() * .maximumAmount() * .metadata() @@ -23292,19 +24341,19 @@ private constructor( * .planPhaseOrder() * .priceType() * .replacesPriceId() - * .tieredPackageWithMinimumConfig() * ``` */ fun builder() = Builder() } - /** A builder for [TieredPackageWithMinimum]. */ + /** A builder for [MatrixWithAllocation]. */ class Builder internal constructor() { private var id: JsonField? = null private var billableMetric: JsonField? = null private var billingCycleConfiguration: JsonField? = null private var cadence: JsonField? = null + private var compositePriceFilters: JsonField>? = null private var conversionRate: JsonField? = null private var conversionRateConfig: JsonField? = null private var createdAt: JsonField? = null @@ -23315,52 +24364,51 @@ private constructor( private var fixedPriceQuantity: JsonField? = null private var invoicingCycleConfiguration: JsonField? = null private var item: JsonField? = null + private var matrixWithAllocationConfig: JsonField? = null private var maximum: JsonField? = null private var maximumAmount: JsonField? = null private var metadata: JsonField? = null private var minimum: JsonField? = null private var minimumAmount: JsonField? = null - private var modelType: JsonValue = JsonValue.from("tiered_package_with_minimum") + private var modelType: JsonValue = JsonValue.from("matrix_with_allocation") private var name: JsonField? = null private var planPhaseOrder: JsonField? = null private var priceType: JsonField? = null private var replacesPriceId: JsonField? = null - private var tieredPackageWithMinimumConfig: JsonField? = - null private var dimensionalPriceConfiguration: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(tieredPackageWithMinimum: TieredPackageWithMinimum) = apply { - id = tieredPackageWithMinimum.id - billableMetric = tieredPackageWithMinimum.billableMetric - billingCycleConfiguration = tieredPackageWithMinimum.billingCycleConfiguration - cadence = tieredPackageWithMinimum.cadence - conversionRate = tieredPackageWithMinimum.conversionRate - conversionRateConfig = tieredPackageWithMinimum.conversionRateConfig - createdAt = tieredPackageWithMinimum.createdAt - creditAllocation = tieredPackageWithMinimum.creditAllocation - currency = tieredPackageWithMinimum.currency - discount = tieredPackageWithMinimum.discount - externalPriceId = tieredPackageWithMinimum.externalPriceId - fixedPriceQuantity = tieredPackageWithMinimum.fixedPriceQuantity - invoicingCycleConfiguration = tieredPackageWithMinimum.invoicingCycleConfiguration - item = tieredPackageWithMinimum.item - maximum = tieredPackageWithMinimum.maximum - maximumAmount = tieredPackageWithMinimum.maximumAmount - metadata = tieredPackageWithMinimum.metadata - minimum = tieredPackageWithMinimum.minimum - minimumAmount = tieredPackageWithMinimum.minimumAmount - modelType = tieredPackageWithMinimum.modelType - name = tieredPackageWithMinimum.name - planPhaseOrder = tieredPackageWithMinimum.planPhaseOrder - priceType = tieredPackageWithMinimum.priceType - replacesPriceId = tieredPackageWithMinimum.replacesPriceId - tieredPackageWithMinimumConfig = - tieredPackageWithMinimum.tieredPackageWithMinimumConfig - dimensionalPriceConfiguration = - tieredPackageWithMinimum.dimensionalPriceConfiguration - additionalProperties = tieredPackageWithMinimum.additionalProperties.toMutableMap() + internal fun from(matrixWithAllocation: MatrixWithAllocation) = apply { + id = matrixWithAllocation.id + billableMetric = matrixWithAllocation.billableMetric + billingCycleConfiguration = matrixWithAllocation.billingCycleConfiguration + cadence = matrixWithAllocation.cadence + compositePriceFilters = + matrixWithAllocation.compositePriceFilters.map { it.toMutableList() } + conversionRate = matrixWithAllocation.conversionRate + conversionRateConfig = matrixWithAllocation.conversionRateConfig + createdAt = matrixWithAllocation.createdAt + creditAllocation = matrixWithAllocation.creditAllocation + currency = matrixWithAllocation.currency + discount = matrixWithAllocation.discount + externalPriceId = matrixWithAllocation.externalPriceId + fixedPriceQuantity = matrixWithAllocation.fixedPriceQuantity + invoicingCycleConfiguration = matrixWithAllocation.invoicingCycleConfiguration + item = matrixWithAllocation.item + matrixWithAllocationConfig = matrixWithAllocation.matrixWithAllocationConfig + maximum = matrixWithAllocation.maximum + maximumAmount = matrixWithAllocation.maximumAmount + metadata = matrixWithAllocation.metadata + minimum = matrixWithAllocation.minimum + minimumAmount = matrixWithAllocation.minimumAmount + modelType = matrixWithAllocation.modelType + name = matrixWithAllocation.name + planPhaseOrder = matrixWithAllocation.planPhaseOrder + priceType = matrixWithAllocation.priceType + replacesPriceId = matrixWithAllocation.replacesPriceId + dimensionalPriceConfiguration = matrixWithAllocation.dimensionalPriceConfiguration + additionalProperties = matrixWithAllocation.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) @@ -23413,6 +24461,34 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + fun compositePriceFilters(compositePriceFilters: List?) = + compositePriceFilters(JsonField.ofNullable(compositePriceFilters)) + + /** + * Sets [Builder.compositePriceFilters] to an arbitrary JSON value. + * + * You should usually call [Builder.compositePriceFilters] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun compositePriceFilters( + compositePriceFilters: JsonField> + ) = apply { + this.compositePriceFilters = compositePriceFilters.map { it.toMutableList() } + } + + /** + * Adds a single [TransformPriceFilter] to [compositePriceFilters]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addCompositePriceFilter(compositePriceFilter: TransformPriceFilter) = apply { + compositePriceFilters = + (compositePriceFilters ?: JsonField.of(mutableListOf())).also { + checkKnown("compositePriceFilters", it).add(compositePriceFilter) + } + } + fun conversionRate(conversionRate: Double?) = conversionRate(JsonField.ofNullable(conversionRate)) @@ -23680,6 +24756,20 @@ private constructor( */ fun item(item: JsonField) = apply { this.item = item } + fun matrixWithAllocationConfig(matrixWithAllocationConfig: MatrixWithAllocationConfig) = + matrixWithAllocationConfig(JsonField.of(matrixWithAllocationConfig)) + + /** + * Sets [Builder.matrixWithAllocationConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.matrixWithAllocationConfig] with a well-typed + * [MatrixWithAllocationConfig] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun matrixWithAllocationConfig( + matrixWithAllocationConfig: JsonField + ) = apply { this.matrixWithAllocationConfig = matrixWithAllocationConfig } + @Deprecated("deprecated") fun maximum(maximum: Maximum?) = maximum(JsonField.ofNullable(maximum)) @@ -23760,7 +24850,7 @@ private constructor( * It is usually unnecessary to call this method because the field defaults to the * following: * ```kotlin - * JsonValue.from("tiered_package_with_minimum") + * JsonValue.from("matrix_with_allocation") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -23829,21 +24919,6 @@ private constructor( this.replacesPriceId = replacesPriceId } - fun tieredPackageWithMinimumConfig( - tieredPackageWithMinimumConfig: TieredPackageWithMinimumConfig - ) = tieredPackageWithMinimumConfig(JsonField.of(tieredPackageWithMinimumConfig)) - - /** - * Sets [Builder.tieredPackageWithMinimumConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.tieredPackageWithMinimumConfig] with a well-typed - * [TieredPackageWithMinimumConfig] value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun tieredPackageWithMinimumConfig( - tieredPackageWithMinimumConfig: JsonField - ) = apply { this.tieredPackageWithMinimumConfig = tieredPackageWithMinimumConfig } - fun dimensionalPriceConfiguration( dimensionalPriceConfiguration: DimensionalPriceConfiguration? ) = dimensionalPriceConfiguration(JsonField.ofNullable(dimensionalPriceConfiguration)) @@ -23879,7 +24954,7 @@ private constructor( } /** - * Returns an immutable instance of [TieredPackageWithMinimum]. + * Returns an immutable instance of [MatrixWithAllocation]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -23889,6 +24964,7 @@ private constructor( * .billableMetric() * .billingCycleConfiguration() * .cadence() + * .compositePriceFilters() * .conversionRate() * .conversionRateConfig() * .createdAt() @@ -23899,6 +24975,7 @@ private constructor( * .fixedPriceQuantity() * .invoicingCycleConfiguration() * .item() + * .matrixWithAllocationConfig() * .maximum() * .maximumAmount() * .metadata() @@ -23908,17 +24985,19 @@ private constructor( * .planPhaseOrder() * .priceType() * .replacesPriceId() - * .tieredPackageWithMinimumConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): TieredPackageWithMinimum = - TieredPackageWithMinimum( + fun build(): MatrixWithAllocation = + MatrixWithAllocation( checkRequired("id", id), checkRequired("billableMetric", billableMetric), checkRequired("billingCycleConfiguration", billingCycleConfiguration), checkRequired("cadence", cadence), + checkRequired("compositePriceFilters", compositePriceFilters).map { + it.toImmutable() + }, checkRequired("conversionRate", conversionRate), checkRequired("conversionRateConfig", conversionRateConfig), checkRequired("createdAt", createdAt), @@ -23929,6 +25008,7 @@ private constructor( checkRequired("fixedPriceQuantity", fixedPriceQuantity), checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), checkRequired("item", item), + checkRequired("matrixWithAllocationConfig", matrixWithAllocationConfig), checkRequired("maximum", maximum), checkRequired("maximumAmount", maximumAmount), checkRequired("metadata", metadata), @@ -23939,7 +25019,6 @@ private constructor( checkRequired("planPhaseOrder", planPhaseOrder), checkRequired("priceType", priceType), checkRequired("replacesPriceId", replacesPriceId), - checkRequired("tieredPackageWithMinimumConfig", tieredPackageWithMinimumConfig), dimensionalPriceConfiguration, additionalProperties.toMutableMap(), ) @@ -23947,7 +25026,7 @@ private constructor( private var validated: Boolean = false - fun validate(): TieredPackageWithMinimum = apply { + fun validate(): MatrixWithAllocation = apply { if (validated) { return@apply } @@ -23956,6 +25035,7 @@ private constructor( billableMetric()?.validate() billingCycleConfiguration().validate() cadence().validate() + compositePriceFilters()?.forEach { it.validate() } conversionRate() conversionRateConfig()?.validate() createdAt() @@ -23966,13 +25046,14 @@ private constructor( fixedPriceQuantity() invoicingCycleConfiguration()?.validate() item().validate() + matrixWithAllocationConfig().validate() maximum()?.validate() maximumAmount() metadata().validate() minimum()?.validate() minimumAmount() _modelType().let { - if (it != JsonValue.from("tiered_package_with_minimum")) { + if (it != JsonValue.from("matrix_with_allocation")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } @@ -23980,7 +25061,6 @@ private constructor( planPhaseOrder() priceType().validate() replacesPriceId() - tieredPackageWithMinimumConfig().validate() dimensionalPriceConfiguration()?.validate() validated = true } @@ -24004,6 +25084,7 @@ private constructor( (billableMetric.asKnown()?.validity() ?: 0) + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + (cadence.asKnown()?.validity() ?: 0) + + (compositePriceFilters.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + (if (conversionRate.asKnown() == null) 0 else 1) + (conversionRateConfig.asKnown()?.validity() ?: 0) + (if (createdAt.asKnown() == null) 0 else 1) + @@ -24014,19 +25095,17 @@ private constructor( (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + (item.asKnown()?.validity() ?: 0) + + (matrixWithAllocationConfig.asKnown()?.validity() ?: 0) + (maximum.asKnown()?.validity() ?: 0) + (if (maximumAmount.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) + (minimum.asKnown()?.validity() ?: 0) + (if (minimumAmount.asKnown() == null) 0 else 1) + - modelType.let { - if (it == JsonValue.from("tiered_package_with_minimum")) 1 else 0 - } + + modelType.let { if (it == JsonValue.from("matrix_with_allocation")) 1 else 0 } + (if (name.asKnown() == null) 0 else 1) + (if (planPhaseOrder.asKnown() == null) 0 else 1) + (priceType.asKnown()?.validity() ?: 0) + (if (replacesPriceId.asKnown() == null) 0 else 1) + - (tieredPackageWithMinimumConfig.asKnown()?.validity() ?: 0) + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) class Cadence @JsonCreator private constructor(private val value: JsonField) : @@ -24415,124 +25494,17 @@ private constructor( override fun toString() = value.toString() } - class TieredPackageWithMinimumConfig - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [TieredPackageWithMinimumConfig]. - */ - fun builder() = Builder() - } - - /** A builder for [TieredPackageWithMinimumConfig]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(tieredPackageWithMinimumConfig: TieredPackageWithMinimumConfig) = - apply { - additionalProperties = - tieredPackageWithMinimumConfig.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [TieredPackageWithMinimumConfig]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): TieredPackageWithMinimumConfig = - TieredPackageWithMinimumConfig(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): TieredPackageWithMinimumConfig = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is TieredPackageWithMinimumConfig && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "TieredPackageWithMinimumConfig{additionalProperties=$additionalProperties}" - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is TieredPackageWithMinimum && + return other is MatrixWithAllocation && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && + compositePriceFilters == other.compositePriceFilters && conversionRate == other.conversionRate && conversionRateConfig == other.conversionRateConfig && createdAt == other.createdAt && @@ -24543,6 +25515,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && + matrixWithAllocationConfig == other.matrixWithAllocationConfig && maximum == other.maximum && maximumAmount == other.maximumAmount && metadata == other.metadata && @@ -24553,7 +25526,6 @@ private constructor( planPhaseOrder == other.planPhaseOrder && priceType == other.priceType && replacesPriceId == other.replacesPriceId && - tieredPackageWithMinimumConfig == other.tieredPackageWithMinimumConfig && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties } @@ -24564,6 +25536,7 @@ private constructor( billableMetric, billingCycleConfiguration, cadence, + compositePriceFilters, conversionRate, conversionRateConfig, createdAt, @@ -24574,6 +25547,7 @@ private constructor( fixedPriceQuantity, invoicingCycleConfiguration, item, + matrixWithAllocationConfig, maximum, maximumAmount, metadata, @@ -24584,7 +25558,6 @@ private constructor( planPhaseOrder, priceType, replacesPriceId, - tieredPackageWithMinimumConfig, dimensionalPriceConfiguration, additionalProperties, ) @@ -24593,15 +25566,16 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "TieredPackageWithMinimum{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, tieredPackageWithMinimumConfig=$tieredPackageWithMinimumConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "MatrixWithAllocation{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, matrixWithAllocationConfig=$matrixWithAllocationConfig, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" } - class PackageWithAllocation + class TieredWithProration private constructor( private val id: JsonField, private val billableMetric: JsonField, private val billingCycleConfiguration: JsonField, private val cadence: JsonField, + private val compositePriceFilters: JsonField>, private val conversionRate: JsonField, private val conversionRateConfig: JsonField, private val createdAt: JsonField, @@ -24619,10 +25593,10 @@ private constructor( private val minimumAmount: JsonField, private val modelType: JsonValue, private val name: JsonField, - private val packageWithAllocationConfig: JsonField, private val planPhaseOrder: JsonField, private val priceType: JsonField, private val replacesPriceId: JsonField, + private val tieredWithProrationConfig: JsonField, private val dimensionalPriceConfiguration: JsonField, private val additionalProperties: MutableMap, ) { @@ -24637,6 +25611,9 @@ private constructor( @ExcludeMissing billingCycleConfiguration: JsonField = JsonMissing.of(), @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), + @JsonProperty("composite_price_filters") + @ExcludeMissing + compositePriceFilters: JsonField> = JsonMissing.of(), @JsonProperty("conversion_rate") @ExcludeMissing conversionRate: JsonField = JsonMissing.of(), @@ -24678,9 +25655,6 @@ private constructor( minimumAmount: JsonField = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("package_with_allocation_config") - @ExcludeMissing - packageWithAllocationConfig: JsonField = JsonMissing.of(), @JsonProperty("plan_phase_order") @ExcludeMissing planPhaseOrder: JsonField = JsonMissing.of(), @@ -24690,6 +25664,9 @@ private constructor( @JsonProperty("replaces_price_id") @ExcludeMissing replacesPriceId: JsonField = JsonMissing.of(), + @JsonProperty("tiered_with_proration_config") + @ExcludeMissing + tieredWithProrationConfig: JsonField = JsonMissing.of(), @JsonProperty("dimensional_price_configuration") @ExcludeMissing dimensionalPriceConfiguration: JsonField = @@ -24699,6 +25676,7 @@ private constructor( billableMetric, billingCycleConfiguration, cadence, + compositePriceFilters, conversionRate, conversionRateConfig, createdAt, @@ -24716,10 +25694,10 @@ private constructor( minimumAmount, modelType, name, - packageWithAllocationConfig, planPhaseOrder, priceType, replacesPriceId, + tieredWithProrationConfig, dimensionalPriceConfiguration, mutableMapOf(), ) @@ -24749,6 +25727,13 @@ private constructor( */ fun cadence(): Cadence = cadence.getRequired("cadence") + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun compositePriceFilters(): List? = + compositePriceFilters.getNullable("composite_price_filters") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -24850,7 +25835,7 @@ private constructor( /** * Expected to always return the following: * ```kotlin - * JsonValue.from("package_with_allocation") + * JsonValue.from("tiered_with_proration") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -24864,13 +25849,6 @@ private constructor( */ fun name(): String = name.getRequired("name") - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun packageWithAllocationConfig(): PackageWithAllocationConfig = - packageWithAllocationConfig.getRequired("package_with_allocation_config") - /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -24892,6 +25870,13 @@ private constructor( */ fun replacesPriceId(): String? = replacesPriceId.getNullable("replaces_price_id") + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun tieredWithProrationConfig(): TieredWithProrationConfig = + tieredWithProrationConfig.getRequired("tiered_with_proration_config") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -24934,6 +25919,16 @@ private constructor( */ @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence + /** + * Returns the raw JSON value of [compositePriceFilters]. + * + * Unlike [compositePriceFilters], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("composite_price_filters") + @ExcludeMissing + fun _compositePriceFilters(): JsonField> = compositePriceFilters + /** * Returns the raw JSON value of [conversionRate]. * @@ -25084,17 +26079,6 @@ private constructor( */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - /** - * Returns the raw JSON value of [packageWithAllocationConfig]. - * - * Unlike [packageWithAllocationConfig], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("package_with_allocation_config") - @ExcludeMissing - fun _packageWithAllocationConfig(): JsonField = - packageWithAllocationConfig - /** * Returns the raw JSON value of [planPhaseOrder]. * @@ -25124,6 +26108,17 @@ private constructor( @ExcludeMissing fun _replacesPriceId(): JsonField = replacesPriceId + /** + * Returns the raw JSON value of [tieredWithProrationConfig]. + * + * Unlike [tieredWithProrationConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("tiered_with_proration_config") + @ExcludeMissing + fun _tieredWithProrationConfig(): JsonField = + tieredWithProrationConfig + /** * Returns the raw JSON value of [dimensionalPriceConfiguration]. * @@ -25150,7 +26145,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [PackageWithAllocation]. + * Returns a mutable builder for constructing an instance of [TieredWithProration]. * * The following fields are required: * ```kotlin @@ -25158,6 +26153,7 @@ private constructor( * .billableMetric() * .billingCycleConfiguration() * .cadence() + * .compositePriceFilters() * .conversionRate() * .conversionRateConfig() * .createdAt() @@ -25174,22 +26170,23 @@ private constructor( * .minimum() * .minimumAmount() * .name() - * .packageWithAllocationConfig() * .planPhaseOrder() * .priceType() * .replacesPriceId() + * .tieredWithProrationConfig() * ``` */ fun builder() = Builder() } - /** A builder for [PackageWithAllocation]. */ + /** A builder for [TieredWithProration]. */ class Builder internal constructor() { private var id: JsonField? = null private var billableMetric: JsonField? = null private var billingCycleConfiguration: JsonField? = null private var cadence: JsonField? = null + private var compositePriceFilters: JsonField>? = null private var conversionRate: JsonField? = null private var conversionRateConfig: JsonField? = null private var createdAt: JsonField? = null @@ -25205,44 +26202,46 @@ private constructor( private var metadata: JsonField? = null private var minimum: JsonField? = null private var minimumAmount: JsonField? = null - private var modelType: JsonValue = JsonValue.from("package_with_allocation") + private var modelType: JsonValue = JsonValue.from("tiered_with_proration") private var name: JsonField? = null - private var packageWithAllocationConfig: JsonField? = null private var planPhaseOrder: JsonField? = null private var priceType: JsonField? = null private var replacesPriceId: JsonField? = null + private var tieredWithProrationConfig: JsonField? = null private var dimensionalPriceConfiguration: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(packageWithAllocation: PackageWithAllocation) = apply { - id = packageWithAllocation.id - billableMetric = packageWithAllocation.billableMetric - billingCycleConfiguration = packageWithAllocation.billingCycleConfiguration - cadence = packageWithAllocation.cadence - conversionRate = packageWithAllocation.conversionRate - conversionRateConfig = packageWithAllocation.conversionRateConfig - createdAt = packageWithAllocation.createdAt - creditAllocation = packageWithAllocation.creditAllocation - currency = packageWithAllocation.currency - discount = packageWithAllocation.discount - externalPriceId = packageWithAllocation.externalPriceId - fixedPriceQuantity = packageWithAllocation.fixedPriceQuantity - invoicingCycleConfiguration = packageWithAllocation.invoicingCycleConfiguration - item = packageWithAllocation.item - maximum = packageWithAllocation.maximum - maximumAmount = packageWithAllocation.maximumAmount - metadata = packageWithAllocation.metadata - minimum = packageWithAllocation.minimum - minimumAmount = packageWithAllocation.minimumAmount - modelType = packageWithAllocation.modelType - name = packageWithAllocation.name - packageWithAllocationConfig = packageWithAllocation.packageWithAllocationConfig - planPhaseOrder = packageWithAllocation.planPhaseOrder - priceType = packageWithAllocation.priceType - replacesPriceId = packageWithAllocation.replacesPriceId - dimensionalPriceConfiguration = packageWithAllocation.dimensionalPriceConfiguration - additionalProperties = packageWithAllocation.additionalProperties.toMutableMap() + internal fun from(tieredWithProration: TieredWithProration) = apply { + id = tieredWithProration.id + billableMetric = tieredWithProration.billableMetric + billingCycleConfiguration = tieredWithProration.billingCycleConfiguration + cadence = tieredWithProration.cadence + compositePriceFilters = + tieredWithProration.compositePriceFilters.map { it.toMutableList() } + conversionRate = tieredWithProration.conversionRate + conversionRateConfig = tieredWithProration.conversionRateConfig + createdAt = tieredWithProration.createdAt + creditAllocation = tieredWithProration.creditAllocation + currency = tieredWithProration.currency + discount = tieredWithProration.discount + externalPriceId = tieredWithProration.externalPriceId + fixedPriceQuantity = tieredWithProration.fixedPriceQuantity + invoicingCycleConfiguration = tieredWithProration.invoicingCycleConfiguration + item = tieredWithProration.item + maximum = tieredWithProration.maximum + maximumAmount = tieredWithProration.maximumAmount + metadata = tieredWithProration.metadata + minimum = tieredWithProration.minimum + minimumAmount = tieredWithProration.minimumAmount + modelType = tieredWithProration.modelType + name = tieredWithProration.name + planPhaseOrder = tieredWithProration.planPhaseOrder + priceType = tieredWithProration.priceType + replacesPriceId = tieredWithProration.replacesPriceId + tieredWithProrationConfig = tieredWithProration.tieredWithProrationConfig + dimensionalPriceConfiguration = tieredWithProration.dimensionalPriceConfiguration + additionalProperties = tieredWithProration.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) @@ -25295,6 +26294,34 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + fun compositePriceFilters(compositePriceFilters: List?) = + compositePriceFilters(JsonField.ofNullable(compositePriceFilters)) + + /** + * Sets [Builder.compositePriceFilters] to an arbitrary JSON value. + * + * You should usually call [Builder.compositePriceFilters] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun compositePriceFilters( + compositePriceFilters: JsonField> + ) = apply { + this.compositePriceFilters = compositePriceFilters.map { it.toMutableList() } + } + + /** + * Adds a single [TransformPriceFilter] to [compositePriceFilters]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addCompositePriceFilter(compositePriceFilter: TransformPriceFilter) = apply { + compositePriceFilters = + (compositePriceFilters ?: JsonField.of(mutableListOf())).also { + checkKnown("compositePriceFilters", it).add(compositePriceFilter) + } + } + fun conversionRate(conversionRate: Double?) = conversionRate(JsonField.ofNullable(conversionRate)) @@ -25642,7 +26669,7 @@ private constructor( * It is usually unnecessary to call this method because the field defaults to the * following: * ```kotlin - * JsonValue.from("package_with_allocation") + * JsonValue.from("tiered_with_proration") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -25661,21 +26688,6 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } - fun packageWithAllocationConfig( - packageWithAllocationConfig: PackageWithAllocationConfig - ) = packageWithAllocationConfig(JsonField.of(packageWithAllocationConfig)) - - /** - * Sets [Builder.packageWithAllocationConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.packageWithAllocationConfig] with a well-typed - * [PackageWithAllocationConfig] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun packageWithAllocationConfig( - packageWithAllocationConfig: JsonField - ) = apply { this.packageWithAllocationConfig = packageWithAllocationConfig } - fun planPhaseOrder(planPhaseOrder: Long?) = planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) @@ -25726,6 +26738,20 @@ private constructor( this.replacesPriceId = replacesPriceId } + fun tieredWithProrationConfig(tieredWithProrationConfig: TieredWithProrationConfig) = + tieredWithProrationConfig(JsonField.of(tieredWithProrationConfig)) + + /** + * Sets [Builder.tieredWithProrationConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.tieredWithProrationConfig] with a well-typed + * [TieredWithProrationConfig] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tieredWithProrationConfig( + tieredWithProrationConfig: JsonField + ) = apply { this.tieredWithProrationConfig = tieredWithProrationConfig } + fun dimensionalPriceConfiguration( dimensionalPriceConfiguration: DimensionalPriceConfiguration? ) = dimensionalPriceConfiguration(JsonField.ofNullable(dimensionalPriceConfiguration)) @@ -25761,7 +26787,7 @@ private constructor( } /** - * Returns an immutable instance of [PackageWithAllocation]. + * Returns an immutable instance of [TieredWithProration]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -25771,6 +26797,7 @@ private constructor( * .billableMetric() * .billingCycleConfiguration() * .cadence() + * .compositePriceFilters() * .conversionRate() * .conversionRateConfig() * .createdAt() @@ -25787,20 +26814,23 @@ private constructor( * .minimum() * .minimumAmount() * .name() - * .packageWithAllocationConfig() * .planPhaseOrder() * .priceType() * .replacesPriceId() + * .tieredWithProrationConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): PackageWithAllocation = - PackageWithAllocation( + fun build(): TieredWithProration = + TieredWithProration( checkRequired("id", id), checkRequired("billableMetric", billableMetric), checkRequired("billingCycleConfiguration", billingCycleConfiguration), checkRequired("cadence", cadence), + checkRequired("compositePriceFilters", compositePriceFilters).map { + it.toImmutable() + }, checkRequired("conversionRate", conversionRate), checkRequired("conversionRateConfig", conversionRateConfig), checkRequired("createdAt", createdAt), @@ -25818,10 +26848,10 @@ private constructor( checkRequired("minimumAmount", minimumAmount), modelType, checkRequired("name", name), - checkRequired("packageWithAllocationConfig", packageWithAllocationConfig), checkRequired("planPhaseOrder", planPhaseOrder), checkRequired("priceType", priceType), checkRequired("replacesPriceId", replacesPriceId), + checkRequired("tieredWithProrationConfig", tieredWithProrationConfig), dimensionalPriceConfiguration, additionalProperties.toMutableMap(), ) @@ -25829,7 +26859,7 @@ private constructor( private var validated: Boolean = false - fun validate(): PackageWithAllocation = apply { + fun validate(): TieredWithProration = apply { if (validated) { return@apply } @@ -25838,6 +26868,7 @@ private constructor( billableMetric()?.validate() billingCycleConfiguration().validate() cadence().validate() + compositePriceFilters()?.forEach { it.validate() } conversionRate() conversionRateConfig()?.validate() createdAt() @@ -25854,15 +26885,15 @@ private constructor( minimum()?.validate() minimumAmount() _modelType().let { - if (it != JsonValue.from("package_with_allocation")) { + if (it != JsonValue.from("tiered_with_proration")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } name() - packageWithAllocationConfig().validate() planPhaseOrder() priceType().validate() replacesPriceId() + tieredWithProrationConfig().validate() dimensionalPriceConfiguration()?.validate() validated = true } @@ -25886,6 +26917,7 @@ private constructor( (billableMetric.asKnown()?.validity() ?: 0) + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + (cadence.asKnown()?.validity() ?: 0) + + (compositePriceFilters.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + (if (conversionRate.asKnown() == null) 0 else 1) + (conversionRateConfig.asKnown()?.validity() ?: 0) + (if (createdAt.asKnown() == null) 0 else 1) + @@ -25901,12 +26933,12 @@ private constructor( (metadata.asKnown()?.validity() ?: 0) + (minimum.asKnown()?.validity() ?: 0) + (if (minimumAmount.asKnown() == null) 0 else 1) + - modelType.let { if (it == JsonValue.from("package_with_allocation")) 1 else 0 } + + modelType.let { if (it == JsonValue.from("tiered_with_proration")) 1 else 0 } + (if (name.asKnown() == null) 0 else 1) + - (packageWithAllocationConfig.asKnown()?.validity() ?: 0) + (if (planPhaseOrder.asKnown() == null) 0 else 1) + (priceType.asKnown()?.validity() ?: 0) + (if (replacesPriceId.asKnown() == null) 0 else 1) + + (tieredWithProrationConfig.asKnown()?.validity() ?: 0) + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) class Cadence @JsonCreator private constructor(private val value: JsonField) : @@ -26166,114 +27198,6 @@ private constructor( override fun toString() = "Metadata{additionalProperties=$additionalProperties}" } - class PackageWithAllocationConfig - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [PackageWithAllocationConfig]. - */ - fun builder() = Builder() - } - - /** A builder for [PackageWithAllocationConfig]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(packageWithAllocationConfig: PackageWithAllocationConfig) = - apply { - additionalProperties = - packageWithAllocationConfig.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [PackageWithAllocationConfig]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): PackageWithAllocationConfig = - PackageWithAllocationConfig(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): PackageWithAllocationConfig = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is PackageWithAllocationConfig && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "PackageWithAllocationConfig{additionalProperties=$additionalProperties}" - } - class PriceType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -26403,16 +27327,124 @@ private constructor( override fun toString() = value.toString() } + class TieredWithProrationConfig + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [TieredWithProrationConfig]. + */ + fun builder() = Builder() + } + + /** A builder for [TieredWithProrationConfig]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(tieredWithProrationConfig: TieredWithProrationConfig) = apply { + additionalProperties = + tieredWithProrationConfig.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [TieredWithProrationConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): TieredWithProrationConfig = + TieredWithProrationConfig(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): TieredWithProrationConfig = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TieredWithProrationConfig && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TieredWithProrationConfig{additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is PackageWithAllocation && + return other is TieredWithProration && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && + compositePriceFilters == other.compositePriceFilters && conversionRate == other.conversionRate && conversionRateConfig == other.conversionRateConfig && createdAt == other.createdAt && @@ -26430,10 +27462,10 @@ private constructor( minimumAmount == other.minimumAmount && modelType == other.modelType && name == other.name && - packageWithAllocationConfig == other.packageWithAllocationConfig && planPhaseOrder == other.planPhaseOrder && priceType == other.priceType && replacesPriceId == other.replacesPriceId && + tieredWithProrationConfig == other.tieredWithProrationConfig && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties } @@ -26444,6 +27476,7 @@ private constructor( billableMetric, billingCycleConfiguration, cadence, + compositePriceFilters, conversionRate, conversionRateConfig, createdAt, @@ -26461,10 +27494,10 @@ private constructor( minimumAmount, modelType, name, - packageWithAllocationConfig, planPhaseOrder, priceType, replacesPriceId, + tieredWithProrationConfig, dimensionalPriceConfiguration, additionalProperties, ) @@ -26473,15 +27506,16 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "PackageWithAllocation{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, packageWithAllocationConfig=$packageWithAllocationConfig, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "TieredWithProration{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, tieredWithProrationConfig=$tieredWithProrationConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" } - class UnitWithPercent + class UnitWithProration private constructor( private val id: JsonField, private val billableMetric: JsonField, private val billingCycleConfiguration: JsonField, private val cadence: JsonField, + private val compositePriceFilters: JsonField>, private val conversionRate: JsonField, private val conversionRateConfig: JsonField, private val createdAt: JsonField, @@ -26502,7 +27536,7 @@ private constructor( private val planPhaseOrder: JsonField, private val priceType: JsonField, private val replacesPriceId: JsonField, - private val unitWithPercentConfig: JsonField, + private val unitWithProrationConfig: JsonField, private val dimensionalPriceConfiguration: JsonField, private val additionalProperties: MutableMap, ) { @@ -26517,6 +27551,9 @@ private constructor( @ExcludeMissing billingCycleConfiguration: JsonField = JsonMissing.of(), @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), + @JsonProperty("composite_price_filters") + @ExcludeMissing + compositePriceFilters: JsonField> = JsonMissing.of(), @JsonProperty("conversion_rate") @ExcludeMissing conversionRate: JsonField = JsonMissing.of(), @@ -26567,9 +27604,9 @@ private constructor( @JsonProperty("replaces_price_id") @ExcludeMissing replacesPriceId: JsonField = JsonMissing.of(), - @JsonProperty("unit_with_percent_config") + @JsonProperty("unit_with_proration_config") @ExcludeMissing - unitWithPercentConfig: JsonField = JsonMissing.of(), + unitWithProrationConfig: JsonField = JsonMissing.of(), @JsonProperty("dimensional_price_configuration") @ExcludeMissing dimensionalPriceConfiguration: JsonField = @@ -26579,6 +27616,7 @@ private constructor( billableMetric, billingCycleConfiguration, cadence, + compositePriceFilters, conversionRate, conversionRateConfig, createdAt, @@ -26599,7 +27637,7 @@ private constructor( planPhaseOrder, priceType, replacesPriceId, - unitWithPercentConfig, + unitWithProrationConfig, dimensionalPriceConfiguration, mutableMapOf(), ) @@ -26629,6 +27667,13 @@ private constructor( */ fun cadence(): Cadence = cadence.getRequired("cadence") + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun compositePriceFilters(): List? = + compositePriceFilters.getNullable("composite_price_filters") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -26730,7 +27775,7 @@ private constructor( /** * Expected to always return the following: * ```kotlin - * JsonValue.from("unit_with_percent") + * JsonValue.from("unit_with_proration") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -26769,8 +27814,8 @@ private constructor( * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ - fun unitWithPercentConfig(): UnitWithPercentConfig = - unitWithPercentConfig.getRequired("unit_with_percent_config") + fun unitWithProrationConfig(): UnitWithProrationConfig = + unitWithProrationConfig.getRequired("unit_with_proration_config") /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the @@ -26814,6 +27859,16 @@ private constructor( */ @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence + /** + * Returns the raw JSON value of [compositePriceFilters]. + * + * Unlike [compositePriceFilters], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("composite_price_filters") + @ExcludeMissing + fun _compositePriceFilters(): JsonField> = compositePriceFilters + /** * Returns the raw JSON value of [conversionRate]. * @@ -26994,14 +28049,14 @@ private constructor( fun _replacesPriceId(): JsonField = replacesPriceId /** - * Returns the raw JSON value of [unitWithPercentConfig]. + * Returns the raw JSON value of [unitWithProrationConfig]. * - * Unlike [unitWithPercentConfig], this method doesn't throw if the JSON field has an + * Unlike [unitWithProrationConfig], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("unit_with_percent_config") + @JsonProperty("unit_with_proration_config") @ExcludeMissing - fun _unitWithPercentConfig(): JsonField = unitWithPercentConfig + fun _unitWithProrationConfig(): JsonField = unitWithProrationConfig /** * Returns the raw JSON value of [dimensionalPriceConfiguration]. @@ -27029,7 +28084,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [UnitWithPercent]. + * Returns a mutable builder for constructing an instance of [UnitWithProration]. * * The following fields are required: * ```kotlin @@ -27037,6 +28092,7 @@ private constructor( * .billableMetric() * .billingCycleConfiguration() * .cadence() + * .compositePriceFilters() * .conversionRate() * .conversionRateConfig() * .createdAt() @@ -27056,19 +28112,20 @@ private constructor( * .planPhaseOrder() * .priceType() * .replacesPriceId() - * .unitWithPercentConfig() + * .unitWithProrationConfig() * ``` */ fun builder() = Builder() } - /** A builder for [UnitWithPercent]. */ + /** A builder for [UnitWithProration]. */ class Builder internal constructor() { private var id: JsonField? = null private var billableMetric: JsonField? = null private var billingCycleConfiguration: JsonField? = null private var cadence: JsonField? = null + private var compositePriceFilters: JsonField>? = null private var conversionRate: JsonField? = null private var conversionRateConfig: JsonField? = null private var createdAt: JsonField? = null @@ -27084,44 +28141,46 @@ private constructor( private var metadata: JsonField? = null private var minimum: JsonField? = null private var minimumAmount: JsonField? = null - private var modelType: JsonValue = JsonValue.from("unit_with_percent") + private var modelType: JsonValue = JsonValue.from("unit_with_proration") private var name: JsonField? = null private var planPhaseOrder: JsonField? = null private var priceType: JsonField? = null private var replacesPriceId: JsonField? = null - private var unitWithPercentConfig: JsonField? = null + private var unitWithProrationConfig: JsonField? = null private var dimensionalPriceConfiguration: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(unitWithPercent: UnitWithPercent) = apply { - id = unitWithPercent.id - billableMetric = unitWithPercent.billableMetric - billingCycleConfiguration = unitWithPercent.billingCycleConfiguration - cadence = unitWithPercent.cadence - conversionRate = unitWithPercent.conversionRate - conversionRateConfig = unitWithPercent.conversionRateConfig - createdAt = unitWithPercent.createdAt - creditAllocation = unitWithPercent.creditAllocation - currency = unitWithPercent.currency - discount = unitWithPercent.discount - externalPriceId = unitWithPercent.externalPriceId - fixedPriceQuantity = unitWithPercent.fixedPriceQuantity - invoicingCycleConfiguration = unitWithPercent.invoicingCycleConfiguration - item = unitWithPercent.item - maximum = unitWithPercent.maximum - maximumAmount = unitWithPercent.maximumAmount - metadata = unitWithPercent.metadata - minimum = unitWithPercent.minimum - minimumAmount = unitWithPercent.minimumAmount - modelType = unitWithPercent.modelType - name = unitWithPercent.name - planPhaseOrder = unitWithPercent.planPhaseOrder - priceType = unitWithPercent.priceType - replacesPriceId = unitWithPercent.replacesPriceId - unitWithPercentConfig = unitWithPercent.unitWithPercentConfig - dimensionalPriceConfiguration = unitWithPercent.dimensionalPriceConfiguration - additionalProperties = unitWithPercent.additionalProperties.toMutableMap() + internal fun from(unitWithProration: UnitWithProration) = apply { + id = unitWithProration.id + billableMetric = unitWithProration.billableMetric + billingCycleConfiguration = unitWithProration.billingCycleConfiguration + cadence = unitWithProration.cadence + compositePriceFilters = + unitWithProration.compositePriceFilters.map { it.toMutableList() } + conversionRate = unitWithProration.conversionRate + conversionRateConfig = unitWithProration.conversionRateConfig + createdAt = unitWithProration.createdAt + creditAllocation = unitWithProration.creditAllocation + currency = unitWithProration.currency + discount = unitWithProration.discount + externalPriceId = unitWithProration.externalPriceId + fixedPriceQuantity = unitWithProration.fixedPriceQuantity + invoicingCycleConfiguration = unitWithProration.invoicingCycleConfiguration + item = unitWithProration.item + maximum = unitWithProration.maximum + maximumAmount = unitWithProration.maximumAmount + metadata = unitWithProration.metadata + minimum = unitWithProration.minimum + minimumAmount = unitWithProration.minimumAmount + modelType = unitWithProration.modelType + name = unitWithProration.name + planPhaseOrder = unitWithProration.planPhaseOrder + priceType = unitWithProration.priceType + replacesPriceId = unitWithProration.replacesPriceId + unitWithProrationConfig = unitWithProration.unitWithProrationConfig + dimensionalPriceConfiguration = unitWithProration.dimensionalPriceConfiguration + additionalProperties = unitWithProration.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) @@ -27174,6 +28233,34 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + fun compositePriceFilters(compositePriceFilters: List?) = + compositePriceFilters(JsonField.ofNullable(compositePriceFilters)) + + /** + * Sets [Builder.compositePriceFilters] to an arbitrary JSON value. + * + * You should usually call [Builder.compositePriceFilters] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun compositePriceFilters( + compositePriceFilters: JsonField> + ) = apply { + this.compositePriceFilters = compositePriceFilters.map { it.toMutableList() } + } + + /** + * Adds a single [TransformPriceFilter] to [compositePriceFilters]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addCompositePriceFilter(compositePriceFilter: TransformPriceFilter) = apply { + compositePriceFilters = + (compositePriceFilters ?: JsonField.of(mutableListOf())).also { + checkKnown("compositePriceFilters", it).add(compositePriceFilter) + } + } + fun conversionRate(conversionRate: Double?) = conversionRate(JsonField.ofNullable(conversionRate)) @@ -27521,7 +28608,7 @@ private constructor( * It is usually unnecessary to call this method because the field defaults to the * following: * ```kotlin - * JsonValue.from("unit_with_percent") + * JsonValue.from("unit_with_proration") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -27590,20 +28677,19 @@ private constructor( this.replacesPriceId = replacesPriceId } - fun unitWithPercentConfig(unitWithPercentConfig: UnitWithPercentConfig) = - unitWithPercentConfig(JsonField.of(unitWithPercentConfig)) + fun unitWithProrationConfig(unitWithProrationConfig: UnitWithProrationConfig) = + unitWithProrationConfig(JsonField.of(unitWithProrationConfig)) /** - * Sets [Builder.unitWithPercentConfig] to an arbitrary JSON value. + * Sets [Builder.unitWithProrationConfig] to an arbitrary JSON value. * - * You should usually call [Builder.unitWithPercentConfig] with a well-typed - * [UnitWithPercentConfig] value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. + * You should usually call [Builder.unitWithProrationConfig] with a well-typed + * [UnitWithProrationConfig] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. */ - fun unitWithPercentConfig(unitWithPercentConfig: JsonField) = - apply { - this.unitWithPercentConfig = unitWithPercentConfig - } + fun unitWithProrationConfig( + unitWithProrationConfig: JsonField + ) = apply { this.unitWithProrationConfig = unitWithProrationConfig } fun dimensionalPriceConfiguration( dimensionalPriceConfiguration: DimensionalPriceConfiguration? @@ -27640,7 +28726,7 @@ private constructor( } /** - * Returns an immutable instance of [UnitWithPercent]. + * Returns an immutable instance of [UnitWithProration]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -27650,6 +28736,7 @@ private constructor( * .billableMetric() * .billingCycleConfiguration() * .cadence() + * .compositePriceFilters() * .conversionRate() * .conversionRateConfig() * .createdAt() @@ -27669,17 +28756,20 @@ private constructor( * .planPhaseOrder() * .priceType() * .replacesPriceId() - * .unitWithPercentConfig() + * .unitWithProrationConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): UnitWithPercent = - UnitWithPercent( + fun build(): UnitWithProration = + UnitWithProration( checkRequired("id", id), checkRequired("billableMetric", billableMetric), checkRequired("billingCycleConfiguration", billingCycleConfiguration), checkRequired("cadence", cadence), + checkRequired("compositePriceFilters", compositePriceFilters).map { + it.toImmutable() + }, checkRequired("conversionRate", conversionRate), checkRequired("conversionRateConfig", conversionRateConfig), checkRequired("createdAt", createdAt), @@ -27700,7 +28790,7 @@ private constructor( checkRequired("planPhaseOrder", planPhaseOrder), checkRequired("priceType", priceType), checkRequired("replacesPriceId", replacesPriceId), - checkRequired("unitWithPercentConfig", unitWithPercentConfig), + checkRequired("unitWithProrationConfig", unitWithProrationConfig), dimensionalPriceConfiguration, additionalProperties.toMutableMap(), ) @@ -27708,7 +28798,7 @@ private constructor( private var validated: Boolean = false - fun validate(): UnitWithPercent = apply { + fun validate(): UnitWithProration = apply { if (validated) { return@apply } @@ -27717,6 +28807,7 @@ private constructor( billableMetric()?.validate() billingCycleConfiguration().validate() cadence().validate() + compositePriceFilters()?.forEach { it.validate() } conversionRate() conversionRateConfig()?.validate() createdAt() @@ -27733,7 +28824,7 @@ private constructor( minimum()?.validate() minimumAmount() _modelType().let { - if (it != JsonValue.from("unit_with_percent")) { + if (it != JsonValue.from("unit_with_proration")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } @@ -27741,7 +28832,7 @@ private constructor( planPhaseOrder() priceType().validate() replacesPriceId() - unitWithPercentConfig().validate() + unitWithProrationConfig().validate() dimensionalPriceConfiguration()?.validate() validated = true } @@ -27765,6 +28856,7 @@ private constructor( (billableMetric.asKnown()?.validity() ?: 0) + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + (cadence.asKnown()?.validity() ?: 0) + + (compositePriceFilters.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + (if (conversionRate.asKnown() == null) 0 else 1) + (conversionRateConfig.asKnown()?.validity() ?: 0) + (if (createdAt.asKnown() == null) 0 else 1) + @@ -27780,12 +28872,12 @@ private constructor( (metadata.asKnown()?.validity() ?: 0) + (minimum.asKnown()?.validity() ?: 0) + (if (minimumAmount.asKnown() == null) 0 else 1) + - modelType.let { if (it == JsonValue.from("unit_with_percent")) 1 else 0 } + + modelType.let { if (it == JsonValue.from("unit_with_proration")) 1 else 0 } + (if (name.asKnown() == null) 0 else 1) + (if (planPhaseOrder.asKnown() == null) 0 else 1) + (priceType.asKnown()?.validity() ?: 0) + (if (replacesPriceId.asKnown() == null) 0 else 1) + - (unitWithPercentConfig.asKnown()?.validity() ?: 0) + + (unitWithProrationConfig.asKnown()?.validity() ?: 0) + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) class Cadence @JsonCreator private constructor(private val value: JsonField) : @@ -28174,7 +29266,7 @@ private constructor( override fun toString() = value.toString() } - class UnitWithPercentConfig + class UnitWithProrationConfig @JsonCreator private constructor( @com.fasterxml.jackson.annotation.JsonValue @@ -28191,18 +29283,19 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [UnitWithPercentConfig]. + * [UnitWithProrationConfig]. */ fun builder() = Builder() } - /** A builder for [UnitWithPercentConfig]. */ + /** A builder for [UnitWithProrationConfig]. */ class Builder internal constructor() { private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(unitWithPercentConfig: UnitWithPercentConfig) = apply { - additionalProperties = unitWithPercentConfig.additionalProperties.toMutableMap() + internal fun from(unitWithProrationConfig: UnitWithProrationConfig) = apply { + additionalProperties = + unitWithProrationConfig.additionalProperties.toMutableMap() } fun additionalProperties(additionalProperties: Map) = apply { @@ -28228,17 +29321,17 @@ private constructor( } /** - * Returns an immutable instance of [UnitWithPercentConfig]. + * Returns an immutable instance of [UnitWithProrationConfig]. * * Further updates to this [Builder] will not mutate the returned instance. */ - fun build(): UnitWithPercentConfig = - UnitWithPercentConfig(additionalProperties.toImmutable()) + fun build(): UnitWithProrationConfig = + UnitWithProrationConfig(additionalProperties.toImmutable()) } private var validated: Boolean = false - fun validate(): UnitWithPercentConfig = apply { + fun validate(): UnitWithProrationConfig = apply { if (validated) { return@apply } @@ -28268,7 +29361,7 @@ private constructor( return true } - return other is UnitWithPercentConfig && + return other is UnitWithProrationConfig && additionalProperties == other.additionalProperties } @@ -28277,7 +29370,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "UnitWithPercentConfig{additionalProperties=$additionalProperties}" + "UnitWithProrationConfig{additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { @@ -28285,11 +29378,12 @@ private constructor( return true } - return other is UnitWithPercent && + return other is UnitWithProration && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && + compositePriceFilters == other.compositePriceFilters && conversionRate == other.conversionRate && conversionRateConfig == other.conversionRateConfig && createdAt == other.createdAt && @@ -28310,7 +29404,7 @@ private constructor( planPhaseOrder == other.planPhaseOrder && priceType == other.priceType && replacesPriceId == other.replacesPriceId && - unitWithPercentConfig == other.unitWithPercentConfig && + unitWithProrationConfig == other.unitWithProrationConfig && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties } @@ -28321,6 +29415,7 @@ private constructor( billableMetric, billingCycleConfiguration, cadence, + compositePriceFilters, conversionRate, conversionRateConfig, createdAt, @@ -28341,7 +29436,7 @@ private constructor( planPhaseOrder, priceType, replacesPriceId, - unitWithPercentConfig, + unitWithProrationConfig, dimensionalPriceConfiguration, additionalProperties, ) @@ -28350,15 +29445,16 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "UnitWithPercent{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, unitWithPercentConfig=$unitWithPercentConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "UnitWithProration{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, unitWithProrationConfig=$unitWithProrationConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" } - class MatrixWithAllocation + class GroupedAllocation private constructor( private val id: JsonField, private val billableMetric: JsonField, private val billingCycleConfiguration: JsonField, private val cadence: JsonField, + private val compositePriceFilters: JsonField>, private val conversionRate: JsonField, private val conversionRateConfig: JsonField, private val createdAt: JsonField, @@ -28367,9 +29463,9 @@ private constructor( private val discount: JsonField, private val externalPriceId: JsonField, private val fixedPriceQuantity: JsonField, + private val groupedAllocationConfig: JsonField, private val invoicingCycleConfiguration: JsonField, private val item: JsonField, - private val matrixWithAllocationConfig: JsonField, private val maximum: JsonField, private val maximumAmount: JsonField, private val metadata: JsonField, @@ -28394,6 +29490,9 @@ private constructor( @ExcludeMissing billingCycleConfiguration: JsonField = JsonMissing.of(), @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), + @JsonProperty("composite_price_filters") + @ExcludeMissing + compositePriceFilters: JsonField> = JsonMissing.of(), @JsonProperty("conversion_rate") @ExcludeMissing conversionRate: JsonField = JsonMissing.of(), @@ -28418,13 +29517,13 @@ private constructor( @JsonProperty("fixed_price_quantity") @ExcludeMissing fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("grouped_allocation_config") + @ExcludeMissing + groupedAllocationConfig: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), @JsonProperty("item") @ExcludeMissing item: JsonField = JsonMissing.of(), - @JsonProperty("matrix_with_allocation_config") - @ExcludeMissing - matrixWithAllocationConfig: JsonField = JsonMissing.of(), @JsonProperty("maximum") @ExcludeMissing maximum: JsonField = JsonMissing.of(), @JsonProperty("maximum_amount") @ExcludeMissing @@ -28456,6 +29555,7 @@ private constructor( billableMetric, billingCycleConfiguration, cadence, + compositePriceFilters, conversionRate, conversionRateConfig, createdAt, @@ -28464,9 +29564,9 @@ private constructor( discount, externalPriceId, fixedPriceQuantity, + groupedAllocationConfig, invoicingCycleConfiguration, item, - matrixWithAllocationConfig, maximum, maximumAmount, metadata, @@ -28506,6 +29606,13 @@ private constructor( */ fun cadence(): Cadence = cadence.getRequired("cadence") + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun compositePriceFilters(): List? = + compositePriceFilters.getNullable("composite_price_filters") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -28555,6 +29662,13 @@ private constructor( */ fun fixedPriceQuantity(): Double? = fixedPriceQuantity.getNullable("fixed_price_quantity") + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun groupedAllocationConfig(): GroupedAllocationConfig = + groupedAllocationConfig.getRequired("grouped_allocation_config") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -28568,13 +29682,6 @@ private constructor( */ fun item(): ItemSlim = item.getRequired("item") - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun matrixWithAllocationConfig(): MatrixWithAllocationConfig = - matrixWithAllocationConfig.getRequired("matrix_with_allocation_config") - /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -28614,7 +29721,7 @@ private constructor( /** * Expected to always return the following: * ```kotlin - * JsonValue.from("matrix_with_allocation") + * JsonValue.from("grouped_allocation") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -28691,6 +29798,16 @@ private constructor( */ @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence + /** + * Returns the raw JSON value of [compositePriceFilters]. + * + * Unlike [compositePriceFilters], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("composite_price_filters") + @ExcludeMissing + fun _compositePriceFilters(): JsonField> = compositePriceFilters + /** * Returns the raw JSON value of [conversionRate]. * @@ -28767,6 +29884,16 @@ private constructor( @ExcludeMissing fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + /** + * Returns the raw JSON value of [groupedAllocationConfig]. + * + * Unlike [groupedAllocationConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouped_allocation_config") + @ExcludeMissing + fun _groupedAllocationConfig(): JsonField = groupedAllocationConfig + /** * Returns the raw JSON value of [invoicingCycleConfiguration]. * @@ -28785,17 +29912,6 @@ private constructor( */ @JsonProperty("item") @ExcludeMissing fun _item(): JsonField = item - /** - * Returns the raw JSON value of [matrixWithAllocationConfig]. - * - * Unlike [matrixWithAllocationConfig], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("matrix_with_allocation_config") - @ExcludeMissing - fun _matrixWithAllocationConfig(): JsonField = - matrixWithAllocationConfig - /** * Returns the raw JSON value of [maximum]. * @@ -28907,7 +30023,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [MatrixWithAllocation]. + * Returns a mutable builder for constructing an instance of [GroupedAllocation]. * * The following fields are required: * ```kotlin @@ -28915,6 +30031,7 @@ private constructor( * .billableMetric() * .billingCycleConfiguration() * .cadence() + * .compositePriceFilters() * .conversionRate() * .conversionRateConfig() * .createdAt() @@ -28923,9 +30040,9 @@ private constructor( * .discount() * .externalPriceId() * .fixedPriceQuantity() + * .groupedAllocationConfig() * .invoicingCycleConfiguration() * .item() - * .matrixWithAllocationConfig() * .maximum() * .maximumAmount() * .metadata() @@ -28940,13 +30057,14 @@ private constructor( fun builder() = Builder() } - /** A builder for [MatrixWithAllocation]. */ + /** A builder for [GroupedAllocation]. */ class Builder internal constructor() { private var id: JsonField? = null private var billableMetric: JsonField? = null private var billingCycleConfiguration: JsonField? = null private var cadence: JsonField? = null + private var compositePriceFilters: JsonField>? = null private var conversionRate: JsonField? = null private var conversionRateConfig: JsonField? = null private var createdAt: JsonField? = null @@ -28955,15 +30073,15 @@ private constructor( private var discount: JsonField? = null private var externalPriceId: JsonField? = null private var fixedPriceQuantity: JsonField? = null + private var groupedAllocationConfig: JsonField? = null private var invoicingCycleConfiguration: JsonField? = null private var item: JsonField? = null - private var matrixWithAllocationConfig: JsonField? = null private var maximum: JsonField? = null private var maximumAmount: JsonField? = null private var metadata: JsonField? = null private var minimum: JsonField? = null private var minimumAmount: JsonField? = null - private var modelType: JsonValue = JsonValue.from("matrix_with_allocation") + private var modelType: JsonValue = JsonValue.from("grouped_allocation") private var name: JsonField? = null private var planPhaseOrder: JsonField? = null private var priceType: JsonField? = null @@ -28972,34 +30090,36 @@ private constructor( JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(matrixWithAllocation: MatrixWithAllocation) = apply { - id = matrixWithAllocation.id - billableMetric = matrixWithAllocation.billableMetric - billingCycleConfiguration = matrixWithAllocation.billingCycleConfiguration - cadence = matrixWithAllocation.cadence - conversionRate = matrixWithAllocation.conversionRate - conversionRateConfig = matrixWithAllocation.conversionRateConfig - createdAt = matrixWithAllocation.createdAt - creditAllocation = matrixWithAllocation.creditAllocation - currency = matrixWithAllocation.currency - discount = matrixWithAllocation.discount - externalPriceId = matrixWithAllocation.externalPriceId - fixedPriceQuantity = matrixWithAllocation.fixedPriceQuantity - invoicingCycleConfiguration = matrixWithAllocation.invoicingCycleConfiguration - item = matrixWithAllocation.item - matrixWithAllocationConfig = matrixWithAllocation.matrixWithAllocationConfig - maximum = matrixWithAllocation.maximum - maximumAmount = matrixWithAllocation.maximumAmount - metadata = matrixWithAllocation.metadata - minimum = matrixWithAllocation.minimum - minimumAmount = matrixWithAllocation.minimumAmount - modelType = matrixWithAllocation.modelType - name = matrixWithAllocation.name - planPhaseOrder = matrixWithAllocation.planPhaseOrder - priceType = matrixWithAllocation.priceType - replacesPriceId = matrixWithAllocation.replacesPriceId - dimensionalPriceConfiguration = matrixWithAllocation.dimensionalPriceConfiguration - additionalProperties = matrixWithAllocation.additionalProperties.toMutableMap() + internal fun from(groupedAllocation: GroupedAllocation) = apply { + id = groupedAllocation.id + billableMetric = groupedAllocation.billableMetric + billingCycleConfiguration = groupedAllocation.billingCycleConfiguration + cadence = groupedAllocation.cadence + compositePriceFilters = + groupedAllocation.compositePriceFilters.map { it.toMutableList() } + conversionRate = groupedAllocation.conversionRate + conversionRateConfig = groupedAllocation.conversionRateConfig + createdAt = groupedAllocation.createdAt + creditAllocation = groupedAllocation.creditAllocation + currency = groupedAllocation.currency + discount = groupedAllocation.discount + externalPriceId = groupedAllocation.externalPriceId + fixedPriceQuantity = groupedAllocation.fixedPriceQuantity + groupedAllocationConfig = groupedAllocation.groupedAllocationConfig + invoicingCycleConfiguration = groupedAllocation.invoicingCycleConfiguration + item = groupedAllocation.item + maximum = groupedAllocation.maximum + maximumAmount = groupedAllocation.maximumAmount + metadata = groupedAllocation.metadata + minimum = groupedAllocation.minimum + minimumAmount = groupedAllocation.minimumAmount + modelType = groupedAllocation.modelType + name = groupedAllocation.name + planPhaseOrder = groupedAllocation.planPhaseOrder + priceType = groupedAllocation.priceType + replacesPriceId = groupedAllocation.replacesPriceId + dimensionalPriceConfiguration = groupedAllocation.dimensionalPriceConfiguration + additionalProperties = groupedAllocation.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) @@ -29052,6 +30172,34 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + fun compositePriceFilters(compositePriceFilters: List?) = + compositePriceFilters(JsonField.ofNullable(compositePriceFilters)) + + /** + * Sets [Builder.compositePriceFilters] to an arbitrary JSON value. + * + * You should usually call [Builder.compositePriceFilters] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun compositePriceFilters( + compositePriceFilters: JsonField> + ) = apply { + this.compositePriceFilters = compositePriceFilters.map { it.toMutableList() } + } + + /** + * Adds a single [TransformPriceFilter] to [compositePriceFilters]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addCompositePriceFilter(compositePriceFilter: TransformPriceFilter) = apply { + compositePriceFilters = + (compositePriceFilters ?: JsonField.of(mutableListOf())).also { + checkKnown("compositePriceFilters", it).add(compositePriceFilter) + } + } + fun conversionRate(conversionRate: Double?) = conversionRate(JsonField.ofNullable(conversionRate)) @@ -29293,6 +30441,20 @@ private constructor( this.fixedPriceQuantity = fixedPriceQuantity } + fun groupedAllocationConfig(groupedAllocationConfig: GroupedAllocationConfig) = + groupedAllocationConfig(JsonField.of(groupedAllocationConfig)) + + /** + * Sets [Builder.groupedAllocationConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.groupedAllocationConfig] with a well-typed + * [GroupedAllocationConfig] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun groupedAllocationConfig( + groupedAllocationConfig: JsonField + ) = apply { this.groupedAllocationConfig = groupedAllocationConfig } + fun invoicingCycleConfiguration( invoicingCycleConfiguration: BillingCycleConfiguration? ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) @@ -29319,20 +30481,6 @@ private constructor( */ fun item(item: JsonField) = apply { this.item = item } - fun matrixWithAllocationConfig(matrixWithAllocationConfig: MatrixWithAllocationConfig) = - matrixWithAllocationConfig(JsonField.of(matrixWithAllocationConfig)) - - /** - * Sets [Builder.matrixWithAllocationConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.matrixWithAllocationConfig] with a well-typed - * [MatrixWithAllocationConfig] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun matrixWithAllocationConfig( - matrixWithAllocationConfig: JsonField - ) = apply { this.matrixWithAllocationConfig = matrixWithAllocationConfig } - @Deprecated("deprecated") fun maximum(maximum: Maximum?) = maximum(JsonField.ofNullable(maximum)) @@ -29413,7 +30561,7 @@ private constructor( * It is usually unnecessary to call this method because the field defaults to the * following: * ```kotlin - * JsonValue.from("matrix_with_allocation") + * JsonValue.from("grouped_allocation") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -29517,7 +30665,7 @@ private constructor( } /** - * Returns an immutable instance of [MatrixWithAllocation]. + * Returns an immutable instance of [GroupedAllocation]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -29527,6 +30675,7 @@ private constructor( * .billableMetric() * .billingCycleConfiguration() * .cadence() + * .compositePriceFilters() * .conversionRate() * .conversionRateConfig() * .createdAt() @@ -29535,9 +30684,9 @@ private constructor( * .discount() * .externalPriceId() * .fixedPriceQuantity() + * .groupedAllocationConfig() * .invoicingCycleConfiguration() * .item() - * .matrixWithAllocationConfig() * .maximum() * .maximumAmount() * .metadata() @@ -29551,12 +30700,15 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): MatrixWithAllocation = - MatrixWithAllocation( + fun build(): GroupedAllocation = + GroupedAllocation( checkRequired("id", id), checkRequired("billableMetric", billableMetric), checkRequired("billingCycleConfiguration", billingCycleConfiguration), checkRequired("cadence", cadence), + checkRequired("compositePriceFilters", compositePriceFilters).map { + it.toImmutable() + }, checkRequired("conversionRate", conversionRate), checkRequired("conversionRateConfig", conversionRateConfig), checkRequired("createdAt", createdAt), @@ -29565,9 +30717,9 @@ private constructor( checkRequired("discount", discount), checkRequired("externalPriceId", externalPriceId), checkRequired("fixedPriceQuantity", fixedPriceQuantity), + checkRequired("groupedAllocationConfig", groupedAllocationConfig), checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), checkRequired("item", item), - checkRequired("matrixWithAllocationConfig", matrixWithAllocationConfig), checkRequired("maximum", maximum), checkRequired("maximumAmount", maximumAmount), checkRequired("metadata", metadata), @@ -29585,7 +30737,7 @@ private constructor( private var validated: Boolean = false - fun validate(): MatrixWithAllocation = apply { + fun validate(): GroupedAllocation = apply { if (validated) { return@apply } @@ -29594,6 +30746,7 @@ private constructor( billableMetric()?.validate() billingCycleConfiguration().validate() cadence().validate() + compositePriceFilters()?.forEach { it.validate() } conversionRate() conversionRateConfig()?.validate() createdAt() @@ -29602,16 +30755,16 @@ private constructor( discount()?.validate() externalPriceId() fixedPriceQuantity() + groupedAllocationConfig().validate() invoicingCycleConfiguration()?.validate() item().validate() - matrixWithAllocationConfig().validate() maximum()?.validate() maximumAmount() metadata().validate() minimum()?.validate() minimumAmount() _modelType().let { - if (it != JsonValue.from("matrix_with_allocation")) { + if (it != JsonValue.from("grouped_allocation")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } @@ -29642,6 +30795,7 @@ private constructor( (billableMetric.asKnown()?.validity() ?: 0) + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + (cadence.asKnown()?.validity() ?: 0) + + (compositePriceFilters.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + (if (conversionRate.asKnown() == null) 0 else 1) + (conversionRateConfig.asKnown()?.validity() ?: 0) + (if (createdAt.asKnown() == null) 0 else 1) + @@ -29650,15 +30804,15 @@ private constructor( (discount.asKnown()?.validity() ?: 0) + (if (externalPriceId.asKnown() == null) 0 else 1) + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (groupedAllocationConfig.asKnown()?.validity() ?: 0) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + (item.asKnown()?.validity() ?: 0) + - (matrixWithAllocationConfig.asKnown()?.validity() ?: 0) + (maximum.asKnown()?.validity() ?: 0) + (if (maximumAmount.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) + (minimum.asKnown()?.validity() ?: 0) + (if (minimumAmount.asKnown() == null) 0 else 1) + - modelType.let { if (it == JsonValue.from("matrix_with_allocation")) 1 else 0 } + + modelType.let { if (it == JsonValue.from("grouped_allocation")) 1 else 0 } + (if (name.asKnown() == null) 0 else 1) + (if (planPhaseOrder.asKnown() == null) 0 else 1) + (priceType.asKnown()?.validity() ?: 0) + @@ -29817,12 +30971,7 @@ private constructor( override fun toString() = value.toString() } - /** - * User specified key-value pairs for the resource. If not present, this defaults to an - * empty dictionary. Individual keys can be removed by setting the value to `null`, and the - * entire metadata mapping can be cleared by setting `metadata` to `null`. - */ - class Metadata + class GroupedAllocationConfig @JsonCreator private constructor( @com.fasterxml.jackson.annotation.JsonValue @@ -29837,17 +30986,21 @@ private constructor( companion object { - /** Returns a mutable builder for constructing an instance of [Metadata]. */ + /** + * Returns a mutable builder for constructing an instance of + * [GroupedAllocationConfig]. + */ fun builder() = Builder() } - /** A builder for [Metadata]. */ + /** A builder for [GroupedAllocationConfig]. */ class Builder internal constructor() { private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(metadata: Metadata) = apply { - additionalProperties = metadata.additionalProperties.toMutableMap() + internal fun from(groupedAllocationConfig: GroupedAllocationConfig) = apply { + additionalProperties = + groupedAllocationConfig.additionalProperties.toMutableMap() } fun additionalProperties(additionalProperties: Map) = apply { @@ -29873,16 +31026,124 @@ private constructor( } /** - * Returns an immutable instance of [Metadata]. + * Returns an immutable instance of [GroupedAllocationConfig]. * * Further updates to this [Builder] will not mutate the returned instance. */ - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + fun build(): GroupedAllocationConfig = + GroupedAllocationConfig(additionalProperties.toImmutable()) } private var validated: Boolean = false - fun validate(): Metadata = apply { + fun validate(): GroupedAllocationConfig = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedAllocationConfig && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedAllocationConfig{additionalProperties=$additionalProperties}" + } + + /** + * User specified key-value pairs for the resource. If not present, this defaults to an + * empty dictionary. Individual keys can be removed by setting the value to `null`, and the + * entire metadata mapping can be cleared by setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { if (validated) { return@apply } @@ -30056,11 +31317,12 @@ private constructor( return true } - return other is MatrixWithAllocation && + return other is GroupedAllocation && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && + compositePriceFilters == other.compositePriceFilters && conversionRate == other.conversionRate && conversionRateConfig == other.conversionRateConfig && createdAt == other.createdAt && @@ -30069,9 +31331,9 @@ private constructor( discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && + groupedAllocationConfig == other.groupedAllocationConfig && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && - matrixWithAllocationConfig == other.matrixWithAllocationConfig && maximum == other.maximum && maximumAmount == other.maximumAmount && metadata == other.metadata && @@ -30092,6 +31354,7 @@ private constructor( billableMetric, billingCycleConfiguration, cadence, + compositePriceFilters, conversionRate, conversionRateConfig, createdAt, @@ -30100,9 +31363,9 @@ private constructor( discount, externalPriceId, fixedPriceQuantity, + groupedAllocationConfig, invoicingCycleConfiguration, item, - matrixWithAllocationConfig, maximum, maximumAmount, metadata, @@ -30121,15 +31384,16 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "MatrixWithAllocation{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, matrixWithAllocationConfig=$matrixWithAllocationConfig, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "GroupedAllocation{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, groupedAllocationConfig=$groupedAllocationConfig, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" } - class TieredWithProration + class GroupedWithProratedMinimum private constructor( private val id: JsonField, private val billableMetric: JsonField, private val billingCycleConfiguration: JsonField, private val cadence: JsonField, + private val compositePriceFilters: JsonField>, private val conversionRate: JsonField, private val conversionRateConfig: JsonField, private val createdAt: JsonField, @@ -30138,6 +31402,7 @@ private constructor( private val discount: JsonField, private val externalPriceId: JsonField, private val fixedPriceQuantity: JsonField, + private val groupedWithProratedMinimumConfig: JsonField, private val invoicingCycleConfiguration: JsonField, private val item: JsonField, private val maximum: JsonField, @@ -30150,7 +31415,6 @@ private constructor( private val planPhaseOrder: JsonField, private val priceType: JsonField, private val replacesPriceId: JsonField, - private val tieredWithProrationConfig: JsonField, private val dimensionalPriceConfiguration: JsonField, private val additionalProperties: MutableMap, ) { @@ -30165,6 +31429,9 @@ private constructor( @ExcludeMissing billingCycleConfiguration: JsonField = JsonMissing.of(), @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), + @JsonProperty("composite_price_filters") + @ExcludeMissing + compositePriceFilters: JsonField> = JsonMissing.of(), @JsonProperty("conversion_rate") @ExcludeMissing conversionRate: JsonField = JsonMissing.of(), @@ -30189,6 +31456,10 @@ private constructor( @JsonProperty("fixed_price_quantity") @ExcludeMissing fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("grouped_with_prorated_minimum_config") + @ExcludeMissing + groupedWithProratedMinimumConfig: JsonField = + JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), @@ -30215,9 +31486,6 @@ private constructor( @JsonProperty("replaces_price_id") @ExcludeMissing replacesPriceId: JsonField = JsonMissing.of(), - @JsonProperty("tiered_with_proration_config") - @ExcludeMissing - tieredWithProrationConfig: JsonField = JsonMissing.of(), @JsonProperty("dimensional_price_configuration") @ExcludeMissing dimensionalPriceConfiguration: JsonField = @@ -30227,6 +31495,7 @@ private constructor( billableMetric, billingCycleConfiguration, cadence, + compositePriceFilters, conversionRate, conversionRateConfig, createdAt, @@ -30235,6 +31504,7 @@ private constructor( discount, externalPriceId, fixedPriceQuantity, + groupedWithProratedMinimumConfig, invoicingCycleConfiguration, item, maximum, @@ -30247,7 +31517,6 @@ private constructor( planPhaseOrder, priceType, replacesPriceId, - tieredWithProrationConfig, dimensionalPriceConfiguration, mutableMapOf(), ) @@ -30277,6 +31546,13 @@ private constructor( */ fun cadence(): Cadence = cadence.getRequired("cadence") + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun compositePriceFilters(): List? = + compositePriceFilters.getNullable("composite_price_filters") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -30326,6 +31602,13 @@ private constructor( */ fun fixedPriceQuantity(): Double? = fixedPriceQuantity.getNullable("fixed_price_quantity") + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun groupedWithProratedMinimumConfig(): GroupedWithProratedMinimumConfig = + groupedWithProratedMinimumConfig.getRequired("grouped_with_prorated_minimum_config") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -30378,7 +31661,7 @@ private constructor( /** * Expected to always return the following: * ```kotlin - * JsonValue.from("tiered_with_proration") + * JsonValue.from("grouped_with_prorated_minimum") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -30413,13 +31696,6 @@ private constructor( */ fun replacesPriceId(): String? = replacesPriceId.getNullable("replaces_price_id") - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun tieredWithProrationConfig(): TieredWithProrationConfig = - tieredWithProrationConfig.getRequired("tiered_with_proration_config") - /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -30462,6 +31738,16 @@ private constructor( */ @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence + /** + * Returns the raw JSON value of [compositePriceFilters]. + * + * Unlike [compositePriceFilters], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("composite_price_filters") + @ExcludeMissing + fun _compositePriceFilters(): JsonField> = compositePriceFilters + /** * Returns the raw JSON value of [conversionRate]. * @@ -30538,6 +31824,17 @@ private constructor( @ExcludeMissing fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + /** + * Returns the raw JSON value of [groupedWithProratedMinimumConfig]. + * + * Unlike [groupedWithProratedMinimumConfig], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("grouped_with_prorated_minimum_config") + @ExcludeMissing + fun _groupedWithProratedMinimumConfig(): JsonField = + groupedWithProratedMinimumConfig + /** * Returns the raw JSON value of [invoicingCycleConfiguration]. * @@ -30641,17 +31938,6 @@ private constructor( @ExcludeMissing fun _replacesPriceId(): JsonField = replacesPriceId - /** - * Returns the raw JSON value of [tieredWithProrationConfig]. - * - * Unlike [tieredWithProrationConfig], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("tiered_with_proration_config") - @ExcludeMissing - fun _tieredWithProrationConfig(): JsonField = - tieredWithProrationConfig - /** * Returns the raw JSON value of [dimensionalPriceConfiguration]. * @@ -30678,7 +31964,8 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [TieredWithProration]. + * Returns a mutable builder for constructing an instance of + * [GroupedWithProratedMinimum]. * * The following fields are required: * ```kotlin @@ -30686,6 +31973,7 @@ private constructor( * .billableMetric() * .billingCycleConfiguration() * .cadence() + * .compositePriceFilters() * .conversionRate() * .conversionRateConfig() * .createdAt() @@ -30694,6 +31982,7 @@ private constructor( * .discount() * .externalPriceId() * .fixedPriceQuantity() + * .groupedWithProratedMinimumConfig() * .invoicingCycleConfiguration() * .item() * .maximum() @@ -30705,19 +31994,19 @@ private constructor( * .planPhaseOrder() * .priceType() * .replacesPriceId() - * .tieredWithProrationConfig() * ``` */ fun builder() = Builder() } - /** A builder for [TieredWithProration]. */ + /** A builder for [GroupedWithProratedMinimum]. */ class Builder internal constructor() { private var id: JsonField? = null private var billableMetric: JsonField? = null private var billingCycleConfiguration: JsonField? = null private var cadence: JsonField? = null + private var compositePriceFilters: JsonField>? = null private var conversionRate: JsonField? = null private var conversionRateConfig: JsonField? = null private var createdAt: JsonField? = null @@ -30726,6 +32015,9 @@ private constructor( private var discount: JsonField? = null private var externalPriceId: JsonField? = null private var fixedPriceQuantity: JsonField? = null + private var groupedWithProratedMinimumConfig: + JsonField? = + null private var invoicingCycleConfiguration: JsonField? = null private var item: JsonField? = null private var maximum: JsonField? = null @@ -30733,44 +32025,48 @@ private constructor( private var metadata: JsonField? = null private var minimum: JsonField? = null private var minimumAmount: JsonField? = null - private var modelType: JsonValue = JsonValue.from("tiered_with_proration") + private var modelType: JsonValue = JsonValue.from("grouped_with_prorated_minimum") private var name: JsonField? = null private var planPhaseOrder: JsonField? = null private var priceType: JsonField? = null private var replacesPriceId: JsonField? = null - private var tieredWithProrationConfig: JsonField? = null private var dimensionalPriceConfiguration: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(tieredWithProration: TieredWithProration) = apply { - id = tieredWithProration.id - billableMetric = tieredWithProration.billableMetric - billingCycleConfiguration = tieredWithProration.billingCycleConfiguration - cadence = tieredWithProration.cadence - conversionRate = tieredWithProration.conversionRate - conversionRateConfig = tieredWithProration.conversionRateConfig - createdAt = tieredWithProration.createdAt - creditAllocation = tieredWithProration.creditAllocation - currency = tieredWithProration.currency - discount = tieredWithProration.discount - externalPriceId = tieredWithProration.externalPriceId - fixedPriceQuantity = tieredWithProration.fixedPriceQuantity - invoicingCycleConfiguration = tieredWithProration.invoicingCycleConfiguration - item = tieredWithProration.item - maximum = tieredWithProration.maximum - maximumAmount = tieredWithProration.maximumAmount - metadata = tieredWithProration.metadata - minimum = tieredWithProration.minimum - minimumAmount = tieredWithProration.minimumAmount - modelType = tieredWithProration.modelType - name = tieredWithProration.name - planPhaseOrder = tieredWithProration.planPhaseOrder - priceType = tieredWithProration.priceType - replacesPriceId = tieredWithProration.replacesPriceId - tieredWithProrationConfig = tieredWithProration.tieredWithProrationConfig - dimensionalPriceConfiguration = tieredWithProration.dimensionalPriceConfiguration - additionalProperties = tieredWithProration.additionalProperties.toMutableMap() + internal fun from(groupedWithProratedMinimum: GroupedWithProratedMinimum) = apply { + id = groupedWithProratedMinimum.id + billableMetric = groupedWithProratedMinimum.billableMetric + billingCycleConfiguration = groupedWithProratedMinimum.billingCycleConfiguration + cadence = groupedWithProratedMinimum.cadence + compositePriceFilters = + groupedWithProratedMinimum.compositePriceFilters.map { it.toMutableList() } + conversionRate = groupedWithProratedMinimum.conversionRate + conversionRateConfig = groupedWithProratedMinimum.conversionRateConfig + createdAt = groupedWithProratedMinimum.createdAt + creditAllocation = groupedWithProratedMinimum.creditAllocation + currency = groupedWithProratedMinimum.currency + discount = groupedWithProratedMinimum.discount + externalPriceId = groupedWithProratedMinimum.externalPriceId + fixedPriceQuantity = groupedWithProratedMinimum.fixedPriceQuantity + groupedWithProratedMinimumConfig = + groupedWithProratedMinimum.groupedWithProratedMinimumConfig + invoicingCycleConfiguration = groupedWithProratedMinimum.invoicingCycleConfiguration + item = groupedWithProratedMinimum.item + maximum = groupedWithProratedMinimum.maximum + maximumAmount = groupedWithProratedMinimum.maximumAmount + metadata = groupedWithProratedMinimum.metadata + minimum = groupedWithProratedMinimum.minimum + minimumAmount = groupedWithProratedMinimum.minimumAmount + modelType = groupedWithProratedMinimum.modelType + name = groupedWithProratedMinimum.name + planPhaseOrder = groupedWithProratedMinimum.planPhaseOrder + priceType = groupedWithProratedMinimum.priceType + replacesPriceId = groupedWithProratedMinimum.replacesPriceId + dimensionalPriceConfiguration = + groupedWithProratedMinimum.dimensionalPriceConfiguration + additionalProperties = + groupedWithProratedMinimum.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) @@ -30823,6 +32119,34 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + fun compositePriceFilters(compositePriceFilters: List?) = + compositePriceFilters(JsonField.ofNullable(compositePriceFilters)) + + /** + * Sets [Builder.compositePriceFilters] to an arbitrary JSON value. + * + * You should usually call [Builder.compositePriceFilters] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun compositePriceFilters( + compositePriceFilters: JsonField> + ) = apply { + this.compositePriceFilters = compositePriceFilters.map { it.toMutableList() } + } + + /** + * Adds a single [TransformPriceFilter] to [compositePriceFilters]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addCompositePriceFilter(compositePriceFilter: TransformPriceFilter) = apply { + compositePriceFilters = + (compositePriceFilters ?: JsonField.of(mutableListOf())).also { + checkKnown("compositePriceFilters", it).add(compositePriceFilter) + } + } + fun conversionRate(conversionRate: Double?) = conversionRate(JsonField.ofNullable(conversionRate)) @@ -31064,6 +32388,21 @@ private constructor( this.fixedPriceQuantity = fixedPriceQuantity } + fun groupedWithProratedMinimumConfig( + groupedWithProratedMinimumConfig: GroupedWithProratedMinimumConfig + ) = groupedWithProratedMinimumConfig(JsonField.of(groupedWithProratedMinimumConfig)) + + /** + * Sets [Builder.groupedWithProratedMinimumConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.groupedWithProratedMinimumConfig] with a well-typed + * [GroupedWithProratedMinimumConfig] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun groupedWithProratedMinimumConfig( + groupedWithProratedMinimumConfig: JsonField + ) = apply { this.groupedWithProratedMinimumConfig = groupedWithProratedMinimumConfig } + fun invoicingCycleConfiguration( invoicingCycleConfiguration: BillingCycleConfiguration? ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) @@ -31170,7 +32509,7 @@ private constructor( * It is usually unnecessary to call this method because the field defaults to the * following: * ```kotlin - * JsonValue.from("tiered_with_proration") + * JsonValue.from("grouped_with_prorated_minimum") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -31239,20 +32578,6 @@ private constructor( this.replacesPriceId = replacesPriceId } - fun tieredWithProrationConfig(tieredWithProrationConfig: TieredWithProrationConfig) = - tieredWithProrationConfig(JsonField.of(tieredWithProrationConfig)) - - /** - * Sets [Builder.tieredWithProrationConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.tieredWithProrationConfig] with a well-typed - * [TieredWithProrationConfig] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun tieredWithProrationConfig( - tieredWithProrationConfig: JsonField - ) = apply { this.tieredWithProrationConfig = tieredWithProrationConfig } - fun dimensionalPriceConfiguration( dimensionalPriceConfiguration: DimensionalPriceConfiguration? ) = dimensionalPriceConfiguration(JsonField.ofNullable(dimensionalPriceConfiguration)) @@ -31288,7 +32613,7 @@ private constructor( } /** - * Returns an immutable instance of [TieredWithProration]. + * Returns an immutable instance of [GroupedWithProratedMinimum]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -31298,6 +32623,7 @@ private constructor( * .billableMetric() * .billingCycleConfiguration() * .cadence() + * .compositePriceFilters() * .conversionRate() * .conversionRateConfig() * .createdAt() @@ -31306,6 +32632,7 @@ private constructor( * .discount() * .externalPriceId() * .fixedPriceQuantity() + * .groupedWithProratedMinimumConfig() * .invoicingCycleConfiguration() * .item() * .maximum() @@ -31317,17 +32644,19 @@ private constructor( * .planPhaseOrder() * .priceType() * .replacesPriceId() - * .tieredWithProrationConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): TieredWithProration = - TieredWithProration( + fun build(): GroupedWithProratedMinimum = + GroupedWithProratedMinimum( checkRequired("id", id), checkRequired("billableMetric", billableMetric), checkRequired("billingCycleConfiguration", billingCycleConfiguration), checkRequired("cadence", cadence), + checkRequired("compositePriceFilters", compositePriceFilters).map { + it.toImmutable() + }, checkRequired("conversionRate", conversionRate), checkRequired("conversionRateConfig", conversionRateConfig), checkRequired("createdAt", createdAt), @@ -31336,6 +32665,10 @@ private constructor( checkRequired("discount", discount), checkRequired("externalPriceId", externalPriceId), checkRequired("fixedPriceQuantity", fixedPriceQuantity), + checkRequired( + "groupedWithProratedMinimumConfig", + groupedWithProratedMinimumConfig, + ), checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), checkRequired("item", item), checkRequired("maximum", maximum), @@ -31348,7 +32681,6 @@ private constructor( checkRequired("planPhaseOrder", planPhaseOrder), checkRequired("priceType", priceType), checkRequired("replacesPriceId", replacesPriceId), - checkRequired("tieredWithProrationConfig", tieredWithProrationConfig), dimensionalPriceConfiguration, additionalProperties.toMutableMap(), ) @@ -31356,7 +32688,7 @@ private constructor( private var validated: Boolean = false - fun validate(): TieredWithProration = apply { + fun validate(): GroupedWithProratedMinimum = apply { if (validated) { return@apply } @@ -31365,6 +32697,7 @@ private constructor( billableMetric()?.validate() billingCycleConfiguration().validate() cadence().validate() + compositePriceFilters()?.forEach { it.validate() } conversionRate() conversionRateConfig()?.validate() createdAt() @@ -31373,6 +32706,7 @@ private constructor( discount()?.validate() externalPriceId() fixedPriceQuantity() + groupedWithProratedMinimumConfig().validate() invoicingCycleConfiguration()?.validate() item().validate() maximum()?.validate() @@ -31381,7 +32715,7 @@ private constructor( minimum()?.validate() minimumAmount() _modelType().let { - if (it != JsonValue.from("tiered_with_proration")) { + if (it != JsonValue.from("grouped_with_prorated_minimum")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } @@ -31389,7 +32723,6 @@ private constructor( planPhaseOrder() priceType().validate() replacesPriceId() - tieredWithProrationConfig().validate() dimensionalPriceConfiguration()?.validate() validated = true } @@ -31413,6 +32746,7 @@ private constructor( (billableMetric.asKnown()?.validity() ?: 0) + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + (cadence.asKnown()?.validity() ?: 0) + + (compositePriceFilters.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + (if (conversionRate.asKnown() == null) 0 else 1) + (conversionRateConfig.asKnown()?.validity() ?: 0) + (if (createdAt.asKnown() == null) 0 else 1) + @@ -31421,6 +32755,7 @@ private constructor( (discount.asKnown()?.validity() ?: 0) + (if (externalPriceId.asKnown() == null) 0 else 1) + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (groupedWithProratedMinimumConfig.asKnown()?.validity() ?: 0) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + (item.asKnown()?.validity() ?: 0) + (maximum.asKnown()?.validity() ?: 0) + @@ -31428,12 +32763,13 @@ private constructor( (metadata.asKnown()?.validity() ?: 0) + (minimum.asKnown()?.validity() ?: 0) + (if (minimumAmount.asKnown() == null) 0 else 1) + - modelType.let { if (it == JsonValue.from("tiered_with_proration")) 1 else 0 } + + modelType.let { + if (it == JsonValue.from("grouped_with_prorated_minimum")) 1 else 0 + } + (if (name.asKnown() == null) 0 else 1) + (if (planPhaseOrder.asKnown() == null) 0 else 1) + (priceType.asKnown()?.validity() ?: 0) + (if (replacesPriceId.asKnown() == null) 0 else 1) + - (tieredWithProrationConfig.asKnown()?.validity() ?: 0) + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) class Cadence @JsonCreator private constructor(private val value: JsonField) : @@ -31588,6 +32924,115 @@ private constructor( override fun toString() = value.toString() } + class GroupedWithProratedMinimumConfig + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [GroupedWithProratedMinimumConfig]. + */ + fun builder() = Builder() + } + + /** A builder for [GroupedWithProratedMinimumConfig]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from( + groupedWithProratedMinimumConfig: GroupedWithProratedMinimumConfig + ) = apply { + additionalProperties = + groupedWithProratedMinimumConfig.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [GroupedWithProratedMinimumConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): GroupedWithProratedMinimumConfig = + GroupedWithProratedMinimumConfig(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): GroupedWithProratedMinimumConfig = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedWithProratedMinimumConfig && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedWithProratedMinimumConfig{additionalProperties=$additionalProperties}" + } + /** * User specified key-value pairs for the resource. If not present, this defaults to an * empty dictionary. Individual keys can be removed by setting the value to `null`, and the @@ -31822,123 +33267,17 @@ private constructor( override fun toString() = value.toString() } - class TieredWithProrationConfig - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [TieredWithProrationConfig]. - */ - fun builder() = Builder() - } - - /** A builder for [TieredWithProrationConfig]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(tieredWithProrationConfig: TieredWithProrationConfig) = apply { - additionalProperties = - tieredWithProrationConfig.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [TieredWithProrationConfig]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): TieredWithProrationConfig = - TieredWithProrationConfig(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): TieredWithProrationConfig = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is TieredWithProrationConfig && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "TieredWithProrationConfig{additionalProperties=$additionalProperties}" - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is TieredWithProration && + return other is GroupedWithProratedMinimum && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && + compositePriceFilters == other.compositePriceFilters && conversionRate == other.conversionRate && conversionRateConfig == other.conversionRateConfig && createdAt == other.createdAt && @@ -31947,6 +33286,7 @@ private constructor( discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && + groupedWithProratedMinimumConfig == other.groupedWithProratedMinimumConfig && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maximum == other.maximum && @@ -31959,7 +33299,6 @@ private constructor( planPhaseOrder == other.planPhaseOrder && priceType == other.priceType && replacesPriceId == other.replacesPriceId && - tieredWithProrationConfig == other.tieredWithProrationConfig && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties } @@ -31970,6 +33309,7 @@ private constructor( billableMetric, billingCycleConfiguration, cadence, + compositePriceFilters, conversionRate, conversionRateConfig, createdAt, @@ -31978,6 +33318,7 @@ private constructor( discount, externalPriceId, fixedPriceQuantity, + groupedWithProratedMinimumConfig, invoicingCycleConfiguration, item, maximum, @@ -31990,7 +33331,6 @@ private constructor( planPhaseOrder, priceType, replacesPriceId, - tieredWithProrationConfig, dimensionalPriceConfiguration, additionalProperties, ) @@ -31999,15 +33339,16 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "TieredWithProration{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, tieredWithProrationConfig=$tieredWithProrationConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "GroupedWithProratedMinimum{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, groupedWithProratedMinimumConfig=$groupedWithProratedMinimumConfig, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" } - class UnitWithProration + class GroupedWithMeteredMinimum private constructor( private val id: JsonField, private val billableMetric: JsonField, private val billingCycleConfiguration: JsonField, private val cadence: JsonField, + private val compositePriceFilters: JsonField>, private val conversionRate: JsonField, private val conversionRateConfig: JsonField, private val createdAt: JsonField, @@ -32016,6 +33357,7 @@ private constructor( private val discount: JsonField, private val externalPriceId: JsonField, private val fixedPriceQuantity: JsonField, + private val groupedWithMeteredMinimumConfig: JsonField, private val invoicingCycleConfiguration: JsonField, private val item: JsonField, private val maximum: JsonField, @@ -32028,7 +33370,6 @@ private constructor( private val planPhaseOrder: JsonField, private val priceType: JsonField, private val replacesPriceId: JsonField, - private val unitWithProrationConfig: JsonField, private val dimensionalPriceConfiguration: JsonField, private val additionalProperties: MutableMap, ) { @@ -32043,6 +33384,9 @@ private constructor( @ExcludeMissing billingCycleConfiguration: JsonField = JsonMissing.of(), @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), + @JsonProperty("composite_price_filters") + @ExcludeMissing + compositePriceFilters: JsonField> = JsonMissing.of(), @JsonProperty("conversion_rate") @ExcludeMissing conversionRate: JsonField = JsonMissing.of(), @@ -32067,6 +33411,10 @@ private constructor( @JsonProperty("fixed_price_quantity") @ExcludeMissing fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("grouped_with_metered_minimum_config") + @ExcludeMissing + groupedWithMeteredMinimumConfig: JsonField = + JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), @@ -32093,9 +33441,6 @@ private constructor( @JsonProperty("replaces_price_id") @ExcludeMissing replacesPriceId: JsonField = JsonMissing.of(), - @JsonProperty("unit_with_proration_config") - @ExcludeMissing - unitWithProrationConfig: JsonField = JsonMissing.of(), @JsonProperty("dimensional_price_configuration") @ExcludeMissing dimensionalPriceConfiguration: JsonField = @@ -32105,6 +33450,7 @@ private constructor( billableMetric, billingCycleConfiguration, cadence, + compositePriceFilters, conversionRate, conversionRateConfig, createdAt, @@ -32113,6 +33459,7 @@ private constructor( discount, externalPriceId, fixedPriceQuantity, + groupedWithMeteredMinimumConfig, invoicingCycleConfiguration, item, maximum, @@ -32125,7 +33472,6 @@ private constructor( planPhaseOrder, priceType, replacesPriceId, - unitWithProrationConfig, dimensionalPriceConfiguration, mutableMapOf(), ) @@ -32155,6 +33501,13 @@ private constructor( */ fun cadence(): Cadence = cadence.getRequired("cadence") + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun compositePriceFilters(): List? = + compositePriceFilters.getNullable("composite_price_filters") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -32204,6 +33557,13 @@ private constructor( */ fun fixedPriceQuantity(): Double? = fixedPriceQuantity.getNullable("fixed_price_quantity") + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun groupedWithMeteredMinimumConfig(): GroupedWithMeteredMinimumConfig = + groupedWithMeteredMinimumConfig.getRequired("grouped_with_metered_minimum_config") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -32256,7 +33616,7 @@ private constructor( /** * Expected to always return the following: * ```kotlin - * JsonValue.from("unit_with_proration") + * JsonValue.from("grouped_with_metered_minimum") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -32291,13 +33651,6 @@ private constructor( */ fun replacesPriceId(): String? = replacesPriceId.getNullable("replaces_price_id") - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun unitWithProrationConfig(): UnitWithProrationConfig = - unitWithProrationConfig.getRequired("unit_with_proration_config") - /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -32340,6 +33693,16 @@ private constructor( */ @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence + /** + * Returns the raw JSON value of [compositePriceFilters]. + * + * Unlike [compositePriceFilters], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("composite_price_filters") + @ExcludeMissing + fun _compositePriceFilters(): JsonField> = compositePriceFilters + /** * Returns the raw JSON value of [conversionRate]. * @@ -32416,6 +33779,17 @@ private constructor( @ExcludeMissing fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + /** + * Returns the raw JSON value of [groupedWithMeteredMinimumConfig]. + * + * Unlike [groupedWithMeteredMinimumConfig], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("grouped_with_metered_minimum_config") + @ExcludeMissing + fun _groupedWithMeteredMinimumConfig(): JsonField = + groupedWithMeteredMinimumConfig + /** * Returns the raw JSON value of [invoicingCycleConfiguration]. * @@ -32519,16 +33893,6 @@ private constructor( @ExcludeMissing fun _replacesPriceId(): JsonField = replacesPriceId - /** - * Returns the raw JSON value of [unitWithProrationConfig]. - * - * Unlike [unitWithProrationConfig], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("unit_with_proration_config") - @ExcludeMissing - fun _unitWithProrationConfig(): JsonField = unitWithProrationConfig - /** * Returns the raw JSON value of [dimensionalPriceConfiguration]. * @@ -32555,7 +33919,8 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [UnitWithProration]. + * Returns a mutable builder for constructing an instance of + * [GroupedWithMeteredMinimum]. * * The following fields are required: * ```kotlin @@ -32563,6 +33928,7 @@ private constructor( * .billableMetric() * .billingCycleConfiguration() * .cadence() + * .compositePriceFilters() * .conversionRate() * .conversionRateConfig() * .createdAt() @@ -32571,6 +33937,7 @@ private constructor( * .discount() * .externalPriceId() * .fixedPriceQuantity() + * .groupedWithMeteredMinimumConfig() * .invoicingCycleConfiguration() * .item() * .maximum() @@ -32582,19 +33949,19 @@ private constructor( * .planPhaseOrder() * .priceType() * .replacesPriceId() - * .unitWithProrationConfig() * ``` */ fun builder() = Builder() } - /** A builder for [UnitWithProration]. */ + /** A builder for [GroupedWithMeteredMinimum]. */ class Builder internal constructor() { private var id: JsonField? = null private var billableMetric: JsonField? = null private var billingCycleConfiguration: JsonField? = null private var cadence: JsonField? = null + private var compositePriceFilters: JsonField>? = null private var conversionRate: JsonField? = null private var conversionRateConfig: JsonField? = null private var createdAt: JsonField? = null @@ -32603,6 +33970,9 @@ private constructor( private var discount: JsonField? = null private var externalPriceId: JsonField? = null private var fixedPriceQuantity: JsonField? = null + private var groupedWithMeteredMinimumConfig: + JsonField? = + null private var invoicingCycleConfiguration: JsonField? = null private var item: JsonField? = null private var maximum: JsonField? = null @@ -32610,44 +33980,47 @@ private constructor( private var metadata: JsonField? = null private var minimum: JsonField? = null private var minimumAmount: JsonField? = null - private var modelType: JsonValue = JsonValue.from("unit_with_proration") + private var modelType: JsonValue = JsonValue.from("grouped_with_metered_minimum") private var name: JsonField? = null private var planPhaseOrder: JsonField? = null private var priceType: JsonField? = null private var replacesPriceId: JsonField? = null - private var unitWithProrationConfig: JsonField? = null private var dimensionalPriceConfiguration: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(unitWithProration: UnitWithProration) = apply { - id = unitWithProration.id - billableMetric = unitWithProration.billableMetric - billingCycleConfiguration = unitWithProration.billingCycleConfiguration - cadence = unitWithProration.cadence - conversionRate = unitWithProration.conversionRate - conversionRateConfig = unitWithProration.conversionRateConfig - createdAt = unitWithProration.createdAt - creditAllocation = unitWithProration.creditAllocation - currency = unitWithProration.currency - discount = unitWithProration.discount - externalPriceId = unitWithProration.externalPriceId - fixedPriceQuantity = unitWithProration.fixedPriceQuantity - invoicingCycleConfiguration = unitWithProration.invoicingCycleConfiguration - item = unitWithProration.item - maximum = unitWithProration.maximum - maximumAmount = unitWithProration.maximumAmount - metadata = unitWithProration.metadata - minimum = unitWithProration.minimum - minimumAmount = unitWithProration.minimumAmount - modelType = unitWithProration.modelType - name = unitWithProration.name - planPhaseOrder = unitWithProration.planPhaseOrder - priceType = unitWithProration.priceType - replacesPriceId = unitWithProration.replacesPriceId - unitWithProrationConfig = unitWithProration.unitWithProrationConfig - dimensionalPriceConfiguration = unitWithProration.dimensionalPriceConfiguration - additionalProperties = unitWithProration.additionalProperties.toMutableMap() + internal fun from(groupedWithMeteredMinimum: GroupedWithMeteredMinimum) = apply { + id = groupedWithMeteredMinimum.id + billableMetric = groupedWithMeteredMinimum.billableMetric + billingCycleConfiguration = groupedWithMeteredMinimum.billingCycleConfiguration + cadence = groupedWithMeteredMinimum.cadence + compositePriceFilters = + groupedWithMeteredMinimum.compositePriceFilters.map { it.toMutableList() } + conversionRate = groupedWithMeteredMinimum.conversionRate + conversionRateConfig = groupedWithMeteredMinimum.conversionRateConfig + createdAt = groupedWithMeteredMinimum.createdAt + creditAllocation = groupedWithMeteredMinimum.creditAllocation + currency = groupedWithMeteredMinimum.currency + discount = groupedWithMeteredMinimum.discount + externalPriceId = groupedWithMeteredMinimum.externalPriceId + fixedPriceQuantity = groupedWithMeteredMinimum.fixedPriceQuantity + groupedWithMeteredMinimumConfig = + groupedWithMeteredMinimum.groupedWithMeteredMinimumConfig + invoicingCycleConfiguration = groupedWithMeteredMinimum.invoicingCycleConfiguration + item = groupedWithMeteredMinimum.item + maximum = groupedWithMeteredMinimum.maximum + maximumAmount = groupedWithMeteredMinimum.maximumAmount + metadata = groupedWithMeteredMinimum.metadata + minimum = groupedWithMeteredMinimum.minimum + minimumAmount = groupedWithMeteredMinimum.minimumAmount + modelType = groupedWithMeteredMinimum.modelType + name = groupedWithMeteredMinimum.name + planPhaseOrder = groupedWithMeteredMinimum.planPhaseOrder + priceType = groupedWithMeteredMinimum.priceType + replacesPriceId = groupedWithMeteredMinimum.replacesPriceId + dimensionalPriceConfiguration = + groupedWithMeteredMinimum.dimensionalPriceConfiguration + additionalProperties = groupedWithMeteredMinimum.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) @@ -32700,6 +34073,34 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + fun compositePriceFilters(compositePriceFilters: List?) = + compositePriceFilters(JsonField.ofNullable(compositePriceFilters)) + + /** + * Sets [Builder.compositePriceFilters] to an arbitrary JSON value. + * + * You should usually call [Builder.compositePriceFilters] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun compositePriceFilters( + compositePriceFilters: JsonField> + ) = apply { + this.compositePriceFilters = compositePriceFilters.map { it.toMutableList() } + } + + /** + * Adds a single [TransformPriceFilter] to [compositePriceFilters]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addCompositePriceFilter(compositePriceFilter: TransformPriceFilter) = apply { + compositePriceFilters = + (compositePriceFilters ?: JsonField.of(mutableListOf())).also { + checkKnown("compositePriceFilters", it).add(compositePriceFilter) + } + } + fun conversionRate(conversionRate: Double?) = conversionRate(JsonField.ofNullable(conversionRate)) @@ -32941,6 +34342,21 @@ private constructor( this.fixedPriceQuantity = fixedPriceQuantity } + fun groupedWithMeteredMinimumConfig( + groupedWithMeteredMinimumConfig: GroupedWithMeteredMinimumConfig + ) = groupedWithMeteredMinimumConfig(JsonField.of(groupedWithMeteredMinimumConfig)) + + /** + * Sets [Builder.groupedWithMeteredMinimumConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.groupedWithMeteredMinimumConfig] with a well-typed + * [GroupedWithMeteredMinimumConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun groupedWithMeteredMinimumConfig( + groupedWithMeteredMinimumConfig: JsonField + ) = apply { this.groupedWithMeteredMinimumConfig = groupedWithMeteredMinimumConfig } + fun invoicingCycleConfiguration( invoicingCycleConfiguration: BillingCycleConfiguration? ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) @@ -33047,7 +34463,7 @@ private constructor( * It is usually unnecessary to call this method because the field defaults to the * following: * ```kotlin - * JsonValue.from("unit_with_proration") + * JsonValue.from("grouped_with_metered_minimum") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -33116,20 +34532,6 @@ private constructor( this.replacesPriceId = replacesPriceId } - fun unitWithProrationConfig(unitWithProrationConfig: UnitWithProrationConfig) = - unitWithProrationConfig(JsonField.of(unitWithProrationConfig)) - - /** - * Sets [Builder.unitWithProrationConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.unitWithProrationConfig] with a well-typed - * [UnitWithProrationConfig] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun unitWithProrationConfig( - unitWithProrationConfig: JsonField - ) = apply { this.unitWithProrationConfig = unitWithProrationConfig } - fun dimensionalPriceConfiguration( dimensionalPriceConfiguration: DimensionalPriceConfiguration? ) = dimensionalPriceConfiguration(JsonField.ofNullable(dimensionalPriceConfiguration)) @@ -33165,7 +34567,7 @@ private constructor( } /** - * Returns an immutable instance of [UnitWithProration]. + * Returns an immutable instance of [GroupedWithMeteredMinimum]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -33175,6 +34577,7 @@ private constructor( * .billableMetric() * .billingCycleConfiguration() * .cadence() + * .compositePriceFilters() * .conversionRate() * .conversionRateConfig() * .createdAt() @@ -33183,6 +34586,7 @@ private constructor( * .discount() * .externalPriceId() * .fixedPriceQuantity() + * .groupedWithMeteredMinimumConfig() * .invoicingCycleConfiguration() * .item() * .maximum() @@ -33194,17 +34598,19 @@ private constructor( * .planPhaseOrder() * .priceType() * .replacesPriceId() - * .unitWithProrationConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): UnitWithProration = - UnitWithProration( + fun build(): GroupedWithMeteredMinimum = + GroupedWithMeteredMinimum( checkRequired("id", id), checkRequired("billableMetric", billableMetric), checkRequired("billingCycleConfiguration", billingCycleConfiguration), checkRequired("cadence", cadence), + checkRequired("compositePriceFilters", compositePriceFilters).map { + it.toImmutable() + }, checkRequired("conversionRate", conversionRate), checkRequired("conversionRateConfig", conversionRateConfig), checkRequired("createdAt", createdAt), @@ -33213,6 +34619,10 @@ private constructor( checkRequired("discount", discount), checkRequired("externalPriceId", externalPriceId), checkRequired("fixedPriceQuantity", fixedPriceQuantity), + checkRequired( + "groupedWithMeteredMinimumConfig", + groupedWithMeteredMinimumConfig, + ), checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), checkRequired("item", item), checkRequired("maximum", maximum), @@ -33225,7 +34635,6 @@ private constructor( checkRequired("planPhaseOrder", planPhaseOrder), checkRequired("priceType", priceType), checkRequired("replacesPriceId", replacesPriceId), - checkRequired("unitWithProrationConfig", unitWithProrationConfig), dimensionalPriceConfiguration, additionalProperties.toMutableMap(), ) @@ -33233,7 +34642,7 @@ private constructor( private var validated: Boolean = false - fun validate(): UnitWithProration = apply { + fun validate(): GroupedWithMeteredMinimum = apply { if (validated) { return@apply } @@ -33242,6 +34651,7 @@ private constructor( billableMetric()?.validate() billingCycleConfiguration().validate() cadence().validate() + compositePriceFilters()?.forEach { it.validate() } conversionRate() conversionRateConfig()?.validate() createdAt() @@ -33250,6 +34660,7 @@ private constructor( discount()?.validate() externalPriceId() fixedPriceQuantity() + groupedWithMeteredMinimumConfig().validate() invoicingCycleConfiguration()?.validate() item().validate() maximum()?.validate() @@ -33258,7 +34669,7 @@ private constructor( minimum()?.validate() minimumAmount() _modelType().let { - if (it != JsonValue.from("unit_with_proration")) { + if (it != JsonValue.from("grouped_with_metered_minimum")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } @@ -33266,7 +34677,6 @@ private constructor( planPhaseOrder() priceType().validate() replacesPriceId() - unitWithProrationConfig().validate() dimensionalPriceConfiguration()?.validate() validated = true } @@ -33290,6 +34700,7 @@ private constructor( (billableMetric.asKnown()?.validity() ?: 0) + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + (cadence.asKnown()?.validity() ?: 0) + + (compositePriceFilters.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + (if (conversionRate.asKnown() == null) 0 else 1) + (conversionRateConfig.asKnown()?.validity() ?: 0) + (if (createdAt.asKnown() == null) 0 else 1) + @@ -33298,6 +34709,7 @@ private constructor( (discount.asKnown()?.validity() ?: 0) + (if (externalPriceId.asKnown() == null) 0 else 1) + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (groupedWithMeteredMinimumConfig.asKnown()?.validity() ?: 0) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + (item.asKnown()?.validity() ?: 0) + (maximum.asKnown()?.validity() ?: 0) + @@ -33305,12 +34717,13 @@ private constructor( (metadata.asKnown()?.validity() ?: 0) + (minimum.asKnown()?.validity() ?: 0) + (if (minimumAmount.asKnown() == null) 0 else 1) + - modelType.let { if (it == JsonValue.from("unit_with_proration")) 1 else 0 } + + modelType.let { + if (it == JsonValue.from("grouped_with_metered_minimum")) 1 else 0 + } + (if (name.asKnown() == null) 0 else 1) + (if (planPhaseOrder.asKnown() == null) 0 else 1) + (priceType.asKnown()?.validity() ?: 0) + (if (replacesPriceId.asKnown() == null) 0 else 1) + - (unitWithProrationConfig.asKnown()?.validity() ?: 0) + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) class Cadence @JsonCreator private constructor(private val value: JsonField) : @@ -33465,6 +34878,115 @@ private constructor( override fun toString() = value.toString() } + class GroupedWithMeteredMinimumConfig + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [GroupedWithMeteredMinimumConfig]. + */ + fun builder() = Builder() + } + + /** A builder for [GroupedWithMeteredMinimumConfig]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from( + groupedWithMeteredMinimumConfig: GroupedWithMeteredMinimumConfig + ) = apply { + additionalProperties = + groupedWithMeteredMinimumConfig.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [GroupedWithMeteredMinimumConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): GroupedWithMeteredMinimumConfig = + GroupedWithMeteredMinimumConfig(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): GroupedWithMeteredMinimumConfig = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedWithMeteredMinimumConfig && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedWithMeteredMinimumConfig{additionalProperties=$additionalProperties}" + } + /** * User specified key-value pairs for the resource. If not present, this defaults to an * empty dictionary. Individual keys can be removed by setting the value to `null`, and the @@ -33699,123 +35221,17 @@ private constructor( override fun toString() = value.toString() } - class UnitWithProrationConfig - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [UnitWithProrationConfig]. - */ - fun builder() = Builder() - } - - /** A builder for [UnitWithProrationConfig]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(unitWithProrationConfig: UnitWithProrationConfig) = apply { - additionalProperties = - unitWithProrationConfig.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [UnitWithProrationConfig]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): UnitWithProrationConfig = - UnitWithProrationConfig(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): UnitWithProrationConfig = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnitWithProrationConfig && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "UnitWithProrationConfig{additionalProperties=$additionalProperties}" - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is UnitWithProration && + return other is GroupedWithMeteredMinimum && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && + compositePriceFilters == other.compositePriceFilters && conversionRate == other.conversionRate && conversionRateConfig == other.conversionRateConfig && createdAt == other.createdAt && @@ -33824,6 +35240,7 @@ private constructor( discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && + groupedWithMeteredMinimumConfig == other.groupedWithMeteredMinimumConfig && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maximum == other.maximum && @@ -33836,7 +35253,6 @@ private constructor( planPhaseOrder == other.planPhaseOrder && priceType == other.priceType && replacesPriceId == other.replacesPriceId && - unitWithProrationConfig == other.unitWithProrationConfig && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties } @@ -33847,6 +35263,7 @@ private constructor( billableMetric, billingCycleConfiguration, cadence, + compositePriceFilters, conversionRate, conversionRateConfig, createdAt, @@ -33855,6 +35272,7 @@ private constructor( discount, externalPriceId, fixedPriceQuantity, + groupedWithMeteredMinimumConfig, invoicingCycleConfiguration, item, maximum, @@ -33867,7 +35285,6 @@ private constructor( planPhaseOrder, priceType, replacesPriceId, - unitWithProrationConfig, dimensionalPriceConfiguration, additionalProperties, ) @@ -33876,15 +35293,16 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "UnitWithProration{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, unitWithProrationConfig=$unitWithProrationConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "GroupedWithMeteredMinimum{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, groupedWithMeteredMinimumConfig=$groupedWithMeteredMinimumConfig, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" } - class GroupedAllocation + class MatrixWithDisplayName private constructor( private val id: JsonField, private val billableMetric: JsonField, private val billingCycleConfiguration: JsonField, private val cadence: JsonField, + private val compositePriceFilters: JsonField>, private val conversionRate: JsonField, private val conversionRateConfig: JsonField, private val createdAt: JsonField, @@ -33893,9 +35311,9 @@ private constructor( private val discount: JsonField, private val externalPriceId: JsonField, private val fixedPriceQuantity: JsonField, - private val groupedAllocationConfig: JsonField, private val invoicingCycleConfiguration: JsonField, private val item: JsonField, + private val matrixWithDisplayNameConfig: JsonField, private val maximum: JsonField, private val maximumAmount: JsonField, private val metadata: JsonField, @@ -33920,6 +35338,9 @@ private constructor( @ExcludeMissing billingCycleConfiguration: JsonField = JsonMissing.of(), @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), + @JsonProperty("composite_price_filters") + @ExcludeMissing + compositePriceFilters: JsonField> = JsonMissing.of(), @JsonProperty("conversion_rate") @ExcludeMissing conversionRate: JsonField = JsonMissing.of(), @@ -33944,13 +35365,13 @@ private constructor( @JsonProperty("fixed_price_quantity") @ExcludeMissing fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("grouped_allocation_config") - @ExcludeMissing - groupedAllocationConfig: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), @JsonProperty("item") @ExcludeMissing item: JsonField = JsonMissing.of(), + @JsonProperty("matrix_with_display_name_config") + @ExcludeMissing + matrixWithDisplayNameConfig: JsonField = JsonMissing.of(), @JsonProperty("maximum") @ExcludeMissing maximum: JsonField = JsonMissing.of(), @JsonProperty("maximum_amount") @ExcludeMissing @@ -33982,6 +35403,7 @@ private constructor( billableMetric, billingCycleConfiguration, cadence, + compositePriceFilters, conversionRate, conversionRateConfig, createdAt, @@ -33990,9 +35412,9 @@ private constructor( discount, externalPriceId, fixedPriceQuantity, - groupedAllocationConfig, invoicingCycleConfiguration, item, + matrixWithDisplayNameConfig, maximum, maximumAmount, metadata, @@ -34032,6 +35454,13 @@ private constructor( */ fun cadence(): Cadence = cadence.getRequired("cadence") + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun compositePriceFilters(): List? = + compositePriceFilters.getNullable("composite_price_filters") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -34081,13 +35510,6 @@ private constructor( */ fun fixedPriceQuantity(): Double? = fixedPriceQuantity.getNullable("fixed_price_quantity") - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun groupedAllocationConfig(): GroupedAllocationConfig = - groupedAllocationConfig.getRequired("grouped_allocation_config") - /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -34101,6 +35523,13 @@ private constructor( */ fun item(): ItemSlim = item.getRequired("item") + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun matrixWithDisplayNameConfig(): MatrixWithDisplayNameConfig = + matrixWithDisplayNameConfig.getRequired("matrix_with_display_name_config") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -34140,7 +35569,7 @@ private constructor( /** * Expected to always return the following: * ```kotlin - * JsonValue.from("grouped_allocation") + * JsonValue.from("matrix_with_display_name") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -34217,6 +35646,16 @@ private constructor( */ @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence + /** + * Returns the raw JSON value of [compositePriceFilters]. + * + * Unlike [compositePriceFilters], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("composite_price_filters") + @ExcludeMissing + fun _compositePriceFilters(): JsonField> = compositePriceFilters + /** * Returns the raw JSON value of [conversionRate]. * @@ -34293,16 +35732,6 @@ private constructor( @ExcludeMissing fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - /** - * Returns the raw JSON value of [groupedAllocationConfig]. - * - * Unlike [groupedAllocationConfig], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("grouped_allocation_config") - @ExcludeMissing - fun _groupedAllocationConfig(): JsonField = groupedAllocationConfig - /** * Returns the raw JSON value of [invoicingCycleConfiguration]. * @@ -34321,6 +35750,17 @@ private constructor( */ @JsonProperty("item") @ExcludeMissing fun _item(): JsonField = item + /** + * Returns the raw JSON value of [matrixWithDisplayNameConfig]. + * + * Unlike [matrixWithDisplayNameConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("matrix_with_display_name_config") + @ExcludeMissing + fun _matrixWithDisplayNameConfig(): JsonField = + matrixWithDisplayNameConfig + /** * Returns the raw JSON value of [maximum]. * @@ -34432,7 +35872,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [GroupedAllocation]. + * Returns a mutable builder for constructing an instance of [MatrixWithDisplayName]. * * The following fields are required: * ```kotlin @@ -34440,6 +35880,7 @@ private constructor( * .billableMetric() * .billingCycleConfiguration() * .cadence() + * .compositePriceFilters() * .conversionRate() * .conversionRateConfig() * .createdAt() @@ -34448,9 +35889,9 @@ private constructor( * .discount() * .externalPriceId() * .fixedPriceQuantity() - * .groupedAllocationConfig() * .invoicingCycleConfiguration() * .item() + * .matrixWithDisplayNameConfig() * .maximum() * .maximumAmount() * .metadata() @@ -34465,13 +35906,14 @@ private constructor( fun builder() = Builder() } - /** A builder for [GroupedAllocation]. */ + /** A builder for [MatrixWithDisplayName]. */ class Builder internal constructor() { private var id: JsonField? = null private var billableMetric: JsonField? = null private var billingCycleConfiguration: JsonField? = null private var cadence: JsonField? = null + private var compositePriceFilters: JsonField>? = null private var conversionRate: JsonField? = null private var conversionRateConfig: JsonField? = null private var createdAt: JsonField? = null @@ -34480,15 +35922,15 @@ private constructor( private var discount: JsonField? = null private var externalPriceId: JsonField? = null private var fixedPriceQuantity: JsonField? = null - private var groupedAllocationConfig: JsonField? = null private var invoicingCycleConfiguration: JsonField? = null private var item: JsonField? = null + private var matrixWithDisplayNameConfig: JsonField? = null private var maximum: JsonField? = null private var maximumAmount: JsonField? = null private var metadata: JsonField? = null private var minimum: JsonField? = null private var minimumAmount: JsonField? = null - private var modelType: JsonValue = JsonValue.from("grouped_allocation") + private var modelType: JsonValue = JsonValue.from("matrix_with_display_name") private var name: JsonField? = null private var planPhaseOrder: JsonField? = null private var priceType: JsonField? = null @@ -34497,34 +35939,36 @@ private constructor( JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(groupedAllocation: GroupedAllocation) = apply { - id = groupedAllocation.id - billableMetric = groupedAllocation.billableMetric - billingCycleConfiguration = groupedAllocation.billingCycleConfiguration - cadence = groupedAllocation.cadence - conversionRate = groupedAllocation.conversionRate - conversionRateConfig = groupedAllocation.conversionRateConfig - createdAt = groupedAllocation.createdAt - creditAllocation = groupedAllocation.creditAllocation - currency = groupedAllocation.currency - discount = groupedAllocation.discount - externalPriceId = groupedAllocation.externalPriceId - fixedPriceQuantity = groupedAllocation.fixedPriceQuantity - groupedAllocationConfig = groupedAllocation.groupedAllocationConfig - invoicingCycleConfiguration = groupedAllocation.invoicingCycleConfiguration - item = groupedAllocation.item - maximum = groupedAllocation.maximum - maximumAmount = groupedAllocation.maximumAmount - metadata = groupedAllocation.metadata - minimum = groupedAllocation.minimum - minimumAmount = groupedAllocation.minimumAmount - modelType = groupedAllocation.modelType - name = groupedAllocation.name - planPhaseOrder = groupedAllocation.planPhaseOrder - priceType = groupedAllocation.priceType - replacesPriceId = groupedAllocation.replacesPriceId - dimensionalPriceConfiguration = groupedAllocation.dimensionalPriceConfiguration - additionalProperties = groupedAllocation.additionalProperties.toMutableMap() + internal fun from(matrixWithDisplayName: MatrixWithDisplayName) = apply { + id = matrixWithDisplayName.id + billableMetric = matrixWithDisplayName.billableMetric + billingCycleConfiguration = matrixWithDisplayName.billingCycleConfiguration + cadence = matrixWithDisplayName.cadence + compositePriceFilters = + matrixWithDisplayName.compositePriceFilters.map { it.toMutableList() } + conversionRate = matrixWithDisplayName.conversionRate + conversionRateConfig = matrixWithDisplayName.conversionRateConfig + createdAt = matrixWithDisplayName.createdAt + creditAllocation = matrixWithDisplayName.creditAllocation + currency = matrixWithDisplayName.currency + discount = matrixWithDisplayName.discount + externalPriceId = matrixWithDisplayName.externalPriceId + fixedPriceQuantity = matrixWithDisplayName.fixedPriceQuantity + invoicingCycleConfiguration = matrixWithDisplayName.invoicingCycleConfiguration + item = matrixWithDisplayName.item + matrixWithDisplayNameConfig = matrixWithDisplayName.matrixWithDisplayNameConfig + maximum = matrixWithDisplayName.maximum + maximumAmount = matrixWithDisplayName.maximumAmount + metadata = matrixWithDisplayName.metadata + minimum = matrixWithDisplayName.minimum + minimumAmount = matrixWithDisplayName.minimumAmount + modelType = matrixWithDisplayName.modelType + name = matrixWithDisplayName.name + planPhaseOrder = matrixWithDisplayName.planPhaseOrder + priceType = matrixWithDisplayName.priceType + replacesPriceId = matrixWithDisplayName.replacesPriceId + dimensionalPriceConfiguration = matrixWithDisplayName.dimensionalPriceConfiguration + additionalProperties = matrixWithDisplayName.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) @@ -34577,6 +36021,34 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + fun compositePriceFilters(compositePriceFilters: List?) = + compositePriceFilters(JsonField.ofNullable(compositePriceFilters)) + + /** + * Sets [Builder.compositePriceFilters] to an arbitrary JSON value. + * + * You should usually call [Builder.compositePriceFilters] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun compositePriceFilters( + compositePriceFilters: JsonField> + ) = apply { + this.compositePriceFilters = compositePriceFilters.map { it.toMutableList() } + } + + /** + * Adds a single [TransformPriceFilter] to [compositePriceFilters]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addCompositePriceFilter(compositePriceFilter: TransformPriceFilter) = apply { + compositePriceFilters = + (compositePriceFilters ?: JsonField.of(mutableListOf())).also { + checkKnown("compositePriceFilters", it).add(compositePriceFilter) + } + } + fun conversionRate(conversionRate: Double?) = conversionRate(JsonField.ofNullable(conversionRate)) @@ -34818,20 +36290,6 @@ private constructor( this.fixedPriceQuantity = fixedPriceQuantity } - fun groupedAllocationConfig(groupedAllocationConfig: GroupedAllocationConfig) = - groupedAllocationConfig(JsonField.of(groupedAllocationConfig)) - - /** - * Sets [Builder.groupedAllocationConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.groupedAllocationConfig] with a well-typed - * [GroupedAllocationConfig] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun groupedAllocationConfig( - groupedAllocationConfig: JsonField - ) = apply { this.groupedAllocationConfig = groupedAllocationConfig } - fun invoicingCycleConfiguration( invoicingCycleConfiguration: BillingCycleConfiguration? ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) @@ -34858,6 +36316,21 @@ private constructor( */ fun item(item: JsonField) = apply { this.item = item } + fun matrixWithDisplayNameConfig( + matrixWithDisplayNameConfig: MatrixWithDisplayNameConfig + ) = matrixWithDisplayNameConfig(JsonField.of(matrixWithDisplayNameConfig)) + + /** + * Sets [Builder.matrixWithDisplayNameConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.matrixWithDisplayNameConfig] with a well-typed + * [MatrixWithDisplayNameConfig] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun matrixWithDisplayNameConfig( + matrixWithDisplayNameConfig: JsonField + ) = apply { this.matrixWithDisplayNameConfig = matrixWithDisplayNameConfig } + @Deprecated("deprecated") fun maximum(maximum: Maximum?) = maximum(JsonField.ofNullable(maximum)) @@ -34938,7 +36411,7 @@ private constructor( * It is usually unnecessary to call this method because the field defaults to the * following: * ```kotlin - * JsonValue.from("grouped_allocation") + * JsonValue.from("matrix_with_display_name") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -35042,7 +36515,7 @@ private constructor( } /** - * Returns an immutable instance of [GroupedAllocation]. + * Returns an immutable instance of [MatrixWithDisplayName]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -35052,6 +36525,7 @@ private constructor( * .billableMetric() * .billingCycleConfiguration() * .cadence() + * .compositePriceFilters() * .conversionRate() * .conversionRateConfig() * .createdAt() @@ -35060,9 +36534,9 @@ private constructor( * .discount() * .externalPriceId() * .fixedPriceQuantity() - * .groupedAllocationConfig() * .invoicingCycleConfiguration() * .item() + * .matrixWithDisplayNameConfig() * .maximum() * .maximumAmount() * .metadata() @@ -35076,12 +36550,15 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): GroupedAllocation = - GroupedAllocation( + fun build(): MatrixWithDisplayName = + MatrixWithDisplayName( checkRequired("id", id), checkRequired("billableMetric", billableMetric), checkRequired("billingCycleConfiguration", billingCycleConfiguration), checkRequired("cadence", cadence), + checkRequired("compositePriceFilters", compositePriceFilters).map { + it.toImmutable() + }, checkRequired("conversionRate", conversionRate), checkRequired("conversionRateConfig", conversionRateConfig), checkRequired("createdAt", createdAt), @@ -35090,9 +36567,9 @@ private constructor( checkRequired("discount", discount), checkRequired("externalPriceId", externalPriceId), checkRequired("fixedPriceQuantity", fixedPriceQuantity), - checkRequired("groupedAllocationConfig", groupedAllocationConfig), checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), checkRequired("item", item), + checkRequired("matrixWithDisplayNameConfig", matrixWithDisplayNameConfig), checkRequired("maximum", maximum), checkRequired("maximumAmount", maximumAmount), checkRequired("metadata", metadata), @@ -35110,7 +36587,7 @@ private constructor( private var validated: Boolean = false - fun validate(): GroupedAllocation = apply { + fun validate(): MatrixWithDisplayName = apply { if (validated) { return@apply } @@ -35119,6 +36596,7 @@ private constructor( billableMetric()?.validate() billingCycleConfiguration().validate() cadence().validate() + compositePriceFilters()?.forEach { it.validate() } conversionRate() conversionRateConfig()?.validate() createdAt() @@ -35127,16 +36605,16 @@ private constructor( discount()?.validate() externalPriceId() fixedPriceQuantity() - groupedAllocationConfig().validate() invoicingCycleConfiguration()?.validate() item().validate() + matrixWithDisplayNameConfig().validate() maximum()?.validate() maximumAmount() metadata().validate() minimum()?.validate() minimumAmount() _modelType().let { - if (it != JsonValue.from("grouped_allocation")) { + if (it != JsonValue.from("matrix_with_display_name")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } @@ -35167,6 +36645,7 @@ private constructor( (billableMetric.asKnown()?.validity() ?: 0) + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + (cadence.asKnown()?.validity() ?: 0) + + (compositePriceFilters.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + (if (conversionRate.asKnown() == null) 0 else 1) + (conversionRateConfig.asKnown()?.validity() ?: 0) + (if (createdAt.asKnown() == null) 0 else 1) + @@ -35175,15 +36654,15 @@ private constructor( (discount.asKnown()?.validity() ?: 0) + (if (externalPriceId.asKnown() == null) 0 else 1) + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + - (groupedAllocationConfig.asKnown()?.validity() ?: 0) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + (item.asKnown()?.validity() ?: 0) + + (matrixWithDisplayNameConfig.asKnown()?.validity() ?: 0) + (maximum.asKnown()?.validity() ?: 0) + (if (maximumAmount.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) + (minimum.asKnown()?.validity() ?: 0) + (if (minimumAmount.asKnown() == null) 0 else 1) + - modelType.let { if (it == JsonValue.from("grouped_allocation")) 1 else 0 } + + modelType.let { if (it == JsonValue.from("matrix_with_display_name")) 1 else 0 } + (if (name.asKnown() == null) 0 else 1) + (if (planPhaseOrder.asKnown() == null) 0 else 1) + (priceType.asKnown()?.validity() ?: 0) + @@ -35342,7 +36821,7 @@ private constructor( override fun toString() = value.toString() } - class GroupedAllocationConfig + class MatrixWithDisplayNameConfig @JsonCreator private constructor( @com.fasterxml.jackson.annotation.JsonValue @@ -35359,20 +36838,21 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [GroupedAllocationConfig]. + * [MatrixWithDisplayNameConfig]. */ fun builder() = Builder() } - /** A builder for [GroupedAllocationConfig]. */ + /** A builder for [MatrixWithDisplayNameConfig]. */ class Builder internal constructor() { private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(groupedAllocationConfig: GroupedAllocationConfig) = apply { - additionalProperties = - groupedAllocationConfig.additionalProperties.toMutableMap() - } + internal fun from(matrixWithDisplayNameConfig: MatrixWithDisplayNameConfig) = + apply { + additionalProperties = + matrixWithDisplayNameConfig.additionalProperties.toMutableMap() + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -35397,17 +36877,17 @@ private constructor( } /** - * Returns an immutable instance of [GroupedAllocationConfig]. + * Returns an immutable instance of [MatrixWithDisplayNameConfig]. * * Further updates to this [Builder] will not mutate the returned instance. */ - fun build(): GroupedAllocationConfig = - GroupedAllocationConfig(additionalProperties.toImmutable()) + fun build(): MatrixWithDisplayNameConfig = + MatrixWithDisplayNameConfig(additionalProperties.toImmutable()) } private var validated: Boolean = false - fun validate(): GroupedAllocationConfig = apply { + fun validate(): MatrixWithDisplayNameConfig = apply { if (validated) { return@apply } @@ -35437,7 +36917,7 @@ private constructor( return true } - return other is GroupedAllocationConfig && + return other is MatrixWithDisplayNameConfig && additionalProperties == other.additionalProperties } @@ -35446,7 +36926,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "GroupedAllocationConfig{additionalProperties=$additionalProperties}" + "MatrixWithDisplayNameConfig{additionalProperties=$additionalProperties}" } /** @@ -35688,11 +37168,12 @@ private constructor( return true } - return other is GroupedAllocation && + return other is MatrixWithDisplayName && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && + compositePriceFilters == other.compositePriceFilters && conversionRate == other.conversionRate && conversionRateConfig == other.conversionRateConfig && createdAt == other.createdAt && @@ -35701,9 +37182,9 @@ private constructor( discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && - groupedAllocationConfig == other.groupedAllocationConfig && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && + matrixWithDisplayNameConfig == other.matrixWithDisplayNameConfig && maximum == other.maximum && maximumAmount == other.maximumAmount && metadata == other.metadata && @@ -35724,6 +37205,7 @@ private constructor( billableMetric, billingCycleConfiguration, cadence, + compositePriceFilters, conversionRate, conversionRateConfig, createdAt, @@ -35732,9 +37214,9 @@ private constructor( discount, externalPriceId, fixedPriceQuantity, - groupedAllocationConfig, invoicingCycleConfiguration, item, + matrixWithDisplayNameConfig, maximum, maximumAmount, metadata, @@ -35753,15 +37235,17 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "GroupedAllocation{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, groupedAllocationConfig=$groupedAllocationConfig, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "MatrixWithDisplayName{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, matrixWithDisplayNameConfig=$matrixWithDisplayNameConfig, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" } - class GroupedWithProratedMinimum + class BulkWithProration private constructor( private val id: JsonField, private val billableMetric: JsonField, private val billingCycleConfiguration: JsonField, + private val bulkWithProrationConfig: JsonField, private val cadence: JsonField, + private val compositePriceFilters: JsonField>, private val conversionRate: JsonField, private val conversionRateConfig: JsonField, private val createdAt: JsonField, @@ -35770,7 +37254,6 @@ private constructor( private val discount: JsonField, private val externalPriceId: JsonField, private val fixedPriceQuantity: JsonField, - private val groupedWithProratedMinimumConfig: JsonField, private val invoicingCycleConfiguration: JsonField, private val item: JsonField, private val maximum: JsonField, @@ -35796,7 +37279,13 @@ private constructor( @JsonProperty("billing_cycle_configuration") @ExcludeMissing billingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("bulk_with_proration_config") + @ExcludeMissing + bulkWithProrationConfig: JsonField = JsonMissing.of(), @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), + @JsonProperty("composite_price_filters") + @ExcludeMissing + compositePriceFilters: JsonField> = JsonMissing.of(), @JsonProperty("conversion_rate") @ExcludeMissing conversionRate: JsonField = JsonMissing.of(), @@ -35821,10 +37310,6 @@ private constructor( @JsonProperty("fixed_price_quantity") @ExcludeMissing fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("grouped_with_prorated_minimum_config") - @ExcludeMissing - groupedWithProratedMinimumConfig: JsonField = - JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), @@ -35859,7 +37344,9 @@ private constructor( id, billableMetric, billingCycleConfiguration, + bulkWithProrationConfig, cadence, + compositePriceFilters, conversionRate, conversionRateConfig, createdAt, @@ -35868,7 +37355,6 @@ private constructor( discount, externalPriceId, fixedPriceQuantity, - groupedWithProratedMinimumConfig, invoicingCycleConfiguration, item, maximum, @@ -35904,12 +37390,26 @@ private constructor( fun billingCycleConfiguration(): BillingCycleConfiguration = billingCycleConfiguration.getRequired("billing_cycle_configuration") + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun bulkWithProrationConfig(): BulkWithProrationConfig = + bulkWithProrationConfig.getRequired("bulk_with_proration_config") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ fun cadence(): Cadence = cadence.getRequired("cadence") + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun compositePriceFilters(): List? = + compositePriceFilters.getNullable("composite_price_filters") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -35959,13 +37459,6 @@ private constructor( */ fun fixedPriceQuantity(): Double? = fixedPriceQuantity.getNullable("fixed_price_quantity") - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun groupedWithProratedMinimumConfig(): GroupedWithProratedMinimumConfig = - groupedWithProratedMinimumConfig.getRequired("grouped_with_prorated_minimum_config") - /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -36018,7 +37511,7 @@ private constructor( /** * Expected to always return the following: * ```kotlin - * JsonValue.from("grouped_with_prorated_minimum") + * JsonValue.from("bulk_with_proration") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -36088,6 +37581,16 @@ private constructor( fun _billingCycleConfiguration(): JsonField = billingCycleConfiguration + /** + * Returns the raw JSON value of [bulkWithProrationConfig]. + * + * Unlike [bulkWithProrationConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("bulk_with_proration_config") + @ExcludeMissing + fun _bulkWithProrationConfig(): JsonField = bulkWithProrationConfig + /** * Returns the raw JSON value of [cadence]. * @@ -36095,6 +37598,16 @@ private constructor( */ @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence + /** + * Returns the raw JSON value of [compositePriceFilters]. + * + * Unlike [compositePriceFilters], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("composite_price_filters") + @ExcludeMissing + fun _compositePriceFilters(): JsonField> = compositePriceFilters + /** * Returns the raw JSON value of [conversionRate]. * @@ -36171,17 +37684,6 @@ private constructor( @ExcludeMissing fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - /** - * Returns the raw JSON value of [groupedWithProratedMinimumConfig]. - * - * Unlike [groupedWithProratedMinimumConfig], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("grouped_with_prorated_minimum_config") - @ExcludeMissing - fun _groupedWithProratedMinimumConfig(): JsonField = - groupedWithProratedMinimumConfig - /** * Returns the raw JSON value of [invoicingCycleConfiguration]. * @@ -36311,15 +37813,16 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [GroupedWithProratedMinimum]. + * Returns a mutable builder for constructing an instance of [BulkWithProration]. * * The following fields are required: * ```kotlin * .id() * .billableMetric() * .billingCycleConfiguration() + * .bulkWithProrationConfig() * .cadence() + * .compositePriceFilters() * .conversionRate() * .conversionRateConfig() * .createdAt() @@ -36328,7 +37831,6 @@ private constructor( * .discount() * .externalPriceId() * .fixedPriceQuantity() - * .groupedWithProratedMinimumConfig() * .invoicingCycleConfiguration() * .item() * .maximum() @@ -36345,13 +37847,15 @@ private constructor( fun builder() = Builder() } - /** A builder for [GroupedWithProratedMinimum]. */ + /** A builder for [BulkWithProration]. */ class Builder internal constructor() { private var id: JsonField? = null private var billableMetric: JsonField? = null private var billingCycleConfiguration: JsonField? = null + private var bulkWithProrationConfig: JsonField? = null private var cadence: JsonField? = null + private var compositePriceFilters: JsonField>? = null private var conversionRate: JsonField? = null private var conversionRateConfig: JsonField? = null private var createdAt: JsonField? = null @@ -36360,9 +37864,6 @@ private constructor( private var discount: JsonField? = null private var externalPriceId: JsonField? = null private var fixedPriceQuantity: JsonField? = null - private var groupedWithProratedMinimumConfig: - JsonField? = - null private var invoicingCycleConfiguration: JsonField? = null private var item: JsonField? = null private var maximum: JsonField? = null @@ -36370,7 +37871,7 @@ private constructor( private var metadata: JsonField? = null private var minimum: JsonField? = null private var minimumAmount: JsonField? = null - private var modelType: JsonValue = JsonValue.from("grouped_with_prorated_minimum") + private var modelType: JsonValue = JsonValue.from("bulk_with_proration") private var name: JsonField? = null private var planPhaseOrder: JsonField? = null private var priceType: JsonField? = null @@ -36379,37 +37880,36 @@ private constructor( JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(groupedWithProratedMinimum: GroupedWithProratedMinimum) = apply { - id = groupedWithProratedMinimum.id - billableMetric = groupedWithProratedMinimum.billableMetric - billingCycleConfiguration = groupedWithProratedMinimum.billingCycleConfiguration - cadence = groupedWithProratedMinimum.cadence - conversionRate = groupedWithProratedMinimum.conversionRate - conversionRateConfig = groupedWithProratedMinimum.conversionRateConfig - createdAt = groupedWithProratedMinimum.createdAt - creditAllocation = groupedWithProratedMinimum.creditAllocation - currency = groupedWithProratedMinimum.currency - discount = groupedWithProratedMinimum.discount - externalPriceId = groupedWithProratedMinimum.externalPriceId - fixedPriceQuantity = groupedWithProratedMinimum.fixedPriceQuantity - groupedWithProratedMinimumConfig = - groupedWithProratedMinimum.groupedWithProratedMinimumConfig - invoicingCycleConfiguration = groupedWithProratedMinimum.invoicingCycleConfiguration - item = groupedWithProratedMinimum.item - maximum = groupedWithProratedMinimum.maximum - maximumAmount = groupedWithProratedMinimum.maximumAmount - metadata = groupedWithProratedMinimum.metadata - minimum = groupedWithProratedMinimum.minimum - minimumAmount = groupedWithProratedMinimum.minimumAmount - modelType = groupedWithProratedMinimum.modelType - name = groupedWithProratedMinimum.name - planPhaseOrder = groupedWithProratedMinimum.planPhaseOrder - priceType = groupedWithProratedMinimum.priceType - replacesPriceId = groupedWithProratedMinimum.replacesPriceId - dimensionalPriceConfiguration = - groupedWithProratedMinimum.dimensionalPriceConfiguration - additionalProperties = - groupedWithProratedMinimum.additionalProperties.toMutableMap() + internal fun from(bulkWithProration: BulkWithProration) = apply { + id = bulkWithProration.id + billableMetric = bulkWithProration.billableMetric + billingCycleConfiguration = bulkWithProration.billingCycleConfiguration + bulkWithProrationConfig = bulkWithProration.bulkWithProrationConfig + cadence = bulkWithProration.cadence + compositePriceFilters = + bulkWithProration.compositePriceFilters.map { it.toMutableList() } + conversionRate = bulkWithProration.conversionRate + conversionRateConfig = bulkWithProration.conversionRateConfig + createdAt = bulkWithProration.createdAt + creditAllocation = bulkWithProration.creditAllocation + currency = bulkWithProration.currency + discount = bulkWithProration.discount + externalPriceId = bulkWithProration.externalPriceId + fixedPriceQuantity = bulkWithProration.fixedPriceQuantity + invoicingCycleConfiguration = bulkWithProration.invoicingCycleConfiguration + item = bulkWithProration.item + maximum = bulkWithProration.maximum + maximumAmount = bulkWithProration.maximumAmount + metadata = bulkWithProration.metadata + minimum = bulkWithProration.minimum + minimumAmount = bulkWithProration.minimumAmount + modelType = bulkWithProration.modelType + name = bulkWithProration.name + planPhaseOrder = bulkWithProration.planPhaseOrder + priceType = bulkWithProration.priceType + replacesPriceId = bulkWithProration.replacesPriceId + dimensionalPriceConfiguration = bulkWithProration.dimensionalPriceConfiguration + additionalProperties = bulkWithProration.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) @@ -36451,6 +37951,20 @@ private constructor( billingCycleConfiguration: JsonField ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + fun bulkWithProrationConfig(bulkWithProrationConfig: BulkWithProrationConfig) = + bulkWithProrationConfig(JsonField.of(bulkWithProrationConfig)) + + /** + * Sets [Builder.bulkWithProrationConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.bulkWithProrationConfig] with a well-typed + * [BulkWithProrationConfig] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun bulkWithProrationConfig( + bulkWithProrationConfig: JsonField + ) = apply { this.bulkWithProrationConfig = bulkWithProrationConfig } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) /** @@ -36462,6 +37976,34 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + fun compositePriceFilters(compositePriceFilters: List?) = + compositePriceFilters(JsonField.ofNullable(compositePriceFilters)) + + /** + * Sets [Builder.compositePriceFilters] to an arbitrary JSON value. + * + * You should usually call [Builder.compositePriceFilters] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun compositePriceFilters( + compositePriceFilters: JsonField> + ) = apply { + this.compositePriceFilters = compositePriceFilters.map { it.toMutableList() } + } + + /** + * Adds a single [TransformPriceFilter] to [compositePriceFilters]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addCompositePriceFilter(compositePriceFilter: TransformPriceFilter) = apply { + compositePriceFilters = + (compositePriceFilters ?: JsonField.of(mutableListOf())).also { + checkKnown("compositePriceFilters", it).add(compositePriceFilter) + } + } + fun conversionRate(conversionRate: Double?) = conversionRate(JsonField.ofNullable(conversionRate)) @@ -36703,21 +38245,6 @@ private constructor( this.fixedPriceQuantity = fixedPriceQuantity } - fun groupedWithProratedMinimumConfig( - groupedWithProratedMinimumConfig: GroupedWithProratedMinimumConfig - ) = groupedWithProratedMinimumConfig(JsonField.of(groupedWithProratedMinimumConfig)) - - /** - * Sets [Builder.groupedWithProratedMinimumConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.groupedWithProratedMinimumConfig] with a well-typed - * [GroupedWithProratedMinimumConfig] value instead. This method is primarily for - * setting the field to an undocumented or not yet supported value. - */ - fun groupedWithProratedMinimumConfig( - groupedWithProratedMinimumConfig: JsonField - ) = apply { this.groupedWithProratedMinimumConfig = groupedWithProratedMinimumConfig } - fun invoicingCycleConfiguration( invoicingCycleConfiguration: BillingCycleConfiguration? ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) @@ -36824,7 +38351,7 @@ private constructor( * It is usually unnecessary to call this method because the field defaults to the * following: * ```kotlin - * JsonValue.from("grouped_with_prorated_minimum") + * JsonValue.from("bulk_with_proration") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -36928,7 +38455,7 @@ private constructor( } /** - * Returns an immutable instance of [GroupedWithProratedMinimum]. + * Returns an immutable instance of [BulkWithProration]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -36937,7 +38464,9 @@ private constructor( * .id() * .billableMetric() * .billingCycleConfiguration() + * .bulkWithProrationConfig() * .cadence() + * .compositePriceFilters() * .conversionRate() * .conversionRateConfig() * .createdAt() @@ -36946,7 +38475,6 @@ private constructor( * .discount() * .externalPriceId() * .fixedPriceQuantity() - * .groupedWithProratedMinimumConfig() * .invoicingCycleConfiguration() * .item() * .maximum() @@ -36962,12 +38490,16 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): GroupedWithProratedMinimum = - GroupedWithProratedMinimum( + fun build(): BulkWithProration = + BulkWithProration( checkRequired("id", id), checkRequired("billableMetric", billableMetric), checkRequired("billingCycleConfiguration", billingCycleConfiguration), + checkRequired("bulkWithProrationConfig", bulkWithProrationConfig), checkRequired("cadence", cadence), + checkRequired("compositePriceFilters", compositePriceFilters).map { + it.toImmutable() + }, checkRequired("conversionRate", conversionRate), checkRequired("conversionRateConfig", conversionRateConfig), checkRequired("createdAt", createdAt), @@ -36976,10 +38508,6 @@ private constructor( checkRequired("discount", discount), checkRequired("externalPriceId", externalPriceId), checkRequired("fixedPriceQuantity", fixedPriceQuantity), - checkRequired( - "groupedWithProratedMinimumConfig", - groupedWithProratedMinimumConfig, - ), checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), checkRequired("item", item), checkRequired("maximum", maximum), @@ -36999,7 +38527,7 @@ private constructor( private var validated: Boolean = false - fun validate(): GroupedWithProratedMinimum = apply { + fun validate(): BulkWithProration = apply { if (validated) { return@apply } @@ -37007,7 +38535,9 @@ private constructor( id() billableMetric()?.validate() billingCycleConfiguration().validate() + bulkWithProrationConfig().validate() cadence().validate() + compositePriceFilters()?.forEach { it.validate() } conversionRate() conversionRateConfig()?.validate() createdAt() @@ -37016,7 +38546,6 @@ private constructor( discount()?.validate() externalPriceId() fixedPriceQuantity() - groupedWithProratedMinimumConfig().validate() invoicingCycleConfiguration()?.validate() item().validate() maximum()?.validate() @@ -37025,7 +38554,7 @@ private constructor( minimum()?.validate() minimumAmount() _modelType().let { - if (it != JsonValue.from("grouped_with_prorated_minimum")) { + if (it != JsonValue.from("bulk_with_proration")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } @@ -37055,7 +38584,9 @@ private constructor( (if (id.asKnown() == null) 0 else 1) + (billableMetric.asKnown()?.validity() ?: 0) + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (bulkWithProrationConfig.asKnown()?.validity() ?: 0) + (cadence.asKnown()?.validity() ?: 0) + + (compositePriceFilters.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + (if (conversionRate.asKnown() == null) 0 else 1) + (conversionRateConfig.asKnown()?.validity() ?: 0) + (if (createdAt.asKnown() == null) 0 else 1) + @@ -37064,7 +38595,6 @@ private constructor( (discount.asKnown()?.validity() ?: 0) + (if (externalPriceId.asKnown() == null) 0 else 1) + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + - (groupedWithProratedMinimumConfig.asKnown()?.validity() ?: 0) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + (item.asKnown()?.validity() ?: 0) + (maximum.asKnown()?.validity() ?: 0) + @@ -37072,15 +38602,120 @@ private constructor( (metadata.asKnown()?.validity() ?: 0) + (minimum.asKnown()?.validity() ?: 0) + (if (minimumAmount.asKnown() == null) 0 else 1) + - modelType.let { - if (it == JsonValue.from("grouped_with_prorated_minimum")) 1 else 0 - } + + modelType.let { if (it == JsonValue.from("bulk_with_proration")) 1 else 0 } + (if (name.asKnown() == null) 0 else 1) + (if (planPhaseOrder.asKnown() == null) 0 else 1) + (priceType.asKnown()?.validity() ?: 0) + (if (replacesPriceId.asKnown() == null) 0 else 1) + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + class BulkWithProrationConfig + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [BulkWithProrationConfig]. + */ + fun builder() = Builder() + } + + /** A builder for [BulkWithProrationConfig]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(bulkWithProrationConfig: BulkWithProrationConfig) = apply { + additionalProperties = + bulkWithProrationConfig.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BulkWithProrationConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): BulkWithProrationConfig = + BulkWithProrationConfig(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): BulkWithProrationConfig = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BulkWithProrationConfig && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BulkWithProrationConfig{additionalProperties=$additionalProperties}" + } + class Cadence @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -37233,115 +38868,6 @@ private constructor( override fun toString() = value.toString() } - class GroupedWithProratedMinimumConfig - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [GroupedWithProratedMinimumConfig]. - */ - fun builder() = Builder() - } - - /** A builder for [GroupedWithProratedMinimumConfig]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from( - groupedWithProratedMinimumConfig: GroupedWithProratedMinimumConfig - ) = apply { - additionalProperties = - groupedWithProratedMinimumConfig.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [GroupedWithProratedMinimumConfig]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): GroupedWithProratedMinimumConfig = - GroupedWithProratedMinimumConfig(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): GroupedWithProratedMinimumConfig = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is GroupedWithProratedMinimumConfig && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "GroupedWithProratedMinimumConfig{additionalProperties=$additionalProperties}" - } - /** * User specified key-value pairs for the resource. If not present, this defaults to an * empty dictionary. Individual keys can be removed by setting the value to `null`, and the @@ -37581,11 +39107,13 @@ private constructor( return true } - return other is GroupedWithProratedMinimum && + return other is BulkWithProration && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && + bulkWithProrationConfig == other.bulkWithProrationConfig && cadence == other.cadence && + compositePriceFilters == other.compositePriceFilters && conversionRate == other.conversionRate && conversionRateConfig == other.conversionRateConfig && createdAt == other.createdAt && @@ -37594,7 +39122,6 @@ private constructor( discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && - groupedWithProratedMinimumConfig == other.groupedWithProratedMinimumConfig && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maximum == other.maximum && @@ -37616,7 +39143,9 @@ private constructor( id, billableMetric, billingCycleConfiguration, + bulkWithProrationConfig, cadence, + compositePriceFilters, conversionRate, conversionRateConfig, createdAt, @@ -37625,7 +39154,6 @@ private constructor( discount, externalPriceId, fixedPriceQuantity, - groupedWithProratedMinimumConfig, invoicingCycleConfiguration, item, maximum, @@ -37646,15 +39174,16 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "GroupedWithProratedMinimum{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, groupedWithProratedMinimumConfig=$groupedWithProratedMinimumConfig, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "BulkWithProration{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, bulkWithProrationConfig=$bulkWithProrationConfig, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" } - class GroupedWithMeteredMinimum + class GroupedTieredPackage private constructor( private val id: JsonField, private val billableMetric: JsonField, private val billingCycleConfiguration: JsonField, private val cadence: JsonField, + private val compositePriceFilters: JsonField>, private val conversionRate: JsonField, private val conversionRateConfig: JsonField, private val createdAt: JsonField, @@ -37663,7 +39192,7 @@ private constructor( private val discount: JsonField, private val externalPriceId: JsonField, private val fixedPriceQuantity: JsonField, - private val groupedWithMeteredMinimumConfig: JsonField, + private val groupedTieredPackageConfig: JsonField, private val invoicingCycleConfiguration: JsonField, private val item: JsonField, private val maximum: JsonField, @@ -37690,6 +39219,9 @@ private constructor( @ExcludeMissing billingCycleConfiguration: JsonField = JsonMissing.of(), @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), + @JsonProperty("composite_price_filters") + @ExcludeMissing + compositePriceFilters: JsonField> = JsonMissing.of(), @JsonProperty("conversion_rate") @ExcludeMissing conversionRate: JsonField = JsonMissing.of(), @@ -37714,10 +39246,9 @@ private constructor( @JsonProperty("fixed_price_quantity") @ExcludeMissing fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("grouped_with_metered_minimum_config") + @JsonProperty("grouped_tiered_package_config") @ExcludeMissing - groupedWithMeteredMinimumConfig: JsonField = - JsonMissing.of(), + groupedTieredPackageConfig: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), @@ -37753,6 +39284,7 @@ private constructor( billableMetric, billingCycleConfiguration, cadence, + compositePriceFilters, conversionRate, conversionRateConfig, createdAt, @@ -37761,7 +39293,7 @@ private constructor( discount, externalPriceId, fixedPriceQuantity, - groupedWithMeteredMinimumConfig, + groupedTieredPackageConfig, invoicingCycleConfiguration, item, maximum, @@ -37803,6 +39335,13 @@ private constructor( */ fun cadence(): Cadence = cadence.getRequired("cadence") + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun compositePriceFilters(): List? = + compositePriceFilters.getNullable("composite_price_filters") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -37856,8 +39395,8 @@ private constructor( * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ - fun groupedWithMeteredMinimumConfig(): GroupedWithMeteredMinimumConfig = - groupedWithMeteredMinimumConfig.getRequired("grouped_with_metered_minimum_config") + fun groupedTieredPackageConfig(): GroupedTieredPackageConfig = + groupedTieredPackageConfig.getRequired("grouped_tiered_package_config") /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the @@ -37911,7 +39450,7 @@ private constructor( /** * Expected to always return the following: * ```kotlin - * JsonValue.from("grouped_with_metered_minimum") + * JsonValue.from("grouped_tiered_package") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -37988,6 +39527,16 @@ private constructor( */ @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence + /** + * Returns the raw JSON value of [compositePriceFilters]. + * + * Unlike [compositePriceFilters], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("composite_price_filters") + @ExcludeMissing + fun _compositePriceFilters(): JsonField> = compositePriceFilters + /** * Returns the raw JSON value of [conversionRate]. * @@ -38065,15 +39614,15 @@ private constructor( fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity /** - * Returns the raw JSON value of [groupedWithMeteredMinimumConfig]. + * Returns the raw JSON value of [groupedTieredPackageConfig]. * - * Unlike [groupedWithMeteredMinimumConfig], this method doesn't throw if the JSON field has - * an unexpected type. + * Unlike [groupedTieredPackageConfig], this method doesn't throw if the JSON field has an + * unexpected type. */ - @JsonProperty("grouped_with_metered_minimum_config") + @JsonProperty("grouped_tiered_package_config") @ExcludeMissing - fun _groupedWithMeteredMinimumConfig(): JsonField = - groupedWithMeteredMinimumConfig + fun _groupedTieredPackageConfig(): JsonField = + groupedTieredPackageConfig /** * Returns the raw JSON value of [invoicingCycleConfiguration]. @@ -38204,8 +39753,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [GroupedWithMeteredMinimum]. + * Returns a mutable builder for constructing an instance of [GroupedTieredPackage]. * * The following fields are required: * ```kotlin @@ -38213,6 +39761,7 @@ private constructor( * .billableMetric() * .billingCycleConfiguration() * .cadence() + * .compositePriceFilters() * .conversionRate() * .conversionRateConfig() * .createdAt() @@ -38221,7 +39770,7 @@ private constructor( * .discount() * .externalPriceId() * .fixedPriceQuantity() - * .groupedWithMeteredMinimumConfig() + * .groupedTieredPackageConfig() * .invoicingCycleConfiguration() * .item() * .maximum() @@ -38238,13 +39787,14 @@ private constructor( fun builder() = Builder() } - /** A builder for [GroupedWithMeteredMinimum]. */ + /** A builder for [GroupedTieredPackage]. */ class Builder internal constructor() { private var id: JsonField? = null private var billableMetric: JsonField? = null private var billingCycleConfiguration: JsonField? = null private var cadence: JsonField? = null + private var compositePriceFilters: JsonField>? = null private var conversionRate: JsonField? = null private var conversionRateConfig: JsonField? = null private var createdAt: JsonField? = null @@ -38253,9 +39803,7 @@ private constructor( private var discount: JsonField? = null private var externalPriceId: JsonField? = null private var fixedPriceQuantity: JsonField? = null - private var groupedWithMeteredMinimumConfig: - JsonField? = - null + private var groupedTieredPackageConfig: JsonField? = null private var invoicingCycleConfiguration: JsonField? = null private var item: JsonField? = null private var maximum: JsonField? = null @@ -38263,7 +39811,7 @@ private constructor( private var metadata: JsonField? = null private var minimum: JsonField? = null private var minimumAmount: JsonField? = null - private var modelType: JsonValue = JsonValue.from("grouped_with_metered_minimum") + private var modelType: JsonValue = JsonValue.from("grouped_tiered_package") private var name: JsonField? = null private var planPhaseOrder: JsonField? = null private var priceType: JsonField? = null @@ -38272,36 +39820,36 @@ private constructor( JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(groupedWithMeteredMinimum: GroupedWithMeteredMinimum) = apply { - id = groupedWithMeteredMinimum.id - billableMetric = groupedWithMeteredMinimum.billableMetric - billingCycleConfiguration = groupedWithMeteredMinimum.billingCycleConfiguration - cadence = groupedWithMeteredMinimum.cadence - conversionRate = groupedWithMeteredMinimum.conversionRate - conversionRateConfig = groupedWithMeteredMinimum.conversionRateConfig - createdAt = groupedWithMeteredMinimum.createdAt - creditAllocation = groupedWithMeteredMinimum.creditAllocation - currency = groupedWithMeteredMinimum.currency - discount = groupedWithMeteredMinimum.discount - externalPriceId = groupedWithMeteredMinimum.externalPriceId - fixedPriceQuantity = groupedWithMeteredMinimum.fixedPriceQuantity - groupedWithMeteredMinimumConfig = - groupedWithMeteredMinimum.groupedWithMeteredMinimumConfig - invoicingCycleConfiguration = groupedWithMeteredMinimum.invoicingCycleConfiguration - item = groupedWithMeteredMinimum.item - maximum = groupedWithMeteredMinimum.maximum - maximumAmount = groupedWithMeteredMinimum.maximumAmount - metadata = groupedWithMeteredMinimum.metadata - minimum = groupedWithMeteredMinimum.minimum - minimumAmount = groupedWithMeteredMinimum.minimumAmount - modelType = groupedWithMeteredMinimum.modelType - name = groupedWithMeteredMinimum.name - planPhaseOrder = groupedWithMeteredMinimum.planPhaseOrder - priceType = groupedWithMeteredMinimum.priceType - replacesPriceId = groupedWithMeteredMinimum.replacesPriceId - dimensionalPriceConfiguration = - groupedWithMeteredMinimum.dimensionalPriceConfiguration - additionalProperties = groupedWithMeteredMinimum.additionalProperties.toMutableMap() + internal fun from(groupedTieredPackage: GroupedTieredPackage) = apply { + id = groupedTieredPackage.id + billableMetric = groupedTieredPackage.billableMetric + billingCycleConfiguration = groupedTieredPackage.billingCycleConfiguration + cadence = groupedTieredPackage.cadence + compositePriceFilters = + groupedTieredPackage.compositePriceFilters.map { it.toMutableList() } + conversionRate = groupedTieredPackage.conversionRate + conversionRateConfig = groupedTieredPackage.conversionRateConfig + createdAt = groupedTieredPackage.createdAt + creditAllocation = groupedTieredPackage.creditAllocation + currency = groupedTieredPackage.currency + discount = groupedTieredPackage.discount + externalPriceId = groupedTieredPackage.externalPriceId + fixedPriceQuantity = groupedTieredPackage.fixedPriceQuantity + groupedTieredPackageConfig = groupedTieredPackage.groupedTieredPackageConfig + invoicingCycleConfiguration = groupedTieredPackage.invoicingCycleConfiguration + item = groupedTieredPackage.item + maximum = groupedTieredPackage.maximum + maximumAmount = groupedTieredPackage.maximumAmount + metadata = groupedTieredPackage.metadata + minimum = groupedTieredPackage.minimum + minimumAmount = groupedTieredPackage.minimumAmount + modelType = groupedTieredPackage.modelType + name = groupedTieredPackage.name + planPhaseOrder = groupedTieredPackage.planPhaseOrder + priceType = groupedTieredPackage.priceType + replacesPriceId = groupedTieredPackage.replacesPriceId + dimensionalPriceConfiguration = groupedTieredPackage.dimensionalPriceConfiguration + additionalProperties = groupedTieredPackage.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) @@ -38354,6 +39902,34 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + fun compositePriceFilters(compositePriceFilters: List?) = + compositePriceFilters(JsonField.ofNullable(compositePriceFilters)) + + /** + * Sets [Builder.compositePriceFilters] to an arbitrary JSON value. + * + * You should usually call [Builder.compositePriceFilters] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun compositePriceFilters( + compositePriceFilters: JsonField> + ) = apply { + this.compositePriceFilters = compositePriceFilters.map { it.toMutableList() } + } + + /** + * Adds a single [TransformPriceFilter] to [compositePriceFilters]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addCompositePriceFilter(compositePriceFilter: TransformPriceFilter) = apply { + compositePriceFilters = + (compositePriceFilters ?: JsonField.of(mutableListOf())).also { + checkKnown("compositePriceFilters", it).add(compositePriceFilter) + } + } + fun conversionRate(conversionRate: Double?) = conversionRate(JsonField.ofNullable(conversionRate)) @@ -38595,20 +40171,19 @@ private constructor( this.fixedPriceQuantity = fixedPriceQuantity } - fun groupedWithMeteredMinimumConfig( - groupedWithMeteredMinimumConfig: GroupedWithMeteredMinimumConfig - ) = groupedWithMeteredMinimumConfig(JsonField.of(groupedWithMeteredMinimumConfig)) + fun groupedTieredPackageConfig(groupedTieredPackageConfig: GroupedTieredPackageConfig) = + groupedTieredPackageConfig(JsonField.of(groupedTieredPackageConfig)) /** - * Sets [Builder.groupedWithMeteredMinimumConfig] to an arbitrary JSON value. + * Sets [Builder.groupedTieredPackageConfig] to an arbitrary JSON value. * - * You should usually call [Builder.groupedWithMeteredMinimumConfig] with a well-typed - * [GroupedWithMeteredMinimumConfig] value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. + * You should usually call [Builder.groupedTieredPackageConfig] with a well-typed + * [GroupedTieredPackageConfig] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. */ - fun groupedWithMeteredMinimumConfig( - groupedWithMeteredMinimumConfig: JsonField - ) = apply { this.groupedWithMeteredMinimumConfig = groupedWithMeteredMinimumConfig } + fun groupedTieredPackageConfig( + groupedTieredPackageConfig: JsonField + ) = apply { this.groupedTieredPackageConfig = groupedTieredPackageConfig } fun invoicingCycleConfiguration( invoicingCycleConfiguration: BillingCycleConfiguration? @@ -38716,7 +40291,7 @@ private constructor( * It is usually unnecessary to call this method because the field defaults to the * following: * ```kotlin - * JsonValue.from("grouped_with_metered_minimum") + * JsonValue.from("grouped_tiered_package") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -38820,7 +40395,7 @@ private constructor( } /** - * Returns an immutable instance of [GroupedWithMeteredMinimum]. + * Returns an immutable instance of [GroupedTieredPackage]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -38830,6 +40405,7 @@ private constructor( * .billableMetric() * .billingCycleConfiguration() * .cadence() + * .compositePriceFilters() * .conversionRate() * .conversionRateConfig() * .createdAt() @@ -38838,7 +40414,7 @@ private constructor( * .discount() * .externalPriceId() * .fixedPriceQuantity() - * .groupedWithMeteredMinimumConfig() + * .groupedTieredPackageConfig() * .invoicingCycleConfiguration() * .item() * .maximum() @@ -38854,12 +40430,15 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): GroupedWithMeteredMinimum = - GroupedWithMeteredMinimum( + fun build(): GroupedTieredPackage = + GroupedTieredPackage( checkRequired("id", id), checkRequired("billableMetric", billableMetric), checkRequired("billingCycleConfiguration", billingCycleConfiguration), checkRequired("cadence", cadence), + checkRequired("compositePriceFilters", compositePriceFilters).map { + it.toImmutable() + }, checkRequired("conversionRate", conversionRate), checkRequired("conversionRateConfig", conversionRateConfig), checkRequired("createdAt", createdAt), @@ -38868,10 +40447,7 @@ private constructor( checkRequired("discount", discount), checkRequired("externalPriceId", externalPriceId), checkRequired("fixedPriceQuantity", fixedPriceQuantity), - checkRequired( - "groupedWithMeteredMinimumConfig", - groupedWithMeteredMinimumConfig, - ), + checkRequired("groupedTieredPackageConfig", groupedTieredPackageConfig), checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), checkRequired("item", item), checkRequired("maximum", maximum), @@ -38891,7 +40467,7 @@ private constructor( private var validated: Boolean = false - fun validate(): GroupedWithMeteredMinimum = apply { + fun validate(): GroupedTieredPackage = apply { if (validated) { return@apply } @@ -38900,6 +40476,7 @@ private constructor( billableMetric()?.validate() billingCycleConfiguration().validate() cadence().validate() + compositePriceFilters()?.forEach { it.validate() } conversionRate() conversionRateConfig()?.validate() createdAt() @@ -38908,7 +40485,7 @@ private constructor( discount()?.validate() externalPriceId() fixedPriceQuantity() - groupedWithMeteredMinimumConfig().validate() + groupedTieredPackageConfig().validate() invoicingCycleConfiguration()?.validate() item().validate() maximum()?.validate() @@ -38917,7 +40494,7 @@ private constructor( minimum()?.validate() minimumAmount() _modelType().let { - if (it != JsonValue.from("grouped_with_metered_minimum")) { + if (it != JsonValue.from("grouped_tiered_package")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } @@ -38948,6 +40525,7 @@ private constructor( (billableMetric.asKnown()?.validity() ?: 0) + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + (cadence.asKnown()?.validity() ?: 0) + + (compositePriceFilters.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + (if (conversionRate.asKnown() == null) 0 else 1) + (conversionRateConfig.asKnown()?.validity() ?: 0) + (if (createdAt.asKnown() == null) 0 else 1) + @@ -38956,7 +40534,7 @@ private constructor( (discount.asKnown()?.validity() ?: 0) + (if (externalPriceId.asKnown() == null) 0 else 1) + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + - (groupedWithMeteredMinimumConfig.asKnown()?.validity() ?: 0) + + (groupedTieredPackageConfig.asKnown()?.validity() ?: 0) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + (item.asKnown()?.validity() ?: 0) + (maximum.asKnown()?.validity() ?: 0) + @@ -38964,9 +40542,7 @@ private constructor( (metadata.asKnown()?.validity() ?: 0) + (minimum.asKnown()?.validity() ?: 0) + (if (minimumAmount.asKnown() == null) 0 else 1) + - modelType.let { - if (it == JsonValue.from("grouped_with_metered_minimum")) 1 else 0 - } + + modelType.let { if (it == JsonValue.from("grouped_tiered_package")) 1 else 0 } + (if (name.asKnown() == null) 0 else 1) + (if (planPhaseOrder.asKnown() == null) 0 else 1) + (priceType.asKnown()?.validity() ?: 0) + @@ -39125,7 +40701,7 @@ private constructor( override fun toString() = value.toString() } - class GroupedWithMeteredMinimumConfig + class GroupedTieredPackageConfig @JsonCreator private constructor( @com.fasterxml.jackson.annotation.JsonValue @@ -39142,21 +40718,19 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [GroupedWithMeteredMinimumConfig]. + * [GroupedTieredPackageConfig]. */ fun builder() = Builder() } - /** A builder for [GroupedWithMeteredMinimumConfig]. */ + /** A builder for [GroupedTieredPackageConfig]. */ class Builder internal constructor() { private var additionalProperties: MutableMap = mutableMapOf() - internal fun from( - groupedWithMeteredMinimumConfig: GroupedWithMeteredMinimumConfig - ) = apply { + internal fun from(groupedTieredPackageConfig: GroupedTieredPackageConfig) = apply { additionalProperties = - groupedWithMeteredMinimumConfig.additionalProperties.toMutableMap() + groupedTieredPackageConfig.additionalProperties.toMutableMap() } fun additionalProperties(additionalProperties: Map) = apply { @@ -39182,17 +40756,17 @@ private constructor( } /** - * Returns an immutable instance of [GroupedWithMeteredMinimumConfig]. + * Returns an immutable instance of [GroupedTieredPackageConfig]. * * Further updates to this [Builder] will not mutate the returned instance. */ - fun build(): GroupedWithMeteredMinimumConfig = - GroupedWithMeteredMinimumConfig(additionalProperties.toImmutable()) + fun build(): GroupedTieredPackageConfig = + GroupedTieredPackageConfig(additionalProperties.toImmutable()) } private var validated: Boolean = false - fun validate(): GroupedWithMeteredMinimumConfig = apply { + fun validate(): GroupedTieredPackageConfig = apply { if (validated) { return@apply } @@ -39222,7 +40796,7 @@ private constructor( return true } - return other is GroupedWithMeteredMinimumConfig && + return other is GroupedTieredPackageConfig && additionalProperties == other.additionalProperties } @@ -39231,7 +40805,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "GroupedWithMeteredMinimumConfig{additionalProperties=$additionalProperties}" + "GroupedTieredPackageConfig{additionalProperties=$additionalProperties}" } /** @@ -39473,11 +41047,12 @@ private constructor( return true } - return other is GroupedWithMeteredMinimum && + return other is GroupedTieredPackage && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && + compositePriceFilters == other.compositePriceFilters && conversionRate == other.conversionRate && conversionRateConfig == other.conversionRateConfig && createdAt == other.createdAt && @@ -39486,7 +41061,7 @@ private constructor( discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && - groupedWithMeteredMinimumConfig == other.groupedWithMeteredMinimumConfig && + groupedTieredPackageConfig == other.groupedTieredPackageConfig && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maximum == other.maximum && @@ -39509,6 +41084,7 @@ private constructor( billableMetric, billingCycleConfiguration, cadence, + compositePriceFilters, conversionRate, conversionRateConfig, createdAt, @@ -39517,7 +41093,7 @@ private constructor( discount, externalPriceId, fixedPriceQuantity, - groupedWithMeteredMinimumConfig, + groupedTieredPackageConfig, invoicingCycleConfiguration, item, maximum, @@ -39538,15 +41114,16 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "GroupedWithMeteredMinimum{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, groupedWithMeteredMinimumConfig=$groupedWithMeteredMinimumConfig, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "GroupedTieredPackage{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, groupedTieredPackageConfig=$groupedTieredPackageConfig, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" } - class MatrixWithDisplayName + class MaxGroupTieredPackage private constructor( private val id: JsonField, private val billableMetric: JsonField, private val billingCycleConfiguration: JsonField, private val cadence: JsonField, + private val compositePriceFilters: JsonField>, private val conversionRate: JsonField, private val conversionRateConfig: JsonField, private val createdAt: JsonField, @@ -39557,7 +41134,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoicingCycleConfiguration: JsonField, private val item: JsonField, - private val matrixWithDisplayNameConfig: JsonField, + private val maxGroupTieredPackageConfig: JsonField, private val maximum: JsonField, private val maximumAmount: JsonField, private val metadata: JsonField, @@ -39582,6 +41159,9 @@ private constructor( @ExcludeMissing billingCycleConfiguration: JsonField = JsonMissing.of(), @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), + @JsonProperty("composite_price_filters") + @ExcludeMissing + compositePriceFilters: JsonField> = JsonMissing.of(), @JsonProperty("conversion_rate") @ExcludeMissing conversionRate: JsonField = JsonMissing.of(), @@ -39610,9 +41190,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), @JsonProperty("item") @ExcludeMissing item: JsonField = JsonMissing.of(), - @JsonProperty("matrix_with_display_name_config") + @JsonProperty("max_group_tiered_package_config") @ExcludeMissing - matrixWithDisplayNameConfig: JsonField = JsonMissing.of(), + maxGroupTieredPackageConfig: JsonField = JsonMissing.of(), @JsonProperty("maximum") @ExcludeMissing maximum: JsonField = JsonMissing.of(), @JsonProperty("maximum_amount") @ExcludeMissing @@ -39644,6 +41224,7 @@ private constructor( billableMetric, billingCycleConfiguration, cadence, + compositePriceFilters, conversionRate, conversionRateConfig, createdAt, @@ -39654,7 +41235,7 @@ private constructor( fixedPriceQuantity, invoicingCycleConfiguration, item, - matrixWithDisplayNameConfig, + maxGroupTieredPackageConfig, maximum, maximumAmount, metadata, @@ -39694,6 +41275,13 @@ private constructor( */ fun cadence(): Cadence = cadence.getRequired("cadence") + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun compositePriceFilters(): List? = + compositePriceFilters.getNullable("composite_price_filters") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -39760,8 +41348,8 @@ private constructor( * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ - fun matrixWithDisplayNameConfig(): MatrixWithDisplayNameConfig = - matrixWithDisplayNameConfig.getRequired("matrix_with_display_name_config") + fun maxGroupTieredPackageConfig(): MaxGroupTieredPackageConfig = + maxGroupTieredPackageConfig.getRequired("max_group_tiered_package_config") /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the @@ -39802,7 +41390,7 @@ private constructor( /** * Expected to always return the following: * ```kotlin - * JsonValue.from("matrix_with_display_name") + * JsonValue.from("max_group_tiered_package") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -39879,6 +41467,16 @@ private constructor( */ @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence + /** + * Returns the raw JSON value of [compositePriceFilters]. + * + * Unlike [compositePriceFilters], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("composite_price_filters") + @ExcludeMissing + fun _compositePriceFilters(): JsonField> = compositePriceFilters + /** * Returns the raw JSON value of [conversionRate]. * @@ -39974,15 +41572,15 @@ private constructor( @JsonProperty("item") @ExcludeMissing fun _item(): JsonField = item /** - * Returns the raw JSON value of [matrixWithDisplayNameConfig]. + * Returns the raw JSON value of [maxGroupTieredPackageConfig]. * - * Unlike [matrixWithDisplayNameConfig], this method doesn't throw if the JSON field has an + * Unlike [maxGroupTieredPackageConfig], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("matrix_with_display_name_config") + @JsonProperty("max_group_tiered_package_config") @ExcludeMissing - fun _matrixWithDisplayNameConfig(): JsonField = - matrixWithDisplayNameConfig + fun _maxGroupTieredPackageConfig(): JsonField = + maxGroupTieredPackageConfig /** * Returns the raw JSON value of [maximum]. @@ -40095,7 +41693,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [MatrixWithDisplayName]. + * Returns a mutable builder for constructing an instance of [MaxGroupTieredPackage]. * * The following fields are required: * ```kotlin @@ -40103,6 +41701,7 @@ private constructor( * .billableMetric() * .billingCycleConfiguration() * .cadence() + * .compositePriceFilters() * .conversionRate() * .conversionRateConfig() * .createdAt() @@ -40113,7 +41712,7 @@ private constructor( * .fixedPriceQuantity() * .invoicingCycleConfiguration() * .item() - * .matrixWithDisplayNameConfig() + * .maxGroupTieredPackageConfig() * .maximum() * .maximumAmount() * .metadata() @@ -40128,13 +41727,14 @@ private constructor( fun builder() = Builder() } - /** A builder for [MatrixWithDisplayName]. */ + /** A builder for [MaxGroupTieredPackage]. */ class Builder internal constructor() { private var id: JsonField? = null private var billableMetric: JsonField? = null private var billingCycleConfiguration: JsonField? = null private var cadence: JsonField? = null + private var compositePriceFilters: JsonField>? = null private var conversionRate: JsonField? = null private var conversionRateConfig: JsonField? = null private var createdAt: JsonField? = null @@ -40145,13 +41745,13 @@ private constructor( private var fixedPriceQuantity: JsonField? = null private var invoicingCycleConfiguration: JsonField? = null private var item: JsonField? = null - private var matrixWithDisplayNameConfig: JsonField? = null + private var maxGroupTieredPackageConfig: JsonField? = null private var maximum: JsonField? = null private var maximumAmount: JsonField? = null private var metadata: JsonField? = null private var minimum: JsonField? = null private var minimumAmount: JsonField? = null - private var modelType: JsonValue = JsonValue.from("matrix_with_display_name") + private var modelType: JsonValue = JsonValue.from("max_group_tiered_package") private var name: JsonField? = null private var planPhaseOrder: JsonField? = null private var priceType: JsonField? = null @@ -40160,34 +41760,36 @@ private constructor( JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(matrixWithDisplayName: MatrixWithDisplayName) = apply { - id = matrixWithDisplayName.id - billableMetric = matrixWithDisplayName.billableMetric - billingCycleConfiguration = matrixWithDisplayName.billingCycleConfiguration - cadence = matrixWithDisplayName.cadence - conversionRate = matrixWithDisplayName.conversionRate - conversionRateConfig = matrixWithDisplayName.conversionRateConfig - createdAt = matrixWithDisplayName.createdAt - creditAllocation = matrixWithDisplayName.creditAllocation - currency = matrixWithDisplayName.currency - discount = matrixWithDisplayName.discount - externalPriceId = matrixWithDisplayName.externalPriceId - fixedPriceQuantity = matrixWithDisplayName.fixedPriceQuantity - invoicingCycleConfiguration = matrixWithDisplayName.invoicingCycleConfiguration - item = matrixWithDisplayName.item - matrixWithDisplayNameConfig = matrixWithDisplayName.matrixWithDisplayNameConfig - maximum = matrixWithDisplayName.maximum - maximumAmount = matrixWithDisplayName.maximumAmount - metadata = matrixWithDisplayName.metadata - minimum = matrixWithDisplayName.minimum - minimumAmount = matrixWithDisplayName.minimumAmount - modelType = matrixWithDisplayName.modelType - name = matrixWithDisplayName.name - planPhaseOrder = matrixWithDisplayName.planPhaseOrder - priceType = matrixWithDisplayName.priceType - replacesPriceId = matrixWithDisplayName.replacesPriceId - dimensionalPriceConfiguration = matrixWithDisplayName.dimensionalPriceConfiguration - additionalProperties = matrixWithDisplayName.additionalProperties.toMutableMap() + internal fun from(maxGroupTieredPackage: MaxGroupTieredPackage) = apply { + id = maxGroupTieredPackage.id + billableMetric = maxGroupTieredPackage.billableMetric + billingCycleConfiguration = maxGroupTieredPackage.billingCycleConfiguration + cadence = maxGroupTieredPackage.cadence + compositePriceFilters = + maxGroupTieredPackage.compositePriceFilters.map { it.toMutableList() } + conversionRate = maxGroupTieredPackage.conversionRate + conversionRateConfig = maxGroupTieredPackage.conversionRateConfig + createdAt = maxGroupTieredPackage.createdAt + creditAllocation = maxGroupTieredPackage.creditAllocation + currency = maxGroupTieredPackage.currency + discount = maxGroupTieredPackage.discount + externalPriceId = maxGroupTieredPackage.externalPriceId + fixedPriceQuantity = maxGroupTieredPackage.fixedPriceQuantity + invoicingCycleConfiguration = maxGroupTieredPackage.invoicingCycleConfiguration + item = maxGroupTieredPackage.item + maxGroupTieredPackageConfig = maxGroupTieredPackage.maxGroupTieredPackageConfig + maximum = maxGroupTieredPackage.maximum + maximumAmount = maxGroupTieredPackage.maximumAmount + metadata = maxGroupTieredPackage.metadata + minimum = maxGroupTieredPackage.minimum + minimumAmount = maxGroupTieredPackage.minimumAmount + modelType = maxGroupTieredPackage.modelType + name = maxGroupTieredPackage.name + planPhaseOrder = maxGroupTieredPackage.planPhaseOrder + priceType = maxGroupTieredPackage.priceType + replacesPriceId = maxGroupTieredPackage.replacesPriceId + dimensionalPriceConfiguration = maxGroupTieredPackage.dimensionalPriceConfiguration + additionalProperties = maxGroupTieredPackage.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) @@ -40240,6 +41842,34 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + fun compositePriceFilters(compositePriceFilters: List?) = + compositePriceFilters(JsonField.ofNullable(compositePriceFilters)) + + /** + * Sets [Builder.compositePriceFilters] to an arbitrary JSON value. + * + * You should usually call [Builder.compositePriceFilters] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun compositePriceFilters( + compositePriceFilters: JsonField> + ) = apply { + this.compositePriceFilters = compositePriceFilters.map { it.toMutableList() } + } + + /** + * Adds a single [TransformPriceFilter] to [compositePriceFilters]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addCompositePriceFilter(compositePriceFilter: TransformPriceFilter) = apply { + compositePriceFilters = + (compositePriceFilters ?: JsonField.of(mutableListOf())).also { + checkKnown("compositePriceFilters", it).add(compositePriceFilter) + } + } + fun conversionRate(conversionRate: Double?) = conversionRate(JsonField.ofNullable(conversionRate)) @@ -40507,20 +42137,20 @@ private constructor( */ fun item(item: JsonField) = apply { this.item = item } - fun matrixWithDisplayNameConfig( - matrixWithDisplayNameConfig: MatrixWithDisplayNameConfig - ) = matrixWithDisplayNameConfig(JsonField.of(matrixWithDisplayNameConfig)) + fun maxGroupTieredPackageConfig( + maxGroupTieredPackageConfig: MaxGroupTieredPackageConfig + ) = maxGroupTieredPackageConfig(JsonField.of(maxGroupTieredPackageConfig)) /** - * Sets [Builder.matrixWithDisplayNameConfig] to an arbitrary JSON value. + * Sets [Builder.maxGroupTieredPackageConfig] to an arbitrary JSON value. * - * You should usually call [Builder.matrixWithDisplayNameConfig] with a well-typed - * [MatrixWithDisplayNameConfig] value instead. This method is primarily for setting the + * You should usually call [Builder.maxGroupTieredPackageConfig] with a well-typed + * [MaxGroupTieredPackageConfig] value instead. This method is primarily for setting the * field to an undocumented or not yet supported value. */ - fun matrixWithDisplayNameConfig( - matrixWithDisplayNameConfig: JsonField - ) = apply { this.matrixWithDisplayNameConfig = matrixWithDisplayNameConfig } + fun maxGroupTieredPackageConfig( + maxGroupTieredPackageConfig: JsonField + ) = apply { this.maxGroupTieredPackageConfig = maxGroupTieredPackageConfig } @Deprecated("deprecated") fun maximum(maximum: Maximum?) = maximum(JsonField.ofNullable(maximum)) @@ -40602,7 +42232,7 @@ private constructor( * It is usually unnecessary to call this method because the field defaults to the * following: * ```kotlin - * JsonValue.from("matrix_with_display_name") + * JsonValue.from("max_group_tiered_package") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -40706,7 +42336,7 @@ private constructor( } /** - * Returns an immutable instance of [MatrixWithDisplayName]. + * Returns an immutable instance of [MaxGroupTieredPackage]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -40716,6 +42346,7 @@ private constructor( * .billableMetric() * .billingCycleConfiguration() * .cadence() + * .compositePriceFilters() * .conversionRate() * .conversionRateConfig() * .createdAt() @@ -40726,7 +42357,7 @@ private constructor( * .fixedPriceQuantity() * .invoicingCycleConfiguration() * .item() - * .matrixWithDisplayNameConfig() + * .maxGroupTieredPackageConfig() * .maximum() * .maximumAmount() * .metadata() @@ -40740,12 +42371,15 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): MatrixWithDisplayName = - MatrixWithDisplayName( + fun build(): MaxGroupTieredPackage = + MaxGroupTieredPackage( checkRequired("id", id), checkRequired("billableMetric", billableMetric), checkRequired("billingCycleConfiguration", billingCycleConfiguration), checkRequired("cadence", cadence), + checkRequired("compositePriceFilters", compositePriceFilters).map { + it.toImmutable() + }, checkRequired("conversionRate", conversionRate), checkRequired("conversionRateConfig", conversionRateConfig), checkRequired("createdAt", createdAt), @@ -40756,7 +42390,7 @@ private constructor( checkRequired("fixedPriceQuantity", fixedPriceQuantity), checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), checkRequired("item", item), - checkRequired("matrixWithDisplayNameConfig", matrixWithDisplayNameConfig), + checkRequired("maxGroupTieredPackageConfig", maxGroupTieredPackageConfig), checkRequired("maximum", maximum), checkRequired("maximumAmount", maximumAmount), checkRequired("metadata", metadata), @@ -40774,7 +42408,7 @@ private constructor( private var validated: Boolean = false - fun validate(): MatrixWithDisplayName = apply { + fun validate(): MaxGroupTieredPackage = apply { if (validated) { return@apply } @@ -40783,6 +42417,7 @@ private constructor( billableMetric()?.validate() billingCycleConfiguration().validate() cadence().validate() + compositePriceFilters()?.forEach { it.validate() } conversionRate() conversionRateConfig()?.validate() createdAt() @@ -40793,14 +42428,14 @@ private constructor( fixedPriceQuantity() invoicingCycleConfiguration()?.validate() item().validate() - matrixWithDisplayNameConfig().validate() + maxGroupTieredPackageConfig().validate() maximum()?.validate() maximumAmount() metadata().validate() minimum()?.validate() minimumAmount() _modelType().let { - if (it != JsonValue.from("matrix_with_display_name")) { + if (it != JsonValue.from("max_group_tiered_package")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } @@ -40831,6 +42466,7 @@ private constructor( (billableMetric.asKnown()?.validity() ?: 0) + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + (cadence.asKnown()?.validity() ?: 0) + + (compositePriceFilters.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + (if (conversionRate.asKnown() == null) 0 else 1) + (conversionRateConfig.asKnown()?.validity() ?: 0) + (if (createdAt.asKnown() == null) 0 else 1) + @@ -40841,13 +42477,13 @@ private constructor( (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + (item.asKnown()?.validity() ?: 0) + - (matrixWithDisplayNameConfig.asKnown()?.validity() ?: 0) + + (maxGroupTieredPackageConfig.asKnown()?.validity() ?: 0) + (maximum.asKnown()?.validity() ?: 0) + (if (maximumAmount.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) + (minimum.asKnown()?.validity() ?: 0) + (if (minimumAmount.asKnown() == null) 0 else 1) + - modelType.let { if (it == JsonValue.from("matrix_with_display_name")) 1 else 0 } + + modelType.let { if (it == JsonValue.from("max_group_tiered_package")) 1 else 0 } + (if (name.asKnown() == null) 0 else 1) + (if (planPhaseOrder.asKnown() == null) 0 else 1) + (priceType.asKnown()?.validity() ?: 0) + @@ -41006,7 +42642,7 @@ private constructor( override fun toString() = value.toString() } - class MatrixWithDisplayNameConfig + class MaxGroupTieredPackageConfig @JsonCreator private constructor( @com.fasterxml.jackson.annotation.JsonValue @@ -41023,20 +42659,20 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [MatrixWithDisplayNameConfig]. + * [MaxGroupTieredPackageConfig]. */ fun builder() = Builder() } - /** A builder for [MatrixWithDisplayNameConfig]. */ + /** A builder for [MaxGroupTieredPackageConfig]. */ class Builder internal constructor() { private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(matrixWithDisplayNameConfig: MatrixWithDisplayNameConfig) = + internal fun from(maxGroupTieredPackageConfig: MaxGroupTieredPackageConfig) = apply { additionalProperties = - matrixWithDisplayNameConfig.additionalProperties.toMutableMap() + maxGroupTieredPackageConfig.additionalProperties.toMutableMap() } fun additionalProperties(additionalProperties: Map) = apply { @@ -41062,17 +42698,17 @@ private constructor( } /** - * Returns an immutable instance of [MatrixWithDisplayNameConfig]. + * Returns an immutable instance of [MaxGroupTieredPackageConfig]. * * Further updates to this [Builder] will not mutate the returned instance. */ - fun build(): MatrixWithDisplayNameConfig = - MatrixWithDisplayNameConfig(additionalProperties.toImmutable()) + fun build(): MaxGroupTieredPackageConfig = + MaxGroupTieredPackageConfig(additionalProperties.toImmutable()) } private var validated: Boolean = false - fun validate(): MatrixWithDisplayNameConfig = apply { + fun validate(): MaxGroupTieredPackageConfig = apply { if (validated) { return@apply } @@ -41102,7 +42738,7 @@ private constructor( return true } - return other is MatrixWithDisplayNameConfig && + return other is MaxGroupTieredPackageConfig && additionalProperties == other.additionalProperties } @@ -41111,7 +42747,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "MatrixWithDisplayNameConfig{additionalProperties=$additionalProperties}" + "MaxGroupTieredPackageConfig{additionalProperties=$additionalProperties}" } /** @@ -41353,11 +42989,12 @@ private constructor( return true } - return other is MatrixWithDisplayName && + return other is MaxGroupTieredPackage && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && + compositePriceFilters == other.compositePriceFilters && conversionRate == other.conversionRate && conversionRateConfig == other.conversionRateConfig && createdAt == other.createdAt && @@ -41368,7 +43005,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && - matrixWithDisplayNameConfig == other.matrixWithDisplayNameConfig && + maxGroupTieredPackageConfig == other.maxGroupTieredPackageConfig && maximum == other.maximum && maximumAmount == other.maximumAmount && metadata == other.metadata && @@ -41389,6 +43026,7 @@ private constructor( billableMetric, billingCycleConfiguration, cadence, + compositePriceFilters, conversionRate, conversionRateConfig, createdAt, @@ -41399,7 +43037,7 @@ private constructor( fixedPriceQuantity, invoicingCycleConfiguration, item, - matrixWithDisplayNameConfig, + maxGroupTieredPackageConfig, maximum, maximumAmount, metadata, @@ -41418,16 +43056,16 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "MatrixWithDisplayName{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, matrixWithDisplayNameConfig=$matrixWithDisplayNameConfig, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "MaxGroupTieredPackage{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maxGroupTieredPackageConfig=$maxGroupTieredPackageConfig, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" } - class BulkWithProration + class ScalableMatrixWithUnitPricing private constructor( private val id: JsonField, private val billableMetric: JsonField, private val billingCycleConfiguration: JsonField, - private val bulkWithProrationConfig: JsonField, private val cadence: JsonField, + private val compositePriceFilters: JsonField>, private val conversionRate: JsonField, private val conversionRateConfig: JsonField, private val createdAt: JsonField, @@ -41448,6 +43086,8 @@ private constructor( private val planPhaseOrder: JsonField, private val priceType: JsonField, private val replacesPriceId: JsonField, + private val scalableMatrixWithUnitPricingConfig: + JsonField, private val dimensionalPriceConfiguration: JsonField, private val additionalProperties: MutableMap, ) { @@ -41461,10 +43101,10 @@ private constructor( @JsonProperty("billing_cycle_configuration") @ExcludeMissing billingCycleConfiguration: JsonField = JsonMissing.of(), - @JsonProperty("bulk_with_proration_config") - @ExcludeMissing - bulkWithProrationConfig: JsonField = JsonMissing.of(), @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), + @JsonProperty("composite_price_filters") + @ExcludeMissing + compositePriceFilters: JsonField> = JsonMissing.of(), @JsonProperty("conversion_rate") @ExcludeMissing conversionRate: JsonField = JsonMissing.of(), @@ -41515,6 +43155,10 @@ private constructor( @JsonProperty("replaces_price_id") @ExcludeMissing replacesPriceId: JsonField = JsonMissing.of(), + @JsonProperty("scalable_matrix_with_unit_pricing_config") + @ExcludeMissing + scalableMatrixWithUnitPricingConfig: JsonField = + JsonMissing.of(), @JsonProperty("dimensional_price_configuration") @ExcludeMissing dimensionalPriceConfiguration: JsonField = @@ -41523,8 +43167,8 @@ private constructor( id, billableMetric, billingCycleConfiguration, - bulkWithProrationConfig, cadence, + compositePriceFilters, conversionRate, conversionRateConfig, createdAt, @@ -41545,6 +43189,7 @@ private constructor( planPhaseOrder, priceType, replacesPriceId, + scalableMatrixWithUnitPricingConfig, dimensionalPriceConfiguration, mutableMapOf(), ) @@ -41572,14 +43217,14 @@ private constructor( * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ - fun bulkWithProrationConfig(): BulkWithProrationConfig = - bulkWithProrationConfig.getRequired("bulk_with_proration_config") + fun cadence(): Cadence = cadence.getRequired("cadence") /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ - fun cadence(): Cadence = cadence.getRequired("cadence") + fun compositePriceFilters(): List? = + compositePriceFilters.getNullable("composite_price_filters") /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the @@ -41682,7 +43327,7 @@ private constructor( /** * Expected to always return the following: * ```kotlin - * JsonValue.from("bulk_with_proration") + * JsonValue.from("scalable_matrix_with_unit_pricing") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -41717,6 +43362,15 @@ private constructor( */ fun replacesPriceId(): String? = replacesPriceId.getNullable("replaces_price_id") + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun scalableMatrixWithUnitPricingConfig(): ScalableMatrixWithUnitPricingConfig = + scalableMatrixWithUnitPricingConfig.getRequired( + "scalable_matrix_with_unit_pricing_config" + ) + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -41753,21 +43407,21 @@ private constructor( billingCycleConfiguration /** - * Returns the raw JSON value of [bulkWithProrationConfig]. + * Returns the raw JSON value of [cadence]. * - * Unlike [bulkWithProrationConfig], this method doesn't throw if the JSON field has an - * unexpected type. + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("bulk_with_proration_config") - @ExcludeMissing - fun _bulkWithProrationConfig(): JsonField = bulkWithProrationConfig + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence /** - * Returns the raw JSON value of [cadence]. + * Returns the raw JSON value of [compositePriceFilters]. * - * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [compositePriceFilters], this method doesn't throw if the JSON field has an + * unexpected type. */ - @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence + @JsonProperty("composite_price_filters") + @ExcludeMissing + fun _compositePriceFilters(): JsonField> = compositePriceFilters /** * Returns the raw JSON value of [conversionRate]. @@ -41948,6 +43602,17 @@ private constructor( @ExcludeMissing fun _replacesPriceId(): JsonField = replacesPriceId + /** + * Returns the raw JSON value of [scalableMatrixWithUnitPricingConfig]. + * + * Unlike [scalableMatrixWithUnitPricingConfig], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("scalable_matrix_with_unit_pricing_config") + @ExcludeMissing + fun _scalableMatrixWithUnitPricingConfig(): JsonField = + scalableMatrixWithUnitPricingConfig + /** * Returns the raw JSON value of [dimensionalPriceConfiguration]. * @@ -41974,15 +43639,16 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [BulkWithProration]. + * Returns a mutable builder for constructing an instance of + * [ScalableMatrixWithUnitPricing]. * * The following fields are required: * ```kotlin * .id() * .billableMetric() * .billingCycleConfiguration() - * .bulkWithProrationConfig() * .cadence() + * .compositePriceFilters() * .conversionRate() * .conversionRateConfig() * .createdAt() @@ -42002,19 +43668,20 @@ private constructor( * .planPhaseOrder() * .priceType() * .replacesPriceId() + * .scalableMatrixWithUnitPricingConfig() * ``` */ fun builder() = Builder() } - /** A builder for [BulkWithProration]. */ + /** A builder for [ScalableMatrixWithUnitPricing]. */ class Builder internal constructor() { private var id: JsonField? = null private var billableMetric: JsonField? = null private var billingCycleConfiguration: JsonField? = null - private var bulkWithProrationConfig: JsonField? = null private var cadence: JsonField? = null + private var compositePriceFilters: JsonField>? = null private var conversionRate: JsonField? = null private var conversionRateConfig: JsonField? = null private var createdAt: JsonField? = null @@ -42030,44 +43697,57 @@ private constructor( private var metadata: JsonField? = null private var minimum: JsonField? = null private var minimumAmount: JsonField? = null - private var modelType: JsonValue = JsonValue.from("bulk_with_proration") + private var modelType: JsonValue = JsonValue.from("scalable_matrix_with_unit_pricing") private var name: JsonField? = null private var planPhaseOrder: JsonField? = null private var priceType: JsonField? = null private var replacesPriceId: JsonField? = null + private var scalableMatrixWithUnitPricingConfig: + JsonField? = + null private var dimensionalPriceConfiguration: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(bulkWithProration: BulkWithProration) = apply { - id = bulkWithProration.id - billableMetric = bulkWithProration.billableMetric - billingCycleConfiguration = bulkWithProration.billingCycleConfiguration - bulkWithProrationConfig = bulkWithProration.bulkWithProrationConfig - cadence = bulkWithProration.cadence - conversionRate = bulkWithProration.conversionRate - conversionRateConfig = bulkWithProration.conversionRateConfig - createdAt = bulkWithProration.createdAt - creditAllocation = bulkWithProration.creditAllocation - currency = bulkWithProration.currency - discount = bulkWithProration.discount - externalPriceId = bulkWithProration.externalPriceId - fixedPriceQuantity = bulkWithProration.fixedPriceQuantity - invoicingCycleConfiguration = bulkWithProration.invoicingCycleConfiguration - item = bulkWithProration.item - maximum = bulkWithProration.maximum - maximumAmount = bulkWithProration.maximumAmount - metadata = bulkWithProration.metadata - minimum = bulkWithProration.minimum - minimumAmount = bulkWithProration.minimumAmount - modelType = bulkWithProration.modelType - name = bulkWithProration.name - planPhaseOrder = bulkWithProration.planPhaseOrder - priceType = bulkWithProration.priceType - replacesPriceId = bulkWithProration.replacesPriceId - dimensionalPriceConfiguration = bulkWithProration.dimensionalPriceConfiguration - additionalProperties = bulkWithProration.additionalProperties.toMutableMap() - } + internal fun from(scalableMatrixWithUnitPricing: ScalableMatrixWithUnitPricing) = + apply { + id = scalableMatrixWithUnitPricing.id + billableMetric = scalableMatrixWithUnitPricing.billableMetric + billingCycleConfiguration = + scalableMatrixWithUnitPricing.billingCycleConfiguration + cadence = scalableMatrixWithUnitPricing.cadence + compositePriceFilters = + scalableMatrixWithUnitPricing.compositePriceFilters.map { + it.toMutableList() + } + conversionRate = scalableMatrixWithUnitPricing.conversionRate + conversionRateConfig = scalableMatrixWithUnitPricing.conversionRateConfig + createdAt = scalableMatrixWithUnitPricing.createdAt + creditAllocation = scalableMatrixWithUnitPricing.creditAllocation + currency = scalableMatrixWithUnitPricing.currency + discount = scalableMatrixWithUnitPricing.discount + externalPriceId = scalableMatrixWithUnitPricing.externalPriceId + fixedPriceQuantity = scalableMatrixWithUnitPricing.fixedPriceQuantity + invoicingCycleConfiguration = + scalableMatrixWithUnitPricing.invoicingCycleConfiguration + item = scalableMatrixWithUnitPricing.item + maximum = scalableMatrixWithUnitPricing.maximum + maximumAmount = scalableMatrixWithUnitPricing.maximumAmount + metadata = scalableMatrixWithUnitPricing.metadata + minimum = scalableMatrixWithUnitPricing.minimum + minimumAmount = scalableMatrixWithUnitPricing.minimumAmount + modelType = scalableMatrixWithUnitPricing.modelType + name = scalableMatrixWithUnitPricing.name + planPhaseOrder = scalableMatrixWithUnitPricing.planPhaseOrder + priceType = scalableMatrixWithUnitPricing.priceType + replacesPriceId = scalableMatrixWithUnitPricing.replacesPriceId + scalableMatrixWithUnitPricingConfig = + scalableMatrixWithUnitPricing.scalableMatrixWithUnitPricingConfig + dimensionalPriceConfiguration = + scalableMatrixWithUnitPricing.dimensionalPriceConfiguration + additionalProperties = + scalableMatrixWithUnitPricing.additionalProperties.toMutableMap() + } fun id(id: String) = id(JsonField.of(id)) @@ -42108,20 +43788,6 @@ private constructor( billingCycleConfiguration: JsonField ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } - fun bulkWithProrationConfig(bulkWithProrationConfig: BulkWithProrationConfig) = - bulkWithProrationConfig(JsonField.of(bulkWithProrationConfig)) - - /** - * Sets [Builder.bulkWithProrationConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.bulkWithProrationConfig] with a well-typed - * [BulkWithProrationConfig] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun bulkWithProrationConfig( - bulkWithProrationConfig: JsonField - ) = apply { this.bulkWithProrationConfig = bulkWithProrationConfig } - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) /** @@ -42133,6 +43799,34 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + fun compositePriceFilters(compositePriceFilters: List?) = + compositePriceFilters(JsonField.ofNullable(compositePriceFilters)) + + /** + * Sets [Builder.compositePriceFilters] to an arbitrary JSON value. + * + * You should usually call [Builder.compositePriceFilters] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun compositePriceFilters( + compositePriceFilters: JsonField> + ) = apply { + this.compositePriceFilters = compositePriceFilters.map { it.toMutableList() } + } + + /** + * Adds a single [TransformPriceFilter] to [compositePriceFilters]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addCompositePriceFilter(compositePriceFilter: TransformPriceFilter) = apply { + compositePriceFilters = + (compositePriceFilters ?: JsonField.of(mutableListOf())).also { + checkKnown("compositePriceFilters", it).add(compositePriceFilter) + } + } + fun conversionRate(conversionRate: Double?) = conversionRate(JsonField.ofNullable(conversionRate)) @@ -42480,7 +44174,7 @@ private constructor( * It is usually unnecessary to call this method because the field defaults to the * following: * ```kotlin - * JsonValue.from("bulk_with_proration") + * JsonValue.from("scalable_matrix_with_unit_pricing") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -42549,6 +44243,26 @@ private constructor( this.replacesPriceId = replacesPriceId } + fun scalableMatrixWithUnitPricingConfig( + scalableMatrixWithUnitPricingConfig: ScalableMatrixWithUnitPricingConfig + ) = + scalableMatrixWithUnitPricingConfig( + JsonField.of(scalableMatrixWithUnitPricingConfig) + ) + + /** + * Sets [Builder.scalableMatrixWithUnitPricingConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.scalableMatrixWithUnitPricingConfig] with a + * well-typed [ScalableMatrixWithUnitPricingConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported value. + */ + fun scalableMatrixWithUnitPricingConfig( + scalableMatrixWithUnitPricingConfig: JsonField + ) = apply { + this.scalableMatrixWithUnitPricingConfig = scalableMatrixWithUnitPricingConfig + } + fun dimensionalPriceConfiguration( dimensionalPriceConfiguration: DimensionalPriceConfiguration? ) = dimensionalPriceConfiguration(JsonField.ofNullable(dimensionalPriceConfiguration)) @@ -42584,7 +44298,7 @@ private constructor( } /** - * Returns an immutable instance of [BulkWithProration]. + * Returns an immutable instance of [ScalableMatrixWithUnitPricing]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -42593,8 +44307,8 @@ private constructor( * .id() * .billableMetric() * .billingCycleConfiguration() - * .bulkWithProrationConfig() * .cadence() + * .compositePriceFilters() * .conversionRate() * .conversionRateConfig() * .createdAt() @@ -42614,17 +44328,20 @@ private constructor( * .planPhaseOrder() * .priceType() * .replacesPriceId() + * .scalableMatrixWithUnitPricingConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): BulkWithProration = - BulkWithProration( + fun build(): ScalableMatrixWithUnitPricing = + ScalableMatrixWithUnitPricing( checkRequired("id", id), checkRequired("billableMetric", billableMetric), checkRequired("billingCycleConfiguration", billingCycleConfiguration), - checkRequired("bulkWithProrationConfig", bulkWithProrationConfig), checkRequired("cadence", cadence), + checkRequired("compositePriceFilters", compositePriceFilters).map { + it.toImmutable() + }, checkRequired("conversionRate", conversionRate), checkRequired("conversionRateConfig", conversionRateConfig), checkRequired("createdAt", createdAt), @@ -42645,6 +44362,10 @@ private constructor( checkRequired("planPhaseOrder", planPhaseOrder), checkRequired("priceType", priceType), checkRequired("replacesPriceId", replacesPriceId), + checkRequired( + "scalableMatrixWithUnitPricingConfig", + scalableMatrixWithUnitPricingConfig, + ), dimensionalPriceConfiguration, additionalProperties.toMutableMap(), ) @@ -42652,7 +44373,7 @@ private constructor( private var validated: Boolean = false - fun validate(): BulkWithProration = apply { + fun validate(): ScalableMatrixWithUnitPricing = apply { if (validated) { return@apply } @@ -42660,8 +44381,8 @@ private constructor( id() billableMetric()?.validate() billingCycleConfiguration().validate() - bulkWithProrationConfig().validate() cadence().validate() + compositePriceFilters()?.forEach { it.validate() } conversionRate() conversionRateConfig()?.validate() createdAt() @@ -42678,7 +44399,7 @@ private constructor( minimum()?.validate() minimumAmount() _modelType().let { - if (it != JsonValue.from("bulk_with_proration")) { + if (it != JsonValue.from("scalable_matrix_with_unit_pricing")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } @@ -42686,6 +44407,7 @@ private constructor( planPhaseOrder() priceType().validate() replacesPriceId() + scalableMatrixWithUnitPricingConfig().validate() dimensionalPriceConfiguration()?.validate() validated = true } @@ -42708,8 +44430,8 @@ private constructor( (if (id.asKnown() == null) 0 else 1) + (billableMetric.asKnown()?.validity() ?: 0) + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + - (bulkWithProrationConfig.asKnown()?.validity() ?: 0) + (cadence.asKnown()?.validity() ?: 0) + + (compositePriceFilters.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + (if (conversionRate.asKnown() == null) 0 else 1) + (conversionRateConfig.asKnown()?.validity() ?: 0) + (if (createdAt.asKnown() == null) 0 else 1) + @@ -42725,120 +44447,16 @@ private constructor( (metadata.asKnown()?.validity() ?: 0) + (minimum.asKnown()?.validity() ?: 0) + (if (minimumAmount.asKnown() == null) 0 else 1) + - modelType.let { if (it == JsonValue.from("bulk_with_proration")) 1 else 0 } + + modelType.let { + if (it == JsonValue.from("scalable_matrix_with_unit_pricing")) 1 else 0 + } + (if (name.asKnown() == null) 0 else 1) + (if (planPhaseOrder.asKnown() == null) 0 else 1) + (priceType.asKnown()?.validity() ?: 0) + (if (replacesPriceId.asKnown() == null) 0 else 1) + + (scalableMatrixWithUnitPricingConfig.asKnown()?.validity() ?: 0) + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) - class BulkWithProrationConfig - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [BulkWithProrationConfig]. - */ - fun builder() = Builder() - } - - /** A builder for [BulkWithProrationConfig]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(bulkWithProrationConfig: BulkWithProrationConfig) = apply { - additionalProperties = - bulkWithProrationConfig.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [BulkWithProrationConfig]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): BulkWithProrationConfig = - BulkWithProrationConfig(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): BulkWithProrationConfig = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is BulkWithProrationConfig && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BulkWithProrationConfig{additionalProperties=$additionalProperties}" - } - class Cadence @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -43225,17 +44843,126 @@ private constructor( override fun toString() = value.toString() } + class ScalableMatrixWithUnitPricingConfig + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [ScalableMatrixWithUnitPricingConfig]. + */ + fun builder() = Builder() + } + + /** A builder for [ScalableMatrixWithUnitPricingConfig]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from( + scalableMatrixWithUnitPricingConfig: ScalableMatrixWithUnitPricingConfig + ) = apply { + additionalProperties = + scalableMatrixWithUnitPricingConfig.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ScalableMatrixWithUnitPricingConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ScalableMatrixWithUnitPricingConfig = + ScalableMatrixWithUnitPricingConfig(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): ScalableMatrixWithUnitPricingConfig = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ScalableMatrixWithUnitPricingConfig && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ScalableMatrixWithUnitPricingConfig{additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is BulkWithProration && + return other is ScalableMatrixWithUnitPricing && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && - bulkWithProrationConfig == other.bulkWithProrationConfig && cadence == other.cadence && + compositePriceFilters == other.compositePriceFilters && conversionRate == other.conversionRate && conversionRateConfig == other.conversionRateConfig && createdAt == other.createdAt && @@ -43256,6 +44983,7 @@ private constructor( planPhaseOrder == other.planPhaseOrder && priceType == other.priceType && replacesPriceId == other.replacesPriceId && + scalableMatrixWithUnitPricingConfig == other.scalableMatrixWithUnitPricingConfig && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties } @@ -43265,8 +44993,8 @@ private constructor( id, billableMetric, billingCycleConfiguration, - bulkWithProrationConfig, cadence, + compositePriceFilters, conversionRate, conversionRateConfig, createdAt, @@ -43287,6 +45015,7 @@ private constructor( planPhaseOrder, priceType, replacesPriceId, + scalableMatrixWithUnitPricingConfig, dimensionalPriceConfiguration, additionalProperties, ) @@ -43295,15 +45024,16 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "BulkWithProration{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, bulkWithProrationConfig=$bulkWithProrationConfig, cadence=$cadence, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "ScalableMatrixWithUnitPricing{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, scalableMatrixWithUnitPricingConfig=$scalableMatrixWithUnitPricingConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" } - class GroupedTieredPackage + class ScalableMatrixWithTieredPricing private constructor( private val id: JsonField, private val billableMetric: JsonField, private val billingCycleConfiguration: JsonField, private val cadence: JsonField, + private val compositePriceFilters: JsonField>, private val conversionRate: JsonField, private val conversionRateConfig: JsonField, private val createdAt: JsonField, @@ -43312,7 +45042,6 @@ private constructor( private val discount: JsonField, private val externalPriceId: JsonField, private val fixedPriceQuantity: JsonField, - private val groupedTieredPackageConfig: JsonField, private val invoicingCycleConfiguration: JsonField, private val item: JsonField, private val maximum: JsonField, @@ -43325,6 +45054,8 @@ private constructor( private val planPhaseOrder: JsonField, private val priceType: JsonField, private val replacesPriceId: JsonField, + private val scalableMatrixWithTieredPricingConfig: + JsonField, private val dimensionalPriceConfiguration: JsonField, private val additionalProperties: MutableMap, ) { @@ -43339,6 +45070,9 @@ private constructor( @ExcludeMissing billingCycleConfiguration: JsonField = JsonMissing.of(), @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), + @JsonProperty("composite_price_filters") + @ExcludeMissing + compositePriceFilters: JsonField> = JsonMissing.of(), @JsonProperty("conversion_rate") @ExcludeMissing conversionRate: JsonField = JsonMissing.of(), @@ -43363,9 +45097,6 @@ private constructor( @JsonProperty("fixed_price_quantity") @ExcludeMissing fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("grouped_tiered_package_config") - @ExcludeMissing - groupedTieredPackageConfig: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), @@ -43392,6 +45123,11 @@ private constructor( @JsonProperty("replaces_price_id") @ExcludeMissing replacesPriceId: JsonField = JsonMissing.of(), + @JsonProperty("scalable_matrix_with_tiered_pricing_config") + @ExcludeMissing + scalableMatrixWithTieredPricingConfig: + JsonField = + JsonMissing.of(), @JsonProperty("dimensional_price_configuration") @ExcludeMissing dimensionalPriceConfiguration: JsonField = @@ -43401,6 +45137,7 @@ private constructor( billableMetric, billingCycleConfiguration, cadence, + compositePriceFilters, conversionRate, conversionRateConfig, createdAt, @@ -43409,7 +45146,6 @@ private constructor( discount, externalPriceId, fixedPriceQuantity, - groupedTieredPackageConfig, invoicingCycleConfiguration, item, maximum, @@ -43422,6 +45158,7 @@ private constructor( planPhaseOrder, priceType, replacesPriceId, + scalableMatrixWithTieredPricingConfig, dimensionalPriceConfiguration, mutableMapOf(), ) @@ -43451,6 +45188,13 @@ private constructor( */ fun cadence(): Cadence = cadence.getRequired("cadence") + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun compositePriceFilters(): List? = + compositePriceFilters.getNullable("composite_price_filters") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -43500,13 +45244,6 @@ private constructor( */ fun fixedPriceQuantity(): Double? = fixedPriceQuantity.getNullable("fixed_price_quantity") - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun groupedTieredPackageConfig(): GroupedTieredPackageConfig = - groupedTieredPackageConfig.getRequired("grouped_tiered_package_config") - /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -43559,7 +45296,7 @@ private constructor( /** * Expected to always return the following: * ```kotlin - * JsonValue.from("grouped_tiered_package") + * JsonValue.from("scalable_matrix_with_tiered_pricing") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -43594,6 +45331,15 @@ private constructor( */ fun replacesPriceId(): String? = replacesPriceId.getNullable("replaces_price_id") + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun scalableMatrixWithTieredPricingConfig(): ScalableMatrixWithTieredPricingConfig = + scalableMatrixWithTieredPricingConfig.getRequired( + "scalable_matrix_with_tiered_pricing_config" + ) + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -43636,6 +45382,16 @@ private constructor( */ @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence + /** + * Returns the raw JSON value of [compositePriceFilters]. + * + * Unlike [compositePriceFilters], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("composite_price_filters") + @ExcludeMissing + fun _compositePriceFilters(): JsonField> = compositePriceFilters + /** * Returns the raw JSON value of [conversionRate]. * @@ -43712,17 +45468,6 @@ private constructor( @ExcludeMissing fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - /** - * Returns the raw JSON value of [groupedTieredPackageConfig]. - * - * Unlike [groupedTieredPackageConfig], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("grouped_tiered_package_config") - @ExcludeMissing - fun _groupedTieredPackageConfig(): JsonField = - groupedTieredPackageConfig - /** * Returns the raw JSON value of [invoicingCycleConfiguration]. * @@ -43826,6 +45571,17 @@ private constructor( @ExcludeMissing fun _replacesPriceId(): JsonField = replacesPriceId + /** + * Returns the raw JSON value of [scalableMatrixWithTieredPricingConfig]. + * + * Unlike [scalableMatrixWithTieredPricingConfig], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("scalable_matrix_with_tiered_pricing_config") + @ExcludeMissing + fun _scalableMatrixWithTieredPricingConfig(): + JsonField = scalableMatrixWithTieredPricingConfig + /** * Returns the raw JSON value of [dimensionalPriceConfiguration]. * @@ -43852,7 +45608,8 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [GroupedTieredPackage]. + * Returns a mutable builder for constructing an instance of + * [ScalableMatrixWithTieredPricing]. * * The following fields are required: * ```kotlin @@ -43860,6 +45617,7 @@ private constructor( * .billableMetric() * .billingCycleConfiguration() * .cadence() + * .compositePriceFilters() * .conversionRate() * .conversionRateConfig() * .createdAt() @@ -43868,7 +45626,6 @@ private constructor( * .discount() * .externalPriceId() * .fixedPriceQuantity() - * .groupedTieredPackageConfig() * .invoicingCycleConfiguration() * .item() * .maximum() @@ -43880,18 +45637,20 @@ private constructor( * .planPhaseOrder() * .priceType() * .replacesPriceId() + * .scalableMatrixWithTieredPricingConfig() * ``` */ fun builder() = Builder() } - /** A builder for [GroupedTieredPackage]. */ + /** A builder for [ScalableMatrixWithTieredPricing]. */ class Builder internal constructor() { private var id: JsonField? = null private var billableMetric: JsonField? = null private var billingCycleConfiguration: JsonField? = null private var cadence: JsonField? = null + private var compositePriceFilters: JsonField>? = null private var conversionRate: JsonField? = null private var conversionRateConfig: JsonField? = null private var createdAt: JsonField? = null @@ -43900,7 +45659,6 @@ private constructor( private var discount: JsonField? = null private var externalPriceId: JsonField? = null private var fixedPriceQuantity: JsonField? = null - private var groupedTieredPackageConfig: JsonField? = null private var invoicingCycleConfiguration: JsonField? = null private var item: JsonField? = null private var maximum: JsonField? = null @@ -43908,44 +45666,57 @@ private constructor( private var metadata: JsonField? = null private var minimum: JsonField? = null private var minimumAmount: JsonField? = null - private var modelType: JsonValue = JsonValue.from("grouped_tiered_package") + private var modelType: JsonValue = JsonValue.from("scalable_matrix_with_tiered_pricing") private var name: JsonField? = null private var planPhaseOrder: JsonField? = null private var priceType: JsonField? = null private var replacesPriceId: JsonField? = null + private var scalableMatrixWithTieredPricingConfig: + JsonField? = + null private var dimensionalPriceConfiguration: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(groupedTieredPackage: GroupedTieredPackage) = apply { - id = groupedTieredPackage.id - billableMetric = groupedTieredPackage.billableMetric - billingCycleConfiguration = groupedTieredPackage.billingCycleConfiguration - cadence = groupedTieredPackage.cadence - conversionRate = groupedTieredPackage.conversionRate - conversionRateConfig = groupedTieredPackage.conversionRateConfig - createdAt = groupedTieredPackage.createdAt - creditAllocation = groupedTieredPackage.creditAllocation - currency = groupedTieredPackage.currency - discount = groupedTieredPackage.discount - externalPriceId = groupedTieredPackage.externalPriceId - fixedPriceQuantity = groupedTieredPackage.fixedPriceQuantity - groupedTieredPackageConfig = groupedTieredPackage.groupedTieredPackageConfig - invoicingCycleConfiguration = groupedTieredPackage.invoicingCycleConfiguration - item = groupedTieredPackage.item - maximum = groupedTieredPackage.maximum - maximumAmount = groupedTieredPackage.maximumAmount - metadata = groupedTieredPackage.metadata - minimum = groupedTieredPackage.minimum - minimumAmount = groupedTieredPackage.minimumAmount - modelType = groupedTieredPackage.modelType - name = groupedTieredPackage.name - planPhaseOrder = groupedTieredPackage.planPhaseOrder - priceType = groupedTieredPackage.priceType - replacesPriceId = groupedTieredPackage.replacesPriceId - dimensionalPriceConfiguration = groupedTieredPackage.dimensionalPriceConfiguration - additionalProperties = groupedTieredPackage.additionalProperties.toMutableMap() - } + internal fun from(scalableMatrixWithTieredPricing: ScalableMatrixWithTieredPricing) = + apply { + id = scalableMatrixWithTieredPricing.id + billableMetric = scalableMatrixWithTieredPricing.billableMetric + billingCycleConfiguration = + scalableMatrixWithTieredPricing.billingCycleConfiguration + cadence = scalableMatrixWithTieredPricing.cadence + compositePriceFilters = + scalableMatrixWithTieredPricing.compositePriceFilters.map { + it.toMutableList() + } + conversionRate = scalableMatrixWithTieredPricing.conversionRate + conversionRateConfig = scalableMatrixWithTieredPricing.conversionRateConfig + createdAt = scalableMatrixWithTieredPricing.createdAt + creditAllocation = scalableMatrixWithTieredPricing.creditAllocation + currency = scalableMatrixWithTieredPricing.currency + discount = scalableMatrixWithTieredPricing.discount + externalPriceId = scalableMatrixWithTieredPricing.externalPriceId + fixedPriceQuantity = scalableMatrixWithTieredPricing.fixedPriceQuantity + invoicingCycleConfiguration = + scalableMatrixWithTieredPricing.invoicingCycleConfiguration + item = scalableMatrixWithTieredPricing.item + maximum = scalableMatrixWithTieredPricing.maximum + maximumAmount = scalableMatrixWithTieredPricing.maximumAmount + metadata = scalableMatrixWithTieredPricing.metadata + minimum = scalableMatrixWithTieredPricing.minimum + minimumAmount = scalableMatrixWithTieredPricing.minimumAmount + modelType = scalableMatrixWithTieredPricing.modelType + name = scalableMatrixWithTieredPricing.name + planPhaseOrder = scalableMatrixWithTieredPricing.planPhaseOrder + priceType = scalableMatrixWithTieredPricing.priceType + replacesPriceId = scalableMatrixWithTieredPricing.replacesPriceId + scalableMatrixWithTieredPricingConfig = + scalableMatrixWithTieredPricing.scalableMatrixWithTieredPricingConfig + dimensionalPriceConfiguration = + scalableMatrixWithTieredPricing.dimensionalPriceConfiguration + additionalProperties = + scalableMatrixWithTieredPricing.additionalProperties.toMutableMap() + } fun id(id: String) = id(JsonField.of(id)) @@ -43997,6 +45768,34 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + fun compositePriceFilters(compositePriceFilters: List?) = + compositePriceFilters(JsonField.ofNullable(compositePriceFilters)) + + /** + * Sets [Builder.compositePriceFilters] to an arbitrary JSON value. + * + * You should usually call [Builder.compositePriceFilters] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun compositePriceFilters( + compositePriceFilters: JsonField> + ) = apply { + this.compositePriceFilters = compositePriceFilters.map { it.toMutableList() } + } + + /** + * Adds a single [TransformPriceFilter] to [compositePriceFilters]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addCompositePriceFilter(compositePriceFilter: TransformPriceFilter) = apply { + compositePriceFilters = + (compositePriceFilters ?: JsonField.of(mutableListOf())).also { + checkKnown("compositePriceFilters", it).add(compositePriceFilter) + } + } + fun conversionRate(conversionRate: Double?) = conversionRate(JsonField.ofNullable(conversionRate)) @@ -44238,20 +46037,6 @@ private constructor( this.fixedPriceQuantity = fixedPriceQuantity } - fun groupedTieredPackageConfig(groupedTieredPackageConfig: GroupedTieredPackageConfig) = - groupedTieredPackageConfig(JsonField.of(groupedTieredPackageConfig)) - - /** - * Sets [Builder.groupedTieredPackageConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.groupedTieredPackageConfig] with a well-typed - * [GroupedTieredPackageConfig] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun groupedTieredPackageConfig( - groupedTieredPackageConfig: JsonField - ) = apply { this.groupedTieredPackageConfig = groupedTieredPackageConfig } - fun invoicingCycleConfiguration( invoicingCycleConfiguration: BillingCycleConfiguration? ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) @@ -44358,7 +46143,7 @@ private constructor( * It is usually unnecessary to call this method because the field defaults to the * following: * ```kotlin - * JsonValue.from("grouped_tiered_package") + * JsonValue.from("scalable_matrix_with_tiered_pricing") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -44427,6 +46212,27 @@ private constructor( this.replacesPriceId = replacesPriceId } + fun scalableMatrixWithTieredPricingConfig( + scalableMatrixWithTieredPricingConfig: ScalableMatrixWithTieredPricingConfig + ) = + scalableMatrixWithTieredPricingConfig( + JsonField.of(scalableMatrixWithTieredPricingConfig) + ) + + /** + * Sets [Builder.scalableMatrixWithTieredPricingConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.scalableMatrixWithTieredPricingConfig] with a + * well-typed [ScalableMatrixWithTieredPricingConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported value. + */ + fun scalableMatrixWithTieredPricingConfig( + scalableMatrixWithTieredPricingConfig: + JsonField + ) = apply { + this.scalableMatrixWithTieredPricingConfig = scalableMatrixWithTieredPricingConfig + } + fun dimensionalPriceConfiguration( dimensionalPriceConfiguration: DimensionalPriceConfiguration? ) = dimensionalPriceConfiguration(JsonField.ofNullable(dimensionalPriceConfiguration)) @@ -44462,7 +46268,7 @@ private constructor( } /** - * Returns an immutable instance of [GroupedTieredPackage]. + * Returns an immutable instance of [ScalableMatrixWithTieredPricing]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -44472,6 +46278,7 @@ private constructor( * .billableMetric() * .billingCycleConfiguration() * .cadence() + * .compositePriceFilters() * .conversionRate() * .conversionRateConfig() * .createdAt() @@ -44480,7 +46287,6 @@ private constructor( * .discount() * .externalPriceId() * .fixedPriceQuantity() - * .groupedTieredPackageConfig() * .invoicingCycleConfiguration() * .item() * .maximum() @@ -44492,16 +46298,20 @@ private constructor( * .planPhaseOrder() * .priceType() * .replacesPriceId() + * .scalableMatrixWithTieredPricingConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): GroupedTieredPackage = - GroupedTieredPackage( + fun build(): ScalableMatrixWithTieredPricing = + ScalableMatrixWithTieredPricing( checkRequired("id", id), checkRequired("billableMetric", billableMetric), checkRequired("billingCycleConfiguration", billingCycleConfiguration), checkRequired("cadence", cadence), + checkRequired("compositePriceFilters", compositePriceFilters).map { + it.toImmutable() + }, checkRequired("conversionRate", conversionRate), checkRequired("conversionRateConfig", conversionRateConfig), checkRequired("createdAt", createdAt), @@ -44510,7 +46320,6 @@ private constructor( checkRequired("discount", discount), checkRequired("externalPriceId", externalPriceId), checkRequired("fixedPriceQuantity", fixedPriceQuantity), - checkRequired("groupedTieredPackageConfig", groupedTieredPackageConfig), checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), checkRequired("item", item), checkRequired("maximum", maximum), @@ -44523,6 +46332,10 @@ private constructor( checkRequired("planPhaseOrder", planPhaseOrder), checkRequired("priceType", priceType), checkRequired("replacesPriceId", replacesPriceId), + checkRequired( + "scalableMatrixWithTieredPricingConfig", + scalableMatrixWithTieredPricingConfig, + ), dimensionalPriceConfiguration, additionalProperties.toMutableMap(), ) @@ -44530,7 +46343,7 @@ private constructor( private var validated: Boolean = false - fun validate(): GroupedTieredPackage = apply { + fun validate(): ScalableMatrixWithTieredPricing = apply { if (validated) { return@apply } @@ -44539,6 +46352,7 @@ private constructor( billableMetric()?.validate() billingCycleConfiguration().validate() cadence().validate() + compositePriceFilters()?.forEach { it.validate() } conversionRate() conversionRateConfig()?.validate() createdAt() @@ -44547,7 +46361,6 @@ private constructor( discount()?.validate() externalPriceId() fixedPriceQuantity() - groupedTieredPackageConfig().validate() invoicingCycleConfiguration()?.validate() item().validate() maximum()?.validate() @@ -44556,7 +46369,7 @@ private constructor( minimum()?.validate() minimumAmount() _modelType().let { - if (it != JsonValue.from("grouped_tiered_package")) { + if (it != JsonValue.from("scalable_matrix_with_tiered_pricing")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } @@ -44564,6 +46377,7 @@ private constructor( planPhaseOrder() priceType().validate() replacesPriceId() + scalableMatrixWithTieredPricingConfig().validate() dimensionalPriceConfiguration()?.validate() validated = true } @@ -44587,6 +46401,7 @@ private constructor( (billableMetric.asKnown()?.validity() ?: 0) + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + (cadence.asKnown()?.validity() ?: 0) + + (compositePriceFilters.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + (if (conversionRate.asKnown() == null) 0 else 1) + (conversionRateConfig.asKnown()?.validity() ?: 0) + (if (createdAt.asKnown() == null) 0 else 1) + @@ -44595,7 +46410,6 @@ private constructor( (discount.asKnown()?.validity() ?: 0) + (if (externalPriceId.asKnown() == null) 0 else 1) + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + - (groupedTieredPackageConfig.asKnown()?.validity() ?: 0) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + (item.asKnown()?.validity() ?: 0) + (maximum.asKnown()?.validity() ?: 0) + @@ -44603,11 +46417,14 @@ private constructor( (metadata.asKnown()?.validity() ?: 0) + (minimum.asKnown()?.validity() ?: 0) + (if (minimumAmount.asKnown() == null) 0 else 1) + - modelType.let { if (it == JsonValue.from("grouped_tiered_package")) 1 else 0 } + + modelType.let { + if (it == JsonValue.from("scalable_matrix_with_tiered_pricing")) 1 else 0 + } + (if (name.asKnown() == null) 0 else 1) + (if (planPhaseOrder.asKnown() == null) 0 else 1) + (priceType.asKnown()?.validity() ?: 0) + (if (replacesPriceId.asKnown() == null) 0 else 1) + + (scalableMatrixWithTieredPricingConfig.asKnown()?.validity() ?: 0) + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) class Cadence @JsonCreator private constructor(private val value: JsonField) : @@ -44762,113 +46579,6 @@ private constructor( override fun toString() = value.toString() } - class GroupedTieredPackageConfig - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [GroupedTieredPackageConfig]. - */ - fun builder() = Builder() - } - - /** A builder for [GroupedTieredPackageConfig]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(groupedTieredPackageConfig: GroupedTieredPackageConfig) = apply { - additionalProperties = - groupedTieredPackageConfig.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [GroupedTieredPackageConfig]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): GroupedTieredPackageConfig = - GroupedTieredPackageConfig(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): GroupedTieredPackageConfig = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is GroupedTieredPackageConfig && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "GroupedTieredPackageConfig{additionalProperties=$additionalProperties}" - } - /** * User specified key-value pairs for the resource. If not present, this defaults to an * empty dictionary. Individual keys can be removed by setting the value to `null`, and the @@ -45103,16 +46813,126 @@ private constructor( override fun toString() = value.toString() } + class ScalableMatrixWithTieredPricingConfig + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [ScalableMatrixWithTieredPricingConfig]. + */ + fun builder() = Builder() + } + + /** A builder for [ScalableMatrixWithTieredPricingConfig]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from( + scalableMatrixWithTieredPricingConfig: ScalableMatrixWithTieredPricingConfig + ) = apply { + additionalProperties = + scalableMatrixWithTieredPricingConfig.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ScalableMatrixWithTieredPricingConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ScalableMatrixWithTieredPricingConfig = + ScalableMatrixWithTieredPricingConfig(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): ScalableMatrixWithTieredPricingConfig = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ScalableMatrixWithTieredPricingConfig && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ScalableMatrixWithTieredPricingConfig{additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is GroupedTieredPackage && + return other is ScalableMatrixWithTieredPricing && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && + compositePriceFilters == other.compositePriceFilters && conversionRate == other.conversionRate && conversionRateConfig == other.conversionRateConfig && createdAt == other.createdAt && @@ -45121,7 +46941,6 @@ private constructor( discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && - groupedTieredPackageConfig == other.groupedTieredPackageConfig && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maximum == other.maximum && @@ -45134,6 +46953,8 @@ private constructor( planPhaseOrder == other.planPhaseOrder && priceType == other.priceType && replacesPriceId == other.replacesPriceId && + scalableMatrixWithTieredPricingConfig == + other.scalableMatrixWithTieredPricingConfig && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties } @@ -45144,6 +46965,7 @@ private constructor( billableMetric, billingCycleConfiguration, cadence, + compositePriceFilters, conversionRate, conversionRateConfig, createdAt, @@ -45152,7 +46974,6 @@ private constructor( discount, externalPriceId, fixedPriceQuantity, - groupedTieredPackageConfig, invoicingCycleConfiguration, item, maximum, @@ -45165,6 +46986,7 @@ private constructor( planPhaseOrder, priceType, replacesPriceId, + scalableMatrixWithTieredPricingConfig, dimensionalPriceConfiguration, additionalProperties, ) @@ -45173,26 +46995,27 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "GroupedTieredPackage{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, groupedTieredPackageConfig=$groupedTieredPackageConfig, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "ScalableMatrixWithTieredPricing{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, scalableMatrixWithTieredPricingConfig=$scalableMatrixWithTieredPricingConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" } - class MaxGroupTieredPackage + class CumulativeGroupedBulk private constructor( private val id: JsonField, private val billableMetric: JsonField, private val billingCycleConfiguration: JsonField, private val cadence: JsonField, + private val compositePriceFilters: JsonField>, private val conversionRate: JsonField, private val conversionRateConfig: JsonField, private val createdAt: JsonField, private val creditAllocation: JsonField, + private val cumulativeGroupedBulkConfig: JsonField, private val currency: JsonField, private val discount: JsonField, private val externalPriceId: JsonField, private val fixedPriceQuantity: JsonField, private val invoicingCycleConfiguration: JsonField, private val item: JsonField, - private val maxGroupTieredPackageConfig: JsonField, private val maximum: JsonField, private val maximumAmount: JsonField, private val metadata: JsonField, @@ -45217,6 +47040,9 @@ private constructor( @ExcludeMissing billingCycleConfiguration: JsonField = JsonMissing.of(), @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), + @JsonProperty("composite_price_filters") + @ExcludeMissing + compositePriceFilters: JsonField> = JsonMissing.of(), @JsonProperty("conversion_rate") @ExcludeMissing conversionRate: JsonField = JsonMissing.of(), @@ -45229,6 +47055,9 @@ private constructor( @JsonProperty("credit_allocation") @ExcludeMissing creditAllocation: JsonField = JsonMissing.of(), + @JsonProperty("cumulative_grouped_bulk_config") + @ExcludeMissing + cumulativeGroupedBulkConfig: JsonField = JsonMissing.of(), @JsonProperty("currency") @ExcludeMissing currency: JsonField = JsonMissing.of(), @@ -45245,9 +47074,6 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), @JsonProperty("item") @ExcludeMissing item: JsonField = JsonMissing.of(), - @JsonProperty("max_group_tiered_package_config") - @ExcludeMissing - maxGroupTieredPackageConfig: JsonField = JsonMissing.of(), @JsonProperty("maximum") @ExcludeMissing maximum: JsonField = JsonMissing.of(), @JsonProperty("maximum_amount") @ExcludeMissing @@ -45279,17 +47105,18 @@ private constructor( billableMetric, billingCycleConfiguration, cadence, + compositePriceFilters, conversionRate, conversionRateConfig, createdAt, creditAllocation, + cumulativeGroupedBulkConfig, currency, discount, externalPriceId, fixedPriceQuantity, invoicingCycleConfiguration, item, - maxGroupTieredPackageConfig, maximum, maximumAmount, metadata, @@ -45329,6 +47156,13 @@ private constructor( */ fun cadence(): Cadence = cadence.getRequired("cadence") + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun compositePriceFilters(): List? = + compositePriceFilters.getNullable("composite_price_filters") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -45354,6 +47188,13 @@ private constructor( */ fun creditAllocation(): Allocation? = creditAllocation.getNullable("credit_allocation") + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun cumulativeGroupedBulkConfig(): CumulativeGroupedBulkConfig = + cumulativeGroupedBulkConfig.getRequired("cumulative_grouped_bulk_config") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). @@ -45391,13 +47232,6 @@ private constructor( */ fun item(): ItemSlim = item.getRequired("item") - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun maxGroupTieredPackageConfig(): MaxGroupTieredPackageConfig = - maxGroupTieredPackageConfig.getRequired("max_group_tiered_package_config") - /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -45437,7 +47271,7 @@ private constructor( /** * Expected to always return the following: * ```kotlin - * JsonValue.from("max_group_tiered_package") + * JsonValue.from("cumulative_grouped_bulk") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -45514,6 +47348,16 @@ private constructor( */ @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence + /** + * Returns the raw JSON value of [compositePriceFilters]. + * + * Unlike [compositePriceFilters], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("composite_price_filters") + @ExcludeMissing + fun _compositePriceFilters(): JsonField> = compositePriceFilters + /** * Returns the raw JSON value of [conversionRate]. * @@ -45553,6 +47397,17 @@ private constructor( @ExcludeMissing fun _creditAllocation(): JsonField = creditAllocation + /** + * Returns the raw JSON value of [cumulativeGroupedBulkConfig]. + * + * Unlike [cumulativeGroupedBulkConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("cumulative_grouped_bulk_config") + @ExcludeMissing + fun _cumulativeGroupedBulkConfig(): JsonField = + cumulativeGroupedBulkConfig + /** * Returns the raw JSON value of [currency]. * @@ -45608,17 +47463,6 @@ private constructor( */ @JsonProperty("item") @ExcludeMissing fun _item(): JsonField = item - /** - * Returns the raw JSON value of [maxGroupTieredPackageConfig]. - * - * Unlike [maxGroupTieredPackageConfig], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("max_group_tiered_package_config") - @ExcludeMissing - fun _maxGroupTieredPackageConfig(): JsonField = - maxGroupTieredPackageConfig - /** * Returns the raw JSON value of [maximum]. * @@ -45730,7 +47574,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [MaxGroupTieredPackage]. + * Returns a mutable builder for constructing an instance of [CumulativeGroupedBulk]. * * The following fields are required: * ```kotlin @@ -45738,17 +47582,18 @@ private constructor( * .billableMetric() * .billingCycleConfiguration() * .cadence() + * .compositePriceFilters() * .conversionRate() * .conversionRateConfig() * .createdAt() * .creditAllocation() + * .cumulativeGroupedBulkConfig() * .currency() * .discount() * .externalPriceId() * .fixedPriceQuantity() * .invoicingCycleConfiguration() * .item() - * .maxGroupTieredPackageConfig() * .maximum() * .maximumAmount() * .metadata() @@ -45763,30 +47608,31 @@ private constructor( fun builder() = Builder() } - /** A builder for [MaxGroupTieredPackage]. */ + /** A builder for [CumulativeGroupedBulk]. */ class Builder internal constructor() { private var id: JsonField? = null private var billableMetric: JsonField? = null private var billingCycleConfiguration: JsonField? = null private var cadence: JsonField? = null + private var compositePriceFilters: JsonField>? = null private var conversionRate: JsonField? = null private var conversionRateConfig: JsonField? = null private var createdAt: JsonField? = null private var creditAllocation: JsonField? = null + private var cumulativeGroupedBulkConfig: JsonField? = null private var currency: JsonField? = null private var discount: JsonField? = null private var externalPriceId: JsonField? = null private var fixedPriceQuantity: JsonField? = null private var invoicingCycleConfiguration: JsonField? = null private var item: JsonField? = null - private var maxGroupTieredPackageConfig: JsonField? = null private var maximum: JsonField? = null private var maximumAmount: JsonField? = null private var metadata: JsonField? = null private var minimum: JsonField? = null private var minimumAmount: JsonField? = null - private var modelType: JsonValue = JsonValue.from("max_group_tiered_package") + private var modelType: JsonValue = JsonValue.from("cumulative_grouped_bulk") private var name: JsonField? = null private var planPhaseOrder: JsonField? = null private var priceType: JsonField? = null @@ -45795,34 +47641,36 @@ private constructor( JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(maxGroupTieredPackage: MaxGroupTieredPackage) = apply { - id = maxGroupTieredPackage.id - billableMetric = maxGroupTieredPackage.billableMetric - billingCycleConfiguration = maxGroupTieredPackage.billingCycleConfiguration - cadence = maxGroupTieredPackage.cadence - conversionRate = maxGroupTieredPackage.conversionRate - conversionRateConfig = maxGroupTieredPackage.conversionRateConfig - createdAt = maxGroupTieredPackage.createdAt - creditAllocation = maxGroupTieredPackage.creditAllocation - currency = maxGroupTieredPackage.currency - discount = maxGroupTieredPackage.discount - externalPriceId = maxGroupTieredPackage.externalPriceId - fixedPriceQuantity = maxGroupTieredPackage.fixedPriceQuantity - invoicingCycleConfiguration = maxGroupTieredPackage.invoicingCycleConfiguration - item = maxGroupTieredPackage.item - maxGroupTieredPackageConfig = maxGroupTieredPackage.maxGroupTieredPackageConfig - maximum = maxGroupTieredPackage.maximum - maximumAmount = maxGroupTieredPackage.maximumAmount - metadata = maxGroupTieredPackage.metadata - minimum = maxGroupTieredPackage.minimum - minimumAmount = maxGroupTieredPackage.minimumAmount - modelType = maxGroupTieredPackage.modelType - name = maxGroupTieredPackage.name - planPhaseOrder = maxGroupTieredPackage.planPhaseOrder - priceType = maxGroupTieredPackage.priceType - replacesPriceId = maxGroupTieredPackage.replacesPriceId - dimensionalPriceConfiguration = maxGroupTieredPackage.dimensionalPriceConfiguration - additionalProperties = maxGroupTieredPackage.additionalProperties.toMutableMap() + internal fun from(cumulativeGroupedBulk: CumulativeGroupedBulk) = apply { + id = cumulativeGroupedBulk.id + billableMetric = cumulativeGroupedBulk.billableMetric + billingCycleConfiguration = cumulativeGroupedBulk.billingCycleConfiguration + cadence = cumulativeGroupedBulk.cadence + compositePriceFilters = + cumulativeGroupedBulk.compositePriceFilters.map { it.toMutableList() } + conversionRate = cumulativeGroupedBulk.conversionRate + conversionRateConfig = cumulativeGroupedBulk.conversionRateConfig + createdAt = cumulativeGroupedBulk.createdAt + creditAllocation = cumulativeGroupedBulk.creditAllocation + cumulativeGroupedBulkConfig = cumulativeGroupedBulk.cumulativeGroupedBulkConfig + currency = cumulativeGroupedBulk.currency + discount = cumulativeGroupedBulk.discount + externalPriceId = cumulativeGroupedBulk.externalPriceId + fixedPriceQuantity = cumulativeGroupedBulk.fixedPriceQuantity + invoicingCycleConfiguration = cumulativeGroupedBulk.invoicingCycleConfiguration + item = cumulativeGroupedBulk.item + maximum = cumulativeGroupedBulk.maximum + maximumAmount = cumulativeGroupedBulk.maximumAmount + metadata = cumulativeGroupedBulk.metadata + minimum = cumulativeGroupedBulk.minimum + minimumAmount = cumulativeGroupedBulk.minimumAmount + modelType = cumulativeGroupedBulk.modelType + name = cumulativeGroupedBulk.name + planPhaseOrder = cumulativeGroupedBulk.planPhaseOrder + priceType = cumulativeGroupedBulk.priceType + replacesPriceId = cumulativeGroupedBulk.replacesPriceId + dimensionalPriceConfiguration = cumulativeGroupedBulk.dimensionalPriceConfiguration + additionalProperties = cumulativeGroupedBulk.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) @@ -45875,6 +47723,34 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + fun compositePriceFilters(compositePriceFilters: List?) = + compositePriceFilters(JsonField.ofNullable(compositePriceFilters)) + + /** + * Sets [Builder.compositePriceFilters] to an arbitrary JSON value. + * + * You should usually call [Builder.compositePriceFilters] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun compositePriceFilters( + compositePriceFilters: JsonField> + ) = apply { + this.compositePriceFilters = compositePriceFilters.map { it.toMutableList() } + } + + /** + * Adds a single [TransformPriceFilter] to [compositePriceFilters]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addCompositePriceFilter(compositePriceFilter: TransformPriceFilter) = apply { + compositePriceFilters = + (compositePriceFilters ?: JsonField.of(mutableListOf())).also { + checkKnown("compositePriceFilters", it).add(compositePriceFilter) + } + } + fun conversionRate(conversionRate: Double?) = conversionRate(JsonField.ofNullable(conversionRate)) @@ -45985,6 +47861,21 @@ private constructor( this.creditAllocation = creditAllocation } + fun cumulativeGroupedBulkConfig( + cumulativeGroupedBulkConfig: CumulativeGroupedBulkConfig + ) = cumulativeGroupedBulkConfig(JsonField.of(cumulativeGroupedBulkConfig)) + + /** + * Sets [Builder.cumulativeGroupedBulkConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.cumulativeGroupedBulkConfig] with a well-typed + * [CumulativeGroupedBulkConfig] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun cumulativeGroupedBulkConfig( + cumulativeGroupedBulkConfig: JsonField + ) = apply { this.cumulativeGroupedBulkConfig = cumulativeGroupedBulkConfig } + fun currency(currency: String) = currency(JsonField.of(currency)) /** @@ -46142,21 +48033,6 @@ private constructor( */ fun item(item: JsonField) = apply { this.item = item } - fun maxGroupTieredPackageConfig( - maxGroupTieredPackageConfig: MaxGroupTieredPackageConfig - ) = maxGroupTieredPackageConfig(JsonField.of(maxGroupTieredPackageConfig)) - - /** - * Sets [Builder.maxGroupTieredPackageConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.maxGroupTieredPackageConfig] with a well-typed - * [MaxGroupTieredPackageConfig] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun maxGroupTieredPackageConfig( - maxGroupTieredPackageConfig: JsonField - ) = apply { this.maxGroupTieredPackageConfig = maxGroupTieredPackageConfig } - @Deprecated("deprecated") fun maximum(maximum: Maximum?) = maximum(JsonField.ofNullable(maximum)) @@ -46237,7 +48113,7 @@ private constructor( * It is usually unnecessary to call this method because the field defaults to the * following: * ```kotlin - * JsonValue.from("max_group_tiered_package") + * JsonValue.from("cumulative_grouped_bulk") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -46341,7 +48217,7 @@ private constructor( } /** - * Returns an immutable instance of [MaxGroupTieredPackage]. + * Returns an immutable instance of [CumulativeGroupedBulk]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -46351,17 +48227,18 @@ private constructor( * .billableMetric() * .billingCycleConfiguration() * .cadence() + * .compositePriceFilters() * .conversionRate() * .conversionRateConfig() * .createdAt() * .creditAllocation() + * .cumulativeGroupedBulkConfig() * .currency() * .discount() * .externalPriceId() * .fixedPriceQuantity() * .invoicingCycleConfiguration() * .item() - * .maxGroupTieredPackageConfig() * .maximum() * .maximumAmount() * .metadata() @@ -46375,23 +48252,26 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): MaxGroupTieredPackage = - MaxGroupTieredPackage( + fun build(): CumulativeGroupedBulk = + CumulativeGroupedBulk( checkRequired("id", id), checkRequired("billableMetric", billableMetric), checkRequired("billingCycleConfiguration", billingCycleConfiguration), checkRequired("cadence", cadence), + checkRequired("compositePriceFilters", compositePriceFilters).map { + it.toImmutable() + }, checkRequired("conversionRate", conversionRate), checkRequired("conversionRateConfig", conversionRateConfig), checkRequired("createdAt", createdAt), checkRequired("creditAllocation", creditAllocation), + checkRequired("cumulativeGroupedBulkConfig", cumulativeGroupedBulkConfig), checkRequired("currency", currency), checkRequired("discount", discount), checkRequired("externalPriceId", externalPriceId), checkRequired("fixedPriceQuantity", fixedPriceQuantity), checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), checkRequired("item", item), - checkRequired("maxGroupTieredPackageConfig", maxGroupTieredPackageConfig), checkRequired("maximum", maximum), checkRequired("maximumAmount", maximumAmount), checkRequired("metadata", metadata), @@ -46409,7 +48289,7 @@ private constructor( private var validated: Boolean = false - fun validate(): MaxGroupTieredPackage = apply { + fun validate(): CumulativeGroupedBulk = apply { if (validated) { return@apply } @@ -46418,24 +48298,25 @@ private constructor( billableMetric()?.validate() billingCycleConfiguration().validate() cadence().validate() + compositePriceFilters()?.forEach { it.validate() } conversionRate() conversionRateConfig()?.validate() createdAt() creditAllocation()?.validate() + cumulativeGroupedBulkConfig().validate() currency() discount()?.validate() externalPriceId() fixedPriceQuantity() invoicingCycleConfiguration()?.validate() item().validate() - maxGroupTieredPackageConfig().validate() maximum()?.validate() maximumAmount() metadata().validate() minimum()?.validate() minimumAmount() _modelType().let { - if (it != JsonValue.from("max_group_tiered_package")) { + if (it != JsonValue.from("cumulative_grouped_bulk")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } @@ -46466,23 +48347,24 @@ private constructor( (billableMetric.asKnown()?.validity() ?: 0) + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + (cadence.asKnown()?.validity() ?: 0) + + (compositePriceFilters.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + (if (conversionRate.asKnown() == null) 0 else 1) + (conversionRateConfig.asKnown()?.validity() ?: 0) + (if (createdAt.asKnown() == null) 0 else 1) + (creditAllocation.asKnown()?.validity() ?: 0) + + (cumulativeGroupedBulkConfig.asKnown()?.validity() ?: 0) + (if (currency.asKnown() == null) 0 else 1) + (discount.asKnown()?.validity() ?: 0) + (if (externalPriceId.asKnown() == null) 0 else 1) + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + (item.asKnown()?.validity() ?: 0) + - (maxGroupTieredPackageConfig.asKnown()?.validity() ?: 0) + (maximum.asKnown()?.validity() ?: 0) + (if (maximumAmount.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) + (minimum.asKnown()?.validity() ?: 0) + (if (minimumAmount.asKnown() == null) 0 else 1) + - modelType.let { if (it == JsonValue.from("max_group_tiered_package")) 1 else 0 } + + modelType.let { if (it == JsonValue.from("cumulative_grouped_bulk")) 1 else 0 } + (if (name.asKnown() == null) 0 else 1) + (if (planPhaseOrder.asKnown() == null) 0 else 1) + (priceType.asKnown()?.validity() ?: 0) + @@ -46641,7 +48523,7 @@ private constructor( override fun toString() = value.toString() } - class MaxGroupTieredPackageConfig + class CumulativeGroupedBulkConfig @JsonCreator private constructor( @com.fasterxml.jackson.annotation.JsonValue @@ -46658,20 +48540,20 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [MaxGroupTieredPackageConfig]. + * [CumulativeGroupedBulkConfig]. */ fun builder() = Builder() } - /** A builder for [MaxGroupTieredPackageConfig]. */ + /** A builder for [CumulativeGroupedBulkConfig]. */ class Builder internal constructor() { private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(maxGroupTieredPackageConfig: MaxGroupTieredPackageConfig) = + internal fun from(cumulativeGroupedBulkConfig: CumulativeGroupedBulkConfig) = apply { additionalProperties = - maxGroupTieredPackageConfig.additionalProperties.toMutableMap() + cumulativeGroupedBulkConfig.additionalProperties.toMutableMap() } fun additionalProperties(additionalProperties: Map) = apply { @@ -46697,17 +48579,17 @@ private constructor( } /** - * Returns an immutable instance of [MaxGroupTieredPackageConfig]. + * Returns an immutable instance of [CumulativeGroupedBulkConfig]. * * Further updates to this [Builder] will not mutate the returned instance. */ - fun build(): MaxGroupTieredPackageConfig = - MaxGroupTieredPackageConfig(additionalProperties.toImmutable()) + fun build(): CumulativeGroupedBulkConfig = + CumulativeGroupedBulkConfig(additionalProperties.toImmutable()) } private var validated: Boolean = false - fun validate(): MaxGroupTieredPackageConfig = apply { + fun validate(): CumulativeGroupedBulkConfig = apply { if (validated) { return@apply } @@ -46737,7 +48619,7 @@ private constructor( return true } - return other is MaxGroupTieredPackageConfig && + return other is CumulativeGroupedBulkConfig && additionalProperties == other.additionalProperties } @@ -46746,7 +48628,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "MaxGroupTieredPackageConfig{additionalProperties=$additionalProperties}" + "CumulativeGroupedBulkConfig{additionalProperties=$additionalProperties}" } /** @@ -46988,22 +48870,23 @@ private constructor( return true } - return other is MaxGroupTieredPackage && + return other is CumulativeGroupedBulk && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && + compositePriceFilters == other.compositePriceFilters && conversionRate == other.conversionRate && conversionRateConfig == other.conversionRateConfig && createdAt == other.createdAt && creditAllocation == other.creditAllocation && + cumulativeGroupedBulkConfig == other.cumulativeGroupedBulkConfig && currency == other.currency && discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && - maxGroupTieredPackageConfig == other.maxGroupTieredPackageConfig && maximum == other.maximum && maximumAmount == other.maximumAmount && metadata == other.metadata && @@ -47024,17 +48907,18 @@ private constructor( billableMetric, billingCycleConfiguration, cadence, + compositePriceFilters, conversionRate, conversionRateConfig, createdAt, creditAllocation, + cumulativeGroupedBulkConfig, currency, discount, externalPriceId, fixedPriceQuantity, invoicingCycleConfiguration, item, - maxGroupTieredPackageConfig, maximum, maximumAmount, metadata, @@ -47053,15 +48937,16 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "MaxGroupTieredPackage{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maxGroupTieredPackageConfig=$maxGroupTieredPackageConfig, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "CumulativeGroupedBulk{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, cumulativeGroupedBulkConfig=$cumulativeGroupedBulkConfig, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" } - class ScalableMatrixWithUnitPricing + class GroupedWithMinMaxThresholds private constructor( private val id: JsonField, private val billableMetric: JsonField, private val billingCycleConfiguration: JsonField, private val cadence: JsonField, + private val compositePriceFilters: JsonField>, private val conversionRate: JsonField, private val conversionRateConfig: JsonField, private val createdAt: JsonField, @@ -47070,6 +48955,7 @@ private constructor( private val discount: JsonField, private val externalPriceId: JsonField, private val fixedPriceQuantity: JsonField, + private val groupedWithMinMaxThresholdsConfig: JsonField, private val invoicingCycleConfiguration: JsonField, private val item: JsonField, private val maximum: JsonField, @@ -47082,8 +48968,6 @@ private constructor( private val planPhaseOrder: JsonField, private val priceType: JsonField, private val replacesPriceId: JsonField, - private val scalableMatrixWithUnitPricingConfig: - JsonField, private val dimensionalPriceConfiguration: JsonField, private val additionalProperties: MutableMap, ) { @@ -47098,6 +48982,9 @@ private constructor( @ExcludeMissing billingCycleConfiguration: JsonField = JsonMissing.of(), @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), + @JsonProperty("composite_price_filters") + @ExcludeMissing + compositePriceFilters: JsonField> = JsonMissing.of(), @JsonProperty("conversion_rate") @ExcludeMissing conversionRate: JsonField = JsonMissing.of(), @@ -47122,6 +49009,10 @@ private constructor( @JsonProperty("fixed_price_quantity") @ExcludeMissing fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("grouped_with_min_max_thresholds_config") + @ExcludeMissing + groupedWithMinMaxThresholdsConfig: JsonField = + JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), @@ -47148,10 +49039,6 @@ private constructor( @JsonProperty("replaces_price_id") @ExcludeMissing replacesPriceId: JsonField = JsonMissing.of(), - @JsonProperty("scalable_matrix_with_unit_pricing_config") - @ExcludeMissing - scalableMatrixWithUnitPricingConfig: JsonField = - JsonMissing.of(), @JsonProperty("dimensional_price_configuration") @ExcludeMissing dimensionalPriceConfiguration: JsonField = @@ -47161,6 +49048,7 @@ private constructor( billableMetric, billingCycleConfiguration, cadence, + compositePriceFilters, conversionRate, conversionRateConfig, createdAt, @@ -47169,6 +49057,7 @@ private constructor( discount, externalPriceId, fixedPriceQuantity, + groupedWithMinMaxThresholdsConfig, invoicingCycleConfiguration, item, maximum, @@ -47181,7 +49070,6 @@ private constructor( planPhaseOrder, priceType, replacesPriceId, - scalableMatrixWithUnitPricingConfig, dimensionalPriceConfiguration, mutableMapOf(), ) @@ -47211,6 +49099,13 @@ private constructor( */ fun cadence(): Cadence = cadence.getRequired("cadence") + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun compositePriceFilters(): List? = + compositePriceFilters.getNullable("composite_price_filters") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -47260,6 +49155,13 @@ private constructor( */ fun fixedPriceQuantity(): Double? = fixedPriceQuantity.getNullable("fixed_price_quantity") + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun groupedWithMinMaxThresholdsConfig(): GroupedWithMinMaxThresholdsConfig = + groupedWithMinMaxThresholdsConfig.getRequired("grouped_with_min_max_thresholds_config") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -47312,7 +49214,7 @@ private constructor( /** * Expected to always return the following: * ```kotlin - * JsonValue.from("scalable_matrix_with_unit_pricing") + * JsonValue.from("grouped_with_min_max_thresholds") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -47347,15 +49249,6 @@ private constructor( */ fun replacesPriceId(): String? = replacesPriceId.getNullable("replaces_price_id") - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun scalableMatrixWithUnitPricingConfig(): ScalableMatrixWithUnitPricingConfig = - scalableMatrixWithUnitPricingConfig.getRequired( - "scalable_matrix_with_unit_pricing_config" - ) - /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -47398,6 +49291,16 @@ private constructor( */ @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence + /** + * Returns the raw JSON value of [compositePriceFilters]. + * + * Unlike [compositePriceFilters], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("composite_price_filters") + @ExcludeMissing + fun _compositePriceFilters(): JsonField> = compositePriceFilters + /** * Returns the raw JSON value of [conversionRate]. * @@ -47474,6 +49377,17 @@ private constructor( @ExcludeMissing fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + /** + * Returns the raw JSON value of [groupedWithMinMaxThresholdsConfig]. + * + * Unlike [groupedWithMinMaxThresholdsConfig], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("grouped_with_min_max_thresholds_config") + @ExcludeMissing + fun _groupedWithMinMaxThresholdsConfig(): JsonField = + groupedWithMinMaxThresholdsConfig + /** * Returns the raw JSON value of [invoicingCycleConfiguration]. * @@ -47577,17 +49491,6 @@ private constructor( @ExcludeMissing fun _replacesPriceId(): JsonField = replacesPriceId - /** - * Returns the raw JSON value of [scalableMatrixWithUnitPricingConfig]. - * - * Unlike [scalableMatrixWithUnitPricingConfig], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("scalable_matrix_with_unit_pricing_config") - @ExcludeMissing - fun _scalableMatrixWithUnitPricingConfig(): JsonField = - scalableMatrixWithUnitPricingConfig - /** * Returns the raw JSON value of [dimensionalPriceConfiguration]. * @@ -47615,7 +49518,7 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [ScalableMatrixWithUnitPricing]. + * [GroupedWithMinMaxThresholds]. * * The following fields are required: * ```kotlin @@ -47623,6 +49526,7 @@ private constructor( * .billableMetric() * .billingCycleConfiguration() * .cadence() + * .compositePriceFilters() * .conversionRate() * .conversionRateConfig() * .createdAt() @@ -47631,6 +49535,7 @@ private constructor( * .discount() * .externalPriceId() * .fixedPriceQuantity() + * .groupedWithMinMaxThresholdsConfig() * .invoicingCycleConfiguration() * .item() * .maximum() @@ -47642,19 +49547,19 @@ private constructor( * .planPhaseOrder() * .priceType() * .replacesPriceId() - * .scalableMatrixWithUnitPricingConfig() * ``` */ fun builder() = Builder() } - /** A builder for [ScalableMatrixWithUnitPricing]. */ + /** A builder for [GroupedWithMinMaxThresholds]. */ class Builder internal constructor() { private var id: JsonField? = null private var billableMetric: JsonField? = null private var billingCycleConfiguration: JsonField? = null private var cadence: JsonField? = null + private var compositePriceFilters: JsonField>? = null private var conversionRate: JsonField? = null private var conversionRateConfig: JsonField? = null private var createdAt: JsonField? = null @@ -47663,6 +49568,9 @@ private constructor( private var discount: JsonField? = null private var externalPriceId: JsonField? = null private var fixedPriceQuantity: JsonField? = null + private var groupedWithMinMaxThresholdsConfig: + JsonField? = + null private var invoicingCycleConfiguration: JsonField? = null private var item: JsonField? = null private var maximum: JsonField? = null @@ -47670,53 +49578,50 @@ private constructor( private var metadata: JsonField? = null private var minimum: JsonField? = null private var minimumAmount: JsonField? = null - private var modelType: JsonValue = JsonValue.from("scalable_matrix_with_unit_pricing") + private var modelType: JsonValue = JsonValue.from("grouped_with_min_max_thresholds") private var name: JsonField? = null private var planPhaseOrder: JsonField? = null private var priceType: JsonField? = null private var replacesPriceId: JsonField? = null - private var scalableMatrixWithUnitPricingConfig: - JsonField? = - null private var dimensionalPriceConfiguration: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(scalableMatrixWithUnitPricing: ScalableMatrixWithUnitPricing) = - apply { - id = scalableMatrixWithUnitPricing.id - billableMetric = scalableMatrixWithUnitPricing.billableMetric - billingCycleConfiguration = - scalableMatrixWithUnitPricing.billingCycleConfiguration - cadence = scalableMatrixWithUnitPricing.cadence - conversionRate = scalableMatrixWithUnitPricing.conversionRate - conversionRateConfig = scalableMatrixWithUnitPricing.conversionRateConfig - createdAt = scalableMatrixWithUnitPricing.createdAt - creditAllocation = scalableMatrixWithUnitPricing.creditAllocation - currency = scalableMatrixWithUnitPricing.currency - discount = scalableMatrixWithUnitPricing.discount - externalPriceId = scalableMatrixWithUnitPricing.externalPriceId - fixedPriceQuantity = scalableMatrixWithUnitPricing.fixedPriceQuantity - invoicingCycleConfiguration = - scalableMatrixWithUnitPricing.invoicingCycleConfiguration - item = scalableMatrixWithUnitPricing.item - maximum = scalableMatrixWithUnitPricing.maximum - maximumAmount = scalableMatrixWithUnitPricing.maximumAmount - metadata = scalableMatrixWithUnitPricing.metadata - minimum = scalableMatrixWithUnitPricing.minimum - minimumAmount = scalableMatrixWithUnitPricing.minimumAmount - modelType = scalableMatrixWithUnitPricing.modelType - name = scalableMatrixWithUnitPricing.name - planPhaseOrder = scalableMatrixWithUnitPricing.planPhaseOrder - priceType = scalableMatrixWithUnitPricing.priceType - replacesPriceId = scalableMatrixWithUnitPricing.replacesPriceId - scalableMatrixWithUnitPricingConfig = - scalableMatrixWithUnitPricing.scalableMatrixWithUnitPricingConfig - dimensionalPriceConfiguration = - scalableMatrixWithUnitPricing.dimensionalPriceConfiguration - additionalProperties = - scalableMatrixWithUnitPricing.additionalProperties.toMutableMap() - } + internal fun from(groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds) = apply { + id = groupedWithMinMaxThresholds.id + billableMetric = groupedWithMinMaxThresholds.billableMetric + billingCycleConfiguration = groupedWithMinMaxThresholds.billingCycleConfiguration + cadence = groupedWithMinMaxThresholds.cadence + compositePriceFilters = + groupedWithMinMaxThresholds.compositePriceFilters.map { it.toMutableList() } + conversionRate = groupedWithMinMaxThresholds.conversionRate + conversionRateConfig = groupedWithMinMaxThresholds.conversionRateConfig + createdAt = groupedWithMinMaxThresholds.createdAt + creditAllocation = groupedWithMinMaxThresholds.creditAllocation + currency = groupedWithMinMaxThresholds.currency + discount = groupedWithMinMaxThresholds.discount + externalPriceId = groupedWithMinMaxThresholds.externalPriceId + fixedPriceQuantity = groupedWithMinMaxThresholds.fixedPriceQuantity + groupedWithMinMaxThresholdsConfig = + groupedWithMinMaxThresholds.groupedWithMinMaxThresholdsConfig + invoicingCycleConfiguration = + groupedWithMinMaxThresholds.invoicingCycleConfiguration + item = groupedWithMinMaxThresholds.item + maximum = groupedWithMinMaxThresholds.maximum + maximumAmount = groupedWithMinMaxThresholds.maximumAmount + metadata = groupedWithMinMaxThresholds.metadata + minimum = groupedWithMinMaxThresholds.minimum + minimumAmount = groupedWithMinMaxThresholds.minimumAmount + modelType = groupedWithMinMaxThresholds.modelType + name = groupedWithMinMaxThresholds.name + planPhaseOrder = groupedWithMinMaxThresholds.planPhaseOrder + priceType = groupedWithMinMaxThresholds.priceType + replacesPriceId = groupedWithMinMaxThresholds.replacesPriceId + dimensionalPriceConfiguration = + groupedWithMinMaxThresholds.dimensionalPriceConfiguration + additionalProperties = + groupedWithMinMaxThresholds.additionalProperties.toMutableMap() + } fun id(id: String) = id(JsonField.of(id)) @@ -47768,6 +49673,34 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + fun compositePriceFilters(compositePriceFilters: List?) = + compositePriceFilters(JsonField.ofNullable(compositePriceFilters)) + + /** + * Sets [Builder.compositePriceFilters] to an arbitrary JSON value. + * + * You should usually call [Builder.compositePriceFilters] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun compositePriceFilters( + compositePriceFilters: JsonField> + ) = apply { + this.compositePriceFilters = compositePriceFilters.map { it.toMutableList() } + } + + /** + * Adds a single [TransformPriceFilter] to [compositePriceFilters]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addCompositePriceFilter(compositePriceFilter: TransformPriceFilter) = apply { + compositePriceFilters = + (compositePriceFilters ?: JsonField.of(mutableListOf())).also { + checkKnown("compositePriceFilters", it).add(compositePriceFilter) + } + } + fun conversionRate(conversionRate: Double?) = conversionRate(JsonField.ofNullable(conversionRate)) @@ -48009,6 +49942,21 @@ private constructor( this.fixedPriceQuantity = fixedPriceQuantity } + fun groupedWithMinMaxThresholdsConfig( + groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + ) = groupedWithMinMaxThresholdsConfig(JsonField.of(groupedWithMinMaxThresholdsConfig)) + + /** + * Sets [Builder.groupedWithMinMaxThresholdsConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.groupedWithMinMaxThresholdsConfig] with a well-typed + * [GroupedWithMinMaxThresholdsConfig] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun groupedWithMinMaxThresholdsConfig( + groupedWithMinMaxThresholdsConfig: JsonField + ) = apply { this.groupedWithMinMaxThresholdsConfig = groupedWithMinMaxThresholdsConfig } + fun invoicingCycleConfiguration( invoicingCycleConfiguration: BillingCycleConfiguration? ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) @@ -48115,7 +50063,7 @@ private constructor( * It is usually unnecessary to call this method because the field defaults to the * following: * ```kotlin - * JsonValue.from("scalable_matrix_with_unit_pricing") + * JsonValue.from("grouped_with_min_max_thresholds") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -48184,26 +50132,6 @@ private constructor( this.replacesPriceId = replacesPriceId } - fun scalableMatrixWithUnitPricingConfig( - scalableMatrixWithUnitPricingConfig: ScalableMatrixWithUnitPricingConfig - ) = - scalableMatrixWithUnitPricingConfig( - JsonField.of(scalableMatrixWithUnitPricingConfig) - ) - - /** - * Sets [Builder.scalableMatrixWithUnitPricingConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.scalableMatrixWithUnitPricingConfig] with a - * well-typed [ScalableMatrixWithUnitPricingConfig] value instead. This method is - * primarily for setting the field to an undocumented or not yet supported value. - */ - fun scalableMatrixWithUnitPricingConfig( - scalableMatrixWithUnitPricingConfig: JsonField - ) = apply { - this.scalableMatrixWithUnitPricingConfig = scalableMatrixWithUnitPricingConfig - } - fun dimensionalPriceConfiguration( dimensionalPriceConfiguration: DimensionalPriceConfiguration? ) = dimensionalPriceConfiguration(JsonField.ofNullable(dimensionalPriceConfiguration)) @@ -48239,7 +50167,7 @@ private constructor( } /** - * Returns an immutable instance of [ScalableMatrixWithUnitPricing]. + * Returns an immutable instance of [GroupedWithMinMaxThresholds]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -48249,6 +50177,7 @@ private constructor( * .billableMetric() * .billingCycleConfiguration() * .cadence() + * .compositePriceFilters() * .conversionRate() * .conversionRateConfig() * .createdAt() @@ -48257,6 +50186,7 @@ private constructor( * .discount() * .externalPriceId() * .fixedPriceQuantity() + * .groupedWithMinMaxThresholdsConfig() * .invoicingCycleConfiguration() * .item() * .maximum() @@ -48268,17 +50198,19 @@ private constructor( * .planPhaseOrder() * .priceType() * .replacesPriceId() - * .scalableMatrixWithUnitPricingConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): ScalableMatrixWithUnitPricing = - ScalableMatrixWithUnitPricing( + fun build(): GroupedWithMinMaxThresholds = + GroupedWithMinMaxThresholds( checkRequired("id", id), checkRequired("billableMetric", billableMetric), checkRequired("billingCycleConfiguration", billingCycleConfiguration), checkRequired("cadence", cadence), + checkRequired("compositePriceFilters", compositePriceFilters).map { + it.toImmutable() + }, checkRequired("conversionRate", conversionRate), checkRequired("conversionRateConfig", conversionRateConfig), checkRequired("createdAt", createdAt), @@ -48287,6 +50219,10 @@ private constructor( checkRequired("discount", discount), checkRequired("externalPriceId", externalPriceId), checkRequired("fixedPriceQuantity", fixedPriceQuantity), + checkRequired( + "groupedWithMinMaxThresholdsConfig", + groupedWithMinMaxThresholdsConfig, + ), checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), checkRequired("item", item), checkRequired("maximum", maximum), @@ -48299,10 +50235,6 @@ private constructor( checkRequired("planPhaseOrder", planPhaseOrder), checkRequired("priceType", priceType), checkRequired("replacesPriceId", replacesPriceId), - checkRequired( - "scalableMatrixWithUnitPricingConfig", - scalableMatrixWithUnitPricingConfig, - ), dimensionalPriceConfiguration, additionalProperties.toMutableMap(), ) @@ -48310,7 +50242,7 @@ private constructor( private var validated: Boolean = false - fun validate(): ScalableMatrixWithUnitPricing = apply { + fun validate(): GroupedWithMinMaxThresholds = apply { if (validated) { return@apply } @@ -48319,6 +50251,7 @@ private constructor( billableMetric()?.validate() billingCycleConfiguration().validate() cadence().validate() + compositePriceFilters()?.forEach { it.validate() } conversionRate() conversionRateConfig()?.validate() createdAt() @@ -48327,6 +50260,7 @@ private constructor( discount()?.validate() externalPriceId() fixedPriceQuantity() + groupedWithMinMaxThresholdsConfig().validate() invoicingCycleConfiguration()?.validate() item().validate() maximum()?.validate() @@ -48335,7 +50269,7 @@ private constructor( minimum()?.validate() minimumAmount() _modelType().let { - if (it != JsonValue.from("scalable_matrix_with_unit_pricing")) { + if (it != JsonValue.from("grouped_with_min_max_thresholds")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } @@ -48343,7 +50277,6 @@ private constructor( planPhaseOrder() priceType().validate() replacesPriceId() - scalableMatrixWithUnitPricingConfig().validate() dimensionalPriceConfiguration()?.validate() validated = true } @@ -48367,6 +50300,7 @@ private constructor( (billableMetric.asKnown()?.validity() ?: 0) + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + (cadence.asKnown()?.validity() ?: 0) + + (compositePriceFilters.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + (if (conversionRate.asKnown() == null) 0 else 1) + (conversionRateConfig.asKnown()?.validity() ?: 0) + (if (createdAt.asKnown() == null) 0 else 1) + @@ -48375,6 +50309,7 @@ private constructor( (discount.asKnown()?.validity() ?: 0) + (if (externalPriceId.asKnown() == null) 0 else 1) + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (groupedWithMinMaxThresholdsConfig.asKnown()?.validity() ?: 0) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + (item.asKnown()?.validity() ?: 0) + (maximum.asKnown()?.validity() ?: 0) + @@ -48383,13 +50318,12 @@ private constructor( (minimum.asKnown()?.validity() ?: 0) + (if (minimumAmount.asKnown() == null) 0 else 1) + modelType.let { - if (it == JsonValue.from("scalable_matrix_with_unit_pricing")) 1 else 0 + if (it == JsonValue.from("grouped_with_min_max_thresholds")) 1 else 0 } + (if (name.asKnown() == null) 0 else 1) + (if (planPhaseOrder.asKnown() == null) 0 else 1) + (priceType.asKnown()?.validity() ?: 0) + (if (replacesPriceId.asKnown() == null) 0 else 1) + - (scalableMatrixWithUnitPricingConfig.asKnown()?.validity() ?: 0) + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) class Cadence @JsonCreator private constructor(private val value: JsonField) : @@ -48544,241 +50478,7 @@ private constructor( override fun toString() = value.toString() } - /** - * User specified key-value pairs for the resource. If not present, this defaults to an - * empty dictionary. Individual keys can be removed by setting the value to `null`, and the - * entire metadata mapping can be cleared by setting `metadata` to `null`. - */ - class Metadata - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Metadata]. */ - fun builder() = Builder() - } - - /** A builder for [Metadata]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(metadata: Metadata) = apply { - additionalProperties = metadata.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Metadata]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Metadata && additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - class PriceType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - val USAGE_PRICE = of("usage_price") - - val FIXED_PRICE = of("fixed_price") - - fun of(value: String) = PriceType(JsonField.of(value)) - } - - /** An enum containing [PriceType]'s known values. */ - enum class Known { - USAGE_PRICE, - FIXED_PRICE, - } - - /** - * An enum containing [PriceType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [PriceType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - USAGE_PRICE, - FIXED_PRICE, - /** - * An enum member indicating that [PriceType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - USAGE_PRICE -> Value.USAGE_PRICE - FIXED_PRICE -> Value.FIXED_PRICE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - USAGE_PRICE -> Known.USAGE_PRICE - FIXED_PRICE -> Known.FIXED_PRICE - else -> throw OrbInvalidDataException("Unknown PriceType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString() ?: throw OrbInvalidDataException("Value is not a String") - - private var validated: Boolean = false - - fun validate(): PriceType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is PriceType && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class ScalableMatrixWithUnitPricingConfig + class GroupedWithMinMaxThresholdsConfig @JsonCreator private constructor( @com.fasterxml.jackson.annotation.JsonValue @@ -48795,21 +50495,21 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [ScalableMatrixWithUnitPricingConfig]. + * [GroupedWithMinMaxThresholdsConfig]. */ fun builder() = Builder() } - /** A builder for [ScalableMatrixWithUnitPricingConfig]. */ + /** A builder for [GroupedWithMinMaxThresholdsConfig]. */ class Builder internal constructor() { private var additionalProperties: MutableMap = mutableMapOf() internal fun from( - scalableMatrixWithUnitPricingConfig: ScalableMatrixWithUnitPricingConfig + groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig ) = apply { additionalProperties = - scalableMatrixWithUnitPricingConfig.additionalProperties.toMutableMap() + groupedWithMinMaxThresholdsConfig.additionalProperties.toMutableMap() } fun additionalProperties(additionalProperties: Map) = apply { @@ -48835,3570 +50535,17 @@ private constructor( } /** - * Returns an immutable instance of [ScalableMatrixWithUnitPricingConfig]. + * Returns an immutable instance of [GroupedWithMinMaxThresholdsConfig]. * * Further updates to this [Builder] will not mutate the returned instance. */ - fun build(): ScalableMatrixWithUnitPricingConfig = - ScalableMatrixWithUnitPricingConfig(additionalProperties.toImmutable()) + fun build(): GroupedWithMinMaxThresholdsConfig = + GroupedWithMinMaxThresholdsConfig(additionalProperties.toImmutable()) } private var validated: Boolean = false - fun validate(): ScalableMatrixWithUnitPricingConfig = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ScalableMatrixWithUnitPricingConfig && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "ScalableMatrixWithUnitPricingConfig{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ScalableMatrixWithUnitPricing && - id == other.id && - billableMetric == other.billableMetric && - billingCycleConfiguration == other.billingCycleConfiguration && - cadence == other.cadence && - conversionRate == other.conversionRate && - conversionRateConfig == other.conversionRateConfig && - createdAt == other.createdAt && - creditAllocation == other.creditAllocation && - currency == other.currency && - discount == other.discount && - externalPriceId == other.externalPriceId && - fixedPriceQuantity == other.fixedPriceQuantity && - invoicingCycleConfiguration == other.invoicingCycleConfiguration && - item == other.item && - maximum == other.maximum && - maximumAmount == other.maximumAmount && - metadata == other.metadata && - minimum == other.minimum && - minimumAmount == other.minimumAmount && - modelType == other.modelType && - name == other.name && - planPhaseOrder == other.planPhaseOrder && - priceType == other.priceType && - replacesPriceId == other.replacesPriceId && - scalableMatrixWithUnitPricingConfig == other.scalableMatrixWithUnitPricingConfig && - dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - id, - billableMetric, - billingCycleConfiguration, - cadence, - conversionRate, - conversionRateConfig, - createdAt, - creditAllocation, - currency, - discount, - externalPriceId, - fixedPriceQuantity, - invoicingCycleConfiguration, - item, - maximum, - maximumAmount, - metadata, - minimum, - minimumAmount, - modelType, - name, - planPhaseOrder, - priceType, - replacesPriceId, - scalableMatrixWithUnitPricingConfig, - dimensionalPriceConfiguration, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "ScalableMatrixWithUnitPricing{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, scalableMatrixWithUnitPricingConfig=$scalableMatrixWithUnitPricingConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" - } - - class ScalableMatrixWithTieredPricing - private constructor( - private val id: JsonField, - private val billableMetric: JsonField, - private val billingCycleConfiguration: JsonField, - private val cadence: JsonField, - private val conversionRate: JsonField, - private val conversionRateConfig: JsonField, - private val createdAt: JsonField, - private val creditAllocation: JsonField, - private val currency: JsonField, - private val discount: JsonField, - private val externalPriceId: JsonField, - private val fixedPriceQuantity: JsonField, - private val invoicingCycleConfiguration: JsonField, - private val item: JsonField, - private val maximum: JsonField, - private val maximumAmount: JsonField, - private val metadata: JsonField, - private val minimum: JsonField, - private val minimumAmount: JsonField, - private val modelType: JsonValue, - private val name: JsonField, - private val planPhaseOrder: JsonField, - private val priceType: JsonField, - private val replacesPriceId: JsonField, - private val scalableMatrixWithTieredPricingConfig: - JsonField, - private val dimensionalPriceConfiguration: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), - @JsonProperty("billable_metric") - @ExcludeMissing - billableMetric: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - billingCycleConfiguration: JsonField = JsonMissing.of(), - @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("conversion_rate_config") - @ExcludeMissing - conversionRateConfig: JsonField = JsonMissing.of(), - @JsonProperty("created_at") - @ExcludeMissing - createdAt: JsonField = JsonMissing.of(), - @JsonProperty("credit_allocation") - @ExcludeMissing - creditAllocation: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - currency: JsonField = JsonMissing.of(), - @JsonProperty("discount") - @ExcludeMissing - discount: JsonField = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - invoicingCycleConfiguration: JsonField = JsonMissing.of(), - @JsonProperty("item") @ExcludeMissing item: JsonField = JsonMissing.of(), - @JsonProperty("maximum") @ExcludeMissing maximum: JsonField = JsonMissing.of(), - @JsonProperty("maximum_amount") - @ExcludeMissing - maximumAmount: JsonField = JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - metadata: JsonField = JsonMissing.of(), - @JsonProperty("minimum") @ExcludeMissing minimum: JsonField = JsonMissing.of(), - @JsonProperty("minimum_amount") - @ExcludeMissing - minimumAmount: JsonField = JsonMissing.of(), - @JsonProperty("model_type") @ExcludeMissing modelType: JsonValue = JsonMissing.of(), - @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("plan_phase_order") - @ExcludeMissing - planPhaseOrder: JsonField = JsonMissing.of(), - @JsonProperty("price_type") - @ExcludeMissing - priceType: JsonField = JsonMissing.of(), - @JsonProperty("replaces_price_id") - @ExcludeMissing - replacesPriceId: JsonField = JsonMissing.of(), - @JsonProperty("scalable_matrix_with_tiered_pricing_config") - @ExcludeMissing - scalableMatrixWithTieredPricingConfig: - JsonField = - JsonMissing.of(), - @JsonProperty("dimensional_price_configuration") - @ExcludeMissing - dimensionalPriceConfiguration: JsonField = - JsonMissing.of(), - ) : this( - id, - billableMetric, - billingCycleConfiguration, - cadence, - conversionRate, - conversionRateConfig, - createdAt, - creditAllocation, - currency, - discount, - externalPriceId, - fixedPriceQuantity, - invoicingCycleConfiguration, - item, - maximum, - maximumAmount, - metadata, - minimum, - minimumAmount, - modelType, - name, - planPhaseOrder, - priceType, - replacesPriceId, - scalableMatrixWithTieredPricingConfig, - dimensionalPriceConfiguration, - mutableMapOf(), - ) - - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun id(): String = id.getRequired("id") - - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun billableMetric(): BillableMetricTiny? = billableMetric.getNullable("billable_metric") - - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun billingCycleConfiguration(): BillingCycleConfiguration = - billingCycleConfiguration.getRequired("billing_cycle_configuration") - - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") - - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun conversionRateConfig(): ConversionRateConfig? = - conversionRateConfig.getNullable("conversion_rate_config") - - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") - - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun creditAllocation(): Allocation? = creditAllocation.getNullable("credit_allocation") - - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun currency(): String = currency.getRequired("currency") - - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - @Deprecated("deprecated") fun discount(): Discount? = discount.getNullable("discount") - - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") - - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun fixedPriceQuantity(): Double? = fixedPriceQuantity.getNullable("fixed_price_quantity") - - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun invoicingCycleConfiguration(): BillingCycleConfiguration? = - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun item(): ItemSlim = item.getRequired("item") - - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - @Deprecated("deprecated") fun maximum(): Maximum? = maximum.getNullable("maximum") - - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - @Deprecated("deprecated") - fun maximumAmount(): String? = maximumAmount.getNullable("maximum_amount") - - /** - * User specified key-value pairs for the resource. If not present, this defaults to an - * empty dictionary. Individual keys can be removed by setting the value to `null`, and the - * entire metadata mapping can be cleared by setting `metadata` to `null`. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun metadata(): Metadata = metadata.getRequired("metadata") - - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - @Deprecated("deprecated") fun minimum(): Minimum? = minimum.getNullable("minimum") - - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - @Deprecated("deprecated") - fun minimumAmount(): String? = minimumAmount.getNullable("minimum_amount") - - /** - * Expected to always return the following: - * ```kotlin - * JsonValue.from("scalable_matrix_with_tiered_pricing") - * ``` - * - * However, this method can be useful for debugging and logging (e.g. if the server - * responded with an unexpected value). - */ - @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType - - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun name(): String = name.getRequired("name") - - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun planPhaseOrder(): Long? = planPhaseOrder.getNullable("plan_phase_order") - - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun priceType(): PriceType = priceType.getRequired("price_type") - - /** - * The price id this price replaces. This price will take the place of the replaced price in - * plan version migrations. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun replacesPriceId(): String? = replacesPriceId.getNullable("replaces_price_id") - - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun scalableMatrixWithTieredPricingConfig(): ScalableMatrixWithTieredPricingConfig = - scalableMatrixWithTieredPricingConfig.getRequired( - "scalable_matrix_with_tiered_pricing_config" - ) - - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun dimensionalPriceConfiguration(): DimensionalPriceConfiguration? = - dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") - - /** - * Returns the raw JSON value of [id]. - * - * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - /** - * Returns the raw JSON value of [billableMetric]. - * - * Unlike [billableMetric], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("billable_metric") - @ExcludeMissing - fun _billableMetric(): JsonField = billableMetric - - /** - * Returns the raw JSON value of [billingCycleConfiguration]. - * - * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** - * Returns the raw JSON value of [cadence]. - * - * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence - - /** - * Returns the raw JSON value of [conversionRate]. - * - * Unlike [conversionRate], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** - * Returns the raw JSON value of [conversionRateConfig]. - * - * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("conversion_rate_config") - @ExcludeMissing - fun _conversionRateConfig(): JsonField = conversionRateConfig - - /** - * Returns the raw JSON value of [createdAt]. - * - * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("created_at") - @ExcludeMissing - fun _createdAt(): JsonField = createdAt - - /** - * Returns the raw JSON value of [creditAllocation]. - * - * Unlike [creditAllocation], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("credit_allocation") - @ExcludeMissing - fun _creditAllocation(): JsonField = creditAllocation - - /** - * Returns the raw JSON value of [currency]. - * - * Unlike [currency], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - - /** - * Returns the raw JSON value of [discount]. - * - * Unlike [discount], this method doesn't throw if the JSON field has an unexpected type. - */ - @Deprecated("deprecated") - @JsonProperty("discount") - @ExcludeMissing - fun _discount(): JsonField = discount - - /** - * Returns the raw JSON value of [externalPriceId]. - * - * Unlike [externalPriceId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * Returns the raw JSON value of [fixedPriceQuantity]. - * - * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** - * Returns the raw JSON value of [invoicingCycleConfiguration]. - * - * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * Returns the raw JSON value of [item]. - * - * Unlike [item], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("item") @ExcludeMissing fun _item(): JsonField = item - - /** - * Returns the raw JSON value of [maximum]. - * - * Unlike [maximum], this method doesn't throw if the JSON field has an unexpected type. - */ - @Deprecated("deprecated") - @JsonProperty("maximum") - @ExcludeMissing - fun _maximum(): JsonField = maximum - - /** - * Returns the raw JSON value of [maximumAmount]. - * - * Unlike [maximumAmount], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @Deprecated("deprecated") - @JsonProperty("maximum_amount") - @ExcludeMissing - fun _maximumAmount(): JsonField = maximumAmount - - /** - * Returns the raw JSON value of [metadata]. - * - * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata - - /** - * Returns the raw JSON value of [minimum]. - * - * Unlike [minimum], this method doesn't throw if the JSON field has an unexpected type. - */ - @Deprecated("deprecated") - @JsonProperty("minimum") - @ExcludeMissing - fun _minimum(): JsonField = minimum - - /** - * Returns the raw JSON value of [minimumAmount]. - * - * Unlike [minimumAmount], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @Deprecated("deprecated") - @JsonProperty("minimum_amount") - @ExcludeMissing - fun _minimumAmount(): JsonField = minimumAmount - - /** - * Returns the raw JSON value of [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - /** - * Returns the raw JSON value of [planPhaseOrder]. - * - * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("plan_phase_order") - @ExcludeMissing - fun _planPhaseOrder(): JsonField = planPhaseOrder - - /** - * Returns the raw JSON value of [priceType]. - * - * Unlike [priceType], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("price_type") - @ExcludeMissing - fun _priceType(): JsonField = priceType - - /** - * Returns the raw JSON value of [replacesPriceId]. - * - * Unlike [replacesPriceId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("replaces_price_id") - @ExcludeMissing - fun _replacesPriceId(): JsonField = replacesPriceId - - /** - * Returns the raw JSON value of [scalableMatrixWithTieredPricingConfig]. - * - * Unlike [scalableMatrixWithTieredPricingConfig], this method doesn't throw if the JSON - * field has an unexpected type. - */ - @JsonProperty("scalable_matrix_with_tiered_pricing_config") - @ExcludeMissing - fun _scalableMatrixWithTieredPricingConfig(): - JsonField = scalableMatrixWithTieredPricingConfig - - /** - * Returns the raw JSON value of [dimensionalPriceConfiguration]. - * - * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("dimensional_price_configuration") - @ExcludeMissing - fun _dimensionalPriceConfiguration(): JsonField = - dimensionalPriceConfiguration - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [ScalableMatrixWithTieredPricing]. - * - * The following fields are required: - * ```kotlin - * .id() - * .billableMetric() - * .billingCycleConfiguration() - * .cadence() - * .conversionRate() - * .conversionRateConfig() - * .createdAt() - * .creditAllocation() - * .currency() - * .discount() - * .externalPriceId() - * .fixedPriceQuantity() - * .invoicingCycleConfiguration() - * .item() - * .maximum() - * .maximumAmount() - * .metadata() - * .minimum() - * .minimumAmount() - * .name() - * .planPhaseOrder() - * .priceType() - * .replacesPriceId() - * .scalableMatrixWithTieredPricingConfig() - * ``` - */ - fun builder() = Builder() - } - - /** A builder for [ScalableMatrixWithTieredPricing]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var billableMetric: JsonField? = null - private var billingCycleConfiguration: JsonField? = null - private var cadence: JsonField? = null - private var conversionRate: JsonField? = null - private var conversionRateConfig: JsonField? = null - private var createdAt: JsonField? = null - private var creditAllocation: JsonField? = null - private var currency: JsonField? = null - private var discount: JsonField? = null - private var externalPriceId: JsonField? = null - private var fixedPriceQuantity: JsonField? = null - private var invoicingCycleConfiguration: JsonField? = null - private var item: JsonField? = null - private var maximum: JsonField? = null - private var maximumAmount: JsonField? = null - private var metadata: JsonField? = null - private var minimum: JsonField? = null - private var minimumAmount: JsonField? = null - private var modelType: JsonValue = JsonValue.from("scalable_matrix_with_tiered_pricing") - private var name: JsonField? = null - private var planPhaseOrder: JsonField? = null - private var priceType: JsonField? = null - private var replacesPriceId: JsonField? = null - private var scalableMatrixWithTieredPricingConfig: - JsonField? = - null - private var dimensionalPriceConfiguration: JsonField = - JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(scalableMatrixWithTieredPricing: ScalableMatrixWithTieredPricing) = - apply { - id = scalableMatrixWithTieredPricing.id - billableMetric = scalableMatrixWithTieredPricing.billableMetric - billingCycleConfiguration = - scalableMatrixWithTieredPricing.billingCycleConfiguration - cadence = scalableMatrixWithTieredPricing.cadence - conversionRate = scalableMatrixWithTieredPricing.conversionRate - conversionRateConfig = scalableMatrixWithTieredPricing.conversionRateConfig - createdAt = scalableMatrixWithTieredPricing.createdAt - creditAllocation = scalableMatrixWithTieredPricing.creditAllocation - currency = scalableMatrixWithTieredPricing.currency - discount = scalableMatrixWithTieredPricing.discount - externalPriceId = scalableMatrixWithTieredPricing.externalPriceId - fixedPriceQuantity = scalableMatrixWithTieredPricing.fixedPriceQuantity - invoicingCycleConfiguration = - scalableMatrixWithTieredPricing.invoicingCycleConfiguration - item = scalableMatrixWithTieredPricing.item - maximum = scalableMatrixWithTieredPricing.maximum - maximumAmount = scalableMatrixWithTieredPricing.maximumAmount - metadata = scalableMatrixWithTieredPricing.metadata - minimum = scalableMatrixWithTieredPricing.minimum - minimumAmount = scalableMatrixWithTieredPricing.minimumAmount - modelType = scalableMatrixWithTieredPricing.modelType - name = scalableMatrixWithTieredPricing.name - planPhaseOrder = scalableMatrixWithTieredPricing.planPhaseOrder - priceType = scalableMatrixWithTieredPricing.priceType - replacesPriceId = scalableMatrixWithTieredPricing.replacesPriceId - scalableMatrixWithTieredPricingConfig = - scalableMatrixWithTieredPricing.scalableMatrixWithTieredPricingConfig - dimensionalPriceConfiguration = - scalableMatrixWithTieredPricing.dimensionalPriceConfiguration - additionalProperties = - scalableMatrixWithTieredPricing.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - /** - * Sets [Builder.id] to an arbitrary JSON value. - * - * You should usually call [Builder.id] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun id(id: JsonField) = apply { this.id = id } - - fun billableMetric(billableMetric: BillableMetricTiny?) = - billableMetric(JsonField.ofNullable(billableMetric)) - - /** - * Sets [Builder.billableMetric] to an arbitrary JSON value. - * - * You should usually call [Builder.billableMetric] with a well-typed - * [BillableMetricTiny] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun billableMetric(billableMetric: JsonField) = apply { - this.billableMetric = billableMetric - } - - fun billingCycleConfiguration(billingCycleConfiguration: BillingCycleConfiguration) = - billingCycleConfiguration(JsonField.of(billingCycleConfiguration)) - - /** - * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.billingCycleConfiguration] with a well-typed - * [BillingCycleConfiguration] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: JsonField - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } - - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** - * Sets [Builder.cadence] to an arbitrary JSON value. - * - * You should usually call [Builder.cadence] with a well-typed [Cadence] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - - fun conversionRate(conversionRate: Double?) = - conversionRate(JsonField.ofNullable(conversionRate)) - - /** - * Alias for [Builder.conversionRate]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) - - /** - * Sets [Builder.conversionRate] to an arbitrary JSON value. - * - * You should usually call [Builder.conversionRate] with a well-typed [Double] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = - conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) - - /** - * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.conversionRateConfig] with a well-typed - * [ConversionRateConfig] value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. - */ - fun conversionRateConfig(conversionRateConfig: JsonField) = - apply { - this.conversionRateConfig = conversionRateConfig - } - - /** - * Alias for calling [conversionRateConfig] with `ConversionRateConfig.ofUnit(unit)`. - */ - fun conversionRateConfig(unit: UnitConversionRateConfig) = - conversionRateConfig(ConversionRateConfig.ofUnit(unit)) - - /** - * Alias for calling [conversionRateConfig] with the following: - * ```kotlin - * UnitConversionRateConfig.builder() - * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) - * .unitConfig(unitConfig) - * .build() - * ``` - */ - fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = - conversionRateConfig( - UnitConversionRateConfig.builder() - .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) - .unitConfig(unitConfig) - .build() - ) - - /** - * Alias for calling [conversionRateConfig] with - * `ConversionRateConfig.ofTiered(tiered)`. - */ - fun conversionRateConfig(tiered: TieredConversionRateConfig) = - conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) - - /** - * Alias for calling [conversionRateConfig] with the following: - * ```kotlin - * TieredConversionRateConfig.builder() - * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) - * .tieredConfig(tieredConfig) - * .build() - * ``` - */ - fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = - conversionRateConfig( - TieredConversionRateConfig.builder() - .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) - .tieredConfig(tieredConfig) - .build() - ) - - fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) - - /** - * Sets [Builder.createdAt] to an arbitrary JSON value. - * - * You should usually call [Builder.createdAt] with a well-typed [OffsetDateTime] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun createdAt(createdAt: JsonField) = apply { - this.createdAt = createdAt - } - - fun creditAllocation(creditAllocation: Allocation?) = - creditAllocation(JsonField.ofNullable(creditAllocation)) - - /** - * Sets [Builder.creditAllocation] to an arbitrary JSON value. - * - * You should usually call [Builder.creditAllocation] with a well-typed [Allocation] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun creditAllocation(creditAllocation: JsonField) = apply { - this.creditAllocation = creditAllocation - } - - fun currency(currency: String) = currency(JsonField.of(currency)) - - /** - * Sets [Builder.currency] to an arbitrary JSON value. - * - * You should usually call [Builder.currency] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } - - @Deprecated("deprecated") - fun discount(discount: Discount?) = discount(JsonField.ofNullable(discount)) - - /** - * Sets [Builder.discount] to an arbitrary JSON value. - * - * You should usually call [Builder.discount] with a well-typed [Discount] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - @Deprecated("deprecated") - fun discount(discount: JsonField) = apply { this.discount = discount } - - /** Alias for calling [discount] with `Discount.ofPercentage(percentage)`. */ - @Deprecated("deprecated") - fun discount(percentage: PercentageDiscount) = - discount(Discount.ofPercentage(percentage)) - - /** - * Alias for calling [discount] with the following: - * ```kotlin - * PercentageDiscount.builder() - * .discountType(PercentageDiscount.DiscountType.PERCENTAGE) - * .percentageDiscount(percentageDiscount) - * .build() - * ``` - */ - @Deprecated("deprecated") - fun percentageDiscount(percentageDiscount: Double) = - discount( - PercentageDiscount.builder() - .discountType(PercentageDiscount.DiscountType.PERCENTAGE) - .percentageDiscount(percentageDiscount) - .build() - ) - - /** Alias for calling [discount] with `Discount.ofTrial(trial)`. */ - @Deprecated("deprecated") - fun discount(trial: TrialDiscount) = discount(Discount.ofTrial(trial)) - - /** Alias for calling [discount] with `Discount.ofUsage(usage)`. */ - @Deprecated("deprecated") - fun discount(usage: UsageDiscount) = discount(Discount.ofUsage(usage)) - - /** - * Alias for calling [discount] with the following: - * ```kotlin - * UsageDiscount.builder() - * .discountType(UsageDiscount.DiscountType.USAGE) - * .usageDiscount(usageDiscount) - * .build() - * ``` - */ - @Deprecated("deprecated") - fun usageDiscount(usageDiscount: Double) = - discount( - UsageDiscount.builder() - .discountType(UsageDiscount.DiscountType.USAGE) - .usageDiscount(usageDiscount) - .build() - ) - - /** Alias for calling [discount] with `Discount.ofAmount(amount)`. */ - @Deprecated("deprecated") - fun discount(amount: AmountDiscount) = discount(Discount.ofAmount(amount)) - - /** - * Alias for calling [discount] with the following: - * ```kotlin - * AmountDiscount.builder() - * .discountType(AmountDiscount.DiscountType.AMOUNT) - * .amountDiscount(amountDiscount) - * .build() - * ``` - */ - @Deprecated("deprecated") - fun amountDiscount(amountDiscount: String) = - discount( - AmountDiscount.builder() - .discountType(AmountDiscount.DiscountType.AMOUNT) - .amountDiscount(amountDiscount) - .build() - ) - - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** - * Sets [Builder.externalPriceId] to an arbitrary JSON value. - * - * You should usually call [Builder.externalPriceId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun externalPriceId(externalPriceId: JsonField) = apply { - this.externalPriceId = externalPriceId - } - - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = - fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) - - /** - * Alias for [Builder.fixedPriceQuantity]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. - * - * You should usually call [Builder.fixedPriceQuantity] with a well-typed [Double] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } - - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: BillingCycleConfiguration? - ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) - - /** - * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.invoicingCycleConfiguration] with a well-typed - * [BillingCycleConfiguration] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - fun item(item: ItemSlim) = item(JsonField.of(item)) - - /** - * Sets [Builder.item] to an arbitrary JSON value. - * - * You should usually call [Builder.item] with a well-typed [ItemSlim] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun item(item: JsonField) = apply { this.item = item } - - @Deprecated("deprecated") - fun maximum(maximum: Maximum?) = maximum(JsonField.ofNullable(maximum)) - - /** - * Sets [Builder.maximum] to an arbitrary JSON value. - * - * You should usually call [Builder.maximum] with a well-typed [Maximum] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - @Deprecated("deprecated") - fun maximum(maximum: JsonField) = apply { this.maximum = maximum } - - @Deprecated("deprecated") - fun maximumAmount(maximumAmount: String?) = - maximumAmount(JsonField.ofNullable(maximumAmount)) - - /** - * Sets [Builder.maximumAmount] to an arbitrary JSON value. - * - * You should usually call [Builder.maximumAmount] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - @Deprecated("deprecated") - fun maximumAmount(maximumAmount: JsonField) = apply { - this.maximumAmount = maximumAmount - } - - /** - * User specified key-value pairs for the resource. If not present, this defaults to an - * empty dictionary. Individual keys can be removed by setting the value to `null`, and - * the entire metadata mapping can be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) - - /** - * Sets [Builder.metadata] to an arbitrary JSON value. - * - * You should usually call [Builder.metadata] with a well-typed [Metadata] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - - @Deprecated("deprecated") - fun minimum(minimum: Minimum?) = minimum(JsonField.ofNullable(minimum)) - - /** - * Sets [Builder.minimum] to an arbitrary JSON value. - * - * You should usually call [Builder.minimum] with a well-typed [Minimum] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - @Deprecated("deprecated") - fun minimum(minimum: JsonField) = apply { this.minimum = minimum } - - @Deprecated("deprecated") - fun minimumAmount(minimumAmount: String?) = - minimumAmount(JsonField.ofNullable(minimumAmount)) - - /** - * Sets [Builder.minimumAmount] to an arbitrary JSON value. - * - * You should usually call [Builder.minimumAmount] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - @Deprecated("deprecated") - fun minimumAmount(minimumAmount: JsonField) = apply { - this.minimumAmount = minimumAmount - } - - /** - * Sets the field to an arbitrary JSON value. - * - * It is usually unnecessary to call this method because the field defaults to the - * following: - * ```kotlin - * JsonValue.from("scalable_matrix_with_tiered_pricing") - * ``` - * - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } - - fun name(name: String) = name(JsonField.of(name)) - - /** - * Sets [Builder.name] to an arbitrary JSON value. - * - * You should usually call [Builder.name] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun name(name: JsonField) = apply { this.name = name } - - fun planPhaseOrder(planPhaseOrder: Long?) = - planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) - - /** - * Alias for [Builder.planPhaseOrder]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) - - /** - * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. - * - * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun planPhaseOrder(planPhaseOrder: JsonField) = apply { - this.planPhaseOrder = planPhaseOrder - } - - fun priceType(priceType: PriceType) = priceType(JsonField.of(priceType)) - - /** - * Sets [Builder.priceType] to an arbitrary JSON value. - * - * You should usually call [Builder.priceType] with a well-typed [PriceType] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun priceType(priceType: JsonField) = apply { this.priceType = priceType } - - /** - * The price id this price replaces. This price will take the place of the replaced - * price in plan version migrations. - */ - fun replacesPriceId(replacesPriceId: String?) = - replacesPriceId(JsonField.ofNullable(replacesPriceId)) - - /** - * Sets [Builder.replacesPriceId] to an arbitrary JSON value. - * - * You should usually call [Builder.replacesPriceId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun replacesPriceId(replacesPriceId: JsonField) = apply { - this.replacesPriceId = replacesPriceId - } - - fun scalableMatrixWithTieredPricingConfig( - scalableMatrixWithTieredPricingConfig: ScalableMatrixWithTieredPricingConfig - ) = - scalableMatrixWithTieredPricingConfig( - JsonField.of(scalableMatrixWithTieredPricingConfig) - ) - - /** - * Sets [Builder.scalableMatrixWithTieredPricingConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.scalableMatrixWithTieredPricingConfig] with a - * well-typed [ScalableMatrixWithTieredPricingConfig] value instead. This method is - * primarily for setting the field to an undocumented or not yet supported value. - */ - fun scalableMatrixWithTieredPricingConfig( - scalableMatrixWithTieredPricingConfig: - JsonField - ) = apply { - this.scalableMatrixWithTieredPricingConfig = scalableMatrixWithTieredPricingConfig - } - - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: DimensionalPriceConfiguration? - ) = dimensionalPriceConfiguration(JsonField.ofNullable(dimensionalPriceConfiguration)) - - /** - * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.dimensionalPriceConfiguration] with a well-typed - * [DimensionalPriceConfiguration] value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: JsonField - ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [ScalableMatrixWithTieredPricing]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```kotlin - * .id() - * .billableMetric() - * .billingCycleConfiguration() - * .cadence() - * .conversionRate() - * .conversionRateConfig() - * .createdAt() - * .creditAllocation() - * .currency() - * .discount() - * .externalPriceId() - * .fixedPriceQuantity() - * .invoicingCycleConfiguration() - * .item() - * .maximum() - * .maximumAmount() - * .metadata() - * .minimum() - * .minimumAmount() - * .name() - * .planPhaseOrder() - * .priceType() - * .replacesPriceId() - * .scalableMatrixWithTieredPricingConfig() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): ScalableMatrixWithTieredPricing = - ScalableMatrixWithTieredPricing( - checkRequired("id", id), - checkRequired("billableMetric", billableMetric), - checkRequired("billingCycleConfiguration", billingCycleConfiguration), - checkRequired("cadence", cadence), - checkRequired("conversionRate", conversionRate), - checkRequired("conversionRateConfig", conversionRateConfig), - checkRequired("createdAt", createdAt), - checkRequired("creditAllocation", creditAllocation), - checkRequired("currency", currency), - checkRequired("discount", discount), - checkRequired("externalPriceId", externalPriceId), - checkRequired("fixedPriceQuantity", fixedPriceQuantity), - checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), - checkRequired("item", item), - checkRequired("maximum", maximum), - checkRequired("maximumAmount", maximumAmount), - checkRequired("metadata", metadata), - checkRequired("minimum", minimum), - checkRequired("minimumAmount", minimumAmount), - modelType, - checkRequired("name", name), - checkRequired("planPhaseOrder", planPhaseOrder), - checkRequired("priceType", priceType), - checkRequired("replacesPriceId", replacesPriceId), - checkRequired( - "scalableMatrixWithTieredPricingConfig", - scalableMatrixWithTieredPricingConfig, - ), - dimensionalPriceConfiguration, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): ScalableMatrixWithTieredPricing = apply { - if (validated) { - return@apply - } - - id() - billableMetric()?.validate() - billingCycleConfiguration().validate() - cadence().validate() - conversionRate() - conversionRateConfig()?.validate() - createdAt() - creditAllocation()?.validate() - currency() - discount()?.validate() - externalPriceId() - fixedPriceQuantity() - invoicingCycleConfiguration()?.validate() - item().validate() - maximum()?.validate() - maximumAmount() - metadata().validate() - minimum()?.validate() - minimumAmount() - _modelType().let { - if (it != JsonValue.from("scalable_matrix_with_tiered_pricing")) { - throw OrbInvalidDataException("'modelType' is invalid, received $it") - } - } - name() - planPhaseOrder() - priceType().validate() - replacesPriceId() - scalableMatrixWithTieredPricingConfig().validate() - dimensionalPriceConfiguration()?.validate() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (if (id.asKnown() == null) 0 else 1) + - (billableMetric.asKnown()?.validity() ?: 0) + - (billingCycleConfiguration.asKnown()?.validity() ?: 0) + - (cadence.asKnown()?.validity() ?: 0) + - (if (conversionRate.asKnown() == null) 0 else 1) + - (conversionRateConfig.asKnown()?.validity() ?: 0) + - (if (createdAt.asKnown() == null) 0 else 1) + - (creditAllocation.asKnown()?.validity() ?: 0) + - (if (currency.asKnown() == null) 0 else 1) + - (discount.asKnown()?.validity() ?: 0) + - (if (externalPriceId.asKnown() == null) 0 else 1) + - (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + - (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + - (item.asKnown()?.validity() ?: 0) + - (maximum.asKnown()?.validity() ?: 0) + - (if (maximumAmount.asKnown() == null) 0 else 1) + - (metadata.asKnown()?.validity() ?: 0) + - (minimum.asKnown()?.validity() ?: 0) + - (if (minimumAmount.asKnown() == null) 0 else 1) + - modelType.let { - if (it == JsonValue.from("scalable_matrix_with_tiered_pricing")) 1 else 0 - } + - (if (name.asKnown() == null) 0 else 1) + - (if (planPhaseOrder.asKnown() == null) 0 else 1) + - (priceType.asKnown()?.validity() ?: 0) + - (if (replacesPriceId.asKnown() == null) 0 else 1) + - (scalableMatrixWithTieredPricingConfig.asKnown()?.validity() ?: 0) + - (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) - - class Cadence @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - val ONE_TIME = of("one_time") - - val MONTHLY = of("monthly") - - val QUARTERLY = of("quarterly") - - val SEMI_ANNUAL = of("semi_annual") - - val ANNUAL = of("annual") - - val CUSTOM = of("custom") - - fun of(value: String) = Cadence(JsonField.of(value)) - } - - /** An enum containing [Cadence]'s known values. */ - enum class Known { - ONE_TIME, - MONTHLY, - QUARTERLY, - SEMI_ANNUAL, - ANNUAL, - CUSTOM, - } - - /** - * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Cadence] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - ONE_TIME, - MONTHLY, - QUARTERLY, - SEMI_ANNUAL, - ANNUAL, - CUSTOM, - /** - * An enum member indicating that [Cadence] was instantiated with an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - ONE_TIME -> Value.ONE_TIME - MONTHLY -> Value.MONTHLY - QUARTERLY -> Value.QUARTERLY - SEMI_ANNUAL -> Value.SEMI_ANNUAL - ANNUAL -> Value.ANNUAL - CUSTOM -> Value.CUSTOM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - ONE_TIME -> Known.ONE_TIME - MONTHLY -> Known.MONTHLY - QUARTERLY -> Known.QUARTERLY - SEMI_ANNUAL -> Known.SEMI_ANNUAL - ANNUAL -> Known.ANNUAL - CUSTOM -> Known.CUSTOM - else -> throw OrbInvalidDataException("Unknown Cadence: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString() ?: throw OrbInvalidDataException("Value is not a String") - - private var validated: Boolean = false - - fun validate(): Cadence = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Cadence && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** - * User specified key-value pairs for the resource. If not present, this defaults to an - * empty dictionary. Individual keys can be removed by setting the value to `null`, and the - * entire metadata mapping can be cleared by setting `metadata` to `null`. - */ - class Metadata - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Metadata]. */ - fun builder() = Builder() - } - - /** A builder for [Metadata]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(metadata: Metadata) = apply { - additionalProperties = metadata.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Metadata]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Metadata && additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - class PriceType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - val USAGE_PRICE = of("usage_price") - - val FIXED_PRICE = of("fixed_price") - - fun of(value: String) = PriceType(JsonField.of(value)) - } - - /** An enum containing [PriceType]'s known values. */ - enum class Known { - USAGE_PRICE, - FIXED_PRICE, - } - - /** - * An enum containing [PriceType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [PriceType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - USAGE_PRICE, - FIXED_PRICE, - /** - * An enum member indicating that [PriceType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - USAGE_PRICE -> Value.USAGE_PRICE - FIXED_PRICE -> Value.FIXED_PRICE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - USAGE_PRICE -> Known.USAGE_PRICE - FIXED_PRICE -> Known.FIXED_PRICE - else -> throw OrbInvalidDataException("Unknown PriceType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString() ?: throw OrbInvalidDataException("Value is not a String") - - private var validated: Boolean = false - - fun validate(): PriceType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is PriceType && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class ScalableMatrixWithTieredPricingConfig - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [ScalableMatrixWithTieredPricingConfig]. - */ - fun builder() = Builder() - } - - /** A builder for [ScalableMatrixWithTieredPricingConfig]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from( - scalableMatrixWithTieredPricingConfig: ScalableMatrixWithTieredPricingConfig - ) = apply { - additionalProperties = - scalableMatrixWithTieredPricingConfig.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [ScalableMatrixWithTieredPricingConfig]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): ScalableMatrixWithTieredPricingConfig = - ScalableMatrixWithTieredPricingConfig(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): ScalableMatrixWithTieredPricingConfig = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ScalableMatrixWithTieredPricingConfig && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "ScalableMatrixWithTieredPricingConfig{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ScalableMatrixWithTieredPricing && - id == other.id && - billableMetric == other.billableMetric && - billingCycleConfiguration == other.billingCycleConfiguration && - cadence == other.cadence && - conversionRate == other.conversionRate && - conversionRateConfig == other.conversionRateConfig && - createdAt == other.createdAt && - creditAllocation == other.creditAllocation && - currency == other.currency && - discount == other.discount && - externalPriceId == other.externalPriceId && - fixedPriceQuantity == other.fixedPriceQuantity && - invoicingCycleConfiguration == other.invoicingCycleConfiguration && - item == other.item && - maximum == other.maximum && - maximumAmount == other.maximumAmount && - metadata == other.metadata && - minimum == other.minimum && - minimumAmount == other.minimumAmount && - modelType == other.modelType && - name == other.name && - planPhaseOrder == other.planPhaseOrder && - priceType == other.priceType && - replacesPriceId == other.replacesPriceId && - scalableMatrixWithTieredPricingConfig == - other.scalableMatrixWithTieredPricingConfig && - dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - id, - billableMetric, - billingCycleConfiguration, - cadence, - conversionRate, - conversionRateConfig, - createdAt, - creditAllocation, - currency, - discount, - externalPriceId, - fixedPriceQuantity, - invoicingCycleConfiguration, - item, - maximum, - maximumAmount, - metadata, - minimum, - minimumAmount, - modelType, - name, - planPhaseOrder, - priceType, - replacesPriceId, - scalableMatrixWithTieredPricingConfig, - dimensionalPriceConfiguration, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "ScalableMatrixWithTieredPricing{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, scalableMatrixWithTieredPricingConfig=$scalableMatrixWithTieredPricingConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" - } - - class CumulativeGroupedBulk - private constructor( - private val id: JsonField, - private val billableMetric: JsonField, - private val billingCycleConfiguration: JsonField, - private val cadence: JsonField, - private val conversionRate: JsonField, - private val conversionRateConfig: JsonField, - private val createdAt: JsonField, - private val creditAllocation: JsonField, - private val cumulativeGroupedBulkConfig: JsonField, - private val currency: JsonField, - private val discount: JsonField, - private val externalPriceId: JsonField, - private val fixedPriceQuantity: JsonField, - private val invoicingCycleConfiguration: JsonField, - private val item: JsonField, - private val maximum: JsonField, - private val maximumAmount: JsonField, - private val metadata: JsonField, - private val minimum: JsonField, - private val minimumAmount: JsonField, - private val modelType: JsonValue, - private val name: JsonField, - private val planPhaseOrder: JsonField, - private val priceType: JsonField, - private val replacesPriceId: JsonField, - private val dimensionalPriceConfiguration: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), - @JsonProperty("billable_metric") - @ExcludeMissing - billableMetric: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - billingCycleConfiguration: JsonField = JsonMissing.of(), - @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("conversion_rate_config") - @ExcludeMissing - conversionRateConfig: JsonField = JsonMissing.of(), - @JsonProperty("created_at") - @ExcludeMissing - createdAt: JsonField = JsonMissing.of(), - @JsonProperty("credit_allocation") - @ExcludeMissing - creditAllocation: JsonField = JsonMissing.of(), - @JsonProperty("cumulative_grouped_bulk_config") - @ExcludeMissing - cumulativeGroupedBulkConfig: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - currency: JsonField = JsonMissing.of(), - @JsonProperty("discount") - @ExcludeMissing - discount: JsonField = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - invoicingCycleConfiguration: JsonField = JsonMissing.of(), - @JsonProperty("item") @ExcludeMissing item: JsonField = JsonMissing.of(), - @JsonProperty("maximum") @ExcludeMissing maximum: JsonField = JsonMissing.of(), - @JsonProperty("maximum_amount") - @ExcludeMissing - maximumAmount: JsonField = JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - metadata: JsonField = JsonMissing.of(), - @JsonProperty("minimum") @ExcludeMissing minimum: JsonField = JsonMissing.of(), - @JsonProperty("minimum_amount") - @ExcludeMissing - minimumAmount: JsonField = JsonMissing.of(), - @JsonProperty("model_type") @ExcludeMissing modelType: JsonValue = JsonMissing.of(), - @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("plan_phase_order") - @ExcludeMissing - planPhaseOrder: JsonField = JsonMissing.of(), - @JsonProperty("price_type") - @ExcludeMissing - priceType: JsonField = JsonMissing.of(), - @JsonProperty("replaces_price_id") - @ExcludeMissing - replacesPriceId: JsonField = JsonMissing.of(), - @JsonProperty("dimensional_price_configuration") - @ExcludeMissing - dimensionalPriceConfiguration: JsonField = - JsonMissing.of(), - ) : this( - id, - billableMetric, - billingCycleConfiguration, - cadence, - conversionRate, - conversionRateConfig, - createdAt, - creditAllocation, - cumulativeGroupedBulkConfig, - currency, - discount, - externalPriceId, - fixedPriceQuantity, - invoicingCycleConfiguration, - item, - maximum, - maximumAmount, - metadata, - minimum, - minimumAmount, - modelType, - name, - planPhaseOrder, - priceType, - replacesPriceId, - dimensionalPriceConfiguration, - mutableMapOf(), - ) - - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun id(): String = id.getRequired("id") - - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun billableMetric(): BillableMetricTiny? = billableMetric.getNullable("billable_metric") - - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun billingCycleConfiguration(): BillingCycleConfiguration = - billingCycleConfiguration.getRequired("billing_cycle_configuration") - - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") - - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun conversionRateConfig(): ConversionRateConfig? = - conversionRateConfig.getNullable("conversion_rate_config") - - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") - - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun creditAllocation(): Allocation? = creditAllocation.getNullable("credit_allocation") - - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun cumulativeGroupedBulkConfig(): CumulativeGroupedBulkConfig = - cumulativeGroupedBulkConfig.getRequired("cumulative_grouped_bulk_config") - - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun currency(): String = currency.getRequired("currency") - - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - @Deprecated("deprecated") fun discount(): Discount? = discount.getNullable("discount") - - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") - - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun fixedPriceQuantity(): Double? = fixedPriceQuantity.getNullable("fixed_price_quantity") - - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun invoicingCycleConfiguration(): BillingCycleConfiguration? = - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun item(): ItemSlim = item.getRequired("item") - - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - @Deprecated("deprecated") fun maximum(): Maximum? = maximum.getNullable("maximum") - - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - @Deprecated("deprecated") - fun maximumAmount(): String? = maximumAmount.getNullable("maximum_amount") - - /** - * User specified key-value pairs for the resource. If not present, this defaults to an - * empty dictionary. Individual keys can be removed by setting the value to `null`, and the - * entire metadata mapping can be cleared by setting `metadata` to `null`. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun metadata(): Metadata = metadata.getRequired("metadata") - - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - @Deprecated("deprecated") fun minimum(): Minimum? = minimum.getNullable("minimum") - - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - @Deprecated("deprecated") - fun minimumAmount(): String? = minimumAmount.getNullable("minimum_amount") - - /** - * Expected to always return the following: - * ```kotlin - * JsonValue.from("cumulative_grouped_bulk") - * ``` - * - * However, this method can be useful for debugging and logging (e.g. if the server - * responded with an unexpected value). - */ - @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType - - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun name(): String = name.getRequired("name") - - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun planPhaseOrder(): Long? = planPhaseOrder.getNullable("plan_phase_order") - - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun priceType(): PriceType = priceType.getRequired("price_type") - - /** - * The price id this price replaces. This price will take the place of the replaced price in - * plan version migrations. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun replacesPriceId(): String? = replacesPriceId.getNullable("replaces_price_id") - - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun dimensionalPriceConfiguration(): DimensionalPriceConfiguration? = - dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") - - /** - * Returns the raw JSON value of [id]. - * - * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - /** - * Returns the raw JSON value of [billableMetric]. - * - * Unlike [billableMetric], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("billable_metric") - @ExcludeMissing - fun _billableMetric(): JsonField = billableMetric - - /** - * Returns the raw JSON value of [billingCycleConfiguration]. - * - * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** - * Returns the raw JSON value of [cadence]. - * - * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence - - /** - * Returns the raw JSON value of [conversionRate]. - * - * Unlike [conversionRate], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** - * Returns the raw JSON value of [conversionRateConfig]. - * - * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("conversion_rate_config") - @ExcludeMissing - fun _conversionRateConfig(): JsonField = conversionRateConfig - - /** - * Returns the raw JSON value of [createdAt]. - * - * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("created_at") - @ExcludeMissing - fun _createdAt(): JsonField = createdAt - - /** - * Returns the raw JSON value of [creditAllocation]. - * - * Unlike [creditAllocation], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("credit_allocation") - @ExcludeMissing - fun _creditAllocation(): JsonField = creditAllocation - - /** - * Returns the raw JSON value of [cumulativeGroupedBulkConfig]. - * - * Unlike [cumulativeGroupedBulkConfig], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("cumulative_grouped_bulk_config") - @ExcludeMissing - fun _cumulativeGroupedBulkConfig(): JsonField = - cumulativeGroupedBulkConfig - - /** - * Returns the raw JSON value of [currency]. - * - * Unlike [currency], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - - /** - * Returns the raw JSON value of [discount]. - * - * Unlike [discount], this method doesn't throw if the JSON field has an unexpected type. - */ - @Deprecated("deprecated") - @JsonProperty("discount") - @ExcludeMissing - fun _discount(): JsonField = discount - - /** - * Returns the raw JSON value of [externalPriceId]. - * - * Unlike [externalPriceId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * Returns the raw JSON value of [fixedPriceQuantity]. - * - * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** - * Returns the raw JSON value of [invoicingCycleConfiguration]. - * - * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * Returns the raw JSON value of [item]. - * - * Unlike [item], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("item") @ExcludeMissing fun _item(): JsonField = item - - /** - * Returns the raw JSON value of [maximum]. - * - * Unlike [maximum], this method doesn't throw if the JSON field has an unexpected type. - */ - @Deprecated("deprecated") - @JsonProperty("maximum") - @ExcludeMissing - fun _maximum(): JsonField = maximum - - /** - * Returns the raw JSON value of [maximumAmount]. - * - * Unlike [maximumAmount], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @Deprecated("deprecated") - @JsonProperty("maximum_amount") - @ExcludeMissing - fun _maximumAmount(): JsonField = maximumAmount - - /** - * Returns the raw JSON value of [metadata]. - * - * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata - - /** - * Returns the raw JSON value of [minimum]. - * - * Unlike [minimum], this method doesn't throw if the JSON field has an unexpected type. - */ - @Deprecated("deprecated") - @JsonProperty("minimum") - @ExcludeMissing - fun _minimum(): JsonField = minimum - - /** - * Returns the raw JSON value of [minimumAmount]. - * - * Unlike [minimumAmount], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @Deprecated("deprecated") - @JsonProperty("minimum_amount") - @ExcludeMissing - fun _minimumAmount(): JsonField = minimumAmount - - /** - * Returns the raw JSON value of [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - /** - * Returns the raw JSON value of [planPhaseOrder]. - * - * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("plan_phase_order") - @ExcludeMissing - fun _planPhaseOrder(): JsonField = planPhaseOrder - - /** - * Returns the raw JSON value of [priceType]. - * - * Unlike [priceType], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("price_type") - @ExcludeMissing - fun _priceType(): JsonField = priceType - - /** - * Returns the raw JSON value of [replacesPriceId]. - * - * Unlike [replacesPriceId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("replaces_price_id") - @ExcludeMissing - fun _replacesPriceId(): JsonField = replacesPriceId - - /** - * Returns the raw JSON value of [dimensionalPriceConfiguration]. - * - * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("dimensional_price_configuration") - @ExcludeMissing - fun _dimensionalPriceConfiguration(): JsonField = - dimensionalPriceConfiguration - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [CumulativeGroupedBulk]. - * - * The following fields are required: - * ```kotlin - * .id() - * .billableMetric() - * .billingCycleConfiguration() - * .cadence() - * .conversionRate() - * .conversionRateConfig() - * .createdAt() - * .creditAllocation() - * .cumulativeGroupedBulkConfig() - * .currency() - * .discount() - * .externalPriceId() - * .fixedPriceQuantity() - * .invoicingCycleConfiguration() - * .item() - * .maximum() - * .maximumAmount() - * .metadata() - * .minimum() - * .minimumAmount() - * .name() - * .planPhaseOrder() - * .priceType() - * .replacesPriceId() - * ``` - */ - fun builder() = Builder() - } - - /** A builder for [CumulativeGroupedBulk]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var billableMetric: JsonField? = null - private var billingCycleConfiguration: JsonField? = null - private var cadence: JsonField? = null - private var conversionRate: JsonField? = null - private var conversionRateConfig: JsonField? = null - private var createdAt: JsonField? = null - private var creditAllocation: JsonField? = null - private var cumulativeGroupedBulkConfig: JsonField? = null - private var currency: JsonField? = null - private var discount: JsonField? = null - private var externalPriceId: JsonField? = null - private var fixedPriceQuantity: JsonField? = null - private var invoicingCycleConfiguration: JsonField? = null - private var item: JsonField? = null - private var maximum: JsonField? = null - private var maximumAmount: JsonField? = null - private var metadata: JsonField? = null - private var minimum: JsonField? = null - private var minimumAmount: JsonField? = null - private var modelType: JsonValue = JsonValue.from("cumulative_grouped_bulk") - private var name: JsonField? = null - private var planPhaseOrder: JsonField? = null - private var priceType: JsonField? = null - private var replacesPriceId: JsonField? = null - private var dimensionalPriceConfiguration: JsonField = - JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(cumulativeGroupedBulk: CumulativeGroupedBulk) = apply { - id = cumulativeGroupedBulk.id - billableMetric = cumulativeGroupedBulk.billableMetric - billingCycleConfiguration = cumulativeGroupedBulk.billingCycleConfiguration - cadence = cumulativeGroupedBulk.cadence - conversionRate = cumulativeGroupedBulk.conversionRate - conversionRateConfig = cumulativeGroupedBulk.conversionRateConfig - createdAt = cumulativeGroupedBulk.createdAt - creditAllocation = cumulativeGroupedBulk.creditAllocation - cumulativeGroupedBulkConfig = cumulativeGroupedBulk.cumulativeGroupedBulkConfig - currency = cumulativeGroupedBulk.currency - discount = cumulativeGroupedBulk.discount - externalPriceId = cumulativeGroupedBulk.externalPriceId - fixedPriceQuantity = cumulativeGroupedBulk.fixedPriceQuantity - invoicingCycleConfiguration = cumulativeGroupedBulk.invoicingCycleConfiguration - item = cumulativeGroupedBulk.item - maximum = cumulativeGroupedBulk.maximum - maximumAmount = cumulativeGroupedBulk.maximumAmount - metadata = cumulativeGroupedBulk.metadata - minimum = cumulativeGroupedBulk.minimum - minimumAmount = cumulativeGroupedBulk.minimumAmount - modelType = cumulativeGroupedBulk.modelType - name = cumulativeGroupedBulk.name - planPhaseOrder = cumulativeGroupedBulk.planPhaseOrder - priceType = cumulativeGroupedBulk.priceType - replacesPriceId = cumulativeGroupedBulk.replacesPriceId - dimensionalPriceConfiguration = cumulativeGroupedBulk.dimensionalPriceConfiguration - additionalProperties = cumulativeGroupedBulk.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - /** - * Sets [Builder.id] to an arbitrary JSON value. - * - * You should usually call [Builder.id] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun id(id: JsonField) = apply { this.id = id } - - fun billableMetric(billableMetric: BillableMetricTiny?) = - billableMetric(JsonField.ofNullable(billableMetric)) - - /** - * Sets [Builder.billableMetric] to an arbitrary JSON value. - * - * You should usually call [Builder.billableMetric] with a well-typed - * [BillableMetricTiny] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun billableMetric(billableMetric: JsonField) = apply { - this.billableMetric = billableMetric - } - - fun billingCycleConfiguration(billingCycleConfiguration: BillingCycleConfiguration) = - billingCycleConfiguration(JsonField.of(billingCycleConfiguration)) - - /** - * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.billingCycleConfiguration] with a well-typed - * [BillingCycleConfiguration] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: JsonField - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } - - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** - * Sets [Builder.cadence] to an arbitrary JSON value. - * - * You should usually call [Builder.cadence] with a well-typed [Cadence] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - - fun conversionRate(conversionRate: Double?) = - conversionRate(JsonField.ofNullable(conversionRate)) - - /** - * Alias for [Builder.conversionRate]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) - - /** - * Sets [Builder.conversionRate] to an arbitrary JSON value. - * - * You should usually call [Builder.conversionRate] with a well-typed [Double] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = - conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) - - /** - * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.conversionRateConfig] with a well-typed - * [ConversionRateConfig] value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. - */ - fun conversionRateConfig(conversionRateConfig: JsonField) = - apply { - this.conversionRateConfig = conversionRateConfig - } - - /** - * Alias for calling [conversionRateConfig] with `ConversionRateConfig.ofUnit(unit)`. - */ - fun conversionRateConfig(unit: UnitConversionRateConfig) = - conversionRateConfig(ConversionRateConfig.ofUnit(unit)) - - /** - * Alias for calling [conversionRateConfig] with the following: - * ```kotlin - * UnitConversionRateConfig.builder() - * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) - * .unitConfig(unitConfig) - * .build() - * ``` - */ - fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = - conversionRateConfig( - UnitConversionRateConfig.builder() - .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) - .unitConfig(unitConfig) - .build() - ) - - /** - * Alias for calling [conversionRateConfig] with - * `ConversionRateConfig.ofTiered(tiered)`. - */ - fun conversionRateConfig(tiered: TieredConversionRateConfig) = - conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) - - /** - * Alias for calling [conversionRateConfig] with the following: - * ```kotlin - * TieredConversionRateConfig.builder() - * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) - * .tieredConfig(tieredConfig) - * .build() - * ``` - */ - fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = - conversionRateConfig( - TieredConversionRateConfig.builder() - .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) - .tieredConfig(tieredConfig) - .build() - ) - - fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) - - /** - * Sets [Builder.createdAt] to an arbitrary JSON value. - * - * You should usually call [Builder.createdAt] with a well-typed [OffsetDateTime] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun createdAt(createdAt: JsonField) = apply { - this.createdAt = createdAt - } - - fun creditAllocation(creditAllocation: Allocation?) = - creditAllocation(JsonField.ofNullable(creditAllocation)) - - /** - * Sets [Builder.creditAllocation] to an arbitrary JSON value. - * - * You should usually call [Builder.creditAllocation] with a well-typed [Allocation] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun creditAllocation(creditAllocation: JsonField) = apply { - this.creditAllocation = creditAllocation - } - - fun cumulativeGroupedBulkConfig( - cumulativeGroupedBulkConfig: CumulativeGroupedBulkConfig - ) = cumulativeGroupedBulkConfig(JsonField.of(cumulativeGroupedBulkConfig)) - - /** - * Sets [Builder.cumulativeGroupedBulkConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.cumulativeGroupedBulkConfig] with a well-typed - * [CumulativeGroupedBulkConfig] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun cumulativeGroupedBulkConfig( - cumulativeGroupedBulkConfig: JsonField - ) = apply { this.cumulativeGroupedBulkConfig = cumulativeGroupedBulkConfig } - - fun currency(currency: String) = currency(JsonField.of(currency)) - - /** - * Sets [Builder.currency] to an arbitrary JSON value. - * - * You should usually call [Builder.currency] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } - - @Deprecated("deprecated") - fun discount(discount: Discount?) = discount(JsonField.ofNullable(discount)) - - /** - * Sets [Builder.discount] to an arbitrary JSON value. - * - * You should usually call [Builder.discount] with a well-typed [Discount] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - @Deprecated("deprecated") - fun discount(discount: JsonField) = apply { this.discount = discount } - - /** Alias for calling [discount] with `Discount.ofPercentage(percentage)`. */ - @Deprecated("deprecated") - fun discount(percentage: PercentageDiscount) = - discount(Discount.ofPercentage(percentage)) - - /** - * Alias for calling [discount] with the following: - * ```kotlin - * PercentageDiscount.builder() - * .discountType(PercentageDiscount.DiscountType.PERCENTAGE) - * .percentageDiscount(percentageDiscount) - * .build() - * ``` - */ - @Deprecated("deprecated") - fun percentageDiscount(percentageDiscount: Double) = - discount( - PercentageDiscount.builder() - .discountType(PercentageDiscount.DiscountType.PERCENTAGE) - .percentageDiscount(percentageDiscount) - .build() - ) - - /** Alias for calling [discount] with `Discount.ofTrial(trial)`. */ - @Deprecated("deprecated") - fun discount(trial: TrialDiscount) = discount(Discount.ofTrial(trial)) - - /** Alias for calling [discount] with `Discount.ofUsage(usage)`. */ - @Deprecated("deprecated") - fun discount(usage: UsageDiscount) = discount(Discount.ofUsage(usage)) - - /** - * Alias for calling [discount] with the following: - * ```kotlin - * UsageDiscount.builder() - * .discountType(UsageDiscount.DiscountType.USAGE) - * .usageDiscount(usageDiscount) - * .build() - * ``` - */ - @Deprecated("deprecated") - fun usageDiscount(usageDiscount: Double) = - discount( - UsageDiscount.builder() - .discountType(UsageDiscount.DiscountType.USAGE) - .usageDiscount(usageDiscount) - .build() - ) - - /** Alias for calling [discount] with `Discount.ofAmount(amount)`. */ - @Deprecated("deprecated") - fun discount(amount: AmountDiscount) = discount(Discount.ofAmount(amount)) - - /** - * Alias for calling [discount] with the following: - * ```kotlin - * AmountDiscount.builder() - * .discountType(AmountDiscount.DiscountType.AMOUNT) - * .amountDiscount(amountDiscount) - * .build() - * ``` - */ - @Deprecated("deprecated") - fun amountDiscount(amountDiscount: String) = - discount( - AmountDiscount.builder() - .discountType(AmountDiscount.DiscountType.AMOUNT) - .amountDiscount(amountDiscount) - .build() - ) - - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** - * Sets [Builder.externalPriceId] to an arbitrary JSON value. - * - * You should usually call [Builder.externalPriceId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun externalPriceId(externalPriceId: JsonField) = apply { - this.externalPriceId = externalPriceId - } - - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = - fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) - - /** - * Alias for [Builder.fixedPriceQuantity]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. - * - * You should usually call [Builder.fixedPriceQuantity] with a well-typed [Double] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } - - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: BillingCycleConfiguration? - ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) - - /** - * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.invoicingCycleConfiguration] with a well-typed - * [BillingCycleConfiguration] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - fun item(item: ItemSlim) = item(JsonField.of(item)) - - /** - * Sets [Builder.item] to an arbitrary JSON value. - * - * You should usually call [Builder.item] with a well-typed [ItemSlim] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun item(item: JsonField) = apply { this.item = item } - - @Deprecated("deprecated") - fun maximum(maximum: Maximum?) = maximum(JsonField.ofNullable(maximum)) - - /** - * Sets [Builder.maximum] to an arbitrary JSON value. - * - * You should usually call [Builder.maximum] with a well-typed [Maximum] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - @Deprecated("deprecated") - fun maximum(maximum: JsonField) = apply { this.maximum = maximum } - - @Deprecated("deprecated") - fun maximumAmount(maximumAmount: String?) = - maximumAmount(JsonField.ofNullable(maximumAmount)) - - /** - * Sets [Builder.maximumAmount] to an arbitrary JSON value. - * - * You should usually call [Builder.maximumAmount] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - @Deprecated("deprecated") - fun maximumAmount(maximumAmount: JsonField) = apply { - this.maximumAmount = maximumAmount - } - - /** - * User specified key-value pairs for the resource. If not present, this defaults to an - * empty dictionary. Individual keys can be removed by setting the value to `null`, and - * the entire metadata mapping can be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) - - /** - * Sets [Builder.metadata] to an arbitrary JSON value. - * - * You should usually call [Builder.metadata] with a well-typed [Metadata] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - - @Deprecated("deprecated") - fun minimum(minimum: Minimum?) = minimum(JsonField.ofNullable(minimum)) - - /** - * Sets [Builder.minimum] to an arbitrary JSON value. - * - * You should usually call [Builder.minimum] with a well-typed [Minimum] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - @Deprecated("deprecated") - fun minimum(minimum: JsonField) = apply { this.minimum = minimum } - - @Deprecated("deprecated") - fun minimumAmount(minimumAmount: String?) = - minimumAmount(JsonField.ofNullable(minimumAmount)) - - /** - * Sets [Builder.minimumAmount] to an arbitrary JSON value. - * - * You should usually call [Builder.minimumAmount] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - @Deprecated("deprecated") - fun minimumAmount(minimumAmount: JsonField) = apply { - this.minimumAmount = minimumAmount - } - - /** - * Sets the field to an arbitrary JSON value. - * - * It is usually unnecessary to call this method because the field defaults to the - * following: - * ```kotlin - * JsonValue.from("cumulative_grouped_bulk") - * ``` - * - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } - - fun name(name: String) = name(JsonField.of(name)) - - /** - * Sets [Builder.name] to an arbitrary JSON value. - * - * You should usually call [Builder.name] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun name(name: JsonField) = apply { this.name = name } - - fun planPhaseOrder(planPhaseOrder: Long?) = - planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) - - /** - * Alias for [Builder.planPhaseOrder]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) - - /** - * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. - * - * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun planPhaseOrder(planPhaseOrder: JsonField) = apply { - this.planPhaseOrder = planPhaseOrder - } - - fun priceType(priceType: PriceType) = priceType(JsonField.of(priceType)) - - /** - * Sets [Builder.priceType] to an arbitrary JSON value. - * - * You should usually call [Builder.priceType] with a well-typed [PriceType] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun priceType(priceType: JsonField) = apply { this.priceType = priceType } - - /** - * The price id this price replaces. This price will take the place of the replaced - * price in plan version migrations. - */ - fun replacesPriceId(replacesPriceId: String?) = - replacesPriceId(JsonField.ofNullable(replacesPriceId)) - - /** - * Sets [Builder.replacesPriceId] to an arbitrary JSON value. - * - * You should usually call [Builder.replacesPriceId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun replacesPriceId(replacesPriceId: JsonField) = apply { - this.replacesPriceId = replacesPriceId - } - - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: DimensionalPriceConfiguration? - ) = dimensionalPriceConfiguration(JsonField.ofNullable(dimensionalPriceConfiguration)) - - /** - * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.dimensionalPriceConfiguration] with a well-typed - * [DimensionalPriceConfiguration] value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: JsonField - ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [CumulativeGroupedBulk]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```kotlin - * .id() - * .billableMetric() - * .billingCycleConfiguration() - * .cadence() - * .conversionRate() - * .conversionRateConfig() - * .createdAt() - * .creditAllocation() - * .cumulativeGroupedBulkConfig() - * .currency() - * .discount() - * .externalPriceId() - * .fixedPriceQuantity() - * .invoicingCycleConfiguration() - * .item() - * .maximum() - * .maximumAmount() - * .metadata() - * .minimum() - * .minimumAmount() - * .name() - * .planPhaseOrder() - * .priceType() - * .replacesPriceId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): CumulativeGroupedBulk = - CumulativeGroupedBulk( - checkRequired("id", id), - checkRequired("billableMetric", billableMetric), - checkRequired("billingCycleConfiguration", billingCycleConfiguration), - checkRequired("cadence", cadence), - checkRequired("conversionRate", conversionRate), - checkRequired("conversionRateConfig", conversionRateConfig), - checkRequired("createdAt", createdAt), - checkRequired("creditAllocation", creditAllocation), - checkRequired("cumulativeGroupedBulkConfig", cumulativeGroupedBulkConfig), - checkRequired("currency", currency), - checkRequired("discount", discount), - checkRequired("externalPriceId", externalPriceId), - checkRequired("fixedPriceQuantity", fixedPriceQuantity), - checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), - checkRequired("item", item), - checkRequired("maximum", maximum), - checkRequired("maximumAmount", maximumAmount), - checkRequired("metadata", metadata), - checkRequired("minimum", minimum), - checkRequired("minimumAmount", minimumAmount), - modelType, - checkRequired("name", name), - checkRequired("planPhaseOrder", planPhaseOrder), - checkRequired("priceType", priceType), - checkRequired("replacesPriceId", replacesPriceId), - dimensionalPriceConfiguration, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): CumulativeGroupedBulk = apply { - if (validated) { - return@apply - } - - id() - billableMetric()?.validate() - billingCycleConfiguration().validate() - cadence().validate() - conversionRate() - conversionRateConfig()?.validate() - createdAt() - creditAllocation()?.validate() - cumulativeGroupedBulkConfig().validate() - currency() - discount()?.validate() - externalPriceId() - fixedPriceQuantity() - invoicingCycleConfiguration()?.validate() - item().validate() - maximum()?.validate() - maximumAmount() - metadata().validate() - minimum()?.validate() - minimumAmount() - _modelType().let { - if (it != JsonValue.from("cumulative_grouped_bulk")) { - throw OrbInvalidDataException("'modelType' is invalid, received $it") - } - } - name() - planPhaseOrder() - priceType().validate() - replacesPriceId() - dimensionalPriceConfiguration()?.validate() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (if (id.asKnown() == null) 0 else 1) + - (billableMetric.asKnown()?.validity() ?: 0) + - (billingCycleConfiguration.asKnown()?.validity() ?: 0) + - (cadence.asKnown()?.validity() ?: 0) + - (if (conversionRate.asKnown() == null) 0 else 1) + - (conversionRateConfig.asKnown()?.validity() ?: 0) + - (if (createdAt.asKnown() == null) 0 else 1) + - (creditAllocation.asKnown()?.validity() ?: 0) + - (cumulativeGroupedBulkConfig.asKnown()?.validity() ?: 0) + - (if (currency.asKnown() == null) 0 else 1) + - (discount.asKnown()?.validity() ?: 0) + - (if (externalPriceId.asKnown() == null) 0 else 1) + - (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + - (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + - (item.asKnown()?.validity() ?: 0) + - (maximum.asKnown()?.validity() ?: 0) + - (if (maximumAmount.asKnown() == null) 0 else 1) + - (metadata.asKnown()?.validity() ?: 0) + - (minimum.asKnown()?.validity() ?: 0) + - (if (minimumAmount.asKnown() == null) 0 else 1) + - modelType.let { if (it == JsonValue.from("cumulative_grouped_bulk")) 1 else 0 } + - (if (name.asKnown() == null) 0 else 1) + - (if (planPhaseOrder.asKnown() == null) 0 else 1) + - (priceType.asKnown()?.validity() ?: 0) + - (if (replacesPriceId.asKnown() == null) 0 else 1) + - (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) - - class Cadence @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - val ONE_TIME = of("one_time") - - val MONTHLY = of("monthly") - - val QUARTERLY = of("quarterly") - - val SEMI_ANNUAL = of("semi_annual") - - val ANNUAL = of("annual") - - val CUSTOM = of("custom") - - fun of(value: String) = Cadence(JsonField.of(value)) - } - - /** An enum containing [Cadence]'s known values. */ - enum class Known { - ONE_TIME, - MONTHLY, - QUARTERLY, - SEMI_ANNUAL, - ANNUAL, - CUSTOM, - } - - /** - * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Cadence] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - ONE_TIME, - MONTHLY, - QUARTERLY, - SEMI_ANNUAL, - ANNUAL, - CUSTOM, - /** - * An enum member indicating that [Cadence] was instantiated with an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - ONE_TIME -> Value.ONE_TIME - MONTHLY -> Value.MONTHLY - QUARTERLY -> Value.QUARTERLY - SEMI_ANNUAL -> Value.SEMI_ANNUAL - ANNUAL -> Value.ANNUAL - CUSTOM -> Value.CUSTOM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - ONE_TIME -> Known.ONE_TIME - MONTHLY -> Known.MONTHLY - QUARTERLY -> Known.QUARTERLY - SEMI_ANNUAL -> Known.SEMI_ANNUAL - ANNUAL -> Known.ANNUAL - CUSTOM -> Known.CUSTOM - else -> throw OrbInvalidDataException("Unknown Cadence: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString() ?: throw OrbInvalidDataException("Value is not a String") - - private var validated: Boolean = false - - fun validate(): Cadence = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Cadence && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class CumulativeGroupedBulkConfig - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [CumulativeGroupedBulkConfig]. - */ - fun builder() = Builder() - } - - /** A builder for [CumulativeGroupedBulkConfig]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(cumulativeGroupedBulkConfig: CumulativeGroupedBulkConfig) = - apply { - additionalProperties = - cumulativeGroupedBulkConfig.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [CumulativeGroupedBulkConfig]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): CumulativeGroupedBulkConfig = - CumulativeGroupedBulkConfig(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): CumulativeGroupedBulkConfig = apply { + fun validate(): GroupedWithMinMaxThresholdsConfig = apply { if (validated) { return@apply } @@ -52428,7 +50575,7 @@ private constructor( return true } - return other is CumulativeGroupedBulkConfig && + return other is GroupedWithMinMaxThresholdsConfig && additionalProperties == other.additionalProperties } @@ -52437,7 +50584,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "CumulativeGroupedBulkConfig{additionalProperties=$additionalProperties}" + "GroupedWithMinMaxThresholdsConfig{additionalProperties=$additionalProperties}" } /** @@ -52679,20 +50826,21 @@ private constructor( return true } - return other is CumulativeGroupedBulk && + return other is GroupedWithMinMaxThresholds && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && + compositePriceFilters == other.compositePriceFilters && conversionRate == other.conversionRate && conversionRateConfig == other.conversionRateConfig && createdAt == other.createdAt && creditAllocation == other.creditAllocation && - cumulativeGroupedBulkConfig == other.cumulativeGroupedBulkConfig && currency == other.currency && discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && + groupedWithMinMaxThresholdsConfig == other.groupedWithMinMaxThresholdsConfig && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maximum == other.maximum && @@ -52715,15 +50863,16 @@ private constructor( billableMetric, billingCycleConfiguration, cadence, + compositePriceFilters, conversionRate, conversionRateConfig, createdAt, creditAllocation, - cumulativeGroupedBulkConfig, currency, discount, externalPriceId, fixedPriceQuantity, + groupedWithMinMaxThresholdsConfig, invoicingCycleConfiguration, item, maximum, @@ -52744,15 +50893,16 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "CumulativeGroupedBulk{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, cumulativeGroupedBulkConfig=$cumulativeGroupedBulkConfig, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "GroupedWithMinMaxThresholds{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" } - class GroupedWithMinMaxThresholds + class Minimum private constructor( private val id: JsonField, private val billableMetric: JsonField, private val billingCycleConfiguration: JsonField, private val cadence: JsonField, + private val compositePriceFilters: JsonField>, private val conversionRate: JsonField, private val conversionRateConfig: JsonField, private val createdAt: JsonField, @@ -52761,7 +50911,6 @@ private constructor( private val discount: JsonField, private val externalPriceId: JsonField, private val fixedPriceQuantity: JsonField, - private val groupedWithMinMaxThresholdsConfig: JsonField, private val invoicingCycleConfiguration: JsonField, private val item: JsonField, private val maximum: JsonField, @@ -52769,6 +50918,7 @@ private constructor( private val metadata: JsonField, private val minimum: JsonField, private val minimumAmount: JsonField, + private val minimumConfig: JsonField, private val modelType: JsonValue, private val name: JsonField, private val planPhaseOrder: JsonField, @@ -52788,6 +50938,9 @@ private constructor( @ExcludeMissing billingCycleConfiguration: JsonField = JsonMissing.of(), @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), + @JsonProperty("composite_price_filters") + @ExcludeMissing + compositePriceFilters: JsonField> = JsonMissing.of(), @JsonProperty("conversion_rate") @ExcludeMissing conversionRate: JsonField = JsonMissing.of(), @@ -52812,10 +50965,6 @@ private constructor( @JsonProperty("fixed_price_quantity") @ExcludeMissing fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("grouped_with_min_max_thresholds_config") - @ExcludeMissing - groupedWithMinMaxThresholdsConfig: JsonField = - JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), @@ -52831,6 +50980,9 @@ private constructor( @JsonProperty("minimum_amount") @ExcludeMissing minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("minimum_config") + @ExcludeMissing + minimumConfig: JsonField = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @JsonProperty("plan_phase_order") @@ -52851,6 +51003,7 @@ private constructor( billableMetric, billingCycleConfiguration, cadence, + compositePriceFilters, conversionRate, conversionRateConfig, createdAt, @@ -52859,7 +51012,6 @@ private constructor( discount, externalPriceId, fixedPriceQuantity, - groupedWithMinMaxThresholdsConfig, invoicingCycleConfiguration, item, maximum, @@ -52867,6 +51019,7 @@ private constructor( metadata, minimum, minimumAmount, + minimumConfig, modelType, name, planPhaseOrder, @@ -52901,6 +51054,13 @@ private constructor( */ fun cadence(): Cadence = cadence.getRequired("cadence") + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun compositePriceFilters(): List? = + compositePriceFilters.getNullable("composite_price_filters") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -52950,13 +51110,6 @@ private constructor( */ fun fixedPriceQuantity(): Double? = fixedPriceQuantity.getNullable("fixed_price_quantity") - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun groupedWithMinMaxThresholdsConfig(): GroupedWithMinMaxThresholdsConfig = - groupedWithMinMaxThresholdsConfig.getRequired("grouped_with_min_max_thresholds_config") - /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -53006,10 +51159,16 @@ private constructor( @Deprecated("deprecated") fun minimumAmount(): String? = minimumAmount.getNullable("minimum_amount") + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun minimumConfig(): MinimumConfig = minimumConfig.getRequired("minimum_config") + /** * Expected to always return the following: * ```kotlin - * JsonValue.from("grouped_with_min_max_thresholds") + * JsonValue.from("minimum") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -53086,6 +51245,16 @@ private constructor( */ @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence + /** + * Returns the raw JSON value of [compositePriceFilters]. + * + * Unlike [compositePriceFilters], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("composite_price_filters") + @ExcludeMissing + fun _compositePriceFilters(): JsonField> = compositePriceFilters + /** * Returns the raw JSON value of [conversionRate]. * @@ -53162,17 +51331,6 @@ private constructor( @ExcludeMissing fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - /** - * Returns the raw JSON value of [groupedWithMinMaxThresholdsConfig]. - * - * Unlike [groupedWithMinMaxThresholdsConfig], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("grouped_with_min_max_thresholds_config") - @ExcludeMissing - fun _groupedWithMinMaxThresholdsConfig(): JsonField = - groupedWithMinMaxThresholdsConfig - /** * Returns the raw JSON value of [invoicingCycleConfiguration]. * @@ -53240,6 +51398,16 @@ private constructor( @ExcludeMissing fun _minimumAmount(): JsonField = minimumAmount + /** + * Returns the raw JSON value of [minimumConfig]. + * + * Unlike [minimumConfig], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("minimum_config") + @ExcludeMissing + fun _minimumConfig(): JsonField = minimumConfig + /** * Returns the raw JSON value of [name]. * @@ -53302,8 +51470,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [GroupedWithMinMaxThresholds]. + * Returns a mutable builder for constructing an instance of [Minimum]. * * The following fields are required: * ```kotlin @@ -53311,6 +51478,7 @@ private constructor( * .billableMetric() * .billingCycleConfiguration() * .cadence() + * .compositePriceFilters() * .conversionRate() * .conversionRateConfig() * .createdAt() @@ -53319,7 +51487,6 @@ private constructor( * .discount() * .externalPriceId() * .fixedPriceQuantity() - * .groupedWithMinMaxThresholdsConfig() * .invoicingCycleConfiguration() * .item() * .maximum() @@ -53327,6 +51494,7 @@ private constructor( * .metadata() * .minimum() * .minimumAmount() + * .minimumConfig() * .name() * .planPhaseOrder() * .priceType() @@ -53336,13 +51504,14 @@ private constructor( fun builder() = Builder() } - /** A builder for [GroupedWithMinMaxThresholds]. */ + /** A builder for [Minimum]. */ class Builder internal constructor() { private var id: JsonField? = null private var billableMetric: JsonField? = null private var billingCycleConfiguration: JsonField? = null private var cadence: JsonField? = null + private var compositePriceFilters: JsonField>? = null private var conversionRate: JsonField? = null private var conversionRateConfig: JsonField? = null private var createdAt: JsonField? = null @@ -53351,9 +51520,6 @@ private constructor( private var discount: JsonField? = null private var externalPriceId: JsonField? = null private var fixedPriceQuantity: JsonField? = null - private var groupedWithMinMaxThresholdsConfig: - JsonField? = - null private var invoicingCycleConfiguration: JsonField? = null private var item: JsonField? = null private var maximum: JsonField? = null @@ -53361,7 +51527,8 @@ private constructor( private var metadata: JsonField? = null private var minimum: JsonField? = null private var minimumAmount: JsonField? = null - private var modelType: JsonValue = JsonValue.from("grouped_with_min_max_thresholds") + private var minimumConfig: JsonField? = null + private var modelType: JsonValue = JsonValue.from("minimum") private var name: JsonField? = null private var planPhaseOrder: JsonField? = null private var priceType: JsonField? = null @@ -53370,38 +51537,35 @@ private constructor( JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds) = apply { - id = groupedWithMinMaxThresholds.id - billableMetric = groupedWithMinMaxThresholds.billableMetric - billingCycleConfiguration = groupedWithMinMaxThresholds.billingCycleConfiguration - cadence = groupedWithMinMaxThresholds.cadence - conversionRate = groupedWithMinMaxThresholds.conversionRate - conversionRateConfig = groupedWithMinMaxThresholds.conversionRateConfig - createdAt = groupedWithMinMaxThresholds.createdAt - creditAllocation = groupedWithMinMaxThresholds.creditAllocation - currency = groupedWithMinMaxThresholds.currency - discount = groupedWithMinMaxThresholds.discount - externalPriceId = groupedWithMinMaxThresholds.externalPriceId - fixedPriceQuantity = groupedWithMinMaxThresholds.fixedPriceQuantity - groupedWithMinMaxThresholdsConfig = - groupedWithMinMaxThresholds.groupedWithMinMaxThresholdsConfig - invoicingCycleConfiguration = - groupedWithMinMaxThresholds.invoicingCycleConfiguration - item = groupedWithMinMaxThresholds.item - maximum = groupedWithMinMaxThresholds.maximum - maximumAmount = groupedWithMinMaxThresholds.maximumAmount - metadata = groupedWithMinMaxThresholds.metadata - minimum = groupedWithMinMaxThresholds.minimum - minimumAmount = groupedWithMinMaxThresholds.minimumAmount - modelType = groupedWithMinMaxThresholds.modelType - name = groupedWithMinMaxThresholds.name - planPhaseOrder = groupedWithMinMaxThresholds.planPhaseOrder - priceType = groupedWithMinMaxThresholds.priceType - replacesPriceId = groupedWithMinMaxThresholds.replacesPriceId - dimensionalPriceConfiguration = - groupedWithMinMaxThresholds.dimensionalPriceConfiguration - additionalProperties = - groupedWithMinMaxThresholds.additionalProperties.toMutableMap() + internal fun from(minimum: Minimum) = apply { + id = minimum.id + billableMetric = minimum.billableMetric + billingCycleConfiguration = minimum.billingCycleConfiguration + cadence = minimum.cadence + compositePriceFilters = minimum.compositePriceFilters.map { it.toMutableList() } + conversionRate = minimum.conversionRate + conversionRateConfig = minimum.conversionRateConfig + createdAt = minimum.createdAt + creditAllocation = minimum.creditAllocation + currency = minimum.currency + discount = minimum.discount + externalPriceId = minimum.externalPriceId + fixedPriceQuantity = minimum.fixedPriceQuantity + invoicingCycleConfiguration = minimum.invoicingCycleConfiguration + item = minimum.item + maximum = minimum.maximum + maximumAmount = minimum.maximumAmount + metadata = minimum.metadata + this.minimum = minimum.minimum + minimumAmount = minimum.minimumAmount + minimumConfig = minimum.minimumConfig + modelType = minimum.modelType + name = minimum.name + planPhaseOrder = minimum.planPhaseOrder + priceType = minimum.priceType + replacesPriceId = minimum.replacesPriceId + dimensionalPriceConfiguration = minimum.dimensionalPriceConfiguration + additionalProperties = minimum.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) @@ -53454,6 +51618,34 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + fun compositePriceFilters(compositePriceFilters: List?) = + compositePriceFilters(JsonField.ofNullable(compositePriceFilters)) + + /** + * Sets [Builder.compositePriceFilters] to an arbitrary JSON value. + * + * You should usually call [Builder.compositePriceFilters] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun compositePriceFilters( + compositePriceFilters: JsonField> + ) = apply { + this.compositePriceFilters = compositePriceFilters.map { it.toMutableList() } + } + + /** + * Adds a single [TransformPriceFilter] to [compositePriceFilters]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addCompositePriceFilter(compositePriceFilter: TransformPriceFilter) = apply { + compositePriceFilters = + (compositePriceFilters ?: JsonField.of(mutableListOf())).also { + checkKnown("compositePriceFilters", it).add(compositePriceFilter) + } + } + fun conversionRate(conversionRate: Double?) = conversionRate(JsonField.ofNullable(conversionRate)) @@ -53695,21 +51887,6 @@ private constructor( this.fixedPriceQuantity = fixedPriceQuantity } - fun groupedWithMinMaxThresholdsConfig( - groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig - ) = groupedWithMinMaxThresholdsConfig(JsonField.of(groupedWithMinMaxThresholdsConfig)) - - /** - * Sets [Builder.groupedWithMinMaxThresholdsConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.groupedWithMinMaxThresholdsConfig] with a well-typed - * [GroupedWithMinMaxThresholdsConfig] value instead. This method is primarily for - * setting the field to an undocumented or not yet supported value. - */ - fun groupedWithMinMaxThresholdsConfig( - groupedWithMinMaxThresholdsConfig: JsonField - ) = apply { this.groupedWithMinMaxThresholdsConfig = groupedWithMinMaxThresholdsConfig } - fun invoicingCycleConfiguration( invoicingCycleConfiguration: BillingCycleConfiguration? ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) @@ -53810,13 +51987,27 @@ private constructor( this.minimumAmount = minimumAmount } + fun minimumConfig(minimumConfig: MinimumConfig) = + minimumConfig(JsonField.of(minimumConfig)) + + /** + * Sets [Builder.minimumConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumConfig] with a well-typed [MinimumConfig] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun minimumConfig(minimumConfig: JsonField) = apply { + this.minimumConfig = minimumConfig + } + /** * Sets the field to an arbitrary JSON value. * * It is usually unnecessary to call this method because the field defaults to the * following: * ```kotlin - * JsonValue.from("grouped_with_min_max_thresholds") + * JsonValue.from("minimum") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -53920,7 +52111,7 @@ private constructor( } /** - * Returns an immutable instance of [GroupedWithMinMaxThresholds]. + * Returns an immutable instance of [Minimum]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -53930,6 +52121,7 @@ private constructor( * .billableMetric() * .billingCycleConfiguration() * .cadence() + * .compositePriceFilters() * .conversionRate() * .conversionRateConfig() * .createdAt() @@ -53938,7 +52130,6 @@ private constructor( * .discount() * .externalPriceId() * .fixedPriceQuantity() - * .groupedWithMinMaxThresholdsConfig() * .invoicingCycleConfiguration() * .item() * .maximum() @@ -53946,6 +52137,7 @@ private constructor( * .metadata() * .minimum() * .minimumAmount() + * .minimumConfig() * .name() * .planPhaseOrder() * .priceType() @@ -53954,12 +52146,15 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): GroupedWithMinMaxThresholds = - GroupedWithMinMaxThresholds( + fun build(): Minimum = + Minimum( checkRequired("id", id), checkRequired("billableMetric", billableMetric), checkRequired("billingCycleConfiguration", billingCycleConfiguration), checkRequired("cadence", cadence), + checkRequired("compositePriceFilters", compositePriceFilters).map { + it.toImmutable() + }, checkRequired("conversionRate", conversionRate), checkRequired("conversionRateConfig", conversionRateConfig), checkRequired("createdAt", createdAt), @@ -53968,10 +52163,6 @@ private constructor( checkRequired("discount", discount), checkRequired("externalPriceId", externalPriceId), checkRequired("fixedPriceQuantity", fixedPriceQuantity), - checkRequired( - "groupedWithMinMaxThresholdsConfig", - groupedWithMinMaxThresholdsConfig, - ), checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), checkRequired("item", item), checkRequired("maximum", maximum), @@ -53979,6 +52170,7 @@ private constructor( checkRequired("metadata", metadata), checkRequired("minimum", minimum), checkRequired("minimumAmount", minimumAmount), + checkRequired("minimumConfig", minimumConfig), modelType, checkRequired("name", name), checkRequired("planPhaseOrder", planPhaseOrder), @@ -53991,7 +52183,7 @@ private constructor( private var validated: Boolean = false - fun validate(): GroupedWithMinMaxThresholds = apply { + fun validate(): Minimum = apply { if (validated) { return@apply } @@ -54000,6 +52192,7 @@ private constructor( billableMetric()?.validate() billingCycleConfiguration().validate() cadence().validate() + compositePriceFilters()?.forEach { it.validate() } conversionRate() conversionRateConfig()?.validate() createdAt() @@ -54008,7 +52201,6 @@ private constructor( discount()?.validate() externalPriceId() fixedPriceQuantity() - groupedWithMinMaxThresholdsConfig().validate() invoicingCycleConfiguration()?.validate() item().validate() maximum()?.validate() @@ -54016,8 +52208,9 @@ private constructor( metadata().validate() minimum()?.validate() minimumAmount() + minimumConfig().validate() _modelType().let { - if (it != JsonValue.from("grouped_with_min_max_thresholds")) { + if (it != JsonValue.from("minimum")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } @@ -54048,6 +52241,7 @@ private constructor( (billableMetric.asKnown()?.validity() ?: 0) + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + (cadence.asKnown()?.validity() ?: 0) + + (compositePriceFilters.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + (if (conversionRate.asKnown() == null) 0 else 1) + (conversionRateConfig.asKnown()?.validity() ?: 0) + (if (createdAt.asKnown() == null) 0 else 1) + @@ -54056,7 +52250,6 @@ private constructor( (discount.asKnown()?.validity() ?: 0) + (if (externalPriceId.asKnown() == null) 0 else 1) + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + - (groupedWithMinMaxThresholdsConfig.asKnown()?.validity() ?: 0) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + (item.asKnown()?.validity() ?: 0) + (maximum.asKnown()?.validity() ?: 0) + @@ -54064,9 +52257,8 @@ private constructor( (metadata.asKnown()?.validity() ?: 0) + (minimum.asKnown()?.validity() ?: 0) + (if (minimumAmount.asKnown() == null) 0 else 1) + - modelType.let { - if (it == JsonValue.from("grouped_with_min_max_thresholds")) 1 else 0 - } + + (minimumConfig.asKnown()?.validity() ?: 0) + + modelType.let { if (it == JsonValue.from("minimum")) 1 else 0 } + (if (name.asKnown() == null) 0 else 1) + (if (planPhaseOrder.asKnown() == null) 0 else 1) + (priceType.asKnown()?.validity() ?: 0) + @@ -54225,7 +52417,12 @@ private constructor( override fun toString() = value.toString() } - class GroupedWithMinMaxThresholdsConfig + /** + * User specified key-value pairs for the resource. If not present, this defaults to an + * empty dictionary. Individual keys can be removed by setting the value to `null`, and the + * entire metadata mapping can be cleared by setting `metadata` to `null`. + */ + class Metadata @JsonCreator private constructor( @com.fasterxml.jackson.annotation.JsonValue @@ -54240,23 +52437,17 @@ private constructor( companion object { - /** - * Returns a mutable builder for constructing an instance of - * [GroupedWithMinMaxThresholdsConfig]. - */ + /** Returns a mutable builder for constructing an instance of [Metadata]. */ fun builder() = Builder() } - /** A builder for [GroupedWithMinMaxThresholdsConfig]. */ + /** A builder for [Metadata]. */ class Builder internal constructor() { private var additionalProperties: MutableMap = mutableMapOf() - internal fun from( - groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig - ) = apply { - additionalProperties = - groupedWithMinMaxThresholdsConfig.additionalProperties.toMutableMap() + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() } fun additionalProperties(additionalProperties: Map) = apply { @@ -54282,17 +52473,16 @@ private constructor( } /** - * Returns an immutable instance of [GroupedWithMinMaxThresholdsConfig]. + * Returns an immutable instance of [Metadata]. * * Further updates to this [Builder] will not mutate the returned instance. */ - fun build(): GroupedWithMinMaxThresholdsConfig = - GroupedWithMinMaxThresholdsConfig(additionalProperties.toImmutable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } private var validated: Boolean = false - fun validate(): GroupedWithMinMaxThresholdsConfig = apply { + fun validate(): Metadata = apply { if (validated) { return@apply } @@ -54322,51 +52512,144 @@ private constructor( return true } - return other is GroupedWithMinMaxThresholdsConfig && - additionalProperties == other.additionalProperties + return other is Metadata && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { Objects.hash(additionalProperties) } override fun hashCode(): Int = hashCode - override fun toString() = - "GroupedWithMinMaxThresholdsConfig{additionalProperties=$additionalProperties}" + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" } - /** - * User specified key-value pairs for the resource. If not present, this defaults to an - * empty dictionary. Individual keys can be removed by setting the value to `null`, and the - * entire metadata mapping can be cleared by setting `metadata` to `null`. - */ - class Metadata - @JsonCreator + class MinimumConfig private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map + private val minimumAmount: JsonField, + private val prorated: JsonField, + private val additionalProperties: MutableMap, ) { + @JsonCreator + private constructor( + @JsonProperty("minimum_amount") + @ExcludeMissing + minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("prorated") + @ExcludeMissing + prorated: JsonField = JsonMissing.of(), + ) : this(minimumAmount, prorated, mutableMapOf()) + + /** + * The minimum amount to apply + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") + + /** + * By default, subtotals from minimum composite prices are prorated based on the service + * period. Set to false to disable proration. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun prorated(): Boolean? = prorated.getNullable("prorated") + + /** + * Returns the raw JSON value of [minimumAmount]. + * + * Unlike [minimumAmount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount + + /** + * Returns the raw JSON value of [prorated]. + * + * Unlike [prorated], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("prorated") @ExcludeMissing fun _prorated(): JsonField = prorated + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) fun toBuilder() = Builder().from(this) companion object { - /** Returns a mutable builder for constructing an instance of [Metadata]. */ + /** + * Returns a mutable builder for constructing an instance of [MinimumConfig]. + * + * The following fields are required: + * ```kotlin + * .minimumAmount() + * ``` + */ fun builder() = Builder() } - /** A builder for [Metadata]. */ + /** A builder for [MinimumConfig]. */ class Builder internal constructor() { + private var minimumAmount: JsonField? = null + private var prorated: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(metadata: Metadata) = apply { - additionalProperties = metadata.additionalProperties.toMutableMap() + internal fun from(minimumConfig: MinimumConfig) = apply { + minimumAmount = minimumConfig.minimumAmount + prorated = minimumConfig.prorated + additionalProperties = minimumConfig.additionalProperties.toMutableMap() + } + + /** The minimum amount to apply */ + fun minimumAmount(minimumAmount: String) = + minimumAmount(JsonField.of(minimumAmount)) + + /** + * Sets [Builder.minimumAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumAmount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount } + /** + * By default, subtotals from minimum composite prices are prorated based on the + * service period. Set to false to disable proration. + */ + fun prorated(prorated: Boolean?) = prorated(JsonField.ofNullable(prorated)) + + /** + * Alias for [Builder.prorated]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun prorated(prorated: Boolean) = prorated(prorated as Boolean?) + + /** + * Sets [Builder.prorated] to an arbitrary JSON value. + * + * You should usually call [Builder.prorated] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun prorated(prorated: JsonField) = apply { this.prorated = prorated } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -54390,20 +52673,34 @@ private constructor( } /** - * Returns an immutable instance of [Metadata]. + * Returns an immutable instance of [MinimumConfig]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .minimumAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + fun build(): MinimumConfig = + MinimumConfig( + checkRequired("minimumAmount", minimumAmount), + prorated, + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false - fun validate(): Metadata = apply { + fun validate(): MinimumConfig = apply { if (validated) { return@apply } + minimumAmount() + prorated() validated = true } @@ -54422,21 +52719,28 @@ private constructor( * Used for best match union deserialization. */ internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + (if (minimumAmount.asKnown() == null) 0 else 1) + + (if (prorated.asKnown() == null) 0 else 1) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is Metadata && additionalProperties == other.additionalProperties + return other is MinimumConfig && + minimumAmount == other.minimumAmount && + prorated == other.prorated && + additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + private val hashCode: Int by lazy { + Objects.hash(minimumAmount, prorated, additionalProperties) + } override fun hashCode(): Int = hashCode - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + override fun toString() = + "MinimumConfig{minimumAmount=$minimumAmount, prorated=$prorated, additionalProperties=$additionalProperties}" } class PriceType @JsonCreator private constructor(private val value: JsonField) : @@ -54573,11 +52877,12 @@ private constructor( return true } - return other is GroupedWithMinMaxThresholds && + return other is Minimum && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && + compositePriceFilters == other.compositePriceFilters && conversionRate == other.conversionRate && conversionRateConfig == other.conversionRateConfig && createdAt == other.createdAt && @@ -54586,7 +52891,6 @@ private constructor( discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && - groupedWithMinMaxThresholdsConfig == other.groupedWithMinMaxThresholdsConfig && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maximum == other.maximum && @@ -54594,6 +52898,7 @@ private constructor( metadata == other.metadata && minimum == other.minimum && minimumAmount == other.minimumAmount && + minimumConfig == other.minimumConfig && modelType == other.modelType && name == other.name && planPhaseOrder == other.planPhaseOrder && @@ -54609,6 +52914,7 @@ private constructor( billableMetric, billingCycleConfiguration, cadence, + compositePriceFilters, conversionRate, conversionRateConfig, createdAt, @@ -54617,7 +52923,6 @@ private constructor( discount, externalPriceId, fixedPriceQuantity, - groupedWithMinMaxThresholdsConfig, invoicingCycleConfiguration, item, maximum, @@ -54625,6 +52930,7 @@ private constructor( metadata, minimum, minimumAmount, + minimumConfig, modelType, name, planPhaseOrder, @@ -54638,6 +52944,6 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "GroupedWithMinMaxThresholds{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "Minimum{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, minimumConfig=$minimumConfig, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" } } diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceCreateParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceCreateParams.kt index b00d87250..72e7d1257 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceCreateParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceCreateParams.kt @@ -2,6 +2,10 @@ package com.withorb.api.models +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.core.JsonGenerator import com.fasterxml.jackson.core.ObjectCodec import com.fasterxml.jackson.databind.JsonNode @@ -11,13 +15,19 @@ import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import com.withorb.api.core.BaseDeserializer import com.withorb.api.core.BaseSerializer +import com.withorb.api.core.Enum +import com.withorb.api.core.ExcludeMissing +import com.withorb.api.core.JsonField +import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.Params import com.withorb.api.core.checkRequired import com.withorb.api.core.getOrThrow import com.withorb.api.core.http.Headers import com.withorb.api.core.http.QueryParams +import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException +import java.util.Collections import java.util.Objects /** @@ -93,15 +103,6 @@ private constructor( /** Alias for calling [body] with `Body.ofTiered(tiered)`. */ fun body(tiered: NewFloatingTieredPrice) = body(Body.ofTiered(tiered)) - /** Alias for calling [body] with `Body.ofTieredBps(tieredBps)`. */ - fun body(tieredBps: NewFloatingTieredBpsPrice) = body(Body.ofTieredBps(tieredBps)) - - /** Alias for calling [body] with `Body.ofBps(bps)`. */ - fun body(bps: NewFloatingBpsPrice) = body(Body.ofBps(bps)) - - /** Alias for calling [body] with `Body.ofBulkBps(bulkBps)`. */ - fun body(bulkBps: NewFloatingBulkBpsPrice) = body(Body.ofBulkBps(bulkBps)) - /** Alias for calling [body] with `Body.ofBulk(bulk)`. */ fun body(bulk: NewFloatingBulkPrice) = body(Body.ofBulk(bulk)) @@ -196,6 +197,16 @@ private constructor( fun body(cumulativeGroupedBulk: NewFloatingCumulativeGroupedBulkPrice) = body(Body.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) + /** + * Alias for calling [body] with + * `Body.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)`. + */ + fun body(groupedWithMinMaxThresholds: Body.GroupedWithMinMaxThresholds) = + body(Body.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)) + + /** Alias for calling [body] with `Body.ofMinimum(minimum)`. */ + fun body(minimum: Body.Minimum) = body(Body.ofMinimum(minimum)) + fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -329,9 +340,6 @@ private constructor( private val matrix: NewFloatingMatrixPrice? = null, private val matrixWithAllocation: NewFloatingMatrixWithAllocationPrice? = null, private val tiered: NewFloatingTieredPrice? = null, - private val tieredBps: NewFloatingTieredBpsPrice? = null, - private val bps: NewFloatingBpsPrice? = null, - private val bulkBps: NewFloatingBulkBpsPrice? = null, private val bulk: NewFloatingBulkPrice? = null, private val thresholdTotalAmount: NewFloatingThresholdTotalAmountPrice? = null, private val tieredPackage: NewFloatingTieredPackagePrice? = null, @@ -355,6 +363,8 @@ private constructor( NewFloatingScalableMatrixWithTieredPricingPrice? = null, private val cumulativeGroupedBulk: NewFloatingCumulativeGroupedBulkPrice? = null, + private val groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds? = null, + private val minimum: Minimum? = null, private val _json: JsonValue? = null, ) { @@ -368,12 +378,6 @@ private constructor( fun tiered(): NewFloatingTieredPrice? = tiered - fun tieredBps(): NewFloatingTieredBpsPrice? = tieredBps - - fun bps(): NewFloatingBpsPrice? = bps - - fun bulkBps(): NewFloatingBulkBpsPrice? = bulkBps - fun bulk(): NewFloatingBulkPrice? = bulk fun thresholdTotalAmount(): NewFloatingThresholdTotalAmountPrice? = thresholdTotalAmount @@ -419,6 +423,11 @@ private constructor( fun cumulativeGroupedBulk(): NewFloatingCumulativeGroupedBulkPrice? = cumulativeGroupedBulk + fun groupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds? = + groupedWithMinMaxThresholds + + fun minimum(): Minimum? = minimum + fun isUnit(): Boolean = unit != null fun isPackage(): Boolean = package_ != null @@ -429,12 +438,6 @@ private constructor( fun isTiered(): Boolean = tiered != null - fun isTieredBps(): Boolean = tieredBps != null - - fun isBps(): Boolean = bps != null - - fun isBulkBps(): Boolean = bulkBps != null - fun isBulk(): Boolean = bulk != null fun isThresholdTotalAmount(): Boolean = thresholdTotalAmount != null @@ -475,6 +478,10 @@ private constructor( fun isCumulativeGroupedBulk(): Boolean = cumulativeGroupedBulk != null + fun isGroupedWithMinMaxThresholds(): Boolean = groupedWithMinMaxThresholds != null + + fun isMinimum(): Boolean = minimum != null + fun asUnit(): NewFloatingUnitPrice = unit.getOrThrow("unit") fun asPackage(): NewFloatingPackagePrice = package_.getOrThrow("package_") @@ -486,12 +493,6 @@ private constructor( fun asTiered(): NewFloatingTieredPrice = tiered.getOrThrow("tiered") - fun asTieredBps(): NewFloatingTieredBpsPrice = tieredBps.getOrThrow("tieredBps") - - fun asBps(): NewFloatingBpsPrice = bps.getOrThrow("bps") - - fun asBulkBps(): NewFloatingBulkBpsPrice = bulkBps.getOrThrow("bulkBps") - fun asBulk(): NewFloatingBulkPrice = bulk.getOrThrow("bulk") fun asThresholdTotalAmount(): NewFloatingThresholdTotalAmountPrice = @@ -551,6 +552,11 @@ private constructor( fun asCumulativeGroupedBulk(): NewFloatingCumulativeGroupedBulkPrice = cumulativeGroupedBulk.getOrThrow("cumulativeGroupedBulk") + fun asGroupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds = + groupedWithMinMaxThresholds.getOrThrow("groupedWithMinMaxThresholds") + + fun asMinimum(): Minimum = minimum.getOrThrow("minimum") + fun _json(): JsonValue? = _json fun accept(visitor: Visitor): T = @@ -561,9 +567,6 @@ private constructor( matrixWithAllocation != null -> visitor.visitMatrixWithAllocation(matrixWithAllocation) tiered != null -> visitor.visitTiered(tiered) - tieredBps != null -> visitor.visitTieredBps(tieredBps) - bps != null -> visitor.visitBps(bps) - bulkBps != null -> visitor.visitBulkBps(bulkBps) bulk != null -> visitor.visitBulk(bulk) thresholdTotalAmount != null -> visitor.visitThresholdTotalAmount(thresholdTotalAmount) @@ -595,6 +598,9 @@ private constructor( visitor.visitScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing) cumulativeGroupedBulk != null -> visitor.visitCumulativeGroupedBulk(cumulativeGroupedBulk) + groupedWithMinMaxThresholds != null -> + visitor.visitGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds) + minimum != null -> visitor.visitMinimum(minimum) else -> visitor.unknown(_json) } @@ -629,18 +635,6 @@ private constructor( tiered.validate() } - override fun visitTieredBps(tieredBps: NewFloatingTieredBpsPrice) { - tieredBps.validate() - } - - override fun visitBps(bps: NewFloatingBpsPrice) { - bps.validate() - } - - override fun visitBulkBps(bulkBps: NewFloatingBulkBpsPrice) { - bulkBps.validate() - } - override fun visitBulk(bulk: NewFloatingBulkPrice) { bulk.validate() } @@ -755,6 +749,16 @@ private constructor( ) { cumulativeGroupedBulk.validate() } + + override fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) { + groupedWithMinMaxThresholds.validate() + } + + override fun visitMinimum(minimum: Minimum) { + minimum.validate() + } } ) validated = true @@ -790,13 +794,6 @@ private constructor( override fun visitTiered(tiered: NewFloatingTieredPrice) = tiered.validity() - override fun visitTieredBps(tieredBps: NewFloatingTieredBpsPrice) = - tieredBps.validity() - - override fun visitBps(bps: NewFloatingBpsPrice) = bps.validity() - - override fun visitBulkBps(bulkBps: NewFloatingBulkBpsPrice) = bulkBps.validity() - override fun visitBulk(bulk: NewFloatingBulkPrice) = bulk.validity() override fun visitThresholdTotalAmount( @@ -874,6 +871,12 @@ private constructor( cumulativeGroupedBulk: NewFloatingCumulativeGroupedBulkPrice ) = cumulativeGroupedBulk.validity() + override fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) = groupedWithMinMaxThresholds.validity() + + override fun visitMinimum(minimum: Minimum) = minimum.validity() + override fun unknown(json: JsonValue?) = 0 } ) @@ -889,9 +892,6 @@ private constructor( matrix == other.matrix && matrixWithAllocation == other.matrixWithAllocation && tiered == other.tiered && - tieredBps == other.tieredBps && - bps == other.bps && - bulkBps == other.bulkBps && bulk == other.bulk && thresholdTotalAmount == other.thresholdTotalAmount && tieredPackage == other.tieredPackage && @@ -911,7 +911,9 @@ private constructor( groupedTieredPackage == other.groupedTieredPackage && scalableMatrixWithUnitPricing == other.scalableMatrixWithUnitPricing && scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && - cumulativeGroupedBulk == other.cumulativeGroupedBulk + cumulativeGroupedBulk == other.cumulativeGroupedBulk && + groupedWithMinMaxThresholds == other.groupedWithMinMaxThresholds && + minimum == other.minimum } override fun hashCode(): Int = @@ -921,9 +923,6 @@ private constructor( matrix, matrixWithAllocation, tiered, - tieredBps, - bps, - bulkBps, bulk, thresholdTotalAmount, tieredPackage, @@ -944,6 +943,8 @@ private constructor( scalableMatrixWithUnitPricing, scalableMatrixWithTieredPricing, cumulativeGroupedBulk, + groupedWithMinMaxThresholds, + minimum, ) override fun toString(): String = @@ -953,9 +954,6 @@ private constructor( matrix != null -> "Body{matrix=$matrix}" matrixWithAllocation != null -> "Body{matrixWithAllocation=$matrixWithAllocation}" tiered != null -> "Body{tiered=$tiered}" - tieredBps != null -> "Body{tieredBps=$tieredBps}" - bps != null -> "Body{bps=$bps}" - bulkBps != null -> "Body{bulkBps=$bulkBps}" bulk != null -> "Body{bulk=$bulk}" thresholdTotalAmount != null -> "Body{thresholdTotalAmount=$thresholdTotalAmount}" tieredPackage != null -> "Body{tieredPackage=$tieredPackage}" @@ -985,6 +983,9 @@ private constructor( "Body{scalableMatrixWithTieredPricing=$scalableMatrixWithTieredPricing}" cumulativeGroupedBulk != null -> "Body{cumulativeGroupedBulk=$cumulativeGroupedBulk}" + groupedWithMinMaxThresholds != null -> + "Body{groupedWithMinMaxThresholds=$groupedWithMinMaxThresholds}" + minimum != null -> "Body{minimum=$minimum}" _json != null -> "Body{_unknown=$_json}" else -> throw IllegalStateException("Invalid Body") } @@ -1002,12 +1003,6 @@ private constructor( fun ofTiered(tiered: NewFloatingTieredPrice) = Body(tiered = tiered) - fun ofTieredBps(tieredBps: NewFloatingTieredBpsPrice) = Body(tieredBps = tieredBps) - - fun ofBps(bps: NewFloatingBpsPrice) = Body(bps = bps) - - fun ofBulkBps(bulkBps: NewFloatingBulkBpsPrice) = Body(bulkBps = bulkBps) - fun ofBulk(bulk: NewFloatingBulkPrice) = Body(bulk = bulk) fun ofThresholdTotalAmount(thresholdTotalAmount: NewFloatingThresholdTotalAmountPrice) = @@ -1075,6 +1070,12 @@ private constructor( fun ofCumulativeGroupedBulk( cumulativeGroupedBulk: NewFloatingCumulativeGroupedBulkPrice ) = Body(cumulativeGroupedBulk = cumulativeGroupedBulk) + + fun ofGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) = Body(groupedWithMinMaxThresholds = groupedWithMinMaxThresholds) + + fun ofMinimum(minimum: Minimum) = Body(minimum = minimum) } /** An interface that defines how to map each variant of [Body] to a value of type [T]. */ @@ -1092,12 +1093,6 @@ private constructor( fun visitTiered(tiered: NewFloatingTieredPrice): T - fun visitTieredBps(tieredBps: NewFloatingTieredBpsPrice): T - - fun visitBps(bps: NewFloatingBpsPrice): T - - fun visitBulkBps(bulkBps: NewFloatingBulkBpsPrice): T - fun visitBulk(bulk: NewFloatingBulkPrice): T fun visitThresholdTotalAmount( @@ -1162,6 +1157,12 @@ private constructor( cumulativeGroupedBulk: NewFloatingCumulativeGroupedBulkPrice ): T + fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ): T + + fun visitMinimum(minimum: Minimum): T + /** * Maps an unknown variant of [Body] to a value of type [T]. * @@ -1210,19 +1211,6 @@ private constructor( Body(tiered = it, _json = json) } ?: Body(_json = json) } - "tiered_bps" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Body(tieredBps = it, _json = json) } ?: Body(_json = json) - } - "bps" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Body(bps = it, _json = json) - } ?: Body(_json = json) - } - "bulk_bps" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Body(bulkBps = it, _json = json) } ?: Body(_json = json) - } "bulk" -> { return tryDeserialize(node, jacksonTypeRef())?.let { Body(bulk = it, _json = json) @@ -1371,6 +1359,16 @@ private constructor( ?.let { Body(cumulativeGroupedBulk = it, _json = json) } ?: Body(_json = json) } + "grouped_with_min_max_thresholds" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Body(groupedWithMinMaxThresholds = it, _json = json) } + ?: Body(_json = json) + } + "minimum" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Body(minimum = it, _json = json) + } ?: Body(_json = json) + } } return Body(_json = json) @@ -1391,9 +1389,6 @@ private constructor( value.matrixWithAllocation != null -> generator.writeObject(value.matrixWithAllocation) value.tiered != null -> generator.writeObject(value.tiered) - value.tieredBps != null -> generator.writeObject(value.tieredBps) - value.bps != null -> generator.writeObject(value.bps) - value.bulkBps != null -> generator.writeObject(value.bulkBps) value.bulk != null -> generator.writeObject(value.bulk) value.thresholdTotalAmount != null -> generator.writeObject(value.thresholdTotalAmount) @@ -1430,11 +1425,2886 @@ private constructor( generator.writeObject(value.scalableMatrixWithTieredPricing) value.cumulativeGroupedBulk != null -> generator.writeObject(value.cumulativeGroupedBulk) + value.groupedWithMinMaxThresholds != null -> + generator.writeObject(value.groupedWithMinMaxThresholds) + value.minimum != null -> generator.writeObject(value.minimum) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid Body") } } } + + class GroupedWithMinMaxThresholds + private constructor( + private val cadence: JsonField, + private val currency: JsonField, + private val groupedWithMinMaxThresholdsConfig: + JsonField, + private val itemId: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val dimensionalPriceConfiguration: JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val metadata: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("grouped_with_min_max_thresholds_config") + @ExcludeMissing + groupedWithMinMaxThresholdsConfig: JsonField = + JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") @ExcludeMissing modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + ) : this( + cadence, + currency, + groupedWithMinMaxThresholdsConfig, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * An ISO 4217 currency string for which this price is billed in. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupedWithMinMaxThresholdsConfig(): GroupedWithMinMaxThresholdsConfig = + groupedWithMinMaxThresholdsConfig.getRequired( + "grouped_with_min_max_thresholds_config" + ) + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * Expected to always return the following: + * ```kotlin + * JsonValue.from("grouped_with_min_max_thresholds") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun billableMetricId(): String? = billableMetricId.getNullable("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + invoiceGroupingKey.getNullable("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [groupedWithMinMaxThresholdsConfig]. + * + * Unlike [groupedWithMinMaxThresholdsConfig], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("grouped_with_min_max_thresholds_config") + @ExcludeMissing + fun _groupedWithMinMaxThresholdsConfig(): JsonField = + groupedWithMinMaxThresholdsConfig + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [GroupedWithMinMaxThresholds]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .currency() + * .groupedWithMinMaxThresholdsConfig() + * .itemId() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [GroupedWithMinMaxThresholds]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var currency: JsonField? = null + private var groupedWithMinMaxThresholdsConfig: + JsonField? = + null + private var itemId: JsonField? = null + private var modelType: JsonValue = JsonValue.from("grouped_with_min_max_thresholds") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds) = + apply { + cadence = groupedWithMinMaxThresholds.cadence + currency = groupedWithMinMaxThresholds.currency + groupedWithMinMaxThresholdsConfig = + groupedWithMinMaxThresholds.groupedWithMinMaxThresholdsConfig + itemId = groupedWithMinMaxThresholds.itemId + modelType = groupedWithMinMaxThresholds.modelType + name = groupedWithMinMaxThresholds.name + billableMetricId = groupedWithMinMaxThresholds.billableMetricId + billedInAdvance = groupedWithMinMaxThresholds.billedInAdvance + billingCycleConfiguration = + groupedWithMinMaxThresholds.billingCycleConfiguration + conversionRate = groupedWithMinMaxThresholds.conversionRate + conversionRateConfig = groupedWithMinMaxThresholds.conversionRateConfig + dimensionalPriceConfiguration = + groupedWithMinMaxThresholds.dimensionalPriceConfiguration + externalPriceId = groupedWithMinMaxThresholds.externalPriceId + fixedPriceQuantity = groupedWithMinMaxThresholds.fixedPriceQuantity + invoiceGroupingKey = groupedWithMinMaxThresholds.invoiceGroupingKey + invoicingCycleConfiguration = + groupedWithMinMaxThresholds.invoicingCycleConfiguration + metadata = groupedWithMinMaxThresholds.metadata + additionalProperties = + groupedWithMinMaxThresholds.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + fun groupedWithMinMaxThresholdsConfig( + groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + ) = + groupedWithMinMaxThresholdsConfig( + JsonField.of(groupedWithMinMaxThresholdsConfig) + ) + + /** + * Sets [Builder.groupedWithMinMaxThresholdsConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.groupedWithMinMaxThresholdsConfig] with a + * well-typed [GroupedWithMinMaxThresholdsConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported value. + */ + fun groupedWithMinMaxThresholdsConfig( + groupedWithMinMaxThresholdsConfig: JsonField + ) = apply { + this.groupedWithMinMaxThresholdsConfig = groupedWithMinMaxThresholdsConfig + } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```kotlin + * JsonValue.from("grouped_with_min_max_thresholds") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun conversionRateConfig(conversionRateConfig: JsonField) = + apply { + this.conversionRateConfig = conversionRateConfig + } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a well-typed + * [NewDimensionalPriceConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [GroupedWithMinMaxThresholds]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .currency() + * .groupedWithMinMaxThresholdsConfig() + * .itemId() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedWithMinMaxThresholds = + GroupedWithMinMaxThresholds( + checkRequired("cadence", cadence), + checkRequired("currency", currency), + checkRequired( + "groupedWithMinMaxThresholdsConfig", + groupedWithMinMaxThresholdsConfig, + ), + checkRequired("itemId", itemId), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GroupedWithMinMaxThresholds = apply { + if (validated) { + return@apply + } + + cadence().validate() + currency() + groupedWithMinMaxThresholdsConfig().validate() + itemId() + _modelType().let { + if (it != JsonValue.from("grouped_with_min_max_thresholds")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + metadata()?.validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (groupedWithMinMaxThresholdsConfig.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + modelType.let { + if (it == JsonValue.from("grouped_with_min_max_thresholds")) 1 else 0 + } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (metadata.asKnown()?.validity() ?: 0) + + /** The cadence to bill for this price on. */ + class Cadence @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class GroupedWithMinMaxThresholdsConfig + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [GroupedWithMinMaxThresholdsConfig]. + */ + fun builder() = Builder() + } + + /** A builder for [GroupedWithMinMaxThresholdsConfig]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from( + groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + ) = apply { + additionalProperties = + groupedWithMinMaxThresholdsConfig.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [GroupedWithMinMaxThresholdsConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): GroupedWithMinMaxThresholdsConfig = + GroupedWithMinMaxThresholdsConfig(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): GroupedWithMinMaxThresholdsConfig = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedWithMinMaxThresholdsConfig && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedWithMinMaxThresholdsConfig{additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedWithMinMaxThresholds && + cadence == other.cadence && + currency == other.currency && + groupedWithMinMaxThresholdsConfig == other.groupedWithMinMaxThresholdsConfig && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + currency, + groupedWithMinMaxThresholdsConfig, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedWithMinMaxThresholds{cadence=$cadence, currency=$currency, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + } + + class Minimum + private constructor( + private val cadence: JsonField, + private val currency: JsonField, + private val itemId: JsonField, + private val minimumConfig: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val dimensionalPriceConfiguration: JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val metadata: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("minimum_config") + @ExcludeMissing + minimumConfig: JsonField = JsonMissing.of(), + @JsonProperty("model_type") @ExcludeMissing modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + ) : this( + cadence, + currency, + itemId, + minimumConfig, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * An ISO 4217 currency string for which this price is billed in. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun minimumConfig(): MinimumConfig = minimumConfig.getRequired("minimum_config") + + /** + * Expected to always return the following: + * ```kotlin + * JsonValue.from("minimum") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun billableMetricId(): String? = billableMetricId.getNullable("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + invoiceGroupingKey.getNullable("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [minimumConfig]. + * + * Unlike [minimumConfig], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("minimum_config") + @ExcludeMissing + fun _minimumConfig(): JsonField = minimumConfig + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Minimum]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .currency() + * .itemId() + * .minimumConfig() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Minimum]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var currency: JsonField? = null + private var itemId: JsonField? = null + private var minimumConfig: JsonField? = null + private var modelType: JsonValue = JsonValue.from("minimum") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(minimum: Minimum) = apply { + cadence = minimum.cadence + currency = minimum.currency + itemId = minimum.itemId + minimumConfig = minimum.minimumConfig + modelType = minimum.modelType + name = minimum.name + billableMetricId = minimum.billableMetricId + billedInAdvance = minimum.billedInAdvance + billingCycleConfiguration = minimum.billingCycleConfiguration + conversionRate = minimum.conversionRate + conversionRateConfig = minimum.conversionRateConfig + dimensionalPriceConfiguration = minimum.dimensionalPriceConfiguration + externalPriceId = minimum.externalPriceId + fixedPriceQuantity = minimum.fixedPriceQuantity + invoiceGroupingKey = minimum.invoiceGroupingKey + invoicingCycleConfiguration = minimum.invoicingCycleConfiguration + metadata = minimum.metadata + additionalProperties = minimum.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun minimumConfig(minimumConfig: MinimumConfig) = + minimumConfig(JsonField.of(minimumConfig)) + + /** + * Sets [Builder.minimumConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumConfig] with a well-typed [MinimumConfig] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun minimumConfig(minimumConfig: JsonField) = apply { + this.minimumConfig = minimumConfig + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```kotlin + * JsonValue.from("minimum") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun conversionRateConfig(conversionRateConfig: JsonField) = + apply { + this.conversionRateConfig = conversionRateConfig + } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a well-typed + * [NewDimensionalPriceConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Minimum]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .currency() + * .itemId() + * .minimumConfig() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Minimum = + Minimum( + checkRequired("cadence", cadence), + checkRequired("currency", currency), + checkRequired("itemId", itemId), + checkRequired("minimumConfig", minimumConfig), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Minimum = apply { + if (validated) { + return@apply + } + + cadence().validate() + currency() + itemId() + minimumConfig().validate() + _modelType().let { + if (it != JsonValue.from("minimum")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + metadata()?.validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (if (itemId.asKnown() == null) 0 else 1) + + (minimumConfig.asKnown()?.validity() ?: 0) + + modelType.let { if (it == JsonValue.from("minimum")) 1 else 0 } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (metadata.asKnown()?.validity() ?: 0) + + /** The cadence to bill for this price on. */ + class Cadence @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class MinimumConfig + private constructor( + private val minimumAmount: JsonField, + private val prorated: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("minimum_amount") + @ExcludeMissing + minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("prorated") + @ExcludeMissing + prorated: JsonField = JsonMissing.of(), + ) : this(minimumAmount, prorated, mutableMapOf()) + + /** + * The minimum amount to apply + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") + + /** + * By default, subtotals from minimum composite prices are prorated based on the + * service period. Set to false to disable proration. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun prorated(): Boolean? = prorated.getNullable("prorated") + + /** + * Returns the raw JSON value of [minimumAmount]. + * + * Unlike [minimumAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount + + /** + * Returns the raw JSON value of [prorated]. + * + * Unlike [prorated], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("prorated") + @ExcludeMissing + fun _prorated(): JsonField = prorated + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [MinimumConfig]. + * + * The following fields are required: + * ```kotlin + * .minimumAmount() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [MinimumConfig]. */ + class Builder internal constructor() { + + private var minimumAmount: JsonField? = null + private var prorated: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(minimumConfig: MinimumConfig) = apply { + minimumAmount = minimumConfig.minimumAmount + prorated = minimumConfig.prorated + additionalProperties = minimumConfig.additionalProperties.toMutableMap() + } + + /** The minimum amount to apply */ + fun minimumAmount(minimumAmount: String) = + minimumAmount(JsonField.of(minimumAmount)) + + /** + * Sets [Builder.minimumAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumAmount] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount + } + + /** + * By default, subtotals from minimum composite prices are prorated based on the + * service period. Set to false to disable proration. + */ + fun prorated(prorated: Boolean?) = prorated(JsonField.ofNullable(prorated)) + + /** + * Alias for [Builder.prorated]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun prorated(prorated: Boolean) = prorated(prorated as Boolean?) + + /** + * Sets [Builder.prorated] to an arbitrary JSON value. + * + * You should usually call [Builder.prorated] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun prorated(prorated: JsonField) = apply { this.prorated = prorated } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [MinimumConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .minimumAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MinimumConfig = + MinimumConfig( + checkRequired("minimumAmount", minimumAmount), + prorated, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MinimumConfig = apply { + if (validated) { + return@apply + } + + minimumAmount() + prorated() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (minimumAmount.asKnown() == null) 0 else 1) + + (if (prorated.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MinimumConfig && + minimumAmount == other.minimumAmount && + prorated == other.prorated && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(minimumAmount, prorated, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MinimumConfig{minimumAmount=$minimumAmount, prorated=$prorated, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Minimum && + cadence == other.cadence && + currency == other.currency && + itemId == other.itemId && + minimumConfig == other.minimumConfig && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + currency, + itemId, + minimumConfig, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Minimum{cadence=$cadence, currency=$currency, itemId=$itemId, minimumConfig=$minimumConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + } } override fun equals(other: Any?): Boolean { diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceEvaluateMultipleParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceEvaluateMultipleParams.kt index d41c3376d..3541d4657 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceEvaluateMultipleParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceEvaluateMultipleParams.kt @@ -15,6 +15,7 @@ import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import com.withorb.api.core.BaseDeserializer import com.withorb.api.core.BaseSerializer +import com.withorb.api.core.Enum import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing @@ -1022,15 +1023,6 @@ private constructor( /** Alias for calling [price] with `Price.ofTiered(tiered)`. */ fun price(tiered: NewFloatingTieredPrice) = price(Price.ofTiered(tiered)) - /** Alias for calling [price] with `Price.ofTieredBps(tieredBps)`. */ - fun price(tieredBps: NewFloatingTieredBpsPrice) = price(Price.ofTieredBps(tieredBps)) - - /** Alias for calling [price] with `Price.ofBps(bps)`. */ - fun price(bps: NewFloatingBpsPrice) = price(Price.ofBps(bps)) - - /** Alias for calling [price] with `Price.ofBulkBps(bulkBps)`. */ - fun price(bulkBps: NewFloatingBulkBpsPrice) = price(Price.ofBulkBps(bulkBps)) - /** Alias for calling [price] with `Price.ofBulk(bulk)`. */ fun price(bulk: NewFloatingBulkPrice) = price(Price.ofBulk(bulk)) @@ -1145,6 +1137,16 @@ private constructor( fun price(cumulativeGroupedBulk: NewFloatingCumulativeGroupedBulkPrice) = price(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) + /** + * Alias for calling [price] with + * `Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)`. + */ + fun price(groupedWithMinMaxThresholds: Price.GroupedWithMinMaxThresholds) = + price(Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)) + + /** Alias for calling [price] with `Price.ofMinimum(minimum)`. */ + fun price(minimum: Price.Minimum) = price(Price.ofMinimum(minimum)) + /** The ID of a price to evaluate that exists in your Orb account. */ fun priceId(priceId: String?) = priceId(JsonField.ofNullable(priceId)) @@ -1241,9 +1243,6 @@ private constructor( private val matrix: NewFloatingMatrixPrice? = null, private val matrixWithAllocation: NewFloatingMatrixWithAllocationPrice? = null, private val tiered: NewFloatingTieredPrice? = null, - private val tieredBps: NewFloatingTieredBpsPrice? = null, - private val bps: NewFloatingBpsPrice? = null, - private val bulkBps: NewFloatingBulkBpsPrice? = null, private val bulk: NewFloatingBulkPrice? = null, private val thresholdTotalAmount: NewFloatingThresholdTotalAmountPrice? = null, private val tieredPackage: NewFloatingTieredPackagePrice? = null, @@ -1270,6 +1269,8 @@ private constructor( NewFloatingScalableMatrixWithTieredPricingPrice? = null, private val cumulativeGroupedBulk: NewFloatingCumulativeGroupedBulkPrice? = null, + private val groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds? = null, + private val minimum: Minimum? = null, private val _json: JsonValue? = null, ) { @@ -1283,12 +1284,6 @@ private constructor( fun tiered(): NewFloatingTieredPrice? = tiered - fun tieredBps(): NewFloatingTieredBpsPrice? = tieredBps - - fun bps(): NewFloatingBpsPrice? = bps - - fun bulkBps(): NewFloatingBulkBpsPrice? = bulkBps - fun bulk(): NewFloatingBulkPrice? = bulk fun thresholdTotalAmount(): NewFloatingThresholdTotalAmountPrice? = thresholdTotalAmount @@ -1338,6 +1333,11 @@ private constructor( fun cumulativeGroupedBulk(): NewFloatingCumulativeGroupedBulkPrice? = cumulativeGroupedBulk + fun groupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds? = + groupedWithMinMaxThresholds + + fun minimum(): Minimum? = minimum + fun isUnit(): Boolean = unit != null fun isPackage(): Boolean = package_ != null @@ -1348,12 +1348,6 @@ private constructor( fun isTiered(): Boolean = tiered != null - fun isTieredBps(): Boolean = tieredBps != null - - fun isBps(): Boolean = bps != null - - fun isBulkBps(): Boolean = bulkBps != null - fun isBulk(): Boolean = bulk != null fun isThresholdTotalAmount(): Boolean = thresholdTotalAmount != null @@ -1395,6 +1389,10 @@ private constructor( fun isCumulativeGroupedBulk(): Boolean = cumulativeGroupedBulk != null + fun isGroupedWithMinMaxThresholds(): Boolean = groupedWithMinMaxThresholds != null + + fun isMinimum(): Boolean = minimum != null + fun asUnit(): NewFloatingUnitPrice = unit.getOrThrow("unit") fun asPackage(): NewFloatingPackagePrice = package_.getOrThrow("package_") @@ -1406,12 +1404,6 @@ private constructor( fun asTiered(): NewFloatingTieredPrice = tiered.getOrThrow("tiered") - fun asTieredBps(): NewFloatingTieredBpsPrice = tieredBps.getOrThrow("tieredBps") - - fun asBps(): NewFloatingBpsPrice = bps.getOrThrow("bps") - - fun asBulkBps(): NewFloatingBulkBpsPrice = bulkBps.getOrThrow("bulkBps") - fun asBulk(): NewFloatingBulkPrice = bulk.getOrThrow("bulk") fun asThresholdTotalAmount(): NewFloatingThresholdTotalAmountPrice = @@ -1472,6 +1464,11 @@ private constructor( fun asCumulativeGroupedBulk(): NewFloatingCumulativeGroupedBulkPrice = cumulativeGroupedBulk.getOrThrow("cumulativeGroupedBulk") + fun asGroupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds = + groupedWithMinMaxThresholds.getOrThrow("groupedWithMinMaxThresholds") + + fun asMinimum(): Minimum = minimum.getOrThrow("minimum") + fun _json(): JsonValue? = _json fun accept(visitor: Visitor): T = @@ -1482,9 +1479,6 @@ private constructor( matrixWithAllocation != null -> visitor.visitMatrixWithAllocation(matrixWithAllocation) tiered != null -> visitor.visitTiered(tiered) - tieredBps != null -> visitor.visitTieredBps(tieredBps) - bps != null -> visitor.visitBps(bps) - bulkBps != null -> visitor.visitBulkBps(bulkBps) bulk != null -> visitor.visitBulk(bulk) thresholdTotalAmount != null -> visitor.visitThresholdTotalAmount(thresholdTotalAmount) @@ -1519,6 +1513,9 @@ private constructor( ) cumulativeGroupedBulk != null -> visitor.visitCumulativeGroupedBulk(cumulativeGroupedBulk) + groupedWithMinMaxThresholds != null -> + visitor.visitGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds) + minimum != null -> visitor.visitMinimum(minimum) else -> visitor.unknown(_json) } @@ -1553,18 +1550,6 @@ private constructor( tiered.validate() } - override fun visitTieredBps(tieredBps: NewFloatingTieredBpsPrice) { - tieredBps.validate() - } - - override fun visitBps(bps: NewFloatingBpsPrice) { - bps.validate() - } - - override fun visitBulkBps(bulkBps: NewFloatingBulkBpsPrice) { - bulkBps.validate() - } - override fun visitBulk(bulk: NewFloatingBulkPrice) { bulk.validate() } @@ -1684,6 +1669,16 @@ private constructor( ) { cumulativeGroupedBulk.validate() } + + override fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) { + groupedWithMinMaxThresholds.validate() + } + + override fun visitMinimum(minimum: Minimum) { + minimum.validate() + } } ) validated = true @@ -1719,14 +1714,6 @@ private constructor( override fun visitTiered(tiered: NewFloatingTieredPrice) = tiered.validity() - override fun visitTieredBps(tieredBps: NewFloatingTieredBpsPrice) = - tieredBps.validity() - - override fun visitBps(bps: NewFloatingBpsPrice) = bps.validity() - - override fun visitBulkBps(bulkBps: NewFloatingBulkBpsPrice) = - bulkBps.validity() - override fun visitBulk(bulk: NewFloatingBulkPrice) = bulk.validity() override fun visitThresholdTotalAmount( @@ -1807,6 +1794,12 @@ private constructor( cumulativeGroupedBulk: NewFloatingCumulativeGroupedBulkPrice ) = cumulativeGroupedBulk.validity() + override fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) = groupedWithMinMaxThresholds.validity() + + override fun visitMinimum(minimum: Minimum) = minimum.validity() + override fun unknown(json: JsonValue?) = 0 } ) @@ -1822,9 +1815,6 @@ private constructor( matrix == other.matrix && matrixWithAllocation == other.matrixWithAllocation && tiered == other.tiered && - tieredBps == other.tieredBps && - bps == other.bps && - bulkBps == other.bulkBps && bulk == other.bulk && thresholdTotalAmount == other.thresholdTotalAmount && tieredPackage == other.tieredPackage && @@ -1844,7 +1834,9 @@ private constructor( groupedTieredPackage == other.groupedTieredPackage && scalableMatrixWithUnitPricing == other.scalableMatrixWithUnitPricing && scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && - cumulativeGroupedBulk == other.cumulativeGroupedBulk + cumulativeGroupedBulk == other.cumulativeGroupedBulk && + groupedWithMinMaxThresholds == other.groupedWithMinMaxThresholds && + minimum == other.minimum } override fun hashCode(): Int = @@ -1854,9 +1846,6 @@ private constructor( matrix, matrixWithAllocation, tiered, - tieredBps, - bps, - bulkBps, bulk, thresholdTotalAmount, tieredPackage, @@ -1877,6 +1866,8 @@ private constructor( scalableMatrixWithUnitPricing, scalableMatrixWithTieredPricing, cumulativeGroupedBulk, + groupedWithMinMaxThresholds, + minimum, ) override fun toString(): String = @@ -1887,9 +1878,6 @@ private constructor( matrixWithAllocation != null -> "Price{matrixWithAllocation=$matrixWithAllocation}" tiered != null -> "Price{tiered=$tiered}" - tieredBps != null -> "Price{tieredBps=$tieredBps}" - bps != null -> "Price{bps=$bps}" - bulkBps != null -> "Price{bulkBps=$bulkBps}" bulk != null -> "Price{bulk=$bulk}" thresholdTotalAmount != null -> "Price{thresholdTotalAmount=$thresholdTotalAmount}" @@ -1921,6 +1909,9 @@ private constructor( "Price{scalableMatrixWithTieredPricing=$scalableMatrixWithTieredPricing}" cumulativeGroupedBulk != null -> "Price{cumulativeGroupedBulk=$cumulativeGroupedBulk}" + groupedWithMinMaxThresholds != null -> + "Price{groupedWithMinMaxThresholds=$groupedWithMinMaxThresholds}" + minimum != null -> "Price{minimum=$minimum}" _json != null -> "Price{_unknown=$_json}" else -> throw IllegalStateException("Invalid Price") } @@ -1939,12 +1930,6 @@ private constructor( fun ofTiered(tiered: NewFloatingTieredPrice) = Price(tiered = tiered) - fun ofTieredBps(tieredBps: NewFloatingTieredBpsPrice) = Price(tieredBps = tieredBps) - - fun ofBps(bps: NewFloatingBpsPrice) = Price(bps = bps) - - fun ofBulkBps(bulkBps: NewFloatingBulkBpsPrice) = Price(bulkBps = bulkBps) - fun ofBulk(bulk: NewFloatingBulkPrice) = Price(bulk = bulk) fun ofThresholdTotalAmount( @@ -2015,6 +2000,12 @@ private constructor( fun ofCumulativeGroupedBulk( cumulativeGroupedBulk: NewFloatingCumulativeGroupedBulkPrice ) = Price(cumulativeGroupedBulk = cumulativeGroupedBulk) + + fun ofGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) = Price(groupedWithMinMaxThresholds = groupedWithMinMaxThresholds) + + fun ofMinimum(minimum: Minimum) = Price(minimum = minimum) } /** @@ -2034,12 +2025,6 @@ private constructor( fun visitTiered(tiered: NewFloatingTieredPrice): T - fun visitTieredBps(tieredBps: NewFloatingTieredBpsPrice): T - - fun visitBps(bps: NewFloatingBpsPrice): T - - fun visitBulkBps(bulkBps: NewFloatingBulkBpsPrice): T - fun visitBulk(bulk: NewFloatingBulkPrice): T fun visitThresholdTotalAmount( @@ -2104,6 +2089,12 @@ private constructor( cumulativeGroupedBulk: NewFloatingCumulativeGroupedBulkPrice ): T + fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ): T + + fun visitMinimum(minimum: Minimum): T + /** * Maps an unknown variant of [Price] to a value of type [T]. * @@ -2150,18 +2141,6 @@ private constructor( return tryDeserialize(node, jacksonTypeRef()) ?.let { Price(tiered = it, _json = json) } ?: Price(_json = json) } - "tiered_bps" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(tieredBps = it, _json = json) } ?: Price(_json = json) - } - "bps" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(bps = it, _json = json) } ?: Price(_json = json) - } - "bulk_bps" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(bulkBps = it, _json = json) } ?: Price(_json = json) - } "bulk" -> { return tryDeserialize(node, jacksonTypeRef()) ?.let { Price(bulk = it, _json = json) } ?: Price(_json = json) @@ -2320,6 +2299,19 @@ private constructor( ?.let { Price(cumulativeGroupedBulk = it, _json = json) } ?: Price(_json = json) } + "grouped_with_min_max_thresholds" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedWithMinMaxThresholds = it, _json = json) } + ?: Price(_json = json) + } + "minimum" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(minimum = it, _json = json) + } ?: Price(_json = json) + } } return Price(_json = json) @@ -2340,9 +2332,6 @@ private constructor( value.matrixWithAllocation != null -> generator.writeObject(value.matrixWithAllocation) value.tiered != null -> generator.writeObject(value.tiered) - value.tieredBps != null -> generator.writeObject(value.tieredBps) - value.bps != null -> generator.writeObject(value.bps) - value.bulkBps != null -> generator.writeObject(value.bulkBps) value.bulk != null -> generator.writeObject(value.bulk) value.thresholdTotalAmount != null -> generator.writeObject(value.thresholdTotalAmount) @@ -2380,11 +2369,2959 @@ private constructor( generator.writeObject(value.scalableMatrixWithTieredPricing) value.cumulativeGroupedBulk != null -> generator.writeObject(value.cumulativeGroupedBulk) + value.groupedWithMinMaxThresholds != null -> + generator.writeObject(value.groupedWithMinMaxThresholds) + value.minimum != null -> generator.writeObject(value.minimum) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid Price") } } } + + class GroupedWithMinMaxThresholds + private constructor( + private val cadence: JsonField, + private val currency: JsonField, + private val groupedWithMinMaxThresholdsConfig: + JsonField, + private val itemId: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val metadata: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("grouped_with_min_max_thresholds_config") + @ExcludeMissing + groupedWithMinMaxThresholdsConfig: + JsonField = + JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + ) : this( + cadence, + currency, + groupedWithMinMaxThresholdsConfig, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * An ISO 4217 currency string for which this price is billed in. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupedWithMinMaxThresholdsConfig(): GroupedWithMinMaxThresholdsConfig = + groupedWithMinMaxThresholdsConfig.getRequired( + "grouped_with_min_max_thresholds_config" + ) + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * Expected to always return the following: + * ```kotlin + * JsonValue.from("grouped_with_min_max_thresholds") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = billableMetricId.getNullable("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + invoiceGroupingKey.getNullable("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [groupedWithMinMaxThresholdsConfig]. + * + * Unlike [groupedWithMinMaxThresholdsConfig], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("grouped_with_min_max_thresholds_config") + @ExcludeMissing + fun _groupedWithMinMaxThresholdsConfig(): + JsonField = groupedWithMinMaxThresholdsConfig + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [GroupedWithMinMaxThresholds]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .currency() + * .groupedWithMinMaxThresholdsConfig() + * .itemId() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [GroupedWithMinMaxThresholds]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var currency: JsonField? = null + private var groupedWithMinMaxThresholdsConfig: + JsonField? = + null + private var itemId: JsonField? = null + private var modelType: JsonValue = + JsonValue.from("grouped_with_min_max_thresholds") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds) = + apply { + cadence = groupedWithMinMaxThresholds.cadence + currency = groupedWithMinMaxThresholds.currency + groupedWithMinMaxThresholdsConfig = + groupedWithMinMaxThresholds.groupedWithMinMaxThresholdsConfig + itemId = groupedWithMinMaxThresholds.itemId + modelType = groupedWithMinMaxThresholds.modelType + name = groupedWithMinMaxThresholds.name + billableMetricId = groupedWithMinMaxThresholds.billableMetricId + billedInAdvance = groupedWithMinMaxThresholds.billedInAdvance + billingCycleConfiguration = + groupedWithMinMaxThresholds.billingCycleConfiguration + conversionRate = groupedWithMinMaxThresholds.conversionRate + conversionRateConfig = groupedWithMinMaxThresholds.conversionRateConfig + dimensionalPriceConfiguration = + groupedWithMinMaxThresholds.dimensionalPriceConfiguration + externalPriceId = groupedWithMinMaxThresholds.externalPriceId + fixedPriceQuantity = groupedWithMinMaxThresholds.fixedPriceQuantity + invoiceGroupingKey = groupedWithMinMaxThresholds.invoiceGroupingKey + invoicingCycleConfiguration = + groupedWithMinMaxThresholds.invoicingCycleConfiguration + metadata = groupedWithMinMaxThresholds.metadata + additionalProperties = + groupedWithMinMaxThresholds.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + fun groupedWithMinMaxThresholdsConfig( + groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + ) = + groupedWithMinMaxThresholdsConfig( + JsonField.of(groupedWithMinMaxThresholdsConfig) + ) + + /** + * Sets [Builder.groupedWithMinMaxThresholdsConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.groupedWithMinMaxThresholdsConfig] with a + * well-typed [GroupedWithMinMaxThresholdsConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun groupedWithMinMaxThresholdsConfig( + groupedWithMinMaxThresholdsConfig: + JsonField + ) = apply { + this.groupedWithMinMaxThresholdsConfig = groupedWithMinMaxThresholdsConfig + } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("grouped_with_min_max_thresholds") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [GroupedWithMinMaxThresholds]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .currency() + * .groupedWithMinMaxThresholdsConfig() + * .itemId() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedWithMinMaxThresholds = + GroupedWithMinMaxThresholds( + checkRequired("cadence", cadence), + checkRequired("currency", currency), + checkRequired( + "groupedWithMinMaxThresholdsConfig", + groupedWithMinMaxThresholdsConfig, + ), + checkRequired("itemId", itemId), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GroupedWithMinMaxThresholds = apply { + if (validated) { + return@apply + } + + cadence().validate() + currency() + groupedWithMinMaxThresholdsConfig().validate() + itemId() + _modelType().let { + if (it != JsonValue.from("grouped_with_min_max_thresholds")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + metadata()?.validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (groupedWithMinMaxThresholdsConfig.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + modelType.let { + if (it == JsonValue.from("grouped_with_min_max_thresholds")) 1 else 0 + } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (metadata.asKnown()?.validity() ?: 0) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class GroupedWithMinMaxThresholdsConfig + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [GroupedWithMinMaxThresholdsConfig]. + */ + fun builder() = Builder() + } + + /** A builder for [GroupedWithMinMaxThresholdsConfig]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from( + groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + ) = apply { + additionalProperties = + groupedWithMinMaxThresholdsConfig.additionalProperties + .toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [GroupedWithMinMaxThresholdsConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): GroupedWithMinMaxThresholdsConfig = + GroupedWithMinMaxThresholdsConfig(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): GroupedWithMinMaxThresholdsConfig = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedWithMinMaxThresholdsConfig && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedWithMinMaxThresholdsConfig{additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedWithMinMaxThresholds && + cadence == other.cadence && + currency == other.currency && + groupedWithMinMaxThresholdsConfig == + other.groupedWithMinMaxThresholdsConfig && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + currency, + groupedWithMinMaxThresholdsConfig, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedWithMinMaxThresholds{cadence=$cadence, currency=$currency, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + } + + class Minimum + private constructor( + private val cadence: JsonField, + private val currency: JsonField, + private val itemId: JsonField, + private val minimumConfig: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val metadata: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("minimum_config") + @ExcludeMissing + minimumConfig: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + ) : this( + cadence, + currency, + itemId, + minimumConfig, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * An ISO 4217 currency string for which this price is billed in. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun minimumConfig(): MinimumConfig = minimumConfig.getRequired("minimum_config") + + /** + * Expected to always return the following: + * ```kotlin + * JsonValue.from("minimum") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = billableMetricId.getNullable("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + invoiceGroupingKey.getNullable("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [minimumConfig]. + * + * Unlike [minimumConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("minimum_config") + @ExcludeMissing + fun _minimumConfig(): JsonField = minimumConfig + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Minimum]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .currency() + * .itemId() + * .minimumConfig() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Minimum]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var currency: JsonField? = null + private var itemId: JsonField? = null + private var minimumConfig: JsonField? = null + private var modelType: JsonValue = JsonValue.from("minimum") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(minimum: Minimum) = apply { + cadence = minimum.cadence + currency = minimum.currency + itemId = minimum.itemId + minimumConfig = minimum.minimumConfig + modelType = minimum.modelType + name = minimum.name + billableMetricId = minimum.billableMetricId + billedInAdvance = minimum.billedInAdvance + billingCycleConfiguration = minimum.billingCycleConfiguration + conversionRate = minimum.conversionRate + conversionRateConfig = minimum.conversionRateConfig + dimensionalPriceConfiguration = minimum.dimensionalPriceConfiguration + externalPriceId = minimum.externalPriceId + fixedPriceQuantity = minimum.fixedPriceQuantity + invoiceGroupingKey = minimum.invoiceGroupingKey + invoicingCycleConfiguration = minimum.invoicingCycleConfiguration + metadata = minimum.metadata + additionalProperties = minimum.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun minimumConfig(minimumConfig: MinimumConfig) = + minimumConfig(JsonField.of(minimumConfig)) + + /** + * Sets [Builder.minimumConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumConfig] with a well-typed + * [MinimumConfig] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun minimumConfig(minimumConfig: JsonField) = apply { + this.minimumConfig = minimumConfig + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("minimum") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Minimum]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .currency() + * .itemId() + * .minimumConfig() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Minimum = + Minimum( + checkRequired("cadence", cadence), + checkRequired("currency", currency), + checkRequired("itemId", itemId), + checkRequired("minimumConfig", minimumConfig), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Minimum = apply { + if (validated) { + return@apply + } + + cadence().validate() + currency() + itemId() + minimumConfig().validate() + _modelType().let { + if (it != JsonValue.from("minimum")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + metadata()?.validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (if (itemId.asKnown() == null) 0 else 1) + + (minimumConfig.asKnown()?.validity() ?: 0) + + modelType.let { if (it == JsonValue.from("minimum")) 1 else 0 } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (metadata.asKnown()?.validity() ?: 0) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class MinimumConfig + private constructor( + private val minimumAmount: JsonField, + private val prorated: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("minimum_amount") + @ExcludeMissing + minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("prorated") + @ExcludeMissing + prorated: JsonField = JsonMissing.of(), + ) : this(minimumAmount, prorated, mutableMapOf()) + + /** + * The minimum amount to apply + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") + + /** + * By default, subtotals from minimum composite prices are prorated based on the + * service period. Set to false to disable proration. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun prorated(): Boolean? = prorated.getNullable("prorated") + + /** + * Returns the raw JSON value of [minimumAmount]. + * + * Unlike [minimumAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount + + /** + * Returns the raw JSON value of [prorated]. + * + * Unlike [prorated], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("prorated") + @ExcludeMissing + fun _prorated(): JsonField = prorated + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [MinimumConfig]. + * + * The following fields are required: + * ```kotlin + * .minimumAmount() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [MinimumConfig]. */ + class Builder internal constructor() { + + private var minimumAmount: JsonField? = null + private var prorated: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(minimumConfig: MinimumConfig) = apply { + minimumAmount = minimumConfig.minimumAmount + prorated = minimumConfig.prorated + additionalProperties = minimumConfig.additionalProperties.toMutableMap() + } + + /** The minimum amount to apply */ + fun minimumAmount(minimumAmount: String) = + minimumAmount(JsonField.of(minimumAmount)) + + /** + * Sets [Builder.minimumAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumAmount] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount + } + + /** + * By default, subtotals from minimum composite prices are prorated based on + * the service period. Set to false to disable proration. + */ + fun prorated(prorated: Boolean?) = prorated(JsonField.ofNullable(prorated)) + + /** + * Alias for [Builder.prorated]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun prorated(prorated: Boolean) = prorated(prorated as Boolean?) + + /** + * Sets [Builder.prorated] to an arbitrary JSON value. + * + * You should usually call [Builder.prorated] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun prorated(prorated: JsonField) = apply { + this.prorated = prorated + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [MinimumConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .minimumAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MinimumConfig = + MinimumConfig( + checkRequired("minimumAmount", minimumAmount), + prorated, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MinimumConfig = apply { + if (validated) { + return@apply + } + + minimumAmount() + prorated() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (minimumAmount.asKnown() == null) 0 else 1) + + (if (prorated.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MinimumConfig && + minimumAmount == other.minimumAmount && + prorated == other.prorated && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(minimumAmount, prorated, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MinimumConfig{minimumAmount=$minimumAmount, prorated=$prorated, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Minimum && + cadence == other.cadence && + currency == other.currency && + itemId == other.itemId && + minimumConfig == other.minimumConfig && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + currency, + itemId, + minimumConfig, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Minimum{cadence=$cadence, currency=$currency, itemId=$itemId, minimumConfig=$minimumConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + } } override fun equals(other: Any?): Boolean { diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceEvaluatePreviewEventsParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceEvaluatePreviewEventsParams.kt index df2f52779..bf51d9773 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceEvaluatePreviewEventsParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceEvaluatePreviewEventsParams.kt @@ -15,6 +15,7 @@ import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import com.withorb.api.core.BaseDeserializer import com.withorb.api.core.BaseSerializer +import com.withorb.api.core.Enum import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing @@ -1556,15 +1557,6 @@ private constructor( /** Alias for calling [price] with `Price.ofTiered(tiered)`. */ fun price(tiered: NewFloatingTieredPrice) = price(Price.ofTiered(tiered)) - /** Alias for calling [price] with `Price.ofTieredBps(tieredBps)`. */ - fun price(tieredBps: NewFloatingTieredBpsPrice) = price(Price.ofTieredBps(tieredBps)) - - /** Alias for calling [price] with `Price.ofBps(bps)`. */ - fun price(bps: NewFloatingBpsPrice) = price(Price.ofBps(bps)) - - /** Alias for calling [price] with `Price.ofBulkBps(bulkBps)`. */ - fun price(bulkBps: NewFloatingBulkBpsPrice) = price(Price.ofBulkBps(bulkBps)) - /** Alias for calling [price] with `Price.ofBulk(bulk)`. */ fun price(bulk: NewFloatingBulkPrice) = price(Price.ofBulk(bulk)) @@ -1679,6 +1671,16 @@ private constructor( fun price(cumulativeGroupedBulk: NewFloatingCumulativeGroupedBulkPrice) = price(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) + /** + * Alias for calling [price] with + * `Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)`. + */ + fun price(groupedWithMinMaxThresholds: Price.GroupedWithMinMaxThresholds) = + price(Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)) + + /** Alias for calling [price] with `Price.ofMinimum(minimum)`. */ + fun price(minimum: Price.Minimum) = price(Price.ofMinimum(minimum)) + /** The ID of a price to evaluate that exists in your Orb account. */ fun priceId(priceId: String?) = priceId(JsonField.ofNullable(priceId)) @@ -1775,9 +1777,6 @@ private constructor( private val matrix: NewFloatingMatrixPrice? = null, private val matrixWithAllocation: NewFloatingMatrixWithAllocationPrice? = null, private val tiered: NewFloatingTieredPrice? = null, - private val tieredBps: NewFloatingTieredBpsPrice? = null, - private val bps: NewFloatingBpsPrice? = null, - private val bulkBps: NewFloatingBulkBpsPrice? = null, private val bulk: NewFloatingBulkPrice? = null, private val thresholdTotalAmount: NewFloatingThresholdTotalAmountPrice? = null, private val tieredPackage: NewFloatingTieredPackagePrice? = null, @@ -1804,6 +1803,8 @@ private constructor( NewFloatingScalableMatrixWithTieredPricingPrice? = null, private val cumulativeGroupedBulk: NewFloatingCumulativeGroupedBulkPrice? = null, + private val groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds? = null, + private val minimum: Minimum? = null, private val _json: JsonValue? = null, ) { @@ -1817,12 +1818,6 @@ private constructor( fun tiered(): NewFloatingTieredPrice? = tiered - fun tieredBps(): NewFloatingTieredBpsPrice? = tieredBps - - fun bps(): NewFloatingBpsPrice? = bps - - fun bulkBps(): NewFloatingBulkBpsPrice? = bulkBps - fun bulk(): NewFloatingBulkPrice? = bulk fun thresholdTotalAmount(): NewFloatingThresholdTotalAmountPrice? = thresholdTotalAmount @@ -1872,6 +1867,11 @@ private constructor( fun cumulativeGroupedBulk(): NewFloatingCumulativeGroupedBulkPrice? = cumulativeGroupedBulk + fun groupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds? = + groupedWithMinMaxThresholds + + fun minimum(): Minimum? = minimum + fun isUnit(): Boolean = unit != null fun isPackage(): Boolean = package_ != null @@ -1882,12 +1882,6 @@ private constructor( fun isTiered(): Boolean = tiered != null - fun isTieredBps(): Boolean = tieredBps != null - - fun isBps(): Boolean = bps != null - - fun isBulkBps(): Boolean = bulkBps != null - fun isBulk(): Boolean = bulk != null fun isThresholdTotalAmount(): Boolean = thresholdTotalAmount != null @@ -1929,6 +1923,10 @@ private constructor( fun isCumulativeGroupedBulk(): Boolean = cumulativeGroupedBulk != null + fun isGroupedWithMinMaxThresholds(): Boolean = groupedWithMinMaxThresholds != null + + fun isMinimum(): Boolean = minimum != null + fun asUnit(): NewFloatingUnitPrice = unit.getOrThrow("unit") fun asPackage(): NewFloatingPackagePrice = package_.getOrThrow("package_") @@ -1940,12 +1938,6 @@ private constructor( fun asTiered(): NewFloatingTieredPrice = tiered.getOrThrow("tiered") - fun asTieredBps(): NewFloatingTieredBpsPrice = tieredBps.getOrThrow("tieredBps") - - fun asBps(): NewFloatingBpsPrice = bps.getOrThrow("bps") - - fun asBulkBps(): NewFloatingBulkBpsPrice = bulkBps.getOrThrow("bulkBps") - fun asBulk(): NewFloatingBulkPrice = bulk.getOrThrow("bulk") fun asThresholdTotalAmount(): NewFloatingThresholdTotalAmountPrice = @@ -2006,6 +1998,11 @@ private constructor( fun asCumulativeGroupedBulk(): NewFloatingCumulativeGroupedBulkPrice = cumulativeGroupedBulk.getOrThrow("cumulativeGroupedBulk") + fun asGroupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds = + groupedWithMinMaxThresholds.getOrThrow("groupedWithMinMaxThresholds") + + fun asMinimum(): Minimum = minimum.getOrThrow("minimum") + fun _json(): JsonValue? = _json fun accept(visitor: Visitor): T = @@ -2016,9 +2013,6 @@ private constructor( matrixWithAllocation != null -> visitor.visitMatrixWithAllocation(matrixWithAllocation) tiered != null -> visitor.visitTiered(tiered) - tieredBps != null -> visitor.visitTieredBps(tieredBps) - bps != null -> visitor.visitBps(bps) - bulkBps != null -> visitor.visitBulkBps(bulkBps) bulk != null -> visitor.visitBulk(bulk) thresholdTotalAmount != null -> visitor.visitThresholdTotalAmount(thresholdTotalAmount) @@ -2053,6 +2047,9 @@ private constructor( ) cumulativeGroupedBulk != null -> visitor.visitCumulativeGroupedBulk(cumulativeGroupedBulk) + groupedWithMinMaxThresholds != null -> + visitor.visitGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds) + minimum != null -> visitor.visitMinimum(minimum) else -> visitor.unknown(_json) } @@ -2087,18 +2084,6 @@ private constructor( tiered.validate() } - override fun visitTieredBps(tieredBps: NewFloatingTieredBpsPrice) { - tieredBps.validate() - } - - override fun visitBps(bps: NewFloatingBpsPrice) { - bps.validate() - } - - override fun visitBulkBps(bulkBps: NewFloatingBulkBpsPrice) { - bulkBps.validate() - } - override fun visitBulk(bulk: NewFloatingBulkPrice) { bulk.validate() } @@ -2218,6 +2203,16 @@ private constructor( ) { cumulativeGroupedBulk.validate() } + + override fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) { + groupedWithMinMaxThresholds.validate() + } + + override fun visitMinimum(minimum: Minimum) { + minimum.validate() + } } ) validated = true @@ -2253,14 +2248,6 @@ private constructor( override fun visitTiered(tiered: NewFloatingTieredPrice) = tiered.validity() - override fun visitTieredBps(tieredBps: NewFloatingTieredBpsPrice) = - tieredBps.validity() - - override fun visitBps(bps: NewFloatingBpsPrice) = bps.validity() - - override fun visitBulkBps(bulkBps: NewFloatingBulkBpsPrice) = - bulkBps.validity() - override fun visitBulk(bulk: NewFloatingBulkPrice) = bulk.validity() override fun visitThresholdTotalAmount( @@ -2341,6 +2328,12 @@ private constructor( cumulativeGroupedBulk: NewFloatingCumulativeGroupedBulkPrice ) = cumulativeGroupedBulk.validity() + override fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) = groupedWithMinMaxThresholds.validity() + + override fun visitMinimum(minimum: Minimum) = minimum.validity() + override fun unknown(json: JsonValue?) = 0 } ) @@ -2356,9 +2349,6 @@ private constructor( matrix == other.matrix && matrixWithAllocation == other.matrixWithAllocation && tiered == other.tiered && - tieredBps == other.tieredBps && - bps == other.bps && - bulkBps == other.bulkBps && bulk == other.bulk && thresholdTotalAmount == other.thresholdTotalAmount && tieredPackage == other.tieredPackage && @@ -2378,7 +2368,9 @@ private constructor( groupedTieredPackage == other.groupedTieredPackage && scalableMatrixWithUnitPricing == other.scalableMatrixWithUnitPricing && scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && - cumulativeGroupedBulk == other.cumulativeGroupedBulk + cumulativeGroupedBulk == other.cumulativeGroupedBulk && + groupedWithMinMaxThresholds == other.groupedWithMinMaxThresholds && + minimum == other.minimum } override fun hashCode(): Int = @@ -2388,9 +2380,6 @@ private constructor( matrix, matrixWithAllocation, tiered, - tieredBps, - bps, - bulkBps, bulk, thresholdTotalAmount, tieredPackage, @@ -2411,6 +2400,8 @@ private constructor( scalableMatrixWithUnitPricing, scalableMatrixWithTieredPricing, cumulativeGroupedBulk, + groupedWithMinMaxThresholds, + minimum, ) override fun toString(): String = @@ -2421,9 +2412,6 @@ private constructor( matrixWithAllocation != null -> "Price{matrixWithAllocation=$matrixWithAllocation}" tiered != null -> "Price{tiered=$tiered}" - tieredBps != null -> "Price{tieredBps=$tieredBps}" - bps != null -> "Price{bps=$bps}" - bulkBps != null -> "Price{bulkBps=$bulkBps}" bulk != null -> "Price{bulk=$bulk}" thresholdTotalAmount != null -> "Price{thresholdTotalAmount=$thresholdTotalAmount}" @@ -2455,6 +2443,9 @@ private constructor( "Price{scalableMatrixWithTieredPricing=$scalableMatrixWithTieredPricing}" cumulativeGroupedBulk != null -> "Price{cumulativeGroupedBulk=$cumulativeGroupedBulk}" + groupedWithMinMaxThresholds != null -> + "Price{groupedWithMinMaxThresholds=$groupedWithMinMaxThresholds}" + minimum != null -> "Price{minimum=$minimum}" _json != null -> "Price{_unknown=$_json}" else -> throw IllegalStateException("Invalid Price") } @@ -2473,12 +2464,6 @@ private constructor( fun ofTiered(tiered: NewFloatingTieredPrice) = Price(tiered = tiered) - fun ofTieredBps(tieredBps: NewFloatingTieredBpsPrice) = Price(tieredBps = tieredBps) - - fun ofBps(bps: NewFloatingBpsPrice) = Price(bps = bps) - - fun ofBulkBps(bulkBps: NewFloatingBulkBpsPrice) = Price(bulkBps = bulkBps) - fun ofBulk(bulk: NewFloatingBulkPrice) = Price(bulk = bulk) fun ofThresholdTotalAmount( @@ -2549,6 +2534,12 @@ private constructor( fun ofCumulativeGroupedBulk( cumulativeGroupedBulk: NewFloatingCumulativeGroupedBulkPrice ) = Price(cumulativeGroupedBulk = cumulativeGroupedBulk) + + fun ofGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) = Price(groupedWithMinMaxThresholds = groupedWithMinMaxThresholds) + + fun ofMinimum(minimum: Minimum) = Price(minimum = minimum) } /** @@ -2568,12 +2559,6 @@ private constructor( fun visitTiered(tiered: NewFloatingTieredPrice): T - fun visitTieredBps(tieredBps: NewFloatingTieredBpsPrice): T - - fun visitBps(bps: NewFloatingBpsPrice): T - - fun visitBulkBps(bulkBps: NewFloatingBulkBpsPrice): T - fun visitBulk(bulk: NewFloatingBulkPrice): T fun visitThresholdTotalAmount( @@ -2638,6 +2623,12 @@ private constructor( cumulativeGroupedBulk: NewFloatingCumulativeGroupedBulkPrice ): T + fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ): T + + fun visitMinimum(minimum: Minimum): T + /** * Maps an unknown variant of [Price] to a value of type [T]. * @@ -2684,18 +2675,6 @@ private constructor( return tryDeserialize(node, jacksonTypeRef()) ?.let { Price(tiered = it, _json = json) } ?: Price(_json = json) } - "tiered_bps" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(tieredBps = it, _json = json) } ?: Price(_json = json) - } - "bps" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(bps = it, _json = json) } ?: Price(_json = json) - } - "bulk_bps" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(bulkBps = it, _json = json) } ?: Price(_json = json) - } "bulk" -> { return tryDeserialize(node, jacksonTypeRef()) ?.let { Price(bulk = it, _json = json) } ?: Price(_json = json) @@ -2854,6 +2833,19 @@ private constructor( ?.let { Price(cumulativeGroupedBulk = it, _json = json) } ?: Price(_json = json) } + "grouped_with_min_max_thresholds" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedWithMinMaxThresholds = it, _json = json) } + ?: Price(_json = json) + } + "minimum" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(minimum = it, _json = json) + } ?: Price(_json = json) + } } return Price(_json = json) @@ -2874,9 +2866,6 @@ private constructor( value.matrixWithAllocation != null -> generator.writeObject(value.matrixWithAllocation) value.tiered != null -> generator.writeObject(value.tiered) - value.tieredBps != null -> generator.writeObject(value.tieredBps) - value.bps != null -> generator.writeObject(value.bps) - value.bulkBps != null -> generator.writeObject(value.bulkBps) value.bulk != null -> generator.writeObject(value.bulk) value.thresholdTotalAmount != null -> generator.writeObject(value.thresholdTotalAmount) @@ -2914,11 +2903,2959 @@ private constructor( generator.writeObject(value.scalableMatrixWithTieredPricing) value.cumulativeGroupedBulk != null -> generator.writeObject(value.cumulativeGroupedBulk) + value.groupedWithMinMaxThresholds != null -> + generator.writeObject(value.groupedWithMinMaxThresholds) + value.minimum != null -> generator.writeObject(value.minimum) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid Price") } } } + + class GroupedWithMinMaxThresholds + private constructor( + private val cadence: JsonField, + private val currency: JsonField, + private val groupedWithMinMaxThresholdsConfig: + JsonField, + private val itemId: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val metadata: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("grouped_with_min_max_thresholds_config") + @ExcludeMissing + groupedWithMinMaxThresholdsConfig: + JsonField = + JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + ) : this( + cadence, + currency, + groupedWithMinMaxThresholdsConfig, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * An ISO 4217 currency string for which this price is billed in. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupedWithMinMaxThresholdsConfig(): GroupedWithMinMaxThresholdsConfig = + groupedWithMinMaxThresholdsConfig.getRequired( + "grouped_with_min_max_thresholds_config" + ) + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * Expected to always return the following: + * ```kotlin + * JsonValue.from("grouped_with_min_max_thresholds") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = billableMetricId.getNullable("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + invoiceGroupingKey.getNullable("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [groupedWithMinMaxThresholdsConfig]. + * + * Unlike [groupedWithMinMaxThresholdsConfig], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("grouped_with_min_max_thresholds_config") + @ExcludeMissing + fun _groupedWithMinMaxThresholdsConfig(): + JsonField = groupedWithMinMaxThresholdsConfig + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [GroupedWithMinMaxThresholds]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .currency() + * .groupedWithMinMaxThresholdsConfig() + * .itemId() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [GroupedWithMinMaxThresholds]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var currency: JsonField? = null + private var groupedWithMinMaxThresholdsConfig: + JsonField? = + null + private var itemId: JsonField? = null + private var modelType: JsonValue = + JsonValue.from("grouped_with_min_max_thresholds") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds) = + apply { + cadence = groupedWithMinMaxThresholds.cadence + currency = groupedWithMinMaxThresholds.currency + groupedWithMinMaxThresholdsConfig = + groupedWithMinMaxThresholds.groupedWithMinMaxThresholdsConfig + itemId = groupedWithMinMaxThresholds.itemId + modelType = groupedWithMinMaxThresholds.modelType + name = groupedWithMinMaxThresholds.name + billableMetricId = groupedWithMinMaxThresholds.billableMetricId + billedInAdvance = groupedWithMinMaxThresholds.billedInAdvance + billingCycleConfiguration = + groupedWithMinMaxThresholds.billingCycleConfiguration + conversionRate = groupedWithMinMaxThresholds.conversionRate + conversionRateConfig = groupedWithMinMaxThresholds.conversionRateConfig + dimensionalPriceConfiguration = + groupedWithMinMaxThresholds.dimensionalPriceConfiguration + externalPriceId = groupedWithMinMaxThresholds.externalPriceId + fixedPriceQuantity = groupedWithMinMaxThresholds.fixedPriceQuantity + invoiceGroupingKey = groupedWithMinMaxThresholds.invoiceGroupingKey + invoicingCycleConfiguration = + groupedWithMinMaxThresholds.invoicingCycleConfiguration + metadata = groupedWithMinMaxThresholds.metadata + additionalProperties = + groupedWithMinMaxThresholds.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + fun groupedWithMinMaxThresholdsConfig( + groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + ) = + groupedWithMinMaxThresholdsConfig( + JsonField.of(groupedWithMinMaxThresholdsConfig) + ) + + /** + * Sets [Builder.groupedWithMinMaxThresholdsConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.groupedWithMinMaxThresholdsConfig] with a + * well-typed [GroupedWithMinMaxThresholdsConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun groupedWithMinMaxThresholdsConfig( + groupedWithMinMaxThresholdsConfig: + JsonField + ) = apply { + this.groupedWithMinMaxThresholdsConfig = groupedWithMinMaxThresholdsConfig + } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("grouped_with_min_max_thresholds") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [GroupedWithMinMaxThresholds]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .currency() + * .groupedWithMinMaxThresholdsConfig() + * .itemId() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedWithMinMaxThresholds = + GroupedWithMinMaxThresholds( + checkRequired("cadence", cadence), + checkRequired("currency", currency), + checkRequired( + "groupedWithMinMaxThresholdsConfig", + groupedWithMinMaxThresholdsConfig, + ), + checkRequired("itemId", itemId), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GroupedWithMinMaxThresholds = apply { + if (validated) { + return@apply + } + + cadence().validate() + currency() + groupedWithMinMaxThresholdsConfig().validate() + itemId() + _modelType().let { + if (it != JsonValue.from("grouped_with_min_max_thresholds")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + metadata()?.validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (groupedWithMinMaxThresholdsConfig.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + modelType.let { + if (it == JsonValue.from("grouped_with_min_max_thresholds")) 1 else 0 + } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (metadata.asKnown()?.validity() ?: 0) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class GroupedWithMinMaxThresholdsConfig + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [GroupedWithMinMaxThresholdsConfig]. + */ + fun builder() = Builder() + } + + /** A builder for [GroupedWithMinMaxThresholdsConfig]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from( + groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + ) = apply { + additionalProperties = + groupedWithMinMaxThresholdsConfig.additionalProperties + .toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [GroupedWithMinMaxThresholdsConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): GroupedWithMinMaxThresholdsConfig = + GroupedWithMinMaxThresholdsConfig(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): GroupedWithMinMaxThresholdsConfig = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedWithMinMaxThresholdsConfig && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedWithMinMaxThresholdsConfig{additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedWithMinMaxThresholds && + cadence == other.cadence && + currency == other.currency && + groupedWithMinMaxThresholdsConfig == + other.groupedWithMinMaxThresholdsConfig && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + currency, + groupedWithMinMaxThresholdsConfig, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedWithMinMaxThresholds{cadence=$cadence, currency=$currency, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + } + + class Minimum + private constructor( + private val cadence: JsonField, + private val currency: JsonField, + private val itemId: JsonField, + private val minimumConfig: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val metadata: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("minimum_config") + @ExcludeMissing + minimumConfig: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + ) : this( + cadence, + currency, + itemId, + minimumConfig, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * An ISO 4217 currency string for which this price is billed in. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun minimumConfig(): MinimumConfig = minimumConfig.getRequired("minimum_config") + + /** + * Expected to always return the following: + * ```kotlin + * JsonValue.from("minimum") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = billableMetricId.getNullable("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + invoiceGroupingKey.getNullable("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [minimumConfig]. + * + * Unlike [minimumConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("minimum_config") + @ExcludeMissing + fun _minimumConfig(): JsonField = minimumConfig + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Minimum]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .currency() + * .itemId() + * .minimumConfig() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Minimum]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var currency: JsonField? = null + private var itemId: JsonField? = null + private var minimumConfig: JsonField? = null + private var modelType: JsonValue = JsonValue.from("minimum") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(minimum: Minimum) = apply { + cadence = minimum.cadence + currency = minimum.currency + itemId = minimum.itemId + minimumConfig = minimum.minimumConfig + modelType = minimum.modelType + name = minimum.name + billableMetricId = minimum.billableMetricId + billedInAdvance = minimum.billedInAdvance + billingCycleConfiguration = minimum.billingCycleConfiguration + conversionRate = minimum.conversionRate + conversionRateConfig = minimum.conversionRateConfig + dimensionalPriceConfiguration = minimum.dimensionalPriceConfiguration + externalPriceId = minimum.externalPriceId + fixedPriceQuantity = minimum.fixedPriceQuantity + invoiceGroupingKey = minimum.invoiceGroupingKey + invoicingCycleConfiguration = minimum.invoicingCycleConfiguration + metadata = minimum.metadata + additionalProperties = minimum.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun minimumConfig(minimumConfig: MinimumConfig) = + minimumConfig(JsonField.of(minimumConfig)) + + /** + * Sets [Builder.minimumConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumConfig] with a well-typed + * [MinimumConfig] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun minimumConfig(minimumConfig: JsonField) = apply { + this.minimumConfig = minimumConfig + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("minimum") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Minimum]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .currency() + * .itemId() + * .minimumConfig() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Minimum = + Minimum( + checkRequired("cadence", cadence), + checkRequired("currency", currency), + checkRequired("itemId", itemId), + checkRequired("minimumConfig", minimumConfig), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Minimum = apply { + if (validated) { + return@apply + } + + cadence().validate() + currency() + itemId() + minimumConfig().validate() + _modelType().let { + if (it != JsonValue.from("minimum")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + metadata()?.validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (if (itemId.asKnown() == null) 0 else 1) + + (minimumConfig.asKnown()?.validity() ?: 0) + + modelType.let { if (it == JsonValue.from("minimum")) 1 else 0 } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (metadata.asKnown()?.validity() ?: 0) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class MinimumConfig + private constructor( + private val minimumAmount: JsonField, + private val prorated: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("minimum_amount") + @ExcludeMissing + minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("prorated") + @ExcludeMissing + prorated: JsonField = JsonMissing.of(), + ) : this(minimumAmount, prorated, mutableMapOf()) + + /** + * The minimum amount to apply + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") + + /** + * By default, subtotals from minimum composite prices are prorated based on the + * service period. Set to false to disable proration. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun prorated(): Boolean? = prorated.getNullable("prorated") + + /** + * Returns the raw JSON value of [minimumAmount]. + * + * Unlike [minimumAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount + + /** + * Returns the raw JSON value of [prorated]. + * + * Unlike [prorated], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("prorated") + @ExcludeMissing + fun _prorated(): JsonField = prorated + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [MinimumConfig]. + * + * The following fields are required: + * ```kotlin + * .minimumAmount() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [MinimumConfig]. */ + class Builder internal constructor() { + + private var minimumAmount: JsonField? = null + private var prorated: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(minimumConfig: MinimumConfig) = apply { + minimumAmount = minimumConfig.minimumAmount + prorated = minimumConfig.prorated + additionalProperties = minimumConfig.additionalProperties.toMutableMap() + } + + /** The minimum amount to apply */ + fun minimumAmount(minimumAmount: String) = + minimumAmount(JsonField.of(minimumAmount)) + + /** + * Sets [Builder.minimumAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumAmount] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount + } + + /** + * By default, subtotals from minimum composite prices are prorated based on + * the service period. Set to false to disable proration. + */ + fun prorated(prorated: Boolean?) = prorated(JsonField.ofNullable(prorated)) + + /** + * Alias for [Builder.prorated]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun prorated(prorated: Boolean) = prorated(prorated as Boolean?) + + /** + * Sets [Builder.prorated] to an arbitrary JSON value. + * + * You should usually call [Builder.prorated] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun prorated(prorated: JsonField) = apply { + this.prorated = prorated + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [MinimumConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .minimumAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MinimumConfig = + MinimumConfig( + checkRequired("minimumAmount", minimumAmount), + prorated, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MinimumConfig = apply { + if (validated) { + return@apply + } + + minimumAmount() + prorated() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (minimumAmount.asKnown() == null) 0 else 1) + + (if (prorated.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MinimumConfig && + minimumAmount == other.minimumAmount && + prorated == other.prorated && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(minimumAmount, prorated, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MinimumConfig{minimumAmount=$minimumAmount, prorated=$prorated, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Minimum && + cadence == other.cadence && + currency == other.currency && + itemId == other.itemId && + minimumConfig == other.minimumConfig && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + currency, + itemId, + minimumConfig, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Minimum{cadence=$cadence, currency=$currency, itemId=$itemId, minimumConfig=$minimumConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + } } override fun equals(other: Any?): Boolean { diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceInterval.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceInterval.kt index 63efc3dad..2bf52b000 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceInterval.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceInterval.kt @@ -486,15 +486,6 @@ private constructor( /** Alias for calling [price] with `Price.ofTiered(tiered)`. */ fun price(tiered: Price.Tiered) = price(Price.ofTiered(tiered)) - /** Alias for calling [price] with `Price.ofTieredBps(tieredBps)`. */ - fun price(tieredBps: Price.TieredBps) = price(Price.ofTieredBps(tieredBps)) - - /** Alias for calling [price] with `Price.ofBps(bps)`. */ - fun price(bps: Price.Bps) = price(Price.ofBps(bps)) - - /** Alias for calling [price] with `Price.ofBulkBps(bulkBps)`. */ - fun price(bulkBps: Price.BulkBps) = price(Price.ofBulkBps(bulkBps)) - /** Alias for calling [price] with `Price.ofBulk(bulk)`. */ fun price(bulk: Price.Bulk) = price(Price.ofBulk(bulk)) @@ -606,6 +597,9 @@ private constructor( fun price(groupedWithMinMaxThresholds: Price.GroupedWithMinMaxThresholds) = price(Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)) + /** Alias for calling [price] with `Price.ofMinimum(minimum)`. */ + fun price(minimum: Price.Minimum) = price(Price.ofMinimum(minimum)) + /** * The start date of the price interval. This is the date that Orb starts billing for this * price. diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceListPageResponse.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceListPageResponse.kt index 853e2cc8d..46e7c76a5 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceListPageResponse.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceListPageResponse.kt @@ -138,15 +138,6 @@ private constructor( /** Alias for calling [addData] with `Price.ofTiered(tiered)`. */ fun addData(tiered: Price.Tiered) = addData(Price.ofTiered(tiered)) - /** Alias for calling [addData] with `Price.ofTieredBps(tieredBps)`. */ - fun addData(tieredBps: Price.TieredBps) = addData(Price.ofTieredBps(tieredBps)) - - /** Alias for calling [addData] with `Price.ofBps(bps)`. */ - fun addData(bps: Price.Bps) = addData(Price.ofBps(bps)) - - /** Alias for calling [addData] with `Price.ofBulkBps(bulkBps)`. */ - fun addData(bulkBps: Price.BulkBps) = addData(Price.ofBulkBps(bulkBps)) - /** Alias for calling [addData] with `Price.ofBulk(bulk)`. */ fun addData(bulk: Price.Bulk) = addData(Price.ofBulk(bulk)) @@ -266,6 +257,9 @@ private constructor( fun addData(groupedWithMinMaxThresholds: Price.GroupedWithMinMaxThresholds) = addData(Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)) + /** Alias for calling [addData] with `Price.ofMinimum(minimum)`. */ + fun addData(minimum: Price.Minimum) = addData(Price.ofMinimum(minimum)) + fun paginationMetadata(paginationMetadata: PaginationMetadata) = paginationMetadata(JsonField.of(paginationMetadata)) diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionCreateParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionCreateParams.kt index e1658ee73..1f74cbc34 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionCreateParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionCreateParams.kt @@ -4566,16 +4566,6 @@ private constructor( /** Alias for calling [price] with `Price.ofTiered(tiered)`. */ fun price(tiered: NewSubscriptionTieredPrice) = price(Price.ofTiered(tiered)) - /** Alias for calling [price] with `Price.ofTieredBps(tieredBps)`. */ - fun price(tieredBps: NewSubscriptionTieredBpsPrice) = - price(Price.ofTieredBps(tieredBps)) - - /** Alias for calling [price] with `Price.ofBps(bps)`. */ - fun price(bps: NewSubscriptionBpsPrice) = price(Price.ofBps(bps)) - - /** Alias for calling [price] with `Price.ofBulkBps(bulkBps)`. */ - fun price(bulkBps: NewSubscriptionBulkBpsPrice) = price(Price.ofBulkBps(bulkBps)) - /** Alias for calling [price] with `Price.ofBulk(bulk)`. */ fun price(bulk: NewSubscriptionBulkPrice) = price(Price.ofBulk(bulk)) @@ -4696,6 +4686,16 @@ private constructor( fun price(groupedTiered: NewSubscriptionGroupedTieredPrice) = price(Price.ofGroupedTiered(groupedTiered)) + /** + * Alias for calling [price] with + * `Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)`. + */ + fun price(groupedWithMinMaxThresholds: Price.GroupedWithMinMaxThresholds) = + price(Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)) + + /** Alias for calling [price] with `Price.ofMinimum(minimum)`. */ + fun price(minimum: Price.Minimum) = price(Price.ofMinimum(minimum)) + /** The id of the price to add to the subscription. */ fun priceId(priceId: String?) = priceId(JsonField.ofNullable(priceId)) @@ -4821,9 +4821,6 @@ private constructor( private val package_: NewSubscriptionPackagePrice? = null, private val matrix: NewSubscriptionMatrixPrice? = null, private val tiered: NewSubscriptionTieredPrice? = null, - private val tieredBps: NewSubscriptionTieredBpsPrice? = null, - private val bps: NewSubscriptionBpsPrice? = null, - private val bulkBps: NewSubscriptionBulkBpsPrice? = null, private val bulk: NewSubscriptionBulkPrice? = null, private val thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice? = null, private val tieredPackage: NewSubscriptionTieredPackagePrice? = null, @@ -4853,6 +4850,8 @@ private constructor( private val tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice? = null, private val groupedTiered: NewSubscriptionGroupedTieredPrice? = null, + private val groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds? = null, + private val minimum: Minimum? = null, private val _json: JsonValue? = null, ) { @@ -4864,12 +4863,6 @@ private constructor( fun tiered(): NewSubscriptionTieredPrice? = tiered - fun tieredBps(): NewSubscriptionTieredBpsPrice? = tieredBps - - fun bps(): NewSubscriptionBpsPrice? = bps - - fun bulkBps(): NewSubscriptionBulkBpsPrice? = bulkBps - fun bulk(): NewSubscriptionBulkPrice? = bulk fun thresholdTotalAmount(): NewSubscriptionThresholdTotalAmountPrice? = @@ -4925,6 +4918,11 @@ private constructor( fun groupedTiered(): NewSubscriptionGroupedTieredPrice? = groupedTiered + fun groupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds? = + groupedWithMinMaxThresholds + + fun minimum(): Minimum? = minimum + fun isUnit(): Boolean = unit != null fun isPackage(): Boolean = package_ != null @@ -4933,12 +4931,6 @@ private constructor( fun isTiered(): Boolean = tiered != null - fun isTieredBps(): Boolean = tieredBps != null - - fun isBps(): Boolean = bps != null - - fun isBulkBps(): Boolean = bulkBps != null - fun isBulk(): Boolean = bulk != null fun isThresholdTotalAmount(): Boolean = thresholdTotalAmount != null @@ -4982,6 +4974,10 @@ private constructor( fun isGroupedTiered(): Boolean = groupedTiered != null + fun isGroupedWithMinMaxThresholds(): Boolean = groupedWithMinMaxThresholds != null + + fun isMinimum(): Boolean = minimum != null + fun asUnit(): NewSubscriptionUnitPrice = unit.getOrThrow("unit") fun asPackage(): NewSubscriptionPackagePrice = package_.getOrThrow("package_") @@ -4990,12 +4986,6 @@ private constructor( fun asTiered(): NewSubscriptionTieredPrice = tiered.getOrThrow("tiered") - fun asTieredBps(): NewSubscriptionTieredBpsPrice = tieredBps.getOrThrow("tieredBps") - - fun asBps(): NewSubscriptionBpsPrice = bps.getOrThrow("bps") - - fun asBulkBps(): NewSubscriptionBulkBpsPrice = bulkBps.getOrThrow("bulkBps") - fun asBulk(): NewSubscriptionBulkPrice = bulk.getOrThrow("bulk") fun asThresholdTotalAmount(): NewSubscriptionThresholdTotalAmountPrice = @@ -5060,6 +5050,11 @@ private constructor( fun asGroupedTiered(): NewSubscriptionGroupedTieredPrice = groupedTiered.getOrThrow("groupedTiered") + fun asGroupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds = + groupedWithMinMaxThresholds.getOrThrow("groupedWithMinMaxThresholds") + + fun asMinimum(): Minimum = minimum.getOrThrow("minimum") + fun _json(): JsonValue? = _json fun accept(visitor: Visitor): T = @@ -5068,9 +5063,6 @@ private constructor( package_ != null -> visitor.visitPackage(package_) matrix != null -> visitor.visitMatrix(matrix) tiered != null -> visitor.visitTiered(tiered) - tieredBps != null -> visitor.visitTieredBps(tieredBps) - bps != null -> visitor.visitBps(bps) - bulkBps != null -> visitor.visitBulkBps(bulkBps) bulk != null -> visitor.visitBulk(bulk) thresholdTotalAmount != null -> visitor.visitThresholdTotalAmount(thresholdTotalAmount) @@ -5107,6 +5099,9 @@ private constructor( tieredPackageWithMinimum != null -> visitor.visitTieredPackageWithMinimum(tieredPackageWithMinimum) groupedTiered != null -> visitor.visitGroupedTiered(groupedTiered) + groupedWithMinMaxThresholds != null -> + visitor.visitGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds) + minimum != null -> visitor.visitMinimum(minimum) else -> visitor.unknown(_json) } @@ -5135,18 +5130,6 @@ private constructor( tiered.validate() } - override fun visitTieredBps(tieredBps: NewSubscriptionTieredBpsPrice) { - tieredBps.validate() - } - - override fun visitBps(bps: NewSubscriptionBpsPrice) { - bps.validate() - } - - override fun visitBulkBps(bulkBps: NewSubscriptionBulkBpsPrice) { - bulkBps.validate() - } - override fun visitBulk(bulk: NewSubscriptionBulkPrice) { bulk.validate() } @@ -5273,6 +5256,16 @@ private constructor( ) { groupedTiered.validate() } + + override fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) { + groupedWithMinMaxThresholds.validate() + } + + override fun visitMinimum(minimum: Minimum) { + minimum.validate() + } } ) validated = true @@ -5306,14 +5299,6 @@ private constructor( override fun visitTiered(tiered: NewSubscriptionTieredPrice) = tiered.validity() - override fun visitTieredBps(tieredBps: NewSubscriptionTieredBpsPrice) = - tieredBps.validity() - - override fun visitBps(bps: NewSubscriptionBpsPrice) = bps.validity() - - override fun visitBulkBps(bulkBps: NewSubscriptionBulkBpsPrice) = - bulkBps.validity() - override fun visitBulk(bulk: NewSubscriptionBulkPrice) = bulk.validity() override fun visitThresholdTotalAmount( @@ -5399,6 +5384,12 @@ private constructor( groupedTiered: NewSubscriptionGroupedTieredPrice ) = groupedTiered.validity() + override fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) = groupedWithMinMaxThresholds.validity() + + override fun visitMinimum(minimum: Minimum) = minimum.validity() + override fun unknown(json: JsonValue?) = 0 } ) @@ -5413,9 +5404,6 @@ private constructor( package_ == other.package_ && matrix == other.matrix && tiered == other.tiered && - tieredBps == other.tieredBps && - bps == other.bps && - bulkBps == other.bulkBps && bulk == other.bulk && thresholdTotalAmount == other.thresholdTotalAmount && tieredPackage == other.tieredPackage && @@ -5436,7 +5424,9 @@ private constructor( groupedTieredPackage == other.groupedTieredPackage && matrixWithAllocation == other.matrixWithAllocation && tieredPackageWithMinimum == other.tieredPackageWithMinimum && - groupedTiered == other.groupedTiered + groupedTiered == other.groupedTiered && + groupedWithMinMaxThresholds == other.groupedWithMinMaxThresholds && + minimum == other.minimum } override fun hashCode(): Int = @@ -5445,9 +5435,6 @@ private constructor( package_, matrix, tiered, - tieredBps, - bps, - bulkBps, bulk, thresholdTotalAmount, tieredPackage, @@ -5469,6 +5456,8 @@ private constructor( matrixWithAllocation, tieredPackageWithMinimum, groupedTiered, + groupedWithMinMaxThresholds, + minimum, ) override fun toString(): String = @@ -5477,9 +5466,6 @@ private constructor( package_ != null -> "Price{package_=$package_}" matrix != null -> "Price{matrix=$matrix}" tiered != null -> "Price{tiered=$tiered}" - tieredBps != null -> "Price{tieredBps=$tieredBps}" - bps != null -> "Price{bps=$bps}" - bulkBps != null -> "Price{bulkBps=$bulkBps}" bulk != null -> "Price{bulk=$bulk}" thresholdTotalAmount != null -> "Price{thresholdTotalAmount=$thresholdTotalAmount}" @@ -5513,6 +5499,9 @@ private constructor( tieredPackageWithMinimum != null -> "Price{tieredPackageWithMinimum=$tieredPackageWithMinimum}" groupedTiered != null -> "Price{groupedTiered=$groupedTiered}" + groupedWithMinMaxThresholds != null -> + "Price{groupedWithMinMaxThresholds=$groupedWithMinMaxThresholds}" + minimum != null -> "Price{minimum=$minimum}" _json != null -> "Price{_unknown=$_json}" else -> throw IllegalStateException("Invalid Price") } @@ -5527,13 +5516,6 @@ private constructor( fun ofTiered(tiered: NewSubscriptionTieredPrice) = Price(tiered = tiered) - fun ofTieredBps(tieredBps: NewSubscriptionTieredBpsPrice) = - Price(tieredBps = tieredBps) - - fun ofBps(bps: NewSubscriptionBpsPrice) = Price(bps = bps) - - fun ofBulkBps(bulkBps: NewSubscriptionBulkBpsPrice) = Price(bulkBps = bulkBps) - fun ofBulk(bulk: NewSubscriptionBulkPrice) = Price(bulk = bulk) fun ofThresholdTotalAmount( @@ -5609,6 +5591,12 @@ private constructor( fun ofGroupedTiered(groupedTiered: NewSubscriptionGroupedTieredPrice) = Price(groupedTiered = groupedTiered) + + fun ofGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) = Price(groupedWithMinMaxThresholds = groupedWithMinMaxThresholds) + + fun ofMinimum(minimum: Minimum) = Price(minimum = minimum) } /** @@ -5624,12 +5612,6 @@ private constructor( fun visitTiered(tiered: NewSubscriptionTieredPrice): T - fun visitTieredBps(tieredBps: NewSubscriptionTieredBpsPrice): T - - fun visitBps(bps: NewSubscriptionBpsPrice): T - - fun visitBulkBps(bulkBps: NewSubscriptionBulkBpsPrice): T - fun visitBulk(bulk: NewSubscriptionBulkPrice): T fun visitThresholdTotalAmount( @@ -5707,6 +5689,12 @@ private constructor( fun visitGroupedTiered(groupedTiered: NewSubscriptionGroupedTieredPrice): T + fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ): T + + fun visitMinimum(minimum: Minimum): T + /** * Maps an unknown variant of [Price] to a value of type [T]. * @@ -5754,24 +5742,6 @@ private constructor( ) ?.let { Price(tiered = it, _json = json) } ?: Price(_json = json) } - "tiered_bps" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(tieredBps = it, _json = json) } ?: Price(_json = json) - } - "bps" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(bps = it, _json = json) } ?: Price(_json = json) - } - "bulk_bps" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(bulkBps = it, _json = json) } ?: Price(_json = json) - } "bulk" -> { return tryDeserialize(node, jacksonTypeRef()) ?.let { Price(bulk = it, _json = json) } ?: Price(_json = json) @@ -5940,6 +5910,19 @@ private constructor( ?.let { Price(groupedTiered = it, _json = json) } ?: Price(_json = json) } + "grouped_with_min_max_thresholds" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedWithMinMaxThresholds = it, _json = json) } + ?: Price(_json = json) + } + "minimum" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(minimum = it, _json = json) + } ?: Price(_json = json) + } } return Price(_json = json) @@ -5958,9 +5941,6 @@ private constructor( value.package_ != null -> generator.writeObject(value.package_) value.matrix != null -> generator.writeObject(value.matrix) value.tiered != null -> generator.writeObject(value.tiered) - value.tieredBps != null -> generator.writeObject(value.tieredBps) - value.bps != null -> generator.writeObject(value.bps) - value.bulkBps != null -> generator.writeObject(value.bulkBps) value.bulk != null -> generator.writeObject(value.bulk) value.thresholdTotalAmount != null -> generator.writeObject(value.thresholdTotalAmount) @@ -6000,1181 +5980,3058 @@ private constructor( value.tieredPackageWithMinimum != null -> generator.writeObject(value.tieredPackageWithMinimum) value.groupedTiered != null -> generator.writeObject(value.groupedTiered) + value.groupedWithMinMaxThresholds != null -> + generator.writeObject(value.groupedWithMinMaxThresholds) + value.minimum != null -> generator.writeObject(value.minimum) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid Price") } } } - } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + class GroupedWithMinMaxThresholds + private constructor( + private val cadence: JsonField, + private val groupedWithMinMaxThresholdsConfig: + JsonField, + private val itemId: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("grouped_with_min_max_thresholds_config") + @ExcludeMissing + groupedWithMinMaxThresholdsConfig: + JsonField = + JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + groupedWithMinMaxThresholdsConfig, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + mutableMapOf(), + ) - return other is AddPrice && - allocationPrice == other.allocationPrice && - discounts == other.discounts && - endDate == other.endDate && - externalPriceId == other.externalPriceId && - maximumAmount == other.maximumAmount && - minimumAmount == other.minimumAmount && - planPhaseOrder == other.planPhaseOrder && - price == other.price && - priceId == other.priceId && - startDate == other.startDate && - additionalProperties == other.additionalProperties - } + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") - private val hashCode: Int by lazy { - Objects.hash( - allocationPrice, - discounts, - endDate, - externalPriceId, - maximumAmount, - minimumAmount, - planPhaseOrder, - price, - priceId, - startDate, - additionalProperties, - ) - } + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupedWithMinMaxThresholdsConfig(): GroupedWithMinMaxThresholdsConfig = + groupedWithMinMaxThresholdsConfig.getRequired( + "grouped_with_min_max_thresholds_config" + ) - override fun hashCode(): Int = hashCode + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") - override fun toString() = - "AddPrice{allocationPrice=$allocationPrice, discounts=$discounts, endDate=$endDate, externalPriceId=$externalPriceId, maximumAmount=$maximumAmount, minimumAmount=$minimumAmount, planPhaseOrder=$planPhaseOrder, price=$price, priceId=$priceId, startDate=$startDate, additionalProperties=$additionalProperties}" - } + /** + * Expected to always return the following: + * ```kotlin + * JsonValue.from("grouped_with_min_max_thresholds") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType - @Deprecated("deprecated") - class ExternalMarketplace - @JsonCreator - private constructor(private val value: JsonField) : Enum { + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API may respond with new members that the SDK is - * unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = billableMetricId.getNullable("billable_metric_id") - companion object { + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") - val GOOGLE = of("google") + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") - val AWS = of("aws") + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") - val AZURE = of("azure") + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") - fun of(value: String) = ExternalMarketplace(JsonField.of(value)) - } + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") - /** An enum containing [ExternalMarketplace]'s known values. */ - enum class Known { - GOOGLE, - AWS, - AZURE, - } + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") - /** - * An enum containing [ExternalMarketplace]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [ExternalMarketplace] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if the - * SDK is on an older version than the API, then the API may respond with new members that - * the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - GOOGLE, - AWS, - AZURE, - /** - * An enum member indicating that [ExternalMarketplace] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") - /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you want - * to throw for the unknown case. - */ - fun value(): Value = - when (this) { - GOOGLE -> Value.GOOGLE - AWS -> Value.AWS - AZURE -> Value.AZURE - else -> Value._UNKNOWN - } + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and don't - * want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known member. - */ - fun known(): Known = - when (this) { - GOOGLE -> Known.GOOGLE - AWS -> Known.AWS - AZURE -> Known.AZURE - else -> throw OrbInvalidDataException("Unknown ExternalMarketplace: $value") - } + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + invoiceGroupingKey.getNullable("invoice_grouping_key") - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the expected - * primitive type. - */ - fun asString(): String = - _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - private var validated: Boolean = false + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") - fun validate(): ExternalMarketplace = apply { - if (validated) { - return@apply - } + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") - known() - validated = true - } + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** + * Returns the raw JSON value of [groupedWithMinMaxThresholdsConfig]. + * + * Unlike [groupedWithMinMaxThresholdsConfig], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("grouped_with_min_max_thresholds_config") + @ExcludeMissing + fun _groupedWithMinMaxThresholdsConfig(): + JsonField = groupedWithMinMaxThresholdsConfig - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - return other is ExternalMarketplace && value == other.value - } + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId - override fun hashCode() = value.hashCode() + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance - override fun toString() = value.toString() - } + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by setting - * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to - * `null`. - */ - class Metadata - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig - fun toBuilder() = Builder().from(this) + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency - companion object { + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration - /** Returns a mutable builder for constructing an instance of [Metadata]. */ - fun builder() = Builder() - } + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId - /** A builder for [Metadata]. */ - class Builder internal constructor() { + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - private var additionalProperties: MutableMap = mutableMapOf() + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - internal fun from(metadata: Metadata) = apply { - additionalProperties = metadata.additionalProperties.toMutableMap() - } + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [GroupedWithMinMaxThresholds]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .groupedWithMinMaxThresholdsConfig() + * .itemId() + * .name() + * ``` + */ + fun builder() = Builder() + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** A builder for [GroupedWithMinMaxThresholds]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var groupedWithMinMaxThresholdsConfig: + JsonField? = + null + private var itemId: JsonField? = null + private var modelType: JsonValue = + JsonValue.from("grouped_with_min_max_thresholds") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds) = + apply { + cadence = groupedWithMinMaxThresholds.cadence + groupedWithMinMaxThresholdsConfig = + groupedWithMinMaxThresholds.groupedWithMinMaxThresholdsConfig + itemId = groupedWithMinMaxThresholds.itemId + modelType = groupedWithMinMaxThresholds.modelType + name = groupedWithMinMaxThresholds.name + billableMetricId = groupedWithMinMaxThresholds.billableMetricId + billedInAdvance = groupedWithMinMaxThresholds.billedInAdvance + billingCycleConfiguration = + groupedWithMinMaxThresholds.billingCycleConfiguration + conversionRate = groupedWithMinMaxThresholds.conversionRate + conversionRateConfig = groupedWithMinMaxThresholds.conversionRateConfig + currency = groupedWithMinMaxThresholds.currency + dimensionalPriceConfiguration = + groupedWithMinMaxThresholds.dimensionalPriceConfiguration + externalPriceId = groupedWithMinMaxThresholds.externalPriceId + fixedPriceQuantity = groupedWithMinMaxThresholds.fixedPriceQuantity + invoiceGroupingKey = groupedWithMinMaxThresholds.invoiceGroupingKey + invoicingCycleConfiguration = + groupedWithMinMaxThresholds.invoicingCycleConfiguration + metadata = groupedWithMinMaxThresholds.metadata + referenceId = groupedWithMinMaxThresholds.referenceId + additionalProperties = + groupedWithMinMaxThresholds.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + fun groupedWithMinMaxThresholdsConfig( + groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + ) = + groupedWithMinMaxThresholdsConfig( + JsonField.of(groupedWithMinMaxThresholdsConfig) + ) - /** - * Returns an immutable instance of [Metadata]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } + /** + * Sets [Builder.groupedWithMinMaxThresholdsConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.groupedWithMinMaxThresholdsConfig] with a + * well-typed [GroupedWithMinMaxThresholdsConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun groupedWithMinMaxThresholdsConfig( + groupedWithMinMaxThresholdsConfig: + JsonField + ) = apply { + this.groupedWithMinMaxThresholdsConfig = groupedWithMinMaxThresholdsConfig + } - private var validated: Boolean = false + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("grouped_with_min_max_thresholds") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } - fun validate(): Metadata = apply { - if (validated) { - return@apply - } + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } - validated = true - } + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) - return other is Metadata && additionalProperties == other.additionalProperties - } + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } - override fun hashCode(): Int = hashCode + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) - class RemoveAdjustment - private constructor( - private val adjustmentId: JsonField, - private val additionalProperties: MutableMap, - ) { + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } - @JsonCreator - private constructor( - @JsonProperty("adjustment_id") - @ExcludeMissing - adjustmentId: JsonField = JsonMissing.of() - ) : this(adjustmentId, mutableMapOf()) + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** - * The id of the adjustment to remove on the subscription. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun adjustmentId(): String = adjustmentId.getRequired("adjustment_id") + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * Returns the raw JSON value of [adjustmentId]. - * - * Unlike [adjustmentId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("adjustment_id") - @ExcludeMissing - fun _adjustmentId(): JsonField = adjustmentId + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - fun toBuilder() = Builder().from(this) + /** + * Returns an immutable instance of [GroupedWithMinMaxThresholds]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .groupedWithMinMaxThresholdsConfig() + * .itemId() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedWithMinMaxThresholds = + GroupedWithMinMaxThresholds( + checkRequired("cadence", cadence), + checkRequired( + "groupedWithMinMaxThresholdsConfig", + groupedWithMinMaxThresholdsConfig, + ), + checkRequired("itemId", itemId), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } - companion object { + private var validated: Boolean = false - /** - * Returns a mutable builder for constructing an instance of [RemoveAdjustment]. - * - * The following fields are required: - * ```kotlin - * .adjustmentId() - * ``` - */ - fun builder() = Builder() - } + fun validate(): GroupedWithMinMaxThresholds = apply { + if (validated) { + return@apply + } - /** A builder for [RemoveAdjustment]. */ - class Builder internal constructor() { + cadence().validate() + groupedWithMinMaxThresholdsConfig().validate() + itemId() + _modelType().let { + if (it != JsonValue.from("grouped_with_min_max_thresholds")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + metadata()?.validate() + referenceId() + validated = true + } - private var adjustmentId: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - internal fun from(removeAdjustment: RemoveAdjustment) = apply { - adjustmentId = removeAdjustment.adjustmentId - additionalProperties = removeAdjustment.additionalProperties.toMutableMap() - } + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (groupedWithMinMaxThresholdsConfig.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + modelType.let { + if (it == JsonValue.from("grouped_with_min_max_thresholds")) 1 else 0 + } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } - /** The id of the adjustment to remove on the subscription. */ - fun adjustmentId(adjustmentId: String) = adjustmentId(JsonField.of(adjustmentId)) + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } - /** - * Sets [Builder.adjustmentId] to an arbitrary JSON value. - * - * You should usually call [Builder.adjustmentId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun adjustmentId(adjustmentId: JsonField) = apply { - this.adjustmentId = adjustmentId - } + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + return other is Cadence && value == other.value + } - /** - * Returns an immutable instance of [RemoveAdjustment]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```kotlin - * .adjustmentId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): RemoveAdjustment = - RemoveAdjustment( - checkRequired("adjustmentId", adjustmentId), - additionalProperties.toMutableMap(), - ) - } + override fun hashCode() = value.hashCode() - private var validated: Boolean = false + override fun toString() = value.toString() + } - fun validate(): RemoveAdjustment = apply { - if (validated) { - return@apply - } + class GroupedWithMinMaxThresholdsConfig + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { - adjustmentId() - validated = true - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + fun toBuilder() = Builder().from(this) - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = (if (adjustmentId.asKnown() == null) 0 else 1) + companion object { - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * Returns a mutable builder for constructing an instance of + * [GroupedWithMinMaxThresholdsConfig]. + */ + fun builder() = Builder() + } - return other is RemoveAdjustment && - adjustmentId == other.adjustmentId && - additionalProperties == other.additionalProperties - } + /** A builder for [GroupedWithMinMaxThresholdsConfig]. */ + class Builder internal constructor() { - private val hashCode: Int by lazy { Objects.hash(adjustmentId, additionalProperties) } + private var additionalProperties: MutableMap = + mutableMapOf() - override fun hashCode(): Int = hashCode + internal fun from( + groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + ) = apply { + additionalProperties = + groupedWithMinMaxThresholdsConfig.additionalProperties + .toMutableMap() + } - override fun toString() = - "RemoveAdjustment{adjustmentId=$adjustmentId, additionalProperties=$additionalProperties}" - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - class RemovePrice - private constructor( - private val externalPriceId: JsonField, - private val priceId: JsonField, - private val additionalProperties: MutableMap, - ) { + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - @JsonCreator - private constructor( - @JsonProperty("external_price_id") - @ExcludeMissing - externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("price_id") @ExcludeMissing priceId: JsonField = JsonMissing.of(), - ) : this(externalPriceId, priceId, mutableMapOf()) + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - /** - * The external price id of the price to remove on the subscription. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - /** - * The id of the price to remove on the subscription. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun priceId(): String? = priceId.getNullable("price_id") + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - /** - * Returns the raw JSON value of [externalPriceId]. - * - * Unlike [externalPriceId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId + /** + * Returns an immutable instance of [GroupedWithMinMaxThresholdsConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): GroupedWithMinMaxThresholdsConfig = + GroupedWithMinMaxThresholdsConfig(additionalProperties.toImmutable()) + } - /** - * Returns the raw JSON value of [priceId]. - * - * Unlike [priceId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId + private var validated: Boolean = false - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + fun validate(): GroupedWithMinMaxThresholdsConfig = apply { + if (validated) { + return@apply + } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + validated = true + } - fun toBuilder() = Builder().from(this) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - companion object { + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } - /** Returns a mutable builder for constructing an instance of [RemovePrice]. */ - fun builder() = Builder() - } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** A builder for [RemovePrice]. */ - class Builder internal constructor() { + return other is GroupedWithMinMaxThresholdsConfig && + additionalProperties == other.additionalProperties + } - private var externalPriceId: JsonField = JsonMissing.of() - private var priceId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - internal fun from(removePrice: RemovePrice) = apply { - externalPriceId = removePrice.externalPriceId - priceId = removePrice.priceId - additionalProperties = removePrice.additionalProperties.toMutableMap() - } + override fun hashCode(): Int = hashCode - /** The external price id of the price to remove on the subscription. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) + override fun toString() = + "GroupedWithMinMaxThresholdsConfig{additionalProperties=$additionalProperties}" + } - /** - * Sets [Builder.externalPriceId] to an arbitrary JSON value. - * - * You should usually call [Builder.externalPriceId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun externalPriceId(externalPriceId: JsonField) = apply { - this.externalPriceId = externalPriceId - } + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { - /** The id of the price to remove on the subscription. */ - fun priceId(priceId: String?) = priceId(JsonField.ofNullable(priceId)) + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties - /** - * Sets [Builder.priceId] to an arbitrary JSON value. - * - * You should usually call [Builder.priceId] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun priceId(priceId: JsonField) = apply { this.priceId = priceId } + fun toBuilder() = Builder().from(this) - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + companion object { - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + /** A builder for [Metadata]. */ + class Builder internal constructor() { - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + private var additionalProperties: MutableMap = + mutableMapOf() - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } - /** - * Returns an immutable instance of [RemovePrice]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): RemovePrice = - RemovePrice(externalPriceId, priceId, additionalProperties.toMutableMap()) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - private var validated: Boolean = false + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun validate(): RemovePrice = apply { - if (validated) { - return@apply - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - externalPriceId() - priceId() - validated = true - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (if (externalPriceId.asKnown() == null) 0 else 1) + - (if (priceId.asKnown() == null) 0 else 1) + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + private var validated: Boolean = false - return other is RemovePrice && - externalPriceId == other.externalPriceId && - priceId == other.priceId && - additionalProperties == other.additionalProperties - } + fun validate(): Metadata = apply { + if (validated) { + return@apply + } - private val hashCode: Int by lazy { - Objects.hash(externalPriceId, priceId, additionalProperties) - } + validated = true + } - override fun hashCode(): Int = hashCode + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - override fun toString() = - "RemovePrice{externalPriceId=$externalPriceId, priceId=$priceId, additionalProperties=$additionalProperties}" - } + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } - class ReplaceAdjustment - private constructor( - private val adjustment: JsonField, - private val replacesAdjustmentId: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("adjustment") - @ExcludeMissing - adjustment: JsonField = JsonMissing.of(), - @JsonProperty("replaces_adjustment_id") - @ExcludeMissing - replacesAdjustmentId: JsonField = JsonMissing.of(), - ) : this(adjustment, replacesAdjustmentId, mutableMapOf()) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * The definition of a new adjustment to create and add to the subscription. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun adjustment(): Adjustment = adjustment.getRequired("adjustment") + return other is Metadata && + additionalProperties == other.additionalProperties + } - /** - * The id of the adjustment on the plan to replace in the subscription. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun replacesAdjustmentId(): String = - replacesAdjustmentId.getRequired("replaces_adjustment_id") + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /** - * Returns the raw JSON value of [adjustment]. - * - * Unlike [adjustment], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("adjustment") - @ExcludeMissing - fun _adjustment(): JsonField = adjustment + override fun hashCode(): Int = hashCode - /** - * Returns the raw JSON value of [replacesAdjustmentId]. - * - * Unlike [replacesAdjustmentId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("replaces_adjustment_id") - @ExcludeMissing - fun _replacesAdjustmentId(): JsonField = replacesAdjustmentId + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + return other is GroupedWithMinMaxThresholds && + cadence == other.cadence && + groupedWithMinMaxThresholdsConfig == + other.groupedWithMinMaxThresholdsConfig && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } - fun toBuilder() = Builder().from(this) + private val hashCode: Int by lazy { + Objects.hash( + cadence, + groupedWithMinMaxThresholdsConfig, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties, + ) + } - companion object { + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedWithMinMaxThresholds{cadence=$cadence, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class Minimum + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val minimumConfig: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("minimum_config") + @ExcludeMissing + minimumConfig: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + minimumConfig, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + mutableMapOf(), + ) - /** - * Returns a mutable builder for constructing an instance of [ReplaceAdjustment]. - * - * The following fields are required: - * ```kotlin - * .adjustment() - * .replacesAdjustmentId() - * ``` - */ - fun builder() = Builder() - } + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") - /** A builder for [ReplaceAdjustment]. */ - class Builder internal constructor() { + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") - private var adjustment: JsonField? = null - private var replacesAdjustmentId: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun minimumConfig(): MinimumConfig = minimumConfig.getRequired("minimum_config") - internal fun from(replaceAdjustment: ReplaceAdjustment) = apply { - adjustment = replaceAdjustment.adjustment - replacesAdjustmentId = replaceAdjustment.replacesAdjustmentId - additionalProperties = replaceAdjustment.additionalProperties.toMutableMap() - } + /** + * Expected to always return the following: + * ```kotlin + * JsonValue.from("minimum") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType - /** The definition of a new adjustment to create and add to the subscription. */ - fun adjustment(adjustment: Adjustment) = adjustment(JsonField.of(adjustment)) + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") - /** - * Sets [Builder.adjustment] to an arbitrary JSON value. - * - * You should usually call [Builder.adjustment] with a well-typed [Adjustment] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun adjustment(adjustment: JsonField) = apply { - this.adjustment = adjustment - } + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = billableMetricId.getNullable("billable_metric_id") - /** - * Alias for calling [adjustment] with - * `Adjustment.ofPercentageDiscount(percentageDiscount)`. - */ - fun adjustment(percentageDiscount: NewPercentageDiscount) = - adjustment(Adjustment.ofPercentageDiscount(percentageDiscount)) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") - /** - * Alias for calling [adjustment] with the following: - * ```kotlin - * NewPercentageDiscount.builder() - * .adjustmentType(NewPercentageDiscount.AdjustmentType.PERCENTAGE_DISCOUNT) - * .percentageDiscount(percentageDiscount) - * .build() - * ``` - */ - fun percentageDiscountAdjustment(percentageDiscount: Double) = - adjustment( - NewPercentageDiscount.builder() - .adjustmentType(NewPercentageDiscount.AdjustmentType.PERCENTAGE_DISCOUNT) - .percentageDiscount(percentageDiscount) - .build() - ) + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") - /** Alias for calling [adjustment] with `Adjustment.ofUsageDiscount(usageDiscount)`. */ - fun adjustment(usageDiscount: NewUsageDiscount) = - adjustment(Adjustment.ofUsageDiscount(usageDiscount)) + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") - /** - * Alias for calling [adjustment] with the following: - * ```kotlin - * NewUsageDiscount.builder() - * .adjustmentType(NewUsageDiscount.AdjustmentType.USAGE_DISCOUNT) - * .usageDiscount(usageDiscount) - * .build() - * ``` - */ - fun usageDiscountAdjustment(usageDiscount: Double) = - adjustment( - NewUsageDiscount.builder() - .adjustmentType(NewUsageDiscount.AdjustmentType.USAGE_DISCOUNT) - .usageDiscount(usageDiscount) - .build() - ) + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") - /** - * Alias for calling [adjustment] with `Adjustment.ofAmountDiscount(amountDiscount)`. - */ - fun adjustment(amountDiscount: NewAmountDiscount) = - adjustment(Adjustment.ofAmountDiscount(amountDiscount)) + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") - /** - * Alias for calling [adjustment] with the following: - * ```kotlin - * NewAmountDiscount.builder() - * .adjustmentType(NewAmountDiscount.AdjustmentType.AMOUNT_DISCOUNT) - * .amountDiscount(amountDiscount) - * .build() - * ``` - */ - fun amountDiscountAdjustment(amountDiscount: String) = - adjustment( - NewAmountDiscount.builder() - .adjustmentType(NewAmountDiscount.AdjustmentType.AMOUNT_DISCOUNT) - .amountDiscount(amountDiscount) - .build() - ) + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") - /** Alias for calling [adjustment] with `Adjustment.ofMinimum(minimum)`. */ - fun adjustment(minimum: NewMinimum) = adjustment(Adjustment.ofMinimum(minimum)) + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") - /** Alias for calling [adjustment] with `Adjustment.ofMaximum(maximum)`. */ - fun adjustment(maximum: NewMaximum) = adjustment(Adjustment.ofMaximum(maximum)) + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") - /** - * Alias for calling [adjustment] with the following: - * ```kotlin - * NewMaximum.builder() - * .adjustmentType(NewMaximum.AdjustmentType.MAXIMUM) - * .maximumAmount(maximumAmount) - * .build() - * ``` - */ - fun maximumAdjustment(maximumAmount: String) = - adjustment( - NewMaximum.builder() - .adjustmentType(NewMaximum.AdjustmentType.MAXIMUM) - .maximumAmount(maximumAmount) - .build() - ) + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + invoiceGroupingKey.getNullable("invoice_grouping_key") - /** The id of the adjustment on the plan to replace in the subscription. */ - fun replacesAdjustmentId(replacesAdjustmentId: String) = - replacesAdjustmentId(JsonField.of(replacesAdjustmentId)) + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - /** - * Sets [Builder.replacesAdjustmentId] to an arbitrary JSON value. - * - * You should usually call [Builder.replacesAdjustmentId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun replacesAdjustmentId(replacesAdjustmentId: JsonField) = apply { - this.replacesAdjustmentId = replacesAdjustmentId - } + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + /** + * Returns the raw JSON value of [minimumConfig]. + * + * Unlike [minimumConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("minimum_config") + @ExcludeMissing + fun _minimumConfig(): JsonField = minimumConfig - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - /** - * Returns an immutable instance of [ReplaceAdjustment]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```kotlin - * .adjustment() - * .replacesAdjustmentId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): ReplaceAdjustment = - ReplaceAdjustment( - checkRequired("adjustment", adjustment), - checkRequired("replacesAdjustmentId", replacesAdjustmentId), - additionalProperties.toMutableMap(), - ) - } + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId - private var validated: Boolean = false + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance - fun validate(): ReplaceAdjustment = apply { - if (validated) { - return@apply - } + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration - adjustment().validate() - replacesAdjustmentId() - validated = true - } + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (adjustment.asKnown()?.validity() ?: 0) + - (if (replacesAdjustmentId.asKnown() == null) 0 else 1) + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency - /** The definition of a new adjustment to create and add to the subscription. */ - @JsonDeserialize(using = Adjustment.Deserializer::class) - @JsonSerialize(using = Adjustment.Serializer::class) - class Adjustment - private constructor( - private val percentageDiscount: NewPercentageDiscount? = null, - private val usageDiscount: NewUsageDiscount? = null, - private val amountDiscount: NewAmountDiscount? = null, - private val minimum: NewMinimum? = null, - private val maximum: NewMaximum? = null, - private val _json: JsonValue? = null, - ) { + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration - fun percentageDiscount(): NewPercentageDiscount? = percentageDiscount + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId - fun usageDiscount(): NewUsageDiscount? = usageDiscount + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - fun amountDiscount(): NewAmountDiscount? = amountDiscount + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - fun minimum(): NewMinimum? = minimum + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration - fun maximum(): NewMaximum? = maximum + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata - fun isPercentageDiscount(): Boolean = percentageDiscount != null + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId - fun isUsageDiscount(): Boolean = usageDiscount != null + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - fun isAmountDiscount(): Boolean = amountDiscount != null + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Minimum]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .minimumConfig() + * .name() + * ``` + */ + fun builder() = Builder() + } - fun isMinimum(): Boolean = minimum != null + /** A builder for [Minimum]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var minimumConfig: JsonField? = null + private var modelType: JsonValue = JsonValue.from("minimum") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(minimum: Minimum) = apply { + cadence = minimum.cadence + itemId = minimum.itemId + minimumConfig = minimum.minimumConfig + modelType = minimum.modelType + name = minimum.name + billableMetricId = minimum.billableMetricId + billedInAdvance = minimum.billedInAdvance + billingCycleConfiguration = minimum.billingCycleConfiguration + conversionRate = minimum.conversionRate + conversionRateConfig = minimum.conversionRateConfig + currency = minimum.currency + dimensionalPriceConfiguration = minimum.dimensionalPriceConfiguration + externalPriceId = minimum.externalPriceId + fixedPriceQuantity = minimum.fixedPriceQuantity + invoiceGroupingKey = minimum.invoiceGroupingKey + invoicingCycleConfiguration = minimum.invoicingCycleConfiguration + metadata = minimum.metadata + referenceId = minimum.referenceId + additionalProperties = minimum.additionalProperties.toMutableMap() + } - fun isMaximum(): Boolean = maximum != null + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun minimumConfig(minimumConfig: MinimumConfig) = + minimumConfig(JsonField.of(minimumConfig)) + + /** + * Sets [Builder.minimumConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumConfig] with a well-typed + * [MinimumConfig] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun minimumConfig(minimumConfig: JsonField) = apply { + this.minimumConfig = minimumConfig + } - fun asPercentageDiscount(): NewPercentageDiscount = - percentageDiscount.getOrThrow("percentageDiscount") + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("minimum") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } - fun asUsageDiscount(): NewUsageDiscount = usageDiscount.getOrThrow("usageDiscount") + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } - fun asAmountDiscount(): NewAmountDiscount = amountDiscount.getOrThrow("amountDiscount") + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } - fun asMinimum(): NewMinimum = minimum.getOrThrow("minimum") + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) - fun asMaximum(): NewMaximum = maximum.getOrThrow("maximum") + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) - fun _json(): JsonValue? = _json + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) - fun accept(visitor: Visitor): T = - when { - percentageDiscount != null -> - visitor.visitPercentageDiscount(percentageDiscount) - usageDiscount != null -> visitor.visitUsageDiscount(usageDiscount) - amountDiscount != null -> visitor.visitAmountDiscount(amountDiscount) - minimum != null -> visitor.visitMinimum(minimum) - maximum != null -> visitor.visitMaximum(maximum) - else -> visitor.unknown(_json) - } + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } - private var validated: Boolean = false + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } - fun validate(): Adjustment = apply { - if (validated) { - return@apply - } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } - accept( - object : Visitor { - override fun visitPercentageDiscount( - percentageDiscount: NewPercentageDiscount - ) { - percentageDiscount.validate() - } + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) - override fun visitUsageDiscount(usageDiscount: NewUsageDiscount) { - usageDiscount.validate() - } + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } - override fun visitAmountDiscount(amountDiscount: NewAmountDiscount) { - amountDiscount.validate() - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - override fun visitMinimum(minimum: NewMinimum) { - minimum.validate() - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - override fun visitMaximum(maximum: NewMaximum) { - maximum.validate() + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) } - ) - validated = true - } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Minimum]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .minimumConfig() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Minimum = + Minimum( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("minimumConfig", minimumConfig), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitPercentageDiscount( - percentageDiscount: NewPercentageDiscount - ) = percentageDiscount.validity() + private var validated: Boolean = false - override fun visitUsageDiscount(usageDiscount: NewUsageDiscount) = - usageDiscount.validity() + fun validate(): Minimum = apply { + if (validated) { + return@apply + } - override fun visitAmountDiscount(amountDiscount: NewAmountDiscount) = - amountDiscount.validity() + cadence().validate() + itemId() + minimumConfig().validate() + _modelType().let { + if (it != JsonValue.from("minimum")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + metadata()?.validate() + referenceId() + validated = true + } - override fun visitMinimum(minimum: NewMinimum) = minimum.validity() + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - override fun visitMaximum(maximum: NewMaximum) = maximum.validity() + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + (minimumConfig.asKnown()?.validity() ?: 0) + + modelType.let { if (it == JsonValue.from("minimum")) 1 else 0 } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } - override fun unknown(json: JsonValue?) = 0 + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, } - ) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } - return other is Adjustment && - percentageDiscount == other.percentageDiscount && - usageDiscount == other.usageDiscount && - amountDiscount == other.amountDiscount && - minimum == other.minimum && - maximum == other.maximum - } + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } - override fun hashCode(): Int = - Objects.hash(percentageDiscount, usageDiscount, amountDiscount, minimum, maximum) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - override fun toString(): String = - when { - percentageDiscount != null -> - "Adjustment{percentageDiscount=$percentageDiscount}" - usageDiscount != null -> "Adjustment{usageDiscount=$usageDiscount}" - amountDiscount != null -> "Adjustment{amountDiscount=$amountDiscount}" - minimum != null -> "Adjustment{minimum=$minimum}" - maximum != null -> "Adjustment{maximum=$maximum}" - _json != null -> "Adjustment{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Adjustment") - } + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - companion object { + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun ofPercentageDiscount(percentageDiscount: NewPercentageDiscount) = - Adjustment(percentageDiscount = percentageDiscount) + return other is Cadence && value == other.value + } - fun ofUsageDiscount(usageDiscount: NewUsageDiscount) = - Adjustment(usageDiscount = usageDiscount) + override fun hashCode() = value.hashCode() - fun ofAmountDiscount(amountDiscount: NewAmountDiscount) = - Adjustment(amountDiscount = amountDiscount) + override fun toString() = value.toString() + } - fun ofMinimum(minimum: NewMinimum) = Adjustment(minimum = minimum) + class MinimumConfig + private constructor( + private val minimumAmount: JsonField, + private val prorated: JsonField, + private val additionalProperties: MutableMap, + ) { - fun ofMaximum(maximum: NewMaximum) = Adjustment(maximum = maximum) - } + @JsonCreator + private constructor( + @JsonProperty("minimum_amount") + @ExcludeMissing + minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("prorated") + @ExcludeMissing + prorated: JsonField = JsonMissing.of(), + ) : this(minimumAmount, prorated, mutableMapOf()) + + /** + * The minimum amount to apply + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") + + /** + * By default, subtotals from minimum composite prices are prorated based on the + * service period. Set to false to disable proration. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun prorated(): Boolean? = prorated.getNullable("prorated") + + /** + * Returns the raw JSON value of [minimumAmount]. + * + * Unlike [minimumAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount + + /** + * Returns the raw JSON value of [prorated]. + * + * Unlike [prorated], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("prorated") + @ExcludeMissing + fun _prorated(): JsonField = prorated + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - /** - * An interface that defines how to map each variant of [Adjustment] to a value of type - * [T]. - */ - interface Visitor { + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [MinimumConfig]. + * + * The following fields are required: + * ```kotlin + * .minimumAmount() + * ``` + */ + fun builder() = Builder() + } - fun visitPercentageDiscount(percentageDiscount: NewPercentageDiscount): T + /** A builder for [MinimumConfig]. */ + class Builder internal constructor() { + + private var minimumAmount: JsonField? = null + private var prorated: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(minimumConfig: MinimumConfig) = apply { + minimumAmount = minimumConfig.minimumAmount + prorated = minimumConfig.prorated + additionalProperties = minimumConfig.additionalProperties.toMutableMap() + } + + /** The minimum amount to apply */ + fun minimumAmount(minimumAmount: String) = + minimumAmount(JsonField.of(minimumAmount)) + + /** + * Sets [Builder.minimumAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumAmount] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount + } + + /** + * By default, subtotals from minimum composite prices are prorated based on + * the service period. Set to false to disable proration. + */ + fun prorated(prorated: Boolean?) = prorated(JsonField.ofNullable(prorated)) + + /** + * Alias for [Builder.prorated]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun prorated(prorated: Boolean) = prorated(prorated as Boolean?) + + /** + * Sets [Builder.prorated] to an arbitrary JSON value. + * + * You should usually call [Builder.prorated] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun prorated(prorated: JsonField) = apply { + this.prorated = prorated + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [MinimumConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .minimumAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MinimumConfig = + MinimumConfig( + checkRequired("minimumAmount", minimumAmount), + prorated, + additionalProperties.toMutableMap(), + ) + } - fun visitUsageDiscount(usageDiscount: NewUsageDiscount): T + private var validated: Boolean = false - fun visitAmountDiscount(amountDiscount: NewAmountDiscount): T + fun validate(): MinimumConfig = apply { + if (validated) { + return@apply + } - fun visitMinimum(minimum: NewMinimum): T + minimumAmount() + prorated() + validated = true + } - fun visitMaximum(maximum: NewMaximum): T + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (minimumAmount.asKnown() == null) 0 else 1) + + (if (prorated.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MinimumConfig && + minimumAmount == other.minimumAmount && + prorated == other.prorated && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(minimumAmount, prorated, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MinimumConfig{minimumAmount=$minimumAmount, prorated=$prorated, additionalProperties=$additionalProperties}" + } /** - * Maps an unknown variant of [Adjustment] to a value of type [T]. - * - * An instance of [Adjustment] can contain an unknown variant if it was deserialized - * from data that doesn't match any known variant. For example, if the SDK is on an - * older version than the API, then the API may respond with new variants that the - * SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown Adjustment: $json") - } - } + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { - internal class Deserializer : BaseDeserializer(Adjustment::class) { + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties - override fun ObjectCodec.deserialize(node: JsonNode): Adjustment { - val json = JsonValue.fromJsonNode(node) - val adjustmentType = json.asObject()?.get("adjustment_type")?.asString() + fun toBuilder() = Builder().from(this) - when (adjustmentType) { - "percentage_discount" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Adjustment(percentageDiscount = it, _json = json) } - ?: Adjustment(_json = json) + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() } - "usage_discount" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(usageDiscount = it, _json = json) - } ?: Adjustment(_json = json) + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) } - "amount_discount" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(amountDiscount = it, _json = json) - } ?: Adjustment(_json = json) + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) } - "minimum" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(minimum = it, _json = json) - } ?: Adjustment(_json = json) + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) } - "maximum" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(maximum = it, _json = json) - } ?: Adjustment(_json = json) + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply } + + validated = true } - return Adjustment(_json = json) - } - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - internal class Serializer : BaseSerializer(Adjustment::class) { + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } - override fun serialize( - value: Adjustment, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.percentageDiscount != null -> - generator.writeObject(value.percentageDiscount) - value.usageDiscount != null -> generator.writeObject(value.usageDiscount) - value.amountDiscount != null -> generator.writeObject(value.amountDiscount) - value.minimum != null -> generator.writeObject(value.minimum) - value.maximum != null -> generator.writeObject(value.maximum) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Adjustment") + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } + + return other is Minimum && + cadence == other.cadence && + itemId == other.itemId && + minimumConfig == other.minimumConfig && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + minimumConfig, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties, + ) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Minimum{cadence=$cadence, itemId=$itemId, minimumConfig=$minimumConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } } @@ -7183,586 +9040,539 @@ private constructor( return true } - return other is ReplaceAdjustment && - adjustment == other.adjustment && - replacesAdjustmentId == other.replacesAdjustmentId && + return other is AddPrice && + allocationPrice == other.allocationPrice && + discounts == other.discounts && + endDate == other.endDate && + externalPriceId == other.externalPriceId && + maximumAmount == other.maximumAmount && + minimumAmount == other.minimumAmount && + planPhaseOrder == other.planPhaseOrder && + price == other.price && + priceId == other.priceId && + startDate == other.startDate && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(adjustment, replacesAdjustmentId, additionalProperties) + Objects.hash( + allocationPrice, + discounts, + endDate, + externalPriceId, + maximumAmount, + minimumAmount, + planPhaseOrder, + price, + priceId, + startDate, + additionalProperties, + ) } override fun hashCode(): Int = hashCode override fun toString() = - "ReplaceAdjustment{adjustment=$adjustment, replacesAdjustmentId=$replacesAdjustmentId, additionalProperties=$additionalProperties}" + "AddPrice{allocationPrice=$allocationPrice, discounts=$discounts, endDate=$endDate, externalPriceId=$externalPriceId, maximumAmount=$maximumAmount, minimumAmount=$minimumAmount, planPhaseOrder=$planPhaseOrder, price=$price, priceId=$priceId, startDate=$startDate, additionalProperties=$additionalProperties}" } - class ReplacePrice - private constructor( - private val replacesPriceId: JsonField, - private val allocationPrice: JsonField, - private val discounts: JsonField>, - private val externalPriceId: JsonField, - private val fixedPriceQuantity: JsonField, - private val maximumAmount: JsonField, - private val minimumAmount: JsonField, - private val price: JsonField, - private val priceId: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("replaces_price_id") - @ExcludeMissing - replacesPriceId: JsonField = JsonMissing.of(), - @JsonProperty("allocation_price") - @ExcludeMissing - allocationPrice: JsonField = JsonMissing.of(), - @JsonProperty("discounts") - @ExcludeMissing - discounts: JsonField> = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("maximum_amount") - @ExcludeMissing - maximumAmount: JsonField = JsonMissing.of(), - @JsonProperty("minimum_amount") - @ExcludeMissing - minimumAmount: JsonField = JsonMissing.of(), - @JsonProperty("price") @ExcludeMissing price: JsonField = JsonMissing.of(), - @JsonProperty("price_id") @ExcludeMissing priceId: JsonField = JsonMissing.of(), - ) : this( - replacesPriceId, - allocationPrice, - discounts, - externalPriceId, - fixedPriceQuantity, - maximumAmount, - minimumAmount, - price, - priceId, - mutableMapOf(), - ) + @Deprecated("deprecated") + class ExternalMarketplace + @JsonCreator + private constructor(private val value: JsonField) : Enum { /** - * The id of the price on the plan to replace in the subscription. + * Returns this class instance's raw value. * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. */ - fun replacesPriceId(): String = replacesPriceId.getRequired("replaces_price_id") + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val GOOGLE = of("google") + + val AWS = of("aws") + + val AZURE = of("azure") + + fun of(value: String) = ExternalMarketplace(JsonField.of(value)) + } + + /** An enum containing [ExternalMarketplace]'s known values. */ + enum class Known { + GOOGLE, + AWS, + AZURE, + } /** - * The definition of a new allocation price to create and add to the subscription. + * An enum containing [ExternalMarketplace]'s known values, as well as an [_UNKNOWN] member. * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). + * An instance of [ExternalMarketplace] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. */ - fun allocationPrice(): NewAllocationPrice? = allocationPrice.getNullable("allocation_price") + enum class Value { + GOOGLE, + AWS, + AZURE, + /** + * An enum member indicating that [ExternalMarketplace] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } /** - * [DEPRECATED] Use add_adjustments instead. The subscription's discounts for the - * replacement price. + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. */ - @Deprecated("deprecated") - fun discounts(): List? = discounts.getNullable("discounts") - - /** - * The external price id of the price to add to the subscription. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") - - /** - * The new quantity of the price, if the price is a fixed price. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun fixedPriceQuantity(): Double? = fixedPriceQuantity.getNullable("fixed_price_quantity") + fun value(): Value = + when (this) { + GOOGLE -> Value.GOOGLE + AWS -> Value.AWS + AZURE -> Value.AZURE + else -> Value._UNKNOWN + } /** - * [DEPRECATED] Use add_adjustments instead. The subscription's maximum amount for the - * replacement price. + * Returns an enum member corresponding to this class instance's value. * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - @Deprecated("deprecated") - fun maximumAmount(): String? = maximumAmount.getNullable("maximum_amount") - - /** - * [DEPRECATED] Use add_adjustments instead. The subscription's minimum amount for the - * replacement price. + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). + * @throws OrbInvalidDataException if this class instance's value is a not a known member. */ - @Deprecated("deprecated") - fun minimumAmount(): String? = minimumAmount.getNullable("minimum_amount") + fun known(): Known = + when (this) { + GOOGLE -> Known.GOOGLE + AWS -> Known.AWS + AZURE -> Known.AZURE + else -> throw OrbInvalidDataException("Unknown ExternalMarketplace: $value") + } /** - * The definition of a new price to create and add to the subscription. + * Returns this class instance's primitive wire representation. * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun price(): Price? = price.getNullable("price") - - /** - * The id of the price to add to the subscription. + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). + * @throws OrbInvalidDataException if this class instance's value does not have the expected + * primitive type. */ - fun priceId(): String? = priceId.getNullable("price_id") + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") - /** - * Returns the raw JSON value of [replacesPriceId]. - * - * Unlike [replacesPriceId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("replaces_price_id") - @ExcludeMissing - fun _replacesPriceId(): JsonField = replacesPriceId + private var validated: Boolean = false - /** - * Returns the raw JSON value of [allocationPrice]. - * - * Unlike [allocationPrice], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("allocation_price") - @ExcludeMissing - fun _allocationPrice(): JsonField = allocationPrice + fun validate(): ExternalMarketplace = apply { + if (validated) { + return@apply + } - /** - * Returns the raw JSON value of [discounts]. - * - * Unlike [discounts], this method doesn't throw if the JSON field has an unexpected type. - */ - @Deprecated("deprecated") - @JsonProperty("discounts") - @ExcludeMissing - fun _discounts(): JsonField> = discounts + known() + validated = true + } - /** - * Returns the raw JSON value of [externalPriceId]. - * - * Unlike [externalPriceId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } /** - * Returns the raw JSON value of [fixedPriceQuantity]. + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an - * unexpected type. + * Used for best match union deserialization. */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - /** - * Returns the raw JSON value of [maximumAmount]. - * - * Unlike [maximumAmount], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @Deprecated("deprecated") - @JsonProperty("maximum_amount") - @ExcludeMissing - fun _maximumAmount(): JsonField = maximumAmount + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * Returns the raw JSON value of [minimumAmount]. - * - * Unlike [minimumAmount], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @Deprecated("deprecated") - @JsonProperty("minimum_amount") - @ExcludeMissing - fun _minimumAmount(): JsonField = minimumAmount + return other is ExternalMarketplace && value == other.value + } - /** - * Returns the raw JSON value of [price]. - * - * Unlike [price], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("price") @ExcludeMissing fun _price(): JsonField = price + override fun hashCode() = value.hashCode() - /** - * Returns the raw JSON value of [priceId]. - * - * Unlike [priceId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId + override fun toString() = value.toString() + } - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by setting + * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to + * `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + fun _additionalProperties(): Map = additionalProperties fun toBuilder() = Builder().from(this) companion object { - /** - * Returns a mutable builder for constructing an instance of [ReplacePrice]. - * - * The following fields are required: - * ```kotlin - * .replacesPriceId() - * ``` - */ + /** Returns a mutable builder for constructing an instance of [Metadata]. */ fun builder() = Builder() } - /** A builder for [ReplacePrice]. */ + /** A builder for [Metadata]. */ class Builder internal constructor() { - private var replacesPriceId: JsonField? = null - private var allocationPrice: JsonField = JsonMissing.of() - private var discounts: JsonField>? = null - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var maximumAmount: JsonField = JsonMissing.of() - private var minimumAmount: JsonField = JsonMissing.of() - private var price: JsonField = JsonMissing.of() - private var priceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(replacePrice: ReplacePrice) = apply { - replacesPriceId = replacePrice.replacesPriceId - allocationPrice = replacePrice.allocationPrice - discounts = replacePrice.discounts.map { it.toMutableList() } - externalPriceId = replacePrice.externalPriceId - fixedPriceQuantity = replacePrice.fixedPriceQuantity - maximumAmount = replacePrice.maximumAmount - minimumAmount = replacePrice.minimumAmount - price = replacePrice.price - priceId = replacePrice.priceId - additionalProperties = replacePrice.additionalProperties.toMutableMap() + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() } - /** The id of the price on the plan to replace in the subscription. */ - fun replacesPriceId(replacesPriceId: String) = - replacesPriceId(JsonField.of(replacesPriceId)) + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** - * Sets [Builder.replacesPriceId] to an arbitrary JSON value. - * - * You should usually call [Builder.replacesPriceId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun replacesPriceId(replacesPriceId: JsonField) = apply { - this.replacesPriceId = replacesPriceId + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) } - /** The definition of a new allocation price to create and add to the subscription. */ - fun allocationPrice(allocationPrice: NewAllocationPrice?) = - allocationPrice(JsonField.ofNullable(allocationPrice)) + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } /** - * Sets [Builder.allocationPrice] to an arbitrary JSON value. + * Returns an immutable instance of [Metadata]. * - * You should usually call [Builder.allocationPrice] with a well-typed - * [NewAllocationPrice] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. + * Further updates to this [Builder] will not mutate the returned instance. */ - fun allocationPrice(allocationPrice: JsonField) = apply { - this.allocationPrice = allocationPrice - } + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } - /** - * [DEPRECATED] Use add_adjustments instead. The subscription's discounts for the - * replacement price. - */ - @Deprecated("deprecated") - fun discounts(discounts: List?) = - discounts(JsonField.ofNullable(discounts)) + private var validated: Boolean = false - /** - * Sets [Builder.discounts] to an arbitrary JSON value. - * - * You should usually call [Builder.discounts] with a well-typed - * `List` value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - @Deprecated("deprecated") - fun discounts(discounts: JsonField>) = apply { - this.discounts = discounts.map { it.toMutableList() } + fun validate(): Metadata = apply { + if (validated) { + return@apply } - /** - * Adds a single [DiscountOverride] to [discounts]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - @Deprecated("deprecated") - fun addDiscount(discount: DiscountOverride) = apply { - discounts = - (discounts ?: JsonField.of(mutableListOf())).also { - checkKnown("discounts", it).add(discount) - } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false } - /** The external price id of the price to add to the subscription. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } - /** - * Sets [Builder.externalPriceId] to an arbitrary JSON value. - * - * You should usually call [Builder.externalPriceId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun externalPriceId(externalPriceId: JsonField) = apply { - this.externalPriceId = externalPriceId + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - /** The new quantity of the price, if the price is a fixed price. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = - fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + return other is Metadata && additionalProperties == other.additionalProperties + } - /** - * Alias for [Builder.fixedPriceQuantity]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + class RemoveAdjustment + private constructor( + private val adjustmentId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("adjustment_id") + @ExcludeMissing + adjustmentId: JsonField = JsonMissing.of() + ) : this(adjustmentId, mutableMapOf()) + + /** + * The id of the adjustment to remove on the subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun adjustmentId(): String = adjustmentId.getRequired("adjustment_id") + + /** + * Returns the raw JSON value of [adjustmentId]. + * + * Unlike [adjustmentId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("adjustment_id") + @ExcludeMissing + fun _adjustmentId(): JsonField = adjustmentId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { /** - * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * Returns a mutable builder for constructing an instance of [RemoveAdjustment]. * - * You should usually call [Builder.fixedPriceQuantity] with a well-typed [Double] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. + * The following fields are required: + * ```kotlin + * .adjustmentId() + * ``` */ - fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { - this.fixedPriceQuantity = fixedPriceQuantity + fun builder() = Builder() + } + + /** A builder for [RemoveAdjustment]. */ + class Builder internal constructor() { + + private var adjustmentId: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(removeAdjustment: RemoveAdjustment) = apply { + adjustmentId = removeAdjustment.adjustmentId + additionalProperties = removeAdjustment.additionalProperties.toMutableMap() } - /** - * [DEPRECATED] Use add_adjustments instead. The subscription's maximum amount for the - * replacement price. - */ - @Deprecated("deprecated") - fun maximumAmount(maximumAmount: String?) = - maximumAmount(JsonField.ofNullable(maximumAmount)) + /** The id of the adjustment to remove on the subscription. */ + fun adjustmentId(adjustmentId: String) = adjustmentId(JsonField.of(adjustmentId)) /** - * Sets [Builder.maximumAmount] to an arbitrary JSON value. + * Sets [Builder.adjustmentId] to an arbitrary JSON value. * - * You should usually call [Builder.maximumAmount] with a well-typed [String] value + * You should usually call [Builder.adjustmentId] with a well-typed [String] value * instead. This method is primarily for setting the field to an undocumented or not yet * supported value. */ - @Deprecated("deprecated") - fun maximumAmount(maximumAmount: JsonField) = apply { - this.maximumAmount = maximumAmount + fun adjustmentId(adjustmentId: JsonField) = apply { + this.adjustmentId = adjustmentId } - /** - * [DEPRECATED] Use add_adjustments instead. The subscription's minimum amount for the - * replacement price. - */ - @Deprecated("deprecated") - fun minimumAmount(minimumAmount: String?) = - minimumAmount(JsonField.ofNullable(minimumAmount)) + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** - * Sets [Builder.minimumAmount] to an arbitrary JSON value. - * - * You should usually call [Builder.minimumAmount] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - @Deprecated("deprecated") - fun minimumAmount(minimumAmount: JsonField) = apply { - this.minimumAmount = minimumAmount + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) } - /** The definition of a new price to create and add to the subscription. */ - fun price(price: Price?) = price(JsonField.ofNullable(price)) + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } /** - * Sets [Builder.price] to an arbitrary JSON value. + * Returns an immutable instance of [RemoveAdjustment]. * - * You should usually call [Builder.price] with a well-typed [Price] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .adjustmentId() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ - fun price(price: JsonField) = apply { this.price = price } - - /** Alias for calling [price] with `Price.ofUnit(unit)`. */ - fun price(unit: NewSubscriptionUnitPrice) = price(Price.ofUnit(unit)) - - /** Alias for calling [price] with `Price.ofPackage(package_)`. */ - fun price(package_: NewSubscriptionPackagePrice) = price(Price.ofPackage(package_)) - - /** Alias for calling [price] with `Price.ofMatrix(matrix)`. */ - fun price(matrix: NewSubscriptionMatrixPrice) = price(Price.ofMatrix(matrix)) + fun build(): RemoveAdjustment = + RemoveAdjustment( + checkRequired("adjustmentId", adjustmentId), + additionalProperties.toMutableMap(), + ) + } - /** Alias for calling [price] with `Price.ofTiered(tiered)`. */ - fun price(tiered: NewSubscriptionTieredPrice) = price(Price.ofTiered(tiered)) + private var validated: Boolean = false - /** Alias for calling [price] with `Price.ofTieredBps(tieredBps)`. */ - fun price(tieredBps: NewSubscriptionTieredBpsPrice) = - price(Price.ofTieredBps(tieredBps)) + fun validate(): RemoveAdjustment = apply { + if (validated) { + return@apply + } - /** Alias for calling [price] with `Price.ofBps(bps)`. */ - fun price(bps: NewSubscriptionBpsPrice) = price(Price.ofBps(bps)) + adjustmentId() + validated = true + } - /** Alias for calling [price] with `Price.ofBulkBps(bulkBps)`. */ - fun price(bulkBps: NewSubscriptionBulkBpsPrice) = price(Price.ofBulkBps(bulkBps)) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - /** Alias for calling [price] with `Price.ofBulk(bulk)`. */ - fun price(bulk: NewSubscriptionBulkPrice) = price(Price.ofBulk(bulk)) + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = (if (adjustmentId.asKnown() == null) 0 else 1) - /** - * Alias for calling [price] with `Price.ofThresholdTotalAmount(thresholdTotalAmount)`. - */ - fun price(thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice) = - price(Price.ofThresholdTotalAmount(thresholdTotalAmount)) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** Alias for calling [price] with `Price.ofTieredPackage(tieredPackage)`. */ - fun price(tieredPackage: NewSubscriptionTieredPackagePrice) = - price(Price.ofTieredPackage(tieredPackage)) + return other is RemoveAdjustment && + adjustmentId == other.adjustmentId && + additionalProperties == other.additionalProperties + } - /** Alias for calling [price] with `Price.ofTieredWithMinimum(tieredWithMinimum)`. */ - fun price(tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice) = - price(Price.ofTieredWithMinimum(tieredWithMinimum)) + private val hashCode: Int by lazy { Objects.hash(adjustmentId, additionalProperties) } - /** Alias for calling [price] with `Price.ofUnitWithPercent(unitWithPercent)`. */ - fun price(unitWithPercent: NewSubscriptionUnitWithPercentPrice) = - price(Price.ofUnitWithPercent(unitWithPercent)) + override fun hashCode(): Int = hashCode - /** - * Alias for calling [price] with - * `Price.ofPackageWithAllocation(packageWithAllocation)`. - */ - fun price(packageWithAllocation: NewSubscriptionPackageWithAllocationPrice) = - price(Price.ofPackageWithAllocation(packageWithAllocation)) + override fun toString() = + "RemoveAdjustment{adjustmentId=$adjustmentId, additionalProperties=$additionalProperties}" + } - /** - * Alias for calling [price] with `Price.ofTieredWithProration(tieredWithProration)`. - */ - fun price(tieredWithProration: NewSubscriptionTierWithProrationPrice) = - price(Price.ofTieredWithProration(tieredWithProration)) + class RemovePrice + private constructor( + private val externalPriceId: JsonField, + private val priceId: JsonField, + private val additionalProperties: MutableMap, + ) { - /** Alias for calling [price] with `Price.ofUnitWithProration(unitWithProration)`. */ - fun price(unitWithProration: NewSubscriptionUnitWithProrationPrice) = - price(Price.ofUnitWithProration(unitWithProration)) + @JsonCreator + private constructor( + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("price_id") @ExcludeMissing priceId: JsonField = JsonMissing.of(), + ) : this(externalPriceId, priceId, mutableMapOf()) - /** Alias for calling [price] with `Price.ofGroupedAllocation(groupedAllocation)`. */ - fun price(groupedAllocation: NewSubscriptionGroupedAllocationPrice) = - price(Price.ofGroupedAllocation(groupedAllocation)) + /** + * The external price id of the price to remove on the subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") - /** - * Alias for calling [price] with - * `Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)`. - */ - fun price(groupedWithProratedMinimum: NewSubscriptionGroupedWithProratedMinimumPrice) = - price(Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)) + /** + * The id of the price to remove on the subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun priceId(): String? = priceId.getNullable("price_id") - /** Alias for calling [price] with `Price.ofBulkWithProration(bulkWithProration)`. */ - fun price(bulkWithProration: NewSubscriptionBulkWithProrationPrice) = - price(Price.ofBulkWithProration(bulkWithProration)) + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId - /** - * Alias for calling [price] with - * `Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)`. - */ - fun price( - scalableMatrixWithUnitPricing: NewSubscriptionScalableMatrixWithUnitPricingPrice - ) = price(Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)) + /** + * Returns the raw JSON value of [priceId]. + * + * Unlike [priceId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId - /** - * Alias for calling [price] with - * `Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)`. - */ - fun price( - scalableMatrixWithTieredPricing: NewSubscriptionScalableMatrixWithTieredPricingPrice - ) = price(Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)) + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - /** - * Alias for calling [price] with - * `Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)`. - */ - fun price(cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice) = - price(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - /** - * Alias for calling [price] with - * `Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)`. - */ - fun price(maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice) = - price(Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)) + fun toBuilder() = Builder().from(this) - /** - * Alias for calling [price] with - * `Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)`. - */ - fun price(groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice) = - price(Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)) + companion object { - /** - * Alias for calling [price] with - * `Price.ofMatrixWithDisplayName(matrixWithDisplayName)`. - */ - fun price(matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice) = - price(Price.ofMatrixWithDisplayName(matrixWithDisplayName)) + /** Returns a mutable builder for constructing an instance of [RemovePrice]. */ + fun builder() = Builder() + } - /** - * Alias for calling [price] with `Price.ofGroupedTieredPackage(groupedTieredPackage)`. - */ - fun price(groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice) = - price(Price.ofGroupedTieredPackage(groupedTieredPackage)) + /** A builder for [RemovePrice]. */ + class Builder internal constructor() { - /** - * Alias for calling [price] with `Price.ofMatrixWithAllocation(matrixWithAllocation)`. - */ - fun price(matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice) = - price(Price.ofMatrixWithAllocation(matrixWithAllocation)) + private var externalPriceId: JsonField = JsonMissing.of() + private var priceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(removePrice: RemovePrice) = apply { + externalPriceId = removePrice.externalPriceId + priceId = removePrice.priceId + additionalProperties = removePrice.additionalProperties.toMutableMap() + } + + /** The external price id of the price to remove on the subscription. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) /** - * Alias for calling [price] with - * `Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)`. + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun price(tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice) = - price(Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)) - - /** Alias for calling [price] with `Price.ofGroupedTiered(groupedTiered)`. */ - fun price(groupedTiered: NewSubscriptionGroupedTieredPrice) = - price(Price.ofGroupedTiered(groupedTiered)) + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } - /** The id of the price to add to the subscription. */ + /** The id of the price to remove on the subscription. */ fun priceId(priceId: String?) = priceId(JsonField.ofNullable(priceId)) /** @@ -7794,47 +9604,22 @@ private constructor( } /** - * Returns an immutable instance of [ReplacePrice]. + * Returns an immutable instance of [RemovePrice]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```kotlin - * .replacesPriceId() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ - fun build(): ReplacePrice = - ReplacePrice( - checkRequired("replacesPriceId", replacesPriceId), - allocationPrice, - (discounts ?: JsonMissing.of()).map { it.toImmutable() }, - externalPriceId, - fixedPriceQuantity, - maximumAmount, - minimumAmount, - price, - priceId, - additionalProperties.toMutableMap(), - ) + fun build(): RemovePrice = + RemovePrice(externalPriceId, priceId, additionalProperties.toMutableMap()) } private var validated: Boolean = false - fun validate(): ReplacePrice = apply { + fun validate(): RemovePrice = apply { if (validated) { return@apply } - replacesPriceId() - allocationPrice()?.validate() - discounts()?.forEach { it.validate() } externalPriceId() - fixedPriceQuantity() - maximumAmount() - minimumAmount() - price()?.validate() priceId() validated = true } @@ -7854,441 +9639,1667 @@ private constructor( * Used for best match union deserialization. */ internal fun validity(): Int = - (if (replacesPriceId.asKnown() == null) 0 else 1) + - (allocationPrice.asKnown()?.validity() ?: 0) + - (discounts.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + - (if (externalPriceId.asKnown() == null) 0 else 1) + - (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + - (if (maximumAmount.asKnown() == null) 0 else 1) + - (if (minimumAmount.asKnown() == null) 0 else 1) + - (price.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + (if (priceId.asKnown() == null) 0 else 1) - /** The definition of a new price to create and add to the subscription. */ - @JsonDeserialize(using = Price.Deserializer::class) - @JsonSerialize(using = Price.Serializer::class) - class Price - private constructor( - private val unit: NewSubscriptionUnitPrice? = null, - private val package_: NewSubscriptionPackagePrice? = null, - private val matrix: NewSubscriptionMatrixPrice? = null, - private val tiered: NewSubscriptionTieredPrice? = null, - private val tieredBps: NewSubscriptionTieredBpsPrice? = null, - private val bps: NewSubscriptionBpsPrice? = null, - private val bulkBps: NewSubscriptionBulkBpsPrice? = null, - private val bulk: NewSubscriptionBulkPrice? = null, - private val thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice? = null, - private val tieredPackage: NewSubscriptionTieredPackagePrice? = null, - private val tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice? = null, - private val unitWithPercent: NewSubscriptionUnitWithPercentPrice? = null, - private val packageWithAllocation: NewSubscriptionPackageWithAllocationPrice? = null, - private val tieredWithProration: NewSubscriptionTierWithProrationPrice? = null, - private val unitWithProration: NewSubscriptionUnitWithProrationPrice? = null, - private val groupedAllocation: NewSubscriptionGroupedAllocationPrice? = null, - private val groupedWithProratedMinimum: - NewSubscriptionGroupedWithProratedMinimumPrice? = - null, - private val bulkWithProration: NewSubscriptionBulkWithProrationPrice? = null, - private val scalableMatrixWithUnitPricing: - NewSubscriptionScalableMatrixWithUnitPricingPrice? = - null, - private val scalableMatrixWithTieredPricing: - NewSubscriptionScalableMatrixWithTieredPricingPrice? = - null, - private val cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice? = null, - private val maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice? = null, - private val groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice? = - null, - private val matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice? = null, - private val groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice? = null, - private val matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice? = null, - private val tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice? = - null, - private val groupedTiered: NewSubscriptionGroupedTieredPrice? = null, - private val _json: JsonValue? = null, - ) { - - fun unit(): NewSubscriptionUnitPrice? = unit + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun package_(): NewSubscriptionPackagePrice? = package_ + return other is RemovePrice && + externalPriceId == other.externalPriceId && + priceId == other.priceId && + additionalProperties == other.additionalProperties + } - fun matrix(): NewSubscriptionMatrixPrice? = matrix + private val hashCode: Int by lazy { + Objects.hash(externalPriceId, priceId, additionalProperties) + } - fun tiered(): NewSubscriptionTieredPrice? = tiered + override fun hashCode(): Int = hashCode - fun tieredBps(): NewSubscriptionTieredBpsPrice? = tieredBps + override fun toString() = + "RemovePrice{externalPriceId=$externalPriceId, priceId=$priceId, additionalProperties=$additionalProperties}" + } - fun bps(): NewSubscriptionBpsPrice? = bps + class ReplaceAdjustment + private constructor( + private val adjustment: JsonField, + private val replacesAdjustmentId: JsonField, + private val additionalProperties: MutableMap, + ) { - fun bulkBps(): NewSubscriptionBulkBpsPrice? = bulkBps + @JsonCreator + private constructor( + @JsonProperty("adjustment") + @ExcludeMissing + adjustment: JsonField = JsonMissing.of(), + @JsonProperty("replaces_adjustment_id") + @ExcludeMissing + replacesAdjustmentId: JsonField = JsonMissing.of(), + ) : this(adjustment, replacesAdjustmentId, mutableMapOf()) - fun bulk(): NewSubscriptionBulkPrice? = bulk + /** + * The definition of a new adjustment to create and add to the subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun adjustment(): Adjustment = adjustment.getRequired("adjustment") - fun thresholdTotalAmount(): NewSubscriptionThresholdTotalAmountPrice? = - thresholdTotalAmount + /** + * The id of the adjustment on the plan to replace in the subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun replacesAdjustmentId(): String = + replacesAdjustmentId.getRequired("replaces_adjustment_id") - fun tieredPackage(): NewSubscriptionTieredPackagePrice? = tieredPackage + /** + * Returns the raw JSON value of [adjustment]. + * + * Unlike [adjustment], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("adjustment") + @ExcludeMissing + fun _adjustment(): JsonField = adjustment - fun tieredWithMinimum(): NewSubscriptionTieredWithMinimumPrice? = tieredWithMinimum + /** + * Returns the raw JSON value of [replacesAdjustmentId]. + * + * Unlike [replacesAdjustmentId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("replaces_adjustment_id") + @ExcludeMissing + fun _replacesAdjustmentId(): JsonField = replacesAdjustmentId - fun unitWithPercent(): NewSubscriptionUnitWithPercentPrice? = unitWithPercent + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - fun packageWithAllocation(): NewSubscriptionPackageWithAllocationPrice? = - packageWithAllocation + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - fun tieredWithProration(): NewSubscriptionTierWithProrationPrice? = tieredWithProration + fun toBuilder() = Builder().from(this) - fun unitWithProration(): NewSubscriptionUnitWithProrationPrice? = unitWithProration + companion object { - fun groupedAllocation(): NewSubscriptionGroupedAllocationPrice? = groupedAllocation + /** + * Returns a mutable builder for constructing an instance of [ReplaceAdjustment]. + * + * The following fields are required: + * ```kotlin + * .adjustment() + * .replacesAdjustmentId() + * ``` + */ + fun builder() = Builder() + } - fun groupedWithProratedMinimum(): NewSubscriptionGroupedWithProratedMinimumPrice? = - groupedWithProratedMinimum + /** A builder for [ReplaceAdjustment]. */ + class Builder internal constructor() { - fun bulkWithProration(): NewSubscriptionBulkWithProrationPrice? = bulkWithProration + private var adjustment: JsonField? = null + private var replacesAdjustmentId: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() - fun scalableMatrixWithUnitPricing(): - NewSubscriptionScalableMatrixWithUnitPricingPrice? = scalableMatrixWithUnitPricing + internal fun from(replaceAdjustment: ReplaceAdjustment) = apply { + adjustment = replaceAdjustment.adjustment + replacesAdjustmentId = replaceAdjustment.replacesAdjustmentId + additionalProperties = replaceAdjustment.additionalProperties.toMutableMap() + } - fun scalableMatrixWithTieredPricing(): - NewSubscriptionScalableMatrixWithTieredPricingPrice? = - scalableMatrixWithTieredPricing + /** The definition of a new adjustment to create and add to the subscription. */ + fun adjustment(adjustment: Adjustment) = adjustment(JsonField.of(adjustment)) - fun cumulativeGroupedBulk(): NewSubscriptionCumulativeGroupedBulkPrice? = - cumulativeGroupedBulk + /** + * Sets [Builder.adjustment] to an arbitrary JSON value. + * + * You should usually call [Builder.adjustment] with a well-typed [Adjustment] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun adjustment(adjustment: JsonField) = apply { + this.adjustment = adjustment + } - fun maxGroupTieredPackage(): NewSubscriptionMaxGroupTieredPackagePrice? = - maxGroupTieredPackage + /** + * Alias for calling [adjustment] with + * `Adjustment.ofPercentageDiscount(percentageDiscount)`. + */ + fun adjustment(percentageDiscount: NewPercentageDiscount) = + adjustment(Adjustment.ofPercentageDiscount(percentageDiscount)) - fun groupedWithMeteredMinimum(): NewSubscriptionGroupedWithMeteredMinimumPrice? = - groupedWithMeteredMinimum + /** + * Alias for calling [adjustment] with the following: + * ```kotlin + * NewPercentageDiscount.builder() + * .adjustmentType(NewPercentageDiscount.AdjustmentType.PERCENTAGE_DISCOUNT) + * .percentageDiscount(percentageDiscount) + * .build() + * ``` + */ + fun percentageDiscountAdjustment(percentageDiscount: Double) = + adjustment( + NewPercentageDiscount.builder() + .adjustmentType(NewPercentageDiscount.AdjustmentType.PERCENTAGE_DISCOUNT) + .percentageDiscount(percentageDiscount) + .build() + ) - fun matrixWithDisplayName(): NewSubscriptionMatrixWithDisplayNamePrice? = - matrixWithDisplayName + /** Alias for calling [adjustment] with `Adjustment.ofUsageDiscount(usageDiscount)`. */ + fun adjustment(usageDiscount: NewUsageDiscount) = + adjustment(Adjustment.ofUsageDiscount(usageDiscount)) - fun groupedTieredPackage(): NewSubscriptionGroupedTieredPackagePrice? = - groupedTieredPackage + /** + * Alias for calling [adjustment] with the following: + * ```kotlin + * NewUsageDiscount.builder() + * .adjustmentType(NewUsageDiscount.AdjustmentType.USAGE_DISCOUNT) + * .usageDiscount(usageDiscount) + * .build() + * ``` + */ + fun usageDiscountAdjustment(usageDiscount: Double) = + adjustment( + NewUsageDiscount.builder() + .adjustmentType(NewUsageDiscount.AdjustmentType.USAGE_DISCOUNT) + .usageDiscount(usageDiscount) + .build() + ) - fun matrixWithAllocation(): NewSubscriptionMatrixWithAllocationPrice? = - matrixWithAllocation + /** + * Alias for calling [adjustment] with `Adjustment.ofAmountDiscount(amountDiscount)`. + */ + fun adjustment(amountDiscount: NewAmountDiscount) = + adjustment(Adjustment.ofAmountDiscount(amountDiscount)) - fun tieredPackageWithMinimum(): NewSubscriptionTieredPackageWithMinimumPrice? = - tieredPackageWithMinimum + /** + * Alias for calling [adjustment] with the following: + * ```kotlin + * NewAmountDiscount.builder() + * .adjustmentType(NewAmountDiscount.AdjustmentType.AMOUNT_DISCOUNT) + * .amountDiscount(amountDiscount) + * .build() + * ``` + */ + fun amountDiscountAdjustment(amountDiscount: String) = + adjustment( + NewAmountDiscount.builder() + .adjustmentType(NewAmountDiscount.AdjustmentType.AMOUNT_DISCOUNT) + .amountDiscount(amountDiscount) + .build() + ) - fun groupedTiered(): NewSubscriptionGroupedTieredPrice? = groupedTiered + /** Alias for calling [adjustment] with `Adjustment.ofMinimum(minimum)`. */ + fun adjustment(minimum: NewMinimum) = adjustment(Adjustment.ofMinimum(minimum)) - fun isUnit(): Boolean = unit != null + /** Alias for calling [adjustment] with `Adjustment.ofMaximum(maximum)`. */ + fun adjustment(maximum: NewMaximum) = adjustment(Adjustment.ofMaximum(maximum)) - fun isPackage(): Boolean = package_ != null + /** + * Alias for calling [adjustment] with the following: + * ```kotlin + * NewMaximum.builder() + * .adjustmentType(NewMaximum.AdjustmentType.MAXIMUM) + * .maximumAmount(maximumAmount) + * .build() + * ``` + */ + fun maximumAdjustment(maximumAmount: String) = + adjustment( + NewMaximum.builder() + .adjustmentType(NewMaximum.AdjustmentType.MAXIMUM) + .maximumAmount(maximumAmount) + .build() + ) - fun isMatrix(): Boolean = matrix != null + /** The id of the adjustment on the plan to replace in the subscription. */ + fun replacesAdjustmentId(replacesAdjustmentId: String) = + replacesAdjustmentId(JsonField.of(replacesAdjustmentId)) - fun isTiered(): Boolean = tiered != null + /** + * Sets [Builder.replacesAdjustmentId] to an arbitrary JSON value. + * + * You should usually call [Builder.replacesAdjustmentId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun replacesAdjustmentId(replacesAdjustmentId: JsonField) = apply { + this.replacesAdjustmentId = replacesAdjustmentId + } - fun isTieredBps(): Boolean = tieredBps != null + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun isBps(): Boolean = bps != null + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun isBulkBps(): Boolean = bulkBps != null + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun isBulk(): Boolean = bulk != null + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - fun isThresholdTotalAmount(): Boolean = thresholdTotalAmount != null + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - fun isTieredPackage(): Boolean = tieredPackage != null + /** + * Returns an immutable instance of [ReplaceAdjustment]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .adjustment() + * .replacesAdjustmentId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ReplaceAdjustment = + ReplaceAdjustment( + checkRequired("adjustment", adjustment), + checkRequired("replacesAdjustmentId", replacesAdjustmentId), + additionalProperties.toMutableMap(), + ) + } - fun isTieredWithMinimum(): Boolean = tieredWithMinimum != null + private var validated: Boolean = false - fun isUnitWithPercent(): Boolean = unitWithPercent != null + fun validate(): ReplaceAdjustment = apply { + if (validated) { + return@apply + } - fun isPackageWithAllocation(): Boolean = packageWithAllocation != null + adjustment().validate() + replacesAdjustmentId() + validated = true + } - fun isTieredWithProration(): Boolean = tieredWithProration != null + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - fun isUnitWithProration(): Boolean = unitWithProration != null + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (adjustment.asKnown()?.validity() ?: 0) + + (if (replacesAdjustmentId.asKnown() == null) 0 else 1) - fun isGroupedAllocation(): Boolean = groupedAllocation != null + /** The definition of a new adjustment to create and add to the subscription. */ + @JsonDeserialize(using = Adjustment.Deserializer::class) + @JsonSerialize(using = Adjustment.Serializer::class) + class Adjustment + private constructor( + private val percentageDiscount: NewPercentageDiscount? = null, + private val usageDiscount: NewUsageDiscount? = null, + private val amountDiscount: NewAmountDiscount? = null, + private val minimum: NewMinimum? = null, + private val maximum: NewMaximum? = null, + private val _json: JsonValue? = null, + ) { - fun isGroupedWithProratedMinimum(): Boolean = groupedWithProratedMinimum != null + fun percentageDiscount(): NewPercentageDiscount? = percentageDiscount - fun isBulkWithProration(): Boolean = bulkWithProration != null + fun usageDiscount(): NewUsageDiscount? = usageDiscount - fun isScalableMatrixWithUnitPricing(): Boolean = scalableMatrixWithUnitPricing != null + fun amountDiscount(): NewAmountDiscount? = amountDiscount - fun isScalableMatrixWithTieredPricing(): Boolean = - scalableMatrixWithTieredPricing != null + fun minimum(): NewMinimum? = minimum - fun isCumulativeGroupedBulk(): Boolean = cumulativeGroupedBulk != null + fun maximum(): NewMaximum? = maximum - fun isMaxGroupTieredPackage(): Boolean = maxGroupTieredPackage != null + fun isPercentageDiscount(): Boolean = percentageDiscount != null - fun isGroupedWithMeteredMinimum(): Boolean = groupedWithMeteredMinimum != null + fun isUsageDiscount(): Boolean = usageDiscount != null - fun isMatrixWithDisplayName(): Boolean = matrixWithDisplayName != null + fun isAmountDiscount(): Boolean = amountDiscount != null - fun isGroupedTieredPackage(): Boolean = groupedTieredPackage != null + fun isMinimum(): Boolean = minimum != null - fun isMatrixWithAllocation(): Boolean = matrixWithAllocation != null + fun isMaximum(): Boolean = maximum != null - fun isTieredPackageWithMinimum(): Boolean = tieredPackageWithMinimum != null + fun asPercentageDiscount(): NewPercentageDiscount = + percentageDiscount.getOrThrow("percentageDiscount") - fun isGroupedTiered(): Boolean = groupedTiered != null + fun asUsageDiscount(): NewUsageDiscount = usageDiscount.getOrThrow("usageDiscount") - fun asUnit(): NewSubscriptionUnitPrice = unit.getOrThrow("unit") + fun asAmountDiscount(): NewAmountDiscount = amountDiscount.getOrThrow("amountDiscount") - fun asPackage(): NewSubscriptionPackagePrice = package_.getOrThrow("package_") + fun asMinimum(): NewMinimum = minimum.getOrThrow("minimum") - fun asMatrix(): NewSubscriptionMatrixPrice = matrix.getOrThrow("matrix") + fun asMaximum(): NewMaximum = maximum.getOrThrow("maximum") - fun asTiered(): NewSubscriptionTieredPrice = tiered.getOrThrow("tiered") + fun _json(): JsonValue? = _json - fun asTieredBps(): NewSubscriptionTieredBpsPrice = tieredBps.getOrThrow("tieredBps") + fun accept(visitor: Visitor): T = + when { + percentageDiscount != null -> + visitor.visitPercentageDiscount(percentageDiscount) + usageDiscount != null -> visitor.visitUsageDiscount(usageDiscount) + amountDiscount != null -> visitor.visitAmountDiscount(amountDiscount) + minimum != null -> visitor.visitMinimum(minimum) + maximum != null -> visitor.visitMaximum(maximum) + else -> visitor.unknown(_json) + } - fun asBps(): NewSubscriptionBpsPrice = bps.getOrThrow("bps") + private var validated: Boolean = false - fun asBulkBps(): NewSubscriptionBulkBpsPrice = bulkBps.getOrThrow("bulkBps") + fun validate(): Adjustment = apply { + if (validated) { + return@apply + } - fun asBulk(): NewSubscriptionBulkPrice = bulk.getOrThrow("bulk") + accept( + object : Visitor { + override fun visitPercentageDiscount( + percentageDiscount: NewPercentageDiscount + ) { + percentageDiscount.validate() + } - fun asThresholdTotalAmount(): NewSubscriptionThresholdTotalAmountPrice = - thresholdTotalAmount.getOrThrow("thresholdTotalAmount") + override fun visitUsageDiscount(usageDiscount: NewUsageDiscount) { + usageDiscount.validate() + } - fun asTieredPackage(): NewSubscriptionTieredPackagePrice = - tieredPackage.getOrThrow("tieredPackage") + override fun visitAmountDiscount(amountDiscount: NewAmountDiscount) { + amountDiscount.validate() + } - fun asTieredWithMinimum(): NewSubscriptionTieredWithMinimumPrice = - tieredWithMinimum.getOrThrow("tieredWithMinimum") + override fun visitMinimum(minimum: NewMinimum) { + minimum.validate() + } - fun asUnitWithPercent(): NewSubscriptionUnitWithPercentPrice = - unitWithPercent.getOrThrow("unitWithPercent") + override fun visitMaximum(maximum: NewMaximum) { + maximum.validate() + } + } + ) + validated = true + } - fun asPackageWithAllocation(): NewSubscriptionPackageWithAllocationPrice = - packageWithAllocation.getOrThrow("packageWithAllocation") + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - fun asTieredWithProration(): NewSubscriptionTierWithProrationPrice = - tieredWithProration.getOrThrow("tieredWithProration") + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitPercentageDiscount( + percentageDiscount: NewPercentageDiscount + ) = percentageDiscount.validity() - fun asUnitWithProration(): NewSubscriptionUnitWithProrationPrice = - unitWithProration.getOrThrow("unitWithProration") + override fun visitUsageDiscount(usageDiscount: NewUsageDiscount) = + usageDiscount.validity() - fun asGroupedAllocation(): NewSubscriptionGroupedAllocationPrice = - groupedAllocation.getOrThrow("groupedAllocation") + override fun visitAmountDiscount(amountDiscount: NewAmountDiscount) = + amountDiscount.validity() - fun asGroupedWithProratedMinimum(): NewSubscriptionGroupedWithProratedMinimumPrice = - groupedWithProratedMinimum.getOrThrow("groupedWithProratedMinimum") + override fun visitMinimum(minimum: NewMinimum) = minimum.validity() - fun asBulkWithProration(): NewSubscriptionBulkWithProrationPrice = - bulkWithProration.getOrThrow("bulkWithProration") + override fun visitMaximum(maximum: NewMaximum) = maximum.validity() - fun asScalableMatrixWithUnitPricing(): - NewSubscriptionScalableMatrixWithUnitPricingPrice = - scalableMatrixWithUnitPricing.getOrThrow("scalableMatrixWithUnitPricing") + override fun unknown(json: JsonValue?) = 0 + } + ) - fun asScalableMatrixWithTieredPricing(): - NewSubscriptionScalableMatrixWithTieredPricingPrice = - scalableMatrixWithTieredPricing.getOrThrow("scalableMatrixWithTieredPricing") + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun asCumulativeGroupedBulk(): NewSubscriptionCumulativeGroupedBulkPrice = - cumulativeGroupedBulk.getOrThrow("cumulativeGroupedBulk") + return other is Adjustment && + percentageDiscount == other.percentageDiscount && + usageDiscount == other.usageDiscount && + amountDiscount == other.amountDiscount && + minimum == other.minimum && + maximum == other.maximum + } - fun asMaxGroupTieredPackage(): NewSubscriptionMaxGroupTieredPackagePrice = - maxGroupTieredPackage.getOrThrow("maxGroupTieredPackage") + override fun hashCode(): Int = + Objects.hash(percentageDiscount, usageDiscount, amountDiscount, minimum, maximum) - fun asGroupedWithMeteredMinimum(): NewSubscriptionGroupedWithMeteredMinimumPrice = - groupedWithMeteredMinimum.getOrThrow("groupedWithMeteredMinimum") + override fun toString(): String = + when { + percentageDiscount != null -> + "Adjustment{percentageDiscount=$percentageDiscount}" + usageDiscount != null -> "Adjustment{usageDiscount=$usageDiscount}" + amountDiscount != null -> "Adjustment{amountDiscount=$amountDiscount}" + minimum != null -> "Adjustment{minimum=$minimum}" + maximum != null -> "Adjustment{maximum=$maximum}" + _json != null -> "Adjustment{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Adjustment") + } - fun asMatrixWithDisplayName(): NewSubscriptionMatrixWithDisplayNamePrice = - matrixWithDisplayName.getOrThrow("matrixWithDisplayName") + companion object { - fun asGroupedTieredPackage(): NewSubscriptionGroupedTieredPackagePrice = - groupedTieredPackage.getOrThrow("groupedTieredPackage") + fun ofPercentageDiscount(percentageDiscount: NewPercentageDiscount) = + Adjustment(percentageDiscount = percentageDiscount) - fun asMatrixWithAllocation(): NewSubscriptionMatrixWithAllocationPrice = - matrixWithAllocation.getOrThrow("matrixWithAllocation") - - fun asTieredPackageWithMinimum(): NewSubscriptionTieredPackageWithMinimumPrice = - tieredPackageWithMinimum.getOrThrow("tieredPackageWithMinimum") - - fun asGroupedTiered(): NewSubscriptionGroupedTieredPrice = - groupedTiered.getOrThrow("groupedTiered") + fun ofUsageDiscount(usageDiscount: NewUsageDiscount) = + Adjustment(usageDiscount = usageDiscount) - fun _json(): JsonValue? = _json + fun ofAmountDiscount(amountDiscount: NewAmountDiscount) = + Adjustment(amountDiscount = amountDiscount) - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - package_ != null -> visitor.visitPackage(package_) - matrix != null -> visitor.visitMatrix(matrix) - tiered != null -> visitor.visitTiered(tiered) - tieredBps != null -> visitor.visitTieredBps(tieredBps) - bps != null -> visitor.visitBps(bps) - bulkBps != null -> visitor.visitBulkBps(bulkBps) - bulk != null -> visitor.visitBulk(bulk) - thresholdTotalAmount != null -> - visitor.visitThresholdTotalAmount(thresholdTotalAmount) - tieredPackage != null -> visitor.visitTieredPackage(tieredPackage) - tieredWithMinimum != null -> visitor.visitTieredWithMinimum(tieredWithMinimum) - unitWithPercent != null -> visitor.visitUnitWithPercent(unitWithPercent) - packageWithAllocation != null -> - visitor.visitPackageWithAllocation(packageWithAllocation) - tieredWithProration != null -> - visitor.visitTieredWithProration(tieredWithProration) - unitWithProration != null -> visitor.visitUnitWithProration(unitWithProration) - groupedAllocation != null -> visitor.visitGroupedAllocation(groupedAllocation) - groupedWithProratedMinimum != null -> - visitor.visitGroupedWithProratedMinimum(groupedWithProratedMinimum) - bulkWithProration != null -> visitor.visitBulkWithProration(bulkWithProration) - scalableMatrixWithUnitPricing != null -> - visitor.visitScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing) - scalableMatrixWithTieredPricing != null -> - visitor.visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing - ) - cumulativeGroupedBulk != null -> - visitor.visitCumulativeGroupedBulk(cumulativeGroupedBulk) - maxGroupTieredPackage != null -> - visitor.visitMaxGroupTieredPackage(maxGroupTieredPackage) - groupedWithMeteredMinimum != null -> - visitor.visitGroupedWithMeteredMinimum(groupedWithMeteredMinimum) - matrixWithDisplayName != null -> - visitor.visitMatrixWithDisplayName(matrixWithDisplayName) - groupedTieredPackage != null -> - visitor.visitGroupedTieredPackage(groupedTieredPackage) - matrixWithAllocation != null -> - visitor.visitMatrixWithAllocation(matrixWithAllocation) - tieredPackageWithMinimum != null -> - visitor.visitTieredPackageWithMinimum(tieredPackageWithMinimum) - groupedTiered != null -> visitor.visitGroupedTiered(groupedTiered) - else -> visitor.unknown(_json) - } + fun ofMinimum(minimum: NewMinimum) = Adjustment(minimum = minimum) - private var validated: Boolean = false + fun ofMaximum(maximum: NewMaximum) = Adjustment(maximum = maximum) + } - fun validate(): Price = apply { - if (validated) { - return@apply - } + /** + * An interface that defines how to map each variant of [Adjustment] to a value of type + * [T]. + */ + interface Visitor { - accept( - object : Visitor { - override fun visitUnit(unit: NewSubscriptionUnitPrice) { - unit.validate() - } + fun visitPercentageDiscount(percentageDiscount: NewPercentageDiscount): T - override fun visitPackage(package_: NewSubscriptionPackagePrice) { - package_.validate() - } + fun visitUsageDiscount(usageDiscount: NewUsageDiscount): T - override fun visitMatrix(matrix: NewSubscriptionMatrixPrice) { - matrix.validate() - } + fun visitAmountDiscount(amountDiscount: NewAmountDiscount): T - override fun visitTiered(tiered: NewSubscriptionTieredPrice) { - tiered.validate() - } + fun visitMinimum(minimum: NewMinimum): T - override fun visitTieredBps(tieredBps: NewSubscriptionTieredBpsPrice) { - tieredBps.validate() - } + fun visitMaximum(maximum: NewMaximum): T - override fun visitBps(bps: NewSubscriptionBpsPrice) { - bps.validate() - } + /** + * Maps an unknown variant of [Adjustment] to a value of type [T]. + * + * An instance of [Adjustment] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the + * SDK is unaware of. + * + * @throws OrbInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw OrbInvalidDataException("Unknown Adjustment: $json") + } + } - override fun visitBulkBps(bulkBps: NewSubscriptionBulkBpsPrice) { - bulkBps.validate() - } + internal class Deserializer : BaseDeserializer(Adjustment::class) { - override fun visitBulk(bulk: NewSubscriptionBulkPrice) { - bulk.validate() - } + override fun ObjectCodec.deserialize(node: JsonNode): Adjustment { + val json = JsonValue.fromJsonNode(node) + val adjustmentType = json.asObject()?.get("adjustment_type")?.asString() - override fun visitThresholdTotalAmount( - thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice - ) { - thresholdTotalAmount.validate() + when (adjustmentType) { + "percentage_discount" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Adjustment(percentageDiscount = it, _json = json) } + ?: Adjustment(_json = json) } - - override fun visitTieredPackage( - tieredPackage: NewSubscriptionTieredPackagePrice - ) { - tieredPackage.validate() + "usage_discount" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(usageDiscount = it, _json = json) + } ?: Adjustment(_json = json) } - - override fun visitTieredWithMinimum( - tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice - ) { - tieredWithMinimum.validate() + "amount_discount" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(amountDiscount = it, _json = json) + } ?: Adjustment(_json = json) } - - override fun visitUnitWithPercent( - unitWithPercent: NewSubscriptionUnitWithPercentPrice - ) { - unitWithPercent.validate() + "minimum" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(minimum = it, _json = json) + } ?: Adjustment(_json = json) } - - override fun visitPackageWithAllocation( - packageWithAllocation: NewSubscriptionPackageWithAllocationPrice - ) { - packageWithAllocation.validate() + "maximum" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(maximum = it, _json = json) + } ?: Adjustment(_json = json) } + } - override fun visitTieredWithProration( - tieredWithProration: NewSubscriptionTierWithProrationPrice - ) { - tieredWithProration.validate() - } + return Adjustment(_json = json) + } + } - override fun visitUnitWithProration( - unitWithProration: NewSubscriptionUnitWithProrationPrice - ) { - unitWithProration.validate() - } + internal class Serializer : BaseSerializer(Adjustment::class) { - override fun visitGroupedAllocation( - groupedAllocation: NewSubscriptionGroupedAllocationPrice - ) { - groupedAllocation.validate() - } + override fun serialize( + value: Adjustment, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.percentageDiscount != null -> + generator.writeObject(value.percentageDiscount) + value.usageDiscount != null -> generator.writeObject(value.usageDiscount) + value.amountDiscount != null -> generator.writeObject(value.amountDiscount) + value.minimum != null -> generator.writeObject(value.minimum) + value.maximum != null -> generator.writeObject(value.maximum) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Adjustment") + } + } + } + } - override fun visitGroupedWithProratedMinimum( - groupedWithProratedMinimum: - NewSubscriptionGroupedWithProratedMinimumPrice - ) { - groupedWithProratedMinimum.validate() - } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - override fun visitBulkWithProration( - bulkWithProration: NewSubscriptionBulkWithProrationPrice - ) { - bulkWithProration.validate() - } + return other is ReplaceAdjustment && + adjustment == other.adjustment && + replacesAdjustmentId == other.replacesAdjustmentId && + additionalProperties == other.additionalProperties + } - override fun visitScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: - NewSubscriptionScalableMatrixWithUnitPricingPrice - ) { - scalableMatrixWithUnitPricing.validate() - } + private val hashCode: Int by lazy { + Objects.hash(adjustment, replacesAdjustmentId, additionalProperties) + } - override fun visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: - NewSubscriptionScalableMatrixWithTieredPricingPrice - ) { - scalableMatrixWithTieredPricing.validate() - } + override fun hashCode(): Int = hashCode - override fun visitCumulativeGroupedBulk( - cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice - ) { - cumulativeGroupedBulk.validate() - } + override fun toString() = + "ReplaceAdjustment{adjustment=$adjustment, replacesAdjustmentId=$replacesAdjustmentId, additionalProperties=$additionalProperties}" + } - override fun visitMaxGroupTieredPackage( - maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice - ) { - maxGroupTieredPackage.validate() - } + class ReplacePrice + private constructor( + private val replacesPriceId: JsonField, + private val allocationPrice: JsonField, + private val discounts: JsonField>, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val maximumAmount: JsonField, + private val minimumAmount: JsonField, + private val price: JsonField, + private val priceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("replaces_price_id") + @ExcludeMissing + replacesPriceId: JsonField = JsonMissing.of(), + @JsonProperty("allocation_price") + @ExcludeMissing + allocationPrice: JsonField = JsonMissing.of(), + @JsonProperty("discounts") + @ExcludeMissing + discounts: JsonField> = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("maximum_amount") + @ExcludeMissing + maximumAmount: JsonField = JsonMissing.of(), + @JsonProperty("minimum_amount") + @ExcludeMissing + minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("price") @ExcludeMissing price: JsonField = JsonMissing.of(), + @JsonProperty("price_id") @ExcludeMissing priceId: JsonField = JsonMissing.of(), + ) : this( + replacesPriceId, + allocationPrice, + discounts, + externalPriceId, + fixedPriceQuantity, + maximumAmount, + minimumAmount, + price, + priceId, + mutableMapOf(), + ) + + /** + * The id of the price on the plan to replace in the subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun replacesPriceId(): String = replacesPriceId.getRequired("replaces_price_id") + + /** + * The definition of a new allocation price to create and add to the subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun allocationPrice(): NewAllocationPrice? = allocationPrice.getNullable("allocation_price") + + /** + * [DEPRECATED] Use add_adjustments instead. The subscription's discounts for the + * replacement price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + @Deprecated("deprecated") + fun discounts(): List? = discounts.getNullable("discounts") + + /** + * The external price id of the price to add to the subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * The new quantity of the price, if the price is a fixed price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * [DEPRECATED] Use add_adjustments instead. The subscription's maximum amount for the + * replacement price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + @Deprecated("deprecated") + fun maximumAmount(): String? = maximumAmount.getNullable("maximum_amount") + + /** + * [DEPRECATED] Use add_adjustments instead. The subscription's minimum amount for the + * replacement price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + @Deprecated("deprecated") + fun minimumAmount(): String? = minimumAmount.getNullable("minimum_amount") + + /** + * The definition of a new price to create and add to the subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun price(): Price? = price.getNullable("price") + + /** + * The id of the price to add to the subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun priceId(): String? = priceId.getNullable("price_id") + + /** + * Returns the raw JSON value of [replacesPriceId]. + * + * Unlike [replacesPriceId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("replaces_price_id") + @ExcludeMissing + fun _replacesPriceId(): JsonField = replacesPriceId + + /** + * Returns the raw JSON value of [allocationPrice]. + * + * Unlike [allocationPrice], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("allocation_price") + @ExcludeMissing + fun _allocationPrice(): JsonField = allocationPrice + + /** + * Returns the raw JSON value of [discounts]. + * + * Unlike [discounts], this method doesn't throw if the JSON field has an unexpected type. + */ + @Deprecated("deprecated") + @JsonProperty("discounts") + @ExcludeMissing + fun _discounts(): JsonField> = discounts + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [maximumAmount]. + * + * Unlike [maximumAmount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @Deprecated("deprecated") + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount + + /** + * Returns the raw JSON value of [minimumAmount]. + * + * Unlike [minimumAmount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @Deprecated("deprecated") + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount + + /** + * Returns the raw JSON value of [price]. + * + * Unlike [price], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("price") @ExcludeMissing fun _price(): JsonField = price + + /** + * Returns the raw JSON value of [priceId]. + * + * Unlike [priceId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ReplacePrice]. + * + * The following fields are required: + * ```kotlin + * .replacesPriceId() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [ReplacePrice]. */ + class Builder internal constructor() { + + private var replacesPriceId: JsonField? = null + private var allocationPrice: JsonField = JsonMissing.of() + private var discounts: JsonField>? = null + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var maximumAmount: JsonField = JsonMissing.of() + private var minimumAmount: JsonField = JsonMissing.of() + private var price: JsonField = JsonMissing.of() + private var priceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(replacePrice: ReplacePrice) = apply { + replacesPriceId = replacePrice.replacesPriceId + allocationPrice = replacePrice.allocationPrice + discounts = replacePrice.discounts.map { it.toMutableList() } + externalPriceId = replacePrice.externalPriceId + fixedPriceQuantity = replacePrice.fixedPriceQuantity + maximumAmount = replacePrice.maximumAmount + minimumAmount = replacePrice.minimumAmount + price = replacePrice.price + priceId = replacePrice.priceId + additionalProperties = replacePrice.additionalProperties.toMutableMap() + } + + /** The id of the price on the plan to replace in the subscription. */ + fun replacesPriceId(replacesPriceId: String) = + replacesPriceId(JsonField.of(replacesPriceId)) + + /** + * Sets [Builder.replacesPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.replacesPriceId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun replacesPriceId(replacesPriceId: JsonField) = apply { + this.replacesPriceId = replacesPriceId + } + + /** The definition of a new allocation price to create and add to the subscription. */ + fun allocationPrice(allocationPrice: NewAllocationPrice?) = + allocationPrice(JsonField.ofNullable(allocationPrice)) + + /** + * Sets [Builder.allocationPrice] to an arbitrary JSON value. + * + * You should usually call [Builder.allocationPrice] with a well-typed + * [NewAllocationPrice] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun allocationPrice(allocationPrice: JsonField) = apply { + this.allocationPrice = allocationPrice + } + + /** + * [DEPRECATED] Use add_adjustments instead. The subscription's discounts for the + * replacement price. + */ + @Deprecated("deprecated") + fun discounts(discounts: List?) = + discounts(JsonField.ofNullable(discounts)) + + /** + * Sets [Builder.discounts] to an arbitrary JSON value. + * + * You should usually call [Builder.discounts] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + @Deprecated("deprecated") + fun discounts(discounts: JsonField>) = apply { + this.discounts = discounts.map { it.toMutableList() } + } + + /** + * Adds a single [DiscountOverride] to [discounts]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + @Deprecated("deprecated") + fun addDiscount(discount: DiscountOverride) = apply { + discounts = + (discounts ?: JsonField.of(mutableListOf())).also { + checkKnown("discounts", it).add(discount) + } + } + + /** The external price id of the price to add to the subscription. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** The new quantity of the price, if the price is a fixed price. */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** + * [DEPRECATED] Use add_adjustments instead. The subscription's maximum amount for the + * replacement price. + */ + @Deprecated("deprecated") + fun maximumAmount(maximumAmount: String?) = + maximumAmount(JsonField.ofNullable(maximumAmount)) + + /** + * Sets [Builder.maximumAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.maximumAmount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + @Deprecated("deprecated") + fun maximumAmount(maximumAmount: JsonField) = apply { + this.maximumAmount = maximumAmount + } + + /** + * [DEPRECATED] Use add_adjustments instead. The subscription's minimum amount for the + * replacement price. + */ + @Deprecated("deprecated") + fun minimumAmount(minimumAmount: String?) = + minimumAmount(JsonField.ofNullable(minimumAmount)) + + /** + * Sets [Builder.minimumAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumAmount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + @Deprecated("deprecated") + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount + } + + /** The definition of a new price to create and add to the subscription. */ + fun price(price: Price?) = price(JsonField.ofNullable(price)) + + /** + * Sets [Builder.price] to an arbitrary JSON value. + * + * You should usually call [Builder.price] with a well-typed [Price] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun price(price: JsonField) = apply { this.price = price } + + /** Alias for calling [price] with `Price.ofUnit(unit)`. */ + fun price(unit: NewSubscriptionUnitPrice) = price(Price.ofUnit(unit)) + + /** Alias for calling [price] with `Price.ofPackage(package_)`. */ + fun price(package_: NewSubscriptionPackagePrice) = price(Price.ofPackage(package_)) + + /** Alias for calling [price] with `Price.ofMatrix(matrix)`. */ + fun price(matrix: NewSubscriptionMatrixPrice) = price(Price.ofMatrix(matrix)) + + /** Alias for calling [price] with `Price.ofTiered(tiered)`. */ + fun price(tiered: NewSubscriptionTieredPrice) = price(Price.ofTiered(tiered)) + + /** Alias for calling [price] with `Price.ofBulk(bulk)`. */ + fun price(bulk: NewSubscriptionBulkPrice) = price(Price.ofBulk(bulk)) + + /** + * Alias for calling [price] with `Price.ofThresholdTotalAmount(thresholdTotalAmount)`. + */ + fun price(thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice) = + price(Price.ofThresholdTotalAmount(thresholdTotalAmount)) + + /** Alias for calling [price] with `Price.ofTieredPackage(tieredPackage)`. */ + fun price(tieredPackage: NewSubscriptionTieredPackagePrice) = + price(Price.ofTieredPackage(tieredPackage)) + + /** Alias for calling [price] with `Price.ofTieredWithMinimum(tieredWithMinimum)`. */ + fun price(tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice) = + price(Price.ofTieredWithMinimum(tieredWithMinimum)) + + /** Alias for calling [price] with `Price.ofUnitWithPercent(unitWithPercent)`. */ + fun price(unitWithPercent: NewSubscriptionUnitWithPercentPrice) = + price(Price.ofUnitWithPercent(unitWithPercent)) + + /** + * Alias for calling [price] with + * `Price.ofPackageWithAllocation(packageWithAllocation)`. + */ + fun price(packageWithAllocation: NewSubscriptionPackageWithAllocationPrice) = + price(Price.ofPackageWithAllocation(packageWithAllocation)) + + /** + * Alias for calling [price] with `Price.ofTieredWithProration(tieredWithProration)`. + */ + fun price(tieredWithProration: NewSubscriptionTierWithProrationPrice) = + price(Price.ofTieredWithProration(tieredWithProration)) + + /** Alias for calling [price] with `Price.ofUnitWithProration(unitWithProration)`. */ + fun price(unitWithProration: NewSubscriptionUnitWithProrationPrice) = + price(Price.ofUnitWithProration(unitWithProration)) + + /** Alias for calling [price] with `Price.ofGroupedAllocation(groupedAllocation)`. */ + fun price(groupedAllocation: NewSubscriptionGroupedAllocationPrice) = + price(Price.ofGroupedAllocation(groupedAllocation)) + + /** + * Alias for calling [price] with + * `Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)`. + */ + fun price(groupedWithProratedMinimum: NewSubscriptionGroupedWithProratedMinimumPrice) = + price(Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)) + + /** Alias for calling [price] with `Price.ofBulkWithProration(bulkWithProration)`. */ + fun price(bulkWithProration: NewSubscriptionBulkWithProrationPrice) = + price(Price.ofBulkWithProration(bulkWithProration)) + + /** + * Alias for calling [price] with + * `Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)`. + */ + fun price( + scalableMatrixWithUnitPricing: NewSubscriptionScalableMatrixWithUnitPricingPrice + ) = price(Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)) + + /** + * Alias for calling [price] with + * `Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)`. + */ + fun price( + scalableMatrixWithTieredPricing: NewSubscriptionScalableMatrixWithTieredPricingPrice + ) = price(Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)) + + /** + * Alias for calling [price] with + * `Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)`. + */ + fun price(cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice) = + price(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) + + /** + * Alias for calling [price] with + * `Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)`. + */ + fun price(maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice) = + price(Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)) + + /** + * Alias for calling [price] with + * `Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)`. + */ + fun price(groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice) = + price(Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)) + + /** + * Alias for calling [price] with + * `Price.ofMatrixWithDisplayName(matrixWithDisplayName)`. + */ + fun price(matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice) = + price(Price.ofMatrixWithDisplayName(matrixWithDisplayName)) + + /** + * Alias for calling [price] with `Price.ofGroupedTieredPackage(groupedTieredPackage)`. + */ + fun price(groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice) = + price(Price.ofGroupedTieredPackage(groupedTieredPackage)) + + /** + * Alias for calling [price] with `Price.ofMatrixWithAllocation(matrixWithAllocation)`. + */ + fun price(matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice) = + price(Price.ofMatrixWithAllocation(matrixWithAllocation)) + + /** + * Alias for calling [price] with + * `Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)`. + */ + fun price(tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice) = + price(Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)) + + /** Alias for calling [price] with `Price.ofGroupedTiered(groupedTiered)`. */ + fun price(groupedTiered: NewSubscriptionGroupedTieredPrice) = + price(Price.ofGroupedTiered(groupedTiered)) + + /** + * Alias for calling [price] with + * `Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)`. + */ + fun price(groupedWithMinMaxThresholds: Price.GroupedWithMinMaxThresholds) = + price(Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)) + + /** Alias for calling [price] with `Price.ofMinimum(minimum)`. */ + fun price(minimum: Price.Minimum) = price(Price.ofMinimum(minimum)) + + /** The id of the price to add to the subscription. */ + fun priceId(priceId: String?) = priceId(JsonField.ofNullable(priceId)) + + /** + * Sets [Builder.priceId] to an arbitrary JSON value. + * + * You should usually call [Builder.priceId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun priceId(priceId: JsonField) = apply { this.priceId = priceId } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ReplacePrice]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .replacesPriceId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ReplacePrice = + ReplacePrice( + checkRequired("replacesPriceId", replacesPriceId), + allocationPrice, + (discounts ?: JsonMissing.of()).map { it.toImmutable() }, + externalPriceId, + fixedPriceQuantity, + maximumAmount, + minimumAmount, + price, + priceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ReplacePrice = apply { + if (validated) { + return@apply + } + + replacesPriceId() + allocationPrice()?.validate() + discounts()?.forEach { it.validate() } + externalPriceId() + fixedPriceQuantity() + maximumAmount() + minimumAmount() + price()?.validate() + priceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (replacesPriceId.asKnown() == null) 0 else 1) + + (allocationPrice.asKnown()?.validity() ?: 0) + + (discounts.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (maximumAmount.asKnown() == null) 0 else 1) + + (if (minimumAmount.asKnown() == null) 0 else 1) + + (price.asKnown()?.validity() ?: 0) + + (if (priceId.asKnown() == null) 0 else 1) + + /** The definition of a new price to create and add to the subscription. */ + @JsonDeserialize(using = Price.Deserializer::class) + @JsonSerialize(using = Price.Serializer::class) + class Price + private constructor( + private val unit: NewSubscriptionUnitPrice? = null, + private val package_: NewSubscriptionPackagePrice? = null, + private val matrix: NewSubscriptionMatrixPrice? = null, + private val tiered: NewSubscriptionTieredPrice? = null, + private val bulk: NewSubscriptionBulkPrice? = null, + private val thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice? = null, + private val tieredPackage: NewSubscriptionTieredPackagePrice? = null, + private val tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice? = null, + private val unitWithPercent: NewSubscriptionUnitWithPercentPrice? = null, + private val packageWithAllocation: NewSubscriptionPackageWithAllocationPrice? = null, + private val tieredWithProration: NewSubscriptionTierWithProrationPrice? = null, + private val unitWithProration: NewSubscriptionUnitWithProrationPrice? = null, + private val groupedAllocation: NewSubscriptionGroupedAllocationPrice? = null, + private val groupedWithProratedMinimum: + NewSubscriptionGroupedWithProratedMinimumPrice? = + null, + private val bulkWithProration: NewSubscriptionBulkWithProrationPrice? = null, + private val scalableMatrixWithUnitPricing: + NewSubscriptionScalableMatrixWithUnitPricingPrice? = + null, + private val scalableMatrixWithTieredPricing: + NewSubscriptionScalableMatrixWithTieredPricingPrice? = + null, + private val cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice? = null, + private val maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice? = null, + private val groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice? = + null, + private val matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice? = null, + private val groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice? = null, + private val matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice? = null, + private val tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice? = + null, + private val groupedTiered: NewSubscriptionGroupedTieredPrice? = null, + private val groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds? = null, + private val minimum: Minimum? = null, + private val _json: JsonValue? = null, + ) { + + fun unit(): NewSubscriptionUnitPrice? = unit + + fun package_(): NewSubscriptionPackagePrice? = package_ + + fun matrix(): NewSubscriptionMatrixPrice? = matrix + + fun tiered(): NewSubscriptionTieredPrice? = tiered + + fun bulk(): NewSubscriptionBulkPrice? = bulk + + fun thresholdTotalAmount(): NewSubscriptionThresholdTotalAmountPrice? = + thresholdTotalAmount + + fun tieredPackage(): NewSubscriptionTieredPackagePrice? = tieredPackage + + fun tieredWithMinimum(): NewSubscriptionTieredWithMinimumPrice? = tieredWithMinimum + + fun unitWithPercent(): NewSubscriptionUnitWithPercentPrice? = unitWithPercent + + fun packageWithAllocation(): NewSubscriptionPackageWithAllocationPrice? = + packageWithAllocation + + fun tieredWithProration(): NewSubscriptionTierWithProrationPrice? = tieredWithProration + + fun unitWithProration(): NewSubscriptionUnitWithProrationPrice? = unitWithProration + + fun groupedAllocation(): NewSubscriptionGroupedAllocationPrice? = groupedAllocation + + fun groupedWithProratedMinimum(): NewSubscriptionGroupedWithProratedMinimumPrice? = + groupedWithProratedMinimum + + fun bulkWithProration(): NewSubscriptionBulkWithProrationPrice? = bulkWithProration + + fun scalableMatrixWithUnitPricing(): + NewSubscriptionScalableMatrixWithUnitPricingPrice? = scalableMatrixWithUnitPricing + + fun scalableMatrixWithTieredPricing(): + NewSubscriptionScalableMatrixWithTieredPricingPrice? = + scalableMatrixWithTieredPricing + + fun cumulativeGroupedBulk(): NewSubscriptionCumulativeGroupedBulkPrice? = + cumulativeGroupedBulk + + fun maxGroupTieredPackage(): NewSubscriptionMaxGroupTieredPackagePrice? = + maxGroupTieredPackage + + fun groupedWithMeteredMinimum(): NewSubscriptionGroupedWithMeteredMinimumPrice? = + groupedWithMeteredMinimum + + fun matrixWithDisplayName(): NewSubscriptionMatrixWithDisplayNamePrice? = + matrixWithDisplayName + + fun groupedTieredPackage(): NewSubscriptionGroupedTieredPackagePrice? = + groupedTieredPackage + + fun matrixWithAllocation(): NewSubscriptionMatrixWithAllocationPrice? = + matrixWithAllocation + + fun tieredPackageWithMinimum(): NewSubscriptionTieredPackageWithMinimumPrice? = + tieredPackageWithMinimum + + fun groupedTiered(): NewSubscriptionGroupedTieredPrice? = groupedTiered + + fun groupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds? = + groupedWithMinMaxThresholds + + fun minimum(): Minimum? = minimum + + fun isUnit(): Boolean = unit != null + + fun isPackage(): Boolean = package_ != null + + fun isMatrix(): Boolean = matrix != null + + fun isTiered(): Boolean = tiered != null + + fun isBulk(): Boolean = bulk != null + + fun isThresholdTotalAmount(): Boolean = thresholdTotalAmount != null + + fun isTieredPackage(): Boolean = tieredPackage != null + + fun isTieredWithMinimum(): Boolean = tieredWithMinimum != null + + fun isUnitWithPercent(): Boolean = unitWithPercent != null + + fun isPackageWithAllocation(): Boolean = packageWithAllocation != null + + fun isTieredWithProration(): Boolean = tieredWithProration != null + + fun isUnitWithProration(): Boolean = unitWithProration != null + + fun isGroupedAllocation(): Boolean = groupedAllocation != null + + fun isGroupedWithProratedMinimum(): Boolean = groupedWithProratedMinimum != null + + fun isBulkWithProration(): Boolean = bulkWithProration != null + + fun isScalableMatrixWithUnitPricing(): Boolean = scalableMatrixWithUnitPricing != null + + fun isScalableMatrixWithTieredPricing(): Boolean = + scalableMatrixWithTieredPricing != null + + fun isCumulativeGroupedBulk(): Boolean = cumulativeGroupedBulk != null + + fun isMaxGroupTieredPackage(): Boolean = maxGroupTieredPackage != null + + fun isGroupedWithMeteredMinimum(): Boolean = groupedWithMeteredMinimum != null + + fun isMatrixWithDisplayName(): Boolean = matrixWithDisplayName != null + + fun isGroupedTieredPackage(): Boolean = groupedTieredPackage != null + + fun isMatrixWithAllocation(): Boolean = matrixWithAllocation != null + + fun isTieredPackageWithMinimum(): Boolean = tieredPackageWithMinimum != null + + fun isGroupedTiered(): Boolean = groupedTiered != null + + fun isGroupedWithMinMaxThresholds(): Boolean = groupedWithMinMaxThresholds != null + + fun isMinimum(): Boolean = minimum != null + + fun asUnit(): NewSubscriptionUnitPrice = unit.getOrThrow("unit") + + fun asPackage(): NewSubscriptionPackagePrice = package_.getOrThrow("package_") + + fun asMatrix(): NewSubscriptionMatrixPrice = matrix.getOrThrow("matrix") + + fun asTiered(): NewSubscriptionTieredPrice = tiered.getOrThrow("tiered") + + fun asBulk(): NewSubscriptionBulkPrice = bulk.getOrThrow("bulk") + + fun asThresholdTotalAmount(): NewSubscriptionThresholdTotalAmountPrice = + thresholdTotalAmount.getOrThrow("thresholdTotalAmount") + + fun asTieredPackage(): NewSubscriptionTieredPackagePrice = + tieredPackage.getOrThrow("tieredPackage") + + fun asTieredWithMinimum(): NewSubscriptionTieredWithMinimumPrice = + tieredWithMinimum.getOrThrow("tieredWithMinimum") + + fun asUnitWithPercent(): NewSubscriptionUnitWithPercentPrice = + unitWithPercent.getOrThrow("unitWithPercent") + + fun asPackageWithAllocation(): NewSubscriptionPackageWithAllocationPrice = + packageWithAllocation.getOrThrow("packageWithAllocation") + + fun asTieredWithProration(): NewSubscriptionTierWithProrationPrice = + tieredWithProration.getOrThrow("tieredWithProration") + + fun asUnitWithProration(): NewSubscriptionUnitWithProrationPrice = + unitWithProration.getOrThrow("unitWithProration") + + fun asGroupedAllocation(): NewSubscriptionGroupedAllocationPrice = + groupedAllocation.getOrThrow("groupedAllocation") + + fun asGroupedWithProratedMinimum(): NewSubscriptionGroupedWithProratedMinimumPrice = + groupedWithProratedMinimum.getOrThrow("groupedWithProratedMinimum") + + fun asBulkWithProration(): NewSubscriptionBulkWithProrationPrice = + bulkWithProration.getOrThrow("bulkWithProration") + + fun asScalableMatrixWithUnitPricing(): + NewSubscriptionScalableMatrixWithUnitPricingPrice = + scalableMatrixWithUnitPricing.getOrThrow("scalableMatrixWithUnitPricing") + + fun asScalableMatrixWithTieredPricing(): + NewSubscriptionScalableMatrixWithTieredPricingPrice = + scalableMatrixWithTieredPricing.getOrThrow("scalableMatrixWithTieredPricing") + + fun asCumulativeGroupedBulk(): NewSubscriptionCumulativeGroupedBulkPrice = + cumulativeGroupedBulk.getOrThrow("cumulativeGroupedBulk") + + fun asMaxGroupTieredPackage(): NewSubscriptionMaxGroupTieredPackagePrice = + maxGroupTieredPackage.getOrThrow("maxGroupTieredPackage") + + fun asGroupedWithMeteredMinimum(): NewSubscriptionGroupedWithMeteredMinimumPrice = + groupedWithMeteredMinimum.getOrThrow("groupedWithMeteredMinimum") + + fun asMatrixWithDisplayName(): NewSubscriptionMatrixWithDisplayNamePrice = + matrixWithDisplayName.getOrThrow("matrixWithDisplayName") + + fun asGroupedTieredPackage(): NewSubscriptionGroupedTieredPackagePrice = + groupedTieredPackage.getOrThrow("groupedTieredPackage") + + fun asMatrixWithAllocation(): NewSubscriptionMatrixWithAllocationPrice = + matrixWithAllocation.getOrThrow("matrixWithAllocation") + + fun asTieredPackageWithMinimum(): NewSubscriptionTieredPackageWithMinimumPrice = + tieredPackageWithMinimum.getOrThrow("tieredPackageWithMinimum") + + fun asGroupedTiered(): NewSubscriptionGroupedTieredPrice = + groupedTiered.getOrThrow("groupedTiered") + + fun asGroupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds = + groupedWithMinMaxThresholds.getOrThrow("groupedWithMinMaxThresholds") + + fun asMinimum(): Minimum = minimum.getOrThrow("minimum") + + fun _json(): JsonValue? = _json + + fun accept(visitor: Visitor): T = + when { + unit != null -> visitor.visitUnit(unit) + package_ != null -> visitor.visitPackage(package_) + matrix != null -> visitor.visitMatrix(matrix) + tiered != null -> visitor.visitTiered(tiered) + bulk != null -> visitor.visitBulk(bulk) + thresholdTotalAmount != null -> + visitor.visitThresholdTotalAmount(thresholdTotalAmount) + tieredPackage != null -> visitor.visitTieredPackage(tieredPackage) + tieredWithMinimum != null -> visitor.visitTieredWithMinimum(tieredWithMinimum) + unitWithPercent != null -> visitor.visitUnitWithPercent(unitWithPercent) + packageWithAllocation != null -> + visitor.visitPackageWithAllocation(packageWithAllocation) + tieredWithProration != null -> + visitor.visitTieredWithProration(tieredWithProration) + unitWithProration != null -> visitor.visitUnitWithProration(unitWithProration) + groupedAllocation != null -> visitor.visitGroupedAllocation(groupedAllocation) + groupedWithProratedMinimum != null -> + visitor.visitGroupedWithProratedMinimum(groupedWithProratedMinimum) + bulkWithProration != null -> visitor.visitBulkWithProration(bulkWithProration) + scalableMatrixWithUnitPricing != null -> + visitor.visitScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing) + scalableMatrixWithTieredPricing != null -> + visitor.visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing + ) + cumulativeGroupedBulk != null -> + visitor.visitCumulativeGroupedBulk(cumulativeGroupedBulk) + maxGroupTieredPackage != null -> + visitor.visitMaxGroupTieredPackage(maxGroupTieredPackage) + groupedWithMeteredMinimum != null -> + visitor.visitGroupedWithMeteredMinimum(groupedWithMeteredMinimum) + matrixWithDisplayName != null -> + visitor.visitMatrixWithDisplayName(matrixWithDisplayName) + groupedTieredPackage != null -> + visitor.visitGroupedTieredPackage(groupedTieredPackage) + matrixWithAllocation != null -> + visitor.visitMatrixWithAllocation(matrixWithAllocation) + tieredPackageWithMinimum != null -> + visitor.visitTieredPackageWithMinimum(tieredPackageWithMinimum) + groupedTiered != null -> visitor.visitGroupedTiered(groupedTiered) + groupedWithMinMaxThresholds != null -> + visitor.visitGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds) + minimum != null -> visitor.visitMinimum(minimum) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Price = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitUnit(unit: NewSubscriptionUnitPrice) { + unit.validate() + } + + override fun visitPackage(package_: NewSubscriptionPackagePrice) { + package_.validate() + } + + override fun visitMatrix(matrix: NewSubscriptionMatrixPrice) { + matrix.validate() + } + + override fun visitTiered(tiered: NewSubscriptionTieredPrice) { + tiered.validate() + } + + override fun visitBulk(bulk: NewSubscriptionBulkPrice) { + bulk.validate() + } + + override fun visitThresholdTotalAmount( + thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice + ) { + thresholdTotalAmount.validate() + } + + override fun visitTieredPackage( + tieredPackage: NewSubscriptionTieredPackagePrice + ) { + tieredPackage.validate() + } + + override fun visitTieredWithMinimum( + tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice + ) { + tieredWithMinimum.validate() + } + + override fun visitUnitWithPercent( + unitWithPercent: NewSubscriptionUnitWithPercentPrice + ) { + unitWithPercent.validate() + } + + override fun visitPackageWithAllocation( + packageWithAllocation: NewSubscriptionPackageWithAllocationPrice + ) { + packageWithAllocation.validate() + } + + override fun visitTieredWithProration( + tieredWithProration: NewSubscriptionTierWithProrationPrice + ) { + tieredWithProration.validate() + } + + override fun visitUnitWithProration( + unitWithProration: NewSubscriptionUnitWithProrationPrice + ) { + unitWithProration.validate() + } + + override fun visitGroupedAllocation( + groupedAllocation: NewSubscriptionGroupedAllocationPrice + ) { + groupedAllocation.validate() + } + + override fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: + NewSubscriptionGroupedWithProratedMinimumPrice + ) { + groupedWithProratedMinimum.validate() + } + + override fun visitBulkWithProration( + bulkWithProration: NewSubscriptionBulkWithProrationPrice + ) { + bulkWithProration.validate() + } + + override fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: + NewSubscriptionScalableMatrixWithUnitPricingPrice + ) { + scalableMatrixWithUnitPricing.validate() + } + + override fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: + NewSubscriptionScalableMatrixWithTieredPricingPrice + ) { + scalableMatrixWithTieredPricing.validate() + } + + override fun visitCumulativeGroupedBulk( + cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice + ) { + cumulativeGroupedBulk.validate() + } + + override fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice + ) { + maxGroupTieredPackage.validate() + } override fun visitGroupedWithMeteredMinimum( groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice @@ -8296,766 +11307,3811 @@ private constructor( groupedWithMeteredMinimum.validate() } - override fun visitMatrixWithDisplayName( - matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice - ) { - matrixWithDisplayName.validate() - } + override fun visitMatrixWithDisplayName( + matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice + ) { + matrixWithDisplayName.validate() + } + + override fun visitGroupedTieredPackage( + groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice + ) { + groupedTieredPackage.validate() + } + + override fun visitMatrixWithAllocation( + matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice + ) { + matrixWithAllocation.validate() + } + + override fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice + ) { + tieredPackageWithMinimum.validate() + } + + override fun visitGroupedTiered( + groupedTiered: NewSubscriptionGroupedTieredPrice + ) { + groupedTiered.validate() + } + + override fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) { + groupedWithMinMaxThresholds.validate() + } + + override fun visitMinimum(minimum: Minimum) { + minimum.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitUnit(unit: NewSubscriptionUnitPrice) = unit.validity() + + override fun visitPackage(package_: NewSubscriptionPackagePrice) = + package_.validity() + + override fun visitMatrix(matrix: NewSubscriptionMatrixPrice) = + matrix.validity() + + override fun visitTiered(tiered: NewSubscriptionTieredPrice) = + tiered.validity() + + override fun visitBulk(bulk: NewSubscriptionBulkPrice) = bulk.validity() + + override fun visitThresholdTotalAmount( + thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice + ) = thresholdTotalAmount.validity() + + override fun visitTieredPackage( + tieredPackage: NewSubscriptionTieredPackagePrice + ) = tieredPackage.validity() + + override fun visitTieredWithMinimum( + tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice + ) = tieredWithMinimum.validity() + + override fun visitUnitWithPercent( + unitWithPercent: NewSubscriptionUnitWithPercentPrice + ) = unitWithPercent.validity() + + override fun visitPackageWithAllocation( + packageWithAllocation: NewSubscriptionPackageWithAllocationPrice + ) = packageWithAllocation.validity() + + override fun visitTieredWithProration( + tieredWithProration: NewSubscriptionTierWithProrationPrice + ) = tieredWithProration.validity() + + override fun visitUnitWithProration( + unitWithProration: NewSubscriptionUnitWithProrationPrice + ) = unitWithProration.validity() + + override fun visitGroupedAllocation( + groupedAllocation: NewSubscriptionGroupedAllocationPrice + ) = groupedAllocation.validity() + + override fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: + NewSubscriptionGroupedWithProratedMinimumPrice + ) = groupedWithProratedMinimum.validity() + + override fun visitBulkWithProration( + bulkWithProration: NewSubscriptionBulkWithProrationPrice + ) = bulkWithProration.validity() + + override fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: + NewSubscriptionScalableMatrixWithUnitPricingPrice + ) = scalableMatrixWithUnitPricing.validity() + + override fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: + NewSubscriptionScalableMatrixWithTieredPricingPrice + ) = scalableMatrixWithTieredPricing.validity() + + override fun visitCumulativeGroupedBulk( + cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice + ) = cumulativeGroupedBulk.validity() + + override fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice + ) = maxGroupTieredPackage.validity() + + override fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice + ) = groupedWithMeteredMinimum.validity() + + override fun visitMatrixWithDisplayName( + matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice + ) = matrixWithDisplayName.validity() + + override fun visitGroupedTieredPackage( + groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice + ) = groupedTieredPackage.validity() + + override fun visitMatrixWithAllocation( + matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice + ) = matrixWithAllocation.validity() + + override fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice + ) = tieredPackageWithMinimum.validity() + + override fun visitGroupedTiered( + groupedTiered: NewSubscriptionGroupedTieredPrice + ) = groupedTiered.validity() + + override fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) = groupedWithMinMaxThresholds.validity() + + override fun visitMinimum(minimum: Minimum) = minimum.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Price && + unit == other.unit && + package_ == other.package_ && + matrix == other.matrix && + tiered == other.tiered && + bulk == other.bulk && + thresholdTotalAmount == other.thresholdTotalAmount && + tieredPackage == other.tieredPackage && + tieredWithMinimum == other.tieredWithMinimum && + unitWithPercent == other.unitWithPercent && + packageWithAllocation == other.packageWithAllocation && + tieredWithProration == other.tieredWithProration && + unitWithProration == other.unitWithProration && + groupedAllocation == other.groupedAllocation && + groupedWithProratedMinimum == other.groupedWithProratedMinimum && + bulkWithProration == other.bulkWithProration && + scalableMatrixWithUnitPricing == other.scalableMatrixWithUnitPricing && + scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && + cumulativeGroupedBulk == other.cumulativeGroupedBulk && + maxGroupTieredPackage == other.maxGroupTieredPackage && + groupedWithMeteredMinimum == other.groupedWithMeteredMinimum && + matrixWithDisplayName == other.matrixWithDisplayName && + groupedTieredPackage == other.groupedTieredPackage && + matrixWithAllocation == other.matrixWithAllocation && + tieredPackageWithMinimum == other.tieredPackageWithMinimum && + groupedTiered == other.groupedTiered && + groupedWithMinMaxThresholds == other.groupedWithMinMaxThresholds && + minimum == other.minimum + } + + override fun hashCode(): Int = + Objects.hash( + unit, + package_, + matrix, + tiered, + bulk, + thresholdTotalAmount, + tieredPackage, + tieredWithMinimum, + unitWithPercent, + packageWithAllocation, + tieredWithProration, + unitWithProration, + groupedAllocation, + groupedWithProratedMinimum, + bulkWithProration, + scalableMatrixWithUnitPricing, + scalableMatrixWithTieredPricing, + cumulativeGroupedBulk, + maxGroupTieredPackage, + groupedWithMeteredMinimum, + matrixWithDisplayName, + groupedTieredPackage, + matrixWithAllocation, + tieredPackageWithMinimum, + groupedTiered, + groupedWithMinMaxThresholds, + minimum, + ) + + override fun toString(): String = + when { + unit != null -> "Price{unit=$unit}" + package_ != null -> "Price{package_=$package_}" + matrix != null -> "Price{matrix=$matrix}" + tiered != null -> "Price{tiered=$tiered}" + bulk != null -> "Price{bulk=$bulk}" + thresholdTotalAmount != null -> + "Price{thresholdTotalAmount=$thresholdTotalAmount}" + tieredPackage != null -> "Price{tieredPackage=$tieredPackage}" + tieredWithMinimum != null -> "Price{tieredWithMinimum=$tieredWithMinimum}" + unitWithPercent != null -> "Price{unitWithPercent=$unitWithPercent}" + packageWithAllocation != null -> + "Price{packageWithAllocation=$packageWithAllocation}" + tieredWithProration != null -> "Price{tieredWithProration=$tieredWithProration}" + unitWithProration != null -> "Price{unitWithProration=$unitWithProration}" + groupedAllocation != null -> "Price{groupedAllocation=$groupedAllocation}" + groupedWithProratedMinimum != null -> + "Price{groupedWithProratedMinimum=$groupedWithProratedMinimum}" + bulkWithProration != null -> "Price{bulkWithProration=$bulkWithProration}" + scalableMatrixWithUnitPricing != null -> + "Price{scalableMatrixWithUnitPricing=$scalableMatrixWithUnitPricing}" + scalableMatrixWithTieredPricing != null -> + "Price{scalableMatrixWithTieredPricing=$scalableMatrixWithTieredPricing}" + cumulativeGroupedBulk != null -> + "Price{cumulativeGroupedBulk=$cumulativeGroupedBulk}" + maxGroupTieredPackage != null -> + "Price{maxGroupTieredPackage=$maxGroupTieredPackage}" + groupedWithMeteredMinimum != null -> + "Price{groupedWithMeteredMinimum=$groupedWithMeteredMinimum}" + matrixWithDisplayName != null -> + "Price{matrixWithDisplayName=$matrixWithDisplayName}" + groupedTieredPackage != null -> + "Price{groupedTieredPackage=$groupedTieredPackage}" + matrixWithAllocation != null -> + "Price{matrixWithAllocation=$matrixWithAllocation}" + tieredPackageWithMinimum != null -> + "Price{tieredPackageWithMinimum=$tieredPackageWithMinimum}" + groupedTiered != null -> "Price{groupedTiered=$groupedTiered}" + groupedWithMinMaxThresholds != null -> + "Price{groupedWithMinMaxThresholds=$groupedWithMinMaxThresholds}" + minimum != null -> "Price{minimum=$minimum}" + _json != null -> "Price{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Price") + } + + companion object { + + fun ofUnit(unit: NewSubscriptionUnitPrice) = Price(unit = unit) + + fun ofPackage(package_: NewSubscriptionPackagePrice) = Price(package_ = package_) + + fun ofMatrix(matrix: NewSubscriptionMatrixPrice) = Price(matrix = matrix) + + fun ofTiered(tiered: NewSubscriptionTieredPrice) = Price(tiered = tiered) + + fun ofBulk(bulk: NewSubscriptionBulkPrice) = Price(bulk = bulk) + + fun ofThresholdTotalAmount( + thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice + ) = Price(thresholdTotalAmount = thresholdTotalAmount) + + fun ofTieredPackage(tieredPackage: NewSubscriptionTieredPackagePrice) = + Price(tieredPackage = tieredPackage) + + fun ofTieredWithMinimum(tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice) = + Price(tieredWithMinimum = tieredWithMinimum) + + fun ofUnitWithPercent(unitWithPercent: NewSubscriptionUnitWithPercentPrice) = + Price(unitWithPercent = unitWithPercent) + + fun ofPackageWithAllocation( + packageWithAllocation: NewSubscriptionPackageWithAllocationPrice + ) = Price(packageWithAllocation = packageWithAllocation) + + fun ofTieredWithProration( + tieredWithProration: NewSubscriptionTierWithProrationPrice + ) = Price(tieredWithProration = tieredWithProration) + + fun ofUnitWithProration(unitWithProration: NewSubscriptionUnitWithProrationPrice) = + Price(unitWithProration = unitWithProration) + + fun ofGroupedAllocation(groupedAllocation: NewSubscriptionGroupedAllocationPrice) = + Price(groupedAllocation = groupedAllocation) + + fun ofGroupedWithProratedMinimum( + groupedWithProratedMinimum: NewSubscriptionGroupedWithProratedMinimumPrice + ) = Price(groupedWithProratedMinimum = groupedWithProratedMinimum) + + fun ofBulkWithProration(bulkWithProration: NewSubscriptionBulkWithProrationPrice) = + Price(bulkWithProration = bulkWithProration) + + fun ofScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: NewSubscriptionScalableMatrixWithUnitPricingPrice + ) = Price(scalableMatrixWithUnitPricing = scalableMatrixWithUnitPricing) + + fun ofScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: + NewSubscriptionScalableMatrixWithTieredPricingPrice + ) = Price(scalableMatrixWithTieredPricing = scalableMatrixWithTieredPricing) + + fun ofCumulativeGroupedBulk( + cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice + ) = Price(cumulativeGroupedBulk = cumulativeGroupedBulk) + + fun ofMaxGroupTieredPackage( + maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice + ) = Price(maxGroupTieredPackage = maxGroupTieredPackage) + + fun ofGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice + ) = Price(groupedWithMeteredMinimum = groupedWithMeteredMinimum) + + fun ofMatrixWithDisplayName( + matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice + ) = Price(matrixWithDisplayName = matrixWithDisplayName) + + fun ofGroupedTieredPackage( + groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice + ) = Price(groupedTieredPackage = groupedTieredPackage) + + fun ofMatrixWithAllocation( + matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice + ) = Price(matrixWithAllocation = matrixWithAllocation) + + fun ofTieredPackageWithMinimum( + tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice + ) = Price(tieredPackageWithMinimum = tieredPackageWithMinimum) + + fun ofGroupedTiered(groupedTiered: NewSubscriptionGroupedTieredPrice) = + Price(groupedTiered = groupedTiered) + + fun ofGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) = Price(groupedWithMinMaxThresholds = groupedWithMinMaxThresholds) + + fun ofMinimum(minimum: Minimum) = Price(minimum = minimum) + } + + /** + * An interface that defines how to map each variant of [Price] to a value of type [T]. + */ + interface Visitor { + + fun visitUnit(unit: NewSubscriptionUnitPrice): T + + fun visitPackage(package_: NewSubscriptionPackagePrice): T + + fun visitMatrix(matrix: NewSubscriptionMatrixPrice): T + + fun visitTiered(tiered: NewSubscriptionTieredPrice): T + + fun visitBulk(bulk: NewSubscriptionBulkPrice): T + + fun visitThresholdTotalAmount( + thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice + ): T + + fun visitTieredPackage(tieredPackage: NewSubscriptionTieredPackagePrice): T + + fun visitTieredWithMinimum( + tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice + ): T + + fun visitUnitWithPercent(unitWithPercent: NewSubscriptionUnitWithPercentPrice): T + + fun visitPackageWithAllocation( + packageWithAllocation: NewSubscriptionPackageWithAllocationPrice + ): T + + fun visitTieredWithProration( + tieredWithProration: NewSubscriptionTierWithProrationPrice + ): T + + fun visitUnitWithProration( + unitWithProration: NewSubscriptionUnitWithProrationPrice + ): T + + fun visitGroupedAllocation( + groupedAllocation: NewSubscriptionGroupedAllocationPrice + ): T + + fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: NewSubscriptionGroupedWithProratedMinimumPrice + ): T + + fun visitBulkWithProration( + bulkWithProration: NewSubscriptionBulkWithProrationPrice + ): T + + fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: NewSubscriptionScalableMatrixWithUnitPricingPrice + ): T + + fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: + NewSubscriptionScalableMatrixWithTieredPricingPrice + ): T + + fun visitCumulativeGroupedBulk( + cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice + ): T + + fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice + ): T + + fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice + ): T + + fun visitMatrixWithDisplayName( + matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice + ): T + + fun visitGroupedTieredPackage( + groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice + ): T + + fun visitMatrixWithAllocation( + matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice + ): T + + fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice + ): T + + fun visitGroupedTiered(groupedTiered: NewSubscriptionGroupedTieredPrice): T + + fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ): T + + fun visitMinimum(minimum: Minimum): T + + /** + * Maps an unknown variant of [Price] to a value of type [T]. + * + * An instance of [Price] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is + * unaware of. + * + * @throws OrbInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw OrbInvalidDataException("Unknown Price: $json") + } + } + + internal class Deserializer : BaseDeserializer(Price::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Price { + val json = JsonValue.fromJsonNode(node) + val modelType = json.asObject()?.get("model_type")?.asString() + + when (modelType) { + "unit" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(unit = it, _json = json) } ?: Price(_json = json) + } + "package" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(package_ = it, _json = json) } ?: Price(_json = json) + } + "matrix" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(matrix = it, _json = json) } ?: Price(_json = json) + } + "tiered" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(tiered = it, _json = json) } ?: Price(_json = json) + } + "bulk" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(bulk = it, _json = json) } ?: Price(_json = json) + } + "threshold_total_amount" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(thresholdTotalAmount = it, _json = json) } + ?: Price(_json = json) + } + "tiered_package" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(tieredPackage = it, _json = json) } + ?: Price(_json = json) + } + "tiered_with_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(tieredWithMinimum = it, _json = json) } + ?: Price(_json = json) + } + "unit_with_percent" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(unitWithPercent = it, _json = json) } + ?: Price(_json = json) + } + "package_with_allocation" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(packageWithAllocation = it, _json = json) } + ?: Price(_json = json) + } + "tiered_with_proration" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(tieredWithProration = it, _json = json) } + ?: Price(_json = json) + } + "unit_with_proration" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(unitWithProration = it, _json = json) } + ?: Price(_json = json) + } + "grouped_allocation" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedAllocation = it, _json = json) } + ?: Price(_json = json) + } + "grouped_with_prorated_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedWithProratedMinimum = it, _json = json) } + ?: Price(_json = json) + } + "bulk_with_proration" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(bulkWithProration = it, _json = json) } + ?: Price(_json = json) + } + "scalable_matrix_with_unit_pricing" -> { + return tryDeserialize( + node, + jacksonTypeRef< + NewSubscriptionScalableMatrixWithUnitPricingPrice + >(), + ) + ?.let { Price(scalableMatrixWithUnitPricing = it, _json = json) } + ?: Price(_json = json) + } + "scalable_matrix_with_tiered_pricing" -> { + return tryDeserialize( + node, + jacksonTypeRef< + NewSubscriptionScalableMatrixWithTieredPricingPrice + >(), + ) + ?.let { Price(scalableMatrixWithTieredPricing = it, _json = json) } + ?: Price(_json = json) + } + "cumulative_grouped_bulk" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(cumulativeGroupedBulk = it, _json = json) } + ?: Price(_json = json) + } + "max_group_tiered_package" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(maxGroupTieredPackage = it, _json = json) } + ?: Price(_json = json) + } + "grouped_with_metered_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedWithMeteredMinimum = it, _json = json) } + ?: Price(_json = json) + } + "matrix_with_display_name" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(matrixWithDisplayName = it, _json = json) } + ?: Price(_json = json) + } + "grouped_tiered_package" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedTieredPackage = it, _json = json) } + ?: Price(_json = json) + } + "matrix_with_allocation" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(matrixWithAllocation = it, _json = json) } + ?: Price(_json = json) + } + "tiered_package_with_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(tieredPackageWithMinimum = it, _json = json) } + ?: Price(_json = json) + } + "grouped_tiered" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedTiered = it, _json = json) } + ?: Price(_json = json) + } + "grouped_with_min_max_thresholds" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedWithMinMaxThresholds = it, _json = json) } + ?: Price(_json = json) + } + "minimum" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(minimum = it, _json = json) + } ?: Price(_json = json) + } + } + + return Price(_json = json) + } + } + + internal class Serializer : BaseSerializer(Price::class) { + + override fun serialize( + value: Price, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.unit != null -> generator.writeObject(value.unit) + value.package_ != null -> generator.writeObject(value.package_) + value.matrix != null -> generator.writeObject(value.matrix) + value.tiered != null -> generator.writeObject(value.tiered) + value.bulk != null -> generator.writeObject(value.bulk) + value.thresholdTotalAmount != null -> + generator.writeObject(value.thresholdTotalAmount) + value.tieredPackage != null -> generator.writeObject(value.tieredPackage) + value.tieredWithMinimum != null -> + generator.writeObject(value.tieredWithMinimum) + value.unitWithPercent != null -> + generator.writeObject(value.unitWithPercent) + value.packageWithAllocation != null -> + generator.writeObject(value.packageWithAllocation) + value.tieredWithProration != null -> + generator.writeObject(value.tieredWithProration) + value.unitWithProration != null -> + generator.writeObject(value.unitWithProration) + value.groupedAllocation != null -> + generator.writeObject(value.groupedAllocation) + value.groupedWithProratedMinimum != null -> + generator.writeObject(value.groupedWithProratedMinimum) + value.bulkWithProration != null -> + generator.writeObject(value.bulkWithProration) + value.scalableMatrixWithUnitPricing != null -> + generator.writeObject(value.scalableMatrixWithUnitPricing) + value.scalableMatrixWithTieredPricing != null -> + generator.writeObject(value.scalableMatrixWithTieredPricing) + value.cumulativeGroupedBulk != null -> + generator.writeObject(value.cumulativeGroupedBulk) + value.maxGroupTieredPackage != null -> + generator.writeObject(value.maxGroupTieredPackage) + value.groupedWithMeteredMinimum != null -> + generator.writeObject(value.groupedWithMeteredMinimum) + value.matrixWithDisplayName != null -> + generator.writeObject(value.matrixWithDisplayName) + value.groupedTieredPackage != null -> + generator.writeObject(value.groupedTieredPackage) + value.matrixWithAllocation != null -> + generator.writeObject(value.matrixWithAllocation) + value.tieredPackageWithMinimum != null -> + generator.writeObject(value.tieredPackageWithMinimum) + value.groupedTiered != null -> generator.writeObject(value.groupedTiered) + value.groupedWithMinMaxThresholds != null -> + generator.writeObject(value.groupedWithMinMaxThresholds) + value.minimum != null -> generator.writeObject(value.minimum) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Price") + } + } + } + + class GroupedWithMinMaxThresholds + private constructor( + private val cadence: JsonField, + private val groupedWithMinMaxThresholdsConfig: + JsonField, + private val itemId: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("grouped_with_min_max_thresholds_config") + @ExcludeMissing + groupedWithMinMaxThresholdsConfig: + JsonField = + JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + groupedWithMinMaxThresholdsConfig, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupedWithMinMaxThresholdsConfig(): GroupedWithMinMaxThresholdsConfig = + groupedWithMinMaxThresholdsConfig.getRequired( + "grouped_with_min_max_thresholds_config" + ) + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * Expected to always return the following: + * ```kotlin + * JsonValue.from("grouped_with_min_max_thresholds") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = billableMetricId.getNullable("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") - override fun visitGroupedTieredPackage( - groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice - ) { - groupedTieredPackage.validate() - } + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") - override fun visitMatrixWithAllocation( - matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice - ) { - matrixWithAllocation.validate() - } + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") - override fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice - ) { - tieredPackageWithMinimum.validate() - } + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") - override fun visitGroupedTiered( - groupedTiered: NewSubscriptionGroupedTieredPrice - ) { - groupedTiered.validate() + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + invoiceGroupingKey.getNullable("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [groupedWithMinMaxThresholdsConfig]. + * + * Unlike [groupedWithMinMaxThresholdsConfig], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("grouped_with_min_max_thresholds_config") + @ExcludeMissing + fun _groupedWithMinMaxThresholdsConfig(): + JsonField = groupedWithMinMaxThresholdsConfig + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [GroupedWithMinMaxThresholds]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .groupedWithMinMaxThresholdsConfig() + * .itemId() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [GroupedWithMinMaxThresholds]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var groupedWithMinMaxThresholdsConfig: + JsonField? = + null + private var itemId: JsonField? = null + private var modelType: JsonValue = + JsonValue.from("grouped_with_min_max_thresholds") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds) = + apply { + cadence = groupedWithMinMaxThresholds.cadence + groupedWithMinMaxThresholdsConfig = + groupedWithMinMaxThresholds.groupedWithMinMaxThresholdsConfig + itemId = groupedWithMinMaxThresholds.itemId + modelType = groupedWithMinMaxThresholds.modelType + name = groupedWithMinMaxThresholds.name + billableMetricId = groupedWithMinMaxThresholds.billableMetricId + billedInAdvance = groupedWithMinMaxThresholds.billedInAdvance + billingCycleConfiguration = + groupedWithMinMaxThresholds.billingCycleConfiguration + conversionRate = groupedWithMinMaxThresholds.conversionRate + conversionRateConfig = groupedWithMinMaxThresholds.conversionRateConfig + currency = groupedWithMinMaxThresholds.currency + dimensionalPriceConfiguration = + groupedWithMinMaxThresholds.dimensionalPriceConfiguration + externalPriceId = groupedWithMinMaxThresholds.externalPriceId + fixedPriceQuantity = groupedWithMinMaxThresholds.fixedPriceQuantity + invoiceGroupingKey = groupedWithMinMaxThresholds.invoiceGroupingKey + invoicingCycleConfiguration = + groupedWithMinMaxThresholds.invoicingCycleConfiguration + metadata = groupedWithMinMaxThresholds.metadata + referenceId = groupedWithMinMaxThresholds.referenceId + additionalProperties = + groupedWithMinMaxThresholds.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + fun groupedWithMinMaxThresholdsConfig( + groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + ) = + groupedWithMinMaxThresholdsConfig( + JsonField.of(groupedWithMinMaxThresholdsConfig) + ) + + /** + * Sets [Builder.groupedWithMinMaxThresholdsConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.groupedWithMinMaxThresholdsConfig] with a + * well-typed [GroupedWithMinMaxThresholdsConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun groupedWithMinMaxThresholdsConfig( + groupedWithMinMaxThresholdsConfig: + JsonField + ) = apply { + this.groupedWithMinMaxThresholdsConfig = groupedWithMinMaxThresholdsConfig + } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("grouped_with_min_max_thresholds") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) } - ) - validated = true - } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [GroupedWithMinMaxThresholds]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .groupedWithMinMaxThresholdsConfig() + * .itemId() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedWithMinMaxThresholds = + GroupedWithMinMaxThresholds( + checkRequired("cadence", cadence), + checkRequired( + "groupedWithMinMaxThresholdsConfig", + groupedWithMinMaxThresholdsConfig, + ), + checkRequired("itemId", itemId), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: NewSubscriptionUnitPrice) = unit.validity() + private var validated: Boolean = false - override fun visitPackage(package_: NewSubscriptionPackagePrice) = - package_.validity() + fun validate(): GroupedWithMinMaxThresholds = apply { + if (validated) { + return@apply + } - override fun visitMatrix(matrix: NewSubscriptionMatrixPrice) = - matrix.validity() + cadence().validate() + groupedWithMinMaxThresholdsConfig().validate() + itemId() + _modelType().let { + if (it != JsonValue.from("grouped_with_min_max_thresholds")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + metadata()?.validate() + referenceId() + validated = true + } - override fun visitTiered(tiered: NewSubscriptionTieredPrice) = - tiered.validity() + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - override fun visitTieredBps(tieredBps: NewSubscriptionTieredBpsPrice) = - tieredBps.validity() + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (groupedWithMinMaxThresholdsConfig.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + modelType.let { + if (it == JsonValue.from("grouped_with_min_max_thresholds")) 1 else 0 + } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } - override fun visitBps(bps: NewSubscriptionBpsPrice) = bps.validity() + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } - override fun visitBulkBps(bulkBps: NewSubscriptionBulkBpsPrice) = - bulkBps.validity() + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } - override fun visitBulk(bulk: NewSubscriptionBulkPrice) = bulk.validity() + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } - override fun visitThresholdTotalAmount( - thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice - ) = thresholdTotalAmount.validity() + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - override fun visitTieredPackage( - tieredPackage: NewSubscriptionTieredPackagePrice - ) = tieredPackage.validity() + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - override fun visitTieredWithMinimum( - tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice - ) = tieredWithMinimum.validity() + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - override fun visitUnitWithPercent( - unitWithPercent: NewSubscriptionUnitWithPercentPrice - ) = unitWithPercent.validity() + return other is Cadence && value == other.value + } - override fun visitPackageWithAllocation( - packageWithAllocation: NewSubscriptionPackageWithAllocationPrice - ) = packageWithAllocation.validity() + override fun hashCode() = value.hashCode() - override fun visitTieredWithProration( - tieredWithProration: NewSubscriptionTierWithProrationPrice - ) = tieredWithProration.validity() + override fun toString() = value.toString() + } - override fun visitUnitWithProration( - unitWithProration: NewSubscriptionUnitWithProrationPrice - ) = unitWithProration.validity() + class GroupedWithMinMaxThresholdsConfig + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { - override fun visitGroupedAllocation( - groupedAllocation: NewSubscriptionGroupedAllocationPrice - ) = groupedAllocation.validity() + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties - override fun visitGroupedWithProratedMinimum( - groupedWithProratedMinimum: - NewSubscriptionGroupedWithProratedMinimumPrice - ) = groupedWithProratedMinimum.validity() + fun toBuilder() = Builder().from(this) - override fun visitBulkWithProration( - bulkWithProration: NewSubscriptionBulkWithProrationPrice - ) = bulkWithProration.validity() + companion object { - override fun visitScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: - NewSubscriptionScalableMatrixWithUnitPricingPrice - ) = scalableMatrixWithUnitPricing.validity() + /** + * Returns a mutable builder for constructing an instance of + * [GroupedWithMinMaxThresholdsConfig]. + */ + fun builder() = Builder() + } + + /** A builder for [GroupedWithMinMaxThresholdsConfig]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from( + groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + ) = apply { + additionalProperties = + groupedWithMinMaxThresholdsConfig.additionalProperties + .toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - override fun visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: - NewSubscriptionScalableMatrixWithTieredPricingPrice - ) = scalableMatrixWithTieredPricing.validity() + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - override fun visitCumulativeGroupedBulk( - cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice - ) = cumulativeGroupedBulk.validity() + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - override fun visitMaxGroupTieredPackage( - maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice - ) = maxGroupTieredPackage.validity() + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - override fun visitGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice - ) = groupedWithMeteredMinimum.validity() + /** + * Returns an immutable instance of [GroupedWithMinMaxThresholdsConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): GroupedWithMinMaxThresholdsConfig = + GroupedWithMinMaxThresholdsConfig(additionalProperties.toImmutable()) + } - override fun visitMatrixWithDisplayName( - matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice - ) = matrixWithDisplayName.validity() + private var validated: Boolean = false - override fun visitGroupedTieredPackage( - groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice - ) = groupedTieredPackage.validity() + fun validate(): GroupedWithMinMaxThresholdsConfig = apply { + if (validated) { + return@apply + } - override fun visitMatrixWithAllocation( - matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice - ) = matrixWithAllocation.validity() + validated = true + } - override fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice - ) = tieredPackageWithMinimum.validity() + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - override fun visitGroupedTiered( - groupedTiered: NewSubscriptionGroupedTieredPrice - ) = groupedTiered.validity() + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } - override fun unknown(json: JsonValue?) = 0 + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedWithMinMaxThresholdsConfig && + additionalProperties == other.additionalProperties } - ) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedWithMinMaxThresholdsConfig{additionalProperties=$additionalProperties}" } - return other is Price && - unit == other.unit && - package_ == other.package_ && - matrix == other.matrix && - tiered == other.tiered && - tieredBps == other.tieredBps && - bps == other.bps && - bulkBps == other.bulkBps && - bulk == other.bulk && - thresholdTotalAmount == other.thresholdTotalAmount && - tieredPackage == other.tieredPackage && - tieredWithMinimum == other.tieredWithMinimum && - unitWithPercent == other.unitWithPercent && - packageWithAllocation == other.packageWithAllocation && - tieredWithProration == other.tieredWithProration && - unitWithProration == other.unitWithProration && - groupedAllocation == other.groupedAllocation && - groupedWithProratedMinimum == other.groupedWithProratedMinimum && - bulkWithProration == other.bulkWithProration && - scalableMatrixWithUnitPricing == other.scalableMatrixWithUnitPricing && - scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && - cumulativeGroupedBulk == other.cumulativeGroupedBulk && - maxGroupTieredPackage == other.maxGroupTieredPackage && - groupedWithMeteredMinimum == other.groupedWithMeteredMinimum && - matrixWithDisplayName == other.matrixWithDisplayName && - groupedTieredPackage == other.groupedTieredPackage && - matrixWithAllocation == other.matrixWithAllocation && - tieredPackageWithMinimum == other.tieredPackageWithMinimum && - groupedTiered == other.groupedTiered - } + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { - override fun hashCode(): Int = - Objects.hash( - unit, - package_, - matrix, - tiered, - tieredBps, - bps, - bulkBps, - bulk, - thresholdTotalAmount, - tieredPackage, - tieredWithMinimum, - unitWithPercent, - packageWithAllocation, - tieredWithProration, - unitWithProration, - groupedAllocation, - groupedWithProratedMinimum, - bulkWithProration, - scalableMatrixWithUnitPricing, - scalableMatrixWithTieredPricing, - cumulativeGroupedBulk, - maxGroupTieredPackage, - groupedWithMeteredMinimum, - matrixWithDisplayName, - groupedTieredPackage, - matrixWithAllocation, - tieredPackageWithMinimum, - groupedTiered, - ) + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties - override fun toString(): String = - when { - unit != null -> "Price{unit=$unit}" - package_ != null -> "Price{package_=$package_}" - matrix != null -> "Price{matrix=$matrix}" - tiered != null -> "Price{tiered=$tiered}" - tieredBps != null -> "Price{tieredBps=$tieredBps}" - bps != null -> "Price{bps=$bps}" - bulkBps != null -> "Price{bulkBps=$bulkBps}" - bulk != null -> "Price{bulk=$bulk}" - thresholdTotalAmount != null -> - "Price{thresholdTotalAmount=$thresholdTotalAmount}" - tieredPackage != null -> "Price{tieredPackage=$tieredPackage}" - tieredWithMinimum != null -> "Price{tieredWithMinimum=$tieredWithMinimum}" - unitWithPercent != null -> "Price{unitWithPercent=$unitWithPercent}" - packageWithAllocation != null -> - "Price{packageWithAllocation=$packageWithAllocation}" - tieredWithProration != null -> "Price{tieredWithProration=$tieredWithProration}" - unitWithProration != null -> "Price{unitWithProration=$unitWithProration}" - groupedAllocation != null -> "Price{groupedAllocation=$groupedAllocation}" - groupedWithProratedMinimum != null -> - "Price{groupedWithProratedMinimum=$groupedWithProratedMinimum}" - bulkWithProration != null -> "Price{bulkWithProration=$bulkWithProration}" - scalableMatrixWithUnitPricing != null -> - "Price{scalableMatrixWithUnitPricing=$scalableMatrixWithUnitPricing}" - scalableMatrixWithTieredPricing != null -> - "Price{scalableMatrixWithTieredPricing=$scalableMatrixWithTieredPricing}" - cumulativeGroupedBulk != null -> - "Price{cumulativeGroupedBulk=$cumulativeGroupedBulk}" - maxGroupTieredPackage != null -> - "Price{maxGroupTieredPackage=$maxGroupTieredPackage}" - groupedWithMeteredMinimum != null -> - "Price{groupedWithMeteredMinimum=$groupedWithMeteredMinimum}" - matrixWithDisplayName != null -> - "Price{matrixWithDisplayName=$matrixWithDisplayName}" - groupedTieredPackage != null -> - "Price{groupedTieredPackage=$groupedTieredPackage}" - matrixWithAllocation != null -> - "Price{matrixWithAllocation=$matrixWithAllocation}" - tieredPackageWithMinimum != null -> - "Price{tieredPackageWithMinimum=$tieredPackageWithMinimum}" - groupedTiered != null -> "Price{groupedTiered=$groupedTiered}" - _json != null -> "Price{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Price") - } + fun toBuilder() = Builder().from(this) - companion object { + companion object { - fun ofUnit(unit: NewSubscriptionUnitPrice) = Price(unit = unit) + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } - fun ofPackage(package_: NewSubscriptionPackagePrice) = Price(package_ = package_) + /** A builder for [Metadata]. */ + class Builder internal constructor() { - fun ofMatrix(matrix: NewSubscriptionMatrixPrice) = Price(matrix = matrix) + private var additionalProperties: MutableMap = + mutableMapOf() - fun ofTiered(tiered: NewSubscriptionTieredPrice) = Price(tiered = tiered) + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } - fun ofTieredBps(tieredBps: NewSubscriptionTieredBpsPrice) = - Price(tieredBps = tieredBps) + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun ofBps(bps: NewSubscriptionBpsPrice) = Price(bps = bps) + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun ofBulkBps(bulkBps: NewSubscriptionBulkBpsPrice) = Price(bulkBps = bulkBps) + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun ofBulk(bulk: NewSubscriptionBulkPrice) = Price(bulk = bulk) + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun ofThresholdTotalAmount( - thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice - ) = Price(thresholdTotalAmount = thresholdTotalAmount) + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - fun ofTieredPackage(tieredPackage: NewSubscriptionTieredPackagePrice) = - Price(tieredPackage = tieredPackage) + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } - fun ofTieredWithMinimum(tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice) = - Price(tieredWithMinimum = tieredWithMinimum) + private var validated: Boolean = false - fun ofUnitWithPercent(unitWithPercent: NewSubscriptionUnitWithPercentPrice) = - Price(unitWithPercent = unitWithPercent) + fun validate(): Metadata = apply { + if (validated) { + return@apply + } - fun ofPackageWithAllocation( - packageWithAllocation: NewSubscriptionPackageWithAllocationPrice - ) = Price(packageWithAllocation = packageWithAllocation) + validated = true + } - fun ofTieredWithProration( - tieredWithProration: NewSubscriptionTierWithProrationPrice - ) = Price(tieredWithProration = tieredWithProration) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - fun ofUnitWithProration(unitWithProration: NewSubscriptionUnitWithProrationPrice) = - Price(unitWithProration = unitWithProration) + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } - fun ofGroupedAllocation(groupedAllocation: NewSubscriptionGroupedAllocationPrice) = - Price(groupedAllocation = groupedAllocation) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun ofGroupedWithProratedMinimum( - groupedWithProratedMinimum: NewSubscriptionGroupedWithProratedMinimumPrice - ) = Price(groupedWithProratedMinimum = groupedWithProratedMinimum) + return other is Metadata && + additionalProperties == other.additionalProperties + } - fun ofBulkWithProration(bulkWithProration: NewSubscriptionBulkWithProrationPrice) = - Price(bulkWithProration = bulkWithProration) + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - fun ofScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: NewSubscriptionScalableMatrixWithUnitPricingPrice - ) = Price(scalableMatrixWithUnitPricing = scalableMatrixWithUnitPricing) + override fun hashCode(): Int = hashCode - fun ofScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: - NewSubscriptionScalableMatrixWithTieredPricingPrice - ) = Price(scalableMatrixWithTieredPricing = scalableMatrixWithTieredPricing) + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } - fun ofCumulativeGroupedBulk( - cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice - ) = Price(cumulativeGroupedBulk = cumulativeGroupedBulk) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun ofMaxGroupTieredPackage( - maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice - ) = Price(maxGroupTieredPackage = maxGroupTieredPackage) + return other is GroupedWithMinMaxThresholds && + cadence == other.cadence && + groupedWithMinMaxThresholdsConfig == + other.groupedWithMinMaxThresholdsConfig && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } - fun ofGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice - ) = Price(groupedWithMeteredMinimum = groupedWithMeteredMinimum) + private val hashCode: Int by lazy { + Objects.hash( + cadence, + groupedWithMinMaxThresholdsConfig, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties, + ) + } - fun ofMatrixWithDisplayName( - matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice - ) = Price(matrixWithDisplayName = matrixWithDisplayName) + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedWithMinMaxThresholds{cadence=$cadence, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class Minimum + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val minimumConfig: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("minimum_config") + @ExcludeMissing + minimumConfig: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + minimumConfig, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + mutableMapOf(), + ) - fun ofGroupedTieredPackage( - groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice - ) = Price(groupedTieredPackage = groupedTieredPackage) + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") - fun ofMatrixWithAllocation( - matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice - ) = Price(matrixWithAllocation = matrixWithAllocation) + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") - fun ofTieredPackageWithMinimum( - tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice - ) = Price(tieredPackageWithMinimum = tieredPackageWithMinimum) + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun minimumConfig(): MinimumConfig = minimumConfig.getRequired("minimum_config") - fun ofGroupedTiered(groupedTiered: NewSubscriptionGroupedTieredPrice) = - Price(groupedTiered = groupedTiered) - } + /** + * Expected to always return the following: + * ```kotlin + * JsonValue.from("minimum") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType - /** - * An interface that defines how to map each variant of [Price] to a value of type [T]. - */ - interface Visitor { + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") - fun visitUnit(unit: NewSubscriptionUnitPrice): T + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = billableMetricId.getNullable("billable_metric_id") - fun visitPackage(package_: NewSubscriptionPackagePrice): T + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") - fun visitMatrix(matrix: NewSubscriptionMatrixPrice): T + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") - fun visitTiered(tiered: NewSubscriptionTieredPrice): T + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") - fun visitTieredBps(tieredBps: NewSubscriptionTieredBpsPrice): T + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") - fun visitBps(bps: NewSubscriptionBpsPrice): T + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") - fun visitBulkBps(bulkBps: NewSubscriptionBulkBpsPrice): T + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") - fun visitBulk(bulk: NewSubscriptionBulkPrice): T + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") - fun visitThresholdTotalAmount( - thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice - ): T + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") - fun visitTieredPackage(tieredPackage: NewSubscriptionTieredPackagePrice): T + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + invoiceGroupingKey.getNullable("invoice_grouping_key") - fun visitTieredWithMinimum( - tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice - ): T + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - fun visitUnitWithPercent(unitWithPercent: NewSubscriptionUnitWithPercentPrice): T + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") - fun visitPackageWithAllocation( - packageWithAllocation: NewSubscriptionPackageWithAllocationPrice - ): T + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") - fun visitTieredWithProration( - tieredWithProration: NewSubscriptionTierWithProrationPrice - ): T + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence - fun visitUnitWithProration( - unitWithProration: NewSubscriptionUnitWithProrationPrice - ): T + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - fun visitGroupedAllocation( - groupedAllocation: NewSubscriptionGroupedAllocationPrice - ): T + /** + * Returns the raw JSON value of [minimumConfig]. + * + * Unlike [minimumConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("minimum_config") + @ExcludeMissing + fun _minimumConfig(): JsonField = minimumConfig - fun visitGroupedWithProratedMinimum( - groupedWithProratedMinimum: NewSubscriptionGroupedWithProratedMinimumPrice - ): T + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - fun visitBulkWithProration( - bulkWithProration: NewSubscriptionBulkWithProrationPrice - ): T + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId - fun visitScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: NewSubscriptionScalableMatrixWithUnitPricingPrice - ): T + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance - fun visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: - NewSubscriptionScalableMatrixWithTieredPricingPrice - ): T + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration - fun visitCumulativeGroupedBulk( - cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice - ): T + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate - fun visitMaxGroupTieredPackage( - maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice - ): T + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig - fun visitGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice - ): T + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency - fun visitMatrixWithDisplayName( - matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice - ): T + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration - fun visitGroupedTieredPackage( - groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice - ): T + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId - fun visitMatrixWithAllocation( - matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice - ): T + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice - ): T + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - fun visitGroupedTiered(groupedTiered: NewSubscriptionGroupedTieredPrice): T + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration /** - * Maps an unknown variant of [Price] to a value of type [T]. + * Returns the raw JSON value of [metadata]. * - * An instance of [Price] can contain an unknown variant if it was deserialized from - * data that doesn't match any known variant. For example, if the SDK is on an older - * version than the API, then the API may respond with new variants that the SDK is - * unaware of. + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. * - * @throws OrbInvalidDataException in the default implementation. + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown Price: $json") + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) } - } - internal class Deserializer : BaseDeserializer(Price::class) { + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Minimum]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .minimumConfig() + * .name() + * ``` + */ + fun builder() = Builder() + } - override fun ObjectCodec.deserialize(node: JsonNode): Price { - val json = JsonValue.fromJsonNode(node) - val modelType = json.asObject()?.get("model_type")?.asString() + /** A builder for [Minimum]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var minimumConfig: JsonField? = null + private var modelType: JsonValue = JsonValue.from("minimum") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(minimum: Minimum) = apply { + cadence = minimum.cadence + itemId = minimum.itemId + minimumConfig = minimum.minimumConfig + modelType = minimum.modelType + name = minimum.name + billableMetricId = minimum.billableMetricId + billedInAdvance = minimum.billedInAdvance + billingCycleConfiguration = minimum.billingCycleConfiguration + conversionRate = minimum.conversionRate + conversionRateConfig = minimum.conversionRateConfig + currency = minimum.currency + dimensionalPriceConfiguration = minimum.dimensionalPriceConfiguration + externalPriceId = minimum.externalPriceId + fixedPriceQuantity = minimum.fixedPriceQuantity + invoiceGroupingKey = minimum.invoiceGroupingKey + invoicingCycleConfiguration = minimum.invoicingCycleConfiguration + metadata = minimum.metadata + referenceId = minimum.referenceId + additionalProperties = minimum.additionalProperties.toMutableMap() + } - when (modelType) { - "unit" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(unit = it, _json = json) } ?: Price(_json = json) - } - "package" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(package_ = it, _json = json) } ?: Price(_json = json) - } - "matrix" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(matrix = it, _json = json) } ?: Price(_json = json) - } - "tiered" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(tiered = it, _json = json) } ?: Price(_json = json) - } - "tiered_bps" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(tieredBps = it, _json = json) } ?: Price(_json = json) - } - "bps" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(bps = it, _json = json) } ?: Price(_json = json) - } - "bulk_bps" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(bulkBps = it, _json = json) } ?: Price(_json = json) - } - "bulk" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(bulk = it, _json = json) } ?: Price(_json = json) - } - "threshold_total_amount" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(thresholdTotalAmount = it, _json = json) } - ?: Price(_json = json) - } - "tiered_package" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(tieredPackage = it, _json = json) } - ?: Price(_json = json) - } - "tiered_with_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(tieredWithMinimum = it, _json = json) } - ?: Price(_json = json) - } - "unit_with_percent" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(unitWithPercent = it, _json = json) } - ?: Price(_json = json) - } - "package_with_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(packageWithAllocation = it, _json = json) } - ?: Price(_json = json) - } - "tiered_with_proration" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(tieredWithProration = it, _json = json) } - ?: Price(_json = json) - } - "unit_with_proration" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(unitWithProration = it, _json = json) } - ?: Price(_json = json) - } - "grouped_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun minimumConfig(minimumConfig: MinimumConfig) = + minimumConfig(JsonField.of(minimumConfig)) + + /** + * Sets [Builder.minimumConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumConfig] with a well-typed + * [MinimumConfig] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun minimumConfig(minimumConfig: JsonField) = apply { + this.minimumConfig = minimumConfig + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("minimum") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT ) - ?.let { Price(groupedAllocation = it, _json = json) } - ?: Price(_json = json) - } - "grouped_with_prorated_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED ) - ?.let { Price(groupedWithProratedMinimum = it, _json = json) } - ?: Price(_json = json) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) } - "bulk_with_proration" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(bulkWithProration = it, _json = json) } - ?: Price(_json = json) + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Minimum]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .minimumConfig() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Minimum = + Minimum( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("minimumConfig", minimumConfig), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Minimum = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + minimumConfig().validate() + _modelType().let { + if (it != JsonValue.from("minimum")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") } - "scalable_matrix_with_unit_pricing" -> { - return tryDeserialize( - node, - jacksonTypeRef< - NewSubscriptionScalableMatrixWithUnitPricingPrice - >(), - ) - ?.let { Price(scalableMatrixWithUnitPricing = it, _json = json) } - ?: Price(_json = json) + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + (minimumConfig.asKnown()?.validity() ?: 0) + + modelType.let { if (it == JsonValue.from("minimum")) 1 else 0 } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false } - "scalable_matrix_with_tiered_pricing" -> { - return tryDeserialize( - node, - jacksonTypeRef< - NewSubscriptionScalableMatrixWithTieredPricingPrice - >(), - ) - ?.let { Price(scalableMatrixWithTieredPricing = it, _json = json) } - ?: Price(_json = json) + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - "cumulative_grouped_bulk" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(cumulativeGroupedBulk = it, _json = json) } - ?: Price(_json = json) + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class MinimumConfig + private constructor( + private val minimumAmount: JsonField, + private val prorated: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("minimum_amount") + @ExcludeMissing + minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("prorated") + @ExcludeMissing + prorated: JsonField = JsonMissing.of(), + ) : this(minimumAmount, prorated, mutableMapOf()) + + /** + * The minimum amount to apply + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") + + /** + * By default, subtotals from minimum composite prices are prorated based on the + * service period. Set to false to disable proration. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun prorated(): Boolean? = prorated.getNullable("prorated") + + /** + * Returns the raw JSON value of [minimumAmount]. + * + * Unlike [minimumAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount + + /** + * Returns the raw JSON value of [prorated]. + * + * Unlike [prorated], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("prorated") + @ExcludeMissing + fun _prorated(): JsonField = prorated + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [MinimumConfig]. + * + * The following fields are required: + * ```kotlin + * .minimumAmount() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [MinimumConfig]. */ + class Builder internal constructor() { + + private var minimumAmount: JsonField? = null + private var prorated: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(minimumConfig: MinimumConfig) = apply { + minimumAmount = minimumConfig.minimumAmount + prorated = minimumConfig.prorated + additionalProperties = minimumConfig.additionalProperties.toMutableMap() + } + + /** The minimum amount to apply */ + fun minimumAmount(minimumAmount: String) = + minimumAmount(JsonField.of(minimumAmount)) + + /** + * Sets [Builder.minimumAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumAmount] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount + } + + /** + * By default, subtotals from minimum composite prices are prorated based on + * the service period. Set to false to disable proration. + */ + fun prorated(prorated: Boolean?) = prorated(JsonField.ofNullable(prorated)) + + /** + * Alias for [Builder.prorated]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun prorated(prorated: Boolean) = prorated(prorated as Boolean?) + + /** + * Sets [Builder.prorated] to an arbitrary JSON value. + * + * You should usually call [Builder.prorated] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun prorated(prorated: JsonField) = apply { + this.prorated = prorated + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [MinimumConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .minimumAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MinimumConfig = + MinimumConfig( + checkRequired("minimumAmount", minimumAmount), + prorated, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MinimumConfig = apply { + if (validated) { + return@apply } - "max_group_tiered_package" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(maxGroupTieredPackage = it, _json = json) } - ?: Price(_json = json) + + minimumAmount() + prorated() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (minimumAmount.asKnown() == null) 0 else 1) + + (if (prorated.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MinimumConfig && + minimumAmount == other.minimumAmount && + prorated == other.prorated && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(minimumAmount, prorated, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MinimumConfig{minimumAmount=$minimumAmount, prorated=$prorated, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() } - "grouped_with_metered_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedWithMeteredMinimum = it, _json = json) } - ?: Price(_json = json) + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) } - "matrix_with_display_name" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(matrixWithDisplayName = it, _json = json) } - ?: Price(_json = json) + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) } - "grouped_tiered_package" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedTieredPackage = it, _json = json) } - ?: Price(_json = json) + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) } - "matrix_with_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(matrixWithAllocation = it, _json = json) } - ?: Price(_json = json) + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply } - "tiered_package_with_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(tieredPackageWithMinimum = it, _json = json) } - ?: Price(_json = json) + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false } - "grouped_tiered" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedTiered = it, _json = json) } - ?: Price(_json = json) + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } + + return other is Metadata && + additionalProperties == other.additionalProperties } - return Price(_json = json) - } - } + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - internal class Serializer : BaseSerializer(Price::class) { + override fun hashCode(): Int = hashCode - override fun serialize( - value: Price, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unit != null -> generator.writeObject(value.unit) - value.package_ != null -> generator.writeObject(value.package_) - value.matrix != null -> generator.writeObject(value.matrix) - value.tiered != null -> generator.writeObject(value.tiered) - value.tieredBps != null -> generator.writeObject(value.tieredBps) - value.bps != null -> generator.writeObject(value.bps) - value.bulkBps != null -> generator.writeObject(value.bulkBps) - value.bulk != null -> generator.writeObject(value.bulk) - value.thresholdTotalAmount != null -> - generator.writeObject(value.thresholdTotalAmount) - value.tieredPackage != null -> generator.writeObject(value.tieredPackage) - value.tieredWithMinimum != null -> - generator.writeObject(value.tieredWithMinimum) - value.unitWithPercent != null -> - generator.writeObject(value.unitWithPercent) - value.packageWithAllocation != null -> - generator.writeObject(value.packageWithAllocation) - value.tieredWithProration != null -> - generator.writeObject(value.tieredWithProration) - value.unitWithProration != null -> - generator.writeObject(value.unitWithProration) - value.groupedAllocation != null -> - generator.writeObject(value.groupedAllocation) - value.groupedWithProratedMinimum != null -> - generator.writeObject(value.groupedWithProratedMinimum) - value.bulkWithProration != null -> - generator.writeObject(value.bulkWithProration) - value.scalableMatrixWithUnitPricing != null -> - generator.writeObject(value.scalableMatrixWithUnitPricing) - value.scalableMatrixWithTieredPricing != null -> - generator.writeObject(value.scalableMatrixWithTieredPricing) - value.cumulativeGroupedBulk != null -> - generator.writeObject(value.cumulativeGroupedBulk) - value.maxGroupTieredPackage != null -> - generator.writeObject(value.maxGroupTieredPackage) - value.groupedWithMeteredMinimum != null -> - generator.writeObject(value.groupedWithMeteredMinimum) - value.matrixWithDisplayName != null -> - generator.writeObject(value.matrixWithDisplayName) - value.groupedTieredPackage != null -> - generator.writeObject(value.groupedTieredPackage) - value.matrixWithAllocation != null -> - generator.writeObject(value.matrixWithAllocation) - value.tieredPackageWithMinimum != null -> - generator.writeObject(value.tieredPackageWithMinimum) - value.groupedTiered != null -> generator.writeObject(value.groupedTiered) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Price") + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } + + return other is Minimum && + cadence == other.cadence && + itemId == other.itemId && + minimumConfig == other.minimumConfig && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + minimumConfig, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Minimum{cadence=$cadence, itemId=$itemId, minimumConfig=$minimumConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } } diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsParams.kt index 2337bc5bd..311410378 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsParams.kt @@ -15,6 +15,7 @@ import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import com.withorb.api.core.BaseDeserializer import com.withorb.api.core.BaseSerializer +import com.withorb.api.core.Enum import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing @@ -1508,15 +1509,6 @@ private constructor( /** Alias for calling [price] with `Price.ofTiered(tiered)`. */ fun price(tiered: NewFloatingTieredPrice) = price(Price.ofTiered(tiered)) - /** Alias for calling [price] with `Price.ofTieredBps(tieredBps)`. */ - fun price(tieredBps: NewFloatingTieredBpsPrice) = price(Price.ofTieredBps(tieredBps)) - - /** Alias for calling [price] with `Price.ofBps(bps)`. */ - fun price(bps: NewFloatingBpsPrice) = price(Price.ofBps(bps)) - - /** Alias for calling [price] with `Price.ofBulkBps(bulkBps)`. */ - fun price(bulkBps: NewFloatingBulkBpsPrice) = price(Price.ofBulkBps(bulkBps)) - /** Alias for calling [price] with `Price.ofBulk(bulk)`. */ fun price(bulk: NewFloatingBulkPrice) = price(Price.ofBulk(bulk)) @@ -1631,6 +1623,16 @@ private constructor( fun price(cumulativeGroupedBulk: NewFloatingCumulativeGroupedBulkPrice) = price(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) + /** + * Alias for calling [price] with + * `Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)`. + */ + fun price(groupedWithMinMaxThresholds: Price.GroupedWithMinMaxThresholds) = + price(Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)) + + /** Alias for calling [price] with `Price.ofMinimum(minimum)`. */ + fun price(minimum: Price.Minimum) = price(Price.ofMinimum(minimum)) + /** The id of the price to add to the subscription. */ fun priceId(priceId: String?) = priceId(JsonField.ofNullable(priceId)) @@ -3219,9 +3221,6 @@ private constructor( private val matrix: NewFloatingMatrixPrice? = null, private val matrixWithAllocation: NewFloatingMatrixWithAllocationPrice? = null, private val tiered: NewFloatingTieredPrice? = null, - private val tieredBps: NewFloatingTieredBpsPrice? = null, - private val bps: NewFloatingBpsPrice? = null, - private val bulkBps: NewFloatingBulkBpsPrice? = null, private val bulk: NewFloatingBulkPrice? = null, private val thresholdTotalAmount: NewFloatingThresholdTotalAmountPrice? = null, private val tieredPackage: NewFloatingTieredPackagePrice? = null, @@ -3248,6 +3247,8 @@ private constructor( NewFloatingScalableMatrixWithTieredPricingPrice? = null, private val cumulativeGroupedBulk: NewFloatingCumulativeGroupedBulkPrice? = null, + private val groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds? = null, + private val minimum: Minimum? = null, private val _json: JsonValue? = null, ) { @@ -3261,12 +3262,6 @@ private constructor( fun tiered(): NewFloatingTieredPrice? = tiered - fun tieredBps(): NewFloatingTieredBpsPrice? = tieredBps - - fun bps(): NewFloatingBpsPrice? = bps - - fun bulkBps(): NewFloatingBulkBpsPrice? = bulkBps - fun bulk(): NewFloatingBulkPrice? = bulk fun thresholdTotalAmount(): NewFloatingThresholdTotalAmountPrice? = thresholdTotalAmount @@ -3316,6 +3311,11 @@ private constructor( fun cumulativeGroupedBulk(): NewFloatingCumulativeGroupedBulkPrice? = cumulativeGroupedBulk + fun groupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds? = + groupedWithMinMaxThresholds + + fun minimum(): Minimum? = minimum + fun isUnit(): Boolean = unit != null fun isPackage(): Boolean = package_ != null @@ -3326,12 +3326,6 @@ private constructor( fun isTiered(): Boolean = tiered != null - fun isTieredBps(): Boolean = tieredBps != null - - fun isBps(): Boolean = bps != null - - fun isBulkBps(): Boolean = bulkBps != null - fun isBulk(): Boolean = bulk != null fun isThresholdTotalAmount(): Boolean = thresholdTotalAmount != null @@ -3373,6 +3367,10 @@ private constructor( fun isCumulativeGroupedBulk(): Boolean = cumulativeGroupedBulk != null + fun isGroupedWithMinMaxThresholds(): Boolean = groupedWithMinMaxThresholds != null + + fun isMinimum(): Boolean = minimum != null + fun asUnit(): NewFloatingUnitPrice = unit.getOrThrow("unit") fun asPackage(): NewFloatingPackagePrice = package_.getOrThrow("package_") @@ -3384,12 +3382,6 @@ private constructor( fun asTiered(): NewFloatingTieredPrice = tiered.getOrThrow("tiered") - fun asTieredBps(): NewFloatingTieredBpsPrice = tieredBps.getOrThrow("tieredBps") - - fun asBps(): NewFloatingBpsPrice = bps.getOrThrow("bps") - - fun asBulkBps(): NewFloatingBulkBpsPrice = bulkBps.getOrThrow("bulkBps") - fun asBulk(): NewFloatingBulkPrice = bulk.getOrThrow("bulk") fun asThresholdTotalAmount(): NewFloatingThresholdTotalAmountPrice = @@ -3450,6 +3442,11 @@ private constructor( fun asCumulativeGroupedBulk(): NewFloatingCumulativeGroupedBulkPrice = cumulativeGroupedBulk.getOrThrow("cumulativeGroupedBulk") + fun asGroupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds = + groupedWithMinMaxThresholds.getOrThrow("groupedWithMinMaxThresholds") + + fun asMinimum(): Minimum = minimum.getOrThrow("minimum") + fun _json(): JsonValue? = _json fun accept(visitor: Visitor): T = @@ -3460,9 +3457,6 @@ private constructor( matrixWithAllocation != null -> visitor.visitMatrixWithAllocation(matrixWithAllocation) tiered != null -> visitor.visitTiered(tiered) - tieredBps != null -> visitor.visitTieredBps(tieredBps) - bps != null -> visitor.visitBps(bps) - bulkBps != null -> visitor.visitBulkBps(bulkBps) bulk != null -> visitor.visitBulk(bulk) thresholdTotalAmount != null -> visitor.visitThresholdTotalAmount(thresholdTotalAmount) @@ -3497,6 +3491,9 @@ private constructor( ) cumulativeGroupedBulk != null -> visitor.visitCumulativeGroupedBulk(cumulativeGroupedBulk) + groupedWithMinMaxThresholds != null -> + visitor.visitGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds) + minimum != null -> visitor.visitMinimum(minimum) else -> visitor.unknown(_json) } @@ -3531,18 +3528,6 @@ private constructor( tiered.validate() } - override fun visitTieredBps(tieredBps: NewFloatingTieredBpsPrice) { - tieredBps.validate() - } - - override fun visitBps(bps: NewFloatingBpsPrice) { - bps.validate() - } - - override fun visitBulkBps(bulkBps: NewFloatingBulkBpsPrice) { - bulkBps.validate() - } - override fun visitBulk(bulk: NewFloatingBulkPrice) { bulk.validate() } @@ -3662,6 +3647,16 @@ private constructor( ) { cumulativeGroupedBulk.validate() } + + override fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) { + groupedWithMinMaxThresholds.validate() + } + + override fun visitMinimum(minimum: Minimum) { + minimum.validate() + } } ) validated = true @@ -3697,14 +3692,6 @@ private constructor( override fun visitTiered(tiered: NewFloatingTieredPrice) = tiered.validity() - override fun visitTieredBps(tieredBps: NewFloatingTieredBpsPrice) = - tieredBps.validity() - - override fun visitBps(bps: NewFloatingBpsPrice) = bps.validity() - - override fun visitBulkBps(bulkBps: NewFloatingBulkBpsPrice) = - bulkBps.validity() - override fun visitBulk(bulk: NewFloatingBulkPrice) = bulk.validity() override fun visitThresholdTotalAmount( @@ -3785,6 +3772,12 @@ private constructor( cumulativeGroupedBulk: NewFloatingCumulativeGroupedBulkPrice ) = cumulativeGroupedBulk.validity() + override fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) = groupedWithMinMaxThresholds.validity() + + override fun visitMinimum(minimum: Minimum) = minimum.validity() + override fun unknown(json: JsonValue?) = 0 } ) @@ -3800,9 +3793,6 @@ private constructor( matrix == other.matrix && matrixWithAllocation == other.matrixWithAllocation && tiered == other.tiered && - tieredBps == other.tieredBps && - bps == other.bps && - bulkBps == other.bulkBps && bulk == other.bulk && thresholdTotalAmount == other.thresholdTotalAmount && tieredPackage == other.tieredPackage && @@ -3822,7 +3812,9 @@ private constructor( groupedTieredPackage == other.groupedTieredPackage && scalableMatrixWithUnitPricing == other.scalableMatrixWithUnitPricing && scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && - cumulativeGroupedBulk == other.cumulativeGroupedBulk + cumulativeGroupedBulk == other.cumulativeGroupedBulk && + groupedWithMinMaxThresholds == other.groupedWithMinMaxThresholds && + minimum == other.minimum } override fun hashCode(): Int = @@ -3832,9 +3824,6 @@ private constructor( matrix, matrixWithAllocation, tiered, - tieredBps, - bps, - bulkBps, bulk, thresholdTotalAmount, tieredPackage, @@ -3855,6 +3844,8 @@ private constructor( scalableMatrixWithUnitPricing, scalableMatrixWithTieredPricing, cumulativeGroupedBulk, + groupedWithMinMaxThresholds, + minimum, ) override fun toString(): String = @@ -3865,9 +3856,6 @@ private constructor( matrixWithAllocation != null -> "Price{matrixWithAllocation=$matrixWithAllocation}" tiered != null -> "Price{tiered=$tiered}" - tieredBps != null -> "Price{tieredBps=$tieredBps}" - bps != null -> "Price{bps=$bps}" - bulkBps != null -> "Price{bulkBps=$bulkBps}" bulk != null -> "Price{bulk=$bulk}" thresholdTotalAmount != null -> "Price{thresholdTotalAmount=$thresholdTotalAmount}" @@ -3899,6 +3887,9 @@ private constructor( "Price{scalableMatrixWithTieredPricing=$scalableMatrixWithTieredPricing}" cumulativeGroupedBulk != null -> "Price{cumulativeGroupedBulk=$cumulativeGroupedBulk}" + groupedWithMinMaxThresholds != null -> + "Price{groupedWithMinMaxThresholds=$groupedWithMinMaxThresholds}" + minimum != null -> "Price{minimum=$minimum}" _json != null -> "Price{_unknown=$_json}" else -> throw IllegalStateException("Invalid Price") } @@ -3917,12 +3908,6 @@ private constructor( fun ofTiered(tiered: NewFloatingTieredPrice) = Price(tiered = tiered) - fun ofTieredBps(tieredBps: NewFloatingTieredBpsPrice) = Price(tieredBps = tieredBps) - - fun ofBps(bps: NewFloatingBpsPrice) = Price(bps = bps) - - fun ofBulkBps(bulkBps: NewFloatingBulkBpsPrice) = Price(bulkBps = bulkBps) - fun ofBulk(bulk: NewFloatingBulkPrice) = Price(bulk = bulk) fun ofThresholdTotalAmount( @@ -3993,6 +3978,12 @@ private constructor( fun ofCumulativeGroupedBulk( cumulativeGroupedBulk: NewFloatingCumulativeGroupedBulkPrice ) = Price(cumulativeGroupedBulk = cumulativeGroupedBulk) + + fun ofGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) = Price(groupedWithMinMaxThresholds = groupedWithMinMaxThresholds) + + fun ofMinimum(minimum: Minimum) = Price(minimum = minimum) } /** @@ -4012,12 +4003,6 @@ private constructor( fun visitTiered(tiered: NewFloatingTieredPrice): T - fun visitTieredBps(tieredBps: NewFloatingTieredBpsPrice): T - - fun visitBps(bps: NewFloatingBpsPrice): T - - fun visitBulkBps(bulkBps: NewFloatingBulkBpsPrice): T - fun visitBulk(bulk: NewFloatingBulkPrice): T fun visitThresholdTotalAmount( @@ -4082,6 +4067,12 @@ private constructor( cumulativeGroupedBulk: NewFloatingCumulativeGroupedBulkPrice ): T + fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ): T + + fun visitMinimum(minimum: Minimum): T + /** * Maps an unknown variant of [Price] to a value of type [T]. * @@ -4128,18 +4119,6 @@ private constructor( return tryDeserialize(node, jacksonTypeRef()) ?.let { Price(tiered = it, _json = json) } ?: Price(_json = json) } - "tiered_bps" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(tieredBps = it, _json = json) } ?: Price(_json = json) - } - "bps" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(bps = it, _json = json) } ?: Price(_json = json) - } - "bulk_bps" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(bulkBps = it, _json = json) } ?: Price(_json = json) - } "bulk" -> { return tryDeserialize(node, jacksonTypeRef()) ?.let { Price(bulk = it, _json = json) } ?: Price(_json = json) @@ -4298,6 +4277,19 @@ private constructor( ?.let { Price(cumulativeGroupedBulk = it, _json = json) } ?: Price(_json = json) } + "grouped_with_min_max_thresholds" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedWithMinMaxThresholds = it, _json = json) } + ?: Price(_json = json) + } + "minimum" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(minimum = it, _json = json) + } ?: Price(_json = json) + } } return Price(_json = json) @@ -4318,9 +4310,6 @@ private constructor( value.matrixWithAllocation != null -> generator.writeObject(value.matrixWithAllocation) value.tiered != null -> generator.writeObject(value.tiered) - value.tieredBps != null -> generator.writeObject(value.tieredBps) - value.bps != null -> generator.writeObject(value.bps) - value.bulkBps != null -> generator.writeObject(value.bulkBps) value.bulk != null -> generator.writeObject(value.bulk) value.thresholdTotalAmount != null -> generator.writeObject(value.thresholdTotalAmount) @@ -4358,140 +4347,3112 @@ private constructor( generator.writeObject(value.scalableMatrixWithTieredPricing) value.cumulativeGroupedBulk != null -> generator.writeObject(value.cumulativeGroupedBulk) + value.groupedWithMinMaxThresholds != null -> + generator.writeObject(value.groupedWithMinMaxThresholds) + value.minimum != null -> generator.writeObject(value.minimum) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid Price") } } } - } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + class GroupedWithMinMaxThresholds + private constructor( + private val cadence: JsonField, + private val currency: JsonField, + private val groupedWithMinMaxThresholdsConfig: + JsonField, + private val itemId: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val metadata: JsonField, + private val additionalProperties: MutableMap, + ) { - return other is Add && - startDate == other.startDate && - allocationPrice == other.allocationPrice && - discounts == other.discounts && - endDate == other.endDate && - externalPriceId == other.externalPriceId && - filter == other.filter && - fixedFeeQuantityTransitions == other.fixedFeeQuantityTransitions && - maximumAmount == other.maximumAmount && - minimumAmount == other.minimumAmount && - price == other.price && - priceId == other.priceId && - usageCustomerIds == other.usageCustomerIds && - additionalProperties == other.additionalProperties - } + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("grouped_with_min_max_thresholds_config") + @ExcludeMissing + groupedWithMinMaxThresholdsConfig: + JsonField = + JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + ) : this( + cadence, + currency, + groupedWithMinMaxThresholdsConfig, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + mutableMapOf(), + ) - private val hashCode: Int by lazy { - Objects.hash( - startDate, - allocationPrice, - discounts, - endDate, - externalPriceId, - filter, - fixedFeeQuantityTransitions, - maximumAmount, - minimumAmount, - price, - priceId, - usageCustomerIds, - additionalProperties, - ) - } + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") - override fun hashCode(): Int = hashCode + /** + * An ISO 4217 currency string for which this price is billed in. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun currency(): String = currency.getRequired("currency") - override fun toString() = - "Add{startDate=$startDate, allocationPrice=$allocationPrice, discounts=$discounts, endDate=$endDate, externalPriceId=$externalPriceId, filter=$filter, fixedFeeQuantityTransitions=$fixedFeeQuantityTransitions, maximumAmount=$maximumAmount, minimumAmount=$minimumAmount, price=$price, priceId=$priceId, usageCustomerIds=$usageCustomerIds, additionalProperties=$additionalProperties}" - } + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupedWithMinMaxThresholdsConfig(): GroupedWithMinMaxThresholdsConfig = + groupedWithMinMaxThresholdsConfig.getRequired( + "grouped_with_min_max_thresholds_config" + ) - class AddAdjustment - private constructor( - private val adjustment: JsonField, - private val startDate: JsonField, - private val endDate: JsonField, - private val additionalProperties: MutableMap, - ) { + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") - @JsonCreator - private constructor( - @JsonProperty("adjustment") - @ExcludeMissing - adjustment: JsonField = JsonMissing.of(), - @JsonProperty("start_date") - @ExcludeMissing - startDate: JsonField = JsonMissing.of(), - @JsonProperty("end_date") @ExcludeMissing endDate: JsonField = JsonMissing.of(), - ) : this(adjustment, startDate, endDate, mutableMapOf()) + /** + * Expected to always return the following: + * ```kotlin + * JsonValue.from("grouped_with_min_max_thresholds") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType - /** - * The definition of a new adjustment to create and add to the subscription. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun adjustment(): Adjustment = adjustment.getRequired("adjustment") + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") - /** - * The start date of the adjustment interval. This is the date that the adjustment will - * start affecting prices on the subscription. The adjustment will apply to invoice dates - * that overlap with this `start_date`. This `start_date` is treated as inclusive for - * in-advance prices, and exclusive for in-arrears prices. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun startDate(): StartDate = startDate.getRequired("start_date") + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = billableMetricId.getNullable("billable_metric_id") - /** - * The end date of the adjustment interval. This is the date that the adjustment will stop - * affecting prices on the subscription. The adjustment will apply to invoice dates that - * overlap with this `end_date`.This `end_date` is treated as exclusive for in-advance - * prices, and inclusive for in-arrears prices. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun endDate(): EndDate? = endDate.getNullable("end_date") + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") - /** - * Returns the raw JSON value of [adjustment]. - * - * Unlike [adjustment], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("adjustment") - @ExcludeMissing - fun _adjustment(): JsonField = adjustment + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") - /** - * Returns the raw JSON value of [startDate]. - * - * Unlike [startDate], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("start_date") - @ExcludeMissing - fun _startDate(): JsonField = startDate + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") - /** - * Returns the raw JSON value of [endDate]. - * - * Unlike [endDate], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("end_date") @ExcludeMissing fun _endDate(): JsonField = endDate + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + invoiceGroupingKey.getNullable("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [groupedWithMinMaxThresholdsConfig]. + * + * Unlike [groupedWithMinMaxThresholdsConfig], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("grouped_with_min_max_thresholds_config") + @ExcludeMissing + fun _groupedWithMinMaxThresholdsConfig(): + JsonField = groupedWithMinMaxThresholdsConfig + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [GroupedWithMinMaxThresholds]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .currency() + * .groupedWithMinMaxThresholdsConfig() + * .itemId() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [GroupedWithMinMaxThresholds]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var currency: JsonField? = null + private var groupedWithMinMaxThresholdsConfig: + JsonField? = + null + private var itemId: JsonField? = null + private var modelType: JsonValue = + JsonValue.from("grouped_with_min_max_thresholds") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds) = + apply { + cadence = groupedWithMinMaxThresholds.cadence + currency = groupedWithMinMaxThresholds.currency + groupedWithMinMaxThresholdsConfig = + groupedWithMinMaxThresholds.groupedWithMinMaxThresholdsConfig + itemId = groupedWithMinMaxThresholds.itemId + modelType = groupedWithMinMaxThresholds.modelType + name = groupedWithMinMaxThresholds.name + billableMetricId = groupedWithMinMaxThresholds.billableMetricId + billedInAdvance = groupedWithMinMaxThresholds.billedInAdvance + billingCycleConfiguration = + groupedWithMinMaxThresholds.billingCycleConfiguration + conversionRate = groupedWithMinMaxThresholds.conversionRate + conversionRateConfig = groupedWithMinMaxThresholds.conversionRateConfig + dimensionalPriceConfiguration = + groupedWithMinMaxThresholds.dimensionalPriceConfiguration + externalPriceId = groupedWithMinMaxThresholds.externalPriceId + fixedPriceQuantity = groupedWithMinMaxThresholds.fixedPriceQuantity + invoiceGroupingKey = groupedWithMinMaxThresholds.invoiceGroupingKey + invoicingCycleConfiguration = + groupedWithMinMaxThresholds.invoicingCycleConfiguration + metadata = groupedWithMinMaxThresholds.metadata + additionalProperties = + groupedWithMinMaxThresholds.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + fun groupedWithMinMaxThresholdsConfig( + groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + ) = + groupedWithMinMaxThresholdsConfig( + JsonField.of(groupedWithMinMaxThresholdsConfig) + ) + + /** + * Sets [Builder.groupedWithMinMaxThresholdsConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.groupedWithMinMaxThresholdsConfig] with a + * well-typed [GroupedWithMinMaxThresholdsConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun groupedWithMinMaxThresholdsConfig( + groupedWithMinMaxThresholdsConfig: + JsonField + ) = apply { + this.groupedWithMinMaxThresholdsConfig = groupedWithMinMaxThresholdsConfig + } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("grouped_with_min_max_thresholds") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [GroupedWithMinMaxThresholds]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .currency() + * .groupedWithMinMaxThresholdsConfig() + * .itemId() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedWithMinMaxThresholds = + GroupedWithMinMaxThresholds( + checkRequired("cadence", cadence), + checkRequired("currency", currency), + checkRequired( + "groupedWithMinMaxThresholdsConfig", + groupedWithMinMaxThresholdsConfig, + ), + checkRequired("itemId", itemId), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GroupedWithMinMaxThresholds = apply { + if (validated) { + return@apply + } + + cadence().validate() + currency() + groupedWithMinMaxThresholdsConfig().validate() + itemId() + _modelType().let { + if (it != JsonValue.from("grouped_with_min_max_thresholds")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + metadata()?.validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (groupedWithMinMaxThresholdsConfig.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + modelType.let { + if (it == JsonValue.from("grouped_with_min_max_thresholds")) 1 else 0 + } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (metadata.asKnown()?.validity() ?: 0) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class GroupedWithMinMaxThresholdsConfig + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [GroupedWithMinMaxThresholdsConfig]. + */ + fun builder() = Builder() + } + + /** A builder for [GroupedWithMinMaxThresholdsConfig]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from( + groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + ) = apply { + additionalProperties = + groupedWithMinMaxThresholdsConfig.additionalProperties + .toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [GroupedWithMinMaxThresholdsConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): GroupedWithMinMaxThresholdsConfig = + GroupedWithMinMaxThresholdsConfig(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): GroupedWithMinMaxThresholdsConfig = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedWithMinMaxThresholdsConfig && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedWithMinMaxThresholdsConfig{additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedWithMinMaxThresholds && + cadence == other.cadence && + currency == other.currency && + groupedWithMinMaxThresholdsConfig == + other.groupedWithMinMaxThresholdsConfig && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + currency, + groupedWithMinMaxThresholdsConfig, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedWithMinMaxThresholds{cadence=$cadence, currency=$currency, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + } + + class Minimum + private constructor( + private val cadence: JsonField, + private val currency: JsonField, + private val itemId: JsonField, + private val minimumConfig: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val metadata: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("minimum_config") + @ExcludeMissing + minimumConfig: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + ) : this( + cadence, + currency, + itemId, + minimumConfig, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * An ISO 4217 currency string for which this price is billed in. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun minimumConfig(): MinimumConfig = minimumConfig.getRequired("minimum_config") + + /** + * Expected to always return the following: + * ```kotlin + * JsonValue.from("minimum") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = billableMetricId.getNullable("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + invoiceGroupingKey.getNullable("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [minimumConfig]. + * + * Unlike [minimumConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("minimum_config") + @ExcludeMissing + fun _minimumConfig(): JsonField = minimumConfig + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Minimum]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .currency() + * .itemId() + * .minimumConfig() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Minimum]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var currency: JsonField? = null + private var itemId: JsonField? = null + private var minimumConfig: JsonField? = null + private var modelType: JsonValue = JsonValue.from("minimum") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(minimum: Minimum) = apply { + cadence = minimum.cadence + currency = minimum.currency + itemId = minimum.itemId + minimumConfig = minimum.minimumConfig + modelType = minimum.modelType + name = minimum.name + billableMetricId = minimum.billableMetricId + billedInAdvance = minimum.billedInAdvance + billingCycleConfiguration = minimum.billingCycleConfiguration + conversionRate = minimum.conversionRate + conversionRateConfig = minimum.conversionRateConfig + dimensionalPriceConfiguration = minimum.dimensionalPriceConfiguration + externalPriceId = minimum.externalPriceId + fixedPriceQuantity = minimum.fixedPriceQuantity + invoiceGroupingKey = minimum.invoiceGroupingKey + invoicingCycleConfiguration = minimum.invoicingCycleConfiguration + metadata = minimum.metadata + additionalProperties = minimum.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun minimumConfig(minimumConfig: MinimumConfig) = + minimumConfig(JsonField.of(minimumConfig)) + + /** + * Sets [Builder.minimumConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumConfig] with a well-typed + * [MinimumConfig] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun minimumConfig(minimumConfig: JsonField) = apply { + this.minimumConfig = minimumConfig + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("minimum") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Minimum]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .currency() + * .itemId() + * .minimumConfig() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Minimum = + Minimum( + checkRequired("cadence", cadence), + checkRequired("currency", currency), + checkRequired("itemId", itemId), + checkRequired("minimumConfig", minimumConfig), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Minimum = apply { + if (validated) { + return@apply + } + + cadence().validate() + currency() + itemId() + minimumConfig().validate() + _modelType().let { + if (it != JsonValue.from("minimum")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + metadata()?.validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (if (itemId.asKnown() == null) 0 else 1) + + (minimumConfig.asKnown()?.validity() ?: 0) + + modelType.let { if (it == JsonValue.from("minimum")) 1 else 0 } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (metadata.asKnown()?.validity() ?: 0) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class MinimumConfig + private constructor( + private val minimumAmount: JsonField, + private val prorated: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("minimum_amount") + @ExcludeMissing + minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("prorated") + @ExcludeMissing + prorated: JsonField = JsonMissing.of(), + ) : this(minimumAmount, prorated, mutableMapOf()) + + /** + * The minimum amount to apply + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") + + /** + * By default, subtotals from minimum composite prices are prorated based on the + * service period. Set to false to disable proration. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun prorated(): Boolean? = prorated.getNullable("prorated") + + /** + * Returns the raw JSON value of [minimumAmount]. + * + * Unlike [minimumAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount + + /** + * Returns the raw JSON value of [prorated]. + * + * Unlike [prorated], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("prorated") + @ExcludeMissing + fun _prorated(): JsonField = prorated + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [MinimumConfig]. + * + * The following fields are required: + * ```kotlin + * .minimumAmount() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [MinimumConfig]. */ + class Builder internal constructor() { + + private var minimumAmount: JsonField? = null + private var prorated: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(minimumConfig: MinimumConfig) = apply { + minimumAmount = minimumConfig.minimumAmount + prorated = minimumConfig.prorated + additionalProperties = minimumConfig.additionalProperties.toMutableMap() + } + + /** The minimum amount to apply */ + fun minimumAmount(minimumAmount: String) = + minimumAmount(JsonField.of(minimumAmount)) + + /** + * Sets [Builder.minimumAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumAmount] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount + } + + /** + * By default, subtotals from minimum composite prices are prorated based on + * the service period. Set to false to disable proration. + */ + fun prorated(prorated: Boolean?) = prorated(JsonField.ofNullable(prorated)) + + /** + * Alias for [Builder.prorated]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun prorated(prorated: Boolean) = prorated(prorated as Boolean?) + + /** + * Sets [Builder.prorated] to an arbitrary JSON value. + * + * You should usually call [Builder.prorated] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun prorated(prorated: JsonField) = apply { + this.prorated = prorated + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [MinimumConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .minimumAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MinimumConfig = + MinimumConfig( + checkRequired("minimumAmount", minimumAmount), + prorated, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MinimumConfig = apply { + if (validated) { + return@apply + } + + minimumAmount() + prorated() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (minimumAmount.asKnown() == null) 0 else 1) + + (if (prorated.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MinimumConfig && + minimumAmount == other.minimumAmount && + prorated == other.prorated && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(minimumAmount, prorated, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MinimumConfig{minimumAmount=$minimumAmount, prorated=$prorated, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Minimum && + cadence == other.cadence && + currency == other.currency && + itemId == other.itemId && + minimumConfig == other.minimumConfig && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + currency, + itemId, + minimumConfig, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Minimum{cadence=$cadence, currency=$currency, itemId=$itemId, minimumConfig=$minimumConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Add && + startDate == other.startDate && + allocationPrice == other.allocationPrice && + discounts == other.discounts && + endDate == other.endDate && + externalPriceId == other.externalPriceId && + filter == other.filter && + fixedFeeQuantityTransitions == other.fixedFeeQuantityTransitions && + maximumAmount == other.maximumAmount && + minimumAmount == other.minimumAmount && + price == other.price && + priceId == other.priceId && + usageCustomerIds == other.usageCustomerIds && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + startDate, + allocationPrice, + discounts, + endDate, + externalPriceId, + filter, + fixedFeeQuantityTransitions, + maximumAmount, + minimumAmount, + price, + priceId, + usageCustomerIds, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Add{startDate=$startDate, allocationPrice=$allocationPrice, discounts=$discounts, endDate=$endDate, externalPriceId=$externalPriceId, filter=$filter, fixedFeeQuantityTransitions=$fixedFeeQuantityTransitions, maximumAmount=$maximumAmount, minimumAmount=$minimumAmount, price=$price, priceId=$priceId, usageCustomerIds=$usageCustomerIds, additionalProperties=$additionalProperties}" + } + + class AddAdjustment + private constructor( + private val startDate: JsonField, + private val adjustment: JsonField, + private val adjustmentId: JsonField, + private val endDate: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("start_date") + @ExcludeMissing + startDate: JsonField = JsonMissing.of(), + @JsonProperty("adjustment") + @ExcludeMissing + adjustment: JsonField = JsonMissing.of(), + @JsonProperty("adjustment_id") + @ExcludeMissing + adjustmentId: JsonField = JsonMissing.of(), + @JsonProperty("end_date") @ExcludeMissing endDate: JsonField = JsonMissing.of(), + ) : this(startDate, adjustment, adjustmentId, endDate, mutableMapOf()) + + /** + * The start date of the adjustment interval. This is the date that the adjustment will + * start affecting prices on the subscription. The adjustment will apply to invoice dates + * that overlap with this `start_date`. This `start_date` is treated as inclusive for + * in-advance prices, and exclusive for in-arrears prices. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun startDate(): StartDate = startDate.getRequired("start_date") + + /** + * The definition of a new adjustment to create and add to the subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun adjustment(): Adjustment? = adjustment.getNullable("adjustment") + + /** + * The ID of the adjustment to add to the subscription. Adjustment IDs can be re-used from + * existing subscriptions or plans, but adjustments associated with coupon redemptions + * cannot be re-used. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun adjustmentId(): String? = adjustmentId.getNullable("adjustment_id") + + /** + * The end date of the adjustment interval. This is the date that the adjustment will stop + * affecting prices on the subscription. The adjustment will apply to invoice dates that + * overlap with this `end_date`.This `end_date` is treated as exclusive for in-advance + * prices, and inclusive for in-arrears prices. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun endDate(): EndDate? = endDate.getNullable("end_date") + + /** + * Returns the raw JSON value of [startDate]. + * + * Unlike [startDate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate + + /** + * Returns the raw JSON value of [adjustment]. + * + * Unlike [adjustment], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("adjustment") + @ExcludeMissing + fun _adjustment(): JsonField = adjustment + + /** + * Returns the raw JSON value of [adjustmentId]. + * + * Unlike [adjustmentId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("adjustment_id") + @ExcludeMissing + fun _adjustmentId(): JsonField = adjustmentId + + /** + * Returns the raw JSON value of [endDate]. + * + * Unlike [endDate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("end_date") @ExcludeMissing fun _endDate(): JsonField = endDate + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = Collections.unmodifiableMap(additionalProperties) fun toBuilder() = Builder().from(this) @@ -4503,7 +7464,6 @@ private constructor( * * The following fields are required: * ```kotlin - * .adjustment() * .startDate() * ``` */ @@ -4513,20 +7473,49 @@ private constructor( /** A builder for [AddAdjustment]. */ class Builder internal constructor() { - private var adjustment: JsonField? = null private var startDate: JsonField? = null + private var adjustment: JsonField = JsonMissing.of() + private var adjustmentId: JsonField = JsonMissing.of() private var endDate: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() internal fun from(addAdjustment: AddAdjustment) = apply { - adjustment = addAdjustment.adjustment startDate = addAdjustment.startDate + adjustment = addAdjustment.adjustment + adjustmentId = addAdjustment.adjustmentId endDate = addAdjustment.endDate additionalProperties = addAdjustment.additionalProperties.toMutableMap() } + /** + * The start date of the adjustment interval. This is the date that the adjustment will + * start affecting prices on the subscription. The adjustment will apply to invoice + * dates that overlap with this `start_date`. This `start_date` is treated as inclusive + * for in-advance prices, and exclusive for in-arrears prices. + */ + fun startDate(startDate: StartDate) = startDate(JsonField.of(startDate)) + + /** + * Sets [Builder.startDate] to an arbitrary JSON value. + * + * You should usually call [Builder.startDate] with a well-typed [StartDate] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun startDate(startDate: JsonField) = apply { this.startDate = startDate } + + /** Alias for calling [startDate] with `StartDate.ofDateTime(dateTime)`. */ + fun startDate(dateTime: OffsetDateTime) = startDate(StartDate.ofDateTime(dateTime)) + + /** + * Alias for calling [startDate] with + * `StartDate.ofBillingCycleRelative(billingCycleRelative)`. + */ + fun startDate(billingCycleRelative: BillingCycleRelativeDate) = + startDate(StartDate.ofBillingCycleRelative(billingCycleRelative)) + /** The definition of a new adjustment to create and add to the subscription. */ - fun adjustment(adjustment: Adjustment) = adjustment(JsonField.of(adjustment)) + fun adjustment(adjustment: Adjustment?) = adjustment(JsonField.ofNullable(adjustment)) /** * Sets [Builder.adjustment] to an arbitrary JSON value. @@ -4631,31 +7620,23 @@ private constructor( ) /** - * The start date of the adjustment interval. This is the date that the adjustment will - * start affecting prices on the subscription. The adjustment will apply to invoice - * dates that overlap with this `start_date`. This `start_date` is treated as inclusive - * for in-advance prices, and exclusive for in-arrears prices. + * The ID of the adjustment to add to the subscription. Adjustment IDs can be re-used + * from existing subscriptions or plans, but adjustments associated with coupon + * redemptions cannot be re-used. */ - fun startDate(startDate: StartDate) = startDate(JsonField.of(startDate)) + fun adjustmentId(adjustmentId: String?) = + adjustmentId(JsonField.ofNullable(adjustmentId)) /** - * Sets [Builder.startDate] to an arbitrary JSON value. + * Sets [Builder.adjustmentId] to an arbitrary JSON value. * - * You should usually call [Builder.startDate] with a well-typed [StartDate] value + * You should usually call [Builder.adjustmentId] with a well-typed [String] value * instead. This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun startDate(startDate: JsonField) = apply { this.startDate = startDate } - - /** Alias for calling [startDate] with `StartDate.ofDateTime(dateTime)`. */ - fun startDate(dateTime: OffsetDateTime) = startDate(StartDate.ofDateTime(dateTime)) - - /** - * Alias for calling [startDate] with - * `StartDate.ofBillingCycleRelative(billingCycleRelative)`. - */ - fun startDate(billingCycleRelative: BillingCycleRelativeDate) = - startDate(StartDate.ofBillingCycleRelative(billingCycleRelative)) + fun adjustmentId(adjustmentId: JsonField) = apply { + this.adjustmentId = adjustmentId + } /** * The end date of the adjustment interval. This is the date that the adjustment will @@ -4710,7 +7691,6 @@ private constructor( * * The following fields are required: * ```kotlin - * .adjustment() * .startDate() * ``` * @@ -4718,44 +7698,234 @@ private constructor( */ fun build(): AddAdjustment = AddAdjustment( - checkRequired("adjustment", adjustment), checkRequired("startDate", startDate), + adjustment, + adjustmentId, endDate, additionalProperties.toMutableMap(), ) } - private var validated: Boolean = false + private var validated: Boolean = false + + fun validate(): AddAdjustment = apply { + if (validated) { + return@apply + } + + startDate().validate() + adjustment()?.validate() + adjustmentId() + endDate()?.validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (startDate.asKnown()?.validity() ?: 0) + + (adjustment.asKnown()?.validity() ?: 0) + + (if (adjustmentId.asKnown() == null) 0 else 1) + + (endDate.asKnown()?.validity() ?: 0) + + /** + * The start date of the adjustment interval. This is the date that the adjustment will + * start affecting prices on the subscription. The adjustment will apply to invoice dates + * that overlap with this `start_date`. This `start_date` is treated as inclusive for + * in-advance prices, and exclusive for in-arrears prices. + */ + @JsonDeserialize(using = StartDate.Deserializer::class) + @JsonSerialize(using = StartDate.Serializer::class) + class StartDate + private constructor( + private val dateTime: OffsetDateTime? = null, + private val billingCycleRelative: BillingCycleRelativeDate? = null, + private val _json: JsonValue? = null, + ) { + + fun dateTime(): OffsetDateTime? = dateTime + + fun billingCycleRelative(): BillingCycleRelativeDate? = billingCycleRelative + + fun isDateTime(): Boolean = dateTime != null + + fun isBillingCycleRelative(): Boolean = billingCycleRelative != null + + fun asDateTime(): OffsetDateTime = dateTime.getOrThrow("dateTime") + + fun asBillingCycleRelative(): BillingCycleRelativeDate = + billingCycleRelative.getOrThrow("billingCycleRelative") + + fun _json(): JsonValue? = _json + + fun accept(visitor: Visitor): T = + when { + dateTime != null -> visitor.visitDateTime(dateTime) + billingCycleRelative != null -> + visitor.visitBillingCycleRelative(billingCycleRelative) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): StartDate = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitDateTime(dateTime: OffsetDateTime) {} + + override fun visitBillingCycleRelative( + billingCycleRelative: BillingCycleRelativeDate + ) { + billingCycleRelative.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitDateTime(dateTime: OffsetDateTime) = 1 + + override fun visitBillingCycleRelative( + billingCycleRelative: BillingCycleRelativeDate + ) = billingCycleRelative.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is StartDate && + dateTime == other.dateTime && + billingCycleRelative == other.billingCycleRelative + } + + override fun hashCode(): Int = Objects.hash(dateTime, billingCycleRelative) + + override fun toString(): String = + when { + dateTime != null -> "StartDate{dateTime=$dateTime}" + billingCycleRelative != null -> + "StartDate{billingCycleRelative=$billingCycleRelative}" + _json != null -> "StartDate{_unknown=$_json}" + else -> throw IllegalStateException("Invalid StartDate") + } + + companion object { + + fun ofDateTime(dateTime: OffsetDateTime) = StartDate(dateTime = dateTime) + + fun ofBillingCycleRelative(billingCycleRelative: BillingCycleRelativeDate) = + StartDate(billingCycleRelative = billingCycleRelative) + } + + /** + * An interface that defines how to map each variant of [StartDate] to a value of type + * [T]. + */ + interface Visitor { + + fun visitDateTime(dateTime: OffsetDateTime): T + + fun visitBillingCycleRelative(billingCycleRelative: BillingCycleRelativeDate): T + + /** + * Maps an unknown variant of [StartDate] to a value of type [T]. + * + * An instance of [StartDate] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the + * SDK is unaware of. + * + * @throws OrbInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw OrbInvalidDataException("Unknown StartDate: $json") + } + } + + internal class Deserializer : BaseDeserializer(StartDate::class) { - fun validate(): AddAdjustment = apply { - if (validated) { - return@apply + override fun ObjectCodec.deserialize(node: JsonNode): StartDate { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef()) + ?.let { StartDate(billingCycleRelative = it, _json = json) }, + tryDeserialize(node, jacksonTypeRef())?.let { + StartDate(dateTime = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible + // with all the possible variants (e.g. deserializing from object). + 0 -> StartDate(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the + // first completely valid match, or simply the first match if none are + // completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } } - adjustment().validate() - startDate().validate() - endDate()?.validate() - validated = true - } + internal class Serializer : BaseSerializer(StartDate::class) { - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false + override fun serialize( + value: StartDate, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.dateTime != null -> generator.writeObject(value.dateTime) + value.billingCycleRelative != null -> + generator.writeObject(value.billingCycleRelative) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid StartDate") + } + } } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (adjustment.asKnown()?.validity() ?: 0) + - (startDate.asKnown()?.validity() ?: 0) + - (endDate.asKnown()?.validity() ?: 0) + } /** The definition of a new adjustment to create and add to the subscription. */ @JsonDeserialize(using = Adjustment.Deserializer::class) @@ -5018,193 +8188,6 @@ private constructor( } } - /** - * The start date of the adjustment interval. This is the date that the adjustment will - * start affecting prices on the subscription. The adjustment will apply to invoice dates - * that overlap with this `start_date`. This `start_date` is treated as inclusive for - * in-advance prices, and exclusive for in-arrears prices. - */ - @JsonDeserialize(using = StartDate.Deserializer::class) - @JsonSerialize(using = StartDate.Serializer::class) - class StartDate - private constructor( - private val dateTime: OffsetDateTime? = null, - private val billingCycleRelative: BillingCycleRelativeDate? = null, - private val _json: JsonValue? = null, - ) { - - fun dateTime(): OffsetDateTime? = dateTime - - fun billingCycleRelative(): BillingCycleRelativeDate? = billingCycleRelative - - fun isDateTime(): Boolean = dateTime != null - - fun isBillingCycleRelative(): Boolean = billingCycleRelative != null - - fun asDateTime(): OffsetDateTime = dateTime.getOrThrow("dateTime") - - fun asBillingCycleRelative(): BillingCycleRelativeDate = - billingCycleRelative.getOrThrow("billingCycleRelative") - - fun _json(): JsonValue? = _json - - fun accept(visitor: Visitor): T = - when { - dateTime != null -> visitor.visitDateTime(dateTime) - billingCycleRelative != null -> - visitor.visitBillingCycleRelative(billingCycleRelative) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): StartDate = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitDateTime(dateTime: OffsetDateTime) {} - - override fun visitBillingCycleRelative( - billingCycleRelative: BillingCycleRelativeDate - ) { - billingCycleRelative.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitDateTime(dateTime: OffsetDateTime) = 1 - - override fun visitBillingCycleRelative( - billingCycleRelative: BillingCycleRelativeDate - ) = billingCycleRelative.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is StartDate && - dateTime == other.dateTime && - billingCycleRelative == other.billingCycleRelative - } - - override fun hashCode(): Int = Objects.hash(dateTime, billingCycleRelative) - - override fun toString(): String = - when { - dateTime != null -> "StartDate{dateTime=$dateTime}" - billingCycleRelative != null -> - "StartDate{billingCycleRelative=$billingCycleRelative}" - _json != null -> "StartDate{_unknown=$_json}" - else -> throw IllegalStateException("Invalid StartDate") - } - - companion object { - - fun ofDateTime(dateTime: OffsetDateTime) = StartDate(dateTime = dateTime) - - fun ofBillingCycleRelative(billingCycleRelative: BillingCycleRelativeDate) = - StartDate(billingCycleRelative = billingCycleRelative) - } - - /** - * An interface that defines how to map each variant of [StartDate] to a value of type - * [T]. - */ - interface Visitor { - - fun visitDateTime(dateTime: OffsetDateTime): T - - fun visitBillingCycleRelative(billingCycleRelative: BillingCycleRelativeDate): T - - /** - * Maps an unknown variant of [StartDate] to a value of type [T]. - * - * An instance of [StartDate] can contain an unknown variant if it was deserialized - * from data that doesn't match any known variant. For example, if the SDK is on an - * older version than the API, then the API may respond with new variants that the - * SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown StartDate: $json") - } - } - - internal class Deserializer : BaseDeserializer(StartDate::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): StartDate { - val json = JsonValue.fromJsonNode(node) - - val bestMatches = - sequenceOf( - tryDeserialize(node, jacksonTypeRef()) - ?.let { StartDate(billingCycleRelative = it, _json = json) }, - tryDeserialize(node, jacksonTypeRef())?.let { - StartDate(dateTime = it, _json = json) - }, - ) - .filterNotNull() - .allMaxBy { it.validity() } - .toList() - return when (bestMatches.size) { - // This can happen if what we're deserializing is completely incompatible - // with all the possible variants (e.g. deserializing from object). - 0 -> StartDate(_json = json) - 1 -> bestMatches.single() - // If there's more than one match with the highest validity, then use the - // first completely valid match, or simply the first match if none are - // completely valid. - else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() - } - } - } - - internal class Serializer : BaseSerializer(StartDate::class) { - - override fun serialize( - value: StartDate, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.dateTime != null -> generator.writeObject(value.dateTime) - value.billingCycleRelative != null -> - generator.writeObject(value.billingCycleRelative) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid StartDate") - } - } - } - } - /** * The end date of the adjustment interval. This is the date that the adjustment will stop * affecting prices on the subscription. The adjustment will apply to invoice dates that @@ -5398,20 +8381,21 @@ private constructor( } return other is AddAdjustment && - adjustment == other.adjustment && startDate == other.startDate && + adjustment == other.adjustment && + adjustmentId == other.adjustmentId && endDate == other.endDate && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(adjustment, startDate, endDate, additionalProperties) + Objects.hash(startDate, adjustment, adjustmentId, endDate, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "AddAdjustment{adjustment=$adjustment, startDate=$startDate, endDate=$endDate, additionalProperties=$additionalProperties}" + "AddAdjustment{startDate=$startDate, adjustment=$adjustment, adjustmentId=$adjustmentId, endDate=$endDate, additionalProperties=$additionalProperties}" } class Edit diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionSchedulePlanChangeParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionSchedulePlanChangeParams.kt index 018a0602b..e5d59cef3 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionSchedulePlanChangeParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionSchedulePlanChangeParams.kt @@ -36,7 +36,7 @@ import java.util.Objects * This endpoint can be used to change an existing subscription's plan. It returns the serialized * updated subscription object. * - * The body parameter `change_option` determines when the plan change occurrs. Orb supports three + * The body parameter `change_option` determines when the plan change occurs. Orb supports three * options: * - `end_of_subscription_term`: changes the plan at the end of the existing plan's term. * - Issuing this plan change request for a monthly subscription will keep the existing plan @@ -4225,16 +4225,6 @@ private constructor( /** Alias for calling [price] with `Price.ofTiered(tiered)`. */ fun price(tiered: NewSubscriptionTieredPrice) = price(Price.ofTiered(tiered)) - /** Alias for calling [price] with `Price.ofTieredBps(tieredBps)`. */ - fun price(tieredBps: NewSubscriptionTieredBpsPrice) = - price(Price.ofTieredBps(tieredBps)) - - /** Alias for calling [price] with `Price.ofBps(bps)`. */ - fun price(bps: NewSubscriptionBpsPrice) = price(Price.ofBps(bps)) - - /** Alias for calling [price] with `Price.ofBulkBps(bulkBps)`. */ - fun price(bulkBps: NewSubscriptionBulkBpsPrice) = price(Price.ofBulkBps(bulkBps)) - /** Alias for calling [price] with `Price.ofBulk(bulk)`. */ fun price(bulk: NewSubscriptionBulkPrice) = price(Price.ofBulk(bulk)) @@ -4355,6 +4345,16 @@ private constructor( fun price(groupedTiered: NewSubscriptionGroupedTieredPrice) = price(Price.ofGroupedTiered(groupedTiered)) + /** + * Alias for calling [price] with + * `Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)`. + */ + fun price(groupedWithMinMaxThresholds: Price.GroupedWithMinMaxThresholds) = + price(Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)) + + /** Alias for calling [price] with `Price.ofMinimum(minimum)`. */ + fun price(minimum: Price.Minimum) = price(Price.ofMinimum(minimum)) + /** The id of the price to add to the subscription. */ fun priceId(priceId: String?) = priceId(JsonField.ofNullable(priceId)) @@ -4480,9 +4480,6 @@ private constructor( private val package_: NewSubscriptionPackagePrice? = null, private val matrix: NewSubscriptionMatrixPrice? = null, private val tiered: NewSubscriptionTieredPrice? = null, - private val tieredBps: NewSubscriptionTieredBpsPrice? = null, - private val bps: NewSubscriptionBpsPrice? = null, - private val bulkBps: NewSubscriptionBulkBpsPrice? = null, private val bulk: NewSubscriptionBulkPrice? = null, private val thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice? = null, private val tieredPackage: NewSubscriptionTieredPackagePrice? = null, @@ -4512,6 +4509,8 @@ private constructor( private val tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice? = null, private val groupedTiered: NewSubscriptionGroupedTieredPrice? = null, + private val groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds? = null, + private val minimum: Minimum? = null, private val _json: JsonValue? = null, ) { @@ -4523,12 +4522,6 @@ private constructor( fun tiered(): NewSubscriptionTieredPrice? = tiered - fun tieredBps(): NewSubscriptionTieredBpsPrice? = tieredBps - - fun bps(): NewSubscriptionBpsPrice? = bps - - fun bulkBps(): NewSubscriptionBulkBpsPrice? = bulkBps - fun bulk(): NewSubscriptionBulkPrice? = bulk fun thresholdTotalAmount(): NewSubscriptionThresholdTotalAmountPrice? = @@ -4584,6 +4577,11 @@ private constructor( fun groupedTiered(): NewSubscriptionGroupedTieredPrice? = groupedTiered + fun groupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds? = + groupedWithMinMaxThresholds + + fun minimum(): Minimum? = minimum + fun isUnit(): Boolean = unit != null fun isPackage(): Boolean = package_ != null @@ -4592,12 +4590,6 @@ private constructor( fun isTiered(): Boolean = tiered != null - fun isTieredBps(): Boolean = tieredBps != null - - fun isBps(): Boolean = bps != null - - fun isBulkBps(): Boolean = bulkBps != null - fun isBulk(): Boolean = bulk != null fun isThresholdTotalAmount(): Boolean = thresholdTotalAmount != null @@ -4641,6 +4633,10 @@ private constructor( fun isGroupedTiered(): Boolean = groupedTiered != null + fun isGroupedWithMinMaxThresholds(): Boolean = groupedWithMinMaxThresholds != null + + fun isMinimum(): Boolean = minimum != null + fun asUnit(): NewSubscriptionUnitPrice = unit.getOrThrow("unit") fun asPackage(): NewSubscriptionPackagePrice = package_.getOrThrow("package_") @@ -4649,12 +4645,6 @@ private constructor( fun asTiered(): NewSubscriptionTieredPrice = tiered.getOrThrow("tiered") - fun asTieredBps(): NewSubscriptionTieredBpsPrice = tieredBps.getOrThrow("tieredBps") - - fun asBps(): NewSubscriptionBpsPrice = bps.getOrThrow("bps") - - fun asBulkBps(): NewSubscriptionBulkBpsPrice = bulkBps.getOrThrow("bulkBps") - fun asBulk(): NewSubscriptionBulkPrice = bulk.getOrThrow("bulk") fun asThresholdTotalAmount(): NewSubscriptionThresholdTotalAmountPrice = @@ -4719,6 +4709,11 @@ private constructor( fun asGroupedTiered(): NewSubscriptionGroupedTieredPrice = groupedTiered.getOrThrow("groupedTiered") + fun asGroupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds = + groupedWithMinMaxThresholds.getOrThrow("groupedWithMinMaxThresholds") + + fun asMinimum(): Minimum = minimum.getOrThrow("minimum") + fun _json(): JsonValue? = _json fun accept(visitor: Visitor): T = @@ -4727,9 +4722,6 @@ private constructor( package_ != null -> visitor.visitPackage(package_) matrix != null -> visitor.visitMatrix(matrix) tiered != null -> visitor.visitTiered(tiered) - tieredBps != null -> visitor.visitTieredBps(tieredBps) - bps != null -> visitor.visitBps(bps) - bulkBps != null -> visitor.visitBulkBps(bulkBps) bulk != null -> visitor.visitBulk(bulk) thresholdTotalAmount != null -> visitor.visitThresholdTotalAmount(thresholdTotalAmount) @@ -4766,6 +4758,9 @@ private constructor( tieredPackageWithMinimum != null -> visitor.visitTieredPackageWithMinimum(tieredPackageWithMinimum) groupedTiered != null -> visitor.visitGroupedTiered(groupedTiered) + groupedWithMinMaxThresholds != null -> + visitor.visitGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds) + minimum != null -> visitor.visitMinimum(minimum) else -> visitor.unknown(_json) } @@ -4794,18 +4789,6 @@ private constructor( tiered.validate() } - override fun visitTieredBps(tieredBps: NewSubscriptionTieredBpsPrice) { - tieredBps.validate() - } - - override fun visitBps(bps: NewSubscriptionBpsPrice) { - bps.validate() - } - - override fun visitBulkBps(bulkBps: NewSubscriptionBulkBpsPrice) { - bulkBps.validate() - } - override fun visitBulk(bulk: NewSubscriptionBulkPrice) { bulk.validate() } @@ -4932,6 +4915,16 @@ private constructor( ) { groupedTiered.validate() } + + override fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) { + groupedWithMinMaxThresholds.validate() + } + + override fun visitMinimum(minimum: Minimum) { + minimum.validate() + } } ) validated = true @@ -4965,14 +4958,6 @@ private constructor( override fun visitTiered(tiered: NewSubscriptionTieredPrice) = tiered.validity() - override fun visitTieredBps(tieredBps: NewSubscriptionTieredBpsPrice) = - tieredBps.validity() - - override fun visitBps(bps: NewSubscriptionBpsPrice) = bps.validity() - - override fun visitBulkBps(bulkBps: NewSubscriptionBulkBpsPrice) = - bulkBps.validity() - override fun visitBulk(bulk: NewSubscriptionBulkPrice) = bulk.validity() override fun visitThresholdTotalAmount( @@ -5058,6 +5043,12 @@ private constructor( groupedTiered: NewSubscriptionGroupedTieredPrice ) = groupedTiered.validity() + override fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) = groupedWithMinMaxThresholds.validity() + + override fun visitMinimum(minimum: Minimum) = minimum.validity() + override fun unknown(json: JsonValue?) = 0 } ) @@ -5072,9 +5063,6 @@ private constructor( package_ == other.package_ && matrix == other.matrix && tiered == other.tiered && - tieredBps == other.tieredBps && - bps == other.bps && - bulkBps == other.bulkBps && bulk == other.bulk && thresholdTotalAmount == other.thresholdTotalAmount && tieredPackage == other.tieredPackage && @@ -5095,7 +5083,9 @@ private constructor( groupedTieredPackage == other.groupedTieredPackage && matrixWithAllocation == other.matrixWithAllocation && tieredPackageWithMinimum == other.tieredPackageWithMinimum && - groupedTiered == other.groupedTiered + groupedTiered == other.groupedTiered && + groupedWithMinMaxThresholds == other.groupedWithMinMaxThresholds && + minimum == other.minimum } override fun hashCode(): Int = @@ -5104,9 +5094,6 @@ private constructor( package_, matrix, tiered, - tieredBps, - bps, - bulkBps, bulk, thresholdTotalAmount, tieredPackage, @@ -5128,6 +5115,8 @@ private constructor( matrixWithAllocation, tieredPackageWithMinimum, groupedTiered, + groupedWithMinMaxThresholds, + minimum, ) override fun toString(): String = @@ -5136,9 +5125,6 @@ private constructor( package_ != null -> "Price{package_=$package_}" matrix != null -> "Price{matrix=$matrix}" tiered != null -> "Price{tiered=$tiered}" - tieredBps != null -> "Price{tieredBps=$tieredBps}" - bps != null -> "Price{bps=$bps}" - bulkBps != null -> "Price{bulkBps=$bulkBps}" bulk != null -> "Price{bulk=$bulk}" thresholdTotalAmount != null -> "Price{thresholdTotalAmount=$thresholdTotalAmount}" @@ -5172,6 +5158,9 @@ private constructor( tieredPackageWithMinimum != null -> "Price{tieredPackageWithMinimum=$tieredPackageWithMinimum}" groupedTiered != null -> "Price{groupedTiered=$groupedTiered}" + groupedWithMinMaxThresholds != null -> + "Price{groupedWithMinMaxThresholds=$groupedWithMinMaxThresholds}" + minimum != null -> "Price{minimum=$minimum}" _json != null -> "Price{_unknown=$_json}" else -> throw IllegalStateException("Invalid Price") } @@ -5186,13 +5175,6 @@ private constructor( fun ofTiered(tiered: NewSubscriptionTieredPrice) = Price(tiered = tiered) - fun ofTieredBps(tieredBps: NewSubscriptionTieredBpsPrice) = - Price(tieredBps = tieredBps) - - fun ofBps(bps: NewSubscriptionBpsPrice) = Price(bps = bps) - - fun ofBulkBps(bulkBps: NewSubscriptionBulkBpsPrice) = Price(bulkBps = bulkBps) - fun ofBulk(bulk: NewSubscriptionBulkPrice) = Price(bulk = bulk) fun ofThresholdTotalAmount( @@ -5268,6 +5250,12 @@ private constructor( fun ofGroupedTiered(groupedTiered: NewSubscriptionGroupedTieredPrice) = Price(groupedTiered = groupedTiered) + + fun ofGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) = Price(groupedWithMinMaxThresholds = groupedWithMinMaxThresholds) + + fun ofMinimum(minimum: Minimum) = Price(minimum = minimum) } /** @@ -5283,12 +5271,6 @@ private constructor( fun visitTiered(tiered: NewSubscriptionTieredPrice): T - fun visitTieredBps(tieredBps: NewSubscriptionTieredBpsPrice): T - - fun visitBps(bps: NewSubscriptionBpsPrice): T - - fun visitBulkBps(bulkBps: NewSubscriptionBulkBpsPrice): T - fun visitBulk(bulk: NewSubscriptionBulkPrice): T fun visitThresholdTotalAmount( @@ -5366,6 +5348,12 @@ private constructor( fun visitGroupedTiered(groupedTiered: NewSubscriptionGroupedTieredPrice): T + fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ): T + + fun visitMinimum(minimum: Minimum): T + /** * Maps an unknown variant of [Price] to a value of type [T]. * @@ -5413,24 +5401,6 @@ private constructor( ) ?.let { Price(tiered = it, _json = json) } ?: Price(_json = json) } - "tiered_bps" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(tieredBps = it, _json = json) } ?: Price(_json = json) - } - "bps" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(bps = it, _json = json) } ?: Price(_json = json) - } - "bulk_bps" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(bulkBps = it, _json = json) } ?: Price(_json = json) - } "bulk" -> { return tryDeserialize(node, jacksonTypeRef()) ?.let { Price(bulk = it, _json = json) } ?: Price(_json = json) @@ -5599,6 +5569,19 @@ private constructor( ?.let { Price(groupedTiered = it, _json = json) } ?: Price(_json = json) } + "grouped_with_min_max_thresholds" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedWithMinMaxThresholds = it, _json = json) } + ?: Price(_json = json) + } + "minimum" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(minimum = it, _json = json) + } ?: Price(_json = json) + } } return Price(_json = json) @@ -5617,9 +5600,6 @@ private constructor( value.package_ != null -> generator.writeObject(value.package_) value.matrix != null -> generator.writeObject(value.matrix) value.tiered != null -> generator.writeObject(value.tiered) - value.tieredBps != null -> generator.writeObject(value.tieredBps) - value.bps != null -> generator.writeObject(value.bps) - value.bulkBps != null -> generator.writeObject(value.bulkBps) value.bulk != null -> generator.writeObject(value.bulk) value.thresholdTotalAmount != null -> generator.writeObject(value.thresholdTotalAmount) @@ -5659,1083 +5639,3058 @@ private constructor( value.tieredPackageWithMinimum != null -> generator.writeObject(value.tieredPackageWithMinimum) value.groupedTiered != null -> generator.writeObject(value.groupedTiered) + value.groupedWithMinMaxThresholds != null -> + generator.writeObject(value.groupedWithMinMaxThresholds) + value.minimum != null -> generator.writeObject(value.minimum) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid Price") } } } - } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + class GroupedWithMinMaxThresholds + private constructor( + private val cadence: JsonField, + private val groupedWithMinMaxThresholdsConfig: + JsonField, + private val itemId: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("grouped_with_min_max_thresholds_config") + @ExcludeMissing + groupedWithMinMaxThresholdsConfig: + JsonField = + JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + groupedWithMinMaxThresholdsConfig, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + mutableMapOf(), + ) - return other is AddPrice && - allocationPrice == other.allocationPrice && - discounts == other.discounts && - endDate == other.endDate && - externalPriceId == other.externalPriceId && - maximumAmount == other.maximumAmount && - minimumAmount == other.minimumAmount && - planPhaseOrder == other.planPhaseOrder && - price == other.price && - priceId == other.priceId && - startDate == other.startDate && - additionalProperties == other.additionalProperties - } + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") - private val hashCode: Int by lazy { - Objects.hash( - allocationPrice, - discounts, - endDate, - externalPriceId, - maximumAmount, - minimumAmount, - planPhaseOrder, - price, - priceId, - startDate, - additionalProperties, - ) - } + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupedWithMinMaxThresholdsConfig(): GroupedWithMinMaxThresholdsConfig = + groupedWithMinMaxThresholdsConfig.getRequired( + "grouped_with_min_max_thresholds_config" + ) - override fun hashCode(): Int = hashCode + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") - override fun toString() = - "AddPrice{allocationPrice=$allocationPrice, discounts=$discounts, endDate=$endDate, externalPriceId=$externalPriceId, maximumAmount=$maximumAmount, minimumAmount=$minimumAmount, planPhaseOrder=$planPhaseOrder, price=$price, priceId=$priceId, startDate=$startDate, additionalProperties=$additionalProperties}" - } + /** + * Expected to always return the following: + * ```kotlin + * JsonValue.from("grouped_with_min_max_thresholds") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType - /** - * Reset billing periods to be aligned with the plan change's effective date or start of the - * month. Defaults to `unchanged` which keeps subscription's existing billing cycle alignment. - */ - class BillingCycleAlignment - @JsonCreator - private constructor(private val value: JsonField) : Enum { + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API may respond with new members that the SDK is - * unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = billableMetricId.getNullable("billable_metric_id") - companion object { + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") - val UNCHANGED = of("unchanged") + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") - val PLAN_CHANGE_DATE = of("plan_change_date") + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") - val START_OF_MONTH = of("start_of_month") + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") - fun of(value: String) = BillingCycleAlignment(JsonField.of(value)) - } + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") - /** An enum containing [BillingCycleAlignment]'s known values. */ - enum class Known { - UNCHANGED, - PLAN_CHANGE_DATE, - START_OF_MONTH, - } + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") - /** - * An enum containing [BillingCycleAlignment]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [BillingCycleAlignment] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if the - * SDK is on an older version than the API, then the API may respond with new members that - * the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - UNCHANGED, - PLAN_CHANGE_DATE, - START_OF_MONTH, - /** - * An enum member indicating that [BillingCycleAlignment] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") - /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you want - * to throw for the unknown case. - */ - fun value(): Value = - when (this) { - UNCHANGED -> Value.UNCHANGED - PLAN_CHANGE_DATE -> Value.PLAN_CHANGE_DATE - START_OF_MONTH -> Value.START_OF_MONTH - else -> Value._UNKNOWN - } + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and don't - * want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known member. - */ - fun known(): Known = - when (this) { - UNCHANGED -> Known.UNCHANGED - PLAN_CHANGE_DATE -> Known.PLAN_CHANGE_DATE - START_OF_MONTH -> Known.START_OF_MONTH - else -> throw OrbInvalidDataException("Unknown BillingCycleAlignment: $value") - } + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + invoiceGroupingKey.getNullable("invoice_grouping_key") - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the expected - * primitive type. - */ - fun asString(): String = - _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - private var validated: Boolean = false + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") - fun validate(): BillingCycleAlignment = apply { - if (validated) { - return@apply - } + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") - known() - validated = true - } + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** + * Returns the raw JSON value of [groupedWithMinMaxThresholdsConfig]. + * + * Unlike [groupedWithMinMaxThresholdsConfig], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("grouped_with_min_max_thresholds_config") + @ExcludeMissing + fun _groupedWithMinMaxThresholdsConfig(): + JsonField = groupedWithMinMaxThresholdsConfig - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - return other is BillingCycleAlignment && value == other.value - } + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId - override fun hashCode() = value.hashCode() + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance - override fun toString() = value.toString() - } + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration - class RemoveAdjustment - private constructor( - private val adjustmentId: JsonField, - private val additionalProperties: MutableMap, - ) { + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate - @JsonCreator - private constructor( - @JsonProperty("adjustment_id") - @ExcludeMissing - adjustmentId: JsonField = JsonMissing.of() - ) : this(adjustmentId, mutableMapOf()) + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig - /** - * The id of the adjustment to remove on the subscription. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun adjustmentId(): String = adjustmentId.getRequired("adjustment_id") + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency - /** - * Returns the raw JSON value of [adjustmentId]. - * - * Unlike [adjustmentId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("adjustment_id") - @ExcludeMissing - fun _adjustmentId(): JsonField = adjustmentId + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - fun toBuilder() = Builder().from(this) + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - companion object { + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration - /** - * Returns a mutable builder for constructing an instance of [RemoveAdjustment]. - * - * The following fields are required: - * ```kotlin - * .adjustmentId() - * ``` - */ - fun builder() = Builder() - } + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata - /** A builder for [RemoveAdjustment]. */ - class Builder internal constructor() { + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId - private var adjustmentId: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - internal fun from(removeAdjustment: RemoveAdjustment) = apply { - adjustmentId = removeAdjustment.adjustmentId - additionalProperties = removeAdjustment.additionalProperties.toMutableMap() - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [GroupedWithMinMaxThresholds]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .groupedWithMinMaxThresholdsConfig() + * .itemId() + * .name() + * ``` + */ + fun builder() = Builder() + } - /** The id of the adjustment to remove on the subscription. */ - fun adjustmentId(adjustmentId: String) = adjustmentId(JsonField.of(adjustmentId)) + /** A builder for [GroupedWithMinMaxThresholds]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var groupedWithMinMaxThresholdsConfig: + JsonField? = + null + private var itemId: JsonField? = null + private var modelType: JsonValue = + JsonValue.from("grouped_with_min_max_thresholds") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds) = + apply { + cadence = groupedWithMinMaxThresholds.cadence + groupedWithMinMaxThresholdsConfig = + groupedWithMinMaxThresholds.groupedWithMinMaxThresholdsConfig + itemId = groupedWithMinMaxThresholds.itemId + modelType = groupedWithMinMaxThresholds.modelType + name = groupedWithMinMaxThresholds.name + billableMetricId = groupedWithMinMaxThresholds.billableMetricId + billedInAdvance = groupedWithMinMaxThresholds.billedInAdvance + billingCycleConfiguration = + groupedWithMinMaxThresholds.billingCycleConfiguration + conversionRate = groupedWithMinMaxThresholds.conversionRate + conversionRateConfig = groupedWithMinMaxThresholds.conversionRateConfig + currency = groupedWithMinMaxThresholds.currency + dimensionalPriceConfiguration = + groupedWithMinMaxThresholds.dimensionalPriceConfiguration + externalPriceId = groupedWithMinMaxThresholds.externalPriceId + fixedPriceQuantity = groupedWithMinMaxThresholds.fixedPriceQuantity + invoiceGroupingKey = groupedWithMinMaxThresholds.invoiceGroupingKey + invoicingCycleConfiguration = + groupedWithMinMaxThresholds.invoicingCycleConfiguration + metadata = groupedWithMinMaxThresholds.metadata + referenceId = groupedWithMinMaxThresholds.referenceId + additionalProperties = + groupedWithMinMaxThresholds.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + fun groupedWithMinMaxThresholdsConfig( + groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + ) = + groupedWithMinMaxThresholdsConfig( + JsonField.of(groupedWithMinMaxThresholdsConfig) + ) - /** - * Sets [Builder.adjustmentId] to an arbitrary JSON value. - * - * You should usually call [Builder.adjustmentId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun adjustmentId(adjustmentId: JsonField) = apply { - this.adjustmentId = adjustmentId - } + /** + * Sets [Builder.groupedWithMinMaxThresholdsConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.groupedWithMinMaxThresholdsConfig] with a + * well-typed [GroupedWithMinMaxThresholdsConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun groupedWithMinMaxThresholdsConfig( + groupedWithMinMaxThresholdsConfig: + JsonField + ) = apply { + this.groupedWithMinMaxThresholdsConfig = groupedWithMinMaxThresholdsConfig + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("grouped_with_min_max_thresholds") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) - /** - * Returns an immutable instance of [RemoveAdjustment]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```kotlin - * .adjustmentId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): RemoveAdjustment = - RemoveAdjustment( - checkRequired("adjustmentId", adjustmentId), - additionalProperties.toMutableMap(), - ) - } + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) - private var validated: Boolean = false + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } - fun validate(): RemoveAdjustment = apply { - if (validated) { - return@apply - } + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } - adjustmentId() - validated = true - } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = (if (adjustmentId.asKnown() == null) 0 else 1) + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - return other is RemoveAdjustment && - adjustmentId == other.adjustmentId && - additionalProperties == other.additionalProperties - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - private val hashCode: Int by lazy { Objects.hash(adjustmentId, additionalProperties) } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - override fun hashCode(): Int = hashCode + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - override fun toString() = - "RemoveAdjustment{adjustmentId=$adjustmentId, additionalProperties=$additionalProperties}" - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - class RemovePrice - private constructor( - private val externalPriceId: JsonField, - private val priceId: JsonField, - private val additionalProperties: MutableMap, - ) { + /** + * Returns an immutable instance of [GroupedWithMinMaxThresholds]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .groupedWithMinMaxThresholdsConfig() + * .itemId() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedWithMinMaxThresholds = + GroupedWithMinMaxThresholds( + checkRequired("cadence", cadence), + checkRequired( + "groupedWithMinMaxThresholdsConfig", + groupedWithMinMaxThresholdsConfig, + ), + checkRequired("itemId", itemId), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } - @JsonCreator - private constructor( - @JsonProperty("external_price_id") - @ExcludeMissing - externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("price_id") @ExcludeMissing priceId: JsonField = JsonMissing.of(), - ) : this(externalPriceId, priceId, mutableMapOf()) + private var validated: Boolean = false - /** - * The external price id of the price to remove on the subscription. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + fun validate(): GroupedWithMinMaxThresholds = apply { + if (validated) { + return@apply + } - /** - * The id of the price to remove on the subscription. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun priceId(): String? = priceId.getNullable("price_id") + cadence().validate() + groupedWithMinMaxThresholdsConfig().validate() + itemId() + _modelType().let { + if (it != JsonValue.from("grouped_with_min_max_thresholds")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + metadata()?.validate() + referenceId() + validated = true + } - /** - * Returns the raw JSON value of [externalPriceId]. - * - * Unlike [externalPriceId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - /** - * Returns the raw JSON value of [priceId]. - * - * Unlike [priceId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (groupedWithMinMaxThresholdsConfig.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + modelType.let { + if (it == JsonValue.from("grouped_with_min_max_thresholds")) 1 else 0 + } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } - fun toBuilder() = Builder().from(this) + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } - companion object { + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - /** Returns a mutable builder for constructing an instance of [RemovePrice]. */ - fun builder() = Builder() - } + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - /** A builder for [RemovePrice]. */ - class Builder internal constructor() { + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - private var externalPriceId: JsonField = JsonMissing.of() - private var priceId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + return other is Cadence && value == other.value + } - internal fun from(removePrice: RemovePrice) = apply { - externalPriceId = removePrice.externalPriceId - priceId = removePrice.priceId - additionalProperties = removePrice.additionalProperties.toMutableMap() - } + override fun hashCode() = value.hashCode() - /** The external price id of the price to remove on the subscription. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) + override fun toString() = value.toString() + } - /** - * Sets [Builder.externalPriceId] to an arbitrary JSON value. - * - * You should usually call [Builder.externalPriceId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun externalPriceId(externalPriceId: JsonField) = apply { - this.externalPriceId = externalPriceId - } + class GroupedWithMinMaxThresholdsConfig + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { - /** The id of the price to remove on the subscription. */ - fun priceId(priceId: String?) = priceId(JsonField.ofNullable(priceId)) + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties - /** - * Sets [Builder.priceId] to an arbitrary JSON value. - * - * You should usually call [Builder.priceId] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun priceId(priceId: JsonField) = apply { this.priceId = priceId } + fun toBuilder() = Builder().from(this) - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + companion object { - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * Returns a mutable builder for constructing an instance of + * [GroupedWithMinMaxThresholdsConfig]. + */ + fun builder() = Builder() + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + /** A builder for [GroupedWithMinMaxThresholdsConfig]. */ + class Builder internal constructor() { - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + private var additionalProperties: MutableMap = + mutableMapOf() - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + internal fun from( + groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + ) = apply { + additionalProperties = + groupedWithMinMaxThresholdsConfig.additionalProperties + .toMutableMap() + } - /** - * Returns an immutable instance of [RemovePrice]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): RemovePrice = - RemovePrice(externalPriceId, priceId, additionalProperties.toMutableMap()) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - private var validated: Boolean = false + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun validate(): RemovePrice = apply { - if (validated) { - return@apply - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - externalPriceId() - priceId() - validated = true - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (if (externalPriceId.asKnown() == null) 0 else 1) + - (if (priceId.asKnown() == null) 0 else 1) + /** + * Returns an immutable instance of [GroupedWithMinMaxThresholdsConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): GroupedWithMinMaxThresholdsConfig = + GroupedWithMinMaxThresholdsConfig(additionalProperties.toImmutable()) + } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + private var validated: Boolean = false - return other is RemovePrice && - externalPriceId == other.externalPriceId && - priceId == other.priceId && - additionalProperties == other.additionalProperties - } + fun validate(): GroupedWithMinMaxThresholdsConfig = apply { + if (validated) { + return@apply + } - private val hashCode: Int by lazy { - Objects.hash(externalPriceId, priceId, additionalProperties) - } + validated = true + } - override fun hashCode(): Int = hashCode + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - override fun toString() = - "RemovePrice{externalPriceId=$externalPriceId, priceId=$priceId, additionalProperties=$additionalProperties}" - } + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } - class ReplaceAdjustment - private constructor( - private val adjustment: JsonField, - private val replacesAdjustmentId: JsonField, - private val additionalProperties: MutableMap, - ) { + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - @JsonCreator - private constructor( - @JsonProperty("adjustment") - @ExcludeMissing - adjustment: JsonField = JsonMissing.of(), - @JsonProperty("replaces_adjustment_id") - @ExcludeMissing - replacesAdjustmentId: JsonField = JsonMissing.of(), - ) : this(adjustment, replacesAdjustmentId, mutableMapOf()) + return other is GroupedWithMinMaxThresholdsConfig && + additionalProperties == other.additionalProperties + } - /** - * The definition of a new adjustment to create and add to the subscription. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun adjustment(): Adjustment = adjustment.getRequired("adjustment") + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /** - * The id of the adjustment on the plan to replace in the subscription. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun replacesAdjustmentId(): String = - replacesAdjustmentId.getRequired("replaces_adjustment_id") + override fun hashCode(): Int = hashCode - /** - * Returns the raw JSON value of [adjustment]. - * - * Unlike [adjustment], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("adjustment") - @ExcludeMissing - fun _adjustment(): JsonField = adjustment + override fun toString() = + "GroupedWithMinMaxThresholdsConfig{additionalProperties=$additionalProperties}" + } - /** - * Returns the raw JSON value of [replacesAdjustmentId]. - * - * Unlike [replacesAdjustmentId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("replaces_adjustment_id") - @ExcludeMissing - fun _replacesAdjustmentId(): JsonField = replacesAdjustmentId + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + fun toBuilder() = Builder().from(this) - fun toBuilder() = Builder().from(this) + companion object { - companion object { + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } - /** - * Returns a mutable builder for constructing an instance of [ReplaceAdjustment]. - * - * The following fields are required: - * ```kotlin - * .adjustment() - * .replacesAdjustmentId() - * ``` - */ - fun builder() = Builder() - } + /** A builder for [Metadata]. */ + class Builder internal constructor() { - /** A builder for [ReplaceAdjustment]. */ - class Builder internal constructor() { + private var additionalProperties: MutableMap = + mutableMapOf() - private var adjustment: JsonField? = null - private var replacesAdjustmentId: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } - internal fun from(replaceAdjustment: ReplaceAdjustment) = apply { - adjustment = replaceAdjustment.adjustment - replacesAdjustmentId = replaceAdjustment.replacesAdjustmentId - additionalProperties = replaceAdjustment.additionalProperties.toMutableMap() - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** The definition of a new adjustment to create and add to the subscription. */ - fun adjustment(adjustment: Adjustment) = adjustment(JsonField.of(adjustment)) + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * Sets [Builder.adjustment] to an arbitrary JSON value. - * - * You should usually call [Builder.adjustment] with a well-typed [Adjustment] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun adjustment(adjustment: JsonField) = apply { - this.adjustment = adjustment - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - /** - * Alias for calling [adjustment] with - * `Adjustment.ofPercentageDiscount(percentageDiscount)`. - */ - fun adjustment(percentageDiscount: NewPercentageDiscount) = - adjustment(Adjustment.ofPercentageDiscount(percentageDiscount)) + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - /** - * Alias for calling [adjustment] with the following: - * ```kotlin - * NewPercentageDiscount.builder() - * .adjustmentType(NewPercentageDiscount.AdjustmentType.PERCENTAGE_DISCOUNT) - * .percentageDiscount(percentageDiscount) - * .build() - * ``` - */ - fun percentageDiscountAdjustment(percentageDiscount: Double) = - adjustment( - NewPercentageDiscount.builder() - .adjustmentType(NewPercentageDiscount.AdjustmentType.PERCENTAGE_DISCOUNT) - .percentageDiscount(percentageDiscount) - .build() - ) + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - /** Alias for calling [adjustment] with `Adjustment.ofUsageDiscount(usageDiscount)`. */ - fun adjustment(usageDiscount: NewUsageDiscount) = - adjustment(Adjustment.ofUsageDiscount(usageDiscount)) + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } - /** - * Alias for calling [adjustment] with the following: - * ```kotlin - * NewUsageDiscount.builder() - * .adjustmentType(NewUsageDiscount.AdjustmentType.USAGE_DISCOUNT) - * .usageDiscount(usageDiscount) - * .build() - * ``` - */ - fun usageDiscountAdjustment(usageDiscount: Double) = - adjustment( - NewUsageDiscount.builder() - .adjustmentType(NewUsageDiscount.AdjustmentType.USAGE_DISCOUNT) - .usageDiscount(usageDiscount) - .build() - ) + private var validated: Boolean = false - /** - * Alias for calling [adjustment] with `Adjustment.ofAmountDiscount(amountDiscount)`. - */ - fun adjustment(amountDiscount: NewAmountDiscount) = - adjustment(Adjustment.ofAmountDiscount(amountDiscount)) + fun validate(): Metadata = apply { + if (validated) { + return@apply + } - /** - * Alias for calling [adjustment] with the following: - * ```kotlin - * NewAmountDiscount.builder() - * .adjustmentType(NewAmountDiscount.AdjustmentType.AMOUNT_DISCOUNT) - * .amountDiscount(amountDiscount) - * .build() - * ``` - */ - fun amountDiscountAdjustment(amountDiscount: String) = - adjustment( - NewAmountDiscount.builder() - .adjustmentType(NewAmountDiscount.AdjustmentType.AMOUNT_DISCOUNT) - .amountDiscount(amountDiscount) - .build() - ) + validated = true + } - /** Alias for calling [adjustment] with `Adjustment.ofMinimum(minimum)`. */ - fun adjustment(minimum: NewMinimum) = adjustment(Adjustment.ofMinimum(minimum)) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - /** Alias for calling [adjustment] with `Adjustment.ofMaximum(maximum)`. */ - fun adjustment(maximum: NewMaximum) = adjustment(Adjustment.ofMaximum(maximum)) + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } - /** - * Alias for calling [adjustment] with the following: - * ```kotlin - * NewMaximum.builder() - * .adjustmentType(NewMaximum.AdjustmentType.MAXIMUM) - * .maximumAmount(maximumAmount) - * .build() - * ``` - */ - fun maximumAdjustment(maximumAmount: String) = - adjustment( - NewMaximum.builder() - .adjustmentType(NewMaximum.AdjustmentType.MAXIMUM) - .maximumAmount(maximumAmount) - .build() - ) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** The id of the adjustment on the plan to replace in the subscription. */ - fun replacesAdjustmentId(replacesAdjustmentId: String) = - replacesAdjustmentId(JsonField.of(replacesAdjustmentId)) + return other is Metadata && + additionalProperties == other.additionalProperties + } - /** - * Sets [Builder.replacesAdjustmentId] to an arbitrary JSON value. - * - * You should usually call [Builder.replacesAdjustmentId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun replacesAdjustmentId(replacesAdjustmentId: JsonField) = apply { - this.replacesAdjustmentId = replacesAdjustmentId - } + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + override fun hashCode(): Int = hashCode - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + return other is GroupedWithMinMaxThresholds && + cadence == other.cadence && + groupedWithMinMaxThresholdsConfig == + other.groupedWithMinMaxThresholdsConfig && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + private val hashCode: Int by lazy { + Objects.hash( + cadence, + groupedWithMinMaxThresholdsConfig, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties, + ) + } - /** - * Returns an immutable instance of [ReplaceAdjustment]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```kotlin - * .adjustment() - * .replacesAdjustmentId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): ReplaceAdjustment = - ReplaceAdjustment( - checkRequired("adjustment", adjustment), - checkRequired("replacesAdjustmentId", replacesAdjustmentId), - additionalProperties.toMutableMap(), + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedWithMinMaxThresholds{cadence=$cadence, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class Minimum + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val minimumConfig: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("minimum_config") + @ExcludeMissing + minimumConfig: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + minimumConfig, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + mutableMapOf(), ) - } - - private var validated: Boolean = false - fun validate(): ReplaceAdjustment = apply { - if (validated) { - return@apply - } + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") - adjustment().validate() - replacesAdjustmentId() - validated = true - } + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun minimumConfig(): MinimumConfig = minimumConfig.getRequired("minimum_config") - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (adjustment.asKnown()?.validity() ?: 0) + - (if (replacesAdjustmentId.asKnown() == null) 0 else 1) + /** + * Expected to always return the following: + * ```kotlin + * JsonValue.from("minimum") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType - /** The definition of a new adjustment to create and add to the subscription. */ - @JsonDeserialize(using = Adjustment.Deserializer::class) - @JsonSerialize(using = Adjustment.Serializer::class) - class Adjustment - private constructor( - private val percentageDiscount: NewPercentageDiscount? = null, - private val usageDiscount: NewUsageDiscount? = null, - private val amountDiscount: NewAmountDiscount? = null, - private val minimum: NewMinimum? = null, - private val maximum: NewMaximum? = null, - private val _json: JsonValue? = null, - ) { + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") - fun percentageDiscount(): NewPercentageDiscount? = percentageDiscount + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = billableMetricId.getNullable("billable_metric_id") - fun usageDiscount(): NewUsageDiscount? = usageDiscount + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") - fun amountDiscount(): NewAmountDiscount? = amountDiscount + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") - fun minimum(): NewMinimum? = minimum + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") - fun maximum(): NewMaximum? = maximum + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") - fun isPercentageDiscount(): Boolean = percentageDiscount != null + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") - fun isUsageDiscount(): Boolean = usageDiscount != null + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") - fun isAmountDiscount(): Boolean = amountDiscount != null + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") - fun isMinimum(): Boolean = minimum != null + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") - fun isMaximum(): Boolean = maximum != null + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + invoiceGroupingKey.getNullable("invoice_grouping_key") - fun asPercentageDiscount(): NewPercentageDiscount = - percentageDiscount.getOrThrow("percentageDiscount") + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - fun asUsageDiscount(): NewUsageDiscount = usageDiscount.getOrThrow("usageDiscount") + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") - fun asAmountDiscount(): NewAmountDiscount = amountDiscount.getOrThrow("amountDiscount") + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") - fun asMinimum(): NewMinimum = minimum.getOrThrow("minimum") + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence - fun asMaximum(): NewMaximum = maximum.getOrThrow("maximum") + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - fun _json(): JsonValue? = _json + /** + * Returns the raw JSON value of [minimumConfig]. + * + * Unlike [minimumConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("minimum_config") + @ExcludeMissing + fun _minimumConfig(): JsonField = minimumConfig - fun accept(visitor: Visitor): T = - when { - percentageDiscount != null -> - visitor.visitPercentageDiscount(percentageDiscount) - usageDiscount != null -> visitor.visitUsageDiscount(usageDiscount) - amountDiscount != null -> visitor.visitAmountDiscount(amountDiscount) - minimum != null -> visitor.visitMinimum(minimum) - maximum != null -> visitor.visitMaximum(maximum) - else -> visitor.unknown(_json) - } + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - private var validated: Boolean = false + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId - fun validate(): Adjustment = apply { - if (validated) { - return@apply - } + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance - accept( - object : Visitor { - override fun visitPercentageDiscount( - percentageDiscount: NewPercentageDiscount - ) { - percentageDiscount.validate() - } + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration - override fun visitUsageDiscount(usageDiscount: NewUsageDiscount) { - usageDiscount.validate() - } + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate - override fun visitAmountDiscount(amountDiscount: NewAmountDiscount) { - amountDiscount.validate() - } + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig - override fun visitMinimum(minimum: NewMinimum) { - minimum.validate() - } + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency - override fun visitMaximum(maximum: NewMaximum) { - maximum.validate() - } - } - ) - validated = true - } + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitPercentageDiscount( - percentageDiscount: NewPercentageDiscount - ) = percentageDiscount.validity() + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Minimum]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .minimumConfig() + * .name() + * ``` + */ + fun builder() = Builder() + } - override fun visitUsageDiscount(usageDiscount: NewUsageDiscount) = - usageDiscount.validity() + /** A builder for [Minimum]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var minimumConfig: JsonField? = null + private var modelType: JsonValue = JsonValue.from("minimum") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(minimum: Minimum) = apply { + cadence = minimum.cadence + itemId = minimum.itemId + minimumConfig = minimum.minimumConfig + modelType = minimum.modelType + name = minimum.name + billableMetricId = minimum.billableMetricId + billedInAdvance = minimum.billedInAdvance + billingCycleConfiguration = minimum.billingCycleConfiguration + conversionRate = minimum.conversionRate + conversionRateConfig = minimum.conversionRateConfig + currency = minimum.currency + dimensionalPriceConfiguration = minimum.dimensionalPriceConfiguration + externalPriceId = minimum.externalPriceId + fixedPriceQuantity = minimum.fixedPriceQuantity + invoiceGroupingKey = minimum.invoiceGroupingKey + invoicingCycleConfiguration = minimum.invoicingCycleConfiguration + metadata = minimum.metadata + referenceId = minimum.referenceId + additionalProperties = minimum.additionalProperties.toMutableMap() + } - override fun visitAmountDiscount(amountDiscount: NewAmountDiscount) = - amountDiscount.validity() + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun minimumConfig(minimumConfig: MinimumConfig) = + minimumConfig(JsonField.of(minimumConfig)) + + /** + * Sets [Builder.minimumConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumConfig] with a well-typed + * [MinimumConfig] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun minimumConfig(minimumConfig: JsonField) = apply { + this.minimumConfig = minimumConfig + } - override fun visitMinimum(minimum: NewMinimum) = minimum.validity() + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("minimum") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } - override fun visitMaximum(maximum: NewMaximum) = maximum.validity() + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } - override fun unknown(json: JsonValue?) = 0 + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate } - ) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) - return other is Adjustment && - percentageDiscount == other.percentageDiscount && - usageDiscount == other.usageDiscount && - amountDiscount == other.amountDiscount && - minimum == other.minimum && - maximum == other.maximum - } + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) - override fun hashCode(): Int = - Objects.hash(percentageDiscount, usageDiscount, amountDiscount, minimum, maximum) + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) - override fun toString(): String = - when { - percentageDiscount != null -> - "Adjustment{percentageDiscount=$percentageDiscount}" - usageDiscount != null -> "Adjustment{usageDiscount=$usageDiscount}" - amountDiscount != null -> "Adjustment{amountDiscount=$amountDiscount}" - minimum != null -> "Adjustment{minimum=$minimum}" - maximum != null -> "Adjustment{maximum=$maximum}" - _json != null -> "Adjustment{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Adjustment") - } + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } - companion object { + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } - fun ofPercentageDiscount(percentageDiscount: NewPercentageDiscount) = - Adjustment(percentageDiscount = percentageDiscount) + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } - fun ofUsageDiscount(usageDiscount: NewUsageDiscount) = - Adjustment(usageDiscount = usageDiscount) + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) - fun ofAmountDiscount(amountDiscount: NewAmountDiscount) = - Adjustment(amountDiscount = amountDiscount) + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } - fun ofMinimum(minimum: NewMinimum) = Adjustment(minimum = minimum) + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun ofMaximum(maximum: NewMaximum) = Adjustment(maximum = maximum) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * An interface that defines how to map each variant of [Adjustment] to a value of type - * [T]. - */ - interface Visitor { + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun visitPercentageDiscount(percentageDiscount: NewPercentageDiscount): T + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun visitUsageDiscount(usageDiscount: NewUsageDiscount): T + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - fun visitAmountDiscount(amountDiscount: NewAmountDiscount): T + /** + * Returns an immutable instance of [Minimum]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .minimumConfig() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Minimum = + Minimum( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("minimumConfig", minimumConfig), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } - fun visitMinimum(minimum: NewMinimum): T + private var validated: Boolean = false - fun visitMaximum(maximum: NewMaximum): T + fun validate(): Minimum = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + minimumConfig().validate() + _modelType().let { + if (it != JsonValue.from("minimum")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } /** - * Maps an unknown variant of [Adjustment] to a value of type [T]. - * - * An instance of [Adjustment] can contain an unknown variant if it was deserialized - * from data that doesn't match any known variant. For example, if the SDK is on an - * older version than the API, then the API may respond with new variants that the - * SDK is unaware of. + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * @throws OrbInvalidDataException in the default implementation. + * Used for best match union deserialization. */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown Adjustment: $json") - } - } + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + (minimumConfig.asKnown()?.validity() ?: 0) + + modelType.let { if (it == JsonValue.from("minimum")) 1 else 0 } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } - internal class Deserializer : BaseDeserializer(Adjustment::class) { + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } - override fun ObjectCodec.deserialize(node: JsonNode): Adjustment { - val json = JsonValue.fromJsonNode(node) - val adjustmentType = json.asObject()?.get("adjustment_type")?.asString() + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } - when (adjustmentType) { - "percentage_discount" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Adjustment(percentageDiscount = it, _json = json) } - ?: Adjustment(_json = json) - } - "usage_discount" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(usageDiscount = it, _json = json) - } ?: Adjustment(_json = json) - } - "amount_discount" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(amountDiscount = it, _json = json) - } ?: Adjustment(_json = json) - } - "minimum" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(minimum = it, _json = json) - } ?: Adjustment(_json = json) + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false } - "maximum" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(maximum = it, _json = json) - } ?: Adjustment(_json = json) + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } + + return other is Cadence && value == other.value } - return Adjustment(_json = json) - } - } + override fun hashCode() = value.hashCode() - internal class Serializer : BaseSerializer(Adjustment::class) { + override fun toString() = value.toString() + } - override fun serialize( - value: Adjustment, - generator: JsonGenerator, - provider: SerializerProvider, + class MinimumConfig + private constructor( + private val minimumAmount: JsonField, + private val prorated: JsonField, + private val additionalProperties: MutableMap, ) { - when { - value.percentageDiscount != null -> - generator.writeObject(value.percentageDiscount) - value.usageDiscount != null -> generator.writeObject(value.usageDiscount) - value.amountDiscount != null -> generator.writeObject(value.amountDiscount) - value.minimum != null -> generator.writeObject(value.minimum) - value.maximum != null -> generator.writeObject(value.maximum) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Adjustment") + + @JsonCreator + private constructor( + @JsonProperty("minimum_amount") + @ExcludeMissing + minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("prorated") + @ExcludeMissing + prorated: JsonField = JsonMissing.of(), + ) : this(minimumAmount, prorated, mutableMapOf()) + + /** + * The minimum amount to apply + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") + + /** + * By default, subtotals from minimum composite prices are prorated based on the + * service period. Set to false to disable proration. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun prorated(): Boolean? = prorated.getNullable("prorated") + + /** + * Returns the raw JSON value of [minimumAmount]. + * + * Unlike [minimumAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount + + /** + * Returns the raw JSON value of [prorated]. + * + * Unlike [prorated], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("prorated") + @ExcludeMissing + fun _prorated(): JsonField = prorated + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) } - } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [MinimumConfig]. + * + * The following fields are required: + * ```kotlin + * .minimumAmount() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [MinimumConfig]. */ + class Builder internal constructor() { + + private var minimumAmount: JsonField? = null + private var prorated: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(minimumConfig: MinimumConfig) = apply { + minimumAmount = minimumConfig.minimumAmount + prorated = minimumConfig.prorated + additionalProperties = minimumConfig.additionalProperties.toMutableMap() + } + + /** The minimum amount to apply */ + fun minimumAmount(minimumAmount: String) = + minimumAmount(JsonField.of(minimumAmount)) + + /** + * Sets [Builder.minimumAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumAmount] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount + } + + /** + * By default, subtotals from minimum composite prices are prorated based on + * the service period. Set to false to disable proration. + */ + fun prorated(prorated: Boolean?) = prorated(JsonField.ofNullable(prorated)) + + /** + * Alias for [Builder.prorated]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun prorated(prorated: Boolean) = prorated(prorated as Boolean?) + + /** + * Sets [Builder.prorated] to an arbitrary JSON value. + * + * You should usually call [Builder.prorated] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun prorated(prorated: JsonField) = apply { + this.prorated = prorated + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [MinimumConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .minimumAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MinimumConfig = + MinimumConfig( + checkRequired("minimumAmount", minimumAmount), + prorated, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MinimumConfig = apply { + if (validated) { + return@apply + } + + minimumAmount() + prorated() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (minimumAmount.asKnown() == null) 0 else 1) + + (if (prorated.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MinimumConfig && + minimumAmount == other.minimumAmount && + prorated == other.prorated && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(minimumAmount, prorated, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MinimumConfig{minimumAmount=$minimumAmount, prorated=$prorated, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Minimum && + cadence == other.cadence && + itemId == other.itemId && + minimumConfig == other.minimumConfig && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + minimumConfig, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Minimum{cadence=$cadence, itemId=$itemId, minimumConfig=$minimumConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } } @@ -6744,237 +8699,212 @@ private constructor( return true } - return other is ReplaceAdjustment && - adjustment == other.adjustment && - replacesAdjustmentId == other.replacesAdjustmentId && + return other is AddPrice && + allocationPrice == other.allocationPrice && + discounts == other.discounts && + endDate == other.endDate && + externalPriceId == other.externalPriceId && + maximumAmount == other.maximumAmount && + minimumAmount == other.minimumAmount && + planPhaseOrder == other.planPhaseOrder && + price == other.price && + priceId == other.priceId && + startDate == other.startDate && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(adjustment, replacesAdjustmentId, additionalProperties) + Objects.hash( + allocationPrice, + discounts, + endDate, + externalPriceId, + maximumAmount, + minimumAmount, + planPhaseOrder, + price, + priceId, + startDate, + additionalProperties, + ) } override fun hashCode(): Int = hashCode override fun toString() = - "ReplaceAdjustment{adjustment=$adjustment, replacesAdjustmentId=$replacesAdjustmentId, additionalProperties=$additionalProperties}" + "AddPrice{allocationPrice=$allocationPrice, discounts=$discounts, endDate=$endDate, externalPriceId=$externalPriceId, maximumAmount=$maximumAmount, minimumAmount=$minimumAmount, planPhaseOrder=$planPhaseOrder, price=$price, priceId=$priceId, startDate=$startDate, additionalProperties=$additionalProperties}" } - class ReplacePrice - private constructor( - private val replacesPriceId: JsonField, - private val allocationPrice: JsonField, - private val discounts: JsonField>, - private val externalPriceId: JsonField, - private val fixedPriceQuantity: JsonField, - private val maximumAmount: JsonField, - private val minimumAmount: JsonField, - private val price: JsonField, - private val priceId: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("replaces_price_id") - @ExcludeMissing - replacesPriceId: JsonField = JsonMissing.of(), - @JsonProperty("allocation_price") - @ExcludeMissing - allocationPrice: JsonField = JsonMissing.of(), - @JsonProperty("discounts") - @ExcludeMissing - discounts: JsonField> = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("maximum_amount") - @ExcludeMissing - maximumAmount: JsonField = JsonMissing.of(), - @JsonProperty("minimum_amount") - @ExcludeMissing - minimumAmount: JsonField = JsonMissing.of(), - @JsonProperty("price") @ExcludeMissing price: JsonField = JsonMissing.of(), - @JsonProperty("price_id") @ExcludeMissing priceId: JsonField = JsonMissing.of(), - ) : this( - replacesPriceId, - allocationPrice, - discounts, - externalPriceId, - fixedPriceQuantity, - maximumAmount, - minimumAmount, - price, - priceId, - mutableMapOf(), - ) + /** + * Reset billing periods to be aligned with the plan change's effective date or start of the + * month. Defaults to `unchanged` which keeps subscription's existing billing cycle alignment. + */ + class BillingCycleAlignment + @JsonCreator + private constructor(private val value: JsonField) : Enum { /** - * The id of the price on the plan to replace in the subscription. + * Returns this class instance's raw value. * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. */ - fun replacesPriceId(): String = replacesPriceId.getRequired("replaces_price_id") + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - /** - * The definition of a new allocation price to create and add to the subscription. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun allocationPrice(): NewAllocationPrice? = allocationPrice.getNullable("allocation_price") + companion object { + + val UNCHANGED = of("unchanged") + + val PLAN_CHANGE_DATE = of("plan_change_date") + + val START_OF_MONTH = of("start_of_month") + + fun of(value: String) = BillingCycleAlignment(JsonField.of(value)) + } + + /** An enum containing [BillingCycleAlignment]'s known values. */ + enum class Known { + UNCHANGED, + PLAN_CHANGE_DATE, + START_OF_MONTH, + } /** - * [DEPRECATED] Use add_adjustments instead. The subscription's discounts for the - * replacement price. + * An enum containing [BillingCycleAlignment]'s known values, as well as an [_UNKNOWN] + * member. * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). + * An instance of [BillingCycleAlignment] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. */ - @Deprecated("deprecated") - fun discounts(): List? = discounts.getNullable("discounts") + enum class Value { + UNCHANGED, + PLAN_CHANGE_DATE, + START_OF_MONTH, + /** + * An enum member indicating that [BillingCycleAlignment] was instantiated with an + * unknown value. + */ + _UNKNOWN, + } /** - * The external price id of the price to add to the subscription. + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. */ - fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + fun value(): Value = + when (this) { + UNCHANGED -> Value.UNCHANGED + PLAN_CHANGE_DATE -> Value.PLAN_CHANGE_DATE + START_OF_MONTH -> Value.START_OF_MONTH + else -> Value._UNKNOWN + } /** - * The new quantity of the price, if the price is a fixed price. + * Returns an enum member corresponding to this class instance's value. * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known member. */ - fun fixedPriceQuantity(): Double? = fixedPriceQuantity.getNullable("fixed_price_quantity") + fun known(): Known = + when (this) { + UNCHANGED -> Known.UNCHANGED + PLAN_CHANGE_DATE -> Known.PLAN_CHANGE_DATE + START_OF_MONTH -> Known.START_OF_MONTH + else -> throw OrbInvalidDataException("Unknown BillingCycleAlignment: $value") + } /** - * [DEPRECATED] Use add_adjustments instead. The subscription's maximum amount for the - * replacement price. + * Returns this class instance's primitive wire representation. * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the expected + * primitive type. */ - @Deprecated("deprecated") - fun maximumAmount(): String? = maximumAmount.getNullable("maximum_amount") + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") - /** - * [DEPRECATED] Use add_adjustments instead. The subscription's minimum amount for the - * replacement price. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - @Deprecated("deprecated") - fun minimumAmount(): String? = minimumAmount.getNullable("minimum_amount") + private var validated: Boolean = false - /** - * The definition of a new price to create and add to the subscription. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun price(): Price? = price.getNullable("price") + fun validate(): BillingCycleAlignment = apply { + if (validated) { + return@apply + } - /** - * The id of the price to add to the subscription. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun priceId(): String? = priceId.getNullable("price_id") + known() + validated = true + } - /** - * Returns the raw JSON value of [replacesPriceId]. - * - * Unlike [replacesPriceId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("replaces_price_id") - @ExcludeMissing - fun _replacesPriceId(): JsonField = replacesPriceId + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } /** - * Returns the raw JSON value of [allocationPrice]. + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * Unlike [allocationPrice], this method doesn't throw if the JSON field has an unexpected - * type. + * Used for best match union deserialization. */ - @JsonProperty("allocation_price") - @ExcludeMissing - fun _allocationPrice(): JsonField = allocationPrice + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - /** - * Returns the raw JSON value of [discounts]. - * - * Unlike [discounts], this method doesn't throw if the JSON field has an unexpected type. - */ - @Deprecated("deprecated") - @JsonProperty("discounts") - @ExcludeMissing - fun _discounts(): JsonField> = discounts + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * Returns the raw JSON value of [externalPriceId]. - * - * Unlike [externalPriceId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId + return other is BillingCycleAlignment && value == other.value + } - /** - * Returns the raw JSON value of [fixedPriceQuantity]. - * - * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + override fun hashCode() = value.hashCode() - /** - * Returns the raw JSON value of [maximumAmount]. - * - * Unlike [maximumAmount], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @Deprecated("deprecated") - @JsonProperty("maximum_amount") - @ExcludeMissing - fun _maximumAmount(): JsonField = maximumAmount + override fun toString() = value.toString() + } - /** - * Returns the raw JSON value of [minimumAmount]. - * - * Unlike [minimumAmount], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @Deprecated("deprecated") - @JsonProperty("minimum_amount") - @ExcludeMissing - fun _minimumAmount(): JsonField = minimumAmount + class RemoveAdjustment + private constructor( + private val adjustmentId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("adjustment_id") + @ExcludeMissing + adjustmentId: JsonField = JsonMissing.of() + ) : this(adjustmentId, mutableMapOf()) /** - * Returns the raw JSON value of [price]. + * The id of the adjustment to remove on the subscription. * - * Unlike [price], this method doesn't throw if the JSON field has an unexpected type. + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ - @JsonProperty("price") @ExcludeMissing fun _price(): JsonField = price + fun adjustmentId(): String = adjustmentId.getRequired("adjustment_id") /** - * Returns the raw JSON value of [priceId]. + * Returns the raw JSON value of [adjustmentId]. * - * Unlike [priceId], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [adjustmentId], this method doesn't throw if the JSON field has an unexpected + * type. */ - @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId + @JsonProperty("adjustment_id") + @ExcludeMissing + fun _adjustmentId(): JsonField = adjustmentId @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -6991,349 +8921,229 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [ReplacePrice]. + * Returns a mutable builder for constructing an instance of [RemoveAdjustment]. * * The following fields are required: * ```kotlin - * .replacesPriceId() + * .adjustmentId() * ``` */ fun builder() = Builder() } - /** A builder for [ReplacePrice]. */ + /** A builder for [RemoveAdjustment]. */ class Builder internal constructor() { - private var replacesPriceId: JsonField? = null - private var allocationPrice: JsonField = JsonMissing.of() - private var discounts: JsonField>? = null - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var maximumAmount: JsonField = JsonMissing.of() - private var minimumAmount: JsonField = JsonMissing.of() - private var price: JsonField = JsonMissing.of() - private var priceId: JsonField = JsonMissing.of() + private var adjustmentId: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(replacePrice: ReplacePrice) = apply { - replacesPriceId = replacePrice.replacesPriceId - allocationPrice = replacePrice.allocationPrice - discounts = replacePrice.discounts.map { it.toMutableList() } - externalPriceId = replacePrice.externalPriceId - fixedPriceQuantity = replacePrice.fixedPriceQuantity - maximumAmount = replacePrice.maximumAmount - minimumAmount = replacePrice.minimumAmount - price = replacePrice.price - priceId = replacePrice.priceId - additionalProperties = replacePrice.additionalProperties.toMutableMap() + internal fun from(removeAdjustment: RemoveAdjustment) = apply { + adjustmentId = removeAdjustment.adjustmentId + additionalProperties = removeAdjustment.additionalProperties.toMutableMap() } - /** The id of the price on the plan to replace in the subscription. */ - fun replacesPriceId(replacesPriceId: String) = - replacesPriceId(JsonField.of(replacesPriceId)) + /** The id of the adjustment to remove on the subscription. */ + fun adjustmentId(adjustmentId: String) = adjustmentId(JsonField.of(adjustmentId)) /** - * Sets [Builder.replacesPriceId] to an arbitrary JSON value. + * Sets [Builder.adjustmentId] to an arbitrary JSON value. * - * You should usually call [Builder.replacesPriceId] with a well-typed [String] value + * You should usually call [Builder.adjustmentId] with a well-typed [String] value * instead. This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun replacesPriceId(replacesPriceId: JsonField) = apply { - this.replacesPriceId = replacesPriceId + fun adjustmentId(adjustmentId: JsonField) = apply { + this.adjustmentId = adjustmentId } - /** The definition of a new allocation price to create and add to the subscription. */ - fun allocationPrice(allocationPrice: NewAllocationPrice?) = - allocationPrice(JsonField.ofNullable(allocationPrice)) - - /** - * Sets [Builder.allocationPrice] to an arbitrary JSON value. - * - * You should usually call [Builder.allocationPrice] with a well-typed - * [NewAllocationPrice] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun allocationPrice(allocationPrice: JsonField) = apply { - this.allocationPrice = allocationPrice + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) } - /** - * [DEPRECATED] Use add_adjustments instead. The subscription's discounts for the - * replacement price. - */ - @Deprecated("deprecated") - fun discounts(discounts: List?) = - discounts(JsonField.ofNullable(discounts)) - - /** - * Sets [Builder.discounts] to an arbitrary JSON value. - * - * You should usually call [Builder.discounts] with a well-typed - * `List` value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - @Deprecated("deprecated") - fun discounts(discounts: JsonField>) = apply { - this.discounts = discounts.map { it.toMutableList() } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) } - /** - * Adds a single [DiscountOverride] to [discounts]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - @Deprecated("deprecated") - fun addDiscount(discount: DiscountOverride) = apply { - discounts = - (discounts ?: JsonField.of(mutableListOf())).also { - checkKnown("discounts", it).add(discount) - } + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) } - /** The external price id of the price to add to the subscription. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - /** - * Sets [Builder.externalPriceId] to an arbitrary JSON value. - * - * You should usually call [Builder.externalPriceId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun externalPriceId(externalPriceId: JsonField) = apply { - this.externalPriceId = externalPriceId + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) } - /** The new quantity of the price, if the price is a fixed price. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = - fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) - /** - * Alias for [Builder.fixedPriceQuantity]. + * Returns an immutable instance of [RemoveAdjustment]. * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * Further updates to this [Builder] will not mutate the returned instance. * - * You should usually call [Builder.fixedPriceQuantity] with a well-typed [Double] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. + * The following fields are required: + * ```kotlin + * .adjustmentId() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ - fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + fun build(): RemoveAdjustment = + RemoveAdjustment( + checkRequired("adjustmentId", adjustmentId), + additionalProperties.toMutableMap(), + ) + } - /** - * [DEPRECATED] Use add_adjustments instead. The subscription's maximum amount for the - * replacement price. - */ - @Deprecated("deprecated") - fun maximumAmount(maximumAmount: String?) = - maximumAmount(JsonField.ofNullable(maximumAmount)) + private var validated: Boolean = false - /** - * Sets [Builder.maximumAmount] to an arbitrary JSON value. - * - * You should usually call [Builder.maximumAmount] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - @Deprecated("deprecated") - fun maximumAmount(maximumAmount: JsonField) = apply { - this.maximumAmount = maximumAmount + fun validate(): RemoveAdjustment = apply { + if (validated) { + return@apply } - /** - * [DEPRECATED] Use add_adjustments instead. The subscription's minimum amount for the - * replacement price. - */ - @Deprecated("deprecated") - fun minimumAmount(minimumAmount: String?) = - minimumAmount(JsonField.ofNullable(minimumAmount)) + adjustmentId() + validated = true + } - /** - * Sets [Builder.minimumAmount] to an arbitrary JSON value. - * - * You should usually call [Builder.minimumAmount] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - @Deprecated("deprecated") - fun minimumAmount(minimumAmount: JsonField) = apply { - this.minimumAmount = minimumAmount + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false } - /** The definition of a new price to create and add to the subscription. */ - fun price(price: Price?) = price(JsonField.ofNullable(price)) + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = (if (adjustmentId.asKnown() == null) 0 else 1) - /** - * Sets [Builder.price] to an arbitrary JSON value. - * - * You should usually call [Builder.price] with a well-typed [Price] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun price(price: JsonField) = apply { this.price = price } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** Alias for calling [price] with `Price.ofUnit(unit)`. */ - fun price(unit: NewSubscriptionUnitPrice) = price(Price.ofUnit(unit)) + return other is RemoveAdjustment && + adjustmentId == other.adjustmentId && + additionalProperties == other.additionalProperties + } - /** Alias for calling [price] with `Price.ofPackage(package_)`. */ - fun price(package_: NewSubscriptionPackagePrice) = price(Price.ofPackage(package_)) + private val hashCode: Int by lazy { Objects.hash(adjustmentId, additionalProperties) } - /** Alias for calling [price] with `Price.ofMatrix(matrix)`. */ - fun price(matrix: NewSubscriptionMatrixPrice) = price(Price.ofMatrix(matrix)) + override fun hashCode(): Int = hashCode - /** Alias for calling [price] with `Price.ofTiered(tiered)`. */ - fun price(tiered: NewSubscriptionTieredPrice) = price(Price.ofTiered(tiered)) + override fun toString() = + "RemoveAdjustment{adjustmentId=$adjustmentId, additionalProperties=$additionalProperties}" + } - /** Alias for calling [price] with `Price.ofTieredBps(tieredBps)`. */ - fun price(tieredBps: NewSubscriptionTieredBpsPrice) = - price(Price.ofTieredBps(tieredBps)) + class RemovePrice + private constructor( + private val externalPriceId: JsonField, + private val priceId: JsonField, + private val additionalProperties: MutableMap, + ) { - /** Alias for calling [price] with `Price.ofBps(bps)`. */ - fun price(bps: NewSubscriptionBpsPrice) = price(Price.ofBps(bps)) + @JsonCreator + private constructor( + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("price_id") @ExcludeMissing priceId: JsonField = JsonMissing.of(), + ) : this(externalPriceId, priceId, mutableMapOf()) - /** Alias for calling [price] with `Price.ofBulkBps(bulkBps)`. */ - fun price(bulkBps: NewSubscriptionBulkBpsPrice) = price(Price.ofBulkBps(bulkBps)) + /** + * The external price id of the price to remove on the subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") - /** Alias for calling [price] with `Price.ofBulk(bulk)`. */ - fun price(bulk: NewSubscriptionBulkPrice) = price(Price.ofBulk(bulk)) + /** + * The id of the price to remove on the subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun priceId(): String? = priceId.getNullable("price_id") - /** - * Alias for calling [price] with `Price.ofThresholdTotalAmount(thresholdTotalAmount)`. - */ - fun price(thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice) = - price(Price.ofThresholdTotalAmount(thresholdTotalAmount)) + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId - /** Alias for calling [price] with `Price.ofTieredPackage(tieredPackage)`. */ - fun price(tieredPackage: NewSubscriptionTieredPackagePrice) = - price(Price.ofTieredPackage(tieredPackage)) + /** + * Returns the raw JSON value of [priceId]. + * + * Unlike [priceId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId - /** Alias for calling [price] with `Price.ofTieredWithMinimum(tieredWithMinimum)`. */ - fun price(tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice) = - price(Price.ofTieredWithMinimum(tieredWithMinimum)) + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - /** Alias for calling [price] with `Price.ofUnitWithPercent(unitWithPercent)`. */ - fun price(unitWithPercent: NewSubscriptionUnitWithPercentPrice) = - price(Price.ofUnitWithPercent(unitWithPercent)) + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - /** - * Alias for calling [price] with - * `Price.ofPackageWithAllocation(packageWithAllocation)`. - */ - fun price(packageWithAllocation: NewSubscriptionPackageWithAllocationPrice) = - price(Price.ofPackageWithAllocation(packageWithAllocation)) + fun toBuilder() = Builder().from(this) - /** - * Alias for calling [price] with `Price.ofTieredWithProration(tieredWithProration)`. - */ - fun price(tieredWithProration: NewSubscriptionTierWithProrationPrice) = - price(Price.ofTieredWithProration(tieredWithProration)) + companion object { - /** Alias for calling [price] with `Price.ofUnitWithProration(unitWithProration)`. */ - fun price(unitWithProration: NewSubscriptionUnitWithProrationPrice) = - price(Price.ofUnitWithProration(unitWithProration)) + /** Returns a mutable builder for constructing an instance of [RemovePrice]. */ + fun builder() = Builder() + } - /** Alias for calling [price] with `Price.ofGroupedAllocation(groupedAllocation)`. */ - fun price(groupedAllocation: NewSubscriptionGroupedAllocationPrice) = - price(Price.ofGroupedAllocation(groupedAllocation)) + /** A builder for [RemovePrice]. */ + class Builder internal constructor() { - /** - * Alias for calling [price] with - * `Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)`. - */ - fun price(groupedWithProratedMinimum: NewSubscriptionGroupedWithProratedMinimumPrice) = - price(Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)) + private var externalPriceId: JsonField = JsonMissing.of() + private var priceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - /** Alias for calling [price] with `Price.ofBulkWithProration(bulkWithProration)`. */ - fun price(bulkWithProration: NewSubscriptionBulkWithProrationPrice) = - price(Price.ofBulkWithProration(bulkWithProration)) + internal fun from(removePrice: RemovePrice) = apply { + externalPriceId = removePrice.externalPriceId + priceId = removePrice.priceId + additionalProperties = removePrice.additionalProperties.toMutableMap() + } - /** - * Alias for calling [price] with - * `Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)`. - */ - fun price( - scalableMatrixWithUnitPricing: NewSubscriptionScalableMatrixWithUnitPricingPrice - ) = price(Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)) + /** The external price id of the price to remove on the subscription. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) /** - * Alias for calling [price] with - * `Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)`. + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun price( - scalableMatrixWithTieredPricing: NewSubscriptionScalableMatrixWithTieredPricingPrice - ) = price(Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)) + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } - /** - * Alias for calling [price] with - * `Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)`. - */ - fun price(cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice) = - price(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) + /** The id of the price to remove on the subscription. */ + fun priceId(priceId: String?) = priceId(JsonField.ofNullable(priceId)) /** - * Alias for calling [price] with - * `Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)`. + * Sets [Builder.priceId] to an arbitrary JSON value. + * + * You should usually call [Builder.priceId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun price(maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice) = - price(Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)) - - /** - * Alias for calling [price] with - * `Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)`. - */ - fun price(groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice) = - price(Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)) - - /** - * Alias for calling [price] with - * `Price.ofMatrixWithDisplayName(matrixWithDisplayName)`. - */ - fun price(matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice) = - price(Price.ofMatrixWithDisplayName(matrixWithDisplayName)) - - /** - * Alias for calling [price] with `Price.ofGroupedTieredPackage(groupedTieredPackage)`. - */ - fun price(groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice) = - price(Price.ofGroupedTieredPackage(groupedTieredPackage)) - - /** - * Alias for calling [price] with `Price.ofMatrixWithAllocation(matrixWithAllocation)`. - */ - fun price(matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice) = - price(Price.ofMatrixWithAllocation(matrixWithAllocation)) - - /** - * Alias for calling [price] with - * `Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)`. - */ - fun price(tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice) = - price(Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)) - - /** Alias for calling [price] with `Price.ofGroupedTiered(groupedTiered)`. */ - fun price(groupedTiered: NewSubscriptionGroupedTieredPrice) = - price(Price.ofGroupedTiered(groupedTiered)) - - /** The id of the price to add to the subscription. */ - fun priceId(priceId: String?) = priceId(JsonField.ofNullable(priceId)) - - /** - * Sets [Builder.priceId] to an arbitrary JSON value. - * - * You should usually call [Builder.priceId] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun priceId(priceId: JsonField) = apply { this.priceId = priceId } + fun priceId(priceId: JsonField) = apply { this.priceId = priceId } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -7355,47 +9165,22 @@ private constructor( } /** - * Returns an immutable instance of [ReplacePrice]. + * Returns an immutable instance of [RemovePrice]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```kotlin - * .replacesPriceId() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ - fun build(): ReplacePrice = - ReplacePrice( - checkRequired("replacesPriceId", replacesPriceId), - allocationPrice, - (discounts ?: JsonMissing.of()).map { it.toImmutable() }, - externalPriceId, - fixedPriceQuantity, - maximumAmount, - minimumAmount, - price, - priceId, - additionalProperties.toMutableMap(), - ) + fun build(): RemovePrice = + RemovePrice(externalPriceId, priceId, additionalProperties.toMutableMap()) } private var validated: Boolean = false - fun validate(): ReplacePrice = apply { + fun validate(): RemovePrice = apply { if (validated) { return@apply } - replacesPriceId() - allocationPrice()?.validate() - discounts()?.forEach { it.validate() } externalPriceId() - fixedPriceQuantity() - maximumAmount() - minimumAmount() - price()?.validate() priceId() validated = true } @@ -7415,1208 +9200,5479 @@ private constructor( * Used for best match union deserialization. */ internal fun validity(): Int = - (if (replacesPriceId.asKnown() == null) 0 else 1) + - (allocationPrice.asKnown()?.validity() ?: 0) + - (discounts.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + - (if (externalPriceId.asKnown() == null) 0 else 1) + - (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + - (if (maximumAmount.asKnown() == null) 0 else 1) + - (if (minimumAmount.asKnown() == null) 0 else 1) + - (price.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + (if (priceId.asKnown() == null) 0 else 1) - /** The definition of a new price to create and add to the subscription. */ - @JsonDeserialize(using = Price.Deserializer::class) - @JsonSerialize(using = Price.Serializer::class) - class Price - private constructor( - private val unit: NewSubscriptionUnitPrice? = null, - private val package_: NewSubscriptionPackagePrice? = null, - private val matrix: NewSubscriptionMatrixPrice? = null, - private val tiered: NewSubscriptionTieredPrice? = null, - private val tieredBps: NewSubscriptionTieredBpsPrice? = null, - private val bps: NewSubscriptionBpsPrice? = null, - private val bulkBps: NewSubscriptionBulkBpsPrice? = null, - private val bulk: NewSubscriptionBulkPrice? = null, - private val thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice? = null, - private val tieredPackage: NewSubscriptionTieredPackagePrice? = null, - private val tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice? = null, - private val unitWithPercent: NewSubscriptionUnitWithPercentPrice? = null, - private val packageWithAllocation: NewSubscriptionPackageWithAllocationPrice? = null, - private val tieredWithProration: NewSubscriptionTierWithProrationPrice? = null, - private val unitWithProration: NewSubscriptionUnitWithProrationPrice? = null, - private val groupedAllocation: NewSubscriptionGroupedAllocationPrice? = null, - private val groupedWithProratedMinimum: - NewSubscriptionGroupedWithProratedMinimumPrice? = - null, - private val bulkWithProration: NewSubscriptionBulkWithProrationPrice? = null, - private val scalableMatrixWithUnitPricing: - NewSubscriptionScalableMatrixWithUnitPricingPrice? = - null, - private val scalableMatrixWithTieredPricing: - NewSubscriptionScalableMatrixWithTieredPricingPrice? = - null, - private val cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice? = null, - private val maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice? = null, - private val groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice? = - null, - private val matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice? = null, - private val groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice? = null, - private val matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice? = null, - private val tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice? = - null, - private val groupedTiered: NewSubscriptionGroupedTieredPrice? = null, - private val _json: JsonValue? = null, - ) { - - fun unit(): NewSubscriptionUnitPrice? = unit - - fun package_(): NewSubscriptionPackagePrice? = package_ - - fun matrix(): NewSubscriptionMatrixPrice? = matrix + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun tiered(): NewSubscriptionTieredPrice? = tiered + return other is RemovePrice && + externalPriceId == other.externalPriceId && + priceId == other.priceId && + additionalProperties == other.additionalProperties + } - fun tieredBps(): NewSubscriptionTieredBpsPrice? = tieredBps + private val hashCode: Int by lazy { + Objects.hash(externalPriceId, priceId, additionalProperties) + } - fun bps(): NewSubscriptionBpsPrice? = bps + override fun hashCode(): Int = hashCode - fun bulkBps(): NewSubscriptionBulkBpsPrice? = bulkBps + override fun toString() = + "RemovePrice{externalPriceId=$externalPriceId, priceId=$priceId, additionalProperties=$additionalProperties}" + } - fun bulk(): NewSubscriptionBulkPrice? = bulk + class ReplaceAdjustment + private constructor( + private val adjustment: JsonField, + private val replacesAdjustmentId: JsonField, + private val additionalProperties: MutableMap, + ) { - fun thresholdTotalAmount(): NewSubscriptionThresholdTotalAmountPrice? = - thresholdTotalAmount + @JsonCreator + private constructor( + @JsonProperty("adjustment") + @ExcludeMissing + adjustment: JsonField = JsonMissing.of(), + @JsonProperty("replaces_adjustment_id") + @ExcludeMissing + replacesAdjustmentId: JsonField = JsonMissing.of(), + ) : this(adjustment, replacesAdjustmentId, mutableMapOf()) - fun tieredPackage(): NewSubscriptionTieredPackagePrice? = tieredPackage + /** + * The definition of a new adjustment to create and add to the subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun adjustment(): Adjustment = adjustment.getRequired("adjustment") - fun tieredWithMinimum(): NewSubscriptionTieredWithMinimumPrice? = tieredWithMinimum + /** + * The id of the adjustment on the plan to replace in the subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun replacesAdjustmentId(): String = + replacesAdjustmentId.getRequired("replaces_adjustment_id") - fun unitWithPercent(): NewSubscriptionUnitWithPercentPrice? = unitWithPercent + /** + * Returns the raw JSON value of [adjustment]. + * + * Unlike [adjustment], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("adjustment") + @ExcludeMissing + fun _adjustment(): JsonField = adjustment - fun packageWithAllocation(): NewSubscriptionPackageWithAllocationPrice? = - packageWithAllocation + /** + * Returns the raw JSON value of [replacesAdjustmentId]. + * + * Unlike [replacesAdjustmentId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("replaces_adjustment_id") + @ExcludeMissing + fun _replacesAdjustmentId(): JsonField = replacesAdjustmentId - fun tieredWithProration(): NewSubscriptionTierWithProrationPrice? = tieredWithProration + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - fun unitWithProration(): NewSubscriptionUnitWithProrationPrice? = unitWithProration + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - fun groupedAllocation(): NewSubscriptionGroupedAllocationPrice? = groupedAllocation + fun toBuilder() = Builder().from(this) - fun groupedWithProratedMinimum(): NewSubscriptionGroupedWithProratedMinimumPrice? = - groupedWithProratedMinimum + companion object { - fun bulkWithProration(): NewSubscriptionBulkWithProrationPrice? = bulkWithProration + /** + * Returns a mutable builder for constructing an instance of [ReplaceAdjustment]. + * + * The following fields are required: + * ```kotlin + * .adjustment() + * .replacesAdjustmentId() + * ``` + */ + fun builder() = Builder() + } - fun scalableMatrixWithUnitPricing(): - NewSubscriptionScalableMatrixWithUnitPricingPrice? = scalableMatrixWithUnitPricing + /** A builder for [ReplaceAdjustment]. */ + class Builder internal constructor() { - fun scalableMatrixWithTieredPricing(): - NewSubscriptionScalableMatrixWithTieredPricingPrice? = - scalableMatrixWithTieredPricing + private var adjustment: JsonField? = null + private var replacesAdjustmentId: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() - fun cumulativeGroupedBulk(): NewSubscriptionCumulativeGroupedBulkPrice? = - cumulativeGroupedBulk + internal fun from(replaceAdjustment: ReplaceAdjustment) = apply { + adjustment = replaceAdjustment.adjustment + replacesAdjustmentId = replaceAdjustment.replacesAdjustmentId + additionalProperties = replaceAdjustment.additionalProperties.toMutableMap() + } - fun maxGroupTieredPackage(): NewSubscriptionMaxGroupTieredPackagePrice? = - maxGroupTieredPackage + /** The definition of a new adjustment to create and add to the subscription. */ + fun adjustment(adjustment: Adjustment) = adjustment(JsonField.of(adjustment)) - fun groupedWithMeteredMinimum(): NewSubscriptionGroupedWithMeteredMinimumPrice? = - groupedWithMeteredMinimum - - fun matrixWithDisplayName(): NewSubscriptionMatrixWithDisplayNamePrice? = - matrixWithDisplayName + /** + * Sets [Builder.adjustment] to an arbitrary JSON value. + * + * You should usually call [Builder.adjustment] with a well-typed [Adjustment] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun adjustment(adjustment: JsonField) = apply { + this.adjustment = adjustment + } - fun groupedTieredPackage(): NewSubscriptionGroupedTieredPackagePrice? = - groupedTieredPackage + /** + * Alias for calling [adjustment] with + * `Adjustment.ofPercentageDiscount(percentageDiscount)`. + */ + fun adjustment(percentageDiscount: NewPercentageDiscount) = + adjustment(Adjustment.ofPercentageDiscount(percentageDiscount)) - fun matrixWithAllocation(): NewSubscriptionMatrixWithAllocationPrice? = - matrixWithAllocation + /** + * Alias for calling [adjustment] with the following: + * ```kotlin + * NewPercentageDiscount.builder() + * .adjustmentType(NewPercentageDiscount.AdjustmentType.PERCENTAGE_DISCOUNT) + * .percentageDiscount(percentageDiscount) + * .build() + * ``` + */ + fun percentageDiscountAdjustment(percentageDiscount: Double) = + adjustment( + NewPercentageDiscount.builder() + .adjustmentType(NewPercentageDiscount.AdjustmentType.PERCENTAGE_DISCOUNT) + .percentageDiscount(percentageDiscount) + .build() + ) - fun tieredPackageWithMinimum(): NewSubscriptionTieredPackageWithMinimumPrice? = - tieredPackageWithMinimum + /** Alias for calling [adjustment] with `Adjustment.ofUsageDiscount(usageDiscount)`. */ + fun adjustment(usageDiscount: NewUsageDiscount) = + adjustment(Adjustment.ofUsageDiscount(usageDiscount)) - fun groupedTiered(): NewSubscriptionGroupedTieredPrice? = groupedTiered + /** + * Alias for calling [adjustment] with the following: + * ```kotlin + * NewUsageDiscount.builder() + * .adjustmentType(NewUsageDiscount.AdjustmentType.USAGE_DISCOUNT) + * .usageDiscount(usageDiscount) + * .build() + * ``` + */ + fun usageDiscountAdjustment(usageDiscount: Double) = + adjustment( + NewUsageDiscount.builder() + .adjustmentType(NewUsageDiscount.AdjustmentType.USAGE_DISCOUNT) + .usageDiscount(usageDiscount) + .build() + ) - fun isUnit(): Boolean = unit != null + /** + * Alias for calling [adjustment] with `Adjustment.ofAmountDiscount(amountDiscount)`. + */ + fun adjustment(amountDiscount: NewAmountDiscount) = + adjustment(Adjustment.ofAmountDiscount(amountDiscount)) - fun isPackage(): Boolean = package_ != null + /** + * Alias for calling [adjustment] with the following: + * ```kotlin + * NewAmountDiscount.builder() + * .adjustmentType(NewAmountDiscount.AdjustmentType.AMOUNT_DISCOUNT) + * .amountDiscount(amountDiscount) + * .build() + * ``` + */ + fun amountDiscountAdjustment(amountDiscount: String) = + adjustment( + NewAmountDiscount.builder() + .adjustmentType(NewAmountDiscount.AdjustmentType.AMOUNT_DISCOUNT) + .amountDiscount(amountDiscount) + .build() + ) - fun isMatrix(): Boolean = matrix != null + /** Alias for calling [adjustment] with `Adjustment.ofMinimum(minimum)`. */ + fun adjustment(minimum: NewMinimum) = adjustment(Adjustment.ofMinimum(minimum)) - fun isTiered(): Boolean = tiered != null + /** Alias for calling [adjustment] with `Adjustment.ofMaximum(maximum)`. */ + fun adjustment(maximum: NewMaximum) = adjustment(Adjustment.ofMaximum(maximum)) - fun isTieredBps(): Boolean = tieredBps != null + /** + * Alias for calling [adjustment] with the following: + * ```kotlin + * NewMaximum.builder() + * .adjustmentType(NewMaximum.AdjustmentType.MAXIMUM) + * .maximumAmount(maximumAmount) + * .build() + * ``` + */ + fun maximumAdjustment(maximumAmount: String) = + adjustment( + NewMaximum.builder() + .adjustmentType(NewMaximum.AdjustmentType.MAXIMUM) + .maximumAmount(maximumAmount) + .build() + ) - fun isBps(): Boolean = bps != null + /** The id of the adjustment on the plan to replace in the subscription. */ + fun replacesAdjustmentId(replacesAdjustmentId: String) = + replacesAdjustmentId(JsonField.of(replacesAdjustmentId)) - fun isBulkBps(): Boolean = bulkBps != null + /** + * Sets [Builder.replacesAdjustmentId] to an arbitrary JSON value. + * + * You should usually call [Builder.replacesAdjustmentId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun replacesAdjustmentId(replacesAdjustmentId: JsonField) = apply { + this.replacesAdjustmentId = replacesAdjustmentId + } - fun isBulk(): Boolean = bulk != null + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun isThresholdTotalAmount(): Boolean = thresholdTotalAmount != null + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun isTieredPackage(): Boolean = tieredPackage != null + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun isTieredWithMinimum(): Boolean = tieredWithMinimum != null + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - fun isUnitWithPercent(): Boolean = unitWithPercent != null + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - fun isPackageWithAllocation(): Boolean = packageWithAllocation != null + /** + * Returns an immutable instance of [ReplaceAdjustment]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .adjustment() + * .replacesAdjustmentId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ReplaceAdjustment = + ReplaceAdjustment( + checkRequired("adjustment", adjustment), + checkRequired("replacesAdjustmentId", replacesAdjustmentId), + additionalProperties.toMutableMap(), + ) + } - fun isTieredWithProration(): Boolean = tieredWithProration != null + private var validated: Boolean = false - fun isUnitWithProration(): Boolean = unitWithProration != null + fun validate(): ReplaceAdjustment = apply { + if (validated) { + return@apply + } - fun isGroupedAllocation(): Boolean = groupedAllocation != null + adjustment().validate() + replacesAdjustmentId() + validated = true + } - fun isGroupedWithProratedMinimum(): Boolean = groupedWithProratedMinimum != null + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - fun isBulkWithProration(): Boolean = bulkWithProration != null + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (adjustment.asKnown()?.validity() ?: 0) + + (if (replacesAdjustmentId.asKnown() == null) 0 else 1) - fun isScalableMatrixWithUnitPricing(): Boolean = scalableMatrixWithUnitPricing != null + /** The definition of a new adjustment to create and add to the subscription. */ + @JsonDeserialize(using = Adjustment.Deserializer::class) + @JsonSerialize(using = Adjustment.Serializer::class) + class Adjustment + private constructor( + private val percentageDiscount: NewPercentageDiscount? = null, + private val usageDiscount: NewUsageDiscount? = null, + private val amountDiscount: NewAmountDiscount? = null, + private val minimum: NewMinimum? = null, + private val maximum: NewMaximum? = null, + private val _json: JsonValue? = null, + ) { - fun isScalableMatrixWithTieredPricing(): Boolean = - scalableMatrixWithTieredPricing != null + fun percentageDiscount(): NewPercentageDiscount? = percentageDiscount - fun isCumulativeGroupedBulk(): Boolean = cumulativeGroupedBulk != null + fun usageDiscount(): NewUsageDiscount? = usageDiscount - fun isMaxGroupTieredPackage(): Boolean = maxGroupTieredPackage != null + fun amountDiscount(): NewAmountDiscount? = amountDiscount - fun isGroupedWithMeteredMinimum(): Boolean = groupedWithMeteredMinimum != null + fun minimum(): NewMinimum? = minimum - fun isMatrixWithDisplayName(): Boolean = matrixWithDisplayName != null + fun maximum(): NewMaximum? = maximum - fun isGroupedTieredPackage(): Boolean = groupedTieredPackage != null + fun isPercentageDiscount(): Boolean = percentageDiscount != null - fun isMatrixWithAllocation(): Boolean = matrixWithAllocation != null + fun isUsageDiscount(): Boolean = usageDiscount != null - fun isTieredPackageWithMinimum(): Boolean = tieredPackageWithMinimum != null + fun isAmountDiscount(): Boolean = amountDiscount != null - fun isGroupedTiered(): Boolean = groupedTiered != null + fun isMinimum(): Boolean = minimum != null - fun asUnit(): NewSubscriptionUnitPrice = unit.getOrThrow("unit") + fun isMaximum(): Boolean = maximum != null - fun asPackage(): NewSubscriptionPackagePrice = package_.getOrThrow("package_") + fun asPercentageDiscount(): NewPercentageDiscount = + percentageDiscount.getOrThrow("percentageDiscount") - fun asMatrix(): NewSubscriptionMatrixPrice = matrix.getOrThrow("matrix") + fun asUsageDiscount(): NewUsageDiscount = usageDiscount.getOrThrow("usageDiscount") - fun asTiered(): NewSubscriptionTieredPrice = tiered.getOrThrow("tiered") + fun asAmountDiscount(): NewAmountDiscount = amountDiscount.getOrThrow("amountDiscount") - fun asTieredBps(): NewSubscriptionTieredBpsPrice = tieredBps.getOrThrow("tieredBps") + fun asMinimum(): NewMinimum = minimum.getOrThrow("minimum") - fun asBps(): NewSubscriptionBpsPrice = bps.getOrThrow("bps") + fun asMaximum(): NewMaximum = maximum.getOrThrow("maximum") - fun asBulkBps(): NewSubscriptionBulkBpsPrice = bulkBps.getOrThrow("bulkBps") + fun _json(): JsonValue? = _json - fun asBulk(): NewSubscriptionBulkPrice = bulk.getOrThrow("bulk") + fun accept(visitor: Visitor): T = + when { + percentageDiscount != null -> + visitor.visitPercentageDiscount(percentageDiscount) + usageDiscount != null -> visitor.visitUsageDiscount(usageDiscount) + amountDiscount != null -> visitor.visitAmountDiscount(amountDiscount) + minimum != null -> visitor.visitMinimum(minimum) + maximum != null -> visitor.visitMaximum(maximum) + else -> visitor.unknown(_json) + } - fun asThresholdTotalAmount(): NewSubscriptionThresholdTotalAmountPrice = - thresholdTotalAmount.getOrThrow("thresholdTotalAmount") + private var validated: Boolean = false - fun asTieredPackage(): NewSubscriptionTieredPackagePrice = - tieredPackage.getOrThrow("tieredPackage") + fun validate(): Adjustment = apply { + if (validated) { + return@apply + } - fun asTieredWithMinimum(): NewSubscriptionTieredWithMinimumPrice = - tieredWithMinimum.getOrThrow("tieredWithMinimum") - - fun asUnitWithPercent(): NewSubscriptionUnitWithPercentPrice = - unitWithPercent.getOrThrow("unitWithPercent") - - fun asPackageWithAllocation(): NewSubscriptionPackageWithAllocationPrice = - packageWithAllocation.getOrThrow("packageWithAllocation") - - fun asTieredWithProration(): NewSubscriptionTierWithProrationPrice = - tieredWithProration.getOrThrow("tieredWithProration") - - fun asUnitWithProration(): NewSubscriptionUnitWithProrationPrice = - unitWithProration.getOrThrow("unitWithProration") + accept( + object : Visitor { + override fun visitPercentageDiscount( + percentageDiscount: NewPercentageDiscount + ) { + percentageDiscount.validate() + } - fun asGroupedAllocation(): NewSubscriptionGroupedAllocationPrice = - groupedAllocation.getOrThrow("groupedAllocation") + override fun visitUsageDiscount(usageDiscount: NewUsageDiscount) { + usageDiscount.validate() + } - fun asGroupedWithProratedMinimum(): NewSubscriptionGroupedWithProratedMinimumPrice = - groupedWithProratedMinimum.getOrThrow("groupedWithProratedMinimum") + override fun visitAmountDiscount(amountDiscount: NewAmountDiscount) { + amountDiscount.validate() + } - fun asBulkWithProration(): NewSubscriptionBulkWithProrationPrice = - bulkWithProration.getOrThrow("bulkWithProration") + override fun visitMinimum(minimum: NewMinimum) { + minimum.validate() + } - fun asScalableMatrixWithUnitPricing(): - NewSubscriptionScalableMatrixWithUnitPricingPrice = - scalableMatrixWithUnitPricing.getOrThrow("scalableMatrixWithUnitPricing") + override fun visitMaximum(maximum: NewMaximum) { + maximum.validate() + } + } + ) + validated = true + } - fun asScalableMatrixWithTieredPricing(): - NewSubscriptionScalableMatrixWithTieredPricingPrice = - scalableMatrixWithTieredPricing.getOrThrow("scalableMatrixWithTieredPricing") + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - fun asCumulativeGroupedBulk(): NewSubscriptionCumulativeGroupedBulkPrice = - cumulativeGroupedBulk.getOrThrow("cumulativeGroupedBulk") + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitPercentageDiscount( + percentageDiscount: NewPercentageDiscount + ) = percentageDiscount.validity() - fun asMaxGroupTieredPackage(): NewSubscriptionMaxGroupTieredPackagePrice = - maxGroupTieredPackage.getOrThrow("maxGroupTieredPackage") + override fun visitUsageDiscount(usageDiscount: NewUsageDiscount) = + usageDiscount.validity() - fun asGroupedWithMeteredMinimum(): NewSubscriptionGroupedWithMeteredMinimumPrice = - groupedWithMeteredMinimum.getOrThrow("groupedWithMeteredMinimum") + override fun visitAmountDiscount(amountDiscount: NewAmountDiscount) = + amountDiscount.validity() - fun asMatrixWithDisplayName(): NewSubscriptionMatrixWithDisplayNamePrice = - matrixWithDisplayName.getOrThrow("matrixWithDisplayName") + override fun visitMinimum(minimum: NewMinimum) = minimum.validity() - fun asGroupedTieredPackage(): NewSubscriptionGroupedTieredPackagePrice = - groupedTieredPackage.getOrThrow("groupedTieredPackage") + override fun visitMaximum(maximum: NewMaximum) = maximum.validity() - fun asMatrixWithAllocation(): NewSubscriptionMatrixWithAllocationPrice = - matrixWithAllocation.getOrThrow("matrixWithAllocation") + override fun unknown(json: JsonValue?) = 0 + } + ) - fun asTieredPackageWithMinimum(): NewSubscriptionTieredPackageWithMinimumPrice = - tieredPackageWithMinimum.getOrThrow("tieredPackageWithMinimum") + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun asGroupedTiered(): NewSubscriptionGroupedTieredPrice = - groupedTiered.getOrThrow("groupedTiered") + return other is Adjustment && + percentageDiscount == other.percentageDiscount && + usageDiscount == other.usageDiscount && + amountDiscount == other.amountDiscount && + minimum == other.minimum && + maximum == other.maximum + } - fun _json(): JsonValue? = _json + override fun hashCode(): Int = + Objects.hash(percentageDiscount, usageDiscount, amountDiscount, minimum, maximum) - fun accept(visitor: Visitor): T = + override fun toString(): String = when { - unit != null -> visitor.visitUnit(unit) - package_ != null -> visitor.visitPackage(package_) - matrix != null -> visitor.visitMatrix(matrix) - tiered != null -> visitor.visitTiered(tiered) - tieredBps != null -> visitor.visitTieredBps(tieredBps) - bps != null -> visitor.visitBps(bps) - bulkBps != null -> visitor.visitBulkBps(bulkBps) - bulk != null -> visitor.visitBulk(bulk) - thresholdTotalAmount != null -> - visitor.visitThresholdTotalAmount(thresholdTotalAmount) - tieredPackage != null -> visitor.visitTieredPackage(tieredPackage) - tieredWithMinimum != null -> visitor.visitTieredWithMinimum(tieredWithMinimum) - unitWithPercent != null -> visitor.visitUnitWithPercent(unitWithPercent) - packageWithAllocation != null -> - visitor.visitPackageWithAllocation(packageWithAllocation) - tieredWithProration != null -> - visitor.visitTieredWithProration(tieredWithProration) - unitWithProration != null -> visitor.visitUnitWithProration(unitWithProration) - groupedAllocation != null -> visitor.visitGroupedAllocation(groupedAllocation) - groupedWithProratedMinimum != null -> - visitor.visitGroupedWithProratedMinimum(groupedWithProratedMinimum) - bulkWithProration != null -> visitor.visitBulkWithProration(bulkWithProration) - scalableMatrixWithUnitPricing != null -> - visitor.visitScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing) - scalableMatrixWithTieredPricing != null -> - visitor.visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing - ) - cumulativeGroupedBulk != null -> - visitor.visitCumulativeGroupedBulk(cumulativeGroupedBulk) - maxGroupTieredPackage != null -> - visitor.visitMaxGroupTieredPackage(maxGroupTieredPackage) - groupedWithMeteredMinimum != null -> - visitor.visitGroupedWithMeteredMinimum(groupedWithMeteredMinimum) - matrixWithDisplayName != null -> - visitor.visitMatrixWithDisplayName(matrixWithDisplayName) - groupedTieredPackage != null -> - visitor.visitGroupedTieredPackage(groupedTieredPackage) - matrixWithAllocation != null -> - visitor.visitMatrixWithAllocation(matrixWithAllocation) - tieredPackageWithMinimum != null -> - visitor.visitTieredPackageWithMinimum(tieredPackageWithMinimum) - groupedTiered != null -> visitor.visitGroupedTiered(groupedTiered) - else -> visitor.unknown(_json) + percentageDiscount != null -> + "Adjustment{percentageDiscount=$percentageDiscount}" + usageDiscount != null -> "Adjustment{usageDiscount=$usageDiscount}" + amountDiscount != null -> "Adjustment{amountDiscount=$amountDiscount}" + minimum != null -> "Adjustment{minimum=$minimum}" + maximum != null -> "Adjustment{maximum=$maximum}" + _json != null -> "Adjustment{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Adjustment") } - private var validated: Boolean = false + companion object { - fun validate(): Price = apply { - if (validated) { - return@apply - } + fun ofPercentageDiscount(percentageDiscount: NewPercentageDiscount) = + Adjustment(percentageDiscount = percentageDiscount) - accept( - object : Visitor { - override fun visitUnit(unit: NewSubscriptionUnitPrice) { - unit.validate() - } + fun ofUsageDiscount(usageDiscount: NewUsageDiscount) = + Adjustment(usageDiscount = usageDiscount) - override fun visitPackage(package_: NewSubscriptionPackagePrice) { - package_.validate() - } + fun ofAmountDiscount(amountDiscount: NewAmountDiscount) = + Adjustment(amountDiscount = amountDiscount) - override fun visitMatrix(matrix: NewSubscriptionMatrixPrice) { - matrix.validate() - } + fun ofMinimum(minimum: NewMinimum) = Adjustment(minimum = minimum) - override fun visitTiered(tiered: NewSubscriptionTieredPrice) { - tiered.validate() - } + fun ofMaximum(maximum: NewMaximum) = Adjustment(maximum = maximum) + } - override fun visitTieredBps(tieredBps: NewSubscriptionTieredBpsPrice) { - tieredBps.validate() - } + /** + * An interface that defines how to map each variant of [Adjustment] to a value of type + * [T]. + */ + interface Visitor { - override fun visitBps(bps: NewSubscriptionBpsPrice) { - bps.validate() - } + fun visitPercentageDiscount(percentageDiscount: NewPercentageDiscount): T - override fun visitBulkBps(bulkBps: NewSubscriptionBulkBpsPrice) { - bulkBps.validate() - } + fun visitUsageDiscount(usageDiscount: NewUsageDiscount): T - override fun visitBulk(bulk: NewSubscriptionBulkPrice) { - bulk.validate() - } + fun visitAmountDiscount(amountDiscount: NewAmountDiscount): T - override fun visitThresholdTotalAmount( - thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice - ) { - thresholdTotalAmount.validate() - } + fun visitMinimum(minimum: NewMinimum): T - override fun visitTieredPackage( - tieredPackage: NewSubscriptionTieredPackagePrice - ) { - tieredPackage.validate() - } + fun visitMaximum(maximum: NewMaximum): T - override fun visitTieredWithMinimum( - tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice - ) { - tieredWithMinimum.validate() - } + /** + * Maps an unknown variant of [Adjustment] to a value of type [T]. + * + * An instance of [Adjustment] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the + * SDK is unaware of. + * + * @throws OrbInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw OrbInvalidDataException("Unknown Adjustment: $json") + } + } - override fun visitUnitWithPercent( - unitWithPercent: NewSubscriptionUnitWithPercentPrice - ) { - unitWithPercent.validate() - } + internal class Deserializer : BaseDeserializer(Adjustment::class) { - override fun visitPackageWithAllocation( - packageWithAllocation: NewSubscriptionPackageWithAllocationPrice - ) { - packageWithAllocation.validate() - } + override fun ObjectCodec.deserialize(node: JsonNode): Adjustment { + val json = JsonValue.fromJsonNode(node) + val adjustmentType = json.asObject()?.get("adjustment_type")?.asString() - override fun visitTieredWithProration( - tieredWithProration: NewSubscriptionTierWithProrationPrice - ) { - tieredWithProration.validate() + when (adjustmentType) { + "percentage_discount" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Adjustment(percentageDiscount = it, _json = json) } + ?: Adjustment(_json = json) } - - override fun visitUnitWithProration( - unitWithProration: NewSubscriptionUnitWithProrationPrice - ) { - unitWithProration.validate() - } - - override fun visitGroupedAllocation( - groupedAllocation: NewSubscriptionGroupedAllocationPrice - ) { - groupedAllocation.validate() - } - - override fun visitGroupedWithProratedMinimum( - groupedWithProratedMinimum: - NewSubscriptionGroupedWithProratedMinimumPrice - ) { - groupedWithProratedMinimum.validate() - } - - override fun visitBulkWithProration( - bulkWithProration: NewSubscriptionBulkWithProrationPrice - ) { - bulkWithProration.validate() - } - - override fun visitScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: - NewSubscriptionScalableMatrixWithUnitPricingPrice - ) { - scalableMatrixWithUnitPricing.validate() - } - - override fun visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: - NewSubscriptionScalableMatrixWithTieredPricingPrice - ) { - scalableMatrixWithTieredPricing.validate() - } - - override fun visitCumulativeGroupedBulk( - cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice - ) { - cumulativeGroupedBulk.validate() - } - - override fun visitMaxGroupTieredPackage( - maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice - ) { - maxGroupTieredPackage.validate() + "usage_discount" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(usageDiscount = it, _json = json) + } ?: Adjustment(_json = json) } - - override fun visitGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice - ) { - groupedWithMeteredMinimum.validate() + "amount_discount" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(amountDiscount = it, _json = json) + } ?: Adjustment(_json = json) } - - override fun visitMatrixWithDisplayName( - matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice - ) { - matrixWithDisplayName.validate() + "minimum" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(minimum = it, _json = json) + } ?: Adjustment(_json = json) } - - override fun visitGroupedTieredPackage( - groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice - ) { - groupedTieredPackage.validate() + "maximum" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(maximum = it, _json = json) + } ?: Adjustment(_json = json) } + } - override fun visitMatrixWithAllocation( - matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice - ) { - matrixWithAllocation.validate() - } + return Adjustment(_json = json) + } + } - override fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice - ) { - tieredPackageWithMinimum.validate() - } + internal class Serializer : BaseSerializer(Adjustment::class) { - override fun visitGroupedTiered( - groupedTiered: NewSubscriptionGroupedTieredPrice - ) { - groupedTiered.validate() - } + override fun serialize( + value: Adjustment, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.percentageDiscount != null -> + generator.writeObject(value.percentageDiscount) + value.usageDiscount != null -> generator.writeObject(value.usageDiscount) + value.amountDiscount != null -> generator.writeObject(value.amountDiscount) + value.minimum != null -> generator.writeObject(value.minimum) + value.maximum != null -> generator.writeObject(value.maximum) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Adjustment") } - ) - validated = true + } } + } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: NewSubscriptionUnitPrice) = unit.validity() + return other is ReplaceAdjustment && + adjustment == other.adjustment && + replacesAdjustmentId == other.replacesAdjustmentId && + additionalProperties == other.additionalProperties + } - override fun visitPackage(package_: NewSubscriptionPackagePrice) = - package_.validity() + private val hashCode: Int by lazy { + Objects.hash(adjustment, replacesAdjustmentId, additionalProperties) + } - override fun visitMatrix(matrix: NewSubscriptionMatrixPrice) = - matrix.validity() + override fun hashCode(): Int = hashCode - override fun visitTiered(tiered: NewSubscriptionTieredPrice) = - tiered.validity() + override fun toString() = + "ReplaceAdjustment{adjustment=$adjustment, replacesAdjustmentId=$replacesAdjustmentId, additionalProperties=$additionalProperties}" + } - override fun visitTieredBps(tieredBps: NewSubscriptionTieredBpsPrice) = - tieredBps.validity() + class ReplacePrice + private constructor( + private val replacesPriceId: JsonField, + private val allocationPrice: JsonField, + private val discounts: JsonField>, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val maximumAmount: JsonField, + private val minimumAmount: JsonField, + private val price: JsonField, + private val priceId: JsonField, + private val additionalProperties: MutableMap, + ) { - override fun visitBps(bps: NewSubscriptionBpsPrice) = bps.validity() + @JsonCreator + private constructor( + @JsonProperty("replaces_price_id") + @ExcludeMissing + replacesPriceId: JsonField = JsonMissing.of(), + @JsonProperty("allocation_price") + @ExcludeMissing + allocationPrice: JsonField = JsonMissing.of(), + @JsonProperty("discounts") + @ExcludeMissing + discounts: JsonField> = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("maximum_amount") + @ExcludeMissing + maximumAmount: JsonField = JsonMissing.of(), + @JsonProperty("minimum_amount") + @ExcludeMissing + minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("price") @ExcludeMissing price: JsonField = JsonMissing.of(), + @JsonProperty("price_id") @ExcludeMissing priceId: JsonField = JsonMissing.of(), + ) : this( + replacesPriceId, + allocationPrice, + discounts, + externalPriceId, + fixedPriceQuantity, + maximumAmount, + minimumAmount, + price, + priceId, + mutableMapOf(), + ) - override fun visitBulkBps(bulkBps: NewSubscriptionBulkBpsPrice) = - bulkBps.validity() + /** + * The id of the price on the plan to replace in the subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun replacesPriceId(): String = replacesPriceId.getRequired("replaces_price_id") - override fun visitBulk(bulk: NewSubscriptionBulkPrice) = bulk.validity() + /** + * The definition of a new allocation price to create and add to the subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun allocationPrice(): NewAllocationPrice? = allocationPrice.getNullable("allocation_price") - override fun visitThresholdTotalAmount( - thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice - ) = thresholdTotalAmount.validity() + /** + * [DEPRECATED] Use add_adjustments instead. The subscription's discounts for the + * replacement price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + @Deprecated("deprecated") + fun discounts(): List? = discounts.getNullable("discounts") - override fun visitTieredPackage( - tieredPackage: NewSubscriptionTieredPackagePrice - ) = tieredPackage.validity() + /** + * The external price id of the price to add to the subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") - override fun visitTieredWithMinimum( - tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice - ) = tieredWithMinimum.validity() + /** + * The new quantity of the price, if the price is a fixed price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = fixedPriceQuantity.getNullable("fixed_price_quantity") - override fun visitUnitWithPercent( - unitWithPercent: NewSubscriptionUnitWithPercentPrice - ) = unitWithPercent.validity() + /** + * [DEPRECATED] Use add_adjustments instead. The subscription's maximum amount for the + * replacement price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + @Deprecated("deprecated") + fun maximumAmount(): String? = maximumAmount.getNullable("maximum_amount") - override fun visitPackageWithAllocation( - packageWithAllocation: NewSubscriptionPackageWithAllocationPrice - ) = packageWithAllocation.validity() + /** + * [DEPRECATED] Use add_adjustments instead. The subscription's minimum amount for the + * replacement price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + @Deprecated("deprecated") + fun minimumAmount(): String? = minimumAmount.getNullable("minimum_amount") - override fun visitTieredWithProration( - tieredWithProration: NewSubscriptionTierWithProrationPrice - ) = tieredWithProration.validity() + /** + * The definition of a new price to create and add to the subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun price(): Price? = price.getNullable("price") - override fun visitUnitWithProration( - unitWithProration: NewSubscriptionUnitWithProrationPrice - ) = unitWithProration.validity() + /** + * The id of the price to add to the subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun priceId(): String? = priceId.getNullable("price_id") - override fun visitGroupedAllocation( - groupedAllocation: NewSubscriptionGroupedAllocationPrice - ) = groupedAllocation.validity() + /** + * Returns the raw JSON value of [replacesPriceId]. + * + * Unlike [replacesPriceId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("replaces_price_id") + @ExcludeMissing + fun _replacesPriceId(): JsonField = replacesPriceId - override fun visitGroupedWithProratedMinimum( - groupedWithProratedMinimum: - NewSubscriptionGroupedWithProratedMinimumPrice - ) = groupedWithProratedMinimum.validity() + /** + * Returns the raw JSON value of [allocationPrice]. + * + * Unlike [allocationPrice], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("allocation_price") + @ExcludeMissing + fun _allocationPrice(): JsonField = allocationPrice - override fun visitBulkWithProration( - bulkWithProration: NewSubscriptionBulkWithProrationPrice - ) = bulkWithProration.validity() + /** + * Returns the raw JSON value of [discounts]. + * + * Unlike [discounts], this method doesn't throw if the JSON field has an unexpected type. + */ + @Deprecated("deprecated") + @JsonProperty("discounts") + @ExcludeMissing + fun _discounts(): JsonField> = discounts - override fun visitScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: - NewSubscriptionScalableMatrixWithUnitPricingPrice - ) = scalableMatrixWithUnitPricing.validity() + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId - override fun visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: - NewSubscriptionScalableMatrixWithTieredPricingPrice - ) = scalableMatrixWithTieredPricing.validity() + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - override fun visitCumulativeGroupedBulk( - cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice - ) = cumulativeGroupedBulk.validity() + /** + * Returns the raw JSON value of [maximumAmount]. + * + * Unlike [maximumAmount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @Deprecated("deprecated") + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount - override fun visitMaxGroupTieredPackage( - maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice - ) = maxGroupTieredPackage.validity() + /** + * Returns the raw JSON value of [minimumAmount]. + * + * Unlike [minimumAmount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @Deprecated("deprecated") + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount - override fun visitGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice - ) = groupedWithMeteredMinimum.validity() + /** + * Returns the raw JSON value of [price]. + * + * Unlike [price], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("price") @ExcludeMissing fun _price(): JsonField = price - override fun visitMatrixWithDisplayName( - matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice - ) = matrixWithDisplayName.validity() + /** + * Returns the raw JSON value of [priceId]. + * + * Unlike [priceId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId - override fun visitGroupedTieredPackage( - groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice - ) = groupedTieredPackage.validity() + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - override fun visitMatrixWithAllocation( - matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice - ) = matrixWithAllocation.validity() + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - override fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice - ) = tieredPackageWithMinimum.validity() + fun toBuilder() = Builder().from(this) - override fun visitGroupedTiered( - groupedTiered: NewSubscriptionGroupedTieredPrice - ) = groupedTiered.validity() + companion object { - override fun unknown(json: JsonValue?) = 0 - } - ) + /** + * Returns a mutable builder for constructing an instance of [ReplacePrice]. + * + * The following fields are required: + * ```kotlin + * .replacesPriceId() + * ``` + */ + fun builder() = Builder() + } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** A builder for [ReplacePrice]. */ + class Builder internal constructor() { - return other is Price && - unit == other.unit && - package_ == other.package_ && - matrix == other.matrix && - tiered == other.tiered && - tieredBps == other.tieredBps && - bps == other.bps && - bulkBps == other.bulkBps && - bulk == other.bulk && - thresholdTotalAmount == other.thresholdTotalAmount && - tieredPackage == other.tieredPackage && - tieredWithMinimum == other.tieredWithMinimum && - unitWithPercent == other.unitWithPercent && - packageWithAllocation == other.packageWithAllocation && - tieredWithProration == other.tieredWithProration && - unitWithProration == other.unitWithProration && - groupedAllocation == other.groupedAllocation && - groupedWithProratedMinimum == other.groupedWithProratedMinimum && - bulkWithProration == other.bulkWithProration && - scalableMatrixWithUnitPricing == other.scalableMatrixWithUnitPricing && - scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && - cumulativeGroupedBulk == other.cumulativeGroupedBulk && - maxGroupTieredPackage == other.maxGroupTieredPackage && - groupedWithMeteredMinimum == other.groupedWithMeteredMinimum && - matrixWithDisplayName == other.matrixWithDisplayName && - groupedTieredPackage == other.groupedTieredPackage && - matrixWithAllocation == other.matrixWithAllocation && - tieredPackageWithMinimum == other.tieredPackageWithMinimum && - groupedTiered == other.groupedTiered + private var replacesPriceId: JsonField? = null + private var allocationPrice: JsonField = JsonMissing.of() + private var discounts: JsonField>? = null + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var maximumAmount: JsonField = JsonMissing.of() + private var minimumAmount: JsonField = JsonMissing.of() + private var price: JsonField = JsonMissing.of() + private var priceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(replacePrice: ReplacePrice) = apply { + replacesPriceId = replacePrice.replacesPriceId + allocationPrice = replacePrice.allocationPrice + discounts = replacePrice.discounts.map { it.toMutableList() } + externalPriceId = replacePrice.externalPriceId + fixedPriceQuantity = replacePrice.fixedPriceQuantity + maximumAmount = replacePrice.maximumAmount + minimumAmount = replacePrice.minimumAmount + price = replacePrice.price + priceId = replacePrice.priceId + additionalProperties = replacePrice.additionalProperties.toMutableMap() } - override fun hashCode(): Int = - Objects.hash( - unit, - package_, - matrix, - tiered, - tieredBps, - bps, - bulkBps, - bulk, - thresholdTotalAmount, - tieredPackage, - tieredWithMinimum, - unitWithPercent, - packageWithAllocation, - tieredWithProration, - unitWithProration, - groupedAllocation, - groupedWithProratedMinimum, - bulkWithProration, - scalableMatrixWithUnitPricing, - scalableMatrixWithTieredPricing, - cumulativeGroupedBulk, - maxGroupTieredPackage, - groupedWithMeteredMinimum, - matrixWithDisplayName, - groupedTieredPackage, - matrixWithAllocation, - tieredPackageWithMinimum, - groupedTiered, - ) - - override fun toString(): String = - when { - unit != null -> "Price{unit=$unit}" - package_ != null -> "Price{package_=$package_}" - matrix != null -> "Price{matrix=$matrix}" - tiered != null -> "Price{tiered=$tiered}" - tieredBps != null -> "Price{tieredBps=$tieredBps}" - bps != null -> "Price{bps=$bps}" - bulkBps != null -> "Price{bulkBps=$bulkBps}" - bulk != null -> "Price{bulk=$bulk}" - thresholdTotalAmount != null -> - "Price{thresholdTotalAmount=$thresholdTotalAmount}" - tieredPackage != null -> "Price{tieredPackage=$tieredPackage}" - tieredWithMinimum != null -> "Price{tieredWithMinimum=$tieredWithMinimum}" - unitWithPercent != null -> "Price{unitWithPercent=$unitWithPercent}" - packageWithAllocation != null -> - "Price{packageWithAllocation=$packageWithAllocation}" - tieredWithProration != null -> "Price{tieredWithProration=$tieredWithProration}" - unitWithProration != null -> "Price{unitWithProration=$unitWithProration}" - groupedAllocation != null -> "Price{groupedAllocation=$groupedAllocation}" - groupedWithProratedMinimum != null -> - "Price{groupedWithProratedMinimum=$groupedWithProratedMinimum}" - bulkWithProration != null -> "Price{bulkWithProration=$bulkWithProration}" - scalableMatrixWithUnitPricing != null -> - "Price{scalableMatrixWithUnitPricing=$scalableMatrixWithUnitPricing}" - scalableMatrixWithTieredPricing != null -> - "Price{scalableMatrixWithTieredPricing=$scalableMatrixWithTieredPricing}" - cumulativeGroupedBulk != null -> - "Price{cumulativeGroupedBulk=$cumulativeGroupedBulk}" - maxGroupTieredPackage != null -> - "Price{maxGroupTieredPackage=$maxGroupTieredPackage}" - groupedWithMeteredMinimum != null -> - "Price{groupedWithMeteredMinimum=$groupedWithMeteredMinimum}" - matrixWithDisplayName != null -> - "Price{matrixWithDisplayName=$matrixWithDisplayName}" - groupedTieredPackage != null -> - "Price{groupedTieredPackage=$groupedTieredPackage}" - matrixWithAllocation != null -> - "Price{matrixWithAllocation=$matrixWithAllocation}" - tieredPackageWithMinimum != null -> - "Price{tieredPackageWithMinimum=$tieredPackageWithMinimum}" - groupedTiered != null -> "Price{groupedTiered=$groupedTiered}" - _json != null -> "Price{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Price") - } + /** The id of the price on the plan to replace in the subscription. */ + fun replacesPriceId(replacesPriceId: String) = + replacesPriceId(JsonField.of(replacesPriceId)) - companion object { + /** + * Sets [Builder.replacesPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.replacesPriceId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun replacesPriceId(replacesPriceId: JsonField) = apply { + this.replacesPriceId = replacesPriceId + } - fun ofUnit(unit: NewSubscriptionUnitPrice) = Price(unit = unit) + /** The definition of a new allocation price to create and add to the subscription. */ + fun allocationPrice(allocationPrice: NewAllocationPrice?) = + allocationPrice(JsonField.ofNullable(allocationPrice)) - fun ofPackage(package_: NewSubscriptionPackagePrice) = Price(package_ = package_) + /** + * Sets [Builder.allocationPrice] to an arbitrary JSON value. + * + * You should usually call [Builder.allocationPrice] with a well-typed + * [NewAllocationPrice] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun allocationPrice(allocationPrice: JsonField) = apply { + this.allocationPrice = allocationPrice + } - fun ofMatrix(matrix: NewSubscriptionMatrixPrice) = Price(matrix = matrix) + /** + * [DEPRECATED] Use add_adjustments instead. The subscription's discounts for the + * replacement price. + */ + @Deprecated("deprecated") + fun discounts(discounts: List?) = + discounts(JsonField.ofNullable(discounts)) - fun ofTiered(tiered: NewSubscriptionTieredPrice) = Price(tiered = tiered) + /** + * Sets [Builder.discounts] to an arbitrary JSON value. + * + * You should usually call [Builder.discounts] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + @Deprecated("deprecated") + fun discounts(discounts: JsonField>) = apply { + this.discounts = discounts.map { it.toMutableList() } + } - fun ofTieredBps(tieredBps: NewSubscriptionTieredBpsPrice) = - Price(tieredBps = tieredBps) + /** + * Adds a single [DiscountOverride] to [discounts]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + @Deprecated("deprecated") + fun addDiscount(discount: DiscountOverride) = apply { + discounts = + (discounts ?: JsonField.of(mutableListOf())).also { + checkKnown("discounts", it).add(discount) + } + } - fun ofBps(bps: NewSubscriptionBpsPrice) = Price(bps = bps) + /** The external price id of the price to add to the subscription. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) - fun ofBulkBps(bulkBps: NewSubscriptionBulkBpsPrice) = Price(bulkBps = bulkBps) + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } - fun ofBulk(bulk: NewSubscriptionBulkPrice) = Price(bulk = bulk) + /** The new quantity of the price, if the price is a fixed price. */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) - fun ofThresholdTotalAmount( - thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice - ) = Price(thresholdTotalAmount = thresholdTotalAmount) + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) - fun ofTieredPackage(tieredPackage: NewSubscriptionTieredPackagePrice) = - Price(tieredPackage = tieredPackage) + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } - fun ofTieredWithMinimum(tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice) = - Price(tieredWithMinimum = tieredWithMinimum) + /** + * [DEPRECATED] Use add_adjustments instead. The subscription's maximum amount for the + * replacement price. + */ + @Deprecated("deprecated") + fun maximumAmount(maximumAmount: String?) = + maximumAmount(JsonField.ofNullable(maximumAmount)) - fun ofUnitWithPercent(unitWithPercent: NewSubscriptionUnitWithPercentPrice) = - Price(unitWithPercent = unitWithPercent) + /** + * Sets [Builder.maximumAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.maximumAmount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + @Deprecated("deprecated") + fun maximumAmount(maximumAmount: JsonField) = apply { + this.maximumAmount = maximumAmount + } - fun ofPackageWithAllocation( - packageWithAllocation: NewSubscriptionPackageWithAllocationPrice - ) = Price(packageWithAllocation = packageWithAllocation) + /** + * [DEPRECATED] Use add_adjustments instead. The subscription's minimum amount for the + * replacement price. + */ + @Deprecated("deprecated") + fun minimumAmount(minimumAmount: String?) = + minimumAmount(JsonField.ofNullable(minimumAmount)) - fun ofTieredWithProration( - tieredWithProration: NewSubscriptionTierWithProrationPrice - ) = Price(tieredWithProration = tieredWithProration) + /** + * Sets [Builder.minimumAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumAmount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + @Deprecated("deprecated") + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount + } - fun ofUnitWithProration(unitWithProration: NewSubscriptionUnitWithProrationPrice) = - Price(unitWithProration = unitWithProration) + /** The definition of a new price to create and add to the subscription. */ + fun price(price: Price?) = price(JsonField.ofNullable(price)) - fun ofGroupedAllocation(groupedAllocation: NewSubscriptionGroupedAllocationPrice) = - Price(groupedAllocation = groupedAllocation) + /** + * Sets [Builder.price] to an arbitrary JSON value. + * + * You should usually call [Builder.price] with a well-typed [Price] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun price(price: JsonField) = apply { this.price = price } - fun ofGroupedWithProratedMinimum( - groupedWithProratedMinimum: NewSubscriptionGroupedWithProratedMinimumPrice - ) = Price(groupedWithProratedMinimum = groupedWithProratedMinimum) + /** Alias for calling [price] with `Price.ofUnit(unit)`. */ + fun price(unit: NewSubscriptionUnitPrice) = price(Price.ofUnit(unit)) - fun ofBulkWithProration(bulkWithProration: NewSubscriptionBulkWithProrationPrice) = - Price(bulkWithProration = bulkWithProration) + /** Alias for calling [price] with `Price.ofPackage(package_)`. */ + fun price(package_: NewSubscriptionPackagePrice) = price(Price.ofPackage(package_)) - fun ofScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: NewSubscriptionScalableMatrixWithUnitPricingPrice - ) = Price(scalableMatrixWithUnitPricing = scalableMatrixWithUnitPricing) + /** Alias for calling [price] with `Price.ofMatrix(matrix)`. */ + fun price(matrix: NewSubscriptionMatrixPrice) = price(Price.ofMatrix(matrix)) - fun ofScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: - NewSubscriptionScalableMatrixWithTieredPricingPrice - ) = Price(scalableMatrixWithTieredPricing = scalableMatrixWithTieredPricing) + /** Alias for calling [price] with `Price.ofTiered(tiered)`. */ + fun price(tiered: NewSubscriptionTieredPrice) = price(Price.ofTiered(tiered)) - fun ofCumulativeGroupedBulk( - cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice - ) = Price(cumulativeGroupedBulk = cumulativeGroupedBulk) + /** Alias for calling [price] with `Price.ofBulk(bulk)`. */ + fun price(bulk: NewSubscriptionBulkPrice) = price(Price.ofBulk(bulk)) - fun ofMaxGroupTieredPackage( - maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice - ) = Price(maxGroupTieredPackage = maxGroupTieredPackage) + /** + * Alias for calling [price] with `Price.ofThresholdTotalAmount(thresholdTotalAmount)`. + */ + fun price(thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice) = + price(Price.ofThresholdTotalAmount(thresholdTotalAmount)) - fun ofGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice - ) = Price(groupedWithMeteredMinimum = groupedWithMeteredMinimum) + /** Alias for calling [price] with `Price.ofTieredPackage(tieredPackage)`. */ + fun price(tieredPackage: NewSubscriptionTieredPackagePrice) = + price(Price.ofTieredPackage(tieredPackage)) - fun ofMatrixWithDisplayName( - matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice - ) = Price(matrixWithDisplayName = matrixWithDisplayName) + /** Alias for calling [price] with `Price.ofTieredWithMinimum(tieredWithMinimum)`. */ + fun price(tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice) = + price(Price.ofTieredWithMinimum(tieredWithMinimum)) - fun ofGroupedTieredPackage( - groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice - ) = Price(groupedTieredPackage = groupedTieredPackage) - - fun ofMatrixWithAllocation( - matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice - ) = Price(matrixWithAllocation = matrixWithAllocation) - - fun ofTieredPackageWithMinimum( - tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice - ) = Price(tieredPackageWithMinimum = tieredPackageWithMinimum) - - fun ofGroupedTiered(groupedTiered: NewSubscriptionGroupedTieredPrice) = - Price(groupedTiered = groupedTiered) - } + /** Alias for calling [price] with `Price.ofUnitWithPercent(unitWithPercent)`. */ + fun price(unitWithPercent: NewSubscriptionUnitWithPercentPrice) = + price(Price.ofUnitWithPercent(unitWithPercent)) /** - * An interface that defines how to map each variant of [Price] to a value of type [T]. + * Alias for calling [price] with + * `Price.ofPackageWithAllocation(packageWithAllocation)`. */ - interface Visitor { - - fun visitUnit(unit: NewSubscriptionUnitPrice): T - - fun visitPackage(package_: NewSubscriptionPackagePrice): T + fun price(packageWithAllocation: NewSubscriptionPackageWithAllocationPrice) = + price(Price.ofPackageWithAllocation(packageWithAllocation)) - fun visitMatrix(matrix: NewSubscriptionMatrixPrice): T + /** + * Alias for calling [price] with `Price.ofTieredWithProration(tieredWithProration)`. + */ + fun price(tieredWithProration: NewSubscriptionTierWithProrationPrice) = + price(Price.ofTieredWithProration(tieredWithProration)) - fun visitTiered(tiered: NewSubscriptionTieredPrice): T + /** Alias for calling [price] with `Price.ofUnitWithProration(unitWithProration)`. */ + fun price(unitWithProration: NewSubscriptionUnitWithProrationPrice) = + price(Price.ofUnitWithProration(unitWithProration)) - fun visitTieredBps(tieredBps: NewSubscriptionTieredBpsPrice): T + /** Alias for calling [price] with `Price.ofGroupedAllocation(groupedAllocation)`. */ + fun price(groupedAllocation: NewSubscriptionGroupedAllocationPrice) = + price(Price.ofGroupedAllocation(groupedAllocation)) - fun visitBps(bps: NewSubscriptionBpsPrice): T + /** + * Alias for calling [price] with + * `Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)`. + */ + fun price(groupedWithProratedMinimum: NewSubscriptionGroupedWithProratedMinimumPrice) = + price(Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)) - fun visitBulkBps(bulkBps: NewSubscriptionBulkBpsPrice): T + /** Alias for calling [price] with `Price.ofBulkWithProration(bulkWithProration)`. */ + fun price(bulkWithProration: NewSubscriptionBulkWithProrationPrice) = + price(Price.ofBulkWithProration(bulkWithProration)) - fun visitBulk(bulk: NewSubscriptionBulkPrice): T + /** + * Alias for calling [price] with + * `Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)`. + */ + fun price( + scalableMatrixWithUnitPricing: NewSubscriptionScalableMatrixWithUnitPricingPrice + ) = price(Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)) - fun visitThresholdTotalAmount( - thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice - ): T + /** + * Alias for calling [price] with + * `Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)`. + */ + fun price( + scalableMatrixWithTieredPricing: NewSubscriptionScalableMatrixWithTieredPricingPrice + ) = price(Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)) - fun visitTieredPackage(tieredPackage: NewSubscriptionTieredPackagePrice): T + /** + * Alias for calling [price] with + * `Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)`. + */ + fun price(cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice) = + price(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) - fun visitTieredWithMinimum( - tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice - ): T + /** + * Alias for calling [price] with + * `Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)`. + */ + fun price(maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice) = + price(Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)) - fun visitUnitWithPercent(unitWithPercent: NewSubscriptionUnitWithPercentPrice): T + /** + * Alias for calling [price] with + * `Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)`. + */ + fun price(groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice) = + price(Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)) - fun visitPackageWithAllocation( - packageWithAllocation: NewSubscriptionPackageWithAllocationPrice - ): T + /** + * Alias for calling [price] with + * `Price.ofMatrixWithDisplayName(matrixWithDisplayName)`. + */ + fun price(matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice) = + price(Price.ofMatrixWithDisplayName(matrixWithDisplayName)) - fun visitTieredWithProration( - tieredWithProration: NewSubscriptionTierWithProrationPrice - ): T + /** + * Alias for calling [price] with `Price.ofGroupedTieredPackage(groupedTieredPackage)`. + */ + fun price(groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice) = + price(Price.ofGroupedTieredPackage(groupedTieredPackage)) - fun visitUnitWithProration( - unitWithProration: NewSubscriptionUnitWithProrationPrice - ): T + /** + * Alias for calling [price] with `Price.ofMatrixWithAllocation(matrixWithAllocation)`. + */ + fun price(matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice) = + price(Price.ofMatrixWithAllocation(matrixWithAllocation)) - fun visitGroupedAllocation( - groupedAllocation: NewSubscriptionGroupedAllocationPrice - ): T + /** + * Alias for calling [price] with + * `Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)`. + */ + fun price(tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice) = + price(Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)) - fun visitGroupedWithProratedMinimum( - groupedWithProratedMinimum: NewSubscriptionGroupedWithProratedMinimumPrice - ): T + /** Alias for calling [price] with `Price.ofGroupedTiered(groupedTiered)`. */ + fun price(groupedTiered: NewSubscriptionGroupedTieredPrice) = + price(Price.ofGroupedTiered(groupedTiered)) - fun visitBulkWithProration( - bulkWithProration: NewSubscriptionBulkWithProrationPrice - ): T + /** + * Alias for calling [price] with + * `Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)`. + */ + fun price(groupedWithMinMaxThresholds: Price.GroupedWithMinMaxThresholds) = + price(Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)) - fun visitScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: NewSubscriptionScalableMatrixWithUnitPricingPrice - ): T + /** Alias for calling [price] with `Price.ofMinimum(minimum)`. */ + fun price(minimum: Price.Minimum) = price(Price.ofMinimum(minimum)) - fun visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: - NewSubscriptionScalableMatrixWithTieredPricingPrice - ): T + /** The id of the price to add to the subscription. */ + fun priceId(priceId: String?) = priceId(JsonField.ofNullable(priceId)) - fun visitCumulativeGroupedBulk( - cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice - ): T + /** + * Sets [Builder.priceId] to an arbitrary JSON value. + * + * You should usually call [Builder.priceId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun priceId(priceId: JsonField) = apply { this.priceId = priceId } - fun visitMaxGroupTieredPackage( - maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice - ): T + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun visitGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice - ): T + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun visitMatrixWithDisplayName( - matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice - ): T + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun visitGroupedTieredPackage( - groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice - ): T + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - fun visitMatrixWithAllocation( - matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice - ): T + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice - ): T + /** + * Returns an immutable instance of [ReplacePrice]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .replacesPriceId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ReplacePrice = + ReplacePrice( + checkRequired("replacesPriceId", replacesPriceId), + allocationPrice, + (discounts ?: JsonMissing.of()).map { it.toImmutable() }, + externalPriceId, + fixedPriceQuantity, + maximumAmount, + minimumAmount, + price, + priceId, + additionalProperties.toMutableMap(), + ) + } - fun visitGroupedTiered(groupedTiered: NewSubscriptionGroupedTieredPrice): T + private var validated: Boolean = false - /** - * Maps an unknown variant of [Price] to a value of type [T]. - * - * An instance of [Price] can contain an unknown variant if it was deserialized from - * data that doesn't match any known variant. For example, if the SDK is on an older - * version than the API, then the API may respond with new variants that the SDK is - * unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown Price: $json") - } + fun validate(): ReplacePrice = apply { + if (validated) { + return@apply } - internal class Deserializer : BaseDeserializer(Price::class) { + replacesPriceId() + allocationPrice()?.validate() + discounts()?.forEach { it.validate() } + externalPriceId() + fixedPriceQuantity() + maximumAmount() + minimumAmount() + price()?.validate() + priceId() + validated = true + } - override fun ObjectCodec.deserialize(node: JsonNode): Price { - val json = JsonValue.fromJsonNode(node) - val modelType = json.asObject()?.get("model_type")?.asString() + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - when (modelType) { + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (replacesPriceId.asKnown() == null) 0 else 1) + + (allocationPrice.asKnown()?.validity() ?: 0) + + (discounts.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (maximumAmount.asKnown() == null) 0 else 1) + + (if (minimumAmount.asKnown() == null) 0 else 1) + + (price.asKnown()?.validity() ?: 0) + + (if (priceId.asKnown() == null) 0 else 1) + + /** The definition of a new price to create and add to the subscription. */ + @JsonDeserialize(using = Price.Deserializer::class) + @JsonSerialize(using = Price.Serializer::class) + class Price + private constructor( + private val unit: NewSubscriptionUnitPrice? = null, + private val package_: NewSubscriptionPackagePrice? = null, + private val matrix: NewSubscriptionMatrixPrice? = null, + private val tiered: NewSubscriptionTieredPrice? = null, + private val bulk: NewSubscriptionBulkPrice? = null, + private val thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice? = null, + private val tieredPackage: NewSubscriptionTieredPackagePrice? = null, + private val tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice? = null, + private val unitWithPercent: NewSubscriptionUnitWithPercentPrice? = null, + private val packageWithAllocation: NewSubscriptionPackageWithAllocationPrice? = null, + private val tieredWithProration: NewSubscriptionTierWithProrationPrice? = null, + private val unitWithProration: NewSubscriptionUnitWithProrationPrice? = null, + private val groupedAllocation: NewSubscriptionGroupedAllocationPrice? = null, + private val groupedWithProratedMinimum: + NewSubscriptionGroupedWithProratedMinimumPrice? = + null, + private val bulkWithProration: NewSubscriptionBulkWithProrationPrice? = null, + private val scalableMatrixWithUnitPricing: + NewSubscriptionScalableMatrixWithUnitPricingPrice? = + null, + private val scalableMatrixWithTieredPricing: + NewSubscriptionScalableMatrixWithTieredPricingPrice? = + null, + private val cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice? = null, + private val maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice? = null, + private val groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice? = + null, + private val matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice? = null, + private val groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice? = null, + private val matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice? = null, + private val tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice? = + null, + private val groupedTiered: NewSubscriptionGroupedTieredPrice? = null, + private val groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds? = null, + private val minimum: Minimum? = null, + private val _json: JsonValue? = null, + ) { + + fun unit(): NewSubscriptionUnitPrice? = unit + + fun package_(): NewSubscriptionPackagePrice? = package_ + + fun matrix(): NewSubscriptionMatrixPrice? = matrix + + fun tiered(): NewSubscriptionTieredPrice? = tiered + + fun bulk(): NewSubscriptionBulkPrice? = bulk + + fun thresholdTotalAmount(): NewSubscriptionThresholdTotalAmountPrice? = + thresholdTotalAmount + + fun tieredPackage(): NewSubscriptionTieredPackagePrice? = tieredPackage + + fun tieredWithMinimum(): NewSubscriptionTieredWithMinimumPrice? = tieredWithMinimum + + fun unitWithPercent(): NewSubscriptionUnitWithPercentPrice? = unitWithPercent + + fun packageWithAllocation(): NewSubscriptionPackageWithAllocationPrice? = + packageWithAllocation + + fun tieredWithProration(): NewSubscriptionTierWithProrationPrice? = tieredWithProration + + fun unitWithProration(): NewSubscriptionUnitWithProrationPrice? = unitWithProration + + fun groupedAllocation(): NewSubscriptionGroupedAllocationPrice? = groupedAllocation + + fun groupedWithProratedMinimum(): NewSubscriptionGroupedWithProratedMinimumPrice? = + groupedWithProratedMinimum + + fun bulkWithProration(): NewSubscriptionBulkWithProrationPrice? = bulkWithProration + + fun scalableMatrixWithUnitPricing(): + NewSubscriptionScalableMatrixWithUnitPricingPrice? = scalableMatrixWithUnitPricing + + fun scalableMatrixWithTieredPricing(): + NewSubscriptionScalableMatrixWithTieredPricingPrice? = + scalableMatrixWithTieredPricing + + fun cumulativeGroupedBulk(): NewSubscriptionCumulativeGroupedBulkPrice? = + cumulativeGroupedBulk + + fun maxGroupTieredPackage(): NewSubscriptionMaxGroupTieredPackagePrice? = + maxGroupTieredPackage + + fun groupedWithMeteredMinimum(): NewSubscriptionGroupedWithMeteredMinimumPrice? = + groupedWithMeteredMinimum + + fun matrixWithDisplayName(): NewSubscriptionMatrixWithDisplayNamePrice? = + matrixWithDisplayName + + fun groupedTieredPackage(): NewSubscriptionGroupedTieredPackagePrice? = + groupedTieredPackage + + fun matrixWithAllocation(): NewSubscriptionMatrixWithAllocationPrice? = + matrixWithAllocation + + fun tieredPackageWithMinimum(): NewSubscriptionTieredPackageWithMinimumPrice? = + tieredPackageWithMinimum + + fun groupedTiered(): NewSubscriptionGroupedTieredPrice? = groupedTiered + + fun groupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds? = + groupedWithMinMaxThresholds + + fun minimum(): Minimum? = minimum + + fun isUnit(): Boolean = unit != null + + fun isPackage(): Boolean = package_ != null + + fun isMatrix(): Boolean = matrix != null + + fun isTiered(): Boolean = tiered != null + + fun isBulk(): Boolean = bulk != null + + fun isThresholdTotalAmount(): Boolean = thresholdTotalAmount != null + + fun isTieredPackage(): Boolean = tieredPackage != null + + fun isTieredWithMinimum(): Boolean = tieredWithMinimum != null + + fun isUnitWithPercent(): Boolean = unitWithPercent != null + + fun isPackageWithAllocation(): Boolean = packageWithAllocation != null + + fun isTieredWithProration(): Boolean = tieredWithProration != null + + fun isUnitWithProration(): Boolean = unitWithProration != null + + fun isGroupedAllocation(): Boolean = groupedAllocation != null + + fun isGroupedWithProratedMinimum(): Boolean = groupedWithProratedMinimum != null + + fun isBulkWithProration(): Boolean = bulkWithProration != null + + fun isScalableMatrixWithUnitPricing(): Boolean = scalableMatrixWithUnitPricing != null + + fun isScalableMatrixWithTieredPricing(): Boolean = + scalableMatrixWithTieredPricing != null + + fun isCumulativeGroupedBulk(): Boolean = cumulativeGroupedBulk != null + + fun isMaxGroupTieredPackage(): Boolean = maxGroupTieredPackage != null + + fun isGroupedWithMeteredMinimum(): Boolean = groupedWithMeteredMinimum != null + + fun isMatrixWithDisplayName(): Boolean = matrixWithDisplayName != null + + fun isGroupedTieredPackage(): Boolean = groupedTieredPackage != null + + fun isMatrixWithAllocation(): Boolean = matrixWithAllocation != null + + fun isTieredPackageWithMinimum(): Boolean = tieredPackageWithMinimum != null + + fun isGroupedTiered(): Boolean = groupedTiered != null + + fun isGroupedWithMinMaxThresholds(): Boolean = groupedWithMinMaxThresholds != null + + fun isMinimum(): Boolean = minimum != null + + fun asUnit(): NewSubscriptionUnitPrice = unit.getOrThrow("unit") + + fun asPackage(): NewSubscriptionPackagePrice = package_.getOrThrow("package_") + + fun asMatrix(): NewSubscriptionMatrixPrice = matrix.getOrThrow("matrix") + + fun asTiered(): NewSubscriptionTieredPrice = tiered.getOrThrow("tiered") + + fun asBulk(): NewSubscriptionBulkPrice = bulk.getOrThrow("bulk") + + fun asThresholdTotalAmount(): NewSubscriptionThresholdTotalAmountPrice = + thresholdTotalAmount.getOrThrow("thresholdTotalAmount") + + fun asTieredPackage(): NewSubscriptionTieredPackagePrice = + tieredPackage.getOrThrow("tieredPackage") + + fun asTieredWithMinimum(): NewSubscriptionTieredWithMinimumPrice = + tieredWithMinimum.getOrThrow("tieredWithMinimum") + + fun asUnitWithPercent(): NewSubscriptionUnitWithPercentPrice = + unitWithPercent.getOrThrow("unitWithPercent") + + fun asPackageWithAllocation(): NewSubscriptionPackageWithAllocationPrice = + packageWithAllocation.getOrThrow("packageWithAllocation") + + fun asTieredWithProration(): NewSubscriptionTierWithProrationPrice = + tieredWithProration.getOrThrow("tieredWithProration") + + fun asUnitWithProration(): NewSubscriptionUnitWithProrationPrice = + unitWithProration.getOrThrow("unitWithProration") + + fun asGroupedAllocation(): NewSubscriptionGroupedAllocationPrice = + groupedAllocation.getOrThrow("groupedAllocation") + + fun asGroupedWithProratedMinimum(): NewSubscriptionGroupedWithProratedMinimumPrice = + groupedWithProratedMinimum.getOrThrow("groupedWithProratedMinimum") + + fun asBulkWithProration(): NewSubscriptionBulkWithProrationPrice = + bulkWithProration.getOrThrow("bulkWithProration") + + fun asScalableMatrixWithUnitPricing(): + NewSubscriptionScalableMatrixWithUnitPricingPrice = + scalableMatrixWithUnitPricing.getOrThrow("scalableMatrixWithUnitPricing") + + fun asScalableMatrixWithTieredPricing(): + NewSubscriptionScalableMatrixWithTieredPricingPrice = + scalableMatrixWithTieredPricing.getOrThrow("scalableMatrixWithTieredPricing") + + fun asCumulativeGroupedBulk(): NewSubscriptionCumulativeGroupedBulkPrice = + cumulativeGroupedBulk.getOrThrow("cumulativeGroupedBulk") + + fun asMaxGroupTieredPackage(): NewSubscriptionMaxGroupTieredPackagePrice = + maxGroupTieredPackage.getOrThrow("maxGroupTieredPackage") + + fun asGroupedWithMeteredMinimum(): NewSubscriptionGroupedWithMeteredMinimumPrice = + groupedWithMeteredMinimum.getOrThrow("groupedWithMeteredMinimum") + + fun asMatrixWithDisplayName(): NewSubscriptionMatrixWithDisplayNamePrice = + matrixWithDisplayName.getOrThrow("matrixWithDisplayName") + + fun asGroupedTieredPackage(): NewSubscriptionGroupedTieredPackagePrice = + groupedTieredPackage.getOrThrow("groupedTieredPackage") + + fun asMatrixWithAllocation(): NewSubscriptionMatrixWithAllocationPrice = + matrixWithAllocation.getOrThrow("matrixWithAllocation") + + fun asTieredPackageWithMinimum(): NewSubscriptionTieredPackageWithMinimumPrice = + tieredPackageWithMinimum.getOrThrow("tieredPackageWithMinimum") + + fun asGroupedTiered(): NewSubscriptionGroupedTieredPrice = + groupedTiered.getOrThrow("groupedTiered") + + fun asGroupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds = + groupedWithMinMaxThresholds.getOrThrow("groupedWithMinMaxThresholds") + + fun asMinimum(): Minimum = minimum.getOrThrow("minimum") + + fun _json(): JsonValue? = _json + + fun accept(visitor: Visitor): T = + when { + unit != null -> visitor.visitUnit(unit) + package_ != null -> visitor.visitPackage(package_) + matrix != null -> visitor.visitMatrix(matrix) + tiered != null -> visitor.visitTiered(tiered) + bulk != null -> visitor.visitBulk(bulk) + thresholdTotalAmount != null -> + visitor.visitThresholdTotalAmount(thresholdTotalAmount) + tieredPackage != null -> visitor.visitTieredPackage(tieredPackage) + tieredWithMinimum != null -> visitor.visitTieredWithMinimum(tieredWithMinimum) + unitWithPercent != null -> visitor.visitUnitWithPercent(unitWithPercent) + packageWithAllocation != null -> + visitor.visitPackageWithAllocation(packageWithAllocation) + tieredWithProration != null -> + visitor.visitTieredWithProration(tieredWithProration) + unitWithProration != null -> visitor.visitUnitWithProration(unitWithProration) + groupedAllocation != null -> visitor.visitGroupedAllocation(groupedAllocation) + groupedWithProratedMinimum != null -> + visitor.visitGroupedWithProratedMinimum(groupedWithProratedMinimum) + bulkWithProration != null -> visitor.visitBulkWithProration(bulkWithProration) + scalableMatrixWithUnitPricing != null -> + visitor.visitScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing) + scalableMatrixWithTieredPricing != null -> + visitor.visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing + ) + cumulativeGroupedBulk != null -> + visitor.visitCumulativeGroupedBulk(cumulativeGroupedBulk) + maxGroupTieredPackage != null -> + visitor.visitMaxGroupTieredPackage(maxGroupTieredPackage) + groupedWithMeteredMinimum != null -> + visitor.visitGroupedWithMeteredMinimum(groupedWithMeteredMinimum) + matrixWithDisplayName != null -> + visitor.visitMatrixWithDisplayName(matrixWithDisplayName) + groupedTieredPackage != null -> + visitor.visitGroupedTieredPackage(groupedTieredPackage) + matrixWithAllocation != null -> + visitor.visitMatrixWithAllocation(matrixWithAllocation) + tieredPackageWithMinimum != null -> + visitor.visitTieredPackageWithMinimum(tieredPackageWithMinimum) + groupedTiered != null -> visitor.visitGroupedTiered(groupedTiered) + groupedWithMinMaxThresholds != null -> + visitor.visitGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds) + minimum != null -> visitor.visitMinimum(minimum) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Price = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitUnit(unit: NewSubscriptionUnitPrice) { + unit.validate() + } + + override fun visitPackage(package_: NewSubscriptionPackagePrice) { + package_.validate() + } + + override fun visitMatrix(matrix: NewSubscriptionMatrixPrice) { + matrix.validate() + } + + override fun visitTiered(tiered: NewSubscriptionTieredPrice) { + tiered.validate() + } + + override fun visitBulk(bulk: NewSubscriptionBulkPrice) { + bulk.validate() + } + + override fun visitThresholdTotalAmount( + thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice + ) { + thresholdTotalAmount.validate() + } + + override fun visitTieredPackage( + tieredPackage: NewSubscriptionTieredPackagePrice + ) { + tieredPackage.validate() + } + + override fun visitTieredWithMinimum( + tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice + ) { + tieredWithMinimum.validate() + } + + override fun visitUnitWithPercent( + unitWithPercent: NewSubscriptionUnitWithPercentPrice + ) { + unitWithPercent.validate() + } + + override fun visitPackageWithAllocation( + packageWithAllocation: NewSubscriptionPackageWithAllocationPrice + ) { + packageWithAllocation.validate() + } + + override fun visitTieredWithProration( + tieredWithProration: NewSubscriptionTierWithProrationPrice + ) { + tieredWithProration.validate() + } + + override fun visitUnitWithProration( + unitWithProration: NewSubscriptionUnitWithProrationPrice + ) { + unitWithProration.validate() + } + + override fun visitGroupedAllocation( + groupedAllocation: NewSubscriptionGroupedAllocationPrice + ) { + groupedAllocation.validate() + } + + override fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: + NewSubscriptionGroupedWithProratedMinimumPrice + ) { + groupedWithProratedMinimum.validate() + } + + override fun visitBulkWithProration( + bulkWithProration: NewSubscriptionBulkWithProrationPrice + ) { + bulkWithProration.validate() + } + + override fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: + NewSubscriptionScalableMatrixWithUnitPricingPrice + ) { + scalableMatrixWithUnitPricing.validate() + } + + override fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: + NewSubscriptionScalableMatrixWithTieredPricingPrice + ) { + scalableMatrixWithTieredPricing.validate() + } + + override fun visitCumulativeGroupedBulk( + cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice + ) { + cumulativeGroupedBulk.validate() + } + + override fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice + ) { + maxGroupTieredPackage.validate() + } + + override fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice + ) { + groupedWithMeteredMinimum.validate() + } + + override fun visitMatrixWithDisplayName( + matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice + ) { + matrixWithDisplayName.validate() + } + + override fun visitGroupedTieredPackage( + groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice + ) { + groupedTieredPackage.validate() + } + + override fun visitMatrixWithAllocation( + matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice + ) { + matrixWithAllocation.validate() + } + + override fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice + ) { + tieredPackageWithMinimum.validate() + } + + override fun visitGroupedTiered( + groupedTiered: NewSubscriptionGroupedTieredPrice + ) { + groupedTiered.validate() + } + + override fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) { + groupedWithMinMaxThresholds.validate() + } + + override fun visitMinimum(minimum: Minimum) { + minimum.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitUnit(unit: NewSubscriptionUnitPrice) = unit.validity() + + override fun visitPackage(package_: NewSubscriptionPackagePrice) = + package_.validity() + + override fun visitMatrix(matrix: NewSubscriptionMatrixPrice) = + matrix.validity() + + override fun visitTiered(tiered: NewSubscriptionTieredPrice) = + tiered.validity() + + override fun visitBulk(bulk: NewSubscriptionBulkPrice) = bulk.validity() + + override fun visitThresholdTotalAmount( + thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice + ) = thresholdTotalAmount.validity() + + override fun visitTieredPackage( + tieredPackage: NewSubscriptionTieredPackagePrice + ) = tieredPackage.validity() + + override fun visitTieredWithMinimum( + tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice + ) = tieredWithMinimum.validity() + + override fun visitUnitWithPercent( + unitWithPercent: NewSubscriptionUnitWithPercentPrice + ) = unitWithPercent.validity() + + override fun visitPackageWithAllocation( + packageWithAllocation: NewSubscriptionPackageWithAllocationPrice + ) = packageWithAllocation.validity() + + override fun visitTieredWithProration( + tieredWithProration: NewSubscriptionTierWithProrationPrice + ) = tieredWithProration.validity() + + override fun visitUnitWithProration( + unitWithProration: NewSubscriptionUnitWithProrationPrice + ) = unitWithProration.validity() + + override fun visitGroupedAllocation( + groupedAllocation: NewSubscriptionGroupedAllocationPrice + ) = groupedAllocation.validity() + + override fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: + NewSubscriptionGroupedWithProratedMinimumPrice + ) = groupedWithProratedMinimum.validity() + + override fun visitBulkWithProration( + bulkWithProration: NewSubscriptionBulkWithProrationPrice + ) = bulkWithProration.validity() + + override fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: + NewSubscriptionScalableMatrixWithUnitPricingPrice + ) = scalableMatrixWithUnitPricing.validity() + + override fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: + NewSubscriptionScalableMatrixWithTieredPricingPrice + ) = scalableMatrixWithTieredPricing.validity() + + override fun visitCumulativeGroupedBulk( + cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice + ) = cumulativeGroupedBulk.validity() + + override fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice + ) = maxGroupTieredPackage.validity() + + override fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice + ) = groupedWithMeteredMinimum.validity() + + override fun visitMatrixWithDisplayName( + matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice + ) = matrixWithDisplayName.validity() + + override fun visitGroupedTieredPackage( + groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice + ) = groupedTieredPackage.validity() + + override fun visitMatrixWithAllocation( + matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice + ) = matrixWithAllocation.validity() + + override fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice + ) = tieredPackageWithMinimum.validity() + + override fun visitGroupedTiered( + groupedTiered: NewSubscriptionGroupedTieredPrice + ) = groupedTiered.validity() + + override fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) = groupedWithMinMaxThresholds.validity() + + override fun visitMinimum(minimum: Minimum) = minimum.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Price && + unit == other.unit && + package_ == other.package_ && + matrix == other.matrix && + tiered == other.tiered && + bulk == other.bulk && + thresholdTotalAmount == other.thresholdTotalAmount && + tieredPackage == other.tieredPackage && + tieredWithMinimum == other.tieredWithMinimum && + unitWithPercent == other.unitWithPercent && + packageWithAllocation == other.packageWithAllocation && + tieredWithProration == other.tieredWithProration && + unitWithProration == other.unitWithProration && + groupedAllocation == other.groupedAllocation && + groupedWithProratedMinimum == other.groupedWithProratedMinimum && + bulkWithProration == other.bulkWithProration && + scalableMatrixWithUnitPricing == other.scalableMatrixWithUnitPricing && + scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && + cumulativeGroupedBulk == other.cumulativeGroupedBulk && + maxGroupTieredPackage == other.maxGroupTieredPackage && + groupedWithMeteredMinimum == other.groupedWithMeteredMinimum && + matrixWithDisplayName == other.matrixWithDisplayName && + groupedTieredPackage == other.groupedTieredPackage && + matrixWithAllocation == other.matrixWithAllocation && + tieredPackageWithMinimum == other.tieredPackageWithMinimum && + groupedTiered == other.groupedTiered && + groupedWithMinMaxThresholds == other.groupedWithMinMaxThresholds && + minimum == other.minimum + } + + override fun hashCode(): Int = + Objects.hash( + unit, + package_, + matrix, + tiered, + bulk, + thresholdTotalAmount, + tieredPackage, + tieredWithMinimum, + unitWithPercent, + packageWithAllocation, + tieredWithProration, + unitWithProration, + groupedAllocation, + groupedWithProratedMinimum, + bulkWithProration, + scalableMatrixWithUnitPricing, + scalableMatrixWithTieredPricing, + cumulativeGroupedBulk, + maxGroupTieredPackage, + groupedWithMeteredMinimum, + matrixWithDisplayName, + groupedTieredPackage, + matrixWithAllocation, + tieredPackageWithMinimum, + groupedTiered, + groupedWithMinMaxThresholds, + minimum, + ) + + override fun toString(): String = + when { + unit != null -> "Price{unit=$unit}" + package_ != null -> "Price{package_=$package_}" + matrix != null -> "Price{matrix=$matrix}" + tiered != null -> "Price{tiered=$tiered}" + bulk != null -> "Price{bulk=$bulk}" + thresholdTotalAmount != null -> + "Price{thresholdTotalAmount=$thresholdTotalAmount}" + tieredPackage != null -> "Price{tieredPackage=$tieredPackage}" + tieredWithMinimum != null -> "Price{tieredWithMinimum=$tieredWithMinimum}" + unitWithPercent != null -> "Price{unitWithPercent=$unitWithPercent}" + packageWithAllocation != null -> + "Price{packageWithAllocation=$packageWithAllocation}" + tieredWithProration != null -> "Price{tieredWithProration=$tieredWithProration}" + unitWithProration != null -> "Price{unitWithProration=$unitWithProration}" + groupedAllocation != null -> "Price{groupedAllocation=$groupedAllocation}" + groupedWithProratedMinimum != null -> + "Price{groupedWithProratedMinimum=$groupedWithProratedMinimum}" + bulkWithProration != null -> "Price{bulkWithProration=$bulkWithProration}" + scalableMatrixWithUnitPricing != null -> + "Price{scalableMatrixWithUnitPricing=$scalableMatrixWithUnitPricing}" + scalableMatrixWithTieredPricing != null -> + "Price{scalableMatrixWithTieredPricing=$scalableMatrixWithTieredPricing}" + cumulativeGroupedBulk != null -> + "Price{cumulativeGroupedBulk=$cumulativeGroupedBulk}" + maxGroupTieredPackage != null -> + "Price{maxGroupTieredPackage=$maxGroupTieredPackage}" + groupedWithMeteredMinimum != null -> + "Price{groupedWithMeteredMinimum=$groupedWithMeteredMinimum}" + matrixWithDisplayName != null -> + "Price{matrixWithDisplayName=$matrixWithDisplayName}" + groupedTieredPackage != null -> + "Price{groupedTieredPackage=$groupedTieredPackage}" + matrixWithAllocation != null -> + "Price{matrixWithAllocation=$matrixWithAllocation}" + tieredPackageWithMinimum != null -> + "Price{tieredPackageWithMinimum=$tieredPackageWithMinimum}" + groupedTiered != null -> "Price{groupedTiered=$groupedTiered}" + groupedWithMinMaxThresholds != null -> + "Price{groupedWithMinMaxThresholds=$groupedWithMinMaxThresholds}" + minimum != null -> "Price{minimum=$minimum}" + _json != null -> "Price{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Price") + } + + companion object { + + fun ofUnit(unit: NewSubscriptionUnitPrice) = Price(unit = unit) + + fun ofPackage(package_: NewSubscriptionPackagePrice) = Price(package_ = package_) + + fun ofMatrix(matrix: NewSubscriptionMatrixPrice) = Price(matrix = matrix) + + fun ofTiered(tiered: NewSubscriptionTieredPrice) = Price(tiered = tiered) + + fun ofBulk(bulk: NewSubscriptionBulkPrice) = Price(bulk = bulk) + + fun ofThresholdTotalAmount( + thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice + ) = Price(thresholdTotalAmount = thresholdTotalAmount) + + fun ofTieredPackage(tieredPackage: NewSubscriptionTieredPackagePrice) = + Price(tieredPackage = tieredPackage) + + fun ofTieredWithMinimum(tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice) = + Price(tieredWithMinimum = tieredWithMinimum) + + fun ofUnitWithPercent(unitWithPercent: NewSubscriptionUnitWithPercentPrice) = + Price(unitWithPercent = unitWithPercent) + + fun ofPackageWithAllocation( + packageWithAllocation: NewSubscriptionPackageWithAllocationPrice + ) = Price(packageWithAllocation = packageWithAllocation) + + fun ofTieredWithProration( + tieredWithProration: NewSubscriptionTierWithProrationPrice + ) = Price(tieredWithProration = tieredWithProration) + + fun ofUnitWithProration(unitWithProration: NewSubscriptionUnitWithProrationPrice) = + Price(unitWithProration = unitWithProration) + + fun ofGroupedAllocation(groupedAllocation: NewSubscriptionGroupedAllocationPrice) = + Price(groupedAllocation = groupedAllocation) + + fun ofGroupedWithProratedMinimum( + groupedWithProratedMinimum: NewSubscriptionGroupedWithProratedMinimumPrice + ) = Price(groupedWithProratedMinimum = groupedWithProratedMinimum) + + fun ofBulkWithProration(bulkWithProration: NewSubscriptionBulkWithProrationPrice) = + Price(bulkWithProration = bulkWithProration) + + fun ofScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: NewSubscriptionScalableMatrixWithUnitPricingPrice + ) = Price(scalableMatrixWithUnitPricing = scalableMatrixWithUnitPricing) + + fun ofScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: + NewSubscriptionScalableMatrixWithTieredPricingPrice + ) = Price(scalableMatrixWithTieredPricing = scalableMatrixWithTieredPricing) + + fun ofCumulativeGroupedBulk( + cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice + ) = Price(cumulativeGroupedBulk = cumulativeGroupedBulk) + + fun ofMaxGroupTieredPackage( + maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice + ) = Price(maxGroupTieredPackage = maxGroupTieredPackage) + + fun ofGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice + ) = Price(groupedWithMeteredMinimum = groupedWithMeteredMinimum) + + fun ofMatrixWithDisplayName( + matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice + ) = Price(matrixWithDisplayName = matrixWithDisplayName) + + fun ofGroupedTieredPackage( + groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice + ) = Price(groupedTieredPackage = groupedTieredPackage) + + fun ofMatrixWithAllocation( + matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice + ) = Price(matrixWithAllocation = matrixWithAllocation) + + fun ofTieredPackageWithMinimum( + tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice + ) = Price(tieredPackageWithMinimum = tieredPackageWithMinimum) + + fun ofGroupedTiered(groupedTiered: NewSubscriptionGroupedTieredPrice) = + Price(groupedTiered = groupedTiered) + + fun ofGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) = Price(groupedWithMinMaxThresholds = groupedWithMinMaxThresholds) + + fun ofMinimum(minimum: Minimum) = Price(minimum = minimum) + } + + /** + * An interface that defines how to map each variant of [Price] to a value of type [T]. + */ + interface Visitor { + + fun visitUnit(unit: NewSubscriptionUnitPrice): T + + fun visitPackage(package_: NewSubscriptionPackagePrice): T + + fun visitMatrix(matrix: NewSubscriptionMatrixPrice): T + + fun visitTiered(tiered: NewSubscriptionTieredPrice): T + + fun visitBulk(bulk: NewSubscriptionBulkPrice): T + + fun visitThresholdTotalAmount( + thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice + ): T + + fun visitTieredPackage(tieredPackage: NewSubscriptionTieredPackagePrice): T + + fun visitTieredWithMinimum( + tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice + ): T + + fun visitUnitWithPercent(unitWithPercent: NewSubscriptionUnitWithPercentPrice): T + + fun visitPackageWithAllocation( + packageWithAllocation: NewSubscriptionPackageWithAllocationPrice + ): T + + fun visitTieredWithProration( + tieredWithProration: NewSubscriptionTierWithProrationPrice + ): T + + fun visitUnitWithProration( + unitWithProration: NewSubscriptionUnitWithProrationPrice + ): T + + fun visitGroupedAllocation( + groupedAllocation: NewSubscriptionGroupedAllocationPrice + ): T + + fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: NewSubscriptionGroupedWithProratedMinimumPrice + ): T + + fun visitBulkWithProration( + bulkWithProration: NewSubscriptionBulkWithProrationPrice + ): T + + fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: NewSubscriptionScalableMatrixWithUnitPricingPrice + ): T + + fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: + NewSubscriptionScalableMatrixWithTieredPricingPrice + ): T + + fun visitCumulativeGroupedBulk( + cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice + ): T + + fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice + ): T + + fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice + ): T + + fun visitMatrixWithDisplayName( + matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice + ): T + + fun visitGroupedTieredPackage( + groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice + ): T + + fun visitMatrixWithAllocation( + matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice + ): T + + fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice + ): T + + fun visitGroupedTiered(groupedTiered: NewSubscriptionGroupedTieredPrice): T + + fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ): T + + fun visitMinimum(minimum: Minimum): T + + /** + * Maps an unknown variant of [Price] to a value of type [T]. + * + * An instance of [Price] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is + * unaware of. + * + * @throws OrbInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw OrbInvalidDataException("Unknown Price: $json") + } + } + + internal class Deserializer : BaseDeserializer(Price::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Price { + val json = JsonValue.fromJsonNode(node) + val modelType = json.asObject()?.get("model_type")?.asString() + + when (modelType) { "unit" -> { return tryDeserialize(node, jacksonTypeRef()) ?.let { Price(unit = it, _json = json) } ?: Price(_json = json) } - "package" -> { + "package" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(package_ = it, _json = json) } ?: Price(_json = json) + } + "matrix" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(matrix = it, _json = json) } ?: Price(_json = json) + } + "tiered" -> { return tryDeserialize( node, - jacksonTypeRef(), + jacksonTypeRef(), + ) + ?.let { Price(tiered = it, _json = json) } ?: Price(_json = json) + } + "bulk" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(bulk = it, _json = json) } ?: Price(_json = json) + } + "threshold_total_amount" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(thresholdTotalAmount = it, _json = json) } + ?: Price(_json = json) + } + "tiered_package" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(tieredPackage = it, _json = json) } + ?: Price(_json = json) + } + "tiered_with_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(tieredWithMinimum = it, _json = json) } + ?: Price(_json = json) + } + "unit_with_percent" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(unitWithPercent = it, _json = json) } + ?: Price(_json = json) + } + "package_with_allocation" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(packageWithAllocation = it, _json = json) } + ?: Price(_json = json) + } + "tiered_with_proration" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(tieredWithProration = it, _json = json) } + ?: Price(_json = json) + } + "unit_with_proration" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(unitWithProration = it, _json = json) } + ?: Price(_json = json) + } + "grouped_allocation" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedAllocation = it, _json = json) } + ?: Price(_json = json) + } + "grouped_with_prorated_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedWithProratedMinimum = it, _json = json) } + ?: Price(_json = json) + } + "bulk_with_proration" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(bulkWithProration = it, _json = json) } + ?: Price(_json = json) + } + "scalable_matrix_with_unit_pricing" -> { + return tryDeserialize( + node, + jacksonTypeRef< + NewSubscriptionScalableMatrixWithUnitPricingPrice + >(), + ) + ?.let { Price(scalableMatrixWithUnitPricing = it, _json = json) } + ?: Price(_json = json) + } + "scalable_matrix_with_tiered_pricing" -> { + return tryDeserialize( + node, + jacksonTypeRef< + NewSubscriptionScalableMatrixWithTieredPricingPrice + >(), + ) + ?.let { Price(scalableMatrixWithTieredPricing = it, _json = json) } + ?: Price(_json = json) + } + "cumulative_grouped_bulk" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(cumulativeGroupedBulk = it, _json = json) } + ?: Price(_json = json) + } + "max_group_tiered_package" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(maxGroupTieredPackage = it, _json = json) } + ?: Price(_json = json) + } + "grouped_with_metered_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedWithMeteredMinimum = it, _json = json) } + ?: Price(_json = json) + } + "matrix_with_display_name" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(matrixWithDisplayName = it, _json = json) } + ?: Price(_json = json) + } + "grouped_tiered_package" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedTieredPackage = it, _json = json) } + ?: Price(_json = json) + } + "matrix_with_allocation" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(matrixWithAllocation = it, _json = json) } + ?: Price(_json = json) + } + "tiered_package_with_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(tieredPackageWithMinimum = it, _json = json) } + ?: Price(_json = json) + } + "grouped_tiered" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedTiered = it, _json = json) } + ?: Price(_json = json) + } + "grouped_with_min_max_thresholds" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedWithMinMaxThresholds = it, _json = json) } + ?: Price(_json = json) + } + "minimum" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(minimum = it, _json = json) + } ?: Price(_json = json) + } + } + + return Price(_json = json) + } + } + + internal class Serializer : BaseSerializer(Price::class) { + + override fun serialize( + value: Price, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.unit != null -> generator.writeObject(value.unit) + value.package_ != null -> generator.writeObject(value.package_) + value.matrix != null -> generator.writeObject(value.matrix) + value.tiered != null -> generator.writeObject(value.tiered) + value.bulk != null -> generator.writeObject(value.bulk) + value.thresholdTotalAmount != null -> + generator.writeObject(value.thresholdTotalAmount) + value.tieredPackage != null -> generator.writeObject(value.tieredPackage) + value.tieredWithMinimum != null -> + generator.writeObject(value.tieredWithMinimum) + value.unitWithPercent != null -> + generator.writeObject(value.unitWithPercent) + value.packageWithAllocation != null -> + generator.writeObject(value.packageWithAllocation) + value.tieredWithProration != null -> + generator.writeObject(value.tieredWithProration) + value.unitWithProration != null -> + generator.writeObject(value.unitWithProration) + value.groupedAllocation != null -> + generator.writeObject(value.groupedAllocation) + value.groupedWithProratedMinimum != null -> + generator.writeObject(value.groupedWithProratedMinimum) + value.bulkWithProration != null -> + generator.writeObject(value.bulkWithProration) + value.scalableMatrixWithUnitPricing != null -> + generator.writeObject(value.scalableMatrixWithUnitPricing) + value.scalableMatrixWithTieredPricing != null -> + generator.writeObject(value.scalableMatrixWithTieredPricing) + value.cumulativeGroupedBulk != null -> + generator.writeObject(value.cumulativeGroupedBulk) + value.maxGroupTieredPackage != null -> + generator.writeObject(value.maxGroupTieredPackage) + value.groupedWithMeteredMinimum != null -> + generator.writeObject(value.groupedWithMeteredMinimum) + value.matrixWithDisplayName != null -> + generator.writeObject(value.matrixWithDisplayName) + value.groupedTieredPackage != null -> + generator.writeObject(value.groupedTieredPackage) + value.matrixWithAllocation != null -> + generator.writeObject(value.matrixWithAllocation) + value.tieredPackageWithMinimum != null -> + generator.writeObject(value.tieredPackageWithMinimum) + value.groupedTiered != null -> generator.writeObject(value.groupedTiered) + value.groupedWithMinMaxThresholds != null -> + generator.writeObject(value.groupedWithMinMaxThresholds) + value.minimum != null -> generator.writeObject(value.minimum) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Price") + } + } + } + + class GroupedWithMinMaxThresholds + private constructor( + private val cadence: JsonField, + private val groupedWithMinMaxThresholdsConfig: + JsonField, + private val itemId: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("grouped_with_min_max_thresholds_config") + @ExcludeMissing + groupedWithMinMaxThresholdsConfig: + JsonField = + JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + groupedWithMinMaxThresholdsConfig, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupedWithMinMaxThresholdsConfig(): GroupedWithMinMaxThresholdsConfig = + groupedWithMinMaxThresholdsConfig.getRequired( + "grouped_with_min_max_thresholds_config" + ) + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * Expected to always return the following: + * ```kotlin + * JsonValue.from("grouped_with_min_max_thresholds") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = billableMetricId.getNullable("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + invoiceGroupingKey.getNullable("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [groupedWithMinMaxThresholdsConfig]. + * + * Unlike [groupedWithMinMaxThresholdsConfig], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("grouped_with_min_max_thresholds_config") + @ExcludeMissing + fun _groupedWithMinMaxThresholdsConfig(): + JsonField = groupedWithMinMaxThresholdsConfig + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [GroupedWithMinMaxThresholds]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .groupedWithMinMaxThresholdsConfig() + * .itemId() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [GroupedWithMinMaxThresholds]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var groupedWithMinMaxThresholdsConfig: + JsonField? = + null + private var itemId: JsonField? = null + private var modelType: JsonValue = + JsonValue.from("grouped_with_min_max_thresholds") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds) = + apply { + cadence = groupedWithMinMaxThresholds.cadence + groupedWithMinMaxThresholdsConfig = + groupedWithMinMaxThresholds.groupedWithMinMaxThresholdsConfig + itemId = groupedWithMinMaxThresholds.itemId + modelType = groupedWithMinMaxThresholds.modelType + name = groupedWithMinMaxThresholds.name + billableMetricId = groupedWithMinMaxThresholds.billableMetricId + billedInAdvance = groupedWithMinMaxThresholds.billedInAdvance + billingCycleConfiguration = + groupedWithMinMaxThresholds.billingCycleConfiguration + conversionRate = groupedWithMinMaxThresholds.conversionRate + conversionRateConfig = groupedWithMinMaxThresholds.conversionRateConfig + currency = groupedWithMinMaxThresholds.currency + dimensionalPriceConfiguration = + groupedWithMinMaxThresholds.dimensionalPriceConfiguration + externalPriceId = groupedWithMinMaxThresholds.externalPriceId + fixedPriceQuantity = groupedWithMinMaxThresholds.fixedPriceQuantity + invoiceGroupingKey = groupedWithMinMaxThresholds.invoiceGroupingKey + invoicingCycleConfiguration = + groupedWithMinMaxThresholds.invoicingCycleConfiguration + metadata = groupedWithMinMaxThresholds.metadata + referenceId = groupedWithMinMaxThresholds.referenceId + additionalProperties = + groupedWithMinMaxThresholds.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + fun groupedWithMinMaxThresholdsConfig( + groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + ) = + groupedWithMinMaxThresholdsConfig( + JsonField.of(groupedWithMinMaxThresholdsConfig) + ) + + /** + * Sets [Builder.groupedWithMinMaxThresholdsConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.groupedWithMinMaxThresholdsConfig] with a + * well-typed [GroupedWithMinMaxThresholdsConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun groupedWithMinMaxThresholdsConfig( + groupedWithMinMaxThresholdsConfig: + JsonField + ) = apply { + this.groupedWithMinMaxThresholdsConfig = groupedWithMinMaxThresholdsConfig + } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("grouped_with_min_max_thresholds") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT ) - ?.let { Price(package_ = it, _json = json) } ?: Price(_json = json) - } - "matrix" -> { - return tryDeserialize( - node, - jacksonTypeRef(), + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED ) - ?.let { Price(matrix = it, _json = json) } ?: Price(_json = json) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) } - "tiered" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(tiered = it, _json = json) } ?: Price(_json = json) + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [GroupedWithMinMaxThresholds]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .groupedWithMinMaxThresholdsConfig() + * .itemId() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedWithMinMaxThresholds = + GroupedWithMinMaxThresholds( + checkRequired("cadence", cadence), + checkRequired( + "groupedWithMinMaxThresholdsConfig", + groupedWithMinMaxThresholdsConfig, + ), + checkRequired("itemId", itemId), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GroupedWithMinMaxThresholds = apply { + if (validated) { + return@apply + } + + cadence().validate() + groupedWithMinMaxThresholdsConfig().validate() + itemId() + _modelType().let { + if (it != JsonValue.from("grouped_with_min_max_thresholds")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") } - "tiered_bps" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(tieredBps = it, _json = json) } ?: Price(_json = json) + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (groupedWithMinMaxThresholdsConfig.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + modelType.let { + if (it == JsonValue.from("grouped_with_min_max_thresholds")) 1 else 0 + } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false } - "bps" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(bps = it, _json = json) } ?: Price(_json = json) + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - "bulk_bps" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(bulkBps = it, _json = json) } ?: Price(_json = json) + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class GroupedWithMinMaxThresholdsConfig + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [GroupedWithMinMaxThresholdsConfig]. + */ + fun builder() = Builder() + } + + /** A builder for [GroupedWithMinMaxThresholdsConfig]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from( + groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + ) = apply { + additionalProperties = + groupedWithMinMaxThresholdsConfig.additionalProperties + .toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [GroupedWithMinMaxThresholdsConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): GroupedWithMinMaxThresholdsConfig = + GroupedWithMinMaxThresholdsConfig(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): GroupedWithMinMaxThresholdsConfig = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - "bulk" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(bulk = it, _json = json) } ?: Price(_json = json) + + return other is GroupedWithMinMaxThresholdsConfig && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedWithMinMaxThresholdsConfig{additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() } - "threshold_total_amount" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(thresholdTotalAmount = it, _json = json) } - ?: Price(_json = json) + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) } - "tiered_package" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(tieredPackage = it, _json = json) } - ?: Price(_json = json) + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) } - "tiered_with_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(tieredWithMinimum = it, _json = json) } - ?: Price(_json = json) + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) } - "unit_with_percent" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(unitWithPercent = it, _json = json) } - ?: Price(_json = json) + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply } - "package_with_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(packageWithAllocation = it, _json = json) } - ?: Price(_json = json) + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false } - "tiered_with_proration" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(tieredWithProration = it, _json = json) } - ?: Price(_json = json) + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() } - "unit_with_proration" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(unitWithProration = it, _json = json) } - ?: Price(_json = json) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - "grouped_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedWithMinMaxThresholds && + cadence == other.cadence && + groupedWithMinMaxThresholdsConfig == + other.groupedWithMinMaxThresholdsConfig && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + groupedWithMinMaxThresholdsConfig, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedWithMinMaxThresholds{cadence=$cadence, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class Minimum + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val minimumConfig: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("minimum_config") + @ExcludeMissing + minimumConfig: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + minimumConfig, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun minimumConfig(): MinimumConfig = minimumConfig.getRequired("minimum_config") + + /** + * Expected to always return the following: + * ```kotlin + * JsonValue.from("minimum") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = billableMetricId.getNullable("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + invoiceGroupingKey.getNullable("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [minimumConfig]. + * + * Unlike [minimumConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("minimum_config") + @ExcludeMissing + fun _minimumConfig(): JsonField = minimumConfig + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Minimum]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .minimumConfig() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Minimum]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var minimumConfig: JsonField? = null + private var modelType: JsonValue = JsonValue.from("minimum") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(minimum: Minimum) = apply { + cadence = minimum.cadence + itemId = minimum.itemId + minimumConfig = minimum.minimumConfig + modelType = minimum.modelType + name = minimum.name + billableMetricId = minimum.billableMetricId + billedInAdvance = minimum.billedInAdvance + billingCycleConfiguration = minimum.billingCycleConfiguration + conversionRate = minimum.conversionRate + conversionRateConfig = minimum.conversionRateConfig + currency = minimum.currency + dimensionalPriceConfiguration = minimum.dimensionalPriceConfiguration + externalPriceId = minimum.externalPriceId + fixedPriceQuantity = minimum.fixedPriceQuantity + invoiceGroupingKey = minimum.invoiceGroupingKey + invoicingCycleConfiguration = minimum.invoicingCycleConfiguration + metadata = minimum.metadata + referenceId = minimum.referenceId + additionalProperties = minimum.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun minimumConfig(minimumConfig: MinimumConfig) = + minimumConfig(JsonField.of(minimumConfig)) + + /** + * Sets [Builder.minimumConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumConfig] with a well-typed + * [MinimumConfig] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun minimumConfig(minimumConfig: JsonField) = apply { + this.minimumConfig = minimumConfig + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("minimum") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT ) - ?.let { Price(groupedAllocation = it, _json = json) } - ?: Price(_json = json) - } - "grouped_with_prorated_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED ) - ?.let { Price(groupedWithProratedMinimum = it, _json = json) } - ?: Price(_json = json) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) } - "bulk_with_proration" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(bulkWithProration = it, _json = json) } - ?: Price(_json = json) + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Minimum]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .minimumConfig() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Minimum = + Minimum( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("minimumConfig", minimumConfig), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Minimum = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + minimumConfig().validate() + _modelType().let { + if (it != JsonValue.from("minimum")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") } - "scalable_matrix_with_unit_pricing" -> { - return tryDeserialize( - node, - jacksonTypeRef< - NewSubscriptionScalableMatrixWithUnitPricingPrice - >(), - ) - ?.let { Price(scalableMatrixWithUnitPricing = it, _json = json) } - ?: Price(_json = json) + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + (minimumConfig.asKnown()?.validity() ?: 0) + + modelType.let { if (it == JsonValue.from("minimum")) 1 else 0 } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false } - "scalable_matrix_with_tiered_pricing" -> { - return tryDeserialize( - node, - jacksonTypeRef< - NewSubscriptionScalableMatrixWithTieredPricingPrice - >(), - ) - ?.let { Price(scalableMatrixWithTieredPricing = it, _json = json) } - ?: Price(_json = json) + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - "cumulative_grouped_bulk" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(cumulativeGroupedBulk = it, _json = json) } - ?: Price(_json = json) + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class MinimumConfig + private constructor( + private val minimumAmount: JsonField, + private val prorated: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("minimum_amount") + @ExcludeMissing + minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("prorated") + @ExcludeMissing + prorated: JsonField = JsonMissing.of(), + ) : this(minimumAmount, prorated, mutableMapOf()) + + /** + * The minimum amount to apply + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") + + /** + * By default, subtotals from minimum composite prices are prorated based on the + * service period. Set to false to disable proration. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun prorated(): Boolean? = prorated.getNullable("prorated") + + /** + * Returns the raw JSON value of [minimumAmount]. + * + * Unlike [minimumAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount + + /** + * Returns the raw JSON value of [prorated]. + * + * Unlike [prorated], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("prorated") + @ExcludeMissing + fun _prorated(): JsonField = prorated + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [MinimumConfig]. + * + * The following fields are required: + * ```kotlin + * .minimumAmount() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [MinimumConfig]. */ + class Builder internal constructor() { + + private var minimumAmount: JsonField? = null + private var prorated: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(minimumConfig: MinimumConfig) = apply { + minimumAmount = minimumConfig.minimumAmount + prorated = minimumConfig.prorated + additionalProperties = minimumConfig.additionalProperties.toMutableMap() + } + + /** The minimum amount to apply */ + fun minimumAmount(minimumAmount: String) = + minimumAmount(JsonField.of(minimumAmount)) + + /** + * Sets [Builder.minimumAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumAmount] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount + } + + /** + * By default, subtotals from minimum composite prices are prorated based on + * the service period. Set to false to disable proration. + */ + fun prorated(prorated: Boolean?) = prorated(JsonField.ofNullable(prorated)) + + /** + * Alias for [Builder.prorated]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun prorated(prorated: Boolean) = prorated(prorated as Boolean?) + + /** + * Sets [Builder.prorated] to an arbitrary JSON value. + * + * You should usually call [Builder.prorated] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun prorated(prorated: JsonField) = apply { + this.prorated = prorated + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [MinimumConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .minimumAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MinimumConfig = + MinimumConfig( + checkRequired("minimumAmount", minimumAmount), + prorated, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MinimumConfig = apply { + if (validated) { + return@apply } - "max_group_tiered_package" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(maxGroupTieredPackage = it, _json = json) } - ?: Price(_json = json) + + minimumAmount() + prorated() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (minimumAmount.asKnown() == null) 0 else 1) + + (if (prorated.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MinimumConfig && + minimumAmount == other.minimumAmount && + prorated == other.prorated && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(minimumAmount, prorated, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MinimumConfig{minimumAmount=$minimumAmount, prorated=$prorated, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() } - "grouped_with_metered_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedWithMeteredMinimum = it, _json = json) } - ?: Price(_json = json) + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) } - "matrix_with_display_name" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(matrixWithDisplayName = it, _json = json) } - ?: Price(_json = json) + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) } - "grouped_tiered_package" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedTieredPackage = it, _json = json) } - ?: Price(_json = json) + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) } - "matrix_with_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(matrixWithAllocation = it, _json = json) } - ?: Price(_json = json) + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply } - "tiered_package_with_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(tieredPackageWithMinimum = it, _json = json) } - ?: Price(_json = json) + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false } - "grouped_tiered" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedTiered = it, _json = json) } - ?: Price(_json = json) + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } + + return other is Metadata && + additionalProperties == other.additionalProperties } - return Price(_json = json) - } - } + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - internal class Serializer : BaseSerializer(Price::class) { + override fun hashCode(): Int = hashCode - override fun serialize( - value: Price, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unit != null -> generator.writeObject(value.unit) - value.package_ != null -> generator.writeObject(value.package_) - value.matrix != null -> generator.writeObject(value.matrix) - value.tiered != null -> generator.writeObject(value.tiered) - value.tieredBps != null -> generator.writeObject(value.tieredBps) - value.bps != null -> generator.writeObject(value.bps) - value.bulkBps != null -> generator.writeObject(value.bulkBps) - value.bulk != null -> generator.writeObject(value.bulk) - value.thresholdTotalAmount != null -> - generator.writeObject(value.thresholdTotalAmount) - value.tieredPackage != null -> generator.writeObject(value.tieredPackage) - value.tieredWithMinimum != null -> - generator.writeObject(value.tieredWithMinimum) - value.unitWithPercent != null -> - generator.writeObject(value.unitWithPercent) - value.packageWithAllocation != null -> - generator.writeObject(value.packageWithAllocation) - value.tieredWithProration != null -> - generator.writeObject(value.tieredWithProration) - value.unitWithProration != null -> - generator.writeObject(value.unitWithProration) - value.groupedAllocation != null -> - generator.writeObject(value.groupedAllocation) - value.groupedWithProratedMinimum != null -> - generator.writeObject(value.groupedWithProratedMinimum) - value.bulkWithProration != null -> - generator.writeObject(value.bulkWithProration) - value.scalableMatrixWithUnitPricing != null -> - generator.writeObject(value.scalableMatrixWithUnitPricing) - value.scalableMatrixWithTieredPricing != null -> - generator.writeObject(value.scalableMatrixWithTieredPricing) - value.cumulativeGroupedBulk != null -> - generator.writeObject(value.cumulativeGroupedBulk) - value.maxGroupTieredPackage != null -> - generator.writeObject(value.maxGroupTieredPackage) - value.groupedWithMeteredMinimum != null -> - generator.writeObject(value.groupedWithMeteredMinimum) - value.matrixWithDisplayName != null -> - generator.writeObject(value.matrixWithDisplayName) - value.groupedTieredPackage != null -> - generator.writeObject(value.groupedTieredPackage) - value.matrixWithAllocation != null -> - generator.writeObject(value.matrixWithAllocation) - value.tieredPackageWithMinimum != null -> - generator.writeObject(value.tieredPackageWithMinimum) - value.groupedTiered != null -> generator.writeObject(value.groupedTiered) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Price") + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } + + return other is Minimum && + cadence == other.cadence && + itemId == other.itemId && + minimumConfig == other.minimumConfig && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + minimumConfig, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Minimum{cadence=$cadence, itemId=$itemId, minimumConfig=$minimumConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } } diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/TieredBpsConfig.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/TieredBpsConfig.kt deleted file mode 100644 index 4e80e5049..000000000 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/TieredBpsConfig.kt +++ /dev/null @@ -1,186 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.withorb.api.models - -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import com.withorb.api.core.ExcludeMissing -import com.withorb.api.core.JsonField -import com.withorb.api.core.JsonMissing -import com.withorb.api.core.JsonValue -import com.withorb.api.core.checkKnown -import com.withorb.api.core.checkRequired -import com.withorb.api.core.toImmutable -import com.withorb.api.errors.OrbInvalidDataException -import java.util.Collections -import java.util.Objects - -class TieredBpsConfig -private constructor( - private val tiers: JsonField>, - private val additionalProperties: MutableMap, -) { - - @JsonCreator - private constructor( - @JsonProperty("tiers") @ExcludeMissing tiers: JsonField> = JsonMissing.of() - ) : this(tiers, mutableMapOf()) - - /** - * Tiers for a Graduated BPS pricing model, where usage is bucketed into specified tiers - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly - * missing or null (e.g. if the server responded with an unexpected value). - */ - fun tiers(): List = tiers.getRequired("tiers") - - /** - * Returns the raw JSON value of [tiers]. - * - * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("tiers") @ExcludeMissing fun _tiers(): JsonField> = tiers - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [TieredBpsConfig]. - * - * The following fields are required: - * ```kotlin - * .tiers() - * ``` - */ - fun builder() = Builder() - } - - /** A builder for [TieredBpsConfig]. */ - class Builder internal constructor() { - - private var tiers: JsonField>? = null - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(tieredBpsConfig: TieredBpsConfig) = apply { - tiers = tieredBpsConfig.tiers.map { it.toMutableList() } - additionalProperties = tieredBpsConfig.additionalProperties.toMutableMap() - } - - /** Tiers for a Graduated BPS pricing model, where usage is bucketed into specified tiers */ - fun tiers(tiers: List) = tiers(JsonField.of(tiers)) - - /** - * Sets [Builder.tiers] to an arbitrary JSON value. - * - * You should usually call [Builder.tiers] with a well-typed `List` value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun tiers(tiers: JsonField>) = apply { - this.tiers = tiers.map { it.toMutableList() } - } - - /** - * Adds a single [BpsTier] to [tiers]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addTier(tier: BpsTier) = apply { - tiers = - (tiers ?: JsonField.of(mutableListOf())).also { checkKnown("tiers", it).add(tier) } - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [TieredBpsConfig]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```kotlin - * .tiers() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): TieredBpsConfig = - TieredBpsConfig( - checkRequired("tiers", tiers).map { it.toImmutable() }, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): TieredBpsConfig = apply { - if (validated) { - return@apply - } - - tiers().forEach { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = (tiers.asKnown()?.sumOf { it.validity().toInt() } ?: 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is TieredBpsConfig && - tiers == other.tiers && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(tiers, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "TieredBpsConfig{tiers=$tiers, additionalProperties=$additionalProperties}" -} diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/AlertServiceAsync.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/AlertServiceAsync.kt index ddb4835ce..aa938149e 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/AlertServiceAsync.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/AlertServiceAsync.kt @@ -70,8 +70,8 @@ interface AlertServiceAsync { * * The request must specify one of `customer_id`, `external_customer_id`, or `subscription_id`. * - * If querying by subscripion_id, the endpoint will return the subscription level alerts as well - * as the plan level alerts associated with the subscription. + * If querying by subscription_id, the endpoint will return the subscription level alerts as + * well as the plan level alerts associated with the subscription. * * The list of alerts is ordered starting from the most recently created alert. This endpoint * follows Orb's [standardized pagination format](/api-reference/pagination). diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/DimensionalPriceGroupServiceAsync.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/DimensionalPriceGroupServiceAsync.kt index 873325dfd..2b31fdbc5 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/DimensionalPriceGroupServiceAsync.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/DimensionalPriceGroupServiceAsync.kt @@ -32,7 +32,7 @@ interface DimensionalPriceGroupServiceAsync { /** * A dimensional price group is used to partition the result of a billable metric by a set of - * dimensions. Prices in a price group must specify the parition used to derive their usage. + * dimensions. Prices in a price group must specify the partition used to derive their usage. * * For example, suppose we have a billable metric that measures the number of widgets used and * we want to charge differently depending on the color of the widget. We can create a price diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/InvoiceServiceAsync.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/InvoiceServiceAsync.kt index 8635b4ab6..540570c01 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/InvoiceServiceAsync.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/InvoiceServiceAsync.kt @@ -138,8 +138,8 @@ interface InvoiceServiceAsync { issue(invoiceId, InvoiceIssueParams.none(), requestOptions) /** - * This endpoint allows an invoice's status to be set the `paid` status. This can only be done - * to invoices that are in the `issued` status. + * This endpoint allows an invoice's status to be set to the `paid` status. This can only be + * done to invoices that are in the `issued` or `synced` status. */ suspend fun markPaid( invoiceId: String, @@ -174,8 +174,8 @@ interface InvoiceServiceAsync { pay(invoiceId, InvoicePayParams.none(), requestOptions) /** - * This endpoint allows an invoice's status to be set the `void` status. This can only be done - * to invoices that are in the `issued` status. + * This endpoint allows an invoice's status to be set to the `void` status. This can only be + * done to invoices that are in the `issued` status. * * If the associated invoice has used the customer balance to change the amount due, the * customer balance operation will be reverted. For example, if the invoice used \$10 of diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/SubscriptionServiceAsync.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/SubscriptionServiceAsync.kt index 2288fb74d..825529d4d 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/SubscriptionServiceAsync.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/SubscriptionServiceAsync.kt @@ -776,8 +776,8 @@ interface SubscriptionServiceAsync { * This endpoint can be used to change an existing subscription's plan. It returns the * serialized updated subscription object. * - * The body parameter `change_option` determines when the plan change occurrs. Orb supports - * three options: + * The body parameter `change_option` determines when the plan change occurs. Orb supports three + * options: * - `end_of_subscription_term`: changes the plan at the end of the existing plan's term. * - Issuing this plan change request for a monthly subscription will keep the existing plan * active until the start of the subsequent month. Issuing this plan change request for a diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/customers/credits/LedgerServiceAsync.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/customers/credits/LedgerServiceAsync.kt index f314cb94e..32a819d9c 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/customers/credits/LedgerServiceAsync.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/customers/credits/LedgerServiceAsync.kt @@ -84,7 +84,7 @@ interface LedgerServiceAsync { * * Note that for this entry type, `starting_balance` will equal `ending_balance`, and the * `amount` represents the balance transferred. The credit block linked to the ledger entry is - * the source credit block from which there was an expiration change + * the source credit block from which there was an expiration change. * * ## Credits expiry * @@ -418,7 +418,7 @@ interface LedgerServiceAsync { * * Note that for this entry type, `starting_balance` will equal `ending_balance`, and the * `amount` represents the balance transferred. The credit block linked to the ledger entry is - * the source credit block from which there was an expiration change + * the source credit block from which there was an expiration change. * * ## Credits expiry * diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/events/BackfillServiceAsync.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/events/BackfillServiceAsync.kt index 6eaa43321..2c0aa9a3b 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/events/BackfillServiceAsync.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/events/BackfillServiceAsync.kt @@ -56,7 +56,7 @@ interface BackfillServiceAsync { * * When `replace_existing_events` is `true`, this indicates that existing events in the * timeframe should no longer be counted towards invoiced usage. In this scenario, the parameter - * `filter` can be optionally added which enables filtering using + * `deprecation_filter` can be optionally added which enables filtering using * [computed properties](/extensibility/advanced-metrics#computed-properties). The * expressiveness of computed properties allows you to deprecate existing events based on both a * period of time and specific property values. diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/AlertService.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/AlertService.kt index 46a1cd43e..151142084 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/AlertService.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/AlertService.kt @@ -70,8 +70,8 @@ interface AlertService { * * The request must specify one of `customer_id`, `external_customer_id`, or `subscription_id`. * - * If querying by subscripion_id, the endpoint will return the subscription level alerts as well - * as the plan level alerts associated with the subscription. + * If querying by subscription_id, the endpoint will return the subscription level alerts as + * well as the plan level alerts associated with the subscription. * * The list of alerts is ordered starting from the most recently created alert. This endpoint * follows Orb's [standardized pagination format](/api-reference/pagination). diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/DimensionalPriceGroupService.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/DimensionalPriceGroupService.kt index cb8d062ae..e623d277f 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/DimensionalPriceGroupService.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/DimensionalPriceGroupService.kt @@ -32,7 +32,7 @@ interface DimensionalPriceGroupService { /** * A dimensional price group is used to partition the result of a billable metric by a set of - * dimensions. Prices in a price group must specify the parition used to derive their usage. + * dimensions. Prices in a price group must specify the partition used to derive their usage. * * For example, suppose we have a billable metric that measures the number of widgets used and * we want to charge differently depending on the color of the widget. We can create a price diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/InvoiceService.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/InvoiceService.kt index e32d5f19c..3b87c944a 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/InvoiceService.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/InvoiceService.kt @@ -138,8 +138,8 @@ interface InvoiceService { issue(invoiceId, InvoiceIssueParams.none(), requestOptions) /** - * This endpoint allows an invoice's status to be set the `paid` status. This can only be done - * to invoices that are in the `issued` status. + * This endpoint allows an invoice's status to be set to the `paid` status. This can only be + * done to invoices that are in the `issued` or `synced` status. */ fun markPaid( invoiceId: String, @@ -174,8 +174,8 @@ interface InvoiceService { pay(invoiceId, InvoicePayParams.none(), requestOptions) /** - * This endpoint allows an invoice's status to be set the `void` status. This can only be done - * to invoices that are in the `issued` status. + * This endpoint allows an invoice's status to be set to the `void` status. This can only be + * done to invoices that are in the `issued` status. * * If the associated invoice has used the customer balance to change the amount due, the * customer balance operation will be reverted. For example, if the invoice used \$10 of diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/SubscriptionService.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/SubscriptionService.kt index bc144afc1..1461e89b9 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/SubscriptionService.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/SubscriptionService.kt @@ -773,8 +773,8 @@ interface SubscriptionService { * This endpoint can be used to change an existing subscription's plan. It returns the * serialized updated subscription object. * - * The body parameter `change_option` determines when the plan change occurrs. Orb supports - * three options: + * The body parameter `change_option` determines when the plan change occurs. Orb supports three + * options: * - `end_of_subscription_term`: changes the plan at the end of the existing plan's term. * - Issuing this plan change request for a monthly subscription will keep the existing plan * active until the start of the subsequent month. Issuing this plan change request for a diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/customers/credits/LedgerService.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/customers/credits/LedgerService.kt index 2368f1358..58074adf5 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/customers/credits/LedgerService.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/customers/credits/LedgerService.kt @@ -84,7 +84,7 @@ interface LedgerService { * * Note that for this entry type, `starting_balance` will equal `ending_balance`, and the * `amount` represents the balance transferred. The credit block linked to the ledger entry is - * the source credit block from which there was an expiration change + * the source credit block from which there was an expiration change. * * ## Credits expiry * @@ -415,7 +415,7 @@ interface LedgerService { * * Note that for this entry type, `starting_balance` will equal `ending_balance`, and the * `amount` represents the balance transferred. The credit block linked to the ledger entry is - * the source credit block from which there was an expiration change + * the source credit block from which there was an expiration change. * * ## Credits expiry * diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/events/BackfillService.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/events/BackfillService.kt index 2dbaa7a8d..5d450b198 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/events/BackfillService.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/events/BackfillService.kt @@ -56,7 +56,7 @@ interface BackfillService { * * When `replace_existing_events` is `true`, this indicates that existing events in the * timeframe should no longer be counted towards invoiced usage. In this scenario, the parameter - * `filter` can be optionally added which enables filtering using + * `deprecation_filter` can be optionally added which enables filtering using * [computed properties](/extensibility/advanced-metrics#computed-properties). The * expressiveness of computed properties allows you to deprecate existing events based on both a * period of time and specific property values. diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/AggregatedCostTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/AggregatedCostTest.kt index f62a16ed1..b517b9a41 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/AggregatedCostTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/AggregatedCostTest.kt @@ -28,6 +28,13 @@ internal class AggregatedCostTest { .build() ) .cadence(Price.Unit.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder() @@ -145,6 +152,13 @@ internal class AggregatedCostTest { .build() ) .cadence(Price.Unit.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() @@ -266,6 +280,13 @@ internal class AggregatedCostTest { .build() ) .cadence(Price.Unit.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder() diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/BpsConfigTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/BpsConfigTest.kt deleted file mode 100644 index 0c5056b3f..000000000 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/BpsConfigTest.kt +++ /dev/null @@ -1,33 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.withorb.api.models - -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.withorb.api.core.jsonMapper -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class BpsConfigTest { - - @Test - fun create() { - val bpsConfig = BpsConfig.builder().bps(0.0).perUnitMaximum("per_unit_maximum").build() - - assertThat(bpsConfig.bps()).isEqualTo(0.0) - assertThat(bpsConfig.perUnitMaximum()).isEqualTo("per_unit_maximum") - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val bpsConfig = BpsConfig.builder().bps(0.0).perUnitMaximum("per_unit_maximum").build() - - val roundtrippedBpsConfig = - jsonMapper.readValue( - jsonMapper.writeValueAsString(bpsConfig), - jacksonTypeRef(), - ) - - assertThat(roundtrippedBpsConfig).isEqualTo(bpsConfig) - } -} diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/BpsTierTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/BpsTierTest.kt deleted file mode 100644 index 068a3488b..000000000 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/BpsTierTest.kt +++ /dev/null @@ -1,44 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.withorb.api.models - -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.withorb.api.core.jsonMapper -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class BpsTierTest { - - @Test - fun create() { - val bpsTier = - BpsTier.builder() - .bps(0.0) - .minimumAmount("minimum_amount") - .maximumAmount("maximum_amount") - .perUnitMaximum("per_unit_maximum") - .build() - - assertThat(bpsTier.bps()).isEqualTo(0.0) - assertThat(bpsTier.minimumAmount()).isEqualTo("minimum_amount") - assertThat(bpsTier.maximumAmount()).isEqualTo("maximum_amount") - assertThat(bpsTier.perUnitMaximum()).isEqualTo("per_unit_maximum") - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val bpsTier = - BpsTier.builder() - .bps(0.0) - .minimumAmount("minimum_amount") - .maximumAmount("maximum_amount") - .perUnitMaximum("per_unit_maximum") - .build() - - val roundtrippedBpsTier = - jsonMapper.readValue(jsonMapper.writeValueAsString(bpsTier), jacksonTypeRef()) - - assertThat(roundtrippedBpsTier).isEqualTo(bpsTier) - } -} diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/BulkBpsConfigTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/BulkBpsConfigTest.kt deleted file mode 100644 index 8ff08186e..000000000 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/BulkBpsConfigTest.kt +++ /dev/null @@ -1,57 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.withorb.api.models - -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.withorb.api.core.jsonMapper -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class BulkBpsConfigTest { - - @Test - fun create() { - val bulkBpsConfig = - BulkBpsConfig.builder() - .addTier( - BulkBpsTier.builder() - .bps(0.0) - .maximumAmount("maximum_amount") - .perUnitMaximum("per_unit_maximum") - .build() - ) - .build() - - assertThat(bulkBpsConfig.tiers()) - .containsExactly( - BulkBpsTier.builder() - .bps(0.0) - .maximumAmount("maximum_amount") - .perUnitMaximum("per_unit_maximum") - .build() - ) - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val bulkBpsConfig = - BulkBpsConfig.builder() - .addTier( - BulkBpsTier.builder() - .bps(0.0) - .maximumAmount("maximum_amount") - .perUnitMaximum("per_unit_maximum") - .build() - ) - .build() - - val roundtrippedBulkBpsConfig = - jsonMapper.readValue( - jsonMapper.writeValueAsString(bulkBpsConfig), - jacksonTypeRef(), - ) - - assertThat(roundtrippedBulkBpsConfig).isEqualTo(bulkBpsConfig) - } -} diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/BulkBpsTierTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/BulkBpsTierTest.kt deleted file mode 100644 index 426b9b50a..000000000 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/BulkBpsTierTest.kt +++ /dev/null @@ -1,44 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.withorb.api.models - -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.withorb.api.core.jsonMapper -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class BulkBpsTierTest { - - @Test - fun create() { - val bulkBpsTier = - BulkBpsTier.builder() - .bps(0.0) - .maximumAmount("maximum_amount") - .perUnitMaximum("per_unit_maximum") - .build() - - assertThat(bulkBpsTier.bps()).isEqualTo(0.0) - assertThat(bulkBpsTier.maximumAmount()).isEqualTo("maximum_amount") - assertThat(bulkBpsTier.perUnitMaximum()).isEqualTo("per_unit_maximum") - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val bulkBpsTier = - BulkBpsTier.builder() - .bps(0.0) - .maximumAmount("maximum_amount") - .perUnitMaximum("per_unit_maximum") - .build() - - val roundtrippedBulkBpsTier = - jsonMapper.readValue( - jsonMapper.writeValueAsString(bulkBpsTier), - jacksonTypeRef(), - ) - - assertThat(roundtrippedBulkBpsTier).isEqualTo(bulkBpsTier) - } -} diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/ChangedSubscriptionResourcesTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/ChangedSubscriptionResourcesTest.kt index 05ee64f7c..afbfabd98 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/ChangedSubscriptionResourcesTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/ChangedSubscriptionResourcesTest.kt @@ -287,6 +287,13 @@ internal class ChangedSubscriptionResourcesTest { .build() ) .cadence(Price.Unit.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder() @@ -471,6 +478,9 @@ internal class ChangedSubscriptionResourcesTest { .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .paymentProvider(Invoice.PaymentAttempt.PaymentProvider.STRIPE) .paymentProviderId("payment_provider_id") + .receiptPdf( + "https://assets.withorb.com/receipt/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" + ) .succeeded(true) .build() ) @@ -768,6 +778,13 @@ internal class ChangedSubscriptionResourcesTest { .build() ) .cadence(Price.Unit.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder() @@ -952,6 +969,9 @@ internal class ChangedSubscriptionResourcesTest { .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .paymentProvider(Invoice.PaymentAttempt.PaymentProvider.STRIPE) .paymentProviderId("payment_provider_id") + .receiptPdf( + "https://assets.withorb.com/receipt/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" + ) .succeeded(true) .build() ) @@ -1245,6 +1265,13 @@ internal class ChangedSubscriptionResourcesTest { .build() ) .cadence(Price.Unit.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder() @@ -1422,6 +1449,9 @@ internal class ChangedSubscriptionResourcesTest { .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .paymentProvider(Invoice.PaymentAttempt.PaymentProvider.STRIPE) .paymentProviderId("payment_provider_id") + .receiptPdf( + "https://assets.withorb.com/receipt/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" + ) .succeeded(true) .build() ) @@ -1713,6 +1743,13 @@ internal class ChangedSubscriptionResourcesTest { .build() ) .cadence(Price.Unit.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder() @@ -1890,6 +1927,9 @@ internal class ChangedSubscriptionResourcesTest { .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .paymentProvider(Invoice.PaymentAttempt.PaymentProvider.STRIPE) .paymentProviderId("payment_provider_id") + .receiptPdf( + "https://assets.withorb.com/receipt/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" + ) .succeeded(true) .build() ) @@ -2194,6 +2234,13 @@ internal class ChangedSubscriptionResourcesTest { .build() ) .cadence(Price.Unit.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder() @@ -2378,6 +2425,9 @@ internal class ChangedSubscriptionResourcesTest { .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .paymentProvider(Invoice.PaymentAttempt.PaymentProvider.STRIPE) .paymentProviderId("payment_provider_id") + .receiptPdf( + "https://assets.withorb.com/receipt/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" + ) .succeeded(true) .build() ) @@ -2675,6 +2725,13 @@ internal class ChangedSubscriptionResourcesTest { .build() ) .cadence(Price.Unit.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder() @@ -2859,6 +2916,9 @@ internal class ChangedSubscriptionResourcesTest { .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .paymentProvider(Invoice.PaymentAttempt.PaymentProvider.STRIPE) .paymentProviderId("payment_provider_id") + .receiptPdf( + "https://assets.withorb.com/receipt/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" + ) .succeeded(true) .build() ) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCostListByExternalIdResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCostListByExternalIdResponseTest.kt index 21dd041d4..22ba89f9b 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCostListByExternalIdResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCostListByExternalIdResponseTest.kt @@ -34,6 +34,13 @@ internal class CustomerCostListByExternalIdResponseTest { .build() ) .cadence(Price.Unit.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder() @@ -176,6 +183,13 @@ internal class CustomerCostListByExternalIdResponseTest { .build() ) .cadence(Price.Unit.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder() @@ -317,6 +331,13 @@ internal class CustomerCostListByExternalIdResponseTest { .build() ) .cadence(Price.Unit.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder() diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCostListResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCostListResponseTest.kt index d6bcaf783..5f0071abc 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCostListResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCostListResponseTest.kt @@ -34,6 +34,13 @@ internal class CustomerCostListResponseTest { .build() ) .cadence(Price.Unit.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder() @@ -176,6 +183,13 @@ internal class CustomerCostListResponseTest { .build() ) .cadence(Price.Unit.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder() @@ -317,6 +331,13 @@ internal class CustomerCostListResponseTest { .build() ) .cadence(Price.Unit.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder() diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreateParamsTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreateParamsTest.kt index 163b89ce3..21299ff7e 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreateParamsTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreateParamsTest.kt @@ -26,6 +26,7 @@ internal class CustomerCreateParamsTest { ) .addAdditionalEmail("dev@stainless.com") .autoCollection(true) + .autoIssuance(true) .billingAddress( AddressInput.builder() .city("city") @@ -100,6 +101,7 @@ internal class CustomerCreateParamsTest { ) .addAdditionalEmail("dev@stainless.com") .autoCollection(true) + .autoIssuance(true) .billingAddress( AddressInput.builder() .city("city") @@ -172,6 +174,7 @@ internal class CustomerCreateParamsTest { ) assertThat(body.additionalEmails()).containsExactly("dev@stainless.com") assertThat(body.autoCollection()).isEqualTo(true) + assertThat(body.autoIssuance()).isEqualTo(true) assertThat(body.billingAddress()) .isEqualTo( AddressInput.builder() diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdParamsTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdParamsTest.kt index 23a9caafa..8fb52e174 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdParamsTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdParamsTest.kt @@ -27,6 +27,7 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdParamsTest { .builder() .autoCollection(true) .netTerms(0L) + .customDueDate(LocalDate.parse("2019-12-27")) .invoiceDate(LocalDate.parse("2019-12-27")) .memo("memo") .requireSuccessfulPayment(true) @@ -75,6 +76,7 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdParamsTest { .builder() .autoCollection(true) .netTerms(0L) + .customDueDate(LocalDate.parse("2019-12-27")) .invoiceDate(LocalDate.parse("2019-12-27")) .memo("memo") .requireSuccessfulPayment(true) @@ -109,6 +111,7 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdParamsTest { .builder() .autoCollection(true) .netTerms(0L) + .customDueDate(LocalDate.parse("2019-12-27")) .invoiceDate(LocalDate.parse("2019-12-27")) .memo("memo") .requireSuccessfulPayment(true) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdResponseTest.kt index 46ce457c6..c3b9ebc9a 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdResponseTest.kt @@ -233,6 +233,13 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdResponseTest { .build() ) .cadence(Price.Unit.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder() @@ -417,6 +424,9 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdResponseTest { .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .paymentProvider(Invoice.PaymentAttempt.PaymentProvider.STRIPE) .paymentProviderId("payment_provider_id") + .receiptPdf( + "https://assets.withorb.com/receipt/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" + ) .succeeded(true) .build() ) @@ -687,6 +697,15 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdResponseTest { .build() ) .cadence(Price.Unit.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator( + TransformPriceFilter.Operator.INCLUDES + ) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder() @@ -884,6 +903,9 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdResponseTest { .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .paymentProvider(Invoice.PaymentAttempt.PaymentProvider.STRIPE) .paymentProviderId("payment_provider_id") + .receiptPdf( + "https://assets.withorb.com/receipt/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" + ) .succeeded(true) .build() ) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryParamsTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryParamsTest.kt index 615cba892..746f8a2e5 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryParamsTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryParamsTest.kt @@ -26,6 +26,7 @@ internal class CustomerCreditLedgerCreateEntryParamsTest { .builder() .autoCollection(true) .netTerms(0L) + .customDueDate(LocalDate.parse("2019-12-27")) .invoiceDate(LocalDate.parse("2019-12-27")) .memo("memo") .requireSuccessfulPayment(true) @@ -72,6 +73,7 @@ internal class CustomerCreditLedgerCreateEntryParamsTest { .builder() .autoCollection(true) .netTerms(0L) + .customDueDate(LocalDate.parse("2019-12-27")) .invoiceDate(LocalDate.parse("2019-12-27")) .memo("memo") .requireSuccessfulPayment(true) @@ -103,6 +105,7 @@ internal class CustomerCreditLedgerCreateEntryParamsTest { .builder() .autoCollection(true) .netTerms(0L) + .customDueDate(LocalDate.parse("2019-12-27")) .invoiceDate(LocalDate.parse("2019-12-27")) .memo("memo") .requireSuccessfulPayment(true) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryResponseTest.kt index e2e396c26..54bd808cc 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryResponseTest.kt @@ -233,6 +233,13 @@ internal class CustomerCreditLedgerCreateEntryResponseTest { .build() ) .cadence(Price.Unit.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder() @@ -417,6 +424,9 @@ internal class CustomerCreditLedgerCreateEntryResponseTest { .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .paymentProvider(Invoice.PaymentAttempt.PaymentProvider.STRIPE) .paymentProviderId("payment_provider_id") + .receiptPdf( + "https://assets.withorb.com/receipt/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" + ) .succeeded(true) .build() ) @@ -686,6 +696,15 @@ internal class CustomerCreditLedgerCreateEntryResponseTest { .build() ) .cadence(Price.Unit.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator( + TransformPriceFilter.Operator.INCLUDES + ) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder() @@ -883,6 +902,9 @@ internal class CustomerCreditLedgerCreateEntryResponseTest { .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .paymentProvider(Invoice.PaymentAttempt.PaymentProvider.STRIPE) .paymentProviderId("payment_provider_id") + .receiptPdf( + "https://assets.withorb.com/receipt/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" + ) .succeeded(true) .build() ) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdPageResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdPageResponseTest.kt index 79e0ce7ee..f5bda2071 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdPageResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdPageResponseTest.kt @@ -249,6 +249,15 @@ internal class CustomerCreditLedgerListByExternalIdPageResponseTest { .build() ) .cadence(Price.Unit.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator( + TransformPriceFilter.Operator.INCLUDES + ) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder() @@ -458,6 +467,9 @@ internal class CustomerCreditLedgerListByExternalIdPageResponseTest { Invoice.PaymentAttempt.PaymentProvider.STRIPE ) .paymentProviderId("payment_provider_id") + .receiptPdf( + "https://assets.withorb.com/receipt/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" + ) .succeeded(true) .build() ) @@ -728,6 +740,15 @@ internal class CustomerCreditLedgerListByExternalIdPageResponseTest { .build() ) .cadence(Price.Unit.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator( + TransformPriceFilter.Operator.INCLUDES + ) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder() @@ -937,6 +958,9 @@ internal class CustomerCreditLedgerListByExternalIdPageResponseTest { Invoice.PaymentAttempt.PaymentProvider.STRIPE ) .paymentProviderId("payment_provider_id") + .receiptPdf( + "https://assets.withorb.com/receipt/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" + ) .succeeded(true) .build() ) @@ -1210,6 +1234,15 @@ internal class CustomerCreditLedgerListByExternalIdPageResponseTest { .build() ) .cadence(Price.Unit.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator( + TransformPriceFilter.Operator.INCLUDES + ) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder() @@ -1419,6 +1452,9 @@ internal class CustomerCreditLedgerListByExternalIdPageResponseTest { Invoice.PaymentAttempt.PaymentProvider.STRIPE ) .paymentProviderId("payment_provider_id") + .receiptPdf( + "https://assets.withorb.com/receipt/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" + ) .succeeded(true) .build() ) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdResponseTest.kt index fa7b31859..ced450523 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdResponseTest.kt @@ -233,6 +233,13 @@ internal class CustomerCreditLedgerListByExternalIdResponseTest { .build() ) .cadence(Price.Unit.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder() @@ -417,6 +424,9 @@ internal class CustomerCreditLedgerListByExternalIdResponseTest { .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .paymentProvider(Invoice.PaymentAttempt.PaymentProvider.STRIPE) .paymentProviderId("payment_provider_id") + .receiptPdf( + "https://assets.withorb.com/receipt/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" + ) .succeeded(true) .build() ) @@ -686,6 +696,15 @@ internal class CustomerCreditLedgerListByExternalIdResponseTest { .build() ) .cadence(Price.Unit.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator( + TransformPriceFilter.Operator.INCLUDES + ) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder() @@ -883,6 +902,9 @@ internal class CustomerCreditLedgerListByExternalIdResponseTest { .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .paymentProvider(Invoice.PaymentAttempt.PaymentProvider.STRIPE) .paymentProviderId("payment_provider_id") + .receiptPdf( + "https://assets.withorb.com/receipt/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" + ) .succeeded(true) .build() ) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListPageResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListPageResponseTest.kt index 3c66b293a..cfc8ff742 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListPageResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListPageResponseTest.kt @@ -249,6 +249,15 @@ internal class CustomerCreditLedgerListPageResponseTest { .build() ) .cadence(Price.Unit.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator( + TransformPriceFilter.Operator.INCLUDES + ) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder() @@ -458,6 +467,9 @@ internal class CustomerCreditLedgerListPageResponseTest { Invoice.PaymentAttempt.PaymentProvider.STRIPE ) .paymentProviderId("payment_provider_id") + .receiptPdf( + "https://assets.withorb.com/receipt/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" + ) .succeeded(true) .build() ) @@ -728,6 +740,15 @@ internal class CustomerCreditLedgerListPageResponseTest { .build() ) .cadence(Price.Unit.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator( + TransformPriceFilter.Operator.INCLUDES + ) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder() @@ -937,6 +958,9 @@ internal class CustomerCreditLedgerListPageResponseTest { Invoice.PaymentAttempt.PaymentProvider.STRIPE ) .paymentProviderId("payment_provider_id") + .receiptPdf( + "https://assets.withorb.com/receipt/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" + ) .succeeded(true) .build() ) @@ -1210,6 +1234,15 @@ internal class CustomerCreditLedgerListPageResponseTest { .build() ) .cadence(Price.Unit.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator( + TransformPriceFilter.Operator.INCLUDES + ) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder() @@ -1419,6 +1452,9 @@ internal class CustomerCreditLedgerListPageResponseTest { Invoice.PaymentAttempt.PaymentProvider.STRIPE ) .paymentProviderId("payment_provider_id") + .receiptPdf( + "https://assets.withorb.com/receipt/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" + ) .succeeded(true) .build() ) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListResponseTest.kt index c0a2f5eb7..6e196c30f 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListResponseTest.kt @@ -233,6 +233,13 @@ internal class CustomerCreditLedgerListResponseTest { .build() ) .cadence(Price.Unit.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder() @@ -417,6 +424,9 @@ internal class CustomerCreditLedgerListResponseTest { .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .paymentProvider(Invoice.PaymentAttempt.PaymentProvider.STRIPE) .paymentProviderId("payment_provider_id") + .receiptPdf( + "https://assets.withorb.com/receipt/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" + ) .succeeded(true) .build() ) @@ -686,6 +696,15 @@ internal class CustomerCreditLedgerListResponseTest { .build() ) .cadence(Price.Unit.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator( + TransformPriceFilter.Operator.INCLUDES + ) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder() @@ -883,6 +902,9 @@ internal class CustomerCreditLedgerListResponseTest { .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .paymentProvider(Invoice.PaymentAttempt.PaymentProvider.STRIPE) .paymentProviderId("payment_provider_id") + .receiptPdf( + "https://assets.withorb.com/receipt/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" + ) .succeeded(true) .build() ) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerListPageResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerListPageResponseTest.kt index bb3c672cb..3d264a891 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerListPageResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerListPageResponseTest.kt @@ -20,6 +20,7 @@ internal class CustomerListPageResponseTest { .id("id") .addAdditionalEmail("string") .autoCollection(true) + .autoIssuance(true) .balance("balance") .billingAddress( Address.builder() @@ -112,6 +113,7 @@ internal class CustomerListPageResponseTest { .id("id") .addAdditionalEmail("string") .autoCollection(true) + .autoIssuance(true) .balance("balance") .billingAddress( Address.builder() @@ -206,6 +208,7 @@ internal class CustomerListPageResponseTest { .id("id") .addAdditionalEmail("string") .autoCollection(true) + .autoIssuance(true) .balance("balance") .billingAddress( Address.builder() diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerTest.kt index 736e7d60f..e51f3ab3a 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerTest.kt @@ -18,6 +18,7 @@ internal class CustomerTest { .id("id") .addAdditionalEmail("string") .autoCollection(true) + .autoIssuance(true) .balance("balance") .billingAddress( Address.builder() @@ -101,6 +102,7 @@ internal class CustomerTest { assertThat(customer.id()).isEqualTo("id") assertThat(customer.additionalEmails()).containsExactly("string") assertThat(customer.autoCollection()).isEqualTo(true) + assertThat(customer.autoIssuance()).isEqualTo(true) assertThat(customer.balance()).isEqualTo("balance") assertThat(customer.billingAddress()) .isEqualTo( @@ -193,6 +195,7 @@ internal class CustomerTest { .id("id") .addAdditionalEmail("string") .autoCollection(true) + .autoIssuance(true) .balance("balance") .billingAddress( Address.builder() diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerUpdateByExternalIdParamsTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerUpdateByExternalIdParamsTest.kt index 0f8e918f0..05579b6f9 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerUpdateByExternalIdParamsTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerUpdateByExternalIdParamsTest.kt @@ -25,6 +25,7 @@ internal class CustomerUpdateByExternalIdParamsTest { ) .addAdditionalEmail("string") .autoCollection(true) + .autoIssuance(true) .billingAddress( AddressInput.builder() .city("city") @@ -108,6 +109,7 @@ internal class CustomerUpdateByExternalIdParamsTest { ) .addAdditionalEmail("string") .autoCollection(true) + .autoIssuance(true) .billingAddress( AddressInput.builder() .city("city") @@ -179,6 +181,7 @@ internal class CustomerUpdateByExternalIdParamsTest { ) assertThat(body.additionalEmails()).containsExactly("string") assertThat(body.autoCollection()).isEqualTo(true) + assertThat(body.autoIssuance()).isEqualTo(true) assertThat(body.billingAddress()) .isEqualTo( AddressInput.builder() diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerUpdateParamsTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerUpdateParamsTest.kt index e4f795630..adb92b9d2 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerUpdateParamsTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerUpdateParamsTest.kt @@ -25,6 +25,7 @@ internal class CustomerUpdateParamsTest { ) .addAdditionalEmail("string") .autoCollection(true) + .autoIssuance(true) .billingAddress( AddressInput.builder() .city("city") @@ -108,6 +109,7 @@ internal class CustomerUpdateParamsTest { ) .addAdditionalEmail("string") .autoCollection(true) + .autoIssuance(true) .billingAddress( AddressInput.builder() .city("city") @@ -179,6 +181,7 @@ internal class CustomerUpdateParamsTest { ) assertThat(body.additionalEmails()).containsExactly("string") assertThat(body.autoCollection()).isEqualTo(true) + assertThat(body.autoIssuance()).isEqualTo(true) assertThat(body.billingAddress()) .isEqualTo( AddressInput.builder() diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/IncrementLedgerEntryTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/IncrementLedgerEntryTest.kt index 9a2ad5039..771b8f657 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/IncrementLedgerEntryTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/IncrementLedgerEntryTest.kt @@ -229,6 +229,13 @@ internal class IncrementLedgerEntryTest { .build() ) .cadence(Price.Unit.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder() @@ -413,6 +420,9 @@ internal class IncrementLedgerEntryTest { .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .paymentProvider(Invoice.PaymentAttempt.PaymentProvider.STRIPE) .paymentProviderId("payment_provider_id") + .receiptPdf( + "https://assets.withorb.com/receipt/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" + ) .succeeded(true) .build() ) @@ -655,6 +665,13 @@ internal class IncrementLedgerEntryTest { .build() ) .cadence(Price.Unit.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder() @@ -832,6 +849,9 @@ internal class IncrementLedgerEntryTest { .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .paymentProvider(Invoice.PaymentAttempt.PaymentProvider.STRIPE) .paymentProviderId("payment_provider_id") + .receiptPdf( + "https://assets.withorb.com/receipt/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" + ) .succeeded(true) .build() ) @@ -1078,6 +1098,13 @@ internal class IncrementLedgerEntryTest { .build() ) .cadence(Price.Unit.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder() @@ -1262,6 +1289,9 @@ internal class IncrementLedgerEntryTest { .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .paymentProvider(Invoice.PaymentAttempt.PaymentProvider.STRIPE) .paymentProviderId("payment_provider_id") + .receiptPdf( + "https://assets.withorb.com/receipt/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" + ) .succeeded(true) .build() ) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceCreateParamsTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceCreateParamsTest.kt index 17f7b38bb..62bd0eca3 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceCreateParamsTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceCreateParamsTest.kt @@ -43,6 +43,7 @@ internal class InvoiceCreateParamsTest { .reason("reason") .build() ) + .dueDate(LocalDate.parse("2023-09-22")) .externalCustomerId("external-customer-id") .memo("An optional memo for my invoice.") .metadata( @@ -89,6 +90,7 @@ internal class InvoiceCreateParamsTest { .reason("reason") .build() ) + .dueDate(LocalDate.parse("2023-09-22")) .externalCustomerId("external-customer-id") .memo("An optional memo for my invoice.") .metadata( @@ -136,6 +138,8 @@ internal class InvoiceCreateParamsTest { .build() ) ) + assertThat(body.dueDate()) + .isEqualTo(InvoiceCreateParams.DueDate.ofDate(LocalDate.parse("2023-09-22"))) assertThat(body.externalCustomerId()).isEqualTo("external-customer-id") assertThat(body.memo()).isEqualTo("An optional memo for my invoice.") assertThat(body.metadata()) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceFetchUpcomingResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceFetchUpcomingResponseTest.kt index f61e5573b..df7d09080 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceFetchUpcomingResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceFetchUpcomingResponseTest.kt @@ -192,6 +192,13 @@ internal class InvoiceFetchUpcomingResponseTest { .build() ) .cadence(Price.Unit.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder() @@ -359,6 +366,9 @@ internal class InvoiceFetchUpcomingResponseTest { InvoiceFetchUpcomingResponse.PaymentAttempt.PaymentProvider.STRIPE ) .paymentProviderId("payment_provider_id") + .receiptPdf( + "https://assets.withorb.com/receipt/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" + ) .succeeded(true) .build() ) @@ -578,6 +588,13 @@ internal class InvoiceFetchUpcomingResponseTest { .build() ) .cadence(Price.Unit.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() @@ -745,6 +762,9 @@ internal class InvoiceFetchUpcomingResponseTest { InvoiceFetchUpcomingResponse.PaymentAttempt.PaymentProvider.STRIPE ) .paymentProviderId("payment_provider_id") + .receiptPdf( + "https://assets.withorb.com/receipt/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" + ) .succeeded(true) .build() ) @@ -962,6 +982,13 @@ internal class InvoiceFetchUpcomingResponseTest { .build() ) .cadence(Price.Unit.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder() @@ -1129,6 +1156,9 @@ internal class InvoiceFetchUpcomingResponseTest { InvoiceFetchUpcomingResponse.PaymentAttempt.PaymentProvider.STRIPE ) .paymentProviderId("payment_provider_id") + .receiptPdf( + "https://assets.withorb.com/receipt/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" + ) .succeeded(true) .build() ) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceLineItemCreateResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceLineItemCreateResponseTest.kt index 6a6fde78b..b8af213f2 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceLineItemCreateResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceLineItemCreateResponseTest.kt @@ -100,6 +100,13 @@ internal class InvoiceLineItemCreateResponseTest { .build() ) .cadence(Price.Unit.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() @@ -310,6 +317,13 @@ internal class InvoiceLineItemCreateResponseTest { .build() ) .cadence(Price.Unit.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() @@ -520,6 +534,13 @@ internal class InvoiceLineItemCreateResponseTest { .build() ) .cadence(Price.Unit.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceListPageResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceListPageResponseTest.kt index 56d7eff0b..df19d6dbe 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceListPageResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceListPageResponseTest.kt @@ -201,6 +201,13 @@ internal class InvoiceListPageResponseTest { .build() ) .cadence(Price.Unit.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder() @@ -385,6 +392,9 @@ internal class InvoiceListPageResponseTest { .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .paymentProvider(Invoice.PaymentAttempt.PaymentProvider.STRIPE) .paymentProviderId("payment_provider_id") + .receiptPdf( + "https://assets.withorb.com/receipt/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" + ) .succeeded(true) .build() ) @@ -596,6 +606,13 @@ internal class InvoiceListPageResponseTest { .build() ) .cadence(Price.Unit.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder() @@ -773,6 +790,9 @@ internal class InvoiceListPageResponseTest { .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .paymentProvider(Invoice.PaymentAttempt.PaymentProvider.STRIPE) .paymentProviderId("payment_provider_id") + .receiptPdf( + "https://assets.withorb.com/receipt/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" + ) .succeeded(true) .build() ) @@ -993,6 +1013,13 @@ internal class InvoiceListPageResponseTest { .build() ) .cadence(Price.Unit.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder() @@ -1177,6 +1204,9 @@ internal class InvoiceListPageResponseTest { .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .paymentProvider(Invoice.PaymentAttempt.PaymentProvider.STRIPE) .paymentProviderId("payment_provider_id") + .receiptPdf( + "https://assets.withorb.com/receipt/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" + ) .succeeded(true) .build() ) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceTest.kt index ebf4fffba..3f3ca5071 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceTest.kt @@ -188,6 +188,13 @@ internal class InvoiceTest { .build() ) .cadence(Price.Unit.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder() @@ -353,6 +360,9 @@ internal class InvoiceTest { .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .paymentProvider(Invoice.PaymentAttempt.PaymentProvider.STRIPE) .paymentProviderId("payment_provider_id") + .receiptPdf( + "https://assets.withorb.com/receipt/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" + ) .succeeded(true) .build() ) @@ -565,6 +575,13 @@ internal class InvoiceTest { .build() ) .cadence(Price.Unit.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() @@ -729,6 +746,9 @@ internal class InvoiceTest { .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .paymentProvider(Invoice.PaymentAttempt.PaymentProvider.STRIPE) .paymentProviderId("payment_provider_id") + .receiptPdf( + "https://assets.withorb.com/receipt/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" + ) .succeeded(true) .build() ) @@ -938,6 +958,13 @@ internal class InvoiceTest { .build() ) .cadence(Price.Unit.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder() @@ -1103,6 +1130,9 @@ internal class InvoiceTest { .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .paymentProvider(Invoice.PaymentAttempt.PaymentProvider.STRIPE) .paymentProviderId("payment_provider_id") + .receiptPdf( + "https://assets.withorb.com/receipt/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" + ) .succeeded(true) .build() ) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceUpdateParamsTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceUpdateParamsTest.kt index 26b3f3cca..39d7a3b19 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceUpdateParamsTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceUpdateParamsTest.kt @@ -3,6 +3,7 @@ package com.withorb.api.models import com.withorb.api.core.JsonValue +import java.time.LocalDate import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -12,11 +13,13 @@ internal class InvoiceUpdateParamsTest { fun create() { InvoiceUpdateParams.builder() .invoiceId("invoice_id") + .dueDate(LocalDate.parse("2023-09-22")) .metadata( InvoiceUpdateParams.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) + .netTerms(0L) .build() } @@ -34,21 +37,26 @@ internal class InvoiceUpdateParamsTest { val params = InvoiceUpdateParams.builder() .invoiceId("invoice_id") + .dueDate(LocalDate.parse("2023-09-22")) .metadata( InvoiceUpdateParams.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) + .netTerms(0L) .build() val body = params._body() + assertThat(body.dueDate()) + .isEqualTo(InvoiceUpdateParams.DueDate.ofDate(LocalDate.parse("2023-09-22"))) assertThat(body.metadata()) .isEqualTo( InvoiceUpdateParams.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) + assertThat(body.netTerms()).isEqualTo(0L) } @Test diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/MutatedSubscriptionTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/MutatedSubscriptionTest.kt index 46b0fd258..048a69546 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/MutatedSubscriptionTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/MutatedSubscriptionTest.kt @@ -59,6 +59,7 @@ internal class MutatedSubscriptionTest { .id("id") .addAdditionalEmail("string") .autoCollection(true) + .autoIssuance(true) .balance("balance") .billingAddress( Address.builder() @@ -359,6 +360,13 @@ internal class MutatedSubscriptionTest { .build() ) .cadence(Price.Unit.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder() @@ -497,6 +505,13 @@ internal class MutatedSubscriptionTest { .build() ) .cadence(Price.Unit.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder() @@ -903,6 +918,15 @@ internal class MutatedSubscriptionTest { .build() ) .cadence(Price.Unit.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator( + TransformPriceFilter.Operator.INCLUDES + ) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder() @@ -1112,6 +1136,9 @@ internal class MutatedSubscriptionTest { Invoice.PaymentAttempt.PaymentProvider.STRIPE ) .paymentProviderId("payment_provider_id") + .receiptPdf( + "https://assets.withorb.com/receipt/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" + ) .succeeded(true) .build() ) @@ -1434,6 +1461,15 @@ internal class MutatedSubscriptionTest { .build() ) .cadence(Price.Unit.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator( + TransformPriceFilter.Operator.INCLUDES + ) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder() @@ -1643,6 +1679,9 @@ internal class MutatedSubscriptionTest { Invoice.PaymentAttempt.PaymentProvider.STRIPE ) .paymentProviderId("payment_provider_id") + .receiptPdf( + "https://assets.withorb.com/receipt/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" + ) .succeeded(true) .build() ) @@ -1722,6 +1761,7 @@ internal class MutatedSubscriptionTest { .id("id") .addAdditionalEmail("string") .autoCollection(true) + .autoIssuance(true) .balance("balance") .billingAddress( Address.builder() @@ -2031,6 +2071,13 @@ internal class MutatedSubscriptionTest { .build() ) .cadence(Price.Unit.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() @@ -2164,6 +2211,13 @@ internal class MutatedSubscriptionTest { .build() ) .cadence(Price.Unit.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() @@ -2561,6 +2615,15 @@ internal class MutatedSubscriptionTest { .build() ) .cadence(Price.Unit.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator( + TransformPriceFilter.Operator.INCLUDES + ) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder() @@ -2758,6 +2821,9 @@ internal class MutatedSubscriptionTest { .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .paymentProvider(Invoice.PaymentAttempt.PaymentProvider.STRIPE) .paymentProviderId("payment_provider_id") + .receiptPdf( + "https://assets.withorb.com/receipt/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" + ) .succeeded(true) .build() ) @@ -3069,6 +3135,15 @@ internal class MutatedSubscriptionTest { .build() ) .cadence(Price.Unit.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator( + TransformPriceFilter.Operator.INCLUDES + ) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder() @@ -3266,6 +3341,9 @@ internal class MutatedSubscriptionTest { .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .paymentProvider(Invoice.PaymentAttempt.PaymentProvider.STRIPE) .paymentProviderId("payment_provider_id") + .receiptPdf( + "https://assets.withorb.com/receipt/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" + ) .succeeded(true) .build() ) @@ -3346,6 +3424,7 @@ internal class MutatedSubscriptionTest { .id("id") .addAdditionalEmail("string") .autoCollection(true) + .autoIssuance(true) .balance("balance") .billingAddress( Address.builder() @@ -3646,6 +3725,13 @@ internal class MutatedSubscriptionTest { .build() ) .cadence(Price.Unit.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder() @@ -3784,6 +3870,13 @@ internal class MutatedSubscriptionTest { .build() ) .cadence(Price.Unit.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder() @@ -4190,6 +4283,15 @@ internal class MutatedSubscriptionTest { .build() ) .cadence(Price.Unit.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator( + TransformPriceFilter.Operator.INCLUDES + ) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder() @@ -4399,6 +4501,9 @@ internal class MutatedSubscriptionTest { Invoice.PaymentAttempt.PaymentProvider.STRIPE ) .paymentProviderId("payment_provider_id") + .receiptPdf( + "https://assets.withorb.com/receipt/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" + ) .succeeded(true) .build() ) @@ -4721,6 +4826,15 @@ internal class MutatedSubscriptionTest { .build() ) .cadence(Price.Unit.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator( + TransformPriceFilter.Operator.INCLUDES + ) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder() @@ -4930,6 +5044,9 @@ internal class MutatedSubscriptionTest { Invoice.PaymentAttempt.PaymentProvider.STRIPE ) .paymentProviderId("payment_provider_id") + .receiptPdf( + "https://assets.withorb.com/receipt/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" + ) .succeeded(true) .build() ) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingBpsPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingBpsPriceTest.kt deleted file mode 100644 index 2bb24ae85..000000000 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingBpsPriceTest.kt +++ /dev/null @@ -1,166 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.withorb.api.models - -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.withorb.api.core.JsonValue -import com.withorb.api.core.jsonMapper -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class NewFloatingBpsPriceTest { - - @Test - fun create() { - val newFloatingBpsPrice = - NewFloatingBpsPrice.builder() - .bpsConfig(BpsConfig.builder().bps(0.0).perUnitMaximum("per_unit_maximum").build()) - .cadence(NewFloatingBpsPrice.Cadence.ANNUAL) - .currency("currency") - .itemId("item_id") - .modelType(NewFloatingBpsPrice.ModelType.BPS) - .name("Annual fee") - .billableMetricId("billable_metric_id") - .billedInAdvance(true) - .billingCycleConfiguration( - NewBillingCycleConfiguration.builder() - .duration(0L) - .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) - .build() - ) - .conversionRate(0.0) - .unitConversionRateConfig( - ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() - ) - .dimensionalPriceConfiguration( - NewDimensionalPriceConfiguration.builder() - .addDimensionValue("string") - .dimensionalPriceGroupId("dimensional_price_group_id") - .externalDimensionalPriceGroupId("external_dimensional_price_group_id") - .build() - ) - .externalPriceId("external_price_id") - .fixedPriceQuantity(0.0) - .invoiceGroupingKey("x") - .invoicingCycleConfiguration( - NewBillingCycleConfiguration.builder() - .duration(0L) - .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) - .build() - ) - .metadata( - NewFloatingBpsPrice.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - .build() - - assertThat(newFloatingBpsPrice.bpsConfig()) - .isEqualTo(BpsConfig.builder().bps(0.0).perUnitMaximum("per_unit_maximum").build()) - assertThat(newFloatingBpsPrice.cadence()).isEqualTo(NewFloatingBpsPrice.Cadence.ANNUAL) - assertThat(newFloatingBpsPrice.currency()).isEqualTo("currency") - assertThat(newFloatingBpsPrice.itemId()).isEqualTo("item_id") - assertThat(newFloatingBpsPrice.modelType()).isEqualTo(NewFloatingBpsPrice.ModelType.BPS) - assertThat(newFloatingBpsPrice.name()).isEqualTo("Annual fee") - assertThat(newFloatingBpsPrice.billableMetricId()).isEqualTo("billable_metric_id") - assertThat(newFloatingBpsPrice.billedInAdvance()).isEqualTo(true) - assertThat(newFloatingBpsPrice.billingCycleConfiguration()) - .isEqualTo( - NewBillingCycleConfiguration.builder() - .duration(0L) - .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) - .build() - ) - assertThat(newFloatingBpsPrice.conversionRate()).isEqualTo(0.0) - assertThat(newFloatingBpsPrice.conversionRateConfig()) - .isEqualTo( - ConversionRateConfig.ofUnit( - UnitConversionRateConfig.builder() - .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) - .unitConfig( - ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() - ) - .build() - ) - ) - assertThat(newFloatingBpsPrice.dimensionalPriceConfiguration()) - .isEqualTo( - NewDimensionalPriceConfiguration.builder() - .addDimensionValue("string") - .dimensionalPriceGroupId("dimensional_price_group_id") - .externalDimensionalPriceGroupId("external_dimensional_price_group_id") - .build() - ) - assertThat(newFloatingBpsPrice.externalPriceId()).isEqualTo("external_price_id") - assertThat(newFloatingBpsPrice.fixedPriceQuantity()).isEqualTo(0.0) - assertThat(newFloatingBpsPrice.invoiceGroupingKey()).isEqualTo("x") - assertThat(newFloatingBpsPrice.invoicingCycleConfiguration()) - .isEqualTo( - NewBillingCycleConfiguration.builder() - .duration(0L) - .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) - .build() - ) - assertThat(newFloatingBpsPrice.metadata()) - .isEqualTo( - NewFloatingBpsPrice.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val newFloatingBpsPrice = - NewFloatingBpsPrice.builder() - .bpsConfig(BpsConfig.builder().bps(0.0).perUnitMaximum("per_unit_maximum").build()) - .cadence(NewFloatingBpsPrice.Cadence.ANNUAL) - .currency("currency") - .itemId("item_id") - .modelType(NewFloatingBpsPrice.ModelType.BPS) - .name("Annual fee") - .billableMetricId("billable_metric_id") - .billedInAdvance(true) - .billingCycleConfiguration( - NewBillingCycleConfiguration.builder() - .duration(0L) - .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) - .build() - ) - .conversionRate(0.0) - .unitConversionRateConfig( - ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() - ) - .dimensionalPriceConfiguration( - NewDimensionalPriceConfiguration.builder() - .addDimensionValue("string") - .dimensionalPriceGroupId("dimensional_price_group_id") - .externalDimensionalPriceGroupId("external_dimensional_price_group_id") - .build() - ) - .externalPriceId("external_price_id") - .fixedPriceQuantity(0.0) - .invoiceGroupingKey("x") - .invoicingCycleConfiguration( - NewBillingCycleConfiguration.builder() - .duration(0L) - .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) - .build() - ) - .metadata( - NewFloatingBpsPrice.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - .build() - - val roundtrippedNewFloatingBpsPrice = - jsonMapper.readValue( - jsonMapper.writeValueAsString(newFloatingBpsPrice), - jacksonTypeRef(), - ) - - assertThat(roundtrippedNewFloatingBpsPrice).isEqualTo(newFloatingBpsPrice) - } -} diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingBulkBpsPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingBulkBpsPriceTest.kt deleted file mode 100644 index 357688377..000000000 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingBulkBpsPriceTest.kt +++ /dev/null @@ -1,198 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.withorb.api.models - -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.withorb.api.core.JsonValue -import com.withorb.api.core.jsonMapper -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class NewFloatingBulkBpsPriceTest { - - @Test - fun create() { - val newFloatingBulkBpsPrice = - NewFloatingBulkBpsPrice.builder() - .bulkBpsConfig( - BulkBpsConfig.builder() - .addTier( - BulkBpsTier.builder() - .bps(0.0) - .maximumAmount("maximum_amount") - .perUnitMaximum("per_unit_maximum") - .build() - ) - .build() - ) - .cadence(NewFloatingBulkBpsPrice.Cadence.ANNUAL) - .currency("currency") - .itemId("item_id") - .modelType(NewFloatingBulkBpsPrice.ModelType.BULK_BPS) - .name("Annual fee") - .billableMetricId("billable_metric_id") - .billedInAdvance(true) - .billingCycleConfiguration( - NewBillingCycleConfiguration.builder() - .duration(0L) - .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) - .build() - ) - .conversionRate(0.0) - .unitConversionRateConfig( - ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() - ) - .dimensionalPriceConfiguration( - NewDimensionalPriceConfiguration.builder() - .addDimensionValue("string") - .dimensionalPriceGroupId("dimensional_price_group_id") - .externalDimensionalPriceGroupId("external_dimensional_price_group_id") - .build() - ) - .externalPriceId("external_price_id") - .fixedPriceQuantity(0.0) - .invoiceGroupingKey("x") - .invoicingCycleConfiguration( - NewBillingCycleConfiguration.builder() - .duration(0L) - .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) - .build() - ) - .metadata( - NewFloatingBulkBpsPrice.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - .build() - - assertThat(newFloatingBulkBpsPrice.bulkBpsConfig()) - .isEqualTo( - BulkBpsConfig.builder() - .addTier( - BulkBpsTier.builder() - .bps(0.0) - .maximumAmount("maximum_amount") - .perUnitMaximum("per_unit_maximum") - .build() - ) - .build() - ) - assertThat(newFloatingBulkBpsPrice.cadence()) - .isEqualTo(NewFloatingBulkBpsPrice.Cadence.ANNUAL) - assertThat(newFloatingBulkBpsPrice.currency()).isEqualTo("currency") - assertThat(newFloatingBulkBpsPrice.itemId()).isEqualTo("item_id") - assertThat(newFloatingBulkBpsPrice.modelType()) - .isEqualTo(NewFloatingBulkBpsPrice.ModelType.BULK_BPS) - assertThat(newFloatingBulkBpsPrice.name()).isEqualTo("Annual fee") - assertThat(newFloatingBulkBpsPrice.billableMetricId()).isEqualTo("billable_metric_id") - assertThat(newFloatingBulkBpsPrice.billedInAdvance()).isEqualTo(true) - assertThat(newFloatingBulkBpsPrice.billingCycleConfiguration()) - .isEqualTo( - NewBillingCycleConfiguration.builder() - .duration(0L) - .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) - .build() - ) - assertThat(newFloatingBulkBpsPrice.conversionRate()).isEqualTo(0.0) - assertThat(newFloatingBulkBpsPrice.conversionRateConfig()) - .isEqualTo( - ConversionRateConfig.ofUnit( - UnitConversionRateConfig.builder() - .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) - .unitConfig( - ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() - ) - .build() - ) - ) - assertThat(newFloatingBulkBpsPrice.dimensionalPriceConfiguration()) - .isEqualTo( - NewDimensionalPriceConfiguration.builder() - .addDimensionValue("string") - .dimensionalPriceGroupId("dimensional_price_group_id") - .externalDimensionalPriceGroupId("external_dimensional_price_group_id") - .build() - ) - assertThat(newFloatingBulkBpsPrice.externalPriceId()).isEqualTo("external_price_id") - assertThat(newFloatingBulkBpsPrice.fixedPriceQuantity()).isEqualTo(0.0) - assertThat(newFloatingBulkBpsPrice.invoiceGroupingKey()).isEqualTo("x") - assertThat(newFloatingBulkBpsPrice.invoicingCycleConfiguration()) - .isEqualTo( - NewBillingCycleConfiguration.builder() - .duration(0L) - .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) - .build() - ) - assertThat(newFloatingBulkBpsPrice.metadata()) - .isEqualTo( - NewFloatingBulkBpsPrice.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val newFloatingBulkBpsPrice = - NewFloatingBulkBpsPrice.builder() - .bulkBpsConfig( - BulkBpsConfig.builder() - .addTier( - BulkBpsTier.builder() - .bps(0.0) - .maximumAmount("maximum_amount") - .perUnitMaximum("per_unit_maximum") - .build() - ) - .build() - ) - .cadence(NewFloatingBulkBpsPrice.Cadence.ANNUAL) - .currency("currency") - .itemId("item_id") - .modelType(NewFloatingBulkBpsPrice.ModelType.BULK_BPS) - .name("Annual fee") - .billableMetricId("billable_metric_id") - .billedInAdvance(true) - .billingCycleConfiguration( - NewBillingCycleConfiguration.builder() - .duration(0L) - .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) - .build() - ) - .conversionRate(0.0) - .unitConversionRateConfig( - ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() - ) - .dimensionalPriceConfiguration( - NewDimensionalPriceConfiguration.builder() - .addDimensionValue("string") - .dimensionalPriceGroupId("dimensional_price_group_id") - .externalDimensionalPriceGroupId("external_dimensional_price_group_id") - .build() - ) - .externalPriceId("external_price_id") - .fixedPriceQuantity(0.0) - .invoiceGroupingKey("x") - .invoicingCycleConfiguration( - NewBillingCycleConfiguration.builder() - .duration(0L) - .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) - .build() - ) - .metadata( - NewFloatingBulkBpsPrice.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - .build() - - val roundtrippedNewFloatingBulkBpsPrice = - jsonMapper.readValue( - jsonMapper.writeValueAsString(newFloatingBulkBpsPrice), - jacksonTypeRef(), - ) - - assertThat(roundtrippedNewFloatingBulkBpsPrice).isEqualTo(newFloatingBulkBpsPrice) - } -} diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingTieredBpsPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingTieredBpsPriceTest.kt deleted file mode 100644 index 3f70d6b05..000000000 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingTieredBpsPriceTest.kt +++ /dev/null @@ -1,201 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.withorb.api.models - -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.withorb.api.core.JsonValue -import com.withorb.api.core.jsonMapper -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class NewFloatingTieredBpsPriceTest { - - @Test - fun create() { - val newFloatingTieredBpsPrice = - NewFloatingTieredBpsPrice.builder() - .cadence(NewFloatingTieredBpsPrice.Cadence.ANNUAL) - .currency("currency") - .itemId("item_id") - .modelType(NewFloatingTieredBpsPrice.ModelType.TIERED_BPS) - .name("Annual fee") - .tieredBpsConfig( - TieredBpsConfig.builder() - .addTier( - BpsTier.builder() - .bps(0.0) - .minimumAmount("minimum_amount") - .maximumAmount("maximum_amount") - .perUnitMaximum("per_unit_maximum") - .build() - ) - .build() - ) - .billableMetricId("billable_metric_id") - .billedInAdvance(true) - .billingCycleConfiguration( - NewBillingCycleConfiguration.builder() - .duration(0L) - .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) - .build() - ) - .conversionRate(0.0) - .unitConversionRateConfig( - ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() - ) - .dimensionalPriceConfiguration( - NewDimensionalPriceConfiguration.builder() - .addDimensionValue("string") - .dimensionalPriceGroupId("dimensional_price_group_id") - .externalDimensionalPriceGroupId("external_dimensional_price_group_id") - .build() - ) - .externalPriceId("external_price_id") - .fixedPriceQuantity(0.0) - .invoiceGroupingKey("x") - .invoicingCycleConfiguration( - NewBillingCycleConfiguration.builder() - .duration(0L) - .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) - .build() - ) - .metadata( - NewFloatingTieredBpsPrice.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - .build() - - assertThat(newFloatingTieredBpsPrice.cadence()) - .isEqualTo(NewFloatingTieredBpsPrice.Cadence.ANNUAL) - assertThat(newFloatingTieredBpsPrice.currency()).isEqualTo("currency") - assertThat(newFloatingTieredBpsPrice.itemId()).isEqualTo("item_id") - assertThat(newFloatingTieredBpsPrice.modelType()) - .isEqualTo(NewFloatingTieredBpsPrice.ModelType.TIERED_BPS) - assertThat(newFloatingTieredBpsPrice.name()).isEqualTo("Annual fee") - assertThat(newFloatingTieredBpsPrice.tieredBpsConfig()) - .isEqualTo( - TieredBpsConfig.builder() - .addTier( - BpsTier.builder() - .bps(0.0) - .minimumAmount("minimum_amount") - .maximumAmount("maximum_amount") - .perUnitMaximum("per_unit_maximum") - .build() - ) - .build() - ) - assertThat(newFloatingTieredBpsPrice.billableMetricId()).isEqualTo("billable_metric_id") - assertThat(newFloatingTieredBpsPrice.billedInAdvance()).isEqualTo(true) - assertThat(newFloatingTieredBpsPrice.billingCycleConfiguration()) - .isEqualTo( - NewBillingCycleConfiguration.builder() - .duration(0L) - .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) - .build() - ) - assertThat(newFloatingTieredBpsPrice.conversionRate()).isEqualTo(0.0) - assertThat(newFloatingTieredBpsPrice.conversionRateConfig()) - .isEqualTo( - ConversionRateConfig.ofUnit( - UnitConversionRateConfig.builder() - .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) - .unitConfig( - ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() - ) - .build() - ) - ) - assertThat(newFloatingTieredBpsPrice.dimensionalPriceConfiguration()) - .isEqualTo( - NewDimensionalPriceConfiguration.builder() - .addDimensionValue("string") - .dimensionalPriceGroupId("dimensional_price_group_id") - .externalDimensionalPriceGroupId("external_dimensional_price_group_id") - .build() - ) - assertThat(newFloatingTieredBpsPrice.externalPriceId()).isEqualTo("external_price_id") - assertThat(newFloatingTieredBpsPrice.fixedPriceQuantity()).isEqualTo(0.0) - assertThat(newFloatingTieredBpsPrice.invoiceGroupingKey()).isEqualTo("x") - assertThat(newFloatingTieredBpsPrice.invoicingCycleConfiguration()) - .isEqualTo( - NewBillingCycleConfiguration.builder() - .duration(0L) - .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) - .build() - ) - assertThat(newFloatingTieredBpsPrice.metadata()) - .isEqualTo( - NewFloatingTieredBpsPrice.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val newFloatingTieredBpsPrice = - NewFloatingTieredBpsPrice.builder() - .cadence(NewFloatingTieredBpsPrice.Cadence.ANNUAL) - .currency("currency") - .itemId("item_id") - .modelType(NewFloatingTieredBpsPrice.ModelType.TIERED_BPS) - .name("Annual fee") - .tieredBpsConfig( - TieredBpsConfig.builder() - .addTier( - BpsTier.builder() - .bps(0.0) - .minimumAmount("minimum_amount") - .maximumAmount("maximum_amount") - .perUnitMaximum("per_unit_maximum") - .build() - ) - .build() - ) - .billableMetricId("billable_metric_id") - .billedInAdvance(true) - .billingCycleConfiguration( - NewBillingCycleConfiguration.builder() - .duration(0L) - .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) - .build() - ) - .conversionRate(0.0) - .unitConversionRateConfig( - ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() - ) - .dimensionalPriceConfiguration( - NewDimensionalPriceConfiguration.builder() - .addDimensionValue("string") - .dimensionalPriceGroupId("dimensional_price_group_id") - .externalDimensionalPriceGroupId("external_dimensional_price_group_id") - .build() - ) - .externalPriceId("external_price_id") - .fixedPriceQuantity(0.0) - .invoiceGroupingKey("x") - .invoicingCycleConfiguration( - NewBillingCycleConfiguration.builder() - .duration(0L) - .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) - .build() - ) - .metadata( - NewFloatingTieredBpsPrice.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - .build() - - val roundtrippedNewFloatingTieredBpsPrice = - jsonMapper.readValue( - jsonMapper.writeValueAsString(newFloatingTieredBpsPrice), - jacksonTypeRef(), - ) - - assertThat(roundtrippedNewFloatingTieredBpsPrice).isEqualTo(newFloatingTieredBpsPrice) - } -} diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanBpsPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanBpsPriceTest.kt deleted file mode 100644 index b62038621..000000000 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanBpsPriceTest.kt +++ /dev/null @@ -1,169 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.withorb.api.models - -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.withorb.api.core.JsonValue -import com.withorb.api.core.jsonMapper -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class NewPlanBpsPriceTest { - - @Test - fun create() { - val newPlanBpsPrice = - NewPlanBpsPrice.builder() - .bpsConfig(BpsConfig.builder().bps(0.0).perUnitMaximum("per_unit_maximum").build()) - .cadence(NewPlanBpsPrice.Cadence.ANNUAL) - .itemId("item_id") - .modelType(NewPlanBpsPrice.ModelType.BPS) - .name("Annual fee") - .billableMetricId("billable_metric_id") - .billedInAdvance(true) - .billingCycleConfiguration( - NewBillingCycleConfiguration.builder() - .duration(0L) - .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) - .build() - ) - .conversionRate(0.0) - .unitConversionRateConfig( - ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() - ) - .currency("currency") - .dimensionalPriceConfiguration( - NewDimensionalPriceConfiguration.builder() - .addDimensionValue("string") - .dimensionalPriceGroupId("dimensional_price_group_id") - .externalDimensionalPriceGroupId("external_dimensional_price_group_id") - .build() - ) - .externalPriceId("external_price_id") - .fixedPriceQuantity(0.0) - .invoiceGroupingKey("x") - .invoicingCycleConfiguration( - NewBillingCycleConfiguration.builder() - .duration(0L) - .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) - .build() - ) - .metadata( - NewPlanBpsPrice.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - .referenceId("reference_id") - .build() - - assertThat(newPlanBpsPrice.bpsConfig()) - .isEqualTo(BpsConfig.builder().bps(0.0).perUnitMaximum("per_unit_maximum").build()) - assertThat(newPlanBpsPrice.cadence()).isEqualTo(NewPlanBpsPrice.Cadence.ANNUAL) - assertThat(newPlanBpsPrice.itemId()).isEqualTo("item_id") - assertThat(newPlanBpsPrice.modelType()).isEqualTo(NewPlanBpsPrice.ModelType.BPS) - assertThat(newPlanBpsPrice.name()).isEqualTo("Annual fee") - assertThat(newPlanBpsPrice.billableMetricId()).isEqualTo("billable_metric_id") - assertThat(newPlanBpsPrice.billedInAdvance()).isEqualTo(true) - assertThat(newPlanBpsPrice.billingCycleConfiguration()) - .isEqualTo( - NewBillingCycleConfiguration.builder() - .duration(0L) - .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) - .build() - ) - assertThat(newPlanBpsPrice.conversionRate()).isEqualTo(0.0) - assertThat(newPlanBpsPrice.conversionRateConfig()) - .isEqualTo( - ConversionRateConfig.ofUnit( - UnitConversionRateConfig.builder() - .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) - .unitConfig( - ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() - ) - .build() - ) - ) - assertThat(newPlanBpsPrice.currency()).isEqualTo("currency") - assertThat(newPlanBpsPrice.dimensionalPriceConfiguration()) - .isEqualTo( - NewDimensionalPriceConfiguration.builder() - .addDimensionValue("string") - .dimensionalPriceGroupId("dimensional_price_group_id") - .externalDimensionalPriceGroupId("external_dimensional_price_group_id") - .build() - ) - assertThat(newPlanBpsPrice.externalPriceId()).isEqualTo("external_price_id") - assertThat(newPlanBpsPrice.fixedPriceQuantity()).isEqualTo(0.0) - assertThat(newPlanBpsPrice.invoiceGroupingKey()).isEqualTo("x") - assertThat(newPlanBpsPrice.invoicingCycleConfiguration()) - .isEqualTo( - NewBillingCycleConfiguration.builder() - .duration(0L) - .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) - .build() - ) - assertThat(newPlanBpsPrice.metadata()) - .isEqualTo( - NewPlanBpsPrice.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - assertThat(newPlanBpsPrice.referenceId()).isEqualTo("reference_id") - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val newPlanBpsPrice = - NewPlanBpsPrice.builder() - .bpsConfig(BpsConfig.builder().bps(0.0).perUnitMaximum("per_unit_maximum").build()) - .cadence(NewPlanBpsPrice.Cadence.ANNUAL) - .itemId("item_id") - .modelType(NewPlanBpsPrice.ModelType.BPS) - .name("Annual fee") - .billableMetricId("billable_metric_id") - .billedInAdvance(true) - .billingCycleConfiguration( - NewBillingCycleConfiguration.builder() - .duration(0L) - .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) - .build() - ) - .conversionRate(0.0) - .unitConversionRateConfig( - ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() - ) - .currency("currency") - .dimensionalPriceConfiguration( - NewDimensionalPriceConfiguration.builder() - .addDimensionValue("string") - .dimensionalPriceGroupId("dimensional_price_group_id") - .externalDimensionalPriceGroupId("external_dimensional_price_group_id") - .build() - ) - .externalPriceId("external_price_id") - .fixedPriceQuantity(0.0) - .invoiceGroupingKey("x") - .invoicingCycleConfiguration( - NewBillingCycleConfiguration.builder() - .duration(0L) - .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) - .build() - ) - .metadata( - NewPlanBpsPrice.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - .referenceId("reference_id") - .build() - - val roundtrippedNewPlanBpsPrice = - jsonMapper.readValue( - jsonMapper.writeValueAsString(newPlanBpsPrice), - jacksonTypeRef(), - ) - - assertThat(roundtrippedNewPlanBpsPrice).isEqualTo(newPlanBpsPrice) - } -} diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanBulkBpsPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanBulkBpsPriceTest.kt deleted file mode 100644 index 960f6e487..000000000 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanBulkBpsPriceTest.kt +++ /dev/null @@ -1,200 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.withorb.api.models - -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.withorb.api.core.JsonValue -import com.withorb.api.core.jsonMapper -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class NewPlanBulkBpsPriceTest { - - @Test - fun create() { - val newPlanBulkBpsPrice = - NewPlanBulkBpsPrice.builder() - .bulkBpsConfig( - BulkBpsConfig.builder() - .addTier( - BulkBpsTier.builder() - .bps(0.0) - .maximumAmount("maximum_amount") - .perUnitMaximum("per_unit_maximum") - .build() - ) - .build() - ) - .cadence(NewPlanBulkBpsPrice.Cadence.ANNUAL) - .itemId("item_id") - .modelType(NewPlanBulkBpsPrice.ModelType.BULK_BPS) - .name("Annual fee") - .billableMetricId("billable_metric_id") - .billedInAdvance(true) - .billingCycleConfiguration( - NewBillingCycleConfiguration.builder() - .duration(0L) - .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) - .build() - ) - .conversionRate(0.0) - .unitConversionRateConfig( - ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() - ) - .currency("currency") - .dimensionalPriceConfiguration( - NewDimensionalPriceConfiguration.builder() - .addDimensionValue("string") - .dimensionalPriceGroupId("dimensional_price_group_id") - .externalDimensionalPriceGroupId("external_dimensional_price_group_id") - .build() - ) - .externalPriceId("external_price_id") - .fixedPriceQuantity(0.0) - .invoiceGroupingKey("x") - .invoicingCycleConfiguration( - NewBillingCycleConfiguration.builder() - .duration(0L) - .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) - .build() - ) - .metadata( - NewPlanBulkBpsPrice.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - .referenceId("reference_id") - .build() - - assertThat(newPlanBulkBpsPrice.bulkBpsConfig()) - .isEqualTo( - BulkBpsConfig.builder() - .addTier( - BulkBpsTier.builder() - .bps(0.0) - .maximumAmount("maximum_amount") - .perUnitMaximum("per_unit_maximum") - .build() - ) - .build() - ) - assertThat(newPlanBulkBpsPrice.cadence()).isEqualTo(NewPlanBulkBpsPrice.Cadence.ANNUAL) - assertThat(newPlanBulkBpsPrice.itemId()).isEqualTo("item_id") - assertThat(newPlanBulkBpsPrice.modelType()) - .isEqualTo(NewPlanBulkBpsPrice.ModelType.BULK_BPS) - assertThat(newPlanBulkBpsPrice.name()).isEqualTo("Annual fee") - assertThat(newPlanBulkBpsPrice.billableMetricId()).isEqualTo("billable_metric_id") - assertThat(newPlanBulkBpsPrice.billedInAdvance()).isEqualTo(true) - assertThat(newPlanBulkBpsPrice.billingCycleConfiguration()) - .isEqualTo( - NewBillingCycleConfiguration.builder() - .duration(0L) - .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) - .build() - ) - assertThat(newPlanBulkBpsPrice.conversionRate()).isEqualTo(0.0) - assertThat(newPlanBulkBpsPrice.conversionRateConfig()) - .isEqualTo( - ConversionRateConfig.ofUnit( - UnitConversionRateConfig.builder() - .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) - .unitConfig( - ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() - ) - .build() - ) - ) - assertThat(newPlanBulkBpsPrice.currency()).isEqualTo("currency") - assertThat(newPlanBulkBpsPrice.dimensionalPriceConfiguration()) - .isEqualTo( - NewDimensionalPriceConfiguration.builder() - .addDimensionValue("string") - .dimensionalPriceGroupId("dimensional_price_group_id") - .externalDimensionalPriceGroupId("external_dimensional_price_group_id") - .build() - ) - assertThat(newPlanBulkBpsPrice.externalPriceId()).isEqualTo("external_price_id") - assertThat(newPlanBulkBpsPrice.fixedPriceQuantity()).isEqualTo(0.0) - assertThat(newPlanBulkBpsPrice.invoiceGroupingKey()).isEqualTo("x") - assertThat(newPlanBulkBpsPrice.invoicingCycleConfiguration()) - .isEqualTo( - NewBillingCycleConfiguration.builder() - .duration(0L) - .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) - .build() - ) - assertThat(newPlanBulkBpsPrice.metadata()) - .isEqualTo( - NewPlanBulkBpsPrice.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - assertThat(newPlanBulkBpsPrice.referenceId()).isEqualTo("reference_id") - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val newPlanBulkBpsPrice = - NewPlanBulkBpsPrice.builder() - .bulkBpsConfig( - BulkBpsConfig.builder() - .addTier( - BulkBpsTier.builder() - .bps(0.0) - .maximumAmount("maximum_amount") - .perUnitMaximum("per_unit_maximum") - .build() - ) - .build() - ) - .cadence(NewPlanBulkBpsPrice.Cadence.ANNUAL) - .itemId("item_id") - .modelType(NewPlanBulkBpsPrice.ModelType.BULK_BPS) - .name("Annual fee") - .billableMetricId("billable_metric_id") - .billedInAdvance(true) - .billingCycleConfiguration( - NewBillingCycleConfiguration.builder() - .duration(0L) - .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) - .build() - ) - .conversionRate(0.0) - .unitConversionRateConfig( - ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() - ) - .currency("currency") - .dimensionalPriceConfiguration( - NewDimensionalPriceConfiguration.builder() - .addDimensionValue("string") - .dimensionalPriceGroupId("dimensional_price_group_id") - .externalDimensionalPriceGroupId("external_dimensional_price_group_id") - .build() - ) - .externalPriceId("external_price_id") - .fixedPriceQuantity(0.0) - .invoiceGroupingKey("x") - .invoicingCycleConfiguration( - NewBillingCycleConfiguration.builder() - .duration(0L) - .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) - .build() - ) - .metadata( - NewPlanBulkBpsPrice.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - .referenceId("reference_id") - .build() - - val roundtrippedNewPlanBulkBpsPrice = - jsonMapper.readValue( - jsonMapper.writeValueAsString(newPlanBulkBpsPrice), - jacksonTypeRef(), - ) - - assertThat(roundtrippedNewPlanBulkBpsPrice).isEqualTo(newPlanBulkBpsPrice) - } -} diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanTieredBpsPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanTieredBpsPriceTest.kt deleted file mode 100644 index e395f40dd..000000000 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanTieredBpsPriceTest.kt +++ /dev/null @@ -1,203 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.withorb.api.models - -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.withorb.api.core.JsonValue -import com.withorb.api.core.jsonMapper -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class NewPlanTieredBpsPriceTest { - - @Test - fun create() { - val newPlanTieredBpsPrice = - NewPlanTieredBpsPrice.builder() - .cadence(NewPlanTieredBpsPrice.Cadence.ANNUAL) - .itemId("item_id") - .modelType(NewPlanTieredBpsPrice.ModelType.TIERED_BPS) - .name("Annual fee") - .tieredBpsConfig( - TieredBpsConfig.builder() - .addTier( - BpsTier.builder() - .bps(0.0) - .minimumAmount("minimum_amount") - .maximumAmount("maximum_amount") - .perUnitMaximum("per_unit_maximum") - .build() - ) - .build() - ) - .billableMetricId("billable_metric_id") - .billedInAdvance(true) - .billingCycleConfiguration( - NewBillingCycleConfiguration.builder() - .duration(0L) - .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) - .build() - ) - .conversionRate(0.0) - .unitConversionRateConfig( - ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() - ) - .currency("currency") - .dimensionalPriceConfiguration( - NewDimensionalPriceConfiguration.builder() - .addDimensionValue("string") - .dimensionalPriceGroupId("dimensional_price_group_id") - .externalDimensionalPriceGroupId("external_dimensional_price_group_id") - .build() - ) - .externalPriceId("external_price_id") - .fixedPriceQuantity(0.0) - .invoiceGroupingKey("x") - .invoicingCycleConfiguration( - NewBillingCycleConfiguration.builder() - .duration(0L) - .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) - .build() - ) - .metadata( - NewPlanTieredBpsPrice.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - .referenceId("reference_id") - .build() - - assertThat(newPlanTieredBpsPrice.cadence()).isEqualTo(NewPlanTieredBpsPrice.Cadence.ANNUAL) - assertThat(newPlanTieredBpsPrice.itemId()).isEqualTo("item_id") - assertThat(newPlanTieredBpsPrice.modelType()) - .isEqualTo(NewPlanTieredBpsPrice.ModelType.TIERED_BPS) - assertThat(newPlanTieredBpsPrice.name()).isEqualTo("Annual fee") - assertThat(newPlanTieredBpsPrice.tieredBpsConfig()) - .isEqualTo( - TieredBpsConfig.builder() - .addTier( - BpsTier.builder() - .bps(0.0) - .minimumAmount("minimum_amount") - .maximumAmount("maximum_amount") - .perUnitMaximum("per_unit_maximum") - .build() - ) - .build() - ) - assertThat(newPlanTieredBpsPrice.billableMetricId()).isEqualTo("billable_metric_id") - assertThat(newPlanTieredBpsPrice.billedInAdvance()).isEqualTo(true) - assertThat(newPlanTieredBpsPrice.billingCycleConfiguration()) - .isEqualTo( - NewBillingCycleConfiguration.builder() - .duration(0L) - .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) - .build() - ) - assertThat(newPlanTieredBpsPrice.conversionRate()).isEqualTo(0.0) - assertThat(newPlanTieredBpsPrice.conversionRateConfig()) - .isEqualTo( - ConversionRateConfig.ofUnit( - UnitConversionRateConfig.builder() - .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) - .unitConfig( - ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() - ) - .build() - ) - ) - assertThat(newPlanTieredBpsPrice.currency()).isEqualTo("currency") - assertThat(newPlanTieredBpsPrice.dimensionalPriceConfiguration()) - .isEqualTo( - NewDimensionalPriceConfiguration.builder() - .addDimensionValue("string") - .dimensionalPriceGroupId("dimensional_price_group_id") - .externalDimensionalPriceGroupId("external_dimensional_price_group_id") - .build() - ) - assertThat(newPlanTieredBpsPrice.externalPriceId()).isEqualTo("external_price_id") - assertThat(newPlanTieredBpsPrice.fixedPriceQuantity()).isEqualTo(0.0) - assertThat(newPlanTieredBpsPrice.invoiceGroupingKey()).isEqualTo("x") - assertThat(newPlanTieredBpsPrice.invoicingCycleConfiguration()) - .isEqualTo( - NewBillingCycleConfiguration.builder() - .duration(0L) - .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) - .build() - ) - assertThat(newPlanTieredBpsPrice.metadata()) - .isEqualTo( - NewPlanTieredBpsPrice.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - assertThat(newPlanTieredBpsPrice.referenceId()).isEqualTo("reference_id") - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val newPlanTieredBpsPrice = - NewPlanTieredBpsPrice.builder() - .cadence(NewPlanTieredBpsPrice.Cadence.ANNUAL) - .itemId("item_id") - .modelType(NewPlanTieredBpsPrice.ModelType.TIERED_BPS) - .name("Annual fee") - .tieredBpsConfig( - TieredBpsConfig.builder() - .addTier( - BpsTier.builder() - .bps(0.0) - .minimumAmount("minimum_amount") - .maximumAmount("maximum_amount") - .perUnitMaximum("per_unit_maximum") - .build() - ) - .build() - ) - .billableMetricId("billable_metric_id") - .billedInAdvance(true) - .billingCycleConfiguration( - NewBillingCycleConfiguration.builder() - .duration(0L) - .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) - .build() - ) - .conversionRate(0.0) - .unitConversionRateConfig( - ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() - ) - .currency("currency") - .dimensionalPriceConfiguration( - NewDimensionalPriceConfiguration.builder() - .addDimensionValue("string") - .dimensionalPriceGroupId("dimensional_price_group_id") - .externalDimensionalPriceGroupId("external_dimensional_price_group_id") - .build() - ) - .externalPriceId("external_price_id") - .fixedPriceQuantity(0.0) - .invoiceGroupingKey("x") - .invoicingCycleConfiguration( - NewBillingCycleConfiguration.builder() - .duration(0L) - .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) - .build() - ) - .metadata( - NewPlanTieredBpsPrice.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - .referenceId("reference_id") - .build() - - val roundtrippedNewPlanTieredBpsPrice = - jsonMapper.readValue( - jsonMapper.writeValueAsString(newPlanTieredBpsPrice), - jacksonTypeRef(), - ) - - assertThat(roundtrippedNewPlanTieredBpsPrice).isEqualTo(newPlanTieredBpsPrice) - } -} diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionBpsPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionBpsPriceTest.kt deleted file mode 100644 index 052414ec2..000000000 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionBpsPriceTest.kt +++ /dev/null @@ -1,171 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.withorb.api.models - -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.withorb.api.core.JsonValue -import com.withorb.api.core.jsonMapper -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class NewSubscriptionBpsPriceTest { - - @Test - fun create() { - val newSubscriptionBpsPrice = - NewSubscriptionBpsPrice.builder() - .bpsConfig(BpsConfig.builder().bps(0.0).perUnitMaximum("per_unit_maximum").build()) - .cadence(NewSubscriptionBpsPrice.Cadence.ANNUAL) - .itemId("item_id") - .modelType(NewSubscriptionBpsPrice.ModelType.BPS) - .name("Annual fee") - .billableMetricId("billable_metric_id") - .billedInAdvance(true) - .billingCycleConfiguration( - NewBillingCycleConfiguration.builder() - .duration(0L) - .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) - .build() - ) - .conversionRate(0.0) - .unitConversionRateConfig( - ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() - ) - .currency("currency") - .dimensionalPriceConfiguration( - NewDimensionalPriceConfiguration.builder() - .addDimensionValue("string") - .dimensionalPriceGroupId("dimensional_price_group_id") - .externalDimensionalPriceGroupId("external_dimensional_price_group_id") - .build() - ) - .externalPriceId("external_price_id") - .fixedPriceQuantity(0.0) - .invoiceGroupingKey("x") - .invoicingCycleConfiguration( - NewBillingCycleConfiguration.builder() - .duration(0L) - .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) - .build() - ) - .metadata( - NewSubscriptionBpsPrice.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - .referenceId("reference_id") - .build() - - assertThat(newSubscriptionBpsPrice.bpsConfig()) - .isEqualTo(BpsConfig.builder().bps(0.0).perUnitMaximum("per_unit_maximum").build()) - assertThat(newSubscriptionBpsPrice.cadence()) - .isEqualTo(NewSubscriptionBpsPrice.Cadence.ANNUAL) - assertThat(newSubscriptionBpsPrice.itemId()).isEqualTo("item_id") - assertThat(newSubscriptionBpsPrice.modelType()) - .isEqualTo(NewSubscriptionBpsPrice.ModelType.BPS) - assertThat(newSubscriptionBpsPrice.name()).isEqualTo("Annual fee") - assertThat(newSubscriptionBpsPrice.billableMetricId()).isEqualTo("billable_metric_id") - assertThat(newSubscriptionBpsPrice.billedInAdvance()).isEqualTo(true) - assertThat(newSubscriptionBpsPrice.billingCycleConfiguration()) - .isEqualTo( - NewBillingCycleConfiguration.builder() - .duration(0L) - .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) - .build() - ) - assertThat(newSubscriptionBpsPrice.conversionRate()).isEqualTo(0.0) - assertThat(newSubscriptionBpsPrice.conversionRateConfig()) - .isEqualTo( - ConversionRateConfig.ofUnit( - UnitConversionRateConfig.builder() - .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) - .unitConfig( - ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() - ) - .build() - ) - ) - assertThat(newSubscriptionBpsPrice.currency()).isEqualTo("currency") - assertThat(newSubscriptionBpsPrice.dimensionalPriceConfiguration()) - .isEqualTo( - NewDimensionalPriceConfiguration.builder() - .addDimensionValue("string") - .dimensionalPriceGroupId("dimensional_price_group_id") - .externalDimensionalPriceGroupId("external_dimensional_price_group_id") - .build() - ) - assertThat(newSubscriptionBpsPrice.externalPriceId()).isEqualTo("external_price_id") - assertThat(newSubscriptionBpsPrice.fixedPriceQuantity()).isEqualTo(0.0) - assertThat(newSubscriptionBpsPrice.invoiceGroupingKey()).isEqualTo("x") - assertThat(newSubscriptionBpsPrice.invoicingCycleConfiguration()) - .isEqualTo( - NewBillingCycleConfiguration.builder() - .duration(0L) - .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) - .build() - ) - assertThat(newSubscriptionBpsPrice.metadata()) - .isEqualTo( - NewSubscriptionBpsPrice.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - assertThat(newSubscriptionBpsPrice.referenceId()).isEqualTo("reference_id") - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val newSubscriptionBpsPrice = - NewSubscriptionBpsPrice.builder() - .bpsConfig(BpsConfig.builder().bps(0.0).perUnitMaximum("per_unit_maximum").build()) - .cadence(NewSubscriptionBpsPrice.Cadence.ANNUAL) - .itemId("item_id") - .modelType(NewSubscriptionBpsPrice.ModelType.BPS) - .name("Annual fee") - .billableMetricId("billable_metric_id") - .billedInAdvance(true) - .billingCycleConfiguration( - NewBillingCycleConfiguration.builder() - .duration(0L) - .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) - .build() - ) - .conversionRate(0.0) - .unitConversionRateConfig( - ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() - ) - .currency("currency") - .dimensionalPriceConfiguration( - NewDimensionalPriceConfiguration.builder() - .addDimensionValue("string") - .dimensionalPriceGroupId("dimensional_price_group_id") - .externalDimensionalPriceGroupId("external_dimensional_price_group_id") - .build() - ) - .externalPriceId("external_price_id") - .fixedPriceQuantity(0.0) - .invoiceGroupingKey("x") - .invoicingCycleConfiguration( - NewBillingCycleConfiguration.builder() - .duration(0L) - .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) - .build() - ) - .metadata( - NewSubscriptionBpsPrice.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - .referenceId("reference_id") - .build() - - val roundtrippedNewSubscriptionBpsPrice = - jsonMapper.readValue( - jsonMapper.writeValueAsString(newSubscriptionBpsPrice), - jacksonTypeRef(), - ) - - assertThat(roundtrippedNewSubscriptionBpsPrice).isEqualTo(newSubscriptionBpsPrice) - } -} diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionBulkBpsPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionBulkBpsPriceTest.kt deleted file mode 100644 index 4816a40ce..000000000 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionBulkBpsPriceTest.kt +++ /dev/null @@ -1,201 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.withorb.api.models - -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.withorb.api.core.JsonValue -import com.withorb.api.core.jsonMapper -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class NewSubscriptionBulkBpsPriceTest { - - @Test - fun create() { - val newSubscriptionBulkBpsPrice = - NewSubscriptionBulkBpsPrice.builder() - .bulkBpsConfig( - BulkBpsConfig.builder() - .addTier( - BulkBpsTier.builder() - .bps(0.0) - .maximumAmount("maximum_amount") - .perUnitMaximum("per_unit_maximum") - .build() - ) - .build() - ) - .cadence(NewSubscriptionBulkBpsPrice.Cadence.ANNUAL) - .itemId("item_id") - .modelType(NewSubscriptionBulkBpsPrice.ModelType.BULK_BPS) - .name("Annual fee") - .billableMetricId("billable_metric_id") - .billedInAdvance(true) - .billingCycleConfiguration( - NewBillingCycleConfiguration.builder() - .duration(0L) - .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) - .build() - ) - .conversionRate(0.0) - .unitConversionRateConfig( - ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() - ) - .currency("currency") - .dimensionalPriceConfiguration( - NewDimensionalPriceConfiguration.builder() - .addDimensionValue("string") - .dimensionalPriceGroupId("dimensional_price_group_id") - .externalDimensionalPriceGroupId("external_dimensional_price_group_id") - .build() - ) - .externalPriceId("external_price_id") - .fixedPriceQuantity(0.0) - .invoiceGroupingKey("x") - .invoicingCycleConfiguration( - NewBillingCycleConfiguration.builder() - .duration(0L) - .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) - .build() - ) - .metadata( - NewSubscriptionBulkBpsPrice.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - .referenceId("reference_id") - .build() - - assertThat(newSubscriptionBulkBpsPrice.bulkBpsConfig()) - .isEqualTo( - BulkBpsConfig.builder() - .addTier( - BulkBpsTier.builder() - .bps(0.0) - .maximumAmount("maximum_amount") - .perUnitMaximum("per_unit_maximum") - .build() - ) - .build() - ) - assertThat(newSubscriptionBulkBpsPrice.cadence()) - .isEqualTo(NewSubscriptionBulkBpsPrice.Cadence.ANNUAL) - assertThat(newSubscriptionBulkBpsPrice.itemId()).isEqualTo("item_id") - assertThat(newSubscriptionBulkBpsPrice.modelType()) - .isEqualTo(NewSubscriptionBulkBpsPrice.ModelType.BULK_BPS) - assertThat(newSubscriptionBulkBpsPrice.name()).isEqualTo("Annual fee") - assertThat(newSubscriptionBulkBpsPrice.billableMetricId()).isEqualTo("billable_metric_id") - assertThat(newSubscriptionBulkBpsPrice.billedInAdvance()).isEqualTo(true) - assertThat(newSubscriptionBulkBpsPrice.billingCycleConfiguration()) - .isEqualTo( - NewBillingCycleConfiguration.builder() - .duration(0L) - .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) - .build() - ) - assertThat(newSubscriptionBulkBpsPrice.conversionRate()).isEqualTo(0.0) - assertThat(newSubscriptionBulkBpsPrice.conversionRateConfig()) - .isEqualTo( - ConversionRateConfig.ofUnit( - UnitConversionRateConfig.builder() - .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) - .unitConfig( - ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() - ) - .build() - ) - ) - assertThat(newSubscriptionBulkBpsPrice.currency()).isEqualTo("currency") - assertThat(newSubscriptionBulkBpsPrice.dimensionalPriceConfiguration()) - .isEqualTo( - NewDimensionalPriceConfiguration.builder() - .addDimensionValue("string") - .dimensionalPriceGroupId("dimensional_price_group_id") - .externalDimensionalPriceGroupId("external_dimensional_price_group_id") - .build() - ) - assertThat(newSubscriptionBulkBpsPrice.externalPriceId()).isEqualTo("external_price_id") - assertThat(newSubscriptionBulkBpsPrice.fixedPriceQuantity()).isEqualTo(0.0) - assertThat(newSubscriptionBulkBpsPrice.invoiceGroupingKey()).isEqualTo("x") - assertThat(newSubscriptionBulkBpsPrice.invoicingCycleConfiguration()) - .isEqualTo( - NewBillingCycleConfiguration.builder() - .duration(0L) - .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) - .build() - ) - assertThat(newSubscriptionBulkBpsPrice.metadata()) - .isEqualTo( - NewSubscriptionBulkBpsPrice.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - assertThat(newSubscriptionBulkBpsPrice.referenceId()).isEqualTo("reference_id") - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val newSubscriptionBulkBpsPrice = - NewSubscriptionBulkBpsPrice.builder() - .bulkBpsConfig( - BulkBpsConfig.builder() - .addTier( - BulkBpsTier.builder() - .bps(0.0) - .maximumAmount("maximum_amount") - .perUnitMaximum("per_unit_maximum") - .build() - ) - .build() - ) - .cadence(NewSubscriptionBulkBpsPrice.Cadence.ANNUAL) - .itemId("item_id") - .modelType(NewSubscriptionBulkBpsPrice.ModelType.BULK_BPS) - .name("Annual fee") - .billableMetricId("billable_metric_id") - .billedInAdvance(true) - .billingCycleConfiguration( - NewBillingCycleConfiguration.builder() - .duration(0L) - .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) - .build() - ) - .conversionRate(0.0) - .unitConversionRateConfig( - ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() - ) - .currency("currency") - .dimensionalPriceConfiguration( - NewDimensionalPriceConfiguration.builder() - .addDimensionValue("string") - .dimensionalPriceGroupId("dimensional_price_group_id") - .externalDimensionalPriceGroupId("external_dimensional_price_group_id") - .build() - ) - .externalPriceId("external_price_id") - .fixedPriceQuantity(0.0) - .invoiceGroupingKey("x") - .invoicingCycleConfiguration( - NewBillingCycleConfiguration.builder() - .duration(0L) - .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) - .build() - ) - .metadata( - NewSubscriptionBulkBpsPrice.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - .referenceId("reference_id") - .build() - - val roundtrippedNewSubscriptionBulkBpsPrice = - jsonMapper.readValue( - jsonMapper.writeValueAsString(newSubscriptionBulkBpsPrice), - jacksonTypeRef(), - ) - - assertThat(roundtrippedNewSubscriptionBulkBpsPrice).isEqualTo(newSubscriptionBulkBpsPrice) - } -} diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionTieredBpsPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionTieredBpsPriceTest.kt deleted file mode 100644 index d04a8b7ca..000000000 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionTieredBpsPriceTest.kt +++ /dev/null @@ -1,205 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.withorb.api.models - -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.withorb.api.core.JsonValue -import com.withorb.api.core.jsonMapper -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class NewSubscriptionTieredBpsPriceTest { - - @Test - fun create() { - val newSubscriptionTieredBpsPrice = - NewSubscriptionTieredBpsPrice.builder() - .cadence(NewSubscriptionTieredBpsPrice.Cadence.ANNUAL) - .itemId("item_id") - .modelType(NewSubscriptionTieredBpsPrice.ModelType.TIERED_BPS) - .name("Annual fee") - .tieredBpsConfig( - TieredBpsConfig.builder() - .addTier( - BpsTier.builder() - .bps(0.0) - .minimumAmount("minimum_amount") - .maximumAmount("maximum_amount") - .perUnitMaximum("per_unit_maximum") - .build() - ) - .build() - ) - .billableMetricId("billable_metric_id") - .billedInAdvance(true) - .billingCycleConfiguration( - NewBillingCycleConfiguration.builder() - .duration(0L) - .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) - .build() - ) - .conversionRate(0.0) - .unitConversionRateConfig( - ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() - ) - .currency("currency") - .dimensionalPriceConfiguration( - NewDimensionalPriceConfiguration.builder() - .addDimensionValue("string") - .dimensionalPriceGroupId("dimensional_price_group_id") - .externalDimensionalPriceGroupId("external_dimensional_price_group_id") - .build() - ) - .externalPriceId("external_price_id") - .fixedPriceQuantity(0.0) - .invoiceGroupingKey("x") - .invoicingCycleConfiguration( - NewBillingCycleConfiguration.builder() - .duration(0L) - .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) - .build() - ) - .metadata( - NewSubscriptionTieredBpsPrice.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - .referenceId("reference_id") - .build() - - assertThat(newSubscriptionTieredBpsPrice.cadence()) - .isEqualTo(NewSubscriptionTieredBpsPrice.Cadence.ANNUAL) - assertThat(newSubscriptionTieredBpsPrice.itemId()).isEqualTo("item_id") - assertThat(newSubscriptionTieredBpsPrice.modelType()) - .isEqualTo(NewSubscriptionTieredBpsPrice.ModelType.TIERED_BPS) - assertThat(newSubscriptionTieredBpsPrice.name()).isEqualTo("Annual fee") - assertThat(newSubscriptionTieredBpsPrice.tieredBpsConfig()) - .isEqualTo( - TieredBpsConfig.builder() - .addTier( - BpsTier.builder() - .bps(0.0) - .minimumAmount("minimum_amount") - .maximumAmount("maximum_amount") - .perUnitMaximum("per_unit_maximum") - .build() - ) - .build() - ) - assertThat(newSubscriptionTieredBpsPrice.billableMetricId()).isEqualTo("billable_metric_id") - assertThat(newSubscriptionTieredBpsPrice.billedInAdvance()).isEqualTo(true) - assertThat(newSubscriptionTieredBpsPrice.billingCycleConfiguration()) - .isEqualTo( - NewBillingCycleConfiguration.builder() - .duration(0L) - .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) - .build() - ) - assertThat(newSubscriptionTieredBpsPrice.conversionRate()).isEqualTo(0.0) - assertThat(newSubscriptionTieredBpsPrice.conversionRateConfig()) - .isEqualTo( - ConversionRateConfig.ofUnit( - UnitConversionRateConfig.builder() - .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) - .unitConfig( - ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() - ) - .build() - ) - ) - assertThat(newSubscriptionTieredBpsPrice.currency()).isEqualTo("currency") - assertThat(newSubscriptionTieredBpsPrice.dimensionalPriceConfiguration()) - .isEqualTo( - NewDimensionalPriceConfiguration.builder() - .addDimensionValue("string") - .dimensionalPriceGroupId("dimensional_price_group_id") - .externalDimensionalPriceGroupId("external_dimensional_price_group_id") - .build() - ) - assertThat(newSubscriptionTieredBpsPrice.externalPriceId()).isEqualTo("external_price_id") - assertThat(newSubscriptionTieredBpsPrice.fixedPriceQuantity()).isEqualTo(0.0) - assertThat(newSubscriptionTieredBpsPrice.invoiceGroupingKey()).isEqualTo("x") - assertThat(newSubscriptionTieredBpsPrice.invoicingCycleConfiguration()) - .isEqualTo( - NewBillingCycleConfiguration.builder() - .duration(0L) - .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) - .build() - ) - assertThat(newSubscriptionTieredBpsPrice.metadata()) - .isEqualTo( - NewSubscriptionTieredBpsPrice.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - assertThat(newSubscriptionTieredBpsPrice.referenceId()).isEqualTo("reference_id") - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val newSubscriptionTieredBpsPrice = - NewSubscriptionTieredBpsPrice.builder() - .cadence(NewSubscriptionTieredBpsPrice.Cadence.ANNUAL) - .itemId("item_id") - .modelType(NewSubscriptionTieredBpsPrice.ModelType.TIERED_BPS) - .name("Annual fee") - .tieredBpsConfig( - TieredBpsConfig.builder() - .addTier( - BpsTier.builder() - .bps(0.0) - .minimumAmount("minimum_amount") - .maximumAmount("maximum_amount") - .perUnitMaximum("per_unit_maximum") - .build() - ) - .build() - ) - .billableMetricId("billable_metric_id") - .billedInAdvance(true) - .billingCycleConfiguration( - NewBillingCycleConfiguration.builder() - .duration(0L) - .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) - .build() - ) - .conversionRate(0.0) - .unitConversionRateConfig( - ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() - ) - .currency("currency") - .dimensionalPriceConfiguration( - NewDimensionalPriceConfiguration.builder() - .addDimensionValue("string") - .dimensionalPriceGroupId("dimensional_price_group_id") - .externalDimensionalPriceGroupId("external_dimensional_price_group_id") - .build() - ) - .externalPriceId("external_price_id") - .fixedPriceQuantity(0.0) - .invoiceGroupingKey("x") - .invoicingCycleConfiguration( - NewBillingCycleConfiguration.builder() - .duration(0L) - .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) - .build() - ) - .metadata( - NewSubscriptionTieredBpsPrice.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - .referenceId("reference_id") - .build() - - val roundtrippedNewSubscriptionTieredBpsPrice = - jsonMapper.readValue( - jsonMapper.writeValueAsString(newSubscriptionTieredBpsPrice), - jacksonTypeRef(), - ) - - assertThat(roundtrippedNewSubscriptionTieredBpsPrice) - .isEqualTo(newSubscriptionTieredBpsPrice) - } -} diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PerPriceCostTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PerPriceCostTest.kt index 130363b39..119a6eca6 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PerPriceCostTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PerPriceCostTest.kt @@ -26,6 +26,13 @@ internal class PerPriceCostTest { .build() ) .cadence(Price.Unit.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() @@ -134,6 +141,13 @@ internal class PerPriceCostTest { .build() ) .cadence(Price.Unit.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() @@ -246,6 +260,13 @@ internal class PerPriceCostTest { .build() ) .cadence(Price.Unit.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanListPageResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanListPageResponseTest.kt index c54feb689..c79c68717 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanListPageResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanListPageResponseTest.kt @@ -169,6 +169,13 @@ internal class PlanListPageResponseTest { .build() ) .cadence(Price.Unit.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder() @@ -437,6 +444,13 @@ internal class PlanListPageResponseTest { .build() ) .cadence(Price.Unit.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() @@ -706,6 +720,13 @@ internal class PlanListPageResponseTest { .build() ) .cadence(Price.Unit.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder() diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanTest.kt index 58c70483a..ad947c798 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanTest.kt @@ -167,6 +167,13 @@ internal class PlanTest { .build() ) .cadence(Price.Unit.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() @@ -438,6 +445,13 @@ internal class PlanTest { .build() ) .cadence(Price.Unit.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() @@ -704,6 +718,13 @@ internal class PlanTest { .build() ) .cadence(Price.Unit.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanVersionTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanVersionTest.kt index 8aefdd658..78b6080c2 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanVersionTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanVersionTest.kt @@ -58,6 +58,13 @@ internal class PlanVersionTest { .build() ) .cadence(Price.Unit.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() @@ -200,6 +207,13 @@ internal class PlanVersionTest { .build() ) .cadence(Price.Unit.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() @@ -341,6 +355,13 @@ internal class PlanVersionTest { .build() ) .cadence(Price.Unit.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceIntervalTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceIntervalTest.kt index ca898ff5c..809d3e08f 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceIntervalTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceIntervalTest.kt @@ -39,6 +39,13 @@ internal class PriceIntervalTest { .build() ) .cadence(Price.Unit.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() @@ -162,6 +169,13 @@ internal class PriceIntervalTest { .build() ) .cadence(Price.Unit.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() @@ -286,6 +300,13 @@ internal class PriceIntervalTest { .build() ) .cadence(Price.Unit.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceListPageResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceListPageResponseTest.kt index fcecceb07..6d692d39a 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceListPageResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceListPageResponseTest.kt @@ -26,6 +26,13 @@ internal class PriceListPageResponseTest { .build() ) .cadence(Price.Unit.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() @@ -133,6 +140,13 @@ internal class PriceListPageResponseTest { .build() ) .cadence(Price.Unit.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() @@ -243,6 +257,13 @@ internal class PriceListPageResponseTest { .build() ) .cadence(Price.Unit.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceTest.kt index 9ff32f91b..fc86fda89 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceTest.kt @@ -28,6 +28,13 @@ internal class PriceTest { .build() ) .cadence(Price.Unit.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() @@ -123,9 +130,6 @@ internal class PriceTest { assertThat(price.package_()).isNull() assertThat(price.matrix()).isNull() assertThat(price.tiered()).isNull() - assertThat(price.tieredBps()).isNull() - assertThat(price.bps()).isNull() - assertThat(price.bulkBps()).isNull() assertThat(price.bulk()).isNull() assertThat(price.thresholdTotalAmount()).isNull() assertThat(price.tieredPackage()).isNull() @@ -148,6 +152,7 @@ internal class PriceTest { assertThat(price.scalableMatrixWithTieredPricing()).isNull() assertThat(price.cumulativeGroupedBulk()).isNull() assertThat(price.groupedWithMinMaxThresholds()).isNull() + assertThat(price.minimum()).isNull() } @Test @@ -165,6 +170,13 @@ internal class PriceTest { .build() ) .cadence(Price.Unit.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() @@ -274,6 +286,13 @@ internal class PriceTest { .build() ) .cadence(Price.Package.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() @@ -371,9 +390,6 @@ internal class PriceTest { assertThat(price.package_()).isEqualTo(package_) assertThat(price.matrix()).isNull() assertThat(price.tiered()).isNull() - assertThat(price.tieredBps()).isNull() - assertThat(price.bps()).isNull() - assertThat(price.bulkBps()).isNull() assertThat(price.bulk()).isNull() assertThat(price.thresholdTotalAmount()).isNull() assertThat(price.tieredPackage()).isNull() @@ -396,6 +412,7 @@ internal class PriceTest { assertThat(price.scalableMatrixWithTieredPricing()).isNull() assertThat(price.cumulativeGroupedBulk()).isNull() assertThat(price.groupedWithMinMaxThresholds()).isNull() + assertThat(price.minimum()).isNull() } @Test @@ -413,6 +430,13 @@ internal class PriceTest { .build() ) .cadence(Price.Package.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() @@ -527,6 +551,13 @@ internal class PriceTest { .build() ) .cadence(Price.Matrix.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() @@ -633,9 +664,6 @@ internal class PriceTest { assertThat(price.package_()).isNull() assertThat(price.matrix()).isEqualTo(matrix) assertThat(price.tiered()).isNull() - assertThat(price.tieredBps()).isNull() - assertThat(price.bps()).isNull() - assertThat(price.bulkBps()).isNull() assertThat(price.bulk()).isNull() assertThat(price.thresholdTotalAmount()).isNull() assertThat(price.tieredPackage()).isNull() @@ -658,6 +686,7 @@ internal class PriceTest { assertThat(price.scalableMatrixWithTieredPricing()).isNull() assertThat(price.cumulativeGroupedBulk()).isNull() assertThat(price.groupedWithMinMaxThresholds()).isNull() + assertThat(price.minimum()).isNull() } @Test @@ -675,6 +704,13 @@ internal class PriceTest { .build() ) .cadence(Price.Matrix.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() @@ -795,6 +831,13 @@ internal class PriceTest { .build() ) .cadence(Price.Tiered.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() @@ -900,9 +943,6 @@ internal class PriceTest { assertThat(price.package_()).isNull() assertThat(price.matrix()).isNull() assertThat(price.tiered()).isEqualTo(tiered) - assertThat(price.tieredBps()).isNull() - assertThat(price.bps()).isNull() - assertThat(price.bulkBps()).isNull() assertThat(price.bulk()).isNull() assertThat(price.thresholdTotalAmount()).isNull() assertThat(price.tieredPackage()).isNull() @@ -925,6 +965,7 @@ internal class PriceTest { assertThat(price.scalableMatrixWithTieredPricing()).isNull() assertThat(price.cumulativeGroupedBulk()).isNull() assertThat(price.groupedWithMinMaxThresholds()).isNull() + assertThat(price.minimum()).isNull() } @Test @@ -942,6 +983,13 @@ internal class PriceTest { .build() ) .cadence(Price.Tiered.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() @@ -1049,9 +1097,9 @@ internal class PriceTest { } @Test - fun ofTieredBps() { - val tieredBps = - Price.TieredBps.builder() + fun ofBulk() { + val bulk = + Price.Bulk.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -1060,7 +1108,21 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .cadence(Price.TieredBps.Cadence.ONE_TIME) + .bulkConfig( + BulkConfig.builder() + .addTier( + BulkTier.builder().unitAmount("unit_amount").maximumUnits(0.0).build() + ) + .build() + ) + .cadence(Price.Bulk.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() @@ -1119,7 +1181,7 @@ internal class PriceTest { ) .maximumAmount("maximum_amount") .metadata( - Price.TieredBps.Metadata.builder() + Price.Bulk.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -1139,20 +1201,8 @@ internal class PriceTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.TieredBps.PriceType.USAGE_PRICE) + .priceType(Price.Bulk.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .tieredBpsConfig( - TieredBpsConfig.builder() - .addTier( - BpsTier.builder() - .bps(0.0) - .minimumAmount("minimum_amount") - .maximumAmount("maximum_amount") - .perUnitMaximum("per_unit_maximum") - .build() - ) - .build() - ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") @@ -1161,16 +1211,13 @@ internal class PriceTest { ) .build() - val price = Price.ofTieredBps(tieredBps) + val price = Price.ofBulk(bulk) assertThat(price.unit()).isNull() assertThat(price.package_()).isNull() assertThat(price.matrix()).isNull() assertThat(price.tiered()).isNull() - assertThat(price.tieredBps()).isEqualTo(tieredBps) - assertThat(price.bps()).isNull() - assertThat(price.bulkBps()).isNull() - assertThat(price.bulk()).isNull() + assertThat(price.bulk()).isEqualTo(bulk) assertThat(price.thresholdTotalAmount()).isNull() assertThat(price.tieredPackage()).isNull() assertThat(price.groupedTiered()).isNull() @@ -1192,14 +1239,15 @@ internal class PriceTest { assertThat(price.scalableMatrixWithTieredPricing()).isNull() assertThat(price.cumulativeGroupedBulk()).isNull() assertThat(price.groupedWithMinMaxThresholds()).isNull() + assertThat(price.minimum()).isNull() } @Test - fun ofTieredBpsRoundtrip() { + fun ofBulkRoundtrip() { val jsonMapper = jsonMapper() val price = - Price.ofTieredBps( - Price.TieredBps.builder() + Price.ofBulk( + Price.Bulk.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -1208,7 +1256,24 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .cadence(Price.TieredBps.Cadence.ONE_TIME) + .bulkConfig( + BulkConfig.builder() + .addTier( + BulkTier.builder() + .unitAmount("unit_amount") + .maximumUnits(0.0) + .build() + ) + .build() + ) + .cadence(Price.Bulk.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() @@ -1267,7 +1332,7 @@ internal class PriceTest { ) .maximumAmount("maximum_amount") .metadata( - Price.TieredBps.Metadata.builder() + Price.Bulk.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -1287,20 +1352,8 @@ internal class PriceTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.TieredBps.PriceType.USAGE_PRICE) + .priceType(Price.Bulk.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .tieredBpsConfig( - TieredBpsConfig.builder() - .addTier( - BpsTier.builder() - .bps(0.0) - .minimumAmount("minimum_amount") - .maximumAmount("maximum_amount") - .perUnitMaximum("per_unit_maximum") - .build() - ) - .build() - ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") @@ -1317,9 +1370,9 @@ internal class PriceTest { } @Test - fun ofBps() { - val bps = - Price.Bps.builder() + fun ofThresholdTotalAmount() { + val thresholdTotalAmount = + Price.ThresholdTotalAmount.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -1328,8 +1381,14 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .bpsConfig(BpsConfig.builder().bps(0.0).perUnitMaximum("per_unit_maximum").build()) - .cadence(Price.Bps.Cadence.ONE_TIME) + .cadence(Price.ThresholdTotalAmount.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() @@ -1388,7 +1447,7 @@ internal class PriceTest { ) .maximumAmount("maximum_amount") .metadata( - Price.Bps.Metadata.builder() + Price.ThresholdTotalAmount.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -1408,8 +1467,13 @@ internal class PriceTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.Bps.PriceType.USAGE_PRICE) + .priceType(Price.ThresholdTotalAmount.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") + .thresholdTotalAmountConfig( + Price.ThresholdTotalAmount.ThresholdTotalAmountConfig.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") @@ -1418,17 +1482,14 @@ internal class PriceTest { ) .build() - val price = Price.ofBps(bps) + val price = Price.ofThresholdTotalAmount(thresholdTotalAmount) assertThat(price.unit()).isNull() assertThat(price.package_()).isNull() assertThat(price.matrix()).isNull() assertThat(price.tiered()).isNull() - assertThat(price.tieredBps()).isNull() - assertThat(price.bps()).isEqualTo(bps) - assertThat(price.bulkBps()).isNull() assertThat(price.bulk()).isNull() - assertThat(price.thresholdTotalAmount()).isNull() + assertThat(price.thresholdTotalAmount()).isEqualTo(thresholdTotalAmount) assertThat(price.tieredPackage()).isNull() assertThat(price.groupedTiered()).isNull() assertThat(price.tieredWithMinimum()).isNull() @@ -1449,14 +1510,15 @@ internal class PriceTest { assertThat(price.scalableMatrixWithTieredPricing()).isNull() assertThat(price.cumulativeGroupedBulk()).isNull() assertThat(price.groupedWithMinMaxThresholds()).isNull() + assertThat(price.minimum()).isNull() } @Test - fun ofBpsRoundtrip() { + fun ofThresholdTotalAmountRoundtrip() { val jsonMapper = jsonMapper() val price = - Price.ofBps( - Price.Bps.builder() + Price.ofThresholdTotalAmount( + Price.ThresholdTotalAmount.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -1465,10 +1527,14 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .bpsConfig( - BpsConfig.builder().bps(0.0).perUnitMaximum("per_unit_maximum").build() + .cadence(Price.ThresholdTotalAmount.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() ) - .cadence(Price.Bps.Cadence.ONE_TIME) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() @@ -1527,7 +1593,7 @@ internal class PriceTest { ) .maximumAmount("maximum_amount") .metadata( - Price.Bps.Metadata.builder() + Price.ThresholdTotalAmount.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -1547,8 +1613,13 @@ internal class PriceTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.Bps.PriceType.USAGE_PRICE) + .priceType(Price.ThresholdTotalAmount.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") + .thresholdTotalAmountConfig( + Price.ThresholdTotalAmount.ThresholdTotalAmountConfig.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") @@ -1565,9 +1636,9 @@ internal class PriceTest { } @Test - fun ofBulkBps() { - val bulkBps = - Price.BulkBps.builder() + fun ofTieredPackage() { + val tieredPackage = + Price.TieredPackage.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -1576,18 +1647,14 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .bulkBpsConfig( - BulkBpsConfig.builder() - .addTier( - BulkBpsTier.builder() - .bps(0.0) - .maximumAmount("maximum_amount") - .perUnitMaximum("per_unit_maximum") - .build() - ) + .cadence(Price.TieredPackage.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") .build() ) - .cadence(Price.BulkBps.Cadence.ONE_TIME) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() @@ -1646,7 +1713,7 @@ internal class PriceTest { ) .maximumAmount("maximum_amount") .metadata( - Price.BulkBps.Metadata.builder() + Price.TieredPackage.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -1666,8 +1733,13 @@ internal class PriceTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.BulkBps.PriceType.USAGE_PRICE) + .priceType(Price.TieredPackage.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") + .tieredPackageConfig( + Price.TieredPackage.TieredPackageConfig.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") @@ -1676,18 +1748,15 @@ internal class PriceTest { ) .build() - val price = Price.ofBulkBps(bulkBps) + val price = Price.ofTieredPackage(tieredPackage) assertThat(price.unit()).isNull() assertThat(price.package_()).isNull() assertThat(price.matrix()).isNull() assertThat(price.tiered()).isNull() - assertThat(price.tieredBps()).isNull() - assertThat(price.bps()).isNull() - assertThat(price.bulkBps()).isEqualTo(bulkBps) assertThat(price.bulk()).isNull() assertThat(price.thresholdTotalAmount()).isNull() - assertThat(price.tieredPackage()).isNull() + assertThat(price.tieredPackage()).isEqualTo(tieredPackage) assertThat(price.groupedTiered()).isNull() assertThat(price.tieredWithMinimum()).isNull() assertThat(price.tieredPackageWithMinimum()).isNull() @@ -1707,14 +1776,15 @@ internal class PriceTest { assertThat(price.scalableMatrixWithTieredPricing()).isNull() assertThat(price.cumulativeGroupedBulk()).isNull() assertThat(price.groupedWithMinMaxThresholds()).isNull() + assertThat(price.minimum()).isNull() } @Test - fun ofBulkBpsRoundtrip() { + fun ofTieredPackageRoundtrip() { val jsonMapper = jsonMapper() val price = - Price.ofBulkBps( - Price.BulkBps.builder() + Price.ofTieredPackage( + Price.TieredPackage.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -1723,18 +1793,14 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .bulkBpsConfig( - BulkBpsConfig.builder() - .addTier( - BulkBpsTier.builder() - .bps(0.0) - .maximumAmount("maximum_amount") - .perUnitMaximum("per_unit_maximum") - .build() - ) + .cadence(Price.TieredPackage.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") .build() ) - .cadence(Price.BulkBps.Cadence.ONE_TIME) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() @@ -1793,7 +1859,7 @@ internal class PriceTest { ) .maximumAmount("maximum_amount") .metadata( - Price.BulkBps.Metadata.builder() + Price.TieredPackage.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -1813,8 +1879,13 @@ internal class PriceTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.BulkBps.PriceType.USAGE_PRICE) + .priceType(Price.TieredPackage.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") + .tieredPackageConfig( + Price.TieredPackage.TieredPackageConfig.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") @@ -1831,9 +1902,9 @@ internal class PriceTest { } @Test - fun ofBulk() { - val bulk = - Price.Bulk.builder() + fun ofGroupedTiered() { + val groupedTiered = + Price.GroupedTiered.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -1842,14 +1913,14 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .bulkConfig( - BulkConfig.builder() - .addTier( - BulkTier.builder().unitAmount("unit_amount").maximumUnits(0.0).build() - ) + .cadence(Price.GroupedTiered.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") .build() ) - .cadence(Price.Bulk.Cadence.ONE_TIME) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() @@ -1886,6 +1957,11 @@ internal class PriceTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .groupedTieredConfig( + Price.GroupedTiered.GroupedTieredConfig.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -1908,7 +1984,7 @@ internal class PriceTest { ) .maximumAmount("maximum_amount") .metadata( - Price.Bulk.Metadata.builder() + Price.GroupedTiered.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -1928,7 +2004,7 @@ internal class PriceTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.Bulk.PriceType.USAGE_PRICE) + .priceType(Price.GroupedTiered.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -1938,19 +2014,16 @@ internal class PriceTest { ) .build() - val price = Price.ofBulk(bulk) + val price = Price.ofGroupedTiered(groupedTiered) assertThat(price.unit()).isNull() assertThat(price.package_()).isNull() assertThat(price.matrix()).isNull() assertThat(price.tiered()).isNull() - assertThat(price.tieredBps()).isNull() - assertThat(price.bps()).isNull() - assertThat(price.bulkBps()).isNull() - assertThat(price.bulk()).isEqualTo(bulk) + assertThat(price.bulk()).isNull() assertThat(price.thresholdTotalAmount()).isNull() assertThat(price.tieredPackage()).isNull() - assertThat(price.groupedTiered()).isNull() + assertThat(price.groupedTiered()).isEqualTo(groupedTiered) assertThat(price.tieredWithMinimum()).isNull() assertThat(price.tieredPackageWithMinimum()).isNull() assertThat(price.packageWithAllocation()).isNull() @@ -1969,14 +2042,15 @@ internal class PriceTest { assertThat(price.scalableMatrixWithTieredPricing()).isNull() assertThat(price.cumulativeGroupedBulk()).isNull() assertThat(price.groupedWithMinMaxThresholds()).isNull() + assertThat(price.minimum()).isNull() } @Test - fun ofBulkRoundtrip() { + fun ofGroupedTieredRoundtrip() { val jsonMapper = jsonMapper() val price = - Price.ofBulk( - Price.Bulk.builder() + Price.ofGroupedTiered( + Price.GroupedTiered.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -1985,17 +2059,14 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .bulkConfig( - BulkConfig.builder() - .addTier( - BulkTier.builder() - .unitAmount("unit_amount") - .maximumUnits(0.0) - .build() - ) + .cadence(Price.GroupedTiered.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") .build() ) - .cadence(Price.Bulk.Cadence.ONE_TIME) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() @@ -2032,6 +2103,11 @@ internal class PriceTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .groupedTieredConfig( + Price.GroupedTiered.GroupedTieredConfig.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -2054,7 +2130,7 @@ internal class PriceTest { ) .maximumAmount("maximum_amount") .metadata( - Price.Bulk.Metadata.builder() + Price.GroupedTiered.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -2074,7 +2150,7 @@ internal class PriceTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.Bulk.PriceType.USAGE_PRICE) + .priceType(Price.GroupedTiered.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -2092,9 +2168,9 @@ internal class PriceTest { } @Test - fun ofThresholdTotalAmount() { - val thresholdTotalAmount = - Price.ThresholdTotalAmount.builder() + fun ofTieredWithMinimum() { + val tieredWithMinimum = + Price.TieredWithMinimum.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -2103,7 +2179,14 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .cadence(Price.ThresholdTotalAmount.Cadence.ONE_TIME) + .cadence(Price.TieredWithMinimum.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() @@ -2162,7 +2245,7 @@ internal class PriceTest { ) .maximumAmount("maximum_amount") .metadata( - Price.ThresholdTotalAmount.Metadata.builder() + Price.TieredWithMinimum.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -2182,10 +2265,10 @@ internal class PriceTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.ThresholdTotalAmount.PriceType.USAGE_PRICE) + .priceType(Price.TieredWithMinimum.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .thresholdTotalAmountConfig( - Price.ThresholdTotalAmount.ThresholdTotalAmountConfig.builder() + .tieredWithMinimumConfig( + Price.TieredWithMinimum.TieredWithMinimumConfig.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) @@ -2197,20 +2280,17 @@ internal class PriceTest { ) .build() - val price = Price.ofThresholdTotalAmount(thresholdTotalAmount) + val price = Price.ofTieredWithMinimum(tieredWithMinimum) assertThat(price.unit()).isNull() assertThat(price.package_()).isNull() assertThat(price.matrix()).isNull() assertThat(price.tiered()).isNull() - assertThat(price.tieredBps()).isNull() - assertThat(price.bps()).isNull() - assertThat(price.bulkBps()).isNull() assertThat(price.bulk()).isNull() - assertThat(price.thresholdTotalAmount()).isEqualTo(thresholdTotalAmount) + assertThat(price.thresholdTotalAmount()).isNull() assertThat(price.tieredPackage()).isNull() assertThat(price.groupedTiered()).isNull() - assertThat(price.tieredWithMinimum()).isNull() + assertThat(price.tieredWithMinimum()).isEqualTo(tieredWithMinimum) assertThat(price.tieredPackageWithMinimum()).isNull() assertThat(price.packageWithAllocation()).isNull() assertThat(price.unitWithPercent()).isNull() @@ -2228,14 +2308,15 @@ internal class PriceTest { assertThat(price.scalableMatrixWithTieredPricing()).isNull() assertThat(price.cumulativeGroupedBulk()).isNull() assertThat(price.groupedWithMinMaxThresholds()).isNull() + assertThat(price.minimum()).isNull() } @Test - fun ofThresholdTotalAmountRoundtrip() { + fun ofTieredWithMinimumRoundtrip() { val jsonMapper = jsonMapper() val price = - Price.ofThresholdTotalAmount( - Price.ThresholdTotalAmount.builder() + Price.ofTieredWithMinimum( + Price.TieredWithMinimum.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -2244,7 +2325,14 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .cadence(Price.ThresholdTotalAmount.Cadence.ONE_TIME) + .cadence(Price.TieredWithMinimum.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() @@ -2303,7 +2391,7 @@ internal class PriceTest { ) .maximumAmount("maximum_amount") .metadata( - Price.ThresholdTotalAmount.Metadata.builder() + Price.TieredWithMinimum.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -2323,10 +2411,10 @@ internal class PriceTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.ThresholdTotalAmount.PriceType.USAGE_PRICE) + .priceType(Price.TieredWithMinimum.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .thresholdTotalAmountConfig( - Price.ThresholdTotalAmount.ThresholdTotalAmountConfig.builder() + .tieredWithMinimumConfig( + Price.TieredWithMinimum.TieredWithMinimumConfig.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) @@ -2346,9 +2434,9 @@ internal class PriceTest { } @Test - fun ofTieredPackage() { - val tieredPackage = - Price.TieredPackage.builder() + fun ofTieredPackageWithMinimum() { + val tieredPackageWithMinimum = + Price.TieredPackageWithMinimum.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -2357,7 +2445,14 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .cadence(Price.TieredPackage.Cadence.ONE_TIME) + .cadence(Price.TieredPackageWithMinimum.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() @@ -2416,7 +2511,7 @@ internal class PriceTest { ) .maximumAmount("maximum_amount") .metadata( - Price.TieredPackage.Metadata.builder() + Price.TieredPackageWithMinimum.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -2436,10 +2531,10 @@ internal class PriceTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.TieredPackage.PriceType.USAGE_PRICE) + .priceType(Price.TieredPackageWithMinimum.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .tieredPackageConfig( - Price.TieredPackage.TieredPackageConfig.builder() + .tieredPackageWithMinimumConfig( + Price.TieredPackageWithMinimum.TieredPackageWithMinimumConfig.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) @@ -2451,21 +2546,18 @@ internal class PriceTest { ) .build() - val price = Price.ofTieredPackage(tieredPackage) + val price = Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum) assertThat(price.unit()).isNull() assertThat(price.package_()).isNull() assertThat(price.matrix()).isNull() assertThat(price.tiered()).isNull() - assertThat(price.tieredBps()).isNull() - assertThat(price.bps()).isNull() - assertThat(price.bulkBps()).isNull() assertThat(price.bulk()).isNull() assertThat(price.thresholdTotalAmount()).isNull() - assertThat(price.tieredPackage()).isEqualTo(tieredPackage) + assertThat(price.tieredPackage()).isNull() assertThat(price.groupedTiered()).isNull() assertThat(price.tieredWithMinimum()).isNull() - assertThat(price.tieredPackageWithMinimum()).isNull() + assertThat(price.tieredPackageWithMinimum()).isEqualTo(tieredPackageWithMinimum) assertThat(price.packageWithAllocation()).isNull() assertThat(price.unitWithPercent()).isNull() assertThat(price.matrixWithAllocation()).isNull() @@ -2482,14 +2574,15 @@ internal class PriceTest { assertThat(price.scalableMatrixWithTieredPricing()).isNull() assertThat(price.cumulativeGroupedBulk()).isNull() assertThat(price.groupedWithMinMaxThresholds()).isNull() + assertThat(price.minimum()).isNull() } @Test - fun ofTieredPackageRoundtrip() { + fun ofTieredPackageWithMinimumRoundtrip() { val jsonMapper = jsonMapper() val price = - Price.ofTieredPackage( - Price.TieredPackage.builder() + Price.ofTieredPackageWithMinimum( + Price.TieredPackageWithMinimum.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -2498,7 +2591,14 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .cadence(Price.TieredPackage.Cadence.ONE_TIME) + .cadence(Price.TieredPackageWithMinimum.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() @@ -2557,7 +2657,7 @@ internal class PriceTest { ) .maximumAmount("maximum_amount") .metadata( - Price.TieredPackage.Metadata.builder() + Price.TieredPackageWithMinimum.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -2577,769 +2677,7 @@ internal class PriceTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.TieredPackage.PriceType.USAGE_PRICE) - .replacesPriceId("replaces_price_id") - .tieredPackageConfig( - Price.TieredPackage.TieredPackageConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .dimensionalPriceConfiguration( - DimensionalPriceConfiguration.builder() - .addDimensionValue("string") - .dimensionalPriceGroupId("dimensional_price_group_id") - .build() - ) - .build() - ) - - val roundtrippedPrice = - jsonMapper.readValue(jsonMapper.writeValueAsString(price), jacksonTypeRef()) - - assertThat(roundtrippedPrice).isEqualTo(price) - } - - @Test - fun ofGroupedTiered() { - val groupedTiered = - Price.GroupedTiered.builder() - .id("id") - .billableMetric(BillableMetricTiny.builder().id("id").build()) - .billingCycleConfiguration( - BillingCycleConfiguration.builder() - .duration(0L) - .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) - .build() - ) - .cadence(Price.GroupedTiered.Cadence.ONE_TIME) - .conversionRate(0.0) - .unitConversionRateConfig( - ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() - ) - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .creditAllocation( - Allocation.builder() - .allowsRollover(true) - .currency("currency") - .customExpiration( - CustomExpiration.builder() - .duration(0L) - .durationUnit(CustomExpiration.DurationUnit.DAY) - .build() - ) - .build() - ) - .currency("currency") - .discount( - PercentageDiscount.builder() - .discountType(PercentageDiscount.DiscountType.PERCENTAGE) - .percentageDiscount(0.15) - .addAppliesToPriceId("h74gfhdjvn7ujokd") - .addAppliesToPriceId("7hfgtgjnbvc3ujkl") - .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) - .addValue("string") - .build() - ) - .reason("reason") - .build() - ) - .externalPriceId("external_price_id") - .fixedPriceQuantity(0.0) - .groupedTieredConfig( - Price.GroupedTiered.GroupedTieredConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .invoicingCycleConfiguration( - BillingCycleConfiguration.builder() - .duration(0L) - .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) - .build() - ) - .item(ItemSlim.builder().id("id").name("name").build()) - .maximum( - Maximum.builder() - .addAppliesToPriceId("string") - .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) - .addValue("string") - .build() - ) - .maximumAmount("maximum_amount") - .build() - ) - .maximumAmount("maximum_amount") - .metadata( - Price.GroupedTiered.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - .minimum( - Minimum.builder() - .addAppliesToPriceId("string") - .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) - .addValue("string") - .build() - ) - .minimumAmount("minimum_amount") - .build() - ) - .minimumAmount("minimum_amount") - .name("name") - .planPhaseOrder(0L) - .priceType(Price.GroupedTiered.PriceType.USAGE_PRICE) - .replacesPriceId("replaces_price_id") - .dimensionalPriceConfiguration( - DimensionalPriceConfiguration.builder() - .addDimensionValue("string") - .dimensionalPriceGroupId("dimensional_price_group_id") - .build() - ) - .build() - - val price = Price.ofGroupedTiered(groupedTiered) - - assertThat(price.unit()).isNull() - assertThat(price.package_()).isNull() - assertThat(price.matrix()).isNull() - assertThat(price.tiered()).isNull() - assertThat(price.tieredBps()).isNull() - assertThat(price.bps()).isNull() - assertThat(price.bulkBps()).isNull() - assertThat(price.bulk()).isNull() - assertThat(price.thresholdTotalAmount()).isNull() - assertThat(price.tieredPackage()).isNull() - assertThat(price.groupedTiered()).isEqualTo(groupedTiered) - assertThat(price.tieredWithMinimum()).isNull() - assertThat(price.tieredPackageWithMinimum()).isNull() - assertThat(price.packageWithAllocation()).isNull() - assertThat(price.unitWithPercent()).isNull() - assertThat(price.matrixWithAllocation()).isNull() - assertThat(price.tieredWithProration()).isNull() - assertThat(price.unitWithProration()).isNull() - assertThat(price.groupedAllocation()).isNull() - assertThat(price.groupedWithProratedMinimum()).isNull() - assertThat(price.groupedWithMeteredMinimum()).isNull() - assertThat(price.matrixWithDisplayName()).isNull() - assertThat(price.bulkWithProration()).isNull() - assertThat(price.groupedTieredPackage()).isNull() - assertThat(price.maxGroupTieredPackage()).isNull() - assertThat(price.scalableMatrixWithUnitPricing()).isNull() - assertThat(price.scalableMatrixWithTieredPricing()).isNull() - assertThat(price.cumulativeGroupedBulk()).isNull() - assertThat(price.groupedWithMinMaxThresholds()).isNull() - } - - @Test - fun ofGroupedTieredRoundtrip() { - val jsonMapper = jsonMapper() - val price = - Price.ofGroupedTiered( - Price.GroupedTiered.builder() - .id("id") - .billableMetric(BillableMetricTiny.builder().id("id").build()) - .billingCycleConfiguration( - BillingCycleConfiguration.builder() - .duration(0L) - .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) - .build() - ) - .cadence(Price.GroupedTiered.Cadence.ONE_TIME) - .conversionRate(0.0) - .unitConversionRateConfig( - ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() - ) - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .creditAllocation( - Allocation.builder() - .allowsRollover(true) - .currency("currency") - .customExpiration( - CustomExpiration.builder() - .duration(0L) - .durationUnit(CustomExpiration.DurationUnit.DAY) - .build() - ) - .build() - ) - .currency("currency") - .discount( - PercentageDiscount.builder() - .discountType(PercentageDiscount.DiscountType.PERCENTAGE) - .percentageDiscount(0.15) - .addAppliesToPriceId("h74gfhdjvn7ujokd") - .addAppliesToPriceId("7hfgtgjnbvc3ujkl") - .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) - .addValue("string") - .build() - ) - .reason("reason") - .build() - ) - .externalPriceId("external_price_id") - .fixedPriceQuantity(0.0) - .groupedTieredConfig( - Price.GroupedTiered.GroupedTieredConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .invoicingCycleConfiguration( - BillingCycleConfiguration.builder() - .duration(0L) - .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) - .build() - ) - .item(ItemSlim.builder().id("id").name("name").build()) - .maximum( - Maximum.builder() - .addAppliesToPriceId("string") - .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) - .addValue("string") - .build() - ) - .maximumAmount("maximum_amount") - .build() - ) - .maximumAmount("maximum_amount") - .metadata( - Price.GroupedTiered.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - .minimum( - Minimum.builder() - .addAppliesToPriceId("string") - .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) - .addValue("string") - .build() - ) - .minimumAmount("minimum_amount") - .build() - ) - .minimumAmount("minimum_amount") - .name("name") - .planPhaseOrder(0L) - .priceType(Price.GroupedTiered.PriceType.USAGE_PRICE) - .replacesPriceId("replaces_price_id") - .dimensionalPriceConfiguration( - DimensionalPriceConfiguration.builder() - .addDimensionValue("string") - .dimensionalPriceGroupId("dimensional_price_group_id") - .build() - ) - .build() - ) - - val roundtrippedPrice = - jsonMapper.readValue(jsonMapper.writeValueAsString(price), jacksonTypeRef()) - - assertThat(roundtrippedPrice).isEqualTo(price) - } - - @Test - fun ofTieredWithMinimum() { - val tieredWithMinimum = - Price.TieredWithMinimum.builder() - .id("id") - .billableMetric(BillableMetricTiny.builder().id("id").build()) - .billingCycleConfiguration( - BillingCycleConfiguration.builder() - .duration(0L) - .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) - .build() - ) - .cadence(Price.TieredWithMinimum.Cadence.ONE_TIME) - .conversionRate(0.0) - .unitConversionRateConfig( - ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() - ) - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .creditAllocation( - Allocation.builder() - .allowsRollover(true) - .currency("currency") - .customExpiration( - CustomExpiration.builder() - .duration(0L) - .durationUnit(CustomExpiration.DurationUnit.DAY) - .build() - ) - .build() - ) - .currency("currency") - .discount( - PercentageDiscount.builder() - .discountType(PercentageDiscount.DiscountType.PERCENTAGE) - .percentageDiscount(0.15) - .addAppliesToPriceId("h74gfhdjvn7ujokd") - .addAppliesToPriceId("7hfgtgjnbvc3ujkl") - .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) - .addValue("string") - .build() - ) - .reason("reason") - .build() - ) - .externalPriceId("external_price_id") - .fixedPriceQuantity(0.0) - .invoicingCycleConfiguration( - BillingCycleConfiguration.builder() - .duration(0L) - .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) - .build() - ) - .item(ItemSlim.builder().id("id").name("name").build()) - .maximum( - Maximum.builder() - .addAppliesToPriceId("string") - .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) - .addValue("string") - .build() - ) - .maximumAmount("maximum_amount") - .build() - ) - .maximumAmount("maximum_amount") - .metadata( - Price.TieredWithMinimum.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - .minimum( - Minimum.builder() - .addAppliesToPriceId("string") - .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) - .addValue("string") - .build() - ) - .minimumAmount("minimum_amount") - .build() - ) - .minimumAmount("minimum_amount") - .name("name") - .planPhaseOrder(0L) - .priceType(Price.TieredWithMinimum.PriceType.USAGE_PRICE) - .replacesPriceId("replaces_price_id") - .tieredWithMinimumConfig( - Price.TieredWithMinimum.TieredWithMinimumConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .dimensionalPriceConfiguration( - DimensionalPriceConfiguration.builder() - .addDimensionValue("string") - .dimensionalPriceGroupId("dimensional_price_group_id") - .build() - ) - .build() - - val price = Price.ofTieredWithMinimum(tieredWithMinimum) - - assertThat(price.unit()).isNull() - assertThat(price.package_()).isNull() - assertThat(price.matrix()).isNull() - assertThat(price.tiered()).isNull() - assertThat(price.tieredBps()).isNull() - assertThat(price.bps()).isNull() - assertThat(price.bulkBps()).isNull() - assertThat(price.bulk()).isNull() - assertThat(price.thresholdTotalAmount()).isNull() - assertThat(price.tieredPackage()).isNull() - assertThat(price.groupedTiered()).isNull() - assertThat(price.tieredWithMinimum()).isEqualTo(tieredWithMinimum) - assertThat(price.tieredPackageWithMinimum()).isNull() - assertThat(price.packageWithAllocation()).isNull() - assertThat(price.unitWithPercent()).isNull() - assertThat(price.matrixWithAllocation()).isNull() - assertThat(price.tieredWithProration()).isNull() - assertThat(price.unitWithProration()).isNull() - assertThat(price.groupedAllocation()).isNull() - assertThat(price.groupedWithProratedMinimum()).isNull() - assertThat(price.groupedWithMeteredMinimum()).isNull() - assertThat(price.matrixWithDisplayName()).isNull() - assertThat(price.bulkWithProration()).isNull() - assertThat(price.groupedTieredPackage()).isNull() - assertThat(price.maxGroupTieredPackage()).isNull() - assertThat(price.scalableMatrixWithUnitPricing()).isNull() - assertThat(price.scalableMatrixWithTieredPricing()).isNull() - assertThat(price.cumulativeGroupedBulk()).isNull() - assertThat(price.groupedWithMinMaxThresholds()).isNull() - } - - @Test - fun ofTieredWithMinimumRoundtrip() { - val jsonMapper = jsonMapper() - val price = - Price.ofTieredWithMinimum( - Price.TieredWithMinimum.builder() - .id("id") - .billableMetric(BillableMetricTiny.builder().id("id").build()) - .billingCycleConfiguration( - BillingCycleConfiguration.builder() - .duration(0L) - .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) - .build() - ) - .cadence(Price.TieredWithMinimum.Cadence.ONE_TIME) - .conversionRate(0.0) - .unitConversionRateConfig( - ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() - ) - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .creditAllocation( - Allocation.builder() - .allowsRollover(true) - .currency("currency") - .customExpiration( - CustomExpiration.builder() - .duration(0L) - .durationUnit(CustomExpiration.DurationUnit.DAY) - .build() - ) - .build() - ) - .currency("currency") - .discount( - PercentageDiscount.builder() - .discountType(PercentageDiscount.DiscountType.PERCENTAGE) - .percentageDiscount(0.15) - .addAppliesToPriceId("h74gfhdjvn7ujokd") - .addAppliesToPriceId("7hfgtgjnbvc3ujkl") - .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) - .addValue("string") - .build() - ) - .reason("reason") - .build() - ) - .externalPriceId("external_price_id") - .fixedPriceQuantity(0.0) - .invoicingCycleConfiguration( - BillingCycleConfiguration.builder() - .duration(0L) - .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) - .build() - ) - .item(ItemSlim.builder().id("id").name("name").build()) - .maximum( - Maximum.builder() - .addAppliesToPriceId("string") - .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) - .addValue("string") - .build() - ) - .maximumAmount("maximum_amount") - .build() - ) - .maximumAmount("maximum_amount") - .metadata( - Price.TieredWithMinimum.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - .minimum( - Minimum.builder() - .addAppliesToPriceId("string") - .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) - .addValue("string") - .build() - ) - .minimumAmount("minimum_amount") - .build() - ) - .minimumAmount("minimum_amount") - .name("name") - .planPhaseOrder(0L) - .priceType(Price.TieredWithMinimum.PriceType.USAGE_PRICE) - .replacesPriceId("replaces_price_id") - .tieredWithMinimumConfig( - Price.TieredWithMinimum.TieredWithMinimumConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .dimensionalPriceConfiguration( - DimensionalPriceConfiguration.builder() - .addDimensionValue("string") - .dimensionalPriceGroupId("dimensional_price_group_id") - .build() - ) - .build() - ) - - val roundtrippedPrice = - jsonMapper.readValue(jsonMapper.writeValueAsString(price), jacksonTypeRef()) - - assertThat(roundtrippedPrice).isEqualTo(price) - } - - @Test - fun ofTieredPackageWithMinimum() { - val tieredPackageWithMinimum = - Price.TieredPackageWithMinimum.builder() - .id("id") - .billableMetric(BillableMetricTiny.builder().id("id").build()) - .billingCycleConfiguration( - BillingCycleConfiguration.builder() - .duration(0L) - .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) - .build() - ) - .cadence(Price.TieredPackageWithMinimum.Cadence.ONE_TIME) - .conversionRate(0.0) - .unitConversionRateConfig( - ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() - ) - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .creditAllocation( - Allocation.builder() - .allowsRollover(true) - .currency("currency") - .customExpiration( - CustomExpiration.builder() - .duration(0L) - .durationUnit(CustomExpiration.DurationUnit.DAY) - .build() - ) - .build() - ) - .currency("currency") - .discount( - PercentageDiscount.builder() - .discountType(PercentageDiscount.DiscountType.PERCENTAGE) - .percentageDiscount(0.15) - .addAppliesToPriceId("h74gfhdjvn7ujokd") - .addAppliesToPriceId("7hfgtgjnbvc3ujkl") - .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) - .addValue("string") - .build() - ) - .reason("reason") - .build() - ) - .externalPriceId("external_price_id") - .fixedPriceQuantity(0.0) - .invoicingCycleConfiguration( - BillingCycleConfiguration.builder() - .duration(0L) - .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) - .build() - ) - .item(ItemSlim.builder().id("id").name("name").build()) - .maximum( - Maximum.builder() - .addAppliesToPriceId("string") - .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) - .addValue("string") - .build() - ) - .maximumAmount("maximum_amount") - .build() - ) - .maximumAmount("maximum_amount") - .metadata( - Price.TieredPackageWithMinimum.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - .minimum( - Minimum.builder() - .addAppliesToPriceId("string") - .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) - .addValue("string") - .build() - ) - .minimumAmount("minimum_amount") - .build() - ) - .minimumAmount("minimum_amount") - .name("name") - .planPhaseOrder(0L) - .priceType(Price.TieredPackageWithMinimum.PriceType.USAGE_PRICE) - .replacesPriceId("replaces_price_id") - .tieredPackageWithMinimumConfig( - Price.TieredPackageWithMinimum.TieredPackageWithMinimumConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .dimensionalPriceConfiguration( - DimensionalPriceConfiguration.builder() - .addDimensionValue("string") - .dimensionalPriceGroupId("dimensional_price_group_id") - .build() - ) - .build() - - val price = Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum) - - assertThat(price.unit()).isNull() - assertThat(price.package_()).isNull() - assertThat(price.matrix()).isNull() - assertThat(price.tiered()).isNull() - assertThat(price.tieredBps()).isNull() - assertThat(price.bps()).isNull() - assertThat(price.bulkBps()).isNull() - assertThat(price.bulk()).isNull() - assertThat(price.thresholdTotalAmount()).isNull() - assertThat(price.tieredPackage()).isNull() - assertThat(price.groupedTiered()).isNull() - assertThat(price.tieredWithMinimum()).isNull() - assertThat(price.tieredPackageWithMinimum()).isEqualTo(tieredPackageWithMinimum) - assertThat(price.packageWithAllocation()).isNull() - assertThat(price.unitWithPercent()).isNull() - assertThat(price.matrixWithAllocation()).isNull() - assertThat(price.tieredWithProration()).isNull() - assertThat(price.unitWithProration()).isNull() - assertThat(price.groupedAllocation()).isNull() - assertThat(price.groupedWithProratedMinimum()).isNull() - assertThat(price.groupedWithMeteredMinimum()).isNull() - assertThat(price.matrixWithDisplayName()).isNull() - assertThat(price.bulkWithProration()).isNull() - assertThat(price.groupedTieredPackage()).isNull() - assertThat(price.maxGroupTieredPackage()).isNull() - assertThat(price.scalableMatrixWithUnitPricing()).isNull() - assertThat(price.scalableMatrixWithTieredPricing()).isNull() - assertThat(price.cumulativeGroupedBulk()).isNull() - assertThat(price.groupedWithMinMaxThresholds()).isNull() - } - - @Test - fun ofTieredPackageWithMinimumRoundtrip() { - val jsonMapper = jsonMapper() - val price = - Price.ofTieredPackageWithMinimum( - Price.TieredPackageWithMinimum.builder() - .id("id") - .billableMetric(BillableMetricTiny.builder().id("id").build()) - .billingCycleConfiguration( - BillingCycleConfiguration.builder() - .duration(0L) - .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) - .build() - ) - .cadence(Price.TieredPackageWithMinimum.Cadence.ONE_TIME) - .conversionRate(0.0) - .unitConversionRateConfig( - ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() - ) - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .creditAllocation( - Allocation.builder() - .allowsRollover(true) - .currency("currency") - .customExpiration( - CustomExpiration.builder() - .duration(0L) - .durationUnit(CustomExpiration.DurationUnit.DAY) - .build() - ) - .build() - ) - .currency("currency") - .discount( - PercentageDiscount.builder() - .discountType(PercentageDiscount.DiscountType.PERCENTAGE) - .percentageDiscount(0.15) - .addAppliesToPriceId("h74gfhdjvn7ujokd") - .addAppliesToPriceId("7hfgtgjnbvc3ujkl") - .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) - .addValue("string") - .build() - ) - .reason("reason") - .build() - ) - .externalPriceId("external_price_id") - .fixedPriceQuantity(0.0) - .invoicingCycleConfiguration( - BillingCycleConfiguration.builder() - .duration(0L) - .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) - .build() - ) - .item(ItemSlim.builder().id("id").name("name").build()) - .maximum( - Maximum.builder() - .addAppliesToPriceId("string") - .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) - .addValue("string") - .build() - ) - .maximumAmount("maximum_amount") - .build() - ) - .maximumAmount("maximum_amount") - .metadata( - Price.TieredPackageWithMinimum.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - .minimum( - Minimum.builder() - .addAppliesToPriceId("string") - .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) - .addValue("string") - .build() - ) - .minimumAmount("minimum_amount") - .build() - ) - .minimumAmount("minimum_amount") - .name("name") - .planPhaseOrder(0L) - .priceType(Price.TieredPackageWithMinimum.PriceType.USAGE_PRICE) + .priceType(Price.TieredPackageWithMinimum.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .tieredPackageWithMinimumConfig( Price.TieredPackageWithMinimum.TieredPackageWithMinimumConfig.builder() @@ -3374,6 +2712,13 @@ internal class PriceTest { .build() ) .cadence(Price.PackageWithAllocation.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() @@ -3473,9 +2818,6 @@ internal class PriceTest { assertThat(price.package_()).isNull() assertThat(price.matrix()).isNull() assertThat(price.tiered()).isNull() - assertThat(price.tieredBps()).isNull() - assertThat(price.bps()).isNull() - assertThat(price.bulkBps()).isNull() assertThat(price.bulk()).isNull() assertThat(price.thresholdTotalAmount()).isNull() assertThat(price.tieredPackage()).isNull() @@ -3498,6 +2840,7 @@ internal class PriceTest { assertThat(price.scalableMatrixWithTieredPricing()).isNull() assertThat(price.cumulativeGroupedBulk()).isNull() assertThat(price.groupedWithMinMaxThresholds()).isNull() + assertThat(price.minimum()).isNull() } @Test @@ -3515,6 +2858,13 @@ internal class PriceTest { .build() ) .cadence(Price.PackageWithAllocation.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() @@ -3628,6 +2978,13 @@ internal class PriceTest { .build() ) .cadence(Price.UnitWithPercent.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() @@ -3727,9 +3084,6 @@ internal class PriceTest { assertThat(price.package_()).isNull() assertThat(price.matrix()).isNull() assertThat(price.tiered()).isNull() - assertThat(price.tieredBps()).isNull() - assertThat(price.bps()).isNull() - assertThat(price.bulkBps()).isNull() assertThat(price.bulk()).isNull() assertThat(price.thresholdTotalAmount()).isNull() assertThat(price.tieredPackage()).isNull() @@ -3752,6 +3106,7 @@ internal class PriceTest { assertThat(price.scalableMatrixWithTieredPricing()).isNull() assertThat(price.cumulativeGroupedBulk()).isNull() assertThat(price.groupedWithMinMaxThresholds()).isNull() + assertThat(price.minimum()).isNull() } @Test @@ -3769,6 +3124,13 @@ internal class PriceTest { .build() ) .cadence(Price.UnitWithPercent.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() @@ -3882,6 +3244,13 @@ internal class PriceTest { .build() ) .cadence(Price.MatrixWithAllocation.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() @@ -3989,9 +3358,6 @@ internal class PriceTest { assertThat(price.package_()).isNull() assertThat(price.matrix()).isNull() assertThat(price.tiered()).isNull() - assertThat(price.tieredBps()).isNull() - assertThat(price.bps()).isNull() - assertThat(price.bulkBps()).isNull() assertThat(price.bulk()).isNull() assertThat(price.thresholdTotalAmount()).isNull() assertThat(price.tieredPackage()).isNull() @@ -4014,6 +3380,7 @@ internal class PriceTest { assertThat(price.scalableMatrixWithTieredPricing()).isNull() assertThat(price.cumulativeGroupedBulk()).isNull() assertThat(price.groupedWithMinMaxThresholds()).isNull() + assertThat(price.minimum()).isNull() } @Test @@ -4031,6 +3398,13 @@ internal class PriceTest { .build() ) .cadence(Price.MatrixWithAllocation.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() @@ -4152,6 +3526,13 @@ internal class PriceTest { .build() ) .cadence(Price.TieredWithProration.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() @@ -4251,9 +3632,6 @@ internal class PriceTest { assertThat(price.package_()).isNull() assertThat(price.matrix()).isNull() assertThat(price.tiered()).isNull() - assertThat(price.tieredBps()).isNull() - assertThat(price.bps()).isNull() - assertThat(price.bulkBps()).isNull() assertThat(price.bulk()).isNull() assertThat(price.thresholdTotalAmount()).isNull() assertThat(price.tieredPackage()).isNull() @@ -4276,6 +3654,7 @@ internal class PriceTest { assertThat(price.scalableMatrixWithTieredPricing()).isNull() assertThat(price.cumulativeGroupedBulk()).isNull() assertThat(price.groupedWithMinMaxThresholds()).isNull() + assertThat(price.minimum()).isNull() } @Test @@ -4293,6 +3672,13 @@ internal class PriceTest { .build() ) .cadence(Price.TieredWithProration.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() @@ -4406,6 +3792,13 @@ internal class PriceTest { .build() ) .cadence(Price.UnitWithProration.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() @@ -4505,9 +3898,6 @@ internal class PriceTest { assertThat(price.package_()).isNull() assertThat(price.matrix()).isNull() assertThat(price.tiered()).isNull() - assertThat(price.tieredBps()).isNull() - assertThat(price.bps()).isNull() - assertThat(price.bulkBps()).isNull() assertThat(price.bulk()).isNull() assertThat(price.thresholdTotalAmount()).isNull() assertThat(price.tieredPackage()).isNull() @@ -4530,6 +3920,7 @@ internal class PriceTest { assertThat(price.scalableMatrixWithTieredPricing()).isNull() assertThat(price.cumulativeGroupedBulk()).isNull() assertThat(price.groupedWithMinMaxThresholds()).isNull() + assertThat(price.minimum()).isNull() } @Test @@ -4547,6 +3938,13 @@ internal class PriceTest { .build() ) .cadence(Price.UnitWithProration.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() @@ -4660,6 +4058,13 @@ internal class PriceTest { .build() ) .cadence(Price.GroupedAllocation.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() @@ -4759,9 +4164,6 @@ internal class PriceTest { assertThat(price.package_()).isNull() assertThat(price.matrix()).isNull() assertThat(price.tiered()).isNull() - assertThat(price.tieredBps()).isNull() - assertThat(price.bps()).isNull() - assertThat(price.bulkBps()).isNull() assertThat(price.bulk()).isNull() assertThat(price.thresholdTotalAmount()).isNull() assertThat(price.tieredPackage()).isNull() @@ -4784,6 +4186,7 @@ internal class PriceTest { assertThat(price.scalableMatrixWithTieredPricing()).isNull() assertThat(price.cumulativeGroupedBulk()).isNull() assertThat(price.groupedWithMinMaxThresholds()).isNull() + assertThat(price.minimum()).isNull() } @Test @@ -4801,6 +4204,13 @@ internal class PriceTest { .build() ) .cadence(Price.GroupedAllocation.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() @@ -4914,6 +4324,13 @@ internal class PriceTest { .build() ) .cadence(Price.GroupedWithProratedMinimum.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() @@ -5013,9 +4430,6 @@ internal class PriceTest { assertThat(price.package_()).isNull() assertThat(price.matrix()).isNull() assertThat(price.tiered()).isNull() - assertThat(price.tieredBps()).isNull() - assertThat(price.bps()).isNull() - assertThat(price.bulkBps()).isNull() assertThat(price.bulk()).isNull() assertThat(price.thresholdTotalAmount()).isNull() assertThat(price.tieredPackage()).isNull() @@ -5038,6 +4452,7 @@ internal class PriceTest { assertThat(price.scalableMatrixWithTieredPricing()).isNull() assertThat(price.cumulativeGroupedBulk()).isNull() assertThat(price.groupedWithMinMaxThresholds()).isNull() + assertThat(price.minimum()).isNull() } @Test @@ -5055,6 +4470,13 @@ internal class PriceTest { .build() ) .cadence(Price.GroupedWithProratedMinimum.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() @@ -5168,6 +4590,13 @@ internal class PriceTest { .build() ) .cadence(Price.GroupedWithMeteredMinimum.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() @@ -5267,9 +4696,6 @@ internal class PriceTest { assertThat(price.package_()).isNull() assertThat(price.matrix()).isNull() assertThat(price.tiered()).isNull() - assertThat(price.tieredBps()).isNull() - assertThat(price.bps()).isNull() - assertThat(price.bulkBps()).isNull() assertThat(price.bulk()).isNull() assertThat(price.thresholdTotalAmount()).isNull() assertThat(price.tieredPackage()).isNull() @@ -5292,6 +4718,7 @@ internal class PriceTest { assertThat(price.scalableMatrixWithTieredPricing()).isNull() assertThat(price.cumulativeGroupedBulk()).isNull() assertThat(price.groupedWithMinMaxThresholds()).isNull() + assertThat(price.minimum()).isNull() } @Test @@ -5309,6 +4736,13 @@ internal class PriceTest { .build() ) .cadence(Price.GroupedWithMeteredMinimum.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() @@ -5422,6 +4856,13 @@ internal class PriceTest { .build() ) .cadence(Price.MatrixWithDisplayName.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() @@ -5521,9 +4962,6 @@ internal class PriceTest { assertThat(price.package_()).isNull() assertThat(price.matrix()).isNull() assertThat(price.tiered()).isNull() - assertThat(price.tieredBps()).isNull() - assertThat(price.bps()).isNull() - assertThat(price.bulkBps()).isNull() assertThat(price.bulk()).isNull() assertThat(price.thresholdTotalAmount()).isNull() assertThat(price.tieredPackage()).isNull() @@ -5546,6 +4984,7 @@ internal class PriceTest { assertThat(price.scalableMatrixWithTieredPricing()).isNull() assertThat(price.cumulativeGroupedBulk()).isNull() assertThat(price.groupedWithMinMaxThresholds()).isNull() + assertThat(price.minimum()).isNull() } @Test @@ -5563,6 +5002,13 @@ internal class PriceTest { .build() ) .cadence(Price.MatrixWithDisplayName.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() @@ -5681,6 +5127,13 @@ internal class PriceTest { .build() ) .cadence(Price.BulkWithProration.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() @@ -5775,9 +5228,6 @@ internal class PriceTest { assertThat(price.package_()).isNull() assertThat(price.matrix()).isNull() assertThat(price.tiered()).isNull() - assertThat(price.tieredBps()).isNull() - assertThat(price.bps()).isNull() - assertThat(price.bulkBps()).isNull() assertThat(price.bulk()).isNull() assertThat(price.thresholdTotalAmount()).isNull() assertThat(price.tieredPackage()).isNull() @@ -5800,6 +5250,7 @@ internal class PriceTest { assertThat(price.scalableMatrixWithTieredPricing()).isNull() assertThat(price.cumulativeGroupedBulk()).isNull() assertThat(price.groupedWithMinMaxThresholds()).isNull() + assertThat(price.minimum()).isNull() } @Test @@ -5822,6 +5273,13 @@ internal class PriceTest { .build() ) .cadence(Price.BulkWithProration.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() @@ -5930,6 +5388,13 @@ internal class PriceTest { .build() ) .cadence(Price.GroupedTieredPackage.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() @@ -6029,9 +5494,6 @@ internal class PriceTest { assertThat(price.package_()).isNull() assertThat(price.matrix()).isNull() assertThat(price.tiered()).isNull() - assertThat(price.tieredBps()).isNull() - assertThat(price.bps()).isNull() - assertThat(price.bulkBps()).isNull() assertThat(price.bulk()).isNull() assertThat(price.thresholdTotalAmount()).isNull() assertThat(price.tieredPackage()).isNull() @@ -6054,6 +5516,7 @@ internal class PriceTest { assertThat(price.scalableMatrixWithTieredPricing()).isNull() assertThat(price.cumulativeGroupedBulk()).isNull() assertThat(price.groupedWithMinMaxThresholds()).isNull() + assertThat(price.minimum()).isNull() } @Test @@ -6071,6 +5534,13 @@ internal class PriceTest { .build() ) .cadence(Price.GroupedTieredPackage.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() @@ -6184,6 +5654,13 @@ internal class PriceTest { .build() ) .cadence(Price.MaxGroupTieredPackage.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() @@ -6283,9 +5760,6 @@ internal class PriceTest { assertThat(price.package_()).isNull() assertThat(price.matrix()).isNull() assertThat(price.tiered()).isNull() - assertThat(price.tieredBps()).isNull() - assertThat(price.bps()).isNull() - assertThat(price.bulkBps()).isNull() assertThat(price.bulk()).isNull() assertThat(price.thresholdTotalAmount()).isNull() assertThat(price.tieredPackage()).isNull() @@ -6308,6 +5782,7 @@ internal class PriceTest { assertThat(price.scalableMatrixWithTieredPricing()).isNull() assertThat(price.cumulativeGroupedBulk()).isNull() assertThat(price.groupedWithMinMaxThresholds()).isNull() + assertThat(price.minimum()).isNull() } @Test @@ -6325,6 +5800,13 @@ internal class PriceTest { .build() ) .cadence(Price.MaxGroupTieredPackage.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() @@ -6438,6 +5920,13 @@ internal class PriceTest { .build() ) .cadence(Price.ScalableMatrixWithUnitPricing.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() @@ -6538,9 +6027,6 @@ internal class PriceTest { assertThat(price.package_()).isNull() assertThat(price.matrix()).isNull() assertThat(price.tiered()).isNull() - assertThat(price.tieredBps()).isNull() - assertThat(price.bps()).isNull() - assertThat(price.bulkBps()).isNull() assertThat(price.bulk()).isNull() assertThat(price.thresholdTotalAmount()).isNull() assertThat(price.tieredPackage()).isNull() @@ -6563,6 +6049,7 @@ internal class PriceTest { assertThat(price.scalableMatrixWithTieredPricing()).isNull() assertThat(price.cumulativeGroupedBulk()).isNull() assertThat(price.groupedWithMinMaxThresholds()).isNull() + assertThat(price.minimum()).isNull() } @Test @@ -6580,6 +6067,13 @@ internal class PriceTest { .build() ) .cadence(Price.ScalableMatrixWithUnitPricing.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() @@ -6694,6 +6188,13 @@ internal class PriceTest { .build() ) .cadence(Price.ScalableMatrixWithTieredPricing.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() @@ -6794,9 +6295,6 @@ internal class PriceTest { assertThat(price.package_()).isNull() assertThat(price.matrix()).isNull() assertThat(price.tiered()).isNull() - assertThat(price.tieredBps()).isNull() - assertThat(price.bps()).isNull() - assertThat(price.bulkBps()).isNull() assertThat(price.bulk()).isNull() assertThat(price.thresholdTotalAmount()).isNull() assertThat(price.tieredPackage()).isNull() @@ -6820,6 +6318,7 @@ internal class PriceTest { .isEqualTo(scalableMatrixWithTieredPricing) assertThat(price.cumulativeGroupedBulk()).isNull() assertThat(price.groupedWithMinMaxThresholds()).isNull() + assertThat(price.minimum()).isNull() } @Test @@ -6837,6 +6336,13 @@ internal class PriceTest { .build() ) .cadence(Price.ScalableMatrixWithTieredPricing.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() @@ -6951,6 +6457,13 @@ internal class PriceTest { .build() ) .cadence(Price.CumulativeGroupedBulk.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() @@ -7050,9 +6563,6 @@ internal class PriceTest { assertThat(price.package_()).isNull() assertThat(price.matrix()).isNull() assertThat(price.tiered()).isNull() - assertThat(price.tieredBps()).isNull() - assertThat(price.bps()).isNull() - assertThat(price.bulkBps()).isNull() assertThat(price.bulk()).isNull() assertThat(price.thresholdTotalAmount()).isNull() assertThat(price.tieredPackage()).isNull() @@ -7075,6 +6585,7 @@ internal class PriceTest { assertThat(price.scalableMatrixWithTieredPricing()).isNull() assertThat(price.cumulativeGroupedBulk()).isEqualTo(cumulativeGroupedBulk) assertThat(price.groupedWithMinMaxThresholds()).isNull() + assertThat(price.minimum()).isNull() } @Test @@ -7092,6 +6603,13 @@ internal class PriceTest { .build() ) .cadence(Price.CumulativeGroupedBulk.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() @@ -7205,6 +6723,13 @@ internal class PriceTest { .build() ) .cadence(Price.GroupedWithMinMaxThresholds.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() @@ -7304,9 +6829,6 @@ internal class PriceTest { assertThat(price.package_()).isNull() assertThat(price.matrix()).isNull() assertThat(price.tiered()).isNull() - assertThat(price.tieredBps()).isNull() - assertThat(price.bps()).isNull() - assertThat(price.bulkBps()).isNull() assertThat(price.bulk()).isNull() assertThat(price.thresholdTotalAmount()).isNull() assertThat(price.tieredPackage()).isNull() @@ -7329,6 +6851,7 @@ internal class PriceTest { assertThat(price.scalableMatrixWithTieredPricing()).isNull() assertThat(price.cumulativeGroupedBulk()).isNull() assertThat(price.groupedWithMinMaxThresholds()).isEqualTo(groupedWithMinMaxThresholds) + assertThat(price.minimum()).isNull() } @Test @@ -7346,6 +6869,13 @@ internal class PriceTest { .build() ) .cadence(Price.GroupedWithMinMaxThresholds.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() @@ -7447,6 +6977,274 @@ internal class PriceTest { assertThat(roundtrippedPrice).isEqualTo(price) } + @Test + fun ofMinimum() { + val minimum = + Price.Minimum.builder() + .id("id") + .billableMetric(BillableMetricTiny.builder().id("id").build()) + .billingCycleConfiguration( + BillingCycleConfiguration.builder() + .duration(0L) + .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) + .build() + ) + .cadence(Price.Minimum.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) + .conversionRate(0.0) + .unitConversionRateConfig( + ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() + ) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditAllocation( + Allocation.builder() + .allowsRollover(true) + .currency("currency") + .customExpiration( + CustomExpiration.builder() + .duration(0L) + .durationUnit(CustomExpiration.DurationUnit.DAY) + .build() + ) + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .addFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + BillingCycleConfiguration.builder() + .duration(0L) + .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) + .build() + ) + .item(ItemSlim.builder().id("id").name("name").build()) + .maximum( + Maximum.builder() + .addAppliesToPriceId("string") + .addFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.Minimum.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Minimum.builder() + .addAppliesToPriceId("string") + .addFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .minimumConfig( + Price.Minimum.MinimumConfig.builder() + .minimumAmount("minimum_amount") + .prorated(true) + .build() + ) + .name("name") + .planPhaseOrder(0L) + .priceType(Price.Minimum.PriceType.USAGE_PRICE) + .replacesPriceId("replaces_price_id") + .dimensionalPriceConfiguration( + DimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .build() + ) + .build() + + val price = Price.ofMinimum(minimum) + + assertThat(price.unit()).isNull() + assertThat(price.package_()).isNull() + assertThat(price.matrix()).isNull() + assertThat(price.tiered()).isNull() + assertThat(price.bulk()).isNull() + assertThat(price.thresholdTotalAmount()).isNull() + assertThat(price.tieredPackage()).isNull() + assertThat(price.groupedTiered()).isNull() + assertThat(price.tieredWithMinimum()).isNull() + assertThat(price.tieredPackageWithMinimum()).isNull() + assertThat(price.packageWithAllocation()).isNull() + assertThat(price.unitWithPercent()).isNull() + assertThat(price.matrixWithAllocation()).isNull() + assertThat(price.tieredWithProration()).isNull() + assertThat(price.unitWithProration()).isNull() + assertThat(price.groupedAllocation()).isNull() + assertThat(price.groupedWithProratedMinimum()).isNull() + assertThat(price.groupedWithMeteredMinimum()).isNull() + assertThat(price.matrixWithDisplayName()).isNull() + assertThat(price.bulkWithProration()).isNull() + assertThat(price.groupedTieredPackage()).isNull() + assertThat(price.maxGroupTieredPackage()).isNull() + assertThat(price.scalableMatrixWithUnitPricing()).isNull() + assertThat(price.scalableMatrixWithTieredPricing()).isNull() + assertThat(price.cumulativeGroupedBulk()).isNull() + assertThat(price.groupedWithMinMaxThresholds()).isNull() + assertThat(price.minimum()).isEqualTo(minimum) + } + + @Test + fun ofMinimumRoundtrip() { + val jsonMapper = jsonMapper() + val price = + Price.ofMinimum( + Price.Minimum.builder() + .id("id") + .billableMetric(BillableMetricTiny.builder().id("id").build()) + .billingCycleConfiguration( + BillingCycleConfiguration.builder() + .duration(0L) + .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) + .build() + ) + .cadence(Price.Minimum.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) + .conversionRate(0.0) + .unitConversionRateConfig( + ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() + ) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditAllocation( + Allocation.builder() + .allowsRollover(true) + .currency("currency") + .customExpiration( + CustomExpiration.builder() + .duration(0L) + .durationUnit(CustomExpiration.DurationUnit.DAY) + .build() + ) + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .addFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + BillingCycleConfiguration.builder() + .duration(0L) + .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) + .build() + ) + .item(ItemSlim.builder().id("id").name("name").build()) + .maximum( + Maximum.builder() + .addAppliesToPriceId("string") + .addFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.Minimum.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Minimum.builder() + .addAppliesToPriceId("string") + .addFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .minimumConfig( + Price.Minimum.MinimumConfig.builder() + .minimumAmount("minimum_amount") + .prorated(true) + .build() + ) + .name("name") + .planPhaseOrder(0L) + .priceType(Price.Minimum.PriceType.USAGE_PRICE) + .replacesPriceId("replaces_price_id") + .dimensionalPriceConfiguration( + DimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .build() + ) + .build() + ) + + val roundtrippedPrice = + jsonMapper.readValue(jsonMapper.writeValueAsString(price), jacksonTypeRef()) + + assertThat(roundtrippedPrice).isEqualTo(price) + } + enum class IncompatibleJsonShapeTestCase(val value: JsonValue) { BOOLEAN(JsonValue.from(false)), STRING(JsonValue.from("invalid")), diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeApplyResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeApplyResponseTest.kt index 34dde21f7..195269460 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeApplyResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeApplyResponseTest.kt @@ -73,6 +73,7 @@ internal class SubscriptionChangeApplyResponseTest { .id("id") .addAdditionalEmail("string") .autoCollection(true) + .autoIssuance(true) .balance("balance") .billingAddress( Address.builder() @@ -389,6 +390,13 @@ internal class SubscriptionChangeApplyResponseTest { .build() ) .cadence(Price.Unit.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder() @@ -552,6 +560,13 @@ internal class SubscriptionChangeApplyResponseTest { .build() ) .cadence(Price.Unit.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder() @@ -1033,6 +1048,19 @@ internal class SubscriptionChangeApplyResponseTest { .build() ) .cadence(Price.Unit.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field( + TransformPriceFilter.Field + .PRICE_ID + ) + .operator( + TransformPriceFilter.Operator + .INCLUDES + ) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder() @@ -1270,6 +1298,9 @@ internal class SubscriptionChangeApplyResponseTest { Invoice.PaymentAttempt.PaymentProvider.STRIPE ) .paymentProviderId("payment_provider_id") + .receiptPdf( + "https://assets.withorb.com/receipt/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" + ) .succeeded(true) .build() ) @@ -1658,6 +1689,19 @@ internal class SubscriptionChangeApplyResponseTest { .build() ) .cadence(Price.Unit.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field( + TransformPriceFilter.Field + .PRICE_ID + ) + .operator( + TransformPriceFilter.Operator + .INCLUDES + ) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder() @@ -1895,6 +1939,9 @@ internal class SubscriptionChangeApplyResponseTest { Invoice.PaymentAttempt.PaymentProvider.STRIPE ) .paymentProviderId("payment_provider_id") + .receiptPdf( + "https://assets.withorb.com/receipt/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" + ) .succeeded(true) .build() ) @@ -1993,6 +2040,7 @@ internal class SubscriptionChangeApplyResponseTest { .id("id") .addAdditionalEmail("string") .autoCollection(true) + .autoIssuance(true) .balance("balance") .billingAddress( Address.builder() @@ -2307,6 +2355,13 @@ internal class SubscriptionChangeApplyResponseTest { .build() ) .cadence(Price.Unit.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder() @@ -2459,6 +2514,13 @@ internal class SubscriptionChangeApplyResponseTest { .build() ) .cadence(Price.Unit.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder() @@ -2905,6 +2967,18 @@ internal class SubscriptionChangeApplyResponseTest { .build() ) .cadence(Price.Unit.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field( + TransformPriceFilter.Field.PRICE_ID + ) + .operator( + TransformPriceFilter.Operator + .INCLUDES + ) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder() @@ -3130,6 +3204,9 @@ internal class SubscriptionChangeApplyResponseTest { Invoice.PaymentAttempt.PaymentProvider.STRIPE ) .paymentProviderId("payment_provider_id") + .receiptPdf( + "https://assets.withorb.com/receipt/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" + ) .succeeded(true) .build() ) @@ -3488,6 +3565,18 @@ internal class SubscriptionChangeApplyResponseTest { .build() ) .cadence(Price.Unit.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field( + TransformPriceFilter.Field.PRICE_ID + ) + .operator( + TransformPriceFilter.Operator + .INCLUDES + ) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder() @@ -3713,6 +3802,9 @@ internal class SubscriptionChangeApplyResponseTest { Invoice.PaymentAttempt.PaymentProvider.STRIPE ) .paymentProviderId("payment_provider_id") + .receiptPdf( + "https://assets.withorb.com/receipt/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" + ) .succeeded(true) .build() ) @@ -3821,6 +3913,7 @@ internal class SubscriptionChangeApplyResponseTest { .id("id") .addAdditionalEmail("string") .autoCollection(true) + .autoIssuance(true) .balance("balance") .billingAddress( Address.builder() @@ -4137,6 +4230,13 @@ internal class SubscriptionChangeApplyResponseTest { .build() ) .cadence(Price.Unit.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder() @@ -4300,6 +4400,13 @@ internal class SubscriptionChangeApplyResponseTest { .build() ) .cadence(Price.Unit.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder() @@ -4781,6 +4888,19 @@ internal class SubscriptionChangeApplyResponseTest { .build() ) .cadence(Price.Unit.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field( + TransformPriceFilter.Field + .PRICE_ID + ) + .operator( + TransformPriceFilter.Operator + .INCLUDES + ) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder() @@ -5018,6 +5138,9 @@ internal class SubscriptionChangeApplyResponseTest { Invoice.PaymentAttempt.PaymentProvider.STRIPE ) .paymentProviderId("payment_provider_id") + .receiptPdf( + "https://assets.withorb.com/receipt/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" + ) .succeeded(true) .build() ) @@ -5406,6 +5529,19 @@ internal class SubscriptionChangeApplyResponseTest { .build() ) .cadence(Price.Unit.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field( + TransformPriceFilter.Field + .PRICE_ID + ) + .operator( + TransformPriceFilter.Operator + .INCLUDES + ) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder() @@ -5643,6 +5779,9 @@ internal class SubscriptionChangeApplyResponseTest { Invoice.PaymentAttempt.PaymentProvider.STRIPE ) .paymentProviderId("payment_provider_id") + .receiptPdf( + "https://assets.withorb.com/receipt/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" + ) .succeeded(true) .build() ) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeCancelResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeCancelResponseTest.kt index 683076fa5..de8503ace 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeCancelResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeCancelResponseTest.kt @@ -73,6 +73,7 @@ internal class SubscriptionChangeCancelResponseTest { .id("id") .addAdditionalEmail("string") .autoCollection(true) + .autoIssuance(true) .balance("balance") .billingAddress( Address.builder() @@ -389,6 +390,13 @@ internal class SubscriptionChangeCancelResponseTest { .build() ) .cadence(Price.Unit.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder() @@ -552,6 +560,13 @@ internal class SubscriptionChangeCancelResponseTest { .build() ) .cadence(Price.Unit.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder() @@ -1033,6 +1048,19 @@ internal class SubscriptionChangeCancelResponseTest { .build() ) .cadence(Price.Unit.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field( + TransformPriceFilter.Field + .PRICE_ID + ) + .operator( + TransformPriceFilter.Operator + .INCLUDES + ) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder() @@ -1270,6 +1298,9 @@ internal class SubscriptionChangeCancelResponseTest { Invoice.PaymentAttempt.PaymentProvider.STRIPE ) .paymentProviderId("payment_provider_id") + .receiptPdf( + "https://assets.withorb.com/receipt/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" + ) .succeeded(true) .build() ) @@ -1658,6 +1689,19 @@ internal class SubscriptionChangeCancelResponseTest { .build() ) .cadence(Price.Unit.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field( + TransformPriceFilter.Field + .PRICE_ID + ) + .operator( + TransformPriceFilter.Operator + .INCLUDES + ) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder() @@ -1895,6 +1939,9 @@ internal class SubscriptionChangeCancelResponseTest { Invoice.PaymentAttempt.PaymentProvider.STRIPE ) .paymentProviderId("payment_provider_id") + .receiptPdf( + "https://assets.withorb.com/receipt/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" + ) .succeeded(true) .build() ) @@ -1993,6 +2040,7 @@ internal class SubscriptionChangeCancelResponseTest { .id("id") .addAdditionalEmail("string") .autoCollection(true) + .autoIssuance(true) .balance("balance") .billingAddress( Address.builder() @@ -2307,6 +2355,13 @@ internal class SubscriptionChangeCancelResponseTest { .build() ) .cadence(Price.Unit.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder() @@ -2459,6 +2514,13 @@ internal class SubscriptionChangeCancelResponseTest { .build() ) .cadence(Price.Unit.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder() @@ -2905,6 +2967,18 @@ internal class SubscriptionChangeCancelResponseTest { .build() ) .cadence(Price.Unit.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field( + TransformPriceFilter.Field.PRICE_ID + ) + .operator( + TransformPriceFilter.Operator + .INCLUDES + ) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder() @@ -3130,6 +3204,9 @@ internal class SubscriptionChangeCancelResponseTest { Invoice.PaymentAttempt.PaymentProvider.STRIPE ) .paymentProviderId("payment_provider_id") + .receiptPdf( + "https://assets.withorb.com/receipt/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" + ) .succeeded(true) .build() ) @@ -3488,6 +3565,18 @@ internal class SubscriptionChangeCancelResponseTest { .build() ) .cadence(Price.Unit.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field( + TransformPriceFilter.Field.PRICE_ID + ) + .operator( + TransformPriceFilter.Operator + .INCLUDES + ) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder() @@ -3713,6 +3802,9 @@ internal class SubscriptionChangeCancelResponseTest { Invoice.PaymentAttempt.PaymentProvider.STRIPE ) .paymentProviderId("payment_provider_id") + .receiptPdf( + "https://assets.withorb.com/receipt/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" + ) .succeeded(true) .build() ) @@ -3821,6 +3913,7 @@ internal class SubscriptionChangeCancelResponseTest { .id("id") .addAdditionalEmail("string") .autoCollection(true) + .autoIssuance(true) .balance("balance") .billingAddress( Address.builder() @@ -4137,6 +4230,13 @@ internal class SubscriptionChangeCancelResponseTest { .build() ) .cadence(Price.Unit.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder() @@ -4300,6 +4400,13 @@ internal class SubscriptionChangeCancelResponseTest { .build() ) .cadence(Price.Unit.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder() @@ -4781,6 +4888,19 @@ internal class SubscriptionChangeCancelResponseTest { .build() ) .cadence(Price.Unit.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field( + TransformPriceFilter.Field + .PRICE_ID + ) + .operator( + TransformPriceFilter.Operator + .INCLUDES + ) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder() @@ -5018,6 +5138,9 @@ internal class SubscriptionChangeCancelResponseTest { Invoice.PaymentAttempt.PaymentProvider.STRIPE ) .paymentProviderId("payment_provider_id") + .receiptPdf( + "https://assets.withorb.com/receipt/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" + ) .succeeded(true) .build() ) @@ -5406,6 +5529,19 @@ internal class SubscriptionChangeCancelResponseTest { .build() ) .cadence(Price.Unit.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field( + TransformPriceFilter.Field + .PRICE_ID + ) + .operator( + TransformPriceFilter.Operator + .INCLUDES + ) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder() @@ -5643,6 +5779,9 @@ internal class SubscriptionChangeCancelResponseTest { Invoice.PaymentAttempt.PaymentProvider.STRIPE ) .paymentProviderId("payment_provider_id") + .receiptPdf( + "https://assets.withorb.com/receipt/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" + ) .succeeded(true) .build() ) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeRetrieveResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeRetrieveResponseTest.kt index 1a4cb4614..7f8cf2c2c 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeRetrieveResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeRetrieveResponseTest.kt @@ -73,6 +73,7 @@ internal class SubscriptionChangeRetrieveResponseTest { .id("id") .addAdditionalEmail("string") .autoCollection(true) + .autoIssuance(true) .balance("balance") .billingAddress( Address.builder() @@ -389,6 +390,13 @@ internal class SubscriptionChangeRetrieveResponseTest { .build() ) .cadence(Price.Unit.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder() @@ -552,6 +560,13 @@ internal class SubscriptionChangeRetrieveResponseTest { .build() ) .cadence(Price.Unit.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder() @@ -1033,6 +1048,19 @@ internal class SubscriptionChangeRetrieveResponseTest { .build() ) .cadence(Price.Unit.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field( + TransformPriceFilter.Field + .PRICE_ID + ) + .operator( + TransformPriceFilter.Operator + .INCLUDES + ) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder() @@ -1270,6 +1298,9 @@ internal class SubscriptionChangeRetrieveResponseTest { Invoice.PaymentAttempt.PaymentProvider.STRIPE ) .paymentProviderId("payment_provider_id") + .receiptPdf( + "https://assets.withorb.com/receipt/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" + ) .succeeded(true) .build() ) @@ -1658,6 +1689,19 @@ internal class SubscriptionChangeRetrieveResponseTest { .build() ) .cadence(Price.Unit.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field( + TransformPriceFilter.Field + .PRICE_ID + ) + .operator( + TransformPriceFilter.Operator + .INCLUDES + ) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder() @@ -1895,6 +1939,9 @@ internal class SubscriptionChangeRetrieveResponseTest { Invoice.PaymentAttempt.PaymentProvider.STRIPE ) .paymentProviderId("payment_provider_id") + .receiptPdf( + "https://assets.withorb.com/receipt/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" + ) .succeeded(true) .build() ) @@ -1993,6 +2040,7 @@ internal class SubscriptionChangeRetrieveResponseTest { .id("id") .addAdditionalEmail("string") .autoCollection(true) + .autoIssuance(true) .balance("balance") .billingAddress( Address.builder() @@ -2307,6 +2355,13 @@ internal class SubscriptionChangeRetrieveResponseTest { .build() ) .cadence(Price.Unit.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder() @@ -2459,6 +2514,13 @@ internal class SubscriptionChangeRetrieveResponseTest { .build() ) .cadence(Price.Unit.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder() @@ -2905,6 +2967,18 @@ internal class SubscriptionChangeRetrieveResponseTest { .build() ) .cadence(Price.Unit.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field( + TransformPriceFilter.Field.PRICE_ID + ) + .operator( + TransformPriceFilter.Operator + .INCLUDES + ) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder() @@ -3130,6 +3204,9 @@ internal class SubscriptionChangeRetrieveResponseTest { Invoice.PaymentAttempt.PaymentProvider.STRIPE ) .paymentProviderId("payment_provider_id") + .receiptPdf( + "https://assets.withorb.com/receipt/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" + ) .succeeded(true) .build() ) @@ -3488,6 +3565,18 @@ internal class SubscriptionChangeRetrieveResponseTest { .build() ) .cadence(Price.Unit.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field( + TransformPriceFilter.Field.PRICE_ID + ) + .operator( + TransformPriceFilter.Operator + .INCLUDES + ) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder() @@ -3713,6 +3802,9 @@ internal class SubscriptionChangeRetrieveResponseTest { Invoice.PaymentAttempt.PaymentProvider.STRIPE ) .paymentProviderId("payment_provider_id") + .receiptPdf( + "https://assets.withorb.com/receipt/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" + ) .succeeded(true) .build() ) @@ -3821,6 +3913,7 @@ internal class SubscriptionChangeRetrieveResponseTest { .id("id") .addAdditionalEmail("string") .autoCollection(true) + .autoIssuance(true) .balance("balance") .billingAddress( Address.builder() @@ -4137,6 +4230,13 @@ internal class SubscriptionChangeRetrieveResponseTest { .build() ) .cadence(Price.Unit.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder() @@ -4300,6 +4400,13 @@ internal class SubscriptionChangeRetrieveResponseTest { .build() ) .cadence(Price.Unit.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder() @@ -4781,6 +4888,19 @@ internal class SubscriptionChangeRetrieveResponseTest { .build() ) .cadence(Price.Unit.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field( + TransformPriceFilter.Field + .PRICE_ID + ) + .operator( + TransformPriceFilter.Operator + .INCLUDES + ) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder() @@ -5018,6 +5138,9 @@ internal class SubscriptionChangeRetrieveResponseTest { Invoice.PaymentAttempt.PaymentProvider.STRIPE ) .paymentProviderId("payment_provider_id") + .receiptPdf( + "https://assets.withorb.com/receipt/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" + ) .succeeded(true) .build() ) @@ -5406,6 +5529,19 @@ internal class SubscriptionChangeRetrieveResponseTest { .build() ) .cadence(Price.Unit.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field( + TransformPriceFilter.Field + .PRICE_ID + ) + .operator( + TransformPriceFilter.Operator + .INCLUDES + ) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder() @@ -5643,6 +5779,9 @@ internal class SubscriptionChangeRetrieveResponseTest { Invoice.PaymentAttempt.PaymentProvider.STRIPE ) .paymentProviderId("payment_provider_id") + .receiptPdf( + "https://assets.withorb.com/receipt/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" + ) .succeeded(true) .build() ) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionFetchCostsResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionFetchCostsResponseTest.kt index 09f8ae0d5..3b49cad21 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionFetchCostsResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionFetchCostsResponseTest.kt @@ -34,6 +34,13 @@ internal class SubscriptionFetchCostsResponseTest { .build() ) .cadence(Price.Unit.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder() @@ -176,6 +183,13 @@ internal class SubscriptionFetchCostsResponseTest { .build() ) .cadence(Price.Unit.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder() @@ -317,6 +331,13 @@ internal class SubscriptionFetchCostsResponseTest { .build() ) .cadence(Price.Unit.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder() diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsParamsTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsParamsTest.kt index f58e70e2b..4e49452d1 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsParamsTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsParamsTest.kt @@ -93,6 +93,7 @@ internal class SubscriptionPriceIntervalsParamsTest { ) .addAddAdjustment( SubscriptionPriceIntervalsParams.AddAdjustment.builder() + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .adjustment( NewPercentageDiscount.builder() .adjustmentType( @@ -116,7 +117,7 @@ internal class SubscriptionPriceIntervalsParamsTest { .priceType(NewPercentageDiscount.PriceType.USAGE) .build() ) - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .adjustmentId("h74gfhdjvn7ujokd") .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() ) @@ -245,6 +246,7 @@ internal class SubscriptionPriceIntervalsParamsTest { ) .addAddAdjustment( SubscriptionPriceIntervalsParams.AddAdjustment.builder() + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .adjustment( NewPercentageDiscount.builder() .adjustmentType( @@ -268,7 +270,7 @@ internal class SubscriptionPriceIntervalsParamsTest { .priceType(NewPercentageDiscount.PriceType.USAGE) .build() ) - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .adjustmentId("h74gfhdjvn7ujokd") .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() ) @@ -383,6 +385,7 @@ internal class SubscriptionPriceIntervalsParamsTest { assertThat(body.addAdjustments()) .containsExactly( SubscriptionPriceIntervalsParams.AddAdjustment.builder() + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .adjustment( NewPercentageDiscount.builder() .adjustmentType( @@ -406,7 +409,7 @@ internal class SubscriptionPriceIntervalsParamsTest { .priceType(NewPercentageDiscount.PriceType.USAGE) .build() ) - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .adjustmentId("h74gfhdjvn7ujokd") .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() ) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionTest.kt index 5159a50e7..353428029 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionTest.kt @@ -59,6 +59,7 @@ internal class SubscriptionTest { .id("id") .addAdditionalEmail("string") .autoCollection(true) + .autoIssuance(true) .balance("balance") .billingAddress( Address.builder() @@ -359,6 +360,13 @@ internal class SubscriptionTest { .build() ) .cadence(Price.Unit.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder() @@ -497,6 +505,13 @@ internal class SubscriptionTest { .build() ) .cadence(Price.Unit.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder() @@ -656,6 +671,7 @@ internal class SubscriptionTest { .id("id") .addAdditionalEmail("string") .autoCollection(true) + .autoIssuance(true) .balance("balance") .billingAddress( Address.builder() @@ -965,6 +981,13 @@ internal class SubscriptionTest { .build() ) .cadence(Price.Unit.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() @@ -1098,6 +1121,13 @@ internal class SubscriptionTest { .build() ) .cadence(Price.Unit.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() @@ -1259,6 +1289,7 @@ internal class SubscriptionTest { .id("id") .addAdditionalEmail("string") .autoCollection(true) + .autoIssuance(true) .balance("balance") .billingAddress( Address.builder() @@ -1559,6 +1590,13 @@ internal class SubscriptionTest { .build() ) .cadence(Price.Unit.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder() @@ -1697,6 +1735,13 @@ internal class SubscriptionTest { .build() ) .cadence(Price.Unit.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder() diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionsTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionsTest.kt index 6e12850fd..55b855b26 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionsTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionsTest.kt @@ -70,6 +70,7 @@ internal class SubscriptionsTest { .id("id") .addAdditionalEmail("string") .autoCollection(true) + .autoIssuance(true) .balance("balance") .billingAddress( Address.builder() @@ -386,6 +387,13 @@ internal class SubscriptionsTest { .build() ) .cadence(Price.Unit.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder() @@ -549,6 +557,13 @@ internal class SubscriptionsTest { .build() ) .cadence(Price.Unit.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder() @@ -732,6 +747,7 @@ internal class SubscriptionsTest { .id("id") .addAdditionalEmail("string") .autoCollection(true) + .autoIssuance(true) .balance("balance") .billingAddress( Address.builder() @@ -1046,6 +1062,13 @@ internal class SubscriptionsTest { .build() ) .cadence(Price.Unit.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder() @@ -1198,6 +1221,13 @@ internal class SubscriptionsTest { .build() ) .cadence(Price.Unit.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder() @@ -1385,6 +1415,7 @@ internal class SubscriptionsTest { .id("id") .addAdditionalEmail("string") .autoCollection(true) + .autoIssuance(true) .balance("balance") .billingAddress( Address.builder() @@ -1701,6 +1732,13 @@ internal class SubscriptionsTest { .build() ) .cadence(Price.Unit.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder() @@ -1864,6 +1902,13 @@ internal class SubscriptionsTest { .build() ) .cadence(Price.Unit.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder() diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/TieredBpsConfigTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/TieredBpsConfigTest.kt deleted file mode 100644 index 8b7c363ba..000000000 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/TieredBpsConfigTest.kt +++ /dev/null @@ -1,60 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.withorb.api.models - -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.withorb.api.core.jsonMapper -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class TieredBpsConfigTest { - - @Test - fun create() { - val tieredBpsConfig = - TieredBpsConfig.builder() - .addTier( - BpsTier.builder() - .bps(0.0) - .minimumAmount("minimum_amount") - .maximumAmount("maximum_amount") - .perUnitMaximum("per_unit_maximum") - .build() - ) - .build() - - assertThat(tieredBpsConfig.tiers()) - .containsExactly( - BpsTier.builder() - .bps(0.0) - .minimumAmount("minimum_amount") - .maximumAmount("maximum_amount") - .perUnitMaximum("per_unit_maximum") - .build() - ) - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val tieredBpsConfig = - TieredBpsConfig.builder() - .addTier( - BpsTier.builder() - .bps(0.0) - .minimumAmount("minimum_amount") - .maximumAmount("maximum_amount") - .perUnitMaximum("per_unit_maximum") - .build() - ) - .build() - - val roundtrippedTieredBpsConfig = - jsonMapper.readValue( - jsonMapper.writeValueAsString(tieredBpsConfig), - jacksonTypeRef(), - ) - - assertThat(roundtrippedTieredBpsConfig).isEqualTo(tieredBpsConfig) - } -} diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/ErrorHandlingTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/ErrorHandlingTest.kt index 591b40a6a..eb972aae9 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/ErrorHandlingTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/ErrorHandlingTest.kt @@ -94,6 +94,7 @@ internal class ErrorHandlingTest { ) .addAdditionalEmail("dev@stainless.com") .autoCollection(true) + .autoIssuance(true) .billingAddress( AddressInput.builder() .city("city") @@ -186,6 +187,7 @@ internal class ErrorHandlingTest { ) .addAdditionalEmail("dev@stainless.com") .autoCollection(true) + .autoIssuance(true) .billingAddress( AddressInput.builder() .city("city") @@ -278,6 +280,7 @@ internal class ErrorHandlingTest { ) .addAdditionalEmail("dev@stainless.com") .autoCollection(true) + .autoIssuance(true) .billingAddress( AddressInput.builder() .city("city") @@ -370,6 +373,7 @@ internal class ErrorHandlingTest { ) .addAdditionalEmail("dev@stainless.com") .autoCollection(true) + .autoIssuance(true) .billingAddress( AddressInput.builder() .city("city") @@ -462,6 +466,7 @@ internal class ErrorHandlingTest { ) .addAdditionalEmail("dev@stainless.com") .autoCollection(true) + .autoIssuance(true) .billingAddress( AddressInput.builder() .city("city") @@ -554,6 +559,7 @@ internal class ErrorHandlingTest { ) .addAdditionalEmail("dev@stainless.com") .autoCollection(true) + .autoIssuance(true) .billingAddress( AddressInput.builder() .city("city") @@ -646,6 +652,7 @@ internal class ErrorHandlingTest { ) .addAdditionalEmail("dev@stainless.com") .autoCollection(true) + .autoIssuance(true) .billingAddress( AddressInput.builder() .city("city") @@ -738,6 +745,7 @@ internal class ErrorHandlingTest { ) .addAdditionalEmail("dev@stainless.com") .autoCollection(true) + .autoIssuance(true) .billingAddress( AddressInput.builder() .city("city") @@ -830,6 +838,7 @@ internal class ErrorHandlingTest { ) .addAdditionalEmail("dev@stainless.com") .autoCollection(true) + .autoIssuance(true) .billingAddress( AddressInput.builder() .city("city") @@ -922,6 +931,7 @@ internal class ErrorHandlingTest { ) .addAdditionalEmail("dev@stainless.com") .autoCollection(true) + .autoIssuance(true) .billingAddress( AddressInput.builder() .city("city") @@ -1014,6 +1024,7 @@ internal class ErrorHandlingTest { ) .addAdditionalEmail("dev@stainless.com") .autoCollection(true) + .autoIssuance(true) .billingAddress( AddressInput.builder() .city("city") @@ -1106,6 +1117,7 @@ internal class ErrorHandlingTest { ) .addAdditionalEmail("dev@stainless.com") .autoCollection(true) + .autoIssuance(true) .billingAddress( AddressInput.builder() .city("city") @@ -1198,6 +1210,7 @@ internal class ErrorHandlingTest { ) .addAdditionalEmail("dev@stainless.com") .autoCollection(true) + .autoIssuance(true) .billingAddress( AddressInput.builder() .city("city") @@ -1290,6 +1303,7 @@ internal class ErrorHandlingTest { ) .addAdditionalEmail("dev@stainless.com") .autoCollection(true) + .autoIssuance(true) .billingAddress( AddressInput.builder() .city("city") @@ -1382,6 +1396,7 @@ internal class ErrorHandlingTest { ) .addAdditionalEmail("dev@stainless.com") .autoCollection(true) + .autoIssuance(true) .billingAddress( AddressInput.builder() .city("city") @@ -1474,6 +1489,7 @@ internal class ErrorHandlingTest { ) .addAdditionalEmail("dev@stainless.com") .autoCollection(true) + .autoIssuance(true) .billingAddress( AddressInput.builder() .city("city") @@ -1564,6 +1580,7 @@ internal class ErrorHandlingTest { ) .addAdditionalEmail("dev@stainless.com") .autoCollection(true) + .autoIssuance(true) .billingAddress( AddressInput.builder() .city("city") diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/ServiceParamsTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/ServiceParamsTest.kt index 834d04a53..a331a786f 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/ServiceParamsTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/ServiceParamsTest.kt @@ -64,6 +64,7 @@ internal class ServiceParamsTest { ) .addAdditionalEmail("dev@stainless.com") .autoCollection(true) + .autoIssuance(true) .billingAddress( AddressInput.builder() .city("city") diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/CustomerServiceAsyncTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/CustomerServiceAsyncTest.kt index 169d39172..bc800155a 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/CustomerServiceAsyncTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/CustomerServiceAsyncTest.kt @@ -48,6 +48,7 @@ internal class CustomerServiceAsyncTest { ) .addAdditionalEmail("dev@stainless.com") .autoCollection(true) + .autoIssuance(true) .billingAddress( AddressInput.builder() .city("city") @@ -134,6 +135,7 @@ internal class CustomerServiceAsyncTest { ) .addAdditionalEmail("string") .autoCollection(true) + .autoIssuance(true) .billingAddress( AddressInput.builder() .city("city") @@ -301,6 +303,7 @@ internal class CustomerServiceAsyncTest { ) .addAdditionalEmail("string") .autoCollection(true) + .autoIssuance(true) .billingAddress( AddressInput.builder() .city("city") diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/InvoiceServiceAsyncTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/InvoiceServiceAsyncTest.kt index 8d2d127ca..6a2b53fda 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/InvoiceServiceAsyncTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/InvoiceServiceAsyncTest.kt @@ -63,6 +63,7 @@ internal class InvoiceServiceAsyncTest { .reason("reason") .build() ) + .dueDate(LocalDate.parse("2023-09-22")) .externalCustomerId("external-customer-id") .memo("An optional memo for my invoice.") .metadata( @@ -91,11 +92,13 @@ internal class InvoiceServiceAsyncTest { invoiceServiceAsync.update( InvoiceUpdateParams.builder() .invoiceId("invoice_id") + .dueDate(LocalDate.parse("2023-09-22")) .metadata( InvoiceUpdateParams.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) + .netTerms(0L) .build() ) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/SubscriptionServiceAsyncTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/SubscriptionServiceAsyncTest.kt index 3cff00d60..4c51566b2 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/SubscriptionServiceAsyncTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/SubscriptionServiceAsyncTest.kt @@ -579,6 +579,7 @@ internal class SubscriptionServiceAsyncTest { ) .addAddAdjustment( SubscriptionPriceIntervalsParams.AddAdjustment.builder() + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .adjustment( NewPercentageDiscount.builder() .adjustmentType( @@ -602,7 +603,7 @@ internal class SubscriptionServiceAsyncTest { .priceType(NewPercentageDiscount.PriceType.USAGE) .build() ) - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .adjustmentId("h74gfhdjvn7ujokd") .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() ) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/customers/credits/LedgerServiceAsyncTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/customers/credits/LedgerServiceAsyncTest.kt index 54a1a58fe..cd65ac395 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/customers/credits/LedgerServiceAsyncTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/customers/credits/LedgerServiceAsyncTest.kt @@ -54,6 +54,7 @@ internal class LedgerServiceAsyncTest { .builder() .autoCollection(true) .netTerms(0L) + .customDueDate(LocalDate.parse("2019-12-27")) .invoiceDate(LocalDate.parse("2019-12-27")) .memo("memo") .requireSuccessfulPayment(true) @@ -100,6 +101,7 @@ internal class LedgerServiceAsyncTest { .builder() .autoCollection(true) .netTerms(0L) + .customDueDate(LocalDate.parse("2019-12-27")) .invoiceDate(LocalDate.parse("2019-12-27")) .memo("memo") .requireSuccessfulPayment(true) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/CustomerServiceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/CustomerServiceTest.kt index 3218fe7e9..8838c4b68 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/CustomerServiceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/CustomerServiceTest.kt @@ -48,6 +48,7 @@ internal class CustomerServiceTest { ) .addAdditionalEmail("dev@stainless.com") .autoCollection(true) + .autoIssuance(true) .billingAddress( AddressInput.builder() .city("city") @@ -134,6 +135,7 @@ internal class CustomerServiceTest { ) .addAdditionalEmail("string") .autoCollection(true) + .autoIssuance(true) .billingAddress( AddressInput.builder() .city("city") @@ -299,6 +301,7 @@ internal class CustomerServiceTest { ) .addAdditionalEmail("string") .autoCollection(true) + .autoIssuance(true) .billingAddress( AddressInput.builder() .city("city") diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/InvoiceServiceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/InvoiceServiceTest.kt index d6a5b2996..367768764 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/InvoiceServiceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/InvoiceServiceTest.kt @@ -63,6 +63,7 @@ internal class InvoiceServiceTest { .reason("reason") .build() ) + .dueDate(LocalDate.parse("2023-09-22")) .externalCustomerId("external-customer-id") .memo("An optional memo for my invoice.") .metadata( @@ -91,11 +92,13 @@ internal class InvoiceServiceTest { invoiceService.update( InvoiceUpdateParams.builder() .invoiceId("invoice_id") + .dueDate(LocalDate.parse("2023-09-22")) .metadata( InvoiceUpdateParams.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) + .netTerms(0L) .build() ) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/SubscriptionServiceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/SubscriptionServiceTest.kt index 3c88f501b..2d6d063a8 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/SubscriptionServiceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/SubscriptionServiceTest.kt @@ -579,6 +579,7 @@ internal class SubscriptionServiceTest { ) .addAddAdjustment( SubscriptionPriceIntervalsParams.AddAdjustment.builder() + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .adjustment( NewPercentageDiscount.builder() .adjustmentType( @@ -602,7 +603,7 @@ internal class SubscriptionServiceTest { .priceType(NewPercentageDiscount.PriceType.USAGE) .build() ) - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .adjustmentId("h74gfhdjvn7ujokd") .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() ) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/customers/credits/LedgerServiceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/customers/credits/LedgerServiceTest.kt index c484ee91e..f57c343cc 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/customers/credits/LedgerServiceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/customers/credits/LedgerServiceTest.kt @@ -54,6 +54,7 @@ internal class LedgerServiceTest { .builder() .autoCollection(true) .netTerms(0L) + .customDueDate(LocalDate.parse("2019-12-27")) .invoiceDate(LocalDate.parse("2019-12-27")) .memo("memo") .requireSuccessfulPayment(true) @@ -100,6 +101,7 @@ internal class LedgerServiceTest { .builder() .autoCollection(true) .netTerms(0L) + .customDueDate(LocalDate.parse("2019-12-27")) .invoiceDate(LocalDate.parse("2019-12-27")) .memo("memo") .requireSuccessfulPayment(true) From efc789114af507dd96e591c18696a07dffad9af6 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 3 Sep 2025 15:24:19 +0000 Subject: [PATCH 10/68] fix(ci): use java-version 21 for publish step --- .github/workflows/publish-sonatype.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish-sonatype.yml b/.github/workflows/publish-sonatype.yml index 25e2ac851..9b8da594d 100644 --- a/.github/workflows/publish-sonatype.yml +++ b/.github/workflows/publish-sonatype.yml @@ -22,7 +22,7 @@ jobs: distribution: temurin java-version: | 8 - 17 + 21 cache: gradle - name: Set up Gradle From c89ade2708c48dfd327c4260ab1afe01e051e8c9 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 3 Sep 2025 20:08:04 +0000 Subject: [PATCH 11/68] feat: extract minimum composite to type --- .stats.yml | 2 +- .../api/models/BetaCreatePlanVersionParams.kt | 7346 +++++---------- ...taExternalPlanIdCreatePlanVersionParams.kt | 7346 +++++---------- .../NewFloatingMinimumCompositePrice.kt | 1545 +++ .../models/NewPlanMinimumCompositePrice.kt | 1587 ++++ .../NewSubscriptionMinimumCompositePrice.kt | 1593 ++++ .../withorb/api/models/PlanCreateParams.kt | 1590 +--- .../withorb/api/models/PriceCreateParams.kt | 1504 +-- .../api/models/PriceEvaluateMultipleParams.kt | 1539 +-- .../PriceEvaluatePreviewEventsParams.kt | 1539 +-- .../api/models/SubscriptionCreateParams.kt | 8256 +++++------------ .../SubscriptionPriceIntervalsParams.kt | 1539 +-- .../SubscriptionSchedulePlanChangeParams.kt | 7946 +++++----------- .../NewFloatingMinimumCompositePriceTest.kt | 186 + .../NewPlanMinimumCompositePriceTest.kt | 186 + ...ewSubscriptionMinimumCompositePriceTest.kt | 189 + 16 files changed, 14565 insertions(+), 29328 deletions(-) create mode 100644 orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingMinimumCompositePrice.kt create mode 100644 orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanMinimumCompositePrice.kt create mode 100644 orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionMinimumCompositePrice.kt create mode 100644 orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingMinimumCompositePriceTest.kt create mode 100644 orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanMinimumCompositePriceTest.kt create mode 100644 orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionMinimumCompositePriceTest.kt diff --git a/.stats.yml b/.stats.yml index a2f42b369..5c39bf210 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 118 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-6b2550b95f82872b3825619c109352352b9c92281c8b2470fce158e971142881.yml openapi_spec_hash: 379df18de1af6a9d0b50d3653aab4d44 -config_hash: be9350529b910ec14bff0a30cd74a185 +config_hash: 1f73a949b649ecfe6ec68ba1bb459dc2 diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BetaCreatePlanVersionParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BetaCreatePlanVersionParams.kt index 8ec318fab..9f2f11ae2 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BetaCreatePlanVersionParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BetaCreatePlanVersionParams.kt @@ -1966,7 +1966,7 @@ private constructor( price(Price.ofGroupedTiered(groupedTiered)) /** Alias for calling [price] with `Price.ofMinimum(minimum)`. */ - fun price(minimum: Price.Minimum) = price(Price.ofMinimum(minimum)) + fun price(minimum: NewPlanMinimumCompositePrice) = price(Price.ofMinimum(minimum)) fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -2067,7 +2067,7 @@ private constructor( private val tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice? = null, private val matrixWithAllocation: NewPlanMatrixWithAllocationPrice? = null, private val groupedTiered: NewPlanGroupedTieredPrice? = null, - private val minimum: Minimum? = null, + private val minimum: NewPlanMinimumCompositePrice? = null, private val _json: JsonValue? = null, ) { @@ -2129,7 +2129,7 @@ private constructor( fun groupedTiered(): NewPlanGroupedTieredPrice? = groupedTiered - fun minimum(): Minimum? = minimum + fun minimum(): NewPlanMinimumCompositePrice? = minimum fun isUnit(): Boolean = unit != null @@ -2259,7 +2259,7 @@ private constructor( fun asGroupedTiered(): NewPlanGroupedTieredPrice = groupedTiered.getOrThrow("groupedTiered") - fun asMinimum(): Minimum = minimum.getOrThrow("minimum") + fun asMinimum(): NewPlanMinimumCompositePrice = minimum.getOrThrow("minimum") fun _json(): JsonValue? = _json @@ -2463,7 +2463,7 @@ private constructor( groupedTiered.validate() } - override fun visitMinimum(minimum: Minimum) { + override fun visitMinimum(minimum: NewPlanMinimumCompositePrice) { minimum.validate() } } @@ -2582,7 +2582,8 @@ private constructor( override fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) = groupedTiered.validity() - override fun visitMinimum(minimum: Minimum) = minimum.validity() + override fun visitMinimum(minimum: NewPlanMinimumCompositePrice) = + minimum.validity() override fun unknown(json: JsonValue?) = 0 } @@ -2785,7 +2786,7 @@ private constructor( fun ofGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) = Price(groupedTiered = groupedTiered) - fun ofMinimum(minimum: Minimum) = Price(minimum = minimum) + fun ofMinimum(minimum: NewPlanMinimumCompositePrice) = Price(minimum = minimum) } /** @@ -2871,7 +2872,7 @@ private constructor( fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice): T - fun visitMinimum(minimum: Minimum): T + fun visitMinimum(minimum: NewPlanMinimumCompositePrice): T /** * Maps an unknown variant of [Price] to a value of type [T]. @@ -3082,9 +3083,11 @@ private constructor( ?: Price(_json = json) } "minimum" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(minimum = it, _json = json) - } ?: Price(_json = json) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(minimum = it, _json = json) } ?: Price(_json = json) } } @@ -4632,1621 +4635,1112 @@ private constructor( override fun toString() = "GroupedWithMinMaxThresholds{cadence=$cadence, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } + } - class Minimum - private constructor( - private val cadence: JsonField, - private val itemId: JsonField, - private val minimumConfig: JsonField, - private val modelType: JsonValue, - private val name: JsonField, - private val billableMetricId: JsonField, - private val billedInAdvance: JsonField, - private val billingCycleConfiguration: JsonField, - private val conversionRate: JsonField, - private val conversionRateConfig: JsonField, - private val currency: JsonField, - private val dimensionalPriceConfiguration: - JsonField, - private val externalPriceId: JsonField, - private val fixedPriceQuantity: JsonField, - private val invoiceGroupingKey: JsonField, - private val invoicingCycleConfiguration: JsonField, - private val metadata: JsonField, - private val referenceId: JsonField, - private val additionalProperties: MutableMap, - ) { + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - @JsonCreator - private constructor( - @JsonProperty("cadence") - @ExcludeMissing - cadence: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - itemId: JsonField = JsonMissing.of(), - @JsonProperty("minimum_config") - @ExcludeMissing - minimumConfig: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - modelType: JsonValue = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - name: JsonField = JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("conversion_rate_config") - @ExcludeMissing - conversionRateConfig: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - currency: JsonField = JsonMissing.of(), - @JsonProperty("dimensional_price_configuration") - @ExcludeMissing - dimensionalPriceConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - metadata: JsonField = JsonMissing.of(), - @JsonProperty("reference_id") - @ExcludeMissing - referenceId: JsonField = JsonMissing.of(), - ) : this( - cadence, - itemId, - minimumConfig, - modelType, - name, - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - conversionRateConfig, - currency, - dimensionalPriceConfiguration, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - mutableMapOf(), - ) + return other is AddPrice && + allocationPrice == other.allocationPrice && + planPhaseOrder == other.planPhaseOrder && + price == other.price && + additionalProperties == other.additionalProperties + } - /** - * The cadence to bill for this price on. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun cadence(): Cadence = cadence.getRequired("cadence") + private val hashCode: Int by lazy { + Objects.hash(allocationPrice, planPhaseOrder, price, additionalProperties) + } - /** - * The id of the item the price will be associated with. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun itemId(): String = itemId.getRequired("item_id") + override fun hashCode(): Int = hashCode - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun minimumConfig(): MinimumConfig = minimumConfig.getRequired("minimum_config") + override fun toString() = + "AddPrice{allocationPrice=$allocationPrice, planPhaseOrder=$planPhaseOrder, price=$price, additionalProperties=$additionalProperties}" + } - /** - * Expected to always return the following: - * ```kotlin - * JsonValue.from("minimum") - * ``` - * - * However, this method can be useful for debugging and logging (e.g. if the server - * responded with an unexpected value). - */ - @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + class RemoveAdjustment + private constructor( + private val adjustmentId: JsonField, + private val planPhaseOrder: JsonField, + private val additionalProperties: MutableMap, + ) { - /** - * The name of the price. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun name(): String = name.getRequired("name") + @JsonCreator + private constructor( + @JsonProperty("adjustment_id") + @ExcludeMissing + adjustmentId: JsonField = JsonMissing.of(), + @JsonProperty("plan_phase_order") + @ExcludeMissing + planPhaseOrder: JsonField = JsonMissing.of(), + ) : this(adjustmentId, planPhaseOrder, mutableMapOf()) - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun billableMetricId(): String? = billableMetricId.getNullable("billable_metric_id") + /** + * The id of the adjustment to remove from on the plan. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun adjustmentId(): String = adjustmentId.getRequired("adjustment_id") - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + /** + * The phase to remove this adjustment from. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun planPhaseOrder(): Long? = planPhaseOrder.getNullable("plan_phase_order") - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun billingCycleConfiguration(): NewBillingCycleConfiguration? = - billingCycleConfiguration.getNullable("billing_cycle_configuration") + /** + * Returns the raw JSON value of [adjustmentId]. + * + * Unlike [adjustmentId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("adjustment_id") + @ExcludeMissing + fun _adjustmentId(): JsonField = adjustmentId - /** - * The per unit conversion rate of the price currency to the invoicing currency. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + /** + * Returns the raw JSON value of [planPhaseOrder]. + * + * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder - /** - * The configuration for the rate of the price currency to the invoicing currency. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun conversionRateConfig(): ConversionRateConfig? = - conversionRateConfig.getNullable("conversion_rate_config") + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun currency(): String? = currency.getNullable("currency") + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - /** - * For dimensional price: specifies a price group and dimension values - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = - dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + fun toBuilder() = Builder().from(this) - /** - * An alias for the price. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + companion object { - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun fixedPriceQuantity(): Double? = - fixedPriceQuantity.getNullable("fixed_price_quantity") + /** + * Returns a mutable builder for constructing an instance of [RemoveAdjustment]. + * + * The following fields are required: + * ```kotlin + * .adjustmentId() + * ``` + */ + fun builder() = Builder() + } - /** - * The property used to group this price on an invoice - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun invoiceGroupingKey(): String? = - invoiceGroupingKey.getNullable("invoice_grouping_key") + /** A builder for [RemoveAdjustment]. */ + class Builder internal constructor() { - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + private var adjustmentId: JsonField? = null + private var planPhaseOrder: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun metadata(): Metadata? = metadata.getNullable("metadata") + internal fun from(removeAdjustment: RemoveAdjustment) = apply { + adjustmentId = removeAdjustment.adjustmentId + planPhaseOrder = removeAdjustment.planPhaseOrder + additionalProperties = removeAdjustment.additionalProperties.toMutableMap() + } - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun referenceId(): String? = referenceId.getNullable("reference_id") + /** The id of the adjustment to remove from on the plan. */ + fun adjustmentId(adjustmentId: String) = adjustmentId(JsonField.of(adjustmentId)) - /** - * Returns the raw JSON value of [cadence]. - * - * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("cadence") - @ExcludeMissing - fun _cadence(): JsonField = cadence + /** + * Sets [Builder.adjustmentId] to an arbitrary JSON value. + * + * You should usually call [Builder.adjustmentId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun adjustmentId(adjustmentId: JsonField) = apply { + this.adjustmentId = adjustmentId + } - /** - * Returns the raw JSON value of [itemId]. - * - * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + /** The phase to remove this adjustment from. */ + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) - /** - * Returns the raw JSON value of [minimumConfig]. - * - * Unlike [minimumConfig], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("minimum_config") - @ExcludeMissing - fun _minimumConfig(): JsonField = minimumConfig + /** + * Alias for [Builder.planPhaseOrder]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) - /** - * Returns the raw JSON value of [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + /** + * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. + * + * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun planPhaseOrder(planPhaseOrder: JsonField) = apply { + this.planPhaseOrder = planPhaseOrder + } - /** - * Returns the raw JSON value of [billableMetricId]. - * - * Unlike [billableMetricId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = billableMetricId + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** - * Returns the raw JSON value of [billedInAdvance]. - * - * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * Returns the raw JSON value of [billingCycleConfiguration]. - * - * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - /** - * Returns the raw JSON value of [conversionRate]. - * - * Unlike [conversionRate], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - /** - * Returns the raw JSON value of [conversionRateConfig]. - * - * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("conversion_rate_config") - @ExcludeMissing - fun _conversionRateConfig(): JsonField = conversionRateConfig + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - /** - * Returns the raw JSON value of [currency]. - * - * Unlike [currency], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("currency") - @ExcludeMissing - fun _currency(): JsonField = currency + /** + * Returns an immutable instance of [RemoveAdjustment]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .adjustmentId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): RemoveAdjustment = + RemoveAdjustment( + checkRequired("adjustmentId", adjustmentId), + planPhaseOrder, + additionalProperties.toMutableMap(), + ) + } - /** - * Returns the raw JSON value of [dimensionalPriceConfiguration]. - * - * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON - * field has an unexpected type. - */ - @JsonProperty("dimensional_price_configuration") - @ExcludeMissing - fun _dimensionalPriceConfiguration(): JsonField = - dimensionalPriceConfiguration + private var validated: Boolean = false - /** - * Returns the raw JSON value of [externalPriceId]. - * - * Unlike [externalPriceId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId + fun validate(): RemoveAdjustment = apply { + if (validated) { + return@apply + } - /** - * Returns the raw JSON value of [fixedPriceQuantity]. - * - * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + adjustmentId() + planPhaseOrder() + validated = true + } - /** - * Returns the raw JSON value of [invoiceGroupingKey]. - * - * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - /** - * Returns the raw JSON value of [invoicingCycleConfiguration]. - * - * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (adjustmentId.asKnown() == null) 0 else 1) + + (if (planPhaseOrder.asKnown() == null) 0 else 1) - /** - * Returns the raw JSON value of [metadata]. - * - * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * Returns the raw JSON value of [referenceId]. - * - * Unlike [referenceId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("reference_id") - @ExcludeMissing - fun _referenceId(): JsonField = referenceId + return other is RemoveAdjustment && + adjustmentId == other.adjustmentId && + planPhaseOrder == other.planPhaseOrder && + additionalProperties == other.additionalProperties + } - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + private val hashCode: Int by lazy { + Objects.hash(adjustmentId, planPhaseOrder, additionalProperties) + } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + override fun hashCode(): Int = hashCode - fun toBuilder() = Builder().from(this) + override fun toString() = + "RemoveAdjustment{adjustmentId=$adjustmentId, planPhaseOrder=$planPhaseOrder, additionalProperties=$additionalProperties}" + } - companion object { + class RemovePrice + private constructor( + private val priceId: JsonField, + private val planPhaseOrder: JsonField, + private val additionalProperties: MutableMap, + ) { - /** - * Returns a mutable builder for constructing an instance of [Minimum]. - * - * The following fields are required: - * ```kotlin - * .cadence() - * .itemId() - * .minimumConfig() - * .name() - * ``` - */ - fun builder() = Builder() - } + @JsonCreator + private constructor( + @JsonProperty("price_id") @ExcludeMissing priceId: JsonField = JsonMissing.of(), + @JsonProperty("plan_phase_order") + @ExcludeMissing + planPhaseOrder: JsonField = JsonMissing.of(), + ) : this(priceId, planPhaseOrder, mutableMapOf()) - /** A builder for [Minimum]. */ - class Builder internal constructor() { + /** + * The id of the price to remove from the plan. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun priceId(): String = priceId.getRequired("price_id") - private var cadence: JsonField? = null - private var itemId: JsonField? = null - private var minimumConfig: JsonField? = null - private var modelType: JsonValue = JsonValue.from("minimum") - private var name: JsonField? = null - private var billableMetricId: JsonField = JsonMissing.of() - private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var conversionRateConfig: JsonField = - JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var dimensionalPriceConfiguration: - JsonField = - JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: - JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var referenceId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + /** + * The phase to remove this price from. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun planPhaseOrder(): Long? = planPhaseOrder.getNullable("plan_phase_order") - internal fun from(minimum: Minimum) = apply { - cadence = minimum.cadence - itemId = minimum.itemId - minimumConfig = minimum.minimumConfig - modelType = minimum.modelType - name = minimum.name - billableMetricId = minimum.billableMetricId - billedInAdvance = minimum.billedInAdvance - billingCycleConfiguration = minimum.billingCycleConfiguration - conversionRate = minimum.conversionRate - conversionRateConfig = minimum.conversionRateConfig - currency = minimum.currency - dimensionalPriceConfiguration = minimum.dimensionalPriceConfiguration - externalPriceId = minimum.externalPriceId - fixedPriceQuantity = minimum.fixedPriceQuantity - invoiceGroupingKey = minimum.invoiceGroupingKey - invoicingCycleConfiguration = minimum.invoicingCycleConfiguration - metadata = minimum.metadata - referenceId = minimum.referenceId - additionalProperties = minimum.additionalProperties.toMutableMap() - } + /** + * Returns the raw JSON value of [priceId]. + * + * Unlike [priceId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + /** + * Returns the raw JSON value of [planPhaseOrder]. + * + * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder - /** - * Sets [Builder.cadence] to an arbitrary JSON value. - * - * You should usually call [Builder.cadence] with a well-typed [Cadence] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - /** The id of the item the price will be associated with. */ - fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - /** - * Sets [Builder.itemId] to an arbitrary JSON value. - * - * You should usually call [Builder.itemId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + fun toBuilder() = Builder().from(this) - fun minimumConfig(minimumConfig: MinimumConfig) = - minimumConfig(JsonField.of(minimumConfig)) + companion object { - /** - * Sets [Builder.minimumConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.minimumConfig] with a well-typed - * [MinimumConfig] value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. - */ - fun minimumConfig(minimumConfig: JsonField) = apply { - this.minimumConfig = minimumConfig - } + /** + * Returns a mutable builder for constructing an instance of [RemovePrice]. + * + * The following fields are required: + * ```kotlin + * .priceId() + * ``` + */ + fun builder() = Builder() + } - /** - * Sets the field to an arbitrary JSON value. - * - * It is usually unnecessary to call this method because the field defaults to - * the following: - * ```kotlin - * JsonValue.from("minimum") - * ``` - * - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + /** A builder for [RemovePrice]. */ + class Builder internal constructor() { - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) + private var priceId: JsonField? = null + private var planPhaseOrder: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - /** - * Sets [Builder.name] to an arbitrary JSON value. - * - * You should usually call [Builder.name] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun name(name: JsonField) = apply { this.name = name } + internal fun from(removePrice: RemovePrice) = apply { + priceId = removePrice.priceId + planPhaseOrder = removePrice.planPhaseOrder + additionalProperties = removePrice.additionalProperties.toMutableMap() + } - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: String?) = - billableMetricId(JsonField.ofNullable(billableMetricId)) + /** The id of the price to remove from the plan. */ + fun priceId(priceId: String) = priceId(JsonField.of(priceId)) - /** - * Sets [Builder.billableMetricId] to an arbitrary JSON value. - * - * You should usually call [Builder.billableMetricId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun billableMetricId(billableMetricId: JsonField) = apply { - this.billableMetricId = billableMetricId - } + /** + * Sets [Builder.priceId] to an arbitrary JSON value. + * + * You should usually call [Builder.priceId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun priceId(priceId: JsonField) = apply { this.priceId = priceId } - /** - * If the Price represents a fixed cost, the price will be billed in-advance if - * this is true, and in-arrears if this is false. - */ - fun billedInAdvance(billedInAdvance: Boolean?) = - billedInAdvance(JsonField.ofNullable(billedInAdvance)) + /** The phase to remove this price from. */ + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) - /** - * Alias for [Builder.billedInAdvance]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun billedInAdvance(billedInAdvance: Boolean) = - billedInAdvance(billedInAdvance as Boolean?) + /** + * Alias for [Builder.planPhaseOrder]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) - /** - * Sets [Builder.billedInAdvance] to an arbitrary JSON value. - * - * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun billedInAdvance(billedInAdvance: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } + /** + * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. + * + * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun planPhaseOrder(planPhaseOrder: JsonField) = apply { + this.planPhaseOrder = planPhaseOrder + } - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: NewBillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** - * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.billingCycleConfiguration] with a well-typed - * [NewBillingCycleConfiguration] value instead. This method is primarily for - * setting the field to an undocumented or not yet supported value. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: JsonField - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: Double?) = - conversionRate(JsonField.ofNullable(conversionRate)) + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - /** - * Alias for [Builder.conversionRate]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - /** - * Sets [Builder.conversionRate] to an arbitrary JSON value. - * - * You should usually call [Builder.conversionRate] with a well-typed [Double] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - /** - * The configuration for the rate of the price currency to the invoicing - * currency. - */ - fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = - conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + /** + * Returns an immutable instance of [RemovePrice]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .priceId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): RemovePrice = + RemovePrice( + checkRequired("priceId", priceId), + planPhaseOrder, + additionalProperties.toMutableMap(), + ) + } - /** - * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.conversionRateConfig] with a well-typed - * [ConversionRateConfig] value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun conversionRateConfig( - conversionRateConfig: JsonField - ) = apply { this.conversionRateConfig = conversionRateConfig } + private var validated: Boolean = false - /** - * Alias for calling [conversionRateConfig] with - * `ConversionRateConfig.ofUnit(unit)`. - */ - fun conversionRateConfig(unit: UnitConversionRateConfig) = - conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + fun validate(): RemovePrice = apply { + if (validated) { + return@apply + } - /** - * Alias for calling [conversionRateConfig] with the following: - * ```kotlin - * UnitConversionRateConfig.builder() - * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) - * .unitConfig(unitConfig) - * .build() - * ``` - */ - fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = - conversionRateConfig( - UnitConversionRateConfig.builder() - .conversionRateType( - UnitConversionRateConfig.ConversionRateType.UNIT - ) - .unitConfig(unitConfig) - .build() - ) + priceId() + planPhaseOrder() + validated = true + } - /** - * Alias for calling [conversionRateConfig] with - * `ConversionRateConfig.ofTiered(tiered)`. - */ - fun conversionRateConfig(tiered: TieredConversionRateConfig) = - conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - /** - * Alias for calling [conversionRateConfig] with the following: - * ```kotlin - * TieredConversionRateConfig.builder() - * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) - * .tieredConfig(tieredConfig) - * .build() - * ``` - */ - fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = - conversionRateConfig( - TieredConversionRateConfig.builder() - .conversionRateType( - TieredConversionRateConfig.ConversionRateType.TIERED - ) - .tieredConfig(tieredConfig) - .build() - ) + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (priceId.asKnown() == null) 0 else 1) + + (if (planPhaseOrder.asKnown() == null) 0 else 1) - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * Sets [Builder.currency] to an arbitrary JSON value. - * - * You should usually call [Builder.currency] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } + return other is RemovePrice && + priceId == other.priceId && + planPhaseOrder == other.planPhaseOrder && + additionalProperties == other.additionalProperties + } - /** For dimensional price: specifies a price group and dimension values */ - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? - ) = - dimensionalPriceConfiguration( - JsonField.ofNullable(dimensionalPriceConfiguration) - ) + private val hashCode: Int by lazy { + Objects.hash(priceId, planPhaseOrder, additionalProperties) + } - /** - * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.dimensionalPriceConfiguration] with a - * well-typed [NewDimensionalPriceConfiguration] value instead. This method is - * primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: JsonField - ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + override fun hashCode(): Int = hashCode - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) + override fun toString() = + "RemovePrice{priceId=$priceId, planPhaseOrder=$planPhaseOrder, additionalProperties=$additionalProperties}" + } - /** - * Sets [Builder.externalPriceId] to an arbitrary JSON value. - * - * You should usually call [Builder.externalPriceId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun externalPriceId(externalPriceId: JsonField) = apply { - this.externalPriceId = externalPriceId - } + class ReplaceAdjustment + private constructor( + private val adjustment: JsonField, + private val replacesAdjustmentId: JsonField, + private val planPhaseOrder: JsonField, + private val additionalProperties: MutableMap, + ) { - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = - fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + @JsonCreator + private constructor( + @JsonProperty("adjustment") + @ExcludeMissing + adjustment: JsonField = JsonMissing.of(), + @JsonProperty("replaces_adjustment_id") + @ExcludeMissing + replacesAdjustmentId: JsonField = JsonMissing.of(), + @JsonProperty("plan_phase_order") + @ExcludeMissing + planPhaseOrder: JsonField = JsonMissing.of(), + ) : this(adjustment, replacesAdjustmentId, planPhaseOrder, mutableMapOf()) - /** - * Alias for [Builder.fixedPriceQuantity]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) + /** + * The definition of a new adjustment to create and add to the plan. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun adjustment(): Adjustment = adjustment.getRequired("adjustment") - /** - * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. - * - * You should usually call [Builder.fixedPriceQuantity] with a well-typed - * [Double] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + /** + * The id of the adjustment on the plan to replace in the plan. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun replacesAdjustmentId(): String = + replacesAdjustmentId.getRequired("replaces_adjustment_id") - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = - invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + /** + * The phase to replace this adjustment from. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun planPhaseOrder(): Long? = planPhaseOrder.getNullable("plan_phase_order") - /** - * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. - * - * You should usually call [Builder.invoiceGroupingKey] with a well-typed - * [String] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { - this.invoiceGroupingKey = invoiceGroupingKey - } + /** + * Returns the raw JSON value of [adjustment]. + * + * Unlike [adjustment], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("adjustment") + @ExcludeMissing + fun _adjustment(): JsonField = adjustment - /** - * Within each billing cycle, specifies the cadence at which invoices are - * produced. If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: NewBillingCycleConfiguration? - ) = - invoicingCycleConfiguration( - JsonField.ofNullable(invoicingCycleConfiguration) - ) + /** + * Returns the raw JSON value of [replacesAdjustmentId]. + * + * Unlike [replacesAdjustmentId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("replaces_adjustment_id") + @ExcludeMissing + fun _replacesAdjustmentId(): JsonField = replacesAdjustmentId - /** - * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.invoicingCycleConfiguration] with a - * well-typed [NewBillingCycleConfiguration] value instead. This method is - * primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** + * Returns the raw JSON value of [planPhaseOrder]. + * + * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - /** - * Sets [Builder.metadata] to an arbitrary JSON value. - * - * You should usually call [Builder.metadata] with a well-typed [Metadata] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - fun referenceId(referenceId: String?) = - referenceId(JsonField.ofNullable(referenceId)) + fun toBuilder() = Builder().from(this) - /** - * Sets [Builder.referenceId] to an arbitrary JSON value. - * - * You should usually call [Builder.referenceId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun referenceId(referenceId: JsonField) = apply { - this.referenceId = referenceId - } + companion object { - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * Returns a mutable builder for constructing an instance of [ReplaceAdjustment]. + * + * The following fields are required: + * ```kotlin + * .adjustment() + * .replacesAdjustmentId() + * ``` + */ + fun builder() = Builder() + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** A builder for [ReplaceAdjustment]. */ + class Builder internal constructor() { - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + private var adjustment: JsonField? = null + private var replacesAdjustmentId: JsonField? = null + private var planPhaseOrder: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + internal fun from(replaceAdjustment: ReplaceAdjustment) = apply { + adjustment = replaceAdjustment.adjustment + replacesAdjustmentId = replaceAdjustment.replacesAdjustmentId + planPhaseOrder = replaceAdjustment.planPhaseOrder + additionalProperties = replaceAdjustment.additionalProperties.toMutableMap() + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** The definition of a new adjustment to create and add to the plan. */ + fun adjustment(adjustment: Adjustment) = adjustment(JsonField.of(adjustment)) - /** - * Returns an immutable instance of [Minimum]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```kotlin - * .cadence() - * .itemId() - * .minimumConfig() - * .name() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Minimum = - Minimum( - checkRequired("cadence", cadence), - checkRequired("itemId", itemId), - checkRequired("minimumConfig", minimumConfig), - modelType, - checkRequired("name", name), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - conversionRateConfig, - currency, - dimensionalPriceConfiguration, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - additionalProperties.toMutableMap(), - ) - } + /** + * Sets [Builder.adjustment] to an arbitrary JSON value. + * + * You should usually call [Builder.adjustment] with a well-typed [Adjustment] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun adjustment(adjustment: JsonField) = apply { + this.adjustment = adjustment + } - private var validated: Boolean = false + /** + * Alias for calling [adjustment] with + * `Adjustment.ofPercentageDiscount(percentageDiscount)`. + */ + fun adjustment(percentageDiscount: NewPercentageDiscount) = + adjustment(Adjustment.ofPercentageDiscount(percentageDiscount)) - fun validate(): Minimum = apply { - if (validated) { - return@apply - } + /** + * Alias for calling [adjustment] with the following: + * ```kotlin + * NewPercentageDiscount.builder() + * .adjustmentType(NewPercentageDiscount.AdjustmentType.PERCENTAGE_DISCOUNT) + * .percentageDiscount(percentageDiscount) + * .build() + * ``` + */ + fun percentageDiscountAdjustment(percentageDiscount: Double) = + adjustment( + NewPercentageDiscount.builder() + .adjustmentType(NewPercentageDiscount.AdjustmentType.PERCENTAGE_DISCOUNT) + .percentageDiscount(percentageDiscount) + .build() + ) - cadence().validate() - itemId() - minimumConfig().validate() - _modelType().let { - if (it != JsonValue.from("minimum")) { - throw OrbInvalidDataException("'modelType' is invalid, received $it") - } - } - name() - billableMetricId() - billedInAdvance() - billingCycleConfiguration()?.validate() - conversionRate() - conversionRateConfig()?.validate() - currency() - dimensionalPriceConfiguration()?.validate() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration()?.validate() - metadata()?.validate() - referenceId() - validated = true - } + /** Alias for calling [adjustment] with `Adjustment.ofUsageDiscount(usageDiscount)`. */ + fun adjustment(usageDiscount: NewUsageDiscount) = + adjustment(Adjustment.ofUsageDiscount(usageDiscount)) - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** + * Alias for calling [adjustment] with the following: + * ```kotlin + * NewUsageDiscount.builder() + * .adjustmentType(NewUsageDiscount.AdjustmentType.USAGE_DISCOUNT) + * .usageDiscount(usageDiscount) + * .build() + * ``` + */ + fun usageDiscountAdjustment(usageDiscount: Double) = + adjustment( + NewUsageDiscount.builder() + .adjustmentType(NewUsageDiscount.AdjustmentType.USAGE_DISCOUNT) + .usageDiscount(usageDiscount) + .build() + ) - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (cadence.asKnown()?.validity() ?: 0) + - (if (itemId.asKnown() == null) 0 else 1) + - (minimumConfig.asKnown()?.validity() ?: 0) + - modelType.let { if (it == JsonValue.from("minimum")) 1 else 0 } + - (if (name.asKnown() == null) 0 else 1) + - (if (billableMetricId.asKnown() == null) 0 else 1) + - (if (billedInAdvance.asKnown() == null) 0 else 1) + - (billingCycleConfiguration.asKnown()?.validity() ?: 0) + - (if (conversionRate.asKnown() == null) 0 else 1) + - (conversionRateConfig.asKnown()?.validity() ?: 0) + - (if (currency.asKnown() == null) 0 else 1) + - (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + - (if (externalPriceId.asKnown() == null) 0 else 1) + - (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + - (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + - (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + - (metadata.asKnown()?.validity() ?: 0) + - (if (referenceId.asKnown() == null) 0 else 1) + /** + * Alias for calling [adjustment] with `Adjustment.ofAmountDiscount(amountDiscount)`. + */ + fun adjustment(amountDiscount: NewAmountDiscount) = + adjustment(Adjustment.ofAmountDiscount(amountDiscount)) - /** The cadence to bill for this price on. */ - class Cadence - @JsonCreator - private constructor(private val value: JsonField) : Enum { + /** + * Alias for calling [adjustment] with the following: + * ```kotlin + * NewAmountDiscount.builder() + * .adjustmentType(NewAmountDiscount.AdjustmentType.AMOUNT_DISCOUNT) + * .amountDiscount(amountDiscount) + * .build() + * ``` + */ + fun amountDiscountAdjustment(amountDiscount: String) = + adjustment( + NewAmountDiscount.builder() + .adjustmentType(NewAmountDiscount.AdjustmentType.AMOUNT_DISCOUNT) + .amountDiscount(amountDiscount) + .build() + ) - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value + /** Alias for calling [adjustment] with `Adjustment.ofMinimum(minimum)`. */ + fun adjustment(minimum: NewMinimum) = adjustment(Adjustment.ofMinimum(minimum)) - companion object { + /** Alias for calling [adjustment] with `Adjustment.ofMaximum(maximum)`. */ + fun adjustment(maximum: NewMaximum) = adjustment(Adjustment.ofMaximum(maximum)) - val ANNUAL = of("annual") + /** + * Alias for calling [adjustment] with the following: + * ```kotlin + * NewMaximum.builder() + * .adjustmentType(NewMaximum.AdjustmentType.MAXIMUM) + * .maximumAmount(maximumAmount) + * .build() + * ``` + */ + fun maximumAdjustment(maximumAmount: String) = + adjustment( + NewMaximum.builder() + .adjustmentType(NewMaximum.AdjustmentType.MAXIMUM) + .maximumAmount(maximumAmount) + .build() + ) - val SEMI_ANNUAL = of("semi_annual") + /** The id of the adjustment on the plan to replace in the plan. */ + fun replacesAdjustmentId(replacesAdjustmentId: String) = + replacesAdjustmentId(JsonField.of(replacesAdjustmentId)) - val MONTHLY = of("monthly") + /** + * Sets [Builder.replacesAdjustmentId] to an arbitrary JSON value. + * + * You should usually call [Builder.replacesAdjustmentId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun replacesAdjustmentId(replacesAdjustmentId: JsonField) = apply { + this.replacesAdjustmentId = replacesAdjustmentId + } - val QUARTERLY = of("quarterly") + /** The phase to replace this adjustment from. */ + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) - val ONE_TIME = of("one_time") + /** + * Alias for [Builder.planPhaseOrder]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) - val CUSTOM = of("custom") + /** + * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. + * + * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun planPhaseOrder(planPhaseOrder: JsonField) = apply { + this.planPhaseOrder = planPhaseOrder + } - fun of(value: String) = Cadence(JsonField.of(value)) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** An enum containing [Cadence]'s known values. */ - enum class Known { - ANNUAL, - SEMI_ANNUAL, - MONTHLY, - QUARTERLY, - ONE_TIME, - CUSTOM, - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Cadence] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - ANNUAL, - SEMI_ANNUAL, - MONTHLY, - QUARTERLY, - ONE_TIME, - CUSTOM, - /** - * An enum member indicating that [Cadence] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - ANNUAL -> Value.ANNUAL - SEMI_ANNUAL -> Value.SEMI_ANNUAL - MONTHLY -> Value.MONTHLY - QUARTERLY -> Value.QUARTERLY - ONE_TIME -> Value.ONE_TIME - CUSTOM -> Value.CUSTOM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - ANNUAL -> Known.ANNUAL - SEMI_ANNUAL -> Known.SEMI_ANNUAL - MONTHLY -> Known.MONTHLY - QUARTERLY -> Known.QUARTERLY - ONE_TIME -> Known.ONE_TIME - CUSTOM -> Known.CUSTOM - else -> throw OrbInvalidDataException("Unknown Cadence: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString() - ?: throw OrbInvalidDataException("Value is not a String") + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - private var validated: Boolean = false + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - fun validate(): Cadence = apply { - if (validated) { - return@apply - } + /** + * Returns an immutable instance of [ReplaceAdjustment]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .adjustment() + * .replacesAdjustmentId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ReplaceAdjustment = + ReplaceAdjustment( + checkRequired("adjustment", adjustment), + checkRequired("replacesAdjustmentId", replacesAdjustmentId), + planPhaseOrder, + additionalProperties.toMutableMap(), + ) + } - known() - validated = true - } + private var validated: Boolean = false - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + fun validate(): ReplaceAdjustment = apply { + if (validated) { + return@apply + } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + adjustment().validate() + replacesAdjustmentId() + planPhaseOrder() + validated = true + } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - return other is Cadence && value == other.value - } + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (adjustment.asKnown()?.validity() ?: 0) + + (if (replacesAdjustmentId.asKnown() == null) 0 else 1) + + (if (planPhaseOrder.asKnown() == null) 0 else 1) - override fun hashCode() = value.hashCode() + /** The definition of a new adjustment to create and add to the plan. */ + @JsonDeserialize(using = Adjustment.Deserializer::class) + @JsonSerialize(using = Adjustment.Serializer::class) + class Adjustment + private constructor( + private val percentageDiscount: NewPercentageDiscount? = null, + private val usageDiscount: NewUsageDiscount? = null, + private val amountDiscount: NewAmountDiscount? = null, + private val minimum: NewMinimum? = null, + private val maximum: NewMaximum? = null, + private val _json: JsonValue? = null, + ) { - override fun toString() = value.toString() - } + fun percentageDiscount(): NewPercentageDiscount? = percentageDiscount - class MinimumConfig - private constructor( - private val minimumAmount: JsonField, - private val prorated: JsonField, - private val additionalProperties: MutableMap, - ) { + fun usageDiscount(): NewUsageDiscount? = usageDiscount - @JsonCreator - private constructor( - @JsonProperty("minimum_amount") - @ExcludeMissing - minimumAmount: JsonField = JsonMissing.of(), - @JsonProperty("prorated") - @ExcludeMissing - prorated: JsonField = JsonMissing.of(), - ) : this(minimumAmount, prorated, mutableMapOf()) + fun amountDiscount(): NewAmountDiscount? = amountDiscount - /** - * The minimum amount to apply - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") + fun minimum(): NewMinimum? = minimum - /** - * By default, subtotals from minimum composite prices are prorated based on the - * service period. Set to false to disable proration. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun prorated(): Boolean? = prorated.getNullable("prorated") + fun maximum(): NewMaximum? = maximum - /** - * Returns the raw JSON value of [minimumAmount]. - * - * Unlike [minimumAmount], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("minimum_amount") - @ExcludeMissing - fun _minimumAmount(): JsonField = minimumAmount + fun isPercentageDiscount(): Boolean = percentageDiscount != null - /** - * Returns the raw JSON value of [prorated]. - * - * Unlike [prorated], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("prorated") - @ExcludeMissing - fun _prorated(): JsonField = prorated + fun isUsageDiscount(): Boolean = usageDiscount != null - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + fun isAmountDiscount(): Boolean = amountDiscount != null - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + fun isMinimum(): Boolean = minimum != null - fun toBuilder() = Builder().from(this) + fun isMaximum(): Boolean = maximum != null - companion object { + fun asPercentageDiscount(): NewPercentageDiscount = + percentageDiscount.getOrThrow("percentageDiscount") - /** - * Returns a mutable builder for constructing an instance of - * [MinimumConfig]. - * - * The following fields are required: - * ```kotlin - * .minimumAmount() - * ``` - */ - fun builder() = Builder() - } + fun asUsageDiscount(): NewUsageDiscount = usageDiscount.getOrThrow("usageDiscount") - /** A builder for [MinimumConfig]. */ - class Builder internal constructor() { + fun asAmountDiscount(): NewAmountDiscount = amountDiscount.getOrThrow("amountDiscount") - private var minimumAmount: JsonField? = null - private var prorated: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() + fun asMinimum(): NewMinimum = minimum.getOrThrow("minimum") - internal fun from(minimumConfig: MinimumConfig) = apply { - minimumAmount = minimumConfig.minimumAmount - prorated = minimumConfig.prorated - additionalProperties = minimumConfig.additionalProperties.toMutableMap() - } + fun asMaximum(): NewMaximum = maximum.getOrThrow("maximum") - /** The minimum amount to apply */ - fun minimumAmount(minimumAmount: String) = - minimumAmount(JsonField.of(minimumAmount)) + fun _json(): JsonValue? = _json - /** - * Sets [Builder.minimumAmount] to an arbitrary JSON value. - * - * You should usually call [Builder.minimumAmount] with a well-typed - * [String] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun minimumAmount(minimumAmount: JsonField) = apply { - this.minimumAmount = minimumAmount - } + fun accept(visitor: Visitor): T = + when { + percentageDiscount != null -> + visitor.visitPercentageDiscount(percentageDiscount) + usageDiscount != null -> visitor.visitUsageDiscount(usageDiscount) + amountDiscount != null -> visitor.visitAmountDiscount(amountDiscount) + minimum != null -> visitor.visitMinimum(minimum) + maximum != null -> visitor.visitMaximum(maximum) + else -> visitor.unknown(_json) + } - /** - * By default, subtotals from minimum composite prices are prorated based on - * the service period. Set to false to disable proration. - */ - fun prorated(prorated: Boolean?) = prorated(JsonField.ofNullable(prorated)) + private var validated: Boolean = false - /** - * Alias for [Builder.prorated]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun prorated(prorated: Boolean) = prorated(prorated as Boolean?) + fun validate(): Adjustment = apply { + if (validated) { + return@apply + } - /** - * Sets [Builder.prorated] to an arbitrary JSON value. - * - * You should usually call [Builder.prorated] with a well-typed [Boolean] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun prorated(prorated: JsonField) = apply { - this.prorated = prorated + accept( + object : Visitor { + override fun visitPercentageDiscount( + percentageDiscount: NewPercentageDiscount + ) { + percentageDiscount.validate() } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) + override fun visitUsageDiscount(usageDiscount: NewUsageDiscount) { + usageDiscount.validate() } - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) + override fun visitAmountDiscount(amountDiscount: NewAmountDiscount) { + amountDiscount.validate() } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) + override fun visitMinimum(minimum: NewMinimum) { + minimum.validate() } - /** - * Returns an immutable instance of [MinimumConfig]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```kotlin - * .minimumAmount() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): MinimumConfig = - MinimumConfig( - checkRequired("minimumAmount", minimumAmount), - prorated, - additionalProperties.toMutableMap(), - ) + override fun visitMaximum(maximum: NewMaximum) { + maximum.validate() + } } + ) + validated = true + } - private var validated: Boolean = false + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - fun validate(): MinimumConfig = apply { - if (validated) { - return@apply - } + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitPercentageDiscount( + percentageDiscount: NewPercentageDiscount + ) = percentageDiscount.validity() - minimumAmount() - prorated() - validated = true - } + override fun visitUsageDiscount(usageDiscount: NewUsageDiscount) = + usageDiscount.validity() - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + override fun visitAmountDiscount(amountDiscount: NewAmountDiscount) = + amountDiscount.validity() - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (if (minimumAmount.asKnown() == null) 0 else 1) + - (if (prorated.asKnown() == null) 0 else 1) + override fun visitMinimum(minimum: NewMinimum) = minimum.validity() - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + override fun visitMaximum(maximum: NewMaximum) = maximum.validity() - return other is MinimumConfig && - minimumAmount == other.minimumAmount && - prorated == other.prorated && - additionalProperties == other.additionalProperties + override fun unknown(json: JsonValue?) = 0 } + ) - private val hashCode: Int by lazy { - Objects.hash(minimumAmount, prorated, additionalProperties) - } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - override fun hashCode(): Int = hashCode + return other is Adjustment && + percentageDiscount == other.percentageDiscount && + usageDiscount == other.usageDiscount && + amountDiscount == other.amountDiscount && + minimum == other.minimum && + maximum == other.maximum + } - override fun toString() = - "MinimumConfig{minimumAmount=$minimumAmount, prorated=$prorated, additionalProperties=$additionalProperties}" + override fun hashCode(): Int = + Objects.hash(percentageDiscount, usageDiscount, amountDiscount, minimum, maximum) + + override fun toString(): String = + when { + percentageDiscount != null -> + "Adjustment{percentageDiscount=$percentageDiscount}" + usageDiscount != null -> "Adjustment{usageDiscount=$usageDiscount}" + amountDiscount != null -> "Adjustment{amountDiscount=$amountDiscount}" + minimum != null -> "Adjustment{minimum=$minimum}" + maximum != null -> "Adjustment{maximum=$maximum}" + _json != null -> "Adjustment{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Adjustment") } - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - class Metadata - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { + companion object { - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun ofPercentageDiscount(percentageDiscount: NewPercentageDiscount) = + Adjustment(percentageDiscount = percentageDiscount) - fun toBuilder() = Builder().from(this) + fun ofUsageDiscount(usageDiscount: NewUsageDiscount) = + Adjustment(usageDiscount = usageDiscount) - companion object { + fun ofAmountDiscount(amountDiscount: NewAmountDiscount) = + Adjustment(amountDiscount = amountDiscount) - /** Returns a mutable builder for constructing an instance of [Metadata]. */ - fun builder() = Builder() - } + fun ofMinimum(minimum: NewMinimum) = Adjustment(minimum = minimum) - /** A builder for [Metadata]. */ - class Builder internal constructor() { + fun ofMaximum(maximum: NewMaximum) = Adjustment(maximum = maximum) + } - private var additionalProperties: MutableMap = - mutableMapOf() + /** + * An interface that defines how to map each variant of [Adjustment] to a value of type + * [T]. + */ + interface Visitor { - internal fun from(metadata: Metadata) = apply { - additionalProperties = metadata.additionalProperties.toMutableMap() - } + fun visitPercentageDiscount(percentageDiscount: NewPercentageDiscount): T - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun visitUsageDiscount(usageDiscount: NewUsageDiscount): T - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun visitAmountDiscount(amountDiscount: NewAmountDiscount): T - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + fun visitMinimum(minimum: NewMinimum): T - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun visitMaximum(maximum: NewMaximum): T - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * Maps an unknown variant of [Adjustment] to a value of type [T]. + * + * An instance of [Adjustment] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the + * SDK is unaware of. + * + * @throws OrbInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw OrbInvalidDataException("Unknown Adjustment: $json") + } + } - /** - * Returns an immutable instance of [Metadata]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } + internal class Deserializer : BaseDeserializer(Adjustment::class) { - private var validated: Boolean = false + override fun ObjectCodec.deserialize(node: JsonNode): Adjustment { + val json = JsonValue.fromJsonNode(node) + val adjustmentType = json.asObject()?.get("adjustment_type")?.asString() - fun validate(): Metadata = apply { - if (validated) { - return@apply + when (adjustmentType) { + "percentage_discount" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Adjustment(percentageDiscount = it, _json = json) } + ?: Adjustment(_json = json) } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false + "usage_discount" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(usageDiscount = it, _json = json) + } ?: Adjustment(_json = json) } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - additionalProperties.count { (_, value) -> - !value.isNull() && !value.isMissing() + "amount_discount" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(amountDiscount = it, _json = json) + } ?: Adjustment(_json = json) } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + "minimum" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(minimum = it, _json = json) + } ?: Adjustment(_json = json) + } + "maximum" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(maximum = it, _json = json) + } ?: Adjustment(_json = json) } - - return other is Metadata && - additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + return Adjustment(_json = json) + } + } - override fun hashCode(): Int = hashCode + internal class Serializer : BaseSerializer(Adjustment::class) { - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + override fun serialize( + value: Adjustment, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.percentageDiscount != null -> + generator.writeObject(value.percentageDiscount) + value.usageDiscount != null -> generator.writeObject(value.usageDiscount) + value.amountDiscount != null -> generator.writeObject(value.amountDiscount) + value.minimum != null -> generator.writeObject(value.minimum) + value.maximum != null -> generator.writeObject(value.maximum) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Adjustment") + } } + } + } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - return other is Minimum && - cadence == other.cadence && - itemId == other.itemId && - minimumConfig == other.minimumConfig && - modelType == other.modelType && - name == other.name && - billableMetricId == other.billableMetricId && - billedInAdvance == other.billedInAdvance && - billingCycleConfiguration == other.billingCycleConfiguration && - conversionRate == other.conversionRate && - conversionRateConfig == other.conversionRateConfig && - currency == other.currency && - dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && - externalPriceId == other.externalPriceId && - fixedPriceQuantity == other.fixedPriceQuantity && - invoiceGroupingKey == other.invoiceGroupingKey && - invoicingCycleConfiguration == other.invoicingCycleConfiguration && - metadata == other.metadata && - referenceId == other.referenceId && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - cadence, - itemId, - minimumConfig, - modelType, - name, - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - conversionRateConfig, - currency, - dimensionalPriceConfiguration, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Minimum{cadence=$cadence, itemId=$itemId, minimumConfig=$minimumConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is AddPrice && - allocationPrice == other.allocationPrice && + return other is ReplaceAdjustment && + adjustment == other.adjustment && + replacesAdjustmentId == other.replacesAdjustmentId && planPhaseOrder == other.planPhaseOrder && - price == other.price && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(allocationPrice, planPhaseOrder, price, additionalProperties) + Objects.hash(adjustment, replacesAdjustmentId, planPhaseOrder, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "AddPrice{allocationPrice=$allocationPrice, planPhaseOrder=$planPhaseOrder, price=$price, additionalProperties=$additionalProperties}" + "ReplaceAdjustment{adjustment=$adjustment, replacesAdjustmentId=$replacesAdjustmentId, planPhaseOrder=$planPhaseOrder, additionalProperties=$additionalProperties}" } - class RemoveAdjustment + class ReplacePrice private constructor( - private val adjustmentId: JsonField, + private val replacesPriceId: JsonField, + private val allocationPrice: JsonField, private val planPhaseOrder: JsonField, + private val price: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("adjustment_id") + @JsonProperty("replaces_price_id") @ExcludeMissing - adjustmentId: JsonField = JsonMissing.of(), + replacesPriceId: JsonField = JsonMissing.of(), + @JsonProperty("allocation_price") + @ExcludeMissing + allocationPrice: JsonField = JsonMissing.of(), @JsonProperty("plan_phase_order") @ExcludeMissing planPhaseOrder: JsonField = JsonMissing.of(), - ) : this(adjustmentId, planPhaseOrder, mutableMapOf()) + @JsonProperty("price") @ExcludeMissing price: JsonField = JsonMissing.of(), + ) : this(replacesPriceId, allocationPrice, planPhaseOrder, price, mutableMapOf()) /** - * The id of the adjustment to remove from on the plan. + * The id of the price on the plan to replace in the plan. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ - fun adjustmentId(): String = adjustmentId.getRequired("adjustment_id") + fun replacesPriceId(): String = replacesPriceId.getRequired("replaces_price_id") /** - * The phase to remove this adjustment from. + * The allocation price to add to the plan. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun allocationPrice(): NewAllocationPrice? = allocationPrice.getNullable("allocation_price") + + /** + * The phase to replace this price from. * * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -6254,14 +5748,32 @@ private constructor( fun planPhaseOrder(): Long? = planPhaseOrder.getNullable("plan_phase_order") /** - * Returns the raw JSON value of [adjustmentId]. + * The price to add to the plan * - * Unlike [adjustmentId], this method doesn't throw if the JSON field has an unexpected + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun price(): Price? = price.getNullable("price") + + /** + * Returns the raw JSON value of [replacesPriceId]. + * + * Unlike [replacesPriceId], this method doesn't throw if the JSON field has an unexpected * type. */ - @JsonProperty("adjustment_id") + @JsonProperty("replaces_price_id") @ExcludeMissing - fun _adjustmentId(): JsonField = adjustmentId + fun _replacesPriceId(): JsonField = replacesPriceId + + /** + * Returns the raw JSON value of [allocationPrice]. + * + * Unlike [allocationPrice], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("allocation_price") + @ExcludeMissing + fun _allocationPrice(): JsonField = allocationPrice /** * Returns the raw JSON value of [planPhaseOrder]. @@ -6273,6 +5785,13 @@ private constructor( @ExcludeMissing fun _planPhaseOrder(): JsonField = planPhaseOrder + /** + * Returns the raw JSON value of [price]. + * + * Unlike [price], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("price") @ExcludeMissing fun _price(): JsonField = price + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -6288,44 +5807,64 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [RemoveAdjustment]. + * Returns a mutable builder for constructing an instance of [ReplacePrice]. * * The following fields are required: * ```kotlin - * .adjustmentId() + * .replacesPriceId() * ``` */ fun builder() = Builder() } - /** A builder for [RemoveAdjustment]. */ + /** A builder for [ReplacePrice]. */ class Builder internal constructor() { - private var adjustmentId: JsonField? = null + private var replacesPriceId: JsonField? = null + private var allocationPrice: JsonField = JsonMissing.of() private var planPhaseOrder: JsonField = JsonMissing.of() + private var price: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(removeAdjustment: RemoveAdjustment) = apply { - adjustmentId = removeAdjustment.adjustmentId - planPhaseOrder = removeAdjustment.planPhaseOrder - additionalProperties = removeAdjustment.additionalProperties.toMutableMap() + internal fun from(replacePrice: ReplacePrice) = apply { + replacesPriceId = replacePrice.replacesPriceId + allocationPrice = replacePrice.allocationPrice + planPhaseOrder = replacePrice.planPhaseOrder + price = replacePrice.price + additionalProperties = replacePrice.additionalProperties.toMutableMap() } - /** The id of the adjustment to remove from on the plan. */ - fun adjustmentId(adjustmentId: String) = adjustmentId(JsonField.of(adjustmentId)) + /** The id of the price on the plan to replace in the plan. */ + fun replacesPriceId(replacesPriceId: String) = + replacesPriceId(JsonField.of(replacesPriceId)) /** - * Sets [Builder.adjustmentId] to an arbitrary JSON value. + * Sets [Builder.replacesPriceId] to an arbitrary JSON value. * - * You should usually call [Builder.adjustmentId] with a well-typed [String] value + * You should usually call [Builder.replacesPriceId] with a well-typed [String] value * instead. This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun adjustmentId(adjustmentId: JsonField) = apply { - this.adjustmentId = adjustmentId + fun replacesPriceId(replacesPriceId: JsonField) = apply { + this.replacesPriceId = replacesPriceId } - /** The phase to remove this adjustment from. */ + /** The allocation price to add to the plan. */ + fun allocationPrice(allocationPrice: NewAllocationPrice?) = + allocationPrice(JsonField.ofNullable(allocationPrice)) + + /** + * Sets [Builder.allocationPrice] to an arbitrary JSON value. + * + * You should usually call [Builder.allocationPrice] with a well-typed + * [NewAllocationPrice] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun allocationPrice(allocationPrice: JsonField) = apply { + this.allocationPrice = allocationPrice + } + + /** The phase to replace this price from. */ fun planPhaseOrder(planPhaseOrder: Long?) = planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) @@ -6347,215 +5886,158 @@ private constructor( this.planPhaseOrder = planPhaseOrder } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** The price to add to the plan */ + fun price(price: Price?) = price(JsonField.ofNullable(price)) - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * Sets [Builder.price] to an arbitrary JSON value. + * + * You should usually call [Builder.price] with a well-typed [Price] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun price(price: JsonField) = apply { this.price = price } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + /** Alias for calling [price] with `Price.ofUnit(unit)`. */ + fun price(unit: NewPlanUnitPrice) = price(Price.ofUnit(unit)) - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + /** Alias for calling [price] with `Price.ofPackage(package_)`. */ + fun price(package_: NewPlanPackagePrice) = price(Price.ofPackage(package_)) - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** Alias for calling [price] with `Price.ofMatrix(matrix)`. */ + fun price(matrix: NewPlanMatrixPrice) = price(Price.ofMatrix(matrix)) + + /** Alias for calling [price] with `Price.ofTiered(tiered)`. */ + fun price(tiered: NewPlanTieredPrice) = price(Price.ofTiered(tiered)) + + /** Alias for calling [price] with `Price.ofBulk(bulk)`. */ + fun price(bulk: NewPlanBulkPrice) = price(Price.ofBulk(bulk)) /** - * Returns an immutable instance of [RemoveAdjustment]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```kotlin - * .adjustmentId() - * ``` - * - * @throws IllegalStateException if any required field is unset. + * Alias for calling [price] with `Price.ofThresholdTotalAmount(thresholdTotalAmount)`. */ - fun build(): RemoveAdjustment = - RemoveAdjustment( - checkRequired("adjustmentId", adjustmentId), - planPhaseOrder, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false + fun price(thresholdTotalAmount: NewPlanThresholdTotalAmountPrice) = + price(Price.ofThresholdTotalAmount(thresholdTotalAmount)) - fun validate(): RemoveAdjustment = apply { - if (validated) { - return@apply - } + /** Alias for calling [price] with `Price.ofTieredPackage(tieredPackage)`. */ + fun price(tieredPackage: NewPlanTieredPackagePrice) = + price(Price.ofTieredPackage(tieredPackage)) - adjustmentId() - planPhaseOrder() - validated = true - } + /** Alias for calling [price] with `Price.ofTieredWithMinimum(tieredWithMinimum)`. */ + fun price(tieredWithMinimum: NewPlanTieredWithMinimumPrice) = + price(Price.ofTieredWithMinimum(tieredWithMinimum)) - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** Alias for calling [price] with `Price.ofUnitWithPercent(unitWithPercent)`. */ + fun price(unitWithPercent: NewPlanUnitWithPercentPrice) = + price(Price.ofUnitWithPercent(unitWithPercent)) - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (if (adjustmentId.asKnown() == null) 0 else 1) + - (if (planPhaseOrder.asKnown() == null) 0 else 1) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is RemoveAdjustment && - adjustmentId == other.adjustmentId && - planPhaseOrder == other.planPhaseOrder && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(adjustmentId, planPhaseOrder, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "RemoveAdjustment{adjustmentId=$adjustmentId, planPhaseOrder=$planPhaseOrder, additionalProperties=$additionalProperties}" - } - - class RemovePrice - private constructor( - private val priceId: JsonField, - private val planPhaseOrder: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("price_id") @ExcludeMissing priceId: JsonField = JsonMissing.of(), - @JsonProperty("plan_phase_order") - @ExcludeMissing - planPhaseOrder: JsonField = JsonMissing.of(), - ) : this(priceId, planPhaseOrder, mutableMapOf()) - - /** - * The id of the price to remove from the plan. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun priceId(): String = priceId.getRequired("price_id") - - /** - * The phase to remove this price from. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun planPhaseOrder(): Long? = planPhaseOrder.getNullable("plan_phase_order") + /** + * Alias for calling [price] with + * `Price.ofPackageWithAllocation(packageWithAllocation)`. + */ + fun price(packageWithAllocation: NewPlanPackageWithAllocationPrice) = + price(Price.ofPackageWithAllocation(packageWithAllocation)) - /** - * Returns the raw JSON value of [priceId]. - * - * Unlike [priceId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId + /** + * Alias for calling [price] with `Price.ofTieredWithProration(tieredWithProration)`. + */ + fun price(tieredWithProration: NewPlanTierWithProrationPrice) = + price(Price.ofTieredWithProration(tieredWithProration)) - /** - * Returns the raw JSON value of [planPhaseOrder]. - * - * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("plan_phase_order") - @ExcludeMissing - fun _planPhaseOrder(): JsonField = planPhaseOrder + /** Alias for calling [price] with `Price.ofUnitWithProration(unitWithProration)`. */ + fun price(unitWithProration: NewPlanUnitWithProrationPrice) = + price(Price.ofUnitWithProration(unitWithProration)) - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** Alias for calling [price] with `Price.ofGroupedAllocation(groupedAllocation)`. */ + fun price(groupedAllocation: NewPlanGroupedAllocationPrice) = + price(Price.ofGroupedAllocation(groupedAllocation)) - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** + * Alias for calling [price] with + * `Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)`. + */ + fun price(groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice) = + price(Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)) - fun toBuilder() = Builder().from(this) + /** + * Alias for calling [price] with + * `Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)`. + */ + fun price(groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice) = + price(Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)) - companion object { + /** + * Alias for calling [price] with + * `Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)`. + */ + fun price(groupedWithMinMaxThresholds: Price.GroupedWithMinMaxThresholds) = + price(Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)) /** - * Returns a mutable builder for constructing an instance of [RemovePrice]. - * - * The following fields are required: - * ```kotlin - * .priceId() - * ``` + * Alias for calling [price] with + * `Price.ofMatrixWithDisplayName(matrixWithDisplayName)`. */ - fun builder() = Builder() - } + fun price(matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice) = + price(Price.ofMatrixWithDisplayName(matrixWithDisplayName)) - /** A builder for [RemovePrice]. */ - class Builder internal constructor() { + /** Alias for calling [price] with `Price.ofBulkWithProration(bulkWithProration)`. */ + fun price(bulkWithProration: NewPlanBulkWithProrationPrice) = + price(Price.ofBulkWithProration(bulkWithProration)) - private var priceId: JsonField? = null - private var planPhaseOrder: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + /** + * Alias for calling [price] with `Price.ofGroupedTieredPackage(groupedTieredPackage)`. + */ + fun price(groupedTieredPackage: NewPlanGroupedTieredPackagePrice) = + price(Price.ofGroupedTieredPackage(groupedTieredPackage)) - internal fun from(removePrice: RemovePrice) = apply { - priceId = removePrice.priceId - planPhaseOrder = removePrice.planPhaseOrder - additionalProperties = removePrice.additionalProperties.toMutableMap() - } + /** + * Alias for calling [price] with + * `Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)`. + */ + fun price(maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice) = + price(Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)) - /** The id of the price to remove from the plan. */ - fun priceId(priceId: String) = priceId(JsonField.of(priceId)) + /** + * Alias for calling [price] with + * `Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)`. + */ + fun price(scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice) = + price(Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)) /** - * Sets [Builder.priceId] to an arbitrary JSON value. - * - * You should usually call [Builder.priceId] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. + * Alias for calling [price] with + * `Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)`. */ - fun priceId(priceId: JsonField) = apply { this.priceId = priceId } + fun price( + scalableMatrixWithTieredPricing: NewPlanScalableMatrixWithTieredPricingPrice + ) = price(Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)) - /** The phase to remove this price from. */ - fun planPhaseOrder(planPhaseOrder: Long?) = - planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + /** + * Alias for calling [price] with + * `Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)`. + */ + fun price(cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice) = + price(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) /** - * Alias for [Builder.planPhaseOrder]. - * - * This unboxed primitive overload exists for backwards compatibility. + * Alias for calling [price] with + * `Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)`. */ - fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + fun price(tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice) = + price(Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)) /** - * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. - * - * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. + * Alias for calling [price] with `Price.ofMatrixWithAllocation(matrixWithAllocation)`. */ - fun planPhaseOrder(planPhaseOrder: JsonField) = apply { - this.planPhaseOrder = planPhaseOrder - } + fun price(matrixWithAllocation: NewPlanMatrixWithAllocationPrice) = + price(Price.ofMatrixWithAllocation(matrixWithAllocation)) + + /** Alias for calling [price] with `Price.ofGroupedTiered(groupedTiered)`. */ + fun price(groupedTiered: NewPlanGroupedTieredPrice) = + price(Price.ofGroupedTiered(groupedTiered)) + + /** Alias for calling [price] with `Price.ofMinimum(minimum)`. */ + fun price(minimum: NewPlanMinimumCompositePrice) = price(Price.ofMinimum(minimum)) fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -6577,34 +6059,38 @@ private constructor( } /** - * Returns an immutable instance of [RemovePrice]. + * Returns an immutable instance of [ReplacePrice]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```kotlin - * .priceId() + * .replacesPriceId() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): RemovePrice = - RemovePrice( - checkRequired("priceId", priceId), + fun build(): ReplacePrice = + ReplacePrice( + checkRequired("replacesPriceId", replacesPriceId), + allocationPrice, planPhaseOrder, + price, additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): RemovePrice = apply { + fun validate(): ReplacePrice = apply { if (validated) { return@apply } - priceId() + replacesPriceId() + allocationPrice()?.validate() planPhaseOrder() + price()?.validate() validated = true } @@ -6623,3663 +6109,1139 @@ private constructor( * Used for best match union deserialization. */ internal fun validity(): Int = - (if (priceId.asKnown() == null) 0 else 1) + - (if (planPhaseOrder.asKnown() == null) 0 else 1) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is RemovePrice && - priceId == other.priceId && - planPhaseOrder == other.planPhaseOrder && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(priceId, planPhaseOrder, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "RemovePrice{priceId=$priceId, planPhaseOrder=$planPhaseOrder, additionalProperties=$additionalProperties}" - } + (if (replacesPriceId.asKnown() == null) 0 else 1) + + (allocationPrice.asKnown()?.validity() ?: 0) + + (if (planPhaseOrder.asKnown() == null) 0 else 1) + + (price.asKnown()?.validity() ?: 0) - class ReplaceAdjustment - private constructor( - private val adjustment: JsonField, - private val replacesAdjustmentId: JsonField, - private val planPhaseOrder: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator + /** The price to add to the plan */ + @JsonDeserialize(using = Price.Deserializer::class) + @JsonSerialize(using = Price.Serializer::class) + class Price private constructor( - @JsonProperty("adjustment") - @ExcludeMissing - adjustment: JsonField = JsonMissing.of(), - @JsonProperty("replaces_adjustment_id") - @ExcludeMissing - replacesAdjustmentId: JsonField = JsonMissing.of(), - @JsonProperty("plan_phase_order") - @ExcludeMissing - planPhaseOrder: JsonField = JsonMissing.of(), - ) : this(adjustment, replacesAdjustmentId, planPhaseOrder, mutableMapOf()) + private val unit: NewPlanUnitPrice? = null, + private val package_: NewPlanPackagePrice? = null, + private val matrix: NewPlanMatrixPrice? = null, + private val tiered: NewPlanTieredPrice? = null, + private val bulk: NewPlanBulkPrice? = null, + private val thresholdTotalAmount: NewPlanThresholdTotalAmountPrice? = null, + private val tieredPackage: NewPlanTieredPackagePrice? = null, + private val tieredWithMinimum: NewPlanTieredWithMinimumPrice? = null, + private val unitWithPercent: NewPlanUnitWithPercentPrice? = null, + private val packageWithAllocation: NewPlanPackageWithAllocationPrice? = null, + private val tieredWithProration: NewPlanTierWithProrationPrice? = null, + private val unitWithProration: NewPlanUnitWithProrationPrice? = null, + private val groupedAllocation: NewPlanGroupedAllocationPrice? = null, + private val groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice? = null, + private val groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice? = null, + private val groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds? = null, + private val matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice? = null, + private val bulkWithProration: NewPlanBulkWithProrationPrice? = null, + private val groupedTieredPackage: NewPlanGroupedTieredPackagePrice? = null, + private val maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice? = null, + private val scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice? = + null, + private val scalableMatrixWithTieredPricing: + NewPlanScalableMatrixWithTieredPricingPrice? = + null, + private val cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice? = null, + private val tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice? = null, + private val matrixWithAllocation: NewPlanMatrixWithAllocationPrice? = null, + private val groupedTiered: NewPlanGroupedTieredPrice? = null, + private val minimum: NewPlanMinimumCompositePrice? = null, + private val _json: JsonValue? = null, + ) { - /** - * The definition of a new adjustment to create and add to the plan. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun adjustment(): Adjustment = adjustment.getRequired("adjustment") + fun unit(): NewPlanUnitPrice? = unit - /** - * The id of the adjustment on the plan to replace in the plan. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun replacesAdjustmentId(): String = - replacesAdjustmentId.getRequired("replaces_adjustment_id") + fun package_(): NewPlanPackagePrice? = package_ - /** - * The phase to replace this adjustment from. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun planPhaseOrder(): Long? = planPhaseOrder.getNullable("plan_phase_order") + fun matrix(): NewPlanMatrixPrice? = matrix - /** - * Returns the raw JSON value of [adjustment]. - * - * Unlike [adjustment], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("adjustment") - @ExcludeMissing - fun _adjustment(): JsonField = adjustment + fun tiered(): NewPlanTieredPrice? = tiered - /** - * Returns the raw JSON value of [replacesAdjustmentId]. - * - * Unlike [replacesAdjustmentId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("replaces_adjustment_id") - @ExcludeMissing - fun _replacesAdjustmentId(): JsonField = replacesAdjustmentId + fun bulk(): NewPlanBulkPrice? = bulk - /** - * Returns the raw JSON value of [planPhaseOrder]. - * - * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("plan_phase_order") - @ExcludeMissing - fun _planPhaseOrder(): JsonField = planPhaseOrder + fun thresholdTotalAmount(): NewPlanThresholdTotalAmountPrice? = thresholdTotalAmount - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + fun tieredPackage(): NewPlanTieredPackagePrice? = tieredPackage - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + fun tieredWithMinimum(): NewPlanTieredWithMinimumPrice? = tieredWithMinimum - fun toBuilder() = Builder().from(this) + fun unitWithPercent(): NewPlanUnitWithPercentPrice? = unitWithPercent - companion object { + fun packageWithAllocation(): NewPlanPackageWithAllocationPrice? = packageWithAllocation - /** - * Returns a mutable builder for constructing an instance of [ReplaceAdjustment]. - * - * The following fields are required: - * ```kotlin - * .adjustment() - * .replacesAdjustmentId() - * ``` - */ - fun builder() = Builder() - } + fun tieredWithProration(): NewPlanTierWithProrationPrice? = tieredWithProration - /** A builder for [ReplaceAdjustment]. */ - class Builder internal constructor() { + fun unitWithProration(): NewPlanUnitWithProrationPrice? = unitWithProration - private var adjustment: JsonField? = null - private var replacesAdjustmentId: JsonField? = null - private var planPhaseOrder: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + fun groupedAllocation(): NewPlanGroupedAllocationPrice? = groupedAllocation - internal fun from(replaceAdjustment: ReplaceAdjustment) = apply { - adjustment = replaceAdjustment.adjustment - replacesAdjustmentId = replaceAdjustment.replacesAdjustmentId - planPhaseOrder = replaceAdjustment.planPhaseOrder - additionalProperties = replaceAdjustment.additionalProperties.toMutableMap() - } + fun groupedWithProratedMinimum(): NewPlanGroupedWithProratedMinimumPrice? = + groupedWithProratedMinimum - /** The definition of a new adjustment to create and add to the plan. */ - fun adjustment(adjustment: Adjustment) = adjustment(JsonField.of(adjustment)) + fun groupedWithMeteredMinimum(): NewPlanGroupedWithMeteredMinimumPrice? = + groupedWithMeteredMinimum - /** - * Sets [Builder.adjustment] to an arbitrary JSON value. - * - * You should usually call [Builder.adjustment] with a well-typed [Adjustment] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun adjustment(adjustment: JsonField) = apply { - this.adjustment = adjustment - } + fun groupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds? = + groupedWithMinMaxThresholds - /** - * Alias for calling [adjustment] with - * `Adjustment.ofPercentageDiscount(percentageDiscount)`. - */ - fun adjustment(percentageDiscount: NewPercentageDiscount) = - adjustment(Adjustment.ofPercentageDiscount(percentageDiscount)) + fun matrixWithDisplayName(): NewPlanMatrixWithDisplayNamePrice? = matrixWithDisplayName - /** - * Alias for calling [adjustment] with the following: - * ```kotlin - * NewPercentageDiscount.builder() - * .adjustmentType(NewPercentageDiscount.AdjustmentType.PERCENTAGE_DISCOUNT) - * .percentageDiscount(percentageDiscount) - * .build() - * ``` - */ - fun percentageDiscountAdjustment(percentageDiscount: Double) = - adjustment( - NewPercentageDiscount.builder() - .adjustmentType(NewPercentageDiscount.AdjustmentType.PERCENTAGE_DISCOUNT) - .percentageDiscount(percentageDiscount) - .build() - ) + fun bulkWithProration(): NewPlanBulkWithProrationPrice? = bulkWithProration - /** Alias for calling [adjustment] with `Adjustment.ofUsageDiscount(usageDiscount)`. */ - fun adjustment(usageDiscount: NewUsageDiscount) = - adjustment(Adjustment.ofUsageDiscount(usageDiscount)) + fun groupedTieredPackage(): NewPlanGroupedTieredPackagePrice? = groupedTieredPackage - /** - * Alias for calling [adjustment] with the following: - * ```kotlin - * NewUsageDiscount.builder() - * .adjustmentType(NewUsageDiscount.AdjustmentType.USAGE_DISCOUNT) - * .usageDiscount(usageDiscount) - * .build() - * ``` - */ - fun usageDiscountAdjustment(usageDiscount: Double) = - adjustment( - NewUsageDiscount.builder() - .adjustmentType(NewUsageDiscount.AdjustmentType.USAGE_DISCOUNT) - .usageDiscount(usageDiscount) - .build() - ) + fun maxGroupTieredPackage(): NewPlanMaxGroupTieredPackagePrice? = maxGroupTieredPackage - /** - * Alias for calling [adjustment] with `Adjustment.ofAmountDiscount(amountDiscount)`. - */ - fun adjustment(amountDiscount: NewAmountDiscount) = - adjustment(Adjustment.ofAmountDiscount(amountDiscount)) + fun scalableMatrixWithUnitPricing(): NewPlanScalableMatrixWithUnitPricingPrice? = + scalableMatrixWithUnitPricing - /** - * Alias for calling [adjustment] with the following: - * ```kotlin - * NewAmountDiscount.builder() - * .adjustmentType(NewAmountDiscount.AdjustmentType.AMOUNT_DISCOUNT) - * .amountDiscount(amountDiscount) - * .build() - * ``` - */ - fun amountDiscountAdjustment(amountDiscount: String) = - adjustment( - NewAmountDiscount.builder() - .adjustmentType(NewAmountDiscount.AdjustmentType.AMOUNT_DISCOUNT) - .amountDiscount(amountDiscount) - .build() - ) + fun scalableMatrixWithTieredPricing(): NewPlanScalableMatrixWithTieredPricingPrice? = + scalableMatrixWithTieredPricing - /** Alias for calling [adjustment] with `Adjustment.ofMinimum(minimum)`. */ - fun adjustment(minimum: NewMinimum) = adjustment(Adjustment.ofMinimum(minimum)) + fun cumulativeGroupedBulk(): NewPlanCumulativeGroupedBulkPrice? = cumulativeGroupedBulk - /** Alias for calling [adjustment] with `Adjustment.ofMaximum(maximum)`. */ - fun adjustment(maximum: NewMaximum) = adjustment(Adjustment.ofMaximum(maximum)) + fun tieredPackageWithMinimum(): NewPlanTieredPackageWithMinimumPrice? = + tieredPackageWithMinimum - /** - * Alias for calling [adjustment] with the following: - * ```kotlin - * NewMaximum.builder() - * .adjustmentType(NewMaximum.AdjustmentType.MAXIMUM) - * .maximumAmount(maximumAmount) - * .build() - * ``` - */ - fun maximumAdjustment(maximumAmount: String) = - adjustment( - NewMaximum.builder() - .adjustmentType(NewMaximum.AdjustmentType.MAXIMUM) - .maximumAmount(maximumAmount) - .build() - ) + fun matrixWithAllocation(): NewPlanMatrixWithAllocationPrice? = matrixWithAllocation - /** The id of the adjustment on the plan to replace in the plan. */ - fun replacesAdjustmentId(replacesAdjustmentId: String) = - replacesAdjustmentId(JsonField.of(replacesAdjustmentId)) + fun groupedTiered(): NewPlanGroupedTieredPrice? = groupedTiered - /** - * Sets [Builder.replacesAdjustmentId] to an arbitrary JSON value. - * - * You should usually call [Builder.replacesAdjustmentId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun replacesAdjustmentId(replacesAdjustmentId: JsonField) = apply { - this.replacesAdjustmentId = replacesAdjustmentId - } + fun minimum(): NewPlanMinimumCompositePrice? = minimum - /** The phase to replace this adjustment from. */ - fun planPhaseOrder(planPhaseOrder: Long?) = - planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + fun isUnit(): Boolean = unit != null - /** - * Alias for [Builder.planPhaseOrder]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + fun isPackage(): Boolean = package_ != null - /** - * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. - * - * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun planPhaseOrder(planPhaseOrder: JsonField) = apply { - this.planPhaseOrder = planPhaseOrder - } + fun isMatrix(): Boolean = matrix != null - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun isTiered(): Boolean = tiered != null - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun isBulk(): Boolean = bulk != null - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun isThresholdTotalAmount(): Boolean = thresholdTotalAmount != null - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun isTieredPackage(): Boolean = tieredPackage != null - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun isTieredWithMinimum(): Boolean = tieredWithMinimum != null - /** - * Returns an immutable instance of [ReplaceAdjustment]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```kotlin - * .adjustment() - * .replacesAdjustmentId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): ReplaceAdjustment = - ReplaceAdjustment( - checkRequired("adjustment", adjustment), - checkRequired("replacesAdjustmentId", replacesAdjustmentId), - planPhaseOrder, - additionalProperties.toMutableMap(), - ) - } + fun isUnitWithPercent(): Boolean = unitWithPercent != null - private var validated: Boolean = false + fun isPackageWithAllocation(): Boolean = packageWithAllocation != null - fun validate(): ReplaceAdjustment = apply { - if (validated) { - return@apply - } + fun isTieredWithProration(): Boolean = tieredWithProration != null - adjustment().validate() - replacesAdjustmentId() - planPhaseOrder() - validated = true - } + fun isUnitWithProration(): Boolean = unitWithProration != null - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + fun isGroupedAllocation(): Boolean = groupedAllocation != null - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (adjustment.asKnown()?.validity() ?: 0) + - (if (replacesAdjustmentId.asKnown() == null) 0 else 1) + - (if (planPhaseOrder.asKnown() == null) 0 else 1) + fun isGroupedWithProratedMinimum(): Boolean = groupedWithProratedMinimum != null - /** The definition of a new adjustment to create and add to the plan. */ - @JsonDeserialize(using = Adjustment.Deserializer::class) - @JsonSerialize(using = Adjustment.Serializer::class) - class Adjustment - private constructor( - private val percentageDiscount: NewPercentageDiscount? = null, - private val usageDiscount: NewUsageDiscount? = null, - private val amountDiscount: NewAmountDiscount? = null, - private val minimum: NewMinimum? = null, - private val maximum: NewMaximum? = null, - private val _json: JsonValue? = null, - ) { + fun isGroupedWithMeteredMinimum(): Boolean = groupedWithMeteredMinimum != null - fun percentageDiscount(): NewPercentageDiscount? = percentageDiscount + fun isGroupedWithMinMaxThresholds(): Boolean = groupedWithMinMaxThresholds != null - fun usageDiscount(): NewUsageDiscount? = usageDiscount + fun isMatrixWithDisplayName(): Boolean = matrixWithDisplayName != null - fun amountDiscount(): NewAmountDiscount? = amountDiscount + fun isBulkWithProration(): Boolean = bulkWithProration != null - fun minimum(): NewMinimum? = minimum + fun isGroupedTieredPackage(): Boolean = groupedTieredPackage != null - fun maximum(): NewMaximum? = maximum + fun isMaxGroupTieredPackage(): Boolean = maxGroupTieredPackage != null - fun isPercentageDiscount(): Boolean = percentageDiscount != null + fun isScalableMatrixWithUnitPricing(): Boolean = scalableMatrixWithUnitPricing != null - fun isUsageDiscount(): Boolean = usageDiscount != null + fun isScalableMatrixWithTieredPricing(): Boolean = + scalableMatrixWithTieredPricing != null - fun isAmountDiscount(): Boolean = amountDiscount != null + fun isCumulativeGroupedBulk(): Boolean = cumulativeGroupedBulk != null - fun isMinimum(): Boolean = minimum != null + fun isTieredPackageWithMinimum(): Boolean = tieredPackageWithMinimum != null - fun isMaximum(): Boolean = maximum != null + fun isMatrixWithAllocation(): Boolean = matrixWithAllocation != null - fun asPercentageDiscount(): NewPercentageDiscount = - percentageDiscount.getOrThrow("percentageDiscount") + fun isGroupedTiered(): Boolean = groupedTiered != null - fun asUsageDiscount(): NewUsageDiscount = usageDiscount.getOrThrow("usageDiscount") + fun isMinimum(): Boolean = minimum != null - fun asAmountDiscount(): NewAmountDiscount = amountDiscount.getOrThrow("amountDiscount") + fun asUnit(): NewPlanUnitPrice = unit.getOrThrow("unit") - fun asMinimum(): NewMinimum = minimum.getOrThrow("minimum") + fun asPackage(): NewPlanPackagePrice = package_.getOrThrow("package_") - fun asMaximum(): NewMaximum = maximum.getOrThrow("maximum") + fun asMatrix(): NewPlanMatrixPrice = matrix.getOrThrow("matrix") - fun _json(): JsonValue? = _json + fun asTiered(): NewPlanTieredPrice = tiered.getOrThrow("tiered") - fun accept(visitor: Visitor): T = - when { - percentageDiscount != null -> - visitor.visitPercentageDiscount(percentageDiscount) - usageDiscount != null -> visitor.visitUsageDiscount(usageDiscount) - amountDiscount != null -> visitor.visitAmountDiscount(amountDiscount) - minimum != null -> visitor.visitMinimum(minimum) - maximum != null -> visitor.visitMaximum(maximum) - else -> visitor.unknown(_json) - } + fun asBulk(): NewPlanBulkPrice = bulk.getOrThrow("bulk") - private var validated: Boolean = false + fun asThresholdTotalAmount(): NewPlanThresholdTotalAmountPrice = + thresholdTotalAmount.getOrThrow("thresholdTotalAmount") - fun validate(): Adjustment = apply { - if (validated) { - return@apply - } + fun asTieredPackage(): NewPlanTieredPackagePrice = + tieredPackage.getOrThrow("tieredPackage") - accept( - object : Visitor { - override fun visitPercentageDiscount( - percentageDiscount: NewPercentageDiscount - ) { - percentageDiscount.validate() - } + fun asTieredWithMinimum(): NewPlanTieredWithMinimumPrice = + tieredWithMinimum.getOrThrow("tieredWithMinimum") - override fun visitUsageDiscount(usageDiscount: NewUsageDiscount) { - usageDiscount.validate() - } + fun asUnitWithPercent(): NewPlanUnitWithPercentPrice = + unitWithPercent.getOrThrow("unitWithPercent") - override fun visitAmountDiscount(amountDiscount: NewAmountDiscount) { - amountDiscount.validate() - } + fun asPackageWithAllocation(): NewPlanPackageWithAllocationPrice = + packageWithAllocation.getOrThrow("packageWithAllocation") - override fun visitMinimum(minimum: NewMinimum) { - minimum.validate() - } + fun asTieredWithProration(): NewPlanTierWithProrationPrice = + tieredWithProration.getOrThrow("tieredWithProration") - override fun visitMaximum(maximum: NewMaximum) { - maximum.validate() - } - } - ) - validated = true - } + fun asUnitWithProration(): NewPlanUnitWithProrationPrice = + unitWithProration.getOrThrow("unitWithProration") - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + fun asGroupedAllocation(): NewPlanGroupedAllocationPrice = + groupedAllocation.getOrThrow("groupedAllocation") - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitPercentageDiscount( - percentageDiscount: NewPercentageDiscount - ) = percentageDiscount.validity() + fun asGroupedWithProratedMinimum(): NewPlanGroupedWithProratedMinimumPrice = + groupedWithProratedMinimum.getOrThrow("groupedWithProratedMinimum") - override fun visitUsageDiscount(usageDiscount: NewUsageDiscount) = - usageDiscount.validity() + fun asGroupedWithMeteredMinimum(): NewPlanGroupedWithMeteredMinimumPrice = + groupedWithMeteredMinimum.getOrThrow("groupedWithMeteredMinimum") - override fun visitAmountDiscount(amountDiscount: NewAmountDiscount) = - amountDiscount.validity() + fun asGroupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds = + groupedWithMinMaxThresholds.getOrThrow("groupedWithMinMaxThresholds") - override fun visitMinimum(minimum: NewMinimum) = minimum.validity() + fun asMatrixWithDisplayName(): NewPlanMatrixWithDisplayNamePrice = + matrixWithDisplayName.getOrThrow("matrixWithDisplayName") - override fun visitMaximum(maximum: NewMaximum) = maximum.validity() + fun asBulkWithProration(): NewPlanBulkWithProrationPrice = + bulkWithProration.getOrThrow("bulkWithProration") - override fun unknown(json: JsonValue?) = 0 - } - ) + fun asGroupedTieredPackage(): NewPlanGroupedTieredPackagePrice = + groupedTieredPackage.getOrThrow("groupedTieredPackage") - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + fun asMaxGroupTieredPackage(): NewPlanMaxGroupTieredPackagePrice = + maxGroupTieredPackage.getOrThrow("maxGroupTieredPackage") - return other is Adjustment && - percentageDiscount == other.percentageDiscount && - usageDiscount == other.usageDiscount && - amountDiscount == other.amountDiscount && - minimum == other.minimum && - maximum == other.maximum - } + fun asScalableMatrixWithUnitPricing(): NewPlanScalableMatrixWithUnitPricingPrice = + scalableMatrixWithUnitPricing.getOrThrow("scalableMatrixWithUnitPricing") - override fun hashCode(): Int = - Objects.hash(percentageDiscount, usageDiscount, amountDiscount, minimum, maximum) + fun asScalableMatrixWithTieredPricing(): NewPlanScalableMatrixWithTieredPricingPrice = + scalableMatrixWithTieredPricing.getOrThrow("scalableMatrixWithTieredPricing") - override fun toString(): String = - when { - percentageDiscount != null -> - "Adjustment{percentageDiscount=$percentageDiscount}" - usageDiscount != null -> "Adjustment{usageDiscount=$usageDiscount}" - amountDiscount != null -> "Adjustment{amountDiscount=$amountDiscount}" - minimum != null -> "Adjustment{minimum=$minimum}" - maximum != null -> "Adjustment{maximum=$maximum}" - _json != null -> "Adjustment{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Adjustment") - } + fun asCumulativeGroupedBulk(): NewPlanCumulativeGroupedBulkPrice = + cumulativeGroupedBulk.getOrThrow("cumulativeGroupedBulk") - companion object { + fun asTieredPackageWithMinimum(): NewPlanTieredPackageWithMinimumPrice = + tieredPackageWithMinimum.getOrThrow("tieredPackageWithMinimum") - fun ofPercentageDiscount(percentageDiscount: NewPercentageDiscount) = - Adjustment(percentageDiscount = percentageDiscount) + fun asMatrixWithAllocation(): NewPlanMatrixWithAllocationPrice = + matrixWithAllocation.getOrThrow("matrixWithAllocation") - fun ofUsageDiscount(usageDiscount: NewUsageDiscount) = - Adjustment(usageDiscount = usageDiscount) + fun asGroupedTiered(): NewPlanGroupedTieredPrice = + groupedTiered.getOrThrow("groupedTiered") - fun ofAmountDiscount(amountDiscount: NewAmountDiscount) = - Adjustment(amountDiscount = amountDiscount) + fun asMinimum(): NewPlanMinimumCompositePrice = minimum.getOrThrow("minimum") - fun ofMinimum(minimum: NewMinimum) = Adjustment(minimum = minimum) + fun _json(): JsonValue? = _json - fun ofMaximum(maximum: NewMaximum) = Adjustment(maximum = maximum) - } + fun accept(visitor: Visitor): T = + when { + unit != null -> visitor.visitUnit(unit) + package_ != null -> visitor.visitPackage(package_) + matrix != null -> visitor.visitMatrix(matrix) + tiered != null -> visitor.visitTiered(tiered) + bulk != null -> visitor.visitBulk(bulk) + thresholdTotalAmount != null -> + visitor.visitThresholdTotalAmount(thresholdTotalAmount) + tieredPackage != null -> visitor.visitTieredPackage(tieredPackage) + tieredWithMinimum != null -> visitor.visitTieredWithMinimum(tieredWithMinimum) + unitWithPercent != null -> visitor.visitUnitWithPercent(unitWithPercent) + packageWithAllocation != null -> + visitor.visitPackageWithAllocation(packageWithAllocation) + tieredWithProration != null -> + visitor.visitTieredWithProration(tieredWithProration) + unitWithProration != null -> visitor.visitUnitWithProration(unitWithProration) + groupedAllocation != null -> visitor.visitGroupedAllocation(groupedAllocation) + groupedWithProratedMinimum != null -> + visitor.visitGroupedWithProratedMinimum(groupedWithProratedMinimum) + groupedWithMeteredMinimum != null -> + visitor.visitGroupedWithMeteredMinimum(groupedWithMeteredMinimum) + groupedWithMinMaxThresholds != null -> + visitor.visitGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds) + matrixWithDisplayName != null -> + visitor.visitMatrixWithDisplayName(matrixWithDisplayName) + bulkWithProration != null -> visitor.visitBulkWithProration(bulkWithProration) + groupedTieredPackage != null -> + visitor.visitGroupedTieredPackage(groupedTieredPackage) + maxGroupTieredPackage != null -> + visitor.visitMaxGroupTieredPackage(maxGroupTieredPackage) + scalableMatrixWithUnitPricing != null -> + visitor.visitScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing) + scalableMatrixWithTieredPricing != null -> + visitor.visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing + ) + cumulativeGroupedBulk != null -> + visitor.visitCumulativeGroupedBulk(cumulativeGroupedBulk) + tieredPackageWithMinimum != null -> + visitor.visitTieredPackageWithMinimum(tieredPackageWithMinimum) + matrixWithAllocation != null -> + visitor.visitMatrixWithAllocation(matrixWithAllocation) + groupedTiered != null -> visitor.visitGroupedTiered(groupedTiered) + minimum != null -> visitor.visitMinimum(minimum) + else -> visitor.unknown(_json) + } - /** - * An interface that defines how to map each variant of [Adjustment] to a value of type - * [T]. - */ - interface Visitor { + private var validated: Boolean = false - fun visitPercentageDiscount(percentageDiscount: NewPercentageDiscount): T + fun validate(): Price = apply { + if (validated) { + return@apply + } - fun visitUsageDiscount(usageDiscount: NewUsageDiscount): T + accept( + object : Visitor { + override fun visitUnit(unit: NewPlanUnitPrice) { + unit.validate() + } - fun visitAmountDiscount(amountDiscount: NewAmountDiscount): T + override fun visitPackage(package_: NewPlanPackagePrice) { + package_.validate() + } - fun visitMinimum(minimum: NewMinimum): T + override fun visitMatrix(matrix: NewPlanMatrixPrice) { + matrix.validate() + } - fun visitMaximum(maximum: NewMaximum): T + override fun visitTiered(tiered: NewPlanTieredPrice) { + tiered.validate() + } - /** - * Maps an unknown variant of [Adjustment] to a value of type [T]. - * - * An instance of [Adjustment] can contain an unknown variant if it was deserialized - * from data that doesn't match any known variant. For example, if the SDK is on an - * older version than the API, then the API may respond with new variants that the - * SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown Adjustment: $json") - } - } + override fun visitBulk(bulk: NewPlanBulkPrice) { + bulk.validate() + } - internal class Deserializer : BaseDeserializer(Adjustment::class) { + override fun visitThresholdTotalAmount( + thresholdTotalAmount: NewPlanThresholdTotalAmountPrice + ) { + thresholdTotalAmount.validate() + } - override fun ObjectCodec.deserialize(node: JsonNode): Adjustment { - val json = JsonValue.fromJsonNode(node) - val adjustmentType = json.asObject()?.get("adjustment_type")?.asString() + override fun visitTieredPackage(tieredPackage: NewPlanTieredPackagePrice) { + tieredPackage.validate() + } - when (adjustmentType) { - "percentage_discount" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Adjustment(percentageDiscount = it, _json = json) } - ?: Adjustment(_json = json) + override fun visitTieredWithMinimum( + tieredWithMinimum: NewPlanTieredWithMinimumPrice + ) { + tieredWithMinimum.validate() } - "usage_discount" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(usageDiscount = it, _json = json) - } ?: Adjustment(_json = json) + + override fun visitUnitWithPercent( + unitWithPercent: NewPlanUnitWithPercentPrice + ) { + unitWithPercent.validate() } - "amount_discount" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(amountDiscount = it, _json = json) - } ?: Adjustment(_json = json) + + override fun visitPackageWithAllocation( + packageWithAllocation: NewPlanPackageWithAllocationPrice + ) { + packageWithAllocation.validate() } - "minimum" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(minimum = it, _json = json) - } ?: Adjustment(_json = json) + + override fun visitTieredWithProration( + tieredWithProration: NewPlanTierWithProrationPrice + ) { + tieredWithProration.validate() } - "maximum" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(maximum = it, _json = json) - } ?: Adjustment(_json = json) + + override fun visitUnitWithProration( + unitWithProration: NewPlanUnitWithProrationPrice + ) { + unitWithProration.validate() } - } - return Adjustment(_json = json) - } - } + override fun visitGroupedAllocation( + groupedAllocation: NewPlanGroupedAllocationPrice + ) { + groupedAllocation.validate() + } - internal class Serializer : BaseSerializer(Adjustment::class) { + override fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice + ) { + groupedWithProratedMinimum.validate() + } - override fun serialize( - value: Adjustment, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.percentageDiscount != null -> - generator.writeObject(value.percentageDiscount) - value.usageDiscount != null -> generator.writeObject(value.usageDiscount) - value.amountDiscount != null -> generator.writeObject(value.amountDiscount) - value.minimum != null -> generator.writeObject(value.minimum) - value.maximum != null -> generator.writeObject(value.maximum) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Adjustment") - } - } - } - } + override fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice + ) { + groupedWithMeteredMinimum.validate() + } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + override fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) { + groupedWithMinMaxThresholds.validate() + } - return other is ReplaceAdjustment && - adjustment == other.adjustment && - replacesAdjustmentId == other.replacesAdjustmentId && - planPhaseOrder == other.planPhaseOrder && - additionalProperties == other.additionalProperties - } + override fun visitMatrixWithDisplayName( + matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice + ) { + matrixWithDisplayName.validate() + } - private val hashCode: Int by lazy { - Objects.hash(adjustment, replacesAdjustmentId, planPhaseOrder, additionalProperties) - } + override fun visitBulkWithProration( + bulkWithProration: NewPlanBulkWithProrationPrice + ) { + bulkWithProration.validate() + } - override fun hashCode(): Int = hashCode + override fun visitGroupedTieredPackage( + groupedTieredPackage: NewPlanGroupedTieredPackagePrice + ) { + groupedTieredPackage.validate() + } - override fun toString() = - "ReplaceAdjustment{adjustment=$adjustment, replacesAdjustmentId=$replacesAdjustmentId, planPhaseOrder=$planPhaseOrder, additionalProperties=$additionalProperties}" - } + override fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice + ) { + maxGroupTieredPackage.validate() + } - class ReplacePrice - private constructor( - private val replacesPriceId: JsonField, - private val allocationPrice: JsonField, - private val planPhaseOrder: JsonField, - private val price: JsonField, - private val additionalProperties: MutableMap, - ) { + override fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice + ) { + scalableMatrixWithUnitPricing.validate() + } - @JsonCreator - private constructor( - @JsonProperty("replaces_price_id") - @ExcludeMissing - replacesPriceId: JsonField = JsonMissing.of(), - @JsonProperty("allocation_price") - @ExcludeMissing - allocationPrice: JsonField = JsonMissing.of(), - @JsonProperty("plan_phase_order") - @ExcludeMissing - planPhaseOrder: JsonField = JsonMissing.of(), - @JsonProperty("price") @ExcludeMissing price: JsonField = JsonMissing.of(), - ) : this(replacesPriceId, allocationPrice, planPhaseOrder, price, mutableMapOf()) + override fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: + NewPlanScalableMatrixWithTieredPricingPrice + ) { + scalableMatrixWithTieredPricing.validate() + } - /** - * The id of the price on the plan to replace in the plan. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun replacesPriceId(): String = replacesPriceId.getRequired("replaces_price_id") + override fun visitCumulativeGroupedBulk( + cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice + ) { + cumulativeGroupedBulk.validate() + } - /** - * The allocation price to add to the plan. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun allocationPrice(): NewAllocationPrice? = allocationPrice.getNullable("allocation_price") + override fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice + ) { + tieredPackageWithMinimum.validate() + } - /** - * The phase to replace this price from. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun planPhaseOrder(): Long? = planPhaseOrder.getNullable("plan_phase_order") + override fun visitMatrixWithAllocation( + matrixWithAllocation: NewPlanMatrixWithAllocationPrice + ) { + matrixWithAllocation.validate() + } - /** - * The price to add to the plan - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun price(): Price? = price.getNullable("price") + override fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) { + groupedTiered.validate() + } - /** - * Returns the raw JSON value of [replacesPriceId]. - * - * Unlike [replacesPriceId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("replaces_price_id") - @ExcludeMissing - fun _replacesPriceId(): JsonField = replacesPriceId + override fun visitMinimum(minimum: NewPlanMinimumCompositePrice) { + minimum.validate() + } + } + ) + validated = true + } - /** - * Returns the raw JSON value of [allocationPrice]. - * - * Unlike [allocationPrice], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("allocation_price") - @ExcludeMissing - fun _allocationPrice(): JsonField = allocationPrice + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - /** - * Returns the raw JSON value of [planPhaseOrder]. - * - * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("plan_phase_order") - @ExcludeMissing - fun _planPhaseOrder(): JsonField = planPhaseOrder + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitUnit(unit: NewPlanUnitPrice) = unit.validity() - /** - * Returns the raw JSON value of [price]. - * - * Unlike [price], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("price") @ExcludeMissing fun _price(): JsonField = price + override fun visitPackage(package_: NewPlanPackagePrice) = + package_.validity() - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + override fun visitMatrix(matrix: NewPlanMatrixPrice) = matrix.validity() - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + override fun visitTiered(tiered: NewPlanTieredPrice) = tiered.validity() - fun toBuilder() = Builder().from(this) + override fun visitBulk(bulk: NewPlanBulkPrice) = bulk.validity() - companion object { + override fun visitThresholdTotalAmount( + thresholdTotalAmount: NewPlanThresholdTotalAmountPrice + ) = thresholdTotalAmount.validity() - /** - * Returns a mutable builder for constructing an instance of [ReplacePrice]. - * - * The following fields are required: - * ```kotlin - * .replacesPriceId() - * ``` - */ - fun builder() = Builder() - } + override fun visitTieredPackage(tieredPackage: NewPlanTieredPackagePrice) = + tieredPackage.validity() - /** A builder for [ReplacePrice]. */ - class Builder internal constructor() { + override fun visitTieredWithMinimum( + tieredWithMinimum: NewPlanTieredWithMinimumPrice + ) = tieredWithMinimum.validity() - private var replacesPriceId: JsonField? = null - private var allocationPrice: JsonField = JsonMissing.of() - private var planPhaseOrder: JsonField = JsonMissing.of() - private var price: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + override fun visitUnitWithPercent( + unitWithPercent: NewPlanUnitWithPercentPrice + ) = unitWithPercent.validity() - internal fun from(replacePrice: ReplacePrice) = apply { - replacesPriceId = replacePrice.replacesPriceId - allocationPrice = replacePrice.allocationPrice - planPhaseOrder = replacePrice.planPhaseOrder - price = replacePrice.price - additionalProperties = replacePrice.additionalProperties.toMutableMap() - } + override fun visitPackageWithAllocation( + packageWithAllocation: NewPlanPackageWithAllocationPrice + ) = packageWithAllocation.validity() - /** The id of the price on the plan to replace in the plan. */ - fun replacesPriceId(replacesPriceId: String) = - replacesPriceId(JsonField.of(replacesPriceId)) + override fun visitTieredWithProration( + tieredWithProration: NewPlanTierWithProrationPrice + ) = tieredWithProration.validity() - /** - * Sets [Builder.replacesPriceId] to an arbitrary JSON value. - * - * You should usually call [Builder.replacesPriceId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun replacesPriceId(replacesPriceId: JsonField) = apply { - this.replacesPriceId = replacesPriceId - } + override fun visitUnitWithProration( + unitWithProration: NewPlanUnitWithProrationPrice + ) = unitWithProration.validity() - /** The allocation price to add to the plan. */ - fun allocationPrice(allocationPrice: NewAllocationPrice?) = - allocationPrice(JsonField.ofNullable(allocationPrice)) + override fun visitGroupedAllocation( + groupedAllocation: NewPlanGroupedAllocationPrice + ) = groupedAllocation.validity() - /** - * Sets [Builder.allocationPrice] to an arbitrary JSON value. - * - * You should usually call [Builder.allocationPrice] with a well-typed - * [NewAllocationPrice] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun allocationPrice(allocationPrice: JsonField) = apply { - this.allocationPrice = allocationPrice - } + override fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice + ) = groupedWithProratedMinimum.validity() - /** The phase to replace this price from. */ - fun planPhaseOrder(planPhaseOrder: Long?) = - planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + override fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice + ) = groupedWithMeteredMinimum.validity() - /** - * Alias for [Builder.planPhaseOrder]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + override fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) = groupedWithMinMaxThresholds.validity() - /** - * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. - * - * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun planPhaseOrder(planPhaseOrder: JsonField) = apply { - this.planPhaseOrder = planPhaseOrder - } + override fun visitMatrixWithDisplayName( + matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice + ) = matrixWithDisplayName.validity() - /** The price to add to the plan */ - fun price(price: Price?) = price(JsonField.ofNullable(price)) + override fun visitBulkWithProration( + bulkWithProration: NewPlanBulkWithProrationPrice + ) = bulkWithProration.validity() - /** - * Sets [Builder.price] to an arbitrary JSON value. - * - * You should usually call [Builder.price] with a well-typed [Price] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun price(price: JsonField) = apply { this.price = price } + override fun visitGroupedTieredPackage( + groupedTieredPackage: NewPlanGroupedTieredPackagePrice + ) = groupedTieredPackage.validity() - /** Alias for calling [price] with `Price.ofUnit(unit)`. */ - fun price(unit: NewPlanUnitPrice) = price(Price.ofUnit(unit)) + override fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice + ) = maxGroupTieredPackage.validity() - /** Alias for calling [price] with `Price.ofPackage(package_)`. */ - fun price(package_: NewPlanPackagePrice) = price(Price.ofPackage(package_)) + override fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice + ) = scalableMatrixWithUnitPricing.validity() - /** Alias for calling [price] with `Price.ofMatrix(matrix)`. */ - fun price(matrix: NewPlanMatrixPrice) = price(Price.ofMatrix(matrix)) + override fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: + NewPlanScalableMatrixWithTieredPricingPrice + ) = scalableMatrixWithTieredPricing.validity() - /** Alias for calling [price] with `Price.ofTiered(tiered)`. */ - fun price(tiered: NewPlanTieredPrice) = price(Price.ofTiered(tiered)) + override fun visitCumulativeGroupedBulk( + cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice + ) = cumulativeGroupedBulk.validity() - /** Alias for calling [price] with `Price.ofBulk(bulk)`. */ - fun price(bulk: NewPlanBulkPrice) = price(Price.ofBulk(bulk)) + override fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice + ) = tieredPackageWithMinimum.validity() - /** - * Alias for calling [price] with `Price.ofThresholdTotalAmount(thresholdTotalAmount)`. - */ - fun price(thresholdTotalAmount: NewPlanThresholdTotalAmountPrice) = - price(Price.ofThresholdTotalAmount(thresholdTotalAmount)) + override fun visitMatrixWithAllocation( + matrixWithAllocation: NewPlanMatrixWithAllocationPrice + ) = matrixWithAllocation.validity() - /** Alias for calling [price] with `Price.ofTieredPackage(tieredPackage)`. */ - fun price(tieredPackage: NewPlanTieredPackagePrice) = - price(Price.ofTieredPackage(tieredPackage)) + override fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) = + groupedTiered.validity() - /** Alias for calling [price] with `Price.ofTieredWithMinimum(tieredWithMinimum)`. */ - fun price(tieredWithMinimum: NewPlanTieredWithMinimumPrice) = - price(Price.ofTieredWithMinimum(tieredWithMinimum)) + override fun visitMinimum(minimum: NewPlanMinimumCompositePrice) = + minimum.validity() - /** Alias for calling [price] with `Price.ofUnitWithPercent(unitWithPercent)`. */ - fun price(unitWithPercent: NewPlanUnitWithPercentPrice) = - price(Price.ofUnitWithPercent(unitWithPercent)) + override fun unknown(json: JsonValue?) = 0 + } + ) - /** - * Alias for calling [price] with - * `Price.ofPackageWithAllocation(packageWithAllocation)`. - */ - fun price(packageWithAllocation: NewPlanPackageWithAllocationPrice) = - price(Price.ofPackageWithAllocation(packageWithAllocation)) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * Alias for calling [price] with `Price.ofTieredWithProration(tieredWithProration)`. - */ - fun price(tieredWithProration: NewPlanTierWithProrationPrice) = - price(Price.ofTieredWithProration(tieredWithProration)) + return other is Price && + unit == other.unit && + package_ == other.package_ && + matrix == other.matrix && + tiered == other.tiered && + bulk == other.bulk && + thresholdTotalAmount == other.thresholdTotalAmount && + tieredPackage == other.tieredPackage && + tieredWithMinimum == other.tieredWithMinimum && + unitWithPercent == other.unitWithPercent && + packageWithAllocation == other.packageWithAllocation && + tieredWithProration == other.tieredWithProration && + unitWithProration == other.unitWithProration && + groupedAllocation == other.groupedAllocation && + groupedWithProratedMinimum == other.groupedWithProratedMinimum && + groupedWithMeteredMinimum == other.groupedWithMeteredMinimum && + groupedWithMinMaxThresholds == other.groupedWithMinMaxThresholds && + matrixWithDisplayName == other.matrixWithDisplayName && + bulkWithProration == other.bulkWithProration && + groupedTieredPackage == other.groupedTieredPackage && + maxGroupTieredPackage == other.maxGroupTieredPackage && + scalableMatrixWithUnitPricing == other.scalableMatrixWithUnitPricing && + scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && + cumulativeGroupedBulk == other.cumulativeGroupedBulk && + tieredPackageWithMinimum == other.tieredPackageWithMinimum && + matrixWithAllocation == other.matrixWithAllocation && + groupedTiered == other.groupedTiered && + minimum == other.minimum + } - /** Alias for calling [price] with `Price.ofUnitWithProration(unitWithProration)`. */ - fun price(unitWithProration: NewPlanUnitWithProrationPrice) = - price(Price.ofUnitWithProration(unitWithProration)) + override fun hashCode(): Int = + Objects.hash( + unit, + package_, + matrix, + tiered, + bulk, + thresholdTotalAmount, + tieredPackage, + tieredWithMinimum, + unitWithPercent, + packageWithAllocation, + tieredWithProration, + unitWithProration, + groupedAllocation, + groupedWithProratedMinimum, + groupedWithMeteredMinimum, + groupedWithMinMaxThresholds, + matrixWithDisplayName, + bulkWithProration, + groupedTieredPackage, + maxGroupTieredPackage, + scalableMatrixWithUnitPricing, + scalableMatrixWithTieredPricing, + cumulativeGroupedBulk, + tieredPackageWithMinimum, + matrixWithAllocation, + groupedTiered, + minimum, + ) - /** Alias for calling [price] with `Price.ofGroupedAllocation(groupedAllocation)`. */ - fun price(groupedAllocation: NewPlanGroupedAllocationPrice) = - price(Price.ofGroupedAllocation(groupedAllocation)) + override fun toString(): String = + when { + unit != null -> "Price{unit=$unit}" + package_ != null -> "Price{package_=$package_}" + matrix != null -> "Price{matrix=$matrix}" + tiered != null -> "Price{tiered=$tiered}" + bulk != null -> "Price{bulk=$bulk}" + thresholdTotalAmount != null -> + "Price{thresholdTotalAmount=$thresholdTotalAmount}" + tieredPackage != null -> "Price{tieredPackage=$tieredPackage}" + tieredWithMinimum != null -> "Price{tieredWithMinimum=$tieredWithMinimum}" + unitWithPercent != null -> "Price{unitWithPercent=$unitWithPercent}" + packageWithAllocation != null -> + "Price{packageWithAllocation=$packageWithAllocation}" + tieredWithProration != null -> "Price{tieredWithProration=$tieredWithProration}" + unitWithProration != null -> "Price{unitWithProration=$unitWithProration}" + groupedAllocation != null -> "Price{groupedAllocation=$groupedAllocation}" + groupedWithProratedMinimum != null -> + "Price{groupedWithProratedMinimum=$groupedWithProratedMinimum}" + groupedWithMeteredMinimum != null -> + "Price{groupedWithMeteredMinimum=$groupedWithMeteredMinimum}" + groupedWithMinMaxThresholds != null -> + "Price{groupedWithMinMaxThresholds=$groupedWithMinMaxThresholds}" + matrixWithDisplayName != null -> + "Price{matrixWithDisplayName=$matrixWithDisplayName}" + bulkWithProration != null -> "Price{bulkWithProration=$bulkWithProration}" + groupedTieredPackage != null -> + "Price{groupedTieredPackage=$groupedTieredPackage}" + maxGroupTieredPackage != null -> + "Price{maxGroupTieredPackage=$maxGroupTieredPackage}" + scalableMatrixWithUnitPricing != null -> + "Price{scalableMatrixWithUnitPricing=$scalableMatrixWithUnitPricing}" + scalableMatrixWithTieredPricing != null -> + "Price{scalableMatrixWithTieredPricing=$scalableMatrixWithTieredPricing}" + cumulativeGroupedBulk != null -> + "Price{cumulativeGroupedBulk=$cumulativeGroupedBulk}" + tieredPackageWithMinimum != null -> + "Price{tieredPackageWithMinimum=$tieredPackageWithMinimum}" + matrixWithAllocation != null -> + "Price{matrixWithAllocation=$matrixWithAllocation}" + groupedTiered != null -> "Price{groupedTiered=$groupedTiered}" + minimum != null -> "Price{minimum=$minimum}" + _json != null -> "Price{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Price") + } - /** - * Alias for calling [price] with - * `Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)`. - */ - fun price(groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice) = - price(Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)) + companion object { - /** - * Alias for calling [price] with - * `Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)`. - */ - fun price(groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice) = - price(Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)) + fun ofUnit(unit: NewPlanUnitPrice) = Price(unit = unit) - /** - * Alias for calling [price] with - * `Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)`. - */ - fun price(groupedWithMinMaxThresholds: Price.GroupedWithMinMaxThresholds) = - price(Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)) + fun ofPackage(package_: NewPlanPackagePrice) = Price(package_ = package_) - /** - * Alias for calling [price] with - * `Price.ofMatrixWithDisplayName(matrixWithDisplayName)`. - */ - fun price(matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice) = - price(Price.ofMatrixWithDisplayName(matrixWithDisplayName)) + fun ofMatrix(matrix: NewPlanMatrixPrice) = Price(matrix = matrix) - /** Alias for calling [price] with `Price.ofBulkWithProration(bulkWithProration)`. */ - fun price(bulkWithProration: NewPlanBulkWithProrationPrice) = - price(Price.ofBulkWithProration(bulkWithProration)) + fun ofTiered(tiered: NewPlanTieredPrice) = Price(tiered = tiered) - /** - * Alias for calling [price] with `Price.ofGroupedTieredPackage(groupedTieredPackage)`. - */ - fun price(groupedTieredPackage: NewPlanGroupedTieredPackagePrice) = - price(Price.ofGroupedTieredPackage(groupedTieredPackage)) + fun ofBulk(bulk: NewPlanBulkPrice) = Price(bulk = bulk) - /** - * Alias for calling [price] with - * `Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)`. - */ - fun price(maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice) = - price(Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)) + fun ofThresholdTotalAmount(thresholdTotalAmount: NewPlanThresholdTotalAmountPrice) = + Price(thresholdTotalAmount = thresholdTotalAmount) - /** - * Alias for calling [price] with - * `Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)`. - */ - fun price(scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice) = - price(Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)) - - /** - * Alias for calling [price] with - * `Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)`. - */ - fun price( - scalableMatrixWithTieredPricing: NewPlanScalableMatrixWithTieredPricingPrice - ) = price(Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)) + fun ofTieredPackage(tieredPackage: NewPlanTieredPackagePrice) = + Price(tieredPackage = tieredPackage) - /** - * Alias for calling [price] with - * `Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)`. - */ - fun price(cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice) = - price(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) + fun ofTieredWithMinimum(tieredWithMinimum: NewPlanTieredWithMinimumPrice) = + Price(tieredWithMinimum = tieredWithMinimum) - /** - * Alias for calling [price] with - * `Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)`. - */ - fun price(tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice) = - price(Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)) + fun ofUnitWithPercent(unitWithPercent: NewPlanUnitWithPercentPrice) = + Price(unitWithPercent = unitWithPercent) - /** - * Alias for calling [price] with `Price.ofMatrixWithAllocation(matrixWithAllocation)`. - */ - fun price(matrixWithAllocation: NewPlanMatrixWithAllocationPrice) = - price(Price.ofMatrixWithAllocation(matrixWithAllocation)) + fun ofPackageWithAllocation( + packageWithAllocation: NewPlanPackageWithAllocationPrice + ) = Price(packageWithAllocation = packageWithAllocation) - /** Alias for calling [price] with `Price.ofGroupedTiered(groupedTiered)`. */ - fun price(groupedTiered: NewPlanGroupedTieredPrice) = - price(Price.ofGroupedTiered(groupedTiered)) + fun ofTieredWithProration(tieredWithProration: NewPlanTierWithProrationPrice) = + Price(tieredWithProration = tieredWithProration) - /** Alias for calling [price] with `Price.ofMinimum(minimum)`. */ - fun price(minimum: Price.Minimum) = price(Price.ofMinimum(minimum)) + fun ofUnitWithProration(unitWithProration: NewPlanUnitWithProrationPrice) = + Price(unitWithProration = unitWithProration) - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun ofGroupedAllocation(groupedAllocation: NewPlanGroupedAllocationPrice) = + Price(groupedAllocation = groupedAllocation) - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun ofGroupedWithProratedMinimum( + groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice + ) = Price(groupedWithProratedMinimum = groupedWithProratedMinimum) - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun ofGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice + ) = Price(groupedWithMeteredMinimum = groupedWithMeteredMinimum) - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun ofGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) = Price(groupedWithMinMaxThresholds = groupedWithMinMaxThresholds) - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun ofMatrixWithDisplayName( + matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice + ) = Price(matrixWithDisplayName = matrixWithDisplayName) - /** - * Returns an immutable instance of [ReplacePrice]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```kotlin - * .replacesPriceId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): ReplacePrice = - ReplacePrice( - checkRequired("replacesPriceId", replacesPriceId), - allocationPrice, - planPhaseOrder, - price, - additionalProperties.toMutableMap(), - ) - } + fun ofBulkWithProration(bulkWithProration: NewPlanBulkWithProrationPrice) = + Price(bulkWithProration = bulkWithProration) - private var validated: Boolean = false + fun ofGroupedTieredPackage(groupedTieredPackage: NewPlanGroupedTieredPackagePrice) = + Price(groupedTieredPackage = groupedTieredPackage) - fun validate(): ReplacePrice = apply { - if (validated) { - return@apply - } + fun ofMaxGroupTieredPackage( + maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice + ) = Price(maxGroupTieredPackage = maxGroupTieredPackage) - replacesPriceId() - allocationPrice()?.validate() - planPhaseOrder() - price()?.validate() - validated = true - } + fun ofScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice + ) = Price(scalableMatrixWithUnitPricing = scalableMatrixWithUnitPricing) - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + fun ofScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: NewPlanScalableMatrixWithTieredPricingPrice + ) = Price(scalableMatrixWithTieredPricing = scalableMatrixWithTieredPricing) - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (if (replacesPriceId.asKnown() == null) 0 else 1) + - (allocationPrice.asKnown()?.validity() ?: 0) + - (if (planPhaseOrder.asKnown() == null) 0 else 1) + - (price.asKnown()?.validity() ?: 0) + fun ofCumulativeGroupedBulk( + cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice + ) = Price(cumulativeGroupedBulk = cumulativeGroupedBulk) - /** The price to add to the plan */ - @JsonDeserialize(using = Price.Deserializer::class) - @JsonSerialize(using = Price.Serializer::class) - class Price - private constructor( - private val unit: NewPlanUnitPrice? = null, - private val package_: NewPlanPackagePrice? = null, - private val matrix: NewPlanMatrixPrice? = null, - private val tiered: NewPlanTieredPrice? = null, - private val bulk: NewPlanBulkPrice? = null, - private val thresholdTotalAmount: NewPlanThresholdTotalAmountPrice? = null, - private val tieredPackage: NewPlanTieredPackagePrice? = null, - private val tieredWithMinimum: NewPlanTieredWithMinimumPrice? = null, - private val unitWithPercent: NewPlanUnitWithPercentPrice? = null, - private val packageWithAllocation: NewPlanPackageWithAllocationPrice? = null, - private val tieredWithProration: NewPlanTierWithProrationPrice? = null, - private val unitWithProration: NewPlanUnitWithProrationPrice? = null, - private val groupedAllocation: NewPlanGroupedAllocationPrice? = null, - private val groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice? = null, - private val groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice? = null, - private val groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds? = null, - private val matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice? = null, - private val bulkWithProration: NewPlanBulkWithProrationPrice? = null, - private val groupedTieredPackage: NewPlanGroupedTieredPackagePrice? = null, - private val maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice? = null, - private val scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice? = - null, - private val scalableMatrixWithTieredPricing: - NewPlanScalableMatrixWithTieredPricingPrice? = - null, - private val cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice? = null, - private val tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice? = null, - private val matrixWithAllocation: NewPlanMatrixWithAllocationPrice? = null, - private val groupedTiered: NewPlanGroupedTieredPrice? = null, - private val minimum: Minimum? = null, - private val _json: JsonValue? = null, - ) { + fun ofTieredPackageWithMinimum( + tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice + ) = Price(tieredPackageWithMinimum = tieredPackageWithMinimum) - fun unit(): NewPlanUnitPrice? = unit + fun ofMatrixWithAllocation(matrixWithAllocation: NewPlanMatrixWithAllocationPrice) = + Price(matrixWithAllocation = matrixWithAllocation) - fun package_(): NewPlanPackagePrice? = package_ + fun ofGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) = + Price(groupedTiered = groupedTiered) - fun matrix(): NewPlanMatrixPrice? = matrix + fun ofMinimum(minimum: NewPlanMinimumCompositePrice) = Price(minimum = minimum) + } - fun tiered(): NewPlanTieredPrice? = tiered + /** + * An interface that defines how to map each variant of [Price] to a value of type [T]. + */ + interface Visitor { - fun bulk(): NewPlanBulkPrice? = bulk + fun visitUnit(unit: NewPlanUnitPrice): T - fun thresholdTotalAmount(): NewPlanThresholdTotalAmountPrice? = thresholdTotalAmount + fun visitPackage(package_: NewPlanPackagePrice): T - fun tieredPackage(): NewPlanTieredPackagePrice? = tieredPackage + fun visitMatrix(matrix: NewPlanMatrixPrice): T - fun tieredWithMinimum(): NewPlanTieredWithMinimumPrice? = tieredWithMinimum + fun visitTiered(tiered: NewPlanTieredPrice): T - fun unitWithPercent(): NewPlanUnitWithPercentPrice? = unitWithPercent + fun visitBulk(bulk: NewPlanBulkPrice): T - fun packageWithAllocation(): NewPlanPackageWithAllocationPrice? = packageWithAllocation + fun visitThresholdTotalAmount( + thresholdTotalAmount: NewPlanThresholdTotalAmountPrice + ): T - fun tieredWithProration(): NewPlanTierWithProrationPrice? = tieredWithProration + fun visitTieredPackage(tieredPackage: NewPlanTieredPackagePrice): T - fun unitWithProration(): NewPlanUnitWithProrationPrice? = unitWithProration + fun visitTieredWithMinimum(tieredWithMinimum: NewPlanTieredWithMinimumPrice): T - fun groupedAllocation(): NewPlanGroupedAllocationPrice? = groupedAllocation + fun visitUnitWithPercent(unitWithPercent: NewPlanUnitWithPercentPrice): T - fun groupedWithProratedMinimum(): NewPlanGroupedWithProratedMinimumPrice? = - groupedWithProratedMinimum + fun visitPackageWithAllocation( + packageWithAllocation: NewPlanPackageWithAllocationPrice + ): T - fun groupedWithMeteredMinimum(): NewPlanGroupedWithMeteredMinimumPrice? = - groupedWithMeteredMinimum + fun visitTieredWithProration(tieredWithProration: NewPlanTierWithProrationPrice): T - fun groupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds? = - groupedWithMinMaxThresholds + fun visitUnitWithProration(unitWithProration: NewPlanUnitWithProrationPrice): T - fun matrixWithDisplayName(): NewPlanMatrixWithDisplayNamePrice? = matrixWithDisplayName + fun visitGroupedAllocation(groupedAllocation: NewPlanGroupedAllocationPrice): T - fun bulkWithProration(): NewPlanBulkWithProrationPrice? = bulkWithProration + fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice + ): T - fun groupedTieredPackage(): NewPlanGroupedTieredPackagePrice? = groupedTieredPackage + fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice + ): T - fun maxGroupTieredPackage(): NewPlanMaxGroupTieredPackagePrice? = maxGroupTieredPackage + fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ): T - fun scalableMatrixWithUnitPricing(): NewPlanScalableMatrixWithUnitPricingPrice? = - scalableMatrixWithUnitPricing + fun visitMatrixWithDisplayName( + matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice + ): T - fun scalableMatrixWithTieredPricing(): NewPlanScalableMatrixWithTieredPricingPrice? = - scalableMatrixWithTieredPricing + fun visitBulkWithProration(bulkWithProration: NewPlanBulkWithProrationPrice): T - fun cumulativeGroupedBulk(): NewPlanCumulativeGroupedBulkPrice? = cumulativeGroupedBulk + fun visitGroupedTieredPackage( + groupedTieredPackage: NewPlanGroupedTieredPackagePrice + ): T - fun tieredPackageWithMinimum(): NewPlanTieredPackageWithMinimumPrice? = - tieredPackageWithMinimum + fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice + ): T - fun matrixWithAllocation(): NewPlanMatrixWithAllocationPrice? = matrixWithAllocation + fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice + ): T - fun groupedTiered(): NewPlanGroupedTieredPrice? = groupedTiered - - fun minimum(): Minimum? = minimum - - fun isUnit(): Boolean = unit != null - - fun isPackage(): Boolean = package_ != null - - fun isMatrix(): Boolean = matrix != null - - fun isTiered(): Boolean = tiered != null - - fun isBulk(): Boolean = bulk != null - - fun isThresholdTotalAmount(): Boolean = thresholdTotalAmount != null - - fun isTieredPackage(): Boolean = tieredPackage != null - - fun isTieredWithMinimum(): Boolean = tieredWithMinimum != null - - fun isUnitWithPercent(): Boolean = unitWithPercent != null - - fun isPackageWithAllocation(): Boolean = packageWithAllocation != null - - fun isTieredWithProration(): Boolean = tieredWithProration != null - - fun isUnitWithProration(): Boolean = unitWithProration != null - - fun isGroupedAllocation(): Boolean = groupedAllocation != null - - fun isGroupedWithProratedMinimum(): Boolean = groupedWithProratedMinimum != null - - fun isGroupedWithMeteredMinimum(): Boolean = groupedWithMeteredMinimum != null - - fun isGroupedWithMinMaxThresholds(): Boolean = groupedWithMinMaxThresholds != null - - fun isMatrixWithDisplayName(): Boolean = matrixWithDisplayName != null - - fun isBulkWithProration(): Boolean = bulkWithProration != null - - fun isGroupedTieredPackage(): Boolean = groupedTieredPackage != null - - fun isMaxGroupTieredPackage(): Boolean = maxGroupTieredPackage != null - - fun isScalableMatrixWithUnitPricing(): Boolean = scalableMatrixWithUnitPricing != null - - fun isScalableMatrixWithTieredPricing(): Boolean = - scalableMatrixWithTieredPricing != null - - fun isCumulativeGroupedBulk(): Boolean = cumulativeGroupedBulk != null - - fun isTieredPackageWithMinimum(): Boolean = tieredPackageWithMinimum != null - - fun isMatrixWithAllocation(): Boolean = matrixWithAllocation != null - - fun isGroupedTiered(): Boolean = groupedTiered != null - - fun isMinimum(): Boolean = minimum != null - - fun asUnit(): NewPlanUnitPrice = unit.getOrThrow("unit") - - fun asPackage(): NewPlanPackagePrice = package_.getOrThrow("package_") - - fun asMatrix(): NewPlanMatrixPrice = matrix.getOrThrow("matrix") - - fun asTiered(): NewPlanTieredPrice = tiered.getOrThrow("tiered") - - fun asBulk(): NewPlanBulkPrice = bulk.getOrThrow("bulk") - - fun asThresholdTotalAmount(): NewPlanThresholdTotalAmountPrice = - thresholdTotalAmount.getOrThrow("thresholdTotalAmount") - - fun asTieredPackage(): NewPlanTieredPackagePrice = - tieredPackage.getOrThrow("tieredPackage") - - fun asTieredWithMinimum(): NewPlanTieredWithMinimumPrice = - tieredWithMinimum.getOrThrow("tieredWithMinimum") - - fun asUnitWithPercent(): NewPlanUnitWithPercentPrice = - unitWithPercent.getOrThrow("unitWithPercent") - - fun asPackageWithAllocation(): NewPlanPackageWithAllocationPrice = - packageWithAllocation.getOrThrow("packageWithAllocation") - - fun asTieredWithProration(): NewPlanTierWithProrationPrice = - tieredWithProration.getOrThrow("tieredWithProration") - - fun asUnitWithProration(): NewPlanUnitWithProrationPrice = - unitWithProration.getOrThrow("unitWithProration") - - fun asGroupedAllocation(): NewPlanGroupedAllocationPrice = - groupedAllocation.getOrThrow("groupedAllocation") - - fun asGroupedWithProratedMinimum(): NewPlanGroupedWithProratedMinimumPrice = - groupedWithProratedMinimum.getOrThrow("groupedWithProratedMinimum") - - fun asGroupedWithMeteredMinimum(): NewPlanGroupedWithMeteredMinimumPrice = - groupedWithMeteredMinimum.getOrThrow("groupedWithMeteredMinimum") - - fun asGroupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds = - groupedWithMinMaxThresholds.getOrThrow("groupedWithMinMaxThresholds") - - fun asMatrixWithDisplayName(): NewPlanMatrixWithDisplayNamePrice = - matrixWithDisplayName.getOrThrow("matrixWithDisplayName") - - fun asBulkWithProration(): NewPlanBulkWithProrationPrice = - bulkWithProration.getOrThrow("bulkWithProration") - - fun asGroupedTieredPackage(): NewPlanGroupedTieredPackagePrice = - groupedTieredPackage.getOrThrow("groupedTieredPackage") - - fun asMaxGroupTieredPackage(): NewPlanMaxGroupTieredPackagePrice = - maxGroupTieredPackage.getOrThrow("maxGroupTieredPackage") - - fun asScalableMatrixWithUnitPricing(): NewPlanScalableMatrixWithUnitPricingPrice = - scalableMatrixWithUnitPricing.getOrThrow("scalableMatrixWithUnitPricing") - - fun asScalableMatrixWithTieredPricing(): NewPlanScalableMatrixWithTieredPricingPrice = - scalableMatrixWithTieredPricing.getOrThrow("scalableMatrixWithTieredPricing") - - fun asCumulativeGroupedBulk(): NewPlanCumulativeGroupedBulkPrice = - cumulativeGroupedBulk.getOrThrow("cumulativeGroupedBulk") + fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: NewPlanScalableMatrixWithTieredPricingPrice + ): T - fun asTieredPackageWithMinimum(): NewPlanTieredPackageWithMinimumPrice = - tieredPackageWithMinimum.getOrThrow("tieredPackageWithMinimum") + fun visitCumulativeGroupedBulk( + cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice + ): T - fun asMatrixWithAllocation(): NewPlanMatrixWithAllocationPrice = - matrixWithAllocation.getOrThrow("matrixWithAllocation") + fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice + ): T - fun asGroupedTiered(): NewPlanGroupedTieredPrice = - groupedTiered.getOrThrow("groupedTiered") + fun visitMatrixWithAllocation( + matrixWithAllocation: NewPlanMatrixWithAllocationPrice + ): T - fun asMinimum(): Minimum = minimum.getOrThrow("minimum") + fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice): T - fun _json(): JsonValue? = _json + fun visitMinimum(minimum: NewPlanMinimumCompositePrice): T - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - package_ != null -> visitor.visitPackage(package_) - matrix != null -> visitor.visitMatrix(matrix) - tiered != null -> visitor.visitTiered(tiered) - bulk != null -> visitor.visitBulk(bulk) - thresholdTotalAmount != null -> - visitor.visitThresholdTotalAmount(thresholdTotalAmount) - tieredPackage != null -> visitor.visitTieredPackage(tieredPackage) - tieredWithMinimum != null -> visitor.visitTieredWithMinimum(tieredWithMinimum) - unitWithPercent != null -> visitor.visitUnitWithPercent(unitWithPercent) - packageWithAllocation != null -> - visitor.visitPackageWithAllocation(packageWithAllocation) - tieredWithProration != null -> - visitor.visitTieredWithProration(tieredWithProration) - unitWithProration != null -> visitor.visitUnitWithProration(unitWithProration) - groupedAllocation != null -> visitor.visitGroupedAllocation(groupedAllocation) - groupedWithProratedMinimum != null -> - visitor.visitGroupedWithProratedMinimum(groupedWithProratedMinimum) - groupedWithMeteredMinimum != null -> - visitor.visitGroupedWithMeteredMinimum(groupedWithMeteredMinimum) - groupedWithMinMaxThresholds != null -> - visitor.visitGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds) - matrixWithDisplayName != null -> - visitor.visitMatrixWithDisplayName(matrixWithDisplayName) - bulkWithProration != null -> visitor.visitBulkWithProration(bulkWithProration) - groupedTieredPackage != null -> - visitor.visitGroupedTieredPackage(groupedTieredPackage) - maxGroupTieredPackage != null -> - visitor.visitMaxGroupTieredPackage(maxGroupTieredPackage) - scalableMatrixWithUnitPricing != null -> - visitor.visitScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing) - scalableMatrixWithTieredPricing != null -> - visitor.visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing - ) - cumulativeGroupedBulk != null -> - visitor.visitCumulativeGroupedBulk(cumulativeGroupedBulk) - tieredPackageWithMinimum != null -> - visitor.visitTieredPackageWithMinimum(tieredPackageWithMinimum) - matrixWithAllocation != null -> - visitor.visitMatrixWithAllocation(matrixWithAllocation) - groupedTiered != null -> visitor.visitGroupedTiered(groupedTiered) - minimum != null -> visitor.visitMinimum(minimum) - else -> visitor.unknown(_json) + /** + * Maps an unknown variant of [Price] to a value of type [T]. + * + * An instance of [Price] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is + * unaware of. + * + * @throws OrbInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw OrbInvalidDataException("Unknown Price: $json") } + } - private var validated: Boolean = false + internal class Deserializer : BaseDeserializer(Price::class) { - fun validate(): Price = apply { - if (validated) { - return@apply - } + override fun ObjectCodec.deserialize(node: JsonNode): Price { + val json = JsonValue.fromJsonNode(node) + val modelType = json.asObject()?.get("model_type")?.asString() - accept( - object : Visitor { - override fun visitUnit(unit: NewPlanUnitPrice) { - unit.validate() + when (modelType) { + "unit" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(unit = it, _json = json) + } ?: Price(_json = json) } - - override fun visitPackage(package_: NewPlanPackagePrice) { - package_.validate() + "package" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(package_ = it, _json = json) } ?: Price(_json = json) } - - override fun visitMatrix(matrix: NewPlanMatrixPrice) { - matrix.validate() + "matrix" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(matrix = it, _json = json) + } ?: Price(_json = json) } - - override fun visitTiered(tiered: NewPlanTieredPrice) { - tiered.validate() + "tiered" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(tiered = it, _json = json) + } ?: Price(_json = json) } - - override fun visitBulk(bulk: NewPlanBulkPrice) { - bulk.validate() + "bulk" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(bulk = it, _json = json) + } ?: Price(_json = json) } - - override fun visitThresholdTotalAmount( - thresholdTotalAmount: NewPlanThresholdTotalAmountPrice - ) { - thresholdTotalAmount.validate() + "threshold_total_amount" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(thresholdTotalAmount = it, _json = json) } + ?: Price(_json = json) } - - override fun visitTieredPackage(tieredPackage: NewPlanTieredPackagePrice) { - tieredPackage.validate() - } - - override fun visitTieredWithMinimum( - tieredWithMinimum: NewPlanTieredWithMinimumPrice - ) { - tieredWithMinimum.validate() + "tiered_package" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(tieredPackage = it, _json = json) } + ?: Price(_json = json) } - - override fun visitUnitWithPercent( - unitWithPercent: NewPlanUnitWithPercentPrice - ) { - unitWithPercent.validate() + "tiered_with_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(tieredWithMinimum = it, _json = json) } + ?: Price(_json = json) } - - override fun visitPackageWithAllocation( - packageWithAllocation: NewPlanPackageWithAllocationPrice - ) { - packageWithAllocation.validate() + "unit_with_percent" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(unitWithPercent = it, _json = json) } + ?: Price(_json = json) } - - override fun visitTieredWithProration( - tieredWithProration: NewPlanTierWithProrationPrice - ) { - tieredWithProration.validate() + "package_with_allocation" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(packageWithAllocation = it, _json = json) } + ?: Price(_json = json) } - - override fun visitUnitWithProration( - unitWithProration: NewPlanUnitWithProrationPrice - ) { - unitWithProration.validate() + "tiered_with_proration" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(tieredWithProration = it, _json = json) } + ?: Price(_json = json) } - - override fun visitGroupedAllocation( - groupedAllocation: NewPlanGroupedAllocationPrice - ) { - groupedAllocation.validate() + "unit_with_proration" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(unitWithProration = it, _json = json) } + ?: Price(_json = json) } - - override fun visitGroupedWithProratedMinimum( - groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice - ) { - groupedWithProratedMinimum.validate() + "grouped_allocation" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedAllocation = it, _json = json) } + ?: Price(_json = json) } - - override fun visitGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice - ) { - groupedWithMeteredMinimum.validate() + "grouped_with_prorated_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedWithProratedMinimum = it, _json = json) } + ?: Price(_json = json) } - - override fun visitGroupedWithMinMaxThresholds( - groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds - ) { - groupedWithMinMaxThresholds.validate() + "grouped_with_metered_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedWithMeteredMinimum = it, _json = json) } + ?: Price(_json = json) } - - override fun visitMatrixWithDisplayName( - matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice - ) { - matrixWithDisplayName.validate() + "grouped_with_min_max_thresholds" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedWithMinMaxThresholds = it, _json = json) } + ?: Price(_json = json) } - - override fun visitBulkWithProration( - bulkWithProration: NewPlanBulkWithProrationPrice - ) { - bulkWithProration.validate() + "matrix_with_display_name" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(matrixWithDisplayName = it, _json = json) } + ?: Price(_json = json) } - - override fun visitGroupedTieredPackage( - groupedTieredPackage: NewPlanGroupedTieredPackagePrice - ) { - groupedTieredPackage.validate() + "bulk_with_proration" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(bulkWithProration = it, _json = json) } + ?: Price(_json = json) } - - override fun visitMaxGroupTieredPackage( - maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice - ) { - maxGroupTieredPackage.validate() + "grouped_tiered_package" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedTieredPackage = it, _json = json) } + ?: Price(_json = json) } - - override fun visitScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice - ) { - scalableMatrixWithUnitPricing.validate() + "max_group_tiered_package" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(maxGroupTieredPackage = it, _json = json) } + ?: Price(_json = json) } - - override fun visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: - NewPlanScalableMatrixWithTieredPricingPrice - ) { - scalableMatrixWithTieredPricing.validate() + "scalable_matrix_with_unit_pricing" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(scalableMatrixWithUnitPricing = it, _json = json) } + ?: Price(_json = json) } - - override fun visitCumulativeGroupedBulk( - cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice - ) { - cumulativeGroupedBulk.validate() + "scalable_matrix_with_tiered_pricing" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(scalableMatrixWithTieredPricing = it, _json = json) } + ?: Price(_json = json) } - - override fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice - ) { - tieredPackageWithMinimum.validate() + "cumulative_grouped_bulk" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(cumulativeGroupedBulk = it, _json = json) } + ?: Price(_json = json) } - - override fun visitMatrixWithAllocation( - matrixWithAllocation: NewPlanMatrixWithAllocationPrice - ) { - matrixWithAllocation.validate() + "tiered_package_with_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(tieredPackageWithMinimum = it, _json = json) } + ?: Price(_json = json) } - - override fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) { - groupedTiered.validate() + "matrix_with_allocation" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(matrixWithAllocation = it, _json = json) } + ?: Price(_json = json) } - - override fun visitMinimum(minimum: Minimum) { - minimum.validate() + "grouped_tiered" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(groupedTiered = it, _json = json) } + ?: Price(_json = json) } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: NewPlanUnitPrice) = unit.validity() - - override fun visitPackage(package_: NewPlanPackagePrice) = - package_.validity() - - override fun visitMatrix(matrix: NewPlanMatrixPrice) = matrix.validity() - - override fun visitTiered(tiered: NewPlanTieredPrice) = tiered.validity() - - override fun visitBulk(bulk: NewPlanBulkPrice) = bulk.validity() - - override fun visitThresholdTotalAmount( - thresholdTotalAmount: NewPlanThresholdTotalAmountPrice - ) = thresholdTotalAmount.validity() - - override fun visitTieredPackage(tieredPackage: NewPlanTieredPackagePrice) = - tieredPackage.validity() - - override fun visitTieredWithMinimum( - tieredWithMinimum: NewPlanTieredWithMinimumPrice - ) = tieredWithMinimum.validity() - - override fun visitUnitWithPercent( - unitWithPercent: NewPlanUnitWithPercentPrice - ) = unitWithPercent.validity() - - override fun visitPackageWithAllocation( - packageWithAllocation: NewPlanPackageWithAllocationPrice - ) = packageWithAllocation.validity() - - override fun visitTieredWithProration( - tieredWithProration: NewPlanTierWithProrationPrice - ) = tieredWithProration.validity() - - override fun visitUnitWithProration( - unitWithProration: NewPlanUnitWithProrationPrice - ) = unitWithProration.validity() - - override fun visitGroupedAllocation( - groupedAllocation: NewPlanGroupedAllocationPrice - ) = groupedAllocation.validity() - - override fun visitGroupedWithProratedMinimum( - groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice - ) = groupedWithProratedMinimum.validity() - - override fun visitGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice - ) = groupedWithMeteredMinimum.validity() - - override fun visitGroupedWithMinMaxThresholds( - groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds - ) = groupedWithMinMaxThresholds.validity() - - override fun visitMatrixWithDisplayName( - matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice - ) = matrixWithDisplayName.validity() - - override fun visitBulkWithProration( - bulkWithProration: NewPlanBulkWithProrationPrice - ) = bulkWithProration.validity() - - override fun visitGroupedTieredPackage( - groupedTieredPackage: NewPlanGroupedTieredPackagePrice - ) = groupedTieredPackage.validity() - - override fun visitMaxGroupTieredPackage( - maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice - ) = maxGroupTieredPackage.validity() - - override fun visitScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice - ) = scalableMatrixWithUnitPricing.validity() - - override fun visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: - NewPlanScalableMatrixWithTieredPricingPrice - ) = scalableMatrixWithTieredPricing.validity() - - override fun visitCumulativeGroupedBulk( - cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice - ) = cumulativeGroupedBulk.validity() - - override fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice - ) = tieredPackageWithMinimum.validity() - - override fun visitMatrixWithAllocation( - matrixWithAllocation: NewPlanMatrixWithAllocationPrice - ) = matrixWithAllocation.validity() - - override fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) = - groupedTiered.validity() - - override fun visitMinimum(minimum: Minimum) = minimum.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Price && - unit == other.unit && - package_ == other.package_ && - matrix == other.matrix && - tiered == other.tiered && - bulk == other.bulk && - thresholdTotalAmount == other.thresholdTotalAmount && - tieredPackage == other.tieredPackage && - tieredWithMinimum == other.tieredWithMinimum && - unitWithPercent == other.unitWithPercent && - packageWithAllocation == other.packageWithAllocation && - tieredWithProration == other.tieredWithProration && - unitWithProration == other.unitWithProration && - groupedAllocation == other.groupedAllocation && - groupedWithProratedMinimum == other.groupedWithProratedMinimum && - groupedWithMeteredMinimum == other.groupedWithMeteredMinimum && - groupedWithMinMaxThresholds == other.groupedWithMinMaxThresholds && - matrixWithDisplayName == other.matrixWithDisplayName && - bulkWithProration == other.bulkWithProration && - groupedTieredPackage == other.groupedTieredPackage && - maxGroupTieredPackage == other.maxGroupTieredPackage && - scalableMatrixWithUnitPricing == other.scalableMatrixWithUnitPricing && - scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && - cumulativeGroupedBulk == other.cumulativeGroupedBulk && - tieredPackageWithMinimum == other.tieredPackageWithMinimum && - matrixWithAllocation == other.matrixWithAllocation && - groupedTiered == other.groupedTiered && - minimum == other.minimum - } - - override fun hashCode(): Int = - Objects.hash( - unit, - package_, - matrix, - tiered, - bulk, - thresholdTotalAmount, - tieredPackage, - tieredWithMinimum, - unitWithPercent, - packageWithAllocation, - tieredWithProration, - unitWithProration, - groupedAllocation, - groupedWithProratedMinimum, - groupedWithMeteredMinimum, - groupedWithMinMaxThresholds, - matrixWithDisplayName, - bulkWithProration, - groupedTieredPackage, - maxGroupTieredPackage, - scalableMatrixWithUnitPricing, - scalableMatrixWithTieredPricing, - cumulativeGroupedBulk, - tieredPackageWithMinimum, - matrixWithAllocation, - groupedTiered, - minimum, - ) - - override fun toString(): String = - when { - unit != null -> "Price{unit=$unit}" - package_ != null -> "Price{package_=$package_}" - matrix != null -> "Price{matrix=$matrix}" - tiered != null -> "Price{tiered=$tiered}" - bulk != null -> "Price{bulk=$bulk}" - thresholdTotalAmount != null -> - "Price{thresholdTotalAmount=$thresholdTotalAmount}" - tieredPackage != null -> "Price{tieredPackage=$tieredPackage}" - tieredWithMinimum != null -> "Price{tieredWithMinimum=$tieredWithMinimum}" - unitWithPercent != null -> "Price{unitWithPercent=$unitWithPercent}" - packageWithAllocation != null -> - "Price{packageWithAllocation=$packageWithAllocation}" - tieredWithProration != null -> "Price{tieredWithProration=$tieredWithProration}" - unitWithProration != null -> "Price{unitWithProration=$unitWithProration}" - groupedAllocation != null -> "Price{groupedAllocation=$groupedAllocation}" - groupedWithProratedMinimum != null -> - "Price{groupedWithProratedMinimum=$groupedWithProratedMinimum}" - groupedWithMeteredMinimum != null -> - "Price{groupedWithMeteredMinimum=$groupedWithMeteredMinimum}" - groupedWithMinMaxThresholds != null -> - "Price{groupedWithMinMaxThresholds=$groupedWithMinMaxThresholds}" - matrixWithDisplayName != null -> - "Price{matrixWithDisplayName=$matrixWithDisplayName}" - bulkWithProration != null -> "Price{bulkWithProration=$bulkWithProration}" - groupedTieredPackage != null -> - "Price{groupedTieredPackage=$groupedTieredPackage}" - maxGroupTieredPackage != null -> - "Price{maxGroupTieredPackage=$maxGroupTieredPackage}" - scalableMatrixWithUnitPricing != null -> - "Price{scalableMatrixWithUnitPricing=$scalableMatrixWithUnitPricing}" - scalableMatrixWithTieredPricing != null -> - "Price{scalableMatrixWithTieredPricing=$scalableMatrixWithTieredPricing}" - cumulativeGroupedBulk != null -> - "Price{cumulativeGroupedBulk=$cumulativeGroupedBulk}" - tieredPackageWithMinimum != null -> - "Price{tieredPackageWithMinimum=$tieredPackageWithMinimum}" - matrixWithAllocation != null -> - "Price{matrixWithAllocation=$matrixWithAllocation}" - groupedTiered != null -> "Price{groupedTiered=$groupedTiered}" - minimum != null -> "Price{minimum=$minimum}" - _json != null -> "Price{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Price") - } - - companion object { - - fun ofUnit(unit: NewPlanUnitPrice) = Price(unit = unit) - - fun ofPackage(package_: NewPlanPackagePrice) = Price(package_ = package_) - - fun ofMatrix(matrix: NewPlanMatrixPrice) = Price(matrix = matrix) - - fun ofTiered(tiered: NewPlanTieredPrice) = Price(tiered = tiered) - - fun ofBulk(bulk: NewPlanBulkPrice) = Price(bulk = bulk) - - fun ofThresholdTotalAmount(thresholdTotalAmount: NewPlanThresholdTotalAmountPrice) = - Price(thresholdTotalAmount = thresholdTotalAmount) - - fun ofTieredPackage(tieredPackage: NewPlanTieredPackagePrice) = - Price(tieredPackage = tieredPackage) - - fun ofTieredWithMinimum(tieredWithMinimum: NewPlanTieredWithMinimumPrice) = - Price(tieredWithMinimum = tieredWithMinimum) - - fun ofUnitWithPercent(unitWithPercent: NewPlanUnitWithPercentPrice) = - Price(unitWithPercent = unitWithPercent) - - fun ofPackageWithAllocation( - packageWithAllocation: NewPlanPackageWithAllocationPrice - ) = Price(packageWithAllocation = packageWithAllocation) - - fun ofTieredWithProration(tieredWithProration: NewPlanTierWithProrationPrice) = - Price(tieredWithProration = tieredWithProration) - - fun ofUnitWithProration(unitWithProration: NewPlanUnitWithProrationPrice) = - Price(unitWithProration = unitWithProration) - - fun ofGroupedAllocation(groupedAllocation: NewPlanGroupedAllocationPrice) = - Price(groupedAllocation = groupedAllocation) - - fun ofGroupedWithProratedMinimum( - groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice - ) = Price(groupedWithProratedMinimum = groupedWithProratedMinimum) - - fun ofGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice - ) = Price(groupedWithMeteredMinimum = groupedWithMeteredMinimum) - - fun ofGroupedWithMinMaxThresholds( - groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds - ) = Price(groupedWithMinMaxThresholds = groupedWithMinMaxThresholds) - - fun ofMatrixWithDisplayName( - matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice - ) = Price(matrixWithDisplayName = matrixWithDisplayName) - - fun ofBulkWithProration(bulkWithProration: NewPlanBulkWithProrationPrice) = - Price(bulkWithProration = bulkWithProration) - - fun ofGroupedTieredPackage(groupedTieredPackage: NewPlanGroupedTieredPackagePrice) = - Price(groupedTieredPackage = groupedTieredPackage) - - fun ofMaxGroupTieredPackage( - maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice - ) = Price(maxGroupTieredPackage = maxGroupTieredPackage) - - fun ofScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice - ) = Price(scalableMatrixWithUnitPricing = scalableMatrixWithUnitPricing) - - fun ofScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: NewPlanScalableMatrixWithTieredPricingPrice - ) = Price(scalableMatrixWithTieredPricing = scalableMatrixWithTieredPricing) - - fun ofCumulativeGroupedBulk( - cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice - ) = Price(cumulativeGroupedBulk = cumulativeGroupedBulk) - - fun ofTieredPackageWithMinimum( - tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice - ) = Price(tieredPackageWithMinimum = tieredPackageWithMinimum) - - fun ofMatrixWithAllocation(matrixWithAllocation: NewPlanMatrixWithAllocationPrice) = - Price(matrixWithAllocation = matrixWithAllocation) - - fun ofGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) = - Price(groupedTiered = groupedTiered) - - fun ofMinimum(minimum: Minimum) = Price(minimum = minimum) - } - - /** - * An interface that defines how to map each variant of [Price] to a value of type [T]. - */ - interface Visitor { - - fun visitUnit(unit: NewPlanUnitPrice): T - - fun visitPackage(package_: NewPlanPackagePrice): T - - fun visitMatrix(matrix: NewPlanMatrixPrice): T - - fun visitTiered(tiered: NewPlanTieredPrice): T - - fun visitBulk(bulk: NewPlanBulkPrice): T - - fun visitThresholdTotalAmount( - thresholdTotalAmount: NewPlanThresholdTotalAmountPrice - ): T - - fun visitTieredPackage(tieredPackage: NewPlanTieredPackagePrice): T - - fun visitTieredWithMinimum(tieredWithMinimum: NewPlanTieredWithMinimumPrice): T - - fun visitUnitWithPercent(unitWithPercent: NewPlanUnitWithPercentPrice): T - - fun visitPackageWithAllocation( - packageWithAllocation: NewPlanPackageWithAllocationPrice - ): T - - fun visitTieredWithProration(tieredWithProration: NewPlanTierWithProrationPrice): T - - fun visitUnitWithProration(unitWithProration: NewPlanUnitWithProrationPrice): T - - fun visitGroupedAllocation(groupedAllocation: NewPlanGroupedAllocationPrice): T - - fun visitGroupedWithProratedMinimum( - groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice - ): T - - fun visitGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice - ): T - - fun visitGroupedWithMinMaxThresholds( - groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds - ): T - - fun visitMatrixWithDisplayName( - matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice - ): T - - fun visitBulkWithProration(bulkWithProration: NewPlanBulkWithProrationPrice): T - - fun visitGroupedTieredPackage( - groupedTieredPackage: NewPlanGroupedTieredPackagePrice - ): T - - fun visitMaxGroupTieredPackage( - maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice - ): T - - fun visitScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice - ): T - - fun visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: NewPlanScalableMatrixWithTieredPricingPrice - ): T - - fun visitCumulativeGroupedBulk( - cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice - ): T - - fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice - ): T - - fun visitMatrixWithAllocation( - matrixWithAllocation: NewPlanMatrixWithAllocationPrice - ): T - - fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice): T - - fun visitMinimum(minimum: Minimum): T - - /** - * Maps an unknown variant of [Price] to a value of type [T]. - * - * An instance of [Price] can contain an unknown variant if it was deserialized from - * data that doesn't match any known variant. For example, if the SDK is on an older - * version than the API, then the API may respond with new variants that the SDK is - * unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown Price: $json") - } - } - - internal class Deserializer : BaseDeserializer(Price::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): Price { - val json = JsonValue.fromJsonNode(node) - val modelType = json.asObject()?.get("model_type")?.asString() - - when (modelType) { - "unit" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(unit = it, _json = json) - } ?: Price(_json = json) - } - "package" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(package_ = it, _json = json) } ?: Price(_json = json) - } - "matrix" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(matrix = it, _json = json) - } ?: Price(_json = json) - } - "tiered" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(tiered = it, _json = json) - } ?: Price(_json = json) - } - "bulk" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(bulk = it, _json = json) - } ?: Price(_json = json) - } - "threshold_total_amount" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(thresholdTotalAmount = it, _json = json) } - ?: Price(_json = json) - } - "tiered_package" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(tieredPackage = it, _json = json) } - ?: Price(_json = json) - } - "tiered_with_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(tieredWithMinimum = it, _json = json) } - ?: Price(_json = json) - } - "unit_with_percent" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(unitWithPercent = it, _json = json) } - ?: Price(_json = json) - } - "package_with_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(packageWithAllocation = it, _json = json) } - ?: Price(_json = json) - } - "tiered_with_proration" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(tieredWithProration = it, _json = json) } - ?: Price(_json = json) - } - "unit_with_proration" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(unitWithProration = it, _json = json) } - ?: Price(_json = json) - } - "grouped_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedAllocation = it, _json = json) } - ?: Price(_json = json) - } - "grouped_with_prorated_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedWithProratedMinimum = it, _json = json) } - ?: Price(_json = json) - } - "grouped_with_metered_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedWithMeteredMinimum = it, _json = json) } - ?: Price(_json = json) - } - "grouped_with_min_max_thresholds" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedWithMinMaxThresholds = it, _json = json) } - ?: Price(_json = json) - } - "matrix_with_display_name" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(matrixWithDisplayName = it, _json = json) } - ?: Price(_json = json) - } - "bulk_with_proration" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(bulkWithProration = it, _json = json) } - ?: Price(_json = json) - } - "grouped_tiered_package" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedTieredPackage = it, _json = json) } - ?: Price(_json = json) - } - "max_group_tiered_package" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(maxGroupTieredPackage = it, _json = json) } - ?: Price(_json = json) - } - "scalable_matrix_with_unit_pricing" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(scalableMatrixWithUnitPricing = it, _json = json) } - ?: Price(_json = json) - } - "scalable_matrix_with_tiered_pricing" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(scalableMatrixWithTieredPricing = it, _json = json) } - ?: Price(_json = json) - } - "cumulative_grouped_bulk" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(cumulativeGroupedBulk = it, _json = json) } - ?: Price(_json = json) - } - "tiered_package_with_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(tieredPackageWithMinimum = it, _json = json) } - ?: Price(_json = json) - } - "matrix_with_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(matrixWithAllocation = it, _json = json) } - ?: Price(_json = json) - } - "grouped_tiered" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(groupedTiered = it, _json = json) } - ?: Price(_json = json) - } - "minimum" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(minimum = it, _json = json) - } ?: Price(_json = json) - } - } - - return Price(_json = json) - } - } - - internal class Serializer : BaseSerializer(Price::class) { - - override fun serialize( - value: Price, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unit != null -> generator.writeObject(value.unit) - value.package_ != null -> generator.writeObject(value.package_) - value.matrix != null -> generator.writeObject(value.matrix) - value.tiered != null -> generator.writeObject(value.tiered) - value.bulk != null -> generator.writeObject(value.bulk) - value.thresholdTotalAmount != null -> - generator.writeObject(value.thresholdTotalAmount) - value.tieredPackage != null -> generator.writeObject(value.tieredPackage) - value.tieredWithMinimum != null -> - generator.writeObject(value.tieredWithMinimum) - value.unitWithPercent != null -> - generator.writeObject(value.unitWithPercent) - value.packageWithAllocation != null -> - generator.writeObject(value.packageWithAllocation) - value.tieredWithProration != null -> - generator.writeObject(value.tieredWithProration) - value.unitWithProration != null -> - generator.writeObject(value.unitWithProration) - value.groupedAllocation != null -> - generator.writeObject(value.groupedAllocation) - value.groupedWithProratedMinimum != null -> - generator.writeObject(value.groupedWithProratedMinimum) - value.groupedWithMeteredMinimum != null -> - generator.writeObject(value.groupedWithMeteredMinimum) - value.groupedWithMinMaxThresholds != null -> - generator.writeObject(value.groupedWithMinMaxThresholds) - value.matrixWithDisplayName != null -> - generator.writeObject(value.matrixWithDisplayName) - value.bulkWithProration != null -> - generator.writeObject(value.bulkWithProration) - value.groupedTieredPackage != null -> - generator.writeObject(value.groupedTieredPackage) - value.maxGroupTieredPackage != null -> - generator.writeObject(value.maxGroupTieredPackage) - value.scalableMatrixWithUnitPricing != null -> - generator.writeObject(value.scalableMatrixWithUnitPricing) - value.scalableMatrixWithTieredPricing != null -> - generator.writeObject(value.scalableMatrixWithTieredPricing) - value.cumulativeGroupedBulk != null -> - generator.writeObject(value.cumulativeGroupedBulk) - value.tieredPackageWithMinimum != null -> - generator.writeObject(value.tieredPackageWithMinimum) - value.matrixWithAllocation != null -> - generator.writeObject(value.matrixWithAllocation) - value.groupedTiered != null -> generator.writeObject(value.groupedTiered) - value.minimum != null -> generator.writeObject(value.minimum) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Price") - } - } - } - - class GroupedWithMinMaxThresholds - private constructor( - private val cadence: JsonField, - private val groupedWithMinMaxThresholdsConfig: - JsonField, - private val itemId: JsonField, - private val modelType: JsonValue, - private val name: JsonField, - private val billableMetricId: JsonField, - private val billedInAdvance: JsonField, - private val billingCycleConfiguration: JsonField, - private val conversionRate: JsonField, - private val conversionRateConfig: JsonField, - private val currency: JsonField, - private val dimensionalPriceConfiguration: - JsonField, - private val externalPriceId: JsonField, - private val fixedPriceQuantity: JsonField, - private val invoiceGroupingKey: JsonField, - private val invoicingCycleConfiguration: JsonField, - private val metadata: JsonField, - private val referenceId: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("cadence") - @ExcludeMissing - cadence: JsonField = JsonMissing.of(), - @JsonProperty("grouped_with_min_max_thresholds_config") - @ExcludeMissing - groupedWithMinMaxThresholdsConfig: - JsonField = - JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - modelType: JsonValue = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - name: JsonField = JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("conversion_rate_config") - @ExcludeMissing - conversionRateConfig: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - currency: JsonField = JsonMissing.of(), - @JsonProperty("dimensional_price_configuration") - @ExcludeMissing - dimensionalPriceConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - metadata: JsonField = JsonMissing.of(), - @JsonProperty("reference_id") - @ExcludeMissing - referenceId: JsonField = JsonMissing.of(), - ) : this( - cadence, - groupedWithMinMaxThresholdsConfig, - itemId, - modelType, - name, - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - conversionRateConfig, - currency, - dimensionalPriceConfiguration, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - mutableMapOf(), - ) - - /** - * The cadence to bill for this price on. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun groupedWithMinMaxThresholdsConfig(): GroupedWithMinMaxThresholdsConfig = - groupedWithMinMaxThresholdsConfig.getRequired( - "grouped_with_min_max_thresholds_config" - ) - - /** - * The id of the item the price will be associated with. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun itemId(): String = itemId.getRequired("item_id") - - /** - * Expected to always return the following: - * ```kotlin - * JsonValue.from("grouped_with_min_max_thresholds") - * ``` - * - * However, this method can be useful for debugging and logging (e.g. if the server - * responded with an unexpected value). - */ - @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType - - /** - * The name of the price. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun name(): String = name.getRequired("name") - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun billableMetricId(): String? = billableMetricId.getNullable("billable_metric_id") - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun billingCycleConfiguration(): NewBillingCycleConfiguration? = - billingCycleConfiguration.getNullable("billing_cycle_configuration") - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") - - /** - * The configuration for the rate of the price currency to the invoicing currency. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun conversionRateConfig(): ConversionRateConfig? = - conversionRateConfig.getNullable("conversion_rate_config") - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun currency(): String? = currency.getNullable("currency") - - /** - * For dimensional price: specifies a price group and dimension values - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = - dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") - - /** - * An alias for the price. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun fixedPriceQuantity(): Double? = - fixedPriceQuantity.getNullable("fixed_price_quantity") - - /** - * The property used to group this price on an invoice - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun invoiceGroupingKey(): String? = - invoiceGroupingKey.getNullable("invoice_grouping_key") - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun metadata(): Metadata? = metadata.getNullable("metadata") - - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun referenceId(): String? = referenceId.getNullable("reference_id") - - /** - * Returns the raw JSON value of [cadence]. - * - * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("cadence") - @ExcludeMissing - fun _cadence(): JsonField = cadence - - /** - * Returns the raw JSON value of [groupedWithMinMaxThresholdsConfig]. - * - * Unlike [groupedWithMinMaxThresholdsConfig], this method doesn't throw if the JSON - * field has an unexpected type. - */ - @JsonProperty("grouped_with_min_max_thresholds_config") - @ExcludeMissing - fun _groupedWithMinMaxThresholdsConfig(): - JsonField = groupedWithMinMaxThresholdsConfig - - /** - * Returns the raw JSON value of [itemId]. - * - * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - /** - * Returns the raw JSON value of [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - /** - * Returns the raw JSON value of [billableMetricId]. - * - * Unlike [billableMetricId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = billableMetricId - - /** - * Returns the raw JSON value of [billedInAdvance]. - * - * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance - - /** - * Returns the raw JSON value of [billingCycleConfiguration]. - * - * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** - * Returns the raw JSON value of [conversionRate]. - * - * Unlike [conversionRate], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** - * Returns the raw JSON value of [conversionRateConfig]. - * - * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("conversion_rate_config") - @ExcludeMissing - fun _conversionRateConfig(): JsonField = conversionRateConfig - - /** - * Returns the raw JSON value of [currency]. - * - * Unlike [currency], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("currency") - @ExcludeMissing - fun _currency(): JsonField = currency - - /** - * Returns the raw JSON value of [dimensionalPriceConfiguration]. - * - * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON - * field has an unexpected type. - */ - @JsonProperty("dimensional_price_configuration") - @ExcludeMissing - fun _dimensionalPriceConfiguration(): JsonField = - dimensionalPriceConfiguration - - /** - * Returns the raw JSON value of [externalPriceId]. - * - * Unlike [externalPriceId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * Returns the raw JSON value of [fixedPriceQuantity]. - * - * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** - * Returns the raw JSON value of [invoiceGroupingKey]. - * - * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Returns the raw JSON value of [invoicingCycleConfiguration]. - * - * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * Returns the raw JSON value of [metadata]. - * - * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - /** - * Returns the raw JSON value of [referenceId]. - * - * Unlike [referenceId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("reference_id") - @ExcludeMissing - fun _referenceId(): JsonField = referenceId - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [GroupedWithMinMaxThresholds]. - * - * The following fields are required: - * ```kotlin - * .cadence() - * .groupedWithMinMaxThresholdsConfig() - * .itemId() - * .name() - * ``` - */ - fun builder() = Builder() - } - - /** A builder for [GroupedWithMinMaxThresholds]. */ - class Builder internal constructor() { - - private var cadence: JsonField? = null - private var groupedWithMinMaxThresholdsConfig: - JsonField? = - null - private var itemId: JsonField? = null - private var modelType: JsonValue = - JsonValue.from("grouped_with_min_max_thresholds") - private var name: JsonField? = null - private var billableMetricId: JsonField = JsonMissing.of() - private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var conversionRateConfig: JsonField = - JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var dimensionalPriceConfiguration: - JsonField = - JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: - JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var referenceId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds) = - apply { - cadence = groupedWithMinMaxThresholds.cadence - groupedWithMinMaxThresholdsConfig = - groupedWithMinMaxThresholds.groupedWithMinMaxThresholdsConfig - itemId = groupedWithMinMaxThresholds.itemId - modelType = groupedWithMinMaxThresholds.modelType - name = groupedWithMinMaxThresholds.name - billableMetricId = groupedWithMinMaxThresholds.billableMetricId - billedInAdvance = groupedWithMinMaxThresholds.billedInAdvance - billingCycleConfiguration = - groupedWithMinMaxThresholds.billingCycleConfiguration - conversionRate = groupedWithMinMaxThresholds.conversionRate - conversionRateConfig = groupedWithMinMaxThresholds.conversionRateConfig - currency = groupedWithMinMaxThresholds.currency - dimensionalPriceConfiguration = - groupedWithMinMaxThresholds.dimensionalPriceConfiguration - externalPriceId = groupedWithMinMaxThresholds.externalPriceId - fixedPriceQuantity = groupedWithMinMaxThresholds.fixedPriceQuantity - invoiceGroupingKey = groupedWithMinMaxThresholds.invoiceGroupingKey - invoicingCycleConfiguration = - groupedWithMinMaxThresholds.invoicingCycleConfiguration - metadata = groupedWithMinMaxThresholds.metadata - referenceId = groupedWithMinMaxThresholds.referenceId - additionalProperties = - groupedWithMinMaxThresholds.additionalProperties.toMutableMap() - } - - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** - * Sets [Builder.cadence] to an arbitrary JSON value. - * - * You should usually call [Builder.cadence] with a well-typed [Cadence] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - - fun groupedWithMinMaxThresholdsConfig( - groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig - ) = - groupedWithMinMaxThresholdsConfig( - JsonField.of(groupedWithMinMaxThresholdsConfig) - ) - - /** - * Sets [Builder.groupedWithMinMaxThresholdsConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.groupedWithMinMaxThresholdsConfig] with a - * well-typed [GroupedWithMinMaxThresholdsConfig] value instead. This method is - * primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun groupedWithMinMaxThresholdsConfig( - groupedWithMinMaxThresholdsConfig: - JsonField - ) = apply { - this.groupedWithMinMaxThresholdsConfig = groupedWithMinMaxThresholdsConfig - } - - /** The id of the item the price will be associated with. */ - fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - - /** - * Sets [Builder.itemId] to an arbitrary JSON value. - * - * You should usually call [Builder.itemId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - /** - * Sets the field to an arbitrary JSON value. - * - * It is usually unnecessary to call this method because the field defaults to - * the following: - * ```kotlin - * JsonValue.from("grouped_with_min_max_thresholds") - * ``` - * - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } - - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) - - /** - * Sets [Builder.name] to an arbitrary JSON value. - * - * You should usually call [Builder.name] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun name(name: JsonField) = apply { this.name = name } - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: String?) = - billableMetricId(JsonField.ofNullable(billableMetricId)) - - /** - * Sets [Builder.billableMetricId] to an arbitrary JSON value. - * - * You should usually call [Builder.billableMetricId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun billableMetricId(billableMetricId: JsonField) = apply { - this.billableMetricId = billableMetricId - } - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if - * this is true, and in-arrears if this is false. - */ - fun billedInAdvance(billedInAdvance: Boolean?) = - billedInAdvance(JsonField.ofNullable(billedInAdvance)) - - /** - * Alias for [Builder.billedInAdvance]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun billedInAdvance(billedInAdvance: Boolean) = - billedInAdvance(billedInAdvance as Boolean?) - - /** - * Sets [Builder.billedInAdvance] to an arbitrary JSON value. - * - * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun billedInAdvance(billedInAdvance: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: NewBillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - - /** - * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.billingCycleConfiguration] with a well-typed - * [NewBillingCycleConfiguration] value instead. This method is primarily for - * setting the field to an undocumented or not yet supported value. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: JsonField - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: Double?) = - conversionRate(JsonField.ofNullable(conversionRate)) - - /** - * Alias for [Builder.conversionRate]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) - - /** - * Sets [Builder.conversionRate] to an arbitrary JSON value. - * - * You should usually call [Builder.conversionRate] with a well-typed [Double] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** - * The configuration for the rate of the price currency to the invoicing - * currency. - */ - fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = - conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) - - /** - * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.conversionRateConfig] with a well-typed - * [ConversionRateConfig] value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun conversionRateConfig( - conversionRateConfig: JsonField - ) = apply { this.conversionRateConfig = conversionRateConfig } - - /** - * Alias for calling [conversionRateConfig] with - * `ConversionRateConfig.ofUnit(unit)`. - */ - fun conversionRateConfig(unit: UnitConversionRateConfig) = - conversionRateConfig(ConversionRateConfig.ofUnit(unit)) - - /** - * Alias for calling [conversionRateConfig] with the following: - * ```kotlin - * UnitConversionRateConfig.builder() - * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) - * .unitConfig(unitConfig) - * .build() - * ``` - */ - fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = - conversionRateConfig( - UnitConversionRateConfig.builder() - .conversionRateType( - UnitConversionRateConfig.ConversionRateType.UNIT - ) - .unitConfig(unitConfig) - .build() - ) - - /** - * Alias for calling [conversionRateConfig] with - * `ConversionRateConfig.ofTiered(tiered)`. - */ - fun conversionRateConfig(tiered: TieredConversionRateConfig) = - conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) - - /** - * Alias for calling [conversionRateConfig] with the following: - * ```kotlin - * TieredConversionRateConfig.builder() - * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) - * .tieredConfig(tieredConfig) - * .build() - * ``` - */ - fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = - conversionRateConfig( - TieredConversionRateConfig.builder() - .conversionRateType( - TieredConversionRateConfig.ConversionRateType.TIERED - ) - .tieredConfig(tieredConfig) - .build() - ) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) - - /** - * Sets [Builder.currency] to an arbitrary JSON value. - * - * You should usually call [Builder.currency] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } - - /** For dimensional price: specifies a price group and dimension values */ - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? - ) = - dimensionalPriceConfiguration( - JsonField.ofNullable(dimensionalPriceConfiguration) - ) - - /** - * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.dimensionalPriceConfiguration] with a - * well-typed [NewDimensionalPriceConfiguration] value instead. This method is - * primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: JsonField - ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** - * Sets [Builder.externalPriceId] to an arbitrary JSON value. - * - * You should usually call [Builder.externalPriceId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun externalPriceId(externalPriceId: JsonField) = apply { - this.externalPriceId = externalPriceId - } - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = - fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) - - /** - * Alias for [Builder.fixedPriceQuantity]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. - * - * You should usually call [Builder.fixedPriceQuantity] with a well-typed - * [Double] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = - invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) - - /** - * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. - * - * You should usually call [Builder.invoiceGroupingKey] with a well-typed - * [String] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { - this.invoiceGroupingKey = invoiceGroupingKey - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are - * produced. If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: NewBillingCycleConfiguration? - ) = - invoicingCycleConfiguration( - JsonField.ofNullable(invoicingCycleConfiguration) - ) - - /** - * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.invoicingCycleConfiguration] with a - * well-typed [NewBillingCycleConfiguration] value instead. This method is - * primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * Sets [Builder.metadata] to an arbitrary JSON value. - * - * You should usually call [Builder.metadata] with a well-typed [Metadata] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - fun referenceId(referenceId: String?) = - referenceId(JsonField.ofNullable(referenceId)) - - /** - * Sets [Builder.referenceId] to an arbitrary JSON value. - * - * You should usually call [Builder.referenceId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun referenceId(referenceId: JsonField) = apply { - this.referenceId = referenceId - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [GroupedWithMinMaxThresholds]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```kotlin - * .cadence() - * .groupedWithMinMaxThresholdsConfig() - * .itemId() - * .name() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): GroupedWithMinMaxThresholds = - GroupedWithMinMaxThresholds( - checkRequired("cadence", cadence), - checkRequired( - "groupedWithMinMaxThresholdsConfig", - groupedWithMinMaxThresholdsConfig, - ), - checkRequired("itemId", itemId), - modelType, - checkRequired("name", name), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - conversionRateConfig, - currency, - dimensionalPriceConfiguration, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): GroupedWithMinMaxThresholds = apply { - if (validated) { - return@apply - } - - cadence().validate() - groupedWithMinMaxThresholdsConfig().validate() - itemId() - _modelType().let { - if (it != JsonValue.from("grouped_with_min_max_thresholds")) { - throw OrbInvalidDataException("'modelType' is invalid, received $it") - } - } - name() - billableMetricId() - billedInAdvance() - billingCycleConfiguration()?.validate() - conversionRate() - conversionRateConfig()?.validate() - currency() - dimensionalPriceConfiguration()?.validate() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration()?.validate() - metadata()?.validate() - referenceId() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (cadence.asKnown()?.validity() ?: 0) + - (groupedWithMinMaxThresholdsConfig.asKnown()?.validity() ?: 0) + - (if (itemId.asKnown() == null) 0 else 1) + - modelType.let { - if (it == JsonValue.from("grouped_with_min_max_thresholds")) 1 else 0 - } + - (if (name.asKnown() == null) 0 else 1) + - (if (billableMetricId.asKnown() == null) 0 else 1) + - (if (billedInAdvance.asKnown() == null) 0 else 1) + - (billingCycleConfiguration.asKnown()?.validity() ?: 0) + - (if (conversionRate.asKnown() == null) 0 else 1) + - (conversionRateConfig.asKnown()?.validity() ?: 0) + - (if (currency.asKnown() == null) 0 else 1) + - (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + - (if (externalPriceId.asKnown() == null) 0 else 1) + - (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + - (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + - (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + - (metadata.asKnown()?.validity() ?: 0) + - (if (referenceId.asKnown() == null) 0 else 1) - - /** The cadence to bill for this price on. */ - class Cadence - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - val ANNUAL = of("annual") - - val SEMI_ANNUAL = of("semi_annual") - - val MONTHLY = of("monthly") - - val QUARTERLY = of("quarterly") - - val ONE_TIME = of("one_time") - - val CUSTOM = of("custom") - - fun of(value: String) = Cadence(JsonField.of(value)) - } - - /** An enum containing [Cadence]'s known values. */ - enum class Known { - ANNUAL, - SEMI_ANNUAL, - MONTHLY, - QUARTERLY, - ONE_TIME, - CUSTOM, - } - - /** - * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Cadence] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - ANNUAL, - SEMI_ANNUAL, - MONTHLY, - QUARTERLY, - ONE_TIME, - CUSTOM, - /** - * An enum member indicating that [Cadence] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - ANNUAL -> Value.ANNUAL - SEMI_ANNUAL -> Value.SEMI_ANNUAL - MONTHLY -> Value.MONTHLY - QUARTERLY -> Value.QUARTERLY - ONE_TIME -> Value.ONE_TIME - CUSTOM -> Value.CUSTOM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - ANNUAL -> Known.ANNUAL - SEMI_ANNUAL -> Known.SEMI_ANNUAL - MONTHLY -> Known.MONTHLY - QUARTERLY -> Known.QUARTERLY - ONE_TIME -> Known.ONE_TIME - CUSTOM -> Known.CUSTOM - else -> throw OrbInvalidDataException("Unknown Cadence: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString() - ?: throw OrbInvalidDataException("Value is not a String") - - private var validated: Boolean = false - - fun validate(): Cadence = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Cadence && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class GroupedWithMinMaxThresholdsConfig - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [GroupedWithMinMaxThresholdsConfig]. - */ - fun builder() = Builder() - } - - /** A builder for [GroupedWithMinMaxThresholdsConfig]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = - mutableMapOf() - - internal fun from( - groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig - ) = apply { - additionalProperties = - groupedWithMinMaxThresholdsConfig.additionalProperties - .toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [GroupedWithMinMaxThresholdsConfig]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): GroupedWithMinMaxThresholdsConfig = - GroupedWithMinMaxThresholdsConfig(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): GroupedWithMinMaxThresholdsConfig = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - additionalProperties.count { (_, value) -> - !value.isNull() && !value.isMissing() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is GroupedWithMinMaxThresholdsConfig && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "GroupedWithMinMaxThresholdsConfig{additionalProperties=$additionalProperties}" - } - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - class Metadata - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Metadata]. */ - fun builder() = Builder() - } - - /** A builder for [Metadata]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = - mutableMapOf() - - internal fun from(metadata: Metadata) = apply { - additionalProperties = metadata.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Metadata]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - additionalProperties.count { (_, value) -> - !value.isNull() && !value.isMissing() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Metadata && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is GroupedWithMinMaxThresholds && - cadence == other.cadence && - groupedWithMinMaxThresholdsConfig == - other.groupedWithMinMaxThresholdsConfig && - itemId == other.itemId && - modelType == other.modelType && - name == other.name && - billableMetricId == other.billableMetricId && - billedInAdvance == other.billedInAdvance && - billingCycleConfiguration == other.billingCycleConfiguration && - conversionRate == other.conversionRate && - conversionRateConfig == other.conversionRateConfig && - currency == other.currency && - dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && - externalPriceId == other.externalPriceId && - fixedPriceQuantity == other.fixedPriceQuantity && - invoiceGroupingKey == other.invoiceGroupingKey && - invoicingCycleConfiguration == other.invoicingCycleConfiguration && - metadata == other.metadata && - referenceId == other.referenceId && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - cadence, - groupedWithMinMaxThresholdsConfig, - itemId, - modelType, - name, - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - conversionRateConfig, - currency, - dimensionalPriceConfiguration, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - additionalProperties, - ) + "minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(minimum = it, _json = json) } ?: Price(_json = json) + } + } + + return Price(_json = json) } + } - override fun hashCode(): Int = hashCode + internal class Serializer : BaseSerializer(Price::class) { - override fun toString() = - "GroupedWithMinMaxThresholds{cadence=$cadence, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + override fun serialize( + value: Price, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.unit != null -> generator.writeObject(value.unit) + value.package_ != null -> generator.writeObject(value.package_) + value.matrix != null -> generator.writeObject(value.matrix) + value.tiered != null -> generator.writeObject(value.tiered) + value.bulk != null -> generator.writeObject(value.bulk) + value.thresholdTotalAmount != null -> + generator.writeObject(value.thresholdTotalAmount) + value.tieredPackage != null -> generator.writeObject(value.tieredPackage) + value.tieredWithMinimum != null -> + generator.writeObject(value.tieredWithMinimum) + value.unitWithPercent != null -> + generator.writeObject(value.unitWithPercent) + value.packageWithAllocation != null -> + generator.writeObject(value.packageWithAllocation) + value.tieredWithProration != null -> + generator.writeObject(value.tieredWithProration) + value.unitWithProration != null -> + generator.writeObject(value.unitWithProration) + value.groupedAllocation != null -> + generator.writeObject(value.groupedAllocation) + value.groupedWithProratedMinimum != null -> + generator.writeObject(value.groupedWithProratedMinimum) + value.groupedWithMeteredMinimum != null -> + generator.writeObject(value.groupedWithMeteredMinimum) + value.groupedWithMinMaxThresholds != null -> + generator.writeObject(value.groupedWithMinMaxThresholds) + value.matrixWithDisplayName != null -> + generator.writeObject(value.matrixWithDisplayName) + value.bulkWithProration != null -> + generator.writeObject(value.bulkWithProration) + value.groupedTieredPackage != null -> + generator.writeObject(value.groupedTieredPackage) + value.maxGroupTieredPackage != null -> + generator.writeObject(value.maxGroupTieredPackage) + value.scalableMatrixWithUnitPricing != null -> + generator.writeObject(value.scalableMatrixWithUnitPricing) + value.scalableMatrixWithTieredPricing != null -> + generator.writeObject(value.scalableMatrixWithTieredPricing) + value.cumulativeGroupedBulk != null -> + generator.writeObject(value.cumulativeGroupedBulk) + value.tieredPackageWithMinimum != null -> + generator.writeObject(value.tieredPackageWithMinimum) + value.matrixWithAllocation != null -> + generator.writeObject(value.matrixWithAllocation) + value.groupedTiered != null -> generator.writeObject(value.groupedTiered) + value.minimum != null -> generator.writeObject(value.minimum) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Price") + } + } } - class Minimum + class GroupedWithMinMaxThresholds private constructor( private val cadence: JsonField, + private val groupedWithMinMaxThresholdsConfig: + JsonField, private val itemId: JsonField, - private val minimumConfig: JsonField, private val modelType: JsonValue, private val name: JsonField, private val billableMetricId: JsonField, @@ -10304,12 +7266,14 @@ private constructor( @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), + @JsonProperty("grouped_with_min_max_thresholds_config") + @ExcludeMissing + groupedWithMinMaxThresholdsConfig: + JsonField = + JsonMissing.of(), @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), - @JsonProperty("minimum_config") - @ExcludeMissing - minimumConfig: JsonField = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing modelType: JsonValue = JsonMissing.of(), @@ -10360,8 +7324,8 @@ private constructor( referenceId: JsonField = JsonMissing.of(), ) : this( cadence, + groupedWithMinMaxThresholdsConfig, itemId, - minimumConfig, modelType, name, billableMetricId, @@ -10390,25 +7354,28 @@ private constructor( fun cadence(): Cadence = cadence.getRequired("cadence") /** - * The id of the item the price will be associated with. - * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected * value). */ - fun itemId(): String = itemId.getRequired("item_id") + fun groupedWithMinMaxThresholdsConfig(): GroupedWithMinMaxThresholdsConfig = + groupedWithMinMaxThresholdsConfig.getRequired( + "grouped_with_min_max_thresholds_config" + ) /** + * The id of the item the price will be associated with. + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected * value). */ - fun minimumConfig(): MinimumConfig = minimumConfig.getRequired("minimum_config") + fun itemId(): String = itemId.getRequired("item_id") /** * Expected to always return the following: * ```kotlin - * JsonValue.from("minimum") + * JsonValue.from("grouped_with_min_max_thresholds") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -10555,22 +7522,23 @@ private constructor( fun _cadence(): JsonField = cadence /** - * Returns the raw JSON value of [itemId]. + * Returns the raw JSON value of [groupedWithMinMaxThresholdsConfig]. * - * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected - * type. + * Unlike [groupedWithMinMaxThresholdsConfig], this method doesn't throw if the JSON + * field has an unexpected type. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + @JsonProperty("grouped_with_min_max_thresholds_config") + @ExcludeMissing + fun _groupedWithMinMaxThresholdsConfig(): + JsonField = groupedWithMinMaxThresholdsConfig /** - * Returns the raw JSON value of [minimumConfig]. + * Returns the raw JSON value of [itemId]. * - * Unlike [minimumConfig], this method doesn't throw if the JSON field has an - * unexpected type. + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. */ - @JsonProperty("minimum_config") - @ExcludeMissing - fun _minimumConfig(): JsonField = minimumConfig + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId /** * Returns the raw JSON value of [name]. @@ -10728,26 +7696,30 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [Minimum]. + * Returns a mutable builder for constructing an instance of + * [GroupedWithMinMaxThresholds]. * * The following fields are required: * ```kotlin * .cadence() + * .groupedWithMinMaxThresholdsConfig() * .itemId() - * .minimumConfig() * .name() * ``` */ fun builder() = Builder() } - /** A builder for [Minimum]. */ + /** A builder for [GroupedWithMinMaxThresholds]. */ class Builder internal constructor() { private var cadence: JsonField? = null + private var groupedWithMinMaxThresholdsConfig: + JsonField? = + null private var itemId: JsonField? = null - private var minimumConfig: JsonField? = null - private var modelType: JsonValue = JsonValue.from("minimum") + private var modelType: JsonValue = + JsonValue.from("grouped_with_min_max_thresholds") private var name: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() @@ -10770,27 +7742,33 @@ private constructor( private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(minimum: Minimum) = apply { - cadence = minimum.cadence - itemId = minimum.itemId - minimumConfig = minimum.minimumConfig - modelType = minimum.modelType - name = minimum.name - billableMetricId = minimum.billableMetricId - billedInAdvance = minimum.billedInAdvance - billingCycleConfiguration = minimum.billingCycleConfiguration - conversionRate = minimum.conversionRate - conversionRateConfig = minimum.conversionRateConfig - currency = minimum.currency - dimensionalPriceConfiguration = minimum.dimensionalPriceConfiguration - externalPriceId = minimum.externalPriceId - fixedPriceQuantity = minimum.fixedPriceQuantity - invoiceGroupingKey = minimum.invoiceGroupingKey - invoicingCycleConfiguration = minimum.invoicingCycleConfiguration - metadata = minimum.metadata - referenceId = minimum.referenceId - additionalProperties = minimum.additionalProperties.toMutableMap() - } + internal fun from(groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds) = + apply { + cadence = groupedWithMinMaxThresholds.cadence + groupedWithMinMaxThresholdsConfig = + groupedWithMinMaxThresholds.groupedWithMinMaxThresholdsConfig + itemId = groupedWithMinMaxThresholds.itemId + modelType = groupedWithMinMaxThresholds.modelType + name = groupedWithMinMaxThresholds.name + billableMetricId = groupedWithMinMaxThresholds.billableMetricId + billedInAdvance = groupedWithMinMaxThresholds.billedInAdvance + billingCycleConfiguration = + groupedWithMinMaxThresholds.billingCycleConfiguration + conversionRate = groupedWithMinMaxThresholds.conversionRate + conversionRateConfig = groupedWithMinMaxThresholds.conversionRateConfig + currency = groupedWithMinMaxThresholds.currency + dimensionalPriceConfiguration = + groupedWithMinMaxThresholds.dimensionalPriceConfiguration + externalPriceId = groupedWithMinMaxThresholds.externalPriceId + fixedPriceQuantity = groupedWithMinMaxThresholds.fixedPriceQuantity + invoiceGroupingKey = groupedWithMinMaxThresholds.invoiceGroupingKey + invoicingCycleConfiguration = + groupedWithMinMaxThresholds.invoicingCycleConfiguration + metadata = groupedWithMinMaxThresholds.metadata + referenceId = groupedWithMinMaxThresholds.referenceId + additionalProperties = + groupedWithMinMaxThresholds.additionalProperties.toMutableMap() + } /** The cadence to bill for this price on. */ fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) @@ -10804,6 +7782,28 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + fun groupedWithMinMaxThresholdsConfig( + groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + ) = + groupedWithMinMaxThresholdsConfig( + JsonField.of(groupedWithMinMaxThresholdsConfig) + ) + + /** + * Sets [Builder.groupedWithMinMaxThresholdsConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.groupedWithMinMaxThresholdsConfig] with a + * well-typed [GroupedWithMinMaxThresholdsConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun groupedWithMinMaxThresholdsConfig( + groupedWithMinMaxThresholdsConfig: + JsonField + ) = apply { + this.groupedWithMinMaxThresholdsConfig = groupedWithMinMaxThresholdsConfig + } + /** The id of the item the price will be associated with. */ fun itemId(itemId: String) = itemId(JsonField.of(itemId)) @@ -10816,27 +7816,13 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun minimumConfig(minimumConfig: MinimumConfig) = - minimumConfig(JsonField.of(minimumConfig)) - - /** - * Sets [Builder.minimumConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.minimumConfig] with a well-typed - * [MinimumConfig] value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. - */ - fun minimumConfig(minimumConfig: JsonField) = apply { - this.minimumConfig = minimumConfig - } - /** * Sets the field to an arbitrary JSON value. * * It is usually unnecessary to call this method because the field defaults to * the following: * ```kotlin - * JsonValue.from("minimum") + * JsonValue.from("grouped_with_min_max_thresholds") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -11185,25 +8171,28 @@ private constructor( } /** - * Returns an immutable instance of [Minimum]. + * Returns an immutable instance of [GroupedWithMinMaxThresholds]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```kotlin * .cadence() + * .groupedWithMinMaxThresholdsConfig() * .itemId() - * .minimumConfig() * .name() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): Minimum = - Minimum( + fun build(): GroupedWithMinMaxThresholds = + GroupedWithMinMaxThresholds( checkRequired("cadence", cadence), + checkRequired( + "groupedWithMinMaxThresholdsConfig", + groupedWithMinMaxThresholdsConfig, + ), checkRequired("itemId", itemId), - checkRequired("minimumConfig", minimumConfig), modelType, checkRequired("name", name), billableMetricId, @@ -11225,16 +8214,16 @@ private constructor( private var validated: Boolean = false - fun validate(): Minimum = apply { + fun validate(): GroupedWithMinMaxThresholds = apply { if (validated) { return@apply } cadence().validate() + groupedWithMinMaxThresholdsConfig().validate() itemId() - minimumConfig().validate() _modelType().let { - if (it != JsonValue.from("minimum")) { + if (it != JsonValue.from("grouped_with_min_max_thresholds")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } @@ -11271,9 +8260,11 @@ private constructor( */ internal fun validity(): Int = (cadence.asKnown()?.validity() ?: 0) + + (groupedWithMinMaxThresholdsConfig.asKnown()?.validity() ?: 0) + (if (itemId.asKnown() == null) 0 else 1) + - (minimumConfig.asKnown()?.validity() ?: 0) + - modelType.let { if (it == JsonValue.from("minimum")) 1 else 0 } + + modelType.let { + if (it == JsonValue.from("grouped_with_min_max_thresholds")) 1 else 0 + } + (if (name.asKnown() == null) 0 else 1) + (if (billableMetricId.asKnown() == null) 0 else 1) + (if (billedInAdvance.asKnown() == null) 0 else 1) + @@ -11446,70 +8437,16 @@ private constructor( override fun toString() = value.toString() } - class MinimumConfig + class GroupedWithMinMaxThresholdsConfig + @JsonCreator private constructor( - private val minimumAmount: JsonField, - private val prorated: JsonField, - private val additionalProperties: MutableMap, + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map ) { - @JsonCreator - private constructor( - @JsonProperty("minimum_amount") - @ExcludeMissing - minimumAmount: JsonField = JsonMissing.of(), - @JsonProperty("prorated") - @ExcludeMissing - prorated: JsonField = JsonMissing.of(), - ) : this(minimumAmount, prorated, mutableMapOf()) - - /** - * The minimum amount to apply - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") - - /** - * By default, subtotals from minimum composite prices are prorated based on the - * service period. Set to false to disable proration. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun prorated(): Boolean? = prorated.getNullable("prorated") - - /** - * Returns the raw JSON value of [minimumAmount]. - * - * Unlike [minimumAmount], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("minimum_amount") - @ExcludeMissing - fun _minimumAmount(): JsonField = minimumAmount - - /** - * Returns the raw JSON value of [prorated]. - * - * Unlike [prorated], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("prorated") - @ExcludeMissing - fun _prorated(): JsonField = prorated - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + fun _additionalProperties(): Map = additionalProperties fun toBuilder() = Builder().from(this) @@ -11517,67 +8454,23 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [MinimumConfig]. - * - * The following fields are required: - * ```kotlin - * .minimumAmount() - * ``` + * [GroupedWithMinMaxThresholdsConfig]. */ fun builder() = Builder() } - /** A builder for [MinimumConfig]. */ + /** A builder for [GroupedWithMinMaxThresholdsConfig]. */ class Builder internal constructor() { - private var minimumAmount: JsonField? = null - private var prorated: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(minimumConfig: MinimumConfig) = apply { - minimumAmount = minimumConfig.minimumAmount - prorated = minimumConfig.prorated - additionalProperties = minimumConfig.additionalProperties.toMutableMap() - } - - /** The minimum amount to apply */ - fun minimumAmount(minimumAmount: String) = - minimumAmount(JsonField.of(minimumAmount)) - - /** - * Sets [Builder.minimumAmount] to an arbitrary JSON value. - * - * You should usually call [Builder.minimumAmount] with a well-typed - * [String] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun minimumAmount(minimumAmount: JsonField) = apply { - this.minimumAmount = minimumAmount - } - - /** - * By default, subtotals from minimum composite prices are prorated based on - * the service period. Set to false to disable proration. - */ - fun prorated(prorated: Boolean?) = prorated(JsonField.ofNullable(prorated)) - - /** - * Alias for [Builder.prorated]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun prorated(prorated: Boolean) = prorated(prorated as Boolean?) - - /** - * Sets [Builder.prorated] to an arbitrary JSON value. - * - * You should usually call [Builder.prorated] with a well-typed [Boolean] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun prorated(prorated: JsonField) = apply { - this.prorated = prorated + internal fun from( + groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + ) = apply { + additionalProperties = + groupedWithMinMaxThresholdsConfig.additionalProperties + .toMutableMap() } fun additionalProperties(additionalProperties: Map) = @@ -11603,34 +8496,21 @@ private constructor( } /** - * Returns an immutable instance of [MinimumConfig]. + * Returns an immutable instance of [GroupedWithMinMaxThresholdsConfig]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```kotlin - * .minimumAmount() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ - fun build(): MinimumConfig = - MinimumConfig( - checkRequired("minimumAmount", minimumAmount), - prorated, - additionalProperties.toMutableMap(), - ) + fun build(): GroupedWithMinMaxThresholdsConfig = + GroupedWithMinMaxThresholdsConfig(additionalProperties.toImmutable()) } private var validated: Boolean = false - fun validate(): MinimumConfig = apply { + fun validate(): GroupedWithMinMaxThresholdsConfig = apply { if (validated) { return@apply } - minimumAmount() - prorated() validated = true } @@ -11649,28 +8529,25 @@ private constructor( * Used for best match union deserialization. */ internal fun validity(): Int = - (if (minimumAmount.asKnown() == null) 0 else 1) + - (if (prorated.asKnown() == null) 0 else 1) + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is MinimumConfig && - minimumAmount == other.minimumAmount && - prorated == other.prorated && + return other is GroupedWithMinMaxThresholdsConfig && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { - Objects.hash(minimumAmount, prorated, additionalProperties) - } + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "MinimumConfig{minimumAmount=$minimumAmount, prorated=$prorated, additionalProperties=$additionalProperties}" + "GroupedWithMinMaxThresholdsConfig{additionalProperties=$additionalProperties}" } /** @@ -11787,10 +8664,11 @@ private constructor( return true } - return other is Minimum && + return other is GroupedWithMinMaxThresholds && cadence == other.cadence && + groupedWithMinMaxThresholdsConfig == + other.groupedWithMinMaxThresholdsConfig && itemId == other.itemId && - minimumConfig == other.minimumConfig && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && @@ -11812,8 +8690,8 @@ private constructor( private val hashCode: Int by lazy { Objects.hash( cadence, + groupedWithMinMaxThresholdsConfig, itemId, - minimumConfig, modelType, name, billableMetricId, @@ -11836,7 +8714,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Minimum{cadence=$cadence, itemId=$itemId, minimumConfig=$minimumConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "GroupedWithMinMaxThresholds{cadence=$cadence, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } } diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BetaExternalPlanIdCreatePlanVersionParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BetaExternalPlanIdCreatePlanVersionParams.kt index 0c5f4b666..85437b1fc 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BetaExternalPlanIdCreatePlanVersionParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BetaExternalPlanIdCreatePlanVersionParams.kt @@ -1971,7 +1971,7 @@ private constructor( price(Price.ofGroupedTiered(groupedTiered)) /** Alias for calling [price] with `Price.ofMinimum(minimum)`. */ - fun price(minimum: Price.Minimum) = price(Price.ofMinimum(minimum)) + fun price(minimum: NewPlanMinimumCompositePrice) = price(Price.ofMinimum(minimum)) fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -2072,7 +2072,7 @@ private constructor( private val tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice? = null, private val matrixWithAllocation: NewPlanMatrixWithAllocationPrice? = null, private val groupedTiered: NewPlanGroupedTieredPrice? = null, - private val minimum: Minimum? = null, + private val minimum: NewPlanMinimumCompositePrice? = null, private val _json: JsonValue? = null, ) { @@ -2134,7 +2134,7 @@ private constructor( fun groupedTiered(): NewPlanGroupedTieredPrice? = groupedTiered - fun minimum(): Minimum? = minimum + fun minimum(): NewPlanMinimumCompositePrice? = minimum fun isUnit(): Boolean = unit != null @@ -2264,7 +2264,7 @@ private constructor( fun asGroupedTiered(): NewPlanGroupedTieredPrice = groupedTiered.getOrThrow("groupedTiered") - fun asMinimum(): Minimum = minimum.getOrThrow("minimum") + fun asMinimum(): NewPlanMinimumCompositePrice = minimum.getOrThrow("minimum") fun _json(): JsonValue? = _json @@ -2468,7 +2468,7 @@ private constructor( groupedTiered.validate() } - override fun visitMinimum(minimum: Minimum) { + override fun visitMinimum(minimum: NewPlanMinimumCompositePrice) { minimum.validate() } } @@ -2587,7 +2587,8 @@ private constructor( override fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) = groupedTiered.validity() - override fun visitMinimum(minimum: Minimum) = minimum.validity() + override fun visitMinimum(minimum: NewPlanMinimumCompositePrice) = + minimum.validity() override fun unknown(json: JsonValue?) = 0 } @@ -2790,7 +2791,7 @@ private constructor( fun ofGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) = Price(groupedTiered = groupedTiered) - fun ofMinimum(minimum: Minimum) = Price(minimum = minimum) + fun ofMinimum(minimum: NewPlanMinimumCompositePrice) = Price(minimum = minimum) } /** @@ -2876,7 +2877,7 @@ private constructor( fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice): T - fun visitMinimum(minimum: Minimum): T + fun visitMinimum(minimum: NewPlanMinimumCompositePrice): T /** * Maps an unknown variant of [Price] to a value of type [T]. @@ -3087,9 +3088,11 @@ private constructor( ?: Price(_json = json) } "minimum" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(minimum = it, _json = json) - } ?: Price(_json = json) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(minimum = it, _json = json) } ?: Price(_json = json) } } @@ -4637,1621 +4640,1112 @@ private constructor( override fun toString() = "GroupedWithMinMaxThresholds{cadence=$cadence, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } + } - class Minimum - private constructor( - private val cadence: JsonField, - private val itemId: JsonField, - private val minimumConfig: JsonField, - private val modelType: JsonValue, - private val name: JsonField, - private val billableMetricId: JsonField, - private val billedInAdvance: JsonField, - private val billingCycleConfiguration: JsonField, - private val conversionRate: JsonField, - private val conversionRateConfig: JsonField, - private val currency: JsonField, - private val dimensionalPriceConfiguration: - JsonField, - private val externalPriceId: JsonField, - private val fixedPriceQuantity: JsonField, - private val invoiceGroupingKey: JsonField, - private val invoicingCycleConfiguration: JsonField, - private val metadata: JsonField, - private val referenceId: JsonField, - private val additionalProperties: MutableMap, - ) { + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - @JsonCreator - private constructor( - @JsonProperty("cadence") - @ExcludeMissing - cadence: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - itemId: JsonField = JsonMissing.of(), - @JsonProperty("minimum_config") - @ExcludeMissing - minimumConfig: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - modelType: JsonValue = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - name: JsonField = JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("conversion_rate_config") - @ExcludeMissing - conversionRateConfig: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - currency: JsonField = JsonMissing.of(), - @JsonProperty("dimensional_price_configuration") - @ExcludeMissing - dimensionalPriceConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - metadata: JsonField = JsonMissing.of(), - @JsonProperty("reference_id") - @ExcludeMissing - referenceId: JsonField = JsonMissing.of(), - ) : this( - cadence, - itemId, - minimumConfig, - modelType, - name, - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - conversionRateConfig, - currency, - dimensionalPriceConfiguration, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - mutableMapOf(), - ) + return other is AddPrice && + allocationPrice == other.allocationPrice && + planPhaseOrder == other.planPhaseOrder && + price == other.price && + additionalProperties == other.additionalProperties + } - /** - * The cadence to bill for this price on. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun cadence(): Cadence = cadence.getRequired("cadence") + private val hashCode: Int by lazy { + Objects.hash(allocationPrice, planPhaseOrder, price, additionalProperties) + } - /** - * The id of the item the price will be associated with. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun itemId(): String = itemId.getRequired("item_id") + override fun hashCode(): Int = hashCode - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun minimumConfig(): MinimumConfig = minimumConfig.getRequired("minimum_config") + override fun toString() = + "AddPrice{allocationPrice=$allocationPrice, planPhaseOrder=$planPhaseOrder, price=$price, additionalProperties=$additionalProperties}" + } - /** - * Expected to always return the following: - * ```kotlin - * JsonValue.from("minimum") - * ``` - * - * However, this method can be useful for debugging and logging (e.g. if the server - * responded with an unexpected value). - */ - @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + class RemoveAdjustment + private constructor( + private val adjustmentId: JsonField, + private val planPhaseOrder: JsonField, + private val additionalProperties: MutableMap, + ) { - /** - * The name of the price. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun name(): String = name.getRequired("name") + @JsonCreator + private constructor( + @JsonProperty("adjustment_id") + @ExcludeMissing + adjustmentId: JsonField = JsonMissing.of(), + @JsonProperty("plan_phase_order") + @ExcludeMissing + planPhaseOrder: JsonField = JsonMissing.of(), + ) : this(adjustmentId, planPhaseOrder, mutableMapOf()) - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun billableMetricId(): String? = billableMetricId.getNullable("billable_metric_id") + /** + * The id of the adjustment to remove from on the plan. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun adjustmentId(): String = adjustmentId.getRequired("adjustment_id") - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + /** + * The phase to remove this adjustment from. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun planPhaseOrder(): Long? = planPhaseOrder.getNullable("plan_phase_order") - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun billingCycleConfiguration(): NewBillingCycleConfiguration? = - billingCycleConfiguration.getNullable("billing_cycle_configuration") + /** + * Returns the raw JSON value of [adjustmentId]. + * + * Unlike [adjustmentId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("adjustment_id") + @ExcludeMissing + fun _adjustmentId(): JsonField = adjustmentId - /** - * The per unit conversion rate of the price currency to the invoicing currency. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + /** + * Returns the raw JSON value of [planPhaseOrder]. + * + * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder - /** - * The configuration for the rate of the price currency to the invoicing currency. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun conversionRateConfig(): ConversionRateConfig? = - conversionRateConfig.getNullable("conversion_rate_config") + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun currency(): String? = currency.getNullable("currency") + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - /** - * For dimensional price: specifies a price group and dimension values - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = - dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + fun toBuilder() = Builder().from(this) - /** - * An alias for the price. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + companion object { - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun fixedPriceQuantity(): Double? = - fixedPriceQuantity.getNullable("fixed_price_quantity") + /** + * Returns a mutable builder for constructing an instance of [RemoveAdjustment]. + * + * The following fields are required: + * ```kotlin + * .adjustmentId() + * ``` + */ + fun builder() = Builder() + } - /** - * The property used to group this price on an invoice - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun invoiceGroupingKey(): String? = - invoiceGroupingKey.getNullable("invoice_grouping_key") + /** A builder for [RemoveAdjustment]. */ + class Builder internal constructor() { - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + private var adjustmentId: JsonField? = null + private var planPhaseOrder: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun metadata(): Metadata? = metadata.getNullable("metadata") + internal fun from(removeAdjustment: RemoveAdjustment) = apply { + adjustmentId = removeAdjustment.adjustmentId + planPhaseOrder = removeAdjustment.planPhaseOrder + additionalProperties = removeAdjustment.additionalProperties.toMutableMap() + } - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun referenceId(): String? = referenceId.getNullable("reference_id") + /** The id of the adjustment to remove from on the plan. */ + fun adjustmentId(adjustmentId: String) = adjustmentId(JsonField.of(adjustmentId)) - /** - * Returns the raw JSON value of [cadence]. - * - * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("cadence") - @ExcludeMissing - fun _cadence(): JsonField = cadence + /** + * Sets [Builder.adjustmentId] to an arbitrary JSON value. + * + * You should usually call [Builder.adjustmentId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun adjustmentId(adjustmentId: JsonField) = apply { + this.adjustmentId = adjustmentId + } - /** - * Returns the raw JSON value of [itemId]. - * - * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + /** The phase to remove this adjustment from. */ + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) - /** - * Returns the raw JSON value of [minimumConfig]. - * - * Unlike [minimumConfig], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("minimum_config") - @ExcludeMissing - fun _minimumConfig(): JsonField = minimumConfig + /** + * Alias for [Builder.planPhaseOrder]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) - /** - * Returns the raw JSON value of [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + /** + * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. + * + * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun planPhaseOrder(planPhaseOrder: JsonField) = apply { + this.planPhaseOrder = planPhaseOrder + } - /** - * Returns the raw JSON value of [billableMetricId]. - * - * Unlike [billableMetricId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = billableMetricId + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** - * Returns the raw JSON value of [billedInAdvance]. - * - * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * Returns the raw JSON value of [billingCycleConfiguration]. - * - * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - /** - * Returns the raw JSON value of [conversionRate]. - * - * Unlike [conversionRate], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - /** - * Returns the raw JSON value of [conversionRateConfig]. - * - * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("conversion_rate_config") - @ExcludeMissing - fun _conversionRateConfig(): JsonField = conversionRateConfig + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - /** - * Returns the raw JSON value of [currency]. - * - * Unlike [currency], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("currency") - @ExcludeMissing - fun _currency(): JsonField = currency + /** + * Returns an immutable instance of [RemoveAdjustment]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .adjustmentId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): RemoveAdjustment = + RemoveAdjustment( + checkRequired("adjustmentId", adjustmentId), + planPhaseOrder, + additionalProperties.toMutableMap(), + ) + } - /** - * Returns the raw JSON value of [dimensionalPriceConfiguration]. - * - * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON - * field has an unexpected type. - */ - @JsonProperty("dimensional_price_configuration") - @ExcludeMissing - fun _dimensionalPriceConfiguration(): JsonField = - dimensionalPriceConfiguration + private var validated: Boolean = false - /** - * Returns the raw JSON value of [externalPriceId]. - * - * Unlike [externalPriceId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId + fun validate(): RemoveAdjustment = apply { + if (validated) { + return@apply + } - /** - * Returns the raw JSON value of [fixedPriceQuantity]. - * - * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + adjustmentId() + planPhaseOrder() + validated = true + } - /** - * Returns the raw JSON value of [invoiceGroupingKey]. - * - * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - /** - * Returns the raw JSON value of [invoicingCycleConfiguration]. - * - * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (adjustmentId.asKnown() == null) 0 else 1) + + (if (planPhaseOrder.asKnown() == null) 0 else 1) - /** - * Returns the raw JSON value of [metadata]. - * - * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * Returns the raw JSON value of [referenceId]. - * - * Unlike [referenceId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("reference_id") - @ExcludeMissing - fun _referenceId(): JsonField = referenceId + return other is RemoveAdjustment && + adjustmentId == other.adjustmentId && + planPhaseOrder == other.planPhaseOrder && + additionalProperties == other.additionalProperties + } - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + private val hashCode: Int by lazy { + Objects.hash(adjustmentId, planPhaseOrder, additionalProperties) + } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + override fun hashCode(): Int = hashCode - fun toBuilder() = Builder().from(this) + override fun toString() = + "RemoveAdjustment{adjustmentId=$adjustmentId, planPhaseOrder=$planPhaseOrder, additionalProperties=$additionalProperties}" + } - companion object { + class RemovePrice + private constructor( + private val priceId: JsonField, + private val planPhaseOrder: JsonField, + private val additionalProperties: MutableMap, + ) { - /** - * Returns a mutable builder for constructing an instance of [Minimum]. - * - * The following fields are required: - * ```kotlin - * .cadence() - * .itemId() - * .minimumConfig() - * .name() - * ``` - */ - fun builder() = Builder() - } + @JsonCreator + private constructor( + @JsonProperty("price_id") @ExcludeMissing priceId: JsonField = JsonMissing.of(), + @JsonProperty("plan_phase_order") + @ExcludeMissing + planPhaseOrder: JsonField = JsonMissing.of(), + ) : this(priceId, planPhaseOrder, mutableMapOf()) - /** A builder for [Minimum]. */ - class Builder internal constructor() { + /** + * The id of the price to remove from the plan. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun priceId(): String = priceId.getRequired("price_id") - private var cadence: JsonField? = null - private var itemId: JsonField? = null - private var minimumConfig: JsonField? = null - private var modelType: JsonValue = JsonValue.from("minimum") - private var name: JsonField? = null - private var billableMetricId: JsonField = JsonMissing.of() - private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var conversionRateConfig: JsonField = - JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var dimensionalPriceConfiguration: - JsonField = - JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: - JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var referenceId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + /** + * The phase to remove this price from. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun planPhaseOrder(): Long? = planPhaseOrder.getNullable("plan_phase_order") - internal fun from(minimum: Minimum) = apply { - cadence = minimum.cadence - itemId = minimum.itemId - minimumConfig = minimum.minimumConfig - modelType = minimum.modelType - name = minimum.name - billableMetricId = minimum.billableMetricId - billedInAdvance = minimum.billedInAdvance - billingCycleConfiguration = minimum.billingCycleConfiguration - conversionRate = minimum.conversionRate - conversionRateConfig = minimum.conversionRateConfig - currency = minimum.currency - dimensionalPriceConfiguration = minimum.dimensionalPriceConfiguration - externalPriceId = minimum.externalPriceId - fixedPriceQuantity = minimum.fixedPriceQuantity - invoiceGroupingKey = minimum.invoiceGroupingKey - invoicingCycleConfiguration = minimum.invoicingCycleConfiguration - metadata = minimum.metadata - referenceId = minimum.referenceId - additionalProperties = minimum.additionalProperties.toMutableMap() - } + /** + * Returns the raw JSON value of [priceId]. + * + * Unlike [priceId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + /** + * Returns the raw JSON value of [planPhaseOrder]. + * + * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder - /** - * Sets [Builder.cadence] to an arbitrary JSON value. - * - * You should usually call [Builder.cadence] with a well-typed [Cadence] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - /** The id of the item the price will be associated with. */ - fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - /** - * Sets [Builder.itemId] to an arbitrary JSON value. - * - * You should usually call [Builder.itemId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + fun toBuilder() = Builder().from(this) - fun minimumConfig(minimumConfig: MinimumConfig) = - minimumConfig(JsonField.of(minimumConfig)) + companion object { - /** - * Sets [Builder.minimumConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.minimumConfig] with a well-typed - * [MinimumConfig] value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. - */ - fun minimumConfig(minimumConfig: JsonField) = apply { - this.minimumConfig = minimumConfig - } + /** + * Returns a mutable builder for constructing an instance of [RemovePrice]. + * + * The following fields are required: + * ```kotlin + * .priceId() + * ``` + */ + fun builder() = Builder() + } - /** - * Sets the field to an arbitrary JSON value. - * - * It is usually unnecessary to call this method because the field defaults to - * the following: - * ```kotlin - * JsonValue.from("minimum") - * ``` - * - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + /** A builder for [RemovePrice]. */ + class Builder internal constructor() { - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) + private var priceId: JsonField? = null + private var planPhaseOrder: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - /** - * Sets [Builder.name] to an arbitrary JSON value. - * - * You should usually call [Builder.name] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun name(name: JsonField) = apply { this.name = name } + internal fun from(removePrice: RemovePrice) = apply { + priceId = removePrice.priceId + planPhaseOrder = removePrice.planPhaseOrder + additionalProperties = removePrice.additionalProperties.toMutableMap() + } - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: String?) = - billableMetricId(JsonField.ofNullable(billableMetricId)) + /** The id of the price to remove from the plan. */ + fun priceId(priceId: String) = priceId(JsonField.of(priceId)) - /** - * Sets [Builder.billableMetricId] to an arbitrary JSON value. - * - * You should usually call [Builder.billableMetricId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun billableMetricId(billableMetricId: JsonField) = apply { - this.billableMetricId = billableMetricId - } + /** + * Sets [Builder.priceId] to an arbitrary JSON value. + * + * You should usually call [Builder.priceId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun priceId(priceId: JsonField) = apply { this.priceId = priceId } - /** - * If the Price represents a fixed cost, the price will be billed in-advance if - * this is true, and in-arrears if this is false. - */ - fun billedInAdvance(billedInAdvance: Boolean?) = - billedInAdvance(JsonField.ofNullable(billedInAdvance)) + /** The phase to remove this price from. */ + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) - /** - * Alias for [Builder.billedInAdvance]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun billedInAdvance(billedInAdvance: Boolean) = - billedInAdvance(billedInAdvance as Boolean?) + /** + * Alias for [Builder.planPhaseOrder]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) - /** - * Sets [Builder.billedInAdvance] to an arbitrary JSON value. - * - * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun billedInAdvance(billedInAdvance: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } + /** + * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. + * + * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun planPhaseOrder(planPhaseOrder: JsonField) = apply { + this.planPhaseOrder = planPhaseOrder + } - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: NewBillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** - * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.billingCycleConfiguration] with a well-typed - * [NewBillingCycleConfiguration] value instead. This method is primarily for - * setting the field to an undocumented or not yet supported value. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: JsonField - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: Double?) = - conversionRate(JsonField.ofNullable(conversionRate)) + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - /** - * Alias for [Builder.conversionRate]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - /** - * Sets [Builder.conversionRate] to an arbitrary JSON value. - * - * You should usually call [Builder.conversionRate] with a well-typed [Double] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - /** - * The configuration for the rate of the price currency to the invoicing - * currency. - */ - fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = - conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + /** + * Returns an immutable instance of [RemovePrice]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .priceId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): RemovePrice = + RemovePrice( + checkRequired("priceId", priceId), + planPhaseOrder, + additionalProperties.toMutableMap(), + ) + } - /** - * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.conversionRateConfig] with a well-typed - * [ConversionRateConfig] value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun conversionRateConfig( - conversionRateConfig: JsonField - ) = apply { this.conversionRateConfig = conversionRateConfig } + private var validated: Boolean = false - /** - * Alias for calling [conversionRateConfig] with - * `ConversionRateConfig.ofUnit(unit)`. - */ - fun conversionRateConfig(unit: UnitConversionRateConfig) = - conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + fun validate(): RemovePrice = apply { + if (validated) { + return@apply + } - /** - * Alias for calling [conversionRateConfig] with the following: - * ```kotlin - * UnitConversionRateConfig.builder() - * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) - * .unitConfig(unitConfig) - * .build() - * ``` - */ - fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = - conversionRateConfig( - UnitConversionRateConfig.builder() - .conversionRateType( - UnitConversionRateConfig.ConversionRateType.UNIT - ) - .unitConfig(unitConfig) - .build() - ) + priceId() + planPhaseOrder() + validated = true + } - /** - * Alias for calling [conversionRateConfig] with - * `ConversionRateConfig.ofTiered(tiered)`. - */ - fun conversionRateConfig(tiered: TieredConversionRateConfig) = - conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - /** - * Alias for calling [conversionRateConfig] with the following: - * ```kotlin - * TieredConversionRateConfig.builder() - * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) - * .tieredConfig(tieredConfig) - * .build() - * ``` - */ - fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = - conversionRateConfig( - TieredConversionRateConfig.builder() - .conversionRateType( - TieredConversionRateConfig.ConversionRateType.TIERED - ) - .tieredConfig(tieredConfig) - .build() - ) + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (priceId.asKnown() == null) 0 else 1) + + (if (planPhaseOrder.asKnown() == null) 0 else 1) - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * Sets [Builder.currency] to an arbitrary JSON value. - * - * You should usually call [Builder.currency] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } + return other is RemovePrice && + priceId == other.priceId && + planPhaseOrder == other.planPhaseOrder && + additionalProperties == other.additionalProperties + } - /** For dimensional price: specifies a price group and dimension values */ - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? - ) = - dimensionalPriceConfiguration( - JsonField.ofNullable(dimensionalPriceConfiguration) - ) + private val hashCode: Int by lazy { + Objects.hash(priceId, planPhaseOrder, additionalProperties) + } - /** - * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.dimensionalPriceConfiguration] with a - * well-typed [NewDimensionalPriceConfiguration] value instead. This method is - * primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: JsonField - ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + override fun hashCode(): Int = hashCode - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) + override fun toString() = + "RemovePrice{priceId=$priceId, planPhaseOrder=$planPhaseOrder, additionalProperties=$additionalProperties}" + } - /** - * Sets [Builder.externalPriceId] to an arbitrary JSON value. - * - * You should usually call [Builder.externalPriceId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun externalPriceId(externalPriceId: JsonField) = apply { - this.externalPriceId = externalPriceId - } + class ReplaceAdjustment + private constructor( + private val adjustment: JsonField, + private val replacesAdjustmentId: JsonField, + private val planPhaseOrder: JsonField, + private val additionalProperties: MutableMap, + ) { - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = - fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + @JsonCreator + private constructor( + @JsonProperty("adjustment") + @ExcludeMissing + adjustment: JsonField = JsonMissing.of(), + @JsonProperty("replaces_adjustment_id") + @ExcludeMissing + replacesAdjustmentId: JsonField = JsonMissing.of(), + @JsonProperty("plan_phase_order") + @ExcludeMissing + planPhaseOrder: JsonField = JsonMissing.of(), + ) : this(adjustment, replacesAdjustmentId, planPhaseOrder, mutableMapOf()) - /** - * Alias for [Builder.fixedPriceQuantity]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) + /** + * The definition of a new adjustment to create and add to the plan. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun adjustment(): Adjustment = adjustment.getRequired("adjustment") - /** - * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. - * - * You should usually call [Builder.fixedPriceQuantity] with a well-typed - * [Double] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + /** + * The id of the adjustment on the plan to replace in the plan. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun replacesAdjustmentId(): String = + replacesAdjustmentId.getRequired("replaces_adjustment_id") - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = - invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + /** + * The phase to replace this adjustment from. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun planPhaseOrder(): Long? = planPhaseOrder.getNullable("plan_phase_order") - /** - * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. - * - * You should usually call [Builder.invoiceGroupingKey] with a well-typed - * [String] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { - this.invoiceGroupingKey = invoiceGroupingKey - } + /** + * Returns the raw JSON value of [adjustment]. + * + * Unlike [adjustment], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("adjustment") + @ExcludeMissing + fun _adjustment(): JsonField = adjustment - /** - * Within each billing cycle, specifies the cadence at which invoices are - * produced. If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: NewBillingCycleConfiguration? - ) = - invoicingCycleConfiguration( - JsonField.ofNullable(invoicingCycleConfiguration) - ) + /** + * Returns the raw JSON value of [replacesAdjustmentId]. + * + * Unlike [replacesAdjustmentId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("replaces_adjustment_id") + @ExcludeMissing + fun _replacesAdjustmentId(): JsonField = replacesAdjustmentId - /** - * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.invoicingCycleConfiguration] with a - * well-typed [NewBillingCycleConfiguration] value instead. This method is - * primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** + * Returns the raw JSON value of [planPhaseOrder]. + * + * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - /** - * Sets [Builder.metadata] to an arbitrary JSON value. - * - * You should usually call [Builder.metadata] with a well-typed [Metadata] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - fun referenceId(referenceId: String?) = - referenceId(JsonField.ofNullable(referenceId)) + fun toBuilder() = Builder().from(this) - /** - * Sets [Builder.referenceId] to an arbitrary JSON value. - * - * You should usually call [Builder.referenceId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun referenceId(referenceId: JsonField) = apply { - this.referenceId = referenceId - } + companion object { - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * Returns a mutable builder for constructing an instance of [ReplaceAdjustment]. + * + * The following fields are required: + * ```kotlin + * .adjustment() + * .replacesAdjustmentId() + * ``` + */ + fun builder() = Builder() + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** A builder for [ReplaceAdjustment]. */ + class Builder internal constructor() { - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + private var adjustment: JsonField? = null + private var replacesAdjustmentId: JsonField? = null + private var planPhaseOrder: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + internal fun from(replaceAdjustment: ReplaceAdjustment) = apply { + adjustment = replaceAdjustment.adjustment + replacesAdjustmentId = replaceAdjustment.replacesAdjustmentId + planPhaseOrder = replaceAdjustment.planPhaseOrder + additionalProperties = replaceAdjustment.additionalProperties.toMutableMap() + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** The definition of a new adjustment to create and add to the plan. */ + fun adjustment(adjustment: Adjustment) = adjustment(JsonField.of(adjustment)) - /** - * Returns an immutable instance of [Minimum]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```kotlin - * .cadence() - * .itemId() - * .minimumConfig() - * .name() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Minimum = - Minimum( - checkRequired("cadence", cadence), - checkRequired("itemId", itemId), - checkRequired("minimumConfig", minimumConfig), - modelType, - checkRequired("name", name), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - conversionRateConfig, - currency, - dimensionalPriceConfiguration, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - additionalProperties.toMutableMap(), - ) - } + /** + * Sets [Builder.adjustment] to an arbitrary JSON value. + * + * You should usually call [Builder.adjustment] with a well-typed [Adjustment] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun adjustment(adjustment: JsonField) = apply { + this.adjustment = adjustment + } - private var validated: Boolean = false + /** + * Alias for calling [adjustment] with + * `Adjustment.ofPercentageDiscount(percentageDiscount)`. + */ + fun adjustment(percentageDiscount: NewPercentageDiscount) = + adjustment(Adjustment.ofPercentageDiscount(percentageDiscount)) - fun validate(): Minimum = apply { - if (validated) { - return@apply - } + /** + * Alias for calling [adjustment] with the following: + * ```kotlin + * NewPercentageDiscount.builder() + * .adjustmentType(NewPercentageDiscount.AdjustmentType.PERCENTAGE_DISCOUNT) + * .percentageDiscount(percentageDiscount) + * .build() + * ``` + */ + fun percentageDiscountAdjustment(percentageDiscount: Double) = + adjustment( + NewPercentageDiscount.builder() + .adjustmentType(NewPercentageDiscount.AdjustmentType.PERCENTAGE_DISCOUNT) + .percentageDiscount(percentageDiscount) + .build() + ) - cadence().validate() - itemId() - minimumConfig().validate() - _modelType().let { - if (it != JsonValue.from("minimum")) { - throw OrbInvalidDataException("'modelType' is invalid, received $it") - } - } - name() - billableMetricId() - billedInAdvance() - billingCycleConfiguration()?.validate() - conversionRate() - conversionRateConfig()?.validate() - currency() - dimensionalPriceConfiguration()?.validate() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration()?.validate() - metadata()?.validate() - referenceId() - validated = true - } + /** Alias for calling [adjustment] with `Adjustment.ofUsageDiscount(usageDiscount)`. */ + fun adjustment(usageDiscount: NewUsageDiscount) = + adjustment(Adjustment.ofUsageDiscount(usageDiscount)) - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** + * Alias for calling [adjustment] with the following: + * ```kotlin + * NewUsageDiscount.builder() + * .adjustmentType(NewUsageDiscount.AdjustmentType.USAGE_DISCOUNT) + * .usageDiscount(usageDiscount) + * .build() + * ``` + */ + fun usageDiscountAdjustment(usageDiscount: Double) = + adjustment( + NewUsageDiscount.builder() + .adjustmentType(NewUsageDiscount.AdjustmentType.USAGE_DISCOUNT) + .usageDiscount(usageDiscount) + .build() + ) - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (cadence.asKnown()?.validity() ?: 0) + - (if (itemId.asKnown() == null) 0 else 1) + - (minimumConfig.asKnown()?.validity() ?: 0) + - modelType.let { if (it == JsonValue.from("minimum")) 1 else 0 } + - (if (name.asKnown() == null) 0 else 1) + - (if (billableMetricId.asKnown() == null) 0 else 1) + - (if (billedInAdvance.asKnown() == null) 0 else 1) + - (billingCycleConfiguration.asKnown()?.validity() ?: 0) + - (if (conversionRate.asKnown() == null) 0 else 1) + - (conversionRateConfig.asKnown()?.validity() ?: 0) + - (if (currency.asKnown() == null) 0 else 1) + - (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + - (if (externalPriceId.asKnown() == null) 0 else 1) + - (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + - (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + - (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + - (metadata.asKnown()?.validity() ?: 0) + - (if (referenceId.asKnown() == null) 0 else 1) + /** + * Alias for calling [adjustment] with `Adjustment.ofAmountDiscount(amountDiscount)`. + */ + fun adjustment(amountDiscount: NewAmountDiscount) = + adjustment(Adjustment.ofAmountDiscount(amountDiscount)) - /** The cadence to bill for this price on. */ - class Cadence - @JsonCreator - private constructor(private val value: JsonField) : Enum { + /** + * Alias for calling [adjustment] with the following: + * ```kotlin + * NewAmountDiscount.builder() + * .adjustmentType(NewAmountDiscount.AdjustmentType.AMOUNT_DISCOUNT) + * .amountDiscount(amountDiscount) + * .build() + * ``` + */ + fun amountDiscountAdjustment(amountDiscount: String) = + adjustment( + NewAmountDiscount.builder() + .adjustmentType(NewAmountDiscount.AdjustmentType.AMOUNT_DISCOUNT) + .amountDiscount(amountDiscount) + .build() + ) - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value + /** Alias for calling [adjustment] with `Adjustment.ofMinimum(minimum)`. */ + fun adjustment(minimum: NewMinimum) = adjustment(Adjustment.ofMinimum(minimum)) - companion object { + /** Alias for calling [adjustment] with `Adjustment.ofMaximum(maximum)`. */ + fun adjustment(maximum: NewMaximum) = adjustment(Adjustment.ofMaximum(maximum)) - val ANNUAL = of("annual") + /** + * Alias for calling [adjustment] with the following: + * ```kotlin + * NewMaximum.builder() + * .adjustmentType(NewMaximum.AdjustmentType.MAXIMUM) + * .maximumAmount(maximumAmount) + * .build() + * ``` + */ + fun maximumAdjustment(maximumAmount: String) = + adjustment( + NewMaximum.builder() + .adjustmentType(NewMaximum.AdjustmentType.MAXIMUM) + .maximumAmount(maximumAmount) + .build() + ) - val SEMI_ANNUAL = of("semi_annual") + /** The id of the adjustment on the plan to replace in the plan. */ + fun replacesAdjustmentId(replacesAdjustmentId: String) = + replacesAdjustmentId(JsonField.of(replacesAdjustmentId)) - val MONTHLY = of("monthly") + /** + * Sets [Builder.replacesAdjustmentId] to an arbitrary JSON value. + * + * You should usually call [Builder.replacesAdjustmentId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun replacesAdjustmentId(replacesAdjustmentId: JsonField) = apply { + this.replacesAdjustmentId = replacesAdjustmentId + } - val QUARTERLY = of("quarterly") + /** The phase to replace this adjustment from. */ + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) - val ONE_TIME = of("one_time") + /** + * Alias for [Builder.planPhaseOrder]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) - val CUSTOM = of("custom") + /** + * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. + * + * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun planPhaseOrder(planPhaseOrder: JsonField) = apply { + this.planPhaseOrder = planPhaseOrder + } - fun of(value: String) = Cadence(JsonField.of(value)) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** An enum containing [Cadence]'s known values. */ - enum class Known { - ANNUAL, - SEMI_ANNUAL, - MONTHLY, - QUARTERLY, - ONE_TIME, - CUSTOM, - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Cadence] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - ANNUAL, - SEMI_ANNUAL, - MONTHLY, - QUARTERLY, - ONE_TIME, - CUSTOM, - /** - * An enum member indicating that [Cadence] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - ANNUAL -> Value.ANNUAL - SEMI_ANNUAL -> Value.SEMI_ANNUAL - MONTHLY -> Value.MONTHLY - QUARTERLY -> Value.QUARTERLY - ONE_TIME -> Value.ONE_TIME - CUSTOM -> Value.CUSTOM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - ANNUAL -> Known.ANNUAL - SEMI_ANNUAL -> Known.SEMI_ANNUAL - MONTHLY -> Known.MONTHLY - QUARTERLY -> Known.QUARTERLY - ONE_TIME -> Known.ONE_TIME - CUSTOM -> Known.CUSTOM - else -> throw OrbInvalidDataException("Unknown Cadence: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString() - ?: throw OrbInvalidDataException("Value is not a String") + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - private var validated: Boolean = false + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - fun validate(): Cadence = apply { - if (validated) { - return@apply - } + /** + * Returns an immutable instance of [ReplaceAdjustment]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .adjustment() + * .replacesAdjustmentId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ReplaceAdjustment = + ReplaceAdjustment( + checkRequired("adjustment", adjustment), + checkRequired("replacesAdjustmentId", replacesAdjustmentId), + planPhaseOrder, + additionalProperties.toMutableMap(), + ) + } - known() - validated = true - } + private var validated: Boolean = false - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + fun validate(): ReplaceAdjustment = apply { + if (validated) { + return@apply + } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + adjustment().validate() + replacesAdjustmentId() + planPhaseOrder() + validated = true + } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - return other is Cadence && value == other.value - } + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (adjustment.asKnown()?.validity() ?: 0) + + (if (replacesAdjustmentId.asKnown() == null) 0 else 1) + + (if (planPhaseOrder.asKnown() == null) 0 else 1) - override fun hashCode() = value.hashCode() + /** The definition of a new adjustment to create and add to the plan. */ + @JsonDeserialize(using = Adjustment.Deserializer::class) + @JsonSerialize(using = Adjustment.Serializer::class) + class Adjustment + private constructor( + private val percentageDiscount: NewPercentageDiscount? = null, + private val usageDiscount: NewUsageDiscount? = null, + private val amountDiscount: NewAmountDiscount? = null, + private val minimum: NewMinimum? = null, + private val maximum: NewMaximum? = null, + private val _json: JsonValue? = null, + ) { - override fun toString() = value.toString() - } + fun percentageDiscount(): NewPercentageDiscount? = percentageDiscount - class MinimumConfig - private constructor( - private val minimumAmount: JsonField, - private val prorated: JsonField, - private val additionalProperties: MutableMap, - ) { + fun usageDiscount(): NewUsageDiscount? = usageDiscount - @JsonCreator - private constructor( - @JsonProperty("minimum_amount") - @ExcludeMissing - minimumAmount: JsonField = JsonMissing.of(), - @JsonProperty("prorated") - @ExcludeMissing - prorated: JsonField = JsonMissing.of(), - ) : this(minimumAmount, prorated, mutableMapOf()) + fun amountDiscount(): NewAmountDiscount? = amountDiscount - /** - * The minimum amount to apply - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") + fun minimum(): NewMinimum? = minimum - /** - * By default, subtotals from minimum composite prices are prorated based on the - * service period. Set to false to disable proration. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun prorated(): Boolean? = prorated.getNullable("prorated") + fun maximum(): NewMaximum? = maximum - /** - * Returns the raw JSON value of [minimumAmount]. - * - * Unlike [minimumAmount], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("minimum_amount") - @ExcludeMissing - fun _minimumAmount(): JsonField = minimumAmount + fun isPercentageDiscount(): Boolean = percentageDiscount != null - /** - * Returns the raw JSON value of [prorated]. - * - * Unlike [prorated], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("prorated") - @ExcludeMissing - fun _prorated(): JsonField = prorated + fun isUsageDiscount(): Boolean = usageDiscount != null - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + fun isAmountDiscount(): Boolean = amountDiscount != null - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + fun isMinimum(): Boolean = minimum != null - fun toBuilder() = Builder().from(this) + fun isMaximum(): Boolean = maximum != null - companion object { + fun asPercentageDiscount(): NewPercentageDiscount = + percentageDiscount.getOrThrow("percentageDiscount") - /** - * Returns a mutable builder for constructing an instance of - * [MinimumConfig]. - * - * The following fields are required: - * ```kotlin - * .minimumAmount() - * ``` - */ - fun builder() = Builder() - } + fun asUsageDiscount(): NewUsageDiscount = usageDiscount.getOrThrow("usageDiscount") - /** A builder for [MinimumConfig]. */ - class Builder internal constructor() { + fun asAmountDiscount(): NewAmountDiscount = amountDiscount.getOrThrow("amountDiscount") - private var minimumAmount: JsonField? = null - private var prorated: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() + fun asMinimum(): NewMinimum = minimum.getOrThrow("minimum") - internal fun from(minimumConfig: MinimumConfig) = apply { - minimumAmount = minimumConfig.minimumAmount - prorated = minimumConfig.prorated - additionalProperties = minimumConfig.additionalProperties.toMutableMap() - } + fun asMaximum(): NewMaximum = maximum.getOrThrow("maximum") - /** The minimum amount to apply */ - fun minimumAmount(minimumAmount: String) = - minimumAmount(JsonField.of(minimumAmount)) + fun _json(): JsonValue? = _json - /** - * Sets [Builder.minimumAmount] to an arbitrary JSON value. - * - * You should usually call [Builder.minimumAmount] with a well-typed - * [String] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun minimumAmount(minimumAmount: JsonField) = apply { - this.minimumAmount = minimumAmount - } + fun accept(visitor: Visitor): T = + when { + percentageDiscount != null -> + visitor.visitPercentageDiscount(percentageDiscount) + usageDiscount != null -> visitor.visitUsageDiscount(usageDiscount) + amountDiscount != null -> visitor.visitAmountDiscount(amountDiscount) + minimum != null -> visitor.visitMinimum(minimum) + maximum != null -> visitor.visitMaximum(maximum) + else -> visitor.unknown(_json) + } - /** - * By default, subtotals from minimum composite prices are prorated based on - * the service period. Set to false to disable proration. - */ - fun prorated(prorated: Boolean?) = prorated(JsonField.ofNullable(prorated)) + private var validated: Boolean = false - /** - * Alias for [Builder.prorated]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun prorated(prorated: Boolean) = prorated(prorated as Boolean?) + fun validate(): Adjustment = apply { + if (validated) { + return@apply + } - /** - * Sets [Builder.prorated] to an arbitrary JSON value. - * - * You should usually call [Builder.prorated] with a well-typed [Boolean] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun prorated(prorated: JsonField) = apply { - this.prorated = prorated + accept( + object : Visitor { + override fun visitPercentageDiscount( + percentageDiscount: NewPercentageDiscount + ) { + percentageDiscount.validate() } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) + override fun visitUsageDiscount(usageDiscount: NewUsageDiscount) { + usageDiscount.validate() } - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) + override fun visitAmountDiscount(amountDiscount: NewAmountDiscount) { + amountDiscount.validate() } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) + override fun visitMinimum(minimum: NewMinimum) { + minimum.validate() } - /** - * Returns an immutable instance of [MinimumConfig]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```kotlin - * .minimumAmount() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): MinimumConfig = - MinimumConfig( - checkRequired("minimumAmount", minimumAmount), - prorated, - additionalProperties.toMutableMap(), - ) + override fun visitMaximum(maximum: NewMaximum) { + maximum.validate() + } } + ) + validated = true + } - private var validated: Boolean = false + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - fun validate(): MinimumConfig = apply { - if (validated) { - return@apply - } + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitPercentageDiscount( + percentageDiscount: NewPercentageDiscount + ) = percentageDiscount.validity() - minimumAmount() - prorated() - validated = true - } + override fun visitUsageDiscount(usageDiscount: NewUsageDiscount) = + usageDiscount.validity() - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + override fun visitAmountDiscount(amountDiscount: NewAmountDiscount) = + amountDiscount.validity() - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (if (minimumAmount.asKnown() == null) 0 else 1) + - (if (prorated.asKnown() == null) 0 else 1) + override fun visitMinimum(minimum: NewMinimum) = minimum.validity() - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + override fun visitMaximum(maximum: NewMaximum) = maximum.validity() - return other is MinimumConfig && - minimumAmount == other.minimumAmount && - prorated == other.prorated && - additionalProperties == other.additionalProperties + override fun unknown(json: JsonValue?) = 0 } + ) - private val hashCode: Int by lazy { - Objects.hash(minimumAmount, prorated, additionalProperties) - } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - override fun hashCode(): Int = hashCode + return other is Adjustment && + percentageDiscount == other.percentageDiscount && + usageDiscount == other.usageDiscount && + amountDiscount == other.amountDiscount && + minimum == other.minimum && + maximum == other.maximum + } - override fun toString() = - "MinimumConfig{minimumAmount=$minimumAmount, prorated=$prorated, additionalProperties=$additionalProperties}" + override fun hashCode(): Int = + Objects.hash(percentageDiscount, usageDiscount, amountDiscount, minimum, maximum) + + override fun toString(): String = + when { + percentageDiscount != null -> + "Adjustment{percentageDiscount=$percentageDiscount}" + usageDiscount != null -> "Adjustment{usageDiscount=$usageDiscount}" + amountDiscount != null -> "Adjustment{amountDiscount=$amountDiscount}" + minimum != null -> "Adjustment{minimum=$minimum}" + maximum != null -> "Adjustment{maximum=$maximum}" + _json != null -> "Adjustment{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Adjustment") } - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - class Metadata - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { + companion object { - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun ofPercentageDiscount(percentageDiscount: NewPercentageDiscount) = + Adjustment(percentageDiscount = percentageDiscount) - fun toBuilder() = Builder().from(this) + fun ofUsageDiscount(usageDiscount: NewUsageDiscount) = + Adjustment(usageDiscount = usageDiscount) - companion object { + fun ofAmountDiscount(amountDiscount: NewAmountDiscount) = + Adjustment(amountDiscount = amountDiscount) - /** Returns a mutable builder for constructing an instance of [Metadata]. */ - fun builder() = Builder() - } + fun ofMinimum(minimum: NewMinimum) = Adjustment(minimum = minimum) - /** A builder for [Metadata]. */ - class Builder internal constructor() { + fun ofMaximum(maximum: NewMaximum) = Adjustment(maximum = maximum) + } - private var additionalProperties: MutableMap = - mutableMapOf() + /** + * An interface that defines how to map each variant of [Adjustment] to a value of type + * [T]. + */ + interface Visitor { - internal fun from(metadata: Metadata) = apply { - additionalProperties = metadata.additionalProperties.toMutableMap() - } + fun visitPercentageDiscount(percentageDiscount: NewPercentageDiscount): T - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun visitUsageDiscount(usageDiscount: NewUsageDiscount): T - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun visitAmountDiscount(amountDiscount: NewAmountDiscount): T - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + fun visitMinimum(minimum: NewMinimum): T - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun visitMaximum(maximum: NewMaximum): T - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * Maps an unknown variant of [Adjustment] to a value of type [T]. + * + * An instance of [Adjustment] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the + * SDK is unaware of. + * + * @throws OrbInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw OrbInvalidDataException("Unknown Adjustment: $json") + } + } - /** - * Returns an immutable instance of [Metadata]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } + internal class Deserializer : BaseDeserializer(Adjustment::class) { - private var validated: Boolean = false + override fun ObjectCodec.deserialize(node: JsonNode): Adjustment { + val json = JsonValue.fromJsonNode(node) + val adjustmentType = json.asObject()?.get("adjustment_type")?.asString() - fun validate(): Metadata = apply { - if (validated) { - return@apply + when (adjustmentType) { + "percentage_discount" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Adjustment(percentageDiscount = it, _json = json) } + ?: Adjustment(_json = json) } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false + "usage_discount" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(usageDiscount = it, _json = json) + } ?: Adjustment(_json = json) } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - additionalProperties.count { (_, value) -> - !value.isNull() && !value.isMissing() + "amount_discount" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(amountDiscount = it, _json = json) + } ?: Adjustment(_json = json) } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + "minimum" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(minimum = it, _json = json) + } ?: Adjustment(_json = json) + } + "maximum" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(maximum = it, _json = json) + } ?: Adjustment(_json = json) } - - return other is Metadata && - additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + return Adjustment(_json = json) + } + } - override fun hashCode(): Int = hashCode + internal class Serializer : BaseSerializer(Adjustment::class) { - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + override fun serialize( + value: Adjustment, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.percentageDiscount != null -> + generator.writeObject(value.percentageDiscount) + value.usageDiscount != null -> generator.writeObject(value.usageDiscount) + value.amountDiscount != null -> generator.writeObject(value.amountDiscount) + value.minimum != null -> generator.writeObject(value.minimum) + value.maximum != null -> generator.writeObject(value.maximum) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Adjustment") + } } + } + } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - return other is Minimum && - cadence == other.cadence && - itemId == other.itemId && - minimumConfig == other.minimumConfig && - modelType == other.modelType && - name == other.name && - billableMetricId == other.billableMetricId && - billedInAdvance == other.billedInAdvance && - billingCycleConfiguration == other.billingCycleConfiguration && - conversionRate == other.conversionRate && - conversionRateConfig == other.conversionRateConfig && - currency == other.currency && - dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && - externalPriceId == other.externalPriceId && - fixedPriceQuantity == other.fixedPriceQuantity && - invoiceGroupingKey == other.invoiceGroupingKey && - invoicingCycleConfiguration == other.invoicingCycleConfiguration && - metadata == other.metadata && - referenceId == other.referenceId && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - cadence, - itemId, - minimumConfig, - modelType, - name, - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - conversionRateConfig, - currency, - dimensionalPriceConfiguration, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Minimum{cadence=$cadence, itemId=$itemId, minimumConfig=$minimumConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is AddPrice && - allocationPrice == other.allocationPrice && + return other is ReplaceAdjustment && + adjustment == other.adjustment && + replacesAdjustmentId == other.replacesAdjustmentId && planPhaseOrder == other.planPhaseOrder && - price == other.price && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(allocationPrice, planPhaseOrder, price, additionalProperties) + Objects.hash(adjustment, replacesAdjustmentId, planPhaseOrder, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "AddPrice{allocationPrice=$allocationPrice, planPhaseOrder=$planPhaseOrder, price=$price, additionalProperties=$additionalProperties}" + "ReplaceAdjustment{adjustment=$adjustment, replacesAdjustmentId=$replacesAdjustmentId, planPhaseOrder=$planPhaseOrder, additionalProperties=$additionalProperties}" } - class RemoveAdjustment + class ReplacePrice private constructor( - private val adjustmentId: JsonField, + private val replacesPriceId: JsonField, + private val allocationPrice: JsonField, private val planPhaseOrder: JsonField, + private val price: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("adjustment_id") + @JsonProperty("replaces_price_id") @ExcludeMissing - adjustmentId: JsonField = JsonMissing.of(), + replacesPriceId: JsonField = JsonMissing.of(), + @JsonProperty("allocation_price") + @ExcludeMissing + allocationPrice: JsonField = JsonMissing.of(), @JsonProperty("plan_phase_order") @ExcludeMissing planPhaseOrder: JsonField = JsonMissing.of(), - ) : this(adjustmentId, planPhaseOrder, mutableMapOf()) + @JsonProperty("price") @ExcludeMissing price: JsonField = JsonMissing.of(), + ) : this(replacesPriceId, allocationPrice, planPhaseOrder, price, mutableMapOf()) /** - * The id of the adjustment to remove from on the plan. + * The id of the price on the plan to replace in the plan. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ - fun adjustmentId(): String = adjustmentId.getRequired("adjustment_id") + fun replacesPriceId(): String = replacesPriceId.getRequired("replaces_price_id") /** - * The phase to remove this adjustment from. + * The allocation price to add to the plan. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun allocationPrice(): NewAllocationPrice? = allocationPrice.getNullable("allocation_price") + + /** + * The phase to replace this price from. * * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -6259,14 +5753,32 @@ private constructor( fun planPhaseOrder(): Long? = planPhaseOrder.getNullable("plan_phase_order") /** - * Returns the raw JSON value of [adjustmentId]. + * The price to add to the plan * - * Unlike [adjustmentId], this method doesn't throw if the JSON field has an unexpected + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun price(): Price? = price.getNullable("price") + + /** + * Returns the raw JSON value of [replacesPriceId]. + * + * Unlike [replacesPriceId], this method doesn't throw if the JSON field has an unexpected * type. */ - @JsonProperty("adjustment_id") + @JsonProperty("replaces_price_id") @ExcludeMissing - fun _adjustmentId(): JsonField = adjustmentId + fun _replacesPriceId(): JsonField = replacesPriceId + + /** + * Returns the raw JSON value of [allocationPrice]. + * + * Unlike [allocationPrice], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("allocation_price") + @ExcludeMissing + fun _allocationPrice(): JsonField = allocationPrice /** * Returns the raw JSON value of [planPhaseOrder]. @@ -6278,6 +5790,13 @@ private constructor( @ExcludeMissing fun _planPhaseOrder(): JsonField = planPhaseOrder + /** + * Returns the raw JSON value of [price]. + * + * Unlike [price], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("price") @ExcludeMissing fun _price(): JsonField = price + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -6293,44 +5812,64 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [RemoveAdjustment]. + * Returns a mutable builder for constructing an instance of [ReplacePrice]. * * The following fields are required: * ```kotlin - * .adjustmentId() + * .replacesPriceId() * ``` */ fun builder() = Builder() } - /** A builder for [RemoveAdjustment]. */ + /** A builder for [ReplacePrice]. */ class Builder internal constructor() { - private var adjustmentId: JsonField? = null + private var replacesPriceId: JsonField? = null + private var allocationPrice: JsonField = JsonMissing.of() private var planPhaseOrder: JsonField = JsonMissing.of() + private var price: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(removeAdjustment: RemoveAdjustment) = apply { - adjustmentId = removeAdjustment.adjustmentId - planPhaseOrder = removeAdjustment.planPhaseOrder - additionalProperties = removeAdjustment.additionalProperties.toMutableMap() + internal fun from(replacePrice: ReplacePrice) = apply { + replacesPriceId = replacePrice.replacesPriceId + allocationPrice = replacePrice.allocationPrice + planPhaseOrder = replacePrice.planPhaseOrder + price = replacePrice.price + additionalProperties = replacePrice.additionalProperties.toMutableMap() } - /** The id of the adjustment to remove from on the plan. */ - fun adjustmentId(adjustmentId: String) = adjustmentId(JsonField.of(adjustmentId)) + /** The id of the price on the plan to replace in the plan. */ + fun replacesPriceId(replacesPriceId: String) = + replacesPriceId(JsonField.of(replacesPriceId)) /** - * Sets [Builder.adjustmentId] to an arbitrary JSON value. + * Sets [Builder.replacesPriceId] to an arbitrary JSON value. * - * You should usually call [Builder.adjustmentId] with a well-typed [String] value + * You should usually call [Builder.replacesPriceId] with a well-typed [String] value * instead. This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun adjustmentId(adjustmentId: JsonField) = apply { - this.adjustmentId = adjustmentId + fun replacesPriceId(replacesPriceId: JsonField) = apply { + this.replacesPriceId = replacesPriceId } - /** The phase to remove this adjustment from. */ + /** The allocation price to add to the plan. */ + fun allocationPrice(allocationPrice: NewAllocationPrice?) = + allocationPrice(JsonField.ofNullable(allocationPrice)) + + /** + * Sets [Builder.allocationPrice] to an arbitrary JSON value. + * + * You should usually call [Builder.allocationPrice] with a well-typed + * [NewAllocationPrice] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun allocationPrice(allocationPrice: JsonField) = apply { + this.allocationPrice = allocationPrice + } + + /** The phase to replace this price from. */ fun planPhaseOrder(planPhaseOrder: Long?) = planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) @@ -6352,215 +5891,158 @@ private constructor( this.planPhaseOrder = planPhaseOrder } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** The price to add to the plan */ + fun price(price: Price?) = price(JsonField.ofNullable(price)) - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * Sets [Builder.price] to an arbitrary JSON value. + * + * You should usually call [Builder.price] with a well-typed [Price] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun price(price: JsonField) = apply { this.price = price } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + /** Alias for calling [price] with `Price.ofUnit(unit)`. */ + fun price(unit: NewPlanUnitPrice) = price(Price.ofUnit(unit)) - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + /** Alias for calling [price] with `Price.ofPackage(package_)`. */ + fun price(package_: NewPlanPackagePrice) = price(Price.ofPackage(package_)) - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** Alias for calling [price] with `Price.ofMatrix(matrix)`. */ + fun price(matrix: NewPlanMatrixPrice) = price(Price.ofMatrix(matrix)) + + /** Alias for calling [price] with `Price.ofTiered(tiered)`. */ + fun price(tiered: NewPlanTieredPrice) = price(Price.ofTiered(tiered)) + + /** Alias for calling [price] with `Price.ofBulk(bulk)`. */ + fun price(bulk: NewPlanBulkPrice) = price(Price.ofBulk(bulk)) /** - * Returns an immutable instance of [RemoveAdjustment]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```kotlin - * .adjustmentId() - * ``` - * - * @throws IllegalStateException if any required field is unset. + * Alias for calling [price] with `Price.ofThresholdTotalAmount(thresholdTotalAmount)`. */ - fun build(): RemoveAdjustment = - RemoveAdjustment( - checkRequired("adjustmentId", adjustmentId), - planPhaseOrder, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false + fun price(thresholdTotalAmount: NewPlanThresholdTotalAmountPrice) = + price(Price.ofThresholdTotalAmount(thresholdTotalAmount)) - fun validate(): RemoveAdjustment = apply { - if (validated) { - return@apply - } + /** Alias for calling [price] with `Price.ofTieredPackage(tieredPackage)`. */ + fun price(tieredPackage: NewPlanTieredPackagePrice) = + price(Price.ofTieredPackage(tieredPackage)) - adjustmentId() - planPhaseOrder() - validated = true - } + /** Alias for calling [price] with `Price.ofTieredWithMinimum(tieredWithMinimum)`. */ + fun price(tieredWithMinimum: NewPlanTieredWithMinimumPrice) = + price(Price.ofTieredWithMinimum(tieredWithMinimum)) - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** Alias for calling [price] with `Price.ofUnitWithPercent(unitWithPercent)`. */ + fun price(unitWithPercent: NewPlanUnitWithPercentPrice) = + price(Price.ofUnitWithPercent(unitWithPercent)) - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (if (adjustmentId.asKnown() == null) 0 else 1) + - (if (planPhaseOrder.asKnown() == null) 0 else 1) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is RemoveAdjustment && - adjustmentId == other.adjustmentId && - planPhaseOrder == other.planPhaseOrder && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(adjustmentId, planPhaseOrder, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "RemoveAdjustment{adjustmentId=$adjustmentId, planPhaseOrder=$planPhaseOrder, additionalProperties=$additionalProperties}" - } - - class RemovePrice - private constructor( - private val priceId: JsonField, - private val planPhaseOrder: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("price_id") @ExcludeMissing priceId: JsonField = JsonMissing.of(), - @JsonProperty("plan_phase_order") - @ExcludeMissing - planPhaseOrder: JsonField = JsonMissing.of(), - ) : this(priceId, planPhaseOrder, mutableMapOf()) - - /** - * The id of the price to remove from the plan. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun priceId(): String = priceId.getRequired("price_id") - - /** - * The phase to remove this price from. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun planPhaseOrder(): Long? = planPhaseOrder.getNullable("plan_phase_order") + /** + * Alias for calling [price] with + * `Price.ofPackageWithAllocation(packageWithAllocation)`. + */ + fun price(packageWithAllocation: NewPlanPackageWithAllocationPrice) = + price(Price.ofPackageWithAllocation(packageWithAllocation)) - /** - * Returns the raw JSON value of [priceId]. - * - * Unlike [priceId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId + /** + * Alias for calling [price] with `Price.ofTieredWithProration(tieredWithProration)`. + */ + fun price(tieredWithProration: NewPlanTierWithProrationPrice) = + price(Price.ofTieredWithProration(tieredWithProration)) - /** - * Returns the raw JSON value of [planPhaseOrder]. - * - * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("plan_phase_order") - @ExcludeMissing - fun _planPhaseOrder(): JsonField = planPhaseOrder + /** Alias for calling [price] with `Price.ofUnitWithProration(unitWithProration)`. */ + fun price(unitWithProration: NewPlanUnitWithProrationPrice) = + price(Price.ofUnitWithProration(unitWithProration)) - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** Alias for calling [price] with `Price.ofGroupedAllocation(groupedAllocation)`. */ + fun price(groupedAllocation: NewPlanGroupedAllocationPrice) = + price(Price.ofGroupedAllocation(groupedAllocation)) - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** + * Alias for calling [price] with + * `Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)`. + */ + fun price(groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice) = + price(Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)) - fun toBuilder() = Builder().from(this) + /** + * Alias for calling [price] with + * `Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)`. + */ + fun price(groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice) = + price(Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)) - companion object { + /** + * Alias for calling [price] with + * `Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)`. + */ + fun price(groupedWithMinMaxThresholds: Price.GroupedWithMinMaxThresholds) = + price(Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)) /** - * Returns a mutable builder for constructing an instance of [RemovePrice]. - * - * The following fields are required: - * ```kotlin - * .priceId() - * ``` + * Alias for calling [price] with + * `Price.ofMatrixWithDisplayName(matrixWithDisplayName)`. */ - fun builder() = Builder() - } + fun price(matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice) = + price(Price.ofMatrixWithDisplayName(matrixWithDisplayName)) - /** A builder for [RemovePrice]. */ - class Builder internal constructor() { + /** Alias for calling [price] with `Price.ofBulkWithProration(bulkWithProration)`. */ + fun price(bulkWithProration: NewPlanBulkWithProrationPrice) = + price(Price.ofBulkWithProration(bulkWithProration)) - private var priceId: JsonField? = null - private var planPhaseOrder: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + /** + * Alias for calling [price] with `Price.ofGroupedTieredPackage(groupedTieredPackage)`. + */ + fun price(groupedTieredPackage: NewPlanGroupedTieredPackagePrice) = + price(Price.ofGroupedTieredPackage(groupedTieredPackage)) - internal fun from(removePrice: RemovePrice) = apply { - priceId = removePrice.priceId - planPhaseOrder = removePrice.planPhaseOrder - additionalProperties = removePrice.additionalProperties.toMutableMap() - } + /** + * Alias for calling [price] with + * `Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)`. + */ + fun price(maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice) = + price(Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)) - /** The id of the price to remove from the plan. */ - fun priceId(priceId: String) = priceId(JsonField.of(priceId)) + /** + * Alias for calling [price] with + * `Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)`. + */ + fun price(scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice) = + price(Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)) /** - * Sets [Builder.priceId] to an arbitrary JSON value. - * - * You should usually call [Builder.priceId] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. + * Alias for calling [price] with + * `Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)`. */ - fun priceId(priceId: JsonField) = apply { this.priceId = priceId } + fun price( + scalableMatrixWithTieredPricing: NewPlanScalableMatrixWithTieredPricingPrice + ) = price(Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)) - /** The phase to remove this price from. */ - fun planPhaseOrder(planPhaseOrder: Long?) = - planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + /** + * Alias for calling [price] with + * `Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)`. + */ + fun price(cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice) = + price(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) /** - * Alias for [Builder.planPhaseOrder]. - * - * This unboxed primitive overload exists for backwards compatibility. + * Alias for calling [price] with + * `Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)`. */ - fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + fun price(tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice) = + price(Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)) /** - * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. - * - * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. + * Alias for calling [price] with `Price.ofMatrixWithAllocation(matrixWithAllocation)`. */ - fun planPhaseOrder(planPhaseOrder: JsonField) = apply { - this.planPhaseOrder = planPhaseOrder - } + fun price(matrixWithAllocation: NewPlanMatrixWithAllocationPrice) = + price(Price.ofMatrixWithAllocation(matrixWithAllocation)) + + /** Alias for calling [price] with `Price.ofGroupedTiered(groupedTiered)`. */ + fun price(groupedTiered: NewPlanGroupedTieredPrice) = + price(Price.ofGroupedTiered(groupedTiered)) + + /** Alias for calling [price] with `Price.ofMinimum(minimum)`. */ + fun price(minimum: NewPlanMinimumCompositePrice) = price(Price.ofMinimum(minimum)) fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -6582,34 +6064,38 @@ private constructor( } /** - * Returns an immutable instance of [RemovePrice]. + * Returns an immutable instance of [ReplacePrice]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```kotlin - * .priceId() + * .replacesPriceId() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): RemovePrice = - RemovePrice( - checkRequired("priceId", priceId), + fun build(): ReplacePrice = + ReplacePrice( + checkRequired("replacesPriceId", replacesPriceId), + allocationPrice, planPhaseOrder, + price, additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): RemovePrice = apply { + fun validate(): ReplacePrice = apply { if (validated) { return@apply } - priceId() + replacesPriceId() + allocationPrice()?.validate() planPhaseOrder() + price()?.validate() validated = true } @@ -6628,3663 +6114,1139 @@ private constructor( * Used for best match union deserialization. */ internal fun validity(): Int = - (if (priceId.asKnown() == null) 0 else 1) + - (if (planPhaseOrder.asKnown() == null) 0 else 1) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is RemovePrice && - priceId == other.priceId && - planPhaseOrder == other.planPhaseOrder && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(priceId, planPhaseOrder, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "RemovePrice{priceId=$priceId, planPhaseOrder=$planPhaseOrder, additionalProperties=$additionalProperties}" - } + (if (replacesPriceId.asKnown() == null) 0 else 1) + + (allocationPrice.asKnown()?.validity() ?: 0) + + (if (planPhaseOrder.asKnown() == null) 0 else 1) + + (price.asKnown()?.validity() ?: 0) - class ReplaceAdjustment - private constructor( - private val adjustment: JsonField, - private val replacesAdjustmentId: JsonField, - private val planPhaseOrder: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator + /** The price to add to the plan */ + @JsonDeserialize(using = Price.Deserializer::class) + @JsonSerialize(using = Price.Serializer::class) + class Price private constructor( - @JsonProperty("adjustment") - @ExcludeMissing - adjustment: JsonField = JsonMissing.of(), - @JsonProperty("replaces_adjustment_id") - @ExcludeMissing - replacesAdjustmentId: JsonField = JsonMissing.of(), - @JsonProperty("plan_phase_order") - @ExcludeMissing - planPhaseOrder: JsonField = JsonMissing.of(), - ) : this(adjustment, replacesAdjustmentId, planPhaseOrder, mutableMapOf()) + private val unit: NewPlanUnitPrice? = null, + private val package_: NewPlanPackagePrice? = null, + private val matrix: NewPlanMatrixPrice? = null, + private val tiered: NewPlanTieredPrice? = null, + private val bulk: NewPlanBulkPrice? = null, + private val thresholdTotalAmount: NewPlanThresholdTotalAmountPrice? = null, + private val tieredPackage: NewPlanTieredPackagePrice? = null, + private val tieredWithMinimum: NewPlanTieredWithMinimumPrice? = null, + private val unitWithPercent: NewPlanUnitWithPercentPrice? = null, + private val packageWithAllocation: NewPlanPackageWithAllocationPrice? = null, + private val tieredWithProration: NewPlanTierWithProrationPrice? = null, + private val unitWithProration: NewPlanUnitWithProrationPrice? = null, + private val groupedAllocation: NewPlanGroupedAllocationPrice? = null, + private val groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice? = null, + private val groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice? = null, + private val groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds? = null, + private val matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice? = null, + private val bulkWithProration: NewPlanBulkWithProrationPrice? = null, + private val groupedTieredPackage: NewPlanGroupedTieredPackagePrice? = null, + private val maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice? = null, + private val scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice? = + null, + private val scalableMatrixWithTieredPricing: + NewPlanScalableMatrixWithTieredPricingPrice? = + null, + private val cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice? = null, + private val tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice? = null, + private val matrixWithAllocation: NewPlanMatrixWithAllocationPrice? = null, + private val groupedTiered: NewPlanGroupedTieredPrice? = null, + private val minimum: NewPlanMinimumCompositePrice? = null, + private val _json: JsonValue? = null, + ) { - /** - * The definition of a new adjustment to create and add to the plan. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun adjustment(): Adjustment = adjustment.getRequired("adjustment") + fun unit(): NewPlanUnitPrice? = unit - /** - * The id of the adjustment on the plan to replace in the plan. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun replacesAdjustmentId(): String = - replacesAdjustmentId.getRequired("replaces_adjustment_id") + fun package_(): NewPlanPackagePrice? = package_ - /** - * The phase to replace this adjustment from. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun planPhaseOrder(): Long? = planPhaseOrder.getNullable("plan_phase_order") + fun matrix(): NewPlanMatrixPrice? = matrix - /** - * Returns the raw JSON value of [adjustment]. - * - * Unlike [adjustment], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("adjustment") - @ExcludeMissing - fun _adjustment(): JsonField = adjustment + fun tiered(): NewPlanTieredPrice? = tiered - /** - * Returns the raw JSON value of [replacesAdjustmentId]. - * - * Unlike [replacesAdjustmentId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("replaces_adjustment_id") - @ExcludeMissing - fun _replacesAdjustmentId(): JsonField = replacesAdjustmentId + fun bulk(): NewPlanBulkPrice? = bulk - /** - * Returns the raw JSON value of [planPhaseOrder]. - * - * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("plan_phase_order") - @ExcludeMissing - fun _planPhaseOrder(): JsonField = planPhaseOrder + fun thresholdTotalAmount(): NewPlanThresholdTotalAmountPrice? = thresholdTotalAmount - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + fun tieredPackage(): NewPlanTieredPackagePrice? = tieredPackage - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + fun tieredWithMinimum(): NewPlanTieredWithMinimumPrice? = tieredWithMinimum - fun toBuilder() = Builder().from(this) + fun unitWithPercent(): NewPlanUnitWithPercentPrice? = unitWithPercent - companion object { + fun packageWithAllocation(): NewPlanPackageWithAllocationPrice? = packageWithAllocation - /** - * Returns a mutable builder for constructing an instance of [ReplaceAdjustment]. - * - * The following fields are required: - * ```kotlin - * .adjustment() - * .replacesAdjustmentId() - * ``` - */ - fun builder() = Builder() - } + fun tieredWithProration(): NewPlanTierWithProrationPrice? = tieredWithProration - /** A builder for [ReplaceAdjustment]. */ - class Builder internal constructor() { + fun unitWithProration(): NewPlanUnitWithProrationPrice? = unitWithProration - private var adjustment: JsonField? = null - private var replacesAdjustmentId: JsonField? = null - private var planPhaseOrder: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + fun groupedAllocation(): NewPlanGroupedAllocationPrice? = groupedAllocation - internal fun from(replaceAdjustment: ReplaceAdjustment) = apply { - adjustment = replaceAdjustment.adjustment - replacesAdjustmentId = replaceAdjustment.replacesAdjustmentId - planPhaseOrder = replaceAdjustment.planPhaseOrder - additionalProperties = replaceAdjustment.additionalProperties.toMutableMap() - } + fun groupedWithProratedMinimum(): NewPlanGroupedWithProratedMinimumPrice? = + groupedWithProratedMinimum - /** The definition of a new adjustment to create and add to the plan. */ - fun adjustment(adjustment: Adjustment) = adjustment(JsonField.of(adjustment)) + fun groupedWithMeteredMinimum(): NewPlanGroupedWithMeteredMinimumPrice? = + groupedWithMeteredMinimum - /** - * Sets [Builder.adjustment] to an arbitrary JSON value. - * - * You should usually call [Builder.adjustment] with a well-typed [Adjustment] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun adjustment(adjustment: JsonField) = apply { - this.adjustment = adjustment - } + fun groupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds? = + groupedWithMinMaxThresholds - /** - * Alias for calling [adjustment] with - * `Adjustment.ofPercentageDiscount(percentageDiscount)`. - */ - fun adjustment(percentageDiscount: NewPercentageDiscount) = - adjustment(Adjustment.ofPercentageDiscount(percentageDiscount)) + fun matrixWithDisplayName(): NewPlanMatrixWithDisplayNamePrice? = matrixWithDisplayName - /** - * Alias for calling [adjustment] with the following: - * ```kotlin - * NewPercentageDiscount.builder() - * .adjustmentType(NewPercentageDiscount.AdjustmentType.PERCENTAGE_DISCOUNT) - * .percentageDiscount(percentageDiscount) - * .build() - * ``` - */ - fun percentageDiscountAdjustment(percentageDiscount: Double) = - adjustment( - NewPercentageDiscount.builder() - .adjustmentType(NewPercentageDiscount.AdjustmentType.PERCENTAGE_DISCOUNT) - .percentageDiscount(percentageDiscount) - .build() - ) + fun bulkWithProration(): NewPlanBulkWithProrationPrice? = bulkWithProration - /** Alias for calling [adjustment] with `Adjustment.ofUsageDiscount(usageDiscount)`. */ - fun adjustment(usageDiscount: NewUsageDiscount) = - adjustment(Adjustment.ofUsageDiscount(usageDiscount)) + fun groupedTieredPackage(): NewPlanGroupedTieredPackagePrice? = groupedTieredPackage - /** - * Alias for calling [adjustment] with the following: - * ```kotlin - * NewUsageDiscount.builder() - * .adjustmentType(NewUsageDiscount.AdjustmentType.USAGE_DISCOUNT) - * .usageDiscount(usageDiscount) - * .build() - * ``` - */ - fun usageDiscountAdjustment(usageDiscount: Double) = - adjustment( - NewUsageDiscount.builder() - .adjustmentType(NewUsageDiscount.AdjustmentType.USAGE_DISCOUNT) - .usageDiscount(usageDiscount) - .build() - ) + fun maxGroupTieredPackage(): NewPlanMaxGroupTieredPackagePrice? = maxGroupTieredPackage - /** - * Alias for calling [adjustment] with `Adjustment.ofAmountDiscount(amountDiscount)`. - */ - fun adjustment(amountDiscount: NewAmountDiscount) = - adjustment(Adjustment.ofAmountDiscount(amountDiscount)) + fun scalableMatrixWithUnitPricing(): NewPlanScalableMatrixWithUnitPricingPrice? = + scalableMatrixWithUnitPricing - /** - * Alias for calling [adjustment] with the following: - * ```kotlin - * NewAmountDiscount.builder() - * .adjustmentType(NewAmountDiscount.AdjustmentType.AMOUNT_DISCOUNT) - * .amountDiscount(amountDiscount) - * .build() - * ``` - */ - fun amountDiscountAdjustment(amountDiscount: String) = - adjustment( - NewAmountDiscount.builder() - .adjustmentType(NewAmountDiscount.AdjustmentType.AMOUNT_DISCOUNT) - .amountDiscount(amountDiscount) - .build() - ) + fun scalableMatrixWithTieredPricing(): NewPlanScalableMatrixWithTieredPricingPrice? = + scalableMatrixWithTieredPricing - /** Alias for calling [adjustment] with `Adjustment.ofMinimum(minimum)`. */ - fun adjustment(minimum: NewMinimum) = adjustment(Adjustment.ofMinimum(minimum)) + fun cumulativeGroupedBulk(): NewPlanCumulativeGroupedBulkPrice? = cumulativeGroupedBulk - /** Alias for calling [adjustment] with `Adjustment.ofMaximum(maximum)`. */ - fun adjustment(maximum: NewMaximum) = adjustment(Adjustment.ofMaximum(maximum)) + fun tieredPackageWithMinimum(): NewPlanTieredPackageWithMinimumPrice? = + tieredPackageWithMinimum - /** - * Alias for calling [adjustment] with the following: - * ```kotlin - * NewMaximum.builder() - * .adjustmentType(NewMaximum.AdjustmentType.MAXIMUM) - * .maximumAmount(maximumAmount) - * .build() - * ``` - */ - fun maximumAdjustment(maximumAmount: String) = - adjustment( - NewMaximum.builder() - .adjustmentType(NewMaximum.AdjustmentType.MAXIMUM) - .maximumAmount(maximumAmount) - .build() - ) + fun matrixWithAllocation(): NewPlanMatrixWithAllocationPrice? = matrixWithAllocation - /** The id of the adjustment on the plan to replace in the plan. */ - fun replacesAdjustmentId(replacesAdjustmentId: String) = - replacesAdjustmentId(JsonField.of(replacesAdjustmentId)) + fun groupedTiered(): NewPlanGroupedTieredPrice? = groupedTiered - /** - * Sets [Builder.replacesAdjustmentId] to an arbitrary JSON value. - * - * You should usually call [Builder.replacesAdjustmentId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun replacesAdjustmentId(replacesAdjustmentId: JsonField) = apply { - this.replacesAdjustmentId = replacesAdjustmentId - } + fun minimum(): NewPlanMinimumCompositePrice? = minimum - /** The phase to replace this adjustment from. */ - fun planPhaseOrder(planPhaseOrder: Long?) = - planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + fun isUnit(): Boolean = unit != null - /** - * Alias for [Builder.planPhaseOrder]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + fun isPackage(): Boolean = package_ != null - /** - * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. - * - * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun planPhaseOrder(planPhaseOrder: JsonField) = apply { - this.planPhaseOrder = planPhaseOrder - } + fun isMatrix(): Boolean = matrix != null - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun isTiered(): Boolean = tiered != null - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun isBulk(): Boolean = bulk != null - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun isThresholdTotalAmount(): Boolean = thresholdTotalAmount != null - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun isTieredPackage(): Boolean = tieredPackage != null - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun isTieredWithMinimum(): Boolean = tieredWithMinimum != null - /** - * Returns an immutable instance of [ReplaceAdjustment]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```kotlin - * .adjustment() - * .replacesAdjustmentId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): ReplaceAdjustment = - ReplaceAdjustment( - checkRequired("adjustment", adjustment), - checkRequired("replacesAdjustmentId", replacesAdjustmentId), - planPhaseOrder, - additionalProperties.toMutableMap(), - ) - } + fun isUnitWithPercent(): Boolean = unitWithPercent != null - private var validated: Boolean = false + fun isPackageWithAllocation(): Boolean = packageWithAllocation != null - fun validate(): ReplaceAdjustment = apply { - if (validated) { - return@apply - } + fun isTieredWithProration(): Boolean = tieredWithProration != null - adjustment().validate() - replacesAdjustmentId() - planPhaseOrder() - validated = true - } + fun isUnitWithProration(): Boolean = unitWithProration != null - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + fun isGroupedAllocation(): Boolean = groupedAllocation != null - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (adjustment.asKnown()?.validity() ?: 0) + - (if (replacesAdjustmentId.asKnown() == null) 0 else 1) + - (if (planPhaseOrder.asKnown() == null) 0 else 1) + fun isGroupedWithProratedMinimum(): Boolean = groupedWithProratedMinimum != null - /** The definition of a new adjustment to create and add to the plan. */ - @JsonDeserialize(using = Adjustment.Deserializer::class) - @JsonSerialize(using = Adjustment.Serializer::class) - class Adjustment - private constructor( - private val percentageDiscount: NewPercentageDiscount? = null, - private val usageDiscount: NewUsageDiscount? = null, - private val amountDiscount: NewAmountDiscount? = null, - private val minimum: NewMinimum? = null, - private val maximum: NewMaximum? = null, - private val _json: JsonValue? = null, - ) { + fun isGroupedWithMeteredMinimum(): Boolean = groupedWithMeteredMinimum != null - fun percentageDiscount(): NewPercentageDiscount? = percentageDiscount + fun isGroupedWithMinMaxThresholds(): Boolean = groupedWithMinMaxThresholds != null - fun usageDiscount(): NewUsageDiscount? = usageDiscount + fun isMatrixWithDisplayName(): Boolean = matrixWithDisplayName != null - fun amountDiscount(): NewAmountDiscount? = amountDiscount + fun isBulkWithProration(): Boolean = bulkWithProration != null - fun minimum(): NewMinimum? = minimum + fun isGroupedTieredPackage(): Boolean = groupedTieredPackage != null - fun maximum(): NewMaximum? = maximum + fun isMaxGroupTieredPackage(): Boolean = maxGroupTieredPackage != null - fun isPercentageDiscount(): Boolean = percentageDiscount != null + fun isScalableMatrixWithUnitPricing(): Boolean = scalableMatrixWithUnitPricing != null - fun isUsageDiscount(): Boolean = usageDiscount != null + fun isScalableMatrixWithTieredPricing(): Boolean = + scalableMatrixWithTieredPricing != null - fun isAmountDiscount(): Boolean = amountDiscount != null + fun isCumulativeGroupedBulk(): Boolean = cumulativeGroupedBulk != null - fun isMinimum(): Boolean = minimum != null + fun isTieredPackageWithMinimum(): Boolean = tieredPackageWithMinimum != null - fun isMaximum(): Boolean = maximum != null + fun isMatrixWithAllocation(): Boolean = matrixWithAllocation != null - fun asPercentageDiscount(): NewPercentageDiscount = - percentageDiscount.getOrThrow("percentageDiscount") + fun isGroupedTiered(): Boolean = groupedTiered != null - fun asUsageDiscount(): NewUsageDiscount = usageDiscount.getOrThrow("usageDiscount") + fun isMinimum(): Boolean = minimum != null - fun asAmountDiscount(): NewAmountDiscount = amountDiscount.getOrThrow("amountDiscount") + fun asUnit(): NewPlanUnitPrice = unit.getOrThrow("unit") - fun asMinimum(): NewMinimum = minimum.getOrThrow("minimum") + fun asPackage(): NewPlanPackagePrice = package_.getOrThrow("package_") - fun asMaximum(): NewMaximum = maximum.getOrThrow("maximum") + fun asMatrix(): NewPlanMatrixPrice = matrix.getOrThrow("matrix") - fun _json(): JsonValue? = _json + fun asTiered(): NewPlanTieredPrice = tiered.getOrThrow("tiered") - fun accept(visitor: Visitor): T = - when { - percentageDiscount != null -> - visitor.visitPercentageDiscount(percentageDiscount) - usageDiscount != null -> visitor.visitUsageDiscount(usageDiscount) - amountDiscount != null -> visitor.visitAmountDiscount(amountDiscount) - minimum != null -> visitor.visitMinimum(minimum) - maximum != null -> visitor.visitMaximum(maximum) - else -> visitor.unknown(_json) - } + fun asBulk(): NewPlanBulkPrice = bulk.getOrThrow("bulk") - private var validated: Boolean = false + fun asThresholdTotalAmount(): NewPlanThresholdTotalAmountPrice = + thresholdTotalAmount.getOrThrow("thresholdTotalAmount") - fun validate(): Adjustment = apply { - if (validated) { - return@apply - } + fun asTieredPackage(): NewPlanTieredPackagePrice = + tieredPackage.getOrThrow("tieredPackage") - accept( - object : Visitor { - override fun visitPercentageDiscount( - percentageDiscount: NewPercentageDiscount - ) { - percentageDiscount.validate() - } + fun asTieredWithMinimum(): NewPlanTieredWithMinimumPrice = + tieredWithMinimum.getOrThrow("tieredWithMinimum") - override fun visitUsageDiscount(usageDiscount: NewUsageDiscount) { - usageDiscount.validate() - } + fun asUnitWithPercent(): NewPlanUnitWithPercentPrice = + unitWithPercent.getOrThrow("unitWithPercent") - override fun visitAmountDiscount(amountDiscount: NewAmountDiscount) { - amountDiscount.validate() - } + fun asPackageWithAllocation(): NewPlanPackageWithAllocationPrice = + packageWithAllocation.getOrThrow("packageWithAllocation") - override fun visitMinimum(minimum: NewMinimum) { - minimum.validate() - } + fun asTieredWithProration(): NewPlanTierWithProrationPrice = + tieredWithProration.getOrThrow("tieredWithProration") - override fun visitMaximum(maximum: NewMaximum) { - maximum.validate() - } - } - ) - validated = true - } + fun asUnitWithProration(): NewPlanUnitWithProrationPrice = + unitWithProration.getOrThrow("unitWithProration") - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + fun asGroupedAllocation(): NewPlanGroupedAllocationPrice = + groupedAllocation.getOrThrow("groupedAllocation") - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitPercentageDiscount( - percentageDiscount: NewPercentageDiscount - ) = percentageDiscount.validity() + fun asGroupedWithProratedMinimum(): NewPlanGroupedWithProratedMinimumPrice = + groupedWithProratedMinimum.getOrThrow("groupedWithProratedMinimum") - override fun visitUsageDiscount(usageDiscount: NewUsageDiscount) = - usageDiscount.validity() + fun asGroupedWithMeteredMinimum(): NewPlanGroupedWithMeteredMinimumPrice = + groupedWithMeteredMinimum.getOrThrow("groupedWithMeteredMinimum") - override fun visitAmountDiscount(amountDiscount: NewAmountDiscount) = - amountDiscount.validity() + fun asGroupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds = + groupedWithMinMaxThresholds.getOrThrow("groupedWithMinMaxThresholds") - override fun visitMinimum(minimum: NewMinimum) = minimum.validity() + fun asMatrixWithDisplayName(): NewPlanMatrixWithDisplayNamePrice = + matrixWithDisplayName.getOrThrow("matrixWithDisplayName") - override fun visitMaximum(maximum: NewMaximum) = maximum.validity() + fun asBulkWithProration(): NewPlanBulkWithProrationPrice = + bulkWithProration.getOrThrow("bulkWithProration") - override fun unknown(json: JsonValue?) = 0 - } - ) + fun asGroupedTieredPackage(): NewPlanGroupedTieredPackagePrice = + groupedTieredPackage.getOrThrow("groupedTieredPackage") - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + fun asMaxGroupTieredPackage(): NewPlanMaxGroupTieredPackagePrice = + maxGroupTieredPackage.getOrThrow("maxGroupTieredPackage") - return other is Adjustment && - percentageDiscount == other.percentageDiscount && - usageDiscount == other.usageDiscount && - amountDiscount == other.amountDiscount && - minimum == other.minimum && - maximum == other.maximum - } + fun asScalableMatrixWithUnitPricing(): NewPlanScalableMatrixWithUnitPricingPrice = + scalableMatrixWithUnitPricing.getOrThrow("scalableMatrixWithUnitPricing") - override fun hashCode(): Int = - Objects.hash(percentageDiscount, usageDiscount, amountDiscount, minimum, maximum) + fun asScalableMatrixWithTieredPricing(): NewPlanScalableMatrixWithTieredPricingPrice = + scalableMatrixWithTieredPricing.getOrThrow("scalableMatrixWithTieredPricing") - override fun toString(): String = - when { - percentageDiscount != null -> - "Adjustment{percentageDiscount=$percentageDiscount}" - usageDiscount != null -> "Adjustment{usageDiscount=$usageDiscount}" - amountDiscount != null -> "Adjustment{amountDiscount=$amountDiscount}" - minimum != null -> "Adjustment{minimum=$minimum}" - maximum != null -> "Adjustment{maximum=$maximum}" - _json != null -> "Adjustment{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Adjustment") - } + fun asCumulativeGroupedBulk(): NewPlanCumulativeGroupedBulkPrice = + cumulativeGroupedBulk.getOrThrow("cumulativeGroupedBulk") - companion object { + fun asTieredPackageWithMinimum(): NewPlanTieredPackageWithMinimumPrice = + tieredPackageWithMinimum.getOrThrow("tieredPackageWithMinimum") - fun ofPercentageDiscount(percentageDiscount: NewPercentageDiscount) = - Adjustment(percentageDiscount = percentageDiscount) + fun asMatrixWithAllocation(): NewPlanMatrixWithAllocationPrice = + matrixWithAllocation.getOrThrow("matrixWithAllocation") - fun ofUsageDiscount(usageDiscount: NewUsageDiscount) = - Adjustment(usageDiscount = usageDiscount) + fun asGroupedTiered(): NewPlanGroupedTieredPrice = + groupedTiered.getOrThrow("groupedTiered") - fun ofAmountDiscount(amountDiscount: NewAmountDiscount) = - Adjustment(amountDiscount = amountDiscount) + fun asMinimum(): NewPlanMinimumCompositePrice = minimum.getOrThrow("minimum") - fun ofMinimum(minimum: NewMinimum) = Adjustment(minimum = minimum) + fun _json(): JsonValue? = _json - fun ofMaximum(maximum: NewMaximum) = Adjustment(maximum = maximum) - } + fun accept(visitor: Visitor): T = + when { + unit != null -> visitor.visitUnit(unit) + package_ != null -> visitor.visitPackage(package_) + matrix != null -> visitor.visitMatrix(matrix) + tiered != null -> visitor.visitTiered(tiered) + bulk != null -> visitor.visitBulk(bulk) + thresholdTotalAmount != null -> + visitor.visitThresholdTotalAmount(thresholdTotalAmount) + tieredPackage != null -> visitor.visitTieredPackage(tieredPackage) + tieredWithMinimum != null -> visitor.visitTieredWithMinimum(tieredWithMinimum) + unitWithPercent != null -> visitor.visitUnitWithPercent(unitWithPercent) + packageWithAllocation != null -> + visitor.visitPackageWithAllocation(packageWithAllocation) + tieredWithProration != null -> + visitor.visitTieredWithProration(tieredWithProration) + unitWithProration != null -> visitor.visitUnitWithProration(unitWithProration) + groupedAllocation != null -> visitor.visitGroupedAllocation(groupedAllocation) + groupedWithProratedMinimum != null -> + visitor.visitGroupedWithProratedMinimum(groupedWithProratedMinimum) + groupedWithMeteredMinimum != null -> + visitor.visitGroupedWithMeteredMinimum(groupedWithMeteredMinimum) + groupedWithMinMaxThresholds != null -> + visitor.visitGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds) + matrixWithDisplayName != null -> + visitor.visitMatrixWithDisplayName(matrixWithDisplayName) + bulkWithProration != null -> visitor.visitBulkWithProration(bulkWithProration) + groupedTieredPackage != null -> + visitor.visitGroupedTieredPackage(groupedTieredPackage) + maxGroupTieredPackage != null -> + visitor.visitMaxGroupTieredPackage(maxGroupTieredPackage) + scalableMatrixWithUnitPricing != null -> + visitor.visitScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing) + scalableMatrixWithTieredPricing != null -> + visitor.visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing + ) + cumulativeGroupedBulk != null -> + visitor.visitCumulativeGroupedBulk(cumulativeGroupedBulk) + tieredPackageWithMinimum != null -> + visitor.visitTieredPackageWithMinimum(tieredPackageWithMinimum) + matrixWithAllocation != null -> + visitor.visitMatrixWithAllocation(matrixWithAllocation) + groupedTiered != null -> visitor.visitGroupedTiered(groupedTiered) + minimum != null -> visitor.visitMinimum(minimum) + else -> visitor.unknown(_json) + } - /** - * An interface that defines how to map each variant of [Adjustment] to a value of type - * [T]. - */ - interface Visitor { + private var validated: Boolean = false - fun visitPercentageDiscount(percentageDiscount: NewPercentageDiscount): T + fun validate(): Price = apply { + if (validated) { + return@apply + } - fun visitUsageDiscount(usageDiscount: NewUsageDiscount): T + accept( + object : Visitor { + override fun visitUnit(unit: NewPlanUnitPrice) { + unit.validate() + } - fun visitAmountDiscount(amountDiscount: NewAmountDiscount): T + override fun visitPackage(package_: NewPlanPackagePrice) { + package_.validate() + } - fun visitMinimum(minimum: NewMinimum): T + override fun visitMatrix(matrix: NewPlanMatrixPrice) { + matrix.validate() + } - fun visitMaximum(maximum: NewMaximum): T + override fun visitTiered(tiered: NewPlanTieredPrice) { + tiered.validate() + } - /** - * Maps an unknown variant of [Adjustment] to a value of type [T]. - * - * An instance of [Adjustment] can contain an unknown variant if it was deserialized - * from data that doesn't match any known variant. For example, if the SDK is on an - * older version than the API, then the API may respond with new variants that the - * SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown Adjustment: $json") - } - } + override fun visitBulk(bulk: NewPlanBulkPrice) { + bulk.validate() + } - internal class Deserializer : BaseDeserializer(Adjustment::class) { + override fun visitThresholdTotalAmount( + thresholdTotalAmount: NewPlanThresholdTotalAmountPrice + ) { + thresholdTotalAmount.validate() + } - override fun ObjectCodec.deserialize(node: JsonNode): Adjustment { - val json = JsonValue.fromJsonNode(node) - val adjustmentType = json.asObject()?.get("adjustment_type")?.asString() + override fun visitTieredPackage(tieredPackage: NewPlanTieredPackagePrice) { + tieredPackage.validate() + } - when (adjustmentType) { - "percentage_discount" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Adjustment(percentageDiscount = it, _json = json) } - ?: Adjustment(_json = json) + override fun visitTieredWithMinimum( + tieredWithMinimum: NewPlanTieredWithMinimumPrice + ) { + tieredWithMinimum.validate() } - "usage_discount" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(usageDiscount = it, _json = json) - } ?: Adjustment(_json = json) + + override fun visitUnitWithPercent( + unitWithPercent: NewPlanUnitWithPercentPrice + ) { + unitWithPercent.validate() } - "amount_discount" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(amountDiscount = it, _json = json) - } ?: Adjustment(_json = json) + + override fun visitPackageWithAllocation( + packageWithAllocation: NewPlanPackageWithAllocationPrice + ) { + packageWithAllocation.validate() } - "minimum" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(minimum = it, _json = json) - } ?: Adjustment(_json = json) + + override fun visitTieredWithProration( + tieredWithProration: NewPlanTierWithProrationPrice + ) { + tieredWithProration.validate() } - "maximum" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(maximum = it, _json = json) - } ?: Adjustment(_json = json) + + override fun visitUnitWithProration( + unitWithProration: NewPlanUnitWithProrationPrice + ) { + unitWithProration.validate() } - } - return Adjustment(_json = json) - } - } + override fun visitGroupedAllocation( + groupedAllocation: NewPlanGroupedAllocationPrice + ) { + groupedAllocation.validate() + } - internal class Serializer : BaseSerializer(Adjustment::class) { + override fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice + ) { + groupedWithProratedMinimum.validate() + } - override fun serialize( - value: Adjustment, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.percentageDiscount != null -> - generator.writeObject(value.percentageDiscount) - value.usageDiscount != null -> generator.writeObject(value.usageDiscount) - value.amountDiscount != null -> generator.writeObject(value.amountDiscount) - value.minimum != null -> generator.writeObject(value.minimum) - value.maximum != null -> generator.writeObject(value.maximum) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Adjustment") - } - } - } - } + override fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice + ) { + groupedWithMeteredMinimum.validate() + } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + override fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) { + groupedWithMinMaxThresholds.validate() + } - return other is ReplaceAdjustment && - adjustment == other.adjustment && - replacesAdjustmentId == other.replacesAdjustmentId && - planPhaseOrder == other.planPhaseOrder && - additionalProperties == other.additionalProperties - } + override fun visitMatrixWithDisplayName( + matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice + ) { + matrixWithDisplayName.validate() + } - private val hashCode: Int by lazy { - Objects.hash(adjustment, replacesAdjustmentId, planPhaseOrder, additionalProperties) - } + override fun visitBulkWithProration( + bulkWithProration: NewPlanBulkWithProrationPrice + ) { + bulkWithProration.validate() + } - override fun hashCode(): Int = hashCode + override fun visitGroupedTieredPackage( + groupedTieredPackage: NewPlanGroupedTieredPackagePrice + ) { + groupedTieredPackage.validate() + } - override fun toString() = - "ReplaceAdjustment{adjustment=$adjustment, replacesAdjustmentId=$replacesAdjustmentId, planPhaseOrder=$planPhaseOrder, additionalProperties=$additionalProperties}" - } + override fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice + ) { + maxGroupTieredPackage.validate() + } - class ReplacePrice - private constructor( - private val replacesPriceId: JsonField, - private val allocationPrice: JsonField, - private val planPhaseOrder: JsonField, - private val price: JsonField, - private val additionalProperties: MutableMap, - ) { + override fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice + ) { + scalableMatrixWithUnitPricing.validate() + } - @JsonCreator - private constructor( - @JsonProperty("replaces_price_id") - @ExcludeMissing - replacesPriceId: JsonField = JsonMissing.of(), - @JsonProperty("allocation_price") - @ExcludeMissing - allocationPrice: JsonField = JsonMissing.of(), - @JsonProperty("plan_phase_order") - @ExcludeMissing - planPhaseOrder: JsonField = JsonMissing.of(), - @JsonProperty("price") @ExcludeMissing price: JsonField = JsonMissing.of(), - ) : this(replacesPriceId, allocationPrice, planPhaseOrder, price, mutableMapOf()) + override fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: + NewPlanScalableMatrixWithTieredPricingPrice + ) { + scalableMatrixWithTieredPricing.validate() + } - /** - * The id of the price on the plan to replace in the plan. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun replacesPriceId(): String = replacesPriceId.getRequired("replaces_price_id") + override fun visitCumulativeGroupedBulk( + cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice + ) { + cumulativeGroupedBulk.validate() + } - /** - * The allocation price to add to the plan. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun allocationPrice(): NewAllocationPrice? = allocationPrice.getNullable("allocation_price") + override fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice + ) { + tieredPackageWithMinimum.validate() + } - /** - * The phase to replace this price from. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun planPhaseOrder(): Long? = planPhaseOrder.getNullable("plan_phase_order") + override fun visitMatrixWithAllocation( + matrixWithAllocation: NewPlanMatrixWithAllocationPrice + ) { + matrixWithAllocation.validate() + } - /** - * The price to add to the plan - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun price(): Price? = price.getNullable("price") + override fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) { + groupedTiered.validate() + } - /** - * Returns the raw JSON value of [replacesPriceId]. - * - * Unlike [replacesPriceId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("replaces_price_id") - @ExcludeMissing - fun _replacesPriceId(): JsonField = replacesPriceId + override fun visitMinimum(minimum: NewPlanMinimumCompositePrice) { + minimum.validate() + } + } + ) + validated = true + } - /** - * Returns the raw JSON value of [allocationPrice]. - * - * Unlike [allocationPrice], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("allocation_price") - @ExcludeMissing - fun _allocationPrice(): JsonField = allocationPrice + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - /** - * Returns the raw JSON value of [planPhaseOrder]. - * - * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("plan_phase_order") - @ExcludeMissing - fun _planPhaseOrder(): JsonField = planPhaseOrder + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitUnit(unit: NewPlanUnitPrice) = unit.validity() - /** - * Returns the raw JSON value of [price]. - * - * Unlike [price], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("price") @ExcludeMissing fun _price(): JsonField = price + override fun visitPackage(package_: NewPlanPackagePrice) = + package_.validity() - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + override fun visitMatrix(matrix: NewPlanMatrixPrice) = matrix.validity() - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + override fun visitTiered(tiered: NewPlanTieredPrice) = tiered.validity() - fun toBuilder() = Builder().from(this) + override fun visitBulk(bulk: NewPlanBulkPrice) = bulk.validity() - companion object { + override fun visitThresholdTotalAmount( + thresholdTotalAmount: NewPlanThresholdTotalAmountPrice + ) = thresholdTotalAmount.validity() - /** - * Returns a mutable builder for constructing an instance of [ReplacePrice]. - * - * The following fields are required: - * ```kotlin - * .replacesPriceId() - * ``` - */ - fun builder() = Builder() - } + override fun visitTieredPackage(tieredPackage: NewPlanTieredPackagePrice) = + tieredPackage.validity() - /** A builder for [ReplacePrice]. */ - class Builder internal constructor() { + override fun visitTieredWithMinimum( + tieredWithMinimum: NewPlanTieredWithMinimumPrice + ) = tieredWithMinimum.validity() - private var replacesPriceId: JsonField? = null - private var allocationPrice: JsonField = JsonMissing.of() - private var planPhaseOrder: JsonField = JsonMissing.of() - private var price: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + override fun visitUnitWithPercent( + unitWithPercent: NewPlanUnitWithPercentPrice + ) = unitWithPercent.validity() - internal fun from(replacePrice: ReplacePrice) = apply { - replacesPriceId = replacePrice.replacesPriceId - allocationPrice = replacePrice.allocationPrice - planPhaseOrder = replacePrice.planPhaseOrder - price = replacePrice.price - additionalProperties = replacePrice.additionalProperties.toMutableMap() - } + override fun visitPackageWithAllocation( + packageWithAllocation: NewPlanPackageWithAllocationPrice + ) = packageWithAllocation.validity() - /** The id of the price on the plan to replace in the plan. */ - fun replacesPriceId(replacesPriceId: String) = - replacesPriceId(JsonField.of(replacesPriceId)) + override fun visitTieredWithProration( + tieredWithProration: NewPlanTierWithProrationPrice + ) = tieredWithProration.validity() - /** - * Sets [Builder.replacesPriceId] to an arbitrary JSON value. - * - * You should usually call [Builder.replacesPriceId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun replacesPriceId(replacesPriceId: JsonField) = apply { - this.replacesPriceId = replacesPriceId - } + override fun visitUnitWithProration( + unitWithProration: NewPlanUnitWithProrationPrice + ) = unitWithProration.validity() - /** The allocation price to add to the plan. */ - fun allocationPrice(allocationPrice: NewAllocationPrice?) = - allocationPrice(JsonField.ofNullable(allocationPrice)) + override fun visitGroupedAllocation( + groupedAllocation: NewPlanGroupedAllocationPrice + ) = groupedAllocation.validity() - /** - * Sets [Builder.allocationPrice] to an arbitrary JSON value. - * - * You should usually call [Builder.allocationPrice] with a well-typed - * [NewAllocationPrice] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun allocationPrice(allocationPrice: JsonField) = apply { - this.allocationPrice = allocationPrice - } + override fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice + ) = groupedWithProratedMinimum.validity() - /** The phase to replace this price from. */ - fun planPhaseOrder(planPhaseOrder: Long?) = - planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + override fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice + ) = groupedWithMeteredMinimum.validity() - /** - * Alias for [Builder.planPhaseOrder]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + override fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) = groupedWithMinMaxThresholds.validity() - /** - * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. - * - * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun planPhaseOrder(planPhaseOrder: JsonField) = apply { - this.planPhaseOrder = planPhaseOrder - } + override fun visitMatrixWithDisplayName( + matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice + ) = matrixWithDisplayName.validity() - /** The price to add to the plan */ - fun price(price: Price?) = price(JsonField.ofNullable(price)) + override fun visitBulkWithProration( + bulkWithProration: NewPlanBulkWithProrationPrice + ) = bulkWithProration.validity() - /** - * Sets [Builder.price] to an arbitrary JSON value. - * - * You should usually call [Builder.price] with a well-typed [Price] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun price(price: JsonField) = apply { this.price = price } + override fun visitGroupedTieredPackage( + groupedTieredPackage: NewPlanGroupedTieredPackagePrice + ) = groupedTieredPackage.validity() - /** Alias for calling [price] with `Price.ofUnit(unit)`. */ - fun price(unit: NewPlanUnitPrice) = price(Price.ofUnit(unit)) + override fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice + ) = maxGroupTieredPackage.validity() - /** Alias for calling [price] with `Price.ofPackage(package_)`. */ - fun price(package_: NewPlanPackagePrice) = price(Price.ofPackage(package_)) + override fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice + ) = scalableMatrixWithUnitPricing.validity() - /** Alias for calling [price] with `Price.ofMatrix(matrix)`. */ - fun price(matrix: NewPlanMatrixPrice) = price(Price.ofMatrix(matrix)) + override fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: + NewPlanScalableMatrixWithTieredPricingPrice + ) = scalableMatrixWithTieredPricing.validity() - /** Alias for calling [price] with `Price.ofTiered(tiered)`. */ - fun price(tiered: NewPlanTieredPrice) = price(Price.ofTiered(tiered)) + override fun visitCumulativeGroupedBulk( + cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice + ) = cumulativeGroupedBulk.validity() - /** Alias for calling [price] with `Price.ofBulk(bulk)`. */ - fun price(bulk: NewPlanBulkPrice) = price(Price.ofBulk(bulk)) + override fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice + ) = tieredPackageWithMinimum.validity() - /** - * Alias for calling [price] with `Price.ofThresholdTotalAmount(thresholdTotalAmount)`. - */ - fun price(thresholdTotalAmount: NewPlanThresholdTotalAmountPrice) = - price(Price.ofThresholdTotalAmount(thresholdTotalAmount)) + override fun visitMatrixWithAllocation( + matrixWithAllocation: NewPlanMatrixWithAllocationPrice + ) = matrixWithAllocation.validity() - /** Alias for calling [price] with `Price.ofTieredPackage(tieredPackage)`. */ - fun price(tieredPackage: NewPlanTieredPackagePrice) = - price(Price.ofTieredPackage(tieredPackage)) + override fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) = + groupedTiered.validity() - /** Alias for calling [price] with `Price.ofTieredWithMinimum(tieredWithMinimum)`. */ - fun price(tieredWithMinimum: NewPlanTieredWithMinimumPrice) = - price(Price.ofTieredWithMinimum(tieredWithMinimum)) + override fun visitMinimum(minimum: NewPlanMinimumCompositePrice) = + minimum.validity() - /** Alias for calling [price] with `Price.ofUnitWithPercent(unitWithPercent)`. */ - fun price(unitWithPercent: NewPlanUnitWithPercentPrice) = - price(Price.ofUnitWithPercent(unitWithPercent)) + override fun unknown(json: JsonValue?) = 0 + } + ) - /** - * Alias for calling [price] with - * `Price.ofPackageWithAllocation(packageWithAllocation)`. - */ - fun price(packageWithAllocation: NewPlanPackageWithAllocationPrice) = - price(Price.ofPackageWithAllocation(packageWithAllocation)) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * Alias for calling [price] with `Price.ofTieredWithProration(tieredWithProration)`. - */ - fun price(tieredWithProration: NewPlanTierWithProrationPrice) = - price(Price.ofTieredWithProration(tieredWithProration)) + return other is Price && + unit == other.unit && + package_ == other.package_ && + matrix == other.matrix && + tiered == other.tiered && + bulk == other.bulk && + thresholdTotalAmount == other.thresholdTotalAmount && + tieredPackage == other.tieredPackage && + tieredWithMinimum == other.tieredWithMinimum && + unitWithPercent == other.unitWithPercent && + packageWithAllocation == other.packageWithAllocation && + tieredWithProration == other.tieredWithProration && + unitWithProration == other.unitWithProration && + groupedAllocation == other.groupedAllocation && + groupedWithProratedMinimum == other.groupedWithProratedMinimum && + groupedWithMeteredMinimum == other.groupedWithMeteredMinimum && + groupedWithMinMaxThresholds == other.groupedWithMinMaxThresholds && + matrixWithDisplayName == other.matrixWithDisplayName && + bulkWithProration == other.bulkWithProration && + groupedTieredPackage == other.groupedTieredPackage && + maxGroupTieredPackage == other.maxGroupTieredPackage && + scalableMatrixWithUnitPricing == other.scalableMatrixWithUnitPricing && + scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && + cumulativeGroupedBulk == other.cumulativeGroupedBulk && + tieredPackageWithMinimum == other.tieredPackageWithMinimum && + matrixWithAllocation == other.matrixWithAllocation && + groupedTiered == other.groupedTiered && + minimum == other.minimum + } - /** Alias for calling [price] with `Price.ofUnitWithProration(unitWithProration)`. */ - fun price(unitWithProration: NewPlanUnitWithProrationPrice) = - price(Price.ofUnitWithProration(unitWithProration)) + override fun hashCode(): Int = + Objects.hash( + unit, + package_, + matrix, + tiered, + bulk, + thresholdTotalAmount, + tieredPackage, + tieredWithMinimum, + unitWithPercent, + packageWithAllocation, + tieredWithProration, + unitWithProration, + groupedAllocation, + groupedWithProratedMinimum, + groupedWithMeteredMinimum, + groupedWithMinMaxThresholds, + matrixWithDisplayName, + bulkWithProration, + groupedTieredPackage, + maxGroupTieredPackage, + scalableMatrixWithUnitPricing, + scalableMatrixWithTieredPricing, + cumulativeGroupedBulk, + tieredPackageWithMinimum, + matrixWithAllocation, + groupedTiered, + minimum, + ) - /** Alias for calling [price] with `Price.ofGroupedAllocation(groupedAllocation)`. */ - fun price(groupedAllocation: NewPlanGroupedAllocationPrice) = - price(Price.ofGroupedAllocation(groupedAllocation)) + override fun toString(): String = + when { + unit != null -> "Price{unit=$unit}" + package_ != null -> "Price{package_=$package_}" + matrix != null -> "Price{matrix=$matrix}" + tiered != null -> "Price{tiered=$tiered}" + bulk != null -> "Price{bulk=$bulk}" + thresholdTotalAmount != null -> + "Price{thresholdTotalAmount=$thresholdTotalAmount}" + tieredPackage != null -> "Price{tieredPackage=$tieredPackage}" + tieredWithMinimum != null -> "Price{tieredWithMinimum=$tieredWithMinimum}" + unitWithPercent != null -> "Price{unitWithPercent=$unitWithPercent}" + packageWithAllocation != null -> + "Price{packageWithAllocation=$packageWithAllocation}" + tieredWithProration != null -> "Price{tieredWithProration=$tieredWithProration}" + unitWithProration != null -> "Price{unitWithProration=$unitWithProration}" + groupedAllocation != null -> "Price{groupedAllocation=$groupedAllocation}" + groupedWithProratedMinimum != null -> + "Price{groupedWithProratedMinimum=$groupedWithProratedMinimum}" + groupedWithMeteredMinimum != null -> + "Price{groupedWithMeteredMinimum=$groupedWithMeteredMinimum}" + groupedWithMinMaxThresholds != null -> + "Price{groupedWithMinMaxThresholds=$groupedWithMinMaxThresholds}" + matrixWithDisplayName != null -> + "Price{matrixWithDisplayName=$matrixWithDisplayName}" + bulkWithProration != null -> "Price{bulkWithProration=$bulkWithProration}" + groupedTieredPackage != null -> + "Price{groupedTieredPackage=$groupedTieredPackage}" + maxGroupTieredPackage != null -> + "Price{maxGroupTieredPackage=$maxGroupTieredPackage}" + scalableMatrixWithUnitPricing != null -> + "Price{scalableMatrixWithUnitPricing=$scalableMatrixWithUnitPricing}" + scalableMatrixWithTieredPricing != null -> + "Price{scalableMatrixWithTieredPricing=$scalableMatrixWithTieredPricing}" + cumulativeGroupedBulk != null -> + "Price{cumulativeGroupedBulk=$cumulativeGroupedBulk}" + tieredPackageWithMinimum != null -> + "Price{tieredPackageWithMinimum=$tieredPackageWithMinimum}" + matrixWithAllocation != null -> + "Price{matrixWithAllocation=$matrixWithAllocation}" + groupedTiered != null -> "Price{groupedTiered=$groupedTiered}" + minimum != null -> "Price{minimum=$minimum}" + _json != null -> "Price{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Price") + } - /** - * Alias for calling [price] with - * `Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)`. - */ - fun price(groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice) = - price(Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)) + companion object { - /** - * Alias for calling [price] with - * `Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)`. - */ - fun price(groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice) = - price(Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)) + fun ofUnit(unit: NewPlanUnitPrice) = Price(unit = unit) - /** - * Alias for calling [price] with - * `Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)`. - */ - fun price(groupedWithMinMaxThresholds: Price.GroupedWithMinMaxThresholds) = - price(Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)) + fun ofPackage(package_: NewPlanPackagePrice) = Price(package_ = package_) - /** - * Alias for calling [price] with - * `Price.ofMatrixWithDisplayName(matrixWithDisplayName)`. - */ - fun price(matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice) = - price(Price.ofMatrixWithDisplayName(matrixWithDisplayName)) + fun ofMatrix(matrix: NewPlanMatrixPrice) = Price(matrix = matrix) - /** Alias for calling [price] with `Price.ofBulkWithProration(bulkWithProration)`. */ - fun price(bulkWithProration: NewPlanBulkWithProrationPrice) = - price(Price.ofBulkWithProration(bulkWithProration)) + fun ofTiered(tiered: NewPlanTieredPrice) = Price(tiered = tiered) - /** - * Alias for calling [price] with `Price.ofGroupedTieredPackage(groupedTieredPackage)`. - */ - fun price(groupedTieredPackage: NewPlanGroupedTieredPackagePrice) = - price(Price.ofGroupedTieredPackage(groupedTieredPackage)) + fun ofBulk(bulk: NewPlanBulkPrice) = Price(bulk = bulk) - /** - * Alias for calling [price] with - * `Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)`. - */ - fun price(maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice) = - price(Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)) + fun ofThresholdTotalAmount(thresholdTotalAmount: NewPlanThresholdTotalAmountPrice) = + Price(thresholdTotalAmount = thresholdTotalAmount) - /** - * Alias for calling [price] with - * `Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)`. - */ - fun price(scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice) = - price(Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)) - - /** - * Alias for calling [price] with - * `Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)`. - */ - fun price( - scalableMatrixWithTieredPricing: NewPlanScalableMatrixWithTieredPricingPrice - ) = price(Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)) + fun ofTieredPackage(tieredPackage: NewPlanTieredPackagePrice) = + Price(tieredPackage = tieredPackage) - /** - * Alias for calling [price] with - * `Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)`. - */ - fun price(cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice) = - price(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) + fun ofTieredWithMinimum(tieredWithMinimum: NewPlanTieredWithMinimumPrice) = + Price(tieredWithMinimum = tieredWithMinimum) - /** - * Alias for calling [price] with - * `Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)`. - */ - fun price(tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice) = - price(Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)) + fun ofUnitWithPercent(unitWithPercent: NewPlanUnitWithPercentPrice) = + Price(unitWithPercent = unitWithPercent) - /** - * Alias for calling [price] with `Price.ofMatrixWithAllocation(matrixWithAllocation)`. - */ - fun price(matrixWithAllocation: NewPlanMatrixWithAllocationPrice) = - price(Price.ofMatrixWithAllocation(matrixWithAllocation)) + fun ofPackageWithAllocation( + packageWithAllocation: NewPlanPackageWithAllocationPrice + ) = Price(packageWithAllocation = packageWithAllocation) - /** Alias for calling [price] with `Price.ofGroupedTiered(groupedTiered)`. */ - fun price(groupedTiered: NewPlanGroupedTieredPrice) = - price(Price.ofGroupedTiered(groupedTiered)) + fun ofTieredWithProration(tieredWithProration: NewPlanTierWithProrationPrice) = + Price(tieredWithProration = tieredWithProration) - /** Alias for calling [price] with `Price.ofMinimum(minimum)`. */ - fun price(minimum: Price.Minimum) = price(Price.ofMinimum(minimum)) + fun ofUnitWithProration(unitWithProration: NewPlanUnitWithProrationPrice) = + Price(unitWithProration = unitWithProration) - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun ofGroupedAllocation(groupedAllocation: NewPlanGroupedAllocationPrice) = + Price(groupedAllocation = groupedAllocation) - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun ofGroupedWithProratedMinimum( + groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice + ) = Price(groupedWithProratedMinimum = groupedWithProratedMinimum) - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun ofGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice + ) = Price(groupedWithMeteredMinimum = groupedWithMeteredMinimum) - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun ofGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) = Price(groupedWithMinMaxThresholds = groupedWithMinMaxThresholds) - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun ofMatrixWithDisplayName( + matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice + ) = Price(matrixWithDisplayName = matrixWithDisplayName) - /** - * Returns an immutable instance of [ReplacePrice]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```kotlin - * .replacesPriceId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): ReplacePrice = - ReplacePrice( - checkRequired("replacesPriceId", replacesPriceId), - allocationPrice, - planPhaseOrder, - price, - additionalProperties.toMutableMap(), - ) - } + fun ofBulkWithProration(bulkWithProration: NewPlanBulkWithProrationPrice) = + Price(bulkWithProration = bulkWithProration) - private var validated: Boolean = false + fun ofGroupedTieredPackage(groupedTieredPackage: NewPlanGroupedTieredPackagePrice) = + Price(groupedTieredPackage = groupedTieredPackage) - fun validate(): ReplacePrice = apply { - if (validated) { - return@apply - } + fun ofMaxGroupTieredPackage( + maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice + ) = Price(maxGroupTieredPackage = maxGroupTieredPackage) - replacesPriceId() - allocationPrice()?.validate() - planPhaseOrder() - price()?.validate() - validated = true - } + fun ofScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice + ) = Price(scalableMatrixWithUnitPricing = scalableMatrixWithUnitPricing) - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + fun ofScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: NewPlanScalableMatrixWithTieredPricingPrice + ) = Price(scalableMatrixWithTieredPricing = scalableMatrixWithTieredPricing) - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (if (replacesPriceId.asKnown() == null) 0 else 1) + - (allocationPrice.asKnown()?.validity() ?: 0) + - (if (planPhaseOrder.asKnown() == null) 0 else 1) + - (price.asKnown()?.validity() ?: 0) + fun ofCumulativeGroupedBulk( + cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice + ) = Price(cumulativeGroupedBulk = cumulativeGroupedBulk) - /** The price to add to the plan */ - @JsonDeserialize(using = Price.Deserializer::class) - @JsonSerialize(using = Price.Serializer::class) - class Price - private constructor( - private val unit: NewPlanUnitPrice? = null, - private val package_: NewPlanPackagePrice? = null, - private val matrix: NewPlanMatrixPrice? = null, - private val tiered: NewPlanTieredPrice? = null, - private val bulk: NewPlanBulkPrice? = null, - private val thresholdTotalAmount: NewPlanThresholdTotalAmountPrice? = null, - private val tieredPackage: NewPlanTieredPackagePrice? = null, - private val tieredWithMinimum: NewPlanTieredWithMinimumPrice? = null, - private val unitWithPercent: NewPlanUnitWithPercentPrice? = null, - private val packageWithAllocation: NewPlanPackageWithAllocationPrice? = null, - private val tieredWithProration: NewPlanTierWithProrationPrice? = null, - private val unitWithProration: NewPlanUnitWithProrationPrice? = null, - private val groupedAllocation: NewPlanGroupedAllocationPrice? = null, - private val groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice? = null, - private val groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice? = null, - private val groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds? = null, - private val matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice? = null, - private val bulkWithProration: NewPlanBulkWithProrationPrice? = null, - private val groupedTieredPackage: NewPlanGroupedTieredPackagePrice? = null, - private val maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice? = null, - private val scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice? = - null, - private val scalableMatrixWithTieredPricing: - NewPlanScalableMatrixWithTieredPricingPrice? = - null, - private val cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice? = null, - private val tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice? = null, - private val matrixWithAllocation: NewPlanMatrixWithAllocationPrice? = null, - private val groupedTiered: NewPlanGroupedTieredPrice? = null, - private val minimum: Minimum? = null, - private val _json: JsonValue? = null, - ) { + fun ofTieredPackageWithMinimum( + tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice + ) = Price(tieredPackageWithMinimum = tieredPackageWithMinimum) - fun unit(): NewPlanUnitPrice? = unit + fun ofMatrixWithAllocation(matrixWithAllocation: NewPlanMatrixWithAllocationPrice) = + Price(matrixWithAllocation = matrixWithAllocation) - fun package_(): NewPlanPackagePrice? = package_ + fun ofGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) = + Price(groupedTiered = groupedTiered) - fun matrix(): NewPlanMatrixPrice? = matrix + fun ofMinimum(minimum: NewPlanMinimumCompositePrice) = Price(minimum = minimum) + } - fun tiered(): NewPlanTieredPrice? = tiered + /** + * An interface that defines how to map each variant of [Price] to a value of type [T]. + */ + interface Visitor { - fun bulk(): NewPlanBulkPrice? = bulk + fun visitUnit(unit: NewPlanUnitPrice): T - fun thresholdTotalAmount(): NewPlanThresholdTotalAmountPrice? = thresholdTotalAmount + fun visitPackage(package_: NewPlanPackagePrice): T - fun tieredPackage(): NewPlanTieredPackagePrice? = tieredPackage + fun visitMatrix(matrix: NewPlanMatrixPrice): T - fun tieredWithMinimum(): NewPlanTieredWithMinimumPrice? = tieredWithMinimum + fun visitTiered(tiered: NewPlanTieredPrice): T - fun unitWithPercent(): NewPlanUnitWithPercentPrice? = unitWithPercent + fun visitBulk(bulk: NewPlanBulkPrice): T - fun packageWithAllocation(): NewPlanPackageWithAllocationPrice? = packageWithAllocation + fun visitThresholdTotalAmount( + thresholdTotalAmount: NewPlanThresholdTotalAmountPrice + ): T - fun tieredWithProration(): NewPlanTierWithProrationPrice? = tieredWithProration + fun visitTieredPackage(tieredPackage: NewPlanTieredPackagePrice): T - fun unitWithProration(): NewPlanUnitWithProrationPrice? = unitWithProration + fun visitTieredWithMinimum(tieredWithMinimum: NewPlanTieredWithMinimumPrice): T - fun groupedAllocation(): NewPlanGroupedAllocationPrice? = groupedAllocation + fun visitUnitWithPercent(unitWithPercent: NewPlanUnitWithPercentPrice): T - fun groupedWithProratedMinimum(): NewPlanGroupedWithProratedMinimumPrice? = - groupedWithProratedMinimum + fun visitPackageWithAllocation( + packageWithAllocation: NewPlanPackageWithAllocationPrice + ): T - fun groupedWithMeteredMinimum(): NewPlanGroupedWithMeteredMinimumPrice? = - groupedWithMeteredMinimum + fun visitTieredWithProration(tieredWithProration: NewPlanTierWithProrationPrice): T - fun groupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds? = - groupedWithMinMaxThresholds + fun visitUnitWithProration(unitWithProration: NewPlanUnitWithProrationPrice): T - fun matrixWithDisplayName(): NewPlanMatrixWithDisplayNamePrice? = matrixWithDisplayName + fun visitGroupedAllocation(groupedAllocation: NewPlanGroupedAllocationPrice): T - fun bulkWithProration(): NewPlanBulkWithProrationPrice? = bulkWithProration + fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice + ): T - fun groupedTieredPackage(): NewPlanGroupedTieredPackagePrice? = groupedTieredPackage + fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice + ): T - fun maxGroupTieredPackage(): NewPlanMaxGroupTieredPackagePrice? = maxGroupTieredPackage + fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ): T - fun scalableMatrixWithUnitPricing(): NewPlanScalableMatrixWithUnitPricingPrice? = - scalableMatrixWithUnitPricing + fun visitMatrixWithDisplayName( + matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice + ): T - fun scalableMatrixWithTieredPricing(): NewPlanScalableMatrixWithTieredPricingPrice? = - scalableMatrixWithTieredPricing + fun visitBulkWithProration(bulkWithProration: NewPlanBulkWithProrationPrice): T - fun cumulativeGroupedBulk(): NewPlanCumulativeGroupedBulkPrice? = cumulativeGroupedBulk + fun visitGroupedTieredPackage( + groupedTieredPackage: NewPlanGroupedTieredPackagePrice + ): T - fun tieredPackageWithMinimum(): NewPlanTieredPackageWithMinimumPrice? = - tieredPackageWithMinimum + fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice + ): T - fun matrixWithAllocation(): NewPlanMatrixWithAllocationPrice? = matrixWithAllocation + fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice + ): T - fun groupedTiered(): NewPlanGroupedTieredPrice? = groupedTiered - - fun minimum(): Minimum? = minimum - - fun isUnit(): Boolean = unit != null - - fun isPackage(): Boolean = package_ != null - - fun isMatrix(): Boolean = matrix != null - - fun isTiered(): Boolean = tiered != null - - fun isBulk(): Boolean = bulk != null - - fun isThresholdTotalAmount(): Boolean = thresholdTotalAmount != null - - fun isTieredPackage(): Boolean = tieredPackage != null - - fun isTieredWithMinimum(): Boolean = tieredWithMinimum != null - - fun isUnitWithPercent(): Boolean = unitWithPercent != null - - fun isPackageWithAllocation(): Boolean = packageWithAllocation != null - - fun isTieredWithProration(): Boolean = tieredWithProration != null - - fun isUnitWithProration(): Boolean = unitWithProration != null - - fun isGroupedAllocation(): Boolean = groupedAllocation != null - - fun isGroupedWithProratedMinimum(): Boolean = groupedWithProratedMinimum != null - - fun isGroupedWithMeteredMinimum(): Boolean = groupedWithMeteredMinimum != null - - fun isGroupedWithMinMaxThresholds(): Boolean = groupedWithMinMaxThresholds != null - - fun isMatrixWithDisplayName(): Boolean = matrixWithDisplayName != null - - fun isBulkWithProration(): Boolean = bulkWithProration != null - - fun isGroupedTieredPackage(): Boolean = groupedTieredPackage != null - - fun isMaxGroupTieredPackage(): Boolean = maxGroupTieredPackage != null - - fun isScalableMatrixWithUnitPricing(): Boolean = scalableMatrixWithUnitPricing != null - - fun isScalableMatrixWithTieredPricing(): Boolean = - scalableMatrixWithTieredPricing != null - - fun isCumulativeGroupedBulk(): Boolean = cumulativeGroupedBulk != null - - fun isTieredPackageWithMinimum(): Boolean = tieredPackageWithMinimum != null - - fun isMatrixWithAllocation(): Boolean = matrixWithAllocation != null - - fun isGroupedTiered(): Boolean = groupedTiered != null - - fun isMinimum(): Boolean = minimum != null - - fun asUnit(): NewPlanUnitPrice = unit.getOrThrow("unit") - - fun asPackage(): NewPlanPackagePrice = package_.getOrThrow("package_") - - fun asMatrix(): NewPlanMatrixPrice = matrix.getOrThrow("matrix") - - fun asTiered(): NewPlanTieredPrice = tiered.getOrThrow("tiered") - - fun asBulk(): NewPlanBulkPrice = bulk.getOrThrow("bulk") - - fun asThresholdTotalAmount(): NewPlanThresholdTotalAmountPrice = - thresholdTotalAmount.getOrThrow("thresholdTotalAmount") - - fun asTieredPackage(): NewPlanTieredPackagePrice = - tieredPackage.getOrThrow("tieredPackage") - - fun asTieredWithMinimum(): NewPlanTieredWithMinimumPrice = - tieredWithMinimum.getOrThrow("tieredWithMinimum") - - fun asUnitWithPercent(): NewPlanUnitWithPercentPrice = - unitWithPercent.getOrThrow("unitWithPercent") - - fun asPackageWithAllocation(): NewPlanPackageWithAllocationPrice = - packageWithAllocation.getOrThrow("packageWithAllocation") - - fun asTieredWithProration(): NewPlanTierWithProrationPrice = - tieredWithProration.getOrThrow("tieredWithProration") - - fun asUnitWithProration(): NewPlanUnitWithProrationPrice = - unitWithProration.getOrThrow("unitWithProration") - - fun asGroupedAllocation(): NewPlanGroupedAllocationPrice = - groupedAllocation.getOrThrow("groupedAllocation") - - fun asGroupedWithProratedMinimum(): NewPlanGroupedWithProratedMinimumPrice = - groupedWithProratedMinimum.getOrThrow("groupedWithProratedMinimum") - - fun asGroupedWithMeteredMinimum(): NewPlanGroupedWithMeteredMinimumPrice = - groupedWithMeteredMinimum.getOrThrow("groupedWithMeteredMinimum") - - fun asGroupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds = - groupedWithMinMaxThresholds.getOrThrow("groupedWithMinMaxThresholds") - - fun asMatrixWithDisplayName(): NewPlanMatrixWithDisplayNamePrice = - matrixWithDisplayName.getOrThrow("matrixWithDisplayName") - - fun asBulkWithProration(): NewPlanBulkWithProrationPrice = - bulkWithProration.getOrThrow("bulkWithProration") - - fun asGroupedTieredPackage(): NewPlanGroupedTieredPackagePrice = - groupedTieredPackage.getOrThrow("groupedTieredPackage") - - fun asMaxGroupTieredPackage(): NewPlanMaxGroupTieredPackagePrice = - maxGroupTieredPackage.getOrThrow("maxGroupTieredPackage") - - fun asScalableMatrixWithUnitPricing(): NewPlanScalableMatrixWithUnitPricingPrice = - scalableMatrixWithUnitPricing.getOrThrow("scalableMatrixWithUnitPricing") - - fun asScalableMatrixWithTieredPricing(): NewPlanScalableMatrixWithTieredPricingPrice = - scalableMatrixWithTieredPricing.getOrThrow("scalableMatrixWithTieredPricing") - - fun asCumulativeGroupedBulk(): NewPlanCumulativeGroupedBulkPrice = - cumulativeGroupedBulk.getOrThrow("cumulativeGroupedBulk") + fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: NewPlanScalableMatrixWithTieredPricingPrice + ): T - fun asTieredPackageWithMinimum(): NewPlanTieredPackageWithMinimumPrice = - tieredPackageWithMinimum.getOrThrow("tieredPackageWithMinimum") + fun visitCumulativeGroupedBulk( + cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice + ): T - fun asMatrixWithAllocation(): NewPlanMatrixWithAllocationPrice = - matrixWithAllocation.getOrThrow("matrixWithAllocation") + fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice + ): T - fun asGroupedTiered(): NewPlanGroupedTieredPrice = - groupedTiered.getOrThrow("groupedTiered") + fun visitMatrixWithAllocation( + matrixWithAllocation: NewPlanMatrixWithAllocationPrice + ): T - fun asMinimum(): Minimum = minimum.getOrThrow("minimum") + fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice): T - fun _json(): JsonValue? = _json + fun visitMinimum(minimum: NewPlanMinimumCompositePrice): T - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - package_ != null -> visitor.visitPackage(package_) - matrix != null -> visitor.visitMatrix(matrix) - tiered != null -> visitor.visitTiered(tiered) - bulk != null -> visitor.visitBulk(bulk) - thresholdTotalAmount != null -> - visitor.visitThresholdTotalAmount(thresholdTotalAmount) - tieredPackage != null -> visitor.visitTieredPackage(tieredPackage) - tieredWithMinimum != null -> visitor.visitTieredWithMinimum(tieredWithMinimum) - unitWithPercent != null -> visitor.visitUnitWithPercent(unitWithPercent) - packageWithAllocation != null -> - visitor.visitPackageWithAllocation(packageWithAllocation) - tieredWithProration != null -> - visitor.visitTieredWithProration(tieredWithProration) - unitWithProration != null -> visitor.visitUnitWithProration(unitWithProration) - groupedAllocation != null -> visitor.visitGroupedAllocation(groupedAllocation) - groupedWithProratedMinimum != null -> - visitor.visitGroupedWithProratedMinimum(groupedWithProratedMinimum) - groupedWithMeteredMinimum != null -> - visitor.visitGroupedWithMeteredMinimum(groupedWithMeteredMinimum) - groupedWithMinMaxThresholds != null -> - visitor.visitGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds) - matrixWithDisplayName != null -> - visitor.visitMatrixWithDisplayName(matrixWithDisplayName) - bulkWithProration != null -> visitor.visitBulkWithProration(bulkWithProration) - groupedTieredPackage != null -> - visitor.visitGroupedTieredPackage(groupedTieredPackage) - maxGroupTieredPackage != null -> - visitor.visitMaxGroupTieredPackage(maxGroupTieredPackage) - scalableMatrixWithUnitPricing != null -> - visitor.visitScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing) - scalableMatrixWithTieredPricing != null -> - visitor.visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing - ) - cumulativeGroupedBulk != null -> - visitor.visitCumulativeGroupedBulk(cumulativeGroupedBulk) - tieredPackageWithMinimum != null -> - visitor.visitTieredPackageWithMinimum(tieredPackageWithMinimum) - matrixWithAllocation != null -> - visitor.visitMatrixWithAllocation(matrixWithAllocation) - groupedTiered != null -> visitor.visitGroupedTiered(groupedTiered) - minimum != null -> visitor.visitMinimum(minimum) - else -> visitor.unknown(_json) + /** + * Maps an unknown variant of [Price] to a value of type [T]. + * + * An instance of [Price] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is + * unaware of. + * + * @throws OrbInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw OrbInvalidDataException("Unknown Price: $json") } + } - private var validated: Boolean = false + internal class Deserializer : BaseDeserializer(Price::class) { - fun validate(): Price = apply { - if (validated) { - return@apply - } + override fun ObjectCodec.deserialize(node: JsonNode): Price { + val json = JsonValue.fromJsonNode(node) + val modelType = json.asObject()?.get("model_type")?.asString() - accept( - object : Visitor { - override fun visitUnit(unit: NewPlanUnitPrice) { - unit.validate() + when (modelType) { + "unit" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(unit = it, _json = json) + } ?: Price(_json = json) } - - override fun visitPackage(package_: NewPlanPackagePrice) { - package_.validate() + "package" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(package_ = it, _json = json) } ?: Price(_json = json) } - - override fun visitMatrix(matrix: NewPlanMatrixPrice) { - matrix.validate() + "matrix" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(matrix = it, _json = json) + } ?: Price(_json = json) } - - override fun visitTiered(tiered: NewPlanTieredPrice) { - tiered.validate() + "tiered" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(tiered = it, _json = json) + } ?: Price(_json = json) } - - override fun visitBulk(bulk: NewPlanBulkPrice) { - bulk.validate() + "bulk" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(bulk = it, _json = json) + } ?: Price(_json = json) } - - override fun visitThresholdTotalAmount( - thresholdTotalAmount: NewPlanThresholdTotalAmountPrice - ) { - thresholdTotalAmount.validate() + "threshold_total_amount" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(thresholdTotalAmount = it, _json = json) } + ?: Price(_json = json) } - - override fun visitTieredPackage(tieredPackage: NewPlanTieredPackagePrice) { - tieredPackage.validate() - } - - override fun visitTieredWithMinimum( - tieredWithMinimum: NewPlanTieredWithMinimumPrice - ) { - tieredWithMinimum.validate() + "tiered_package" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(tieredPackage = it, _json = json) } + ?: Price(_json = json) } - - override fun visitUnitWithPercent( - unitWithPercent: NewPlanUnitWithPercentPrice - ) { - unitWithPercent.validate() + "tiered_with_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(tieredWithMinimum = it, _json = json) } + ?: Price(_json = json) } - - override fun visitPackageWithAllocation( - packageWithAllocation: NewPlanPackageWithAllocationPrice - ) { - packageWithAllocation.validate() + "unit_with_percent" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(unitWithPercent = it, _json = json) } + ?: Price(_json = json) } - - override fun visitTieredWithProration( - tieredWithProration: NewPlanTierWithProrationPrice - ) { - tieredWithProration.validate() + "package_with_allocation" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(packageWithAllocation = it, _json = json) } + ?: Price(_json = json) } - - override fun visitUnitWithProration( - unitWithProration: NewPlanUnitWithProrationPrice - ) { - unitWithProration.validate() + "tiered_with_proration" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(tieredWithProration = it, _json = json) } + ?: Price(_json = json) } - - override fun visitGroupedAllocation( - groupedAllocation: NewPlanGroupedAllocationPrice - ) { - groupedAllocation.validate() + "unit_with_proration" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(unitWithProration = it, _json = json) } + ?: Price(_json = json) } - - override fun visitGroupedWithProratedMinimum( - groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice - ) { - groupedWithProratedMinimum.validate() + "grouped_allocation" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedAllocation = it, _json = json) } + ?: Price(_json = json) } - - override fun visitGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice - ) { - groupedWithMeteredMinimum.validate() + "grouped_with_prorated_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedWithProratedMinimum = it, _json = json) } + ?: Price(_json = json) } - - override fun visitGroupedWithMinMaxThresholds( - groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds - ) { - groupedWithMinMaxThresholds.validate() + "grouped_with_metered_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedWithMeteredMinimum = it, _json = json) } + ?: Price(_json = json) } - - override fun visitMatrixWithDisplayName( - matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice - ) { - matrixWithDisplayName.validate() + "grouped_with_min_max_thresholds" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedWithMinMaxThresholds = it, _json = json) } + ?: Price(_json = json) } - - override fun visitBulkWithProration( - bulkWithProration: NewPlanBulkWithProrationPrice - ) { - bulkWithProration.validate() + "matrix_with_display_name" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(matrixWithDisplayName = it, _json = json) } + ?: Price(_json = json) } - - override fun visitGroupedTieredPackage( - groupedTieredPackage: NewPlanGroupedTieredPackagePrice - ) { - groupedTieredPackage.validate() + "bulk_with_proration" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(bulkWithProration = it, _json = json) } + ?: Price(_json = json) } - - override fun visitMaxGroupTieredPackage( - maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice - ) { - maxGroupTieredPackage.validate() + "grouped_tiered_package" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedTieredPackage = it, _json = json) } + ?: Price(_json = json) } - - override fun visitScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice - ) { - scalableMatrixWithUnitPricing.validate() + "max_group_tiered_package" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(maxGroupTieredPackage = it, _json = json) } + ?: Price(_json = json) } - - override fun visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: - NewPlanScalableMatrixWithTieredPricingPrice - ) { - scalableMatrixWithTieredPricing.validate() + "scalable_matrix_with_unit_pricing" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(scalableMatrixWithUnitPricing = it, _json = json) } + ?: Price(_json = json) } - - override fun visitCumulativeGroupedBulk( - cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice - ) { - cumulativeGroupedBulk.validate() + "scalable_matrix_with_tiered_pricing" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(scalableMatrixWithTieredPricing = it, _json = json) } + ?: Price(_json = json) } - - override fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice - ) { - tieredPackageWithMinimum.validate() + "cumulative_grouped_bulk" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(cumulativeGroupedBulk = it, _json = json) } + ?: Price(_json = json) } - - override fun visitMatrixWithAllocation( - matrixWithAllocation: NewPlanMatrixWithAllocationPrice - ) { - matrixWithAllocation.validate() + "tiered_package_with_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(tieredPackageWithMinimum = it, _json = json) } + ?: Price(_json = json) } - - override fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) { - groupedTiered.validate() + "matrix_with_allocation" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(matrixWithAllocation = it, _json = json) } + ?: Price(_json = json) } - - override fun visitMinimum(minimum: Minimum) { - minimum.validate() + "grouped_tiered" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(groupedTiered = it, _json = json) } + ?: Price(_json = json) } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: NewPlanUnitPrice) = unit.validity() - - override fun visitPackage(package_: NewPlanPackagePrice) = - package_.validity() - - override fun visitMatrix(matrix: NewPlanMatrixPrice) = matrix.validity() - - override fun visitTiered(tiered: NewPlanTieredPrice) = tiered.validity() - - override fun visitBulk(bulk: NewPlanBulkPrice) = bulk.validity() - - override fun visitThresholdTotalAmount( - thresholdTotalAmount: NewPlanThresholdTotalAmountPrice - ) = thresholdTotalAmount.validity() - - override fun visitTieredPackage(tieredPackage: NewPlanTieredPackagePrice) = - tieredPackage.validity() - - override fun visitTieredWithMinimum( - tieredWithMinimum: NewPlanTieredWithMinimumPrice - ) = tieredWithMinimum.validity() - - override fun visitUnitWithPercent( - unitWithPercent: NewPlanUnitWithPercentPrice - ) = unitWithPercent.validity() - - override fun visitPackageWithAllocation( - packageWithAllocation: NewPlanPackageWithAllocationPrice - ) = packageWithAllocation.validity() - - override fun visitTieredWithProration( - tieredWithProration: NewPlanTierWithProrationPrice - ) = tieredWithProration.validity() - - override fun visitUnitWithProration( - unitWithProration: NewPlanUnitWithProrationPrice - ) = unitWithProration.validity() - - override fun visitGroupedAllocation( - groupedAllocation: NewPlanGroupedAllocationPrice - ) = groupedAllocation.validity() - - override fun visitGroupedWithProratedMinimum( - groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice - ) = groupedWithProratedMinimum.validity() - - override fun visitGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice - ) = groupedWithMeteredMinimum.validity() - - override fun visitGroupedWithMinMaxThresholds( - groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds - ) = groupedWithMinMaxThresholds.validity() - - override fun visitMatrixWithDisplayName( - matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice - ) = matrixWithDisplayName.validity() - - override fun visitBulkWithProration( - bulkWithProration: NewPlanBulkWithProrationPrice - ) = bulkWithProration.validity() - - override fun visitGroupedTieredPackage( - groupedTieredPackage: NewPlanGroupedTieredPackagePrice - ) = groupedTieredPackage.validity() - - override fun visitMaxGroupTieredPackage( - maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice - ) = maxGroupTieredPackage.validity() - - override fun visitScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice - ) = scalableMatrixWithUnitPricing.validity() - - override fun visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: - NewPlanScalableMatrixWithTieredPricingPrice - ) = scalableMatrixWithTieredPricing.validity() - - override fun visitCumulativeGroupedBulk( - cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice - ) = cumulativeGroupedBulk.validity() - - override fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice - ) = tieredPackageWithMinimum.validity() - - override fun visitMatrixWithAllocation( - matrixWithAllocation: NewPlanMatrixWithAllocationPrice - ) = matrixWithAllocation.validity() - - override fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) = - groupedTiered.validity() - - override fun visitMinimum(minimum: Minimum) = minimum.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Price && - unit == other.unit && - package_ == other.package_ && - matrix == other.matrix && - tiered == other.tiered && - bulk == other.bulk && - thresholdTotalAmount == other.thresholdTotalAmount && - tieredPackage == other.tieredPackage && - tieredWithMinimum == other.tieredWithMinimum && - unitWithPercent == other.unitWithPercent && - packageWithAllocation == other.packageWithAllocation && - tieredWithProration == other.tieredWithProration && - unitWithProration == other.unitWithProration && - groupedAllocation == other.groupedAllocation && - groupedWithProratedMinimum == other.groupedWithProratedMinimum && - groupedWithMeteredMinimum == other.groupedWithMeteredMinimum && - groupedWithMinMaxThresholds == other.groupedWithMinMaxThresholds && - matrixWithDisplayName == other.matrixWithDisplayName && - bulkWithProration == other.bulkWithProration && - groupedTieredPackage == other.groupedTieredPackage && - maxGroupTieredPackage == other.maxGroupTieredPackage && - scalableMatrixWithUnitPricing == other.scalableMatrixWithUnitPricing && - scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && - cumulativeGroupedBulk == other.cumulativeGroupedBulk && - tieredPackageWithMinimum == other.tieredPackageWithMinimum && - matrixWithAllocation == other.matrixWithAllocation && - groupedTiered == other.groupedTiered && - minimum == other.minimum - } - - override fun hashCode(): Int = - Objects.hash( - unit, - package_, - matrix, - tiered, - bulk, - thresholdTotalAmount, - tieredPackage, - tieredWithMinimum, - unitWithPercent, - packageWithAllocation, - tieredWithProration, - unitWithProration, - groupedAllocation, - groupedWithProratedMinimum, - groupedWithMeteredMinimum, - groupedWithMinMaxThresholds, - matrixWithDisplayName, - bulkWithProration, - groupedTieredPackage, - maxGroupTieredPackage, - scalableMatrixWithUnitPricing, - scalableMatrixWithTieredPricing, - cumulativeGroupedBulk, - tieredPackageWithMinimum, - matrixWithAllocation, - groupedTiered, - minimum, - ) - - override fun toString(): String = - when { - unit != null -> "Price{unit=$unit}" - package_ != null -> "Price{package_=$package_}" - matrix != null -> "Price{matrix=$matrix}" - tiered != null -> "Price{tiered=$tiered}" - bulk != null -> "Price{bulk=$bulk}" - thresholdTotalAmount != null -> - "Price{thresholdTotalAmount=$thresholdTotalAmount}" - tieredPackage != null -> "Price{tieredPackage=$tieredPackage}" - tieredWithMinimum != null -> "Price{tieredWithMinimum=$tieredWithMinimum}" - unitWithPercent != null -> "Price{unitWithPercent=$unitWithPercent}" - packageWithAllocation != null -> - "Price{packageWithAllocation=$packageWithAllocation}" - tieredWithProration != null -> "Price{tieredWithProration=$tieredWithProration}" - unitWithProration != null -> "Price{unitWithProration=$unitWithProration}" - groupedAllocation != null -> "Price{groupedAllocation=$groupedAllocation}" - groupedWithProratedMinimum != null -> - "Price{groupedWithProratedMinimum=$groupedWithProratedMinimum}" - groupedWithMeteredMinimum != null -> - "Price{groupedWithMeteredMinimum=$groupedWithMeteredMinimum}" - groupedWithMinMaxThresholds != null -> - "Price{groupedWithMinMaxThresholds=$groupedWithMinMaxThresholds}" - matrixWithDisplayName != null -> - "Price{matrixWithDisplayName=$matrixWithDisplayName}" - bulkWithProration != null -> "Price{bulkWithProration=$bulkWithProration}" - groupedTieredPackage != null -> - "Price{groupedTieredPackage=$groupedTieredPackage}" - maxGroupTieredPackage != null -> - "Price{maxGroupTieredPackage=$maxGroupTieredPackage}" - scalableMatrixWithUnitPricing != null -> - "Price{scalableMatrixWithUnitPricing=$scalableMatrixWithUnitPricing}" - scalableMatrixWithTieredPricing != null -> - "Price{scalableMatrixWithTieredPricing=$scalableMatrixWithTieredPricing}" - cumulativeGroupedBulk != null -> - "Price{cumulativeGroupedBulk=$cumulativeGroupedBulk}" - tieredPackageWithMinimum != null -> - "Price{tieredPackageWithMinimum=$tieredPackageWithMinimum}" - matrixWithAllocation != null -> - "Price{matrixWithAllocation=$matrixWithAllocation}" - groupedTiered != null -> "Price{groupedTiered=$groupedTiered}" - minimum != null -> "Price{minimum=$minimum}" - _json != null -> "Price{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Price") - } - - companion object { - - fun ofUnit(unit: NewPlanUnitPrice) = Price(unit = unit) - - fun ofPackage(package_: NewPlanPackagePrice) = Price(package_ = package_) - - fun ofMatrix(matrix: NewPlanMatrixPrice) = Price(matrix = matrix) - - fun ofTiered(tiered: NewPlanTieredPrice) = Price(tiered = tiered) - - fun ofBulk(bulk: NewPlanBulkPrice) = Price(bulk = bulk) - - fun ofThresholdTotalAmount(thresholdTotalAmount: NewPlanThresholdTotalAmountPrice) = - Price(thresholdTotalAmount = thresholdTotalAmount) - - fun ofTieredPackage(tieredPackage: NewPlanTieredPackagePrice) = - Price(tieredPackage = tieredPackage) - - fun ofTieredWithMinimum(tieredWithMinimum: NewPlanTieredWithMinimumPrice) = - Price(tieredWithMinimum = tieredWithMinimum) - - fun ofUnitWithPercent(unitWithPercent: NewPlanUnitWithPercentPrice) = - Price(unitWithPercent = unitWithPercent) - - fun ofPackageWithAllocation( - packageWithAllocation: NewPlanPackageWithAllocationPrice - ) = Price(packageWithAllocation = packageWithAllocation) - - fun ofTieredWithProration(tieredWithProration: NewPlanTierWithProrationPrice) = - Price(tieredWithProration = tieredWithProration) - - fun ofUnitWithProration(unitWithProration: NewPlanUnitWithProrationPrice) = - Price(unitWithProration = unitWithProration) - - fun ofGroupedAllocation(groupedAllocation: NewPlanGroupedAllocationPrice) = - Price(groupedAllocation = groupedAllocation) - - fun ofGroupedWithProratedMinimum( - groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice - ) = Price(groupedWithProratedMinimum = groupedWithProratedMinimum) - - fun ofGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice - ) = Price(groupedWithMeteredMinimum = groupedWithMeteredMinimum) - - fun ofGroupedWithMinMaxThresholds( - groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds - ) = Price(groupedWithMinMaxThresholds = groupedWithMinMaxThresholds) - - fun ofMatrixWithDisplayName( - matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice - ) = Price(matrixWithDisplayName = matrixWithDisplayName) - - fun ofBulkWithProration(bulkWithProration: NewPlanBulkWithProrationPrice) = - Price(bulkWithProration = bulkWithProration) - - fun ofGroupedTieredPackage(groupedTieredPackage: NewPlanGroupedTieredPackagePrice) = - Price(groupedTieredPackage = groupedTieredPackage) - - fun ofMaxGroupTieredPackage( - maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice - ) = Price(maxGroupTieredPackage = maxGroupTieredPackage) - - fun ofScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice - ) = Price(scalableMatrixWithUnitPricing = scalableMatrixWithUnitPricing) - - fun ofScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: NewPlanScalableMatrixWithTieredPricingPrice - ) = Price(scalableMatrixWithTieredPricing = scalableMatrixWithTieredPricing) - - fun ofCumulativeGroupedBulk( - cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice - ) = Price(cumulativeGroupedBulk = cumulativeGroupedBulk) - - fun ofTieredPackageWithMinimum( - tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice - ) = Price(tieredPackageWithMinimum = tieredPackageWithMinimum) - - fun ofMatrixWithAllocation(matrixWithAllocation: NewPlanMatrixWithAllocationPrice) = - Price(matrixWithAllocation = matrixWithAllocation) - - fun ofGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) = - Price(groupedTiered = groupedTiered) - - fun ofMinimum(minimum: Minimum) = Price(minimum = minimum) - } - - /** - * An interface that defines how to map each variant of [Price] to a value of type [T]. - */ - interface Visitor { - - fun visitUnit(unit: NewPlanUnitPrice): T - - fun visitPackage(package_: NewPlanPackagePrice): T - - fun visitMatrix(matrix: NewPlanMatrixPrice): T - - fun visitTiered(tiered: NewPlanTieredPrice): T - - fun visitBulk(bulk: NewPlanBulkPrice): T - - fun visitThresholdTotalAmount( - thresholdTotalAmount: NewPlanThresholdTotalAmountPrice - ): T - - fun visitTieredPackage(tieredPackage: NewPlanTieredPackagePrice): T - - fun visitTieredWithMinimum(tieredWithMinimum: NewPlanTieredWithMinimumPrice): T - - fun visitUnitWithPercent(unitWithPercent: NewPlanUnitWithPercentPrice): T - - fun visitPackageWithAllocation( - packageWithAllocation: NewPlanPackageWithAllocationPrice - ): T - - fun visitTieredWithProration(tieredWithProration: NewPlanTierWithProrationPrice): T - - fun visitUnitWithProration(unitWithProration: NewPlanUnitWithProrationPrice): T - - fun visitGroupedAllocation(groupedAllocation: NewPlanGroupedAllocationPrice): T - - fun visitGroupedWithProratedMinimum( - groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice - ): T - - fun visitGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice - ): T - - fun visitGroupedWithMinMaxThresholds( - groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds - ): T - - fun visitMatrixWithDisplayName( - matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice - ): T - - fun visitBulkWithProration(bulkWithProration: NewPlanBulkWithProrationPrice): T - - fun visitGroupedTieredPackage( - groupedTieredPackage: NewPlanGroupedTieredPackagePrice - ): T - - fun visitMaxGroupTieredPackage( - maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice - ): T - - fun visitScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice - ): T - - fun visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: NewPlanScalableMatrixWithTieredPricingPrice - ): T - - fun visitCumulativeGroupedBulk( - cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice - ): T - - fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice - ): T - - fun visitMatrixWithAllocation( - matrixWithAllocation: NewPlanMatrixWithAllocationPrice - ): T - - fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice): T - - fun visitMinimum(minimum: Minimum): T - - /** - * Maps an unknown variant of [Price] to a value of type [T]. - * - * An instance of [Price] can contain an unknown variant if it was deserialized from - * data that doesn't match any known variant. For example, if the SDK is on an older - * version than the API, then the API may respond with new variants that the SDK is - * unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown Price: $json") - } - } - - internal class Deserializer : BaseDeserializer(Price::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): Price { - val json = JsonValue.fromJsonNode(node) - val modelType = json.asObject()?.get("model_type")?.asString() - - when (modelType) { - "unit" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(unit = it, _json = json) - } ?: Price(_json = json) - } - "package" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(package_ = it, _json = json) } ?: Price(_json = json) - } - "matrix" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(matrix = it, _json = json) - } ?: Price(_json = json) - } - "tiered" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(tiered = it, _json = json) - } ?: Price(_json = json) - } - "bulk" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(bulk = it, _json = json) - } ?: Price(_json = json) - } - "threshold_total_amount" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(thresholdTotalAmount = it, _json = json) } - ?: Price(_json = json) - } - "tiered_package" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(tieredPackage = it, _json = json) } - ?: Price(_json = json) - } - "tiered_with_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(tieredWithMinimum = it, _json = json) } - ?: Price(_json = json) - } - "unit_with_percent" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(unitWithPercent = it, _json = json) } - ?: Price(_json = json) - } - "package_with_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(packageWithAllocation = it, _json = json) } - ?: Price(_json = json) - } - "tiered_with_proration" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(tieredWithProration = it, _json = json) } - ?: Price(_json = json) - } - "unit_with_proration" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(unitWithProration = it, _json = json) } - ?: Price(_json = json) - } - "grouped_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedAllocation = it, _json = json) } - ?: Price(_json = json) - } - "grouped_with_prorated_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedWithProratedMinimum = it, _json = json) } - ?: Price(_json = json) - } - "grouped_with_metered_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedWithMeteredMinimum = it, _json = json) } - ?: Price(_json = json) - } - "grouped_with_min_max_thresholds" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedWithMinMaxThresholds = it, _json = json) } - ?: Price(_json = json) - } - "matrix_with_display_name" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(matrixWithDisplayName = it, _json = json) } - ?: Price(_json = json) - } - "bulk_with_proration" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(bulkWithProration = it, _json = json) } - ?: Price(_json = json) - } - "grouped_tiered_package" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedTieredPackage = it, _json = json) } - ?: Price(_json = json) - } - "max_group_tiered_package" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(maxGroupTieredPackage = it, _json = json) } - ?: Price(_json = json) - } - "scalable_matrix_with_unit_pricing" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(scalableMatrixWithUnitPricing = it, _json = json) } - ?: Price(_json = json) - } - "scalable_matrix_with_tiered_pricing" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(scalableMatrixWithTieredPricing = it, _json = json) } - ?: Price(_json = json) - } - "cumulative_grouped_bulk" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(cumulativeGroupedBulk = it, _json = json) } - ?: Price(_json = json) - } - "tiered_package_with_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(tieredPackageWithMinimum = it, _json = json) } - ?: Price(_json = json) - } - "matrix_with_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(matrixWithAllocation = it, _json = json) } - ?: Price(_json = json) - } - "grouped_tiered" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(groupedTiered = it, _json = json) } - ?: Price(_json = json) - } - "minimum" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(minimum = it, _json = json) - } ?: Price(_json = json) - } - } - - return Price(_json = json) - } - } - - internal class Serializer : BaseSerializer(Price::class) { - - override fun serialize( - value: Price, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unit != null -> generator.writeObject(value.unit) - value.package_ != null -> generator.writeObject(value.package_) - value.matrix != null -> generator.writeObject(value.matrix) - value.tiered != null -> generator.writeObject(value.tiered) - value.bulk != null -> generator.writeObject(value.bulk) - value.thresholdTotalAmount != null -> - generator.writeObject(value.thresholdTotalAmount) - value.tieredPackage != null -> generator.writeObject(value.tieredPackage) - value.tieredWithMinimum != null -> - generator.writeObject(value.tieredWithMinimum) - value.unitWithPercent != null -> - generator.writeObject(value.unitWithPercent) - value.packageWithAllocation != null -> - generator.writeObject(value.packageWithAllocation) - value.tieredWithProration != null -> - generator.writeObject(value.tieredWithProration) - value.unitWithProration != null -> - generator.writeObject(value.unitWithProration) - value.groupedAllocation != null -> - generator.writeObject(value.groupedAllocation) - value.groupedWithProratedMinimum != null -> - generator.writeObject(value.groupedWithProratedMinimum) - value.groupedWithMeteredMinimum != null -> - generator.writeObject(value.groupedWithMeteredMinimum) - value.groupedWithMinMaxThresholds != null -> - generator.writeObject(value.groupedWithMinMaxThresholds) - value.matrixWithDisplayName != null -> - generator.writeObject(value.matrixWithDisplayName) - value.bulkWithProration != null -> - generator.writeObject(value.bulkWithProration) - value.groupedTieredPackage != null -> - generator.writeObject(value.groupedTieredPackage) - value.maxGroupTieredPackage != null -> - generator.writeObject(value.maxGroupTieredPackage) - value.scalableMatrixWithUnitPricing != null -> - generator.writeObject(value.scalableMatrixWithUnitPricing) - value.scalableMatrixWithTieredPricing != null -> - generator.writeObject(value.scalableMatrixWithTieredPricing) - value.cumulativeGroupedBulk != null -> - generator.writeObject(value.cumulativeGroupedBulk) - value.tieredPackageWithMinimum != null -> - generator.writeObject(value.tieredPackageWithMinimum) - value.matrixWithAllocation != null -> - generator.writeObject(value.matrixWithAllocation) - value.groupedTiered != null -> generator.writeObject(value.groupedTiered) - value.minimum != null -> generator.writeObject(value.minimum) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Price") - } - } - } - - class GroupedWithMinMaxThresholds - private constructor( - private val cadence: JsonField, - private val groupedWithMinMaxThresholdsConfig: - JsonField, - private val itemId: JsonField, - private val modelType: JsonValue, - private val name: JsonField, - private val billableMetricId: JsonField, - private val billedInAdvance: JsonField, - private val billingCycleConfiguration: JsonField, - private val conversionRate: JsonField, - private val conversionRateConfig: JsonField, - private val currency: JsonField, - private val dimensionalPriceConfiguration: - JsonField, - private val externalPriceId: JsonField, - private val fixedPriceQuantity: JsonField, - private val invoiceGroupingKey: JsonField, - private val invoicingCycleConfiguration: JsonField, - private val metadata: JsonField, - private val referenceId: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("cadence") - @ExcludeMissing - cadence: JsonField = JsonMissing.of(), - @JsonProperty("grouped_with_min_max_thresholds_config") - @ExcludeMissing - groupedWithMinMaxThresholdsConfig: - JsonField = - JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - modelType: JsonValue = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - name: JsonField = JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("conversion_rate_config") - @ExcludeMissing - conversionRateConfig: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - currency: JsonField = JsonMissing.of(), - @JsonProperty("dimensional_price_configuration") - @ExcludeMissing - dimensionalPriceConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - metadata: JsonField = JsonMissing.of(), - @JsonProperty("reference_id") - @ExcludeMissing - referenceId: JsonField = JsonMissing.of(), - ) : this( - cadence, - groupedWithMinMaxThresholdsConfig, - itemId, - modelType, - name, - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - conversionRateConfig, - currency, - dimensionalPriceConfiguration, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - mutableMapOf(), - ) - - /** - * The cadence to bill for this price on. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun groupedWithMinMaxThresholdsConfig(): GroupedWithMinMaxThresholdsConfig = - groupedWithMinMaxThresholdsConfig.getRequired( - "grouped_with_min_max_thresholds_config" - ) - - /** - * The id of the item the price will be associated with. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun itemId(): String = itemId.getRequired("item_id") - - /** - * Expected to always return the following: - * ```kotlin - * JsonValue.from("grouped_with_min_max_thresholds") - * ``` - * - * However, this method can be useful for debugging and logging (e.g. if the server - * responded with an unexpected value). - */ - @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType - - /** - * The name of the price. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun name(): String = name.getRequired("name") - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun billableMetricId(): String? = billableMetricId.getNullable("billable_metric_id") - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun billingCycleConfiguration(): NewBillingCycleConfiguration? = - billingCycleConfiguration.getNullable("billing_cycle_configuration") - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") - - /** - * The configuration for the rate of the price currency to the invoicing currency. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun conversionRateConfig(): ConversionRateConfig? = - conversionRateConfig.getNullable("conversion_rate_config") - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun currency(): String? = currency.getNullable("currency") - - /** - * For dimensional price: specifies a price group and dimension values - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = - dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") - - /** - * An alias for the price. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun fixedPriceQuantity(): Double? = - fixedPriceQuantity.getNullable("fixed_price_quantity") - - /** - * The property used to group this price on an invoice - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun invoiceGroupingKey(): String? = - invoiceGroupingKey.getNullable("invoice_grouping_key") - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun metadata(): Metadata? = metadata.getNullable("metadata") - - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun referenceId(): String? = referenceId.getNullable("reference_id") - - /** - * Returns the raw JSON value of [cadence]. - * - * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("cadence") - @ExcludeMissing - fun _cadence(): JsonField = cadence - - /** - * Returns the raw JSON value of [groupedWithMinMaxThresholdsConfig]. - * - * Unlike [groupedWithMinMaxThresholdsConfig], this method doesn't throw if the JSON - * field has an unexpected type. - */ - @JsonProperty("grouped_with_min_max_thresholds_config") - @ExcludeMissing - fun _groupedWithMinMaxThresholdsConfig(): - JsonField = groupedWithMinMaxThresholdsConfig - - /** - * Returns the raw JSON value of [itemId]. - * - * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - /** - * Returns the raw JSON value of [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - /** - * Returns the raw JSON value of [billableMetricId]. - * - * Unlike [billableMetricId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = billableMetricId - - /** - * Returns the raw JSON value of [billedInAdvance]. - * - * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance - - /** - * Returns the raw JSON value of [billingCycleConfiguration]. - * - * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** - * Returns the raw JSON value of [conversionRate]. - * - * Unlike [conversionRate], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** - * Returns the raw JSON value of [conversionRateConfig]. - * - * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("conversion_rate_config") - @ExcludeMissing - fun _conversionRateConfig(): JsonField = conversionRateConfig - - /** - * Returns the raw JSON value of [currency]. - * - * Unlike [currency], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("currency") - @ExcludeMissing - fun _currency(): JsonField = currency - - /** - * Returns the raw JSON value of [dimensionalPriceConfiguration]. - * - * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON - * field has an unexpected type. - */ - @JsonProperty("dimensional_price_configuration") - @ExcludeMissing - fun _dimensionalPriceConfiguration(): JsonField = - dimensionalPriceConfiguration - - /** - * Returns the raw JSON value of [externalPriceId]. - * - * Unlike [externalPriceId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * Returns the raw JSON value of [fixedPriceQuantity]. - * - * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** - * Returns the raw JSON value of [invoiceGroupingKey]. - * - * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Returns the raw JSON value of [invoicingCycleConfiguration]. - * - * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * Returns the raw JSON value of [metadata]. - * - * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - /** - * Returns the raw JSON value of [referenceId]. - * - * Unlike [referenceId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("reference_id") - @ExcludeMissing - fun _referenceId(): JsonField = referenceId - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [GroupedWithMinMaxThresholds]. - * - * The following fields are required: - * ```kotlin - * .cadence() - * .groupedWithMinMaxThresholdsConfig() - * .itemId() - * .name() - * ``` - */ - fun builder() = Builder() - } - - /** A builder for [GroupedWithMinMaxThresholds]. */ - class Builder internal constructor() { - - private var cadence: JsonField? = null - private var groupedWithMinMaxThresholdsConfig: - JsonField? = - null - private var itemId: JsonField? = null - private var modelType: JsonValue = - JsonValue.from("grouped_with_min_max_thresholds") - private var name: JsonField? = null - private var billableMetricId: JsonField = JsonMissing.of() - private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var conversionRateConfig: JsonField = - JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var dimensionalPriceConfiguration: - JsonField = - JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: - JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var referenceId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds) = - apply { - cadence = groupedWithMinMaxThresholds.cadence - groupedWithMinMaxThresholdsConfig = - groupedWithMinMaxThresholds.groupedWithMinMaxThresholdsConfig - itemId = groupedWithMinMaxThresholds.itemId - modelType = groupedWithMinMaxThresholds.modelType - name = groupedWithMinMaxThresholds.name - billableMetricId = groupedWithMinMaxThresholds.billableMetricId - billedInAdvance = groupedWithMinMaxThresholds.billedInAdvance - billingCycleConfiguration = - groupedWithMinMaxThresholds.billingCycleConfiguration - conversionRate = groupedWithMinMaxThresholds.conversionRate - conversionRateConfig = groupedWithMinMaxThresholds.conversionRateConfig - currency = groupedWithMinMaxThresholds.currency - dimensionalPriceConfiguration = - groupedWithMinMaxThresholds.dimensionalPriceConfiguration - externalPriceId = groupedWithMinMaxThresholds.externalPriceId - fixedPriceQuantity = groupedWithMinMaxThresholds.fixedPriceQuantity - invoiceGroupingKey = groupedWithMinMaxThresholds.invoiceGroupingKey - invoicingCycleConfiguration = - groupedWithMinMaxThresholds.invoicingCycleConfiguration - metadata = groupedWithMinMaxThresholds.metadata - referenceId = groupedWithMinMaxThresholds.referenceId - additionalProperties = - groupedWithMinMaxThresholds.additionalProperties.toMutableMap() - } - - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** - * Sets [Builder.cadence] to an arbitrary JSON value. - * - * You should usually call [Builder.cadence] with a well-typed [Cadence] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - - fun groupedWithMinMaxThresholdsConfig( - groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig - ) = - groupedWithMinMaxThresholdsConfig( - JsonField.of(groupedWithMinMaxThresholdsConfig) - ) - - /** - * Sets [Builder.groupedWithMinMaxThresholdsConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.groupedWithMinMaxThresholdsConfig] with a - * well-typed [GroupedWithMinMaxThresholdsConfig] value instead. This method is - * primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun groupedWithMinMaxThresholdsConfig( - groupedWithMinMaxThresholdsConfig: - JsonField - ) = apply { - this.groupedWithMinMaxThresholdsConfig = groupedWithMinMaxThresholdsConfig - } - - /** The id of the item the price will be associated with. */ - fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - - /** - * Sets [Builder.itemId] to an arbitrary JSON value. - * - * You should usually call [Builder.itemId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - /** - * Sets the field to an arbitrary JSON value. - * - * It is usually unnecessary to call this method because the field defaults to - * the following: - * ```kotlin - * JsonValue.from("grouped_with_min_max_thresholds") - * ``` - * - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } - - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) - - /** - * Sets [Builder.name] to an arbitrary JSON value. - * - * You should usually call [Builder.name] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun name(name: JsonField) = apply { this.name = name } - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: String?) = - billableMetricId(JsonField.ofNullable(billableMetricId)) - - /** - * Sets [Builder.billableMetricId] to an arbitrary JSON value. - * - * You should usually call [Builder.billableMetricId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun billableMetricId(billableMetricId: JsonField) = apply { - this.billableMetricId = billableMetricId - } - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if - * this is true, and in-arrears if this is false. - */ - fun billedInAdvance(billedInAdvance: Boolean?) = - billedInAdvance(JsonField.ofNullable(billedInAdvance)) - - /** - * Alias for [Builder.billedInAdvance]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun billedInAdvance(billedInAdvance: Boolean) = - billedInAdvance(billedInAdvance as Boolean?) - - /** - * Sets [Builder.billedInAdvance] to an arbitrary JSON value. - * - * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun billedInAdvance(billedInAdvance: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: NewBillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - - /** - * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.billingCycleConfiguration] with a well-typed - * [NewBillingCycleConfiguration] value instead. This method is primarily for - * setting the field to an undocumented or not yet supported value. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: JsonField - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: Double?) = - conversionRate(JsonField.ofNullable(conversionRate)) - - /** - * Alias for [Builder.conversionRate]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) - - /** - * Sets [Builder.conversionRate] to an arbitrary JSON value. - * - * You should usually call [Builder.conversionRate] with a well-typed [Double] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** - * The configuration for the rate of the price currency to the invoicing - * currency. - */ - fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = - conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) - - /** - * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.conversionRateConfig] with a well-typed - * [ConversionRateConfig] value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun conversionRateConfig( - conversionRateConfig: JsonField - ) = apply { this.conversionRateConfig = conversionRateConfig } - - /** - * Alias for calling [conversionRateConfig] with - * `ConversionRateConfig.ofUnit(unit)`. - */ - fun conversionRateConfig(unit: UnitConversionRateConfig) = - conversionRateConfig(ConversionRateConfig.ofUnit(unit)) - - /** - * Alias for calling [conversionRateConfig] with the following: - * ```kotlin - * UnitConversionRateConfig.builder() - * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) - * .unitConfig(unitConfig) - * .build() - * ``` - */ - fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = - conversionRateConfig( - UnitConversionRateConfig.builder() - .conversionRateType( - UnitConversionRateConfig.ConversionRateType.UNIT - ) - .unitConfig(unitConfig) - .build() - ) - - /** - * Alias for calling [conversionRateConfig] with - * `ConversionRateConfig.ofTiered(tiered)`. - */ - fun conversionRateConfig(tiered: TieredConversionRateConfig) = - conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) - - /** - * Alias for calling [conversionRateConfig] with the following: - * ```kotlin - * TieredConversionRateConfig.builder() - * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) - * .tieredConfig(tieredConfig) - * .build() - * ``` - */ - fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = - conversionRateConfig( - TieredConversionRateConfig.builder() - .conversionRateType( - TieredConversionRateConfig.ConversionRateType.TIERED - ) - .tieredConfig(tieredConfig) - .build() - ) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) - - /** - * Sets [Builder.currency] to an arbitrary JSON value. - * - * You should usually call [Builder.currency] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } - - /** For dimensional price: specifies a price group and dimension values */ - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? - ) = - dimensionalPriceConfiguration( - JsonField.ofNullable(dimensionalPriceConfiguration) - ) - - /** - * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.dimensionalPriceConfiguration] with a - * well-typed [NewDimensionalPriceConfiguration] value instead. This method is - * primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: JsonField - ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** - * Sets [Builder.externalPriceId] to an arbitrary JSON value. - * - * You should usually call [Builder.externalPriceId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun externalPriceId(externalPriceId: JsonField) = apply { - this.externalPriceId = externalPriceId - } - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = - fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) - - /** - * Alias for [Builder.fixedPriceQuantity]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. - * - * You should usually call [Builder.fixedPriceQuantity] with a well-typed - * [Double] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = - invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) - - /** - * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. - * - * You should usually call [Builder.invoiceGroupingKey] with a well-typed - * [String] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { - this.invoiceGroupingKey = invoiceGroupingKey - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are - * produced. If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: NewBillingCycleConfiguration? - ) = - invoicingCycleConfiguration( - JsonField.ofNullable(invoicingCycleConfiguration) - ) - - /** - * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.invoicingCycleConfiguration] with a - * well-typed [NewBillingCycleConfiguration] value instead. This method is - * primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * Sets [Builder.metadata] to an arbitrary JSON value. - * - * You should usually call [Builder.metadata] with a well-typed [Metadata] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - fun referenceId(referenceId: String?) = - referenceId(JsonField.ofNullable(referenceId)) - - /** - * Sets [Builder.referenceId] to an arbitrary JSON value. - * - * You should usually call [Builder.referenceId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun referenceId(referenceId: JsonField) = apply { - this.referenceId = referenceId - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [GroupedWithMinMaxThresholds]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```kotlin - * .cadence() - * .groupedWithMinMaxThresholdsConfig() - * .itemId() - * .name() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): GroupedWithMinMaxThresholds = - GroupedWithMinMaxThresholds( - checkRequired("cadence", cadence), - checkRequired( - "groupedWithMinMaxThresholdsConfig", - groupedWithMinMaxThresholdsConfig, - ), - checkRequired("itemId", itemId), - modelType, - checkRequired("name", name), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - conversionRateConfig, - currency, - dimensionalPriceConfiguration, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): GroupedWithMinMaxThresholds = apply { - if (validated) { - return@apply - } - - cadence().validate() - groupedWithMinMaxThresholdsConfig().validate() - itemId() - _modelType().let { - if (it != JsonValue.from("grouped_with_min_max_thresholds")) { - throw OrbInvalidDataException("'modelType' is invalid, received $it") - } - } - name() - billableMetricId() - billedInAdvance() - billingCycleConfiguration()?.validate() - conversionRate() - conversionRateConfig()?.validate() - currency() - dimensionalPriceConfiguration()?.validate() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration()?.validate() - metadata()?.validate() - referenceId() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (cadence.asKnown()?.validity() ?: 0) + - (groupedWithMinMaxThresholdsConfig.asKnown()?.validity() ?: 0) + - (if (itemId.asKnown() == null) 0 else 1) + - modelType.let { - if (it == JsonValue.from("grouped_with_min_max_thresholds")) 1 else 0 - } + - (if (name.asKnown() == null) 0 else 1) + - (if (billableMetricId.asKnown() == null) 0 else 1) + - (if (billedInAdvance.asKnown() == null) 0 else 1) + - (billingCycleConfiguration.asKnown()?.validity() ?: 0) + - (if (conversionRate.asKnown() == null) 0 else 1) + - (conversionRateConfig.asKnown()?.validity() ?: 0) + - (if (currency.asKnown() == null) 0 else 1) + - (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + - (if (externalPriceId.asKnown() == null) 0 else 1) + - (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + - (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + - (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + - (metadata.asKnown()?.validity() ?: 0) + - (if (referenceId.asKnown() == null) 0 else 1) - - /** The cadence to bill for this price on. */ - class Cadence - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - val ANNUAL = of("annual") - - val SEMI_ANNUAL = of("semi_annual") - - val MONTHLY = of("monthly") - - val QUARTERLY = of("quarterly") - - val ONE_TIME = of("one_time") - - val CUSTOM = of("custom") - - fun of(value: String) = Cadence(JsonField.of(value)) - } - - /** An enum containing [Cadence]'s known values. */ - enum class Known { - ANNUAL, - SEMI_ANNUAL, - MONTHLY, - QUARTERLY, - ONE_TIME, - CUSTOM, - } - - /** - * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Cadence] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - ANNUAL, - SEMI_ANNUAL, - MONTHLY, - QUARTERLY, - ONE_TIME, - CUSTOM, - /** - * An enum member indicating that [Cadence] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - ANNUAL -> Value.ANNUAL - SEMI_ANNUAL -> Value.SEMI_ANNUAL - MONTHLY -> Value.MONTHLY - QUARTERLY -> Value.QUARTERLY - ONE_TIME -> Value.ONE_TIME - CUSTOM -> Value.CUSTOM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - ANNUAL -> Known.ANNUAL - SEMI_ANNUAL -> Known.SEMI_ANNUAL - MONTHLY -> Known.MONTHLY - QUARTERLY -> Known.QUARTERLY - ONE_TIME -> Known.ONE_TIME - CUSTOM -> Known.CUSTOM - else -> throw OrbInvalidDataException("Unknown Cadence: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString() - ?: throw OrbInvalidDataException("Value is not a String") - - private var validated: Boolean = false - - fun validate(): Cadence = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Cadence && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class GroupedWithMinMaxThresholdsConfig - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [GroupedWithMinMaxThresholdsConfig]. - */ - fun builder() = Builder() - } - - /** A builder for [GroupedWithMinMaxThresholdsConfig]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = - mutableMapOf() - - internal fun from( - groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig - ) = apply { - additionalProperties = - groupedWithMinMaxThresholdsConfig.additionalProperties - .toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [GroupedWithMinMaxThresholdsConfig]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): GroupedWithMinMaxThresholdsConfig = - GroupedWithMinMaxThresholdsConfig(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): GroupedWithMinMaxThresholdsConfig = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - additionalProperties.count { (_, value) -> - !value.isNull() && !value.isMissing() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is GroupedWithMinMaxThresholdsConfig && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "GroupedWithMinMaxThresholdsConfig{additionalProperties=$additionalProperties}" - } - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - class Metadata - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Metadata]. */ - fun builder() = Builder() - } - - /** A builder for [Metadata]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = - mutableMapOf() - - internal fun from(metadata: Metadata) = apply { - additionalProperties = metadata.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Metadata]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - additionalProperties.count { (_, value) -> - !value.isNull() && !value.isMissing() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Metadata && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is GroupedWithMinMaxThresholds && - cadence == other.cadence && - groupedWithMinMaxThresholdsConfig == - other.groupedWithMinMaxThresholdsConfig && - itemId == other.itemId && - modelType == other.modelType && - name == other.name && - billableMetricId == other.billableMetricId && - billedInAdvance == other.billedInAdvance && - billingCycleConfiguration == other.billingCycleConfiguration && - conversionRate == other.conversionRate && - conversionRateConfig == other.conversionRateConfig && - currency == other.currency && - dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && - externalPriceId == other.externalPriceId && - fixedPriceQuantity == other.fixedPriceQuantity && - invoiceGroupingKey == other.invoiceGroupingKey && - invoicingCycleConfiguration == other.invoicingCycleConfiguration && - metadata == other.metadata && - referenceId == other.referenceId && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - cadence, - groupedWithMinMaxThresholdsConfig, - itemId, - modelType, - name, - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - conversionRateConfig, - currency, - dimensionalPriceConfiguration, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - additionalProperties, - ) + "minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(minimum = it, _json = json) } ?: Price(_json = json) + } + } + + return Price(_json = json) } + } - override fun hashCode(): Int = hashCode + internal class Serializer : BaseSerializer(Price::class) { - override fun toString() = - "GroupedWithMinMaxThresholds{cadence=$cadence, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + override fun serialize( + value: Price, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.unit != null -> generator.writeObject(value.unit) + value.package_ != null -> generator.writeObject(value.package_) + value.matrix != null -> generator.writeObject(value.matrix) + value.tiered != null -> generator.writeObject(value.tiered) + value.bulk != null -> generator.writeObject(value.bulk) + value.thresholdTotalAmount != null -> + generator.writeObject(value.thresholdTotalAmount) + value.tieredPackage != null -> generator.writeObject(value.tieredPackage) + value.tieredWithMinimum != null -> + generator.writeObject(value.tieredWithMinimum) + value.unitWithPercent != null -> + generator.writeObject(value.unitWithPercent) + value.packageWithAllocation != null -> + generator.writeObject(value.packageWithAllocation) + value.tieredWithProration != null -> + generator.writeObject(value.tieredWithProration) + value.unitWithProration != null -> + generator.writeObject(value.unitWithProration) + value.groupedAllocation != null -> + generator.writeObject(value.groupedAllocation) + value.groupedWithProratedMinimum != null -> + generator.writeObject(value.groupedWithProratedMinimum) + value.groupedWithMeteredMinimum != null -> + generator.writeObject(value.groupedWithMeteredMinimum) + value.groupedWithMinMaxThresholds != null -> + generator.writeObject(value.groupedWithMinMaxThresholds) + value.matrixWithDisplayName != null -> + generator.writeObject(value.matrixWithDisplayName) + value.bulkWithProration != null -> + generator.writeObject(value.bulkWithProration) + value.groupedTieredPackage != null -> + generator.writeObject(value.groupedTieredPackage) + value.maxGroupTieredPackage != null -> + generator.writeObject(value.maxGroupTieredPackage) + value.scalableMatrixWithUnitPricing != null -> + generator.writeObject(value.scalableMatrixWithUnitPricing) + value.scalableMatrixWithTieredPricing != null -> + generator.writeObject(value.scalableMatrixWithTieredPricing) + value.cumulativeGroupedBulk != null -> + generator.writeObject(value.cumulativeGroupedBulk) + value.tieredPackageWithMinimum != null -> + generator.writeObject(value.tieredPackageWithMinimum) + value.matrixWithAllocation != null -> + generator.writeObject(value.matrixWithAllocation) + value.groupedTiered != null -> generator.writeObject(value.groupedTiered) + value.minimum != null -> generator.writeObject(value.minimum) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Price") + } + } } - class Minimum + class GroupedWithMinMaxThresholds private constructor( private val cadence: JsonField, + private val groupedWithMinMaxThresholdsConfig: + JsonField, private val itemId: JsonField, - private val minimumConfig: JsonField, private val modelType: JsonValue, private val name: JsonField, private val billableMetricId: JsonField, @@ -10309,12 +7271,14 @@ private constructor( @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), + @JsonProperty("grouped_with_min_max_thresholds_config") + @ExcludeMissing + groupedWithMinMaxThresholdsConfig: + JsonField = + JsonMissing.of(), @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), - @JsonProperty("minimum_config") - @ExcludeMissing - minimumConfig: JsonField = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing modelType: JsonValue = JsonMissing.of(), @@ -10365,8 +7329,8 @@ private constructor( referenceId: JsonField = JsonMissing.of(), ) : this( cadence, + groupedWithMinMaxThresholdsConfig, itemId, - minimumConfig, modelType, name, billableMetricId, @@ -10395,25 +7359,28 @@ private constructor( fun cadence(): Cadence = cadence.getRequired("cadence") /** - * The id of the item the price will be associated with. - * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected * value). */ - fun itemId(): String = itemId.getRequired("item_id") + fun groupedWithMinMaxThresholdsConfig(): GroupedWithMinMaxThresholdsConfig = + groupedWithMinMaxThresholdsConfig.getRequired( + "grouped_with_min_max_thresholds_config" + ) /** + * The id of the item the price will be associated with. + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected * value). */ - fun minimumConfig(): MinimumConfig = minimumConfig.getRequired("minimum_config") + fun itemId(): String = itemId.getRequired("item_id") /** * Expected to always return the following: * ```kotlin - * JsonValue.from("minimum") + * JsonValue.from("grouped_with_min_max_thresholds") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -10560,22 +7527,23 @@ private constructor( fun _cadence(): JsonField = cadence /** - * Returns the raw JSON value of [itemId]. + * Returns the raw JSON value of [groupedWithMinMaxThresholdsConfig]. * - * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected - * type. + * Unlike [groupedWithMinMaxThresholdsConfig], this method doesn't throw if the JSON + * field has an unexpected type. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + @JsonProperty("grouped_with_min_max_thresholds_config") + @ExcludeMissing + fun _groupedWithMinMaxThresholdsConfig(): + JsonField = groupedWithMinMaxThresholdsConfig /** - * Returns the raw JSON value of [minimumConfig]. + * Returns the raw JSON value of [itemId]. * - * Unlike [minimumConfig], this method doesn't throw if the JSON field has an - * unexpected type. + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. */ - @JsonProperty("minimum_config") - @ExcludeMissing - fun _minimumConfig(): JsonField = minimumConfig + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId /** * Returns the raw JSON value of [name]. @@ -10733,26 +7701,30 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [Minimum]. + * Returns a mutable builder for constructing an instance of + * [GroupedWithMinMaxThresholds]. * * The following fields are required: * ```kotlin * .cadence() + * .groupedWithMinMaxThresholdsConfig() * .itemId() - * .minimumConfig() * .name() * ``` */ fun builder() = Builder() } - /** A builder for [Minimum]. */ + /** A builder for [GroupedWithMinMaxThresholds]. */ class Builder internal constructor() { private var cadence: JsonField? = null + private var groupedWithMinMaxThresholdsConfig: + JsonField? = + null private var itemId: JsonField? = null - private var minimumConfig: JsonField? = null - private var modelType: JsonValue = JsonValue.from("minimum") + private var modelType: JsonValue = + JsonValue.from("grouped_with_min_max_thresholds") private var name: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() @@ -10775,27 +7747,33 @@ private constructor( private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(minimum: Minimum) = apply { - cadence = minimum.cadence - itemId = minimum.itemId - minimumConfig = minimum.minimumConfig - modelType = minimum.modelType - name = minimum.name - billableMetricId = minimum.billableMetricId - billedInAdvance = minimum.billedInAdvance - billingCycleConfiguration = minimum.billingCycleConfiguration - conversionRate = minimum.conversionRate - conversionRateConfig = minimum.conversionRateConfig - currency = minimum.currency - dimensionalPriceConfiguration = minimum.dimensionalPriceConfiguration - externalPriceId = minimum.externalPriceId - fixedPriceQuantity = minimum.fixedPriceQuantity - invoiceGroupingKey = minimum.invoiceGroupingKey - invoicingCycleConfiguration = minimum.invoicingCycleConfiguration - metadata = minimum.metadata - referenceId = minimum.referenceId - additionalProperties = minimum.additionalProperties.toMutableMap() - } + internal fun from(groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds) = + apply { + cadence = groupedWithMinMaxThresholds.cadence + groupedWithMinMaxThresholdsConfig = + groupedWithMinMaxThresholds.groupedWithMinMaxThresholdsConfig + itemId = groupedWithMinMaxThresholds.itemId + modelType = groupedWithMinMaxThresholds.modelType + name = groupedWithMinMaxThresholds.name + billableMetricId = groupedWithMinMaxThresholds.billableMetricId + billedInAdvance = groupedWithMinMaxThresholds.billedInAdvance + billingCycleConfiguration = + groupedWithMinMaxThresholds.billingCycleConfiguration + conversionRate = groupedWithMinMaxThresholds.conversionRate + conversionRateConfig = groupedWithMinMaxThresholds.conversionRateConfig + currency = groupedWithMinMaxThresholds.currency + dimensionalPriceConfiguration = + groupedWithMinMaxThresholds.dimensionalPriceConfiguration + externalPriceId = groupedWithMinMaxThresholds.externalPriceId + fixedPriceQuantity = groupedWithMinMaxThresholds.fixedPriceQuantity + invoiceGroupingKey = groupedWithMinMaxThresholds.invoiceGroupingKey + invoicingCycleConfiguration = + groupedWithMinMaxThresholds.invoicingCycleConfiguration + metadata = groupedWithMinMaxThresholds.metadata + referenceId = groupedWithMinMaxThresholds.referenceId + additionalProperties = + groupedWithMinMaxThresholds.additionalProperties.toMutableMap() + } /** The cadence to bill for this price on. */ fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) @@ -10809,6 +7787,28 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + fun groupedWithMinMaxThresholdsConfig( + groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + ) = + groupedWithMinMaxThresholdsConfig( + JsonField.of(groupedWithMinMaxThresholdsConfig) + ) + + /** + * Sets [Builder.groupedWithMinMaxThresholdsConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.groupedWithMinMaxThresholdsConfig] with a + * well-typed [GroupedWithMinMaxThresholdsConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun groupedWithMinMaxThresholdsConfig( + groupedWithMinMaxThresholdsConfig: + JsonField + ) = apply { + this.groupedWithMinMaxThresholdsConfig = groupedWithMinMaxThresholdsConfig + } + /** The id of the item the price will be associated with. */ fun itemId(itemId: String) = itemId(JsonField.of(itemId)) @@ -10821,27 +7821,13 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun minimumConfig(minimumConfig: MinimumConfig) = - minimumConfig(JsonField.of(minimumConfig)) - - /** - * Sets [Builder.minimumConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.minimumConfig] with a well-typed - * [MinimumConfig] value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. - */ - fun minimumConfig(minimumConfig: JsonField) = apply { - this.minimumConfig = minimumConfig - } - /** * Sets the field to an arbitrary JSON value. * * It is usually unnecessary to call this method because the field defaults to * the following: * ```kotlin - * JsonValue.from("minimum") + * JsonValue.from("grouped_with_min_max_thresholds") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -11190,25 +8176,28 @@ private constructor( } /** - * Returns an immutable instance of [Minimum]. + * Returns an immutable instance of [GroupedWithMinMaxThresholds]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```kotlin * .cadence() + * .groupedWithMinMaxThresholdsConfig() * .itemId() - * .minimumConfig() * .name() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): Minimum = - Minimum( + fun build(): GroupedWithMinMaxThresholds = + GroupedWithMinMaxThresholds( checkRequired("cadence", cadence), + checkRequired( + "groupedWithMinMaxThresholdsConfig", + groupedWithMinMaxThresholdsConfig, + ), checkRequired("itemId", itemId), - checkRequired("minimumConfig", minimumConfig), modelType, checkRequired("name", name), billableMetricId, @@ -11230,16 +8219,16 @@ private constructor( private var validated: Boolean = false - fun validate(): Minimum = apply { + fun validate(): GroupedWithMinMaxThresholds = apply { if (validated) { return@apply } cadence().validate() + groupedWithMinMaxThresholdsConfig().validate() itemId() - minimumConfig().validate() _modelType().let { - if (it != JsonValue.from("minimum")) { + if (it != JsonValue.from("grouped_with_min_max_thresholds")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } @@ -11276,9 +8265,11 @@ private constructor( */ internal fun validity(): Int = (cadence.asKnown()?.validity() ?: 0) + + (groupedWithMinMaxThresholdsConfig.asKnown()?.validity() ?: 0) + (if (itemId.asKnown() == null) 0 else 1) + - (minimumConfig.asKnown()?.validity() ?: 0) + - modelType.let { if (it == JsonValue.from("minimum")) 1 else 0 } + + modelType.let { + if (it == JsonValue.from("grouped_with_min_max_thresholds")) 1 else 0 + } + (if (name.asKnown() == null) 0 else 1) + (if (billableMetricId.asKnown() == null) 0 else 1) + (if (billedInAdvance.asKnown() == null) 0 else 1) + @@ -11451,70 +8442,16 @@ private constructor( override fun toString() = value.toString() } - class MinimumConfig + class GroupedWithMinMaxThresholdsConfig + @JsonCreator private constructor( - private val minimumAmount: JsonField, - private val prorated: JsonField, - private val additionalProperties: MutableMap, + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map ) { - @JsonCreator - private constructor( - @JsonProperty("minimum_amount") - @ExcludeMissing - minimumAmount: JsonField = JsonMissing.of(), - @JsonProperty("prorated") - @ExcludeMissing - prorated: JsonField = JsonMissing.of(), - ) : this(minimumAmount, prorated, mutableMapOf()) - - /** - * The minimum amount to apply - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") - - /** - * By default, subtotals from minimum composite prices are prorated based on the - * service period. Set to false to disable proration. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun prorated(): Boolean? = prorated.getNullable("prorated") - - /** - * Returns the raw JSON value of [minimumAmount]. - * - * Unlike [minimumAmount], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("minimum_amount") - @ExcludeMissing - fun _minimumAmount(): JsonField = minimumAmount - - /** - * Returns the raw JSON value of [prorated]. - * - * Unlike [prorated], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("prorated") - @ExcludeMissing - fun _prorated(): JsonField = prorated - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + fun _additionalProperties(): Map = additionalProperties fun toBuilder() = Builder().from(this) @@ -11522,67 +8459,23 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [MinimumConfig]. - * - * The following fields are required: - * ```kotlin - * .minimumAmount() - * ``` + * [GroupedWithMinMaxThresholdsConfig]. */ fun builder() = Builder() } - /** A builder for [MinimumConfig]. */ + /** A builder for [GroupedWithMinMaxThresholdsConfig]. */ class Builder internal constructor() { - private var minimumAmount: JsonField? = null - private var prorated: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(minimumConfig: MinimumConfig) = apply { - minimumAmount = minimumConfig.minimumAmount - prorated = minimumConfig.prorated - additionalProperties = minimumConfig.additionalProperties.toMutableMap() - } - - /** The minimum amount to apply */ - fun minimumAmount(minimumAmount: String) = - minimumAmount(JsonField.of(minimumAmount)) - - /** - * Sets [Builder.minimumAmount] to an arbitrary JSON value. - * - * You should usually call [Builder.minimumAmount] with a well-typed - * [String] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun minimumAmount(minimumAmount: JsonField) = apply { - this.minimumAmount = minimumAmount - } - - /** - * By default, subtotals from minimum composite prices are prorated based on - * the service period. Set to false to disable proration. - */ - fun prorated(prorated: Boolean?) = prorated(JsonField.ofNullable(prorated)) - - /** - * Alias for [Builder.prorated]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun prorated(prorated: Boolean) = prorated(prorated as Boolean?) - - /** - * Sets [Builder.prorated] to an arbitrary JSON value. - * - * You should usually call [Builder.prorated] with a well-typed [Boolean] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun prorated(prorated: JsonField) = apply { - this.prorated = prorated + internal fun from( + groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + ) = apply { + additionalProperties = + groupedWithMinMaxThresholdsConfig.additionalProperties + .toMutableMap() } fun additionalProperties(additionalProperties: Map) = @@ -11608,34 +8501,21 @@ private constructor( } /** - * Returns an immutable instance of [MinimumConfig]. + * Returns an immutable instance of [GroupedWithMinMaxThresholdsConfig]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```kotlin - * .minimumAmount() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ - fun build(): MinimumConfig = - MinimumConfig( - checkRequired("minimumAmount", minimumAmount), - prorated, - additionalProperties.toMutableMap(), - ) + fun build(): GroupedWithMinMaxThresholdsConfig = + GroupedWithMinMaxThresholdsConfig(additionalProperties.toImmutable()) } private var validated: Boolean = false - fun validate(): MinimumConfig = apply { + fun validate(): GroupedWithMinMaxThresholdsConfig = apply { if (validated) { return@apply } - minimumAmount() - prorated() validated = true } @@ -11654,28 +8534,25 @@ private constructor( * Used for best match union deserialization. */ internal fun validity(): Int = - (if (minimumAmount.asKnown() == null) 0 else 1) + - (if (prorated.asKnown() == null) 0 else 1) + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is MinimumConfig && - minimumAmount == other.minimumAmount && - prorated == other.prorated && + return other is GroupedWithMinMaxThresholdsConfig && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { - Objects.hash(minimumAmount, prorated, additionalProperties) - } + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "MinimumConfig{minimumAmount=$minimumAmount, prorated=$prorated, additionalProperties=$additionalProperties}" + "GroupedWithMinMaxThresholdsConfig{additionalProperties=$additionalProperties}" } /** @@ -11792,10 +8669,11 @@ private constructor( return true } - return other is Minimum && + return other is GroupedWithMinMaxThresholds && cadence == other.cadence && + groupedWithMinMaxThresholdsConfig == + other.groupedWithMinMaxThresholdsConfig && itemId == other.itemId && - minimumConfig == other.minimumConfig && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && @@ -11817,8 +8695,8 @@ private constructor( private val hashCode: Int by lazy { Objects.hash( cadence, + groupedWithMinMaxThresholdsConfig, itemId, - minimumConfig, modelType, name, billableMetricId, @@ -11841,7 +8719,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Minimum{cadence=$cadence, itemId=$itemId, minimumConfig=$minimumConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "GroupedWithMinMaxThresholds{cadence=$cadence, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } } diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingMinimumCompositePrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingMinimumCompositePrice.kt new file mode 100644 index 000000000..9e8f49f36 --- /dev/null +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingMinimumCompositePrice.kt @@ -0,0 +1,1545 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.withorb.api.core.Enum +import com.withorb.api.core.ExcludeMissing +import com.withorb.api.core.JsonField +import com.withorb.api.core.JsonMissing +import com.withorb.api.core.JsonValue +import com.withorb.api.core.checkRequired +import com.withorb.api.core.toImmutable +import com.withorb.api.errors.OrbInvalidDataException +import java.util.Collections +import java.util.Objects + +class NewFloatingMinimumCompositePrice +private constructor( + private val cadence: JsonField, + private val currency: JsonField, + private val itemId: JsonField, + private val minimumConfig: JsonField, + private val modelType: JsonField, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val dimensionalPriceConfiguration: JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val metadata: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), + @JsonProperty("currency") @ExcludeMissing currency: JsonField = JsonMissing.of(), + @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), + @JsonProperty("minimum_config") + @ExcludeMissing + minimumConfig: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), + ) : this( + cadence, + currency, + itemId, + minimumConfig, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * An ISO 4217 currency string for which this price is billed in. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun minimumConfig(): MinimumConfig = minimumConfig.getRequired("minimum_config") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun modelType(): ModelType = modelType.getRequired("model_type") + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun billableMetricId(): String? = billableMetricId.getNullable("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is true, + * and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = invoiceGroupingKey.getNullable("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by setting + * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to + * `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [minimumConfig]. + * + * Unlike [minimumConfig], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("minimum_config") + @ExcludeMissing + fun _minimumConfig(): JsonField = minimumConfig + + /** + * Returns the raw JSON value of [modelType]. + * + * Unlike [modelType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonField = modelType + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [NewFloatingMinimumCompositePrice]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .currency() + * .itemId() + * .minimumConfig() + * .modelType() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [NewFloatingMinimumCompositePrice]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var currency: JsonField? = null + private var itemId: JsonField? = null + private var minimumConfig: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(newFloatingMinimumCompositePrice: NewFloatingMinimumCompositePrice) = + apply { + cadence = newFloatingMinimumCompositePrice.cadence + currency = newFloatingMinimumCompositePrice.currency + itemId = newFloatingMinimumCompositePrice.itemId + minimumConfig = newFloatingMinimumCompositePrice.minimumConfig + modelType = newFloatingMinimumCompositePrice.modelType + name = newFloatingMinimumCompositePrice.name + billableMetricId = newFloatingMinimumCompositePrice.billableMetricId + billedInAdvance = newFloatingMinimumCompositePrice.billedInAdvance + billingCycleConfiguration = + newFloatingMinimumCompositePrice.billingCycleConfiguration + conversionRate = newFloatingMinimumCompositePrice.conversionRate + conversionRateConfig = newFloatingMinimumCompositePrice.conversionRateConfig + dimensionalPriceConfiguration = + newFloatingMinimumCompositePrice.dimensionalPriceConfiguration + externalPriceId = newFloatingMinimumCompositePrice.externalPriceId + fixedPriceQuantity = newFloatingMinimumCompositePrice.fixedPriceQuantity + invoiceGroupingKey = newFloatingMinimumCompositePrice.invoiceGroupingKey + invoicingCycleConfiguration = + newFloatingMinimumCompositePrice.invoicingCycleConfiguration + metadata = newFloatingMinimumCompositePrice.metadata + additionalProperties = + newFloatingMinimumCompositePrice.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun minimumConfig(minimumConfig: MinimumConfig) = minimumConfig(JsonField.of(minimumConfig)) + + /** + * Sets [Builder.minimumConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumConfig] with a well-typed [MinimumConfig] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun minimumConfig(minimumConfig: JsonField) = apply { + this.minimumConfig = minimumConfig + } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + /** + * Sets [Builder.modelType] to an arbitrary JSON value. + * + * You should usually call [Builder.modelType] with a well-typed [ModelType] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun modelType(modelType: JsonField) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** The id of the billable metric for the price. Only needed if the price is usage-based. */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** For custom cadence: specifies the duration of the billing period in days or months. */ + fun billingCycleConfiguration(billingCycleConfiguration: NewBillingCycleConfiguration?) = + billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** The configuration for the rate of the price currency to the invoicing currency. */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun conversionRateConfig(conversionRateConfig: JsonField) = apply { + this.conversionRateConfig = conversionRateConfig + } + + /** Alias for calling [conversionRateConfig] with `ConversionRateConfig.ofUnit(unit)`. */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + .tieredConfig(tieredConfig) + .build() + ) + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = dimensionalPriceConfiguration(JsonField.ofNullable(dimensionalPriceConfiguration)) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a well-typed + * [NewDimensionalPriceConfiguration] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** If the Price represents a fixed cost, this represents the quantity of units applied. */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [NewFloatingMinimumCompositePrice]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .currency() + * .itemId() + * .minimumConfig() + * .modelType() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): NewFloatingMinimumCompositePrice = + NewFloatingMinimumCompositePrice( + checkRequired("cadence", cadence), + checkRequired("currency", currency), + checkRequired("itemId", itemId), + checkRequired("minimumConfig", minimumConfig), + checkRequired("modelType", modelType), + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): NewFloatingMinimumCompositePrice = apply { + if (validated) { + return@apply + } + + cadence().validate() + currency() + itemId() + minimumConfig().validate() + modelType().validate() + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + metadata()?.validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (if (itemId.asKnown() == null) 0 else 1) + + (minimumConfig.asKnown()?.validity() ?: 0) + + (modelType.asKnown()?.validity() ?: 0) + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (metadata.asKnown()?.validity() ?: 0) + + /** The cadence to bill for this price on. */ + class Cadence @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** An enum member indicating that [Cadence] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the expected + * primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class MinimumConfig + private constructor( + private val minimumAmount: JsonField, + private val prorated: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("minimum_amount") + @ExcludeMissing + minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("prorated") + @ExcludeMissing + prorated: JsonField = JsonMissing.of(), + ) : this(minimumAmount, prorated, mutableMapOf()) + + /** + * The minimum amount to apply + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") + + /** + * By default, subtotals from minimum composite prices are prorated based on the service + * period. Set to false to disable proration. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun prorated(): Boolean? = prorated.getNullable("prorated") + + /** + * Returns the raw JSON value of [minimumAmount]. + * + * Unlike [minimumAmount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount + + /** + * Returns the raw JSON value of [prorated]. + * + * Unlike [prorated], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("prorated") @ExcludeMissing fun _prorated(): JsonField = prorated + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [MinimumConfig]. + * + * The following fields are required: + * ```kotlin + * .minimumAmount() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [MinimumConfig]. */ + class Builder internal constructor() { + + private var minimumAmount: JsonField? = null + private var prorated: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(minimumConfig: MinimumConfig) = apply { + minimumAmount = minimumConfig.minimumAmount + prorated = minimumConfig.prorated + additionalProperties = minimumConfig.additionalProperties.toMutableMap() + } + + /** The minimum amount to apply */ + fun minimumAmount(minimumAmount: String) = minimumAmount(JsonField.of(minimumAmount)) + + /** + * Sets [Builder.minimumAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumAmount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount + } + + /** + * By default, subtotals from minimum composite prices are prorated based on the service + * period. Set to false to disable proration. + */ + fun prorated(prorated: Boolean?) = prorated(JsonField.ofNullable(prorated)) + + /** + * Alias for [Builder.prorated]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun prorated(prorated: Boolean) = prorated(prorated as Boolean?) + + /** + * Sets [Builder.prorated] to an arbitrary JSON value. + * + * You should usually call [Builder.prorated] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun prorated(prorated: JsonField) = apply { this.prorated = prorated } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [MinimumConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .minimumAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MinimumConfig = + MinimumConfig( + checkRequired("minimumAmount", minimumAmount), + prorated, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MinimumConfig = apply { + if (validated) { + return@apply + } + + minimumAmount() + prorated() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (minimumAmount.asKnown() == null) 0 else 1) + + (if (prorated.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MinimumConfig && + minimumAmount == other.minimumAmount && + prorated == other.prorated && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(minimumAmount, prorated, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MinimumConfig{minimumAmount=$minimumAmount, prorated=$prorated, additionalProperties=$additionalProperties}" + } + + class ModelType @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val MINIMUM = of("minimum") + + fun of(value: String) = ModelType(JsonField.of(value)) + } + + /** An enum containing [ModelType]'s known values. */ + enum class Known { + MINIMUM + } + + /** + * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ModelType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + MINIMUM, + /** + * An enum member indicating that [ModelType] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + MINIMUM -> Value.MINIMUM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known member. + */ + fun known(): Known = + when (this) { + MINIMUM -> Known.MINIMUM + else -> throw OrbInvalidDataException("Unknown ModelType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the expected + * primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): ModelType = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ModelType && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by setting + * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to + * `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is NewFloatingMinimumCompositePrice && + cadence == other.cadence && + currency == other.currency && + itemId == other.itemId && + minimumConfig == other.minimumConfig && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + currency, + itemId, + minimumConfig, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "NewFloatingMinimumCompositePrice{cadence=$cadence, currency=$currency, itemId=$itemId, minimumConfig=$minimumConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" +} diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanMinimumCompositePrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanMinimumCompositePrice.kt new file mode 100644 index 000000000..c99720957 --- /dev/null +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanMinimumCompositePrice.kt @@ -0,0 +1,1587 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.withorb.api.core.Enum +import com.withorb.api.core.ExcludeMissing +import com.withorb.api.core.JsonField +import com.withorb.api.core.JsonMissing +import com.withorb.api.core.JsonValue +import com.withorb.api.core.checkRequired +import com.withorb.api.core.toImmutable +import com.withorb.api.errors.OrbInvalidDataException +import java.util.Collections +import java.util.Objects + +class NewPlanMinimumCompositePrice +private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val minimumConfig: JsonField, + private val modelType: JsonField, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), + @JsonProperty("minimum_config") + @ExcludeMissing + minimumConfig: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") @ExcludeMissing currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + minimumConfig, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun minimumConfig(): MinimumConfig = minimumConfig.getRequired("minimum_config") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun modelType(): ModelType = modelType.getRequired("model_type") + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun billableMetricId(): String? = billableMetricId.getNullable("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is true, + * and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this price is + * billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = invoiceGroupingKey.getNullable("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by setting + * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to + * `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments in the same + * API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [minimumConfig]. + * + * Unlike [minimumConfig], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("minimum_config") + @ExcludeMissing + fun _minimumConfig(): JsonField = minimumConfig + + /** + * Returns the raw JSON value of [modelType]. + * + * Unlike [modelType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonField = modelType + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [NewPlanMinimumCompositePrice]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .minimumConfig() + * .modelType() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [NewPlanMinimumCompositePrice]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var minimumConfig: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(newPlanMinimumCompositePrice: NewPlanMinimumCompositePrice) = apply { + cadence = newPlanMinimumCompositePrice.cadence + itemId = newPlanMinimumCompositePrice.itemId + minimumConfig = newPlanMinimumCompositePrice.minimumConfig + modelType = newPlanMinimumCompositePrice.modelType + name = newPlanMinimumCompositePrice.name + billableMetricId = newPlanMinimumCompositePrice.billableMetricId + billedInAdvance = newPlanMinimumCompositePrice.billedInAdvance + billingCycleConfiguration = newPlanMinimumCompositePrice.billingCycleConfiguration + conversionRate = newPlanMinimumCompositePrice.conversionRate + conversionRateConfig = newPlanMinimumCompositePrice.conversionRateConfig + currency = newPlanMinimumCompositePrice.currency + dimensionalPriceConfiguration = + newPlanMinimumCompositePrice.dimensionalPriceConfiguration + externalPriceId = newPlanMinimumCompositePrice.externalPriceId + fixedPriceQuantity = newPlanMinimumCompositePrice.fixedPriceQuantity + invoiceGroupingKey = newPlanMinimumCompositePrice.invoiceGroupingKey + invoicingCycleConfiguration = newPlanMinimumCompositePrice.invoicingCycleConfiguration + metadata = newPlanMinimumCompositePrice.metadata + referenceId = newPlanMinimumCompositePrice.referenceId + additionalProperties = newPlanMinimumCompositePrice.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun minimumConfig(minimumConfig: MinimumConfig) = minimumConfig(JsonField.of(minimumConfig)) + + /** + * Sets [Builder.minimumConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumConfig] with a well-typed [MinimumConfig] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun minimumConfig(minimumConfig: JsonField) = apply { + this.minimumConfig = minimumConfig + } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + /** + * Sets [Builder.modelType] to an arbitrary JSON value. + * + * You should usually call [Builder.modelType] with a well-typed [ModelType] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun modelType(modelType: JsonField) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** The id of the billable metric for the price. Only needed if the price is usage-based. */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** For custom cadence: specifies the duration of the billing period in days or months. */ + fun billingCycleConfiguration(billingCycleConfiguration: NewBillingCycleConfiguration?) = + billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** The configuration for the rate of the price currency to the invoicing currency. */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun conversionRateConfig(conversionRateConfig: JsonField) = apply { + this.conversionRateConfig = conversionRateConfig + } + + /** Alias for calling [conversionRateConfig] with `ConversionRateConfig.ofUnit(unit)`. */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this price is + * billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = dimensionalPriceConfiguration(JsonField.ofNullable(dimensionalPriceConfiguration)) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a well-typed + * [NewDimensionalPriceConfiguration] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** If the Price represents a fixed cost, this represents the quantity of units applied. */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding adjustments in the + * same API call. + */ + fun referenceId(referenceId: String?) = referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun referenceId(referenceId: JsonField) = apply { this.referenceId = referenceId } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [NewPlanMinimumCompositePrice]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .minimumConfig() + * .modelType() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): NewPlanMinimumCompositePrice = + NewPlanMinimumCompositePrice( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("minimumConfig", minimumConfig), + checkRequired("modelType", modelType), + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): NewPlanMinimumCompositePrice = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + minimumConfig().validate() + modelType().validate() + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + (minimumConfig.asKnown()?.validity() ?: 0) + + (modelType.asKnown()?.validity() ?: 0) + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** An enum member indicating that [Cadence] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the expected + * primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class MinimumConfig + private constructor( + private val minimumAmount: JsonField, + private val prorated: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("minimum_amount") + @ExcludeMissing + minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("prorated") + @ExcludeMissing + prorated: JsonField = JsonMissing.of(), + ) : this(minimumAmount, prorated, mutableMapOf()) + + /** + * The minimum amount to apply + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") + + /** + * By default, subtotals from minimum composite prices are prorated based on the service + * period. Set to false to disable proration. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun prorated(): Boolean? = prorated.getNullable("prorated") + + /** + * Returns the raw JSON value of [minimumAmount]. + * + * Unlike [minimumAmount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount + + /** + * Returns the raw JSON value of [prorated]. + * + * Unlike [prorated], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("prorated") @ExcludeMissing fun _prorated(): JsonField = prorated + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [MinimumConfig]. + * + * The following fields are required: + * ```kotlin + * .minimumAmount() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [MinimumConfig]. */ + class Builder internal constructor() { + + private var minimumAmount: JsonField? = null + private var prorated: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(minimumConfig: MinimumConfig) = apply { + minimumAmount = minimumConfig.minimumAmount + prorated = minimumConfig.prorated + additionalProperties = minimumConfig.additionalProperties.toMutableMap() + } + + /** The minimum amount to apply */ + fun minimumAmount(minimumAmount: String) = minimumAmount(JsonField.of(minimumAmount)) + + /** + * Sets [Builder.minimumAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumAmount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount + } + + /** + * By default, subtotals from minimum composite prices are prorated based on the service + * period. Set to false to disable proration. + */ + fun prorated(prorated: Boolean?) = prorated(JsonField.ofNullable(prorated)) + + /** + * Alias for [Builder.prorated]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun prorated(prorated: Boolean) = prorated(prorated as Boolean?) + + /** + * Sets [Builder.prorated] to an arbitrary JSON value. + * + * You should usually call [Builder.prorated] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun prorated(prorated: JsonField) = apply { this.prorated = prorated } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [MinimumConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .minimumAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MinimumConfig = + MinimumConfig( + checkRequired("minimumAmount", minimumAmount), + prorated, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MinimumConfig = apply { + if (validated) { + return@apply + } + + minimumAmount() + prorated() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (minimumAmount.asKnown() == null) 0 else 1) + + (if (prorated.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MinimumConfig && + minimumAmount == other.minimumAmount && + prorated == other.prorated && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(minimumAmount, prorated, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MinimumConfig{minimumAmount=$minimumAmount, prorated=$prorated, additionalProperties=$additionalProperties}" + } + + class ModelType @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val MINIMUM = of("minimum") + + fun of(value: String) = ModelType(JsonField.of(value)) + } + + /** An enum containing [ModelType]'s known values. */ + enum class Known { + MINIMUM + } + + /** + * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ModelType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + MINIMUM, + /** + * An enum member indicating that [ModelType] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + MINIMUM -> Value.MINIMUM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known member. + */ + fun known(): Known = + when (this) { + MINIMUM -> Known.MINIMUM + else -> throw OrbInvalidDataException("Unknown ModelType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the expected + * primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): ModelType = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ModelType && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by setting + * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to + * `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is NewPlanMinimumCompositePrice && + cadence == other.cadence && + itemId == other.itemId && + minimumConfig == other.minimumConfig && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + minimumConfig, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "NewPlanMinimumCompositePrice{cadence=$cadence, itemId=$itemId, minimumConfig=$minimumConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" +} diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionMinimumCompositePrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionMinimumCompositePrice.kt new file mode 100644 index 000000000..3e28ecf1d --- /dev/null +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionMinimumCompositePrice.kt @@ -0,0 +1,1593 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.withorb.api.core.Enum +import com.withorb.api.core.ExcludeMissing +import com.withorb.api.core.JsonField +import com.withorb.api.core.JsonMissing +import com.withorb.api.core.JsonValue +import com.withorb.api.core.checkRequired +import com.withorb.api.core.toImmutable +import com.withorb.api.errors.OrbInvalidDataException +import java.util.Collections +import java.util.Objects + +class NewSubscriptionMinimumCompositePrice +private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val minimumConfig: JsonField, + private val modelType: JsonField, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), + @JsonProperty("minimum_config") + @ExcludeMissing + minimumConfig: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") @ExcludeMissing currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + minimumConfig, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun minimumConfig(): MinimumConfig = minimumConfig.getRequired("minimum_config") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun modelType(): ModelType = modelType.getRequired("model_type") + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun billableMetricId(): String? = billableMetricId.getNullable("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is true, + * and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this price is + * billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = invoiceGroupingKey.getNullable("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by setting + * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to + * `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments in the same + * API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [minimumConfig]. + * + * Unlike [minimumConfig], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("minimum_config") + @ExcludeMissing + fun _minimumConfig(): JsonField = minimumConfig + + /** + * Returns the raw JSON value of [modelType]. + * + * Unlike [modelType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonField = modelType + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [NewSubscriptionMinimumCompositePrice]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .minimumConfig() + * .modelType() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [NewSubscriptionMinimumCompositePrice]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var minimumConfig: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from( + newSubscriptionMinimumCompositePrice: NewSubscriptionMinimumCompositePrice + ) = apply { + cadence = newSubscriptionMinimumCompositePrice.cadence + itemId = newSubscriptionMinimumCompositePrice.itemId + minimumConfig = newSubscriptionMinimumCompositePrice.minimumConfig + modelType = newSubscriptionMinimumCompositePrice.modelType + name = newSubscriptionMinimumCompositePrice.name + billableMetricId = newSubscriptionMinimumCompositePrice.billableMetricId + billedInAdvance = newSubscriptionMinimumCompositePrice.billedInAdvance + billingCycleConfiguration = + newSubscriptionMinimumCompositePrice.billingCycleConfiguration + conversionRate = newSubscriptionMinimumCompositePrice.conversionRate + conversionRateConfig = newSubscriptionMinimumCompositePrice.conversionRateConfig + currency = newSubscriptionMinimumCompositePrice.currency + dimensionalPriceConfiguration = + newSubscriptionMinimumCompositePrice.dimensionalPriceConfiguration + externalPriceId = newSubscriptionMinimumCompositePrice.externalPriceId + fixedPriceQuantity = newSubscriptionMinimumCompositePrice.fixedPriceQuantity + invoiceGroupingKey = newSubscriptionMinimumCompositePrice.invoiceGroupingKey + invoicingCycleConfiguration = + newSubscriptionMinimumCompositePrice.invoicingCycleConfiguration + metadata = newSubscriptionMinimumCompositePrice.metadata + referenceId = newSubscriptionMinimumCompositePrice.referenceId + additionalProperties = + newSubscriptionMinimumCompositePrice.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun minimumConfig(minimumConfig: MinimumConfig) = minimumConfig(JsonField.of(minimumConfig)) + + /** + * Sets [Builder.minimumConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumConfig] with a well-typed [MinimumConfig] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun minimumConfig(minimumConfig: JsonField) = apply { + this.minimumConfig = minimumConfig + } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + /** + * Sets [Builder.modelType] to an arbitrary JSON value. + * + * You should usually call [Builder.modelType] with a well-typed [ModelType] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun modelType(modelType: JsonField) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** The id of the billable metric for the price. Only needed if the price is usage-based. */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** For custom cadence: specifies the duration of the billing period in days or months. */ + fun billingCycleConfiguration(billingCycleConfiguration: NewBillingCycleConfiguration?) = + billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** The configuration for the rate of the price currency to the invoicing currency. */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun conversionRateConfig(conversionRateConfig: JsonField) = apply { + this.conversionRateConfig = conversionRateConfig + } + + /** Alias for calling [conversionRateConfig] with `ConversionRateConfig.ofUnit(unit)`. */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this price is + * billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = dimensionalPriceConfiguration(JsonField.ofNullable(dimensionalPriceConfiguration)) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a well-typed + * [NewDimensionalPriceConfiguration] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** If the Price represents a fixed cost, this represents the quantity of units applied. */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding adjustments in the + * same API call. + */ + fun referenceId(referenceId: String?) = referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun referenceId(referenceId: JsonField) = apply { this.referenceId = referenceId } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [NewSubscriptionMinimumCompositePrice]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .minimumConfig() + * .modelType() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): NewSubscriptionMinimumCompositePrice = + NewSubscriptionMinimumCompositePrice( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("minimumConfig", minimumConfig), + checkRequired("modelType", modelType), + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): NewSubscriptionMinimumCompositePrice = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + minimumConfig().validate() + modelType().validate() + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + (minimumConfig.asKnown()?.validity() ?: 0) + + (modelType.asKnown()?.validity() ?: 0) + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** An enum member indicating that [Cadence] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the expected + * primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class MinimumConfig + private constructor( + private val minimumAmount: JsonField, + private val prorated: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("minimum_amount") + @ExcludeMissing + minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("prorated") + @ExcludeMissing + prorated: JsonField = JsonMissing.of(), + ) : this(minimumAmount, prorated, mutableMapOf()) + + /** + * The minimum amount to apply + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") + + /** + * By default, subtotals from minimum composite prices are prorated based on the service + * period. Set to false to disable proration. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun prorated(): Boolean? = prorated.getNullable("prorated") + + /** + * Returns the raw JSON value of [minimumAmount]. + * + * Unlike [minimumAmount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount + + /** + * Returns the raw JSON value of [prorated]. + * + * Unlike [prorated], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("prorated") @ExcludeMissing fun _prorated(): JsonField = prorated + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [MinimumConfig]. + * + * The following fields are required: + * ```kotlin + * .minimumAmount() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [MinimumConfig]. */ + class Builder internal constructor() { + + private var minimumAmount: JsonField? = null + private var prorated: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(minimumConfig: MinimumConfig) = apply { + minimumAmount = minimumConfig.minimumAmount + prorated = minimumConfig.prorated + additionalProperties = minimumConfig.additionalProperties.toMutableMap() + } + + /** The minimum amount to apply */ + fun minimumAmount(minimumAmount: String) = minimumAmount(JsonField.of(minimumAmount)) + + /** + * Sets [Builder.minimumAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumAmount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount + } + + /** + * By default, subtotals from minimum composite prices are prorated based on the service + * period. Set to false to disable proration. + */ + fun prorated(prorated: Boolean?) = prorated(JsonField.ofNullable(prorated)) + + /** + * Alias for [Builder.prorated]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun prorated(prorated: Boolean) = prorated(prorated as Boolean?) + + /** + * Sets [Builder.prorated] to an arbitrary JSON value. + * + * You should usually call [Builder.prorated] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun prorated(prorated: JsonField) = apply { this.prorated = prorated } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [MinimumConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .minimumAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MinimumConfig = + MinimumConfig( + checkRequired("minimumAmount", minimumAmount), + prorated, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MinimumConfig = apply { + if (validated) { + return@apply + } + + minimumAmount() + prorated() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (minimumAmount.asKnown() == null) 0 else 1) + + (if (prorated.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MinimumConfig && + minimumAmount == other.minimumAmount && + prorated == other.prorated && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(minimumAmount, prorated, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MinimumConfig{minimumAmount=$minimumAmount, prorated=$prorated, additionalProperties=$additionalProperties}" + } + + class ModelType @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val MINIMUM = of("minimum") + + fun of(value: String) = ModelType(JsonField.of(value)) + } + + /** An enum containing [ModelType]'s known values. */ + enum class Known { + MINIMUM + } + + /** + * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ModelType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + MINIMUM, + /** + * An enum member indicating that [ModelType] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + MINIMUM -> Value.MINIMUM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known member. + */ + fun known(): Known = + when (this) { + MINIMUM -> Known.MINIMUM + else -> throw OrbInvalidDataException("Unknown ModelType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the expected + * primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): ModelType = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ModelType && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by setting + * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to + * `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is NewSubscriptionMinimumCompositePrice && + cadence == other.cadence && + itemId == other.itemId && + minimumConfig == other.minimumConfig && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + minimumConfig, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "NewSubscriptionMinimumCompositePrice{cadence=$cadence, itemId=$itemId, minimumConfig=$minimumConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" +} diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanCreateParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanCreateParams.kt index e0303df01..5005bef18 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanCreateParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanCreateParams.kt @@ -1464,7 +1464,7 @@ private constructor( price(InnerPrice.ofGroupedTiered(groupedTiered)) /** Alias for calling [price] with `InnerPrice.ofMinimum(minimum)`. */ - fun price(minimum: InnerPrice.Minimum) = price(InnerPrice.ofMinimum(minimum)) + fun price(minimum: NewPlanMinimumCompositePrice) = price(InnerPrice.ofMinimum(minimum)) fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -1560,7 +1560,7 @@ private constructor( private val tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice? = null, private val matrixWithAllocation: NewPlanMatrixWithAllocationPrice? = null, private val groupedTiered: NewPlanGroupedTieredPrice? = null, - private val minimum: Minimum? = null, + private val minimum: NewPlanMinimumCompositePrice? = null, private val _json: JsonValue? = null, ) { @@ -1622,7 +1622,7 @@ private constructor( fun groupedTiered(): NewPlanGroupedTieredPrice? = groupedTiered - fun minimum(): Minimum? = minimum + fun minimum(): NewPlanMinimumCompositePrice? = minimum fun isUnit(): Boolean = unit != null @@ -1752,7 +1752,7 @@ private constructor( fun asGroupedTiered(): NewPlanGroupedTieredPrice = groupedTiered.getOrThrow("groupedTiered") - fun asMinimum(): Minimum = minimum.getOrThrow("minimum") + fun asMinimum(): NewPlanMinimumCompositePrice = minimum.getOrThrow("minimum") fun _json(): JsonValue? = _json @@ -1956,7 +1956,7 @@ private constructor( groupedTiered.validate() } - override fun visitMinimum(minimum: Minimum) { + override fun visitMinimum(minimum: NewPlanMinimumCompositePrice) { minimum.validate() } } @@ -2075,7 +2075,8 @@ private constructor( override fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) = groupedTiered.validity() - override fun visitMinimum(minimum: Minimum) = minimum.validity() + override fun visitMinimum(minimum: NewPlanMinimumCompositePrice) = + minimum.validity() override fun unknown(json: JsonValue?) = 0 } @@ -2279,7 +2280,7 @@ private constructor( fun ofGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) = InnerPrice(groupedTiered = groupedTiered) - fun ofMinimum(minimum: Minimum) = InnerPrice(minimum = minimum) + fun ofMinimum(minimum: NewPlanMinimumCompositePrice) = InnerPrice(minimum = minimum) } /** @@ -2366,7 +2367,7 @@ private constructor( fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice): T - fun visitMinimum(minimum: Minimum): T + fun visitMinimum(minimum: NewPlanMinimumCompositePrice): T /** * Maps an unknown variant of [InnerPrice] to a value of type [T]. @@ -2580,9 +2581,12 @@ private constructor( ?: InnerPrice(_json = json) } "minimum" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - InnerPrice(minimum = it, _json = json) - } ?: InnerPrice(_json = json) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { InnerPrice(minimum = it, _json = json) } + ?: InnerPrice(_json = json) } } @@ -4130,1570 +4134,6 @@ private constructor( override fun toString() = "GroupedWithMinMaxThresholds{cadence=$cadence, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - - class Minimum - private constructor( - private val cadence: JsonField, - private val itemId: JsonField, - private val minimumConfig: JsonField, - private val modelType: JsonValue, - private val name: JsonField, - private val billableMetricId: JsonField, - private val billedInAdvance: JsonField, - private val billingCycleConfiguration: JsonField, - private val conversionRate: JsonField, - private val conversionRateConfig: JsonField, - private val currency: JsonField, - private val dimensionalPriceConfiguration: - JsonField, - private val externalPriceId: JsonField, - private val fixedPriceQuantity: JsonField, - private val invoiceGroupingKey: JsonField, - private val invoicingCycleConfiguration: JsonField, - private val metadata: JsonField, - private val referenceId: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("cadence") - @ExcludeMissing - cadence: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - itemId: JsonField = JsonMissing.of(), - @JsonProperty("minimum_config") - @ExcludeMissing - minimumConfig: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - modelType: JsonValue = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - name: JsonField = JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("conversion_rate_config") - @ExcludeMissing - conversionRateConfig: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - currency: JsonField = JsonMissing.of(), - @JsonProperty("dimensional_price_configuration") - @ExcludeMissing - dimensionalPriceConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - metadata: JsonField = JsonMissing.of(), - @JsonProperty("reference_id") - @ExcludeMissing - referenceId: JsonField = JsonMissing.of(), - ) : this( - cadence, - itemId, - minimumConfig, - modelType, - name, - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - conversionRateConfig, - currency, - dimensionalPriceConfiguration, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - mutableMapOf(), - ) - - /** - * The cadence to bill for this price on. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - /** - * The id of the item the price will be associated with. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun itemId(): String = itemId.getRequired("item_id") - - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun minimumConfig(): MinimumConfig = minimumConfig.getRequired("minimum_config") - - /** - * Expected to always return the following: - * ```kotlin - * JsonValue.from("minimum") - * ``` - * - * However, this method can be useful for debugging and logging (e.g. if the server - * responded with an unexpected value). - */ - @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType - - /** - * The name of the price. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun name(): String = name.getRequired("name") - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun billableMetricId(): String? = billableMetricId.getNullable("billable_metric_id") - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun billingCycleConfiguration(): NewBillingCycleConfiguration? = - billingCycleConfiguration.getNullable("billing_cycle_configuration") - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") - - /** - * The configuration for the rate of the price currency to the invoicing currency. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun conversionRateConfig(): ConversionRateConfig? = - conversionRateConfig.getNullable("conversion_rate_config") - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun currency(): String? = currency.getNullable("currency") - - /** - * For dimensional price: specifies a price group and dimension values - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = - dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") - - /** - * An alias for the price. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun fixedPriceQuantity(): Double? = - fixedPriceQuantity.getNullable("fixed_price_quantity") - - /** - * The property used to group this price on an invoice - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun invoiceGroupingKey(): String? = - invoiceGroupingKey.getNullable("invoice_grouping_key") - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun metadata(): Metadata? = metadata.getNullable("metadata") - - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun referenceId(): String? = referenceId.getNullable("reference_id") - - /** - * Returns the raw JSON value of [cadence]. - * - * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("cadence") - @ExcludeMissing - fun _cadence(): JsonField = cadence - - /** - * Returns the raw JSON value of [itemId]. - * - * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - /** - * Returns the raw JSON value of [minimumConfig]. - * - * Unlike [minimumConfig], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("minimum_config") - @ExcludeMissing - fun _minimumConfig(): JsonField = minimumConfig - - /** - * Returns the raw JSON value of [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - /** - * Returns the raw JSON value of [billableMetricId]. - * - * Unlike [billableMetricId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = billableMetricId - - /** - * Returns the raw JSON value of [billedInAdvance]. - * - * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance - - /** - * Returns the raw JSON value of [billingCycleConfiguration]. - * - * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** - * Returns the raw JSON value of [conversionRate]. - * - * Unlike [conversionRate], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** - * Returns the raw JSON value of [conversionRateConfig]. - * - * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("conversion_rate_config") - @ExcludeMissing - fun _conversionRateConfig(): JsonField = conversionRateConfig - - /** - * Returns the raw JSON value of [currency]. - * - * Unlike [currency], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("currency") - @ExcludeMissing - fun _currency(): JsonField = currency - - /** - * Returns the raw JSON value of [dimensionalPriceConfiguration]. - * - * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON - * field has an unexpected type. - */ - @JsonProperty("dimensional_price_configuration") - @ExcludeMissing - fun _dimensionalPriceConfiguration(): JsonField = - dimensionalPriceConfiguration - - /** - * Returns the raw JSON value of [externalPriceId]. - * - * Unlike [externalPriceId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * Returns the raw JSON value of [fixedPriceQuantity]. - * - * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** - * Returns the raw JSON value of [invoiceGroupingKey]. - * - * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Returns the raw JSON value of [invoicingCycleConfiguration]. - * - * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * Returns the raw JSON value of [metadata]. - * - * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - /** - * Returns the raw JSON value of [referenceId]. - * - * Unlike [referenceId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("reference_id") - @ExcludeMissing - fun _referenceId(): JsonField = referenceId - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [Minimum]. - * - * The following fields are required: - * ```kotlin - * .cadence() - * .itemId() - * .minimumConfig() - * .name() - * ``` - */ - fun builder() = Builder() - } - - /** A builder for [Minimum]. */ - class Builder internal constructor() { - - private var cadence: JsonField? = null - private var itemId: JsonField? = null - private var minimumConfig: JsonField? = null - private var modelType: JsonValue = JsonValue.from("minimum") - private var name: JsonField? = null - private var billableMetricId: JsonField = JsonMissing.of() - private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var conversionRateConfig: JsonField = - JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var dimensionalPriceConfiguration: - JsonField = - JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: - JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var referenceId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(minimum: Minimum) = apply { - cadence = minimum.cadence - itemId = minimum.itemId - minimumConfig = minimum.minimumConfig - modelType = minimum.modelType - name = minimum.name - billableMetricId = minimum.billableMetricId - billedInAdvance = minimum.billedInAdvance - billingCycleConfiguration = minimum.billingCycleConfiguration - conversionRate = minimum.conversionRate - conversionRateConfig = minimum.conversionRateConfig - currency = minimum.currency - dimensionalPriceConfiguration = minimum.dimensionalPriceConfiguration - externalPriceId = minimum.externalPriceId - fixedPriceQuantity = minimum.fixedPriceQuantity - invoiceGroupingKey = minimum.invoiceGroupingKey - invoicingCycleConfiguration = minimum.invoicingCycleConfiguration - metadata = minimum.metadata - referenceId = minimum.referenceId - additionalProperties = minimum.additionalProperties.toMutableMap() - } - - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** - * Sets [Builder.cadence] to an arbitrary JSON value. - * - * You should usually call [Builder.cadence] with a well-typed [Cadence] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - - /** The id of the item the price will be associated with. */ - fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - - /** - * Sets [Builder.itemId] to an arbitrary JSON value. - * - * You should usually call [Builder.itemId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - fun minimumConfig(minimumConfig: MinimumConfig) = - minimumConfig(JsonField.of(minimumConfig)) - - /** - * Sets [Builder.minimumConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.minimumConfig] with a well-typed - * [MinimumConfig] value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. - */ - fun minimumConfig(minimumConfig: JsonField) = apply { - this.minimumConfig = minimumConfig - } - - /** - * Sets the field to an arbitrary JSON value. - * - * It is usually unnecessary to call this method because the field defaults to - * the following: - * ```kotlin - * JsonValue.from("minimum") - * ``` - * - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } - - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) - - /** - * Sets [Builder.name] to an arbitrary JSON value. - * - * You should usually call [Builder.name] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun name(name: JsonField) = apply { this.name = name } - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: String?) = - billableMetricId(JsonField.ofNullable(billableMetricId)) - - /** - * Sets [Builder.billableMetricId] to an arbitrary JSON value. - * - * You should usually call [Builder.billableMetricId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun billableMetricId(billableMetricId: JsonField) = apply { - this.billableMetricId = billableMetricId - } - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if - * this is true, and in-arrears if this is false. - */ - fun billedInAdvance(billedInAdvance: Boolean?) = - billedInAdvance(JsonField.ofNullable(billedInAdvance)) - - /** - * Alias for [Builder.billedInAdvance]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun billedInAdvance(billedInAdvance: Boolean) = - billedInAdvance(billedInAdvance as Boolean?) - - /** - * Sets [Builder.billedInAdvance] to an arbitrary JSON value. - * - * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun billedInAdvance(billedInAdvance: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: NewBillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - - /** - * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.billingCycleConfiguration] with a well-typed - * [NewBillingCycleConfiguration] value instead. This method is primarily for - * setting the field to an undocumented or not yet supported value. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: JsonField - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: Double?) = - conversionRate(JsonField.ofNullable(conversionRate)) - - /** - * Alias for [Builder.conversionRate]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) - - /** - * Sets [Builder.conversionRate] to an arbitrary JSON value. - * - * You should usually call [Builder.conversionRate] with a well-typed [Double] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** - * The configuration for the rate of the price currency to the invoicing - * currency. - */ - fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = - conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) - - /** - * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.conversionRateConfig] with a well-typed - * [ConversionRateConfig] value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun conversionRateConfig( - conversionRateConfig: JsonField - ) = apply { this.conversionRateConfig = conversionRateConfig } - - /** - * Alias for calling [conversionRateConfig] with - * `ConversionRateConfig.ofUnit(unit)`. - */ - fun conversionRateConfig(unit: UnitConversionRateConfig) = - conversionRateConfig(ConversionRateConfig.ofUnit(unit)) - - /** - * Alias for calling [conversionRateConfig] with the following: - * ```kotlin - * UnitConversionRateConfig.builder() - * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) - * .unitConfig(unitConfig) - * .build() - * ``` - */ - fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = - conversionRateConfig( - UnitConversionRateConfig.builder() - .conversionRateType( - UnitConversionRateConfig.ConversionRateType.UNIT - ) - .unitConfig(unitConfig) - .build() - ) - - /** - * Alias for calling [conversionRateConfig] with - * `ConversionRateConfig.ofTiered(tiered)`. - */ - fun conversionRateConfig(tiered: TieredConversionRateConfig) = - conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) - - /** - * Alias for calling [conversionRateConfig] with the following: - * ```kotlin - * TieredConversionRateConfig.builder() - * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) - * .tieredConfig(tieredConfig) - * .build() - * ``` - */ - fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = - conversionRateConfig( - TieredConversionRateConfig.builder() - .conversionRateType( - TieredConversionRateConfig.ConversionRateType.TIERED - ) - .tieredConfig(tieredConfig) - .build() - ) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) - - /** - * Sets [Builder.currency] to an arbitrary JSON value. - * - * You should usually call [Builder.currency] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } - - /** For dimensional price: specifies a price group and dimension values */ - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? - ) = - dimensionalPriceConfiguration( - JsonField.ofNullable(dimensionalPriceConfiguration) - ) - - /** - * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.dimensionalPriceConfiguration] with a - * well-typed [NewDimensionalPriceConfiguration] value instead. This method is - * primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: JsonField - ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** - * Sets [Builder.externalPriceId] to an arbitrary JSON value. - * - * You should usually call [Builder.externalPriceId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun externalPriceId(externalPriceId: JsonField) = apply { - this.externalPriceId = externalPriceId - } - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = - fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) - - /** - * Alias for [Builder.fixedPriceQuantity]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. - * - * You should usually call [Builder.fixedPriceQuantity] with a well-typed - * [Double] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = - invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) - - /** - * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. - * - * You should usually call [Builder.invoiceGroupingKey] with a well-typed - * [String] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { - this.invoiceGroupingKey = invoiceGroupingKey - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are - * produced. If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: NewBillingCycleConfiguration? - ) = - invoicingCycleConfiguration( - JsonField.ofNullable(invoicingCycleConfiguration) - ) - - /** - * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.invoicingCycleConfiguration] with a - * well-typed [NewBillingCycleConfiguration] value instead. This method is - * primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * Sets [Builder.metadata] to an arbitrary JSON value. - * - * You should usually call [Builder.metadata] with a well-typed [Metadata] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - fun referenceId(referenceId: String?) = - referenceId(JsonField.ofNullable(referenceId)) - - /** - * Sets [Builder.referenceId] to an arbitrary JSON value. - * - * You should usually call [Builder.referenceId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun referenceId(referenceId: JsonField) = apply { - this.referenceId = referenceId - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Minimum]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```kotlin - * .cadence() - * .itemId() - * .minimumConfig() - * .name() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Minimum = - Minimum( - checkRequired("cadence", cadence), - checkRequired("itemId", itemId), - checkRequired("minimumConfig", minimumConfig), - modelType, - checkRequired("name", name), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - conversionRateConfig, - currency, - dimensionalPriceConfiguration, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Minimum = apply { - if (validated) { - return@apply - } - - cadence().validate() - itemId() - minimumConfig().validate() - _modelType().let { - if (it != JsonValue.from("minimum")) { - throw OrbInvalidDataException("'modelType' is invalid, received $it") - } - } - name() - billableMetricId() - billedInAdvance() - billingCycleConfiguration()?.validate() - conversionRate() - conversionRateConfig()?.validate() - currency() - dimensionalPriceConfiguration()?.validate() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration()?.validate() - metadata()?.validate() - referenceId() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (cadence.asKnown()?.validity() ?: 0) + - (if (itemId.asKnown() == null) 0 else 1) + - (minimumConfig.asKnown()?.validity() ?: 0) + - modelType.let { if (it == JsonValue.from("minimum")) 1 else 0 } + - (if (name.asKnown() == null) 0 else 1) + - (if (billableMetricId.asKnown() == null) 0 else 1) + - (if (billedInAdvance.asKnown() == null) 0 else 1) + - (billingCycleConfiguration.asKnown()?.validity() ?: 0) + - (if (conversionRate.asKnown() == null) 0 else 1) + - (conversionRateConfig.asKnown()?.validity() ?: 0) + - (if (currency.asKnown() == null) 0 else 1) + - (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + - (if (externalPriceId.asKnown() == null) 0 else 1) + - (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + - (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + - (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + - (metadata.asKnown()?.validity() ?: 0) + - (if (referenceId.asKnown() == null) 0 else 1) - - /** The cadence to bill for this price on. */ - class Cadence - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - val ANNUAL = of("annual") - - val SEMI_ANNUAL = of("semi_annual") - - val MONTHLY = of("monthly") - - val QUARTERLY = of("quarterly") - - val ONE_TIME = of("one_time") - - val CUSTOM = of("custom") - - fun of(value: String) = Cadence(JsonField.of(value)) - } - - /** An enum containing [Cadence]'s known values. */ - enum class Known { - ANNUAL, - SEMI_ANNUAL, - MONTHLY, - QUARTERLY, - ONE_TIME, - CUSTOM, - } - - /** - * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Cadence] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - ANNUAL, - SEMI_ANNUAL, - MONTHLY, - QUARTERLY, - ONE_TIME, - CUSTOM, - /** - * An enum member indicating that [Cadence] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - ANNUAL -> Value.ANNUAL - SEMI_ANNUAL -> Value.SEMI_ANNUAL - MONTHLY -> Value.MONTHLY - QUARTERLY -> Value.QUARTERLY - ONE_TIME -> Value.ONE_TIME - CUSTOM -> Value.CUSTOM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - ANNUAL -> Known.ANNUAL - SEMI_ANNUAL -> Known.SEMI_ANNUAL - MONTHLY -> Known.MONTHLY - QUARTERLY -> Known.QUARTERLY - ONE_TIME -> Known.ONE_TIME - CUSTOM -> Known.CUSTOM - else -> throw OrbInvalidDataException("Unknown Cadence: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString() - ?: throw OrbInvalidDataException("Value is not a String") - - private var validated: Boolean = false - - fun validate(): Cadence = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Cadence && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class MinimumConfig - private constructor( - private val minimumAmount: JsonField, - private val prorated: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("minimum_amount") - @ExcludeMissing - minimumAmount: JsonField = JsonMissing.of(), - @JsonProperty("prorated") - @ExcludeMissing - prorated: JsonField = JsonMissing.of(), - ) : this(minimumAmount, prorated, mutableMapOf()) - - /** - * The minimum amount to apply - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") - - /** - * By default, subtotals from minimum composite prices are prorated based on the - * service period. Set to false to disable proration. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun prorated(): Boolean? = prorated.getNullable("prorated") - - /** - * Returns the raw JSON value of [minimumAmount]. - * - * Unlike [minimumAmount], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("minimum_amount") - @ExcludeMissing - fun _minimumAmount(): JsonField = minimumAmount - - /** - * Returns the raw JSON value of [prorated]. - * - * Unlike [prorated], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("prorated") - @ExcludeMissing - fun _prorated(): JsonField = prorated - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [MinimumConfig]. - * - * The following fields are required: - * ```kotlin - * .minimumAmount() - * ``` - */ - fun builder() = Builder() - } - - /** A builder for [MinimumConfig]. */ - class Builder internal constructor() { - - private var minimumAmount: JsonField? = null - private var prorated: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - internal fun from(minimumConfig: MinimumConfig) = apply { - minimumAmount = minimumConfig.minimumAmount - prorated = minimumConfig.prorated - additionalProperties = minimumConfig.additionalProperties.toMutableMap() - } - - /** The minimum amount to apply */ - fun minimumAmount(minimumAmount: String) = - minimumAmount(JsonField.of(minimumAmount)) - - /** - * Sets [Builder.minimumAmount] to an arbitrary JSON value. - * - * You should usually call [Builder.minimumAmount] with a well-typed - * [String] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun minimumAmount(minimumAmount: JsonField) = apply { - this.minimumAmount = minimumAmount - } - - /** - * By default, subtotals from minimum composite prices are prorated based on - * the service period. Set to false to disable proration. - */ - fun prorated(prorated: Boolean?) = prorated(JsonField.ofNullable(prorated)) - - /** - * Alias for [Builder.prorated]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun prorated(prorated: Boolean) = prorated(prorated as Boolean?) - - /** - * Sets [Builder.prorated] to an arbitrary JSON value. - * - * You should usually call [Builder.prorated] with a well-typed [Boolean] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun prorated(prorated: JsonField) = apply { - this.prorated = prorated - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [MinimumConfig]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```kotlin - * .minimumAmount() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): MinimumConfig = - MinimumConfig( - checkRequired("minimumAmount", minimumAmount), - prorated, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): MinimumConfig = apply { - if (validated) { - return@apply - } - - minimumAmount() - prorated() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (if (minimumAmount.asKnown() == null) 0 else 1) + - (if (prorated.asKnown() == null) 0 else 1) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is MinimumConfig && - minimumAmount == other.minimumAmount && - prorated == other.prorated && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(minimumAmount, prorated, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "MinimumConfig{minimumAmount=$minimumAmount, prorated=$prorated, additionalProperties=$additionalProperties}" - } - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - class Metadata - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Metadata]. */ - fun builder() = Builder() - } - - /** A builder for [Metadata]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = - mutableMapOf() - - internal fun from(metadata: Metadata) = apply { - additionalProperties = metadata.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Metadata]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - additionalProperties.count { (_, value) -> - !value.isNull() && !value.isMissing() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Metadata && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Minimum && - cadence == other.cadence && - itemId == other.itemId && - minimumConfig == other.minimumConfig && - modelType == other.modelType && - name == other.name && - billableMetricId == other.billableMetricId && - billedInAdvance == other.billedInAdvance && - billingCycleConfiguration == other.billingCycleConfiguration && - conversionRate == other.conversionRate && - conversionRateConfig == other.conversionRateConfig && - currency == other.currency && - dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && - externalPriceId == other.externalPriceId && - fixedPriceQuantity == other.fixedPriceQuantity && - invoiceGroupingKey == other.invoiceGroupingKey && - invoicingCycleConfiguration == other.invoicingCycleConfiguration && - metadata == other.metadata && - referenceId == other.referenceId && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - cadence, - itemId, - minimumConfig, - modelType, - name, - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - conversionRateConfig, - currency, - dimensionalPriceConfiguration, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Minimum{cadence=$cadence, itemId=$itemId, minimumConfig=$minimumConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" - } } override fun equals(other: Any?): Boolean { diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceCreateParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceCreateParams.kt index 72e7d1257..e7632cba6 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceCreateParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceCreateParams.kt @@ -205,7 +205,7 @@ private constructor( body(Body.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)) /** Alias for calling [body] with `Body.ofMinimum(minimum)`. */ - fun body(minimum: Body.Minimum) = body(Body.ofMinimum(minimum)) + fun body(minimum: NewFloatingMinimumCompositePrice) = body(Body.ofMinimum(minimum)) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -364,7 +364,7 @@ private constructor( null, private val cumulativeGroupedBulk: NewFloatingCumulativeGroupedBulkPrice? = null, private val groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds? = null, - private val minimum: Minimum? = null, + private val minimum: NewFloatingMinimumCompositePrice? = null, private val _json: JsonValue? = null, ) { @@ -426,7 +426,7 @@ private constructor( fun groupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds? = groupedWithMinMaxThresholds - fun minimum(): Minimum? = minimum + fun minimum(): NewFloatingMinimumCompositePrice? = minimum fun isUnit(): Boolean = unit != null @@ -555,7 +555,7 @@ private constructor( fun asGroupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds = groupedWithMinMaxThresholds.getOrThrow("groupedWithMinMaxThresholds") - fun asMinimum(): Minimum = minimum.getOrThrow("minimum") + fun asMinimum(): NewFloatingMinimumCompositePrice = minimum.getOrThrow("minimum") fun _json(): JsonValue? = _json @@ -756,7 +756,7 @@ private constructor( groupedWithMinMaxThresholds.validate() } - override fun visitMinimum(minimum: Minimum) { + override fun visitMinimum(minimum: NewFloatingMinimumCompositePrice) { minimum.validate() } } @@ -875,7 +875,8 @@ private constructor( groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds ) = groupedWithMinMaxThresholds.validity() - override fun visitMinimum(minimum: Minimum) = minimum.validity() + override fun visitMinimum(minimum: NewFloatingMinimumCompositePrice) = + minimum.validity() override fun unknown(json: JsonValue?) = 0 } @@ -1075,7 +1076,7 @@ private constructor( groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds ) = Body(groupedWithMinMaxThresholds = groupedWithMinMaxThresholds) - fun ofMinimum(minimum: Minimum) = Body(minimum = minimum) + fun ofMinimum(minimum: NewFloatingMinimumCompositePrice) = Body(minimum = minimum) } /** An interface that defines how to map each variant of [Body] to a value of type [T]. */ @@ -1161,7 +1162,7 @@ private constructor( groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds ): T - fun visitMinimum(minimum: Minimum): T + fun visitMinimum(minimum: NewFloatingMinimumCompositePrice): T /** * Maps an unknown variant of [Body] to a value of type [T]. @@ -1365,9 +1366,11 @@ private constructor( ?: Body(_json = json) } "minimum" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Body(minimum = it, _json = json) - } ?: Body(_json = json) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Body(minimum = it, _json = json) } ?: Body(_json = json) } } @@ -2826,1485 +2829,6 @@ private constructor( override fun toString() = "GroupedWithMinMaxThresholds{cadence=$cadence, currency=$currency, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" } - - class Minimum - private constructor( - private val cadence: JsonField, - private val currency: JsonField, - private val itemId: JsonField, - private val minimumConfig: JsonField, - private val modelType: JsonValue, - private val name: JsonField, - private val billableMetricId: JsonField, - private val billedInAdvance: JsonField, - private val billingCycleConfiguration: JsonField, - private val conversionRate: JsonField, - private val conversionRateConfig: JsonField, - private val dimensionalPriceConfiguration: JsonField, - private val externalPriceId: JsonField, - private val fixedPriceQuantity: JsonField, - private val invoiceGroupingKey: JsonField, - private val invoicingCycleConfiguration: JsonField, - private val metadata: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("cadence") - @ExcludeMissing - cadence: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - currency: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - itemId: JsonField = JsonMissing.of(), - @JsonProperty("minimum_config") - @ExcludeMissing - minimumConfig: JsonField = JsonMissing.of(), - @JsonProperty("model_type") @ExcludeMissing modelType: JsonValue = JsonMissing.of(), - @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("conversion_rate_config") - @ExcludeMissing - conversionRateConfig: JsonField = JsonMissing.of(), - @JsonProperty("dimensional_price_configuration") - @ExcludeMissing - dimensionalPriceConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - metadata: JsonField = JsonMissing.of(), - ) : this( - cadence, - currency, - itemId, - minimumConfig, - modelType, - name, - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - conversionRateConfig, - dimensionalPriceConfiguration, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - mutableMapOf(), - ) - - /** - * The cadence to bill for this price on. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - /** - * An ISO 4217 currency string for which this price is billed in. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun currency(): String = currency.getRequired("currency") - - /** - * The id of the item the price will be associated with. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun itemId(): String = itemId.getRequired("item_id") - - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun minimumConfig(): MinimumConfig = minimumConfig.getRequired("minimum_config") - - /** - * Expected to always return the following: - * ```kotlin - * JsonValue.from("minimum") - * ``` - * - * However, this method can be useful for debugging and logging (e.g. if the server - * responded with an unexpected value). - */ - @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType - - /** - * The name of the price. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun name(): String = name.getRequired("name") - - /** - * The id of the billable metric for the price. Only needed if the price is usage-based. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun billableMetricId(): String? = billableMetricId.getNullable("billable_metric_id") - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this is - * true, and in-arrears if this is false. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") - - /** - * For custom cadence: specifies the duration of the billing period in days or months. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun billingCycleConfiguration(): NewBillingCycleConfiguration? = - billingCycleConfiguration.getNullable("billing_cycle_configuration") - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") - - /** - * The configuration for the rate of the price currency to the invoicing currency. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun conversionRateConfig(): ConversionRateConfig? = - conversionRateConfig.getNullable("conversion_rate_config") - - /** - * For dimensional price: specifies a price group and dimension values - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = - dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") - - /** - * An alias for the price. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") - - /** - * If the Price represents a fixed cost, this represents the quantity of units applied. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun fixedPriceQuantity(): Double? = - fixedPriceQuantity.getNullable("fixed_price_quantity") - - /** - * The property used to group this price on an invoice - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun invoiceGroupingKey(): String? = - invoiceGroupingKey.getNullable("invoice_grouping_key") - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. If - * unspecified, a single invoice is produced per billing cycle. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by - * setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun metadata(): Metadata? = metadata.getNullable("metadata") - - /** - * Returns the raw JSON value of [cadence]. - * - * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence - - /** - * Returns the raw JSON value of [currency]. - * - * Unlike [currency], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - - /** - * Returns the raw JSON value of [itemId]. - * - * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - /** - * Returns the raw JSON value of [minimumConfig]. - * - * Unlike [minimumConfig], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("minimum_config") - @ExcludeMissing - fun _minimumConfig(): JsonField = minimumConfig - - /** - * Returns the raw JSON value of [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - /** - * Returns the raw JSON value of [billableMetricId]. - * - * Unlike [billableMetricId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = billableMetricId - - /** - * Returns the raw JSON value of [billedInAdvance]. - * - * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance - - /** - * Returns the raw JSON value of [billingCycleConfiguration]. - * - * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** - * Returns the raw JSON value of [conversionRate]. - * - * Unlike [conversionRate], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** - * Returns the raw JSON value of [conversionRateConfig]. - * - * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("conversion_rate_config") - @ExcludeMissing - fun _conversionRateConfig(): JsonField = conversionRateConfig - - /** - * Returns the raw JSON value of [dimensionalPriceConfiguration]. - * - * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("dimensional_price_configuration") - @ExcludeMissing - fun _dimensionalPriceConfiguration(): JsonField = - dimensionalPriceConfiguration - - /** - * Returns the raw JSON value of [externalPriceId]. - * - * Unlike [externalPriceId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * Returns the raw JSON value of [fixedPriceQuantity]. - * - * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** - * Returns the raw JSON value of [invoiceGroupingKey]. - * - * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Returns the raw JSON value of [invoicingCycleConfiguration]. - * - * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * Returns the raw JSON value of [metadata]. - * - * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [Minimum]. - * - * The following fields are required: - * ```kotlin - * .cadence() - * .currency() - * .itemId() - * .minimumConfig() - * .name() - * ``` - */ - fun builder() = Builder() - } - - /** A builder for [Minimum]. */ - class Builder internal constructor() { - - private var cadence: JsonField? = null - private var currency: JsonField? = null - private var itemId: JsonField? = null - private var minimumConfig: JsonField? = null - private var modelType: JsonValue = JsonValue.from("minimum") - private var name: JsonField? = null - private var billableMetricId: JsonField = JsonMissing.of() - private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var conversionRateConfig: JsonField = JsonMissing.of() - private var dimensionalPriceConfiguration: - JsonField = - JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(minimum: Minimum) = apply { - cadence = minimum.cadence - currency = minimum.currency - itemId = minimum.itemId - minimumConfig = minimum.minimumConfig - modelType = minimum.modelType - name = minimum.name - billableMetricId = minimum.billableMetricId - billedInAdvance = minimum.billedInAdvance - billingCycleConfiguration = minimum.billingCycleConfiguration - conversionRate = minimum.conversionRate - conversionRateConfig = minimum.conversionRateConfig - dimensionalPriceConfiguration = minimum.dimensionalPriceConfiguration - externalPriceId = minimum.externalPriceId - fixedPriceQuantity = minimum.fixedPriceQuantity - invoiceGroupingKey = minimum.invoiceGroupingKey - invoicingCycleConfiguration = minimum.invoicingCycleConfiguration - metadata = minimum.metadata - additionalProperties = minimum.additionalProperties.toMutableMap() - } - - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** - * Sets [Builder.cadence] to an arbitrary JSON value. - * - * You should usually call [Builder.cadence] with a well-typed [Cadence] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - - /** An ISO 4217 currency string for which this price is billed in. */ - fun currency(currency: String) = currency(JsonField.of(currency)) - - /** - * Sets [Builder.currency] to an arbitrary JSON value. - * - * You should usually call [Builder.currency] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } - - /** The id of the item the price will be associated with. */ - fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - - /** - * Sets [Builder.itemId] to an arbitrary JSON value. - * - * You should usually call [Builder.itemId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - fun minimumConfig(minimumConfig: MinimumConfig) = - minimumConfig(JsonField.of(minimumConfig)) - - /** - * Sets [Builder.minimumConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.minimumConfig] with a well-typed [MinimumConfig] - * value instead. This method is primarily for setting the field to an undocumented - * or not yet supported value. - */ - fun minimumConfig(minimumConfig: JsonField) = apply { - this.minimumConfig = minimumConfig - } - - /** - * Sets the field to an arbitrary JSON value. - * - * It is usually unnecessary to call this method because the field defaults to the - * following: - * ```kotlin - * JsonValue.from("minimum") - * ``` - * - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } - - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) - - /** - * Sets [Builder.name] to an arbitrary JSON value. - * - * You should usually call [Builder.name] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun name(name: JsonField) = apply { this.name = name } - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: String?) = - billableMetricId(JsonField.ofNullable(billableMetricId)) - - /** - * Sets [Builder.billableMetricId] to an arbitrary JSON value. - * - * You should usually call [Builder.billableMetricId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an undocumented - * or not yet supported value. - */ - fun billableMetricId(billableMetricId: JsonField) = apply { - this.billableMetricId = billableMetricId - } - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - */ - fun billedInAdvance(billedInAdvance: Boolean?) = - billedInAdvance(JsonField.ofNullable(billedInAdvance)) - - /** - * Alias for [Builder.billedInAdvance]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun billedInAdvance(billedInAdvance: Boolean) = - billedInAdvance(billedInAdvance as Boolean?) - - /** - * Sets [Builder.billedInAdvance] to an arbitrary JSON value. - * - * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] - * value instead. This method is primarily for setting the field to an undocumented - * or not yet supported value. - */ - fun billedInAdvance(billedInAdvance: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: NewBillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - - /** - * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.billingCycleConfiguration] with a well-typed - * [NewBillingCycleConfiguration] value instead. This method is primarily for - * setting the field to an undocumented or not yet supported value. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: JsonField - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double?) = - conversionRate(JsonField.ofNullable(conversionRate)) - - /** - * Alias for [Builder.conversionRate]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) - - /** - * Sets [Builder.conversionRate] to an arbitrary JSON value. - * - * You should usually call [Builder.conversionRate] with a well-typed [Double] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** - * The configuration for the rate of the price currency to the invoicing currency. - */ - fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = - conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) - - /** - * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.conversionRateConfig] with a well-typed - * [ConversionRateConfig] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun conversionRateConfig(conversionRateConfig: JsonField) = - apply { - this.conversionRateConfig = conversionRateConfig - } - - /** - * Alias for calling [conversionRateConfig] with - * `ConversionRateConfig.ofUnit(unit)`. - */ - fun conversionRateConfig(unit: UnitConversionRateConfig) = - conversionRateConfig(ConversionRateConfig.ofUnit(unit)) - - /** - * Alias for calling [conversionRateConfig] with the following: - * ```kotlin - * UnitConversionRateConfig.builder() - * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) - * .unitConfig(unitConfig) - * .build() - * ``` - */ - fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = - conversionRateConfig( - UnitConversionRateConfig.builder() - .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) - .unitConfig(unitConfig) - .build() - ) - - /** - * Alias for calling [conversionRateConfig] with - * `ConversionRateConfig.ofTiered(tiered)`. - */ - fun conversionRateConfig(tiered: TieredConversionRateConfig) = - conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) - - /** - * Alias for calling [conversionRateConfig] with the following: - * ```kotlin - * TieredConversionRateConfig.builder() - * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) - * .tieredConfig(tieredConfig) - * .build() - * ``` - */ - fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = - conversionRateConfig( - TieredConversionRateConfig.builder() - .conversionRateType( - TieredConversionRateConfig.ConversionRateType.TIERED - ) - .tieredConfig(tieredConfig) - .build() - ) - - /** For dimensional price: specifies a price group and dimension values */ - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? - ) = - dimensionalPriceConfiguration( - JsonField.ofNullable(dimensionalPriceConfiguration) - ) - - /** - * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.dimensionalPriceConfiguration] with a well-typed - * [NewDimensionalPriceConfiguration] value instead. This method is primarily for - * setting the field to an undocumented or not yet supported value. - */ - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: JsonField - ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** - * Sets [Builder.externalPriceId] to an arbitrary JSON value. - * - * You should usually call [Builder.externalPriceId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an undocumented - * or not yet supported value. - */ - fun externalPriceId(externalPriceId: JsonField) = apply { - this.externalPriceId = externalPriceId - } - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = - fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) - - /** - * Alias for [Builder.fixedPriceQuantity]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. - * - * You should usually call [Builder.fixedPriceQuantity] with a well-typed [Double] - * value instead. This method is primarily for setting the field to an undocumented - * or not yet supported value. - */ - fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = - invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) - - /** - * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. - * - * You should usually call [Builder.invoiceGroupingKey] with a well-typed [String] - * value instead. This method is primarily for setting the field to an undocumented - * or not yet supported value. - */ - fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { - this.invoiceGroupingKey = invoiceGroupingKey - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: NewBillingCycleConfiguration? - ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) - - /** - * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.invoicingCycleConfiguration] with a well-typed - * [NewBillingCycleConfiguration] value instead. This method is primarily for - * setting the field to an undocumented or not yet supported value. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * Sets [Builder.metadata] to an arbitrary JSON value. - * - * You should usually call [Builder.metadata] with a well-typed [Metadata] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Minimum]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```kotlin - * .cadence() - * .currency() - * .itemId() - * .minimumConfig() - * .name() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Minimum = - Minimum( - checkRequired("cadence", cadence), - checkRequired("currency", currency), - checkRequired("itemId", itemId), - checkRequired("minimumConfig", minimumConfig), - modelType, - checkRequired("name", name), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - conversionRateConfig, - dimensionalPriceConfiguration, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Minimum = apply { - if (validated) { - return@apply - } - - cadence().validate() - currency() - itemId() - minimumConfig().validate() - _modelType().let { - if (it != JsonValue.from("minimum")) { - throw OrbInvalidDataException("'modelType' is invalid, received $it") - } - } - name() - billableMetricId() - billedInAdvance() - billingCycleConfiguration()?.validate() - conversionRate() - conversionRateConfig()?.validate() - dimensionalPriceConfiguration()?.validate() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration()?.validate() - metadata()?.validate() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (cadence.asKnown()?.validity() ?: 0) + - (if (currency.asKnown() == null) 0 else 1) + - (if (itemId.asKnown() == null) 0 else 1) + - (minimumConfig.asKnown()?.validity() ?: 0) + - modelType.let { if (it == JsonValue.from("minimum")) 1 else 0 } + - (if (name.asKnown() == null) 0 else 1) + - (if (billableMetricId.asKnown() == null) 0 else 1) + - (if (billedInAdvance.asKnown() == null) 0 else 1) + - (billingCycleConfiguration.asKnown()?.validity() ?: 0) + - (if (conversionRate.asKnown() == null) 0 else 1) + - (conversionRateConfig.asKnown()?.validity() ?: 0) + - (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + - (if (externalPriceId.asKnown() == null) 0 else 1) + - (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + - (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + - (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + - (metadata.asKnown()?.validity() ?: 0) - - /** The cadence to bill for this price on. */ - class Cadence @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - val ANNUAL = of("annual") - - val SEMI_ANNUAL = of("semi_annual") - - val MONTHLY = of("monthly") - - val QUARTERLY = of("quarterly") - - val ONE_TIME = of("one_time") - - val CUSTOM = of("custom") - - fun of(value: String) = Cadence(JsonField.of(value)) - } - - /** An enum containing [Cadence]'s known values. */ - enum class Known { - ANNUAL, - SEMI_ANNUAL, - MONTHLY, - QUARTERLY, - ONE_TIME, - CUSTOM, - } - - /** - * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Cadence] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - ANNUAL, - SEMI_ANNUAL, - MONTHLY, - QUARTERLY, - ONE_TIME, - CUSTOM, - /** - * An enum member indicating that [Cadence] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - ANNUAL -> Value.ANNUAL - SEMI_ANNUAL -> Value.SEMI_ANNUAL - MONTHLY -> Value.MONTHLY - QUARTERLY -> Value.QUARTERLY - ONE_TIME -> Value.ONE_TIME - CUSTOM -> Value.CUSTOM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - ANNUAL -> Known.ANNUAL - SEMI_ANNUAL -> Known.SEMI_ANNUAL - MONTHLY -> Known.MONTHLY - QUARTERLY -> Known.QUARTERLY - ONE_TIME -> Known.ONE_TIME - CUSTOM -> Known.CUSTOM - else -> throw OrbInvalidDataException("Unknown Cadence: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString() ?: throw OrbInvalidDataException("Value is not a String") - - private var validated: Boolean = false - - fun validate(): Cadence = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Cadence && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class MinimumConfig - private constructor( - private val minimumAmount: JsonField, - private val prorated: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("minimum_amount") - @ExcludeMissing - minimumAmount: JsonField = JsonMissing.of(), - @JsonProperty("prorated") - @ExcludeMissing - prorated: JsonField = JsonMissing.of(), - ) : this(minimumAmount, prorated, mutableMapOf()) - - /** - * The minimum amount to apply - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") - - /** - * By default, subtotals from minimum composite prices are prorated based on the - * service period. Set to false to disable proration. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun prorated(): Boolean? = prorated.getNullable("prorated") - - /** - * Returns the raw JSON value of [minimumAmount]. - * - * Unlike [minimumAmount], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("minimum_amount") - @ExcludeMissing - fun _minimumAmount(): JsonField = minimumAmount - - /** - * Returns the raw JSON value of [prorated]. - * - * Unlike [prorated], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("prorated") - @ExcludeMissing - fun _prorated(): JsonField = prorated - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [MinimumConfig]. - * - * The following fields are required: - * ```kotlin - * .minimumAmount() - * ``` - */ - fun builder() = Builder() - } - - /** A builder for [MinimumConfig]. */ - class Builder internal constructor() { - - private var minimumAmount: JsonField? = null - private var prorated: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(minimumConfig: MinimumConfig) = apply { - minimumAmount = minimumConfig.minimumAmount - prorated = minimumConfig.prorated - additionalProperties = minimumConfig.additionalProperties.toMutableMap() - } - - /** The minimum amount to apply */ - fun minimumAmount(minimumAmount: String) = - minimumAmount(JsonField.of(minimumAmount)) - - /** - * Sets [Builder.minimumAmount] to an arbitrary JSON value. - * - * You should usually call [Builder.minimumAmount] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun minimumAmount(minimumAmount: JsonField) = apply { - this.minimumAmount = minimumAmount - } - - /** - * By default, subtotals from minimum composite prices are prorated based on the - * service period. Set to false to disable proration. - */ - fun prorated(prorated: Boolean?) = prorated(JsonField.ofNullable(prorated)) - - /** - * Alias for [Builder.prorated]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun prorated(prorated: Boolean) = prorated(prorated as Boolean?) - - /** - * Sets [Builder.prorated] to an arbitrary JSON value. - * - * You should usually call [Builder.prorated] with a well-typed [Boolean] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun prorated(prorated: JsonField) = apply { this.prorated = prorated } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [MinimumConfig]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```kotlin - * .minimumAmount() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): MinimumConfig = - MinimumConfig( - checkRequired("minimumAmount", minimumAmount), - prorated, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): MinimumConfig = apply { - if (validated) { - return@apply - } - - minimumAmount() - prorated() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (if (minimumAmount.asKnown() == null) 0 else 1) + - (if (prorated.asKnown() == null) 0 else 1) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is MinimumConfig && - minimumAmount == other.minimumAmount && - prorated == other.prorated && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(minimumAmount, prorated, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "MinimumConfig{minimumAmount=$minimumAmount, prorated=$prorated, additionalProperties=$additionalProperties}" - } - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by - * setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - class Metadata - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Metadata]. */ - fun builder() = Builder() - } - - /** A builder for [Metadata]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(metadata: Metadata) = apply { - additionalProperties = metadata.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Metadata]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - additionalProperties.count { (_, value) -> - !value.isNull() && !value.isMissing() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Metadata && additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Minimum && - cadence == other.cadence && - currency == other.currency && - itemId == other.itemId && - minimumConfig == other.minimumConfig && - modelType == other.modelType && - name == other.name && - billableMetricId == other.billableMetricId && - billedInAdvance == other.billedInAdvance && - billingCycleConfiguration == other.billingCycleConfiguration && - conversionRate == other.conversionRate && - conversionRateConfig == other.conversionRateConfig && - dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && - externalPriceId == other.externalPriceId && - fixedPriceQuantity == other.fixedPriceQuantity && - invoiceGroupingKey == other.invoiceGroupingKey && - invoicingCycleConfiguration == other.invoicingCycleConfiguration && - metadata == other.metadata && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - cadence, - currency, - itemId, - minimumConfig, - modelType, - name, - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - conversionRateConfig, - dimensionalPriceConfiguration, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Minimum{cadence=$cadence, currency=$currency, itemId=$itemId, minimumConfig=$minimumConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" - } } override fun equals(other: Any?): Boolean { diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceEvaluateMultipleParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceEvaluateMultipleParams.kt index 3541d4657..38520ec04 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceEvaluateMultipleParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceEvaluateMultipleParams.kt @@ -1145,7 +1145,7 @@ private constructor( price(Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)) /** Alias for calling [price] with `Price.ofMinimum(minimum)`. */ - fun price(minimum: Price.Minimum) = price(Price.ofMinimum(minimum)) + fun price(minimum: NewFloatingMinimumCompositePrice) = price(Price.ofMinimum(minimum)) /** The ID of a price to evaluate that exists in your Orb account. */ fun priceId(priceId: String?) = priceId(JsonField.ofNullable(priceId)) @@ -1270,7 +1270,7 @@ private constructor( null, private val cumulativeGroupedBulk: NewFloatingCumulativeGroupedBulkPrice? = null, private val groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds? = null, - private val minimum: Minimum? = null, + private val minimum: NewFloatingMinimumCompositePrice? = null, private val _json: JsonValue? = null, ) { @@ -1336,7 +1336,7 @@ private constructor( fun groupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds? = groupedWithMinMaxThresholds - fun minimum(): Minimum? = minimum + fun minimum(): NewFloatingMinimumCompositePrice? = minimum fun isUnit(): Boolean = unit != null @@ -1467,7 +1467,7 @@ private constructor( fun asGroupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds = groupedWithMinMaxThresholds.getOrThrow("groupedWithMinMaxThresholds") - fun asMinimum(): Minimum = minimum.getOrThrow("minimum") + fun asMinimum(): NewFloatingMinimumCompositePrice = minimum.getOrThrow("minimum") fun _json(): JsonValue? = _json @@ -1676,7 +1676,7 @@ private constructor( groupedWithMinMaxThresholds.validate() } - override fun visitMinimum(minimum: Minimum) { + override fun visitMinimum(minimum: NewFloatingMinimumCompositePrice) { minimum.validate() } } @@ -1798,7 +1798,8 @@ private constructor( groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds ) = groupedWithMinMaxThresholds.validity() - override fun visitMinimum(minimum: Minimum) = minimum.validity() + override fun visitMinimum(minimum: NewFloatingMinimumCompositePrice) = + minimum.validity() override fun unknown(json: JsonValue?) = 0 } @@ -2005,7 +2006,7 @@ private constructor( groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds ) = Price(groupedWithMinMaxThresholds = groupedWithMinMaxThresholds) - fun ofMinimum(minimum: Minimum) = Price(minimum = minimum) + fun ofMinimum(minimum: NewFloatingMinimumCompositePrice) = Price(minimum = minimum) } /** @@ -2093,7 +2094,7 @@ private constructor( groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds ): T - fun visitMinimum(minimum: Minimum): T + fun visitMinimum(minimum: NewFloatingMinimumCompositePrice): T /** * Maps an unknown variant of [Price] to a value of type [T]. @@ -2308,9 +2309,11 @@ private constructor( ?: Price(_json = json) } "minimum" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(minimum = it, _json = json) - } ?: Price(_json = json) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(minimum = it, _json = json) } ?: Price(_json = json) } } @@ -3808,1520 +3811,6 @@ private constructor( override fun toString() = "GroupedWithMinMaxThresholds{cadence=$cadence, currency=$currency, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" } - - class Minimum - private constructor( - private val cadence: JsonField, - private val currency: JsonField, - private val itemId: JsonField, - private val minimumConfig: JsonField, - private val modelType: JsonValue, - private val name: JsonField, - private val billableMetricId: JsonField, - private val billedInAdvance: JsonField, - private val billingCycleConfiguration: JsonField, - private val conversionRate: JsonField, - private val conversionRateConfig: JsonField, - private val dimensionalPriceConfiguration: - JsonField, - private val externalPriceId: JsonField, - private val fixedPriceQuantity: JsonField, - private val invoiceGroupingKey: JsonField, - private val invoicingCycleConfiguration: JsonField, - private val metadata: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("cadence") - @ExcludeMissing - cadence: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - currency: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - itemId: JsonField = JsonMissing.of(), - @JsonProperty("minimum_config") - @ExcludeMissing - minimumConfig: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - modelType: JsonValue = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - name: JsonField = JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("conversion_rate_config") - @ExcludeMissing - conversionRateConfig: JsonField = JsonMissing.of(), - @JsonProperty("dimensional_price_configuration") - @ExcludeMissing - dimensionalPriceConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - metadata: JsonField = JsonMissing.of(), - ) : this( - cadence, - currency, - itemId, - minimumConfig, - modelType, - name, - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - conversionRateConfig, - dimensionalPriceConfiguration, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - mutableMapOf(), - ) - - /** - * The cadence to bill for this price on. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - /** - * An ISO 4217 currency string for which this price is billed in. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun currency(): String = currency.getRequired("currency") - - /** - * The id of the item the price will be associated with. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun itemId(): String = itemId.getRequired("item_id") - - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun minimumConfig(): MinimumConfig = minimumConfig.getRequired("minimum_config") - - /** - * Expected to always return the following: - * ```kotlin - * JsonValue.from("minimum") - * ``` - * - * However, this method can be useful for debugging and logging (e.g. if the server - * responded with an unexpected value). - */ - @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType - - /** - * The name of the price. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun name(): String = name.getRequired("name") - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun billableMetricId(): String? = billableMetricId.getNullable("billable_metric_id") - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun billingCycleConfiguration(): NewBillingCycleConfiguration? = - billingCycleConfiguration.getNullable("billing_cycle_configuration") - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") - - /** - * The configuration for the rate of the price currency to the invoicing currency. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun conversionRateConfig(): ConversionRateConfig? = - conversionRateConfig.getNullable("conversion_rate_config") - - /** - * For dimensional price: specifies a price group and dimension values - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = - dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") - - /** - * An alias for the price. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun fixedPriceQuantity(): Double? = - fixedPriceQuantity.getNullable("fixed_price_quantity") - - /** - * The property used to group this price on an invoice - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun invoiceGroupingKey(): String? = - invoiceGroupingKey.getNullable("invoice_grouping_key") - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun metadata(): Metadata? = metadata.getNullable("metadata") - - /** - * Returns the raw JSON value of [cadence]. - * - * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("cadence") - @ExcludeMissing - fun _cadence(): JsonField = cadence - - /** - * Returns the raw JSON value of [currency]. - * - * Unlike [currency], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("currency") - @ExcludeMissing - fun _currency(): JsonField = currency - - /** - * Returns the raw JSON value of [itemId]. - * - * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - /** - * Returns the raw JSON value of [minimumConfig]. - * - * Unlike [minimumConfig], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("minimum_config") - @ExcludeMissing - fun _minimumConfig(): JsonField = minimumConfig - - /** - * Returns the raw JSON value of [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - /** - * Returns the raw JSON value of [billableMetricId]. - * - * Unlike [billableMetricId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = billableMetricId - - /** - * Returns the raw JSON value of [billedInAdvance]. - * - * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance - - /** - * Returns the raw JSON value of [billingCycleConfiguration]. - * - * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** - * Returns the raw JSON value of [conversionRate]. - * - * Unlike [conversionRate], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** - * Returns the raw JSON value of [conversionRateConfig]. - * - * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("conversion_rate_config") - @ExcludeMissing - fun _conversionRateConfig(): JsonField = conversionRateConfig - - /** - * Returns the raw JSON value of [dimensionalPriceConfiguration]. - * - * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON - * field has an unexpected type. - */ - @JsonProperty("dimensional_price_configuration") - @ExcludeMissing - fun _dimensionalPriceConfiguration(): JsonField = - dimensionalPriceConfiguration - - /** - * Returns the raw JSON value of [externalPriceId]. - * - * Unlike [externalPriceId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * Returns the raw JSON value of [fixedPriceQuantity]. - * - * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** - * Returns the raw JSON value of [invoiceGroupingKey]. - * - * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Returns the raw JSON value of [invoicingCycleConfiguration]. - * - * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * Returns the raw JSON value of [metadata]. - * - * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [Minimum]. - * - * The following fields are required: - * ```kotlin - * .cadence() - * .currency() - * .itemId() - * .minimumConfig() - * .name() - * ``` - */ - fun builder() = Builder() - } - - /** A builder for [Minimum]. */ - class Builder internal constructor() { - - private var cadence: JsonField? = null - private var currency: JsonField? = null - private var itemId: JsonField? = null - private var minimumConfig: JsonField? = null - private var modelType: JsonValue = JsonValue.from("minimum") - private var name: JsonField? = null - private var billableMetricId: JsonField = JsonMissing.of() - private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var conversionRateConfig: JsonField = - JsonMissing.of() - private var dimensionalPriceConfiguration: - JsonField = - JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: - JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(minimum: Minimum) = apply { - cadence = minimum.cadence - currency = minimum.currency - itemId = minimum.itemId - minimumConfig = minimum.minimumConfig - modelType = minimum.modelType - name = minimum.name - billableMetricId = minimum.billableMetricId - billedInAdvance = minimum.billedInAdvance - billingCycleConfiguration = minimum.billingCycleConfiguration - conversionRate = minimum.conversionRate - conversionRateConfig = minimum.conversionRateConfig - dimensionalPriceConfiguration = minimum.dimensionalPriceConfiguration - externalPriceId = minimum.externalPriceId - fixedPriceQuantity = minimum.fixedPriceQuantity - invoiceGroupingKey = minimum.invoiceGroupingKey - invoicingCycleConfiguration = minimum.invoicingCycleConfiguration - metadata = minimum.metadata - additionalProperties = minimum.additionalProperties.toMutableMap() - } - - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** - * Sets [Builder.cadence] to an arbitrary JSON value. - * - * You should usually call [Builder.cadence] with a well-typed [Cadence] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - - /** An ISO 4217 currency string for which this price is billed in. */ - fun currency(currency: String) = currency(JsonField.of(currency)) - - /** - * Sets [Builder.currency] to an arbitrary JSON value. - * - * You should usually call [Builder.currency] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } - - /** The id of the item the price will be associated with. */ - fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - - /** - * Sets [Builder.itemId] to an arbitrary JSON value. - * - * You should usually call [Builder.itemId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - fun minimumConfig(minimumConfig: MinimumConfig) = - minimumConfig(JsonField.of(minimumConfig)) - - /** - * Sets [Builder.minimumConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.minimumConfig] with a well-typed - * [MinimumConfig] value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. - */ - fun minimumConfig(minimumConfig: JsonField) = apply { - this.minimumConfig = minimumConfig - } - - /** - * Sets the field to an arbitrary JSON value. - * - * It is usually unnecessary to call this method because the field defaults to - * the following: - * ```kotlin - * JsonValue.from("minimum") - * ``` - * - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } - - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) - - /** - * Sets [Builder.name] to an arbitrary JSON value. - * - * You should usually call [Builder.name] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun name(name: JsonField) = apply { this.name = name } - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: String?) = - billableMetricId(JsonField.ofNullable(billableMetricId)) - - /** - * Sets [Builder.billableMetricId] to an arbitrary JSON value. - * - * You should usually call [Builder.billableMetricId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun billableMetricId(billableMetricId: JsonField) = apply { - this.billableMetricId = billableMetricId - } - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if - * this is true, and in-arrears if this is false. - */ - fun billedInAdvance(billedInAdvance: Boolean?) = - billedInAdvance(JsonField.ofNullable(billedInAdvance)) - - /** - * Alias for [Builder.billedInAdvance]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun billedInAdvance(billedInAdvance: Boolean) = - billedInAdvance(billedInAdvance as Boolean?) - - /** - * Sets [Builder.billedInAdvance] to an arbitrary JSON value. - * - * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun billedInAdvance(billedInAdvance: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: NewBillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - - /** - * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.billingCycleConfiguration] with a well-typed - * [NewBillingCycleConfiguration] value instead. This method is primarily for - * setting the field to an undocumented or not yet supported value. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: JsonField - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: Double?) = - conversionRate(JsonField.ofNullable(conversionRate)) - - /** - * Alias for [Builder.conversionRate]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) - - /** - * Sets [Builder.conversionRate] to an arbitrary JSON value. - * - * You should usually call [Builder.conversionRate] with a well-typed [Double] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** - * The configuration for the rate of the price currency to the invoicing - * currency. - */ - fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = - conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) - - /** - * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.conversionRateConfig] with a well-typed - * [ConversionRateConfig] value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun conversionRateConfig( - conversionRateConfig: JsonField - ) = apply { this.conversionRateConfig = conversionRateConfig } - - /** - * Alias for calling [conversionRateConfig] with - * `ConversionRateConfig.ofUnit(unit)`. - */ - fun conversionRateConfig(unit: UnitConversionRateConfig) = - conversionRateConfig(ConversionRateConfig.ofUnit(unit)) - - /** - * Alias for calling [conversionRateConfig] with the following: - * ```kotlin - * UnitConversionRateConfig.builder() - * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) - * .unitConfig(unitConfig) - * .build() - * ``` - */ - fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = - conversionRateConfig( - UnitConversionRateConfig.builder() - .conversionRateType( - UnitConversionRateConfig.ConversionRateType.UNIT - ) - .unitConfig(unitConfig) - .build() - ) - - /** - * Alias for calling [conversionRateConfig] with - * `ConversionRateConfig.ofTiered(tiered)`. - */ - fun conversionRateConfig(tiered: TieredConversionRateConfig) = - conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) - - /** - * Alias for calling [conversionRateConfig] with the following: - * ```kotlin - * TieredConversionRateConfig.builder() - * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) - * .tieredConfig(tieredConfig) - * .build() - * ``` - */ - fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = - conversionRateConfig( - TieredConversionRateConfig.builder() - .conversionRateType( - TieredConversionRateConfig.ConversionRateType.TIERED - ) - .tieredConfig(tieredConfig) - .build() - ) - - /** For dimensional price: specifies a price group and dimension values */ - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? - ) = - dimensionalPriceConfiguration( - JsonField.ofNullable(dimensionalPriceConfiguration) - ) - - /** - * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.dimensionalPriceConfiguration] with a - * well-typed [NewDimensionalPriceConfiguration] value instead. This method is - * primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: JsonField - ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** - * Sets [Builder.externalPriceId] to an arbitrary JSON value. - * - * You should usually call [Builder.externalPriceId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun externalPriceId(externalPriceId: JsonField) = apply { - this.externalPriceId = externalPriceId - } - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = - fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) - - /** - * Alias for [Builder.fixedPriceQuantity]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. - * - * You should usually call [Builder.fixedPriceQuantity] with a well-typed - * [Double] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = - invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) - - /** - * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. - * - * You should usually call [Builder.invoiceGroupingKey] with a well-typed - * [String] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { - this.invoiceGroupingKey = invoiceGroupingKey - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are - * produced. If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: NewBillingCycleConfiguration? - ) = - invoicingCycleConfiguration( - JsonField.ofNullable(invoicingCycleConfiguration) - ) - - /** - * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.invoicingCycleConfiguration] with a - * well-typed [NewBillingCycleConfiguration] value instead. This method is - * primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * Sets [Builder.metadata] to an arbitrary JSON value. - * - * You should usually call [Builder.metadata] with a well-typed [Metadata] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Minimum]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```kotlin - * .cadence() - * .currency() - * .itemId() - * .minimumConfig() - * .name() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Minimum = - Minimum( - checkRequired("cadence", cadence), - checkRequired("currency", currency), - checkRequired("itemId", itemId), - checkRequired("minimumConfig", minimumConfig), - modelType, - checkRequired("name", name), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - conversionRateConfig, - dimensionalPriceConfiguration, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Minimum = apply { - if (validated) { - return@apply - } - - cadence().validate() - currency() - itemId() - minimumConfig().validate() - _modelType().let { - if (it != JsonValue.from("minimum")) { - throw OrbInvalidDataException("'modelType' is invalid, received $it") - } - } - name() - billableMetricId() - billedInAdvance() - billingCycleConfiguration()?.validate() - conversionRate() - conversionRateConfig()?.validate() - dimensionalPriceConfiguration()?.validate() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration()?.validate() - metadata()?.validate() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (cadence.asKnown()?.validity() ?: 0) + - (if (currency.asKnown() == null) 0 else 1) + - (if (itemId.asKnown() == null) 0 else 1) + - (minimumConfig.asKnown()?.validity() ?: 0) + - modelType.let { if (it == JsonValue.from("minimum")) 1 else 0 } + - (if (name.asKnown() == null) 0 else 1) + - (if (billableMetricId.asKnown() == null) 0 else 1) + - (if (billedInAdvance.asKnown() == null) 0 else 1) + - (billingCycleConfiguration.asKnown()?.validity() ?: 0) + - (if (conversionRate.asKnown() == null) 0 else 1) + - (conversionRateConfig.asKnown()?.validity() ?: 0) + - (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + - (if (externalPriceId.asKnown() == null) 0 else 1) + - (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + - (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + - (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + - (metadata.asKnown()?.validity() ?: 0) - - /** The cadence to bill for this price on. */ - class Cadence - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - val ANNUAL = of("annual") - - val SEMI_ANNUAL = of("semi_annual") - - val MONTHLY = of("monthly") - - val QUARTERLY = of("quarterly") - - val ONE_TIME = of("one_time") - - val CUSTOM = of("custom") - - fun of(value: String) = Cadence(JsonField.of(value)) - } - - /** An enum containing [Cadence]'s known values. */ - enum class Known { - ANNUAL, - SEMI_ANNUAL, - MONTHLY, - QUARTERLY, - ONE_TIME, - CUSTOM, - } - - /** - * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Cadence] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - ANNUAL, - SEMI_ANNUAL, - MONTHLY, - QUARTERLY, - ONE_TIME, - CUSTOM, - /** - * An enum member indicating that [Cadence] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - ANNUAL -> Value.ANNUAL - SEMI_ANNUAL -> Value.SEMI_ANNUAL - MONTHLY -> Value.MONTHLY - QUARTERLY -> Value.QUARTERLY - ONE_TIME -> Value.ONE_TIME - CUSTOM -> Value.CUSTOM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - ANNUAL -> Known.ANNUAL - SEMI_ANNUAL -> Known.SEMI_ANNUAL - MONTHLY -> Known.MONTHLY - QUARTERLY -> Known.QUARTERLY - ONE_TIME -> Known.ONE_TIME - CUSTOM -> Known.CUSTOM - else -> throw OrbInvalidDataException("Unknown Cadence: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString() - ?: throw OrbInvalidDataException("Value is not a String") - - private var validated: Boolean = false - - fun validate(): Cadence = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Cadence && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class MinimumConfig - private constructor( - private val minimumAmount: JsonField, - private val prorated: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("minimum_amount") - @ExcludeMissing - minimumAmount: JsonField = JsonMissing.of(), - @JsonProperty("prorated") - @ExcludeMissing - prorated: JsonField = JsonMissing.of(), - ) : this(minimumAmount, prorated, mutableMapOf()) - - /** - * The minimum amount to apply - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") - - /** - * By default, subtotals from minimum composite prices are prorated based on the - * service period. Set to false to disable proration. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun prorated(): Boolean? = prorated.getNullable("prorated") - - /** - * Returns the raw JSON value of [minimumAmount]. - * - * Unlike [minimumAmount], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("minimum_amount") - @ExcludeMissing - fun _minimumAmount(): JsonField = minimumAmount - - /** - * Returns the raw JSON value of [prorated]. - * - * Unlike [prorated], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("prorated") - @ExcludeMissing - fun _prorated(): JsonField = prorated - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [MinimumConfig]. - * - * The following fields are required: - * ```kotlin - * .minimumAmount() - * ``` - */ - fun builder() = Builder() - } - - /** A builder for [MinimumConfig]. */ - class Builder internal constructor() { - - private var minimumAmount: JsonField? = null - private var prorated: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - internal fun from(minimumConfig: MinimumConfig) = apply { - minimumAmount = minimumConfig.minimumAmount - prorated = minimumConfig.prorated - additionalProperties = minimumConfig.additionalProperties.toMutableMap() - } - - /** The minimum amount to apply */ - fun minimumAmount(minimumAmount: String) = - minimumAmount(JsonField.of(minimumAmount)) - - /** - * Sets [Builder.minimumAmount] to an arbitrary JSON value. - * - * You should usually call [Builder.minimumAmount] with a well-typed - * [String] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun minimumAmount(minimumAmount: JsonField) = apply { - this.minimumAmount = minimumAmount - } - - /** - * By default, subtotals from minimum composite prices are prorated based on - * the service period. Set to false to disable proration. - */ - fun prorated(prorated: Boolean?) = prorated(JsonField.ofNullable(prorated)) - - /** - * Alias for [Builder.prorated]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun prorated(prorated: Boolean) = prorated(prorated as Boolean?) - - /** - * Sets [Builder.prorated] to an arbitrary JSON value. - * - * You should usually call [Builder.prorated] with a well-typed [Boolean] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun prorated(prorated: JsonField) = apply { - this.prorated = prorated - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [MinimumConfig]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```kotlin - * .minimumAmount() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): MinimumConfig = - MinimumConfig( - checkRequired("minimumAmount", minimumAmount), - prorated, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): MinimumConfig = apply { - if (validated) { - return@apply - } - - minimumAmount() - prorated() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (if (minimumAmount.asKnown() == null) 0 else 1) + - (if (prorated.asKnown() == null) 0 else 1) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is MinimumConfig && - minimumAmount == other.minimumAmount && - prorated == other.prorated && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(minimumAmount, prorated, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "MinimumConfig{minimumAmount=$minimumAmount, prorated=$prorated, additionalProperties=$additionalProperties}" - } - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - class Metadata - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Metadata]. */ - fun builder() = Builder() - } - - /** A builder for [Metadata]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = - mutableMapOf() - - internal fun from(metadata: Metadata) = apply { - additionalProperties = metadata.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Metadata]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - additionalProperties.count { (_, value) -> - !value.isNull() && !value.isMissing() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Metadata && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Minimum && - cadence == other.cadence && - currency == other.currency && - itemId == other.itemId && - minimumConfig == other.minimumConfig && - modelType == other.modelType && - name == other.name && - billableMetricId == other.billableMetricId && - billedInAdvance == other.billedInAdvance && - billingCycleConfiguration == other.billingCycleConfiguration && - conversionRate == other.conversionRate && - conversionRateConfig == other.conversionRateConfig && - dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && - externalPriceId == other.externalPriceId && - fixedPriceQuantity == other.fixedPriceQuantity && - invoiceGroupingKey == other.invoiceGroupingKey && - invoicingCycleConfiguration == other.invoicingCycleConfiguration && - metadata == other.metadata && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - cadence, - currency, - itemId, - minimumConfig, - modelType, - name, - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - conversionRateConfig, - dimensionalPriceConfiguration, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Minimum{cadence=$cadence, currency=$currency, itemId=$itemId, minimumConfig=$minimumConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" - } } override fun equals(other: Any?): Boolean { diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceEvaluatePreviewEventsParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceEvaluatePreviewEventsParams.kt index bf51d9773..e611e8af1 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceEvaluatePreviewEventsParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceEvaluatePreviewEventsParams.kt @@ -1679,7 +1679,7 @@ private constructor( price(Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)) /** Alias for calling [price] with `Price.ofMinimum(minimum)`. */ - fun price(minimum: Price.Minimum) = price(Price.ofMinimum(minimum)) + fun price(minimum: NewFloatingMinimumCompositePrice) = price(Price.ofMinimum(minimum)) /** The ID of a price to evaluate that exists in your Orb account. */ fun priceId(priceId: String?) = priceId(JsonField.ofNullable(priceId)) @@ -1804,7 +1804,7 @@ private constructor( null, private val cumulativeGroupedBulk: NewFloatingCumulativeGroupedBulkPrice? = null, private val groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds? = null, - private val minimum: Minimum? = null, + private val minimum: NewFloatingMinimumCompositePrice? = null, private val _json: JsonValue? = null, ) { @@ -1870,7 +1870,7 @@ private constructor( fun groupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds? = groupedWithMinMaxThresholds - fun minimum(): Minimum? = minimum + fun minimum(): NewFloatingMinimumCompositePrice? = minimum fun isUnit(): Boolean = unit != null @@ -2001,7 +2001,7 @@ private constructor( fun asGroupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds = groupedWithMinMaxThresholds.getOrThrow("groupedWithMinMaxThresholds") - fun asMinimum(): Minimum = minimum.getOrThrow("minimum") + fun asMinimum(): NewFloatingMinimumCompositePrice = minimum.getOrThrow("minimum") fun _json(): JsonValue? = _json @@ -2210,7 +2210,7 @@ private constructor( groupedWithMinMaxThresholds.validate() } - override fun visitMinimum(minimum: Minimum) { + override fun visitMinimum(minimum: NewFloatingMinimumCompositePrice) { minimum.validate() } } @@ -2332,7 +2332,8 @@ private constructor( groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds ) = groupedWithMinMaxThresholds.validity() - override fun visitMinimum(minimum: Minimum) = minimum.validity() + override fun visitMinimum(minimum: NewFloatingMinimumCompositePrice) = + minimum.validity() override fun unknown(json: JsonValue?) = 0 } @@ -2539,7 +2540,7 @@ private constructor( groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds ) = Price(groupedWithMinMaxThresholds = groupedWithMinMaxThresholds) - fun ofMinimum(minimum: Minimum) = Price(minimum = minimum) + fun ofMinimum(minimum: NewFloatingMinimumCompositePrice) = Price(minimum = minimum) } /** @@ -2627,7 +2628,7 @@ private constructor( groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds ): T - fun visitMinimum(minimum: Minimum): T + fun visitMinimum(minimum: NewFloatingMinimumCompositePrice): T /** * Maps an unknown variant of [Price] to a value of type [T]. @@ -2842,9 +2843,11 @@ private constructor( ?: Price(_json = json) } "minimum" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(minimum = it, _json = json) - } ?: Price(_json = json) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(minimum = it, _json = json) } ?: Price(_json = json) } } @@ -4342,1520 +4345,6 @@ private constructor( override fun toString() = "GroupedWithMinMaxThresholds{cadence=$cadence, currency=$currency, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" } - - class Minimum - private constructor( - private val cadence: JsonField, - private val currency: JsonField, - private val itemId: JsonField, - private val minimumConfig: JsonField, - private val modelType: JsonValue, - private val name: JsonField, - private val billableMetricId: JsonField, - private val billedInAdvance: JsonField, - private val billingCycleConfiguration: JsonField, - private val conversionRate: JsonField, - private val conversionRateConfig: JsonField, - private val dimensionalPriceConfiguration: - JsonField, - private val externalPriceId: JsonField, - private val fixedPriceQuantity: JsonField, - private val invoiceGroupingKey: JsonField, - private val invoicingCycleConfiguration: JsonField, - private val metadata: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("cadence") - @ExcludeMissing - cadence: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - currency: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - itemId: JsonField = JsonMissing.of(), - @JsonProperty("minimum_config") - @ExcludeMissing - minimumConfig: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - modelType: JsonValue = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - name: JsonField = JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("conversion_rate_config") - @ExcludeMissing - conversionRateConfig: JsonField = JsonMissing.of(), - @JsonProperty("dimensional_price_configuration") - @ExcludeMissing - dimensionalPriceConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - metadata: JsonField = JsonMissing.of(), - ) : this( - cadence, - currency, - itemId, - minimumConfig, - modelType, - name, - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - conversionRateConfig, - dimensionalPriceConfiguration, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - mutableMapOf(), - ) - - /** - * The cadence to bill for this price on. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - /** - * An ISO 4217 currency string for which this price is billed in. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun currency(): String = currency.getRequired("currency") - - /** - * The id of the item the price will be associated with. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun itemId(): String = itemId.getRequired("item_id") - - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun minimumConfig(): MinimumConfig = minimumConfig.getRequired("minimum_config") - - /** - * Expected to always return the following: - * ```kotlin - * JsonValue.from("minimum") - * ``` - * - * However, this method can be useful for debugging and logging (e.g. if the server - * responded with an unexpected value). - */ - @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType - - /** - * The name of the price. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun name(): String = name.getRequired("name") - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun billableMetricId(): String? = billableMetricId.getNullable("billable_metric_id") - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun billingCycleConfiguration(): NewBillingCycleConfiguration? = - billingCycleConfiguration.getNullable("billing_cycle_configuration") - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") - - /** - * The configuration for the rate of the price currency to the invoicing currency. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun conversionRateConfig(): ConversionRateConfig? = - conversionRateConfig.getNullable("conversion_rate_config") - - /** - * For dimensional price: specifies a price group and dimension values - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = - dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") - - /** - * An alias for the price. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun fixedPriceQuantity(): Double? = - fixedPriceQuantity.getNullable("fixed_price_quantity") - - /** - * The property used to group this price on an invoice - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun invoiceGroupingKey(): String? = - invoiceGroupingKey.getNullable("invoice_grouping_key") - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun metadata(): Metadata? = metadata.getNullable("metadata") - - /** - * Returns the raw JSON value of [cadence]. - * - * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("cadence") - @ExcludeMissing - fun _cadence(): JsonField = cadence - - /** - * Returns the raw JSON value of [currency]. - * - * Unlike [currency], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("currency") - @ExcludeMissing - fun _currency(): JsonField = currency - - /** - * Returns the raw JSON value of [itemId]. - * - * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - /** - * Returns the raw JSON value of [minimumConfig]. - * - * Unlike [minimumConfig], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("minimum_config") - @ExcludeMissing - fun _minimumConfig(): JsonField = minimumConfig - - /** - * Returns the raw JSON value of [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - /** - * Returns the raw JSON value of [billableMetricId]. - * - * Unlike [billableMetricId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = billableMetricId - - /** - * Returns the raw JSON value of [billedInAdvance]. - * - * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance - - /** - * Returns the raw JSON value of [billingCycleConfiguration]. - * - * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** - * Returns the raw JSON value of [conversionRate]. - * - * Unlike [conversionRate], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** - * Returns the raw JSON value of [conversionRateConfig]. - * - * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("conversion_rate_config") - @ExcludeMissing - fun _conversionRateConfig(): JsonField = conversionRateConfig - - /** - * Returns the raw JSON value of [dimensionalPriceConfiguration]. - * - * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON - * field has an unexpected type. - */ - @JsonProperty("dimensional_price_configuration") - @ExcludeMissing - fun _dimensionalPriceConfiguration(): JsonField = - dimensionalPriceConfiguration - - /** - * Returns the raw JSON value of [externalPriceId]. - * - * Unlike [externalPriceId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * Returns the raw JSON value of [fixedPriceQuantity]. - * - * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** - * Returns the raw JSON value of [invoiceGroupingKey]. - * - * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Returns the raw JSON value of [invoicingCycleConfiguration]. - * - * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * Returns the raw JSON value of [metadata]. - * - * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [Minimum]. - * - * The following fields are required: - * ```kotlin - * .cadence() - * .currency() - * .itemId() - * .minimumConfig() - * .name() - * ``` - */ - fun builder() = Builder() - } - - /** A builder for [Minimum]. */ - class Builder internal constructor() { - - private var cadence: JsonField? = null - private var currency: JsonField? = null - private var itemId: JsonField? = null - private var minimumConfig: JsonField? = null - private var modelType: JsonValue = JsonValue.from("minimum") - private var name: JsonField? = null - private var billableMetricId: JsonField = JsonMissing.of() - private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var conversionRateConfig: JsonField = - JsonMissing.of() - private var dimensionalPriceConfiguration: - JsonField = - JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: - JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(minimum: Minimum) = apply { - cadence = minimum.cadence - currency = minimum.currency - itemId = minimum.itemId - minimumConfig = minimum.minimumConfig - modelType = minimum.modelType - name = minimum.name - billableMetricId = minimum.billableMetricId - billedInAdvance = minimum.billedInAdvance - billingCycleConfiguration = minimum.billingCycleConfiguration - conversionRate = minimum.conversionRate - conversionRateConfig = minimum.conversionRateConfig - dimensionalPriceConfiguration = minimum.dimensionalPriceConfiguration - externalPriceId = minimum.externalPriceId - fixedPriceQuantity = minimum.fixedPriceQuantity - invoiceGroupingKey = minimum.invoiceGroupingKey - invoicingCycleConfiguration = minimum.invoicingCycleConfiguration - metadata = minimum.metadata - additionalProperties = minimum.additionalProperties.toMutableMap() - } - - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** - * Sets [Builder.cadence] to an arbitrary JSON value. - * - * You should usually call [Builder.cadence] with a well-typed [Cadence] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - - /** An ISO 4217 currency string for which this price is billed in. */ - fun currency(currency: String) = currency(JsonField.of(currency)) - - /** - * Sets [Builder.currency] to an arbitrary JSON value. - * - * You should usually call [Builder.currency] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } - - /** The id of the item the price will be associated with. */ - fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - - /** - * Sets [Builder.itemId] to an arbitrary JSON value. - * - * You should usually call [Builder.itemId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - fun minimumConfig(minimumConfig: MinimumConfig) = - minimumConfig(JsonField.of(minimumConfig)) - - /** - * Sets [Builder.minimumConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.minimumConfig] with a well-typed - * [MinimumConfig] value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. - */ - fun minimumConfig(minimumConfig: JsonField) = apply { - this.minimumConfig = minimumConfig - } - - /** - * Sets the field to an arbitrary JSON value. - * - * It is usually unnecessary to call this method because the field defaults to - * the following: - * ```kotlin - * JsonValue.from("minimum") - * ``` - * - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } - - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) - - /** - * Sets [Builder.name] to an arbitrary JSON value. - * - * You should usually call [Builder.name] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun name(name: JsonField) = apply { this.name = name } - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: String?) = - billableMetricId(JsonField.ofNullable(billableMetricId)) - - /** - * Sets [Builder.billableMetricId] to an arbitrary JSON value. - * - * You should usually call [Builder.billableMetricId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun billableMetricId(billableMetricId: JsonField) = apply { - this.billableMetricId = billableMetricId - } - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if - * this is true, and in-arrears if this is false. - */ - fun billedInAdvance(billedInAdvance: Boolean?) = - billedInAdvance(JsonField.ofNullable(billedInAdvance)) - - /** - * Alias for [Builder.billedInAdvance]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun billedInAdvance(billedInAdvance: Boolean) = - billedInAdvance(billedInAdvance as Boolean?) - - /** - * Sets [Builder.billedInAdvance] to an arbitrary JSON value. - * - * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun billedInAdvance(billedInAdvance: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: NewBillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - - /** - * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.billingCycleConfiguration] with a well-typed - * [NewBillingCycleConfiguration] value instead. This method is primarily for - * setting the field to an undocumented or not yet supported value. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: JsonField - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: Double?) = - conversionRate(JsonField.ofNullable(conversionRate)) - - /** - * Alias for [Builder.conversionRate]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) - - /** - * Sets [Builder.conversionRate] to an arbitrary JSON value. - * - * You should usually call [Builder.conversionRate] with a well-typed [Double] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** - * The configuration for the rate of the price currency to the invoicing - * currency. - */ - fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = - conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) - - /** - * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.conversionRateConfig] with a well-typed - * [ConversionRateConfig] value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun conversionRateConfig( - conversionRateConfig: JsonField - ) = apply { this.conversionRateConfig = conversionRateConfig } - - /** - * Alias for calling [conversionRateConfig] with - * `ConversionRateConfig.ofUnit(unit)`. - */ - fun conversionRateConfig(unit: UnitConversionRateConfig) = - conversionRateConfig(ConversionRateConfig.ofUnit(unit)) - - /** - * Alias for calling [conversionRateConfig] with the following: - * ```kotlin - * UnitConversionRateConfig.builder() - * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) - * .unitConfig(unitConfig) - * .build() - * ``` - */ - fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = - conversionRateConfig( - UnitConversionRateConfig.builder() - .conversionRateType( - UnitConversionRateConfig.ConversionRateType.UNIT - ) - .unitConfig(unitConfig) - .build() - ) - - /** - * Alias for calling [conversionRateConfig] with - * `ConversionRateConfig.ofTiered(tiered)`. - */ - fun conversionRateConfig(tiered: TieredConversionRateConfig) = - conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) - - /** - * Alias for calling [conversionRateConfig] with the following: - * ```kotlin - * TieredConversionRateConfig.builder() - * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) - * .tieredConfig(tieredConfig) - * .build() - * ``` - */ - fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = - conversionRateConfig( - TieredConversionRateConfig.builder() - .conversionRateType( - TieredConversionRateConfig.ConversionRateType.TIERED - ) - .tieredConfig(tieredConfig) - .build() - ) - - /** For dimensional price: specifies a price group and dimension values */ - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? - ) = - dimensionalPriceConfiguration( - JsonField.ofNullable(dimensionalPriceConfiguration) - ) - - /** - * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.dimensionalPriceConfiguration] with a - * well-typed [NewDimensionalPriceConfiguration] value instead. This method is - * primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: JsonField - ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** - * Sets [Builder.externalPriceId] to an arbitrary JSON value. - * - * You should usually call [Builder.externalPriceId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun externalPriceId(externalPriceId: JsonField) = apply { - this.externalPriceId = externalPriceId - } - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = - fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) - - /** - * Alias for [Builder.fixedPriceQuantity]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. - * - * You should usually call [Builder.fixedPriceQuantity] with a well-typed - * [Double] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = - invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) - - /** - * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. - * - * You should usually call [Builder.invoiceGroupingKey] with a well-typed - * [String] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { - this.invoiceGroupingKey = invoiceGroupingKey - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are - * produced. If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: NewBillingCycleConfiguration? - ) = - invoicingCycleConfiguration( - JsonField.ofNullable(invoicingCycleConfiguration) - ) - - /** - * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.invoicingCycleConfiguration] with a - * well-typed [NewBillingCycleConfiguration] value instead. This method is - * primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * Sets [Builder.metadata] to an arbitrary JSON value. - * - * You should usually call [Builder.metadata] with a well-typed [Metadata] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Minimum]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```kotlin - * .cadence() - * .currency() - * .itemId() - * .minimumConfig() - * .name() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Minimum = - Minimum( - checkRequired("cadence", cadence), - checkRequired("currency", currency), - checkRequired("itemId", itemId), - checkRequired("minimumConfig", minimumConfig), - modelType, - checkRequired("name", name), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - conversionRateConfig, - dimensionalPriceConfiguration, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Minimum = apply { - if (validated) { - return@apply - } - - cadence().validate() - currency() - itemId() - minimumConfig().validate() - _modelType().let { - if (it != JsonValue.from("minimum")) { - throw OrbInvalidDataException("'modelType' is invalid, received $it") - } - } - name() - billableMetricId() - billedInAdvance() - billingCycleConfiguration()?.validate() - conversionRate() - conversionRateConfig()?.validate() - dimensionalPriceConfiguration()?.validate() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration()?.validate() - metadata()?.validate() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (cadence.asKnown()?.validity() ?: 0) + - (if (currency.asKnown() == null) 0 else 1) + - (if (itemId.asKnown() == null) 0 else 1) + - (minimumConfig.asKnown()?.validity() ?: 0) + - modelType.let { if (it == JsonValue.from("minimum")) 1 else 0 } + - (if (name.asKnown() == null) 0 else 1) + - (if (billableMetricId.asKnown() == null) 0 else 1) + - (if (billedInAdvance.asKnown() == null) 0 else 1) + - (billingCycleConfiguration.asKnown()?.validity() ?: 0) + - (if (conversionRate.asKnown() == null) 0 else 1) + - (conversionRateConfig.asKnown()?.validity() ?: 0) + - (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + - (if (externalPriceId.asKnown() == null) 0 else 1) + - (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + - (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + - (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + - (metadata.asKnown()?.validity() ?: 0) - - /** The cadence to bill for this price on. */ - class Cadence - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - val ANNUAL = of("annual") - - val SEMI_ANNUAL = of("semi_annual") - - val MONTHLY = of("monthly") - - val QUARTERLY = of("quarterly") - - val ONE_TIME = of("one_time") - - val CUSTOM = of("custom") - - fun of(value: String) = Cadence(JsonField.of(value)) - } - - /** An enum containing [Cadence]'s known values. */ - enum class Known { - ANNUAL, - SEMI_ANNUAL, - MONTHLY, - QUARTERLY, - ONE_TIME, - CUSTOM, - } - - /** - * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Cadence] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - ANNUAL, - SEMI_ANNUAL, - MONTHLY, - QUARTERLY, - ONE_TIME, - CUSTOM, - /** - * An enum member indicating that [Cadence] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - ANNUAL -> Value.ANNUAL - SEMI_ANNUAL -> Value.SEMI_ANNUAL - MONTHLY -> Value.MONTHLY - QUARTERLY -> Value.QUARTERLY - ONE_TIME -> Value.ONE_TIME - CUSTOM -> Value.CUSTOM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - ANNUAL -> Known.ANNUAL - SEMI_ANNUAL -> Known.SEMI_ANNUAL - MONTHLY -> Known.MONTHLY - QUARTERLY -> Known.QUARTERLY - ONE_TIME -> Known.ONE_TIME - CUSTOM -> Known.CUSTOM - else -> throw OrbInvalidDataException("Unknown Cadence: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString() - ?: throw OrbInvalidDataException("Value is not a String") - - private var validated: Boolean = false - - fun validate(): Cadence = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Cadence && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class MinimumConfig - private constructor( - private val minimumAmount: JsonField, - private val prorated: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("minimum_amount") - @ExcludeMissing - minimumAmount: JsonField = JsonMissing.of(), - @JsonProperty("prorated") - @ExcludeMissing - prorated: JsonField = JsonMissing.of(), - ) : this(minimumAmount, prorated, mutableMapOf()) - - /** - * The minimum amount to apply - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") - - /** - * By default, subtotals from minimum composite prices are prorated based on the - * service period. Set to false to disable proration. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun prorated(): Boolean? = prorated.getNullable("prorated") - - /** - * Returns the raw JSON value of [minimumAmount]. - * - * Unlike [minimumAmount], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("minimum_amount") - @ExcludeMissing - fun _minimumAmount(): JsonField = minimumAmount - - /** - * Returns the raw JSON value of [prorated]. - * - * Unlike [prorated], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("prorated") - @ExcludeMissing - fun _prorated(): JsonField = prorated - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [MinimumConfig]. - * - * The following fields are required: - * ```kotlin - * .minimumAmount() - * ``` - */ - fun builder() = Builder() - } - - /** A builder for [MinimumConfig]. */ - class Builder internal constructor() { - - private var minimumAmount: JsonField? = null - private var prorated: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - internal fun from(minimumConfig: MinimumConfig) = apply { - minimumAmount = minimumConfig.minimumAmount - prorated = minimumConfig.prorated - additionalProperties = minimumConfig.additionalProperties.toMutableMap() - } - - /** The minimum amount to apply */ - fun minimumAmount(minimumAmount: String) = - minimumAmount(JsonField.of(minimumAmount)) - - /** - * Sets [Builder.minimumAmount] to an arbitrary JSON value. - * - * You should usually call [Builder.minimumAmount] with a well-typed - * [String] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun minimumAmount(minimumAmount: JsonField) = apply { - this.minimumAmount = minimumAmount - } - - /** - * By default, subtotals from minimum composite prices are prorated based on - * the service period. Set to false to disable proration. - */ - fun prorated(prorated: Boolean?) = prorated(JsonField.ofNullable(prorated)) - - /** - * Alias for [Builder.prorated]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun prorated(prorated: Boolean) = prorated(prorated as Boolean?) - - /** - * Sets [Builder.prorated] to an arbitrary JSON value. - * - * You should usually call [Builder.prorated] with a well-typed [Boolean] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun prorated(prorated: JsonField) = apply { - this.prorated = prorated - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [MinimumConfig]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```kotlin - * .minimumAmount() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): MinimumConfig = - MinimumConfig( - checkRequired("minimumAmount", minimumAmount), - prorated, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): MinimumConfig = apply { - if (validated) { - return@apply - } - - minimumAmount() - prorated() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (if (minimumAmount.asKnown() == null) 0 else 1) + - (if (prorated.asKnown() == null) 0 else 1) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is MinimumConfig && - minimumAmount == other.minimumAmount && - prorated == other.prorated && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(minimumAmount, prorated, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "MinimumConfig{minimumAmount=$minimumAmount, prorated=$prorated, additionalProperties=$additionalProperties}" - } - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - class Metadata - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Metadata]. */ - fun builder() = Builder() - } - - /** A builder for [Metadata]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = - mutableMapOf() - - internal fun from(metadata: Metadata) = apply { - additionalProperties = metadata.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Metadata]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - additionalProperties.count { (_, value) -> - !value.isNull() && !value.isMissing() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Metadata && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Minimum && - cadence == other.cadence && - currency == other.currency && - itemId == other.itemId && - minimumConfig == other.minimumConfig && - modelType == other.modelType && - name == other.name && - billableMetricId == other.billableMetricId && - billedInAdvance == other.billedInAdvance && - billingCycleConfiguration == other.billingCycleConfiguration && - conversionRate == other.conversionRate && - conversionRateConfig == other.conversionRateConfig && - dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && - externalPriceId == other.externalPriceId && - fixedPriceQuantity == other.fixedPriceQuantity && - invoiceGroupingKey == other.invoiceGroupingKey && - invoicingCycleConfiguration == other.invoicingCycleConfiguration && - metadata == other.metadata && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - cadence, - currency, - itemId, - minimumConfig, - modelType, - name, - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - conversionRateConfig, - dimensionalPriceConfiguration, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Minimum{cadence=$cadence, currency=$currency, itemId=$itemId, minimumConfig=$minimumConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" - } } override fun equals(other: Any?): Boolean { diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionCreateParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionCreateParams.kt index 1f74cbc34..b372b5e53 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionCreateParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionCreateParams.kt @@ -4694,7 +4694,8 @@ private constructor( price(Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)) /** Alias for calling [price] with `Price.ofMinimum(minimum)`. */ - fun price(minimum: Price.Minimum) = price(Price.ofMinimum(minimum)) + fun price(minimum: NewSubscriptionMinimumCompositePrice) = + price(Price.ofMinimum(minimum)) /** The id of the price to add to the subscription. */ fun priceId(priceId: String?) = priceId(JsonField.ofNullable(priceId)) @@ -4851,7 +4852,7 @@ private constructor( null, private val groupedTiered: NewSubscriptionGroupedTieredPrice? = null, private val groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds? = null, - private val minimum: Minimum? = null, + private val minimum: NewSubscriptionMinimumCompositePrice? = null, private val _json: JsonValue? = null, ) { @@ -4921,7 +4922,7 @@ private constructor( fun groupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds? = groupedWithMinMaxThresholds - fun minimum(): Minimum? = minimum + fun minimum(): NewSubscriptionMinimumCompositePrice? = minimum fun isUnit(): Boolean = unit != null @@ -5053,7 +5054,7 @@ private constructor( fun asGroupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds = groupedWithMinMaxThresholds.getOrThrow("groupedWithMinMaxThresholds") - fun asMinimum(): Minimum = minimum.getOrThrow("minimum") + fun asMinimum(): NewSubscriptionMinimumCompositePrice = minimum.getOrThrow("minimum") fun _json(): JsonValue? = _json @@ -5263,7 +5264,7 @@ private constructor( groupedWithMinMaxThresholds.validate() } - override fun visitMinimum(minimum: Minimum) { + override fun visitMinimum(minimum: NewSubscriptionMinimumCompositePrice) { minimum.validate() } } @@ -5388,7 +5389,8 @@ private constructor( groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds ) = groupedWithMinMaxThresholds.validity() - override fun visitMinimum(minimum: Minimum) = minimum.validity() + override fun visitMinimum(minimum: NewSubscriptionMinimumCompositePrice) = + minimum.validity() override fun unknown(json: JsonValue?) = 0 } @@ -5596,7 +5598,8 @@ private constructor( groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds ) = Price(groupedWithMinMaxThresholds = groupedWithMinMaxThresholds) - fun ofMinimum(minimum: Minimum) = Price(minimum = minimum) + fun ofMinimum(minimum: NewSubscriptionMinimumCompositePrice) = + Price(minimum = minimum) } /** @@ -5693,7 +5696,7 @@ private constructor( groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds ): T - fun visitMinimum(minimum: Minimum): T + fun visitMinimum(minimum: NewSubscriptionMinimumCompositePrice): T /** * Maps an unknown variant of [Price] to a value of type [T]. @@ -5919,9 +5922,11 @@ private constructor( ?: Price(_json = json) } "minimum" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(minimum = it, _json = json) - } ?: Price(_json = json) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(minimum = it, _json = json) } ?: Price(_json = json) } } @@ -7469,1569 +7474,1176 @@ private constructor( override fun toString() = "GroupedWithMinMaxThresholds{cadence=$cadence, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } + } - class Minimum - private constructor( - private val cadence: JsonField, - private val itemId: JsonField, - private val minimumConfig: JsonField, - private val modelType: JsonValue, - private val name: JsonField, - private val billableMetricId: JsonField, - private val billedInAdvance: JsonField, - private val billingCycleConfiguration: JsonField, - private val conversionRate: JsonField, - private val conversionRateConfig: JsonField, - private val currency: JsonField, - private val dimensionalPriceConfiguration: - JsonField, - private val externalPriceId: JsonField, - private val fixedPriceQuantity: JsonField, - private val invoiceGroupingKey: JsonField, - private val invoicingCycleConfiguration: JsonField, - private val metadata: JsonField, - private val referenceId: JsonField, - private val additionalProperties: MutableMap, - ) { + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - @JsonCreator - private constructor( - @JsonProperty("cadence") - @ExcludeMissing - cadence: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - itemId: JsonField = JsonMissing.of(), - @JsonProperty("minimum_config") - @ExcludeMissing - minimumConfig: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - modelType: JsonValue = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - name: JsonField = JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("conversion_rate_config") - @ExcludeMissing - conversionRateConfig: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - currency: JsonField = JsonMissing.of(), - @JsonProperty("dimensional_price_configuration") - @ExcludeMissing - dimensionalPriceConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - metadata: JsonField = JsonMissing.of(), - @JsonProperty("reference_id") - @ExcludeMissing - referenceId: JsonField = JsonMissing.of(), - ) : this( - cadence, - itemId, - minimumConfig, - modelType, - name, - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - conversionRateConfig, - currency, - dimensionalPriceConfiguration, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - mutableMapOf(), - ) + return other is AddPrice && + allocationPrice == other.allocationPrice && + discounts == other.discounts && + endDate == other.endDate && + externalPriceId == other.externalPriceId && + maximumAmount == other.maximumAmount && + minimumAmount == other.minimumAmount && + planPhaseOrder == other.planPhaseOrder && + price == other.price && + priceId == other.priceId && + startDate == other.startDate && + additionalProperties == other.additionalProperties + } - /** - * The cadence to bill for this price on. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun cadence(): Cadence = cadence.getRequired("cadence") + private val hashCode: Int by lazy { + Objects.hash( + allocationPrice, + discounts, + endDate, + externalPriceId, + maximumAmount, + minimumAmount, + planPhaseOrder, + price, + priceId, + startDate, + additionalProperties, + ) + } - /** - * The id of the item the price will be associated with. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun itemId(): String = itemId.getRequired("item_id") + override fun hashCode(): Int = hashCode - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun minimumConfig(): MinimumConfig = minimumConfig.getRequired("minimum_config") + override fun toString() = + "AddPrice{allocationPrice=$allocationPrice, discounts=$discounts, endDate=$endDate, externalPriceId=$externalPriceId, maximumAmount=$maximumAmount, minimumAmount=$minimumAmount, planPhaseOrder=$planPhaseOrder, price=$price, priceId=$priceId, startDate=$startDate, additionalProperties=$additionalProperties}" + } - /** - * Expected to always return the following: - * ```kotlin - * JsonValue.from("minimum") - * ``` - * - * However, this method can be useful for debugging and logging (e.g. if the server - * responded with an unexpected value). - */ - @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + @Deprecated("deprecated") + class ExternalMarketplace + @JsonCreator + private constructor(private val value: JsonField) : Enum { - /** - * The name of the price. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun name(): String = name.getRequired("name") + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun billableMetricId(): String? = billableMetricId.getNullable("billable_metric_id") + companion object { - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + val GOOGLE = of("google") - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun billingCycleConfiguration(): NewBillingCycleConfiguration? = - billingCycleConfiguration.getNullable("billing_cycle_configuration") + val AWS = of("aws") - /** - * The per unit conversion rate of the price currency to the invoicing currency. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + val AZURE = of("azure") - /** - * The configuration for the rate of the price currency to the invoicing currency. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun conversionRateConfig(): ConversionRateConfig? = - conversionRateConfig.getNullable("conversion_rate_config") + fun of(value: String) = ExternalMarketplace(JsonField.of(value)) + } - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun currency(): String? = currency.getNullable("currency") + /** An enum containing [ExternalMarketplace]'s known values. */ + enum class Known { + GOOGLE, + AWS, + AZURE, + } - /** - * For dimensional price: specifies a price group and dimension values - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = - dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + /** + * An enum containing [ExternalMarketplace]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ExternalMarketplace] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + GOOGLE, + AWS, + AZURE, + /** + * An enum member indicating that [ExternalMarketplace] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } - /** - * An alias for the price. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + GOOGLE -> Value.GOOGLE + AWS -> Value.AWS + AZURE -> Value.AZURE + else -> Value._UNKNOWN + } - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun fixedPriceQuantity(): Double? = - fixedPriceQuantity.getNullable("fixed_price_quantity") + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known member. + */ + fun known(): Known = + when (this) { + GOOGLE -> Known.GOOGLE + AWS -> Known.AWS + AZURE -> Known.AZURE + else -> throw OrbInvalidDataException("Unknown ExternalMarketplace: $value") + } - /** - * The property used to group this price on an invoice - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun invoiceGroupingKey(): String? = - invoiceGroupingKey.getNullable("invoice_grouping_key") + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the expected + * primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + private var validated: Boolean = false - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun metadata(): Metadata? = metadata.getNullable("metadata") + fun validate(): ExternalMarketplace = apply { + if (validated) { + return@apply + } - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun referenceId(): String? = referenceId.getNullable("reference_id") + known() + validated = true + } - /** - * Returns the raw JSON value of [cadence]. - * - * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("cadence") - @ExcludeMissing - fun _cadence(): JsonField = cadence + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - /** - * Returns the raw JSON value of [itemId]. - * - * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - /** - * Returns the raw JSON value of [minimumConfig]. - * - * Unlike [minimumConfig], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("minimum_config") - @ExcludeMissing - fun _minimumConfig(): JsonField = minimumConfig + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * Returns the raw JSON value of [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + return other is ExternalMarketplace && value == other.value + } - /** - * Returns the raw JSON value of [billableMetricId]. - * - * Unlike [billableMetricId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = billableMetricId + override fun hashCode() = value.hashCode() - /** - * Returns the raw JSON value of [billedInAdvance]. - * - * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance + override fun toString() = value.toString() + } - /** - * Returns the raw JSON value of [billingCycleConfiguration]. - * - * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by setting + * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to + * `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { - /** - * Returns the raw JSON value of [conversionRate]. - * - * Unlike [conversionRate], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties - /** - * Returns the raw JSON value of [conversionRateConfig]. - * - * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("conversion_rate_config") - @ExcludeMissing - fun _conversionRateConfig(): JsonField = conversionRateConfig + fun toBuilder() = Builder().from(this) - /** - * Returns the raw JSON value of [currency]. - * - * Unlike [currency], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("currency") - @ExcludeMissing - fun _currency(): JsonField = currency + companion object { - /** - * Returns the raw JSON value of [dimensionalPriceConfiguration]. - * - * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON - * field has an unexpected type. - */ - @JsonProperty("dimensional_price_configuration") - @ExcludeMissing - fun _dimensionalPriceConfiguration(): JsonField = - dimensionalPriceConfiguration + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } - /** - * Returns the raw JSON value of [externalPriceId]. - * - * Unlike [externalPriceId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId + /** A builder for [Metadata]. */ + class Builder internal constructor() { - /** - * Returns the raw JSON value of [fixedPriceQuantity]. - * - * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + private var additionalProperties: MutableMap = mutableMapOf() - /** - * Returns the raw JSON value of [invoiceGroupingKey]. - * - * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } - /** - * Returns the raw JSON value of [invoicingCycleConfiguration]. - * - * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** - * Returns the raw JSON value of [metadata]. - * - * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * Returns the raw JSON value of [referenceId]. - * - * Unlike [referenceId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("reference_id") - @ExcludeMissing - fun _referenceId(): JsonField = referenceId + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - fun toBuilder() = Builder().from(this) + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } - companion object { + private var validated: Boolean = false - /** - * Returns a mutable builder for constructing an instance of [Minimum]. - * - * The following fields are required: - * ```kotlin - * .cadence() - * .itemId() - * .minimumConfig() - * .name() - * ``` - */ - fun builder() = Builder() - } + fun validate(): Metadata = apply { + if (validated) { + return@apply + } - /** A builder for [Minimum]. */ - class Builder internal constructor() { + validated = true + } - private var cadence: JsonField? = null - private var itemId: JsonField? = null - private var minimumConfig: JsonField? = null - private var modelType: JsonValue = JsonValue.from("minimum") - private var name: JsonField? = null - private var billableMetricId: JsonField = JsonMissing.of() - private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var conversionRateConfig: JsonField = - JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var dimensionalPriceConfiguration: - JsonField = - JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: - JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var referenceId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - internal fun from(minimum: Minimum) = apply { - cadence = minimum.cadence - itemId = minimum.itemId - minimumConfig = minimum.minimumConfig - modelType = minimum.modelType - name = minimum.name - billableMetricId = minimum.billableMetricId - billedInAdvance = minimum.billedInAdvance - billingCycleConfiguration = minimum.billingCycleConfiguration - conversionRate = minimum.conversionRate - conversionRateConfig = minimum.conversionRateConfig - currency = minimum.currency - dimensionalPriceConfiguration = minimum.dimensionalPriceConfiguration - externalPriceId = minimum.externalPriceId - fixedPriceQuantity = minimum.fixedPriceQuantity - invoiceGroupingKey = minimum.invoiceGroupingKey - invoicingCycleConfiguration = minimum.invoicingCycleConfiguration - metadata = minimum.metadata - referenceId = minimum.referenceId - additionalProperties = minimum.additionalProperties.toMutableMap() - } + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * Sets [Builder.cadence] to an arbitrary JSON value. - * - * You should usually call [Builder.cadence] with a well-typed [Cadence] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + return other is Metadata && additionalProperties == other.additionalProperties + } - /** The id of the item the price will be associated with. */ - fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /** - * Sets [Builder.itemId] to an arbitrary JSON value. - * - * You should usually call [Builder.itemId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + override fun hashCode(): Int = hashCode - fun minimumConfig(minimumConfig: MinimumConfig) = - minimumConfig(JsonField.of(minimumConfig)) + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } - /** - * Sets [Builder.minimumConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.minimumConfig] with a well-typed - * [MinimumConfig] value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. - */ - fun minimumConfig(minimumConfig: JsonField) = apply { - this.minimumConfig = minimumConfig - } + class RemoveAdjustment + private constructor( + private val adjustmentId: JsonField, + private val additionalProperties: MutableMap, + ) { - /** - * Sets the field to an arbitrary JSON value. - * - * It is usually unnecessary to call this method because the field defaults to - * the following: - * ```kotlin - * JsonValue.from("minimum") - * ``` - * - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + @JsonCreator + private constructor( + @JsonProperty("adjustment_id") + @ExcludeMissing + adjustmentId: JsonField = JsonMissing.of() + ) : this(adjustmentId, mutableMapOf()) - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) + /** + * The id of the adjustment to remove on the subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun adjustmentId(): String = adjustmentId.getRequired("adjustment_id") - /** - * Sets [Builder.name] to an arbitrary JSON value. - * - * You should usually call [Builder.name] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun name(name: JsonField) = apply { this.name = name } + /** + * Returns the raw JSON value of [adjustmentId]. + * + * Unlike [adjustmentId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("adjustment_id") + @ExcludeMissing + fun _adjustmentId(): JsonField = adjustmentId - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: String?) = - billableMetricId(JsonField.ofNullable(billableMetricId)) + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - /** - * Sets [Builder.billableMetricId] to an arbitrary JSON value. - * - * You should usually call [Builder.billableMetricId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun billableMetricId(billableMetricId: JsonField) = apply { - this.billableMetricId = billableMetricId - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - /** - * If the Price represents a fixed cost, the price will be billed in-advance if - * this is true, and in-arrears if this is false. - */ - fun billedInAdvance(billedInAdvance: Boolean?) = - billedInAdvance(JsonField.ofNullable(billedInAdvance)) - - /** - * Alias for [Builder.billedInAdvance]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun billedInAdvance(billedInAdvance: Boolean) = - billedInAdvance(billedInAdvance as Boolean?) + fun toBuilder() = Builder().from(this) - /** - * Sets [Builder.billedInAdvance] to an arbitrary JSON value. - * - * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun billedInAdvance(billedInAdvance: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } + companion object { - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: NewBillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + /** + * Returns a mutable builder for constructing an instance of [RemoveAdjustment]. + * + * The following fields are required: + * ```kotlin + * .adjustmentId() + * ``` + */ + fun builder() = Builder() + } - /** - * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.billingCycleConfiguration] with a well-typed - * [NewBillingCycleConfiguration] value instead. This method is primarily for - * setting the field to an undocumented or not yet supported value. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: JsonField - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + /** A builder for [RemoveAdjustment]. */ + class Builder internal constructor() { - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: Double?) = - conversionRate(JsonField.ofNullable(conversionRate)) + private var adjustmentId: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() - /** - * Alias for [Builder.conversionRate]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) + internal fun from(removeAdjustment: RemoveAdjustment) = apply { + adjustmentId = removeAdjustment.adjustmentId + additionalProperties = removeAdjustment.additionalProperties.toMutableMap() + } - /** - * Sets [Builder.conversionRate] to an arbitrary JSON value. - * - * You should usually call [Builder.conversionRate] with a well-typed [Double] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } + /** The id of the adjustment to remove on the subscription. */ + fun adjustmentId(adjustmentId: String) = adjustmentId(JsonField.of(adjustmentId)) - /** - * The configuration for the rate of the price currency to the invoicing - * currency. - */ - fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = - conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + /** + * Sets [Builder.adjustmentId] to an arbitrary JSON value. + * + * You should usually call [Builder.adjustmentId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun adjustmentId(adjustmentId: JsonField) = apply { + this.adjustmentId = adjustmentId + } - /** - * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.conversionRateConfig] with a well-typed - * [ConversionRateConfig] value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun conversionRateConfig( - conversionRateConfig: JsonField - ) = apply { this.conversionRateConfig = conversionRateConfig } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** - * Alias for calling [conversionRateConfig] with - * `ConversionRateConfig.ofUnit(unit)`. - */ - fun conversionRateConfig(unit: UnitConversionRateConfig) = - conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * Alias for calling [conversionRateConfig] with the following: - * ```kotlin - * UnitConversionRateConfig.builder() - * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) - * .unitConfig(unitConfig) - * .build() - * ``` - */ - fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = - conversionRateConfig( - UnitConversionRateConfig.builder() - .conversionRateType( - UnitConversionRateConfig.ConversionRateType.UNIT - ) - .unitConfig(unitConfig) - .build() - ) + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - /** - * Alias for calling [conversionRateConfig] with - * `ConversionRateConfig.ofTiered(tiered)`. - */ - fun conversionRateConfig(tiered: TieredConversionRateConfig) = - conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - /** - * Alias for calling [conversionRateConfig] with the following: - * ```kotlin - * TieredConversionRateConfig.builder() - * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) - * .tieredConfig(tieredConfig) - * .build() - * ``` - */ - fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = - conversionRateConfig( - TieredConversionRateConfig.builder() - .conversionRateType( - TieredConversionRateConfig.ConversionRateType.TIERED - ) - .tieredConfig(tieredConfig) - .build() - ) + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + /** + * Returns an immutable instance of [RemoveAdjustment]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .adjustmentId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): RemoveAdjustment = + RemoveAdjustment( + checkRequired("adjustmentId", adjustmentId), + additionalProperties.toMutableMap(), + ) + } - /** - * Sets [Builder.currency] to an arbitrary JSON value. - * - * You should usually call [Builder.currency] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } + private var validated: Boolean = false - /** For dimensional price: specifies a price group and dimension values */ - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? - ) = - dimensionalPriceConfiguration( - JsonField.ofNullable(dimensionalPriceConfiguration) - ) + fun validate(): RemoveAdjustment = apply { + if (validated) { + return@apply + } - /** - * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.dimensionalPriceConfiguration] with a - * well-typed [NewDimensionalPriceConfiguration] value instead. This method is - * primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: JsonField - ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + adjustmentId() + validated = true + } - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - /** - * Sets [Builder.externalPriceId] to an arbitrary JSON value. - * - * You should usually call [Builder.externalPriceId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun externalPriceId(externalPriceId: JsonField) = apply { - this.externalPriceId = externalPriceId - } + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = (if (adjustmentId.asKnown() == null) 0 else 1) - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = - fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) - - /** - * Alias for [Builder.fixedPriceQuantity]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. - * - * You should usually call [Builder.fixedPriceQuantity] with a well-typed - * [Double] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + return other is RemoveAdjustment && + adjustmentId == other.adjustmentId && + additionalProperties == other.additionalProperties + } - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = - invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + private val hashCode: Int by lazy { Objects.hash(adjustmentId, additionalProperties) } - /** - * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. - * - * You should usually call [Builder.invoiceGroupingKey] with a well-typed - * [String] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { - this.invoiceGroupingKey = invoiceGroupingKey - } + override fun hashCode(): Int = hashCode - /** - * Within each billing cycle, specifies the cadence at which invoices are - * produced. If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: NewBillingCycleConfiguration? - ) = - invoicingCycleConfiguration( - JsonField.ofNullable(invoicingCycleConfiguration) - ) + override fun toString() = + "RemoveAdjustment{adjustmentId=$adjustmentId, additionalProperties=$additionalProperties}" + } - /** - * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.invoicingCycleConfiguration] with a - * well-typed [NewBillingCycleConfiguration] value instead. This method is - * primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + class RemovePrice + private constructor( + private val externalPriceId: JsonField, + private val priceId: JsonField, + private val additionalProperties: MutableMap, + ) { - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + @JsonCreator + private constructor( + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("price_id") @ExcludeMissing priceId: JsonField = JsonMissing.of(), + ) : this(externalPriceId, priceId, mutableMapOf()) - /** - * Sets [Builder.metadata] to an arbitrary JSON value. - * - * You should usually call [Builder.metadata] with a well-typed [Metadata] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + /** + * The external price id of the price to remove on the subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - fun referenceId(referenceId: String?) = - referenceId(JsonField.ofNullable(referenceId)) + /** + * The id of the price to remove on the subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun priceId(): String? = priceId.getNullable("price_id") - /** - * Sets [Builder.referenceId] to an arbitrary JSON value. - * - * You should usually call [Builder.referenceId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun referenceId(referenceId: JsonField) = apply { - this.referenceId = referenceId - } + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * Returns the raw JSON value of [priceId]. + * + * Unlike [priceId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun toBuilder() = Builder().from(this) - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + companion object { - /** - * Returns an immutable instance of [Minimum]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```kotlin - * .cadence() - * .itemId() - * .minimumConfig() - * .name() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Minimum = - Minimum( - checkRequired("cadence", cadence), - checkRequired("itemId", itemId), - checkRequired("minimumConfig", minimumConfig), - modelType, - checkRequired("name", name), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - conversionRateConfig, - currency, - dimensionalPriceConfiguration, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - additionalProperties.toMutableMap(), - ) - } + /** Returns a mutable builder for constructing an instance of [RemovePrice]. */ + fun builder() = Builder() + } - private var validated: Boolean = false + /** A builder for [RemovePrice]. */ + class Builder internal constructor() { - fun validate(): Minimum = apply { - if (validated) { - return@apply - } + private var externalPriceId: JsonField = JsonMissing.of() + private var priceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - cadence().validate() - itemId() - minimumConfig().validate() - _modelType().let { - if (it != JsonValue.from("minimum")) { - throw OrbInvalidDataException("'modelType' is invalid, received $it") - } - } - name() - billableMetricId() - billedInAdvance() - billingCycleConfiguration()?.validate() - conversionRate() - conversionRateConfig()?.validate() - currency() - dimensionalPriceConfiguration()?.validate() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration()?.validate() - metadata()?.validate() - referenceId() - validated = true - } + internal fun from(removePrice: RemovePrice) = apply { + externalPriceId = removePrice.externalPriceId + priceId = removePrice.priceId + additionalProperties = removePrice.additionalProperties.toMutableMap() + } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** The external price id of the price to remove on the subscription. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (cadence.asKnown()?.validity() ?: 0) + - (if (itemId.asKnown() == null) 0 else 1) + - (minimumConfig.asKnown()?.validity() ?: 0) + - modelType.let { if (it == JsonValue.from("minimum")) 1 else 0 } + - (if (name.asKnown() == null) 0 else 1) + - (if (billableMetricId.asKnown() == null) 0 else 1) + - (if (billedInAdvance.asKnown() == null) 0 else 1) + - (billingCycleConfiguration.asKnown()?.validity() ?: 0) + - (if (conversionRate.asKnown() == null) 0 else 1) + - (conversionRateConfig.asKnown()?.validity() ?: 0) + - (if (currency.asKnown() == null) 0 else 1) + - (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + - (if (externalPriceId.asKnown() == null) 0 else 1) + - (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + - (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + - (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + - (metadata.asKnown()?.validity() ?: 0) + - (if (referenceId.asKnown() == null) 0 else 1) - - /** The cadence to bill for this price on. */ - class Cadence - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } - companion object { + /** The id of the price to remove on the subscription. */ + fun priceId(priceId: String?) = priceId(JsonField.ofNullable(priceId)) - val ANNUAL = of("annual") + /** + * Sets [Builder.priceId] to an arbitrary JSON value. + * + * You should usually call [Builder.priceId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun priceId(priceId: JsonField) = apply { this.priceId = priceId } - val SEMI_ANNUAL = of("semi_annual") + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - val MONTHLY = of("monthly") + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - val QUARTERLY = of("quarterly") + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - val ONE_TIME = of("one_time") + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - val CUSTOM = of("custom") + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - fun of(value: String) = Cadence(JsonField.of(value)) - } + /** + * Returns an immutable instance of [RemovePrice]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): RemovePrice = + RemovePrice(externalPriceId, priceId, additionalProperties.toMutableMap()) + } - /** An enum containing [Cadence]'s known values. */ - enum class Known { - ANNUAL, - SEMI_ANNUAL, - MONTHLY, - QUARTERLY, - ONE_TIME, - CUSTOM, - } + private var validated: Boolean = false - /** - * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Cadence] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - ANNUAL, - SEMI_ANNUAL, - MONTHLY, - QUARTERLY, - ONE_TIME, - CUSTOM, - /** - * An enum member indicating that [Cadence] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } + fun validate(): RemovePrice = apply { + if (validated) { + return@apply + } - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - ANNUAL -> Value.ANNUAL - SEMI_ANNUAL -> Value.SEMI_ANNUAL - MONTHLY -> Value.MONTHLY - QUARTERLY -> Value.QUARTERLY - ONE_TIME -> Value.ONE_TIME - CUSTOM -> Value.CUSTOM - else -> Value._UNKNOWN - } + externalPriceId() + priceId() + validated = true + } - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - ANNUAL -> Known.ANNUAL - SEMI_ANNUAL -> Known.SEMI_ANNUAL - MONTHLY -> Known.MONTHLY - QUARTERLY -> Known.QUARTERLY - ONE_TIME -> Known.ONE_TIME - CUSTOM -> Known.CUSTOM - else -> throw OrbInvalidDataException("Unknown Cadence: $value") - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString() - ?: throw OrbInvalidDataException("Value is not a String") + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (priceId.asKnown() == null) 0 else 1) - private var validated: Boolean = false + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun validate(): Cadence = apply { - if (validated) { - return@apply - } + return other is RemovePrice && + externalPriceId == other.externalPriceId && + priceId == other.priceId && + additionalProperties == other.additionalProperties + } - known() - validated = true - } + private val hashCode: Int by lazy { + Objects.hash(externalPriceId, priceId, additionalProperties) + } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + override fun hashCode(): Int = hashCode - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun toString() = + "RemovePrice{externalPriceId=$externalPriceId, priceId=$priceId, additionalProperties=$additionalProperties}" + } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + class ReplaceAdjustment + private constructor( + private val adjustment: JsonField, + private val replacesAdjustmentId: JsonField, + private val additionalProperties: MutableMap, + ) { - return other is Cadence && value == other.value - } + @JsonCreator + private constructor( + @JsonProperty("adjustment") + @ExcludeMissing + adjustment: JsonField = JsonMissing.of(), + @JsonProperty("replaces_adjustment_id") + @ExcludeMissing + replacesAdjustmentId: JsonField = JsonMissing.of(), + ) : this(adjustment, replacesAdjustmentId, mutableMapOf()) - override fun hashCode() = value.hashCode() + /** + * The definition of a new adjustment to create and add to the subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun adjustment(): Adjustment = adjustment.getRequired("adjustment") - override fun toString() = value.toString() - } + /** + * The id of the adjustment on the plan to replace in the subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun replacesAdjustmentId(): String = + replacesAdjustmentId.getRequired("replaces_adjustment_id") - class MinimumConfig - private constructor( - private val minimumAmount: JsonField, - private val prorated: JsonField, - private val additionalProperties: MutableMap, - ) { + /** + * Returns the raw JSON value of [adjustment]. + * + * Unlike [adjustment], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("adjustment") + @ExcludeMissing + fun _adjustment(): JsonField = adjustment - @JsonCreator - private constructor( - @JsonProperty("minimum_amount") - @ExcludeMissing - minimumAmount: JsonField = JsonMissing.of(), - @JsonProperty("prorated") - @ExcludeMissing - prorated: JsonField = JsonMissing.of(), - ) : this(minimumAmount, prorated, mutableMapOf()) + /** + * Returns the raw JSON value of [replacesAdjustmentId]. + * + * Unlike [replacesAdjustmentId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("replaces_adjustment_id") + @ExcludeMissing + fun _replacesAdjustmentId(): JsonField = replacesAdjustmentId - /** - * The minimum amount to apply - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - /** - * By default, subtotals from minimum composite prices are prorated based on the - * service period. Set to false to disable proration. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun prorated(): Boolean? = prorated.getNullable("prorated") + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - /** - * Returns the raw JSON value of [minimumAmount]. - * - * Unlike [minimumAmount], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("minimum_amount") - @ExcludeMissing - fun _minimumAmount(): JsonField = minimumAmount + fun toBuilder() = Builder().from(this) - /** - * Returns the raw JSON value of [prorated]. - * - * Unlike [prorated], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("prorated") - @ExcludeMissing - fun _prorated(): JsonField = prorated + companion object { - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** + * Returns a mutable builder for constructing an instance of [ReplaceAdjustment]. + * + * The following fields are required: + * ```kotlin + * .adjustment() + * .replacesAdjustmentId() + * ``` + */ + fun builder() = Builder() + } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** A builder for [ReplaceAdjustment]. */ + class Builder internal constructor() { - fun toBuilder() = Builder().from(this) + private var adjustment: JsonField? = null + private var replacesAdjustmentId: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() - companion object { + internal fun from(replaceAdjustment: ReplaceAdjustment) = apply { + adjustment = replaceAdjustment.adjustment + replacesAdjustmentId = replaceAdjustment.replacesAdjustmentId + additionalProperties = replaceAdjustment.additionalProperties.toMutableMap() + } - /** - * Returns a mutable builder for constructing an instance of - * [MinimumConfig]. - * - * The following fields are required: - * ```kotlin - * .minimumAmount() - * ``` - */ - fun builder() = Builder() - } + /** The definition of a new adjustment to create and add to the subscription. */ + fun adjustment(adjustment: Adjustment) = adjustment(JsonField.of(adjustment)) - /** A builder for [MinimumConfig]. */ - class Builder internal constructor() { + /** + * Sets [Builder.adjustment] to an arbitrary JSON value. + * + * You should usually call [Builder.adjustment] with a well-typed [Adjustment] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun adjustment(adjustment: JsonField) = apply { + this.adjustment = adjustment + } - private var minimumAmount: JsonField? = null - private var prorated: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() + /** + * Alias for calling [adjustment] with + * `Adjustment.ofPercentageDiscount(percentageDiscount)`. + */ + fun adjustment(percentageDiscount: NewPercentageDiscount) = + adjustment(Adjustment.ofPercentageDiscount(percentageDiscount)) - internal fun from(minimumConfig: MinimumConfig) = apply { - minimumAmount = minimumConfig.minimumAmount - prorated = minimumConfig.prorated - additionalProperties = minimumConfig.additionalProperties.toMutableMap() - } + /** + * Alias for calling [adjustment] with the following: + * ```kotlin + * NewPercentageDiscount.builder() + * .adjustmentType(NewPercentageDiscount.AdjustmentType.PERCENTAGE_DISCOUNT) + * .percentageDiscount(percentageDiscount) + * .build() + * ``` + */ + fun percentageDiscountAdjustment(percentageDiscount: Double) = + adjustment( + NewPercentageDiscount.builder() + .adjustmentType(NewPercentageDiscount.AdjustmentType.PERCENTAGE_DISCOUNT) + .percentageDiscount(percentageDiscount) + .build() + ) - /** The minimum amount to apply */ - fun minimumAmount(minimumAmount: String) = - minimumAmount(JsonField.of(minimumAmount)) + /** Alias for calling [adjustment] with `Adjustment.ofUsageDiscount(usageDiscount)`. */ + fun adjustment(usageDiscount: NewUsageDiscount) = + adjustment(Adjustment.ofUsageDiscount(usageDiscount)) - /** - * Sets [Builder.minimumAmount] to an arbitrary JSON value. - * - * You should usually call [Builder.minimumAmount] with a well-typed - * [String] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun minimumAmount(minimumAmount: JsonField) = apply { - this.minimumAmount = minimumAmount - } + /** + * Alias for calling [adjustment] with the following: + * ```kotlin + * NewUsageDiscount.builder() + * .adjustmentType(NewUsageDiscount.AdjustmentType.USAGE_DISCOUNT) + * .usageDiscount(usageDiscount) + * .build() + * ``` + */ + fun usageDiscountAdjustment(usageDiscount: Double) = + adjustment( + NewUsageDiscount.builder() + .adjustmentType(NewUsageDiscount.AdjustmentType.USAGE_DISCOUNT) + .usageDiscount(usageDiscount) + .build() + ) - /** - * By default, subtotals from minimum composite prices are prorated based on - * the service period. Set to false to disable proration. - */ - fun prorated(prorated: Boolean?) = prorated(JsonField.ofNullable(prorated)) + /** + * Alias for calling [adjustment] with `Adjustment.ofAmountDiscount(amountDiscount)`. + */ + fun adjustment(amountDiscount: NewAmountDiscount) = + adjustment(Adjustment.ofAmountDiscount(amountDiscount)) - /** - * Alias for [Builder.prorated]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun prorated(prorated: Boolean) = prorated(prorated as Boolean?) + /** + * Alias for calling [adjustment] with the following: + * ```kotlin + * NewAmountDiscount.builder() + * .adjustmentType(NewAmountDiscount.AdjustmentType.AMOUNT_DISCOUNT) + * .amountDiscount(amountDiscount) + * .build() + * ``` + */ + fun amountDiscountAdjustment(amountDiscount: String) = + adjustment( + NewAmountDiscount.builder() + .adjustmentType(NewAmountDiscount.AdjustmentType.AMOUNT_DISCOUNT) + .amountDiscount(amountDiscount) + .build() + ) - /** - * Sets [Builder.prorated] to an arbitrary JSON value. - * - * You should usually call [Builder.prorated] with a well-typed [Boolean] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun prorated(prorated: JsonField) = apply { - this.prorated = prorated - } + /** Alias for calling [adjustment] with `Adjustment.ofMinimum(minimum)`. */ + fun adjustment(minimum: NewMinimum) = adjustment(Adjustment.ofMinimum(minimum)) - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** Alias for calling [adjustment] with `Adjustment.ofMaximum(maximum)`. */ + fun adjustment(maximum: NewMaximum) = adjustment(Adjustment.ofMaximum(maximum)) - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * Alias for calling [adjustment] with the following: + * ```kotlin + * NewMaximum.builder() + * .adjustmentType(NewMaximum.AdjustmentType.MAXIMUM) + * .maximumAmount(maximumAmount) + * .build() + * ``` + */ + fun maximumAdjustment(maximumAmount: String) = + adjustment( + NewMaximum.builder() + .adjustmentType(NewMaximum.AdjustmentType.MAXIMUM) + .maximumAmount(maximumAmount) + .build() + ) - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + /** The id of the adjustment on the plan to replace in the subscription. */ + fun replacesAdjustmentId(replacesAdjustmentId: String) = + replacesAdjustmentId(JsonField.of(replacesAdjustmentId)) - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + /** + * Sets [Builder.replacesAdjustmentId] to an arbitrary JSON value. + * + * You should usually call [Builder.replacesAdjustmentId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun replacesAdjustmentId(replacesAdjustmentId: JsonField) = apply { + this.replacesAdjustmentId = replacesAdjustmentId + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** - * Returns an immutable instance of [MinimumConfig]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```kotlin - * .minimumAmount() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): MinimumConfig = - MinimumConfig( - checkRequired("minimumAmount", minimumAmount), - prorated, - additionalProperties.toMutableMap(), - ) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - private var validated: Boolean = false + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun validate(): MinimumConfig = apply { - if (validated) { - return@apply - } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - minimumAmount() - prorated() - validated = true - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** + * Returns an immutable instance of [ReplaceAdjustment]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .adjustment() + * .replacesAdjustmentId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ReplaceAdjustment = + ReplaceAdjustment( + checkRequired("adjustment", adjustment), + checkRequired("replacesAdjustmentId", replacesAdjustmentId), + additionalProperties.toMutableMap(), + ) + } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (if (minimumAmount.asKnown() == null) 0 else 1) + - (if (prorated.asKnown() == null) 0 else 1) + private var validated: Boolean = false - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + fun validate(): ReplaceAdjustment = apply { + if (validated) { + return@apply + } - return other is MinimumConfig && - minimumAmount == other.minimumAmount && - prorated == other.prorated && - additionalProperties == other.additionalProperties - } + adjustment().validate() + replacesAdjustmentId() + validated = true + } - private val hashCode: Int by lazy { - Objects.hash(minimumAmount, prorated, additionalProperties) - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - override fun hashCode(): Int = hashCode + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (adjustment.asKnown()?.validity() ?: 0) + + (if (replacesAdjustmentId.asKnown() == null) 0 else 1) - override fun toString() = - "MinimumConfig{minimumAmount=$minimumAmount, prorated=$prorated, additionalProperties=$additionalProperties}" - } + /** The definition of a new adjustment to create and add to the subscription. */ + @JsonDeserialize(using = Adjustment.Deserializer::class) + @JsonSerialize(using = Adjustment.Serializer::class) + class Adjustment + private constructor( + private val percentageDiscount: NewPercentageDiscount? = null, + private val usageDiscount: NewUsageDiscount? = null, + private val amountDiscount: NewAmountDiscount? = null, + private val minimum: NewMinimum? = null, + private val maximum: NewMaximum? = null, + private val _json: JsonValue? = null, + ) { - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - class Metadata - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { + fun percentageDiscount(): NewPercentageDiscount? = percentageDiscount - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun usageDiscount(): NewUsageDiscount? = usageDiscount - fun toBuilder() = Builder().from(this) + fun amountDiscount(): NewAmountDiscount? = amountDiscount - companion object { + fun minimum(): NewMinimum? = minimum - /** Returns a mutable builder for constructing an instance of [Metadata]. */ - fun builder() = Builder() - } + fun maximum(): NewMaximum? = maximum - /** A builder for [Metadata]. */ - class Builder internal constructor() { + fun isPercentageDiscount(): Boolean = percentageDiscount != null - private var additionalProperties: MutableMap = - mutableMapOf() + fun isUsageDiscount(): Boolean = usageDiscount != null - internal fun from(metadata: Metadata) = apply { - additionalProperties = metadata.additionalProperties.toMutableMap() - } + fun isAmountDiscount(): Boolean = amountDiscount != null - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun isMinimum(): Boolean = minimum != null - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun isMaximum(): Boolean = maximum != null - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + fun asPercentageDiscount(): NewPercentageDiscount = + percentageDiscount.getOrThrow("percentageDiscount") - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun asUsageDiscount(): NewUsageDiscount = usageDiscount.getOrThrow("usageDiscount") - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun asAmountDiscount(): NewAmountDiscount = amountDiscount.getOrThrow("amountDiscount") - /** - * Returns an immutable instance of [Metadata]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } + fun asMinimum(): NewMinimum = minimum.getOrThrow("minimum") - private var validated: Boolean = false + fun asMaximum(): NewMaximum = maximum.getOrThrow("maximum") - fun validate(): Metadata = apply { - if (validated) { - return@apply - } + fun _json(): JsonValue? = _json - validated = true - } + fun accept(visitor: Visitor): T = + when { + percentageDiscount != null -> + visitor.visitPercentageDiscount(percentageDiscount) + usageDiscount != null -> visitor.visitUsageDiscount(usageDiscount) + amountDiscount != null -> visitor.visitAmountDiscount(amountDiscount) + minimum != null -> visitor.visitMinimum(minimum) + maximum != null -> visitor.visitMaximum(maximum) + else -> visitor.unknown(_json) + } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false + private var validated: Boolean = false + + fun validate(): Adjustment = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitPercentageDiscount( + percentageDiscount: NewPercentageDiscount + ) { + percentageDiscount.validate() } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - additionalProperties.count { (_, value) -> - !value.isNull() && !value.isMissing() + override fun visitUsageDiscount(usageDiscount: NewUsageDiscount) { + usageDiscount.validate() } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + override fun visitAmountDiscount(amountDiscount: NewAmountDiscount) { + amountDiscount.validate() } - return other is Metadata && - additionalProperties == other.additionalProperties + override fun visitMinimum(minimum: NewMinimum) { + minimum.validate() + } + + override fun visitMaximum(maximum: NewMaximum) { + maximum.validate() + } } + ) + validated = true + } - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - override fun hashCode(): Int = hashCode + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitPercentageDiscount( + percentageDiscount: NewPercentageDiscount + ) = percentageDiscount.validity() - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } + override fun visitUsageDiscount(usageDiscount: NewUsageDiscount) = + usageDiscount.validity() - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + override fun visitAmountDiscount(amountDiscount: NewAmountDiscount) = + amountDiscount.validity() + + override fun visitMinimum(minimum: NewMinimum) = minimum.validity() + + override fun visitMaximum(maximum: NewMaximum) = maximum.validity() + + override fun unknown(json: JsonValue?) = 0 } + ) - return other is Minimum && - cadence == other.cadence && - itemId == other.itemId && - minimumConfig == other.minimumConfig && - modelType == other.modelType && - name == other.name && - billableMetricId == other.billableMetricId && - billedInAdvance == other.billedInAdvance && - billingCycleConfiguration == other.billingCycleConfiguration && - conversionRate == other.conversionRate && - conversionRateConfig == other.conversionRateConfig && - currency == other.currency && - dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && - externalPriceId == other.externalPriceId && - fixedPriceQuantity == other.fixedPriceQuantity && - invoiceGroupingKey == other.invoiceGroupingKey && - invoicingCycleConfiguration == other.invoicingCycleConfiguration && - metadata == other.metadata && - referenceId == other.referenceId && - additionalProperties == other.additionalProperties + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - private val hashCode: Int by lazy { - Objects.hash( - cadence, - itemId, - minimumConfig, - modelType, - name, - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - conversionRateConfig, - currency, - dimensionalPriceConfiguration, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - additionalProperties, - ) + return other is Adjustment && + percentageDiscount == other.percentageDiscount && + usageDiscount == other.usageDiscount && + amountDiscount == other.amountDiscount && + minimum == other.minimum && + maximum == other.maximum + } + + override fun hashCode(): Int = + Objects.hash(percentageDiscount, usageDiscount, amountDiscount, minimum, maximum) + + override fun toString(): String = + when { + percentageDiscount != null -> + "Adjustment{percentageDiscount=$percentageDiscount}" + usageDiscount != null -> "Adjustment{usageDiscount=$usageDiscount}" + amountDiscount != null -> "Adjustment{amountDiscount=$amountDiscount}" + minimum != null -> "Adjustment{minimum=$minimum}" + maximum != null -> "Adjustment{maximum=$maximum}" + _json != null -> "Adjustment{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Adjustment") } - override fun hashCode(): Int = hashCode + companion object { - override fun toString() = - "Minimum{cadence=$cadence, itemId=$itemId, minimumConfig=$minimumConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + fun ofPercentageDiscount(percentageDiscount: NewPercentageDiscount) = + Adjustment(percentageDiscount = percentageDiscount) + + fun ofUsageDiscount(usageDiscount: NewUsageDiscount) = + Adjustment(usageDiscount = usageDiscount) + + fun ofAmountDiscount(amountDiscount: NewAmountDiscount) = + Adjustment(amountDiscount = amountDiscount) + + fun ofMinimum(minimum: NewMinimum) = Adjustment(minimum = minimum) + + fun ofMaximum(maximum: NewMaximum) = Adjustment(maximum = maximum) + } + + /** + * An interface that defines how to map each variant of [Adjustment] to a value of type + * [T]. + */ + interface Visitor { + + fun visitPercentageDiscount(percentageDiscount: NewPercentageDiscount): T + + fun visitUsageDiscount(usageDiscount: NewUsageDiscount): T + + fun visitAmountDiscount(amountDiscount: NewAmountDiscount): T + + fun visitMinimum(minimum: NewMinimum): T + + fun visitMaximum(maximum: NewMaximum): T + + /** + * Maps an unknown variant of [Adjustment] to a value of type [T]. + * + * An instance of [Adjustment] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the + * SDK is unaware of. + * + * @throws OrbInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw OrbInvalidDataException("Unknown Adjustment: $json") + } + } + + internal class Deserializer : BaseDeserializer(Adjustment::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Adjustment { + val json = JsonValue.fromJsonNode(node) + val adjustmentType = json.asObject()?.get("adjustment_type")?.asString() + + when (adjustmentType) { + "percentage_discount" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Adjustment(percentageDiscount = it, _json = json) } + ?: Adjustment(_json = json) + } + "usage_discount" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(usageDiscount = it, _json = json) + } ?: Adjustment(_json = json) + } + "amount_discount" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(amountDiscount = it, _json = json) + } ?: Adjustment(_json = json) + } + "minimum" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(minimum = it, _json = json) + } ?: Adjustment(_json = json) + } + "maximum" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(maximum = it, _json = json) + } ?: Adjustment(_json = json) + } + } + + return Adjustment(_json = json) + } + } + + internal class Serializer : BaseSerializer(Adjustment::class) { + + override fun serialize( + value: Adjustment, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.percentageDiscount != null -> + generator.writeObject(value.percentageDiscount) + value.usageDiscount != null -> generator.writeObject(value.usageDiscount) + value.amountDiscount != null -> generator.writeObject(value.amountDiscount) + value.minimum != null -> generator.writeObject(value.minimum) + value.maximum != null -> generator.writeObject(value.maximum) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Adjustment") + } + } } } @@ -9040,539 +8652,587 @@ private constructor( return true } - return other is AddPrice && - allocationPrice == other.allocationPrice && - discounts == other.discounts && - endDate == other.endDate && - externalPriceId == other.externalPriceId && - maximumAmount == other.maximumAmount && - minimumAmount == other.minimumAmount && - planPhaseOrder == other.planPhaseOrder && - price == other.price && - priceId == other.priceId && - startDate == other.startDate && + return other is ReplaceAdjustment && + adjustment == other.adjustment && + replacesAdjustmentId == other.replacesAdjustmentId && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash( - allocationPrice, - discounts, - endDate, - externalPriceId, - maximumAmount, - minimumAmount, - planPhaseOrder, - price, - priceId, - startDate, - additionalProperties, - ) + Objects.hash(adjustment, replacesAdjustmentId, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "AddPrice{allocationPrice=$allocationPrice, discounts=$discounts, endDate=$endDate, externalPriceId=$externalPriceId, maximumAmount=$maximumAmount, minimumAmount=$minimumAmount, planPhaseOrder=$planPhaseOrder, price=$price, priceId=$priceId, startDate=$startDate, additionalProperties=$additionalProperties}" + "ReplaceAdjustment{adjustment=$adjustment, replacesAdjustmentId=$replacesAdjustmentId, additionalProperties=$additionalProperties}" } - @Deprecated("deprecated") - class ExternalMarketplace - @JsonCreator - private constructor(private val value: JsonField) : Enum { + class ReplacePrice + private constructor( + private val replacesPriceId: JsonField, + private val allocationPrice: JsonField, + private val discounts: JsonField>, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val maximumAmount: JsonField, + private val minimumAmount: JsonField, + private val price: JsonField, + private val priceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("replaces_price_id") + @ExcludeMissing + replacesPriceId: JsonField = JsonMissing.of(), + @JsonProperty("allocation_price") + @ExcludeMissing + allocationPrice: JsonField = JsonMissing.of(), + @JsonProperty("discounts") + @ExcludeMissing + discounts: JsonField> = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("maximum_amount") + @ExcludeMissing + maximumAmount: JsonField = JsonMissing.of(), + @JsonProperty("minimum_amount") + @ExcludeMissing + minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("price") @ExcludeMissing price: JsonField = JsonMissing.of(), + @JsonProperty("price_id") @ExcludeMissing priceId: JsonField = JsonMissing.of(), + ) : this( + replacesPriceId, + allocationPrice, + discounts, + externalPriceId, + fixedPriceQuantity, + maximumAmount, + minimumAmount, + price, + priceId, + mutableMapOf(), + ) /** - * Returns this class instance's raw value. + * The id of the price on the plan to replace in the subscription. * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API may respond with new members that the SDK is - * unaware of. + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { + fun replacesPriceId(): String = replacesPriceId.getRequired("replaces_price_id") - val GOOGLE = of("google") + /** + * The definition of a new allocation price to create and add to the subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun allocationPrice(): NewAllocationPrice? = allocationPrice.getNullable("allocation_price") - val AWS = of("aws") + /** + * [DEPRECATED] Use add_adjustments instead. The subscription's discounts for the + * replacement price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + @Deprecated("deprecated") + fun discounts(): List? = discounts.getNullable("discounts") - val AZURE = of("azure") + /** + * The external price id of the price to add to the subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") - fun of(value: String) = ExternalMarketplace(JsonField.of(value)) - } + /** + * The new quantity of the price, if the price is a fixed price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = fixedPriceQuantity.getNullable("fixed_price_quantity") - /** An enum containing [ExternalMarketplace]'s known values. */ - enum class Known { - GOOGLE, - AWS, - AZURE, - } + /** + * [DEPRECATED] Use add_adjustments instead. The subscription's maximum amount for the + * replacement price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + @Deprecated("deprecated") + fun maximumAmount(): String? = maximumAmount.getNullable("maximum_amount") /** - * An enum containing [ExternalMarketplace]'s known values, as well as an [_UNKNOWN] member. + * [DEPRECATED] Use add_adjustments instead. The subscription's minimum amount for the + * replacement price. * - * An instance of [ExternalMarketplace] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if the - * SDK is on an older version than the API, then the API may respond with new members that - * the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ - enum class Value { - GOOGLE, - AWS, - AZURE, - /** - * An enum member indicating that [ExternalMarketplace] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } + @Deprecated("deprecated") + fun minimumAmount(): String? = minimumAmount.getNullable("minimum_amount") /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. + * The definition of a new price to create and add to the subscription. * - * Use the [known] method instead if you're certain the value is always known or if you want - * to throw for the unknown case. + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ - fun value(): Value = - when (this) { - GOOGLE -> Value.GOOGLE - AWS -> Value.AWS - AZURE -> Value.AZURE - else -> Value._UNKNOWN - } + fun price(): Price? = price.getNullable("price") /** - * Returns an enum member corresponding to this class instance's value. + * The id of the price to add to the subscription. * - * Use the [value] method instead if you're uncertain the value is always known and don't - * want to throw for the unknown case. + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun priceId(): String? = priceId.getNullable("price_id") + + /** + * Returns the raw JSON value of [replacesPriceId]. * - * @throws OrbInvalidDataException if this class instance's value is a not a known member. + * Unlike [replacesPriceId], this method doesn't throw if the JSON field has an unexpected + * type. */ - fun known(): Known = - when (this) { - GOOGLE -> Known.GOOGLE - AWS -> Known.AWS - AZURE -> Known.AZURE - else -> throw OrbInvalidDataException("Unknown ExternalMarketplace: $value") - } + @JsonProperty("replaces_price_id") + @ExcludeMissing + fun _replacesPriceId(): JsonField = replacesPriceId /** - * Returns this class instance's primitive wire representation. + * Returns the raw JSON value of [allocationPrice]. * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. + * Unlike [allocationPrice], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("allocation_price") + @ExcludeMissing + fun _allocationPrice(): JsonField = allocationPrice + + /** + * Returns the raw JSON value of [discounts]. * - * @throws OrbInvalidDataException if this class instance's value does not have the expected - * primitive type. + * Unlike [discounts], this method doesn't throw if the JSON field has an unexpected type. */ - fun asString(): String = - _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + @Deprecated("deprecated") + @JsonProperty("discounts") + @ExcludeMissing + fun _discounts(): JsonField> = discounts - private var validated: Boolean = false + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId - fun validate(): ExternalMarketplace = apply { - if (validated) { - return@apply - } + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - known() - validated = true - } + /** + * Returns the raw JSON value of [maximumAmount]. + * + * Unlike [maximumAmount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @Deprecated("deprecated") + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** + * Returns the raw JSON value of [minimumAmount]. + * + * Unlike [minimumAmount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @Deprecated("deprecated") + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount /** - * Returns a score indicating how many valid values are contained in this object - * recursively. + * Returns the raw JSON value of [price]. * - * Used for best match union deserialization. + * Unlike [price], this method doesn't throw if the JSON field has an unexpected type. */ - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + @JsonProperty("price") @ExcludeMissing fun _price(): JsonField = price - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * Returns the raw JSON value of [priceId]. + * + * Unlike [priceId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId - return other is ExternalMarketplace && value == other.value + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) } - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by setting - * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to - * `null`. - */ - class Metadata - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) fun toBuilder() = Builder().from(this) companion object { - /** Returns a mutable builder for constructing an instance of [Metadata]. */ + /** + * Returns a mutable builder for constructing an instance of [ReplacePrice]. + * + * The following fields are required: + * ```kotlin + * .replacesPriceId() + * ``` + */ fun builder() = Builder() } - /** A builder for [Metadata]. */ + /** A builder for [ReplacePrice]. */ class Builder internal constructor() { + private var replacesPriceId: JsonField? = null + private var allocationPrice: JsonField = JsonMissing.of() + private var discounts: JsonField>? = null + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var maximumAmount: JsonField = JsonMissing.of() + private var minimumAmount: JsonField = JsonMissing.of() + private var price: JsonField = JsonMissing.of() + private var priceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(metadata: Metadata) = apply { - additionalProperties = metadata.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) + internal fun from(replacePrice: ReplacePrice) = apply { + replacesPriceId = replacePrice.replacesPriceId + allocationPrice = replacePrice.allocationPrice + discounts = replacePrice.discounts.map { it.toMutableList() } + externalPriceId = replacePrice.externalPriceId + fixedPriceQuantity = replacePrice.fixedPriceQuantity + maximumAmount = replacePrice.maximumAmount + minimumAmount = replacePrice.minimumAmount + price = replacePrice.price + priceId = replacePrice.priceId + additionalProperties = replacePrice.additionalProperties.toMutableMap() } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** The id of the price on the plan to replace in the subscription. */ + fun replacesPriceId(replacesPriceId: String) = + replacesPriceId(JsonField.of(replacesPriceId)) /** - * Returns an immutable instance of [Metadata]. + * Sets [Builder.replacesPriceId] to an arbitrary JSON value. * - * Further updates to this [Builder] will not mutate the returned instance. + * You should usually call [Builder.replacesPriceId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply + fun replacesPriceId(replacesPriceId: JsonField) = apply { + this.replacesPriceId = replacesPriceId } - validated = true - } + /** The definition of a new allocation price to create and add to the subscription. */ + fun allocationPrice(allocationPrice: NewAllocationPrice?) = + allocationPrice(JsonField.ofNullable(allocationPrice)) - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false + /** + * Sets [Builder.allocationPrice] to an arbitrary JSON value. + * + * You should usually call [Builder.allocationPrice] with a well-typed + * [NewAllocationPrice] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun allocationPrice(allocationPrice: JsonField) = apply { + this.allocationPrice = allocationPrice } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + /** + * [DEPRECATED] Use add_adjustments instead. The subscription's discounts for the + * replacement price. + */ + @Deprecated("deprecated") + fun discounts(discounts: List?) = + discounts(JsonField.ofNullable(discounts)) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + /** + * Sets [Builder.discounts] to an arbitrary JSON value. + * + * You should usually call [Builder.discounts] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + @Deprecated("deprecated") + fun discounts(discounts: JsonField>) = apply { + this.discounts = discounts.map { it.toMutableList() } } - return other is Metadata && additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - class RemoveAdjustment - private constructor( - private val adjustmentId: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("adjustment_id") - @ExcludeMissing - adjustmentId: JsonField = JsonMissing.of() - ) : this(adjustmentId, mutableMapOf()) - - /** - * The id of the adjustment to remove on the subscription. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun adjustmentId(): String = adjustmentId.getRequired("adjustment_id") - - /** - * Returns the raw JSON value of [adjustmentId]. - * - * Unlike [adjustmentId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("adjustment_id") - @ExcludeMissing - fun _adjustmentId(): JsonField = adjustmentId - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) + /** + * Adds a single [DiscountOverride] to [discounts]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + @Deprecated("deprecated") + fun addDiscount(discount: DiscountOverride) = apply { + discounts = + (discounts ?: JsonField.of(mutableListOf())).also { + checkKnown("discounts", it).add(discount) + } + } - companion object { + /** The external price id of the price to add to the subscription. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) /** - * Returns a mutable builder for constructing an instance of [RemoveAdjustment]. + * Sets [Builder.externalPriceId] to an arbitrary JSON value. * - * The following fields are required: - * ```kotlin - * .adjustmentId() - * ``` + * You should usually call [Builder.externalPriceId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun builder() = Builder() - } + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } - /** A builder for [RemoveAdjustment]. */ - class Builder internal constructor() { + /** The new quantity of the price, if the price is a fixed price. */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) - private var adjustmentId: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) - internal fun from(removeAdjustment: RemoveAdjustment) = apply { - adjustmentId = removeAdjustment.adjustmentId - additionalProperties = removeAdjustment.additionalProperties.toMutableMap() + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity } - /** The id of the adjustment to remove on the subscription. */ - fun adjustmentId(adjustmentId: String) = adjustmentId(JsonField.of(adjustmentId)) + /** + * [DEPRECATED] Use add_adjustments instead. The subscription's maximum amount for the + * replacement price. + */ + @Deprecated("deprecated") + fun maximumAmount(maximumAmount: String?) = + maximumAmount(JsonField.ofNullable(maximumAmount)) /** - * Sets [Builder.adjustmentId] to an arbitrary JSON value. + * Sets [Builder.maximumAmount] to an arbitrary JSON value. * - * You should usually call [Builder.adjustmentId] with a well-typed [String] value + * You should usually call [Builder.maximumAmount] with a well-typed [String] value * instead. This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun adjustmentId(adjustmentId: JsonField) = apply { - this.adjustmentId = adjustmentId - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) + @Deprecated("deprecated") + fun maximumAmount(maximumAmount: JsonField) = apply { + this.maximumAmount = maximumAmount } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * [DEPRECATED] Use add_adjustments instead. The subscription's minimum amount for the + * replacement price. + */ + @Deprecated("deprecated") + fun minimumAmount(minimumAmount: String?) = + minimumAmount(JsonField.ofNullable(minimumAmount)) - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) + /** + * Sets [Builder.minimumAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumAmount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + @Deprecated("deprecated") + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** The definition of a new price to create and add to the subscription. */ + fun price(price: Price?) = price(JsonField.ofNullable(price)) /** - * Returns an immutable instance of [RemoveAdjustment]. - * - * Further updates to this [Builder] will not mutate the returned instance. + * Sets [Builder.price] to an arbitrary JSON value. * - * The following fields are required: - * ```kotlin - * .adjustmentId() - * ``` - * - * @throws IllegalStateException if any required field is unset. + * You should usually call [Builder.price] with a well-typed [Price] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. */ - fun build(): RemoveAdjustment = - RemoveAdjustment( - checkRequired("adjustmentId", adjustmentId), - additionalProperties.toMutableMap(), - ) - } + fun price(price: JsonField) = apply { this.price = price } - private var validated: Boolean = false + /** Alias for calling [price] with `Price.ofUnit(unit)`. */ + fun price(unit: NewSubscriptionUnitPrice) = price(Price.ofUnit(unit)) - fun validate(): RemoveAdjustment = apply { - if (validated) { - return@apply - } + /** Alias for calling [price] with `Price.ofPackage(package_)`. */ + fun price(package_: NewSubscriptionPackagePrice) = price(Price.ofPackage(package_)) - adjustmentId() - validated = true - } + /** Alias for calling [price] with `Price.ofMatrix(matrix)`. */ + fun price(matrix: NewSubscriptionMatrixPrice) = price(Price.ofMatrix(matrix)) - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** Alias for calling [price] with `Price.ofTiered(tiered)`. */ + fun price(tiered: NewSubscriptionTieredPrice) = price(Price.ofTiered(tiered)) - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = (if (adjustmentId.asKnown() == null) 0 else 1) + /** Alias for calling [price] with `Price.ofBulk(bulk)`. */ + fun price(bulk: NewSubscriptionBulkPrice) = price(Price.ofBulk(bulk)) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * Alias for calling [price] with `Price.ofThresholdTotalAmount(thresholdTotalAmount)`. + */ + fun price(thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice) = + price(Price.ofThresholdTotalAmount(thresholdTotalAmount)) - return other is RemoveAdjustment && - adjustmentId == other.adjustmentId && - additionalProperties == other.additionalProperties - } + /** Alias for calling [price] with `Price.ofTieredPackage(tieredPackage)`. */ + fun price(tieredPackage: NewSubscriptionTieredPackagePrice) = + price(Price.ofTieredPackage(tieredPackage)) - private val hashCode: Int by lazy { Objects.hash(adjustmentId, additionalProperties) } + /** Alias for calling [price] with `Price.ofTieredWithMinimum(tieredWithMinimum)`. */ + fun price(tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice) = + price(Price.ofTieredWithMinimum(tieredWithMinimum)) - override fun hashCode(): Int = hashCode + /** Alias for calling [price] with `Price.ofUnitWithPercent(unitWithPercent)`. */ + fun price(unitWithPercent: NewSubscriptionUnitWithPercentPrice) = + price(Price.ofUnitWithPercent(unitWithPercent)) - override fun toString() = - "RemoveAdjustment{adjustmentId=$adjustmentId, additionalProperties=$additionalProperties}" - } + /** + * Alias for calling [price] with + * `Price.ofPackageWithAllocation(packageWithAllocation)`. + */ + fun price(packageWithAllocation: NewSubscriptionPackageWithAllocationPrice) = + price(Price.ofPackageWithAllocation(packageWithAllocation)) - class RemovePrice - private constructor( - private val externalPriceId: JsonField, - private val priceId: JsonField, - private val additionalProperties: MutableMap, - ) { + /** + * Alias for calling [price] with `Price.ofTieredWithProration(tieredWithProration)`. + */ + fun price(tieredWithProration: NewSubscriptionTierWithProrationPrice) = + price(Price.ofTieredWithProration(tieredWithProration)) - @JsonCreator - private constructor( - @JsonProperty("external_price_id") - @ExcludeMissing - externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("price_id") @ExcludeMissing priceId: JsonField = JsonMissing.of(), - ) : this(externalPriceId, priceId, mutableMapOf()) + /** Alias for calling [price] with `Price.ofUnitWithProration(unitWithProration)`. */ + fun price(unitWithProration: NewSubscriptionUnitWithProrationPrice) = + price(Price.ofUnitWithProration(unitWithProration)) - /** - * The external price id of the price to remove on the subscription. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + /** Alias for calling [price] with `Price.ofGroupedAllocation(groupedAllocation)`. */ + fun price(groupedAllocation: NewSubscriptionGroupedAllocationPrice) = + price(Price.ofGroupedAllocation(groupedAllocation)) - /** - * The id of the price to remove on the subscription. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun priceId(): String? = priceId.getNullable("price_id") + /** + * Alias for calling [price] with + * `Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)`. + */ + fun price(groupedWithProratedMinimum: NewSubscriptionGroupedWithProratedMinimumPrice) = + price(Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)) - /** - * Returns the raw JSON value of [externalPriceId]. - * - * Unlike [externalPriceId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId + /** Alias for calling [price] with `Price.ofBulkWithProration(bulkWithProration)`. */ + fun price(bulkWithProration: NewSubscriptionBulkWithProrationPrice) = + price(Price.ofBulkWithProration(bulkWithProration)) - /** - * Returns the raw JSON value of [priceId]. - * - * Unlike [priceId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId + /** + * Alias for calling [price] with + * `Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)`. + */ + fun price( + scalableMatrixWithUnitPricing: NewSubscriptionScalableMatrixWithUnitPricingPrice + ) = price(Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)) - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** + * Alias for calling [price] with + * `Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)`. + */ + fun price( + scalableMatrixWithTieredPricing: NewSubscriptionScalableMatrixWithTieredPricingPrice + ) = price(Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)) - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** + * Alias for calling [price] with + * `Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)`. + */ + fun price(cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice) = + price(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) - fun toBuilder() = Builder().from(this) + /** + * Alias for calling [price] with + * `Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)`. + */ + fun price(maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice) = + price(Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)) - companion object { + /** + * Alias for calling [price] with + * `Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)`. + */ + fun price(groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice) = + price(Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)) - /** Returns a mutable builder for constructing an instance of [RemovePrice]. */ - fun builder() = Builder() - } + /** + * Alias for calling [price] with + * `Price.ofMatrixWithDisplayName(matrixWithDisplayName)`. + */ + fun price(matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice) = + price(Price.ofMatrixWithDisplayName(matrixWithDisplayName)) - /** A builder for [RemovePrice]. */ - class Builder internal constructor() { + /** + * Alias for calling [price] with `Price.ofGroupedTieredPackage(groupedTieredPackage)`. + */ + fun price(groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice) = + price(Price.ofGroupedTieredPackage(groupedTieredPackage)) - private var externalPriceId: JsonField = JsonMissing.of() - private var priceId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + /** + * Alias for calling [price] with `Price.ofMatrixWithAllocation(matrixWithAllocation)`. + */ + fun price(matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice) = + price(Price.ofMatrixWithAllocation(matrixWithAllocation)) - internal fun from(removePrice: RemovePrice) = apply { - externalPriceId = removePrice.externalPriceId - priceId = removePrice.priceId - additionalProperties = removePrice.additionalProperties.toMutableMap() - } + /** + * Alias for calling [price] with + * `Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)`. + */ + fun price(tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice) = + price(Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)) - /** The external price id of the price to remove on the subscription. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) + /** Alias for calling [price] with `Price.ofGroupedTiered(groupedTiered)`. */ + fun price(groupedTiered: NewSubscriptionGroupedTieredPrice) = + price(Price.ofGroupedTiered(groupedTiered)) /** - * Sets [Builder.externalPriceId] to an arbitrary JSON value. - * - * You should usually call [Builder.externalPriceId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. + * Alias for calling [price] with + * `Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)`. */ - fun externalPriceId(externalPriceId: JsonField) = apply { - this.externalPriceId = externalPriceId - } + fun price(groupedWithMinMaxThresholds: Price.GroupedWithMinMaxThresholds) = + price(Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)) - /** The id of the price to remove on the subscription. */ + /** Alias for calling [price] with `Price.ofMinimum(minimum)`. */ + fun price(minimum: NewSubscriptionMinimumCompositePrice) = + price(Price.ofMinimum(minimum)) + + /** The id of the price to add to the subscription. */ fun priceId(priceId: String?) = priceId(JsonField.ofNullable(priceId)) /** @@ -9604,22 +9264,47 @@ private constructor( } /** - * Returns an immutable instance of [RemovePrice]. + * Returns an immutable instance of [ReplacePrice]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .replacesPriceId() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ - fun build(): RemovePrice = - RemovePrice(externalPriceId, priceId, additionalProperties.toMutableMap()) - } - - private var validated: Boolean = false - - fun validate(): RemovePrice = apply { - if (validated) { - return@apply + fun build(): ReplacePrice = + ReplacePrice( + checkRequired("replacesPriceId", replacesPriceId), + allocationPrice, + (discounts ?: JsonMissing.of()).map { it.toImmutable() }, + externalPriceId, + fixedPriceQuantity, + maximumAmount, + minimumAmount, + price, + priceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ReplacePrice = apply { + if (validated) { + return@apply } + replacesPriceId() + allocationPrice()?.validate() + discounts()?.forEach { it.validate() } externalPriceId() + fixedPriceQuantity() + maximumAmount() + minimumAmount() + price()?.validate() priceId() validated = true } @@ -9639,3922 +9324,1203 @@ private constructor( * Used for best match union deserialization. */ internal fun validity(): Int = - (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (replacesPriceId.asKnown() == null) 0 else 1) + + (allocationPrice.asKnown()?.validity() ?: 0) + + (discounts.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (maximumAmount.asKnown() == null) 0 else 1) + + (if (minimumAmount.asKnown() == null) 0 else 1) + + (price.asKnown()?.validity() ?: 0) + (if (priceId.asKnown() == null) 0 else 1) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** The definition of a new price to create and add to the subscription. */ + @JsonDeserialize(using = Price.Deserializer::class) + @JsonSerialize(using = Price.Serializer::class) + class Price + private constructor( + private val unit: NewSubscriptionUnitPrice? = null, + private val package_: NewSubscriptionPackagePrice? = null, + private val matrix: NewSubscriptionMatrixPrice? = null, + private val tiered: NewSubscriptionTieredPrice? = null, + private val bulk: NewSubscriptionBulkPrice? = null, + private val thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice? = null, + private val tieredPackage: NewSubscriptionTieredPackagePrice? = null, + private val tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice? = null, + private val unitWithPercent: NewSubscriptionUnitWithPercentPrice? = null, + private val packageWithAllocation: NewSubscriptionPackageWithAllocationPrice? = null, + private val tieredWithProration: NewSubscriptionTierWithProrationPrice? = null, + private val unitWithProration: NewSubscriptionUnitWithProrationPrice? = null, + private val groupedAllocation: NewSubscriptionGroupedAllocationPrice? = null, + private val groupedWithProratedMinimum: + NewSubscriptionGroupedWithProratedMinimumPrice? = + null, + private val bulkWithProration: NewSubscriptionBulkWithProrationPrice? = null, + private val scalableMatrixWithUnitPricing: + NewSubscriptionScalableMatrixWithUnitPricingPrice? = + null, + private val scalableMatrixWithTieredPricing: + NewSubscriptionScalableMatrixWithTieredPricingPrice? = + null, + private val cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice? = null, + private val maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice? = null, + private val groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice? = + null, + private val matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice? = null, + private val groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice? = null, + private val matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice? = null, + private val tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice? = + null, + private val groupedTiered: NewSubscriptionGroupedTieredPrice? = null, + private val groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds? = null, + private val minimum: NewSubscriptionMinimumCompositePrice? = null, + private val _json: JsonValue? = null, + ) { - return other is RemovePrice && - externalPriceId == other.externalPriceId && - priceId == other.priceId && - additionalProperties == other.additionalProperties - } + fun unit(): NewSubscriptionUnitPrice? = unit - private val hashCode: Int by lazy { - Objects.hash(externalPriceId, priceId, additionalProperties) - } + fun package_(): NewSubscriptionPackagePrice? = package_ - override fun hashCode(): Int = hashCode + fun matrix(): NewSubscriptionMatrixPrice? = matrix - override fun toString() = - "RemovePrice{externalPriceId=$externalPriceId, priceId=$priceId, additionalProperties=$additionalProperties}" - } + fun tiered(): NewSubscriptionTieredPrice? = tiered - class ReplaceAdjustment - private constructor( - private val adjustment: JsonField, - private val replacesAdjustmentId: JsonField, - private val additionalProperties: MutableMap, - ) { + fun bulk(): NewSubscriptionBulkPrice? = bulk - @JsonCreator - private constructor( - @JsonProperty("adjustment") - @ExcludeMissing - adjustment: JsonField = JsonMissing.of(), - @JsonProperty("replaces_adjustment_id") - @ExcludeMissing - replacesAdjustmentId: JsonField = JsonMissing.of(), - ) : this(adjustment, replacesAdjustmentId, mutableMapOf()) + fun thresholdTotalAmount(): NewSubscriptionThresholdTotalAmountPrice? = + thresholdTotalAmount - /** - * The definition of a new adjustment to create and add to the subscription. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun adjustment(): Adjustment = adjustment.getRequired("adjustment") + fun tieredPackage(): NewSubscriptionTieredPackagePrice? = tieredPackage - /** - * The id of the adjustment on the plan to replace in the subscription. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun replacesAdjustmentId(): String = - replacesAdjustmentId.getRequired("replaces_adjustment_id") + fun tieredWithMinimum(): NewSubscriptionTieredWithMinimumPrice? = tieredWithMinimum - /** - * Returns the raw JSON value of [adjustment]. - * - * Unlike [adjustment], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("adjustment") - @ExcludeMissing - fun _adjustment(): JsonField = adjustment + fun unitWithPercent(): NewSubscriptionUnitWithPercentPrice? = unitWithPercent - /** - * Returns the raw JSON value of [replacesAdjustmentId]. - * - * Unlike [replacesAdjustmentId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("replaces_adjustment_id") - @ExcludeMissing - fun _replacesAdjustmentId(): JsonField = replacesAdjustmentId + fun packageWithAllocation(): NewSubscriptionPackageWithAllocationPrice? = + packageWithAllocation - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + fun tieredWithProration(): NewSubscriptionTierWithProrationPrice? = tieredWithProration - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + fun unitWithProration(): NewSubscriptionUnitWithProrationPrice? = unitWithProration - fun toBuilder() = Builder().from(this) + fun groupedAllocation(): NewSubscriptionGroupedAllocationPrice? = groupedAllocation - companion object { + fun groupedWithProratedMinimum(): NewSubscriptionGroupedWithProratedMinimumPrice? = + groupedWithProratedMinimum - /** - * Returns a mutable builder for constructing an instance of [ReplaceAdjustment]. - * - * The following fields are required: - * ```kotlin - * .adjustment() - * .replacesAdjustmentId() - * ``` - */ - fun builder() = Builder() - } + fun bulkWithProration(): NewSubscriptionBulkWithProrationPrice? = bulkWithProration - /** A builder for [ReplaceAdjustment]. */ - class Builder internal constructor() { + fun scalableMatrixWithUnitPricing(): + NewSubscriptionScalableMatrixWithUnitPricingPrice? = scalableMatrixWithUnitPricing - private var adjustment: JsonField? = null - private var replacesAdjustmentId: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() + fun scalableMatrixWithTieredPricing(): + NewSubscriptionScalableMatrixWithTieredPricingPrice? = + scalableMatrixWithTieredPricing - internal fun from(replaceAdjustment: ReplaceAdjustment) = apply { - adjustment = replaceAdjustment.adjustment - replacesAdjustmentId = replaceAdjustment.replacesAdjustmentId - additionalProperties = replaceAdjustment.additionalProperties.toMutableMap() - } + fun cumulativeGroupedBulk(): NewSubscriptionCumulativeGroupedBulkPrice? = + cumulativeGroupedBulk - /** The definition of a new adjustment to create and add to the subscription. */ - fun adjustment(adjustment: Adjustment) = adjustment(JsonField.of(adjustment)) + fun maxGroupTieredPackage(): NewSubscriptionMaxGroupTieredPackagePrice? = + maxGroupTieredPackage - /** - * Sets [Builder.adjustment] to an arbitrary JSON value. - * - * You should usually call [Builder.adjustment] with a well-typed [Adjustment] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun adjustment(adjustment: JsonField) = apply { - this.adjustment = adjustment - } + fun groupedWithMeteredMinimum(): NewSubscriptionGroupedWithMeteredMinimumPrice? = + groupedWithMeteredMinimum - /** - * Alias for calling [adjustment] with - * `Adjustment.ofPercentageDiscount(percentageDiscount)`. - */ - fun adjustment(percentageDiscount: NewPercentageDiscount) = - adjustment(Adjustment.ofPercentageDiscount(percentageDiscount)) + fun matrixWithDisplayName(): NewSubscriptionMatrixWithDisplayNamePrice? = + matrixWithDisplayName - /** - * Alias for calling [adjustment] with the following: - * ```kotlin - * NewPercentageDiscount.builder() - * .adjustmentType(NewPercentageDiscount.AdjustmentType.PERCENTAGE_DISCOUNT) - * .percentageDiscount(percentageDiscount) - * .build() - * ``` - */ - fun percentageDiscountAdjustment(percentageDiscount: Double) = - adjustment( - NewPercentageDiscount.builder() - .adjustmentType(NewPercentageDiscount.AdjustmentType.PERCENTAGE_DISCOUNT) - .percentageDiscount(percentageDiscount) - .build() - ) + fun groupedTieredPackage(): NewSubscriptionGroupedTieredPackagePrice? = + groupedTieredPackage - /** Alias for calling [adjustment] with `Adjustment.ofUsageDiscount(usageDiscount)`. */ - fun adjustment(usageDiscount: NewUsageDiscount) = - adjustment(Adjustment.ofUsageDiscount(usageDiscount)) + fun matrixWithAllocation(): NewSubscriptionMatrixWithAllocationPrice? = + matrixWithAllocation - /** - * Alias for calling [adjustment] with the following: - * ```kotlin - * NewUsageDiscount.builder() - * .adjustmentType(NewUsageDiscount.AdjustmentType.USAGE_DISCOUNT) - * .usageDiscount(usageDiscount) - * .build() - * ``` - */ - fun usageDiscountAdjustment(usageDiscount: Double) = - adjustment( - NewUsageDiscount.builder() - .adjustmentType(NewUsageDiscount.AdjustmentType.USAGE_DISCOUNT) - .usageDiscount(usageDiscount) - .build() - ) + fun tieredPackageWithMinimum(): NewSubscriptionTieredPackageWithMinimumPrice? = + tieredPackageWithMinimum - /** - * Alias for calling [adjustment] with `Adjustment.ofAmountDiscount(amountDiscount)`. - */ - fun adjustment(amountDiscount: NewAmountDiscount) = - adjustment(Adjustment.ofAmountDiscount(amountDiscount)) + fun groupedTiered(): NewSubscriptionGroupedTieredPrice? = groupedTiered - /** - * Alias for calling [adjustment] with the following: - * ```kotlin - * NewAmountDiscount.builder() - * .adjustmentType(NewAmountDiscount.AdjustmentType.AMOUNT_DISCOUNT) - * .amountDiscount(amountDiscount) - * .build() - * ``` - */ - fun amountDiscountAdjustment(amountDiscount: String) = - adjustment( - NewAmountDiscount.builder() - .adjustmentType(NewAmountDiscount.AdjustmentType.AMOUNT_DISCOUNT) - .amountDiscount(amountDiscount) - .build() - ) + fun groupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds? = + groupedWithMinMaxThresholds - /** Alias for calling [adjustment] with `Adjustment.ofMinimum(minimum)`. */ - fun adjustment(minimum: NewMinimum) = adjustment(Adjustment.ofMinimum(minimum)) + fun minimum(): NewSubscriptionMinimumCompositePrice? = minimum - /** Alias for calling [adjustment] with `Adjustment.ofMaximum(maximum)`. */ - fun adjustment(maximum: NewMaximum) = adjustment(Adjustment.ofMaximum(maximum)) + fun isUnit(): Boolean = unit != null - /** - * Alias for calling [adjustment] with the following: - * ```kotlin - * NewMaximum.builder() - * .adjustmentType(NewMaximum.AdjustmentType.MAXIMUM) - * .maximumAmount(maximumAmount) - * .build() - * ``` - */ - fun maximumAdjustment(maximumAmount: String) = - adjustment( - NewMaximum.builder() - .adjustmentType(NewMaximum.AdjustmentType.MAXIMUM) - .maximumAmount(maximumAmount) - .build() - ) + fun isPackage(): Boolean = package_ != null - /** The id of the adjustment on the plan to replace in the subscription. */ - fun replacesAdjustmentId(replacesAdjustmentId: String) = - replacesAdjustmentId(JsonField.of(replacesAdjustmentId)) + fun isMatrix(): Boolean = matrix != null - /** - * Sets [Builder.replacesAdjustmentId] to an arbitrary JSON value. - * - * You should usually call [Builder.replacesAdjustmentId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun replacesAdjustmentId(replacesAdjustmentId: JsonField) = apply { - this.replacesAdjustmentId = replacesAdjustmentId - } + fun isTiered(): Boolean = tiered != null - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun isBulk(): Boolean = bulk != null - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun isThresholdTotalAmount(): Boolean = thresholdTotalAmount != null - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun isTieredPackage(): Boolean = tieredPackage != null - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun isTieredWithMinimum(): Boolean = tieredWithMinimum != null - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun isUnitWithPercent(): Boolean = unitWithPercent != null - /** - * Returns an immutable instance of [ReplaceAdjustment]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```kotlin - * .adjustment() - * .replacesAdjustmentId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): ReplaceAdjustment = - ReplaceAdjustment( - checkRequired("adjustment", adjustment), - checkRequired("replacesAdjustmentId", replacesAdjustmentId), - additionalProperties.toMutableMap(), - ) - } + fun isPackageWithAllocation(): Boolean = packageWithAllocation != null - private var validated: Boolean = false + fun isTieredWithProration(): Boolean = tieredWithProration != null - fun validate(): ReplaceAdjustment = apply { - if (validated) { - return@apply - } + fun isUnitWithProration(): Boolean = unitWithProration != null - adjustment().validate() - replacesAdjustmentId() - validated = true - } + fun isGroupedAllocation(): Boolean = groupedAllocation != null - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + fun isGroupedWithProratedMinimum(): Boolean = groupedWithProratedMinimum != null - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (adjustment.asKnown()?.validity() ?: 0) + - (if (replacesAdjustmentId.asKnown() == null) 0 else 1) + fun isBulkWithProration(): Boolean = bulkWithProration != null - /** The definition of a new adjustment to create and add to the subscription. */ - @JsonDeserialize(using = Adjustment.Deserializer::class) - @JsonSerialize(using = Adjustment.Serializer::class) - class Adjustment - private constructor( - private val percentageDiscount: NewPercentageDiscount? = null, - private val usageDiscount: NewUsageDiscount? = null, - private val amountDiscount: NewAmountDiscount? = null, - private val minimum: NewMinimum? = null, - private val maximum: NewMaximum? = null, - private val _json: JsonValue? = null, - ) { + fun isScalableMatrixWithUnitPricing(): Boolean = scalableMatrixWithUnitPricing != null - fun percentageDiscount(): NewPercentageDiscount? = percentageDiscount + fun isScalableMatrixWithTieredPricing(): Boolean = + scalableMatrixWithTieredPricing != null - fun usageDiscount(): NewUsageDiscount? = usageDiscount + fun isCumulativeGroupedBulk(): Boolean = cumulativeGroupedBulk != null - fun amountDiscount(): NewAmountDiscount? = amountDiscount + fun isMaxGroupTieredPackage(): Boolean = maxGroupTieredPackage != null - fun minimum(): NewMinimum? = minimum + fun isGroupedWithMeteredMinimum(): Boolean = groupedWithMeteredMinimum != null - fun maximum(): NewMaximum? = maximum + fun isMatrixWithDisplayName(): Boolean = matrixWithDisplayName != null - fun isPercentageDiscount(): Boolean = percentageDiscount != null + fun isGroupedTieredPackage(): Boolean = groupedTieredPackage != null - fun isUsageDiscount(): Boolean = usageDiscount != null + fun isMatrixWithAllocation(): Boolean = matrixWithAllocation != null - fun isAmountDiscount(): Boolean = amountDiscount != null + fun isTieredPackageWithMinimum(): Boolean = tieredPackageWithMinimum != null + + fun isGroupedTiered(): Boolean = groupedTiered != null + + fun isGroupedWithMinMaxThresholds(): Boolean = groupedWithMinMaxThresholds != null fun isMinimum(): Boolean = minimum != null - fun isMaximum(): Boolean = maximum != null + fun asUnit(): NewSubscriptionUnitPrice = unit.getOrThrow("unit") - fun asPercentageDiscount(): NewPercentageDiscount = - percentageDiscount.getOrThrow("percentageDiscount") + fun asPackage(): NewSubscriptionPackagePrice = package_.getOrThrow("package_") - fun asUsageDiscount(): NewUsageDiscount = usageDiscount.getOrThrow("usageDiscount") + fun asMatrix(): NewSubscriptionMatrixPrice = matrix.getOrThrow("matrix") - fun asAmountDiscount(): NewAmountDiscount = amountDiscount.getOrThrow("amountDiscount") + fun asTiered(): NewSubscriptionTieredPrice = tiered.getOrThrow("tiered") - fun asMinimum(): NewMinimum = minimum.getOrThrow("minimum") + fun asBulk(): NewSubscriptionBulkPrice = bulk.getOrThrow("bulk") - fun asMaximum(): NewMaximum = maximum.getOrThrow("maximum") + fun asThresholdTotalAmount(): NewSubscriptionThresholdTotalAmountPrice = + thresholdTotalAmount.getOrThrow("thresholdTotalAmount") - fun _json(): JsonValue? = _json + fun asTieredPackage(): NewSubscriptionTieredPackagePrice = + tieredPackage.getOrThrow("tieredPackage") - fun accept(visitor: Visitor): T = - when { - percentageDiscount != null -> - visitor.visitPercentageDiscount(percentageDiscount) - usageDiscount != null -> visitor.visitUsageDiscount(usageDiscount) - amountDiscount != null -> visitor.visitAmountDiscount(amountDiscount) - minimum != null -> visitor.visitMinimum(minimum) - maximum != null -> visitor.visitMaximum(maximum) - else -> visitor.unknown(_json) - } + fun asTieredWithMinimum(): NewSubscriptionTieredWithMinimumPrice = + tieredWithMinimum.getOrThrow("tieredWithMinimum") - private var validated: Boolean = false + fun asUnitWithPercent(): NewSubscriptionUnitWithPercentPrice = + unitWithPercent.getOrThrow("unitWithPercent") - fun validate(): Adjustment = apply { - if (validated) { - return@apply - } + fun asPackageWithAllocation(): NewSubscriptionPackageWithAllocationPrice = + packageWithAllocation.getOrThrow("packageWithAllocation") - accept( - object : Visitor { - override fun visitPercentageDiscount( - percentageDiscount: NewPercentageDiscount - ) { - percentageDiscount.validate() - } + fun asTieredWithProration(): NewSubscriptionTierWithProrationPrice = + tieredWithProration.getOrThrow("tieredWithProration") - override fun visitUsageDiscount(usageDiscount: NewUsageDiscount) { - usageDiscount.validate() - } + fun asUnitWithProration(): NewSubscriptionUnitWithProrationPrice = + unitWithProration.getOrThrow("unitWithProration") - override fun visitAmountDiscount(amountDiscount: NewAmountDiscount) { - amountDiscount.validate() - } + fun asGroupedAllocation(): NewSubscriptionGroupedAllocationPrice = + groupedAllocation.getOrThrow("groupedAllocation") - override fun visitMinimum(minimum: NewMinimum) { - minimum.validate() - } + fun asGroupedWithProratedMinimum(): NewSubscriptionGroupedWithProratedMinimumPrice = + groupedWithProratedMinimum.getOrThrow("groupedWithProratedMinimum") - override fun visitMaximum(maximum: NewMaximum) { - maximum.validate() - } - } - ) - validated = true - } + fun asBulkWithProration(): NewSubscriptionBulkWithProrationPrice = + bulkWithProration.getOrThrow("bulkWithProration") - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + fun asScalableMatrixWithUnitPricing(): + NewSubscriptionScalableMatrixWithUnitPricingPrice = + scalableMatrixWithUnitPricing.getOrThrow("scalableMatrixWithUnitPricing") - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitPercentageDiscount( - percentageDiscount: NewPercentageDiscount - ) = percentageDiscount.validity() - - override fun visitUsageDiscount(usageDiscount: NewUsageDiscount) = - usageDiscount.validity() + fun asScalableMatrixWithTieredPricing(): + NewSubscriptionScalableMatrixWithTieredPricingPrice = + scalableMatrixWithTieredPricing.getOrThrow("scalableMatrixWithTieredPricing") - override fun visitAmountDiscount(amountDiscount: NewAmountDiscount) = - amountDiscount.validity() + fun asCumulativeGroupedBulk(): NewSubscriptionCumulativeGroupedBulkPrice = + cumulativeGroupedBulk.getOrThrow("cumulativeGroupedBulk") - override fun visitMinimum(minimum: NewMinimum) = minimum.validity() + fun asMaxGroupTieredPackage(): NewSubscriptionMaxGroupTieredPackagePrice = + maxGroupTieredPackage.getOrThrow("maxGroupTieredPackage") - override fun visitMaximum(maximum: NewMaximum) = maximum.validity() + fun asGroupedWithMeteredMinimum(): NewSubscriptionGroupedWithMeteredMinimumPrice = + groupedWithMeteredMinimum.getOrThrow("groupedWithMeteredMinimum") - override fun unknown(json: JsonValue?) = 0 - } - ) + fun asMatrixWithDisplayName(): NewSubscriptionMatrixWithDisplayNamePrice = + matrixWithDisplayName.getOrThrow("matrixWithDisplayName") - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + fun asGroupedTieredPackage(): NewSubscriptionGroupedTieredPackagePrice = + groupedTieredPackage.getOrThrow("groupedTieredPackage") - return other is Adjustment && - percentageDiscount == other.percentageDiscount && - usageDiscount == other.usageDiscount && - amountDiscount == other.amountDiscount && - minimum == other.minimum && - maximum == other.maximum - } + fun asMatrixWithAllocation(): NewSubscriptionMatrixWithAllocationPrice = + matrixWithAllocation.getOrThrow("matrixWithAllocation") - override fun hashCode(): Int = - Objects.hash(percentageDiscount, usageDiscount, amountDiscount, minimum, maximum) + fun asTieredPackageWithMinimum(): NewSubscriptionTieredPackageWithMinimumPrice = + tieredPackageWithMinimum.getOrThrow("tieredPackageWithMinimum") - override fun toString(): String = - when { - percentageDiscount != null -> - "Adjustment{percentageDiscount=$percentageDiscount}" - usageDiscount != null -> "Adjustment{usageDiscount=$usageDiscount}" - amountDiscount != null -> "Adjustment{amountDiscount=$amountDiscount}" - minimum != null -> "Adjustment{minimum=$minimum}" - maximum != null -> "Adjustment{maximum=$maximum}" - _json != null -> "Adjustment{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Adjustment") - } + fun asGroupedTiered(): NewSubscriptionGroupedTieredPrice = + groupedTiered.getOrThrow("groupedTiered") - companion object { + fun asGroupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds = + groupedWithMinMaxThresholds.getOrThrow("groupedWithMinMaxThresholds") - fun ofPercentageDiscount(percentageDiscount: NewPercentageDiscount) = - Adjustment(percentageDiscount = percentageDiscount) + fun asMinimum(): NewSubscriptionMinimumCompositePrice = minimum.getOrThrow("minimum") - fun ofUsageDiscount(usageDiscount: NewUsageDiscount) = - Adjustment(usageDiscount = usageDiscount) + fun _json(): JsonValue? = _json - fun ofAmountDiscount(amountDiscount: NewAmountDiscount) = - Adjustment(amountDiscount = amountDiscount) + fun accept(visitor: Visitor): T = + when { + unit != null -> visitor.visitUnit(unit) + package_ != null -> visitor.visitPackage(package_) + matrix != null -> visitor.visitMatrix(matrix) + tiered != null -> visitor.visitTiered(tiered) + bulk != null -> visitor.visitBulk(bulk) + thresholdTotalAmount != null -> + visitor.visitThresholdTotalAmount(thresholdTotalAmount) + tieredPackage != null -> visitor.visitTieredPackage(tieredPackage) + tieredWithMinimum != null -> visitor.visitTieredWithMinimum(tieredWithMinimum) + unitWithPercent != null -> visitor.visitUnitWithPercent(unitWithPercent) + packageWithAllocation != null -> + visitor.visitPackageWithAllocation(packageWithAllocation) + tieredWithProration != null -> + visitor.visitTieredWithProration(tieredWithProration) + unitWithProration != null -> visitor.visitUnitWithProration(unitWithProration) + groupedAllocation != null -> visitor.visitGroupedAllocation(groupedAllocation) + groupedWithProratedMinimum != null -> + visitor.visitGroupedWithProratedMinimum(groupedWithProratedMinimum) + bulkWithProration != null -> visitor.visitBulkWithProration(bulkWithProration) + scalableMatrixWithUnitPricing != null -> + visitor.visitScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing) + scalableMatrixWithTieredPricing != null -> + visitor.visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing + ) + cumulativeGroupedBulk != null -> + visitor.visitCumulativeGroupedBulk(cumulativeGroupedBulk) + maxGroupTieredPackage != null -> + visitor.visitMaxGroupTieredPackage(maxGroupTieredPackage) + groupedWithMeteredMinimum != null -> + visitor.visitGroupedWithMeteredMinimum(groupedWithMeteredMinimum) + matrixWithDisplayName != null -> + visitor.visitMatrixWithDisplayName(matrixWithDisplayName) + groupedTieredPackage != null -> + visitor.visitGroupedTieredPackage(groupedTieredPackage) + matrixWithAllocation != null -> + visitor.visitMatrixWithAllocation(matrixWithAllocation) + tieredPackageWithMinimum != null -> + visitor.visitTieredPackageWithMinimum(tieredPackageWithMinimum) + groupedTiered != null -> visitor.visitGroupedTiered(groupedTiered) + groupedWithMinMaxThresholds != null -> + visitor.visitGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds) + minimum != null -> visitor.visitMinimum(minimum) + else -> visitor.unknown(_json) + } - fun ofMinimum(minimum: NewMinimum) = Adjustment(minimum = minimum) + private var validated: Boolean = false - fun ofMaximum(maximum: NewMaximum) = Adjustment(maximum = maximum) - } + fun validate(): Price = apply { + if (validated) { + return@apply + } - /** - * An interface that defines how to map each variant of [Adjustment] to a value of type - * [T]. - */ - interface Visitor { + accept( + object : Visitor { + override fun visitUnit(unit: NewSubscriptionUnitPrice) { + unit.validate() + } - fun visitPercentageDiscount(percentageDiscount: NewPercentageDiscount): T + override fun visitPackage(package_: NewSubscriptionPackagePrice) { + package_.validate() + } - fun visitUsageDiscount(usageDiscount: NewUsageDiscount): T + override fun visitMatrix(matrix: NewSubscriptionMatrixPrice) { + matrix.validate() + } - fun visitAmountDiscount(amountDiscount: NewAmountDiscount): T + override fun visitTiered(tiered: NewSubscriptionTieredPrice) { + tiered.validate() + } - fun visitMinimum(minimum: NewMinimum): T + override fun visitBulk(bulk: NewSubscriptionBulkPrice) { + bulk.validate() + } - fun visitMaximum(maximum: NewMaximum): T + override fun visitThresholdTotalAmount( + thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice + ) { + thresholdTotalAmount.validate() + } - /** - * Maps an unknown variant of [Adjustment] to a value of type [T]. - * - * An instance of [Adjustment] can contain an unknown variant if it was deserialized - * from data that doesn't match any known variant. For example, if the SDK is on an - * older version than the API, then the API may respond with new variants that the - * SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown Adjustment: $json") - } - } + override fun visitTieredPackage( + tieredPackage: NewSubscriptionTieredPackagePrice + ) { + tieredPackage.validate() + } - internal class Deserializer : BaseDeserializer(Adjustment::class) { + override fun visitTieredWithMinimum( + tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice + ) { + tieredWithMinimum.validate() + } - override fun ObjectCodec.deserialize(node: JsonNode): Adjustment { - val json = JsonValue.fromJsonNode(node) - val adjustmentType = json.asObject()?.get("adjustment_type")?.asString() + override fun visitUnitWithPercent( + unitWithPercent: NewSubscriptionUnitWithPercentPrice + ) { + unitWithPercent.validate() + } - when (adjustmentType) { - "percentage_discount" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Adjustment(percentageDiscount = it, _json = json) } - ?: Adjustment(_json = json) + override fun visitPackageWithAllocation( + packageWithAllocation: NewSubscriptionPackageWithAllocationPrice + ) { + packageWithAllocation.validate() } - "usage_discount" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(usageDiscount = it, _json = json) - } ?: Adjustment(_json = json) + + override fun visitTieredWithProration( + tieredWithProration: NewSubscriptionTierWithProrationPrice + ) { + tieredWithProration.validate() } - "amount_discount" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(amountDiscount = it, _json = json) - } ?: Adjustment(_json = json) + + override fun visitUnitWithProration( + unitWithProration: NewSubscriptionUnitWithProrationPrice + ) { + unitWithProration.validate() } - "minimum" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(minimum = it, _json = json) - } ?: Adjustment(_json = json) + + override fun visitGroupedAllocation( + groupedAllocation: NewSubscriptionGroupedAllocationPrice + ) { + groupedAllocation.validate() } - "maximum" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(maximum = it, _json = json) - } ?: Adjustment(_json = json) + + override fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: + NewSubscriptionGroupedWithProratedMinimumPrice + ) { + groupedWithProratedMinimum.validate() } - } - return Adjustment(_json = json) - } - } + override fun visitBulkWithProration( + bulkWithProration: NewSubscriptionBulkWithProrationPrice + ) { + bulkWithProration.validate() + } - internal class Serializer : BaseSerializer(Adjustment::class) { + override fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: + NewSubscriptionScalableMatrixWithUnitPricingPrice + ) { + scalableMatrixWithUnitPricing.validate() + } - override fun serialize( - value: Adjustment, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.percentageDiscount != null -> - generator.writeObject(value.percentageDiscount) - value.usageDiscount != null -> generator.writeObject(value.usageDiscount) - value.amountDiscount != null -> generator.writeObject(value.amountDiscount) - value.minimum != null -> generator.writeObject(value.minimum) - value.maximum != null -> generator.writeObject(value.maximum) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Adjustment") - } - } - } - } + override fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: + NewSubscriptionScalableMatrixWithTieredPricingPrice + ) { + scalableMatrixWithTieredPricing.validate() + } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + override fun visitCumulativeGroupedBulk( + cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice + ) { + cumulativeGroupedBulk.validate() + } - return other is ReplaceAdjustment && - adjustment == other.adjustment && - replacesAdjustmentId == other.replacesAdjustmentId && - additionalProperties == other.additionalProperties - } + override fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice + ) { + maxGroupTieredPackage.validate() + } - private val hashCode: Int by lazy { - Objects.hash(adjustment, replacesAdjustmentId, additionalProperties) - } + override fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice + ) { + groupedWithMeteredMinimum.validate() + } - override fun hashCode(): Int = hashCode + override fun visitMatrixWithDisplayName( + matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice + ) { + matrixWithDisplayName.validate() + } - override fun toString() = - "ReplaceAdjustment{adjustment=$adjustment, replacesAdjustmentId=$replacesAdjustmentId, additionalProperties=$additionalProperties}" - } + override fun visitGroupedTieredPackage( + groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice + ) { + groupedTieredPackage.validate() + } - class ReplacePrice - private constructor( - private val replacesPriceId: JsonField, - private val allocationPrice: JsonField, - private val discounts: JsonField>, - private val externalPriceId: JsonField, - private val fixedPriceQuantity: JsonField, - private val maximumAmount: JsonField, - private val minimumAmount: JsonField, - private val price: JsonField, - private val priceId: JsonField, - private val additionalProperties: MutableMap, - ) { + override fun visitMatrixWithAllocation( + matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice + ) { + matrixWithAllocation.validate() + } - @JsonCreator - private constructor( - @JsonProperty("replaces_price_id") - @ExcludeMissing - replacesPriceId: JsonField = JsonMissing.of(), - @JsonProperty("allocation_price") - @ExcludeMissing - allocationPrice: JsonField = JsonMissing.of(), - @JsonProperty("discounts") - @ExcludeMissing - discounts: JsonField> = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("maximum_amount") - @ExcludeMissing - maximumAmount: JsonField = JsonMissing.of(), - @JsonProperty("minimum_amount") - @ExcludeMissing - minimumAmount: JsonField = JsonMissing.of(), - @JsonProperty("price") @ExcludeMissing price: JsonField = JsonMissing.of(), - @JsonProperty("price_id") @ExcludeMissing priceId: JsonField = JsonMissing.of(), - ) : this( - replacesPriceId, - allocationPrice, - discounts, - externalPriceId, - fixedPriceQuantity, - maximumAmount, - minimumAmount, - price, - priceId, - mutableMapOf(), - ) + override fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice + ) { + tieredPackageWithMinimum.validate() + } - /** - * The id of the price on the plan to replace in the subscription. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun replacesPriceId(): String = replacesPriceId.getRequired("replaces_price_id") + override fun visitGroupedTiered( + groupedTiered: NewSubscriptionGroupedTieredPrice + ) { + groupedTiered.validate() + } - /** - * The definition of a new allocation price to create and add to the subscription. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun allocationPrice(): NewAllocationPrice? = allocationPrice.getNullable("allocation_price") + override fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) { + groupedWithMinMaxThresholds.validate() + } - /** - * [DEPRECATED] Use add_adjustments instead. The subscription's discounts for the - * replacement price. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - @Deprecated("deprecated") - fun discounts(): List? = discounts.getNullable("discounts") + override fun visitMinimum(minimum: NewSubscriptionMinimumCompositePrice) { + minimum.validate() + } + } + ) + validated = true + } - /** - * The external price id of the price to add to the subscription. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - /** - * The new quantity of the price, if the price is a fixed price. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun fixedPriceQuantity(): Double? = fixedPriceQuantity.getNullable("fixed_price_quantity") + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitUnit(unit: NewSubscriptionUnitPrice) = unit.validity() - /** - * [DEPRECATED] Use add_adjustments instead. The subscription's maximum amount for the - * replacement price. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - @Deprecated("deprecated") - fun maximumAmount(): String? = maximumAmount.getNullable("maximum_amount") + override fun visitPackage(package_: NewSubscriptionPackagePrice) = + package_.validity() - /** - * [DEPRECATED] Use add_adjustments instead. The subscription's minimum amount for the - * replacement price. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - @Deprecated("deprecated") - fun minimumAmount(): String? = minimumAmount.getNullable("minimum_amount") + override fun visitMatrix(matrix: NewSubscriptionMatrixPrice) = + matrix.validity() - /** - * The definition of a new price to create and add to the subscription. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun price(): Price? = price.getNullable("price") + override fun visitTiered(tiered: NewSubscriptionTieredPrice) = + tiered.validity() - /** - * The id of the price to add to the subscription. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun priceId(): String? = priceId.getNullable("price_id") + override fun visitBulk(bulk: NewSubscriptionBulkPrice) = bulk.validity() - /** - * Returns the raw JSON value of [replacesPriceId]. - * - * Unlike [replacesPriceId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("replaces_price_id") - @ExcludeMissing - fun _replacesPriceId(): JsonField = replacesPriceId + override fun visitThresholdTotalAmount( + thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice + ) = thresholdTotalAmount.validity() - /** - * Returns the raw JSON value of [allocationPrice]. - * - * Unlike [allocationPrice], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("allocation_price") - @ExcludeMissing - fun _allocationPrice(): JsonField = allocationPrice + override fun visitTieredPackage( + tieredPackage: NewSubscriptionTieredPackagePrice + ) = tieredPackage.validity() - /** - * Returns the raw JSON value of [discounts]. - * - * Unlike [discounts], this method doesn't throw if the JSON field has an unexpected type. - */ - @Deprecated("deprecated") - @JsonProperty("discounts") - @ExcludeMissing - fun _discounts(): JsonField> = discounts - - /** - * Returns the raw JSON value of [externalPriceId]. - * - * Unlike [externalPriceId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId + override fun visitTieredWithMinimum( + tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice + ) = tieredWithMinimum.validity() - /** - * Returns the raw JSON value of [fixedPriceQuantity]. - * - * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + override fun visitUnitWithPercent( + unitWithPercent: NewSubscriptionUnitWithPercentPrice + ) = unitWithPercent.validity() - /** - * Returns the raw JSON value of [maximumAmount]. - * - * Unlike [maximumAmount], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @Deprecated("deprecated") - @JsonProperty("maximum_amount") - @ExcludeMissing - fun _maximumAmount(): JsonField = maximumAmount + override fun visitPackageWithAllocation( + packageWithAllocation: NewSubscriptionPackageWithAllocationPrice + ) = packageWithAllocation.validity() - /** - * Returns the raw JSON value of [minimumAmount]. - * - * Unlike [minimumAmount], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @Deprecated("deprecated") - @JsonProperty("minimum_amount") - @ExcludeMissing - fun _minimumAmount(): JsonField = minimumAmount + override fun visitTieredWithProration( + tieredWithProration: NewSubscriptionTierWithProrationPrice + ) = tieredWithProration.validity() - /** - * Returns the raw JSON value of [price]. - * - * Unlike [price], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("price") @ExcludeMissing fun _price(): JsonField = price + override fun visitUnitWithProration( + unitWithProration: NewSubscriptionUnitWithProrationPrice + ) = unitWithProration.validity() - /** - * Returns the raw JSON value of [priceId]. - * - * Unlike [priceId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId + override fun visitGroupedAllocation( + groupedAllocation: NewSubscriptionGroupedAllocationPrice + ) = groupedAllocation.validity() - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + override fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: + NewSubscriptionGroupedWithProratedMinimumPrice + ) = groupedWithProratedMinimum.validity() - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + override fun visitBulkWithProration( + bulkWithProration: NewSubscriptionBulkWithProrationPrice + ) = bulkWithProration.validity() - fun toBuilder() = Builder().from(this) + override fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: + NewSubscriptionScalableMatrixWithUnitPricingPrice + ) = scalableMatrixWithUnitPricing.validity() - companion object { + override fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: + NewSubscriptionScalableMatrixWithTieredPricingPrice + ) = scalableMatrixWithTieredPricing.validity() - /** - * Returns a mutable builder for constructing an instance of [ReplacePrice]. - * - * The following fields are required: - * ```kotlin - * .replacesPriceId() - * ``` - */ - fun builder() = Builder() - } + override fun visitCumulativeGroupedBulk( + cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice + ) = cumulativeGroupedBulk.validity() - /** A builder for [ReplacePrice]. */ - class Builder internal constructor() { + override fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice + ) = maxGroupTieredPackage.validity() - private var replacesPriceId: JsonField? = null - private var allocationPrice: JsonField = JsonMissing.of() - private var discounts: JsonField>? = null - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var maximumAmount: JsonField = JsonMissing.of() - private var minimumAmount: JsonField = JsonMissing.of() - private var price: JsonField = JsonMissing.of() - private var priceId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + override fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice + ) = groupedWithMeteredMinimum.validity() - internal fun from(replacePrice: ReplacePrice) = apply { - replacesPriceId = replacePrice.replacesPriceId - allocationPrice = replacePrice.allocationPrice - discounts = replacePrice.discounts.map { it.toMutableList() } - externalPriceId = replacePrice.externalPriceId - fixedPriceQuantity = replacePrice.fixedPriceQuantity - maximumAmount = replacePrice.maximumAmount - minimumAmount = replacePrice.minimumAmount - price = replacePrice.price - priceId = replacePrice.priceId - additionalProperties = replacePrice.additionalProperties.toMutableMap() - } + override fun visitMatrixWithDisplayName( + matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice + ) = matrixWithDisplayName.validity() - /** The id of the price on the plan to replace in the subscription. */ - fun replacesPriceId(replacesPriceId: String) = - replacesPriceId(JsonField.of(replacesPriceId)) + override fun visitGroupedTieredPackage( + groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice + ) = groupedTieredPackage.validity() - /** - * Sets [Builder.replacesPriceId] to an arbitrary JSON value. - * - * You should usually call [Builder.replacesPriceId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun replacesPriceId(replacesPriceId: JsonField) = apply { - this.replacesPriceId = replacesPriceId - } + override fun visitMatrixWithAllocation( + matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice + ) = matrixWithAllocation.validity() - /** The definition of a new allocation price to create and add to the subscription. */ - fun allocationPrice(allocationPrice: NewAllocationPrice?) = - allocationPrice(JsonField.ofNullable(allocationPrice)) + override fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice + ) = tieredPackageWithMinimum.validity() - /** - * Sets [Builder.allocationPrice] to an arbitrary JSON value. - * - * You should usually call [Builder.allocationPrice] with a well-typed - * [NewAllocationPrice] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun allocationPrice(allocationPrice: JsonField) = apply { - this.allocationPrice = allocationPrice - } + override fun visitGroupedTiered( + groupedTiered: NewSubscriptionGroupedTieredPrice + ) = groupedTiered.validity() - /** - * [DEPRECATED] Use add_adjustments instead. The subscription's discounts for the - * replacement price. - */ - @Deprecated("deprecated") - fun discounts(discounts: List?) = - discounts(JsonField.ofNullable(discounts)) + override fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) = groupedWithMinMaxThresholds.validity() - /** - * Sets [Builder.discounts] to an arbitrary JSON value. - * - * You should usually call [Builder.discounts] with a well-typed - * `List` value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - @Deprecated("deprecated") - fun discounts(discounts: JsonField>) = apply { - this.discounts = discounts.map { it.toMutableList() } - } + override fun visitMinimum(minimum: NewSubscriptionMinimumCompositePrice) = + minimum.validity() - /** - * Adds a single [DiscountOverride] to [discounts]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - @Deprecated("deprecated") - fun addDiscount(discount: DiscountOverride) = apply { - discounts = - (discounts ?: JsonField.of(mutableListOf())).also { - checkKnown("discounts", it).add(discount) + override fun unknown(json: JsonValue?) = 0 } - } - - /** The external price id of the price to add to the subscription. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** - * Sets [Builder.externalPriceId] to an arbitrary JSON value. - * - * You should usually call [Builder.externalPriceId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun externalPriceId(externalPriceId: JsonField) = apply { - this.externalPriceId = externalPriceId - } - - /** The new quantity of the price, if the price is a fixed price. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = - fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + ) - /** - * Alias for [Builder.fixedPriceQuantity]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. - * - * You should usually call [Builder.fixedPriceQuantity] with a well-typed [Double] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { - this.fixedPriceQuantity = fixedPriceQuantity + return other is Price && + unit == other.unit && + package_ == other.package_ && + matrix == other.matrix && + tiered == other.tiered && + bulk == other.bulk && + thresholdTotalAmount == other.thresholdTotalAmount && + tieredPackage == other.tieredPackage && + tieredWithMinimum == other.tieredWithMinimum && + unitWithPercent == other.unitWithPercent && + packageWithAllocation == other.packageWithAllocation && + tieredWithProration == other.tieredWithProration && + unitWithProration == other.unitWithProration && + groupedAllocation == other.groupedAllocation && + groupedWithProratedMinimum == other.groupedWithProratedMinimum && + bulkWithProration == other.bulkWithProration && + scalableMatrixWithUnitPricing == other.scalableMatrixWithUnitPricing && + scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && + cumulativeGroupedBulk == other.cumulativeGroupedBulk && + maxGroupTieredPackage == other.maxGroupTieredPackage && + groupedWithMeteredMinimum == other.groupedWithMeteredMinimum && + matrixWithDisplayName == other.matrixWithDisplayName && + groupedTieredPackage == other.groupedTieredPackage && + matrixWithAllocation == other.matrixWithAllocation && + tieredPackageWithMinimum == other.tieredPackageWithMinimum && + groupedTiered == other.groupedTiered && + groupedWithMinMaxThresholds == other.groupedWithMinMaxThresholds && + minimum == other.minimum } - /** - * [DEPRECATED] Use add_adjustments instead. The subscription's maximum amount for the - * replacement price. - */ - @Deprecated("deprecated") - fun maximumAmount(maximumAmount: String?) = - maximumAmount(JsonField.ofNullable(maximumAmount)) + override fun hashCode(): Int = + Objects.hash( + unit, + package_, + matrix, + tiered, + bulk, + thresholdTotalAmount, + tieredPackage, + tieredWithMinimum, + unitWithPercent, + packageWithAllocation, + tieredWithProration, + unitWithProration, + groupedAllocation, + groupedWithProratedMinimum, + bulkWithProration, + scalableMatrixWithUnitPricing, + scalableMatrixWithTieredPricing, + cumulativeGroupedBulk, + maxGroupTieredPackage, + groupedWithMeteredMinimum, + matrixWithDisplayName, + groupedTieredPackage, + matrixWithAllocation, + tieredPackageWithMinimum, + groupedTiered, + groupedWithMinMaxThresholds, + minimum, + ) - /** - * Sets [Builder.maximumAmount] to an arbitrary JSON value. - * - * You should usually call [Builder.maximumAmount] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - @Deprecated("deprecated") - fun maximumAmount(maximumAmount: JsonField) = apply { - this.maximumAmount = maximumAmount - } + override fun toString(): String = + when { + unit != null -> "Price{unit=$unit}" + package_ != null -> "Price{package_=$package_}" + matrix != null -> "Price{matrix=$matrix}" + tiered != null -> "Price{tiered=$tiered}" + bulk != null -> "Price{bulk=$bulk}" + thresholdTotalAmount != null -> + "Price{thresholdTotalAmount=$thresholdTotalAmount}" + tieredPackage != null -> "Price{tieredPackage=$tieredPackage}" + tieredWithMinimum != null -> "Price{tieredWithMinimum=$tieredWithMinimum}" + unitWithPercent != null -> "Price{unitWithPercent=$unitWithPercent}" + packageWithAllocation != null -> + "Price{packageWithAllocation=$packageWithAllocation}" + tieredWithProration != null -> "Price{tieredWithProration=$tieredWithProration}" + unitWithProration != null -> "Price{unitWithProration=$unitWithProration}" + groupedAllocation != null -> "Price{groupedAllocation=$groupedAllocation}" + groupedWithProratedMinimum != null -> + "Price{groupedWithProratedMinimum=$groupedWithProratedMinimum}" + bulkWithProration != null -> "Price{bulkWithProration=$bulkWithProration}" + scalableMatrixWithUnitPricing != null -> + "Price{scalableMatrixWithUnitPricing=$scalableMatrixWithUnitPricing}" + scalableMatrixWithTieredPricing != null -> + "Price{scalableMatrixWithTieredPricing=$scalableMatrixWithTieredPricing}" + cumulativeGroupedBulk != null -> + "Price{cumulativeGroupedBulk=$cumulativeGroupedBulk}" + maxGroupTieredPackage != null -> + "Price{maxGroupTieredPackage=$maxGroupTieredPackage}" + groupedWithMeteredMinimum != null -> + "Price{groupedWithMeteredMinimum=$groupedWithMeteredMinimum}" + matrixWithDisplayName != null -> + "Price{matrixWithDisplayName=$matrixWithDisplayName}" + groupedTieredPackage != null -> + "Price{groupedTieredPackage=$groupedTieredPackage}" + matrixWithAllocation != null -> + "Price{matrixWithAllocation=$matrixWithAllocation}" + tieredPackageWithMinimum != null -> + "Price{tieredPackageWithMinimum=$tieredPackageWithMinimum}" + groupedTiered != null -> "Price{groupedTiered=$groupedTiered}" + groupedWithMinMaxThresholds != null -> + "Price{groupedWithMinMaxThresholds=$groupedWithMinMaxThresholds}" + minimum != null -> "Price{minimum=$minimum}" + _json != null -> "Price{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Price") + } - /** - * [DEPRECATED] Use add_adjustments instead. The subscription's minimum amount for the - * replacement price. - */ - @Deprecated("deprecated") - fun minimumAmount(minimumAmount: String?) = - minimumAmount(JsonField.ofNullable(minimumAmount)) + companion object { - /** - * Sets [Builder.minimumAmount] to an arbitrary JSON value. - * - * You should usually call [Builder.minimumAmount] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - @Deprecated("deprecated") - fun minimumAmount(minimumAmount: JsonField) = apply { - this.minimumAmount = minimumAmount - } + fun ofUnit(unit: NewSubscriptionUnitPrice) = Price(unit = unit) - /** The definition of a new price to create and add to the subscription. */ - fun price(price: Price?) = price(JsonField.ofNullable(price)) + fun ofPackage(package_: NewSubscriptionPackagePrice) = Price(package_ = package_) - /** - * Sets [Builder.price] to an arbitrary JSON value. - * - * You should usually call [Builder.price] with a well-typed [Price] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun price(price: JsonField) = apply { this.price = price } + fun ofMatrix(matrix: NewSubscriptionMatrixPrice) = Price(matrix = matrix) - /** Alias for calling [price] with `Price.ofUnit(unit)`. */ - fun price(unit: NewSubscriptionUnitPrice) = price(Price.ofUnit(unit)) + fun ofTiered(tiered: NewSubscriptionTieredPrice) = Price(tiered = tiered) - /** Alias for calling [price] with `Price.ofPackage(package_)`. */ - fun price(package_: NewSubscriptionPackagePrice) = price(Price.ofPackage(package_)) + fun ofBulk(bulk: NewSubscriptionBulkPrice) = Price(bulk = bulk) - /** Alias for calling [price] with `Price.ofMatrix(matrix)`. */ - fun price(matrix: NewSubscriptionMatrixPrice) = price(Price.ofMatrix(matrix)) + fun ofThresholdTotalAmount( + thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice + ) = Price(thresholdTotalAmount = thresholdTotalAmount) - /** Alias for calling [price] with `Price.ofTiered(tiered)`. */ - fun price(tiered: NewSubscriptionTieredPrice) = price(Price.ofTiered(tiered)) + fun ofTieredPackage(tieredPackage: NewSubscriptionTieredPackagePrice) = + Price(tieredPackage = tieredPackage) - /** Alias for calling [price] with `Price.ofBulk(bulk)`. */ - fun price(bulk: NewSubscriptionBulkPrice) = price(Price.ofBulk(bulk)) + fun ofTieredWithMinimum(tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice) = + Price(tieredWithMinimum = tieredWithMinimum) - /** - * Alias for calling [price] with `Price.ofThresholdTotalAmount(thresholdTotalAmount)`. - */ - fun price(thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice) = - price(Price.ofThresholdTotalAmount(thresholdTotalAmount)) + fun ofUnitWithPercent(unitWithPercent: NewSubscriptionUnitWithPercentPrice) = + Price(unitWithPercent = unitWithPercent) - /** Alias for calling [price] with `Price.ofTieredPackage(tieredPackage)`. */ - fun price(tieredPackage: NewSubscriptionTieredPackagePrice) = - price(Price.ofTieredPackage(tieredPackage)) + fun ofPackageWithAllocation( + packageWithAllocation: NewSubscriptionPackageWithAllocationPrice + ) = Price(packageWithAllocation = packageWithAllocation) - /** Alias for calling [price] with `Price.ofTieredWithMinimum(tieredWithMinimum)`. */ - fun price(tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice) = - price(Price.ofTieredWithMinimum(tieredWithMinimum)) + fun ofTieredWithProration( + tieredWithProration: NewSubscriptionTierWithProrationPrice + ) = Price(tieredWithProration = tieredWithProration) - /** Alias for calling [price] with `Price.ofUnitWithPercent(unitWithPercent)`. */ - fun price(unitWithPercent: NewSubscriptionUnitWithPercentPrice) = - price(Price.ofUnitWithPercent(unitWithPercent)) + fun ofUnitWithProration(unitWithProration: NewSubscriptionUnitWithProrationPrice) = + Price(unitWithProration = unitWithProration) - /** - * Alias for calling [price] with - * `Price.ofPackageWithAllocation(packageWithAllocation)`. - */ - fun price(packageWithAllocation: NewSubscriptionPackageWithAllocationPrice) = - price(Price.ofPackageWithAllocation(packageWithAllocation)) + fun ofGroupedAllocation(groupedAllocation: NewSubscriptionGroupedAllocationPrice) = + Price(groupedAllocation = groupedAllocation) - /** - * Alias for calling [price] with `Price.ofTieredWithProration(tieredWithProration)`. - */ - fun price(tieredWithProration: NewSubscriptionTierWithProrationPrice) = - price(Price.ofTieredWithProration(tieredWithProration)) + fun ofGroupedWithProratedMinimum( + groupedWithProratedMinimum: NewSubscriptionGroupedWithProratedMinimumPrice + ) = Price(groupedWithProratedMinimum = groupedWithProratedMinimum) - /** Alias for calling [price] with `Price.ofUnitWithProration(unitWithProration)`. */ - fun price(unitWithProration: NewSubscriptionUnitWithProrationPrice) = - price(Price.ofUnitWithProration(unitWithProration)) + fun ofBulkWithProration(bulkWithProration: NewSubscriptionBulkWithProrationPrice) = + Price(bulkWithProration = bulkWithProration) - /** Alias for calling [price] with `Price.ofGroupedAllocation(groupedAllocation)`. */ - fun price(groupedAllocation: NewSubscriptionGroupedAllocationPrice) = - price(Price.ofGroupedAllocation(groupedAllocation)) + fun ofScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: NewSubscriptionScalableMatrixWithUnitPricingPrice + ) = Price(scalableMatrixWithUnitPricing = scalableMatrixWithUnitPricing) - /** - * Alias for calling [price] with - * `Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)`. - */ - fun price(groupedWithProratedMinimum: NewSubscriptionGroupedWithProratedMinimumPrice) = - price(Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)) + fun ofScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: + NewSubscriptionScalableMatrixWithTieredPricingPrice + ) = Price(scalableMatrixWithTieredPricing = scalableMatrixWithTieredPricing) - /** Alias for calling [price] with `Price.ofBulkWithProration(bulkWithProration)`. */ - fun price(bulkWithProration: NewSubscriptionBulkWithProrationPrice) = - price(Price.ofBulkWithProration(bulkWithProration)) + fun ofCumulativeGroupedBulk( + cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice + ) = Price(cumulativeGroupedBulk = cumulativeGroupedBulk) - /** - * Alias for calling [price] with - * `Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)`. - */ - fun price( - scalableMatrixWithUnitPricing: NewSubscriptionScalableMatrixWithUnitPricingPrice - ) = price(Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)) + fun ofMaxGroupTieredPackage( + maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice + ) = Price(maxGroupTieredPackage = maxGroupTieredPackage) - /** - * Alias for calling [price] with - * `Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)`. - */ - fun price( - scalableMatrixWithTieredPricing: NewSubscriptionScalableMatrixWithTieredPricingPrice - ) = price(Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)) - - /** - * Alias for calling [price] with - * `Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)`. - */ - fun price(cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice) = - price(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) + fun ofGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice + ) = Price(groupedWithMeteredMinimum = groupedWithMeteredMinimum) - /** - * Alias for calling [price] with - * `Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)`. - */ - fun price(maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice) = - price(Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)) + fun ofMatrixWithDisplayName( + matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice + ) = Price(matrixWithDisplayName = matrixWithDisplayName) - /** - * Alias for calling [price] with - * `Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)`. - */ - fun price(groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice) = - price(Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)) + fun ofGroupedTieredPackage( + groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice + ) = Price(groupedTieredPackage = groupedTieredPackage) - /** - * Alias for calling [price] with - * `Price.ofMatrixWithDisplayName(matrixWithDisplayName)`. - */ - fun price(matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice) = - price(Price.ofMatrixWithDisplayName(matrixWithDisplayName)) + fun ofMatrixWithAllocation( + matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice + ) = Price(matrixWithAllocation = matrixWithAllocation) - /** - * Alias for calling [price] with `Price.ofGroupedTieredPackage(groupedTieredPackage)`. - */ - fun price(groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice) = - price(Price.ofGroupedTieredPackage(groupedTieredPackage)) + fun ofTieredPackageWithMinimum( + tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice + ) = Price(tieredPackageWithMinimum = tieredPackageWithMinimum) - /** - * Alias for calling [price] with `Price.ofMatrixWithAllocation(matrixWithAllocation)`. - */ - fun price(matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice) = - price(Price.ofMatrixWithAllocation(matrixWithAllocation)) + fun ofGroupedTiered(groupedTiered: NewSubscriptionGroupedTieredPrice) = + Price(groupedTiered = groupedTiered) - /** - * Alias for calling [price] with - * `Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)`. - */ - fun price(tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice) = - price(Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)) + fun ofGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) = Price(groupedWithMinMaxThresholds = groupedWithMinMaxThresholds) - /** Alias for calling [price] with `Price.ofGroupedTiered(groupedTiered)`. */ - fun price(groupedTiered: NewSubscriptionGroupedTieredPrice) = - price(Price.ofGroupedTiered(groupedTiered)) + fun ofMinimum(minimum: NewSubscriptionMinimumCompositePrice) = + Price(minimum = minimum) + } /** - * Alias for calling [price] with - * `Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)`. + * An interface that defines how to map each variant of [Price] to a value of type [T]. */ - fun price(groupedWithMinMaxThresholds: Price.GroupedWithMinMaxThresholds) = - price(Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)) + interface Visitor { - /** Alias for calling [price] with `Price.ofMinimum(minimum)`. */ - fun price(minimum: Price.Minimum) = price(Price.ofMinimum(minimum)) + fun visitUnit(unit: NewSubscriptionUnitPrice): T - /** The id of the price to add to the subscription. */ - fun priceId(priceId: String?) = priceId(JsonField.ofNullable(priceId)) + fun visitPackage(package_: NewSubscriptionPackagePrice): T - /** - * Sets [Builder.priceId] to an arbitrary JSON value. - * - * You should usually call [Builder.priceId] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun priceId(priceId: JsonField) = apply { this.priceId = priceId } + fun visitMatrix(matrix: NewSubscriptionMatrixPrice): T - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun visitTiered(tiered: NewSubscriptionTieredPrice): T - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun visitBulk(bulk: NewSubscriptionBulkPrice): T - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun visitThresholdTotalAmount( + thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice + ): T - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun visitTieredPackage(tieredPackage: NewSubscriptionTieredPackagePrice): T - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun visitTieredWithMinimum( + tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice + ): T - /** - * Returns an immutable instance of [ReplacePrice]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```kotlin - * .replacesPriceId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): ReplacePrice = - ReplacePrice( - checkRequired("replacesPriceId", replacesPriceId), - allocationPrice, - (discounts ?: JsonMissing.of()).map { it.toImmutable() }, - externalPriceId, - fixedPriceQuantity, - maximumAmount, - minimumAmount, - price, - priceId, - additionalProperties.toMutableMap(), - ) - } + fun visitUnitWithPercent(unitWithPercent: NewSubscriptionUnitWithPercentPrice): T - private var validated: Boolean = false + fun visitPackageWithAllocation( + packageWithAllocation: NewSubscriptionPackageWithAllocationPrice + ): T - fun validate(): ReplacePrice = apply { - if (validated) { - return@apply - } + fun visitTieredWithProration( + tieredWithProration: NewSubscriptionTierWithProrationPrice + ): T - replacesPriceId() - allocationPrice()?.validate() - discounts()?.forEach { it.validate() } - externalPriceId() - fixedPriceQuantity() - maximumAmount() - minimumAmount() - price()?.validate() - priceId() - validated = true - } + fun visitUnitWithProration( + unitWithProration: NewSubscriptionUnitWithProrationPrice + ): T - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + fun visitGroupedAllocation( + groupedAllocation: NewSubscriptionGroupedAllocationPrice + ): T - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (if (replacesPriceId.asKnown() == null) 0 else 1) + - (allocationPrice.asKnown()?.validity() ?: 0) + - (discounts.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + - (if (externalPriceId.asKnown() == null) 0 else 1) + - (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + - (if (maximumAmount.asKnown() == null) 0 else 1) + - (if (minimumAmount.asKnown() == null) 0 else 1) + - (price.asKnown()?.validity() ?: 0) + - (if (priceId.asKnown() == null) 0 else 1) + fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: NewSubscriptionGroupedWithProratedMinimumPrice + ): T - /** The definition of a new price to create and add to the subscription. */ - @JsonDeserialize(using = Price.Deserializer::class) - @JsonSerialize(using = Price.Serializer::class) - class Price - private constructor( - private val unit: NewSubscriptionUnitPrice? = null, - private val package_: NewSubscriptionPackagePrice? = null, - private val matrix: NewSubscriptionMatrixPrice? = null, - private val tiered: NewSubscriptionTieredPrice? = null, - private val bulk: NewSubscriptionBulkPrice? = null, - private val thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice? = null, - private val tieredPackage: NewSubscriptionTieredPackagePrice? = null, - private val tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice? = null, - private val unitWithPercent: NewSubscriptionUnitWithPercentPrice? = null, - private val packageWithAllocation: NewSubscriptionPackageWithAllocationPrice? = null, - private val tieredWithProration: NewSubscriptionTierWithProrationPrice? = null, - private val unitWithProration: NewSubscriptionUnitWithProrationPrice? = null, - private val groupedAllocation: NewSubscriptionGroupedAllocationPrice? = null, - private val groupedWithProratedMinimum: - NewSubscriptionGroupedWithProratedMinimumPrice? = - null, - private val bulkWithProration: NewSubscriptionBulkWithProrationPrice? = null, - private val scalableMatrixWithUnitPricing: - NewSubscriptionScalableMatrixWithUnitPricingPrice? = - null, - private val scalableMatrixWithTieredPricing: - NewSubscriptionScalableMatrixWithTieredPricingPrice? = - null, - private val cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice? = null, - private val maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice? = null, - private val groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice? = - null, - private val matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice? = null, - private val groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice? = null, - private val matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice? = null, - private val tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice? = - null, - private val groupedTiered: NewSubscriptionGroupedTieredPrice? = null, - private val groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds? = null, - private val minimum: Minimum? = null, - private val _json: JsonValue? = null, - ) { + fun visitBulkWithProration( + bulkWithProration: NewSubscriptionBulkWithProrationPrice + ): T - fun unit(): NewSubscriptionUnitPrice? = unit + fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: NewSubscriptionScalableMatrixWithUnitPricingPrice + ): T - fun package_(): NewSubscriptionPackagePrice? = package_ + fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: + NewSubscriptionScalableMatrixWithTieredPricingPrice + ): T - fun matrix(): NewSubscriptionMatrixPrice? = matrix + fun visitCumulativeGroupedBulk( + cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice + ): T - fun tiered(): NewSubscriptionTieredPrice? = tiered + fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice + ): T - fun bulk(): NewSubscriptionBulkPrice? = bulk + fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice + ): T - fun thresholdTotalAmount(): NewSubscriptionThresholdTotalAmountPrice? = - thresholdTotalAmount - - fun tieredPackage(): NewSubscriptionTieredPackagePrice? = tieredPackage - - fun tieredWithMinimum(): NewSubscriptionTieredWithMinimumPrice? = tieredWithMinimum - - fun unitWithPercent(): NewSubscriptionUnitWithPercentPrice? = unitWithPercent - - fun packageWithAllocation(): NewSubscriptionPackageWithAllocationPrice? = - packageWithAllocation - - fun tieredWithProration(): NewSubscriptionTierWithProrationPrice? = tieredWithProration - - fun unitWithProration(): NewSubscriptionUnitWithProrationPrice? = unitWithProration - - fun groupedAllocation(): NewSubscriptionGroupedAllocationPrice? = groupedAllocation - - fun groupedWithProratedMinimum(): NewSubscriptionGroupedWithProratedMinimumPrice? = - groupedWithProratedMinimum - - fun bulkWithProration(): NewSubscriptionBulkWithProrationPrice? = bulkWithProration - - fun scalableMatrixWithUnitPricing(): - NewSubscriptionScalableMatrixWithUnitPricingPrice? = scalableMatrixWithUnitPricing - - fun scalableMatrixWithTieredPricing(): - NewSubscriptionScalableMatrixWithTieredPricingPrice? = - scalableMatrixWithTieredPricing - - fun cumulativeGroupedBulk(): NewSubscriptionCumulativeGroupedBulkPrice? = - cumulativeGroupedBulk - - fun maxGroupTieredPackage(): NewSubscriptionMaxGroupTieredPackagePrice? = - maxGroupTieredPackage - - fun groupedWithMeteredMinimum(): NewSubscriptionGroupedWithMeteredMinimumPrice? = - groupedWithMeteredMinimum - - fun matrixWithDisplayName(): NewSubscriptionMatrixWithDisplayNamePrice? = - matrixWithDisplayName - - fun groupedTieredPackage(): NewSubscriptionGroupedTieredPackagePrice? = - groupedTieredPackage - - fun matrixWithAllocation(): NewSubscriptionMatrixWithAllocationPrice? = - matrixWithAllocation - - fun tieredPackageWithMinimum(): NewSubscriptionTieredPackageWithMinimumPrice? = - tieredPackageWithMinimum - - fun groupedTiered(): NewSubscriptionGroupedTieredPrice? = groupedTiered - - fun groupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds? = - groupedWithMinMaxThresholds - - fun minimum(): Minimum? = minimum - - fun isUnit(): Boolean = unit != null - - fun isPackage(): Boolean = package_ != null - - fun isMatrix(): Boolean = matrix != null - - fun isTiered(): Boolean = tiered != null - - fun isBulk(): Boolean = bulk != null - - fun isThresholdTotalAmount(): Boolean = thresholdTotalAmount != null - - fun isTieredPackage(): Boolean = tieredPackage != null - - fun isTieredWithMinimum(): Boolean = tieredWithMinimum != null - - fun isUnitWithPercent(): Boolean = unitWithPercent != null - - fun isPackageWithAllocation(): Boolean = packageWithAllocation != null - - fun isTieredWithProration(): Boolean = tieredWithProration != null - - fun isUnitWithProration(): Boolean = unitWithProration != null - - fun isGroupedAllocation(): Boolean = groupedAllocation != null - - fun isGroupedWithProratedMinimum(): Boolean = groupedWithProratedMinimum != null - - fun isBulkWithProration(): Boolean = bulkWithProration != null - - fun isScalableMatrixWithUnitPricing(): Boolean = scalableMatrixWithUnitPricing != null - - fun isScalableMatrixWithTieredPricing(): Boolean = - scalableMatrixWithTieredPricing != null - - fun isCumulativeGroupedBulk(): Boolean = cumulativeGroupedBulk != null - - fun isMaxGroupTieredPackage(): Boolean = maxGroupTieredPackage != null - - fun isGroupedWithMeteredMinimum(): Boolean = groupedWithMeteredMinimum != null - - fun isMatrixWithDisplayName(): Boolean = matrixWithDisplayName != null - - fun isGroupedTieredPackage(): Boolean = groupedTieredPackage != null - - fun isMatrixWithAllocation(): Boolean = matrixWithAllocation != null - - fun isTieredPackageWithMinimum(): Boolean = tieredPackageWithMinimum != null - - fun isGroupedTiered(): Boolean = groupedTiered != null - - fun isGroupedWithMinMaxThresholds(): Boolean = groupedWithMinMaxThresholds != null - - fun isMinimum(): Boolean = minimum != null - - fun asUnit(): NewSubscriptionUnitPrice = unit.getOrThrow("unit") - - fun asPackage(): NewSubscriptionPackagePrice = package_.getOrThrow("package_") - - fun asMatrix(): NewSubscriptionMatrixPrice = matrix.getOrThrow("matrix") - - fun asTiered(): NewSubscriptionTieredPrice = tiered.getOrThrow("tiered") - - fun asBulk(): NewSubscriptionBulkPrice = bulk.getOrThrow("bulk") - - fun asThresholdTotalAmount(): NewSubscriptionThresholdTotalAmountPrice = - thresholdTotalAmount.getOrThrow("thresholdTotalAmount") - - fun asTieredPackage(): NewSubscriptionTieredPackagePrice = - tieredPackage.getOrThrow("tieredPackage") - - fun asTieredWithMinimum(): NewSubscriptionTieredWithMinimumPrice = - tieredWithMinimum.getOrThrow("tieredWithMinimum") - - fun asUnitWithPercent(): NewSubscriptionUnitWithPercentPrice = - unitWithPercent.getOrThrow("unitWithPercent") - - fun asPackageWithAllocation(): NewSubscriptionPackageWithAllocationPrice = - packageWithAllocation.getOrThrow("packageWithAllocation") - - fun asTieredWithProration(): NewSubscriptionTierWithProrationPrice = - tieredWithProration.getOrThrow("tieredWithProration") - - fun asUnitWithProration(): NewSubscriptionUnitWithProrationPrice = - unitWithProration.getOrThrow("unitWithProration") - - fun asGroupedAllocation(): NewSubscriptionGroupedAllocationPrice = - groupedAllocation.getOrThrow("groupedAllocation") - - fun asGroupedWithProratedMinimum(): NewSubscriptionGroupedWithProratedMinimumPrice = - groupedWithProratedMinimum.getOrThrow("groupedWithProratedMinimum") - - fun asBulkWithProration(): NewSubscriptionBulkWithProrationPrice = - bulkWithProration.getOrThrow("bulkWithProration") - - fun asScalableMatrixWithUnitPricing(): - NewSubscriptionScalableMatrixWithUnitPricingPrice = - scalableMatrixWithUnitPricing.getOrThrow("scalableMatrixWithUnitPricing") - - fun asScalableMatrixWithTieredPricing(): - NewSubscriptionScalableMatrixWithTieredPricingPrice = - scalableMatrixWithTieredPricing.getOrThrow("scalableMatrixWithTieredPricing") - - fun asCumulativeGroupedBulk(): NewSubscriptionCumulativeGroupedBulkPrice = - cumulativeGroupedBulk.getOrThrow("cumulativeGroupedBulk") - - fun asMaxGroupTieredPackage(): NewSubscriptionMaxGroupTieredPackagePrice = - maxGroupTieredPackage.getOrThrow("maxGroupTieredPackage") - - fun asGroupedWithMeteredMinimum(): NewSubscriptionGroupedWithMeteredMinimumPrice = - groupedWithMeteredMinimum.getOrThrow("groupedWithMeteredMinimum") - - fun asMatrixWithDisplayName(): NewSubscriptionMatrixWithDisplayNamePrice = - matrixWithDisplayName.getOrThrow("matrixWithDisplayName") - - fun asGroupedTieredPackage(): NewSubscriptionGroupedTieredPackagePrice = - groupedTieredPackage.getOrThrow("groupedTieredPackage") - - fun asMatrixWithAllocation(): NewSubscriptionMatrixWithAllocationPrice = - matrixWithAllocation.getOrThrow("matrixWithAllocation") - - fun asTieredPackageWithMinimum(): NewSubscriptionTieredPackageWithMinimumPrice = - tieredPackageWithMinimum.getOrThrow("tieredPackageWithMinimum") - - fun asGroupedTiered(): NewSubscriptionGroupedTieredPrice = - groupedTiered.getOrThrow("groupedTiered") - - fun asGroupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds = - groupedWithMinMaxThresholds.getOrThrow("groupedWithMinMaxThresholds") - - fun asMinimum(): Minimum = minimum.getOrThrow("minimum") - - fun _json(): JsonValue? = _json - - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - package_ != null -> visitor.visitPackage(package_) - matrix != null -> visitor.visitMatrix(matrix) - tiered != null -> visitor.visitTiered(tiered) - bulk != null -> visitor.visitBulk(bulk) - thresholdTotalAmount != null -> - visitor.visitThresholdTotalAmount(thresholdTotalAmount) - tieredPackage != null -> visitor.visitTieredPackage(tieredPackage) - tieredWithMinimum != null -> visitor.visitTieredWithMinimum(tieredWithMinimum) - unitWithPercent != null -> visitor.visitUnitWithPercent(unitWithPercent) - packageWithAllocation != null -> - visitor.visitPackageWithAllocation(packageWithAllocation) - tieredWithProration != null -> - visitor.visitTieredWithProration(tieredWithProration) - unitWithProration != null -> visitor.visitUnitWithProration(unitWithProration) - groupedAllocation != null -> visitor.visitGroupedAllocation(groupedAllocation) - groupedWithProratedMinimum != null -> - visitor.visitGroupedWithProratedMinimum(groupedWithProratedMinimum) - bulkWithProration != null -> visitor.visitBulkWithProration(bulkWithProration) - scalableMatrixWithUnitPricing != null -> - visitor.visitScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing) - scalableMatrixWithTieredPricing != null -> - visitor.visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing - ) - cumulativeGroupedBulk != null -> - visitor.visitCumulativeGroupedBulk(cumulativeGroupedBulk) - maxGroupTieredPackage != null -> - visitor.visitMaxGroupTieredPackage(maxGroupTieredPackage) - groupedWithMeteredMinimum != null -> - visitor.visitGroupedWithMeteredMinimum(groupedWithMeteredMinimum) - matrixWithDisplayName != null -> - visitor.visitMatrixWithDisplayName(matrixWithDisplayName) - groupedTieredPackage != null -> - visitor.visitGroupedTieredPackage(groupedTieredPackage) - matrixWithAllocation != null -> - visitor.visitMatrixWithAllocation(matrixWithAllocation) - tieredPackageWithMinimum != null -> - visitor.visitTieredPackageWithMinimum(tieredPackageWithMinimum) - groupedTiered != null -> visitor.visitGroupedTiered(groupedTiered) - groupedWithMinMaxThresholds != null -> - visitor.visitGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds) - minimum != null -> visitor.visitMinimum(minimum) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): Price = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitUnit(unit: NewSubscriptionUnitPrice) { - unit.validate() - } - - override fun visitPackage(package_: NewSubscriptionPackagePrice) { - package_.validate() - } - - override fun visitMatrix(matrix: NewSubscriptionMatrixPrice) { - matrix.validate() - } - - override fun visitTiered(tiered: NewSubscriptionTieredPrice) { - tiered.validate() - } - - override fun visitBulk(bulk: NewSubscriptionBulkPrice) { - bulk.validate() - } - - override fun visitThresholdTotalAmount( - thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice - ) { - thresholdTotalAmount.validate() - } - - override fun visitTieredPackage( - tieredPackage: NewSubscriptionTieredPackagePrice - ) { - tieredPackage.validate() - } - - override fun visitTieredWithMinimum( - tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice - ) { - tieredWithMinimum.validate() - } - - override fun visitUnitWithPercent( - unitWithPercent: NewSubscriptionUnitWithPercentPrice - ) { - unitWithPercent.validate() - } - - override fun visitPackageWithAllocation( - packageWithAllocation: NewSubscriptionPackageWithAllocationPrice - ) { - packageWithAllocation.validate() - } - - override fun visitTieredWithProration( - tieredWithProration: NewSubscriptionTierWithProrationPrice - ) { - tieredWithProration.validate() - } - - override fun visitUnitWithProration( - unitWithProration: NewSubscriptionUnitWithProrationPrice - ) { - unitWithProration.validate() - } - - override fun visitGroupedAllocation( - groupedAllocation: NewSubscriptionGroupedAllocationPrice - ) { - groupedAllocation.validate() - } - - override fun visitGroupedWithProratedMinimum( - groupedWithProratedMinimum: - NewSubscriptionGroupedWithProratedMinimumPrice - ) { - groupedWithProratedMinimum.validate() - } - - override fun visitBulkWithProration( - bulkWithProration: NewSubscriptionBulkWithProrationPrice - ) { - bulkWithProration.validate() - } - - override fun visitScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: - NewSubscriptionScalableMatrixWithUnitPricingPrice - ) { - scalableMatrixWithUnitPricing.validate() - } - - override fun visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: - NewSubscriptionScalableMatrixWithTieredPricingPrice - ) { - scalableMatrixWithTieredPricing.validate() - } - - override fun visitCumulativeGroupedBulk( - cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice - ) { - cumulativeGroupedBulk.validate() - } - - override fun visitMaxGroupTieredPackage( - maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice - ) { - maxGroupTieredPackage.validate() - } - - override fun visitGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice - ) { - groupedWithMeteredMinimum.validate() - } - - override fun visitMatrixWithDisplayName( - matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice - ) { - matrixWithDisplayName.validate() - } - - override fun visitGroupedTieredPackage( - groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice - ) { - groupedTieredPackage.validate() - } - - override fun visitMatrixWithAllocation( - matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice - ) { - matrixWithAllocation.validate() - } - - override fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice - ) { - tieredPackageWithMinimum.validate() - } - - override fun visitGroupedTiered( - groupedTiered: NewSubscriptionGroupedTieredPrice - ) { - groupedTiered.validate() - } - - override fun visitGroupedWithMinMaxThresholds( - groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds - ) { - groupedWithMinMaxThresholds.validate() - } - - override fun visitMinimum(minimum: Minimum) { - minimum.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: NewSubscriptionUnitPrice) = unit.validity() - - override fun visitPackage(package_: NewSubscriptionPackagePrice) = - package_.validity() - - override fun visitMatrix(matrix: NewSubscriptionMatrixPrice) = - matrix.validity() - - override fun visitTiered(tiered: NewSubscriptionTieredPrice) = - tiered.validity() - - override fun visitBulk(bulk: NewSubscriptionBulkPrice) = bulk.validity() - - override fun visitThresholdTotalAmount( - thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice - ) = thresholdTotalAmount.validity() - - override fun visitTieredPackage( - tieredPackage: NewSubscriptionTieredPackagePrice - ) = tieredPackage.validity() - - override fun visitTieredWithMinimum( - tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice - ) = tieredWithMinimum.validity() - - override fun visitUnitWithPercent( - unitWithPercent: NewSubscriptionUnitWithPercentPrice - ) = unitWithPercent.validity() - - override fun visitPackageWithAllocation( - packageWithAllocation: NewSubscriptionPackageWithAllocationPrice - ) = packageWithAllocation.validity() - - override fun visitTieredWithProration( - tieredWithProration: NewSubscriptionTierWithProrationPrice - ) = tieredWithProration.validity() - - override fun visitUnitWithProration( - unitWithProration: NewSubscriptionUnitWithProrationPrice - ) = unitWithProration.validity() - - override fun visitGroupedAllocation( - groupedAllocation: NewSubscriptionGroupedAllocationPrice - ) = groupedAllocation.validity() - - override fun visitGroupedWithProratedMinimum( - groupedWithProratedMinimum: - NewSubscriptionGroupedWithProratedMinimumPrice - ) = groupedWithProratedMinimum.validity() - - override fun visitBulkWithProration( - bulkWithProration: NewSubscriptionBulkWithProrationPrice - ) = bulkWithProration.validity() - - override fun visitScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: - NewSubscriptionScalableMatrixWithUnitPricingPrice - ) = scalableMatrixWithUnitPricing.validity() - - override fun visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: - NewSubscriptionScalableMatrixWithTieredPricingPrice - ) = scalableMatrixWithTieredPricing.validity() - - override fun visitCumulativeGroupedBulk( - cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice - ) = cumulativeGroupedBulk.validity() - - override fun visitMaxGroupTieredPackage( - maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice - ) = maxGroupTieredPackage.validity() - - override fun visitGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice - ) = groupedWithMeteredMinimum.validity() - - override fun visitMatrixWithDisplayName( - matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice - ) = matrixWithDisplayName.validity() - - override fun visitGroupedTieredPackage( - groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice - ) = groupedTieredPackage.validity() - - override fun visitMatrixWithAllocation( - matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice - ) = matrixWithAllocation.validity() - - override fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice - ) = tieredPackageWithMinimum.validity() - - override fun visitGroupedTiered( - groupedTiered: NewSubscriptionGroupedTieredPrice - ) = groupedTiered.validity() - - override fun visitGroupedWithMinMaxThresholds( - groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds - ) = groupedWithMinMaxThresholds.validity() - - override fun visitMinimum(minimum: Minimum) = minimum.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Price && - unit == other.unit && - package_ == other.package_ && - matrix == other.matrix && - tiered == other.tiered && - bulk == other.bulk && - thresholdTotalAmount == other.thresholdTotalAmount && - tieredPackage == other.tieredPackage && - tieredWithMinimum == other.tieredWithMinimum && - unitWithPercent == other.unitWithPercent && - packageWithAllocation == other.packageWithAllocation && - tieredWithProration == other.tieredWithProration && - unitWithProration == other.unitWithProration && - groupedAllocation == other.groupedAllocation && - groupedWithProratedMinimum == other.groupedWithProratedMinimum && - bulkWithProration == other.bulkWithProration && - scalableMatrixWithUnitPricing == other.scalableMatrixWithUnitPricing && - scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && - cumulativeGroupedBulk == other.cumulativeGroupedBulk && - maxGroupTieredPackage == other.maxGroupTieredPackage && - groupedWithMeteredMinimum == other.groupedWithMeteredMinimum && - matrixWithDisplayName == other.matrixWithDisplayName && - groupedTieredPackage == other.groupedTieredPackage && - matrixWithAllocation == other.matrixWithAllocation && - tieredPackageWithMinimum == other.tieredPackageWithMinimum && - groupedTiered == other.groupedTiered && - groupedWithMinMaxThresholds == other.groupedWithMinMaxThresholds && - minimum == other.minimum - } - - override fun hashCode(): Int = - Objects.hash( - unit, - package_, - matrix, - tiered, - bulk, - thresholdTotalAmount, - tieredPackage, - tieredWithMinimum, - unitWithPercent, - packageWithAllocation, - tieredWithProration, - unitWithProration, - groupedAllocation, - groupedWithProratedMinimum, - bulkWithProration, - scalableMatrixWithUnitPricing, - scalableMatrixWithTieredPricing, - cumulativeGroupedBulk, - maxGroupTieredPackage, - groupedWithMeteredMinimum, - matrixWithDisplayName, - groupedTieredPackage, - matrixWithAllocation, - tieredPackageWithMinimum, - groupedTiered, - groupedWithMinMaxThresholds, - minimum, - ) - - override fun toString(): String = - when { - unit != null -> "Price{unit=$unit}" - package_ != null -> "Price{package_=$package_}" - matrix != null -> "Price{matrix=$matrix}" - tiered != null -> "Price{tiered=$tiered}" - bulk != null -> "Price{bulk=$bulk}" - thresholdTotalAmount != null -> - "Price{thresholdTotalAmount=$thresholdTotalAmount}" - tieredPackage != null -> "Price{tieredPackage=$tieredPackage}" - tieredWithMinimum != null -> "Price{tieredWithMinimum=$tieredWithMinimum}" - unitWithPercent != null -> "Price{unitWithPercent=$unitWithPercent}" - packageWithAllocation != null -> - "Price{packageWithAllocation=$packageWithAllocation}" - tieredWithProration != null -> "Price{tieredWithProration=$tieredWithProration}" - unitWithProration != null -> "Price{unitWithProration=$unitWithProration}" - groupedAllocation != null -> "Price{groupedAllocation=$groupedAllocation}" - groupedWithProratedMinimum != null -> - "Price{groupedWithProratedMinimum=$groupedWithProratedMinimum}" - bulkWithProration != null -> "Price{bulkWithProration=$bulkWithProration}" - scalableMatrixWithUnitPricing != null -> - "Price{scalableMatrixWithUnitPricing=$scalableMatrixWithUnitPricing}" - scalableMatrixWithTieredPricing != null -> - "Price{scalableMatrixWithTieredPricing=$scalableMatrixWithTieredPricing}" - cumulativeGroupedBulk != null -> - "Price{cumulativeGroupedBulk=$cumulativeGroupedBulk}" - maxGroupTieredPackage != null -> - "Price{maxGroupTieredPackage=$maxGroupTieredPackage}" - groupedWithMeteredMinimum != null -> - "Price{groupedWithMeteredMinimum=$groupedWithMeteredMinimum}" - matrixWithDisplayName != null -> - "Price{matrixWithDisplayName=$matrixWithDisplayName}" - groupedTieredPackage != null -> - "Price{groupedTieredPackage=$groupedTieredPackage}" - matrixWithAllocation != null -> - "Price{matrixWithAllocation=$matrixWithAllocation}" - tieredPackageWithMinimum != null -> - "Price{tieredPackageWithMinimum=$tieredPackageWithMinimum}" - groupedTiered != null -> "Price{groupedTiered=$groupedTiered}" - groupedWithMinMaxThresholds != null -> - "Price{groupedWithMinMaxThresholds=$groupedWithMinMaxThresholds}" - minimum != null -> "Price{minimum=$minimum}" - _json != null -> "Price{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Price") - } - - companion object { - - fun ofUnit(unit: NewSubscriptionUnitPrice) = Price(unit = unit) - - fun ofPackage(package_: NewSubscriptionPackagePrice) = Price(package_ = package_) - - fun ofMatrix(matrix: NewSubscriptionMatrixPrice) = Price(matrix = matrix) - - fun ofTiered(tiered: NewSubscriptionTieredPrice) = Price(tiered = tiered) - - fun ofBulk(bulk: NewSubscriptionBulkPrice) = Price(bulk = bulk) - - fun ofThresholdTotalAmount( - thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice - ) = Price(thresholdTotalAmount = thresholdTotalAmount) - - fun ofTieredPackage(tieredPackage: NewSubscriptionTieredPackagePrice) = - Price(tieredPackage = tieredPackage) - - fun ofTieredWithMinimum(tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice) = - Price(tieredWithMinimum = tieredWithMinimum) - - fun ofUnitWithPercent(unitWithPercent: NewSubscriptionUnitWithPercentPrice) = - Price(unitWithPercent = unitWithPercent) - - fun ofPackageWithAllocation( - packageWithAllocation: NewSubscriptionPackageWithAllocationPrice - ) = Price(packageWithAllocation = packageWithAllocation) - - fun ofTieredWithProration( - tieredWithProration: NewSubscriptionTierWithProrationPrice - ) = Price(tieredWithProration = tieredWithProration) - - fun ofUnitWithProration(unitWithProration: NewSubscriptionUnitWithProrationPrice) = - Price(unitWithProration = unitWithProration) - - fun ofGroupedAllocation(groupedAllocation: NewSubscriptionGroupedAllocationPrice) = - Price(groupedAllocation = groupedAllocation) - - fun ofGroupedWithProratedMinimum( - groupedWithProratedMinimum: NewSubscriptionGroupedWithProratedMinimumPrice - ) = Price(groupedWithProratedMinimum = groupedWithProratedMinimum) - - fun ofBulkWithProration(bulkWithProration: NewSubscriptionBulkWithProrationPrice) = - Price(bulkWithProration = bulkWithProration) - - fun ofScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: NewSubscriptionScalableMatrixWithUnitPricingPrice - ) = Price(scalableMatrixWithUnitPricing = scalableMatrixWithUnitPricing) - - fun ofScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: - NewSubscriptionScalableMatrixWithTieredPricingPrice - ) = Price(scalableMatrixWithTieredPricing = scalableMatrixWithTieredPricing) - - fun ofCumulativeGroupedBulk( - cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice - ) = Price(cumulativeGroupedBulk = cumulativeGroupedBulk) - - fun ofMaxGroupTieredPackage( - maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice - ) = Price(maxGroupTieredPackage = maxGroupTieredPackage) - - fun ofGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice - ) = Price(groupedWithMeteredMinimum = groupedWithMeteredMinimum) - - fun ofMatrixWithDisplayName( - matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice - ) = Price(matrixWithDisplayName = matrixWithDisplayName) - - fun ofGroupedTieredPackage( - groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice - ) = Price(groupedTieredPackage = groupedTieredPackage) - - fun ofMatrixWithAllocation( - matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice - ) = Price(matrixWithAllocation = matrixWithAllocation) - - fun ofTieredPackageWithMinimum( - tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice - ) = Price(tieredPackageWithMinimum = tieredPackageWithMinimum) - - fun ofGroupedTiered(groupedTiered: NewSubscriptionGroupedTieredPrice) = - Price(groupedTiered = groupedTiered) - - fun ofGroupedWithMinMaxThresholds( - groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds - ) = Price(groupedWithMinMaxThresholds = groupedWithMinMaxThresholds) - - fun ofMinimum(minimum: Minimum) = Price(minimum = minimum) - } - - /** - * An interface that defines how to map each variant of [Price] to a value of type [T]. - */ - interface Visitor { - - fun visitUnit(unit: NewSubscriptionUnitPrice): T - - fun visitPackage(package_: NewSubscriptionPackagePrice): T - - fun visitMatrix(matrix: NewSubscriptionMatrixPrice): T - - fun visitTiered(tiered: NewSubscriptionTieredPrice): T - - fun visitBulk(bulk: NewSubscriptionBulkPrice): T - - fun visitThresholdTotalAmount( - thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice - ): T - - fun visitTieredPackage(tieredPackage: NewSubscriptionTieredPackagePrice): T - - fun visitTieredWithMinimum( - tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice - ): T - - fun visitUnitWithPercent(unitWithPercent: NewSubscriptionUnitWithPercentPrice): T - - fun visitPackageWithAllocation( - packageWithAllocation: NewSubscriptionPackageWithAllocationPrice - ): T - - fun visitTieredWithProration( - tieredWithProration: NewSubscriptionTierWithProrationPrice - ): T - - fun visitUnitWithProration( - unitWithProration: NewSubscriptionUnitWithProrationPrice - ): T - - fun visitGroupedAllocation( - groupedAllocation: NewSubscriptionGroupedAllocationPrice - ): T - - fun visitGroupedWithProratedMinimum( - groupedWithProratedMinimum: NewSubscriptionGroupedWithProratedMinimumPrice - ): T - - fun visitBulkWithProration( - bulkWithProration: NewSubscriptionBulkWithProrationPrice - ): T - - fun visitScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: NewSubscriptionScalableMatrixWithUnitPricingPrice - ): T - - fun visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: - NewSubscriptionScalableMatrixWithTieredPricingPrice - ): T - - fun visitCumulativeGroupedBulk( - cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice - ): T - - fun visitMaxGroupTieredPackage( - maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice - ): T - - fun visitGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice - ): T - - fun visitMatrixWithDisplayName( - matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice - ): T - - fun visitGroupedTieredPackage( - groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice - ): T - - fun visitMatrixWithAllocation( - matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice - ): T - - fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice - ): T - - fun visitGroupedTiered(groupedTiered: NewSubscriptionGroupedTieredPrice): T - - fun visitGroupedWithMinMaxThresholds( - groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds - ): T - - fun visitMinimum(minimum: Minimum): T - - /** - * Maps an unknown variant of [Price] to a value of type [T]. - * - * An instance of [Price] can contain an unknown variant if it was deserialized from - * data that doesn't match any known variant. For example, if the SDK is on an older - * version than the API, then the API may respond with new variants that the SDK is - * unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown Price: $json") - } - } - - internal class Deserializer : BaseDeserializer(Price::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): Price { - val json = JsonValue.fromJsonNode(node) - val modelType = json.asObject()?.get("model_type")?.asString() - - when (modelType) { - "unit" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(unit = it, _json = json) } ?: Price(_json = json) - } - "package" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(package_ = it, _json = json) } ?: Price(_json = json) - } - "matrix" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(matrix = it, _json = json) } ?: Price(_json = json) - } - "tiered" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(tiered = it, _json = json) } ?: Price(_json = json) - } - "bulk" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(bulk = it, _json = json) } ?: Price(_json = json) - } - "threshold_total_amount" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(thresholdTotalAmount = it, _json = json) } - ?: Price(_json = json) - } - "tiered_package" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(tieredPackage = it, _json = json) } - ?: Price(_json = json) - } - "tiered_with_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(tieredWithMinimum = it, _json = json) } - ?: Price(_json = json) - } - "unit_with_percent" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(unitWithPercent = it, _json = json) } - ?: Price(_json = json) - } - "package_with_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(packageWithAllocation = it, _json = json) } - ?: Price(_json = json) - } - "tiered_with_proration" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(tieredWithProration = it, _json = json) } - ?: Price(_json = json) - } - "unit_with_proration" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(unitWithProration = it, _json = json) } - ?: Price(_json = json) - } - "grouped_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedAllocation = it, _json = json) } - ?: Price(_json = json) - } - "grouped_with_prorated_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedWithProratedMinimum = it, _json = json) } - ?: Price(_json = json) - } - "bulk_with_proration" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(bulkWithProration = it, _json = json) } - ?: Price(_json = json) - } - "scalable_matrix_with_unit_pricing" -> { - return tryDeserialize( - node, - jacksonTypeRef< - NewSubscriptionScalableMatrixWithUnitPricingPrice - >(), - ) - ?.let { Price(scalableMatrixWithUnitPricing = it, _json = json) } - ?: Price(_json = json) - } - "scalable_matrix_with_tiered_pricing" -> { - return tryDeserialize( - node, - jacksonTypeRef< - NewSubscriptionScalableMatrixWithTieredPricingPrice - >(), - ) - ?.let { Price(scalableMatrixWithTieredPricing = it, _json = json) } - ?: Price(_json = json) - } - "cumulative_grouped_bulk" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(cumulativeGroupedBulk = it, _json = json) } - ?: Price(_json = json) - } - "max_group_tiered_package" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(maxGroupTieredPackage = it, _json = json) } - ?: Price(_json = json) - } - "grouped_with_metered_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedWithMeteredMinimum = it, _json = json) } - ?: Price(_json = json) - } - "matrix_with_display_name" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(matrixWithDisplayName = it, _json = json) } - ?: Price(_json = json) - } - "grouped_tiered_package" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedTieredPackage = it, _json = json) } - ?: Price(_json = json) - } - "matrix_with_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(matrixWithAllocation = it, _json = json) } - ?: Price(_json = json) - } - "tiered_package_with_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(tieredPackageWithMinimum = it, _json = json) } - ?: Price(_json = json) - } - "grouped_tiered" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedTiered = it, _json = json) } - ?: Price(_json = json) - } - "grouped_with_min_max_thresholds" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedWithMinMaxThresholds = it, _json = json) } - ?: Price(_json = json) - } - "minimum" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(minimum = it, _json = json) - } ?: Price(_json = json) - } - } - - return Price(_json = json) - } - } - - internal class Serializer : BaseSerializer(Price::class) { - - override fun serialize( - value: Price, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unit != null -> generator.writeObject(value.unit) - value.package_ != null -> generator.writeObject(value.package_) - value.matrix != null -> generator.writeObject(value.matrix) - value.tiered != null -> generator.writeObject(value.tiered) - value.bulk != null -> generator.writeObject(value.bulk) - value.thresholdTotalAmount != null -> - generator.writeObject(value.thresholdTotalAmount) - value.tieredPackage != null -> generator.writeObject(value.tieredPackage) - value.tieredWithMinimum != null -> - generator.writeObject(value.tieredWithMinimum) - value.unitWithPercent != null -> - generator.writeObject(value.unitWithPercent) - value.packageWithAllocation != null -> - generator.writeObject(value.packageWithAllocation) - value.tieredWithProration != null -> - generator.writeObject(value.tieredWithProration) - value.unitWithProration != null -> - generator.writeObject(value.unitWithProration) - value.groupedAllocation != null -> - generator.writeObject(value.groupedAllocation) - value.groupedWithProratedMinimum != null -> - generator.writeObject(value.groupedWithProratedMinimum) - value.bulkWithProration != null -> - generator.writeObject(value.bulkWithProration) - value.scalableMatrixWithUnitPricing != null -> - generator.writeObject(value.scalableMatrixWithUnitPricing) - value.scalableMatrixWithTieredPricing != null -> - generator.writeObject(value.scalableMatrixWithTieredPricing) - value.cumulativeGroupedBulk != null -> - generator.writeObject(value.cumulativeGroupedBulk) - value.maxGroupTieredPackage != null -> - generator.writeObject(value.maxGroupTieredPackage) - value.groupedWithMeteredMinimum != null -> - generator.writeObject(value.groupedWithMeteredMinimum) - value.matrixWithDisplayName != null -> - generator.writeObject(value.matrixWithDisplayName) - value.groupedTieredPackage != null -> - generator.writeObject(value.groupedTieredPackage) - value.matrixWithAllocation != null -> - generator.writeObject(value.matrixWithAllocation) - value.tieredPackageWithMinimum != null -> - generator.writeObject(value.tieredPackageWithMinimum) - value.groupedTiered != null -> generator.writeObject(value.groupedTiered) - value.groupedWithMinMaxThresholds != null -> - generator.writeObject(value.groupedWithMinMaxThresholds) - value.minimum != null -> generator.writeObject(value.minimum) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Price") - } - } - } - - class GroupedWithMinMaxThresholds - private constructor( - private val cadence: JsonField, - private val groupedWithMinMaxThresholdsConfig: - JsonField, - private val itemId: JsonField, - private val modelType: JsonValue, - private val name: JsonField, - private val billableMetricId: JsonField, - private val billedInAdvance: JsonField, - private val billingCycleConfiguration: JsonField, - private val conversionRate: JsonField, - private val conversionRateConfig: JsonField, - private val currency: JsonField, - private val dimensionalPriceConfiguration: - JsonField, - private val externalPriceId: JsonField, - private val fixedPriceQuantity: JsonField, - private val invoiceGroupingKey: JsonField, - private val invoicingCycleConfiguration: JsonField, - private val metadata: JsonField, - private val referenceId: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("cadence") - @ExcludeMissing - cadence: JsonField = JsonMissing.of(), - @JsonProperty("grouped_with_min_max_thresholds_config") - @ExcludeMissing - groupedWithMinMaxThresholdsConfig: - JsonField = - JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - modelType: JsonValue = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - name: JsonField = JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("conversion_rate_config") - @ExcludeMissing - conversionRateConfig: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - currency: JsonField = JsonMissing.of(), - @JsonProperty("dimensional_price_configuration") - @ExcludeMissing - dimensionalPriceConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - metadata: JsonField = JsonMissing.of(), - @JsonProperty("reference_id") - @ExcludeMissing - referenceId: JsonField = JsonMissing.of(), - ) : this( - cadence, - groupedWithMinMaxThresholdsConfig, - itemId, - modelType, - name, - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - conversionRateConfig, - currency, - dimensionalPriceConfiguration, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - mutableMapOf(), - ) - - /** - * The cadence to bill for this price on. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun groupedWithMinMaxThresholdsConfig(): GroupedWithMinMaxThresholdsConfig = - groupedWithMinMaxThresholdsConfig.getRequired( - "grouped_with_min_max_thresholds_config" - ) - - /** - * The id of the item the price will be associated with. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun itemId(): String = itemId.getRequired("item_id") - - /** - * Expected to always return the following: - * ```kotlin - * JsonValue.from("grouped_with_min_max_thresholds") - * ``` - * - * However, this method can be useful for debugging and logging (e.g. if the server - * responded with an unexpected value). - */ - @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType - - /** - * The name of the price. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun name(): String = name.getRequired("name") - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun billableMetricId(): String? = billableMetricId.getNullable("billable_metric_id") - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun billingCycleConfiguration(): NewBillingCycleConfiguration? = - billingCycleConfiguration.getNullable("billing_cycle_configuration") - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") - - /** - * The configuration for the rate of the price currency to the invoicing currency. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun conversionRateConfig(): ConversionRateConfig? = - conversionRateConfig.getNullable("conversion_rate_config") - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun currency(): String? = currency.getNullable("currency") - - /** - * For dimensional price: specifies a price group and dimension values - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = - dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") - - /** - * An alias for the price. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun fixedPriceQuantity(): Double? = - fixedPriceQuantity.getNullable("fixed_price_quantity") - - /** - * The property used to group this price on an invoice - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun invoiceGroupingKey(): String? = - invoiceGroupingKey.getNullable("invoice_grouping_key") - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun metadata(): Metadata? = metadata.getNullable("metadata") - - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun referenceId(): String? = referenceId.getNullable("reference_id") - - /** - * Returns the raw JSON value of [cadence]. - * - * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("cadence") - @ExcludeMissing - fun _cadence(): JsonField = cadence - - /** - * Returns the raw JSON value of [groupedWithMinMaxThresholdsConfig]. - * - * Unlike [groupedWithMinMaxThresholdsConfig], this method doesn't throw if the JSON - * field has an unexpected type. - */ - @JsonProperty("grouped_with_min_max_thresholds_config") - @ExcludeMissing - fun _groupedWithMinMaxThresholdsConfig(): - JsonField = groupedWithMinMaxThresholdsConfig - - /** - * Returns the raw JSON value of [itemId]. - * - * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - /** - * Returns the raw JSON value of [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - /** - * Returns the raw JSON value of [billableMetricId]. - * - * Unlike [billableMetricId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = billableMetricId - - /** - * Returns the raw JSON value of [billedInAdvance]. - * - * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance - - /** - * Returns the raw JSON value of [billingCycleConfiguration]. - * - * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** - * Returns the raw JSON value of [conversionRate]. - * - * Unlike [conversionRate], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** - * Returns the raw JSON value of [conversionRateConfig]. - * - * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("conversion_rate_config") - @ExcludeMissing - fun _conversionRateConfig(): JsonField = conversionRateConfig - - /** - * Returns the raw JSON value of [currency]. - * - * Unlike [currency], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("currency") - @ExcludeMissing - fun _currency(): JsonField = currency - - /** - * Returns the raw JSON value of [dimensionalPriceConfiguration]. - * - * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON - * field has an unexpected type. - */ - @JsonProperty("dimensional_price_configuration") - @ExcludeMissing - fun _dimensionalPriceConfiguration(): JsonField = - dimensionalPriceConfiguration - - /** - * Returns the raw JSON value of [externalPriceId]. - * - * Unlike [externalPriceId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * Returns the raw JSON value of [fixedPriceQuantity]. - * - * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** - * Returns the raw JSON value of [invoiceGroupingKey]. - * - * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Returns the raw JSON value of [invoicingCycleConfiguration]. - * - * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * Returns the raw JSON value of [metadata]. - * - * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - /** - * Returns the raw JSON value of [referenceId]. - * - * Unlike [referenceId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("reference_id") - @ExcludeMissing - fun _referenceId(): JsonField = referenceId - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [GroupedWithMinMaxThresholds]. - * - * The following fields are required: - * ```kotlin - * .cadence() - * .groupedWithMinMaxThresholdsConfig() - * .itemId() - * .name() - * ``` - */ - fun builder() = Builder() - } - - /** A builder for [GroupedWithMinMaxThresholds]. */ - class Builder internal constructor() { - - private var cadence: JsonField? = null - private var groupedWithMinMaxThresholdsConfig: - JsonField? = - null - private var itemId: JsonField? = null - private var modelType: JsonValue = - JsonValue.from("grouped_with_min_max_thresholds") - private var name: JsonField? = null - private var billableMetricId: JsonField = JsonMissing.of() - private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var conversionRateConfig: JsonField = - JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var dimensionalPriceConfiguration: - JsonField = - JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: - JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var referenceId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds) = - apply { - cadence = groupedWithMinMaxThresholds.cadence - groupedWithMinMaxThresholdsConfig = - groupedWithMinMaxThresholds.groupedWithMinMaxThresholdsConfig - itemId = groupedWithMinMaxThresholds.itemId - modelType = groupedWithMinMaxThresholds.modelType - name = groupedWithMinMaxThresholds.name - billableMetricId = groupedWithMinMaxThresholds.billableMetricId - billedInAdvance = groupedWithMinMaxThresholds.billedInAdvance - billingCycleConfiguration = - groupedWithMinMaxThresholds.billingCycleConfiguration - conversionRate = groupedWithMinMaxThresholds.conversionRate - conversionRateConfig = groupedWithMinMaxThresholds.conversionRateConfig - currency = groupedWithMinMaxThresholds.currency - dimensionalPriceConfiguration = - groupedWithMinMaxThresholds.dimensionalPriceConfiguration - externalPriceId = groupedWithMinMaxThresholds.externalPriceId - fixedPriceQuantity = groupedWithMinMaxThresholds.fixedPriceQuantity - invoiceGroupingKey = groupedWithMinMaxThresholds.invoiceGroupingKey - invoicingCycleConfiguration = - groupedWithMinMaxThresholds.invoicingCycleConfiguration - metadata = groupedWithMinMaxThresholds.metadata - referenceId = groupedWithMinMaxThresholds.referenceId - additionalProperties = - groupedWithMinMaxThresholds.additionalProperties.toMutableMap() - } - - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** - * Sets [Builder.cadence] to an arbitrary JSON value. - * - * You should usually call [Builder.cadence] with a well-typed [Cadence] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - - fun groupedWithMinMaxThresholdsConfig( - groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig - ) = - groupedWithMinMaxThresholdsConfig( - JsonField.of(groupedWithMinMaxThresholdsConfig) - ) - - /** - * Sets [Builder.groupedWithMinMaxThresholdsConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.groupedWithMinMaxThresholdsConfig] with a - * well-typed [GroupedWithMinMaxThresholdsConfig] value instead. This method is - * primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun groupedWithMinMaxThresholdsConfig( - groupedWithMinMaxThresholdsConfig: - JsonField - ) = apply { - this.groupedWithMinMaxThresholdsConfig = groupedWithMinMaxThresholdsConfig - } - - /** The id of the item the price will be associated with. */ - fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - - /** - * Sets [Builder.itemId] to an arbitrary JSON value. - * - * You should usually call [Builder.itemId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - /** - * Sets the field to an arbitrary JSON value. - * - * It is usually unnecessary to call this method because the field defaults to - * the following: - * ```kotlin - * JsonValue.from("grouped_with_min_max_thresholds") - * ``` - * - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } - - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) - - /** - * Sets [Builder.name] to an arbitrary JSON value. - * - * You should usually call [Builder.name] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun name(name: JsonField) = apply { this.name = name } - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: String?) = - billableMetricId(JsonField.ofNullable(billableMetricId)) - - /** - * Sets [Builder.billableMetricId] to an arbitrary JSON value. - * - * You should usually call [Builder.billableMetricId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun billableMetricId(billableMetricId: JsonField) = apply { - this.billableMetricId = billableMetricId - } - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if - * this is true, and in-arrears if this is false. - */ - fun billedInAdvance(billedInAdvance: Boolean?) = - billedInAdvance(JsonField.ofNullable(billedInAdvance)) - - /** - * Alias for [Builder.billedInAdvance]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun billedInAdvance(billedInAdvance: Boolean) = - billedInAdvance(billedInAdvance as Boolean?) - - /** - * Sets [Builder.billedInAdvance] to an arbitrary JSON value. - * - * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun billedInAdvance(billedInAdvance: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: NewBillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - - /** - * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.billingCycleConfiguration] with a well-typed - * [NewBillingCycleConfiguration] value instead. This method is primarily for - * setting the field to an undocumented or not yet supported value. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: JsonField - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: Double?) = - conversionRate(JsonField.ofNullable(conversionRate)) - - /** - * Alias for [Builder.conversionRate]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) - - /** - * Sets [Builder.conversionRate] to an arbitrary JSON value. - * - * You should usually call [Builder.conversionRate] with a well-typed [Double] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** - * The configuration for the rate of the price currency to the invoicing - * currency. - */ - fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = - conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) - - /** - * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.conversionRateConfig] with a well-typed - * [ConversionRateConfig] value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun conversionRateConfig( - conversionRateConfig: JsonField - ) = apply { this.conversionRateConfig = conversionRateConfig } - - /** - * Alias for calling [conversionRateConfig] with - * `ConversionRateConfig.ofUnit(unit)`. - */ - fun conversionRateConfig(unit: UnitConversionRateConfig) = - conversionRateConfig(ConversionRateConfig.ofUnit(unit)) - - /** - * Alias for calling [conversionRateConfig] with the following: - * ```kotlin - * UnitConversionRateConfig.builder() - * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) - * .unitConfig(unitConfig) - * .build() - * ``` - */ - fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = - conversionRateConfig( - UnitConversionRateConfig.builder() - .conversionRateType( - UnitConversionRateConfig.ConversionRateType.UNIT - ) - .unitConfig(unitConfig) - .build() - ) - - /** - * Alias for calling [conversionRateConfig] with - * `ConversionRateConfig.ofTiered(tiered)`. - */ - fun conversionRateConfig(tiered: TieredConversionRateConfig) = - conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) - - /** - * Alias for calling [conversionRateConfig] with the following: - * ```kotlin - * TieredConversionRateConfig.builder() - * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) - * .tieredConfig(tieredConfig) - * .build() - * ``` - */ - fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = - conversionRateConfig( - TieredConversionRateConfig.builder() - .conversionRateType( - TieredConversionRateConfig.ConversionRateType.TIERED - ) - .tieredConfig(tieredConfig) - .build() - ) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) - - /** - * Sets [Builder.currency] to an arbitrary JSON value. - * - * You should usually call [Builder.currency] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } - - /** For dimensional price: specifies a price group and dimension values */ - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? - ) = - dimensionalPriceConfiguration( - JsonField.ofNullable(dimensionalPriceConfiguration) - ) - - /** - * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.dimensionalPriceConfiguration] with a - * well-typed [NewDimensionalPriceConfiguration] value instead. This method is - * primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: JsonField - ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** - * Sets [Builder.externalPriceId] to an arbitrary JSON value. - * - * You should usually call [Builder.externalPriceId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun externalPriceId(externalPriceId: JsonField) = apply { - this.externalPriceId = externalPriceId - } - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = - fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) - - /** - * Alias for [Builder.fixedPriceQuantity]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. - * - * You should usually call [Builder.fixedPriceQuantity] with a well-typed - * [Double] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = - invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) - - /** - * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. - * - * You should usually call [Builder.invoiceGroupingKey] with a well-typed - * [String] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { - this.invoiceGroupingKey = invoiceGroupingKey - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are - * produced. If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: NewBillingCycleConfiguration? - ) = - invoicingCycleConfiguration( - JsonField.ofNullable(invoicingCycleConfiguration) - ) - - /** - * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.invoicingCycleConfiguration] with a - * well-typed [NewBillingCycleConfiguration] value instead. This method is - * primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * Sets [Builder.metadata] to an arbitrary JSON value. - * - * You should usually call [Builder.metadata] with a well-typed [Metadata] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - fun referenceId(referenceId: String?) = - referenceId(JsonField.ofNullable(referenceId)) - - /** - * Sets [Builder.referenceId] to an arbitrary JSON value. - * - * You should usually call [Builder.referenceId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun referenceId(referenceId: JsonField) = apply { - this.referenceId = referenceId - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [GroupedWithMinMaxThresholds]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```kotlin - * .cadence() - * .groupedWithMinMaxThresholdsConfig() - * .itemId() - * .name() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): GroupedWithMinMaxThresholds = - GroupedWithMinMaxThresholds( - checkRequired("cadence", cadence), - checkRequired( - "groupedWithMinMaxThresholdsConfig", - groupedWithMinMaxThresholdsConfig, - ), - checkRequired("itemId", itemId), - modelType, - checkRequired("name", name), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - conversionRateConfig, - currency, - dimensionalPriceConfiguration, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): GroupedWithMinMaxThresholds = apply { - if (validated) { - return@apply - } - - cadence().validate() - groupedWithMinMaxThresholdsConfig().validate() - itemId() - _modelType().let { - if (it != JsonValue.from("grouped_with_min_max_thresholds")) { - throw OrbInvalidDataException("'modelType' is invalid, received $it") - } - } - name() - billableMetricId() - billedInAdvance() - billingCycleConfiguration()?.validate() - conversionRate() - conversionRateConfig()?.validate() - currency() - dimensionalPriceConfiguration()?.validate() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration()?.validate() - metadata()?.validate() - referenceId() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (cadence.asKnown()?.validity() ?: 0) + - (groupedWithMinMaxThresholdsConfig.asKnown()?.validity() ?: 0) + - (if (itemId.asKnown() == null) 0 else 1) + - modelType.let { - if (it == JsonValue.from("grouped_with_min_max_thresholds")) 1 else 0 - } + - (if (name.asKnown() == null) 0 else 1) + - (if (billableMetricId.asKnown() == null) 0 else 1) + - (if (billedInAdvance.asKnown() == null) 0 else 1) + - (billingCycleConfiguration.asKnown()?.validity() ?: 0) + - (if (conversionRate.asKnown() == null) 0 else 1) + - (conversionRateConfig.asKnown()?.validity() ?: 0) + - (if (currency.asKnown() == null) 0 else 1) + - (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + - (if (externalPriceId.asKnown() == null) 0 else 1) + - (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + - (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + - (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + - (metadata.asKnown()?.validity() ?: 0) + - (if (referenceId.asKnown() == null) 0 else 1) - - /** The cadence to bill for this price on. */ - class Cadence - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - val ANNUAL = of("annual") - - val SEMI_ANNUAL = of("semi_annual") - - val MONTHLY = of("monthly") - - val QUARTERLY = of("quarterly") - - val ONE_TIME = of("one_time") - - val CUSTOM = of("custom") - - fun of(value: String) = Cadence(JsonField.of(value)) - } - - /** An enum containing [Cadence]'s known values. */ - enum class Known { - ANNUAL, - SEMI_ANNUAL, - MONTHLY, - QUARTERLY, - ONE_TIME, - CUSTOM, - } - - /** - * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Cadence] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - ANNUAL, - SEMI_ANNUAL, - MONTHLY, - QUARTERLY, - ONE_TIME, - CUSTOM, - /** - * An enum member indicating that [Cadence] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - ANNUAL -> Value.ANNUAL - SEMI_ANNUAL -> Value.SEMI_ANNUAL - MONTHLY -> Value.MONTHLY - QUARTERLY -> Value.QUARTERLY - ONE_TIME -> Value.ONE_TIME - CUSTOM -> Value.CUSTOM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - ANNUAL -> Known.ANNUAL - SEMI_ANNUAL -> Known.SEMI_ANNUAL - MONTHLY -> Known.MONTHLY - QUARTERLY -> Known.QUARTERLY - ONE_TIME -> Known.ONE_TIME - CUSTOM -> Known.CUSTOM - else -> throw OrbInvalidDataException("Unknown Cadence: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString() - ?: throw OrbInvalidDataException("Value is not a String") - - private var validated: Boolean = false - - fun validate(): Cadence = apply { - if (validated) { - return@apply - } + fun visitMatrixWithDisplayName( + matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice + ): T - known() - validated = true - } + fun visitGroupedTieredPackage( + groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice + ): T - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + fun visitMatrixWithAllocation( + matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice + ): T - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice + ): T - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + fun visitGroupedTiered(groupedTiered: NewSubscriptionGroupedTieredPrice): T - return other is Cadence && value == other.value - } + fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ): T - override fun hashCode() = value.hashCode() + fun visitMinimum(minimum: NewSubscriptionMinimumCompositePrice): T - override fun toString() = value.toString() + /** + * Maps an unknown variant of [Price] to a value of type [T]. + * + * An instance of [Price] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is + * unaware of. + * + * @throws OrbInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw OrbInvalidDataException("Unknown Price: $json") } + } - class GroupedWithMinMaxThresholdsConfig - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [GroupedWithMinMaxThresholdsConfig]. - */ - fun builder() = Builder() - } - - /** A builder for [GroupedWithMinMaxThresholdsConfig]. */ - class Builder internal constructor() { + internal class Deserializer : BaseDeserializer(Price::class) { - private var additionalProperties: MutableMap = - mutableMapOf() + override fun ObjectCodec.deserialize(node: JsonNode): Price { + val json = JsonValue.fromJsonNode(node) + val modelType = json.asObject()?.get("model_type")?.asString() - internal fun from( - groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig - ) = apply { - additionalProperties = - groupedWithMinMaxThresholdsConfig.additionalProperties - .toMutableMap() + when (modelType) { + "unit" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(unit = it, _json = json) } ?: Price(_json = json) } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) + "package" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(package_ = it, _json = json) } ?: Price(_json = json) } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) + "matrix" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(matrix = it, _json = json) } ?: Price(_json = json) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) + "tiered" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(tiered = it, _json = json) } ?: Price(_json = json) } - - /** - * Returns an immutable instance of [GroupedWithMinMaxThresholdsConfig]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): GroupedWithMinMaxThresholdsConfig = - GroupedWithMinMaxThresholdsConfig(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): GroupedWithMinMaxThresholdsConfig = apply { - if (validated) { - return@apply + "bulk" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(bulk = it, _json = json) } ?: Price(_json = json) } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false + "threshold_total_amount" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(thresholdTotalAmount = it, _json = json) } + ?: Price(_json = json) + } + "tiered_package" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(tieredPackage = it, _json = json) } + ?: Price(_json = json) + } + "tiered_with_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(tieredWithMinimum = it, _json = json) } + ?: Price(_json = json) + } + "unit_with_percent" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(unitWithPercent = it, _json = json) } + ?: Price(_json = json) + } + "package_with_allocation" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(packageWithAllocation = it, _json = json) } + ?: Price(_json = json) + } + "tiered_with_proration" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(tieredWithProration = it, _json = json) } + ?: Price(_json = json) + } + "unit_with_proration" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(unitWithProration = it, _json = json) } + ?: Price(_json = json) + } + "grouped_allocation" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedAllocation = it, _json = json) } + ?: Price(_json = json) + } + "grouped_with_prorated_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedWithProratedMinimum = it, _json = json) } + ?: Price(_json = json) + } + "bulk_with_proration" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(bulkWithProration = it, _json = json) } + ?: Price(_json = json) + } + "scalable_matrix_with_unit_pricing" -> { + return tryDeserialize( + node, + jacksonTypeRef< + NewSubscriptionScalableMatrixWithUnitPricingPrice + >(), + ) + ?.let { Price(scalableMatrixWithUnitPricing = it, _json = json) } + ?: Price(_json = json) } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - additionalProperties.count { (_, value) -> - !value.isNull() && !value.isMissing() + "scalable_matrix_with_tiered_pricing" -> { + return tryDeserialize( + node, + jacksonTypeRef< + NewSubscriptionScalableMatrixWithTieredPricingPrice + >(), + ) + ?.let { Price(scalableMatrixWithTieredPricing = it, _json = json) } + ?: Price(_json = json) } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + "cumulative_grouped_bulk" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(cumulativeGroupedBulk = it, _json = json) } + ?: Price(_json = json) } - - return other is GroupedWithMinMaxThresholdsConfig && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "GroupedWithMinMaxThresholdsConfig{additionalProperties=$additionalProperties}" - } - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - class Metadata - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Metadata]. */ - fun builder() = Builder() - } - - /** A builder for [Metadata]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = - mutableMapOf() - - internal fun from(metadata: Metadata) = apply { - additionalProperties = metadata.additionalProperties.toMutableMap() + "max_group_tiered_package" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(maxGroupTieredPackage = it, _json = json) } + ?: Price(_json = json) } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) + "grouped_with_metered_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedWithMeteredMinimum = it, _json = json) } + ?: Price(_json = json) } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) + "matrix_with_display_name" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(matrixWithDisplayName = it, _json = json) } + ?: Price(_json = json) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) + "grouped_tiered_package" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedTieredPackage = it, _json = json) } + ?: Price(_json = json) } - - /** - * Returns an immutable instance of [Metadata]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply + "matrix_with_allocation" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(matrixWithAllocation = it, _json = json) } + ?: Price(_json = json) } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false + "tiered_package_with_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(tieredPackageWithMinimum = it, _json = json) } + ?: Price(_json = json) } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - additionalProperties.count { (_, value) -> - !value.isNull() && !value.isMissing() + "grouped_tiered" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedTiered = it, _json = json) } + ?: Price(_json = json) } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + "grouped_with_min_max_thresholds" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedWithMinMaxThresholds = it, _json = json) } + ?: Price(_json = json) } - - return other is Metadata && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is GroupedWithMinMaxThresholds && - cadence == other.cadence && - groupedWithMinMaxThresholdsConfig == - other.groupedWithMinMaxThresholdsConfig && - itemId == other.itemId && - modelType == other.modelType && - name == other.name && - billableMetricId == other.billableMetricId && - billedInAdvance == other.billedInAdvance && - billingCycleConfiguration == other.billingCycleConfiguration && - conversionRate == other.conversionRate && - conversionRateConfig == other.conversionRateConfig && - currency == other.currency && - dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && - externalPriceId == other.externalPriceId && - fixedPriceQuantity == other.fixedPriceQuantity && - invoiceGroupingKey == other.invoiceGroupingKey && - invoicingCycleConfiguration == other.invoicingCycleConfiguration && - metadata == other.metadata && - referenceId == other.referenceId && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - cadence, - groupedWithMinMaxThresholdsConfig, - itemId, - modelType, - name, - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - conversionRateConfig, - currency, - dimensionalPriceConfiguration, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - additionalProperties, - ) + "minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(minimum = it, _json = json) } ?: Price(_json = json) + } + } + + return Price(_json = json) } + } - override fun hashCode(): Int = hashCode + internal class Serializer : BaseSerializer(Price::class) { - override fun toString() = - "GroupedWithMinMaxThresholds{cadence=$cadence, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + override fun serialize( + value: Price, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.unit != null -> generator.writeObject(value.unit) + value.package_ != null -> generator.writeObject(value.package_) + value.matrix != null -> generator.writeObject(value.matrix) + value.tiered != null -> generator.writeObject(value.tiered) + value.bulk != null -> generator.writeObject(value.bulk) + value.thresholdTotalAmount != null -> + generator.writeObject(value.thresholdTotalAmount) + value.tieredPackage != null -> generator.writeObject(value.tieredPackage) + value.tieredWithMinimum != null -> + generator.writeObject(value.tieredWithMinimum) + value.unitWithPercent != null -> + generator.writeObject(value.unitWithPercent) + value.packageWithAllocation != null -> + generator.writeObject(value.packageWithAllocation) + value.tieredWithProration != null -> + generator.writeObject(value.tieredWithProration) + value.unitWithProration != null -> + generator.writeObject(value.unitWithProration) + value.groupedAllocation != null -> + generator.writeObject(value.groupedAllocation) + value.groupedWithProratedMinimum != null -> + generator.writeObject(value.groupedWithProratedMinimum) + value.bulkWithProration != null -> + generator.writeObject(value.bulkWithProration) + value.scalableMatrixWithUnitPricing != null -> + generator.writeObject(value.scalableMatrixWithUnitPricing) + value.scalableMatrixWithTieredPricing != null -> + generator.writeObject(value.scalableMatrixWithTieredPricing) + value.cumulativeGroupedBulk != null -> + generator.writeObject(value.cumulativeGroupedBulk) + value.maxGroupTieredPackage != null -> + generator.writeObject(value.maxGroupTieredPackage) + value.groupedWithMeteredMinimum != null -> + generator.writeObject(value.groupedWithMeteredMinimum) + value.matrixWithDisplayName != null -> + generator.writeObject(value.matrixWithDisplayName) + value.groupedTieredPackage != null -> + generator.writeObject(value.groupedTieredPackage) + value.matrixWithAllocation != null -> + generator.writeObject(value.matrixWithAllocation) + value.tieredPackageWithMinimum != null -> + generator.writeObject(value.tieredPackageWithMinimum) + value.groupedTiered != null -> generator.writeObject(value.groupedTiered) + value.groupedWithMinMaxThresholds != null -> + generator.writeObject(value.groupedWithMinMaxThresholds) + value.minimum != null -> generator.writeObject(value.minimum) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Price") + } + } } - class Minimum + class GroupedWithMinMaxThresholds private constructor( private val cadence: JsonField, + private val groupedWithMinMaxThresholdsConfig: + JsonField, private val itemId: JsonField, - private val minimumConfig: JsonField, private val modelType: JsonValue, private val name: JsonField, private val billableMetricId: JsonField, @@ -13579,12 +10545,14 @@ private constructor( @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), + @JsonProperty("grouped_with_min_max_thresholds_config") + @ExcludeMissing + groupedWithMinMaxThresholdsConfig: + JsonField = + JsonMissing.of(), @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), - @JsonProperty("minimum_config") - @ExcludeMissing - minimumConfig: JsonField = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing modelType: JsonValue = JsonMissing.of(), @@ -13635,8 +10603,8 @@ private constructor( referenceId: JsonField = JsonMissing.of(), ) : this( cadence, + groupedWithMinMaxThresholdsConfig, itemId, - minimumConfig, modelType, name, billableMetricId, @@ -13665,25 +10633,28 @@ private constructor( fun cadence(): Cadence = cadence.getRequired("cadence") /** - * The id of the item the price will be associated with. - * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected * value). */ - fun itemId(): String = itemId.getRequired("item_id") + fun groupedWithMinMaxThresholdsConfig(): GroupedWithMinMaxThresholdsConfig = + groupedWithMinMaxThresholdsConfig.getRequired( + "grouped_with_min_max_thresholds_config" + ) /** + * The id of the item the price will be associated with. + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected * value). */ - fun minimumConfig(): MinimumConfig = minimumConfig.getRequired("minimum_config") + fun itemId(): String = itemId.getRequired("item_id") /** * Expected to always return the following: * ```kotlin - * JsonValue.from("minimum") + * JsonValue.from("grouped_with_min_max_thresholds") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -13830,22 +10801,23 @@ private constructor( fun _cadence(): JsonField = cadence /** - * Returns the raw JSON value of [itemId]. + * Returns the raw JSON value of [groupedWithMinMaxThresholdsConfig]. * - * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected - * type. + * Unlike [groupedWithMinMaxThresholdsConfig], this method doesn't throw if the JSON + * field has an unexpected type. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + @JsonProperty("grouped_with_min_max_thresholds_config") + @ExcludeMissing + fun _groupedWithMinMaxThresholdsConfig(): + JsonField = groupedWithMinMaxThresholdsConfig /** - * Returns the raw JSON value of [minimumConfig]. + * Returns the raw JSON value of [itemId]. * - * Unlike [minimumConfig], this method doesn't throw if the JSON field has an - * unexpected type. + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. */ - @JsonProperty("minimum_config") - @ExcludeMissing - fun _minimumConfig(): JsonField = minimumConfig + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId /** * Returns the raw JSON value of [name]. @@ -14003,26 +10975,30 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [Minimum]. + * Returns a mutable builder for constructing an instance of + * [GroupedWithMinMaxThresholds]. * * The following fields are required: * ```kotlin * .cadence() + * .groupedWithMinMaxThresholdsConfig() * .itemId() - * .minimumConfig() * .name() * ``` */ fun builder() = Builder() } - /** A builder for [Minimum]. */ + /** A builder for [GroupedWithMinMaxThresholds]. */ class Builder internal constructor() { private var cadence: JsonField? = null + private var groupedWithMinMaxThresholdsConfig: + JsonField? = + null private var itemId: JsonField? = null - private var minimumConfig: JsonField? = null - private var modelType: JsonValue = JsonValue.from("minimum") + private var modelType: JsonValue = + JsonValue.from("grouped_with_min_max_thresholds") private var name: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() @@ -14045,27 +11021,33 @@ private constructor( private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(minimum: Minimum) = apply { - cadence = minimum.cadence - itemId = minimum.itemId - minimumConfig = minimum.minimumConfig - modelType = minimum.modelType - name = minimum.name - billableMetricId = minimum.billableMetricId - billedInAdvance = minimum.billedInAdvance - billingCycleConfiguration = minimum.billingCycleConfiguration - conversionRate = minimum.conversionRate - conversionRateConfig = minimum.conversionRateConfig - currency = minimum.currency - dimensionalPriceConfiguration = minimum.dimensionalPriceConfiguration - externalPriceId = minimum.externalPriceId - fixedPriceQuantity = minimum.fixedPriceQuantity - invoiceGroupingKey = minimum.invoiceGroupingKey - invoicingCycleConfiguration = minimum.invoicingCycleConfiguration - metadata = minimum.metadata - referenceId = minimum.referenceId - additionalProperties = minimum.additionalProperties.toMutableMap() - } + internal fun from(groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds) = + apply { + cadence = groupedWithMinMaxThresholds.cadence + groupedWithMinMaxThresholdsConfig = + groupedWithMinMaxThresholds.groupedWithMinMaxThresholdsConfig + itemId = groupedWithMinMaxThresholds.itemId + modelType = groupedWithMinMaxThresholds.modelType + name = groupedWithMinMaxThresholds.name + billableMetricId = groupedWithMinMaxThresholds.billableMetricId + billedInAdvance = groupedWithMinMaxThresholds.billedInAdvance + billingCycleConfiguration = + groupedWithMinMaxThresholds.billingCycleConfiguration + conversionRate = groupedWithMinMaxThresholds.conversionRate + conversionRateConfig = groupedWithMinMaxThresholds.conversionRateConfig + currency = groupedWithMinMaxThresholds.currency + dimensionalPriceConfiguration = + groupedWithMinMaxThresholds.dimensionalPriceConfiguration + externalPriceId = groupedWithMinMaxThresholds.externalPriceId + fixedPriceQuantity = groupedWithMinMaxThresholds.fixedPriceQuantity + invoiceGroupingKey = groupedWithMinMaxThresholds.invoiceGroupingKey + invoicingCycleConfiguration = + groupedWithMinMaxThresholds.invoicingCycleConfiguration + metadata = groupedWithMinMaxThresholds.metadata + referenceId = groupedWithMinMaxThresholds.referenceId + additionalProperties = + groupedWithMinMaxThresholds.additionalProperties.toMutableMap() + } /** The cadence to bill for this price on. */ fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) @@ -14079,6 +11061,28 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + fun groupedWithMinMaxThresholdsConfig( + groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + ) = + groupedWithMinMaxThresholdsConfig( + JsonField.of(groupedWithMinMaxThresholdsConfig) + ) + + /** + * Sets [Builder.groupedWithMinMaxThresholdsConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.groupedWithMinMaxThresholdsConfig] with a + * well-typed [GroupedWithMinMaxThresholdsConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun groupedWithMinMaxThresholdsConfig( + groupedWithMinMaxThresholdsConfig: + JsonField + ) = apply { + this.groupedWithMinMaxThresholdsConfig = groupedWithMinMaxThresholdsConfig + } + /** The id of the item the price will be associated with. */ fun itemId(itemId: String) = itemId(JsonField.of(itemId)) @@ -14091,27 +11095,13 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun minimumConfig(minimumConfig: MinimumConfig) = - minimumConfig(JsonField.of(minimumConfig)) - - /** - * Sets [Builder.minimumConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.minimumConfig] with a well-typed - * [MinimumConfig] value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. - */ - fun minimumConfig(minimumConfig: JsonField) = apply { - this.minimumConfig = minimumConfig - } - /** * Sets the field to an arbitrary JSON value. * * It is usually unnecessary to call this method because the field defaults to * the following: * ```kotlin - * JsonValue.from("minimum") + * JsonValue.from("grouped_with_min_max_thresholds") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -14460,25 +11450,28 @@ private constructor( } /** - * Returns an immutable instance of [Minimum]. + * Returns an immutable instance of [GroupedWithMinMaxThresholds]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```kotlin * .cadence() + * .groupedWithMinMaxThresholdsConfig() * .itemId() - * .minimumConfig() * .name() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): Minimum = - Minimum( + fun build(): GroupedWithMinMaxThresholds = + GroupedWithMinMaxThresholds( checkRequired("cadence", cadence), + checkRequired( + "groupedWithMinMaxThresholdsConfig", + groupedWithMinMaxThresholdsConfig, + ), checkRequired("itemId", itemId), - checkRequired("minimumConfig", minimumConfig), modelType, checkRequired("name", name), billableMetricId, @@ -14500,16 +11493,16 @@ private constructor( private var validated: Boolean = false - fun validate(): Minimum = apply { + fun validate(): GroupedWithMinMaxThresholds = apply { if (validated) { return@apply } cadence().validate() + groupedWithMinMaxThresholdsConfig().validate() itemId() - minimumConfig().validate() _modelType().let { - if (it != JsonValue.from("minimum")) { + if (it != JsonValue.from("grouped_with_min_max_thresholds")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } @@ -14546,9 +11539,11 @@ private constructor( */ internal fun validity(): Int = (cadence.asKnown()?.validity() ?: 0) + + (groupedWithMinMaxThresholdsConfig.asKnown()?.validity() ?: 0) + (if (itemId.asKnown() == null) 0 else 1) + - (minimumConfig.asKnown()?.validity() ?: 0) + - modelType.let { if (it == JsonValue.from("minimum")) 1 else 0 } + + modelType.let { + if (it == JsonValue.from("grouped_with_min_max_thresholds")) 1 else 0 + } + (if (name.asKnown() == null) 0 else 1) + (if (billableMetricId.asKnown() == null) 0 else 1) + (if (billedInAdvance.asKnown() == null) 0 else 1) + @@ -14721,70 +11716,16 @@ private constructor( override fun toString() = value.toString() } - class MinimumConfig + class GroupedWithMinMaxThresholdsConfig + @JsonCreator private constructor( - private val minimumAmount: JsonField, - private val prorated: JsonField, - private val additionalProperties: MutableMap, + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map ) { - @JsonCreator - private constructor( - @JsonProperty("minimum_amount") - @ExcludeMissing - minimumAmount: JsonField = JsonMissing.of(), - @JsonProperty("prorated") - @ExcludeMissing - prorated: JsonField = JsonMissing.of(), - ) : this(minimumAmount, prorated, mutableMapOf()) - - /** - * The minimum amount to apply - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") - - /** - * By default, subtotals from minimum composite prices are prorated based on the - * service period. Set to false to disable proration. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun prorated(): Boolean? = prorated.getNullable("prorated") - - /** - * Returns the raw JSON value of [minimumAmount]. - * - * Unlike [minimumAmount], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("minimum_amount") - @ExcludeMissing - fun _minimumAmount(): JsonField = minimumAmount - - /** - * Returns the raw JSON value of [prorated]. - * - * Unlike [prorated], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("prorated") - @ExcludeMissing - fun _prorated(): JsonField = prorated - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + fun _additionalProperties(): Map = additionalProperties fun toBuilder() = Builder().from(this) @@ -14792,67 +11733,23 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [MinimumConfig]. - * - * The following fields are required: - * ```kotlin - * .minimumAmount() - * ``` + * [GroupedWithMinMaxThresholdsConfig]. */ fun builder() = Builder() } - /** A builder for [MinimumConfig]. */ + /** A builder for [GroupedWithMinMaxThresholdsConfig]. */ class Builder internal constructor() { - private var minimumAmount: JsonField? = null - private var prorated: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(minimumConfig: MinimumConfig) = apply { - minimumAmount = minimumConfig.minimumAmount - prorated = minimumConfig.prorated - additionalProperties = minimumConfig.additionalProperties.toMutableMap() - } - - /** The minimum amount to apply */ - fun minimumAmount(minimumAmount: String) = - minimumAmount(JsonField.of(minimumAmount)) - - /** - * Sets [Builder.minimumAmount] to an arbitrary JSON value. - * - * You should usually call [Builder.minimumAmount] with a well-typed - * [String] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun minimumAmount(minimumAmount: JsonField) = apply { - this.minimumAmount = minimumAmount - } - - /** - * By default, subtotals from minimum composite prices are prorated based on - * the service period. Set to false to disable proration. - */ - fun prorated(prorated: Boolean?) = prorated(JsonField.ofNullable(prorated)) - - /** - * Alias for [Builder.prorated]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun prorated(prorated: Boolean) = prorated(prorated as Boolean?) - - /** - * Sets [Builder.prorated] to an arbitrary JSON value. - * - * You should usually call [Builder.prorated] with a well-typed [Boolean] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun prorated(prorated: JsonField) = apply { - this.prorated = prorated + internal fun from( + groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + ) = apply { + additionalProperties = + groupedWithMinMaxThresholdsConfig.additionalProperties + .toMutableMap() } fun additionalProperties(additionalProperties: Map) = @@ -14878,34 +11775,21 @@ private constructor( } /** - * Returns an immutable instance of [MinimumConfig]. + * Returns an immutable instance of [GroupedWithMinMaxThresholdsConfig]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```kotlin - * .minimumAmount() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ - fun build(): MinimumConfig = - MinimumConfig( - checkRequired("minimumAmount", minimumAmount), - prorated, - additionalProperties.toMutableMap(), - ) + fun build(): GroupedWithMinMaxThresholdsConfig = + GroupedWithMinMaxThresholdsConfig(additionalProperties.toImmutable()) } private var validated: Boolean = false - fun validate(): MinimumConfig = apply { + fun validate(): GroupedWithMinMaxThresholdsConfig = apply { if (validated) { return@apply } - minimumAmount() - prorated() validated = true } @@ -14924,28 +11808,25 @@ private constructor( * Used for best match union deserialization. */ internal fun validity(): Int = - (if (minimumAmount.asKnown() == null) 0 else 1) + - (if (prorated.asKnown() == null) 0 else 1) + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is MinimumConfig && - minimumAmount == other.minimumAmount && - prorated == other.prorated && + return other is GroupedWithMinMaxThresholdsConfig && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { - Objects.hash(minimumAmount, prorated, additionalProperties) - } + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "MinimumConfig{minimumAmount=$minimumAmount, prorated=$prorated, additionalProperties=$additionalProperties}" + "GroupedWithMinMaxThresholdsConfig{additionalProperties=$additionalProperties}" } /** @@ -15062,10 +11943,11 @@ private constructor( return true } - return other is Minimum && + return other is GroupedWithMinMaxThresholds && cadence == other.cadence && + groupedWithMinMaxThresholdsConfig == + other.groupedWithMinMaxThresholdsConfig && itemId == other.itemId && - minimumConfig == other.minimumConfig && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && @@ -15087,8 +11969,8 @@ private constructor( private val hashCode: Int by lazy { Objects.hash( cadence, + groupedWithMinMaxThresholdsConfig, itemId, - minimumConfig, modelType, name, billableMetricId, @@ -15111,7 +11993,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Minimum{cadence=$cadence, itemId=$itemId, minimumConfig=$minimumConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "GroupedWithMinMaxThresholds{cadence=$cadence, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } } diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsParams.kt index 311410378..6eba17912 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsParams.kt @@ -1631,7 +1631,7 @@ private constructor( price(Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)) /** Alias for calling [price] with `Price.ofMinimum(minimum)`. */ - fun price(minimum: Price.Minimum) = price(Price.ofMinimum(minimum)) + fun price(minimum: NewFloatingMinimumCompositePrice) = price(Price.ofMinimum(minimum)) /** The id of the price to add to the subscription. */ fun priceId(priceId: String?) = priceId(JsonField.ofNullable(priceId)) @@ -3248,7 +3248,7 @@ private constructor( null, private val cumulativeGroupedBulk: NewFloatingCumulativeGroupedBulkPrice? = null, private val groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds? = null, - private val minimum: Minimum? = null, + private val minimum: NewFloatingMinimumCompositePrice? = null, private val _json: JsonValue? = null, ) { @@ -3314,7 +3314,7 @@ private constructor( fun groupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds? = groupedWithMinMaxThresholds - fun minimum(): Minimum? = minimum + fun minimum(): NewFloatingMinimumCompositePrice? = minimum fun isUnit(): Boolean = unit != null @@ -3445,7 +3445,7 @@ private constructor( fun asGroupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds = groupedWithMinMaxThresholds.getOrThrow("groupedWithMinMaxThresholds") - fun asMinimum(): Minimum = minimum.getOrThrow("minimum") + fun asMinimum(): NewFloatingMinimumCompositePrice = minimum.getOrThrow("minimum") fun _json(): JsonValue? = _json @@ -3654,7 +3654,7 @@ private constructor( groupedWithMinMaxThresholds.validate() } - override fun visitMinimum(minimum: Minimum) { + override fun visitMinimum(minimum: NewFloatingMinimumCompositePrice) { minimum.validate() } } @@ -3776,7 +3776,8 @@ private constructor( groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds ) = groupedWithMinMaxThresholds.validity() - override fun visitMinimum(minimum: Minimum) = minimum.validity() + override fun visitMinimum(minimum: NewFloatingMinimumCompositePrice) = + minimum.validity() override fun unknown(json: JsonValue?) = 0 } @@ -3983,7 +3984,7 @@ private constructor( groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds ) = Price(groupedWithMinMaxThresholds = groupedWithMinMaxThresholds) - fun ofMinimum(minimum: Minimum) = Price(minimum = minimum) + fun ofMinimum(minimum: NewFloatingMinimumCompositePrice) = Price(minimum = minimum) } /** @@ -4071,7 +4072,7 @@ private constructor( groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds ): T - fun visitMinimum(minimum: Minimum): T + fun visitMinimum(minimum: NewFloatingMinimumCompositePrice): T /** * Maps an unknown variant of [Price] to a value of type [T]. @@ -4286,9 +4287,11 @@ private constructor( ?: Price(_json = json) } "minimum" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(minimum = it, _json = json) - } ?: Price(_json = json) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(minimum = it, _json = json) } ?: Price(_json = json) } } @@ -5786,1520 +5789,6 @@ private constructor( override fun toString() = "GroupedWithMinMaxThresholds{cadence=$cadence, currency=$currency, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" } - - class Minimum - private constructor( - private val cadence: JsonField, - private val currency: JsonField, - private val itemId: JsonField, - private val minimumConfig: JsonField, - private val modelType: JsonValue, - private val name: JsonField, - private val billableMetricId: JsonField, - private val billedInAdvance: JsonField, - private val billingCycleConfiguration: JsonField, - private val conversionRate: JsonField, - private val conversionRateConfig: JsonField, - private val dimensionalPriceConfiguration: - JsonField, - private val externalPriceId: JsonField, - private val fixedPriceQuantity: JsonField, - private val invoiceGroupingKey: JsonField, - private val invoicingCycleConfiguration: JsonField, - private val metadata: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("cadence") - @ExcludeMissing - cadence: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - currency: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - itemId: JsonField = JsonMissing.of(), - @JsonProperty("minimum_config") - @ExcludeMissing - minimumConfig: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - modelType: JsonValue = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - name: JsonField = JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("conversion_rate_config") - @ExcludeMissing - conversionRateConfig: JsonField = JsonMissing.of(), - @JsonProperty("dimensional_price_configuration") - @ExcludeMissing - dimensionalPriceConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - metadata: JsonField = JsonMissing.of(), - ) : this( - cadence, - currency, - itemId, - minimumConfig, - modelType, - name, - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - conversionRateConfig, - dimensionalPriceConfiguration, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - mutableMapOf(), - ) - - /** - * The cadence to bill for this price on. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - /** - * An ISO 4217 currency string for which this price is billed in. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun currency(): String = currency.getRequired("currency") - - /** - * The id of the item the price will be associated with. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun itemId(): String = itemId.getRequired("item_id") - - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun minimumConfig(): MinimumConfig = minimumConfig.getRequired("minimum_config") - - /** - * Expected to always return the following: - * ```kotlin - * JsonValue.from("minimum") - * ``` - * - * However, this method can be useful for debugging and logging (e.g. if the server - * responded with an unexpected value). - */ - @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType - - /** - * The name of the price. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun name(): String = name.getRequired("name") - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun billableMetricId(): String? = billableMetricId.getNullable("billable_metric_id") - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun billingCycleConfiguration(): NewBillingCycleConfiguration? = - billingCycleConfiguration.getNullable("billing_cycle_configuration") - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") - - /** - * The configuration for the rate of the price currency to the invoicing currency. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun conversionRateConfig(): ConversionRateConfig? = - conversionRateConfig.getNullable("conversion_rate_config") - - /** - * For dimensional price: specifies a price group and dimension values - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = - dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") - - /** - * An alias for the price. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun fixedPriceQuantity(): Double? = - fixedPriceQuantity.getNullable("fixed_price_quantity") - - /** - * The property used to group this price on an invoice - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun invoiceGroupingKey(): String? = - invoiceGroupingKey.getNullable("invoice_grouping_key") - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun metadata(): Metadata? = metadata.getNullable("metadata") - - /** - * Returns the raw JSON value of [cadence]. - * - * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("cadence") - @ExcludeMissing - fun _cadence(): JsonField = cadence - - /** - * Returns the raw JSON value of [currency]. - * - * Unlike [currency], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("currency") - @ExcludeMissing - fun _currency(): JsonField = currency - - /** - * Returns the raw JSON value of [itemId]. - * - * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - /** - * Returns the raw JSON value of [minimumConfig]. - * - * Unlike [minimumConfig], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("minimum_config") - @ExcludeMissing - fun _minimumConfig(): JsonField = minimumConfig - - /** - * Returns the raw JSON value of [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - /** - * Returns the raw JSON value of [billableMetricId]. - * - * Unlike [billableMetricId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = billableMetricId - - /** - * Returns the raw JSON value of [billedInAdvance]. - * - * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance - - /** - * Returns the raw JSON value of [billingCycleConfiguration]. - * - * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** - * Returns the raw JSON value of [conversionRate]. - * - * Unlike [conversionRate], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** - * Returns the raw JSON value of [conversionRateConfig]. - * - * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("conversion_rate_config") - @ExcludeMissing - fun _conversionRateConfig(): JsonField = conversionRateConfig - - /** - * Returns the raw JSON value of [dimensionalPriceConfiguration]. - * - * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON - * field has an unexpected type. - */ - @JsonProperty("dimensional_price_configuration") - @ExcludeMissing - fun _dimensionalPriceConfiguration(): JsonField = - dimensionalPriceConfiguration - - /** - * Returns the raw JSON value of [externalPriceId]. - * - * Unlike [externalPriceId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * Returns the raw JSON value of [fixedPriceQuantity]. - * - * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** - * Returns the raw JSON value of [invoiceGroupingKey]. - * - * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Returns the raw JSON value of [invoicingCycleConfiguration]. - * - * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * Returns the raw JSON value of [metadata]. - * - * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [Minimum]. - * - * The following fields are required: - * ```kotlin - * .cadence() - * .currency() - * .itemId() - * .minimumConfig() - * .name() - * ``` - */ - fun builder() = Builder() - } - - /** A builder for [Minimum]. */ - class Builder internal constructor() { - - private var cadence: JsonField? = null - private var currency: JsonField? = null - private var itemId: JsonField? = null - private var minimumConfig: JsonField? = null - private var modelType: JsonValue = JsonValue.from("minimum") - private var name: JsonField? = null - private var billableMetricId: JsonField = JsonMissing.of() - private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var conversionRateConfig: JsonField = - JsonMissing.of() - private var dimensionalPriceConfiguration: - JsonField = - JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: - JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(minimum: Minimum) = apply { - cadence = minimum.cadence - currency = minimum.currency - itemId = minimum.itemId - minimumConfig = minimum.minimumConfig - modelType = minimum.modelType - name = minimum.name - billableMetricId = minimum.billableMetricId - billedInAdvance = minimum.billedInAdvance - billingCycleConfiguration = minimum.billingCycleConfiguration - conversionRate = minimum.conversionRate - conversionRateConfig = minimum.conversionRateConfig - dimensionalPriceConfiguration = minimum.dimensionalPriceConfiguration - externalPriceId = minimum.externalPriceId - fixedPriceQuantity = minimum.fixedPriceQuantity - invoiceGroupingKey = minimum.invoiceGroupingKey - invoicingCycleConfiguration = minimum.invoicingCycleConfiguration - metadata = minimum.metadata - additionalProperties = minimum.additionalProperties.toMutableMap() - } - - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** - * Sets [Builder.cadence] to an arbitrary JSON value. - * - * You should usually call [Builder.cadence] with a well-typed [Cadence] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - - /** An ISO 4217 currency string for which this price is billed in. */ - fun currency(currency: String) = currency(JsonField.of(currency)) - - /** - * Sets [Builder.currency] to an arbitrary JSON value. - * - * You should usually call [Builder.currency] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } - - /** The id of the item the price will be associated with. */ - fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - - /** - * Sets [Builder.itemId] to an arbitrary JSON value. - * - * You should usually call [Builder.itemId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - fun minimumConfig(minimumConfig: MinimumConfig) = - minimumConfig(JsonField.of(minimumConfig)) - - /** - * Sets [Builder.minimumConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.minimumConfig] with a well-typed - * [MinimumConfig] value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. - */ - fun minimumConfig(minimumConfig: JsonField) = apply { - this.minimumConfig = minimumConfig - } - - /** - * Sets the field to an arbitrary JSON value. - * - * It is usually unnecessary to call this method because the field defaults to - * the following: - * ```kotlin - * JsonValue.from("minimum") - * ``` - * - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } - - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) - - /** - * Sets [Builder.name] to an arbitrary JSON value. - * - * You should usually call [Builder.name] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun name(name: JsonField) = apply { this.name = name } - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: String?) = - billableMetricId(JsonField.ofNullable(billableMetricId)) - - /** - * Sets [Builder.billableMetricId] to an arbitrary JSON value. - * - * You should usually call [Builder.billableMetricId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun billableMetricId(billableMetricId: JsonField) = apply { - this.billableMetricId = billableMetricId - } - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if - * this is true, and in-arrears if this is false. - */ - fun billedInAdvance(billedInAdvance: Boolean?) = - billedInAdvance(JsonField.ofNullable(billedInAdvance)) - - /** - * Alias for [Builder.billedInAdvance]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun billedInAdvance(billedInAdvance: Boolean) = - billedInAdvance(billedInAdvance as Boolean?) - - /** - * Sets [Builder.billedInAdvance] to an arbitrary JSON value. - * - * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun billedInAdvance(billedInAdvance: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: NewBillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - - /** - * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.billingCycleConfiguration] with a well-typed - * [NewBillingCycleConfiguration] value instead. This method is primarily for - * setting the field to an undocumented or not yet supported value. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: JsonField - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: Double?) = - conversionRate(JsonField.ofNullable(conversionRate)) - - /** - * Alias for [Builder.conversionRate]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) - - /** - * Sets [Builder.conversionRate] to an arbitrary JSON value. - * - * You should usually call [Builder.conversionRate] with a well-typed [Double] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** - * The configuration for the rate of the price currency to the invoicing - * currency. - */ - fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = - conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) - - /** - * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.conversionRateConfig] with a well-typed - * [ConversionRateConfig] value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun conversionRateConfig( - conversionRateConfig: JsonField - ) = apply { this.conversionRateConfig = conversionRateConfig } - - /** - * Alias for calling [conversionRateConfig] with - * `ConversionRateConfig.ofUnit(unit)`. - */ - fun conversionRateConfig(unit: UnitConversionRateConfig) = - conversionRateConfig(ConversionRateConfig.ofUnit(unit)) - - /** - * Alias for calling [conversionRateConfig] with the following: - * ```kotlin - * UnitConversionRateConfig.builder() - * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) - * .unitConfig(unitConfig) - * .build() - * ``` - */ - fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = - conversionRateConfig( - UnitConversionRateConfig.builder() - .conversionRateType( - UnitConversionRateConfig.ConversionRateType.UNIT - ) - .unitConfig(unitConfig) - .build() - ) - - /** - * Alias for calling [conversionRateConfig] with - * `ConversionRateConfig.ofTiered(tiered)`. - */ - fun conversionRateConfig(tiered: TieredConversionRateConfig) = - conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) - - /** - * Alias for calling [conversionRateConfig] with the following: - * ```kotlin - * TieredConversionRateConfig.builder() - * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) - * .tieredConfig(tieredConfig) - * .build() - * ``` - */ - fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = - conversionRateConfig( - TieredConversionRateConfig.builder() - .conversionRateType( - TieredConversionRateConfig.ConversionRateType.TIERED - ) - .tieredConfig(tieredConfig) - .build() - ) - - /** For dimensional price: specifies a price group and dimension values */ - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? - ) = - dimensionalPriceConfiguration( - JsonField.ofNullable(dimensionalPriceConfiguration) - ) - - /** - * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.dimensionalPriceConfiguration] with a - * well-typed [NewDimensionalPriceConfiguration] value instead. This method is - * primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: JsonField - ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** - * Sets [Builder.externalPriceId] to an arbitrary JSON value. - * - * You should usually call [Builder.externalPriceId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun externalPriceId(externalPriceId: JsonField) = apply { - this.externalPriceId = externalPriceId - } - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = - fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) - - /** - * Alias for [Builder.fixedPriceQuantity]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. - * - * You should usually call [Builder.fixedPriceQuantity] with a well-typed - * [Double] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = - invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) - - /** - * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. - * - * You should usually call [Builder.invoiceGroupingKey] with a well-typed - * [String] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { - this.invoiceGroupingKey = invoiceGroupingKey - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are - * produced. If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: NewBillingCycleConfiguration? - ) = - invoicingCycleConfiguration( - JsonField.ofNullable(invoicingCycleConfiguration) - ) - - /** - * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.invoicingCycleConfiguration] with a - * well-typed [NewBillingCycleConfiguration] value instead. This method is - * primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * Sets [Builder.metadata] to an arbitrary JSON value. - * - * You should usually call [Builder.metadata] with a well-typed [Metadata] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Minimum]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```kotlin - * .cadence() - * .currency() - * .itemId() - * .minimumConfig() - * .name() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Minimum = - Minimum( - checkRequired("cadence", cadence), - checkRequired("currency", currency), - checkRequired("itemId", itemId), - checkRequired("minimumConfig", minimumConfig), - modelType, - checkRequired("name", name), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - conversionRateConfig, - dimensionalPriceConfiguration, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Minimum = apply { - if (validated) { - return@apply - } - - cadence().validate() - currency() - itemId() - minimumConfig().validate() - _modelType().let { - if (it != JsonValue.from("minimum")) { - throw OrbInvalidDataException("'modelType' is invalid, received $it") - } - } - name() - billableMetricId() - billedInAdvance() - billingCycleConfiguration()?.validate() - conversionRate() - conversionRateConfig()?.validate() - dimensionalPriceConfiguration()?.validate() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration()?.validate() - metadata()?.validate() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (cadence.asKnown()?.validity() ?: 0) + - (if (currency.asKnown() == null) 0 else 1) + - (if (itemId.asKnown() == null) 0 else 1) + - (minimumConfig.asKnown()?.validity() ?: 0) + - modelType.let { if (it == JsonValue.from("minimum")) 1 else 0 } + - (if (name.asKnown() == null) 0 else 1) + - (if (billableMetricId.asKnown() == null) 0 else 1) + - (if (billedInAdvance.asKnown() == null) 0 else 1) + - (billingCycleConfiguration.asKnown()?.validity() ?: 0) + - (if (conversionRate.asKnown() == null) 0 else 1) + - (conversionRateConfig.asKnown()?.validity() ?: 0) + - (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + - (if (externalPriceId.asKnown() == null) 0 else 1) + - (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + - (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + - (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + - (metadata.asKnown()?.validity() ?: 0) - - /** The cadence to bill for this price on. */ - class Cadence - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - val ANNUAL = of("annual") - - val SEMI_ANNUAL = of("semi_annual") - - val MONTHLY = of("monthly") - - val QUARTERLY = of("quarterly") - - val ONE_TIME = of("one_time") - - val CUSTOM = of("custom") - - fun of(value: String) = Cadence(JsonField.of(value)) - } - - /** An enum containing [Cadence]'s known values. */ - enum class Known { - ANNUAL, - SEMI_ANNUAL, - MONTHLY, - QUARTERLY, - ONE_TIME, - CUSTOM, - } - - /** - * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Cadence] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - ANNUAL, - SEMI_ANNUAL, - MONTHLY, - QUARTERLY, - ONE_TIME, - CUSTOM, - /** - * An enum member indicating that [Cadence] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - ANNUAL -> Value.ANNUAL - SEMI_ANNUAL -> Value.SEMI_ANNUAL - MONTHLY -> Value.MONTHLY - QUARTERLY -> Value.QUARTERLY - ONE_TIME -> Value.ONE_TIME - CUSTOM -> Value.CUSTOM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - ANNUAL -> Known.ANNUAL - SEMI_ANNUAL -> Known.SEMI_ANNUAL - MONTHLY -> Known.MONTHLY - QUARTERLY -> Known.QUARTERLY - ONE_TIME -> Known.ONE_TIME - CUSTOM -> Known.CUSTOM - else -> throw OrbInvalidDataException("Unknown Cadence: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString() - ?: throw OrbInvalidDataException("Value is not a String") - - private var validated: Boolean = false - - fun validate(): Cadence = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Cadence && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class MinimumConfig - private constructor( - private val minimumAmount: JsonField, - private val prorated: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("minimum_amount") - @ExcludeMissing - minimumAmount: JsonField = JsonMissing.of(), - @JsonProperty("prorated") - @ExcludeMissing - prorated: JsonField = JsonMissing.of(), - ) : this(minimumAmount, prorated, mutableMapOf()) - - /** - * The minimum amount to apply - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") - - /** - * By default, subtotals from minimum composite prices are prorated based on the - * service period. Set to false to disable proration. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun prorated(): Boolean? = prorated.getNullable("prorated") - - /** - * Returns the raw JSON value of [minimumAmount]. - * - * Unlike [minimumAmount], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("minimum_amount") - @ExcludeMissing - fun _minimumAmount(): JsonField = minimumAmount - - /** - * Returns the raw JSON value of [prorated]. - * - * Unlike [prorated], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("prorated") - @ExcludeMissing - fun _prorated(): JsonField = prorated - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [MinimumConfig]. - * - * The following fields are required: - * ```kotlin - * .minimumAmount() - * ``` - */ - fun builder() = Builder() - } - - /** A builder for [MinimumConfig]. */ - class Builder internal constructor() { - - private var minimumAmount: JsonField? = null - private var prorated: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - internal fun from(minimumConfig: MinimumConfig) = apply { - minimumAmount = minimumConfig.minimumAmount - prorated = minimumConfig.prorated - additionalProperties = minimumConfig.additionalProperties.toMutableMap() - } - - /** The minimum amount to apply */ - fun minimumAmount(minimumAmount: String) = - minimumAmount(JsonField.of(minimumAmount)) - - /** - * Sets [Builder.minimumAmount] to an arbitrary JSON value. - * - * You should usually call [Builder.minimumAmount] with a well-typed - * [String] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun minimumAmount(minimumAmount: JsonField) = apply { - this.minimumAmount = minimumAmount - } - - /** - * By default, subtotals from minimum composite prices are prorated based on - * the service period. Set to false to disable proration. - */ - fun prorated(prorated: Boolean?) = prorated(JsonField.ofNullable(prorated)) - - /** - * Alias for [Builder.prorated]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun prorated(prorated: Boolean) = prorated(prorated as Boolean?) - - /** - * Sets [Builder.prorated] to an arbitrary JSON value. - * - * You should usually call [Builder.prorated] with a well-typed [Boolean] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun prorated(prorated: JsonField) = apply { - this.prorated = prorated - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [MinimumConfig]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```kotlin - * .minimumAmount() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): MinimumConfig = - MinimumConfig( - checkRequired("minimumAmount", minimumAmount), - prorated, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): MinimumConfig = apply { - if (validated) { - return@apply - } - - minimumAmount() - prorated() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (if (minimumAmount.asKnown() == null) 0 else 1) + - (if (prorated.asKnown() == null) 0 else 1) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is MinimumConfig && - minimumAmount == other.minimumAmount && - prorated == other.prorated && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(minimumAmount, prorated, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "MinimumConfig{minimumAmount=$minimumAmount, prorated=$prorated, additionalProperties=$additionalProperties}" - } - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - class Metadata - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Metadata]. */ - fun builder() = Builder() - } - - /** A builder for [Metadata]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = - mutableMapOf() - - internal fun from(metadata: Metadata) = apply { - additionalProperties = metadata.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Metadata]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - additionalProperties.count { (_, value) -> - !value.isNull() && !value.isMissing() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Metadata && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Minimum && - cadence == other.cadence && - currency == other.currency && - itemId == other.itemId && - minimumConfig == other.minimumConfig && - modelType == other.modelType && - name == other.name && - billableMetricId == other.billableMetricId && - billedInAdvance == other.billedInAdvance && - billingCycleConfiguration == other.billingCycleConfiguration && - conversionRate == other.conversionRate && - conversionRateConfig == other.conversionRateConfig && - dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && - externalPriceId == other.externalPriceId && - fixedPriceQuantity == other.fixedPriceQuantity && - invoiceGroupingKey == other.invoiceGroupingKey && - invoicingCycleConfiguration == other.invoicingCycleConfiguration && - metadata == other.metadata && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - cadence, - currency, - itemId, - minimumConfig, - modelType, - name, - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - conversionRateConfig, - dimensionalPriceConfiguration, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Minimum{cadence=$cadence, currency=$currency, itemId=$itemId, minimumConfig=$minimumConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" - } } override fun equals(other: Any?): Boolean { diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionSchedulePlanChangeParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionSchedulePlanChangeParams.kt index e5d59cef3..04a768f6b 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionSchedulePlanChangeParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionSchedulePlanChangeParams.kt @@ -4353,7 +4353,8 @@ private constructor( price(Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)) /** Alias for calling [price] with `Price.ofMinimum(minimum)`. */ - fun price(minimum: Price.Minimum) = price(Price.ofMinimum(minimum)) + fun price(minimum: NewSubscriptionMinimumCompositePrice) = + price(Price.ofMinimum(minimum)) /** The id of the price to add to the subscription. */ fun priceId(priceId: String?) = priceId(JsonField.ofNullable(priceId)) @@ -4510,7 +4511,7 @@ private constructor( null, private val groupedTiered: NewSubscriptionGroupedTieredPrice? = null, private val groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds? = null, - private val minimum: Minimum? = null, + private val minimum: NewSubscriptionMinimumCompositePrice? = null, private val _json: JsonValue? = null, ) { @@ -4580,7 +4581,7 @@ private constructor( fun groupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds? = groupedWithMinMaxThresholds - fun minimum(): Minimum? = minimum + fun minimum(): NewSubscriptionMinimumCompositePrice? = minimum fun isUnit(): Boolean = unit != null @@ -4712,7 +4713,7 @@ private constructor( fun asGroupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds = groupedWithMinMaxThresholds.getOrThrow("groupedWithMinMaxThresholds") - fun asMinimum(): Minimum = minimum.getOrThrow("minimum") + fun asMinimum(): NewSubscriptionMinimumCompositePrice = minimum.getOrThrow("minimum") fun _json(): JsonValue? = _json @@ -4922,7 +4923,7 @@ private constructor( groupedWithMinMaxThresholds.validate() } - override fun visitMinimum(minimum: Minimum) { + override fun visitMinimum(minimum: NewSubscriptionMinimumCompositePrice) { minimum.validate() } } @@ -5047,7 +5048,8 @@ private constructor( groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds ) = groupedWithMinMaxThresholds.validity() - override fun visitMinimum(minimum: Minimum) = minimum.validity() + override fun visitMinimum(minimum: NewSubscriptionMinimumCompositePrice) = + minimum.validity() override fun unknown(json: JsonValue?) = 0 } @@ -5255,7 +5257,8 @@ private constructor( groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds ) = Price(groupedWithMinMaxThresholds = groupedWithMinMaxThresholds) - fun ofMinimum(minimum: Minimum) = Price(minimum = minimum) + fun ofMinimum(minimum: NewSubscriptionMinimumCompositePrice) = + Price(minimum = minimum) } /** @@ -5352,7 +5355,7 @@ private constructor( groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds ): T - fun visitMinimum(minimum: Minimum): T + fun visitMinimum(minimum: NewSubscriptionMinimumCompositePrice): T /** * Maps an unknown variant of [Price] to a value of type [T]. @@ -5578,9 +5581,11 @@ private constructor( ?: Price(_json = json) } "minimum" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(minimum = it, _json = json) - } ?: Price(_json = json) + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(minimum = it, _json = json) } ?: Price(_json = json) } } @@ -7128,1569 +7133,1078 @@ private constructor( override fun toString() = "GroupedWithMinMaxThresholds{cadence=$cadence, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } + } - class Minimum - private constructor( - private val cadence: JsonField, - private val itemId: JsonField, - private val minimumConfig: JsonField, - private val modelType: JsonValue, - private val name: JsonField, - private val billableMetricId: JsonField, - private val billedInAdvance: JsonField, - private val billingCycleConfiguration: JsonField, - private val conversionRate: JsonField, - private val conversionRateConfig: JsonField, - private val currency: JsonField, - private val dimensionalPriceConfiguration: - JsonField, - private val externalPriceId: JsonField, - private val fixedPriceQuantity: JsonField, - private val invoiceGroupingKey: JsonField, - private val invoicingCycleConfiguration: JsonField, - private val metadata: JsonField, - private val referenceId: JsonField, - private val additionalProperties: MutableMap, - ) { + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - @JsonCreator - private constructor( - @JsonProperty("cadence") - @ExcludeMissing - cadence: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - itemId: JsonField = JsonMissing.of(), - @JsonProperty("minimum_config") - @ExcludeMissing - minimumConfig: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - modelType: JsonValue = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - name: JsonField = JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("conversion_rate_config") - @ExcludeMissing - conversionRateConfig: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - currency: JsonField = JsonMissing.of(), - @JsonProperty("dimensional_price_configuration") - @ExcludeMissing - dimensionalPriceConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - metadata: JsonField = JsonMissing.of(), - @JsonProperty("reference_id") - @ExcludeMissing - referenceId: JsonField = JsonMissing.of(), - ) : this( - cadence, - itemId, - minimumConfig, - modelType, - name, - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - conversionRateConfig, - currency, - dimensionalPriceConfiguration, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - mutableMapOf(), - ) + return other is AddPrice && + allocationPrice == other.allocationPrice && + discounts == other.discounts && + endDate == other.endDate && + externalPriceId == other.externalPriceId && + maximumAmount == other.maximumAmount && + minimumAmount == other.minimumAmount && + planPhaseOrder == other.planPhaseOrder && + price == other.price && + priceId == other.priceId && + startDate == other.startDate && + additionalProperties == other.additionalProperties + } - /** - * The cadence to bill for this price on. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun cadence(): Cadence = cadence.getRequired("cadence") + private val hashCode: Int by lazy { + Objects.hash( + allocationPrice, + discounts, + endDate, + externalPriceId, + maximumAmount, + minimumAmount, + planPhaseOrder, + price, + priceId, + startDate, + additionalProperties, + ) + } - /** - * The id of the item the price will be associated with. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun itemId(): String = itemId.getRequired("item_id") + override fun hashCode(): Int = hashCode - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun minimumConfig(): MinimumConfig = minimumConfig.getRequired("minimum_config") + override fun toString() = + "AddPrice{allocationPrice=$allocationPrice, discounts=$discounts, endDate=$endDate, externalPriceId=$externalPriceId, maximumAmount=$maximumAmount, minimumAmount=$minimumAmount, planPhaseOrder=$planPhaseOrder, price=$price, priceId=$priceId, startDate=$startDate, additionalProperties=$additionalProperties}" + } - /** - * Expected to always return the following: - * ```kotlin - * JsonValue.from("minimum") - * ``` - * - * However, this method can be useful for debugging and logging (e.g. if the server - * responded with an unexpected value). - */ - @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + /** + * Reset billing periods to be aligned with the plan change's effective date or start of the + * month. Defaults to `unchanged` which keeps subscription's existing billing cycle alignment. + */ + class BillingCycleAlignment + @JsonCreator + private constructor(private val value: JsonField) : Enum { - /** - * The name of the price. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun name(): String = name.getRequired("name") + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun billableMetricId(): String? = billableMetricId.getNullable("billable_metric_id") + companion object { - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + val UNCHANGED = of("unchanged") - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun billingCycleConfiguration(): NewBillingCycleConfiguration? = - billingCycleConfiguration.getNullable("billing_cycle_configuration") + val PLAN_CHANGE_DATE = of("plan_change_date") - /** - * The per unit conversion rate of the price currency to the invoicing currency. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + val START_OF_MONTH = of("start_of_month") - /** - * The configuration for the rate of the price currency to the invoicing currency. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun conversionRateConfig(): ConversionRateConfig? = - conversionRateConfig.getNullable("conversion_rate_config") + fun of(value: String) = BillingCycleAlignment(JsonField.of(value)) + } - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun currency(): String? = currency.getNullable("currency") + /** An enum containing [BillingCycleAlignment]'s known values. */ + enum class Known { + UNCHANGED, + PLAN_CHANGE_DATE, + START_OF_MONTH, + } - /** - * For dimensional price: specifies a price group and dimension values - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = - dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + /** + * An enum containing [BillingCycleAlignment]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [BillingCycleAlignment] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + UNCHANGED, + PLAN_CHANGE_DATE, + START_OF_MONTH, + /** + * An enum member indicating that [BillingCycleAlignment] was instantiated with an + * unknown value. + */ + _UNKNOWN, + } - /** - * An alias for the price. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + UNCHANGED -> Value.UNCHANGED + PLAN_CHANGE_DATE -> Value.PLAN_CHANGE_DATE + START_OF_MONTH -> Value.START_OF_MONTH + else -> Value._UNKNOWN + } - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun fixedPriceQuantity(): Double? = - fixedPriceQuantity.getNullable("fixed_price_quantity") + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known member. + */ + fun known(): Known = + when (this) { + UNCHANGED -> Known.UNCHANGED + PLAN_CHANGE_DATE -> Known.PLAN_CHANGE_DATE + START_OF_MONTH -> Known.START_OF_MONTH + else -> throw OrbInvalidDataException("Unknown BillingCycleAlignment: $value") + } - /** - * The property used to group this price on an invoice - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun invoiceGroupingKey(): String? = - invoiceGroupingKey.getNullable("invoice_grouping_key") + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the expected + * primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + private var validated: Boolean = false - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun metadata(): Metadata? = metadata.getNullable("metadata") + fun validate(): BillingCycleAlignment = apply { + if (validated) { + return@apply + } - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun referenceId(): String? = referenceId.getNullable("reference_id") + known() + validated = true + } - /** - * Returns the raw JSON value of [cadence]. - * - * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("cadence") - @ExcludeMissing - fun _cadence(): JsonField = cadence + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - /** - * Returns the raw JSON value of [itemId]. - * - * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - /** - * Returns the raw JSON value of [minimumConfig]. - * - * Unlike [minimumConfig], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("minimum_config") - @ExcludeMissing - fun _minimumConfig(): JsonField = minimumConfig + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * Returns the raw JSON value of [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + return other is BillingCycleAlignment && value == other.value + } - /** - * Returns the raw JSON value of [billableMetricId]. - * - * Unlike [billableMetricId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = billableMetricId + override fun hashCode() = value.hashCode() - /** - * Returns the raw JSON value of [billedInAdvance]. - * - * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance + override fun toString() = value.toString() + } - /** - * Returns the raw JSON value of [billingCycleConfiguration]. - * - * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration + class RemoveAdjustment + private constructor( + private val adjustmentId: JsonField, + private val additionalProperties: MutableMap, + ) { - /** - * Returns the raw JSON value of [conversionRate]. - * - * Unlike [conversionRate], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate + @JsonCreator + private constructor( + @JsonProperty("adjustment_id") + @ExcludeMissing + adjustmentId: JsonField = JsonMissing.of() + ) : this(adjustmentId, mutableMapOf()) - /** - * Returns the raw JSON value of [conversionRateConfig]. - * - * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("conversion_rate_config") - @ExcludeMissing - fun _conversionRateConfig(): JsonField = conversionRateConfig + /** + * The id of the adjustment to remove on the subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun adjustmentId(): String = adjustmentId.getRequired("adjustment_id") - /** - * Returns the raw JSON value of [currency]. - * - * Unlike [currency], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("currency") - @ExcludeMissing - fun _currency(): JsonField = currency + /** + * Returns the raw JSON value of [adjustmentId]. + * + * Unlike [adjustmentId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("adjustment_id") + @ExcludeMissing + fun _adjustmentId(): JsonField = adjustmentId - /** - * Returns the raw JSON value of [dimensionalPriceConfiguration]. - * - * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON - * field has an unexpected type. - */ - @JsonProperty("dimensional_price_configuration") - @ExcludeMissing - fun _dimensionalPriceConfiguration(): JsonField = - dimensionalPriceConfiguration + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - /** - * Returns the raw JSON value of [externalPriceId]. - * - * Unlike [externalPriceId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - /** - * Returns the raw JSON value of [fixedPriceQuantity]. - * - * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + fun toBuilder() = Builder().from(this) - /** - * Returns the raw JSON value of [invoiceGroupingKey]. - * - * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + companion object { - /** - * Returns the raw JSON value of [invoicingCycleConfiguration]. - * - * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration + /** + * Returns a mutable builder for constructing an instance of [RemoveAdjustment]. + * + * The following fields are required: + * ```kotlin + * .adjustmentId() + * ``` + */ + fun builder() = Builder() + } - /** - * Returns the raw JSON value of [metadata]. - * - * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata + /** A builder for [RemoveAdjustment]. */ + class Builder internal constructor() { - /** - * Returns the raw JSON value of [referenceId]. - * - * Unlike [referenceId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("reference_id") - @ExcludeMissing - fun _referenceId(): JsonField = referenceId + private var adjustmentId: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + internal fun from(removeAdjustment: RemoveAdjustment) = apply { + adjustmentId = removeAdjustment.adjustmentId + additionalProperties = removeAdjustment.additionalProperties.toMutableMap() + } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** The id of the adjustment to remove on the subscription. */ + fun adjustmentId(adjustmentId: String) = adjustmentId(JsonField.of(adjustmentId)) - fun toBuilder() = Builder().from(this) + /** + * Sets [Builder.adjustmentId] to an arbitrary JSON value. + * + * You should usually call [Builder.adjustmentId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun adjustmentId(adjustmentId: JsonField) = apply { + this.adjustmentId = adjustmentId + } - companion object { + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** - * Returns a mutable builder for constructing an instance of [Minimum]. - * - * The following fields are required: - * ```kotlin - * .cadence() - * .itemId() - * .minimumConfig() - * .name() - * ``` - */ - fun builder() = Builder() - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** A builder for [Minimum]. */ - class Builder internal constructor() { + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - private var cadence: JsonField? = null - private var itemId: JsonField? = null - private var minimumConfig: JsonField? = null - private var modelType: JsonValue = JsonValue.from("minimum") - private var name: JsonField? = null - private var billableMetricId: JsonField = JsonMissing.of() - private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var conversionRateConfig: JsonField = - JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var dimensionalPriceConfiguration: - JsonField = - JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: - JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var referenceId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - internal fun from(minimum: Minimum) = apply { - cadence = minimum.cadence - itemId = minimum.itemId - minimumConfig = minimum.minimumConfig - modelType = minimum.modelType - name = minimum.name - billableMetricId = minimum.billableMetricId - billedInAdvance = minimum.billedInAdvance - billingCycleConfiguration = minimum.billingCycleConfiguration - conversionRate = minimum.conversionRate - conversionRateConfig = minimum.conversionRateConfig - currency = minimum.currency - dimensionalPriceConfiguration = minimum.dimensionalPriceConfiguration - externalPriceId = minimum.externalPriceId - fixedPriceQuantity = minimum.fixedPriceQuantity - invoiceGroupingKey = minimum.invoiceGroupingKey - invoicingCycleConfiguration = minimum.invoicingCycleConfiguration - metadata = minimum.metadata - referenceId = minimum.referenceId - additionalProperties = minimum.additionalProperties.toMutableMap() - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + /** + * Returns an immutable instance of [RemoveAdjustment]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .adjustmentId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): RemoveAdjustment = + RemoveAdjustment( + checkRequired("adjustmentId", adjustmentId), + additionalProperties.toMutableMap(), + ) + } - /** - * Sets [Builder.cadence] to an arbitrary JSON value. - * - * You should usually call [Builder.cadence] with a well-typed [Cadence] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + private var validated: Boolean = false - /** The id of the item the price will be associated with. */ - fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + fun validate(): RemoveAdjustment = apply { + if (validated) { + return@apply + } - /** - * Sets [Builder.itemId] to an arbitrary JSON value. - * - * You should usually call [Builder.itemId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + adjustmentId() + validated = true + } - fun minimumConfig(minimumConfig: MinimumConfig) = - minimumConfig(JsonField.of(minimumConfig)) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - /** - * Sets [Builder.minimumConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.minimumConfig] with a well-typed - * [MinimumConfig] value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. - */ - fun minimumConfig(minimumConfig: JsonField) = apply { - this.minimumConfig = minimumConfig - } + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = (if (adjustmentId.asKnown() == null) 0 else 1) - /** - * Sets the field to an arbitrary JSON value. - * - * It is usually unnecessary to call this method because the field defaults to - * the following: - * ```kotlin - * JsonValue.from("minimum") - * ``` - * - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) + return other is RemoveAdjustment && + adjustmentId == other.adjustmentId && + additionalProperties == other.additionalProperties + } - /** - * Sets [Builder.name] to an arbitrary JSON value. - * - * You should usually call [Builder.name] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun name(name: JsonField) = apply { this.name = name } + private val hashCode: Int by lazy { Objects.hash(adjustmentId, additionalProperties) } - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: String?) = - billableMetricId(JsonField.ofNullable(billableMetricId)) + override fun hashCode(): Int = hashCode - /** - * Sets [Builder.billableMetricId] to an arbitrary JSON value. - * - * You should usually call [Builder.billableMetricId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun billableMetricId(billableMetricId: JsonField) = apply { - this.billableMetricId = billableMetricId - } + override fun toString() = + "RemoveAdjustment{adjustmentId=$adjustmentId, additionalProperties=$additionalProperties}" + } - /** - * If the Price represents a fixed cost, the price will be billed in-advance if - * this is true, and in-arrears if this is false. - */ - fun billedInAdvance(billedInAdvance: Boolean?) = - billedInAdvance(JsonField.ofNullable(billedInAdvance)) + class RemovePrice + private constructor( + private val externalPriceId: JsonField, + private val priceId: JsonField, + private val additionalProperties: MutableMap, + ) { - /** - * Alias for [Builder.billedInAdvance]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun billedInAdvance(billedInAdvance: Boolean) = - billedInAdvance(billedInAdvance as Boolean?) + @JsonCreator + private constructor( + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("price_id") @ExcludeMissing priceId: JsonField = JsonMissing.of(), + ) : this(externalPriceId, priceId, mutableMapOf()) - /** - * Sets [Builder.billedInAdvance] to an arbitrary JSON value. - * - * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun billedInAdvance(billedInAdvance: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } + /** + * The external price id of the price to remove on the subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: NewBillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + /** + * The id of the price to remove on the subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun priceId(): String? = priceId.getNullable("price_id") - /** - * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.billingCycleConfiguration] with a well-typed - * [NewBillingCycleConfiguration] value instead. This method is primarily for - * setting the field to an undocumented or not yet supported value. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: JsonField - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: Double?) = - conversionRate(JsonField.ofNullable(conversionRate)) + /** + * Returns the raw JSON value of [priceId]. + * + * Unlike [priceId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId - /** - * Alias for [Builder.conversionRate]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - /** - * Sets [Builder.conversionRate] to an arbitrary JSON value. - * - * You should usually call [Builder.conversionRate] with a well-typed [Double] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - /** - * The configuration for the rate of the price currency to the invoicing - * currency. - */ - fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = - conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + fun toBuilder() = Builder().from(this) - /** - * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.conversionRateConfig] with a well-typed - * [ConversionRateConfig] value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun conversionRateConfig( - conversionRateConfig: JsonField - ) = apply { this.conversionRateConfig = conversionRateConfig } + companion object { - /** - * Alias for calling [conversionRateConfig] with - * `ConversionRateConfig.ofUnit(unit)`. - */ - fun conversionRateConfig(unit: UnitConversionRateConfig) = - conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + /** Returns a mutable builder for constructing an instance of [RemovePrice]. */ + fun builder() = Builder() + } - /** - * Alias for calling [conversionRateConfig] with the following: - * ```kotlin - * UnitConversionRateConfig.builder() - * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) - * .unitConfig(unitConfig) - * .build() - * ``` - */ - fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = - conversionRateConfig( - UnitConversionRateConfig.builder() - .conversionRateType( - UnitConversionRateConfig.ConversionRateType.UNIT - ) - .unitConfig(unitConfig) - .build() - ) + /** A builder for [RemovePrice]. */ + class Builder internal constructor() { - /** - * Alias for calling [conversionRateConfig] with - * `ConversionRateConfig.ofTiered(tiered)`. - */ - fun conversionRateConfig(tiered: TieredConversionRateConfig) = - conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + private var externalPriceId: JsonField = JsonMissing.of() + private var priceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - /** - * Alias for calling [conversionRateConfig] with the following: - * ```kotlin - * TieredConversionRateConfig.builder() - * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) - * .tieredConfig(tieredConfig) - * .build() - * ``` - */ - fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = - conversionRateConfig( - TieredConversionRateConfig.builder() - .conversionRateType( - TieredConversionRateConfig.ConversionRateType.TIERED - ) - .tieredConfig(tieredConfig) - .build() - ) + internal fun from(removePrice: RemovePrice) = apply { + externalPriceId = removePrice.externalPriceId + priceId = removePrice.priceId + additionalProperties = removePrice.additionalProperties.toMutableMap() + } - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + /** The external price id of the price to remove on the subscription. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) - /** - * Sets [Builder.currency] to an arbitrary JSON value. - * - * You should usually call [Builder.currency] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } - /** For dimensional price: specifies a price group and dimension values */ - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? - ) = - dimensionalPriceConfiguration( - JsonField.ofNullable(dimensionalPriceConfiguration) - ) + /** The id of the price to remove on the subscription. */ + fun priceId(priceId: String?) = priceId(JsonField.ofNullable(priceId)) - /** - * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.dimensionalPriceConfiguration] with a - * well-typed [NewDimensionalPriceConfiguration] value instead. This method is - * primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: JsonField - ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + /** + * Sets [Builder.priceId] to an arbitrary JSON value. + * + * You should usually call [Builder.priceId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun priceId(priceId: JsonField) = apply { this.priceId = priceId } - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** - * Sets [Builder.externalPriceId] to an arbitrary JSON value. - * - * You should usually call [Builder.externalPriceId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun externalPriceId(externalPriceId: JsonField) = apply { - this.externalPriceId = externalPriceId - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = - fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - /** - * Alias for [Builder.fixedPriceQuantity]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - /** - * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. - * - * You should usually call [Builder.fixedPriceQuantity] with a well-typed - * [Double] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = - invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + /** + * Returns an immutable instance of [RemovePrice]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): RemovePrice = + RemovePrice(externalPriceId, priceId, additionalProperties.toMutableMap()) + } - /** - * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. - * - * You should usually call [Builder.invoiceGroupingKey] with a well-typed - * [String] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { - this.invoiceGroupingKey = invoiceGroupingKey - } + private var validated: Boolean = false - /** - * Within each billing cycle, specifies the cadence at which invoices are - * produced. If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: NewBillingCycleConfiguration? - ) = - invoicingCycleConfiguration( - JsonField.ofNullable(invoicingCycleConfiguration) - ) + fun validate(): RemovePrice = apply { + if (validated) { + return@apply + } - /** - * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.invoicingCycleConfiguration] with a - * well-typed [NewBillingCycleConfiguration] value instead. This method is - * primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + externalPriceId() + priceId() + validated = true + } - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - /** - * Sets [Builder.metadata] to an arbitrary JSON value. - * - * You should usually call [Builder.metadata] with a well-typed [Metadata] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (priceId.asKnown() == null) 0 else 1) - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - fun referenceId(referenceId: String?) = - referenceId(JsonField.ofNullable(referenceId)) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * Sets [Builder.referenceId] to an arbitrary JSON value. - * - * You should usually call [Builder.referenceId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun referenceId(referenceId: JsonField) = apply { - this.referenceId = referenceId - } + return other is RemovePrice && + externalPriceId == other.externalPriceId && + priceId == other.priceId && + additionalProperties == other.additionalProperties + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + private val hashCode: Int by lazy { + Objects.hash(externalPriceId, priceId, additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + override fun hashCode(): Int = hashCode - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + override fun toString() = + "RemovePrice{externalPriceId=$externalPriceId, priceId=$priceId, additionalProperties=$additionalProperties}" + } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + class ReplaceAdjustment + private constructor( + private val adjustment: JsonField, + private val replacesAdjustmentId: JsonField, + private val additionalProperties: MutableMap, + ) { - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + @JsonCreator + private constructor( + @JsonProperty("adjustment") + @ExcludeMissing + adjustment: JsonField = JsonMissing.of(), + @JsonProperty("replaces_adjustment_id") + @ExcludeMissing + replacesAdjustmentId: JsonField = JsonMissing.of(), + ) : this(adjustment, replacesAdjustmentId, mutableMapOf()) - /** - * Returns an immutable instance of [Minimum]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```kotlin - * .cadence() - * .itemId() - * .minimumConfig() - * .name() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Minimum = - Minimum( - checkRequired("cadence", cadence), - checkRequired("itemId", itemId), - checkRequired("minimumConfig", minimumConfig), - modelType, - checkRequired("name", name), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - conversionRateConfig, - currency, - dimensionalPriceConfiguration, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - additionalProperties.toMutableMap(), - ) - } + /** + * The definition of a new adjustment to create and add to the subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun adjustment(): Adjustment = adjustment.getRequired("adjustment") - private var validated: Boolean = false + /** + * The id of the adjustment on the plan to replace in the subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun replacesAdjustmentId(): String = + replacesAdjustmentId.getRequired("replaces_adjustment_id") - fun validate(): Minimum = apply { - if (validated) { - return@apply - } - - cadence().validate() - itemId() - minimumConfig().validate() - _modelType().let { - if (it != JsonValue.from("minimum")) { - throw OrbInvalidDataException("'modelType' is invalid, received $it") - } - } - name() - billableMetricId() - billedInAdvance() - billingCycleConfiguration()?.validate() - conversionRate() - conversionRateConfig()?.validate() - currency() - dimensionalPriceConfiguration()?.validate() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration()?.validate() - metadata()?.validate() - referenceId() - validated = true - } + /** + * Returns the raw JSON value of [adjustment]. + * + * Unlike [adjustment], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("adjustment") + @ExcludeMissing + fun _adjustment(): JsonField = adjustment - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** + * Returns the raw JSON value of [replacesAdjustmentId]. + * + * Unlike [replacesAdjustmentId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("replaces_adjustment_id") + @ExcludeMissing + fun _replacesAdjustmentId(): JsonField = replacesAdjustmentId - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (cadence.asKnown()?.validity() ?: 0) + - (if (itemId.asKnown() == null) 0 else 1) + - (minimumConfig.asKnown()?.validity() ?: 0) + - modelType.let { if (it == JsonValue.from("minimum")) 1 else 0 } + - (if (name.asKnown() == null) 0 else 1) + - (if (billableMetricId.asKnown() == null) 0 else 1) + - (if (billedInAdvance.asKnown() == null) 0 else 1) + - (billingCycleConfiguration.asKnown()?.validity() ?: 0) + - (if (conversionRate.asKnown() == null) 0 else 1) + - (conversionRateConfig.asKnown()?.validity() ?: 0) + - (if (currency.asKnown() == null) 0 else 1) + - (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + - (if (externalPriceId.asKnown() == null) 0 else 1) + - (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + - (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + - (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + - (metadata.asKnown()?.validity() ?: 0) + - (if (referenceId.asKnown() == null) 0 else 1) + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - /** The cadence to bill for this price on. */ - class Cadence - @JsonCreator - private constructor(private val value: JsonField) : Enum { + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value + fun toBuilder() = Builder().from(this) - companion object { + companion object { - val ANNUAL = of("annual") + /** + * Returns a mutable builder for constructing an instance of [ReplaceAdjustment]. + * + * The following fields are required: + * ```kotlin + * .adjustment() + * .replacesAdjustmentId() + * ``` + */ + fun builder() = Builder() + } - val SEMI_ANNUAL = of("semi_annual") + /** A builder for [ReplaceAdjustment]. */ + class Builder internal constructor() { - val MONTHLY = of("monthly") + private var adjustment: JsonField? = null + private var replacesAdjustmentId: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() - val QUARTERLY = of("quarterly") + internal fun from(replaceAdjustment: ReplaceAdjustment) = apply { + adjustment = replaceAdjustment.adjustment + replacesAdjustmentId = replaceAdjustment.replacesAdjustmentId + additionalProperties = replaceAdjustment.additionalProperties.toMutableMap() + } - val ONE_TIME = of("one_time") + /** The definition of a new adjustment to create and add to the subscription. */ + fun adjustment(adjustment: Adjustment) = adjustment(JsonField.of(adjustment)) - val CUSTOM = of("custom") + /** + * Sets [Builder.adjustment] to an arbitrary JSON value. + * + * You should usually call [Builder.adjustment] with a well-typed [Adjustment] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun adjustment(adjustment: JsonField) = apply { + this.adjustment = adjustment + } - fun of(value: String) = Cadence(JsonField.of(value)) - } + /** + * Alias for calling [adjustment] with + * `Adjustment.ofPercentageDiscount(percentageDiscount)`. + */ + fun adjustment(percentageDiscount: NewPercentageDiscount) = + adjustment(Adjustment.ofPercentageDiscount(percentageDiscount)) - /** An enum containing [Cadence]'s known values. */ - enum class Known { - ANNUAL, - SEMI_ANNUAL, - MONTHLY, - QUARTERLY, - ONE_TIME, - CUSTOM, - } + /** + * Alias for calling [adjustment] with the following: + * ```kotlin + * NewPercentageDiscount.builder() + * .adjustmentType(NewPercentageDiscount.AdjustmentType.PERCENTAGE_DISCOUNT) + * .percentageDiscount(percentageDiscount) + * .build() + * ``` + */ + fun percentageDiscountAdjustment(percentageDiscount: Double) = + adjustment( + NewPercentageDiscount.builder() + .adjustmentType(NewPercentageDiscount.AdjustmentType.PERCENTAGE_DISCOUNT) + .percentageDiscount(percentageDiscount) + .build() + ) - /** - * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Cadence] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - ANNUAL, - SEMI_ANNUAL, - MONTHLY, - QUARTERLY, - ONE_TIME, - CUSTOM, - /** - * An enum member indicating that [Cadence] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } + /** Alias for calling [adjustment] with `Adjustment.ofUsageDiscount(usageDiscount)`. */ + fun adjustment(usageDiscount: NewUsageDiscount) = + adjustment(Adjustment.ofUsageDiscount(usageDiscount)) - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - ANNUAL -> Value.ANNUAL - SEMI_ANNUAL -> Value.SEMI_ANNUAL - MONTHLY -> Value.MONTHLY - QUARTERLY -> Value.QUARTERLY - ONE_TIME -> Value.ONE_TIME - CUSTOM -> Value.CUSTOM - else -> Value._UNKNOWN - } + /** + * Alias for calling [adjustment] with the following: + * ```kotlin + * NewUsageDiscount.builder() + * .adjustmentType(NewUsageDiscount.AdjustmentType.USAGE_DISCOUNT) + * .usageDiscount(usageDiscount) + * .build() + * ``` + */ + fun usageDiscountAdjustment(usageDiscount: Double) = + adjustment( + NewUsageDiscount.builder() + .adjustmentType(NewUsageDiscount.AdjustmentType.USAGE_DISCOUNT) + .usageDiscount(usageDiscount) + .build() + ) - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - ANNUAL -> Known.ANNUAL - SEMI_ANNUAL -> Known.SEMI_ANNUAL - MONTHLY -> Known.MONTHLY - QUARTERLY -> Known.QUARTERLY - ONE_TIME -> Known.ONE_TIME - CUSTOM -> Known.CUSTOM - else -> throw OrbInvalidDataException("Unknown Cadence: $value") - } + /** + * Alias for calling [adjustment] with `Adjustment.ofAmountDiscount(amountDiscount)`. + */ + fun adjustment(amountDiscount: NewAmountDiscount) = + adjustment(Adjustment.ofAmountDiscount(amountDiscount)) - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString() - ?: throw OrbInvalidDataException("Value is not a String") + /** + * Alias for calling [adjustment] with the following: + * ```kotlin + * NewAmountDiscount.builder() + * .adjustmentType(NewAmountDiscount.AdjustmentType.AMOUNT_DISCOUNT) + * .amountDiscount(amountDiscount) + * .build() + * ``` + */ + fun amountDiscountAdjustment(amountDiscount: String) = + adjustment( + NewAmountDiscount.builder() + .adjustmentType(NewAmountDiscount.AdjustmentType.AMOUNT_DISCOUNT) + .amountDiscount(amountDiscount) + .build() + ) - private var validated: Boolean = false + /** Alias for calling [adjustment] with `Adjustment.ofMinimum(minimum)`. */ + fun adjustment(minimum: NewMinimum) = adjustment(Adjustment.ofMinimum(minimum)) - fun validate(): Cadence = apply { - if (validated) { - return@apply - } + /** Alias for calling [adjustment] with `Adjustment.ofMaximum(maximum)`. */ + fun adjustment(maximum: NewMaximum) = adjustment(Adjustment.ofMaximum(maximum)) - known() - validated = true - } + /** + * Alias for calling [adjustment] with the following: + * ```kotlin + * NewMaximum.builder() + * .adjustmentType(NewMaximum.AdjustmentType.MAXIMUM) + * .maximumAmount(maximumAmount) + * .build() + * ``` + */ + fun maximumAdjustment(maximumAmount: String) = + adjustment( + NewMaximum.builder() + .adjustmentType(NewMaximum.AdjustmentType.MAXIMUM) + .maximumAmount(maximumAmount) + .build() + ) - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** The id of the adjustment on the plan to replace in the subscription. */ + fun replacesAdjustmentId(replacesAdjustmentId: String) = + replacesAdjustmentId(JsonField.of(replacesAdjustmentId)) - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + /** + * Sets [Builder.replacesAdjustmentId] to an arbitrary JSON value. + * + * You should usually call [Builder.replacesAdjustmentId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun replacesAdjustmentId(replacesAdjustmentId: JsonField) = apply { + this.replacesAdjustmentId = replacesAdjustmentId + } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - return other is Cadence && value == other.value - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - override fun hashCode() = value.hashCode() + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - override fun toString() = value.toString() - } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - class MinimumConfig - private constructor( - private val minimumAmount: JsonField, - private val prorated: JsonField, - private val additionalProperties: MutableMap, - ) { + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - @JsonCreator - private constructor( - @JsonProperty("minimum_amount") - @ExcludeMissing - minimumAmount: JsonField = JsonMissing.of(), - @JsonProperty("prorated") - @ExcludeMissing - prorated: JsonField = JsonMissing.of(), - ) : this(minimumAmount, prorated, mutableMapOf()) + /** + * Returns an immutable instance of [ReplaceAdjustment]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .adjustment() + * .replacesAdjustmentId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ReplaceAdjustment = + ReplaceAdjustment( + checkRequired("adjustment", adjustment), + checkRequired("replacesAdjustmentId", replacesAdjustmentId), + additionalProperties.toMutableMap(), + ) + } - /** - * The minimum amount to apply - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") + private var validated: Boolean = false - /** - * By default, subtotals from minimum composite prices are prorated based on the - * service period. Set to false to disable proration. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun prorated(): Boolean? = prorated.getNullable("prorated") + fun validate(): ReplaceAdjustment = apply { + if (validated) { + return@apply + } - /** - * Returns the raw JSON value of [minimumAmount]. - * - * Unlike [minimumAmount], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("minimum_amount") - @ExcludeMissing - fun _minimumAmount(): JsonField = minimumAmount + adjustment().validate() + replacesAdjustmentId() + validated = true + } - /** - * Returns the raw JSON value of [prorated]. - * - * Unlike [prorated], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("prorated") - @ExcludeMissing - fun _prorated(): JsonField = prorated + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (adjustment.asKnown()?.validity() ?: 0) + + (if (replacesAdjustmentId.asKnown() == null) 0 else 1) - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** The definition of a new adjustment to create and add to the subscription. */ + @JsonDeserialize(using = Adjustment.Deserializer::class) + @JsonSerialize(using = Adjustment.Serializer::class) + class Adjustment + private constructor( + private val percentageDiscount: NewPercentageDiscount? = null, + private val usageDiscount: NewUsageDiscount? = null, + private val amountDiscount: NewAmountDiscount? = null, + private val minimum: NewMinimum? = null, + private val maximum: NewMaximum? = null, + private val _json: JsonValue? = null, + ) { - fun toBuilder() = Builder().from(this) + fun percentageDiscount(): NewPercentageDiscount? = percentageDiscount - companion object { + fun usageDiscount(): NewUsageDiscount? = usageDiscount - /** - * Returns a mutable builder for constructing an instance of - * [MinimumConfig]. - * - * The following fields are required: - * ```kotlin - * .minimumAmount() - * ``` - */ - fun builder() = Builder() - } + fun amountDiscount(): NewAmountDiscount? = amountDiscount - /** A builder for [MinimumConfig]. */ - class Builder internal constructor() { + fun minimum(): NewMinimum? = minimum - private var minimumAmount: JsonField? = null - private var prorated: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() + fun maximum(): NewMaximum? = maximum - internal fun from(minimumConfig: MinimumConfig) = apply { - minimumAmount = minimumConfig.minimumAmount - prorated = minimumConfig.prorated - additionalProperties = minimumConfig.additionalProperties.toMutableMap() - } + fun isPercentageDiscount(): Boolean = percentageDiscount != null - /** The minimum amount to apply */ - fun minimumAmount(minimumAmount: String) = - minimumAmount(JsonField.of(minimumAmount)) + fun isUsageDiscount(): Boolean = usageDiscount != null - /** - * Sets [Builder.minimumAmount] to an arbitrary JSON value. - * - * You should usually call [Builder.minimumAmount] with a well-typed - * [String] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun minimumAmount(minimumAmount: JsonField) = apply { - this.minimumAmount = minimumAmount - } + fun isAmountDiscount(): Boolean = amountDiscount != null - /** - * By default, subtotals from minimum composite prices are prorated based on - * the service period. Set to false to disable proration. - */ - fun prorated(prorated: Boolean?) = prorated(JsonField.ofNullable(prorated)) + fun isMinimum(): Boolean = minimum != null - /** - * Alias for [Builder.prorated]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun prorated(prorated: Boolean) = prorated(prorated as Boolean?) + fun isMaximum(): Boolean = maximum != null - /** - * Sets [Builder.prorated] to an arbitrary JSON value. - * - * You should usually call [Builder.prorated] with a well-typed [Boolean] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun prorated(prorated: JsonField) = apply { - this.prorated = prorated - } + fun asPercentageDiscount(): NewPercentageDiscount = + percentageDiscount.getOrThrow("percentageDiscount") - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun asUsageDiscount(): NewUsageDiscount = usageDiscount.getOrThrow("usageDiscount") - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun asAmountDiscount(): NewAmountDiscount = amountDiscount.getOrThrow("amountDiscount") - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + fun asMinimum(): NewMinimum = minimum.getOrThrow("minimum") - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun asMaximum(): NewMaximum = maximum.getOrThrow("maximum") - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun _json(): JsonValue? = _json - /** - * Returns an immutable instance of [MinimumConfig]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```kotlin - * .minimumAmount() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): MinimumConfig = - MinimumConfig( - checkRequired("minimumAmount", minimumAmount), - prorated, - additionalProperties.toMutableMap(), - ) - } + fun accept(visitor: Visitor): T = + when { + percentageDiscount != null -> + visitor.visitPercentageDiscount(percentageDiscount) + usageDiscount != null -> visitor.visitUsageDiscount(usageDiscount) + amountDiscount != null -> visitor.visitAmountDiscount(amountDiscount) + minimum != null -> visitor.visitMinimum(minimum) + maximum != null -> visitor.visitMaximum(maximum) + else -> visitor.unknown(_json) + } - private var validated: Boolean = false - - fun validate(): MinimumConfig = apply { - if (validated) { - return@apply - } + private var validated: Boolean = false - minimumAmount() - prorated() - validated = true - } + fun validate(): Adjustment = apply { + if (validated) { + return@apply + } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false + accept( + object : Visitor { + override fun visitPercentageDiscount( + percentageDiscount: NewPercentageDiscount + ) { + percentageDiscount.validate() } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (if (minimumAmount.asKnown() == null) 0 else 1) + - (if (prorated.asKnown() == null) 0 else 1) + override fun visitUsageDiscount(usageDiscount: NewUsageDiscount) { + usageDiscount.validate() + } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + override fun visitAmountDiscount(amountDiscount: NewAmountDiscount) { + amountDiscount.validate() } - return other is MinimumConfig && - minimumAmount == other.minimumAmount && - prorated == other.prorated && - additionalProperties == other.additionalProperties - } + override fun visitMinimum(minimum: NewMinimum) { + minimum.validate() + } - private val hashCode: Int by lazy { - Objects.hash(minimumAmount, prorated, additionalProperties) + override fun visitMaximum(maximum: NewMaximum) { + maximum.validate() + } } + ) + validated = true + } - override fun hashCode(): Int = hashCode - - override fun toString() = - "MinimumConfig{minimumAmount=$minimumAmount, prorated=$prorated, additionalProperties=$additionalProperties}" + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false } - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - class Metadata - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitPercentageDiscount( + percentageDiscount: NewPercentageDiscount + ) = percentageDiscount.validity() - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + override fun visitUsageDiscount(usageDiscount: NewUsageDiscount) = + usageDiscount.validity() - fun toBuilder() = Builder().from(this) + override fun visitAmountDiscount(amountDiscount: NewAmountDiscount) = + amountDiscount.validity() - companion object { + override fun visitMinimum(minimum: NewMinimum) = minimum.validity() - /** Returns a mutable builder for constructing an instance of [Metadata]. */ - fun builder() = Builder() + override fun visitMaximum(maximum: NewMaximum) = maximum.validity() + + override fun unknown(json: JsonValue?) = 0 } + ) - /** A builder for [Metadata]. */ - class Builder internal constructor() { + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - private var additionalProperties: MutableMap = - mutableMapOf() + return other is Adjustment && + percentageDiscount == other.percentageDiscount && + usageDiscount == other.usageDiscount && + amountDiscount == other.amountDiscount && + minimum == other.minimum && + maximum == other.maximum + } - internal fun from(metadata: Metadata) = apply { - additionalProperties = metadata.additionalProperties.toMutableMap() - } + override fun hashCode(): Int = + Objects.hash(percentageDiscount, usageDiscount, amountDiscount, minimum, maximum) - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + override fun toString(): String = + when { + percentageDiscount != null -> + "Adjustment{percentageDiscount=$percentageDiscount}" + usageDiscount != null -> "Adjustment{usageDiscount=$usageDiscount}" + amountDiscount != null -> "Adjustment{amountDiscount=$amountDiscount}" + minimum != null -> "Adjustment{minimum=$minimum}" + maximum != null -> "Adjustment{maximum=$maximum}" + _json != null -> "Adjustment{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Adjustment") + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + companion object { - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + fun ofPercentageDiscount(percentageDiscount: NewPercentageDiscount) = + Adjustment(percentageDiscount = percentageDiscount) - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun ofUsageDiscount(usageDiscount: NewUsageDiscount) = + Adjustment(usageDiscount = usageDiscount) - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun ofAmountDiscount(amountDiscount: NewAmountDiscount) = + Adjustment(amountDiscount = amountDiscount) - /** - * Returns an immutable instance of [Metadata]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } + fun ofMinimum(minimum: NewMinimum) = Adjustment(minimum = minimum) - private var validated: Boolean = false + fun ofMaximum(maximum: NewMaximum) = Adjustment(maximum = maximum) + } - fun validate(): Metadata = apply { - if (validated) { - return@apply - } + /** + * An interface that defines how to map each variant of [Adjustment] to a value of type + * [T]. + */ + interface Visitor { - validated = true - } + fun visitPercentageDiscount(percentageDiscount: NewPercentageDiscount): T - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + fun visitUsageDiscount(usageDiscount: NewUsageDiscount): T - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - additionalProperties.count { (_, value) -> - !value.isNull() && !value.isMissing() - } + fun visitAmountDiscount(amountDiscount: NewAmountDiscount): T - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + fun visitMinimum(minimum: NewMinimum): T - return other is Metadata && - additionalProperties == other.additionalProperties - } + fun visitMaximum(maximum: NewMaximum): T - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /** + * Maps an unknown variant of [Adjustment] to a value of type [T]. + * + * An instance of [Adjustment] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the + * SDK is unaware of. + * + * @throws OrbInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw OrbInvalidDataException("Unknown Adjustment: $json") + } + } - override fun hashCode(): Int = hashCode + internal class Deserializer : BaseDeserializer(Adjustment::class) { - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } + override fun ObjectCodec.deserialize(node: JsonNode): Adjustment { + val json = JsonValue.fromJsonNode(node) + val adjustmentType = json.asObject()?.get("adjustment_type")?.asString() - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + when (adjustmentType) { + "percentage_discount" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Adjustment(percentageDiscount = it, _json = json) } + ?: Adjustment(_json = json) + } + "usage_discount" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(usageDiscount = it, _json = json) + } ?: Adjustment(_json = json) + } + "amount_discount" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(amountDiscount = it, _json = json) + } ?: Adjustment(_json = json) + } + "minimum" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(minimum = it, _json = json) + } ?: Adjustment(_json = json) + } + "maximum" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(maximum = it, _json = json) + } ?: Adjustment(_json = json) + } } - return other is Minimum && - cadence == other.cadence && - itemId == other.itemId && - minimumConfig == other.minimumConfig && - modelType == other.modelType && - name == other.name && - billableMetricId == other.billableMetricId && - billedInAdvance == other.billedInAdvance && - billingCycleConfiguration == other.billingCycleConfiguration && - conversionRate == other.conversionRate && - conversionRateConfig == other.conversionRateConfig && - currency == other.currency && - dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && - externalPriceId == other.externalPriceId && - fixedPriceQuantity == other.fixedPriceQuantity && - invoiceGroupingKey == other.invoiceGroupingKey && - invoicingCycleConfiguration == other.invoicingCycleConfiguration && - metadata == other.metadata && - referenceId == other.referenceId && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - cadence, - itemId, - minimumConfig, - modelType, - name, - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - conversionRateConfig, - currency, - dimensionalPriceConfiguration, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - additionalProperties, - ) + return Adjustment(_json = json) } + } - override fun hashCode(): Int = hashCode + internal class Serializer : BaseSerializer(Adjustment::class) { - override fun toString() = - "Minimum{cadence=$cadence, itemId=$itemId, minimumConfig=$minimumConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + override fun serialize( + value: Adjustment, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.percentageDiscount != null -> + generator.writeObject(value.percentageDiscount) + value.usageDiscount != null -> generator.writeObject(value.usageDiscount) + value.amountDiscount != null -> generator.writeObject(value.amountDiscount) + value.minimum != null -> generator.writeObject(value.minimum) + value.maximum != null -> generator.writeObject(value.maximum) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Adjustment") + } + } } } @@ -8699,212 +8213,237 @@ private constructor( return true } - return other is AddPrice && - allocationPrice == other.allocationPrice && - discounts == other.discounts && - endDate == other.endDate && - externalPriceId == other.externalPriceId && - maximumAmount == other.maximumAmount && - minimumAmount == other.minimumAmount && - planPhaseOrder == other.planPhaseOrder && - price == other.price && - priceId == other.priceId && - startDate == other.startDate && + return other is ReplaceAdjustment && + adjustment == other.adjustment && + replacesAdjustmentId == other.replacesAdjustmentId && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash( - allocationPrice, - discounts, - endDate, - externalPriceId, - maximumAmount, - minimumAmount, - planPhaseOrder, - price, - priceId, - startDate, - additionalProperties, - ) + Objects.hash(adjustment, replacesAdjustmentId, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "AddPrice{allocationPrice=$allocationPrice, discounts=$discounts, endDate=$endDate, externalPriceId=$externalPriceId, maximumAmount=$maximumAmount, minimumAmount=$minimumAmount, planPhaseOrder=$planPhaseOrder, price=$price, priceId=$priceId, startDate=$startDate, additionalProperties=$additionalProperties}" + "ReplaceAdjustment{adjustment=$adjustment, replacesAdjustmentId=$replacesAdjustmentId, additionalProperties=$additionalProperties}" } - /** - * Reset billing periods to be aligned with the plan change's effective date or start of the - * month. Defaults to `unchanged` which keeps subscription's existing billing cycle alignment. - */ - class BillingCycleAlignment - @JsonCreator - private constructor(private val value: JsonField) : Enum { + class ReplacePrice + private constructor( + private val replacesPriceId: JsonField, + private val allocationPrice: JsonField, + private val discounts: JsonField>, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val maximumAmount: JsonField, + private val minimumAmount: JsonField, + private val price: JsonField, + private val priceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("replaces_price_id") + @ExcludeMissing + replacesPriceId: JsonField = JsonMissing.of(), + @JsonProperty("allocation_price") + @ExcludeMissing + allocationPrice: JsonField = JsonMissing.of(), + @JsonProperty("discounts") + @ExcludeMissing + discounts: JsonField> = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("maximum_amount") + @ExcludeMissing + maximumAmount: JsonField = JsonMissing.of(), + @JsonProperty("minimum_amount") + @ExcludeMissing + minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("price") @ExcludeMissing price: JsonField = JsonMissing.of(), + @JsonProperty("price_id") @ExcludeMissing priceId: JsonField = JsonMissing.of(), + ) : this( + replacesPriceId, + allocationPrice, + discounts, + externalPriceId, + fixedPriceQuantity, + maximumAmount, + minimumAmount, + price, + priceId, + mutableMapOf(), + ) /** - * Returns this class instance's raw value. + * The id of the price on the plan to replace in the subscription. * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API may respond with new members that the SDK is - * unaware of. + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - val UNCHANGED = of("unchanged") - - val PLAN_CHANGE_DATE = of("plan_change_date") - - val START_OF_MONTH = of("start_of_month") - - fun of(value: String) = BillingCycleAlignment(JsonField.of(value)) - } - - /** An enum containing [BillingCycleAlignment]'s known values. */ - enum class Known { - UNCHANGED, - PLAN_CHANGE_DATE, - START_OF_MONTH, - } + fun replacesPriceId(): String = replacesPriceId.getRequired("replaces_price_id") /** - * An enum containing [BillingCycleAlignment]'s known values, as well as an [_UNKNOWN] - * member. + * The definition of a new allocation price to create and add to the subscription. * - * An instance of [BillingCycleAlignment] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if the - * SDK is on an older version than the API, then the API may respond with new members that - * the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ - enum class Value { - UNCHANGED, - PLAN_CHANGE_DATE, - START_OF_MONTH, - /** - * An enum member indicating that [BillingCycleAlignment] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } + fun allocationPrice(): NewAllocationPrice? = allocationPrice.getNullable("allocation_price") /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. + * [DEPRECATED] Use add_adjustments instead. The subscription's discounts for the + * replacement price. * - * Use the [known] method instead if you're certain the value is always known or if you want - * to throw for the unknown case. + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ - fun value(): Value = - when (this) { - UNCHANGED -> Value.UNCHANGED - PLAN_CHANGE_DATE -> Value.PLAN_CHANGE_DATE - START_OF_MONTH -> Value.START_OF_MONTH - else -> Value._UNKNOWN - } + @Deprecated("deprecated") + fun discounts(): List? = discounts.getNullable("discounts") /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and don't - * want to throw for the unknown case. + * The external price id of the price to add to the subscription. * - * @throws OrbInvalidDataException if this class instance's value is a not a known member. + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ - fun known(): Known = - when (this) { - UNCHANGED -> Known.UNCHANGED - PLAN_CHANGE_DATE -> Known.PLAN_CHANGE_DATE - START_OF_MONTH -> Known.START_OF_MONTH - else -> throw OrbInvalidDataException("Unknown BillingCycleAlignment: $value") - } + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. + * The new quantity of the price, if the price is a fixed price. * - * @throws OrbInvalidDataException if this class instance's value does not have the expected - * primitive type. + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ - fun asString(): String = - _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + fun fixedPriceQuantity(): Double? = fixedPriceQuantity.getNullable("fixed_price_quantity") - private var validated: Boolean = false + /** + * [DEPRECATED] Use add_adjustments instead. The subscription's maximum amount for the + * replacement price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + @Deprecated("deprecated") + fun maximumAmount(): String? = maximumAmount.getNullable("maximum_amount") - fun validate(): BillingCycleAlignment = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** + * [DEPRECATED] Use add_adjustments instead. The subscription's minimum amount for the + * replacement price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + @Deprecated("deprecated") + fun minimumAmount(): String? = minimumAmount.getNullable("minimum_amount") /** - * Returns a score indicating how many valid values are contained in this object - * recursively. + * The definition of a new price to create and add to the subscription. * - * Used for best match union deserialization. + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + fun price(): Price? = price.getNullable("price") - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * The id of the price to add to the subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun priceId(): String? = priceId.getNullable("price_id") - return other is BillingCycleAlignment && value == other.value - } + /** + * Returns the raw JSON value of [replacesPriceId]. + * + * Unlike [replacesPriceId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("replaces_price_id") + @ExcludeMissing + fun _replacesPriceId(): JsonField = replacesPriceId - override fun hashCode() = value.hashCode() + /** + * Returns the raw JSON value of [allocationPrice]. + * + * Unlike [allocationPrice], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("allocation_price") + @ExcludeMissing + fun _allocationPrice(): JsonField = allocationPrice - override fun toString() = value.toString() - } + /** + * Returns the raw JSON value of [discounts]. + * + * Unlike [discounts], this method doesn't throw if the JSON field has an unexpected type. + */ + @Deprecated("deprecated") + @JsonProperty("discounts") + @ExcludeMissing + fun _discounts(): JsonField> = discounts - class RemoveAdjustment - private constructor( - private val adjustmentId: JsonField, - private val additionalProperties: MutableMap, - ) { + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId - @JsonCreator - private constructor( - @JsonProperty("adjustment_id") - @ExcludeMissing - adjustmentId: JsonField = JsonMissing.of() - ) : this(adjustmentId, mutableMapOf()) + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity /** - * The id of the adjustment to remove on the subscription. + * Returns the raw JSON value of [maximumAmount]. * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + * Unlike [maximumAmount], this method doesn't throw if the JSON field has an unexpected + * type. */ - fun adjustmentId(): String = adjustmentId.getRequired("adjustment_id") + @Deprecated("deprecated") + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount /** - * Returns the raw JSON value of [adjustmentId]. + * Returns the raw JSON value of [minimumAmount]. * - * Unlike [adjustmentId], this method doesn't throw if the JSON field has an unexpected + * Unlike [minimumAmount], this method doesn't throw if the JSON field has an unexpected * type. */ - @JsonProperty("adjustment_id") + @Deprecated("deprecated") + @JsonProperty("minimum_amount") @ExcludeMissing - fun _adjustmentId(): JsonField = adjustmentId + fun _minimumAmount(): JsonField = minimumAmount + + /** + * Returns the raw JSON value of [price]. + * + * Unlike [price], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("price") @ExcludeMissing fun _price(): JsonField = price + + /** + * Returns the raw JSON value of [priceId]. + * + * Unlike [priceId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -8921,206 +8460,109 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [RemoveAdjustment]. + * Returns a mutable builder for constructing an instance of [ReplacePrice]. * * The following fields are required: * ```kotlin - * .adjustmentId() + * .replacesPriceId() * ``` */ fun builder() = Builder() } - /** A builder for [RemoveAdjustment]. */ + /** A builder for [ReplacePrice]. */ class Builder internal constructor() { - private var adjustmentId: JsonField? = null + private var replacesPriceId: JsonField? = null + private var allocationPrice: JsonField = JsonMissing.of() + private var discounts: JsonField>? = null + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var maximumAmount: JsonField = JsonMissing.of() + private var minimumAmount: JsonField = JsonMissing.of() + private var price: JsonField = JsonMissing.of() + private var priceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(removeAdjustment: RemoveAdjustment) = apply { - adjustmentId = removeAdjustment.adjustmentId - additionalProperties = removeAdjustment.additionalProperties.toMutableMap() + internal fun from(replacePrice: ReplacePrice) = apply { + replacesPriceId = replacePrice.replacesPriceId + allocationPrice = replacePrice.allocationPrice + discounts = replacePrice.discounts.map { it.toMutableList() } + externalPriceId = replacePrice.externalPriceId + fixedPriceQuantity = replacePrice.fixedPriceQuantity + maximumAmount = replacePrice.maximumAmount + minimumAmount = replacePrice.minimumAmount + price = replacePrice.price + priceId = replacePrice.priceId + additionalProperties = replacePrice.additionalProperties.toMutableMap() } - /** The id of the adjustment to remove on the subscription. */ - fun adjustmentId(adjustmentId: String) = adjustmentId(JsonField.of(adjustmentId)) + /** The id of the price on the plan to replace in the subscription. */ + fun replacesPriceId(replacesPriceId: String) = + replacesPriceId(JsonField.of(replacesPriceId)) /** - * Sets [Builder.adjustmentId] to an arbitrary JSON value. + * Sets [Builder.replacesPriceId] to an arbitrary JSON value. * - * You should usually call [Builder.adjustmentId] with a well-typed [String] value + * You should usually call [Builder.replacesPriceId] with a well-typed [String] value * instead. This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun adjustmentId(adjustmentId: JsonField) = apply { - this.adjustmentId = adjustmentId - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) + fun replacesPriceId(replacesPriceId: JsonField) = apply { + this.replacesPriceId = replacesPriceId } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** The definition of a new allocation price to create and add to the subscription. */ + fun allocationPrice(allocationPrice: NewAllocationPrice?) = + allocationPrice(JsonField.ofNullable(allocationPrice)) - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) + /** + * Sets [Builder.allocationPrice] to an arbitrary JSON value. + * + * You should usually call [Builder.allocationPrice] with a well-typed + * [NewAllocationPrice] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun allocationPrice(allocationPrice: JsonField) = apply { + this.allocationPrice = allocationPrice } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + /** + * [DEPRECATED] Use add_adjustments instead. The subscription's discounts for the + * replacement price. + */ + @Deprecated("deprecated") + fun discounts(discounts: List?) = + discounts(JsonField.ofNullable(discounts)) - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) + /** + * Sets [Builder.discounts] to an arbitrary JSON value. + * + * You should usually call [Builder.discounts] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + @Deprecated("deprecated") + fun discounts(discounts: JsonField>) = apply { + this.discounts = discounts.map { it.toMutableList() } } /** - * Returns an immutable instance of [RemoveAdjustment]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```kotlin - * .adjustmentId() - * ``` + * Adds a single [DiscountOverride] to [discounts]. * - * @throws IllegalStateException if any required field is unset. + * @throws IllegalStateException if the field was previously set to a non-list. */ - fun build(): RemoveAdjustment = - RemoveAdjustment( - checkRequired("adjustmentId", adjustmentId), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): RemoveAdjustment = apply { - if (validated) { - return@apply + @Deprecated("deprecated") + fun addDiscount(discount: DiscountOverride) = apply { + discounts = + (discounts ?: JsonField.of(mutableListOf())).also { + checkKnown("discounts", it).add(discount) + } } - adjustmentId() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = (if (adjustmentId.asKnown() == null) 0 else 1) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is RemoveAdjustment && - adjustmentId == other.adjustmentId && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(adjustmentId, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "RemoveAdjustment{adjustmentId=$adjustmentId, additionalProperties=$additionalProperties}" - } - - class RemovePrice - private constructor( - private val externalPriceId: JsonField, - private val priceId: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("external_price_id") - @ExcludeMissing - externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("price_id") @ExcludeMissing priceId: JsonField = JsonMissing.of(), - ) : this(externalPriceId, priceId, mutableMapOf()) - - /** - * The external price id of the price to remove on the subscription. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") - - /** - * The id of the price to remove on the subscription. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun priceId(): String? = priceId.getNullable("price_id") - - /** - * Returns the raw JSON value of [externalPriceId]. - * - * Unlike [externalPriceId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * Returns the raw JSON value of [priceId]. - * - * Unlike [priceId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [RemovePrice]. */ - fun builder() = Builder() - } - - /** A builder for [RemovePrice]. */ - class Builder internal constructor() { - - private var externalPriceId: JsonField = JsonMissing.of() - private var priceId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(removePrice: RemovePrice) = apply { - externalPriceId = removePrice.externalPriceId - priceId = removePrice.priceId - additionalProperties = removePrice.additionalProperties.toMutableMap() - } - - /** The external price id of the price to remove on the subscription. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) + /** The external price id of the price to add to the subscription. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) /** * Sets [Builder.externalPriceId] to an arbitrary JSON value. @@ -9133,308 +8575,235 @@ private constructor( this.externalPriceId = externalPriceId } - /** The id of the price to remove on the subscription. */ - fun priceId(priceId: String?) = priceId(JsonField.ofNullable(priceId)) + /** The new quantity of the price, if the price is a fixed price. */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) /** - * Sets [Builder.priceId] to an arbitrary JSON value. + * Alias for [Builder.fixedPriceQuantity]. * - * You should usually call [Builder.priceId] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. + * This unboxed primitive overload exists for backwards compatibility. */ - fun priceId(priceId: JsonField) = apply { this.priceId = priceId } + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * [DEPRECATED] Use add_adjustments instead. The subscription's maximum amount for the + * replacement price. + */ + @Deprecated("deprecated") + fun maximumAmount(maximumAmount: String?) = + maximumAmount(JsonField.ofNullable(maximumAmount)) - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) + /** + * Sets [Builder.maximumAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.maximumAmount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + @Deprecated("deprecated") + fun maximumAmount(maximumAmount: JsonField) = apply { + this.maximumAmount = maximumAmount } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + /** + * [DEPRECATED] Use add_adjustments instead. The subscription's minimum amount for the + * replacement price. + */ + @Deprecated("deprecated") + fun minimumAmount(minimumAmount: String?) = + minimumAmount(JsonField.ofNullable(minimumAmount)) - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) + /** + * Sets [Builder.minimumAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumAmount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + @Deprecated("deprecated") + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount } + /** The definition of a new price to create and add to the subscription. */ + fun price(price: Price?) = price(JsonField.ofNullable(price)) + /** - * Returns an immutable instance of [RemovePrice]. + * Sets [Builder.price] to an arbitrary JSON value. * - * Further updates to this [Builder] will not mutate the returned instance. + * You should usually call [Builder.price] with a well-typed [Price] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. */ - fun build(): RemovePrice = - RemovePrice(externalPriceId, priceId, additionalProperties.toMutableMap()) - } + fun price(price: JsonField) = apply { this.price = price } - private var validated: Boolean = false + /** Alias for calling [price] with `Price.ofUnit(unit)`. */ + fun price(unit: NewSubscriptionUnitPrice) = price(Price.ofUnit(unit)) - fun validate(): RemovePrice = apply { - if (validated) { - return@apply - } + /** Alias for calling [price] with `Price.ofPackage(package_)`. */ + fun price(package_: NewSubscriptionPackagePrice) = price(Price.ofPackage(package_)) - externalPriceId() - priceId() - validated = true - } + /** Alias for calling [price] with `Price.ofMatrix(matrix)`. */ + fun price(matrix: NewSubscriptionMatrixPrice) = price(Price.ofMatrix(matrix)) - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** Alias for calling [price] with `Price.ofTiered(tiered)`. */ + fun price(tiered: NewSubscriptionTieredPrice) = price(Price.ofTiered(tiered)) - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (if (externalPriceId.asKnown() == null) 0 else 1) + - (if (priceId.asKnown() == null) 0 else 1) + /** Alias for calling [price] with `Price.ofBulk(bulk)`. */ + fun price(bulk: NewSubscriptionBulkPrice) = price(Price.ofBulk(bulk)) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * Alias for calling [price] with `Price.ofThresholdTotalAmount(thresholdTotalAmount)`. + */ + fun price(thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice) = + price(Price.ofThresholdTotalAmount(thresholdTotalAmount)) - return other is RemovePrice && - externalPriceId == other.externalPriceId && - priceId == other.priceId && - additionalProperties == other.additionalProperties - } + /** Alias for calling [price] with `Price.ofTieredPackage(tieredPackage)`. */ + fun price(tieredPackage: NewSubscriptionTieredPackagePrice) = + price(Price.ofTieredPackage(tieredPackage)) - private val hashCode: Int by lazy { - Objects.hash(externalPriceId, priceId, additionalProperties) - } + /** Alias for calling [price] with `Price.ofTieredWithMinimum(tieredWithMinimum)`. */ + fun price(tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice) = + price(Price.ofTieredWithMinimum(tieredWithMinimum)) - override fun hashCode(): Int = hashCode - - override fun toString() = - "RemovePrice{externalPriceId=$externalPriceId, priceId=$priceId, additionalProperties=$additionalProperties}" - } - - class ReplaceAdjustment - private constructor( - private val adjustment: JsonField, - private val replacesAdjustmentId: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("adjustment") - @ExcludeMissing - adjustment: JsonField = JsonMissing.of(), - @JsonProperty("replaces_adjustment_id") - @ExcludeMissing - replacesAdjustmentId: JsonField = JsonMissing.of(), - ) : this(adjustment, replacesAdjustmentId, mutableMapOf()) - - /** - * The definition of a new adjustment to create and add to the subscription. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun adjustment(): Adjustment = adjustment.getRequired("adjustment") - - /** - * The id of the adjustment on the plan to replace in the subscription. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun replacesAdjustmentId(): String = - replacesAdjustmentId.getRequired("replaces_adjustment_id") - - /** - * Returns the raw JSON value of [adjustment]. - * - * Unlike [adjustment], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("adjustment") - @ExcludeMissing - fun _adjustment(): JsonField = adjustment - - /** - * Returns the raw JSON value of [replacesAdjustmentId]. - * - * Unlike [replacesAdjustmentId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("replaces_adjustment_id") - @ExcludeMissing - fun _replacesAdjustmentId(): JsonField = replacesAdjustmentId + /** Alias for calling [price] with `Price.ofUnitWithPercent(unitWithPercent)`. */ + fun price(unitWithPercent: NewSubscriptionUnitWithPercentPrice) = + price(Price.ofUnitWithPercent(unitWithPercent)) - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** + * Alias for calling [price] with + * `Price.ofPackageWithAllocation(packageWithAllocation)`. + */ + fun price(packageWithAllocation: NewSubscriptionPackageWithAllocationPrice) = + price(Price.ofPackageWithAllocation(packageWithAllocation)) - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** + * Alias for calling [price] with `Price.ofTieredWithProration(tieredWithProration)`. + */ + fun price(tieredWithProration: NewSubscriptionTierWithProrationPrice) = + price(Price.ofTieredWithProration(tieredWithProration)) - fun toBuilder() = Builder().from(this) + /** Alias for calling [price] with `Price.ofUnitWithProration(unitWithProration)`. */ + fun price(unitWithProration: NewSubscriptionUnitWithProrationPrice) = + price(Price.ofUnitWithProration(unitWithProration)) - companion object { + /** Alias for calling [price] with `Price.ofGroupedAllocation(groupedAllocation)`. */ + fun price(groupedAllocation: NewSubscriptionGroupedAllocationPrice) = + price(Price.ofGroupedAllocation(groupedAllocation)) /** - * Returns a mutable builder for constructing an instance of [ReplaceAdjustment]. - * - * The following fields are required: - * ```kotlin - * .adjustment() - * .replacesAdjustmentId() - * ``` + * Alias for calling [price] with + * `Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)`. */ - fun builder() = Builder() - } - - /** A builder for [ReplaceAdjustment]. */ - class Builder internal constructor() { - - private var adjustment: JsonField? = null - private var replacesAdjustmentId: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() + fun price(groupedWithProratedMinimum: NewSubscriptionGroupedWithProratedMinimumPrice) = + price(Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)) - internal fun from(replaceAdjustment: ReplaceAdjustment) = apply { - adjustment = replaceAdjustment.adjustment - replacesAdjustmentId = replaceAdjustment.replacesAdjustmentId - additionalProperties = replaceAdjustment.additionalProperties.toMutableMap() - } + /** Alias for calling [price] with `Price.ofBulkWithProration(bulkWithProration)`. */ + fun price(bulkWithProration: NewSubscriptionBulkWithProrationPrice) = + price(Price.ofBulkWithProration(bulkWithProration)) - /** The definition of a new adjustment to create and add to the subscription. */ - fun adjustment(adjustment: Adjustment) = adjustment(JsonField.of(adjustment)) + /** + * Alias for calling [price] with + * `Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)`. + */ + fun price( + scalableMatrixWithUnitPricing: NewSubscriptionScalableMatrixWithUnitPricingPrice + ) = price(Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)) /** - * Sets [Builder.adjustment] to an arbitrary JSON value. - * - * You should usually call [Builder.adjustment] with a well-typed [Adjustment] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. + * Alias for calling [price] with + * `Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)`. */ - fun adjustment(adjustment: JsonField) = apply { - this.adjustment = adjustment - } + fun price( + scalableMatrixWithTieredPricing: NewSubscriptionScalableMatrixWithTieredPricingPrice + ) = price(Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)) /** - * Alias for calling [adjustment] with - * `Adjustment.ofPercentageDiscount(percentageDiscount)`. + * Alias for calling [price] with + * `Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)`. */ - fun adjustment(percentageDiscount: NewPercentageDiscount) = - adjustment(Adjustment.ofPercentageDiscount(percentageDiscount)) + fun price(cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice) = + price(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) /** - * Alias for calling [adjustment] with the following: - * ```kotlin - * NewPercentageDiscount.builder() - * .adjustmentType(NewPercentageDiscount.AdjustmentType.PERCENTAGE_DISCOUNT) - * .percentageDiscount(percentageDiscount) - * .build() - * ``` + * Alias for calling [price] with + * `Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)`. */ - fun percentageDiscountAdjustment(percentageDiscount: Double) = - adjustment( - NewPercentageDiscount.builder() - .adjustmentType(NewPercentageDiscount.AdjustmentType.PERCENTAGE_DISCOUNT) - .percentageDiscount(percentageDiscount) - .build() - ) + fun price(maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice) = + price(Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)) - /** Alias for calling [adjustment] with `Adjustment.ofUsageDiscount(usageDiscount)`. */ - fun adjustment(usageDiscount: NewUsageDiscount) = - adjustment(Adjustment.ofUsageDiscount(usageDiscount)) + /** + * Alias for calling [price] with + * `Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)`. + */ + fun price(groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice) = + price(Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)) /** - * Alias for calling [adjustment] with the following: - * ```kotlin - * NewUsageDiscount.builder() - * .adjustmentType(NewUsageDiscount.AdjustmentType.USAGE_DISCOUNT) - * .usageDiscount(usageDiscount) - * .build() - * ``` + * Alias for calling [price] with + * `Price.ofMatrixWithDisplayName(matrixWithDisplayName)`. */ - fun usageDiscountAdjustment(usageDiscount: Double) = - adjustment( - NewUsageDiscount.builder() - .adjustmentType(NewUsageDiscount.AdjustmentType.USAGE_DISCOUNT) - .usageDiscount(usageDiscount) - .build() - ) + fun price(matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice) = + price(Price.ofMatrixWithDisplayName(matrixWithDisplayName)) /** - * Alias for calling [adjustment] with `Adjustment.ofAmountDiscount(amountDiscount)`. + * Alias for calling [price] with `Price.ofGroupedTieredPackage(groupedTieredPackage)`. */ - fun adjustment(amountDiscount: NewAmountDiscount) = - adjustment(Adjustment.ofAmountDiscount(amountDiscount)) + fun price(groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice) = + price(Price.ofGroupedTieredPackage(groupedTieredPackage)) /** - * Alias for calling [adjustment] with the following: - * ```kotlin - * NewAmountDiscount.builder() - * .adjustmentType(NewAmountDiscount.AdjustmentType.AMOUNT_DISCOUNT) - * .amountDiscount(amountDiscount) - * .build() - * ``` + * Alias for calling [price] with `Price.ofMatrixWithAllocation(matrixWithAllocation)`. */ - fun amountDiscountAdjustment(amountDiscount: String) = - adjustment( - NewAmountDiscount.builder() - .adjustmentType(NewAmountDiscount.AdjustmentType.AMOUNT_DISCOUNT) - .amountDiscount(amountDiscount) - .build() - ) + fun price(matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice) = + price(Price.ofMatrixWithAllocation(matrixWithAllocation)) - /** Alias for calling [adjustment] with `Adjustment.ofMinimum(minimum)`. */ - fun adjustment(minimum: NewMinimum) = adjustment(Adjustment.ofMinimum(minimum)) + /** + * Alias for calling [price] with + * `Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)`. + */ + fun price(tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice) = + price(Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)) - /** Alias for calling [adjustment] with `Adjustment.ofMaximum(maximum)`. */ - fun adjustment(maximum: NewMaximum) = adjustment(Adjustment.ofMaximum(maximum)) + /** Alias for calling [price] with `Price.ofGroupedTiered(groupedTiered)`. */ + fun price(groupedTiered: NewSubscriptionGroupedTieredPrice) = + price(Price.ofGroupedTiered(groupedTiered)) /** - * Alias for calling [adjustment] with the following: - * ```kotlin - * NewMaximum.builder() - * .adjustmentType(NewMaximum.AdjustmentType.MAXIMUM) - * .maximumAmount(maximumAmount) - * .build() - * ``` + * Alias for calling [price] with + * `Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)`. */ - fun maximumAdjustment(maximumAmount: String) = - adjustment( - NewMaximum.builder() - .adjustmentType(NewMaximum.AdjustmentType.MAXIMUM) - .maximumAmount(maximumAmount) - .build() - ) + fun price(groupedWithMinMaxThresholds: Price.GroupedWithMinMaxThresholds) = + price(Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)) - /** The id of the adjustment on the plan to replace in the subscription. */ - fun replacesAdjustmentId(replacesAdjustmentId: String) = - replacesAdjustmentId(JsonField.of(replacesAdjustmentId)) + /** Alias for calling [price] with `Price.ofMinimum(minimum)`. */ + fun price(minimum: NewSubscriptionMinimumCompositePrice) = + price(Price.ofMinimum(minimum)) + + /** The id of the price to add to the subscription. */ + fun priceId(priceId: String?) = priceId(JsonField.ofNullable(priceId)) /** - * Sets [Builder.replacesAdjustmentId] to an arbitrary JSON value. + * Sets [Builder.priceId] to an arbitrary JSON value. * - * You should usually call [Builder.replacesAdjustmentId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. + * You should usually call [Builder.priceId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun replacesAdjustmentId(replacesAdjustmentId: JsonField) = apply { - this.replacesAdjustmentId = replacesAdjustmentId - } + fun priceId(priceId: JsonField) = apply { this.priceId = priceId } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -9456,35 +8825,48 @@ private constructor( } /** - * Returns an immutable instance of [ReplaceAdjustment]. + * Returns an immutable instance of [ReplacePrice]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```kotlin - * .adjustment() - * .replacesAdjustmentId() + * .replacesPriceId() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): ReplaceAdjustment = - ReplaceAdjustment( - checkRequired("adjustment", adjustment), - checkRequired("replacesAdjustmentId", replacesAdjustmentId), + fun build(): ReplacePrice = + ReplacePrice( + checkRequired("replacesPriceId", replacesPriceId), + allocationPrice, + (discounts ?: JsonMissing.of()).map { it.toImmutable() }, + externalPriceId, + fixedPriceQuantity, + maximumAmount, + minimumAmount, + price, + priceId, additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): ReplaceAdjustment = apply { + fun validate(): ReplacePrice = apply { if (validated) { return@apply } - adjustment().validate() - replacesAdjustmentId() + replacesPriceId() + allocationPrice()?.validate() + discounts()?.forEach { it.validate() } + externalPriceId() + fixedPriceQuantity() + maximumAmount() + minimumAmount() + price()?.validate() + priceId() validated = true } @@ -9503,3619 +8885,1203 @@ private constructor( * Used for best match union deserialization. */ internal fun validity(): Int = - (adjustment.asKnown()?.validity() ?: 0) + - (if (replacesAdjustmentId.asKnown() == null) 0 else 1) + (if (replacesPriceId.asKnown() == null) 0 else 1) + + (allocationPrice.asKnown()?.validity() ?: 0) + + (discounts.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (maximumAmount.asKnown() == null) 0 else 1) + + (if (minimumAmount.asKnown() == null) 0 else 1) + + (price.asKnown()?.validity() ?: 0) + + (if (priceId.asKnown() == null) 0 else 1) - /** The definition of a new adjustment to create and add to the subscription. */ - @JsonDeserialize(using = Adjustment.Deserializer::class) - @JsonSerialize(using = Adjustment.Serializer::class) - class Adjustment + /** The definition of a new price to create and add to the subscription. */ + @JsonDeserialize(using = Price.Deserializer::class) + @JsonSerialize(using = Price.Serializer::class) + class Price private constructor( - private val percentageDiscount: NewPercentageDiscount? = null, - private val usageDiscount: NewUsageDiscount? = null, - private val amountDiscount: NewAmountDiscount? = null, - private val minimum: NewMinimum? = null, - private val maximum: NewMaximum? = null, + private val unit: NewSubscriptionUnitPrice? = null, + private val package_: NewSubscriptionPackagePrice? = null, + private val matrix: NewSubscriptionMatrixPrice? = null, + private val tiered: NewSubscriptionTieredPrice? = null, + private val bulk: NewSubscriptionBulkPrice? = null, + private val thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice? = null, + private val tieredPackage: NewSubscriptionTieredPackagePrice? = null, + private val tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice? = null, + private val unitWithPercent: NewSubscriptionUnitWithPercentPrice? = null, + private val packageWithAllocation: NewSubscriptionPackageWithAllocationPrice? = null, + private val tieredWithProration: NewSubscriptionTierWithProrationPrice? = null, + private val unitWithProration: NewSubscriptionUnitWithProrationPrice? = null, + private val groupedAllocation: NewSubscriptionGroupedAllocationPrice? = null, + private val groupedWithProratedMinimum: + NewSubscriptionGroupedWithProratedMinimumPrice? = + null, + private val bulkWithProration: NewSubscriptionBulkWithProrationPrice? = null, + private val scalableMatrixWithUnitPricing: + NewSubscriptionScalableMatrixWithUnitPricingPrice? = + null, + private val scalableMatrixWithTieredPricing: + NewSubscriptionScalableMatrixWithTieredPricingPrice? = + null, + private val cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice? = null, + private val maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice? = null, + private val groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice? = + null, + private val matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice? = null, + private val groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice? = null, + private val matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice? = null, + private val tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice? = + null, + private val groupedTiered: NewSubscriptionGroupedTieredPrice? = null, + private val groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds? = null, + private val minimum: NewSubscriptionMinimumCompositePrice? = null, private val _json: JsonValue? = null, ) { - fun percentageDiscount(): NewPercentageDiscount? = percentageDiscount + fun unit(): NewSubscriptionUnitPrice? = unit - fun usageDiscount(): NewUsageDiscount? = usageDiscount + fun package_(): NewSubscriptionPackagePrice? = package_ - fun amountDiscount(): NewAmountDiscount? = amountDiscount + fun matrix(): NewSubscriptionMatrixPrice? = matrix - fun minimum(): NewMinimum? = minimum + fun tiered(): NewSubscriptionTieredPrice? = tiered - fun maximum(): NewMaximum? = maximum + fun bulk(): NewSubscriptionBulkPrice? = bulk - fun isPercentageDiscount(): Boolean = percentageDiscount != null + fun thresholdTotalAmount(): NewSubscriptionThresholdTotalAmountPrice? = + thresholdTotalAmount - fun isUsageDiscount(): Boolean = usageDiscount != null + fun tieredPackage(): NewSubscriptionTieredPackagePrice? = tieredPackage - fun isAmountDiscount(): Boolean = amountDiscount != null + fun tieredWithMinimum(): NewSubscriptionTieredWithMinimumPrice? = tieredWithMinimum - fun isMinimum(): Boolean = minimum != null + fun unitWithPercent(): NewSubscriptionUnitWithPercentPrice? = unitWithPercent - fun isMaximum(): Boolean = maximum != null + fun packageWithAllocation(): NewSubscriptionPackageWithAllocationPrice? = + packageWithAllocation - fun asPercentageDiscount(): NewPercentageDiscount = - percentageDiscount.getOrThrow("percentageDiscount") + fun tieredWithProration(): NewSubscriptionTierWithProrationPrice? = tieredWithProration - fun asUsageDiscount(): NewUsageDiscount = usageDiscount.getOrThrow("usageDiscount") + fun unitWithProration(): NewSubscriptionUnitWithProrationPrice? = unitWithProration - fun asAmountDiscount(): NewAmountDiscount = amountDiscount.getOrThrow("amountDiscount") + fun groupedAllocation(): NewSubscriptionGroupedAllocationPrice? = groupedAllocation - fun asMinimum(): NewMinimum = minimum.getOrThrow("minimum") + fun groupedWithProratedMinimum(): NewSubscriptionGroupedWithProratedMinimumPrice? = + groupedWithProratedMinimum - fun asMaximum(): NewMaximum = maximum.getOrThrow("maximum") + fun bulkWithProration(): NewSubscriptionBulkWithProrationPrice? = bulkWithProration - fun _json(): JsonValue? = _json + fun scalableMatrixWithUnitPricing(): + NewSubscriptionScalableMatrixWithUnitPricingPrice? = scalableMatrixWithUnitPricing - fun accept(visitor: Visitor): T = - when { - percentageDiscount != null -> - visitor.visitPercentageDiscount(percentageDiscount) - usageDiscount != null -> visitor.visitUsageDiscount(usageDiscount) - amountDiscount != null -> visitor.visitAmountDiscount(amountDiscount) - minimum != null -> visitor.visitMinimum(minimum) - maximum != null -> visitor.visitMaximum(maximum) - else -> visitor.unknown(_json) - } + fun scalableMatrixWithTieredPricing(): + NewSubscriptionScalableMatrixWithTieredPricingPrice? = + scalableMatrixWithTieredPricing - private var validated: Boolean = false + fun cumulativeGroupedBulk(): NewSubscriptionCumulativeGroupedBulkPrice? = + cumulativeGroupedBulk - fun validate(): Adjustment = apply { - if (validated) { - return@apply - } + fun maxGroupTieredPackage(): NewSubscriptionMaxGroupTieredPackagePrice? = + maxGroupTieredPackage - accept( - object : Visitor { - override fun visitPercentageDiscount( - percentageDiscount: NewPercentageDiscount - ) { - percentageDiscount.validate() - } + fun groupedWithMeteredMinimum(): NewSubscriptionGroupedWithMeteredMinimumPrice? = + groupedWithMeteredMinimum - override fun visitUsageDiscount(usageDiscount: NewUsageDiscount) { - usageDiscount.validate() - } + fun matrixWithDisplayName(): NewSubscriptionMatrixWithDisplayNamePrice? = + matrixWithDisplayName - override fun visitAmountDiscount(amountDiscount: NewAmountDiscount) { - amountDiscount.validate() - } + fun groupedTieredPackage(): NewSubscriptionGroupedTieredPackagePrice? = + groupedTieredPackage - override fun visitMinimum(minimum: NewMinimum) { - minimum.validate() - } + fun matrixWithAllocation(): NewSubscriptionMatrixWithAllocationPrice? = + matrixWithAllocation - override fun visitMaximum(maximum: NewMaximum) { - maximum.validate() - } - } - ) - validated = true - } + fun tieredPackageWithMinimum(): NewSubscriptionTieredPackageWithMinimumPrice? = + tieredPackageWithMinimum - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + fun groupedTiered(): NewSubscriptionGroupedTieredPrice? = groupedTiered - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitPercentageDiscount( - percentageDiscount: NewPercentageDiscount - ) = percentageDiscount.validity() + fun groupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds? = + groupedWithMinMaxThresholds - override fun visitUsageDiscount(usageDiscount: NewUsageDiscount) = - usageDiscount.validity() + fun minimum(): NewSubscriptionMinimumCompositePrice? = minimum - override fun visitAmountDiscount(amountDiscount: NewAmountDiscount) = - amountDiscount.validity() + fun isUnit(): Boolean = unit != null - override fun visitMinimum(minimum: NewMinimum) = minimum.validity() + fun isPackage(): Boolean = package_ != null - override fun visitMaximum(maximum: NewMaximum) = maximum.validity() + fun isMatrix(): Boolean = matrix != null - override fun unknown(json: JsonValue?) = 0 - } - ) + fun isTiered(): Boolean = tiered != null - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + fun isBulk(): Boolean = bulk != null - return other is Adjustment && - percentageDiscount == other.percentageDiscount && - usageDiscount == other.usageDiscount && - amountDiscount == other.amountDiscount && - minimum == other.minimum && - maximum == other.maximum - } + fun isThresholdTotalAmount(): Boolean = thresholdTotalAmount != null - override fun hashCode(): Int = - Objects.hash(percentageDiscount, usageDiscount, amountDiscount, minimum, maximum) + fun isTieredPackage(): Boolean = tieredPackage != null - override fun toString(): String = - when { - percentageDiscount != null -> - "Adjustment{percentageDiscount=$percentageDiscount}" - usageDiscount != null -> "Adjustment{usageDiscount=$usageDiscount}" - amountDiscount != null -> "Adjustment{amountDiscount=$amountDiscount}" - minimum != null -> "Adjustment{minimum=$minimum}" - maximum != null -> "Adjustment{maximum=$maximum}" - _json != null -> "Adjustment{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Adjustment") - } + fun isTieredWithMinimum(): Boolean = tieredWithMinimum != null - companion object { + fun isUnitWithPercent(): Boolean = unitWithPercent != null - fun ofPercentageDiscount(percentageDiscount: NewPercentageDiscount) = - Adjustment(percentageDiscount = percentageDiscount) - - fun ofUsageDiscount(usageDiscount: NewUsageDiscount) = - Adjustment(usageDiscount = usageDiscount) + fun isPackageWithAllocation(): Boolean = packageWithAllocation != null - fun ofAmountDiscount(amountDiscount: NewAmountDiscount) = - Adjustment(amountDiscount = amountDiscount) + fun isTieredWithProration(): Boolean = tieredWithProration != null - fun ofMinimum(minimum: NewMinimum) = Adjustment(minimum = minimum) + fun isUnitWithProration(): Boolean = unitWithProration != null - fun ofMaximum(maximum: NewMaximum) = Adjustment(maximum = maximum) - } + fun isGroupedAllocation(): Boolean = groupedAllocation != null - /** - * An interface that defines how to map each variant of [Adjustment] to a value of type - * [T]. - */ - interface Visitor { + fun isGroupedWithProratedMinimum(): Boolean = groupedWithProratedMinimum != null - fun visitPercentageDiscount(percentageDiscount: NewPercentageDiscount): T + fun isBulkWithProration(): Boolean = bulkWithProration != null - fun visitUsageDiscount(usageDiscount: NewUsageDiscount): T + fun isScalableMatrixWithUnitPricing(): Boolean = scalableMatrixWithUnitPricing != null - fun visitAmountDiscount(amountDiscount: NewAmountDiscount): T + fun isScalableMatrixWithTieredPricing(): Boolean = + scalableMatrixWithTieredPricing != null - fun visitMinimum(minimum: NewMinimum): T + fun isCumulativeGroupedBulk(): Boolean = cumulativeGroupedBulk != null - fun visitMaximum(maximum: NewMaximum): T + fun isMaxGroupTieredPackage(): Boolean = maxGroupTieredPackage != null - /** - * Maps an unknown variant of [Adjustment] to a value of type [T]. - * - * An instance of [Adjustment] can contain an unknown variant if it was deserialized - * from data that doesn't match any known variant. For example, if the SDK is on an - * older version than the API, then the API may respond with new variants that the - * SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown Adjustment: $json") - } - } + fun isGroupedWithMeteredMinimum(): Boolean = groupedWithMeteredMinimum != null - internal class Deserializer : BaseDeserializer(Adjustment::class) { + fun isMatrixWithDisplayName(): Boolean = matrixWithDisplayName != null - override fun ObjectCodec.deserialize(node: JsonNode): Adjustment { - val json = JsonValue.fromJsonNode(node) - val adjustmentType = json.asObject()?.get("adjustment_type")?.asString() + fun isGroupedTieredPackage(): Boolean = groupedTieredPackage != null - when (adjustmentType) { - "percentage_discount" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Adjustment(percentageDiscount = it, _json = json) } - ?: Adjustment(_json = json) - } - "usage_discount" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(usageDiscount = it, _json = json) - } ?: Adjustment(_json = json) - } - "amount_discount" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(amountDiscount = it, _json = json) - } ?: Adjustment(_json = json) - } - "minimum" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(minimum = it, _json = json) - } ?: Adjustment(_json = json) - } - "maximum" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(maximum = it, _json = json) - } ?: Adjustment(_json = json) - } - } + fun isMatrixWithAllocation(): Boolean = matrixWithAllocation != null - return Adjustment(_json = json) - } - } + fun isTieredPackageWithMinimum(): Boolean = tieredPackageWithMinimum != null - internal class Serializer : BaseSerializer(Adjustment::class) { + fun isGroupedTiered(): Boolean = groupedTiered != null - override fun serialize( - value: Adjustment, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.percentageDiscount != null -> - generator.writeObject(value.percentageDiscount) - value.usageDiscount != null -> generator.writeObject(value.usageDiscount) - value.amountDiscount != null -> generator.writeObject(value.amountDiscount) - value.minimum != null -> generator.writeObject(value.minimum) - value.maximum != null -> generator.writeObject(value.maximum) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Adjustment") - } - } - } - } + fun isGroupedWithMinMaxThresholds(): Boolean = groupedWithMinMaxThresholds != null - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + fun isMinimum(): Boolean = minimum != null - return other is ReplaceAdjustment && - adjustment == other.adjustment && - replacesAdjustmentId == other.replacesAdjustmentId && - additionalProperties == other.additionalProperties - } + fun asUnit(): NewSubscriptionUnitPrice = unit.getOrThrow("unit") - private val hashCode: Int by lazy { - Objects.hash(adjustment, replacesAdjustmentId, additionalProperties) - } + fun asPackage(): NewSubscriptionPackagePrice = package_.getOrThrow("package_") - override fun hashCode(): Int = hashCode + fun asMatrix(): NewSubscriptionMatrixPrice = matrix.getOrThrow("matrix") - override fun toString() = - "ReplaceAdjustment{adjustment=$adjustment, replacesAdjustmentId=$replacesAdjustmentId, additionalProperties=$additionalProperties}" - } + fun asTiered(): NewSubscriptionTieredPrice = tiered.getOrThrow("tiered") - class ReplacePrice - private constructor( - private val replacesPriceId: JsonField, - private val allocationPrice: JsonField, - private val discounts: JsonField>, - private val externalPriceId: JsonField, - private val fixedPriceQuantity: JsonField, - private val maximumAmount: JsonField, - private val minimumAmount: JsonField, - private val price: JsonField, - private val priceId: JsonField, - private val additionalProperties: MutableMap, - ) { + fun asBulk(): NewSubscriptionBulkPrice = bulk.getOrThrow("bulk") - @JsonCreator - private constructor( - @JsonProperty("replaces_price_id") - @ExcludeMissing - replacesPriceId: JsonField = JsonMissing.of(), - @JsonProperty("allocation_price") - @ExcludeMissing - allocationPrice: JsonField = JsonMissing.of(), - @JsonProperty("discounts") - @ExcludeMissing - discounts: JsonField> = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("maximum_amount") - @ExcludeMissing - maximumAmount: JsonField = JsonMissing.of(), - @JsonProperty("minimum_amount") - @ExcludeMissing - minimumAmount: JsonField = JsonMissing.of(), - @JsonProperty("price") @ExcludeMissing price: JsonField = JsonMissing.of(), - @JsonProperty("price_id") @ExcludeMissing priceId: JsonField = JsonMissing.of(), - ) : this( - replacesPriceId, - allocationPrice, - discounts, - externalPriceId, - fixedPriceQuantity, - maximumAmount, - minimumAmount, - price, - priceId, - mutableMapOf(), - ) + fun asThresholdTotalAmount(): NewSubscriptionThresholdTotalAmountPrice = + thresholdTotalAmount.getOrThrow("thresholdTotalAmount") - /** - * The id of the price on the plan to replace in the subscription. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun replacesPriceId(): String = replacesPriceId.getRequired("replaces_price_id") + fun asTieredPackage(): NewSubscriptionTieredPackagePrice = + tieredPackage.getOrThrow("tieredPackage") - /** - * The definition of a new allocation price to create and add to the subscription. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun allocationPrice(): NewAllocationPrice? = allocationPrice.getNullable("allocation_price") + fun asTieredWithMinimum(): NewSubscriptionTieredWithMinimumPrice = + tieredWithMinimum.getOrThrow("tieredWithMinimum") - /** - * [DEPRECATED] Use add_adjustments instead. The subscription's discounts for the - * replacement price. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - @Deprecated("deprecated") - fun discounts(): List? = discounts.getNullable("discounts") + fun asUnitWithPercent(): NewSubscriptionUnitWithPercentPrice = + unitWithPercent.getOrThrow("unitWithPercent") - /** - * The external price id of the price to add to the subscription. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + fun asPackageWithAllocation(): NewSubscriptionPackageWithAllocationPrice = + packageWithAllocation.getOrThrow("packageWithAllocation") - /** - * The new quantity of the price, if the price is a fixed price. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun fixedPriceQuantity(): Double? = fixedPriceQuantity.getNullable("fixed_price_quantity") + fun asTieredWithProration(): NewSubscriptionTierWithProrationPrice = + tieredWithProration.getOrThrow("tieredWithProration") - /** - * [DEPRECATED] Use add_adjustments instead. The subscription's maximum amount for the - * replacement price. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - @Deprecated("deprecated") - fun maximumAmount(): String? = maximumAmount.getNullable("maximum_amount") + fun asUnitWithProration(): NewSubscriptionUnitWithProrationPrice = + unitWithProration.getOrThrow("unitWithProration") - /** - * [DEPRECATED] Use add_adjustments instead. The subscription's minimum amount for the - * replacement price. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - @Deprecated("deprecated") - fun minimumAmount(): String? = minimumAmount.getNullable("minimum_amount") + fun asGroupedAllocation(): NewSubscriptionGroupedAllocationPrice = + groupedAllocation.getOrThrow("groupedAllocation") - /** - * The definition of a new price to create and add to the subscription. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun price(): Price? = price.getNullable("price") + fun asGroupedWithProratedMinimum(): NewSubscriptionGroupedWithProratedMinimumPrice = + groupedWithProratedMinimum.getOrThrow("groupedWithProratedMinimum") - /** - * The id of the price to add to the subscription. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun priceId(): String? = priceId.getNullable("price_id") + fun asBulkWithProration(): NewSubscriptionBulkWithProrationPrice = + bulkWithProration.getOrThrow("bulkWithProration") - /** - * Returns the raw JSON value of [replacesPriceId]. - * - * Unlike [replacesPriceId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("replaces_price_id") - @ExcludeMissing - fun _replacesPriceId(): JsonField = replacesPriceId + fun asScalableMatrixWithUnitPricing(): + NewSubscriptionScalableMatrixWithUnitPricingPrice = + scalableMatrixWithUnitPricing.getOrThrow("scalableMatrixWithUnitPricing") - /** - * Returns the raw JSON value of [allocationPrice]. - * - * Unlike [allocationPrice], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("allocation_price") - @ExcludeMissing - fun _allocationPrice(): JsonField = allocationPrice + fun asScalableMatrixWithTieredPricing(): + NewSubscriptionScalableMatrixWithTieredPricingPrice = + scalableMatrixWithTieredPricing.getOrThrow("scalableMatrixWithTieredPricing") - /** - * Returns the raw JSON value of [discounts]. - * - * Unlike [discounts], this method doesn't throw if the JSON field has an unexpected type. - */ - @Deprecated("deprecated") - @JsonProperty("discounts") - @ExcludeMissing - fun _discounts(): JsonField> = discounts + fun asCumulativeGroupedBulk(): NewSubscriptionCumulativeGroupedBulkPrice = + cumulativeGroupedBulk.getOrThrow("cumulativeGroupedBulk") - /** - * Returns the raw JSON value of [externalPriceId]. - * - * Unlike [externalPriceId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId + fun asMaxGroupTieredPackage(): NewSubscriptionMaxGroupTieredPackagePrice = + maxGroupTieredPackage.getOrThrow("maxGroupTieredPackage") - /** - * Returns the raw JSON value of [fixedPriceQuantity]. - * - * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + fun asGroupedWithMeteredMinimum(): NewSubscriptionGroupedWithMeteredMinimumPrice = + groupedWithMeteredMinimum.getOrThrow("groupedWithMeteredMinimum") - /** - * Returns the raw JSON value of [maximumAmount]. - * - * Unlike [maximumAmount], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @Deprecated("deprecated") - @JsonProperty("maximum_amount") - @ExcludeMissing - fun _maximumAmount(): JsonField = maximumAmount + fun asMatrixWithDisplayName(): NewSubscriptionMatrixWithDisplayNamePrice = + matrixWithDisplayName.getOrThrow("matrixWithDisplayName") - /** - * Returns the raw JSON value of [minimumAmount]. - * - * Unlike [minimumAmount], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @Deprecated("deprecated") - @JsonProperty("minimum_amount") - @ExcludeMissing - fun _minimumAmount(): JsonField = minimumAmount + fun asGroupedTieredPackage(): NewSubscriptionGroupedTieredPackagePrice = + groupedTieredPackage.getOrThrow("groupedTieredPackage") - /** - * Returns the raw JSON value of [price]. - * - * Unlike [price], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("price") @ExcludeMissing fun _price(): JsonField = price + fun asMatrixWithAllocation(): NewSubscriptionMatrixWithAllocationPrice = + matrixWithAllocation.getOrThrow("matrixWithAllocation") - /** - * Returns the raw JSON value of [priceId]. - * - * Unlike [priceId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId + fun asTieredPackageWithMinimum(): NewSubscriptionTieredPackageWithMinimumPrice = + tieredPackageWithMinimum.getOrThrow("tieredPackageWithMinimum") - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + fun asGroupedTiered(): NewSubscriptionGroupedTieredPrice = + groupedTiered.getOrThrow("groupedTiered") - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + fun asGroupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds = + groupedWithMinMaxThresholds.getOrThrow("groupedWithMinMaxThresholds") - fun toBuilder() = Builder().from(this) + fun asMinimum(): NewSubscriptionMinimumCompositePrice = minimum.getOrThrow("minimum") - companion object { + fun _json(): JsonValue? = _json - /** - * Returns a mutable builder for constructing an instance of [ReplacePrice]. - * - * The following fields are required: - * ```kotlin - * .replacesPriceId() - * ``` - */ - fun builder() = Builder() - } + fun accept(visitor: Visitor): T = + when { + unit != null -> visitor.visitUnit(unit) + package_ != null -> visitor.visitPackage(package_) + matrix != null -> visitor.visitMatrix(matrix) + tiered != null -> visitor.visitTiered(tiered) + bulk != null -> visitor.visitBulk(bulk) + thresholdTotalAmount != null -> + visitor.visitThresholdTotalAmount(thresholdTotalAmount) + tieredPackage != null -> visitor.visitTieredPackage(tieredPackage) + tieredWithMinimum != null -> visitor.visitTieredWithMinimum(tieredWithMinimum) + unitWithPercent != null -> visitor.visitUnitWithPercent(unitWithPercent) + packageWithAllocation != null -> + visitor.visitPackageWithAllocation(packageWithAllocation) + tieredWithProration != null -> + visitor.visitTieredWithProration(tieredWithProration) + unitWithProration != null -> visitor.visitUnitWithProration(unitWithProration) + groupedAllocation != null -> visitor.visitGroupedAllocation(groupedAllocation) + groupedWithProratedMinimum != null -> + visitor.visitGroupedWithProratedMinimum(groupedWithProratedMinimum) + bulkWithProration != null -> visitor.visitBulkWithProration(bulkWithProration) + scalableMatrixWithUnitPricing != null -> + visitor.visitScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing) + scalableMatrixWithTieredPricing != null -> + visitor.visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing + ) + cumulativeGroupedBulk != null -> + visitor.visitCumulativeGroupedBulk(cumulativeGroupedBulk) + maxGroupTieredPackage != null -> + visitor.visitMaxGroupTieredPackage(maxGroupTieredPackage) + groupedWithMeteredMinimum != null -> + visitor.visitGroupedWithMeteredMinimum(groupedWithMeteredMinimum) + matrixWithDisplayName != null -> + visitor.visitMatrixWithDisplayName(matrixWithDisplayName) + groupedTieredPackage != null -> + visitor.visitGroupedTieredPackage(groupedTieredPackage) + matrixWithAllocation != null -> + visitor.visitMatrixWithAllocation(matrixWithAllocation) + tieredPackageWithMinimum != null -> + visitor.visitTieredPackageWithMinimum(tieredPackageWithMinimum) + groupedTiered != null -> visitor.visitGroupedTiered(groupedTiered) + groupedWithMinMaxThresholds != null -> + visitor.visitGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds) + minimum != null -> visitor.visitMinimum(minimum) + else -> visitor.unknown(_json) + } - /** A builder for [ReplacePrice]. */ - class Builder internal constructor() { + private var validated: Boolean = false - private var replacesPriceId: JsonField? = null - private var allocationPrice: JsonField = JsonMissing.of() - private var discounts: JsonField>? = null - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var maximumAmount: JsonField = JsonMissing.of() - private var minimumAmount: JsonField = JsonMissing.of() - private var price: JsonField = JsonMissing.of() - private var priceId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + fun validate(): Price = apply { + if (validated) { + return@apply + } - internal fun from(replacePrice: ReplacePrice) = apply { - replacesPriceId = replacePrice.replacesPriceId - allocationPrice = replacePrice.allocationPrice - discounts = replacePrice.discounts.map { it.toMutableList() } - externalPriceId = replacePrice.externalPriceId - fixedPriceQuantity = replacePrice.fixedPriceQuantity - maximumAmount = replacePrice.maximumAmount - minimumAmount = replacePrice.minimumAmount - price = replacePrice.price - priceId = replacePrice.priceId - additionalProperties = replacePrice.additionalProperties.toMutableMap() - } + accept( + object : Visitor { + override fun visitUnit(unit: NewSubscriptionUnitPrice) { + unit.validate() + } - /** The id of the price on the plan to replace in the subscription. */ - fun replacesPriceId(replacesPriceId: String) = - replacesPriceId(JsonField.of(replacesPriceId)) + override fun visitPackage(package_: NewSubscriptionPackagePrice) { + package_.validate() + } - /** - * Sets [Builder.replacesPriceId] to an arbitrary JSON value. - * - * You should usually call [Builder.replacesPriceId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun replacesPriceId(replacesPriceId: JsonField) = apply { - this.replacesPriceId = replacesPriceId - } + override fun visitMatrix(matrix: NewSubscriptionMatrixPrice) { + matrix.validate() + } - /** The definition of a new allocation price to create and add to the subscription. */ - fun allocationPrice(allocationPrice: NewAllocationPrice?) = - allocationPrice(JsonField.ofNullable(allocationPrice)) + override fun visitTiered(tiered: NewSubscriptionTieredPrice) { + tiered.validate() + } - /** - * Sets [Builder.allocationPrice] to an arbitrary JSON value. - * - * You should usually call [Builder.allocationPrice] with a well-typed - * [NewAllocationPrice] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun allocationPrice(allocationPrice: JsonField) = apply { - this.allocationPrice = allocationPrice - } + override fun visitBulk(bulk: NewSubscriptionBulkPrice) { + bulk.validate() + } - /** - * [DEPRECATED] Use add_adjustments instead. The subscription's discounts for the - * replacement price. - */ - @Deprecated("deprecated") - fun discounts(discounts: List?) = - discounts(JsonField.ofNullable(discounts)) + override fun visitThresholdTotalAmount( + thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice + ) { + thresholdTotalAmount.validate() + } - /** - * Sets [Builder.discounts] to an arbitrary JSON value. - * - * You should usually call [Builder.discounts] with a well-typed - * `List` value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - @Deprecated("deprecated") - fun discounts(discounts: JsonField>) = apply { - this.discounts = discounts.map { it.toMutableList() } - } + override fun visitTieredPackage( + tieredPackage: NewSubscriptionTieredPackagePrice + ) { + tieredPackage.validate() + } - /** - * Adds a single [DiscountOverride] to [discounts]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - @Deprecated("deprecated") - fun addDiscount(discount: DiscountOverride) = apply { - discounts = - (discounts ?: JsonField.of(mutableListOf())).also { - checkKnown("discounts", it).add(discount) - } - } + override fun visitTieredWithMinimum( + tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice + ) { + tieredWithMinimum.validate() + } - /** The external price id of the price to add to the subscription. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) + override fun visitUnitWithPercent( + unitWithPercent: NewSubscriptionUnitWithPercentPrice + ) { + unitWithPercent.validate() + } - /** - * Sets [Builder.externalPriceId] to an arbitrary JSON value. - * - * You should usually call [Builder.externalPriceId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun externalPriceId(externalPriceId: JsonField) = apply { - this.externalPriceId = externalPriceId - } + override fun visitPackageWithAllocation( + packageWithAllocation: NewSubscriptionPackageWithAllocationPrice + ) { + packageWithAllocation.validate() + } - /** The new quantity of the price, if the price is a fixed price. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = - fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + override fun visitTieredWithProration( + tieredWithProration: NewSubscriptionTierWithProrationPrice + ) { + tieredWithProration.validate() + } - /** - * Alias for [Builder.fixedPriceQuantity]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) + override fun visitUnitWithProration( + unitWithProration: NewSubscriptionUnitWithProrationPrice + ) { + unitWithProration.validate() + } - /** - * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. - * - * You should usually call [Builder.fixedPriceQuantity] with a well-typed [Double] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + override fun visitGroupedAllocation( + groupedAllocation: NewSubscriptionGroupedAllocationPrice + ) { + groupedAllocation.validate() + } - /** - * [DEPRECATED] Use add_adjustments instead. The subscription's maximum amount for the - * replacement price. - */ - @Deprecated("deprecated") - fun maximumAmount(maximumAmount: String?) = - maximumAmount(JsonField.ofNullable(maximumAmount)) + override fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: + NewSubscriptionGroupedWithProratedMinimumPrice + ) { + groupedWithProratedMinimum.validate() + } - /** - * Sets [Builder.maximumAmount] to an arbitrary JSON value. - * - * You should usually call [Builder.maximumAmount] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - @Deprecated("deprecated") - fun maximumAmount(maximumAmount: JsonField) = apply { - this.maximumAmount = maximumAmount - } + override fun visitBulkWithProration( + bulkWithProration: NewSubscriptionBulkWithProrationPrice + ) { + bulkWithProration.validate() + } - /** - * [DEPRECATED] Use add_adjustments instead. The subscription's minimum amount for the - * replacement price. - */ - @Deprecated("deprecated") - fun minimumAmount(minimumAmount: String?) = - minimumAmount(JsonField.ofNullable(minimumAmount)) + override fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: + NewSubscriptionScalableMatrixWithUnitPricingPrice + ) { + scalableMatrixWithUnitPricing.validate() + } - /** - * Sets [Builder.minimumAmount] to an arbitrary JSON value. - * - * You should usually call [Builder.minimumAmount] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - @Deprecated("deprecated") - fun minimumAmount(minimumAmount: JsonField) = apply { - this.minimumAmount = minimumAmount - } + override fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: + NewSubscriptionScalableMatrixWithTieredPricingPrice + ) { + scalableMatrixWithTieredPricing.validate() + } - /** The definition of a new price to create and add to the subscription. */ - fun price(price: Price?) = price(JsonField.ofNullable(price)) + override fun visitCumulativeGroupedBulk( + cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice + ) { + cumulativeGroupedBulk.validate() + } - /** - * Sets [Builder.price] to an arbitrary JSON value. - * - * You should usually call [Builder.price] with a well-typed [Price] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun price(price: JsonField) = apply { this.price = price } + override fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice + ) { + maxGroupTieredPackage.validate() + } - /** Alias for calling [price] with `Price.ofUnit(unit)`. */ - fun price(unit: NewSubscriptionUnitPrice) = price(Price.ofUnit(unit)) + override fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice + ) { + groupedWithMeteredMinimum.validate() + } - /** Alias for calling [price] with `Price.ofPackage(package_)`. */ - fun price(package_: NewSubscriptionPackagePrice) = price(Price.ofPackage(package_)) + override fun visitMatrixWithDisplayName( + matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice + ) { + matrixWithDisplayName.validate() + } - /** Alias for calling [price] with `Price.ofMatrix(matrix)`. */ - fun price(matrix: NewSubscriptionMatrixPrice) = price(Price.ofMatrix(matrix)) + override fun visitGroupedTieredPackage( + groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice + ) { + groupedTieredPackage.validate() + } - /** Alias for calling [price] with `Price.ofTiered(tiered)`. */ - fun price(tiered: NewSubscriptionTieredPrice) = price(Price.ofTiered(tiered)) + override fun visitMatrixWithAllocation( + matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice + ) { + matrixWithAllocation.validate() + } - /** Alias for calling [price] with `Price.ofBulk(bulk)`. */ - fun price(bulk: NewSubscriptionBulkPrice) = price(Price.ofBulk(bulk)) + override fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice + ) { + tieredPackageWithMinimum.validate() + } - /** - * Alias for calling [price] with `Price.ofThresholdTotalAmount(thresholdTotalAmount)`. - */ - fun price(thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice) = - price(Price.ofThresholdTotalAmount(thresholdTotalAmount)) + override fun visitGroupedTiered( + groupedTiered: NewSubscriptionGroupedTieredPrice + ) { + groupedTiered.validate() + } - /** Alias for calling [price] with `Price.ofTieredPackage(tieredPackage)`. */ - fun price(tieredPackage: NewSubscriptionTieredPackagePrice) = - price(Price.ofTieredPackage(tieredPackage)) + override fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) { + groupedWithMinMaxThresholds.validate() + } - /** Alias for calling [price] with `Price.ofTieredWithMinimum(tieredWithMinimum)`. */ - fun price(tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice) = - price(Price.ofTieredWithMinimum(tieredWithMinimum)) + override fun visitMinimum(minimum: NewSubscriptionMinimumCompositePrice) { + minimum.validate() + } + } + ) + validated = true + } - /** Alias for calling [price] with `Price.ofUnitWithPercent(unitWithPercent)`. */ - fun price(unitWithPercent: NewSubscriptionUnitWithPercentPrice) = - price(Price.ofUnitWithPercent(unitWithPercent)) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } /** - * Alias for calling [price] with - * `Price.ofPackageWithAllocation(packageWithAllocation)`. + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. */ - fun price(packageWithAllocation: NewSubscriptionPackageWithAllocationPrice) = - price(Price.ofPackageWithAllocation(packageWithAllocation)) + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitUnit(unit: NewSubscriptionUnitPrice) = unit.validity() - /** - * Alias for calling [price] with `Price.ofTieredWithProration(tieredWithProration)`. - */ - fun price(tieredWithProration: NewSubscriptionTierWithProrationPrice) = - price(Price.ofTieredWithProration(tieredWithProration)) + override fun visitPackage(package_: NewSubscriptionPackagePrice) = + package_.validity() - /** Alias for calling [price] with `Price.ofUnitWithProration(unitWithProration)`. */ - fun price(unitWithProration: NewSubscriptionUnitWithProrationPrice) = - price(Price.ofUnitWithProration(unitWithProration)) + override fun visitMatrix(matrix: NewSubscriptionMatrixPrice) = + matrix.validity() - /** Alias for calling [price] with `Price.ofGroupedAllocation(groupedAllocation)`. */ - fun price(groupedAllocation: NewSubscriptionGroupedAllocationPrice) = - price(Price.ofGroupedAllocation(groupedAllocation)) + override fun visitTiered(tiered: NewSubscriptionTieredPrice) = + tiered.validity() - /** - * Alias for calling [price] with - * `Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)`. - */ - fun price(groupedWithProratedMinimum: NewSubscriptionGroupedWithProratedMinimumPrice) = - price(Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)) + override fun visitBulk(bulk: NewSubscriptionBulkPrice) = bulk.validity() - /** Alias for calling [price] with `Price.ofBulkWithProration(bulkWithProration)`. */ - fun price(bulkWithProration: NewSubscriptionBulkWithProrationPrice) = - price(Price.ofBulkWithProration(bulkWithProration)) + override fun visitThresholdTotalAmount( + thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice + ) = thresholdTotalAmount.validity() - /** - * Alias for calling [price] with - * `Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)`. - */ - fun price( - scalableMatrixWithUnitPricing: NewSubscriptionScalableMatrixWithUnitPricingPrice - ) = price(Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)) + override fun visitTieredPackage( + tieredPackage: NewSubscriptionTieredPackagePrice + ) = tieredPackage.validity() - /** - * Alias for calling [price] with - * `Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)`. - */ - fun price( - scalableMatrixWithTieredPricing: NewSubscriptionScalableMatrixWithTieredPricingPrice - ) = price(Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)) + override fun visitTieredWithMinimum( + tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice + ) = tieredWithMinimum.validity() - /** - * Alias for calling [price] with - * `Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)`. - */ - fun price(cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice) = - price(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) + override fun visitUnitWithPercent( + unitWithPercent: NewSubscriptionUnitWithPercentPrice + ) = unitWithPercent.validity() - /** - * Alias for calling [price] with - * `Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)`. - */ - fun price(maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice) = - price(Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)) + override fun visitPackageWithAllocation( + packageWithAllocation: NewSubscriptionPackageWithAllocationPrice + ) = packageWithAllocation.validity() - /** - * Alias for calling [price] with - * `Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)`. - */ - fun price(groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice) = - price(Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)) + override fun visitTieredWithProration( + tieredWithProration: NewSubscriptionTierWithProrationPrice + ) = tieredWithProration.validity() - /** - * Alias for calling [price] with - * `Price.ofMatrixWithDisplayName(matrixWithDisplayName)`. - */ - fun price(matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice) = - price(Price.ofMatrixWithDisplayName(matrixWithDisplayName)) + override fun visitUnitWithProration( + unitWithProration: NewSubscriptionUnitWithProrationPrice + ) = unitWithProration.validity() - /** - * Alias for calling [price] with `Price.ofGroupedTieredPackage(groupedTieredPackage)`. - */ - fun price(groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice) = - price(Price.ofGroupedTieredPackage(groupedTieredPackage)) + override fun visitGroupedAllocation( + groupedAllocation: NewSubscriptionGroupedAllocationPrice + ) = groupedAllocation.validity() - /** - * Alias for calling [price] with `Price.ofMatrixWithAllocation(matrixWithAllocation)`. - */ - fun price(matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice) = - price(Price.ofMatrixWithAllocation(matrixWithAllocation)) + override fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: + NewSubscriptionGroupedWithProratedMinimumPrice + ) = groupedWithProratedMinimum.validity() - /** - * Alias for calling [price] with - * `Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)`. - */ - fun price(tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice) = - price(Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)) + override fun visitBulkWithProration( + bulkWithProration: NewSubscriptionBulkWithProrationPrice + ) = bulkWithProration.validity() - /** Alias for calling [price] with `Price.ofGroupedTiered(groupedTiered)`. */ - fun price(groupedTiered: NewSubscriptionGroupedTieredPrice) = - price(Price.ofGroupedTiered(groupedTiered)) + override fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: + NewSubscriptionScalableMatrixWithUnitPricingPrice + ) = scalableMatrixWithUnitPricing.validity() - /** - * Alias for calling [price] with - * `Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)`. - */ - fun price(groupedWithMinMaxThresholds: Price.GroupedWithMinMaxThresholds) = - price(Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)) + override fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: + NewSubscriptionScalableMatrixWithTieredPricingPrice + ) = scalableMatrixWithTieredPricing.validity() - /** Alias for calling [price] with `Price.ofMinimum(minimum)`. */ - fun price(minimum: Price.Minimum) = price(Price.ofMinimum(minimum)) + override fun visitCumulativeGroupedBulk( + cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice + ) = cumulativeGroupedBulk.validity() - /** The id of the price to add to the subscription. */ - fun priceId(priceId: String?) = priceId(JsonField.ofNullable(priceId)) + override fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice + ) = maxGroupTieredPackage.validity() - /** - * Sets [Builder.priceId] to an arbitrary JSON value. - * - * You should usually call [Builder.priceId] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun priceId(priceId: JsonField) = apply { this.priceId = priceId } + override fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice + ) = groupedWithMeteredMinimum.validity() - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + override fun visitMatrixWithDisplayName( + matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice + ) = matrixWithDisplayName.validity() - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + override fun visitGroupedTieredPackage( + groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice + ) = groupedTieredPackage.validity() - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + override fun visitMatrixWithAllocation( + matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice + ) = matrixWithAllocation.validity() - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + override fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice + ) = tieredPackageWithMinimum.validity() - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + override fun visitGroupedTiered( + groupedTiered: NewSubscriptionGroupedTieredPrice + ) = groupedTiered.validity() - /** - * Returns an immutable instance of [ReplacePrice]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```kotlin - * .replacesPriceId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): ReplacePrice = - ReplacePrice( - checkRequired("replacesPriceId", replacesPriceId), - allocationPrice, - (discounts ?: JsonMissing.of()).map { it.toImmutable() }, - externalPriceId, - fixedPriceQuantity, - maximumAmount, - minimumAmount, - price, - priceId, - additionalProperties.toMutableMap(), + override fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) = groupedWithMinMaxThresholds.validity() + + override fun visitMinimum(minimum: NewSubscriptionMinimumCompositePrice) = + minimum.validity() + + override fun unknown(json: JsonValue?) = 0 + } ) - } - private var validated: Boolean = false + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun validate(): ReplacePrice = apply { - if (validated) { - return@apply + return other is Price && + unit == other.unit && + package_ == other.package_ && + matrix == other.matrix && + tiered == other.tiered && + bulk == other.bulk && + thresholdTotalAmount == other.thresholdTotalAmount && + tieredPackage == other.tieredPackage && + tieredWithMinimum == other.tieredWithMinimum && + unitWithPercent == other.unitWithPercent && + packageWithAllocation == other.packageWithAllocation && + tieredWithProration == other.tieredWithProration && + unitWithProration == other.unitWithProration && + groupedAllocation == other.groupedAllocation && + groupedWithProratedMinimum == other.groupedWithProratedMinimum && + bulkWithProration == other.bulkWithProration && + scalableMatrixWithUnitPricing == other.scalableMatrixWithUnitPricing && + scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && + cumulativeGroupedBulk == other.cumulativeGroupedBulk && + maxGroupTieredPackage == other.maxGroupTieredPackage && + groupedWithMeteredMinimum == other.groupedWithMeteredMinimum && + matrixWithDisplayName == other.matrixWithDisplayName && + groupedTieredPackage == other.groupedTieredPackage && + matrixWithAllocation == other.matrixWithAllocation && + tieredPackageWithMinimum == other.tieredPackageWithMinimum && + groupedTiered == other.groupedTiered && + groupedWithMinMaxThresholds == other.groupedWithMinMaxThresholds && + minimum == other.minimum } - replacesPriceId() - allocationPrice()?.validate() - discounts()?.forEach { it.validate() } - externalPriceId() - fixedPriceQuantity() - maximumAmount() - minimumAmount() - price()?.validate() - priceId() - validated = true - } + override fun hashCode(): Int = + Objects.hash( + unit, + package_, + matrix, + tiered, + bulk, + thresholdTotalAmount, + tieredPackage, + tieredWithMinimum, + unitWithPercent, + packageWithAllocation, + tieredWithProration, + unitWithProration, + groupedAllocation, + groupedWithProratedMinimum, + bulkWithProration, + scalableMatrixWithUnitPricing, + scalableMatrixWithTieredPricing, + cumulativeGroupedBulk, + maxGroupTieredPackage, + groupedWithMeteredMinimum, + matrixWithDisplayName, + groupedTieredPackage, + matrixWithAllocation, + tieredPackageWithMinimum, + groupedTiered, + groupedWithMinMaxThresholds, + minimum, + ) - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + override fun toString(): String = + when { + unit != null -> "Price{unit=$unit}" + package_ != null -> "Price{package_=$package_}" + matrix != null -> "Price{matrix=$matrix}" + tiered != null -> "Price{tiered=$tiered}" + bulk != null -> "Price{bulk=$bulk}" + thresholdTotalAmount != null -> + "Price{thresholdTotalAmount=$thresholdTotalAmount}" + tieredPackage != null -> "Price{tieredPackage=$tieredPackage}" + tieredWithMinimum != null -> "Price{tieredWithMinimum=$tieredWithMinimum}" + unitWithPercent != null -> "Price{unitWithPercent=$unitWithPercent}" + packageWithAllocation != null -> + "Price{packageWithAllocation=$packageWithAllocation}" + tieredWithProration != null -> "Price{tieredWithProration=$tieredWithProration}" + unitWithProration != null -> "Price{unitWithProration=$unitWithProration}" + groupedAllocation != null -> "Price{groupedAllocation=$groupedAllocation}" + groupedWithProratedMinimum != null -> + "Price{groupedWithProratedMinimum=$groupedWithProratedMinimum}" + bulkWithProration != null -> "Price{bulkWithProration=$bulkWithProration}" + scalableMatrixWithUnitPricing != null -> + "Price{scalableMatrixWithUnitPricing=$scalableMatrixWithUnitPricing}" + scalableMatrixWithTieredPricing != null -> + "Price{scalableMatrixWithTieredPricing=$scalableMatrixWithTieredPricing}" + cumulativeGroupedBulk != null -> + "Price{cumulativeGroupedBulk=$cumulativeGroupedBulk}" + maxGroupTieredPackage != null -> + "Price{maxGroupTieredPackage=$maxGroupTieredPackage}" + groupedWithMeteredMinimum != null -> + "Price{groupedWithMeteredMinimum=$groupedWithMeteredMinimum}" + matrixWithDisplayName != null -> + "Price{matrixWithDisplayName=$matrixWithDisplayName}" + groupedTieredPackage != null -> + "Price{groupedTieredPackage=$groupedTieredPackage}" + matrixWithAllocation != null -> + "Price{matrixWithAllocation=$matrixWithAllocation}" + tieredPackageWithMinimum != null -> + "Price{tieredPackageWithMinimum=$tieredPackageWithMinimum}" + groupedTiered != null -> "Price{groupedTiered=$groupedTiered}" + groupedWithMinMaxThresholds != null -> + "Price{groupedWithMinMaxThresholds=$groupedWithMinMaxThresholds}" + minimum != null -> "Price{minimum=$minimum}" + _json != null -> "Price{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Price") + } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (if (replacesPriceId.asKnown() == null) 0 else 1) + - (allocationPrice.asKnown()?.validity() ?: 0) + - (discounts.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + - (if (externalPriceId.asKnown() == null) 0 else 1) + - (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + - (if (maximumAmount.asKnown() == null) 0 else 1) + - (if (minimumAmount.asKnown() == null) 0 else 1) + - (price.asKnown()?.validity() ?: 0) + - (if (priceId.asKnown() == null) 0 else 1) + companion object { - /** The definition of a new price to create and add to the subscription. */ - @JsonDeserialize(using = Price.Deserializer::class) - @JsonSerialize(using = Price.Serializer::class) - class Price - private constructor( - private val unit: NewSubscriptionUnitPrice? = null, - private val package_: NewSubscriptionPackagePrice? = null, - private val matrix: NewSubscriptionMatrixPrice? = null, - private val tiered: NewSubscriptionTieredPrice? = null, - private val bulk: NewSubscriptionBulkPrice? = null, - private val thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice? = null, - private val tieredPackage: NewSubscriptionTieredPackagePrice? = null, - private val tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice? = null, - private val unitWithPercent: NewSubscriptionUnitWithPercentPrice? = null, - private val packageWithAllocation: NewSubscriptionPackageWithAllocationPrice? = null, - private val tieredWithProration: NewSubscriptionTierWithProrationPrice? = null, - private val unitWithProration: NewSubscriptionUnitWithProrationPrice? = null, - private val groupedAllocation: NewSubscriptionGroupedAllocationPrice? = null, - private val groupedWithProratedMinimum: - NewSubscriptionGroupedWithProratedMinimumPrice? = - null, - private val bulkWithProration: NewSubscriptionBulkWithProrationPrice? = null, - private val scalableMatrixWithUnitPricing: - NewSubscriptionScalableMatrixWithUnitPricingPrice? = - null, - private val scalableMatrixWithTieredPricing: - NewSubscriptionScalableMatrixWithTieredPricingPrice? = - null, - private val cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice? = null, - private val maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice? = null, - private val groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice? = - null, - private val matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice? = null, - private val groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice? = null, - private val matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice? = null, - private val tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice? = - null, - private val groupedTiered: NewSubscriptionGroupedTieredPrice? = null, - private val groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds? = null, - private val minimum: Minimum? = null, - private val _json: JsonValue? = null, - ) { + fun ofUnit(unit: NewSubscriptionUnitPrice) = Price(unit = unit) - fun unit(): NewSubscriptionUnitPrice? = unit + fun ofPackage(package_: NewSubscriptionPackagePrice) = Price(package_ = package_) - fun package_(): NewSubscriptionPackagePrice? = package_ + fun ofMatrix(matrix: NewSubscriptionMatrixPrice) = Price(matrix = matrix) - fun matrix(): NewSubscriptionMatrixPrice? = matrix + fun ofTiered(tiered: NewSubscriptionTieredPrice) = Price(tiered = tiered) - fun tiered(): NewSubscriptionTieredPrice? = tiered + fun ofBulk(bulk: NewSubscriptionBulkPrice) = Price(bulk = bulk) - fun bulk(): NewSubscriptionBulkPrice? = bulk + fun ofThresholdTotalAmount( + thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice + ) = Price(thresholdTotalAmount = thresholdTotalAmount) - fun thresholdTotalAmount(): NewSubscriptionThresholdTotalAmountPrice? = - thresholdTotalAmount + fun ofTieredPackage(tieredPackage: NewSubscriptionTieredPackagePrice) = + Price(tieredPackage = tieredPackage) - fun tieredPackage(): NewSubscriptionTieredPackagePrice? = tieredPackage + fun ofTieredWithMinimum(tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice) = + Price(tieredWithMinimum = tieredWithMinimum) - fun tieredWithMinimum(): NewSubscriptionTieredWithMinimumPrice? = tieredWithMinimum + fun ofUnitWithPercent(unitWithPercent: NewSubscriptionUnitWithPercentPrice) = + Price(unitWithPercent = unitWithPercent) - fun unitWithPercent(): NewSubscriptionUnitWithPercentPrice? = unitWithPercent + fun ofPackageWithAllocation( + packageWithAllocation: NewSubscriptionPackageWithAllocationPrice + ) = Price(packageWithAllocation = packageWithAllocation) - fun packageWithAllocation(): NewSubscriptionPackageWithAllocationPrice? = - packageWithAllocation + fun ofTieredWithProration( + tieredWithProration: NewSubscriptionTierWithProrationPrice + ) = Price(tieredWithProration = tieredWithProration) - fun tieredWithProration(): NewSubscriptionTierWithProrationPrice? = tieredWithProration + fun ofUnitWithProration(unitWithProration: NewSubscriptionUnitWithProrationPrice) = + Price(unitWithProration = unitWithProration) - fun unitWithProration(): NewSubscriptionUnitWithProrationPrice? = unitWithProration + fun ofGroupedAllocation(groupedAllocation: NewSubscriptionGroupedAllocationPrice) = + Price(groupedAllocation = groupedAllocation) - fun groupedAllocation(): NewSubscriptionGroupedAllocationPrice? = groupedAllocation + fun ofGroupedWithProratedMinimum( + groupedWithProratedMinimum: NewSubscriptionGroupedWithProratedMinimumPrice + ) = Price(groupedWithProratedMinimum = groupedWithProratedMinimum) - fun groupedWithProratedMinimum(): NewSubscriptionGroupedWithProratedMinimumPrice? = - groupedWithProratedMinimum + fun ofBulkWithProration(bulkWithProration: NewSubscriptionBulkWithProrationPrice) = + Price(bulkWithProration = bulkWithProration) - fun bulkWithProration(): NewSubscriptionBulkWithProrationPrice? = bulkWithProration + fun ofScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: NewSubscriptionScalableMatrixWithUnitPricingPrice + ) = Price(scalableMatrixWithUnitPricing = scalableMatrixWithUnitPricing) - fun scalableMatrixWithUnitPricing(): - NewSubscriptionScalableMatrixWithUnitPricingPrice? = scalableMatrixWithUnitPricing + fun ofScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: + NewSubscriptionScalableMatrixWithTieredPricingPrice + ) = Price(scalableMatrixWithTieredPricing = scalableMatrixWithTieredPricing) - fun scalableMatrixWithTieredPricing(): - NewSubscriptionScalableMatrixWithTieredPricingPrice? = - scalableMatrixWithTieredPricing + fun ofCumulativeGroupedBulk( + cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice + ) = Price(cumulativeGroupedBulk = cumulativeGroupedBulk) - fun cumulativeGroupedBulk(): NewSubscriptionCumulativeGroupedBulkPrice? = - cumulativeGroupedBulk + fun ofMaxGroupTieredPackage( + maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice + ) = Price(maxGroupTieredPackage = maxGroupTieredPackage) - fun maxGroupTieredPackage(): NewSubscriptionMaxGroupTieredPackagePrice? = - maxGroupTieredPackage + fun ofGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice + ) = Price(groupedWithMeteredMinimum = groupedWithMeteredMinimum) - fun groupedWithMeteredMinimum(): NewSubscriptionGroupedWithMeteredMinimumPrice? = - groupedWithMeteredMinimum + fun ofMatrixWithDisplayName( + matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice + ) = Price(matrixWithDisplayName = matrixWithDisplayName) - fun matrixWithDisplayName(): NewSubscriptionMatrixWithDisplayNamePrice? = - matrixWithDisplayName + fun ofGroupedTieredPackage( + groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice + ) = Price(groupedTieredPackage = groupedTieredPackage) - fun groupedTieredPackage(): NewSubscriptionGroupedTieredPackagePrice? = - groupedTieredPackage + fun ofMatrixWithAllocation( + matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice + ) = Price(matrixWithAllocation = matrixWithAllocation) - fun matrixWithAllocation(): NewSubscriptionMatrixWithAllocationPrice? = - matrixWithAllocation + fun ofTieredPackageWithMinimum( + tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice + ) = Price(tieredPackageWithMinimum = tieredPackageWithMinimum) - fun tieredPackageWithMinimum(): NewSubscriptionTieredPackageWithMinimumPrice? = - tieredPackageWithMinimum + fun ofGroupedTiered(groupedTiered: NewSubscriptionGroupedTieredPrice) = + Price(groupedTiered = groupedTiered) - fun groupedTiered(): NewSubscriptionGroupedTieredPrice? = groupedTiered + fun ofGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) = Price(groupedWithMinMaxThresholds = groupedWithMinMaxThresholds) - fun groupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds? = - groupedWithMinMaxThresholds + fun ofMinimum(minimum: NewSubscriptionMinimumCompositePrice) = + Price(minimum = minimum) + } - fun minimum(): Minimum? = minimum + /** + * An interface that defines how to map each variant of [Price] to a value of type [T]. + */ + interface Visitor { - fun isUnit(): Boolean = unit != null + fun visitUnit(unit: NewSubscriptionUnitPrice): T - fun isPackage(): Boolean = package_ != null + fun visitPackage(package_: NewSubscriptionPackagePrice): T - fun isMatrix(): Boolean = matrix != null - - fun isTiered(): Boolean = tiered != null - - fun isBulk(): Boolean = bulk != null - - fun isThresholdTotalAmount(): Boolean = thresholdTotalAmount != null - - fun isTieredPackage(): Boolean = tieredPackage != null - - fun isTieredWithMinimum(): Boolean = tieredWithMinimum != null - - fun isUnitWithPercent(): Boolean = unitWithPercent != null - - fun isPackageWithAllocation(): Boolean = packageWithAllocation != null - - fun isTieredWithProration(): Boolean = tieredWithProration != null - - fun isUnitWithProration(): Boolean = unitWithProration != null - - fun isGroupedAllocation(): Boolean = groupedAllocation != null - - fun isGroupedWithProratedMinimum(): Boolean = groupedWithProratedMinimum != null - - fun isBulkWithProration(): Boolean = bulkWithProration != null - - fun isScalableMatrixWithUnitPricing(): Boolean = scalableMatrixWithUnitPricing != null - - fun isScalableMatrixWithTieredPricing(): Boolean = - scalableMatrixWithTieredPricing != null - - fun isCumulativeGroupedBulk(): Boolean = cumulativeGroupedBulk != null - - fun isMaxGroupTieredPackage(): Boolean = maxGroupTieredPackage != null - - fun isGroupedWithMeteredMinimum(): Boolean = groupedWithMeteredMinimum != null - - fun isMatrixWithDisplayName(): Boolean = matrixWithDisplayName != null - - fun isGroupedTieredPackage(): Boolean = groupedTieredPackage != null - - fun isMatrixWithAllocation(): Boolean = matrixWithAllocation != null - - fun isTieredPackageWithMinimum(): Boolean = tieredPackageWithMinimum != null - - fun isGroupedTiered(): Boolean = groupedTiered != null - - fun isGroupedWithMinMaxThresholds(): Boolean = groupedWithMinMaxThresholds != null - - fun isMinimum(): Boolean = minimum != null - - fun asUnit(): NewSubscriptionUnitPrice = unit.getOrThrow("unit") - - fun asPackage(): NewSubscriptionPackagePrice = package_.getOrThrow("package_") - - fun asMatrix(): NewSubscriptionMatrixPrice = matrix.getOrThrow("matrix") - - fun asTiered(): NewSubscriptionTieredPrice = tiered.getOrThrow("tiered") + fun visitMatrix(matrix: NewSubscriptionMatrixPrice): T - fun asBulk(): NewSubscriptionBulkPrice = bulk.getOrThrow("bulk") + fun visitTiered(tiered: NewSubscriptionTieredPrice): T - fun asThresholdTotalAmount(): NewSubscriptionThresholdTotalAmountPrice = - thresholdTotalAmount.getOrThrow("thresholdTotalAmount") + fun visitBulk(bulk: NewSubscriptionBulkPrice): T - fun asTieredPackage(): NewSubscriptionTieredPackagePrice = - tieredPackage.getOrThrow("tieredPackage") + fun visitThresholdTotalAmount( + thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice + ): T - fun asTieredWithMinimum(): NewSubscriptionTieredWithMinimumPrice = - tieredWithMinimum.getOrThrow("tieredWithMinimum") + fun visitTieredPackage(tieredPackage: NewSubscriptionTieredPackagePrice): T - fun asUnitWithPercent(): NewSubscriptionUnitWithPercentPrice = - unitWithPercent.getOrThrow("unitWithPercent") + fun visitTieredWithMinimum( + tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice + ): T - fun asPackageWithAllocation(): NewSubscriptionPackageWithAllocationPrice = - packageWithAllocation.getOrThrow("packageWithAllocation") + fun visitUnitWithPercent(unitWithPercent: NewSubscriptionUnitWithPercentPrice): T - fun asTieredWithProration(): NewSubscriptionTierWithProrationPrice = - tieredWithProration.getOrThrow("tieredWithProration") + fun visitPackageWithAllocation( + packageWithAllocation: NewSubscriptionPackageWithAllocationPrice + ): T - fun asUnitWithProration(): NewSubscriptionUnitWithProrationPrice = - unitWithProration.getOrThrow("unitWithProration") + fun visitTieredWithProration( + tieredWithProration: NewSubscriptionTierWithProrationPrice + ): T - fun asGroupedAllocation(): NewSubscriptionGroupedAllocationPrice = - groupedAllocation.getOrThrow("groupedAllocation") + fun visitUnitWithProration( + unitWithProration: NewSubscriptionUnitWithProrationPrice + ): T - fun asGroupedWithProratedMinimum(): NewSubscriptionGroupedWithProratedMinimumPrice = - groupedWithProratedMinimum.getOrThrow("groupedWithProratedMinimum") + fun visitGroupedAllocation( + groupedAllocation: NewSubscriptionGroupedAllocationPrice + ): T - fun asBulkWithProration(): NewSubscriptionBulkWithProrationPrice = - bulkWithProration.getOrThrow("bulkWithProration") + fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: NewSubscriptionGroupedWithProratedMinimumPrice + ): T - fun asScalableMatrixWithUnitPricing(): - NewSubscriptionScalableMatrixWithUnitPricingPrice = - scalableMatrixWithUnitPricing.getOrThrow("scalableMatrixWithUnitPricing") + fun visitBulkWithProration( + bulkWithProration: NewSubscriptionBulkWithProrationPrice + ): T - fun asScalableMatrixWithTieredPricing(): - NewSubscriptionScalableMatrixWithTieredPricingPrice = - scalableMatrixWithTieredPricing.getOrThrow("scalableMatrixWithTieredPricing") + fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: NewSubscriptionScalableMatrixWithUnitPricingPrice + ): T - fun asCumulativeGroupedBulk(): NewSubscriptionCumulativeGroupedBulkPrice = - cumulativeGroupedBulk.getOrThrow("cumulativeGroupedBulk") + fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: + NewSubscriptionScalableMatrixWithTieredPricingPrice + ): T - fun asMaxGroupTieredPackage(): NewSubscriptionMaxGroupTieredPackagePrice = - maxGroupTieredPackage.getOrThrow("maxGroupTieredPackage") + fun visitCumulativeGroupedBulk( + cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice + ): T - fun asGroupedWithMeteredMinimum(): NewSubscriptionGroupedWithMeteredMinimumPrice = - groupedWithMeteredMinimum.getOrThrow("groupedWithMeteredMinimum") + fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice + ): T - fun asMatrixWithDisplayName(): NewSubscriptionMatrixWithDisplayNamePrice = - matrixWithDisplayName.getOrThrow("matrixWithDisplayName") + fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice + ): T - fun asGroupedTieredPackage(): NewSubscriptionGroupedTieredPackagePrice = - groupedTieredPackage.getOrThrow("groupedTieredPackage") + fun visitMatrixWithDisplayName( + matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice + ): T - fun asMatrixWithAllocation(): NewSubscriptionMatrixWithAllocationPrice = - matrixWithAllocation.getOrThrow("matrixWithAllocation") + fun visitGroupedTieredPackage( + groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice + ): T - fun asTieredPackageWithMinimum(): NewSubscriptionTieredPackageWithMinimumPrice = - tieredPackageWithMinimum.getOrThrow("tieredPackageWithMinimum") + fun visitMatrixWithAllocation( + matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice + ): T - fun asGroupedTiered(): NewSubscriptionGroupedTieredPrice = - groupedTiered.getOrThrow("groupedTiered") + fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice + ): T - fun asGroupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds = - groupedWithMinMaxThresholds.getOrThrow("groupedWithMinMaxThresholds") + fun visitGroupedTiered(groupedTiered: NewSubscriptionGroupedTieredPrice): T - fun asMinimum(): Minimum = minimum.getOrThrow("minimum") + fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ): T - fun _json(): JsonValue? = _json + fun visitMinimum(minimum: NewSubscriptionMinimumCompositePrice): T - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - package_ != null -> visitor.visitPackage(package_) - matrix != null -> visitor.visitMatrix(matrix) - tiered != null -> visitor.visitTiered(tiered) - bulk != null -> visitor.visitBulk(bulk) - thresholdTotalAmount != null -> - visitor.visitThresholdTotalAmount(thresholdTotalAmount) - tieredPackage != null -> visitor.visitTieredPackage(tieredPackage) - tieredWithMinimum != null -> visitor.visitTieredWithMinimum(tieredWithMinimum) - unitWithPercent != null -> visitor.visitUnitWithPercent(unitWithPercent) - packageWithAllocation != null -> - visitor.visitPackageWithAllocation(packageWithAllocation) - tieredWithProration != null -> - visitor.visitTieredWithProration(tieredWithProration) - unitWithProration != null -> visitor.visitUnitWithProration(unitWithProration) - groupedAllocation != null -> visitor.visitGroupedAllocation(groupedAllocation) - groupedWithProratedMinimum != null -> - visitor.visitGroupedWithProratedMinimum(groupedWithProratedMinimum) - bulkWithProration != null -> visitor.visitBulkWithProration(bulkWithProration) - scalableMatrixWithUnitPricing != null -> - visitor.visitScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing) - scalableMatrixWithTieredPricing != null -> - visitor.visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing - ) - cumulativeGroupedBulk != null -> - visitor.visitCumulativeGroupedBulk(cumulativeGroupedBulk) - maxGroupTieredPackage != null -> - visitor.visitMaxGroupTieredPackage(maxGroupTieredPackage) - groupedWithMeteredMinimum != null -> - visitor.visitGroupedWithMeteredMinimum(groupedWithMeteredMinimum) - matrixWithDisplayName != null -> - visitor.visitMatrixWithDisplayName(matrixWithDisplayName) - groupedTieredPackage != null -> - visitor.visitGroupedTieredPackage(groupedTieredPackage) - matrixWithAllocation != null -> - visitor.visitMatrixWithAllocation(matrixWithAllocation) - tieredPackageWithMinimum != null -> - visitor.visitTieredPackageWithMinimum(tieredPackageWithMinimum) - groupedTiered != null -> visitor.visitGroupedTiered(groupedTiered) - groupedWithMinMaxThresholds != null -> - visitor.visitGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds) - minimum != null -> visitor.visitMinimum(minimum) - else -> visitor.unknown(_json) + /** + * Maps an unknown variant of [Price] to a value of type [T]. + * + * An instance of [Price] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is + * unaware of. + * + * @throws OrbInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw OrbInvalidDataException("Unknown Price: $json") } + } - private var validated: Boolean = false - - fun validate(): Price = apply { - if (validated) { - return@apply - } + internal class Deserializer : BaseDeserializer(Price::class) { - accept( - object : Visitor { - override fun visitUnit(unit: NewSubscriptionUnitPrice) { - unit.validate() - } + override fun ObjectCodec.deserialize(node: JsonNode): Price { + val json = JsonValue.fromJsonNode(node) + val modelType = json.asObject()?.get("model_type")?.asString() - override fun visitPackage(package_: NewSubscriptionPackagePrice) { - package_.validate() + when (modelType) { + "unit" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(unit = it, _json = json) } ?: Price(_json = json) } - - override fun visitMatrix(matrix: NewSubscriptionMatrixPrice) { - matrix.validate() + "package" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(package_ = it, _json = json) } ?: Price(_json = json) } - - override fun visitTiered(tiered: NewSubscriptionTieredPrice) { - tiered.validate() - } - - override fun visitBulk(bulk: NewSubscriptionBulkPrice) { - bulk.validate() + "matrix" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(matrix = it, _json = json) } ?: Price(_json = json) } - - override fun visitThresholdTotalAmount( - thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice - ) { - thresholdTotalAmount.validate() + "tiered" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(tiered = it, _json = json) } ?: Price(_json = json) } - - override fun visitTieredPackage( - tieredPackage: NewSubscriptionTieredPackagePrice - ) { - tieredPackage.validate() + "bulk" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(bulk = it, _json = json) } ?: Price(_json = json) } - - override fun visitTieredWithMinimum( - tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice - ) { - tieredWithMinimum.validate() + "threshold_total_amount" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(thresholdTotalAmount = it, _json = json) } + ?: Price(_json = json) } - - override fun visitUnitWithPercent( - unitWithPercent: NewSubscriptionUnitWithPercentPrice - ) { - unitWithPercent.validate() + "tiered_package" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(tieredPackage = it, _json = json) } + ?: Price(_json = json) } - - override fun visitPackageWithAllocation( - packageWithAllocation: NewSubscriptionPackageWithAllocationPrice - ) { - packageWithAllocation.validate() + "tiered_with_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(tieredWithMinimum = it, _json = json) } + ?: Price(_json = json) } - - override fun visitTieredWithProration( - tieredWithProration: NewSubscriptionTierWithProrationPrice - ) { - tieredWithProration.validate() + "unit_with_percent" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(unitWithPercent = it, _json = json) } + ?: Price(_json = json) } - - override fun visitUnitWithProration( - unitWithProration: NewSubscriptionUnitWithProrationPrice - ) { - unitWithProration.validate() + "package_with_allocation" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(packageWithAllocation = it, _json = json) } + ?: Price(_json = json) } - - override fun visitGroupedAllocation( - groupedAllocation: NewSubscriptionGroupedAllocationPrice - ) { - groupedAllocation.validate() + "tiered_with_proration" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(tieredWithProration = it, _json = json) } + ?: Price(_json = json) } - - override fun visitGroupedWithProratedMinimum( - groupedWithProratedMinimum: - NewSubscriptionGroupedWithProratedMinimumPrice - ) { - groupedWithProratedMinimum.validate() + "unit_with_proration" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(unitWithProration = it, _json = json) } + ?: Price(_json = json) } - - override fun visitBulkWithProration( - bulkWithProration: NewSubscriptionBulkWithProrationPrice - ) { - bulkWithProration.validate() + "grouped_allocation" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedAllocation = it, _json = json) } + ?: Price(_json = json) } - - override fun visitScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: - NewSubscriptionScalableMatrixWithUnitPricingPrice - ) { - scalableMatrixWithUnitPricing.validate() + "grouped_with_prorated_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedWithProratedMinimum = it, _json = json) } + ?: Price(_json = json) } - - override fun visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: - NewSubscriptionScalableMatrixWithTieredPricingPrice - ) { - scalableMatrixWithTieredPricing.validate() + "bulk_with_proration" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(bulkWithProration = it, _json = json) } + ?: Price(_json = json) } - - override fun visitCumulativeGroupedBulk( - cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice - ) { - cumulativeGroupedBulk.validate() + "scalable_matrix_with_unit_pricing" -> { + return tryDeserialize( + node, + jacksonTypeRef< + NewSubscriptionScalableMatrixWithUnitPricingPrice + >(), + ) + ?.let { Price(scalableMatrixWithUnitPricing = it, _json = json) } + ?: Price(_json = json) } - - override fun visitMaxGroupTieredPackage( - maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice - ) { - maxGroupTieredPackage.validate() + "scalable_matrix_with_tiered_pricing" -> { + return tryDeserialize( + node, + jacksonTypeRef< + NewSubscriptionScalableMatrixWithTieredPricingPrice + >(), + ) + ?.let { Price(scalableMatrixWithTieredPricing = it, _json = json) } + ?: Price(_json = json) } - - override fun visitGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice - ) { - groupedWithMeteredMinimum.validate() + "cumulative_grouped_bulk" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(cumulativeGroupedBulk = it, _json = json) } + ?: Price(_json = json) } - - override fun visitMatrixWithDisplayName( - matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice - ) { - matrixWithDisplayName.validate() + "max_group_tiered_package" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(maxGroupTieredPackage = it, _json = json) } + ?: Price(_json = json) } - - override fun visitGroupedTieredPackage( - groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice - ) { - groupedTieredPackage.validate() + "grouped_with_metered_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedWithMeteredMinimum = it, _json = json) } + ?: Price(_json = json) } - - override fun visitMatrixWithAllocation( - matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice - ) { - matrixWithAllocation.validate() + "matrix_with_display_name" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(matrixWithDisplayName = it, _json = json) } + ?: Price(_json = json) } - - override fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice - ) { - tieredPackageWithMinimum.validate() + "grouped_tiered_package" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedTieredPackage = it, _json = json) } + ?: Price(_json = json) } - - override fun visitGroupedTiered( - groupedTiered: NewSubscriptionGroupedTieredPrice - ) { - groupedTiered.validate() + "matrix_with_allocation" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(matrixWithAllocation = it, _json = json) } + ?: Price(_json = json) } - - override fun visitGroupedWithMinMaxThresholds( - groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds - ) { - groupedWithMinMaxThresholds.validate() - } - - override fun visitMinimum(minimum: Minimum) { - minimum.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: NewSubscriptionUnitPrice) = unit.validity() - - override fun visitPackage(package_: NewSubscriptionPackagePrice) = - package_.validity() - - override fun visitMatrix(matrix: NewSubscriptionMatrixPrice) = - matrix.validity() - - override fun visitTiered(tiered: NewSubscriptionTieredPrice) = - tiered.validity() - - override fun visitBulk(bulk: NewSubscriptionBulkPrice) = bulk.validity() - - override fun visitThresholdTotalAmount( - thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice - ) = thresholdTotalAmount.validity() - - override fun visitTieredPackage( - tieredPackage: NewSubscriptionTieredPackagePrice - ) = tieredPackage.validity() - - override fun visitTieredWithMinimum( - tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice - ) = tieredWithMinimum.validity() - - override fun visitUnitWithPercent( - unitWithPercent: NewSubscriptionUnitWithPercentPrice - ) = unitWithPercent.validity() - - override fun visitPackageWithAllocation( - packageWithAllocation: NewSubscriptionPackageWithAllocationPrice - ) = packageWithAllocation.validity() - - override fun visitTieredWithProration( - tieredWithProration: NewSubscriptionTierWithProrationPrice - ) = tieredWithProration.validity() - - override fun visitUnitWithProration( - unitWithProration: NewSubscriptionUnitWithProrationPrice - ) = unitWithProration.validity() - - override fun visitGroupedAllocation( - groupedAllocation: NewSubscriptionGroupedAllocationPrice - ) = groupedAllocation.validity() - - override fun visitGroupedWithProratedMinimum( - groupedWithProratedMinimum: - NewSubscriptionGroupedWithProratedMinimumPrice - ) = groupedWithProratedMinimum.validity() - - override fun visitBulkWithProration( - bulkWithProration: NewSubscriptionBulkWithProrationPrice - ) = bulkWithProration.validity() - - override fun visitScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: - NewSubscriptionScalableMatrixWithUnitPricingPrice - ) = scalableMatrixWithUnitPricing.validity() - - override fun visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: - NewSubscriptionScalableMatrixWithTieredPricingPrice - ) = scalableMatrixWithTieredPricing.validity() - - override fun visitCumulativeGroupedBulk( - cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice - ) = cumulativeGroupedBulk.validity() - - override fun visitMaxGroupTieredPackage( - maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice - ) = maxGroupTieredPackage.validity() - - override fun visitGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice - ) = groupedWithMeteredMinimum.validity() - - override fun visitMatrixWithDisplayName( - matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice - ) = matrixWithDisplayName.validity() - - override fun visitGroupedTieredPackage( - groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice - ) = groupedTieredPackage.validity() - - override fun visitMatrixWithAllocation( - matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice - ) = matrixWithAllocation.validity() - - override fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice - ) = tieredPackageWithMinimum.validity() - - override fun visitGroupedTiered( - groupedTiered: NewSubscriptionGroupedTieredPrice - ) = groupedTiered.validity() - - override fun visitGroupedWithMinMaxThresholds( - groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds - ) = groupedWithMinMaxThresholds.validity() - - override fun visitMinimum(minimum: Minimum) = minimum.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Price && - unit == other.unit && - package_ == other.package_ && - matrix == other.matrix && - tiered == other.tiered && - bulk == other.bulk && - thresholdTotalAmount == other.thresholdTotalAmount && - tieredPackage == other.tieredPackage && - tieredWithMinimum == other.tieredWithMinimum && - unitWithPercent == other.unitWithPercent && - packageWithAllocation == other.packageWithAllocation && - tieredWithProration == other.tieredWithProration && - unitWithProration == other.unitWithProration && - groupedAllocation == other.groupedAllocation && - groupedWithProratedMinimum == other.groupedWithProratedMinimum && - bulkWithProration == other.bulkWithProration && - scalableMatrixWithUnitPricing == other.scalableMatrixWithUnitPricing && - scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && - cumulativeGroupedBulk == other.cumulativeGroupedBulk && - maxGroupTieredPackage == other.maxGroupTieredPackage && - groupedWithMeteredMinimum == other.groupedWithMeteredMinimum && - matrixWithDisplayName == other.matrixWithDisplayName && - groupedTieredPackage == other.groupedTieredPackage && - matrixWithAllocation == other.matrixWithAllocation && - tieredPackageWithMinimum == other.tieredPackageWithMinimum && - groupedTiered == other.groupedTiered && - groupedWithMinMaxThresholds == other.groupedWithMinMaxThresholds && - minimum == other.minimum - } - - override fun hashCode(): Int = - Objects.hash( - unit, - package_, - matrix, - tiered, - bulk, - thresholdTotalAmount, - tieredPackage, - tieredWithMinimum, - unitWithPercent, - packageWithAllocation, - tieredWithProration, - unitWithProration, - groupedAllocation, - groupedWithProratedMinimum, - bulkWithProration, - scalableMatrixWithUnitPricing, - scalableMatrixWithTieredPricing, - cumulativeGroupedBulk, - maxGroupTieredPackage, - groupedWithMeteredMinimum, - matrixWithDisplayName, - groupedTieredPackage, - matrixWithAllocation, - tieredPackageWithMinimum, - groupedTiered, - groupedWithMinMaxThresholds, - minimum, - ) - - override fun toString(): String = - when { - unit != null -> "Price{unit=$unit}" - package_ != null -> "Price{package_=$package_}" - matrix != null -> "Price{matrix=$matrix}" - tiered != null -> "Price{tiered=$tiered}" - bulk != null -> "Price{bulk=$bulk}" - thresholdTotalAmount != null -> - "Price{thresholdTotalAmount=$thresholdTotalAmount}" - tieredPackage != null -> "Price{tieredPackage=$tieredPackage}" - tieredWithMinimum != null -> "Price{tieredWithMinimum=$tieredWithMinimum}" - unitWithPercent != null -> "Price{unitWithPercent=$unitWithPercent}" - packageWithAllocation != null -> - "Price{packageWithAllocation=$packageWithAllocation}" - tieredWithProration != null -> "Price{tieredWithProration=$tieredWithProration}" - unitWithProration != null -> "Price{unitWithProration=$unitWithProration}" - groupedAllocation != null -> "Price{groupedAllocation=$groupedAllocation}" - groupedWithProratedMinimum != null -> - "Price{groupedWithProratedMinimum=$groupedWithProratedMinimum}" - bulkWithProration != null -> "Price{bulkWithProration=$bulkWithProration}" - scalableMatrixWithUnitPricing != null -> - "Price{scalableMatrixWithUnitPricing=$scalableMatrixWithUnitPricing}" - scalableMatrixWithTieredPricing != null -> - "Price{scalableMatrixWithTieredPricing=$scalableMatrixWithTieredPricing}" - cumulativeGroupedBulk != null -> - "Price{cumulativeGroupedBulk=$cumulativeGroupedBulk}" - maxGroupTieredPackage != null -> - "Price{maxGroupTieredPackage=$maxGroupTieredPackage}" - groupedWithMeteredMinimum != null -> - "Price{groupedWithMeteredMinimum=$groupedWithMeteredMinimum}" - matrixWithDisplayName != null -> - "Price{matrixWithDisplayName=$matrixWithDisplayName}" - groupedTieredPackage != null -> - "Price{groupedTieredPackage=$groupedTieredPackage}" - matrixWithAllocation != null -> - "Price{matrixWithAllocation=$matrixWithAllocation}" - tieredPackageWithMinimum != null -> - "Price{tieredPackageWithMinimum=$tieredPackageWithMinimum}" - groupedTiered != null -> "Price{groupedTiered=$groupedTiered}" - groupedWithMinMaxThresholds != null -> - "Price{groupedWithMinMaxThresholds=$groupedWithMinMaxThresholds}" - minimum != null -> "Price{minimum=$minimum}" - _json != null -> "Price{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Price") - } - - companion object { - - fun ofUnit(unit: NewSubscriptionUnitPrice) = Price(unit = unit) - - fun ofPackage(package_: NewSubscriptionPackagePrice) = Price(package_ = package_) - - fun ofMatrix(matrix: NewSubscriptionMatrixPrice) = Price(matrix = matrix) - - fun ofTiered(tiered: NewSubscriptionTieredPrice) = Price(tiered = tiered) - - fun ofBulk(bulk: NewSubscriptionBulkPrice) = Price(bulk = bulk) - - fun ofThresholdTotalAmount( - thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice - ) = Price(thresholdTotalAmount = thresholdTotalAmount) - - fun ofTieredPackage(tieredPackage: NewSubscriptionTieredPackagePrice) = - Price(tieredPackage = tieredPackage) - - fun ofTieredWithMinimum(tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice) = - Price(tieredWithMinimum = tieredWithMinimum) - - fun ofUnitWithPercent(unitWithPercent: NewSubscriptionUnitWithPercentPrice) = - Price(unitWithPercent = unitWithPercent) - - fun ofPackageWithAllocation( - packageWithAllocation: NewSubscriptionPackageWithAllocationPrice - ) = Price(packageWithAllocation = packageWithAllocation) - - fun ofTieredWithProration( - tieredWithProration: NewSubscriptionTierWithProrationPrice - ) = Price(tieredWithProration = tieredWithProration) - - fun ofUnitWithProration(unitWithProration: NewSubscriptionUnitWithProrationPrice) = - Price(unitWithProration = unitWithProration) - - fun ofGroupedAllocation(groupedAllocation: NewSubscriptionGroupedAllocationPrice) = - Price(groupedAllocation = groupedAllocation) - - fun ofGroupedWithProratedMinimum( - groupedWithProratedMinimum: NewSubscriptionGroupedWithProratedMinimumPrice - ) = Price(groupedWithProratedMinimum = groupedWithProratedMinimum) - - fun ofBulkWithProration(bulkWithProration: NewSubscriptionBulkWithProrationPrice) = - Price(bulkWithProration = bulkWithProration) - - fun ofScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: NewSubscriptionScalableMatrixWithUnitPricingPrice - ) = Price(scalableMatrixWithUnitPricing = scalableMatrixWithUnitPricing) - - fun ofScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: - NewSubscriptionScalableMatrixWithTieredPricingPrice - ) = Price(scalableMatrixWithTieredPricing = scalableMatrixWithTieredPricing) - - fun ofCumulativeGroupedBulk( - cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice - ) = Price(cumulativeGroupedBulk = cumulativeGroupedBulk) - - fun ofMaxGroupTieredPackage( - maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice - ) = Price(maxGroupTieredPackage = maxGroupTieredPackage) - - fun ofGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice - ) = Price(groupedWithMeteredMinimum = groupedWithMeteredMinimum) - - fun ofMatrixWithDisplayName( - matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice - ) = Price(matrixWithDisplayName = matrixWithDisplayName) - - fun ofGroupedTieredPackage( - groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice - ) = Price(groupedTieredPackage = groupedTieredPackage) - - fun ofMatrixWithAllocation( - matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice - ) = Price(matrixWithAllocation = matrixWithAllocation) - - fun ofTieredPackageWithMinimum( - tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice - ) = Price(tieredPackageWithMinimum = tieredPackageWithMinimum) - - fun ofGroupedTiered(groupedTiered: NewSubscriptionGroupedTieredPrice) = - Price(groupedTiered = groupedTiered) - - fun ofGroupedWithMinMaxThresholds( - groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds - ) = Price(groupedWithMinMaxThresholds = groupedWithMinMaxThresholds) - - fun ofMinimum(minimum: Minimum) = Price(minimum = minimum) - } - - /** - * An interface that defines how to map each variant of [Price] to a value of type [T]. - */ - interface Visitor { - - fun visitUnit(unit: NewSubscriptionUnitPrice): T - - fun visitPackage(package_: NewSubscriptionPackagePrice): T - - fun visitMatrix(matrix: NewSubscriptionMatrixPrice): T - - fun visitTiered(tiered: NewSubscriptionTieredPrice): T - - fun visitBulk(bulk: NewSubscriptionBulkPrice): T - - fun visitThresholdTotalAmount( - thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice - ): T - - fun visitTieredPackage(tieredPackage: NewSubscriptionTieredPackagePrice): T - - fun visitTieredWithMinimum( - tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice - ): T - - fun visitUnitWithPercent(unitWithPercent: NewSubscriptionUnitWithPercentPrice): T - - fun visitPackageWithAllocation( - packageWithAllocation: NewSubscriptionPackageWithAllocationPrice - ): T - - fun visitTieredWithProration( - tieredWithProration: NewSubscriptionTierWithProrationPrice - ): T - - fun visitUnitWithProration( - unitWithProration: NewSubscriptionUnitWithProrationPrice - ): T - - fun visitGroupedAllocation( - groupedAllocation: NewSubscriptionGroupedAllocationPrice - ): T - - fun visitGroupedWithProratedMinimum( - groupedWithProratedMinimum: NewSubscriptionGroupedWithProratedMinimumPrice - ): T - - fun visitBulkWithProration( - bulkWithProration: NewSubscriptionBulkWithProrationPrice - ): T - - fun visitScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: NewSubscriptionScalableMatrixWithUnitPricingPrice - ): T - - fun visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: - NewSubscriptionScalableMatrixWithTieredPricingPrice - ): T - - fun visitCumulativeGroupedBulk( - cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice - ): T - - fun visitMaxGroupTieredPackage( - maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice - ): T - - fun visitGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice - ): T - - fun visitMatrixWithDisplayName( - matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice - ): T - - fun visitGroupedTieredPackage( - groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice - ): T - - fun visitMatrixWithAllocation( - matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice - ): T - - fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice - ): T - - fun visitGroupedTiered(groupedTiered: NewSubscriptionGroupedTieredPrice): T - - fun visitGroupedWithMinMaxThresholds( - groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds - ): T - - fun visitMinimum(minimum: Minimum): T - - /** - * Maps an unknown variant of [Price] to a value of type [T]. - * - * An instance of [Price] can contain an unknown variant if it was deserialized from - * data that doesn't match any known variant. For example, if the SDK is on an older - * version than the API, then the API may respond with new variants that the SDK is - * unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown Price: $json") - } - } - - internal class Deserializer : BaseDeserializer(Price::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): Price { - val json = JsonValue.fromJsonNode(node) - val modelType = json.asObject()?.get("model_type")?.asString() - - when (modelType) { - "unit" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(unit = it, _json = json) } ?: Price(_json = json) - } - "package" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(package_ = it, _json = json) } ?: Price(_json = json) - } - "matrix" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(matrix = it, _json = json) } ?: Price(_json = json) - } - "tiered" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(tiered = it, _json = json) } ?: Price(_json = json) - } - "bulk" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(bulk = it, _json = json) } ?: Price(_json = json) - } - "threshold_total_amount" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(thresholdTotalAmount = it, _json = json) } - ?: Price(_json = json) - } - "tiered_package" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(tieredPackage = it, _json = json) } - ?: Price(_json = json) - } - "tiered_with_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(tieredWithMinimum = it, _json = json) } - ?: Price(_json = json) - } - "unit_with_percent" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(unitWithPercent = it, _json = json) } - ?: Price(_json = json) - } - "package_with_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(packageWithAllocation = it, _json = json) } - ?: Price(_json = json) - } - "tiered_with_proration" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(tieredWithProration = it, _json = json) } - ?: Price(_json = json) - } - "unit_with_proration" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(unitWithProration = it, _json = json) } - ?: Price(_json = json) - } - "grouped_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedAllocation = it, _json = json) } - ?: Price(_json = json) - } - "grouped_with_prorated_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedWithProratedMinimum = it, _json = json) } - ?: Price(_json = json) - } - "bulk_with_proration" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(bulkWithProration = it, _json = json) } - ?: Price(_json = json) - } - "scalable_matrix_with_unit_pricing" -> { - return tryDeserialize( - node, - jacksonTypeRef< - NewSubscriptionScalableMatrixWithUnitPricingPrice - >(), - ) - ?.let { Price(scalableMatrixWithUnitPricing = it, _json = json) } - ?: Price(_json = json) - } - "scalable_matrix_with_tiered_pricing" -> { - return tryDeserialize( - node, - jacksonTypeRef< - NewSubscriptionScalableMatrixWithTieredPricingPrice - >(), - ) - ?.let { Price(scalableMatrixWithTieredPricing = it, _json = json) } - ?: Price(_json = json) - } - "cumulative_grouped_bulk" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(cumulativeGroupedBulk = it, _json = json) } - ?: Price(_json = json) - } - "max_group_tiered_package" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(maxGroupTieredPackage = it, _json = json) } - ?: Price(_json = json) - } - "grouped_with_metered_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedWithMeteredMinimum = it, _json = json) } - ?: Price(_json = json) - } - "matrix_with_display_name" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(matrixWithDisplayName = it, _json = json) } - ?: Price(_json = json) - } - "grouped_tiered_package" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedTieredPackage = it, _json = json) } - ?: Price(_json = json) - } - "matrix_with_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(matrixWithAllocation = it, _json = json) } - ?: Price(_json = json) - } - "tiered_package_with_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(tieredPackageWithMinimum = it, _json = json) } - ?: Price(_json = json) - } - "grouped_tiered" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedTiered = it, _json = json) } - ?: Price(_json = json) - } - "grouped_with_min_max_thresholds" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedWithMinMaxThresholds = it, _json = json) } - ?: Price(_json = json) - } - "minimum" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(minimum = it, _json = json) - } ?: Price(_json = json) - } - } - - return Price(_json = json) - } - } - - internal class Serializer : BaseSerializer(Price::class) { - - override fun serialize( - value: Price, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unit != null -> generator.writeObject(value.unit) - value.package_ != null -> generator.writeObject(value.package_) - value.matrix != null -> generator.writeObject(value.matrix) - value.tiered != null -> generator.writeObject(value.tiered) - value.bulk != null -> generator.writeObject(value.bulk) - value.thresholdTotalAmount != null -> - generator.writeObject(value.thresholdTotalAmount) - value.tieredPackage != null -> generator.writeObject(value.tieredPackage) - value.tieredWithMinimum != null -> - generator.writeObject(value.tieredWithMinimum) - value.unitWithPercent != null -> - generator.writeObject(value.unitWithPercent) - value.packageWithAllocation != null -> - generator.writeObject(value.packageWithAllocation) - value.tieredWithProration != null -> - generator.writeObject(value.tieredWithProration) - value.unitWithProration != null -> - generator.writeObject(value.unitWithProration) - value.groupedAllocation != null -> - generator.writeObject(value.groupedAllocation) - value.groupedWithProratedMinimum != null -> - generator.writeObject(value.groupedWithProratedMinimum) - value.bulkWithProration != null -> - generator.writeObject(value.bulkWithProration) - value.scalableMatrixWithUnitPricing != null -> - generator.writeObject(value.scalableMatrixWithUnitPricing) - value.scalableMatrixWithTieredPricing != null -> - generator.writeObject(value.scalableMatrixWithTieredPricing) - value.cumulativeGroupedBulk != null -> - generator.writeObject(value.cumulativeGroupedBulk) - value.maxGroupTieredPackage != null -> - generator.writeObject(value.maxGroupTieredPackage) - value.groupedWithMeteredMinimum != null -> - generator.writeObject(value.groupedWithMeteredMinimum) - value.matrixWithDisplayName != null -> - generator.writeObject(value.matrixWithDisplayName) - value.groupedTieredPackage != null -> - generator.writeObject(value.groupedTieredPackage) - value.matrixWithAllocation != null -> - generator.writeObject(value.matrixWithAllocation) - value.tieredPackageWithMinimum != null -> - generator.writeObject(value.tieredPackageWithMinimum) - value.groupedTiered != null -> generator.writeObject(value.groupedTiered) - value.groupedWithMinMaxThresholds != null -> - generator.writeObject(value.groupedWithMinMaxThresholds) - value.minimum != null -> generator.writeObject(value.minimum) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Price") - } - } - } - - class GroupedWithMinMaxThresholds - private constructor( - private val cadence: JsonField, - private val groupedWithMinMaxThresholdsConfig: - JsonField, - private val itemId: JsonField, - private val modelType: JsonValue, - private val name: JsonField, - private val billableMetricId: JsonField, - private val billedInAdvance: JsonField, - private val billingCycleConfiguration: JsonField, - private val conversionRate: JsonField, - private val conversionRateConfig: JsonField, - private val currency: JsonField, - private val dimensionalPriceConfiguration: - JsonField, - private val externalPriceId: JsonField, - private val fixedPriceQuantity: JsonField, - private val invoiceGroupingKey: JsonField, - private val invoicingCycleConfiguration: JsonField, - private val metadata: JsonField, - private val referenceId: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("cadence") - @ExcludeMissing - cadence: JsonField = JsonMissing.of(), - @JsonProperty("grouped_with_min_max_thresholds_config") - @ExcludeMissing - groupedWithMinMaxThresholdsConfig: - JsonField = - JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - modelType: JsonValue = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - name: JsonField = JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("conversion_rate_config") - @ExcludeMissing - conversionRateConfig: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - currency: JsonField = JsonMissing.of(), - @JsonProperty("dimensional_price_configuration") - @ExcludeMissing - dimensionalPriceConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - metadata: JsonField = JsonMissing.of(), - @JsonProperty("reference_id") - @ExcludeMissing - referenceId: JsonField = JsonMissing.of(), - ) : this( - cadence, - groupedWithMinMaxThresholdsConfig, - itemId, - modelType, - name, - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - conversionRateConfig, - currency, - dimensionalPriceConfiguration, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - mutableMapOf(), - ) - - /** - * The cadence to bill for this price on. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun groupedWithMinMaxThresholdsConfig(): GroupedWithMinMaxThresholdsConfig = - groupedWithMinMaxThresholdsConfig.getRequired( - "grouped_with_min_max_thresholds_config" - ) - - /** - * The id of the item the price will be associated with. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun itemId(): String = itemId.getRequired("item_id") - - /** - * Expected to always return the following: - * ```kotlin - * JsonValue.from("grouped_with_min_max_thresholds") - * ``` - * - * However, this method can be useful for debugging and logging (e.g. if the server - * responded with an unexpected value). - */ - @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType - - /** - * The name of the price. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun name(): String = name.getRequired("name") - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun billableMetricId(): String? = billableMetricId.getNullable("billable_metric_id") - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun billingCycleConfiguration(): NewBillingCycleConfiguration? = - billingCycleConfiguration.getNullable("billing_cycle_configuration") - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") - - /** - * The configuration for the rate of the price currency to the invoicing currency. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun conversionRateConfig(): ConversionRateConfig? = - conversionRateConfig.getNullable("conversion_rate_config") - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun currency(): String? = currency.getNullable("currency") - - /** - * For dimensional price: specifies a price group and dimension values - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = - dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") - - /** - * An alias for the price. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun fixedPriceQuantity(): Double? = - fixedPriceQuantity.getNullable("fixed_price_quantity") - - /** - * The property used to group this price on an invoice - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun invoiceGroupingKey(): String? = - invoiceGroupingKey.getNullable("invoice_grouping_key") - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun metadata(): Metadata? = metadata.getNullable("metadata") - - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun referenceId(): String? = referenceId.getNullable("reference_id") - - /** - * Returns the raw JSON value of [cadence]. - * - * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("cadence") - @ExcludeMissing - fun _cadence(): JsonField = cadence - - /** - * Returns the raw JSON value of [groupedWithMinMaxThresholdsConfig]. - * - * Unlike [groupedWithMinMaxThresholdsConfig], this method doesn't throw if the JSON - * field has an unexpected type. - */ - @JsonProperty("grouped_with_min_max_thresholds_config") - @ExcludeMissing - fun _groupedWithMinMaxThresholdsConfig(): - JsonField = groupedWithMinMaxThresholdsConfig - - /** - * Returns the raw JSON value of [itemId]. - * - * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - /** - * Returns the raw JSON value of [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - /** - * Returns the raw JSON value of [billableMetricId]. - * - * Unlike [billableMetricId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = billableMetricId - - /** - * Returns the raw JSON value of [billedInAdvance]. - * - * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance - - /** - * Returns the raw JSON value of [billingCycleConfiguration]. - * - * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** - * Returns the raw JSON value of [conversionRate]. - * - * Unlike [conversionRate], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** - * Returns the raw JSON value of [conversionRateConfig]. - * - * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("conversion_rate_config") - @ExcludeMissing - fun _conversionRateConfig(): JsonField = conversionRateConfig - - /** - * Returns the raw JSON value of [currency]. - * - * Unlike [currency], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("currency") - @ExcludeMissing - fun _currency(): JsonField = currency - - /** - * Returns the raw JSON value of [dimensionalPriceConfiguration]. - * - * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON - * field has an unexpected type. - */ - @JsonProperty("dimensional_price_configuration") - @ExcludeMissing - fun _dimensionalPriceConfiguration(): JsonField = - dimensionalPriceConfiguration - - /** - * Returns the raw JSON value of [externalPriceId]. - * - * Unlike [externalPriceId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * Returns the raw JSON value of [fixedPriceQuantity]. - * - * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** - * Returns the raw JSON value of [invoiceGroupingKey]. - * - * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Returns the raw JSON value of [invoicingCycleConfiguration]. - * - * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * Returns the raw JSON value of [metadata]. - * - * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - /** - * Returns the raw JSON value of [referenceId]. - * - * Unlike [referenceId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("reference_id") - @ExcludeMissing - fun _referenceId(): JsonField = referenceId - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [GroupedWithMinMaxThresholds]. - * - * The following fields are required: - * ```kotlin - * .cadence() - * .groupedWithMinMaxThresholdsConfig() - * .itemId() - * .name() - * ``` - */ - fun builder() = Builder() - } - - /** A builder for [GroupedWithMinMaxThresholds]. */ - class Builder internal constructor() { - - private var cadence: JsonField? = null - private var groupedWithMinMaxThresholdsConfig: - JsonField? = - null - private var itemId: JsonField? = null - private var modelType: JsonValue = - JsonValue.from("grouped_with_min_max_thresholds") - private var name: JsonField? = null - private var billableMetricId: JsonField = JsonMissing.of() - private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var conversionRateConfig: JsonField = - JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var dimensionalPriceConfiguration: - JsonField = - JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: - JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var referenceId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds) = - apply { - cadence = groupedWithMinMaxThresholds.cadence - groupedWithMinMaxThresholdsConfig = - groupedWithMinMaxThresholds.groupedWithMinMaxThresholdsConfig - itemId = groupedWithMinMaxThresholds.itemId - modelType = groupedWithMinMaxThresholds.modelType - name = groupedWithMinMaxThresholds.name - billableMetricId = groupedWithMinMaxThresholds.billableMetricId - billedInAdvance = groupedWithMinMaxThresholds.billedInAdvance - billingCycleConfiguration = - groupedWithMinMaxThresholds.billingCycleConfiguration - conversionRate = groupedWithMinMaxThresholds.conversionRate - conversionRateConfig = groupedWithMinMaxThresholds.conversionRateConfig - currency = groupedWithMinMaxThresholds.currency - dimensionalPriceConfiguration = - groupedWithMinMaxThresholds.dimensionalPriceConfiguration - externalPriceId = groupedWithMinMaxThresholds.externalPriceId - fixedPriceQuantity = groupedWithMinMaxThresholds.fixedPriceQuantity - invoiceGroupingKey = groupedWithMinMaxThresholds.invoiceGroupingKey - invoicingCycleConfiguration = - groupedWithMinMaxThresholds.invoicingCycleConfiguration - metadata = groupedWithMinMaxThresholds.metadata - referenceId = groupedWithMinMaxThresholds.referenceId - additionalProperties = - groupedWithMinMaxThresholds.additionalProperties.toMutableMap() - } - - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** - * Sets [Builder.cadence] to an arbitrary JSON value. - * - * You should usually call [Builder.cadence] with a well-typed [Cadence] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - - fun groupedWithMinMaxThresholdsConfig( - groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig - ) = - groupedWithMinMaxThresholdsConfig( - JsonField.of(groupedWithMinMaxThresholdsConfig) - ) - - /** - * Sets [Builder.groupedWithMinMaxThresholdsConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.groupedWithMinMaxThresholdsConfig] with a - * well-typed [GroupedWithMinMaxThresholdsConfig] value instead. This method is - * primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun groupedWithMinMaxThresholdsConfig( - groupedWithMinMaxThresholdsConfig: - JsonField - ) = apply { - this.groupedWithMinMaxThresholdsConfig = groupedWithMinMaxThresholdsConfig - } - - /** The id of the item the price will be associated with. */ - fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - - /** - * Sets [Builder.itemId] to an arbitrary JSON value. - * - * You should usually call [Builder.itemId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - /** - * Sets the field to an arbitrary JSON value. - * - * It is usually unnecessary to call this method because the field defaults to - * the following: - * ```kotlin - * JsonValue.from("grouped_with_min_max_thresholds") - * ``` - * - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } - - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) - - /** - * Sets [Builder.name] to an arbitrary JSON value. - * - * You should usually call [Builder.name] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun name(name: JsonField) = apply { this.name = name } - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: String?) = - billableMetricId(JsonField.ofNullable(billableMetricId)) - - /** - * Sets [Builder.billableMetricId] to an arbitrary JSON value. - * - * You should usually call [Builder.billableMetricId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun billableMetricId(billableMetricId: JsonField) = apply { - this.billableMetricId = billableMetricId - } - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if - * this is true, and in-arrears if this is false. - */ - fun billedInAdvance(billedInAdvance: Boolean?) = - billedInAdvance(JsonField.ofNullable(billedInAdvance)) - - /** - * Alias for [Builder.billedInAdvance]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun billedInAdvance(billedInAdvance: Boolean) = - billedInAdvance(billedInAdvance as Boolean?) - - /** - * Sets [Builder.billedInAdvance] to an arbitrary JSON value. - * - * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun billedInAdvance(billedInAdvance: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: NewBillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - - /** - * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.billingCycleConfiguration] with a well-typed - * [NewBillingCycleConfiguration] value instead. This method is primarily for - * setting the field to an undocumented or not yet supported value. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: JsonField - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: Double?) = - conversionRate(JsonField.ofNullable(conversionRate)) - - /** - * Alias for [Builder.conversionRate]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) - - /** - * Sets [Builder.conversionRate] to an arbitrary JSON value. - * - * You should usually call [Builder.conversionRate] with a well-typed [Double] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** - * The configuration for the rate of the price currency to the invoicing - * currency. - */ - fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = - conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) - - /** - * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.conversionRateConfig] with a well-typed - * [ConversionRateConfig] value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun conversionRateConfig( - conversionRateConfig: JsonField - ) = apply { this.conversionRateConfig = conversionRateConfig } - - /** - * Alias for calling [conversionRateConfig] with - * `ConversionRateConfig.ofUnit(unit)`. - */ - fun conversionRateConfig(unit: UnitConversionRateConfig) = - conversionRateConfig(ConversionRateConfig.ofUnit(unit)) - - /** - * Alias for calling [conversionRateConfig] with the following: - * ```kotlin - * UnitConversionRateConfig.builder() - * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) - * .unitConfig(unitConfig) - * .build() - * ``` - */ - fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = - conversionRateConfig( - UnitConversionRateConfig.builder() - .conversionRateType( - UnitConversionRateConfig.ConversionRateType.UNIT - ) - .unitConfig(unitConfig) - .build() - ) - - /** - * Alias for calling [conversionRateConfig] with - * `ConversionRateConfig.ofTiered(tiered)`. - */ - fun conversionRateConfig(tiered: TieredConversionRateConfig) = - conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) - - /** - * Alias for calling [conversionRateConfig] with the following: - * ```kotlin - * TieredConversionRateConfig.builder() - * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) - * .tieredConfig(tieredConfig) - * .build() - * ``` - */ - fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = - conversionRateConfig( - TieredConversionRateConfig.builder() - .conversionRateType( - TieredConversionRateConfig.ConversionRateType.TIERED - ) - .tieredConfig(tieredConfig) - .build() - ) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) - - /** - * Sets [Builder.currency] to an arbitrary JSON value. - * - * You should usually call [Builder.currency] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } - - /** For dimensional price: specifies a price group and dimension values */ - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? - ) = - dimensionalPriceConfiguration( - JsonField.ofNullable(dimensionalPriceConfiguration) - ) - - /** - * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.dimensionalPriceConfiguration] with a - * well-typed [NewDimensionalPriceConfiguration] value instead. This method is - * primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: JsonField - ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** - * Sets [Builder.externalPriceId] to an arbitrary JSON value. - * - * You should usually call [Builder.externalPriceId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun externalPriceId(externalPriceId: JsonField) = apply { - this.externalPriceId = externalPriceId - } - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = - fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) - - /** - * Alias for [Builder.fixedPriceQuantity]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. - * - * You should usually call [Builder.fixedPriceQuantity] with a well-typed - * [Double] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = - invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) - - /** - * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. - * - * You should usually call [Builder.invoiceGroupingKey] with a well-typed - * [String] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { - this.invoiceGroupingKey = invoiceGroupingKey - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are - * produced. If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: NewBillingCycleConfiguration? - ) = - invoicingCycleConfiguration( - JsonField.ofNullable(invoicingCycleConfiguration) - ) - - /** - * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.invoicingCycleConfiguration] with a - * well-typed [NewBillingCycleConfiguration] value instead. This method is - * primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * Sets [Builder.metadata] to an arbitrary JSON value. - * - * You should usually call [Builder.metadata] with a well-typed [Metadata] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - fun referenceId(referenceId: String?) = - referenceId(JsonField.ofNullable(referenceId)) - - /** - * Sets [Builder.referenceId] to an arbitrary JSON value. - * - * You should usually call [Builder.referenceId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun referenceId(referenceId: JsonField) = apply { - this.referenceId = referenceId - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [GroupedWithMinMaxThresholds]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```kotlin - * .cadence() - * .groupedWithMinMaxThresholdsConfig() - * .itemId() - * .name() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): GroupedWithMinMaxThresholds = - GroupedWithMinMaxThresholds( - checkRequired("cadence", cadence), - checkRequired( - "groupedWithMinMaxThresholdsConfig", - groupedWithMinMaxThresholdsConfig, - ), - checkRequired("itemId", itemId), - modelType, - checkRequired("name", name), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - conversionRateConfig, - currency, - dimensionalPriceConfiguration, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): GroupedWithMinMaxThresholds = apply { - if (validated) { - return@apply - } - - cadence().validate() - groupedWithMinMaxThresholdsConfig().validate() - itemId() - _modelType().let { - if (it != JsonValue.from("grouped_with_min_max_thresholds")) { - throw OrbInvalidDataException("'modelType' is invalid, received $it") - } - } - name() - billableMetricId() - billedInAdvance() - billingCycleConfiguration()?.validate() - conversionRate() - conversionRateConfig()?.validate() - currency() - dimensionalPriceConfiguration()?.validate() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration()?.validate() - metadata()?.validate() - referenceId() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (cadence.asKnown()?.validity() ?: 0) + - (groupedWithMinMaxThresholdsConfig.asKnown()?.validity() ?: 0) + - (if (itemId.asKnown() == null) 0 else 1) + - modelType.let { - if (it == JsonValue.from("grouped_with_min_max_thresholds")) 1 else 0 - } + - (if (name.asKnown() == null) 0 else 1) + - (if (billableMetricId.asKnown() == null) 0 else 1) + - (if (billedInAdvance.asKnown() == null) 0 else 1) + - (billingCycleConfiguration.asKnown()?.validity() ?: 0) + - (if (conversionRate.asKnown() == null) 0 else 1) + - (conversionRateConfig.asKnown()?.validity() ?: 0) + - (if (currency.asKnown() == null) 0 else 1) + - (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + - (if (externalPriceId.asKnown() == null) 0 else 1) + - (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + - (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + - (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + - (metadata.asKnown()?.validity() ?: 0) + - (if (referenceId.asKnown() == null) 0 else 1) - - /** The cadence to bill for this price on. */ - class Cadence - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - val ANNUAL = of("annual") - - val SEMI_ANNUAL = of("semi_annual") - - val MONTHLY = of("monthly") - - val QUARTERLY = of("quarterly") - - val ONE_TIME = of("one_time") - - val CUSTOM = of("custom") - - fun of(value: String) = Cadence(JsonField.of(value)) - } - - /** An enum containing [Cadence]'s known values. */ - enum class Known { - ANNUAL, - SEMI_ANNUAL, - MONTHLY, - QUARTERLY, - ONE_TIME, - CUSTOM, - } - - /** - * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Cadence] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - ANNUAL, - SEMI_ANNUAL, - MONTHLY, - QUARTERLY, - ONE_TIME, - CUSTOM, - /** - * An enum member indicating that [Cadence] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - ANNUAL -> Value.ANNUAL - SEMI_ANNUAL -> Value.SEMI_ANNUAL - MONTHLY -> Value.MONTHLY - QUARTERLY -> Value.QUARTERLY - ONE_TIME -> Value.ONE_TIME - CUSTOM -> Value.CUSTOM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - ANNUAL -> Known.ANNUAL - SEMI_ANNUAL -> Known.SEMI_ANNUAL - MONTHLY -> Known.MONTHLY - QUARTERLY -> Known.QUARTERLY - ONE_TIME -> Known.ONE_TIME - CUSTOM -> Known.CUSTOM - else -> throw OrbInvalidDataException("Unknown Cadence: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString() - ?: throw OrbInvalidDataException("Value is not a String") - - private var validated: Boolean = false - - fun validate(): Cadence = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Cadence && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class GroupedWithMinMaxThresholdsConfig - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [GroupedWithMinMaxThresholdsConfig]. - */ - fun builder() = Builder() - } - - /** A builder for [GroupedWithMinMaxThresholdsConfig]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = - mutableMapOf() - - internal fun from( - groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig - ) = apply { - additionalProperties = - groupedWithMinMaxThresholdsConfig.additionalProperties - .toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [GroupedWithMinMaxThresholdsConfig]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): GroupedWithMinMaxThresholdsConfig = - GroupedWithMinMaxThresholdsConfig(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): GroupedWithMinMaxThresholdsConfig = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - additionalProperties.count { (_, value) -> - !value.isNull() && !value.isMissing() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is GroupedWithMinMaxThresholdsConfig && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "GroupedWithMinMaxThresholdsConfig{additionalProperties=$additionalProperties}" - } - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - class Metadata - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Metadata]. */ - fun builder() = Builder() - } - - /** A builder for [Metadata]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = - mutableMapOf() - - internal fun from(metadata: Metadata) = apply { - additionalProperties = metadata.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Metadata]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false + "tiered_package_with_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(tieredPackageWithMinimum = it, _json = json) } + ?: Price(_json = json) } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - additionalProperties.count { (_, value) -> - !value.isNull() && !value.isMissing() + "grouped_tiered" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedTiered = it, _json = json) } + ?: Price(_json = json) } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + "grouped_with_min_max_thresholds" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedWithMinMaxThresholds = it, _json = json) } + ?: Price(_json = json) } - - return other is Metadata && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is GroupedWithMinMaxThresholds && - cadence == other.cadence && - groupedWithMinMaxThresholdsConfig == - other.groupedWithMinMaxThresholdsConfig && - itemId == other.itemId && - modelType == other.modelType && - name == other.name && - billableMetricId == other.billableMetricId && - billedInAdvance == other.billedInAdvance && - billingCycleConfiguration == other.billingCycleConfiguration && - conversionRate == other.conversionRate && - conversionRateConfig == other.conversionRateConfig && - currency == other.currency && - dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && - externalPriceId == other.externalPriceId && - fixedPriceQuantity == other.fixedPriceQuantity && - invoiceGroupingKey == other.invoiceGroupingKey && - invoicingCycleConfiguration == other.invoicingCycleConfiguration && - metadata == other.metadata && - referenceId == other.referenceId && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - cadence, - groupedWithMinMaxThresholdsConfig, - itemId, - modelType, - name, - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - conversionRateConfig, - currency, - dimensionalPriceConfiguration, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - additionalProperties, - ) + "minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(minimum = it, _json = json) } ?: Price(_json = json) + } + } + + return Price(_json = json) } + } - override fun hashCode(): Int = hashCode + internal class Serializer : BaseSerializer(Price::class) { - override fun toString() = - "GroupedWithMinMaxThresholds{cadence=$cadence, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + override fun serialize( + value: Price, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.unit != null -> generator.writeObject(value.unit) + value.package_ != null -> generator.writeObject(value.package_) + value.matrix != null -> generator.writeObject(value.matrix) + value.tiered != null -> generator.writeObject(value.tiered) + value.bulk != null -> generator.writeObject(value.bulk) + value.thresholdTotalAmount != null -> + generator.writeObject(value.thresholdTotalAmount) + value.tieredPackage != null -> generator.writeObject(value.tieredPackage) + value.tieredWithMinimum != null -> + generator.writeObject(value.tieredWithMinimum) + value.unitWithPercent != null -> + generator.writeObject(value.unitWithPercent) + value.packageWithAllocation != null -> + generator.writeObject(value.packageWithAllocation) + value.tieredWithProration != null -> + generator.writeObject(value.tieredWithProration) + value.unitWithProration != null -> + generator.writeObject(value.unitWithProration) + value.groupedAllocation != null -> + generator.writeObject(value.groupedAllocation) + value.groupedWithProratedMinimum != null -> + generator.writeObject(value.groupedWithProratedMinimum) + value.bulkWithProration != null -> + generator.writeObject(value.bulkWithProration) + value.scalableMatrixWithUnitPricing != null -> + generator.writeObject(value.scalableMatrixWithUnitPricing) + value.scalableMatrixWithTieredPricing != null -> + generator.writeObject(value.scalableMatrixWithTieredPricing) + value.cumulativeGroupedBulk != null -> + generator.writeObject(value.cumulativeGroupedBulk) + value.maxGroupTieredPackage != null -> + generator.writeObject(value.maxGroupTieredPackage) + value.groupedWithMeteredMinimum != null -> + generator.writeObject(value.groupedWithMeteredMinimum) + value.matrixWithDisplayName != null -> + generator.writeObject(value.matrixWithDisplayName) + value.groupedTieredPackage != null -> + generator.writeObject(value.groupedTieredPackage) + value.matrixWithAllocation != null -> + generator.writeObject(value.matrixWithAllocation) + value.tieredPackageWithMinimum != null -> + generator.writeObject(value.tieredPackageWithMinimum) + value.groupedTiered != null -> generator.writeObject(value.groupedTiered) + value.groupedWithMinMaxThresholds != null -> + generator.writeObject(value.groupedWithMinMaxThresholds) + value.minimum != null -> generator.writeObject(value.minimum) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Price") + } + } } - class Minimum + class GroupedWithMinMaxThresholds private constructor( private val cadence: JsonField, + private val groupedWithMinMaxThresholdsConfig: + JsonField, private val itemId: JsonField, - private val minimumConfig: JsonField, private val modelType: JsonValue, private val name: JsonField, private val billableMetricId: JsonField, @@ -13140,12 +10106,14 @@ private constructor( @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), + @JsonProperty("grouped_with_min_max_thresholds_config") + @ExcludeMissing + groupedWithMinMaxThresholdsConfig: + JsonField = + JsonMissing.of(), @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), - @JsonProperty("minimum_config") - @ExcludeMissing - minimumConfig: JsonField = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing modelType: JsonValue = JsonMissing.of(), @@ -13196,8 +10164,8 @@ private constructor( referenceId: JsonField = JsonMissing.of(), ) : this( cadence, + groupedWithMinMaxThresholdsConfig, itemId, - minimumConfig, modelType, name, billableMetricId, @@ -13226,25 +10194,28 @@ private constructor( fun cadence(): Cadence = cadence.getRequired("cadence") /** - * The id of the item the price will be associated with. - * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected * value). */ - fun itemId(): String = itemId.getRequired("item_id") + fun groupedWithMinMaxThresholdsConfig(): GroupedWithMinMaxThresholdsConfig = + groupedWithMinMaxThresholdsConfig.getRequired( + "grouped_with_min_max_thresholds_config" + ) /** + * The id of the item the price will be associated with. + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected * value). */ - fun minimumConfig(): MinimumConfig = minimumConfig.getRequired("minimum_config") + fun itemId(): String = itemId.getRequired("item_id") /** * Expected to always return the following: * ```kotlin - * JsonValue.from("minimum") + * JsonValue.from("grouped_with_min_max_thresholds") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -13391,22 +10362,23 @@ private constructor( fun _cadence(): JsonField = cadence /** - * Returns the raw JSON value of [itemId]. + * Returns the raw JSON value of [groupedWithMinMaxThresholdsConfig]. * - * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected - * type. + * Unlike [groupedWithMinMaxThresholdsConfig], this method doesn't throw if the JSON + * field has an unexpected type. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + @JsonProperty("grouped_with_min_max_thresholds_config") + @ExcludeMissing + fun _groupedWithMinMaxThresholdsConfig(): + JsonField = groupedWithMinMaxThresholdsConfig /** - * Returns the raw JSON value of [minimumConfig]. + * Returns the raw JSON value of [itemId]. * - * Unlike [minimumConfig], this method doesn't throw if the JSON field has an - * unexpected type. + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. */ - @JsonProperty("minimum_config") - @ExcludeMissing - fun _minimumConfig(): JsonField = minimumConfig + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId /** * Returns the raw JSON value of [name]. @@ -13564,26 +10536,30 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [Minimum]. + * Returns a mutable builder for constructing an instance of + * [GroupedWithMinMaxThresholds]. * * The following fields are required: * ```kotlin * .cadence() + * .groupedWithMinMaxThresholdsConfig() * .itemId() - * .minimumConfig() * .name() * ``` */ fun builder() = Builder() } - /** A builder for [Minimum]. */ + /** A builder for [GroupedWithMinMaxThresholds]. */ class Builder internal constructor() { private var cadence: JsonField? = null + private var groupedWithMinMaxThresholdsConfig: + JsonField? = + null private var itemId: JsonField? = null - private var minimumConfig: JsonField? = null - private var modelType: JsonValue = JsonValue.from("minimum") + private var modelType: JsonValue = + JsonValue.from("grouped_with_min_max_thresholds") private var name: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() @@ -13606,27 +10582,33 @@ private constructor( private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(minimum: Minimum) = apply { - cadence = minimum.cadence - itemId = minimum.itemId - minimumConfig = minimum.minimumConfig - modelType = minimum.modelType - name = minimum.name - billableMetricId = minimum.billableMetricId - billedInAdvance = minimum.billedInAdvance - billingCycleConfiguration = minimum.billingCycleConfiguration - conversionRate = minimum.conversionRate - conversionRateConfig = minimum.conversionRateConfig - currency = minimum.currency - dimensionalPriceConfiguration = minimum.dimensionalPriceConfiguration - externalPriceId = minimum.externalPriceId - fixedPriceQuantity = minimum.fixedPriceQuantity - invoiceGroupingKey = minimum.invoiceGroupingKey - invoicingCycleConfiguration = minimum.invoicingCycleConfiguration - metadata = minimum.metadata - referenceId = minimum.referenceId - additionalProperties = minimum.additionalProperties.toMutableMap() - } + internal fun from(groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds) = + apply { + cadence = groupedWithMinMaxThresholds.cadence + groupedWithMinMaxThresholdsConfig = + groupedWithMinMaxThresholds.groupedWithMinMaxThresholdsConfig + itemId = groupedWithMinMaxThresholds.itemId + modelType = groupedWithMinMaxThresholds.modelType + name = groupedWithMinMaxThresholds.name + billableMetricId = groupedWithMinMaxThresholds.billableMetricId + billedInAdvance = groupedWithMinMaxThresholds.billedInAdvance + billingCycleConfiguration = + groupedWithMinMaxThresholds.billingCycleConfiguration + conversionRate = groupedWithMinMaxThresholds.conversionRate + conversionRateConfig = groupedWithMinMaxThresholds.conversionRateConfig + currency = groupedWithMinMaxThresholds.currency + dimensionalPriceConfiguration = + groupedWithMinMaxThresholds.dimensionalPriceConfiguration + externalPriceId = groupedWithMinMaxThresholds.externalPriceId + fixedPriceQuantity = groupedWithMinMaxThresholds.fixedPriceQuantity + invoiceGroupingKey = groupedWithMinMaxThresholds.invoiceGroupingKey + invoicingCycleConfiguration = + groupedWithMinMaxThresholds.invoicingCycleConfiguration + metadata = groupedWithMinMaxThresholds.metadata + referenceId = groupedWithMinMaxThresholds.referenceId + additionalProperties = + groupedWithMinMaxThresholds.additionalProperties.toMutableMap() + } /** The cadence to bill for this price on. */ fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) @@ -13640,6 +10622,28 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + fun groupedWithMinMaxThresholdsConfig( + groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + ) = + groupedWithMinMaxThresholdsConfig( + JsonField.of(groupedWithMinMaxThresholdsConfig) + ) + + /** + * Sets [Builder.groupedWithMinMaxThresholdsConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.groupedWithMinMaxThresholdsConfig] with a + * well-typed [GroupedWithMinMaxThresholdsConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun groupedWithMinMaxThresholdsConfig( + groupedWithMinMaxThresholdsConfig: + JsonField + ) = apply { + this.groupedWithMinMaxThresholdsConfig = groupedWithMinMaxThresholdsConfig + } + /** The id of the item the price will be associated with. */ fun itemId(itemId: String) = itemId(JsonField.of(itemId)) @@ -13652,27 +10656,13 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun minimumConfig(minimumConfig: MinimumConfig) = - minimumConfig(JsonField.of(minimumConfig)) - - /** - * Sets [Builder.minimumConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.minimumConfig] with a well-typed - * [MinimumConfig] value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. - */ - fun minimumConfig(minimumConfig: JsonField) = apply { - this.minimumConfig = minimumConfig - } - /** * Sets the field to an arbitrary JSON value. * * It is usually unnecessary to call this method because the field defaults to * the following: * ```kotlin - * JsonValue.from("minimum") + * JsonValue.from("grouped_with_min_max_thresholds") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -14021,25 +11011,28 @@ private constructor( } /** - * Returns an immutable instance of [Minimum]. + * Returns an immutable instance of [GroupedWithMinMaxThresholds]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```kotlin * .cadence() + * .groupedWithMinMaxThresholdsConfig() * .itemId() - * .minimumConfig() * .name() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): Minimum = - Minimum( + fun build(): GroupedWithMinMaxThresholds = + GroupedWithMinMaxThresholds( checkRequired("cadence", cadence), + checkRequired( + "groupedWithMinMaxThresholdsConfig", + groupedWithMinMaxThresholdsConfig, + ), checkRequired("itemId", itemId), - checkRequired("minimumConfig", minimumConfig), modelType, checkRequired("name", name), billableMetricId, @@ -14061,16 +11054,16 @@ private constructor( private var validated: Boolean = false - fun validate(): Minimum = apply { + fun validate(): GroupedWithMinMaxThresholds = apply { if (validated) { return@apply } cadence().validate() + groupedWithMinMaxThresholdsConfig().validate() itemId() - minimumConfig().validate() _modelType().let { - if (it != JsonValue.from("minimum")) { + if (it != JsonValue.from("grouped_with_min_max_thresholds")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } @@ -14107,9 +11100,11 @@ private constructor( */ internal fun validity(): Int = (cadence.asKnown()?.validity() ?: 0) + + (groupedWithMinMaxThresholdsConfig.asKnown()?.validity() ?: 0) + (if (itemId.asKnown() == null) 0 else 1) + - (minimumConfig.asKnown()?.validity() ?: 0) + - modelType.let { if (it == JsonValue.from("minimum")) 1 else 0 } + + modelType.let { + if (it == JsonValue.from("grouped_with_min_max_thresholds")) 1 else 0 + } + (if (name.asKnown() == null) 0 else 1) + (if (billableMetricId.asKnown() == null) 0 else 1) + (if (billedInAdvance.asKnown() == null) 0 else 1) + @@ -14282,70 +11277,16 @@ private constructor( override fun toString() = value.toString() } - class MinimumConfig + class GroupedWithMinMaxThresholdsConfig + @JsonCreator private constructor( - private val minimumAmount: JsonField, - private val prorated: JsonField, - private val additionalProperties: MutableMap, + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map ) { - @JsonCreator - private constructor( - @JsonProperty("minimum_amount") - @ExcludeMissing - minimumAmount: JsonField = JsonMissing.of(), - @JsonProperty("prorated") - @ExcludeMissing - prorated: JsonField = JsonMissing.of(), - ) : this(minimumAmount, prorated, mutableMapOf()) - - /** - * The minimum amount to apply - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") - - /** - * By default, subtotals from minimum composite prices are prorated based on the - * service period. Set to false to disable proration. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun prorated(): Boolean? = prorated.getNullable("prorated") - - /** - * Returns the raw JSON value of [minimumAmount]. - * - * Unlike [minimumAmount], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("minimum_amount") - @ExcludeMissing - fun _minimumAmount(): JsonField = minimumAmount - - /** - * Returns the raw JSON value of [prorated]. - * - * Unlike [prorated], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("prorated") - @ExcludeMissing - fun _prorated(): JsonField = prorated - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + fun _additionalProperties(): Map = additionalProperties fun toBuilder() = Builder().from(this) @@ -14353,67 +11294,23 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [MinimumConfig]. - * - * The following fields are required: - * ```kotlin - * .minimumAmount() - * ``` + * [GroupedWithMinMaxThresholdsConfig]. */ fun builder() = Builder() } - /** A builder for [MinimumConfig]. */ + /** A builder for [GroupedWithMinMaxThresholdsConfig]. */ class Builder internal constructor() { - private var minimumAmount: JsonField? = null - private var prorated: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(minimumConfig: MinimumConfig) = apply { - minimumAmount = minimumConfig.minimumAmount - prorated = minimumConfig.prorated - additionalProperties = minimumConfig.additionalProperties.toMutableMap() - } - - /** The minimum amount to apply */ - fun minimumAmount(minimumAmount: String) = - minimumAmount(JsonField.of(minimumAmount)) - - /** - * Sets [Builder.minimumAmount] to an arbitrary JSON value. - * - * You should usually call [Builder.minimumAmount] with a well-typed - * [String] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun minimumAmount(minimumAmount: JsonField) = apply { - this.minimumAmount = minimumAmount - } - - /** - * By default, subtotals from minimum composite prices are prorated based on - * the service period. Set to false to disable proration. - */ - fun prorated(prorated: Boolean?) = prorated(JsonField.ofNullable(prorated)) - - /** - * Alias for [Builder.prorated]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun prorated(prorated: Boolean) = prorated(prorated as Boolean?) - - /** - * Sets [Builder.prorated] to an arbitrary JSON value. - * - * You should usually call [Builder.prorated] with a well-typed [Boolean] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun prorated(prorated: JsonField) = apply { - this.prorated = prorated + internal fun from( + groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + ) = apply { + additionalProperties = + groupedWithMinMaxThresholdsConfig.additionalProperties + .toMutableMap() } fun additionalProperties(additionalProperties: Map) = @@ -14439,34 +11336,21 @@ private constructor( } /** - * Returns an immutable instance of [MinimumConfig]. + * Returns an immutable instance of [GroupedWithMinMaxThresholdsConfig]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```kotlin - * .minimumAmount() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ - fun build(): MinimumConfig = - MinimumConfig( - checkRequired("minimumAmount", minimumAmount), - prorated, - additionalProperties.toMutableMap(), - ) + fun build(): GroupedWithMinMaxThresholdsConfig = + GroupedWithMinMaxThresholdsConfig(additionalProperties.toImmutable()) } private var validated: Boolean = false - fun validate(): MinimumConfig = apply { + fun validate(): GroupedWithMinMaxThresholdsConfig = apply { if (validated) { return@apply } - minimumAmount() - prorated() validated = true } @@ -14485,28 +11369,25 @@ private constructor( * Used for best match union deserialization. */ internal fun validity(): Int = - (if (minimumAmount.asKnown() == null) 0 else 1) + - (if (prorated.asKnown() == null) 0 else 1) + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is MinimumConfig && - minimumAmount == other.minimumAmount && - prorated == other.prorated && + return other is GroupedWithMinMaxThresholdsConfig && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { - Objects.hash(minimumAmount, prorated, additionalProperties) - } + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "MinimumConfig{minimumAmount=$minimumAmount, prorated=$prorated, additionalProperties=$additionalProperties}" + "GroupedWithMinMaxThresholdsConfig{additionalProperties=$additionalProperties}" } /** @@ -14623,10 +11504,11 @@ private constructor( return true } - return other is Minimum && + return other is GroupedWithMinMaxThresholds && cadence == other.cadence && + groupedWithMinMaxThresholdsConfig == + other.groupedWithMinMaxThresholdsConfig && itemId == other.itemId && - minimumConfig == other.minimumConfig && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && @@ -14648,8 +11530,8 @@ private constructor( private val hashCode: Int by lazy { Objects.hash( cadence, + groupedWithMinMaxThresholdsConfig, itemId, - minimumConfig, modelType, name, billableMetricId, @@ -14672,7 +11554,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Minimum{cadence=$cadence, itemId=$itemId, minimumConfig=$minimumConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "GroupedWithMinMaxThresholds{cadence=$cadence, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } } diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingMinimumCompositePriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingMinimumCompositePriceTest.kt new file mode 100644 index 000000000..9106d3c6e --- /dev/null +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingMinimumCompositePriceTest.kt @@ -0,0 +1,186 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.withorb.api.core.JsonValue +import com.withorb.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class NewFloatingMinimumCompositePriceTest { + + @Test + fun create() { + val newFloatingMinimumCompositePrice = + NewFloatingMinimumCompositePrice.builder() + .cadence(NewFloatingMinimumCompositePrice.Cadence.ANNUAL) + .currency("currency") + .itemId("item_id") + .minimumConfig( + NewFloatingMinimumCompositePrice.MinimumConfig.builder() + .minimumAmount("minimum_amount") + .prorated(true) + .build() + ) + .modelType(NewFloatingMinimumCompositePrice.ModelType.MINIMUM) + .name("Annual fee") + .billableMetricId("billable_metric_id") + .billedInAdvance(true) + .billingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) + .build() + ) + .conversionRate(0.0) + .unitConversionRateConfig( + ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() + ) + .dimensionalPriceConfiguration( + NewDimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .externalDimensionalPriceGroupId("external_dimensional_price_group_id") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoiceGroupingKey("x") + .invoicingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) + .build() + ) + .metadata( + NewFloatingMinimumCompositePrice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .build() + + assertThat(newFloatingMinimumCompositePrice.cadence()) + .isEqualTo(NewFloatingMinimumCompositePrice.Cadence.ANNUAL) + assertThat(newFloatingMinimumCompositePrice.currency()).isEqualTo("currency") + assertThat(newFloatingMinimumCompositePrice.itemId()).isEqualTo("item_id") + assertThat(newFloatingMinimumCompositePrice.minimumConfig()) + .isEqualTo( + NewFloatingMinimumCompositePrice.MinimumConfig.builder() + .minimumAmount("minimum_amount") + .prorated(true) + .build() + ) + assertThat(newFloatingMinimumCompositePrice.modelType()) + .isEqualTo(NewFloatingMinimumCompositePrice.ModelType.MINIMUM) + assertThat(newFloatingMinimumCompositePrice.name()).isEqualTo("Annual fee") + assertThat(newFloatingMinimumCompositePrice.billableMetricId()) + .isEqualTo("billable_metric_id") + assertThat(newFloatingMinimumCompositePrice.billedInAdvance()).isEqualTo(true) + assertThat(newFloatingMinimumCompositePrice.billingCycleConfiguration()) + .isEqualTo( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) + .build() + ) + assertThat(newFloatingMinimumCompositePrice.conversionRate()).isEqualTo(0.0) + assertThat(newFloatingMinimumCompositePrice.conversionRateConfig()) + .isEqualTo( + ConversionRateConfig.ofUnit( + UnitConversionRateConfig.builder() + .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + .unitConfig( + ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() + ) + .build() + ) + ) + assertThat(newFloatingMinimumCompositePrice.dimensionalPriceConfiguration()) + .isEqualTo( + NewDimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .externalDimensionalPriceGroupId("external_dimensional_price_group_id") + .build() + ) + assertThat(newFloatingMinimumCompositePrice.externalPriceId()) + .isEqualTo("external_price_id") + assertThat(newFloatingMinimumCompositePrice.fixedPriceQuantity()).isEqualTo(0.0) + assertThat(newFloatingMinimumCompositePrice.invoiceGroupingKey()).isEqualTo("x") + assertThat(newFloatingMinimumCompositePrice.invoicingCycleConfiguration()) + .isEqualTo( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) + .build() + ) + assertThat(newFloatingMinimumCompositePrice.metadata()) + .isEqualTo( + NewFloatingMinimumCompositePrice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val newFloatingMinimumCompositePrice = + NewFloatingMinimumCompositePrice.builder() + .cadence(NewFloatingMinimumCompositePrice.Cadence.ANNUAL) + .currency("currency") + .itemId("item_id") + .minimumConfig( + NewFloatingMinimumCompositePrice.MinimumConfig.builder() + .minimumAmount("minimum_amount") + .prorated(true) + .build() + ) + .modelType(NewFloatingMinimumCompositePrice.ModelType.MINIMUM) + .name("Annual fee") + .billableMetricId("billable_metric_id") + .billedInAdvance(true) + .billingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) + .build() + ) + .conversionRate(0.0) + .unitConversionRateConfig( + ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() + ) + .dimensionalPriceConfiguration( + NewDimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .externalDimensionalPriceGroupId("external_dimensional_price_group_id") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoiceGroupingKey("x") + .invoicingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) + .build() + ) + .metadata( + NewFloatingMinimumCompositePrice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .build() + + val roundtrippedNewFloatingMinimumCompositePrice = + jsonMapper.readValue( + jsonMapper.writeValueAsString(newFloatingMinimumCompositePrice), + jacksonTypeRef(), + ) + + assertThat(roundtrippedNewFloatingMinimumCompositePrice) + .isEqualTo(newFloatingMinimumCompositePrice) + } +} diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanMinimumCompositePriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanMinimumCompositePriceTest.kt new file mode 100644 index 000000000..5584c0752 --- /dev/null +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanMinimumCompositePriceTest.kt @@ -0,0 +1,186 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.withorb.api.core.JsonValue +import com.withorb.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class NewPlanMinimumCompositePriceTest { + + @Test + fun create() { + val newPlanMinimumCompositePrice = + NewPlanMinimumCompositePrice.builder() + .cadence(NewPlanMinimumCompositePrice.Cadence.ANNUAL) + .itemId("item_id") + .minimumConfig( + NewPlanMinimumCompositePrice.MinimumConfig.builder() + .minimumAmount("minimum_amount") + .prorated(true) + .build() + ) + .modelType(NewPlanMinimumCompositePrice.ModelType.MINIMUM) + .name("Annual fee") + .billableMetricId("billable_metric_id") + .billedInAdvance(true) + .billingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) + .build() + ) + .conversionRate(0.0) + .unitConversionRateConfig( + ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() + ) + .currency("currency") + .dimensionalPriceConfiguration( + NewDimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .externalDimensionalPriceGroupId("external_dimensional_price_group_id") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoiceGroupingKey("x") + .invoicingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) + .build() + ) + .metadata( + NewPlanMinimumCompositePrice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .referenceId("reference_id") + .build() + + assertThat(newPlanMinimumCompositePrice.cadence()) + .isEqualTo(NewPlanMinimumCompositePrice.Cadence.ANNUAL) + assertThat(newPlanMinimumCompositePrice.itemId()).isEqualTo("item_id") + assertThat(newPlanMinimumCompositePrice.minimumConfig()) + .isEqualTo( + NewPlanMinimumCompositePrice.MinimumConfig.builder() + .minimumAmount("minimum_amount") + .prorated(true) + .build() + ) + assertThat(newPlanMinimumCompositePrice.modelType()) + .isEqualTo(NewPlanMinimumCompositePrice.ModelType.MINIMUM) + assertThat(newPlanMinimumCompositePrice.name()).isEqualTo("Annual fee") + assertThat(newPlanMinimumCompositePrice.billableMetricId()).isEqualTo("billable_metric_id") + assertThat(newPlanMinimumCompositePrice.billedInAdvance()).isEqualTo(true) + assertThat(newPlanMinimumCompositePrice.billingCycleConfiguration()) + .isEqualTo( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) + .build() + ) + assertThat(newPlanMinimumCompositePrice.conversionRate()).isEqualTo(0.0) + assertThat(newPlanMinimumCompositePrice.conversionRateConfig()) + .isEqualTo( + ConversionRateConfig.ofUnit( + UnitConversionRateConfig.builder() + .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + .unitConfig( + ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() + ) + .build() + ) + ) + assertThat(newPlanMinimumCompositePrice.currency()).isEqualTo("currency") + assertThat(newPlanMinimumCompositePrice.dimensionalPriceConfiguration()) + .isEqualTo( + NewDimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .externalDimensionalPriceGroupId("external_dimensional_price_group_id") + .build() + ) + assertThat(newPlanMinimumCompositePrice.externalPriceId()).isEqualTo("external_price_id") + assertThat(newPlanMinimumCompositePrice.fixedPriceQuantity()).isEqualTo(0.0) + assertThat(newPlanMinimumCompositePrice.invoiceGroupingKey()).isEqualTo("x") + assertThat(newPlanMinimumCompositePrice.invoicingCycleConfiguration()) + .isEqualTo( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) + .build() + ) + assertThat(newPlanMinimumCompositePrice.metadata()) + .isEqualTo( + NewPlanMinimumCompositePrice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + assertThat(newPlanMinimumCompositePrice.referenceId()).isEqualTo("reference_id") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val newPlanMinimumCompositePrice = + NewPlanMinimumCompositePrice.builder() + .cadence(NewPlanMinimumCompositePrice.Cadence.ANNUAL) + .itemId("item_id") + .minimumConfig( + NewPlanMinimumCompositePrice.MinimumConfig.builder() + .minimumAmount("minimum_amount") + .prorated(true) + .build() + ) + .modelType(NewPlanMinimumCompositePrice.ModelType.MINIMUM) + .name("Annual fee") + .billableMetricId("billable_metric_id") + .billedInAdvance(true) + .billingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) + .build() + ) + .conversionRate(0.0) + .unitConversionRateConfig( + ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() + ) + .currency("currency") + .dimensionalPriceConfiguration( + NewDimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .externalDimensionalPriceGroupId("external_dimensional_price_group_id") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoiceGroupingKey("x") + .invoicingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) + .build() + ) + .metadata( + NewPlanMinimumCompositePrice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .referenceId("reference_id") + .build() + + val roundtrippedNewPlanMinimumCompositePrice = + jsonMapper.readValue( + jsonMapper.writeValueAsString(newPlanMinimumCompositePrice), + jacksonTypeRef(), + ) + + assertThat(roundtrippedNewPlanMinimumCompositePrice).isEqualTo(newPlanMinimumCompositePrice) + } +} diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionMinimumCompositePriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionMinimumCompositePriceTest.kt new file mode 100644 index 000000000..317aab45c --- /dev/null +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionMinimumCompositePriceTest.kt @@ -0,0 +1,189 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.withorb.api.core.JsonValue +import com.withorb.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class NewSubscriptionMinimumCompositePriceTest { + + @Test + fun create() { + val newSubscriptionMinimumCompositePrice = + NewSubscriptionMinimumCompositePrice.builder() + .cadence(NewSubscriptionMinimumCompositePrice.Cadence.ANNUAL) + .itemId("item_id") + .minimumConfig( + NewSubscriptionMinimumCompositePrice.MinimumConfig.builder() + .minimumAmount("minimum_amount") + .prorated(true) + .build() + ) + .modelType(NewSubscriptionMinimumCompositePrice.ModelType.MINIMUM) + .name("Annual fee") + .billableMetricId("billable_metric_id") + .billedInAdvance(true) + .billingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) + .build() + ) + .conversionRate(0.0) + .unitConversionRateConfig( + ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() + ) + .currency("currency") + .dimensionalPriceConfiguration( + NewDimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .externalDimensionalPriceGroupId("external_dimensional_price_group_id") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoiceGroupingKey("x") + .invoicingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) + .build() + ) + .metadata( + NewSubscriptionMinimumCompositePrice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .referenceId("reference_id") + .build() + + assertThat(newSubscriptionMinimumCompositePrice.cadence()) + .isEqualTo(NewSubscriptionMinimumCompositePrice.Cadence.ANNUAL) + assertThat(newSubscriptionMinimumCompositePrice.itemId()).isEqualTo("item_id") + assertThat(newSubscriptionMinimumCompositePrice.minimumConfig()) + .isEqualTo( + NewSubscriptionMinimumCompositePrice.MinimumConfig.builder() + .minimumAmount("minimum_amount") + .prorated(true) + .build() + ) + assertThat(newSubscriptionMinimumCompositePrice.modelType()) + .isEqualTo(NewSubscriptionMinimumCompositePrice.ModelType.MINIMUM) + assertThat(newSubscriptionMinimumCompositePrice.name()).isEqualTo("Annual fee") + assertThat(newSubscriptionMinimumCompositePrice.billableMetricId()) + .isEqualTo("billable_metric_id") + assertThat(newSubscriptionMinimumCompositePrice.billedInAdvance()).isEqualTo(true) + assertThat(newSubscriptionMinimumCompositePrice.billingCycleConfiguration()) + .isEqualTo( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) + .build() + ) + assertThat(newSubscriptionMinimumCompositePrice.conversionRate()).isEqualTo(0.0) + assertThat(newSubscriptionMinimumCompositePrice.conversionRateConfig()) + .isEqualTo( + ConversionRateConfig.ofUnit( + UnitConversionRateConfig.builder() + .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + .unitConfig( + ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() + ) + .build() + ) + ) + assertThat(newSubscriptionMinimumCompositePrice.currency()).isEqualTo("currency") + assertThat(newSubscriptionMinimumCompositePrice.dimensionalPriceConfiguration()) + .isEqualTo( + NewDimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .externalDimensionalPriceGroupId("external_dimensional_price_group_id") + .build() + ) + assertThat(newSubscriptionMinimumCompositePrice.externalPriceId()) + .isEqualTo("external_price_id") + assertThat(newSubscriptionMinimumCompositePrice.fixedPriceQuantity()).isEqualTo(0.0) + assertThat(newSubscriptionMinimumCompositePrice.invoiceGroupingKey()).isEqualTo("x") + assertThat(newSubscriptionMinimumCompositePrice.invoicingCycleConfiguration()) + .isEqualTo( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) + .build() + ) + assertThat(newSubscriptionMinimumCompositePrice.metadata()) + .isEqualTo( + NewSubscriptionMinimumCompositePrice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + assertThat(newSubscriptionMinimumCompositePrice.referenceId()).isEqualTo("reference_id") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val newSubscriptionMinimumCompositePrice = + NewSubscriptionMinimumCompositePrice.builder() + .cadence(NewSubscriptionMinimumCompositePrice.Cadence.ANNUAL) + .itemId("item_id") + .minimumConfig( + NewSubscriptionMinimumCompositePrice.MinimumConfig.builder() + .minimumAmount("minimum_amount") + .prorated(true) + .build() + ) + .modelType(NewSubscriptionMinimumCompositePrice.ModelType.MINIMUM) + .name("Annual fee") + .billableMetricId("billable_metric_id") + .billedInAdvance(true) + .billingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) + .build() + ) + .conversionRate(0.0) + .unitConversionRateConfig( + ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() + ) + .currency("currency") + .dimensionalPriceConfiguration( + NewDimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .externalDimensionalPriceGroupId("external_dimensional_price_group_id") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoiceGroupingKey("x") + .invoicingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) + .build() + ) + .metadata( + NewSubscriptionMinimumCompositePrice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .referenceId("reference_id") + .build() + + val roundtrippedNewSubscriptionMinimumCompositePrice = + jsonMapper.readValue( + jsonMapper.writeValueAsString(newSubscriptionMinimumCompositePrice), + jacksonTypeRef(), + ) + + assertThat(roundtrippedNewSubscriptionMinimumCompositePrice) + .isEqualTo(newSubscriptionMinimumCompositePrice) + } +} From 6180a95d21214a3bf90989d6a80e55cf2c066fc8 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 3 Sep 2025 22:32:35 +0000 Subject: [PATCH 12/68] feat(api): api update --- .stats.yml | 4 +- .../api/models/BetaCreatePlanVersionParams.kt | 8824 ++++++++--- ...taExternalPlanIdCreatePlanVersionParams.kt | 8824 ++++++++--- .../com/withorb/api/models/BulkConfig.kt | 1 + .../kotlin/com/withorb/api/models/BulkTier.kt | 1 + .../api/models/CustomerCreateParams.kt | 281 +- .../CustomerUpdateByExternalIdParams.kt | 282 +- .../api/models/CustomerUpdateParams.kt | 282 +- .../kotlin/com/withorb/api/models/Invoice.kt | 42 +- .../withorb/api/models/InvoiceCreateParams.kt | 3 + .../models/InvoiceFetchUpcomingResponse.kt | 42 +- .../models/InvoiceLineItemCreateResponse.kt | 40 +- .../com/withorb/api/models/MatrixConfig.kt | 5 +- .../com/withorb/api/models/MatrixValue.kt | 11 +- .../api/models/MatrixWithAllocationConfig.kt | 253 +- .../api/models/NewFloatingBulkPrice.kt | 7 + .../NewFloatingBulkWithProrationPrice.kt | 311 +- .../NewFloatingCumulativeGroupedBulkPrice.kt | 405 +- .../NewFloatingGroupedAllocationPrice.kt | 174 +- .../NewFloatingGroupedTieredPackagePrice.kt | 400 +- .../models/NewFloatingGroupedTieredPrice.kt | 363 +- ...wFloatingGroupedWithMeteredMinimumPrice.kt | 787 +- ...FloatingGroupedWithProratedMinimumPrice.kt | 164 +- .../api/models/NewFloatingMatrixPrice.kt | 7 + .../NewFloatingMatrixWithAllocationPrice.kt | 7 + .../NewFloatingMatrixWithDisplayNamePrice.kt | 403 +- .../NewFloatingMaxGroupTieredPackagePrice.kt | 401 +- .../NewFloatingMinimumCompositePrice.kt | 25 +- .../api/models/NewFloatingPackagePrice.kt | 7 + .../NewFloatingPackageWithAllocationPrice.kt | 173 +- ...ingScalableMatrixWithTieredPricingPrice.kt | 742 +- ...atingScalableMatrixWithUnitPricingPrice.kt | 562 +- .../NewFloatingThresholdTotalAmountPrice.kt | 366 +- .../models/NewFloatingTieredPackagePrice.kt | 360 +- ...ewFloatingTieredPackageWithMinimumPrice.kt | 401 +- .../api/models/NewFloatingTieredPrice.kt | 7 + .../NewFloatingTieredWithMinimumPrice.kt | 444 +- .../NewFloatingTieredWithProrationPrice.kt | 317 +- .../api/models/NewFloatingUnitPrice.kt | 7 + .../models/NewFloatingUnitWithPercentPrice.kt | 122 +- .../NewFloatingUnitWithProrationPrice.kt | 85 +- .../withorb/api/models/NewPlanBulkPrice.kt | 7 + .../models/NewPlanBulkWithProrationPrice.kt | 311 +- .../NewPlanCumulativeGroupedBulkPrice.kt | 405 +- .../models/NewPlanGroupedAllocationPrice.kt | 174 +- .../NewPlanGroupedTieredPackagePrice.kt | 400 +- .../api/models/NewPlanGroupedTieredPrice.kt | 363 +- .../NewPlanGroupedWithMeteredMinimumPrice.kt | 787 +- .../NewPlanGroupedWithProratedMinimumPrice.kt | 164 +- .../withorb/api/models/NewPlanMatrixPrice.kt | 7 + .../NewPlanMatrixWithAllocationPrice.kt | 7 + .../NewPlanMatrixWithDisplayNamePrice.kt | 403 +- .../NewPlanMaxGroupTieredPackagePrice.kt | 401 +- .../models/NewPlanMinimumCompositePrice.kt | 25 +- .../withorb/api/models/NewPlanPackagePrice.kt | 7 + .../NewPlanPackageWithAllocationPrice.kt | 173 +- ...lanScalableMatrixWithTieredPricingPrice.kt | 742 +- ...wPlanScalableMatrixWithUnitPricingPrice.kt | 562 +- .../NewPlanThresholdTotalAmountPrice.kt | 366 +- .../models/NewPlanTierWithProrationPrice.kt | 1480 -- .../api/models/NewPlanTieredPackagePrice.kt | 360 +- .../NewPlanTieredPackageWithMinimumPrice.kt | 401 +- .../withorb/api/models/NewPlanTieredPrice.kt | 7 + .../models/NewPlanTieredWithMinimumPrice.kt | 444 +- .../withorb/api/models/NewPlanUnitPrice.kt | 7 + .../api/models/NewPlanUnitWithPercentPrice.kt | 122 +- .../models/NewPlanUnitWithProrationPrice.kt | 85 +- .../api/models/NewSubscriptionBulkPrice.kt | 7 + .../NewSubscriptionBulkWithProrationPrice.kt | 311 +- ...wSubscriptionCumulativeGroupedBulkPrice.kt | 405 +- .../NewSubscriptionGroupedAllocationPrice.kt | 174 +- ...ewSubscriptionGroupedTieredPackagePrice.kt | 400 +- .../NewSubscriptionGroupedTieredPrice.kt | 363 +- ...scriptionGroupedWithMeteredMinimumPrice.kt | 787 +- ...criptionGroupedWithProratedMinimumPrice.kt | 164 +- .../api/models/NewSubscriptionMatrixPrice.kt | 7 + ...ewSubscriptionMatrixWithAllocationPrice.kt | 7 + ...wSubscriptionMatrixWithDisplayNamePrice.kt | 403 +- ...wSubscriptionMaxGroupTieredPackagePrice.kt | 401 +- .../NewSubscriptionMinimumCompositePrice.kt | 25 +- .../api/models/NewSubscriptionPackagePrice.kt | 7 + ...wSubscriptionPackageWithAllocationPrice.kt | 173 +- ...ionScalableMatrixWithTieredPricingPrice.kt | 742 +- ...ptionScalableMatrixWithUnitPricingPrice.kt | 562 +- ...ewSubscriptionThresholdTotalAmountPrice.kt | 366 +- .../NewSubscriptionTierWithProrationPrice.kt | 1486 -- .../NewSubscriptionTieredPackagePrice.kt | 360 +- ...bscriptionTieredPackageWithMinimumPrice.kt | 401 +- .../api/models/NewSubscriptionTieredPrice.kt | 7 + .../NewSubscriptionTieredWithMinimumPrice.kt | 444 +- .../api/models/NewSubscriptionUnitPrice.kt | 7 + .../NewSubscriptionUnitWithPercentPrice.kt | 122 +- .../NewSubscriptionUnitWithProrationPrice.kt | 85 +- .../com/withorb/api/models/PackageConfig.kt | 1 + .../com/withorb/api/models/PerPriceCost.kt | 40 +- .../kotlin/com/withorb/api/models/Plan.kt | 42 +- .../withorb/api/models/PlanCreateParams.kt | 2642 +++- .../com/withorb/api/models/PlanVersion.kt | 42 +- .../kotlin/com/withorb/api/models/Price.kt | 12296 ++++++++++++---- .../withorb/api/models/PriceCreateParams.kt | 838 +- .../api/models/PriceEvaluateMultipleParams.kt | 872 +- .../PriceEvaluatePreviewEventsParams.kt | 872 +- .../com/withorb/api/models/PriceInterval.kt | 40 +- .../api/models/PriceListPageResponse.kt | 42 +- .../api/models/SubscriptionCreateParams.kt | 10064 +++++++++---- .../SubscriptionPriceIntervalsParams.kt | 865 +- .../SubscriptionSchedulePlanChangeParams.kt | 10016 +++++++++---- .../kotlin/com/withorb/api/models/Tier.kt | 5 +- .../com/withorb/api/models/TierConfig.kt | 248 - .../com/withorb/api/models/TierSubLineItem.kt | 240 + .../com/withorb/api/models/TieredConfig.kt | 1 + .../com/withorb/api/models/UnitConfig.kt | 68 +- .../withorb/api/models/AggregatedCostTest.kt | 21 +- .../models/BetaCreatePlanVersionParamsTest.kt | 42 +- ...ternalPlanIdCreatePlanVersionParamsTest.kt | 42 +- .../ChangedSubscriptionResourcesTest.kt | 30 +- ...ustomerCostListByExternalIdResponseTest.kt | 15 +- .../models/CustomerCostListResponseTest.kt | 15 +- ...dgerCreateEntryByExternalIdResponseTest.kt | 6 +- ...omerCreditLedgerCreateEntryResponseTest.kt | 6 +- ...tLedgerListByExternalIdPageResponseTest.kt | 3 + ...reditLedgerListByExternalIdResponseTest.kt | 6 +- ...ustomerCreditLedgerListPageResponseTest.kt | 3 + .../CustomerCreditLedgerListResponseTest.kt | 6 +- .../api/models/IncrementLedgerEntryTest.kt | 15 +- .../api/models/InvoiceCreateParamsTest.kt | 15 +- .../InvoiceFetchUpcomingResponseTest.kt | 21 +- .../InvoiceLineItemCreateResponseTest.kt | 21 +- .../api/models/InvoiceListPageResponseTest.kt | 15 +- .../com/withorb/api/models/InvoiceTest.kt | 21 +- .../models/MatrixWithAllocationConfigTest.kt | 15 +- .../api/models/MutatedSubscriptionTest.kt | 48 +- .../NewFloatingBulkWithProrationPriceTest.kt | 39 +- ...wFloatingCumulativeGroupedBulkPriceTest.kt | 33 +- .../NewFloatingGroupedAllocationPriceTest.kt | 12 +- ...ewFloatingGroupedTieredPackagePriceTest.kt | 51 +- .../NewFloatingGroupedTieredPriceTest.kt | 42 +- ...atingGroupedWithMeteredMinimumPriceTest.kt | 67 +- ...tingGroupedWithProratedMinimumPriceTest.kt | 12 +- ...ewFloatingMatrixWithAllocationPriceTest.kt | 12 +- ...wFloatingMatrixWithDisplayNamePriceTest.kt | 32 +- ...wFloatingMaxGroupTieredPackagePriceTest.kt | 51 +- .../api/models/NewFloatingPackagePriceTest.kt | 6 +- ...wFloatingPackageWithAllocationPriceTest.kt | 12 +- ...calableMatrixWithTieredPricingPriceTest.kt | 93 +- ...gScalableMatrixWithUnitPricingPriceTest.kt | 45 +- ...ewFloatingThresholdTotalAmountPriceTest.kt | 54 +- .../NewFloatingTieredPackagePriceTest.kt | 42 +- ...oatingTieredPackageWithMinimumPriceTest.kt | 58 +- .../NewFloatingTieredWithMinimumPriceTest.kt | 51 +- ...NewFloatingTieredWithProrationPriceTest.kt | 23 +- .../api/models/NewFloatingUnitPriceTest.kt | 10 +- .../NewFloatingUnitWithPercentPriceTest.kt | 9 +- .../NewFloatingUnitWithProrationPriceTest.kt | 6 +- .../NewPlanBulkWithProrationPriceTest.kt | 39 +- .../NewPlanCumulativeGroupedBulkPriceTest.kt | 32 +- .../NewPlanGroupedAllocationPriceTest.kt | 12 +- .../NewPlanGroupedTieredPackagePriceTest.kt | 49 +- .../models/NewPlanGroupedTieredPriceTest.kt | 42 +- ...wPlanGroupedWithMeteredMinimumPriceTest.kt | 63 +- ...PlanGroupedWithProratedMinimumPriceTest.kt | 12 +- .../NewPlanMatrixWithAllocationPriceTest.kt | 12 +- .../NewPlanMatrixWithDisplayNamePriceTest.kt | 30 +- .../NewPlanMaxGroupTieredPackagePriceTest.kt | 49 +- .../api/models/NewPlanPackagePriceTest.kt | 6 +- .../NewPlanPackageWithAllocationPriceTest.kt | 12 +- ...calableMatrixWithTieredPricingPriceTest.kt | 93 +- ...nScalableMatrixWithUnitPricingPriceTest.kt | 45 +- .../NewPlanThresholdTotalAmountPriceTest.kt | 52 +- .../NewPlanTierWithProrationPriceTest.kt | 184 - .../models/NewPlanTieredPackagePriceTest.kt | 42 +- ...ewPlanTieredPackageWithMinimumPriceTest.kt | 54 +- .../NewPlanTieredWithMinimumPriceTest.kt | 51 +- .../api/models/NewPlanUnitPriceTest.kt | 10 +- .../models/NewPlanUnitWithPercentPriceTest.kt | 9 +- .../NewPlanUnitWithProrationPriceTest.kt | 6 +- ...wSubscriptionBulkWithProrationPriceTest.kt | 43 +- ...scriptionCumulativeGroupedBulkPriceTest.kt | 33 +- ...wSubscriptionGroupedAllocationPriceTest.kt | 12 +- ...bscriptionGroupedTieredPackagePriceTest.kt | 51 +- .../NewSubscriptionGroupedTieredPriceTest.kt | 42 +- ...ptionGroupedWithMeteredMinimumPriceTest.kt | 69 +- ...tionGroupedWithProratedMinimumPriceTest.kt | 12 +- ...bscriptionMatrixWithAllocationPriceTest.kt | 12 +- ...scriptionMatrixWithDisplayNamePriceTest.kt | 33 +- ...scriptionMaxGroupTieredPackagePriceTest.kt | 55 +- .../models/NewSubscriptionPackagePriceTest.kt | 6 +- ...scriptionPackageWithAllocationPriceTest.kt | 12 +- ...calableMatrixWithTieredPricingPriceTest.kt | 93 +- ...nScalableMatrixWithUnitPricingPriceTest.kt | 45 +- ...bscriptionThresholdTotalAmountPriceTest.kt | 54 +- ...wSubscriptionTierWithProrationPriceTest.kt | 186 - .../NewSubscriptionTieredPackagePriceTest.kt | 42 +- ...iptionTieredPackageWithMinimumPriceTest.kt | 64 +- ...wSubscriptionTieredWithMinimumPriceTest.kt | 55 +- .../models/NewSubscriptionUnitPriceTest.kt | 10 +- ...NewSubscriptionUnitWithPercentPriceTest.kt | 9 +- ...wSubscriptionUnitWithProrationPriceTest.kt | 6 +- .../withorb/api/models/PackageConfigTest.kt | 6 +- .../withorb/api/models/PerPriceCostTest.kt | 21 +- .../api/models/PlanCreateParamsTest.kt | 21 +- .../api/models/PlanListPageResponseTest.kt | 21 +- .../kotlin/com/withorb/api/models/PlanTest.kt | 21 +- .../com/withorb/api/models/PlanVersionTest.kt | 21 +- .../api/models/PriceCreateParamsTest.kt | 18 +- .../models/PriceEvaluateMultipleParamsTest.kt | 21 +- .../PriceEvaluatePreviewEventsParamsTest.kt | 21 +- .../withorb/api/models/PriceIntervalTest.kt | 21 +- .../api/models/PriceListPageResponseTest.kt | 21 +- .../com/withorb/api/models/PriceTest.kt | 1562 +- .../SubscriptionChangeApplyResponseTest.kt | 36 +- .../SubscriptionChangeCancelResponseTest.kt | 36 +- .../SubscriptionChangeRetrieveResponseTest.kt | 36 +- .../models/SubscriptionCreateParamsTest.kt | 42 +- .../SubscriptionFetchCostsResponseTest.kt | 15 +- .../SubscriptionPriceIntervalsParamsTest.kt | 21 +- ...ubscriptionSchedulePlanChangeParamsTest.kt | 42 +- .../withorb/api/models/SubscriptionTest.kt | 42 +- .../withorb/api/models/SubscriptionsTest.kt | 30 +- .../com/withorb/api/models/TierConfigTest.kt | 36 - .../withorb/api/models/TierSubLineItemTest.kt | 18 +- .../com/withorb/api/models/UnitConfigTest.kt | 5 +- .../services/async/BetaServiceAsyncTest.kt | 10 +- .../services/async/InvoiceServiceAsyncTest.kt | 7 +- .../services/async/PlanServiceAsyncTest.kt | 5 +- .../services/async/PriceServiceAsyncTest.kt | 17 +- .../async/SubscriptionServiceAsyncTest.kt | 25 +- .../beta/ExternalPlanIdServiceAsyncTest.kt | 10 +- .../api/services/blocking/BetaServiceTest.kt | 10 +- .../services/blocking/InvoiceServiceTest.kt | 7 +- .../api/services/blocking/PlanServiceTest.kt | 5 +- .../api/services/blocking/PriceServiceTest.kt | 17 +- .../blocking/SubscriptionServiceTest.kt | 25 +- .../beta/ExternalPlanIdServiceTest.kt | 10 +- 234 files changed, 66336 insertions(+), 20522 deletions(-) delete mode 100644 orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanTierWithProrationPrice.kt delete mode 100644 orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTierWithProrationPrice.kt delete mode 100644 orb-kotlin-core/src/main/kotlin/com/withorb/api/models/TierConfig.kt delete mode 100644 orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanTierWithProrationPriceTest.kt delete mode 100644 orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionTierWithProrationPriceTest.kt delete mode 100644 orb-kotlin-core/src/test/kotlin/com/withorb/api/models/TierConfigTest.kt diff --git a/.stats.yml b/.stats.yml index 5c39bf210..9f1d47fda 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 118 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-6b2550b95f82872b3825619c109352352b9c92281c8b2470fce158e971142881.yml -openapi_spec_hash: 379df18de1af6a9d0b50d3653aab4d44 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-9dda3e74d276c581c08bea0cad47ae390143d94640f267d827caf234301f2721.yml +openapi_spec_hash: 60daf7a378cdf7dd1f7338c303e2d661 config_hash: 1f73a949b649ecfe6ec68ba1bb459dc2 diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BetaCreatePlanVersionParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BetaCreatePlanVersionParams.kt index 9f2f11ae2..45596201b 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BetaCreatePlanVersionParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BetaCreatePlanVersionParams.kt @@ -1711,7 +1711,7 @@ private constructor( fun planPhaseOrder(): Long? = planPhaseOrder.getNullable("plan_phase_order") /** - * The price to add to the plan + * New plan price request body params. * * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -1815,7 +1815,7 @@ private constructor( this.planPhaseOrder = planPhaseOrder } - /** The price to add to the plan */ + /** New plan price request body params. */ fun price(price: Price?) = price(JsonField.ofNullable(price)) /** @@ -1830,18 +1830,18 @@ private constructor( /** Alias for calling [price] with `Price.ofUnit(unit)`. */ fun price(unit: NewPlanUnitPrice) = price(Price.ofUnit(unit)) - /** Alias for calling [price] with `Price.ofPackage(package_)`. */ - fun price(package_: NewPlanPackagePrice) = price(Price.ofPackage(package_)) - - /** Alias for calling [price] with `Price.ofMatrix(matrix)`. */ - fun price(matrix: NewPlanMatrixPrice) = price(Price.ofMatrix(matrix)) - /** Alias for calling [price] with `Price.ofTiered(tiered)`. */ fun price(tiered: NewPlanTieredPrice) = price(Price.ofTiered(tiered)) /** Alias for calling [price] with `Price.ofBulk(bulk)`. */ fun price(bulk: NewPlanBulkPrice) = price(Price.ofBulk(bulk)) + /** Alias for calling [price] with `Price.ofPackage(package_)`. */ + fun price(package_: NewPlanPackagePrice) = price(Price.ofPackage(package_)) + + /** Alias for calling [price] with `Price.ofMatrix(matrix)`. */ + fun price(matrix: NewPlanMatrixPrice) = price(Price.ofMatrix(matrix)) + /** * Alias for calling [price] with `Price.ofThresholdTotalAmount(thresholdTotalAmount)`. */ @@ -1856,9 +1856,16 @@ private constructor( fun price(tieredWithMinimum: NewPlanTieredWithMinimumPrice) = price(Price.ofTieredWithMinimum(tieredWithMinimum)) - /** Alias for calling [price] with `Price.ofUnitWithPercent(unitWithPercent)`. */ - fun price(unitWithPercent: NewPlanUnitWithPercentPrice) = - price(Price.ofUnitWithPercent(unitWithPercent)) + /** Alias for calling [price] with `Price.ofGroupedTiered(groupedTiered)`. */ + fun price(groupedTiered: NewPlanGroupedTieredPrice) = + price(Price.ofGroupedTiered(groupedTiered)) + + /** + * Alias for calling [price] with + * `Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)`. + */ + fun price(tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice) = + price(Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)) /** * Alias for calling [price] with @@ -1867,10 +1874,20 @@ private constructor( fun price(packageWithAllocation: NewPlanPackageWithAllocationPrice) = price(Price.ofPackageWithAllocation(packageWithAllocation)) + /** Alias for calling [price] with `Price.ofUnitWithPercent(unitWithPercent)`. */ + fun price(unitWithPercent: NewPlanUnitWithPercentPrice) = + price(Price.ofUnitWithPercent(unitWithPercent)) + + /** + * Alias for calling [price] with `Price.ofMatrixWithAllocation(matrixWithAllocation)`. + */ + fun price(matrixWithAllocation: NewPlanMatrixWithAllocationPrice) = + price(Price.ofMatrixWithAllocation(matrixWithAllocation)) + /** * Alias for calling [price] with `Price.ofTieredWithProration(tieredWithProration)`. */ - fun price(tieredWithProration: NewPlanTierWithProrationPrice) = + fun price(tieredWithProration: Price.TieredWithProration) = price(Price.ofTieredWithProration(tieredWithProration)) /** Alias for calling [price] with `Price.ofUnitWithProration(unitWithProration)`. */ @@ -1881,6 +1898,10 @@ private constructor( fun price(groupedAllocation: NewPlanGroupedAllocationPrice) = price(Price.ofGroupedAllocation(groupedAllocation)) + /** Alias for calling [price] with `Price.ofBulkWithProration(bulkWithProration)`. */ + fun price(bulkWithProration: NewPlanBulkWithProrationPrice) = + price(Price.ofBulkWithProration(bulkWithProration)) + /** * Alias for calling [price] with * `Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)`. @@ -1909,10 +1930,6 @@ private constructor( fun price(matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice) = price(Price.ofMatrixWithDisplayName(matrixWithDisplayName)) - /** Alias for calling [price] with `Price.ofBulkWithProration(bulkWithProration)`. */ - fun price(bulkWithProration: NewPlanBulkWithProrationPrice) = - price(Price.ofBulkWithProration(bulkWithProration)) - /** * Alias for calling [price] with `Price.ofGroupedTieredPackage(groupedTieredPackage)`. */ @@ -1948,23 +1965,6 @@ private constructor( fun price(cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice) = price(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) - /** - * Alias for calling [price] with - * `Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)`. - */ - fun price(tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice) = - price(Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)) - - /** - * Alias for calling [price] with `Price.ofMatrixWithAllocation(matrixWithAllocation)`. - */ - fun price(matrixWithAllocation: NewPlanMatrixWithAllocationPrice) = - price(Price.ofMatrixWithAllocation(matrixWithAllocation)) - - /** Alias for calling [price] with `Price.ofGroupedTiered(groupedTiered)`. */ - fun price(groupedTiered: NewPlanGroupedTieredPrice) = - price(Price.ofGroupedTiered(groupedTiered)) - /** Alias for calling [price] with `Price.ofMinimum(minimum)`. */ fun price(minimum: NewPlanMinimumCompositePrice) = price(Price.ofMinimum(minimum)) @@ -2033,29 +2033,32 @@ private constructor( (if (planPhaseOrder.asKnown() == null) 0 else 1) + (price.asKnown()?.validity() ?: 0) - /** The price to add to the plan */ + /** New plan price request body params. */ @JsonDeserialize(using = Price.Deserializer::class) @JsonSerialize(using = Price.Serializer::class) class Price private constructor( private val unit: NewPlanUnitPrice? = null, - private val package_: NewPlanPackagePrice? = null, - private val matrix: NewPlanMatrixPrice? = null, private val tiered: NewPlanTieredPrice? = null, private val bulk: NewPlanBulkPrice? = null, + private val package_: NewPlanPackagePrice? = null, + private val matrix: NewPlanMatrixPrice? = null, private val thresholdTotalAmount: NewPlanThresholdTotalAmountPrice? = null, private val tieredPackage: NewPlanTieredPackagePrice? = null, private val tieredWithMinimum: NewPlanTieredWithMinimumPrice? = null, - private val unitWithPercent: NewPlanUnitWithPercentPrice? = null, + private val groupedTiered: NewPlanGroupedTieredPrice? = null, + private val tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice? = null, private val packageWithAllocation: NewPlanPackageWithAllocationPrice? = null, - private val tieredWithProration: NewPlanTierWithProrationPrice? = null, + private val unitWithPercent: NewPlanUnitWithPercentPrice? = null, + private val matrixWithAllocation: NewPlanMatrixWithAllocationPrice? = null, + private val tieredWithProration: TieredWithProration? = null, private val unitWithProration: NewPlanUnitWithProrationPrice? = null, private val groupedAllocation: NewPlanGroupedAllocationPrice? = null, + private val bulkWithProration: NewPlanBulkWithProrationPrice? = null, private val groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice? = null, private val groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice? = null, private val groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds? = null, private val matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice? = null, - private val bulkWithProration: NewPlanBulkWithProrationPrice? = null, private val groupedTieredPackage: NewPlanGroupedTieredPackagePrice? = null, private val maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice? = null, private val scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice? = @@ -2064,39 +2067,45 @@ private constructor( NewPlanScalableMatrixWithTieredPricingPrice? = null, private val cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice? = null, - private val tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice? = null, - private val matrixWithAllocation: NewPlanMatrixWithAllocationPrice? = null, - private val groupedTiered: NewPlanGroupedTieredPrice? = null, private val minimum: NewPlanMinimumCompositePrice? = null, private val _json: JsonValue? = null, ) { fun unit(): NewPlanUnitPrice? = unit - fun package_(): NewPlanPackagePrice? = package_ - - fun matrix(): NewPlanMatrixPrice? = matrix - fun tiered(): NewPlanTieredPrice? = tiered fun bulk(): NewPlanBulkPrice? = bulk + fun package_(): NewPlanPackagePrice? = package_ + + fun matrix(): NewPlanMatrixPrice? = matrix + fun thresholdTotalAmount(): NewPlanThresholdTotalAmountPrice? = thresholdTotalAmount fun tieredPackage(): NewPlanTieredPackagePrice? = tieredPackage fun tieredWithMinimum(): NewPlanTieredWithMinimumPrice? = tieredWithMinimum - fun unitWithPercent(): NewPlanUnitWithPercentPrice? = unitWithPercent + fun groupedTiered(): NewPlanGroupedTieredPrice? = groupedTiered + + fun tieredPackageWithMinimum(): NewPlanTieredPackageWithMinimumPrice? = + tieredPackageWithMinimum fun packageWithAllocation(): NewPlanPackageWithAllocationPrice? = packageWithAllocation - fun tieredWithProration(): NewPlanTierWithProrationPrice? = tieredWithProration + fun unitWithPercent(): NewPlanUnitWithPercentPrice? = unitWithPercent + + fun matrixWithAllocation(): NewPlanMatrixWithAllocationPrice? = matrixWithAllocation + + fun tieredWithProration(): TieredWithProration? = tieredWithProration fun unitWithProration(): NewPlanUnitWithProrationPrice? = unitWithProration fun groupedAllocation(): NewPlanGroupedAllocationPrice? = groupedAllocation + fun bulkWithProration(): NewPlanBulkWithProrationPrice? = bulkWithProration + fun groupedWithProratedMinimum(): NewPlanGroupedWithProratedMinimumPrice? = groupedWithProratedMinimum @@ -2108,8 +2117,6 @@ private constructor( fun matrixWithDisplayName(): NewPlanMatrixWithDisplayNamePrice? = matrixWithDisplayName - fun bulkWithProration(): NewPlanBulkWithProrationPrice? = bulkWithProration - fun groupedTieredPackage(): NewPlanGroupedTieredPackagePrice? = groupedTieredPackage fun maxGroupTieredPackage(): NewPlanMaxGroupTieredPackagePrice? = maxGroupTieredPackage @@ -2122,41 +2129,42 @@ private constructor( fun cumulativeGroupedBulk(): NewPlanCumulativeGroupedBulkPrice? = cumulativeGroupedBulk - fun tieredPackageWithMinimum(): NewPlanTieredPackageWithMinimumPrice? = - tieredPackageWithMinimum - - fun matrixWithAllocation(): NewPlanMatrixWithAllocationPrice? = matrixWithAllocation - - fun groupedTiered(): NewPlanGroupedTieredPrice? = groupedTiered - fun minimum(): NewPlanMinimumCompositePrice? = minimum fun isUnit(): Boolean = unit != null - fun isPackage(): Boolean = package_ != null - - fun isMatrix(): Boolean = matrix != null - fun isTiered(): Boolean = tiered != null fun isBulk(): Boolean = bulk != null + fun isPackage(): Boolean = package_ != null + + fun isMatrix(): Boolean = matrix != null + fun isThresholdTotalAmount(): Boolean = thresholdTotalAmount != null fun isTieredPackage(): Boolean = tieredPackage != null fun isTieredWithMinimum(): Boolean = tieredWithMinimum != null - fun isUnitWithPercent(): Boolean = unitWithPercent != null + fun isGroupedTiered(): Boolean = groupedTiered != null + + fun isTieredPackageWithMinimum(): Boolean = tieredPackageWithMinimum != null fun isPackageWithAllocation(): Boolean = packageWithAllocation != null + fun isUnitWithPercent(): Boolean = unitWithPercent != null + + fun isMatrixWithAllocation(): Boolean = matrixWithAllocation != null + fun isTieredWithProration(): Boolean = tieredWithProration != null fun isUnitWithProration(): Boolean = unitWithProration != null fun isGroupedAllocation(): Boolean = groupedAllocation != null + fun isBulkWithProration(): Boolean = bulkWithProration != null + fun isGroupedWithProratedMinimum(): Boolean = groupedWithProratedMinimum != null fun isGroupedWithMeteredMinimum(): Boolean = groupedWithMeteredMinimum != null @@ -2165,8 +2173,6 @@ private constructor( fun isMatrixWithDisplayName(): Boolean = matrixWithDisplayName != null - fun isBulkWithProration(): Boolean = bulkWithProration != null - fun isGroupedTieredPackage(): Boolean = groupedTieredPackage != null fun isMaxGroupTieredPackage(): Boolean = maxGroupTieredPackage != null @@ -2178,24 +2184,18 @@ private constructor( fun isCumulativeGroupedBulk(): Boolean = cumulativeGroupedBulk != null - fun isTieredPackageWithMinimum(): Boolean = tieredPackageWithMinimum != null - - fun isMatrixWithAllocation(): Boolean = matrixWithAllocation != null - - fun isGroupedTiered(): Boolean = groupedTiered != null - fun isMinimum(): Boolean = minimum != null fun asUnit(): NewPlanUnitPrice = unit.getOrThrow("unit") - fun asPackage(): NewPlanPackagePrice = package_.getOrThrow("package_") - - fun asMatrix(): NewPlanMatrixPrice = matrix.getOrThrow("matrix") - fun asTiered(): NewPlanTieredPrice = tiered.getOrThrow("tiered") fun asBulk(): NewPlanBulkPrice = bulk.getOrThrow("bulk") + fun asPackage(): NewPlanPackagePrice = package_.getOrThrow("package_") + + fun asMatrix(): NewPlanMatrixPrice = matrix.getOrThrow("matrix") + fun asThresholdTotalAmount(): NewPlanThresholdTotalAmountPrice = thresholdTotalAmount.getOrThrow("thresholdTotalAmount") @@ -2205,13 +2205,22 @@ private constructor( fun asTieredWithMinimum(): NewPlanTieredWithMinimumPrice = tieredWithMinimum.getOrThrow("tieredWithMinimum") - fun asUnitWithPercent(): NewPlanUnitWithPercentPrice = - unitWithPercent.getOrThrow("unitWithPercent") + fun asGroupedTiered(): NewPlanGroupedTieredPrice = + groupedTiered.getOrThrow("groupedTiered") + + fun asTieredPackageWithMinimum(): NewPlanTieredPackageWithMinimumPrice = + tieredPackageWithMinimum.getOrThrow("tieredPackageWithMinimum") fun asPackageWithAllocation(): NewPlanPackageWithAllocationPrice = packageWithAllocation.getOrThrow("packageWithAllocation") - fun asTieredWithProration(): NewPlanTierWithProrationPrice = + fun asUnitWithPercent(): NewPlanUnitWithPercentPrice = + unitWithPercent.getOrThrow("unitWithPercent") + + fun asMatrixWithAllocation(): NewPlanMatrixWithAllocationPrice = + matrixWithAllocation.getOrThrow("matrixWithAllocation") + + fun asTieredWithProration(): TieredWithProration = tieredWithProration.getOrThrow("tieredWithProration") fun asUnitWithProration(): NewPlanUnitWithProrationPrice = @@ -2220,6 +2229,9 @@ private constructor( fun asGroupedAllocation(): NewPlanGroupedAllocationPrice = groupedAllocation.getOrThrow("groupedAllocation") + fun asBulkWithProration(): NewPlanBulkWithProrationPrice = + bulkWithProration.getOrThrow("bulkWithProration") + fun asGroupedWithProratedMinimum(): NewPlanGroupedWithProratedMinimumPrice = groupedWithProratedMinimum.getOrThrow("groupedWithProratedMinimum") @@ -2232,9 +2244,6 @@ private constructor( fun asMatrixWithDisplayName(): NewPlanMatrixWithDisplayNamePrice = matrixWithDisplayName.getOrThrow("matrixWithDisplayName") - fun asBulkWithProration(): NewPlanBulkWithProrationPrice = - bulkWithProration.getOrThrow("bulkWithProration") - fun asGroupedTieredPackage(): NewPlanGroupedTieredPackagePrice = groupedTieredPackage.getOrThrow("groupedTieredPackage") @@ -2250,15 +2259,6 @@ private constructor( fun asCumulativeGroupedBulk(): NewPlanCumulativeGroupedBulkPrice = cumulativeGroupedBulk.getOrThrow("cumulativeGroupedBulk") - fun asTieredPackageWithMinimum(): NewPlanTieredPackageWithMinimumPrice = - tieredPackageWithMinimum.getOrThrow("tieredPackageWithMinimum") - - fun asMatrixWithAllocation(): NewPlanMatrixWithAllocationPrice = - matrixWithAllocation.getOrThrow("matrixWithAllocation") - - fun asGroupedTiered(): NewPlanGroupedTieredPrice = - groupedTiered.getOrThrow("groupedTiered") - fun asMinimum(): NewPlanMinimumCompositePrice = minimum.getOrThrow("minimum") fun _json(): JsonValue? = _json @@ -2266,21 +2266,27 @@ private constructor( fun accept(visitor: Visitor): T = when { unit != null -> visitor.visitUnit(unit) - package_ != null -> visitor.visitPackage(package_) - matrix != null -> visitor.visitMatrix(matrix) tiered != null -> visitor.visitTiered(tiered) bulk != null -> visitor.visitBulk(bulk) + package_ != null -> visitor.visitPackage(package_) + matrix != null -> visitor.visitMatrix(matrix) thresholdTotalAmount != null -> visitor.visitThresholdTotalAmount(thresholdTotalAmount) tieredPackage != null -> visitor.visitTieredPackage(tieredPackage) tieredWithMinimum != null -> visitor.visitTieredWithMinimum(tieredWithMinimum) - unitWithPercent != null -> visitor.visitUnitWithPercent(unitWithPercent) + groupedTiered != null -> visitor.visitGroupedTiered(groupedTiered) + tieredPackageWithMinimum != null -> + visitor.visitTieredPackageWithMinimum(tieredPackageWithMinimum) packageWithAllocation != null -> visitor.visitPackageWithAllocation(packageWithAllocation) + unitWithPercent != null -> visitor.visitUnitWithPercent(unitWithPercent) + matrixWithAllocation != null -> + visitor.visitMatrixWithAllocation(matrixWithAllocation) tieredWithProration != null -> visitor.visitTieredWithProration(tieredWithProration) unitWithProration != null -> visitor.visitUnitWithProration(unitWithProration) groupedAllocation != null -> visitor.visitGroupedAllocation(groupedAllocation) + bulkWithProration != null -> visitor.visitBulkWithProration(bulkWithProration) groupedWithProratedMinimum != null -> visitor.visitGroupedWithProratedMinimum(groupedWithProratedMinimum) groupedWithMeteredMinimum != null -> @@ -2289,7 +2295,6 @@ private constructor( visitor.visitGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds) matrixWithDisplayName != null -> visitor.visitMatrixWithDisplayName(matrixWithDisplayName) - bulkWithProration != null -> visitor.visitBulkWithProration(bulkWithProration) groupedTieredPackage != null -> visitor.visitGroupedTieredPackage(groupedTieredPackage) maxGroupTieredPackage != null -> @@ -2302,11 +2307,6 @@ private constructor( ) cumulativeGroupedBulk != null -> visitor.visitCumulativeGroupedBulk(cumulativeGroupedBulk) - tieredPackageWithMinimum != null -> - visitor.visitTieredPackageWithMinimum(tieredPackageWithMinimum) - matrixWithAllocation != null -> - visitor.visitMatrixWithAllocation(matrixWithAllocation) - groupedTiered != null -> visitor.visitGroupedTiered(groupedTiered) minimum != null -> visitor.visitMinimum(minimum) else -> visitor.unknown(_json) } @@ -2324,14 +2324,6 @@ private constructor( unit.validate() } - override fun visitPackage(package_: NewPlanPackagePrice) { - package_.validate() - } - - override fun visitMatrix(matrix: NewPlanMatrixPrice) { - matrix.validate() - } - override fun visitTiered(tiered: NewPlanTieredPrice) { tiered.validate() } @@ -2340,6 +2332,14 @@ private constructor( bulk.validate() } + override fun visitPackage(package_: NewPlanPackagePrice) { + package_.validate() + } + + override fun visitMatrix(matrix: NewPlanMatrixPrice) { + matrix.validate() + } + override fun visitThresholdTotalAmount( thresholdTotalAmount: NewPlanThresholdTotalAmountPrice ) { @@ -2356,10 +2356,14 @@ private constructor( tieredWithMinimum.validate() } - override fun visitUnitWithPercent( - unitWithPercent: NewPlanUnitWithPercentPrice + override fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) { + groupedTiered.validate() + } + + override fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice ) { - unitWithPercent.validate() + tieredPackageWithMinimum.validate() } override fun visitPackageWithAllocation( @@ -2368,8 +2372,20 @@ private constructor( packageWithAllocation.validate() } + override fun visitUnitWithPercent( + unitWithPercent: NewPlanUnitWithPercentPrice + ) { + unitWithPercent.validate() + } + + override fun visitMatrixWithAllocation( + matrixWithAllocation: NewPlanMatrixWithAllocationPrice + ) { + matrixWithAllocation.validate() + } + override fun visitTieredWithProration( - tieredWithProration: NewPlanTierWithProrationPrice + tieredWithProration: TieredWithProration ) { tieredWithProration.validate() } @@ -2386,6 +2402,12 @@ private constructor( groupedAllocation.validate() } + override fun visitBulkWithProration( + bulkWithProration: NewPlanBulkWithProrationPrice + ) { + bulkWithProration.validate() + } + override fun visitGroupedWithProratedMinimum( groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice ) { @@ -2410,12 +2432,6 @@ private constructor( matrixWithDisplayName.validate() } - override fun visitBulkWithProration( - bulkWithProration: NewPlanBulkWithProrationPrice - ) { - bulkWithProration.validate() - } - override fun visitGroupedTieredPackage( groupedTieredPackage: NewPlanGroupedTieredPackagePrice ) { @@ -2447,22 +2463,6 @@ private constructor( cumulativeGroupedBulk.validate() } - override fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice - ) { - tieredPackageWithMinimum.validate() - } - - override fun visitMatrixWithAllocation( - matrixWithAllocation: NewPlanMatrixWithAllocationPrice - ) { - matrixWithAllocation.validate() - } - - override fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) { - groupedTiered.validate() - } - override fun visitMinimum(minimum: NewPlanMinimumCompositePrice) { minimum.validate() } @@ -2490,15 +2490,15 @@ private constructor( object : Visitor { override fun visitUnit(unit: NewPlanUnitPrice) = unit.validity() + override fun visitTiered(tiered: NewPlanTieredPrice) = tiered.validity() + + override fun visitBulk(bulk: NewPlanBulkPrice) = bulk.validity() + override fun visitPackage(package_: NewPlanPackagePrice) = package_.validity() override fun visitMatrix(matrix: NewPlanMatrixPrice) = matrix.validity() - override fun visitTiered(tiered: NewPlanTieredPrice) = tiered.validity() - - override fun visitBulk(bulk: NewPlanBulkPrice) = bulk.validity() - override fun visitThresholdTotalAmount( thresholdTotalAmount: NewPlanThresholdTotalAmountPrice ) = thresholdTotalAmount.validity() @@ -2510,16 +2510,27 @@ private constructor( tieredWithMinimum: NewPlanTieredWithMinimumPrice ) = tieredWithMinimum.validity() - override fun visitUnitWithPercent( - unitWithPercent: NewPlanUnitWithPercentPrice - ) = unitWithPercent.validity() + override fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) = + groupedTiered.validity() + + override fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice + ) = tieredPackageWithMinimum.validity() override fun visitPackageWithAllocation( packageWithAllocation: NewPlanPackageWithAllocationPrice ) = packageWithAllocation.validity() + override fun visitUnitWithPercent( + unitWithPercent: NewPlanUnitWithPercentPrice + ) = unitWithPercent.validity() + + override fun visitMatrixWithAllocation( + matrixWithAllocation: NewPlanMatrixWithAllocationPrice + ) = matrixWithAllocation.validity() + override fun visitTieredWithProration( - tieredWithProration: NewPlanTierWithProrationPrice + tieredWithProration: TieredWithProration ) = tieredWithProration.validity() override fun visitUnitWithProration( @@ -2530,6 +2541,10 @@ private constructor( groupedAllocation: NewPlanGroupedAllocationPrice ) = groupedAllocation.validity() + override fun visitBulkWithProration( + bulkWithProration: NewPlanBulkWithProrationPrice + ) = bulkWithProration.validity() + override fun visitGroupedWithProratedMinimum( groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice ) = groupedWithProratedMinimum.validity() @@ -2546,10 +2561,6 @@ private constructor( matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice ) = matrixWithDisplayName.validity() - override fun visitBulkWithProration( - bulkWithProration: NewPlanBulkWithProrationPrice - ) = bulkWithProration.validity() - override fun visitGroupedTieredPackage( groupedTieredPackage: NewPlanGroupedTieredPackagePrice ) = groupedTieredPackage.validity() @@ -2571,17 +2582,6 @@ private constructor( cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice ) = cumulativeGroupedBulk.validity() - override fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice - ) = tieredPackageWithMinimum.validity() - - override fun visitMatrixWithAllocation( - matrixWithAllocation: NewPlanMatrixWithAllocationPrice - ) = matrixWithAllocation.validity() - - override fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) = - groupedTiered.validity() - override fun visitMinimum(minimum: NewPlanMinimumCompositePrice) = minimum.validity() @@ -2596,82 +2596,88 @@ private constructor( return other is Price && unit == other.unit && - package_ == other.package_ && - matrix == other.matrix && tiered == other.tiered && bulk == other.bulk && + package_ == other.package_ && + matrix == other.matrix && thresholdTotalAmount == other.thresholdTotalAmount && tieredPackage == other.tieredPackage && tieredWithMinimum == other.tieredWithMinimum && - unitWithPercent == other.unitWithPercent && + groupedTiered == other.groupedTiered && + tieredPackageWithMinimum == other.tieredPackageWithMinimum && packageWithAllocation == other.packageWithAllocation && + unitWithPercent == other.unitWithPercent && + matrixWithAllocation == other.matrixWithAllocation && tieredWithProration == other.tieredWithProration && unitWithProration == other.unitWithProration && groupedAllocation == other.groupedAllocation && + bulkWithProration == other.bulkWithProration && groupedWithProratedMinimum == other.groupedWithProratedMinimum && groupedWithMeteredMinimum == other.groupedWithMeteredMinimum && groupedWithMinMaxThresholds == other.groupedWithMinMaxThresholds && matrixWithDisplayName == other.matrixWithDisplayName && - bulkWithProration == other.bulkWithProration && groupedTieredPackage == other.groupedTieredPackage && maxGroupTieredPackage == other.maxGroupTieredPackage && scalableMatrixWithUnitPricing == other.scalableMatrixWithUnitPricing && scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && cumulativeGroupedBulk == other.cumulativeGroupedBulk && - tieredPackageWithMinimum == other.tieredPackageWithMinimum && - matrixWithAllocation == other.matrixWithAllocation && - groupedTiered == other.groupedTiered && minimum == other.minimum } override fun hashCode(): Int = Objects.hash( unit, - package_, - matrix, tiered, bulk, + package_, + matrix, thresholdTotalAmount, tieredPackage, tieredWithMinimum, - unitWithPercent, + groupedTiered, + tieredPackageWithMinimum, packageWithAllocation, + unitWithPercent, + matrixWithAllocation, tieredWithProration, unitWithProration, groupedAllocation, + bulkWithProration, groupedWithProratedMinimum, groupedWithMeteredMinimum, groupedWithMinMaxThresholds, matrixWithDisplayName, - bulkWithProration, groupedTieredPackage, maxGroupTieredPackage, scalableMatrixWithUnitPricing, scalableMatrixWithTieredPricing, cumulativeGroupedBulk, - tieredPackageWithMinimum, - matrixWithAllocation, - groupedTiered, minimum, ) override fun toString(): String = when { unit != null -> "Price{unit=$unit}" - package_ != null -> "Price{package_=$package_}" - matrix != null -> "Price{matrix=$matrix}" tiered != null -> "Price{tiered=$tiered}" bulk != null -> "Price{bulk=$bulk}" + package_ != null -> "Price{package_=$package_}" + matrix != null -> "Price{matrix=$matrix}" thresholdTotalAmount != null -> "Price{thresholdTotalAmount=$thresholdTotalAmount}" tieredPackage != null -> "Price{tieredPackage=$tieredPackage}" tieredWithMinimum != null -> "Price{tieredWithMinimum=$tieredWithMinimum}" - unitWithPercent != null -> "Price{unitWithPercent=$unitWithPercent}" + groupedTiered != null -> "Price{groupedTiered=$groupedTiered}" + tieredPackageWithMinimum != null -> + "Price{tieredPackageWithMinimum=$tieredPackageWithMinimum}" packageWithAllocation != null -> "Price{packageWithAllocation=$packageWithAllocation}" + unitWithPercent != null -> "Price{unitWithPercent=$unitWithPercent}" + matrixWithAllocation != null -> + "Price{matrixWithAllocation=$matrixWithAllocation}" tieredWithProration != null -> "Price{tieredWithProration=$tieredWithProration}" unitWithProration != null -> "Price{unitWithProration=$unitWithProration}" groupedAllocation != null -> "Price{groupedAllocation=$groupedAllocation}" + bulkWithProration != null -> "Price{bulkWithProration=$bulkWithProration}" groupedWithProratedMinimum != null -> "Price{groupedWithProratedMinimum=$groupedWithProratedMinimum}" groupedWithMeteredMinimum != null -> @@ -2680,7 +2686,6 @@ private constructor( "Price{groupedWithMinMaxThresholds=$groupedWithMinMaxThresholds}" matrixWithDisplayName != null -> "Price{matrixWithDisplayName=$matrixWithDisplayName}" - bulkWithProration != null -> "Price{bulkWithProration=$bulkWithProration}" groupedTieredPackage != null -> "Price{groupedTieredPackage=$groupedTieredPackage}" maxGroupTieredPackage != null -> @@ -2691,11 +2696,6 @@ private constructor( "Price{scalableMatrixWithTieredPricing=$scalableMatrixWithTieredPricing}" cumulativeGroupedBulk != null -> "Price{cumulativeGroupedBulk=$cumulativeGroupedBulk}" - tieredPackageWithMinimum != null -> - "Price{tieredPackageWithMinimum=$tieredPackageWithMinimum}" - matrixWithAllocation != null -> - "Price{matrixWithAllocation=$matrixWithAllocation}" - groupedTiered != null -> "Price{groupedTiered=$groupedTiered}" minimum != null -> "Price{minimum=$minimum}" _json != null -> "Price{_unknown=$_json}" else -> throw IllegalStateException("Invalid Price") @@ -2705,14 +2705,14 @@ private constructor( fun ofUnit(unit: NewPlanUnitPrice) = Price(unit = unit) - fun ofPackage(package_: NewPlanPackagePrice) = Price(package_ = package_) - - fun ofMatrix(matrix: NewPlanMatrixPrice) = Price(matrix = matrix) - fun ofTiered(tiered: NewPlanTieredPrice) = Price(tiered = tiered) fun ofBulk(bulk: NewPlanBulkPrice) = Price(bulk = bulk) + fun ofPackage(package_: NewPlanPackagePrice) = Price(package_ = package_) + + fun ofMatrix(matrix: NewPlanMatrixPrice) = Price(matrix = matrix) + fun ofThresholdTotalAmount(thresholdTotalAmount: NewPlanThresholdTotalAmountPrice) = Price(thresholdTotalAmount = thresholdTotalAmount) @@ -2722,14 +2722,24 @@ private constructor( fun ofTieredWithMinimum(tieredWithMinimum: NewPlanTieredWithMinimumPrice) = Price(tieredWithMinimum = tieredWithMinimum) - fun ofUnitWithPercent(unitWithPercent: NewPlanUnitWithPercentPrice) = - Price(unitWithPercent = unitWithPercent) + fun ofGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) = + Price(groupedTiered = groupedTiered) + + fun ofTieredPackageWithMinimum( + tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice + ) = Price(tieredPackageWithMinimum = tieredPackageWithMinimum) fun ofPackageWithAllocation( packageWithAllocation: NewPlanPackageWithAllocationPrice ) = Price(packageWithAllocation = packageWithAllocation) - fun ofTieredWithProration(tieredWithProration: NewPlanTierWithProrationPrice) = + fun ofUnitWithPercent(unitWithPercent: NewPlanUnitWithPercentPrice) = + Price(unitWithPercent = unitWithPercent) + + fun ofMatrixWithAllocation(matrixWithAllocation: NewPlanMatrixWithAllocationPrice) = + Price(matrixWithAllocation = matrixWithAllocation) + + fun ofTieredWithProration(tieredWithProration: TieredWithProration) = Price(tieredWithProration = tieredWithProration) fun ofUnitWithProration(unitWithProration: NewPlanUnitWithProrationPrice) = @@ -2738,6 +2748,9 @@ private constructor( fun ofGroupedAllocation(groupedAllocation: NewPlanGroupedAllocationPrice) = Price(groupedAllocation = groupedAllocation) + fun ofBulkWithProration(bulkWithProration: NewPlanBulkWithProrationPrice) = + Price(bulkWithProration = bulkWithProration) + fun ofGroupedWithProratedMinimum( groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice ) = Price(groupedWithProratedMinimum = groupedWithProratedMinimum) @@ -2754,9 +2767,6 @@ private constructor( matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice ) = Price(matrixWithDisplayName = matrixWithDisplayName) - fun ofBulkWithProration(bulkWithProration: NewPlanBulkWithProrationPrice) = - Price(bulkWithProration = bulkWithProration) - fun ofGroupedTieredPackage(groupedTieredPackage: NewPlanGroupedTieredPackagePrice) = Price(groupedTieredPackage = groupedTieredPackage) @@ -2776,16 +2786,6 @@ private constructor( cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice ) = Price(cumulativeGroupedBulk = cumulativeGroupedBulk) - fun ofTieredPackageWithMinimum( - tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice - ) = Price(tieredPackageWithMinimum = tieredPackageWithMinimum) - - fun ofMatrixWithAllocation(matrixWithAllocation: NewPlanMatrixWithAllocationPrice) = - Price(matrixWithAllocation = matrixWithAllocation) - - fun ofGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) = - Price(groupedTiered = groupedTiered) - fun ofMinimum(minimum: NewPlanMinimumCompositePrice) = Price(minimum = minimum) } @@ -2796,14 +2796,14 @@ private constructor( fun visitUnit(unit: NewPlanUnitPrice): T - fun visitPackage(package_: NewPlanPackagePrice): T - - fun visitMatrix(matrix: NewPlanMatrixPrice): T - fun visitTiered(tiered: NewPlanTieredPrice): T fun visitBulk(bulk: NewPlanBulkPrice): T + fun visitPackage(package_: NewPlanPackagePrice): T + + fun visitMatrix(matrix: NewPlanMatrixPrice): T + fun visitThresholdTotalAmount( thresholdTotalAmount: NewPlanThresholdTotalAmountPrice ): T @@ -2812,18 +2812,30 @@ private constructor( fun visitTieredWithMinimum(tieredWithMinimum: NewPlanTieredWithMinimumPrice): T - fun visitUnitWithPercent(unitWithPercent: NewPlanUnitWithPercentPrice): T + fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice): T + + fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice + ): T fun visitPackageWithAllocation( packageWithAllocation: NewPlanPackageWithAllocationPrice ): T - fun visitTieredWithProration(tieredWithProration: NewPlanTierWithProrationPrice): T + fun visitUnitWithPercent(unitWithPercent: NewPlanUnitWithPercentPrice): T + + fun visitMatrixWithAllocation( + matrixWithAllocation: NewPlanMatrixWithAllocationPrice + ): T + + fun visitTieredWithProration(tieredWithProration: TieredWithProration): T fun visitUnitWithProration(unitWithProration: NewPlanUnitWithProrationPrice): T fun visitGroupedAllocation(groupedAllocation: NewPlanGroupedAllocationPrice): T + fun visitBulkWithProration(bulkWithProration: NewPlanBulkWithProrationPrice): T + fun visitGroupedWithProratedMinimum( groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice ): T @@ -2840,8 +2852,6 @@ private constructor( matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice ): T - fun visitBulkWithProration(bulkWithProration: NewPlanBulkWithProrationPrice): T - fun visitGroupedTieredPackage( groupedTieredPackage: NewPlanGroupedTieredPackagePrice ): T @@ -2862,16 +2872,6 @@ private constructor( cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice ): T - fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice - ): T - - fun visitMatrixWithAllocation( - matrixWithAllocation: NewPlanMatrixWithAllocationPrice - ): T - - fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice): T - fun visitMinimum(minimum: NewPlanMinimumCompositePrice): T /** @@ -2901,15 +2901,6 @@ private constructor( Price(unit = it, _json = json) } ?: Price(_json = json) } - "package" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(package_ = it, _json = json) } ?: Price(_json = json) - } - "matrix" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(matrix = it, _json = json) - } ?: Price(_json = json) - } "tiered" -> { return tryDeserialize(node, jacksonTypeRef())?.let { Price(tiered = it, _json = json) @@ -2920,6 +2911,15 @@ private constructor( Price(bulk = it, _json = json) } ?: Price(_json = json) } + "package" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(package_ = it, _json = json) } ?: Price(_json = json) + } + "matrix" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(matrix = it, _json = json) + } ?: Price(_json = json) + } "threshold_total_amount" -> { return tryDeserialize( node, @@ -2941,12 +2941,17 @@ private constructor( ?.let { Price(tieredWithMinimum = it, _json = json) } ?: Price(_json = json) } - "unit_with_percent" -> { + "grouped_tiered" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(groupedTiered = it, _json = json) } + ?: Price(_json = json) + } + "tiered_package_with_minimum" -> { return tryDeserialize( node, - jacksonTypeRef(), + jacksonTypeRef(), ) - ?.let { Price(unitWithPercent = it, _json = json) } + ?.let { Price(tieredPackageWithMinimum = it, _json = json) } ?: Price(_json = json) } "package_with_allocation" -> { @@ -2957,11 +2962,24 @@ private constructor( ?.let { Price(packageWithAllocation = it, _json = json) } ?: Price(_json = json) } - "tiered_with_proration" -> { + "unit_with_percent" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(unitWithPercent = it, _json = json) } + ?: Price(_json = json) + } + "matrix_with_allocation" -> { return tryDeserialize( node, - jacksonTypeRef(), + jacksonTypeRef(), ) + ?.let { Price(matrixWithAllocation = it, _json = json) } + ?: Price(_json = json) + } + "tiered_with_proration" -> { + return tryDeserialize(node, jacksonTypeRef()) ?.let { Price(tieredWithProration = it, _json = json) } ?: Price(_json = json) } @@ -2981,6 +2999,14 @@ private constructor( ?.let { Price(groupedAllocation = it, _json = json) } ?: Price(_json = json) } + "bulk_with_proration" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(bulkWithProration = it, _json = json) } + ?: Price(_json = json) + } "grouped_with_prorated_minimum" -> { return tryDeserialize( node, @@ -3013,14 +3039,6 @@ private constructor( ?.let { Price(matrixWithDisplayName = it, _json = json) } ?: Price(_json = json) } - "bulk_with_proration" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(bulkWithProration = it, _json = json) } - ?: Price(_json = json) - } "grouped_tiered_package" -> { return tryDeserialize( node, @@ -3061,27 +3079,6 @@ private constructor( ?.let { Price(cumulativeGroupedBulk = it, _json = json) } ?: Price(_json = json) } - "tiered_package_with_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(tieredPackageWithMinimum = it, _json = json) } - ?: Price(_json = json) - } - "matrix_with_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(matrixWithAllocation = it, _json = json) } - ?: Price(_json = json) - } - "grouped_tiered" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(groupedTiered = it, _json = json) } - ?: Price(_json = json) - } "minimum" -> { return tryDeserialize( node, @@ -3104,25 +3101,32 @@ private constructor( ) { when { value.unit != null -> generator.writeObject(value.unit) - value.package_ != null -> generator.writeObject(value.package_) - value.matrix != null -> generator.writeObject(value.matrix) value.tiered != null -> generator.writeObject(value.tiered) value.bulk != null -> generator.writeObject(value.bulk) + value.package_ != null -> generator.writeObject(value.package_) + value.matrix != null -> generator.writeObject(value.matrix) value.thresholdTotalAmount != null -> generator.writeObject(value.thresholdTotalAmount) value.tieredPackage != null -> generator.writeObject(value.tieredPackage) value.tieredWithMinimum != null -> generator.writeObject(value.tieredWithMinimum) - value.unitWithPercent != null -> - generator.writeObject(value.unitWithPercent) + value.groupedTiered != null -> generator.writeObject(value.groupedTiered) + value.tieredPackageWithMinimum != null -> + generator.writeObject(value.tieredPackageWithMinimum) value.packageWithAllocation != null -> generator.writeObject(value.packageWithAllocation) + value.unitWithPercent != null -> + generator.writeObject(value.unitWithPercent) + value.matrixWithAllocation != null -> + generator.writeObject(value.matrixWithAllocation) value.tieredWithProration != null -> generator.writeObject(value.tieredWithProration) value.unitWithProration != null -> generator.writeObject(value.unitWithProration) value.groupedAllocation != null -> generator.writeObject(value.groupedAllocation) + value.bulkWithProration != null -> + generator.writeObject(value.bulkWithProration) value.groupedWithProratedMinimum != null -> generator.writeObject(value.groupedWithProratedMinimum) value.groupedWithMeteredMinimum != null -> @@ -3131,8 +3135,6 @@ private constructor( generator.writeObject(value.groupedWithMinMaxThresholds) value.matrixWithDisplayName != null -> generator.writeObject(value.matrixWithDisplayName) - value.bulkWithProration != null -> - generator.writeObject(value.bulkWithProration) value.groupedTieredPackage != null -> generator.writeObject(value.groupedTieredPackage) value.maxGroupTieredPackage != null -> @@ -3143,11 +3145,6 @@ private constructor( generator.writeObject(value.scalableMatrixWithTieredPricing) value.cumulativeGroupedBulk != null -> generator.writeObject(value.cumulativeGroupedBulk) - value.tieredPackageWithMinimum != null -> - generator.writeObject(value.tieredPackageWithMinimum) - value.matrixWithAllocation != null -> - generator.writeObject(value.matrixWithAllocation) - value.groupedTiered != null -> generator.writeObject(value.groupedTiered) value.minimum != null -> generator.writeObject(value.minimum) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid Price") @@ -3155,14 +3152,13 @@ private constructor( } } - class GroupedWithMinMaxThresholds + class TieredWithProration private constructor( private val cadence: JsonField, - private val groupedWithMinMaxThresholdsConfig: - JsonField, private val itemId: JsonField, private val modelType: JsonValue, private val name: JsonField, + private val tieredWithProrationConfig: JsonField, private val billableMetricId: JsonField, private val billedInAdvance: JsonField, private val billingCycleConfiguration: JsonField, @@ -3185,11 +3181,6 @@ private constructor( @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), - @JsonProperty("grouped_with_min_max_thresholds_config") - @ExcludeMissing - groupedWithMinMaxThresholdsConfig: - JsonField = - JsonMissing.of(), @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), @@ -3199,6 +3190,10 @@ private constructor( @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("tiered_with_proration_config") + @ExcludeMissing + tieredWithProrationConfig: JsonField = + JsonMissing.of(), @JsonProperty("billable_metric_id") @ExcludeMissing billableMetricId: JsonField = JsonMissing.of(), @@ -3243,10 +3238,10 @@ private constructor( referenceId: JsonField = JsonMissing.of(), ) : this( cadence, - groupedWithMinMaxThresholdsConfig, itemId, modelType, name, + tieredWithProrationConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -3272,16 +3267,6 @@ private constructor( */ fun cadence(): Cadence = cadence.getRequired("cadence") - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun groupedWithMinMaxThresholdsConfig(): GroupedWithMinMaxThresholdsConfig = - groupedWithMinMaxThresholdsConfig.getRequired( - "grouped_with_min_max_thresholds_config" - ) - /** * The id of the item the price will be associated with. * @@ -3292,9 +3277,11 @@ private constructor( fun itemId(): String = itemId.getRequired("item_id") /** + * The pricing model type + * * Expected to always return the following: * ```kotlin - * JsonValue.from("grouped_with_min_max_thresholds") + * JsonValue.from("tiered_with_proration") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -3311,6 +3298,16 @@ private constructor( */ fun name(): String = name.getRequired("name") + /** + * Configuration for tiered_with_proration pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun tieredWithProrationConfig(): TieredWithProrationConfig = + tieredWithProrationConfig.getRequired("tiered_with_proration_config") + /** * The id of the billable metric for the price. Only needed if the price is * usage-based. @@ -3440,17 +3437,6 @@ private constructor( @ExcludeMissing fun _cadence(): JsonField = cadence - /** - * Returns the raw JSON value of [groupedWithMinMaxThresholdsConfig]. - * - * Unlike [groupedWithMinMaxThresholdsConfig], this method doesn't throw if the JSON - * field has an unexpected type. - */ - @JsonProperty("grouped_with_min_max_thresholds_config") - @ExcludeMissing - fun _groupedWithMinMaxThresholdsConfig(): - JsonField = groupedWithMinMaxThresholdsConfig - /** * Returns the raw JSON value of [itemId]. * @@ -3467,6 +3453,17 @@ private constructor( */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + /** + * Returns the raw JSON value of [tieredWithProrationConfig]. + * + * Unlike [tieredWithProrationConfig], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("tiered_with_proration_config") + @ExcludeMissing + fun _tieredWithProrationConfig(): JsonField = + tieredWithProrationConfig + /** * Returns the raw JSON value of [billableMetricId]. * @@ -3616,30 +3613,28 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [GroupedWithMinMaxThresholds]. + * [TieredWithProration]. * * The following fields are required: * ```kotlin * .cadence() - * .groupedWithMinMaxThresholdsConfig() * .itemId() * .name() + * .tieredWithProrationConfig() * ``` */ fun builder() = Builder() } - /** A builder for [GroupedWithMinMaxThresholds]. */ + /** A builder for [TieredWithProration]. */ class Builder internal constructor() { private var cadence: JsonField? = null - private var groupedWithMinMaxThresholdsConfig: - JsonField? = - null private var itemId: JsonField? = null - private var modelType: JsonValue = - JsonValue.from("grouped_with_min_max_thresholds") + private var modelType: JsonValue = JsonValue.from("tiered_with_proration") private var name: JsonField? = null + private var tieredWithProrationConfig: JsonField? = + null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() private var billingCycleConfiguration: JsonField = @@ -3661,33 +3656,30 @@ private constructor( private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds) = - apply { - cadence = groupedWithMinMaxThresholds.cadence - groupedWithMinMaxThresholdsConfig = - groupedWithMinMaxThresholds.groupedWithMinMaxThresholdsConfig - itemId = groupedWithMinMaxThresholds.itemId - modelType = groupedWithMinMaxThresholds.modelType - name = groupedWithMinMaxThresholds.name - billableMetricId = groupedWithMinMaxThresholds.billableMetricId - billedInAdvance = groupedWithMinMaxThresholds.billedInAdvance - billingCycleConfiguration = - groupedWithMinMaxThresholds.billingCycleConfiguration - conversionRate = groupedWithMinMaxThresholds.conversionRate - conversionRateConfig = groupedWithMinMaxThresholds.conversionRateConfig - currency = groupedWithMinMaxThresholds.currency - dimensionalPriceConfiguration = - groupedWithMinMaxThresholds.dimensionalPriceConfiguration - externalPriceId = groupedWithMinMaxThresholds.externalPriceId - fixedPriceQuantity = groupedWithMinMaxThresholds.fixedPriceQuantity - invoiceGroupingKey = groupedWithMinMaxThresholds.invoiceGroupingKey - invoicingCycleConfiguration = - groupedWithMinMaxThresholds.invoicingCycleConfiguration - metadata = groupedWithMinMaxThresholds.metadata - referenceId = groupedWithMinMaxThresholds.referenceId - additionalProperties = - groupedWithMinMaxThresholds.additionalProperties.toMutableMap() - } + internal fun from(tieredWithProration: TieredWithProration) = apply { + cadence = tieredWithProration.cadence + itemId = tieredWithProration.itemId + modelType = tieredWithProration.modelType + name = tieredWithProration.name + tieredWithProrationConfig = tieredWithProration.tieredWithProrationConfig + billableMetricId = tieredWithProration.billableMetricId + billedInAdvance = tieredWithProration.billedInAdvance + billingCycleConfiguration = tieredWithProration.billingCycleConfiguration + conversionRate = tieredWithProration.conversionRate + conversionRateConfig = tieredWithProration.conversionRateConfig + currency = tieredWithProration.currency + dimensionalPriceConfiguration = + tieredWithProration.dimensionalPriceConfiguration + externalPriceId = tieredWithProration.externalPriceId + fixedPriceQuantity = tieredWithProration.fixedPriceQuantity + invoiceGroupingKey = tieredWithProration.invoiceGroupingKey + invoicingCycleConfiguration = + tieredWithProration.invoicingCycleConfiguration + metadata = tieredWithProration.metadata + referenceId = tieredWithProration.referenceId + additionalProperties = + tieredWithProration.additionalProperties.toMutableMap() + } /** The cadence to bill for this price on. */ fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) @@ -3701,28 +3693,6 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - fun groupedWithMinMaxThresholdsConfig( - groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig - ) = - groupedWithMinMaxThresholdsConfig( - JsonField.of(groupedWithMinMaxThresholdsConfig) - ) - - /** - * Sets [Builder.groupedWithMinMaxThresholdsConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.groupedWithMinMaxThresholdsConfig] with a - * well-typed [GroupedWithMinMaxThresholdsConfig] value instead. This method is - * primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun groupedWithMinMaxThresholdsConfig( - groupedWithMinMaxThresholdsConfig: - JsonField - ) = apply { - this.groupedWithMinMaxThresholdsConfig = groupedWithMinMaxThresholdsConfig - } - /** The id of the item the price will be associated with. */ fun itemId(itemId: String) = itemId(JsonField.of(itemId)) @@ -3741,7 +3711,7 @@ private constructor( * It is usually unnecessary to call this method because the field defaults to * the following: * ```kotlin - * JsonValue.from("grouped_with_min_max_thresholds") + * JsonValue.from("tiered_with_proration") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -3761,6 +3731,22 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } + /** Configuration for tiered_with_proration pricing */ + fun tieredWithProrationConfig( + tieredWithProrationConfig: TieredWithProrationConfig + ) = tieredWithProrationConfig(JsonField.of(tieredWithProrationConfig)) + + /** + * Sets [Builder.tieredWithProrationConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.tieredWithProrationConfig] with a well-typed + * [TieredWithProrationConfig] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun tieredWithProrationConfig( + tieredWithProrationConfig: JsonField + ) = apply { this.tieredWithProrationConfig = tieredWithProrationConfig } + /** * The id of the billable metric for the price. Only needed if the price is * usage-based. @@ -4090,30 +4076,27 @@ private constructor( } /** - * Returns an immutable instance of [GroupedWithMinMaxThresholds]. + * Returns an immutable instance of [TieredWithProration]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```kotlin * .cadence() - * .groupedWithMinMaxThresholdsConfig() * .itemId() * .name() + * .tieredWithProrationConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): GroupedWithMinMaxThresholds = - GroupedWithMinMaxThresholds( + fun build(): TieredWithProration = + TieredWithProration( checkRequired("cadence", cadence), - checkRequired( - "groupedWithMinMaxThresholdsConfig", - groupedWithMinMaxThresholdsConfig, - ), checkRequired("itemId", itemId), modelType, checkRequired("name", name), + checkRequired("tieredWithProrationConfig", tieredWithProrationConfig), billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -4133,20 +4116,20 @@ private constructor( private var validated: Boolean = false - fun validate(): GroupedWithMinMaxThresholds = apply { + fun validate(): TieredWithProration = apply { if (validated) { return@apply } cadence().validate() - groupedWithMinMaxThresholdsConfig().validate() itemId() _modelType().let { - if (it != JsonValue.from("grouped_with_min_max_thresholds")) { + if (it != JsonValue.from("tiered_with_proration")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } name() + tieredWithProrationConfig().validate() billableMetricId() billedInAdvance() billingCycleConfiguration()?.validate() @@ -4179,12 +4162,12 @@ private constructor( */ internal fun validity(): Int = (cadence.asKnown()?.validity() ?: 0) + - (groupedWithMinMaxThresholdsConfig.asKnown()?.validity() ?: 0) + (if (itemId.asKnown() == null) 0 else 1) + modelType.let { - if (it == JsonValue.from("grouped_with_min_max_thresholds")) 1 else 0 + if (it == JsonValue.from("tiered_with_proration")) 1 else 0 } + (if (name.asKnown() == null) 0 else 1) + + (tieredWithProrationConfig.asKnown()?.validity() ?: 0) + (if (billableMetricId.asKnown() == null) 0 else 1) + (if (billedInAdvance.asKnown() == null) 0 else 1) + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + @@ -4356,16 +4339,49 @@ private constructor( override fun toString() = value.toString() } - class GroupedWithMinMaxThresholdsConfig - @JsonCreator + /** Configuration for tiered_with_proration pricing */ + class TieredWithProrationConfig private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map + private val tiers: JsonField>, + private val additionalProperties: MutableMap, ) { + @JsonCreator + private constructor( + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of() + ) : this(tiers, mutableMapOf()) + + /** + * Tiers for rating based on total usage quantities into the specified tier with + * proration + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun tiers(): List = tiers.getRequired("tiers") + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) fun toBuilder() = Builder().from(this) @@ -4373,23 +4389,58 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [GroupedWithMinMaxThresholdsConfig]. + * [TieredWithProrationConfig]. + * + * The following fields are required: + * ```kotlin + * .tiers() + * ``` */ fun builder() = Builder() } - /** A builder for [GroupedWithMinMaxThresholdsConfig]. */ + /** A builder for [TieredWithProrationConfig]. */ class Builder internal constructor() { + private var tiers: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() - internal fun from( - groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig - ) = apply { - additionalProperties = - groupedWithMinMaxThresholdsConfig.additionalProperties - .toMutableMap() + internal fun from(tieredWithProrationConfig: TieredWithProrationConfig) = + apply { + tiers = tieredWithProrationConfig.tiers.map { it.toMutableList() } + additionalProperties = + tieredWithProrationConfig.additionalProperties.toMutableMap() + } + + /** + * Tiers for rating based on total usage quantities into the specified tier + * with proration + */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } } fun additionalProperties(additionalProperties: Map) = @@ -4415,21 +4466,32 @@ private constructor( } /** - * Returns an immutable instance of [GroupedWithMinMaxThresholdsConfig]. + * Returns an immutable instance of [TieredWithProrationConfig]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ - fun build(): GroupedWithMinMaxThresholdsConfig = - GroupedWithMinMaxThresholdsConfig(additionalProperties.toImmutable()) + fun build(): TieredWithProrationConfig = + TieredWithProrationConfig( + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false - fun validate(): GroupedWithMinMaxThresholdsConfig = apply { + fun validate(): TieredWithProrationConfig = apply { if (validated) { return@apply } + tiers().forEach { it.validate() } validated = true } @@ -4448,25 +4510,246 @@ private constructor( * Used for best match union deserialization. */ internal fun validity(): Int = - additionalProperties.count { (_, value) -> - !value.isNull() && !value.isMissing() + (tiers.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single tiered with proration tier */ + class Tier + private constructor( + private val tierLowerBound: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(tierLowerBound, unitAmount, mutableMapOf()) + + /** + * Inclusive tier starting value + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun tierLowerBound(): String = + tierLowerBound.getRequired("tier_lower_bound") + + /** + * Amount per unit + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Tier]. + * + * The following fields are required: + * ```kotlin + * .tierLowerBound() + * .unitAmount() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var tierLowerBound: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(tier: Tier) = apply { + tierLowerBound = tier.tierLowerBound + unitAmount = tier.unitAmount + additionalProperties = tier.additionalProperties.toMutableMap() + } + + /** Inclusive tier starting value */ + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + /** Amount per unit */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```kotlin + * .tierLowerBound() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("tierLowerBound", tierLowerBound), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + tierLowerBound() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (tierLowerBound.asKnown() == null) 0 else 1) + + (if (unitAmount.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + tierLowerBound == other.tierLowerBound && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties } + private val hashCode: Int by lazy { + Objects.hash(tierLowerBound, unitAmount, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is GroupedWithMinMaxThresholdsConfig && + return other is TieredWithProrationConfig && + tiers == other.tiers && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(tiers, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "GroupedWithMinMaxThresholdsConfig{additionalProperties=$additionalProperties}" + "TieredWithProrationConfig{tiers=$tiers, additionalProperties=$additionalProperties}" } /** @@ -4583,13 +4866,12 @@ private constructor( return true } - return other is GroupedWithMinMaxThresholds && + return other is TieredWithProration && cadence == other.cadence && - groupedWithMinMaxThresholdsConfig == - other.groupedWithMinMaxThresholdsConfig && itemId == other.itemId && modelType == other.modelType && name == other.name && + tieredWithProrationConfig == other.tieredWithProrationConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && @@ -4609,10 +4891,10 @@ private constructor( private val hashCode: Int by lazy { Objects.hash( cadence, - groupedWithMinMaxThresholdsConfig, itemId, modelType, name, + tieredWithProrationConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -4633,1048 +4915,1703 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "GroupedWithMinMaxThresholds{cadence=$cadence, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + "TieredWithProration{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredWithProrationConfig=$tieredWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - return other is AddPrice && - allocationPrice == other.allocationPrice && - planPhaseOrder == other.planPhaseOrder && - price == other.price && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(allocationPrice, planPhaseOrder, price, additionalProperties) - } + class GroupedWithMinMaxThresholds + private constructor( + private val cadence: JsonField, + private val groupedWithMinMaxThresholdsConfig: + JsonField, + private val itemId: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { - override fun hashCode(): Int = hashCode + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("grouped_with_min_max_thresholds_config") + @ExcludeMissing + groupedWithMinMaxThresholdsConfig: + JsonField = + JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + groupedWithMinMaxThresholdsConfig, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + mutableMapOf(), + ) - override fun toString() = - "AddPrice{allocationPrice=$allocationPrice, planPhaseOrder=$planPhaseOrder, price=$price, additionalProperties=$additionalProperties}" - } + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") - class RemoveAdjustment - private constructor( - private val adjustmentId: JsonField, - private val planPhaseOrder: JsonField, - private val additionalProperties: MutableMap, - ) { + /** + * Configuration for grouped_with_min_max_thresholds pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupedWithMinMaxThresholdsConfig(): GroupedWithMinMaxThresholdsConfig = + groupedWithMinMaxThresholdsConfig.getRequired( + "grouped_with_min_max_thresholds_config" + ) - @JsonCreator - private constructor( - @JsonProperty("adjustment_id") - @ExcludeMissing - adjustmentId: JsonField = JsonMissing.of(), - @JsonProperty("plan_phase_order") - @ExcludeMissing - planPhaseOrder: JsonField = JsonMissing.of(), - ) : this(adjustmentId, planPhaseOrder, mutableMapOf()) + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") - /** - * The id of the adjustment to remove from on the plan. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun adjustmentId(): String = adjustmentId.getRequired("adjustment_id") + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("grouped_with_min_max_thresholds") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType - /** - * The phase to remove this adjustment from. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun planPhaseOrder(): Long? = planPhaseOrder.getNullable("plan_phase_order") + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") - /** - * Returns the raw JSON value of [adjustmentId]. - * - * Unlike [adjustmentId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("adjustment_id") - @ExcludeMissing - fun _adjustmentId(): JsonField = adjustmentId + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = billableMetricId.getNullable("billable_metric_id") - /** - * Returns the raw JSON value of [planPhaseOrder]. - * - * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("plan_phase_order") - @ExcludeMissing - fun _planPhaseOrder(): JsonField = planPhaseOrder + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") - fun toBuilder() = Builder().from(this) + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") - companion object { - - /** - * Returns a mutable builder for constructing an instance of [RemoveAdjustment]. - * - * The following fields are required: - * ```kotlin - * .adjustmentId() - * ``` - */ - fun builder() = Builder() - } - - /** A builder for [RemoveAdjustment]. */ - class Builder internal constructor() { + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") - private var adjustmentId: JsonField? = null - private var planPhaseOrder: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") - internal fun from(removeAdjustment: RemoveAdjustment) = apply { - adjustmentId = removeAdjustment.adjustmentId - planPhaseOrder = removeAdjustment.planPhaseOrder - additionalProperties = removeAdjustment.additionalProperties.toMutableMap() - } + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") - /** The id of the adjustment to remove from on the plan. */ - fun adjustmentId(adjustmentId: String) = adjustmentId(JsonField.of(adjustmentId)) + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") - /** - * Sets [Builder.adjustmentId] to an arbitrary JSON value. - * - * You should usually call [Builder.adjustmentId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun adjustmentId(adjustmentId: JsonField) = apply { - this.adjustmentId = adjustmentId - } + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + invoiceGroupingKey.getNullable("invoice_grouping_key") - /** The phase to remove this adjustment from. */ - fun planPhaseOrder(planPhaseOrder: Long?) = - planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - /** - * Alias for [Builder.planPhaseOrder]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") - /** - * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. - * - * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun planPhaseOrder(planPhaseOrder: JsonField) = apply { - this.planPhaseOrder = planPhaseOrder - } + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * Returns the raw JSON value of [groupedWithMinMaxThresholdsConfig]. + * + * Unlike [groupedWithMinMaxThresholdsConfig], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("grouped_with_min_max_thresholds_config") + @ExcludeMissing + fun _groupedWithMinMaxThresholdsConfig(): + JsonField = groupedWithMinMaxThresholdsConfig - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId - /** - * Returns an immutable instance of [RemoveAdjustment]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```kotlin - * .adjustmentId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): RemoveAdjustment = - RemoveAdjustment( - checkRequired("adjustmentId", adjustmentId), - planPhaseOrder, - additionalProperties.toMutableMap(), - ) - } + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance - private var validated: Boolean = false + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration - fun validate(): RemoveAdjustment = apply { - if (validated) { - return@apply - } + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate - adjustmentId() - planPhaseOrder() - validated = true - } + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (if (adjustmentId.asKnown() == null) 0 else 1) + - (if (planPhaseOrder.asKnown() == null) 0 else 1) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration - return other is RemoveAdjustment && - adjustmentId == other.adjustmentId && - planPhaseOrder == other.planPhaseOrder && - additionalProperties == other.additionalProperties - } + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId - private val hashCode: Int by lazy { - Objects.hash(adjustmentId, planPhaseOrder, additionalProperties) - } + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - override fun hashCode(): Int = hashCode + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - override fun toString() = - "RemoveAdjustment{adjustmentId=$adjustmentId, planPhaseOrder=$planPhaseOrder, additionalProperties=$additionalProperties}" - } + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration - class RemovePrice - private constructor( - private val priceId: JsonField, - private val planPhaseOrder: JsonField, - private val additionalProperties: MutableMap, - ) { + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata - @JsonCreator - private constructor( - @JsonProperty("price_id") @ExcludeMissing priceId: JsonField = JsonMissing.of(), - @JsonProperty("plan_phase_order") - @ExcludeMissing - planPhaseOrder: JsonField = JsonMissing.of(), - ) : this(priceId, planPhaseOrder, mutableMapOf()) + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId - /** - * The id of the price to remove from the plan. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun priceId(): String = priceId.getRequired("price_id") + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - /** - * The phase to remove this price from. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun planPhaseOrder(): Long? = planPhaseOrder.getNullable("plan_phase_order") + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - /** - * Returns the raw JSON value of [priceId]. - * - * Unlike [priceId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId + fun toBuilder() = Builder().from(this) - /** - * Returns the raw JSON value of [planPhaseOrder]. - * - * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("plan_phase_order") - @ExcludeMissing - fun _planPhaseOrder(): JsonField = planPhaseOrder + companion object { - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** + * Returns a mutable builder for constructing an instance of + * [GroupedWithMinMaxThresholds]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .groupedWithMinMaxThresholdsConfig() + * .itemId() + * .name() + * ``` + */ + fun builder() = Builder() + } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** A builder for [GroupedWithMinMaxThresholds]. */ + class Builder internal constructor() { - fun toBuilder() = Builder().from(this) + private var cadence: JsonField? = null + private var groupedWithMinMaxThresholdsConfig: + JsonField? = + null + private var itemId: JsonField? = null + private var modelType: JsonValue = + JsonValue.from("grouped_with_min_max_thresholds") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - companion object { + internal fun from(groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds) = + apply { + cadence = groupedWithMinMaxThresholds.cadence + groupedWithMinMaxThresholdsConfig = + groupedWithMinMaxThresholds.groupedWithMinMaxThresholdsConfig + itemId = groupedWithMinMaxThresholds.itemId + modelType = groupedWithMinMaxThresholds.modelType + name = groupedWithMinMaxThresholds.name + billableMetricId = groupedWithMinMaxThresholds.billableMetricId + billedInAdvance = groupedWithMinMaxThresholds.billedInAdvance + billingCycleConfiguration = + groupedWithMinMaxThresholds.billingCycleConfiguration + conversionRate = groupedWithMinMaxThresholds.conversionRate + conversionRateConfig = groupedWithMinMaxThresholds.conversionRateConfig + currency = groupedWithMinMaxThresholds.currency + dimensionalPriceConfiguration = + groupedWithMinMaxThresholds.dimensionalPriceConfiguration + externalPriceId = groupedWithMinMaxThresholds.externalPriceId + fixedPriceQuantity = groupedWithMinMaxThresholds.fixedPriceQuantity + invoiceGroupingKey = groupedWithMinMaxThresholds.invoiceGroupingKey + invoicingCycleConfiguration = + groupedWithMinMaxThresholds.invoicingCycleConfiguration + metadata = groupedWithMinMaxThresholds.metadata + referenceId = groupedWithMinMaxThresholds.referenceId + additionalProperties = + groupedWithMinMaxThresholds.additionalProperties.toMutableMap() + } - /** - * Returns a mutable builder for constructing an instance of [RemovePrice]. - * - * The following fields are required: - * ```kotlin - * .priceId() - * ``` - */ - fun builder() = Builder() - } + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - /** A builder for [RemovePrice]. */ - class Builder internal constructor() { + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - private var priceId: JsonField? = null - private var planPhaseOrder: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + /** Configuration for grouped_with_min_max_thresholds pricing */ + fun groupedWithMinMaxThresholdsConfig( + groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + ) = + groupedWithMinMaxThresholdsConfig( + JsonField.of(groupedWithMinMaxThresholdsConfig) + ) - internal fun from(removePrice: RemovePrice) = apply { - priceId = removePrice.priceId - planPhaseOrder = removePrice.planPhaseOrder - additionalProperties = removePrice.additionalProperties.toMutableMap() - } - - /** The id of the price to remove from the plan. */ - fun priceId(priceId: String) = priceId(JsonField.of(priceId)) - - /** - * Sets [Builder.priceId] to an arbitrary JSON value. - * - * You should usually call [Builder.priceId] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun priceId(priceId: JsonField) = apply { this.priceId = priceId } + /** + * Sets [Builder.groupedWithMinMaxThresholdsConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.groupedWithMinMaxThresholdsConfig] with a + * well-typed [GroupedWithMinMaxThresholdsConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun groupedWithMinMaxThresholdsConfig( + groupedWithMinMaxThresholdsConfig: + JsonField + ) = apply { + this.groupedWithMinMaxThresholdsConfig = groupedWithMinMaxThresholdsConfig + } - /** The phase to remove this price from. */ - fun planPhaseOrder(planPhaseOrder: Long?) = - planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - /** - * Alias for [Builder.planPhaseOrder]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - /** - * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. - * - * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun planPhaseOrder(planPhaseOrder: JsonField) = apply { - this.planPhaseOrder = planPhaseOrder - } + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("grouped_with_min_max_thresholds") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) - /** - * Returns an immutable instance of [RemovePrice]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```kotlin - * .priceId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): RemovePrice = - RemovePrice( - checkRequired("priceId", priceId), - planPhaseOrder, - additionalProperties.toMutableMap(), - ) - } + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) - private var validated: Boolean = false + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } - fun validate(): RemovePrice = apply { - if (validated) { - return@apply - } + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - priceId() - planPhaseOrder() - validated = true - } + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (if (priceId.asKnown() == null) 0 else 1) + - (if (planPhaseOrder.asKnown() == null) 0 else 1) + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } - return other is RemovePrice && - priceId == other.priceId && - planPhaseOrder == other.planPhaseOrder && - additionalProperties == other.additionalProperties - } + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) - private val hashCode: Int by lazy { - Objects.hash(priceId, planPhaseOrder, additionalProperties) - } + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } - override fun hashCode(): Int = hashCode + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) - override fun toString() = - "RemovePrice{priceId=$priceId, planPhaseOrder=$planPhaseOrder, additionalProperties=$additionalProperties}" - } - - class ReplaceAdjustment - private constructor( - private val adjustment: JsonField, - private val replacesAdjustmentId: JsonField, - private val planPhaseOrder: JsonField, - private val additionalProperties: MutableMap, - ) { + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) - @JsonCreator - private constructor( - @JsonProperty("adjustment") - @ExcludeMissing - adjustment: JsonField = JsonMissing.of(), - @JsonProperty("replaces_adjustment_id") - @ExcludeMissing - replacesAdjustmentId: JsonField = JsonMissing.of(), - @JsonProperty("plan_phase_order") - @ExcludeMissing - planPhaseOrder: JsonField = JsonMissing.of(), - ) : this(adjustment, replacesAdjustmentId, planPhaseOrder, mutableMapOf()) + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) - /** - * The definition of a new adjustment to create and add to the plan. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun adjustment(): Adjustment = adjustment.getRequired("adjustment") + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) - /** - * The id of the adjustment on the plan to replace in the plan. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun replacesAdjustmentId(): String = - replacesAdjustmentId.getRequired("replaces_adjustment_id") + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) - /** - * The phase to replace this adjustment from. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun planPhaseOrder(): Long? = planPhaseOrder.getNullable("plan_phase_order") + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } - /** - * Returns the raw JSON value of [adjustment]. - * - * Unlike [adjustment], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("adjustment") - @ExcludeMissing - fun _adjustment(): JsonField = adjustment + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) - /** - * Returns the raw JSON value of [replacesAdjustmentId]. - * - * Unlike [replacesAdjustmentId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("replaces_adjustment_id") - @ExcludeMissing - fun _replacesAdjustmentId(): JsonField = replacesAdjustmentId + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } - /** - * Returns the raw JSON value of [planPhaseOrder]. - * - * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("plan_phase_order") - @ExcludeMissing - fun _planPhaseOrder(): JsonField = planPhaseOrder + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) - fun toBuilder() = Builder().from(this) + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) - companion object { + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } - /** - * Returns a mutable builder for constructing an instance of [ReplaceAdjustment]. - * - * The following fields are required: - * ```kotlin - * .adjustment() - * .replacesAdjustmentId() - * ``` - */ - fun builder() = Builder() - } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) - /** A builder for [ReplaceAdjustment]. */ - class Builder internal constructor() { + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } - private var adjustment: JsonField? = null - private var replacesAdjustmentId: JsonField? = null - private var planPhaseOrder: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) - internal fun from(replaceAdjustment: ReplaceAdjustment) = apply { - adjustment = replaceAdjustment.adjustment - replacesAdjustmentId = replaceAdjustment.replacesAdjustmentId - planPhaseOrder = replaceAdjustment.planPhaseOrder - additionalProperties = replaceAdjustment.additionalProperties.toMutableMap() - } + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - /** The definition of a new adjustment to create and add to the plan. */ - fun adjustment(adjustment: Adjustment) = adjustment(JsonField.of(adjustment)) + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - /** - * Sets [Builder.adjustment] to an arbitrary JSON value. - * - * You should usually call [Builder.adjustment] with a well-typed [Adjustment] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun adjustment(adjustment: JsonField) = apply { - this.adjustment = adjustment - } + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - /** - * Alias for calling [adjustment] with - * `Adjustment.ofPercentageDiscount(percentageDiscount)`. - */ - fun adjustment(percentageDiscount: NewPercentageDiscount) = - adjustment(Adjustment.ofPercentageDiscount(percentageDiscount)) + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) - /** - * Alias for calling [adjustment] with the following: - * ```kotlin - * NewPercentageDiscount.builder() - * .adjustmentType(NewPercentageDiscount.AdjustmentType.PERCENTAGE_DISCOUNT) - * .percentageDiscount(percentageDiscount) - * .build() - * ``` - */ - fun percentageDiscountAdjustment(percentageDiscount: Double) = - adjustment( - NewPercentageDiscount.builder() - .adjustmentType(NewPercentageDiscount.AdjustmentType.PERCENTAGE_DISCOUNT) - .percentageDiscount(percentageDiscount) - .build() - ) + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } - /** Alias for calling [adjustment] with `Adjustment.ofUsageDiscount(usageDiscount)`. */ - fun adjustment(usageDiscount: NewUsageDiscount) = - adjustment(Adjustment.ofUsageDiscount(usageDiscount)) + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** - * Alias for calling [adjustment] with the following: - * ```kotlin - * NewUsageDiscount.builder() - * .adjustmentType(NewUsageDiscount.AdjustmentType.USAGE_DISCOUNT) - * .usageDiscount(usageDiscount) - * .build() - * ``` - */ - fun usageDiscountAdjustment(usageDiscount: Double) = - adjustment( - NewUsageDiscount.builder() - .adjustmentType(NewUsageDiscount.AdjustmentType.USAGE_DISCOUNT) - .usageDiscount(usageDiscount) - .build() - ) + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * Alias for calling [adjustment] with `Adjustment.ofAmountDiscount(amountDiscount)`. - */ - fun adjustment(amountDiscount: NewAmountDiscount) = - adjustment(Adjustment.ofAmountDiscount(amountDiscount)) + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - /** - * Alias for calling [adjustment] with the following: - * ```kotlin - * NewAmountDiscount.builder() - * .adjustmentType(NewAmountDiscount.AdjustmentType.AMOUNT_DISCOUNT) - * .amountDiscount(amountDiscount) - * .build() - * ``` - */ - fun amountDiscountAdjustment(amountDiscount: String) = - adjustment( - NewAmountDiscount.builder() - .adjustmentType(NewAmountDiscount.AdjustmentType.AMOUNT_DISCOUNT) - .amountDiscount(amountDiscount) - .build() - ) + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - /** Alias for calling [adjustment] with `Adjustment.ofMinimum(minimum)`. */ - fun adjustment(minimum: NewMinimum) = adjustment(Adjustment.ofMinimum(minimum)) + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - /** Alias for calling [adjustment] with `Adjustment.ofMaximum(maximum)`. */ - fun adjustment(maximum: NewMaximum) = adjustment(Adjustment.ofMaximum(maximum)) + /** + * Returns an immutable instance of [GroupedWithMinMaxThresholds]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .groupedWithMinMaxThresholdsConfig() + * .itemId() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedWithMinMaxThresholds = + GroupedWithMinMaxThresholds( + checkRequired("cadence", cadence), + checkRequired( + "groupedWithMinMaxThresholdsConfig", + groupedWithMinMaxThresholdsConfig, + ), + checkRequired("itemId", itemId), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } - /** - * Alias for calling [adjustment] with the following: - * ```kotlin - * NewMaximum.builder() - * .adjustmentType(NewMaximum.AdjustmentType.MAXIMUM) - * .maximumAmount(maximumAmount) - * .build() - * ``` - */ - fun maximumAdjustment(maximumAmount: String) = - adjustment( - NewMaximum.builder() - .adjustmentType(NewMaximum.AdjustmentType.MAXIMUM) - .maximumAmount(maximumAmount) - .build() - ) + private var validated: Boolean = false - /** The id of the adjustment on the plan to replace in the plan. */ - fun replacesAdjustmentId(replacesAdjustmentId: String) = - replacesAdjustmentId(JsonField.of(replacesAdjustmentId)) + fun validate(): GroupedWithMinMaxThresholds = apply { + if (validated) { + return@apply + } - /** - * Sets [Builder.replacesAdjustmentId] to an arbitrary JSON value. - * - * You should usually call [Builder.replacesAdjustmentId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun replacesAdjustmentId(replacesAdjustmentId: JsonField) = apply { - this.replacesAdjustmentId = replacesAdjustmentId - } + cadence().validate() + groupedWithMinMaxThresholdsConfig().validate() + itemId() + _modelType().let { + if (it != JsonValue.from("grouped_with_min_max_thresholds")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + metadata()?.validate() + referenceId() + validated = true + } - /** The phase to replace this adjustment from. */ - fun planPhaseOrder(planPhaseOrder: Long?) = - planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - /** - * Alias for [Builder.planPhaseOrder]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (groupedWithMinMaxThresholdsConfig.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + modelType.let { + if (it == JsonValue.from("grouped_with_min_max_thresholds")) 1 else 0 + } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) - /** - * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. - * - * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun planPhaseOrder(planPhaseOrder: JsonField) = apply { - this.planPhaseOrder = planPhaseOrder - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + companion object { - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + val ANNUAL = of("annual") - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + val SEMI_ANNUAL = of("semi_annual") - /** - * Returns an immutable instance of [ReplaceAdjustment]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```kotlin - * .adjustment() - * .replacesAdjustmentId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): ReplaceAdjustment = - ReplaceAdjustment( - checkRequired("adjustment", adjustment), - checkRequired("replacesAdjustmentId", replacesAdjustmentId), - planPhaseOrder, - additionalProperties.toMutableMap(), - ) - } + val MONTHLY = of("monthly") - private var validated: Boolean = false + val QUARTERLY = of("quarterly") - fun validate(): ReplaceAdjustment = apply { - if (validated) { - return@apply - } + val ONE_TIME = of("one_time") - adjustment().validate() - replacesAdjustmentId() - planPhaseOrder() - validated = true - } + val CUSTOM = of("custom") - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + fun of(value: String) = Cadence(JsonField.of(value)) + } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (adjustment.asKnown()?.validity() ?: 0) + - (if (replacesAdjustmentId.asKnown() == null) 0 else 1) + - (if (planPhaseOrder.asKnown() == null) 0 else 1) + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } - /** The definition of a new adjustment to create and add to the plan. */ - @JsonDeserialize(using = Adjustment.Deserializer::class) - @JsonSerialize(using = Adjustment.Serializer::class) - class Adjustment - private constructor( - private val percentageDiscount: NewPercentageDiscount? = null, - private val usageDiscount: NewUsageDiscount? = null, - private val amountDiscount: NewAmountDiscount? = null, - private val minimum: NewMinimum? = null, - private val maximum: NewMaximum? = null, - private val _json: JsonValue? = null, - ) { + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } - fun percentageDiscount(): NewPercentageDiscount? = percentageDiscount + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } - fun usageDiscount(): NewUsageDiscount? = usageDiscount + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } - fun amountDiscount(): NewAmountDiscount? = amountDiscount + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") - fun minimum(): NewMinimum? = minimum + private var validated: Boolean = false - fun maximum(): NewMaximum? = maximum + fun validate(): Cadence = apply { + if (validated) { + return@apply + } - fun isPercentageDiscount(): Boolean = percentageDiscount != null + known() + validated = true + } - fun isUsageDiscount(): Boolean = usageDiscount != null + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - fun isAmountDiscount(): Boolean = amountDiscount != null + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - fun isMinimum(): Boolean = minimum != null + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun isMaximum(): Boolean = maximum != null + return other is Cadence && value == other.value + } - fun asPercentageDiscount(): NewPercentageDiscount = - percentageDiscount.getOrThrow("percentageDiscount") + override fun hashCode() = value.hashCode() - fun asUsageDiscount(): NewUsageDiscount = usageDiscount.getOrThrow("usageDiscount") + override fun toString() = value.toString() + } - fun asAmountDiscount(): NewAmountDiscount = amountDiscount.getOrThrow("amountDiscount") + /** Configuration for grouped_with_min_max_thresholds pricing */ + class GroupedWithMinMaxThresholdsConfig + private constructor( + private val groupingKey: JsonField, + private val maximumCharge: JsonField, + private val minimumCharge: JsonField, + private val perUnitRate: JsonField, + private val additionalProperties: MutableMap, + ) { - fun asMinimum(): NewMinimum = minimum.getOrThrow("minimum") + @JsonCreator + private constructor( + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("maximum_charge") + @ExcludeMissing + maximumCharge: JsonField = JsonMissing.of(), + @JsonProperty("minimum_charge") + @ExcludeMissing + minimumCharge: JsonField = JsonMissing.of(), + @JsonProperty("per_unit_rate") + @ExcludeMissing + perUnitRate: JsonField = JsonMissing.of(), + ) : this(groupingKey, maximumCharge, minimumCharge, perUnitRate, mutableMapOf()) - fun asMaximum(): NewMaximum = maximum.getOrThrow("maximum") + /** + * The event property used to group before applying thresholds + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") - fun _json(): JsonValue? = _json + /** + * The maximum amount to charge each group + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun maximumCharge(): String = maximumCharge.getRequired("maximum_charge") - fun accept(visitor: Visitor): T = - when { - percentageDiscount != null -> - visitor.visitPercentageDiscount(percentageDiscount) - usageDiscount != null -> visitor.visitUsageDiscount(usageDiscount) - amountDiscount != null -> visitor.visitAmountDiscount(amountDiscount) - minimum != null -> visitor.visitMinimum(minimum) - maximum != null -> visitor.visitMaximum(maximum) - else -> visitor.unknown(_json) - } + /** + * The minimum amount to charge each group, regardless of usage + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun minimumCharge(): String = minimumCharge.getRequired("minimum_charge") - private var validated: Boolean = false - - fun validate(): Adjustment = apply { - if (validated) { - return@apply - } + /** + * The base price charged per group + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun perUnitRate(): String = perUnitRate.getRequired("per_unit_rate") - accept( - object : Visitor { - override fun visitPercentageDiscount( - percentageDiscount: NewPercentageDiscount - ) { - percentageDiscount.validate() - } + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey - override fun visitUsageDiscount(usageDiscount: NewUsageDiscount) { - usageDiscount.validate() - } + /** + * Returns the raw JSON value of [maximumCharge]. + * + * Unlike [maximumCharge], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("maximum_charge") + @ExcludeMissing + fun _maximumCharge(): JsonField = maximumCharge - override fun visitAmountDiscount(amountDiscount: NewAmountDiscount) { - amountDiscount.validate() - } + /** + * Returns the raw JSON value of [minimumCharge]. + * + * Unlike [minimumCharge], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("minimum_charge") + @ExcludeMissing + fun _minimumCharge(): JsonField = minimumCharge - override fun visitMinimum(minimum: NewMinimum) { - minimum.validate() - } + /** + * Returns the raw JSON value of [perUnitRate]. + * + * Unlike [perUnitRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("per_unit_rate") + @ExcludeMissing + fun _perUnitRate(): JsonField = perUnitRate - override fun visitMaximum(maximum: NewMaximum) { - maximum.validate() - } + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) } - ) - validated = true - } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitPercentageDiscount( - percentageDiscount: NewPercentageDiscount - ) = percentageDiscount.validity() + fun toBuilder() = Builder().from(this) - override fun visitUsageDiscount(usageDiscount: NewUsageDiscount) = - usageDiscount.validity() + companion object { - override fun visitAmountDiscount(amountDiscount: NewAmountDiscount) = - amountDiscount.validity() + /** + * Returns a mutable builder for constructing an instance of + * [GroupedWithMinMaxThresholdsConfig]. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .maximumCharge() + * .minimumCharge() + * .perUnitRate() + * ``` + */ + fun builder() = Builder() + } - override fun visitMinimum(minimum: NewMinimum) = minimum.validity() + /** A builder for [GroupedWithMinMaxThresholdsConfig]. */ + class Builder internal constructor() { - override fun visitMaximum(maximum: NewMaximum) = maximum.validity() + private var groupingKey: JsonField? = null + private var maximumCharge: JsonField? = null + private var minimumCharge: JsonField? = null + private var perUnitRate: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() - override fun unknown(json: JsonValue?) = 0 - } - ) + internal fun from( + groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + ) = apply { + groupingKey = groupedWithMinMaxThresholdsConfig.groupingKey + maximumCharge = groupedWithMinMaxThresholdsConfig.maximumCharge + minimumCharge = groupedWithMinMaxThresholdsConfig.minimumCharge + perUnitRate = groupedWithMinMaxThresholdsConfig.perUnitRate + additionalProperties = + groupedWithMinMaxThresholdsConfig.additionalProperties + .toMutableMap() + } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** The event property used to group before applying thresholds */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) - return other is Adjustment && - percentageDiscount == other.percentageDiscount && - usageDiscount == other.usageDiscount && - amountDiscount == other.amountDiscount && - minimum == other.minimum && - maximum == other.maximum - } + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } - override fun hashCode(): Int = - Objects.hash(percentageDiscount, usageDiscount, amountDiscount, minimum, maximum) + /** The maximum amount to charge each group */ + fun maximumCharge(maximumCharge: String) = + maximumCharge(JsonField.of(maximumCharge)) - override fun toString(): String = - when { - percentageDiscount != null -> - "Adjustment{percentageDiscount=$percentageDiscount}" - usageDiscount != null -> "Adjustment{usageDiscount=$usageDiscount}" - amountDiscount != null -> "Adjustment{amountDiscount=$amountDiscount}" - minimum != null -> "Adjustment{minimum=$minimum}" - maximum != null -> "Adjustment{maximum=$maximum}" - _json != null -> "Adjustment{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Adjustment") - } + /** + * Sets [Builder.maximumCharge] to an arbitrary JSON value. + * + * You should usually call [Builder.maximumCharge] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun maximumCharge(maximumCharge: JsonField) = apply { + this.maximumCharge = maximumCharge + } - companion object { + /** The minimum amount to charge each group, regardless of usage */ + fun minimumCharge(minimumCharge: String) = + minimumCharge(JsonField.of(minimumCharge)) - fun ofPercentageDiscount(percentageDiscount: NewPercentageDiscount) = - Adjustment(percentageDiscount = percentageDiscount) + /** + * Sets [Builder.minimumCharge] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumCharge] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun minimumCharge(minimumCharge: JsonField) = apply { + this.minimumCharge = minimumCharge + } - fun ofUsageDiscount(usageDiscount: NewUsageDiscount) = - Adjustment(usageDiscount = usageDiscount) + /** The base price charged per group */ + fun perUnitRate(perUnitRate: String) = + perUnitRate(JsonField.of(perUnitRate)) - fun ofAmountDiscount(amountDiscount: NewAmountDiscount) = - Adjustment(amountDiscount = amountDiscount) + /** + * Sets [Builder.perUnitRate] to an arbitrary JSON value. + * + * You should usually call [Builder.perUnitRate] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun perUnitRate(perUnitRate: JsonField) = apply { + this.perUnitRate = perUnitRate + } - fun ofMinimum(minimum: NewMinimum) = Adjustment(minimum = minimum) + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun ofMaximum(maximum: NewMaximum) = Adjustment(maximum = maximum) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * An interface that defines how to map each variant of [Adjustment] to a value of type - * [T]. - */ - interface Visitor { + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun visitPercentageDiscount(percentageDiscount: NewPercentageDiscount): T + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun visitUsageDiscount(usageDiscount: NewUsageDiscount): T + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - fun visitAmountDiscount(amountDiscount: NewAmountDiscount): T + /** + * Returns an immutable instance of [GroupedWithMinMaxThresholdsConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .maximumCharge() + * .minimumCharge() + * .perUnitRate() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedWithMinMaxThresholdsConfig = + GroupedWithMinMaxThresholdsConfig( + checkRequired("groupingKey", groupingKey), + checkRequired("maximumCharge", maximumCharge), + checkRequired("minimumCharge", minimumCharge), + checkRequired("perUnitRate", perUnitRate), + additionalProperties.toMutableMap(), + ) + } - fun visitMinimum(minimum: NewMinimum): T + private var validated: Boolean = false - fun visitMaximum(maximum: NewMaximum): T + fun validate(): GroupedWithMinMaxThresholdsConfig = apply { + if (validated) { + return@apply + } - /** - * Maps an unknown variant of [Adjustment] to a value of type [T]. - * - * An instance of [Adjustment] can contain an unknown variant if it was deserialized - * from data that doesn't match any known variant. For example, if the SDK is on an - * older version than the API, then the API may respond with new variants that the - * SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown Adjustment: $json") - } - } + groupingKey() + maximumCharge() + minimumCharge() + perUnitRate() + validated = true + } - internal class Deserializer : BaseDeserializer(Adjustment::class) { + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - override fun ObjectCodec.deserialize(node: JsonNode): Adjustment { - val json = JsonValue.fromJsonNode(node) - val adjustmentType = json.asObject()?.get("adjustment_type")?.asString() + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (groupingKey.asKnown() == null) 0 else 1) + + (if (maximumCharge.asKnown() == null) 0 else 1) + + (if (minimumCharge.asKnown() == null) 0 else 1) + + (if (perUnitRate.asKnown() == null) 0 else 1) - when (adjustmentType) { - "percentage_discount" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Adjustment(percentageDiscount = it, _json = json) } - ?: Adjustment(_json = json) - } - "usage_discount" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(usageDiscount = it, _json = json) - } ?: Adjustment(_json = json) - } - "amount_discount" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(amountDiscount = it, _json = json) - } ?: Adjustment(_json = json) - } - "minimum" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(minimum = it, _json = json) - } ?: Adjustment(_json = json) - } - "maximum" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(maximum = it, _json = json) - } ?: Adjustment(_json = json) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } + + return other is GroupedWithMinMaxThresholdsConfig && + groupingKey == other.groupingKey && + maximumCharge == other.maximumCharge && + minimumCharge == other.minimumCharge && + perUnitRate == other.perUnitRate && + additionalProperties == other.additionalProperties } - return Adjustment(_json = json) - } - } + private val hashCode: Int by lazy { + Objects.hash( + groupingKey, + maximumCharge, + minimumCharge, + perUnitRate, + additionalProperties, + ) + } - internal class Serializer : BaseSerializer(Adjustment::class) { + override fun hashCode(): Int = hashCode - override fun serialize( - value: Adjustment, - generator: JsonGenerator, - provider: SerializerProvider, + override fun toString() = + "GroupedWithMinMaxThresholdsConfig{groupingKey=$groupingKey, maximumCharge=$maximumCharge, minimumCharge=$minimumCharge, perUnitRate=$perUnitRate, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map ) { - when { - value.percentageDiscount != null -> - generator.writeObject(value.percentageDiscount) - value.usageDiscount != null -> generator.writeObject(value.usageDiscount) - value.amountDiscount != null -> generator.writeObject(value.amountDiscount) - value.minimum != null -> generator.writeObject(value.minimum) - value.maximum != null -> generator.writeObject(value.maximum) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Adjustment") + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } + + return other is GroupedWithMinMaxThresholds && + cadence == other.cadence && + groupedWithMinMaxThresholdsConfig == + other.groupedWithMinMaxThresholdsConfig && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + groupedWithMinMaxThresholdsConfig, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties, + ) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedWithMinMaxThresholds{cadence=$cadence, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } } @@ -5683,64 +6620,50 @@ private constructor( return true } - return other is ReplaceAdjustment && - adjustment == other.adjustment && - replacesAdjustmentId == other.replacesAdjustmentId && + return other is AddPrice && + allocationPrice == other.allocationPrice && planPhaseOrder == other.planPhaseOrder && + price == other.price && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(adjustment, replacesAdjustmentId, planPhaseOrder, additionalProperties) + Objects.hash(allocationPrice, planPhaseOrder, price, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "ReplaceAdjustment{adjustment=$adjustment, replacesAdjustmentId=$replacesAdjustmentId, planPhaseOrder=$planPhaseOrder, additionalProperties=$additionalProperties}" + "AddPrice{allocationPrice=$allocationPrice, planPhaseOrder=$planPhaseOrder, price=$price, additionalProperties=$additionalProperties}" } - class ReplacePrice + class RemoveAdjustment private constructor( - private val replacesPriceId: JsonField, - private val allocationPrice: JsonField, + private val adjustmentId: JsonField, private val planPhaseOrder: JsonField, - private val price: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("replaces_price_id") - @ExcludeMissing - replacesPriceId: JsonField = JsonMissing.of(), - @JsonProperty("allocation_price") + @JsonProperty("adjustment_id") @ExcludeMissing - allocationPrice: JsonField = JsonMissing.of(), + adjustmentId: JsonField = JsonMissing.of(), @JsonProperty("plan_phase_order") @ExcludeMissing planPhaseOrder: JsonField = JsonMissing.of(), - @JsonProperty("price") @ExcludeMissing price: JsonField = JsonMissing.of(), - ) : this(replacesPriceId, allocationPrice, planPhaseOrder, price, mutableMapOf()) + ) : this(adjustmentId, planPhaseOrder, mutableMapOf()) /** - * The id of the price on the plan to replace in the plan. + * The id of the adjustment to remove from on the plan. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ - fun replacesPriceId(): String = replacesPriceId.getRequired("replaces_price_id") - - /** - * The allocation price to add to the plan. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun allocationPrice(): NewAllocationPrice? = allocationPrice.getNullable("allocation_price") + fun adjustmentId(): String = adjustmentId.getRequired("adjustment_id") /** - * The phase to replace this price from. + * The phase to remove this adjustment from. * * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -5748,32 +6671,14 @@ private constructor( fun planPhaseOrder(): Long? = planPhaseOrder.getNullable("plan_phase_order") /** - * The price to add to the plan - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun price(): Price? = price.getNullable("price") - - /** - * Returns the raw JSON value of [replacesPriceId]. - * - * Unlike [replacesPriceId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("replaces_price_id") - @ExcludeMissing - fun _replacesPriceId(): JsonField = replacesPriceId - - /** - * Returns the raw JSON value of [allocationPrice]. + * Returns the raw JSON value of [adjustmentId]. * - * Unlike [allocationPrice], this method doesn't throw if the JSON field has an unexpected + * Unlike [adjustmentId], this method doesn't throw if the JSON field has an unexpected * type. */ - @JsonProperty("allocation_price") + @JsonProperty("adjustment_id") @ExcludeMissing - fun _allocationPrice(): JsonField = allocationPrice + fun _adjustmentId(): JsonField = adjustmentId /** * Returns the raw JSON value of [planPhaseOrder]. @@ -5785,13 +6690,6 @@ private constructor( @ExcludeMissing fun _planPhaseOrder(): JsonField = planPhaseOrder - /** - * Returns the raw JSON value of [price]. - * - * Unlike [price], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("price") @ExcludeMissing fun _price(): JsonField = price - @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -5807,64 +6705,44 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [ReplacePrice]. + * Returns a mutable builder for constructing an instance of [RemoveAdjustment]. * * The following fields are required: * ```kotlin - * .replacesPriceId() + * .adjustmentId() * ``` */ fun builder() = Builder() } - /** A builder for [ReplacePrice]. */ + /** A builder for [RemoveAdjustment]. */ class Builder internal constructor() { - private var replacesPriceId: JsonField? = null - private var allocationPrice: JsonField = JsonMissing.of() + private var adjustmentId: JsonField? = null private var planPhaseOrder: JsonField = JsonMissing.of() - private var price: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(replacePrice: ReplacePrice) = apply { - replacesPriceId = replacePrice.replacesPriceId - allocationPrice = replacePrice.allocationPrice - planPhaseOrder = replacePrice.planPhaseOrder - price = replacePrice.price - additionalProperties = replacePrice.additionalProperties.toMutableMap() + internal fun from(removeAdjustment: RemoveAdjustment) = apply { + adjustmentId = removeAdjustment.adjustmentId + planPhaseOrder = removeAdjustment.planPhaseOrder + additionalProperties = removeAdjustment.additionalProperties.toMutableMap() } - /** The id of the price on the plan to replace in the plan. */ - fun replacesPriceId(replacesPriceId: String) = - replacesPriceId(JsonField.of(replacesPriceId)) + /** The id of the adjustment to remove from on the plan. */ + fun adjustmentId(adjustmentId: String) = adjustmentId(JsonField.of(adjustmentId)) /** - * Sets [Builder.replacesPriceId] to an arbitrary JSON value. + * Sets [Builder.adjustmentId] to an arbitrary JSON value. * - * You should usually call [Builder.replacesPriceId] with a well-typed [String] value + * You should usually call [Builder.adjustmentId] with a well-typed [String] value * instead. This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun replacesPriceId(replacesPriceId: JsonField) = apply { - this.replacesPriceId = replacesPriceId - } - - /** The allocation price to add to the plan. */ - fun allocationPrice(allocationPrice: NewAllocationPrice?) = - allocationPrice(JsonField.ofNullable(allocationPrice)) - - /** - * Sets [Builder.allocationPrice] to an arbitrary JSON value. - * - * You should usually call [Builder.allocationPrice] with a well-typed - * [NewAllocationPrice] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun allocationPrice(allocationPrice: JsonField) = apply { - this.allocationPrice = allocationPrice + fun adjustmentId(adjustmentId: JsonField) = apply { + this.adjustmentId = adjustmentId } - /** The phase to replace this price from. */ + /** The phase to remove this adjustment from. */ fun planPhaseOrder(planPhaseOrder: Long?) = planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) @@ -5886,159 +6764,6 @@ private constructor( this.planPhaseOrder = planPhaseOrder } - /** The price to add to the plan */ - fun price(price: Price?) = price(JsonField.ofNullable(price)) - - /** - * Sets [Builder.price] to an arbitrary JSON value. - * - * You should usually call [Builder.price] with a well-typed [Price] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun price(price: JsonField) = apply { this.price = price } - - /** Alias for calling [price] with `Price.ofUnit(unit)`. */ - fun price(unit: NewPlanUnitPrice) = price(Price.ofUnit(unit)) - - /** Alias for calling [price] with `Price.ofPackage(package_)`. */ - fun price(package_: NewPlanPackagePrice) = price(Price.ofPackage(package_)) - - /** Alias for calling [price] with `Price.ofMatrix(matrix)`. */ - fun price(matrix: NewPlanMatrixPrice) = price(Price.ofMatrix(matrix)) - - /** Alias for calling [price] with `Price.ofTiered(tiered)`. */ - fun price(tiered: NewPlanTieredPrice) = price(Price.ofTiered(tiered)) - - /** Alias for calling [price] with `Price.ofBulk(bulk)`. */ - fun price(bulk: NewPlanBulkPrice) = price(Price.ofBulk(bulk)) - - /** - * Alias for calling [price] with `Price.ofThresholdTotalAmount(thresholdTotalAmount)`. - */ - fun price(thresholdTotalAmount: NewPlanThresholdTotalAmountPrice) = - price(Price.ofThresholdTotalAmount(thresholdTotalAmount)) - - /** Alias for calling [price] with `Price.ofTieredPackage(tieredPackage)`. */ - fun price(tieredPackage: NewPlanTieredPackagePrice) = - price(Price.ofTieredPackage(tieredPackage)) - - /** Alias for calling [price] with `Price.ofTieredWithMinimum(tieredWithMinimum)`. */ - fun price(tieredWithMinimum: NewPlanTieredWithMinimumPrice) = - price(Price.ofTieredWithMinimum(tieredWithMinimum)) - - /** Alias for calling [price] with `Price.ofUnitWithPercent(unitWithPercent)`. */ - fun price(unitWithPercent: NewPlanUnitWithPercentPrice) = - price(Price.ofUnitWithPercent(unitWithPercent)) - - /** - * Alias for calling [price] with - * `Price.ofPackageWithAllocation(packageWithAllocation)`. - */ - fun price(packageWithAllocation: NewPlanPackageWithAllocationPrice) = - price(Price.ofPackageWithAllocation(packageWithAllocation)) - - /** - * Alias for calling [price] with `Price.ofTieredWithProration(tieredWithProration)`. - */ - fun price(tieredWithProration: NewPlanTierWithProrationPrice) = - price(Price.ofTieredWithProration(tieredWithProration)) - - /** Alias for calling [price] with `Price.ofUnitWithProration(unitWithProration)`. */ - fun price(unitWithProration: NewPlanUnitWithProrationPrice) = - price(Price.ofUnitWithProration(unitWithProration)) - - /** Alias for calling [price] with `Price.ofGroupedAllocation(groupedAllocation)`. */ - fun price(groupedAllocation: NewPlanGroupedAllocationPrice) = - price(Price.ofGroupedAllocation(groupedAllocation)) - - /** - * Alias for calling [price] with - * `Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)`. - */ - fun price(groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice) = - price(Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)) - - /** - * Alias for calling [price] with - * `Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)`. - */ - fun price(groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice) = - price(Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)) - - /** - * Alias for calling [price] with - * `Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)`. - */ - fun price(groupedWithMinMaxThresholds: Price.GroupedWithMinMaxThresholds) = - price(Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)) - - /** - * Alias for calling [price] with - * `Price.ofMatrixWithDisplayName(matrixWithDisplayName)`. - */ - fun price(matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice) = - price(Price.ofMatrixWithDisplayName(matrixWithDisplayName)) - - /** Alias for calling [price] with `Price.ofBulkWithProration(bulkWithProration)`. */ - fun price(bulkWithProration: NewPlanBulkWithProrationPrice) = - price(Price.ofBulkWithProration(bulkWithProration)) - - /** - * Alias for calling [price] with `Price.ofGroupedTieredPackage(groupedTieredPackage)`. - */ - fun price(groupedTieredPackage: NewPlanGroupedTieredPackagePrice) = - price(Price.ofGroupedTieredPackage(groupedTieredPackage)) - - /** - * Alias for calling [price] with - * `Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)`. - */ - fun price(maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice) = - price(Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)) - - /** - * Alias for calling [price] with - * `Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)`. - */ - fun price(scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice) = - price(Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)) - - /** - * Alias for calling [price] with - * `Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)`. - */ - fun price( - scalableMatrixWithTieredPricing: NewPlanScalableMatrixWithTieredPricingPrice - ) = price(Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)) - - /** - * Alias for calling [price] with - * `Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)`. - */ - fun price(cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice) = - price(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) - - /** - * Alias for calling [price] with - * `Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)`. - */ - fun price(tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice) = - price(Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)) - - /** - * Alias for calling [price] with `Price.ofMatrixWithAllocation(matrixWithAllocation)`. - */ - fun price(matrixWithAllocation: NewPlanMatrixWithAllocationPrice) = - price(Price.ofMatrixWithAllocation(matrixWithAllocation)) - - /** Alias for calling [price] with `Price.ofGroupedTiered(groupedTiered)`. */ - fun price(groupedTiered: NewPlanGroupedTieredPrice) = - price(Price.ofGroupedTiered(groupedTiered)) - - /** Alias for calling [price] with `Price.ofMinimum(minimum)`. */ - fun price(minimum: NewPlanMinimumCompositePrice) = price(Price.ofMinimum(minimum)) - fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -6059,38 +6784,34 @@ private constructor( } /** - * Returns an immutable instance of [ReplacePrice]. + * Returns an immutable instance of [RemoveAdjustment]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```kotlin - * .replacesPriceId() + * .adjustmentId() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): ReplacePrice = - ReplacePrice( - checkRequired("replacesPriceId", replacesPriceId), - allocationPrice, + fun build(): RemoveAdjustment = + RemoveAdjustment( + checkRequired("adjustmentId", adjustmentId), planPhaseOrder, - price, additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): ReplacePrice = apply { + fun validate(): RemoveAdjustment = apply { if (validated) { return@apply } - replacesPriceId() - allocationPrice()?.validate() + adjustmentId() planPhaseOrder() - price()?.validate() validated = true } @@ -6109,1131 +6830,4151 @@ private constructor( * Used for best match union deserialization. */ internal fun validity(): Int = - (if (replacesPriceId.asKnown() == null) 0 else 1) + - (allocationPrice.asKnown()?.validity() ?: 0) + - (if (planPhaseOrder.asKnown() == null) 0 else 1) + - (price.asKnown()?.validity() ?: 0) + (if (adjustmentId.asKnown() == null) 0 else 1) + + (if (planPhaseOrder.asKnown() == null) 0 else 1) - /** The price to add to the plan */ - @JsonDeserialize(using = Price.Deserializer::class) - @JsonSerialize(using = Price.Serializer::class) - class Price + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RemoveAdjustment && + adjustmentId == other.adjustmentId && + planPhaseOrder == other.planPhaseOrder && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(adjustmentId, planPhaseOrder, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "RemoveAdjustment{adjustmentId=$adjustmentId, planPhaseOrder=$planPhaseOrder, additionalProperties=$additionalProperties}" + } + + class RemovePrice + private constructor( + private val priceId: JsonField, + private val planPhaseOrder: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator private constructor( - private val unit: NewPlanUnitPrice? = null, - private val package_: NewPlanPackagePrice? = null, - private val matrix: NewPlanMatrixPrice? = null, - private val tiered: NewPlanTieredPrice? = null, - private val bulk: NewPlanBulkPrice? = null, - private val thresholdTotalAmount: NewPlanThresholdTotalAmountPrice? = null, - private val tieredPackage: NewPlanTieredPackagePrice? = null, - private val tieredWithMinimum: NewPlanTieredWithMinimumPrice? = null, - private val unitWithPercent: NewPlanUnitWithPercentPrice? = null, - private val packageWithAllocation: NewPlanPackageWithAllocationPrice? = null, - private val tieredWithProration: NewPlanTierWithProrationPrice? = null, - private val unitWithProration: NewPlanUnitWithProrationPrice? = null, - private val groupedAllocation: NewPlanGroupedAllocationPrice? = null, - private val groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice? = null, - private val groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice? = null, - private val groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds? = null, - private val matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice? = null, - private val bulkWithProration: NewPlanBulkWithProrationPrice? = null, - private val groupedTieredPackage: NewPlanGroupedTieredPackagePrice? = null, - private val maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice? = null, - private val scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice? = - null, - private val scalableMatrixWithTieredPricing: - NewPlanScalableMatrixWithTieredPricingPrice? = - null, - private val cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice? = null, - private val tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice? = null, - private val matrixWithAllocation: NewPlanMatrixWithAllocationPrice? = null, - private val groupedTiered: NewPlanGroupedTieredPrice? = null, - private val minimum: NewPlanMinimumCompositePrice? = null, - private val _json: JsonValue? = null, - ) { + @JsonProperty("price_id") @ExcludeMissing priceId: JsonField = JsonMissing.of(), + @JsonProperty("plan_phase_order") + @ExcludeMissing + planPhaseOrder: JsonField = JsonMissing.of(), + ) : this(priceId, planPhaseOrder, mutableMapOf()) - fun unit(): NewPlanUnitPrice? = unit + /** + * The id of the price to remove from the plan. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun priceId(): String = priceId.getRequired("price_id") - fun package_(): NewPlanPackagePrice? = package_ + /** + * The phase to remove this price from. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun planPhaseOrder(): Long? = planPhaseOrder.getNullable("plan_phase_order") - fun matrix(): NewPlanMatrixPrice? = matrix + /** + * Returns the raw JSON value of [priceId]. + * + * Unlike [priceId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId - fun tiered(): NewPlanTieredPrice? = tiered + /** + * Returns the raw JSON value of [planPhaseOrder]. + * + * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder - fun bulk(): NewPlanBulkPrice? = bulk + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - fun thresholdTotalAmount(): NewPlanThresholdTotalAmountPrice? = thresholdTotalAmount + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - fun tieredPackage(): NewPlanTieredPackagePrice? = tieredPackage + fun toBuilder() = Builder().from(this) - fun tieredWithMinimum(): NewPlanTieredWithMinimumPrice? = tieredWithMinimum + companion object { - fun unitWithPercent(): NewPlanUnitWithPercentPrice? = unitWithPercent + /** + * Returns a mutable builder for constructing an instance of [RemovePrice]. + * + * The following fields are required: + * ```kotlin + * .priceId() + * ``` + */ + fun builder() = Builder() + } - fun packageWithAllocation(): NewPlanPackageWithAllocationPrice? = packageWithAllocation + /** A builder for [RemovePrice]. */ + class Builder internal constructor() { - fun tieredWithProration(): NewPlanTierWithProrationPrice? = tieredWithProration + private var priceId: JsonField? = null + private var planPhaseOrder: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - fun unitWithProration(): NewPlanUnitWithProrationPrice? = unitWithProration + internal fun from(removePrice: RemovePrice) = apply { + priceId = removePrice.priceId + planPhaseOrder = removePrice.planPhaseOrder + additionalProperties = removePrice.additionalProperties.toMutableMap() + } - fun groupedAllocation(): NewPlanGroupedAllocationPrice? = groupedAllocation + /** The id of the price to remove from the plan. */ + fun priceId(priceId: String) = priceId(JsonField.of(priceId)) - fun groupedWithProratedMinimum(): NewPlanGroupedWithProratedMinimumPrice? = - groupedWithProratedMinimum + /** + * Sets [Builder.priceId] to an arbitrary JSON value. + * + * You should usually call [Builder.priceId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun priceId(priceId: JsonField) = apply { this.priceId = priceId } - fun groupedWithMeteredMinimum(): NewPlanGroupedWithMeteredMinimumPrice? = - groupedWithMeteredMinimum + /** The phase to remove this price from. */ + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) - fun groupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds? = - groupedWithMinMaxThresholds + /** + * Alias for [Builder.planPhaseOrder]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) - fun matrixWithDisplayName(): NewPlanMatrixWithDisplayNamePrice? = matrixWithDisplayName + /** + * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. + * + * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun planPhaseOrder(planPhaseOrder: JsonField) = apply { + this.planPhaseOrder = planPhaseOrder + } - fun bulkWithProration(): NewPlanBulkWithProrationPrice? = bulkWithProration + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun groupedTieredPackage(): NewPlanGroupedTieredPackagePrice? = groupedTieredPackage + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun maxGroupTieredPackage(): NewPlanMaxGroupTieredPackagePrice? = maxGroupTieredPackage + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun scalableMatrixWithUnitPricing(): NewPlanScalableMatrixWithUnitPricingPrice? = - scalableMatrixWithUnitPricing + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - fun scalableMatrixWithTieredPricing(): NewPlanScalableMatrixWithTieredPricingPrice? = - scalableMatrixWithTieredPricing + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - fun cumulativeGroupedBulk(): NewPlanCumulativeGroupedBulkPrice? = cumulativeGroupedBulk + /** + * Returns an immutable instance of [RemovePrice]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .priceId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): RemovePrice = + RemovePrice( + checkRequired("priceId", priceId), + planPhaseOrder, + additionalProperties.toMutableMap(), + ) + } - fun tieredPackageWithMinimum(): NewPlanTieredPackageWithMinimumPrice? = - tieredPackageWithMinimum + private var validated: Boolean = false - fun matrixWithAllocation(): NewPlanMatrixWithAllocationPrice? = matrixWithAllocation + fun validate(): RemovePrice = apply { + if (validated) { + return@apply + } - fun groupedTiered(): NewPlanGroupedTieredPrice? = groupedTiered + priceId() + planPhaseOrder() + validated = true + } - fun minimum(): NewPlanMinimumCompositePrice? = minimum + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - fun isUnit(): Boolean = unit != null + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (priceId.asKnown() == null) 0 else 1) + + (if (planPhaseOrder.asKnown() == null) 0 else 1) - fun isPackage(): Boolean = package_ != null + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun isMatrix(): Boolean = matrix != null + return other is RemovePrice && + priceId == other.priceId && + planPhaseOrder == other.planPhaseOrder && + additionalProperties == other.additionalProperties + } - fun isTiered(): Boolean = tiered != null + private val hashCode: Int by lazy { + Objects.hash(priceId, planPhaseOrder, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "RemovePrice{priceId=$priceId, planPhaseOrder=$planPhaseOrder, additionalProperties=$additionalProperties}" + } + + class ReplaceAdjustment + private constructor( + private val adjustment: JsonField, + private val replacesAdjustmentId: JsonField, + private val planPhaseOrder: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("adjustment") + @ExcludeMissing + adjustment: JsonField = JsonMissing.of(), + @JsonProperty("replaces_adjustment_id") + @ExcludeMissing + replacesAdjustmentId: JsonField = JsonMissing.of(), + @JsonProperty("plan_phase_order") + @ExcludeMissing + planPhaseOrder: JsonField = JsonMissing.of(), + ) : this(adjustment, replacesAdjustmentId, planPhaseOrder, mutableMapOf()) + + /** + * The definition of a new adjustment to create and add to the plan. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun adjustment(): Adjustment = adjustment.getRequired("adjustment") + + /** + * The id of the adjustment on the plan to replace in the plan. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun replacesAdjustmentId(): String = + replacesAdjustmentId.getRequired("replaces_adjustment_id") + + /** + * The phase to replace this adjustment from. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun planPhaseOrder(): Long? = planPhaseOrder.getNullable("plan_phase_order") + + /** + * Returns the raw JSON value of [adjustment]. + * + * Unlike [adjustment], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("adjustment") + @ExcludeMissing + fun _adjustment(): JsonField = adjustment + + /** + * Returns the raw JSON value of [replacesAdjustmentId]. + * + * Unlike [replacesAdjustmentId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("replaces_adjustment_id") + @ExcludeMissing + fun _replacesAdjustmentId(): JsonField = replacesAdjustmentId + + /** + * Returns the raw JSON value of [planPhaseOrder]. + * + * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ReplaceAdjustment]. + * + * The following fields are required: + * ```kotlin + * .adjustment() + * .replacesAdjustmentId() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [ReplaceAdjustment]. */ + class Builder internal constructor() { + + private var adjustment: JsonField? = null + private var replacesAdjustmentId: JsonField? = null + private var planPhaseOrder: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(replaceAdjustment: ReplaceAdjustment) = apply { + adjustment = replaceAdjustment.adjustment + replacesAdjustmentId = replaceAdjustment.replacesAdjustmentId + planPhaseOrder = replaceAdjustment.planPhaseOrder + additionalProperties = replaceAdjustment.additionalProperties.toMutableMap() + } + + /** The definition of a new adjustment to create and add to the plan. */ + fun adjustment(adjustment: Adjustment) = adjustment(JsonField.of(adjustment)) + + /** + * Sets [Builder.adjustment] to an arbitrary JSON value. + * + * You should usually call [Builder.adjustment] with a well-typed [Adjustment] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun adjustment(adjustment: JsonField) = apply { + this.adjustment = adjustment + } + + /** + * Alias for calling [adjustment] with + * `Adjustment.ofPercentageDiscount(percentageDiscount)`. + */ + fun adjustment(percentageDiscount: NewPercentageDiscount) = + adjustment(Adjustment.ofPercentageDiscount(percentageDiscount)) + + /** + * Alias for calling [adjustment] with the following: + * ```kotlin + * NewPercentageDiscount.builder() + * .adjustmentType(NewPercentageDiscount.AdjustmentType.PERCENTAGE_DISCOUNT) + * .percentageDiscount(percentageDiscount) + * .build() + * ``` + */ + fun percentageDiscountAdjustment(percentageDiscount: Double) = + adjustment( + NewPercentageDiscount.builder() + .adjustmentType(NewPercentageDiscount.AdjustmentType.PERCENTAGE_DISCOUNT) + .percentageDiscount(percentageDiscount) + .build() + ) + + /** Alias for calling [adjustment] with `Adjustment.ofUsageDiscount(usageDiscount)`. */ + fun adjustment(usageDiscount: NewUsageDiscount) = + adjustment(Adjustment.ofUsageDiscount(usageDiscount)) + + /** + * Alias for calling [adjustment] with the following: + * ```kotlin + * NewUsageDiscount.builder() + * .adjustmentType(NewUsageDiscount.AdjustmentType.USAGE_DISCOUNT) + * .usageDiscount(usageDiscount) + * .build() + * ``` + */ + fun usageDiscountAdjustment(usageDiscount: Double) = + adjustment( + NewUsageDiscount.builder() + .adjustmentType(NewUsageDiscount.AdjustmentType.USAGE_DISCOUNT) + .usageDiscount(usageDiscount) + .build() + ) + + /** + * Alias for calling [adjustment] with `Adjustment.ofAmountDiscount(amountDiscount)`. + */ + fun adjustment(amountDiscount: NewAmountDiscount) = + adjustment(Adjustment.ofAmountDiscount(amountDiscount)) + + /** + * Alias for calling [adjustment] with the following: + * ```kotlin + * NewAmountDiscount.builder() + * .adjustmentType(NewAmountDiscount.AdjustmentType.AMOUNT_DISCOUNT) + * .amountDiscount(amountDiscount) + * .build() + * ``` + */ + fun amountDiscountAdjustment(amountDiscount: String) = + adjustment( + NewAmountDiscount.builder() + .adjustmentType(NewAmountDiscount.AdjustmentType.AMOUNT_DISCOUNT) + .amountDiscount(amountDiscount) + .build() + ) + + /** Alias for calling [adjustment] with `Adjustment.ofMinimum(minimum)`. */ + fun adjustment(minimum: NewMinimum) = adjustment(Adjustment.ofMinimum(minimum)) + + /** Alias for calling [adjustment] with `Adjustment.ofMaximum(maximum)`. */ + fun adjustment(maximum: NewMaximum) = adjustment(Adjustment.ofMaximum(maximum)) + + /** + * Alias for calling [adjustment] with the following: + * ```kotlin + * NewMaximum.builder() + * .adjustmentType(NewMaximum.AdjustmentType.MAXIMUM) + * .maximumAmount(maximumAmount) + * .build() + * ``` + */ + fun maximumAdjustment(maximumAmount: String) = + adjustment( + NewMaximum.builder() + .adjustmentType(NewMaximum.AdjustmentType.MAXIMUM) + .maximumAmount(maximumAmount) + .build() + ) + + /** The id of the adjustment on the plan to replace in the plan. */ + fun replacesAdjustmentId(replacesAdjustmentId: String) = + replacesAdjustmentId(JsonField.of(replacesAdjustmentId)) + + /** + * Sets [Builder.replacesAdjustmentId] to an arbitrary JSON value. + * + * You should usually call [Builder.replacesAdjustmentId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun replacesAdjustmentId(replacesAdjustmentId: JsonField) = apply { + this.replacesAdjustmentId = replacesAdjustmentId + } + + /** The phase to replace this adjustment from. */ + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + + /** + * Alias for [Builder.planPhaseOrder]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + + /** + * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. + * + * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun planPhaseOrder(planPhaseOrder: JsonField) = apply { + this.planPhaseOrder = planPhaseOrder + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ReplaceAdjustment]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .adjustment() + * .replacesAdjustmentId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ReplaceAdjustment = + ReplaceAdjustment( + checkRequired("adjustment", adjustment), + checkRequired("replacesAdjustmentId", replacesAdjustmentId), + planPhaseOrder, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ReplaceAdjustment = apply { + if (validated) { + return@apply + } + + adjustment().validate() + replacesAdjustmentId() + planPhaseOrder() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (adjustment.asKnown()?.validity() ?: 0) + + (if (replacesAdjustmentId.asKnown() == null) 0 else 1) + + (if (planPhaseOrder.asKnown() == null) 0 else 1) + + /** The definition of a new adjustment to create and add to the plan. */ + @JsonDeserialize(using = Adjustment.Deserializer::class) + @JsonSerialize(using = Adjustment.Serializer::class) + class Adjustment + private constructor( + private val percentageDiscount: NewPercentageDiscount? = null, + private val usageDiscount: NewUsageDiscount? = null, + private val amountDiscount: NewAmountDiscount? = null, + private val minimum: NewMinimum? = null, + private val maximum: NewMaximum? = null, + private val _json: JsonValue? = null, + ) { + + fun percentageDiscount(): NewPercentageDiscount? = percentageDiscount + + fun usageDiscount(): NewUsageDiscount? = usageDiscount + + fun amountDiscount(): NewAmountDiscount? = amountDiscount + + fun minimum(): NewMinimum? = minimum + + fun maximum(): NewMaximum? = maximum + + fun isPercentageDiscount(): Boolean = percentageDiscount != null + + fun isUsageDiscount(): Boolean = usageDiscount != null + + fun isAmountDiscount(): Boolean = amountDiscount != null + + fun isMinimum(): Boolean = minimum != null + + fun isMaximum(): Boolean = maximum != null + + fun asPercentageDiscount(): NewPercentageDiscount = + percentageDiscount.getOrThrow("percentageDiscount") + + fun asUsageDiscount(): NewUsageDiscount = usageDiscount.getOrThrow("usageDiscount") + + fun asAmountDiscount(): NewAmountDiscount = amountDiscount.getOrThrow("amountDiscount") + + fun asMinimum(): NewMinimum = minimum.getOrThrow("minimum") + + fun asMaximum(): NewMaximum = maximum.getOrThrow("maximum") + + fun _json(): JsonValue? = _json + + fun accept(visitor: Visitor): T = + when { + percentageDiscount != null -> + visitor.visitPercentageDiscount(percentageDiscount) + usageDiscount != null -> visitor.visitUsageDiscount(usageDiscount) + amountDiscount != null -> visitor.visitAmountDiscount(amountDiscount) + minimum != null -> visitor.visitMinimum(minimum) + maximum != null -> visitor.visitMaximum(maximum) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Adjustment = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitPercentageDiscount( + percentageDiscount: NewPercentageDiscount + ) { + percentageDiscount.validate() + } + + override fun visitUsageDiscount(usageDiscount: NewUsageDiscount) { + usageDiscount.validate() + } + + override fun visitAmountDiscount(amountDiscount: NewAmountDiscount) { + amountDiscount.validate() + } + + override fun visitMinimum(minimum: NewMinimum) { + minimum.validate() + } + + override fun visitMaximum(maximum: NewMaximum) { + maximum.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitPercentageDiscount( + percentageDiscount: NewPercentageDiscount + ) = percentageDiscount.validity() + + override fun visitUsageDiscount(usageDiscount: NewUsageDiscount) = + usageDiscount.validity() + + override fun visitAmountDiscount(amountDiscount: NewAmountDiscount) = + amountDiscount.validity() + + override fun visitMinimum(minimum: NewMinimum) = minimum.validity() + + override fun visitMaximum(maximum: NewMaximum) = maximum.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Adjustment && + percentageDiscount == other.percentageDiscount && + usageDiscount == other.usageDiscount && + amountDiscount == other.amountDiscount && + minimum == other.minimum && + maximum == other.maximum + } + + override fun hashCode(): Int = + Objects.hash(percentageDiscount, usageDiscount, amountDiscount, minimum, maximum) + + override fun toString(): String = + when { + percentageDiscount != null -> + "Adjustment{percentageDiscount=$percentageDiscount}" + usageDiscount != null -> "Adjustment{usageDiscount=$usageDiscount}" + amountDiscount != null -> "Adjustment{amountDiscount=$amountDiscount}" + minimum != null -> "Adjustment{minimum=$minimum}" + maximum != null -> "Adjustment{maximum=$maximum}" + _json != null -> "Adjustment{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Adjustment") + } + + companion object { + + fun ofPercentageDiscount(percentageDiscount: NewPercentageDiscount) = + Adjustment(percentageDiscount = percentageDiscount) + + fun ofUsageDiscount(usageDiscount: NewUsageDiscount) = + Adjustment(usageDiscount = usageDiscount) + + fun ofAmountDiscount(amountDiscount: NewAmountDiscount) = + Adjustment(amountDiscount = amountDiscount) + + fun ofMinimum(minimum: NewMinimum) = Adjustment(minimum = minimum) + + fun ofMaximum(maximum: NewMaximum) = Adjustment(maximum = maximum) + } + + /** + * An interface that defines how to map each variant of [Adjustment] to a value of type + * [T]. + */ + interface Visitor { + + fun visitPercentageDiscount(percentageDiscount: NewPercentageDiscount): T + + fun visitUsageDiscount(usageDiscount: NewUsageDiscount): T + + fun visitAmountDiscount(amountDiscount: NewAmountDiscount): T + + fun visitMinimum(minimum: NewMinimum): T + + fun visitMaximum(maximum: NewMaximum): T + + /** + * Maps an unknown variant of [Adjustment] to a value of type [T]. + * + * An instance of [Adjustment] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the + * SDK is unaware of. + * + * @throws OrbInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw OrbInvalidDataException("Unknown Adjustment: $json") + } + } + + internal class Deserializer : BaseDeserializer(Adjustment::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Adjustment { + val json = JsonValue.fromJsonNode(node) + val adjustmentType = json.asObject()?.get("adjustment_type")?.asString() + + when (adjustmentType) { + "percentage_discount" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Adjustment(percentageDiscount = it, _json = json) } + ?: Adjustment(_json = json) + } + "usage_discount" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(usageDiscount = it, _json = json) + } ?: Adjustment(_json = json) + } + "amount_discount" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(amountDiscount = it, _json = json) + } ?: Adjustment(_json = json) + } + "minimum" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(minimum = it, _json = json) + } ?: Adjustment(_json = json) + } + "maximum" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(maximum = it, _json = json) + } ?: Adjustment(_json = json) + } + } + + return Adjustment(_json = json) + } + } + + internal class Serializer : BaseSerializer(Adjustment::class) { + + override fun serialize( + value: Adjustment, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.percentageDiscount != null -> + generator.writeObject(value.percentageDiscount) + value.usageDiscount != null -> generator.writeObject(value.usageDiscount) + value.amountDiscount != null -> generator.writeObject(value.amountDiscount) + value.minimum != null -> generator.writeObject(value.minimum) + value.maximum != null -> generator.writeObject(value.maximum) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Adjustment") + } + } + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ReplaceAdjustment && + adjustment == other.adjustment && + replacesAdjustmentId == other.replacesAdjustmentId && + planPhaseOrder == other.planPhaseOrder && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(adjustment, replacesAdjustmentId, planPhaseOrder, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ReplaceAdjustment{adjustment=$adjustment, replacesAdjustmentId=$replacesAdjustmentId, planPhaseOrder=$planPhaseOrder, additionalProperties=$additionalProperties}" + } + + class ReplacePrice + private constructor( + private val replacesPriceId: JsonField, + private val allocationPrice: JsonField, + private val planPhaseOrder: JsonField, + private val price: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("replaces_price_id") + @ExcludeMissing + replacesPriceId: JsonField = JsonMissing.of(), + @JsonProperty("allocation_price") + @ExcludeMissing + allocationPrice: JsonField = JsonMissing.of(), + @JsonProperty("plan_phase_order") + @ExcludeMissing + planPhaseOrder: JsonField = JsonMissing.of(), + @JsonProperty("price") @ExcludeMissing price: JsonField = JsonMissing.of(), + ) : this(replacesPriceId, allocationPrice, planPhaseOrder, price, mutableMapOf()) + + /** + * The id of the price on the plan to replace in the plan. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun replacesPriceId(): String = replacesPriceId.getRequired("replaces_price_id") + + /** + * The allocation price to add to the plan. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun allocationPrice(): NewAllocationPrice? = allocationPrice.getNullable("allocation_price") + + /** + * The phase to replace this price from. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun planPhaseOrder(): Long? = planPhaseOrder.getNullable("plan_phase_order") + + /** + * New plan price request body params. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun price(): Price? = price.getNullable("price") + + /** + * Returns the raw JSON value of [replacesPriceId]. + * + * Unlike [replacesPriceId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("replaces_price_id") + @ExcludeMissing + fun _replacesPriceId(): JsonField = replacesPriceId + + /** + * Returns the raw JSON value of [allocationPrice]. + * + * Unlike [allocationPrice], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("allocation_price") + @ExcludeMissing + fun _allocationPrice(): JsonField = allocationPrice + + /** + * Returns the raw JSON value of [planPhaseOrder]. + * + * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder + + /** + * Returns the raw JSON value of [price]. + * + * Unlike [price], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("price") @ExcludeMissing fun _price(): JsonField = price + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ReplacePrice]. + * + * The following fields are required: + * ```kotlin + * .replacesPriceId() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [ReplacePrice]. */ + class Builder internal constructor() { + + private var replacesPriceId: JsonField? = null + private var allocationPrice: JsonField = JsonMissing.of() + private var planPhaseOrder: JsonField = JsonMissing.of() + private var price: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(replacePrice: ReplacePrice) = apply { + replacesPriceId = replacePrice.replacesPriceId + allocationPrice = replacePrice.allocationPrice + planPhaseOrder = replacePrice.planPhaseOrder + price = replacePrice.price + additionalProperties = replacePrice.additionalProperties.toMutableMap() + } + + /** The id of the price on the plan to replace in the plan. */ + fun replacesPriceId(replacesPriceId: String) = + replacesPriceId(JsonField.of(replacesPriceId)) + + /** + * Sets [Builder.replacesPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.replacesPriceId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun replacesPriceId(replacesPriceId: JsonField) = apply { + this.replacesPriceId = replacesPriceId + } + + /** The allocation price to add to the plan. */ + fun allocationPrice(allocationPrice: NewAllocationPrice?) = + allocationPrice(JsonField.ofNullable(allocationPrice)) + + /** + * Sets [Builder.allocationPrice] to an arbitrary JSON value. + * + * You should usually call [Builder.allocationPrice] with a well-typed + * [NewAllocationPrice] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun allocationPrice(allocationPrice: JsonField) = apply { + this.allocationPrice = allocationPrice + } + + /** The phase to replace this price from. */ + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + + /** + * Alias for [Builder.planPhaseOrder]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + + /** + * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. + * + * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun planPhaseOrder(planPhaseOrder: JsonField) = apply { + this.planPhaseOrder = planPhaseOrder + } + + /** New plan price request body params. */ + fun price(price: Price?) = price(JsonField.ofNullable(price)) + + /** + * Sets [Builder.price] to an arbitrary JSON value. + * + * You should usually call [Builder.price] with a well-typed [Price] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun price(price: JsonField) = apply { this.price = price } + + /** Alias for calling [price] with `Price.ofUnit(unit)`. */ + fun price(unit: NewPlanUnitPrice) = price(Price.ofUnit(unit)) + + /** Alias for calling [price] with `Price.ofTiered(tiered)`. */ + fun price(tiered: NewPlanTieredPrice) = price(Price.ofTiered(tiered)) + + /** Alias for calling [price] with `Price.ofBulk(bulk)`. */ + fun price(bulk: NewPlanBulkPrice) = price(Price.ofBulk(bulk)) + + /** Alias for calling [price] with `Price.ofPackage(package_)`. */ + fun price(package_: NewPlanPackagePrice) = price(Price.ofPackage(package_)) + + /** Alias for calling [price] with `Price.ofMatrix(matrix)`. */ + fun price(matrix: NewPlanMatrixPrice) = price(Price.ofMatrix(matrix)) + + /** + * Alias for calling [price] with `Price.ofThresholdTotalAmount(thresholdTotalAmount)`. + */ + fun price(thresholdTotalAmount: NewPlanThresholdTotalAmountPrice) = + price(Price.ofThresholdTotalAmount(thresholdTotalAmount)) + + /** Alias for calling [price] with `Price.ofTieredPackage(tieredPackage)`. */ + fun price(tieredPackage: NewPlanTieredPackagePrice) = + price(Price.ofTieredPackage(tieredPackage)) + + /** Alias for calling [price] with `Price.ofTieredWithMinimum(tieredWithMinimum)`. */ + fun price(tieredWithMinimum: NewPlanTieredWithMinimumPrice) = + price(Price.ofTieredWithMinimum(tieredWithMinimum)) + + /** Alias for calling [price] with `Price.ofGroupedTiered(groupedTiered)`. */ + fun price(groupedTiered: NewPlanGroupedTieredPrice) = + price(Price.ofGroupedTiered(groupedTiered)) + + /** + * Alias for calling [price] with + * `Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)`. + */ + fun price(tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice) = + price(Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)) + + /** + * Alias for calling [price] with + * `Price.ofPackageWithAllocation(packageWithAllocation)`. + */ + fun price(packageWithAllocation: NewPlanPackageWithAllocationPrice) = + price(Price.ofPackageWithAllocation(packageWithAllocation)) + + /** Alias for calling [price] with `Price.ofUnitWithPercent(unitWithPercent)`. */ + fun price(unitWithPercent: NewPlanUnitWithPercentPrice) = + price(Price.ofUnitWithPercent(unitWithPercent)) + + /** + * Alias for calling [price] with `Price.ofMatrixWithAllocation(matrixWithAllocation)`. + */ + fun price(matrixWithAllocation: NewPlanMatrixWithAllocationPrice) = + price(Price.ofMatrixWithAllocation(matrixWithAllocation)) + + /** + * Alias for calling [price] with `Price.ofTieredWithProration(tieredWithProration)`. + */ + fun price(tieredWithProration: Price.TieredWithProration) = + price(Price.ofTieredWithProration(tieredWithProration)) + + /** Alias for calling [price] with `Price.ofUnitWithProration(unitWithProration)`. */ + fun price(unitWithProration: NewPlanUnitWithProrationPrice) = + price(Price.ofUnitWithProration(unitWithProration)) + + /** Alias for calling [price] with `Price.ofGroupedAllocation(groupedAllocation)`. */ + fun price(groupedAllocation: NewPlanGroupedAllocationPrice) = + price(Price.ofGroupedAllocation(groupedAllocation)) + + /** Alias for calling [price] with `Price.ofBulkWithProration(bulkWithProration)`. */ + fun price(bulkWithProration: NewPlanBulkWithProrationPrice) = + price(Price.ofBulkWithProration(bulkWithProration)) + + /** + * Alias for calling [price] with + * `Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)`. + */ + fun price(groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice) = + price(Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)) + + /** + * Alias for calling [price] with + * `Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)`. + */ + fun price(groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice) = + price(Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)) + + /** + * Alias for calling [price] with + * `Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)`. + */ + fun price(groupedWithMinMaxThresholds: Price.GroupedWithMinMaxThresholds) = + price(Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)) + + /** + * Alias for calling [price] with + * `Price.ofMatrixWithDisplayName(matrixWithDisplayName)`. + */ + fun price(matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice) = + price(Price.ofMatrixWithDisplayName(matrixWithDisplayName)) + + /** + * Alias for calling [price] with `Price.ofGroupedTieredPackage(groupedTieredPackage)`. + */ + fun price(groupedTieredPackage: NewPlanGroupedTieredPackagePrice) = + price(Price.ofGroupedTieredPackage(groupedTieredPackage)) + + /** + * Alias for calling [price] with + * `Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)`. + */ + fun price(maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice) = + price(Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)) + + /** + * Alias for calling [price] with + * `Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)`. + */ + fun price(scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice) = + price(Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)) + + /** + * Alias for calling [price] with + * `Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)`. + */ + fun price( + scalableMatrixWithTieredPricing: NewPlanScalableMatrixWithTieredPricingPrice + ) = price(Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)) + + /** + * Alias for calling [price] with + * `Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)`. + */ + fun price(cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice) = + price(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) + + /** Alias for calling [price] with `Price.ofMinimum(minimum)`. */ + fun price(minimum: NewPlanMinimumCompositePrice) = price(Price.ofMinimum(minimum)) + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ReplacePrice]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .replacesPriceId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ReplacePrice = + ReplacePrice( + checkRequired("replacesPriceId", replacesPriceId), + allocationPrice, + planPhaseOrder, + price, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ReplacePrice = apply { + if (validated) { + return@apply + } + + replacesPriceId() + allocationPrice()?.validate() + planPhaseOrder() + price()?.validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (replacesPriceId.asKnown() == null) 0 else 1) + + (allocationPrice.asKnown()?.validity() ?: 0) + + (if (planPhaseOrder.asKnown() == null) 0 else 1) + + (price.asKnown()?.validity() ?: 0) + + /** New plan price request body params. */ + @JsonDeserialize(using = Price.Deserializer::class) + @JsonSerialize(using = Price.Serializer::class) + class Price + private constructor( + private val unit: NewPlanUnitPrice? = null, + private val tiered: NewPlanTieredPrice? = null, + private val bulk: NewPlanBulkPrice? = null, + private val package_: NewPlanPackagePrice? = null, + private val matrix: NewPlanMatrixPrice? = null, + private val thresholdTotalAmount: NewPlanThresholdTotalAmountPrice? = null, + private val tieredPackage: NewPlanTieredPackagePrice? = null, + private val tieredWithMinimum: NewPlanTieredWithMinimumPrice? = null, + private val groupedTiered: NewPlanGroupedTieredPrice? = null, + private val tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice? = null, + private val packageWithAllocation: NewPlanPackageWithAllocationPrice? = null, + private val unitWithPercent: NewPlanUnitWithPercentPrice? = null, + private val matrixWithAllocation: NewPlanMatrixWithAllocationPrice? = null, + private val tieredWithProration: TieredWithProration? = null, + private val unitWithProration: NewPlanUnitWithProrationPrice? = null, + private val groupedAllocation: NewPlanGroupedAllocationPrice? = null, + private val bulkWithProration: NewPlanBulkWithProrationPrice? = null, + private val groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice? = null, + private val groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice? = null, + private val groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds? = null, + private val matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice? = null, + private val groupedTieredPackage: NewPlanGroupedTieredPackagePrice? = null, + private val maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice? = null, + private val scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice? = + null, + private val scalableMatrixWithTieredPricing: + NewPlanScalableMatrixWithTieredPricingPrice? = + null, + private val cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice? = null, + private val minimum: NewPlanMinimumCompositePrice? = null, + private val _json: JsonValue? = null, + ) { + + fun unit(): NewPlanUnitPrice? = unit + + fun tiered(): NewPlanTieredPrice? = tiered + + fun bulk(): NewPlanBulkPrice? = bulk + + fun package_(): NewPlanPackagePrice? = package_ + + fun matrix(): NewPlanMatrixPrice? = matrix + + fun thresholdTotalAmount(): NewPlanThresholdTotalAmountPrice? = thresholdTotalAmount + + fun tieredPackage(): NewPlanTieredPackagePrice? = tieredPackage + + fun tieredWithMinimum(): NewPlanTieredWithMinimumPrice? = tieredWithMinimum + + fun groupedTiered(): NewPlanGroupedTieredPrice? = groupedTiered + + fun tieredPackageWithMinimum(): NewPlanTieredPackageWithMinimumPrice? = + tieredPackageWithMinimum + + fun packageWithAllocation(): NewPlanPackageWithAllocationPrice? = packageWithAllocation + + fun unitWithPercent(): NewPlanUnitWithPercentPrice? = unitWithPercent + + fun matrixWithAllocation(): NewPlanMatrixWithAllocationPrice? = matrixWithAllocation + + fun tieredWithProration(): TieredWithProration? = tieredWithProration + + fun unitWithProration(): NewPlanUnitWithProrationPrice? = unitWithProration + + fun groupedAllocation(): NewPlanGroupedAllocationPrice? = groupedAllocation + + fun bulkWithProration(): NewPlanBulkWithProrationPrice? = bulkWithProration + + fun groupedWithProratedMinimum(): NewPlanGroupedWithProratedMinimumPrice? = + groupedWithProratedMinimum + + fun groupedWithMeteredMinimum(): NewPlanGroupedWithMeteredMinimumPrice? = + groupedWithMeteredMinimum + + fun groupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds? = + groupedWithMinMaxThresholds + + fun matrixWithDisplayName(): NewPlanMatrixWithDisplayNamePrice? = matrixWithDisplayName + + fun groupedTieredPackage(): NewPlanGroupedTieredPackagePrice? = groupedTieredPackage + + fun maxGroupTieredPackage(): NewPlanMaxGroupTieredPackagePrice? = maxGroupTieredPackage + + fun scalableMatrixWithUnitPricing(): NewPlanScalableMatrixWithUnitPricingPrice? = + scalableMatrixWithUnitPricing + + fun scalableMatrixWithTieredPricing(): NewPlanScalableMatrixWithTieredPricingPrice? = + scalableMatrixWithTieredPricing + + fun cumulativeGroupedBulk(): NewPlanCumulativeGroupedBulkPrice? = cumulativeGroupedBulk + + fun minimum(): NewPlanMinimumCompositePrice? = minimum + + fun isUnit(): Boolean = unit != null + + fun isTiered(): Boolean = tiered != null + + fun isBulk(): Boolean = bulk != null + + fun isPackage(): Boolean = package_ != null + + fun isMatrix(): Boolean = matrix != null + + fun isThresholdTotalAmount(): Boolean = thresholdTotalAmount != null + + fun isTieredPackage(): Boolean = tieredPackage != null + + fun isTieredWithMinimum(): Boolean = tieredWithMinimum != null + + fun isGroupedTiered(): Boolean = groupedTiered != null + + fun isTieredPackageWithMinimum(): Boolean = tieredPackageWithMinimum != null + + fun isPackageWithAllocation(): Boolean = packageWithAllocation != null + + fun isUnitWithPercent(): Boolean = unitWithPercent != null + + fun isMatrixWithAllocation(): Boolean = matrixWithAllocation != null + + fun isTieredWithProration(): Boolean = tieredWithProration != null + + fun isUnitWithProration(): Boolean = unitWithProration != null + + fun isGroupedAllocation(): Boolean = groupedAllocation != null + + fun isBulkWithProration(): Boolean = bulkWithProration != null + + fun isGroupedWithProratedMinimum(): Boolean = groupedWithProratedMinimum != null + + fun isGroupedWithMeteredMinimum(): Boolean = groupedWithMeteredMinimum != null + + fun isGroupedWithMinMaxThresholds(): Boolean = groupedWithMinMaxThresholds != null + + fun isMatrixWithDisplayName(): Boolean = matrixWithDisplayName != null + + fun isGroupedTieredPackage(): Boolean = groupedTieredPackage != null + + fun isMaxGroupTieredPackage(): Boolean = maxGroupTieredPackage != null + + fun isScalableMatrixWithUnitPricing(): Boolean = scalableMatrixWithUnitPricing != null + + fun isScalableMatrixWithTieredPricing(): Boolean = + scalableMatrixWithTieredPricing != null + + fun isCumulativeGroupedBulk(): Boolean = cumulativeGroupedBulk != null + + fun isMinimum(): Boolean = minimum != null + + fun asUnit(): NewPlanUnitPrice = unit.getOrThrow("unit") + + fun asTiered(): NewPlanTieredPrice = tiered.getOrThrow("tiered") + + fun asBulk(): NewPlanBulkPrice = bulk.getOrThrow("bulk") + + fun asPackage(): NewPlanPackagePrice = package_.getOrThrow("package_") + + fun asMatrix(): NewPlanMatrixPrice = matrix.getOrThrow("matrix") + + fun asThresholdTotalAmount(): NewPlanThresholdTotalAmountPrice = + thresholdTotalAmount.getOrThrow("thresholdTotalAmount") + + fun asTieredPackage(): NewPlanTieredPackagePrice = + tieredPackage.getOrThrow("tieredPackage") + + fun asTieredWithMinimum(): NewPlanTieredWithMinimumPrice = + tieredWithMinimum.getOrThrow("tieredWithMinimum") + + fun asGroupedTiered(): NewPlanGroupedTieredPrice = + groupedTiered.getOrThrow("groupedTiered") + + fun asTieredPackageWithMinimum(): NewPlanTieredPackageWithMinimumPrice = + tieredPackageWithMinimum.getOrThrow("tieredPackageWithMinimum") + + fun asPackageWithAllocation(): NewPlanPackageWithAllocationPrice = + packageWithAllocation.getOrThrow("packageWithAllocation") + + fun asUnitWithPercent(): NewPlanUnitWithPercentPrice = + unitWithPercent.getOrThrow("unitWithPercent") + + fun asMatrixWithAllocation(): NewPlanMatrixWithAllocationPrice = + matrixWithAllocation.getOrThrow("matrixWithAllocation") + + fun asTieredWithProration(): TieredWithProration = + tieredWithProration.getOrThrow("tieredWithProration") + + fun asUnitWithProration(): NewPlanUnitWithProrationPrice = + unitWithProration.getOrThrow("unitWithProration") + + fun asGroupedAllocation(): NewPlanGroupedAllocationPrice = + groupedAllocation.getOrThrow("groupedAllocation") + + fun asBulkWithProration(): NewPlanBulkWithProrationPrice = + bulkWithProration.getOrThrow("bulkWithProration") + + fun asGroupedWithProratedMinimum(): NewPlanGroupedWithProratedMinimumPrice = + groupedWithProratedMinimum.getOrThrow("groupedWithProratedMinimum") + + fun asGroupedWithMeteredMinimum(): NewPlanGroupedWithMeteredMinimumPrice = + groupedWithMeteredMinimum.getOrThrow("groupedWithMeteredMinimum") + + fun asGroupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds = + groupedWithMinMaxThresholds.getOrThrow("groupedWithMinMaxThresholds") + + fun asMatrixWithDisplayName(): NewPlanMatrixWithDisplayNamePrice = + matrixWithDisplayName.getOrThrow("matrixWithDisplayName") + + fun asGroupedTieredPackage(): NewPlanGroupedTieredPackagePrice = + groupedTieredPackage.getOrThrow("groupedTieredPackage") + + fun asMaxGroupTieredPackage(): NewPlanMaxGroupTieredPackagePrice = + maxGroupTieredPackage.getOrThrow("maxGroupTieredPackage") + + fun asScalableMatrixWithUnitPricing(): NewPlanScalableMatrixWithUnitPricingPrice = + scalableMatrixWithUnitPricing.getOrThrow("scalableMatrixWithUnitPricing") + + fun asScalableMatrixWithTieredPricing(): NewPlanScalableMatrixWithTieredPricingPrice = + scalableMatrixWithTieredPricing.getOrThrow("scalableMatrixWithTieredPricing") + + fun asCumulativeGroupedBulk(): NewPlanCumulativeGroupedBulkPrice = + cumulativeGroupedBulk.getOrThrow("cumulativeGroupedBulk") + + fun asMinimum(): NewPlanMinimumCompositePrice = minimum.getOrThrow("minimum") + + fun _json(): JsonValue? = _json + + fun accept(visitor: Visitor): T = + when { + unit != null -> visitor.visitUnit(unit) + tiered != null -> visitor.visitTiered(tiered) + bulk != null -> visitor.visitBulk(bulk) + package_ != null -> visitor.visitPackage(package_) + matrix != null -> visitor.visitMatrix(matrix) + thresholdTotalAmount != null -> + visitor.visitThresholdTotalAmount(thresholdTotalAmount) + tieredPackage != null -> visitor.visitTieredPackage(tieredPackage) + tieredWithMinimum != null -> visitor.visitTieredWithMinimum(tieredWithMinimum) + groupedTiered != null -> visitor.visitGroupedTiered(groupedTiered) + tieredPackageWithMinimum != null -> + visitor.visitTieredPackageWithMinimum(tieredPackageWithMinimum) + packageWithAllocation != null -> + visitor.visitPackageWithAllocation(packageWithAllocation) + unitWithPercent != null -> visitor.visitUnitWithPercent(unitWithPercent) + matrixWithAllocation != null -> + visitor.visitMatrixWithAllocation(matrixWithAllocation) + tieredWithProration != null -> + visitor.visitTieredWithProration(tieredWithProration) + unitWithProration != null -> visitor.visitUnitWithProration(unitWithProration) + groupedAllocation != null -> visitor.visitGroupedAllocation(groupedAllocation) + bulkWithProration != null -> visitor.visitBulkWithProration(bulkWithProration) + groupedWithProratedMinimum != null -> + visitor.visitGroupedWithProratedMinimum(groupedWithProratedMinimum) + groupedWithMeteredMinimum != null -> + visitor.visitGroupedWithMeteredMinimum(groupedWithMeteredMinimum) + groupedWithMinMaxThresholds != null -> + visitor.visitGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds) + matrixWithDisplayName != null -> + visitor.visitMatrixWithDisplayName(matrixWithDisplayName) + groupedTieredPackage != null -> + visitor.visitGroupedTieredPackage(groupedTieredPackage) + maxGroupTieredPackage != null -> + visitor.visitMaxGroupTieredPackage(maxGroupTieredPackage) + scalableMatrixWithUnitPricing != null -> + visitor.visitScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing) + scalableMatrixWithTieredPricing != null -> + visitor.visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing + ) + cumulativeGroupedBulk != null -> + visitor.visitCumulativeGroupedBulk(cumulativeGroupedBulk) + minimum != null -> visitor.visitMinimum(minimum) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Price = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitUnit(unit: NewPlanUnitPrice) { + unit.validate() + } + + override fun visitTiered(tiered: NewPlanTieredPrice) { + tiered.validate() + } + + override fun visitBulk(bulk: NewPlanBulkPrice) { + bulk.validate() + } + + override fun visitPackage(package_: NewPlanPackagePrice) { + package_.validate() + } + + override fun visitMatrix(matrix: NewPlanMatrixPrice) { + matrix.validate() + } + + override fun visitThresholdTotalAmount( + thresholdTotalAmount: NewPlanThresholdTotalAmountPrice + ) { + thresholdTotalAmount.validate() + } + + override fun visitTieredPackage(tieredPackage: NewPlanTieredPackagePrice) { + tieredPackage.validate() + } + + override fun visitTieredWithMinimum( + tieredWithMinimum: NewPlanTieredWithMinimumPrice + ) { + tieredWithMinimum.validate() + } + + override fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) { + groupedTiered.validate() + } + + override fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice + ) { + tieredPackageWithMinimum.validate() + } + + override fun visitPackageWithAllocation( + packageWithAllocation: NewPlanPackageWithAllocationPrice + ) { + packageWithAllocation.validate() + } + + override fun visitUnitWithPercent( + unitWithPercent: NewPlanUnitWithPercentPrice + ) { + unitWithPercent.validate() + } + + override fun visitMatrixWithAllocation( + matrixWithAllocation: NewPlanMatrixWithAllocationPrice + ) { + matrixWithAllocation.validate() + } + + override fun visitTieredWithProration( + tieredWithProration: TieredWithProration + ) { + tieredWithProration.validate() + } + + override fun visitUnitWithProration( + unitWithProration: NewPlanUnitWithProrationPrice + ) { + unitWithProration.validate() + } + + override fun visitGroupedAllocation( + groupedAllocation: NewPlanGroupedAllocationPrice + ) { + groupedAllocation.validate() + } + + override fun visitBulkWithProration( + bulkWithProration: NewPlanBulkWithProrationPrice + ) { + bulkWithProration.validate() + } + + override fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice + ) { + groupedWithProratedMinimum.validate() + } + + override fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice + ) { + groupedWithMeteredMinimum.validate() + } + + override fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) { + groupedWithMinMaxThresholds.validate() + } + + override fun visitMatrixWithDisplayName( + matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice + ) { + matrixWithDisplayName.validate() + } + + override fun visitGroupedTieredPackage( + groupedTieredPackage: NewPlanGroupedTieredPackagePrice + ) { + groupedTieredPackage.validate() + } + + override fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice + ) { + maxGroupTieredPackage.validate() + } + + override fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice + ) { + scalableMatrixWithUnitPricing.validate() + } + + override fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: + NewPlanScalableMatrixWithTieredPricingPrice + ) { + scalableMatrixWithTieredPricing.validate() + } + + override fun visitCumulativeGroupedBulk( + cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice + ) { + cumulativeGroupedBulk.validate() + } + + override fun visitMinimum(minimum: NewPlanMinimumCompositePrice) { + minimum.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitUnit(unit: NewPlanUnitPrice) = unit.validity() + + override fun visitTiered(tiered: NewPlanTieredPrice) = tiered.validity() + + override fun visitBulk(bulk: NewPlanBulkPrice) = bulk.validity() + + override fun visitPackage(package_: NewPlanPackagePrice) = + package_.validity() + + override fun visitMatrix(matrix: NewPlanMatrixPrice) = matrix.validity() + + override fun visitThresholdTotalAmount( + thresholdTotalAmount: NewPlanThresholdTotalAmountPrice + ) = thresholdTotalAmount.validity() + + override fun visitTieredPackage(tieredPackage: NewPlanTieredPackagePrice) = + tieredPackage.validity() + + override fun visitTieredWithMinimum( + tieredWithMinimum: NewPlanTieredWithMinimumPrice + ) = tieredWithMinimum.validity() + + override fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) = + groupedTiered.validity() + + override fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice + ) = tieredPackageWithMinimum.validity() + + override fun visitPackageWithAllocation( + packageWithAllocation: NewPlanPackageWithAllocationPrice + ) = packageWithAllocation.validity() + + override fun visitUnitWithPercent( + unitWithPercent: NewPlanUnitWithPercentPrice + ) = unitWithPercent.validity() + + override fun visitMatrixWithAllocation( + matrixWithAllocation: NewPlanMatrixWithAllocationPrice + ) = matrixWithAllocation.validity() + + override fun visitTieredWithProration( + tieredWithProration: TieredWithProration + ) = tieredWithProration.validity() + + override fun visitUnitWithProration( + unitWithProration: NewPlanUnitWithProrationPrice + ) = unitWithProration.validity() + + override fun visitGroupedAllocation( + groupedAllocation: NewPlanGroupedAllocationPrice + ) = groupedAllocation.validity() + + override fun visitBulkWithProration( + bulkWithProration: NewPlanBulkWithProrationPrice + ) = bulkWithProration.validity() + + override fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice + ) = groupedWithProratedMinimum.validity() + + override fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice + ) = groupedWithMeteredMinimum.validity() + + override fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) = groupedWithMinMaxThresholds.validity() + + override fun visitMatrixWithDisplayName( + matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice + ) = matrixWithDisplayName.validity() + + override fun visitGroupedTieredPackage( + groupedTieredPackage: NewPlanGroupedTieredPackagePrice + ) = groupedTieredPackage.validity() + + override fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice + ) = maxGroupTieredPackage.validity() + + override fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice + ) = scalableMatrixWithUnitPricing.validity() + + override fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: + NewPlanScalableMatrixWithTieredPricingPrice + ) = scalableMatrixWithTieredPricing.validity() + + override fun visitCumulativeGroupedBulk( + cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice + ) = cumulativeGroupedBulk.validity() + + override fun visitMinimum(minimum: NewPlanMinimumCompositePrice) = + minimum.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Price && + unit == other.unit && + tiered == other.tiered && + bulk == other.bulk && + package_ == other.package_ && + matrix == other.matrix && + thresholdTotalAmount == other.thresholdTotalAmount && + tieredPackage == other.tieredPackage && + tieredWithMinimum == other.tieredWithMinimum && + groupedTiered == other.groupedTiered && + tieredPackageWithMinimum == other.tieredPackageWithMinimum && + packageWithAllocation == other.packageWithAllocation && + unitWithPercent == other.unitWithPercent && + matrixWithAllocation == other.matrixWithAllocation && + tieredWithProration == other.tieredWithProration && + unitWithProration == other.unitWithProration && + groupedAllocation == other.groupedAllocation && + bulkWithProration == other.bulkWithProration && + groupedWithProratedMinimum == other.groupedWithProratedMinimum && + groupedWithMeteredMinimum == other.groupedWithMeteredMinimum && + groupedWithMinMaxThresholds == other.groupedWithMinMaxThresholds && + matrixWithDisplayName == other.matrixWithDisplayName && + groupedTieredPackage == other.groupedTieredPackage && + maxGroupTieredPackage == other.maxGroupTieredPackage && + scalableMatrixWithUnitPricing == other.scalableMatrixWithUnitPricing && + scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && + cumulativeGroupedBulk == other.cumulativeGroupedBulk && + minimum == other.minimum + } + + override fun hashCode(): Int = + Objects.hash( + unit, + tiered, + bulk, + package_, + matrix, + thresholdTotalAmount, + tieredPackage, + tieredWithMinimum, + groupedTiered, + tieredPackageWithMinimum, + packageWithAllocation, + unitWithPercent, + matrixWithAllocation, + tieredWithProration, + unitWithProration, + groupedAllocation, + bulkWithProration, + groupedWithProratedMinimum, + groupedWithMeteredMinimum, + groupedWithMinMaxThresholds, + matrixWithDisplayName, + groupedTieredPackage, + maxGroupTieredPackage, + scalableMatrixWithUnitPricing, + scalableMatrixWithTieredPricing, + cumulativeGroupedBulk, + minimum, + ) + + override fun toString(): String = + when { + unit != null -> "Price{unit=$unit}" + tiered != null -> "Price{tiered=$tiered}" + bulk != null -> "Price{bulk=$bulk}" + package_ != null -> "Price{package_=$package_}" + matrix != null -> "Price{matrix=$matrix}" + thresholdTotalAmount != null -> + "Price{thresholdTotalAmount=$thresholdTotalAmount}" + tieredPackage != null -> "Price{tieredPackage=$tieredPackage}" + tieredWithMinimum != null -> "Price{tieredWithMinimum=$tieredWithMinimum}" + groupedTiered != null -> "Price{groupedTiered=$groupedTiered}" + tieredPackageWithMinimum != null -> + "Price{tieredPackageWithMinimum=$tieredPackageWithMinimum}" + packageWithAllocation != null -> + "Price{packageWithAllocation=$packageWithAllocation}" + unitWithPercent != null -> "Price{unitWithPercent=$unitWithPercent}" + matrixWithAllocation != null -> + "Price{matrixWithAllocation=$matrixWithAllocation}" + tieredWithProration != null -> "Price{tieredWithProration=$tieredWithProration}" + unitWithProration != null -> "Price{unitWithProration=$unitWithProration}" + groupedAllocation != null -> "Price{groupedAllocation=$groupedAllocation}" + bulkWithProration != null -> "Price{bulkWithProration=$bulkWithProration}" + groupedWithProratedMinimum != null -> + "Price{groupedWithProratedMinimum=$groupedWithProratedMinimum}" + groupedWithMeteredMinimum != null -> + "Price{groupedWithMeteredMinimum=$groupedWithMeteredMinimum}" + groupedWithMinMaxThresholds != null -> + "Price{groupedWithMinMaxThresholds=$groupedWithMinMaxThresholds}" + matrixWithDisplayName != null -> + "Price{matrixWithDisplayName=$matrixWithDisplayName}" + groupedTieredPackage != null -> + "Price{groupedTieredPackage=$groupedTieredPackage}" + maxGroupTieredPackage != null -> + "Price{maxGroupTieredPackage=$maxGroupTieredPackage}" + scalableMatrixWithUnitPricing != null -> + "Price{scalableMatrixWithUnitPricing=$scalableMatrixWithUnitPricing}" + scalableMatrixWithTieredPricing != null -> + "Price{scalableMatrixWithTieredPricing=$scalableMatrixWithTieredPricing}" + cumulativeGroupedBulk != null -> + "Price{cumulativeGroupedBulk=$cumulativeGroupedBulk}" + minimum != null -> "Price{minimum=$minimum}" + _json != null -> "Price{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Price") + } + + companion object { + + fun ofUnit(unit: NewPlanUnitPrice) = Price(unit = unit) + + fun ofTiered(tiered: NewPlanTieredPrice) = Price(tiered = tiered) + + fun ofBulk(bulk: NewPlanBulkPrice) = Price(bulk = bulk) + + fun ofPackage(package_: NewPlanPackagePrice) = Price(package_ = package_) + + fun ofMatrix(matrix: NewPlanMatrixPrice) = Price(matrix = matrix) + + fun ofThresholdTotalAmount(thresholdTotalAmount: NewPlanThresholdTotalAmountPrice) = + Price(thresholdTotalAmount = thresholdTotalAmount) + + fun ofTieredPackage(tieredPackage: NewPlanTieredPackagePrice) = + Price(tieredPackage = tieredPackage) + + fun ofTieredWithMinimum(tieredWithMinimum: NewPlanTieredWithMinimumPrice) = + Price(tieredWithMinimum = tieredWithMinimum) + + fun ofGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) = + Price(groupedTiered = groupedTiered) + + fun ofTieredPackageWithMinimum( + tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice + ) = Price(tieredPackageWithMinimum = tieredPackageWithMinimum) + + fun ofPackageWithAllocation( + packageWithAllocation: NewPlanPackageWithAllocationPrice + ) = Price(packageWithAllocation = packageWithAllocation) + + fun ofUnitWithPercent(unitWithPercent: NewPlanUnitWithPercentPrice) = + Price(unitWithPercent = unitWithPercent) + + fun ofMatrixWithAllocation(matrixWithAllocation: NewPlanMatrixWithAllocationPrice) = + Price(matrixWithAllocation = matrixWithAllocation) + + fun ofTieredWithProration(tieredWithProration: TieredWithProration) = + Price(tieredWithProration = tieredWithProration) + + fun ofUnitWithProration(unitWithProration: NewPlanUnitWithProrationPrice) = + Price(unitWithProration = unitWithProration) + + fun ofGroupedAllocation(groupedAllocation: NewPlanGroupedAllocationPrice) = + Price(groupedAllocation = groupedAllocation) + + fun ofBulkWithProration(bulkWithProration: NewPlanBulkWithProrationPrice) = + Price(bulkWithProration = bulkWithProration) + + fun ofGroupedWithProratedMinimum( + groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice + ) = Price(groupedWithProratedMinimum = groupedWithProratedMinimum) + + fun ofGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice + ) = Price(groupedWithMeteredMinimum = groupedWithMeteredMinimum) + + fun ofGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) = Price(groupedWithMinMaxThresholds = groupedWithMinMaxThresholds) + + fun ofMatrixWithDisplayName( + matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice + ) = Price(matrixWithDisplayName = matrixWithDisplayName) + + fun ofGroupedTieredPackage(groupedTieredPackage: NewPlanGroupedTieredPackagePrice) = + Price(groupedTieredPackage = groupedTieredPackage) + + fun ofMaxGroupTieredPackage( + maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice + ) = Price(maxGroupTieredPackage = maxGroupTieredPackage) + + fun ofScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice + ) = Price(scalableMatrixWithUnitPricing = scalableMatrixWithUnitPricing) + + fun ofScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: NewPlanScalableMatrixWithTieredPricingPrice + ) = Price(scalableMatrixWithTieredPricing = scalableMatrixWithTieredPricing) + + fun ofCumulativeGroupedBulk( + cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice + ) = Price(cumulativeGroupedBulk = cumulativeGroupedBulk) + + fun ofMinimum(minimum: NewPlanMinimumCompositePrice) = Price(minimum = minimum) + } + + /** + * An interface that defines how to map each variant of [Price] to a value of type [T]. + */ + interface Visitor { + + fun visitUnit(unit: NewPlanUnitPrice): T + + fun visitTiered(tiered: NewPlanTieredPrice): T + + fun visitBulk(bulk: NewPlanBulkPrice): T + + fun visitPackage(package_: NewPlanPackagePrice): T + + fun visitMatrix(matrix: NewPlanMatrixPrice): T + + fun visitThresholdTotalAmount( + thresholdTotalAmount: NewPlanThresholdTotalAmountPrice + ): T + + fun visitTieredPackage(tieredPackage: NewPlanTieredPackagePrice): T + + fun visitTieredWithMinimum(tieredWithMinimum: NewPlanTieredWithMinimumPrice): T + + fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice): T + + fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice + ): T + + fun visitPackageWithAllocation( + packageWithAllocation: NewPlanPackageWithAllocationPrice + ): T + + fun visitUnitWithPercent(unitWithPercent: NewPlanUnitWithPercentPrice): T + + fun visitMatrixWithAllocation( + matrixWithAllocation: NewPlanMatrixWithAllocationPrice + ): T + + fun visitTieredWithProration(tieredWithProration: TieredWithProration): T + + fun visitUnitWithProration(unitWithProration: NewPlanUnitWithProrationPrice): T + + fun visitGroupedAllocation(groupedAllocation: NewPlanGroupedAllocationPrice): T + + fun visitBulkWithProration(bulkWithProration: NewPlanBulkWithProrationPrice): T + + fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice + ): T + + fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice + ): T + + fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ): T + + fun visitMatrixWithDisplayName( + matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice + ): T + + fun visitGroupedTieredPackage( + groupedTieredPackage: NewPlanGroupedTieredPackagePrice + ): T + + fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice + ): T + + fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice + ): T + + fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: NewPlanScalableMatrixWithTieredPricingPrice + ): T + + fun visitCumulativeGroupedBulk( + cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice + ): T + + fun visitMinimum(minimum: NewPlanMinimumCompositePrice): T + + /** + * Maps an unknown variant of [Price] to a value of type [T]. + * + * An instance of [Price] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is + * unaware of. + * + * @throws OrbInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw OrbInvalidDataException("Unknown Price: $json") + } + } + + internal class Deserializer : BaseDeserializer(Price::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Price { + val json = JsonValue.fromJsonNode(node) + val modelType = json.asObject()?.get("model_type")?.asString() + + when (modelType) { + "unit" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(unit = it, _json = json) + } ?: Price(_json = json) + } + "tiered" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(tiered = it, _json = json) + } ?: Price(_json = json) + } + "bulk" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(bulk = it, _json = json) + } ?: Price(_json = json) + } + "package" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(package_ = it, _json = json) } ?: Price(_json = json) + } + "matrix" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(matrix = it, _json = json) + } ?: Price(_json = json) + } + "threshold_total_amount" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(thresholdTotalAmount = it, _json = json) } + ?: Price(_json = json) + } + "tiered_package" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(tieredPackage = it, _json = json) } + ?: Price(_json = json) + } + "tiered_with_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(tieredWithMinimum = it, _json = json) } + ?: Price(_json = json) + } + "grouped_tiered" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(groupedTiered = it, _json = json) } + ?: Price(_json = json) + } + "tiered_package_with_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(tieredPackageWithMinimum = it, _json = json) } + ?: Price(_json = json) + } + "package_with_allocation" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(packageWithAllocation = it, _json = json) } + ?: Price(_json = json) + } + "unit_with_percent" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(unitWithPercent = it, _json = json) } + ?: Price(_json = json) + } + "matrix_with_allocation" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(matrixWithAllocation = it, _json = json) } + ?: Price(_json = json) + } + "tiered_with_proration" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(tieredWithProration = it, _json = json) } + ?: Price(_json = json) + } + "unit_with_proration" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(unitWithProration = it, _json = json) } + ?: Price(_json = json) + } + "grouped_allocation" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedAllocation = it, _json = json) } + ?: Price(_json = json) + } + "bulk_with_proration" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(bulkWithProration = it, _json = json) } + ?: Price(_json = json) + } + "grouped_with_prorated_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedWithProratedMinimum = it, _json = json) } + ?: Price(_json = json) + } + "grouped_with_metered_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedWithMeteredMinimum = it, _json = json) } + ?: Price(_json = json) + } + "grouped_with_min_max_thresholds" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedWithMinMaxThresholds = it, _json = json) } + ?: Price(_json = json) + } + "matrix_with_display_name" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(matrixWithDisplayName = it, _json = json) } + ?: Price(_json = json) + } + "grouped_tiered_package" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedTieredPackage = it, _json = json) } + ?: Price(_json = json) + } + "max_group_tiered_package" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(maxGroupTieredPackage = it, _json = json) } + ?: Price(_json = json) + } + "scalable_matrix_with_unit_pricing" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(scalableMatrixWithUnitPricing = it, _json = json) } + ?: Price(_json = json) + } + "scalable_matrix_with_tiered_pricing" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(scalableMatrixWithTieredPricing = it, _json = json) } + ?: Price(_json = json) + } + "cumulative_grouped_bulk" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(cumulativeGroupedBulk = it, _json = json) } + ?: Price(_json = json) + } + "minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(minimum = it, _json = json) } ?: Price(_json = json) + } + } + + return Price(_json = json) + } + } + + internal class Serializer : BaseSerializer(Price::class) { + + override fun serialize( + value: Price, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.unit != null -> generator.writeObject(value.unit) + value.tiered != null -> generator.writeObject(value.tiered) + value.bulk != null -> generator.writeObject(value.bulk) + value.package_ != null -> generator.writeObject(value.package_) + value.matrix != null -> generator.writeObject(value.matrix) + value.thresholdTotalAmount != null -> + generator.writeObject(value.thresholdTotalAmount) + value.tieredPackage != null -> generator.writeObject(value.tieredPackage) + value.tieredWithMinimum != null -> + generator.writeObject(value.tieredWithMinimum) + value.groupedTiered != null -> generator.writeObject(value.groupedTiered) + value.tieredPackageWithMinimum != null -> + generator.writeObject(value.tieredPackageWithMinimum) + value.packageWithAllocation != null -> + generator.writeObject(value.packageWithAllocation) + value.unitWithPercent != null -> + generator.writeObject(value.unitWithPercent) + value.matrixWithAllocation != null -> + generator.writeObject(value.matrixWithAllocation) + value.tieredWithProration != null -> + generator.writeObject(value.tieredWithProration) + value.unitWithProration != null -> + generator.writeObject(value.unitWithProration) + value.groupedAllocation != null -> + generator.writeObject(value.groupedAllocation) + value.bulkWithProration != null -> + generator.writeObject(value.bulkWithProration) + value.groupedWithProratedMinimum != null -> + generator.writeObject(value.groupedWithProratedMinimum) + value.groupedWithMeteredMinimum != null -> + generator.writeObject(value.groupedWithMeteredMinimum) + value.groupedWithMinMaxThresholds != null -> + generator.writeObject(value.groupedWithMinMaxThresholds) + value.matrixWithDisplayName != null -> + generator.writeObject(value.matrixWithDisplayName) + value.groupedTieredPackage != null -> + generator.writeObject(value.groupedTieredPackage) + value.maxGroupTieredPackage != null -> + generator.writeObject(value.maxGroupTieredPackage) + value.scalableMatrixWithUnitPricing != null -> + generator.writeObject(value.scalableMatrixWithUnitPricing) + value.scalableMatrixWithTieredPricing != null -> + generator.writeObject(value.scalableMatrixWithTieredPricing) + value.cumulativeGroupedBulk != null -> + generator.writeObject(value.cumulativeGroupedBulk) + value.minimum != null -> generator.writeObject(value.minimum) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Price") + } + } + } + + class TieredWithProration + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val tieredWithProrationConfig: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("tiered_with_proration_config") + @ExcludeMissing + tieredWithProrationConfig: JsonField = + JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + modelType, + name, + tieredWithProrationConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("tiered_with_proration") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType - fun isBulk(): Boolean = bulk != null + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") - fun isThresholdTotalAmount(): Boolean = thresholdTotalAmount != null + /** + * Configuration for tiered_with_proration pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun tieredWithProrationConfig(): TieredWithProrationConfig = + tieredWithProrationConfig.getRequired("tiered_with_proration_config") - fun isTieredPackage(): Boolean = tieredPackage != null + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = billableMetricId.getNullable("billable_metric_id") - fun isTieredWithMinimum(): Boolean = tieredWithMinimum != null + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") - fun isUnitWithPercent(): Boolean = unitWithPercent != null + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") - fun isPackageWithAllocation(): Boolean = packageWithAllocation != null + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") - fun isTieredWithProration(): Boolean = tieredWithProration != null + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") - fun isUnitWithProration(): Boolean = unitWithProration != null + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") - fun isGroupedAllocation(): Boolean = groupedAllocation != null + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") - fun isGroupedWithProratedMinimum(): Boolean = groupedWithProratedMinimum != null + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") - fun isGroupedWithMeteredMinimum(): Boolean = groupedWithMeteredMinimum != null + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") - fun isGroupedWithMinMaxThresholds(): Boolean = groupedWithMinMaxThresholds != null + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + invoiceGroupingKey.getNullable("invoice_grouping_key") - fun isMatrixWithDisplayName(): Boolean = matrixWithDisplayName != null + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - fun isBulkWithProration(): Boolean = bulkWithProration != null + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") - fun isGroupedTieredPackage(): Boolean = groupedTieredPackage != null + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") - fun isMaxGroupTieredPackage(): Boolean = maxGroupTieredPackage != null + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence - fun isScalableMatrixWithUnitPricing(): Boolean = scalableMatrixWithUnitPricing != null + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - fun isScalableMatrixWithTieredPricing(): Boolean = - scalableMatrixWithTieredPricing != null + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - fun isCumulativeGroupedBulk(): Boolean = cumulativeGroupedBulk != null + /** + * Returns the raw JSON value of [tieredWithProrationConfig]. + * + * Unlike [tieredWithProrationConfig], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("tiered_with_proration_config") + @ExcludeMissing + fun _tieredWithProrationConfig(): JsonField = + tieredWithProrationConfig - fun isTieredPackageWithMinimum(): Boolean = tieredPackageWithMinimum != null + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId - fun isMatrixWithAllocation(): Boolean = matrixWithAllocation != null + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance - fun isGroupedTiered(): Boolean = groupedTiered != null + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration - fun isMinimum(): Boolean = minimum != null + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate - fun asUnit(): NewPlanUnitPrice = unit.getOrThrow("unit") + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig - fun asPackage(): NewPlanPackagePrice = package_.getOrThrow("package_") + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency - fun asMatrix(): NewPlanMatrixPrice = matrix.getOrThrow("matrix") + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration - fun asTiered(): NewPlanTieredPrice = tiered.getOrThrow("tiered") + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId - fun asBulk(): NewPlanBulkPrice = bulk.getOrThrow("bulk") + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - fun asThresholdTotalAmount(): NewPlanThresholdTotalAmountPrice = - thresholdTotalAmount.getOrThrow("thresholdTotalAmount") + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - fun asTieredPackage(): NewPlanTieredPackagePrice = - tieredPackage.getOrThrow("tieredPackage") + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration - fun asTieredWithMinimum(): NewPlanTieredWithMinimumPrice = - tieredWithMinimum.getOrThrow("tieredWithMinimum") + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata - fun asUnitWithPercent(): NewPlanUnitWithPercentPrice = - unitWithPercent.getOrThrow("unitWithPercent") + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId - fun asPackageWithAllocation(): NewPlanPackageWithAllocationPrice = - packageWithAllocation.getOrThrow("packageWithAllocation") + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - fun asTieredWithProration(): NewPlanTierWithProrationPrice = - tieredWithProration.getOrThrow("tieredWithProration") + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - fun asUnitWithProration(): NewPlanUnitWithProrationPrice = - unitWithProration.getOrThrow("unitWithProration") + fun toBuilder() = Builder().from(this) - fun asGroupedAllocation(): NewPlanGroupedAllocationPrice = - groupedAllocation.getOrThrow("groupedAllocation") + companion object { - fun asGroupedWithProratedMinimum(): NewPlanGroupedWithProratedMinimumPrice = - groupedWithProratedMinimum.getOrThrow("groupedWithProratedMinimum") + /** + * Returns a mutable builder for constructing an instance of + * [TieredWithProration]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .name() + * .tieredWithProrationConfig() + * ``` + */ + fun builder() = Builder() + } - fun asGroupedWithMeteredMinimum(): NewPlanGroupedWithMeteredMinimumPrice = - groupedWithMeteredMinimum.getOrThrow("groupedWithMeteredMinimum") + /** A builder for [TieredWithProration]. */ + class Builder internal constructor() { - fun asGroupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds = - groupedWithMinMaxThresholds.getOrThrow("groupedWithMinMaxThresholds") + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonValue = JsonValue.from("tiered_with_proration") + private var name: JsonField? = null + private var tieredWithProrationConfig: JsonField? = + null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - fun asMatrixWithDisplayName(): NewPlanMatrixWithDisplayNamePrice = - matrixWithDisplayName.getOrThrow("matrixWithDisplayName") + internal fun from(tieredWithProration: TieredWithProration) = apply { + cadence = tieredWithProration.cadence + itemId = tieredWithProration.itemId + modelType = tieredWithProration.modelType + name = tieredWithProration.name + tieredWithProrationConfig = tieredWithProration.tieredWithProrationConfig + billableMetricId = tieredWithProration.billableMetricId + billedInAdvance = tieredWithProration.billedInAdvance + billingCycleConfiguration = tieredWithProration.billingCycleConfiguration + conversionRate = tieredWithProration.conversionRate + conversionRateConfig = tieredWithProration.conversionRateConfig + currency = tieredWithProration.currency + dimensionalPriceConfiguration = + tieredWithProration.dimensionalPriceConfiguration + externalPriceId = tieredWithProration.externalPriceId + fixedPriceQuantity = tieredWithProration.fixedPriceQuantity + invoiceGroupingKey = tieredWithProration.invoiceGroupingKey + invoicingCycleConfiguration = + tieredWithProration.invoicingCycleConfiguration + metadata = tieredWithProration.metadata + referenceId = tieredWithProration.referenceId + additionalProperties = + tieredWithProration.additionalProperties.toMutableMap() + } - fun asBulkWithProration(): NewPlanBulkWithProrationPrice = - bulkWithProration.getOrThrow("bulkWithProration") + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - fun asGroupedTieredPackage(): NewPlanGroupedTieredPackagePrice = - groupedTieredPackage.getOrThrow("groupedTieredPackage") + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - fun asMaxGroupTieredPackage(): NewPlanMaxGroupTieredPackagePrice = - maxGroupTieredPackage.getOrThrow("maxGroupTieredPackage") + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - fun asScalableMatrixWithUnitPricing(): NewPlanScalableMatrixWithUnitPricingPrice = - scalableMatrixWithUnitPricing.getOrThrow("scalableMatrixWithUnitPricing") + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun asScalableMatrixWithTieredPricing(): NewPlanScalableMatrixWithTieredPricingPrice = - scalableMatrixWithTieredPricing.getOrThrow("scalableMatrixWithTieredPricing") + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("tiered_with_proration") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } - fun asCumulativeGroupedBulk(): NewPlanCumulativeGroupedBulkPrice = - cumulativeGroupedBulk.getOrThrow("cumulativeGroupedBulk") + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) - fun asTieredPackageWithMinimum(): NewPlanTieredPackageWithMinimumPrice = - tieredPackageWithMinimum.getOrThrow("tieredPackageWithMinimum") + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } - fun asMatrixWithAllocation(): NewPlanMatrixWithAllocationPrice = - matrixWithAllocation.getOrThrow("matrixWithAllocation") + /** Configuration for tiered_with_proration pricing */ + fun tieredWithProrationConfig( + tieredWithProrationConfig: TieredWithProrationConfig + ) = tieredWithProrationConfig(JsonField.of(tieredWithProrationConfig)) - fun asGroupedTiered(): NewPlanGroupedTieredPrice = - groupedTiered.getOrThrow("groupedTiered") + /** + * Sets [Builder.tieredWithProrationConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.tieredWithProrationConfig] with a well-typed + * [TieredWithProrationConfig] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun tieredWithProrationConfig( + tieredWithProrationConfig: JsonField + ) = apply { this.tieredWithProrationConfig = tieredWithProrationConfig } - fun asMinimum(): NewPlanMinimumCompositePrice = minimum.getOrThrow("minimum") + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) - fun _json(): JsonValue? = _json + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - package_ != null -> visitor.visitPackage(package_) - matrix != null -> visitor.visitMatrix(matrix) - tiered != null -> visitor.visitTiered(tiered) - bulk != null -> visitor.visitBulk(bulk) - thresholdTotalAmount != null -> - visitor.visitThresholdTotalAmount(thresholdTotalAmount) - tieredPackage != null -> visitor.visitTieredPackage(tieredPackage) - tieredWithMinimum != null -> visitor.visitTieredWithMinimum(tieredWithMinimum) - unitWithPercent != null -> visitor.visitUnitWithPercent(unitWithPercent) - packageWithAllocation != null -> - visitor.visitPackageWithAllocation(packageWithAllocation) - tieredWithProration != null -> - visitor.visitTieredWithProration(tieredWithProration) - unitWithProration != null -> visitor.visitUnitWithProration(unitWithProration) - groupedAllocation != null -> visitor.visitGroupedAllocation(groupedAllocation) - groupedWithProratedMinimum != null -> - visitor.visitGroupedWithProratedMinimum(groupedWithProratedMinimum) - groupedWithMeteredMinimum != null -> - visitor.visitGroupedWithMeteredMinimum(groupedWithMeteredMinimum) - groupedWithMinMaxThresholds != null -> - visitor.visitGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds) - matrixWithDisplayName != null -> - visitor.visitMatrixWithDisplayName(matrixWithDisplayName) - bulkWithProration != null -> visitor.visitBulkWithProration(bulkWithProration) - groupedTieredPackage != null -> - visitor.visitGroupedTieredPackage(groupedTieredPackage) - maxGroupTieredPackage != null -> - visitor.visitMaxGroupTieredPackage(maxGroupTieredPackage) - scalableMatrixWithUnitPricing != null -> - visitor.visitScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing) - scalableMatrixWithTieredPricing != null -> - visitor.visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing - ) - cumulativeGroupedBulk != null -> - visitor.visitCumulativeGroupedBulk(cumulativeGroupedBulk) - tieredPackageWithMinimum != null -> - visitor.visitTieredPackageWithMinimum(tieredPackageWithMinimum) - matrixWithAllocation != null -> - visitor.visitMatrixWithAllocation(matrixWithAllocation) - groupedTiered != null -> visitor.visitGroupedTiered(groupedTiered) - minimum != null -> visitor.visitMinimum(minimum) - else -> visitor.unknown(_json) - } + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) - private var validated: Boolean = false + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) - fun validate(): Price = apply { - if (validated) { - return@apply - } + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } - accept( - object : Visitor { - override fun visitUnit(unit: NewPlanUnitPrice) { - unit.validate() - } + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - override fun visitPackage(package_: NewPlanPackagePrice) { - package_.validate() - } + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } - override fun visitMatrix(matrix: NewPlanMatrixPrice) { - matrix.validate() - } + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) - override fun visitTiered(tiered: NewPlanTieredPrice) { - tiered.validate() - } + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) - override fun visitBulk(bulk: NewPlanBulkPrice) { - bulk.validate() - } + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } - override fun visitThresholdTotalAmount( - thresholdTotalAmount: NewPlanThresholdTotalAmountPrice - ) { - thresholdTotalAmount.validate() - } + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) - override fun visitTieredPackage(tieredPackage: NewPlanTieredPackagePrice) { - tieredPackage.validate() - } + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } - override fun visitTieredWithMinimum( - tieredWithMinimum: NewPlanTieredWithMinimumPrice - ) { - tieredWithMinimum.validate() - } + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) - override fun visitUnitWithPercent( - unitWithPercent: NewPlanUnitWithPercentPrice - ) { - unitWithPercent.validate() - } + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) - override fun visitPackageWithAllocation( - packageWithAllocation: NewPlanPackageWithAllocationPrice - ) { - packageWithAllocation.validate() - } + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) - override fun visitTieredWithProration( - tieredWithProration: NewPlanTierWithProrationPrice - ) { - tieredWithProration.validate() - } + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) - override fun visitUnitWithProration( - unitWithProration: NewPlanUnitWithProrationPrice - ) { - unitWithProration.validate() - } + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) - override fun visitGroupedAllocation( - groupedAllocation: NewPlanGroupedAllocationPrice - ) { - groupedAllocation.validate() - } + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } - override fun visitGroupedWithProratedMinimum( - groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice - ) { - groupedWithProratedMinimum.validate() - } + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) - override fun visitGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice - ) { - groupedWithMeteredMinimum.validate() - } + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } - override fun visitGroupedWithMinMaxThresholds( - groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds - ) { - groupedWithMinMaxThresholds.validate() - } + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) - override fun visitMatrixWithDisplayName( - matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice - ) { - matrixWithDisplayName.validate() - } + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } - override fun visitBulkWithProration( - bulkWithProration: NewPlanBulkWithProrationPrice - ) { - bulkWithProration.validate() - } + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) - override fun visitGroupedTieredPackage( - groupedTieredPackage: NewPlanGroupedTieredPackagePrice - ) { - groupedTieredPackage.validate() - } + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } - override fun visitMaxGroupTieredPackage( - maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice - ) { - maxGroupTieredPackage.validate() - } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) - override fun visitScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice - ) { - scalableMatrixWithUnitPricing.validate() - } + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } - override fun visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: - NewPlanScalableMatrixWithTieredPricingPrice - ) { - scalableMatrixWithTieredPricing.validate() - } + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) - override fun visitCumulativeGroupedBulk( - cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice - ) { - cumulativeGroupedBulk.validate() - } + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - override fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice - ) { - tieredPackageWithMinimum.validate() - } + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - override fun visitMatrixWithAllocation( - matrixWithAllocation: NewPlanMatrixWithAllocationPrice - ) { - matrixWithAllocation.validate() - } + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - override fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) { - groupedTiered.validate() - } + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) - override fun visitMinimum(minimum: NewPlanMinimumCompositePrice) { - minimum.validate() - } + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId } - ) - validated = true - } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: NewPlanUnitPrice) = unit.validity() + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - override fun visitPackage(package_: NewPlanPackagePrice) = - package_.validity() + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - override fun visitMatrix(matrix: NewPlanMatrixPrice) = matrix.validity() + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - override fun visitTiered(tiered: NewPlanTieredPrice) = tiered.validity() + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - override fun visitBulk(bulk: NewPlanBulkPrice) = bulk.validity() + /** + * Returns an immutable instance of [TieredWithProration]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .name() + * .tieredWithProrationConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TieredWithProration = + TieredWithProration( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + modelType, + checkRequired("name", name), + checkRequired("tieredWithProrationConfig", tieredWithProrationConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } - override fun visitThresholdTotalAmount( - thresholdTotalAmount: NewPlanThresholdTotalAmountPrice - ) = thresholdTotalAmount.validity() + private var validated: Boolean = false - override fun visitTieredPackage(tieredPackage: NewPlanTieredPackagePrice) = - tieredPackage.validity() + fun validate(): TieredWithProration = apply { + if (validated) { + return@apply + } - override fun visitTieredWithMinimum( - tieredWithMinimum: NewPlanTieredWithMinimumPrice - ) = tieredWithMinimum.validity() + cadence().validate() + itemId() + _modelType().let { + if (it != JsonValue.from("tiered_with_proration")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + tieredWithProrationConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + metadata()?.validate() + referenceId() + validated = true + } - override fun visitUnitWithPercent( - unitWithPercent: NewPlanUnitWithPercentPrice - ) = unitWithPercent.validity() + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - override fun visitPackageWithAllocation( - packageWithAllocation: NewPlanPackageWithAllocationPrice - ) = packageWithAllocation.validity() + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + modelType.let { + if (it == JsonValue.from("tiered_with_proration")) 1 else 0 + } + + (if (name.asKnown() == null) 0 else 1) + + (tieredWithProrationConfig.asKnown()?.validity() ?: 0) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) - override fun visitTieredWithProration( - tieredWithProration: NewPlanTierWithProrationPrice - ) = tieredWithProration.validity() + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { - override fun visitUnitWithProration( - unitWithProration: NewPlanUnitWithProrationPrice - ) = unitWithProration.validity() + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value - override fun visitGroupedAllocation( - groupedAllocation: NewPlanGroupedAllocationPrice - ) = groupedAllocation.validity() + companion object { - override fun visitGroupedWithProratedMinimum( - groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice - ) = groupedWithProratedMinimum.validity() + val ANNUAL = of("annual") - override fun visitGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice - ) = groupedWithMeteredMinimum.validity() + val SEMI_ANNUAL = of("semi_annual") - override fun visitGroupedWithMinMaxThresholds( - groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds - ) = groupedWithMinMaxThresholds.validity() + val MONTHLY = of("monthly") - override fun visitMatrixWithDisplayName( - matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice - ) = matrixWithDisplayName.validity() + val QUARTERLY = of("quarterly") - override fun visitBulkWithProration( - bulkWithProration: NewPlanBulkWithProrationPrice - ) = bulkWithProration.validity() + val ONE_TIME = of("one_time") - override fun visitGroupedTieredPackage( - groupedTieredPackage: NewPlanGroupedTieredPackagePrice - ) = groupedTieredPackage.validity() + val CUSTOM = of("custom") - override fun visitMaxGroupTieredPackage( - maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice - ) = maxGroupTieredPackage.validity() + fun of(value: String) = Cadence(JsonField.of(value)) + } - override fun visitScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice - ) = scalableMatrixWithUnitPricing.validity() + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } - override fun visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: - NewPlanScalableMatrixWithTieredPricingPrice - ) = scalableMatrixWithTieredPricing.validity() + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } - override fun visitCumulativeGroupedBulk( - cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice - ) = cumulativeGroupedBulk.validity() + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } - override fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice - ) = tieredPackageWithMinimum.validity() + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } - override fun visitMatrixWithAllocation( - matrixWithAllocation: NewPlanMatrixWithAllocationPrice - ) = matrixWithAllocation.validity() + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") - override fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) = - groupedTiered.validity() + private var validated: Boolean = false - override fun visitMinimum(minimum: NewPlanMinimumCompositePrice) = - minimum.validity() + fun validate(): Cadence = apply { + if (validated) { + return@apply + } - override fun unknown(json: JsonValue?) = 0 + known() + validated = true } - ) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - return other is Price && - unit == other.unit && - package_ == other.package_ && - matrix == other.matrix && - tiered == other.tiered && - bulk == other.bulk && - thresholdTotalAmount == other.thresholdTotalAmount && - tieredPackage == other.tieredPackage && - tieredWithMinimum == other.tieredWithMinimum && - unitWithPercent == other.unitWithPercent && - packageWithAllocation == other.packageWithAllocation && - tieredWithProration == other.tieredWithProration && - unitWithProration == other.unitWithProration && - groupedAllocation == other.groupedAllocation && - groupedWithProratedMinimum == other.groupedWithProratedMinimum && - groupedWithMeteredMinimum == other.groupedWithMeteredMinimum && - groupedWithMinMaxThresholds == other.groupedWithMinMaxThresholds && - matrixWithDisplayName == other.matrixWithDisplayName && - bulkWithProration == other.bulkWithProration && - groupedTieredPackage == other.groupedTieredPackage && - maxGroupTieredPackage == other.maxGroupTieredPackage && - scalableMatrixWithUnitPricing == other.scalableMatrixWithUnitPricing && - scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && - cumulativeGroupedBulk == other.cumulativeGroupedBulk && - tieredPackageWithMinimum == other.tieredPackageWithMinimum && - matrixWithAllocation == other.matrixWithAllocation && - groupedTiered == other.groupedTiered && - minimum == other.minimum - } + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - override fun hashCode(): Int = - Objects.hash( - unit, - package_, - matrix, - tiered, - bulk, - thresholdTotalAmount, - tieredPackage, - tieredWithMinimum, - unitWithPercent, - packageWithAllocation, - tieredWithProration, - unitWithProration, - groupedAllocation, - groupedWithProratedMinimum, - groupedWithMeteredMinimum, - groupedWithMinMaxThresholds, - matrixWithDisplayName, - bulkWithProration, - groupedTieredPackage, - maxGroupTieredPackage, - scalableMatrixWithUnitPricing, - scalableMatrixWithTieredPricing, - cumulativeGroupedBulk, - tieredPackageWithMinimum, - matrixWithAllocation, - groupedTiered, - minimum, - ) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } - override fun toString(): String = - when { - unit != null -> "Price{unit=$unit}" - package_ != null -> "Price{package_=$package_}" - matrix != null -> "Price{matrix=$matrix}" - tiered != null -> "Price{tiered=$tiered}" - bulk != null -> "Price{bulk=$bulk}" - thresholdTotalAmount != null -> - "Price{thresholdTotalAmount=$thresholdTotalAmount}" - tieredPackage != null -> "Price{tieredPackage=$tieredPackage}" - tieredWithMinimum != null -> "Price{tieredWithMinimum=$tieredWithMinimum}" - unitWithPercent != null -> "Price{unitWithPercent=$unitWithPercent}" - packageWithAllocation != null -> - "Price{packageWithAllocation=$packageWithAllocation}" - tieredWithProration != null -> "Price{tieredWithProration=$tieredWithProration}" - unitWithProration != null -> "Price{unitWithProration=$unitWithProration}" - groupedAllocation != null -> "Price{groupedAllocation=$groupedAllocation}" - groupedWithProratedMinimum != null -> - "Price{groupedWithProratedMinimum=$groupedWithProratedMinimum}" - groupedWithMeteredMinimum != null -> - "Price{groupedWithMeteredMinimum=$groupedWithMeteredMinimum}" - groupedWithMinMaxThresholds != null -> - "Price{groupedWithMinMaxThresholds=$groupedWithMinMaxThresholds}" - matrixWithDisplayName != null -> - "Price{matrixWithDisplayName=$matrixWithDisplayName}" - bulkWithProration != null -> "Price{bulkWithProration=$bulkWithProration}" - groupedTieredPackage != null -> - "Price{groupedTieredPackage=$groupedTieredPackage}" - maxGroupTieredPackage != null -> - "Price{maxGroupTieredPackage=$maxGroupTieredPackage}" - scalableMatrixWithUnitPricing != null -> - "Price{scalableMatrixWithUnitPricing=$scalableMatrixWithUnitPricing}" - scalableMatrixWithTieredPricing != null -> - "Price{scalableMatrixWithTieredPricing=$scalableMatrixWithTieredPricing}" - cumulativeGroupedBulk != null -> - "Price{cumulativeGroupedBulk=$cumulativeGroupedBulk}" - tieredPackageWithMinimum != null -> - "Price{tieredPackageWithMinimum=$tieredPackageWithMinimum}" - matrixWithAllocation != null -> - "Price{matrixWithAllocation=$matrixWithAllocation}" - groupedTiered != null -> "Price{groupedTiered=$groupedTiered}" - minimum != null -> "Price{minimum=$minimum}" - _json != null -> "Price{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Price") + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() } - companion object { + /** Configuration for tiered_with_proration pricing */ + class TieredWithProrationConfig + private constructor( + private val tiers: JsonField>, + private val additionalProperties: MutableMap, + ) { - fun ofUnit(unit: NewPlanUnitPrice) = Price(unit = unit) + @JsonCreator + private constructor( + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of() + ) : this(tiers, mutableMapOf()) - fun ofPackage(package_: NewPlanPackagePrice) = Price(package_ = package_) + /** + * Tiers for rating based on total usage quantities into the specified tier with + * proration + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun tiers(): List = tiers.getRequired("tiers") - fun ofMatrix(matrix: NewPlanMatrixPrice) = Price(matrix = matrix) + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers - fun ofTiered(tiered: NewPlanTieredPrice) = Price(tiered = tiered) + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - fun ofBulk(bulk: NewPlanBulkPrice) = Price(bulk = bulk) + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - fun ofThresholdTotalAmount(thresholdTotalAmount: NewPlanThresholdTotalAmountPrice) = - Price(thresholdTotalAmount = thresholdTotalAmount) + fun toBuilder() = Builder().from(this) - fun ofTieredPackage(tieredPackage: NewPlanTieredPackagePrice) = - Price(tieredPackage = tieredPackage) + companion object { - fun ofTieredWithMinimum(tieredWithMinimum: NewPlanTieredWithMinimumPrice) = - Price(tieredWithMinimum = tieredWithMinimum) + /** + * Returns a mutable builder for constructing an instance of + * [TieredWithProrationConfig]. + * + * The following fields are required: + * ```kotlin + * .tiers() + * ``` + */ + fun builder() = Builder() + } - fun ofUnitWithPercent(unitWithPercent: NewPlanUnitWithPercentPrice) = - Price(unitWithPercent = unitWithPercent) + /** A builder for [TieredWithProrationConfig]. */ + class Builder internal constructor() { - fun ofPackageWithAllocation( - packageWithAllocation: NewPlanPackageWithAllocationPrice - ) = Price(packageWithAllocation = packageWithAllocation) + private var tiers: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() - fun ofTieredWithProration(tieredWithProration: NewPlanTierWithProrationPrice) = - Price(tieredWithProration = tieredWithProration) + internal fun from(tieredWithProrationConfig: TieredWithProrationConfig) = + apply { + tiers = tieredWithProrationConfig.tiers.map { it.toMutableList() } + additionalProperties = + tieredWithProrationConfig.additionalProperties.toMutableMap() + } - fun ofUnitWithProration(unitWithProration: NewPlanUnitWithProrationPrice) = - Price(unitWithProration = unitWithProration) + /** + * Tiers for rating based on total usage quantities into the specified tier + * with proration + */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) - fun ofGroupedAllocation(groupedAllocation: NewPlanGroupedAllocationPrice) = - Price(groupedAllocation = groupedAllocation) + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } - fun ofGroupedWithProratedMinimum( - groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice - ) = Price(groupedWithProratedMinimum = groupedWithProratedMinimum) + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } - fun ofGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice - ) = Price(groupedWithMeteredMinimum = groupedWithMeteredMinimum) + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun ofGroupedWithMinMaxThresholds( - groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds - ) = Price(groupedWithMinMaxThresholds = groupedWithMinMaxThresholds) + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun ofMatrixWithDisplayName( - matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice - ) = Price(matrixWithDisplayName = matrixWithDisplayName) + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun ofBulkWithProration(bulkWithProration: NewPlanBulkWithProrationPrice) = - Price(bulkWithProration = bulkWithProration) + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun ofGroupedTieredPackage(groupedTieredPackage: NewPlanGroupedTieredPackagePrice) = - Price(groupedTieredPackage = groupedTieredPackage) + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - fun ofMaxGroupTieredPackage( - maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice - ) = Price(maxGroupTieredPackage = maxGroupTieredPackage) + /** + * Returns an immutable instance of [TieredWithProrationConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TieredWithProrationConfig = + TieredWithProrationConfig( + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } - fun ofScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice - ) = Price(scalableMatrixWithUnitPricing = scalableMatrixWithUnitPricing) + private var validated: Boolean = false - fun ofScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: NewPlanScalableMatrixWithTieredPricingPrice - ) = Price(scalableMatrixWithTieredPricing = scalableMatrixWithTieredPricing) + fun validate(): TieredWithProrationConfig = apply { + if (validated) { + return@apply + } - fun ofCumulativeGroupedBulk( - cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice - ) = Price(cumulativeGroupedBulk = cumulativeGroupedBulk) + tiers().forEach { it.validate() } + validated = true + } - fun ofTieredPackageWithMinimum( - tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice - ) = Price(tieredPackageWithMinimum = tieredPackageWithMinimum) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - fun ofMatrixWithAllocation(matrixWithAllocation: NewPlanMatrixWithAllocationPrice) = - Price(matrixWithAllocation = matrixWithAllocation) + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (tiers.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single tiered with proration tier */ + class Tier + private constructor( + private val tierLowerBound: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(tierLowerBound, unitAmount, mutableMapOf()) - fun ofGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) = - Price(groupedTiered = groupedTiered) + /** + * Inclusive tier starting value + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun tierLowerBound(): String = + tierLowerBound.getRequired("tier_lower_bound") - fun ofMinimum(minimum: NewPlanMinimumCompositePrice) = Price(minimum = minimum) - } + /** + * Amount per unit + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") - /** - * An interface that defines how to map each variant of [Price] to a value of type [T]. - */ - interface Visitor { + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound - fun visitUnit(unit: NewPlanUnitPrice): T + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount - fun visitPackage(package_: NewPlanPackagePrice): T + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - fun visitMatrix(matrix: NewPlanMatrixPrice): T + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - fun visitTiered(tiered: NewPlanTieredPrice): T + fun toBuilder() = Builder().from(this) - fun visitBulk(bulk: NewPlanBulkPrice): T + companion object { - fun visitThresholdTotalAmount( - thresholdTotalAmount: NewPlanThresholdTotalAmountPrice - ): T + /** + * Returns a mutable builder for constructing an instance of [Tier]. + * + * The following fields are required: + * ```kotlin + * .tierLowerBound() + * .unitAmount() + * ``` + */ + fun builder() = Builder() + } - fun visitTieredPackage(tieredPackage: NewPlanTieredPackagePrice): T + /** A builder for [Tier]. */ + class Builder internal constructor() { - fun visitTieredWithMinimum(tieredWithMinimum: NewPlanTieredWithMinimumPrice): T + private var tierLowerBound: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() - fun visitUnitWithPercent(unitWithPercent: NewPlanUnitWithPercentPrice): T + internal fun from(tier: Tier) = apply { + tierLowerBound = tier.tierLowerBound + unitAmount = tier.unitAmount + additionalProperties = tier.additionalProperties.toMutableMap() + } - fun visitPackageWithAllocation( - packageWithAllocation: NewPlanPackageWithAllocationPrice - ): T + /** Inclusive tier starting value */ + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } - fun visitTieredWithProration(tieredWithProration: NewPlanTierWithProrationPrice): T + /** Amount per unit */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } - fun visitUnitWithProration(unitWithProration: NewPlanUnitWithProrationPrice): T + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun visitGroupedAllocation(groupedAllocation: NewPlanGroupedAllocationPrice): T + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun visitGroupedWithProratedMinimum( - groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice - ): T + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun visitGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice - ): T + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun visitGroupedWithMinMaxThresholds( - groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds - ): T + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - fun visitMatrixWithDisplayName( - matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice - ): T + /** + * Returns an immutable instance of [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```kotlin + * .tierLowerBound() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("tierLowerBound", tierLowerBound), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } - fun visitBulkWithProration(bulkWithProration: NewPlanBulkWithProrationPrice): T + private var validated: Boolean = false - fun visitGroupedTieredPackage( - groupedTieredPackage: NewPlanGroupedTieredPackagePrice - ): T + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + tierLowerBound() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (tierLowerBound.asKnown() == null) 0 else 1) + + (if (unitAmount.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun visitMaxGroupTieredPackage( - maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice - ): T + return other is Tier && + tierLowerBound == other.tierLowerBound && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } - fun visitScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice - ): T + private val hashCode: Int by lazy { + Objects.hash(tierLowerBound, unitAmount, additionalProperties) + } - fun visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: NewPlanScalableMatrixWithTieredPricingPrice - ): T + override fun hashCode(): Int = hashCode - fun visitCumulativeGroupedBulk( - cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice - ): T + override fun toString() = + "Tier{tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } - fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice - ): T + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun visitMatrixWithAllocation( - matrixWithAllocation: NewPlanMatrixWithAllocationPrice - ): T + return other is TieredWithProrationConfig && + tiers == other.tiers && + additionalProperties == other.additionalProperties + } - fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice): T + private val hashCode: Int by lazy { Objects.hash(tiers, additionalProperties) } - fun visitMinimum(minimum: NewPlanMinimumCompositePrice): T + override fun hashCode(): Int = hashCode + + override fun toString() = + "TieredWithProrationConfig{tiers=$tiers, additionalProperties=$additionalProperties}" + } /** - * Maps an unknown variant of [Price] to a value of type [T]. - * - * An instance of [Price] can contain an unknown variant if it was deserialized from - * data that doesn't match any known variant. For example, if the SDK is on an older - * version than the API, then the API may respond with new variants that the SDK is - * unaware of. - * - * @throws OrbInvalidDataException in the default implementation. + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown Price: $json") - } - } + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { - internal class Deserializer : BaseDeserializer(Price::class) { + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties - override fun ObjectCodec.deserialize(node: JsonNode): Price { - val json = JsonValue.fromJsonNode(node) - val modelType = json.asObject()?.get("model_type")?.asString() + fun toBuilder() = Builder().from(this) - when (modelType) { - "unit" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(unit = it, _json = json) - } ?: Price(_json = json) - } - "package" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(package_ = it, _json = json) } ?: Price(_json = json) - } - "matrix" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(matrix = it, _json = json) - } ?: Price(_json = json) - } - "tiered" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(tiered = it, _json = json) - } ?: Price(_json = json) - } - "bulk" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(bulk = it, _json = json) - } ?: Price(_json = json) - } - "threshold_total_amount" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(thresholdTotalAmount = it, _json = json) } - ?: Price(_json = json) - } - "tiered_package" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(tieredPackage = it, _json = json) } - ?: Price(_json = json) - } - "tiered_with_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(tieredWithMinimum = it, _json = json) } - ?: Price(_json = json) - } - "unit_with_percent" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(unitWithPercent = it, _json = json) } - ?: Price(_json = json) - } - "package_with_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(packageWithAllocation = it, _json = json) } - ?: Price(_json = json) - } - "tiered_with_proration" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(tieredWithProration = it, _json = json) } - ?: Price(_json = json) - } - "unit_with_proration" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(unitWithProration = it, _json = json) } - ?: Price(_json = json) - } - "grouped_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedAllocation = it, _json = json) } - ?: Price(_json = json) - } - "grouped_with_prorated_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedWithProratedMinimum = it, _json = json) } - ?: Price(_json = json) - } - "grouped_with_metered_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedWithMeteredMinimum = it, _json = json) } - ?: Price(_json = json) - } - "grouped_with_min_max_thresholds" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedWithMinMaxThresholds = it, _json = json) } - ?: Price(_json = json) - } - "matrix_with_display_name" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(matrixWithDisplayName = it, _json = json) } - ?: Price(_json = json) - } - "bulk_with_proration" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(bulkWithProration = it, _json = json) } - ?: Price(_json = json) - } - "grouped_tiered_package" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedTieredPackage = it, _json = json) } - ?: Price(_json = json) - } - "max_group_tiered_package" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(maxGroupTieredPackage = it, _json = json) } - ?: Price(_json = json) + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() } - "scalable_matrix_with_unit_pricing" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(scalableMatrixWithUnitPricing = it, _json = json) } - ?: Price(_json = json) + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) } - "scalable_matrix_with_tiered_pricing" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(scalableMatrixWithTieredPricing = it, _json = json) } - ?: Price(_json = json) + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) } - "cumulative_grouped_bulk" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(cumulativeGroupedBulk = it, _json = json) } - ?: Price(_json = json) + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) } - "tiered_package_with_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(tieredPackageWithMinimum = it, _json = json) } - ?: Price(_json = json) + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply } - "matrix_with_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(matrixWithAllocation = it, _json = json) } - ?: Price(_json = json) + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false } - "grouped_tiered" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(groupedTiered = it, _json = json) } - ?: Price(_json = json) + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() } - "minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(minimum = it, _json = json) } ?: Price(_json = json) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } + + return other is Metadata && + additionalProperties == other.additionalProperties } - return Price(_json = json) - } - } + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - internal class Serializer : BaseSerializer(Price::class) { + override fun hashCode(): Int = hashCode - override fun serialize( - value: Price, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unit != null -> generator.writeObject(value.unit) - value.package_ != null -> generator.writeObject(value.package_) - value.matrix != null -> generator.writeObject(value.matrix) - value.tiered != null -> generator.writeObject(value.tiered) - value.bulk != null -> generator.writeObject(value.bulk) - value.thresholdTotalAmount != null -> - generator.writeObject(value.thresholdTotalAmount) - value.tieredPackage != null -> generator.writeObject(value.tieredPackage) - value.tieredWithMinimum != null -> - generator.writeObject(value.tieredWithMinimum) - value.unitWithPercent != null -> - generator.writeObject(value.unitWithPercent) - value.packageWithAllocation != null -> - generator.writeObject(value.packageWithAllocation) - value.tieredWithProration != null -> - generator.writeObject(value.tieredWithProration) - value.unitWithProration != null -> - generator.writeObject(value.unitWithProration) - value.groupedAllocation != null -> - generator.writeObject(value.groupedAllocation) - value.groupedWithProratedMinimum != null -> - generator.writeObject(value.groupedWithProratedMinimum) - value.groupedWithMeteredMinimum != null -> - generator.writeObject(value.groupedWithMeteredMinimum) - value.groupedWithMinMaxThresholds != null -> - generator.writeObject(value.groupedWithMinMaxThresholds) - value.matrixWithDisplayName != null -> - generator.writeObject(value.matrixWithDisplayName) - value.bulkWithProration != null -> - generator.writeObject(value.bulkWithProration) - value.groupedTieredPackage != null -> - generator.writeObject(value.groupedTieredPackage) - value.maxGroupTieredPackage != null -> - generator.writeObject(value.maxGroupTieredPackage) - value.scalableMatrixWithUnitPricing != null -> - generator.writeObject(value.scalableMatrixWithUnitPricing) - value.scalableMatrixWithTieredPricing != null -> - generator.writeObject(value.scalableMatrixWithTieredPricing) - value.cumulativeGroupedBulk != null -> - generator.writeObject(value.cumulativeGroupedBulk) - value.tieredPackageWithMinimum != null -> - generator.writeObject(value.tieredPackageWithMinimum) - value.matrixWithAllocation != null -> - generator.writeObject(value.matrixWithAllocation) - value.groupedTiered != null -> generator.writeObject(value.groupedTiered) - value.minimum != null -> generator.writeObject(value.minimum) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Price") + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } + + return other is TieredWithProration && + cadence == other.cadence && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + tieredWithProrationConfig == other.tieredWithProrationConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + modelType, + name, + tieredWithProrationConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties, + ) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TieredWithProration{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredWithProrationConfig=$tieredWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } class GroupedWithMinMaxThresholds @@ -7354,6 +11095,8 @@ private constructor( fun cadence(): Cadence = cadence.getRequired("cadence") /** + * Configuration for grouped_with_min_max_thresholds pricing + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected * value). @@ -7373,6 +11116,8 @@ private constructor( fun itemId(): String = itemId.getRequired("item_id") /** + * The pricing model type + * * Expected to always return the following: * ```kotlin * JsonValue.from("grouped_with_min_max_thresholds") @@ -7782,6 +11527,7 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + /** Configuration for grouped_with_min_max_thresholds pricing */ fun groupedWithMinMaxThresholdsConfig( groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig ) = @@ -8437,16 +12183,117 @@ private constructor( override fun toString() = value.toString() } + /** Configuration for grouped_with_min_max_thresholds pricing */ class GroupedWithMinMaxThresholdsConfig - @JsonCreator private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map + private val groupingKey: JsonField, + private val maximumCharge: JsonField, + private val minimumCharge: JsonField, + private val perUnitRate: JsonField, + private val additionalProperties: MutableMap, ) { + @JsonCreator + private constructor( + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("maximum_charge") + @ExcludeMissing + maximumCharge: JsonField = JsonMissing.of(), + @JsonProperty("minimum_charge") + @ExcludeMissing + minimumCharge: JsonField = JsonMissing.of(), + @JsonProperty("per_unit_rate") + @ExcludeMissing + perUnitRate: JsonField = JsonMissing.of(), + ) : this(groupingKey, maximumCharge, minimumCharge, perUnitRate, mutableMapOf()) + + /** + * The event property used to group before applying thresholds + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The maximum amount to charge each group + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun maximumCharge(): String = maximumCharge.getRequired("maximum_charge") + + /** + * The minimum amount to charge each group, regardless of usage + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun minimumCharge(): String = minimumCharge.getRequired("minimum_charge") + + /** + * The base price charged per group + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun perUnitRate(): String = perUnitRate.getRequired("per_unit_rate") + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [maximumCharge]. + * + * Unlike [maximumCharge], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("maximum_charge") + @ExcludeMissing + fun _maximumCharge(): JsonField = maximumCharge + + /** + * Returns the raw JSON value of [minimumCharge]. + * + * Unlike [minimumCharge], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("minimum_charge") + @ExcludeMissing + fun _minimumCharge(): JsonField = minimumCharge + + /** + * Returns the raw JSON value of [perUnitRate]. + * + * Unlike [perUnitRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("per_unit_rate") + @ExcludeMissing + fun _perUnitRate(): JsonField = perUnitRate + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) fun toBuilder() = Builder().from(this) @@ -8455,6 +12302,14 @@ private constructor( /** * Returns a mutable builder for constructing an instance of * [GroupedWithMinMaxThresholdsConfig]. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .maximumCharge() + * .minimumCharge() + * .perUnitRate() + * ``` */ fun builder() = Builder() } @@ -8462,17 +12317,85 @@ private constructor( /** A builder for [GroupedWithMinMaxThresholdsConfig]. */ class Builder internal constructor() { + private var groupingKey: JsonField? = null + private var maximumCharge: JsonField? = null + private var minimumCharge: JsonField? = null + private var perUnitRate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from( groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig ) = apply { + groupingKey = groupedWithMinMaxThresholdsConfig.groupingKey + maximumCharge = groupedWithMinMaxThresholdsConfig.maximumCharge + minimumCharge = groupedWithMinMaxThresholdsConfig.minimumCharge + perUnitRate = groupedWithMinMaxThresholdsConfig.perUnitRate additionalProperties = groupedWithMinMaxThresholdsConfig.additionalProperties .toMutableMap() } + /** The event property used to group before applying thresholds */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The maximum amount to charge each group */ + fun maximumCharge(maximumCharge: String) = + maximumCharge(JsonField.of(maximumCharge)) + + /** + * Sets [Builder.maximumCharge] to an arbitrary JSON value. + * + * You should usually call [Builder.maximumCharge] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun maximumCharge(maximumCharge: JsonField) = apply { + this.maximumCharge = maximumCharge + } + + /** The minimum amount to charge each group, regardless of usage */ + fun minimumCharge(minimumCharge: String) = + minimumCharge(JsonField.of(minimumCharge)) + + /** + * Sets [Builder.minimumCharge] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumCharge] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun minimumCharge(minimumCharge: JsonField) = apply { + this.minimumCharge = minimumCharge + } + + /** The base price charged per group */ + fun perUnitRate(perUnitRate: String) = + perUnitRate(JsonField.of(perUnitRate)) + + /** + * Sets [Builder.perUnitRate] to an arbitrary JSON value. + * + * You should usually call [Builder.perUnitRate] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun perUnitRate(perUnitRate: JsonField) = apply { + this.perUnitRate = perUnitRate + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -8499,9 +12422,25 @@ private constructor( * Returns an immutable instance of [GroupedWithMinMaxThresholdsConfig]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .maximumCharge() + * .minimumCharge() + * .perUnitRate() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ fun build(): GroupedWithMinMaxThresholdsConfig = - GroupedWithMinMaxThresholdsConfig(additionalProperties.toImmutable()) + GroupedWithMinMaxThresholdsConfig( + checkRequired("groupingKey", groupingKey), + checkRequired("maximumCharge", maximumCharge), + checkRequired("minimumCharge", minimumCharge), + checkRequired("perUnitRate", perUnitRate), + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false @@ -8511,6 +12450,10 @@ private constructor( return@apply } + groupingKey() + maximumCharge() + minimumCharge() + perUnitRate() validated = true } @@ -8529,9 +12472,10 @@ private constructor( * Used for best match union deserialization. */ internal fun validity(): Int = - additionalProperties.count { (_, value) -> - !value.isNull() && !value.isMissing() - } + (if (groupingKey.asKnown() == null) 0 else 1) + + (if (maximumCharge.asKnown() == null) 0 else 1) + + (if (minimumCharge.asKnown() == null) 0 else 1) + + (if (perUnitRate.asKnown() == null) 0 else 1) override fun equals(other: Any?): Boolean { if (this === other) { @@ -8539,15 +12483,27 @@ private constructor( } return other is GroupedWithMinMaxThresholdsConfig && + groupingKey == other.groupingKey && + maximumCharge == other.maximumCharge && + minimumCharge == other.minimumCharge && + perUnitRate == other.perUnitRate && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + private val hashCode: Int by lazy { + Objects.hash( + groupingKey, + maximumCharge, + minimumCharge, + perUnitRate, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode override fun toString() = - "GroupedWithMinMaxThresholdsConfig{additionalProperties=$additionalProperties}" + "GroupedWithMinMaxThresholdsConfig{groupingKey=$groupingKey, maximumCharge=$maximumCharge, minimumCharge=$minimumCharge, perUnitRate=$perUnitRate, additionalProperties=$additionalProperties}" } /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BetaExternalPlanIdCreatePlanVersionParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BetaExternalPlanIdCreatePlanVersionParams.kt index 85437b1fc..e0f688def 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BetaExternalPlanIdCreatePlanVersionParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BetaExternalPlanIdCreatePlanVersionParams.kt @@ -1716,7 +1716,7 @@ private constructor( fun planPhaseOrder(): Long? = planPhaseOrder.getNullable("plan_phase_order") /** - * The price to add to the plan + * New plan price request body params. * * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -1820,7 +1820,7 @@ private constructor( this.planPhaseOrder = planPhaseOrder } - /** The price to add to the plan */ + /** New plan price request body params. */ fun price(price: Price?) = price(JsonField.ofNullable(price)) /** @@ -1835,18 +1835,18 @@ private constructor( /** Alias for calling [price] with `Price.ofUnit(unit)`. */ fun price(unit: NewPlanUnitPrice) = price(Price.ofUnit(unit)) - /** Alias for calling [price] with `Price.ofPackage(package_)`. */ - fun price(package_: NewPlanPackagePrice) = price(Price.ofPackage(package_)) - - /** Alias for calling [price] with `Price.ofMatrix(matrix)`. */ - fun price(matrix: NewPlanMatrixPrice) = price(Price.ofMatrix(matrix)) - /** Alias for calling [price] with `Price.ofTiered(tiered)`. */ fun price(tiered: NewPlanTieredPrice) = price(Price.ofTiered(tiered)) /** Alias for calling [price] with `Price.ofBulk(bulk)`. */ fun price(bulk: NewPlanBulkPrice) = price(Price.ofBulk(bulk)) + /** Alias for calling [price] with `Price.ofPackage(package_)`. */ + fun price(package_: NewPlanPackagePrice) = price(Price.ofPackage(package_)) + + /** Alias for calling [price] with `Price.ofMatrix(matrix)`. */ + fun price(matrix: NewPlanMatrixPrice) = price(Price.ofMatrix(matrix)) + /** * Alias for calling [price] with `Price.ofThresholdTotalAmount(thresholdTotalAmount)`. */ @@ -1861,9 +1861,16 @@ private constructor( fun price(tieredWithMinimum: NewPlanTieredWithMinimumPrice) = price(Price.ofTieredWithMinimum(tieredWithMinimum)) - /** Alias for calling [price] with `Price.ofUnitWithPercent(unitWithPercent)`. */ - fun price(unitWithPercent: NewPlanUnitWithPercentPrice) = - price(Price.ofUnitWithPercent(unitWithPercent)) + /** Alias for calling [price] with `Price.ofGroupedTiered(groupedTiered)`. */ + fun price(groupedTiered: NewPlanGroupedTieredPrice) = + price(Price.ofGroupedTiered(groupedTiered)) + + /** + * Alias for calling [price] with + * `Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)`. + */ + fun price(tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice) = + price(Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)) /** * Alias for calling [price] with @@ -1872,10 +1879,20 @@ private constructor( fun price(packageWithAllocation: NewPlanPackageWithAllocationPrice) = price(Price.ofPackageWithAllocation(packageWithAllocation)) + /** Alias for calling [price] with `Price.ofUnitWithPercent(unitWithPercent)`. */ + fun price(unitWithPercent: NewPlanUnitWithPercentPrice) = + price(Price.ofUnitWithPercent(unitWithPercent)) + + /** + * Alias for calling [price] with `Price.ofMatrixWithAllocation(matrixWithAllocation)`. + */ + fun price(matrixWithAllocation: NewPlanMatrixWithAllocationPrice) = + price(Price.ofMatrixWithAllocation(matrixWithAllocation)) + /** * Alias for calling [price] with `Price.ofTieredWithProration(tieredWithProration)`. */ - fun price(tieredWithProration: NewPlanTierWithProrationPrice) = + fun price(tieredWithProration: Price.TieredWithProration) = price(Price.ofTieredWithProration(tieredWithProration)) /** Alias for calling [price] with `Price.ofUnitWithProration(unitWithProration)`. */ @@ -1886,6 +1903,10 @@ private constructor( fun price(groupedAllocation: NewPlanGroupedAllocationPrice) = price(Price.ofGroupedAllocation(groupedAllocation)) + /** Alias for calling [price] with `Price.ofBulkWithProration(bulkWithProration)`. */ + fun price(bulkWithProration: NewPlanBulkWithProrationPrice) = + price(Price.ofBulkWithProration(bulkWithProration)) + /** * Alias for calling [price] with * `Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)`. @@ -1914,10 +1935,6 @@ private constructor( fun price(matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice) = price(Price.ofMatrixWithDisplayName(matrixWithDisplayName)) - /** Alias for calling [price] with `Price.ofBulkWithProration(bulkWithProration)`. */ - fun price(bulkWithProration: NewPlanBulkWithProrationPrice) = - price(Price.ofBulkWithProration(bulkWithProration)) - /** * Alias for calling [price] with `Price.ofGroupedTieredPackage(groupedTieredPackage)`. */ @@ -1953,23 +1970,6 @@ private constructor( fun price(cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice) = price(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) - /** - * Alias for calling [price] with - * `Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)`. - */ - fun price(tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice) = - price(Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)) - - /** - * Alias for calling [price] with `Price.ofMatrixWithAllocation(matrixWithAllocation)`. - */ - fun price(matrixWithAllocation: NewPlanMatrixWithAllocationPrice) = - price(Price.ofMatrixWithAllocation(matrixWithAllocation)) - - /** Alias for calling [price] with `Price.ofGroupedTiered(groupedTiered)`. */ - fun price(groupedTiered: NewPlanGroupedTieredPrice) = - price(Price.ofGroupedTiered(groupedTiered)) - /** Alias for calling [price] with `Price.ofMinimum(minimum)`. */ fun price(minimum: NewPlanMinimumCompositePrice) = price(Price.ofMinimum(minimum)) @@ -2038,29 +2038,32 @@ private constructor( (if (planPhaseOrder.asKnown() == null) 0 else 1) + (price.asKnown()?.validity() ?: 0) - /** The price to add to the plan */ + /** New plan price request body params. */ @JsonDeserialize(using = Price.Deserializer::class) @JsonSerialize(using = Price.Serializer::class) class Price private constructor( private val unit: NewPlanUnitPrice? = null, - private val package_: NewPlanPackagePrice? = null, - private val matrix: NewPlanMatrixPrice? = null, private val tiered: NewPlanTieredPrice? = null, private val bulk: NewPlanBulkPrice? = null, + private val package_: NewPlanPackagePrice? = null, + private val matrix: NewPlanMatrixPrice? = null, private val thresholdTotalAmount: NewPlanThresholdTotalAmountPrice? = null, private val tieredPackage: NewPlanTieredPackagePrice? = null, private val tieredWithMinimum: NewPlanTieredWithMinimumPrice? = null, - private val unitWithPercent: NewPlanUnitWithPercentPrice? = null, + private val groupedTiered: NewPlanGroupedTieredPrice? = null, + private val tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice? = null, private val packageWithAllocation: NewPlanPackageWithAllocationPrice? = null, - private val tieredWithProration: NewPlanTierWithProrationPrice? = null, + private val unitWithPercent: NewPlanUnitWithPercentPrice? = null, + private val matrixWithAllocation: NewPlanMatrixWithAllocationPrice? = null, + private val tieredWithProration: TieredWithProration? = null, private val unitWithProration: NewPlanUnitWithProrationPrice? = null, private val groupedAllocation: NewPlanGroupedAllocationPrice? = null, + private val bulkWithProration: NewPlanBulkWithProrationPrice? = null, private val groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice? = null, private val groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice? = null, private val groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds? = null, private val matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice? = null, - private val bulkWithProration: NewPlanBulkWithProrationPrice? = null, private val groupedTieredPackage: NewPlanGroupedTieredPackagePrice? = null, private val maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice? = null, private val scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice? = @@ -2069,39 +2072,45 @@ private constructor( NewPlanScalableMatrixWithTieredPricingPrice? = null, private val cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice? = null, - private val tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice? = null, - private val matrixWithAllocation: NewPlanMatrixWithAllocationPrice? = null, - private val groupedTiered: NewPlanGroupedTieredPrice? = null, private val minimum: NewPlanMinimumCompositePrice? = null, private val _json: JsonValue? = null, ) { fun unit(): NewPlanUnitPrice? = unit - fun package_(): NewPlanPackagePrice? = package_ - - fun matrix(): NewPlanMatrixPrice? = matrix - fun tiered(): NewPlanTieredPrice? = tiered fun bulk(): NewPlanBulkPrice? = bulk + fun package_(): NewPlanPackagePrice? = package_ + + fun matrix(): NewPlanMatrixPrice? = matrix + fun thresholdTotalAmount(): NewPlanThresholdTotalAmountPrice? = thresholdTotalAmount fun tieredPackage(): NewPlanTieredPackagePrice? = tieredPackage fun tieredWithMinimum(): NewPlanTieredWithMinimumPrice? = tieredWithMinimum - fun unitWithPercent(): NewPlanUnitWithPercentPrice? = unitWithPercent + fun groupedTiered(): NewPlanGroupedTieredPrice? = groupedTiered + + fun tieredPackageWithMinimum(): NewPlanTieredPackageWithMinimumPrice? = + tieredPackageWithMinimum fun packageWithAllocation(): NewPlanPackageWithAllocationPrice? = packageWithAllocation - fun tieredWithProration(): NewPlanTierWithProrationPrice? = tieredWithProration + fun unitWithPercent(): NewPlanUnitWithPercentPrice? = unitWithPercent + + fun matrixWithAllocation(): NewPlanMatrixWithAllocationPrice? = matrixWithAllocation + + fun tieredWithProration(): TieredWithProration? = tieredWithProration fun unitWithProration(): NewPlanUnitWithProrationPrice? = unitWithProration fun groupedAllocation(): NewPlanGroupedAllocationPrice? = groupedAllocation + fun bulkWithProration(): NewPlanBulkWithProrationPrice? = bulkWithProration + fun groupedWithProratedMinimum(): NewPlanGroupedWithProratedMinimumPrice? = groupedWithProratedMinimum @@ -2113,8 +2122,6 @@ private constructor( fun matrixWithDisplayName(): NewPlanMatrixWithDisplayNamePrice? = matrixWithDisplayName - fun bulkWithProration(): NewPlanBulkWithProrationPrice? = bulkWithProration - fun groupedTieredPackage(): NewPlanGroupedTieredPackagePrice? = groupedTieredPackage fun maxGroupTieredPackage(): NewPlanMaxGroupTieredPackagePrice? = maxGroupTieredPackage @@ -2127,41 +2134,42 @@ private constructor( fun cumulativeGroupedBulk(): NewPlanCumulativeGroupedBulkPrice? = cumulativeGroupedBulk - fun tieredPackageWithMinimum(): NewPlanTieredPackageWithMinimumPrice? = - tieredPackageWithMinimum - - fun matrixWithAllocation(): NewPlanMatrixWithAllocationPrice? = matrixWithAllocation - - fun groupedTiered(): NewPlanGroupedTieredPrice? = groupedTiered - fun minimum(): NewPlanMinimumCompositePrice? = minimum fun isUnit(): Boolean = unit != null - fun isPackage(): Boolean = package_ != null - - fun isMatrix(): Boolean = matrix != null - fun isTiered(): Boolean = tiered != null fun isBulk(): Boolean = bulk != null + fun isPackage(): Boolean = package_ != null + + fun isMatrix(): Boolean = matrix != null + fun isThresholdTotalAmount(): Boolean = thresholdTotalAmount != null fun isTieredPackage(): Boolean = tieredPackage != null fun isTieredWithMinimum(): Boolean = tieredWithMinimum != null - fun isUnitWithPercent(): Boolean = unitWithPercent != null + fun isGroupedTiered(): Boolean = groupedTiered != null + + fun isTieredPackageWithMinimum(): Boolean = tieredPackageWithMinimum != null fun isPackageWithAllocation(): Boolean = packageWithAllocation != null + fun isUnitWithPercent(): Boolean = unitWithPercent != null + + fun isMatrixWithAllocation(): Boolean = matrixWithAllocation != null + fun isTieredWithProration(): Boolean = tieredWithProration != null fun isUnitWithProration(): Boolean = unitWithProration != null fun isGroupedAllocation(): Boolean = groupedAllocation != null + fun isBulkWithProration(): Boolean = bulkWithProration != null + fun isGroupedWithProratedMinimum(): Boolean = groupedWithProratedMinimum != null fun isGroupedWithMeteredMinimum(): Boolean = groupedWithMeteredMinimum != null @@ -2170,8 +2178,6 @@ private constructor( fun isMatrixWithDisplayName(): Boolean = matrixWithDisplayName != null - fun isBulkWithProration(): Boolean = bulkWithProration != null - fun isGroupedTieredPackage(): Boolean = groupedTieredPackage != null fun isMaxGroupTieredPackage(): Boolean = maxGroupTieredPackage != null @@ -2183,24 +2189,18 @@ private constructor( fun isCumulativeGroupedBulk(): Boolean = cumulativeGroupedBulk != null - fun isTieredPackageWithMinimum(): Boolean = tieredPackageWithMinimum != null - - fun isMatrixWithAllocation(): Boolean = matrixWithAllocation != null - - fun isGroupedTiered(): Boolean = groupedTiered != null - fun isMinimum(): Boolean = minimum != null fun asUnit(): NewPlanUnitPrice = unit.getOrThrow("unit") - fun asPackage(): NewPlanPackagePrice = package_.getOrThrow("package_") - - fun asMatrix(): NewPlanMatrixPrice = matrix.getOrThrow("matrix") - fun asTiered(): NewPlanTieredPrice = tiered.getOrThrow("tiered") fun asBulk(): NewPlanBulkPrice = bulk.getOrThrow("bulk") + fun asPackage(): NewPlanPackagePrice = package_.getOrThrow("package_") + + fun asMatrix(): NewPlanMatrixPrice = matrix.getOrThrow("matrix") + fun asThresholdTotalAmount(): NewPlanThresholdTotalAmountPrice = thresholdTotalAmount.getOrThrow("thresholdTotalAmount") @@ -2210,13 +2210,22 @@ private constructor( fun asTieredWithMinimum(): NewPlanTieredWithMinimumPrice = tieredWithMinimum.getOrThrow("tieredWithMinimum") - fun asUnitWithPercent(): NewPlanUnitWithPercentPrice = - unitWithPercent.getOrThrow("unitWithPercent") + fun asGroupedTiered(): NewPlanGroupedTieredPrice = + groupedTiered.getOrThrow("groupedTiered") + + fun asTieredPackageWithMinimum(): NewPlanTieredPackageWithMinimumPrice = + tieredPackageWithMinimum.getOrThrow("tieredPackageWithMinimum") fun asPackageWithAllocation(): NewPlanPackageWithAllocationPrice = packageWithAllocation.getOrThrow("packageWithAllocation") - fun asTieredWithProration(): NewPlanTierWithProrationPrice = + fun asUnitWithPercent(): NewPlanUnitWithPercentPrice = + unitWithPercent.getOrThrow("unitWithPercent") + + fun asMatrixWithAllocation(): NewPlanMatrixWithAllocationPrice = + matrixWithAllocation.getOrThrow("matrixWithAllocation") + + fun asTieredWithProration(): TieredWithProration = tieredWithProration.getOrThrow("tieredWithProration") fun asUnitWithProration(): NewPlanUnitWithProrationPrice = @@ -2225,6 +2234,9 @@ private constructor( fun asGroupedAllocation(): NewPlanGroupedAllocationPrice = groupedAllocation.getOrThrow("groupedAllocation") + fun asBulkWithProration(): NewPlanBulkWithProrationPrice = + bulkWithProration.getOrThrow("bulkWithProration") + fun asGroupedWithProratedMinimum(): NewPlanGroupedWithProratedMinimumPrice = groupedWithProratedMinimum.getOrThrow("groupedWithProratedMinimum") @@ -2237,9 +2249,6 @@ private constructor( fun asMatrixWithDisplayName(): NewPlanMatrixWithDisplayNamePrice = matrixWithDisplayName.getOrThrow("matrixWithDisplayName") - fun asBulkWithProration(): NewPlanBulkWithProrationPrice = - bulkWithProration.getOrThrow("bulkWithProration") - fun asGroupedTieredPackage(): NewPlanGroupedTieredPackagePrice = groupedTieredPackage.getOrThrow("groupedTieredPackage") @@ -2255,15 +2264,6 @@ private constructor( fun asCumulativeGroupedBulk(): NewPlanCumulativeGroupedBulkPrice = cumulativeGroupedBulk.getOrThrow("cumulativeGroupedBulk") - fun asTieredPackageWithMinimum(): NewPlanTieredPackageWithMinimumPrice = - tieredPackageWithMinimum.getOrThrow("tieredPackageWithMinimum") - - fun asMatrixWithAllocation(): NewPlanMatrixWithAllocationPrice = - matrixWithAllocation.getOrThrow("matrixWithAllocation") - - fun asGroupedTiered(): NewPlanGroupedTieredPrice = - groupedTiered.getOrThrow("groupedTiered") - fun asMinimum(): NewPlanMinimumCompositePrice = minimum.getOrThrow("minimum") fun _json(): JsonValue? = _json @@ -2271,21 +2271,27 @@ private constructor( fun accept(visitor: Visitor): T = when { unit != null -> visitor.visitUnit(unit) - package_ != null -> visitor.visitPackage(package_) - matrix != null -> visitor.visitMatrix(matrix) tiered != null -> visitor.visitTiered(tiered) bulk != null -> visitor.visitBulk(bulk) + package_ != null -> visitor.visitPackage(package_) + matrix != null -> visitor.visitMatrix(matrix) thresholdTotalAmount != null -> visitor.visitThresholdTotalAmount(thresholdTotalAmount) tieredPackage != null -> visitor.visitTieredPackage(tieredPackage) tieredWithMinimum != null -> visitor.visitTieredWithMinimum(tieredWithMinimum) - unitWithPercent != null -> visitor.visitUnitWithPercent(unitWithPercent) + groupedTiered != null -> visitor.visitGroupedTiered(groupedTiered) + tieredPackageWithMinimum != null -> + visitor.visitTieredPackageWithMinimum(tieredPackageWithMinimum) packageWithAllocation != null -> visitor.visitPackageWithAllocation(packageWithAllocation) + unitWithPercent != null -> visitor.visitUnitWithPercent(unitWithPercent) + matrixWithAllocation != null -> + visitor.visitMatrixWithAllocation(matrixWithAllocation) tieredWithProration != null -> visitor.visitTieredWithProration(tieredWithProration) unitWithProration != null -> visitor.visitUnitWithProration(unitWithProration) groupedAllocation != null -> visitor.visitGroupedAllocation(groupedAllocation) + bulkWithProration != null -> visitor.visitBulkWithProration(bulkWithProration) groupedWithProratedMinimum != null -> visitor.visitGroupedWithProratedMinimum(groupedWithProratedMinimum) groupedWithMeteredMinimum != null -> @@ -2294,7 +2300,6 @@ private constructor( visitor.visitGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds) matrixWithDisplayName != null -> visitor.visitMatrixWithDisplayName(matrixWithDisplayName) - bulkWithProration != null -> visitor.visitBulkWithProration(bulkWithProration) groupedTieredPackage != null -> visitor.visitGroupedTieredPackage(groupedTieredPackage) maxGroupTieredPackage != null -> @@ -2307,11 +2312,6 @@ private constructor( ) cumulativeGroupedBulk != null -> visitor.visitCumulativeGroupedBulk(cumulativeGroupedBulk) - tieredPackageWithMinimum != null -> - visitor.visitTieredPackageWithMinimum(tieredPackageWithMinimum) - matrixWithAllocation != null -> - visitor.visitMatrixWithAllocation(matrixWithAllocation) - groupedTiered != null -> visitor.visitGroupedTiered(groupedTiered) minimum != null -> visitor.visitMinimum(minimum) else -> visitor.unknown(_json) } @@ -2329,14 +2329,6 @@ private constructor( unit.validate() } - override fun visitPackage(package_: NewPlanPackagePrice) { - package_.validate() - } - - override fun visitMatrix(matrix: NewPlanMatrixPrice) { - matrix.validate() - } - override fun visitTiered(tiered: NewPlanTieredPrice) { tiered.validate() } @@ -2345,6 +2337,14 @@ private constructor( bulk.validate() } + override fun visitPackage(package_: NewPlanPackagePrice) { + package_.validate() + } + + override fun visitMatrix(matrix: NewPlanMatrixPrice) { + matrix.validate() + } + override fun visitThresholdTotalAmount( thresholdTotalAmount: NewPlanThresholdTotalAmountPrice ) { @@ -2361,10 +2361,14 @@ private constructor( tieredWithMinimum.validate() } - override fun visitUnitWithPercent( - unitWithPercent: NewPlanUnitWithPercentPrice + override fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) { + groupedTiered.validate() + } + + override fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice ) { - unitWithPercent.validate() + tieredPackageWithMinimum.validate() } override fun visitPackageWithAllocation( @@ -2373,8 +2377,20 @@ private constructor( packageWithAllocation.validate() } + override fun visitUnitWithPercent( + unitWithPercent: NewPlanUnitWithPercentPrice + ) { + unitWithPercent.validate() + } + + override fun visitMatrixWithAllocation( + matrixWithAllocation: NewPlanMatrixWithAllocationPrice + ) { + matrixWithAllocation.validate() + } + override fun visitTieredWithProration( - tieredWithProration: NewPlanTierWithProrationPrice + tieredWithProration: TieredWithProration ) { tieredWithProration.validate() } @@ -2391,6 +2407,12 @@ private constructor( groupedAllocation.validate() } + override fun visitBulkWithProration( + bulkWithProration: NewPlanBulkWithProrationPrice + ) { + bulkWithProration.validate() + } + override fun visitGroupedWithProratedMinimum( groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice ) { @@ -2415,12 +2437,6 @@ private constructor( matrixWithDisplayName.validate() } - override fun visitBulkWithProration( - bulkWithProration: NewPlanBulkWithProrationPrice - ) { - bulkWithProration.validate() - } - override fun visitGroupedTieredPackage( groupedTieredPackage: NewPlanGroupedTieredPackagePrice ) { @@ -2452,22 +2468,6 @@ private constructor( cumulativeGroupedBulk.validate() } - override fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice - ) { - tieredPackageWithMinimum.validate() - } - - override fun visitMatrixWithAllocation( - matrixWithAllocation: NewPlanMatrixWithAllocationPrice - ) { - matrixWithAllocation.validate() - } - - override fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) { - groupedTiered.validate() - } - override fun visitMinimum(minimum: NewPlanMinimumCompositePrice) { minimum.validate() } @@ -2495,15 +2495,15 @@ private constructor( object : Visitor { override fun visitUnit(unit: NewPlanUnitPrice) = unit.validity() + override fun visitTiered(tiered: NewPlanTieredPrice) = tiered.validity() + + override fun visitBulk(bulk: NewPlanBulkPrice) = bulk.validity() + override fun visitPackage(package_: NewPlanPackagePrice) = package_.validity() override fun visitMatrix(matrix: NewPlanMatrixPrice) = matrix.validity() - override fun visitTiered(tiered: NewPlanTieredPrice) = tiered.validity() - - override fun visitBulk(bulk: NewPlanBulkPrice) = bulk.validity() - override fun visitThresholdTotalAmount( thresholdTotalAmount: NewPlanThresholdTotalAmountPrice ) = thresholdTotalAmount.validity() @@ -2515,16 +2515,27 @@ private constructor( tieredWithMinimum: NewPlanTieredWithMinimumPrice ) = tieredWithMinimum.validity() - override fun visitUnitWithPercent( - unitWithPercent: NewPlanUnitWithPercentPrice - ) = unitWithPercent.validity() + override fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) = + groupedTiered.validity() + + override fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice + ) = tieredPackageWithMinimum.validity() override fun visitPackageWithAllocation( packageWithAllocation: NewPlanPackageWithAllocationPrice ) = packageWithAllocation.validity() + override fun visitUnitWithPercent( + unitWithPercent: NewPlanUnitWithPercentPrice + ) = unitWithPercent.validity() + + override fun visitMatrixWithAllocation( + matrixWithAllocation: NewPlanMatrixWithAllocationPrice + ) = matrixWithAllocation.validity() + override fun visitTieredWithProration( - tieredWithProration: NewPlanTierWithProrationPrice + tieredWithProration: TieredWithProration ) = tieredWithProration.validity() override fun visitUnitWithProration( @@ -2535,6 +2546,10 @@ private constructor( groupedAllocation: NewPlanGroupedAllocationPrice ) = groupedAllocation.validity() + override fun visitBulkWithProration( + bulkWithProration: NewPlanBulkWithProrationPrice + ) = bulkWithProration.validity() + override fun visitGroupedWithProratedMinimum( groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice ) = groupedWithProratedMinimum.validity() @@ -2551,10 +2566,6 @@ private constructor( matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice ) = matrixWithDisplayName.validity() - override fun visitBulkWithProration( - bulkWithProration: NewPlanBulkWithProrationPrice - ) = bulkWithProration.validity() - override fun visitGroupedTieredPackage( groupedTieredPackage: NewPlanGroupedTieredPackagePrice ) = groupedTieredPackage.validity() @@ -2576,17 +2587,6 @@ private constructor( cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice ) = cumulativeGroupedBulk.validity() - override fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice - ) = tieredPackageWithMinimum.validity() - - override fun visitMatrixWithAllocation( - matrixWithAllocation: NewPlanMatrixWithAllocationPrice - ) = matrixWithAllocation.validity() - - override fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) = - groupedTiered.validity() - override fun visitMinimum(minimum: NewPlanMinimumCompositePrice) = minimum.validity() @@ -2601,82 +2601,88 @@ private constructor( return other is Price && unit == other.unit && - package_ == other.package_ && - matrix == other.matrix && tiered == other.tiered && bulk == other.bulk && + package_ == other.package_ && + matrix == other.matrix && thresholdTotalAmount == other.thresholdTotalAmount && tieredPackage == other.tieredPackage && tieredWithMinimum == other.tieredWithMinimum && - unitWithPercent == other.unitWithPercent && + groupedTiered == other.groupedTiered && + tieredPackageWithMinimum == other.tieredPackageWithMinimum && packageWithAllocation == other.packageWithAllocation && + unitWithPercent == other.unitWithPercent && + matrixWithAllocation == other.matrixWithAllocation && tieredWithProration == other.tieredWithProration && unitWithProration == other.unitWithProration && groupedAllocation == other.groupedAllocation && + bulkWithProration == other.bulkWithProration && groupedWithProratedMinimum == other.groupedWithProratedMinimum && groupedWithMeteredMinimum == other.groupedWithMeteredMinimum && groupedWithMinMaxThresholds == other.groupedWithMinMaxThresholds && matrixWithDisplayName == other.matrixWithDisplayName && - bulkWithProration == other.bulkWithProration && groupedTieredPackage == other.groupedTieredPackage && maxGroupTieredPackage == other.maxGroupTieredPackage && scalableMatrixWithUnitPricing == other.scalableMatrixWithUnitPricing && scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && cumulativeGroupedBulk == other.cumulativeGroupedBulk && - tieredPackageWithMinimum == other.tieredPackageWithMinimum && - matrixWithAllocation == other.matrixWithAllocation && - groupedTiered == other.groupedTiered && minimum == other.minimum } override fun hashCode(): Int = Objects.hash( unit, - package_, - matrix, tiered, bulk, + package_, + matrix, thresholdTotalAmount, tieredPackage, tieredWithMinimum, - unitWithPercent, + groupedTiered, + tieredPackageWithMinimum, packageWithAllocation, + unitWithPercent, + matrixWithAllocation, tieredWithProration, unitWithProration, groupedAllocation, + bulkWithProration, groupedWithProratedMinimum, groupedWithMeteredMinimum, groupedWithMinMaxThresholds, matrixWithDisplayName, - bulkWithProration, groupedTieredPackage, maxGroupTieredPackage, scalableMatrixWithUnitPricing, scalableMatrixWithTieredPricing, cumulativeGroupedBulk, - tieredPackageWithMinimum, - matrixWithAllocation, - groupedTiered, minimum, ) override fun toString(): String = when { unit != null -> "Price{unit=$unit}" - package_ != null -> "Price{package_=$package_}" - matrix != null -> "Price{matrix=$matrix}" tiered != null -> "Price{tiered=$tiered}" bulk != null -> "Price{bulk=$bulk}" + package_ != null -> "Price{package_=$package_}" + matrix != null -> "Price{matrix=$matrix}" thresholdTotalAmount != null -> "Price{thresholdTotalAmount=$thresholdTotalAmount}" tieredPackage != null -> "Price{tieredPackage=$tieredPackage}" tieredWithMinimum != null -> "Price{tieredWithMinimum=$tieredWithMinimum}" - unitWithPercent != null -> "Price{unitWithPercent=$unitWithPercent}" + groupedTiered != null -> "Price{groupedTiered=$groupedTiered}" + tieredPackageWithMinimum != null -> + "Price{tieredPackageWithMinimum=$tieredPackageWithMinimum}" packageWithAllocation != null -> "Price{packageWithAllocation=$packageWithAllocation}" + unitWithPercent != null -> "Price{unitWithPercent=$unitWithPercent}" + matrixWithAllocation != null -> + "Price{matrixWithAllocation=$matrixWithAllocation}" tieredWithProration != null -> "Price{tieredWithProration=$tieredWithProration}" unitWithProration != null -> "Price{unitWithProration=$unitWithProration}" groupedAllocation != null -> "Price{groupedAllocation=$groupedAllocation}" + bulkWithProration != null -> "Price{bulkWithProration=$bulkWithProration}" groupedWithProratedMinimum != null -> "Price{groupedWithProratedMinimum=$groupedWithProratedMinimum}" groupedWithMeteredMinimum != null -> @@ -2685,7 +2691,6 @@ private constructor( "Price{groupedWithMinMaxThresholds=$groupedWithMinMaxThresholds}" matrixWithDisplayName != null -> "Price{matrixWithDisplayName=$matrixWithDisplayName}" - bulkWithProration != null -> "Price{bulkWithProration=$bulkWithProration}" groupedTieredPackage != null -> "Price{groupedTieredPackage=$groupedTieredPackage}" maxGroupTieredPackage != null -> @@ -2696,11 +2701,6 @@ private constructor( "Price{scalableMatrixWithTieredPricing=$scalableMatrixWithTieredPricing}" cumulativeGroupedBulk != null -> "Price{cumulativeGroupedBulk=$cumulativeGroupedBulk}" - tieredPackageWithMinimum != null -> - "Price{tieredPackageWithMinimum=$tieredPackageWithMinimum}" - matrixWithAllocation != null -> - "Price{matrixWithAllocation=$matrixWithAllocation}" - groupedTiered != null -> "Price{groupedTiered=$groupedTiered}" minimum != null -> "Price{minimum=$minimum}" _json != null -> "Price{_unknown=$_json}" else -> throw IllegalStateException("Invalid Price") @@ -2710,14 +2710,14 @@ private constructor( fun ofUnit(unit: NewPlanUnitPrice) = Price(unit = unit) - fun ofPackage(package_: NewPlanPackagePrice) = Price(package_ = package_) - - fun ofMatrix(matrix: NewPlanMatrixPrice) = Price(matrix = matrix) - fun ofTiered(tiered: NewPlanTieredPrice) = Price(tiered = tiered) fun ofBulk(bulk: NewPlanBulkPrice) = Price(bulk = bulk) + fun ofPackage(package_: NewPlanPackagePrice) = Price(package_ = package_) + + fun ofMatrix(matrix: NewPlanMatrixPrice) = Price(matrix = matrix) + fun ofThresholdTotalAmount(thresholdTotalAmount: NewPlanThresholdTotalAmountPrice) = Price(thresholdTotalAmount = thresholdTotalAmount) @@ -2727,14 +2727,24 @@ private constructor( fun ofTieredWithMinimum(tieredWithMinimum: NewPlanTieredWithMinimumPrice) = Price(tieredWithMinimum = tieredWithMinimum) - fun ofUnitWithPercent(unitWithPercent: NewPlanUnitWithPercentPrice) = - Price(unitWithPercent = unitWithPercent) + fun ofGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) = + Price(groupedTiered = groupedTiered) + + fun ofTieredPackageWithMinimum( + tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice + ) = Price(tieredPackageWithMinimum = tieredPackageWithMinimum) fun ofPackageWithAllocation( packageWithAllocation: NewPlanPackageWithAllocationPrice ) = Price(packageWithAllocation = packageWithAllocation) - fun ofTieredWithProration(tieredWithProration: NewPlanTierWithProrationPrice) = + fun ofUnitWithPercent(unitWithPercent: NewPlanUnitWithPercentPrice) = + Price(unitWithPercent = unitWithPercent) + + fun ofMatrixWithAllocation(matrixWithAllocation: NewPlanMatrixWithAllocationPrice) = + Price(matrixWithAllocation = matrixWithAllocation) + + fun ofTieredWithProration(tieredWithProration: TieredWithProration) = Price(tieredWithProration = tieredWithProration) fun ofUnitWithProration(unitWithProration: NewPlanUnitWithProrationPrice) = @@ -2743,6 +2753,9 @@ private constructor( fun ofGroupedAllocation(groupedAllocation: NewPlanGroupedAllocationPrice) = Price(groupedAllocation = groupedAllocation) + fun ofBulkWithProration(bulkWithProration: NewPlanBulkWithProrationPrice) = + Price(bulkWithProration = bulkWithProration) + fun ofGroupedWithProratedMinimum( groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice ) = Price(groupedWithProratedMinimum = groupedWithProratedMinimum) @@ -2759,9 +2772,6 @@ private constructor( matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice ) = Price(matrixWithDisplayName = matrixWithDisplayName) - fun ofBulkWithProration(bulkWithProration: NewPlanBulkWithProrationPrice) = - Price(bulkWithProration = bulkWithProration) - fun ofGroupedTieredPackage(groupedTieredPackage: NewPlanGroupedTieredPackagePrice) = Price(groupedTieredPackage = groupedTieredPackage) @@ -2781,16 +2791,6 @@ private constructor( cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice ) = Price(cumulativeGroupedBulk = cumulativeGroupedBulk) - fun ofTieredPackageWithMinimum( - tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice - ) = Price(tieredPackageWithMinimum = tieredPackageWithMinimum) - - fun ofMatrixWithAllocation(matrixWithAllocation: NewPlanMatrixWithAllocationPrice) = - Price(matrixWithAllocation = matrixWithAllocation) - - fun ofGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) = - Price(groupedTiered = groupedTiered) - fun ofMinimum(minimum: NewPlanMinimumCompositePrice) = Price(minimum = minimum) } @@ -2801,14 +2801,14 @@ private constructor( fun visitUnit(unit: NewPlanUnitPrice): T - fun visitPackage(package_: NewPlanPackagePrice): T - - fun visitMatrix(matrix: NewPlanMatrixPrice): T - fun visitTiered(tiered: NewPlanTieredPrice): T fun visitBulk(bulk: NewPlanBulkPrice): T + fun visitPackage(package_: NewPlanPackagePrice): T + + fun visitMatrix(matrix: NewPlanMatrixPrice): T + fun visitThresholdTotalAmount( thresholdTotalAmount: NewPlanThresholdTotalAmountPrice ): T @@ -2817,18 +2817,30 @@ private constructor( fun visitTieredWithMinimum(tieredWithMinimum: NewPlanTieredWithMinimumPrice): T - fun visitUnitWithPercent(unitWithPercent: NewPlanUnitWithPercentPrice): T + fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice): T + + fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice + ): T fun visitPackageWithAllocation( packageWithAllocation: NewPlanPackageWithAllocationPrice ): T - fun visitTieredWithProration(tieredWithProration: NewPlanTierWithProrationPrice): T + fun visitUnitWithPercent(unitWithPercent: NewPlanUnitWithPercentPrice): T + + fun visitMatrixWithAllocation( + matrixWithAllocation: NewPlanMatrixWithAllocationPrice + ): T + + fun visitTieredWithProration(tieredWithProration: TieredWithProration): T fun visitUnitWithProration(unitWithProration: NewPlanUnitWithProrationPrice): T fun visitGroupedAllocation(groupedAllocation: NewPlanGroupedAllocationPrice): T + fun visitBulkWithProration(bulkWithProration: NewPlanBulkWithProrationPrice): T + fun visitGroupedWithProratedMinimum( groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice ): T @@ -2845,8 +2857,6 @@ private constructor( matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice ): T - fun visitBulkWithProration(bulkWithProration: NewPlanBulkWithProrationPrice): T - fun visitGroupedTieredPackage( groupedTieredPackage: NewPlanGroupedTieredPackagePrice ): T @@ -2867,16 +2877,6 @@ private constructor( cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice ): T - fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice - ): T - - fun visitMatrixWithAllocation( - matrixWithAllocation: NewPlanMatrixWithAllocationPrice - ): T - - fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice): T - fun visitMinimum(minimum: NewPlanMinimumCompositePrice): T /** @@ -2906,15 +2906,6 @@ private constructor( Price(unit = it, _json = json) } ?: Price(_json = json) } - "package" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(package_ = it, _json = json) } ?: Price(_json = json) - } - "matrix" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(matrix = it, _json = json) - } ?: Price(_json = json) - } "tiered" -> { return tryDeserialize(node, jacksonTypeRef())?.let { Price(tiered = it, _json = json) @@ -2925,6 +2916,15 @@ private constructor( Price(bulk = it, _json = json) } ?: Price(_json = json) } + "package" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(package_ = it, _json = json) } ?: Price(_json = json) + } + "matrix" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(matrix = it, _json = json) + } ?: Price(_json = json) + } "threshold_total_amount" -> { return tryDeserialize( node, @@ -2946,12 +2946,17 @@ private constructor( ?.let { Price(tieredWithMinimum = it, _json = json) } ?: Price(_json = json) } - "unit_with_percent" -> { + "grouped_tiered" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(groupedTiered = it, _json = json) } + ?: Price(_json = json) + } + "tiered_package_with_minimum" -> { return tryDeserialize( node, - jacksonTypeRef(), + jacksonTypeRef(), ) - ?.let { Price(unitWithPercent = it, _json = json) } + ?.let { Price(tieredPackageWithMinimum = it, _json = json) } ?: Price(_json = json) } "package_with_allocation" -> { @@ -2962,11 +2967,24 @@ private constructor( ?.let { Price(packageWithAllocation = it, _json = json) } ?: Price(_json = json) } - "tiered_with_proration" -> { + "unit_with_percent" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(unitWithPercent = it, _json = json) } + ?: Price(_json = json) + } + "matrix_with_allocation" -> { return tryDeserialize( node, - jacksonTypeRef(), + jacksonTypeRef(), ) + ?.let { Price(matrixWithAllocation = it, _json = json) } + ?: Price(_json = json) + } + "tiered_with_proration" -> { + return tryDeserialize(node, jacksonTypeRef()) ?.let { Price(tieredWithProration = it, _json = json) } ?: Price(_json = json) } @@ -2986,6 +3004,14 @@ private constructor( ?.let { Price(groupedAllocation = it, _json = json) } ?: Price(_json = json) } + "bulk_with_proration" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(bulkWithProration = it, _json = json) } + ?: Price(_json = json) + } "grouped_with_prorated_minimum" -> { return tryDeserialize( node, @@ -3018,14 +3044,6 @@ private constructor( ?.let { Price(matrixWithDisplayName = it, _json = json) } ?: Price(_json = json) } - "bulk_with_proration" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(bulkWithProration = it, _json = json) } - ?: Price(_json = json) - } "grouped_tiered_package" -> { return tryDeserialize( node, @@ -3066,27 +3084,6 @@ private constructor( ?.let { Price(cumulativeGroupedBulk = it, _json = json) } ?: Price(_json = json) } - "tiered_package_with_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(tieredPackageWithMinimum = it, _json = json) } - ?: Price(_json = json) - } - "matrix_with_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(matrixWithAllocation = it, _json = json) } - ?: Price(_json = json) - } - "grouped_tiered" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(groupedTiered = it, _json = json) } - ?: Price(_json = json) - } "minimum" -> { return tryDeserialize( node, @@ -3109,25 +3106,32 @@ private constructor( ) { when { value.unit != null -> generator.writeObject(value.unit) - value.package_ != null -> generator.writeObject(value.package_) - value.matrix != null -> generator.writeObject(value.matrix) value.tiered != null -> generator.writeObject(value.tiered) value.bulk != null -> generator.writeObject(value.bulk) + value.package_ != null -> generator.writeObject(value.package_) + value.matrix != null -> generator.writeObject(value.matrix) value.thresholdTotalAmount != null -> generator.writeObject(value.thresholdTotalAmount) value.tieredPackage != null -> generator.writeObject(value.tieredPackage) value.tieredWithMinimum != null -> generator.writeObject(value.tieredWithMinimum) - value.unitWithPercent != null -> - generator.writeObject(value.unitWithPercent) + value.groupedTiered != null -> generator.writeObject(value.groupedTiered) + value.tieredPackageWithMinimum != null -> + generator.writeObject(value.tieredPackageWithMinimum) value.packageWithAllocation != null -> generator.writeObject(value.packageWithAllocation) + value.unitWithPercent != null -> + generator.writeObject(value.unitWithPercent) + value.matrixWithAllocation != null -> + generator.writeObject(value.matrixWithAllocation) value.tieredWithProration != null -> generator.writeObject(value.tieredWithProration) value.unitWithProration != null -> generator.writeObject(value.unitWithProration) value.groupedAllocation != null -> generator.writeObject(value.groupedAllocation) + value.bulkWithProration != null -> + generator.writeObject(value.bulkWithProration) value.groupedWithProratedMinimum != null -> generator.writeObject(value.groupedWithProratedMinimum) value.groupedWithMeteredMinimum != null -> @@ -3136,8 +3140,6 @@ private constructor( generator.writeObject(value.groupedWithMinMaxThresholds) value.matrixWithDisplayName != null -> generator.writeObject(value.matrixWithDisplayName) - value.bulkWithProration != null -> - generator.writeObject(value.bulkWithProration) value.groupedTieredPackage != null -> generator.writeObject(value.groupedTieredPackage) value.maxGroupTieredPackage != null -> @@ -3148,11 +3150,6 @@ private constructor( generator.writeObject(value.scalableMatrixWithTieredPricing) value.cumulativeGroupedBulk != null -> generator.writeObject(value.cumulativeGroupedBulk) - value.tieredPackageWithMinimum != null -> - generator.writeObject(value.tieredPackageWithMinimum) - value.matrixWithAllocation != null -> - generator.writeObject(value.matrixWithAllocation) - value.groupedTiered != null -> generator.writeObject(value.groupedTiered) value.minimum != null -> generator.writeObject(value.minimum) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid Price") @@ -3160,14 +3157,13 @@ private constructor( } } - class GroupedWithMinMaxThresholds + class TieredWithProration private constructor( private val cadence: JsonField, - private val groupedWithMinMaxThresholdsConfig: - JsonField, private val itemId: JsonField, private val modelType: JsonValue, private val name: JsonField, + private val tieredWithProrationConfig: JsonField, private val billableMetricId: JsonField, private val billedInAdvance: JsonField, private val billingCycleConfiguration: JsonField, @@ -3190,11 +3186,6 @@ private constructor( @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), - @JsonProperty("grouped_with_min_max_thresholds_config") - @ExcludeMissing - groupedWithMinMaxThresholdsConfig: - JsonField = - JsonMissing.of(), @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), @@ -3204,6 +3195,10 @@ private constructor( @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("tiered_with_proration_config") + @ExcludeMissing + tieredWithProrationConfig: JsonField = + JsonMissing.of(), @JsonProperty("billable_metric_id") @ExcludeMissing billableMetricId: JsonField = JsonMissing.of(), @@ -3248,10 +3243,10 @@ private constructor( referenceId: JsonField = JsonMissing.of(), ) : this( cadence, - groupedWithMinMaxThresholdsConfig, itemId, modelType, name, + tieredWithProrationConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -3277,16 +3272,6 @@ private constructor( */ fun cadence(): Cadence = cadence.getRequired("cadence") - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun groupedWithMinMaxThresholdsConfig(): GroupedWithMinMaxThresholdsConfig = - groupedWithMinMaxThresholdsConfig.getRequired( - "grouped_with_min_max_thresholds_config" - ) - /** * The id of the item the price will be associated with. * @@ -3297,9 +3282,11 @@ private constructor( fun itemId(): String = itemId.getRequired("item_id") /** + * The pricing model type + * * Expected to always return the following: * ```kotlin - * JsonValue.from("grouped_with_min_max_thresholds") + * JsonValue.from("tiered_with_proration") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -3316,6 +3303,16 @@ private constructor( */ fun name(): String = name.getRequired("name") + /** + * Configuration for tiered_with_proration pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun tieredWithProrationConfig(): TieredWithProrationConfig = + tieredWithProrationConfig.getRequired("tiered_with_proration_config") + /** * The id of the billable metric for the price. Only needed if the price is * usage-based. @@ -3445,17 +3442,6 @@ private constructor( @ExcludeMissing fun _cadence(): JsonField = cadence - /** - * Returns the raw JSON value of [groupedWithMinMaxThresholdsConfig]. - * - * Unlike [groupedWithMinMaxThresholdsConfig], this method doesn't throw if the JSON - * field has an unexpected type. - */ - @JsonProperty("grouped_with_min_max_thresholds_config") - @ExcludeMissing - fun _groupedWithMinMaxThresholdsConfig(): - JsonField = groupedWithMinMaxThresholdsConfig - /** * Returns the raw JSON value of [itemId]. * @@ -3472,6 +3458,17 @@ private constructor( */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + /** + * Returns the raw JSON value of [tieredWithProrationConfig]. + * + * Unlike [tieredWithProrationConfig], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("tiered_with_proration_config") + @ExcludeMissing + fun _tieredWithProrationConfig(): JsonField = + tieredWithProrationConfig + /** * Returns the raw JSON value of [billableMetricId]. * @@ -3621,30 +3618,28 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [GroupedWithMinMaxThresholds]. + * [TieredWithProration]. * * The following fields are required: * ```kotlin * .cadence() - * .groupedWithMinMaxThresholdsConfig() * .itemId() * .name() + * .tieredWithProrationConfig() * ``` */ fun builder() = Builder() } - /** A builder for [GroupedWithMinMaxThresholds]. */ + /** A builder for [TieredWithProration]. */ class Builder internal constructor() { private var cadence: JsonField? = null - private var groupedWithMinMaxThresholdsConfig: - JsonField? = - null private var itemId: JsonField? = null - private var modelType: JsonValue = - JsonValue.from("grouped_with_min_max_thresholds") + private var modelType: JsonValue = JsonValue.from("tiered_with_proration") private var name: JsonField? = null + private var tieredWithProrationConfig: JsonField? = + null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() private var billingCycleConfiguration: JsonField = @@ -3666,33 +3661,30 @@ private constructor( private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds) = - apply { - cadence = groupedWithMinMaxThresholds.cadence - groupedWithMinMaxThresholdsConfig = - groupedWithMinMaxThresholds.groupedWithMinMaxThresholdsConfig - itemId = groupedWithMinMaxThresholds.itemId - modelType = groupedWithMinMaxThresholds.modelType - name = groupedWithMinMaxThresholds.name - billableMetricId = groupedWithMinMaxThresholds.billableMetricId - billedInAdvance = groupedWithMinMaxThresholds.billedInAdvance - billingCycleConfiguration = - groupedWithMinMaxThresholds.billingCycleConfiguration - conversionRate = groupedWithMinMaxThresholds.conversionRate - conversionRateConfig = groupedWithMinMaxThresholds.conversionRateConfig - currency = groupedWithMinMaxThresholds.currency - dimensionalPriceConfiguration = - groupedWithMinMaxThresholds.dimensionalPriceConfiguration - externalPriceId = groupedWithMinMaxThresholds.externalPriceId - fixedPriceQuantity = groupedWithMinMaxThresholds.fixedPriceQuantity - invoiceGroupingKey = groupedWithMinMaxThresholds.invoiceGroupingKey - invoicingCycleConfiguration = - groupedWithMinMaxThresholds.invoicingCycleConfiguration - metadata = groupedWithMinMaxThresholds.metadata - referenceId = groupedWithMinMaxThresholds.referenceId - additionalProperties = - groupedWithMinMaxThresholds.additionalProperties.toMutableMap() - } + internal fun from(tieredWithProration: TieredWithProration) = apply { + cadence = tieredWithProration.cadence + itemId = tieredWithProration.itemId + modelType = tieredWithProration.modelType + name = tieredWithProration.name + tieredWithProrationConfig = tieredWithProration.tieredWithProrationConfig + billableMetricId = tieredWithProration.billableMetricId + billedInAdvance = tieredWithProration.billedInAdvance + billingCycleConfiguration = tieredWithProration.billingCycleConfiguration + conversionRate = tieredWithProration.conversionRate + conversionRateConfig = tieredWithProration.conversionRateConfig + currency = tieredWithProration.currency + dimensionalPriceConfiguration = + tieredWithProration.dimensionalPriceConfiguration + externalPriceId = tieredWithProration.externalPriceId + fixedPriceQuantity = tieredWithProration.fixedPriceQuantity + invoiceGroupingKey = tieredWithProration.invoiceGroupingKey + invoicingCycleConfiguration = + tieredWithProration.invoicingCycleConfiguration + metadata = tieredWithProration.metadata + referenceId = tieredWithProration.referenceId + additionalProperties = + tieredWithProration.additionalProperties.toMutableMap() + } /** The cadence to bill for this price on. */ fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) @@ -3706,28 +3698,6 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - fun groupedWithMinMaxThresholdsConfig( - groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig - ) = - groupedWithMinMaxThresholdsConfig( - JsonField.of(groupedWithMinMaxThresholdsConfig) - ) - - /** - * Sets [Builder.groupedWithMinMaxThresholdsConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.groupedWithMinMaxThresholdsConfig] with a - * well-typed [GroupedWithMinMaxThresholdsConfig] value instead. This method is - * primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun groupedWithMinMaxThresholdsConfig( - groupedWithMinMaxThresholdsConfig: - JsonField - ) = apply { - this.groupedWithMinMaxThresholdsConfig = groupedWithMinMaxThresholdsConfig - } - /** The id of the item the price will be associated with. */ fun itemId(itemId: String) = itemId(JsonField.of(itemId)) @@ -3746,7 +3716,7 @@ private constructor( * It is usually unnecessary to call this method because the field defaults to * the following: * ```kotlin - * JsonValue.from("grouped_with_min_max_thresholds") + * JsonValue.from("tiered_with_proration") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -3766,6 +3736,22 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } + /** Configuration for tiered_with_proration pricing */ + fun tieredWithProrationConfig( + tieredWithProrationConfig: TieredWithProrationConfig + ) = tieredWithProrationConfig(JsonField.of(tieredWithProrationConfig)) + + /** + * Sets [Builder.tieredWithProrationConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.tieredWithProrationConfig] with a well-typed + * [TieredWithProrationConfig] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun tieredWithProrationConfig( + tieredWithProrationConfig: JsonField + ) = apply { this.tieredWithProrationConfig = tieredWithProrationConfig } + /** * The id of the billable metric for the price. Only needed if the price is * usage-based. @@ -4095,30 +4081,27 @@ private constructor( } /** - * Returns an immutable instance of [GroupedWithMinMaxThresholds]. + * Returns an immutable instance of [TieredWithProration]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```kotlin * .cadence() - * .groupedWithMinMaxThresholdsConfig() * .itemId() * .name() + * .tieredWithProrationConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): GroupedWithMinMaxThresholds = - GroupedWithMinMaxThresholds( + fun build(): TieredWithProration = + TieredWithProration( checkRequired("cadence", cadence), - checkRequired( - "groupedWithMinMaxThresholdsConfig", - groupedWithMinMaxThresholdsConfig, - ), checkRequired("itemId", itemId), modelType, checkRequired("name", name), + checkRequired("tieredWithProrationConfig", tieredWithProrationConfig), billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -4138,20 +4121,20 @@ private constructor( private var validated: Boolean = false - fun validate(): GroupedWithMinMaxThresholds = apply { + fun validate(): TieredWithProration = apply { if (validated) { return@apply } cadence().validate() - groupedWithMinMaxThresholdsConfig().validate() itemId() _modelType().let { - if (it != JsonValue.from("grouped_with_min_max_thresholds")) { + if (it != JsonValue.from("tiered_with_proration")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } name() + tieredWithProrationConfig().validate() billableMetricId() billedInAdvance() billingCycleConfiguration()?.validate() @@ -4184,12 +4167,12 @@ private constructor( */ internal fun validity(): Int = (cadence.asKnown()?.validity() ?: 0) + - (groupedWithMinMaxThresholdsConfig.asKnown()?.validity() ?: 0) + (if (itemId.asKnown() == null) 0 else 1) + modelType.let { - if (it == JsonValue.from("grouped_with_min_max_thresholds")) 1 else 0 + if (it == JsonValue.from("tiered_with_proration")) 1 else 0 } + (if (name.asKnown() == null) 0 else 1) + + (tieredWithProrationConfig.asKnown()?.validity() ?: 0) + (if (billableMetricId.asKnown() == null) 0 else 1) + (if (billedInAdvance.asKnown() == null) 0 else 1) + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + @@ -4361,16 +4344,49 @@ private constructor( override fun toString() = value.toString() } - class GroupedWithMinMaxThresholdsConfig - @JsonCreator + /** Configuration for tiered_with_proration pricing */ + class TieredWithProrationConfig private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map + private val tiers: JsonField>, + private val additionalProperties: MutableMap, ) { + @JsonCreator + private constructor( + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of() + ) : this(tiers, mutableMapOf()) + + /** + * Tiers for rating based on total usage quantities into the specified tier with + * proration + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun tiers(): List = tiers.getRequired("tiers") + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) fun toBuilder() = Builder().from(this) @@ -4378,23 +4394,58 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [GroupedWithMinMaxThresholdsConfig]. + * [TieredWithProrationConfig]. + * + * The following fields are required: + * ```kotlin + * .tiers() + * ``` */ fun builder() = Builder() } - /** A builder for [GroupedWithMinMaxThresholdsConfig]. */ + /** A builder for [TieredWithProrationConfig]. */ class Builder internal constructor() { + private var tiers: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() - internal fun from( - groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig - ) = apply { - additionalProperties = - groupedWithMinMaxThresholdsConfig.additionalProperties - .toMutableMap() + internal fun from(tieredWithProrationConfig: TieredWithProrationConfig) = + apply { + tiers = tieredWithProrationConfig.tiers.map { it.toMutableList() } + additionalProperties = + tieredWithProrationConfig.additionalProperties.toMutableMap() + } + + /** + * Tiers for rating based on total usage quantities into the specified tier + * with proration + */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } } fun additionalProperties(additionalProperties: Map) = @@ -4420,21 +4471,32 @@ private constructor( } /** - * Returns an immutable instance of [GroupedWithMinMaxThresholdsConfig]. + * Returns an immutable instance of [TieredWithProrationConfig]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ - fun build(): GroupedWithMinMaxThresholdsConfig = - GroupedWithMinMaxThresholdsConfig(additionalProperties.toImmutable()) + fun build(): TieredWithProrationConfig = + TieredWithProrationConfig( + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false - fun validate(): GroupedWithMinMaxThresholdsConfig = apply { + fun validate(): TieredWithProrationConfig = apply { if (validated) { return@apply } + tiers().forEach { it.validate() } validated = true } @@ -4453,25 +4515,246 @@ private constructor( * Used for best match union deserialization. */ internal fun validity(): Int = - additionalProperties.count { (_, value) -> - !value.isNull() && !value.isMissing() + (tiers.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single tiered with proration tier */ + class Tier + private constructor( + private val tierLowerBound: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(tierLowerBound, unitAmount, mutableMapOf()) + + /** + * Inclusive tier starting value + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun tierLowerBound(): String = + tierLowerBound.getRequired("tier_lower_bound") + + /** + * Amount per unit + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Tier]. + * + * The following fields are required: + * ```kotlin + * .tierLowerBound() + * .unitAmount() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var tierLowerBound: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(tier: Tier) = apply { + tierLowerBound = tier.tierLowerBound + unitAmount = tier.unitAmount + additionalProperties = tier.additionalProperties.toMutableMap() + } + + /** Inclusive tier starting value */ + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + /** Amount per unit */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```kotlin + * .tierLowerBound() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("tierLowerBound", tierLowerBound), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + tierLowerBound() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (tierLowerBound.asKnown() == null) 0 else 1) + + (if (unitAmount.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + tierLowerBound == other.tierLowerBound && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties } + private val hashCode: Int by lazy { + Objects.hash(tierLowerBound, unitAmount, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is GroupedWithMinMaxThresholdsConfig && + return other is TieredWithProrationConfig && + tiers == other.tiers && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(tiers, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "GroupedWithMinMaxThresholdsConfig{additionalProperties=$additionalProperties}" + "TieredWithProrationConfig{tiers=$tiers, additionalProperties=$additionalProperties}" } /** @@ -4588,13 +4871,12 @@ private constructor( return true } - return other is GroupedWithMinMaxThresholds && + return other is TieredWithProration && cadence == other.cadence && - groupedWithMinMaxThresholdsConfig == - other.groupedWithMinMaxThresholdsConfig && itemId == other.itemId && modelType == other.modelType && name == other.name && + tieredWithProrationConfig == other.tieredWithProrationConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && @@ -4614,10 +4896,10 @@ private constructor( private val hashCode: Int by lazy { Objects.hash( cadence, - groupedWithMinMaxThresholdsConfig, itemId, modelType, name, + tieredWithProrationConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -4638,1048 +4920,1703 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "GroupedWithMinMaxThresholds{cadence=$cadence, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + "TieredWithProration{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredWithProrationConfig=$tieredWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - return other is AddPrice && - allocationPrice == other.allocationPrice && - planPhaseOrder == other.planPhaseOrder && - price == other.price && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(allocationPrice, planPhaseOrder, price, additionalProperties) - } + class GroupedWithMinMaxThresholds + private constructor( + private val cadence: JsonField, + private val groupedWithMinMaxThresholdsConfig: + JsonField, + private val itemId: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { - override fun hashCode(): Int = hashCode + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("grouped_with_min_max_thresholds_config") + @ExcludeMissing + groupedWithMinMaxThresholdsConfig: + JsonField = + JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + groupedWithMinMaxThresholdsConfig, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + mutableMapOf(), + ) - override fun toString() = - "AddPrice{allocationPrice=$allocationPrice, planPhaseOrder=$planPhaseOrder, price=$price, additionalProperties=$additionalProperties}" - } + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") - class RemoveAdjustment - private constructor( - private val adjustmentId: JsonField, - private val planPhaseOrder: JsonField, - private val additionalProperties: MutableMap, - ) { + /** + * Configuration for grouped_with_min_max_thresholds pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupedWithMinMaxThresholdsConfig(): GroupedWithMinMaxThresholdsConfig = + groupedWithMinMaxThresholdsConfig.getRequired( + "grouped_with_min_max_thresholds_config" + ) - @JsonCreator - private constructor( - @JsonProperty("adjustment_id") - @ExcludeMissing - adjustmentId: JsonField = JsonMissing.of(), - @JsonProperty("plan_phase_order") - @ExcludeMissing - planPhaseOrder: JsonField = JsonMissing.of(), - ) : this(adjustmentId, planPhaseOrder, mutableMapOf()) + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") - /** - * The id of the adjustment to remove from on the plan. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun adjustmentId(): String = adjustmentId.getRequired("adjustment_id") + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("grouped_with_min_max_thresholds") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType - /** - * The phase to remove this adjustment from. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun planPhaseOrder(): Long? = planPhaseOrder.getNullable("plan_phase_order") + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") - /** - * Returns the raw JSON value of [adjustmentId]. - * - * Unlike [adjustmentId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("adjustment_id") - @ExcludeMissing - fun _adjustmentId(): JsonField = adjustmentId + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = billableMetricId.getNullable("billable_metric_id") - /** - * Returns the raw JSON value of [planPhaseOrder]. - * - * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("plan_phase_order") - @ExcludeMissing - fun _planPhaseOrder(): JsonField = planPhaseOrder + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") - fun toBuilder() = Builder().from(this) + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") - companion object { - - /** - * Returns a mutable builder for constructing an instance of [RemoveAdjustment]. - * - * The following fields are required: - * ```kotlin - * .adjustmentId() - * ``` - */ - fun builder() = Builder() - } - - /** A builder for [RemoveAdjustment]. */ - class Builder internal constructor() { + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") - private var adjustmentId: JsonField? = null - private var planPhaseOrder: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") - internal fun from(removeAdjustment: RemoveAdjustment) = apply { - adjustmentId = removeAdjustment.adjustmentId - planPhaseOrder = removeAdjustment.planPhaseOrder - additionalProperties = removeAdjustment.additionalProperties.toMutableMap() - } + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") - /** The id of the adjustment to remove from on the plan. */ - fun adjustmentId(adjustmentId: String) = adjustmentId(JsonField.of(adjustmentId)) + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") - /** - * Sets [Builder.adjustmentId] to an arbitrary JSON value. - * - * You should usually call [Builder.adjustmentId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun adjustmentId(adjustmentId: JsonField) = apply { - this.adjustmentId = adjustmentId - } + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + invoiceGroupingKey.getNullable("invoice_grouping_key") - /** The phase to remove this adjustment from. */ - fun planPhaseOrder(planPhaseOrder: Long?) = - planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - /** - * Alias for [Builder.planPhaseOrder]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") - /** - * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. - * - * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun planPhaseOrder(planPhaseOrder: JsonField) = apply { - this.planPhaseOrder = planPhaseOrder - } + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * Returns the raw JSON value of [groupedWithMinMaxThresholdsConfig]. + * + * Unlike [groupedWithMinMaxThresholdsConfig], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("grouped_with_min_max_thresholds_config") + @ExcludeMissing + fun _groupedWithMinMaxThresholdsConfig(): + JsonField = groupedWithMinMaxThresholdsConfig - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId - /** - * Returns an immutable instance of [RemoveAdjustment]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```kotlin - * .adjustmentId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): RemoveAdjustment = - RemoveAdjustment( - checkRequired("adjustmentId", adjustmentId), - planPhaseOrder, - additionalProperties.toMutableMap(), - ) - } + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance - private var validated: Boolean = false + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration - fun validate(): RemoveAdjustment = apply { - if (validated) { - return@apply - } + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate - adjustmentId() - planPhaseOrder() - validated = true - } + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (if (adjustmentId.asKnown() == null) 0 else 1) + - (if (planPhaseOrder.asKnown() == null) 0 else 1) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration - return other is RemoveAdjustment && - adjustmentId == other.adjustmentId && - planPhaseOrder == other.planPhaseOrder && - additionalProperties == other.additionalProperties - } + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId - private val hashCode: Int by lazy { - Objects.hash(adjustmentId, planPhaseOrder, additionalProperties) - } + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - override fun hashCode(): Int = hashCode + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - override fun toString() = - "RemoveAdjustment{adjustmentId=$adjustmentId, planPhaseOrder=$planPhaseOrder, additionalProperties=$additionalProperties}" - } + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration - class RemovePrice - private constructor( - private val priceId: JsonField, - private val planPhaseOrder: JsonField, - private val additionalProperties: MutableMap, - ) { + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata - @JsonCreator - private constructor( - @JsonProperty("price_id") @ExcludeMissing priceId: JsonField = JsonMissing.of(), - @JsonProperty("plan_phase_order") - @ExcludeMissing - planPhaseOrder: JsonField = JsonMissing.of(), - ) : this(priceId, planPhaseOrder, mutableMapOf()) + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId - /** - * The id of the price to remove from the plan. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun priceId(): String = priceId.getRequired("price_id") + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - /** - * The phase to remove this price from. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun planPhaseOrder(): Long? = planPhaseOrder.getNullable("plan_phase_order") + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - /** - * Returns the raw JSON value of [priceId]. - * - * Unlike [priceId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId + fun toBuilder() = Builder().from(this) - /** - * Returns the raw JSON value of [planPhaseOrder]. - * - * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("plan_phase_order") - @ExcludeMissing - fun _planPhaseOrder(): JsonField = planPhaseOrder + companion object { - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** + * Returns a mutable builder for constructing an instance of + * [GroupedWithMinMaxThresholds]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .groupedWithMinMaxThresholdsConfig() + * .itemId() + * .name() + * ``` + */ + fun builder() = Builder() + } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** A builder for [GroupedWithMinMaxThresholds]. */ + class Builder internal constructor() { - fun toBuilder() = Builder().from(this) + private var cadence: JsonField? = null + private var groupedWithMinMaxThresholdsConfig: + JsonField? = + null + private var itemId: JsonField? = null + private var modelType: JsonValue = + JsonValue.from("grouped_with_min_max_thresholds") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - companion object { + internal fun from(groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds) = + apply { + cadence = groupedWithMinMaxThresholds.cadence + groupedWithMinMaxThresholdsConfig = + groupedWithMinMaxThresholds.groupedWithMinMaxThresholdsConfig + itemId = groupedWithMinMaxThresholds.itemId + modelType = groupedWithMinMaxThresholds.modelType + name = groupedWithMinMaxThresholds.name + billableMetricId = groupedWithMinMaxThresholds.billableMetricId + billedInAdvance = groupedWithMinMaxThresholds.billedInAdvance + billingCycleConfiguration = + groupedWithMinMaxThresholds.billingCycleConfiguration + conversionRate = groupedWithMinMaxThresholds.conversionRate + conversionRateConfig = groupedWithMinMaxThresholds.conversionRateConfig + currency = groupedWithMinMaxThresholds.currency + dimensionalPriceConfiguration = + groupedWithMinMaxThresholds.dimensionalPriceConfiguration + externalPriceId = groupedWithMinMaxThresholds.externalPriceId + fixedPriceQuantity = groupedWithMinMaxThresholds.fixedPriceQuantity + invoiceGroupingKey = groupedWithMinMaxThresholds.invoiceGroupingKey + invoicingCycleConfiguration = + groupedWithMinMaxThresholds.invoicingCycleConfiguration + metadata = groupedWithMinMaxThresholds.metadata + referenceId = groupedWithMinMaxThresholds.referenceId + additionalProperties = + groupedWithMinMaxThresholds.additionalProperties.toMutableMap() + } - /** - * Returns a mutable builder for constructing an instance of [RemovePrice]. - * - * The following fields are required: - * ```kotlin - * .priceId() - * ``` - */ - fun builder() = Builder() - } + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - /** A builder for [RemovePrice]. */ - class Builder internal constructor() { + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - private var priceId: JsonField? = null - private var planPhaseOrder: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + /** Configuration for grouped_with_min_max_thresholds pricing */ + fun groupedWithMinMaxThresholdsConfig( + groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + ) = + groupedWithMinMaxThresholdsConfig( + JsonField.of(groupedWithMinMaxThresholdsConfig) + ) - internal fun from(removePrice: RemovePrice) = apply { - priceId = removePrice.priceId - planPhaseOrder = removePrice.planPhaseOrder - additionalProperties = removePrice.additionalProperties.toMutableMap() - } - - /** The id of the price to remove from the plan. */ - fun priceId(priceId: String) = priceId(JsonField.of(priceId)) - - /** - * Sets [Builder.priceId] to an arbitrary JSON value. - * - * You should usually call [Builder.priceId] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun priceId(priceId: JsonField) = apply { this.priceId = priceId } + /** + * Sets [Builder.groupedWithMinMaxThresholdsConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.groupedWithMinMaxThresholdsConfig] with a + * well-typed [GroupedWithMinMaxThresholdsConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun groupedWithMinMaxThresholdsConfig( + groupedWithMinMaxThresholdsConfig: + JsonField + ) = apply { + this.groupedWithMinMaxThresholdsConfig = groupedWithMinMaxThresholdsConfig + } - /** The phase to remove this price from. */ - fun planPhaseOrder(planPhaseOrder: Long?) = - planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - /** - * Alias for [Builder.planPhaseOrder]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - /** - * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. - * - * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun planPhaseOrder(planPhaseOrder: JsonField) = apply { - this.planPhaseOrder = planPhaseOrder - } + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("grouped_with_min_max_thresholds") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) - /** - * Returns an immutable instance of [RemovePrice]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```kotlin - * .priceId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): RemovePrice = - RemovePrice( - checkRequired("priceId", priceId), - planPhaseOrder, - additionalProperties.toMutableMap(), - ) - } + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) - private var validated: Boolean = false + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } - fun validate(): RemovePrice = apply { - if (validated) { - return@apply - } + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - priceId() - planPhaseOrder() - validated = true - } + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (if (priceId.asKnown() == null) 0 else 1) + - (if (planPhaseOrder.asKnown() == null) 0 else 1) + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } - return other is RemovePrice && - priceId == other.priceId && - planPhaseOrder == other.planPhaseOrder && - additionalProperties == other.additionalProperties - } + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) - private val hashCode: Int by lazy { - Objects.hash(priceId, planPhaseOrder, additionalProperties) - } + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } - override fun hashCode(): Int = hashCode + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) - override fun toString() = - "RemovePrice{priceId=$priceId, planPhaseOrder=$planPhaseOrder, additionalProperties=$additionalProperties}" - } - - class ReplaceAdjustment - private constructor( - private val adjustment: JsonField, - private val replacesAdjustmentId: JsonField, - private val planPhaseOrder: JsonField, - private val additionalProperties: MutableMap, - ) { + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) - @JsonCreator - private constructor( - @JsonProperty("adjustment") - @ExcludeMissing - adjustment: JsonField = JsonMissing.of(), - @JsonProperty("replaces_adjustment_id") - @ExcludeMissing - replacesAdjustmentId: JsonField = JsonMissing.of(), - @JsonProperty("plan_phase_order") - @ExcludeMissing - planPhaseOrder: JsonField = JsonMissing.of(), - ) : this(adjustment, replacesAdjustmentId, planPhaseOrder, mutableMapOf()) + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) - /** - * The definition of a new adjustment to create and add to the plan. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun adjustment(): Adjustment = adjustment.getRequired("adjustment") + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) - /** - * The id of the adjustment on the plan to replace in the plan. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun replacesAdjustmentId(): String = - replacesAdjustmentId.getRequired("replaces_adjustment_id") + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) - /** - * The phase to replace this adjustment from. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun planPhaseOrder(): Long? = planPhaseOrder.getNullable("plan_phase_order") + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } - /** - * Returns the raw JSON value of [adjustment]. - * - * Unlike [adjustment], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("adjustment") - @ExcludeMissing - fun _adjustment(): JsonField = adjustment + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) - /** - * Returns the raw JSON value of [replacesAdjustmentId]. - * - * Unlike [replacesAdjustmentId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("replaces_adjustment_id") - @ExcludeMissing - fun _replacesAdjustmentId(): JsonField = replacesAdjustmentId + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } - /** - * Returns the raw JSON value of [planPhaseOrder]. - * - * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("plan_phase_order") - @ExcludeMissing - fun _planPhaseOrder(): JsonField = planPhaseOrder + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) - fun toBuilder() = Builder().from(this) + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) - companion object { + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } - /** - * Returns a mutable builder for constructing an instance of [ReplaceAdjustment]. - * - * The following fields are required: - * ```kotlin - * .adjustment() - * .replacesAdjustmentId() - * ``` - */ - fun builder() = Builder() - } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) - /** A builder for [ReplaceAdjustment]. */ - class Builder internal constructor() { + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } - private var adjustment: JsonField? = null - private var replacesAdjustmentId: JsonField? = null - private var planPhaseOrder: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) - internal fun from(replaceAdjustment: ReplaceAdjustment) = apply { - adjustment = replaceAdjustment.adjustment - replacesAdjustmentId = replaceAdjustment.replacesAdjustmentId - planPhaseOrder = replaceAdjustment.planPhaseOrder - additionalProperties = replaceAdjustment.additionalProperties.toMutableMap() - } + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - /** The definition of a new adjustment to create and add to the plan. */ - fun adjustment(adjustment: Adjustment) = adjustment(JsonField.of(adjustment)) + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - /** - * Sets [Builder.adjustment] to an arbitrary JSON value. - * - * You should usually call [Builder.adjustment] with a well-typed [Adjustment] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun adjustment(adjustment: JsonField) = apply { - this.adjustment = adjustment - } + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - /** - * Alias for calling [adjustment] with - * `Adjustment.ofPercentageDiscount(percentageDiscount)`. - */ - fun adjustment(percentageDiscount: NewPercentageDiscount) = - adjustment(Adjustment.ofPercentageDiscount(percentageDiscount)) + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) - /** - * Alias for calling [adjustment] with the following: - * ```kotlin - * NewPercentageDiscount.builder() - * .adjustmentType(NewPercentageDiscount.AdjustmentType.PERCENTAGE_DISCOUNT) - * .percentageDiscount(percentageDiscount) - * .build() - * ``` - */ - fun percentageDiscountAdjustment(percentageDiscount: Double) = - adjustment( - NewPercentageDiscount.builder() - .adjustmentType(NewPercentageDiscount.AdjustmentType.PERCENTAGE_DISCOUNT) - .percentageDiscount(percentageDiscount) - .build() - ) + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } - /** Alias for calling [adjustment] with `Adjustment.ofUsageDiscount(usageDiscount)`. */ - fun adjustment(usageDiscount: NewUsageDiscount) = - adjustment(Adjustment.ofUsageDiscount(usageDiscount)) + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** - * Alias for calling [adjustment] with the following: - * ```kotlin - * NewUsageDiscount.builder() - * .adjustmentType(NewUsageDiscount.AdjustmentType.USAGE_DISCOUNT) - * .usageDiscount(usageDiscount) - * .build() - * ``` - */ - fun usageDiscountAdjustment(usageDiscount: Double) = - adjustment( - NewUsageDiscount.builder() - .adjustmentType(NewUsageDiscount.AdjustmentType.USAGE_DISCOUNT) - .usageDiscount(usageDiscount) - .build() - ) + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * Alias for calling [adjustment] with `Adjustment.ofAmountDiscount(amountDiscount)`. - */ - fun adjustment(amountDiscount: NewAmountDiscount) = - adjustment(Adjustment.ofAmountDiscount(amountDiscount)) + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - /** - * Alias for calling [adjustment] with the following: - * ```kotlin - * NewAmountDiscount.builder() - * .adjustmentType(NewAmountDiscount.AdjustmentType.AMOUNT_DISCOUNT) - * .amountDiscount(amountDiscount) - * .build() - * ``` - */ - fun amountDiscountAdjustment(amountDiscount: String) = - adjustment( - NewAmountDiscount.builder() - .adjustmentType(NewAmountDiscount.AdjustmentType.AMOUNT_DISCOUNT) - .amountDiscount(amountDiscount) - .build() - ) + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - /** Alias for calling [adjustment] with `Adjustment.ofMinimum(minimum)`. */ - fun adjustment(minimum: NewMinimum) = adjustment(Adjustment.ofMinimum(minimum)) + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - /** Alias for calling [adjustment] with `Adjustment.ofMaximum(maximum)`. */ - fun adjustment(maximum: NewMaximum) = adjustment(Adjustment.ofMaximum(maximum)) + /** + * Returns an immutable instance of [GroupedWithMinMaxThresholds]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .groupedWithMinMaxThresholdsConfig() + * .itemId() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedWithMinMaxThresholds = + GroupedWithMinMaxThresholds( + checkRequired("cadence", cadence), + checkRequired( + "groupedWithMinMaxThresholdsConfig", + groupedWithMinMaxThresholdsConfig, + ), + checkRequired("itemId", itemId), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } - /** - * Alias for calling [adjustment] with the following: - * ```kotlin - * NewMaximum.builder() - * .adjustmentType(NewMaximum.AdjustmentType.MAXIMUM) - * .maximumAmount(maximumAmount) - * .build() - * ``` - */ - fun maximumAdjustment(maximumAmount: String) = - adjustment( - NewMaximum.builder() - .adjustmentType(NewMaximum.AdjustmentType.MAXIMUM) - .maximumAmount(maximumAmount) - .build() - ) + private var validated: Boolean = false - /** The id of the adjustment on the plan to replace in the plan. */ - fun replacesAdjustmentId(replacesAdjustmentId: String) = - replacesAdjustmentId(JsonField.of(replacesAdjustmentId)) + fun validate(): GroupedWithMinMaxThresholds = apply { + if (validated) { + return@apply + } - /** - * Sets [Builder.replacesAdjustmentId] to an arbitrary JSON value. - * - * You should usually call [Builder.replacesAdjustmentId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun replacesAdjustmentId(replacesAdjustmentId: JsonField) = apply { - this.replacesAdjustmentId = replacesAdjustmentId - } + cadence().validate() + groupedWithMinMaxThresholdsConfig().validate() + itemId() + _modelType().let { + if (it != JsonValue.from("grouped_with_min_max_thresholds")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + metadata()?.validate() + referenceId() + validated = true + } - /** The phase to replace this adjustment from. */ - fun planPhaseOrder(planPhaseOrder: Long?) = - planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - /** - * Alias for [Builder.planPhaseOrder]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (groupedWithMinMaxThresholdsConfig.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + modelType.let { + if (it == JsonValue.from("grouped_with_min_max_thresholds")) 1 else 0 + } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) - /** - * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. - * - * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun planPhaseOrder(planPhaseOrder: JsonField) = apply { - this.planPhaseOrder = planPhaseOrder - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + companion object { - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + val ANNUAL = of("annual") - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + val SEMI_ANNUAL = of("semi_annual") - /** - * Returns an immutable instance of [ReplaceAdjustment]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```kotlin - * .adjustment() - * .replacesAdjustmentId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): ReplaceAdjustment = - ReplaceAdjustment( - checkRequired("adjustment", adjustment), - checkRequired("replacesAdjustmentId", replacesAdjustmentId), - planPhaseOrder, - additionalProperties.toMutableMap(), - ) - } + val MONTHLY = of("monthly") - private var validated: Boolean = false + val QUARTERLY = of("quarterly") - fun validate(): ReplaceAdjustment = apply { - if (validated) { - return@apply - } + val ONE_TIME = of("one_time") - adjustment().validate() - replacesAdjustmentId() - planPhaseOrder() - validated = true - } + val CUSTOM = of("custom") - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + fun of(value: String) = Cadence(JsonField.of(value)) + } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (adjustment.asKnown()?.validity() ?: 0) + - (if (replacesAdjustmentId.asKnown() == null) 0 else 1) + - (if (planPhaseOrder.asKnown() == null) 0 else 1) + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } - /** The definition of a new adjustment to create and add to the plan. */ - @JsonDeserialize(using = Adjustment.Deserializer::class) - @JsonSerialize(using = Adjustment.Serializer::class) - class Adjustment - private constructor( - private val percentageDiscount: NewPercentageDiscount? = null, - private val usageDiscount: NewUsageDiscount? = null, - private val amountDiscount: NewAmountDiscount? = null, - private val minimum: NewMinimum? = null, - private val maximum: NewMaximum? = null, - private val _json: JsonValue? = null, - ) { + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } - fun percentageDiscount(): NewPercentageDiscount? = percentageDiscount + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } - fun usageDiscount(): NewUsageDiscount? = usageDiscount + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } - fun amountDiscount(): NewAmountDiscount? = amountDiscount + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") - fun minimum(): NewMinimum? = minimum + private var validated: Boolean = false - fun maximum(): NewMaximum? = maximum + fun validate(): Cadence = apply { + if (validated) { + return@apply + } - fun isPercentageDiscount(): Boolean = percentageDiscount != null + known() + validated = true + } - fun isUsageDiscount(): Boolean = usageDiscount != null + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - fun isAmountDiscount(): Boolean = amountDiscount != null + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - fun isMinimum(): Boolean = minimum != null + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun isMaximum(): Boolean = maximum != null + return other is Cadence && value == other.value + } - fun asPercentageDiscount(): NewPercentageDiscount = - percentageDiscount.getOrThrow("percentageDiscount") + override fun hashCode() = value.hashCode() - fun asUsageDiscount(): NewUsageDiscount = usageDiscount.getOrThrow("usageDiscount") + override fun toString() = value.toString() + } - fun asAmountDiscount(): NewAmountDiscount = amountDiscount.getOrThrow("amountDiscount") + /** Configuration for grouped_with_min_max_thresholds pricing */ + class GroupedWithMinMaxThresholdsConfig + private constructor( + private val groupingKey: JsonField, + private val maximumCharge: JsonField, + private val minimumCharge: JsonField, + private val perUnitRate: JsonField, + private val additionalProperties: MutableMap, + ) { - fun asMinimum(): NewMinimum = minimum.getOrThrow("minimum") + @JsonCreator + private constructor( + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("maximum_charge") + @ExcludeMissing + maximumCharge: JsonField = JsonMissing.of(), + @JsonProperty("minimum_charge") + @ExcludeMissing + minimumCharge: JsonField = JsonMissing.of(), + @JsonProperty("per_unit_rate") + @ExcludeMissing + perUnitRate: JsonField = JsonMissing.of(), + ) : this(groupingKey, maximumCharge, minimumCharge, perUnitRate, mutableMapOf()) - fun asMaximum(): NewMaximum = maximum.getOrThrow("maximum") + /** + * The event property used to group before applying thresholds + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") - fun _json(): JsonValue? = _json + /** + * The maximum amount to charge each group + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun maximumCharge(): String = maximumCharge.getRequired("maximum_charge") - fun accept(visitor: Visitor): T = - when { - percentageDiscount != null -> - visitor.visitPercentageDiscount(percentageDiscount) - usageDiscount != null -> visitor.visitUsageDiscount(usageDiscount) - amountDiscount != null -> visitor.visitAmountDiscount(amountDiscount) - minimum != null -> visitor.visitMinimum(minimum) - maximum != null -> visitor.visitMaximum(maximum) - else -> visitor.unknown(_json) - } + /** + * The minimum amount to charge each group, regardless of usage + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun minimumCharge(): String = minimumCharge.getRequired("minimum_charge") - private var validated: Boolean = false - - fun validate(): Adjustment = apply { - if (validated) { - return@apply - } + /** + * The base price charged per group + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun perUnitRate(): String = perUnitRate.getRequired("per_unit_rate") - accept( - object : Visitor { - override fun visitPercentageDiscount( - percentageDiscount: NewPercentageDiscount - ) { - percentageDiscount.validate() - } + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey - override fun visitUsageDiscount(usageDiscount: NewUsageDiscount) { - usageDiscount.validate() - } + /** + * Returns the raw JSON value of [maximumCharge]. + * + * Unlike [maximumCharge], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("maximum_charge") + @ExcludeMissing + fun _maximumCharge(): JsonField = maximumCharge - override fun visitAmountDiscount(amountDiscount: NewAmountDiscount) { - amountDiscount.validate() - } + /** + * Returns the raw JSON value of [minimumCharge]. + * + * Unlike [minimumCharge], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("minimum_charge") + @ExcludeMissing + fun _minimumCharge(): JsonField = minimumCharge - override fun visitMinimum(minimum: NewMinimum) { - minimum.validate() - } + /** + * Returns the raw JSON value of [perUnitRate]. + * + * Unlike [perUnitRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("per_unit_rate") + @ExcludeMissing + fun _perUnitRate(): JsonField = perUnitRate - override fun visitMaximum(maximum: NewMaximum) { - maximum.validate() - } + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) } - ) - validated = true - } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitPercentageDiscount( - percentageDiscount: NewPercentageDiscount - ) = percentageDiscount.validity() + fun toBuilder() = Builder().from(this) - override fun visitUsageDiscount(usageDiscount: NewUsageDiscount) = - usageDiscount.validity() + companion object { - override fun visitAmountDiscount(amountDiscount: NewAmountDiscount) = - amountDiscount.validity() + /** + * Returns a mutable builder for constructing an instance of + * [GroupedWithMinMaxThresholdsConfig]. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .maximumCharge() + * .minimumCharge() + * .perUnitRate() + * ``` + */ + fun builder() = Builder() + } - override fun visitMinimum(minimum: NewMinimum) = minimum.validity() + /** A builder for [GroupedWithMinMaxThresholdsConfig]. */ + class Builder internal constructor() { - override fun visitMaximum(maximum: NewMaximum) = maximum.validity() + private var groupingKey: JsonField? = null + private var maximumCharge: JsonField? = null + private var minimumCharge: JsonField? = null + private var perUnitRate: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() - override fun unknown(json: JsonValue?) = 0 - } - ) + internal fun from( + groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + ) = apply { + groupingKey = groupedWithMinMaxThresholdsConfig.groupingKey + maximumCharge = groupedWithMinMaxThresholdsConfig.maximumCharge + minimumCharge = groupedWithMinMaxThresholdsConfig.minimumCharge + perUnitRate = groupedWithMinMaxThresholdsConfig.perUnitRate + additionalProperties = + groupedWithMinMaxThresholdsConfig.additionalProperties + .toMutableMap() + } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** The event property used to group before applying thresholds */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) - return other is Adjustment && - percentageDiscount == other.percentageDiscount && - usageDiscount == other.usageDiscount && - amountDiscount == other.amountDiscount && - minimum == other.minimum && - maximum == other.maximum - } + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } - override fun hashCode(): Int = - Objects.hash(percentageDiscount, usageDiscount, amountDiscount, minimum, maximum) + /** The maximum amount to charge each group */ + fun maximumCharge(maximumCharge: String) = + maximumCharge(JsonField.of(maximumCharge)) - override fun toString(): String = - when { - percentageDiscount != null -> - "Adjustment{percentageDiscount=$percentageDiscount}" - usageDiscount != null -> "Adjustment{usageDiscount=$usageDiscount}" - amountDiscount != null -> "Adjustment{amountDiscount=$amountDiscount}" - minimum != null -> "Adjustment{minimum=$minimum}" - maximum != null -> "Adjustment{maximum=$maximum}" - _json != null -> "Adjustment{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Adjustment") - } + /** + * Sets [Builder.maximumCharge] to an arbitrary JSON value. + * + * You should usually call [Builder.maximumCharge] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun maximumCharge(maximumCharge: JsonField) = apply { + this.maximumCharge = maximumCharge + } - companion object { + /** The minimum amount to charge each group, regardless of usage */ + fun minimumCharge(minimumCharge: String) = + minimumCharge(JsonField.of(minimumCharge)) - fun ofPercentageDiscount(percentageDiscount: NewPercentageDiscount) = - Adjustment(percentageDiscount = percentageDiscount) + /** + * Sets [Builder.minimumCharge] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumCharge] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun minimumCharge(minimumCharge: JsonField) = apply { + this.minimumCharge = minimumCharge + } - fun ofUsageDiscount(usageDiscount: NewUsageDiscount) = - Adjustment(usageDiscount = usageDiscount) + /** The base price charged per group */ + fun perUnitRate(perUnitRate: String) = + perUnitRate(JsonField.of(perUnitRate)) - fun ofAmountDiscount(amountDiscount: NewAmountDiscount) = - Adjustment(amountDiscount = amountDiscount) + /** + * Sets [Builder.perUnitRate] to an arbitrary JSON value. + * + * You should usually call [Builder.perUnitRate] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun perUnitRate(perUnitRate: JsonField) = apply { + this.perUnitRate = perUnitRate + } - fun ofMinimum(minimum: NewMinimum) = Adjustment(minimum = minimum) + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun ofMaximum(maximum: NewMaximum) = Adjustment(maximum = maximum) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * An interface that defines how to map each variant of [Adjustment] to a value of type - * [T]. - */ - interface Visitor { + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun visitPercentageDiscount(percentageDiscount: NewPercentageDiscount): T + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun visitUsageDiscount(usageDiscount: NewUsageDiscount): T + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - fun visitAmountDiscount(amountDiscount: NewAmountDiscount): T + /** + * Returns an immutable instance of [GroupedWithMinMaxThresholdsConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .maximumCharge() + * .minimumCharge() + * .perUnitRate() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedWithMinMaxThresholdsConfig = + GroupedWithMinMaxThresholdsConfig( + checkRequired("groupingKey", groupingKey), + checkRequired("maximumCharge", maximumCharge), + checkRequired("minimumCharge", minimumCharge), + checkRequired("perUnitRate", perUnitRate), + additionalProperties.toMutableMap(), + ) + } - fun visitMinimum(minimum: NewMinimum): T + private var validated: Boolean = false - fun visitMaximum(maximum: NewMaximum): T + fun validate(): GroupedWithMinMaxThresholdsConfig = apply { + if (validated) { + return@apply + } - /** - * Maps an unknown variant of [Adjustment] to a value of type [T]. - * - * An instance of [Adjustment] can contain an unknown variant if it was deserialized - * from data that doesn't match any known variant. For example, if the SDK is on an - * older version than the API, then the API may respond with new variants that the - * SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown Adjustment: $json") - } - } + groupingKey() + maximumCharge() + minimumCharge() + perUnitRate() + validated = true + } - internal class Deserializer : BaseDeserializer(Adjustment::class) { + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - override fun ObjectCodec.deserialize(node: JsonNode): Adjustment { - val json = JsonValue.fromJsonNode(node) - val adjustmentType = json.asObject()?.get("adjustment_type")?.asString() + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (groupingKey.asKnown() == null) 0 else 1) + + (if (maximumCharge.asKnown() == null) 0 else 1) + + (if (minimumCharge.asKnown() == null) 0 else 1) + + (if (perUnitRate.asKnown() == null) 0 else 1) - when (adjustmentType) { - "percentage_discount" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Adjustment(percentageDiscount = it, _json = json) } - ?: Adjustment(_json = json) - } - "usage_discount" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(usageDiscount = it, _json = json) - } ?: Adjustment(_json = json) - } - "amount_discount" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(amountDiscount = it, _json = json) - } ?: Adjustment(_json = json) - } - "minimum" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(minimum = it, _json = json) - } ?: Adjustment(_json = json) - } - "maximum" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(maximum = it, _json = json) - } ?: Adjustment(_json = json) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } + + return other is GroupedWithMinMaxThresholdsConfig && + groupingKey == other.groupingKey && + maximumCharge == other.maximumCharge && + minimumCharge == other.minimumCharge && + perUnitRate == other.perUnitRate && + additionalProperties == other.additionalProperties } - return Adjustment(_json = json) - } - } + private val hashCode: Int by lazy { + Objects.hash( + groupingKey, + maximumCharge, + minimumCharge, + perUnitRate, + additionalProperties, + ) + } - internal class Serializer : BaseSerializer(Adjustment::class) { + override fun hashCode(): Int = hashCode - override fun serialize( - value: Adjustment, - generator: JsonGenerator, - provider: SerializerProvider, + override fun toString() = + "GroupedWithMinMaxThresholdsConfig{groupingKey=$groupingKey, maximumCharge=$maximumCharge, minimumCharge=$minimumCharge, perUnitRate=$perUnitRate, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map ) { - when { - value.percentageDiscount != null -> - generator.writeObject(value.percentageDiscount) - value.usageDiscount != null -> generator.writeObject(value.usageDiscount) - value.amountDiscount != null -> generator.writeObject(value.amountDiscount) - value.minimum != null -> generator.writeObject(value.minimum) - value.maximum != null -> generator.writeObject(value.maximum) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Adjustment") + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } + + return other is GroupedWithMinMaxThresholds && + cadence == other.cadence && + groupedWithMinMaxThresholdsConfig == + other.groupedWithMinMaxThresholdsConfig && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + groupedWithMinMaxThresholdsConfig, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties, + ) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedWithMinMaxThresholds{cadence=$cadence, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } } @@ -5688,64 +6625,50 @@ private constructor( return true } - return other is ReplaceAdjustment && - adjustment == other.adjustment && - replacesAdjustmentId == other.replacesAdjustmentId && + return other is AddPrice && + allocationPrice == other.allocationPrice && planPhaseOrder == other.planPhaseOrder && + price == other.price && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(adjustment, replacesAdjustmentId, planPhaseOrder, additionalProperties) + Objects.hash(allocationPrice, planPhaseOrder, price, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "ReplaceAdjustment{adjustment=$adjustment, replacesAdjustmentId=$replacesAdjustmentId, planPhaseOrder=$planPhaseOrder, additionalProperties=$additionalProperties}" + "AddPrice{allocationPrice=$allocationPrice, planPhaseOrder=$planPhaseOrder, price=$price, additionalProperties=$additionalProperties}" } - class ReplacePrice + class RemoveAdjustment private constructor( - private val replacesPriceId: JsonField, - private val allocationPrice: JsonField, + private val adjustmentId: JsonField, private val planPhaseOrder: JsonField, - private val price: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("replaces_price_id") - @ExcludeMissing - replacesPriceId: JsonField = JsonMissing.of(), - @JsonProperty("allocation_price") + @JsonProperty("adjustment_id") @ExcludeMissing - allocationPrice: JsonField = JsonMissing.of(), + adjustmentId: JsonField = JsonMissing.of(), @JsonProperty("plan_phase_order") @ExcludeMissing planPhaseOrder: JsonField = JsonMissing.of(), - @JsonProperty("price") @ExcludeMissing price: JsonField = JsonMissing.of(), - ) : this(replacesPriceId, allocationPrice, planPhaseOrder, price, mutableMapOf()) + ) : this(adjustmentId, planPhaseOrder, mutableMapOf()) /** - * The id of the price on the plan to replace in the plan. + * The id of the adjustment to remove from on the plan. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ - fun replacesPriceId(): String = replacesPriceId.getRequired("replaces_price_id") - - /** - * The allocation price to add to the plan. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun allocationPrice(): NewAllocationPrice? = allocationPrice.getNullable("allocation_price") + fun adjustmentId(): String = adjustmentId.getRequired("adjustment_id") /** - * The phase to replace this price from. + * The phase to remove this adjustment from. * * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -5753,32 +6676,14 @@ private constructor( fun planPhaseOrder(): Long? = planPhaseOrder.getNullable("plan_phase_order") /** - * The price to add to the plan - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun price(): Price? = price.getNullable("price") - - /** - * Returns the raw JSON value of [replacesPriceId]. - * - * Unlike [replacesPriceId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("replaces_price_id") - @ExcludeMissing - fun _replacesPriceId(): JsonField = replacesPriceId - - /** - * Returns the raw JSON value of [allocationPrice]. + * Returns the raw JSON value of [adjustmentId]. * - * Unlike [allocationPrice], this method doesn't throw if the JSON field has an unexpected + * Unlike [adjustmentId], this method doesn't throw if the JSON field has an unexpected * type. */ - @JsonProperty("allocation_price") + @JsonProperty("adjustment_id") @ExcludeMissing - fun _allocationPrice(): JsonField = allocationPrice + fun _adjustmentId(): JsonField = adjustmentId /** * Returns the raw JSON value of [planPhaseOrder]. @@ -5790,13 +6695,6 @@ private constructor( @ExcludeMissing fun _planPhaseOrder(): JsonField = planPhaseOrder - /** - * Returns the raw JSON value of [price]. - * - * Unlike [price], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("price") @ExcludeMissing fun _price(): JsonField = price - @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -5812,64 +6710,44 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [ReplacePrice]. + * Returns a mutable builder for constructing an instance of [RemoveAdjustment]. * * The following fields are required: * ```kotlin - * .replacesPriceId() + * .adjustmentId() * ``` */ fun builder() = Builder() } - /** A builder for [ReplacePrice]. */ + /** A builder for [RemoveAdjustment]. */ class Builder internal constructor() { - private var replacesPriceId: JsonField? = null - private var allocationPrice: JsonField = JsonMissing.of() + private var adjustmentId: JsonField? = null private var planPhaseOrder: JsonField = JsonMissing.of() - private var price: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(replacePrice: ReplacePrice) = apply { - replacesPriceId = replacePrice.replacesPriceId - allocationPrice = replacePrice.allocationPrice - planPhaseOrder = replacePrice.planPhaseOrder - price = replacePrice.price - additionalProperties = replacePrice.additionalProperties.toMutableMap() + internal fun from(removeAdjustment: RemoveAdjustment) = apply { + adjustmentId = removeAdjustment.adjustmentId + planPhaseOrder = removeAdjustment.planPhaseOrder + additionalProperties = removeAdjustment.additionalProperties.toMutableMap() } - /** The id of the price on the plan to replace in the plan. */ - fun replacesPriceId(replacesPriceId: String) = - replacesPriceId(JsonField.of(replacesPriceId)) + /** The id of the adjustment to remove from on the plan. */ + fun adjustmentId(adjustmentId: String) = adjustmentId(JsonField.of(adjustmentId)) /** - * Sets [Builder.replacesPriceId] to an arbitrary JSON value. + * Sets [Builder.adjustmentId] to an arbitrary JSON value. * - * You should usually call [Builder.replacesPriceId] with a well-typed [String] value + * You should usually call [Builder.adjustmentId] with a well-typed [String] value * instead. This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun replacesPriceId(replacesPriceId: JsonField) = apply { - this.replacesPriceId = replacesPriceId - } - - /** The allocation price to add to the plan. */ - fun allocationPrice(allocationPrice: NewAllocationPrice?) = - allocationPrice(JsonField.ofNullable(allocationPrice)) - - /** - * Sets [Builder.allocationPrice] to an arbitrary JSON value. - * - * You should usually call [Builder.allocationPrice] with a well-typed - * [NewAllocationPrice] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun allocationPrice(allocationPrice: JsonField) = apply { - this.allocationPrice = allocationPrice + fun adjustmentId(adjustmentId: JsonField) = apply { + this.adjustmentId = adjustmentId } - /** The phase to replace this price from. */ + /** The phase to remove this adjustment from. */ fun planPhaseOrder(planPhaseOrder: Long?) = planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) @@ -5891,159 +6769,6 @@ private constructor( this.planPhaseOrder = planPhaseOrder } - /** The price to add to the plan */ - fun price(price: Price?) = price(JsonField.ofNullable(price)) - - /** - * Sets [Builder.price] to an arbitrary JSON value. - * - * You should usually call [Builder.price] with a well-typed [Price] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun price(price: JsonField) = apply { this.price = price } - - /** Alias for calling [price] with `Price.ofUnit(unit)`. */ - fun price(unit: NewPlanUnitPrice) = price(Price.ofUnit(unit)) - - /** Alias for calling [price] with `Price.ofPackage(package_)`. */ - fun price(package_: NewPlanPackagePrice) = price(Price.ofPackage(package_)) - - /** Alias for calling [price] with `Price.ofMatrix(matrix)`. */ - fun price(matrix: NewPlanMatrixPrice) = price(Price.ofMatrix(matrix)) - - /** Alias for calling [price] with `Price.ofTiered(tiered)`. */ - fun price(tiered: NewPlanTieredPrice) = price(Price.ofTiered(tiered)) - - /** Alias for calling [price] with `Price.ofBulk(bulk)`. */ - fun price(bulk: NewPlanBulkPrice) = price(Price.ofBulk(bulk)) - - /** - * Alias for calling [price] with `Price.ofThresholdTotalAmount(thresholdTotalAmount)`. - */ - fun price(thresholdTotalAmount: NewPlanThresholdTotalAmountPrice) = - price(Price.ofThresholdTotalAmount(thresholdTotalAmount)) - - /** Alias for calling [price] with `Price.ofTieredPackage(tieredPackage)`. */ - fun price(tieredPackage: NewPlanTieredPackagePrice) = - price(Price.ofTieredPackage(tieredPackage)) - - /** Alias for calling [price] with `Price.ofTieredWithMinimum(tieredWithMinimum)`. */ - fun price(tieredWithMinimum: NewPlanTieredWithMinimumPrice) = - price(Price.ofTieredWithMinimum(tieredWithMinimum)) - - /** Alias for calling [price] with `Price.ofUnitWithPercent(unitWithPercent)`. */ - fun price(unitWithPercent: NewPlanUnitWithPercentPrice) = - price(Price.ofUnitWithPercent(unitWithPercent)) - - /** - * Alias for calling [price] with - * `Price.ofPackageWithAllocation(packageWithAllocation)`. - */ - fun price(packageWithAllocation: NewPlanPackageWithAllocationPrice) = - price(Price.ofPackageWithAllocation(packageWithAllocation)) - - /** - * Alias for calling [price] with `Price.ofTieredWithProration(tieredWithProration)`. - */ - fun price(tieredWithProration: NewPlanTierWithProrationPrice) = - price(Price.ofTieredWithProration(tieredWithProration)) - - /** Alias for calling [price] with `Price.ofUnitWithProration(unitWithProration)`. */ - fun price(unitWithProration: NewPlanUnitWithProrationPrice) = - price(Price.ofUnitWithProration(unitWithProration)) - - /** Alias for calling [price] with `Price.ofGroupedAllocation(groupedAllocation)`. */ - fun price(groupedAllocation: NewPlanGroupedAllocationPrice) = - price(Price.ofGroupedAllocation(groupedAllocation)) - - /** - * Alias for calling [price] with - * `Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)`. - */ - fun price(groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice) = - price(Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)) - - /** - * Alias for calling [price] with - * `Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)`. - */ - fun price(groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice) = - price(Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)) - - /** - * Alias for calling [price] with - * `Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)`. - */ - fun price(groupedWithMinMaxThresholds: Price.GroupedWithMinMaxThresholds) = - price(Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)) - - /** - * Alias for calling [price] with - * `Price.ofMatrixWithDisplayName(matrixWithDisplayName)`. - */ - fun price(matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice) = - price(Price.ofMatrixWithDisplayName(matrixWithDisplayName)) - - /** Alias for calling [price] with `Price.ofBulkWithProration(bulkWithProration)`. */ - fun price(bulkWithProration: NewPlanBulkWithProrationPrice) = - price(Price.ofBulkWithProration(bulkWithProration)) - - /** - * Alias for calling [price] with `Price.ofGroupedTieredPackage(groupedTieredPackage)`. - */ - fun price(groupedTieredPackage: NewPlanGroupedTieredPackagePrice) = - price(Price.ofGroupedTieredPackage(groupedTieredPackage)) - - /** - * Alias for calling [price] with - * `Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)`. - */ - fun price(maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice) = - price(Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)) - - /** - * Alias for calling [price] with - * `Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)`. - */ - fun price(scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice) = - price(Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)) - - /** - * Alias for calling [price] with - * `Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)`. - */ - fun price( - scalableMatrixWithTieredPricing: NewPlanScalableMatrixWithTieredPricingPrice - ) = price(Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)) - - /** - * Alias for calling [price] with - * `Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)`. - */ - fun price(cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice) = - price(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) - - /** - * Alias for calling [price] with - * `Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)`. - */ - fun price(tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice) = - price(Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)) - - /** - * Alias for calling [price] with `Price.ofMatrixWithAllocation(matrixWithAllocation)`. - */ - fun price(matrixWithAllocation: NewPlanMatrixWithAllocationPrice) = - price(Price.ofMatrixWithAllocation(matrixWithAllocation)) - - /** Alias for calling [price] with `Price.ofGroupedTiered(groupedTiered)`. */ - fun price(groupedTiered: NewPlanGroupedTieredPrice) = - price(Price.ofGroupedTiered(groupedTiered)) - - /** Alias for calling [price] with `Price.ofMinimum(minimum)`. */ - fun price(minimum: NewPlanMinimumCompositePrice) = price(Price.ofMinimum(minimum)) - fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -6064,38 +6789,34 @@ private constructor( } /** - * Returns an immutable instance of [ReplacePrice]. + * Returns an immutable instance of [RemoveAdjustment]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```kotlin - * .replacesPriceId() + * .adjustmentId() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): ReplacePrice = - ReplacePrice( - checkRequired("replacesPriceId", replacesPriceId), - allocationPrice, + fun build(): RemoveAdjustment = + RemoveAdjustment( + checkRequired("adjustmentId", adjustmentId), planPhaseOrder, - price, additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): ReplacePrice = apply { + fun validate(): RemoveAdjustment = apply { if (validated) { return@apply } - replacesPriceId() - allocationPrice()?.validate() + adjustmentId() planPhaseOrder() - price()?.validate() validated = true } @@ -6114,1131 +6835,4151 @@ private constructor( * Used for best match union deserialization. */ internal fun validity(): Int = - (if (replacesPriceId.asKnown() == null) 0 else 1) + - (allocationPrice.asKnown()?.validity() ?: 0) + - (if (planPhaseOrder.asKnown() == null) 0 else 1) + - (price.asKnown()?.validity() ?: 0) + (if (adjustmentId.asKnown() == null) 0 else 1) + + (if (planPhaseOrder.asKnown() == null) 0 else 1) - /** The price to add to the plan */ - @JsonDeserialize(using = Price.Deserializer::class) - @JsonSerialize(using = Price.Serializer::class) - class Price + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RemoveAdjustment && + adjustmentId == other.adjustmentId && + planPhaseOrder == other.planPhaseOrder && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(adjustmentId, planPhaseOrder, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "RemoveAdjustment{adjustmentId=$adjustmentId, planPhaseOrder=$planPhaseOrder, additionalProperties=$additionalProperties}" + } + + class RemovePrice + private constructor( + private val priceId: JsonField, + private val planPhaseOrder: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator private constructor( - private val unit: NewPlanUnitPrice? = null, - private val package_: NewPlanPackagePrice? = null, - private val matrix: NewPlanMatrixPrice? = null, - private val tiered: NewPlanTieredPrice? = null, - private val bulk: NewPlanBulkPrice? = null, - private val thresholdTotalAmount: NewPlanThresholdTotalAmountPrice? = null, - private val tieredPackage: NewPlanTieredPackagePrice? = null, - private val tieredWithMinimum: NewPlanTieredWithMinimumPrice? = null, - private val unitWithPercent: NewPlanUnitWithPercentPrice? = null, - private val packageWithAllocation: NewPlanPackageWithAllocationPrice? = null, - private val tieredWithProration: NewPlanTierWithProrationPrice? = null, - private val unitWithProration: NewPlanUnitWithProrationPrice? = null, - private val groupedAllocation: NewPlanGroupedAllocationPrice? = null, - private val groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice? = null, - private val groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice? = null, - private val groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds? = null, - private val matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice? = null, - private val bulkWithProration: NewPlanBulkWithProrationPrice? = null, - private val groupedTieredPackage: NewPlanGroupedTieredPackagePrice? = null, - private val maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice? = null, - private val scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice? = - null, - private val scalableMatrixWithTieredPricing: - NewPlanScalableMatrixWithTieredPricingPrice? = - null, - private val cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice? = null, - private val tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice? = null, - private val matrixWithAllocation: NewPlanMatrixWithAllocationPrice? = null, - private val groupedTiered: NewPlanGroupedTieredPrice? = null, - private val minimum: NewPlanMinimumCompositePrice? = null, - private val _json: JsonValue? = null, - ) { + @JsonProperty("price_id") @ExcludeMissing priceId: JsonField = JsonMissing.of(), + @JsonProperty("plan_phase_order") + @ExcludeMissing + planPhaseOrder: JsonField = JsonMissing.of(), + ) : this(priceId, planPhaseOrder, mutableMapOf()) - fun unit(): NewPlanUnitPrice? = unit + /** + * The id of the price to remove from the plan. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun priceId(): String = priceId.getRequired("price_id") - fun package_(): NewPlanPackagePrice? = package_ + /** + * The phase to remove this price from. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun planPhaseOrder(): Long? = planPhaseOrder.getNullable("plan_phase_order") - fun matrix(): NewPlanMatrixPrice? = matrix + /** + * Returns the raw JSON value of [priceId]. + * + * Unlike [priceId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId - fun tiered(): NewPlanTieredPrice? = tiered + /** + * Returns the raw JSON value of [planPhaseOrder]. + * + * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder - fun bulk(): NewPlanBulkPrice? = bulk + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - fun thresholdTotalAmount(): NewPlanThresholdTotalAmountPrice? = thresholdTotalAmount + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - fun tieredPackage(): NewPlanTieredPackagePrice? = tieredPackage + fun toBuilder() = Builder().from(this) - fun tieredWithMinimum(): NewPlanTieredWithMinimumPrice? = tieredWithMinimum + companion object { - fun unitWithPercent(): NewPlanUnitWithPercentPrice? = unitWithPercent + /** + * Returns a mutable builder for constructing an instance of [RemovePrice]. + * + * The following fields are required: + * ```kotlin + * .priceId() + * ``` + */ + fun builder() = Builder() + } - fun packageWithAllocation(): NewPlanPackageWithAllocationPrice? = packageWithAllocation + /** A builder for [RemovePrice]. */ + class Builder internal constructor() { - fun tieredWithProration(): NewPlanTierWithProrationPrice? = tieredWithProration + private var priceId: JsonField? = null + private var planPhaseOrder: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - fun unitWithProration(): NewPlanUnitWithProrationPrice? = unitWithProration + internal fun from(removePrice: RemovePrice) = apply { + priceId = removePrice.priceId + planPhaseOrder = removePrice.planPhaseOrder + additionalProperties = removePrice.additionalProperties.toMutableMap() + } - fun groupedAllocation(): NewPlanGroupedAllocationPrice? = groupedAllocation + /** The id of the price to remove from the plan. */ + fun priceId(priceId: String) = priceId(JsonField.of(priceId)) - fun groupedWithProratedMinimum(): NewPlanGroupedWithProratedMinimumPrice? = - groupedWithProratedMinimum + /** + * Sets [Builder.priceId] to an arbitrary JSON value. + * + * You should usually call [Builder.priceId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun priceId(priceId: JsonField) = apply { this.priceId = priceId } - fun groupedWithMeteredMinimum(): NewPlanGroupedWithMeteredMinimumPrice? = - groupedWithMeteredMinimum + /** The phase to remove this price from. */ + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) - fun groupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds? = - groupedWithMinMaxThresholds + /** + * Alias for [Builder.planPhaseOrder]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) - fun matrixWithDisplayName(): NewPlanMatrixWithDisplayNamePrice? = matrixWithDisplayName + /** + * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. + * + * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun planPhaseOrder(planPhaseOrder: JsonField) = apply { + this.planPhaseOrder = planPhaseOrder + } - fun bulkWithProration(): NewPlanBulkWithProrationPrice? = bulkWithProration + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun groupedTieredPackage(): NewPlanGroupedTieredPackagePrice? = groupedTieredPackage + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun maxGroupTieredPackage(): NewPlanMaxGroupTieredPackagePrice? = maxGroupTieredPackage + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun scalableMatrixWithUnitPricing(): NewPlanScalableMatrixWithUnitPricingPrice? = - scalableMatrixWithUnitPricing + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - fun scalableMatrixWithTieredPricing(): NewPlanScalableMatrixWithTieredPricingPrice? = - scalableMatrixWithTieredPricing + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - fun cumulativeGroupedBulk(): NewPlanCumulativeGroupedBulkPrice? = cumulativeGroupedBulk + /** + * Returns an immutable instance of [RemovePrice]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .priceId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): RemovePrice = + RemovePrice( + checkRequired("priceId", priceId), + planPhaseOrder, + additionalProperties.toMutableMap(), + ) + } - fun tieredPackageWithMinimum(): NewPlanTieredPackageWithMinimumPrice? = - tieredPackageWithMinimum + private var validated: Boolean = false - fun matrixWithAllocation(): NewPlanMatrixWithAllocationPrice? = matrixWithAllocation + fun validate(): RemovePrice = apply { + if (validated) { + return@apply + } - fun groupedTiered(): NewPlanGroupedTieredPrice? = groupedTiered + priceId() + planPhaseOrder() + validated = true + } - fun minimum(): NewPlanMinimumCompositePrice? = minimum + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - fun isUnit(): Boolean = unit != null + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (priceId.asKnown() == null) 0 else 1) + + (if (planPhaseOrder.asKnown() == null) 0 else 1) - fun isPackage(): Boolean = package_ != null + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun isMatrix(): Boolean = matrix != null + return other is RemovePrice && + priceId == other.priceId && + planPhaseOrder == other.planPhaseOrder && + additionalProperties == other.additionalProperties + } - fun isTiered(): Boolean = tiered != null + private val hashCode: Int by lazy { + Objects.hash(priceId, planPhaseOrder, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "RemovePrice{priceId=$priceId, planPhaseOrder=$planPhaseOrder, additionalProperties=$additionalProperties}" + } + + class ReplaceAdjustment + private constructor( + private val adjustment: JsonField, + private val replacesAdjustmentId: JsonField, + private val planPhaseOrder: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("adjustment") + @ExcludeMissing + adjustment: JsonField = JsonMissing.of(), + @JsonProperty("replaces_adjustment_id") + @ExcludeMissing + replacesAdjustmentId: JsonField = JsonMissing.of(), + @JsonProperty("plan_phase_order") + @ExcludeMissing + planPhaseOrder: JsonField = JsonMissing.of(), + ) : this(adjustment, replacesAdjustmentId, planPhaseOrder, mutableMapOf()) + + /** + * The definition of a new adjustment to create and add to the plan. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun adjustment(): Adjustment = adjustment.getRequired("adjustment") + + /** + * The id of the adjustment on the plan to replace in the plan. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun replacesAdjustmentId(): String = + replacesAdjustmentId.getRequired("replaces_adjustment_id") + + /** + * The phase to replace this adjustment from. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun planPhaseOrder(): Long? = planPhaseOrder.getNullable("plan_phase_order") + + /** + * Returns the raw JSON value of [adjustment]. + * + * Unlike [adjustment], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("adjustment") + @ExcludeMissing + fun _adjustment(): JsonField = adjustment + + /** + * Returns the raw JSON value of [replacesAdjustmentId]. + * + * Unlike [replacesAdjustmentId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("replaces_adjustment_id") + @ExcludeMissing + fun _replacesAdjustmentId(): JsonField = replacesAdjustmentId + + /** + * Returns the raw JSON value of [planPhaseOrder]. + * + * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ReplaceAdjustment]. + * + * The following fields are required: + * ```kotlin + * .adjustment() + * .replacesAdjustmentId() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [ReplaceAdjustment]. */ + class Builder internal constructor() { + + private var adjustment: JsonField? = null + private var replacesAdjustmentId: JsonField? = null + private var planPhaseOrder: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(replaceAdjustment: ReplaceAdjustment) = apply { + adjustment = replaceAdjustment.adjustment + replacesAdjustmentId = replaceAdjustment.replacesAdjustmentId + planPhaseOrder = replaceAdjustment.planPhaseOrder + additionalProperties = replaceAdjustment.additionalProperties.toMutableMap() + } + + /** The definition of a new adjustment to create and add to the plan. */ + fun adjustment(adjustment: Adjustment) = adjustment(JsonField.of(adjustment)) + + /** + * Sets [Builder.adjustment] to an arbitrary JSON value. + * + * You should usually call [Builder.adjustment] with a well-typed [Adjustment] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun adjustment(adjustment: JsonField) = apply { + this.adjustment = adjustment + } + + /** + * Alias for calling [adjustment] with + * `Adjustment.ofPercentageDiscount(percentageDiscount)`. + */ + fun adjustment(percentageDiscount: NewPercentageDiscount) = + adjustment(Adjustment.ofPercentageDiscount(percentageDiscount)) + + /** + * Alias for calling [adjustment] with the following: + * ```kotlin + * NewPercentageDiscount.builder() + * .adjustmentType(NewPercentageDiscount.AdjustmentType.PERCENTAGE_DISCOUNT) + * .percentageDiscount(percentageDiscount) + * .build() + * ``` + */ + fun percentageDiscountAdjustment(percentageDiscount: Double) = + adjustment( + NewPercentageDiscount.builder() + .adjustmentType(NewPercentageDiscount.AdjustmentType.PERCENTAGE_DISCOUNT) + .percentageDiscount(percentageDiscount) + .build() + ) + + /** Alias for calling [adjustment] with `Adjustment.ofUsageDiscount(usageDiscount)`. */ + fun adjustment(usageDiscount: NewUsageDiscount) = + adjustment(Adjustment.ofUsageDiscount(usageDiscount)) + + /** + * Alias for calling [adjustment] with the following: + * ```kotlin + * NewUsageDiscount.builder() + * .adjustmentType(NewUsageDiscount.AdjustmentType.USAGE_DISCOUNT) + * .usageDiscount(usageDiscount) + * .build() + * ``` + */ + fun usageDiscountAdjustment(usageDiscount: Double) = + adjustment( + NewUsageDiscount.builder() + .adjustmentType(NewUsageDiscount.AdjustmentType.USAGE_DISCOUNT) + .usageDiscount(usageDiscount) + .build() + ) + + /** + * Alias for calling [adjustment] with `Adjustment.ofAmountDiscount(amountDiscount)`. + */ + fun adjustment(amountDiscount: NewAmountDiscount) = + adjustment(Adjustment.ofAmountDiscount(amountDiscount)) + + /** + * Alias for calling [adjustment] with the following: + * ```kotlin + * NewAmountDiscount.builder() + * .adjustmentType(NewAmountDiscount.AdjustmentType.AMOUNT_DISCOUNT) + * .amountDiscount(amountDiscount) + * .build() + * ``` + */ + fun amountDiscountAdjustment(amountDiscount: String) = + adjustment( + NewAmountDiscount.builder() + .adjustmentType(NewAmountDiscount.AdjustmentType.AMOUNT_DISCOUNT) + .amountDiscount(amountDiscount) + .build() + ) + + /** Alias for calling [adjustment] with `Adjustment.ofMinimum(minimum)`. */ + fun adjustment(minimum: NewMinimum) = adjustment(Adjustment.ofMinimum(minimum)) + + /** Alias for calling [adjustment] with `Adjustment.ofMaximum(maximum)`. */ + fun adjustment(maximum: NewMaximum) = adjustment(Adjustment.ofMaximum(maximum)) + + /** + * Alias for calling [adjustment] with the following: + * ```kotlin + * NewMaximum.builder() + * .adjustmentType(NewMaximum.AdjustmentType.MAXIMUM) + * .maximumAmount(maximumAmount) + * .build() + * ``` + */ + fun maximumAdjustment(maximumAmount: String) = + adjustment( + NewMaximum.builder() + .adjustmentType(NewMaximum.AdjustmentType.MAXIMUM) + .maximumAmount(maximumAmount) + .build() + ) + + /** The id of the adjustment on the plan to replace in the plan. */ + fun replacesAdjustmentId(replacesAdjustmentId: String) = + replacesAdjustmentId(JsonField.of(replacesAdjustmentId)) + + /** + * Sets [Builder.replacesAdjustmentId] to an arbitrary JSON value. + * + * You should usually call [Builder.replacesAdjustmentId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun replacesAdjustmentId(replacesAdjustmentId: JsonField) = apply { + this.replacesAdjustmentId = replacesAdjustmentId + } + + /** The phase to replace this adjustment from. */ + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + + /** + * Alias for [Builder.planPhaseOrder]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + + /** + * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. + * + * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun planPhaseOrder(planPhaseOrder: JsonField) = apply { + this.planPhaseOrder = planPhaseOrder + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ReplaceAdjustment]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .adjustment() + * .replacesAdjustmentId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ReplaceAdjustment = + ReplaceAdjustment( + checkRequired("adjustment", adjustment), + checkRequired("replacesAdjustmentId", replacesAdjustmentId), + planPhaseOrder, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ReplaceAdjustment = apply { + if (validated) { + return@apply + } + + adjustment().validate() + replacesAdjustmentId() + planPhaseOrder() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (adjustment.asKnown()?.validity() ?: 0) + + (if (replacesAdjustmentId.asKnown() == null) 0 else 1) + + (if (planPhaseOrder.asKnown() == null) 0 else 1) + + /** The definition of a new adjustment to create and add to the plan. */ + @JsonDeserialize(using = Adjustment.Deserializer::class) + @JsonSerialize(using = Adjustment.Serializer::class) + class Adjustment + private constructor( + private val percentageDiscount: NewPercentageDiscount? = null, + private val usageDiscount: NewUsageDiscount? = null, + private val amountDiscount: NewAmountDiscount? = null, + private val minimum: NewMinimum? = null, + private val maximum: NewMaximum? = null, + private val _json: JsonValue? = null, + ) { + + fun percentageDiscount(): NewPercentageDiscount? = percentageDiscount + + fun usageDiscount(): NewUsageDiscount? = usageDiscount + + fun amountDiscount(): NewAmountDiscount? = amountDiscount + + fun minimum(): NewMinimum? = minimum + + fun maximum(): NewMaximum? = maximum + + fun isPercentageDiscount(): Boolean = percentageDiscount != null + + fun isUsageDiscount(): Boolean = usageDiscount != null + + fun isAmountDiscount(): Boolean = amountDiscount != null + + fun isMinimum(): Boolean = minimum != null + + fun isMaximum(): Boolean = maximum != null + + fun asPercentageDiscount(): NewPercentageDiscount = + percentageDiscount.getOrThrow("percentageDiscount") + + fun asUsageDiscount(): NewUsageDiscount = usageDiscount.getOrThrow("usageDiscount") + + fun asAmountDiscount(): NewAmountDiscount = amountDiscount.getOrThrow("amountDiscount") + + fun asMinimum(): NewMinimum = minimum.getOrThrow("minimum") + + fun asMaximum(): NewMaximum = maximum.getOrThrow("maximum") + + fun _json(): JsonValue? = _json + + fun accept(visitor: Visitor): T = + when { + percentageDiscount != null -> + visitor.visitPercentageDiscount(percentageDiscount) + usageDiscount != null -> visitor.visitUsageDiscount(usageDiscount) + amountDiscount != null -> visitor.visitAmountDiscount(amountDiscount) + minimum != null -> visitor.visitMinimum(minimum) + maximum != null -> visitor.visitMaximum(maximum) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Adjustment = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitPercentageDiscount( + percentageDiscount: NewPercentageDiscount + ) { + percentageDiscount.validate() + } + + override fun visitUsageDiscount(usageDiscount: NewUsageDiscount) { + usageDiscount.validate() + } + + override fun visitAmountDiscount(amountDiscount: NewAmountDiscount) { + amountDiscount.validate() + } + + override fun visitMinimum(minimum: NewMinimum) { + minimum.validate() + } + + override fun visitMaximum(maximum: NewMaximum) { + maximum.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitPercentageDiscount( + percentageDiscount: NewPercentageDiscount + ) = percentageDiscount.validity() + + override fun visitUsageDiscount(usageDiscount: NewUsageDiscount) = + usageDiscount.validity() + + override fun visitAmountDiscount(amountDiscount: NewAmountDiscount) = + amountDiscount.validity() + + override fun visitMinimum(minimum: NewMinimum) = minimum.validity() + + override fun visitMaximum(maximum: NewMaximum) = maximum.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Adjustment && + percentageDiscount == other.percentageDiscount && + usageDiscount == other.usageDiscount && + amountDiscount == other.amountDiscount && + minimum == other.minimum && + maximum == other.maximum + } + + override fun hashCode(): Int = + Objects.hash(percentageDiscount, usageDiscount, amountDiscount, minimum, maximum) + + override fun toString(): String = + when { + percentageDiscount != null -> + "Adjustment{percentageDiscount=$percentageDiscount}" + usageDiscount != null -> "Adjustment{usageDiscount=$usageDiscount}" + amountDiscount != null -> "Adjustment{amountDiscount=$amountDiscount}" + minimum != null -> "Adjustment{minimum=$minimum}" + maximum != null -> "Adjustment{maximum=$maximum}" + _json != null -> "Adjustment{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Adjustment") + } + + companion object { + + fun ofPercentageDiscount(percentageDiscount: NewPercentageDiscount) = + Adjustment(percentageDiscount = percentageDiscount) + + fun ofUsageDiscount(usageDiscount: NewUsageDiscount) = + Adjustment(usageDiscount = usageDiscount) + + fun ofAmountDiscount(amountDiscount: NewAmountDiscount) = + Adjustment(amountDiscount = amountDiscount) + + fun ofMinimum(minimum: NewMinimum) = Adjustment(minimum = minimum) + + fun ofMaximum(maximum: NewMaximum) = Adjustment(maximum = maximum) + } + + /** + * An interface that defines how to map each variant of [Adjustment] to a value of type + * [T]. + */ + interface Visitor { + + fun visitPercentageDiscount(percentageDiscount: NewPercentageDiscount): T + + fun visitUsageDiscount(usageDiscount: NewUsageDiscount): T + + fun visitAmountDiscount(amountDiscount: NewAmountDiscount): T + + fun visitMinimum(minimum: NewMinimum): T + + fun visitMaximum(maximum: NewMaximum): T + + /** + * Maps an unknown variant of [Adjustment] to a value of type [T]. + * + * An instance of [Adjustment] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the + * SDK is unaware of. + * + * @throws OrbInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw OrbInvalidDataException("Unknown Adjustment: $json") + } + } + + internal class Deserializer : BaseDeserializer(Adjustment::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Adjustment { + val json = JsonValue.fromJsonNode(node) + val adjustmentType = json.asObject()?.get("adjustment_type")?.asString() + + when (adjustmentType) { + "percentage_discount" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Adjustment(percentageDiscount = it, _json = json) } + ?: Adjustment(_json = json) + } + "usage_discount" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(usageDiscount = it, _json = json) + } ?: Adjustment(_json = json) + } + "amount_discount" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(amountDiscount = it, _json = json) + } ?: Adjustment(_json = json) + } + "minimum" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(minimum = it, _json = json) + } ?: Adjustment(_json = json) + } + "maximum" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(maximum = it, _json = json) + } ?: Adjustment(_json = json) + } + } + + return Adjustment(_json = json) + } + } + + internal class Serializer : BaseSerializer(Adjustment::class) { + + override fun serialize( + value: Adjustment, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.percentageDiscount != null -> + generator.writeObject(value.percentageDiscount) + value.usageDiscount != null -> generator.writeObject(value.usageDiscount) + value.amountDiscount != null -> generator.writeObject(value.amountDiscount) + value.minimum != null -> generator.writeObject(value.minimum) + value.maximum != null -> generator.writeObject(value.maximum) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Adjustment") + } + } + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ReplaceAdjustment && + adjustment == other.adjustment && + replacesAdjustmentId == other.replacesAdjustmentId && + planPhaseOrder == other.planPhaseOrder && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(adjustment, replacesAdjustmentId, planPhaseOrder, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ReplaceAdjustment{adjustment=$adjustment, replacesAdjustmentId=$replacesAdjustmentId, planPhaseOrder=$planPhaseOrder, additionalProperties=$additionalProperties}" + } + + class ReplacePrice + private constructor( + private val replacesPriceId: JsonField, + private val allocationPrice: JsonField, + private val planPhaseOrder: JsonField, + private val price: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("replaces_price_id") + @ExcludeMissing + replacesPriceId: JsonField = JsonMissing.of(), + @JsonProperty("allocation_price") + @ExcludeMissing + allocationPrice: JsonField = JsonMissing.of(), + @JsonProperty("plan_phase_order") + @ExcludeMissing + planPhaseOrder: JsonField = JsonMissing.of(), + @JsonProperty("price") @ExcludeMissing price: JsonField = JsonMissing.of(), + ) : this(replacesPriceId, allocationPrice, planPhaseOrder, price, mutableMapOf()) + + /** + * The id of the price on the plan to replace in the plan. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun replacesPriceId(): String = replacesPriceId.getRequired("replaces_price_id") + + /** + * The allocation price to add to the plan. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun allocationPrice(): NewAllocationPrice? = allocationPrice.getNullable("allocation_price") + + /** + * The phase to replace this price from. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun planPhaseOrder(): Long? = planPhaseOrder.getNullable("plan_phase_order") + + /** + * New plan price request body params. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun price(): Price? = price.getNullable("price") + + /** + * Returns the raw JSON value of [replacesPriceId]. + * + * Unlike [replacesPriceId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("replaces_price_id") + @ExcludeMissing + fun _replacesPriceId(): JsonField = replacesPriceId + + /** + * Returns the raw JSON value of [allocationPrice]. + * + * Unlike [allocationPrice], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("allocation_price") + @ExcludeMissing + fun _allocationPrice(): JsonField = allocationPrice + + /** + * Returns the raw JSON value of [planPhaseOrder]. + * + * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder + + /** + * Returns the raw JSON value of [price]. + * + * Unlike [price], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("price") @ExcludeMissing fun _price(): JsonField = price + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ReplacePrice]. + * + * The following fields are required: + * ```kotlin + * .replacesPriceId() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [ReplacePrice]. */ + class Builder internal constructor() { + + private var replacesPriceId: JsonField? = null + private var allocationPrice: JsonField = JsonMissing.of() + private var planPhaseOrder: JsonField = JsonMissing.of() + private var price: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(replacePrice: ReplacePrice) = apply { + replacesPriceId = replacePrice.replacesPriceId + allocationPrice = replacePrice.allocationPrice + planPhaseOrder = replacePrice.planPhaseOrder + price = replacePrice.price + additionalProperties = replacePrice.additionalProperties.toMutableMap() + } + + /** The id of the price on the plan to replace in the plan. */ + fun replacesPriceId(replacesPriceId: String) = + replacesPriceId(JsonField.of(replacesPriceId)) + + /** + * Sets [Builder.replacesPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.replacesPriceId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun replacesPriceId(replacesPriceId: JsonField) = apply { + this.replacesPriceId = replacesPriceId + } + + /** The allocation price to add to the plan. */ + fun allocationPrice(allocationPrice: NewAllocationPrice?) = + allocationPrice(JsonField.ofNullable(allocationPrice)) + + /** + * Sets [Builder.allocationPrice] to an arbitrary JSON value. + * + * You should usually call [Builder.allocationPrice] with a well-typed + * [NewAllocationPrice] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun allocationPrice(allocationPrice: JsonField) = apply { + this.allocationPrice = allocationPrice + } + + /** The phase to replace this price from. */ + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + + /** + * Alias for [Builder.planPhaseOrder]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + + /** + * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. + * + * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun planPhaseOrder(planPhaseOrder: JsonField) = apply { + this.planPhaseOrder = planPhaseOrder + } + + /** New plan price request body params. */ + fun price(price: Price?) = price(JsonField.ofNullable(price)) + + /** + * Sets [Builder.price] to an arbitrary JSON value. + * + * You should usually call [Builder.price] with a well-typed [Price] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun price(price: JsonField) = apply { this.price = price } + + /** Alias for calling [price] with `Price.ofUnit(unit)`. */ + fun price(unit: NewPlanUnitPrice) = price(Price.ofUnit(unit)) + + /** Alias for calling [price] with `Price.ofTiered(tiered)`. */ + fun price(tiered: NewPlanTieredPrice) = price(Price.ofTiered(tiered)) + + /** Alias for calling [price] with `Price.ofBulk(bulk)`. */ + fun price(bulk: NewPlanBulkPrice) = price(Price.ofBulk(bulk)) + + /** Alias for calling [price] with `Price.ofPackage(package_)`. */ + fun price(package_: NewPlanPackagePrice) = price(Price.ofPackage(package_)) + + /** Alias for calling [price] with `Price.ofMatrix(matrix)`. */ + fun price(matrix: NewPlanMatrixPrice) = price(Price.ofMatrix(matrix)) + + /** + * Alias for calling [price] with `Price.ofThresholdTotalAmount(thresholdTotalAmount)`. + */ + fun price(thresholdTotalAmount: NewPlanThresholdTotalAmountPrice) = + price(Price.ofThresholdTotalAmount(thresholdTotalAmount)) + + /** Alias for calling [price] with `Price.ofTieredPackage(tieredPackage)`. */ + fun price(tieredPackage: NewPlanTieredPackagePrice) = + price(Price.ofTieredPackage(tieredPackage)) + + /** Alias for calling [price] with `Price.ofTieredWithMinimum(tieredWithMinimum)`. */ + fun price(tieredWithMinimum: NewPlanTieredWithMinimumPrice) = + price(Price.ofTieredWithMinimum(tieredWithMinimum)) + + /** Alias for calling [price] with `Price.ofGroupedTiered(groupedTiered)`. */ + fun price(groupedTiered: NewPlanGroupedTieredPrice) = + price(Price.ofGroupedTiered(groupedTiered)) + + /** + * Alias for calling [price] with + * `Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)`. + */ + fun price(tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice) = + price(Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)) + + /** + * Alias for calling [price] with + * `Price.ofPackageWithAllocation(packageWithAllocation)`. + */ + fun price(packageWithAllocation: NewPlanPackageWithAllocationPrice) = + price(Price.ofPackageWithAllocation(packageWithAllocation)) + + /** Alias for calling [price] with `Price.ofUnitWithPercent(unitWithPercent)`. */ + fun price(unitWithPercent: NewPlanUnitWithPercentPrice) = + price(Price.ofUnitWithPercent(unitWithPercent)) + + /** + * Alias for calling [price] with `Price.ofMatrixWithAllocation(matrixWithAllocation)`. + */ + fun price(matrixWithAllocation: NewPlanMatrixWithAllocationPrice) = + price(Price.ofMatrixWithAllocation(matrixWithAllocation)) + + /** + * Alias for calling [price] with `Price.ofTieredWithProration(tieredWithProration)`. + */ + fun price(tieredWithProration: Price.TieredWithProration) = + price(Price.ofTieredWithProration(tieredWithProration)) + + /** Alias for calling [price] with `Price.ofUnitWithProration(unitWithProration)`. */ + fun price(unitWithProration: NewPlanUnitWithProrationPrice) = + price(Price.ofUnitWithProration(unitWithProration)) + + /** Alias for calling [price] with `Price.ofGroupedAllocation(groupedAllocation)`. */ + fun price(groupedAllocation: NewPlanGroupedAllocationPrice) = + price(Price.ofGroupedAllocation(groupedAllocation)) + + /** Alias for calling [price] with `Price.ofBulkWithProration(bulkWithProration)`. */ + fun price(bulkWithProration: NewPlanBulkWithProrationPrice) = + price(Price.ofBulkWithProration(bulkWithProration)) + + /** + * Alias for calling [price] with + * `Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)`. + */ + fun price(groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice) = + price(Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)) + + /** + * Alias for calling [price] with + * `Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)`. + */ + fun price(groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice) = + price(Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)) + + /** + * Alias for calling [price] with + * `Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)`. + */ + fun price(groupedWithMinMaxThresholds: Price.GroupedWithMinMaxThresholds) = + price(Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)) + + /** + * Alias for calling [price] with + * `Price.ofMatrixWithDisplayName(matrixWithDisplayName)`. + */ + fun price(matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice) = + price(Price.ofMatrixWithDisplayName(matrixWithDisplayName)) + + /** + * Alias for calling [price] with `Price.ofGroupedTieredPackage(groupedTieredPackage)`. + */ + fun price(groupedTieredPackage: NewPlanGroupedTieredPackagePrice) = + price(Price.ofGroupedTieredPackage(groupedTieredPackage)) + + /** + * Alias for calling [price] with + * `Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)`. + */ + fun price(maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice) = + price(Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)) + + /** + * Alias for calling [price] with + * `Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)`. + */ + fun price(scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice) = + price(Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)) + + /** + * Alias for calling [price] with + * `Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)`. + */ + fun price( + scalableMatrixWithTieredPricing: NewPlanScalableMatrixWithTieredPricingPrice + ) = price(Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)) + + /** + * Alias for calling [price] with + * `Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)`. + */ + fun price(cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice) = + price(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) + + /** Alias for calling [price] with `Price.ofMinimum(minimum)`. */ + fun price(minimum: NewPlanMinimumCompositePrice) = price(Price.ofMinimum(minimum)) + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ReplacePrice]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .replacesPriceId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ReplacePrice = + ReplacePrice( + checkRequired("replacesPriceId", replacesPriceId), + allocationPrice, + planPhaseOrder, + price, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ReplacePrice = apply { + if (validated) { + return@apply + } + + replacesPriceId() + allocationPrice()?.validate() + planPhaseOrder() + price()?.validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (replacesPriceId.asKnown() == null) 0 else 1) + + (allocationPrice.asKnown()?.validity() ?: 0) + + (if (planPhaseOrder.asKnown() == null) 0 else 1) + + (price.asKnown()?.validity() ?: 0) + + /** New plan price request body params. */ + @JsonDeserialize(using = Price.Deserializer::class) + @JsonSerialize(using = Price.Serializer::class) + class Price + private constructor( + private val unit: NewPlanUnitPrice? = null, + private val tiered: NewPlanTieredPrice? = null, + private val bulk: NewPlanBulkPrice? = null, + private val package_: NewPlanPackagePrice? = null, + private val matrix: NewPlanMatrixPrice? = null, + private val thresholdTotalAmount: NewPlanThresholdTotalAmountPrice? = null, + private val tieredPackage: NewPlanTieredPackagePrice? = null, + private val tieredWithMinimum: NewPlanTieredWithMinimumPrice? = null, + private val groupedTiered: NewPlanGroupedTieredPrice? = null, + private val tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice? = null, + private val packageWithAllocation: NewPlanPackageWithAllocationPrice? = null, + private val unitWithPercent: NewPlanUnitWithPercentPrice? = null, + private val matrixWithAllocation: NewPlanMatrixWithAllocationPrice? = null, + private val tieredWithProration: TieredWithProration? = null, + private val unitWithProration: NewPlanUnitWithProrationPrice? = null, + private val groupedAllocation: NewPlanGroupedAllocationPrice? = null, + private val bulkWithProration: NewPlanBulkWithProrationPrice? = null, + private val groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice? = null, + private val groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice? = null, + private val groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds? = null, + private val matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice? = null, + private val groupedTieredPackage: NewPlanGroupedTieredPackagePrice? = null, + private val maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice? = null, + private val scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice? = + null, + private val scalableMatrixWithTieredPricing: + NewPlanScalableMatrixWithTieredPricingPrice? = + null, + private val cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice? = null, + private val minimum: NewPlanMinimumCompositePrice? = null, + private val _json: JsonValue? = null, + ) { + + fun unit(): NewPlanUnitPrice? = unit + + fun tiered(): NewPlanTieredPrice? = tiered + + fun bulk(): NewPlanBulkPrice? = bulk + + fun package_(): NewPlanPackagePrice? = package_ + + fun matrix(): NewPlanMatrixPrice? = matrix + + fun thresholdTotalAmount(): NewPlanThresholdTotalAmountPrice? = thresholdTotalAmount + + fun tieredPackage(): NewPlanTieredPackagePrice? = tieredPackage + + fun tieredWithMinimum(): NewPlanTieredWithMinimumPrice? = tieredWithMinimum + + fun groupedTiered(): NewPlanGroupedTieredPrice? = groupedTiered + + fun tieredPackageWithMinimum(): NewPlanTieredPackageWithMinimumPrice? = + tieredPackageWithMinimum + + fun packageWithAllocation(): NewPlanPackageWithAllocationPrice? = packageWithAllocation + + fun unitWithPercent(): NewPlanUnitWithPercentPrice? = unitWithPercent + + fun matrixWithAllocation(): NewPlanMatrixWithAllocationPrice? = matrixWithAllocation + + fun tieredWithProration(): TieredWithProration? = tieredWithProration + + fun unitWithProration(): NewPlanUnitWithProrationPrice? = unitWithProration + + fun groupedAllocation(): NewPlanGroupedAllocationPrice? = groupedAllocation + + fun bulkWithProration(): NewPlanBulkWithProrationPrice? = bulkWithProration + + fun groupedWithProratedMinimum(): NewPlanGroupedWithProratedMinimumPrice? = + groupedWithProratedMinimum + + fun groupedWithMeteredMinimum(): NewPlanGroupedWithMeteredMinimumPrice? = + groupedWithMeteredMinimum + + fun groupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds? = + groupedWithMinMaxThresholds + + fun matrixWithDisplayName(): NewPlanMatrixWithDisplayNamePrice? = matrixWithDisplayName + + fun groupedTieredPackage(): NewPlanGroupedTieredPackagePrice? = groupedTieredPackage + + fun maxGroupTieredPackage(): NewPlanMaxGroupTieredPackagePrice? = maxGroupTieredPackage + + fun scalableMatrixWithUnitPricing(): NewPlanScalableMatrixWithUnitPricingPrice? = + scalableMatrixWithUnitPricing + + fun scalableMatrixWithTieredPricing(): NewPlanScalableMatrixWithTieredPricingPrice? = + scalableMatrixWithTieredPricing + + fun cumulativeGroupedBulk(): NewPlanCumulativeGroupedBulkPrice? = cumulativeGroupedBulk + + fun minimum(): NewPlanMinimumCompositePrice? = minimum + + fun isUnit(): Boolean = unit != null + + fun isTiered(): Boolean = tiered != null + + fun isBulk(): Boolean = bulk != null + + fun isPackage(): Boolean = package_ != null + + fun isMatrix(): Boolean = matrix != null + + fun isThresholdTotalAmount(): Boolean = thresholdTotalAmount != null + + fun isTieredPackage(): Boolean = tieredPackage != null + + fun isTieredWithMinimum(): Boolean = tieredWithMinimum != null + + fun isGroupedTiered(): Boolean = groupedTiered != null + + fun isTieredPackageWithMinimum(): Boolean = tieredPackageWithMinimum != null + + fun isPackageWithAllocation(): Boolean = packageWithAllocation != null + + fun isUnitWithPercent(): Boolean = unitWithPercent != null + + fun isMatrixWithAllocation(): Boolean = matrixWithAllocation != null + + fun isTieredWithProration(): Boolean = tieredWithProration != null + + fun isUnitWithProration(): Boolean = unitWithProration != null + + fun isGroupedAllocation(): Boolean = groupedAllocation != null + + fun isBulkWithProration(): Boolean = bulkWithProration != null + + fun isGroupedWithProratedMinimum(): Boolean = groupedWithProratedMinimum != null + + fun isGroupedWithMeteredMinimum(): Boolean = groupedWithMeteredMinimum != null + + fun isGroupedWithMinMaxThresholds(): Boolean = groupedWithMinMaxThresholds != null + + fun isMatrixWithDisplayName(): Boolean = matrixWithDisplayName != null + + fun isGroupedTieredPackage(): Boolean = groupedTieredPackage != null + + fun isMaxGroupTieredPackage(): Boolean = maxGroupTieredPackage != null + + fun isScalableMatrixWithUnitPricing(): Boolean = scalableMatrixWithUnitPricing != null + + fun isScalableMatrixWithTieredPricing(): Boolean = + scalableMatrixWithTieredPricing != null + + fun isCumulativeGroupedBulk(): Boolean = cumulativeGroupedBulk != null + + fun isMinimum(): Boolean = minimum != null + + fun asUnit(): NewPlanUnitPrice = unit.getOrThrow("unit") + + fun asTiered(): NewPlanTieredPrice = tiered.getOrThrow("tiered") + + fun asBulk(): NewPlanBulkPrice = bulk.getOrThrow("bulk") + + fun asPackage(): NewPlanPackagePrice = package_.getOrThrow("package_") + + fun asMatrix(): NewPlanMatrixPrice = matrix.getOrThrow("matrix") + + fun asThresholdTotalAmount(): NewPlanThresholdTotalAmountPrice = + thresholdTotalAmount.getOrThrow("thresholdTotalAmount") + + fun asTieredPackage(): NewPlanTieredPackagePrice = + tieredPackage.getOrThrow("tieredPackage") + + fun asTieredWithMinimum(): NewPlanTieredWithMinimumPrice = + tieredWithMinimum.getOrThrow("tieredWithMinimum") + + fun asGroupedTiered(): NewPlanGroupedTieredPrice = + groupedTiered.getOrThrow("groupedTiered") + + fun asTieredPackageWithMinimum(): NewPlanTieredPackageWithMinimumPrice = + tieredPackageWithMinimum.getOrThrow("tieredPackageWithMinimum") + + fun asPackageWithAllocation(): NewPlanPackageWithAllocationPrice = + packageWithAllocation.getOrThrow("packageWithAllocation") + + fun asUnitWithPercent(): NewPlanUnitWithPercentPrice = + unitWithPercent.getOrThrow("unitWithPercent") + + fun asMatrixWithAllocation(): NewPlanMatrixWithAllocationPrice = + matrixWithAllocation.getOrThrow("matrixWithAllocation") + + fun asTieredWithProration(): TieredWithProration = + tieredWithProration.getOrThrow("tieredWithProration") + + fun asUnitWithProration(): NewPlanUnitWithProrationPrice = + unitWithProration.getOrThrow("unitWithProration") + + fun asGroupedAllocation(): NewPlanGroupedAllocationPrice = + groupedAllocation.getOrThrow("groupedAllocation") + + fun asBulkWithProration(): NewPlanBulkWithProrationPrice = + bulkWithProration.getOrThrow("bulkWithProration") + + fun asGroupedWithProratedMinimum(): NewPlanGroupedWithProratedMinimumPrice = + groupedWithProratedMinimum.getOrThrow("groupedWithProratedMinimum") + + fun asGroupedWithMeteredMinimum(): NewPlanGroupedWithMeteredMinimumPrice = + groupedWithMeteredMinimum.getOrThrow("groupedWithMeteredMinimum") + + fun asGroupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds = + groupedWithMinMaxThresholds.getOrThrow("groupedWithMinMaxThresholds") + + fun asMatrixWithDisplayName(): NewPlanMatrixWithDisplayNamePrice = + matrixWithDisplayName.getOrThrow("matrixWithDisplayName") + + fun asGroupedTieredPackage(): NewPlanGroupedTieredPackagePrice = + groupedTieredPackage.getOrThrow("groupedTieredPackage") + + fun asMaxGroupTieredPackage(): NewPlanMaxGroupTieredPackagePrice = + maxGroupTieredPackage.getOrThrow("maxGroupTieredPackage") + + fun asScalableMatrixWithUnitPricing(): NewPlanScalableMatrixWithUnitPricingPrice = + scalableMatrixWithUnitPricing.getOrThrow("scalableMatrixWithUnitPricing") + + fun asScalableMatrixWithTieredPricing(): NewPlanScalableMatrixWithTieredPricingPrice = + scalableMatrixWithTieredPricing.getOrThrow("scalableMatrixWithTieredPricing") + + fun asCumulativeGroupedBulk(): NewPlanCumulativeGroupedBulkPrice = + cumulativeGroupedBulk.getOrThrow("cumulativeGroupedBulk") + + fun asMinimum(): NewPlanMinimumCompositePrice = minimum.getOrThrow("minimum") + + fun _json(): JsonValue? = _json + + fun accept(visitor: Visitor): T = + when { + unit != null -> visitor.visitUnit(unit) + tiered != null -> visitor.visitTiered(tiered) + bulk != null -> visitor.visitBulk(bulk) + package_ != null -> visitor.visitPackage(package_) + matrix != null -> visitor.visitMatrix(matrix) + thresholdTotalAmount != null -> + visitor.visitThresholdTotalAmount(thresholdTotalAmount) + tieredPackage != null -> visitor.visitTieredPackage(tieredPackage) + tieredWithMinimum != null -> visitor.visitTieredWithMinimum(tieredWithMinimum) + groupedTiered != null -> visitor.visitGroupedTiered(groupedTiered) + tieredPackageWithMinimum != null -> + visitor.visitTieredPackageWithMinimum(tieredPackageWithMinimum) + packageWithAllocation != null -> + visitor.visitPackageWithAllocation(packageWithAllocation) + unitWithPercent != null -> visitor.visitUnitWithPercent(unitWithPercent) + matrixWithAllocation != null -> + visitor.visitMatrixWithAllocation(matrixWithAllocation) + tieredWithProration != null -> + visitor.visitTieredWithProration(tieredWithProration) + unitWithProration != null -> visitor.visitUnitWithProration(unitWithProration) + groupedAllocation != null -> visitor.visitGroupedAllocation(groupedAllocation) + bulkWithProration != null -> visitor.visitBulkWithProration(bulkWithProration) + groupedWithProratedMinimum != null -> + visitor.visitGroupedWithProratedMinimum(groupedWithProratedMinimum) + groupedWithMeteredMinimum != null -> + visitor.visitGroupedWithMeteredMinimum(groupedWithMeteredMinimum) + groupedWithMinMaxThresholds != null -> + visitor.visitGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds) + matrixWithDisplayName != null -> + visitor.visitMatrixWithDisplayName(matrixWithDisplayName) + groupedTieredPackage != null -> + visitor.visitGroupedTieredPackage(groupedTieredPackage) + maxGroupTieredPackage != null -> + visitor.visitMaxGroupTieredPackage(maxGroupTieredPackage) + scalableMatrixWithUnitPricing != null -> + visitor.visitScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing) + scalableMatrixWithTieredPricing != null -> + visitor.visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing + ) + cumulativeGroupedBulk != null -> + visitor.visitCumulativeGroupedBulk(cumulativeGroupedBulk) + minimum != null -> visitor.visitMinimum(minimum) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Price = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitUnit(unit: NewPlanUnitPrice) { + unit.validate() + } + + override fun visitTiered(tiered: NewPlanTieredPrice) { + tiered.validate() + } + + override fun visitBulk(bulk: NewPlanBulkPrice) { + bulk.validate() + } + + override fun visitPackage(package_: NewPlanPackagePrice) { + package_.validate() + } + + override fun visitMatrix(matrix: NewPlanMatrixPrice) { + matrix.validate() + } + + override fun visitThresholdTotalAmount( + thresholdTotalAmount: NewPlanThresholdTotalAmountPrice + ) { + thresholdTotalAmount.validate() + } + + override fun visitTieredPackage(tieredPackage: NewPlanTieredPackagePrice) { + tieredPackage.validate() + } + + override fun visitTieredWithMinimum( + tieredWithMinimum: NewPlanTieredWithMinimumPrice + ) { + tieredWithMinimum.validate() + } + + override fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) { + groupedTiered.validate() + } + + override fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice + ) { + tieredPackageWithMinimum.validate() + } + + override fun visitPackageWithAllocation( + packageWithAllocation: NewPlanPackageWithAllocationPrice + ) { + packageWithAllocation.validate() + } + + override fun visitUnitWithPercent( + unitWithPercent: NewPlanUnitWithPercentPrice + ) { + unitWithPercent.validate() + } + + override fun visitMatrixWithAllocation( + matrixWithAllocation: NewPlanMatrixWithAllocationPrice + ) { + matrixWithAllocation.validate() + } + + override fun visitTieredWithProration( + tieredWithProration: TieredWithProration + ) { + tieredWithProration.validate() + } + + override fun visitUnitWithProration( + unitWithProration: NewPlanUnitWithProrationPrice + ) { + unitWithProration.validate() + } + + override fun visitGroupedAllocation( + groupedAllocation: NewPlanGroupedAllocationPrice + ) { + groupedAllocation.validate() + } + + override fun visitBulkWithProration( + bulkWithProration: NewPlanBulkWithProrationPrice + ) { + bulkWithProration.validate() + } + + override fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice + ) { + groupedWithProratedMinimum.validate() + } + + override fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice + ) { + groupedWithMeteredMinimum.validate() + } + + override fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) { + groupedWithMinMaxThresholds.validate() + } + + override fun visitMatrixWithDisplayName( + matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice + ) { + matrixWithDisplayName.validate() + } + + override fun visitGroupedTieredPackage( + groupedTieredPackage: NewPlanGroupedTieredPackagePrice + ) { + groupedTieredPackage.validate() + } + + override fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice + ) { + maxGroupTieredPackage.validate() + } + + override fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice + ) { + scalableMatrixWithUnitPricing.validate() + } + + override fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: + NewPlanScalableMatrixWithTieredPricingPrice + ) { + scalableMatrixWithTieredPricing.validate() + } + + override fun visitCumulativeGroupedBulk( + cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice + ) { + cumulativeGroupedBulk.validate() + } + + override fun visitMinimum(minimum: NewPlanMinimumCompositePrice) { + minimum.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitUnit(unit: NewPlanUnitPrice) = unit.validity() + + override fun visitTiered(tiered: NewPlanTieredPrice) = tiered.validity() + + override fun visitBulk(bulk: NewPlanBulkPrice) = bulk.validity() + + override fun visitPackage(package_: NewPlanPackagePrice) = + package_.validity() + + override fun visitMatrix(matrix: NewPlanMatrixPrice) = matrix.validity() + + override fun visitThresholdTotalAmount( + thresholdTotalAmount: NewPlanThresholdTotalAmountPrice + ) = thresholdTotalAmount.validity() + + override fun visitTieredPackage(tieredPackage: NewPlanTieredPackagePrice) = + tieredPackage.validity() + + override fun visitTieredWithMinimum( + tieredWithMinimum: NewPlanTieredWithMinimumPrice + ) = tieredWithMinimum.validity() + + override fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) = + groupedTiered.validity() + + override fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice + ) = tieredPackageWithMinimum.validity() + + override fun visitPackageWithAllocation( + packageWithAllocation: NewPlanPackageWithAllocationPrice + ) = packageWithAllocation.validity() + + override fun visitUnitWithPercent( + unitWithPercent: NewPlanUnitWithPercentPrice + ) = unitWithPercent.validity() + + override fun visitMatrixWithAllocation( + matrixWithAllocation: NewPlanMatrixWithAllocationPrice + ) = matrixWithAllocation.validity() + + override fun visitTieredWithProration( + tieredWithProration: TieredWithProration + ) = tieredWithProration.validity() + + override fun visitUnitWithProration( + unitWithProration: NewPlanUnitWithProrationPrice + ) = unitWithProration.validity() + + override fun visitGroupedAllocation( + groupedAllocation: NewPlanGroupedAllocationPrice + ) = groupedAllocation.validity() + + override fun visitBulkWithProration( + bulkWithProration: NewPlanBulkWithProrationPrice + ) = bulkWithProration.validity() + + override fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice + ) = groupedWithProratedMinimum.validity() + + override fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice + ) = groupedWithMeteredMinimum.validity() + + override fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) = groupedWithMinMaxThresholds.validity() + + override fun visitMatrixWithDisplayName( + matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice + ) = matrixWithDisplayName.validity() + + override fun visitGroupedTieredPackage( + groupedTieredPackage: NewPlanGroupedTieredPackagePrice + ) = groupedTieredPackage.validity() + + override fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice + ) = maxGroupTieredPackage.validity() + + override fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice + ) = scalableMatrixWithUnitPricing.validity() + + override fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: + NewPlanScalableMatrixWithTieredPricingPrice + ) = scalableMatrixWithTieredPricing.validity() + + override fun visitCumulativeGroupedBulk( + cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice + ) = cumulativeGroupedBulk.validity() + + override fun visitMinimum(minimum: NewPlanMinimumCompositePrice) = + minimum.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Price && + unit == other.unit && + tiered == other.tiered && + bulk == other.bulk && + package_ == other.package_ && + matrix == other.matrix && + thresholdTotalAmount == other.thresholdTotalAmount && + tieredPackage == other.tieredPackage && + tieredWithMinimum == other.tieredWithMinimum && + groupedTiered == other.groupedTiered && + tieredPackageWithMinimum == other.tieredPackageWithMinimum && + packageWithAllocation == other.packageWithAllocation && + unitWithPercent == other.unitWithPercent && + matrixWithAllocation == other.matrixWithAllocation && + tieredWithProration == other.tieredWithProration && + unitWithProration == other.unitWithProration && + groupedAllocation == other.groupedAllocation && + bulkWithProration == other.bulkWithProration && + groupedWithProratedMinimum == other.groupedWithProratedMinimum && + groupedWithMeteredMinimum == other.groupedWithMeteredMinimum && + groupedWithMinMaxThresholds == other.groupedWithMinMaxThresholds && + matrixWithDisplayName == other.matrixWithDisplayName && + groupedTieredPackage == other.groupedTieredPackage && + maxGroupTieredPackage == other.maxGroupTieredPackage && + scalableMatrixWithUnitPricing == other.scalableMatrixWithUnitPricing && + scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && + cumulativeGroupedBulk == other.cumulativeGroupedBulk && + minimum == other.minimum + } + + override fun hashCode(): Int = + Objects.hash( + unit, + tiered, + bulk, + package_, + matrix, + thresholdTotalAmount, + tieredPackage, + tieredWithMinimum, + groupedTiered, + tieredPackageWithMinimum, + packageWithAllocation, + unitWithPercent, + matrixWithAllocation, + tieredWithProration, + unitWithProration, + groupedAllocation, + bulkWithProration, + groupedWithProratedMinimum, + groupedWithMeteredMinimum, + groupedWithMinMaxThresholds, + matrixWithDisplayName, + groupedTieredPackage, + maxGroupTieredPackage, + scalableMatrixWithUnitPricing, + scalableMatrixWithTieredPricing, + cumulativeGroupedBulk, + minimum, + ) + + override fun toString(): String = + when { + unit != null -> "Price{unit=$unit}" + tiered != null -> "Price{tiered=$tiered}" + bulk != null -> "Price{bulk=$bulk}" + package_ != null -> "Price{package_=$package_}" + matrix != null -> "Price{matrix=$matrix}" + thresholdTotalAmount != null -> + "Price{thresholdTotalAmount=$thresholdTotalAmount}" + tieredPackage != null -> "Price{tieredPackage=$tieredPackage}" + tieredWithMinimum != null -> "Price{tieredWithMinimum=$tieredWithMinimum}" + groupedTiered != null -> "Price{groupedTiered=$groupedTiered}" + tieredPackageWithMinimum != null -> + "Price{tieredPackageWithMinimum=$tieredPackageWithMinimum}" + packageWithAllocation != null -> + "Price{packageWithAllocation=$packageWithAllocation}" + unitWithPercent != null -> "Price{unitWithPercent=$unitWithPercent}" + matrixWithAllocation != null -> + "Price{matrixWithAllocation=$matrixWithAllocation}" + tieredWithProration != null -> "Price{tieredWithProration=$tieredWithProration}" + unitWithProration != null -> "Price{unitWithProration=$unitWithProration}" + groupedAllocation != null -> "Price{groupedAllocation=$groupedAllocation}" + bulkWithProration != null -> "Price{bulkWithProration=$bulkWithProration}" + groupedWithProratedMinimum != null -> + "Price{groupedWithProratedMinimum=$groupedWithProratedMinimum}" + groupedWithMeteredMinimum != null -> + "Price{groupedWithMeteredMinimum=$groupedWithMeteredMinimum}" + groupedWithMinMaxThresholds != null -> + "Price{groupedWithMinMaxThresholds=$groupedWithMinMaxThresholds}" + matrixWithDisplayName != null -> + "Price{matrixWithDisplayName=$matrixWithDisplayName}" + groupedTieredPackage != null -> + "Price{groupedTieredPackage=$groupedTieredPackage}" + maxGroupTieredPackage != null -> + "Price{maxGroupTieredPackage=$maxGroupTieredPackage}" + scalableMatrixWithUnitPricing != null -> + "Price{scalableMatrixWithUnitPricing=$scalableMatrixWithUnitPricing}" + scalableMatrixWithTieredPricing != null -> + "Price{scalableMatrixWithTieredPricing=$scalableMatrixWithTieredPricing}" + cumulativeGroupedBulk != null -> + "Price{cumulativeGroupedBulk=$cumulativeGroupedBulk}" + minimum != null -> "Price{minimum=$minimum}" + _json != null -> "Price{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Price") + } + + companion object { + + fun ofUnit(unit: NewPlanUnitPrice) = Price(unit = unit) + + fun ofTiered(tiered: NewPlanTieredPrice) = Price(tiered = tiered) + + fun ofBulk(bulk: NewPlanBulkPrice) = Price(bulk = bulk) + + fun ofPackage(package_: NewPlanPackagePrice) = Price(package_ = package_) + + fun ofMatrix(matrix: NewPlanMatrixPrice) = Price(matrix = matrix) + + fun ofThresholdTotalAmount(thresholdTotalAmount: NewPlanThresholdTotalAmountPrice) = + Price(thresholdTotalAmount = thresholdTotalAmount) + + fun ofTieredPackage(tieredPackage: NewPlanTieredPackagePrice) = + Price(tieredPackage = tieredPackage) + + fun ofTieredWithMinimum(tieredWithMinimum: NewPlanTieredWithMinimumPrice) = + Price(tieredWithMinimum = tieredWithMinimum) + + fun ofGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) = + Price(groupedTiered = groupedTiered) + + fun ofTieredPackageWithMinimum( + tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice + ) = Price(tieredPackageWithMinimum = tieredPackageWithMinimum) + + fun ofPackageWithAllocation( + packageWithAllocation: NewPlanPackageWithAllocationPrice + ) = Price(packageWithAllocation = packageWithAllocation) + + fun ofUnitWithPercent(unitWithPercent: NewPlanUnitWithPercentPrice) = + Price(unitWithPercent = unitWithPercent) + + fun ofMatrixWithAllocation(matrixWithAllocation: NewPlanMatrixWithAllocationPrice) = + Price(matrixWithAllocation = matrixWithAllocation) + + fun ofTieredWithProration(tieredWithProration: TieredWithProration) = + Price(tieredWithProration = tieredWithProration) + + fun ofUnitWithProration(unitWithProration: NewPlanUnitWithProrationPrice) = + Price(unitWithProration = unitWithProration) + + fun ofGroupedAllocation(groupedAllocation: NewPlanGroupedAllocationPrice) = + Price(groupedAllocation = groupedAllocation) + + fun ofBulkWithProration(bulkWithProration: NewPlanBulkWithProrationPrice) = + Price(bulkWithProration = bulkWithProration) + + fun ofGroupedWithProratedMinimum( + groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice + ) = Price(groupedWithProratedMinimum = groupedWithProratedMinimum) + + fun ofGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice + ) = Price(groupedWithMeteredMinimum = groupedWithMeteredMinimum) + + fun ofGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) = Price(groupedWithMinMaxThresholds = groupedWithMinMaxThresholds) + + fun ofMatrixWithDisplayName( + matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice + ) = Price(matrixWithDisplayName = matrixWithDisplayName) + + fun ofGroupedTieredPackage(groupedTieredPackage: NewPlanGroupedTieredPackagePrice) = + Price(groupedTieredPackage = groupedTieredPackage) + + fun ofMaxGroupTieredPackage( + maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice + ) = Price(maxGroupTieredPackage = maxGroupTieredPackage) + + fun ofScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice + ) = Price(scalableMatrixWithUnitPricing = scalableMatrixWithUnitPricing) + + fun ofScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: NewPlanScalableMatrixWithTieredPricingPrice + ) = Price(scalableMatrixWithTieredPricing = scalableMatrixWithTieredPricing) + + fun ofCumulativeGroupedBulk( + cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice + ) = Price(cumulativeGroupedBulk = cumulativeGroupedBulk) + + fun ofMinimum(minimum: NewPlanMinimumCompositePrice) = Price(minimum = minimum) + } + + /** + * An interface that defines how to map each variant of [Price] to a value of type [T]. + */ + interface Visitor { + + fun visitUnit(unit: NewPlanUnitPrice): T + + fun visitTiered(tiered: NewPlanTieredPrice): T + + fun visitBulk(bulk: NewPlanBulkPrice): T + + fun visitPackage(package_: NewPlanPackagePrice): T + + fun visitMatrix(matrix: NewPlanMatrixPrice): T + + fun visitThresholdTotalAmount( + thresholdTotalAmount: NewPlanThresholdTotalAmountPrice + ): T + + fun visitTieredPackage(tieredPackage: NewPlanTieredPackagePrice): T + + fun visitTieredWithMinimum(tieredWithMinimum: NewPlanTieredWithMinimumPrice): T + + fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice): T + + fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice + ): T + + fun visitPackageWithAllocation( + packageWithAllocation: NewPlanPackageWithAllocationPrice + ): T + + fun visitUnitWithPercent(unitWithPercent: NewPlanUnitWithPercentPrice): T + + fun visitMatrixWithAllocation( + matrixWithAllocation: NewPlanMatrixWithAllocationPrice + ): T + + fun visitTieredWithProration(tieredWithProration: TieredWithProration): T + + fun visitUnitWithProration(unitWithProration: NewPlanUnitWithProrationPrice): T + + fun visitGroupedAllocation(groupedAllocation: NewPlanGroupedAllocationPrice): T + + fun visitBulkWithProration(bulkWithProration: NewPlanBulkWithProrationPrice): T + + fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice + ): T + + fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice + ): T + + fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ): T + + fun visitMatrixWithDisplayName( + matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice + ): T + + fun visitGroupedTieredPackage( + groupedTieredPackage: NewPlanGroupedTieredPackagePrice + ): T + + fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice + ): T + + fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice + ): T + + fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: NewPlanScalableMatrixWithTieredPricingPrice + ): T + + fun visitCumulativeGroupedBulk( + cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice + ): T + + fun visitMinimum(minimum: NewPlanMinimumCompositePrice): T + + /** + * Maps an unknown variant of [Price] to a value of type [T]. + * + * An instance of [Price] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is + * unaware of. + * + * @throws OrbInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw OrbInvalidDataException("Unknown Price: $json") + } + } + + internal class Deserializer : BaseDeserializer(Price::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Price { + val json = JsonValue.fromJsonNode(node) + val modelType = json.asObject()?.get("model_type")?.asString() + + when (modelType) { + "unit" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(unit = it, _json = json) + } ?: Price(_json = json) + } + "tiered" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(tiered = it, _json = json) + } ?: Price(_json = json) + } + "bulk" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(bulk = it, _json = json) + } ?: Price(_json = json) + } + "package" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(package_ = it, _json = json) } ?: Price(_json = json) + } + "matrix" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(matrix = it, _json = json) + } ?: Price(_json = json) + } + "threshold_total_amount" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(thresholdTotalAmount = it, _json = json) } + ?: Price(_json = json) + } + "tiered_package" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(tieredPackage = it, _json = json) } + ?: Price(_json = json) + } + "tiered_with_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(tieredWithMinimum = it, _json = json) } + ?: Price(_json = json) + } + "grouped_tiered" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(groupedTiered = it, _json = json) } + ?: Price(_json = json) + } + "tiered_package_with_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(tieredPackageWithMinimum = it, _json = json) } + ?: Price(_json = json) + } + "package_with_allocation" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(packageWithAllocation = it, _json = json) } + ?: Price(_json = json) + } + "unit_with_percent" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(unitWithPercent = it, _json = json) } + ?: Price(_json = json) + } + "matrix_with_allocation" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(matrixWithAllocation = it, _json = json) } + ?: Price(_json = json) + } + "tiered_with_proration" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(tieredWithProration = it, _json = json) } + ?: Price(_json = json) + } + "unit_with_proration" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(unitWithProration = it, _json = json) } + ?: Price(_json = json) + } + "grouped_allocation" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedAllocation = it, _json = json) } + ?: Price(_json = json) + } + "bulk_with_proration" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(bulkWithProration = it, _json = json) } + ?: Price(_json = json) + } + "grouped_with_prorated_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedWithProratedMinimum = it, _json = json) } + ?: Price(_json = json) + } + "grouped_with_metered_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedWithMeteredMinimum = it, _json = json) } + ?: Price(_json = json) + } + "grouped_with_min_max_thresholds" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedWithMinMaxThresholds = it, _json = json) } + ?: Price(_json = json) + } + "matrix_with_display_name" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(matrixWithDisplayName = it, _json = json) } + ?: Price(_json = json) + } + "grouped_tiered_package" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedTieredPackage = it, _json = json) } + ?: Price(_json = json) + } + "max_group_tiered_package" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(maxGroupTieredPackage = it, _json = json) } + ?: Price(_json = json) + } + "scalable_matrix_with_unit_pricing" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(scalableMatrixWithUnitPricing = it, _json = json) } + ?: Price(_json = json) + } + "scalable_matrix_with_tiered_pricing" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(scalableMatrixWithTieredPricing = it, _json = json) } + ?: Price(_json = json) + } + "cumulative_grouped_bulk" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(cumulativeGroupedBulk = it, _json = json) } + ?: Price(_json = json) + } + "minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(minimum = it, _json = json) } ?: Price(_json = json) + } + } + + return Price(_json = json) + } + } + + internal class Serializer : BaseSerializer(Price::class) { + + override fun serialize( + value: Price, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.unit != null -> generator.writeObject(value.unit) + value.tiered != null -> generator.writeObject(value.tiered) + value.bulk != null -> generator.writeObject(value.bulk) + value.package_ != null -> generator.writeObject(value.package_) + value.matrix != null -> generator.writeObject(value.matrix) + value.thresholdTotalAmount != null -> + generator.writeObject(value.thresholdTotalAmount) + value.tieredPackage != null -> generator.writeObject(value.tieredPackage) + value.tieredWithMinimum != null -> + generator.writeObject(value.tieredWithMinimum) + value.groupedTiered != null -> generator.writeObject(value.groupedTiered) + value.tieredPackageWithMinimum != null -> + generator.writeObject(value.tieredPackageWithMinimum) + value.packageWithAllocation != null -> + generator.writeObject(value.packageWithAllocation) + value.unitWithPercent != null -> + generator.writeObject(value.unitWithPercent) + value.matrixWithAllocation != null -> + generator.writeObject(value.matrixWithAllocation) + value.tieredWithProration != null -> + generator.writeObject(value.tieredWithProration) + value.unitWithProration != null -> + generator.writeObject(value.unitWithProration) + value.groupedAllocation != null -> + generator.writeObject(value.groupedAllocation) + value.bulkWithProration != null -> + generator.writeObject(value.bulkWithProration) + value.groupedWithProratedMinimum != null -> + generator.writeObject(value.groupedWithProratedMinimum) + value.groupedWithMeteredMinimum != null -> + generator.writeObject(value.groupedWithMeteredMinimum) + value.groupedWithMinMaxThresholds != null -> + generator.writeObject(value.groupedWithMinMaxThresholds) + value.matrixWithDisplayName != null -> + generator.writeObject(value.matrixWithDisplayName) + value.groupedTieredPackage != null -> + generator.writeObject(value.groupedTieredPackage) + value.maxGroupTieredPackage != null -> + generator.writeObject(value.maxGroupTieredPackage) + value.scalableMatrixWithUnitPricing != null -> + generator.writeObject(value.scalableMatrixWithUnitPricing) + value.scalableMatrixWithTieredPricing != null -> + generator.writeObject(value.scalableMatrixWithTieredPricing) + value.cumulativeGroupedBulk != null -> + generator.writeObject(value.cumulativeGroupedBulk) + value.minimum != null -> generator.writeObject(value.minimum) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Price") + } + } + } + + class TieredWithProration + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val tieredWithProrationConfig: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("tiered_with_proration_config") + @ExcludeMissing + tieredWithProrationConfig: JsonField = + JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + modelType, + name, + tieredWithProrationConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("tiered_with_proration") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType - fun isBulk(): Boolean = bulk != null + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") - fun isThresholdTotalAmount(): Boolean = thresholdTotalAmount != null + /** + * Configuration for tiered_with_proration pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun tieredWithProrationConfig(): TieredWithProrationConfig = + tieredWithProrationConfig.getRequired("tiered_with_proration_config") - fun isTieredPackage(): Boolean = tieredPackage != null + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = billableMetricId.getNullable("billable_metric_id") - fun isTieredWithMinimum(): Boolean = tieredWithMinimum != null + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") - fun isUnitWithPercent(): Boolean = unitWithPercent != null + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") - fun isPackageWithAllocation(): Boolean = packageWithAllocation != null + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") - fun isTieredWithProration(): Boolean = tieredWithProration != null + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") - fun isUnitWithProration(): Boolean = unitWithProration != null + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") - fun isGroupedAllocation(): Boolean = groupedAllocation != null + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") - fun isGroupedWithProratedMinimum(): Boolean = groupedWithProratedMinimum != null + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") - fun isGroupedWithMeteredMinimum(): Boolean = groupedWithMeteredMinimum != null + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") - fun isGroupedWithMinMaxThresholds(): Boolean = groupedWithMinMaxThresholds != null + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + invoiceGroupingKey.getNullable("invoice_grouping_key") - fun isMatrixWithDisplayName(): Boolean = matrixWithDisplayName != null + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - fun isBulkWithProration(): Boolean = bulkWithProration != null + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") - fun isGroupedTieredPackage(): Boolean = groupedTieredPackage != null + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") - fun isMaxGroupTieredPackage(): Boolean = maxGroupTieredPackage != null + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence - fun isScalableMatrixWithUnitPricing(): Boolean = scalableMatrixWithUnitPricing != null + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - fun isScalableMatrixWithTieredPricing(): Boolean = - scalableMatrixWithTieredPricing != null + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - fun isCumulativeGroupedBulk(): Boolean = cumulativeGroupedBulk != null + /** + * Returns the raw JSON value of [tieredWithProrationConfig]. + * + * Unlike [tieredWithProrationConfig], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("tiered_with_proration_config") + @ExcludeMissing + fun _tieredWithProrationConfig(): JsonField = + tieredWithProrationConfig - fun isTieredPackageWithMinimum(): Boolean = tieredPackageWithMinimum != null + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId - fun isMatrixWithAllocation(): Boolean = matrixWithAllocation != null + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance - fun isGroupedTiered(): Boolean = groupedTiered != null + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration - fun isMinimum(): Boolean = minimum != null + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate - fun asUnit(): NewPlanUnitPrice = unit.getOrThrow("unit") + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig - fun asPackage(): NewPlanPackagePrice = package_.getOrThrow("package_") + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency - fun asMatrix(): NewPlanMatrixPrice = matrix.getOrThrow("matrix") + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration - fun asTiered(): NewPlanTieredPrice = tiered.getOrThrow("tiered") + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId - fun asBulk(): NewPlanBulkPrice = bulk.getOrThrow("bulk") + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - fun asThresholdTotalAmount(): NewPlanThresholdTotalAmountPrice = - thresholdTotalAmount.getOrThrow("thresholdTotalAmount") + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - fun asTieredPackage(): NewPlanTieredPackagePrice = - tieredPackage.getOrThrow("tieredPackage") + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration - fun asTieredWithMinimum(): NewPlanTieredWithMinimumPrice = - tieredWithMinimum.getOrThrow("tieredWithMinimum") + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata - fun asUnitWithPercent(): NewPlanUnitWithPercentPrice = - unitWithPercent.getOrThrow("unitWithPercent") + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId - fun asPackageWithAllocation(): NewPlanPackageWithAllocationPrice = - packageWithAllocation.getOrThrow("packageWithAllocation") + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - fun asTieredWithProration(): NewPlanTierWithProrationPrice = - tieredWithProration.getOrThrow("tieredWithProration") + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - fun asUnitWithProration(): NewPlanUnitWithProrationPrice = - unitWithProration.getOrThrow("unitWithProration") + fun toBuilder() = Builder().from(this) - fun asGroupedAllocation(): NewPlanGroupedAllocationPrice = - groupedAllocation.getOrThrow("groupedAllocation") + companion object { - fun asGroupedWithProratedMinimum(): NewPlanGroupedWithProratedMinimumPrice = - groupedWithProratedMinimum.getOrThrow("groupedWithProratedMinimum") + /** + * Returns a mutable builder for constructing an instance of + * [TieredWithProration]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .name() + * .tieredWithProrationConfig() + * ``` + */ + fun builder() = Builder() + } - fun asGroupedWithMeteredMinimum(): NewPlanGroupedWithMeteredMinimumPrice = - groupedWithMeteredMinimum.getOrThrow("groupedWithMeteredMinimum") + /** A builder for [TieredWithProration]. */ + class Builder internal constructor() { - fun asGroupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds = - groupedWithMinMaxThresholds.getOrThrow("groupedWithMinMaxThresholds") + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonValue = JsonValue.from("tiered_with_proration") + private var name: JsonField? = null + private var tieredWithProrationConfig: JsonField? = + null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - fun asMatrixWithDisplayName(): NewPlanMatrixWithDisplayNamePrice = - matrixWithDisplayName.getOrThrow("matrixWithDisplayName") + internal fun from(tieredWithProration: TieredWithProration) = apply { + cadence = tieredWithProration.cadence + itemId = tieredWithProration.itemId + modelType = tieredWithProration.modelType + name = tieredWithProration.name + tieredWithProrationConfig = tieredWithProration.tieredWithProrationConfig + billableMetricId = tieredWithProration.billableMetricId + billedInAdvance = tieredWithProration.billedInAdvance + billingCycleConfiguration = tieredWithProration.billingCycleConfiguration + conversionRate = tieredWithProration.conversionRate + conversionRateConfig = tieredWithProration.conversionRateConfig + currency = tieredWithProration.currency + dimensionalPriceConfiguration = + tieredWithProration.dimensionalPriceConfiguration + externalPriceId = tieredWithProration.externalPriceId + fixedPriceQuantity = tieredWithProration.fixedPriceQuantity + invoiceGroupingKey = tieredWithProration.invoiceGroupingKey + invoicingCycleConfiguration = + tieredWithProration.invoicingCycleConfiguration + metadata = tieredWithProration.metadata + referenceId = tieredWithProration.referenceId + additionalProperties = + tieredWithProration.additionalProperties.toMutableMap() + } - fun asBulkWithProration(): NewPlanBulkWithProrationPrice = - bulkWithProration.getOrThrow("bulkWithProration") + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - fun asGroupedTieredPackage(): NewPlanGroupedTieredPackagePrice = - groupedTieredPackage.getOrThrow("groupedTieredPackage") + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - fun asMaxGroupTieredPackage(): NewPlanMaxGroupTieredPackagePrice = - maxGroupTieredPackage.getOrThrow("maxGroupTieredPackage") + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - fun asScalableMatrixWithUnitPricing(): NewPlanScalableMatrixWithUnitPricingPrice = - scalableMatrixWithUnitPricing.getOrThrow("scalableMatrixWithUnitPricing") + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun asScalableMatrixWithTieredPricing(): NewPlanScalableMatrixWithTieredPricingPrice = - scalableMatrixWithTieredPricing.getOrThrow("scalableMatrixWithTieredPricing") + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("tiered_with_proration") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } - fun asCumulativeGroupedBulk(): NewPlanCumulativeGroupedBulkPrice = - cumulativeGroupedBulk.getOrThrow("cumulativeGroupedBulk") + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) - fun asTieredPackageWithMinimum(): NewPlanTieredPackageWithMinimumPrice = - tieredPackageWithMinimum.getOrThrow("tieredPackageWithMinimum") + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } - fun asMatrixWithAllocation(): NewPlanMatrixWithAllocationPrice = - matrixWithAllocation.getOrThrow("matrixWithAllocation") + /** Configuration for tiered_with_proration pricing */ + fun tieredWithProrationConfig( + tieredWithProrationConfig: TieredWithProrationConfig + ) = tieredWithProrationConfig(JsonField.of(tieredWithProrationConfig)) - fun asGroupedTiered(): NewPlanGroupedTieredPrice = - groupedTiered.getOrThrow("groupedTiered") + /** + * Sets [Builder.tieredWithProrationConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.tieredWithProrationConfig] with a well-typed + * [TieredWithProrationConfig] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun tieredWithProrationConfig( + tieredWithProrationConfig: JsonField + ) = apply { this.tieredWithProrationConfig = tieredWithProrationConfig } - fun asMinimum(): NewPlanMinimumCompositePrice = minimum.getOrThrow("minimum") + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) - fun _json(): JsonValue? = _json + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - package_ != null -> visitor.visitPackage(package_) - matrix != null -> visitor.visitMatrix(matrix) - tiered != null -> visitor.visitTiered(tiered) - bulk != null -> visitor.visitBulk(bulk) - thresholdTotalAmount != null -> - visitor.visitThresholdTotalAmount(thresholdTotalAmount) - tieredPackage != null -> visitor.visitTieredPackage(tieredPackage) - tieredWithMinimum != null -> visitor.visitTieredWithMinimum(tieredWithMinimum) - unitWithPercent != null -> visitor.visitUnitWithPercent(unitWithPercent) - packageWithAllocation != null -> - visitor.visitPackageWithAllocation(packageWithAllocation) - tieredWithProration != null -> - visitor.visitTieredWithProration(tieredWithProration) - unitWithProration != null -> visitor.visitUnitWithProration(unitWithProration) - groupedAllocation != null -> visitor.visitGroupedAllocation(groupedAllocation) - groupedWithProratedMinimum != null -> - visitor.visitGroupedWithProratedMinimum(groupedWithProratedMinimum) - groupedWithMeteredMinimum != null -> - visitor.visitGroupedWithMeteredMinimum(groupedWithMeteredMinimum) - groupedWithMinMaxThresholds != null -> - visitor.visitGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds) - matrixWithDisplayName != null -> - visitor.visitMatrixWithDisplayName(matrixWithDisplayName) - bulkWithProration != null -> visitor.visitBulkWithProration(bulkWithProration) - groupedTieredPackage != null -> - visitor.visitGroupedTieredPackage(groupedTieredPackage) - maxGroupTieredPackage != null -> - visitor.visitMaxGroupTieredPackage(maxGroupTieredPackage) - scalableMatrixWithUnitPricing != null -> - visitor.visitScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing) - scalableMatrixWithTieredPricing != null -> - visitor.visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing - ) - cumulativeGroupedBulk != null -> - visitor.visitCumulativeGroupedBulk(cumulativeGroupedBulk) - tieredPackageWithMinimum != null -> - visitor.visitTieredPackageWithMinimum(tieredPackageWithMinimum) - matrixWithAllocation != null -> - visitor.visitMatrixWithAllocation(matrixWithAllocation) - groupedTiered != null -> visitor.visitGroupedTiered(groupedTiered) - minimum != null -> visitor.visitMinimum(minimum) - else -> visitor.unknown(_json) - } + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) - private var validated: Boolean = false + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) - fun validate(): Price = apply { - if (validated) { - return@apply - } + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } - accept( - object : Visitor { - override fun visitUnit(unit: NewPlanUnitPrice) { - unit.validate() - } + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - override fun visitPackage(package_: NewPlanPackagePrice) { - package_.validate() - } + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } - override fun visitMatrix(matrix: NewPlanMatrixPrice) { - matrix.validate() - } + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) - override fun visitTiered(tiered: NewPlanTieredPrice) { - tiered.validate() - } + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) - override fun visitBulk(bulk: NewPlanBulkPrice) { - bulk.validate() - } + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } - override fun visitThresholdTotalAmount( - thresholdTotalAmount: NewPlanThresholdTotalAmountPrice - ) { - thresholdTotalAmount.validate() - } + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) - override fun visitTieredPackage(tieredPackage: NewPlanTieredPackagePrice) { - tieredPackage.validate() - } + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } - override fun visitTieredWithMinimum( - tieredWithMinimum: NewPlanTieredWithMinimumPrice - ) { - tieredWithMinimum.validate() - } + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) - override fun visitUnitWithPercent( - unitWithPercent: NewPlanUnitWithPercentPrice - ) { - unitWithPercent.validate() - } + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) - override fun visitPackageWithAllocation( - packageWithAllocation: NewPlanPackageWithAllocationPrice - ) { - packageWithAllocation.validate() - } + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) - override fun visitTieredWithProration( - tieredWithProration: NewPlanTierWithProrationPrice - ) { - tieredWithProration.validate() - } + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) - override fun visitUnitWithProration( - unitWithProration: NewPlanUnitWithProrationPrice - ) { - unitWithProration.validate() - } + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) - override fun visitGroupedAllocation( - groupedAllocation: NewPlanGroupedAllocationPrice - ) { - groupedAllocation.validate() - } + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } - override fun visitGroupedWithProratedMinimum( - groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice - ) { - groupedWithProratedMinimum.validate() - } + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) - override fun visitGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice - ) { - groupedWithMeteredMinimum.validate() - } + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } - override fun visitGroupedWithMinMaxThresholds( - groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds - ) { - groupedWithMinMaxThresholds.validate() - } + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) - override fun visitMatrixWithDisplayName( - matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice - ) { - matrixWithDisplayName.validate() - } + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } - override fun visitBulkWithProration( - bulkWithProration: NewPlanBulkWithProrationPrice - ) { - bulkWithProration.validate() - } + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) - override fun visitGroupedTieredPackage( - groupedTieredPackage: NewPlanGroupedTieredPackagePrice - ) { - groupedTieredPackage.validate() - } + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } - override fun visitMaxGroupTieredPackage( - maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice - ) { - maxGroupTieredPackage.validate() - } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) - override fun visitScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice - ) { - scalableMatrixWithUnitPricing.validate() - } + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } - override fun visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: - NewPlanScalableMatrixWithTieredPricingPrice - ) { - scalableMatrixWithTieredPricing.validate() - } + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) - override fun visitCumulativeGroupedBulk( - cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice - ) { - cumulativeGroupedBulk.validate() - } + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - override fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice - ) { - tieredPackageWithMinimum.validate() - } + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - override fun visitMatrixWithAllocation( - matrixWithAllocation: NewPlanMatrixWithAllocationPrice - ) { - matrixWithAllocation.validate() - } + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - override fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) { - groupedTiered.validate() - } + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) - override fun visitMinimum(minimum: NewPlanMinimumCompositePrice) { - minimum.validate() - } + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId } - ) - validated = true - } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: NewPlanUnitPrice) = unit.validity() + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - override fun visitPackage(package_: NewPlanPackagePrice) = - package_.validity() + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - override fun visitMatrix(matrix: NewPlanMatrixPrice) = matrix.validity() + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - override fun visitTiered(tiered: NewPlanTieredPrice) = tiered.validity() + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - override fun visitBulk(bulk: NewPlanBulkPrice) = bulk.validity() + /** + * Returns an immutable instance of [TieredWithProration]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .name() + * .tieredWithProrationConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TieredWithProration = + TieredWithProration( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + modelType, + checkRequired("name", name), + checkRequired("tieredWithProrationConfig", tieredWithProrationConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } - override fun visitThresholdTotalAmount( - thresholdTotalAmount: NewPlanThresholdTotalAmountPrice - ) = thresholdTotalAmount.validity() + private var validated: Boolean = false - override fun visitTieredPackage(tieredPackage: NewPlanTieredPackagePrice) = - tieredPackage.validity() + fun validate(): TieredWithProration = apply { + if (validated) { + return@apply + } - override fun visitTieredWithMinimum( - tieredWithMinimum: NewPlanTieredWithMinimumPrice - ) = tieredWithMinimum.validity() + cadence().validate() + itemId() + _modelType().let { + if (it != JsonValue.from("tiered_with_proration")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + tieredWithProrationConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + metadata()?.validate() + referenceId() + validated = true + } - override fun visitUnitWithPercent( - unitWithPercent: NewPlanUnitWithPercentPrice - ) = unitWithPercent.validity() + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - override fun visitPackageWithAllocation( - packageWithAllocation: NewPlanPackageWithAllocationPrice - ) = packageWithAllocation.validity() + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + modelType.let { + if (it == JsonValue.from("tiered_with_proration")) 1 else 0 + } + + (if (name.asKnown() == null) 0 else 1) + + (tieredWithProrationConfig.asKnown()?.validity() ?: 0) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) - override fun visitTieredWithProration( - tieredWithProration: NewPlanTierWithProrationPrice - ) = tieredWithProration.validity() + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { - override fun visitUnitWithProration( - unitWithProration: NewPlanUnitWithProrationPrice - ) = unitWithProration.validity() + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value - override fun visitGroupedAllocation( - groupedAllocation: NewPlanGroupedAllocationPrice - ) = groupedAllocation.validity() + companion object { - override fun visitGroupedWithProratedMinimum( - groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice - ) = groupedWithProratedMinimum.validity() + val ANNUAL = of("annual") - override fun visitGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice - ) = groupedWithMeteredMinimum.validity() + val SEMI_ANNUAL = of("semi_annual") - override fun visitGroupedWithMinMaxThresholds( - groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds - ) = groupedWithMinMaxThresholds.validity() + val MONTHLY = of("monthly") - override fun visitMatrixWithDisplayName( - matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice - ) = matrixWithDisplayName.validity() + val QUARTERLY = of("quarterly") - override fun visitBulkWithProration( - bulkWithProration: NewPlanBulkWithProrationPrice - ) = bulkWithProration.validity() + val ONE_TIME = of("one_time") - override fun visitGroupedTieredPackage( - groupedTieredPackage: NewPlanGroupedTieredPackagePrice - ) = groupedTieredPackage.validity() + val CUSTOM = of("custom") - override fun visitMaxGroupTieredPackage( - maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice - ) = maxGroupTieredPackage.validity() + fun of(value: String) = Cadence(JsonField.of(value)) + } - override fun visitScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice - ) = scalableMatrixWithUnitPricing.validity() + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } - override fun visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: - NewPlanScalableMatrixWithTieredPricingPrice - ) = scalableMatrixWithTieredPricing.validity() + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } - override fun visitCumulativeGroupedBulk( - cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice - ) = cumulativeGroupedBulk.validity() + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } - override fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice - ) = tieredPackageWithMinimum.validity() + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } - override fun visitMatrixWithAllocation( - matrixWithAllocation: NewPlanMatrixWithAllocationPrice - ) = matrixWithAllocation.validity() + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") - override fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) = - groupedTiered.validity() + private var validated: Boolean = false - override fun visitMinimum(minimum: NewPlanMinimumCompositePrice) = - minimum.validity() + fun validate(): Cadence = apply { + if (validated) { + return@apply + } - override fun unknown(json: JsonValue?) = 0 + known() + validated = true } - ) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - return other is Price && - unit == other.unit && - package_ == other.package_ && - matrix == other.matrix && - tiered == other.tiered && - bulk == other.bulk && - thresholdTotalAmount == other.thresholdTotalAmount && - tieredPackage == other.tieredPackage && - tieredWithMinimum == other.tieredWithMinimum && - unitWithPercent == other.unitWithPercent && - packageWithAllocation == other.packageWithAllocation && - tieredWithProration == other.tieredWithProration && - unitWithProration == other.unitWithProration && - groupedAllocation == other.groupedAllocation && - groupedWithProratedMinimum == other.groupedWithProratedMinimum && - groupedWithMeteredMinimum == other.groupedWithMeteredMinimum && - groupedWithMinMaxThresholds == other.groupedWithMinMaxThresholds && - matrixWithDisplayName == other.matrixWithDisplayName && - bulkWithProration == other.bulkWithProration && - groupedTieredPackage == other.groupedTieredPackage && - maxGroupTieredPackage == other.maxGroupTieredPackage && - scalableMatrixWithUnitPricing == other.scalableMatrixWithUnitPricing && - scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && - cumulativeGroupedBulk == other.cumulativeGroupedBulk && - tieredPackageWithMinimum == other.tieredPackageWithMinimum && - matrixWithAllocation == other.matrixWithAllocation && - groupedTiered == other.groupedTiered && - minimum == other.minimum - } + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - override fun hashCode(): Int = - Objects.hash( - unit, - package_, - matrix, - tiered, - bulk, - thresholdTotalAmount, - tieredPackage, - tieredWithMinimum, - unitWithPercent, - packageWithAllocation, - tieredWithProration, - unitWithProration, - groupedAllocation, - groupedWithProratedMinimum, - groupedWithMeteredMinimum, - groupedWithMinMaxThresholds, - matrixWithDisplayName, - bulkWithProration, - groupedTieredPackage, - maxGroupTieredPackage, - scalableMatrixWithUnitPricing, - scalableMatrixWithTieredPricing, - cumulativeGroupedBulk, - tieredPackageWithMinimum, - matrixWithAllocation, - groupedTiered, - minimum, - ) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } - override fun toString(): String = - when { - unit != null -> "Price{unit=$unit}" - package_ != null -> "Price{package_=$package_}" - matrix != null -> "Price{matrix=$matrix}" - tiered != null -> "Price{tiered=$tiered}" - bulk != null -> "Price{bulk=$bulk}" - thresholdTotalAmount != null -> - "Price{thresholdTotalAmount=$thresholdTotalAmount}" - tieredPackage != null -> "Price{tieredPackage=$tieredPackage}" - tieredWithMinimum != null -> "Price{tieredWithMinimum=$tieredWithMinimum}" - unitWithPercent != null -> "Price{unitWithPercent=$unitWithPercent}" - packageWithAllocation != null -> - "Price{packageWithAllocation=$packageWithAllocation}" - tieredWithProration != null -> "Price{tieredWithProration=$tieredWithProration}" - unitWithProration != null -> "Price{unitWithProration=$unitWithProration}" - groupedAllocation != null -> "Price{groupedAllocation=$groupedAllocation}" - groupedWithProratedMinimum != null -> - "Price{groupedWithProratedMinimum=$groupedWithProratedMinimum}" - groupedWithMeteredMinimum != null -> - "Price{groupedWithMeteredMinimum=$groupedWithMeteredMinimum}" - groupedWithMinMaxThresholds != null -> - "Price{groupedWithMinMaxThresholds=$groupedWithMinMaxThresholds}" - matrixWithDisplayName != null -> - "Price{matrixWithDisplayName=$matrixWithDisplayName}" - bulkWithProration != null -> "Price{bulkWithProration=$bulkWithProration}" - groupedTieredPackage != null -> - "Price{groupedTieredPackage=$groupedTieredPackage}" - maxGroupTieredPackage != null -> - "Price{maxGroupTieredPackage=$maxGroupTieredPackage}" - scalableMatrixWithUnitPricing != null -> - "Price{scalableMatrixWithUnitPricing=$scalableMatrixWithUnitPricing}" - scalableMatrixWithTieredPricing != null -> - "Price{scalableMatrixWithTieredPricing=$scalableMatrixWithTieredPricing}" - cumulativeGroupedBulk != null -> - "Price{cumulativeGroupedBulk=$cumulativeGroupedBulk}" - tieredPackageWithMinimum != null -> - "Price{tieredPackageWithMinimum=$tieredPackageWithMinimum}" - matrixWithAllocation != null -> - "Price{matrixWithAllocation=$matrixWithAllocation}" - groupedTiered != null -> "Price{groupedTiered=$groupedTiered}" - minimum != null -> "Price{minimum=$minimum}" - _json != null -> "Price{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Price") + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() } - companion object { + /** Configuration for tiered_with_proration pricing */ + class TieredWithProrationConfig + private constructor( + private val tiers: JsonField>, + private val additionalProperties: MutableMap, + ) { - fun ofUnit(unit: NewPlanUnitPrice) = Price(unit = unit) + @JsonCreator + private constructor( + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of() + ) : this(tiers, mutableMapOf()) - fun ofPackage(package_: NewPlanPackagePrice) = Price(package_ = package_) + /** + * Tiers for rating based on total usage quantities into the specified tier with + * proration + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun tiers(): List = tiers.getRequired("tiers") - fun ofMatrix(matrix: NewPlanMatrixPrice) = Price(matrix = matrix) + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers - fun ofTiered(tiered: NewPlanTieredPrice) = Price(tiered = tiered) + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - fun ofBulk(bulk: NewPlanBulkPrice) = Price(bulk = bulk) + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - fun ofThresholdTotalAmount(thresholdTotalAmount: NewPlanThresholdTotalAmountPrice) = - Price(thresholdTotalAmount = thresholdTotalAmount) + fun toBuilder() = Builder().from(this) - fun ofTieredPackage(tieredPackage: NewPlanTieredPackagePrice) = - Price(tieredPackage = tieredPackage) + companion object { - fun ofTieredWithMinimum(tieredWithMinimum: NewPlanTieredWithMinimumPrice) = - Price(tieredWithMinimum = tieredWithMinimum) + /** + * Returns a mutable builder for constructing an instance of + * [TieredWithProrationConfig]. + * + * The following fields are required: + * ```kotlin + * .tiers() + * ``` + */ + fun builder() = Builder() + } - fun ofUnitWithPercent(unitWithPercent: NewPlanUnitWithPercentPrice) = - Price(unitWithPercent = unitWithPercent) + /** A builder for [TieredWithProrationConfig]. */ + class Builder internal constructor() { - fun ofPackageWithAllocation( - packageWithAllocation: NewPlanPackageWithAllocationPrice - ) = Price(packageWithAllocation = packageWithAllocation) + private var tiers: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() - fun ofTieredWithProration(tieredWithProration: NewPlanTierWithProrationPrice) = - Price(tieredWithProration = tieredWithProration) + internal fun from(tieredWithProrationConfig: TieredWithProrationConfig) = + apply { + tiers = tieredWithProrationConfig.tiers.map { it.toMutableList() } + additionalProperties = + tieredWithProrationConfig.additionalProperties.toMutableMap() + } - fun ofUnitWithProration(unitWithProration: NewPlanUnitWithProrationPrice) = - Price(unitWithProration = unitWithProration) + /** + * Tiers for rating based on total usage quantities into the specified tier + * with proration + */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) - fun ofGroupedAllocation(groupedAllocation: NewPlanGroupedAllocationPrice) = - Price(groupedAllocation = groupedAllocation) + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } - fun ofGroupedWithProratedMinimum( - groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice - ) = Price(groupedWithProratedMinimum = groupedWithProratedMinimum) + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } - fun ofGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice - ) = Price(groupedWithMeteredMinimum = groupedWithMeteredMinimum) + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun ofGroupedWithMinMaxThresholds( - groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds - ) = Price(groupedWithMinMaxThresholds = groupedWithMinMaxThresholds) + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun ofMatrixWithDisplayName( - matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice - ) = Price(matrixWithDisplayName = matrixWithDisplayName) + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun ofBulkWithProration(bulkWithProration: NewPlanBulkWithProrationPrice) = - Price(bulkWithProration = bulkWithProration) + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun ofGroupedTieredPackage(groupedTieredPackage: NewPlanGroupedTieredPackagePrice) = - Price(groupedTieredPackage = groupedTieredPackage) + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - fun ofMaxGroupTieredPackage( - maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice - ) = Price(maxGroupTieredPackage = maxGroupTieredPackage) + /** + * Returns an immutable instance of [TieredWithProrationConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TieredWithProrationConfig = + TieredWithProrationConfig( + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } - fun ofScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice - ) = Price(scalableMatrixWithUnitPricing = scalableMatrixWithUnitPricing) + private var validated: Boolean = false - fun ofScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: NewPlanScalableMatrixWithTieredPricingPrice - ) = Price(scalableMatrixWithTieredPricing = scalableMatrixWithTieredPricing) + fun validate(): TieredWithProrationConfig = apply { + if (validated) { + return@apply + } - fun ofCumulativeGroupedBulk( - cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice - ) = Price(cumulativeGroupedBulk = cumulativeGroupedBulk) + tiers().forEach { it.validate() } + validated = true + } - fun ofTieredPackageWithMinimum( - tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice - ) = Price(tieredPackageWithMinimum = tieredPackageWithMinimum) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - fun ofMatrixWithAllocation(matrixWithAllocation: NewPlanMatrixWithAllocationPrice) = - Price(matrixWithAllocation = matrixWithAllocation) + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (tiers.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single tiered with proration tier */ + class Tier + private constructor( + private val tierLowerBound: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(tierLowerBound, unitAmount, mutableMapOf()) - fun ofGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) = - Price(groupedTiered = groupedTiered) + /** + * Inclusive tier starting value + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun tierLowerBound(): String = + tierLowerBound.getRequired("tier_lower_bound") - fun ofMinimum(minimum: NewPlanMinimumCompositePrice) = Price(minimum = minimum) - } + /** + * Amount per unit + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") - /** - * An interface that defines how to map each variant of [Price] to a value of type [T]. - */ - interface Visitor { + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound - fun visitUnit(unit: NewPlanUnitPrice): T + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount - fun visitPackage(package_: NewPlanPackagePrice): T + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - fun visitMatrix(matrix: NewPlanMatrixPrice): T + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - fun visitTiered(tiered: NewPlanTieredPrice): T + fun toBuilder() = Builder().from(this) - fun visitBulk(bulk: NewPlanBulkPrice): T + companion object { - fun visitThresholdTotalAmount( - thresholdTotalAmount: NewPlanThresholdTotalAmountPrice - ): T + /** + * Returns a mutable builder for constructing an instance of [Tier]. + * + * The following fields are required: + * ```kotlin + * .tierLowerBound() + * .unitAmount() + * ``` + */ + fun builder() = Builder() + } - fun visitTieredPackage(tieredPackage: NewPlanTieredPackagePrice): T + /** A builder for [Tier]. */ + class Builder internal constructor() { - fun visitTieredWithMinimum(tieredWithMinimum: NewPlanTieredWithMinimumPrice): T + private var tierLowerBound: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() - fun visitUnitWithPercent(unitWithPercent: NewPlanUnitWithPercentPrice): T + internal fun from(tier: Tier) = apply { + tierLowerBound = tier.tierLowerBound + unitAmount = tier.unitAmount + additionalProperties = tier.additionalProperties.toMutableMap() + } - fun visitPackageWithAllocation( - packageWithAllocation: NewPlanPackageWithAllocationPrice - ): T + /** Inclusive tier starting value */ + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } - fun visitTieredWithProration(tieredWithProration: NewPlanTierWithProrationPrice): T + /** Amount per unit */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } - fun visitUnitWithProration(unitWithProration: NewPlanUnitWithProrationPrice): T + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun visitGroupedAllocation(groupedAllocation: NewPlanGroupedAllocationPrice): T + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun visitGroupedWithProratedMinimum( - groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice - ): T + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun visitGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice - ): T + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun visitGroupedWithMinMaxThresholds( - groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds - ): T + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - fun visitMatrixWithDisplayName( - matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice - ): T + /** + * Returns an immutable instance of [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```kotlin + * .tierLowerBound() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("tierLowerBound", tierLowerBound), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } - fun visitBulkWithProration(bulkWithProration: NewPlanBulkWithProrationPrice): T + private var validated: Boolean = false - fun visitGroupedTieredPackage( - groupedTieredPackage: NewPlanGroupedTieredPackagePrice - ): T + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + tierLowerBound() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (tierLowerBound.asKnown() == null) 0 else 1) + + (if (unitAmount.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun visitMaxGroupTieredPackage( - maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice - ): T + return other is Tier && + tierLowerBound == other.tierLowerBound && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } - fun visitScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice - ): T + private val hashCode: Int by lazy { + Objects.hash(tierLowerBound, unitAmount, additionalProperties) + } - fun visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: NewPlanScalableMatrixWithTieredPricingPrice - ): T + override fun hashCode(): Int = hashCode - fun visitCumulativeGroupedBulk( - cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice - ): T + override fun toString() = + "Tier{tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } - fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice - ): T + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun visitMatrixWithAllocation( - matrixWithAllocation: NewPlanMatrixWithAllocationPrice - ): T + return other is TieredWithProrationConfig && + tiers == other.tiers && + additionalProperties == other.additionalProperties + } - fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice): T + private val hashCode: Int by lazy { Objects.hash(tiers, additionalProperties) } - fun visitMinimum(minimum: NewPlanMinimumCompositePrice): T + override fun hashCode(): Int = hashCode + + override fun toString() = + "TieredWithProrationConfig{tiers=$tiers, additionalProperties=$additionalProperties}" + } /** - * Maps an unknown variant of [Price] to a value of type [T]. - * - * An instance of [Price] can contain an unknown variant if it was deserialized from - * data that doesn't match any known variant. For example, if the SDK is on an older - * version than the API, then the API may respond with new variants that the SDK is - * unaware of. - * - * @throws OrbInvalidDataException in the default implementation. + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown Price: $json") - } - } + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { - internal class Deserializer : BaseDeserializer(Price::class) { + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties - override fun ObjectCodec.deserialize(node: JsonNode): Price { - val json = JsonValue.fromJsonNode(node) - val modelType = json.asObject()?.get("model_type")?.asString() + fun toBuilder() = Builder().from(this) - when (modelType) { - "unit" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(unit = it, _json = json) - } ?: Price(_json = json) - } - "package" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(package_ = it, _json = json) } ?: Price(_json = json) - } - "matrix" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(matrix = it, _json = json) - } ?: Price(_json = json) - } - "tiered" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(tiered = it, _json = json) - } ?: Price(_json = json) - } - "bulk" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(bulk = it, _json = json) - } ?: Price(_json = json) - } - "threshold_total_amount" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(thresholdTotalAmount = it, _json = json) } - ?: Price(_json = json) - } - "tiered_package" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(tieredPackage = it, _json = json) } - ?: Price(_json = json) - } - "tiered_with_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(tieredWithMinimum = it, _json = json) } - ?: Price(_json = json) - } - "unit_with_percent" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(unitWithPercent = it, _json = json) } - ?: Price(_json = json) - } - "package_with_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(packageWithAllocation = it, _json = json) } - ?: Price(_json = json) - } - "tiered_with_proration" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(tieredWithProration = it, _json = json) } - ?: Price(_json = json) - } - "unit_with_proration" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(unitWithProration = it, _json = json) } - ?: Price(_json = json) - } - "grouped_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedAllocation = it, _json = json) } - ?: Price(_json = json) - } - "grouped_with_prorated_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedWithProratedMinimum = it, _json = json) } - ?: Price(_json = json) - } - "grouped_with_metered_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedWithMeteredMinimum = it, _json = json) } - ?: Price(_json = json) - } - "grouped_with_min_max_thresholds" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedWithMinMaxThresholds = it, _json = json) } - ?: Price(_json = json) - } - "matrix_with_display_name" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(matrixWithDisplayName = it, _json = json) } - ?: Price(_json = json) - } - "bulk_with_proration" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(bulkWithProration = it, _json = json) } - ?: Price(_json = json) - } - "grouped_tiered_package" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedTieredPackage = it, _json = json) } - ?: Price(_json = json) - } - "max_group_tiered_package" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(maxGroupTieredPackage = it, _json = json) } - ?: Price(_json = json) + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() } - "scalable_matrix_with_unit_pricing" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(scalableMatrixWithUnitPricing = it, _json = json) } - ?: Price(_json = json) + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) } - "scalable_matrix_with_tiered_pricing" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(scalableMatrixWithTieredPricing = it, _json = json) } - ?: Price(_json = json) + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) } - "cumulative_grouped_bulk" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(cumulativeGroupedBulk = it, _json = json) } - ?: Price(_json = json) + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) } - "tiered_package_with_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(tieredPackageWithMinimum = it, _json = json) } - ?: Price(_json = json) + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply } - "matrix_with_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(matrixWithAllocation = it, _json = json) } - ?: Price(_json = json) + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false } - "grouped_tiered" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(groupedTiered = it, _json = json) } - ?: Price(_json = json) + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() } - "minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(minimum = it, _json = json) } ?: Price(_json = json) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } + + return other is Metadata && + additionalProperties == other.additionalProperties } - return Price(_json = json) - } - } + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - internal class Serializer : BaseSerializer(Price::class) { + override fun hashCode(): Int = hashCode - override fun serialize( - value: Price, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unit != null -> generator.writeObject(value.unit) - value.package_ != null -> generator.writeObject(value.package_) - value.matrix != null -> generator.writeObject(value.matrix) - value.tiered != null -> generator.writeObject(value.tiered) - value.bulk != null -> generator.writeObject(value.bulk) - value.thresholdTotalAmount != null -> - generator.writeObject(value.thresholdTotalAmount) - value.tieredPackage != null -> generator.writeObject(value.tieredPackage) - value.tieredWithMinimum != null -> - generator.writeObject(value.tieredWithMinimum) - value.unitWithPercent != null -> - generator.writeObject(value.unitWithPercent) - value.packageWithAllocation != null -> - generator.writeObject(value.packageWithAllocation) - value.tieredWithProration != null -> - generator.writeObject(value.tieredWithProration) - value.unitWithProration != null -> - generator.writeObject(value.unitWithProration) - value.groupedAllocation != null -> - generator.writeObject(value.groupedAllocation) - value.groupedWithProratedMinimum != null -> - generator.writeObject(value.groupedWithProratedMinimum) - value.groupedWithMeteredMinimum != null -> - generator.writeObject(value.groupedWithMeteredMinimum) - value.groupedWithMinMaxThresholds != null -> - generator.writeObject(value.groupedWithMinMaxThresholds) - value.matrixWithDisplayName != null -> - generator.writeObject(value.matrixWithDisplayName) - value.bulkWithProration != null -> - generator.writeObject(value.bulkWithProration) - value.groupedTieredPackage != null -> - generator.writeObject(value.groupedTieredPackage) - value.maxGroupTieredPackage != null -> - generator.writeObject(value.maxGroupTieredPackage) - value.scalableMatrixWithUnitPricing != null -> - generator.writeObject(value.scalableMatrixWithUnitPricing) - value.scalableMatrixWithTieredPricing != null -> - generator.writeObject(value.scalableMatrixWithTieredPricing) - value.cumulativeGroupedBulk != null -> - generator.writeObject(value.cumulativeGroupedBulk) - value.tieredPackageWithMinimum != null -> - generator.writeObject(value.tieredPackageWithMinimum) - value.matrixWithAllocation != null -> - generator.writeObject(value.matrixWithAllocation) - value.groupedTiered != null -> generator.writeObject(value.groupedTiered) - value.minimum != null -> generator.writeObject(value.minimum) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Price") + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } + + return other is TieredWithProration && + cadence == other.cadence && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + tieredWithProrationConfig == other.tieredWithProrationConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + modelType, + name, + tieredWithProrationConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties, + ) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TieredWithProration{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredWithProrationConfig=$tieredWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } class GroupedWithMinMaxThresholds @@ -7359,6 +11100,8 @@ private constructor( fun cadence(): Cadence = cadence.getRequired("cadence") /** + * Configuration for grouped_with_min_max_thresholds pricing + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected * value). @@ -7378,6 +11121,8 @@ private constructor( fun itemId(): String = itemId.getRequired("item_id") /** + * The pricing model type + * * Expected to always return the following: * ```kotlin * JsonValue.from("grouped_with_min_max_thresholds") @@ -7787,6 +11532,7 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + /** Configuration for grouped_with_min_max_thresholds pricing */ fun groupedWithMinMaxThresholdsConfig( groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig ) = @@ -8442,16 +12188,117 @@ private constructor( override fun toString() = value.toString() } + /** Configuration for grouped_with_min_max_thresholds pricing */ class GroupedWithMinMaxThresholdsConfig - @JsonCreator private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map + private val groupingKey: JsonField, + private val maximumCharge: JsonField, + private val minimumCharge: JsonField, + private val perUnitRate: JsonField, + private val additionalProperties: MutableMap, ) { + @JsonCreator + private constructor( + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("maximum_charge") + @ExcludeMissing + maximumCharge: JsonField = JsonMissing.of(), + @JsonProperty("minimum_charge") + @ExcludeMissing + minimumCharge: JsonField = JsonMissing.of(), + @JsonProperty("per_unit_rate") + @ExcludeMissing + perUnitRate: JsonField = JsonMissing.of(), + ) : this(groupingKey, maximumCharge, minimumCharge, perUnitRate, mutableMapOf()) + + /** + * The event property used to group before applying thresholds + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The maximum amount to charge each group + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun maximumCharge(): String = maximumCharge.getRequired("maximum_charge") + + /** + * The minimum amount to charge each group, regardless of usage + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun minimumCharge(): String = minimumCharge.getRequired("minimum_charge") + + /** + * The base price charged per group + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun perUnitRate(): String = perUnitRate.getRequired("per_unit_rate") + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [maximumCharge]. + * + * Unlike [maximumCharge], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("maximum_charge") + @ExcludeMissing + fun _maximumCharge(): JsonField = maximumCharge + + /** + * Returns the raw JSON value of [minimumCharge]. + * + * Unlike [minimumCharge], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("minimum_charge") + @ExcludeMissing + fun _minimumCharge(): JsonField = minimumCharge + + /** + * Returns the raw JSON value of [perUnitRate]. + * + * Unlike [perUnitRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("per_unit_rate") + @ExcludeMissing + fun _perUnitRate(): JsonField = perUnitRate + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) fun toBuilder() = Builder().from(this) @@ -8460,6 +12307,14 @@ private constructor( /** * Returns a mutable builder for constructing an instance of * [GroupedWithMinMaxThresholdsConfig]. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .maximumCharge() + * .minimumCharge() + * .perUnitRate() + * ``` */ fun builder() = Builder() } @@ -8467,17 +12322,85 @@ private constructor( /** A builder for [GroupedWithMinMaxThresholdsConfig]. */ class Builder internal constructor() { + private var groupingKey: JsonField? = null + private var maximumCharge: JsonField? = null + private var minimumCharge: JsonField? = null + private var perUnitRate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from( groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig ) = apply { + groupingKey = groupedWithMinMaxThresholdsConfig.groupingKey + maximumCharge = groupedWithMinMaxThresholdsConfig.maximumCharge + minimumCharge = groupedWithMinMaxThresholdsConfig.minimumCharge + perUnitRate = groupedWithMinMaxThresholdsConfig.perUnitRate additionalProperties = groupedWithMinMaxThresholdsConfig.additionalProperties .toMutableMap() } + /** The event property used to group before applying thresholds */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The maximum amount to charge each group */ + fun maximumCharge(maximumCharge: String) = + maximumCharge(JsonField.of(maximumCharge)) + + /** + * Sets [Builder.maximumCharge] to an arbitrary JSON value. + * + * You should usually call [Builder.maximumCharge] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun maximumCharge(maximumCharge: JsonField) = apply { + this.maximumCharge = maximumCharge + } + + /** The minimum amount to charge each group, regardless of usage */ + fun minimumCharge(minimumCharge: String) = + minimumCharge(JsonField.of(minimumCharge)) + + /** + * Sets [Builder.minimumCharge] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumCharge] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun minimumCharge(minimumCharge: JsonField) = apply { + this.minimumCharge = minimumCharge + } + + /** The base price charged per group */ + fun perUnitRate(perUnitRate: String) = + perUnitRate(JsonField.of(perUnitRate)) + + /** + * Sets [Builder.perUnitRate] to an arbitrary JSON value. + * + * You should usually call [Builder.perUnitRate] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun perUnitRate(perUnitRate: JsonField) = apply { + this.perUnitRate = perUnitRate + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -8504,9 +12427,25 @@ private constructor( * Returns an immutable instance of [GroupedWithMinMaxThresholdsConfig]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .maximumCharge() + * .minimumCharge() + * .perUnitRate() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ fun build(): GroupedWithMinMaxThresholdsConfig = - GroupedWithMinMaxThresholdsConfig(additionalProperties.toImmutable()) + GroupedWithMinMaxThresholdsConfig( + checkRequired("groupingKey", groupingKey), + checkRequired("maximumCharge", maximumCharge), + checkRequired("minimumCharge", minimumCharge), + checkRequired("perUnitRate", perUnitRate), + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false @@ -8516,6 +12455,10 @@ private constructor( return@apply } + groupingKey() + maximumCharge() + minimumCharge() + perUnitRate() validated = true } @@ -8534,9 +12477,10 @@ private constructor( * Used for best match union deserialization. */ internal fun validity(): Int = - additionalProperties.count { (_, value) -> - !value.isNull() && !value.isMissing() - } + (if (groupingKey.asKnown() == null) 0 else 1) + + (if (maximumCharge.asKnown() == null) 0 else 1) + + (if (minimumCharge.asKnown() == null) 0 else 1) + + (if (perUnitRate.asKnown() == null) 0 else 1) override fun equals(other: Any?): Boolean { if (this === other) { @@ -8544,15 +12488,27 @@ private constructor( } return other is GroupedWithMinMaxThresholdsConfig && + groupingKey == other.groupingKey && + maximumCharge == other.maximumCharge && + minimumCharge == other.minimumCharge && + perUnitRate == other.perUnitRate && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + private val hashCode: Int by lazy { + Objects.hash( + groupingKey, + maximumCharge, + minimumCharge, + perUnitRate, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode override fun toString() = - "GroupedWithMinMaxThresholdsConfig{additionalProperties=$additionalProperties}" + "GroupedWithMinMaxThresholdsConfig{groupingKey=$groupingKey, maximumCharge=$maximumCharge, minimumCharge=$minimumCharge, perUnitRate=$perUnitRate, additionalProperties=$additionalProperties}" } /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BulkConfig.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BulkConfig.kt index 7cbe4a050..16c86e250 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BulkConfig.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BulkConfig.kt @@ -17,6 +17,7 @@ import com.withorb.api.errors.OrbInvalidDataException import java.util.Collections import java.util.Objects +/** Configuration for bulk pricing */ class BulkConfig private constructor( private val tiers: JsonField>, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BulkTier.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BulkTier.kt index 33ea995d9..f87f68722 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BulkTier.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BulkTier.kt @@ -15,6 +15,7 @@ import com.withorb.api.errors.OrbInvalidDataException import java.util.Collections import java.util.Objects +/** Configuration for a single bulk pricing tier */ class BulkTier private constructor( private val unitAmount: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreateParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreateParams.kt index e0d2fc7a7..f393a59b8 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreateParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreateParams.kt @@ -76,7 +76,8 @@ private constructor( /** * Additional email addresses for this customer. If populated, these email addresses will be - * CC'd for customer communications. + * CC'd for customer communications. The total number of email addresses (including the primary + * email) cannot exceed 50. * * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server * responded with an unexpected value). @@ -583,7 +584,8 @@ private constructor( /** * Additional email addresses for this customer. If populated, these email addresses will be - * CC'd for customer communications. + * CC'd for customer communications. The total number of email addresses (including the + * primary email) cannot exceed 50. */ fun additionalEmails(additionalEmails: List?) = apply { body.additionalEmails(additionalEmails) @@ -897,6 +899,23 @@ private constructor( body.sphereTaxConfiguration(taxExempt) } + /** Alias for calling [taxConfiguration] with `TaxConfiguration.ofNumeral(numeral)`. */ + fun taxConfiguration(numeral: TaxConfiguration.Numeral) = apply { + body.taxConfiguration(numeral) + } + + /** + * Alias for calling [taxConfiguration] with the following: + * ```kotlin + * TaxConfiguration.Numeral.builder() + * .taxExempt(taxExempt) + * .build() + * ``` + */ + fun numeralTaxConfiguration(taxExempt: Boolean) = apply { + body.numeralTaxConfiguration(taxExempt) + } + /** * Tax IDs are commonly required to be displayed on customer invoices, which are added to * the headers of invoices. @@ -1339,7 +1358,8 @@ private constructor( /** * Additional email addresses for this customer. If populated, these email addresses will be - * CC'd for customer communications. + * CC'd for customer communications. The total number of email addresses (including the + * primary email) cannot exceed 50. * * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -1906,7 +1926,8 @@ private constructor( /** * Additional email addresses for this customer. If populated, these email addresses - * will be CC'd for customer communications. + * will be CC'd for customer communications. The total number of email addresses + * (including the primary email) cannot exceed 50. */ fun additionalEmails(additionalEmails: List?) = additionalEmails(JsonField.ofNullable(additionalEmails)) @@ -2228,6 +2249,21 @@ private constructor( .build() ) + /** Alias for calling [taxConfiguration] with `TaxConfiguration.ofNumeral(numeral)`. */ + fun taxConfiguration(numeral: TaxConfiguration.Numeral) = + taxConfiguration(TaxConfiguration.ofNumeral(numeral)) + + /** + * Alias for calling [taxConfiguration] with the following: + * ```kotlin + * TaxConfiguration.Numeral.builder() + * .taxExempt(taxExempt) + * .build() + * ``` + */ + fun numeralTaxConfiguration(taxExempt: Boolean) = + taxConfiguration(TaxConfiguration.Numeral.builder().taxExempt(taxExempt).build()) + /** * Tax IDs are commonly required to be displayed on customer invoices, which are added * to the headers of invoices. @@ -2839,6 +2875,7 @@ private constructor( private val avalara: NewAvalaraTaxConfiguration? = null, private val taxjar: NewTaxJarConfiguration? = null, private val sphere: NewSphereConfiguration? = null, + private val numeral: Numeral? = null, private val _json: JsonValue? = null, ) { @@ -2848,18 +2885,24 @@ private constructor( fun sphere(): NewSphereConfiguration? = sphere + fun numeral(): Numeral? = numeral + fun isAvalara(): Boolean = avalara != null fun isTaxjar(): Boolean = taxjar != null fun isSphere(): Boolean = sphere != null + fun isNumeral(): Boolean = numeral != null + fun asAvalara(): NewAvalaraTaxConfiguration = avalara.getOrThrow("avalara") fun asTaxjar(): NewTaxJarConfiguration = taxjar.getOrThrow("taxjar") fun asSphere(): NewSphereConfiguration = sphere.getOrThrow("sphere") + fun asNumeral(): Numeral = numeral.getOrThrow("numeral") + fun _json(): JsonValue? = _json fun accept(visitor: Visitor): T = @@ -2867,6 +2910,7 @@ private constructor( avalara != null -> visitor.visitAvalara(avalara) taxjar != null -> visitor.visitTaxjar(taxjar) sphere != null -> visitor.visitSphere(sphere) + numeral != null -> visitor.visitNumeral(numeral) else -> visitor.unknown(_json) } @@ -2890,6 +2934,10 @@ private constructor( override fun visitSphere(sphere: NewSphereConfiguration) { sphere.validate() } + + override fun visitNumeral(numeral: Numeral) { + numeral.validate() + } } ) validated = true @@ -2919,6 +2967,8 @@ private constructor( override fun visitSphere(sphere: NewSphereConfiguration) = sphere.validity() + override fun visitNumeral(numeral: Numeral) = numeral.validity() + override fun unknown(json: JsonValue?) = 0 } ) @@ -2931,16 +2981,18 @@ private constructor( return other is TaxConfiguration && avalara == other.avalara && taxjar == other.taxjar && - sphere == other.sphere + sphere == other.sphere && + numeral == other.numeral } - override fun hashCode(): Int = Objects.hash(avalara, taxjar, sphere) + override fun hashCode(): Int = Objects.hash(avalara, taxjar, sphere, numeral) override fun toString(): String = when { avalara != null -> "TaxConfiguration{avalara=$avalara}" taxjar != null -> "TaxConfiguration{taxjar=$taxjar}" sphere != null -> "TaxConfiguration{sphere=$sphere}" + numeral != null -> "TaxConfiguration{numeral=$numeral}" _json != null -> "TaxConfiguration{_unknown=$_json}" else -> throw IllegalStateException("Invalid TaxConfiguration") } @@ -2952,6 +3004,8 @@ private constructor( fun ofTaxjar(taxjar: NewTaxJarConfiguration) = TaxConfiguration(taxjar = taxjar) fun ofSphere(sphere: NewSphereConfiguration) = TaxConfiguration(sphere = sphere) + + fun ofNumeral(numeral: Numeral) = TaxConfiguration(numeral = numeral) } /** @@ -2966,6 +3020,8 @@ private constructor( fun visitSphere(sphere: NewSphereConfiguration): T + fun visitNumeral(numeral: Numeral): T + /** * Maps an unknown variant of [TaxConfiguration] to a value of type [T]. * @@ -3003,6 +3059,11 @@ private constructor( TaxConfiguration(sphere = it, _json = json) } ?: TaxConfiguration(_json = json) } + "numeral" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + TaxConfiguration(numeral = it, _json = json) + } ?: TaxConfiguration(_json = json) + } } return TaxConfiguration(_json = json) @@ -3020,11 +3081,219 @@ private constructor( value.avalara != null -> generator.writeObject(value.avalara) value.taxjar != null -> generator.writeObject(value.taxjar) value.sphere != null -> generator.writeObject(value.sphere) + value.numeral != null -> generator.writeObject(value.numeral) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid TaxConfiguration") } } } + + class Numeral + private constructor( + private val taxExempt: JsonField, + private val taxProvider: JsonValue, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("tax_exempt") + @ExcludeMissing + taxExempt: JsonField = JsonMissing.of(), + @JsonProperty("tax_provider") + @ExcludeMissing + taxProvider: JsonValue = JsonMissing.of(), + ) : this(taxExempt, taxProvider, mutableMapOf()) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun taxExempt(): Boolean = taxExempt.getRequired("tax_exempt") + + /** + * Expected to always return the following: + * ```kotlin + * JsonValue.from("numeral") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("tax_provider") + @ExcludeMissing + fun _taxProvider(): JsonValue = taxProvider + + /** + * Returns the raw JSON value of [taxExempt]. + * + * Unlike [taxExempt], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tax_exempt") + @ExcludeMissing + fun _taxExempt(): JsonField = taxExempt + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Numeral]. + * + * The following fields are required: + * ```kotlin + * .taxExempt() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Numeral]. */ + class Builder internal constructor() { + + private var taxExempt: JsonField? = null + private var taxProvider: JsonValue = JsonValue.from("numeral") + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(numeral: Numeral) = apply { + taxExempt = numeral.taxExempt + taxProvider = numeral.taxProvider + additionalProperties = numeral.additionalProperties.toMutableMap() + } + + fun taxExempt(taxExempt: Boolean) = taxExempt(JsonField.of(taxExempt)) + + /** + * Sets [Builder.taxExempt] to an arbitrary JSON value. + * + * You should usually call [Builder.taxExempt] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun taxExempt(taxExempt: JsonField) = apply { this.taxExempt = taxExempt } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```kotlin + * JsonValue.from("numeral") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun taxProvider(taxProvider: JsonValue) = apply { this.taxProvider = taxProvider } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Numeral]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .taxExempt() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Numeral = + Numeral( + checkRequired("taxExempt", taxExempt), + taxProvider, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Numeral = apply { + if (validated) { + return@apply + } + + taxExempt() + _taxProvider().let { + if (it != JsonValue.from("numeral")) { + throw OrbInvalidDataException("'taxProvider' is invalid, received $it") + } + } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (taxExempt.asKnown() == null) 0 else 1) + + taxProvider.let { if (it == JsonValue.from("numeral")) 1 else 0 } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Numeral && + taxExempt == other.taxExempt && + taxProvider == other.taxProvider && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(taxExempt, taxProvider, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Numeral{taxExempt=$taxExempt, taxProvider=$taxProvider, additionalProperties=$additionalProperties}" + } } override fun equals(other: Any?): Boolean { diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerUpdateByExternalIdParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerUpdateByExternalIdParams.kt index 014421728..cc7e088f4 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerUpdateByExternalIdParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerUpdateByExternalIdParams.kt @@ -22,6 +22,7 @@ import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.Params import com.withorb.api.core.checkKnown +import com.withorb.api.core.checkRequired import com.withorb.api.core.getOrThrow import com.withorb.api.core.http.Headers import com.withorb.api.core.http.QueryParams @@ -54,7 +55,8 @@ private constructor( /** * Additional email addresses for this customer. If populated, these email addresses will be - * CC'd for customer communications. + * CC'd for customer communications. The total number of email addresses (including the primary + * email) cannot exceed 50. * * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server * responded with an unexpected value). @@ -542,7 +544,8 @@ private constructor( /** * Additional email addresses for this customer. If populated, these email addresses will be - * CC'd for customer communications. + * CC'd for customer communications. The total number of email addresses (including the + * primary email) cannot exceed 50. */ fun additionalEmails(additionalEmails: List?) = apply { body.additionalEmails(additionalEmails) @@ -882,6 +885,23 @@ private constructor( body.sphereTaxConfiguration(taxExempt) } + /** Alias for calling [taxConfiguration] with `TaxConfiguration.ofNumeral(numeral)`. */ + fun taxConfiguration(numeral: TaxConfiguration.Numeral) = apply { + body.taxConfiguration(numeral) + } + + /** + * Alias for calling [taxConfiguration] with the following: + * ```kotlin + * TaxConfiguration.Numeral.builder() + * .taxExempt(taxExempt) + * .build() + * ``` + */ + fun numeralTaxConfiguration(taxExempt: Boolean) = apply { + body.numeralTaxConfiguration(taxExempt) + } + /** * Tax IDs are commonly required to be displayed on customer invoices, which are added to * the headers of invoices. @@ -1288,7 +1308,8 @@ private constructor( /** * Additional email addresses for this customer. If populated, these email addresses will be - * CC'd for customer communications. + * CC'd for customer communications. The total number of email addresses (including the + * primary email) cannot exceed 50. * * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -1820,7 +1841,8 @@ private constructor( /** * Additional email addresses for this customer. If populated, these email addresses - * will be CC'd for customer communications. + * will be CC'd for customer communications. The total number of email addresses + * (including the primary email) cannot exceed 50. */ fun additionalEmails(additionalEmails: List?) = additionalEmails(JsonField.ofNullable(additionalEmails)) @@ -2171,6 +2193,21 @@ private constructor( .build() ) + /** Alias for calling [taxConfiguration] with `TaxConfiguration.ofNumeral(numeral)`. */ + fun taxConfiguration(numeral: TaxConfiguration.Numeral) = + taxConfiguration(TaxConfiguration.ofNumeral(numeral)) + + /** + * Alias for calling [taxConfiguration] with the following: + * ```kotlin + * TaxConfiguration.Numeral.builder() + * .taxExempt(taxExempt) + * .build() + * ``` + */ + fun numeralTaxConfiguration(taxExempt: Boolean) = + taxConfiguration(TaxConfiguration.Numeral.builder().taxExempt(taxExempt).build()) + /** * Tax IDs are commonly required to be displayed on customer invoices, which are added * to the headers of invoices. @@ -2756,6 +2793,7 @@ private constructor( private val avalara: NewAvalaraTaxConfiguration? = null, private val taxjar: NewTaxJarConfiguration? = null, private val sphere: NewSphereConfiguration? = null, + private val numeral: Numeral? = null, private val _json: JsonValue? = null, ) { @@ -2765,18 +2803,24 @@ private constructor( fun sphere(): NewSphereConfiguration? = sphere + fun numeral(): Numeral? = numeral + fun isAvalara(): Boolean = avalara != null fun isTaxjar(): Boolean = taxjar != null fun isSphere(): Boolean = sphere != null + fun isNumeral(): Boolean = numeral != null + fun asAvalara(): NewAvalaraTaxConfiguration = avalara.getOrThrow("avalara") fun asTaxjar(): NewTaxJarConfiguration = taxjar.getOrThrow("taxjar") fun asSphere(): NewSphereConfiguration = sphere.getOrThrow("sphere") + fun asNumeral(): Numeral = numeral.getOrThrow("numeral") + fun _json(): JsonValue? = _json fun accept(visitor: Visitor): T = @@ -2784,6 +2828,7 @@ private constructor( avalara != null -> visitor.visitAvalara(avalara) taxjar != null -> visitor.visitTaxjar(taxjar) sphere != null -> visitor.visitSphere(sphere) + numeral != null -> visitor.visitNumeral(numeral) else -> visitor.unknown(_json) } @@ -2807,6 +2852,10 @@ private constructor( override fun visitSphere(sphere: NewSphereConfiguration) { sphere.validate() } + + override fun visitNumeral(numeral: Numeral) { + numeral.validate() + } } ) validated = true @@ -2836,6 +2885,8 @@ private constructor( override fun visitSphere(sphere: NewSphereConfiguration) = sphere.validity() + override fun visitNumeral(numeral: Numeral) = numeral.validity() + override fun unknown(json: JsonValue?) = 0 } ) @@ -2848,16 +2899,18 @@ private constructor( return other is TaxConfiguration && avalara == other.avalara && taxjar == other.taxjar && - sphere == other.sphere + sphere == other.sphere && + numeral == other.numeral } - override fun hashCode(): Int = Objects.hash(avalara, taxjar, sphere) + override fun hashCode(): Int = Objects.hash(avalara, taxjar, sphere, numeral) override fun toString(): String = when { avalara != null -> "TaxConfiguration{avalara=$avalara}" taxjar != null -> "TaxConfiguration{taxjar=$taxjar}" sphere != null -> "TaxConfiguration{sphere=$sphere}" + numeral != null -> "TaxConfiguration{numeral=$numeral}" _json != null -> "TaxConfiguration{_unknown=$_json}" else -> throw IllegalStateException("Invalid TaxConfiguration") } @@ -2869,6 +2922,8 @@ private constructor( fun ofTaxjar(taxjar: NewTaxJarConfiguration) = TaxConfiguration(taxjar = taxjar) fun ofSphere(sphere: NewSphereConfiguration) = TaxConfiguration(sphere = sphere) + + fun ofNumeral(numeral: Numeral) = TaxConfiguration(numeral = numeral) } /** @@ -2883,6 +2938,8 @@ private constructor( fun visitSphere(sphere: NewSphereConfiguration): T + fun visitNumeral(numeral: Numeral): T + /** * Maps an unknown variant of [TaxConfiguration] to a value of type [T]. * @@ -2920,6 +2977,11 @@ private constructor( TaxConfiguration(sphere = it, _json = json) } ?: TaxConfiguration(_json = json) } + "numeral" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + TaxConfiguration(numeral = it, _json = json) + } ?: TaxConfiguration(_json = json) + } } return TaxConfiguration(_json = json) @@ -2937,11 +2999,219 @@ private constructor( value.avalara != null -> generator.writeObject(value.avalara) value.taxjar != null -> generator.writeObject(value.taxjar) value.sphere != null -> generator.writeObject(value.sphere) + value.numeral != null -> generator.writeObject(value.numeral) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid TaxConfiguration") } } } + + class Numeral + private constructor( + private val taxExempt: JsonField, + private val taxProvider: JsonValue, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("tax_exempt") + @ExcludeMissing + taxExempt: JsonField = JsonMissing.of(), + @JsonProperty("tax_provider") + @ExcludeMissing + taxProvider: JsonValue = JsonMissing.of(), + ) : this(taxExempt, taxProvider, mutableMapOf()) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun taxExempt(): Boolean = taxExempt.getRequired("tax_exempt") + + /** + * Expected to always return the following: + * ```kotlin + * JsonValue.from("numeral") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("tax_provider") + @ExcludeMissing + fun _taxProvider(): JsonValue = taxProvider + + /** + * Returns the raw JSON value of [taxExempt]. + * + * Unlike [taxExempt], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tax_exempt") + @ExcludeMissing + fun _taxExempt(): JsonField = taxExempt + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Numeral]. + * + * The following fields are required: + * ```kotlin + * .taxExempt() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Numeral]. */ + class Builder internal constructor() { + + private var taxExempt: JsonField? = null + private var taxProvider: JsonValue = JsonValue.from("numeral") + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(numeral: Numeral) = apply { + taxExempt = numeral.taxExempt + taxProvider = numeral.taxProvider + additionalProperties = numeral.additionalProperties.toMutableMap() + } + + fun taxExempt(taxExempt: Boolean) = taxExempt(JsonField.of(taxExempt)) + + /** + * Sets [Builder.taxExempt] to an arbitrary JSON value. + * + * You should usually call [Builder.taxExempt] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun taxExempt(taxExempt: JsonField) = apply { this.taxExempt = taxExempt } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```kotlin + * JsonValue.from("numeral") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun taxProvider(taxProvider: JsonValue) = apply { this.taxProvider = taxProvider } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Numeral]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .taxExempt() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Numeral = + Numeral( + checkRequired("taxExempt", taxExempt), + taxProvider, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Numeral = apply { + if (validated) { + return@apply + } + + taxExempt() + _taxProvider().let { + if (it != JsonValue.from("numeral")) { + throw OrbInvalidDataException("'taxProvider' is invalid, received $it") + } + } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (taxExempt.asKnown() == null) 0 else 1) + + taxProvider.let { if (it == JsonValue.from("numeral")) 1 else 0 } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Numeral && + taxExempt == other.taxExempt && + taxProvider == other.taxProvider && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(taxExempt, taxProvider, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Numeral{taxExempt=$taxExempt, taxProvider=$taxProvider, additionalProperties=$additionalProperties}" + } } override fun equals(other: Any?): Boolean { diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerUpdateParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerUpdateParams.kt index 52b8cd556..df1deeba5 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerUpdateParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerUpdateParams.kt @@ -22,6 +22,7 @@ import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.Params import com.withorb.api.core.checkKnown +import com.withorb.api.core.checkRequired import com.withorb.api.core.getOrThrow import com.withorb.api.core.http.Headers import com.withorb.api.core.http.QueryParams @@ -55,7 +56,8 @@ private constructor( /** * Additional email addresses for this customer. If populated, these email addresses will be - * CC'd for customer communications. + * CC'd for customer communications. The total number of email addresses (including the primary + * email) cannot exceed 50. * * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server * responded with an unexpected value). @@ -538,7 +540,8 @@ private constructor( /** * Additional email addresses for this customer. If populated, these email addresses will be - * CC'd for customer communications. + * CC'd for customer communications. The total number of email addresses (including the + * primary email) cannot exceed 50. */ fun additionalEmails(additionalEmails: List?) = apply { body.additionalEmails(additionalEmails) @@ -878,6 +881,23 @@ private constructor( body.sphereTaxConfiguration(taxExempt) } + /** Alias for calling [taxConfiguration] with `TaxConfiguration.ofNumeral(numeral)`. */ + fun taxConfiguration(numeral: TaxConfiguration.Numeral) = apply { + body.taxConfiguration(numeral) + } + + /** + * Alias for calling [taxConfiguration] with the following: + * ```kotlin + * TaxConfiguration.Numeral.builder() + * .taxExempt(taxExempt) + * .build() + * ``` + */ + fun numeralTaxConfiguration(taxExempt: Boolean) = apply { + body.numeralTaxConfiguration(taxExempt) + } + /** * Tax IDs are commonly required to be displayed on customer invoices, which are added to * the headers of invoices. @@ -1284,7 +1304,8 @@ private constructor( /** * Additional email addresses for this customer. If populated, these email addresses will be - * CC'd for customer communications. + * CC'd for customer communications. The total number of email addresses (including the + * primary email) cannot exceed 50. * * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -1816,7 +1837,8 @@ private constructor( /** * Additional email addresses for this customer. If populated, these email addresses - * will be CC'd for customer communications. + * will be CC'd for customer communications. The total number of email addresses + * (including the primary email) cannot exceed 50. */ fun additionalEmails(additionalEmails: List?) = additionalEmails(JsonField.ofNullable(additionalEmails)) @@ -2167,6 +2189,21 @@ private constructor( .build() ) + /** Alias for calling [taxConfiguration] with `TaxConfiguration.ofNumeral(numeral)`. */ + fun taxConfiguration(numeral: TaxConfiguration.Numeral) = + taxConfiguration(TaxConfiguration.ofNumeral(numeral)) + + /** + * Alias for calling [taxConfiguration] with the following: + * ```kotlin + * TaxConfiguration.Numeral.builder() + * .taxExempt(taxExempt) + * .build() + * ``` + */ + fun numeralTaxConfiguration(taxExempt: Boolean) = + taxConfiguration(TaxConfiguration.Numeral.builder().taxExempt(taxExempt).build()) + /** * Tax IDs are commonly required to be displayed on customer invoices, which are added * to the headers of invoices. @@ -2752,6 +2789,7 @@ private constructor( private val avalara: NewAvalaraTaxConfiguration? = null, private val taxjar: NewTaxJarConfiguration? = null, private val sphere: NewSphereConfiguration? = null, + private val numeral: Numeral? = null, private val _json: JsonValue? = null, ) { @@ -2761,18 +2799,24 @@ private constructor( fun sphere(): NewSphereConfiguration? = sphere + fun numeral(): Numeral? = numeral + fun isAvalara(): Boolean = avalara != null fun isTaxjar(): Boolean = taxjar != null fun isSphere(): Boolean = sphere != null + fun isNumeral(): Boolean = numeral != null + fun asAvalara(): NewAvalaraTaxConfiguration = avalara.getOrThrow("avalara") fun asTaxjar(): NewTaxJarConfiguration = taxjar.getOrThrow("taxjar") fun asSphere(): NewSphereConfiguration = sphere.getOrThrow("sphere") + fun asNumeral(): Numeral = numeral.getOrThrow("numeral") + fun _json(): JsonValue? = _json fun accept(visitor: Visitor): T = @@ -2780,6 +2824,7 @@ private constructor( avalara != null -> visitor.visitAvalara(avalara) taxjar != null -> visitor.visitTaxjar(taxjar) sphere != null -> visitor.visitSphere(sphere) + numeral != null -> visitor.visitNumeral(numeral) else -> visitor.unknown(_json) } @@ -2803,6 +2848,10 @@ private constructor( override fun visitSphere(sphere: NewSphereConfiguration) { sphere.validate() } + + override fun visitNumeral(numeral: Numeral) { + numeral.validate() + } } ) validated = true @@ -2832,6 +2881,8 @@ private constructor( override fun visitSphere(sphere: NewSphereConfiguration) = sphere.validity() + override fun visitNumeral(numeral: Numeral) = numeral.validity() + override fun unknown(json: JsonValue?) = 0 } ) @@ -2844,16 +2895,18 @@ private constructor( return other is TaxConfiguration && avalara == other.avalara && taxjar == other.taxjar && - sphere == other.sphere + sphere == other.sphere && + numeral == other.numeral } - override fun hashCode(): Int = Objects.hash(avalara, taxjar, sphere) + override fun hashCode(): Int = Objects.hash(avalara, taxjar, sphere, numeral) override fun toString(): String = when { avalara != null -> "TaxConfiguration{avalara=$avalara}" taxjar != null -> "TaxConfiguration{taxjar=$taxjar}" sphere != null -> "TaxConfiguration{sphere=$sphere}" + numeral != null -> "TaxConfiguration{numeral=$numeral}" _json != null -> "TaxConfiguration{_unknown=$_json}" else -> throw IllegalStateException("Invalid TaxConfiguration") } @@ -2865,6 +2918,8 @@ private constructor( fun ofTaxjar(taxjar: NewTaxJarConfiguration) = TaxConfiguration(taxjar = taxjar) fun ofSphere(sphere: NewSphereConfiguration) = TaxConfiguration(sphere = sphere) + + fun ofNumeral(numeral: Numeral) = TaxConfiguration(numeral = numeral) } /** @@ -2879,6 +2934,8 @@ private constructor( fun visitSphere(sphere: NewSphereConfiguration): T + fun visitNumeral(numeral: Numeral): T + /** * Maps an unknown variant of [TaxConfiguration] to a value of type [T]. * @@ -2916,6 +2973,11 @@ private constructor( TaxConfiguration(sphere = it, _json = json) } ?: TaxConfiguration(_json = json) } + "numeral" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + TaxConfiguration(numeral = it, _json = json) + } ?: TaxConfiguration(_json = json) + } } return TaxConfiguration(_json = json) @@ -2933,11 +2995,219 @@ private constructor( value.avalara != null -> generator.writeObject(value.avalara) value.taxjar != null -> generator.writeObject(value.taxjar) value.sphere != null -> generator.writeObject(value.sphere) + value.numeral != null -> generator.writeObject(value.numeral) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid TaxConfiguration") } } } + + class Numeral + private constructor( + private val taxExempt: JsonField, + private val taxProvider: JsonValue, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("tax_exempt") + @ExcludeMissing + taxExempt: JsonField = JsonMissing.of(), + @JsonProperty("tax_provider") + @ExcludeMissing + taxProvider: JsonValue = JsonMissing.of(), + ) : this(taxExempt, taxProvider, mutableMapOf()) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun taxExempt(): Boolean = taxExempt.getRequired("tax_exempt") + + /** + * Expected to always return the following: + * ```kotlin + * JsonValue.from("numeral") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("tax_provider") + @ExcludeMissing + fun _taxProvider(): JsonValue = taxProvider + + /** + * Returns the raw JSON value of [taxExempt]. + * + * Unlike [taxExempt], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tax_exempt") + @ExcludeMissing + fun _taxExempt(): JsonField = taxExempt + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Numeral]. + * + * The following fields are required: + * ```kotlin + * .taxExempt() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Numeral]. */ + class Builder internal constructor() { + + private var taxExempt: JsonField? = null + private var taxProvider: JsonValue = JsonValue.from("numeral") + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(numeral: Numeral) = apply { + taxExempt = numeral.taxExempt + taxProvider = numeral.taxProvider + additionalProperties = numeral.additionalProperties.toMutableMap() + } + + fun taxExempt(taxExempt: Boolean) = taxExempt(JsonField.of(taxExempt)) + + /** + * Sets [Builder.taxExempt] to an arbitrary JSON value. + * + * You should usually call [Builder.taxExempt] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun taxExempt(taxExempt: JsonField) = apply { this.taxExempt = taxExempt } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```kotlin + * JsonValue.from("numeral") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun taxProvider(taxProvider: JsonValue) = apply { this.taxProvider = taxProvider } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Numeral]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .taxExempt() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Numeral = + Numeral( + checkRequired("taxExempt", taxExempt), + taxProvider, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Numeral = apply { + if (validated) { + return@apply + } + + taxExempt() + _taxProvider().let { + if (it != JsonValue.from("numeral")) { + throw OrbInvalidDataException("'taxProvider' is invalid, received $it") + } + } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (taxExempt.asKnown() == null) 0 else 1) + + taxProvider.let { if (it == JsonValue.from("numeral")) 1 else 0 } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Numeral && + taxExempt == other.taxExempt && + taxProvider == other.taxProvider && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(taxExempt, taxProvider, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Numeral{taxExempt=$taxExempt, taxProvider=$taxProvider, additionalProperties=$additionalProperties}" + } } override fun equals(other: Any?): Boolean { diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Invoice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Invoice.kt index b23046bd3..ab948f2e0 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Invoice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Invoice.kt @@ -4897,18 +4897,18 @@ private constructor( /** Alias for calling [price] with `Price.ofUnit(unit)`. */ fun price(unit: Price.Unit) = price(Price.ofUnit(unit)) - /** Alias for calling [price] with `Price.ofPackage(package_)`. */ - fun price(package_: Price.Package) = price(Price.ofPackage(package_)) - - /** Alias for calling [price] with `Price.ofMatrix(matrix)`. */ - fun price(matrix: Price.Matrix) = price(Price.ofMatrix(matrix)) - /** Alias for calling [price] with `Price.ofTiered(tiered)`. */ fun price(tiered: Price.Tiered) = price(Price.ofTiered(tiered)) /** Alias for calling [price] with `Price.ofBulk(bulk)`. */ fun price(bulk: Price.Bulk) = price(Price.ofBulk(bulk)) + /** Alias for calling [price] with `Price.ofPackage(package_)`. */ + fun price(package_: Price.Package) = price(Price.ofPackage(package_)) + + /** Alias for calling [price] with `Price.ofMatrix(matrix)`. */ + fun price(matrix: Price.Matrix) = price(Price.ofMatrix(matrix)) + /** * Alias for calling [price] with `Price.ofThresholdTotalAmount(thresholdTotalAmount)`. */ @@ -4919,14 +4919,14 @@ private constructor( fun price(tieredPackage: Price.TieredPackage) = price(Price.ofTieredPackage(tieredPackage)) - /** Alias for calling [price] with `Price.ofGroupedTiered(groupedTiered)`. */ - fun price(groupedTiered: Price.GroupedTiered) = - price(Price.ofGroupedTiered(groupedTiered)) - /** Alias for calling [price] with `Price.ofTieredWithMinimum(tieredWithMinimum)`. */ fun price(tieredWithMinimum: Price.TieredWithMinimum) = price(Price.ofTieredWithMinimum(tieredWithMinimum)) + /** Alias for calling [price] with `Price.ofGroupedTiered(groupedTiered)`. */ + fun price(groupedTiered: Price.GroupedTiered) = + price(Price.ofGroupedTiered(groupedTiered)) + /** * Alias for calling [price] with * `Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)`. @@ -4965,6 +4965,10 @@ private constructor( fun price(groupedAllocation: Price.GroupedAllocation) = price(Price.ofGroupedAllocation(groupedAllocation)) + /** Alias for calling [price] with `Price.ofBulkWithProration(bulkWithProration)`. */ + fun price(bulkWithProration: Price.BulkWithProration) = + price(Price.ofBulkWithProration(bulkWithProration)) + /** * Alias for calling [price] with * `Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)`. @@ -4979,6 +4983,13 @@ private constructor( fun price(groupedWithMeteredMinimum: Price.GroupedWithMeteredMinimum) = price(Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)) + /** + * Alias for calling [price] with + * `Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)`. + */ + fun price(groupedWithMinMaxThresholds: Price.GroupedWithMinMaxThresholds) = + price(Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)) + /** * Alias for calling [price] with * `Price.ofMatrixWithDisplayName(matrixWithDisplayName)`. @@ -4986,10 +4997,6 @@ private constructor( fun price(matrixWithDisplayName: Price.MatrixWithDisplayName) = price(Price.ofMatrixWithDisplayName(matrixWithDisplayName)) - /** Alias for calling [price] with `Price.ofBulkWithProration(bulkWithProration)`. */ - fun price(bulkWithProration: Price.BulkWithProration) = - price(Price.ofBulkWithProration(bulkWithProration)) - /** * Alias for calling [price] with `Price.ofGroupedTieredPackage(groupedTieredPackage)`. */ @@ -5024,13 +5031,6 @@ private constructor( fun price(cumulativeGroupedBulk: Price.CumulativeGroupedBulk) = price(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) - /** - * Alias for calling [price] with - * `Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)`. - */ - fun price(groupedWithMinMaxThresholds: Price.GroupedWithMinMaxThresholds) = - price(Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)) - /** Alias for calling [price] with `Price.ofMinimum(minimum)`. */ fun price(minimum: Price.Minimum) = price(Price.ofMinimum(minimum)) diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceCreateParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceCreateParams.kt index 7d666218b..1cfb06679 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceCreateParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceCreateParams.kt @@ -1433,6 +1433,8 @@ private constructor( fun startDate(): LocalDate = startDate.getRequired("start_date") /** + * Configuration for unit pricing + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ @@ -1617,6 +1619,7 @@ private constructor( */ fun startDate(startDate: JsonField) = apply { this.startDate = startDate } + /** Configuration for unit pricing */ fun unitConfig(unitConfig: UnitConfig) = unitConfig(JsonField.of(unitConfig)) /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceFetchUpcomingResponse.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceFetchUpcomingResponse.kt index c233b6e74..2428d7bd6 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceFetchUpcomingResponse.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceFetchUpcomingResponse.kt @@ -4891,18 +4891,18 @@ private constructor( /** Alias for calling [price] with `Price.ofUnit(unit)`. */ fun price(unit: Price.Unit) = price(Price.ofUnit(unit)) - /** Alias for calling [price] with `Price.ofPackage(package_)`. */ - fun price(package_: Price.Package) = price(Price.ofPackage(package_)) - - /** Alias for calling [price] with `Price.ofMatrix(matrix)`. */ - fun price(matrix: Price.Matrix) = price(Price.ofMatrix(matrix)) - /** Alias for calling [price] with `Price.ofTiered(tiered)`. */ fun price(tiered: Price.Tiered) = price(Price.ofTiered(tiered)) /** Alias for calling [price] with `Price.ofBulk(bulk)`. */ fun price(bulk: Price.Bulk) = price(Price.ofBulk(bulk)) + /** Alias for calling [price] with `Price.ofPackage(package_)`. */ + fun price(package_: Price.Package) = price(Price.ofPackage(package_)) + + /** Alias for calling [price] with `Price.ofMatrix(matrix)`. */ + fun price(matrix: Price.Matrix) = price(Price.ofMatrix(matrix)) + /** * Alias for calling [price] with `Price.ofThresholdTotalAmount(thresholdTotalAmount)`. */ @@ -4913,14 +4913,14 @@ private constructor( fun price(tieredPackage: Price.TieredPackage) = price(Price.ofTieredPackage(tieredPackage)) - /** Alias for calling [price] with `Price.ofGroupedTiered(groupedTiered)`. */ - fun price(groupedTiered: Price.GroupedTiered) = - price(Price.ofGroupedTiered(groupedTiered)) - /** Alias for calling [price] with `Price.ofTieredWithMinimum(tieredWithMinimum)`. */ fun price(tieredWithMinimum: Price.TieredWithMinimum) = price(Price.ofTieredWithMinimum(tieredWithMinimum)) + /** Alias for calling [price] with `Price.ofGroupedTiered(groupedTiered)`. */ + fun price(groupedTiered: Price.GroupedTiered) = + price(Price.ofGroupedTiered(groupedTiered)) + /** * Alias for calling [price] with * `Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)`. @@ -4959,6 +4959,10 @@ private constructor( fun price(groupedAllocation: Price.GroupedAllocation) = price(Price.ofGroupedAllocation(groupedAllocation)) + /** Alias for calling [price] with `Price.ofBulkWithProration(bulkWithProration)`. */ + fun price(bulkWithProration: Price.BulkWithProration) = + price(Price.ofBulkWithProration(bulkWithProration)) + /** * Alias for calling [price] with * `Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)`. @@ -4973,6 +4977,13 @@ private constructor( fun price(groupedWithMeteredMinimum: Price.GroupedWithMeteredMinimum) = price(Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)) + /** + * Alias for calling [price] with + * `Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)`. + */ + fun price(groupedWithMinMaxThresholds: Price.GroupedWithMinMaxThresholds) = + price(Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)) + /** * Alias for calling [price] with * `Price.ofMatrixWithDisplayName(matrixWithDisplayName)`. @@ -4980,10 +4991,6 @@ private constructor( fun price(matrixWithDisplayName: Price.MatrixWithDisplayName) = price(Price.ofMatrixWithDisplayName(matrixWithDisplayName)) - /** Alias for calling [price] with `Price.ofBulkWithProration(bulkWithProration)`. */ - fun price(bulkWithProration: Price.BulkWithProration) = - price(Price.ofBulkWithProration(bulkWithProration)) - /** * Alias for calling [price] with `Price.ofGroupedTieredPackage(groupedTieredPackage)`. */ @@ -5018,13 +5025,6 @@ private constructor( fun price(cumulativeGroupedBulk: Price.CumulativeGroupedBulk) = price(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) - /** - * Alias for calling [price] with - * `Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)`. - */ - fun price(groupedWithMinMaxThresholds: Price.GroupedWithMinMaxThresholds) = - price(Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)) - /** Alias for calling [price] with `Price.ofMinimum(minimum)`. */ fun price(minimum: Price.Minimum) = price(Price.ofMinimum(minimum)) diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceLineItemCreateResponse.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceLineItemCreateResponse.kt index 2b32b5ef3..61e610846 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceLineItemCreateResponse.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceLineItemCreateResponse.kt @@ -954,18 +954,18 @@ private constructor( /** Alias for calling [price] with `Price.ofUnit(unit)`. */ fun price(unit: Price.Unit) = price(Price.ofUnit(unit)) - /** Alias for calling [price] with `Price.ofPackage(package_)`. */ - fun price(package_: Price.Package) = price(Price.ofPackage(package_)) - - /** Alias for calling [price] with `Price.ofMatrix(matrix)`. */ - fun price(matrix: Price.Matrix) = price(Price.ofMatrix(matrix)) - /** Alias for calling [price] with `Price.ofTiered(tiered)`. */ fun price(tiered: Price.Tiered) = price(Price.ofTiered(tiered)) /** Alias for calling [price] with `Price.ofBulk(bulk)`. */ fun price(bulk: Price.Bulk) = price(Price.ofBulk(bulk)) + /** Alias for calling [price] with `Price.ofPackage(package_)`. */ + fun price(package_: Price.Package) = price(Price.ofPackage(package_)) + + /** Alias for calling [price] with `Price.ofMatrix(matrix)`. */ + fun price(matrix: Price.Matrix) = price(Price.ofMatrix(matrix)) + /** Alias for calling [price] with `Price.ofThresholdTotalAmount(thresholdTotalAmount)`. */ fun price(thresholdTotalAmount: Price.ThresholdTotalAmount) = price(Price.ofThresholdTotalAmount(thresholdTotalAmount)) @@ -973,13 +973,13 @@ private constructor( /** Alias for calling [price] with `Price.ofTieredPackage(tieredPackage)`. */ fun price(tieredPackage: Price.TieredPackage) = price(Price.ofTieredPackage(tieredPackage)) - /** Alias for calling [price] with `Price.ofGroupedTiered(groupedTiered)`. */ - fun price(groupedTiered: Price.GroupedTiered) = price(Price.ofGroupedTiered(groupedTiered)) - /** Alias for calling [price] with `Price.ofTieredWithMinimum(tieredWithMinimum)`. */ fun price(tieredWithMinimum: Price.TieredWithMinimum) = price(Price.ofTieredWithMinimum(tieredWithMinimum)) + /** Alias for calling [price] with `Price.ofGroupedTiered(groupedTiered)`. */ + fun price(groupedTiered: Price.GroupedTiered) = price(Price.ofGroupedTiered(groupedTiered)) + /** * Alias for calling [price] with * `Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)`. @@ -1013,6 +1013,10 @@ private constructor( fun price(groupedAllocation: Price.GroupedAllocation) = price(Price.ofGroupedAllocation(groupedAllocation)) + /** Alias for calling [price] with `Price.ofBulkWithProration(bulkWithProration)`. */ + fun price(bulkWithProration: Price.BulkWithProration) = + price(Price.ofBulkWithProration(bulkWithProration)) + /** * Alias for calling [price] with * `Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)`. @@ -1027,16 +1031,19 @@ private constructor( fun price(groupedWithMeteredMinimum: Price.GroupedWithMeteredMinimum) = price(Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)) + /** + * Alias for calling [price] with + * `Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)`. + */ + fun price(groupedWithMinMaxThresholds: Price.GroupedWithMinMaxThresholds) = + price(Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)) + /** * Alias for calling [price] with `Price.ofMatrixWithDisplayName(matrixWithDisplayName)`. */ fun price(matrixWithDisplayName: Price.MatrixWithDisplayName) = price(Price.ofMatrixWithDisplayName(matrixWithDisplayName)) - /** Alias for calling [price] with `Price.ofBulkWithProration(bulkWithProration)`. */ - fun price(bulkWithProration: Price.BulkWithProration) = - price(Price.ofBulkWithProration(bulkWithProration)) - /** Alias for calling [price] with `Price.ofGroupedTieredPackage(groupedTieredPackage)`. */ fun price(groupedTieredPackage: Price.GroupedTieredPackage) = price(Price.ofGroupedTieredPackage(groupedTieredPackage)) @@ -1067,13 +1074,6 @@ private constructor( fun price(cumulativeGroupedBulk: Price.CumulativeGroupedBulk) = price(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) - /** - * Alias for calling [price] with - * `Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)`. - */ - fun price(groupedWithMinMaxThresholds: Price.GroupedWithMinMaxThresholds) = - price(Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)) - /** Alias for calling [price] with `Price.ofMinimum(minimum)`. */ fun price(minimum: Price.Minimum) = price(Price.ofMinimum(minimum)) diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MatrixConfig.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MatrixConfig.kt index 03efe2165..49eea695f 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MatrixConfig.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MatrixConfig.kt @@ -17,6 +17,7 @@ import com.withorb.api.errors.OrbInvalidDataException import java.util.Collections import java.util.Objects +/** Configuration for matrix pricing */ class MatrixConfig private constructor( private val defaultUnitAmount: JsonField, @@ -55,7 +56,7 @@ private constructor( fun dimensions(): List = dimensions.getRequired("dimensions") /** - * Matrix values for specified matrix grouping keys + * Matrix values configuration * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). @@ -173,7 +174,7 @@ private constructor( } } - /** Matrix values for specified matrix grouping keys */ + /** Matrix values configuration */ fun matrixValues(matrixValues: List) = matrixValues(JsonField.of(matrixValues)) /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MatrixValue.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MatrixValue.kt index 8b8a473b6..1d4c1ff7a 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MatrixValue.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MatrixValue.kt @@ -17,6 +17,7 @@ import com.withorb.api.errors.OrbInvalidDataException import java.util.Collections import java.util.Objects +/** Configuration for a single matrix value */ class MatrixValue private constructor( private val dimensionValues: JsonField>, @@ -35,9 +36,7 @@ private constructor( ) : this(dimensionValues, unitAmount, mutableMapOf()) /** - * One or two matrix keys to filter usage to this Matrix value by. For example, - * ["region", "tier"] could be used to filter cloud usage by a cloud region and an instance - * tier. + * One or two matrix keys to filter usage to this Matrix value by * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). @@ -107,11 +106,7 @@ private constructor( additionalProperties = matrixValue.additionalProperties.toMutableMap() } - /** - * One or two matrix keys to filter usage to this Matrix value by. For example, - * ["region", "tier"] could be used to filter cloud usage by a cloud region and an instance - * tier. - */ + /** One or two matrix keys to filter usage to this Matrix value by */ fun dimensionValues(dimensionValues: List) = dimensionValues(JsonField.of(dimensionValues)) diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MatrixWithAllocationConfig.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MatrixWithAllocationConfig.kt index 588a20d74..8a3454a40 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MatrixWithAllocationConfig.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MatrixWithAllocationConfig.kt @@ -17,9 +17,10 @@ import com.withorb.api.errors.OrbInvalidDataException import java.util.Collections import java.util.Objects +/** Configuration for matrix pricing with usage allocation */ class MatrixWithAllocationConfig private constructor( - private val allocation: JsonField, + private val allocation: JsonField, private val defaultUnitAmount: JsonField, private val dimensions: JsonField>, private val matrixValues: JsonField>, @@ -30,7 +31,7 @@ private constructor( private constructor( @JsonProperty("allocation") @ExcludeMissing - allocation: JsonField = JsonMissing.of(), + allocation: JsonField = JsonMissing.of(), @JsonProperty("default_unit_amount") @ExcludeMissing defaultUnitAmount: JsonField = JsonMissing.of(), @@ -43,12 +44,12 @@ private constructor( ) : this(allocation, defaultUnitAmount, dimensions, matrixValues, mutableMapOf()) /** - * Allocation to be used to calculate the price + * Usage allocation * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ - fun allocation(): Double = allocation.getRequired("allocation") + fun allocation(): String = allocation.getRequired("allocation") /** * Default per unit rate for any usage not bucketed into a specified matrix_value @@ -67,7 +68,7 @@ private constructor( fun dimensions(): List = dimensions.getRequired("dimensions") /** - * Matrix values for specified matrix grouping keys + * Matrix values configuration * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). @@ -79,7 +80,7 @@ private constructor( * * Unlike [allocation], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("allocation") @ExcludeMissing fun _allocation(): JsonField = allocation + @JsonProperty("allocation") @ExcludeMissing fun _allocation(): JsonField = allocation /** * Returns the raw JSON value of [defaultUnitAmount]. @@ -140,7 +141,7 @@ private constructor( /** A builder for [MatrixWithAllocationConfig]. */ class Builder internal constructor() { - private var allocation: JsonField? = null + private var allocation: JsonField? = null private var defaultUnitAmount: JsonField? = null private var dimensions: JsonField>? = null private var matrixValues: JsonField>? = null @@ -154,17 +155,17 @@ private constructor( additionalProperties = matrixWithAllocationConfig.additionalProperties.toMutableMap() } - /** Allocation to be used to calculate the price */ - fun allocation(allocation: Double) = allocation(JsonField.of(allocation)) + /** Usage allocation */ + fun allocation(allocation: String) = allocation(JsonField.of(allocation)) /** * Sets [Builder.allocation] to an arbitrary JSON value. * - * You should usually call [Builder.allocation] with a well-typed [Double] value instead. + * You should usually call [Builder.allocation] with a well-typed [String] value instead. * This method is primarily for setting the field to an undocumented or not yet supported * value. */ - fun allocation(allocation: JsonField) = apply { this.allocation = allocation } + fun allocation(allocation: JsonField) = apply { this.allocation = allocation } /** Default per unit rate for any usage not bucketed into a specified matrix_value */ fun defaultUnitAmount(defaultUnitAmount: String) = @@ -207,7 +208,7 @@ private constructor( } } - /** Matrix values for specified matrix grouping keys */ + /** Matrix values configuration */ fun matrixValues(matrixValues: List) = matrixValues(JsonField.of(matrixValues)) /** @@ -310,6 +311,234 @@ private constructor( (dimensions.asKnown()?.sumOf { (if (it == null) 0 else 1).toInt() } ?: 0) + (matrixValues.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + /** Configuration for a single matrix value */ + class MatrixValue + private constructor( + private val dimensionValues: JsonField>, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("dimension_values") + @ExcludeMissing + dimensionValues: JsonField> = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(dimensionValues, unitAmount, mutableMapOf()) + + /** + * One or two matrix keys to filter usage to this Matrix value by. For example, + * ["region", "tier"] could be used to filter cloud usage by a cloud region and an instance + * tier. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun dimensionValues(): List = dimensionValues.getRequired("dimension_values") + + /** + * Unit price for the specified dimension_values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [dimensionValues]. + * + * Unlike [dimensionValues], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("dimension_values") + @ExcludeMissing + fun _dimensionValues(): JsonField> = dimensionValues + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [MatrixValue]. + * + * The following fields are required: + * ```kotlin + * .dimensionValues() + * .unitAmount() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [MatrixValue]. */ + class Builder internal constructor() { + + private var dimensionValues: JsonField>? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(matrixValue: MatrixValue) = apply { + dimensionValues = matrixValue.dimensionValues.map { it.toMutableList() } + unitAmount = matrixValue.unitAmount + additionalProperties = matrixValue.additionalProperties.toMutableMap() + } + + /** + * One or two matrix keys to filter usage to this Matrix value by. For example, + * ["region", "tier"] could be used to filter cloud usage by a cloud region and an + * instance tier. + */ + fun dimensionValues(dimensionValues: List) = + dimensionValues(JsonField.of(dimensionValues)) + + /** + * Sets [Builder.dimensionValues] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionValues] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun dimensionValues(dimensionValues: JsonField>) = apply { + this.dimensionValues = dimensionValues.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [dimensionValues]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addDimensionValue(dimensionValue: String) = apply { + dimensionValues = + (dimensionValues ?: JsonField.of(mutableListOf())).also { + checkKnown("dimensionValues", it).add(dimensionValue) + } + } + + /** Unit price for the specified dimension_values */ + fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { this.unitAmount = unitAmount } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [MatrixValue]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .dimensionValues() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MatrixValue = + MatrixValue( + checkRequired("dimensionValues", dimensionValues).map { it.toImmutable() }, + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MatrixValue = apply { + if (validated) { + return@apply + } + + dimensionValues() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (dimensionValues.asKnown()?.sumOf { (if (it == null) 0 else 1).toInt() } ?: 0) + + (if (unitAmount.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MatrixValue && + dimensionValues == other.dimensionValues && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(dimensionValues, unitAmount, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MatrixValue{dimensionValues=$dimensionValues, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingBulkPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingBulkPrice.kt index e6768ee6a..ff78ce223 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingBulkPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingBulkPrice.kt @@ -105,6 +105,8 @@ private constructor( ) /** + * Configuration for bulk pricing + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ @@ -135,6 +137,8 @@ private constructor( fun itemId(): String = itemId.getRequired("item_id") /** + * The pricing model type + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ @@ -471,6 +475,7 @@ private constructor( additionalProperties = newFloatingBulkPrice.additionalProperties.toMutableMap() } + /** Configuration for bulk pricing */ fun bulkConfig(bulkConfig: BulkConfig) = bulkConfig(JsonField.of(bulkConfig)) /** @@ -515,6 +520,7 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + /** The pricing model type */ fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) /** @@ -1044,6 +1050,7 @@ private constructor( override fun toString() = value.toString() } + /** The pricing model type */ class ModelType @JsonCreator private constructor(private val value: JsonField) : Enum { /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingBulkWithProrationPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingBulkWithProrationPrice.kt index 056c655c1..3c46c9857 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingBulkWithProrationPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingBulkWithProrationPrice.kt @@ -11,6 +11,7 @@ import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue +import com.withorb.api.core.checkKnown import com.withorb.api.core.checkRequired import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException @@ -105,6 +106,8 @@ private constructor( ) /** + * Configuration for bulk_with_proration pricing + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ @@ -136,6 +139,8 @@ private constructor( fun itemId(): String = itemId.getRequired("item_id") /** + * The pricing model type + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ @@ -479,6 +484,7 @@ private constructor( newFloatingBulkWithProrationPrice.additionalProperties.toMutableMap() } + /** Configuration for bulk_with_proration pricing */ fun bulkWithProrationConfig(bulkWithProrationConfig: BulkWithProrationConfig) = bulkWithProrationConfig(JsonField.of(bulkWithProrationConfig)) @@ -527,6 +533,7 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + /** The pricing model type */ fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) /** @@ -907,16 +914,42 @@ private constructor( (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + (metadata.asKnown()?.validity() ?: 0) + /** Configuration for bulk_with_proration pricing */ class BulkWithProrationConfig - @JsonCreator private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map + private val tiers: JsonField>, + private val additionalProperties: MutableMap, ) { + @JsonCreator + private constructor( + @JsonProperty("tiers") @ExcludeMissing tiers: JsonField> = JsonMissing.of() + ) : this(tiers, mutableMapOf()) + + /** + * Bulk tiers for rating based on total usage volume + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun tiers(): List = tiers.getRequired("tiers") + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tiers") @ExcludeMissing fun _tiers(): JsonField> = tiers + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) fun toBuilder() = Builder().from(this) @@ -924,6 +957,11 @@ private constructor( /** * Returns a mutable builder for constructing an instance of [BulkWithProrationConfig]. + * + * The following fields are required: + * ```kotlin + * .tiers() + * ``` */ fun builder() = Builder() } @@ -931,12 +969,40 @@ private constructor( /** A builder for [BulkWithProrationConfig]. */ class Builder internal constructor() { + private var tiers: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(bulkWithProrationConfig: BulkWithProrationConfig) = apply { + tiers = bulkWithProrationConfig.tiers.map { it.toMutableList() } additionalProperties = bulkWithProrationConfig.additionalProperties.toMutableMap() } + /** Bulk tiers for rating based on total usage volume */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -960,9 +1026,19 @@ private constructor( * Returns an immutable instance of [BulkWithProrationConfig]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ fun build(): BulkWithProrationConfig = - BulkWithProrationConfig(additionalProperties.toImmutable()) + BulkWithProrationConfig( + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false @@ -972,6 +1048,7 @@ private constructor( return@apply } + tiers().forEach { it.validate() } validated = true } @@ -989,8 +1066,222 @@ private constructor( * * Used for best match union deserialization. */ - internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + internal fun validity(): Int = (tiers.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single bulk pricing tier with proration */ + class Tier + private constructor( + private val unitAmount: JsonField, + private val tierLowerBound: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + ) : this(unitAmount, tierLowerBound, mutableMapOf()) + + /** + * Cost per unit + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * The lower bound for this tier + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun tierLowerBound(): String? = tierLowerBound.getNullable("tier_lower_bound") + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Tier]. + * + * The following fields are required: + * ```kotlin + * .unitAmount() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var unitAmount: JsonField? = null + private var tierLowerBound: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(tier: Tier) = apply { + unitAmount = tier.unitAmount + tierLowerBound = tier.tierLowerBound + additionalProperties = tier.additionalProperties.toMutableMap() + } + + /** Cost per unit */ + fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + /** The lower bound for this tier */ + fun tierLowerBound(tierLowerBound: String?) = + tierLowerBound(JsonField.ofNullable(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Tier]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("unitAmount", unitAmount), + tierLowerBound, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + unitAmount() + tierLowerBound() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (unitAmount.asKnown() == null) 0 else 1) + + (if (tierLowerBound.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + unitAmount == other.unitAmount && + tierLowerBound == other.tierLowerBound && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(unitAmount, tierLowerBound, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{unitAmount=$unitAmount, tierLowerBound=$tierLowerBound, additionalProperties=$additionalProperties}" + } override fun equals(other: Any?): Boolean { if (this === other) { @@ -998,15 +1289,16 @@ private constructor( } return other is BulkWithProrationConfig && + tiers == other.tiers && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(tiers, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "BulkWithProrationConfig{additionalProperties=$additionalProperties}" + "BulkWithProrationConfig{tiers=$tiers, additionalProperties=$additionalProperties}" } /** The cadence to bill for this price on. */ @@ -1158,6 +1450,7 @@ private constructor( override fun toString() = value.toString() } + /** The pricing model type */ class ModelType @JsonCreator private constructor(private val value: JsonField) : Enum { /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingCumulativeGroupedBulkPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingCumulativeGroupedBulkPrice.kt index eea158ef4..cf2baf868 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingCumulativeGroupedBulkPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingCumulativeGroupedBulkPrice.kt @@ -11,6 +11,7 @@ import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue +import com.withorb.api.core.checkKnown import com.withorb.api.core.checkRequired import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException @@ -113,6 +114,8 @@ private constructor( fun cadence(): Cadence = cadence.getRequired("cadence") /** + * Configuration for cumulative_grouped_bulk pricing + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ @@ -136,6 +139,8 @@ private constructor( fun itemId(): String = itemId.getRequired("item_id") /** + * The pricing model type + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ @@ -493,6 +498,7 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + /** Configuration for cumulative_grouped_bulk pricing */ fun cumulativeGroupedBulkConfig(cumulativeGroupedBulkConfig: CumulativeGroupedBulkConfig) = cumulativeGroupedBulkConfig(JsonField.of(cumulativeGroupedBulkConfig)) @@ -529,6 +535,7 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + /** The pricing model type */ fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) /** @@ -1058,16 +1065,65 @@ private constructor( override fun toString() = value.toString() } + /** Configuration for cumulative_grouped_bulk pricing */ class CumulativeGroupedBulkConfig - @JsonCreator private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map + private val dimensionValues: JsonField>, + private val group: JsonField, + private val additionalProperties: MutableMap, ) { + @JsonCreator + private constructor( + @JsonProperty("dimension_values") + @ExcludeMissing + dimensionValues: JsonField> = JsonMissing.of(), + @JsonProperty("group") @ExcludeMissing group: JsonField = JsonMissing.of(), + ) : this(dimensionValues, group, mutableMapOf()) + + /** + * Each tier lower bound must have the same group of values. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun dimensionValues(): List = + dimensionValues.getRequired("dimension_values") + + /** + * Grouping key name + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun group(): String = group.getRequired("group") + + /** + * Returns the raw JSON value of [dimensionValues]. + * + * Unlike [dimensionValues], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("dimension_values") + @ExcludeMissing + fun _dimensionValues(): JsonField> = dimensionValues + + /** + * Returns the raw JSON value of [group]. + * + * Unlike [group], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("group") @ExcludeMissing fun _group(): JsonField = group + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) fun toBuilder() = Builder().from(this) @@ -1076,6 +1132,12 @@ private constructor( /** * Returns a mutable builder for constructing an instance of * [CumulativeGroupedBulkConfig]. + * + * The following fields are required: + * ```kotlin + * .dimensionValues() + * .group() + * ``` */ fun builder() = Builder() } @@ -1083,13 +1145,57 @@ private constructor( /** A builder for [CumulativeGroupedBulkConfig]. */ class Builder internal constructor() { + private var dimensionValues: JsonField>? = null + private var group: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(cumulativeGroupedBulkConfig: CumulativeGroupedBulkConfig) = apply { + dimensionValues = + cumulativeGroupedBulkConfig.dimensionValues.map { it.toMutableList() } + group = cumulativeGroupedBulkConfig.group additionalProperties = cumulativeGroupedBulkConfig.additionalProperties.toMutableMap() } + /** Each tier lower bound must have the same group of values. */ + fun dimensionValues(dimensionValues: List) = + dimensionValues(JsonField.of(dimensionValues)) + + /** + * Sets [Builder.dimensionValues] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionValues] with a well-typed + * `List` value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun dimensionValues(dimensionValues: JsonField>) = apply { + this.dimensionValues = dimensionValues.map { it.toMutableList() } + } + + /** + * Adds a single [DimensionValue] to [dimensionValues]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addDimensionValue(dimensionValue: DimensionValue) = apply { + dimensionValues = + (dimensionValues ?: JsonField.of(mutableListOf())).also { + checkKnown("dimensionValues", it).add(dimensionValue) + } + } + + /** Grouping key name */ + fun group(group: String) = group(JsonField.of(group)) + + /** + * Sets [Builder.group] to an arbitrary JSON value. + * + * You should usually call [Builder.group] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun group(group: JsonField) = apply { this.group = group } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -1113,9 +1219,21 @@ private constructor( * Returns an immutable instance of [CumulativeGroupedBulkConfig]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .dimensionValues() + * .group() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ fun build(): CumulativeGroupedBulkConfig = - CumulativeGroupedBulkConfig(additionalProperties.toImmutable()) + CumulativeGroupedBulkConfig( + checkRequired("dimensionValues", dimensionValues).map { it.toImmutable() }, + checkRequired("group", group), + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false @@ -1125,6 +1243,8 @@ private constructor( return@apply } + dimensionValues().forEach { it.validate() } + group() validated = true } @@ -1143,7 +1263,271 @@ private constructor( * Used for best match union deserialization. */ internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + (dimensionValues.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + (if (group.asKnown() == null) 0 else 1) + + /** Configuration for a dimension value entry */ + class DimensionValue + private constructor( + private val groupingKey: JsonField, + private val tierLowerBound: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(groupingKey, tierLowerBound, unitAmount, mutableMapOf()) + + /** + * Grouping key value + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * Tier lower bound + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun tierLowerBound(): String = tierLowerBound.getRequired("tier_lower_bound") + + /** + * Unit amount for this combination + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [DimensionValue]. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .tierLowerBound() + * .unitAmount() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [DimensionValue]. */ + class Builder internal constructor() { + + private var groupingKey: JsonField? = null + private var tierLowerBound: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(dimensionValue: DimensionValue) = apply { + groupingKey = dimensionValue.groupingKey + tierLowerBound = dimensionValue.tierLowerBound + unitAmount = dimensionValue.unitAmount + additionalProperties = dimensionValue.additionalProperties.toMutableMap() + } + + /** Grouping key value */ + fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** Tier lower bound */ + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + /** Unit amount for this combination */ + fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [DimensionValue]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .tierLowerBound() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): DimensionValue = + DimensionValue( + checkRequired("groupingKey", groupingKey), + checkRequired("tierLowerBound", tierLowerBound), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): DimensionValue = apply { + if (validated) { + return@apply + } + + groupingKey() + tierLowerBound() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (groupingKey.asKnown() == null) 0 else 1) + + (if (tierLowerBound.asKnown() == null) 0 else 1) + + (if (unitAmount.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is DimensionValue && + groupingKey == other.groupingKey && + tierLowerBound == other.tierLowerBound && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(groupingKey, tierLowerBound, unitAmount, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "DimensionValue{groupingKey=$groupingKey, tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } override fun equals(other: Any?): Boolean { if (this === other) { @@ -1151,17 +1535,22 @@ private constructor( } return other is CumulativeGroupedBulkConfig && + dimensionValues == other.dimensionValues && + group == other.group && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + private val hashCode: Int by lazy { + Objects.hash(dimensionValues, group, additionalProperties) + } override fun hashCode(): Int = hashCode override fun toString() = - "CumulativeGroupedBulkConfig{additionalProperties=$additionalProperties}" + "CumulativeGroupedBulkConfig{dimensionValues=$dimensionValues, group=$group, additionalProperties=$additionalProperties}" } + /** The pricing model type */ class ModelType @JsonCreator private constructor(private val value: JsonField) : Enum { /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingGroupedAllocationPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingGroupedAllocationPrice.kt index dcf5aee14..7046cad33 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingGroupedAllocationPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingGroupedAllocationPrice.kt @@ -121,6 +121,8 @@ private constructor( fun currency(): String = currency.getRequired("currency") /** + * Configuration for grouped_allocation pricing + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ @@ -136,6 +138,8 @@ private constructor( fun itemId(): String = itemId.getRequired("item_id") /** + * The pricing model type + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ @@ -501,6 +505,7 @@ private constructor( */ fun currency(currency: JsonField) = apply { this.currency = currency } + /** Configuration for grouped_allocation pricing */ fun groupedAllocationConfig(groupedAllocationConfig: GroupedAllocationConfig) = groupedAllocationConfig(JsonField.of(groupedAllocationConfig)) @@ -527,6 +532,7 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + /** The pricing model type */ fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) /** @@ -1056,16 +1062,89 @@ private constructor( override fun toString() = value.toString() } + /** Configuration for grouped_allocation pricing */ class GroupedAllocationConfig - @JsonCreator private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map + private val allocation: JsonField, + private val groupingKey: JsonField, + private val overageUnitRate: JsonField, + private val additionalProperties: MutableMap, ) { + @JsonCreator + private constructor( + @JsonProperty("allocation") + @ExcludeMissing + allocation: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("overage_unit_rate") + @ExcludeMissing + overageUnitRate: JsonField = JsonMissing.of(), + ) : this(allocation, groupingKey, overageUnitRate, mutableMapOf()) + + /** + * Usage allocation per group + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun allocation(): String = allocation.getRequired("allocation") + + /** + * How to determine the groups that should each be allocated some quantity + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * Unit rate for post-allocation + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun overageUnitRate(): String = overageUnitRate.getRequired("overage_unit_rate") + + /** + * Returns the raw JSON value of [allocation]. + * + * Unlike [allocation], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("allocation") + @ExcludeMissing + fun _allocation(): JsonField = allocation + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [overageUnitRate]. + * + * Unlike [overageUnitRate], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("overage_unit_rate") + @ExcludeMissing + fun _overageUnitRate(): JsonField = overageUnitRate + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) fun toBuilder() = Builder().from(this) @@ -1073,6 +1152,13 @@ private constructor( /** * Returns a mutable builder for constructing an instance of [GroupedAllocationConfig]. + * + * The following fields are required: + * ```kotlin + * .allocation() + * .groupingKey() + * .overageUnitRate() + * ``` */ fun builder() = Builder() } @@ -1080,12 +1166,59 @@ private constructor( /** A builder for [GroupedAllocationConfig]. */ class Builder internal constructor() { + private var allocation: JsonField? = null + private var groupingKey: JsonField? = null + private var overageUnitRate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(groupedAllocationConfig: GroupedAllocationConfig) = apply { + allocation = groupedAllocationConfig.allocation + groupingKey = groupedAllocationConfig.groupingKey + overageUnitRate = groupedAllocationConfig.overageUnitRate additionalProperties = groupedAllocationConfig.additionalProperties.toMutableMap() } + /** Usage allocation per group */ + fun allocation(allocation: String) = allocation(JsonField.of(allocation)) + + /** + * Sets [Builder.allocation] to an arbitrary JSON value. + * + * You should usually call [Builder.allocation] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun allocation(allocation: JsonField) = apply { this.allocation = allocation } + + /** How to determine the groups that should each be allocated some quantity */ + fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** Unit rate for post-allocation */ + fun overageUnitRate(overageUnitRate: String) = + overageUnitRate(JsonField.of(overageUnitRate)) + + /** + * Sets [Builder.overageUnitRate] to an arbitrary JSON value. + * + * You should usually call [Builder.overageUnitRate] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun overageUnitRate(overageUnitRate: JsonField) = apply { + this.overageUnitRate = overageUnitRate + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -1109,9 +1242,23 @@ private constructor( * Returns an immutable instance of [GroupedAllocationConfig]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .allocation() + * .groupingKey() + * .overageUnitRate() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ fun build(): GroupedAllocationConfig = - GroupedAllocationConfig(additionalProperties.toImmutable()) + GroupedAllocationConfig( + checkRequired("allocation", allocation), + checkRequired("groupingKey", groupingKey), + checkRequired("overageUnitRate", overageUnitRate), + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false @@ -1121,6 +1268,9 @@ private constructor( return@apply } + allocation() + groupingKey() + overageUnitRate() validated = true } @@ -1139,7 +1289,9 @@ private constructor( * Used for best match union deserialization. */ internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + (if (allocation.asKnown() == null) 0 else 1) + + (if (groupingKey.asKnown() == null) 0 else 1) + + (if (overageUnitRate.asKnown() == null) 0 else 1) override fun equals(other: Any?): Boolean { if (this === other) { @@ -1147,17 +1299,23 @@ private constructor( } return other is GroupedAllocationConfig && + allocation == other.allocation && + groupingKey == other.groupingKey && + overageUnitRate == other.overageUnitRate && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + private val hashCode: Int by lazy { + Objects.hash(allocation, groupingKey, overageUnitRate, additionalProperties) + } override fun hashCode(): Int = hashCode override fun toString() = - "GroupedAllocationConfig{additionalProperties=$additionalProperties}" + "GroupedAllocationConfig{allocation=$allocation, groupingKey=$groupingKey, overageUnitRate=$overageUnitRate, additionalProperties=$additionalProperties}" } + /** The pricing model type */ class ModelType @JsonCreator private constructor(private val value: JsonField) : Enum { /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingGroupedTieredPackagePrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingGroupedTieredPackagePrice.kt index aa339ce45..647ba532b 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingGroupedTieredPackagePrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingGroupedTieredPackagePrice.kt @@ -11,6 +11,7 @@ import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue +import com.withorb.api.core.checkKnown import com.withorb.api.core.checkRequired import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException @@ -121,6 +122,8 @@ private constructor( fun currency(): String = currency.getRequired("currency") /** + * Configuration for grouped_tiered_package pricing + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ @@ -136,6 +139,8 @@ private constructor( fun itemId(): String = itemId.getRequired("item_id") /** + * The pricing model type + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ @@ -504,6 +509,7 @@ private constructor( */ fun currency(currency: JsonField) = apply { this.currency = currency } + /** Configuration for grouped_tiered_package pricing */ fun groupedTieredPackageConfig(groupedTieredPackageConfig: GroupedTieredPackageConfig) = groupedTieredPackageConfig(JsonField.of(groupedTieredPackageConfig)) @@ -529,6 +535,7 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + /** The pricing model type */ fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) /** @@ -1058,16 +1065,85 @@ private constructor( override fun toString() = value.toString() } + /** Configuration for grouped_tiered_package pricing */ class GroupedTieredPackageConfig - @JsonCreator private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map + private val groupingKey: JsonField, + private val packageSize: JsonField, + private val tiers: JsonField>, + private val additionalProperties: MutableMap, ) { + @JsonCreator + private constructor( + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("package_size") + @ExcludeMissing + packageSize: JsonField = JsonMissing.of(), + @JsonProperty("tiers") @ExcludeMissing tiers: JsonField> = JsonMissing.of(), + ) : this(groupingKey, packageSize, tiers, mutableMapOf()) + + /** + * The event property used to group before tiering + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * Package size + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun packageSize(): String = packageSize.getRequired("package_size") + + /** + * Apply tiered pricing after rounding up the quantity to the package size. Tiers are + * defined using exclusive lower bounds. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun tiers(): List = tiers.getRequired("tiers") + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [packageSize]. + * + * Unlike [packageSize], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("package_size") + @ExcludeMissing + fun _packageSize(): JsonField = packageSize + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tiers") @ExcludeMissing fun _tiers(): JsonField> = tiers + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) fun toBuilder() = Builder().from(this) @@ -1076,6 +1152,13 @@ private constructor( /** * Returns a mutable builder for constructing an instance of * [GroupedTieredPackageConfig]. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .packageSize() + * .tiers() + * ``` */ fun builder() = Builder() } @@ -1083,13 +1166,76 @@ private constructor( /** A builder for [GroupedTieredPackageConfig]. */ class Builder internal constructor() { + private var groupingKey: JsonField? = null + private var packageSize: JsonField? = null + private var tiers: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(groupedTieredPackageConfig: GroupedTieredPackageConfig) = apply { + groupingKey = groupedTieredPackageConfig.groupingKey + packageSize = groupedTieredPackageConfig.packageSize + tiers = groupedTieredPackageConfig.tiers.map { it.toMutableList() } additionalProperties = groupedTieredPackageConfig.additionalProperties.toMutableMap() } + /** The event property used to group before tiering */ + fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** Package size */ + fun packageSize(packageSize: String) = packageSize(JsonField.of(packageSize)) + + /** + * Sets [Builder.packageSize] to an arbitrary JSON value. + * + * You should usually call [Builder.packageSize] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun packageSize(packageSize: JsonField) = apply { + this.packageSize = packageSize + } + + /** + * Apply tiered pricing after rounding up the quantity to the package size. Tiers are + * defined using exclusive lower bounds. + */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -1113,9 +1259,23 @@ private constructor( * Returns an immutable instance of [GroupedTieredPackageConfig]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .packageSize() + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ fun build(): GroupedTieredPackageConfig = - GroupedTieredPackageConfig(additionalProperties.toImmutable()) + GroupedTieredPackageConfig( + checkRequired("groupingKey", groupingKey), + checkRequired("packageSize", packageSize), + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false @@ -1125,6 +1285,9 @@ private constructor( return@apply } + groupingKey() + packageSize() + tiers().forEach { it.validate() } validated = true } @@ -1143,7 +1306,222 @@ private constructor( * Used for best match union deserialization. */ internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + (if (groupingKey.asKnown() == null) 0 else 1) + + (if (packageSize.asKnown() == null) 0 else 1) + + (tiers.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single tier */ + class Tier + private constructor( + private val perUnit: JsonField, + private val tierLowerBound: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("per_unit") + @ExcludeMissing + perUnit: JsonField = JsonMissing.of(), + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + ) : this(perUnit, tierLowerBound, mutableMapOf()) + + /** + * Price per package + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun perUnit(): String = perUnit.getRequired("per_unit") + + /** + * Tier lower bound + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun tierLowerBound(): String = tierLowerBound.getRequired("tier_lower_bound") + + /** + * Returns the raw JSON value of [perUnit]. + * + * Unlike [perUnit], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("per_unit") @ExcludeMissing fun _perUnit(): JsonField = perUnit + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Tier]. + * + * The following fields are required: + * ```kotlin + * .perUnit() + * .tierLowerBound() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var perUnit: JsonField? = null + private var tierLowerBound: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(tier: Tier) = apply { + perUnit = tier.perUnit + tierLowerBound = tier.tierLowerBound + additionalProperties = tier.additionalProperties.toMutableMap() + } + + /** Price per package */ + fun perUnit(perUnit: String) = perUnit(JsonField.of(perUnit)) + + /** + * Sets [Builder.perUnit] to an arbitrary JSON value. + * + * You should usually call [Builder.perUnit] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun perUnit(perUnit: JsonField) = apply { this.perUnit = perUnit } + + /** Tier lower bound */ + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Tier]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .perUnit() + * .tierLowerBound() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("perUnit", perUnit), + checkRequired("tierLowerBound", tierLowerBound), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + perUnit() + tierLowerBound() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (perUnit.asKnown() == null) 0 else 1) + + (if (tierLowerBound.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + perUnit == other.perUnit && + tierLowerBound == other.tierLowerBound && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(perUnit, tierLowerBound, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{perUnit=$perUnit, tierLowerBound=$tierLowerBound, additionalProperties=$additionalProperties}" + } override fun equals(other: Any?): Boolean { if (this === other) { @@ -1151,17 +1529,23 @@ private constructor( } return other is GroupedTieredPackageConfig && + groupingKey == other.groupingKey && + packageSize == other.packageSize && + tiers == other.tiers && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + private val hashCode: Int by lazy { + Objects.hash(groupingKey, packageSize, tiers, additionalProperties) + } override fun hashCode(): Int = hashCode override fun toString() = - "GroupedTieredPackageConfig{additionalProperties=$additionalProperties}" + "GroupedTieredPackageConfig{groupingKey=$groupingKey, packageSize=$packageSize, tiers=$tiers, additionalProperties=$additionalProperties}" } + /** The pricing model type */ class ModelType @JsonCreator private constructor(private val value: JsonField) : Enum { /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingGroupedTieredPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingGroupedTieredPrice.kt index ca8637ba5..204446e99 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingGroupedTieredPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingGroupedTieredPrice.kt @@ -11,6 +11,7 @@ import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue +import com.withorb.api.core.checkKnown import com.withorb.api.core.checkRequired import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException @@ -121,6 +122,8 @@ private constructor( fun currency(): String = currency.getRequired("currency") /** + * Configuration for grouped_tiered pricing + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ @@ -136,6 +139,8 @@ private constructor( fun itemId(): String = itemId.getRequired("item_id") /** + * The pricing model type + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ @@ -497,6 +502,7 @@ private constructor( */ fun currency(currency: JsonField) = apply { this.currency = currency } + /** Configuration for grouped_tiered pricing */ fun groupedTieredConfig(groupedTieredConfig: GroupedTieredConfig) = groupedTieredConfig(JsonField.of(groupedTieredConfig)) @@ -522,6 +528,7 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + /** The pricing model type */ fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) /** @@ -1051,34 +1058,135 @@ private constructor( override fun toString() = value.toString() } + /** Configuration for grouped_tiered pricing */ class GroupedTieredConfig - @JsonCreator private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map + private val groupingKey: JsonField, + private val tiers: JsonField>, + private val additionalProperties: MutableMap, ) { + @JsonCreator + private constructor( + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("tiers") @ExcludeMissing tiers: JsonField> = JsonMissing.of(), + ) : this(groupingKey, tiers, mutableMapOf()) + + /** + * The billable metric property used to group before tiering + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * Apply tiered pricing to each segment generated after grouping with the provided key + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun tiers(): List = tiers.getRequired("tiers") + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tiers") @ExcludeMissing fun _tiers(): JsonField> = tiers + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) fun toBuilder() = Builder().from(this) companion object { - /** Returns a mutable builder for constructing an instance of [GroupedTieredConfig]. */ + /** + * Returns a mutable builder for constructing an instance of [GroupedTieredConfig]. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .tiers() + * ``` + */ fun builder() = Builder() } /** A builder for [GroupedTieredConfig]. */ class Builder internal constructor() { + private var groupingKey: JsonField? = null + private var tiers: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(groupedTieredConfig: GroupedTieredConfig) = apply { + groupingKey = groupedTieredConfig.groupingKey + tiers = groupedTieredConfig.tiers.map { it.toMutableList() } additionalProperties = groupedTieredConfig.additionalProperties.toMutableMap() } + /** The billable metric property used to group before tiering */ + fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** + * Apply tiered pricing to each segment generated after grouping with the provided key + */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -1102,9 +1210,21 @@ private constructor( * Returns an immutable instance of [GroupedTieredConfig]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ fun build(): GroupedTieredConfig = - GroupedTieredConfig(additionalProperties.toImmutable()) + GroupedTieredConfig( + checkRequired("groupingKey", groupingKey), + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false @@ -1114,6 +1234,8 @@ private constructor( return@apply } + groupingKey() + tiers().forEach { it.validate() } validated = true } @@ -1132,7 +1254,226 @@ private constructor( * Used for best match union deserialization. */ internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + (if (groupingKey.asKnown() == null) 0 else 1) + + (tiers.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single tier */ + class Tier + private constructor( + private val tierLowerBound: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(tierLowerBound, unitAmount, mutableMapOf()) + + /** + * Tier lower bound + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun tierLowerBound(): String = tierLowerBound.getRequired("tier_lower_bound") + + /** + * Per unit amount + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Tier]. + * + * The following fields are required: + * ```kotlin + * .tierLowerBound() + * .unitAmount() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var tierLowerBound: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(tier: Tier) = apply { + tierLowerBound = tier.tierLowerBound + unitAmount = tier.unitAmount + additionalProperties = tier.additionalProperties.toMutableMap() + } + + /** Tier lower bound */ + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + /** Per unit amount */ + fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Tier]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .tierLowerBound() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("tierLowerBound", tierLowerBound), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + tierLowerBound() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (tierLowerBound.asKnown() == null) 0 else 1) + + (if (unitAmount.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + tierLowerBound == other.tierLowerBound && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(tierLowerBound, unitAmount, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } override fun equals(other: Any?): Boolean { if (this === other) { @@ -1140,16 +1481,20 @@ private constructor( } return other is GroupedTieredConfig && + groupingKey == other.groupingKey && + tiers == other.tiers && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(groupingKey, tiers, additionalProperties) } override fun hashCode(): Int = hashCode - override fun toString() = "GroupedTieredConfig{additionalProperties=$additionalProperties}" + override fun toString() = + "GroupedTieredConfig{groupingKey=$groupingKey, tiers=$tiers, additionalProperties=$additionalProperties}" } + /** The pricing model type */ class ModelType @JsonCreator private constructor(private val value: JsonField) : Enum { /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingGroupedWithMeteredMinimumPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingGroupedWithMeteredMinimumPrice.kt index af7fd6221..48b30ee9e 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingGroupedWithMeteredMinimumPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingGroupedWithMeteredMinimumPrice.kt @@ -11,6 +11,7 @@ import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue +import com.withorb.api.core.checkKnown import com.withorb.api.core.checkRequired import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException @@ -122,6 +123,8 @@ private constructor( fun currency(): String = currency.getRequired("currency") /** + * Configuration for grouped_with_metered_minimum pricing + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ @@ -137,6 +140,8 @@ private constructor( fun itemId(): String = itemId.getRequired("item_id") /** + * The pricing model type + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ @@ -506,6 +511,7 @@ private constructor( */ fun currency(currency: JsonField) = apply { this.currency = currency } + /** Configuration for grouped_with_metered_minimum pricing */ fun groupedWithMeteredMinimumConfig( groupedWithMeteredMinimumConfig: GroupedWithMeteredMinimumConfig ) = groupedWithMeteredMinimumConfig(JsonField.of(groupedWithMeteredMinimumConfig)) @@ -532,6 +538,7 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + /** The pricing model type */ fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) /** @@ -1061,16 +1068,162 @@ private constructor( override fun toString() = value.toString() } + /** Configuration for grouped_with_metered_minimum pricing */ class GroupedWithMeteredMinimumConfig - @JsonCreator private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map + private val groupingKey: JsonField, + private val minimumUnitAmount: JsonField, + private val pricingKey: JsonField, + private val scalingFactors: JsonField>, + private val scalingKey: JsonField, + private val unitAmounts: JsonField>, + private val additionalProperties: MutableMap, ) { + @JsonCreator + private constructor( + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("minimum_unit_amount") + @ExcludeMissing + minimumUnitAmount: JsonField = JsonMissing.of(), + @JsonProperty("pricing_key") + @ExcludeMissing + pricingKey: JsonField = JsonMissing.of(), + @JsonProperty("scaling_factors") + @ExcludeMissing + scalingFactors: JsonField> = JsonMissing.of(), + @JsonProperty("scaling_key") + @ExcludeMissing + scalingKey: JsonField = JsonMissing.of(), + @JsonProperty("unit_amounts") + @ExcludeMissing + unitAmounts: JsonField> = JsonMissing.of(), + ) : this( + groupingKey, + minimumUnitAmount, + pricingKey, + scalingFactors, + scalingKey, + unitAmounts, + mutableMapOf(), + ) + + /** + * Used to partition the usage into groups. The minimum amount is applied to each group. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The minimum amount to charge per group per unit + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun minimumUnitAmount(): String = minimumUnitAmount.getRequired("minimum_unit_amount") + + /** + * Used to determine the unit rate + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun pricingKey(): String = pricingKey.getRequired("pricing_key") + + /** + * Scale the unit rates by the scaling factor. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun scalingFactors(): List = scalingFactors.getRequired("scaling_factors") + + /** + * Used to determine the unit rate scaling factor + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun scalingKey(): String = scalingKey.getRequired("scaling_key") + + /** + * Apply per unit pricing to each pricing value. The minimum amount is applied any unmatched + * usage. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun unitAmounts(): List = unitAmounts.getRequired("unit_amounts") + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [minimumUnitAmount]. + * + * Unlike [minimumUnitAmount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("minimum_unit_amount") + @ExcludeMissing + fun _minimumUnitAmount(): JsonField = minimumUnitAmount + + /** + * Returns the raw JSON value of [pricingKey]. + * + * Unlike [pricingKey], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("pricing_key") + @ExcludeMissing + fun _pricingKey(): JsonField = pricingKey + + /** + * Returns the raw JSON value of [scalingFactors]. + * + * Unlike [scalingFactors], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("scaling_factors") + @ExcludeMissing + fun _scalingFactors(): JsonField> = scalingFactors + + /** + * Returns the raw JSON value of [scalingKey]. + * + * Unlike [scalingKey], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("scaling_key") + @ExcludeMissing + fun _scalingKey(): JsonField = scalingKey + + /** + * Returns the raw JSON value of [unitAmounts]. + * + * Unlike [unitAmounts], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("unit_amounts") + @ExcludeMissing + fun _unitAmounts(): JsonField> = unitAmounts + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) fun toBuilder() = Builder().from(this) @@ -1079,6 +1232,16 @@ private constructor( /** * Returns a mutable builder for constructing an instance of * [GroupedWithMeteredMinimumConfig]. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .minimumUnitAmount() + * .pricingKey() + * .scalingFactors() + * .scalingKey() + * .unitAmounts() + * ``` */ fun builder() = Builder() } @@ -1086,14 +1249,139 @@ private constructor( /** A builder for [GroupedWithMeteredMinimumConfig]. */ class Builder internal constructor() { + private var groupingKey: JsonField? = null + private var minimumUnitAmount: JsonField? = null + private var pricingKey: JsonField? = null + private var scalingFactors: JsonField>? = null + private var scalingKey: JsonField? = null + private var unitAmounts: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(groupedWithMeteredMinimumConfig: GroupedWithMeteredMinimumConfig) = apply { + groupingKey = groupedWithMeteredMinimumConfig.groupingKey + minimumUnitAmount = groupedWithMeteredMinimumConfig.minimumUnitAmount + pricingKey = groupedWithMeteredMinimumConfig.pricingKey + scalingFactors = + groupedWithMeteredMinimumConfig.scalingFactors.map { it.toMutableList() } + scalingKey = groupedWithMeteredMinimumConfig.scalingKey + unitAmounts = + groupedWithMeteredMinimumConfig.unitAmounts.map { it.toMutableList() } additionalProperties = groupedWithMeteredMinimumConfig.additionalProperties.toMutableMap() } + /** + * Used to partition the usage into groups. The minimum amount is applied to each group. + */ + fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The minimum amount to charge per group per unit */ + fun minimumUnitAmount(minimumUnitAmount: String) = + minimumUnitAmount(JsonField.of(minimumUnitAmount)) + + /** + * Sets [Builder.minimumUnitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumUnitAmount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun minimumUnitAmount(minimumUnitAmount: JsonField) = apply { + this.minimumUnitAmount = minimumUnitAmount + } + + /** Used to determine the unit rate */ + fun pricingKey(pricingKey: String) = pricingKey(JsonField.of(pricingKey)) + + /** + * Sets [Builder.pricingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.pricingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun pricingKey(pricingKey: JsonField) = apply { this.pricingKey = pricingKey } + + /** Scale the unit rates by the scaling factor. */ + fun scalingFactors(scalingFactors: List) = + scalingFactors(JsonField.of(scalingFactors)) + + /** + * Sets [Builder.scalingFactors] to an arbitrary JSON value. + * + * You should usually call [Builder.scalingFactors] with a well-typed + * `List` value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun scalingFactors(scalingFactors: JsonField>) = apply { + this.scalingFactors = scalingFactors.map { it.toMutableList() } + } + + /** + * Adds a single [ScalingFactor] to [scalingFactors]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addScalingFactor(scalingFactor: ScalingFactor) = apply { + scalingFactors = + (scalingFactors ?: JsonField.of(mutableListOf())).also { + checkKnown("scalingFactors", it).add(scalingFactor) + } + } + + /** Used to determine the unit rate scaling factor */ + fun scalingKey(scalingKey: String) = scalingKey(JsonField.of(scalingKey)) + + /** + * Sets [Builder.scalingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.scalingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun scalingKey(scalingKey: JsonField) = apply { this.scalingKey = scalingKey } + + /** + * Apply per unit pricing to each pricing value. The minimum amount is applied any + * unmatched usage. + */ + fun unitAmounts(unitAmounts: List) = unitAmounts(JsonField.of(unitAmounts)) + + /** + * Sets [Builder.unitAmounts] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmounts] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun unitAmounts(unitAmounts: JsonField>) = apply { + this.unitAmounts = unitAmounts.map { it.toMutableList() } + } + + /** + * Adds a single [UnitAmount] to [unitAmounts]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addUnitAmount(unitAmount: UnitAmount) = apply { + unitAmounts = + (unitAmounts ?: JsonField.of(mutableListOf())).also { + checkKnown("unitAmounts", it).add(unitAmount) + } + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -1117,9 +1405,29 @@ private constructor( * Returns an immutable instance of [GroupedWithMeteredMinimumConfig]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .minimumUnitAmount() + * .pricingKey() + * .scalingFactors() + * .scalingKey() + * .unitAmounts() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ fun build(): GroupedWithMeteredMinimumConfig = - GroupedWithMeteredMinimumConfig(additionalProperties.toImmutable()) + GroupedWithMeteredMinimumConfig( + checkRequired("groupingKey", groupingKey), + checkRequired("minimumUnitAmount", minimumUnitAmount), + checkRequired("pricingKey", pricingKey), + checkRequired("scalingFactors", scalingFactors).map { it.toImmutable() }, + checkRequired("scalingKey", scalingKey), + checkRequired("unitAmounts", unitAmounts).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false @@ -1129,6 +1437,12 @@ private constructor( return@apply } + groupingKey() + minimumUnitAmount() + pricingKey() + scalingFactors().forEach { it.validate() } + scalingKey() + unitAmounts().forEach { it.validate() } validated = true } @@ -1147,7 +1461,447 @@ private constructor( * Used for best match union deserialization. */ internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + (if (groupingKey.asKnown() == null) 0 else 1) + + (if (minimumUnitAmount.asKnown() == null) 0 else 1) + + (if (pricingKey.asKnown() == null) 0 else 1) + + (scalingFactors.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + (if (scalingKey.asKnown() == null) 0 else 1) + + (unitAmounts.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a scaling factor */ + class ScalingFactor + private constructor( + private val scalingFactor: JsonField, + private val scalingValue: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("scaling_factor") + @ExcludeMissing + scalingFactor: JsonField = JsonMissing.of(), + @JsonProperty("scaling_value") + @ExcludeMissing + scalingValue: JsonField = JsonMissing.of(), + ) : this(scalingFactor, scalingValue, mutableMapOf()) + + /** + * Scaling factor + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun scalingFactor(): String = scalingFactor.getRequired("scaling_factor") + + /** + * Scaling value + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun scalingValue(): String = scalingValue.getRequired("scaling_value") + + /** + * Returns the raw JSON value of [scalingFactor]. + * + * Unlike [scalingFactor], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("scaling_factor") + @ExcludeMissing + fun _scalingFactor(): JsonField = scalingFactor + + /** + * Returns the raw JSON value of [scalingValue]. + * + * Unlike [scalingValue], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("scaling_value") + @ExcludeMissing + fun _scalingValue(): JsonField = scalingValue + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ScalingFactor]. + * + * The following fields are required: + * ```kotlin + * .scalingFactor() + * .scalingValue() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [ScalingFactor]. */ + class Builder internal constructor() { + + private var scalingFactor: JsonField? = null + private var scalingValue: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(scalingFactor: ScalingFactor) = apply { + this.scalingFactor = scalingFactor.scalingFactor + scalingValue = scalingFactor.scalingValue + additionalProperties = scalingFactor.additionalProperties.toMutableMap() + } + + /** Scaling factor */ + fun scalingFactor(scalingFactor: String) = + scalingFactor(JsonField.of(scalingFactor)) + + /** + * Sets [Builder.scalingFactor] to an arbitrary JSON value. + * + * You should usually call [Builder.scalingFactor] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun scalingFactor(scalingFactor: JsonField) = apply { + this.scalingFactor = scalingFactor + } + + /** Scaling value */ + fun scalingValue(scalingValue: String) = scalingValue(JsonField.of(scalingValue)) + + /** + * Sets [Builder.scalingValue] to an arbitrary JSON value. + * + * You should usually call [Builder.scalingValue] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun scalingValue(scalingValue: JsonField) = apply { + this.scalingValue = scalingValue + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ScalingFactor]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .scalingFactor() + * .scalingValue() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ScalingFactor = + ScalingFactor( + checkRequired("scalingFactor", scalingFactor), + checkRequired("scalingValue", scalingValue), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ScalingFactor = apply { + if (validated) { + return@apply + } + + scalingFactor() + scalingValue() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (scalingFactor.asKnown() == null) 0 else 1) + + (if (scalingValue.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ScalingFactor && + scalingFactor == other.scalingFactor && + scalingValue == other.scalingValue && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(scalingFactor, scalingValue, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ScalingFactor{scalingFactor=$scalingFactor, scalingValue=$scalingValue, additionalProperties=$additionalProperties}" + } + + /** Configuration for a unit amount */ + class UnitAmount + private constructor( + private val pricingValue: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("pricing_value") + @ExcludeMissing + pricingValue: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(pricingValue, unitAmount, mutableMapOf()) + + /** + * Pricing value + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun pricingValue(): String = pricingValue.getRequired("pricing_value") + + /** + * Per unit amount + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [pricingValue]. + * + * Unlike [pricingValue], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("pricing_value") + @ExcludeMissing + fun _pricingValue(): JsonField = pricingValue + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [UnitAmount]. + * + * The following fields are required: + * ```kotlin + * .pricingValue() + * .unitAmount() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [UnitAmount]. */ + class Builder internal constructor() { + + private var pricingValue: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(unitAmount: UnitAmount) = apply { + pricingValue = unitAmount.pricingValue + this.unitAmount = unitAmount.unitAmount + additionalProperties = unitAmount.additionalProperties.toMutableMap() + } + + /** Pricing value */ + fun pricingValue(pricingValue: String) = pricingValue(JsonField.of(pricingValue)) + + /** + * Sets [Builder.pricingValue] to an arbitrary JSON value. + * + * You should usually call [Builder.pricingValue] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun pricingValue(pricingValue: JsonField) = apply { + this.pricingValue = pricingValue + } + + /** Per unit amount */ + fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [UnitAmount]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .pricingValue() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UnitAmount = + UnitAmount( + checkRequired("pricingValue", pricingValue), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UnitAmount = apply { + if (validated) { + return@apply + } + + pricingValue() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (pricingValue.asKnown() == null) 0 else 1) + + (if (unitAmount.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnitAmount && + pricingValue == other.pricingValue && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(pricingValue, unitAmount, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UnitAmount{pricingValue=$pricingValue, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } override fun equals(other: Any?): Boolean { if (this === other) { @@ -1155,17 +1909,34 @@ private constructor( } return other is GroupedWithMeteredMinimumConfig && + groupingKey == other.groupingKey && + minimumUnitAmount == other.minimumUnitAmount && + pricingKey == other.pricingKey && + scalingFactors == other.scalingFactors && + scalingKey == other.scalingKey && + unitAmounts == other.unitAmounts && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + private val hashCode: Int by lazy { + Objects.hash( + groupingKey, + minimumUnitAmount, + pricingKey, + scalingFactors, + scalingKey, + unitAmounts, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode override fun toString() = - "GroupedWithMeteredMinimumConfig{additionalProperties=$additionalProperties}" + "GroupedWithMeteredMinimumConfig{groupingKey=$groupingKey, minimumUnitAmount=$minimumUnitAmount, pricingKey=$pricingKey, scalingFactors=$scalingFactors, scalingKey=$scalingKey, unitAmounts=$unitAmounts, additionalProperties=$additionalProperties}" } + /** The pricing model type */ class ModelType @JsonCreator private constructor(private val value: JsonField) : Enum { /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingGroupedWithProratedMinimumPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingGroupedWithProratedMinimumPrice.kt index eb04b2c67..6d06d7192 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingGroupedWithProratedMinimumPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingGroupedWithProratedMinimumPrice.kt @@ -122,6 +122,8 @@ private constructor( fun currency(): String = currency.getRequired("currency") /** + * Configuration for grouped_with_prorated_minimum pricing + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ @@ -137,6 +139,8 @@ private constructor( fun itemId(): String = itemId.getRequired("item_id") /** + * The pricing model type + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ @@ -506,6 +510,7 @@ private constructor( */ fun currency(currency: JsonField) = apply { this.currency = currency } + /** Configuration for grouped_with_prorated_minimum pricing */ fun groupedWithProratedMinimumConfig( groupedWithProratedMinimumConfig: GroupedWithProratedMinimumConfig ) = groupedWithProratedMinimumConfig(JsonField.of(groupedWithProratedMinimumConfig)) @@ -532,6 +537,7 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + /** The pricing model type */ fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) /** @@ -1061,16 +1067,82 @@ private constructor( override fun toString() = value.toString() } + /** Configuration for grouped_with_prorated_minimum pricing */ class GroupedWithProratedMinimumConfig - @JsonCreator private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map + private val groupingKey: JsonField, + private val minimum: JsonField, + private val unitRate: JsonField, + private val additionalProperties: MutableMap, ) { + @JsonCreator + private constructor( + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("minimum") @ExcludeMissing minimum: JsonField = JsonMissing.of(), + @JsonProperty("unit_rate") + @ExcludeMissing + unitRate: JsonField = JsonMissing.of(), + ) : this(groupingKey, minimum, unitRate, mutableMapOf()) + + /** + * How to determine the groups that should each have a minimum + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The minimum amount to charge per group + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun minimum(): String = minimum.getRequired("minimum") + + /** + * The amount to charge per unit + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun unitRate(): String = unitRate.getRequired("unit_rate") + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [minimum]. + * + * Unlike [minimum], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("minimum") @ExcludeMissing fun _minimum(): JsonField = minimum + + /** + * Returns the raw JSON value of [unitRate]. + * + * Unlike [unitRate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("unit_rate") @ExcludeMissing fun _unitRate(): JsonField = unitRate + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) fun toBuilder() = Builder().from(this) @@ -1079,6 +1151,13 @@ private constructor( /** * Returns a mutable builder for constructing an instance of * [GroupedWithProratedMinimumConfig]. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .minimum() + * .unitRate() + * ``` */ fun builder() = Builder() } @@ -1086,14 +1165,58 @@ private constructor( /** A builder for [GroupedWithProratedMinimumConfig]. */ class Builder internal constructor() { + private var groupingKey: JsonField? = null + private var minimum: JsonField? = null + private var unitRate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(groupedWithProratedMinimumConfig: GroupedWithProratedMinimumConfig) = apply { + groupingKey = groupedWithProratedMinimumConfig.groupingKey + minimum = groupedWithProratedMinimumConfig.minimum + unitRate = groupedWithProratedMinimumConfig.unitRate additionalProperties = groupedWithProratedMinimumConfig.additionalProperties.toMutableMap() } + /** How to determine the groups that should each have a minimum */ + fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The minimum amount to charge per group */ + fun minimum(minimum: String) = minimum(JsonField.of(minimum)) + + /** + * Sets [Builder.minimum] to an arbitrary JSON value. + * + * You should usually call [Builder.minimum] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun minimum(minimum: JsonField) = apply { this.minimum = minimum } + + /** The amount to charge per unit */ + fun unitRate(unitRate: String) = unitRate(JsonField.of(unitRate)) + + /** + * Sets [Builder.unitRate] to an arbitrary JSON value. + * + * You should usually call [Builder.unitRate] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun unitRate(unitRate: JsonField) = apply { this.unitRate = unitRate } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -1117,9 +1240,23 @@ private constructor( * Returns an immutable instance of [GroupedWithProratedMinimumConfig]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .minimum() + * .unitRate() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ fun build(): GroupedWithProratedMinimumConfig = - GroupedWithProratedMinimumConfig(additionalProperties.toImmutable()) + GroupedWithProratedMinimumConfig( + checkRequired("groupingKey", groupingKey), + checkRequired("minimum", minimum), + checkRequired("unitRate", unitRate), + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false @@ -1129,6 +1266,9 @@ private constructor( return@apply } + groupingKey() + minimum() + unitRate() validated = true } @@ -1147,7 +1287,9 @@ private constructor( * Used for best match union deserialization. */ internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + (if (groupingKey.asKnown() == null) 0 else 1) + + (if (minimum.asKnown() == null) 0 else 1) + + (if (unitRate.asKnown() == null) 0 else 1) override fun equals(other: Any?): Boolean { if (this === other) { @@ -1155,17 +1297,23 @@ private constructor( } return other is GroupedWithProratedMinimumConfig && + groupingKey == other.groupingKey && + minimum == other.minimum && + unitRate == other.unitRate && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + private val hashCode: Int by lazy { + Objects.hash(groupingKey, minimum, unitRate, additionalProperties) + } override fun hashCode(): Int = hashCode override fun toString() = - "GroupedWithProratedMinimumConfig{additionalProperties=$additionalProperties}" + "GroupedWithProratedMinimumConfig{groupingKey=$groupingKey, minimum=$minimum, unitRate=$unitRate, additionalProperties=$additionalProperties}" } + /** The pricing model type */ class ModelType @JsonCreator private constructor(private val value: JsonField) : Enum { /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingMatrixPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingMatrixPrice.kt index 146cca862..12fcd4e34 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingMatrixPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingMatrixPrice.kt @@ -129,12 +129,16 @@ private constructor( fun itemId(): String = itemId.getRequired("item_id") /** + * Configuration for matrix pricing + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ fun matrixConfig(): MatrixConfig = matrixConfig.getRequired("matrix_config") /** + * The pricing model type + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ @@ -504,6 +508,7 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + /** Configuration for matrix pricing */ fun matrixConfig(matrixConfig: MatrixConfig) = matrixConfig(JsonField.of(matrixConfig)) /** @@ -517,6 +522,7 @@ private constructor( this.matrixConfig = matrixConfig } + /** The pricing model type */ fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) /** @@ -1046,6 +1052,7 @@ private constructor( override fun toString() = value.toString() } + /** The pricing model type */ class ModelType @JsonCreator private constructor(private val value: JsonField) : Enum { /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingMatrixWithAllocationPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingMatrixWithAllocationPrice.kt index 6bb525f1b..9e92652dd 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingMatrixWithAllocationPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingMatrixWithAllocationPrice.kt @@ -129,6 +129,8 @@ private constructor( fun itemId(): String = itemId.getRequired("item_id") /** + * Configuration for matrix_with_allocation pricing + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ @@ -136,6 +138,8 @@ private constructor( matrixWithAllocationConfig.getRequired("matrix_with_allocation_config") /** + * The pricing model type + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ @@ -515,6 +519,7 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + /** Configuration for matrix_with_allocation pricing */ fun matrixWithAllocationConfig(matrixWithAllocationConfig: MatrixWithAllocationConfig) = matrixWithAllocationConfig(JsonField.of(matrixWithAllocationConfig)) @@ -529,6 +534,7 @@ private constructor( matrixWithAllocationConfig: JsonField ) = apply { this.matrixWithAllocationConfig = matrixWithAllocationConfig } + /** The pricing model type */ fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) /** @@ -1058,6 +1064,7 @@ private constructor( override fun toString() = value.toString() } + /** The pricing model type */ class ModelType @JsonCreator private constructor(private val value: JsonField) : Enum { /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingMatrixWithDisplayNamePrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingMatrixWithDisplayNamePrice.kt index 55d03bd70..52fc0b8d0 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingMatrixWithDisplayNamePrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingMatrixWithDisplayNamePrice.kt @@ -11,6 +11,7 @@ import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue +import com.withorb.api.core.checkKnown import com.withorb.api.core.checkRequired import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException @@ -129,6 +130,8 @@ private constructor( fun itemId(): String = itemId.getRequired("item_id") /** + * Configuration for matrix_with_display_name pricing + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ @@ -136,6 +139,8 @@ private constructor( matrixWithDisplayNameConfig.getRequired("matrix_with_display_name_config") /** + * The pricing model type + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ @@ -515,6 +520,7 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + /** Configuration for matrix_with_display_name pricing */ fun matrixWithDisplayNameConfig(matrixWithDisplayNameConfig: MatrixWithDisplayNameConfig) = matrixWithDisplayNameConfig(JsonField.of(matrixWithDisplayNameConfig)) @@ -529,6 +535,7 @@ private constructor( matrixWithDisplayNameConfig: JsonField ) = apply { this.matrixWithDisplayNameConfig = matrixWithDisplayNameConfig } + /** The pricing model type */ fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) /** @@ -1058,16 +1065,65 @@ private constructor( override fun toString() = value.toString() } + /** Configuration for matrix_with_display_name pricing */ class MatrixWithDisplayNameConfig - @JsonCreator private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map + private val dimension: JsonField, + private val unitAmounts: JsonField>, + private val additionalProperties: MutableMap, ) { + @JsonCreator + private constructor( + @JsonProperty("dimension") + @ExcludeMissing + dimension: JsonField = JsonMissing.of(), + @JsonProperty("unit_amounts") + @ExcludeMissing + unitAmounts: JsonField> = JsonMissing.of(), + ) : this(dimension, unitAmounts, mutableMapOf()) + + /** + * Used to determine the unit rate + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun dimension(): String = dimension.getRequired("dimension") + + /** + * Apply per unit pricing to each dimension value + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun unitAmounts(): List = unitAmounts.getRequired("unit_amounts") + + /** + * Returns the raw JSON value of [dimension]. + * + * Unlike [dimension], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("dimension") @ExcludeMissing fun _dimension(): JsonField = dimension + + /** + * Returns the raw JSON value of [unitAmounts]. + * + * Unlike [unitAmounts], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("unit_amounts") + @ExcludeMissing + fun _unitAmounts(): JsonField> = unitAmounts + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) fun toBuilder() = Builder().from(this) @@ -1076,6 +1132,12 @@ private constructor( /** * Returns a mutable builder for constructing an instance of * [MatrixWithDisplayNameConfig]. + * + * The following fields are required: + * ```kotlin + * .dimension() + * .unitAmounts() + * ``` */ fun builder() = Builder() } @@ -1083,13 +1145,55 @@ private constructor( /** A builder for [MatrixWithDisplayNameConfig]. */ class Builder internal constructor() { + private var dimension: JsonField? = null + private var unitAmounts: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(matrixWithDisplayNameConfig: MatrixWithDisplayNameConfig) = apply { + dimension = matrixWithDisplayNameConfig.dimension + unitAmounts = matrixWithDisplayNameConfig.unitAmounts.map { it.toMutableList() } additionalProperties = matrixWithDisplayNameConfig.additionalProperties.toMutableMap() } + /** Used to determine the unit rate */ + fun dimension(dimension: String) = dimension(JsonField.of(dimension)) + + /** + * Sets [Builder.dimension] to an arbitrary JSON value. + * + * You should usually call [Builder.dimension] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun dimension(dimension: JsonField) = apply { this.dimension = dimension } + + /** Apply per unit pricing to each dimension value */ + fun unitAmounts(unitAmounts: List) = unitAmounts(JsonField.of(unitAmounts)) + + /** + * Sets [Builder.unitAmounts] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmounts] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun unitAmounts(unitAmounts: JsonField>) = apply { + this.unitAmounts = unitAmounts.map { it.toMutableList() } + } + + /** + * Adds a single [UnitAmount] to [unitAmounts]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addUnitAmount(unitAmount: UnitAmount) = apply { + unitAmounts = + (unitAmounts ?: JsonField.of(mutableListOf())).also { + checkKnown("unitAmounts", it).add(unitAmount) + } + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -1113,9 +1217,21 @@ private constructor( * Returns an immutable instance of [MatrixWithDisplayNameConfig]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .dimension() + * .unitAmounts() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ fun build(): MatrixWithDisplayNameConfig = - MatrixWithDisplayNameConfig(additionalProperties.toImmutable()) + MatrixWithDisplayNameConfig( + checkRequired("dimension", dimension), + checkRequired("unitAmounts", unitAmounts).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false @@ -1125,6 +1241,8 @@ private constructor( return@apply } + dimension() + unitAmounts().forEach { it.validate() } validated = true } @@ -1143,7 +1261,271 @@ private constructor( * Used for best match union deserialization. */ internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + (if (dimension.asKnown() == null) 0 else 1) + + (unitAmounts.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a unit amount item */ + class UnitAmount + private constructor( + private val dimensionValue: JsonField, + private val displayName: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("dimension_value") + @ExcludeMissing + dimensionValue: JsonField = JsonMissing.of(), + @JsonProperty("display_name") + @ExcludeMissing + displayName: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(dimensionValue, displayName, unitAmount, mutableMapOf()) + + /** + * The dimension value + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun dimensionValue(): String = dimensionValue.getRequired("dimension_value") + + /** + * Display name for this dimension value + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun displayName(): String = displayName.getRequired("display_name") + + /** + * Per unit amount + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [dimensionValue]. + * + * Unlike [dimensionValue], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("dimension_value") + @ExcludeMissing + fun _dimensionValue(): JsonField = dimensionValue + + /** + * Returns the raw JSON value of [displayName]. + * + * Unlike [displayName], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("display_name") + @ExcludeMissing + fun _displayName(): JsonField = displayName + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [UnitAmount]. + * + * The following fields are required: + * ```kotlin + * .dimensionValue() + * .displayName() + * .unitAmount() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [UnitAmount]. */ + class Builder internal constructor() { + + private var dimensionValue: JsonField? = null + private var displayName: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(unitAmount: UnitAmount) = apply { + dimensionValue = unitAmount.dimensionValue + displayName = unitAmount.displayName + this.unitAmount = unitAmount.unitAmount + additionalProperties = unitAmount.additionalProperties.toMutableMap() + } + + /** The dimension value */ + fun dimensionValue(dimensionValue: String) = + dimensionValue(JsonField.of(dimensionValue)) + + /** + * Sets [Builder.dimensionValue] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionValue] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun dimensionValue(dimensionValue: JsonField) = apply { + this.dimensionValue = dimensionValue + } + + /** Display name for this dimension value */ + fun displayName(displayName: String) = displayName(JsonField.of(displayName)) + + /** + * Sets [Builder.displayName] to an arbitrary JSON value. + * + * You should usually call [Builder.displayName] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun displayName(displayName: JsonField) = apply { + this.displayName = displayName + } + + /** Per unit amount */ + fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [UnitAmount]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .dimensionValue() + * .displayName() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UnitAmount = + UnitAmount( + checkRequired("dimensionValue", dimensionValue), + checkRequired("displayName", displayName), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UnitAmount = apply { + if (validated) { + return@apply + } + + dimensionValue() + displayName() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (dimensionValue.asKnown() == null) 0 else 1) + + (if (displayName.asKnown() == null) 0 else 1) + + (if (unitAmount.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnitAmount && + dimensionValue == other.dimensionValue && + displayName == other.displayName && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(dimensionValue, displayName, unitAmount, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UnitAmount{dimensionValue=$dimensionValue, displayName=$displayName, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } override fun equals(other: Any?): Boolean { if (this === other) { @@ -1151,17 +1533,22 @@ private constructor( } return other is MatrixWithDisplayNameConfig && + dimension == other.dimension && + unitAmounts == other.unitAmounts && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + private val hashCode: Int by lazy { + Objects.hash(dimension, unitAmounts, additionalProperties) + } override fun hashCode(): Int = hashCode override fun toString() = - "MatrixWithDisplayNameConfig{additionalProperties=$additionalProperties}" + "MatrixWithDisplayNameConfig{dimension=$dimension, unitAmounts=$unitAmounts, additionalProperties=$additionalProperties}" } + /** The pricing model type */ class ModelType @JsonCreator private constructor(private val value: JsonField) : Enum { /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingMaxGroupTieredPackagePrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingMaxGroupTieredPackagePrice.kt index c61dc9fba..8e681e430 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingMaxGroupTieredPackagePrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingMaxGroupTieredPackagePrice.kt @@ -11,6 +11,7 @@ import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue +import com.withorb.api.core.checkKnown import com.withorb.api.core.checkRequired import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException @@ -129,6 +130,8 @@ private constructor( fun itemId(): String = itemId.getRequired("item_id") /** + * Configuration for max_group_tiered_package pricing + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ @@ -136,6 +139,8 @@ private constructor( maxGroupTieredPackageConfig.getRequired("max_group_tiered_package_config") /** + * The pricing model type + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ @@ -515,6 +520,7 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + /** Configuration for max_group_tiered_package pricing */ fun maxGroupTieredPackageConfig(maxGroupTieredPackageConfig: MaxGroupTieredPackageConfig) = maxGroupTieredPackageConfig(JsonField.of(maxGroupTieredPackageConfig)) @@ -529,6 +535,7 @@ private constructor( maxGroupTieredPackageConfig: JsonField ) = apply { this.maxGroupTieredPackageConfig = maxGroupTieredPackageConfig } + /** The pricing model type */ fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) /** @@ -1058,16 +1065,84 @@ private constructor( override fun toString() = value.toString() } + /** Configuration for max_group_tiered_package pricing */ class MaxGroupTieredPackageConfig - @JsonCreator private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map + private val groupingKey: JsonField, + private val packageSize: JsonField, + private val tiers: JsonField>, + private val additionalProperties: MutableMap, ) { + @JsonCreator + private constructor( + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("package_size") + @ExcludeMissing + packageSize: JsonField = JsonMissing.of(), + @JsonProperty("tiers") @ExcludeMissing tiers: JsonField> = JsonMissing.of(), + ) : this(groupingKey, packageSize, tiers, mutableMapOf()) + + /** + * The event property used to group before tiering the group with the highest value + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * Package size + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun packageSize(): String = packageSize.getRequired("package_size") + + /** + * Apply tiered pricing to the largest group after grouping with the provided key. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun tiers(): List = tiers.getRequired("tiers") + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [packageSize]. + * + * Unlike [packageSize], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("package_size") + @ExcludeMissing + fun _packageSize(): JsonField = packageSize + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tiers") @ExcludeMissing fun _tiers(): JsonField> = tiers + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) fun toBuilder() = Builder().from(this) @@ -1076,6 +1151,13 @@ private constructor( /** * Returns a mutable builder for constructing an instance of * [MaxGroupTieredPackageConfig]. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .packageSize() + * .tiers() + * ``` */ fun builder() = Builder() } @@ -1083,13 +1165,73 @@ private constructor( /** A builder for [MaxGroupTieredPackageConfig]. */ class Builder internal constructor() { + private var groupingKey: JsonField? = null + private var packageSize: JsonField? = null + private var tiers: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(maxGroupTieredPackageConfig: MaxGroupTieredPackageConfig) = apply { + groupingKey = maxGroupTieredPackageConfig.groupingKey + packageSize = maxGroupTieredPackageConfig.packageSize + tiers = maxGroupTieredPackageConfig.tiers.map { it.toMutableList() } additionalProperties = maxGroupTieredPackageConfig.additionalProperties.toMutableMap() } + /** The event property used to group before tiering the group with the highest value */ + fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** Package size */ + fun packageSize(packageSize: String) = packageSize(JsonField.of(packageSize)) + + /** + * Sets [Builder.packageSize] to an arbitrary JSON value. + * + * You should usually call [Builder.packageSize] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun packageSize(packageSize: JsonField) = apply { + this.packageSize = packageSize + } + + /** Apply tiered pricing to the largest group after grouping with the provided key. */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -1113,9 +1255,23 @@ private constructor( * Returns an immutable instance of [MaxGroupTieredPackageConfig]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .packageSize() + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ fun build(): MaxGroupTieredPackageConfig = - MaxGroupTieredPackageConfig(additionalProperties.toImmutable()) + MaxGroupTieredPackageConfig( + checkRequired("groupingKey", groupingKey), + checkRequired("packageSize", packageSize), + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false @@ -1125,6 +1281,9 @@ private constructor( return@apply } + groupingKey() + packageSize() + tiers().forEach { it.validate() } validated = true } @@ -1143,7 +1302,227 @@ private constructor( * Used for best match union deserialization. */ internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + (if (groupingKey.asKnown() == null) 0 else 1) + + (if (packageSize.asKnown() == null) 0 else 1) + + (tiers.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single tier */ + class Tier + private constructor( + private val tierLowerBound: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(tierLowerBound, unitAmount, mutableMapOf()) + + /** + * Tier lower bound + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun tierLowerBound(): String = tierLowerBound.getRequired("tier_lower_bound") + + /** + * Per unit amount + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Tier]. + * + * The following fields are required: + * ```kotlin + * .tierLowerBound() + * .unitAmount() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var tierLowerBound: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(tier: Tier) = apply { + tierLowerBound = tier.tierLowerBound + unitAmount = tier.unitAmount + additionalProperties = tier.additionalProperties.toMutableMap() + } + + /** Tier lower bound */ + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + /** Per unit amount */ + fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Tier]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .tierLowerBound() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("tierLowerBound", tierLowerBound), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + tierLowerBound() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (tierLowerBound.asKnown() == null) 0 else 1) + + (if (unitAmount.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + tierLowerBound == other.tierLowerBound && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(tierLowerBound, unitAmount, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } override fun equals(other: Any?): Boolean { if (this === other) { @@ -1151,17 +1530,23 @@ private constructor( } return other is MaxGroupTieredPackageConfig && + groupingKey == other.groupingKey && + packageSize == other.packageSize && + tiers == other.tiers && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + private val hashCode: Int by lazy { + Objects.hash(groupingKey, packageSize, tiers, additionalProperties) + } override fun hashCode(): Int = hashCode override fun toString() = - "MaxGroupTieredPackageConfig{additionalProperties=$additionalProperties}" + "MaxGroupTieredPackageConfig{groupingKey=$groupingKey, packageSize=$packageSize, tiers=$tiers, additionalProperties=$additionalProperties}" } + /** The pricing model type */ class ModelType @JsonCreator private constructor(private val value: JsonField) : Enum { /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingMinimumCompositePrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingMinimumCompositePrice.kt index 9e8f49f36..ed367990e 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingMinimumCompositePrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingMinimumCompositePrice.kt @@ -129,12 +129,16 @@ private constructor( fun itemId(): String = itemId.getRequired("item_id") /** + * Configuration for minimum pricing + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ fun minimumConfig(): MinimumConfig = minimumConfig.getRequired("minimum_config") /** + * The pricing model type + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ @@ -510,6 +514,7 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + /** Configuration for minimum pricing */ fun minimumConfig(minimumConfig: MinimumConfig) = minimumConfig(JsonField.of(minimumConfig)) /** @@ -523,6 +528,7 @@ private constructor( this.minimumConfig = minimumConfig } + /** The pricing model type */ fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) /** @@ -1052,6 +1058,7 @@ private constructor( override fun toString() = value.toString() } + /** Configuration for minimum pricing */ class MinimumConfig private constructor( private val minimumAmount: JsonField, @@ -1078,8 +1085,7 @@ private constructor( fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") /** - * By default, subtotals from minimum composite prices are prorated based on the service - * period. Set to false to disable proration. + * If true, subtotals from this price are prorated based on the service period * * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -1155,18 +1161,8 @@ private constructor( this.minimumAmount = minimumAmount } - /** - * By default, subtotals from minimum composite prices are prorated based on the service - * period. Set to false to disable proration. - */ - fun prorated(prorated: Boolean?) = prorated(JsonField.ofNullable(prorated)) - - /** - * Alias for [Builder.prorated]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun prorated(prorated: Boolean) = prorated(prorated as Boolean?) + /** If true, subtotals from this price are prorated based on the service period */ + fun prorated(prorated: Boolean) = prorated(JsonField.of(prorated)) /** * Sets [Builder.prorated] to an arbitrary JSON value. @@ -1267,6 +1263,7 @@ private constructor( "MinimumConfig{minimumAmount=$minimumAmount, prorated=$prorated, additionalProperties=$additionalProperties}" } + /** The pricing model type */ class ModelType @JsonCreator private constructor(private val value: JsonField) : Enum { /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingPackagePrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingPackagePrice.kt index 6c203872f..6f5daf5f9 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingPackagePrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingPackagePrice.kt @@ -129,6 +129,8 @@ private constructor( fun itemId(): String = itemId.getRequired("item_id") /** + * The pricing model type + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ @@ -143,6 +145,8 @@ private constructor( fun name(): String = name.getRequired("name") /** + * Configuration for package pricing + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ @@ -504,6 +508,7 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + /** The pricing model type */ fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) /** @@ -526,6 +531,7 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } + /** Configuration for package pricing */ fun packageConfig(packageConfig: PackageConfig) = packageConfig(JsonField.of(packageConfig)) /** @@ -1046,6 +1052,7 @@ private constructor( override fun toString() = value.toString() } + /** The pricing model type */ class ModelType @JsonCreator private constructor(private val value: JsonField) : Enum { /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingPackageWithAllocationPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingPackageWithAllocationPrice.kt index a593271f5..aab035939 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingPackageWithAllocationPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingPackageWithAllocationPrice.kt @@ -129,6 +129,8 @@ private constructor( fun itemId(): String = itemId.getRequired("item_id") /** + * The pricing model type + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ @@ -143,6 +145,8 @@ private constructor( fun name(): String = name.getRequired("name") /** + * Configuration for package_with_allocation pricing + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ @@ -515,6 +519,7 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + /** The pricing model type */ fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) /** @@ -537,6 +542,7 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } + /** Configuration for package_with_allocation pricing */ fun packageWithAllocationConfig(packageWithAllocationConfig: PackageWithAllocationConfig) = packageWithAllocationConfig(JsonField.of(packageWithAllocationConfig)) @@ -1058,6 +1064,7 @@ private constructor( override fun toString() = value.toString() } + /** The pricing model type */ class ModelType @JsonCreator private constructor(private val value: JsonField) : Enum { /** @@ -1178,16 +1185,89 @@ private constructor( override fun toString() = value.toString() } + /** Configuration for package_with_allocation pricing */ class PackageWithAllocationConfig - @JsonCreator private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map + private val allocation: JsonField, + private val packageAmount: JsonField, + private val packageSize: JsonField, + private val additionalProperties: MutableMap, ) { + @JsonCreator + private constructor( + @JsonProperty("allocation") + @ExcludeMissing + allocation: JsonField = JsonMissing.of(), + @JsonProperty("package_amount") + @ExcludeMissing + packageAmount: JsonField = JsonMissing.of(), + @JsonProperty("package_size") + @ExcludeMissing + packageSize: JsonField = JsonMissing.of(), + ) : this(allocation, packageAmount, packageSize, mutableMapOf()) + + /** + * Usage allocation + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun allocation(): String = allocation.getRequired("allocation") + + /** + * Price per package + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun packageAmount(): String = packageAmount.getRequired("package_amount") + + /** + * Package size + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun packageSize(): String = packageSize.getRequired("package_size") + + /** + * Returns the raw JSON value of [allocation]. + * + * Unlike [allocation], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("allocation") + @ExcludeMissing + fun _allocation(): JsonField = allocation + + /** + * Returns the raw JSON value of [packageAmount]. + * + * Unlike [packageAmount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("package_amount") + @ExcludeMissing + fun _packageAmount(): JsonField = packageAmount + + /** + * Returns the raw JSON value of [packageSize]. + * + * Unlike [packageSize], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("package_size") + @ExcludeMissing + fun _packageSize(): JsonField = packageSize + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) fun toBuilder() = Builder().from(this) @@ -1196,6 +1276,13 @@ private constructor( /** * Returns a mutable builder for constructing an instance of * [PackageWithAllocationConfig]. + * + * The following fields are required: + * ```kotlin + * .allocation() + * .packageAmount() + * .packageSize() + * ``` */ fun builder() = Builder() } @@ -1203,13 +1290,59 @@ private constructor( /** A builder for [PackageWithAllocationConfig]. */ class Builder internal constructor() { + private var allocation: JsonField? = null + private var packageAmount: JsonField? = null + private var packageSize: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(packageWithAllocationConfig: PackageWithAllocationConfig) = apply { + allocation = packageWithAllocationConfig.allocation + packageAmount = packageWithAllocationConfig.packageAmount + packageSize = packageWithAllocationConfig.packageSize additionalProperties = packageWithAllocationConfig.additionalProperties.toMutableMap() } + /** Usage allocation */ + fun allocation(allocation: String) = allocation(JsonField.of(allocation)) + + /** + * Sets [Builder.allocation] to an arbitrary JSON value. + * + * You should usually call [Builder.allocation] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun allocation(allocation: JsonField) = apply { this.allocation = allocation } + + /** Price per package */ + fun packageAmount(packageAmount: String) = packageAmount(JsonField.of(packageAmount)) + + /** + * Sets [Builder.packageAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.packageAmount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun packageAmount(packageAmount: JsonField) = apply { + this.packageAmount = packageAmount + } + + /** Package size */ + fun packageSize(packageSize: String) = packageSize(JsonField.of(packageSize)) + + /** + * Sets [Builder.packageSize] to an arbitrary JSON value. + * + * You should usually call [Builder.packageSize] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun packageSize(packageSize: JsonField) = apply { + this.packageSize = packageSize + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -1233,9 +1366,23 @@ private constructor( * Returns an immutable instance of [PackageWithAllocationConfig]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .allocation() + * .packageAmount() + * .packageSize() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ fun build(): PackageWithAllocationConfig = - PackageWithAllocationConfig(additionalProperties.toImmutable()) + PackageWithAllocationConfig( + checkRequired("allocation", allocation), + checkRequired("packageAmount", packageAmount), + checkRequired("packageSize", packageSize), + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false @@ -1245,6 +1392,9 @@ private constructor( return@apply } + allocation() + packageAmount() + packageSize() validated = true } @@ -1263,7 +1413,9 @@ private constructor( * Used for best match union deserialization. */ internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + (if (allocation.asKnown() == null) 0 else 1) + + (if (packageAmount.asKnown() == null) 0 else 1) + + (if (packageSize.asKnown() == null) 0 else 1) override fun equals(other: Any?): Boolean { if (this === other) { @@ -1271,15 +1423,20 @@ private constructor( } return other is PackageWithAllocationConfig && + allocation == other.allocation && + packageAmount == other.packageAmount && + packageSize == other.packageSize && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + private val hashCode: Int by lazy { + Objects.hash(allocation, packageAmount, packageSize, additionalProperties) + } override fun hashCode(): Int = hashCode override fun toString() = - "PackageWithAllocationConfig{additionalProperties=$additionalProperties}" + "PackageWithAllocationConfig{allocation=$allocation, packageAmount=$packageAmount, packageSize=$packageSize, additionalProperties=$additionalProperties}" } /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingScalableMatrixWithTieredPricingPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingScalableMatrixWithTieredPricingPrice.kt index 981236464..5967337f1 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingScalableMatrixWithTieredPricingPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingScalableMatrixWithTieredPricingPrice.kt @@ -11,6 +11,7 @@ import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue +import com.withorb.api.core.checkKnown import com.withorb.api.core.checkRequired import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException @@ -131,6 +132,8 @@ private constructor( fun itemId(): String = itemId.getRequired("item_id") /** + * The pricing model type + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ @@ -145,6 +148,8 @@ private constructor( fun name(): String = name.getRequired("name") /** + * Configuration for scalable_matrix_with_tiered_pricing pricing + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ @@ -524,6 +529,7 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + /** The pricing model type */ fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) /** @@ -546,6 +552,7 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } + /** Configuration for scalable_matrix_with_tiered_pricing pricing */ fun scalableMatrixWithTieredPricingConfig( scalableMatrixWithTieredPricingConfig: ScalableMatrixWithTieredPricingConfig ) = @@ -1076,6 +1083,7 @@ private constructor( override fun toString() = value.toString() } + /** The pricing model type */ class ModelType @JsonCreator private constructor(private val value: JsonField) : Enum { /** @@ -1196,16 +1204,109 @@ private constructor( override fun toString() = value.toString() } + /** Configuration for scalable_matrix_with_tiered_pricing pricing */ class ScalableMatrixWithTieredPricingConfig - @JsonCreator private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map + private val firstDimension: JsonField, + private val matrixScalingFactors: JsonField>, + private val tiers: JsonField>, + private val secondDimension: JsonField, + private val additionalProperties: MutableMap, ) { + @JsonCreator + private constructor( + @JsonProperty("first_dimension") + @ExcludeMissing + firstDimension: JsonField = JsonMissing.of(), + @JsonProperty("matrix_scaling_factors") + @ExcludeMissing + matrixScalingFactors: JsonField> = JsonMissing.of(), + @JsonProperty("tiers") @ExcludeMissing tiers: JsonField> = JsonMissing.of(), + @JsonProperty("second_dimension") + @ExcludeMissing + secondDimension: JsonField = JsonMissing.of(), + ) : this(firstDimension, matrixScalingFactors, tiers, secondDimension, mutableMapOf()) + + /** + * Used for the scalable matrix first dimension + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun firstDimension(): String = firstDimension.getRequired("first_dimension") + + /** + * Apply a scaling factor to each dimension + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun matrixScalingFactors(): List = + matrixScalingFactors.getRequired("matrix_scaling_factors") + + /** + * Tier pricing structure + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun tiers(): List = tiers.getRequired("tiers") + + /** + * Used for the scalable matrix second dimension (optional) + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun secondDimension(): String? = secondDimension.getNullable("second_dimension") + + /** + * Returns the raw JSON value of [firstDimension]. + * + * Unlike [firstDimension], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("first_dimension") + @ExcludeMissing + fun _firstDimension(): JsonField = firstDimension + + /** + * Returns the raw JSON value of [matrixScalingFactors]. + * + * Unlike [matrixScalingFactors], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("matrix_scaling_factors") + @ExcludeMissing + fun _matrixScalingFactors(): JsonField> = matrixScalingFactors + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tiers") @ExcludeMissing fun _tiers(): JsonField> = tiers + + /** + * Returns the raw JSON value of [secondDimension]. + * + * Unlike [secondDimension], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("second_dimension") + @ExcludeMissing + fun _secondDimension(): JsonField = secondDimension + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) fun toBuilder() = Builder().from(this) @@ -1214,6 +1315,13 @@ private constructor( /** * Returns a mutable builder for constructing an instance of * [ScalableMatrixWithTieredPricingConfig]. + * + * The following fields are required: + * ```kotlin + * .firstDimension() + * .matrixScalingFactors() + * .tiers() + * ``` */ fun builder() = Builder() } @@ -1221,15 +1329,110 @@ private constructor( /** A builder for [ScalableMatrixWithTieredPricingConfig]. */ class Builder internal constructor() { + private var firstDimension: JsonField? = null + private var matrixScalingFactors: JsonField>? = null + private var tiers: JsonField>? = null + private var secondDimension: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() internal fun from( scalableMatrixWithTieredPricingConfig: ScalableMatrixWithTieredPricingConfig ) = apply { + firstDimension = scalableMatrixWithTieredPricingConfig.firstDimension + matrixScalingFactors = + scalableMatrixWithTieredPricingConfig.matrixScalingFactors.map { + it.toMutableList() + } + tiers = scalableMatrixWithTieredPricingConfig.tiers.map { it.toMutableList() } + secondDimension = scalableMatrixWithTieredPricingConfig.secondDimension additionalProperties = scalableMatrixWithTieredPricingConfig.additionalProperties.toMutableMap() } + /** Used for the scalable matrix first dimension */ + fun firstDimension(firstDimension: String) = + firstDimension(JsonField.of(firstDimension)) + + /** + * Sets [Builder.firstDimension] to an arbitrary JSON value. + * + * You should usually call [Builder.firstDimension] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun firstDimension(firstDimension: JsonField) = apply { + this.firstDimension = firstDimension + } + + /** Apply a scaling factor to each dimension */ + fun matrixScalingFactors(matrixScalingFactors: List) = + matrixScalingFactors(JsonField.of(matrixScalingFactors)) + + /** + * Sets [Builder.matrixScalingFactors] to an arbitrary JSON value. + * + * You should usually call [Builder.matrixScalingFactors] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun matrixScalingFactors(matrixScalingFactors: JsonField>) = + apply { + this.matrixScalingFactors = matrixScalingFactors.map { it.toMutableList() } + } + + /** + * Adds a single [MatrixScalingFactor] to [matrixScalingFactors]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addMatrixScalingFactor(matrixScalingFactor: MatrixScalingFactor) = apply { + matrixScalingFactors = + (matrixScalingFactors ?: JsonField.of(mutableListOf())).also { + checkKnown("matrixScalingFactors", it).add(matrixScalingFactor) + } + } + + /** Tier pricing structure */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + + /** Used for the scalable matrix second dimension (optional) */ + fun secondDimension(secondDimension: String?) = + secondDimension(JsonField.ofNullable(secondDimension)) + + /** + * Sets [Builder.secondDimension] to an arbitrary JSON value. + * + * You should usually call [Builder.secondDimension] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun secondDimension(secondDimension: JsonField) = apply { + this.secondDimension = secondDimension + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -1253,9 +1456,26 @@ private constructor( * Returns an immutable instance of [ScalableMatrixWithTieredPricingConfig]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .firstDimension() + * .matrixScalingFactors() + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ fun build(): ScalableMatrixWithTieredPricingConfig = - ScalableMatrixWithTieredPricingConfig(additionalProperties.toImmutable()) + ScalableMatrixWithTieredPricingConfig( + checkRequired("firstDimension", firstDimension), + checkRequired("matrixScalingFactors", matrixScalingFactors).map { + it.toImmutable() + }, + checkRequired("tiers", tiers).map { it.toImmutable() }, + secondDimension, + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false @@ -1265,6 +1485,10 @@ private constructor( return@apply } + firstDimension() + matrixScalingFactors().forEach { it.validate() } + tiers().forEach { it.validate() } + secondDimension() validated = true } @@ -1283,7 +1507,497 @@ private constructor( * Used for best match union deserialization. */ internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + (if (firstDimension.asKnown() == null) 0 else 1) + + (matrixScalingFactors.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + (tiers.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + (if (secondDimension.asKnown() == null) 0 else 1) + + /** Configuration for a single matrix scaling factor */ + class MatrixScalingFactor + private constructor( + private val firstDimensionValue: JsonField, + private val scalingFactor: JsonField, + private val secondDimensionValue: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("first_dimension_value") + @ExcludeMissing + firstDimensionValue: JsonField = JsonMissing.of(), + @JsonProperty("scaling_factor") + @ExcludeMissing + scalingFactor: JsonField = JsonMissing.of(), + @JsonProperty("second_dimension_value") + @ExcludeMissing + secondDimensionValue: JsonField = JsonMissing.of(), + ) : this(firstDimensionValue, scalingFactor, secondDimensionValue, mutableMapOf()) + + /** + * First dimension value + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun firstDimensionValue(): String = + firstDimensionValue.getRequired("first_dimension_value") + + /** + * Scaling factor + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun scalingFactor(): String = scalingFactor.getRequired("scaling_factor") + + /** + * Second dimension value (optional) + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun secondDimensionValue(): String? = + secondDimensionValue.getNullable("second_dimension_value") + + /** + * Returns the raw JSON value of [firstDimensionValue]. + * + * Unlike [firstDimensionValue], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("first_dimension_value") + @ExcludeMissing + fun _firstDimensionValue(): JsonField = firstDimensionValue + + /** + * Returns the raw JSON value of [scalingFactor]. + * + * Unlike [scalingFactor], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("scaling_factor") + @ExcludeMissing + fun _scalingFactor(): JsonField = scalingFactor + + /** + * Returns the raw JSON value of [secondDimensionValue]. + * + * Unlike [secondDimensionValue], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("second_dimension_value") + @ExcludeMissing + fun _secondDimensionValue(): JsonField = secondDimensionValue + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [MatrixScalingFactor]. + * + * The following fields are required: + * ```kotlin + * .firstDimensionValue() + * .scalingFactor() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [MatrixScalingFactor]. */ + class Builder internal constructor() { + + private var firstDimensionValue: JsonField? = null + private var scalingFactor: JsonField? = null + private var secondDimensionValue: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(matrixScalingFactor: MatrixScalingFactor) = apply { + firstDimensionValue = matrixScalingFactor.firstDimensionValue + scalingFactor = matrixScalingFactor.scalingFactor + secondDimensionValue = matrixScalingFactor.secondDimensionValue + additionalProperties = matrixScalingFactor.additionalProperties.toMutableMap() + } + + /** First dimension value */ + fun firstDimensionValue(firstDimensionValue: String) = + firstDimensionValue(JsonField.of(firstDimensionValue)) + + /** + * Sets [Builder.firstDimensionValue] to an arbitrary JSON value. + * + * You should usually call [Builder.firstDimensionValue] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun firstDimensionValue(firstDimensionValue: JsonField) = apply { + this.firstDimensionValue = firstDimensionValue + } + + /** Scaling factor */ + fun scalingFactor(scalingFactor: String) = + scalingFactor(JsonField.of(scalingFactor)) + + /** + * Sets [Builder.scalingFactor] to an arbitrary JSON value. + * + * You should usually call [Builder.scalingFactor] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun scalingFactor(scalingFactor: JsonField) = apply { + this.scalingFactor = scalingFactor + } + + /** Second dimension value (optional) */ + fun secondDimensionValue(secondDimensionValue: String?) = + secondDimensionValue(JsonField.ofNullable(secondDimensionValue)) + + /** + * Sets [Builder.secondDimensionValue] to an arbitrary JSON value. + * + * You should usually call [Builder.secondDimensionValue] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun secondDimensionValue(secondDimensionValue: JsonField) = apply { + this.secondDimensionValue = secondDimensionValue + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [MatrixScalingFactor]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .firstDimensionValue() + * .scalingFactor() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MatrixScalingFactor = + MatrixScalingFactor( + checkRequired("firstDimensionValue", firstDimensionValue), + checkRequired("scalingFactor", scalingFactor), + secondDimensionValue, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MatrixScalingFactor = apply { + if (validated) { + return@apply + } + + firstDimensionValue() + scalingFactor() + secondDimensionValue() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (firstDimensionValue.asKnown() == null) 0 else 1) + + (if (scalingFactor.asKnown() == null) 0 else 1) + + (if (secondDimensionValue.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MatrixScalingFactor && + firstDimensionValue == other.firstDimensionValue && + scalingFactor == other.scalingFactor && + secondDimensionValue == other.secondDimensionValue && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + firstDimensionValue, + scalingFactor, + secondDimensionValue, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MatrixScalingFactor{firstDimensionValue=$firstDimensionValue, scalingFactor=$scalingFactor, secondDimensionValue=$secondDimensionValue, additionalProperties=$additionalProperties}" + } + + /** Configuration for a single tier entry with business logic */ + class Tier + private constructor( + private val tierLowerBound: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(tierLowerBound, unitAmount, mutableMapOf()) + + /** + * Tier lower bound + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun tierLowerBound(): String = tierLowerBound.getRequired("tier_lower_bound") + + /** + * Per unit amount + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Tier]. + * + * The following fields are required: + * ```kotlin + * .tierLowerBound() + * .unitAmount() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var tierLowerBound: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(tier: Tier) = apply { + tierLowerBound = tier.tierLowerBound + unitAmount = tier.unitAmount + additionalProperties = tier.additionalProperties.toMutableMap() + } + + /** Tier lower bound */ + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + /** Per unit amount */ + fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Tier]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .tierLowerBound() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("tierLowerBound", tierLowerBound), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + tierLowerBound() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (tierLowerBound.asKnown() == null) 0 else 1) + + (if (unitAmount.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + tierLowerBound == other.tierLowerBound && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(tierLowerBound, unitAmount, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } override fun equals(other: Any?): Boolean { if (this === other) { @@ -1291,15 +2005,27 @@ private constructor( } return other is ScalableMatrixWithTieredPricingConfig && + firstDimension == other.firstDimension && + matrixScalingFactors == other.matrixScalingFactors && + tiers == other.tiers && + secondDimension == other.secondDimension && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + private val hashCode: Int by lazy { + Objects.hash( + firstDimension, + matrixScalingFactors, + tiers, + secondDimension, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode override fun toString() = - "ScalableMatrixWithTieredPricingConfig{additionalProperties=$additionalProperties}" + "ScalableMatrixWithTieredPricingConfig{firstDimension=$firstDimension, matrixScalingFactors=$matrixScalingFactors, tiers=$tiers, secondDimension=$secondDimension, additionalProperties=$additionalProperties}" } /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingScalableMatrixWithUnitPricingPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingScalableMatrixWithUnitPricingPrice.kt index 31f555d72..14baf1c26 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingScalableMatrixWithUnitPricingPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingScalableMatrixWithUnitPricingPrice.kt @@ -11,6 +11,7 @@ import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue +import com.withorb.api.core.checkKnown import com.withorb.api.core.checkRequired import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException @@ -130,6 +131,8 @@ private constructor( fun itemId(): String = itemId.getRequired("item_id") /** + * The pricing model type + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ @@ -144,6 +147,8 @@ private constructor( fun name(): String = name.getRequired("name") /** + * Configuration for scalable_matrix_with_unit_pricing pricing + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ @@ -520,6 +525,7 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + /** The pricing model type */ fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) /** @@ -542,6 +548,7 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } + /** Configuration for scalable_matrix_with_unit_pricing pricing */ fun scalableMatrixWithUnitPricingConfig( scalableMatrixWithUnitPricingConfig: ScalableMatrixWithUnitPricingConfig ) = scalableMatrixWithUnitPricingConfig(JsonField.of(scalableMatrixWithUnitPricingConfig)) @@ -1067,6 +1074,7 @@ private constructor( override fun toString() = value.toString() } + /** The pricing model type */ class ModelType @JsonCreator private constructor(private val value: JsonField) : Enum { /** @@ -1187,16 +1195,135 @@ private constructor( override fun toString() = value.toString() } + /** Configuration for scalable_matrix_with_unit_pricing pricing */ class ScalableMatrixWithUnitPricingConfig - @JsonCreator private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map + private val firstDimension: JsonField, + private val matrixScalingFactors: JsonField>, + private val unitPrice: JsonField, + private val prorate: JsonField, + private val secondDimension: JsonField, + private val additionalProperties: MutableMap, ) { + @JsonCreator + private constructor( + @JsonProperty("first_dimension") + @ExcludeMissing + firstDimension: JsonField = JsonMissing.of(), + @JsonProperty("matrix_scaling_factors") + @ExcludeMissing + matrixScalingFactors: JsonField> = JsonMissing.of(), + @JsonProperty("unit_price") + @ExcludeMissing + unitPrice: JsonField = JsonMissing.of(), + @JsonProperty("prorate") @ExcludeMissing prorate: JsonField = JsonMissing.of(), + @JsonProperty("second_dimension") + @ExcludeMissing + secondDimension: JsonField = JsonMissing.of(), + ) : this( + firstDimension, + matrixScalingFactors, + unitPrice, + prorate, + secondDimension, + mutableMapOf(), + ) + + /** + * Used to determine the unit rate + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun firstDimension(): String = firstDimension.getRequired("first_dimension") + + /** + * Apply a scaling factor to each dimension + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun matrixScalingFactors(): List = + matrixScalingFactors.getRequired("matrix_scaling_factors") + + /** + * The final unit price to rate against the output of the matrix + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun unitPrice(): String = unitPrice.getRequired("unit_price") + + /** + * If true, the unit price will be prorated to the billing period + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun prorate(): Boolean? = prorate.getNullable("prorate") + + /** + * Used to determine the unit rate (optional) + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun secondDimension(): String? = secondDimension.getNullable("second_dimension") + + /** + * Returns the raw JSON value of [firstDimension]. + * + * Unlike [firstDimension], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("first_dimension") + @ExcludeMissing + fun _firstDimension(): JsonField = firstDimension + + /** + * Returns the raw JSON value of [matrixScalingFactors]. + * + * Unlike [matrixScalingFactors], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("matrix_scaling_factors") + @ExcludeMissing + fun _matrixScalingFactors(): JsonField> = matrixScalingFactors + + /** + * Returns the raw JSON value of [unitPrice]. + * + * Unlike [unitPrice], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("unit_price") @ExcludeMissing fun _unitPrice(): JsonField = unitPrice + + /** + * Returns the raw JSON value of [prorate]. + * + * Unlike [prorate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("prorate") @ExcludeMissing fun _prorate(): JsonField = prorate + + /** + * Returns the raw JSON value of [secondDimension]. + * + * Unlike [secondDimension], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("second_dimension") + @ExcludeMissing + fun _secondDimension(): JsonField = secondDimension + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) fun toBuilder() = Builder().from(this) @@ -1205,6 +1332,13 @@ private constructor( /** * Returns a mutable builder for constructing an instance of * [ScalableMatrixWithUnitPricingConfig]. + * + * The following fields are required: + * ```kotlin + * .firstDimension() + * .matrixScalingFactors() + * .unitPrice() + * ``` */ fun builder() = Builder() } @@ -1212,15 +1346,117 @@ private constructor( /** A builder for [ScalableMatrixWithUnitPricingConfig]. */ class Builder internal constructor() { + private var firstDimension: JsonField? = null + private var matrixScalingFactors: JsonField>? = null + private var unitPrice: JsonField? = null + private var prorate: JsonField = JsonMissing.of() + private var secondDimension: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() internal fun from( scalableMatrixWithUnitPricingConfig: ScalableMatrixWithUnitPricingConfig ) = apply { + firstDimension = scalableMatrixWithUnitPricingConfig.firstDimension + matrixScalingFactors = + scalableMatrixWithUnitPricingConfig.matrixScalingFactors.map { + it.toMutableList() + } + unitPrice = scalableMatrixWithUnitPricingConfig.unitPrice + prorate = scalableMatrixWithUnitPricingConfig.prorate + secondDimension = scalableMatrixWithUnitPricingConfig.secondDimension additionalProperties = scalableMatrixWithUnitPricingConfig.additionalProperties.toMutableMap() } + /** Used to determine the unit rate */ + fun firstDimension(firstDimension: String) = + firstDimension(JsonField.of(firstDimension)) + + /** + * Sets [Builder.firstDimension] to an arbitrary JSON value. + * + * You should usually call [Builder.firstDimension] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun firstDimension(firstDimension: JsonField) = apply { + this.firstDimension = firstDimension + } + + /** Apply a scaling factor to each dimension */ + fun matrixScalingFactors(matrixScalingFactors: List) = + matrixScalingFactors(JsonField.of(matrixScalingFactors)) + + /** + * Sets [Builder.matrixScalingFactors] to an arbitrary JSON value. + * + * You should usually call [Builder.matrixScalingFactors] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun matrixScalingFactors(matrixScalingFactors: JsonField>) = + apply { + this.matrixScalingFactors = matrixScalingFactors.map { it.toMutableList() } + } + + /** + * Adds a single [MatrixScalingFactor] to [matrixScalingFactors]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addMatrixScalingFactor(matrixScalingFactor: MatrixScalingFactor) = apply { + matrixScalingFactors = + (matrixScalingFactors ?: JsonField.of(mutableListOf())).also { + checkKnown("matrixScalingFactors", it).add(matrixScalingFactor) + } + } + + /** The final unit price to rate against the output of the matrix */ + fun unitPrice(unitPrice: String) = unitPrice(JsonField.of(unitPrice)) + + /** + * Sets [Builder.unitPrice] to an arbitrary JSON value. + * + * You should usually call [Builder.unitPrice] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun unitPrice(unitPrice: JsonField) = apply { this.unitPrice = unitPrice } + + /** If true, the unit price will be prorated to the billing period */ + fun prorate(prorate: Boolean?) = prorate(JsonField.ofNullable(prorate)) + + /** + * Alias for [Builder.prorate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun prorate(prorate: Boolean) = prorate(prorate as Boolean?) + + /** + * Sets [Builder.prorate] to an arbitrary JSON value. + * + * You should usually call [Builder.prorate] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun prorate(prorate: JsonField) = apply { this.prorate = prorate } + + /** Used to determine the unit rate (optional) */ + fun secondDimension(secondDimension: String?) = + secondDimension(JsonField.ofNullable(secondDimension)) + + /** + * Sets [Builder.secondDimension] to an arbitrary JSON value. + * + * You should usually call [Builder.secondDimension] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun secondDimension(secondDimension: JsonField) = apply { + this.secondDimension = secondDimension + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -1244,9 +1480,27 @@ private constructor( * Returns an immutable instance of [ScalableMatrixWithUnitPricingConfig]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .firstDimension() + * .matrixScalingFactors() + * .unitPrice() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ fun build(): ScalableMatrixWithUnitPricingConfig = - ScalableMatrixWithUnitPricingConfig(additionalProperties.toImmutable()) + ScalableMatrixWithUnitPricingConfig( + checkRequired("firstDimension", firstDimension), + checkRequired("matrixScalingFactors", matrixScalingFactors).map { + it.toImmutable() + }, + checkRequired("unitPrice", unitPrice), + prorate, + secondDimension, + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false @@ -1256,6 +1510,11 @@ private constructor( return@apply } + firstDimension() + matrixScalingFactors().forEach { it.validate() } + unitPrice() + prorate() + secondDimension() validated = true } @@ -1274,7 +1533,280 @@ private constructor( * Used for best match union deserialization. */ internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + (if (firstDimension.asKnown() == null) 0 else 1) + + (matrixScalingFactors.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + (if (unitPrice.asKnown() == null) 0 else 1) + + (if (prorate.asKnown() == null) 0 else 1) + + (if (secondDimension.asKnown() == null) 0 else 1) + + /** Configuration for a single matrix scaling factor */ + class MatrixScalingFactor + private constructor( + private val firstDimensionValue: JsonField, + private val scalingFactor: JsonField, + private val secondDimensionValue: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("first_dimension_value") + @ExcludeMissing + firstDimensionValue: JsonField = JsonMissing.of(), + @JsonProperty("scaling_factor") + @ExcludeMissing + scalingFactor: JsonField = JsonMissing.of(), + @JsonProperty("second_dimension_value") + @ExcludeMissing + secondDimensionValue: JsonField = JsonMissing.of(), + ) : this(firstDimensionValue, scalingFactor, secondDimensionValue, mutableMapOf()) + + /** + * First dimension value + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun firstDimensionValue(): String = + firstDimensionValue.getRequired("first_dimension_value") + + /** + * Scaling factor + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun scalingFactor(): String = scalingFactor.getRequired("scaling_factor") + + /** + * Second dimension value (optional) + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun secondDimensionValue(): String? = + secondDimensionValue.getNullable("second_dimension_value") + + /** + * Returns the raw JSON value of [firstDimensionValue]. + * + * Unlike [firstDimensionValue], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("first_dimension_value") + @ExcludeMissing + fun _firstDimensionValue(): JsonField = firstDimensionValue + + /** + * Returns the raw JSON value of [scalingFactor]. + * + * Unlike [scalingFactor], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("scaling_factor") + @ExcludeMissing + fun _scalingFactor(): JsonField = scalingFactor + + /** + * Returns the raw JSON value of [secondDimensionValue]. + * + * Unlike [secondDimensionValue], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("second_dimension_value") + @ExcludeMissing + fun _secondDimensionValue(): JsonField = secondDimensionValue + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [MatrixScalingFactor]. + * + * The following fields are required: + * ```kotlin + * .firstDimensionValue() + * .scalingFactor() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [MatrixScalingFactor]. */ + class Builder internal constructor() { + + private var firstDimensionValue: JsonField? = null + private var scalingFactor: JsonField? = null + private var secondDimensionValue: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(matrixScalingFactor: MatrixScalingFactor) = apply { + firstDimensionValue = matrixScalingFactor.firstDimensionValue + scalingFactor = matrixScalingFactor.scalingFactor + secondDimensionValue = matrixScalingFactor.secondDimensionValue + additionalProperties = matrixScalingFactor.additionalProperties.toMutableMap() + } + + /** First dimension value */ + fun firstDimensionValue(firstDimensionValue: String) = + firstDimensionValue(JsonField.of(firstDimensionValue)) + + /** + * Sets [Builder.firstDimensionValue] to an arbitrary JSON value. + * + * You should usually call [Builder.firstDimensionValue] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun firstDimensionValue(firstDimensionValue: JsonField) = apply { + this.firstDimensionValue = firstDimensionValue + } + + /** Scaling factor */ + fun scalingFactor(scalingFactor: String) = + scalingFactor(JsonField.of(scalingFactor)) + + /** + * Sets [Builder.scalingFactor] to an arbitrary JSON value. + * + * You should usually call [Builder.scalingFactor] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun scalingFactor(scalingFactor: JsonField) = apply { + this.scalingFactor = scalingFactor + } + + /** Second dimension value (optional) */ + fun secondDimensionValue(secondDimensionValue: String?) = + secondDimensionValue(JsonField.ofNullable(secondDimensionValue)) + + /** + * Sets [Builder.secondDimensionValue] to an arbitrary JSON value. + * + * You should usually call [Builder.secondDimensionValue] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun secondDimensionValue(secondDimensionValue: JsonField) = apply { + this.secondDimensionValue = secondDimensionValue + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [MatrixScalingFactor]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .firstDimensionValue() + * .scalingFactor() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MatrixScalingFactor = + MatrixScalingFactor( + checkRequired("firstDimensionValue", firstDimensionValue), + checkRequired("scalingFactor", scalingFactor), + secondDimensionValue, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MatrixScalingFactor = apply { + if (validated) { + return@apply + } + + firstDimensionValue() + scalingFactor() + secondDimensionValue() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (firstDimensionValue.asKnown() == null) 0 else 1) + + (if (scalingFactor.asKnown() == null) 0 else 1) + + (if (secondDimensionValue.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MatrixScalingFactor && + firstDimensionValue == other.firstDimensionValue && + scalingFactor == other.scalingFactor && + secondDimensionValue == other.secondDimensionValue && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + firstDimensionValue, + scalingFactor, + secondDimensionValue, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MatrixScalingFactor{firstDimensionValue=$firstDimensionValue, scalingFactor=$scalingFactor, secondDimensionValue=$secondDimensionValue, additionalProperties=$additionalProperties}" + } override fun equals(other: Any?): Boolean { if (this === other) { @@ -1282,15 +1814,29 @@ private constructor( } return other is ScalableMatrixWithUnitPricingConfig && + firstDimension == other.firstDimension && + matrixScalingFactors == other.matrixScalingFactors && + unitPrice == other.unitPrice && + prorate == other.prorate && + secondDimension == other.secondDimension && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + private val hashCode: Int by lazy { + Objects.hash( + firstDimension, + matrixScalingFactors, + unitPrice, + prorate, + secondDimension, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode override fun toString() = - "ScalableMatrixWithUnitPricingConfig{additionalProperties=$additionalProperties}" + "ScalableMatrixWithUnitPricingConfig{firstDimension=$firstDimension, matrixScalingFactors=$matrixScalingFactors, unitPrice=$unitPrice, prorate=$prorate, secondDimension=$secondDimension, additionalProperties=$additionalProperties}" } /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingThresholdTotalAmountPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingThresholdTotalAmountPrice.kt index 1fdcd6ec3..a0f350a38 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingThresholdTotalAmountPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingThresholdTotalAmountPrice.kt @@ -11,6 +11,7 @@ import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue +import com.withorb.api.core.checkKnown import com.withorb.api.core.checkRequired import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException @@ -129,6 +130,8 @@ private constructor( fun itemId(): String = itemId.getRequired("item_id") /** + * The pricing model type + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ @@ -143,6 +146,8 @@ private constructor( fun name(): String = name.getRequired("name") /** + * Configuration for threshold_total_amount pricing + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ @@ -515,6 +520,7 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + /** The pricing model type */ fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) /** @@ -537,6 +543,7 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } + /** Configuration for threshold_total_amount pricing */ fun thresholdTotalAmountConfig(thresholdTotalAmountConfig: ThresholdTotalAmountConfig) = thresholdTotalAmountConfig(JsonField.of(thresholdTotalAmountConfig)) @@ -1058,6 +1065,7 @@ private constructor( override fun toString() = value.toString() } + /** The pricing model type */ class ModelType @JsonCreator private constructor(private val value: JsonField) : Enum { /** @@ -1178,16 +1186,66 @@ private constructor( override fun toString() = value.toString() } + /** Configuration for threshold_total_amount pricing */ class ThresholdTotalAmountConfig - @JsonCreator private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map + private val consumptionTable: JsonField>, + private val prorate: JsonField, + private val additionalProperties: MutableMap, ) { + @JsonCreator + private constructor( + @JsonProperty("consumption_table") + @ExcludeMissing + consumptionTable: JsonField> = JsonMissing.of(), + @JsonProperty("prorate") @ExcludeMissing prorate: JsonField = JsonMissing.of(), + ) : this(consumptionTable, prorate, mutableMapOf()) + + /** + * When the quantity consumed passes a provided threshold, the configured total will be + * charged + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun consumptionTable(): List = + consumptionTable.getRequired("consumption_table") + + /** + * If true, the unit price will be prorated to the billing period + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun prorate(): Boolean? = prorate.getNullable("prorate") + + /** + * Returns the raw JSON value of [consumptionTable]. + * + * Unlike [consumptionTable], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("consumption_table") + @ExcludeMissing + fun _consumptionTable(): JsonField> = consumptionTable + + /** + * Returns the raw JSON value of [prorate]. + * + * Unlike [prorate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("prorate") @ExcludeMissing fun _prorate(): JsonField = prorate + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) fun toBuilder() = Builder().from(this) @@ -1196,6 +1254,11 @@ private constructor( /** * Returns a mutable builder for constructing an instance of * [ThresholdTotalAmountConfig]. + * + * The following fields are required: + * ```kotlin + * .consumptionTable() + * ``` */ fun builder() = Builder() } @@ -1203,13 +1266,67 @@ private constructor( /** A builder for [ThresholdTotalAmountConfig]. */ class Builder internal constructor() { + private var consumptionTable: JsonField>? = null + private var prorate: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() internal fun from(thresholdTotalAmountConfig: ThresholdTotalAmountConfig) = apply { + consumptionTable = + thresholdTotalAmountConfig.consumptionTable.map { it.toMutableList() } + prorate = thresholdTotalAmountConfig.prorate additionalProperties = thresholdTotalAmountConfig.additionalProperties.toMutableMap() } + /** + * When the quantity consumed passes a provided threshold, the configured total will be + * charged + */ + fun consumptionTable(consumptionTable: List) = + consumptionTable(JsonField.of(consumptionTable)) + + /** + * Sets [Builder.consumptionTable] to an arbitrary JSON value. + * + * You should usually call [Builder.consumptionTable] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun consumptionTable(consumptionTable: JsonField>) = apply { + this.consumptionTable = consumptionTable.map { it.toMutableList() } + } + + /** + * Adds a single [ConsumptionTable] to [Builder.consumptionTable]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addConsumptionTable(consumptionTable: ConsumptionTable) = apply { + this.consumptionTable = + (this.consumptionTable ?: JsonField.of(mutableListOf())).also { + checkKnown("consumptionTable", it).add(consumptionTable) + } + } + + /** If true, the unit price will be prorated to the billing period */ + fun prorate(prorate: Boolean?) = prorate(JsonField.ofNullable(prorate)) + + /** + * Alias for [Builder.prorate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun prorate(prorate: Boolean) = prorate(prorate as Boolean?) + + /** + * Sets [Builder.prorate] to an arbitrary JSON value. + * + * You should usually call [Builder.prorate] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun prorate(prorate: JsonField) = apply { this.prorate = prorate } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -1233,9 +1350,20 @@ private constructor( * Returns an immutable instance of [ThresholdTotalAmountConfig]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .consumptionTable() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ fun build(): ThresholdTotalAmountConfig = - ThresholdTotalAmountConfig(additionalProperties.toImmutable()) + ThresholdTotalAmountConfig( + checkRequired("consumptionTable", consumptionTable).map { it.toImmutable() }, + prorate, + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false @@ -1245,6 +1373,8 @@ private constructor( return@apply } + consumptionTable().forEach { it.validate() } + prorate() validated = true } @@ -1263,7 +1393,223 @@ private constructor( * Used for best match union deserialization. */ internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + (consumptionTable.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + (if (prorate.asKnown() == null) 0 else 1) + + /** Configuration for a single threshold */ + class ConsumptionTable + private constructor( + private val threshold: JsonField, + private val totalAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("threshold") + @ExcludeMissing + threshold: JsonField = JsonMissing.of(), + @JsonProperty("total_amount") + @ExcludeMissing + totalAmount: JsonField = JsonMissing.of(), + ) : this(threshold, totalAmount, mutableMapOf()) + + /** + * Quantity threshold + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun threshold(): String = threshold.getRequired("threshold") + + /** + * Total amount for this threshold + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun totalAmount(): String = totalAmount.getRequired("total_amount") + + /** + * Returns the raw JSON value of [threshold]. + * + * Unlike [threshold], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("threshold") + @ExcludeMissing + fun _threshold(): JsonField = threshold + + /** + * Returns the raw JSON value of [totalAmount]. + * + * Unlike [totalAmount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("total_amount") + @ExcludeMissing + fun _totalAmount(): JsonField = totalAmount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ConsumptionTable]. + * + * The following fields are required: + * ```kotlin + * .threshold() + * .totalAmount() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [ConsumptionTable]. */ + class Builder internal constructor() { + + private var threshold: JsonField? = null + private var totalAmount: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(consumptionTable: ConsumptionTable) = apply { + threshold = consumptionTable.threshold + totalAmount = consumptionTable.totalAmount + additionalProperties = consumptionTable.additionalProperties.toMutableMap() + } + + /** Quantity threshold */ + fun threshold(threshold: String) = threshold(JsonField.of(threshold)) + + /** + * Sets [Builder.threshold] to an arbitrary JSON value. + * + * You should usually call [Builder.threshold] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun threshold(threshold: JsonField) = apply { this.threshold = threshold } + + /** Total amount for this threshold */ + fun totalAmount(totalAmount: String) = totalAmount(JsonField.of(totalAmount)) + + /** + * Sets [Builder.totalAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.totalAmount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun totalAmount(totalAmount: JsonField) = apply { + this.totalAmount = totalAmount + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ConsumptionTable]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .threshold() + * .totalAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ConsumptionTable = + ConsumptionTable( + checkRequired("threshold", threshold), + checkRequired("totalAmount", totalAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ConsumptionTable = apply { + if (validated) { + return@apply + } + + threshold() + totalAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (threshold.asKnown() == null) 0 else 1) + + (if (totalAmount.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ConsumptionTable && + threshold == other.threshold && + totalAmount == other.totalAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(threshold, totalAmount, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ConsumptionTable{threshold=$threshold, totalAmount=$totalAmount, additionalProperties=$additionalProperties}" + } override fun equals(other: Any?): Boolean { if (this === other) { @@ -1271,15 +1617,19 @@ private constructor( } return other is ThresholdTotalAmountConfig && + consumptionTable == other.consumptionTable && + prorate == other.prorate && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + private val hashCode: Int by lazy { + Objects.hash(consumptionTable, prorate, additionalProperties) + } override fun hashCode(): Int = hashCode override fun toString() = - "ThresholdTotalAmountConfig{additionalProperties=$additionalProperties}" + "ThresholdTotalAmountConfig{consumptionTable=$consumptionTable, prorate=$prorate, additionalProperties=$additionalProperties}" } /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredPackagePrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredPackagePrice.kt index 219be74ae..3b48e3f94 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredPackagePrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredPackagePrice.kt @@ -11,6 +11,7 @@ import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue +import com.withorb.api.core.checkKnown import com.withorb.api.core.checkRequired import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException @@ -129,6 +130,8 @@ private constructor( fun itemId(): String = itemId.getRequired("item_id") /** + * The pricing model type + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ @@ -143,6 +146,8 @@ private constructor( fun name(): String = name.getRequired("name") /** + * Configuration for tiered_package pricing + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ @@ -508,6 +513,7 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + /** The pricing model type */ fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) /** @@ -530,6 +536,7 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } + /** Configuration for tiered_package pricing */ fun tieredPackageConfig(tieredPackageConfig: TieredPackageConfig) = tieredPackageConfig(JsonField.of(tieredPackageConfig)) @@ -1051,6 +1058,7 @@ private constructor( override fun toString() = value.toString() } + /** The pricing model type */ class ModelType @JsonCreator private constructor(private val value: JsonField) : Enum { /** @@ -1171,34 +1179,137 @@ private constructor( override fun toString() = value.toString() } + /** Configuration for tiered_package pricing */ class TieredPackageConfig - @JsonCreator private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map + private val packageSize: JsonField, + private val tiers: JsonField>, + private val additionalProperties: MutableMap, ) { + @JsonCreator + private constructor( + @JsonProperty("package_size") + @ExcludeMissing + packageSize: JsonField = JsonMissing.of(), + @JsonProperty("tiers") @ExcludeMissing tiers: JsonField> = JsonMissing.of(), + ) : this(packageSize, tiers, mutableMapOf()) + + /** + * Package size + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun packageSize(): String = packageSize.getRequired("package_size") + + /** + * Apply tiered pricing after rounding up the quantity to the package size. Tiers are + * defined using exclusive lower bounds. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun tiers(): List = tiers.getRequired("tiers") + + /** + * Returns the raw JSON value of [packageSize]. + * + * Unlike [packageSize], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("package_size") + @ExcludeMissing + fun _packageSize(): JsonField = packageSize + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tiers") @ExcludeMissing fun _tiers(): JsonField> = tiers + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) fun toBuilder() = Builder().from(this) companion object { - /** Returns a mutable builder for constructing an instance of [TieredPackageConfig]. */ + /** + * Returns a mutable builder for constructing an instance of [TieredPackageConfig]. + * + * The following fields are required: + * ```kotlin + * .packageSize() + * .tiers() + * ``` + */ fun builder() = Builder() } /** A builder for [TieredPackageConfig]. */ class Builder internal constructor() { + private var packageSize: JsonField? = null + private var tiers: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(tieredPackageConfig: TieredPackageConfig) = apply { + packageSize = tieredPackageConfig.packageSize + tiers = tieredPackageConfig.tiers.map { it.toMutableList() } additionalProperties = tieredPackageConfig.additionalProperties.toMutableMap() } + /** Package size */ + fun packageSize(packageSize: String) = packageSize(JsonField.of(packageSize)) + + /** + * Sets [Builder.packageSize] to an arbitrary JSON value. + * + * You should usually call [Builder.packageSize] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun packageSize(packageSize: JsonField) = apply { + this.packageSize = packageSize + } + + /** + * Apply tiered pricing after rounding up the quantity to the package size. Tiers are + * defined using exclusive lower bounds. + */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -1222,9 +1333,21 @@ private constructor( * Returns an immutable instance of [TieredPackageConfig]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .packageSize() + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ fun build(): TieredPackageConfig = - TieredPackageConfig(additionalProperties.toImmutable()) + TieredPackageConfig( + checkRequired("packageSize", packageSize), + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false @@ -1234,6 +1357,8 @@ private constructor( return@apply } + packageSize() + tiers().forEach { it.validate() } validated = true } @@ -1252,7 +1377,221 @@ private constructor( * Used for best match union deserialization. */ internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + (if (packageSize.asKnown() == null) 0 else 1) + + (tiers.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single tier with business logic */ + class Tier + private constructor( + private val perUnit: JsonField, + private val tierLowerBound: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("per_unit") + @ExcludeMissing + perUnit: JsonField = JsonMissing.of(), + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + ) : this(perUnit, tierLowerBound, mutableMapOf()) + + /** + * Price per package + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun perUnit(): String = perUnit.getRequired("per_unit") + + /** + * Tier lower bound + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun tierLowerBound(): String = tierLowerBound.getRequired("tier_lower_bound") + + /** + * Returns the raw JSON value of [perUnit]. + * + * Unlike [perUnit], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("per_unit") @ExcludeMissing fun _perUnit(): JsonField = perUnit + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Tier]. + * + * The following fields are required: + * ```kotlin + * .perUnit() + * .tierLowerBound() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var perUnit: JsonField? = null + private var tierLowerBound: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(tier: Tier) = apply { + perUnit = tier.perUnit + tierLowerBound = tier.tierLowerBound + additionalProperties = tier.additionalProperties.toMutableMap() + } + + /** Price per package */ + fun perUnit(perUnit: String) = perUnit(JsonField.of(perUnit)) + + /** + * Sets [Builder.perUnit] to an arbitrary JSON value. + * + * You should usually call [Builder.perUnit] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun perUnit(perUnit: JsonField) = apply { this.perUnit = perUnit } + + /** Tier lower bound */ + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Tier]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .perUnit() + * .tierLowerBound() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("perUnit", perUnit), + checkRequired("tierLowerBound", tierLowerBound), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + perUnit() + tierLowerBound() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (perUnit.asKnown() == null) 0 else 1) + + (if (tierLowerBound.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + perUnit == other.perUnit && + tierLowerBound == other.tierLowerBound && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(perUnit, tierLowerBound, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{perUnit=$perUnit, tierLowerBound=$tierLowerBound, additionalProperties=$additionalProperties}" + } override fun equals(other: Any?): Boolean { if (this === other) { @@ -1260,14 +1599,17 @@ private constructor( } return other is TieredPackageConfig && + packageSize == other.packageSize && + tiers == other.tiers && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(packageSize, tiers, additionalProperties) } override fun hashCode(): Int = hashCode - override fun toString() = "TieredPackageConfig{additionalProperties=$additionalProperties}" + override fun toString() = + "TieredPackageConfig{packageSize=$packageSize, tiers=$tiers, additionalProperties=$additionalProperties}" } /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredPackageWithMinimumPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredPackageWithMinimumPrice.kt index 2d3895f26..33a6c9594 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredPackageWithMinimumPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredPackageWithMinimumPrice.kt @@ -11,6 +11,7 @@ import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue +import com.withorb.api.core.checkKnown import com.withorb.api.core.checkRequired import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException @@ -130,6 +131,8 @@ private constructor( fun itemId(): String = itemId.getRequired("item_id") /** + * The pricing model type + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ @@ -144,6 +147,8 @@ private constructor( fun name(): String = name.getRequired("name") /** + * Configuration for tiered_package_with_minimum pricing + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ @@ -517,6 +522,7 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + /** The pricing model type */ fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) /** @@ -539,6 +545,7 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } + /** Configuration for tiered_package_with_minimum pricing */ fun tieredPackageWithMinimumConfig( tieredPackageWithMinimumConfig: TieredPackageWithMinimumConfig ) = tieredPackageWithMinimumConfig(JsonField.of(tieredPackageWithMinimumConfig)) @@ -1061,6 +1068,7 @@ private constructor( override fun toString() = value.toString() } + /** The pricing model type */ class ModelType @JsonCreator private constructor(private val value: JsonField) : Enum { /** @@ -1181,16 +1189,64 @@ private constructor( override fun toString() = value.toString() } + /** Configuration for tiered_package_with_minimum pricing */ class TieredPackageWithMinimumConfig - @JsonCreator private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map + private val packageSize: JsonField, + private val tiers: JsonField>, + private val additionalProperties: MutableMap, ) { + @JsonCreator + private constructor( + @JsonProperty("package_size") + @ExcludeMissing + packageSize: JsonField = JsonMissing.of(), + @JsonProperty("tiers") @ExcludeMissing tiers: JsonField> = JsonMissing.of(), + ) : this(packageSize, tiers, mutableMapOf()) + + /** + * Package size + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun packageSize(): Double = packageSize.getRequired("package_size") + + /** + * Apply tiered pricing after rounding up the quantity to the package size. Tiers are + * defined using exclusive lower bounds. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun tiers(): List = tiers.getRequired("tiers") + + /** + * Returns the raw JSON value of [packageSize]. + * + * Unlike [packageSize], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("package_size") + @ExcludeMissing + fun _packageSize(): JsonField = packageSize + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tiers") @ExcludeMissing fun _tiers(): JsonField> = tiers + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) fun toBuilder() = Builder().from(this) @@ -1199,6 +1255,12 @@ private constructor( /** * Returns a mutable builder for constructing an instance of * [TieredPackageWithMinimumConfig]. + * + * The following fields are required: + * ```kotlin + * .packageSize() + * .tiers() + * ``` */ fun builder() = Builder() } @@ -1206,14 +1268,61 @@ private constructor( /** A builder for [TieredPackageWithMinimumConfig]. */ class Builder internal constructor() { + private var packageSize: JsonField? = null + private var tiers: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(tieredPackageWithMinimumConfig: TieredPackageWithMinimumConfig) = apply { + packageSize = tieredPackageWithMinimumConfig.packageSize + tiers = tieredPackageWithMinimumConfig.tiers.map { it.toMutableList() } additionalProperties = tieredPackageWithMinimumConfig.additionalProperties.toMutableMap() } + /** Package size */ + fun packageSize(packageSize: Double) = packageSize(JsonField.of(packageSize)) + + /** + * Sets [Builder.packageSize] to an arbitrary JSON value. + * + * You should usually call [Builder.packageSize] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun packageSize(packageSize: JsonField) = apply { + this.packageSize = packageSize + } + + /** + * Apply tiered pricing after rounding up the quantity to the package size. Tiers are + * defined using exclusive lower bounds. + */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -1237,9 +1346,21 @@ private constructor( * Returns an immutable instance of [TieredPackageWithMinimumConfig]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .packageSize() + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ fun build(): TieredPackageWithMinimumConfig = - TieredPackageWithMinimumConfig(additionalProperties.toImmutable()) + TieredPackageWithMinimumConfig( + checkRequired("packageSize", packageSize), + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false @@ -1249,6 +1370,8 @@ private constructor( return@apply } + packageSize() + tiers().forEach { it.validate() } validated = true } @@ -1267,7 +1390,267 @@ private constructor( * Used for best match union deserialization. */ internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + (if (packageSize.asKnown() == null) 0 else 1) + + (tiers.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single tier */ + class Tier + private constructor( + private val minimumAmount: JsonField, + private val perUnit: JsonField, + private val tierLowerBound: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("minimum_amount") + @ExcludeMissing + minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("per_unit") + @ExcludeMissing + perUnit: JsonField = JsonMissing.of(), + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + ) : this(minimumAmount, perUnit, tierLowerBound, mutableMapOf()) + + /** + * Minimum amount + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") + + /** + * Price per package + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun perUnit(): String = perUnit.getRequired("per_unit") + + /** + * Tier lower bound + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun tierLowerBound(): String = tierLowerBound.getRequired("tier_lower_bound") + + /** + * Returns the raw JSON value of [minimumAmount]. + * + * Unlike [minimumAmount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount + + /** + * Returns the raw JSON value of [perUnit]. + * + * Unlike [perUnit], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("per_unit") @ExcludeMissing fun _perUnit(): JsonField = perUnit + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Tier]. + * + * The following fields are required: + * ```kotlin + * .minimumAmount() + * .perUnit() + * .tierLowerBound() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var minimumAmount: JsonField? = null + private var perUnit: JsonField? = null + private var tierLowerBound: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(tier: Tier) = apply { + minimumAmount = tier.minimumAmount + perUnit = tier.perUnit + tierLowerBound = tier.tierLowerBound + additionalProperties = tier.additionalProperties.toMutableMap() + } + + /** Minimum amount */ + fun minimumAmount(minimumAmount: String) = + minimumAmount(JsonField.of(minimumAmount)) + + /** + * Sets [Builder.minimumAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumAmount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount + } + + /** Price per package */ + fun perUnit(perUnit: String) = perUnit(JsonField.of(perUnit)) + + /** + * Sets [Builder.perUnit] to an arbitrary JSON value. + * + * You should usually call [Builder.perUnit] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun perUnit(perUnit: JsonField) = apply { this.perUnit = perUnit } + + /** Tier lower bound */ + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Tier]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .minimumAmount() + * .perUnit() + * .tierLowerBound() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("minimumAmount", minimumAmount), + checkRequired("perUnit", perUnit), + checkRequired("tierLowerBound", tierLowerBound), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + minimumAmount() + perUnit() + tierLowerBound() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (minimumAmount.asKnown() == null) 0 else 1) + + (if (perUnit.asKnown() == null) 0 else 1) + + (if (tierLowerBound.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + minimumAmount == other.minimumAmount && + perUnit == other.perUnit && + tierLowerBound == other.tierLowerBound && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(minimumAmount, perUnit, tierLowerBound, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{minimumAmount=$minimumAmount, perUnit=$perUnit, tierLowerBound=$tierLowerBound, additionalProperties=$additionalProperties}" + } override fun equals(other: Any?): Boolean { if (this === other) { @@ -1275,15 +1658,17 @@ private constructor( } return other is TieredPackageWithMinimumConfig && + packageSize == other.packageSize && + tiers == other.tiers && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(packageSize, tiers, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "TieredPackageWithMinimumConfig{additionalProperties=$additionalProperties}" + "TieredPackageWithMinimumConfig{packageSize=$packageSize, tiers=$tiers, additionalProperties=$additionalProperties}" } /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredPrice.kt index a81bac049..3d16dd498 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredPrice.kt @@ -129,6 +129,8 @@ private constructor( fun itemId(): String = itemId.getRequired("item_id") /** + * The pricing model type + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ @@ -143,6 +145,8 @@ private constructor( fun name(): String = name.getRequired("name") /** + * Configuration for tiered pricing + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ @@ -504,6 +508,7 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + /** The pricing model type */ fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) /** @@ -526,6 +531,7 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } + /** Configuration for tiered pricing */ fun tieredConfig(tieredConfig: TieredConfig) = tieredConfig(JsonField.of(tieredConfig)) /** @@ -1046,6 +1052,7 @@ private constructor( override fun toString() = value.toString() } + /** The pricing model type */ class ModelType @JsonCreator private constructor(private val value: JsonField) : Enum { /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredWithMinimumPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredWithMinimumPrice.kt index 7536c9c30..1b166c417 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredWithMinimumPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredWithMinimumPrice.kt @@ -11,6 +11,7 @@ import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue +import com.withorb.api.core.checkKnown import com.withorb.api.core.checkRequired import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException @@ -129,6 +130,8 @@ private constructor( fun itemId(): String = itemId.getRequired("item_id") /** + * The pricing model type + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ @@ -143,6 +146,8 @@ private constructor( fun name(): String = name.getRequired("name") /** + * Configuration for tiered_with_minimum pricing + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ @@ -512,6 +517,7 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + /** The pricing model type */ fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) /** @@ -534,6 +540,7 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } + /** Configuration for tiered_with_minimum pricing */ fun tieredWithMinimumConfig(tieredWithMinimumConfig: TieredWithMinimumConfig) = tieredWithMinimumConfig(JsonField.of(tieredWithMinimumConfig)) @@ -1056,6 +1063,7 @@ private constructor( override fun toString() = value.toString() } + /** The pricing model type */ class ModelType @JsonCreator private constructor(private val value: JsonField) : Enum { /** @@ -1176,16 +1184,83 @@ private constructor( override fun toString() = value.toString() } + /** Configuration for tiered_with_minimum pricing */ class TieredWithMinimumConfig - @JsonCreator private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map + private val tiers: JsonField>, + private val hideZeroAmountTiers: JsonField, + private val prorate: JsonField, + private val additionalProperties: MutableMap, ) { + @JsonCreator + private constructor( + @JsonProperty("tiers") @ExcludeMissing tiers: JsonField> = JsonMissing.of(), + @JsonProperty("hide_zero_amount_tiers") + @ExcludeMissing + hideZeroAmountTiers: JsonField = JsonMissing.of(), + @JsonProperty("prorate") @ExcludeMissing prorate: JsonField = JsonMissing.of(), + ) : this(tiers, hideZeroAmountTiers, prorate, mutableMapOf()) + + /** + * Tiered pricing with a minimum amount dependent on the volume tier. Tiers are defined + * using exclusive lower bounds. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun tiers(): List = tiers.getRequired("tiers") + + /** + * If true, tiers with an accrued amount of 0 will not be included in the rating. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun hideZeroAmountTiers(): Boolean? = + hideZeroAmountTiers.getNullable("hide_zero_amount_tiers") + + /** + * If true, the unit price will be prorated to the billing period + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun prorate(): Boolean? = prorate.getNullable("prorate") + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tiers") @ExcludeMissing fun _tiers(): JsonField> = tiers + + /** + * Returns the raw JSON value of [hideZeroAmountTiers]. + * + * Unlike [hideZeroAmountTiers], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("hide_zero_amount_tiers") + @ExcludeMissing + fun _hideZeroAmountTiers(): JsonField = hideZeroAmountTiers + + /** + * Returns the raw JSON value of [prorate]. + * + * Unlike [prorate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("prorate") @ExcludeMissing fun _prorate(): JsonField = prorate + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) fun toBuilder() = Builder().from(this) @@ -1193,6 +1268,11 @@ private constructor( /** * Returns a mutable builder for constructing an instance of [TieredWithMinimumConfig]. + * + * The following fields are required: + * ```kotlin + * .tiers() + * ``` */ fun builder() = Builder() } @@ -1200,12 +1280,74 @@ private constructor( /** A builder for [TieredWithMinimumConfig]. */ class Builder internal constructor() { + private var tiers: JsonField>? = null + private var hideZeroAmountTiers: JsonField = JsonMissing.of() + private var prorate: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() internal fun from(tieredWithMinimumConfig: TieredWithMinimumConfig) = apply { + tiers = tieredWithMinimumConfig.tiers.map { it.toMutableList() } + hideZeroAmountTiers = tieredWithMinimumConfig.hideZeroAmountTiers + prorate = tieredWithMinimumConfig.prorate additionalProperties = tieredWithMinimumConfig.additionalProperties.toMutableMap() } + /** + * Tiered pricing with a minimum amount dependent on the volume tier. Tiers are defined + * using exclusive lower bounds. + */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + + /** If true, tiers with an accrued amount of 0 will not be included in the rating. */ + fun hideZeroAmountTiers(hideZeroAmountTiers: Boolean) = + hideZeroAmountTiers(JsonField.of(hideZeroAmountTiers)) + + /** + * Sets [Builder.hideZeroAmountTiers] to an arbitrary JSON value. + * + * You should usually call [Builder.hideZeroAmountTiers] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun hideZeroAmountTiers(hideZeroAmountTiers: JsonField) = apply { + this.hideZeroAmountTiers = hideZeroAmountTiers + } + + /** If true, the unit price will be prorated to the billing period */ + fun prorate(prorate: Boolean) = prorate(JsonField.of(prorate)) + + /** + * Sets [Builder.prorate] to an arbitrary JSON value. + * + * You should usually call [Builder.prorate] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun prorate(prorate: JsonField) = apply { this.prorate = prorate } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -1229,9 +1371,21 @@ private constructor( * Returns an immutable instance of [TieredWithMinimumConfig]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ fun build(): TieredWithMinimumConfig = - TieredWithMinimumConfig(additionalProperties.toImmutable()) + TieredWithMinimumConfig( + checkRequired("tiers", tiers).map { it.toImmutable() }, + hideZeroAmountTiers, + prorate, + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false @@ -1241,6 +1395,9 @@ private constructor( return@apply } + tiers().forEach { it.validate() } + hideZeroAmountTiers() + prorate() validated = true } @@ -1259,7 +1416,273 @@ private constructor( * Used for best match union deserialization. */ internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + (tiers.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + (if (hideZeroAmountTiers.asKnown() == null) 0 else 1) + + (if (prorate.asKnown() == null) 0 else 1) + + /** Configuration for a single tier */ + class Tier + private constructor( + private val minimumAmount: JsonField, + private val tierLowerBound: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("minimum_amount") + @ExcludeMissing + minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(minimumAmount, tierLowerBound, unitAmount, mutableMapOf()) + + /** + * Minimum amount + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") + + /** + * Tier lower bound + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun tierLowerBound(): String = tierLowerBound.getRequired("tier_lower_bound") + + /** + * Per unit amount + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [minimumAmount]. + * + * Unlike [minimumAmount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Tier]. + * + * The following fields are required: + * ```kotlin + * .minimumAmount() + * .tierLowerBound() + * .unitAmount() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var minimumAmount: JsonField? = null + private var tierLowerBound: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(tier: Tier) = apply { + minimumAmount = tier.minimumAmount + tierLowerBound = tier.tierLowerBound + unitAmount = tier.unitAmount + additionalProperties = tier.additionalProperties.toMutableMap() + } + + /** Minimum amount */ + fun minimumAmount(minimumAmount: String) = + minimumAmount(JsonField.of(minimumAmount)) + + /** + * Sets [Builder.minimumAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumAmount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount + } + + /** Tier lower bound */ + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + /** Per unit amount */ + fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Tier]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .minimumAmount() + * .tierLowerBound() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("minimumAmount", minimumAmount), + checkRequired("tierLowerBound", tierLowerBound), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + minimumAmount() + tierLowerBound() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (minimumAmount.asKnown() == null) 0 else 1) + + (if (tierLowerBound.asKnown() == null) 0 else 1) + + (if (unitAmount.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + minimumAmount == other.minimumAmount && + tierLowerBound == other.tierLowerBound && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(minimumAmount, tierLowerBound, unitAmount, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{minimumAmount=$minimumAmount, tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } override fun equals(other: Any?): Boolean { if (this === other) { @@ -1267,15 +1690,20 @@ private constructor( } return other is TieredWithMinimumConfig && + tiers == other.tiers && + hideZeroAmountTiers == other.hideZeroAmountTiers && + prorate == other.prorate && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + private val hashCode: Int by lazy { + Objects.hash(tiers, hideZeroAmountTiers, prorate, additionalProperties) + } override fun hashCode(): Int = hashCode override fun toString() = - "TieredWithMinimumConfig{additionalProperties=$additionalProperties}" + "TieredWithMinimumConfig{tiers=$tiers, hideZeroAmountTiers=$hideZeroAmountTiers, prorate=$prorate, additionalProperties=$additionalProperties}" } /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredWithProrationPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredWithProrationPrice.kt index 94864ca08..47eb82db3 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredWithProrationPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredWithProrationPrice.kt @@ -11,6 +11,7 @@ import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue +import com.withorb.api.core.checkKnown import com.withorb.api.core.checkRequired import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException @@ -129,6 +130,8 @@ private constructor( fun itemId(): String = itemId.getRequired("item_id") /** + * The pricing model type + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ @@ -143,6 +146,8 @@ private constructor( fun name(): String = name.getRequired("name") /** + * Configuration for tiered_with_proration pricing + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ @@ -515,6 +520,7 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + /** The pricing model type */ fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) /** @@ -537,6 +543,7 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } + /** Configuration for tiered_with_proration pricing */ fun tieredWithProrationConfig(tieredWithProrationConfig: TieredWithProrationConfig) = tieredWithProrationConfig(JsonField.of(tieredWithProrationConfig)) @@ -1058,6 +1065,7 @@ private constructor( override fun toString() = value.toString() } + /** The pricing model type */ class ModelType @JsonCreator private constructor(private val value: JsonField) : Enum { /** @@ -1178,16 +1186,42 @@ private constructor( override fun toString() = value.toString() } + /** Configuration for tiered_with_proration pricing */ class TieredWithProrationConfig - @JsonCreator private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map + private val tiers: JsonField>, + private val additionalProperties: MutableMap, ) { + @JsonCreator + private constructor( + @JsonProperty("tiers") @ExcludeMissing tiers: JsonField> = JsonMissing.of() + ) : this(tiers, mutableMapOf()) + + /** + * Tiers for rating based on total usage quantities into the specified tier with proration + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun tiers(): List = tiers.getRequired("tiers") + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tiers") @ExcludeMissing fun _tiers(): JsonField> = tiers + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) fun toBuilder() = Builder().from(this) @@ -1196,6 +1230,11 @@ private constructor( /** * Returns a mutable builder for constructing an instance of * [TieredWithProrationConfig]. + * + * The following fields are required: + * ```kotlin + * .tiers() + * ``` */ fun builder() = Builder() } @@ -1203,12 +1242,43 @@ private constructor( /** A builder for [TieredWithProrationConfig]. */ class Builder internal constructor() { + private var tiers: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(tieredWithProrationConfig: TieredWithProrationConfig) = apply { + tiers = tieredWithProrationConfig.tiers.map { it.toMutableList() } additionalProperties = tieredWithProrationConfig.additionalProperties.toMutableMap() } + /** + * Tiers for rating based on total usage quantities into the specified tier with + * proration + */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -1232,9 +1302,19 @@ private constructor( * Returns an immutable instance of [TieredWithProrationConfig]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ fun build(): TieredWithProrationConfig = - TieredWithProrationConfig(additionalProperties.toImmutable()) + TieredWithProrationConfig( + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false @@ -1244,6 +1324,7 @@ private constructor( return@apply } + tiers().forEach { it.validate() } validated = true } @@ -1261,8 +1342,225 @@ private constructor( * * Used for best match union deserialization. */ - internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + internal fun validity(): Int = (tiers.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single tiered with proration tier */ + class Tier + private constructor( + private val tierLowerBound: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(tierLowerBound, unitAmount, mutableMapOf()) + + /** + * Inclusive tier starting value + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun tierLowerBound(): String = tierLowerBound.getRequired("tier_lower_bound") + + /** + * Amount per unit + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Tier]. + * + * The following fields are required: + * ```kotlin + * .tierLowerBound() + * .unitAmount() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var tierLowerBound: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(tier: Tier) = apply { + tierLowerBound = tier.tierLowerBound + unitAmount = tier.unitAmount + additionalProperties = tier.additionalProperties.toMutableMap() + } + + /** Inclusive tier starting value */ + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + /** Amount per unit */ + fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Tier]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .tierLowerBound() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("tierLowerBound", tierLowerBound), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + tierLowerBound() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (tierLowerBound.asKnown() == null) 0 else 1) + + (if (unitAmount.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + tierLowerBound == other.tierLowerBound && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(tierLowerBound, unitAmount, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } override fun equals(other: Any?): Boolean { if (this === other) { @@ -1270,15 +1568,16 @@ private constructor( } return other is TieredWithProrationConfig && + tiers == other.tiers && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(tiers, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "TieredWithProrationConfig{additionalProperties=$additionalProperties}" + "TieredWithProrationConfig{tiers=$tiers, additionalProperties=$additionalProperties}" } /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingUnitPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingUnitPrice.kt index 2788716f7..156ef8cb5 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingUnitPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingUnitPrice.kt @@ -129,6 +129,8 @@ private constructor( fun itemId(): String = itemId.getRequired("item_id") /** + * The pricing model type + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ @@ -143,6 +145,8 @@ private constructor( fun name(): String = name.getRequired("name") /** + * Configuration for unit pricing + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ @@ -504,6 +508,7 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + /** The pricing model type */ fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) /** @@ -526,6 +531,7 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } + /** Configuration for unit pricing */ fun unitConfig(unitConfig: UnitConfig) = unitConfig(JsonField.of(unitConfig)) /** @@ -1044,6 +1050,7 @@ private constructor( override fun toString() = value.toString() } + /** The pricing model type */ class ModelType @JsonCreator private constructor(private val value: JsonField) : Enum { /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingUnitWithPercentPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingUnitWithPercentPrice.kt index 447a23413..91bda2272 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingUnitWithPercentPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingUnitWithPercentPrice.kt @@ -129,6 +129,8 @@ private constructor( fun itemId(): String = itemId.getRequired("item_id") /** + * The pricing model type + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ @@ -143,6 +145,8 @@ private constructor( fun name(): String = name.getRequired("name") /** + * Configuration for unit_with_percent pricing + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ @@ -512,6 +516,7 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + /** The pricing model type */ fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) /** @@ -534,6 +539,7 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } + /** Configuration for unit_with_percent pricing */ fun unitWithPercentConfig(unitWithPercentConfig: UnitWithPercentConfig) = unitWithPercentConfig(JsonField.of(unitWithPercentConfig)) @@ -1055,6 +1061,7 @@ private constructor( override fun toString() = value.toString() } + /** The pricing model type */ class ModelType @JsonCreator private constructor(private val value: JsonField) : Enum { /** @@ -1175,16 +1182,63 @@ private constructor( override fun toString() = value.toString() } + /** Configuration for unit_with_percent pricing */ class UnitWithPercentConfig - @JsonCreator private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map + private val percent: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, ) { + @JsonCreator + private constructor( + @JsonProperty("percent") @ExcludeMissing percent: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(percent, unitAmount, mutableMapOf()) + + /** + * What percent, out of 100, of the calculated total to charge + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun percent(): String = percent.getRequired("percent") + + /** + * Rate per unit of usage + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [percent]. + * + * Unlike [percent], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("percent") @ExcludeMissing fun _percent(): JsonField = percent + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) fun toBuilder() = Builder().from(this) @@ -1192,6 +1246,12 @@ private constructor( /** * Returns a mutable builder for constructing an instance of [UnitWithPercentConfig]. + * + * The following fields are required: + * ```kotlin + * .percent() + * .unitAmount() + * ``` */ fun builder() = Builder() } @@ -1199,12 +1259,40 @@ private constructor( /** A builder for [UnitWithPercentConfig]. */ class Builder internal constructor() { + private var percent: JsonField? = null + private var unitAmount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(unitWithPercentConfig: UnitWithPercentConfig) = apply { + percent = unitWithPercentConfig.percent + unitAmount = unitWithPercentConfig.unitAmount additionalProperties = unitWithPercentConfig.additionalProperties.toMutableMap() } + /** What percent, out of 100, of the calculated total to charge */ + fun percent(percent: String) = percent(JsonField.of(percent)) + + /** + * Sets [Builder.percent] to an arbitrary JSON value. + * + * You should usually call [Builder.percent] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun percent(percent: JsonField) = apply { this.percent = percent } + + /** Rate per unit of usage */ + fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { this.unitAmount = unitAmount } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -1228,9 +1316,21 @@ private constructor( * Returns an immutable instance of [UnitWithPercentConfig]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .percent() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ fun build(): UnitWithPercentConfig = - UnitWithPercentConfig(additionalProperties.toImmutable()) + UnitWithPercentConfig( + checkRequired("percent", percent), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false @@ -1240,6 +1340,8 @@ private constructor( return@apply } + percent() + unitAmount() validated = true } @@ -1258,7 +1360,7 @@ private constructor( * Used for best match union deserialization. */ internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + (if (percent.asKnown() == null) 0 else 1) + (if (unitAmount.asKnown() == null) 0 else 1) override fun equals(other: Any?): Boolean { if (this === other) { @@ -1266,15 +1368,19 @@ private constructor( } return other is UnitWithPercentConfig && + percent == other.percent && + unitAmount == other.unitAmount && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + private val hashCode: Int by lazy { + Objects.hash(percent, unitAmount, additionalProperties) + } override fun hashCode(): Int = hashCode override fun toString() = - "UnitWithPercentConfig{additionalProperties=$additionalProperties}" + "UnitWithPercentConfig{percent=$percent, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" } /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingUnitWithProrationPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingUnitWithProrationPrice.kt index 15e3d39a0..48892d987 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingUnitWithProrationPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingUnitWithProrationPrice.kt @@ -129,6 +129,8 @@ private constructor( fun itemId(): String = itemId.getRequired("item_id") /** + * The pricing model type + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ @@ -143,6 +145,8 @@ private constructor( fun name(): String = name.getRequired("name") /** + * Configuration for unit_with_proration pricing + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ @@ -512,6 +516,7 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + /** The pricing model type */ fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) /** @@ -534,6 +539,7 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } + /** Configuration for unit_with_proration pricing */ fun unitWithProrationConfig(unitWithProrationConfig: UnitWithProrationConfig) = unitWithProrationConfig(JsonField.of(unitWithProrationConfig)) @@ -1056,6 +1062,7 @@ private constructor( override fun toString() = value.toString() } + /** The pricing model type */ class ModelType @JsonCreator private constructor(private val value: JsonField) : Enum { /** @@ -1176,16 +1183,46 @@ private constructor( override fun toString() = value.toString() } + /** Configuration for unit_with_proration pricing */ class UnitWithProrationConfig - @JsonCreator private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, ) { + @JsonCreator + private constructor( + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of() + ) : this(unitAmount, mutableMapOf()) + + /** + * Rate per unit of usage + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) fun toBuilder() = Builder().from(this) @@ -1193,6 +1230,11 @@ private constructor( /** * Returns a mutable builder for constructing an instance of [UnitWithProrationConfig]. + * + * The following fields are required: + * ```kotlin + * .unitAmount() + * ``` */ fun builder() = Builder() } @@ -1200,12 +1242,26 @@ private constructor( /** A builder for [UnitWithProrationConfig]. */ class Builder internal constructor() { + private var unitAmount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(unitWithProrationConfig: UnitWithProrationConfig) = apply { + unitAmount = unitWithProrationConfig.unitAmount additionalProperties = unitWithProrationConfig.additionalProperties.toMutableMap() } + /** Rate per unit of usage */ + fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { this.unitAmount = unitAmount } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -1229,9 +1285,19 @@ private constructor( * Returns an immutable instance of [UnitWithProrationConfig]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ fun build(): UnitWithProrationConfig = - UnitWithProrationConfig(additionalProperties.toImmutable()) + UnitWithProrationConfig( + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false @@ -1241,6 +1307,7 @@ private constructor( return@apply } + unitAmount() validated = true } @@ -1258,8 +1325,7 @@ private constructor( * * Used for best match union deserialization. */ - internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + internal fun validity(): Int = (if (unitAmount.asKnown() == null) 0 else 1) override fun equals(other: Any?): Boolean { if (this === other) { @@ -1267,15 +1333,16 @@ private constructor( } return other is UnitWithProrationConfig && + unitAmount == other.unitAmount && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(unitAmount, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "UnitWithProrationConfig{additionalProperties=$additionalProperties}" + "UnitWithProrationConfig{unitAmount=$unitAmount, additionalProperties=$additionalProperties}" } /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanBulkPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanBulkPrice.kt index 036869299..51fb48aab 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanBulkPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanBulkPrice.kt @@ -110,6 +110,8 @@ private constructor( ) /** + * Configuration for bulk pricing + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ @@ -132,6 +134,8 @@ private constructor( fun itemId(): String = itemId.getRequired("item_id") /** + * The pricing model type + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ @@ -496,6 +500,7 @@ private constructor( additionalProperties = newPlanBulkPrice.additionalProperties.toMutableMap() } + /** Configuration for bulk pricing */ fun bulkConfig(bulkConfig: BulkConfig) = bulkConfig(JsonField.of(bulkConfig)) /** @@ -529,6 +534,7 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + /** The pricing model type */ fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) /** @@ -1089,6 +1095,7 @@ private constructor( override fun toString() = value.toString() } + /** The pricing model type */ class ModelType @JsonCreator private constructor(private val value: JsonField) : Enum { /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanBulkWithProrationPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanBulkWithProrationPrice.kt index feb8f7230..6bba819fb 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanBulkWithProrationPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanBulkWithProrationPrice.kt @@ -11,6 +11,7 @@ import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue +import com.withorb.api.core.checkKnown import com.withorb.api.core.checkRequired import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException @@ -110,6 +111,8 @@ private constructor( ) /** + * Configuration for bulk_with_proration pricing + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ @@ -133,6 +136,8 @@ private constructor( fun itemId(): String = itemId.getRequired("item_id") /** + * The pricing model type + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ @@ -500,6 +505,7 @@ private constructor( additionalProperties = newPlanBulkWithProrationPrice.additionalProperties.toMutableMap() } + /** Configuration for bulk_with_proration pricing */ fun bulkWithProrationConfig(bulkWithProrationConfig: BulkWithProrationConfig) = bulkWithProrationConfig(JsonField.of(bulkWithProrationConfig)) @@ -537,6 +543,7 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + /** The pricing model type */ fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) /** @@ -948,16 +955,42 @@ private constructor( (metadata.asKnown()?.validity() ?: 0) + (if (referenceId.asKnown() == null) 0 else 1) + /** Configuration for bulk_with_proration pricing */ class BulkWithProrationConfig - @JsonCreator private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map + private val tiers: JsonField>, + private val additionalProperties: MutableMap, ) { + @JsonCreator + private constructor( + @JsonProperty("tiers") @ExcludeMissing tiers: JsonField> = JsonMissing.of() + ) : this(tiers, mutableMapOf()) + + /** + * Bulk tiers for rating based on total usage volume + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun tiers(): List = tiers.getRequired("tiers") + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tiers") @ExcludeMissing fun _tiers(): JsonField> = tiers + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) fun toBuilder() = Builder().from(this) @@ -965,6 +998,11 @@ private constructor( /** * Returns a mutable builder for constructing an instance of [BulkWithProrationConfig]. + * + * The following fields are required: + * ```kotlin + * .tiers() + * ``` */ fun builder() = Builder() } @@ -972,12 +1010,40 @@ private constructor( /** A builder for [BulkWithProrationConfig]. */ class Builder internal constructor() { + private var tiers: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(bulkWithProrationConfig: BulkWithProrationConfig) = apply { + tiers = bulkWithProrationConfig.tiers.map { it.toMutableList() } additionalProperties = bulkWithProrationConfig.additionalProperties.toMutableMap() } + /** Bulk tiers for rating based on total usage volume */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -1001,9 +1067,19 @@ private constructor( * Returns an immutable instance of [BulkWithProrationConfig]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ fun build(): BulkWithProrationConfig = - BulkWithProrationConfig(additionalProperties.toImmutable()) + BulkWithProrationConfig( + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false @@ -1013,6 +1089,7 @@ private constructor( return@apply } + tiers().forEach { it.validate() } validated = true } @@ -1030,8 +1107,222 @@ private constructor( * * Used for best match union deserialization. */ - internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + internal fun validity(): Int = (tiers.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single bulk pricing tier with proration */ + class Tier + private constructor( + private val unitAmount: JsonField, + private val tierLowerBound: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + ) : this(unitAmount, tierLowerBound, mutableMapOf()) + + /** + * Cost per unit + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * The lower bound for this tier + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun tierLowerBound(): String? = tierLowerBound.getNullable("tier_lower_bound") + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Tier]. + * + * The following fields are required: + * ```kotlin + * .unitAmount() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var unitAmount: JsonField? = null + private var tierLowerBound: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(tier: Tier) = apply { + unitAmount = tier.unitAmount + tierLowerBound = tier.tierLowerBound + additionalProperties = tier.additionalProperties.toMutableMap() + } + + /** Cost per unit */ + fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + /** The lower bound for this tier */ + fun tierLowerBound(tierLowerBound: String?) = + tierLowerBound(JsonField.ofNullable(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Tier]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("unitAmount", unitAmount), + tierLowerBound, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + unitAmount() + tierLowerBound() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (unitAmount.asKnown() == null) 0 else 1) + + (if (tierLowerBound.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + unitAmount == other.unitAmount && + tierLowerBound == other.tierLowerBound && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(unitAmount, tierLowerBound, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{unitAmount=$unitAmount, tierLowerBound=$tierLowerBound, additionalProperties=$additionalProperties}" + } override fun equals(other: Any?): Boolean { if (this === other) { @@ -1039,15 +1330,16 @@ private constructor( } return other is BulkWithProrationConfig && + tiers == other.tiers && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(tiers, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "BulkWithProrationConfig{additionalProperties=$additionalProperties}" + "BulkWithProrationConfig{tiers=$tiers, additionalProperties=$additionalProperties}" } /** The cadence to bill for this price on. */ @@ -1199,6 +1491,7 @@ private constructor( override fun toString() = value.toString() } + /** The pricing model type */ class ModelType @JsonCreator private constructor(private val value: JsonField) : Enum { /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanCumulativeGroupedBulkPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanCumulativeGroupedBulkPrice.kt index e491d8f73..6584cee77 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanCumulativeGroupedBulkPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanCumulativeGroupedBulkPrice.kt @@ -11,6 +11,7 @@ import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue +import com.withorb.api.core.checkKnown import com.withorb.api.core.checkRequired import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException @@ -118,6 +119,8 @@ private constructor( fun cadence(): Cadence = cadence.getRequired("cadence") /** + * Configuration for cumulative_grouped_bulk pricing + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ @@ -133,6 +136,8 @@ private constructor( fun itemId(): String = itemId.getRequired("item_id") /** + * The pricing model type + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ @@ -517,6 +522,7 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + /** Configuration for cumulative_grouped_bulk pricing */ fun cumulativeGroupedBulkConfig(cumulativeGroupedBulkConfig: CumulativeGroupedBulkConfig) = cumulativeGroupedBulkConfig(JsonField.of(cumulativeGroupedBulkConfig)) @@ -542,6 +548,7 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + /** The pricing model type */ fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) /** @@ -1102,16 +1109,65 @@ private constructor( override fun toString() = value.toString() } + /** Configuration for cumulative_grouped_bulk pricing */ class CumulativeGroupedBulkConfig - @JsonCreator private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map + private val dimensionValues: JsonField>, + private val group: JsonField, + private val additionalProperties: MutableMap, ) { + @JsonCreator + private constructor( + @JsonProperty("dimension_values") + @ExcludeMissing + dimensionValues: JsonField> = JsonMissing.of(), + @JsonProperty("group") @ExcludeMissing group: JsonField = JsonMissing.of(), + ) : this(dimensionValues, group, mutableMapOf()) + + /** + * Each tier lower bound must have the same group of values. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun dimensionValues(): List = + dimensionValues.getRequired("dimension_values") + + /** + * Grouping key name + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun group(): String = group.getRequired("group") + + /** + * Returns the raw JSON value of [dimensionValues]. + * + * Unlike [dimensionValues], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("dimension_values") + @ExcludeMissing + fun _dimensionValues(): JsonField> = dimensionValues + + /** + * Returns the raw JSON value of [group]. + * + * Unlike [group], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("group") @ExcludeMissing fun _group(): JsonField = group + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) fun toBuilder() = Builder().from(this) @@ -1120,6 +1176,12 @@ private constructor( /** * Returns a mutable builder for constructing an instance of * [CumulativeGroupedBulkConfig]. + * + * The following fields are required: + * ```kotlin + * .dimensionValues() + * .group() + * ``` */ fun builder() = Builder() } @@ -1127,13 +1189,57 @@ private constructor( /** A builder for [CumulativeGroupedBulkConfig]. */ class Builder internal constructor() { + private var dimensionValues: JsonField>? = null + private var group: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(cumulativeGroupedBulkConfig: CumulativeGroupedBulkConfig) = apply { + dimensionValues = + cumulativeGroupedBulkConfig.dimensionValues.map { it.toMutableList() } + group = cumulativeGroupedBulkConfig.group additionalProperties = cumulativeGroupedBulkConfig.additionalProperties.toMutableMap() } + /** Each tier lower bound must have the same group of values. */ + fun dimensionValues(dimensionValues: List) = + dimensionValues(JsonField.of(dimensionValues)) + + /** + * Sets [Builder.dimensionValues] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionValues] with a well-typed + * `List` value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun dimensionValues(dimensionValues: JsonField>) = apply { + this.dimensionValues = dimensionValues.map { it.toMutableList() } + } + + /** + * Adds a single [DimensionValue] to [dimensionValues]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addDimensionValue(dimensionValue: DimensionValue) = apply { + dimensionValues = + (dimensionValues ?: JsonField.of(mutableListOf())).also { + checkKnown("dimensionValues", it).add(dimensionValue) + } + } + + /** Grouping key name */ + fun group(group: String) = group(JsonField.of(group)) + + /** + * Sets [Builder.group] to an arbitrary JSON value. + * + * You should usually call [Builder.group] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun group(group: JsonField) = apply { this.group = group } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -1157,9 +1263,21 @@ private constructor( * Returns an immutable instance of [CumulativeGroupedBulkConfig]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .dimensionValues() + * .group() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ fun build(): CumulativeGroupedBulkConfig = - CumulativeGroupedBulkConfig(additionalProperties.toImmutable()) + CumulativeGroupedBulkConfig( + checkRequired("dimensionValues", dimensionValues).map { it.toImmutable() }, + checkRequired("group", group), + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false @@ -1169,6 +1287,8 @@ private constructor( return@apply } + dimensionValues().forEach { it.validate() } + group() validated = true } @@ -1187,7 +1307,271 @@ private constructor( * Used for best match union deserialization. */ internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + (dimensionValues.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + (if (group.asKnown() == null) 0 else 1) + + /** Configuration for a dimension value entry */ + class DimensionValue + private constructor( + private val groupingKey: JsonField, + private val tierLowerBound: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(groupingKey, tierLowerBound, unitAmount, mutableMapOf()) + + /** + * Grouping key value + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * Tier lower bound + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun tierLowerBound(): String = tierLowerBound.getRequired("tier_lower_bound") + + /** + * Unit amount for this combination + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [DimensionValue]. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .tierLowerBound() + * .unitAmount() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [DimensionValue]. */ + class Builder internal constructor() { + + private var groupingKey: JsonField? = null + private var tierLowerBound: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(dimensionValue: DimensionValue) = apply { + groupingKey = dimensionValue.groupingKey + tierLowerBound = dimensionValue.tierLowerBound + unitAmount = dimensionValue.unitAmount + additionalProperties = dimensionValue.additionalProperties.toMutableMap() + } + + /** Grouping key value */ + fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** Tier lower bound */ + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + /** Unit amount for this combination */ + fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [DimensionValue]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .tierLowerBound() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): DimensionValue = + DimensionValue( + checkRequired("groupingKey", groupingKey), + checkRequired("tierLowerBound", tierLowerBound), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): DimensionValue = apply { + if (validated) { + return@apply + } + + groupingKey() + tierLowerBound() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (groupingKey.asKnown() == null) 0 else 1) + + (if (tierLowerBound.asKnown() == null) 0 else 1) + + (if (unitAmount.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is DimensionValue && + groupingKey == other.groupingKey && + tierLowerBound == other.tierLowerBound && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(groupingKey, tierLowerBound, unitAmount, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "DimensionValue{groupingKey=$groupingKey, tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } override fun equals(other: Any?): Boolean { if (this === other) { @@ -1195,17 +1579,22 @@ private constructor( } return other is CumulativeGroupedBulkConfig && + dimensionValues == other.dimensionValues && + group == other.group && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + private val hashCode: Int by lazy { + Objects.hash(dimensionValues, group, additionalProperties) + } override fun hashCode(): Int = hashCode override fun toString() = - "CumulativeGroupedBulkConfig{additionalProperties=$additionalProperties}" + "CumulativeGroupedBulkConfig{dimensionValues=$dimensionValues, group=$group, additionalProperties=$additionalProperties}" } + /** The pricing model type */ class ModelType @JsonCreator private constructor(private val value: JsonField) : Enum { /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanGroupedAllocationPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanGroupedAllocationPrice.kt index 49561abbc..4c175c430 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanGroupedAllocationPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanGroupedAllocationPrice.kt @@ -118,6 +118,8 @@ private constructor( fun cadence(): Cadence = cadence.getRequired("cadence") /** + * Configuration for grouped_allocation pricing + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ @@ -133,6 +135,8 @@ private constructor( fun itemId(): String = itemId.getRequired("item_id") /** + * The pricing model type + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ @@ -511,6 +515,7 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + /** Configuration for grouped_allocation pricing */ fun groupedAllocationConfig(groupedAllocationConfig: GroupedAllocationConfig) = groupedAllocationConfig(JsonField.of(groupedAllocationConfig)) @@ -537,6 +542,7 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + /** The pricing model type */ fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) /** @@ -1097,16 +1103,89 @@ private constructor( override fun toString() = value.toString() } + /** Configuration for grouped_allocation pricing */ class GroupedAllocationConfig - @JsonCreator private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map + private val allocation: JsonField, + private val groupingKey: JsonField, + private val overageUnitRate: JsonField, + private val additionalProperties: MutableMap, ) { + @JsonCreator + private constructor( + @JsonProperty("allocation") + @ExcludeMissing + allocation: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("overage_unit_rate") + @ExcludeMissing + overageUnitRate: JsonField = JsonMissing.of(), + ) : this(allocation, groupingKey, overageUnitRate, mutableMapOf()) + + /** + * Usage allocation per group + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun allocation(): String = allocation.getRequired("allocation") + + /** + * How to determine the groups that should each be allocated some quantity + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * Unit rate for post-allocation + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun overageUnitRate(): String = overageUnitRate.getRequired("overage_unit_rate") + + /** + * Returns the raw JSON value of [allocation]. + * + * Unlike [allocation], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("allocation") + @ExcludeMissing + fun _allocation(): JsonField = allocation + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [overageUnitRate]. + * + * Unlike [overageUnitRate], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("overage_unit_rate") + @ExcludeMissing + fun _overageUnitRate(): JsonField = overageUnitRate + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) fun toBuilder() = Builder().from(this) @@ -1114,6 +1193,13 @@ private constructor( /** * Returns a mutable builder for constructing an instance of [GroupedAllocationConfig]. + * + * The following fields are required: + * ```kotlin + * .allocation() + * .groupingKey() + * .overageUnitRate() + * ``` */ fun builder() = Builder() } @@ -1121,12 +1207,59 @@ private constructor( /** A builder for [GroupedAllocationConfig]. */ class Builder internal constructor() { + private var allocation: JsonField? = null + private var groupingKey: JsonField? = null + private var overageUnitRate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(groupedAllocationConfig: GroupedAllocationConfig) = apply { + allocation = groupedAllocationConfig.allocation + groupingKey = groupedAllocationConfig.groupingKey + overageUnitRate = groupedAllocationConfig.overageUnitRate additionalProperties = groupedAllocationConfig.additionalProperties.toMutableMap() } + /** Usage allocation per group */ + fun allocation(allocation: String) = allocation(JsonField.of(allocation)) + + /** + * Sets [Builder.allocation] to an arbitrary JSON value. + * + * You should usually call [Builder.allocation] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun allocation(allocation: JsonField) = apply { this.allocation = allocation } + + /** How to determine the groups that should each be allocated some quantity */ + fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** Unit rate for post-allocation */ + fun overageUnitRate(overageUnitRate: String) = + overageUnitRate(JsonField.of(overageUnitRate)) + + /** + * Sets [Builder.overageUnitRate] to an arbitrary JSON value. + * + * You should usually call [Builder.overageUnitRate] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun overageUnitRate(overageUnitRate: JsonField) = apply { + this.overageUnitRate = overageUnitRate + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -1150,9 +1283,23 @@ private constructor( * Returns an immutable instance of [GroupedAllocationConfig]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .allocation() + * .groupingKey() + * .overageUnitRate() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ fun build(): GroupedAllocationConfig = - GroupedAllocationConfig(additionalProperties.toImmutable()) + GroupedAllocationConfig( + checkRequired("allocation", allocation), + checkRequired("groupingKey", groupingKey), + checkRequired("overageUnitRate", overageUnitRate), + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false @@ -1162,6 +1309,9 @@ private constructor( return@apply } + allocation() + groupingKey() + overageUnitRate() validated = true } @@ -1180,7 +1330,9 @@ private constructor( * Used for best match union deserialization. */ internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + (if (allocation.asKnown() == null) 0 else 1) + + (if (groupingKey.asKnown() == null) 0 else 1) + + (if (overageUnitRate.asKnown() == null) 0 else 1) override fun equals(other: Any?): Boolean { if (this === other) { @@ -1188,17 +1340,23 @@ private constructor( } return other is GroupedAllocationConfig && + allocation == other.allocation && + groupingKey == other.groupingKey && + overageUnitRate == other.overageUnitRate && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + private val hashCode: Int by lazy { + Objects.hash(allocation, groupingKey, overageUnitRate, additionalProperties) + } override fun hashCode(): Int = hashCode override fun toString() = - "GroupedAllocationConfig{additionalProperties=$additionalProperties}" + "GroupedAllocationConfig{allocation=$allocation, groupingKey=$groupingKey, overageUnitRate=$overageUnitRate, additionalProperties=$additionalProperties}" } + /** The pricing model type */ class ModelType @JsonCreator private constructor(private val value: JsonField) : Enum { /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanGroupedTieredPackagePrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanGroupedTieredPackagePrice.kt index fd07cea0b..8df304a44 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanGroupedTieredPackagePrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanGroupedTieredPackagePrice.kt @@ -11,6 +11,7 @@ import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue +import com.withorb.api.core.checkKnown import com.withorb.api.core.checkRequired import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException @@ -118,6 +119,8 @@ private constructor( fun cadence(): Cadence = cadence.getRequired("cadence") /** + * Configuration for grouped_tiered_package pricing + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ @@ -133,6 +136,8 @@ private constructor( fun itemId(): String = itemId.getRequired("item_id") /** + * The pricing model type + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ @@ -517,6 +522,7 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + /** Configuration for grouped_tiered_package pricing */ fun groupedTieredPackageConfig(groupedTieredPackageConfig: GroupedTieredPackageConfig) = groupedTieredPackageConfig(JsonField.of(groupedTieredPackageConfig)) @@ -542,6 +548,7 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + /** The pricing model type */ fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) /** @@ -1102,16 +1109,85 @@ private constructor( override fun toString() = value.toString() } + /** Configuration for grouped_tiered_package pricing */ class GroupedTieredPackageConfig - @JsonCreator private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map + private val groupingKey: JsonField, + private val packageSize: JsonField, + private val tiers: JsonField>, + private val additionalProperties: MutableMap, ) { + @JsonCreator + private constructor( + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("package_size") + @ExcludeMissing + packageSize: JsonField = JsonMissing.of(), + @JsonProperty("tiers") @ExcludeMissing tiers: JsonField> = JsonMissing.of(), + ) : this(groupingKey, packageSize, tiers, mutableMapOf()) + + /** + * The event property used to group before tiering + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * Package size + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun packageSize(): String = packageSize.getRequired("package_size") + + /** + * Apply tiered pricing after rounding up the quantity to the package size. Tiers are + * defined using exclusive lower bounds. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun tiers(): List = tiers.getRequired("tiers") + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [packageSize]. + * + * Unlike [packageSize], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("package_size") + @ExcludeMissing + fun _packageSize(): JsonField = packageSize + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tiers") @ExcludeMissing fun _tiers(): JsonField> = tiers + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) fun toBuilder() = Builder().from(this) @@ -1120,6 +1196,13 @@ private constructor( /** * Returns a mutable builder for constructing an instance of * [GroupedTieredPackageConfig]. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .packageSize() + * .tiers() + * ``` */ fun builder() = Builder() } @@ -1127,13 +1210,76 @@ private constructor( /** A builder for [GroupedTieredPackageConfig]. */ class Builder internal constructor() { + private var groupingKey: JsonField? = null + private var packageSize: JsonField? = null + private var tiers: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(groupedTieredPackageConfig: GroupedTieredPackageConfig) = apply { + groupingKey = groupedTieredPackageConfig.groupingKey + packageSize = groupedTieredPackageConfig.packageSize + tiers = groupedTieredPackageConfig.tiers.map { it.toMutableList() } additionalProperties = groupedTieredPackageConfig.additionalProperties.toMutableMap() } + /** The event property used to group before tiering */ + fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** Package size */ + fun packageSize(packageSize: String) = packageSize(JsonField.of(packageSize)) + + /** + * Sets [Builder.packageSize] to an arbitrary JSON value. + * + * You should usually call [Builder.packageSize] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun packageSize(packageSize: JsonField) = apply { + this.packageSize = packageSize + } + + /** + * Apply tiered pricing after rounding up the quantity to the package size. Tiers are + * defined using exclusive lower bounds. + */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -1157,9 +1303,23 @@ private constructor( * Returns an immutable instance of [GroupedTieredPackageConfig]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .packageSize() + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ fun build(): GroupedTieredPackageConfig = - GroupedTieredPackageConfig(additionalProperties.toImmutable()) + GroupedTieredPackageConfig( + checkRequired("groupingKey", groupingKey), + checkRequired("packageSize", packageSize), + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false @@ -1169,6 +1329,9 @@ private constructor( return@apply } + groupingKey() + packageSize() + tiers().forEach { it.validate() } validated = true } @@ -1187,7 +1350,222 @@ private constructor( * Used for best match union deserialization. */ internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + (if (groupingKey.asKnown() == null) 0 else 1) + + (if (packageSize.asKnown() == null) 0 else 1) + + (tiers.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single tier */ + class Tier + private constructor( + private val perUnit: JsonField, + private val tierLowerBound: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("per_unit") + @ExcludeMissing + perUnit: JsonField = JsonMissing.of(), + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + ) : this(perUnit, tierLowerBound, mutableMapOf()) + + /** + * Price per package + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun perUnit(): String = perUnit.getRequired("per_unit") + + /** + * Tier lower bound + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun tierLowerBound(): String = tierLowerBound.getRequired("tier_lower_bound") + + /** + * Returns the raw JSON value of [perUnit]. + * + * Unlike [perUnit], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("per_unit") @ExcludeMissing fun _perUnit(): JsonField = perUnit + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Tier]. + * + * The following fields are required: + * ```kotlin + * .perUnit() + * .tierLowerBound() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var perUnit: JsonField? = null + private var tierLowerBound: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(tier: Tier) = apply { + perUnit = tier.perUnit + tierLowerBound = tier.tierLowerBound + additionalProperties = tier.additionalProperties.toMutableMap() + } + + /** Price per package */ + fun perUnit(perUnit: String) = perUnit(JsonField.of(perUnit)) + + /** + * Sets [Builder.perUnit] to an arbitrary JSON value. + * + * You should usually call [Builder.perUnit] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun perUnit(perUnit: JsonField) = apply { this.perUnit = perUnit } + + /** Tier lower bound */ + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Tier]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .perUnit() + * .tierLowerBound() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("perUnit", perUnit), + checkRequired("tierLowerBound", tierLowerBound), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + perUnit() + tierLowerBound() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (perUnit.asKnown() == null) 0 else 1) + + (if (tierLowerBound.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + perUnit == other.perUnit && + tierLowerBound == other.tierLowerBound && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(perUnit, tierLowerBound, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{perUnit=$perUnit, tierLowerBound=$tierLowerBound, additionalProperties=$additionalProperties}" + } override fun equals(other: Any?): Boolean { if (this === other) { @@ -1195,17 +1573,23 @@ private constructor( } return other is GroupedTieredPackageConfig && + groupingKey == other.groupingKey && + packageSize == other.packageSize && + tiers == other.tiers && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + private val hashCode: Int by lazy { + Objects.hash(groupingKey, packageSize, tiers, additionalProperties) + } override fun hashCode(): Int = hashCode override fun toString() = - "GroupedTieredPackageConfig{additionalProperties=$additionalProperties}" + "GroupedTieredPackageConfig{groupingKey=$groupingKey, packageSize=$packageSize, tiers=$tiers, additionalProperties=$additionalProperties}" } + /** The pricing model type */ class ModelType @JsonCreator private constructor(private val value: JsonField) : Enum { /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanGroupedTieredPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanGroupedTieredPrice.kt index 27977218e..c58f93ecd 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanGroupedTieredPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanGroupedTieredPrice.kt @@ -11,6 +11,7 @@ import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue +import com.withorb.api.core.checkKnown import com.withorb.api.core.checkRequired import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException @@ -118,6 +119,8 @@ private constructor( fun cadence(): Cadence = cadence.getRequired("cadence") /** + * Configuration for grouped_tiered pricing + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ @@ -133,6 +136,8 @@ private constructor( fun itemId(): String = itemId.getRequired("item_id") /** + * The pricing model type + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ @@ -509,6 +514,7 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + /** Configuration for grouped_tiered pricing */ fun groupedTieredConfig(groupedTieredConfig: GroupedTieredConfig) = groupedTieredConfig(JsonField.of(groupedTieredConfig)) @@ -534,6 +540,7 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + /** The pricing model type */ fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) /** @@ -1094,34 +1101,135 @@ private constructor( override fun toString() = value.toString() } + /** Configuration for grouped_tiered pricing */ class GroupedTieredConfig - @JsonCreator private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map + private val groupingKey: JsonField, + private val tiers: JsonField>, + private val additionalProperties: MutableMap, ) { + @JsonCreator + private constructor( + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("tiers") @ExcludeMissing tiers: JsonField> = JsonMissing.of(), + ) : this(groupingKey, tiers, mutableMapOf()) + + /** + * The billable metric property used to group before tiering + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * Apply tiered pricing to each segment generated after grouping with the provided key + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun tiers(): List = tiers.getRequired("tiers") + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tiers") @ExcludeMissing fun _tiers(): JsonField> = tiers + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) fun toBuilder() = Builder().from(this) companion object { - /** Returns a mutable builder for constructing an instance of [GroupedTieredConfig]. */ + /** + * Returns a mutable builder for constructing an instance of [GroupedTieredConfig]. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .tiers() + * ``` + */ fun builder() = Builder() } /** A builder for [GroupedTieredConfig]. */ class Builder internal constructor() { + private var groupingKey: JsonField? = null + private var tiers: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(groupedTieredConfig: GroupedTieredConfig) = apply { + groupingKey = groupedTieredConfig.groupingKey + tiers = groupedTieredConfig.tiers.map { it.toMutableList() } additionalProperties = groupedTieredConfig.additionalProperties.toMutableMap() } + /** The billable metric property used to group before tiering */ + fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** + * Apply tiered pricing to each segment generated after grouping with the provided key + */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -1145,9 +1253,21 @@ private constructor( * Returns an immutable instance of [GroupedTieredConfig]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ fun build(): GroupedTieredConfig = - GroupedTieredConfig(additionalProperties.toImmutable()) + GroupedTieredConfig( + checkRequired("groupingKey", groupingKey), + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false @@ -1157,6 +1277,8 @@ private constructor( return@apply } + groupingKey() + tiers().forEach { it.validate() } validated = true } @@ -1175,7 +1297,226 @@ private constructor( * Used for best match union deserialization. */ internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + (if (groupingKey.asKnown() == null) 0 else 1) + + (tiers.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single tier */ + class Tier + private constructor( + private val tierLowerBound: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(tierLowerBound, unitAmount, mutableMapOf()) + + /** + * Tier lower bound + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun tierLowerBound(): String = tierLowerBound.getRequired("tier_lower_bound") + + /** + * Per unit amount + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Tier]. + * + * The following fields are required: + * ```kotlin + * .tierLowerBound() + * .unitAmount() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var tierLowerBound: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(tier: Tier) = apply { + tierLowerBound = tier.tierLowerBound + unitAmount = tier.unitAmount + additionalProperties = tier.additionalProperties.toMutableMap() + } + + /** Tier lower bound */ + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + /** Per unit amount */ + fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Tier]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .tierLowerBound() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("tierLowerBound", tierLowerBound), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + tierLowerBound() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (tierLowerBound.asKnown() == null) 0 else 1) + + (if (unitAmount.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + tierLowerBound == other.tierLowerBound && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(tierLowerBound, unitAmount, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } override fun equals(other: Any?): Boolean { if (this === other) { @@ -1183,16 +1524,20 @@ private constructor( } return other is GroupedTieredConfig && + groupingKey == other.groupingKey && + tiers == other.tiers && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(groupingKey, tiers, additionalProperties) } override fun hashCode(): Int = hashCode - override fun toString() = "GroupedTieredConfig{additionalProperties=$additionalProperties}" + override fun toString() = + "GroupedTieredConfig{groupingKey=$groupingKey, tiers=$tiers, additionalProperties=$additionalProperties}" } + /** The pricing model type */ class ModelType @JsonCreator private constructor(private val value: JsonField) : Enum { /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanGroupedWithMeteredMinimumPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanGroupedWithMeteredMinimumPrice.kt index 7a4d8f17c..a694be46a 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanGroupedWithMeteredMinimumPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanGroupedWithMeteredMinimumPrice.kt @@ -11,6 +11,7 @@ import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue +import com.withorb.api.core.checkKnown import com.withorb.api.core.checkRequired import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException @@ -119,6 +120,8 @@ private constructor( fun cadence(): Cadence = cadence.getRequired("cadence") /** + * Configuration for grouped_with_metered_minimum pricing + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ @@ -134,6 +137,8 @@ private constructor( fun itemId(): String = itemId.getRequired("item_id") /** + * The pricing model type + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ @@ -520,6 +525,7 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + /** Configuration for grouped_with_metered_minimum pricing */ fun groupedWithMeteredMinimumConfig( groupedWithMeteredMinimumConfig: GroupedWithMeteredMinimumConfig ) = groupedWithMeteredMinimumConfig(JsonField.of(groupedWithMeteredMinimumConfig)) @@ -546,6 +552,7 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + /** The pricing model type */ fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) /** @@ -1106,16 +1113,162 @@ private constructor( override fun toString() = value.toString() } + /** Configuration for grouped_with_metered_minimum pricing */ class GroupedWithMeteredMinimumConfig - @JsonCreator private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map + private val groupingKey: JsonField, + private val minimumUnitAmount: JsonField, + private val pricingKey: JsonField, + private val scalingFactors: JsonField>, + private val scalingKey: JsonField, + private val unitAmounts: JsonField>, + private val additionalProperties: MutableMap, ) { + @JsonCreator + private constructor( + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("minimum_unit_amount") + @ExcludeMissing + minimumUnitAmount: JsonField = JsonMissing.of(), + @JsonProperty("pricing_key") + @ExcludeMissing + pricingKey: JsonField = JsonMissing.of(), + @JsonProperty("scaling_factors") + @ExcludeMissing + scalingFactors: JsonField> = JsonMissing.of(), + @JsonProperty("scaling_key") + @ExcludeMissing + scalingKey: JsonField = JsonMissing.of(), + @JsonProperty("unit_amounts") + @ExcludeMissing + unitAmounts: JsonField> = JsonMissing.of(), + ) : this( + groupingKey, + minimumUnitAmount, + pricingKey, + scalingFactors, + scalingKey, + unitAmounts, + mutableMapOf(), + ) + + /** + * Used to partition the usage into groups. The minimum amount is applied to each group. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The minimum amount to charge per group per unit + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun minimumUnitAmount(): String = minimumUnitAmount.getRequired("minimum_unit_amount") + + /** + * Used to determine the unit rate + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun pricingKey(): String = pricingKey.getRequired("pricing_key") + + /** + * Scale the unit rates by the scaling factor. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun scalingFactors(): List = scalingFactors.getRequired("scaling_factors") + + /** + * Used to determine the unit rate scaling factor + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun scalingKey(): String = scalingKey.getRequired("scaling_key") + + /** + * Apply per unit pricing to each pricing value. The minimum amount is applied any unmatched + * usage. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun unitAmounts(): List = unitAmounts.getRequired("unit_amounts") + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [minimumUnitAmount]. + * + * Unlike [minimumUnitAmount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("minimum_unit_amount") + @ExcludeMissing + fun _minimumUnitAmount(): JsonField = minimumUnitAmount + + /** + * Returns the raw JSON value of [pricingKey]. + * + * Unlike [pricingKey], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("pricing_key") + @ExcludeMissing + fun _pricingKey(): JsonField = pricingKey + + /** + * Returns the raw JSON value of [scalingFactors]. + * + * Unlike [scalingFactors], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("scaling_factors") + @ExcludeMissing + fun _scalingFactors(): JsonField> = scalingFactors + + /** + * Returns the raw JSON value of [scalingKey]. + * + * Unlike [scalingKey], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("scaling_key") + @ExcludeMissing + fun _scalingKey(): JsonField = scalingKey + + /** + * Returns the raw JSON value of [unitAmounts]. + * + * Unlike [unitAmounts], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("unit_amounts") + @ExcludeMissing + fun _unitAmounts(): JsonField> = unitAmounts + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) fun toBuilder() = Builder().from(this) @@ -1124,6 +1277,16 @@ private constructor( /** * Returns a mutable builder for constructing an instance of * [GroupedWithMeteredMinimumConfig]. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .minimumUnitAmount() + * .pricingKey() + * .scalingFactors() + * .scalingKey() + * .unitAmounts() + * ``` */ fun builder() = Builder() } @@ -1131,14 +1294,139 @@ private constructor( /** A builder for [GroupedWithMeteredMinimumConfig]. */ class Builder internal constructor() { + private var groupingKey: JsonField? = null + private var minimumUnitAmount: JsonField? = null + private var pricingKey: JsonField? = null + private var scalingFactors: JsonField>? = null + private var scalingKey: JsonField? = null + private var unitAmounts: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(groupedWithMeteredMinimumConfig: GroupedWithMeteredMinimumConfig) = apply { + groupingKey = groupedWithMeteredMinimumConfig.groupingKey + minimumUnitAmount = groupedWithMeteredMinimumConfig.minimumUnitAmount + pricingKey = groupedWithMeteredMinimumConfig.pricingKey + scalingFactors = + groupedWithMeteredMinimumConfig.scalingFactors.map { it.toMutableList() } + scalingKey = groupedWithMeteredMinimumConfig.scalingKey + unitAmounts = + groupedWithMeteredMinimumConfig.unitAmounts.map { it.toMutableList() } additionalProperties = groupedWithMeteredMinimumConfig.additionalProperties.toMutableMap() } + /** + * Used to partition the usage into groups. The minimum amount is applied to each group. + */ + fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The minimum amount to charge per group per unit */ + fun minimumUnitAmount(minimumUnitAmount: String) = + minimumUnitAmount(JsonField.of(minimumUnitAmount)) + + /** + * Sets [Builder.minimumUnitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumUnitAmount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun minimumUnitAmount(minimumUnitAmount: JsonField) = apply { + this.minimumUnitAmount = minimumUnitAmount + } + + /** Used to determine the unit rate */ + fun pricingKey(pricingKey: String) = pricingKey(JsonField.of(pricingKey)) + + /** + * Sets [Builder.pricingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.pricingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun pricingKey(pricingKey: JsonField) = apply { this.pricingKey = pricingKey } + + /** Scale the unit rates by the scaling factor. */ + fun scalingFactors(scalingFactors: List) = + scalingFactors(JsonField.of(scalingFactors)) + + /** + * Sets [Builder.scalingFactors] to an arbitrary JSON value. + * + * You should usually call [Builder.scalingFactors] with a well-typed + * `List` value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun scalingFactors(scalingFactors: JsonField>) = apply { + this.scalingFactors = scalingFactors.map { it.toMutableList() } + } + + /** + * Adds a single [ScalingFactor] to [scalingFactors]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addScalingFactor(scalingFactor: ScalingFactor) = apply { + scalingFactors = + (scalingFactors ?: JsonField.of(mutableListOf())).also { + checkKnown("scalingFactors", it).add(scalingFactor) + } + } + + /** Used to determine the unit rate scaling factor */ + fun scalingKey(scalingKey: String) = scalingKey(JsonField.of(scalingKey)) + + /** + * Sets [Builder.scalingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.scalingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun scalingKey(scalingKey: JsonField) = apply { this.scalingKey = scalingKey } + + /** + * Apply per unit pricing to each pricing value. The minimum amount is applied any + * unmatched usage. + */ + fun unitAmounts(unitAmounts: List) = unitAmounts(JsonField.of(unitAmounts)) + + /** + * Sets [Builder.unitAmounts] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmounts] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun unitAmounts(unitAmounts: JsonField>) = apply { + this.unitAmounts = unitAmounts.map { it.toMutableList() } + } + + /** + * Adds a single [UnitAmount] to [unitAmounts]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addUnitAmount(unitAmount: UnitAmount) = apply { + unitAmounts = + (unitAmounts ?: JsonField.of(mutableListOf())).also { + checkKnown("unitAmounts", it).add(unitAmount) + } + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -1162,9 +1450,29 @@ private constructor( * Returns an immutable instance of [GroupedWithMeteredMinimumConfig]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .minimumUnitAmount() + * .pricingKey() + * .scalingFactors() + * .scalingKey() + * .unitAmounts() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ fun build(): GroupedWithMeteredMinimumConfig = - GroupedWithMeteredMinimumConfig(additionalProperties.toImmutable()) + GroupedWithMeteredMinimumConfig( + checkRequired("groupingKey", groupingKey), + checkRequired("minimumUnitAmount", minimumUnitAmount), + checkRequired("pricingKey", pricingKey), + checkRequired("scalingFactors", scalingFactors).map { it.toImmutable() }, + checkRequired("scalingKey", scalingKey), + checkRequired("unitAmounts", unitAmounts).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false @@ -1174,6 +1482,12 @@ private constructor( return@apply } + groupingKey() + minimumUnitAmount() + pricingKey() + scalingFactors().forEach { it.validate() } + scalingKey() + unitAmounts().forEach { it.validate() } validated = true } @@ -1192,7 +1506,447 @@ private constructor( * Used for best match union deserialization. */ internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + (if (groupingKey.asKnown() == null) 0 else 1) + + (if (minimumUnitAmount.asKnown() == null) 0 else 1) + + (if (pricingKey.asKnown() == null) 0 else 1) + + (scalingFactors.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + (if (scalingKey.asKnown() == null) 0 else 1) + + (unitAmounts.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a scaling factor */ + class ScalingFactor + private constructor( + private val scalingFactor: JsonField, + private val scalingValue: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("scaling_factor") + @ExcludeMissing + scalingFactor: JsonField = JsonMissing.of(), + @JsonProperty("scaling_value") + @ExcludeMissing + scalingValue: JsonField = JsonMissing.of(), + ) : this(scalingFactor, scalingValue, mutableMapOf()) + + /** + * Scaling factor + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun scalingFactor(): String = scalingFactor.getRequired("scaling_factor") + + /** + * Scaling value + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun scalingValue(): String = scalingValue.getRequired("scaling_value") + + /** + * Returns the raw JSON value of [scalingFactor]. + * + * Unlike [scalingFactor], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("scaling_factor") + @ExcludeMissing + fun _scalingFactor(): JsonField = scalingFactor + + /** + * Returns the raw JSON value of [scalingValue]. + * + * Unlike [scalingValue], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("scaling_value") + @ExcludeMissing + fun _scalingValue(): JsonField = scalingValue + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ScalingFactor]. + * + * The following fields are required: + * ```kotlin + * .scalingFactor() + * .scalingValue() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [ScalingFactor]. */ + class Builder internal constructor() { + + private var scalingFactor: JsonField? = null + private var scalingValue: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(scalingFactor: ScalingFactor) = apply { + this.scalingFactor = scalingFactor.scalingFactor + scalingValue = scalingFactor.scalingValue + additionalProperties = scalingFactor.additionalProperties.toMutableMap() + } + + /** Scaling factor */ + fun scalingFactor(scalingFactor: String) = + scalingFactor(JsonField.of(scalingFactor)) + + /** + * Sets [Builder.scalingFactor] to an arbitrary JSON value. + * + * You should usually call [Builder.scalingFactor] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun scalingFactor(scalingFactor: JsonField) = apply { + this.scalingFactor = scalingFactor + } + + /** Scaling value */ + fun scalingValue(scalingValue: String) = scalingValue(JsonField.of(scalingValue)) + + /** + * Sets [Builder.scalingValue] to an arbitrary JSON value. + * + * You should usually call [Builder.scalingValue] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun scalingValue(scalingValue: JsonField) = apply { + this.scalingValue = scalingValue + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ScalingFactor]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .scalingFactor() + * .scalingValue() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ScalingFactor = + ScalingFactor( + checkRequired("scalingFactor", scalingFactor), + checkRequired("scalingValue", scalingValue), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ScalingFactor = apply { + if (validated) { + return@apply + } + + scalingFactor() + scalingValue() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (scalingFactor.asKnown() == null) 0 else 1) + + (if (scalingValue.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ScalingFactor && + scalingFactor == other.scalingFactor && + scalingValue == other.scalingValue && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(scalingFactor, scalingValue, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ScalingFactor{scalingFactor=$scalingFactor, scalingValue=$scalingValue, additionalProperties=$additionalProperties}" + } + + /** Configuration for a unit amount */ + class UnitAmount + private constructor( + private val pricingValue: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("pricing_value") + @ExcludeMissing + pricingValue: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(pricingValue, unitAmount, mutableMapOf()) + + /** + * Pricing value + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun pricingValue(): String = pricingValue.getRequired("pricing_value") + + /** + * Per unit amount + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [pricingValue]. + * + * Unlike [pricingValue], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("pricing_value") + @ExcludeMissing + fun _pricingValue(): JsonField = pricingValue + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [UnitAmount]. + * + * The following fields are required: + * ```kotlin + * .pricingValue() + * .unitAmount() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [UnitAmount]. */ + class Builder internal constructor() { + + private var pricingValue: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(unitAmount: UnitAmount) = apply { + pricingValue = unitAmount.pricingValue + this.unitAmount = unitAmount.unitAmount + additionalProperties = unitAmount.additionalProperties.toMutableMap() + } + + /** Pricing value */ + fun pricingValue(pricingValue: String) = pricingValue(JsonField.of(pricingValue)) + + /** + * Sets [Builder.pricingValue] to an arbitrary JSON value. + * + * You should usually call [Builder.pricingValue] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun pricingValue(pricingValue: JsonField) = apply { + this.pricingValue = pricingValue + } + + /** Per unit amount */ + fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [UnitAmount]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .pricingValue() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UnitAmount = + UnitAmount( + checkRequired("pricingValue", pricingValue), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UnitAmount = apply { + if (validated) { + return@apply + } + + pricingValue() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (pricingValue.asKnown() == null) 0 else 1) + + (if (unitAmount.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnitAmount && + pricingValue == other.pricingValue && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(pricingValue, unitAmount, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UnitAmount{pricingValue=$pricingValue, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } override fun equals(other: Any?): Boolean { if (this === other) { @@ -1200,17 +1954,34 @@ private constructor( } return other is GroupedWithMeteredMinimumConfig && + groupingKey == other.groupingKey && + minimumUnitAmount == other.minimumUnitAmount && + pricingKey == other.pricingKey && + scalingFactors == other.scalingFactors && + scalingKey == other.scalingKey && + unitAmounts == other.unitAmounts && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + private val hashCode: Int by lazy { + Objects.hash( + groupingKey, + minimumUnitAmount, + pricingKey, + scalingFactors, + scalingKey, + unitAmounts, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode override fun toString() = - "GroupedWithMeteredMinimumConfig{additionalProperties=$additionalProperties}" + "GroupedWithMeteredMinimumConfig{groupingKey=$groupingKey, minimumUnitAmount=$minimumUnitAmount, pricingKey=$pricingKey, scalingFactors=$scalingFactors, scalingKey=$scalingKey, unitAmounts=$unitAmounts, additionalProperties=$additionalProperties}" } + /** The pricing model type */ class ModelType @JsonCreator private constructor(private val value: JsonField) : Enum { /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanGroupedWithProratedMinimumPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanGroupedWithProratedMinimumPrice.kt index 0d648d2af..30a5bb14a 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanGroupedWithProratedMinimumPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanGroupedWithProratedMinimumPrice.kt @@ -119,6 +119,8 @@ private constructor( fun cadence(): Cadence = cadence.getRequired("cadence") /** + * Configuration for grouped_with_prorated_minimum pricing + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ @@ -134,6 +136,8 @@ private constructor( fun itemId(): String = itemId.getRequired("item_id") /** + * The pricing model type + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ @@ -520,6 +524,7 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + /** Configuration for grouped_with_prorated_minimum pricing */ fun groupedWithProratedMinimumConfig( groupedWithProratedMinimumConfig: GroupedWithProratedMinimumConfig ) = groupedWithProratedMinimumConfig(JsonField.of(groupedWithProratedMinimumConfig)) @@ -546,6 +551,7 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + /** The pricing model type */ fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) /** @@ -1106,16 +1112,82 @@ private constructor( override fun toString() = value.toString() } + /** Configuration for grouped_with_prorated_minimum pricing */ class GroupedWithProratedMinimumConfig - @JsonCreator private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map + private val groupingKey: JsonField, + private val minimum: JsonField, + private val unitRate: JsonField, + private val additionalProperties: MutableMap, ) { + @JsonCreator + private constructor( + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("minimum") @ExcludeMissing minimum: JsonField = JsonMissing.of(), + @JsonProperty("unit_rate") + @ExcludeMissing + unitRate: JsonField = JsonMissing.of(), + ) : this(groupingKey, minimum, unitRate, mutableMapOf()) + + /** + * How to determine the groups that should each have a minimum + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The minimum amount to charge per group + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun minimum(): String = minimum.getRequired("minimum") + + /** + * The amount to charge per unit + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun unitRate(): String = unitRate.getRequired("unit_rate") + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [minimum]. + * + * Unlike [minimum], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("minimum") @ExcludeMissing fun _minimum(): JsonField = minimum + + /** + * Returns the raw JSON value of [unitRate]. + * + * Unlike [unitRate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("unit_rate") @ExcludeMissing fun _unitRate(): JsonField = unitRate + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) fun toBuilder() = Builder().from(this) @@ -1124,6 +1196,13 @@ private constructor( /** * Returns a mutable builder for constructing an instance of * [GroupedWithProratedMinimumConfig]. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .minimum() + * .unitRate() + * ``` */ fun builder() = Builder() } @@ -1131,14 +1210,58 @@ private constructor( /** A builder for [GroupedWithProratedMinimumConfig]. */ class Builder internal constructor() { + private var groupingKey: JsonField? = null + private var minimum: JsonField? = null + private var unitRate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(groupedWithProratedMinimumConfig: GroupedWithProratedMinimumConfig) = apply { + groupingKey = groupedWithProratedMinimumConfig.groupingKey + minimum = groupedWithProratedMinimumConfig.minimum + unitRate = groupedWithProratedMinimumConfig.unitRate additionalProperties = groupedWithProratedMinimumConfig.additionalProperties.toMutableMap() } + /** How to determine the groups that should each have a minimum */ + fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The minimum amount to charge per group */ + fun minimum(minimum: String) = minimum(JsonField.of(minimum)) + + /** + * Sets [Builder.minimum] to an arbitrary JSON value. + * + * You should usually call [Builder.minimum] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun minimum(minimum: JsonField) = apply { this.minimum = minimum } + + /** The amount to charge per unit */ + fun unitRate(unitRate: String) = unitRate(JsonField.of(unitRate)) + + /** + * Sets [Builder.unitRate] to an arbitrary JSON value. + * + * You should usually call [Builder.unitRate] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun unitRate(unitRate: JsonField) = apply { this.unitRate = unitRate } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -1162,9 +1285,23 @@ private constructor( * Returns an immutable instance of [GroupedWithProratedMinimumConfig]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .minimum() + * .unitRate() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ fun build(): GroupedWithProratedMinimumConfig = - GroupedWithProratedMinimumConfig(additionalProperties.toImmutable()) + GroupedWithProratedMinimumConfig( + checkRequired("groupingKey", groupingKey), + checkRequired("minimum", minimum), + checkRequired("unitRate", unitRate), + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false @@ -1174,6 +1311,9 @@ private constructor( return@apply } + groupingKey() + minimum() + unitRate() validated = true } @@ -1192,7 +1332,9 @@ private constructor( * Used for best match union deserialization. */ internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + (if (groupingKey.asKnown() == null) 0 else 1) + + (if (minimum.asKnown() == null) 0 else 1) + + (if (unitRate.asKnown() == null) 0 else 1) override fun equals(other: Any?): Boolean { if (this === other) { @@ -1200,17 +1342,23 @@ private constructor( } return other is GroupedWithProratedMinimumConfig && + groupingKey == other.groupingKey && + minimum == other.minimum && + unitRate == other.unitRate && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + private val hashCode: Int by lazy { + Objects.hash(groupingKey, minimum, unitRate, additionalProperties) + } override fun hashCode(): Int = hashCode override fun toString() = - "GroupedWithProratedMinimumConfig{additionalProperties=$additionalProperties}" + "GroupedWithProratedMinimumConfig{groupingKey=$groupingKey, minimum=$minimum, unitRate=$unitRate, additionalProperties=$additionalProperties}" } + /** The pricing model type */ class ModelType @JsonCreator private constructor(private val value: JsonField) : Enum { /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanMatrixPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanMatrixPrice.kt index 661efba19..a3b83d4c1 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanMatrixPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanMatrixPrice.kt @@ -126,12 +126,16 @@ private constructor( fun itemId(): String = itemId.getRequired("item_id") /** + * Configuration for matrix pricing + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ fun matrixConfig(): MatrixConfig = matrixConfig.getRequired("matrix_config") /** + * The pricing model type + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ @@ -518,6 +522,7 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + /** Configuration for matrix pricing */ fun matrixConfig(matrixConfig: MatrixConfig) = matrixConfig(JsonField.of(matrixConfig)) /** @@ -531,6 +536,7 @@ private constructor( this.matrixConfig = matrixConfig } + /** The pricing model type */ fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) /** @@ -1091,6 +1097,7 @@ private constructor( override fun toString() = value.toString() } + /** The pricing model type */ class ModelType @JsonCreator private constructor(private val value: JsonField) : Enum { /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanMatrixWithAllocationPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanMatrixWithAllocationPrice.kt index 16f02371f..d266b1229 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanMatrixWithAllocationPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanMatrixWithAllocationPrice.kt @@ -126,6 +126,8 @@ private constructor( fun itemId(): String = itemId.getRequired("item_id") /** + * Configuration for matrix_with_allocation pricing + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ @@ -133,6 +135,8 @@ private constructor( matrixWithAllocationConfig.getRequired("matrix_with_allocation_config") /** + * The pricing model type + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ @@ -528,6 +532,7 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + /** Configuration for matrix_with_allocation pricing */ fun matrixWithAllocationConfig(matrixWithAllocationConfig: MatrixWithAllocationConfig) = matrixWithAllocationConfig(JsonField.of(matrixWithAllocationConfig)) @@ -542,6 +547,7 @@ private constructor( matrixWithAllocationConfig: JsonField ) = apply { this.matrixWithAllocationConfig = matrixWithAllocationConfig } + /** The pricing model type */ fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) /** @@ -1102,6 +1108,7 @@ private constructor( override fun toString() = value.toString() } + /** The pricing model type */ class ModelType @JsonCreator private constructor(private val value: JsonField) : Enum { /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanMatrixWithDisplayNamePrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanMatrixWithDisplayNamePrice.kt index 0c59c7801..ed312d182 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanMatrixWithDisplayNamePrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanMatrixWithDisplayNamePrice.kt @@ -11,6 +11,7 @@ import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue +import com.withorb.api.core.checkKnown import com.withorb.api.core.checkRequired import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException @@ -126,6 +127,8 @@ private constructor( fun itemId(): String = itemId.getRequired("item_id") /** + * Configuration for matrix_with_display_name pricing + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ @@ -133,6 +136,8 @@ private constructor( matrixWithDisplayNameConfig.getRequired("matrix_with_display_name_config") /** + * The pricing model type + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ @@ -528,6 +533,7 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + /** Configuration for matrix_with_display_name pricing */ fun matrixWithDisplayNameConfig(matrixWithDisplayNameConfig: MatrixWithDisplayNameConfig) = matrixWithDisplayNameConfig(JsonField.of(matrixWithDisplayNameConfig)) @@ -542,6 +548,7 @@ private constructor( matrixWithDisplayNameConfig: JsonField ) = apply { this.matrixWithDisplayNameConfig = matrixWithDisplayNameConfig } + /** The pricing model type */ fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) /** @@ -1102,16 +1109,65 @@ private constructor( override fun toString() = value.toString() } + /** Configuration for matrix_with_display_name pricing */ class MatrixWithDisplayNameConfig - @JsonCreator private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map + private val dimension: JsonField, + private val unitAmounts: JsonField>, + private val additionalProperties: MutableMap, ) { + @JsonCreator + private constructor( + @JsonProperty("dimension") + @ExcludeMissing + dimension: JsonField = JsonMissing.of(), + @JsonProperty("unit_amounts") + @ExcludeMissing + unitAmounts: JsonField> = JsonMissing.of(), + ) : this(dimension, unitAmounts, mutableMapOf()) + + /** + * Used to determine the unit rate + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun dimension(): String = dimension.getRequired("dimension") + + /** + * Apply per unit pricing to each dimension value + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun unitAmounts(): List = unitAmounts.getRequired("unit_amounts") + + /** + * Returns the raw JSON value of [dimension]. + * + * Unlike [dimension], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("dimension") @ExcludeMissing fun _dimension(): JsonField = dimension + + /** + * Returns the raw JSON value of [unitAmounts]. + * + * Unlike [unitAmounts], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("unit_amounts") + @ExcludeMissing + fun _unitAmounts(): JsonField> = unitAmounts + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) fun toBuilder() = Builder().from(this) @@ -1120,6 +1176,12 @@ private constructor( /** * Returns a mutable builder for constructing an instance of * [MatrixWithDisplayNameConfig]. + * + * The following fields are required: + * ```kotlin + * .dimension() + * .unitAmounts() + * ``` */ fun builder() = Builder() } @@ -1127,13 +1189,55 @@ private constructor( /** A builder for [MatrixWithDisplayNameConfig]. */ class Builder internal constructor() { + private var dimension: JsonField? = null + private var unitAmounts: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(matrixWithDisplayNameConfig: MatrixWithDisplayNameConfig) = apply { + dimension = matrixWithDisplayNameConfig.dimension + unitAmounts = matrixWithDisplayNameConfig.unitAmounts.map { it.toMutableList() } additionalProperties = matrixWithDisplayNameConfig.additionalProperties.toMutableMap() } + /** Used to determine the unit rate */ + fun dimension(dimension: String) = dimension(JsonField.of(dimension)) + + /** + * Sets [Builder.dimension] to an arbitrary JSON value. + * + * You should usually call [Builder.dimension] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun dimension(dimension: JsonField) = apply { this.dimension = dimension } + + /** Apply per unit pricing to each dimension value */ + fun unitAmounts(unitAmounts: List) = unitAmounts(JsonField.of(unitAmounts)) + + /** + * Sets [Builder.unitAmounts] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmounts] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun unitAmounts(unitAmounts: JsonField>) = apply { + this.unitAmounts = unitAmounts.map { it.toMutableList() } + } + + /** + * Adds a single [UnitAmount] to [unitAmounts]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addUnitAmount(unitAmount: UnitAmount) = apply { + unitAmounts = + (unitAmounts ?: JsonField.of(mutableListOf())).also { + checkKnown("unitAmounts", it).add(unitAmount) + } + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -1157,9 +1261,21 @@ private constructor( * Returns an immutable instance of [MatrixWithDisplayNameConfig]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .dimension() + * .unitAmounts() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ fun build(): MatrixWithDisplayNameConfig = - MatrixWithDisplayNameConfig(additionalProperties.toImmutable()) + MatrixWithDisplayNameConfig( + checkRequired("dimension", dimension), + checkRequired("unitAmounts", unitAmounts).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false @@ -1169,6 +1285,8 @@ private constructor( return@apply } + dimension() + unitAmounts().forEach { it.validate() } validated = true } @@ -1187,7 +1305,271 @@ private constructor( * Used for best match union deserialization. */ internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + (if (dimension.asKnown() == null) 0 else 1) + + (unitAmounts.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a unit amount item */ + class UnitAmount + private constructor( + private val dimensionValue: JsonField, + private val displayName: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("dimension_value") + @ExcludeMissing + dimensionValue: JsonField = JsonMissing.of(), + @JsonProperty("display_name") + @ExcludeMissing + displayName: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(dimensionValue, displayName, unitAmount, mutableMapOf()) + + /** + * The dimension value + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun dimensionValue(): String = dimensionValue.getRequired("dimension_value") + + /** + * Display name for this dimension value + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun displayName(): String = displayName.getRequired("display_name") + + /** + * Per unit amount + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [dimensionValue]. + * + * Unlike [dimensionValue], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("dimension_value") + @ExcludeMissing + fun _dimensionValue(): JsonField = dimensionValue + + /** + * Returns the raw JSON value of [displayName]. + * + * Unlike [displayName], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("display_name") + @ExcludeMissing + fun _displayName(): JsonField = displayName + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [UnitAmount]. + * + * The following fields are required: + * ```kotlin + * .dimensionValue() + * .displayName() + * .unitAmount() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [UnitAmount]. */ + class Builder internal constructor() { + + private var dimensionValue: JsonField? = null + private var displayName: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(unitAmount: UnitAmount) = apply { + dimensionValue = unitAmount.dimensionValue + displayName = unitAmount.displayName + this.unitAmount = unitAmount.unitAmount + additionalProperties = unitAmount.additionalProperties.toMutableMap() + } + + /** The dimension value */ + fun dimensionValue(dimensionValue: String) = + dimensionValue(JsonField.of(dimensionValue)) + + /** + * Sets [Builder.dimensionValue] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionValue] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun dimensionValue(dimensionValue: JsonField) = apply { + this.dimensionValue = dimensionValue + } + + /** Display name for this dimension value */ + fun displayName(displayName: String) = displayName(JsonField.of(displayName)) + + /** + * Sets [Builder.displayName] to an arbitrary JSON value. + * + * You should usually call [Builder.displayName] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun displayName(displayName: JsonField) = apply { + this.displayName = displayName + } + + /** Per unit amount */ + fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [UnitAmount]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .dimensionValue() + * .displayName() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UnitAmount = + UnitAmount( + checkRequired("dimensionValue", dimensionValue), + checkRequired("displayName", displayName), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UnitAmount = apply { + if (validated) { + return@apply + } + + dimensionValue() + displayName() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (dimensionValue.asKnown() == null) 0 else 1) + + (if (displayName.asKnown() == null) 0 else 1) + + (if (unitAmount.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnitAmount && + dimensionValue == other.dimensionValue && + displayName == other.displayName && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(dimensionValue, displayName, unitAmount, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UnitAmount{dimensionValue=$dimensionValue, displayName=$displayName, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } override fun equals(other: Any?): Boolean { if (this === other) { @@ -1195,17 +1577,22 @@ private constructor( } return other is MatrixWithDisplayNameConfig && + dimension == other.dimension && + unitAmounts == other.unitAmounts && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + private val hashCode: Int by lazy { + Objects.hash(dimension, unitAmounts, additionalProperties) + } override fun hashCode(): Int = hashCode override fun toString() = - "MatrixWithDisplayNameConfig{additionalProperties=$additionalProperties}" + "MatrixWithDisplayNameConfig{dimension=$dimension, unitAmounts=$unitAmounts, additionalProperties=$additionalProperties}" } + /** The pricing model type */ class ModelType @JsonCreator private constructor(private val value: JsonField) : Enum { /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanMaxGroupTieredPackagePrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanMaxGroupTieredPackagePrice.kt index 6db67a12b..df6fbdb54 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanMaxGroupTieredPackagePrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanMaxGroupTieredPackagePrice.kt @@ -11,6 +11,7 @@ import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue +import com.withorb.api.core.checkKnown import com.withorb.api.core.checkRequired import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException @@ -126,6 +127,8 @@ private constructor( fun itemId(): String = itemId.getRequired("item_id") /** + * Configuration for max_group_tiered_package pricing + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ @@ -133,6 +136,8 @@ private constructor( maxGroupTieredPackageConfig.getRequired("max_group_tiered_package_config") /** + * The pricing model type + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ @@ -528,6 +533,7 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + /** Configuration for max_group_tiered_package pricing */ fun maxGroupTieredPackageConfig(maxGroupTieredPackageConfig: MaxGroupTieredPackageConfig) = maxGroupTieredPackageConfig(JsonField.of(maxGroupTieredPackageConfig)) @@ -542,6 +548,7 @@ private constructor( maxGroupTieredPackageConfig: JsonField ) = apply { this.maxGroupTieredPackageConfig = maxGroupTieredPackageConfig } + /** The pricing model type */ fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) /** @@ -1102,16 +1109,84 @@ private constructor( override fun toString() = value.toString() } + /** Configuration for max_group_tiered_package pricing */ class MaxGroupTieredPackageConfig - @JsonCreator private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map + private val groupingKey: JsonField, + private val packageSize: JsonField, + private val tiers: JsonField>, + private val additionalProperties: MutableMap, ) { + @JsonCreator + private constructor( + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("package_size") + @ExcludeMissing + packageSize: JsonField = JsonMissing.of(), + @JsonProperty("tiers") @ExcludeMissing tiers: JsonField> = JsonMissing.of(), + ) : this(groupingKey, packageSize, tiers, mutableMapOf()) + + /** + * The event property used to group before tiering the group with the highest value + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * Package size + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun packageSize(): String = packageSize.getRequired("package_size") + + /** + * Apply tiered pricing to the largest group after grouping with the provided key. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun tiers(): List = tiers.getRequired("tiers") + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [packageSize]. + * + * Unlike [packageSize], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("package_size") + @ExcludeMissing + fun _packageSize(): JsonField = packageSize + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tiers") @ExcludeMissing fun _tiers(): JsonField> = tiers + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) fun toBuilder() = Builder().from(this) @@ -1120,6 +1195,13 @@ private constructor( /** * Returns a mutable builder for constructing an instance of * [MaxGroupTieredPackageConfig]. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .packageSize() + * .tiers() + * ``` */ fun builder() = Builder() } @@ -1127,13 +1209,73 @@ private constructor( /** A builder for [MaxGroupTieredPackageConfig]. */ class Builder internal constructor() { + private var groupingKey: JsonField? = null + private var packageSize: JsonField? = null + private var tiers: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(maxGroupTieredPackageConfig: MaxGroupTieredPackageConfig) = apply { + groupingKey = maxGroupTieredPackageConfig.groupingKey + packageSize = maxGroupTieredPackageConfig.packageSize + tiers = maxGroupTieredPackageConfig.tiers.map { it.toMutableList() } additionalProperties = maxGroupTieredPackageConfig.additionalProperties.toMutableMap() } + /** The event property used to group before tiering the group with the highest value */ + fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** Package size */ + fun packageSize(packageSize: String) = packageSize(JsonField.of(packageSize)) + + /** + * Sets [Builder.packageSize] to an arbitrary JSON value. + * + * You should usually call [Builder.packageSize] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun packageSize(packageSize: JsonField) = apply { + this.packageSize = packageSize + } + + /** Apply tiered pricing to the largest group after grouping with the provided key. */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -1157,9 +1299,23 @@ private constructor( * Returns an immutable instance of [MaxGroupTieredPackageConfig]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .packageSize() + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ fun build(): MaxGroupTieredPackageConfig = - MaxGroupTieredPackageConfig(additionalProperties.toImmutable()) + MaxGroupTieredPackageConfig( + checkRequired("groupingKey", groupingKey), + checkRequired("packageSize", packageSize), + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false @@ -1169,6 +1325,9 @@ private constructor( return@apply } + groupingKey() + packageSize() + tiers().forEach { it.validate() } validated = true } @@ -1187,7 +1346,227 @@ private constructor( * Used for best match union deserialization. */ internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + (if (groupingKey.asKnown() == null) 0 else 1) + + (if (packageSize.asKnown() == null) 0 else 1) + + (tiers.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single tier */ + class Tier + private constructor( + private val tierLowerBound: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(tierLowerBound, unitAmount, mutableMapOf()) + + /** + * Tier lower bound + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun tierLowerBound(): String = tierLowerBound.getRequired("tier_lower_bound") + + /** + * Per unit amount + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Tier]. + * + * The following fields are required: + * ```kotlin + * .tierLowerBound() + * .unitAmount() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var tierLowerBound: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(tier: Tier) = apply { + tierLowerBound = tier.tierLowerBound + unitAmount = tier.unitAmount + additionalProperties = tier.additionalProperties.toMutableMap() + } + + /** Tier lower bound */ + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + /** Per unit amount */ + fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Tier]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .tierLowerBound() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("tierLowerBound", tierLowerBound), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + tierLowerBound() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (tierLowerBound.asKnown() == null) 0 else 1) + + (if (unitAmount.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + tierLowerBound == other.tierLowerBound && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(tierLowerBound, unitAmount, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } override fun equals(other: Any?): Boolean { if (this === other) { @@ -1195,17 +1574,23 @@ private constructor( } return other is MaxGroupTieredPackageConfig && + groupingKey == other.groupingKey && + packageSize == other.packageSize && + tiers == other.tiers && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + private val hashCode: Int by lazy { + Objects.hash(groupingKey, packageSize, tiers, additionalProperties) + } override fun hashCode(): Int = hashCode override fun toString() = - "MaxGroupTieredPackageConfig{additionalProperties=$additionalProperties}" + "MaxGroupTieredPackageConfig{groupingKey=$groupingKey, packageSize=$packageSize, tiers=$tiers, additionalProperties=$additionalProperties}" } + /** The pricing model type */ class ModelType @JsonCreator private constructor(private val value: JsonField) : Enum { /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanMinimumCompositePrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanMinimumCompositePrice.kt index c99720957..0eecc0913 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanMinimumCompositePrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanMinimumCompositePrice.kt @@ -126,12 +126,16 @@ private constructor( fun itemId(): String = itemId.getRequired("item_id") /** + * Configuration for minimum pricing + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ fun minimumConfig(): MinimumConfig = minimumConfig.getRequired("minimum_config") /** + * The pricing model type + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ @@ -519,6 +523,7 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + /** Configuration for minimum pricing */ fun minimumConfig(minimumConfig: MinimumConfig) = minimumConfig(JsonField.of(minimumConfig)) /** @@ -532,6 +537,7 @@ private constructor( this.minimumConfig = minimumConfig } + /** The pricing model type */ fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) /** @@ -1092,6 +1098,7 @@ private constructor( override fun toString() = value.toString() } + /** Configuration for minimum pricing */ class MinimumConfig private constructor( private val minimumAmount: JsonField, @@ -1118,8 +1125,7 @@ private constructor( fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") /** - * By default, subtotals from minimum composite prices are prorated based on the service - * period. Set to false to disable proration. + * If true, subtotals from this price are prorated based on the service period * * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -1195,18 +1201,8 @@ private constructor( this.minimumAmount = minimumAmount } - /** - * By default, subtotals from minimum composite prices are prorated based on the service - * period. Set to false to disable proration. - */ - fun prorated(prorated: Boolean?) = prorated(JsonField.ofNullable(prorated)) - - /** - * Alias for [Builder.prorated]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun prorated(prorated: Boolean) = prorated(prorated as Boolean?) + /** If true, subtotals from this price are prorated based on the service period */ + fun prorated(prorated: Boolean) = prorated(JsonField.of(prorated)) /** * Sets [Builder.prorated] to an arbitrary JSON value. @@ -1307,6 +1303,7 @@ private constructor( "MinimumConfig{minimumAmount=$minimumAmount, prorated=$prorated, additionalProperties=$additionalProperties}" } + /** The pricing model type */ class ModelType @JsonCreator private constructor(private val value: JsonField) : Enum { /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanPackagePrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanPackagePrice.kt index 35a1795ff..42f613675 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanPackagePrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanPackagePrice.kt @@ -126,6 +126,8 @@ private constructor( fun itemId(): String = itemId.getRequired("item_id") /** + * The pricing model type + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ @@ -140,6 +142,8 @@ private constructor( fun name(): String = name.getRequired("name") /** + * Configuration for package pricing + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ @@ -518,6 +522,7 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + /** The pricing model type */ fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) /** @@ -540,6 +545,7 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } + /** Configuration for package pricing */ fun packageConfig(packageConfig: PackageConfig) = packageConfig(JsonField.of(packageConfig)) /** @@ -1091,6 +1097,7 @@ private constructor( override fun toString() = value.toString() } + /** The pricing model type */ class ModelType @JsonCreator private constructor(private val value: JsonField) : Enum { /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanPackageWithAllocationPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanPackageWithAllocationPrice.kt index 634948f22..9fc1505af 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanPackageWithAllocationPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanPackageWithAllocationPrice.kt @@ -126,6 +126,8 @@ private constructor( fun itemId(): String = itemId.getRequired("item_id") /** + * The pricing model type + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ @@ -140,6 +142,8 @@ private constructor( fun name(): String = name.getRequired("name") /** + * Configuration for package_with_allocation pricing + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ @@ -528,6 +532,7 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + /** The pricing model type */ fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) /** @@ -550,6 +555,7 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } + /** Configuration for package_with_allocation pricing */ fun packageWithAllocationConfig(packageWithAllocationConfig: PackageWithAllocationConfig) = packageWithAllocationConfig(JsonField.of(packageWithAllocationConfig)) @@ -1102,6 +1108,7 @@ private constructor( override fun toString() = value.toString() } + /** The pricing model type */ class ModelType @JsonCreator private constructor(private val value: JsonField) : Enum { /** @@ -1222,16 +1229,89 @@ private constructor( override fun toString() = value.toString() } + /** Configuration for package_with_allocation pricing */ class PackageWithAllocationConfig - @JsonCreator private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map + private val allocation: JsonField, + private val packageAmount: JsonField, + private val packageSize: JsonField, + private val additionalProperties: MutableMap, ) { + @JsonCreator + private constructor( + @JsonProperty("allocation") + @ExcludeMissing + allocation: JsonField = JsonMissing.of(), + @JsonProperty("package_amount") + @ExcludeMissing + packageAmount: JsonField = JsonMissing.of(), + @JsonProperty("package_size") + @ExcludeMissing + packageSize: JsonField = JsonMissing.of(), + ) : this(allocation, packageAmount, packageSize, mutableMapOf()) + + /** + * Usage allocation + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun allocation(): String = allocation.getRequired("allocation") + + /** + * Price per package + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun packageAmount(): String = packageAmount.getRequired("package_amount") + + /** + * Package size + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun packageSize(): String = packageSize.getRequired("package_size") + + /** + * Returns the raw JSON value of [allocation]. + * + * Unlike [allocation], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("allocation") + @ExcludeMissing + fun _allocation(): JsonField = allocation + + /** + * Returns the raw JSON value of [packageAmount]. + * + * Unlike [packageAmount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("package_amount") + @ExcludeMissing + fun _packageAmount(): JsonField = packageAmount + + /** + * Returns the raw JSON value of [packageSize]. + * + * Unlike [packageSize], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("package_size") + @ExcludeMissing + fun _packageSize(): JsonField = packageSize + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) fun toBuilder() = Builder().from(this) @@ -1240,6 +1320,13 @@ private constructor( /** * Returns a mutable builder for constructing an instance of * [PackageWithAllocationConfig]. + * + * The following fields are required: + * ```kotlin + * .allocation() + * .packageAmount() + * .packageSize() + * ``` */ fun builder() = Builder() } @@ -1247,13 +1334,59 @@ private constructor( /** A builder for [PackageWithAllocationConfig]. */ class Builder internal constructor() { + private var allocation: JsonField? = null + private var packageAmount: JsonField? = null + private var packageSize: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(packageWithAllocationConfig: PackageWithAllocationConfig) = apply { + allocation = packageWithAllocationConfig.allocation + packageAmount = packageWithAllocationConfig.packageAmount + packageSize = packageWithAllocationConfig.packageSize additionalProperties = packageWithAllocationConfig.additionalProperties.toMutableMap() } + /** Usage allocation */ + fun allocation(allocation: String) = allocation(JsonField.of(allocation)) + + /** + * Sets [Builder.allocation] to an arbitrary JSON value. + * + * You should usually call [Builder.allocation] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun allocation(allocation: JsonField) = apply { this.allocation = allocation } + + /** Price per package */ + fun packageAmount(packageAmount: String) = packageAmount(JsonField.of(packageAmount)) + + /** + * Sets [Builder.packageAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.packageAmount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun packageAmount(packageAmount: JsonField) = apply { + this.packageAmount = packageAmount + } + + /** Package size */ + fun packageSize(packageSize: String) = packageSize(JsonField.of(packageSize)) + + /** + * Sets [Builder.packageSize] to an arbitrary JSON value. + * + * You should usually call [Builder.packageSize] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun packageSize(packageSize: JsonField) = apply { + this.packageSize = packageSize + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -1277,9 +1410,23 @@ private constructor( * Returns an immutable instance of [PackageWithAllocationConfig]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .allocation() + * .packageAmount() + * .packageSize() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ fun build(): PackageWithAllocationConfig = - PackageWithAllocationConfig(additionalProperties.toImmutable()) + PackageWithAllocationConfig( + checkRequired("allocation", allocation), + checkRequired("packageAmount", packageAmount), + checkRequired("packageSize", packageSize), + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false @@ -1289,6 +1436,9 @@ private constructor( return@apply } + allocation() + packageAmount() + packageSize() validated = true } @@ -1307,7 +1457,9 @@ private constructor( * Used for best match union deserialization. */ internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + (if (allocation.asKnown() == null) 0 else 1) + + (if (packageAmount.asKnown() == null) 0 else 1) + + (if (packageSize.asKnown() == null) 0 else 1) override fun equals(other: Any?): Boolean { if (this === other) { @@ -1315,15 +1467,20 @@ private constructor( } return other is PackageWithAllocationConfig && + allocation == other.allocation && + packageAmount == other.packageAmount && + packageSize == other.packageSize && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + private val hashCode: Int by lazy { + Objects.hash(allocation, packageAmount, packageSize, additionalProperties) + } override fun hashCode(): Int = hashCode override fun toString() = - "PackageWithAllocationConfig{additionalProperties=$additionalProperties}" + "PackageWithAllocationConfig{allocation=$allocation, packageAmount=$packageAmount, packageSize=$packageSize, additionalProperties=$additionalProperties}" } /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanScalableMatrixWithTieredPricingPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanScalableMatrixWithTieredPricingPrice.kt index ef3604f00..754ade139 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanScalableMatrixWithTieredPricingPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanScalableMatrixWithTieredPricingPrice.kt @@ -11,6 +11,7 @@ import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue +import com.withorb.api.core.checkKnown import com.withorb.api.core.checkRequired import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException @@ -128,6 +129,8 @@ private constructor( fun itemId(): String = itemId.getRequired("item_id") /** + * The pricing model type + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ @@ -142,6 +145,8 @@ private constructor( fun name(): String = name.getRequired("name") /** + * Configuration for scalable_matrix_with_tiered_pricing pricing + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ @@ -535,6 +540,7 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + /** The pricing model type */ fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) /** @@ -557,6 +563,7 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } + /** Configuration for scalable_matrix_with_tiered_pricing pricing */ fun scalableMatrixWithTieredPricingConfig( scalableMatrixWithTieredPricingConfig: ScalableMatrixWithTieredPricingConfig ) = @@ -1118,6 +1125,7 @@ private constructor( override fun toString() = value.toString() } + /** The pricing model type */ class ModelType @JsonCreator private constructor(private val value: JsonField) : Enum { /** @@ -1238,16 +1246,109 @@ private constructor( override fun toString() = value.toString() } + /** Configuration for scalable_matrix_with_tiered_pricing pricing */ class ScalableMatrixWithTieredPricingConfig - @JsonCreator private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map + private val firstDimension: JsonField, + private val matrixScalingFactors: JsonField>, + private val tiers: JsonField>, + private val secondDimension: JsonField, + private val additionalProperties: MutableMap, ) { + @JsonCreator + private constructor( + @JsonProperty("first_dimension") + @ExcludeMissing + firstDimension: JsonField = JsonMissing.of(), + @JsonProperty("matrix_scaling_factors") + @ExcludeMissing + matrixScalingFactors: JsonField> = JsonMissing.of(), + @JsonProperty("tiers") @ExcludeMissing tiers: JsonField> = JsonMissing.of(), + @JsonProperty("second_dimension") + @ExcludeMissing + secondDimension: JsonField = JsonMissing.of(), + ) : this(firstDimension, matrixScalingFactors, tiers, secondDimension, mutableMapOf()) + + /** + * Used for the scalable matrix first dimension + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun firstDimension(): String = firstDimension.getRequired("first_dimension") + + /** + * Apply a scaling factor to each dimension + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun matrixScalingFactors(): List = + matrixScalingFactors.getRequired("matrix_scaling_factors") + + /** + * Tier pricing structure + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun tiers(): List = tiers.getRequired("tiers") + + /** + * Used for the scalable matrix second dimension (optional) + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun secondDimension(): String? = secondDimension.getNullable("second_dimension") + + /** + * Returns the raw JSON value of [firstDimension]. + * + * Unlike [firstDimension], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("first_dimension") + @ExcludeMissing + fun _firstDimension(): JsonField = firstDimension + + /** + * Returns the raw JSON value of [matrixScalingFactors]. + * + * Unlike [matrixScalingFactors], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("matrix_scaling_factors") + @ExcludeMissing + fun _matrixScalingFactors(): JsonField> = matrixScalingFactors + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tiers") @ExcludeMissing fun _tiers(): JsonField> = tiers + + /** + * Returns the raw JSON value of [secondDimension]. + * + * Unlike [secondDimension], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("second_dimension") + @ExcludeMissing + fun _secondDimension(): JsonField = secondDimension + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) fun toBuilder() = Builder().from(this) @@ -1256,6 +1357,13 @@ private constructor( /** * Returns a mutable builder for constructing an instance of * [ScalableMatrixWithTieredPricingConfig]. + * + * The following fields are required: + * ```kotlin + * .firstDimension() + * .matrixScalingFactors() + * .tiers() + * ``` */ fun builder() = Builder() } @@ -1263,15 +1371,110 @@ private constructor( /** A builder for [ScalableMatrixWithTieredPricingConfig]. */ class Builder internal constructor() { + private var firstDimension: JsonField? = null + private var matrixScalingFactors: JsonField>? = null + private var tiers: JsonField>? = null + private var secondDimension: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() internal fun from( scalableMatrixWithTieredPricingConfig: ScalableMatrixWithTieredPricingConfig ) = apply { + firstDimension = scalableMatrixWithTieredPricingConfig.firstDimension + matrixScalingFactors = + scalableMatrixWithTieredPricingConfig.matrixScalingFactors.map { + it.toMutableList() + } + tiers = scalableMatrixWithTieredPricingConfig.tiers.map { it.toMutableList() } + secondDimension = scalableMatrixWithTieredPricingConfig.secondDimension additionalProperties = scalableMatrixWithTieredPricingConfig.additionalProperties.toMutableMap() } + /** Used for the scalable matrix first dimension */ + fun firstDimension(firstDimension: String) = + firstDimension(JsonField.of(firstDimension)) + + /** + * Sets [Builder.firstDimension] to an arbitrary JSON value. + * + * You should usually call [Builder.firstDimension] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun firstDimension(firstDimension: JsonField) = apply { + this.firstDimension = firstDimension + } + + /** Apply a scaling factor to each dimension */ + fun matrixScalingFactors(matrixScalingFactors: List) = + matrixScalingFactors(JsonField.of(matrixScalingFactors)) + + /** + * Sets [Builder.matrixScalingFactors] to an arbitrary JSON value. + * + * You should usually call [Builder.matrixScalingFactors] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun matrixScalingFactors(matrixScalingFactors: JsonField>) = + apply { + this.matrixScalingFactors = matrixScalingFactors.map { it.toMutableList() } + } + + /** + * Adds a single [MatrixScalingFactor] to [matrixScalingFactors]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addMatrixScalingFactor(matrixScalingFactor: MatrixScalingFactor) = apply { + matrixScalingFactors = + (matrixScalingFactors ?: JsonField.of(mutableListOf())).also { + checkKnown("matrixScalingFactors", it).add(matrixScalingFactor) + } + } + + /** Tier pricing structure */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + + /** Used for the scalable matrix second dimension (optional) */ + fun secondDimension(secondDimension: String?) = + secondDimension(JsonField.ofNullable(secondDimension)) + + /** + * Sets [Builder.secondDimension] to an arbitrary JSON value. + * + * You should usually call [Builder.secondDimension] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun secondDimension(secondDimension: JsonField) = apply { + this.secondDimension = secondDimension + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -1295,9 +1498,26 @@ private constructor( * Returns an immutable instance of [ScalableMatrixWithTieredPricingConfig]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .firstDimension() + * .matrixScalingFactors() + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ fun build(): ScalableMatrixWithTieredPricingConfig = - ScalableMatrixWithTieredPricingConfig(additionalProperties.toImmutable()) + ScalableMatrixWithTieredPricingConfig( + checkRequired("firstDimension", firstDimension), + checkRequired("matrixScalingFactors", matrixScalingFactors).map { + it.toImmutable() + }, + checkRequired("tiers", tiers).map { it.toImmutable() }, + secondDimension, + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false @@ -1307,6 +1527,10 @@ private constructor( return@apply } + firstDimension() + matrixScalingFactors().forEach { it.validate() } + tiers().forEach { it.validate() } + secondDimension() validated = true } @@ -1325,7 +1549,497 @@ private constructor( * Used for best match union deserialization. */ internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + (if (firstDimension.asKnown() == null) 0 else 1) + + (matrixScalingFactors.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + (tiers.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + (if (secondDimension.asKnown() == null) 0 else 1) + + /** Configuration for a single matrix scaling factor */ + class MatrixScalingFactor + private constructor( + private val firstDimensionValue: JsonField, + private val scalingFactor: JsonField, + private val secondDimensionValue: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("first_dimension_value") + @ExcludeMissing + firstDimensionValue: JsonField = JsonMissing.of(), + @JsonProperty("scaling_factor") + @ExcludeMissing + scalingFactor: JsonField = JsonMissing.of(), + @JsonProperty("second_dimension_value") + @ExcludeMissing + secondDimensionValue: JsonField = JsonMissing.of(), + ) : this(firstDimensionValue, scalingFactor, secondDimensionValue, mutableMapOf()) + + /** + * First dimension value + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun firstDimensionValue(): String = + firstDimensionValue.getRequired("first_dimension_value") + + /** + * Scaling factor + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun scalingFactor(): String = scalingFactor.getRequired("scaling_factor") + + /** + * Second dimension value (optional) + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun secondDimensionValue(): String? = + secondDimensionValue.getNullable("second_dimension_value") + + /** + * Returns the raw JSON value of [firstDimensionValue]. + * + * Unlike [firstDimensionValue], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("first_dimension_value") + @ExcludeMissing + fun _firstDimensionValue(): JsonField = firstDimensionValue + + /** + * Returns the raw JSON value of [scalingFactor]. + * + * Unlike [scalingFactor], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("scaling_factor") + @ExcludeMissing + fun _scalingFactor(): JsonField = scalingFactor + + /** + * Returns the raw JSON value of [secondDimensionValue]. + * + * Unlike [secondDimensionValue], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("second_dimension_value") + @ExcludeMissing + fun _secondDimensionValue(): JsonField = secondDimensionValue + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [MatrixScalingFactor]. + * + * The following fields are required: + * ```kotlin + * .firstDimensionValue() + * .scalingFactor() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [MatrixScalingFactor]. */ + class Builder internal constructor() { + + private var firstDimensionValue: JsonField? = null + private var scalingFactor: JsonField? = null + private var secondDimensionValue: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(matrixScalingFactor: MatrixScalingFactor) = apply { + firstDimensionValue = matrixScalingFactor.firstDimensionValue + scalingFactor = matrixScalingFactor.scalingFactor + secondDimensionValue = matrixScalingFactor.secondDimensionValue + additionalProperties = matrixScalingFactor.additionalProperties.toMutableMap() + } + + /** First dimension value */ + fun firstDimensionValue(firstDimensionValue: String) = + firstDimensionValue(JsonField.of(firstDimensionValue)) + + /** + * Sets [Builder.firstDimensionValue] to an arbitrary JSON value. + * + * You should usually call [Builder.firstDimensionValue] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun firstDimensionValue(firstDimensionValue: JsonField) = apply { + this.firstDimensionValue = firstDimensionValue + } + + /** Scaling factor */ + fun scalingFactor(scalingFactor: String) = + scalingFactor(JsonField.of(scalingFactor)) + + /** + * Sets [Builder.scalingFactor] to an arbitrary JSON value. + * + * You should usually call [Builder.scalingFactor] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun scalingFactor(scalingFactor: JsonField) = apply { + this.scalingFactor = scalingFactor + } + + /** Second dimension value (optional) */ + fun secondDimensionValue(secondDimensionValue: String?) = + secondDimensionValue(JsonField.ofNullable(secondDimensionValue)) + + /** + * Sets [Builder.secondDimensionValue] to an arbitrary JSON value. + * + * You should usually call [Builder.secondDimensionValue] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun secondDimensionValue(secondDimensionValue: JsonField) = apply { + this.secondDimensionValue = secondDimensionValue + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [MatrixScalingFactor]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .firstDimensionValue() + * .scalingFactor() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MatrixScalingFactor = + MatrixScalingFactor( + checkRequired("firstDimensionValue", firstDimensionValue), + checkRequired("scalingFactor", scalingFactor), + secondDimensionValue, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MatrixScalingFactor = apply { + if (validated) { + return@apply + } + + firstDimensionValue() + scalingFactor() + secondDimensionValue() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (firstDimensionValue.asKnown() == null) 0 else 1) + + (if (scalingFactor.asKnown() == null) 0 else 1) + + (if (secondDimensionValue.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MatrixScalingFactor && + firstDimensionValue == other.firstDimensionValue && + scalingFactor == other.scalingFactor && + secondDimensionValue == other.secondDimensionValue && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + firstDimensionValue, + scalingFactor, + secondDimensionValue, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MatrixScalingFactor{firstDimensionValue=$firstDimensionValue, scalingFactor=$scalingFactor, secondDimensionValue=$secondDimensionValue, additionalProperties=$additionalProperties}" + } + + /** Configuration for a single tier entry with business logic */ + class Tier + private constructor( + private val tierLowerBound: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(tierLowerBound, unitAmount, mutableMapOf()) + + /** + * Tier lower bound + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun tierLowerBound(): String = tierLowerBound.getRequired("tier_lower_bound") + + /** + * Per unit amount + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Tier]. + * + * The following fields are required: + * ```kotlin + * .tierLowerBound() + * .unitAmount() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var tierLowerBound: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(tier: Tier) = apply { + tierLowerBound = tier.tierLowerBound + unitAmount = tier.unitAmount + additionalProperties = tier.additionalProperties.toMutableMap() + } + + /** Tier lower bound */ + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + /** Per unit amount */ + fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Tier]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .tierLowerBound() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("tierLowerBound", tierLowerBound), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + tierLowerBound() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (tierLowerBound.asKnown() == null) 0 else 1) + + (if (unitAmount.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + tierLowerBound == other.tierLowerBound && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(tierLowerBound, unitAmount, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } override fun equals(other: Any?): Boolean { if (this === other) { @@ -1333,15 +2047,27 @@ private constructor( } return other is ScalableMatrixWithTieredPricingConfig && + firstDimension == other.firstDimension && + matrixScalingFactors == other.matrixScalingFactors && + tiers == other.tiers && + secondDimension == other.secondDimension && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + private val hashCode: Int by lazy { + Objects.hash( + firstDimension, + matrixScalingFactors, + tiers, + secondDimension, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode override fun toString() = - "ScalableMatrixWithTieredPricingConfig{additionalProperties=$additionalProperties}" + "ScalableMatrixWithTieredPricingConfig{firstDimension=$firstDimension, matrixScalingFactors=$matrixScalingFactors, tiers=$tiers, secondDimension=$secondDimension, additionalProperties=$additionalProperties}" } /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanScalableMatrixWithUnitPricingPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanScalableMatrixWithUnitPricingPrice.kt index 7aaf64ca6..32d04d426 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanScalableMatrixWithUnitPricingPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanScalableMatrixWithUnitPricingPrice.kt @@ -11,6 +11,7 @@ import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue +import com.withorb.api.core.checkKnown import com.withorb.api.core.checkRequired import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException @@ -127,6 +128,8 @@ private constructor( fun itemId(): String = itemId.getRequired("item_id") /** + * The pricing model type + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ @@ -141,6 +144,8 @@ private constructor( fun name(): String = name.getRequired("name") /** + * Configuration for scalable_matrix_with_unit_pricing pricing + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ @@ -532,6 +537,7 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + /** The pricing model type */ fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) /** @@ -554,6 +560,7 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } + /** Configuration for scalable_matrix_with_unit_pricing pricing */ fun scalableMatrixWithUnitPricingConfig( scalableMatrixWithUnitPricingConfig: ScalableMatrixWithUnitPricingConfig ) = scalableMatrixWithUnitPricingConfig(JsonField.of(scalableMatrixWithUnitPricingConfig)) @@ -1110,6 +1117,7 @@ private constructor( override fun toString() = value.toString() } + /** The pricing model type */ class ModelType @JsonCreator private constructor(private val value: JsonField) : Enum { /** @@ -1230,16 +1238,135 @@ private constructor( override fun toString() = value.toString() } + /** Configuration for scalable_matrix_with_unit_pricing pricing */ class ScalableMatrixWithUnitPricingConfig - @JsonCreator private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map + private val firstDimension: JsonField, + private val matrixScalingFactors: JsonField>, + private val unitPrice: JsonField, + private val prorate: JsonField, + private val secondDimension: JsonField, + private val additionalProperties: MutableMap, ) { + @JsonCreator + private constructor( + @JsonProperty("first_dimension") + @ExcludeMissing + firstDimension: JsonField = JsonMissing.of(), + @JsonProperty("matrix_scaling_factors") + @ExcludeMissing + matrixScalingFactors: JsonField> = JsonMissing.of(), + @JsonProperty("unit_price") + @ExcludeMissing + unitPrice: JsonField = JsonMissing.of(), + @JsonProperty("prorate") @ExcludeMissing prorate: JsonField = JsonMissing.of(), + @JsonProperty("second_dimension") + @ExcludeMissing + secondDimension: JsonField = JsonMissing.of(), + ) : this( + firstDimension, + matrixScalingFactors, + unitPrice, + prorate, + secondDimension, + mutableMapOf(), + ) + + /** + * Used to determine the unit rate + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun firstDimension(): String = firstDimension.getRequired("first_dimension") + + /** + * Apply a scaling factor to each dimension + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun matrixScalingFactors(): List = + matrixScalingFactors.getRequired("matrix_scaling_factors") + + /** + * The final unit price to rate against the output of the matrix + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun unitPrice(): String = unitPrice.getRequired("unit_price") + + /** + * If true, the unit price will be prorated to the billing period + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun prorate(): Boolean? = prorate.getNullable("prorate") + + /** + * Used to determine the unit rate (optional) + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun secondDimension(): String? = secondDimension.getNullable("second_dimension") + + /** + * Returns the raw JSON value of [firstDimension]. + * + * Unlike [firstDimension], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("first_dimension") + @ExcludeMissing + fun _firstDimension(): JsonField = firstDimension + + /** + * Returns the raw JSON value of [matrixScalingFactors]. + * + * Unlike [matrixScalingFactors], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("matrix_scaling_factors") + @ExcludeMissing + fun _matrixScalingFactors(): JsonField> = matrixScalingFactors + + /** + * Returns the raw JSON value of [unitPrice]. + * + * Unlike [unitPrice], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("unit_price") @ExcludeMissing fun _unitPrice(): JsonField = unitPrice + + /** + * Returns the raw JSON value of [prorate]. + * + * Unlike [prorate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("prorate") @ExcludeMissing fun _prorate(): JsonField = prorate + + /** + * Returns the raw JSON value of [secondDimension]. + * + * Unlike [secondDimension], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("second_dimension") + @ExcludeMissing + fun _secondDimension(): JsonField = secondDimension + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) fun toBuilder() = Builder().from(this) @@ -1248,6 +1375,13 @@ private constructor( /** * Returns a mutable builder for constructing an instance of * [ScalableMatrixWithUnitPricingConfig]. + * + * The following fields are required: + * ```kotlin + * .firstDimension() + * .matrixScalingFactors() + * .unitPrice() + * ``` */ fun builder() = Builder() } @@ -1255,15 +1389,117 @@ private constructor( /** A builder for [ScalableMatrixWithUnitPricingConfig]. */ class Builder internal constructor() { + private var firstDimension: JsonField? = null + private var matrixScalingFactors: JsonField>? = null + private var unitPrice: JsonField? = null + private var prorate: JsonField = JsonMissing.of() + private var secondDimension: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() internal fun from( scalableMatrixWithUnitPricingConfig: ScalableMatrixWithUnitPricingConfig ) = apply { + firstDimension = scalableMatrixWithUnitPricingConfig.firstDimension + matrixScalingFactors = + scalableMatrixWithUnitPricingConfig.matrixScalingFactors.map { + it.toMutableList() + } + unitPrice = scalableMatrixWithUnitPricingConfig.unitPrice + prorate = scalableMatrixWithUnitPricingConfig.prorate + secondDimension = scalableMatrixWithUnitPricingConfig.secondDimension additionalProperties = scalableMatrixWithUnitPricingConfig.additionalProperties.toMutableMap() } + /** Used to determine the unit rate */ + fun firstDimension(firstDimension: String) = + firstDimension(JsonField.of(firstDimension)) + + /** + * Sets [Builder.firstDimension] to an arbitrary JSON value. + * + * You should usually call [Builder.firstDimension] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun firstDimension(firstDimension: JsonField) = apply { + this.firstDimension = firstDimension + } + + /** Apply a scaling factor to each dimension */ + fun matrixScalingFactors(matrixScalingFactors: List) = + matrixScalingFactors(JsonField.of(matrixScalingFactors)) + + /** + * Sets [Builder.matrixScalingFactors] to an arbitrary JSON value. + * + * You should usually call [Builder.matrixScalingFactors] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun matrixScalingFactors(matrixScalingFactors: JsonField>) = + apply { + this.matrixScalingFactors = matrixScalingFactors.map { it.toMutableList() } + } + + /** + * Adds a single [MatrixScalingFactor] to [matrixScalingFactors]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addMatrixScalingFactor(matrixScalingFactor: MatrixScalingFactor) = apply { + matrixScalingFactors = + (matrixScalingFactors ?: JsonField.of(mutableListOf())).also { + checkKnown("matrixScalingFactors", it).add(matrixScalingFactor) + } + } + + /** The final unit price to rate against the output of the matrix */ + fun unitPrice(unitPrice: String) = unitPrice(JsonField.of(unitPrice)) + + /** + * Sets [Builder.unitPrice] to an arbitrary JSON value. + * + * You should usually call [Builder.unitPrice] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun unitPrice(unitPrice: JsonField) = apply { this.unitPrice = unitPrice } + + /** If true, the unit price will be prorated to the billing period */ + fun prorate(prorate: Boolean?) = prorate(JsonField.ofNullable(prorate)) + + /** + * Alias for [Builder.prorate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun prorate(prorate: Boolean) = prorate(prorate as Boolean?) + + /** + * Sets [Builder.prorate] to an arbitrary JSON value. + * + * You should usually call [Builder.prorate] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun prorate(prorate: JsonField) = apply { this.prorate = prorate } + + /** Used to determine the unit rate (optional) */ + fun secondDimension(secondDimension: String?) = + secondDimension(JsonField.ofNullable(secondDimension)) + + /** + * Sets [Builder.secondDimension] to an arbitrary JSON value. + * + * You should usually call [Builder.secondDimension] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun secondDimension(secondDimension: JsonField) = apply { + this.secondDimension = secondDimension + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -1287,9 +1523,27 @@ private constructor( * Returns an immutable instance of [ScalableMatrixWithUnitPricingConfig]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .firstDimension() + * .matrixScalingFactors() + * .unitPrice() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ fun build(): ScalableMatrixWithUnitPricingConfig = - ScalableMatrixWithUnitPricingConfig(additionalProperties.toImmutable()) + ScalableMatrixWithUnitPricingConfig( + checkRequired("firstDimension", firstDimension), + checkRequired("matrixScalingFactors", matrixScalingFactors).map { + it.toImmutable() + }, + checkRequired("unitPrice", unitPrice), + prorate, + secondDimension, + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false @@ -1299,6 +1553,11 @@ private constructor( return@apply } + firstDimension() + matrixScalingFactors().forEach { it.validate() } + unitPrice() + prorate() + secondDimension() validated = true } @@ -1317,7 +1576,280 @@ private constructor( * Used for best match union deserialization. */ internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + (if (firstDimension.asKnown() == null) 0 else 1) + + (matrixScalingFactors.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + (if (unitPrice.asKnown() == null) 0 else 1) + + (if (prorate.asKnown() == null) 0 else 1) + + (if (secondDimension.asKnown() == null) 0 else 1) + + /** Configuration for a single matrix scaling factor */ + class MatrixScalingFactor + private constructor( + private val firstDimensionValue: JsonField, + private val scalingFactor: JsonField, + private val secondDimensionValue: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("first_dimension_value") + @ExcludeMissing + firstDimensionValue: JsonField = JsonMissing.of(), + @JsonProperty("scaling_factor") + @ExcludeMissing + scalingFactor: JsonField = JsonMissing.of(), + @JsonProperty("second_dimension_value") + @ExcludeMissing + secondDimensionValue: JsonField = JsonMissing.of(), + ) : this(firstDimensionValue, scalingFactor, secondDimensionValue, mutableMapOf()) + + /** + * First dimension value + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun firstDimensionValue(): String = + firstDimensionValue.getRequired("first_dimension_value") + + /** + * Scaling factor + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun scalingFactor(): String = scalingFactor.getRequired("scaling_factor") + + /** + * Second dimension value (optional) + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun secondDimensionValue(): String? = + secondDimensionValue.getNullable("second_dimension_value") + + /** + * Returns the raw JSON value of [firstDimensionValue]. + * + * Unlike [firstDimensionValue], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("first_dimension_value") + @ExcludeMissing + fun _firstDimensionValue(): JsonField = firstDimensionValue + + /** + * Returns the raw JSON value of [scalingFactor]. + * + * Unlike [scalingFactor], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("scaling_factor") + @ExcludeMissing + fun _scalingFactor(): JsonField = scalingFactor + + /** + * Returns the raw JSON value of [secondDimensionValue]. + * + * Unlike [secondDimensionValue], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("second_dimension_value") + @ExcludeMissing + fun _secondDimensionValue(): JsonField = secondDimensionValue + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [MatrixScalingFactor]. + * + * The following fields are required: + * ```kotlin + * .firstDimensionValue() + * .scalingFactor() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [MatrixScalingFactor]. */ + class Builder internal constructor() { + + private var firstDimensionValue: JsonField? = null + private var scalingFactor: JsonField? = null + private var secondDimensionValue: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(matrixScalingFactor: MatrixScalingFactor) = apply { + firstDimensionValue = matrixScalingFactor.firstDimensionValue + scalingFactor = matrixScalingFactor.scalingFactor + secondDimensionValue = matrixScalingFactor.secondDimensionValue + additionalProperties = matrixScalingFactor.additionalProperties.toMutableMap() + } + + /** First dimension value */ + fun firstDimensionValue(firstDimensionValue: String) = + firstDimensionValue(JsonField.of(firstDimensionValue)) + + /** + * Sets [Builder.firstDimensionValue] to an arbitrary JSON value. + * + * You should usually call [Builder.firstDimensionValue] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun firstDimensionValue(firstDimensionValue: JsonField) = apply { + this.firstDimensionValue = firstDimensionValue + } + + /** Scaling factor */ + fun scalingFactor(scalingFactor: String) = + scalingFactor(JsonField.of(scalingFactor)) + + /** + * Sets [Builder.scalingFactor] to an arbitrary JSON value. + * + * You should usually call [Builder.scalingFactor] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun scalingFactor(scalingFactor: JsonField) = apply { + this.scalingFactor = scalingFactor + } + + /** Second dimension value (optional) */ + fun secondDimensionValue(secondDimensionValue: String?) = + secondDimensionValue(JsonField.ofNullable(secondDimensionValue)) + + /** + * Sets [Builder.secondDimensionValue] to an arbitrary JSON value. + * + * You should usually call [Builder.secondDimensionValue] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun secondDimensionValue(secondDimensionValue: JsonField) = apply { + this.secondDimensionValue = secondDimensionValue + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [MatrixScalingFactor]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .firstDimensionValue() + * .scalingFactor() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MatrixScalingFactor = + MatrixScalingFactor( + checkRequired("firstDimensionValue", firstDimensionValue), + checkRequired("scalingFactor", scalingFactor), + secondDimensionValue, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MatrixScalingFactor = apply { + if (validated) { + return@apply + } + + firstDimensionValue() + scalingFactor() + secondDimensionValue() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (firstDimensionValue.asKnown() == null) 0 else 1) + + (if (scalingFactor.asKnown() == null) 0 else 1) + + (if (secondDimensionValue.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MatrixScalingFactor && + firstDimensionValue == other.firstDimensionValue && + scalingFactor == other.scalingFactor && + secondDimensionValue == other.secondDimensionValue && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + firstDimensionValue, + scalingFactor, + secondDimensionValue, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MatrixScalingFactor{firstDimensionValue=$firstDimensionValue, scalingFactor=$scalingFactor, secondDimensionValue=$secondDimensionValue, additionalProperties=$additionalProperties}" + } override fun equals(other: Any?): Boolean { if (this === other) { @@ -1325,15 +1857,29 @@ private constructor( } return other is ScalableMatrixWithUnitPricingConfig && + firstDimension == other.firstDimension && + matrixScalingFactors == other.matrixScalingFactors && + unitPrice == other.unitPrice && + prorate == other.prorate && + secondDimension == other.secondDimension && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + private val hashCode: Int by lazy { + Objects.hash( + firstDimension, + matrixScalingFactors, + unitPrice, + prorate, + secondDimension, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode override fun toString() = - "ScalableMatrixWithUnitPricingConfig{additionalProperties=$additionalProperties}" + "ScalableMatrixWithUnitPricingConfig{firstDimension=$firstDimension, matrixScalingFactors=$matrixScalingFactors, unitPrice=$unitPrice, prorate=$prorate, secondDimension=$secondDimension, additionalProperties=$additionalProperties}" } /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanThresholdTotalAmountPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanThresholdTotalAmountPrice.kt index 161bf9ccc..b27136cfd 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanThresholdTotalAmountPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanThresholdTotalAmountPrice.kt @@ -11,6 +11,7 @@ import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue +import com.withorb.api.core.checkKnown import com.withorb.api.core.checkRequired import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException @@ -126,6 +127,8 @@ private constructor( fun itemId(): String = itemId.getRequired("item_id") /** + * The pricing model type + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ @@ -140,6 +143,8 @@ private constructor( fun name(): String = name.getRequired("name") /** + * Configuration for threshold_total_amount pricing + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ @@ -528,6 +533,7 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + /** The pricing model type */ fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) /** @@ -550,6 +556,7 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } + /** Configuration for threshold_total_amount pricing */ fun thresholdTotalAmountConfig(thresholdTotalAmountConfig: ThresholdTotalAmountConfig) = thresholdTotalAmountConfig(JsonField.of(thresholdTotalAmountConfig)) @@ -1102,6 +1109,7 @@ private constructor( override fun toString() = value.toString() } + /** The pricing model type */ class ModelType @JsonCreator private constructor(private val value: JsonField) : Enum { /** @@ -1222,16 +1230,66 @@ private constructor( override fun toString() = value.toString() } + /** Configuration for threshold_total_amount pricing */ class ThresholdTotalAmountConfig - @JsonCreator private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map + private val consumptionTable: JsonField>, + private val prorate: JsonField, + private val additionalProperties: MutableMap, ) { + @JsonCreator + private constructor( + @JsonProperty("consumption_table") + @ExcludeMissing + consumptionTable: JsonField> = JsonMissing.of(), + @JsonProperty("prorate") @ExcludeMissing prorate: JsonField = JsonMissing.of(), + ) : this(consumptionTable, prorate, mutableMapOf()) + + /** + * When the quantity consumed passes a provided threshold, the configured total will be + * charged + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun consumptionTable(): List = + consumptionTable.getRequired("consumption_table") + + /** + * If true, the unit price will be prorated to the billing period + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun prorate(): Boolean? = prorate.getNullable("prorate") + + /** + * Returns the raw JSON value of [consumptionTable]. + * + * Unlike [consumptionTable], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("consumption_table") + @ExcludeMissing + fun _consumptionTable(): JsonField> = consumptionTable + + /** + * Returns the raw JSON value of [prorate]. + * + * Unlike [prorate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("prorate") @ExcludeMissing fun _prorate(): JsonField = prorate + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) fun toBuilder() = Builder().from(this) @@ -1240,6 +1298,11 @@ private constructor( /** * Returns a mutable builder for constructing an instance of * [ThresholdTotalAmountConfig]. + * + * The following fields are required: + * ```kotlin + * .consumptionTable() + * ``` */ fun builder() = Builder() } @@ -1247,13 +1310,67 @@ private constructor( /** A builder for [ThresholdTotalAmountConfig]. */ class Builder internal constructor() { + private var consumptionTable: JsonField>? = null + private var prorate: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() internal fun from(thresholdTotalAmountConfig: ThresholdTotalAmountConfig) = apply { + consumptionTable = + thresholdTotalAmountConfig.consumptionTable.map { it.toMutableList() } + prorate = thresholdTotalAmountConfig.prorate additionalProperties = thresholdTotalAmountConfig.additionalProperties.toMutableMap() } + /** + * When the quantity consumed passes a provided threshold, the configured total will be + * charged + */ + fun consumptionTable(consumptionTable: List) = + consumptionTable(JsonField.of(consumptionTable)) + + /** + * Sets [Builder.consumptionTable] to an arbitrary JSON value. + * + * You should usually call [Builder.consumptionTable] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun consumptionTable(consumptionTable: JsonField>) = apply { + this.consumptionTable = consumptionTable.map { it.toMutableList() } + } + + /** + * Adds a single [ConsumptionTable] to [Builder.consumptionTable]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addConsumptionTable(consumptionTable: ConsumptionTable) = apply { + this.consumptionTable = + (this.consumptionTable ?: JsonField.of(mutableListOf())).also { + checkKnown("consumptionTable", it).add(consumptionTable) + } + } + + /** If true, the unit price will be prorated to the billing period */ + fun prorate(prorate: Boolean?) = prorate(JsonField.ofNullable(prorate)) + + /** + * Alias for [Builder.prorate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun prorate(prorate: Boolean) = prorate(prorate as Boolean?) + + /** + * Sets [Builder.prorate] to an arbitrary JSON value. + * + * You should usually call [Builder.prorate] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun prorate(prorate: JsonField) = apply { this.prorate = prorate } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -1277,9 +1394,20 @@ private constructor( * Returns an immutable instance of [ThresholdTotalAmountConfig]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .consumptionTable() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ fun build(): ThresholdTotalAmountConfig = - ThresholdTotalAmountConfig(additionalProperties.toImmutable()) + ThresholdTotalAmountConfig( + checkRequired("consumptionTable", consumptionTable).map { it.toImmutable() }, + prorate, + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false @@ -1289,6 +1417,8 @@ private constructor( return@apply } + consumptionTable().forEach { it.validate() } + prorate() validated = true } @@ -1307,7 +1437,223 @@ private constructor( * Used for best match union deserialization. */ internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + (consumptionTable.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + (if (prorate.asKnown() == null) 0 else 1) + + /** Configuration for a single threshold */ + class ConsumptionTable + private constructor( + private val threshold: JsonField, + private val totalAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("threshold") + @ExcludeMissing + threshold: JsonField = JsonMissing.of(), + @JsonProperty("total_amount") + @ExcludeMissing + totalAmount: JsonField = JsonMissing.of(), + ) : this(threshold, totalAmount, mutableMapOf()) + + /** + * Quantity threshold + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun threshold(): String = threshold.getRequired("threshold") + + /** + * Total amount for this threshold + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun totalAmount(): String = totalAmount.getRequired("total_amount") + + /** + * Returns the raw JSON value of [threshold]. + * + * Unlike [threshold], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("threshold") + @ExcludeMissing + fun _threshold(): JsonField = threshold + + /** + * Returns the raw JSON value of [totalAmount]. + * + * Unlike [totalAmount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("total_amount") + @ExcludeMissing + fun _totalAmount(): JsonField = totalAmount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ConsumptionTable]. + * + * The following fields are required: + * ```kotlin + * .threshold() + * .totalAmount() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [ConsumptionTable]. */ + class Builder internal constructor() { + + private var threshold: JsonField? = null + private var totalAmount: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(consumptionTable: ConsumptionTable) = apply { + threshold = consumptionTable.threshold + totalAmount = consumptionTable.totalAmount + additionalProperties = consumptionTable.additionalProperties.toMutableMap() + } + + /** Quantity threshold */ + fun threshold(threshold: String) = threshold(JsonField.of(threshold)) + + /** + * Sets [Builder.threshold] to an arbitrary JSON value. + * + * You should usually call [Builder.threshold] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun threshold(threshold: JsonField) = apply { this.threshold = threshold } + + /** Total amount for this threshold */ + fun totalAmount(totalAmount: String) = totalAmount(JsonField.of(totalAmount)) + + /** + * Sets [Builder.totalAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.totalAmount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun totalAmount(totalAmount: JsonField) = apply { + this.totalAmount = totalAmount + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ConsumptionTable]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .threshold() + * .totalAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ConsumptionTable = + ConsumptionTable( + checkRequired("threshold", threshold), + checkRequired("totalAmount", totalAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ConsumptionTable = apply { + if (validated) { + return@apply + } + + threshold() + totalAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (threshold.asKnown() == null) 0 else 1) + + (if (totalAmount.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ConsumptionTable && + threshold == other.threshold && + totalAmount == other.totalAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(threshold, totalAmount, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ConsumptionTable{threshold=$threshold, totalAmount=$totalAmount, additionalProperties=$additionalProperties}" + } override fun equals(other: Any?): Boolean { if (this === other) { @@ -1315,15 +1661,19 @@ private constructor( } return other is ThresholdTotalAmountConfig && + consumptionTable == other.consumptionTable && + prorate == other.prorate && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + private val hashCode: Int by lazy { + Objects.hash(consumptionTable, prorate, additionalProperties) + } override fun hashCode(): Int = hashCode override fun toString() = - "ThresholdTotalAmountConfig{additionalProperties=$additionalProperties}" + "ThresholdTotalAmountConfig{consumptionTable=$consumptionTable, prorate=$prorate, additionalProperties=$additionalProperties}" } /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanTierWithProrationPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanTierWithProrationPrice.kt deleted file mode 100644 index 18497940a..000000000 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanTierWithProrationPrice.kt +++ /dev/null @@ -1,1480 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.withorb.api.models - -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import com.withorb.api.core.Enum -import com.withorb.api.core.ExcludeMissing -import com.withorb.api.core.JsonField -import com.withorb.api.core.JsonMissing -import com.withorb.api.core.JsonValue -import com.withorb.api.core.checkRequired -import com.withorb.api.core.toImmutable -import com.withorb.api.errors.OrbInvalidDataException -import java.util.Collections -import java.util.Objects - -class NewPlanTierWithProrationPrice -private constructor( - private val cadence: JsonField, - private val itemId: JsonField, - private val modelType: JsonField, - private val name: JsonField, - private val tieredWithProrationConfig: JsonField, - private val billableMetricId: JsonField, - private val billedInAdvance: JsonField, - private val billingCycleConfiguration: JsonField, - private val conversionRate: JsonField, - private val conversionRateConfig: JsonField, - private val currency: JsonField, - private val dimensionalPriceConfiguration: JsonField, - private val externalPriceId: JsonField, - private val fixedPriceQuantity: JsonField, - private val invoiceGroupingKey: JsonField, - private val invoicingCycleConfiguration: JsonField, - private val metadata: JsonField, - private val referenceId: JsonField, - private val additionalProperties: MutableMap, -) { - - @JsonCreator - private constructor( - @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), - @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - modelType: JsonField = JsonMissing.of(), - @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("tiered_with_proration_config") - @ExcludeMissing - tieredWithProrationConfig: JsonField = JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - billingCycleConfiguration: JsonField = JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("conversion_rate_config") - @ExcludeMissing - conversionRateConfig: JsonField = JsonMissing.of(), - @JsonProperty("currency") @ExcludeMissing currency: JsonField = JsonMissing.of(), - @JsonProperty("dimensional_price_configuration") - @ExcludeMissing - dimensionalPriceConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - invoicingCycleConfiguration: JsonField = JsonMissing.of(), - @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), - @JsonProperty("reference_id") - @ExcludeMissing - referenceId: JsonField = JsonMissing.of(), - ) : this( - cadence, - itemId, - modelType, - name, - tieredWithProrationConfig, - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - conversionRateConfig, - currency, - dimensionalPriceConfiguration, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - mutableMapOf(), - ) - - /** - * The cadence to bill for this price on. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly - * missing or null (e.g. if the server responded with an unexpected value). - */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - /** - * The id of the item the price will be associated with. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly - * missing or null (e.g. if the server responded with an unexpected value). - */ - fun itemId(): String = itemId.getRequired("item_id") - - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly - * missing or null (e.g. if the server responded with an unexpected value). - */ - fun modelType(): ModelType = modelType.getRequired("model_type") - - /** - * The name of the price. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly - * missing or null (e.g. if the server responded with an unexpected value). - */ - fun name(): String = name.getRequired("name") - - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly - * missing or null (e.g. if the server responded with an unexpected value). - */ - fun tieredWithProrationConfig(): TieredWithProrationConfig = - tieredWithProrationConfig.getRequired("tiered_with_proration_config") - - /** - * The id of the billable metric for the price. Only needed if the price is usage-based. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - fun billableMetricId(): String? = billableMetricId.getNullable("billable_metric_id") - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this is true, - * and in-arrears if this is false. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") - - /** - * For custom cadence: specifies the duration of the billing period in days or months. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - fun billingCycleConfiguration(): NewBillingCycleConfiguration? = - billingCycleConfiguration.getNullable("billing_cycle_configuration") - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") - - /** - * The configuration for the rate of the price currency to the invoicing currency. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - fun conversionRateConfig(): ConversionRateConfig? = - conversionRateConfig.getNullable("conversion_rate_config") - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this price is - * billed. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - fun currency(): String? = currency.getNullable("currency") - - /** - * For dimensional price: specifies a price group and dimension values - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = - dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") - - /** - * An alias for the price. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") - - /** - * If the Price represents a fixed cost, this represents the quantity of units applied. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - fun fixedPriceQuantity(): Double? = fixedPriceQuantity.getNullable("fixed_price_quantity") - - /** - * The property used to group this price on an invoice - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - fun invoiceGroupingKey(): String? = invoiceGroupingKey.getNullable("invoice_grouping_key") - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. If - * unspecified, a single invoice is produced per billing cycle. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by setting - * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to - * `null`. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - fun metadata(): Metadata? = metadata.getNullable("metadata") - - /** - * A transient ID that can be used to reference this price when adding adjustments in the same - * API call. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - fun referenceId(): String? = referenceId.getNullable("reference_id") - - /** - * Returns the raw JSON value of [cadence]. - * - * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence - - /** - * Returns the raw JSON value of [itemId]. - * - * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - /** - * Returns the raw JSON value of [modelType]. - * - * Unlike [modelType], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonField = modelType - - /** - * Returns the raw JSON value of [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - /** - * Returns the raw JSON value of [tieredWithProrationConfig]. - * - * Unlike [tieredWithProrationConfig], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("tiered_with_proration_config") - @ExcludeMissing - fun _tieredWithProrationConfig(): JsonField = - tieredWithProrationConfig - - /** - * Returns the raw JSON value of [billableMetricId]. - * - * Unlike [billableMetricId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = billableMetricId - - /** - * Returns the raw JSON value of [billedInAdvance]. - * - * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance - - /** - * Returns the raw JSON value of [billingCycleConfiguration]. - * - * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** - * Returns the raw JSON value of [conversionRate]. - * - * Unlike [conversionRate], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** - * Returns the raw JSON value of [conversionRateConfig]. - * - * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("conversion_rate_config") - @ExcludeMissing - fun _conversionRateConfig(): JsonField = conversionRateConfig - - /** - * Returns the raw JSON value of [currency]. - * - * Unlike [currency], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - - /** - * Returns the raw JSON value of [dimensionalPriceConfiguration]. - * - * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("dimensional_price_configuration") - @ExcludeMissing - fun _dimensionalPriceConfiguration(): JsonField = - dimensionalPriceConfiguration - - /** - * Returns the raw JSON value of [externalPriceId]. - * - * Unlike [externalPriceId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * Returns the raw JSON value of [fixedPriceQuantity]. - * - * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** - * Returns the raw JSON value of [invoiceGroupingKey]. - * - * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Returns the raw JSON value of [invoicingCycleConfiguration]. - * - * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * Returns the raw JSON value of [metadata]. - * - * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata - - /** - * Returns the raw JSON value of [referenceId]. - * - * Unlike [referenceId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("reference_id") - @ExcludeMissing - fun _referenceId(): JsonField = referenceId - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [NewPlanTierWithProrationPrice]. - * - * The following fields are required: - * ```kotlin - * .cadence() - * .itemId() - * .modelType() - * .name() - * .tieredWithProrationConfig() - * ``` - */ - fun builder() = Builder() - } - - /** A builder for [NewPlanTierWithProrationPrice]. */ - class Builder internal constructor() { - - private var cadence: JsonField? = null - private var itemId: JsonField? = null - private var modelType: JsonField? = null - private var name: JsonField? = null - private var tieredWithProrationConfig: JsonField? = null - private var billableMetricId: JsonField = JsonMissing.of() - private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var conversionRateConfig: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var dimensionalPriceConfiguration: JsonField = - JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var referenceId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(newPlanTierWithProrationPrice: NewPlanTierWithProrationPrice) = apply { - cadence = newPlanTierWithProrationPrice.cadence - itemId = newPlanTierWithProrationPrice.itemId - modelType = newPlanTierWithProrationPrice.modelType - name = newPlanTierWithProrationPrice.name - tieredWithProrationConfig = newPlanTierWithProrationPrice.tieredWithProrationConfig - billableMetricId = newPlanTierWithProrationPrice.billableMetricId - billedInAdvance = newPlanTierWithProrationPrice.billedInAdvance - billingCycleConfiguration = newPlanTierWithProrationPrice.billingCycleConfiguration - conversionRate = newPlanTierWithProrationPrice.conversionRate - conversionRateConfig = newPlanTierWithProrationPrice.conversionRateConfig - currency = newPlanTierWithProrationPrice.currency - dimensionalPriceConfiguration = - newPlanTierWithProrationPrice.dimensionalPriceConfiguration - externalPriceId = newPlanTierWithProrationPrice.externalPriceId - fixedPriceQuantity = newPlanTierWithProrationPrice.fixedPriceQuantity - invoiceGroupingKey = newPlanTierWithProrationPrice.invoiceGroupingKey - invoicingCycleConfiguration = newPlanTierWithProrationPrice.invoicingCycleConfiguration - metadata = newPlanTierWithProrationPrice.metadata - referenceId = newPlanTierWithProrationPrice.referenceId - additionalProperties = newPlanTierWithProrationPrice.additionalProperties.toMutableMap() - } - - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** - * Sets [Builder.cadence] to an arbitrary JSON value. - * - * You should usually call [Builder.cadence] with a well-typed [Cadence] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - - /** The id of the item the price will be associated with. */ - fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - - /** - * Sets [Builder.itemId] to an arbitrary JSON value. - * - * You should usually call [Builder.itemId] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - - /** - * Sets [Builder.modelType] to an arbitrary JSON value. - * - * You should usually call [Builder.modelType] with a well-typed [ModelType] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun modelType(modelType: JsonField) = apply { this.modelType = modelType } - - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) - - /** - * Sets [Builder.name] to an arbitrary JSON value. - * - * You should usually call [Builder.name] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun name(name: JsonField) = apply { this.name = name } - - fun tieredWithProrationConfig(tieredWithProrationConfig: TieredWithProrationConfig) = - tieredWithProrationConfig(JsonField.of(tieredWithProrationConfig)) - - /** - * Sets [Builder.tieredWithProrationConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.tieredWithProrationConfig] with a well-typed - * [TieredWithProrationConfig] value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. - */ - fun tieredWithProrationConfig( - tieredWithProrationConfig: JsonField - ) = apply { this.tieredWithProrationConfig = tieredWithProrationConfig } - - /** The id of the billable metric for the price. Only needed if the price is usage-based. */ - fun billableMetricId(billableMetricId: String?) = - billableMetricId(JsonField.ofNullable(billableMetricId)) - - /** - * Sets [Builder.billableMetricId] to an arbitrary JSON value. - * - * You should usually call [Builder.billableMetricId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun billableMetricId(billableMetricId: JsonField) = apply { - this.billableMetricId = billableMetricId - } - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this is - * true, and in-arrears if this is false. - */ - fun billedInAdvance(billedInAdvance: Boolean?) = - billedInAdvance(JsonField.ofNullable(billedInAdvance)) - - /** - * Alias for [Builder.billedInAdvance]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun billedInAdvance(billedInAdvance: Boolean) = billedInAdvance(billedInAdvance as Boolean?) - - /** - * Sets [Builder.billedInAdvance] to an arbitrary JSON value. - * - * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun billedInAdvance(billedInAdvance: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** For custom cadence: specifies the duration of the billing period in days or months. */ - fun billingCycleConfiguration(billingCycleConfiguration: NewBillingCycleConfiguration?) = - billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - - /** - * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.billingCycleConfiguration] with a well-typed - * [NewBillingCycleConfiguration] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: JsonField - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double?) = - conversionRate(JsonField.ofNullable(conversionRate)) - - /** - * Alias for [Builder.conversionRate]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) - - /** - * Sets [Builder.conversionRate] to an arbitrary JSON value. - * - * You should usually call [Builder.conversionRate] with a well-typed [Double] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** The configuration for the rate of the price currency to the invoicing currency. */ - fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = - conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) - - /** - * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.conversionRateConfig] with a well-typed - * [ConversionRateConfig] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun conversionRateConfig(conversionRateConfig: JsonField) = apply { - this.conversionRateConfig = conversionRateConfig - } - - /** Alias for calling [conversionRateConfig] with `ConversionRateConfig.ofUnit(unit)`. */ - fun conversionRateConfig(unit: UnitConversionRateConfig) = - conversionRateConfig(ConversionRateConfig.ofUnit(unit)) - - /** - * Alias for calling [conversionRateConfig] with the following: - * ```kotlin - * UnitConversionRateConfig.builder() - * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) - * .unitConfig(unitConfig) - * .build() - * ``` - */ - fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = - conversionRateConfig( - UnitConversionRateConfig.builder() - .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) - .unitConfig(unitConfig) - .build() - ) - - /** - * Alias for calling [conversionRateConfig] with `ConversionRateConfig.ofTiered(tiered)`. - */ - fun conversionRateConfig(tiered: TieredConversionRateConfig) = - conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) - - /** - * Alias for calling [conversionRateConfig] with the following: - * ```kotlin - * TieredConversionRateConfig.builder() - * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) - * .tieredConfig(tieredConfig) - * .build() - * ``` - */ - fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = - conversionRateConfig( - TieredConversionRateConfig.builder() - .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) - .tieredConfig(tieredConfig) - .build() - ) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this price is - * billed. - */ - fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) - - /** - * Sets [Builder.currency] to an arbitrary JSON value. - * - * You should usually call [Builder.currency] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } - - /** For dimensional price: specifies a price group and dimension values */ - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? - ) = dimensionalPriceConfiguration(JsonField.ofNullable(dimensionalPriceConfiguration)) - - /** - * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.dimensionalPriceConfiguration] with a well-typed - * [NewDimensionalPriceConfiguration] value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: JsonField - ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** - * Sets [Builder.externalPriceId] to an arbitrary JSON value. - * - * You should usually call [Builder.externalPriceId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun externalPriceId(externalPriceId: JsonField) = apply { - this.externalPriceId = externalPriceId - } - - /** If the Price represents a fixed cost, this represents the quantity of units applied. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = - fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) - - /** - * Alias for [Builder.fixedPriceQuantity]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. - * - * You should usually call [Builder.fixedPriceQuantity] with a well-typed [Double] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = - invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) - - /** - * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. - * - * You should usually call [Builder.invoiceGroupingKey] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { - this.invoiceGroupingKey = invoiceGroupingKey - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. If - * unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: NewBillingCycleConfiguration? - ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) - - /** - * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.invoicingCycleConfiguration] with a well-typed - * [NewBillingCycleConfiguration] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by - * setting the value to `null`, and the entire metadata mapping can be cleared by setting - * `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * Sets [Builder.metadata] to an arbitrary JSON value. - * - * You should usually call [Builder.metadata] with a well-typed [Metadata] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - - /** - * A transient ID that can be used to reference this price when adding adjustments in the - * same API call. - */ - fun referenceId(referenceId: String?) = referenceId(JsonField.ofNullable(referenceId)) - - /** - * Sets [Builder.referenceId] to an arbitrary JSON value. - * - * You should usually call [Builder.referenceId] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun referenceId(referenceId: JsonField) = apply { this.referenceId = referenceId } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [NewPlanTierWithProrationPrice]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```kotlin - * .cadence() - * .itemId() - * .modelType() - * .name() - * .tieredWithProrationConfig() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): NewPlanTierWithProrationPrice = - NewPlanTierWithProrationPrice( - checkRequired("cadence", cadence), - checkRequired("itemId", itemId), - checkRequired("modelType", modelType), - checkRequired("name", name), - checkRequired("tieredWithProrationConfig", tieredWithProrationConfig), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - conversionRateConfig, - currency, - dimensionalPriceConfiguration, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): NewPlanTierWithProrationPrice = apply { - if (validated) { - return@apply - } - - cadence().validate() - itemId() - modelType().validate() - name() - tieredWithProrationConfig().validate() - billableMetricId() - billedInAdvance() - billingCycleConfiguration()?.validate() - conversionRate() - conversionRateConfig()?.validate() - currency() - dimensionalPriceConfiguration()?.validate() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration()?.validate() - metadata()?.validate() - referenceId() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (cadence.asKnown()?.validity() ?: 0) + - (if (itemId.asKnown() == null) 0 else 1) + - (modelType.asKnown()?.validity() ?: 0) + - (if (name.asKnown() == null) 0 else 1) + - (tieredWithProrationConfig.asKnown()?.validity() ?: 0) + - (if (billableMetricId.asKnown() == null) 0 else 1) + - (if (billedInAdvance.asKnown() == null) 0 else 1) + - (billingCycleConfiguration.asKnown()?.validity() ?: 0) + - (if (conversionRate.asKnown() == null) 0 else 1) + - (conversionRateConfig.asKnown()?.validity() ?: 0) + - (if (currency.asKnown() == null) 0 else 1) + - (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + - (if (externalPriceId.asKnown() == null) 0 else 1) + - (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + - (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + - (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + - (metadata.asKnown()?.validity() ?: 0) + - (if (referenceId.asKnown() == null) 0 else 1) - - /** The cadence to bill for this price on. */ - class Cadence @JsonCreator private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API may respond with new members that the SDK is - * unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - val ANNUAL = of("annual") - - val SEMI_ANNUAL = of("semi_annual") - - val MONTHLY = of("monthly") - - val QUARTERLY = of("quarterly") - - val ONE_TIME = of("one_time") - - val CUSTOM = of("custom") - - fun of(value: String) = Cadence(JsonField.of(value)) - } - - /** An enum containing [Cadence]'s known values. */ - enum class Known { - ANNUAL, - SEMI_ANNUAL, - MONTHLY, - QUARTERLY, - ONE_TIME, - CUSTOM, - } - - /** - * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Cadence] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if the - * SDK is on an older version than the API, then the API may respond with new members that - * the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - ANNUAL, - SEMI_ANNUAL, - MONTHLY, - QUARTERLY, - ONE_TIME, - CUSTOM, - /** An enum member indicating that [Cadence] was instantiated with an unknown value. */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you want - * to throw for the unknown case. - */ - fun value(): Value = - when (this) { - ANNUAL -> Value.ANNUAL - SEMI_ANNUAL -> Value.SEMI_ANNUAL - MONTHLY -> Value.MONTHLY - QUARTERLY -> Value.QUARTERLY - ONE_TIME -> Value.ONE_TIME - CUSTOM -> Value.CUSTOM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and don't - * want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known member. - */ - fun known(): Known = - when (this) { - ANNUAL -> Known.ANNUAL - SEMI_ANNUAL -> Known.SEMI_ANNUAL - MONTHLY -> Known.MONTHLY - QUARTERLY -> Known.QUARTERLY - ONE_TIME -> Known.ONE_TIME - CUSTOM -> Known.CUSTOM - else -> throw OrbInvalidDataException("Unknown Cadence: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the expected - * primitive type. - */ - fun asString(): String = - _value().asString() ?: throw OrbInvalidDataException("Value is not a String") - - private var validated: Boolean = false - - fun validate(): Cadence = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Cadence && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class ModelType @JsonCreator private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API may respond with new members that the SDK is - * unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - val TIERED_WITH_PRORATION = of("tiered_with_proration") - - fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - TIERED_WITH_PRORATION - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if the - * SDK is on an older version than the API, then the API may respond with new members that - * the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - TIERED_WITH_PRORATION, - /** - * An enum member indicating that [ModelType] was instantiated with an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you want - * to throw for the unknown case. - */ - fun value(): Value = - when (this) { - TIERED_WITH_PRORATION -> Value.TIERED_WITH_PRORATION - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and don't - * want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known member. - */ - fun known(): Known = - when (this) { - TIERED_WITH_PRORATION -> Known.TIERED_WITH_PRORATION - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the expected - * primitive type. - */ - fun asString(): String = - _value().asString() ?: throw OrbInvalidDataException("Value is not a String") - - private var validated: Boolean = false - - fun validate(): ModelType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ModelType && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class TieredWithProrationConfig - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [TieredWithProrationConfig]. - */ - fun builder() = Builder() - } - - /** A builder for [TieredWithProrationConfig]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(tieredWithProrationConfig: TieredWithProrationConfig) = apply { - additionalProperties = tieredWithProrationConfig.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [TieredWithProrationConfig]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): TieredWithProrationConfig = - TieredWithProrationConfig(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): TieredWithProrationConfig = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is TieredWithProrationConfig && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "TieredWithProrationConfig{additionalProperties=$additionalProperties}" - } - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by setting - * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to - * `null`. - */ - class Metadata - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Metadata]. */ - fun builder() = Builder() - } - - /** A builder for [Metadata]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(metadata: Metadata) = apply { - additionalProperties = metadata.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Metadata]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Metadata && additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is NewPlanTierWithProrationPrice && - cadence == other.cadence && - itemId == other.itemId && - modelType == other.modelType && - name == other.name && - tieredWithProrationConfig == other.tieredWithProrationConfig && - billableMetricId == other.billableMetricId && - billedInAdvance == other.billedInAdvance && - billingCycleConfiguration == other.billingCycleConfiguration && - conversionRate == other.conversionRate && - conversionRateConfig == other.conversionRateConfig && - currency == other.currency && - dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && - externalPriceId == other.externalPriceId && - fixedPriceQuantity == other.fixedPriceQuantity && - invoiceGroupingKey == other.invoiceGroupingKey && - invoicingCycleConfiguration == other.invoicingCycleConfiguration && - metadata == other.metadata && - referenceId == other.referenceId && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - cadence, - itemId, - modelType, - name, - tieredWithProrationConfig, - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - conversionRateConfig, - currency, - dimensionalPriceConfiguration, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewPlanTierWithProrationPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredWithProrationConfig=$tieredWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" -} diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanTieredPackagePrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanTieredPackagePrice.kt index 6cbd86c32..7e147d55d 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanTieredPackagePrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanTieredPackagePrice.kt @@ -11,6 +11,7 @@ import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue +import com.withorb.api.core.checkKnown import com.withorb.api.core.checkRequired import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException @@ -126,6 +127,8 @@ private constructor( fun itemId(): String = itemId.getRequired("item_id") /** + * The pricing model type + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ @@ -140,6 +143,8 @@ private constructor( fun name(): String = name.getRequired("name") /** + * Configuration for tiered_package pricing + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ @@ -520,6 +525,7 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + /** The pricing model type */ fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) /** @@ -542,6 +548,7 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } + /** Configuration for tiered_package pricing */ fun tieredPackageConfig(tieredPackageConfig: TieredPackageConfig) = tieredPackageConfig(JsonField.of(tieredPackageConfig)) @@ -1094,6 +1101,7 @@ private constructor( override fun toString() = value.toString() } + /** The pricing model type */ class ModelType @JsonCreator private constructor(private val value: JsonField) : Enum { /** @@ -1214,34 +1222,137 @@ private constructor( override fun toString() = value.toString() } + /** Configuration for tiered_package pricing */ class TieredPackageConfig - @JsonCreator private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map + private val packageSize: JsonField, + private val tiers: JsonField>, + private val additionalProperties: MutableMap, ) { + @JsonCreator + private constructor( + @JsonProperty("package_size") + @ExcludeMissing + packageSize: JsonField = JsonMissing.of(), + @JsonProperty("tiers") @ExcludeMissing tiers: JsonField> = JsonMissing.of(), + ) : this(packageSize, tiers, mutableMapOf()) + + /** + * Package size + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun packageSize(): String = packageSize.getRequired("package_size") + + /** + * Apply tiered pricing after rounding up the quantity to the package size. Tiers are + * defined using exclusive lower bounds. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun tiers(): List = tiers.getRequired("tiers") + + /** + * Returns the raw JSON value of [packageSize]. + * + * Unlike [packageSize], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("package_size") + @ExcludeMissing + fun _packageSize(): JsonField = packageSize + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tiers") @ExcludeMissing fun _tiers(): JsonField> = tiers + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) fun toBuilder() = Builder().from(this) companion object { - /** Returns a mutable builder for constructing an instance of [TieredPackageConfig]. */ + /** + * Returns a mutable builder for constructing an instance of [TieredPackageConfig]. + * + * The following fields are required: + * ```kotlin + * .packageSize() + * .tiers() + * ``` + */ fun builder() = Builder() } /** A builder for [TieredPackageConfig]. */ class Builder internal constructor() { + private var packageSize: JsonField? = null + private var tiers: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(tieredPackageConfig: TieredPackageConfig) = apply { + packageSize = tieredPackageConfig.packageSize + tiers = tieredPackageConfig.tiers.map { it.toMutableList() } additionalProperties = tieredPackageConfig.additionalProperties.toMutableMap() } + /** Package size */ + fun packageSize(packageSize: String) = packageSize(JsonField.of(packageSize)) + + /** + * Sets [Builder.packageSize] to an arbitrary JSON value. + * + * You should usually call [Builder.packageSize] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun packageSize(packageSize: JsonField) = apply { + this.packageSize = packageSize + } + + /** + * Apply tiered pricing after rounding up the quantity to the package size. Tiers are + * defined using exclusive lower bounds. + */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -1265,9 +1376,21 @@ private constructor( * Returns an immutable instance of [TieredPackageConfig]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .packageSize() + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ fun build(): TieredPackageConfig = - TieredPackageConfig(additionalProperties.toImmutable()) + TieredPackageConfig( + checkRequired("packageSize", packageSize), + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false @@ -1277,6 +1400,8 @@ private constructor( return@apply } + packageSize() + tiers().forEach { it.validate() } validated = true } @@ -1295,7 +1420,221 @@ private constructor( * Used for best match union deserialization. */ internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + (if (packageSize.asKnown() == null) 0 else 1) + + (tiers.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single tier with business logic */ + class Tier + private constructor( + private val perUnit: JsonField, + private val tierLowerBound: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("per_unit") + @ExcludeMissing + perUnit: JsonField = JsonMissing.of(), + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + ) : this(perUnit, tierLowerBound, mutableMapOf()) + + /** + * Price per package + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun perUnit(): String = perUnit.getRequired("per_unit") + + /** + * Tier lower bound + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun tierLowerBound(): String = tierLowerBound.getRequired("tier_lower_bound") + + /** + * Returns the raw JSON value of [perUnit]. + * + * Unlike [perUnit], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("per_unit") @ExcludeMissing fun _perUnit(): JsonField = perUnit + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Tier]. + * + * The following fields are required: + * ```kotlin + * .perUnit() + * .tierLowerBound() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var perUnit: JsonField? = null + private var tierLowerBound: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(tier: Tier) = apply { + perUnit = tier.perUnit + tierLowerBound = tier.tierLowerBound + additionalProperties = tier.additionalProperties.toMutableMap() + } + + /** Price per package */ + fun perUnit(perUnit: String) = perUnit(JsonField.of(perUnit)) + + /** + * Sets [Builder.perUnit] to an arbitrary JSON value. + * + * You should usually call [Builder.perUnit] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun perUnit(perUnit: JsonField) = apply { this.perUnit = perUnit } + + /** Tier lower bound */ + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Tier]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .perUnit() + * .tierLowerBound() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("perUnit", perUnit), + checkRequired("tierLowerBound", tierLowerBound), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + perUnit() + tierLowerBound() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (perUnit.asKnown() == null) 0 else 1) + + (if (tierLowerBound.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + perUnit == other.perUnit && + tierLowerBound == other.tierLowerBound && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(perUnit, tierLowerBound, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{perUnit=$perUnit, tierLowerBound=$tierLowerBound, additionalProperties=$additionalProperties}" + } override fun equals(other: Any?): Boolean { if (this === other) { @@ -1303,14 +1642,17 @@ private constructor( } return other is TieredPackageConfig && + packageSize == other.packageSize && + tiers == other.tiers && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(packageSize, tiers, additionalProperties) } override fun hashCode(): Int = hashCode - override fun toString() = "TieredPackageConfig{additionalProperties=$additionalProperties}" + override fun toString() = + "TieredPackageConfig{packageSize=$packageSize, tiers=$tiers, additionalProperties=$additionalProperties}" } /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanTieredPackageWithMinimumPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanTieredPackageWithMinimumPrice.kt index 98db828b0..66c2a20b8 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanTieredPackageWithMinimumPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanTieredPackageWithMinimumPrice.kt @@ -11,6 +11,7 @@ import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue +import com.withorb.api.core.checkKnown import com.withorb.api.core.checkRequired import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException @@ -127,6 +128,8 @@ private constructor( fun itemId(): String = itemId.getRequired("item_id") /** + * The pricing model type + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ @@ -141,6 +144,8 @@ private constructor( fun name(): String = name.getRequired("name") /** + * Configuration for tiered_package_with_minimum pricing + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ @@ -531,6 +536,7 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + /** The pricing model type */ fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) /** @@ -553,6 +559,7 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } + /** Configuration for tiered_package_with_minimum pricing */ fun tieredPackageWithMinimumConfig( tieredPackageWithMinimumConfig: TieredPackageWithMinimumConfig ) = tieredPackageWithMinimumConfig(JsonField.of(tieredPackageWithMinimumConfig)) @@ -1106,6 +1113,7 @@ private constructor( override fun toString() = value.toString() } + /** The pricing model type */ class ModelType @JsonCreator private constructor(private val value: JsonField) : Enum { /** @@ -1226,16 +1234,64 @@ private constructor( override fun toString() = value.toString() } + /** Configuration for tiered_package_with_minimum pricing */ class TieredPackageWithMinimumConfig - @JsonCreator private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map + private val packageSize: JsonField, + private val tiers: JsonField>, + private val additionalProperties: MutableMap, ) { + @JsonCreator + private constructor( + @JsonProperty("package_size") + @ExcludeMissing + packageSize: JsonField = JsonMissing.of(), + @JsonProperty("tiers") @ExcludeMissing tiers: JsonField> = JsonMissing.of(), + ) : this(packageSize, tiers, mutableMapOf()) + + /** + * Package size + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun packageSize(): Double = packageSize.getRequired("package_size") + + /** + * Apply tiered pricing after rounding up the quantity to the package size. Tiers are + * defined using exclusive lower bounds. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun tiers(): List = tiers.getRequired("tiers") + + /** + * Returns the raw JSON value of [packageSize]. + * + * Unlike [packageSize], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("package_size") + @ExcludeMissing + fun _packageSize(): JsonField = packageSize + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tiers") @ExcludeMissing fun _tiers(): JsonField> = tiers + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) fun toBuilder() = Builder().from(this) @@ -1244,6 +1300,12 @@ private constructor( /** * Returns a mutable builder for constructing an instance of * [TieredPackageWithMinimumConfig]. + * + * The following fields are required: + * ```kotlin + * .packageSize() + * .tiers() + * ``` */ fun builder() = Builder() } @@ -1251,14 +1313,61 @@ private constructor( /** A builder for [TieredPackageWithMinimumConfig]. */ class Builder internal constructor() { + private var packageSize: JsonField? = null + private var tiers: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(tieredPackageWithMinimumConfig: TieredPackageWithMinimumConfig) = apply { + packageSize = tieredPackageWithMinimumConfig.packageSize + tiers = tieredPackageWithMinimumConfig.tiers.map { it.toMutableList() } additionalProperties = tieredPackageWithMinimumConfig.additionalProperties.toMutableMap() } + /** Package size */ + fun packageSize(packageSize: Double) = packageSize(JsonField.of(packageSize)) + + /** + * Sets [Builder.packageSize] to an arbitrary JSON value. + * + * You should usually call [Builder.packageSize] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun packageSize(packageSize: JsonField) = apply { + this.packageSize = packageSize + } + + /** + * Apply tiered pricing after rounding up the quantity to the package size. Tiers are + * defined using exclusive lower bounds. + */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -1282,9 +1391,21 @@ private constructor( * Returns an immutable instance of [TieredPackageWithMinimumConfig]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .packageSize() + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ fun build(): TieredPackageWithMinimumConfig = - TieredPackageWithMinimumConfig(additionalProperties.toImmutable()) + TieredPackageWithMinimumConfig( + checkRequired("packageSize", packageSize), + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false @@ -1294,6 +1415,8 @@ private constructor( return@apply } + packageSize() + tiers().forEach { it.validate() } validated = true } @@ -1312,7 +1435,267 @@ private constructor( * Used for best match union deserialization. */ internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + (if (packageSize.asKnown() == null) 0 else 1) + + (tiers.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single tier */ + class Tier + private constructor( + private val minimumAmount: JsonField, + private val perUnit: JsonField, + private val tierLowerBound: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("minimum_amount") + @ExcludeMissing + minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("per_unit") + @ExcludeMissing + perUnit: JsonField = JsonMissing.of(), + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + ) : this(minimumAmount, perUnit, tierLowerBound, mutableMapOf()) + + /** + * Minimum amount + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") + + /** + * Price per package + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun perUnit(): String = perUnit.getRequired("per_unit") + + /** + * Tier lower bound + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun tierLowerBound(): String = tierLowerBound.getRequired("tier_lower_bound") + + /** + * Returns the raw JSON value of [minimumAmount]. + * + * Unlike [minimumAmount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount + + /** + * Returns the raw JSON value of [perUnit]. + * + * Unlike [perUnit], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("per_unit") @ExcludeMissing fun _perUnit(): JsonField = perUnit + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Tier]. + * + * The following fields are required: + * ```kotlin + * .minimumAmount() + * .perUnit() + * .tierLowerBound() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var minimumAmount: JsonField? = null + private var perUnit: JsonField? = null + private var tierLowerBound: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(tier: Tier) = apply { + minimumAmount = tier.minimumAmount + perUnit = tier.perUnit + tierLowerBound = tier.tierLowerBound + additionalProperties = tier.additionalProperties.toMutableMap() + } + + /** Minimum amount */ + fun minimumAmount(minimumAmount: String) = + minimumAmount(JsonField.of(minimumAmount)) + + /** + * Sets [Builder.minimumAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumAmount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount + } + + /** Price per package */ + fun perUnit(perUnit: String) = perUnit(JsonField.of(perUnit)) + + /** + * Sets [Builder.perUnit] to an arbitrary JSON value. + * + * You should usually call [Builder.perUnit] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun perUnit(perUnit: JsonField) = apply { this.perUnit = perUnit } + + /** Tier lower bound */ + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Tier]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .minimumAmount() + * .perUnit() + * .tierLowerBound() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("minimumAmount", minimumAmount), + checkRequired("perUnit", perUnit), + checkRequired("tierLowerBound", tierLowerBound), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + minimumAmount() + perUnit() + tierLowerBound() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (minimumAmount.asKnown() == null) 0 else 1) + + (if (perUnit.asKnown() == null) 0 else 1) + + (if (tierLowerBound.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + minimumAmount == other.minimumAmount && + perUnit == other.perUnit && + tierLowerBound == other.tierLowerBound && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(minimumAmount, perUnit, tierLowerBound, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{minimumAmount=$minimumAmount, perUnit=$perUnit, tierLowerBound=$tierLowerBound, additionalProperties=$additionalProperties}" + } override fun equals(other: Any?): Boolean { if (this === other) { @@ -1320,15 +1703,17 @@ private constructor( } return other is TieredPackageWithMinimumConfig && + packageSize == other.packageSize && + tiers == other.tiers && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(packageSize, tiers, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "TieredPackageWithMinimumConfig{additionalProperties=$additionalProperties}" + "TieredPackageWithMinimumConfig{packageSize=$packageSize, tiers=$tiers, additionalProperties=$additionalProperties}" } /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanTieredPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanTieredPrice.kt index 0a312f614..f91ff9ee9 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanTieredPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanTieredPrice.kt @@ -126,6 +126,8 @@ private constructor( fun itemId(): String = itemId.getRequired("item_id") /** + * The pricing model type + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ @@ -140,6 +142,8 @@ private constructor( fun name(): String = name.getRequired("name") /** + * Configuration for tiered pricing + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ @@ -518,6 +522,7 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + /** The pricing model type */ fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) /** @@ -540,6 +545,7 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } + /** Configuration for tiered pricing */ fun tieredConfig(tieredConfig: TieredConfig) = tieredConfig(JsonField.of(tieredConfig)) /** @@ -1091,6 +1097,7 @@ private constructor( override fun toString() = value.toString() } + /** The pricing model type */ class ModelType @JsonCreator private constructor(private val value: JsonField) : Enum { /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanTieredWithMinimumPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanTieredWithMinimumPrice.kt index 46f83bf7e..ac14f2e41 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanTieredWithMinimumPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanTieredWithMinimumPrice.kt @@ -11,6 +11,7 @@ import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue +import com.withorb.api.core.checkKnown import com.withorb.api.core.checkRequired import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException @@ -126,6 +127,8 @@ private constructor( fun itemId(): String = itemId.getRequired("item_id") /** + * The pricing model type + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ @@ -140,6 +143,8 @@ private constructor( fun name(): String = name.getRequired("name") /** + * Configuration for tiered_with_minimum pricing + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ @@ -522,6 +527,7 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + /** The pricing model type */ fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) /** @@ -544,6 +550,7 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } + /** Configuration for tiered_with_minimum pricing */ fun tieredWithMinimumConfig(tieredWithMinimumConfig: TieredWithMinimumConfig) = tieredWithMinimumConfig(JsonField.of(tieredWithMinimumConfig)) @@ -1097,6 +1104,7 @@ private constructor( override fun toString() = value.toString() } + /** The pricing model type */ class ModelType @JsonCreator private constructor(private val value: JsonField) : Enum { /** @@ -1217,16 +1225,83 @@ private constructor( override fun toString() = value.toString() } + /** Configuration for tiered_with_minimum pricing */ class TieredWithMinimumConfig - @JsonCreator private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map + private val tiers: JsonField>, + private val hideZeroAmountTiers: JsonField, + private val prorate: JsonField, + private val additionalProperties: MutableMap, ) { + @JsonCreator + private constructor( + @JsonProperty("tiers") @ExcludeMissing tiers: JsonField> = JsonMissing.of(), + @JsonProperty("hide_zero_amount_tiers") + @ExcludeMissing + hideZeroAmountTiers: JsonField = JsonMissing.of(), + @JsonProperty("prorate") @ExcludeMissing prorate: JsonField = JsonMissing.of(), + ) : this(tiers, hideZeroAmountTiers, prorate, mutableMapOf()) + + /** + * Tiered pricing with a minimum amount dependent on the volume tier. Tiers are defined + * using exclusive lower bounds. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun tiers(): List = tiers.getRequired("tiers") + + /** + * If true, tiers with an accrued amount of 0 will not be included in the rating. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun hideZeroAmountTiers(): Boolean? = + hideZeroAmountTiers.getNullable("hide_zero_amount_tiers") + + /** + * If true, the unit price will be prorated to the billing period + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun prorate(): Boolean? = prorate.getNullable("prorate") + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tiers") @ExcludeMissing fun _tiers(): JsonField> = tiers + + /** + * Returns the raw JSON value of [hideZeroAmountTiers]. + * + * Unlike [hideZeroAmountTiers], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("hide_zero_amount_tiers") + @ExcludeMissing + fun _hideZeroAmountTiers(): JsonField = hideZeroAmountTiers + + /** + * Returns the raw JSON value of [prorate]. + * + * Unlike [prorate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("prorate") @ExcludeMissing fun _prorate(): JsonField = prorate + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) fun toBuilder() = Builder().from(this) @@ -1234,6 +1309,11 @@ private constructor( /** * Returns a mutable builder for constructing an instance of [TieredWithMinimumConfig]. + * + * The following fields are required: + * ```kotlin + * .tiers() + * ``` */ fun builder() = Builder() } @@ -1241,12 +1321,74 @@ private constructor( /** A builder for [TieredWithMinimumConfig]. */ class Builder internal constructor() { + private var tiers: JsonField>? = null + private var hideZeroAmountTiers: JsonField = JsonMissing.of() + private var prorate: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() internal fun from(tieredWithMinimumConfig: TieredWithMinimumConfig) = apply { + tiers = tieredWithMinimumConfig.tiers.map { it.toMutableList() } + hideZeroAmountTiers = tieredWithMinimumConfig.hideZeroAmountTiers + prorate = tieredWithMinimumConfig.prorate additionalProperties = tieredWithMinimumConfig.additionalProperties.toMutableMap() } + /** + * Tiered pricing with a minimum amount dependent on the volume tier. Tiers are defined + * using exclusive lower bounds. + */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + + /** If true, tiers with an accrued amount of 0 will not be included in the rating. */ + fun hideZeroAmountTiers(hideZeroAmountTiers: Boolean) = + hideZeroAmountTiers(JsonField.of(hideZeroAmountTiers)) + + /** + * Sets [Builder.hideZeroAmountTiers] to an arbitrary JSON value. + * + * You should usually call [Builder.hideZeroAmountTiers] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun hideZeroAmountTiers(hideZeroAmountTiers: JsonField) = apply { + this.hideZeroAmountTiers = hideZeroAmountTiers + } + + /** If true, the unit price will be prorated to the billing period */ + fun prorate(prorate: Boolean) = prorate(JsonField.of(prorate)) + + /** + * Sets [Builder.prorate] to an arbitrary JSON value. + * + * You should usually call [Builder.prorate] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun prorate(prorate: JsonField) = apply { this.prorate = prorate } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -1270,9 +1412,21 @@ private constructor( * Returns an immutable instance of [TieredWithMinimumConfig]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ fun build(): TieredWithMinimumConfig = - TieredWithMinimumConfig(additionalProperties.toImmutable()) + TieredWithMinimumConfig( + checkRequired("tiers", tiers).map { it.toImmutable() }, + hideZeroAmountTiers, + prorate, + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false @@ -1282,6 +1436,9 @@ private constructor( return@apply } + tiers().forEach { it.validate() } + hideZeroAmountTiers() + prorate() validated = true } @@ -1300,7 +1457,273 @@ private constructor( * Used for best match union deserialization. */ internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + (tiers.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + (if (hideZeroAmountTiers.asKnown() == null) 0 else 1) + + (if (prorate.asKnown() == null) 0 else 1) + + /** Configuration for a single tier */ + class Tier + private constructor( + private val minimumAmount: JsonField, + private val tierLowerBound: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("minimum_amount") + @ExcludeMissing + minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(minimumAmount, tierLowerBound, unitAmount, mutableMapOf()) + + /** + * Minimum amount + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") + + /** + * Tier lower bound + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun tierLowerBound(): String = tierLowerBound.getRequired("tier_lower_bound") + + /** + * Per unit amount + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [minimumAmount]. + * + * Unlike [minimumAmount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Tier]. + * + * The following fields are required: + * ```kotlin + * .minimumAmount() + * .tierLowerBound() + * .unitAmount() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var minimumAmount: JsonField? = null + private var tierLowerBound: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(tier: Tier) = apply { + minimumAmount = tier.minimumAmount + tierLowerBound = tier.tierLowerBound + unitAmount = tier.unitAmount + additionalProperties = tier.additionalProperties.toMutableMap() + } + + /** Minimum amount */ + fun minimumAmount(minimumAmount: String) = + minimumAmount(JsonField.of(minimumAmount)) + + /** + * Sets [Builder.minimumAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumAmount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount + } + + /** Tier lower bound */ + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + /** Per unit amount */ + fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Tier]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .minimumAmount() + * .tierLowerBound() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("minimumAmount", minimumAmount), + checkRequired("tierLowerBound", tierLowerBound), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + minimumAmount() + tierLowerBound() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (minimumAmount.asKnown() == null) 0 else 1) + + (if (tierLowerBound.asKnown() == null) 0 else 1) + + (if (unitAmount.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + minimumAmount == other.minimumAmount && + tierLowerBound == other.tierLowerBound && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(minimumAmount, tierLowerBound, unitAmount, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{minimumAmount=$minimumAmount, tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } override fun equals(other: Any?): Boolean { if (this === other) { @@ -1308,15 +1731,20 @@ private constructor( } return other is TieredWithMinimumConfig && + tiers == other.tiers && + hideZeroAmountTiers == other.hideZeroAmountTiers && + prorate == other.prorate && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + private val hashCode: Int by lazy { + Objects.hash(tiers, hideZeroAmountTiers, prorate, additionalProperties) + } override fun hashCode(): Int = hashCode override fun toString() = - "TieredWithMinimumConfig{additionalProperties=$additionalProperties}" + "TieredWithMinimumConfig{tiers=$tiers, hideZeroAmountTiers=$hideZeroAmountTiers, prorate=$prorate, additionalProperties=$additionalProperties}" } /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanUnitPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanUnitPrice.kt index 2dc6fd602..42fea98f7 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanUnitPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanUnitPrice.kt @@ -126,6 +126,8 @@ private constructor( fun itemId(): String = itemId.getRequired("item_id") /** + * The pricing model type + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ @@ -140,6 +142,8 @@ private constructor( fun name(): String = name.getRequired("name") /** + * Configuration for unit pricing + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ @@ -518,6 +522,7 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + /** The pricing model type */ fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) /** @@ -540,6 +545,7 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } + /** Configuration for unit pricing */ fun unitConfig(unitConfig: UnitConfig) = unitConfig(JsonField.of(unitConfig)) /** @@ -1089,6 +1095,7 @@ private constructor( override fun toString() = value.toString() } + /** The pricing model type */ class ModelType @JsonCreator private constructor(private val value: JsonField) : Enum { /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanUnitWithPercentPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanUnitWithPercentPrice.kt index 8e9d67e67..37a59f63c 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanUnitWithPercentPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanUnitWithPercentPrice.kt @@ -126,6 +126,8 @@ private constructor( fun itemId(): String = itemId.getRequired("item_id") /** + * The pricing model type + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ @@ -140,6 +142,8 @@ private constructor( fun name(): String = name.getRequired("name") /** + * Configuration for unit_with_percent pricing + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ @@ -521,6 +525,7 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + /** The pricing model type */ fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) /** @@ -543,6 +548,7 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } + /** Configuration for unit_with_percent pricing */ fun unitWithPercentConfig(unitWithPercentConfig: UnitWithPercentConfig) = unitWithPercentConfig(JsonField.of(unitWithPercentConfig)) @@ -1095,6 +1101,7 @@ private constructor( override fun toString() = value.toString() } + /** The pricing model type */ class ModelType @JsonCreator private constructor(private val value: JsonField) : Enum { /** @@ -1215,16 +1222,63 @@ private constructor( override fun toString() = value.toString() } + /** Configuration for unit_with_percent pricing */ class UnitWithPercentConfig - @JsonCreator private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map + private val percent: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, ) { + @JsonCreator + private constructor( + @JsonProperty("percent") @ExcludeMissing percent: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(percent, unitAmount, mutableMapOf()) + + /** + * What percent, out of 100, of the calculated total to charge + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun percent(): String = percent.getRequired("percent") + + /** + * Rate per unit of usage + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [percent]. + * + * Unlike [percent], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("percent") @ExcludeMissing fun _percent(): JsonField = percent + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) fun toBuilder() = Builder().from(this) @@ -1232,6 +1286,12 @@ private constructor( /** * Returns a mutable builder for constructing an instance of [UnitWithPercentConfig]. + * + * The following fields are required: + * ```kotlin + * .percent() + * .unitAmount() + * ``` */ fun builder() = Builder() } @@ -1239,12 +1299,40 @@ private constructor( /** A builder for [UnitWithPercentConfig]. */ class Builder internal constructor() { + private var percent: JsonField? = null + private var unitAmount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(unitWithPercentConfig: UnitWithPercentConfig) = apply { + percent = unitWithPercentConfig.percent + unitAmount = unitWithPercentConfig.unitAmount additionalProperties = unitWithPercentConfig.additionalProperties.toMutableMap() } + /** What percent, out of 100, of the calculated total to charge */ + fun percent(percent: String) = percent(JsonField.of(percent)) + + /** + * Sets [Builder.percent] to an arbitrary JSON value. + * + * You should usually call [Builder.percent] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun percent(percent: JsonField) = apply { this.percent = percent } + + /** Rate per unit of usage */ + fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { this.unitAmount = unitAmount } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -1268,9 +1356,21 @@ private constructor( * Returns an immutable instance of [UnitWithPercentConfig]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .percent() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ fun build(): UnitWithPercentConfig = - UnitWithPercentConfig(additionalProperties.toImmutable()) + UnitWithPercentConfig( + checkRequired("percent", percent), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false @@ -1280,6 +1380,8 @@ private constructor( return@apply } + percent() + unitAmount() validated = true } @@ -1298,7 +1400,7 @@ private constructor( * Used for best match union deserialization. */ internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + (if (percent.asKnown() == null) 0 else 1) + (if (unitAmount.asKnown() == null) 0 else 1) override fun equals(other: Any?): Boolean { if (this === other) { @@ -1306,15 +1408,19 @@ private constructor( } return other is UnitWithPercentConfig && + percent == other.percent && + unitAmount == other.unitAmount && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + private val hashCode: Int by lazy { + Objects.hash(percent, unitAmount, additionalProperties) + } override fun hashCode(): Int = hashCode override fun toString() = - "UnitWithPercentConfig{additionalProperties=$additionalProperties}" + "UnitWithPercentConfig{percent=$percent, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" } /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanUnitWithProrationPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanUnitWithProrationPrice.kt index e3c420a6a..287164cff 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanUnitWithProrationPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanUnitWithProrationPrice.kt @@ -126,6 +126,8 @@ private constructor( fun itemId(): String = itemId.getRequired("item_id") /** + * The pricing model type + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ @@ -140,6 +142,8 @@ private constructor( fun name(): String = name.getRequired("name") /** + * Configuration for unit_with_proration pricing + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ @@ -522,6 +526,7 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + /** The pricing model type */ fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) /** @@ -544,6 +549,7 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } + /** Configuration for unit_with_proration pricing */ fun unitWithProrationConfig(unitWithProrationConfig: UnitWithProrationConfig) = unitWithProrationConfig(JsonField.of(unitWithProrationConfig)) @@ -1097,6 +1103,7 @@ private constructor( override fun toString() = value.toString() } + /** The pricing model type */ class ModelType @JsonCreator private constructor(private val value: JsonField) : Enum { /** @@ -1217,16 +1224,46 @@ private constructor( override fun toString() = value.toString() } + /** Configuration for unit_with_proration pricing */ class UnitWithProrationConfig - @JsonCreator private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, ) { + @JsonCreator + private constructor( + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of() + ) : this(unitAmount, mutableMapOf()) + + /** + * Rate per unit of usage + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) fun toBuilder() = Builder().from(this) @@ -1234,6 +1271,11 @@ private constructor( /** * Returns a mutable builder for constructing an instance of [UnitWithProrationConfig]. + * + * The following fields are required: + * ```kotlin + * .unitAmount() + * ``` */ fun builder() = Builder() } @@ -1241,12 +1283,26 @@ private constructor( /** A builder for [UnitWithProrationConfig]. */ class Builder internal constructor() { + private var unitAmount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(unitWithProrationConfig: UnitWithProrationConfig) = apply { + unitAmount = unitWithProrationConfig.unitAmount additionalProperties = unitWithProrationConfig.additionalProperties.toMutableMap() } + /** Rate per unit of usage */ + fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { this.unitAmount = unitAmount } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -1270,9 +1326,19 @@ private constructor( * Returns an immutable instance of [UnitWithProrationConfig]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ fun build(): UnitWithProrationConfig = - UnitWithProrationConfig(additionalProperties.toImmutable()) + UnitWithProrationConfig( + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false @@ -1282,6 +1348,7 @@ private constructor( return@apply } + unitAmount() validated = true } @@ -1299,8 +1366,7 @@ private constructor( * * Used for best match union deserialization. */ - internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + internal fun validity(): Int = (if (unitAmount.asKnown() == null) 0 else 1) override fun equals(other: Any?): Boolean { if (this === other) { @@ -1308,15 +1374,16 @@ private constructor( } return other is UnitWithProrationConfig && + unitAmount == other.unitAmount && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(unitAmount, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "UnitWithProrationConfig{additionalProperties=$additionalProperties}" + "UnitWithProrationConfig{unitAmount=$unitAmount, additionalProperties=$additionalProperties}" } /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionBulkPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionBulkPrice.kt index 8a5648595..5a07abc42 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionBulkPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionBulkPrice.kt @@ -110,6 +110,8 @@ private constructor( ) /** + * Configuration for bulk pricing + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ @@ -132,6 +134,8 @@ private constructor( fun itemId(): String = itemId.getRequired("item_id") /** + * The pricing model type + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ @@ -496,6 +500,7 @@ private constructor( additionalProperties = newSubscriptionBulkPrice.additionalProperties.toMutableMap() } + /** Configuration for bulk pricing */ fun bulkConfig(bulkConfig: BulkConfig) = bulkConfig(JsonField.of(bulkConfig)) /** @@ -529,6 +534,7 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + /** The pricing model type */ fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) /** @@ -1089,6 +1095,7 @@ private constructor( override fun toString() = value.toString() } + /** The pricing model type */ class ModelType @JsonCreator private constructor(private val value: JsonField) : Enum { /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionBulkWithProrationPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionBulkWithProrationPrice.kt index 4a8bfcc50..dffafead4 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionBulkWithProrationPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionBulkWithProrationPrice.kt @@ -11,6 +11,7 @@ import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue +import com.withorb.api.core.checkKnown import com.withorb.api.core.checkRequired import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException @@ -110,6 +111,8 @@ private constructor( ) /** + * Configuration for bulk_with_proration pricing + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ @@ -133,6 +136,8 @@ private constructor( fun itemId(): String = itemId.getRequired("item_id") /** + * The pricing model type + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ @@ -505,6 +510,7 @@ private constructor( newSubscriptionBulkWithProrationPrice.additionalProperties.toMutableMap() } + /** Configuration for bulk_with_proration pricing */ fun bulkWithProrationConfig(bulkWithProrationConfig: BulkWithProrationConfig) = bulkWithProrationConfig(JsonField.of(bulkWithProrationConfig)) @@ -542,6 +548,7 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + /** The pricing model type */ fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) /** @@ -953,16 +960,42 @@ private constructor( (metadata.asKnown()?.validity() ?: 0) + (if (referenceId.asKnown() == null) 0 else 1) + /** Configuration for bulk_with_proration pricing */ class BulkWithProrationConfig - @JsonCreator private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map + private val tiers: JsonField>, + private val additionalProperties: MutableMap, ) { + @JsonCreator + private constructor( + @JsonProperty("tiers") @ExcludeMissing tiers: JsonField> = JsonMissing.of() + ) : this(tiers, mutableMapOf()) + + /** + * Bulk tiers for rating based on total usage volume + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun tiers(): List = tiers.getRequired("tiers") + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tiers") @ExcludeMissing fun _tiers(): JsonField> = tiers + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) fun toBuilder() = Builder().from(this) @@ -970,6 +1003,11 @@ private constructor( /** * Returns a mutable builder for constructing an instance of [BulkWithProrationConfig]. + * + * The following fields are required: + * ```kotlin + * .tiers() + * ``` */ fun builder() = Builder() } @@ -977,12 +1015,40 @@ private constructor( /** A builder for [BulkWithProrationConfig]. */ class Builder internal constructor() { + private var tiers: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(bulkWithProrationConfig: BulkWithProrationConfig) = apply { + tiers = bulkWithProrationConfig.tiers.map { it.toMutableList() } additionalProperties = bulkWithProrationConfig.additionalProperties.toMutableMap() } + /** Bulk tiers for rating based on total usage volume */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -1006,9 +1072,19 @@ private constructor( * Returns an immutable instance of [BulkWithProrationConfig]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ fun build(): BulkWithProrationConfig = - BulkWithProrationConfig(additionalProperties.toImmutable()) + BulkWithProrationConfig( + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false @@ -1018,6 +1094,7 @@ private constructor( return@apply } + tiers().forEach { it.validate() } validated = true } @@ -1035,8 +1112,222 @@ private constructor( * * Used for best match union deserialization. */ - internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + internal fun validity(): Int = (tiers.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single bulk pricing tier with proration */ + class Tier + private constructor( + private val unitAmount: JsonField, + private val tierLowerBound: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + ) : this(unitAmount, tierLowerBound, mutableMapOf()) + + /** + * Cost per unit + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * The lower bound for this tier + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun tierLowerBound(): String? = tierLowerBound.getNullable("tier_lower_bound") + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Tier]. + * + * The following fields are required: + * ```kotlin + * .unitAmount() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var unitAmount: JsonField? = null + private var tierLowerBound: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(tier: Tier) = apply { + unitAmount = tier.unitAmount + tierLowerBound = tier.tierLowerBound + additionalProperties = tier.additionalProperties.toMutableMap() + } + + /** Cost per unit */ + fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + /** The lower bound for this tier */ + fun tierLowerBound(tierLowerBound: String?) = + tierLowerBound(JsonField.ofNullable(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Tier]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("unitAmount", unitAmount), + tierLowerBound, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + unitAmount() + tierLowerBound() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (unitAmount.asKnown() == null) 0 else 1) + + (if (tierLowerBound.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + unitAmount == other.unitAmount && + tierLowerBound == other.tierLowerBound && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(unitAmount, tierLowerBound, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{unitAmount=$unitAmount, tierLowerBound=$tierLowerBound, additionalProperties=$additionalProperties}" + } override fun equals(other: Any?): Boolean { if (this === other) { @@ -1044,15 +1335,16 @@ private constructor( } return other is BulkWithProrationConfig && + tiers == other.tiers && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(tiers, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "BulkWithProrationConfig{additionalProperties=$additionalProperties}" + "BulkWithProrationConfig{tiers=$tiers, additionalProperties=$additionalProperties}" } /** The cadence to bill for this price on. */ @@ -1204,6 +1496,7 @@ private constructor( override fun toString() = value.toString() } + /** The pricing model type */ class ModelType @JsonCreator private constructor(private val value: JsonField) : Enum { /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionCumulativeGroupedBulkPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionCumulativeGroupedBulkPrice.kt index 793384cd9..089f4741b 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionCumulativeGroupedBulkPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionCumulativeGroupedBulkPrice.kt @@ -11,6 +11,7 @@ import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue +import com.withorb.api.core.checkKnown import com.withorb.api.core.checkRequired import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException @@ -118,6 +119,8 @@ private constructor( fun cadence(): Cadence = cadence.getRequired("cadence") /** + * Configuration for cumulative_grouped_bulk pricing + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ @@ -133,6 +136,8 @@ private constructor( fun itemId(): String = itemId.getRequired("item_id") /** + * The pricing model type + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ @@ -518,6 +523,7 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + /** Configuration for cumulative_grouped_bulk pricing */ fun cumulativeGroupedBulkConfig(cumulativeGroupedBulkConfig: CumulativeGroupedBulkConfig) = cumulativeGroupedBulkConfig(JsonField.of(cumulativeGroupedBulkConfig)) @@ -543,6 +549,7 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + /** The pricing model type */ fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) /** @@ -1103,16 +1110,65 @@ private constructor( override fun toString() = value.toString() } + /** Configuration for cumulative_grouped_bulk pricing */ class CumulativeGroupedBulkConfig - @JsonCreator private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map + private val dimensionValues: JsonField>, + private val group: JsonField, + private val additionalProperties: MutableMap, ) { + @JsonCreator + private constructor( + @JsonProperty("dimension_values") + @ExcludeMissing + dimensionValues: JsonField> = JsonMissing.of(), + @JsonProperty("group") @ExcludeMissing group: JsonField = JsonMissing.of(), + ) : this(dimensionValues, group, mutableMapOf()) + + /** + * Each tier lower bound must have the same group of values. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun dimensionValues(): List = + dimensionValues.getRequired("dimension_values") + + /** + * Grouping key name + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun group(): String = group.getRequired("group") + + /** + * Returns the raw JSON value of [dimensionValues]. + * + * Unlike [dimensionValues], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("dimension_values") + @ExcludeMissing + fun _dimensionValues(): JsonField> = dimensionValues + + /** + * Returns the raw JSON value of [group]. + * + * Unlike [group], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("group") @ExcludeMissing fun _group(): JsonField = group + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) fun toBuilder() = Builder().from(this) @@ -1121,6 +1177,12 @@ private constructor( /** * Returns a mutable builder for constructing an instance of * [CumulativeGroupedBulkConfig]. + * + * The following fields are required: + * ```kotlin + * .dimensionValues() + * .group() + * ``` */ fun builder() = Builder() } @@ -1128,13 +1190,57 @@ private constructor( /** A builder for [CumulativeGroupedBulkConfig]. */ class Builder internal constructor() { + private var dimensionValues: JsonField>? = null + private var group: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(cumulativeGroupedBulkConfig: CumulativeGroupedBulkConfig) = apply { + dimensionValues = + cumulativeGroupedBulkConfig.dimensionValues.map { it.toMutableList() } + group = cumulativeGroupedBulkConfig.group additionalProperties = cumulativeGroupedBulkConfig.additionalProperties.toMutableMap() } + /** Each tier lower bound must have the same group of values. */ + fun dimensionValues(dimensionValues: List) = + dimensionValues(JsonField.of(dimensionValues)) + + /** + * Sets [Builder.dimensionValues] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionValues] with a well-typed + * `List` value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun dimensionValues(dimensionValues: JsonField>) = apply { + this.dimensionValues = dimensionValues.map { it.toMutableList() } + } + + /** + * Adds a single [DimensionValue] to [dimensionValues]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addDimensionValue(dimensionValue: DimensionValue) = apply { + dimensionValues = + (dimensionValues ?: JsonField.of(mutableListOf())).also { + checkKnown("dimensionValues", it).add(dimensionValue) + } + } + + /** Grouping key name */ + fun group(group: String) = group(JsonField.of(group)) + + /** + * Sets [Builder.group] to an arbitrary JSON value. + * + * You should usually call [Builder.group] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun group(group: JsonField) = apply { this.group = group } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -1158,9 +1264,21 @@ private constructor( * Returns an immutable instance of [CumulativeGroupedBulkConfig]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .dimensionValues() + * .group() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ fun build(): CumulativeGroupedBulkConfig = - CumulativeGroupedBulkConfig(additionalProperties.toImmutable()) + CumulativeGroupedBulkConfig( + checkRequired("dimensionValues", dimensionValues).map { it.toImmutable() }, + checkRequired("group", group), + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false @@ -1170,6 +1288,8 @@ private constructor( return@apply } + dimensionValues().forEach { it.validate() } + group() validated = true } @@ -1188,7 +1308,271 @@ private constructor( * Used for best match union deserialization. */ internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + (dimensionValues.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + (if (group.asKnown() == null) 0 else 1) + + /** Configuration for a dimension value entry */ + class DimensionValue + private constructor( + private val groupingKey: JsonField, + private val tierLowerBound: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(groupingKey, tierLowerBound, unitAmount, mutableMapOf()) + + /** + * Grouping key value + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * Tier lower bound + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun tierLowerBound(): String = tierLowerBound.getRequired("tier_lower_bound") + + /** + * Unit amount for this combination + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [DimensionValue]. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .tierLowerBound() + * .unitAmount() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [DimensionValue]. */ + class Builder internal constructor() { + + private var groupingKey: JsonField? = null + private var tierLowerBound: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(dimensionValue: DimensionValue) = apply { + groupingKey = dimensionValue.groupingKey + tierLowerBound = dimensionValue.tierLowerBound + unitAmount = dimensionValue.unitAmount + additionalProperties = dimensionValue.additionalProperties.toMutableMap() + } + + /** Grouping key value */ + fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** Tier lower bound */ + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + /** Unit amount for this combination */ + fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [DimensionValue]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .tierLowerBound() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): DimensionValue = + DimensionValue( + checkRequired("groupingKey", groupingKey), + checkRequired("tierLowerBound", tierLowerBound), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): DimensionValue = apply { + if (validated) { + return@apply + } + + groupingKey() + tierLowerBound() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (groupingKey.asKnown() == null) 0 else 1) + + (if (tierLowerBound.asKnown() == null) 0 else 1) + + (if (unitAmount.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is DimensionValue && + groupingKey == other.groupingKey && + tierLowerBound == other.tierLowerBound && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(groupingKey, tierLowerBound, unitAmount, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "DimensionValue{groupingKey=$groupingKey, tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } override fun equals(other: Any?): Boolean { if (this === other) { @@ -1196,17 +1580,22 @@ private constructor( } return other is CumulativeGroupedBulkConfig && + dimensionValues == other.dimensionValues && + group == other.group && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + private val hashCode: Int by lazy { + Objects.hash(dimensionValues, group, additionalProperties) + } override fun hashCode(): Int = hashCode override fun toString() = - "CumulativeGroupedBulkConfig{additionalProperties=$additionalProperties}" + "CumulativeGroupedBulkConfig{dimensionValues=$dimensionValues, group=$group, additionalProperties=$additionalProperties}" } + /** The pricing model type */ class ModelType @JsonCreator private constructor(private val value: JsonField) : Enum { /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionGroupedAllocationPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionGroupedAllocationPrice.kt index 24505a30b..15750b2a7 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionGroupedAllocationPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionGroupedAllocationPrice.kt @@ -118,6 +118,8 @@ private constructor( fun cadence(): Cadence = cadence.getRequired("cadence") /** + * Configuration for grouped_allocation pricing + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ @@ -133,6 +135,8 @@ private constructor( fun itemId(): String = itemId.getRequired("item_id") /** + * The pricing model type + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ @@ -516,6 +520,7 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + /** Configuration for grouped_allocation pricing */ fun groupedAllocationConfig(groupedAllocationConfig: GroupedAllocationConfig) = groupedAllocationConfig(JsonField.of(groupedAllocationConfig)) @@ -542,6 +547,7 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + /** The pricing model type */ fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) /** @@ -1102,16 +1108,89 @@ private constructor( override fun toString() = value.toString() } + /** Configuration for grouped_allocation pricing */ class GroupedAllocationConfig - @JsonCreator private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map + private val allocation: JsonField, + private val groupingKey: JsonField, + private val overageUnitRate: JsonField, + private val additionalProperties: MutableMap, ) { + @JsonCreator + private constructor( + @JsonProperty("allocation") + @ExcludeMissing + allocation: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("overage_unit_rate") + @ExcludeMissing + overageUnitRate: JsonField = JsonMissing.of(), + ) : this(allocation, groupingKey, overageUnitRate, mutableMapOf()) + + /** + * Usage allocation per group + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun allocation(): String = allocation.getRequired("allocation") + + /** + * How to determine the groups that should each be allocated some quantity + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * Unit rate for post-allocation + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun overageUnitRate(): String = overageUnitRate.getRequired("overage_unit_rate") + + /** + * Returns the raw JSON value of [allocation]. + * + * Unlike [allocation], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("allocation") + @ExcludeMissing + fun _allocation(): JsonField = allocation + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [overageUnitRate]. + * + * Unlike [overageUnitRate], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("overage_unit_rate") + @ExcludeMissing + fun _overageUnitRate(): JsonField = overageUnitRate + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) fun toBuilder() = Builder().from(this) @@ -1119,6 +1198,13 @@ private constructor( /** * Returns a mutable builder for constructing an instance of [GroupedAllocationConfig]. + * + * The following fields are required: + * ```kotlin + * .allocation() + * .groupingKey() + * .overageUnitRate() + * ``` */ fun builder() = Builder() } @@ -1126,12 +1212,59 @@ private constructor( /** A builder for [GroupedAllocationConfig]. */ class Builder internal constructor() { + private var allocation: JsonField? = null + private var groupingKey: JsonField? = null + private var overageUnitRate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(groupedAllocationConfig: GroupedAllocationConfig) = apply { + allocation = groupedAllocationConfig.allocation + groupingKey = groupedAllocationConfig.groupingKey + overageUnitRate = groupedAllocationConfig.overageUnitRate additionalProperties = groupedAllocationConfig.additionalProperties.toMutableMap() } + /** Usage allocation per group */ + fun allocation(allocation: String) = allocation(JsonField.of(allocation)) + + /** + * Sets [Builder.allocation] to an arbitrary JSON value. + * + * You should usually call [Builder.allocation] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun allocation(allocation: JsonField) = apply { this.allocation = allocation } + + /** How to determine the groups that should each be allocated some quantity */ + fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** Unit rate for post-allocation */ + fun overageUnitRate(overageUnitRate: String) = + overageUnitRate(JsonField.of(overageUnitRate)) + + /** + * Sets [Builder.overageUnitRate] to an arbitrary JSON value. + * + * You should usually call [Builder.overageUnitRate] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun overageUnitRate(overageUnitRate: JsonField) = apply { + this.overageUnitRate = overageUnitRate + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -1155,9 +1288,23 @@ private constructor( * Returns an immutable instance of [GroupedAllocationConfig]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .allocation() + * .groupingKey() + * .overageUnitRate() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ fun build(): GroupedAllocationConfig = - GroupedAllocationConfig(additionalProperties.toImmutable()) + GroupedAllocationConfig( + checkRequired("allocation", allocation), + checkRequired("groupingKey", groupingKey), + checkRequired("overageUnitRate", overageUnitRate), + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false @@ -1167,6 +1314,9 @@ private constructor( return@apply } + allocation() + groupingKey() + overageUnitRate() validated = true } @@ -1185,7 +1335,9 @@ private constructor( * Used for best match union deserialization. */ internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + (if (allocation.asKnown() == null) 0 else 1) + + (if (groupingKey.asKnown() == null) 0 else 1) + + (if (overageUnitRate.asKnown() == null) 0 else 1) override fun equals(other: Any?): Boolean { if (this === other) { @@ -1193,17 +1345,23 @@ private constructor( } return other is GroupedAllocationConfig && + allocation == other.allocation && + groupingKey == other.groupingKey && + overageUnitRate == other.overageUnitRate && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + private val hashCode: Int by lazy { + Objects.hash(allocation, groupingKey, overageUnitRate, additionalProperties) + } override fun hashCode(): Int = hashCode override fun toString() = - "GroupedAllocationConfig{additionalProperties=$additionalProperties}" + "GroupedAllocationConfig{allocation=$allocation, groupingKey=$groupingKey, overageUnitRate=$overageUnitRate, additionalProperties=$additionalProperties}" } + /** The pricing model type */ class ModelType @JsonCreator private constructor(private val value: JsonField) : Enum { /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionGroupedTieredPackagePrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionGroupedTieredPackagePrice.kt index 92d1725a3..41f69acb5 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionGroupedTieredPackagePrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionGroupedTieredPackagePrice.kt @@ -11,6 +11,7 @@ import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue +import com.withorb.api.core.checkKnown import com.withorb.api.core.checkRequired import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException @@ -118,6 +119,8 @@ private constructor( fun cadence(): Cadence = cadence.getRequired("cadence") /** + * Configuration for grouped_tiered_package pricing + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ @@ -133,6 +136,8 @@ private constructor( fun itemId(): String = itemId.getRequired("item_id") /** + * The pricing model type + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ @@ -518,6 +523,7 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + /** Configuration for grouped_tiered_package pricing */ fun groupedTieredPackageConfig(groupedTieredPackageConfig: GroupedTieredPackageConfig) = groupedTieredPackageConfig(JsonField.of(groupedTieredPackageConfig)) @@ -543,6 +549,7 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + /** The pricing model type */ fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) /** @@ -1103,16 +1110,85 @@ private constructor( override fun toString() = value.toString() } + /** Configuration for grouped_tiered_package pricing */ class GroupedTieredPackageConfig - @JsonCreator private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map + private val groupingKey: JsonField, + private val packageSize: JsonField, + private val tiers: JsonField>, + private val additionalProperties: MutableMap, ) { + @JsonCreator + private constructor( + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("package_size") + @ExcludeMissing + packageSize: JsonField = JsonMissing.of(), + @JsonProperty("tiers") @ExcludeMissing tiers: JsonField> = JsonMissing.of(), + ) : this(groupingKey, packageSize, tiers, mutableMapOf()) + + /** + * The event property used to group before tiering + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * Package size + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun packageSize(): String = packageSize.getRequired("package_size") + + /** + * Apply tiered pricing after rounding up the quantity to the package size. Tiers are + * defined using exclusive lower bounds. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun tiers(): List = tiers.getRequired("tiers") + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [packageSize]. + * + * Unlike [packageSize], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("package_size") + @ExcludeMissing + fun _packageSize(): JsonField = packageSize + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tiers") @ExcludeMissing fun _tiers(): JsonField> = tiers + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) fun toBuilder() = Builder().from(this) @@ -1121,6 +1197,13 @@ private constructor( /** * Returns a mutable builder for constructing an instance of * [GroupedTieredPackageConfig]. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .packageSize() + * .tiers() + * ``` */ fun builder() = Builder() } @@ -1128,13 +1211,76 @@ private constructor( /** A builder for [GroupedTieredPackageConfig]. */ class Builder internal constructor() { + private var groupingKey: JsonField? = null + private var packageSize: JsonField? = null + private var tiers: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(groupedTieredPackageConfig: GroupedTieredPackageConfig) = apply { + groupingKey = groupedTieredPackageConfig.groupingKey + packageSize = groupedTieredPackageConfig.packageSize + tiers = groupedTieredPackageConfig.tiers.map { it.toMutableList() } additionalProperties = groupedTieredPackageConfig.additionalProperties.toMutableMap() } + /** The event property used to group before tiering */ + fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** Package size */ + fun packageSize(packageSize: String) = packageSize(JsonField.of(packageSize)) + + /** + * Sets [Builder.packageSize] to an arbitrary JSON value. + * + * You should usually call [Builder.packageSize] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun packageSize(packageSize: JsonField) = apply { + this.packageSize = packageSize + } + + /** + * Apply tiered pricing after rounding up the quantity to the package size. Tiers are + * defined using exclusive lower bounds. + */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -1158,9 +1304,23 @@ private constructor( * Returns an immutable instance of [GroupedTieredPackageConfig]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .packageSize() + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ fun build(): GroupedTieredPackageConfig = - GroupedTieredPackageConfig(additionalProperties.toImmutable()) + GroupedTieredPackageConfig( + checkRequired("groupingKey", groupingKey), + checkRequired("packageSize", packageSize), + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false @@ -1170,6 +1330,9 @@ private constructor( return@apply } + groupingKey() + packageSize() + tiers().forEach { it.validate() } validated = true } @@ -1188,7 +1351,222 @@ private constructor( * Used for best match union deserialization. */ internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + (if (groupingKey.asKnown() == null) 0 else 1) + + (if (packageSize.asKnown() == null) 0 else 1) + + (tiers.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single tier */ + class Tier + private constructor( + private val perUnit: JsonField, + private val tierLowerBound: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("per_unit") + @ExcludeMissing + perUnit: JsonField = JsonMissing.of(), + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + ) : this(perUnit, tierLowerBound, mutableMapOf()) + + /** + * Price per package + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun perUnit(): String = perUnit.getRequired("per_unit") + + /** + * Tier lower bound + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun tierLowerBound(): String = tierLowerBound.getRequired("tier_lower_bound") + + /** + * Returns the raw JSON value of [perUnit]. + * + * Unlike [perUnit], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("per_unit") @ExcludeMissing fun _perUnit(): JsonField = perUnit + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Tier]. + * + * The following fields are required: + * ```kotlin + * .perUnit() + * .tierLowerBound() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var perUnit: JsonField? = null + private var tierLowerBound: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(tier: Tier) = apply { + perUnit = tier.perUnit + tierLowerBound = tier.tierLowerBound + additionalProperties = tier.additionalProperties.toMutableMap() + } + + /** Price per package */ + fun perUnit(perUnit: String) = perUnit(JsonField.of(perUnit)) + + /** + * Sets [Builder.perUnit] to an arbitrary JSON value. + * + * You should usually call [Builder.perUnit] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun perUnit(perUnit: JsonField) = apply { this.perUnit = perUnit } + + /** Tier lower bound */ + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Tier]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .perUnit() + * .tierLowerBound() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("perUnit", perUnit), + checkRequired("tierLowerBound", tierLowerBound), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + perUnit() + tierLowerBound() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (perUnit.asKnown() == null) 0 else 1) + + (if (tierLowerBound.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + perUnit == other.perUnit && + tierLowerBound == other.tierLowerBound && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(perUnit, tierLowerBound, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{perUnit=$perUnit, tierLowerBound=$tierLowerBound, additionalProperties=$additionalProperties}" + } override fun equals(other: Any?): Boolean { if (this === other) { @@ -1196,17 +1574,23 @@ private constructor( } return other is GroupedTieredPackageConfig && + groupingKey == other.groupingKey && + packageSize == other.packageSize && + tiers == other.tiers && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + private val hashCode: Int by lazy { + Objects.hash(groupingKey, packageSize, tiers, additionalProperties) + } override fun hashCode(): Int = hashCode override fun toString() = - "GroupedTieredPackageConfig{additionalProperties=$additionalProperties}" + "GroupedTieredPackageConfig{groupingKey=$groupingKey, packageSize=$packageSize, tiers=$tiers, additionalProperties=$additionalProperties}" } + /** The pricing model type */ class ModelType @JsonCreator private constructor(private val value: JsonField) : Enum { /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionGroupedTieredPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionGroupedTieredPrice.kt index a18b5613a..b40665d23 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionGroupedTieredPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionGroupedTieredPrice.kt @@ -11,6 +11,7 @@ import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue +import com.withorb.api.core.checkKnown import com.withorb.api.core.checkRequired import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException @@ -118,6 +119,8 @@ private constructor( fun cadence(): Cadence = cadence.getRequired("cadence") /** + * Configuration for grouped_tiered pricing + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ @@ -133,6 +136,8 @@ private constructor( fun itemId(): String = itemId.getRequired("item_id") /** + * The pricing model type + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ @@ -515,6 +520,7 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + /** Configuration for grouped_tiered pricing */ fun groupedTieredConfig(groupedTieredConfig: GroupedTieredConfig) = groupedTieredConfig(JsonField.of(groupedTieredConfig)) @@ -540,6 +546,7 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + /** The pricing model type */ fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) /** @@ -1100,34 +1107,135 @@ private constructor( override fun toString() = value.toString() } + /** Configuration for grouped_tiered pricing */ class GroupedTieredConfig - @JsonCreator private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map + private val groupingKey: JsonField, + private val tiers: JsonField>, + private val additionalProperties: MutableMap, ) { + @JsonCreator + private constructor( + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("tiers") @ExcludeMissing tiers: JsonField> = JsonMissing.of(), + ) : this(groupingKey, tiers, mutableMapOf()) + + /** + * The billable metric property used to group before tiering + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * Apply tiered pricing to each segment generated after grouping with the provided key + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun tiers(): List = tiers.getRequired("tiers") + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tiers") @ExcludeMissing fun _tiers(): JsonField> = tiers + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) fun toBuilder() = Builder().from(this) companion object { - /** Returns a mutable builder for constructing an instance of [GroupedTieredConfig]. */ + /** + * Returns a mutable builder for constructing an instance of [GroupedTieredConfig]. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .tiers() + * ``` + */ fun builder() = Builder() } /** A builder for [GroupedTieredConfig]. */ class Builder internal constructor() { + private var groupingKey: JsonField? = null + private var tiers: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(groupedTieredConfig: GroupedTieredConfig) = apply { + groupingKey = groupedTieredConfig.groupingKey + tiers = groupedTieredConfig.tiers.map { it.toMutableList() } additionalProperties = groupedTieredConfig.additionalProperties.toMutableMap() } + /** The billable metric property used to group before tiering */ + fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** + * Apply tiered pricing to each segment generated after grouping with the provided key + */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -1151,9 +1259,21 @@ private constructor( * Returns an immutable instance of [GroupedTieredConfig]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ fun build(): GroupedTieredConfig = - GroupedTieredConfig(additionalProperties.toImmutable()) + GroupedTieredConfig( + checkRequired("groupingKey", groupingKey), + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false @@ -1163,6 +1283,8 @@ private constructor( return@apply } + groupingKey() + tiers().forEach { it.validate() } validated = true } @@ -1181,7 +1303,226 @@ private constructor( * Used for best match union deserialization. */ internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + (if (groupingKey.asKnown() == null) 0 else 1) + + (tiers.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single tier */ + class Tier + private constructor( + private val tierLowerBound: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(tierLowerBound, unitAmount, mutableMapOf()) + + /** + * Tier lower bound + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun tierLowerBound(): String = tierLowerBound.getRequired("tier_lower_bound") + + /** + * Per unit amount + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Tier]. + * + * The following fields are required: + * ```kotlin + * .tierLowerBound() + * .unitAmount() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var tierLowerBound: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(tier: Tier) = apply { + tierLowerBound = tier.tierLowerBound + unitAmount = tier.unitAmount + additionalProperties = tier.additionalProperties.toMutableMap() + } + + /** Tier lower bound */ + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + /** Per unit amount */ + fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Tier]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .tierLowerBound() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("tierLowerBound", tierLowerBound), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + tierLowerBound() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (tierLowerBound.asKnown() == null) 0 else 1) + + (if (unitAmount.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + tierLowerBound == other.tierLowerBound && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(tierLowerBound, unitAmount, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } override fun equals(other: Any?): Boolean { if (this === other) { @@ -1189,16 +1530,20 @@ private constructor( } return other is GroupedTieredConfig && + groupingKey == other.groupingKey && + tiers == other.tiers && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(groupingKey, tiers, additionalProperties) } override fun hashCode(): Int = hashCode - override fun toString() = "GroupedTieredConfig{additionalProperties=$additionalProperties}" + override fun toString() = + "GroupedTieredConfig{groupingKey=$groupingKey, tiers=$tiers, additionalProperties=$additionalProperties}" } + /** The pricing model type */ class ModelType @JsonCreator private constructor(private val value: JsonField) : Enum { /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionGroupedWithMeteredMinimumPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionGroupedWithMeteredMinimumPrice.kt index adf0df789..1c18ffe36 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionGroupedWithMeteredMinimumPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionGroupedWithMeteredMinimumPrice.kt @@ -11,6 +11,7 @@ import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue +import com.withorb.api.core.checkKnown import com.withorb.api.core.checkRequired import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException @@ -119,6 +120,8 @@ private constructor( fun cadence(): Cadence = cadence.getRequired("cadence") /** + * Configuration for grouped_with_metered_minimum pricing + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ @@ -134,6 +137,8 @@ private constructor( fun itemId(): String = itemId.getRequired("item_id") /** + * The pricing model type + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ @@ -522,6 +527,7 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + /** Configuration for grouped_with_metered_minimum pricing */ fun groupedWithMeteredMinimumConfig( groupedWithMeteredMinimumConfig: GroupedWithMeteredMinimumConfig ) = groupedWithMeteredMinimumConfig(JsonField.of(groupedWithMeteredMinimumConfig)) @@ -548,6 +554,7 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + /** The pricing model type */ fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) /** @@ -1108,16 +1115,162 @@ private constructor( override fun toString() = value.toString() } + /** Configuration for grouped_with_metered_minimum pricing */ class GroupedWithMeteredMinimumConfig - @JsonCreator private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map + private val groupingKey: JsonField, + private val minimumUnitAmount: JsonField, + private val pricingKey: JsonField, + private val scalingFactors: JsonField>, + private val scalingKey: JsonField, + private val unitAmounts: JsonField>, + private val additionalProperties: MutableMap, ) { + @JsonCreator + private constructor( + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("minimum_unit_amount") + @ExcludeMissing + minimumUnitAmount: JsonField = JsonMissing.of(), + @JsonProperty("pricing_key") + @ExcludeMissing + pricingKey: JsonField = JsonMissing.of(), + @JsonProperty("scaling_factors") + @ExcludeMissing + scalingFactors: JsonField> = JsonMissing.of(), + @JsonProperty("scaling_key") + @ExcludeMissing + scalingKey: JsonField = JsonMissing.of(), + @JsonProperty("unit_amounts") + @ExcludeMissing + unitAmounts: JsonField> = JsonMissing.of(), + ) : this( + groupingKey, + minimumUnitAmount, + pricingKey, + scalingFactors, + scalingKey, + unitAmounts, + mutableMapOf(), + ) + + /** + * Used to partition the usage into groups. The minimum amount is applied to each group. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The minimum amount to charge per group per unit + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun minimumUnitAmount(): String = minimumUnitAmount.getRequired("minimum_unit_amount") + + /** + * Used to determine the unit rate + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun pricingKey(): String = pricingKey.getRequired("pricing_key") + + /** + * Scale the unit rates by the scaling factor. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun scalingFactors(): List = scalingFactors.getRequired("scaling_factors") + + /** + * Used to determine the unit rate scaling factor + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun scalingKey(): String = scalingKey.getRequired("scaling_key") + + /** + * Apply per unit pricing to each pricing value. The minimum amount is applied any unmatched + * usage. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun unitAmounts(): List = unitAmounts.getRequired("unit_amounts") + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [minimumUnitAmount]. + * + * Unlike [minimumUnitAmount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("minimum_unit_amount") + @ExcludeMissing + fun _minimumUnitAmount(): JsonField = minimumUnitAmount + + /** + * Returns the raw JSON value of [pricingKey]. + * + * Unlike [pricingKey], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("pricing_key") + @ExcludeMissing + fun _pricingKey(): JsonField = pricingKey + + /** + * Returns the raw JSON value of [scalingFactors]. + * + * Unlike [scalingFactors], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("scaling_factors") + @ExcludeMissing + fun _scalingFactors(): JsonField> = scalingFactors + + /** + * Returns the raw JSON value of [scalingKey]. + * + * Unlike [scalingKey], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("scaling_key") + @ExcludeMissing + fun _scalingKey(): JsonField = scalingKey + + /** + * Returns the raw JSON value of [unitAmounts]. + * + * Unlike [unitAmounts], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("unit_amounts") + @ExcludeMissing + fun _unitAmounts(): JsonField> = unitAmounts + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) fun toBuilder() = Builder().from(this) @@ -1126,6 +1279,16 @@ private constructor( /** * Returns a mutable builder for constructing an instance of * [GroupedWithMeteredMinimumConfig]. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .minimumUnitAmount() + * .pricingKey() + * .scalingFactors() + * .scalingKey() + * .unitAmounts() + * ``` */ fun builder() = Builder() } @@ -1133,14 +1296,139 @@ private constructor( /** A builder for [GroupedWithMeteredMinimumConfig]. */ class Builder internal constructor() { + private var groupingKey: JsonField? = null + private var minimumUnitAmount: JsonField? = null + private var pricingKey: JsonField? = null + private var scalingFactors: JsonField>? = null + private var scalingKey: JsonField? = null + private var unitAmounts: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(groupedWithMeteredMinimumConfig: GroupedWithMeteredMinimumConfig) = apply { + groupingKey = groupedWithMeteredMinimumConfig.groupingKey + minimumUnitAmount = groupedWithMeteredMinimumConfig.minimumUnitAmount + pricingKey = groupedWithMeteredMinimumConfig.pricingKey + scalingFactors = + groupedWithMeteredMinimumConfig.scalingFactors.map { it.toMutableList() } + scalingKey = groupedWithMeteredMinimumConfig.scalingKey + unitAmounts = + groupedWithMeteredMinimumConfig.unitAmounts.map { it.toMutableList() } additionalProperties = groupedWithMeteredMinimumConfig.additionalProperties.toMutableMap() } + /** + * Used to partition the usage into groups. The minimum amount is applied to each group. + */ + fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The minimum amount to charge per group per unit */ + fun minimumUnitAmount(minimumUnitAmount: String) = + minimumUnitAmount(JsonField.of(minimumUnitAmount)) + + /** + * Sets [Builder.minimumUnitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumUnitAmount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun minimumUnitAmount(minimumUnitAmount: JsonField) = apply { + this.minimumUnitAmount = minimumUnitAmount + } + + /** Used to determine the unit rate */ + fun pricingKey(pricingKey: String) = pricingKey(JsonField.of(pricingKey)) + + /** + * Sets [Builder.pricingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.pricingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun pricingKey(pricingKey: JsonField) = apply { this.pricingKey = pricingKey } + + /** Scale the unit rates by the scaling factor. */ + fun scalingFactors(scalingFactors: List) = + scalingFactors(JsonField.of(scalingFactors)) + + /** + * Sets [Builder.scalingFactors] to an arbitrary JSON value. + * + * You should usually call [Builder.scalingFactors] with a well-typed + * `List` value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun scalingFactors(scalingFactors: JsonField>) = apply { + this.scalingFactors = scalingFactors.map { it.toMutableList() } + } + + /** + * Adds a single [ScalingFactor] to [scalingFactors]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addScalingFactor(scalingFactor: ScalingFactor) = apply { + scalingFactors = + (scalingFactors ?: JsonField.of(mutableListOf())).also { + checkKnown("scalingFactors", it).add(scalingFactor) + } + } + + /** Used to determine the unit rate scaling factor */ + fun scalingKey(scalingKey: String) = scalingKey(JsonField.of(scalingKey)) + + /** + * Sets [Builder.scalingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.scalingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun scalingKey(scalingKey: JsonField) = apply { this.scalingKey = scalingKey } + + /** + * Apply per unit pricing to each pricing value. The minimum amount is applied any + * unmatched usage. + */ + fun unitAmounts(unitAmounts: List) = unitAmounts(JsonField.of(unitAmounts)) + + /** + * Sets [Builder.unitAmounts] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmounts] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun unitAmounts(unitAmounts: JsonField>) = apply { + this.unitAmounts = unitAmounts.map { it.toMutableList() } + } + + /** + * Adds a single [UnitAmount] to [unitAmounts]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addUnitAmount(unitAmount: UnitAmount) = apply { + unitAmounts = + (unitAmounts ?: JsonField.of(mutableListOf())).also { + checkKnown("unitAmounts", it).add(unitAmount) + } + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -1164,9 +1452,29 @@ private constructor( * Returns an immutable instance of [GroupedWithMeteredMinimumConfig]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .minimumUnitAmount() + * .pricingKey() + * .scalingFactors() + * .scalingKey() + * .unitAmounts() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ fun build(): GroupedWithMeteredMinimumConfig = - GroupedWithMeteredMinimumConfig(additionalProperties.toImmutable()) + GroupedWithMeteredMinimumConfig( + checkRequired("groupingKey", groupingKey), + checkRequired("minimumUnitAmount", minimumUnitAmount), + checkRequired("pricingKey", pricingKey), + checkRequired("scalingFactors", scalingFactors).map { it.toImmutable() }, + checkRequired("scalingKey", scalingKey), + checkRequired("unitAmounts", unitAmounts).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false @@ -1176,6 +1484,12 @@ private constructor( return@apply } + groupingKey() + minimumUnitAmount() + pricingKey() + scalingFactors().forEach { it.validate() } + scalingKey() + unitAmounts().forEach { it.validate() } validated = true } @@ -1194,7 +1508,447 @@ private constructor( * Used for best match union deserialization. */ internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + (if (groupingKey.asKnown() == null) 0 else 1) + + (if (minimumUnitAmount.asKnown() == null) 0 else 1) + + (if (pricingKey.asKnown() == null) 0 else 1) + + (scalingFactors.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + (if (scalingKey.asKnown() == null) 0 else 1) + + (unitAmounts.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a scaling factor */ + class ScalingFactor + private constructor( + private val scalingFactor: JsonField, + private val scalingValue: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("scaling_factor") + @ExcludeMissing + scalingFactor: JsonField = JsonMissing.of(), + @JsonProperty("scaling_value") + @ExcludeMissing + scalingValue: JsonField = JsonMissing.of(), + ) : this(scalingFactor, scalingValue, mutableMapOf()) + + /** + * Scaling factor + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun scalingFactor(): String = scalingFactor.getRequired("scaling_factor") + + /** + * Scaling value + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun scalingValue(): String = scalingValue.getRequired("scaling_value") + + /** + * Returns the raw JSON value of [scalingFactor]. + * + * Unlike [scalingFactor], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("scaling_factor") + @ExcludeMissing + fun _scalingFactor(): JsonField = scalingFactor + + /** + * Returns the raw JSON value of [scalingValue]. + * + * Unlike [scalingValue], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("scaling_value") + @ExcludeMissing + fun _scalingValue(): JsonField = scalingValue + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ScalingFactor]. + * + * The following fields are required: + * ```kotlin + * .scalingFactor() + * .scalingValue() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [ScalingFactor]. */ + class Builder internal constructor() { + + private var scalingFactor: JsonField? = null + private var scalingValue: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(scalingFactor: ScalingFactor) = apply { + this.scalingFactor = scalingFactor.scalingFactor + scalingValue = scalingFactor.scalingValue + additionalProperties = scalingFactor.additionalProperties.toMutableMap() + } + + /** Scaling factor */ + fun scalingFactor(scalingFactor: String) = + scalingFactor(JsonField.of(scalingFactor)) + + /** + * Sets [Builder.scalingFactor] to an arbitrary JSON value. + * + * You should usually call [Builder.scalingFactor] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun scalingFactor(scalingFactor: JsonField) = apply { + this.scalingFactor = scalingFactor + } + + /** Scaling value */ + fun scalingValue(scalingValue: String) = scalingValue(JsonField.of(scalingValue)) + + /** + * Sets [Builder.scalingValue] to an arbitrary JSON value. + * + * You should usually call [Builder.scalingValue] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun scalingValue(scalingValue: JsonField) = apply { + this.scalingValue = scalingValue + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ScalingFactor]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .scalingFactor() + * .scalingValue() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ScalingFactor = + ScalingFactor( + checkRequired("scalingFactor", scalingFactor), + checkRequired("scalingValue", scalingValue), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ScalingFactor = apply { + if (validated) { + return@apply + } + + scalingFactor() + scalingValue() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (scalingFactor.asKnown() == null) 0 else 1) + + (if (scalingValue.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ScalingFactor && + scalingFactor == other.scalingFactor && + scalingValue == other.scalingValue && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(scalingFactor, scalingValue, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ScalingFactor{scalingFactor=$scalingFactor, scalingValue=$scalingValue, additionalProperties=$additionalProperties}" + } + + /** Configuration for a unit amount */ + class UnitAmount + private constructor( + private val pricingValue: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("pricing_value") + @ExcludeMissing + pricingValue: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(pricingValue, unitAmount, mutableMapOf()) + + /** + * Pricing value + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun pricingValue(): String = pricingValue.getRequired("pricing_value") + + /** + * Per unit amount + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [pricingValue]. + * + * Unlike [pricingValue], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("pricing_value") + @ExcludeMissing + fun _pricingValue(): JsonField = pricingValue + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [UnitAmount]. + * + * The following fields are required: + * ```kotlin + * .pricingValue() + * .unitAmount() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [UnitAmount]. */ + class Builder internal constructor() { + + private var pricingValue: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(unitAmount: UnitAmount) = apply { + pricingValue = unitAmount.pricingValue + this.unitAmount = unitAmount.unitAmount + additionalProperties = unitAmount.additionalProperties.toMutableMap() + } + + /** Pricing value */ + fun pricingValue(pricingValue: String) = pricingValue(JsonField.of(pricingValue)) + + /** + * Sets [Builder.pricingValue] to an arbitrary JSON value. + * + * You should usually call [Builder.pricingValue] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun pricingValue(pricingValue: JsonField) = apply { + this.pricingValue = pricingValue + } + + /** Per unit amount */ + fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [UnitAmount]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .pricingValue() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UnitAmount = + UnitAmount( + checkRequired("pricingValue", pricingValue), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UnitAmount = apply { + if (validated) { + return@apply + } + + pricingValue() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (pricingValue.asKnown() == null) 0 else 1) + + (if (unitAmount.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnitAmount && + pricingValue == other.pricingValue && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(pricingValue, unitAmount, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UnitAmount{pricingValue=$pricingValue, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } override fun equals(other: Any?): Boolean { if (this === other) { @@ -1202,17 +1956,34 @@ private constructor( } return other is GroupedWithMeteredMinimumConfig && + groupingKey == other.groupingKey && + minimumUnitAmount == other.minimumUnitAmount && + pricingKey == other.pricingKey && + scalingFactors == other.scalingFactors && + scalingKey == other.scalingKey && + unitAmounts == other.unitAmounts && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + private val hashCode: Int by lazy { + Objects.hash( + groupingKey, + minimumUnitAmount, + pricingKey, + scalingFactors, + scalingKey, + unitAmounts, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode override fun toString() = - "GroupedWithMeteredMinimumConfig{additionalProperties=$additionalProperties}" + "GroupedWithMeteredMinimumConfig{groupingKey=$groupingKey, minimumUnitAmount=$minimumUnitAmount, pricingKey=$pricingKey, scalingFactors=$scalingFactors, scalingKey=$scalingKey, unitAmounts=$unitAmounts, additionalProperties=$additionalProperties}" } + /** The pricing model type */ class ModelType @JsonCreator private constructor(private val value: JsonField) : Enum { /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionGroupedWithProratedMinimumPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionGroupedWithProratedMinimumPrice.kt index 314744fd6..5f92b1ef5 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionGroupedWithProratedMinimumPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionGroupedWithProratedMinimumPrice.kt @@ -119,6 +119,8 @@ private constructor( fun cadence(): Cadence = cadence.getRequired("cadence") /** + * Configuration for grouped_with_prorated_minimum pricing + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ @@ -134,6 +136,8 @@ private constructor( fun itemId(): String = itemId.getRequired("item_id") /** + * The pricing model type + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ @@ -522,6 +526,7 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + /** Configuration for grouped_with_prorated_minimum pricing */ fun groupedWithProratedMinimumConfig( groupedWithProratedMinimumConfig: GroupedWithProratedMinimumConfig ) = groupedWithProratedMinimumConfig(JsonField.of(groupedWithProratedMinimumConfig)) @@ -548,6 +553,7 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + /** The pricing model type */ fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) /** @@ -1108,16 +1114,82 @@ private constructor( override fun toString() = value.toString() } + /** Configuration for grouped_with_prorated_minimum pricing */ class GroupedWithProratedMinimumConfig - @JsonCreator private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map + private val groupingKey: JsonField, + private val minimum: JsonField, + private val unitRate: JsonField, + private val additionalProperties: MutableMap, ) { + @JsonCreator + private constructor( + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("minimum") @ExcludeMissing minimum: JsonField = JsonMissing.of(), + @JsonProperty("unit_rate") + @ExcludeMissing + unitRate: JsonField = JsonMissing.of(), + ) : this(groupingKey, minimum, unitRate, mutableMapOf()) + + /** + * How to determine the groups that should each have a minimum + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The minimum amount to charge per group + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun minimum(): String = minimum.getRequired("minimum") + + /** + * The amount to charge per unit + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun unitRate(): String = unitRate.getRequired("unit_rate") + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [minimum]. + * + * Unlike [minimum], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("minimum") @ExcludeMissing fun _minimum(): JsonField = minimum + + /** + * Returns the raw JSON value of [unitRate]. + * + * Unlike [unitRate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("unit_rate") @ExcludeMissing fun _unitRate(): JsonField = unitRate + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) fun toBuilder() = Builder().from(this) @@ -1126,6 +1198,13 @@ private constructor( /** * Returns a mutable builder for constructing an instance of * [GroupedWithProratedMinimumConfig]. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .minimum() + * .unitRate() + * ``` */ fun builder() = Builder() } @@ -1133,14 +1212,58 @@ private constructor( /** A builder for [GroupedWithProratedMinimumConfig]. */ class Builder internal constructor() { + private var groupingKey: JsonField? = null + private var minimum: JsonField? = null + private var unitRate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(groupedWithProratedMinimumConfig: GroupedWithProratedMinimumConfig) = apply { + groupingKey = groupedWithProratedMinimumConfig.groupingKey + minimum = groupedWithProratedMinimumConfig.minimum + unitRate = groupedWithProratedMinimumConfig.unitRate additionalProperties = groupedWithProratedMinimumConfig.additionalProperties.toMutableMap() } + /** How to determine the groups that should each have a minimum */ + fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The minimum amount to charge per group */ + fun minimum(minimum: String) = minimum(JsonField.of(minimum)) + + /** + * Sets [Builder.minimum] to an arbitrary JSON value. + * + * You should usually call [Builder.minimum] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun minimum(minimum: JsonField) = apply { this.minimum = minimum } + + /** The amount to charge per unit */ + fun unitRate(unitRate: String) = unitRate(JsonField.of(unitRate)) + + /** + * Sets [Builder.unitRate] to an arbitrary JSON value. + * + * You should usually call [Builder.unitRate] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun unitRate(unitRate: JsonField) = apply { this.unitRate = unitRate } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -1164,9 +1287,23 @@ private constructor( * Returns an immutable instance of [GroupedWithProratedMinimumConfig]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .minimum() + * .unitRate() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ fun build(): GroupedWithProratedMinimumConfig = - GroupedWithProratedMinimumConfig(additionalProperties.toImmutable()) + GroupedWithProratedMinimumConfig( + checkRequired("groupingKey", groupingKey), + checkRequired("minimum", minimum), + checkRequired("unitRate", unitRate), + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false @@ -1176,6 +1313,9 @@ private constructor( return@apply } + groupingKey() + minimum() + unitRate() validated = true } @@ -1194,7 +1334,9 @@ private constructor( * Used for best match union deserialization. */ internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + (if (groupingKey.asKnown() == null) 0 else 1) + + (if (minimum.asKnown() == null) 0 else 1) + + (if (unitRate.asKnown() == null) 0 else 1) override fun equals(other: Any?): Boolean { if (this === other) { @@ -1202,17 +1344,23 @@ private constructor( } return other is GroupedWithProratedMinimumConfig && + groupingKey == other.groupingKey && + minimum == other.minimum && + unitRate == other.unitRate && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + private val hashCode: Int by lazy { + Objects.hash(groupingKey, minimum, unitRate, additionalProperties) + } override fun hashCode(): Int = hashCode override fun toString() = - "GroupedWithProratedMinimumConfig{additionalProperties=$additionalProperties}" + "GroupedWithProratedMinimumConfig{groupingKey=$groupingKey, minimum=$minimum, unitRate=$unitRate, additionalProperties=$additionalProperties}" } + /** The pricing model type */ class ModelType @JsonCreator private constructor(private val value: JsonField) : Enum { /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionMatrixPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionMatrixPrice.kt index 256b98784..9928a7429 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionMatrixPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionMatrixPrice.kt @@ -126,12 +126,16 @@ private constructor( fun itemId(): String = itemId.getRequired("item_id") /** + * Configuration for matrix pricing + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ fun matrixConfig(): MatrixConfig = matrixConfig.getRequired("matrix_config") /** + * The pricing model type + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ @@ -518,6 +522,7 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + /** Configuration for matrix pricing */ fun matrixConfig(matrixConfig: MatrixConfig) = matrixConfig(JsonField.of(matrixConfig)) /** @@ -531,6 +536,7 @@ private constructor( this.matrixConfig = matrixConfig } + /** The pricing model type */ fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) /** @@ -1091,6 +1097,7 @@ private constructor( override fun toString() = value.toString() } + /** The pricing model type */ class ModelType @JsonCreator private constructor(private val value: JsonField) : Enum { /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionMatrixWithAllocationPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionMatrixWithAllocationPrice.kt index aa280bd87..a14f0cf99 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionMatrixWithAllocationPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionMatrixWithAllocationPrice.kt @@ -126,6 +126,8 @@ private constructor( fun itemId(): String = itemId.getRequired("item_id") /** + * Configuration for matrix_with_allocation pricing + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ @@ -133,6 +135,8 @@ private constructor( matrixWithAllocationConfig.getRequired("matrix_with_allocation_config") /** + * The pricing model type + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ @@ -529,6 +533,7 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + /** Configuration for matrix_with_allocation pricing */ fun matrixWithAllocationConfig(matrixWithAllocationConfig: MatrixWithAllocationConfig) = matrixWithAllocationConfig(JsonField.of(matrixWithAllocationConfig)) @@ -543,6 +548,7 @@ private constructor( matrixWithAllocationConfig: JsonField ) = apply { this.matrixWithAllocationConfig = matrixWithAllocationConfig } + /** The pricing model type */ fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) /** @@ -1103,6 +1109,7 @@ private constructor( override fun toString() = value.toString() } + /** The pricing model type */ class ModelType @JsonCreator private constructor(private val value: JsonField) : Enum { /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionMatrixWithDisplayNamePrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionMatrixWithDisplayNamePrice.kt index ea2bd5ab1..e1e4604f1 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionMatrixWithDisplayNamePrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionMatrixWithDisplayNamePrice.kt @@ -11,6 +11,7 @@ import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue +import com.withorb.api.core.checkKnown import com.withorb.api.core.checkRequired import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException @@ -126,6 +127,8 @@ private constructor( fun itemId(): String = itemId.getRequired("item_id") /** + * Configuration for matrix_with_display_name pricing + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ @@ -133,6 +136,8 @@ private constructor( matrixWithDisplayNameConfig.getRequired("matrix_with_display_name_config") /** + * The pricing model type + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ @@ -529,6 +534,7 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + /** Configuration for matrix_with_display_name pricing */ fun matrixWithDisplayNameConfig(matrixWithDisplayNameConfig: MatrixWithDisplayNameConfig) = matrixWithDisplayNameConfig(JsonField.of(matrixWithDisplayNameConfig)) @@ -543,6 +549,7 @@ private constructor( matrixWithDisplayNameConfig: JsonField ) = apply { this.matrixWithDisplayNameConfig = matrixWithDisplayNameConfig } + /** The pricing model type */ fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) /** @@ -1103,16 +1110,65 @@ private constructor( override fun toString() = value.toString() } + /** Configuration for matrix_with_display_name pricing */ class MatrixWithDisplayNameConfig - @JsonCreator private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map + private val dimension: JsonField, + private val unitAmounts: JsonField>, + private val additionalProperties: MutableMap, ) { + @JsonCreator + private constructor( + @JsonProperty("dimension") + @ExcludeMissing + dimension: JsonField = JsonMissing.of(), + @JsonProperty("unit_amounts") + @ExcludeMissing + unitAmounts: JsonField> = JsonMissing.of(), + ) : this(dimension, unitAmounts, mutableMapOf()) + + /** + * Used to determine the unit rate + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun dimension(): String = dimension.getRequired("dimension") + + /** + * Apply per unit pricing to each dimension value + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun unitAmounts(): List = unitAmounts.getRequired("unit_amounts") + + /** + * Returns the raw JSON value of [dimension]. + * + * Unlike [dimension], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("dimension") @ExcludeMissing fun _dimension(): JsonField = dimension + + /** + * Returns the raw JSON value of [unitAmounts]. + * + * Unlike [unitAmounts], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("unit_amounts") + @ExcludeMissing + fun _unitAmounts(): JsonField> = unitAmounts + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) fun toBuilder() = Builder().from(this) @@ -1121,6 +1177,12 @@ private constructor( /** * Returns a mutable builder for constructing an instance of * [MatrixWithDisplayNameConfig]. + * + * The following fields are required: + * ```kotlin + * .dimension() + * .unitAmounts() + * ``` */ fun builder() = Builder() } @@ -1128,13 +1190,55 @@ private constructor( /** A builder for [MatrixWithDisplayNameConfig]. */ class Builder internal constructor() { + private var dimension: JsonField? = null + private var unitAmounts: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(matrixWithDisplayNameConfig: MatrixWithDisplayNameConfig) = apply { + dimension = matrixWithDisplayNameConfig.dimension + unitAmounts = matrixWithDisplayNameConfig.unitAmounts.map { it.toMutableList() } additionalProperties = matrixWithDisplayNameConfig.additionalProperties.toMutableMap() } + /** Used to determine the unit rate */ + fun dimension(dimension: String) = dimension(JsonField.of(dimension)) + + /** + * Sets [Builder.dimension] to an arbitrary JSON value. + * + * You should usually call [Builder.dimension] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun dimension(dimension: JsonField) = apply { this.dimension = dimension } + + /** Apply per unit pricing to each dimension value */ + fun unitAmounts(unitAmounts: List) = unitAmounts(JsonField.of(unitAmounts)) + + /** + * Sets [Builder.unitAmounts] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmounts] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun unitAmounts(unitAmounts: JsonField>) = apply { + this.unitAmounts = unitAmounts.map { it.toMutableList() } + } + + /** + * Adds a single [UnitAmount] to [unitAmounts]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addUnitAmount(unitAmount: UnitAmount) = apply { + unitAmounts = + (unitAmounts ?: JsonField.of(mutableListOf())).also { + checkKnown("unitAmounts", it).add(unitAmount) + } + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -1158,9 +1262,21 @@ private constructor( * Returns an immutable instance of [MatrixWithDisplayNameConfig]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .dimension() + * .unitAmounts() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ fun build(): MatrixWithDisplayNameConfig = - MatrixWithDisplayNameConfig(additionalProperties.toImmutable()) + MatrixWithDisplayNameConfig( + checkRequired("dimension", dimension), + checkRequired("unitAmounts", unitAmounts).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false @@ -1170,6 +1286,8 @@ private constructor( return@apply } + dimension() + unitAmounts().forEach { it.validate() } validated = true } @@ -1188,7 +1306,271 @@ private constructor( * Used for best match union deserialization. */ internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + (if (dimension.asKnown() == null) 0 else 1) + + (unitAmounts.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a unit amount item */ + class UnitAmount + private constructor( + private val dimensionValue: JsonField, + private val displayName: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("dimension_value") + @ExcludeMissing + dimensionValue: JsonField = JsonMissing.of(), + @JsonProperty("display_name") + @ExcludeMissing + displayName: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(dimensionValue, displayName, unitAmount, mutableMapOf()) + + /** + * The dimension value + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun dimensionValue(): String = dimensionValue.getRequired("dimension_value") + + /** + * Display name for this dimension value + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun displayName(): String = displayName.getRequired("display_name") + + /** + * Per unit amount + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [dimensionValue]. + * + * Unlike [dimensionValue], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("dimension_value") + @ExcludeMissing + fun _dimensionValue(): JsonField = dimensionValue + + /** + * Returns the raw JSON value of [displayName]. + * + * Unlike [displayName], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("display_name") + @ExcludeMissing + fun _displayName(): JsonField = displayName + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [UnitAmount]. + * + * The following fields are required: + * ```kotlin + * .dimensionValue() + * .displayName() + * .unitAmount() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [UnitAmount]. */ + class Builder internal constructor() { + + private var dimensionValue: JsonField? = null + private var displayName: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(unitAmount: UnitAmount) = apply { + dimensionValue = unitAmount.dimensionValue + displayName = unitAmount.displayName + this.unitAmount = unitAmount.unitAmount + additionalProperties = unitAmount.additionalProperties.toMutableMap() + } + + /** The dimension value */ + fun dimensionValue(dimensionValue: String) = + dimensionValue(JsonField.of(dimensionValue)) + + /** + * Sets [Builder.dimensionValue] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionValue] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun dimensionValue(dimensionValue: JsonField) = apply { + this.dimensionValue = dimensionValue + } + + /** Display name for this dimension value */ + fun displayName(displayName: String) = displayName(JsonField.of(displayName)) + + /** + * Sets [Builder.displayName] to an arbitrary JSON value. + * + * You should usually call [Builder.displayName] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun displayName(displayName: JsonField) = apply { + this.displayName = displayName + } + + /** Per unit amount */ + fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [UnitAmount]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .dimensionValue() + * .displayName() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UnitAmount = + UnitAmount( + checkRequired("dimensionValue", dimensionValue), + checkRequired("displayName", displayName), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UnitAmount = apply { + if (validated) { + return@apply + } + + dimensionValue() + displayName() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (dimensionValue.asKnown() == null) 0 else 1) + + (if (displayName.asKnown() == null) 0 else 1) + + (if (unitAmount.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnitAmount && + dimensionValue == other.dimensionValue && + displayName == other.displayName && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(dimensionValue, displayName, unitAmount, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UnitAmount{dimensionValue=$dimensionValue, displayName=$displayName, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } override fun equals(other: Any?): Boolean { if (this === other) { @@ -1196,17 +1578,22 @@ private constructor( } return other is MatrixWithDisplayNameConfig && + dimension == other.dimension && + unitAmounts == other.unitAmounts && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + private val hashCode: Int by lazy { + Objects.hash(dimension, unitAmounts, additionalProperties) + } override fun hashCode(): Int = hashCode override fun toString() = - "MatrixWithDisplayNameConfig{additionalProperties=$additionalProperties}" + "MatrixWithDisplayNameConfig{dimension=$dimension, unitAmounts=$unitAmounts, additionalProperties=$additionalProperties}" } + /** The pricing model type */ class ModelType @JsonCreator private constructor(private val value: JsonField) : Enum { /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionMaxGroupTieredPackagePrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionMaxGroupTieredPackagePrice.kt index 65c838439..dbd7d1758 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionMaxGroupTieredPackagePrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionMaxGroupTieredPackagePrice.kt @@ -11,6 +11,7 @@ import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue +import com.withorb.api.core.checkKnown import com.withorb.api.core.checkRequired import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException @@ -126,6 +127,8 @@ private constructor( fun itemId(): String = itemId.getRequired("item_id") /** + * Configuration for max_group_tiered_package pricing + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ @@ -133,6 +136,8 @@ private constructor( maxGroupTieredPackageConfig.getRequired("max_group_tiered_package_config") /** + * The pricing model type + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ @@ -529,6 +534,7 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + /** Configuration for max_group_tiered_package pricing */ fun maxGroupTieredPackageConfig(maxGroupTieredPackageConfig: MaxGroupTieredPackageConfig) = maxGroupTieredPackageConfig(JsonField.of(maxGroupTieredPackageConfig)) @@ -543,6 +549,7 @@ private constructor( maxGroupTieredPackageConfig: JsonField ) = apply { this.maxGroupTieredPackageConfig = maxGroupTieredPackageConfig } + /** The pricing model type */ fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) /** @@ -1103,16 +1110,84 @@ private constructor( override fun toString() = value.toString() } + /** Configuration for max_group_tiered_package pricing */ class MaxGroupTieredPackageConfig - @JsonCreator private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map + private val groupingKey: JsonField, + private val packageSize: JsonField, + private val tiers: JsonField>, + private val additionalProperties: MutableMap, ) { + @JsonCreator + private constructor( + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("package_size") + @ExcludeMissing + packageSize: JsonField = JsonMissing.of(), + @JsonProperty("tiers") @ExcludeMissing tiers: JsonField> = JsonMissing.of(), + ) : this(groupingKey, packageSize, tiers, mutableMapOf()) + + /** + * The event property used to group before tiering the group with the highest value + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * Package size + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun packageSize(): String = packageSize.getRequired("package_size") + + /** + * Apply tiered pricing to the largest group after grouping with the provided key. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun tiers(): List = tiers.getRequired("tiers") + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [packageSize]. + * + * Unlike [packageSize], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("package_size") + @ExcludeMissing + fun _packageSize(): JsonField = packageSize + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tiers") @ExcludeMissing fun _tiers(): JsonField> = tiers + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) fun toBuilder() = Builder().from(this) @@ -1121,6 +1196,13 @@ private constructor( /** * Returns a mutable builder for constructing an instance of * [MaxGroupTieredPackageConfig]. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .packageSize() + * .tiers() + * ``` */ fun builder() = Builder() } @@ -1128,13 +1210,73 @@ private constructor( /** A builder for [MaxGroupTieredPackageConfig]. */ class Builder internal constructor() { + private var groupingKey: JsonField? = null + private var packageSize: JsonField? = null + private var tiers: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(maxGroupTieredPackageConfig: MaxGroupTieredPackageConfig) = apply { + groupingKey = maxGroupTieredPackageConfig.groupingKey + packageSize = maxGroupTieredPackageConfig.packageSize + tiers = maxGroupTieredPackageConfig.tiers.map { it.toMutableList() } additionalProperties = maxGroupTieredPackageConfig.additionalProperties.toMutableMap() } + /** The event property used to group before tiering the group with the highest value */ + fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** Package size */ + fun packageSize(packageSize: String) = packageSize(JsonField.of(packageSize)) + + /** + * Sets [Builder.packageSize] to an arbitrary JSON value. + * + * You should usually call [Builder.packageSize] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun packageSize(packageSize: JsonField) = apply { + this.packageSize = packageSize + } + + /** Apply tiered pricing to the largest group after grouping with the provided key. */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -1158,9 +1300,23 @@ private constructor( * Returns an immutable instance of [MaxGroupTieredPackageConfig]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .packageSize() + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ fun build(): MaxGroupTieredPackageConfig = - MaxGroupTieredPackageConfig(additionalProperties.toImmutable()) + MaxGroupTieredPackageConfig( + checkRequired("groupingKey", groupingKey), + checkRequired("packageSize", packageSize), + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false @@ -1170,6 +1326,9 @@ private constructor( return@apply } + groupingKey() + packageSize() + tiers().forEach { it.validate() } validated = true } @@ -1188,7 +1347,227 @@ private constructor( * Used for best match union deserialization. */ internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + (if (groupingKey.asKnown() == null) 0 else 1) + + (if (packageSize.asKnown() == null) 0 else 1) + + (tiers.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single tier */ + class Tier + private constructor( + private val tierLowerBound: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(tierLowerBound, unitAmount, mutableMapOf()) + + /** + * Tier lower bound + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun tierLowerBound(): String = tierLowerBound.getRequired("tier_lower_bound") + + /** + * Per unit amount + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Tier]. + * + * The following fields are required: + * ```kotlin + * .tierLowerBound() + * .unitAmount() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var tierLowerBound: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(tier: Tier) = apply { + tierLowerBound = tier.tierLowerBound + unitAmount = tier.unitAmount + additionalProperties = tier.additionalProperties.toMutableMap() + } + + /** Tier lower bound */ + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + /** Per unit amount */ + fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Tier]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .tierLowerBound() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("tierLowerBound", tierLowerBound), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + tierLowerBound() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (tierLowerBound.asKnown() == null) 0 else 1) + + (if (unitAmount.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + tierLowerBound == other.tierLowerBound && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(tierLowerBound, unitAmount, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } override fun equals(other: Any?): Boolean { if (this === other) { @@ -1196,17 +1575,23 @@ private constructor( } return other is MaxGroupTieredPackageConfig && + groupingKey == other.groupingKey && + packageSize == other.packageSize && + tiers == other.tiers && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + private val hashCode: Int by lazy { + Objects.hash(groupingKey, packageSize, tiers, additionalProperties) + } override fun hashCode(): Int = hashCode override fun toString() = - "MaxGroupTieredPackageConfig{additionalProperties=$additionalProperties}" + "MaxGroupTieredPackageConfig{groupingKey=$groupingKey, packageSize=$packageSize, tiers=$tiers, additionalProperties=$additionalProperties}" } + /** The pricing model type */ class ModelType @JsonCreator private constructor(private val value: JsonField) : Enum { /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionMinimumCompositePrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionMinimumCompositePrice.kt index 3e28ecf1d..40a12cef5 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionMinimumCompositePrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionMinimumCompositePrice.kt @@ -126,12 +126,16 @@ private constructor( fun itemId(): String = itemId.getRequired("item_id") /** + * Configuration for minimum pricing + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ fun minimumConfig(): MinimumConfig = minimumConfig.getRequired("minimum_config") /** + * The pricing model type + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ @@ -525,6 +529,7 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + /** Configuration for minimum pricing */ fun minimumConfig(minimumConfig: MinimumConfig) = minimumConfig(JsonField.of(minimumConfig)) /** @@ -538,6 +543,7 @@ private constructor( this.minimumConfig = minimumConfig } + /** The pricing model type */ fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) /** @@ -1098,6 +1104,7 @@ private constructor( override fun toString() = value.toString() } + /** Configuration for minimum pricing */ class MinimumConfig private constructor( private val minimumAmount: JsonField, @@ -1124,8 +1131,7 @@ private constructor( fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") /** - * By default, subtotals from minimum composite prices are prorated based on the service - * period. Set to false to disable proration. + * If true, subtotals from this price are prorated based on the service period * * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -1201,18 +1207,8 @@ private constructor( this.minimumAmount = minimumAmount } - /** - * By default, subtotals from minimum composite prices are prorated based on the service - * period. Set to false to disable proration. - */ - fun prorated(prorated: Boolean?) = prorated(JsonField.ofNullable(prorated)) - - /** - * Alias for [Builder.prorated]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun prorated(prorated: Boolean) = prorated(prorated as Boolean?) + /** If true, subtotals from this price are prorated based on the service period */ + fun prorated(prorated: Boolean) = prorated(JsonField.of(prorated)) /** * Sets [Builder.prorated] to an arbitrary JSON value. @@ -1313,6 +1309,7 @@ private constructor( "MinimumConfig{minimumAmount=$minimumAmount, prorated=$prorated, additionalProperties=$additionalProperties}" } + /** The pricing model type */ class ModelType @JsonCreator private constructor(private val value: JsonField) : Enum { /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionPackagePrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionPackagePrice.kt index ec79cb3a8..581a8af22 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionPackagePrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionPackagePrice.kt @@ -126,6 +126,8 @@ private constructor( fun itemId(): String = itemId.getRequired("item_id") /** + * The pricing model type + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ @@ -140,6 +142,8 @@ private constructor( fun name(): String = name.getRequired("name") /** + * Configuration for package pricing + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ @@ -519,6 +523,7 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + /** The pricing model type */ fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) /** @@ -541,6 +546,7 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } + /** Configuration for package pricing */ fun packageConfig(packageConfig: PackageConfig) = packageConfig(JsonField.of(packageConfig)) /** @@ -1092,6 +1098,7 @@ private constructor( override fun toString() = value.toString() } + /** The pricing model type */ class ModelType @JsonCreator private constructor(private val value: JsonField) : Enum { /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionPackageWithAllocationPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionPackageWithAllocationPrice.kt index 9d07625c6..4f15f85b7 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionPackageWithAllocationPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionPackageWithAllocationPrice.kt @@ -126,6 +126,8 @@ private constructor( fun itemId(): String = itemId.getRequired("item_id") /** + * The pricing model type + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ @@ -140,6 +142,8 @@ private constructor( fun name(): String = name.getRequired("name") /** + * Configuration for package_with_allocation pricing + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ @@ -529,6 +533,7 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + /** The pricing model type */ fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) /** @@ -551,6 +556,7 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } + /** Configuration for package_with_allocation pricing */ fun packageWithAllocationConfig(packageWithAllocationConfig: PackageWithAllocationConfig) = packageWithAllocationConfig(JsonField.of(packageWithAllocationConfig)) @@ -1103,6 +1109,7 @@ private constructor( override fun toString() = value.toString() } + /** The pricing model type */ class ModelType @JsonCreator private constructor(private val value: JsonField) : Enum { /** @@ -1223,16 +1230,89 @@ private constructor( override fun toString() = value.toString() } + /** Configuration for package_with_allocation pricing */ class PackageWithAllocationConfig - @JsonCreator private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map + private val allocation: JsonField, + private val packageAmount: JsonField, + private val packageSize: JsonField, + private val additionalProperties: MutableMap, ) { + @JsonCreator + private constructor( + @JsonProperty("allocation") + @ExcludeMissing + allocation: JsonField = JsonMissing.of(), + @JsonProperty("package_amount") + @ExcludeMissing + packageAmount: JsonField = JsonMissing.of(), + @JsonProperty("package_size") + @ExcludeMissing + packageSize: JsonField = JsonMissing.of(), + ) : this(allocation, packageAmount, packageSize, mutableMapOf()) + + /** + * Usage allocation + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun allocation(): String = allocation.getRequired("allocation") + + /** + * Price per package + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun packageAmount(): String = packageAmount.getRequired("package_amount") + + /** + * Package size + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun packageSize(): String = packageSize.getRequired("package_size") + + /** + * Returns the raw JSON value of [allocation]. + * + * Unlike [allocation], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("allocation") + @ExcludeMissing + fun _allocation(): JsonField = allocation + + /** + * Returns the raw JSON value of [packageAmount]. + * + * Unlike [packageAmount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("package_amount") + @ExcludeMissing + fun _packageAmount(): JsonField = packageAmount + + /** + * Returns the raw JSON value of [packageSize]. + * + * Unlike [packageSize], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("package_size") + @ExcludeMissing + fun _packageSize(): JsonField = packageSize + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) fun toBuilder() = Builder().from(this) @@ -1241,6 +1321,13 @@ private constructor( /** * Returns a mutable builder for constructing an instance of * [PackageWithAllocationConfig]. + * + * The following fields are required: + * ```kotlin + * .allocation() + * .packageAmount() + * .packageSize() + * ``` */ fun builder() = Builder() } @@ -1248,13 +1335,59 @@ private constructor( /** A builder for [PackageWithAllocationConfig]. */ class Builder internal constructor() { + private var allocation: JsonField? = null + private var packageAmount: JsonField? = null + private var packageSize: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(packageWithAllocationConfig: PackageWithAllocationConfig) = apply { + allocation = packageWithAllocationConfig.allocation + packageAmount = packageWithAllocationConfig.packageAmount + packageSize = packageWithAllocationConfig.packageSize additionalProperties = packageWithAllocationConfig.additionalProperties.toMutableMap() } + /** Usage allocation */ + fun allocation(allocation: String) = allocation(JsonField.of(allocation)) + + /** + * Sets [Builder.allocation] to an arbitrary JSON value. + * + * You should usually call [Builder.allocation] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun allocation(allocation: JsonField) = apply { this.allocation = allocation } + + /** Price per package */ + fun packageAmount(packageAmount: String) = packageAmount(JsonField.of(packageAmount)) + + /** + * Sets [Builder.packageAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.packageAmount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun packageAmount(packageAmount: JsonField) = apply { + this.packageAmount = packageAmount + } + + /** Package size */ + fun packageSize(packageSize: String) = packageSize(JsonField.of(packageSize)) + + /** + * Sets [Builder.packageSize] to an arbitrary JSON value. + * + * You should usually call [Builder.packageSize] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun packageSize(packageSize: JsonField) = apply { + this.packageSize = packageSize + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -1278,9 +1411,23 @@ private constructor( * Returns an immutable instance of [PackageWithAllocationConfig]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .allocation() + * .packageAmount() + * .packageSize() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ fun build(): PackageWithAllocationConfig = - PackageWithAllocationConfig(additionalProperties.toImmutable()) + PackageWithAllocationConfig( + checkRequired("allocation", allocation), + checkRequired("packageAmount", packageAmount), + checkRequired("packageSize", packageSize), + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false @@ -1290,6 +1437,9 @@ private constructor( return@apply } + allocation() + packageAmount() + packageSize() validated = true } @@ -1308,7 +1458,9 @@ private constructor( * Used for best match union deserialization. */ internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + (if (allocation.asKnown() == null) 0 else 1) + + (if (packageAmount.asKnown() == null) 0 else 1) + + (if (packageSize.asKnown() == null) 0 else 1) override fun equals(other: Any?): Boolean { if (this === other) { @@ -1316,15 +1468,20 @@ private constructor( } return other is PackageWithAllocationConfig && + allocation == other.allocation && + packageAmount == other.packageAmount && + packageSize == other.packageSize && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + private val hashCode: Int by lazy { + Objects.hash(allocation, packageAmount, packageSize, additionalProperties) + } override fun hashCode(): Int = hashCode override fun toString() = - "PackageWithAllocationConfig{additionalProperties=$additionalProperties}" + "PackageWithAllocationConfig{allocation=$allocation, packageAmount=$packageAmount, packageSize=$packageSize, additionalProperties=$additionalProperties}" } /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionScalableMatrixWithTieredPricingPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionScalableMatrixWithTieredPricingPrice.kt index 74e3e1485..2ef27833a 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionScalableMatrixWithTieredPricingPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionScalableMatrixWithTieredPricingPrice.kt @@ -11,6 +11,7 @@ import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue +import com.withorb.api.core.checkKnown import com.withorb.api.core.checkRequired import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException @@ -128,6 +129,8 @@ private constructor( fun itemId(): String = itemId.getRequired("item_id") /** + * The pricing model type + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ @@ -142,6 +145,8 @@ private constructor( fun name(): String = name.getRequired("name") /** + * Configuration for scalable_matrix_with_tiered_pricing pricing + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ @@ -541,6 +546,7 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + /** The pricing model type */ fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) /** @@ -563,6 +569,7 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } + /** Configuration for scalable_matrix_with_tiered_pricing pricing */ fun scalableMatrixWithTieredPricingConfig( scalableMatrixWithTieredPricingConfig: ScalableMatrixWithTieredPricingConfig ) = @@ -1124,6 +1131,7 @@ private constructor( override fun toString() = value.toString() } + /** The pricing model type */ class ModelType @JsonCreator private constructor(private val value: JsonField) : Enum { /** @@ -1244,16 +1252,109 @@ private constructor( override fun toString() = value.toString() } + /** Configuration for scalable_matrix_with_tiered_pricing pricing */ class ScalableMatrixWithTieredPricingConfig - @JsonCreator private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map + private val firstDimension: JsonField, + private val matrixScalingFactors: JsonField>, + private val tiers: JsonField>, + private val secondDimension: JsonField, + private val additionalProperties: MutableMap, ) { + @JsonCreator + private constructor( + @JsonProperty("first_dimension") + @ExcludeMissing + firstDimension: JsonField = JsonMissing.of(), + @JsonProperty("matrix_scaling_factors") + @ExcludeMissing + matrixScalingFactors: JsonField> = JsonMissing.of(), + @JsonProperty("tiers") @ExcludeMissing tiers: JsonField> = JsonMissing.of(), + @JsonProperty("second_dimension") + @ExcludeMissing + secondDimension: JsonField = JsonMissing.of(), + ) : this(firstDimension, matrixScalingFactors, tiers, secondDimension, mutableMapOf()) + + /** + * Used for the scalable matrix first dimension + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun firstDimension(): String = firstDimension.getRequired("first_dimension") + + /** + * Apply a scaling factor to each dimension + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun matrixScalingFactors(): List = + matrixScalingFactors.getRequired("matrix_scaling_factors") + + /** + * Tier pricing structure + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun tiers(): List = tiers.getRequired("tiers") + + /** + * Used for the scalable matrix second dimension (optional) + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun secondDimension(): String? = secondDimension.getNullable("second_dimension") + + /** + * Returns the raw JSON value of [firstDimension]. + * + * Unlike [firstDimension], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("first_dimension") + @ExcludeMissing + fun _firstDimension(): JsonField = firstDimension + + /** + * Returns the raw JSON value of [matrixScalingFactors]. + * + * Unlike [matrixScalingFactors], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("matrix_scaling_factors") + @ExcludeMissing + fun _matrixScalingFactors(): JsonField> = matrixScalingFactors + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tiers") @ExcludeMissing fun _tiers(): JsonField> = tiers + + /** + * Returns the raw JSON value of [secondDimension]. + * + * Unlike [secondDimension], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("second_dimension") + @ExcludeMissing + fun _secondDimension(): JsonField = secondDimension + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) fun toBuilder() = Builder().from(this) @@ -1262,6 +1363,13 @@ private constructor( /** * Returns a mutable builder for constructing an instance of * [ScalableMatrixWithTieredPricingConfig]. + * + * The following fields are required: + * ```kotlin + * .firstDimension() + * .matrixScalingFactors() + * .tiers() + * ``` */ fun builder() = Builder() } @@ -1269,15 +1377,110 @@ private constructor( /** A builder for [ScalableMatrixWithTieredPricingConfig]. */ class Builder internal constructor() { + private var firstDimension: JsonField? = null + private var matrixScalingFactors: JsonField>? = null + private var tiers: JsonField>? = null + private var secondDimension: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() internal fun from( scalableMatrixWithTieredPricingConfig: ScalableMatrixWithTieredPricingConfig ) = apply { + firstDimension = scalableMatrixWithTieredPricingConfig.firstDimension + matrixScalingFactors = + scalableMatrixWithTieredPricingConfig.matrixScalingFactors.map { + it.toMutableList() + } + tiers = scalableMatrixWithTieredPricingConfig.tiers.map { it.toMutableList() } + secondDimension = scalableMatrixWithTieredPricingConfig.secondDimension additionalProperties = scalableMatrixWithTieredPricingConfig.additionalProperties.toMutableMap() } + /** Used for the scalable matrix first dimension */ + fun firstDimension(firstDimension: String) = + firstDimension(JsonField.of(firstDimension)) + + /** + * Sets [Builder.firstDimension] to an arbitrary JSON value. + * + * You should usually call [Builder.firstDimension] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun firstDimension(firstDimension: JsonField) = apply { + this.firstDimension = firstDimension + } + + /** Apply a scaling factor to each dimension */ + fun matrixScalingFactors(matrixScalingFactors: List) = + matrixScalingFactors(JsonField.of(matrixScalingFactors)) + + /** + * Sets [Builder.matrixScalingFactors] to an arbitrary JSON value. + * + * You should usually call [Builder.matrixScalingFactors] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun matrixScalingFactors(matrixScalingFactors: JsonField>) = + apply { + this.matrixScalingFactors = matrixScalingFactors.map { it.toMutableList() } + } + + /** + * Adds a single [MatrixScalingFactor] to [matrixScalingFactors]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addMatrixScalingFactor(matrixScalingFactor: MatrixScalingFactor) = apply { + matrixScalingFactors = + (matrixScalingFactors ?: JsonField.of(mutableListOf())).also { + checkKnown("matrixScalingFactors", it).add(matrixScalingFactor) + } + } + + /** Tier pricing structure */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + + /** Used for the scalable matrix second dimension (optional) */ + fun secondDimension(secondDimension: String?) = + secondDimension(JsonField.ofNullable(secondDimension)) + + /** + * Sets [Builder.secondDimension] to an arbitrary JSON value. + * + * You should usually call [Builder.secondDimension] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun secondDimension(secondDimension: JsonField) = apply { + this.secondDimension = secondDimension + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -1301,9 +1504,26 @@ private constructor( * Returns an immutable instance of [ScalableMatrixWithTieredPricingConfig]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .firstDimension() + * .matrixScalingFactors() + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ fun build(): ScalableMatrixWithTieredPricingConfig = - ScalableMatrixWithTieredPricingConfig(additionalProperties.toImmutable()) + ScalableMatrixWithTieredPricingConfig( + checkRequired("firstDimension", firstDimension), + checkRequired("matrixScalingFactors", matrixScalingFactors).map { + it.toImmutable() + }, + checkRequired("tiers", tiers).map { it.toImmutable() }, + secondDimension, + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false @@ -1313,6 +1533,10 @@ private constructor( return@apply } + firstDimension() + matrixScalingFactors().forEach { it.validate() } + tiers().forEach { it.validate() } + secondDimension() validated = true } @@ -1331,7 +1555,497 @@ private constructor( * Used for best match union deserialization. */ internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + (if (firstDimension.asKnown() == null) 0 else 1) + + (matrixScalingFactors.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + (tiers.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + (if (secondDimension.asKnown() == null) 0 else 1) + + /** Configuration for a single matrix scaling factor */ + class MatrixScalingFactor + private constructor( + private val firstDimensionValue: JsonField, + private val scalingFactor: JsonField, + private val secondDimensionValue: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("first_dimension_value") + @ExcludeMissing + firstDimensionValue: JsonField = JsonMissing.of(), + @JsonProperty("scaling_factor") + @ExcludeMissing + scalingFactor: JsonField = JsonMissing.of(), + @JsonProperty("second_dimension_value") + @ExcludeMissing + secondDimensionValue: JsonField = JsonMissing.of(), + ) : this(firstDimensionValue, scalingFactor, secondDimensionValue, mutableMapOf()) + + /** + * First dimension value + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun firstDimensionValue(): String = + firstDimensionValue.getRequired("first_dimension_value") + + /** + * Scaling factor + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun scalingFactor(): String = scalingFactor.getRequired("scaling_factor") + + /** + * Second dimension value (optional) + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun secondDimensionValue(): String? = + secondDimensionValue.getNullable("second_dimension_value") + + /** + * Returns the raw JSON value of [firstDimensionValue]. + * + * Unlike [firstDimensionValue], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("first_dimension_value") + @ExcludeMissing + fun _firstDimensionValue(): JsonField = firstDimensionValue + + /** + * Returns the raw JSON value of [scalingFactor]. + * + * Unlike [scalingFactor], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("scaling_factor") + @ExcludeMissing + fun _scalingFactor(): JsonField = scalingFactor + + /** + * Returns the raw JSON value of [secondDimensionValue]. + * + * Unlike [secondDimensionValue], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("second_dimension_value") + @ExcludeMissing + fun _secondDimensionValue(): JsonField = secondDimensionValue + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [MatrixScalingFactor]. + * + * The following fields are required: + * ```kotlin + * .firstDimensionValue() + * .scalingFactor() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [MatrixScalingFactor]. */ + class Builder internal constructor() { + + private var firstDimensionValue: JsonField? = null + private var scalingFactor: JsonField? = null + private var secondDimensionValue: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(matrixScalingFactor: MatrixScalingFactor) = apply { + firstDimensionValue = matrixScalingFactor.firstDimensionValue + scalingFactor = matrixScalingFactor.scalingFactor + secondDimensionValue = matrixScalingFactor.secondDimensionValue + additionalProperties = matrixScalingFactor.additionalProperties.toMutableMap() + } + + /** First dimension value */ + fun firstDimensionValue(firstDimensionValue: String) = + firstDimensionValue(JsonField.of(firstDimensionValue)) + + /** + * Sets [Builder.firstDimensionValue] to an arbitrary JSON value. + * + * You should usually call [Builder.firstDimensionValue] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun firstDimensionValue(firstDimensionValue: JsonField) = apply { + this.firstDimensionValue = firstDimensionValue + } + + /** Scaling factor */ + fun scalingFactor(scalingFactor: String) = + scalingFactor(JsonField.of(scalingFactor)) + + /** + * Sets [Builder.scalingFactor] to an arbitrary JSON value. + * + * You should usually call [Builder.scalingFactor] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun scalingFactor(scalingFactor: JsonField) = apply { + this.scalingFactor = scalingFactor + } + + /** Second dimension value (optional) */ + fun secondDimensionValue(secondDimensionValue: String?) = + secondDimensionValue(JsonField.ofNullable(secondDimensionValue)) + + /** + * Sets [Builder.secondDimensionValue] to an arbitrary JSON value. + * + * You should usually call [Builder.secondDimensionValue] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun secondDimensionValue(secondDimensionValue: JsonField) = apply { + this.secondDimensionValue = secondDimensionValue + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [MatrixScalingFactor]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .firstDimensionValue() + * .scalingFactor() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MatrixScalingFactor = + MatrixScalingFactor( + checkRequired("firstDimensionValue", firstDimensionValue), + checkRequired("scalingFactor", scalingFactor), + secondDimensionValue, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MatrixScalingFactor = apply { + if (validated) { + return@apply + } + + firstDimensionValue() + scalingFactor() + secondDimensionValue() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (firstDimensionValue.asKnown() == null) 0 else 1) + + (if (scalingFactor.asKnown() == null) 0 else 1) + + (if (secondDimensionValue.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MatrixScalingFactor && + firstDimensionValue == other.firstDimensionValue && + scalingFactor == other.scalingFactor && + secondDimensionValue == other.secondDimensionValue && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + firstDimensionValue, + scalingFactor, + secondDimensionValue, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MatrixScalingFactor{firstDimensionValue=$firstDimensionValue, scalingFactor=$scalingFactor, secondDimensionValue=$secondDimensionValue, additionalProperties=$additionalProperties}" + } + + /** Configuration for a single tier entry with business logic */ + class Tier + private constructor( + private val tierLowerBound: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(tierLowerBound, unitAmount, mutableMapOf()) + + /** + * Tier lower bound + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun tierLowerBound(): String = tierLowerBound.getRequired("tier_lower_bound") + + /** + * Per unit amount + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Tier]. + * + * The following fields are required: + * ```kotlin + * .tierLowerBound() + * .unitAmount() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var tierLowerBound: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(tier: Tier) = apply { + tierLowerBound = tier.tierLowerBound + unitAmount = tier.unitAmount + additionalProperties = tier.additionalProperties.toMutableMap() + } + + /** Tier lower bound */ + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + /** Per unit amount */ + fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Tier]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .tierLowerBound() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("tierLowerBound", tierLowerBound), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + tierLowerBound() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (tierLowerBound.asKnown() == null) 0 else 1) + + (if (unitAmount.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + tierLowerBound == other.tierLowerBound && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(tierLowerBound, unitAmount, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } override fun equals(other: Any?): Boolean { if (this === other) { @@ -1339,15 +2053,27 @@ private constructor( } return other is ScalableMatrixWithTieredPricingConfig && + firstDimension == other.firstDimension && + matrixScalingFactors == other.matrixScalingFactors && + tiers == other.tiers && + secondDimension == other.secondDimension && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + private val hashCode: Int by lazy { + Objects.hash( + firstDimension, + matrixScalingFactors, + tiers, + secondDimension, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode override fun toString() = - "ScalableMatrixWithTieredPricingConfig{additionalProperties=$additionalProperties}" + "ScalableMatrixWithTieredPricingConfig{firstDimension=$firstDimension, matrixScalingFactors=$matrixScalingFactors, tiers=$tiers, secondDimension=$secondDimension, additionalProperties=$additionalProperties}" } /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionScalableMatrixWithUnitPricingPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionScalableMatrixWithUnitPricingPrice.kt index fd608668e..5c687de68 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionScalableMatrixWithUnitPricingPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionScalableMatrixWithUnitPricingPrice.kt @@ -11,6 +11,7 @@ import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue +import com.withorb.api.core.checkKnown import com.withorb.api.core.checkRequired import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException @@ -127,6 +128,8 @@ private constructor( fun itemId(): String = itemId.getRequired("item_id") /** + * The pricing model type + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ @@ -141,6 +144,8 @@ private constructor( fun name(): String = name.getRequired("name") /** + * Configuration for scalable_matrix_with_unit_pricing pricing + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ @@ -538,6 +543,7 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + /** The pricing model type */ fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) /** @@ -560,6 +566,7 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } + /** Configuration for scalable_matrix_with_unit_pricing pricing */ fun scalableMatrixWithUnitPricingConfig( scalableMatrixWithUnitPricingConfig: ScalableMatrixWithUnitPricingConfig ) = scalableMatrixWithUnitPricingConfig(JsonField.of(scalableMatrixWithUnitPricingConfig)) @@ -1116,6 +1123,7 @@ private constructor( override fun toString() = value.toString() } + /** The pricing model type */ class ModelType @JsonCreator private constructor(private val value: JsonField) : Enum { /** @@ -1236,16 +1244,135 @@ private constructor( override fun toString() = value.toString() } + /** Configuration for scalable_matrix_with_unit_pricing pricing */ class ScalableMatrixWithUnitPricingConfig - @JsonCreator private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map + private val firstDimension: JsonField, + private val matrixScalingFactors: JsonField>, + private val unitPrice: JsonField, + private val prorate: JsonField, + private val secondDimension: JsonField, + private val additionalProperties: MutableMap, ) { + @JsonCreator + private constructor( + @JsonProperty("first_dimension") + @ExcludeMissing + firstDimension: JsonField = JsonMissing.of(), + @JsonProperty("matrix_scaling_factors") + @ExcludeMissing + matrixScalingFactors: JsonField> = JsonMissing.of(), + @JsonProperty("unit_price") + @ExcludeMissing + unitPrice: JsonField = JsonMissing.of(), + @JsonProperty("prorate") @ExcludeMissing prorate: JsonField = JsonMissing.of(), + @JsonProperty("second_dimension") + @ExcludeMissing + secondDimension: JsonField = JsonMissing.of(), + ) : this( + firstDimension, + matrixScalingFactors, + unitPrice, + prorate, + secondDimension, + mutableMapOf(), + ) + + /** + * Used to determine the unit rate + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun firstDimension(): String = firstDimension.getRequired("first_dimension") + + /** + * Apply a scaling factor to each dimension + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun matrixScalingFactors(): List = + matrixScalingFactors.getRequired("matrix_scaling_factors") + + /** + * The final unit price to rate against the output of the matrix + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun unitPrice(): String = unitPrice.getRequired("unit_price") + + /** + * If true, the unit price will be prorated to the billing period + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun prorate(): Boolean? = prorate.getNullable("prorate") + + /** + * Used to determine the unit rate (optional) + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun secondDimension(): String? = secondDimension.getNullable("second_dimension") + + /** + * Returns the raw JSON value of [firstDimension]. + * + * Unlike [firstDimension], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("first_dimension") + @ExcludeMissing + fun _firstDimension(): JsonField = firstDimension + + /** + * Returns the raw JSON value of [matrixScalingFactors]. + * + * Unlike [matrixScalingFactors], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("matrix_scaling_factors") + @ExcludeMissing + fun _matrixScalingFactors(): JsonField> = matrixScalingFactors + + /** + * Returns the raw JSON value of [unitPrice]. + * + * Unlike [unitPrice], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("unit_price") @ExcludeMissing fun _unitPrice(): JsonField = unitPrice + + /** + * Returns the raw JSON value of [prorate]. + * + * Unlike [prorate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("prorate") @ExcludeMissing fun _prorate(): JsonField = prorate + + /** + * Returns the raw JSON value of [secondDimension]. + * + * Unlike [secondDimension], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("second_dimension") + @ExcludeMissing + fun _secondDimension(): JsonField = secondDimension + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) fun toBuilder() = Builder().from(this) @@ -1254,6 +1381,13 @@ private constructor( /** * Returns a mutable builder for constructing an instance of * [ScalableMatrixWithUnitPricingConfig]. + * + * The following fields are required: + * ```kotlin + * .firstDimension() + * .matrixScalingFactors() + * .unitPrice() + * ``` */ fun builder() = Builder() } @@ -1261,15 +1395,117 @@ private constructor( /** A builder for [ScalableMatrixWithUnitPricingConfig]. */ class Builder internal constructor() { + private var firstDimension: JsonField? = null + private var matrixScalingFactors: JsonField>? = null + private var unitPrice: JsonField? = null + private var prorate: JsonField = JsonMissing.of() + private var secondDimension: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() internal fun from( scalableMatrixWithUnitPricingConfig: ScalableMatrixWithUnitPricingConfig ) = apply { + firstDimension = scalableMatrixWithUnitPricingConfig.firstDimension + matrixScalingFactors = + scalableMatrixWithUnitPricingConfig.matrixScalingFactors.map { + it.toMutableList() + } + unitPrice = scalableMatrixWithUnitPricingConfig.unitPrice + prorate = scalableMatrixWithUnitPricingConfig.prorate + secondDimension = scalableMatrixWithUnitPricingConfig.secondDimension additionalProperties = scalableMatrixWithUnitPricingConfig.additionalProperties.toMutableMap() } + /** Used to determine the unit rate */ + fun firstDimension(firstDimension: String) = + firstDimension(JsonField.of(firstDimension)) + + /** + * Sets [Builder.firstDimension] to an arbitrary JSON value. + * + * You should usually call [Builder.firstDimension] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun firstDimension(firstDimension: JsonField) = apply { + this.firstDimension = firstDimension + } + + /** Apply a scaling factor to each dimension */ + fun matrixScalingFactors(matrixScalingFactors: List) = + matrixScalingFactors(JsonField.of(matrixScalingFactors)) + + /** + * Sets [Builder.matrixScalingFactors] to an arbitrary JSON value. + * + * You should usually call [Builder.matrixScalingFactors] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun matrixScalingFactors(matrixScalingFactors: JsonField>) = + apply { + this.matrixScalingFactors = matrixScalingFactors.map { it.toMutableList() } + } + + /** + * Adds a single [MatrixScalingFactor] to [matrixScalingFactors]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addMatrixScalingFactor(matrixScalingFactor: MatrixScalingFactor) = apply { + matrixScalingFactors = + (matrixScalingFactors ?: JsonField.of(mutableListOf())).also { + checkKnown("matrixScalingFactors", it).add(matrixScalingFactor) + } + } + + /** The final unit price to rate against the output of the matrix */ + fun unitPrice(unitPrice: String) = unitPrice(JsonField.of(unitPrice)) + + /** + * Sets [Builder.unitPrice] to an arbitrary JSON value. + * + * You should usually call [Builder.unitPrice] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun unitPrice(unitPrice: JsonField) = apply { this.unitPrice = unitPrice } + + /** If true, the unit price will be prorated to the billing period */ + fun prorate(prorate: Boolean?) = prorate(JsonField.ofNullable(prorate)) + + /** + * Alias for [Builder.prorate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun prorate(prorate: Boolean) = prorate(prorate as Boolean?) + + /** + * Sets [Builder.prorate] to an arbitrary JSON value. + * + * You should usually call [Builder.prorate] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun prorate(prorate: JsonField) = apply { this.prorate = prorate } + + /** Used to determine the unit rate (optional) */ + fun secondDimension(secondDimension: String?) = + secondDimension(JsonField.ofNullable(secondDimension)) + + /** + * Sets [Builder.secondDimension] to an arbitrary JSON value. + * + * You should usually call [Builder.secondDimension] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun secondDimension(secondDimension: JsonField) = apply { + this.secondDimension = secondDimension + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -1293,9 +1529,27 @@ private constructor( * Returns an immutable instance of [ScalableMatrixWithUnitPricingConfig]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .firstDimension() + * .matrixScalingFactors() + * .unitPrice() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ fun build(): ScalableMatrixWithUnitPricingConfig = - ScalableMatrixWithUnitPricingConfig(additionalProperties.toImmutable()) + ScalableMatrixWithUnitPricingConfig( + checkRequired("firstDimension", firstDimension), + checkRequired("matrixScalingFactors", matrixScalingFactors).map { + it.toImmutable() + }, + checkRequired("unitPrice", unitPrice), + prorate, + secondDimension, + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false @@ -1305,6 +1559,11 @@ private constructor( return@apply } + firstDimension() + matrixScalingFactors().forEach { it.validate() } + unitPrice() + prorate() + secondDimension() validated = true } @@ -1323,7 +1582,280 @@ private constructor( * Used for best match union deserialization. */ internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + (if (firstDimension.asKnown() == null) 0 else 1) + + (matrixScalingFactors.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + (if (unitPrice.asKnown() == null) 0 else 1) + + (if (prorate.asKnown() == null) 0 else 1) + + (if (secondDimension.asKnown() == null) 0 else 1) + + /** Configuration for a single matrix scaling factor */ + class MatrixScalingFactor + private constructor( + private val firstDimensionValue: JsonField, + private val scalingFactor: JsonField, + private val secondDimensionValue: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("first_dimension_value") + @ExcludeMissing + firstDimensionValue: JsonField = JsonMissing.of(), + @JsonProperty("scaling_factor") + @ExcludeMissing + scalingFactor: JsonField = JsonMissing.of(), + @JsonProperty("second_dimension_value") + @ExcludeMissing + secondDimensionValue: JsonField = JsonMissing.of(), + ) : this(firstDimensionValue, scalingFactor, secondDimensionValue, mutableMapOf()) + + /** + * First dimension value + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun firstDimensionValue(): String = + firstDimensionValue.getRequired("first_dimension_value") + + /** + * Scaling factor + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun scalingFactor(): String = scalingFactor.getRequired("scaling_factor") + + /** + * Second dimension value (optional) + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun secondDimensionValue(): String? = + secondDimensionValue.getNullable("second_dimension_value") + + /** + * Returns the raw JSON value of [firstDimensionValue]. + * + * Unlike [firstDimensionValue], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("first_dimension_value") + @ExcludeMissing + fun _firstDimensionValue(): JsonField = firstDimensionValue + + /** + * Returns the raw JSON value of [scalingFactor]. + * + * Unlike [scalingFactor], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("scaling_factor") + @ExcludeMissing + fun _scalingFactor(): JsonField = scalingFactor + + /** + * Returns the raw JSON value of [secondDimensionValue]. + * + * Unlike [secondDimensionValue], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("second_dimension_value") + @ExcludeMissing + fun _secondDimensionValue(): JsonField = secondDimensionValue + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [MatrixScalingFactor]. + * + * The following fields are required: + * ```kotlin + * .firstDimensionValue() + * .scalingFactor() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [MatrixScalingFactor]. */ + class Builder internal constructor() { + + private var firstDimensionValue: JsonField? = null + private var scalingFactor: JsonField? = null + private var secondDimensionValue: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(matrixScalingFactor: MatrixScalingFactor) = apply { + firstDimensionValue = matrixScalingFactor.firstDimensionValue + scalingFactor = matrixScalingFactor.scalingFactor + secondDimensionValue = matrixScalingFactor.secondDimensionValue + additionalProperties = matrixScalingFactor.additionalProperties.toMutableMap() + } + + /** First dimension value */ + fun firstDimensionValue(firstDimensionValue: String) = + firstDimensionValue(JsonField.of(firstDimensionValue)) + + /** + * Sets [Builder.firstDimensionValue] to an arbitrary JSON value. + * + * You should usually call [Builder.firstDimensionValue] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun firstDimensionValue(firstDimensionValue: JsonField) = apply { + this.firstDimensionValue = firstDimensionValue + } + + /** Scaling factor */ + fun scalingFactor(scalingFactor: String) = + scalingFactor(JsonField.of(scalingFactor)) + + /** + * Sets [Builder.scalingFactor] to an arbitrary JSON value. + * + * You should usually call [Builder.scalingFactor] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun scalingFactor(scalingFactor: JsonField) = apply { + this.scalingFactor = scalingFactor + } + + /** Second dimension value (optional) */ + fun secondDimensionValue(secondDimensionValue: String?) = + secondDimensionValue(JsonField.ofNullable(secondDimensionValue)) + + /** + * Sets [Builder.secondDimensionValue] to an arbitrary JSON value. + * + * You should usually call [Builder.secondDimensionValue] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun secondDimensionValue(secondDimensionValue: JsonField) = apply { + this.secondDimensionValue = secondDimensionValue + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [MatrixScalingFactor]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .firstDimensionValue() + * .scalingFactor() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MatrixScalingFactor = + MatrixScalingFactor( + checkRequired("firstDimensionValue", firstDimensionValue), + checkRequired("scalingFactor", scalingFactor), + secondDimensionValue, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MatrixScalingFactor = apply { + if (validated) { + return@apply + } + + firstDimensionValue() + scalingFactor() + secondDimensionValue() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (firstDimensionValue.asKnown() == null) 0 else 1) + + (if (scalingFactor.asKnown() == null) 0 else 1) + + (if (secondDimensionValue.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MatrixScalingFactor && + firstDimensionValue == other.firstDimensionValue && + scalingFactor == other.scalingFactor && + secondDimensionValue == other.secondDimensionValue && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + firstDimensionValue, + scalingFactor, + secondDimensionValue, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MatrixScalingFactor{firstDimensionValue=$firstDimensionValue, scalingFactor=$scalingFactor, secondDimensionValue=$secondDimensionValue, additionalProperties=$additionalProperties}" + } override fun equals(other: Any?): Boolean { if (this === other) { @@ -1331,15 +1863,29 @@ private constructor( } return other is ScalableMatrixWithUnitPricingConfig && + firstDimension == other.firstDimension && + matrixScalingFactors == other.matrixScalingFactors && + unitPrice == other.unitPrice && + prorate == other.prorate && + secondDimension == other.secondDimension && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + private val hashCode: Int by lazy { + Objects.hash( + firstDimension, + matrixScalingFactors, + unitPrice, + prorate, + secondDimension, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode override fun toString() = - "ScalableMatrixWithUnitPricingConfig{additionalProperties=$additionalProperties}" + "ScalableMatrixWithUnitPricingConfig{firstDimension=$firstDimension, matrixScalingFactors=$matrixScalingFactors, unitPrice=$unitPrice, prorate=$prorate, secondDimension=$secondDimension, additionalProperties=$additionalProperties}" } /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionThresholdTotalAmountPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionThresholdTotalAmountPrice.kt index 55cc0573a..ffb89053d 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionThresholdTotalAmountPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionThresholdTotalAmountPrice.kt @@ -11,6 +11,7 @@ import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue +import com.withorb.api.core.checkKnown import com.withorb.api.core.checkRequired import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException @@ -126,6 +127,8 @@ private constructor( fun itemId(): String = itemId.getRequired("item_id") /** + * The pricing model type + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ @@ -140,6 +143,8 @@ private constructor( fun name(): String = name.getRequired("name") /** + * Configuration for threshold_total_amount pricing + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ @@ -529,6 +534,7 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + /** The pricing model type */ fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) /** @@ -551,6 +557,7 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } + /** Configuration for threshold_total_amount pricing */ fun thresholdTotalAmountConfig(thresholdTotalAmountConfig: ThresholdTotalAmountConfig) = thresholdTotalAmountConfig(JsonField.of(thresholdTotalAmountConfig)) @@ -1103,6 +1110,7 @@ private constructor( override fun toString() = value.toString() } + /** The pricing model type */ class ModelType @JsonCreator private constructor(private val value: JsonField) : Enum { /** @@ -1223,16 +1231,66 @@ private constructor( override fun toString() = value.toString() } + /** Configuration for threshold_total_amount pricing */ class ThresholdTotalAmountConfig - @JsonCreator private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map + private val consumptionTable: JsonField>, + private val prorate: JsonField, + private val additionalProperties: MutableMap, ) { + @JsonCreator + private constructor( + @JsonProperty("consumption_table") + @ExcludeMissing + consumptionTable: JsonField> = JsonMissing.of(), + @JsonProperty("prorate") @ExcludeMissing prorate: JsonField = JsonMissing.of(), + ) : this(consumptionTable, prorate, mutableMapOf()) + + /** + * When the quantity consumed passes a provided threshold, the configured total will be + * charged + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun consumptionTable(): List = + consumptionTable.getRequired("consumption_table") + + /** + * If true, the unit price will be prorated to the billing period + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun prorate(): Boolean? = prorate.getNullable("prorate") + + /** + * Returns the raw JSON value of [consumptionTable]. + * + * Unlike [consumptionTable], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("consumption_table") + @ExcludeMissing + fun _consumptionTable(): JsonField> = consumptionTable + + /** + * Returns the raw JSON value of [prorate]. + * + * Unlike [prorate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("prorate") @ExcludeMissing fun _prorate(): JsonField = prorate + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) fun toBuilder() = Builder().from(this) @@ -1241,6 +1299,11 @@ private constructor( /** * Returns a mutable builder for constructing an instance of * [ThresholdTotalAmountConfig]. + * + * The following fields are required: + * ```kotlin + * .consumptionTable() + * ``` */ fun builder() = Builder() } @@ -1248,13 +1311,67 @@ private constructor( /** A builder for [ThresholdTotalAmountConfig]. */ class Builder internal constructor() { + private var consumptionTable: JsonField>? = null + private var prorate: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() internal fun from(thresholdTotalAmountConfig: ThresholdTotalAmountConfig) = apply { + consumptionTable = + thresholdTotalAmountConfig.consumptionTable.map { it.toMutableList() } + prorate = thresholdTotalAmountConfig.prorate additionalProperties = thresholdTotalAmountConfig.additionalProperties.toMutableMap() } + /** + * When the quantity consumed passes a provided threshold, the configured total will be + * charged + */ + fun consumptionTable(consumptionTable: List) = + consumptionTable(JsonField.of(consumptionTable)) + + /** + * Sets [Builder.consumptionTable] to an arbitrary JSON value. + * + * You should usually call [Builder.consumptionTable] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun consumptionTable(consumptionTable: JsonField>) = apply { + this.consumptionTable = consumptionTable.map { it.toMutableList() } + } + + /** + * Adds a single [ConsumptionTable] to [Builder.consumptionTable]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addConsumptionTable(consumptionTable: ConsumptionTable) = apply { + this.consumptionTable = + (this.consumptionTable ?: JsonField.of(mutableListOf())).also { + checkKnown("consumptionTable", it).add(consumptionTable) + } + } + + /** If true, the unit price will be prorated to the billing period */ + fun prorate(prorate: Boolean?) = prorate(JsonField.ofNullable(prorate)) + + /** + * Alias for [Builder.prorate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun prorate(prorate: Boolean) = prorate(prorate as Boolean?) + + /** + * Sets [Builder.prorate] to an arbitrary JSON value. + * + * You should usually call [Builder.prorate] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun prorate(prorate: JsonField) = apply { this.prorate = prorate } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -1278,9 +1395,20 @@ private constructor( * Returns an immutable instance of [ThresholdTotalAmountConfig]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .consumptionTable() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ fun build(): ThresholdTotalAmountConfig = - ThresholdTotalAmountConfig(additionalProperties.toImmutable()) + ThresholdTotalAmountConfig( + checkRequired("consumptionTable", consumptionTable).map { it.toImmutable() }, + prorate, + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false @@ -1290,6 +1418,8 @@ private constructor( return@apply } + consumptionTable().forEach { it.validate() } + prorate() validated = true } @@ -1308,7 +1438,223 @@ private constructor( * Used for best match union deserialization. */ internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + (consumptionTable.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + (if (prorate.asKnown() == null) 0 else 1) + + /** Configuration for a single threshold */ + class ConsumptionTable + private constructor( + private val threshold: JsonField, + private val totalAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("threshold") + @ExcludeMissing + threshold: JsonField = JsonMissing.of(), + @JsonProperty("total_amount") + @ExcludeMissing + totalAmount: JsonField = JsonMissing.of(), + ) : this(threshold, totalAmount, mutableMapOf()) + + /** + * Quantity threshold + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun threshold(): String = threshold.getRequired("threshold") + + /** + * Total amount for this threshold + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun totalAmount(): String = totalAmount.getRequired("total_amount") + + /** + * Returns the raw JSON value of [threshold]. + * + * Unlike [threshold], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("threshold") + @ExcludeMissing + fun _threshold(): JsonField = threshold + + /** + * Returns the raw JSON value of [totalAmount]. + * + * Unlike [totalAmount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("total_amount") + @ExcludeMissing + fun _totalAmount(): JsonField = totalAmount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ConsumptionTable]. + * + * The following fields are required: + * ```kotlin + * .threshold() + * .totalAmount() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [ConsumptionTable]. */ + class Builder internal constructor() { + + private var threshold: JsonField? = null + private var totalAmount: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(consumptionTable: ConsumptionTable) = apply { + threshold = consumptionTable.threshold + totalAmount = consumptionTable.totalAmount + additionalProperties = consumptionTable.additionalProperties.toMutableMap() + } + + /** Quantity threshold */ + fun threshold(threshold: String) = threshold(JsonField.of(threshold)) + + /** + * Sets [Builder.threshold] to an arbitrary JSON value. + * + * You should usually call [Builder.threshold] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun threshold(threshold: JsonField) = apply { this.threshold = threshold } + + /** Total amount for this threshold */ + fun totalAmount(totalAmount: String) = totalAmount(JsonField.of(totalAmount)) + + /** + * Sets [Builder.totalAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.totalAmount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun totalAmount(totalAmount: JsonField) = apply { + this.totalAmount = totalAmount + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ConsumptionTable]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .threshold() + * .totalAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ConsumptionTable = + ConsumptionTable( + checkRequired("threshold", threshold), + checkRequired("totalAmount", totalAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ConsumptionTable = apply { + if (validated) { + return@apply + } + + threshold() + totalAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (threshold.asKnown() == null) 0 else 1) + + (if (totalAmount.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ConsumptionTable && + threshold == other.threshold && + totalAmount == other.totalAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(threshold, totalAmount, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ConsumptionTable{threshold=$threshold, totalAmount=$totalAmount, additionalProperties=$additionalProperties}" + } override fun equals(other: Any?): Boolean { if (this === other) { @@ -1316,15 +1662,19 @@ private constructor( } return other is ThresholdTotalAmountConfig && + consumptionTable == other.consumptionTable && + prorate == other.prorate && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + private val hashCode: Int by lazy { + Objects.hash(consumptionTable, prorate, additionalProperties) + } override fun hashCode(): Int = hashCode override fun toString() = - "ThresholdTotalAmountConfig{additionalProperties=$additionalProperties}" + "ThresholdTotalAmountConfig{consumptionTable=$consumptionTable, prorate=$prorate, additionalProperties=$additionalProperties}" } /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTierWithProrationPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTierWithProrationPrice.kt deleted file mode 100644 index 4719c7d2f..000000000 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTierWithProrationPrice.kt +++ /dev/null @@ -1,1486 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.withorb.api.models - -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import com.withorb.api.core.Enum -import com.withorb.api.core.ExcludeMissing -import com.withorb.api.core.JsonField -import com.withorb.api.core.JsonMissing -import com.withorb.api.core.JsonValue -import com.withorb.api.core.checkRequired -import com.withorb.api.core.toImmutable -import com.withorb.api.errors.OrbInvalidDataException -import java.util.Collections -import java.util.Objects - -class NewSubscriptionTierWithProrationPrice -private constructor( - private val cadence: JsonField, - private val itemId: JsonField, - private val modelType: JsonField, - private val name: JsonField, - private val tieredWithProrationConfig: JsonField, - private val billableMetricId: JsonField, - private val billedInAdvance: JsonField, - private val billingCycleConfiguration: JsonField, - private val conversionRate: JsonField, - private val conversionRateConfig: JsonField, - private val currency: JsonField, - private val dimensionalPriceConfiguration: JsonField, - private val externalPriceId: JsonField, - private val fixedPriceQuantity: JsonField, - private val invoiceGroupingKey: JsonField, - private val invoicingCycleConfiguration: JsonField, - private val metadata: JsonField, - private val referenceId: JsonField, - private val additionalProperties: MutableMap, -) { - - @JsonCreator - private constructor( - @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), - @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - modelType: JsonField = JsonMissing.of(), - @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("tiered_with_proration_config") - @ExcludeMissing - tieredWithProrationConfig: JsonField = JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - billingCycleConfiguration: JsonField = JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("conversion_rate_config") - @ExcludeMissing - conversionRateConfig: JsonField = JsonMissing.of(), - @JsonProperty("currency") @ExcludeMissing currency: JsonField = JsonMissing.of(), - @JsonProperty("dimensional_price_configuration") - @ExcludeMissing - dimensionalPriceConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - invoicingCycleConfiguration: JsonField = JsonMissing.of(), - @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), - @JsonProperty("reference_id") - @ExcludeMissing - referenceId: JsonField = JsonMissing.of(), - ) : this( - cadence, - itemId, - modelType, - name, - tieredWithProrationConfig, - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - conversionRateConfig, - currency, - dimensionalPriceConfiguration, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - mutableMapOf(), - ) - - /** - * The cadence to bill for this price on. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly - * missing or null (e.g. if the server responded with an unexpected value). - */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - /** - * The id of the item the price will be associated with. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly - * missing or null (e.g. if the server responded with an unexpected value). - */ - fun itemId(): String = itemId.getRequired("item_id") - - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly - * missing or null (e.g. if the server responded with an unexpected value). - */ - fun modelType(): ModelType = modelType.getRequired("model_type") - - /** - * The name of the price. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly - * missing or null (e.g. if the server responded with an unexpected value). - */ - fun name(): String = name.getRequired("name") - - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly - * missing or null (e.g. if the server responded with an unexpected value). - */ - fun tieredWithProrationConfig(): TieredWithProrationConfig = - tieredWithProrationConfig.getRequired("tiered_with_proration_config") - - /** - * The id of the billable metric for the price. Only needed if the price is usage-based. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - fun billableMetricId(): String? = billableMetricId.getNullable("billable_metric_id") - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this is true, - * and in-arrears if this is false. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") - - /** - * For custom cadence: specifies the duration of the billing period in days or months. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - fun billingCycleConfiguration(): NewBillingCycleConfiguration? = - billingCycleConfiguration.getNullable("billing_cycle_configuration") - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") - - /** - * The configuration for the rate of the price currency to the invoicing currency. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - fun conversionRateConfig(): ConversionRateConfig? = - conversionRateConfig.getNullable("conversion_rate_config") - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this price is - * billed. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - fun currency(): String? = currency.getNullable("currency") - - /** - * For dimensional price: specifies a price group and dimension values - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = - dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") - - /** - * An alias for the price. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") - - /** - * If the Price represents a fixed cost, this represents the quantity of units applied. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - fun fixedPriceQuantity(): Double? = fixedPriceQuantity.getNullable("fixed_price_quantity") - - /** - * The property used to group this price on an invoice - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - fun invoiceGroupingKey(): String? = invoiceGroupingKey.getNullable("invoice_grouping_key") - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. If - * unspecified, a single invoice is produced per billing cycle. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by setting - * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to - * `null`. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - fun metadata(): Metadata? = metadata.getNullable("metadata") - - /** - * A transient ID that can be used to reference this price when adding adjustments in the same - * API call. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - fun referenceId(): String? = referenceId.getNullable("reference_id") - - /** - * Returns the raw JSON value of [cadence]. - * - * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence - - /** - * Returns the raw JSON value of [itemId]. - * - * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - /** - * Returns the raw JSON value of [modelType]. - * - * Unlike [modelType], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonField = modelType - - /** - * Returns the raw JSON value of [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - /** - * Returns the raw JSON value of [tieredWithProrationConfig]. - * - * Unlike [tieredWithProrationConfig], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("tiered_with_proration_config") - @ExcludeMissing - fun _tieredWithProrationConfig(): JsonField = - tieredWithProrationConfig - - /** - * Returns the raw JSON value of [billableMetricId]. - * - * Unlike [billableMetricId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = billableMetricId - - /** - * Returns the raw JSON value of [billedInAdvance]. - * - * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance - - /** - * Returns the raw JSON value of [billingCycleConfiguration]. - * - * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** - * Returns the raw JSON value of [conversionRate]. - * - * Unlike [conversionRate], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** - * Returns the raw JSON value of [conversionRateConfig]. - * - * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("conversion_rate_config") - @ExcludeMissing - fun _conversionRateConfig(): JsonField = conversionRateConfig - - /** - * Returns the raw JSON value of [currency]. - * - * Unlike [currency], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - - /** - * Returns the raw JSON value of [dimensionalPriceConfiguration]. - * - * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("dimensional_price_configuration") - @ExcludeMissing - fun _dimensionalPriceConfiguration(): JsonField = - dimensionalPriceConfiguration - - /** - * Returns the raw JSON value of [externalPriceId]. - * - * Unlike [externalPriceId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * Returns the raw JSON value of [fixedPriceQuantity]. - * - * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** - * Returns the raw JSON value of [invoiceGroupingKey]. - * - * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Returns the raw JSON value of [invoicingCycleConfiguration]. - * - * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * Returns the raw JSON value of [metadata]. - * - * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata - - /** - * Returns the raw JSON value of [referenceId]. - * - * Unlike [referenceId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("reference_id") - @ExcludeMissing - fun _referenceId(): JsonField = referenceId - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [NewSubscriptionTierWithProrationPrice]. - * - * The following fields are required: - * ```kotlin - * .cadence() - * .itemId() - * .modelType() - * .name() - * .tieredWithProrationConfig() - * ``` - */ - fun builder() = Builder() - } - - /** A builder for [NewSubscriptionTierWithProrationPrice]. */ - class Builder internal constructor() { - - private var cadence: JsonField? = null - private var itemId: JsonField? = null - private var modelType: JsonField? = null - private var name: JsonField? = null - private var tieredWithProrationConfig: JsonField? = null - private var billableMetricId: JsonField = JsonMissing.of() - private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var conversionRateConfig: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var dimensionalPriceConfiguration: JsonField = - JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var referenceId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from( - newSubscriptionTierWithProrationPrice: NewSubscriptionTierWithProrationPrice - ) = apply { - cadence = newSubscriptionTierWithProrationPrice.cadence - itemId = newSubscriptionTierWithProrationPrice.itemId - modelType = newSubscriptionTierWithProrationPrice.modelType - name = newSubscriptionTierWithProrationPrice.name - tieredWithProrationConfig = - newSubscriptionTierWithProrationPrice.tieredWithProrationConfig - billableMetricId = newSubscriptionTierWithProrationPrice.billableMetricId - billedInAdvance = newSubscriptionTierWithProrationPrice.billedInAdvance - billingCycleConfiguration = - newSubscriptionTierWithProrationPrice.billingCycleConfiguration - conversionRate = newSubscriptionTierWithProrationPrice.conversionRate - conversionRateConfig = newSubscriptionTierWithProrationPrice.conversionRateConfig - currency = newSubscriptionTierWithProrationPrice.currency - dimensionalPriceConfiguration = - newSubscriptionTierWithProrationPrice.dimensionalPriceConfiguration - externalPriceId = newSubscriptionTierWithProrationPrice.externalPriceId - fixedPriceQuantity = newSubscriptionTierWithProrationPrice.fixedPriceQuantity - invoiceGroupingKey = newSubscriptionTierWithProrationPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newSubscriptionTierWithProrationPrice.invoicingCycleConfiguration - metadata = newSubscriptionTierWithProrationPrice.metadata - referenceId = newSubscriptionTierWithProrationPrice.referenceId - additionalProperties = - newSubscriptionTierWithProrationPrice.additionalProperties.toMutableMap() - } - - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** - * Sets [Builder.cadence] to an arbitrary JSON value. - * - * You should usually call [Builder.cadence] with a well-typed [Cadence] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - - /** The id of the item the price will be associated with. */ - fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - - /** - * Sets [Builder.itemId] to an arbitrary JSON value. - * - * You should usually call [Builder.itemId] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - - /** - * Sets [Builder.modelType] to an arbitrary JSON value. - * - * You should usually call [Builder.modelType] with a well-typed [ModelType] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun modelType(modelType: JsonField) = apply { this.modelType = modelType } - - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) - - /** - * Sets [Builder.name] to an arbitrary JSON value. - * - * You should usually call [Builder.name] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun name(name: JsonField) = apply { this.name = name } - - fun tieredWithProrationConfig(tieredWithProrationConfig: TieredWithProrationConfig) = - tieredWithProrationConfig(JsonField.of(tieredWithProrationConfig)) - - /** - * Sets [Builder.tieredWithProrationConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.tieredWithProrationConfig] with a well-typed - * [TieredWithProrationConfig] value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. - */ - fun tieredWithProrationConfig( - tieredWithProrationConfig: JsonField - ) = apply { this.tieredWithProrationConfig = tieredWithProrationConfig } - - /** The id of the billable metric for the price. Only needed if the price is usage-based. */ - fun billableMetricId(billableMetricId: String?) = - billableMetricId(JsonField.ofNullable(billableMetricId)) - - /** - * Sets [Builder.billableMetricId] to an arbitrary JSON value. - * - * You should usually call [Builder.billableMetricId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun billableMetricId(billableMetricId: JsonField) = apply { - this.billableMetricId = billableMetricId - } - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this is - * true, and in-arrears if this is false. - */ - fun billedInAdvance(billedInAdvance: Boolean?) = - billedInAdvance(JsonField.ofNullable(billedInAdvance)) - - /** - * Alias for [Builder.billedInAdvance]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun billedInAdvance(billedInAdvance: Boolean) = billedInAdvance(billedInAdvance as Boolean?) - - /** - * Sets [Builder.billedInAdvance] to an arbitrary JSON value. - * - * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun billedInAdvance(billedInAdvance: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** For custom cadence: specifies the duration of the billing period in days or months. */ - fun billingCycleConfiguration(billingCycleConfiguration: NewBillingCycleConfiguration?) = - billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - - /** - * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.billingCycleConfiguration] with a well-typed - * [NewBillingCycleConfiguration] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: JsonField - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double?) = - conversionRate(JsonField.ofNullable(conversionRate)) - - /** - * Alias for [Builder.conversionRate]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) - - /** - * Sets [Builder.conversionRate] to an arbitrary JSON value. - * - * You should usually call [Builder.conversionRate] with a well-typed [Double] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** The configuration for the rate of the price currency to the invoicing currency. */ - fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = - conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) - - /** - * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.conversionRateConfig] with a well-typed - * [ConversionRateConfig] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun conversionRateConfig(conversionRateConfig: JsonField) = apply { - this.conversionRateConfig = conversionRateConfig - } - - /** Alias for calling [conversionRateConfig] with `ConversionRateConfig.ofUnit(unit)`. */ - fun conversionRateConfig(unit: UnitConversionRateConfig) = - conversionRateConfig(ConversionRateConfig.ofUnit(unit)) - - /** - * Alias for calling [conversionRateConfig] with the following: - * ```kotlin - * UnitConversionRateConfig.builder() - * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) - * .unitConfig(unitConfig) - * .build() - * ``` - */ - fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = - conversionRateConfig( - UnitConversionRateConfig.builder() - .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) - .unitConfig(unitConfig) - .build() - ) - - /** - * Alias for calling [conversionRateConfig] with `ConversionRateConfig.ofTiered(tiered)`. - */ - fun conversionRateConfig(tiered: TieredConversionRateConfig) = - conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) - - /** - * Alias for calling [conversionRateConfig] with the following: - * ```kotlin - * TieredConversionRateConfig.builder() - * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) - * .tieredConfig(tieredConfig) - * .build() - * ``` - */ - fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = - conversionRateConfig( - TieredConversionRateConfig.builder() - .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) - .tieredConfig(tieredConfig) - .build() - ) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this price is - * billed. - */ - fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) - - /** - * Sets [Builder.currency] to an arbitrary JSON value. - * - * You should usually call [Builder.currency] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } - - /** For dimensional price: specifies a price group and dimension values */ - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? - ) = dimensionalPriceConfiguration(JsonField.ofNullable(dimensionalPriceConfiguration)) - - /** - * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.dimensionalPriceConfiguration] with a well-typed - * [NewDimensionalPriceConfiguration] value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: JsonField - ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** - * Sets [Builder.externalPriceId] to an arbitrary JSON value. - * - * You should usually call [Builder.externalPriceId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun externalPriceId(externalPriceId: JsonField) = apply { - this.externalPriceId = externalPriceId - } - - /** If the Price represents a fixed cost, this represents the quantity of units applied. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = - fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) - - /** - * Alias for [Builder.fixedPriceQuantity]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. - * - * You should usually call [Builder.fixedPriceQuantity] with a well-typed [Double] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = - invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) - - /** - * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. - * - * You should usually call [Builder.invoiceGroupingKey] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { - this.invoiceGroupingKey = invoiceGroupingKey - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. If - * unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: NewBillingCycleConfiguration? - ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) - - /** - * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.invoicingCycleConfiguration] with a well-typed - * [NewBillingCycleConfiguration] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by - * setting the value to `null`, and the entire metadata mapping can be cleared by setting - * `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * Sets [Builder.metadata] to an arbitrary JSON value. - * - * You should usually call [Builder.metadata] with a well-typed [Metadata] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - - /** - * A transient ID that can be used to reference this price when adding adjustments in the - * same API call. - */ - fun referenceId(referenceId: String?) = referenceId(JsonField.ofNullable(referenceId)) - - /** - * Sets [Builder.referenceId] to an arbitrary JSON value. - * - * You should usually call [Builder.referenceId] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun referenceId(referenceId: JsonField) = apply { this.referenceId = referenceId } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [NewSubscriptionTierWithProrationPrice]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```kotlin - * .cadence() - * .itemId() - * .modelType() - * .name() - * .tieredWithProrationConfig() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): NewSubscriptionTierWithProrationPrice = - NewSubscriptionTierWithProrationPrice( - checkRequired("cadence", cadence), - checkRequired("itemId", itemId), - checkRequired("modelType", modelType), - checkRequired("name", name), - checkRequired("tieredWithProrationConfig", tieredWithProrationConfig), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - conversionRateConfig, - currency, - dimensionalPriceConfiguration, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): NewSubscriptionTierWithProrationPrice = apply { - if (validated) { - return@apply - } - - cadence().validate() - itemId() - modelType().validate() - name() - tieredWithProrationConfig().validate() - billableMetricId() - billedInAdvance() - billingCycleConfiguration()?.validate() - conversionRate() - conversionRateConfig()?.validate() - currency() - dimensionalPriceConfiguration()?.validate() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration()?.validate() - metadata()?.validate() - referenceId() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (cadence.asKnown()?.validity() ?: 0) + - (if (itemId.asKnown() == null) 0 else 1) + - (modelType.asKnown()?.validity() ?: 0) + - (if (name.asKnown() == null) 0 else 1) + - (tieredWithProrationConfig.asKnown()?.validity() ?: 0) + - (if (billableMetricId.asKnown() == null) 0 else 1) + - (if (billedInAdvance.asKnown() == null) 0 else 1) + - (billingCycleConfiguration.asKnown()?.validity() ?: 0) + - (if (conversionRate.asKnown() == null) 0 else 1) + - (conversionRateConfig.asKnown()?.validity() ?: 0) + - (if (currency.asKnown() == null) 0 else 1) + - (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + - (if (externalPriceId.asKnown() == null) 0 else 1) + - (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + - (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + - (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + - (metadata.asKnown()?.validity() ?: 0) + - (if (referenceId.asKnown() == null) 0 else 1) - - /** The cadence to bill for this price on. */ - class Cadence @JsonCreator private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API may respond with new members that the SDK is - * unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - val ANNUAL = of("annual") - - val SEMI_ANNUAL = of("semi_annual") - - val MONTHLY = of("monthly") - - val QUARTERLY = of("quarterly") - - val ONE_TIME = of("one_time") - - val CUSTOM = of("custom") - - fun of(value: String) = Cadence(JsonField.of(value)) - } - - /** An enum containing [Cadence]'s known values. */ - enum class Known { - ANNUAL, - SEMI_ANNUAL, - MONTHLY, - QUARTERLY, - ONE_TIME, - CUSTOM, - } - - /** - * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Cadence] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if the - * SDK is on an older version than the API, then the API may respond with new members that - * the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - ANNUAL, - SEMI_ANNUAL, - MONTHLY, - QUARTERLY, - ONE_TIME, - CUSTOM, - /** An enum member indicating that [Cadence] was instantiated with an unknown value. */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you want - * to throw for the unknown case. - */ - fun value(): Value = - when (this) { - ANNUAL -> Value.ANNUAL - SEMI_ANNUAL -> Value.SEMI_ANNUAL - MONTHLY -> Value.MONTHLY - QUARTERLY -> Value.QUARTERLY - ONE_TIME -> Value.ONE_TIME - CUSTOM -> Value.CUSTOM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and don't - * want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known member. - */ - fun known(): Known = - when (this) { - ANNUAL -> Known.ANNUAL - SEMI_ANNUAL -> Known.SEMI_ANNUAL - MONTHLY -> Known.MONTHLY - QUARTERLY -> Known.QUARTERLY - ONE_TIME -> Known.ONE_TIME - CUSTOM -> Known.CUSTOM - else -> throw OrbInvalidDataException("Unknown Cadence: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the expected - * primitive type. - */ - fun asString(): String = - _value().asString() ?: throw OrbInvalidDataException("Value is not a String") - - private var validated: Boolean = false - - fun validate(): Cadence = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Cadence && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class ModelType @JsonCreator private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API may respond with new members that the SDK is - * unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - val TIERED_WITH_PRORATION = of("tiered_with_proration") - - fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - TIERED_WITH_PRORATION - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if the - * SDK is on an older version than the API, then the API may respond with new members that - * the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - TIERED_WITH_PRORATION, - /** - * An enum member indicating that [ModelType] was instantiated with an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you want - * to throw for the unknown case. - */ - fun value(): Value = - when (this) { - TIERED_WITH_PRORATION -> Value.TIERED_WITH_PRORATION - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and don't - * want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known member. - */ - fun known(): Known = - when (this) { - TIERED_WITH_PRORATION -> Known.TIERED_WITH_PRORATION - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the expected - * primitive type. - */ - fun asString(): String = - _value().asString() ?: throw OrbInvalidDataException("Value is not a String") - - private var validated: Boolean = false - - fun validate(): ModelType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ModelType && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class TieredWithProrationConfig - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [TieredWithProrationConfig]. - */ - fun builder() = Builder() - } - - /** A builder for [TieredWithProrationConfig]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(tieredWithProrationConfig: TieredWithProrationConfig) = apply { - additionalProperties = tieredWithProrationConfig.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [TieredWithProrationConfig]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): TieredWithProrationConfig = - TieredWithProrationConfig(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): TieredWithProrationConfig = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is TieredWithProrationConfig && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "TieredWithProrationConfig{additionalProperties=$additionalProperties}" - } - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by setting - * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to - * `null`. - */ - class Metadata - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Metadata]. */ - fun builder() = Builder() - } - - /** A builder for [Metadata]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(metadata: Metadata) = apply { - additionalProperties = metadata.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Metadata]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Metadata && additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is NewSubscriptionTierWithProrationPrice && - cadence == other.cadence && - itemId == other.itemId && - modelType == other.modelType && - name == other.name && - tieredWithProrationConfig == other.tieredWithProrationConfig && - billableMetricId == other.billableMetricId && - billedInAdvance == other.billedInAdvance && - billingCycleConfiguration == other.billingCycleConfiguration && - conversionRate == other.conversionRate && - conversionRateConfig == other.conversionRateConfig && - currency == other.currency && - dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && - externalPriceId == other.externalPriceId && - fixedPriceQuantity == other.fixedPriceQuantity && - invoiceGroupingKey == other.invoiceGroupingKey && - invoicingCycleConfiguration == other.invoicingCycleConfiguration && - metadata == other.metadata && - referenceId == other.referenceId && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - cadence, - itemId, - modelType, - name, - tieredWithProrationConfig, - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - conversionRateConfig, - currency, - dimensionalPriceConfiguration, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewSubscriptionTierWithProrationPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredWithProrationConfig=$tieredWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" -} diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTieredPackagePrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTieredPackagePrice.kt index bdd628241..b673bd3fd 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTieredPackagePrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTieredPackagePrice.kt @@ -11,6 +11,7 @@ import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue +import com.withorb.api.core.checkKnown import com.withorb.api.core.checkRequired import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException @@ -126,6 +127,8 @@ private constructor( fun itemId(): String = itemId.getRequired("item_id") /** + * The pricing model type + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ @@ -140,6 +143,8 @@ private constructor( fun name(): String = name.getRequired("name") /** + * Configuration for tiered_package pricing + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ @@ -526,6 +531,7 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + /** The pricing model type */ fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) /** @@ -548,6 +554,7 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } + /** Configuration for tiered_package pricing */ fun tieredPackageConfig(tieredPackageConfig: TieredPackageConfig) = tieredPackageConfig(JsonField.of(tieredPackageConfig)) @@ -1100,6 +1107,7 @@ private constructor( override fun toString() = value.toString() } + /** The pricing model type */ class ModelType @JsonCreator private constructor(private val value: JsonField) : Enum { /** @@ -1220,34 +1228,137 @@ private constructor( override fun toString() = value.toString() } + /** Configuration for tiered_package pricing */ class TieredPackageConfig - @JsonCreator private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map + private val packageSize: JsonField, + private val tiers: JsonField>, + private val additionalProperties: MutableMap, ) { + @JsonCreator + private constructor( + @JsonProperty("package_size") + @ExcludeMissing + packageSize: JsonField = JsonMissing.of(), + @JsonProperty("tiers") @ExcludeMissing tiers: JsonField> = JsonMissing.of(), + ) : this(packageSize, tiers, mutableMapOf()) + + /** + * Package size + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun packageSize(): String = packageSize.getRequired("package_size") + + /** + * Apply tiered pricing after rounding up the quantity to the package size. Tiers are + * defined using exclusive lower bounds. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun tiers(): List = tiers.getRequired("tiers") + + /** + * Returns the raw JSON value of [packageSize]. + * + * Unlike [packageSize], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("package_size") + @ExcludeMissing + fun _packageSize(): JsonField = packageSize + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tiers") @ExcludeMissing fun _tiers(): JsonField> = tiers + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) fun toBuilder() = Builder().from(this) companion object { - /** Returns a mutable builder for constructing an instance of [TieredPackageConfig]. */ + /** + * Returns a mutable builder for constructing an instance of [TieredPackageConfig]. + * + * The following fields are required: + * ```kotlin + * .packageSize() + * .tiers() + * ``` + */ fun builder() = Builder() } /** A builder for [TieredPackageConfig]. */ class Builder internal constructor() { + private var packageSize: JsonField? = null + private var tiers: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(tieredPackageConfig: TieredPackageConfig) = apply { + packageSize = tieredPackageConfig.packageSize + tiers = tieredPackageConfig.tiers.map { it.toMutableList() } additionalProperties = tieredPackageConfig.additionalProperties.toMutableMap() } + /** Package size */ + fun packageSize(packageSize: String) = packageSize(JsonField.of(packageSize)) + + /** + * Sets [Builder.packageSize] to an arbitrary JSON value. + * + * You should usually call [Builder.packageSize] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun packageSize(packageSize: JsonField) = apply { + this.packageSize = packageSize + } + + /** + * Apply tiered pricing after rounding up the quantity to the package size. Tiers are + * defined using exclusive lower bounds. + */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -1271,9 +1382,21 @@ private constructor( * Returns an immutable instance of [TieredPackageConfig]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .packageSize() + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ fun build(): TieredPackageConfig = - TieredPackageConfig(additionalProperties.toImmutable()) + TieredPackageConfig( + checkRequired("packageSize", packageSize), + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false @@ -1283,6 +1406,8 @@ private constructor( return@apply } + packageSize() + tiers().forEach { it.validate() } validated = true } @@ -1301,7 +1426,221 @@ private constructor( * Used for best match union deserialization. */ internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + (if (packageSize.asKnown() == null) 0 else 1) + + (tiers.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single tier with business logic */ + class Tier + private constructor( + private val perUnit: JsonField, + private val tierLowerBound: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("per_unit") + @ExcludeMissing + perUnit: JsonField = JsonMissing.of(), + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + ) : this(perUnit, tierLowerBound, mutableMapOf()) + + /** + * Price per package + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun perUnit(): String = perUnit.getRequired("per_unit") + + /** + * Tier lower bound + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun tierLowerBound(): String = tierLowerBound.getRequired("tier_lower_bound") + + /** + * Returns the raw JSON value of [perUnit]. + * + * Unlike [perUnit], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("per_unit") @ExcludeMissing fun _perUnit(): JsonField = perUnit + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Tier]. + * + * The following fields are required: + * ```kotlin + * .perUnit() + * .tierLowerBound() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var perUnit: JsonField? = null + private var tierLowerBound: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(tier: Tier) = apply { + perUnit = tier.perUnit + tierLowerBound = tier.tierLowerBound + additionalProperties = tier.additionalProperties.toMutableMap() + } + + /** Price per package */ + fun perUnit(perUnit: String) = perUnit(JsonField.of(perUnit)) + + /** + * Sets [Builder.perUnit] to an arbitrary JSON value. + * + * You should usually call [Builder.perUnit] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun perUnit(perUnit: JsonField) = apply { this.perUnit = perUnit } + + /** Tier lower bound */ + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Tier]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .perUnit() + * .tierLowerBound() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("perUnit", perUnit), + checkRequired("tierLowerBound", tierLowerBound), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + perUnit() + tierLowerBound() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (perUnit.asKnown() == null) 0 else 1) + + (if (tierLowerBound.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + perUnit == other.perUnit && + tierLowerBound == other.tierLowerBound && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(perUnit, tierLowerBound, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{perUnit=$perUnit, tierLowerBound=$tierLowerBound, additionalProperties=$additionalProperties}" + } override fun equals(other: Any?): Boolean { if (this === other) { @@ -1309,14 +1648,17 @@ private constructor( } return other is TieredPackageConfig && + packageSize == other.packageSize && + tiers == other.tiers && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(packageSize, tiers, additionalProperties) } override fun hashCode(): Int = hashCode - override fun toString() = "TieredPackageConfig{additionalProperties=$additionalProperties}" + override fun toString() = + "TieredPackageConfig{packageSize=$packageSize, tiers=$tiers, additionalProperties=$additionalProperties}" } /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTieredPackageWithMinimumPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTieredPackageWithMinimumPrice.kt index e4aad85c8..664f83455 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTieredPackageWithMinimumPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTieredPackageWithMinimumPrice.kt @@ -11,6 +11,7 @@ import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue +import com.withorb.api.core.checkKnown import com.withorb.api.core.checkRequired import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException @@ -127,6 +128,8 @@ private constructor( fun itemId(): String = itemId.getRequired("item_id") /** + * The pricing model type + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ @@ -141,6 +144,8 @@ private constructor( fun name(): String = name.getRequired("name") /** + * Configuration for tiered_package_with_minimum pricing + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ @@ -532,6 +537,7 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + /** The pricing model type */ fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) /** @@ -554,6 +560,7 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } + /** Configuration for tiered_package_with_minimum pricing */ fun tieredPackageWithMinimumConfig( tieredPackageWithMinimumConfig: TieredPackageWithMinimumConfig ) = tieredPackageWithMinimumConfig(JsonField.of(tieredPackageWithMinimumConfig)) @@ -1107,6 +1114,7 @@ private constructor( override fun toString() = value.toString() } + /** The pricing model type */ class ModelType @JsonCreator private constructor(private val value: JsonField) : Enum { /** @@ -1227,16 +1235,64 @@ private constructor( override fun toString() = value.toString() } + /** Configuration for tiered_package_with_minimum pricing */ class TieredPackageWithMinimumConfig - @JsonCreator private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map + private val packageSize: JsonField, + private val tiers: JsonField>, + private val additionalProperties: MutableMap, ) { + @JsonCreator + private constructor( + @JsonProperty("package_size") + @ExcludeMissing + packageSize: JsonField = JsonMissing.of(), + @JsonProperty("tiers") @ExcludeMissing tiers: JsonField> = JsonMissing.of(), + ) : this(packageSize, tiers, mutableMapOf()) + + /** + * Package size + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun packageSize(): Double = packageSize.getRequired("package_size") + + /** + * Apply tiered pricing after rounding up the quantity to the package size. Tiers are + * defined using exclusive lower bounds. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun tiers(): List = tiers.getRequired("tiers") + + /** + * Returns the raw JSON value of [packageSize]. + * + * Unlike [packageSize], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("package_size") + @ExcludeMissing + fun _packageSize(): JsonField = packageSize + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tiers") @ExcludeMissing fun _tiers(): JsonField> = tiers + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) fun toBuilder() = Builder().from(this) @@ -1245,6 +1301,12 @@ private constructor( /** * Returns a mutable builder for constructing an instance of * [TieredPackageWithMinimumConfig]. + * + * The following fields are required: + * ```kotlin + * .packageSize() + * .tiers() + * ``` */ fun builder() = Builder() } @@ -1252,14 +1314,61 @@ private constructor( /** A builder for [TieredPackageWithMinimumConfig]. */ class Builder internal constructor() { + private var packageSize: JsonField? = null + private var tiers: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(tieredPackageWithMinimumConfig: TieredPackageWithMinimumConfig) = apply { + packageSize = tieredPackageWithMinimumConfig.packageSize + tiers = tieredPackageWithMinimumConfig.tiers.map { it.toMutableList() } additionalProperties = tieredPackageWithMinimumConfig.additionalProperties.toMutableMap() } + /** Package size */ + fun packageSize(packageSize: Double) = packageSize(JsonField.of(packageSize)) + + /** + * Sets [Builder.packageSize] to an arbitrary JSON value. + * + * You should usually call [Builder.packageSize] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun packageSize(packageSize: JsonField) = apply { + this.packageSize = packageSize + } + + /** + * Apply tiered pricing after rounding up the quantity to the package size. Tiers are + * defined using exclusive lower bounds. + */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -1283,9 +1392,21 @@ private constructor( * Returns an immutable instance of [TieredPackageWithMinimumConfig]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .packageSize() + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ fun build(): TieredPackageWithMinimumConfig = - TieredPackageWithMinimumConfig(additionalProperties.toImmutable()) + TieredPackageWithMinimumConfig( + checkRequired("packageSize", packageSize), + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false @@ -1295,6 +1416,8 @@ private constructor( return@apply } + packageSize() + tiers().forEach { it.validate() } validated = true } @@ -1313,7 +1436,267 @@ private constructor( * Used for best match union deserialization. */ internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + (if (packageSize.asKnown() == null) 0 else 1) + + (tiers.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single tier */ + class Tier + private constructor( + private val minimumAmount: JsonField, + private val perUnit: JsonField, + private val tierLowerBound: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("minimum_amount") + @ExcludeMissing + minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("per_unit") + @ExcludeMissing + perUnit: JsonField = JsonMissing.of(), + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + ) : this(minimumAmount, perUnit, tierLowerBound, mutableMapOf()) + + /** + * Minimum amount + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") + + /** + * Price per package + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun perUnit(): String = perUnit.getRequired("per_unit") + + /** + * Tier lower bound + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun tierLowerBound(): String = tierLowerBound.getRequired("tier_lower_bound") + + /** + * Returns the raw JSON value of [minimumAmount]. + * + * Unlike [minimumAmount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount + + /** + * Returns the raw JSON value of [perUnit]. + * + * Unlike [perUnit], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("per_unit") @ExcludeMissing fun _perUnit(): JsonField = perUnit + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Tier]. + * + * The following fields are required: + * ```kotlin + * .minimumAmount() + * .perUnit() + * .tierLowerBound() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var minimumAmount: JsonField? = null + private var perUnit: JsonField? = null + private var tierLowerBound: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(tier: Tier) = apply { + minimumAmount = tier.minimumAmount + perUnit = tier.perUnit + tierLowerBound = tier.tierLowerBound + additionalProperties = tier.additionalProperties.toMutableMap() + } + + /** Minimum amount */ + fun minimumAmount(minimumAmount: String) = + minimumAmount(JsonField.of(minimumAmount)) + + /** + * Sets [Builder.minimumAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumAmount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount + } + + /** Price per package */ + fun perUnit(perUnit: String) = perUnit(JsonField.of(perUnit)) + + /** + * Sets [Builder.perUnit] to an arbitrary JSON value. + * + * You should usually call [Builder.perUnit] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun perUnit(perUnit: JsonField) = apply { this.perUnit = perUnit } + + /** Tier lower bound */ + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Tier]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .minimumAmount() + * .perUnit() + * .tierLowerBound() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("minimumAmount", minimumAmount), + checkRequired("perUnit", perUnit), + checkRequired("tierLowerBound", tierLowerBound), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + minimumAmount() + perUnit() + tierLowerBound() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (minimumAmount.asKnown() == null) 0 else 1) + + (if (perUnit.asKnown() == null) 0 else 1) + + (if (tierLowerBound.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + minimumAmount == other.minimumAmount && + perUnit == other.perUnit && + tierLowerBound == other.tierLowerBound && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(minimumAmount, perUnit, tierLowerBound, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{minimumAmount=$minimumAmount, perUnit=$perUnit, tierLowerBound=$tierLowerBound, additionalProperties=$additionalProperties}" + } override fun equals(other: Any?): Boolean { if (this === other) { @@ -1321,15 +1704,17 @@ private constructor( } return other is TieredPackageWithMinimumConfig && + packageSize == other.packageSize && + tiers == other.tiers && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(packageSize, tiers, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "TieredPackageWithMinimumConfig{additionalProperties=$additionalProperties}" + "TieredPackageWithMinimumConfig{packageSize=$packageSize, tiers=$tiers, additionalProperties=$additionalProperties}" } /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTieredPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTieredPrice.kt index 13636f668..7ccc05bef 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTieredPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTieredPrice.kt @@ -126,6 +126,8 @@ private constructor( fun itemId(): String = itemId.getRequired("item_id") /** + * The pricing model type + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ @@ -140,6 +142,8 @@ private constructor( fun name(): String = name.getRequired("name") /** + * Configuration for tiered pricing + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ @@ -518,6 +522,7 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + /** The pricing model type */ fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) /** @@ -540,6 +545,7 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } + /** Configuration for tiered pricing */ fun tieredConfig(tieredConfig: TieredConfig) = tieredConfig(JsonField.of(tieredConfig)) /** @@ -1091,6 +1097,7 @@ private constructor( override fun toString() = value.toString() } + /** The pricing model type */ class ModelType @JsonCreator private constructor(private val value: JsonField) : Enum { /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTieredWithMinimumPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTieredWithMinimumPrice.kt index 151fb24bc..ad9720aa4 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTieredWithMinimumPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTieredWithMinimumPrice.kt @@ -11,6 +11,7 @@ import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue +import com.withorb.api.core.checkKnown import com.withorb.api.core.checkRequired import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException @@ -126,6 +127,8 @@ private constructor( fun itemId(): String = itemId.getRequired("item_id") /** + * The pricing model type + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ @@ -140,6 +143,8 @@ private constructor( fun name(): String = name.getRequired("name") /** + * Configuration for tiered_with_minimum pricing + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ @@ -527,6 +532,7 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + /** The pricing model type */ fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) /** @@ -549,6 +555,7 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } + /** Configuration for tiered_with_minimum pricing */ fun tieredWithMinimumConfig(tieredWithMinimumConfig: TieredWithMinimumConfig) = tieredWithMinimumConfig(JsonField.of(tieredWithMinimumConfig)) @@ -1102,6 +1109,7 @@ private constructor( override fun toString() = value.toString() } + /** The pricing model type */ class ModelType @JsonCreator private constructor(private val value: JsonField) : Enum { /** @@ -1222,16 +1230,83 @@ private constructor( override fun toString() = value.toString() } + /** Configuration for tiered_with_minimum pricing */ class TieredWithMinimumConfig - @JsonCreator private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map + private val tiers: JsonField>, + private val hideZeroAmountTiers: JsonField, + private val prorate: JsonField, + private val additionalProperties: MutableMap, ) { + @JsonCreator + private constructor( + @JsonProperty("tiers") @ExcludeMissing tiers: JsonField> = JsonMissing.of(), + @JsonProperty("hide_zero_amount_tiers") + @ExcludeMissing + hideZeroAmountTiers: JsonField = JsonMissing.of(), + @JsonProperty("prorate") @ExcludeMissing prorate: JsonField = JsonMissing.of(), + ) : this(tiers, hideZeroAmountTiers, prorate, mutableMapOf()) + + /** + * Tiered pricing with a minimum amount dependent on the volume tier. Tiers are defined + * using exclusive lower bounds. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun tiers(): List = tiers.getRequired("tiers") + + /** + * If true, tiers with an accrued amount of 0 will not be included in the rating. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun hideZeroAmountTiers(): Boolean? = + hideZeroAmountTiers.getNullable("hide_zero_amount_tiers") + + /** + * If true, the unit price will be prorated to the billing period + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun prorate(): Boolean? = prorate.getNullable("prorate") + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tiers") @ExcludeMissing fun _tiers(): JsonField> = tiers + + /** + * Returns the raw JSON value of [hideZeroAmountTiers]. + * + * Unlike [hideZeroAmountTiers], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("hide_zero_amount_tiers") + @ExcludeMissing + fun _hideZeroAmountTiers(): JsonField = hideZeroAmountTiers + + /** + * Returns the raw JSON value of [prorate]. + * + * Unlike [prorate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("prorate") @ExcludeMissing fun _prorate(): JsonField = prorate + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) fun toBuilder() = Builder().from(this) @@ -1239,6 +1314,11 @@ private constructor( /** * Returns a mutable builder for constructing an instance of [TieredWithMinimumConfig]. + * + * The following fields are required: + * ```kotlin + * .tiers() + * ``` */ fun builder() = Builder() } @@ -1246,12 +1326,74 @@ private constructor( /** A builder for [TieredWithMinimumConfig]. */ class Builder internal constructor() { + private var tiers: JsonField>? = null + private var hideZeroAmountTiers: JsonField = JsonMissing.of() + private var prorate: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() internal fun from(tieredWithMinimumConfig: TieredWithMinimumConfig) = apply { + tiers = tieredWithMinimumConfig.tiers.map { it.toMutableList() } + hideZeroAmountTiers = tieredWithMinimumConfig.hideZeroAmountTiers + prorate = tieredWithMinimumConfig.prorate additionalProperties = tieredWithMinimumConfig.additionalProperties.toMutableMap() } + /** + * Tiered pricing with a minimum amount dependent on the volume tier. Tiers are defined + * using exclusive lower bounds. + */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + + /** If true, tiers with an accrued amount of 0 will not be included in the rating. */ + fun hideZeroAmountTiers(hideZeroAmountTiers: Boolean) = + hideZeroAmountTiers(JsonField.of(hideZeroAmountTiers)) + + /** + * Sets [Builder.hideZeroAmountTiers] to an arbitrary JSON value. + * + * You should usually call [Builder.hideZeroAmountTiers] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun hideZeroAmountTiers(hideZeroAmountTiers: JsonField) = apply { + this.hideZeroAmountTiers = hideZeroAmountTiers + } + + /** If true, the unit price will be prorated to the billing period */ + fun prorate(prorate: Boolean) = prorate(JsonField.of(prorate)) + + /** + * Sets [Builder.prorate] to an arbitrary JSON value. + * + * You should usually call [Builder.prorate] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun prorate(prorate: JsonField) = apply { this.prorate = prorate } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -1275,9 +1417,21 @@ private constructor( * Returns an immutable instance of [TieredWithMinimumConfig]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ fun build(): TieredWithMinimumConfig = - TieredWithMinimumConfig(additionalProperties.toImmutable()) + TieredWithMinimumConfig( + checkRequired("tiers", tiers).map { it.toImmutable() }, + hideZeroAmountTiers, + prorate, + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false @@ -1287,6 +1441,9 @@ private constructor( return@apply } + tiers().forEach { it.validate() } + hideZeroAmountTiers() + prorate() validated = true } @@ -1305,7 +1462,273 @@ private constructor( * Used for best match union deserialization. */ internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + (tiers.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + (if (hideZeroAmountTiers.asKnown() == null) 0 else 1) + + (if (prorate.asKnown() == null) 0 else 1) + + /** Configuration for a single tier */ + class Tier + private constructor( + private val minimumAmount: JsonField, + private val tierLowerBound: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("minimum_amount") + @ExcludeMissing + minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(minimumAmount, tierLowerBound, unitAmount, mutableMapOf()) + + /** + * Minimum amount + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") + + /** + * Tier lower bound + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun tierLowerBound(): String = tierLowerBound.getRequired("tier_lower_bound") + + /** + * Per unit amount + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [minimumAmount]. + * + * Unlike [minimumAmount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Tier]. + * + * The following fields are required: + * ```kotlin + * .minimumAmount() + * .tierLowerBound() + * .unitAmount() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var minimumAmount: JsonField? = null + private var tierLowerBound: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(tier: Tier) = apply { + minimumAmount = tier.minimumAmount + tierLowerBound = tier.tierLowerBound + unitAmount = tier.unitAmount + additionalProperties = tier.additionalProperties.toMutableMap() + } + + /** Minimum amount */ + fun minimumAmount(minimumAmount: String) = + minimumAmount(JsonField.of(minimumAmount)) + + /** + * Sets [Builder.minimumAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumAmount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount + } + + /** Tier lower bound */ + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + /** Per unit amount */ + fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Tier]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .minimumAmount() + * .tierLowerBound() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("minimumAmount", minimumAmount), + checkRequired("tierLowerBound", tierLowerBound), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + minimumAmount() + tierLowerBound() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (minimumAmount.asKnown() == null) 0 else 1) + + (if (tierLowerBound.asKnown() == null) 0 else 1) + + (if (unitAmount.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + minimumAmount == other.minimumAmount && + tierLowerBound == other.tierLowerBound && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(minimumAmount, tierLowerBound, unitAmount, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{minimumAmount=$minimumAmount, tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } override fun equals(other: Any?): Boolean { if (this === other) { @@ -1313,15 +1736,20 @@ private constructor( } return other is TieredWithMinimumConfig && + tiers == other.tiers && + hideZeroAmountTiers == other.hideZeroAmountTiers && + prorate == other.prorate && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + private val hashCode: Int by lazy { + Objects.hash(tiers, hideZeroAmountTiers, prorate, additionalProperties) + } override fun hashCode(): Int = hashCode override fun toString() = - "TieredWithMinimumConfig{additionalProperties=$additionalProperties}" + "TieredWithMinimumConfig{tiers=$tiers, hideZeroAmountTiers=$hideZeroAmountTiers, prorate=$prorate, additionalProperties=$additionalProperties}" } /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionUnitPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionUnitPrice.kt index 7368807a2..4aa43ab33 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionUnitPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionUnitPrice.kt @@ -126,6 +126,8 @@ private constructor( fun itemId(): String = itemId.getRequired("item_id") /** + * The pricing model type + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ @@ -140,6 +142,8 @@ private constructor( fun name(): String = name.getRequired("name") /** + * Configuration for unit pricing + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ @@ -518,6 +522,7 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + /** The pricing model type */ fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) /** @@ -540,6 +545,7 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } + /** Configuration for unit pricing */ fun unitConfig(unitConfig: UnitConfig) = unitConfig(JsonField.of(unitConfig)) /** @@ -1089,6 +1095,7 @@ private constructor( override fun toString() = value.toString() } + /** The pricing model type */ class ModelType @JsonCreator private constructor(private val value: JsonField) : Enum { /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionUnitWithPercentPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionUnitWithPercentPrice.kt index 2a46bbc80..4c6d350e1 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionUnitWithPercentPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionUnitWithPercentPrice.kt @@ -126,6 +126,8 @@ private constructor( fun itemId(): String = itemId.getRequired("item_id") /** + * The pricing model type + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ @@ -140,6 +142,8 @@ private constructor( fun name(): String = name.getRequired("name") /** + * Configuration for unit_with_percent pricing + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ @@ -527,6 +531,7 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + /** The pricing model type */ fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) /** @@ -549,6 +554,7 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } + /** Configuration for unit_with_percent pricing */ fun unitWithPercentConfig(unitWithPercentConfig: UnitWithPercentConfig) = unitWithPercentConfig(JsonField.of(unitWithPercentConfig)) @@ -1101,6 +1107,7 @@ private constructor( override fun toString() = value.toString() } + /** The pricing model type */ class ModelType @JsonCreator private constructor(private val value: JsonField) : Enum { /** @@ -1221,16 +1228,63 @@ private constructor( override fun toString() = value.toString() } + /** Configuration for unit_with_percent pricing */ class UnitWithPercentConfig - @JsonCreator private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map + private val percent: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, ) { + @JsonCreator + private constructor( + @JsonProperty("percent") @ExcludeMissing percent: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(percent, unitAmount, mutableMapOf()) + + /** + * What percent, out of 100, of the calculated total to charge + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun percent(): String = percent.getRequired("percent") + + /** + * Rate per unit of usage + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [percent]. + * + * Unlike [percent], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("percent") @ExcludeMissing fun _percent(): JsonField = percent + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) fun toBuilder() = Builder().from(this) @@ -1238,6 +1292,12 @@ private constructor( /** * Returns a mutable builder for constructing an instance of [UnitWithPercentConfig]. + * + * The following fields are required: + * ```kotlin + * .percent() + * .unitAmount() + * ``` */ fun builder() = Builder() } @@ -1245,12 +1305,40 @@ private constructor( /** A builder for [UnitWithPercentConfig]. */ class Builder internal constructor() { + private var percent: JsonField? = null + private var unitAmount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(unitWithPercentConfig: UnitWithPercentConfig) = apply { + percent = unitWithPercentConfig.percent + unitAmount = unitWithPercentConfig.unitAmount additionalProperties = unitWithPercentConfig.additionalProperties.toMutableMap() } + /** What percent, out of 100, of the calculated total to charge */ + fun percent(percent: String) = percent(JsonField.of(percent)) + + /** + * Sets [Builder.percent] to an arbitrary JSON value. + * + * You should usually call [Builder.percent] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun percent(percent: JsonField) = apply { this.percent = percent } + + /** Rate per unit of usage */ + fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { this.unitAmount = unitAmount } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -1274,9 +1362,21 @@ private constructor( * Returns an immutable instance of [UnitWithPercentConfig]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .percent() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ fun build(): UnitWithPercentConfig = - UnitWithPercentConfig(additionalProperties.toImmutable()) + UnitWithPercentConfig( + checkRequired("percent", percent), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false @@ -1286,6 +1386,8 @@ private constructor( return@apply } + percent() + unitAmount() validated = true } @@ -1304,7 +1406,7 @@ private constructor( * Used for best match union deserialization. */ internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + (if (percent.asKnown() == null) 0 else 1) + (if (unitAmount.asKnown() == null) 0 else 1) override fun equals(other: Any?): Boolean { if (this === other) { @@ -1312,15 +1414,19 @@ private constructor( } return other is UnitWithPercentConfig && + percent == other.percent && + unitAmount == other.unitAmount && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + private val hashCode: Int by lazy { + Objects.hash(percent, unitAmount, additionalProperties) + } override fun hashCode(): Int = hashCode override fun toString() = - "UnitWithPercentConfig{additionalProperties=$additionalProperties}" + "UnitWithPercentConfig{percent=$percent, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" } /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionUnitWithProrationPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionUnitWithProrationPrice.kt index 6087625cd..b0403713c 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionUnitWithProrationPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionUnitWithProrationPrice.kt @@ -126,6 +126,8 @@ private constructor( fun itemId(): String = itemId.getRequired("item_id") /** + * The pricing model type + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ @@ -140,6 +142,8 @@ private constructor( fun name(): String = name.getRequired("name") /** + * Configuration for unit_with_proration pricing + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ @@ -527,6 +531,7 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + /** The pricing model type */ fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) /** @@ -549,6 +554,7 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } + /** Configuration for unit_with_proration pricing */ fun unitWithProrationConfig(unitWithProrationConfig: UnitWithProrationConfig) = unitWithProrationConfig(JsonField.of(unitWithProrationConfig)) @@ -1102,6 +1108,7 @@ private constructor( override fun toString() = value.toString() } + /** The pricing model type */ class ModelType @JsonCreator private constructor(private val value: JsonField) : Enum { /** @@ -1222,16 +1229,46 @@ private constructor( override fun toString() = value.toString() } + /** Configuration for unit_with_proration pricing */ class UnitWithProrationConfig - @JsonCreator private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, ) { + @JsonCreator + private constructor( + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of() + ) : this(unitAmount, mutableMapOf()) + + /** + * Rate per unit of usage + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) fun toBuilder() = Builder().from(this) @@ -1239,6 +1276,11 @@ private constructor( /** * Returns a mutable builder for constructing an instance of [UnitWithProrationConfig]. + * + * The following fields are required: + * ```kotlin + * .unitAmount() + * ``` */ fun builder() = Builder() } @@ -1246,12 +1288,26 @@ private constructor( /** A builder for [UnitWithProrationConfig]. */ class Builder internal constructor() { + private var unitAmount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(unitWithProrationConfig: UnitWithProrationConfig) = apply { + unitAmount = unitWithProrationConfig.unitAmount additionalProperties = unitWithProrationConfig.additionalProperties.toMutableMap() } + /** Rate per unit of usage */ + fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { this.unitAmount = unitAmount } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -1275,9 +1331,19 @@ private constructor( * Returns an immutable instance of [UnitWithProrationConfig]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ fun build(): UnitWithProrationConfig = - UnitWithProrationConfig(additionalProperties.toImmutable()) + UnitWithProrationConfig( + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false @@ -1287,6 +1353,7 @@ private constructor( return@apply } + unitAmount() validated = true } @@ -1304,8 +1371,7 @@ private constructor( * * Used for best match union deserialization. */ - internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + internal fun validity(): Int = (if (unitAmount.asKnown() == null) 0 else 1) override fun equals(other: Any?): Boolean { if (this === other) { @@ -1313,15 +1379,16 @@ private constructor( } return other is UnitWithProrationConfig && + unitAmount == other.unitAmount && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(unitAmount, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "UnitWithProrationConfig{additionalProperties=$additionalProperties}" + "UnitWithProrationConfig{unitAmount=$unitAmount, additionalProperties=$additionalProperties}" } /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PackageConfig.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PackageConfig.kt index 5c64d7386..505639b60 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PackageConfig.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PackageConfig.kt @@ -15,6 +15,7 @@ import com.withorb.api.errors.OrbInvalidDataException import java.util.Collections import java.util.Objects +/** Configuration for package pricing */ class PackageConfig private constructor( private val packageAmount: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PerPriceCost.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PerPriceCost.kt index 631e88a88..5ba4efb39 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PerPriceCost.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PerPriceCost.kt @@ -170,18 +170,18 @@ private constructor( /** Alias for calling [price] with `Price.ofUnit(unit)`. */ fun price(unit: Price.Unit) = price(Price.ofUnit(unit)) - /** Alias for calling [price] with `Price.ofPackage(package_)`. */ - fun price(package_: Price.Package) = price(Price.ofPackage(package_)) - - /** Alias for calling [price] with `Price.ofMatrix(matrix)`. */ - fun price(matrix: Price.Matrix) = price(Price.ofMatrix(matrix)) - /** Alias for calling [price] with `Price.ofTiered(tiered)`. */ fun price(tiered: Price.Tiered) = price(Price.ofTiered(tiered)) /** Alias for calling [price] with `Price.ofBulk(bulk)`. */ fun price(bulk: Price.Bulk) = price(Price.ofBulk(bulk)) + /** Alias for calling [price] with `Price.ofPackage(package_)`. */ + fun price(package_: Price.Package) = price(Price.ofPackage(package_)) + + /** Alias for calling [price] with `Price.ofMatrix(matrix)`. */ + fun price(matrix: Price.Matrix) = price(Price.ofMatrix(matrix)) + /** Alias for calling [price] with `Price.ofThresholdTotalAmount(thresholdTotalAmount)`. */ fun price(thresholdTotalAmount: Price.ThresholdTotalAmount) = price(Price.ofThresholdTotalAmount(thresholdTotalAmount)) @@ -189,13 +189,13 @@ private constructor( /** Alias for calling [price] with `Price.ofTieredPackage(tieredPackage)`. */ fun price(tieredPackage: Price.TieredPackage) = price(Price.ofTieredPackage(tieredPackage)) - /** Alias for calling [price] with `Price.ofGroupedTiered(groupedTiered)`. */ - fun price(groupedTiered: Price.GroupedTiered) = price(Price.ofGroupedTiered(groupedTiered)) - /** Alias for calling [price] with `Price.ofTieredWithMinimum(tieredWithMinimum)`. */ fun price(tieredWithMinimum: Price.TieredWithMinimum) = price(Price.ofTieredWithMinimum(tieredWithMinimum)) + /** Alias for calling [price] with `Price.ofGroupedTiered(groupedTiered)`. */ + fun price(groupedTiered: Price.GroupedTiered) = price(Price.ofGroupedTiered(groupedTiered)) + /** * Alias for calling [price] with * `Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)`. @@ -229,6 +229,10 @@ private constructor( fun price(groupedAllocation: Price.GroupedAllocation) = price(Price.ofGroupedAllocation(groupedAllocation)) + /** Alias for calling [price] with `Price.ofBulkWithProration(bulkWithProration)`. */ + fun price(bulkWithProration: Price.BulkWithProration) = + price(Price.ofBulkWithProration(bulkWithProration)) + /** * Alias for calling [price] with * `Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)`. @@ -243,16 +247,19 @@ private constructor( fun price(groupedWithMeteredMinimum: Price.GroupedWithMeteredMinimum) = price(Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)) + /** + * Alias for calling [price] with + * `Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)`. + */ + fun price(groupedWithMinMaxThresholds: Price.GroupedWithMinMaxThresholds) = + price(Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)) + /** * Alias for calling [price] with `Price.ofMatrixWithDisplayName(matrixWithDisplayName)`. */ fun price(matrixWithDisplayName: Price.MatrixWithDisplayName) = price(Price.ofMatrixWithDisplayName(matrixWithDisplayName)) - /** Alias for calling [price] with `Price.ofBulkWithProration(bulkWithProration)`. */ - fun price(bulkWithProration: Price.BulkWithProration) = - price(Price.ofBulkWithProration(bulkWithProration)) - /** Alias for calling [price] with `Price.ofGroupedTieredPackage(groupedTieredPackage)`. */ fun price(groupedTieredPackage: Price.GroupedTieredPackage) = price(Price.ofGroupedTieredPackage(groupedTieredPackage)) @@ -283,13 +290,6 @@ private constructor( fun price(cumulativeGroupedBulk: Price.CumulativeGroupedBulk) = price(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) - /** - * Alias for calling [price] with - * `Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)`. - */ - fun price(groupedWithMinMaxThresholds: Price.GroupedWithMinMaxThresholds) = - price(Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)) - /** Alias for calling [price] with `Price.ofMinimum(minimum)`. */ fun price(minimum: Price.Minimum) = price(Price.ofMinimum(minimum)) diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Plan.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Plan.kt index e7c11dde6..dcf467b1d 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Plan.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Plan.kt @@ -1045,18 +1045,18 @@ private constructor( /** Alias for calling [addPrice] with `Price.ofUnit(unit)`. */ fun addPrice(unit: Price.Unit) = addPrice(Price.ofUnit(unit)) - /** Alias for calling [addPrice] with `Price.ofPackage(package_)`. */ - fun addPrice(package_: Price.Package) = addPrice(Price.ofPackage(package_)) - - /** Alias for calling [addPrice] with `Price.ofMatrix(matrix)`. */ - fun addPrice(matrix: Price.Matrix) = addPrice(Price.ofMatrix(matrix)) - /** Alias for calling [addPrice] with `Price.ofTiered(tiered)`. */ fun addPrice(tiered: Price.Tiered) = addPrice(Price.ofTiered(tiered)) /** Alias for calling [addPrice] with `Price.ofBulk(bulk)`. */ fun addPrice(bulk: Price.Bulk) = addPrice(Price.ofBulk(bulk)) + /** Alias for calling [addPrice] with `Price.ofPackage(package_)`. */ + fun addPrice(package_: Price.Package) = addPrice(Price.ofPackage(package_)) + + /** Alias for calling [addPrice] with `Price.ofMatrix(matrix)`. */ + fun addPrice(matrix: Price.Matrix) = addPrice(Price.ofMatrix(matrix)) + /** * Alias for calling [addPrice] with `Price.ofThresholdTotalAmount(thresholdTotalAmount)`. */ @@ -1067,14 +1067,14 @@ private constructor( fun addPrice(tieredPackage: Price.TieredPackage) = addPrice(Price.ofTieredPackage(tieredPackage)) - /** Alias for calling [addPrice] with `Price.ofGroupedTiered(groupedTiered)`. */ - fun addPrice(groupedTiered: Price.GroupedTiered) = - addPrice(Price.ofGroupedTiered(groupedTiered)) - /** Alias for calling [addPrice] with `Price.ofTieredWithMinimum(tieredWithMinimum)`. */ fun addPrice(tieredWithMinimum: Price.TieredWithMinimum) = addPrice(Price.ofTieredWithMinimum(tieredWithMinimum)) + /** Alias for calling [addPrice] with `Price.ofGroupedTiered(groupedTiered)`. */ + fun addPrice(groupedTiered: Price.GroupedTiered) = + addPrice(Price.ofGroupedTiered(groupedTiered)) + /** * Alias for calling [addPrice] with * `Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)`. @@ -1110,6 +1110,10 @@ private constructor( fun addPrice(groupedAllocation: Price.GroupedAllocation) = addPrice(Price.ofGroupedAllocation(groupedAllocation)) + /** Alias for calling [addPrice] with `Price.ofBulkWithProration(bulkWithProration)`. */ + fun addPrice(bulkWithProration: Price.BulkWithProration) = + addPrice(Price.ofBulkWithProration(bulkWithProration)) + /** * Alias for calling [addPrice] with * `Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)`. @@ -1124,16 +1128,19 @@ private constructor( fun addPrice(groupedWithMeteredMinimum: Price.GroupedWithMeteredMinimum) = addPrice(Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)) + /** + * Alias for calling [addPrice] with + * `Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)`. + */ + fun addPrice(groupedWithMinMaxThresholds: Price.GroupedWithMinMaxThresholds) = + addPrice(Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)) + /** * Alias for calling [addPrice] with `Price.ofMatrixWithDisplayName(matrixWithDisplayName)`. */ fun addPrice(matrixWithDisplayName: Price.MatrixWithDisplayName) = addPrice(Price.ofMatrixWithDisplayName(matrixWithDisplayName)) - /** Alias for calling [addPrice] with `Price.ofBulkWithProration(bulkWithProration)`. */ - fun addPrice(bulkWithProration: Price.BulkWithProration) = - addPrice(Price.ofBulkWithProration(bulkWithProration)) - /** * Alias for calling [addPrice] with `Price.ofGroupedTieredPackage(groupedTieredPackage)`. */ @@ -1166,13 +1173,6 @@ private constructor( fun addPrice(cumulativeGroupedBulk: Price.CumulativeGroupedBulk) = addPrice(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) - /** - * Alias for calling [addPrice] with - * `Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)`. - */ - fun addPrice(groupedWithMinMaxThresholds: Price.GroupedWithMinMaxThresholds) = - addPrice(Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)) - /** Alias for calling [addPrice] with `Price.ofMinimum(minimum)`. */ fun addPrice(minimum: Price.Minimum) = addPrice(Price.ofMinimum(minimum)) diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanCreateParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanCreateParams.kt index 5005bef18..69f259f8e 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanCreateParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanCreateParams.kt @@ -1197,7 +1197,7 @@ private constructor( fun planPhaseOrder(): Long? = planPhaseOrder.getNullable("plan_phase_order") /** - * The price to add to the plan + * New plan price request body params. * * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -1301,7 +1301,7 @@ private constructor( this.planPhaseOrder = planPhaseOrder } - /** The price to add to the plan */ + /** New plan price request body params. */ fun price(price: InnerPrice?) = price(JsonField.ofNullable(price)) /** @@ -1316,18 +1316,18 @@ private constructor( /** Alias for calling [price] with `InnerPrice.ofUnit(unit)`. */ fun price(unit: NewPlanUnitPrice) = price(InnerPrice.ofUnit(unit)) - /** Alias for calling [price] with `InnerPrice.ofPackage(package_)`. */ - fun price(package_: NewPlanPackagePrice) = price(InnerPrice.ofPackage(package_)) - - /** Alias for calling [price] with `InnerPrice.ofMatrix(matrix)`. */ - fun price(matrix: NewPlanMatrixPrice) = price(InnerPrice.ofMatrix(matrix)) - /** Alias for calling [price] with `InnerPrice.ofTiered(tiered)`. */ fun price(tiered: NewPlanTieredPrice) = price(InnerPrice.ofTiered(tiered)) /** Alias for calling [price] with `InnerPrice.ofBulk(bulk)`. */ fun price(bulk: NewPlanBulkPrice) = price(InnerPrice.ofBulk(bulk)) + /** Alias for calling [price] with `InnerPrice.ofPackage(package_)`. */ + fun price(package_: NewPlanPackagePrice) = price(InnerPrice.ofPackage(package_)) + + /** Alias for calling [price] with `InnerPrice.ofMatrix(matrix)`. */ + fun price(matrix: NewPlanMatrixPrice) = price(InnerPrice.ofMatrix(matrix)) + /** * Alias for calling [price] with * `InnerPrice.ofThresholdTotalAmount(thresholdTotalAmount)`. @@ -1345,9 +1345,16 @@ private constructor( fun price(tieredWithMinimum: NewPlanTieredWithMinimumPrice) = price(InnerPrice.ofTieredWithMinimum(tieredWithMinimum)) - /** Alias for calling [price] with `InnerPrice.ofUnitWithPercent(unitWithPercent)`. */ - fun price(unitWithPercent: NewPlanUnitWithPercentPrice) = - price(InnerPrice.ofUnitWithPercent(unitWithPercent)) + /** Alias for calling [price] with `InnerPrice.ofGroupedTiered(groupedTiered)`. */ + fun price(groupedTiered: NewPlanGroupedTieredPrice) = + price(InnerPrice.ofGroupedTiered(groupedTiered)) + + /** + * Alias for calling [price] with + * `InnerPrice.ofTieredPackageWithMinimum(tieredPackageWithMinimum)`. + */ + fun price(tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice) = + price(InnerPrice.ofTieredPackageWithMinimum(tieredPackageWithMinimum)) /** * Alias for calling [price] with @@ -1356,11 +1363,22 @@ private constructor( fun price(packageWithAllocation: NewPlanPackageWithAllocationPrice) = price(InnerPrice.ofPackageWithAllocation(packageWithAllocation)) + /** Alias for calling [price] with `InnerPrice.ofUnitWithPercent(unitWithPercent)`. */ + fun price(unitWithPercent: NewPlanUnitWithPercentPrice) = + price(InnerPrice.ofUnitWithPercent(unitWithPercent)) + + /** + * Alias for calling [price] with + * `InnerPrice.ofMatrixWithAllocation(matrixWithAllocation)`. + */ + fun price(matrixWithAllocation: NewPlanMatrixWithAllocationPrice) = + price(InnerPrice.ofMatrixWithAllocation(matrixWithAllocation)) + /** * Alias for calling [price] with * `InnerPrice.ofTieredWithProration(tieredWithProration)`. */ - fun price(tieredWithProration: NewPlanTierWithProrationPrice) = + fun price(tieredWithProration: InnerPrice.TieredWithProration) = price(InnerPrice.ofTieredWithProration(tieredWithProration)) /** @@ -1375,6 +1393,12 @@ private constructor( fun price(groupedAllocation: NewPlanGroupedAllocationPrice) = price(InnerPrice.ofGroupedAllocation(groupedAllocation)) + /** + * Alias for calling [price] with `InnerPrice.ofBulkWithProration(bulkWithProration)`. + */ + fun price(bulkWithProration: NewPlanBulkWithProrationPrice) = + price(InnerPrice.ofBulkWithProration(bulkWithProration)) + /** * Alias for calling [price] with * `InnerPrice.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)`. @@ -1403,12 +1427,6 @@ private constructor( fun price(matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice) = price(InnerPrice.ofMatrixWithDisplayName(matrixWithDisplayName)) - /** - * Alias for calling [price] with `InnerPrice.ofBulkWithProration(bulkWithProration)`. - */ - fun price(bulkWithProration: NewPlanBulkWithProrationPrice) = - price(InnerPrice.ofBulkWithProration(bulkWithProration)) - /** * Alias for calling [price] with * `InnerPrice.ofGroupedTieredPackage(groupedTieredPackage)`. @@ -1445,24 +1463,6 @@ private constructor( fun price(cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice) = price(InnerPrice.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) - /** - * Alias for calling [price] with - * `InnerPrice.ofTieredPackageWithMinimum(tieredPackageWithMinimum)`. - */ - fun price(tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice) = - price(InnerPrice.ofTieredPackageWithMinimum(tieredPackageWithMinimum)) - - /** - * Alias for calling [price] with - * `InnerPrice.ofMatrixWithAllocation(matrixWithAllocation)`. - */ - fun price(matrixWithAllocation: NewPlanMatrixWithAllocationPrice) = - price(InnerPrice.ofMatrixWithAllocation(matrixWithAllocation)) - - /** Alias for calling [price] with `InnerPrice.ofGroupedTiered(groupedTiered)`. */ - fun price(groupedTiered: NewPlanGroupedTieredPrice) = - price(InnerPrice.ofGroupedTiered(groupedTiered)) - /** Alias for calling [price] with `InnerPrice.ofMinimum(minimum)`. */ fun price(minimum: NewPlanMinimumCompositePrice) = price(InnerPrice.ofMinimum(minimum)) @@ -1526,29 +1526,32 @@ private constructor( (if (planPhaseOrder.asKnown() == null) 0 else 1) + (price.asKnown()?.validity() ?: 0) - /** The price to add to the plan */ + /** New plan price request body params. */ @JsonDeserialize(using = InnerPrice.Deserializer::class) @JsonSerialize(using = InnerPrice.Serializer::class) class InnerPrice private constructor( private val unit: NewPlanUnitPrice? = null, - private val package_: NewPlanPackagePrice? = null, - private val matrix: NewPlanMatrixPrice? = null, private val tiered: NewPlanTieredPrice? = null, private val bulk: NewPlanBulkPrice? = null, + private val package_: NewPlanPackagePrice? = null, + private val matrix: NewPlanMatrixPrice? = null, private val thresholdTotalAmount: NewPlanThresholdTotalAmountPrice? = null, private val tieredPackage: NewPlanTieredPackagePrice? = null, private val tieredWithMinimum: NewPlanTieredWithMinimumPrice? = null, - private val unitWithPercent: NewPlanUnitWithPercentPrice? = null, + private val groupedTiered: NewPlanGroupedTieredPrice? = null, + private val tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice? = null, private val packageWithAllocation: NewPlanPackageWithAllocationPrice? = null, - private val tieredWithProration: NewPlanTierWithProrationPrice? = null, + private val unitWithPercent: NewPlanUnitWithPercentPrice? = null, + private val matrixWithAllocation: NewPlanMatrixWithAllocationPrice? = null, + private val tieredWithProration: TieredWithProration? = null, private val unitWithProration: NewPlanUnitWithProrationPrice? = null, private val groupedAllocation: NewPlanGroupedAllocationPrice? = null, + private val bulkWithProration: NewPlanBulkWithProrationPrice? = null, private val groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice? = null, private val groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice? = null, private val groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds? = null, private val matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice? = null, - private val bulkWithProration: NewPlanBulkWithProrationPrice? = null, private val groupedTieredPackage: NewPlanGroupedTieredPackagePrice? = null, private val maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice? = null, private val scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice? = @@ -1557,39 +1560,45 @@ private constructor( NewPlanScalableMatrixWithTieredPricingPrice? = null, private val cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice? = null, - private val tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice? = null, - private val matrixWithAllocation: NewPlanMatrixWithAllocationPrice? = null, - private val groupedTiered: NewPlanGroupedTieredPrice? = null, private val minimum: NewPlanMinimumCompositePrice? = null, private val _json: JsonValue? = null, ) { fun unit(): NewPlanUnitPrice? = unit - fun package_(): NewPlanPackagePrice? = package_ - - fun matrix(): NewPlanMatrixPrice? = matrix - fun tiered(): NewPlanTieredPrice? = tiered fun bulk(): NewPlanBulkPrice? = bulk + fun package_(): NewPlanPackagePrice? = package_ + + fun matrix(): NewPlanMatrixPrice? = matrix + fun thresholdTotalAmount(): NewPlanThresholdTotalAmountPrice? = thresholdTotalAmount fun tieredPackage(): NewPlanTieredPackagePrice? = tieredPackage fun tieredWithMinimum(): NewPlanTieredWithMinimumPrice? = tieredWithMinimum - fun unitWithPercent(): NewPlanUnitWithPercentPrice? = unitWithPercent + fun groupedTiered(): NewPlanGroupedTieredPrice? = groupedTiered + + fun tieredPackageWithMinimum(): NewPlanTieredPackageWithMinimumPrice? = + tieredPackageWithMinimum fun packageWithAllocation(): NewPlanPackageWithAllocationPrice? = packageWithAllocation - fun tieredWithProration(): NewPlanTierWithProrationPrice? = tieredWithProration + fun unitWithPercent(): NewPlanUnitWithPercentPrice? = unitWithPercent + + fun matrixWithAllocation(): NewPlanMatrixWithAllocationPrice? = matrixWithAllocation + + fun tieredWithProration(): TieredWithProration? = tieredWithProration fun unitWithProration(): NewPlanUnitWithProrationPrice? = unitWithProration fun groupedAllocation(): NewPlanGroupedAllocationPrice? = groupedAllocation + fun bulkWithProration(): NewPlanBulkWithProrationPrice? = bulkWithProration + fun groupedWithProratedMinimum(): NewPlanGroupedWithProratedMinimumPrice? = groupedWithProratedMinimum @@ -1601,8 +1610,6 @@ private constructor( fun matrixWithDisplayName(): NewPlanMatrixWithDisplayNamePrice? = matrixWithDisplayName - fun bulkWithProration(): NewPlanBulkWithProrationPrice? = bulkWithProration - fun groupedTieredPackage(): NewPlanGroupedTieredPackagePrice? = groupedTieredPackage fun maxGroupTieredPackage(): NewPlanMaxGroupTieredPackagePrice? = maxGroupTieredPackage @@ -1615,41 +1622,42 @@ private constructor( fun cumulativeGroupedBulk(): NewPlanCumulativeGroupedBulkPrice? = cumulativeGroupedBulk - fun tieredPackageWithMinimum(): NewPlanTieredPackageWithMinimumPrice? = - tieredPackageWithMinimum - - fun matrixWithAllocation(): NewPlanMatrixWithAllocationPrice? = matrixWithAllocation - - fun groupedTiered(): NewPlanGroupedTieredPrice? = groupedTiered - fun minimum(): NewPlanMinimumCompositePrice? = minimum fun isUnit(): Boolean = unit != null - fun isPackage(): Boolean = package_ != null - - fun isMatrix(): Boolean = matrix != null - fun isTiered(): Boolean = tiered != null fun isBulk(): Boolean = bulk != null + fun isPackage(): Boolean = package_ != null + + fun isMatrix(): Boolean = matrix != null + fun isThresholdTotalAmount(): Boolean = thresholdTotalAmount != null fun isTieredPackage(): Boolean = tieredPackage != null fun isTieredWithMinimum(): Boolean = tieredWithMinimum != null - fun isUnitWithPercent(): Boolean = unitWithPercent != null + fun isGroupedTiered(): Boolean = groupedTiered != null + + fun isTieredPackageWithMinimum(): Boolean = tieredPackageWithMinimum != null fun isPackageWithAllocation(): Boolean = packageWithAllocation != null + fun isUnitWithPercent(): Boolean = unitWithPercent != null + + fun isMatrixWithAllocation(): Boolean = matrixWithAllocation != null + fun isTieredWithProration(): Boolean = tieredWithProration != null fun isUnitWithProration(): Boolean = unitWithProration != null fun isGroupedAllocation(): Boolean = groupedAllocation != null + fun isBulkWithProration(): Boolean = bulkWithProration != null + fun isGroupedWithProratedMinimum(): Boolean = groupedWithProratedMinimum != null fun isGroupedWithMeteredMinimum(): Boolean = groupedWithMeteredMinimum != null @@ -1658,8 +1666,6 @@ private constructor( fun isMatrixWithDisplayName(): Boolean = matrixWithDisplayName != null - fun isBulkWithProration(): Boolean = bulkWithProration != null - fun isGroupedTieredPackage(): Boolean = groupedTieredPackage != null fun isMaxGroupTieredPackage(): Boolean = maxGroupTieredPackage != null @@ -1671,24 +1677,18 @@ private constructor( fun isCumulativeGroupedBulk(): Boolean = cumulativeGroupedBulk != null - fun isTieredPackageWithMinimum(): Boolean = tieredPackageWithMinimum != null - - fun isMatrixWithAllocation(): Boolean = matrixWithAllocation != null - - fun isGroupedTiered(): Boolean = groupedTiered != null - fun isMinimum(): Boolean = minimum != null fun asUnit(): NewPlanUnitPrice = unit.getOrThrow("unit") - fun asPackage(): NewPlanPackagePrice = package_.getOrThrow("package_") - - fun asMatrix(): NewPlanMatrixPrice = matrix.getOrThrow("matrix") - fun asTiered(): NewPlanTieredPrice = tiered.getOrThrow("tiered") fun asBulk(): NewPlanBulkPrice = bulk.getOrThrow("bulk") + fun asPackage(): NewPlanPackagePrice = package_.getOrThrow("package_") + + fun asMatrix(): NewPlanMatrixPrice = matrix.getOrThrow("matrix") + fun asThresholdTotalAmount(): NewPlanThresholdTotalAmountPrice = thresholdTotalAmount.getOrThrow("thresholdTotalAmount") @@ -1698,13 +1698,22 @@ private constructor( fun asTieredWithMinimum(): NewPlanTieredWithMinimumPrice = tieredWithMinimum.getOrThrow("tieredWithMinimum") - fun asUnitWithPercent(): NewPlanUnitWithPercentPrice = - unitWithPercent.getOrThrow("unitWithPercent") + fun asGroupedTiered(): NewPlanGroupedTieredPrice = + groupedTiered.getOrThrow("groupedTiered") + + fun asTieredPackageWithMinimum(): NewPlanTieredPackageWithMinimumPrice = + tieredPackageWithMinimum.getOrThrow("tieredPackageWithMinimum") fun asPackageWithAllocation(): NewPlanPackageWithAllocationPrice = packageWithAllocation.getOrThrow("packageWithAllocation") - fun asTieredWithProration(): NewPlanTierWithProrationPrice = + fun asUnitWithPercent(): NewPlanUnitWithPercentPrice = + unitWithPercent.getOrThrow("unitWithPercent") + + fun asMatrixWithAllocation(): NewPlanMatrixWithAllocationPrice = + matrixWithAllocation.getOrThrow("matrixWithAllocation") + + fun asTieredWithProration(): TieredWithProration = tieredWithProration.getOrThrow("tieredWithProration") fun asUnitWithProration(): NewPlanUnitWithProrationPrice = @@ -1713,6 +1722,9 @@ private constructor( fun asGroupedAllocation(): NewPlanGroupedAllocationPrice = groupedAllocation.getOrThrow("groupedAllocation") + fun asBulkWithProration(): NewPlanBulkWithProrationPrice = + bulkWithProration.getOrThrow("bulkWithProration") + fun asGroupedWithProratedMinimum(): NewPlanGroupedWithProratedMinimumPrice = groupedWithProratedMinimum.getOrThrow("groupedWithProratedMinimum") @@ -1725,9 +1737,6 @@ private constructor( fun asMatrixWithDisplayName(): NewPlanMatrixWithDisplayNamePrice = matrixWithDisplayName.getOrThrow("matrixWithDisplayName") - fun asBulkWithProration(): NewPlanBulkWithProrationPrice = - bulkWithProration.getOrThrow("bulkWithProration") - fun asGroupedTieredPackage(): NewPlanGroupedTieredPackagePrice = groupedTieredPackage.getOrThrow("groupedTieredPackage") @@ -1743,15 +1752,6 @@ private constructor( fun asCumulativeGroupedBulk(): NewPlanCumulativeGroupedBulkPrice = cumulativeGroupedBulk.getOrThrow("cumulativeGroupedBulk") - fun asTieredPackageWithMinimum(): NewPlanTieredPackageWithMinimumPrice = - tieredPackageWithMinimum.getOrThrow("tieredPackageWithMinimum") - - fun asMatrixWithAllocation(): NewPlanMatrixWithAllocationPrice = - matrixWithAllocation.getOrThrow("matrixWithAllocation") - - fun asGroupedTiered(): NewPlanGroupedTieredPrice = - groupedTiered.getOrThrow("groupedTiered") - fun asMinimum(): NewPlanMinimumCompositePrice = minimum.getOrThrow("minimum") fun _json(): JsonValue? = _json @@ -1759,21 +1759,27 @@ private constructor( fun accept(visitor: Visitor): T = when { unit != null -> visitor.visitUnit(unit) - package_ != null -> visitor.visitPackage(package_) - matrix != null -> visitor.visitMatrix(matrix) tiered != null -> visitor.visitTiered(tiered) bulk != null -> visitor.visitBulk(bulk) + package_ != null -> visitor.visitPackage(package_) + matrix != null -> visitor.visitMatrix(matrix) thresholdTotalAmount != null -> visitor.visitThresholdTotalAmount(thresholdTotalAmount) tieredPackage != null -> visitor.visitTieredPackage(tieredPackage) tieredWithMinimum != null -> visitor.visitTieredWithMinimum(tieredWithMinimum) - unitWithPercent != null -> visitor.visitUnitWithPercent(unitWithPercent) + groupedTiered != null -> visitor.visitGroupedTiered(groupedTiered) + tieredPackageWithMinimum != null -> + visitor.visitTieredPackageWithMinimum(tieredPackageWithMinimum) packageWithAllocation != null -> visitor.visitPackageWithAllocation(packageWithAllocation) + unitWithPercent != null -> visitor.visitUnitWithPercent(unitWithPercent) + matrixWithAllocation != null -> + visitor.visitMatrixWithAllocation(matrixWithAllocation) tieredWithProration != null -> visitor.visitTieredWithProration(tieredWithProration) unitWithProration != null -> visitor.visitUnitWithProration(unitWithProration) groupedAllocation != null -> visitor.visitGroupedAllocation(groupedAllocation) + bulkWithProration != null -> visitor.visitBulkWithProration(bulkWithProration) groupedWithProratedMinimum != null -> visitor.visitGroupedWithProratedMinimum(groupedWithProratedMinimum) groupedWithMeteredMinimum != null -> @@ -1782,7 +1788,6 @@ private constructor( visitor.visitGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds) matrixWithDisplayName != null -> visitor.visitMatrixWithDisplayName(matrixWithDisplayName) - bulkWithProration != null -> visitor.visitBulkWithProration(bulkWithProration) groupedTieredPackage != null -> visitor.visitGroupedTieredPackage(groupedTieredPackage) maxGroupTieredPackage != null -> @@ -1795,11 +1800,6 @@ private constructor( ) cumulativeGroupedBulk != null -> visitor.visitCumulativeGroupedBulk(cumulativeGroupedBulk) - tieredPackageWithMinimum != null -> - visitor.visitTieredPackageWithMinimum(tieredPackageWithMinimum) - matrixWithAllocation != null -> - visitor.visitMatrixWithAllocation(matrixWithAllocation) - groupedTiered != null -> visitor.visitGroupedTiered(groupedTiered) minimum != null -> visitor.visitMinimum(minimum) else -> visitor.unknown(_json) } @@ -1817,14 +1817,6 @@ private constructor( unit.validate() } - override fun visitPackage(package_: NewPlanPackagePrice) { - package_.validate() - } - - override fun visitMatrix(matrix: NewPlanMatrixPrice) { - matrix.validate() - } - override fun visitTiered(tiered: NewPlanTieredPrice) { tiered.validate() } @@ -1833,6 +1825,14 @@ private constructor( bulk.validate() } + override fun visitPackage(package_: NewPlanPackagePrice) { + package_.validate() + } + + override fun visitMatrix(matrix: NewPlanMatrixPrice) { + matrix.validate() + } + override fun visitThresholdTotalAmount( thresholdTotalAmount: NewPlanThresholdTotalAmountPrice ) { @@ -1849,10 +1849,14 @@ private constructor( tieredWithMinimum.validate() } - override fun visitUnitWithPercent( - unitWithPercent: NewPlanUnitWithPercentPrice + override fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) { + groupedTiered.validate() + } + + override fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice ) { - unitWithPercent.validate() + tieredPackageWithMinimum.validate() } override fun visitPackageWithAllocation( @@ -1861,8 +1865,20 @@ private constructor( packageWithAllocation.validate() } + override fun visitUnitWithPercent( + unitWithPercent: NewPlanUnitWithPercentPrice + ) { + unitWithPercent.validate() + } + + override fun visitMatrixWithAllocation( + matrixWithAllocation: NewPlanMatrixWithAllocationPrice + ) { + matrixWithAllocation.validate() + } + override fun visitTieredWithProration( - tieredWithProration: NewPlanTierWithProrationPrice + tieredWithProration: TieredWithProration ) { tieredWithProration.validate() } @@ -1879,6 +1895,12 @@ private constructor( groupedAllocation.validate() } + override fun visitBulkWithProration( + bulkWithProration: NewPlanBulkWithProrationPrice + ) { + bulkWithProration.validate() + } + override fun visitGroupedWithProratedMinimum( groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice ) { @@ -1903,12 +1925,6 @@ private constructor( matrixWithDisplayName.validate() } - override fun visitBulkWithProration( - bulkWithProration: NewPlanBulkWithProrationPrice - ) { - bulkWithProration.validate() - } - override fun visitGroupedTieredPackage( groupedTieredPackage: NewPlanGroupedTieredPackagePrice ) { @@ -1940,22 +1956,6 @@ private constructor( cumulativeGroupedBulk.validate() } - override fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice - ) { - tieredPackageWithMinimum.validate() - } - - override fun visitMatrixWithAllocation( - matrixWithAllocation: NewPlanMatrixWithAllocationPrice - ) { - matrixWithAllocation.validate() - } - - override fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) { - groupedTiered.validate() - } - override fun visitMinimum(minimum: NewPlanMinimumCompositePrice) { minimum.validate() } @@ -1983,15 +1983,15 @@ private constructor( object : Visitor { override fun visitUnit(unit: NewPlanUnitPrice) = unit.validity() - override fun visitPackage(package_: NewPlanPackagePrice) = - package_.validity() - - override fun visitMatrix(matrix: NewPlanMatrixPrice) = matrix.validity() - override fun visitTiered(tiered: NewPlanTieredPrice) = tiered.validity() override fun visitBulk(bulk: NewPlanBulkPrice) = bulk.validity() + override fun visitPackage(package_: NewPlanPackagePrice) = + package_.validity() + + override fun visitMatrix(matrix: NewPlanMatrixPrice) = matrix.validity() + override fun visitThresholdTotalAmount( thresholdTotalAmount: NewPlanThresholdTotalAmountPrice ) = thresholdTotalAmount.validity() @@ -2003,16 +2003,27 @@ private constructor( tieredWithMinimum: NewPlanTieredWithMinimumPrice ) = tieredWithMinimum.validity() - override fun visitUnitWithPercent( - unitWithPercent: NewPlanUnitWithPercentPrice - ) = unitWithPercent.validity() + override fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) = + groupedTiered.validity() + + override fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice + ) = tieredPackageWithMinimum.validity() override fun visitPackageWithAllocation( packageWithAllocation: NewPlanPackageWithAllocationPrice ) = packageWithAllocation.validity() + override fun visitUnitWithPercent( + unitWithPercent: NewPlanUnitWithPercentPrice + ) = unitWithPercent.validity() + + override fun visitMatrixWithAllocation( + matrixWithAllocation: NewPlanMatrixWithAllocationPrice + ) = matrixWithAllocation.validity() + override fun visitTieredWithProration( - tieredWithProration: NewPlanTierWithProrationPrice + tieredWithProration: TieredWithProration ) = tieredWithProration.validity() override fun visitUnitWithProration( @@ -2023,6 +2034,10 @@ private constructor( groupedAllocation: NewPlanGroupedAllocationPrice ) = groupedAllocation.validity() + override fun visitBulkWithProration( + bulkWithProration: NewPlanBulkWithProrationPrice + ) = bulkWithProration.validity() + override fun visitGroupedWithProratedMinimum( groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice ) = groupedWithProratedMinimum.validity() @@ -2039,10 +2054,6 @@ private constructor( matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice ) = matrixWithDisplayName.validity() - override fun visitBulkWithProration( - bulkWithProration: NewPlanBulkWithProrationPrice - ) = bulkWithProration.validity() - override fun visitGroupedTieredPackage( groupedTieredPackage: NewPlanGroupedTieredPackagePrice ) = groupedTieredPackage.validity() @@ -2064,17 +2075,6 @@ private constructor( cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice ) = cumulativeGroupedBulk.validity() - override fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice - ) = tieredPackageWithMinimum.validity() - - override fun visitMatrixWithAllocation( - matrixWithAllocation: NewPlanMatrixWithAllocationPrice - ) = matrixWithAllocation.validity() - - override fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) = - groupedTiered.validity() - override fun visitMinimum(minimum: NewPlanMinimumCompositePrice) = minimum.validity() @@ -2089,83 +2089,89 @@ private constructor( return other is InnerPrice && unit == other.unit && - package_ == other.package_ && - matrix == other.matrix && tiered == other.tiered && bulk == other.bulk && + package_ == other.package_ && + matrix == other.matrix && thresholdTotalAmount == other.thresholdTotalAmount && tieredPackage == other.tieredPackage && tieredWithMinimum == other.tieredWithMinimum && - unitWithPercent == other.unitWithPercent && + groupedTiered == other.groupedTiered && + tieredPackageWithMinimum == other.tieredPackageWithMinimum && packageWithAllocation == other.packageWithAllocation && + unitWithPercent == other.unitWithPercent && + matrixWithAllocation == other.matrixWithAllocation && tieredWithProration == other.tieredWithProration && unitWithProration == other.unitWithProration && groupedAllocation == other.groupedAllocation && + bulkWithProration == other.bulkWithProration && groupedWithProratedMinimum == other.groupedWithProratedMinimum && groupedWithMeteredMinimum == other.groupedWithMeteredMinimum && groupedWithMinMaxThresholds == other.groupedWithMinMaxThresholds && matrixWithDisplayName == other.matrixWithDisplayName && - bulkWithProration == other.bulkWithProration && groupedTieredPackage == other.groupedTieredPackage && maxGroupTieredPackage == other.maxGroupTieredPackage && scalableMatrixWithUnitPricing == other.scalableMatrixWithUnitPricing && scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && cumulativeGroupedBulk == other.cumulativeGroupedBulk && - tieredPackageWithMinimum == other.tieredPackageWithMinimum && - matrixWithAllocation == other.matrixWithAllocation && - groupedTiered == other.groupedTiered && minimum == other.minimum } override fun hashCode(): Int = Objects.hash( unit, - package_, - matrix, tiered, bulk, + package_, + matrix, thresholdTotalAmount, tieredPackage, tieredWithMinimum, - unitWithPercent, + groupedTiered, + tieredPackageWithMinimum, packageWithAllocation, + unitWithPercent, + matrixWithAllocation, tieredWithProration, unitWithProration, groupedAllocation, + bulkWithProration, groupedWithProratedMinimum, groupedWithMeteredMinimum, groupedWithMinMaxThresholds, matrixWithDisplayName, - bulkWithProration, groupedTieredPackage, maxGroupTieredPackage, scalableMatrixWithUnitPricing, scalableMatrixWithTieredPricing, cumulativeGroupedBulk, - tieredPackageWithMinimum, - matrixWithAllocation, - groupedTiered, minimum, ) override fun toString(): String = when { unit != null -> "InnerPrice{unit=$unit}" - package_ != null -> "InnerPrice{package_=$package_}" - matrix != null -> "InnerPrice{matrix=$matrix}" tiered != null -> "InnerPrice{tiered=$tiered}" bulk != null -> "InnerPrice{bulk=$bulk}" + package_ != null -> "InnerPrice{package_=$package_}" + matrix != null -> "InnerPrice{matrix=$matrix}" thresholdTotalAmount != null -> "InnerPrice{thresholdTotalAmount=$thresholdTotalAmount}" tieredPackage != null -> "InnerPrice{tieredPackage=$tieredPackage}" tieredWithMinimum != null -> "InnerPrice{tieredWithMinimum=$tieredWithMinimum}" - unitWithPercent != null -> "InnerPrice{unitWithPercent=$unitWithPercent}" + groupedTiered != null -> "InnerPrice{groupedTiered=$groupedTiered}" + tieredPackageWithMinimum != null -> + "InnerPrice{tieredPackageWithMinimum=$tieredPackageWithMinimum}" packageWithAllocation != null -> "InnerPrice{packageWithAllocation=$packageWithAllocation}" + unitWithPercent != null -> "InnerPrice{unitWithPercent=$unitWithPercent}" + matrixWithAllocation != null -> + "InnerPrice{matrixWithAllocation=$matrixWithAllocation}" tieredWithProration != null -> "InnerPrice{tieredWithProration=$tieredWithProration}" unitWithProration != null -> "InnerPrice{unitWithProration=$unitWithProration}" groupedAllocation != null -> "InnerPrice{groupedAllocation=$groupedAllocation}" + bulkWithProration != null -> "InnerPrice{bulkWithProration=$bulkWithProration}" groupedWithProratedMinimum != null -> "InnerPrice{groupedWithProratedMinimum=$groupedWithProratedMinimum}" groupedWithMeteredMinimum != null -> @@ -2174,7 +2180,6 @@ private constructor( "InnerPrice{groupedWithMinMaxThresholds=$groupedWithMinMaxThresholds}" matrixWithDisplayName != null -> "InnerPrice{matrixWithDisplayName=$matrixWithDisplayName}" - bulkWithProration != null -> "InnerPrice{bulkWithProration=$bulkWithProration}" groupedTieredPackage != null -> "InnerPrice{groupedTieredPackage=$groupedTieredPackage}" maxGroupTieredPackage != null -> @@ -2185,11 +2190,6 @@ private constructor( "InnerPrice{scalableMatrixWithTieredPricing=$scalableMatrixWithTieredPricing}" cumulativeGroupedBulk != null -> "InnerPrice{cumulativeGroupedBulk=$cumulativeGroupedBulk}" - tieredPackageWithMinimum != null -> - "InnerPrice{tieredPackageWithMinimum=$tieredPackageWithMinimum}" - matrixWithAllocation != null -> - "InnerPrice{matrixWithAllocation=$matrixWithAllocation}" - groupedTiered != null -> "InnerPrice{groupedTiered=$groupedTiered}" minimum != null -> "InnerPrice{minimum=$minimum}" _json != null -> "InnerPrice{_unknown=$_json}" else -> throw IllegalStateException("Invalid InnerPrice") @@ -2199,14 +2199,14 @@ private constructor( fun ofUnit(unit: NewPlanUnitPrice) = InnerPrice(unit = unit) - fun ofPackage(package_: NewPlanPackagePrice) = InnerPrice(package_ = package_) - - fun ofMatrix(matrix: NewPlanMatrixPrice) = InnerPrice(matrix = matrix) - fun ofTiered(tiered: NewPlanTieredPrice) = InnerPrice(tiered = tiered) fun ofBulk(bulk: NewPlanBulkPrice) = InnerPrice(bulk = bulk) + fun ofPackage(package_: NewPlanPackagePrice) = InnerPrice(package_ = package_) + + fun ofMatrix(matrix: NewPlanMatrixPrice) = InnerPrice(matrix = matrix) + fun ofThresholdTotalAmount(thresholdTotalAmount: NewPlanThresholdTotalAmountPrice) = InnerPrice(thresholdTotalAmount = thresholdTotalAmount) @@ -2216,14 +2216,24 @@ private constructor( fun ofTieredWithMinimum(tieredWithMinimum: NewPlanTieredWithMinimumPrice) = InnerPrice(tieredWithMinimum = tieredWithMinimum) - fun ofUnitWithPercent(unitWithPercent: NewPlanUnitWithPercentPrice) = - InnerPrice(unitWithPercent = unitWithPercent) + fun ofGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) = + InnerPrice(groupedTiered = groupedTiered) + + fun ofTieredPackageWithMinimum( + tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice + ) = InnerPrice(tieredPackageWithMinimum = tieredPackageWithMinimum) fun ofPackageWithAllocation( packageWithAllocation: NewPlanPackageWithAllocationPrice ) = InnerPrice(packageWithAllocation = packageWithAllocation) - fun ofTieredWithProration(tieredWithProration: NewPlanTierWithProrationPrice) = + fun ofUnitWithPercent(unitWithPercent: NewPlanUnitWithPercentPrice) = + InnerPrice(unitWithPercent = unitWithPercent) + + fun ofMatrixWithAllocation(matrixWithAllocation: NewPlanMatrixWithAllocationPrice) = + InnerPrice(matrixWithAllocation = matrixWithAllocation) + + fun ofTieredWithProration(tieredWithProration: TieredWithProration) = InnerPrice(tieredWithProration = tieredWithProration) fun ofUnitWithProration(unitWithProration: NewPlanUnitWithProrationPrice) = @@ -2232,6 +2242,9 @@ private constructor( fun ofGroupedAllocation(groupedAllocation: NewPlanGroupedAllocationPrice) = InnerPrice(groupedAllocation = groupedAllocation) + fun ofBulkWithProration(bulkWithProration: NewPlanBulkWithProrationPrice) = + InnerPrice(bulkWithProration = bulkWithProration) + fun ofGroupedWithProratedMinimum( groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice ) = InnerPrice(groupedWithProratedMinimum = groupedWithProratedMinimum) @@ -2248,9 +2261,6 @@ private constructor( matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice ) = InnerPrice(matrixWithDisplayName = matrixWithDisplayName) - fun ofBulkWithProration(bulkWithProration: NewPlanBulkWithProrationPrice) = - InnerPrice(bulkWithProration = bulkWithProration) - fun ofGroupedTieredPackage(groupedTieredPackage: NewPlanGroupedTieredPackagePrice) = InnerPrice(groupedTieredPackage = groupedTieredPackage) @@ -2270,16 +2280,6 @@ private constructor( cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice ) = InnerPrice(cumulativeGroupedBulk = cumulativeGroupedBulk) - fun ofTieredPackageWithMinimum( - tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice - ) = InnerPrice(tieredPackageWithMinimum = tieredPackageWithMinimum) - - fun ofMatrixWithAllocation(matrixWithAllocation: NewPlanMatrixWithAllocationPrice) = - InnerPrice(matrixWithAllocation = matrixWithAllocation) - - fun ofGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) = - InnerPrice(groupedTiered = groupedTiered) - fun ofMinimum(minimum: NewPlanMinimumCompositePrice) = InnerPrice(minimum = minimum) } @@ -2291,14 +2291,14 @@ private constructor( fun visitUnit(unit: NewPlanUnitPrice): T - fun visitPackage(package_: NewPlanPackagePrice): T - - fun visitMatrix(matrix: NewPlanMatrixPrice): T - fun visitTiered(tiered: NewPlanTieredPrice): T fun visitBulk(bulk: NewPlanBulkPrice): T + fun visitPackage(package_: NewPlanPackagePrice): T + + fun visitMatrix(matrix: NewPlanMatrixPrice): T + fun visitThresholdTotalAmount( thresholdTotalAmount: NewPlanThresholdTotalAmountPrice ): T @@ -2307,18 +2307,30 @@ private constructor( fun visitTieredWithMinimum(tieredWithMinimum: NewPlanTieredWithMinimumPrice): T - fun visitUnitWithPercent(unitWithPercent: NewPlanUnitWithPercentPrice): T + fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice): T + + fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice + ): T fun visitPackageWithAllocation( packageWithAllocation: NewPlanPackageWithAllocationPrice ): T - fun visitTieredWithProration(tieredWithProration: NewPlanTierWithProrationPrice): T + fun visitUnitWithPercent(unitWithPercent: NewPlanUnitWithPercentPrice): T + + fun visitMatrixWithAllocation( + matrixWithAllocation: NewPlanMatrixWithAllocationPrice + ): T + + fun visitTieredWithProration(tieredWithProration: TieredWithProration): T fun visitUnitWithProration(unitWithProration: NewPlanUnitWithProrationPrice): T fun visitGroupedAllocation(groupedAllocation: NewPlanGroupedAllocationPrice): T + fun visitBulkWithProration(bulkWithProration: NewPlanBulkWithProrationPrice): T + fun visitGroupedWithProratedMinimum( groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice ): T @@ -2335,8 +2347,6 @@ private constructor( matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice ): T - fun visitBulkWithProration(bulkWithProration: NewPlanBulkWithProrationPrice): T - fun visitGroupedTieredPackage( groupedTieredPackage: NewPlanGroupedTieredPackagePrice ): T @@ -2357,16 +2367,6 @@ private constructor( cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice ): T - fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice - ): T - - fun visitMatrixWithAllocation( - matrixWithAllocation: NewPlanMatrixWithAllocationPrice - ): T - - fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice): T - fun visitMinimum(minimum: NewPlanMinimumCompositePrice): T /** @@ -2396,16 +2396,6 @@ private constructor( InnerPrice(unit = it, _json = json) } ?: InnerPrice(_json = json) } - "package" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { InnerPrice(package_ = it, _json = json) } - ?: InnerPrice(_json = json) - } - "matrix" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - InnerPrice(matrix = it, _json = json) - } ?: InnerPrice(_json = json) - } "tiered" -> { return tryDeserialize(node, jacksonTypeRef())?.let { InnerPrice(tiered = it, _json = json) @@ -2416,6 +2406,16 @@ private constructor( InnerPrice(bulk = it, _json = json) } ?: InnerPrice(_json = json) } + "package" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { InnerPrice(package_ = it, _json = json) } + ?: InnerPrice(_json = json) + } + "matrix" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + InnerPrice(matrix = it, _json = json) + } ?: InnerPrice(_json = json) + } "threshold_total_amount" -> { return tryDeserialize( node, @@ -2437,12 +2437,17 @@ private constructor( ?.let { InnerPrice(tieredWithMinimum = it, _json = json) } ?: InnerPrice(_json = json) } - "unit_with_percent" -> { + "grouped_tiered" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { InnerPrice(groupedTiered = it, _json = json) } + ?: InnerPrice(_json = json) + } + "tiered_package_with_minimum" -> { return tryDeserialize( node, - jacksonTypeRef(), + jacksonTypeRef(), ) - ?.let { InnerPrice(unitWithPercent = it, _json = json) } + ?.let { InnerPrice(tieredPackageWithMinimum = it, _json = json) } ?: InnerPrice(_json = json) } "package_with_allocation" -> { @@ -2453,11 +2458,24 @@ private constructor( ?.let { InnerPrice(packageWithAllocation = it, _json = json) } ?: InnerPrice(_json = json) } - "tiered_with_proration" -> { + "unit_with_percent" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { InnerPrice(unitWithPercent = it, _json = json) } + ?: InnerPrice(_json = json) + } + "matrix_with_allocation" -> { return tryDeserialize( node, - jacksonTypeRef(), + jacksonTypeRef(), ) + ?.let { InnerPrice(matrixWithAllocation = it, _json = json) } + ?: InnerPrice(_json = json) + } + "tiered_with_proration" -> { + return tryDeserialize(node, jacksonTypeRef()) ?.let { InnerPrice(tieredWithProration = it, _json = json) } ?: InnerPrice(_json = json) } @@ -2477,6 +2495,14 @@ private constructor( ?.let { InnerPrice(groupedAllocation = it, _json = json) } ?: InnerPrice(_json = json) } + "bulk_with_proration" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { InnerPrice(bulkWithProration = it, _json = json) } + ?: InnerPrice(_json = json) + } "grouped_with_prorated_minimum" -> { return tryDeserialize( node, @@ -2509,14 +2535,6 @@ private constructor( ?.let { InnerPrice(matrixWithDisplayName = it, _json = json) } ?: InnerPrice(_json = json) } - "bulk_with_proration" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { InnerPrice(bulkWithProration = it, _json = json) } - ?: InnerPrice(_json = json) - } "grouped_tiered_package" -> { return tryDeserialize( node, @@ -2559,99 +2577,1844 @@ private constructor( ?.let { InnerPrice(cumulativeGroupedBulk = it, _json = json) } ?: InnerPrice(_json = json) } - "tiered_package_with_minimum" -> { + "minimum" -> { return tryDeserialize( node, - jacksonTypeRef(), + jacksonTypeRef(), ) - ?.let { InnerPrice(tieredPackageWithMinimum = it, _json = json) } + ?.let { InnerPrice(minimum = it, _json = json) } ?: InnerPrice(_json = json) } - "matrix_with_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { InnerPrice(matrixWithAllocation = it, _json = json) } - ?: InnerPrice(_json = json) + } + + return InnerPrice(_json = json) + } + } + + internal class Serializer : BaseSerializer(InnerPrice::class) { + + override fun serialize( + value: InnerPrice, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.unit != null -> generator.writeObject(value.unit) + value.tiered != null -> generator.writeObject(value.tiered) + value.bulk != null -> generator.writeObject(value.bulk) + value.package_ != null -> generator.writeObject(value.package_) + value.matrix != null -> generator.writeObject(value.matrix) + value.thresholdTotalAmount != null -> + generator.writeObject(value.thresholdTotalAmount) + value.tieredPackage != null -> generator.writeObject(value.tieredPackage) + value.tieredWithMinimum != null -> + generator.writeObject(value.tieredWithMinimum) + value.groupedTiered != null -> generator.writeObject(value.groupedTiered) + value.tieredPackageWithMinimum != null -> + generator.writeObject(value.tieredPackageWithMinimum) + value.packageWithAllocation != null -> + generator.writeObject(value.packageWithAllocation) + value.unitWithPercent != null -> + generator.writeObject(value.unitWithPercent) + value.matrixWithAllocation != null -> + generator.writeObject(value.matrixWithAllocation) + value.tieredWithProration != null -> + generator.writeObject(value.tieredWithProration) + value.unitWithProration != null -> + generator.writeObject(value.unitWithProration) + value.groupedAllocation != null -> + generator.writeObject(value.groupedAllocation) + value.bulkWithProration != null -> + generator.writeObject(value.bulkWithProration) + value.groupedWithProratedMinimum != null -> + generator.writeObject(value.groupedWithProratedMinimum) + value.groupedWithMeteredMinimum != null -> + generator.writeObject(value.groupedWithMeteredMinimum) + value.groupedWithMinMaxThresholds != null -> + generator.writeObject(value.groupedWithMinMaxThresholds) + value.matrixWithDisplayName != null -> + generator.writeObject(value.matrixWithDisplayName) + value.groupedTieredPackage != null -> + generator.writeObject(value.groupedTieredPackage) + value.maxGroupTieredPackage != null -> + generator.writeObject(value.maxGroupTieredPackage) + value.scalableMatrixWithUnitPricing != null -> + generator.writeObject(value.scalableMatrixWithUnitPricing) + value.scalableMatrixWithTieredPricing != null -> + generator.writeObject(value.scalableMatrixWithTieredPricing) + value.cumulativeGroupedBulk != null -> + generator.writeObject(value.cumulativeGroupedBulk) + value.minimum != null -> generator.writeObject(value.minimum) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid InnerPrice") + } + } + } + + class TieredWithProration + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val tieredWithProrationConfig: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("tiered_with_proration_config") + @ExcludeMissing + tieredWithProrationConfig: JsonField = + JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + modelType, + name, + tieredWithProrationConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("tiered_with_proration") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * Configuration for tiered_with_proration pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun tieredWithProrationConfig(): TieredWithProrationConfig = + tieredWithProrationConfig.getRequired("tiered_with_proration_config") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = billableMetricId.getNullable("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + invoiceGroupingKey.getNullable("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [tieredWithProrationConfig]. + * + * Unlike [tieredWithProrationConfig], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("tiered_with_proration_config") + @ExcludeMissing + fun _tieredWithProrationConfig(): JsonField = + tieredWithProrationConfig + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [TieredWithProration]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .name() + * .tieredWithProrationConfig() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [TieredWithProration]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonValue = JsonValue.from("tiered_with_proration") + private var name: JsonField? = null + private var tieredWithProrationConfig: JsonField? = + null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(tieredWithProration: TieredWithProration) = apply { + cadence = tieredWithProration.cadence + itemId = tieredWithProration.itemId + modelType = tieredWithProration.modelType + name = tieredWithProration.name + tieredWithProrationConfig = tieredWithProration.tieredWithProrationConfig + billableMetricId = tieredWithProration.billableMetricId + billedInAdvance = tieredWithProration.billedInAdvance + billingCycleConfiguration = tieredWithProration.billingCycleConfiguration + conversionRate = tieredWithProration.conversionRate + conversionRateConfig = tieredWithProration.conversionRateConfig + currency = tieredWithProration.currency + dimensionalPriceConfiguration = + tieredWithProration.dimensionalPriceConfiguration + externalPriceId = tieredWithProration.externalPriceId + fixedPriceQuantity = tieredWithProration.fixedPriceQuantity + invoiceGroupingKey = tieredWithProration.invoiceGroupingKey + invoicingCycleConfiguration = + tieredWithProration.invoicingCycleConfiguration + metadata = tieredWithProration.metadata + referenceId = tieredWithProration.referenceId + additionalProperties = + tieredWithProration.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("tiered_with_proration") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for tiered_with_proration pricing */ + fun tieredWithProrationConfig( + tieredWithProrationConfig: TieredWithProrationConfig + ) = tieredWithProrationConfig(JsonField.of(tieredWithProrationConfig)) + + /** + * Sets [Builder.tieredWithProrationConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.tieredWithProrationConfig] with a well-typed + * [TieredWithProrationConfig] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun tieredWithProrationConfig( + tieredWithProrationConfig: JsonField + ) = apply { this.tieredWithProrationConfig = tieredWithProrationConfig } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [TieredWithProration]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .name() + * .tieredWithProrationConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TieredWithProration = + TieredWithProration( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + modelType, + checkRequired("name", name), + checkRequired("tieredWithProrationConfig", tieredWithProrationConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TieredWithProration = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + _modelType().let { + if (it != JsonValue.from("tiered_with_proration")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + tieredWithProrationConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + modelType.let { + if (it == JsonValue.from("tiered_with_proration")) 1 else 0 + } + + (if (name.asKnown() == null) 0 else 1) + + (tieredWithProrationConfig.asKnown()?.validity() ?: 0) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Configuration for tiered_with_proration pricing */ + class TieredWithProrationConfig + private constructor( + private val tiers: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of() + ) : this(tiers, mutableMapOf()) + + /** + * Tiers for rating based on total usage quantities into the specified tier with + * proration + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun tiers(): List = tiers.getRequired("tiers") + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [TieredWithProrationConfig]. + * + * The following fields are required: + * ```kotlin + * .tiers() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [TieredWithProrationConfig]. */ + class Builder internal constructor() { + + private var tiers: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(tieredWithProrationConfig: TieredWithProrationConfig) = + apply { + tiers = tieredWithProrationConfig.tiers.map { it.toMutableList() } + additionalProperties = + tieredWithProrationConfig.additionalProperties.toMutableMap() + } + + /** + * Tiers for rating based on total usage quantities into the specified tier + * with proration + */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [TieredWithProrationConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TieredWithProrationConfig = + TieredWithProrationConfig( + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TieredWithProrationConfig = apply { + if (validated) { + return@apply + } + + tiers().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (tiers.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single tiered with proration tier */ + class Tier + private constructor( + private val tierLowerBound: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(tierLowerBound, unitAmount, mutableMapOf()) + + /** + * Inclusive tier starting value + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun tierLowerBound(): String = + tierLowerBound.getRequired("tier_lower_bound") + + /** + * Amount per unit + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Tier]. + * + * The following fields are required: + * ```kotlin + * .tierLowerBound() + * .unitAmount() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var tierLowerBound: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(tier: Tier) = apply { + tierLowerBound = tier.tierLowerBound + unitAmount = tier.unitAmount + additionalProperties = tier.additionalProperties.toMutableMap() + } + + /** Inclusive tier starting value */ + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + /** Amount per unit */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```kotlin + * .tierLowerBound() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("tierLowerBound", tierLowerBound), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + tierLowerBound() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (tierLowerBound.asKnown() == null) 0 else 1) + + (if (unitAmount.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + tierLowerBound == other.tierLowerBound && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(tierLowerBound, unitAmount, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TieredWithProrationConfig && + tiers == other.tiers && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(tiers, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TieredWithProrationConfig{tiers=$tiers, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) } - "grouped_tiered" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { InnerPrice(groupedTiered = it, _json = json) } - ?: InnerPrice(_json = json) + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply } - "minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { InnerPrice(minimum = it, _json = json) } - ?: InnerPrice(_json = json) + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } + + return other is Metadata && + additionalProperties == other.additionalProperties } - return InnerPrice(_json = json) - } - } + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - internal class Serializer : BaseSerializer(InnerPrice::class) { + override fun hashCode(): Int = hashCode - override fun serialize( - value: InnerPrice, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unit != null -> generator.writeObject(value.unit) - value.package_ != null -> generator.writeObject(value.package_) - value.matrix != null -> generator.writeObject(value.matrix) - value.tiered != null -> generator.writeObject(value.tiered) - value.bulk != null -> generator.writeObject(value.bulk) - value.thresholdTotalAmount != null -> - generator.writeObject(value.thresholdTotalAmount) - value.tieredPackage != null -> generator.writeObject(value.tieredPackage) - value.tieredWithMinimum != null -> - generator.writeObject(value.tieredWithMinimum) - value.unitWithPercent != null -> - generator.writeObject(value.unitWithPercent) - value.packageWithAllocation != null -> - generator.writeObject(value.packageWithAllocation) - value.tieredWithProration != null -> - generator.writeObject(value.tieredWithProration) - value.unitWithProration != null -> - generator.writeObject(value.unitWithProration) - value.groupedAllocation != null -> - generator.writeObject(value.groupedAllocation) - value.groupedWithProratedMinimum != null -> - generator.writeObject(value.groupedWithProratedMinimum) - value.groupedWithMeteredMinimum != null -> - generator.writeObject(value.groupedWithMeteredMinimum) - value.groupedWithMinMaxThresholds != null -> - generator.writeObject(value.groupedWithMinMaxThresholds) - value.matrixWithDisplayName != null -> - generator.writeObject(value.matrixWithDisplayName) - value.bulkWithProration != null -> - generator.writeObject(value.bulkWithProration) - value.groupedTieredPackage != null -> - generator.writeObject(value.groupedTieredPackage) - value.maxGroupTieredPackage != null -> - generator.writeObject(value.maxGroupTieredPackage) - value.scalableMatrixWithUnitPricing != null -> - generator.writeObject(value.scalableMatrixWithUnitPricing) - value.scalableMatrixWithTieredPricing != null -> - generator.writeObject(value.scalableMatrixWithTieredPricing) - value.cumulativeGroupedBulk != null -> - generator.writeObject(value.cumulativeGroupedBulk) - value.tieredPackageWithMinimum != null -> - generator.writeObject(value.tieredPackageWithMinimum) - value.matrixWithAllocation != null -> - generator.writeObject(value.matrixWithAllocation) - value.groupedTiered != null -> generator.writeObject(value.groupedTiered) - value.minimum != null -> generator.writeObject(value.minimum) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid InnerPrice") + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } + + return other is TieredWithProration && + cadence == other.cadence && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + tieredWithProrationConfig == other.tieredWithProrationConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + modelType, + name, + tieredWithProrationConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties, + ) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TieredWithProration{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredWithProrationConfig=$tieredWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } class GroupedWithMinMaxThresholds @@ -2772,6 +4535,8 @@ private constructor( fun cadence(): Cadence = cadence.getRequired("cadence") /** + * Configuration for grouped_with_min_max_thresholds pricing + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected * value). @@ -2791,6 +4556,8 @@ private constructor( fun itemId(): String = itemId.getRequired("item_id") /** + * The pricing model type + * * Expected to always return the following: * ```kotlin * JsonValue.from("grouped_with_min_max_thresholds") @@ -3200,6 +4967,7 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + /** Configuration for grouped_with_min_max_thresholds pricing */ fun groupedWithMinMaxThresholdsConfig( groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig ) = @@ -3855,16 +5623,117 @@ private constructor( override fun toString() = value.toString() } + /** Configuration for grouped_with_min_max_thresholds pricing */ class GroupedWithMinMaxThresholdsConfig - @JsonCreator private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map + private val groupingKey: JsonField, + private val maximumCharge: JsonField, + private val minimumCharge: JsonField, + private val perUnitRate: JsonField, + private val additionalProperties: MutableMap, ) { + @JsonCreator + private constructor( + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("maximum_charge") + @ExcludeMissing + maximumCharge: JsonField = JsonMissing.of(), + @JsonProperty("minimum_charge") + @ExcludeMissing + minimumCharge: JsonField = JsonMissing.of(), + @JsonProperty("per_unit_rate") + @ExcludeMissing + perUnitRate: JsonField = JsonMissing.of(), + ) : this(groupingKey, maximumCharge, minimumCharge, perUnitRate, mutableMapOf()) + + /** + * The event property used to group before applying thresholds + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The maximum amount to charge each group + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun maximumCharge(): String = maximumCharge.getRequired("maximum_charge") + + /** + * The minimum amount to charge each group, regardless of usage + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun minimumCharge(): String = minimumCharge.getRequired("minimum_charge") + + /** + * The base price charged per group + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun perUnitRate(): String = perUnitRate.getRequired("per_unit_rate") + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [maximumCharge]. + * + * Unlike [maximumCharge], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("maximum_charge") + @ExcludeMissing + fun _maximumCharge(): JsonField = maximumCharge + + /** + * Returns the raw JSON value of [minimumCharge]. + * + * Unlike [minimumCharge], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("minimum_charge") + @ExcludeMissing + fun _minimumCharge(): JsonField = minimumCharge + + /** + * Returns the raw JSON value of [perUnitRate]. + * + * Unlike [perUnitRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("per_unit_rate") + @ExcludeMissing + fun _perUnitRate(): JsonField = perUnitRate + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) fun toBuilder() = Builder().from(this) @@ -3873,6 +5742,14 @@ private constructor( /** * Returns a mutable builder for constructing an instance of * [GroupedWithMinMaxThresholdsConfig]. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .maximumCharge() + * .minimumCharge() + * .perUnitRate() + * ``` */ fun builder() = Builder() } @@ -3880,17 +5757,85 @@ private constructor( /** A builder for [GroupedWithMinMaxThresholdsConfig]. */ class Builder internal constructor() { + private var groupingKey: JsonField? = null + private var maximumCharge: JsonField? = null + private var minimumCharge: JsonField? = null + private var perUnitRate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from( groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig ) = apply { + groupingKey = groupedWithMinMaxThresholdsConfig.groupingKey + maximumCharge = groupedWithMinMaxThresholdsConfig.maximumCharge + minimumCharge = groupedWithMinMaxThresholdsConfig.minimumCharge + perUnitRate = groupedWithMinMaxThresholdsConfig.perUnitRate additionalProperties = groupedWithMinMaxThresholdsConfig.additionalProperties .toMutableMap() } + /** The event property used to group before applying thresholds */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The maximum amount to charge each group */ + fun maximumCharge(maximumCharge: String) = + maximumCharge(JsonField.of(maximumCharge)) + + /** + * Sets [Builder.maximumCharge] to an arbitrary JSON value. + * + * You should usually call [Builder.maximumCharge] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun maximumCharge(maximumCharge: JsonField) = apply { + this.maximumCharge = maximumCharge + } + + /** The minimum amount to charge each group, regardless of usage */ + fun minimumCharge(minimumCharge: String) = + minimumCharge(JsonField.of(minimumCharge)) + + /** + * Sets [Builder.minimumCharge] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumCharge] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun minimumCharge(minimumCharge: JsonField) = apply { + this.minimumCharge = minimumCharge + } + + /** The base price charged per group */ + fun perUnitRate(perUnitRate: String) = + perUnitRate(JsonField.of(perUnitRate)) + + /** + * Sets [Builder.perUnitRate] to an arbitrary JSON value. + * + * You should usually call [Builder.perUnitRate] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun perUnitRate(perUnitRate: JsonField) = apply { + this.perUnitRate = perUnitRate + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -3917,9 +5862,25 @@ private constructor( * Returns an immutable instance of [GroupedWithMinMaxThresholdsConfig]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .maximumCharge() + * .minimumCharge() + * .perUnitRate() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ fun build(): GroupedWithMinMaxThresholdsConfig = - GroupedWithMinMaxThresholdsConfig(additionalProperties.toImmutable()) + GroupedWithMinMaxThresholdsConfig( + checkRequired("groupingKey", groupingKey), + checkRequired("maximumCharge", maximumCharge), + checkRequired("minimumCharge", minimumCharge), + checkRequired("perUnitRate", perUnitRate), + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false @@ -3929,6 +5890,10 @@ private constructor( return@apply } + groupingKey() + maximumCharge() + minimumCharge() + perUnitRate() validated = true } @@ -3947,9 +5912,10 @@ private constructor( * Used for best match union deserialization. */ internal fun validity(): Int = - additionalProperties.count { (_, value) -> - !value.isNull() && !value.isMissing() - } + (if (groupingKey.asKnown() == null) 0 else 1) + + (if (maximumCharge.asKnown() == null) 0 else 1) + + (if (minimumCharge.asKnown() == null) 0 else 1) + + (if (perUnitRate.asKnown() == null) 0 else 1) override fun equals(other: Any?): Boolean { if (this === other) { @@ -3957,15 +5923,27 @@ private constructor( } return other is GroupedWithMinMaxThresholdsConfig && + groupingKey == other.groupingKey && + maximumCharge == other.maximumCharge && + minimumCharge == other.minimumCharge && + perUnitRate == other.perUnitRate && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + private val hashCode: Int by lazy { + Objects.hash( + groupingKey, + maximumCharge, + minimumCharge, + perUnitRate, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode override fun toString() = - "GroupedWithMinMaxThresholdsConfig{additionalProperties=$additionalProperties}" + "GroupedWithMinMaxThresholdsConfig{groupingKey=$groupingKey, maximumCharge=$maximumCharge, minimumCharge=$minimumCharge, perUnitRate=$perUnitRate, additionalProperties=$additionalProperties}" } /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanVersion.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanVersion.kt index 3f238974b..2bea6f329 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanVersion.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanVersion.kt @@ -303,18 +303,18 @@ private constructor( /** Alias for calling [addPrice] with `Price.ofUnit(unit)`. */ fun addPrice(unit: Price.Unit) = addPrice(Price.ofUnit(unit)) - /** Alias for calling [addPrice] with `Price.ofPackage(package_)`. */ - fun addPrice(package_: Price.Package) = addPrice(Price.ofPackage(package_)) - - /** Alias for calling [addPrice] with `Price.ofMatrix(matrix)`. */ - fun addPrice(matrix: Price.Matrix) = addPrice(Price.ofMatrix(matrix)) - /** Alias for calling [addPrice] with `Price.ofTiered(tiered)`. */ fun addPrice(tiered: Price.Tiered) = addPrice(Price.ofTiered(tiered)) /** Alias for calling [addPrice] with `Price.ofBulk(bulk)`. */ fun addPrice(bulk: Price.Bulk) = addPrice(Price.ofBulk(bulk)) + /** Alias for calling [addPrice] with `Price.ofPackage(package_)`. */ + fun addPrice(package_: Price.Package) = addPrice(Price.ofPackage(package_)) + + /** Alias for calling [addPrice] with `Price.ofMatrix(matrix)`. */ + fun addPrice(matrix: Price.Matrix) = addPrice(Price.ofMatrix(matrix)) + /** * Alias for calling [addPrice] with `Price.ofThresholdTotalAmount(thresholdTotalAmount)`. */ @@ -325,14 +325,14 @@ private constructor( fun addPrice(tieredPackage: Price.TieredPackage) = addPrice(Price.ofTieredPackage(tieredPackage)) - /** Alias for calling [addPrice] with `Price.ofGroupedTiered(groupedTiered)`. */ - fun addPrice(groupedTiered: Price.GroupedTiered) = - addPrice(Price.ofGroupedTiered(groupedTiered)) - /** Alias for calling [addPrice] with `Price.ofTieredWithMinimum(tieredWithMinimum)`. */ fun addPrice(tieredWithMinimum: Price.TieredWithMinimum) = addPrice(Price.ofTieredWithMinimum(tieredWithMinimum)) + /** Alias for calling [addPrice] with `Price.ofGroupedTiered(groupedTiered)`. */ + fun addPrice(groupedTiered: Price.GroupedTiered) = + addPrice(Price.ofGroupedTiered(groupedTiered)) + /** * Alias for calling [addPrice] with * `Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)`. @@ -368,6 +368,10 @@ private constructor( fun addPrice(groupedAllocation: Price.GroupedAllocation) = addPrice(Price.ofGroupedAllocation(groupedAllocation)) + /** Alias for calling [addPrice] with `Price.ofBulkWithProration(bulkWithProration)`. */ + fun addPrice(bulkWithProration: Price.BulkWithProration) = + addPrice(Price.ofBulkWithProration(bulkWithProration)) + /** * Alias for calling [addPrice] with * `Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)`. @@ -382,16 +386,19 @@ private constructor( fun addPrice(groupedWithMeteredMinimum: Price.GroupedWithMeteredMinimum) = addPrice(Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)) + /** + * Alias for calling [addPrice] with + * `Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)`. + */ + fun addPrice(groupedWithMinMaxThresholds: Price.GroupedWithMinMaxThresholds) = + addPrice(Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)) + /** * Alias for calling [addPrice] with `Price.ofMatrixWithDisplayName(matrixWithDisplayName)`. */ fun addPrice(matrixWithDisplayName: Price.MatrixWithDisplayName) = addPrice(Price.ofMatrixWithDisplayName(matrixWithDisplayName)) - /** Alias for calling [addPrice] with `Price.ofBulkWithProration(bulkWithProration)`. */ - fun addPrice(bulkWithProration: Price.BulkWithProration) = - addPrice(Price.ofBulkWithProration(bulkWithProration)) - /** * Alias for calling [addPrice] with `Price.ofGroupedTieredPackage(groupedTieredPackage)`. */ @@ -424,13 +431,6 @@ private constructor( fun addPrice(cumulativeGroupedBulk: Price.CumulativeGroupedBulk) = addPrice(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) - /** - * Alias for calling [addPrice] with - * `Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)`. - */ - fun addPrice(groupedWithMinMaxThresholds: Price.GroupedWithMinMaxThresholds) = - addPrice(Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)) - /** Alias for calling [addPrice] with `Price.ofMinimum(minimum)`. */ fun addPrice(minimum: Price.Minimum) = addPrice(Price.ofMinimum(minimum)) diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Price.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Price.kt index 67957ac5d..e3217ab4f 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Price.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Price.kt @@ -47,14 +47,14 @@ import kotlin.Unit as KUnit class Price private constructor( private val unit: Unit? = null, - private val package_: Package? = null, - private val matrix: Matrix? = null, private val tiered: Tiered? = null, private val bulk: Bulk? = null, + private val package_: Package? = null, + private val matrix: Matrix? = null, private val thresholdTotalAmount: ThresholdTotalAmount? = null, private val tieredPackage: TieredPackage? = null, - private val groupedTiered: GroupedTiered? = null, private val tieredWithMinimum: TieredWithMinimum? = null, + private val groupedTiered: GroupedTiered? = null, private val tieredPackageWithMinimum: TieredPackageWithMinimum? = null, private val packageWithAllocation: PackageWithAllocation? = null, private val unitWithPercent: UnitWithPercent? = null, @@ -62,38 +62,38 @@ private constructor( private val tieredWithProration: TieredWithProration? = null, private val unitWithProration: UnitWithProration? = null, private val groupedAllocation: GroupedAllocation? = null, + private val bulkWithProration: BulkWithProration? = null, private val groupedWithProratedMinimum: GroupedWithProratedMinimum? = null, private val groupedWithMeteredMinimum: GroupedWithMeteredMinimum? = null, + private val groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds? = null, private val matrixWithDisplayName: MatrixWithDisplayName? = null, - private val bulkWithProration: BulkWithProration? = null, private val groupedTieredPackage: GroupedTieredPackage? = null, private val maxGroupTieredPackage: MaxGroupTieredPackage? = null, private val scalableMatrixWithUnitPricing: ScalableMatrixWithUnitPricing? = null, private val scalableMatrixWithTieredPricing: ScalableMatrixWithTieredPricing? = null, private val cumulativeGroupedBulk: CumulativeGroupedBulk? = null, - private val groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds? = null, private val minimum: Minimum? = null, private val _json: JsonValue? = null, ) { fun unit(): Unit? = unit - fun package_(): Package? = package_ - - fun matrix(): Matrix? = matrix - fun tiered(): Tiered? = tiered fun bulk(): Bulk? = bulk + fun package_(): Package? = package_ + + fun matrix(): Matrix? = matrix + fun thresholdTotalAmount(): ThresholdTotalAmount? = thresholdTotalAmount fun tieredPackage(): TieredPackage? = tieredPackage - fun groupedTiered(): GroupedTiered? = groupedTiered - fun tieredWithMinimum(): TieredWithMinimum? = tieredWithMinimum + fun groupedTiered(): GroupedTiered? = groupedTiered + fun tieredPackageWithMinimum(): TieredPackageWithMinimum? = tieredPackageWithMinimum fun packageWithAllocation(): PackageWithAllocation? = packageWithAllocation @@ -108,13 +108,15 @@ private constructor( fun groupedAllocation(): GroupedAllocation? = groupedAllocation + fun bulkWithProration(): BulkWithProration? = bulkWithProration + fun groupedWithProratedMinimum(): GroupedWithProratedMinimum? = groupedWithProratedMinimum fun groupedWithMeteredMinimum(): GroupedWithMeteredMinimum? = groupedWithMeteredMinimum - fun matrixWithDisplayName(): MatrixWithDisplayName? = matrixWithDisplayName + fun groupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds? = groupedWithMinMaxThresholds - fun bulkWithProration(): BulkWithProration? = bulkWithProration + fun matrixWithDisplayName(): MatrixWithDisplayName? = matrixWithDisplayName fun groupedTieredPackage(): GroupedTieredPackage? = groupedTieredPackage @@ -128,28 +130,26 @@ private constructor( fun cumulativeGroupedBulk(): CumulativeGroupedBulk? = cumulativeGroupedBulk - fun groupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds? = groupedWithMinMaxThresholds - fun minimum(): Minimum? = minimum fun isUnit(): Boolean = unit != null - fun isPackage(): Boolean = package_ != null - - fun isMatrix(): Boolean = matrix != null - fun isTiered(): Boolean = tiered != null fun isBulk(): Boolean = bulk != null + fun isPackage(): Boolean = package_ != null + + fun isMatrix(): Boolean = matrix != null + fun isThresholdTotalAmount(): Boolean = thresholdTotalAmount != null fun isTieredPackage(): Boolean = tieredPackage != null - fun isGroupedTiered(): Boolean = groupedTiered != null - fun isTieredWithMinimum(): Boolean = tieredWithMinimum != null + fun isGroupedTiered(): Boolean = groupedTiered != null + fun isTieredPackageWithMinimum(): Boolean = tieredPackageWithMinimum != null fun isPackageWithAllocation(): Boolean = packageWithAllocation != null @@ -164,13 +164,15 @@ private constructor( fun isGroupedAllocation(): Boolean = groupedAllocation != null + fun isBulkWithProration(): Boolean = bulkWithProration != null + fun isGroupedWithProratedMinimum(): Boolean = groupedWithProratedMinimum != null fun isGroupedWithMeteredMinimum(): Boolean = groupedWithMeteredMinimum != null - fun isMatrixWithDisplayName(): Boolean = matrixWithDisplayName != null + fun isGroupedWithMinMaxThresholds(): Boolean = groupedWithMinMaxThresholds != null - fun isBulkWithProration(): Boolean = bulkWithProration != null + fun isMatrixWithDisplayName(): Boolean = matrixWithDisplayName != null fun isGroupedTieredPackage(): Boolean = groupedTieredPackage != null @@ -182,29 +184,27 @@ private constructor( fun isCumulativeGroupedBulk(): Boolean = cumulativeGroupedBulk != null - fun isGroupedWithMinMaxThresholds(): Boolean = groupedWithMinMaxThresholds != null - fun isMinimum(): Boolean = minimum != null fun asUnit(): Unit = unit.getOrThrow("unit") - fun asPackage(): Package = package_.getOrThrow("package_") - - fun asMatrix(): Matrix = matrix.getOrThrow("matrix") - fun asTiered(): Tiered = tiered.getOrThrow("tiered") fun asBulk(): Bulk = bulk.getOrThrow("bulk") + fun asPackage(): Package = package_.getOrThrow("package_") + + fun asMatrix(): Matrix = matrix.getOrThrow("matrix") + fun asThresholdTotalAmount(): ThresholdTotalAmount = thresholdTotalAmount.getOrThrow("thresholdTotalAmount") fun asTieredPackage(): TieredPackage = tieredPackage.getOrThrow("tieredPackage") - fun asGroupedTiered(): GroupedTiered = groupedTiered.getOrThrow("groupedTiered") - fun asTieredWithMinimum(): TieredWithMinimum = tieredWithMinimum.getOrThrow("tieredWithMinimum") + fun asGroupedTiered(): GroupedTiered = groupedTiered.getOrThrow("groupedTiered") + fun asTieredPackageWithMinimum(): TieredPackageWithMinimum = tieredPackageWithMinimum.getOrThrow("tieredPackageWithMinimum") @@ -223,17 +223,20 @@ private constructor( fun asGroupedAllocation(): GroupedAllocation = groupedAllocation.getOrThrow("groupedAllocation") + fun asBulkWithProration(): BulkWithProration = bulkWithProration.getOrThrow("bulkWithProration") + fun asGroupedWithProratedMinimum(): GroupedWithProratedMinimum = groupedWithProratedMinimum.getOrThrow("groupedWithProratedMinimum") fun asGroupedWithMeteredMinimum(): GroupedWithMeteredMinimum = groupedWithMeteredMinimum.getOrThrow("groupedWithMeteredMinimum") + fun asGroupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds = + groupedWithMinMaxThresholds.getOrThrow("groupedWithMinMaxThresholds") + fun asMatrixWithDisplayName(): MatrixWithDisplayName = matrixWithDisplayName.getOrThrow("matrixWithDisplayName") - fun asBulkWithProration(): BulkWithProration = bulkWithProration.getOrThrow("bulkWithProration") - fun asGroupedTieredPackage(): GroupedTieredPackage = groupedTieredPackage.getOrThrow("groupedTieredPackage") @@ -249,9 +252,6 @@ private constructor( fun asCumulativeGroupedBulk(): CumulativeGroupedBulk = cumulativeGroupedBulk.getOrThrow("cumulativeGroupedBulk") - fun asGroupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds = - groupedWithMinMaxThresholds.getOrThrow("groupedWithMinMaxThresholds") - fun asMinimum(): Minimum = minimum.getOrThrow("minimum") fun _json(): JsonValue? = _json @@ -259,14 +259,14 @@ private constructor( fun accept(visitor: Visitor): T = when { unit != null -> visitor.visitUnit(unit) - package_ != null -> visitor.visitPackage(package_) - matrix != null -> visitor.visitMatrix(matrix) tiered != null -> visitor.visitTiered(tiered) bulk != null -> visitor.visitBulk(bulk) + package_ != null -> visitor.visitPackage(package_) + matrix != null -> visitor.visitMatrix(matrix) thresholdTotalAmount != null -> visitor.visitThresholdTotalAmount(thresholdTotalAmount) tieredPackage != null -> visitor.visitTieredPackage(tieredPackage) - groupedTiered != null -> visitor.visitGroupedTiered(groupedTiered) tieredWithMinimum != null -> visitor.visitTieredWithMinimum(tieredWithMinimum) + groupedTiered != null -> visitor.visitGroupedTiered(groupedTiered) tieredPackageWithMinimum != null -> visitor.visitTieredPackageWithMinimum(tieredPackageWithMinimum) packageWithAllocation != null -> @@ -276,13 +276,15 @@ private constructor( tieredWithProration != null -> visitor.visitTieredWithProration(tieredWithProration) unitWithProration != null -> visitor.visitUnitWithProration(unitWithProration) groupedAllocation != null -> visitor.visitGroupedAllocation(groupedAllocation) + bulkWithProration != null -> visitor.visitBulkWithProration(bulkWithProration) groupedWithProratedMinimum != null -> visitor.visitGroupedWithProratedMinimum(groupedWithProratedMinimum) groupedWithMeteredMinimum != null -> visitor.visitGroupedWithMeteredMinimum(groupedWithMeteredMinimum) + groupedWithMinMaxThresholds != null -> + visitor.visitGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds) matrixWithDisplayName != null -> visitor.visitMatrixWithDisplayName(matrixWithDisplayName) - bulkWithProration != null -> visitor.visitBulkWithProration(bulkWithProration) groupedTieredPackage != null -> visitor.visitGroupedTieredPackage(groupedTieredPackage) maxGroupTieredPackage != null -> visitor.visitMaxGroupTieredPackage(maxGroupTieredPackage) @@ -292,8 +294,6 @@ private constructor( visitor.visitScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing) cumulativeGroupedBulk != null -> visitor.visitCumulativeGroupedBulk(cumulativeGroupedBulk) - groupedWithMinMaxThresholds != null -> - visitor.visitGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds) minimum != null -> visitor.visitMinimum(minimum) else -> visitor.unknown(_json) } @@ -311,14 +311,6 @@ private constructor( unit.validate() } - override fun visitPackage(package_: Package) { - package_.validate() - } - - override fun visitMatrix(matrix: Matrix) { - matrix.validate() - } - override fun visitTiered(tiered: Tiered) { tiered.validate() } @@ -327,6 +319,14 @@ private constructor( bulk.validate() } + override fun visitPackage(package_: Package) { + package_.validate() + } + + override fun visitMatrix(matrix: Matrix) { + matrix.validate() + } + override fun visitThresholdTotalAmount(thresholdTotalAmount: ThresholdTotalAmount) { thresholdTotalAmount.validate() } @@ -335,14 +335,14 @@ private constructor( tieredPackage.validate() } - override fun visitGroupedTiered(groupedTiered: GroupedTiered) { - groupedTiered.validate() - } - override fun visitTieredWithMinimum(tieredWithMinimum: TieredWithMinimum) { tieredWithMinimum.validate() } + override fun visitGroupedTiered(groupedTiered: GroupedTiered) { + groupedTiered.validate() + } + override fun visitTieredPackageWithMinimum( tieredPackageWithMinimum: TieredPackageWithMinimum ) { @@ -375,6 +375,10 @@ private constructor( groupedAllocation.validate() } + override fun visitBulkWithProration(bulkWithProration: BulkWithProration) { + bulkWithProration.validate() + } + override fun visitGroupedWithProratedMinimum( groupedWithProratedMinimum: GroupedWithProratedMinimum ) { @@ -387,16 +391,18 @@ private constructor( groupedWithMeteredMinimum.validate() } + override fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) { + groupedWithMinMaxThresholds.validate() + } + override fun visitMatrixWithDisplayName( matrixWithDisplayName: MatrixWithDisplayName ) { matrixWithDisplayName.validate() } - override fun visitBulkWithProration(bulkWithProration: BulkWithProration) { - bulkWithProration.validate() - } - override fun visitGroupedTieredPackage(groupedTieredPackage: GroupedTieredPackage) { groupedTieredPackage.validate() } @@ -425,12 +431,6 @@ private constructor( cumulativeGroupedBulk.validate() } - override fun visitGroupedWithMinMaxThresholds( - groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds - ) { - groupedWithMinMaxThresholds.validate() - } - override fun visitMinimum(minimum: Minimum) { minimum.validate() } @@ -457,26 +457,26 @@ private constructor( object : Visitor { override fun visitUnit(unit: Unit) = unit.validity() - override fun visitPackage(package_: Package) = package_.validity() - - override fun visitMatrix(matrix: Matrix) = matrix.validity() - override fun visitTiered(tiered: Tiered) = tiered.validity() override fun visitBulk(bulk: Bulk) = bulk.validity() + override fun visitPackage(package_: Package) = package_.validity() + + override fun visitMatrix(matrix: Matrix) = matrix.validity() + override fun visitThresholdTotalAmount(thresholdTotalAmount: ThresholdTotalAmount) = thresholdTotalAmount.validity() override fun visitTieredPackage(tieredPackage: TieredPackage) = tieredPackage.validity() - override fun visitGroupedTiered(groupedTiered: GroupedTiered) = - groupedTiered.validity() - override fun visitTieredWithMinimum(tieredWithMinimum: TieredWithMinimum) = tieredWithMinimum.validity() + override fun visitGroupedTiered(groupedTiered: GroupedTiered) = + groupedTiered.validity() + override fun visitTieredPackageWithMinimum( tieredPackageWithMinimum: TieredPackageWithMinimum ) = tieredPackageWithMinimum.validity() @@ -500,6 +500,9 @@ private constructor( override fun visitGroupedAllocation(groupedAllocation: GroupedAllocation) = groupedAllocation.validity() + override fun visitBulkWithProration(bulkWithProration: BulkWithProration) = + bulkWithProration.validity() + override fun visitGroupedWithProratedMinimum( groupedWithProratedMinimum: GroupedWithProratedMinimum ) = groupedWithProratedMinimum.validity() @@ -508,13 +511,14 @@ private constructor( groupedWithMeteredMinimum: GroupedWithMeteredMinimum ) = groupedWithMeteredMinimum.validity() + override fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) = groupedWithMinMaxThresholds.validity() + override fun visitMatrixWithDisplayName( matrixWithDisplayName: MatrixWithDisplayName ) = matrixWithDisplayName.validity() - override fun visitBulkWithProration(bulkWithProration: BulkWithProration) = - bulkWithProration.validity() - override fun visitGroupedTieredPackage(groupedTieredPackage: GroupedTieredPackage) = groupedTieredPackage.validity() @@ -534,10 +538,6 @@ private constructor( cumulativeGroupedBulk: CumulativeGroupedBulk ) = cumulativeGroupedBulk.validity() - override fun visitGroupedWithMinMaxThresholds( - groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds - ) = groupedWithMinMaxThresholds.validity() - override fun visitMinimum(minimum: Minimum) = minimum.validity() override fun unknown(json: JsonValue?) = 0 @@ -551,14 +551,14 @@ private constructor( return other is Price && unit == other.unit && - package_ == other.package_ && - matrix == other.matrix && tiered == other.tiered && bulk == other.bulk && + package_ == other.package_ && + matrix == other.matrix && thresholdTotalAmount == other.thresholdTotalAmount && tieredPackage == other.tieredPackage && - groupedTiered == other.groupedTiered && tieredWithMinimum == other.tieredWithMinimum && + groupedTiered == other.groupedTiered && tieredPackageWithMinimum == other.tieredPackageWithMinimum && packageWithAllocation == other.packageWithAllocation && unitWithPercent == other.unitWithPercent && @@ -566,30 +566,30 @@ private constructor( tieredWithProration == other.tieredWithProration && unitWithProration == other.unitWithProration && groupedAllocation == other.groupedAllocation && + bulkWithProration == other.bulkWithProration && groupedWithProratedMinimum == other.groupedWithProratedMinimum && groupedWithMeteredMinimum == other.groupedWithMeteredMinimum && + groupedWithMinMaxThresholds == other.groupedWithMinMaxThresholds && matrixWithDisplayName == other.matrixWithDisplayName && - bulkWithProration == other.bulkWithProration && groupedTieredPackage == other.groupedTieredPackage && maxGroupTieredPackage == other.maxGroupTieredPackage && scalableMatrixWithUnitPricing == other.scalableMatrixWithUnitPricing && scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && cumulativeGroupedBulk == other.cumulativeGroupedBulk && - groupedWithMinMaxThresholds == other.groupedWithMinMaxThresholds && minimum == other.minimum } override fun hashCode(): Int = Objects.hash( unit, - package_, - matrix, tiered, bulk, + package_, + matrix, thresholdTotalAmount, tieredPackage, - groupedTiered, tieredWithMinimum, + groupedTiered, tieredPackageWithMinimum, packageWithAllocation, unitWithPercent, @@ -597,30 +597,30 @@ private constructor( tieredWithProration, unitWithProration, groupedAllocation, + bulkWithProration, groupedWithProratedMinimum, groupedWithMeteredMinimum, + groupedWithMinMaxThresholds, matrixWithDisplayName, - bulkWithProration, groupedTieredPackage, maxGroupTieredPackage, scalableMatrixWithUnitPricing, scalableMatrixWithTieredPricing, cumulativeGroupedBulk, - groupedWithMinMaxThresholds, minimum, ) override fun toString(): String = when { unit != null -> "Price{unit=$unit}" - package_ != null -> "Price{package_=$package_}" - matrix != null -> "Price{matrix=$matrix}" tiered != null -> "Price{tiered=$tiered}" bulk != null -> "Price{bulk=$bulk}" + package_ != null -> "Price{package_=$package_}" + matrix != null -> "Price{matrix=$matrix}" thresholdTotalAmount != null -> "Price{thresholdTotalAmount=$thresholdTotalAmount}" tieredPackage != null -> "Price{tieredPackage=$tieredPackage}" - groupedTiered != null -> "Price{groupedTiered=$groupedTiered}" tieredWithMinimum != null -> "Price{tieredWithMinimum=$tieredWithMinimum}" + groupedTiered != null -> "Price{groupedTiered=$groupedTiered}" tieredPackageWithMinimum != null -> "Price{tieredPackageWithMinimum=$tieredPackageWithMinimum}" packageWithAllocation != null -> "Price{packageWithAllocation=$packageWithAllocation}" @@ -629,12 +629,14 @@ private constructor( tieredWithProration != null -> "Price{tieredWithProration=$tieredWithProration}" unitWithProration != null -> "Price{unitWithProration=$unitWithProration}" groupedAllocation != null -> "Price{groupedAllocation=$groupedAllocation}" + bulkWithProration != null -> "Price{bulkWithProration=$bulkWithProration}" groupedWithProratedMinimum != null -> "Price{groupedWithProratedMinimum=$groupedWithProratedMinimum}" groupedWithMeteredMinimum != null -> "Price{groupedWithMeteredMinimum=$groupedWithMeteredMinimum}" + groupedWithMinMaxThresholds != null -> + "Price{groupedWithMinMaxThresholds=$groupedWithMinMaxThresholds}" matrixWithDisplayName != null -> "Price{matrixWithDisplayName=$matrixWithDisplayName}" - bulkWithProration != null -> "Price{bulkWithProration=$bulkWithProration}" groupedTieredPackage != null -> "Price{groupedTieredPackage=$groupedTieredPackage}" maxGroupTieredPackage != null -> "Price{maxGroupTieredPackage=$maxGroupTieredPackage}" scalableMatrixWithUnitPricing != null -> @@ -642,8 +644,6 @@ private constructor( scalableMatrixWithTieredPricing != null -> "Price{scalableMatrixWithTieredPricing=$scalableMatrixWithTieredPricing}" cumulativeGroupedBulk != null -> "Price{cumulativeGroupedBulk=$cumulativeGroupedBulk}" - groupedWithMinMaxThresholds != null -> - "Price{groupedWithMinMaxThresholds=$groupedWithMinMaxThresholds}" minimum != null -> "Price{minimum=$minimum}" _json != null -> "Price{_unknown=$_json}" else -> throw IllegalStateException("Invalid Price") @@ -653,24 +653,24 @@ private constructor( fun ofUnit(unit: Unit) = Price(unit = unit) - fun ofPackage(package_: Package) = Price(package_ = package_) - - fun ofMatrix(matrix: Matrix) = Price(matrix = matrix) - fun ofTiered(tiered: Tiered) = Price(tiered = tiered) fun ofBulk(bulk: Bulk) = Price(bulk = bulk) + fun ofPackage(package_: Package) = Price(package_ = package_) + + fun ofMatrix(matrix: Matrix) = Price(matrix = matrix) + fun ofThresholdTotalAmount(thresholdTotalAmount: ThresholdTotalAmount) = Price(thresholdTotalAmount = thresholdTotalAmount) fun ofTieredPackage(tieredPackage: TieredPackage) = Price(tieredPackage = tieredPackage) - fun ofGroupedTiered(groupedTiered: GroupedTiered) = Price(groupedTiered = groupedTiered) - fun ofTieredWithMinimum(tieredWithMinimum: TieredWithMinimum) = Price(tieredWithMinimum = tieredWithMinimum) + fun ofGroupedTiered(groupedTiered: GroupedTiered) = Price(groupedTiered = groupedTiered) + fun ofTieredPackageWithMinimum(tieredPackageWithMinimum: TieredPackageWithMinimum) = Price(tieredPackageWithMinimum = tieredPackageWithMinimum) @@ -692,18 +692,22 @@ private constructor( fun ofGroupedAllocation(groupedAllocation: GroupedAllocation) = Price(groupedAllocation = groupedAllocation) + fun ofBulkWithProration(bulkWithProration: BulkWithProration) = + Price(bulkWithProration = bulkWithProration) + fun ofGroupedWithProratedMinimum(groupedWithProratedMinimum: GroupedWithProratedMinimum) = Price(groupedWithProratedMinimum = groupedWithProratedMinimum) fun ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum: GroupedWithMeteredMinimum) = Price(groupedWithMeteredMinimum = groupedWithMeteredMinimum) + fun ofGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) = Price(groupedWithMinMaxThresholds = groupedWithMinMaxThresholds) + fun ofMatrixWithDisplayName(matrixWithDisplayName: MatrixWithDisplayName) = Price(matrixWithDisplayName = matrixWithDisplayName) - fun ofBulkWithProration(bulkWithProration: BulkWithProration) = - Price(bulkWithProration = bulkWithProration) - fun ofGroupedTieredPackage(groupedTieredPackage: GroupedTieredPackage) = Price(groupedTieredPackage = groupedTieredPackage) @@ -721,10 +725,6 @@ private constructor( fun ofCumulativeGroupedBulk(cumulativeGroupedBulk: CumulativeGroupedBulk) = Price(cumulativeGroupedBulk = cumulativeGroupedBulk) - fun ofGroupedWithMinMaxThresholds( - groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds - ) = Price(groupedWithMinMaxThresholds = groupedWithMinMaxThresholds) - fun ofMinimum(minimum: Minimum) = Price(minimum = minimum) } @@ -733,22 +733,22 @@ private constructor( fun visitUnit(unit: Unit): T - fun visitPackage(package_: Package): T - - fun visitMatrix(matrix: Matrix): T - fun visitTiered(tiered: Tiered): T fun visitBulk(bulk: Bulk): T + fun visitPackage(package_: Package): T + + fun visitMatrix(matrix: Matrix): T + fun visitThresholdTotalAmount(thresholdTotalAmount: ThresholdTotalAmount): T fun visitTieredPackage(tieredPackage: TieredPackage): T - fun visitGroupedTiered(groupedTiered: GroupedTiered): T - fun visitTieredWithMinimum(tieredWithMinimum: TieredWithMinimum): T + fun visitGroupedTiered(groupedTiered: GroupedTiered): T + fun visitTieredPackageWithMinimum(tieredPackageWithMinimum: TieredPackageWithMinimum): T fun visitPackageWithAllocation(packageWithAllocation: PackageWithAllocation): T @@ -763,15 +763,19 @@ private constructor( fun visitGroupedAllocation(groupedAllocation: GroupedAllocation): T + fun visitBulkWithProration(bulkWithProration: BulkWithProration): T + fun visitGroupedWithProratedMinimum( groupedWithProratedMinimum: GroupedWithProratedMinimum ): T fun visitGroupedWithMeteredMinimum(groupedWithMeteredMinimum: GroupedWithMeteredMinimum): T - fun visitMatrixWithDisplayName(matrixWithDisplayName: MatrixWithDisplayName): T + fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ): T - fun visitBulkWithProration(bulkWithProration: BulkWithProration): T + fun visitMatrixWithDisplayName(matrixWithDisplayName: MatrixWithDisplayName): T fun visitGroupedTieredPackage(groupedTieredPackage: GroupedTieredPackage): T @@ -787,10 +791,6 @@ private constructor( fun visitCumulativeGroupedBulk(cumulativeGroupedBulk: CumulativeGroupedBulk): T - fun visitGroupedWithMinMaxThresholds( - groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds - ): T - fun visitMinimum(minimum: Minimum): T /** @@ -819,16 +819,6 @@ private constructor( Price(unit = it, _json = json) } ?: Price(_json = json) } - "package" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(package_ = it, _json = json) - } ?: Price(_json = json) - } - "matrix" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(matrix = it, _json = json) - } ?: Price(_json = json) - } "tiered" -> { return tryDeserialize(node, jacksonTypeRef())?.let { Price(tiered = it, _json = json) @@ -839,6 +829,16 @@ private constructor( Price(bulk = it, _json = json) } ?: Price(_json = json) } + "package" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(package_ = it, _json = json) + } ?: Price(_json = json) + } + "matrix" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(matrix = it, _json = json) + } ?: Price(_json = json) + } "threshold_total_amount" -> { return tryDeserialize(node, jacksonTypeRef())?.let { Price(thresholdTotalAmount = it, _json = json) @@ -849,16 +849,16 @@ private constructor( Price(tieredPackage = it, _json = json) } ?: Price(_json = json) } - "grouped_tiered" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(groupedTiered = it, _json = json) - } ?: Price(_json = json) - } "tiered_with_minimum" -> { return tryDeserialize(node, jacksonTypeRef())?.let { Price(tieredWithMinimum = it, _json = json) } ?: Price(_json = json) } + "grouped_tiered" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(groupedTiered = it, _json = json) + } ?: Price(_json = json) + } "tiered_package_with_minimum" -> { return tryDeserialize(node, jacksonTypeRef())?.let { Price(tieredPackageWithMinimum = it, _json = json) @@ -894,6 +894,11 @@ private constructor( Price(groupedAllocation = it, _json = json) } ?: Price(_json = json) } + "bulk_with_proration" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(bulkWithProration = it, _json = json) + } ?: Price(_json = json) + } "grouped_with_prorated_minimum" -> { return tryDeserialize(node, jacksonTypeRef())?.let { Price(groupedWithProratedMinimum = it, _json = json) @@ -904,16 +909,16 @@ private constructor( Price(groupedWithMeteredMinimum = it, _json = json) } ?: Price(_json = json) } + "grouped_with_min_max_thresholds" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(groupedWithMinMaxThresholds = it, _json = json) } + ?: Price(_json = json) + } "matrix_with_display_name" -> { return tryDeserialize(node, jacksonTypeRef())?.let { Price(matrixWithDisplayName = it, _json = json) } ?: Price(_json = json) } - "bulk_with_proration" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(bulkWithProration = it, _json = json) - } ?: Price(_json = json) - } "grouped_tiered_package" -> { return tryDeserialize(node, jacksonTypeRef())?.let { Price(groupedTieredPackage = it, _json = json) @@ -939,11 +944,6 @@ private constructor( Price(cumulativeGroupedBulk = it, _json = json) } ?: Price(_json = json) } - "grouped_with_min_max_thresholds" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(groupedWithMinMaxThresholds = it, _json = json) } - ?: Price(_json = json) - } "minimum" -> { return tryDeserialize(node, jacksonTypeRef())?.let { Price(minimum = it, _json = json) @@ -964,15 +964,15 @@ private constructor( ) { when { value.unit != null -> generator.writeObject(value.unit) - value.package_ != null -> generator.writeObject(value.package_) - value.matrix != null -> generator.writeObject(value.matrix) value.tiered != null -> generator.writeObject(value.tiered) value.bulk != null -> generator.writeObject(value.bulk) + value.package_ != null -> generator.writeObject(value.package_) + value.matrix != null -> generator.writeObject(value.matrix) value.thresholdTotalAmount != null -> generator.writeObject(value.thresholdTotalAmount) value.tieredPackage != null -> generator.writeObject(value.tieredPackage) - value.groupedTiered != null -> generator.writeObject(value.groupedTiered) value.tieredWithMinimum != null -> generator.writeObject(value.tieredWithMinimum) + value.groupedTiered != null -> generator.writeObject(value.groupedTiered) value.tieredPackageWithMinimum != null -> generator.writeObject(value.tieredPackageWithMinimum) value.packageWithAllocation != null -> @@ -984,13 +984,15 @@ private constructor( generator.writeObject(value.tieredWithProration) value.unitWithProration != null -> generator.writeObject(value.unitWithProration) value.groupedAllocation != null -> generator.writeObject(value.groupedAllocation) + value.bulkWithProration != null -> generator.writeObject(value.bulkWithProration) value.groupedWithProratedMinimum != null -> generator.writeObject(value.groupedWithProratedMinimum) value.groupedWithMeteredMinimum != null -> generator.writeObject(value.groupedWithMeteredMinimum) + value.groupedWithMinMaxThresholds != null -> + generator.writeObject(value.groupedWithMinMaxThresholds) value.matrixWithDisplayName != null -> generator.writeObject(value.matrixWithDisplayName) - value.bulkWithProration != null -> generator.writeObject(value.bulkWithProration) value.groupedTieredPackage != null -> generator.writeObject(value.groupedTieredPackage) value.maxGroupTieredPackage != null -> @@ -1001,8 +1003,6 @@ private constructor( generator.writeObject(value.scalableMatrixWithTieredPricing) value.cumulativeGroupedBulk != null -> generator.writeObject(value.cumulativeGroupedBulk) - value.groupedWithMinMaxThresholds != null -> - generator.writeObject(value.groupedWithMinMaxThresholds) value.minimum != null -> generator.writeObject(value.minimum) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid Price") @@ -1274,6 +1274,8 @@ private constructor( fun minimumAmount(): String? = minimumAmount.getNullable("minimum_amount") /** + * The pricing model type + * * Expected to always return the following: * ```kotlin * JsonValue.from("unit") @@ -1312,6 +1314,8 @@ private constructor( fun replacesPriceId(): String? = replacesPriceId.getNullable("replaces_price_id") /** + * Configuration for unit pricing + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ @@ -2175,6 +2179,7 @@ private constructor( this.replacesPriceId = replacesPriceId } + /** Configuration for unit pricing */ fun unitConfig(unitConfig: UnitConfig) = unitConfig(JsonField.of(unitConfig)) /** @@ -2838,7 +2843,7 @@ private constructor( "Unit{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, unitConfig=$unitConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" } - class Package + class Tiered private constructor( private val id: JsonField, private val billableMetric: JsonField, @@ -2862,10 +2867,10 @@ private constructor( private val minimumAmount: JsonField, private val modelType: JsonValue, private val name: JsonField, - private val packageConfig: JsonField, private val planPhaseOrder: JsonField, private val priceType: JsonField, private val replacesPriceId: JsonField, + private val tieredConfig: JsonField, private val dimensionalPriceConfiguration: JsonField, private val additionalProperties: MutableMap, ) { @@ -2924,9 +2929,6 @@ private constructor( minimumAmount: JsonField = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("package_config") - @ExcludeMissing - packageConfig: JsonField = JsonMissing.of(), @JsonProperty("plan_phase_order") @ExcludeMissing planPhaseOrder: JsonField = JsonMissing.of(), @@ -2936,6 +2938,9 @@ private constructor( @JsonProperty("replaces_price_id") @ExcludeMissing replacesPriceId: JsonField = JsonMissing.of(), + @JsonProperty("tiered_config") + @ExcludeMissing + tieredConfig: JsonField = JsonMissing.of(), @JsonProperty("dimensional_price_configuration") @ExcludeMissing dimensionalPriceConfiguration: JsonField = @@ -2963,10 +2968,10 @@ private constructor( minimumAmount, modelType, name, - packageConfig, planPhaseOrder, priceType, replacesPriceId, + tieredConfig, dimensionalPriceConfiguration, mutableMapOf(), ) @@ -3102,9 +3107,11 @@ private constructor( fun minimumAmount(): String? = minimumAmount.getNullable("minimum_amount") /** + * The pricing model type + * * Expected to always return the following: * ```kotlin - * JsonValue.from("package") + * JsonValue.from("tiered") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -3118,12 +3125,6 @@ private constructor( */ fun name(): String = name.getRequired("name") - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun packageConfig(): PackageConfig = packageConfig.getRequired("package_config") - /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -3145,6 +3146,14 @@ private constructor( */ fun replacesPriceId(): String? = replacesPriceId.getNullable("replaces_price_id") + /** + * Configuration for tiered pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun tieredConfig(): TieredConfig = tieredConfig.getRequired("tiered_config") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -3347,16 +3356,6 @@ private constructor( */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - /** - * Returns the raw JSON value of [packageConfig]. - * - * Unlike [packageConfig], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("package_config") - @ExcludeMissing - fun _packageConfig(): JsonField = packageConfig - /** * Returns the raw JSON value of [planPhaseOrder]. * @@ -3386,6 +3385,16 @@ private constructor( @ExcludeMissing fun _replacesPriceId(): JsonField = replacesPriceId + /** + * Returns the raw JSON value of [tieredConfig]. + * + * Unlike [tieredConfig], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tiered_config") + @ExcludeMissing + fun _tieredConfig(): JsonField = tieredConfig + /** * Returns the raw JSON value of [dimensionalPriceConfiguration]. * @@ -3412,7 +3421,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [Package]. + * Returns a mutable builder for constructing an instance of [Tiered]. * * The following fields are required: * ```kotlin @@ -3437,16 +3446,16 @@ private constructor( * .minimum() * .minimumAmount() * .name() - * .packageConfig() * .planPhaseOrder() * .priceType() * .replacesPriceId() + * .tieredConfig() * ``` */ fun builder() = Builder() } - /** A builder for [Package]. */ + /** A builder for [Tiered]. */ class Builder internal constructor() { private var id: JsonField? = null @@ -3469,45 +3478,45 @@ private constructor( private var metadata: JsonField? = null private var minimum: JsonField? = null private var minimumAmount: JsonField? = null - private var modelType: JsonValue = JsonValue.from("package") + private var modelType: JsonValue = JsonValue.from("tiered") private var name: JsonField? = null - private var packageConfig: JsonField? = null private var planPhaseOrder: JsonField? = null private var priceType: JsonField? = null private var replacesPriceId: JsonField? = null + private var tieredConfig: JsonField? = null private var dimensionalPriceConfiguration: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(package_: Package) = apply { - id = package_.id - billableMetric = package_.billableMetric - billingCycleConfiguration = package_.billingCycleConfiguration - cadence = package_.cadence - compositePriceFilters = package_.compositePriceFilters.map { it.toMutableList() } - conversionRate = package_.conversionRate - conversionRateConfig = package_.conversionRateConfig - createdAt = package_.createdAt - creditAllocation = package_.creditAllocation - currency = package_.currency - discount = package_.discount - externalPriceId = package_.externalPriceId - fixedPriceQuantity = package_.fixedPriceQuantity - invoicingCycleConfiguration = package_.invoicingCycleConfiguration - item = package_.item - maximum = package_.maximum - maximumAmount = package_.maximumAmount - metadata = package_.metadata - minimum = package_.minimum - minimumAmount = package_.minimumAmount - modelType = package_.modelType - name = package_.name - packageConfig = package_.packageConfig - planPhaseOrder = package_.planPhaseOrder - priceType = package_.priceType - replacesPriceId = package_.replacesPriceId - dimensionalPriceConfiguration = package_.dimensionalPriceConfiguration - additionalProperties = package_.additionalProperties.toMutableMap() + internal fun from(tiered: Tiered) = apply { + id = tiered.id + billableMetric = tiered.billableMetric + billingCycleConfiguration = tiered.billingCycleConfiguration + cadence = tiered.cadence + compositePriceFilters = tiered.compositePriceFilters.map { it.toMutableList() } + conversionRate = tiered.conversionRate + conversionRateConfig = tiered.conversionRateConfig + createdAt = tiered.createdAt + creditAllocation = tiered.creditAllocation + currency = tiered.currency + discount = tiered.discount + externalPriceId = tiered.externalPriceId + fixedPriceQuantity = tiered.fixedPriceQuantity + invoicingCycleConfiguration = tiered.invoicingCycleConfiguration + item = tiered.item + maximum = tiered.maximum + maximumAmount = tiered.maximumAmount + metadata = tiered.metadata + minimum = tiered.minimum + minimumAmount = tiered.minimumAmount + modelType = tiered.modelType + name = tiered.name + planPhaseOrder = tiered.planPhaseOrder + priceType = tiered.priceType + replacesPriceId = tiered.replacesPriceId + tieredConfig = tiered.tieredConfig + dimensionalPriceConfiguration = tiered.dimensionalPriceConfiguration + additionalProperties = tiered.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) @@ -3935,7 +3944,7 @@ private constructor( * It is usually unnecessary to call this method because the field defaults to the * following: * ```kotlin - * JsonValue.from("package") + * JsonValue.from("tiered") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -3954,20 +3963,6 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } - fun packageConfig(packageConfig: PackageConfig) = - packageConfig(JsonField.of(packageConfig)) - - /** - * Sets [Builder.packageConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.packageConfig] with a well-typed [PackageConfig] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun packageConfig(packageConfig: JsonField) = apply { - this.packageConfig = packageConfig - } - fun planPhaseOrder(planPhaseOrder: Long?) = planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) @@ -4018,6 +4013,20 @@ private constructor( this.replacesPriceId = replacesPriceId } + /** Configuration for tiered pricing */ + fun tieredConfig(tieredConfig: TieredConfig) = tieredConfig(JsonField.of(tieredConfig)) + + /** + * Sets [Builder.tieredConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.tieredConfig] with a well-typed [TieredConfig] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun tieredConfig(tieredConfig: JsonField) = apply { + this.tieredConfig = tieredConfig + } + fun dimensionalPriceConfiguration( dimensionalPriceConfiguration: DimensionalPriceConfiguration? ) = dimensionalPriceConfiguration(JsonField.ofNullable(dimensionalPriceConfiguration)) @@ -4053,7 +4062,7 @@ private constructor( } /** - * Returns an immutable instance of [Package]. + * Returns an immutable instance of [Tiered]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -4080,16 +4089,16 @@ private constructor( * .minimum() * .minimumAmount() * .name() - * .packageConfig() * .planPhaseOrder() * .priceType() * .replacesPriceId() + * .tieredConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): Package = - Package( + fun build(): Tiered = + Tiered( checkRequired("id", id), checkRequired("billableMetric", billableMetric), checkRequired("billingCycleConfiguration", billingCycleConfiguration), @@ -4114,10 +4123,10 @@ private constructor( checkRequired("minimumAmount", minimumAmount), modelType, checkRequired("name", name), - checkRequired("packageConfig", packageConfig), checkRequired("planPhaseOrder", planPhaseOrder), checkRequired("priceType", priceType), checkRequired("replacesPriceId", replacesPriceId), + checkRequired("tieredConfig", tieredConfig), dimensionalPriceConfiguration, additionalProperties.toMutableMap(), ) @@ -4125,7 +4134,7 @@ private constructor( private var validated: Boolean = false - fun validate(): Package = apply { + fun validate(): Tiered = apply { if (validated) { return@apply } @@ -4151,15 +4160,15 @@ private constructor( minimum()?.validate() minimumAmount() _modelType().let { - if (it != JsonValue.from("package")) { + if (it != JsonValue.from("tiered")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } name() - packageConfig().validate() planPhaseOrder() priceType().validate() replacesPriceId() + tieredConfig().validate() dimensionalPriceConfiguration()?.validate() validated = true } @@ -4199,12 +4208,12 @@ private constructor( (metadata.asKnown()?.validity() ?: 0) + (minimum.asKnown()?.validity() ?: 0) + (if (minimumAmount.asKnown() == null) 0 else 1) + - modelType.let { if (it == JsonValue.from("package")) 1 else 0 } + + modelType.let { if (it == JsonValue.from("tiered")) 1 else 0 } + (if (name.asKnown() == null) 0 else 1) + - (packageConfig.asKnown()?.validity() ?: 0) + (if (planPhaseOrder.asKnown() == null) 0 else 1) + (priceType.asKnown()?.validity() ?: 0) + (if (replacesPriceId.asKnown() == null) 0 else 1) + + (tieredConfig.asKnown()?.validity() ?: 0) + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) class Cadence @JsonCreator private constructor(private val value: JsonField) : @@ -4598,7 +4607,7 @@ private constructor( return true } - return other is Package && + return other is Tiered && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && @@ -4621,10 +4630,10 @@ private constructor( minimumAmount == other.minimumAmount && modelType == other.modelType && name == other.name && - packageConfig == other.packageConfig && planPhaseOrder == other.planPhaseOrder && priceType == other.priceType && replacesPriceId == other.replacesPriceId && + tieredConfig == other.tieredConfig && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties } @@ -4653,10 +4662,10 @@ private constructor( minimumAmount, modelType, name, - packageConfig, planPhaseOrder, priceType, replacesPriceId, + tieredConfig, dimensionalPriceConfiguration, additionalProperties, ) @@ -4665,14 +4674,15 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Package{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, packageConfig=$packageConfig, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "Tiered{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, tieredConfig=$tieredConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" } - class Matrix + class Bulk private constructor( private val id: JsonField, private val billableMetric: JsonField, private val billingCycleConfiguration: JsonField, + private val bulkConfig: JsonField, private val cadence: JsonField, private val compositePriceFilters: JsonField>, private val conversionRate: JsonField, @@ -4685,7 +4695,6 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoicingCycleConfiguration: JsonField, private val item: JsonField, - private val matrixConfig: JsonField, private val maximum: JsonField, private val maximumAmount: JsonField, private val metadata: JsonField, @@ -4709,6 +4718,9 @@ private constructor( @JsonProperty("billing_cycle_configuration") @ExcludeMissing billingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("bulk_config") + @ExcludeMissing + bulkConfig: JsonField = JsonMissing.of(), @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), @JsonProperty("composite_price_filters") @ExcludeMissing @@ -4741,9 +4753,6 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), @JsonProperty("item") @ExcludeMissing item: JsonField = JsonMissing.of(), - @JsonProperty("matrix_config") - @ExcludeMissing - matrixConfig: JsonField = JsonMissing.of(), @JsonProperty("maximum") @ExcludeMissing maximum: JsonField = JsonMissing.of(), @JsonProperty("maximum_amount") @ExcludeMissing @@ -4774,6 +4783,7 @@ private constructor( id, billableMetric, billingCycleConfiguration, + bulkConfig, cadence, compositePriceFilters, conversionRate, @@ -4786,7 +4796,6 @@ private constructor( fixedPriceQuantity, invoicingCycleConfiguration, item, - matrixConfig, maximum, maximumAmount, metadata, @@ -4820,6 +4829,14 @@ private constructor( fun billingCycleConfiguration(): BillingCycleConfiguration = billingCycleConfiguration.getRequired("billing_cycle_configuration") + /** + * Configuration for bulk pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun bulkConfig(): BulkConfig = bulkConfig.getRequired("bulk_config") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). @@ -4895,12 +4912,6 @@ private constructor( */ fun item(): ItemSlim = item.getRequired("item") - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun matrixConfig(): MatrixConfig = matrixConfig.getRequired("matrix_config") - /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -4938,9 +4949,11 @@ private constructor( fun minimumAmount(): String? = minimumAmount.getNullable("minimum_amount") /** + * The pricing model type + * * Expected to always return the following: * ```kotlin - * JsonValue.from("matrix") + * JsonValue.from("bulk") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -5010,6 +5023,15 @@ private constructor( fun _billingCycleConfiguration(): JsonField = billingCycleConfiguration + /** + * Returns the raw JSON value of [bulkConfig]. + * + * Unlike [bulkConfig], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("bulk_config") + @ExcludeMissing + fun _bulkConfig(): JsonField = bulkConfig + /** * Returns the raw JSON value of [cadence]. * @@ -5121,16 +5143,6 @@ private constructor( */ @JsonProperty("item") @ExcludeMissing fun _item(): JsonField = item - /** - * Returns the raw JSON value of [matrixConfig]. - * - * Unlike [matrixConfig], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("matrix_config") - @ExcludeMissing - fun _matrixConfig(): JsonField = matrixConfig - /** * Returns the raw JSON value of [maximum]. * @@ -5242,13 +5254,14 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [Matrix]. + * Returns a mutable builder for constructing an instance of [Bulk]. * * The following fields are required: * ```kotlin * .id() * .billableMetric() * .billingCycleConfiguration() + * .bulkConfig() * .cadence() * .compositePriceFilters() * .conversionRate() @@ -5261,7 +5274,6 @@ private constructor( * .fixedPriceQuantity() * .invoicingCycleConfiguration() * .item() - * .matrixConfig() * .maximum() * .maximumAmount() * .metadata() @@ -5276,12 +5288,13 @@ private constructor( fun builder() = Builder() } - /** A builder for [Matrix]. */ + /** A builder for [Bulk]. */ class Builder internal constructor() { private var id: JsonField? = null private var billableMetric: JsonField? = null private var billingCycleConfiguration: JsonField? = null + private var bulkConfig: JsonField? = null private var cadence: JsonField? = null private var compositePriceFilters: JsonField>? = null private var conversionRate: JsonField? = null @@ -5294,13 +5307,12 @@ private constructor( private var fixedPriceQuantity: JsonField? = null private var invoicingCycleConfiguration: JsonField? = null private var item: JsonField? = null - private var matrixConfig: JsonField? = null private var maximum: JsonField? = null private var maximumAmount: JsonField? = null private var metadata: JsonField? = null private var minimum: JsonField? = null private var minimumAmount: JsonField? = null - private var modelType: JsonValue = JsonValue.from("matrix") + private var modelType: JsonValue = JsonValue.from("bulk") private var name: JsonField? = null private var planPhaseOrder: JsonField? = null private var priceType: JsonField? = null @@ -5309,35 +5321,35 @@ private constructor( JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(matrix: Matrix) = apply { - id = matrix.id - billableMetric = matrix.billableMetric - billingCycleConfiguration = matrix.billingCycleConfiguration - cadence = matrix.cadence - compositePriceFilters = matrix.compositePriceFilters.map { it.toMutableList() } - conversionRate = matrix.conversionRate - conversionRateConfig = matrix.conversionRateConfig - createdAt = matrix.createdAt - creditAllocation = matrix.creditAllocation - currency = matrix.currency - discount = matrix.discount - externalPriceId = matrix.externalPriceId - fixedPriceQuantity = matrix.fixedPriceQuantity - invoicingCycleConfiguration = matrix.invoicingCycleConfiguration - item = matrix.item - matrixConfig = matrix.matrixConfig - maximum = matrix.maximum - maximumAmount = matrix.maximumAmount - metadata = matrix.metadata - minimum = matrix.minimum - minimumAmount = matrix.minimumAmount - modelType = matrix.modelType - name = matrix.name - planPhaseOrder = matrix.planPhaseOrder - priceType = matrix.priceType - replacesPriceId = matrix.replacesPriceId - dimensionalPriceConfiguration = matrix.dimensionalPriceConfiguration - additionalProperties = matrix.additionalProperties.toMutableMap() + internal fun from(bulk: Bulk) = apply { + id = bulk.id + billableMetric = bulk.billableMetric + billingCycleConfiguration = bulk.billingCycleConfiguration + bulkConfig = bulk.bulkConfig + cadence = bulk.cadence + compositePriceFilters = bulk.compositePriceFilters.map { it.toMutableList() } + conversionRate = bulk.conversionRate + conversionRateConfig = bulk.conversionRateConfig + createdAt = bulk.createdAt + creditAllocation = bulk.creditAllocation + currency = bulk.currency + discount = bulk.discount + externalPriceId = bulk.externalPriceId + fixedPriceQuantity = bulk.fixedPriceQuantity + invoicingCycleConfiguration = bulk.invoicingCycleConfiguration + item = bulk.item + maximum = bulk.maximum + maximumAmount = bulk.maximumAmount + metadata = bulk.metadata + minimum = bulk.minimum + minimumAmount = bulk.minimumAmount + modelType = bulk.modelType + name = bulk.name + planPhaseOrder = bulk.planPhaseOrder + priceType = bulk.priceType + replacesPriceId = bulk.replacesPriceId + dimensionalPriceConfiguration = bulk.dimensionalPriceConfiguration + additionalProperties = bulk.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) @@ -5379,6 +5391,20 @@ private constructor( billingCycleConfiguration: JsonField ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + /** Configuration for bulk pricing */ + fun bulkConfig(bulkConfig: BulkConfig) = bulkConfig(JsonField.of(bulkConfig)) + + /** + * Sets [Builder.bulkConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.bulkConfig] with a well-typed [BulkConfig] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun bulkConfig(bulkConfig: JsonField) = apply { + this.bulkConfig = bulkConfig + } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) /** @@ -5685,19 +5711,6 @@ private constructor( */ fun item(item: JsonField) = apply { this.item = item } - fun matrixConfig(matrixConfig: MatrixConfig) = matrixConfig(JsonField.of(matrixConfig)) - - /** - * Sets [Builder.matrixConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.matrixConfig] with a well-typed [MatrixConfig] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun matrixConfig(matrixConfig: JsonField) = apply { - this.matrixConfig = matrixConfig - } - @Deprecated("deprecated") fun maximum(maximum: Maximum?) = maximum(JsonField.ofNullable(maximum)) @@ -5778,7 +5791,7 @@ private constructor( * It is usually unnecessary to call this method because the field defaults to the * following: * ```kotlin - * JsonValue.from("matrix") + * JsonValue.from("bulk") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -5882,7 +5895,7 @@ private constructor( } /** - * Returns an immutable instance of [Matrix]. + * Returns an immutable instance of [Bulk]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -5891,6 +5904,7 @@ private constructor( * .id() * .billableMetric() * .billingCycleConfiguration() + * .bulkConfig() * .cadence() * .compositePriceFilters() * .conversionRate() @@ -5903,7 +5917,6 @@ private constructor( * .fixedPriceQuantity() * .invoicingCycleConfiguration() * .item() - * .matrixConfig() * .maximum() * .maximumAmount() * .metadata() @@ -5917,11 +5930,12 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): Matrix = - Matrix( + fun build(): Bulk = + Bulk( checkRequired("id", id), checkRequired("billableMetric", billableMetric), checkRequired("billingCycleConfiguration", billingCycleConfiguration), + checkRequired("bulkConfig", bulkConfig), checkRequired("cadence", cadence), checkRequired("compositePriceFilters", compositePriceFilters).map { it.toImmutable() @@ -5936,7 +5950,6 @@ private constructor( checkRequired("fixedPriceQuantity", fixedPriceQuantity), checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), checkRequired("item", item), - checkRequired("matrixConfig", matrixConfig), checkRequired("maximum", maximum), checkRequired("maximumAmount", maximumAmount), checkRequired("metadata", metadata), @@ -5954,7 +5967,7 @@ private constructor( private var validated: Boolean = false - fun validate(): Matrix = apply { + fun validate(): Bulk = apply { if (validated) { return@apply } @@ -5962,6 +5975,7 @@ private constructor( id() billableMetric()?.validate() billingCycleConfiguration().validate() + bulkConfig().validate() cadence().validate() compositePriceFilters()?.forEach { it.validate() } conversionRate() @@ -5974,14 +5988,13 @@ private constructor( fixedPriceQuantity() invoicingCycleConfiguration()?.validate() item().validate() - matrixConfig().validate() maximum()?.validate() maximumAmount() metadata().validate() minimum()?.validate() minimumAmount() _modelType().let { - if (it != JsonValue.from("matrix")) { + if (it != JsonValue.from("bulk")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } @@ -6011,6 +6024,7 @@ private constructor( (if (id.asKnown() == null) 0 else 1) + (billableMetric.asKnown()?.validity() ?: 0) + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (bulkConfig.asKnown()?.validity() ?: 0) + (cadence.asKnown()?.validity() ?: 0) + (compositePriceFilters.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + (if (conversionRate.asKnown() == null) 0 else 1) + @@ -6023,13 +6037,12 @@ private constructor( (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + (item.asKnown()?.validity() ?: 0) + - (matrixConfig.asKnown()?.validity() ?: 0) + (maximum.asKnown()?.validity() ?: 0) + (if (maximumAmount.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) + (minimum.asKnown()?.validity() ?: 0) + (if (minimumAmount.asKnown() == null) 0 else 1) + - modelType.let { if (it == JsonValue.from("matrix")) 1 else 0 } + + modelType.let { if (it == JsonValue.from("bulk")) 1 else 0 } + (if (name.asKnown() == null) 0 else 1) + (if (planPhaseOrder.asKnown() == null) 0 else 1) + (priceType.asKnown()?.validity() ?: 0) + @@ -6427,10 +6440,11 @@ private constructor( return true } - return other is Matrix && + return other is Bulk && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && + bulkConfig == other.bulkConfig && cadence == other.cadence && compositePriceFilters == other.compositePriceFilters && conversionRate == other.conversionRate && @@ -6443,7 +6457,6 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && - matrixConfig == other.matrixConfig && maximum == other.maximum && maximumAmount == other.maximumAmount && metadata == other.metadata && @@ -6463,6 +6476,7 @@ private constructor( id, billableMetric, billingCycleConfiguration, + bulkConfig, cadence, compositePriceFilters, conversionRate, @@ -6475,7 +6489,6 @@ private constructor( fixedPriceQuantity, invoicingCycleConfiguration, item, - matrixConfig, maximum, maximumAmount, metadata, @@ -6494,10 +6507,10 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Matrix{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, matrixConfig=$matrixConfig, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "Bulk{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, bulkConfig=$bulkConfig, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" } - class Tiered + class Package private constructor( private val id: JsonField, private val billableMetric: JsonField, @@ -6521,10 +6534,10 @@ private constructor( private val minimumAmount: JsonField, private val modelType: JsonValue, private val name: JsonField, + private val packageConfig: JsonField, private val planPhaseOrder: JsonField, private val priceType: JsonField, private val replacesPriceId: JsonField, - private val tieredConfig: JsonField, private val dimensionalPriceConfiguration: JsonField, private val additionalProperties: MutableMap, ) { @@ -6583,6 +6596,9 @@ private constructor( minimumAmount: JsonField = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("package_config") + @ExcludeMissing + packageConfig: JsonField = JsonMissing.of(), @JsonProperty("plan_phase_order") @ExcludeMissing planPhaseOrder: JsonField = JsonMissing.of(), @@ -6592,9 +6608,6 @@ private constructor( @JsonProperty("replaces_price_id") @ExcludeMissing replacesPriceId: JsonField = JsonMissing.of(), - @JsonProperty("tiered_config") - @ExcludeMissing - tieredConfig: JsonField = JsonMissing.of(), @JsonProperty("dimensional_price_configuration") @ExcludeMissing dimensionalPriceConfiguration: JsonField = @@ -6622,10 +6635,10 @@ private constructor( minimumAmount, modelType, name, + packageConfig, planPhaseOrder, priceType, replacesPriceId, - tieredConfig, dimensionalPriceConfiguration, mutableMapOf(), ) @@ -6761,9 +6774,11 @@ private constructor( fun minimumAmount(): String? = minimumAmount.getNullable("minimum_amount") /** + * The pricing model type + * * Expected to always return the following: * ```kotlin - * JsonValue.from("tiered") + * JsonValue.from("package") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -6777,6 +6792,14 @@ private constructor( */ fun name(): String = name.getRequired("name") + /** + * Configuration for package pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun packageConfig(): PackageConfig = packageConfig.getRequired("package_config") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -6798,12 +6821,6 @@ private constructor( */ fun replacesPriceId(): String? = replacesPriceId.getNullable("replaces_price_id") - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun tieredConfig(): TieredConfig = tieredConfig.getRequired("tiered_config") - /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -7006,6 +7023,16 @@ private constructor( */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + /** + * Returns the raw JSON value of [packageConfig]. + * + * Unlike [packageConfig], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("package_config") + @ExcludeMissing + fun _packageConfig(): JsonField = packageConfig + /** * Returns the raw JSON value of [planPhaseOrder]. * @@ -7035,16 +7062,6 @@ private constructor( @ExcludeMissing fun _replacesPriceId(): JsonField = replacesPriceId - /** - * Returns the raw JSON value of [tieredConfig]. - * - * Unlike [tieredConfig], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("tiered_config") - @ExcludeMissing - fun _tieredConfig(): JsonField = tieredConfig - /** * Returns the raw JSON value of [dimensionalPriceConfiguration]. * @@ -7071,7 +7088,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [Tiered]. + * Returns a mutable builder for constructing an instance of [Package]. * * The following fields are required: * ```kotlin @@ -7096,16 +7113,16 @@ private constructor( * .minimum() * .minimumAmount() * .name() + * .packageConfig() * .planPhaseOrder() * .priceType() * .replacesPriceId() - * .tieredConfig() * ``` */ fun builder() = Builder() } - /** A builder for [Tiered]. */ + /** A builder for [Package]. */ class Builder internal constructor() { private var id: JsonField? = null @@ -7128,45 +7145,45 @@ private constructor( private var metadata: JsonField? = null private var minimum: JsonField? = null private var minimumAmount: JsonField? = null - private var modelType: JsonValue = JsonValue.from("tiered") + private var modelType: JsonValue = JsonValue.from("package") private var name: JsonField? = null + private var packageConfig: JsonField? = null private var planPhaseOrder: JsonField? = null private var priceType: JsonField? = null private var replacesPriceId: JsonField? = null - private var tieredConfig: JsonField? = null private var dimensionalPriceConfiguration: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(tiered: Tiered) = apply { - id = tiered.id - billableMetric = tiered.billableMetric - billingCycleConfiguration = tiered.billingCycleConfiguration - cadence = tiered.cadence - compositePriceFilters = tiered.compositePriceFilters.map { it.toMutableList() } - conversionRate = tiered.conversionRate - conversionRateConfig = tiered.conversionRateConfig - createdAt = tiered.createdAt - creditAllocation = tiered.creditAllocation - currency = tiered.currency - discount = tiered.discount - externalPriceId = tiered.externalPriceId - fixedPriceQuantity = tiered.fixedPriceQuantity - invoicingCycleConfiguration = tiered.invoicingCycleConfiguration - item = tiered.item - maximum = tiered.maximum - maximumAmount = tiered.maximumAmount - metadata = tiered.metadata - minimum = tiered.minimum - minimumAmount = tiered.minimumAmount - modelType = tiered.modelType - name = tiered.name - planPhaseOrder = tiered.planPhaseOrder - priceType = tiered.priceType - replacesPriceId = tiered.replacesPriceId - tieredConfig = tiered.tieredConfig - dimensionalPriceConfiguration = tiered.dimensionalPriceConfiguration - additionalProperties = tiered.additionalProperties.toMutableMap() + internal fun from(package_: Package) = apply { + id = package_.id + billableMetric = package_.billableMetric + billingCycleConfiguration = package_.billingCycleConfiguration + cadence = package_.cadence + compositePriceFilters = package_.compositePriceFilters.map { it.toMutableList() } + conversionRate = package_.conversionRate + conversionRateConfig = package_.conversionRateConfig + createdAt = package_.createdAt + creditAllocation = package_.creditAllocation + currency = package_.currency + discount = package_.discount + externalPriceId = package_.externalPriceId + fixedPriceQuantity = package_.fixedPriceQuantity + invoicingCycleConfiguration = package_.invoicingCycleConfiguration + item = package_.item + maximum = package_.maximum + maximumAmount = package_.maximumAmount + metadata = package_.metadata + minimum = package_.minimum + minimumAmount = package_.minimumAmount + modelType = package_.modelType + name = package_.name + packageConfig = package_.packageConfig + planPhaseOrder = package_.planPhaseOrder + priceType = package_.priceType + replacesPriceId = package_.replacesPriceId + dimensionalPriceConfiguration = package_.dimensionalPriceConfiguration + additionalProperties = package_.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) @@ -7594,7 +7611,7 @@ private constructor( * It is usually unnecessary to call this method because the field defaults to the * following: * ```kotlin - * JsonValue.from("tiered") + * JsonValue.from("package") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -7613,6 +7630,21 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } + /** Configuration for package pricing */ + fun packageConfig(packageConfig: PackageConfig) = + packageConfig(JsonField.of(packageConfig)) + + /** + * Sets [Builder.packageConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.packageConfig] with a well-typed [PackageConfig] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun packageConfig(packageConfig: JsonField) = apply { + this.packageConfig = packageConfig + } + fun planPhaseOrder(planPhaseOrder: Long?) = planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) @@ -7663,19 +7695,6 @@ private constructor( this.replacesPriceId = replacesPriceId } - fun tieredConfig(tieredConfig: TieredConfig) = tieredConfig(JsonField.of(tieredConfig)) - - /** - * Sets [Builder.tieredConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.tieredConfig] with a well-typed [TieredConfig] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun tieredConfig(tieredConfig: JsonField) = apply { - this.tieredConfig = tieredConfig - } - fun dimensionalPriceConfiguration( dimensionalPriceConfiguration: DimensionalPriceConfiguration? ) = dimensionalPriceConfiguration(JsonField.ofNullable(dimensionalPriceConfiguration)) @@ -7711,7 +7730,7 @@ private constructor( } /** - * Returns an immutable instance of [Tiered]. + * Returns an immutable instance of [Package]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -7738,16 +7757,16 @@ private constructor( * .minimum() * .minimumAmount() * .name() + * .packageConfig() * .planPhaseOrder() * .priceType() * .replacesPriceId() - * .tieredConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): Tiered = - Tiered( + fun build(): Package = + Package( checkRequired("id", id), checkRequired("billableMetric", billableMetric), checkRequired("billingCycleConfiguration", billingCycleConfiguration), @@ -7772,10 +7791,10 @@ private constructor( checkRequired("minimumAmount", minimumAmount), modelType, checkRequired("name", name), + checkRequired("packageConfig", packageConfig), checkRequired("planPhaseOrder", planPhaseOrder), checkRequired("priceType", priceType), checkRequired("replacesPriceId", replacesPriceId), - checkRequired("tieredConfig", tieredConfig), dimensionalPriceConfiguration, additionalProperties.toMutableMap(), ) @@ -7783,7 +7802,7 @@ private constructor( private var validated: Boolean = false - fun validate(): Tiered = apply { + fun validate(): Package = apply { if (validated) { return@apply } @@ -7809,15 +7828,15 @@ private constructor( minimum()?.validate() minimumAmount() _modelType().let { - if (it != JsonValue.from("tiered")) { + if (it != JsonValue.from("package")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } name() + packageConfig().validate() planPhaseOrder() priceType().validate() replacesPriceId() - tieredConfig().validate() dimensionalPriceConfiguration()?.validate() validated = true } @@ -7857,12 +7876,12 @@ private constructor( (metadata.asKnown()?.validity() ?: 0) + (minimum.asKnown()?.validity() ?: 0) + (if (minimumAmount.asKnown() == null) 0 else 1) + - modelType.let { if (it == JsonValue.from("tiered")) 1 else 0 } + + modelType.let { if (it == JsonValue.from("package")) 1 else 0 } + (if (name.asKnown() == null) 0 else 1) + + (packageConfig.asKnown()?.validity() ?: 0) + (if (planPhaseOrder.asKnown() == null) 0 else 1) + (priceType.asKnown()?.validity() ?: 0) + (if (replacesPriceId.asKnown() == null) 0 else 1) + - (tieredConfig.asKnown()?.validity() ?: 0) + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) class Cadence @JsonCreator private constructor(private val value: JsonField) : @@ -8256,7 +8275,7 @@ private constructor( return true } - return other is Tiered && + return other is Package && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && @@ -8279,10 +8298,10 @@ private constructor( minimumAmount == other.minimumAmount && modelType == other.modelType && name == other.name && + packageConfig == other.packageConfig && planPhaseOrder == other.planPhaseOrder && priceType == other.priceType && replacesPriceId == other.replacesPriceId && - tieredConfig == other.tieredConfig && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties } @@ -8311,10 +8330,10 @@ private constructor( minimumAmount, modelType, name, + packageConfig, planPhaseOrder, priceType, replacesPriceId, - tieredConfig, dimensionalPriceConfiguration, additionalProperties, ) @@ -8323,15 +8342,14 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Tiered{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, tieredConfig=$tieredConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "Package{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, packageConfig=$packageConfig, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" } - class Bulk + class Matrix private constructor( private val id: JsonField, private val billableMetric: JsonField, private val billingCycleConfiguration: JsonField, - private val bulkConfig: JsonField, private val cadence: JsonField, private val compositePriceFilters: JsonField>, private val conversionRate: JsonField, @@ -8344,6 +8362,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoicingCycleConfiguration: JsonField, private val item: JsonField, + private val matrixConfig: JsonField, private val maximum: JsonField, private val maximumAmount: JsonField, private val metadata: JsonField, @@ -8367,9 +8386,6 @@ private constructor( @JsonProperty("billing_cycle_configuration") @ExcludeMissing billingCycleConfiguration: JsonField = JsonMissing.of(), - @JsonProperty("bulk_config") - @ExcludeMissing - bulkConfig: JsonField = JsonMissing.of(), @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), @JsonProperty("composite_price_filters") @ExcludeMissing @@ -8402,6 +8418,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), @JsonProperty("item") @ExcludeMissing item: JsonField = JsonMissing.of(), + @JsonProperty("matrix_config") + @ExcludeMissing + matrixConfig: JsonField = JsonMissing.of(), @JsonProperty("maximum") @ExcludeMissing maximum: JsonField = JsonMissing.of(), @JsonProperty("maximum_amount") @ExcludeMissing @@ -8432,7 +8451,6 @@ private constructor( id, billableMetric, billingCycleConfiguration, - bulkConfig, cadence, compositePriceFilters, conversionRate, @@ -8445,6 +8463,7 @@ private constructor( fixedPriceQuantity, invoicingCycleConfiguration, item, + matrixConfig, maximum, maximumAmount, metadata, @@ -8478,12 +8497,6 @@ private constructor( fun billingCycleConfiguration(): BillingCycleConfiguration = billingCycleConfiguration.getRequired("billing_cycle_configuration") - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun bulkConfig(): BulkConfig = bulkConfig.getRequired("bulk_config") - /** * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). @@ -8559,6 +8572,14 @@ private constructor( */ fun item(): ItemSlim = item.getRequired("item") + /** + * Configuration for matrix pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun matrixConfig(): MatrixConfig = matrixConfig.getRequired("matrix_config") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -8596,9 +8617,11 @@ private constructor( fun minimumAmount(): String? = minimumAmount.getNullable("minimum_amount") /** + * The pricing model type + * * Expected to always return the following: * ```kotlin - * JsonValue.from("bulk") + * JsonValue.from("matrix") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -8668,15 +8691,6 @@ private constructor( fun _billingCycleConfiguration(): JsonField = billingCycleConfiguration - /** - * Returns the raw JSON value of [bulkConfig]. - * - * Unlike [bulkConfig], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("bulk_config") - @ExcludeMissing - fun _bulkConfig(): JsonField = bulkConfig - /** * Returns the raw JSON value of [cadence]. * @@ -8788,6 +8802,16 @@ private constructor( */ @JsonProperty("item") @ExcludeMissing fun _item(): JsonField = item + /** + * Returns the raw JSON value of [matrixConfig]. + * + * Unlike [matrixConfig], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("matrix_config") + @ExcludeMissing + fun _matrixConfig(): JsonField = matrixConfig + /** * Returns the raw JSON value of [maximum]. * @@ -8899,14 +8923,13 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [Bulk]. + * Returns a mutable builder for constructing an instance of [Matrix]. * * The following fields are required: * ```kotlin * .id() * .billableMetric() * .billingCycleConfiguration() - * .bulkConfig() * .cadence() * .compositePriceFilters() * .conversionRate() @@ -8919,6 +8942,7 @@ private constructor( * .fixedPriceQuantity() * .invoicingCycleConfiguration() * .item() + * .matrixConfig() * .maximum() * .maximumAmount() * .metadata() @@ -8933,13 +8957,12 @@ private constructor( fun builder() = Builder() } - /** A builder for [Bulk]. */ + /** A builder for [Matrix]. */ class Builder internal constructor() { private var id: JsonField? = null private var billableMetric: JsonField? = null private var billingCycleConfiguration: JsonField? = null - private var bulkConfig: JsonField? = null private var cadence: JsonField? = null private var compositePriceFilters: JsonField>? = null private var conversionRate: JsonField? = null @@ -8952,12 +8975,13 @@ private constructor( private var fixedPriceQuantity: JsonField? = null private var invoicingCycleConfiguration: JsonField? = null private var item: JsonField? = null + private var matrixConfig: JsonField? = null private var maximum: JsonField? = null private var maximumAmount: JsonField? = null private var metadata: JsonField? = null private var minimum: JsonField? = null private var minimumAmount: JsonField? = null - private var modelType: JsonValue = JsonValue.from("bulk") + private var modelType: JsonValue = JsonValue.from("matrix") private var name: JsonField? = null private var planPhaseOrder: JsonField? = null private var priceType: JsonField? = null @@ -8966,35 +8990,35 @@ private constructor( JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(bulk: Bulk) = apply { - id = bulk.id - billableMetric = bulk.billableMetric - billingCycleConfiguration = bulk.billingCycleConfiguration - bulkConfig = bulk.bulkConfig - cadence = bulk.cadence - compositePriceFilters = bulk.compositePriceFilters.map { it.toMutableList() } - conversionRate = bulk.conversionRate - conversionRateConfig = bulk.conversionRateConfig - createdAt = bulk.createdAt - creditAllocation = bulk.creditAllocation - currency = bulk.currency - discount = bulk.discount - externalPriceId = bulk.externalPriceId - fixedPriceQuantity = bulk.fixedPriceQuantity - invoicingCycleConfiguration = bulk.invoicingCycleConfiguration - item = bulk.item - maximum = bulk.maximum - maximumAmount = bulk.maximumAmount - metadata = bulk.metadata - minimum = bulk.minimum - minimumAmount = bulk.minimumAmount - modelType = bulk.modelType - name = bulk.name - planPhaseOrder = bulk.planPhaseOrder - priceType = bulk.priceType - replacesPriceId = bulk.replacesPriceId - dimensionalPriceConfiguration = bulk.dimensionalPriceConfiguration - additionalProperties = bulk.additionalProperties.toMutableMap() + internal fun from(matrix: Matrix) = apply { + id = matrix.id + billableMetric = matrix.billableMetric + billingCycleConfiguration = matrix.billingCycleConfiguration + cadence = matrix.cadence + compositePriceFilters = matrix.compositePriceFilters.map { it.toMutableList() } + conversionRate = matrix.conversionRate + conversionRateConfig = matrix.conversionRateConfig + createdAt = matrix.createdAt + creditAllocation = matrix.creditAllocation + currency = matrix.currency + discount = matrix.discount + externalPriceId = matrix.externalPriceId + fixedPriceQuantity = matrix.fixedPriceQuantity + invoicingCycleConfiguration = matrix.invoicingCycleConfiguration + item = matrix.item + matrixConfig = matrix.matrixConfig + maximum = matrix.maximum + maximumAmount = matrix.maximumAmount + metadata = matrix.metadata + minimum = matrix.minimum + minimumAmount = matrix.minimumAmount + modelType = matrix.modelType + name = matrix.name + planPhaseOrder = matrix.planPhaseOrder + priceType = matrix.priceType + replacesPriceId = matrix.replacesPriceId + dimensionalPriceConfiguration = matrix.dimensionalPriceConfiguration + additionalProperties = matrix.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) @@ -9036,19 +9060,6 @@ private constructor( billingCycleConfiguration: JsonField ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } - fun bulkConfig(bulkConfig: BulkConfig) = bulkConfig(JsonField.of(bulkConfig)) - - /** - * Sets [Builder.bulkConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.bulkConfig] with a well-typed [BulkConfig] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun bulkConfig(bulkConfig: JsonField) = apply { - this.bulkConfig = bulkConfig - } - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) /** @@ -9355,6 +9366,20 @@ private constructor( */ fun item(item: JsonField) = apply { this.item = item } + /** Configuration for matrix pricing */ + fun matrixConfig(matrixConfig: MatrixConfig) = matrixConfig(JsonField.of(matrixConfig)) + + /** + * Sets [Builder.matrixConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.matrixConfig] with a well-typed [MatrixConfig] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun matrixConfig(matrixConfig: JsonField) = apply { + this.matrixConfig = matrixConfig + } + @Deprecated("deprecated") fun maximum(maximum: Maximum?) = maximum(JsonField.ofNullable(maximum)) @@ -9435,7 +9460,7 @@ private constructor( * It is usually unnecessary to call this method because the field defaults to the * following: * ```kotlin - * JsonValue.from("bulk") + * JsonValue.from("matrix") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -9539,7 +9564,7 @@ private constructor( } /** - * Returns an immutable instance of [Bulk]. + * Returns an immutable instance of [Matrix]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -9548,7 +9573,6 @@ private constructor( * .id() * .billableMetric() * .billingCycleConfiguration() - * .bulkConfig() * .cadence() * .compositePriceFilters() * .conversionRate() @@ -9561,6 +9585,7 @@ private constructor( * .fixedPriceQuantity() * .invoicingCycleConfiguration() * .item() + * .matrixConfig() * .maximum() * .maximumAmount() * .metadata() @@ -9574,12 +9599,11 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): Bulk = - Bulk( + fun build(): Matrix = + Matrix( checkRequired("id", id), checkRequired("billableMetric", billableMetric), checkRequired("billingCycleConfiguration", billingCycleConfiguration), - checkRequired("bulkConfig", bulkConfig), checkRequired("cadence", cadence), checkRequired("compositePriceFilters", compositePriceFilters).map { it.toImmutable() @@ -9594,6 +9618,7 @@ private constructor( checkRequired("fixedPriceQuantity", fixedPriceQuantity), checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), checkRequired("item", item), + checkRequired("matrixConfig", matrixConfig), checkRequired("maximum", maximum), checkRequired("maximumAmount", maximumAmount), checkRequired("metadata", metadata), @@ -9611,7 +9636,7 @@ private constructor( private var validated: Boolean = false - fun validate(): Bulk = apply { + fun validate(): Matrix = apply { if (validated) { return@apply } @@ -9619,7 +9644,6 @@ private constructor( id() billableMetric()?.validate() billingCycleConfiguration().validate() - bulkConfig().validate() cadence().validate() compositePriceFilters()?.forEach { it.validate() } conversionRate() @@ -9632,13 +9656,14 @@ private constructor( fixedPriceQuantity() invoicingCycleConfiguration()?.validate() item().validate() + matrixConfig().validate() maximum()?.validate() maximumAmount() metadata().validate() minimum()?.validate() minimumAmount() _modelType().let { - if (it != JsonValue.from("bulk")) { + if (it != JsonValue.from("matrix")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } @@ -9668,7 +9693,6 @@ private constructor( (if (id.asKnown() == null) 0 else 1) + (billableMetric.asKnown()?.validity() ?: 0) + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + - (bulkConfig.asKnown()?.validity() ?: 0) + (cadence.asKnown()?.validity() ?: 0) + (compositePriceFilters.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + (if (conversionRate.asKnown() == null) 0 else 1) + @@ -9681,12 +9705,13 @@ private constructor( (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + (item.asKnown()?.validity() ?: 0) + + (matrixConfig.asKnown()?.validity() ?: 0) + (maximum.asKnown()?.validity() ?: 0) + (if (maximumAmount.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) + (minimum.asKnown()?.validity() ?: 0) + (if (minimumAmount.asKnown() == null) 0 else 1) + - modelType.let { if (it == JsonValue.from("bulk")) 1 else 0 } + + modelType.let { if (it == JsonValue.from("matrix")) 1 else 0 } + (if (name.asKnown() == null) 0 else 1) + (if (planPhaseOrder.asKnown() == null) 0 else 1) + (priceType.asKnown()?.validity() ?: 0) + @@ -10084,11 +10109,10 @@ private constructor( return true } - return other is Bulk && + return other is Matrix && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && - bulkConfig == other.bulkConfig && cadence == other.cadence && compositePriceFilters == other.compositePriceFilters && conversionRate == other.conversionRate && @@ -10101,6 +10125,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && + matrixConfig == other.matrixConfig && maximum == other.maximum && maximumAmount == other.maximumAmount && metadata == other.metadata && @@ -10120,7 +10145,6 @@ private constructor( id, billableMetric, billingCycleConfiguration, - bulkConfig, cadence, compositePriceFilters, conversionRate, @@ -10133,6 +10157,7 @@ private constructor( fixedPriceQuantity, invoicingCycleConfiguration, item, + matrixConfig, maximum, maximumAmount, metadata, @@ -10151,7 +10176,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Bulk{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, bulkConfig=$bulkConfig, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "Matrix{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, matrixConfig=$matrixConfig, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" } class ThresholdTotalAmount @@ -10418,6 +10443,8 @@ private constructor( fun minimumAmount(): String? = minimumAmount.getNullable("minimum_amount") /** + * The pricing model type + * * Expected to always return the following: * ```kotlin * JsonValue.from("threshold_total_amount") @@ -10456,6 +10483,8 @@ private constructor( fun replacesPriceId(): String? = replacesPriceId.getNullable("replaces_price_id") /** + * Configuration for threshold_total_amount pricing + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ @@ -11323,6 +11352,7 @@ private constructor( this.replacesPriceId = replacesPriceId } + /** Configuration for threshold_total_amount pricing */ fun thresholdTotalAmountConfig(thresholdTotalAmountConfig: ThresholdTotalAmountConfig) = thresholdTotalAmountConfig(JsonField.of(thresholdTotalAmountConfig)) @@ -11912,16 +11942,69 @@ private constructor( override fun toString() = value.toString() } + /** Configuration for threshold_total_amount pricing */ class ThresholdTotalAmountConfig - @JsonCreator private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map + private val consumptionTable: JsonField>, + private val prorate: JsonField, + private val additionalProperties: MutableMap, ) { + @JsonCreator + private constructor( + @JsonProperty("consumption_table") + @ExcludeMissing + consumptionTable: JsonField> = JsonMissing.of(), + @JsonProperty("prorate") + @ExcludeMissing + prorate: JsonField = JsonMissing.of(), + ) : this(consumptionTable, prorate, mutableMapOf()) + + /** + * When the quantity consumed passes a provided threshold, the configured total will be + * charged + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun consumptionTable(): List = + consumptionTable.getRequired("consumption_table") + + /** + * If true, the unit price will be prorated to the billing period + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun prorate(): Boolean? = prorate.getNullable("prorate") + + /** + * Returns the raw JSON value of [consumptionTable]. + * + * Unlike [consumptionTable], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("consumption_table") + @ExcludeMissing + fun _consumptionTable(): JsonField> = consumptionTable + + /** + * Returns the raw JSON value of [prorate]. + * + * Unlike [prorate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("prorate") @ExcludeMissing fun _prorate(): JsonField = prorate + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) fun toBuilder() = Builder().from(this) @@ -11930,6 +12013,11 @@ private constructor( /** * Returns a mutable builder for constructing an instance of * [ThresholdTotalAmountConfig]. + * + * The following fields are required: + * ```kotlin + * .consumptionTable() + * ``` */ fun builder() = Builder() } @@ -11937,13 +12025,67 @@ private constructor( /** A builder for [ThresholdTotalAmountConfig]. */ class Builder internal constructor() { + private var consumptionTable: JsonField>? = null + private var prorate: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() internal fun from(thresholdTotalAmountConfig: ThresholdTotalAmountConfig) = apply { + consumptionTable = + thresholdTotalAmountConfig.consumptionTable.map { it.toMutableList() } + prorate = thresholdTotalAmountConfig.prorate additionalProperties = thresholdTotalAmountConfig.additionalProperties.toMutableMap() } + /** + * When the quantity consumed passes a provided threshold, the configured total will + * be charged + */ + fun consumptionTable(consumptionTable: List) = + consumptionTable(JsonField.of(consumptionTable)) + + /** + * Sets [Builder.consumptionTable] to an arbitrary JSON value. + * + * You should usually call [Builder.consumptionTable] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun consumptionTable(consumptionTable: JsonField>) = apply { + this.consumptionTable = consumptionTable.map { it.toMutableList() } + } + + /** + * Adds a single [ConsumptionTable] to [Builder.consumptionTable]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addConsumptionTable(consumptionTable: ConsumptionTable) = apply { + this.consumptionTable = + (this.consumptionTable ?: JsonField.of(mutableListOf())).also { + checkKnown("consumptionTable", it).add(consumptionTable) + } + } + + /** If true, the unit price will be prorated to the billing period */ + fun prorate(prorate: Boolean?) = prorate(JsonField.ofNullable(prorate)) + + /** + * Alias for [Builder.prorate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun prorate(prorate: Boolean) = prorate(prorate as Boolean?) + + /** + * Sets [Builder.prorate] to an arbitrary JSON value. + * + * You should usually call [Builder.prorate] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun prorate(prorate: JsonField) = apply { this.prorate = prorate } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -11970,9 +12112,22 @@ private constructor( * Returns an immutable instance of [ThresholdTotalAmountConfig]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .consumptionTable() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ fun build(): ThresholdTotalAmountConfig = - ThresholdTotalAmountConfig(additionalProperties.toImmutable()) + ThresholdTotalAmountConfig( + checkRequired("consumptionTable", consumptionTable).map { + it.toImmutable() + }, + prorate, + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false @@ -11982,6 +12137,8 @@ private constructor( return@apply } + consumptionTable().forEach { it.validate() } + prorate() validated = true } @@ -12000,7 +12157,225 @@ private constructor( * Used for best match union deserialization. */ internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + (consumptionTable.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + (if (prorate.asKnown() == null) 0 else 1) + + /** Configuration for a single threshold */ + class ConsumptionTable + private constructor( + private val threshold: JsonField, + private val totalAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("threshold") + @ExcludeMissing + threshold: JsonField = JsonMissing.of(), + @JsonProperty("total_amount") + @ExcludeMissing + totalAmount: JsonField = JsonMissing.of(), + ) : this(threshold, totalAmount, mutableMapOf()) + + /** + * Quantity threshold + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun threshold(): String = threshold.getRequired("threshold") + + /** + * Total amount for this threshold + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun totalAmount(): String = totalAmount.getRequired("total_amount") + + /** + * Returns the raw JSON value of [threshold]. + * + * Unlike [threshold], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("threshold") + @ExcludeMissing + fun _threshold(): JsonField = threshold + + /** + * Returns the raw JSON value of [totalAmount]. + * + * Unlike [totalAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("total_amount") + @ExcludeMissing + fun _totalAmount(): JsonField = totalAmount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ConsumptionTable]. + * + * The following fields are required: + * ```kotlin + * .threshold() + * .totalAmount() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [ConsumptionTable]. */ + class Builder internal constructor() { + + private var threshold: JsonField? = null + private var totalAmount: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(consumptionTable: ConsumptionTable) = apply { + threshold = consumptionTable.threshold + totalAmount = consumptionTable.totalAmount + additionalProperties = consumptionTable.additionalProperties.toMutableMap() + } + + /** Quantity threshold */ + fun threshold(threshold: String) = threshold(JsonField.of(threshold)) + + /** + * Sets [Builder.threshold] to an arbitrary JSON value. + * + * You should usually call [Builder.threshold] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun threshold(threshold: JsonField) = apply { + this.threshold = threshold + } + + /** Total amount for this threshold */ + fun totalAmount(totalAmount: String) = totalAmount(JsonField.of(totalAmount)) + + /** + * Sets [Builder.totalAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.totalAmount] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun totalAmount(totalAmount: JsonField) = apply { + this.totalAmount = totalAmount + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ConsumptionTable]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .threshold() + * .totalAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ConsumptionTable = + ConsumptionTable( + checkRequired("threshold", threshold), + checkRequired("totalAmount", totalAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ConsumptionTable = apply { + if (validated) { + return@apply + } + + threshold() + totalAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (threshold.asKnown() == null) 0 else 1) + + (if (totalAmount.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ConsumptionTable && + threshold == other.threshold && + totalAmount == other.totalAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(threshold, totalAmount, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ConsumptionTable{threshold=$threshold, totalAmount=$totalAmount, additionalProperties=$additionalProperties}" + } override fun equals(other: Any?): Boolean { if (this === other) { @@ -12008,15 +12383,19 @@ private constructor( } return other is ThresholdTotalAmountConfig && + consumptionTable == other.consumptionTable && + prorate == other.prorate && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + private val hashCode: Int by lazy { + Objects.hash(consumptionTable, prorate, additionalProperties) + } override fun hashCode(): Int = hashCode override fun toString() = - "ThresholdTotalAmountConfig{additionalProperties=$additionalProperties}" + "ThresholdTotalAmountConfig{consumptionTable=$consumptionTable, prorate=$prorate, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { @@ -12358,6 +12737,8 @@ private constructor( fun minimumAmount(): String? = minimumAmount.getNullable("minimum_amount") /** + * The pricing model type + * * Expected to always return the following: * ```kotlin * JsonValue.from("tiered_package") @@ -12396,6 +12777,8 @@ private constructor( fun replacesPriceId(): String? = replacesPriceId.getNullable("replaces_price_id") /** + * Configuration for tiered_package pricing + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ @@ -13262,6 +13645,7 @@ private constructor( this.replacesPriceId = replacesPriceId } + /** Configuration for tiered_package pricing */ fun tieredPackageConfig(tieredPackageConfig: TieredPackageConfig) = tieredPackageConfig(JsonField.of(tieredPackageConfig)) @@ -13851,16 +14235,69 @@ private constructor( override fun toString() = value.toString() } + /** Configuration for tiered_package pricing */ class TieredPackageConfig - @JsonCreator private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map + private val packageSize: JsonField, + private val tiers: JsonField>, + private val additionalProperties: MutableMap, ) { + @JsonCreator + private constructor( + @JsonProperty("package_size") + @ExcludeMissing + packageSize: JsonField = JsonMissing.of(), + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of(), + ) : this(packageSize, tiers, mutableMapOf()) + + /** + * Package size + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun packageSize(): String = packageSize.getRequired("package_size") + + /** + * Apply tiered pricing after rounding up the quantity to the package size. Tiers are + * defined using exclusive lower bounds. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun tiers(): List = tiers.getRequired("tiers") + + /** + * Returns the raw JSON value of [packageSize]. + * + * Unlike [packageSize], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("package_size") + @ExcludeMissing + fun _packageSize(): JsonField = packageSize + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tiers") @ExcludeMissing fun _tiers(): JsonField> = tiers + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) fun toBuilder() = Builder().from(this) @@ -13868,6 +14305,12 @@ private constructor( /** * Returns a mutable builder for constructing an instance of [TieredPackageConfig]. + * + * The following fields are required: + * ```kotlin + * .packageSize() + * .tiers() + * ``` */ fun builder() = Builder() } @@ -13875,12 +14318,59 @@ private constructor( /** A builder for [TieredPackageConfig]. */ class Builder internal constructor() { + private var packageSize: JsonField? = null + private var tiers: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(tieredPackageConfig: TieredPackageConfig) = apply { + packageSize = tieredPackageConfig.packageSize + tiers = tieredPackageConfig.tiers.map { it.toMutableList() } additionalProperties = tieredPackageConfig.additionalProperties.toMutableMap() } + /** Package size */ + fun packageSize(packageSize: String) = packageSize(JsonField.of(packageSize)) + + /** + * Sets [Builder.packageSize] to an arbitrary JSON value. + * + * You should usually call [Builder.packageSize] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun packageSize(packageSize: JsonField) = apply { + this.packageSize = packageSize + } + + /** + * Apply tiered pricing after rounding up the quantity to the package size. Tiers + * are defined using exclusive lower bounds. + */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -13907,9 +14397,21 @@ private constructor( * Returns an immutable instance of [TieredPackageConfig]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .packageSize() + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ fun build(): TieredPackageConfig = - TieredPackageConfig(additionalProperties.toImmutable()) + TieredPackageConfig( + checkRequired("packageSize", packageSize), + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false @@ -13919,6 +14421,8 @@ private constructor( return@apply } + packageSize() + tiers().forEach { it.validate() } validated = true } @@ -13937,7 +14441,224 @@ private constructor( * Used for best match union deserialization. */ internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + (if (packageSize.asKnown() == null) 0 else 1) + + (tiers.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single tier with business logic */ + class Tier + private constructor( + private val perUnit: JsonField, + private val tierLowerBound: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("per_unit") + @ExcludeMissing + perUnit: JsonField = JsonMissing.of(), + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + ) : this(perUnit, tierLowerBound, mutableMapOf()) + + /** + * Price per package + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun perUnit(): String = perUnit.getRequired("per_unit") + + /** + * Tier lower bound + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun tierLowerBound(): String = tierLowerBound.getRequired("tier_lower_bound") + + /** + * Returns the raw JSON value of [perUnit]. + * + * Unlike [perUnit], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("per_unit") + @ExcludeMissing + fun _perUnit(): JsonField = perUnit + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Tier]. + * + * The following fields are required: + * ```kotlin + * .perUnit() + * .tierLowerBound() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var perUnit: JsonField? = null + private var tierLowerBound: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(tier: Tier) = apply { + perUnit = tier.perUnit + tierLowerBound = tier.tierLowerBound + additionalProperties = tier.additionalProperties.toMutableMap() + } + + /** Price per package */ + fun perUnit(perUnit: String) = perUnit(JsonField.of(perUnit)) + + /** + * Sets [Builder.perUnit] to an arbitrary JSON value. + * + * You should usually call [Builder.perUnit] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun perUnit(perUnit: JsonField) = apply { this.perUnit = perUnit } + + /** Tier lower bound */ + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Tier]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .perUnit() + * .tierLowerBound() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("perUnit", perUnit), + checkRequired("tierLowerBound", tierLowerBound), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + perUnit() + tierLowerBound() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (perUnit.asKnown() == null) 0 else 1) + + (if (tierLowerBound.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + perUnit == other.perUnit && + tierLowerBound == other.tierLowerBound && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(perUnit, tierLowerBound, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{perUnit=$perUnit, tierLowerBound=$tierLowerBound, additionalProperties=$additionalProperties}" + } override fun equals(other: Any?): Boolean { if (this === other) { @@ -13945,15 +14666,19 @@ private constructor( } return other is TieredPackageConfig && + packageSize == other.packageSize && + tiers == other.tiers && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + private val hashCode: Int by lazy { + Objects.hash(packageSize, tiers, additionalProperties) + } override fun hashCode(): Int = hashCode override fun toString() = - "TieredPackageConfig{additionalProperties=$additionalProperties}" + "TieredPackageConfig{packageSize=$packageSize, tiers=$tiers, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { @@ -14031,7 +14756,7 @@ private constructor( "TieredPackage{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, tieredPackageConfig=$tieredPackageConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" } - class GroupedTiered + class TieredWithMinimum private constructor( private val id: JsonField, private val billableMetric: JsonField, @@ -14046,7 +14771,6 @@ private constructor( private val discount: JsonField, private val externalPriceId: JsonField, private val fixedPriceQuantity: JsonField, - private val groupedTieredConfig: JsonField, private val invoicingCycleConfiguration: JsonField, private val item: JsonField, private val maximum: JsonField, @@ -14059,6 +14783,7 @@ private constructor( private val planPhaseOrder: JsonField, private val priceType: JsonField, private val replacesPriceId: JsonField, + private val tieredWithMinimumConfig: JsonField, private val dimensionalPriceConfiguration: JsonField, private val additionalProperties: MutableMap, ) { @@ -14100,9 +14825,6 @@ private constructor( @JsonProperty("fixed_price_quantity") @ExcludeMissing fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("grouped_tiered_config") - @ExcludeMissing - groupedTieredConfig: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), @@ -14129,6 +14851,9 @@ private constructor( @JsonProperty("replaces_price_id") @ExcludeMissing replacesPriceId: JsonField = JsonMissing.of(), + @JsonProperty("tiered_with_minimum_config") + @ExcludeMissing + tieredWithMinimumConfig: JsonField = JsonMissing.of(), @JsonProperty("dimensional_price_configuration") @ExcludeMissing dimensionalPriceConfiguration: JsonField = @@ -14147,7 +14872,6 @@ private constructor( discount, externalPriceId, fixedPriceQuantity, - groupedTieredConfig, invoicingCycleConfiguration, item, maximum, @@ -14160,6 +14884,7 @@ private constructor( planPhaseOrder, priceType, replacesPriceId, + tieredWithMinimumConfig, dimensionalPriceConfiguration, mutableMapOf(), ) @@ -14245,13 +14970,6 @@ private constructor( */ fun fixedPriceQuantity(): Double? = fixedPriceQuantity.getNullable("fixed_price_quantity") - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun groupedTieredConfig(): GroupedTieredConfig = - groupedTieredConfig.getRequired("grouped_tiered_config") - /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -14302,9 +15020,11 @@ private constructor( fun minimumAmount(): String? = minimumAmount.getNullable("minimum_amount") /** + * The pricing model type + * * Expected to always return the following: * ```kotlin - * JsonValue.from("grouped_tiered") + * JsonValue.from("tiered_with_minimum") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -14339,6 +15059,15 @@ private constructor( */ fun replacesPriceId(): String? = replacesPriceId.getNullable("replaces_price_id") + /** + * Configuration for tiered_with_minimum pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun tieredWithMinimumConfig(): TieredWithMinimumConfig = + tieredWithMinimumConfig.getRequired("tiered_with_minimum_config") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -14467,16 +15196,6 @@ private constructor( @ExcludeMissing fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - /** - * Returns the raw JSON value of [groupedTieredConfig]. - * - * Unlike [groupedTieredConfig], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("grouped_tiered_config") - @ExcludeMissing - fun _groupedTieredConfig(): JsonField = groupedTieredConfig - /** * Returns the raw JSON value of [invoicingCycleConfiguration]. * @@ -14580,6 +15299,16 @@ private constructor( @ExcludeMissing fun _replacesPriceId(): JsonField = replacesPriceId + /** + * Returns the raw JSON value of [tieredWithMinimumConfig]. + * + * Unlike [tieredWithMinimumConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("tiered_with_minimum_config") + @ExcludeMissing + fun _tieredWithMinimumConfig(): JsonField = tieredWithMinimumConfig + /** * Returns the raw JSON value of [dimensionalPriceConfiguration]. * @@ -14606,7 +15335,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [GroupedTiered]. + * Returns a mutable builder for constructing an instance of [TieredWithMinimum]. * * The following fields are required: * ```kotlin @@ -14623,7 +15352,6 @@ private constructor( * .discount() * .externalPriceId() * .fixedPriceQuantity() - * .groupedTieredConfig() * .invoicingCycleConfiguration() * .item() * .maximum() @@ -14635,12 +15363,13 @@ private constructor( * .planPhaseOrder() * .priceType() * .replacesPriceId() + * .tieredWithMinimumConfig() * ``` */ fun builder() = Builder() } - /** A builder for [GroupedTiered]. */ + /** A builder for [TieredWithMinimum]. */ class Builder internal constructor() { private var id: JsonField? = null @@ -14656,7 +15385,6 @@ private constructor( private var discount: JsonField? = null private var externalPriceId: JsonField? = null private var fixedPriceQuantity: JsonField? = null - private var groupedTieredConfig: JsonField? = null private var invoicingCycleConfiguration: JsonField? = null private var item: JsonField? = null private var maximum: JsonField? = null @@ -14664,45 +15392,46 @@ private constructor( private var metadata: JsonField? = null private var minimum: JsonField? = null private var minimumAmount: JsonField? = null - private var modelType: JsonValue = JsonValue.from("grouped_tiered") + private var modelType: JsonValue = JsonValue.from("tiered_with_minimum") private var name: JsonField? = null private var planPhaseOrder: JsonField? = null private var priceType: JsonField? = null private var replacesPriceId: JsonField? = null + private var tieredWithMinimumConfig: JsonField? = null private var dimensionalPriceConfiguration: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(groupedTiered: GroupedTiered) = apply { - id = groupedTiered.id - billableMetric = groupedTiered.billableMetric - billingCycleConfiguration = groupedTiered.billingCycleConfiguration - cadence = groupedTiered.cadence + internal fun from(tieredWithMinimum: TieredWithMinimum) = apply { + id = tieredWithMinimum.id + billableMetric = tieredWithMinimum.billableMetric + billingCycleConfiguration = tieredWithMinimum.billingCycleConfiguration + cadence = tieredWithMinimum.cadence compositePriceFilters = - groupedTiered.compositePriceFilters.map { it.toMutableList() } - conversionRate = groupedTiered.conversionRate - conversionRateConfig = groupedTiered.conversionRateConfig - createdAt = groupedTiered.createdAt - creditAllocation = groupedTiered.creditAllocation - currency = groupedTiered.currency - discount = groupedTiered.discount - externalPriceId = groupedTiered.externalPriceId - fixedPriceQuantity = groupedTiered.fixedPriceQuantity - groupedTieredConfig = groupedTiered.groupedTieredConfig - invoicingCycleConfiguration = groupedTiered.invoicingCycleConfiguration - item = groupedTiered.item - maximum = groupedTiered.maximum - maximumAmount = groupedTiered.maximumAmount - metadata = groupedTiered.metadata - minimum = groupedTiered.minimum - minimumAmount = groupedTiered.minimumAmount - modelType = groupedTiered.modelType - name = groupedTiered.name - planPhaseOrder = groupedTiered.planPhaseOrder - priceType = groupedTiered.priceType - replacesPriceId = groupedTiered.replacesPriceId - dimensionalPriceConfiguration = groupedTiered.dimensionalPriceConfiguration - additionalProperties = groupedTiered.additionalProperties.toMutableMap() + tieredWithMinimum.compositePriceFilters.map { it.toMutableList() } + conversionRate = tieredWithMinimum.conversionRate + conversionRateConfig = tieredWithMinimum.conversionRateConfig + createdAt = tieredWithMinimum.createdAt + creditAllocation = tieredWithMinimum.creditAllocation + currency = tieredWithMinimum.currency + discount = tieredWithMinimum.discount + externalPriceId = tieredWithMinimum.externalPriceId + fixedPriceQuantity = tieredWithMinimum.fixedPriceQuantity + invoicingCycleConfiguration = tieredWithMinimum.invoicingCycleConfiguration + item = tieredWithMinimum.item + maximum = tieredWithMinimum.maximum + maximumAmount = tieredWithMinimum.maximumAmount + metadata = tieredWithMinimum.metadata + minimum = tieredWithMinimum.minimum + minimumAmount = tieredWithMinimum.minimumAmount + modelType = tieredWithMinimum.modelType + name = tieredWithMinimum.name + planPhaseOrder = tieredWithMinimum.planPhaseOrder + priceType = tieredWithMinimum.priceType + replacesPriceId = tieredWithMinimum.replacesPriceId + tieredWithMinimumConfig = tieredWithMinimum.tieredWithMinimumConfig + dimensionalPriceConfiguration = tieredWithMinimum.dimensionalPriceConfiguration + additionalProperties = tieredWithMinimum.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) @@ -15024,20 +15753,6 @@ private constructor( this.fixedPriceQuantity = fixedPriceQuantity } - fun groupedTieredConfig(groupedTieredConfig: GroupedTieredConfig) = - groupedTieredConfig(JsonField.of(groupedTieredConfig)) - - /** - * Sets [Builder.groupedTieredConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.groupedTieredConfig] with a well-typed - * [GroupedTieredConfig] value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. - */ - fun groupedTieredConfig(groupedTieredConfig: JsonField) = apply { - this.groupedTieredConfig = groupedTieredConfig - } - fun invoicingCycleConfiguration( invoicingCycleConfiguration: BillingCycleConfiguration? ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) @@ -15144,7 +15859,7 @@ private constructor( * It is usually unnecessary to call this method because the field defaults to the * following: * ```kotlin - * JsonValue.from("grouped_tiered") + * JsonValue.from("tiered_with_minimum") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -15213,6 +15928,21 @@ private constructor( this.replacesPriceId = replacesPriceId } + /** Configuration for tiered_with_minimum pricing */ + fun tieredWithMinimumConfig(tieredWithMinimumConfig: TieredWithMinimumConfig) = + tieredWithMinimumConfig(JsonField.of(tieredWithMinimumConfig)) + + /** + * Sets [Builder.tieredWithMinimumConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.tieredWithMinimumConfig] with a well-typed + * [TieredWithMinimumConfig] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tieredWithMinimumConfig( + tieredWithMinimumConfig: JsonField + ) = apply { this.tieredWithMinimumConfig = tieredWithMinimumConfig } + fun dimensionalPriceConfiguration( dimensionalPriceConfiguration: DimensionalPriceConfiguration? ) = dimensionalPriceConfiguration(JsonField.ofNullable(dimensionalPriceConfiguration)) @@ -15248,7 +15978,7 @@ private constructor( } /** - * Returns an immutable instance of [GroupedTiered]. + * Returns an immutable instance of [TieredWithMinimum]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -15267,7 +15997,6 @@ private constructor( * .discount() * .externalPriceId() * .fixedPriceQuantity() - * .groupedTieredConfig() * .invoicingCycleConfiguration() * .item() * .maximum() @@ -15279,12 +16008,13 @@ private constructor( * .planPhaseOrder() * .priceType() * .replacesPriceId() + * .tieredWithMinimumConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): GroupedTiered = - GroupedTiered( + fun build(): TieredWithMinimum = + TieredWithMinimum( checkRequired("id", id), checkRequired("billableMetric", billableMetric), checkRequired("billingCycleConfiguration", billingCycleConfiguration), @@ -15300,7 +16030,6 @@ private constructor( checkRequired("discount", discount), checkRequired("externalPriceId", externalPriceId), checkRequired("fixedPriceQuantity", fixedPriceQuantity), - checkRequired("groupedTieredConfig", groupedTieredConfig), checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), checkRequired("item", item), checkRequired("maximum", maximum), @@ -15313,6 +16042,7 @@ private constructor( checkRequired("planPhaseOrder", planPhaseOrder), checkRequired("priceType", priceType), checkRequired("replacesPriceId", replacesPriceId), + checkRequired("tieredWithMinimumConfig", tieredWithMinimumConfig), dimensionalPriceConfiguration, additionalProperties.toMutableMap(), ) @@ -15320,7 +16050,7 @@ private constructor( private var validated: Boolean = false - fun validate(): GroupedTiered = apply { + fun validate(): TieredWithMinimum = apply { if (validated) { return@apply } @@ -15338,7 +16068,6 @@ private constructor( discount()?.validate() externalPriceId() fixedPriceQuantity() - groupedTieredConfig().validate() invoicingCycleConfiguration()?.validate() item().validate() maximum()?.validate() @@ -15347,7 +16076,7 @@ private constructor( minimum()?.validate() minimumAmount() _modelType().let { - if (it != JsonValue.from("grouped_tiered")) { + if (it != JsonValue.from("tiered_with_minimum")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } @@ -15355,6 +16084,7 @@ private constructor( planPhaseOrder() priceType().validate() replacesPriceId() + tieredWithMinimumConfig().validate() dimensionalPriceConfiguration()?.validate() validated = true } @@ -15387,7 +16117,6 @@ private constructor( (discount.asKnown()?.validity() ?: 0) + (if (externalPriceId.asKnown() == null) 0 else 1) + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + - (groupedTieredConfig.asKnown()?.validity() ?: 0) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + (item.asKnown()?.validity() ?: 0) + (maximum.asKnown()?.validity() ?: 0) + @@ -15395,11 +16124,12 @@ private constructor( (metadata.asKnown()?.validity() ?: 0) + (minimum.asKnown()?.validity() ?: 0) + (if (minimumAmount.asKnown() == null) 0 else 1) + - modelType.let { if (it == JsonValue.from("grouped_tiered")) 1 else 0 } + + modelType.let { if (it == JsonValue.from("tiered_with_minimum")) 1 else 0 } + (if (name.asKnown() == null) 0 else 1) + (if (planPhaseOrder.asKnown() == null) 0 else 1) + (priceType.asKnown()?.validity() ?: 0) + (if (replacesPriceId.asKnown() == null) 0 else 1) + + (tieredWithMinimumConfig.asKnown()?.validity() ?: 0) + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) class Cadence @JsonCreator private constructor(private val value: JsonField) : @@ -15554,7 +16284,12 @@ private constructor( override fun toString() = value.toString() } - class GroupedTieredConfig + /** + * User specified key-value pairs for the resource. If not present, this defaults to an + * empty dictionary. Individual keys can be removed by setting the value to `null`, and the + * entire metadata mapping can be cleared by setting `metadata` to `null`. + */ + class Metadata @JsonCreator private constructor( @com.fasterxml.jackson.annotation.JsonValue @@ -15569,19 +16304,17 @@ private constructor( companion object { - /** - * Returns a mutable builder for constructing an instance of [GroupedTieredConfig]. - */ + /** Returns a mutable builder for constructing an instance of [Metadata]. */ fun builder() = Builder() } - /** A builder for [GroupedTieredConfig]. */ + /** A builder for [Metadata]. */ class Builder internal constructor() { private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(groupedTieredConfig: GroupedTieredConfig) = apply { - additionalProperties = groupedTieredConfig.additionalProperties.toMutableMap() + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() } fun additionalProperties(additionalProperties: Map) = apply { @@ -15607,17 +16340,16 @@ private constructor( } /** - * Returns an immutable instance of [GroupedTieredConfig]. + * Returns an immutable instance of [Metadata]. * * Further updates to this [Builder] will not mutate the returned instance. */ - fun build(): GroupedTieredConfig = - GroupedTieredConfig(additionalProperties.toImmutable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } private var validated: Boolean = false - fun validate(): GroupedTieredConfig = apply { + fun validate(): Metadata = apply { if (validated) { return@apply } @@ -15647,51 +16379,318 @@ private constructor( return true } - return other is GroupedTieredConfig && - additionalProperties == other.additionalProperties + return other is Metadata && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { Objects.hash(additionalProperties) } override fun hashCode(): Int = hashCode - override fun toString() = - "GroupedTieredConfig{additionalProperties=$additionalProperties}" + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" } - /** - * User specified key-value pairs for the resource. If not present, this defaults to an - * empty dictionary. Individual keys can be removed by setting the value to `null`, and the - * entire metadata mapping can be cleared by setting `metadata` to `null`. - */ - class Metadata - @JsonCreator + class PriceType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val USAGE_PRICE = of("usage_price") + + val FIXED_PRICE = of("fixed_price") + + fun of(value: String) = PriceType(JsonField.of(value)) + } + + /** An enum containing [PriceType]'s known values. */ + enum class Known { + USAGE_PRICE, + FIXED_PRICE, + } + + /** + * An enum containing [PriceType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [PriceType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + USAGE_PRICE, + FIXED_PRICE, + /** + * An enum member indicating that [PriceType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + USAGE_PRICE -> Value.USAGE_PRICE + FIXED_PRICE -> Value.FIXED_PRICE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + USAGE_PRICE -> Known.USAGE_PRICE + FIXED_PRICE -> Known.FIXED_PRICE + else -> throw OrbInvalidDataException("Unknown PriceType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): PriceType = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PriceType && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Configuration for tiered_with_minimum pricing */ + class TieredWithMinimumConfig private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map + private val tiers: JsonField>, + private val hideZeroAmountTiers: JsonField, + private val prorate: JsonField, + private val additionalProperties: MutableMap, ) { + @JsonCreator + private constructor( + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of(), + @JsonProperty("hide_zero_amount_tiers") + @ExcludeMissing + hideZeroAmountTiers: JsonField = JsonMissing.of(), + @JsonProperty("prorate") + @ExcludeMissing + prorate: JsonField = JsonMissing.of(), + ) : this(tiers, hideZeroAmountTiers, prorate, mutableMapOf()) + + /** + * Tiered pricing with a minimum amount dependent on the volume tier. Tiers are defined + * using exclusive lower bounds. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun tiers(): List = tiers.getRequired("tiers") + + /** + * If true, tiers with an accrued amount of 0 will not be included in the rating. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun hideZeroAmountTiers(): Boolean? = + hideZeroAmountTiers.getNullable("hide_zero_amount_tiers") + + /** + * If true, the unit price will be prorated to the billing period + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun prorate(): Boolean? = prorate.getNullable("prorate") + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tiers") @ExcludeMissing fun _tiers(): JsonField> = tiers + + /** + * Returns the raw JSON value of [hideZeroAmountTiers]. + * + * Unlike [hideZeroAmountTiers], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("hide_zero_amount_tiers") + @ExcludeMissing + fun _hideZeroAmountTiers(): JsonField = hideZeroAmountTiers + + /** + * Returns the raw JSON value of [prorate]. + * + * Unlike [prorate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("prorate") @ExcludeMissing fun _prorate(): JsonField = prorate + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) fun toBuilder() = Builder().from(this) companion object { - /** Returns a mutable builder for constructing an instance of [Metadata]. */ + /** + * Returns a mutable builder for constructing an instance of + * [TieredWithMinimumConfig]. + * + * The following fields are required: + * ```kotlin + * .tiers() + * ``` + */ fun builder() = Builder() } - /** A builder for [Metadata]. */ + /** A builder for [TieredWithMinimumConfig]. */ class Builder internal constructor() { + private var tiers: JsonField>? = null + private var hideZeroAmountTiers: JsonField = JsonMissing.of() + private var prorate: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(metadata: Metadata) = apply { - additionalProperties = metadata.additionalProperties.toMutableMap() + internal fun from(tieredWithMinimumConfig: TieredWithMinimumConfig) = apply { + tiers = tieredWithMinimumConfig.tiers.map { it.toMutableList() } + hideZeroAmountTiers = tieredWithMinimumConfig.hideZeroAmountTiers + prorate = tieredWithMinimumConfig.prorate + additionalProperties = + tieredWithMinimumConfig.additionalProperties.toMutableMap() + } + + /** + * Tiered pricing with a minimum amount dependent on the volume tier. Tiers are + * defined using exclusive lower bounds. + */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } } + /** + * If true, tiers with an accrued amount of 0 will not be included in the rating. + */ + fun hideZeroAmountTiers(hideZeroAmountTiers: Boolean) = + hideZeroAmountTiers(JsonField.of(hideZeroAmountTiers)) + + /** + * Sets [Builder.hideZeroAmountTiers] to an arbitrary JSON value. + * + * You should usually call [Builder.hideZeroAmountTiers] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun hideZeroAmountTiers(hideZeroAmountTiers: JsonField) = apply { + this.hideZeroAmountTiers = hideZeroAmountTiers + } + + /** If true, the unit price will be prorated to the billing period */ + fun prorate(prorate: Boolean) = prorate(JsonField.of(prorate)) + + /** + * Sets [Builder.prorate] to an arbitrary JSON value. + * + * You should usually call [Builder.prorate] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun prorate(prorate: JsonField) = apply { this.prorate = prorate } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -15715,20 +16714,36 @@ private constructor( } /** - * Returns an immutable instance of [Metadata]. + * Returns an immutable instance of [TieredWithMinimumConfig]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + fun build(): TieredWithMinimumConfig = + TieredWithMinimumConfig( + checkRequired("tiers", tiers).map { it.toImmutable() }, + hideZeroAmountTiers, + prorate, + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false - fun validate(): Metadata = apply { + fun validate(): TieredWithMinimumConfig = apply { if (validated) { return@apply } + tiers().forEach { it.validate() } + hideZeroAmountTiers() + prorate() validated = true } @@ -15747,150 +16762,294 @@ private constructor( * Used for best match union deserialization. */ internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + (tiers.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + (if (hideZeroAmountTiers.asKnown() == null) 0 else 1) + + (if (prorate.asKnown() == null) 0 else 1) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** Configuration for a single tier */ + class Tier + private constructor( + private val minimumAmount: JsonField, + private val tierLowerBound: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("minimum_amount") + @ExcludeMissing + minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(minimumAmount, tierLowerBound, unitAmount, mutableMapOf()) - return other is Metadata && additionalProperties == other.additionalProperties - } + /** + * Minimum amount + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /** + * Tier lower bound + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun tierLowerBound(): String = tierLowerBound.getRequired("tier_lower_bound") - override fun hashCode(): Int = hashCode + /** + * Per unit amount + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } + /** + * Returns the raw JSON value of [minimumAmount]. + * + * Unlike [minimumAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount - class PriceType @JsonCreator private constructor(private val value: JsonField) : - Enum { + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount - companion object { + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - val USAGE_PRICE = of("usage_price") + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Tier]. + * + * The following fields are required: + * ```kotlin + * .minimumAmount() + * .tierLowerBound() + * .unitAmount() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var minimumAmount: JsonField? = null + private var tierLowerBound: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(tier: Tier) = apply { + minimumAmount = tier.minimumAmount + tierLowerBound = tier.tierLowerBound + unitAmount = tier.unitAmount + additionalProperties = tier.additionalProperties.toMutableMap() + } - val FIXED_PRICE = of("fixed_price") + /** Minimum amount */ + fun minimumAmount(minimumAmount: String) = + minimumAmount(JsonField.of(minimumAmount)) + + /** + * Sets [Builder.minimumAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumAmount] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount + } - fun of(value: String) = PriceType(JsonField.of(value)) - } + /** Tier lower bound */ + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } - /** An enum containing [PriceType]'s known values. */ - enum class Known { - USAGE_PRICE, - FIXED_PRICE, - } + /** Per unit amount */ + fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } - /** - * An enum containing [PriceType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [PriceType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - USAGE_PRICE, - FIXED_PRICE, - /** - * An enum member indicating that [PriceType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - USAGE_PRICE -> Value.USAGE_PRICE - FIXED_PRICE -> Value.FIXED_PRICE - else -> Value._UNKNOWN - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - USAGE_PRICE -> Known.USAGE_PRICE - FIXED_PRICE -> Known.FIXED_PRICE - else -> throw OrbInvalidDataException("Unknown PriceType: $value") - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - private var validated: Boolean = false + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - fun validate(): PriceType = apply { - if (validated) { - return@apply + /** + * Returns an immutable instance of [Tier]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .minimumAmount() + * .tierLowerBound() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("minimumAmount", minimumAmount), + checkRequired("tierLowerBound", tierLowerBound), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + minimumAmount() + tierLowerBound() + unitAmount() + validated = true } - known() - validated = true - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (minimumAmount.asKnown() == null) 0 else 1) + + (if (tierLowerBound.asKnown() == null) 0 else 1) + + (if (unitAmount.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + minimumAmount == other.minimumAmount && + tierLowerBound == other.tierLowerBound && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + private val hashCode: Int by lazy { + Objects.hash(minimumAmount, tierLowerBound, unitAmount, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{minimumAmount=$minimumAmount, tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is PriceType && value == other.value + return other is TieredWithMinimumConfig && + tiers == other.tiers && + hideZeroAmountTiers == other.hideZeroAmountTiers && + prorate == other.prorate && + additionalProperties == other.additionalProperties } - override fun hashCode() = value.hashCode() + private val hashCode: Int by lazy { + Objects.hash(tiers, hideZeroAmountTiers, prorate, additionalProperties) + } - override fun toString() = value.toString() + override fun hashCode(): Int = hashCode + + override fun toString() = + "TieredWithMinimumConfig{tiers=$tiers, hideZeroAmountTiers=$hideZeroAmountTiers, prorate=$prorate, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { @@ -15898,7 +17057,7 @@ private constructor( return true } - return other is GroupedTiered && + return other is TieredWithMinimum && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && @@ -15912,7 +17071,6 @@ private constructor( discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && - groupedTieredConfig == other.groupedTieredConfig && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maximum == other.maximum && @@ -15925,6 +17083,7 @@ private constructor( planPhaseOrder == other.planPhaseOrder && priceType == other.priceType && replacesPriceId == other.replacesPriceId && + tieredWithMinimumConfig == other.tieredWithMinimumConfig && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties } @@ -15944,7 +17103,6 @@ private constructor( discount, externalPriceId, fixedPriceQuantity, - groupedTieredConfig, invoicingCycleConfiguration, item, maximum, @@ -15957,6 +17115,7 @@ private constructor( planPhaseOrder, priceType, replacesPriceId, + tieredWithMinimumConfig, dimensionalPriceConfiguration, additionalProperties, ) @@ -15965,10 +17124,10 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "GroupedTiered{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, groupedTieredConfig=$groupedTieredConfig, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "TieredWithMinimum{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, tieredWithMinimumConfig=$tieredWithMinimumConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" } - class TieredWithMinimum + class GroupedTiered private constructor( private val id: JsonField, private val billableMetric: JsonField, @@ -15983,6 +17142,7 @@ private constructor( private val discount: JsonField, private val externalPriceId: JsonField, private val fixedPriceQuantity: JsonField, + private val groupedTieredConfig: JsonField, private val invoicingCycleConfiguration: JsonField, private val item: JsonField, private val maximum: JsonField, @@ -15995,7 +17155,6 @@ private constructor( private val planPhaseOrder: JsonField, private val priceType: JsonField, private val replacesPriceId: JsonField, - private val tieredWithMinimumConfig: JsonField, private val dimensionalPriceConfiguration: JsonField, private val additionalProperties: MutableMap, ) { @@ -16037,6 +17196,9 @@ private constructor( @JsonProperty("fixed_price_quantity") @ExcludeMissing fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("grouped_tiered_config") + @ExcludeMissing + groupedTieredConfig: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), @@ -16063,9 +17225,6 @@ private constructor( @JsonProperty("replaces_price_id") @ExcludeMissing replacesPriceId: JsonField = JsonMissing.of(), - @JsonProperty("tiered_with_minimum_config") - @ExcludeMissing - tieredWithMinimumConfig: JsonField = JsonMissing.of(), @JsonProperty("dimensional_price_configuration") @ExcludeMissing dimensionalPriceConfiguration: JsonField = @@ -16084,6 +17243,7 @@ private constructor( discount, externalPriceId, fixedPriceQuantity, + groupedTieredConfig, invoicingCycleConfiguration, item, maximum, @@ -16096,7 +17256,6 @@ private constructor( planPhaseOrder, priceType, replacesPriceId, - tieredWithMinimumConfig, dimensionalPriceConfiguration, mutableMapOf(), ) @@ -16182,6 +17341,15 @@ private constructor( */ fun fixedPriceQuantity(): Double? = fixedPriceQuantity.getNullable("fixed_price_quantity") + /** + * Configuration for grouped_tiered pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun groupedTieredConfig(): GroupedTieredConfig = + groupedTieredConfig.getRequired("grouped_tiered_config") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -16232,9 +17400,11 @@ private constructor( fun minimumAmount(): String? = minimumAmount.getNullable("minimum_amount") /** + * The pricing model type + * * Expected to always return the following: * ```kotlin - * JsonValue.from("tiered_with_minimum") + * JsonValue.from("grouped_tiered") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -16269,13 +17439,6 @@ private constructor( */ fun replacesPriceId(): String? = replacesPriceId.getNullable("replaces_price_id") - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun tieredWithMinimumConfig(): TieredWithMinimumConfig = - tieredWithMinimumConfig.getRequired("tiered_with_minimum_config") - /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -16404,6 +17567,16 @@ private constructor( @ExcludeMissing fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + /** + * Returns the raw JSON value of [groupedTieredConfig]. + * + * Unlike [groupedTieredConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouped_tiered_config") + @ExcludeMissing + fun _groupedTieredConfig(): JsonField = groupedTieredConfig + /** * Returns the raw JSON value of [invoicingCycleConfiguration]. * @@ -16507,16 +17680,6 @@ private constructor( @ExcludeMissing fun _replacesPriceId(): JsonField = replacesPriceId - /** - * Returns the raw JSON value of [tieredWithMinimumConfig]. - * - * Unlike [tieredWithMinimumConfig], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("tiered_with_minimum_config") - @ExcludeMissing - fun _tieredWithMinimumConfig(): JsonField = tieredWithMinimumConfig - /** * Returns the raw JSON value of [dimensionalPriceConfiguration]. * @@ -16543,7 +17706,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [TieredWithMinimum]. + * Returns a mutable builder for constructing an instance of [GroupedTiered]. * * The following fields are required: * ```kotlin @@ -16560,6 +17723,7 @@ private constructor( * .discount() * .externalPriceId() * .fixedPriceQuantity() + * .groupedTieredConfig() * .invoicingCycleConfiguration() * .item() * .maximum() @@ -16571,13 +17735,12 @@ private constructor( * .planPhaseOrder() * .priceType() * .replacesPriceId() - * .tieredWithMinimumConfig() * ``` */ fun builder() = Builder() } - /** A builder for [TieredWithMinimum]. */ + /** A builder for [GroupedTiered]. */ class Builder internal constructor() { private var id: JsonField? = null @@ -16593,6 +17756,7 @@ private constructor( private var discount: JsonField? = null private var externalPriceId: JsonField? = null private var fixedPriceQuantity: JsonField? = null + private var groupedTieredConfig: JsonField? = null private var invoicingCycleConfiguration: JsonField? = null private var item: JsonField? = null private var maximum: JsonField? = null @@ -16600,46 +17764,45 @@ private constructor( private var metadata: JsonField? = null private var minimum: JsonField? = null private var minimumAmount: JsonField? = null - private var modelType: JsonValue = JsonValue.from("tiered_with_minimum") + private var modelType: JsonValue = JsonValue.from("grouped_tiered") private var name: JsonField? = null private var planPhaseOrder: JsonField? = null private var priceType: JsonField? = null private var replacesPriceId: JsonField? = null - private var tieredWithMinimumConfig: JsonField? = null private var dimensionalPriceConfiguration: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(tieredWithMinimum: TieredWithMinimum) = apply { - id = tieredWithMinimum.id - billableMetric = tieredWithMinimum.billableMetric - billingCycleConfiguration = tieredWithMinimum.billingCycleConfiguration - cadence = tieredWithMinimum.cadence + internal fun from(groupedTiered: GroupedTiered) = apply { + id = groupedTiered.id + billableMetric = groupedTiered.billableMetric + billingCycleConfiguration = groupedTiered.billingCycleConfiguration + cadence = groupedTiered.cadence compositePriceFilters = - tieredWithMinimum.compositePriceFilters.map { it.toMutableList() } - conversionRate = tieredWithMinimum.conversionRate - conversionRateConfig = tieredWithMinimum.conversionRateConfig - createdAt = tieredWithMinimum.createdAt - creditAllocation = tieredWithMinimum.creditAllocation - currency = tieredWithMinimum.currency - discount = tieredWithMinimum.discount - externalPriceId = tieredWithMinimum.externalPriceId - fixedPriceQuantity = tieredWithMinimum.fixedPriceQuantity - invoicingCycleConfiguration = tieredWithMinimum.invoicingCycleConfiguration - item = tieredWithMinimum.item - maximum = tieredWithMinimum.maximum - maximumAmount = tieredWithMinimum.maximumAmount - metadata = tieredWithMinimum.metadata - minimum = tieredWithMinimum.minimum - minimumAmount = tieredWithMinimum.minimumAmount - modelType = tieredWithMinimum.modelType - name = tieredWithMinimum.name - planPhaseOrder = tieredWithMinimum.planPhaseOrder - priceType = tieredWithMinimum.priceType - replacesPriceId = tieredWithMinimum.replacesPriceId - tieredWithMinimumConfig = tieredWithMinimum.tieredWithMinimumConfig - dimensionalPriceConfiguration = tieredWithMinimum.dimensionalPriceConfiguration - additionalProperties = tieredWithMinimum.additionalProperties.toMutableMap() + groupedTiered.compositePriceFilters.map { it.toMutableList() } + conversionRate = groupedTiered.conversionRate + conversionRateConfig = groupedTiered.conversionRateConfig + createdAt = groupedTiered.createdAt + creditAllocation = groupedTiered.creditAllocation + currency = groupedTiered.currency + discount = groupedTiered.discount + externalPriceId = groupedTiered.externalPriceId + fixedPriceQuantity = groupedTiered.fixedPriceQuantity + groupedTieredConfig = groupedTiered.groupedTieredConfig + invoicingCycleConfiguration = groupedTiered.invoicingCycleConfiguration + item = groupedTiered.item + maximum = groupedTiered.maximum + maximumAmount = groupedTiered.maximumAmount + metadata = groupedTiered.metadata + minimum = groupedTiered.minimum + minimumAmount = groupedTiered.minimumAmount + modelType = groupedTiered.modelType + name = groupedTiered.name + planPhaseOrder = groupedTiered.planPhaseOrder + priceType = groupedTiered.priceType + replacesPriceId = groupedTiered.replacesPriceId + dimensionalPriceConfiguration = groupedTiered.dimensionalPriceConfiguration + additionalProperties = groupedTiered.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) @@ -16961,6 +18124,21 @@ private constructor( this.fixedPriceQuantity = fixedPriceQuantity } + /** Configuration for grouped_tiered pricing */ + fun groupedTieredConfig(groupedTieredConfig: GroupedTieredConfig) = + groupedTieredConfig(JsonField.of(groupedTieredConfig)) + + /** + * Sets [Builder.groupedTieredConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.groupedTieredConfig] with a well-typed + * [GroupedTieredConfig] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun groupedTieredConfig(groupedTieredConfig: JsonField) = apply { + this.groupedTieredConfig = groupedTieredConfig + } + fun invoicingCycleConfiguration( invoicingCycleConfiguration: BillingCycleConfiguration? ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) @@ -17067,7 +18245,7 @@ private constructor( * It is usually unnecessary to call this method because the field defaults to the * following: * ```kotlin - * JsonValue.from("tiered_with_minimum") + * JsonValue.from("grouped_tiered") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -17136,20 +18314,6 @@ private constructor( this.replacesPriceId = replacesPriceId } - fun tieredWithMinimumConfig(tieredWithMinimumConfig: TieredWithMinimumConfig) = - tieredWithMinimumConfig(JsonField.of(tieredWithMinimumConfig)) - - /** - * Sets [Builder.tieredWithMinimumConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.tieredWithMinimumConfig] with a well-typed - * [TieredWithMinimumConfig] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun tieredWithMinimumConfig( - tieredWithMinimumConfig: JsonField - ) = apply { this.tieredWithMinimumConfig = tieredWithMinimumConfig } - fun dimensionalPriceConfiguration( dimensionalPriceConfiguration: DimensionalPriceConfiguration? ) = dimensionalPriceConfiguration(JsonField.ofNullable(dimensionalPriceConfiguration)) @@ -17185,7 +18349,7 @@ private constructor( } /** - * Returns an immutable instance of [TieredWithMinimum]. + * Returns an immutable instance of [GroupedTiered]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -17204,6 +18368,7 @@ private constructor( * .discount() * .externalPriceId() * .fixedPriceQuantity() + * .groupedTieredConfig() * .invoicingCycleConfiguration() * .item() * .maximum() @@ -17215,13 +18380,12 @@ private constructor( * .planPhaseOrder() * .priceType() * .replacesPriceId() - * .tieredWithMinimumConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): TieredWithMinimum = - TieredWithMinimum( + fun build(): GroupedTiered = + GroupedTiered( checkRequired("id", id), checkRequired("billableMetric", billableMetric), checkRequired("billingCycleConfiguration", billingCycleConfiguration), @@ -17237,6 +18401,7 @@ private constructor( checkRequired("discount", discount), checkRequired("externalPriceId", externalPriceId), checkRequired("fixedPriceQuantity", fixedPriceQuantity), + checkRequired("groupedTieredConfig", groupedTieredConfig), checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), checkRequired("item", item), checkRequired("maximum", maximum), @@ -17249,7 +18414,6 @@ private constructor( checkRequired("planPhaseOrder", planPhaseOrder), checkRequired("priceType", priceType), checkRequired("replacesPriceId", replacesPriceId), - checkRequired("tieredWithMinimumConfig", tieredWithMinimumConfig), dimensionalPriceConfiguration, additionalProperties.toMutableMap(), ) @@ -17257,7 +18421,7 @@ private constructor( private var validated: Boolean = false - fun validate(): TieredWithMinimum = apply { + fun validate(): GroupedTiered = apply { if (validated) { return@apply } @@ -17275,6 +18439,7 @@ private constructor( discount()?.validate() externalPriceId() fixedPriceQuantity() + groupedTieredConfig().validate() invoicingCycleConfiguration()?.validate() item().validate() maximum()?.validate() @@ -17283,7 +18448,7 @@ private constructor( minimum()?.validate() minimumAmount() _modelType().let { - if (it != JsonValue.from("tiered_with_minimum")) { + if (it != JsonValue.from("grouped_tiered")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } @@ -17291,7 +18456,6 @@ private constructor( planPhaseOrder() priceType().validate() replacesPriceId() - tieredWithMinimumConfig().validate() dimensionalPriceConfiguration()?.validate() validated = true } @@ -17324,6 +18488,7 @@ private constructor( (discount.asKnown()?.validity() ?: 0) + (if (externalPriceId.asKnown() == null) 0 else 1) + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (groupedTieredConfig.asKnown()?.validity() ?: 0) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + (item.asKnown()?.validity() ?: 0) + (maximum.asKnown()?.validity() ?: 0) + @@ -17331,12 +18496,11 @@ private constructor( (metadata.asKnown()?.validity() ?: 0) + (minimum.asKnown()?.validity() ?: 0) + (if (minimumAmount.asKnown() == null) 0 else 1) + - modelType.let { if (it == JsonValue.from("tiered_with_minimum")) 1 else 0 } + + modelType.let { if (it == JsonValue.from("grouped_tiered")) 1 else 0 } + (if (name.asKnown() == null) 0 else 1) + (if (planPhaseOrder.asKnown() == null) 0 else 1) + (priceType.asKnown()?.validity() ?: 0) + (if (replacesPriceId.asKnown() == null) 0 else 1) + - (tieredWithMinimumConfig.asKnown()?.validity() ?: 0) + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) class Cadence @JsonCreator private constructor(private val value: JsonField) : @@ -17491,6 +18655,453 @@ private constructor( override fun toString() = value.toString() } + /** Configuration for grouped_tiered pricing */ + class GroupedTieredConfig + private constructor( + private val groupingKey: JsonField, + private val tiers: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of(), + ) : this(groupingKey, tiers, mutableMapOf()) + + /** + * The billable metric property used to group before tiering + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * Apply tiered pricing to each segment generated after grouping with the provided key + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun tiers(): List = tiers.getRequired("tiers") + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tiers") @ExcludeMissing fun _tiers(): JsonField> = tiers + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [GroupedTieredConfig]. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .tiers() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [GroupedTieredConfig]. */ + class Builder internal constructor() { + + private var groupingKey: JsonField? = null + private var tiers: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(groupedTieredConfig: GroupedTieredConfig) = apply { + groupingKey = groupedTieredConfig.groupingKey + tiers = groupedTieredConfig.tiers.map { it.toMutableList() } + additionalProperties = groupedTieredConfig.additionalProperties.toMutableMap() + } + + /** The billable metric property used to group before tiering */ + fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** + * Apply tiered pricing to each segment generated after grouping with the provided + * key + */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [GroupedTieredConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedTieredConfig = + GroupedTieredConfig( + checkRequired("groupingKey", groupingKey), + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GroupedTieredConfig = apply { + if (validated) { + return@apply + } + + groupingKey() + tiers().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (groupingKey.asKnown() == null) 0 else 1) + + (tiers.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single tier */ + class Tier + private constructor( + private val tierLowerBound: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(tierLowerBound, unitAmount, mutableMapOf()) + + /** + * Tier lower bound + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun tierLowerBound(): String = tierLowerBound.getRequired("tier_lower_bound") + + /** + * Per unit amount + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Tier]. + * + * The following fields are required: + * ```kotlin + * .tierLowerBound() + * .unitAmount() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var tierLowerBound: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(tier: Tier) = apply { + tierLowerBound = tier.tierLowerBound + unitAmount = tier.unitAmount + additionalProperties = tier.additionalProperties.toMutableMap() + } + + /** Tier lower bound */ + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + /** Per unit amount */ + fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Tier]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .tierLowerBound() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("tierLowerBound", tierLowerBound), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + tierLowerBound() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (tierLowerBound.asKnown() == null) 0 else 1) + + (if (unitAmount.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + tierLowerBound == other.tierLowerBound && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(tierLowerBound, unitAmount, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedTieredConfig && + groupingKey == other.groupingKey && + tiers == other.tiers && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(groupingKey, tiers, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedTieredConfig{groupingKey=$groupingKey, tiers=$tiers, additionalProperties=$additionalProperties}" + } + /** * User specified key-value pairs for the resource. If not present, this defaults to an * empty dictionary. Individual keys can be removed by setting the value to `null`, and the @@ -17725,119 +19336,12 @@ private constructor( override fun toString() = value.toString() } - class TieredWithMinimumConfig - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [TieredWithMinimumConfig]. - */ - fun builder() = Builder() - } - - /** A builder for [TieredWithMinimumConfig]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(tieredWithMinimumConfig: TieredWithMinimumConfig) = apply { - additionalProperties = - tieredWithMinimumConfig.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [TieredWithMinimumConfig]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): TieredWithMinimumConfig = - TieredWithMinimumConfig(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): TieredWithMinimumConfig = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is TieredWithMinimumConfig && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "TieredWithMinimumConfig{additionalProperties=$additionalProperties}" - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is TieredWithMinimum && + return other is GroupedTiered && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && @@ -17851,6 +19355,7 @@ private constructor( discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && + groupedTieredConfig == other.groupedTieredConfig && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maximum == other.maximum && @@ -17863,7 +19368,6 @@ private constructor( planPhaseOrder == other.planPhaseOrder && priceType == other.priceType && replacesPriceId == other.replacesPriceId && - tieredWithMinimumConfig == other.tieredWithMinimumConfig && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties } @@ -17883,6 +19387,7 @@ private constructor( discount, externalPriceId, fixedPriceQuantity, + groupedTieredConfig, invoicingCycleConfiguration, item, maximum, @@ -17895,7 +19400,6 @@ private constructor( planPhaseOrder, priceType, replacesPriceId, - tieredWithMinimumConfig, dimensionalPriceConfiguration, additionalProperties, ) @@ -17904,7 +19408,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "TieredWithMinimum{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, tieredWithMinimumConfig=$tieredWithMinimumConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "GroupedTiered{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, groupedTieredConfig=$groupedTieredConfig, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" } class TieredPackageWithMinimum @@ -18172,6 +19676,8 @@ private constructor( fun minimumAmount(): String? = minimumAmount.getNullable("minimum_amount") /** + * The pricing model type + * * Expected to always return the following: * ```kotlin * JsonValue.from("tiered_package_with_minimum") @@ -18210,6 +19716,8 @@ private constructor( fun replacesPriceId(): String? = replacesPriceId.getNullable("replaces_price_id") /** + * Configuration for tiered_package_with_minimum pricing + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ @@ -19080,6 +20588,7 @@ private constructor( this.replacesPriceId = replacesPriceId } + /** Configuration for tiered_package_with_minimum pricing */ fun tieredPackageWithMinimumConfig( tieredPackageWithMinimumConfig: TieredPackageWithMinimumConfig ) = tieredPackageWithMinimumConfig(JsonField.of(tieredPackageWithMinimumConfig)) @@ -19672,16 +21181,69 @@ private constructor( override fun toString() = value.toString() } + /** Configuration for tiered_package_with_minimum pricing */ class TieredPackageWithMinimumConfig - @JsonCreator private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map + private val packageSize: JsonField, + private val tiers: JsonField>, + private val additionalProperties: MutableMap, ) { + @JsonCreator + private constructor( + @JsonProperty("package_size") + @ExcludeMissing + packageSize: JsonField = JsonMissing.of(), + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of(), + ) : this(packageSize, tiers, mutableMapOf()) + + /** + * Package size + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun packageSize(): Double = packageSize.getRequired("package_size") + + /** + * Apply tiered pricing after rounding up the quantity to the package size. Tiers are + * defined using exclusive lower bounds. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun tiers(): List = tiers.getRequired("tiers") + + /** + * Returns the raw JSON value of [packageSize]. + * + * Unlike [packageSize], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("package_size") + @ExcludeMissing + fun _packageSize(): JsonField = packageSize + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tiers") @ExcludeMissing fun _tiers(): JsonField> = tiers + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) fun toBuilder() = Builder().from(this) @@ -19690,6 +21252,12 @@ private constructor( /** * Returns a mutable builder for constructing an instance of * [TieredPackageWithMinimumConfig]. + * + * The following fields are required: + * ```kotlin + * .packageSize() + * .tiers() + * ``` */ fun builder() = Builder() } @@ -19697,14 +21265,61 @@ private constructor( /** A builder for [TieredPackageWithMinimumConfig]. */ class Builder internal constructor() { + private var packageSize: JsonField? = null + private var tiers: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(tieredPackageWithMinimumConfig: TieredPackageWithMinimumConfig) = apply { + packageSize = tieredPackageWithMinimumConfig.packageSize + tiers = tieredPackageWithMinimumConfig.tiers.map { it.toMutableList() } additionalProperties = tieredPackageWithMinimumConfig.additionalProperties.toMutableMap() } + /** Package size */ + fun packageSize(packageSize: Double) = packageSize(JsonField.of(packageSize)) + + /** + * Sets [Builder.packageSize] to an arbitrary JSON value. + * + * You should usually call [Builder.packageSize] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun packageSize(packageSize: JsonField) = apply { + this.packageSize = packageSize + } + + /** + * Apply tiered pricing after rounding up the quantity to the package size. Tiers + * are defined using exclusive lower bounds. + */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -19731,9 +21346,21 @@ private constructor( * Returns an immutable instance of [TieredPackageWithMinimumConfig]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .packageSize() + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ fun build(): TieredPackageWithMinimumConfig = - TieredPackageWithMinimumConfig(additionalProperties.toImmutable()) + TieredPackageWithMinimumConfig( + checkRequired("packageSize", packageSize), + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false @@ -19743,6 +21370,8 @@ private constructor( return@apply } + packageSize() + tiers().forEach { it.validate() } validated = true } @@ -19761,7 +21390,270 @@ private constructor( * Used for best match union deserialization. */ internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + (if (packageSize.asKnown() == null) 0 else 1) + + (tiers.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single tier */ + class Tier + private constructor( + private val minimumAmount: JsonField, + private val perUnit: JsonField, + private val tierLowerBound: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("minimum_amount") + @ExcludeMissing + minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("per_unit") + @ExcludeMissing + perUnit: JsonField = JsonMissing.of(), + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + ) : this(minimumAmount, perUnit, tierLowerBound, mutableMapOf()) + + /** + * Minimum amount + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") + + /** + * Price per package + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun perUnit(): String = perUnit.getRequired("per_unit") + + /** + * Tier lower bound + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun tierLowerBound(): String = tierLowerBound.getRequired("tier_lower_bound") + + /** + * Returns the raw JSON value of [minimumAmount]. + * + * Unlike [minimumAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount + + /** + * Returns the raw JSON value of [perUnit]. + * + * Unlike [perUnit], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("per_unit") + @ExcludeMissing + fun _perUnit(): JsonField = perUnit + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Tier]. + * + * The following fields are required: + * ```kotlin + * .minimumAmount() + * .perUnit() + * .tierLowerBound() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var minimumAmount: JsonField? = null + private var perUnit: JsonField? = null + private var tierLowerBound: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(tier: Tier) = apply { + minimumAmount = tier.minimumAmount + perUnit = tier.perUnit + tierLowerBound = tier.tierLowerBound + additionalProperties = tier.additionalProperties.toMutableMap() + } + + /** Minimum amount */ + fun minimumAmount(minimumAmount: String) = + minimumAmount(JsonField.of(minimumAmount)) + + /** + * Sets [Builder.minimumAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumAmount] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount + } + + /** Price per package */ + fun perUnit(perUnit: String) = perUnit(JsonField.of(perUnit)) + + /** + * Sets [Builder.perUnit] to an arbitrary JSON value. + * + * You should usually call [Builder.perUnit] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun perUnit(perUnit: JsonField) = apply { this.perUnit = perUnit } + + /** Tier lower bound */ + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Tier]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .minimumAmount() + * .perUnit() + * .tierLowerBound() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("minimumAmount", minimumAmount), + checkRequired("perUnit", perUnit), + checkRequired("tierLowerBound", tierLowerBound), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + minimumAmount() + perUnit() + tierLowerBound() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (minimumAmount.asKnown() == null) 0 else 1) + + (if (perUnit.asKnown() == null) 0 else 1) + + (if (tierLowerBound.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + minimumAmount == other.minimumAmount && + perUnit == other.perUnit && + tierLowerBound == other.tierLowerBound && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(minimumAmount, perUnit, tierLowerBound, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{minimumAmount=$minimumAmount, perUnit=$perUnit, tierLowerBound=$tierLowerBound, additionalProperties=$additionalProperties}" + } override fun equals(other: Any?): Boolean { if (this === other) { @@ -19769,15 +21661,19 @@ private constructor( } return other is TieredPackageWithMinimumConfig && + packageSize == other.packageSize && + tiers == other.tiers && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + private val hashCode: Int by lazy { + Objects.hash(packageSize, tiers, additionalProperties) + } override fun hashCode(): Int = hashCode override fun toString() = - "TieredPackageWithMinimumConfig{additionalProperties=$additionalProperties}" + "TieredPackageWithMinimumConfig{packageSize=$packageSize, tiers=$tiers, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { @@ -20119,6 +22015,8 @@ private constructor( fun minimumAmount(): String? = minimumAmount.getNullable("minimum_amount") /** + * The pricing model type + * * Expected to always return the following: * ```kotlin * JsonValue.from("package_with_allocation") @@ -20136,6 +22034,8 @@ private constructor( fun name(): String = name.getRequired("name") /** + * Configuration for package_with_allocation pricing + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ @@ -20974,6 +22874,7 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } + /** Configuration for package_with_allocation pricing */ fun packageWithAllocationConfig( packageWithAllocationConfig: PackageWithAllocationConfig ) = packageWithAllocationConfig(JsonField.of(packageWithAllocationConfig)) @@ -21485,16 +23386,94 @@ private constructor( override fun toString() = "Metadata{additionalProperties=$additionalProperties}" } + /** Configuration for package_with_allocation pricing */ class PackageWithAllocationConfig - @JsonCreator private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map + private val allocation: JsonField, + private val packageAmount: JsonField, + private val packageSize: JsonField, + private val additionalProperties: MutableMap, ) { + @JsonCreator + private constructor( + @JsonProperty("allocation") + @ExcludeMissing + allocation: JsonField = JsonMissing.of(), + @JsonProperty("package_amount") + @ExcludeMissing + packageAmount: JsonField = JsonMissing.of(), + @JsonProperty("package_size") + @ExcludeMissing + packageSize: JsonField = JsonMissing.of(), + ) : this(allocation, packageAmount, packageSize, mutableMapOf()) + + /** + * Usage allocation + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun allocation(): String = allocation.getRequired("allocation") + + /** + * Price per package + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun packageAmount(): String = packageAmount.getRequired("package_amount") + + /** + * Package size + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun packageSize(): String = packageSize.getRequired("package_size") + + /** + * Returns the raw JSON value of [allocation]. + * + * Unlike [allocation], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("allocation") + @ExcludeMissing + fun _allocation(): JsonField = allocation + + /** + * Returns the raw JSON value of [packageAmount]. + * + * Unlike [packageAmount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("package_amount") + @ExcludeMissing + fun _packageAmount(): JsonField = packageAmount + + /** + * Returns the raw JSON value of [packageSize]. + * + * Unlike [packageSize], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("package_size") + @ExcludeMissing + fun _packageSize(): JsonField = packageSize + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) fun toBuilder() = Builder().from(this) @@ -21503,6 +23482,13 @@ private constructor( /** * Returns a mutable builder for constructing an instance of * [PackageWithAllocationConfig]. + * + * The following fields are required: + * ```kotlin + * .allocation() + * .packageAmount() + * .packageSize() + * ``` */ fun builder() = Builder() } @@ -21510,14 +23496,63 @@ private constructor( /** A builder for [PackageWithAllocationConfig]. */ class Builder internal constructor() { + private var allocation: JsonField? = null + private var packageAmount: JsonField? = null + private var packageSize: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(packageWithAllocationConfig: PackageWithAllocationConfig) = apply { + allocation = packageWithAllocationConfig.allocation + packageAmount = packageWithAllocationConfig.packageAmount + packageSize = packageWithAllocationConfig.packageSize additionalProperties = packageWithAllocationConfig.additionalProperties.toMutableMap() } + /** Usage allocation */ + fun allocation(allocation: String) = allocation(JsonField.of(allocation)) + + /** + * Sets [Builder.allocation] to an arbitrary JSON value. + * + * You should usually call [Builder.allocation] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun allocation(allocation: JsonField) = apply { + this.allocation = allocation + } + + /** Price per package */ + fun packageAmount(packageAmount: String) = + packageAmount(JsonField.of(packageAmount)) + + /** + * Sets [Builder.packageAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.packageAmount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun packageAmount(packageAmount: JsonField) = apply { + this.packageAmount = packageAmount + } + + /** Package size */ + fun packageSize(packageSize: String) = packageSize(JsonField.of(packageSize)) + + /** + * Sets [Builder.packageSize] to an arbitrary JSON value. + * + * You should usually call [Builder.packageSize] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun packageSize(packageSize: JsonField) = apply { + this.packageSize = packageSize + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -21544,9 +23579,23 @@ private constructor( * Returns an immutable instance of [PackageWithAllocationConfig]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .allocation() + * .packageAmount() + * .packageSize() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ fun build(): PackageWithAllocationConfig = - PackageWithAllocationConfig(additionalProperties.toImmutable()) + PackageWithAllocationConfig( + checkRequired("allocation", allocation), + checkRequired("packageAmount", packageAmount), + checkRequired("packageSize", packageSize), + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false @@ -21556,6 +23605,9 @@ private constructor( return@apply } + allocation() + packageAmount() + packageSize() validated = true } @@ -21574,7 +23626,9 @@ private constructor( * Used for best match union deserialization. */ internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + (if (allocation.asKnown() == null) 0 else 1) + + (if (packageAmount.asKnown() == null) 0 else 1) + + (if (packageSize.asKnown() == null) 0 else 1) override fun equals(other: Any?): Boolean { if (this === other) { @@ -21582,15 +23636,20 @@ private constructor( } return other is PackageWithAllocationConfig && + allocation == other.allocation && + packageAmount == other.packageAmount && + packageSize == other.packageSize && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + private val hashCode: Int by lazy { + Objects.hash(allocation, packageAmount, packageSize, additionalProperties) + } override fun hashCode(): Int = hashCode override fun toString() = - "PackageWithAllocationConfig{additionalProperties=$additionalProperties}" + "PackageWithAllocationConfig{allocation=$allocation, packageAmount=$packageAmount, packageSize=$packageSize, additionalProperties=$additionalProperties}" } class PriceType @JsonCreator private constructor(private val value: JsonField) : @@ -22061,6 +24120,8 @@ private constructor( fun minimumAmount(): String? = minimumAmount.getNullable("minimum_amount") /** + * The pricing model type + * * Expected to always return the following: * ```kotlin * JsonValue.from("unit_with_percent") @@ -22099,6 +24160,8 @@ private constructor( fun replacesPriceId(): String? = replacesPriceId.getNullable("replaces_price_id") /** + * Configuration for unit_with_percent pricing + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ @@ -22965,6 +25028,7 @@ private constructor( this.replacesPriceId = replacesPriceId } + /** Configuration for unit_with_percent pricing */ fun unitWithPercentConfig(unitWithPercentConfig: UnitWithPercentConfig) = unitWithPercentConfig(JsonField.of(unitWithPercentConfig)) @@ -23555,16 +25619,68 @@ private constructor( override fun toString() = value.toString() } + /** Configuration for unit_with_percent pricing */ class UnitWithPercentConfig - @JsonCreator private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map + private val percent: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, ) { + @JsonCreator + private constructor( + @JsonProperty("percent") + @ExcludeMissing + percent: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(percent, unitAmount, mutableMapOf()) + + /** + * What percent, out of 100, of the calculated total to charge + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun percent(): String = percent.getRequired("percent") + + /** + * Rate per unit of usage + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [percent]. + * + * Unlike [percent], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("percent") @ExcludeMissing fun _percent(): JsonField = percent + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) fun toBuilder() = Builder().from(this) @@ -23573,6 +25689,12 @@ private constructor( /** * Returns a mutable builder for constructing an instance of * [UnitWithPercentConfig]. + * + * The following fields are required: + * ```kotlin + * .percent() + * .unitAmount() + * ``` */ fun builder() = Builder() } @@ -23580,12 +25702,42 @@ private constructor( /** A builder for [UnitWithPercentConfig]. */ class Builder internal constructor() { + private var percent: JsonField? = null + private var unitAmount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(unitWithPercentConfig: UnitWithPercentConfig) = apply { + percent = unitWithPercentConfig.percent + unitAmount = unitWithPercentConfig.unitAmount additionalProperties = unitWithPercentConfig.additionalProperties.toMutableMap() } + /** What percent, out of 100, of the calculated total to charge */ + fun percent(percent: String) = percent(JsonField.of(percent)) + + /** + * Sets [Builder.percent] to an arbitrary JSON value. + * + * You should usually call [Builder.percent] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun percent(percent: JsonField) = apply { this.percent = percent } + + /** Rate per unit of usage */ + fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -23612,9 +25764,21 @@ private constructor( * Returns an immutable instance of [UnitWithPercentConfig]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .percent() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ fun build(): UnitWithPercentConfig = - UnitWithPercentConfig(additionalProperties.toImmutable()) + UnitWithPercentConfig( + checkRequired("percent", percent), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false @@ -23624,6 +25788,8 @@ private constructor( return@apply } + percent() + unitAmount() validated = true } @@ -23642,7 +25808,8 @@ private constructor( * Used for best match union deserialization. */ internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + (if (percent.asKnown() == null) 0 else 1) + + (if (unitAmount.asKnown() == null) 0 else 1) override fun equals(other: Any?): Boolean { if (this === other) { @@ -23650,15 +25817,19 @@ private constructor( } return other is UnitWithPercentConfig && + percent == other.percent && + unitAmount == other.unitAmount && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + private val hashCode: Int by lazy { + Objects.hash(percent, unitAmount, additionalProperties) + } override fun hashCode(): Int = hashCode override fun toString() = - "UnitWithPercentConfig{additionalProperties=$additionalProperties}" + "UnitWithPercentConfig{percent=$percent, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { @@ -23964,6 +26135,8 @@ private constructor( fun item(): ItemSlim = item.getRequired("item") /** + * Configuration for matrix_with_allocation pricing + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ @@ -24007,6 +26180,8 @@ private constructor( fun minimumAmount(): String? = minimumAmount.getNullable("minimum_amount") /** + * The pricing model type + * * Expected to always return the following: * ```kotlin * JsonValue.from("matrix_with_allocation") @@ -24756,6 +26931,7 @@ private constructor( */ fun item(item: JsonField) = apply { this.item = item } + /** Configuration for matrix_with_allocation pricing */ fun matrixWithAllocationConfig(matrixWithAllocationConfig: MatrixWithAllocationConfig) = matrixWithAllocationConfig(JsonField.of(matrixWithAllocationConfig)) @@ -25833,6 +28009,8 @@ private constructor( fun minimumAmount(): String? = minimumAmount.getNullable("minimum_amount") /** + * The pricing model type + * * Expected to always return the following: * ```kotlin * JsonValue.from("tiered_with_proration") @@ -25871,6 +28049,8 @@ private constructor( fun replacesPriceId(): String? = replacesPriceId.getNullable("replaces_price_id") /** + * Configuration for tiered_with_proration pricing + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ @@ -26738,6 +28918,7 @@ private constructor( this.replacesPriceId = replacesPriceId } + /** Configuration for tiered_with_proration pricing */ fun tieredWithProrationConfig(tieredWithProrationConfig: TieredWithProrationConfig) = tieredWithProrationConfig(JsonField.of(tieredWithProrationConfig)) @@ -27327,16 +29508,46 @@ private constructor( override fun toString() = value.toString() } + /** Configuration for tiered_with_proration pricing */ class TieredWithProrationConfig - @JsonCreator private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map + private val tiers: JsonField>, + private val additionalProperties: MutableMap, ) { + @JsonCreator + private constructor( + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of() + ) : this(tiers, mutableMapOf()) + + /** + * Tiers for rating based on total usage quantities into the specified tier with + * proration + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun tiers(): List = tiers.getRequired("tiers") + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tiers") @ExcludeMissing fun _tiers(): JsonField> = tiers + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) fun toBuilder() = Builder().from(this) @@ -27345,6 +29556,11 @@ private constructor( /** * Returns a mutable builder for constructing an instance of * [TieredWithProrationConfig]. + * + * The following fields are required: + * ```kotlin + * .tiers() + * ``` */ fun builder() = Builder() } @@ -27352,13 +29568,44 @@ private constructor( /** A builder for [TieredWithProrationConfig]. */ class Builder internal constructor() { + private var tiers: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(tieredWithProrationConfig: TieredWithProrationConfig) = apply { + tiers = tieredWithProrationConfig.tiers.map { it.toMutableList() } additionalProperties = tieredWithProrationConfig.additionalProperties.toMutableMap() } + /** + * Tiers for rating based on total usage quantities into the specified tier with + * proration + */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -27385,9 +29632,19 @@ private constructor( * Returns an immutable instance of [TieredWithProrationConfig]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ fun build(): TieredWithProrationConfig = - TieredWithProrationConfig(additionalProperties.toImmutable()) + TieredWithProrationConfig( + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false @@ -27397,6 +29654,7 @@ private constructor( return@apply } + tiers().forEach { it.validate() } validated = true } @@ -27414,8 +29672,225 @@ private constructor( * * Used for best match union deserialization. */ - internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + internal fun validity(): Int = (tiers.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single tiered with proration tier */ + class Tier + private constructor( + private val tierLowerBound: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(tierLowerBound, unitAmount, mutableMapOf()) + + /** + * Inclusive tier starting value + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun tierLowerBound(): String = tierLowerBound.getRequired("tier_lower_bound") + + /** + * Amount per unit + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Tier]. + * + * The following fields are required: + * ```kotlin + * .tierLowerBound() + * .unitAmount() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var tierLowerBound: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(tier: Tier) = apply { + tierLowerBound = tier.tierLowerBound + unitAmount = tier.unitAmount + additionalProperties = tier.additionalProperties.toMutableMap() + } + + /** Inclusive tier starting value */ + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + /** Amount per unit */ + fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Tier]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .tierLowerBound() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("tierLowerBound", tierLowerBound), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + tierLowerBound() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (tierLowerBound.asKnown() == null) 0 else 1) + + (if (unitAmount.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + tierLowerBound == other.tierLowerBound && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(tierLowerBound, unitAmount, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } override fun equals(other: Any?): Boolean { if (this === other) { @@ -27423,15 +29898,16 @@ private constructor( } return other is TieredWithProrationConfig && + tiers == other.tiers && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(tiers, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "TieredWithProrationConfig{additionalProperties=$additionalProperties}" + "TieredWithProrationConfig{tiers=$tiers, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { @@ -27773,6 +30249,8 @@ private constructor( fun minimumAmount(): String? = minimumAmount.getNullable("minimum_amount") /** + * The pricing model type + * * Expected to always return the following: * ```kotlin * JsonValue.from("unit_with_proration") @@ -27811,6 +30289,8 @@ private constructor( fun replacesPriceId(): String? = replacesPriceId.getNullable("replaces_price_id") /** + * Configuration for unit_with_proration pricing + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ @@ -28677,6 +31157,7 @@ private constructor( this.replacesPriceId = replacesPriceId } + /** Configuration for unit_with_proration pricing */ fun unitWithProrationConfig(unitWithProrationConfig: UnitWithProrationConfig) = unitWithProrationConfig(JsonField.of(unitWithProrationConfig)) @@ -29266,16 +31747,48 @@ private constructor( override fun toString() = value.toString() } + /** Configuration for unit_with_proration pricing */ class UnitWithProrationConfig - @JsonCreator private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, ) { + @JsonCreator + private constructor( + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of() + ) : this(unitAmount, mutableMapOf()) + + /** + * Rate per unit of usage + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) fun toBuilder() = Builder().from(this) @@ -29284,6 +31797,11 @@ private constructor( /** * Returns a mutable builder for constructing an instance of * [UnitWithProrationConfig]. + * + * The following fields are required: + * ```kotlin + * .unitAmount() + * ``` */ fun builder() = Builder() } @@ -29291,13 +31809,29 @@ private constructor( /** A builder for [UnitWithProrationConfig]. */ class Builder internal constructor() { + private var unitAmount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(unitWithProrationConfig: UnitWithProrationConfig) = apply { + unitAmount = unitWithProrationConfig.unitAmount additionalProperties = unitWithProrationConfig.additionalProperties.toMutableMap() } + /** Rate per unit of usage */ + fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -29324,9 +31858,19 @@ private constructor( * Returns an immutable instance of [UnitWithProrationConfig]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ fun build(): UnitWithProrationConfig = - UnitWithProrationConfig(additionalProperties.toImmutable()) + UnitWithProrationConfig( + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false @@ -29336,6 +31880,7 @@ private constructor( return@apply } + unitAmount() validated = true } @@ -29353,8 +31898,7 @@ private constructor( * * Used for best match union deserialization. */ - internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + internal fun validity(): Int = (if (unitAmount.asKnown() == null) 0 else 1) override fun equals(other: Any?): Boolean { if (this === other) { @@ -29362,15 +31906,16 @@ private constructor( } return other is UnitWithProrationConfig && + unitAmount == other.unitAmount && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(unitAmount, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "UnitWithProrationConfig{additionalProperties=$additionalProperties}" + "UnitWithProrationConfig{unitAmount=$unitAmount, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { @@ -29663,6 +32208,8 @@ private constructor( fun fixedPriceQuantity(): Double? = fixedPriceQuantity.getNullable("fixed_price_quantity") /** + * Configuration for grouped_allocation pricing + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ @@ -29719,6 +32266,8 @@ private constructor( fun minimumAmount(): String? = minimumAmount.getNullable("minimum_amount") /** + * The pricing model type + * * Expected to always return the following: * ```kotlin * JsonValue.from("grouped_allocation") @@ -30441,6 +32990,7 @@ private constructor( this.fixedPriceQuantity = fixedPriceQuantity } + /** Configuration for grouped_allocation pricing */ fun groupedAllocationConfig(groupedAllocationConfig: GroupedAllocationConfig) = groupedAllocationConfig(JsonField.of(groupedAllocationConfig)) @@ -30971,16 +33521,94 @@ private constructor( override fun toString() = value.toString() } + /** Configuration for grouped_allocation pricing */ class GroupedAllocationConfig - @JsonCreator private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map + private val allocation: JsonField, + private val groupingKey: JsonField, + private val overageUnitRate: JsonField, + private val additionalProperties: MutableMap, ) { + @JsonCreator + private constructor( + @JsonProperty("allocation") + @ExcludeMissing + allocation: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("overage_unit_rate") + @ExcludeMissing + overageUnitRate: JsonField = JsonMissing.of(), + ) : this(allocation, groupingKey, overageUnitRate, mutableMapOf()) + + /** + * Usage allocation per group + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun allocation(): String = allocation.getRequired("allocation") + + /** + * How to determine the groups that should each be allocated some quantity + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * Unit rate for post-allocation + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun overageUnitRate(): String = overageUnitRate.getRequired("overage_unit_rate") + + /** + * Returns the raw JSON value of [allocation]. + * + * Unlike [allocation], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("allocation") + @ExcludeMissing + fun _allocation(): JsonField = allocation + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [overageUnitRate]. + * + * Unlike [overageUnitRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("overage_unit_rate") + @ExcludeMissing + fun _overageUnitRate(): JsonField = overageUnitRate + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) fun toBuilder() = Builder().from(this) @@ -30989,6 +33617,13 @@ private constructor( /** * Returns a mutable builder for constructing an instance of * [GroupedAllocationConfig]. + * + * The following fields are required: + * ```kotlin + * .allocation() + * .groupingKey() + * .overageUnitRate() + * ``` */ fun builder() = Builder() } @@ -30996,13 +33631,62 @@ private constructor( /** A builder for [GroupedAllocationConfig]. */ class Builder internal constructor() { + private var allocation: JsonField? = null + private var groupingKey: JsonField? = null + private var overageUnitRate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(groupedAllocationConfig: GroupedAllocationConfig) = apply { + allocation = groupedAllocationConfig.allocation + groupingKey = groupedAllocationConfig.groupingKey + overageUnitRate = groupedAllocationConfig.overageUnitRate additionalProperties = groupedAllocationConfig.additionalProperties.toMutableMap() } + /** Usage allocation per group */ + fun allocation(allocation: String) = allocation(JsonField.of(allocation)) + + /** + * Sets [Builder.allocation] to an arbitrary JSON value. + * + * You should usually call [Builder.allocation] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun allocation(allocation: JsonField) = apply { + this.allocation = allocation + } + + /** How to determine the groups that should each be allocated some quantity */ + fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** Unit rate for post-allocation */ + fun overageUnitRate(overageUnitRate: String) = + overageUnitRate(JsonField.of(overageUnitRate)) + + /** + * Sets [Builder.overageUnitRate] to an arbitrary JSON value. + * + * You should usually call [Builder.overageUnitRate] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun overageUnitRate(overageUnitRate: JsonField) = apply { + this.overageUnitRate = overageUnitRate + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -31029,9 +33713,23 @@ private constructor( * Returns an immutable instance of [GroupedAllocationConfig]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .allocation() + * .groupingKey() + * .overageUnitRate() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ fun build(): GroupedAllocationConfig = - GroupedAllocationConfig(additionalProperties.toImmutable()) + GroupedAllocationConfig( + checkRequired("allocation", allocation), + checkRequired("groupingKey", groupingKey), + checkRequired("overageUnitRate", overageUnitRate), + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false @@ -31041,6 +33739,9 @@ private constructor( return@apply } + allocation() + groupingKey() + overageUnitRate() validated = true } @@ -31059,7 +33760,9 @@ private constructor( * Used for best match union deserialization. */ internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + (if (allocation.asKnown() == null) 0 else 1) + + (if (groupingKey.asKnown() == null) 0 else 1) + + (if (overageUnitRate.asKnown() == null) 0 else 1) override fun equals(other: Any?): Boolean { if (this === other) { @@ -31067,15 +33770,20 @@ private constructor( } return other is GroupedAllocationConfig && + allocation == other.allocation && + groupingKey == other.groupingKey && + overageUnitRate == other.overageUnitRate && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + private val hashCode: Int by lazy { + Objects.hash(allocation, groupingKey, overageUnitRate, additionalProperties) + } override fun hashCode(): Int = hashCode override fun toString() = - "GroupedAllocationConfig{additionalProperties=$additionalProperties}" + "GroupedAllocationConfig{allocation=$allocation, groupingKey=$groupingKey, overageUnitRate=$overageUnitRate, additionalProperties=$additionalProperties}" } /** @@ -31387,11 +34095,12 @@ private constructor( "GroupedAllocation{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, groupedAllocationConfig=$groupedAllocationConfig, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" } - class GroupedWithProratedMinimum + class BulkWithProration private constructor( private val id: JsonField, private val billableMetric: JsonField, private val billingCycleConfiguration: JsonField, + private val bulkWithProrationConfig: JsonField, private val cadence: JsonField, private val compositePriceFilters: JsonField>, private val conversionRate: JsonField, @@ -31402,7 +34111,6 @@ private constructor( private val discount: JsonField, private val externalPriceId: JsonField, private val fixedPriceQuantity: JsonField, - private val groupedWithProratedMinimumConfig: JsonField, private val invoicingCycleConfiguration: JsonField, private val item: JsonField, private val maximum: JsonField, @@ -31428,6 +34136,9 @@ private constructor( @JsonProperty("billing_cycle_configuration") @ExcludeMissing billingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("bulk_with_proration_config") + @ExcludeMissing + bulkWithProrationConfig: JsonField = JsonMissing.of(), @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), @JsonProperty("composite_price_filters") @ExcludeMissing @@ -31456,10 +34167,6 @@ private constructor( @JsonProperty("fixed_price_quantity") @ExcludeMissing fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("grouped_with_prorated_minimum_config") - @ExcludeMissing - groupedWithProratedMinimumConfig: JsonField = - JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), @@ -31494,6 +34201,7 @@ private constructor( id, billableMetric, billingCycleConfiguration, + bulkWithProrationConfig, cadence, compositePriceFilters, conversionRate, @@ -31504,7 +34212,6 @@ private constructor( discount, externalPriceId, fixedPriceQuantity, - groupedWithProratedMinimumConfig, invoicingCycleConfiguration, item, maximum, @@ -31540,6 +34247,15 @@ private constructor( fun billingCycleConfiguration(): BillingCycleConfiguration = billingCycleConfiguration.getRequired("billing_cycle_configuration") + /** + * Configuration for bulk_with_proration pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun bulkWithProrationConfig(): BulkWithProrationConfig = + bulkWithProrationConfig.getRequired("bulk_with_proration_config") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). @@ -31602,13 +34318,6 @@ private constructor( */ fun fixedPriceQuantity(): Double? = fixedPriceQuantity.getNullable("fixed_price_quantity") - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun groupedWithProratedMinimumConfig(): GroupedWithProratedMinimumConfig = - groupedWithProratedMinimumConfig.getRequired("grouped_with_prorated_minimum_config") - /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -31659,9 +34368,11 @@ private constructor( fun minimumAmount(): String? = minimumAmount.getNullable("minimum_amount") /** + * The pricing model type + * * Expected to always return the following: * ```kotlin - * JsonValue.from("grouped_with_prorated_minimum") + * JsonValue.from("bulk_with_proration") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -31731,6 +34442,16 @@ private constructor( fun _billingCycleConfiguration(): JsonField = billingCycleConfiguration + /** + * Returns the raw JSON value of [bulkWithProrationConfig]. + * + * Unlike [bulkWithProrationConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("bulk_with_proration_config") + @ExcludeMissing + fun _bulkWithProrationConfig(): JsonField = bulkWithProrationConfig + /** * Returns the raw JSON value of [cadence]. * @@ -31824,17 +34545,6 @@ private constructor( @ExcludeMissing fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - /** - * Returns the raw JSON value of [groupedWithProratedMinimumConfig]. - * - * Unlike [groupedWithProratedMinimumConfig], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("grouped_with_prorated_minimum_config") - @ExcludeMissing - fun _groupedWithProratedMinimumConfig(): JsonField = - groupedWithProratedMinimumConfig - /** * Returns the raw JSON value of [invoicingCycleConfiguration]. * @@ -31964,14 +34674,14 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [GroupedWithProratedMinimum]. + * Returns a mutable builder for constructing an instance of [BulkWithProration]. * * The following fields are required: * ```kotlin * .id() * .billableMetric() * .billingCycleConfiguration() + * .bulkWithProrationConfig() * .cadence() * .compositePriceFilters() * .conversionRate() @@ -31982,7 +34692,6 @@ private constructor( * .discount() * .externalPriceId() * .fixedPriceQuantity() - * .groupedWithProratedMinimumConfig() * .invoicingCycleConfiguration() * .item() * .maximum() @@ -31999,12 +34708,13 @@ private constructor( fun builder() = Builder() } - /** A builder for [GroupedWithProratedMinimum]. */ + /** A builder for [BulkWithProration]. */ class Builder internal constructor() { private var id: JsonField? = null private var billableMetric: JsonField? = null private var billingCycleConfiguration: JsonField? = null + private var bulkWithProrationConfig: JsonField? = null private var cadence: JsonField? = null private var compositePriceFilters: JsonField>? = null private var conversionRate: JsonField? = null @@ -32015,9 +34725,6 @@ private constructor( private var discount: JsonField? = null private var externalPriceId: JsonField? = null private var fixedPriceQuantity: JsonField? = null - private var groupedWithProratedMinimumConfig: - JsonField? = - null private var invoicingCycleConfiguration: JsonField? = null private var item: JsonField? = null private var maximum: JsonField? = null @@ -32025,7 +34732,7 @@ private constructor( private var metadata: JsonField? = null private var minimum: JsonField? = null private var minimumAmount: JsonField? = null - private var modelType: JsonValue = JsonValue.from("grouped_with_prorated_minimum") + private var modelType: JsonValue = JsonValue.from("bulk_with_proration") private var name: JsonField? = null private var planPhaseOrder: JsonField? = null private var priceType: JsonField? = null @@ -32034,39 +34741,36 @@ private constructor( JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(groupedWithProratedMinimum: GroupedWithProratedMinimum) = apply { - id = groupedWithProratedMinimum.id - billableMetric = groupedWithProratedMinimum.billableMetric - billingCycleConfiguration = groupedWithProratedMinimum.billingCycleConfiguration - cadence = groupedWithProratedMinimum.cadence + internal fun from(bulkWithProration: BulkWithProration) = apply { + id = bulkWithProration.id + billableMetric = bulkWithProration.billableMetric + billingCycleConfiguration = bulkWithProration.billingCycleConfiguration + bulkWithProrationConfig = bulkWithProration.bulkWithProrationConfig + cadence = bulkWithProration.cadence compositePriceFilters = - groupedWithProratedMinimum.compositePriceFilters.map { it.toMutableList() } - conversionRate = groupedWithProratedMinimum.conversionRate - conversionRateConfig = groupedWithProratedMinimum.conversionRateConfig - createdAt = groupedWithProratedMinimum.createdAt - creditAllocation = groupedWithProratedMinimum.creditAllocation - currency = groupedWithProratedMinimum.currency - discount = groupedWithProratedMinimum.discount - externalPriceId = groupedWithProratedMinimum.externalPriceId - fixedPriceQuantity = groupedWithProratedMinimum.fixedPriceQuantity - groupedWithProratedMinimumConfig = - groupedWithProratedMinimum.groupedWithProratedMinimumConfig - invoicingCycleConfiguration = groupedWithProratedMinimum.invoicingCycleConfiguration - item = groupedWithProratedMinimum.item - maximum = groupedWithProratedMinimum.maximum - maximumAmount = groupedWithProratedMinimum.maximumAmount - metadata = groupedWithProratedMinimum.metadata - minimum = groupedWithProratedMinimum.minimum - minimumAmount = groupedWithProratedMinimum.minimumAmount - modelType = groupedWithProratedMinimum.modelType - name = groupedWithProratedMinimum.name - planPhaseOrder = groupedWithProratedMinimum.planPhaseOrder - priceType = groupedWithProratedMinimum.priceType - replacesPriceId = groupedWithProratedMinimum.replacesPriceId - dimensionalPriceConfiguration = - groupedWithProratedMinimum.dimensionalPriceConfiguration - additionalProperties = - groupedWithProratedMinimum.additionalProperties.toMutableMap() + bulkWithProration.compositePriceFilters.map { it.toMutableList() } + conversionRate = bulkWithProration.conversionRate + conversionRateConfig = bulkWithProration.conversionRateConfig + createdAt = bulkWithProration.createdAt + creditAllocation = bulkWithProration.creditAllocation + currency = bulkWithProration.currency + discount = bulkWithProration.discount + externalPriceId = bulkWithProration.externalPriceId + fixedPriceQuantity = bulkWithProration.fixedPriceQuantity + invoicingCycleConfiguration = bulkWithProration.invoicingCycleConfiguration + item = bulkWithProration.item + maximum = bulkWithProration.maximum + maximumAmount = bulkWithProration.maximumAmount + metadata = bulkWithProration.metadata + minimum = bulkWithProration.minimum + minimumAmount = bulkWithProration.minimumAmount + modelType = bulkWithProration.modelType + name = bulkWithProration.name + planPhaseOrder = bulkWithProration.planPhaseOrder + priceType = bulkWithProration.priceType + replacesPriceId = bulkWithProration.replacesPriceId + dimensionalPriceConfiguration = bulkWithProration.dimensionalPriceConfiguration + additionalProperties = bulkWithProration.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) @@ -32108,6 +34812,21 @@ private constructor( billingCycleConfiguration: JsonField ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + /** Configuration for bulk_with_proration pricing */ + fun bulkWithProrationConfig(bulkWithProrationConfig: BulkWithProrationConfig) = + bulkWithProrationConfig(JsonField.of(bulkWithProrationConfig)) + + /** + * Sets [Builder.bulkWithProrationConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.bulkWithProrationConfig] with a well-typed + * [BulkWithProrationConfig] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun bulkWithProrationConfig( + bulkWithProrationConfig: JsonField + ) = apply { this.bulkWithProrationConfig = bulkWithProrationConfig } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) /** @@ -32388,21 +35107,6 @@ private constructor( this.fixedPriceQuantity = fixedPriceQuantity } - fun groupedWithProratedMinimumConfig( - groupedWithProratedMinimumConfig: GroupedWithProratedMinimumConfig - ) = groupedWithProratedMinimumConfig(JsonField.of(groupedWithProratedMinimumConfig)) - - /** - * Sets [Builder.groupedWithProratedMinimumConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.groupedWithProratedMinimumConfig] with a well-typed - * [GroupedWithProratedMinimumConfig] value instead. This method is primarily for - * setting the field to an undocumented or not yet supported value. - */ - fun groupedWithProratedMinimumConfig( - groupedWithProratedMinimumConfig: JsonField - ) = apply { this.groupedWithProratedMinimumConfig = groupedWithProratedMinimumConfig } - fun invoicingCycleConfiguration( invoicingCycleConfiguration: BillingCycleConfiguration? ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) @@ -32509,7 +35213,7 @@ private constructor( * It is usually unnecessary to call this method because the field defaults to the * following: * ```kotlin - * JsonValue.from("grouped_with_prorated_minimum") + * JsonValue.from("bulk_with_proration") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -32613,7 +35317,7 @@ private constructor( } /** - * Returns an immutable instance of [GroupedWithProratedMinimum]. + * Returns an immutable instance of [BulkWithProration]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -32622,6 +35326,7 @@ private constructor( * .id() * .billableMetric() * .billingCycleConfiguration() + * .bulkWithProrationConfig() * .cadence() * .compositePriceFilters() * .conversionRate() @@ -32632,7 +35337,6 @@ private constructor( * .discount() * .externalPriceId() * .fixedPriceQuantity() - * .groupedWithProratedMinimumConfig() * .invoicingCycleConfiguration() * .item() * .maximum() @@ -32648,11 +35352,12 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): GroupedWithProratedMinimum = - GroupedWithProratedMinimum( + fun build(): BulkWithProration = + BulkWithProration( checkRequired("id", id), checkRequired("billableMetric", billableMetric), checkRequired("billingCycleConfiguration", billingCycleConfiguration), + checkRequired("bulkWithProrationConfig", bulkWithProrationConfig), checkRequired("cadence", cadence), checkRequired("compositePriceFilters", compositePriceFilters).map { it.toImmutable() @@ -32665,10 +35370,6 @@ private constructor( checkRequired("discount", discount), checkRequired("externalPriceId", externalPriceId), checkRequired("fixedPriceQuantity", fixedPriceQuantity), - checkRequired( - "groupedWithProratedMinimumConfig", - groupedWithProratedMinimumConfig, - ), checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), checkRequired("item", item), checkRequired("maximum", maximum), @@ -32688,7 +35389,7 @@ private constructor( private var validated: Boolean = false - fun validate(): GroupedWithProratedMinimum = apply { + fun validate(): BulkWithProration = apply { if (validated) { return@apply } @@ -32696,6 +35397,7 @@ private constructor( id() billableMetric()?.validate() billingCycleConfiguration().validate() + bulkWithProrationConfig().validate() cadence().validate() compositePriceFilters()?.forEach { it.validate() } conversionRate() @@ -32706,7 +35408,6 @@ private constructor( discount()?.validate() externalPriceId() fixedPriceQuantity() - groupedWithProratedMinimumConfig().validate() invoicingCycleConfiguration()?.validate() item().validate() maximum()?.validate() @@ -32715,7 +35416,7 @@ private constructor( minimum()?.validate() minimumAmount() _modelType().let { - if (it != JsonValue.from("grouped_with_prorated_minimum")) { + if (it != JsonValue.from("bulk_with_proration")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } @@ -32745,6 +35446,7 @@ private constructor( (if (id.asKnown() == null) 0 else 1) + (billableMetric.asKnown()?.validity() ?: 0) + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (bulkWithProrationConfig.asKnown()?.validity() ?: 0) + (cadence.asKnown()?.validity() ?: 0) + (compositePriceFilters.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + (if (conversionRate.asKnown() == null) 0 else 1) + @@ -32755,7 +35457,6 @@ private constructor( (discount.asKnown()?.validity() ?: 0) + (if (externalPriceId.asKnown() == null) 0 else 1) + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + - (groupedWithProratedMinimumConfig.asKnown()?.validity() ?: 0) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + (item.asKnown()?.validity() ?: 0) + (maximum.asKnown()?.validity() ?: 0) + @@ -32763,177 +35464,52 @@ private constructor( (metadata.asKnown()?.validity() ?: 0) + (minimum.asKnown()?.validity() ?: 0) + (if (minimumAmount.asKnown() == null) 0 else 1) + - modelType.let { - if (it == JsonValue.from("grouped_with_prorated_minimum")) 1 else 0 - } + + modelType.let { if (it == JsonValue.from("bulk_with_proration")) 1 else 0 } + (if (name.asKnown() == null) 0 else 1) + (if (planPhaseOrder.asKnown() == null) 0 else 1) + (priceType.asKnown()?.validity() ?: 0) + (if (replacesPriceId.asKnown() == null) 0 else 1) + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) - class Cadence @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - val ONE_TIME = of("one_time") - - val MONTHLY = of("monthly") - - val QUARTERLY = of("quarterly") - - val SEMI_ANNUAL = of("semi_annual") - - val ANNUAL = of("annual") - - val CUSTOM = of("custom") - - fun of(value: String) = Cadence(JsonField.of(value)) - } - - /** An enum containing [Cadence]'s known values. */ - enum class Known { - ONE_TIME, - MONTHLY, - QUARTERLY, - SEMI_ANNUAL, - ANNUAL, - CUSTOM, - } - - /** - * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Cadence] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - ONE_TIME, - MONTHLY, - QUARTERLY, - SEMI_ANNUAL, - ANNUAL, - CUSTOM, - /** - * An enum member indicating that [Cadence] was instantiated with an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - ONE_TIME -> Value.ONE_TIME - MONTHLY -> Value.MONTHLY - QUARTERLY -> Value.QUARTERLY - SEMI_ANNUAL -> Value.SEMI_ANNUAL - ANNUAL -> Value.ANNUAL - CUSTOM -> Value.CUSTOM - else -> Value._UNKNOWN - } + /** Configuration for bulk_with_proration pricing */ + class BulkWithProrationConfig + private constructor( + private val tiers: JsonField>, + private val additionalProperties: MutableMap, + ) { - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - ONE_TIME -> Known.ONE_TIME - MONTHLY -> Known.MONTHLY - QUARTERLY -> Known.QUARTERLY - SEMI_ANNUAL -> Known.SEMI_ANNUAL - ANNUAL -> Known.ANNUAL - CUSTOM -> Known.CUSTOM - else -> throw OrbInvalidDataException("Unknown Cadence: $value") - } + @JsonCreator + private constructor( + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of() + ) : this(tiers, mutableMapOf()) /** - * Returns this class instance's primitive wire representation. + * Bulk tiers for rating based on total usage volume * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). */ - fun asString(): String = - _value().asString() ?: throw OrbInvalidDataException("Value is not a String") - - private var validated: Boolean = false - - fun validate(): Cadence = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + fun tiers(): List = tiers.getRequired("tiers") /** - * Returns a score indicating how many valid values are contained in this object - * recursively. + * Returns the raw JSON value of [tiers]. * - * Used for best match union deserialization. + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected type. */ - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + @JsonProperty("tiers") @ExcludeMissing fun _tiers(): JsonField> = tiers - return other is Cadence && value == other.value + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) } - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class GroupedWithProratedMinimumConfig - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) fun toBuilder() = Builder().from(this) @@ -32941,21 +35517,52 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [GroupedWithProratedMinimumConfig]. + * [BulkWithProrationConfig]. + * + * The following fields are required: + * ```kotlin + * .tiers() + * ``` */ fun builder() = Builder() } - /** A builder for [GroupedWithProratedMinimumConfig]. */ + /** A builder for [BulkWithProrationConfig]. */ class Builder internal constructor() { + private var tiers: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() - internal fun from( - groupedWithProratedMinimumConfig: GroupedWithProratedMinimumConfig - ) = apply { + internal fun from(bulkWithProrationConfig: BulkWithProrationConfig) = apply { + tiers = bulkWithProrationConfig.tiers.map { it.toMutableList() } additionalProperties = - groupedWithProratedMinimumConfig.additionalProperties.toMutableMap() + bulkWithProrationConfig.additionalProperties.toMutableMap() + } + + /** Bulk tiers for rating based on total usage volume */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } } fun additionalProperties(additionalProperties: Map) = apply { @@ -32981,21 +35588,32 @@ private constructor( } /** - * Returns an immutable instance of [GroupedWithProratedMinimumConfig]. + * Returns an immutable instance of [BulkWithProrationConfig]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ - fun build(): GroupedWithProratedMinimumConfig = - GroupedWithProratedMinimumConfig(additionalProperties.toImmutable()) + fun build(): BulkWithProrationConfig = + BulkWithProrationConfig( + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false - fun validate(): GroupedWithProratedMinimumConfig = apply { + fun validate(): BulkWithProrationConfig = apply { if (validated) { return@apply } + tiers().forEach { it.validate() } validated = true } @@ -33013,24 +35631,391 @@ private constructor( * * Used for best match union deserialization. */ - internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + internal fun validity(): Int = (tiers.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single bulk pricing tier with proration */ + class Tier + private constructor( + private val unitAmount: JsonField, + private val tierLowerBound: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + ) : this(unitAmount, tierLowerBound, mutableMapOf()) + + /** + * Cost per unit + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * The lower bound for this tier + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun tierLowerBound(): String? = tierLowerBound.getNullable("tier_lower_bound") + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Tier]. + * + * The following fields are required: + * ```kotlin + * .unitAmount() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var unitAmount: JsonField? = null + private var tierLowerBound: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(tier: Tier) = apply { + unitAmount = tier.unitAmount + tierLowerBound = tier.tierLowerBound + additionalProperties = tier.additionalProperties.toMutableMap() + } + + /** Cost per unit */ + fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + /** The lower bound for this tier */ + fun tierLowerBound(tierLowerBound: String?) = + tierLowerBound(JsonField.ofNullable(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Tier]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("unitAmount", unitAmount), + tierLowerBound, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + unitAmount() + tierLowerBound() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (unitAmount.asKnown() == null) 0 else 1) + + (if (tierLowerBound.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + unitAmount == other.unitAmount && + tierLowerBound == other.tierLowerBound && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(unitAmount, tierLowerBound, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{unitAmount=$unitAmount, tierLowerBound=$tierLowerBound, additionalProperties=$additionalProperties}" + } override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is GroupedWithProratedMinimumConfig && + return other is BulkWithProrationConfig && + tiers == other.tiers && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(tiers, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "GroupedWithProratedMinimumConfig{additionalProperties=$additionalProperties}" + "BulkWithProrationConfig{tiers=$tiers, additionalProperties=$additionalProperties}" + } + + class Cadence @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val ONE_TIME = of("one_time") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val SEMI_ANNUAL = of("semi_annual") + + val ANNUAL = of("annual") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ONE_TIME, + MONTHLY, + QUARTERLY, + SEMI_ANNUAL, + ANNUAL, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ONE_TIME, + MONTHLY, + QUARTERLY, + SEMI_ANNUAL, + ANNUAL, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ONE_TIME -> Value.ONE_TIME + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + SEMI_ANNUAL -> Value.SEMI_ANNUAL + ANNUAL -> Value.ANNUAL + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + ONE_TIME -> Known.ONE_TIME + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + SEMI_ANNUAL -> Known.SEMI_ANNUAL + ANNUAL -> Known.ANNUAL + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() } /** @@ -33272,10 +36257,11 @@ private constructor( return true } - return other is GroupedWithProratedMinimum && + return other is BulkWithProration && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && + bulkWithProrationConfig == other.bulkWithProrationConfig && cadence == other.cadence && compositePriceFilters == other.compositePriceFilters && conversionRate == other.conversionRate && @@ -33286,7 +36272,6 @@ private constructor( discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && - groupedWithProratedMinimumConfig == other.groupedWithProratedMinimumConfig && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maximum == other.maximum && @@ -33308,6 +36293,7 @@ private constructor( id, billableMetric, billingCycleConfiguration, + bulkWithProrationConfig, cadence, compositePriceFilters, conversionRate, @@ -33318,7 +36304,6 @@ private constructor( discount, externalPriceId, fixedPriceQuantity, - groupedWithProratedMinimumConfig, invoicingCycleConfiguration, item, maximum, @@ -33339,10 +36324,10 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "GroupedWithProratedMinimum{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, groupedWithProratedMinimumConfig=$groupedWithProratedMinimumConfig, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "BulkWithProration{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, bulkWithProrationConfig=$bulkWithProrationConfig, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" } - class GroupedWithMeteredMinimum + class GroupedWithProratedMinimum private constructor( private val id: JsonField, private val billableMetric: JsonField, @@ -33357,7 +36342,7 @@ private constructor( private val discount: JsonField, private val externalPriceId: JsonField, private val fixedPriceQuantity: JsonField, - private val groupedWithMeteredMinimumConfig: JsonField, + private val groupedWithProratedMinimumConfig: JsonField, private val invoicingCycleConfiguration: JsonField, private val item: JsonField, private val maximum: JsonField, @@ -33411,9 +36396,9 @@ private constructor( @JsonProperty("fixed_price_quantity") @ExcludeMissing fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("grouped_with_metered_minimum_config") + @JsonProperty("grouped_with_prorated_minimum_config") @ExcludeMissing - groupedWithMeteredMinimumConfig: JsonField = + groupedWithProratedMinimumConfig: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing @@ -33459,7 +36444,7 @@ private constructor( discount, externalPriceId, fixedPriceQuantity, - groupedWithMeteredMinimumConfig, + groupedWithProratedMinimumConfig, invoicingCycleConfiguration, item, maximum, @@ -33558,11 +36543,13 @@ private constructor( fun fixedPriceQuantity(): Double? = fixedPriceQuantity.getNullable("fixed_price_quantity") /** + * Configuration for grouped_with_prorated_minimum pricing + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ - fun groupedWithMeteredMinimumConfig(): GroupedWithMeteredMinimumConfig = - groupedWithMeteredMinimumConfig.getRequired("grouped_with_metered_minimum_config") + fun groupedWithProratedMinimumConfig(): GroupedWithProratedMinimumConfig = + groupedWithProratedMinimumConfig.getRequired("grouped_with_prorated_minimum_config") /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the @@ -33614,9 +36601,11 @@ private constructor( fun minimumAmount(): String? = minimumAmount.getNullable("minimum_amount") /** + * The pricing model type + * * Expected to always return the following: * ```kotlin - * JsonValue.from("grouped_with_metered_minimum") + * JsonValue.from("grouped_with_prorated_minimum") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -33780,15 +36769,15 @@ private constructor( fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity /** - * Returns the raw JSON value of [groupedWithMeteredMinimumConfig]. + * Returns the raw JSON value of [groupedWithProratedMinimumConfig]. * - * Unlike [groupedWithMeteredMinimumConfig], this method doesn't throw if the JSON field has - * an unexpected type. + * Unlike [groupedWithProratedMinimumConfig], this method doesn't throw if the JSON field + * has an unexpected type. */ - @JsonProperty("grouped_with_metered_minimum_config") + @JsonProperty("grouped_with_prorated_minimum_config") @ExcludeMissing - fun _groupedWithMeteredMinimumConfig(): JsonField = - groupedWithMeteredMinimumConfig + fun _groupedWithProratedMinimumConfig(): JsonField = + groupedWithProratedMinimumConfig /** * Returns the raw JSON value of [invoicingCycleConfiguration]. @@ -33920,7 +36909,7 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [GroupedWithMeteredMinimum]. + * [GroupedWithProratedMinimum]. * * The following fields are required: * ```kotlin @@ -33937,7 +36926,7 @@ private constructor( * .discount() * .externalPriceId() * .fixedPriceQuantity() - * .groupedWithMeteredMinimumConfig() + * .groupedWithProratedMinimumConfig() * .invoicingCycleConfiguration() * .item() * .maximum() @@ -33954,7 +36943,7 @@ private constructor( fun builder() = Builder() } - /** A builder for [GroupedWithMeteredMinimum]. */ + /** A builder for [GroupedWithProratedMinimum]. */ class Builder internal constructor() { private var id: JsonField? = null @@ -33970,8 +36959,8 @@ private constructor( private var discount: JsonField? = null private var externalPriceId: JsonField? = null private var fixedPriceQuantity: JsonField? = null - private var groupedWithMeteredMinimumConfig: - JsonField? = + private var groupedWithProratedMinimumConfig: + JsonField? = null private var invoicingCycleConfiguration: JsonField? = null private var item: JsonField? = null @@ -33980,7 +36969,7 @@ private constructor( private var metadata: JsonField? = null private var minimum: JsonField? = null private var minimumAmount: JsonField? = null - private var modelType: JsonValue = JsonValue.from("grouped_with_metered_minimum") + private var modelType: JsonValue = JsonValue.from("grouped_with_prorated_minimum") private var name: JsonField? = null private var planPhaseOrder: JsonField? = null private var priceType: JsonField? = null @@ -33989,38 +36978,39 @@ private constructor( JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(groupedWithMeteredMinimum: GroupedWithMeteredMinimum) = apply { - id = groupedWithMeteredMinimum.id - billableMetric = groupedWithMeteredMinimum.billableMetric - billingCycleConfiguration = groupedWithMeteredMinimum.billingCycleConfiguration - cadence = groupedWithMeteredMinimum.cadence + internal fun from(groupedWithProratedMinimum: GroupedWithProratedMinimum) = apply { + id = groupedWithProratedMinimum.id + billableMetric = groupedWithProratedMinimum.billableMetric + billingCycleConfiguration = groupedWithProratedMinimum.billingCycleConfiguration + cadence = groupedWithProratedMinimum.cadence compositePriceFilters = - groupedWithMeteredMinimum.compositePriceFilters.map { it.toMutableList() } - conversionRate = groupedWithMeteredMinimum.conversionRate - conversionRateConfig = groupedWithMeteredMinimum.conversionRateConfig - createdAt = groupedWithMeteredMinimum.createdAt - creditAllocation = groupedWithMeteredMinimum.creditAllocation - currency = groupedWithMeteredMinimum.currency - discount = groupedWithMeteredMinimum.discount - externalPriceId = groupedWithMeteredMinimum.externalPriceId - fixedPriceQuantity = groupedWithMeteredMinimum.fixedPriceQuantity - groupedWithMeteredMinimumConfig = - groupedWithMeteredMinimum.groupedWithMeteredMinimumConfig - invoicingCycleConfiguration = groupedWithMeteredMinimum.invoicingCycleConfiguration - item = groupedWithMeteredMinimum.item - maximum = groupedWithMeteredMinimum.maximum - maximumAmount = groupedWithMeteredMinimum.maximumAmount - metadata = groupedWithMeteredMinimum.metadata - minimum = groupedWithMeteredMinimum.minimum - minimumAmount = groupedWithMeteredMinimum.minimumAmount - modelType = groupedWithMeteredMinimum.modelType - name = groupedWithMeteredMinimum.name - planPhaseOrder = groupedWithMeteredMinimum.planPhaseOrder - priceType = groupedWithMeteredMinimum.priceType - replacesPriceId = groupedWithMeteredMinimum.replacesPriceId + groupedWithProratedMinimum.compositePriceFilters.map { it.toMutableList() } + conversionRate = groupedWithProratedMinimum.conversionRate + conversionRateConfig = groupedWithProratedMinimum.conversionRateConfig + createdAt = groupedWithProratedMinimum.createdAt + creditAllocation = groupedWithProratedMinimum.creditAllocation + currency = groupedWithProratedMinimum.currency + discount = groupedWithProratedMinimum.discount + externalPriceId = groupedWithProratedMinimum.externalPriceId + fixedPriceQuantity = groupedWithProratedMinimum.fixedPriceQuantity + groupedWithProratedMinimumConfig = + groupedWithProratedMinimum.groupedWithProratedMinimumConfig + invoicingCycleConfiguration = groupedWithProratedMinimum.invoicingCycleConfiguration + item = groupedWithProratedMinimum.item + maximum = groupedWithProratedMinimum.maximum + maximumAmount = groupedWithProratedMinimum.maximumAmount + metadata = groupedWithProratedMinimum.metadata + minimum = groupedWithProratedMinimum.minimum + minimumAmount = groupedWithProratedMinimum.minimumAmount + modelType = groupedWithProratedMinimum.modelType + name = groupedWithProratedMinimum.name + planPhaseOrder = groupedWithProratedMinimum.planPhaseOrder + priceType = groupedWithProratedMinimum.priceType + replacesPriceId = groupedWithProratedMinimum.replacesPriceId dimensionalPriceConfiguration = - groupedWithMeteredMinimum.dimensionalPriceConfiguration - additionalProperties = groupedWithMeteredMinimum.additionalProperties.toMutableMap() + groupedWithProratedMinimum.dimensionalPriceConfiguration + additionalProperties = + groupedWithProratedMinimum.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) @@ -34342,20 +37332,21 @@ private constructor( this.fixedPriceQuantity = fixedPriceQuantity } - fun groupedWithMeteredMinimumConfig( - groupedWithMeteredMinimumConfig: GroupedWithMeteredMinimumConfig - ) = groupedWithMeteredMinimumConfig(JsonField.of(groupedWithMeteredMinimumConfig)) + /** Configuration for grouped_with_prorated_minimum pricing */ + fun groupedWithProratedMinimumConfig( + groupedWithProratedMinimumConfig: GroupedWithProratedMinimumConfig + ) = groupedWithProratedMinimumConfig(JsonField.of(groupedWithProratedMinimumConfig)) /** - * Sets [Builder.groupedWithMeteredMinimumConfig] to an arbitrary JSON value. + * Sets [Builder.groupedWithProratedMinimumConfig] to an arbitrary JSON value. * - * You should usually call [Builder.groupedWithMeteredMinimumConfig] with a well-typed - * [GroupedWithMeteredMinimumConfig] value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. + * You should usually call [Builder.groupedWithProratedMinimumConfig] with a well-typed + * [GroupedWithProratedMinimumConfig] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. */ - fun groupedWithMeteredMinimumConfig( - groupedWithMeteredMinimumConfig: JsonField - ) = apply { this.groupedWithMeteredMinimumConfig = groupedWithMeteredMinimumConfig } + fun groupedWithProratedMinimumConfig( + groupedWithProratedMinimumConfig: JsonField + ) = apply { this.groupedWithProratedMinimumConfig = groupedWithProratedMinimumConfig } fun invoicingCycleConfiguration( invoicingCycleConfiguration: BillingCycleConfiguration? @@ -34463,7 +37454,7 @@ private constructor( * It is usually unnecessary to call this method because the field defaults to the * following: * ```kotlin - * JsonValue.from("grouped_with_metered_minimum") + * JsonValue.from("grouped_with_prorated_minimum") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -34567,7 +37558,7 @@ private constructor( } /** - * Returns an immutable instance of [GroupedWithMeteredMinimum]. + * Returns an immutable instance of [GroupedWithProratedMinimum]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -34586,7 +37577,7 @@ private constructor( * .discount() * .externalPriceId() * .fixedPriceQuantity() - * .groupedWithMeteredMinimumConfig() + * .groupedWithProratedMinimumConfig() * .invoicingCycleConfiguration() * .item() * .maximum() @@ -34602,8 +37593,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): GroupedWithMeteredMinimum = - GroupedWithMeteredMinimum( + fun build(): GroupedWithProratedMinimum = + GroupedWithProratedMinimum( checkRequired("id", id), checkRequired("billableMetric", billableMetric), checkRequired("billingCycleConfiguration", billingCycleConfiguration), @@ -34620,8 +37611,8 @@ private constructor( checkRequired("externalPriceId", externalPriceId), checkRequired("fixedPriceQuantity", fixedPriceQuantity), checkRequired( - "groupedWithMeteredMinimumConfig", - groupedWithMeteredMinimumConfig, + "groupedWithProratedMinimumConfig", + groupedWithProratedMinimumConfig, ), checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), checkRequired("item", item), @@ -34642,7 +37633,7 @@ private constructor( private var validated: Boolean = false - fun validate(): GroupedWithMeteredMinimum = apply { + fun validate(): GroupedWithProratedMinimum = apply { if (validated) { return@apply } @@ -34660,7 +37651,7 @@ private constructor( discount()?.validate() externalPriceId() fixedPriceQuantity() - groupedWithMeteredMinimumConfig().validate() + groupedWithProratedMinimumConfig().validate() invoicingCycleConfiguration()?.validate() item().validate() maximum()?.validate() @@ -34669,7 +37660,7 @@ private constructor( minimum()?.validate() minimumAmount() _modelType().let { - if (it != JsonValue.from("grouped_with_metered_minimum")) { + if (it != JsonValue.from("grouped_with_prorated_minimum")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } @@ -34709,7 +37700,7 @@ private constructor( (discount.asKnown()?.validity() ?: 0) + (if (externalPriceId.asKnown() == null) 0 else 1) + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + - (groupedWithMeteredMinimumConfig.asKnown()?.validity() ?: 0) + + (groupedWithProratedMinimumConfig.asKnown()?.validity() ?: 0) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + (item.asKnown()?.validity() ?: 0) + (maximum.asKnown()?.validity() ?: 0) + @@ -34718,7 +37709,7 @@ private constructor( (minimum.asKnown()?.validity() ?: 0) + (if (minimumAmount.asKnown() == null) 0 else 1) + modelType.let { - if (it == JsonValue.from("grouped_with_metered_minimum")) 1 else 0 + if (it == JsonValue.from("grouped_with_prorated_minimum")) 1 else 0 } + (if (name.asKnown() == null) 0 else 1) + (if (planPhaseOrder.asKnown() == null) 0 else 1) + @@ -34878,16 +37869,89 @@ private constructor( override fun toString() = value.toString() } - class GroupedWithMeteredMinimumConfig - @JsonCreator + /** Configuration for grouped_with_prorated_minimum pricing */ + class GroupedWithProratedMinimumConfig private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map + private val groupingKey: JsonField, + private val minimum: JsonField, + private val unitRate: JsonField, + private val additionalProperties: MutableMap, ) { + @JsonCreator + private constructor( + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("minimum") + @ExcludeMissing + minimum: JsonField = JsonMissing.of(), + @JsonProperty("unit_rate") + @ExcludeMissing + unitRate: JsonField = JsonMissing.of(), + ) : this(groupingKey, minimum, unitRate, mutableMapOf()) + + /** + * How to determine the groups that should each have a minimum + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The minimum amount to charge per group + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun minimum(): String = minimum.getRequired("minimum") + + /** + * The amount to charge per unit + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun unitRate(): String = unitRate.getRequired("unit_rate") + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [minimum]. + * + * Unlike [minimum], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("minimum") @ExcludeMissing fun _minimum(): JsonField = minimum + + /** + * Returns the raw JSON value of [unitRate]. + * + * Unlike [unitRate], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("unit_rate") @ExcludeMissing fun _unitRate(): JsonField = unitRate + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) fun toBuilder() = Builder().from(this) @@ -34895,23 +37959,74 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [GroupedWithMeteredMinimumConfig]. + * [GroupedWithProratedMinimumConfig]. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .minimum() + * .unitRate() + * ``` */ fun builder() = Builder() } - /** A builder for [GroupedWithMeteredMinimumConfig]. */ + /** A builder for [GroupedWithProratedMinimumConfig]. */ class Builder internal constructor() { + private var groupingKey: JsonField? = null + private var minimum: JsonField? = null + private var unitRate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from( - groupedWithMeteredMinimumConfig: GroupedWithMeteredMinimumConfig + groupedWithProratedMinimumConfig: GroupedWithProratedMinimumConfig ) = apply { + groupingKey = groupedWithProratedMinimumConfig.groupingKey + minimum = groupedWithProratedMinimumConfig.minimum + unitRate = groupedWithProratedMinimumConfig.unitRate additionalProperties = - groupedWithMeteredMinimumConfig.additionalProperties.toMutableMap() + groupedWithProratedMinimumConfig.additionalProperties.toMutableMap() + } + + /** How to determine the groups that should each have a minimum */ + fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey } + /** The minimum amount to charge per group */ + fun minimum(minimum: String) = minimum(JsonField.of(minimum)) + + /** + * Sets [Builder.minimum] to an arbitrary JSON value. + * + * You should usually call [Builder.minimum] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun minimum(minimum: JsonField) = apply { this.minimum = minimum } + + /** The amount to charge per unit */ + fun unitRate(unitRate: String) = unitRate(JsonField.of(unitRate)) + + /** + * Sets [Builder.unitRate] to an arbitrary JSON value. + * + * You should usually call [Builder.unitRate] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun unitRate(unitRate: JsonField) = apply { this.unitRate = unitRate } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -34935,21 +38050,38 @@ private constructor( } /** - * Returns an immutable instance of [GroupedWithMeteredMinimumConfig]. + * Returns an immutable instance of [GroupedWithProratedMinimumConfig]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .minimum() + * .unitRate() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ - fun build(): GroupedWithMeteredMinimumConfig = - GroupedWithMeteredMinimumConfig(additionalProperties.toImmutable()) + fun build(): GroupedWithProratedMinimumConfig = + GroupedWithProratedMinimumConfig( + checkRequired("groupingKey", groupingKey), + checkRequired("minimum", minimum), + checkRequired("unitRate", unitRate), + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false - fun validate(): GroupedWithMeteredMinimumConfig = apply { + fun validate(): GroupedWithProratedMinimumConfig = apply { if (validated) { return@apply } + groupingKey() + minimum() + unitRate() validated = true } @@ -34968,23 +38100,30 @@ private constructor( * Used for best match union deserialization. */ internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + (if (groupingKey.asKnown() == null) 0 else 1) + + (if (minimum.asKnown() == null) 0 else 1) + + (if (unitRate.asKnown() == null) 0 else 1) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is GroupedWithMeteredMinimumConfig && + return other is GroupedWithProratedMinimumConfig && + groupingKey == other.groupingKey && + minimum == other.minimum && + unitRate == other.unitRate && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + private val hashCode: Int by lazy { + Objects.hash(groupingKey, minimum, unitRate, additionalProperties) + } override fun hashCode(): Int = hashCode override fun toString() = - "GroupedWithMeteredMinimumConfig{additionalProperties=$additionalProperties}" + "GroupedWithProratedMinimumConfig{groupingKey=$groupingKey, minimum=$minimum, unitRate=$unitRate, additionalProperties=$additionalProperties}" } /** @@ -35226,7 +38365,7 @@ private constructor( return true } - return other is GroupedWithMeteredMinimum && + return other is GroupedWithProratedMinimum && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && @@ -35240,7 +38379,7 @@ private constructor( discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && - groupedWithMeteredMinimumConfig == other.groupedWithMeteredMinimumConfig && + groupedWithProratedMinimumConfig == other.groupedWithProratedMinimumConfig && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maximum == other.maximum && @@ -35272,7 +38411,7 @@ private constructor( discount, externalPriceId, fixedPriceQuantity, - groupedWithMeteredMinimumConfig, + groupedWithProratedMinimumConfig, invoicingCycleConfiguration, item, maximum, @@ -35293,10 +38432,10 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "GroupedWithMeteredMinimum{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, groupedWithMeteredMinimumConfig=$groupedWithMeteredMinimumConfig, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "GroupedWithProratedMinimum{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, groupedWithProratedMinimumConfig=$groupedWithProratedMinimumConfig, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" } - class MatrixWithDisplayName + class GroupedWithMeteredMinimum private constructor( private val id: JsonField, private val billableMetric: JsonField, @@ -35311,9 +38450,9 @@ private constructor( private val discount: JsonField, private val externalPriceId: JsonField, private val fixedPriceQuantity: JsonField, + private val groupedWithMeteredMinimumConfig: JsonField, private val invoicingCycleConfiguration: JsonField, private val item: JsonField, - private val matrixWithDisplayNameConfig: JsonField, private val maximum: JsonField, private val maximumAmount: JsonField, private val metadata: JsonField, @@ -35365,13 +38504,14 @@ private constructor( @JsonProperty("fixed_price_quantity") @ExcludeMissing fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("grouped_with_metered_minimum_config") + @ExcludeMissing + groupedWithMeteredMinimumConfig: JsonField = + JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), @JsonProperty("item") @ExcludeMissing item: JsonField = JsonMissing.of(), - @JsonProperty("matrix_with_display_name_config") - @ExcludeMissing - matrixWithDisplayNameConfig: JsonField = JsonMissing.of(), @JsonProperty("maximum") @ExcludeMissing maximum: JsonField = JsonMissing.of(), @JsonProperty("maximum_amount") @ExcludeMissing @@ -35412,9 +38552,9 @@ private constructor( discount, externalPriceId, fixedPriceQuantity, + groupedWithMeteredMinimumConfig, invoicingCycleConfiguration, item, - matrixWithDisplayNameConfig, maximum, maximumAmount, metadata, @@ -35510,6 +38650,15 @@ private constructor( */ fun fixedPriceQuantity(): Double? = fixedPriceQuantity.getNullable("fixed_price_quantity") + /** + * Configuration for grouped_with_metered_minimum pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun groupedWithMeteredMinimumConfig(): GroupedWithMeteredMinimumConfig = + groupedWithMeteredMinimumConfig.getRequired("grouped_with_metered_minimum_config") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -35523,13 +38672,6 @@ private constructor( */ fun item(): ItemSlim = item.getRequired("item") - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun matrixWithDisplayNameConfig(): MatrixWithDisplayNameConfig = - matrixWithDisplayNameConfig.getRequired("matrix_with_display_name_config") - /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -35567,9 +38709,11 @@ private constructor( fun minimumAmount(): String? = minimumAmount.getNullable("minimum_amount") /** + * The pricing model type + * * Expected to always return the following: * ```kotlin - * JsonValue.from("matrix_with_display_name") + * JsonValue.from("grouped_with_metered_minimum") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -35732,6 +38876,17 @@ private constructor( @ExcludeMissing fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + /** + * Returns the raw JSON value of [groupedWithMeteredMinimumConfig]. + * + * Unlike [groupedWithMeteredMinimumConfig], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("grouped_with_metered_minimum_config") + @ExcludeMissing + fun _groupedWithMeteredMinimumConfig(): JsonField = + groupedWithMeteredMinimumConfig + /** * Returns the raw JSON value of [invoicingCycleConfiguration]. * @@ -35750,17 +38905,6 @@ private constructor( */ @JsonProperty("item") @ExcludeMissing fun _item(): JsonField = item - /** - * Returns the raw JSON value of [matrixWithDisplayNameConfig]. - * - * Unlike [matrixWithDisplayNameConfig], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("matrix_with_display_name_config") - @ExcludeMissing - fun _matrixWithDisplayNameConfig(): JsonField = - matrixWithDisplayNameConfig - /** * Returns the raw JSON value of [maximum]. * @@ -35872,7 +39016,8 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [MatrixWithDisplayName]. + * Returns a mutable builder for constructing an instance of + * [GroupedWithMeteredMinimum]. * * The following fields are required: * ```kotlin @@ -35889,9 +39034,9 @@ private constructor( * .discount() * .externalPriceId() * .fixedPriceQuantity() + * .groupedWithMeteredMinimumConfig() * .invoicingCycleConfiguration() * .item() - * .matrixWithDisplayNameConfig() * .maximum() * .maximumAmount() * .metadata() @@ -35906,7 +39051,7 @@ private constructor( fun builder() = Builder() } - /** A builder for [MatrixWithDisplayName]. */ + /** A builder for [GroupedWithMeteredMinimum]. */ class Builder internal constructor() { private var id: JsonField? = null @@ -35922,15 +39067,17 @@ private constructor( private var discount: JsonField? = null private var externalPriceId: JsonField? = null private var fixedPriceQuantity: JsonField? = null + private var groupedWithMeteredMinimumConfig: + JsonField? = + null private var invoicingCycleConfiguration: JsonField? = null private var item: JsonField? = null - private var matrixWithDisplayNameConfig: JsonField? = null private var maximum: JsonField? = null private var maximumAmount: JsonField? = null private var metadata: JsonField? = null private var minimum: JsonField? = null private var minimumAmount: JsonField? = null - private var modelType: JsonValue = JsonValue.from("matrix_with_display_name") + private var modelType: JsonValue = JsonValue.from("grouped_with_metered_minimum") private var name: JsonField? = null private var planPhaseOrder: JsonField? = null private var priceType: JsonField? = null @@ -35939,36 +39086,38 @@ private constructor( JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(matrixWithDisplayName: MatrixWithDisplayName) = apply { - id = matrixWithDisplayName.id - billableMetric = matrixWithDisplayName.billableMetric - billingCycleConfiguration = matrixWithDisplayName.billingCycleConfiguration - cadence = matrixWithDisplayName.cadence + internal fun from(groupedWithMeteredMinimum: GroupedWithMeteredMinimum) = apply { + id = groupedWithMeteredMinimum.id + billableMetric = groupedWithMeteredMinimum.billableMetric + billingCycleConfiguration = groupedWithMeteredMinimum.billingCycleConfiguration + cadence = groupedWithMeteredMinimum.cadence compositePriceFilters = - matrixWithDisplayName.compositePriceFilters.map { it.toMutableList() } - conversionRate = matrixWithDisplayName.conversionRate - conversionRateConfig = matrixWithDisplayName.conversionRateConfig - createdAt = matrixWithDisplayName.createdAt - creditAllocation = matrixWithDisplayName.creditAllocation - currency = matrixWithDisplayName.currency - discount = matrixWithDisplayName.discount - externalPriceId = matrixWithDisplayName.externalPriceId - fixedPriceQuantity = matrixWithDisplayName.fixedPriceQuantity - invoicingCycleConfiguration = matrixWithDisplayName.invoicingCycleConfiguration - item = matrixWithDisplayName.item - matrixWithDisplayNameConfig = matrixWithDisplayName.matrixWithDisplayNameConfig - maximum = matrixWithDisplayName.maximum - maximumAmount = matrixWithDisplayName.maximumAmount - metadata = matrixWithDisplayName.metadata - minimum = matrixWithDisplayName.minimum - minimumAmount = matrixWithDisplayName.minimumAmount - modelType = matrixWithDisplayName.modelType - name = matrixWithDisplayName.name - planPhaseOrder = matrixWithDisplayName.planPhaseOrder - priceType = matrixWithDisplayName.priceType - replacesPriceId = matrixWithDisplayName.replacesPriceId - dimensionalPriceConfiguration = matrixWithDisplayName.dimensionalPriceConfiguration - additionalProperties = matrixWithDisplayName.additionalProperties.toMutableMap() + groupedWithMeteredMinimum.compositePriceFilters.map { it.toMutableList() } + conversionRate = groupedWithMeteredMinimum.conversionRate + conversionRateConfig = groupedWithMeteredMinimum.conversionRateConfig + createdAt = groupedWithMeteredMinimum.createdAt + creditAllocation = groupedWithMeteredMinimum.creditAllocation + currency = groupedWithMeteredMinimum.currency + discount = groupedWithMeteredMinimum.discount + externalPriceId = groupedWithMeteredMinimum.externalPriceId + fixedPriceQuantity = groupedWithMeteredMinimum.fixedPriceQuantity + groupedWithMeteredMinimumConfig = + groupedWithMeteredMinimum.groupedWithMeteredMinimumConfig + invoicingCycleConfiguration = groupedWithMeteredMinimum.invoicingCycleConfiguration + item = groupedWithMeteredMinimum.item + maximum = groupedWithMeteredMinimum.maximum + maximumAmount = groupedWithMeteredMinimum.maximumAmount + metadata = groupedWithMeteredMinimum.metadata + minimum = groupedWithMeteredMinimum.minimum + minimumAmount = groupedWithMeteredMinimum.minimumAmount + modelType = groupedWithMeteredMinimum.modelType + name = groupedWithMeteredMinimum.name + planPhaseOrder = groupedWithMeteredMinimum.planPhaseOrder + priceType = groupedWithMeteredMinimum.priceType + replacesPriceId = groupedWithMeteredMinimum.replacesPriceId + dimensionalPriceConfiguration = + groupedWithMeteredMinimum.dimensionalPriceConfiguration + additionalProperties = groupedWithMeteredMinimum.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) @@ -36290,6 +39439,22 @@ private constructor( this.fixedPriceQuantity = fixedPriceQuantity } + /** Configuration for grouped_with_metered_minimum pricing */ + fun groupedWithMeteredMinimumConfig( + groupedWithMeteredMinimumConfig: GroupedWithMeteredMinimumConfig + ) = groupedWithMeteredMinimumConfig(JsonField.of(groupedWithMeteredMinimumConfig)) + + /** + * Sets [Builder.groupedWithMeteredMinimumConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.groupedWithMeteredMinimumConfig] with a well-typed + * [GroupedWithMeteredMinimumConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun groupedWithMeteredMinimumConfig( + groupedWithMeteredMinimumConfig: JsonField + ) = apply { this.groupedWithMeteredMinimumConfig = groupedWithMeteredMinimumConfig } + fun invoicingCycleConfiguration( invoicingCycleConfiguration: BillingCycleConfiguration? ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) @@ -36316,21 +39481,6 @@ private constructor( */ fun item(item: JsonField) = apply { this.item = item } - fun matrixWithDisplayNameConfig( - matrixWithDisplayNameConfig: MatrixWithDisplayNameConfig - ) = matrixWithDisplayNameConfig(JsonField.of(matrixWithDisplayNameConfig)) - - /** - * Sets [Builder.matrixWithDisplayNameConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.matrixWithDisplayNameConfig] with a well-typed - * [MatrixWithDisplayNameConfig] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun matrixWithDisplayNameConfig( - matrixWithDisplayNameConfig: JsonField - ) = apply { this.matrixWithDisplayNameConfig = matrixWithDisplayNameConfig } - @Deprecated("deprecated") fun maximum(maximum: Maximum?) = maximum(JsonField.ofNullable(maximum)) @@ -36411,7 +39561,7 @@ private constructor( * It is usually unnecessary to call this method because the field defaults to the * following: * ```kotlin - * JsonValue.from("matrix_with_display_name") + * JsonValue.from("grouped_with_metered_minimum") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -36515,7 +39665,7 @@ private constructor( } /** - * Returns an immutable instance of [MatrixWithDisplayName]. + * Returns an immutable instance of [GroupedWithMeteredMinimum]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -36534,9 +39684,9 @@ private constructor( * .discount() * .externalPriceId() * .fixedPriceQuantity() + * .groupedWithMeteredMinimumConfig() * .invoicingCycleConfiguration() * .item() - * .matrixWithDisplayNameConfig() * .maximum() * .maximumAmount() * .metadata() @@ -36550,8 +39700,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): MatrixWithDisplayName = - MatrixWithDisplayName( + fun build(): GroupedWithMeteredMinimum = + GroupedWithMeteredMinimum( checkRequired("id", id), checkRequired("billableMetric", billableMetric), checkRequired("billingCycleConfiguration", billingCycleConfiguration), @@ -36567,9 +39717,12 @@ private constructor( checkRequired("discount", discount), checkRequired("externalPriceId", externalPriceId), checkRequired("fixedPriceQuantity", fixedPriceQuantity), + checkRequired( + "groupedWithMeteredMinimumConfig", + groupedWithMeteredMinimumConfig, + ), checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), checkRequired("item", item), - checkRequired("matrixWithDisplayNameConfig", matrixWithDisplayNameConfig), checkRequired("maximum", maximum), checkRequired("maximumAmount", maximumAmount), checkRequired("metadata", metadata), @@ -36587,7 +39740,7 @@ private constructor( private var validated: Boolean = false - fun validate(): MatrixWithDisplayName = apply { + fun validate(): GroupedWithMeteredMinimum = apply { if (validated) { return@apply } @@ -36605,16 +39758,16 @@ private constructor( discount()?.validate() externalPriceId() fixedPriceQuantity() + groupedWithMeteredMinimumConfig().validate() invoicingCycleConfiguration()?.validate() item().validate() - matrixWithDisplayNameConfig().validate() maximum()?.validate() maximumAmount() metadata().validate() minimum()?.validate() minimumAmount() _modelType().let { - if (it != JsonValue.from("matrix_with_display_name")) { + if (it != JsonValue.from("grouped_with_metered_minimum")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } @@ -36654,15 +39807,17 @@ private constructor( (discount.asKnown()?.validity() ?: 0) + (if (externalPriceId.asKnown() == null) 0 else 1) + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (groupedWithMeteredMinimumConfig.asKnown()?.validity() ?: 0) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + (item.asKnown()?.validity() ?: 0) + - (matrixWithDisplayNameConfig.asKnown()?.validity() ?: 0) + (maximum.asKnown()?.validity() ?: 0) + (if (maximumAmount.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) + (minimum.asKnown()?.validity() ?: 0) + (if (minimumAmount.asKnown() == null) 0 else 1) + - modelType.let { if (it == JsonValue.from("matrix_with_display_name")) 1 else 0 } + + modelType.let { + if (it == JsonValue.from("grouped_with_metered_minimum")) 1 else 0 + } + (if (name.asKnown() == null) 0 else 1) + (if (planPhaseOrder.asKnown() == null) 0 else 1) + (priceType.asKnown()?.validity() ?: 0) + @@ -36821,16 +39976,173 @@ private constructor( override fun toString() = value.toString() } - class MatrixWithDisplayNameConfig - @JsonCreator + /** Configuration for grouped_with_metered_minimum pricing */ + class GroupedWithMeteredMinimumConfig private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map + private val groupingKey: JsonField, + private val minimumUnitAmount: JsonField, + private val pricingKey: JsonField, + private val scalingFactors: JsonField>, + private val scalingKey: JsonField, + private val unitAmounts: JsonField>, + private val additionalProperties: MutableMap, ) { + @JsonCreator + private constructor( + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("minimum_unit_amount") + @ExcludeMissing + minimumUnitAmount: JsonField = JsonMissing.of(), + @JsonProperty("pricing_key") + @ExcludeMissing + pricingKey: JsonField = JsonMissing.of(), + @JsonProperty("scaling_factors") + @ExcludeMissing + scalingFactors: JsonField> = JsonMissing.of(), + @JsonProperty("scaling_key") + @ExcludeMissing + scalingKey: JsonField = JsonMissing.of(), + @JsonProperty("unit_amounts") + @ExcludeMissing + unitAmounts: JsonField> = JsonMissing.of(), + ) : this( + groupingKey, + minimumUnitAmount, + pricingKey, + scalingFactors, + scalingKey, + unitAmounts, + mutableMapOf(), + ) + + /** + * Used to partition the usage into groups. The minimum amount is applied to each group. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The minimum amount to charge per group per unit + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun minimumUnitAmount(): String = minimumUnitAmount.getRequired("minimum_unit_amount") + + /** + * Used to determine the unit rate + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun pricingKey(): String = pricingKey.getRequired("pricing_key") + + /** + * Scale the unit rates by the scaling factor. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun scalingFactors(): List = + scalingFactors.getRequired("scaling_factors") + + /** + * Used to determine the unit rate scaling factor + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun scalingKey(): String = scalingKey.getRequired("scaling_key") + + /** + * Apply per unit pricing to each pricing value. The minimum amount is applied any + * unmatched usage. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun unitAmounts(): List = unitAmounts.getRequired("unit_amounts") + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [minimumUnitAmount]. + * + * Unlike [minimumUnitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("minimum_unit_amount") + @ExcludeMissing + fun _minimumUnitAmount(): JsonField = minimumUnitAmount + + /** + * Returns the raw JSON value of [pricingKey]. + * + * Unlike [pricingKey], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("pricing_key") + @ExcludeMissing + fun _pricingKey(): JsonField = pricingKey + + /** + * Returns the raw JSON value of [scalingFactors]. + * + * Unlike [scalingFactors], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("scaling_factors") + @ExcludeMissing + fun _scalingFactors(): JsonField> = scalingFactors + + /** + * Returns the raw JSON value of [scalingKey]. + * + * Unlike [scalingKey], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("scaling_key") + @ExcludeMissing + fun _scalingKey(): JsonField = scalingKey + + /** + * Returns the raw JSON value of [unitAmounts]. + * + * Unlike [unitAmounts], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("unit_amounts") + @ExcludeMissing + fun _unitAmounts(): JsonField> = unitAmounts + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) fun toBuilder() = Builder().from(this) @@ -36838,21 +40150,163 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [MatrixWithDisplayNameConfig]. + * [GroupedWithMeteredMinimumConfig]. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .minimumUnitAmount() + * .pricingKey() + * .scalingFactors() + * .scalingKey() + * .unitAmounts() + * ``` */ fun builder() = Builder() } - /** A builder for [MatrixWithDisplayNameConfig]. */ + /** A builder for [GroupedWithMeteredMinimumConfig]. */ class Builder internal constructor() { + private var groupingKey: JsonField? = null + private var minimumUnitAmount: JsonField? = null + private var pricingKey: JsonField? = null + private var scalingFactors: JsonField>? = null + private var scalingKey: JsonField? = null + private var unitAmounts: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(matrixWithDisplayNameConfig: MatrixWithDisplayNameConfig) = - apply { - additionalProperties = - matrixWithDisplayNameConfig.additionalProperties.toMutableMap() - } + internal fun from( + groupedWithMeteredMinimumConfig: GroupedWithMeteredMinimumConfig + ) = apply { + groupingKey = groupedWithMeteredMinimumConfig.groupingKey + minimumUnitAmount = groupedWithMeteredMinimumConfig.minimumUnitAmount + pricingKey = groupedWithMeteredMinimumConfig.pricingKey + scalingFactors = + groupedWithMeteredMinimumConfig.scalingFactors.map { it.toMutableList() } + scalingKey = groupedWithMeteredMinimumConfig.scalingKey + unitAmounts = + groupedWithMeteredMinimumConfig.unitAmounts.map { it.toMutableList() } + additionalProperties = + groupedWithMeteredMinimumConfig.additionalProperties.toMutableMap() + } + + /** + * Used to partition the usage into groups. The minimum amount is applied to each + * group. + */ + fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The minimum amount to charge per group per unit */ + fun minimumUnitAmount(minimumUnitAmount: String) = + minimumUnitAmount(JsonField.of(minimumUnitAmount)) + + /** + * Sets [Builder.minimumUnitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumUnitAmount] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun minimumUnitAmount(minimumUnitAmount: JsonField) = apply { + this.minimumUnitAmount = minimumUnitAmount + } + + /** Used to determine the unit rate */ + fun pricingKey(pricingKey: String) = pricingKey(JsonField.of(pricingKey)) + + /** + * Sets [Builder.pricingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.pricingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun pricingKey(pricingKey: JsonField) = apply { + this.pricingKey = pricingKey + } + + /** Scale the unit rates by the scaling factor. */ + fun scalingFactors(scalingFactors: List) = + scalingFactors(JsonField.of(scalingFactors)) + + /** + * Sets [Builder.scalingFactors] to an arbitrary JSON value. + * + * You should usually call [Builder.scalingFactors] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun scalingFactors(scalingFactors: JsonField>) = apply { + this.scalingFactors = scalingFactors.map { it.toMutableList() } + } + + /** + * Adds a single [ScalingFactor] to [scalingFactors]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addScalingFactor(scalingFactor: ScalingFactor) = apply { + scalingFactors = + (scalingFactors ?: JsonField.of(mutableListOf())).also { + checkKnown("scalingFactors", it).add(scalingFactor) + } + } + + /** Used to determine the unit rate scaling factor */ + fun scalingKey(scalingKey: String) = scalingKey(JsonField.of(scalingKey)) + + /** + * Sets [Builder.scalingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.scalingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun scalingKey(scalingKey: JsonField) = apply { + this.scalingKey = scalingKey + } + + /** + * Apply per unit pricing to each pricing value. The minimum amount is applied any + * unmatched usage. + */ + fun unitAmounts(unitAmounts: List) = + unitAmounts(JsonField.of(unitAmounts)) + + /** + * Sets [Builder.unitAmounts] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmounts] with a well-typed + * `List` value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun unitAmounts(unitAmounts: JsonField>) = apply { + this.unitAmounts = unitAmounts.map { it.toMutableList() } + } + + /** + * Adds a single [UnitAmount] to [unitAmounts]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addUnitAmount(unitAmount: UnitAmount) = apply { + unitAmounts = + (unitAmounts ?: JsonField.of(mutableListOf())).also { + checkKnown("unitAmounts", it).add(unitAmount) + } + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -36877,21 +40331,47 @@ private constructor( } /** - * Returns an immutable instance of [MatrixWithDisplayNameConfig]. + * Returns an immutable instance of [GroupedWithMeteredMinimumConfig]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .minimumUnitAmount() + * .pricingKey() + * .scalingFactors() + * .scalingKey() + * .unitAmounts() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ - fun build(): MatrixWithDisplayNameConfig = - MatrixWithDisplayNameConfig(additionalProperties.toImmutable()) + fun build(): GroupedWithMeteredMinimumConfig = + GroupedWithMeteredMinimumConfig( + checkRequired("groupingKey", groupingKey), + checkRequired("minimumUnitAmount", minimumUnitAmount), + checkRequired("pricingKey", pricingKey), + checkRequired("scalingFactors", scalingFactors).map { it.toImmutable() }, + checkRequired("scalingKey", scalingKey), + checkRequired("unitAmounts", unitAmounts).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false - fun validate(): MatrixWithDisplayNameConfig = apply { + fun validate(): GroupedWithMeteredMinimumConfig = apply { if (validated) { return@apply } + groupingKey() + minimumUnitAmount() + pricingKey() + scalingFactors().forEach { it.validate() } + scalingKey() + unitAmounts().forEach { it.validate() } validated = true } @@ -36910,23 +40390,481 @@ private constructor( * Used for best match union deserialization. */ internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + (if (groupingKey.asKnown() == null) 0 else 1) + + (if (minimumUnitAmount.asKnown() == null) 0 else 1) + + (if (pricingKey.asKnown() == null) 0 else 1) + + (scalingFactors.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + (if (scalingKey.asKnown() == null) 0 else 1) + + (unitAmounts.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a scaling factor */ + class ScalingFactor + private constructor( + private val scalingFactor: JsonField, + private val scalingValue: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("scaling_factor") + @ExcludeMissing + scalingFactor: JsonField = JsonMissing.of(), + @JsonProperty("scaling_value") + @ExcludeMissing + scalingValue: JsonField = JsonMissing.of(), + ) : this(scalingFactor, scalingValue, mutableMapOf()) + + /** + * Scaling factor + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun scalingFactor(): String = scalingFactor.getRequired("scaling_factor") + + /** + * Scaling value + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun scalingValue(): String = scalingValue.getRequired("scaling_value") + + /** + * Returns the raw JSON value of [scalingFactor]. + * + * Unlike [scalingFactor], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("scaling_factor") + @ExcludeMissing + fun _scalingFactor(): JsonField = scalingFactor + + /** + * Returns the raw JSON value of [scalingValue]. + * + * Unlike [scalingValue], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("scaling_value") + @ExcludeMissing + fun _scalingValue(): JsonField = scalingValue + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ScalingFactor]. + * + * The following fields are required: + * ```kotlin + * .scalingFactor() + * .scalingValue() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [ScalingFactor]. */ + class Builder internal constructor() { + + private var scalingFactor: JsonField? = null + private var scalingValue: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(scalingFactor: ScalingFactor) = apply { + this.scalingFactor = scalingFactor.scalingFactor + scalingValue = scalingFactor.scalingValue + additionalProperties = scalingFactor.additionalProperties.toMutableMap() + } + + /** Scaling factor */ + fun scalingFactor(scalingFactor: String) = + scalingFactor(JsonField.of(scalingFactor)) + + /** + * Sets [Builder.scalingFactor] to an arbitrary JSON value. + * + * You should usually call [Builder.scalingFactor] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun scalingFactor(scalingFactor: JsonField) = apply { + this.scalingFactor = scalingFactor + } + + /** Scaling value */ + fun scalingValue(scalingValue: String) = + scalingValue(JsonField.of(scalingValue)) + + /** + * Sets [Builder.scalingValue] to an arbitrary JSON value. + * + * You should usually call [Builder.scalingValue] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun scalingValue(scalingValue: JsonField) = apply { + this.scalingValue = scalingValue + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ScalingFactor]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .scalingFactor() + * .scalingValue() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ScalingFactor = + ScalingFactor( + checkRequired("scalingFactor", scalingFactor), + checkRequired("scalingValue", scalingValue), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ScalingFactor = apply { + if (validated) { + return@apply + } + + scalingFactor() + scalingValue() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (scalingFactor.asKnown() == null) 0 else 1) + + (if (scalingValue.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ScalingFactor && + scalingFactor == other.scalingFactor && + scalingValue == other.scalingValue && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(scalingFactor, scalingValue, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ScalingFactor{scalingFactor=$scalingFactor, scalingValue=$scalingValue, additionalProperties=$additionalProperties}" + } + + /** Configuration for a unit amount */ + class UnitAmount + private constructor( + private val pricingValue: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("pricing_value") + @ExcludeMissing + pricingValue: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(pricingValue, unitAmount, mutableMapOf()) + + /** + * Pricing value + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun pricingValue(): String = pricingValue.getRequired("pricing_value") + + /** + * Per unit amount + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [pricingValue]. + * + * Unlike [pricingValue], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("pricing_value") + @ExcludeMissing + fun _pricingValue(): JsonField = pricingValue + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [UnitAmount]. + * + * The following fields are required: + * ```kotlin + * .pricingValue() + * .unitAmount() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [UnitAmount]. */ + class Builder internal constructor() { + + private var pricingValue: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(unitAmount: UnitAmount) = apply { + pricingValue = unitAmount.pricingValue + this.unitAmount = unitAmount.unitAmount + additionalProperties = unitAmount.additionalProperties.toMutableMap() + } + + /** Pricing value */ + fun pricingValue(pricingValue: String) = + pricingValue(JsonField.of(pricingValue)) + + /** + * Sets [Builder.pricingValue] to an arbitrary JSON value. + * + * You should usually call [Builder.pricingValue] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun pricingValue(pricingValue: JsonField) = apply { + this.pricingValue = pricingValue + } + + /** Per unit amount */ + fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [UnitAmount]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .pricingValue() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UnitAmount = + UnitAmount( + checkRequired("pricingValue", pricingValue), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UnitAmount = apply { + if (validated) { + return@apply + } + + pricingValue() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (pricingValue.asKnown() == null) 0 else 1) + + (if (unitAmount.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnitAmount && + pricingValue == other.pricingValue && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(pricingValue, unitAmount, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UnitAmount{pricingValue=$pricingValue, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is MatrixWithDisplayNameConfig && + return other is GroupedWithMeteredMinimumConfig && + groupingKey == other.groupingKey && + minimumUnitAmount == other.minimumUnitAmount && + pricingKey == other.pricingKey && + scalingFactors == other.scalingFactors && + scalingKey == other.scalingKey && + unitAmounts == other.unitAmounts && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + private val hashCode: Int by lazy { + Objects.hash( + groupingKey, + minimumUnitAmount, + pricingKey, + scalingFactors, + scalingKey, + unitAmounts, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode override fun toString() = - "MatrixWithDisplayNameConfig{additionalProperties=$additionalProperties}" + "GroupedWithMeteredMinimumConfig{groupingKey=$groupingKey, minimumUnitAmount=$minimumUnitAmount, pricingKey=$pricingKey, scalingFactors=$scalingFactors, scalingKey=$scalingKey, unitAmounts=$unitAmounts, additionalProperties=$additionalProperties}" } /** @@ -37168,7 +41106,7 @@ private constructor( return true } - return other is MatrixWithDisplayName && + return other is GroupedWithMeteredMinimum && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && @@ -37182,9 +41120,9 @@ private constructor( discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && + groupedWithMeteredMinimumConfig == other.groupedWithMeteredMinimumConfig && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && - matrixWithDisplayNameConfig == other.matrixWithDisplayNameConfig && maximum == other.maximum && maximumAmount == other.maximumAmount && metadata == other.metadata && @@ -37214,9 +41152,9 @@ private constructor( discount, externalPriceId, fixedPriceQuantity, + groupedWithMeteredMinimumConfig, invoicingCycleConfiguration, item, - matrixWithDisplayNameConfig, maximum, maximumAmount, metadata, @@ -37235,15 +41173,14 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "MatrixWithDisplayName{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, matrixWithDisplayNameConfig=$matrixWithDisplayNameConfig, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "GroupedWithMeteredMinimum{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, groupedWithMeteredMinimumConfig=$groupedWithMeteredMinimumConfig, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" } - class BulkWithProration + class GroupedWithMinMaxThresholds private constructor( private val id: JsonField, private val billableMetric: JsonField, private val billingCycleConfiguration: JsonField, - private val bulkWithProrationConfig: JsonField, private val cadence: JsonField, private val compositePriceFilters: JsonField>, private val conversionRate: JsonField, @@ -37254,6 +41191,7 @@ private constructor( private val discount: JsonField, private val externalPriceId: JsonField, private val fixedPriceQuantity: JsonField, + private val groupedWithMinMaxThresholdsConfig: JsonField, private val invoicingCycleConfiguration: JsonField, private val item: JsonField, private val maximum: JsonField, @@ -37279,9 +41217,6 @@ private constructor( @JsonProperty("billing_cycle_configuration") @ExcludeMissing billingCycleConfiguration: JsonField = JsonMissing.of(), - @JsonProperty("bulk_with_proration_config") - @ExcludeMissing - bulkWithProrationConfig: JsonField = JsonMissing.of(), @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), @JsonProperty("composite_price_filters") @ExcludeMissing @@ -37310,6 +41245,10 @@ private constructor( @JsonProperty("fixed_price_quantity") @ExcludeMissing fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("grouped_with_min_max_thresholds_config") + @ExcludeMissing + groupedWithMinMaxThresholdsConfig: JsonField = + JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), @@ -37344,7 +41283,6 @@ private constructor( id, billableMetric, billingCycleConfiguration, - bulkWithProrationConfig, cadence, compositePriceFilters, conversionRate, @@ -37355,6 +41293,7 @@ private constructor( discount, externalPriceId, fixedPriceQuantity, + groupedWithMinMaxThresholdsConfig, invoicingCycleConfiguration, item, maximum, @@ -37390,13 +41329,6 @@ private constructor( fun billingCycleConfiguration(): BillingCycleConfiguration = billingCycleConfiguration.getRequired("billing_cycle_configuration") - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun bulkWithProrationConfig(): BulkWithProrationConfig = - bulkWithProrationConfig.getRequired("bulk_with_proration_config") - /** * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). @@ -37459,6 +41391,15 @@ private constructor( */ fun fixedPriceQuantity(): Double? = fixedPriceQuantity.getNullable("fixed_price_quantity") + /** + * Configuration for grouped_with_min_max_thresholds pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun groupedWithMinMaxThresholdsConfig(): GroupedWithMinMaxThresholdsConfig = + groupedWithMinMaxThresholdsConfig.getRequired("grouped_with_min_max_thresholds_config") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -37509,9 +41450,11 @@ private constructor( fun minimumAmount(): String? = minimumAmount.getNullable("minimum_amount") /** + * The pricing model type + * * Expected to always return the following: * ```kotlin - * JsonValue.from("bulk_with_proration") + * JsonValue.from("grouped_with_min_max_thresholds") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -37581,16 +41524,6 @@ private constructor( fun _billingCycleConfiguration(): JsonField = billingCycleConfiguration - /** - * Returns the raw JSON value of [bulkWithProrationConfig]. - * - * Unlike [bulkWithProrationConfig], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("bulk_with_proration_config") - @ExcludeMissing - fun _bulkWithProrationConfig(): JsonField = bulkWithProrationConfig - /** * Returns the raw JSON value of [cadence]. * @@ -37684,6 +41617,17 @@ private constructor( @ExcludeMissing fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + /** + * Returns the raw JSON value of [groupedWithMinMaxThresholdsConfig]. + * + * Unlike [groupedWithMinMaxThresholdsConfig], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("grouped_with_min_max_thresholds_config") + @ExcludeMissing + fun _groupedWithMinMaxThresholdsConfig(): JsonField = + groupedWithMinMaxThresholdsConfig + /** * Returns the raw JSON value of [invoicingCycleConfiguration]. * @@ -37813,14 +41757,14 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [BulkWithProration]. + * Returns a mutable builder for constructing an instance of + * [GroupedWithMinMaxThresholds]. * * The following fields are required: * ```kotlin * .id() * .billableMetric() * .billingCycleConfiguration() - * .bulkWithProrationConfig() * .cadence() * .compositePriceFilters() * .conversionRate() @@ -37831,6 +41775,7 @@ private constructor( * .discount() * .externalPriceId() * .fixedPriceQuantity() + * .groupedWithMinMaxThresholdsConfig() * .invoicingCycleConfiguration() * .item() * .maximum() @@ -37847,13 +41792,12 @@ private constructor( fun builder() = Builder() } - /** A builder for [BulkWithProration]. */ + /** A builder for [GroupedWithMinMaxThresholds]. */ class Builder internal constructor() { private var id: JsonField? = null private var billableMetric: JsonField? = null private var billingCycleConfiguration: JsonField? = null - private var bulkWithProrationConfig: JsonField? = null private var cadence: JsonField? = null private var compositePriceFilters: JsonField>? = null private var conversionRate: JsonField? = null @@ -37864,6 +41808,9 @@ private constructor( private var discount: JsonField? = null private var externalPriceId: JsonField? = null private var fixedPriceQuantity: JsonField? = null + private var groupedWithMinMaxThresholdsConfig: + JsonField? = + null private var invoicingCycleConfiguration: JsonField? = null private var item: JsonField? = null private var maximum: JsonField? = null @@ -37871,7 +41818,7 @@ private constructor( private var metadata: JsonField? = null private var minimum: JsonField? = null private var minimumAmount: JsonField? = null - private var modelType: JsonValue = JsonValue.from("bulk_with_proration") + private var modelType: JsonValue = JsonValue.from("grouped_with_min_max_thresholds") private var name: JsonField? = null private var planPhaseOrder: JsonField? = null private var priceType: JsonField? = null @@ -37880,36 +41827,40 @@ private constructor( JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(bulkWithProration: BulkWithProration) = apply { - id = bulkWithProration.id - billableMetric = bulkWithProration.billableMetric - billingCycleConfiguration = bulkWithProration.billingCycleConfiguration - bulkWithProrationConfig = bulkWithProration.bulkWithProrationConfig - cadence = bulkWithProration.cadence + internal fun from(groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds) = apply { + id = groupedWithMinMaxThresholds.id + billableMetric = groupedWithMinMaxThresholds.billableMetric + billingCycleConfiguration = groupedWithMinMaxThresholds.billingCycleConfiguration + cadence = groupedWithMinMaxThresholds.cadence compositePriceFilters = - bulkWithProration.compositePriceFilters.map { it.toMutableList() } - conversionRate = bulkWithProration.conversionRate - conversionRateConfig = bulkWithProration.conversionRateConfig - createdAt = bulkWithProration.createdAt - creditAllocation = bulkWithProration.creditAllocation - currency = bulkWithProration.currency - discount = bulkWithProration.discount - externalPriceId = bulkWithProration.externalPriceId - fixedPriceQuantity = bulkWithProration.fixedPriceQuantity - invoicingCycleConfiguration = bulkWithProration.invoicingCycleConfiguration - item = bulkWithProration.item - maximum = bulkWithProration.maximum - maximumAmount = bulkWithProration.maximumAmount - metadata = bulkWithProration.metadata - minimum = bulkWithProration.minimum - minimumAmount = bulkWithProration.minimumAmount - modelType = bulkWithProration.modelType - name = bulkWithProration.name - planPhaseOrder = bulkWithProration.planPhaseOrder - priceType = bulkWithProration.priceType - replacesPriceId = bulkWithProration.replacesPriceId - dimensionalPriceConfiguration = bulkWithProration.dimensionalPriceConfiguration - additionalProperties = bulkWithProration.additionalProperties.toMutableMap() + groupedWithMinMaxThresholds.compositePriceFilters.map { it.toMutableList() } + conversionRate = groupedWithMinMaxThresholds.conversionRate + conversionRateConfig = groupedWithMinMaxThresholds.conversionRateConfig + createdAt = groupedWithMinMaxThresholds.createdAt + creditAllocation = groupedWithMinMaxThresholds.creditAllocation + currency = groupedWithMinMaxThresholds.currency + discount = groupedWithMinMaxThresholds.discount + externalPriceId = groupedWithMinMaxThresholds.externalPriceId + fixedPriceQuantity = groupedWithMinMaxThresholds.fixedPriceQuantity + groupedWithMinMaxThresholdsConfig = + groupedWithMinMaxThresholds.groupedWithMinMaxThresholdsConfig + invoicingCycleConfiguration = + groupedWithMinMaxThresholds.invoicingCycleConfiguration + item = groupedWithMinMaxThresholds.item + maximum = groupedWithMinMaxThresholds.maximum + maximumAmount = groupedWithMinMaxThresholds.maximumAmount + metadata = groupedWithMinMaxThresholds.metadata + minimum = groupedWithMinMaxThresholds.minimum + minimumAmount = groupedWithMinMaxThresholds.minimumAmount + modelType = groupedWithMinMaxThresholds.modelType + name = groupedWithMinMaxThresholds.name + planPhaseOrder = groupedWithMinMaxThresholds.planPhaseOrder + priceType = groupedWithMinMaxThresholds.priceType + replacesPriceId = groupedWithMinMaxThresholds.replacesPriceId + dimensionalPriceConfiguration = + groupedWithMinMaxThresholds.dimensionalPriceConfiguration + additionalProperties = + groupedWithMinMaxThresholds.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) @@ -37951,20 +41902,6 @@ private constructor( billingCycleConfiguration: JsonField ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } - fun bulkWithProrationConfig(bulkWithProrationConfig: BulkWithProrationConfig) = - bulkWithProrationConfig(JsonField.of(bulkWithProrationConfig)) - - /** - * Sets [Builder.bulkWithProrationConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.bulkWithProrationConfig] with a well-typed - * [BulkWithProrationConfig] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun bulkWithProrationConfig( - bulkWithProrationConfig: JsonField - ) = apply { this.bulkWithProrationConfig = bulkWithProrationConfig } - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) /** @@ -38245,6 +42182,22 @@ private constructor( this.fixedPriceQuantity = fixedPriceQuantity } + /** Configuration for grouped_with_min_max_thresholds pricing */ + fun groupedWithMinMaxThresholdsConfig( + groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + ) = groupedWithMinMaxThresholdsConfig(JsonField.of(groupedWithMinMaxThresholdsConfig)) + + /** + * Sets [Builder.groupedWithMinMaxThresholdsConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.groupedWithMinMaxThresholdsConfig] with a well-typed + * [GroupedWithMinMaxThresholdsConfig] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun groupedWithMinMaxThresholdsConfig( + groupedWithMinMaxThresholdsConfig: JsonField + ) = apply { this.groupedWithMinMaxThresholdsConfig = groupedWithMinMaxThresholdsConfig } + fun invoicingCycleConfiguration( invoicingCycleConfiguration: BillingCycleConfiguration? ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) @@ -38351,7 +42304,7 @@ private constructor( * It is usually unnecessary to call this method because the field defaults to the * following: * ```kotlin - * JsonValue.from("bulk_with_proration") + * JsonValue.from("grouped_with_min_max_thresholds") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -38455,7 +42408,7 @@ private constructor( } /** - * Returns an immutable instance of [BulkWithProration]. + * Returns an immutable instance of [GroupedWithMinMaxThresholds]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -38464,7 +42417,6 @@ private constructor( * .id() * .billableMetric() * .billingCycleConfiguration() - * .bulkWithProrationConfig() * .cadence() * .compositePriceFilters() * .conversionRate() @@ -38475,6 +42427,7 @@ private constructor( * .discount() * .externalPriceId() * .fixedPriceQuantity() + * .groupedWithMinMaxThresholdsConfig() * .invoicingCycleConfiguration() * .item() * .maximum() @@ -38490,12 +42443,11 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): BulkWithProration = - BulkWithProration( + fun build(): GroupedWithMinMaxThresholds = + GroupedWithMinMaxThresholds( checkRequired("id", id), checkRequired("billableMetric", billableMetric), checkRequired("billingCycleConfiguration", billingCycleConfiguration), - checkRequired("bulkWithProrationConfig", bulkWithProrationConfig), checkRequired("cadence", cadence), checkRequired("compositePriceFilters", compositePriceFilters).map { it.toImmutable() @@ -38508,6 +42460,10 @@ private constructor( checkRequired("discount", discount), checkRequired("externalPriceId", externalPriceId), checkRequired("fixedPriceQuantity", fixedPriceQuantity), + checkRequired( + "groupedWithMinMaxThresholdsConfig", + groupedWithMinMaxThresholdsConfig, + ), checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), checkRequired("item", item), checkRequired("maximum", maximum), @@ -38527,7 +42483,7 @@ private constructor( private var validated: Boolean = false - fun validate(): BulkWithProration = apply { + fun validate(): GroupedWithMinMaxThresholds = apply { if (validated) { return@apply } @@ -38535,7 +42491,6 @@ private constructor( id() billableMetric()?.validate() billingCycleConfiguration().validate() - bulkWithProrationConfig().validate() cadence().validate() compositePriceFilters()?.forEach { it.validate() } conversionRate() @@ -38546,6 +42501,7 @@ private constructor( discount()?.validate() externalPriceId() fixedPriceQuantity() + groupedWithMinMaxThresholdsConfig().validate() invoicingCycleConfiguration()?.validate() item().validate() maximum()?.validate() @@ -38554,7 +42510,7 @@ private constructor( minimum()?.validate() minimumAmount() _modelType().let { - if (it != JsonValue.from("bulk_with_proration")) { + if (it != JsonValue.from("grouped_with_min_max_thresholds")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } @@ -38584,7 +42540,6 @@ private constructor( (if (id.asKnown() == null) 0 else 1) + (billableMetric.asKnown()?.validity() ?: 0) + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + - (bulkWithProrationConfig.asKnown()?.validity() ?: 0) + (cadence.asKnown()?.validity() ?: 0) + (compositePriceFilters.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + (if (conversionRate.asKnown() == null) 0 else 1) + @@ -38595,6 +42550,7 @@ private constructor( (discount.asKnown()?.validity() ?: 0) + (if (externalPriceId.asKnown() == null) 0 else 1) + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (groupedWithMinMaxThresholdsConfig.asKnown()?.validity() ?: 0) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + (item.asKnown()?.validity() ?: 0) + (maximum.asKnown()?.validity() ?: 0) + @@ -38602,120 +42558,15 @@ private constructor( (metadata.asKnown()?.validity() ?: 0) + (minimum.asKnown()?.validity() ?: 0) + (if (minimumAmount.asKnown() == null) 0 else 1) + - modelType.let { if (it == JsonValue.from("bulk_with_proration")) 1 else 0 } + + modelType.let { + if (it == JsonValue.from("grouped_with_min_max_thresholds")) 1 else 0 + } + (if (name.asKnown() == null) 0 else 1) + (if (planPhaseOrder.asKnown() == null) 0 else 1) + (priceType.asKnown()?.validity() ?: 0) + (if (replacesPriceId.asKnown() == null) 0 else 1) + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) - class BulkWithProrationConfig - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [BulkWithProrationConfig]. - */ - fun builder() = Builder() - } - - /** A builder for [BulkWithProrationConfig]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(bulkWithProrationConfig: BulkWithProrationConfig) = apply { - additionalProperties = - bulkWithProrationConfig.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [BulkWithProrationConfig]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): BulkWithProrationConfig = - BulkWithProrationConfig(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): BulkWithProrationConfig = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is BulkWithProrationConfig && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BulkWithProrationConfig{additionalProperties=$additionalProperties}" - } - class Cadence @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -38868,37 +42719,356 @@ private constructor( override fun toString() = value.toString() } - /** - * User specified key-value pairs for the resource. If not present, this defaults to an - * empty dictionary. Individual keys can be removed by setting the value to `null`, and the - * entire metadata mapping can be cleared by setting `metadata` to `null`. - */ - class Metadata - @JsonCreator + /** Configuration for grouped_with_min_max_thresholds pricing */ + class GroupedWithMinMaxThresholdsConfig private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map + private val groupingKey: JsonField, + private val maximumCharge: JsonField, + private val minimumCharge: JsonField, + private val perUnitRate: JsonField, + private val additionalProperties: MutableMap, ) { + @JsonCreator + private constructor( + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("maximum_charge") + @ExcludeMissing + maximumCharge: JsonField = JsonMissing.of(), + @JsonProperty("minimum_charge") + @ExcludeMissing + minimumCharge: JsonField = JsonMissing.of(), + @JsonProperty("per_unit_rate") + @ExcludeMissing + perUnitRate: JsonField = JsonMissing.of(), + ) : this(groupingKey, maximumCharge, minimumCharge, perUnitRate, mutableMapOf()) + + /** + * The event property used to group before applying thresholds + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The maximum amount to charge each group + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun maximumCharge(): String = maximumCharge.getRequired("maximum_charge") + + /** + * The minimum amount to charge each group, regardless of usage + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun minimumCharge(): String = minimumCharge.getRequired("minimum_charge") + + /** + * The base price charged per group + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun perUnitRate(): String = perUnitRate.getRequired("per_unit_rate") + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [maximumCharge]. + * + * Unlike [maximumCharge], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("maximum_charge") + @ExcludeMissing + fun _maximumCharge(): JsonField = maximumCharge + + /** + * Returns the raw JSON value of [minimumCharge]. + * + * Unlike [minimumCharge], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("minimum_charge") + @ExcludeMissing + fun _minimumCharge(): JsonField = minimumCharge + + /** + * Returns the raw JSON value of [perUnitRate]. + * + * Unlike [perUnitRate], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("per_unit_rate") + @ExcludeMissing + fun _perUnitRate(): JsonField = perUnitRate + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) fun toBuilder() = Builder().from(this) companion object { - /** Returns a mutable builder for constructing an instance of [Metadata]. */ + /** + * Returns a mutable builder for constructing an instance of + * [GroupedWithMinMaxThresholdsConfig]. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .maximumCharge() + * .minimumCharge() + * .perUnitRate() + * ``` + */ fun builder() = Builder() } - /** A builder for [Metadata]. */ + /** A builder for [GroupedWithMinMaxThresholdsConfig]. */ class Builder internal constructor() { + private var groupingKey: JsonField? = null + private var maximumCharge: JsonField? = null + private var minimumCharge: JsonField? = null + private var perUnitRate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(metadata: Metadata) = apply { - additionalProperties = metadata.additionalProperties.toMutableMap() + internal fun from( + groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + ) = apply { + groupingKey = groupedWithMinMaxThresholdsConfig.groupingKey + maximumCharge = groupedWithMinMaxThresholdsConfig.maximumCharge + minimumCharge = groupedWithMinMaxThresholdsConfig.minimumCharge + perUnitRate = groupedWithMinMaxThresholdsConfig.perUnitRate + additionalProperties = + groupedWithMinMaxThresholdsConfig.additionalProperties.toMutableMap() + } + + /** The event property used to group before applying thresholds */ + fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The maximum amount to charge each group */ + fun maximumCharge(maximumCharge: String) = + maximumCharge(JsonField.of(maximumCharge)) + + /** + * Sets [Builder.maximumCharge] to an arbitrary JSON value. + * + * You should usually call [Builder.maximumCharge] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun maximumCharge(maximumCharge: JsonField) = apply { + this.maximumCharge = maximumCharge + } + + /** The minimum amount to charge each group, regardless of usage */ + fun minimumCharge(minimumCharge: String) = + minimumCharge(JsonField.of(minimumCharge)) + + /** + * Sets [Builder.minimumCharge] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumCharge] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun minimumCharge(minimumCharge: JsonField) = apply { + this.minimumCharge = minimumCharge + } + + /** The base price charged per group */ + fun perUnitRate(perUnitRate: String) = perUnitRate(JsonField.of(perUnitRate)) + + /** + * Sets [Builder.perUnitRate] to an arbitrary JSON value. + * + * You should usually call [Builder.perUnitRate] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun perUnitRate(perUnitRate: JsonField) = apply { + this.perUnitRate = perUnitRate + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [GroupedWithMinMaxThresholdsConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .maximumCharge() + * .minimumCharge() + * .perUnitRate() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedWithMinMaxThresholdsConfig = + GroupedWithMinMaxThresholdsConfig( + checkRequired("groupingKey", groupingKey), + checkRequired("maximumCharge", maximumCharge), + checkRequired("minimumCharge", minimumCharge), + checkRequired("perUnitRate", perUnitRate), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GroupedWithMinMaxThresholdsConfig = apply { + if (validated) { + return@apply + } + + groupingKey() + maximumCharge() + minimumCharge() + perUnitRate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (groupingKey.asKnown() == null) 0 else 1) + + (if (maximumCharge.asKnown() == null) 0 else 1) + + (if (minimumCharge.asKnown() == null) 0 else 1) + + (if (perUnitRate.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedWithMinMaxThresholdsConfig && + groupingKey == other.groupingKey && + maximumCharge == other.maximumCharge && + minimumCharge == other.minimumCharge && + perUnitRate == other.perUnitRate && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + groupingKey, + maximumCharge, + minimumCharge, + perUnitRate, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedWithMinMaxThresholdsConfig{groupingKey=$groupingKey, maximumCharge=$maximumCharge, minimumCharge=$minimumCharge, perUnitRate=$perUnitRate, additionalProperties=$additionalProperties}" + } + + /** + * User specified key-value pairs for the resource. If not present, this defaults to an + * empty dictionary. Individual keys can be removed by setting the value to `null`, and the + * entire metadata mapping can be cleared by setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() } fun additionalProperties(additionalProperties: Map) = apply { @@ -39107,11 +43277,10 @@ private constructor( return true } - return other is BulkWithProration && + return other is GroupedWithMinMaxThresholds && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && - bulkWithProrationConfig == other.bulkWithProrationConfig && cadence == other.cadence && compositePriceFilters == other.compositePriceFilters && conversionRate == other.conversionRate && @@ -39122,6 +43291,7 @@ private constructor( discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && + groupedWithMinMaxThresholdsConfig == other.groupedWithMinMaxThresholdsConfig && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maximum == other.maximum && @@ -39143,7 +43313,6 @@ private constructor( id, billableMetric, billingCycleConfiguration, - bulkWithProrationConfig, cadence, compositePriceFilters, conversionRate, @@ -39154,6 +43323,7 @@ private constructor( discount, externalPriceId, fixedPriceQuantity, + groupedWithMinMaxThresholdsConfig, invoicingCycleConfiguration, item, maximum, @@ -39174,10 +43344,10 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "BulkWithProration{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, bulkWithProrationConfig=$bulkWithProrationConfig, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "GroupedWithMinMaxThresholds{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" } - class GroupedTieredPackage + class MatrixWithDisplayName private constructor( private val id: JsonField, private val billableMetric: JsonField, @@ -39192,9 +43362,9 @@ private constructor( private val discount: JsonField, private val externalPriceId: JsonField, private val fixedPriceQuantity: JsonField, - private val groupedTieredPackageConfig: JsonField, private val invoicingCycleConfiguration: JsonField, private val item: JsonField, + private val matrixWithDisplayNameConfig: JsonField, private val maximum: JsonField, private val maximumAmount: JsonField, private val metadata: JsonField, @@ -39246,13 +43416,13 @@ private constructor( @JsonProperty("fixed_price_quantity") @ExcludeMissing fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("grouped_tiered_package_config") - @ExcludeMissing - groupedTieredPackageConfig: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), @JsonProperty("item") @ExcludeMissing item: JsonField = JsonMissing.of(), + @JsonProperty("matrix_with_display_name_config") + @ExcludeMissing + matrixWithDisplayNameConfig: JsonField = JsonMissing.of(), @JsonProperty("maximum") @ExcludeMissing maximum: JsonField = JsonMissing.of(), @JsonProperty("maximum_amount") @ExcludeMissing @@ -39293,9 +43463,9 @@ private constructor( discount, externalPriceId, fixedPriceQuantity, - groupedTieredPackageConfig, invoicingCycleConfiguration, item, + matrixWithDisplayNameConfig, maximum, maximumAmount, metadata, @@ -39391,13 +43561,6 @@ private constructor( */ fun fixedPriceQuantity(): Double? = fixedPriceQuantity.getNullable("fixed_price_quantity") - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun groupedTieredPackageConfig(): GroupedTieredPackageConfig = - groupedTieredPackageConfig.getRequired("grouped_tiered_package_config") - /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -39411,6 +43574,15 @@ private constructor( */ fun item(): ItemSlim = item.getRequired("item") + /** + * Configuration for matrix_with_display_name pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun matrixWithDisplayNameConfig(): MatrixWithDisplayNameConfig = + matrixWithDisplayNameConfig.getRequired("matrix_with_display_name_config") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -39448,9 +43620,11 @@ private constructor( fun minimumAmount(): String? = minimumAmount.getNullable("minimum_amount") /** + * The pricing model type + * * Expected to always return the following: * ```kotlin - * JsonValue.from("grouped_tiered_package") + * JsonValue.from("matrix_with_display_name") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -39613,17 +43787,6 @@ private constructor( @ExcludeMissing fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - /** - * Returns the raw JSON value of [groupedTieredPackageConfig]. - * - * Unlike [groupedTieredPackageConfig], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("grouped_tiered_package_config") - @ExcludeMissing - fun _groupedTieredPackageConfig(): JsonField = - groupedTieredPackageConfig - /** * Returns the raw JSON value of [invoicingCycleConfiguration]. * @@ -39642,6 +43805,17 @@ private constructor( */ @JsonProperty("item") @ExcludeMissing fun _item(): JsonField = item + /** + * Returns the raw JSON value of [matrixWithDisplayNameConfig]. + * + * Unlike [matrixWithDisplayNameConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("matrix_with_display_name_config") + @ExcludeMissing + fun _matrixWithDisplayNameConfig(): JsonField = + matrixWithDisplayNameConfig + /** * Returns the raw JSON value of [maximum]. * @@ -39753,7 +43927,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [GroupedTieredPackage]. + * Returns a mutable builder for constructing an instance of [MatrixWithDisplayName]. * * The following fields are required: * ```kotlin @@ -39770,9 +43944,9 @@ private constructor( * .discount() * .externalPriceId() * .fixedPriceQuantity() - * .groupedTieredPackageConfig() * .invoicingCycleConfiguration() * .item() + * .matrixWithDisplayNameConfig() * .maximum() * .maximumAmount() * .metadata() @@ -39787,7 +43961,7 @@ private constructor( fun builder() = Builder() } - /** A builder for [GroupedTieredPackage]. */ + /** A builder for [MatrixWithDisplayName]. */ class Builder internal constructor() { private var id: JsonField? = null @@ -39803,15 +43977,15 @@ private constructor( private var discount: JsonField? = null private var externalPriceId: JsonField? = null private var fixedPriceQuantity: JsonField? = null - private var groupedTieredPackageConfig: JsonField? = null private var invoicingCycleConfiguration: JsonField? = null private var item: JsonField? = null + private var matrixWithDisplayNameConfig: JsonField? = null private var maximum: JsonField? = null private var maximumAmount: JsonField? = null private var metadata: JsonField? = null private var minimum: JsonField? = null private var minimumAmount: JsonField? = null - private var modelType: JsonValue = JsonValue.from("grouped_tiered_package") + private var modelType: JsonValue = JsonValue.from("matrix_with_display_name") private var name: JsonField? = null private var planPhaseOrder: JsonField? = null private var priceType: JsonField? = null @@ -39820,36 +43994,36 @@ private constructor( JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(groupedTieredPackage: GroupedTieredPackage) = apply { - id = groupedTieredPackage.id - billableMetric = groupedTieredPackage.billableMetric - billingCycleConfiguration = groupedTieredPackage.billingCycleConfiguration - cadence = groupedTieredPackage.cadence + internal fun from(matrixWithDisplayName: MatrixWithDisplayName) = apply { + id = matrixWithDisplayName.id + billableMetric = matrixWithDisplayName.billableMetric + billingCycleConfiguration = matrixWithDisplayName.billingCycleConfiguration + cadence = matrixWithDisplayName.cadence compositePriceFilters = - groupedTieredPackage.compositePriceFilters.map { it.toMutableList() } - conversionRate = groupedTieredPackage.conversionRate - conversionRateConfig = groupedTieredPackage.conversionRateConfig - createdAt = groupedTieredPackage.createdAt - creditAllocation = groupedTieredPackage.creditAllocation - currency = groupedTieredPackage.currency - discount = groupedTieredPackage.discount - externalPriceId = groupedTieredPackage.externalPriceId - fixedPriceQuantity = groupedTieredPackage.fixedPriceQuantity - groupedTieredPackageConfig = groupedTieredPackage.groupedTieredPackageConfig - invoicingCycleConfiguration = groupedTieredPackage.invoicingCycleConfiguration - item = groupedTieredPackage.item - maximum = groupedTieredPackage.maximum - maximumAmount = groupedTieredPackage.maximumAmount - metadata = groupedTieredPackage.metadata - minimum = groupedTieredPackage.minimum - minimumAmount = groupedTieredPackage.minimumAmount - modelType = groupedTieredPackage.modelType - name = groupedTieredPackage.name - planPhaseOrder = groupedTieredPackage.planPhaseOrder - priceType = groupedTieredPackage.priceType - replacesPriceId = groupedTieredPackage.replacesPriceId - dimensionalPriceConfiguration = groupedTieredPackage.dimensionalPriceConfiguration - additionalProperties = groupedTieredPackage.additionalProperties.toMutableMap() + matrixWithDisplayName.compositePriceFilters.map { it.toMutableList() } + conversionRate = matrixWithDisplayName.conversionRate + conversionRateConfig = matrixWithDisplayName.conversionRateConfig + createdAt = matrixWithDisplayName.createdAt + creditAllocation = matrixWithDisplayName.creditAllocation + currency = matrixWithDisplayName.currency + discount = matrixWithDisplayName.discount + externalPriceId = matrixWithDisplayName.externalPriceId + fixedPriceQuantity = matrixWithDisplayName.fixedPriceQuantity + invoicingCycleConfiguration = matrixWithDisplayName.invoicingCycleConfiguration + item = matrixWithDisplayName.item + matrixWithDisplayNameConfig = matrixWithDisplayName.matrixWithDisplayNameConfig + maximum = matrixWithDisplayName.maximum + maximumAmount = matrixWithDisplayName.maximumAmount + metadata = matrixWithDisplayName.metadata + minimum = matrixWithDisplayName.minimum + minimumAmount = matrixWithDisplayName.minimumAmount + modelType = matrixWithDisplayName.modelType + name = matrixWithDisplayName.name + planPhaseOrder = matrixWithDisplayName.planPhaseOrder + priceType = matrixWithDisplayName.priceType + replacesPriceId = matrixWithDisplayName.replacesPriceId + dimensionalPriceConfiguration = matrixWithDisplayName.dimensionalPriceConfiguration + additionalProperties = matrixWithDisplayName.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) @@ -40171,20 +44345,6 @@ private constructor( this.fixedPriceQuantity = fixedPriceQuantity } - fun groupedTieredPackageConfig(groupedTieredPackageConfig: GroupedTieredPackageConfig) = - groupedTieredPackageConfig(JsonField.of(groupedTieredPackageConfig)) - - /** - * Sets [Builder.groupedTieredPackageConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.groupedTieredPackageConfig] with a well-typed - * [GroupedTieredPackageConfig] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun groupedTieredPackageConfig( - groupedTieredPackageConfig: JsonField - ) = apply { this.groupedTieredPackageConfig = groupedTieredPackageConfig } - fun invoicingCycleConfiguration( invoicingCycleConfiguration: BillingCycleConfiguration? ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) @@ -40211,6 +44371,22 @@ private constructor( */ fun item(item: JsonField) = apply { this.item = item } + /** Configuration for matrix_with_display_name pricing */ + fun matrixWithDisplayNameConfig( + matrixWithDisplayNameConfig: MatrixWithDisplayNameConfig + ) = matrixWithDisplayNameConfig(JsonField.of(matrixWithDisplayNameConfig)) + + /** + * Sets [Builder.matrixWithDisplayNameConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.matrixWithDisplayNameConfig] with a well-typed + * [MatrixWithDisplayNameConfig] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun matrixWithDisplayNameConfig( + matrixWithDisplayNameConfig: JsonField + ) = apply { this.matrixWithDisplayNameConfig = matrixWithDisplayNameConfig } + @Deprecated("deprecated") fun maximum(maximum: Maximum?) = maximum(JsonField.ofNullable(maximum)) @@ -40291,7 +44467,7 @@ private constructor( * It is usually unnecessary to call this method because the field defaults to the * following: * ```kotlin - * JsonValue.from("grouped_tiered_package") + * JsonValue.from("matrix_with_display_name") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -40395,7 +44571,7 @@ private constructor( } /** - * Returns an immutable instance of [GroupedTieredPackage]. + * Returns an immutable instance of [MatrixWithDisplayName]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -40414,9 +44590,9 @@ private constructor( * .discount() * .externalPriceId() * .fixedPriceQuantity() - * .groupedTieredPackageConfig() * .invoicingCycleConfiguration() * .item() + * .matrixWithDisplayNameConfig() * .maximum() * .maximumAmount() * .metadata() @@ -40430,8 +44606,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): GroupedTieredPackage = - GroupedTieredPackage( + fun build(): MatrixWithDisplayName = + MatrixWithDisplayName( checkRequired("id", id), checkRequired("billableMetric", billableMetric), checkRequired("billingCycleConfiguration", billingCycleConfiguration), @@ -40447,9 +44623,9 @@ private constructor( checkRequired("discount", discount), checkRequired("externalPriceId", externalPriceId), checkRequired("fixedPriceQuantity", fixedPriceQuantity), - checkRequired("groupedTieredPackageConfig", groupedTieredPackageConfig), checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), checkRequired("item", item), + checkRequired("matrixWithDisplayNameConfig", matrixWithDisplayNameConfig), checkRequired("maximum", maximum), checkRequired("maximumAmount", maximumAmount), checkRequired("metadata", metadata), @@ -40467,7 +44643,7 @@ private constructor( private var validated: Boolean = false - fun validate(): GroupedTieredPackage = apply { + fun validate(): MatrixWithDisplayName = apply { if (validated) { return@apply } @@ -40485,16 +44661,16 @@ private constructor( discount()?.validate() externalPriceId() fixedPriceQuantity() - groupedTieredPackageConfig().validate() invoicingCycleConfiguration()?.validate() item().validate() + matrixWithDisplayNameConfig().validate() maximum()?.validate() maximumAmount() metadata().validate() minimum()?.validate() minimumAmount() _modelType().let { - if (it != JsonValue.from("grouped_tiered_package")) { + if (it != JsonValue.from("matrix_with_display_name")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } @@ -40534,15 +44710,15 @@ private constructor( (discount.asKnown()?.validity() ?: 0) + (if (externalPriceId.asKnown() == null) 0 else 1) + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + - (groupedTieredPackageConfig.asKnown()?.validity() ?: 0) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + (item.asKnown()?.validity() ?: 0) + + (matrixWithDisplayNameConfig.asKnown()?.validity() ?: 0) + (maximum.asKnown()?.validity() ?: 0) + (if (maximumAmount.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) + (minimum.asKnown()?.validity() ?: 0) + (if (minimumAmount.asKnown() == null) 0 else 1) + - modelType.let { if (it == JsonValue.from("grouped_tiered_package")) 1 else 0 } + + modelType.let { if (it == JsonValue.from("matrix_with_display_name")) 1 else 0 } + (if (name.asKnown() == null) 0 else 1) + (if (planPhaseOrder.asKnown() == null) 0 else 1) + (priceType.asKnown()?.validity() ?: 0) + @@ -40701,16 +44877,71 @@ private constructor( override fun toString() = value.toString() } - class GroupedTieredPackageConfig - @JsonCreator + /** Configuration for matrix_with_display_name pricing */ + class MatrixWithDisplayNameConfig private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map + private val dimension: JsonField, + private val unitAmounts: JsonField>, + private val additionalProperties: MutableMap, ) { + @JsonCreator + private constructor( + @JsonProperty("dimension") + @ExcludeMissing + dimension: JsonField = JsonMissing.of(), + @JsonProperty("unit_amounts") + @ExcludeMissing + unitAmounts: JsonField> = JsonMissing.of(), + ) : this(dimension, unitAmounts, mutableMapOf()) + + /** + * Used to determine the unit rate + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun dimension(): String = dimension.getRequired("dimension") + + /** + * Apply per unit pricing to each dimension value + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun unitAmounts(): List = unitAmounts.getRequired("unit_amounts") + + /** + * Returns the raw JSON value of [dimension]. + * + * Unlike [dimension], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("dimension") + @ExcludeMissing + fun _dimension(): JsonField = dimension + + /** + * Returns the raw JSON value of [unitAmounts]. + * + * Unlike [unitAmounts], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("unit_amounts") + @ExcludeMissing + fun _unitAmounts(): JsonField> = unitAmounts + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) fun toBuilder() = Builder().from(this) @@ -40718,19 +44949,70 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [GroupedTieredPackageConfig]. + * [MatrixWithDisplayNameConfig]. + * + * The following fields are required: + * ```kotlin + * .dimension() + * .unitAmounts() + * ``` */ fun builder() = Builder() } - /** A builder for [GroupedTieredPackageConfig]. */ + /** A builder for [MatrixWithDisplayNameConfig]. */ class Builder internal constructor() { + private var dimension: JsonField? = null + private var unitAmounts: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(groupedTieredPackageConfig: GroupedTieredPackageConfig) = apply { - additionalProperties = - groupedTieredPackageConfig.additionalProperties.toMutableMap() + internal fun from(matrixWithDisplayNameConfig: MatrixWithDisplayNameConfig) = + apply { + dimension = matrixWithDisplayNameConfig.dimension + unitAmounts = + matrixWithDisplayNameConfig.unitAmounts.map { it.toMutableList() } + additionalProperties = + matrixWithDisplayNameConfig.additionalProperties.toMutableMap() + } + + /** Used to determine the unit rate */ + fun dimension(dimension: String) = dimension(JsonField.of(dimension)) + + /** + * Sets [Builder.dimension] to an arbitrary JSON value. + * + * You should usually call [Builder.dimension] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun dimension(dimension: JsonField) = apply { this.dimension = dimension } + + /** Apply per unit pricing to each dimension value */ + fun unitAmounts(unitAmounts: List) = + unitAmounts(JsonField.of(unitAmounts)) + + /** + * Sets [Builder.unitAmounts] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmounts] with a well-typed + * `List` value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun unitAmounts(unitAmounts: JsonField>) = apply { + this.unitAmounts = unitAmounts.map { it.toMutableList() } + } + + /** + * Adds a single [UnitAmount] to [unitAmounts]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addUnitAmount(unitAmount: UnitAmount) = apply { + unitAmounts = + (unitAmounts ?: JsonField.of(mutableListOf())).also { + checkKnown("unitAmounts", it).add(unitAmount) + } } fun additionalProperties(additionalProperties: Map) = apply { @@ -40756,21 +45038,35 @@ private constructor( } /** - * Returns an immutable instance of [GroupedTieredPackageConfig]. + * Returns an immutable instance of [MatrixWithDisplayNameConfig]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .dimension() + * .unitAmounts() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ - fun build(): GroupedTieredPackageConfig = - GroupedTieredPackageConfig(additionalProperties.toImmutable()) + fun build(): MatrixWithDisplayNameConfig = + MatrixWithDisplayNameConfig( + checkRequired("dimension", dimension), + checkRequired("unitAmounts", unitAmounts).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false - fun validate(): GroupedTieredPackageConfig = apply { + fun validate(): MatrixWithDisplayNameConfig = apply { if (validated) { return@apply } + dimension() + unitAmounts().forEach { it.validate() } validated = true } @@ -40789,23 +45085,291 @@ private constructor( * Used for best match union deserialization. */ internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + (if (dimension.asKnown() == null) 0 else 1) + + (unitAmounts.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a unit amount item */ + class UnitAmount + private constructor( + private val dimensionValue: JsonField, + private val displayName: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("dimension_value") + @ExcludeMissing + dimensionValue: JsonField = JsonMissing.of(), + @JsonProperty("display_name") + @ExcludeMissing + displayName: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(dimensionValue, displayName, unitAmount, mutableMapOf()) + + /** + * The dimension value + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun dimensionValue(): String = dimensionValue.getRequired("dimension_value") + + /** + * Display name for this dimension value + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun displayName(): String = displayName.getRequired("display_name") + + /** + * Per unit amount + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [dimensionValue]. + * + * Unlike [dimensionValue], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("dimension_value") + @ExcludeMissing + fun _dimensionValue(): JsonField = dimensionValue + + /** + * Returns the raw JSON value of [displayName]. + * + * Unlike [displayName], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("display_name") + @ExcludeMissing + fun _displayName(): JsonField = displayName + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [UnitAmount]. + * + * The following fields are required: + * ```kotlin + * .dimensionValue() + * .displayName() + * .unitAmount() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [UnitAmount]. */ + class Builder internal constructor() { + + private var dimensionValue: JsonField? = null + private var displayName: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(unitAmount: UnitAmount) = apply { + dimensionValue = unitAmount.dimensionValue + displayName = unitAmount.displayName + this.unitAmount = unitAmount.unitAmount + additionalProperties = unitAmount.additionalProperties.toMutableMap() + } + + /** The dimension value */ + fun dimensionValue(dimensionValue: String) = + dimensionValue(JsonField.of(dimensionValue)) + + /** + * Sets [Builder.dimensionValue] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionValue] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun dimensionValue(dimensionValue: JsonField) = apply { + this.dimensionValue = dimensionValue + } + + /** Display name for this dimension value */ + fun displayName(displayName: String) = displayName(JsonField.of(displayName)) + + /** + * Sets [Builder.displayName] to an arbitrary JSON value. + * + * You should usually call [Builder.displayName] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun displayName(displayName: JsonField) = apply { + this.displayName = displayName + } + + /** Per unit amount */ + fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [UnitAmount]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .dimensionValue() + * .displayName() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UnitAmount = + UnitAmount( + checkRequired("dimensionValue", dimensionValue), + checkRequired("displayName", displayName), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UnitAmount = apply { + if (validated) { + return@apply + } + + dimensionValue() + displayName() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (dimensionValue.asKnown() == null) 0 else 1) + + (if (displayName.asKnown() == null) 0 else 1) + + (if (unitAmount.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnitAmount && + dimensionValue == other.dimensionValue && + displayName == other.displayName && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(dimensionValue, displayName, unitAmount, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UnitAmount{dimensionValue=$dimensionValue, displayName=$displayName, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is GroupedTieredPackageConfig && + return other is MatrixWithDisplayNameConfig && + dimension == other.dimension && + unitAmounts == other.unitAmounts && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + private val hashCode: Int by lazy { + Objects.hash(dimension, unitAmounts, additionalProperties) + } override fun hashCode(): Int = hashCode override fun toString() = - "GroupedTieredPackageConfig{additionalProperties=$additionalProperties}" + "MatrixWithDisplayNameConfig{dimension=$dimension, unitAmounts=$unitAmounts, additionalProperties=$additionalProperties}" } /** @@ -41047,7 +45611,7 @@ private constructor( return true } - return other is GroupedTieredPackage && + return other is MatrixWithDisplayName && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && @@ -41061,9 +45625,9 @@ private constructor( discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && - groupedTieredPackageConfig == other.groupedTieredPackageConfig && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && + matrixWithDisplayNameConfig == other.matrixWithDisplayNameConfig && maximum == other.maximum && maximumAmount == other.maximumAmount && metadata == other.metadata && @@ -41093,9 +45657,9 @@ private constructor( discount, externalPriceId, fixedPriceQuantity, - groupedTieredPackageConfig, invoicingCycleConfiguration, item, + matrixWithDisplayNameConfig, maximum, maximumAmount, metadata, @@ -41114,10 +45678,10 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "GroupedTieredPackage{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, groupedTieredPackageConfig=$groupedTieredPackageConfig, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "MatrixWithDisplayName{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, matrixWithDisplayNameConfig=$matrixWithDisplayNameConfig, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" } - class MaxGroupTieredPackage + class GroupedTieredPackage private constructor( private val id: JsonField, private val billableMetric: JsonField, @@ -41132,9 +45696,9 @@ private constructor( private val discount: JsonField, private val externalPriceId: JsonField, private val fixedPriceQuantity: JsonField, + private val groupedTieredPackageConfig: JsonField, private val invoicingCycleConfiguration: JsonField, private val item: JsonField, - private val maxGroupTieredPackageConfig: JsonField, private val maximum: JsonField, private val maximumAmount: JsonField, private val metadata: JsonField, @@ -41186,13 +45750,13 @@ private constructor( @JsonProperty("fixed_price_quantity") @ExcludeMissing fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("grouped_tiered_package_config") + @ExcludeMissing + groupedTieredPackageConfig: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), @JsonProperty("item") @ExcludeMissing item: JsonField = JsonMissing.of(), - @JsonProperty("max_group_tiered_package_config") - @ExcludeMissing - maxGroupTieredPackageConfig: JsonField = JsonMissing.of(), @JsonProperty("maximum") @ExcludeMissing maximum: JsonField = JsonMissing.of(), @JsonProperty("maximum_amount") @ExcludeMissing @@ -41233,9 +45797,9 @@ private constructor( discount, externalPriceId, fixedPriceQuantity, + groupedTieredPackageConfig, invoicingCycleConfiguration, item, - maxGroupTieredPackageConfig, maximum, maximumAmount, metadata, @@ -41331,6 +45895,15 @@ private constructor( */ fun fixedPriceQuantity(): Double? = fixedPriceQuantity.getNullable("fixed_price_quantity") + /** + * Configuration for grouped_tiered_package pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun groupedTieredPackageConfig(): GroupedTieredPackageConfig = + groupedTieredPackageConfig.getRequired("grouped_tiered_package_config") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -41344,13 +45917,6 @@ private constructor( */ fun item(): ItemSlim = item.getRequired("item") - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun maxGroupTieredPackageConfig(): MaxGroupTieredPackageConfig = - maxGroupTieredPackageConfig.getRequired("max_group_tiered_package_config") - /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -41388,9 +45954,11 @@ private constructor( fun minimumAmount(): String? = minimumAmount.getNullable("minimum_amount") /** + * The pricing model type + * * Expected to always return the following: * ```kotlin - * JsonValue.from("max_group_tiered_package") + * JsonValue.from("grouped_tiered_package") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -41553,6 +46121,17 @@ private constructor( @ExcludeMissing fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + /** + * Returns the raw JSON value of [groupedTieredPackageConfig]. + * + * Unlike [groupedTieredPackageConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouped_tiered_package_config") + @ExcludeMissing + fun _groupedTieredPackageConfig(): JsonField = + groupedTieredPackageConfig + /** * Returns the raw JSON value of [invoicingCycleConfiguration]. * @@ -41571,17 +46150,6 @@ private constructor( */ @JsonProperty("item") @ExcludeMissing fun _item(): JsonField = item - /** - * Returns the raw JSON value of [maxGroupTieredPackageConfig]. - * - * Unlike [maxGroupTieredPackageConfig], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("max_group_tiered_package_config") - @ExcludeMissing - fun _maxGroupTieredPackageConfig(): JsonField = - maxGroupTieredPackageConfig - /** * Returns the raw JSON value of [maximum]. * @@ -41693,7 +46261,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [MaxGroupTieredPackage]. + * Returns a mutable builder for constructing an instance of [GroupedTieredPackage]. * * The following fields are required: * ```kotlin @@ -41710,9 +46278,9 @@ private constructor( * .discount() * .externalPriceId() * .fixedPriceQuantity() + * .groupedTieredPackageConfig() * .invoicingCycleConfiguration() * .item() - * .maxGroupTieredPackageConfig() * .maximum() * .maximumAmount() * .metadata() @@ -41727,7 +46295,7 @@ private constructor( fun builder() = Builder() } - /** A builder for [MaxGroupTieredPackage]. */ + /** A builder for [GroupedTieredPackage]. */ class Builder internal constructor() { private var id: JsonField? = null @@ -41743,15 +46311,15 @@ private constructor( private var discount: JsonField? = null private var externalPriceId: JsonField? = null private var fixedPriceQuantity: JsonField? = null + private var groupedTieredPackageConfig: JsonField? = null private var invoicingCycleConfiguration: JsonField? = null private var item: JsonField? = null - private var maxGroupTieredPackageConfig: JsonField? = null private var maximum: JsonField? = null private var maximumAmount: JsonField? = null private var metadata: JsonField? = null private var minimum: JsonField? = null private var minimumAmount: JsonField? = null - private var modelType: JsonValue = JsonValue.from("max_group_tiered_package") + private var modelType: JsonValue = JsonValue.from("grouped_tiered_package") private var name: JsonField? = null private var planPhaseOrder: JsonField? = null private var priceType: JsonField? = null @@ -41760,36 +46328,36 @@ private constructor( JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(maxGroupTieredPackage: MaxGroupTieredPackage) = apply { - id = maxGroupTieredPackage.id - billableMetric = maxGroupTieredPackage.billableMetric - billingCycleConfiguration = maxGroupTieredPackage.billingCycleConfiguration - cadence = maxGroupTieredPackage.cadence + internal fun from(groupedTieredPackage: GroupedTieredPackage) = apply { + id = groupedTieredPackage.id + billableMetric = groupedTieredPackage.billableMetric + billingCycleConfiguration = groupedTieredPackage.billingCycleConfiguration + cadence = groupedTieredPackage.cadence compositePriceFilters = - maxGroupTieredPackage.compositePriceFilters.map { it.toMutableList() } - conversionRate = maxGroupTieredPackage.conversionRate - conversionRateConfig = maxGroupTieredPackage.conversionRateConfig - createdAt = maxGroupTieredPackage.createdAt - creditAllocation = maxGroupTieredPackage.creditAllocation - currency = maxGroupTieredPackage.currency - discount = maxGroupTieredPackage.discount - externalPriceId = maxGroupTieredPackage.externalPriceId - fixedPriceQuantity = maxGroupTieredPackage.fixedPriceQuantity - invoicingCycleConfiguration = maxGroupTieredPackage.invoicingCycleConfiguration - item = maxGroupTieredPackage.item - maxGroupTieredPackageConfig = maxGroupTieredPackage.maxGroupTieredPackageConfig - maximum = maxGroupTieredPackage.maximum - maximumAmount = maxGroupTieredPackage.maximumAmount - metadata = maxGroupTieredPackage.metadata - minimum = maxGroupTieredPackage.minimum - minimumAmount = maxGroupTieredPackage.minimumAmount - modelType = maxGroupTieredPackage.modelType - name = maxGroupTieredPackage.name - planPhaseOrder = maxGroupTieredPackage.planPhaseOrder - priceType = maxGroupTieredPackage.priceType - replacesPriceId = maxGroupTieredPackage.replacesPriceId - dimensionalPriceConfiguration = maxGroupTieredPackage.dimensionalPriceConfiguration - additionalProperties = maxGroupTieredPackage.additionalProperties.toMutableMap() + groupedTieredPackage.compositePriceFilters.map { it.toMutableList() } + conversionRate = groupedTieredPackage.conversionRate + conversionRateConfig = groupedTieredPackage.conversionRateConfig + createdAt = groupedTieredPackage.createdAt + creditAllocation = groupedTieredPackage.creditAllocation + currency = groupedTieredPackage.currency + discount = groupedTieredPackage.discount + externalPriceId = groupedTieredPackage.externalPriceId + fixedPriceQuantity = groupedTieredPackage.fixedPriceQuantity + groupedTieredPackageConfig = groupedTieredPackage.groupedTieredPackageConfig + invoicingCycleConfiguration = groupedTieredPackage.invoicingCycleConfiguration + item = groupedTieredPackage.item + maximum = groupedTieredPackage.maximum + maximumAmount = groupedTieredPackage.maximumAmount + metadata = groupedTieredPackage.metadata + minimum = groupedTieredPackage.minimum + minimumAmount = groupedTieredPackage.minimumAmount + modelType = groupedTieredPackage.modelType + name = groupedTieredPackage.name + planPhaseOrder = groupedTieredPackage.planPhaseOrder + priceType = groupedTieredPackage.priceType + replacesPriceId = groupedTieredPackage.replacesPriceId + dimensionalPriceConfiguration = groupedTieredPackage.dimensionalPriceConfiguration + additionalProperties = groupedTieredPackage.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) @@ -42111,6 +46679,21 @@ private constructor( this.fixedPriceQuantity = fixedPriceQuantity } + /** Configuration for grouped_tiered_package pricing */ + fun groupedTieredPackageConfig(groupedTieredPackageConfig: GroupedTieredPackageConfig) = + groupedTieredPackageConfig(JsonField.of(groupedTieredPackageConfig)) + + /** + * Sets [Builder.groupedTieredPackageConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.groupedTieredPackageConfig] with a well-typed + * [GroupedTieredPackageConfig] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun groupedTieredPackageConfig( + groupedTieredPackageConfig: JsonField + ) = apply { this.groupedTieredPackageConfig = groupedTieredPackageConfig } + fun invoicingCycleConfiguration( invoicingCycleConfiguration: BillingCycleConfiguration? ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) @@ -42137,21 +46720,6 @@ private constructor( */ fun item(item: JsonField) = apply { this.item = item } - fun maxGroupTieredPackageConfig( - maxGroupTieredPackageConfig: MaxGroupTieredPackageConfig - ) = maxGroupTieredPackageConfig(JsonField.of(maxGroupTieredPackageConfig)) - - /** - * Sets [Builder.maxGroupTieredPackageConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.maxGroupTieredPackageConfig] with a well-typed - * [MaxGroupTieredPackageConfig] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun maxGroupTieredPackageConfig( - maxGroupTieredPackageConfig: JsonField - ) = apply { this.maxGroupTieredPackageConfig = maxGroupTieredPackageConfig } - @Deprecated("deprecated") fun maximum(maximum: Maximum?) = maximum(JsonField.ofNullable(maximum)) @@ -42232,7 +46800,7 @@ private constructor( * It is usually unnecessary to call this method because the field defaults to the * following: * ```kotlin - * JsonValue.from("max_group_tiered_package") + * JsonValue.from("grouped_tiered_package") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -42336,7 +46904,7 @@ private constructor( } /** - * Returns an immutable instance of [MaxGroupTieredPackage]. + * Returns an immutable instance of [GroupedTieredPackage]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -42355,9 +46923,9 @@ private constructor( * .discount() * .externalPriceId() * .fixedPriceQuantity() + * .groupedTieredPackageConfig() * .invoicingCycleConfiguration() * .item() - * .maxGroupTieredPackageConfig() * .maximum() * .maximumAmount() * .metadata() @@ -42371,8 +46939,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): MaxGroupTieredPackage = - MaxGroupTieredPackage( + fun build(): GroupedTieredPackage = + GroupedTieredPackage( checkRequired("id", id), checkRequired("billableMetric", billableMetric), checkRequired("billingCycleConfiguration", billingCycleConfiguration), @@ -42388,9 +46956,9 @@ private constructor( checkRequired("discount", discount), checkRequired("externalPriceId", externalPriceId), checkRequired("fixedPriceQuantity", fixedPriceQuantity), + checkRequired("groupedTieredPackageConfig", groupedTieredPackageConfig), checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), checkRequired("item", item), - checkRequired("maxGroupTieredPackageConfig", maxGroupTieredPackageConfig), checkRequired("maximum", maximum), checkRequired("maximumAmount", maximumAmount), checkRequired("metadata", metadata), @@ -42408,7 +46976,7 @@ private constructor( private var validated: Boolean = false - fun validate(): MaxGroupTieredPackage = apply { + fun validate(): GroupedTieredPackage = apply { if (validated) { return@apply } @@ -42426,16 +46994,16 @@ private constructor( discount()?.validate() externalPriceId() fixedPriceQuantity() + groupedTieredPackageConfig().validate() invoicingCycleConfiguration()?.validate() item().validate() - maxGroupTieredPackageConfig().validate() maximum()?.validate() maximumAmount() metadata().validate() minimum()?.validate() minimumAmount() _modelType().let { - if (it != JsonValue.from("max_group_tiered_package")) { + if (it != JsonValue.from("grouped_tiered_package")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } @@ -42475,15 +47043,15 @@ private constructor( (discount.asKnown()?.validity() ?: 0) + (if (externalPriceId.asKnown() == null) 0 else 1) + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (groupedTieredPackageConfig.asKnown()?.validity() ?: 0) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + (item.asKnown()?.validity() ?: 0) + - (maxGroupTieredPackageConfig.asKnown()?.validity() ?: 0) + (maximum.asKnown()?.validity() ?: 0) + (if (maximumAmount.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) + (minimum.asKnown()?.validity() ?: 0) + (if (minimumAmount.asKnown() == null) 0 else 1) + - modelType.let { if (it == JsonValue.from("max_group_tiered_package")) 1 else 0 } + + modelType.let { if (it == JsonValue.from("grouped_tiered_package")) 1 else 0 } + (if (name.asKnown() == null) 0 else 1) + (if (planPhaseOrder.asKnown() == null) 0 else 1) + (priceType.asKnown()?.validity() ?: 0) + @@ -42642,16 +47210,92 @@ private constructor( override fun toString() = value.toString() } - class MaxGroupTieredPackageConfig - @JsonCreator + /** Configuration for grouped_tiered_package pricing */ + class GroupedTieredPackageConfig private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map + private val groupingKey: JsonField, + private val packageSize: JsonField, + private val tiers: JsonField>, + private val additionalProperties: MutableMap, ) { + @JsonCreator + private constructor( + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("package_size") + @ExcludeMissing + packageSize: JsonField = JsonMissing.of(), + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of(), + ) : this(groupingKey, packageSize, tiers, mutableMapOf()) + + /** + * The event property used to group before tiering + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * Package size + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun packageSize(): String = packageSize.getRequired("package_size") + + /** + * Apply tiered pricing after rounding up the quantity to the package size. Tiers are + * defined using exclusive lower bounds. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun tiers(): List = tiers.getRequired("tiers") + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [packageSize]. + * + * Unlike [packageSize], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("package_size") + @ExcludeMissing + fun _packageSize(): JsonField = packageSize + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tiers") @ExcludeMissing fun _tiers(): JsonField> = tiers + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) fun toBuilder() = Builder().from(this) @@ -42659,128 +47303,437 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [MaxGroupTieredPackageConfig]. + * [GroupedTieredPackageConfig]. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .packageSize() + * .tiers() + * ``` */ fun builder() = Builder() } - /** A builder for [MaxGroupTieredPackageConfig]. */ + /** A builder for [GroupedTieredPackageConfig]. */ class Builder internal constructor() { + private var groupingKey: JsonField? = null + private var packageSize: JsonField? = null + private var tiers: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(maxGroupTieredPackageConfig: MaxGroupTieredPackageConfig) = - apply { - additionalProperties = - maxGroupTieredPackageConfig.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) + internal fun from(groupedTieredPackageConfig: GroupedTieredPackageConfig) = apply { + groupingKey = groupedTieredPackageConfig.groupingKey + packageSize = groupedTieredPackageConfig.packageSize + tiers = groupedTieredPackageConfig.tiers.map { it.toMutableList() } + additionalProperties = + groupedTieredPackageConfig.additionalProperties.toMutableMap() } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** The event property used to group before tiering */ + fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) /** - * Returns an immutable instance of [MaxGroupTieredPackageConfig]. + * Sets [Builder.groupingKey] to an arbitrary JSON value. * - * Further updates to this [Builder] will not mutate the returned instance. + * You should usually call [Builder.groupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. */ - fun build(): MaxGroupTieredPackageConfig = - MaxGroupTieredPackageConfig(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): MaxGroupTieredPackageConfig = apply { - if (validated) { - return@apply + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey } - validated = true - } + /** Package size */ + fun packageSize(packageSize: String) = packageSize(JsonField.of(packageSize)) - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false + /** + * Sets [Builder.packageSize] to an arbitrary JSON value. + * + * You should usually call [Builder.packageSize] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun packageSize(packageSize: JsonField) = apply { + this.packageSize = packageSize } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + /** + * Apply tiered pricing after rounding up the quantity to the package size. Tiers + * are defined using exclusive lower bounds. + */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } } - return other is MaxGroupTieredPackageConfig && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "MaxGroupTieredPackageConfig{additionalProperties=$additionalProperties}" - } - - /** - * User specified key-value pairs for the resource. If not present, this defaults to an - * empty dictionary. Individual keys can be removed by setting the value to `null`, and the - * entire metadata mapping can be cleared by setting `metadata` to `null`. - */ - class Metadata - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Metadata]. */ - fun builder() = Builder() - } - - /** A builder for [Metadata]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(metadata: Metadata) = apply { - additionalProperties = metadata.additionalProperties.toMutableMap() + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [GroupedTieredPackageConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .packageSize() + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedTieredPackageConfig = + GroupedTieredPackageConfig( + checkRequired("groupingKey", groupingKey), + checkRequired("packageSize", packageSize), + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GroupedTieredPackageConfig = apply { + if (validated) { + return@apply + } + + groupingKey() + packageSize() + tiers().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (groupingKey.asKnown() == null) 0 else 1) + + (if (packageSize.asKnown() == null) 0 else 1) + + (tiers.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single tier */ + class Tier + private constructor( + private val perUnit: JsonField, + private val tierLowerBound: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("per_unit") + @ExcludeMissing + perUnit: JsonField = JsonMissing.of(), + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + ) : this(perUnit, tierLowerBound, mutableMapOf()) + + /** + * Price per package + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun perUnit(): String = perUnit.getRequired("per_unit") + + /** + * Tier lower bound + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun tierLowerBound(): String = tierLowerBound.getRequired("tier_lower_bound") + + /** + * Returns the raw JSON value of [perUnit]. + * + * Unlike [perUnit], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("per_unit") + @ExcludeMissing + fun _perUnit(): JsonField = perUnit + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Tier]. + * + * The following fields are required: + * ```kotlin + * .perUnit() + * .tierLowerBound() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var perUnit: JsonField? = null + private var tierLowerBound: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(tier: Tier) = apply { + perUnit = tier.perUnit + tierLowerBound = tier.tierLowerBound + additionalProperties = tier.additionalProperties.toMutableMap() + } + + /** Price per package */ + fun perUnit(perUnit: String) = perUnit(JsonField.of(perUnit)) + + /** + * Sets [Builder.perUnit] to an arbitrary JSON value. + * + * You should usually call [Builder.perUnit] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun perUnit(perUnit: JsonField) = apply { this.perUnit = perUnit } + + /** Tier lower bound */ + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Tier]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .perUnit() + * .tierLowerBound() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("perUnit", perUnit), + checkRequired("tierLowerBound", tierLowerBound), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + perUnit() + tierLowerBound() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (perUnit.asKnown() == null) 0 else 1) + + (if (tierLowerBound.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + perUnit == other.perUnit && + tierLowerBound == other.tierLowerBound && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(perUnit, tierLowerBound, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{perUnit=$perUnit, tierLowerBound=$tierLowerBound, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedTieredPackageConfig && + groupingKey == other.groupingKey && + packageSize == other.packageSize && + tiers == other.tiers && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(groupingKey, packageSize, tiers, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedTieredPackageConfig{groupingKey=$groupingKey, packageSize=$packageSize, tiers=$tiers, additionalProperties=$additionalProperties}" + } + + /** + * User specified key-value pairs for the resource. If not present, this defaults to an + * empty dictionary. Individual keys can be removed by setting the value to `null`, and the + * entire metadata mapping can be cleared by setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() } fun additionalProperties(additionalProperties: Map) = apply { @@ -42989,7 +47942,7 @@ private constructor( return true } - return other is MaxGroupTieredPackage && + return other is GroupedTieredPackage && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && @@ -43003,9 +47956,9 @@ private constructor( discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && + groupedTieredPackageConfig == other.groupedTieredPackageConfig && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && - maxGroupTieredPackageConfig == other.maxGroupTieredPackageConfig && maximum == other.maximum && maximumAmount == other.maximumAmount && metadata == other.metadata && @@ -43035,9 +47988,9 @@ private constructor( discount, externalPriceId, fixedPriceQuantity, + groupedTieredPackageConfig, invoicingCycleConfiguration, item, - maxGroupTieredPackageConfig, maximum, maximumAmount, metadata, @@ -43056,10 +48009,10 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "MaxGroupTieredPackage{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maxGroupTieredPackageConfig=$maxGroupTieredPackageConfig, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "GroupedTieredPackage{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, groupedTieredPackageConfig=$groupedTieredPackageConfig, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" } - class ScalableMatrixWithUnitPricing + class MaxGroupTieredPackage private constructor( private val id: JsonField, private val billableMetric: JsonField, @@ -43076,6 +48029,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoicingCycleConfiguration: JsonField, private val item: JsonField, + private val maxGroupTieredPackageConfig: JsonField, private val maximum: JsonField, private val maximumAmount: JsonField, private val metadata: JsonField, @@ -43086,8 +48040,6 @@ private constructor( private val planPhaseOrder: JsonField, private val priceType: JsonField, private val replacesPriceId: JsonField, - private val scalableMatrixWithUnitPricingConfig: - JsonField, private val dimensionalPriceConfiguration: JsonField, private val additionalProperties: MutableMap, ) { @@ -43133,6 +48085,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), @JsonProperty("item") @ExcludeMissing item: JsonField = JsonMissing.of(), + @JsonProperty("max_group_tiered_package_config") + @ExcludeMissing + maxGroupTieredPackageConfig: JsonField = JsonMissing.of(), @JsonProperty("maximum") @ExcludeMissing maximum: JsonField = JsonMissing.of(), @JsonProperty("maximum_amount") @ExcludeMissing @@ -43155,10 +48110,6 @@ private constructor( @JsonProperty("replaces_price_id") @ExcludeMissing replacesPriceId: JsonField = JsonMissing.of(), - @JsonProperty("scalable_matrix_with_unit_pricing_config") - @ExcludeMissing - scalableMatrixWithUnitPricingConfig: JsonField = - JsonMissing.of(), @JsonProperty("dimensional_price_configuration") @ExcludeMissing dimensionalPriceConfiguration: JsonField = @@ -43179,6 +48130,7 @@ private constructor( fixedPriceQuantity, invoicingCycleConfiguration, item, + maxGroupTieredPackageConfig, maximum, maximumAmount, metadata, @@ -43189,7 +48141,6 @@ private constructor( planPhaseOrder, priceType, replacesPriceId, - scalableMatrixWithUnitPricingConfig, dimensionalPriceConfiguration, mutableMapOf(), ) @@ -43288,6 +48239,15 @@ private constructor( */ fun item(): ItemSlim = item.getRequired("item") + /** + * Configuration for max_group_tiered_package pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun maxGroupTieredPackageConfig(): MaxGroupTieredPackageConfig = + maxGroupTieredPackageConfig.getRequired("max_group_tiered_package_config") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -43325,9 +48285,11 @@ private constructor( fun minimumAmount(): String? = minimumAmount.getNullable("minimum_amount") /** + * The pricing model type + * * Expected to always return the following: * ```kotlin - * JsonValue.from("scalable_matrix_with_unit_pricing") + * JsonValue.from("max_group_tiered_package") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -43362,15 +48324,6 @@ private constructor( */ fun replacesPriceId(): String? = replacesPriceId.getNullable("replaces_price_id") - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun scalableMatrixWithUnitPricingConfig(): ScalableMatrixWithUnitPricingConfig = - scalableMatrixWithUnitPricingConfig.getRequired( - "scalable_matrix_with_unit_pricing_config" - ) - /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -43517,6 +48470,17 @@ private constructor( */ @JsonProperty("item") @ExcludeMissing fun _item(): JsonField = item + /** + * Returns the raw JSON value of [maxGroupTieredPackageConfig]. + * + * Unlike [maxGroupTieredPackageConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("max_group_tiered_package_config") + @ExcludeMissing + fun _maxGroupTieredPackageConfig(): JsonField = + maxGroupTieredPackageConfig + /** * Returns the raw JSON value of [maximum]. * @@ -43602,17 +48566,6 @@ private constructor( @ExcludeMissing fun _replacesPriceId(): JsonField = replacesPriceId - /** - * Returns the raw JSON value of [scalableMatrixWithUnitPricingConfig]. - * - * Unlike [scalableMatrixWithUnitPricingConfig], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("scalable_matrix_with_unit_pricing_config") - @ExcludeMissing - fun _scalableMatrixWithUnitPricingConfig(): JsonField = - scalableMatrixWithUnitPricingConfig - /** * Returns the raw JSON value of [dimensionalPriceConfiguration]. * @@ -43639,8 +48592,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [ScalableMatrixWithUnitPricing]. + * Returns a mutable builder for constructing an instance of [MaxGroupTieredPackage]. * * The following fields are required: * ```kotlin @@ -43659,6 +48611,7 @@ private constructor( * .fixedPriceQuantity() * .invoicingCycleConfiguration() * .item() + * .maxGroupTieredPackageConfig() * .maximum() * .maximumAmount() * .metadata() @@ -43668,13 +48621,12 @@ private constructor( * .planPhaseOrder() * .priceType() * .replacesPriceId() - * .scalableMatrixWithUnitPricingConfig() * ``` */ fun builder() = Builder() } - /** A builder for [ScalableMatrixWithUnitPricing]. */ + /** A builder for [MaxGroupTieredPackage]. */ class Builder internal constructor() { private var id: JsonField? = null @@ -43692,62 +48644,52 @@ private constructor( private var fixedPriceQuantity: JsonField? = null private var invoicingCycleConfiguration: JsonField? = null private var item: JsonField? = null + private var maxGroupTieredPackageConfig: JsonField? = null private var maximum: JsonField? = null private var maximumAmount: JsonField? = null private var metadata: JsonField? = null private var minimum: JsonField? = null private var minimumAmount: JsonField? = null - private var modelType: JsonValue = JsonValue.from("scalable_matrix_with_unit_pricing") + private var modelType: JsonValue = JsonValue.from("max_group_tiered_package") private var name: JsonField? = null private var planPhaseOrder: JsonField? = null private var priceType: JsonField? = null private var replacesPriceId: JsonField? = null - private var scalableMatrixWithUnitPricingConfig: - JsonField? = - null private var dimensionalPriceConfiguration: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(scalableMatrixWithUnitPricing: ScalableMatrixWithUnitPricing) = - apply { - id = scalableMatrixWithUnitPricing.id - billableMetric = scalableMatrixWithUnitPricing.billableMetric - billingCycleConfiguration = - scalableMatrixWithUnitPricing.billingCycleConfiguration - cadence = scalableMatrixWithUnitPricing.cadence - compositePriceFilters = - scalableMatrixWithUnitPricing.compositePriceFilters.map { - it.toMutableList() - } - conversionRate = scalableMatrixWithUnitPricing.conversionRate - conversionRateConfig = scalableMatrixWithUnitPricing.conversionRateConfig - createdAt = scalableMatrixWithUnitPricing.createdAt - creditAllocation = scalableMatrixWithUnitPricing.creditAllocation - currency = scalableMatrixWithUnitPricing.currency - discount = scalableMatrixWithUnitPricing.discount - externalPriceId = scalableMatrixWithUnitPricing.externalPriceId - fixedPriceQuantity = scalableMatrixWithUnitPricing.fixedPriceQuantity - invoicingCycleConfiguration = - scalableMatrixWithUnitPricing.invoicingCycleConfiguration - item = scalableMatrixWithUnitPricing.item - maximum = scalableMatrixWithUnitPricing.maximum - maximumAmount = scalableMatrixWithUnitPricing.maximumAmount - metadata = scalableMatrixWithUnitPricing.metadata - minimum = scalableMatrixWithUnitPricing.minimum - minimumAmount = scalableMatrixWithUnitPricing.minimumAmount - modelType = scalableMatrixWithUnitPricing.modelType - name = scalableMatrixWithUnitPricing.name - planPhaseOrder = scalableMatrixWithUnitPricing.planPhaseOrder - priceType = scalableMatrixWithUnitPricing.priceType - replacesPriceId = scalableMatrixWithUnitPricing.replacesPriceId - scalableMatrixWithUnitPricingConfig = - scalableMatrixWithUnitPricing.scalableMatrixWithUnitPricingConfig - dimensionalPriceConfiguration = - scalableMatrixWithUnitPricing.dimensionalPriceConfiguration - additionalProperties = - scalableMatrixWithUnitPricing.additionalProperties.toMutableMap() - } + internal fun from(maxGroupTieredPackage: MaxGroupTieredPackage) = apply { + id = maxGroupTieredPackage.id + billableMetric = maxGroupTieredPackage.billableMetric + billingCycleConfiguration = maxGroupTieredPackage.billingCycleConfiguration + cadence = maxGroupTieredPackage.cadence + compositePriceFilters = + maxGroupTieredPackage.compositePriceFilters.map { it.toMutableList() } + conversionRate = maxGroupTieredPackage.conversionRate + conversionRateConfig = maxGroupTieredPackage.conversionRateConfig + createdAt = maxGroupTieredPackage.createdAt + creditAllocation = maxGroupTieredPackage.creditAllocation + currency = maxGroupTieredPackage.currency + discount = maxGroupTieredPackage.discount + externalPriceId = maxGroupTieredPackage.externalPriceId + fixedPriceQuantity = maxGroupTieredPackage.fixedPriceQuantity + invoicingCycleConfiguration = maxGroupTieredPackage.invoicingCycleConfiguration + item = maxGroupTieredPackage.item + maxGroupTieredPackageConfig = maxGroupTieredPackage.maxGroupTieredPackageConfig + maximum = maxGroupTieredPackage.maximum + maximumAmount = maxGroupTieredPackage.maximumAmount + metadata = maxGroupTieredPackage.metadata + minimum = maxGroupTieredPackage.minimum + minimumAmount = maxGroupTieredPackage.minimumAmount + modelType = maxGroupTieredPackage.modelType + name = maxGroupTieredPackage.name + planPhaseOrder = maxGroupTieredPackage.planPhaseOrder + priceType = maxGroupTieredPackage.priceType + replacesPriceId = maxGroupTieredPackage.replacesPriceId + dimensionalPriceConfiguration = maxGroupTieredPackage.dimensionalPriceConfiguration + additionalProperties = maxGroupTieredPackage.additionalProperties.toMutableMap() + } fun id(id: String) = id(JsonField.of(id)) @@ -44094,6 +49036,22 @@ private constructor( */ fun item(item: JsonField) = apply { this.item = item } + /** Configuration for max_group_tiered_package pricing */ + fun maxGroupTieredPackageConfig( + maxGroupTieredPackageConfig: MaxGroupTieredPackageConfig + ) = maxGroupTieredPackageConfig(JsonField.of(maxGroupTieredPackageConfig)) + + /** + * Sets [Builder.maxGroupTieredPackageConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.maxGroupTieredPackageConfig] with a well-typed + * [MaxGroupTieredPackageConfig] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun maxGroupTieredPackageConfig( + maxGroupTieredPackageConfig: JsonField + ) = apply { this.maxGroupTieredPackageConfig = maxGroupTieredPackageConfig } + @Deprecated("deprecated") fun maximum(maximum: Maximum?) = maximum(JsonField.ofNullable(maximum)) @@ -44174,7 +49132,7 @@ private constructor( * It is usually unnecessary to call this method because the field defaults to the * following: * ```kotlin - * JsonValue.from("scalable_matrix_with_unit_pricing") + * JsonValue.from("max_group_tiered_package") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -44243,26 +49201,6 @@ private constructor( this.replacesPriceId = replacesPriceId } - fun scalableMatrixWithUnitPricingConfig( - scalableMatrixWithUnitPricingConfig: ScalableMatrixWithUnitPricingConfig - ) = - scalableMatrixWithUnitPricingConfig( - JsonField.of(scalableMatrixWithUnitPricingConfig) - ) - - /** - * Sets [Builder.scalableMatrixWithUnitPricingConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.scalableMatrixWithUnitPricingConfig] with a - * well-typed [ScalableMatrixWithUnitPricingConfig] value instead. This method is - * primarily for setting the field to an undocumented or not yet supported value. - */ - fun scalableMatrixWithUnitPricingConfig( - scalableMatrixWithUnitPricingConfig: JsonField - ) = apply { - this.scalableMatrixWithUnitPricingConfig = scalableMatrixWithUnitPricingConfig - } - fun dimensionalPriceConfiguration( dimensionalPriceConfiguration: DimensionalPriceConfiguration? ) = dimensionalPriceConfiguration(JsonField.ofNullable(dimensionalPriceConfiguration)) @@ -44298,7 +49236,7 @@ private constructor( } /** - * Returns an immutable instance of [ScalableMatrixWithUnitPricing]. + * Returns an immutable instance of [MaxGroupTieredPackage]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -44319,6 +49257,7 @@ private constructor( * .fixedPriceQuantity() * .invoicingCycleConfiguration() * .item() + * .maxGroupTieredPackageConfig() * .maximum() * .maximumAmount() * .metadata() @@ -44328,13 +49267,12 @@ private constructor( * .planPhaseOrder() * .priceType() * .replacesPriceId() - * .scalableMatrixWithUnitPricingConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): ScalableMatrixWithUnitPricing = - ScalableMatrixWithUnitPricing( + fun build(): MaxGroupTieredPackage = + MaxGroupTieredPackage( checkRequired("id", id), checkRequired("billableMetric", billableMetric), checkRequired("billingCycleConfiguration", billingCycleConfiguration), @@ -44352,6 +49290,7 @@ private constructor( checkRequired("fixedPriceQuantity", fixedPriceQuantity), checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), checkRequired("item", item), + checkRequired("maxGroupTieredPackageConfig", maxGroupTieredPackageConfig), checkRequired("maximum", maximum), checkRequired("maximumAmount", maximumAmount), checkRequired("metadata", metadata), @@ -44362,10 +49301,6 @@ private constructor( checkRequired("planPhaseOrder", planPhaseOrder), checkRequired("priceType", priceType), checkRequired("replacesPriceId", replacesPriceId), - checkRequired( - "scalableMatrixWithUnitPricingConfig", - scalableMatrixWithUnitPricingConfig, - ), dimensionalPriceConfiguration, additionalProperties.toMutableMap(), ) @@ -44373,7 +49308,7 @@ private constructor( private var validated: Boolean = false - fun validate(): ScalableMatrixWithUnitPricing = apply { + fun validate(): MaxGroupTieredPackage = apply { if (validated) { return@apply } @@ -44393,13 +49328,14 @@ private constructor( fixedPriceQuantity() invoicingCycleConfiguration()?.validate() item().validate() + maxGroupTieredPackageConfig().validate() maximum()?.validate() maximumAmount() metadata().validate() minimum()?.validate() minimumAmount() _modelType().let { - if (it != JsonValue.from("scalable_matrix_with_unit_pricing")) { + if (it != JsonValue.from("max_group_tiered_package")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } @@ -44407,7 +49343,6 @@ private constructor( planPhaseOrder() priceType().validate() replacesPriceId() - scalableMatrixWithUnitPricingConfig().validate() dimensionalPriceConfiguration()?.validate() validated = true } @@ -44442,19 +49377,17 @@ private constructor( (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + (item.asKnown()?.validity() ?: 0) + + (maxGroupTieredPackageConfig.asKnown()?.validity() ?: 0) + (maximum.asKnown()?.validity() ?: 0) + (if (maximumAmount.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) + (minimum.asKnown()?.validity() ?: 0) + (if (minimumAmount.asKnown() == null) 0 else 1) + - modelType.let { - if (it == JsonValue.from("scalable_matrix_with_unit_pricing")) 1 else 0 - } + + modelType.let { if (it == JsonValue.from("max_group_tiered_package")) 1 else 0 } + (if (name.asKnown() == null) 0 else 1) + (if (planPhaseOrder.asKnown() == null) 0 else 1) + (priceType.asKnown()?.validity() ?: 0) + (if (replacesPriceId.asKnown() == null) 0 else 1) + - (scalableMatrixWithUnitPricingConfig.asKnown()?.validity() ?: 0) + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) class Cadence @JsonCreator private constructor(private val value: JsonField) : @@ -44609,6 +49542,502 @@ private constructor( override fun toString() = value.toString() } + /** Configuration for max_group_tiered_package pricing */ + class MaxGroupTieredPackageConfig + private constructor( + private val groupingKey: JsonField, + private val packageSize: JsonField, + private val tiers: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("package_size") + @ExcludeMissing + packageSize: JsonField = JsonMissing.of(), + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of(), + ) : this(groupingKey, packageSize, tiers, mutableMapOf()) + + /** + * The event property used to group before tiering the group with the highest value + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * Package size + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun packageSize(): String = packageSize.getRequired("package_size") + + /** + * Apply tiered pricing to the largest group after grouping with the provided key. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun tiers(): List = tiers.getRequired("tiers") + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [packageSize]. + * + * Unlike [packageSize], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("package_size") + @ExcludeMissing + fun _packageSize(): JsonField = packageSize + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tiers") @ExcludeMissing fun _tiers(): JsonField> = tiers + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [MaxGroupTieredPackageConfig]. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .packageSize() + * .tiers() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [MaxGroupTieredPackageConfig]. */ + class Builder internal constructor() { + + private var groupingKey: JsonField? = null + private var packageSize: JsonField? = null + private var tiers: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(maxGroupTieredPackageConfig: MaxGroupTieredPackageConfig) = + apply { + groupingKey = maxGroupTieredPackageConfig.groupingKey + packageSize = maxGroupTieredPackageConfig.packageSize + tiers = maxGroupTieredPackageConfig.tiers.map { it.toMutableList() } + additionalProperties = + maxGroupTieredPackageConfig.additionalProperties.toMutableMap() + } + + /** + * The event property used to group before tiering the group with the highest value + */ + fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** Package size */ + fun packageSize(packageSize: String) = packageSize(JsonField.of(packageSize)) + + /** + * Sets [Builder.packageSize] to an arbitrary JSON value. + * + * You should usually call [Builder.packageSize] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun packageSize(packageSize: JsonField) = apply { + this.packageSize = packageSize + } + + /** + * Apply tiered pricing to the largest group after grouping with the provided key. + */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [MaxGroupTieredPackageConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .packageSize() + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MaxGroupTieredPackageConfig = + MaxGroupTieredPackageConfig( + checkRequired("groupingKey", groupingKey), + checkRequired("packageSize", packageSize), + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MaxGroupTieredPackageConfig = apply { + if (validated) { + return@apply + } + + groupingKey() + packageSize() + tiers().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (groupingKey.asKnown() == null) 0 else 1) + + (if (packageSize.asKnown() == null) 0 else 1) + + (tiers.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single tier */ + class Tier + private constructor( + private val tierLowerBound: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(tierLowerBound, unitAmount, mutableMapOf()) + + /** + * Tier lower bound + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun tierLowerBound(): String = tierLowerBound.getRequired("tier_lower_bound") + + /** + * Per unit amount + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Tier]. + * + * The following fields are required: + * ```kotlin + * .tierLowerBound() + * .unitAmount() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var tierLowerBound: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(tier: Tier) = apply { + tierLowerBound = tier.tierLowerBound + unitAmount = tier.unitAmount + additionalProperties = tier.additionalProperties.toMutableMap() + } + + /** Tier lower bound */ + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + /** Per unit amount */ + fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Tier]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .tierLowerBound() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("tierLowerBound", tierLowerBound), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + tierLowerBound() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (tierLowerBound.asKnown() == null) 0 else 1) + + (if (unitAmount.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + tierLowerBound == other.tierLowerBound && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(tierLowerBound, unitAmount, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MaxGroupTieredPackageConfig && + groupingKey == other.groupingKey && + packageSize == other.packageSize && + tiers == other.tiers && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(groupingKey, packageSize, tiers, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MaxGroupTieredPackageConfig{groupingKey=$groupingKey, packageSize=$packageSize, tiers=$tiers, additionalProperties=$additionalProperties}" + } + /** * User specified key-value pairs for the resource. If not present, this defaults to an * empty dictionary. Individual keys can be removed by setting the value to `null`, and the @@ -44843,121 +50272,12 @@ private constructor( override fun toString() = value.toString() } - class ScalableMatrixWithUnitPricingConfig - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [ScalableMatrixWithUnitPricingConfig]. - */ - fun builder() = Builder() - } - - /** A builder for [ScalableMatrixWithUnitPricingConfig]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from( - scalableMatrixWithUnitPricingConfig: ScalableMatrixWithUnitPricingConfig - ) = apply { - additionalProperties = - scalableMatrixWithUnitPricingConfig.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [ScalableMatrixWithUnitPricingConfig]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): ScalableMatrixWithUnitPricingConfig = - ScalableMatrixWithUnitPricingConfig(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): ScalableMatrixWithUnitPricingConfig = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ScalableMatrixWithUnitPricingConfig && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "ScalableMatrixWithUnitPricingConfig{additionalProperties=$additionalProperties}" - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is ScalableMatrixWithUnitPricing && + return other is MaxGroupTieredPackage && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && @@ -44973,6 +50293,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && + maxGroupTieredPackageConfig == other.maxGroupTieredPackageConfig && maximum == other.maximum && maximumAmount == other.maximumAmount && metadata == other.metadata && @@ -44983,7 +50304,6 @@ private constructor( planPhaseOrder == other.planPhaseOrder && priceType == other.priceType && replacesPriceId == other.replacesPriceId && - scalableMatrixWithUnitPricingConfig == other.scalableMatrixWithUnitPricingConfig && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties } @@ -45005,6 +50325,7 @@ private constructor( fixedPriceQuantity, invoicingCycleConfiguration, item, + maxGroupTieredPackageConfig, maximum, maximumAmount, metadata, @@ -45015,7 +50336,6 @@ private constructor( planPhaseOrder, priceType, replacesPriceId, - scalableMatrixWithUnitPricingConfig, dimensionalPriceConfiguration, additionalProperties, ) @@ -45024,10 +50344,10 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "ScalableMatrixWithUnitPricing{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, scalableMatrixWithUnitPricingConfig=$scalableMatrixWithUnitPricingConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "MaxGroupTieredPackage{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maxGroupTieredPackageConfig=$maxGroupTieredPackageConfig, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" } - class ScalableMatrixWithTieredPricing + class ScalableMatrixWithUnitPricing private constructor( private val id: JsonField, private val billableMetric: JsonField, @@ -45054,8 +50374,8 @@ private constructor( private val planPhaseOrder: JsonField, private val priceType: JsonField, private val replacesPriceId: JsonField, - private val scalableMatrixWithTieredPricingConfig: - JsonField, + private val scalableMatrixWithUnitPricingConfig: + JsonField, private val dimensionalPriceConfiguration: JsonField, private val additionalProperties: MutableMap, ) { @@ -45123,10 +50443,9 @@ private constructor( @JsonProperty("replaces_price_id") @ExcludeMissing replacesPriceId: JsonField = JsonMissing.of(), - @JsonProperty("scalable_matrix_with_tiered_pricing_config") + @JsonProperty("scalable_matrix_with_unit_pricing_config") @ExcludeMissing - scalableMatrixWithTieredPricingConfig: - JsonField = + scalableMatrixWithUnitPricingConfig: JsonField = JsonMissing.of(), @JsonProperty("dimensional_price_configuration") @ExcludeMissing @@ -45158,7 +50477,7 @@ private constructor( planPhaseOrder, priceType, replacesPriceId, - scalableMatrixWithTieredPricingConfig, + scalableMatrixWithUnitPricingConfig, dimensionalPriceConfiguration, mutableMapOf(), ) @@ -45294,9 +50613,11 @@ private constructor( fun minimumAmount(): String? = minimumAmount.getNullable("minimum_amount") /** + * The pricing model type + * * Expected to always return the following: * ```kotlin - * JsonValue.from("scalable_matrix_with_tiered_pricing") + * JsonValue.from("scalable_matrix_with_unit_pricing") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -45332,12 +50653,14 @@ private constructor( fun replacesPriceId(): String? = replacesPriceId.getNullable("replaces_price_id") /** + * Configuration for scalable_matrix_with_unit_pricing pricing + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ - fun scalableMatrixWithTieredPricingConfig(): ScalableMatrixWithTieredPricingConfig = - scalableMatrixWithTieredPricingConfig.getRequired( - "scalable_matrix_with_tiered_pricing_config" + fun scalableMatrixWithUnitPricingConfig(): ScalableMatrixWithUnitPricingConfig = + scalableMatrixWithUnitPricingConfig.getRequired( + "scalable_matrix_with_unit_pricing_config" ) /** @@ -45572,15 +50895,15 @@ private constructor( fun _replacesPriceId(): JsonField = replacesPriceId /** - * Returns the raw JSON value of [scalableMatrixWithTieredPricingConfig]. + * Returns the raw JSON value of [scalableMatrixWithUnitPricingConfig]. * - * Unlike [scalableMatrixWithTieredPricingConfig], this method doesn't throw if the JSON - * field has an unexpected type. + * Unlike [scalableMatrixWithUnitPricingConfig], this method doesn't throw if the JSON field + * has an unexpected type. */ - @JsonProperty("scalable_matrix_with_tiered_pricing_config") + @JsonProperty("scalable_matrix_with_unit_pricing_config") @ExcludeMissing - fun _scalableMatrixWithTieredPricingConfig(): - JsonField = scalableMatrixWithTieredPricingConfig + fun _scalableMatrixWithUnitPricingConfig(): JsonField = + scalableMatrixWithUnitPricingConfig /** * Returns the raw JSON value of [dimensionalPriceConfiguration]. @@ -45609,7 +50932,7 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [ScalableMatrixWithTieredPricing]. + * [ScalableMatrixWithUnitPricing]. * * The following fields are required: * ```kotlin @@ -45637,13 +50960,13 @@ private constructor( * .planPhaseOrder() * .priceType() * .replacesPriceId() - * .scalableMatrixWithTieredPricingConfig() + * .scalableMatrixWithUnitPricingConfig() * ``` */ fun builder() = Builder() } - /** A builder for [ScalableMatrixWithTieredPricing]. */ + /** A builder for [ScalableMatrixWithUnitPricing]. */ class Builder internal constructor() { private var id: JsonField? = null @@ -45666,56 +50989,56 @@ private constructor( private var metadata: JsonField? = null private var minimum: JsonField? = null private var minimumAmount: JsonField? = null - private var modelType: JsonValue = JsonValue.from("scalable_matrix_with_tiered_pricing") + private var modelType: JsonValue = JsonValue.from("scalable_matrix_with_unit_pricing") private var name: JsonField? = null private var planPhaseOrder: JsonField? = null private var priceType: JsonField? = null private var replacesPriceId: JsonField? = null - private var scalableMatrixWithTieredPricingConfig: - JsonField? = + private var scalableMatrixWithUnitPricingConfig: + JsonField? = null private var dimensionalPriceConfiguration: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(scalableMatrixWithTieredPricing: ScalableMatrixWithTieredPricing) = + internal fun from(scalableMatrixWithUnitPricing: ScalableMatrixWithUnitPricing) = apply { - id = scalableMatrixWithTieredPricing.id - billableMetric = scalableMatrixWithTieredPricing.billableMetric + id = scalableMatrixWithUnitPricing.id + billableMetric = scalableMatrixWithUnitPricing.billableMetric billingCycleConfiguration = - scalableMatrixWithTieredPricing.billingCycleConfiguration - cadence = scalableMatrixWithTieredPricing.cadence + scalableMatrixWithUnitPricing.billingCycleConfiguration + cadence = scalableMatrixWithUnitPricing.cadence compositePriceFilters = - scalableMatrixWithTieredPricing.compositePriceFilters.map { + scalableMatrixWithUnitPricing.compositePriceFilters.map { it.toMutableList() } - conversionRate = scalableMatrixWithTieredPricing.conversionRate - conversionRateConfig = scalableMatrixWithTieredPricing.conversionRateConfig - createdAt = scalableMatrixWithTieredPricing.createdAt - creditAllocation = scalableMatrixWithTieredPricing.creditAllocation - currency = scalableMatrixWithTieredPricing.currency - discount = scalableMatrixWithTieredPricing.discount - externalPriceId = scalableMatrixWithTieredPricing.externalPriceId - fixedPriceQuantity = scalableMatrixWithTieredPricing.fixedPriceQuantity + conversionRate = scalableMatrixWithUnitPricing.conversionRate + conversionRateConfig = scalableMatrixWithUnitPricing.conversionRateConfig + createdAt = scalableMatrixWithUnitPricing.createdAt + creditAllocation = scalableMatrixWithUnitPricing.creditAllocation + currency = scalableMatrixWithUnitPricing.currency + discount = scalableMatrixWithUnitPricing.discount + externalPriceId = scalableMatrixWithUnitPricing.externalPriceId + fixedPriceQuantity = scalableMatrixWithUnitPricing.fixedPriceQuantity invoicingCycleConfiguration = - scalableMatrixWithTieredPricing.invoicingCycleConfiguration - item = scalableMatrixWithTieredPricing.item - maximum = scalableMatrixWithTieredPricing.maximum - maximumAmount = scalableMatrixWithTieredPricing.maximumAmount - metadata = scalableMatrixWithTieredPricing.metadata - minimum = scalableMatrixWithTieredPricing.minimum - minimumAmount = scalableMatrixWithTieredPricing.minimumAmount - modelType = scalableMatrixWithTieredPricing.modelType - name = scalableMatrixWithTieredPricing.name - planPhaseOrder = scalableMatrixWithTieredPricing.planPhaseOrder - priceType = scalableMatrixWithTieredPricing.priceType - replacesPriceId = scalableMatrixWithTieredPricing.replacesPriceId - scalableMatrixWithTieredPricingConfig = - scalableMatrixWithTieredPricing.scalableMatrixWithTieredPricingConfig + scalableMatrixWithUnitPricing.invoicingCycleConfiguration + item = scalableMatrixWithUnitPricing.item + maximum = scalableMatrixWithUnitPricing.maximum + maximumAmount = scalableMatrixWithUnitPricing.maximumAmount + metadata = scalableMatrixWithUnitPricing.metadata + minimum = scalableMatrixWithUnitPricing.minimum + minimumAmount = scalableMatrixWithUnitPricing.minimumAmount + modelType = scalableMatrixWithUnitPricing.modelType + name = scalableMatrixWithUnitPricing.name + planPhaseOrder = scalableMatrixWithUnitPricing.planPhaseOrder + priceType = scalableMatrixWithUnitPricing.priceType + replacesPriceId = scalableMatrixWithUnitPricing.replacesPriceId + scalableMatrixWithUnitPricingConfig = + scalableMatrixWithUnitPricing.scalableMatrixWithUnitPricingConfig dimensionalPriceConfiguration = - scalableMatrixWithTieredPricing.dimensionalPriceConfiguration + scalableMatrixWithUnitPricing.dimensionalPriceConfiguration additionalProperties = - scalableMatrixWithTieredPricing.additionalProperties.toMutableMap() + scalableMatrixWithUnitPricing.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) @@ -46143,7 +51466,7 @@ private constructor( * It is usually unnecessary to call this method because the field defaults to the * following: * ```kotlin - * JsonValue.from("scalable_matrix_with_tiered_pricing") + * JsonValue.from("scalable_matrix_with_unit_pricing") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -46212,25 +51535,25 @@ private constructor( this.replacesPriceId = replacesPriceId } - fun scalableMatrixWithTieredPricingConfig( - scalableMatrixWithTieredPricingConfig: ScalableMatrixWithTieredPricingConfig + /** Configuration for scalable_matrix_with_unit_pricing pricing */ + fun scalableMatrixWithUnitPricingConfig( + scalableMatrixWithUnitPricingConfig: ScalableMatrixWithUnitPricingConfig ) = - scalableMatrixWithTieredPricingConfig( - JsonField.of(scalableMatrixWithTieredPricingConfig) + scalableMatrixWithUnitPricingConfig( + JsonField.of(scalableMatrixWithUnitPricingConfig) ) /** - * Sets [Builder.scalableMatrixWithTieredPricingConfig] to an arbitrary JSON value. + * Sets [Builder.scalableMatrixWithUnitPricingConfig] to an arbitrary JSON value. * - * You should usually call [Builder.scalableMatrixWithTieredPricingConfig] with a - * well-typed [ScalableMatrixWithTieredPricingConfig] value instead. This method is + * You should usually call [Builder.scalableMatrixWithUnitPricingConfig] with a + * well-typed [ScalableMatrixWithUnitPricingConfig] value instead. This method is * primarily for setting the field to an undocumented or not yet supported value. */ - fun scalableMatrixWithTieredPricingConfig( - scalableMatrixWithTieredPricingConfig: - JsonField + fun scalableMatrixWithUnitPricingConfig( + scalableMatrixWithUnitPricingConfig: JsonField ) = apply { - this.scalableMatrixWithTieredPricingConfig = scalableMatrixWithTieredPricingConfig + this.scalableMatrixWithUnitPricingConfig = scalableMatrixWithUnitPricingConfig } fun dimensionalPriceConfiguration( @@ -46268,7 +51591,7 @@ private constructor( } /** - * Returns an immutable instance of [ScalableMatrixWithTieredPricing]. + * Returns an immutable instance of [ScalableMatrixWithUnitPricing]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -46298,13 +51621,13 @@ private constructor( * .planPhaseOrder() * .priceType() * .replacesPriceId() - * .scalableMatrixWithTieredPricingConfig() + * .scalableMatrixWithUnitPricingConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): ScalableMatrixWithTieredPricing = - ScalableMatrixWithTieredPricing( + fun build(): ScalableMatrixWithUnitPricing = + ScalableMatrixWithUnitPricing( checkRequired("id", id), checkRequired("billableMetric", billableMetric), checkRequired("billingCycleConfiguration", billingCycleConfiguration), @@ -46333,8 +51656,8 @@ private constructor( checkRequired("priceType", priceType), checkRequired("replacesPriceId", replacesPriceId), checkRequired( - "scalableMatrixWithTieredPricingConfig", - scalableMatrixWithTieredPricingConfig, + "scalableMatrixWithUnitPricingConfig", + scalableMatrixWithUnitPricingConfig, ), dimensionalPriceConfiguration, additionalProperties.toMutableMap(), @@ -46343,7 +51666,7 @@ private constructor( private var validated: Boolean = false - fun validate(): ScalableMatrixWithTieredPricing = apply { + fun validate(): ScalableMatrixWithUnitPricing = apply { if (validated) { return@apply } @@ -46369,7 +51692,7 @@ private constructor( minimum()?.validate() minimumAmount() _modelType().let { - if (it != JsonValue.from("scalable_matrix_with_tiered_pricing")) { + if (it != JsonValue.from("scalable_matrix_with_unit_pricing")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } @@ -46377,7 +51700,7 @@ private constructor( planPhaseOrder() priceType().validate() replacesPriceId() - scalableMatrixWithTieredPricingConfig().validate() + scalableMatrixWithUnitPricingConfig().validate() dimensionalPriceConfiguration()?.validate() validated = true } @@ -46418,13 +51741,13 @@ private constructor( (minimum.asKnown()?.validity() ?: 0) + (if (minimumAmount.asKnown() == null) 0 else 1) + modelType.let { - if (it == JsonValue.from("scalable_matrix_with_tiered_pricing")) 1 else 0 + if (it == JsonValue.from("scalable_matrix_with_unit_pricing")) 1 else 0 } + (if (name.asKnown() == null) 0 else 1) + (if (planPhaseOrder.asKnown() == null) 0 else 1) + (priceType.asKnown()?.validity() ?: 0) + (if (replacesPriceId.asKnown() == null) 0 else 1) + - (scalableMatrixWithTieredPricingConfig.asKnown()?.validity() ?: 0) + + (scalableMatrixWithUnitPricingConfig.asKnown()?.validity() ?: 0) + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) class Cadence @JsonCreator private constructor(private val value: JsonField) : @@ -46813,16 +52136,143 @@ private constructor( override fun toString() = value.toString() } - class ScalableMatrixWithTieredPricingConfig - @JsonCreator + /** Configuration for scalable_matrix_with_unit_pricing pricing */ + class ScalableMatrixWithUnitPricingConfig private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map + private val firstDimension: JsonField, + private val matrixScalingFactors: JsonField>, + private val unitPrice: JsonField, + private val prorate: JsonField, + private val secondDimension: JsonField, + private val additionalProperties: MutableMap, ) { + @JsonCreator + private constructor( + @JsonProperty("first_dimension") + @ExcludeMissing + firstDimension: JsonField = JsonMissing.of(), + @JsonProperty("matrix_scaling_factors") + @ExcludeMissing + matrixScalingFactors: JsonField> = JsonMissing.of(), + @JsonProperty("unit_price") + @ExcludeMissing + unitPrice: JsonField = JsonMissing.of(), + @JsonProperty("prorate") + @ExcludeMissing + prorate: JsonField = JsonMissing.of(), + @JsonProperty("second_dimension") + @ExcludeMissing + secondDimension: JsonField = JsonMissing.of(), + ) : this( + firstDimension, + matrixScalingFactors, + unitPrice, + prorate, + secondDimension, + mutableMapOf(), + ) + + /** + * Used to determine the unit rate + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun firstDimension(): String = firstDimension.getRequired("first_dimension") + + /** + * Apply a scaling factor to each dimension + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun matrixScalingFactors(): List = + matrixScalingFactors.getRequired("matrix_scaling_factors") + + /** + * The final unit price to rate against the output of the matrix + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun unitPrice(): String = unitPrice.getRequired("unit_price") + + /** + * If true, the unit price will be prorated to the billing period + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun prorate(): Boolean? = prorate.getNullable("prorate") + + /** + * Used to determine the unit rate (optional) + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun secondDimension(): String? = secondDimension.getNullable("second_dimension") + + /** + * Returns the raw JSON value of [firstDimension]. + * + * Unlike [firstDimension], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("first_dimension") + @ExcludeMissing + fun _firstDimension(): JsonField = firstDimension + + /** + * Returns the raw JSON value of [matrixScalingFactors]. + * + * Unlike [matrixScalingFactors], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("matrix_scaling_factors") + @ExcludeMissing + fun _matrixScalingFactors(): JsonField> = matrixScalingFactors + + /** + * Returns the raw JSON value of [unitPrice]. + * + * Unlike [unitPrice], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("unit_price") + @ExcludeMissing + fun _unitPrice(): JsonField = unitPrice + + /** + * Returns the raw JSON value of [prorate]. + * + * Unlike [prorate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("prorate") @ExcludeMissing fun _prorate(): JsonField = prorate + + /** + * Returns the raw JSON value of [secondDimension]. + * + * Unlike [secondDimension], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("second_dimension") + @ExcludeMissing + fun _secondDimension(): JsonField = secondDimension + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) fun toBuilder() = Builder().from(this) @@ -46830,21 +52280,132 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [ScalableMatrixWithTieredPricingConfig]. + * [ScalableMatrixWithUnitPricingConfig]. + * + * The following fields are required: + * ```kotlin + * .firstDimension() + * .matrixScalingFactors() + * .unitPrice() + * ``` */ fun builder() = Builder() } - /** A builder for [ScalableMatrixWithTieredPricingConfig]. */ + /** A builder for [ScalableMatrixWithUnitPricingConfig]. */ class Builder internal constructor() { + private var firstDimension: JsonField? = null + private var matrixScalingFactors: JsonField>? = + null + private var unitPrice: JsonField? = null + private var prorate: JsonField = JsonMissing.of() + private var secondDimension: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() internal fun from( - scalableMatrixWithTieredPricingConfig: ScalableMatrixWithTieredPricingConfig + scalableMatrixWithUnitPricingConfig: ScalableMatrixWithUnitPricingConfig ) = apply { + firstDimension = scalableMatrixWithUnitPricingConfig.firstDimension + matrixScalingFactors = + scalableMatrixWithUnitPricingConfig.matrixScalingFactors.map { + it.toMutableList() + } + unitPrice = scalableMatrixWithUnitPricingConfig.unitPrice + prorate = scalableMatrixWithUnitPricingConfig.prorate + secondDimension = scalableMatrixWithUnitPricingConfig.secondDimension additionalProperties = - scalableMatrixWithTieredPricingConfig.additionalProperties.toMutableMap() + scalableMatrixWithUnitPricingConfig.additionalProperties.toMutableMap() + } + + /** Used to determine the unit rate */ + fun firstDimension(firstDimension: String) = + firstDimension(JsonField.of(firstDimension)) + + /** + * Sets [Builder.firstDimension] to an arbitrary JSON value. + * + * You should usually call [Builder.firstDimension] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun firstDimension(firstDimension: JsonField) = apply { + this.firstDimension = firstDimension + } + + /** Apply a scaling factor to each dimension */ + fun matrixScalingFactors(matrixScalingFactors: List) = + matrixScalingFactors(JsonField.of(matrixScalingFactors)) + + /** + * Sets [Builder.matrixScalingFactors] to an arbitrary JSON value. + * + * You should usually call [Builder.matrixScalingFactors] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun matrixScalingFactors( + matrixScalingFactors: JsonField> + ) = apply { + this.matrixScalingFactors = matrixScalingFactors.map { it.toMutableList() } + } + + /** + * Adds a single [MatrixScalingFactor] to [matrixScalingFactors]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addMatrixScalingFactor(matrixScalingFactor: MatrixScalingFactor) = apply { + matrixScalingFactors = + (matrixScalingFactors ?: JsonField.of(mutableListOf())).also { + checkKnown("matrixScalingFactors", it).add(matrixScalingFactor) + } + } + + /** The final unit price to rate against the output of the matrix */ + fun unitPrice(unitPrice: String) = unitPrice(JsonField.of(unitPrice)) + + /** + * Sets [Builder.unitPrice] to an arbitrary JSON value. + * + * You should usually call [Builder.unitPrice] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun unitPrice(unitPrice: JsonField) = apply { this.unitPrice = unitPrice } + + /** If true, the unit price will be prorated to the billing period */ + fun prorate(prorate: Boolean?) = prorate(JsonField.ofNullable(prorate)) + + /** + * Alias for [Builder.prorate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun prorate(prorate: Boolean) = prorate(prorate as Boolean?) + + /** + * Sets [Builder.prorate] to an arbitrary JSON value. + * + * You should usually call [Builder.prorate] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun prorate(prorate: JsonField) = apply { this.prorate = prorate } + + /** Used to determine the unit rate (optional) */ + fun secondDimension(secondDimension: String?) = + secondDimension(JsonField.ofNullable(secondDimension)) + + /** + * Sets [Builder.secondDimension] to an arbitrary JSON value. + * + * You should usually call [Builder.secondDimension] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun secondDimension(secondDimension: JsonField) = apply { + this.secondDimension = secondDimension } fun additionalProperties(additionalProperties: Map) = apply { @@ -46870,21 +52431,44 @@ private constructor( } /** - * Returns an immutable instance of [ScalableMatrixWithTieredPricingConfig]. + * Returns an immutable instance of [ScalableMatrixWithUnitPricingConfig]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .firstDimension() + * .matrixScalingFactors() + * .unitPrice() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ - fun build(): ScalableMatrixWithTieredPricingConfig = - ScalableMatrixWithTieredPricingConfig(additionalProperties.toImmutable()) + fun build(): ScalableMatrixWithUnitPricingConfig = + ScalableMatrixWithUnitPricingConfig( + checkRequired("firstDimension", firstDimension), + checkRequired("matrixScalingFactors", matrixScalingFactors).map { + it.toImmutable() + }, + checkRequired("unitPrice", unitPrice), + prorate, + secondDimension, + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false - fun validate(): ScalableMatrixWithTieredPricingConfig = apply { + fun validate(): ScalableMatrixWithUnitPricingConfig = apply { if (validated) { return@apply } + firstDimension() + matrixScalingFactors().forEach { it.validate() } + unitPrice() + prorate() + secondDimension() validated = true } @@ -46903,23 +52487,312 @@ private constructor( * Used for best match union deserialization. */ internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + (if (firstDimension.asKnown() == null) 0 else 1) + + (matrixScalingFactors.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + (if (unitPrice.asKnown() == null) 0 else 1) + + (if (prorate.asKnown() == null) 0 else 1) + + (if (secondDimension.asKnown() == null) 0 else 1) + + /** Configuration for a single matrix scaling factor */ + class MatrixScalingFactor + private constructor( + private val firstDimensionValue: JsonField, + private val scalingFactor: JsonField, + private val secondDimensionValue: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("first_dimension_value") + @ExcludeMissing + firstDimensionValue: JsonField = JsonMissing.of(), + @JsonProperty("scaling_factor") + @ExcludeMissing + scalingFactor: JsonField = JsonMissing.of(), + @JsonProperty("second_dimension_value") + @ExcludeMissing + secondDimensionValue: JsonField = JsonMissing.of(), + ) : this(firstDimensionValue, scalingFactor, secondDimensionValue, mutableMapOf()) + + /** + * First dimension value + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun firstDimensionValue(): String = + firstDimensionValue.getRequired("first_dimension_value") + + /** + * Scaling factor + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun scalingFactor(): String = scalingFactor.getRequired("scaling_factor") + + /** + * Second dimension value (optional) + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun secondDimensionValue(): String? = + secondDimensionValue.getNullable("second_dimension_value") + + /** + * Returns the raw JSON value of [firstDimensionValue]. + * + * Unlike [firstDimensionValue], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("first_dimension_value") + @ExcludeMissing + fun _firstDimensionValue(): JsonField = firstDimensionValue + + /** + * Returns the raw JSON value of [scalingFactor]. + * + * Unlike [scalingFactor], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("scaling_factor") + @ExcludeMissing + fun _scalingFactor(): JsonField = scalingFactor + + /** + * Returns the raw JSON value of [secondDimensionValue]. + * + * Unlike [secondDimensionValue], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("second_dimension_value") + @ExcludeMissing + fun _secondDimensionValue(): JsonField = secondDimensionValue + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [MatrixScalingFactor]. + * + * The following fields are required: + * ```kotlin + * .firstDimensionValue() + * .scalingFactor() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [MatrixScalingFactor]. */ + class Builder internal constructor() { + + private var firstDimensionValue: JsonField? = null + private var scalingFactor: JsonField? = null + private var secondDimensionValue: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(matrixScalingFactor: MatrixScalingFactor) = apply { + firstDimensionValue = matrixScalingFactor.firstDimensionValue + scalingFactor = matrixScalingFactor.scalingFactor + secondDimensionValue = matrixScalingFactor.secondDimensionValue + additionalProperties = + matrixScalingFactor.additionalProperties.toMutableMap() + } + + /** First dimension value */ + fun firstDimensionValue(firstDimensionValue: String) = + firstDimensionValue(JsonField.of(firstDimensionValue)) + + /** + * Sets [Builder.firstDimensionValue] to an arbitrary JSON value. + * + * You should usually call [Builder.firstDimensionValue] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun firstDimensionValue(firstDimensionValue: JsonField) = apply { + this.firstDimensionValue = firstDimensionValue + } + + /** Scaling factor */ + fun scalingFactor(scalingFactor: String) = + scalingFactor(JsonField.of(scalingFactor)) + + /** + * Sets [Builder.scalingFactor] to an arbitrary JSON value. + * + * You should usually call [Builder.scalingFactor] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun scalingFactor(scalingFactor: JsonField) = apply { + this.scalingFactor = scalingFactor + } + + /** Second dimension value (optional) */ + fun secondDimensionValue(secondDimensionValue: String?) = + secondDimensionValue(JsonField.ofNullable(secondDimensionValue)) + + /** + * Sets [Builder.secondDimensionValue] to an arbitrary JSON value. + * + * You should usually call [Builder.secondDimensionValue] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun secondDimensionValue(secondDimensionValue: JsonField) = apply { + this.secondDimensionValue = secondDimensionValue + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [MatrixScalingFactor]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .firstDimensionValue() + * .scalingFactor() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MatrixScalingFactor = + MatrixScalingFactor( + checkRequired("firstDimensionValue", firstDimensionValue), + checkRequired("scalingFactor", scalingFactor), + secondDimensionValue, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MatrixScalingFactor = apply { + if (validated) { + return@apply + } + + firstDimensionValue() + scalingFactor() + secondDimensionValue() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (firstDimensionValue.asKnown() == null) 0 else 1) + + (if (scalingFactor.asKnown() == null) 0 else 1) + + (if (secondDimensionValue.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MatrixScalingFactor && + firstDimensionValue == other.firstDimensionValue && + scalingFactor == other.scalingFactor && + secondDimensionValue == other.secondDimensionValue && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + firstDimensionValue, + scalingFactor, + secondDimensionValue, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MatrixScalingFactor{firstDimensionValue=$firstDimensionValue, scalingFactor=$scalingFactor, secondDimensionValue=$secondDimensionValue, additionalProperties=$additionalProperties}" + } override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is ScalableMatrixWithTieredPricingConfig && + return other is ScalableMatrixWithUnitPricingConfig && + firstDimension == other.firstDimension && + matrixScalingFactors == other.matrixScalingFactors && + unitPrice == other.unitPrice && + prorate == other.prorate && + secondDimension == other.secondDimension && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + private val hashCode: Int by lazy { + Objects.hash( + firstDimension, + matrixScalingFactors, + unitPrice, + prorate, + secondDimension, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode override fun toString() = - "ScalableMatrixWithTieredPricingConfig{additionalProperties=$additionalProperties}" + "ScalableMatrixWithUnitPricingConfig{firstDimension=$firstDimension, matrixScalingFactors=$matrixScalingFactors, unitPrice=$unitPrice, prorate=$prorate, secondDimension=$secondDimension, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { @@ -46927,7 +52800,7 @@ private constructor( return true } - return other is ScalableMatrixWithTieredPricing && + return other is ScalableMatrixWithUnitPricing && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && @@ -46953,8 +52826,7 @@ private constructor( planPhaseOrder == other.planPhaseOrder && priceType == other.priceType && replacesPriceId == other.replacesPriceId && - scalableMatrixWithTieredPricingConfig == - other.scalableMatrixWithTieredPricingConfig && + scalableMatrixWithUnitPricingConfig == other.scalableMatrixWithUnitPricingConfig && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties } @@ -46986,7 +52858,7 @@ private constructor( planPhaseOrder, priceType, replacesPriceId, - scalableMatrixWithTieredPricingConfig, + scalableMatrixWithUnitPricingConfig, dimensionalPriceConfiguration, additionalProperties, ) @@ -46995,10 +52867,10 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "ScalableMatrixWithTieredPricing{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, scalableMatrixWithTieredPricingConfig=$scalableMatrixWithTieredPricingConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "ScalableMatrixWithUnitPricing{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, scalableMatrixWithUnitPricingConfig=$scalableMatrixWithUnitPricingConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" } - class CumulativeGroupedBulk + class ScalableMatrixWithTieredPricing private constructor( private val id: JsonField, private val billableMetric: JsonField, @@ -47009,7 +52881,6 @@ private constructor( private val conversionRateConfig: JsonField, private val createdAt: JsonField, private val creditAllocation: JsonField, - private val cumulativeGroupedBulkConfig: JsonField, private val currency: JsonField, private val discount: JsonField, private val externalPriceId: JsonField, @@ -47026,6 +52897,8 @@ private constructor( private val planPhaseOrder: JsonField, private val priceType: JsonField, private val replacesPriceId: JsonField, + private val scalableMatrixWithTieredPricingConfig: + JsonField, private val dimensionalPriceConfiguration: JsonField, private val additionalProperties: MutableMap, ) { @@ -47055,9 +52928,6 @@ private constructor( @JsonProperty("credit_allocation") @ExcludeMissing creditAllocation: JsonField = JsonMissing.of(), - @JsonProperty("cumulative_grouped_bulk_config") - @ExcludeMissing - cumulativeGroupedBulkConfig: JsonField = JsonMissing.of(), @JsonProperty("currency") @ExcludeMissing currency: JsonField = JsonMissing.of(), @@ -47096,6 +52966,11 @@ private constructor( @JsonProperty("replaces_price_id") @ExcludeMissing replacesPriceId: JsonField = JsonMissing.of(), + @JsonProperty("scalable_matrix_with_tiered_pricing_config") + @ExcludeMissing + scalableMatrixWithTieredPricingConfig: + JsonField = + JsonMissing.of(), @JsonProperty("dimensional_price_configuration") @ExcludeMissing dimensionalPriceConfiguration: JsonField = @@ -47110,7 +52985,6 @@ private constructor( conversionRateConfig, createdAt, creditAllocation, - cumulativeGroupedBulkConfig, currency, discount, externalPriceId, @@ -47127,6 +53001,7 @@ private constructor( planPhaseOrder, priceType, replacesPriceId, + scalableMatrixWithTieredPricingConfig, dimensionalPriceConfiguration, mutableMapOf(), ) @@ -47188,13 +53063,6 @@ private constructor( */ fun creditAllocation(): Allocation? = creditAllocation.getNullable("credit_allocation") - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun cumulativeGroupedBulkConfig(): CumulativeGroupedBulkConfig = - cumulativeGroupedBulkConfig.getRequired("cumulative_grouped_bulk_config") - /** * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). @@ -47269,9 +53137,11 @@ private constructor( fun minimumAmount(): String? = minimumAmount.getNullable("minimum_amount") /** + * The pricing model type + * * Expected to always return the following: * ```kotlin - * JsonValue.from("cumulative_grouped_bulk") + * JsonValue.from("scalable_matrix_with_tiered_pricing") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -47306,6 +53176,17 @@ private constructor( */ fun replacesPriceId(): String? = replacesPriceId.getNullable("replaces_price_id") + /** + * Configuration for scalable_matrix_with_tiered_pricing pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun scalableMatrixWithTieredPricingConfig(): ScalableMatrixWithTieredPricingConfig = + scalableMatrixWithTieredPricingConfig.getRequired( + "scalable_matrix_with_tiered_pricing_config" + ) + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -47397,17 +53278,6 @@ private constructor( @ExcludeMissing fun _creditAllocation(): JsonField = creditAllocation - /** - * Returns the raw JSON value of [cumulativeGroupedBulkConfig]. - * - * Unlike [cumulativeGroupedBulkConfig], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("cumulative_grouped_bulk_config") - @ExcludeMissing - fun _cumulativeGroupedBulkConfig(): JsonField = - cumulativeGroupedBulkConfig - /** * Returns the raw JSON value of [currency]. * @@ -47548,6 +53418,17 @@ private constructor( @ExcludeMissing fun _replacesPriceId(): JsonField = replacesPriceId + /** + * Returns the raw JSON value of [scalableMatrixWithTieredPricingConfig]. + * + * Unlike [scalableMatrixWithTieredPricingConfig], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("scalable_matrix_with_tiered_pricing_config") + @ExcludeMissing + fun _scalableMatrixWithTieredPricingConfig(): + JsonField = scalableMatrixWithTieredPricingConfig + /** * Returns the raw JSON value of [dimensionalPriceConfiguration]. * @@ -47574,7 +53455,8 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [CumulativeGroupedBulk]. + * Returns a mutable builder for constructing an instance of + * [ScalableMatrixWithTieredPricing]. * * The following fields are required: * ```kotlin @@ -47587,7 +53469,6 @@ private constructor( * .conversionRateConfig() * .createdAt() * .creditAllocation() - * .cumulativeGroupedBulkConfig() * .currency() * .discount() * .externalPriceId() @@ -47603,12 +53484,13 @@ private constructor( * .planPhaseOrder() * .priceType() * .replacesPriceId() + * .scalableMatrixWithTieredPricingConfig() * ``` */ fun builder() = Builder() } - /** A builder for [CumulativeGroupedBulk]. */ + /** A builder for [ScalableMatrixWithTieredPricing]. */ class Builder internal constructor() { private var id: JsonField? = null @@ -47620,7 +53502,6 @@ private constructor( private var conversionRateConfig: JsonField? = null private var createdAt: JsonField? = null private var creditAllocation: JsonField? = null - private var cumulativeGroupedBulkConfig: JsonField? = null private var currency: JsonField? = null private var discount: JsonField? = null private var externalPriceId: JsonField? = null @@ -47632,46 +53513,57 @@ private constructor( private var metadata: JsonField? = null private var minimum: JsonField? = null private var minimumAmount: JsonField? = null - private var modelType: JsonValue = JsonValue.from("cumulative_grouped_bulk") + private var modelType: JsonValue = JsonValue.from("scalable_matrix_with_tiered_pricing") private var name: JsonField? = null private var planPhaseOrder: JsonField? = null private var priceType: JsonField? = null private var replacesPriceId: JsonField? = null + private var scalableMatrixWithTieredPricingConfig: + JsonField? = + null private var dimensionalPriceConfiguration: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(cumulativeGroupedBulk: CumulativeGroupedBulk) = apply { - id = cumulativeGroupedBulk.id - billableMetric = cumulativeGroupedBulk.billableMetric - billingCycleConfiguration = cumulativeGroupedBulk.billingCycleConfiguration - cadence = cumulativeGroupedBulk.cadence - compositePriceFilters = - cumulativeGroupedBulk.compositePriceFilters.map { it.toMutableList() } - conversionRate = cumulativeGroupedBulk.conversionRate - conversionRateConfig = cumulativeGroupedBulk.conversionRateConfig - createdAt = cumulativeGroupedBulk.createdAt - creditAllocation = cumulativeGroupedBulk.creditAllocation - cumulativeGroupedBulkConfig = cumulativeGroupedBulk.cumulativeGroupedBulkConfig - currency = cumulativeGroupedBulk.currency - discount = cumulativeGroupedBulk.discount - externalPriceId = cumulativeGroupedBulk.externalPriceId - fixedPriceQuantity = cumulativeGroupedBulk.fixedPriceQuantity - invoicingCycleConfiguration = cumulativeGroupedBulk.invoicingCycleConfiguration - item = cumulativeGroupedBulk.item - maximum = cumulativeGroupedBulk.maximum - maximumAmount = cumulativeGroupedBulk.maximumAmount - metadata = cumulativeGroupedBulk.metadata - minimum = cumulativeGroupedBulk.minimum - minimumAmount = cumulativeGroupedBulk.minimumAmount - modelType = cumulativeGroupedBulk.modelType - name = cumulativeGroupedBulk.name - planPhaseOrder = cumulativeGroupedBulk.planPhaseOrder - priceType = cumulativeGroupedBulk.priceType - replacesPriceId = cumulativeGroupedBulk.replacesPriceId - dimensionalPriceConfiguration = cumulativeGroupedBulk.dimensionalPriceConfiguration - additionalProperties = cumulativeGroupedBulk.additionalProperties.toMutableMap() - } + internal fun from(scalableMatrixWithTieredPricing: ScalableMatrixWithTieredPricing) = + apply { + id = scalableMatrixWithTieredPricing.id + billableMetric = scalableMatrixWithTieredPricing.billableMetric + billingCycleConfiguration = + scalableMatrixWithTieredPricing.billingCycleConfiguration + cadence = scalableMatrixWithTieredPricing.cadence + compositePriceFilters = + scalableMatrixWithTieredPricing.compositePriceFilters.map { + it.toMutableList() + } + conversionRate = scalableMatrixWithTieredPricing.conversionRate + conversionRateConfig = scalableMatrixWithTieredPricing.conversionRateConfig + createdAt = scalableMatrixWithTieredPricing.createdAt + creditAllocation = scalableMatrixWithTieredPricing.creditAllocation + currency = scalableMatrixWithTieredPricing.currency + discount = scalableMatrixWithTieredPricing.discount + externalPriceId = scalableMatrixWithTieredPricing.externalPriceId + fixedPriceQuantity = scalableMatrixWithTieredPricing.fixedPriceQuantity + invoicingCycleConfiguration = + scalableMatrixWithTieredPricing.invoicingCycleConfiguration + item = scalableMatrixWithTieredPricing.item + maximum = scalableMatrixWithTieredPricing.maximum + maximumAmount = scalableMatrixWithTieredPricing.maximumAmount + metadata = scalableMatrixWithTieredPricing.metadata + minimum = scalableMatrixWithTieredPricing.minimum + minimumAmount = scalableMatrixWithTieredPricing.minimumAmount + modelType = scalableMatrixWithTieredPricing.modelType + name = scalableMatrixWithTieredPricing.name + planPhaseOrder = scalableMatrixWithTieredPricing.planPhaseOrder + priceType = scalableMatrixWithTieredPricing.priceType + replacesPriceId = scalableMatrixWithTieredPricing.replacesPriceId + scalableMatrixWithTieredPricingConfig = + scalableMatrixWithTieredPricing.scalableMatrixWithTieredPricingConfig + dimensionalPriceConfiguration = + scalableMatrixWithTieredPricing.dimensionalPriceConfiguration + additionalProperties = + scalableMatrixWithTieredPricing.additionalProperties.toMutableMap() + } fun id(id: String) = id(JsonField.of(id)) @@ -47861,21 +53753,6 @@ private constructor( this.creditAllocation = creditAllocation } - fun cumulativeGroupedBulkConfig( - cumulativeGroupedBulkConfig: CumulativeGroupedBulkConfig - ) = cumulativeGroupedBulkConfig(JsonField.of(cumulativeGroupedBulkConfig)) - - /** - * Sets [Builder.cumulativeGroupedBulkConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.cumulativeGroupedBulkConfig] with a well-typed - * [CumulativeGroupedBulkConfig] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun cumulativeGroupedBulkConfig( - cumulativeGroupedBulkConfig: JsonField - ) = apply { this.cumulativeGroupedBulkConfig = cumulativeGroupedBulkConfig } - fun currency(currency: String) = currency(JsonField.of(currency)) /** @@ -48113,7 +53990,7 @@ private constructor( * It is usually unnecessary to call this method because the field defaults to the * following: * ```kotlin - * JsonValue.from("cumulative_grouped_bulk") + * JsonValue.from("scalable_matrix_with_tiered_pricing") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -48182,6 +54059,28 @@ private constructor( this.replacesPriceId = replacesPriceId } + /** Configuration for scalable_matrix_with_tiered_pricing pricing */ + fun scalableMatrixWithTieredPricingConfig( + scalableMatrixWithTieredPricingConfig: ScalableMatrixWithTieredPricingConfig + ) = + scalableMatrixWithTieredPricingConfig( + JsonField.of(scalableMatrixWithTieredPricingConfig) + ) + + /** + * Sets [Builder.scalableMatrixWithTieredPricingConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.scalableMatrixWithTieredPricingConfig] with a + * well-typed [ScalableMatrixWithTieredPricingConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported value. + */ + fun scalableMatrixWithTieredPricingConfig( + scalableMatrixWithTieredPricingConfig: + JsonField + ) = apply { + this.scalableMatrixWithTieredPricingConfig = scalableMatrixWithTieredPricingConfig + } + fun dimensionalPriceConfiguration( dimensionalPriceConfiguration: DimensionalPriceConfiguration? ) = dimensionalPriceConfiguration(JsonField.ofNullable(dimensionalPriceConfiguration)) @@ -48217,7 +54116,7 @@ private constructor( } /** - * Returns an immutable instance of [CumulativeGroupedBulk]. + * Returns an immutable instance of [ScalableMatrixWithTieredPricing]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -48232,7 +54131,6 @@ private constructor( * .conversionRateConfig() * .createdAt() * .creditAllocation() - * .cumulativeGroupedBulkConfig() * .currency() * .discount() * .externalPriceId() @@ -48248,12 +54146,13 @@ private constructor( * .planPhaseOrder() * .priceType() * .replacesPriceId() + * .scalableMatrixWithTieredPricingConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): CumulativeGroupedBulk = - CumulativeGroupedBulk( + fun build(): ScalableMatrixWithTieredPricing = + ScalableMatrixWithTieredPricing( checkRequired("id", id), checkRequired("billableMetric", billableMetric), checkRequired("billingCycleConfiguration", billingCycleConfiguration), @@ -48265,7 +54164,6 @@ private constructor( checkRequired("conversionRateConfig", conversionRateConfig), checkRequired("createdAt", createdAt), checkRequired("creditAllocation", creditAllocation), - checkRequired("cumulativeGroupedBulkConfig", cumulativeGroupedBulkConfig), checkRequired("currency", currency), checkRequired("discount", discount), checkRequired("externalPriceId", externalPriceId), @@ -48282,6 +54180,10 @@ private constructor( checkRequired("planPhaseOrder", planPhaseOrder), checkRequired("priceType", priceType), checkRequired("replacesPriceId", replacesPriceId), + checkRequired( + "scalableMatrixWithTieredPricingConfig", + scalableMatrixWithTieredPricingConfig, + ), dimensionalPriceConfiguration, additionalProperties.toMutableMap(), ) @@ -48289,7 +54191,7 @@ private constructor( private var validated: Boolean = false - fun validate(): CumulativeGroupedBulk = apply { + fun validate(): ScalableMatrixWithTieredPricing = apply { if (validated) { return@apply } @@ -48303,7 +54205,6 @@ private constructor( conversionRateConfig()?.validate() createdAt() creditAllocation()?.validate() - cumulativeGroupedBulkConfig().validate() currency() discount()?.validate() externalPriceId() @@ -48316,7 +54217,7 @@ private constructor( minimum()?.validate() minimumAmount() _modelType().let { - if (it != JsonValue.from("cumulative_grouped_bulk")) { + if (it != JsonValue.from("scalable_matrix_with_tiered_pricing")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } @@ -48324,6 +54225,7 @@ private constructor( planPhaseOrder() priceType().validate() replacesPriceId() + scalableMatrixWithTieredPricingConfig().validate() dimensionalPriceConfiguration()?.validate() validated = true } @@ -48352,7 +54254,6 @@ private constructor( (conversionRateConfig.asKnown()?.validity() ?: 0) + (if (createdAt.asKnown() == null) 0 else 1) + (creditAllocation.asKnown()?.validity() ?: 0) + - (cumulativeGroupedBulkConfig.asKnown()?.validity() ?: 0) + (if (currency.asKnown() == null) 0 else 1) + (discount.asKnown()?.validity() ?: 0) + (if (externalPriceId.asKnown() == null) 0 else 1) + @@ -48364,11 +54265,14 @@ private constructor( (metadata.asKnown()?.validity() ?: 0) + (minimum.asKnown()?.validity() ?: 0) + (if (minimumAmount.asKnown() == null) 0 else 1) + - modelType.let { if (it == JsonValue.from("cumulative_grouped_bulk")) 1 else 0 } + + modelType.let { + if (it == JsonValue.from("scalable_matrix_with_tiered_pricing")) 1 else 0 + } + (if (name.asKnown() == null) 0 else 1) + (if (planPhaseOrder.asKnown() == null) 0 else 1) + (priceType.asKnown()?.validity() ?: 0) + (if (replacesPriceId.asKnown() == null) 0 else 1) + + (scalableMatrixWithTieredPricingConfig.asKnown()?.validity() ?: 0) + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) class Cadence @JsonCreator private constructor(private val value: JsonField) : @@ -48523,7 +54427,12 @@ private constructor( override fun toString() = value.toString() } - class CumulativeGroupedBulkConfig + /** + * User specified key-value pairs for the resource. If not present, this defaults to an + * empty dictionary. Individual keys can be removed by setting the value to `null`, and the + * entire metadata mapping can be cleared by setting `metadata` to `null`. + */ + class Metadata @JsonCreator private constructor( @com.fasterxml.jackson.annotation.JsonValue @@ -48538,23 +54447,18 @@ private constructor( companion object { - /** - * Returns a mutable builder for constructing an instance of - * [CumulativeGroupedBulkConfig]. - */ + /** Returns a mutable builder for constructing an instance of [Metadata]. */ fun builder() = Builder() } - /** A builder for [CumulativeGroupedBulkConfig]. */ + /** A builder for [Metadata]. */ class Builder internal constructor() { private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(cumulativeGroupedBulkConfig: CumulativeGroupedBulkConfig) = - apply { - additionalProperties = - cumulativeGroupedBulkConfig.additionalProperties.toMutableMap() - } + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -48579,17 +54483,16 @@ private constructor( } /** - * Returns an immutable instance of [CumulativeGroupedBulkConfig]. + * Returns an immutable instance of [Metadata]. * * Further updates to this [Builder] will not mutate the returned instance. */ - fun build(): CumulativeGroupedBulkConfig = - CumulativeGroupedBulkConfig(additionalProperties.toImmutable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } private var validated: Boolean = false - fun validate(): CumulativeGroupedBulkConfig = apply { + fun validate(): Metadata = apply { if (validated) { return@apply } @@ -48619,49 +54522,379 @@ private constructor( return true } - return other is CumulativeGroupedBulkConfig && - additionalProperties == other.additionalProperties + return other is Metadata && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { Objects.hash(additionalProperties) } override fun hashCode(): Int = hashCode - override fun toString() = - "CumulativeGroupedBulkConfig{additionalProperties=$additionalProperties}" + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" } - /** - * User specified key-value pairs for the resource. If not present, this defaults to an - * empty dictionary. Individual keys can be removed by setting the value to `null`, and the - * entire metadata mapping can be cleared by setting `metadata` to `null`. - */ - class Metadata - @JsonCreator + class PriceType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val USAGE_PRICE = of("usage_price") + + val FIXED_PRICE = of("fixed_price") + + fun of(value: String) = PriceType(JsonField.of(value)) + } + + /** An enum containing [PriceType]'s known values. */ + enum class Known { + USAGE_PRICE, + FIXED_PRICE, + } + + /** + * An enum containing [PriceType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [PriceType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + USAGE_PRICE, + FIXED_PRICE, + /** + * An enum member indicating that [PriceType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + USAGE_PRICE -> Value.USAGE_PRICE + FIXED_PRICE -> Value.FIXED_PRICE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + USAGE_PRICE -> Known.USAGE_PRICE + FIXED_PRICE -> Known.FIXED_PRICE + else -> throw OrbInvalidDataException("Unknown PriceType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): PriceType = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PriceType && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Configuration for scalable_matrix_with_tiered_pricing pricing */ + class ScalableMatrixWithTieredPricingConfig private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map + private val firstDimension: JsonField, + private val matrixScalingFactors: JsonField>, + private val tiers: JsonField>, + private val secondDimension: JsonField, + private val additionalProperties: MutableMap, ) { + @JsonCreator + private constructor( + @JsonProperty("first_dimension") + @ExcludeMissing + firstDimension: JsonField = JsonMissing.of(), + @JsonProperty("matrix_scaling_factors") + @ExcludeMissing + matrixScalingFactors: JsonField> = JsonMissing.of(), + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of(), + @JsonProperty("second_dimension") + @ExcludeMissing + secondDimension: JsonField = JsonMissing.of(), + ) : this(firstDimension, matrixScalingFactors, tiers, secondDimension, mutableMapOf()) + + /** + * Used for the scalable matrix first dimension + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun firstDimension(): String = firstDimension.getRequired("first_dimension") + + /** + * Apply a scaling factor to each dimension + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun matrixScalingFactors(): List = + matrixScalingFactors.getRequired("matrix_scaling_factors") + + /** + * Tier pricing structure + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun tiers(): List = tiers.getRequired("tiers") + + /** + * Used for the scalable matrix second dimension (optional) + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun secondDimension(): String? = secondDimension.getNullable("second_dimension") + + /** + * Returns the raw JSON value of [firstDimension]. + * + * Unlike [firstDimension], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("first_dimension") + @ExcludeMissing + fun _firstDimension(): JsonField = firstDimension + + /** + * Returns the raw JSON value of [matrixScalingFactors]. + * + * Unlike [matrixScalingFactors], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("matrix_scaling_factors") + @ExcludeMissing + fun _matrixScalingFactors(): JsonField> = matrixScalingFactors + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tiers") @ExcludeMissing fun _tiers(): JsonField> = tiers + + /** + * Returns the raw JSON value of [secondDimension]. + * + * Unlike [secondDimension], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("second_dimension") + @ExcludeMissing + fun _secondDimension(): JsonField = secondDimension + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) fun toBuilder() = Builder().from(this) companion object { - /** Returns a mutable builder for constructing an instance of [Metadata]. */ + /** + * Returns a mutable builder for constructing an instance of + * [ScalableMatrixWithTieredPricingConfig]. + * + * The following fields are required: + * ```kotlin + * .firstDimension() + * .matrixScalingFactors() + * .tiers() + * ``` + */ fun builder() = Builder() } - /** A builder for [Metadata]. */ + /** A builder for [ScalableMatrixWithTieredPricingConfig]. */ class Builder internal constructor() { + private var firstDimension: JsonField? = null + private var matrixScalingFactors: JsonField>? = + null + private var tiers: JsonField>? = null + private var secondDimension: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(metadata: Metadata) = apply { - additionalProperties = metadata.additionalProperties.toMutableMap() + internal fun from( + scalableMatrixWithTieredPricingConfig: ScalableMatrixWithTieredPricingConfig + ) = apply { + firstDimension = scalableMatrixWithTieredPricingConfig.firstDimension + matrixScalingFactors = + scalableMatrixWithTieredPricingConfig.matrixScalingFactors.map { + it.toMutableList() + } + tiers = scalableMatrixWithTieredPricingConfig.tiers.map { it.toMutableList() } + secondDimension = scalableMatrixWithTieredPricingConfig.secondDimension + additionalProperties = + scalableMatrixWithTieredPricingConfig.additionalProperties.toMutableMap() + } + + /** Used for the scalable matrix first dimension */ + fun firstDimension(firstDimension: String) = + firstDimension(JsonField.of(firstDimension)) + + /** + * Sets [Builder.firstDimension] to an arbitrary JSON value. + * + * You should usually call [Builder.firstDimension] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun firstDimension(firstDimension: JsonField) = apply { + this.firstDimension = firstDimension + } + + /** Apply a scaling factor to each dimension */ + fun matrixScalingFactors(matrixScalingFactors: List) = + matrixScalingFactors(JsonField.of(matrixScalingFactors)) + + /** + * Sets [Builder.matrixScalingFactors] to an arbitrary JSON value. + * + * You should usually call [Builder.matrixScalingFactors] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun matrixScalingFactors( + matrixScalingFactors: JsonField> + ) = apply { + this.matrixScalingFactors = matrixScalingFactors.map { it.toMutableList() } + } + + /** + * Adds a single [MatrixScalingFactor] to [matrixScalingFactors]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addMatrixScalingFactor(matrixScalingFactor: MatrixScalingFactor) = apply { + matrixScalingFactors = + (matrixScalingFactors ?: JsonField.of(mutableListOf())).also { + checkKnown("matrixScalingFactors", it).add(matrixScalingFactor) + } + } + + /** Tier pricing structure */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + + /** Used for the scalable matrix second dimension (optional) */ + fun secondDimension(secondDimension: String?) = + secondDimension(JsonField.ofNullable(secondDimension)) + + /** + * Sets [Builder.secondDimension] to an arbitrary JSON value. + * + * You should usually call [Builder.secondDimension] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun secondDimension(secondDimension: JsonField) = apply { + this.secondDimension = secondDimension } fun additionalProperties(additionalProperties: Map) = apply { @@ -48687,20 +54920,42 @@ private constructor( } /** - * Returns an immutable instance of [Metadata]. + * Returns an immutable instance of [ScalableMatrixWithTieredPricingConfig]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .firstDimension() + * .matrixScalingFactors() + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + fun build(): ScalableMatrixWithTieredPricingConfig = + ScalableMatrixWithTieredPricingConfig( + checkRequired("firstDimension", firstDimension), + checkRequired("matrixScalingFactors", matrixScalingFactors).map { + it.toImmutable() + }, + checkRequired("tiers", tiers).map { it.toImmutable() }, + secondDimension, + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false - fun validate(): Metadata = apply { + fun validate(): ScalableMatrixWithTieredPricingConfig = apply { if (validated) { return@apply } + firstDimension() + matrixScalingFactors().forEach { it.validate() } + tiers().forEach { it.validate() } + secondDimension() validated = true } @@ -48719,150 +54974,527 @@ private constructor( * Used for best match union deserialization. */ internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + (if (firstDimension.asKnown() == null) 0 else 1) + + (matrixScalingFactors.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + (tiers.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + (if (secondDimension.asKnown() == null) 0 else 1) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + /** Configuration for a single matrix scaling factor */ + class MatrixScalingFactor + private constructor( + private val firstDimensionValue: JsonField, + private val scalingFactor: JsonField, + private val secondDimensionValue: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("first_dimension_value") + @ExcludeMissing + firstDimensionValue: JsonField = JsonMissing.of(), + @JsonProperty("scaling_factor") + @ExcludeMissing + scalingFactor: JsonField = JsonMissing.of(), + @JsonProperty("second_dimension_value") + @ExcludeMissing + secondDimensionValue: JsonField = JsonMissing.of(), + ) : this(firstDimensionValue, scalingFactor, secondDimensionValue, mutableMapOf()) + + /** + * First dimension value + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun firstDimensionValue(): String = + firstDimensionValue.getRequired("first_dimension_value") + + /** + * Scaling factor + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun scalingFactor(): String = scalingFactor.getRequired("scaling_factor") + + /** + * Second dimension value (optional) + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun secondDimensionValue(): String? = + secondDimensionValue.getNullable("second_dimension_value") + + /** + * Returns the raw JSON value of [firstDimensionValue]. + * + * Unlike [firstDimensionValue], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("first_dimension_value") + @ExcludeMissing + fun _firstDimensionValue(): JsonField = firstDimensionValue + + /** + * Returns the raw JSON value of [scalingFactor]. + * + * Unlike [scalingFactor], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("scaling_factor") + @ExcludeMissing + fun _scalingFactor(): JsonField = scalingFactor + + /** + * Returns the raw JSON value of [secondDimensionValue]. + * + * Unlike [secondDimensionValue], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("second_dimension_value") + @ExcludeMissing + fun _secondDimensionValue(): JsonField = secondDimensionValue + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) } - return other is Metadata && additionalProperties == other.additionalProperties - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [MatrixScalingFactor]. + * + * The following fields are required: + * ```kotlin + * .firstDimensionValue() + * .scalingFactor() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [MatrixScalingFactor]. */ + class Builder internal constructor() { + + private var firstDimensionValue: JsonField? = null + private var scalingFactor: JsonField? = null + private var secondDimensionValue: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(matrixScalingFactor: MatrixScalingFactor) = apply { + firstDimensionValue = matrixScalingFactor.firstDimensionValue + scalingFactor = matrixScalingFactor.scalingFactor + secondDimensionValue = matrixScalingFactor.secondDimensionValue + additionalProperties = + matrixScalingFactor.additionalProperties.toMutableMap() + } - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /** First dimension value */ + fun firstDimensionValue(firstDimensionValue: String) = + firstDimensionValue(JsonField.of(firstDimensionValue)) + + /** + * Sets [Builder.firstDimensionValue] to an arbitrary JSON value. + * + * You should usually call [Builder.firstDimensionValue] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun firstDimensionValue(firstDimensionValue: JsonField) = apply { + this.firstDimensionValue = firstDimensionValue + } - override fun hashCode(): Int = hashCode + /** Scaling factor */ + fun scalingFactor(scalingFactor: String) = + scalingFactor(JsonField.of(scalingFactor)) + + /** + * Sets [Builder.scalingFactor] to an arbitrary JSON value. + * + * You should usually call [Builder.scalingFactor] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun scalingFactor(scalingFactor: JsonField) = apply { + this.scalingFactor = scalingFactor + } - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } + /** Second dimension value (optional) */ + fun secondDimensionValue(secondDimensionValue: String?) = + secondDimensionValue(JsonField.ofNullable(secondDimensionValue)) + + /** + * Sets [Builder.secondDimensionValue] to an arbitrary JSON value. + * + * You should usually call [Builder.secondDimensionValue] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun secondDimensionValue(secondDimensionValue: JsonField) = apply { + this.secondDimensionValue = secondDimensionValue + } - class PriceType @JsonCreator private constructor(private val value: JsonField) : - Enum { + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - companion object { + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - val USAGE_PRICE = of("usage_price") + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - val FIXED_PRICE = of("fixed_price") + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - fun of(value: String) = PriceType(JsonField.of(value)) - } + /** + * Returns an immutable instance of [MatrixScalingFactor]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .firstDimensionValue() + * .scalingFactor() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MatrixScalingFactor = + MatrixScalingFactor( + checkRequired("firstDimensionValue", firstDimensionValue), + checkRequired("scalingFactor", scalingFactor), + secondDimensionValue, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MatrixScalingFactor = apply { + if (validated) { + return@apply + } - /** An enum containing [PriceType]'s known values. */ - enum class Known { - USAGE_PRICE, - FIXED_PRICE, - } + firstDimensionValue() + scalingFactor() + secondDimensionValue() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - /** - * An enum containing [PriceType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [PriceType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - USAGE_PRICE, - FIXED_PRICE, /** - * An enum member indicating that [PriceType] was instantiated with an unknown - * value. + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. */ - _UNKNOWN, + internal fun validity(): Int = + (if (firstDimensionValue.asKnown() == null) 0 else 1) + + (if (scalingFactor.asKnown() == null) 0 else 1) + + (if (secondDimensionValue.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MatrixScalingFactor && + firstDimensionValue == other.firstDimensionValue && + scalingFactor == other.scalingFactor && + secondDimensionValue == other.secondDimensionValue && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + firstDimensionValue, + scalingFactor, + secondDimensionValue, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MatrixScalingFactor{firstDimensionValue=$firstDimensionValue, scalingFactor=$scalingFactor, secondDimensionValue=$secondDimensionValue, additionalProperties=$additionalProperties}" } - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - USAGE_PRICE -> Value.USAGE_PRICE - FIXED_PRICE -> Value.FIXED_PRICE - else -> Value._UNKNOWN + /** Configuration for a single tier entry with business logic */ + class Tier + private constructor( + private val tierLowerBound: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(tierLowerBound, unitAmount, mutableMapOf()) + + /** + * Tier lower bound + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun tierLowerBound(): String = tierLowerBound.getRequired("tier_lower_bound") + + /** + * Per unit amount + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) } - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - USAGE_PRICE -> Known.USAGE_PRICE - FIXED_PRICE -> Known.FIXED_PRICE - else -> throw OrbInvalidDataException("Unknown PriceType: $value") + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Tier]. + * + * The following fields are required: + * ```kotlin + * .tierLowerBound() + * .unitAmount() + * ``` + */ + fun builder() = Builder() } - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + /** A builder for [Tier]. */ + class Builder internal constructor() { - private var validated: Boolean = false + private var tierLowerBound: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() - fun validate(): PriceType = apply { - if (validated) { - return@apply + internal fun from(tier: Tier) = apply { + tierLowerBound = tier.tierLowerBound + unitAmount = tier.unitAmount + additionalProperties = tier.additionalProperties.toMutableMap() + } + + /** Tier lower bound */ + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + /** Per unit amount */ + fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Tier]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .tierLowerBound() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("tierLowerBound", tierLowerBound), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + tierLowerBound() + unitAmount() + validated = true } - known() - validated = true - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (tierLowerBound.asKnown() == null) 0 else 1) + + (if (unitAmount.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + tierLowerBound == other.tierLowerBound && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + private val hashCode: Int by lazy { + Objects.hash(tierLowerBound, unitAmount, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is PriceType && value == other.value + return other is ScalableMatrixWithTieredPricingConfig && + firstDimension == other.firstDimension && + matrixScalingFactors == other.matrixScalingFactors && + tiers == other.tiers && + secondDimension == other.secondDimension && + additionalProperties == other.additionalProperties } - override fun hashCode() = value.hashCode() + private val hashCode: Int by lazy { + Objects.hash( + firstDimension, + matrixScalingFactors, + tiers, + secondDimension, + additionalProperties, + ) + } - override fun toString() = value.toString() + override fun hashCode(): Int = hashCode + + override fun toString() = + "ScalableMatrixWithTieredPricingConfig{firstDimension=$firstDimension, matrixScalingFactors=$matrixScalingFactors, tiers=$tiers, secondDimension=$secondDimension, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { @@ -48870,7 +55502,7 @@ private constructor( return true } - return other is CumulativeGroupedBulk && + return other is ScalableMatrixWithTieredPricing && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && @@ -48880,7 +55512,6 @@ private constructor( conversionRateConfig == other.conversionRateConfig && createdAt == other.createdAt && creditAllocation == other.creditAllocation && - cumulativeGroupedBulkConfig == other.cumulativeGroupedBulkConfig && currency == other.currency && discount == other.discount && externalPriceId == other.externalPriceId && @@ -48897,6 +55528,8 @@ private constructor( planPhaseOrder == other.planPhaseOrder && priceType == other.priceType && replacesPriceId == other.replacesPriceId && + scalableMatrixWithTieredPricingConfig == + other.scalableMatrixWithTieredPricingConfig && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties } @@ -48912,7 +55545,6 @@ private constructor( conversionRateConfig, createdAt, creditAllocation, - cumulativeGroupedBulkConfig, currency, discount, externalPriceId, @@ -48929,6 +55561,7 @@ private constructor( planPhaseOrder, priceType, replacesPriceId, + scalableMatrixWithTieredPricingConfig, dimensionalPriceConfiguration, additionalProperties, ) @@ -48937,10 +55570,10 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "CumulativeGroupedBulk{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, cumulativeGroupedBulkConfig=$cumulativeGroupedBulkConfig, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "ScalableMatrixWithTieredPricing{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, scalableMatrixWithTieredPricingConfig=$scalableMatrixWithTieredPricingConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" } - class GroupedWithMinMaxThresholds + class CumulativeGroupedBulk private constructor( private val id: JsonField, private val billableMetric: JsonField, @@ -48951,11 +55584,11 @@ private constructor( private val conversionRateConfig: JsonField, private val createdAt: JsonField, private val creditAllocation: JsonField, + private val cumulativeGroupedBulkConfig: JsonField, private val currency: JsonField, private val discount: JsonField, private val externalPriceId: JsonField, private val fixedPriceQuantity: JsonField, - private val groupedWithMinMaxThresholdsConfig: JsonField, private val invoicingCycleConfiguration: JsonField, private val item: JsonField, private val maximum: JsonField, @@ -48997,6 +55630,9 @@ private constructor( @JsonProperty("credit_allocation") @ExcludeMissing creditAllocation: JsonField = JsonMissing.of(), + @JsonProperty("cumulative_grouped_bulk_config") + @ExcludeMissing + cumulativeGroupedBulkConfig: JsonField = JsonMissing.of(), @JsonProperty("currency") @ExcludeMissing currency: JsonField = JsonMissing.of(), @@ -49009,10 +55645,6 @@ private constructor( @JsonProperty("fixed_price_quantity") @ExcludeMissing fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("grouped_with_min_max_thresholds_config") - @ExcludeMissing - groupedWithMinMaxThresholdsConfig: JsonField = - JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), @@ -49053,11 +55685,11 @@ private constructor( conversionRateConfig, createdAt, creditAllocation, + cumulativeGroupedBulkConfig, currency, discount, externalPriceId, fixedPriceQuantity, - groupedWithMinMaxThresholdsConfig, invoicingCycleConfiguration, item, maximum, @@ -49131,6 +55763,15 @@ private constructor( */ fun creditAllocation(): Allocation? = creditAllocation.getNullable("credit_allocation") + /** + * Configuration for cumulative_grouped_bulk pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun cumulativeGroupedBulkConfig(): CumulativeGroupedBulkConfig = + cumulativeGroupedBulkConfig.getRequired("cumulative_grouped_bulk_config") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). @@ -49155,13 +55796,6 @@ private constructor( */ fun fixedPriceQuantity(): Double? = fixedPriceQuantity.getNullable("fixed_price_quantity") - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun groupedWithMinMaxThresholdsConfig(): GroupedWithMinMaxThresholdsConfig = - groupedWithMinMaxThresholdsConfig.getRequired("grouped_with_min_max_thresholds_config") - /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -49212,9 +55846,11 @@ private constructor( fun minimumAmount(): String? = minimumAmount.getNullable("minimum_amount") /** + * The pricing model type + * * Expected to always return the following: * ```kotlin - * JsonValue.from("grouped_with_min_max_thresholds") + * JsonValue.from("cumulative_grouped_bulk") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -49340,6 +55976,17 @@ private constructor( @ExcludeMissing fun _creditAllocation(): JsonField = creditAllocation + /** + * Returns the raw JSON value of [cumulativeGroupedBulkConfig]. + * + * Unlike [cumulativeGroupedBulkConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("cumulative_grouped_bulk_config") + @ExcludeMissing + fun _cumulativeGroupedBulkConfig(): JsonField = + cumulativeGroupedBulkConfig + /** * Returns the raw JSON value of [currency]. * @@ -49377,17 +56024,6 @@ private constructor( @ExcludeMissing fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - /** - * Returns the raw JSON value of [groupedWithMinMaxThresholdsConfig]. - * - * Unlike [groupedWithMinMaxThresholdsConfig], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("grouped_with_min_max_thresholds_config") - @ExcludeMissing - fun _groupedWithMinMaxThresholdsConfig(): JsonField = - groupedWithMinMaxThresholdsConfig - /** * Returns the raw JSON value of [invoicingCycleConfiguration]. * @@ -49517,8 +56153,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [GroupedWithMinMaxThresholds]. + * Returns a mutable builder for constructing an instance of [CumulativeGroupedBulk]. * * The following fields are required: * ```kotlin @@ -49531,11 +56166,11 @@ private constructor( * .conversionRateConfig() * .createdAt() * .creditAllocation() + * .cumulativeGroupedBulkConfig() * .currency() * .discount() * .externalPriceId() * .fixedPriceQuantity() - * .groupedWithMinMaxThresholdsConfig() * .invoicingCycleConfiguration() * .item() * .maximum() @@ -49552,7 +56187,7 @@ private constructor( fun builder() = Builder() } - /** A builder for [GroupedWithMinMaxThresholds]. */ + /** A builder for [CumulativeGroupedBulk]. */ class Builder internal constructor() { private var id: JsonField? = null @@ -49564,13 +56199,11 @@ private constructor( private var conversionRateConfig: JsonField? = null private var createdAt: JsonField? = null private var creditAllocation: JsonField? = null + private var cumulativeGroupedBulkConfig: JsonField? = null private var currency: JsonField? = null private var discount: JsonField? = null private var externalPriceId: JsonField? = null private var fixedPriceQuantity: JsonField? = null - private var groupedWithMinMaxThresholdsConfig: - JsonField? = - null private var invoicingCycleConfiguration: JsonField? = null private var item: JsonField? = null private var maximum: JsonField? = null @@ -49578,7 +56211,7 @@ private constructor( private var metadata: JsonField? = null private var minimum: JsonField? = null private var minimumAmount: JsonField? = null - private var modelType: JsonValue = JsonValue.from("grouped_with_min_max_thresholds") + private var modelType: JsonValue = JsonValue.from("cumulative_grouped_bulk") private var name: JsonField? = null private var planPhaseOrder: JsonField? = null private var priceType: JsonField? = null @@ -49587,40 +56220,36 @@ private constructor( JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds) = apply { - id = groupedWithMinMaxThresholds.id - billableMetric = groupedWithMinMaxThresholds.billableMetric - billingCycleConfiguration = groupedWithMinMaxThresholds.billingCycleConfiguration - cadence = groupedWithMinMaxThresholds.cadence + internal fun from(cumulativeGroupedBulk: CumulativeGroupedBulk) = apply { + id = cumulativeGroupedBulk.id + billableMetric = cumulativeGroupedBulk.billableMetric + billingCycleConfiguration = cumulativeGroupedBulk.billingCycleConfiguration + cadence = cumulativeGroupedBulk.cadence compositePriceFilters = - groupedWithMinMaxThresholds.compositePriceFilters.map { it.toMutableList() } - conversionRate = groupedWithMinMaxThresholds.conversionRate - conversionRateConfig = groupedWithMinMaxThresholds.conversionRateConfig - createdAt = groupedWithMinMaxThresholds.createdAt - creditAllocation = groupedWithMinMaxThresholds.creditAllocation - currency = groupedWithMinMaxThresholds.currency - discount = groupedWithMinMaxThresholds.discount - externalPriceId = groupedWithMinMaxThresholds.externalPriceId - fixedPriceQuantity = groupedWithMinMaxThresholds.fixedPriceQuantity - groupedWithMinMaxThresholdsConfig = - groupedWithMinMaxThresholds.groupedWithMinMaxThresholdsConfig - invoicingCycleConfiguration = - groupedWithMinMaxThresholds.invoicingCycleConfiguration - item = groupedWithMinMaxThresholds.item - maximum = groupedWithMinMaxThresholds.maximum - maximumAmount = groupedWithMinMaxThresholds.maximumAmount - metadata = groupedWithMinMaxThresholds.metadata - minimum = groupedWithMinMaxThresholds.minimum - minimumAmount = groupedWithMinMaxThresholds.minimumAmount - modelType = groupedWithMinMaxThresholds.modelType - name = groupedWithMinMaxThresholds.name - planPhaseOrder = groupedWithMinMaxThresholds.planPhaseOrder - priceType = groupedWithMinMaxThresholds.priceType - replacesPriceId = groupedWithMinMaxThresholds.replacesPriceId - dimensionalPriceConfiguration = - groupedWithMinMaxThresholds.dimensionalPriceConfiguration - additionalProperties = - groupedWithMinMaxThresholds.additionalProperties.toMutableMap() + cumulativeGroupedBulk.compositePriceFilters.map { it.toMutableList() } + conversionRate = cumulativeGroupedBulk.conversionRate + conversionRateConfig = cumulativeGroupedBulk.conversionRateConfig + createdAt = cumulativeGroupedBulk.createdAt + creditAllocation = cumulativeGroupedBulk.creditAllocation + cumulativeGroupedBulkConfig = cumulativeGroupedBulk.cumulativeGroupedBulkConfig + currency = cumulativeGroupedBulk.currency + discount = cumulativeGroupedBulk.discount + externalPriceId = cumulativeGroupedBulk.externalPriceId + fixedPriceQuantity = cumulativeGroupedBulk.fixedPriceQuantity + invoicingCycleConfiguration = cumulativeGroupedBulk.invoicingCycleConfiguration + item = cumulativeGroupedBulk.item + maximum = cumulativeGroupedBulk.maximum + maximumAmount = cumulativeGroupedBulk.maximumAmount + metadata = cumulativeGroupedBulk.metadata + minimum = cumulativeGroupedBulk.minimum + minimumAmount = cumulativeGroupedBulk.minimumAmount + modelType = cumulativeGroupedBulk.modelType + name = cumulativeGroupedBulk.name + planPhaseOrder = cumulativeGroupedBulk.planPhaseOrder + priceType = cumulativeGroupedBulk.priceType + replacesPriceId = cumulativeGroupedBulk.replacesPriceId + dimensionalPriceConfiguration = cumulativeGroupedBulk.dimensionalPriceConfiguration + additionalProperties = cumulativeGroupedBulk.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) @@ -49811,6 +56440,22 @@ private constructor( this.creditAllocation = creditAllocation } + /** Configuration for cumulative_grouped_bulk pricing */ + fun cumulativeGroupedBulkConfig( + cumulativeGroupedBulkConfig: CumulativeGroupedBulkConfig + ) = cumulativeGroupedBulkConfig(JsonField.of(cumulativeGroupedBulkConfig)) + + /** + * Sets [Builder.cumulativeGroupedBulkConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.cumulativeGroupedBulkConfig] with a well-typed + * [CumulativeGroupedBulkConfig] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun cumulativeGroupedBulkConfig( + cumulativeGroupedBulkConfig: JsonField + ) = apply { this.cumulativeGroupedBulkConfig = cumulativeGroupedBulkConfig } + fun currency(currency: String) = currency(JsonField.of(currency)) /** @@ -49942,21 +56587,6 @@ private constructor( this.fixedPriceQuantity = fixedPriceQuantity } - fun groupedWithMinMaxThresholdsConfig( - groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig - ) = groupedWithMinMaxThresholdsConfig(JsonField.of(groupedWithMinMaxThresholdsConfig)) - - /** - * Sets [Builder.groupedWithMinMaxThresholdsConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.groupedWithMinMaxThresholdsConfig] with a well-typed - * [GroupedWithMinMaxThresholdsConfig] value instead. This method is primarily for - * setting the field to an undocumented or not yet supported value. - */ - fun groupedWithMinMaxThresholdsConfig( - groupedWithMinMaxThresholdsConfig: JsonField - ) = apply { this.groupedWithMinMaxThresholdsConfig = groupedWithMinMaxThresholdsConfig } - fun invoicingCycleConfiguration( invoicingCycleConfiguration: BillingCycleConfiguration? ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) @@ -50063,7 +56693,7 @@ private constructor( * It is usually unnecessary to call this method because the field defaults to the * following: * ```kotlin - * JsonValue.from("grouped_with_min_max_thresholds") + * JsonValue.from("cumulative_grouped_bulk") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -50167,7 +56797,7 @@ private constructor( } /** - * Returns an immutable instance of [GroupedWithMinMaxThresholds]. + * Returns an immutable instance of [CumulativeGroupedBulk]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -50182,11 +56812,11 @@ private constructor( * .conversionRateConfig() * .createdAt() * .creditAllocation() + * .cumulativeGroupedBulkConfig() * .currency() * .discount() * .externalPriceId() * .fixedPriceQuantity() - * .groupedWithMinMaxThresholdsConfig() * .invoicingCycleConfiguration() * .item() * .maximum() @@ -50202,8 +56832,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): GroupedWithMinMaxThresholds = - GroupedWithMinMaxThresholds( + fun build(): CumulativeGroupedBulk = + CumulativeGroupedBulk( checkRequired("id", id), checkRequired("billableMetric", billableMetric), checkRequired("billingCycleConfiguration", billingCycleConfiguration), @@ -50215,14 +56845,11 @@ private constructor( checkRequired("conversionRateConfig", conversionRateConfig), checkRequired("createdAt", createdAt), checkRequired("creditAllocation", creditAllocation), + checkRequired("cumulativeGroupedBulkConfig", cumulativeGroupedBulkConfig), checkRequired("currency", currency), checkRequired("discount", discount), checkRequired("externalPriceId", externalPriceId), checkRequired("fixedPriceQuantity", fixedPriceQuantity), - checkRequired( - "groupedWithMinMaxThresholdsConfig", - groupedWithMinMaxThresholdsConfig, - ), checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), checkRequired("item", item), checkRequired("maximum", maximum), @@ -50242,7 +56869,7 @@ private constructor( private var validated: Boolean = false - fun validate(): GroupedWithMinMaxThresholds = apply { + fun validate(): CumulativeGroupedBulk = apply { if (validated) { return@apply } @@ -50256,11 +56883,11 @@ private constructor( conversionRateConfig()?.validate() createdAt() creditAllocation()?.validate() + cumulativeGroupedBulkConfig().validate() currency() discount()?.validate() externalPriceId() fixedPriceQuantity() - groupedWithMinMaxThresholdsConfig().validate() invoicingCycleConfiguration()?.validate() item().validate() maximum()?.validate() @@ -50269,7 +56896,7 @@ private constructor( minimum()?.validate() minimumAmount() _modelType().let { - if (it != JsonValue.from("grouped_with_min_max_thresholds")) { + if (it != JsonValue.from("cumulative_grouped_bulk")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } @@ -50305,11 +56932,11 @@ private constructor( (conversionRateConfig.asKnown()?.validity() ?: 0) + (if (createdAt.asKnown() == null) 0 else 1) + (creditAllocation.asKnown()?.validity() ?: 0) + + (cumulativeGroupedBulkConfig.asKnown()?.validity() ?: 0) + (if (currency.asKnown() == null) 0 else 1) + (discount.asKnown()?.validity() ?: 0) + (if (externalPriceId.asKnown() == null) 0 else 1) + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + - (groupedWithMinMaxThresholdsConfig.asKnown()?.validity() ?: 0) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + (item.asKnown()?.validity() ?: 0) + (maximum.asKnown()?.validity() ?: 0) + @@ -50317,9 +56944,7 @@ private constructor( (metadata.asKnown()?.validity() ?: 0) + (minimum.asKnown()?.validity() ?: 0) + (if (minimumAmount.asKnown() == null) 0 else 1) + - modelType.let { - if (it == JsonValue.from("grouped_with_min_max_thresholds")) 1 else 0 - } + + modelType.let { if (it == JsonValue.from("cumulative_grouped_bulk")) 1 else 0 } + (if (name.asKnown() == null) 0 else 1) + (if (planPhaseOrder.asKnown() == null) 0 else 1) + (priceType.asKnown()?.validity() ?: 0) + @@ -50478,16 +57103,67 @@ private constructor( override fun toString() = value.toString() } - class GroupedWithMinMaxThresholdsConfig - @JsonCreator + /** Configuration for cumulative_grouped_bulk pricing */ + class CumulativeGroupedBulkConfig private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map + private val dimensionValues: JsonField>, + private val group: JsonField, + private val additionalProperties: MutableMap, ) { + @JsonCreator + private constructor( + @JsonProperty("dimension_values") + @ExcludeMissing + dimensionValues: JsonField> = JsonMissing.of(), + @JsonProperty("group") @ExcludeMissing group: JsonField = JsonMissing.of(), + ) : this(dimensionValues, group, mutableMapOf()) + + /** + * Each tier lower bound must have the same group of values. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun dimensionValues(): List = + dimensionValues.getRequired("dimension_values") + + /** + * Grouping key name + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun group(): String = group.getRequired("group") + + /** + * Returns the raw JSON value of [dimensionValues]. + * + * Unlike [dimensionValues], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("dimension_values") + @ExcludeMissing + fun _dimensionValues(): JsonField> = dimensionValues + + /** + * Returns the raw JSON value of [group]. + * + * Unlike [group], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("group") @ExcludeMissing fun _group(): JsonField = group + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) fun toBuilder() = Builder().from(this) @@ -50495,23 +57171,72 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [GroupedWithMinMaxThresholdsConfig]. + * [CumulativeGroupedBulkConfig]. + * + * The following fields are required: + * ```kotlin + * .dimensionValues() + * .group() + * ``` */ fun builder() = Builder() } - /** A builder for [GroupedWithMinMaxThresholdsConfig]. */ + /** A builder for [CumulativeGroupedBulkConfig]. */ class Builder internal constructor() { + private var dimensionValues: JsonField>? = null + private var group: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() - internal fun from( - groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig - ) = apply { - additionalProperties = - groupedWithMinMaxThresholdsConfig.additionalProperties.toMutableMap() + internal fun from(cumulativeGroupedBulkConfig: CumulativeGroupedBulkConfig) = + apply { + dimensionValues = + cumulativeGroupedBulkConfig.dimensionValues.map { it.toMutableList() } + group = cumulativeGroupedBulkConfig.group + additionalProperties = + cumulativeGroupedBulkConfig.additionalProperties.toMutableMap() + } + + /** Each tier lower bound must have the same group of values. */ + fun dimensionValues(dimensionValues: List) = + dimensionValues(JsonField.of(dimensionValues)) + + /** + * Sets [Builder.dimensionValues] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionValues] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun dimensionValues(dimensionValues: JsonField>) = apply { + this.dimensionValues = dimensionValues.map { it.toMutableList() } } + /** + * Adds a single [DimensionValue] to [dimensionValues]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addDimensionValue(dimensionValue: DimensionValue) = apply { + dimensionValues = + (dimensionValues ?: JsonField.of(mutableListOf())).also { + checkKnown("dimensionValues", it).add(dimensionValue) + } + } + + /** Grouping key name */ + fun group(group: String) = group(JsonField.of(group)) + + /** + * Sets [Builder.group] to an arbitrary JSON value. + * + * You should usually call [Builder.group] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun group(group: JsonField) = apply { this.group = group } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -50535,21 +57260,35 @@ private constructor( } /** - * Returns an immutable instance of [GroupedWithMinMaxThresholdsConfig]. + * Returns an immutable instance of [CumulativeGroupedBulkConfig]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .dimensionValues() + * .group() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ - fun build(): GroupedWithMinMaxThresholdsConfig = - GroupedWithMinMaxThresholdsConfig(additionalProperties.toImmutable()) + fun build(): CumulativeGroupedBulkConfig = + CumulativeGroupedBulkConfig( + checkRequired("dimensionValues", dimensionValues).map { it.toImmutable() }, + checkRequired("group", group), + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false - fun validate(): GroupedWithMinMaxThresholdsConfig = apply { + fun validate(): CumulativeGroupedBulkConfig = apply { if (validated) { return@apply } + dimensionValues().forEach { it.validate() } + group() validated = true } @@ -50568,23 +57307,291 @@ private constructor( * Used for best match union deserialization. */ internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + (dimensionValues.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + (if (group.asKnown() == null) 0 else 1) + + /** Configuration for a dimension value entry */ + class DimensionValue + private constructor( + private val groupingKey: JsonField, + private val tierLowerBound: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(groupingKey, tierLowerBound, unitAmount, mutableMapOf()) + + /** + * Grouping key value + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * Tier lower bound + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun tierLowerBound(): String = tierLowerBound.getRequired("tier_lower_bound") + + /** + * Unit amount for this combination + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [DimensionValue]. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .tierLowerBound() + * .unitAmount() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [DimensionValue]. */ + class Builder internal constructor() { + + private var groupingKey: JsonField? = null + private var tierLowerBound: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(dimensionValue: DimensionValue) = apply { + groupingKey = dimensionValue.groupingKey + tierLowerBound = dimensionValue.tierLowerBound + unitAmount = dimensionValue.unitAmount + additionalProperties = dimensionValue.additionalProperties.toMutableMap() + } + + /** Grouping key value */ + fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** Tier lower bound */ + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + /** Unit amount for this combination */ + fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [DimensionValue]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .tierLowerBound() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): DimensionValue = + DimensionValue( + checkRequired("groupingKey", groupingKey), + checkRequired("tierLowerBound", tierLowerBound), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): DimensionValue = apply { + if (validated) { + return@apply + } + + groupingKey() + tierLowerBound() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (groupingKey.asKnown() == null) 0 else 1) + + (if (tierLowerBound.asKnown() == null) 0 else 1) + + (if (unitAmount.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is DimensionValue && + groupingKey == other.groupingKey && + tierLowerBound == other.tierLowerBound && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(groupingKey, tierLowerBound, unitAmount, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "DimensionValue{groupingKey=$groupingKey, tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is GroupedWithMinMaxThresholdsConfig && + return other is CumulativeGroupedBulkConfig && + dimensionValues == other.dimensionValues && + group == other.group && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + private val hashCode: Int by lazy { + Objects.hash(dimensionValues, group, additionalProperties) + } override fun hashCode(): Int = hashCode override fun toString() = - "GroupedWithMinMaxThresholdsConfig{additionalProperties=$additionalProperties}" + "CumulativeGroupedBulkConfig{dimensionValues=$dimensionValues, group=$group, additionalProperties=$additionalProperties}" } /** @@ -50826,7 +57833,7 @@ private constructor( return true } - return other is GroupedWithMinMaxThresholds && + return other is CumulativeGroupedBulk && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && @@ -50836,11 +57843,11 @@ private constructor( conversionRateConfig == other.conversionRateConfig && createdAt == other.createdAt && creditAllocation == other.creditAllocation && + cumulativeGroupedBulkConfig == other.cumulativeGroupedBulkConfig && currency == other.currency && discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && - groupedWithMinMaxThresholdsConfig == other.groupedWithMinMaxThresholdsConfig && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maximum == other.maximum && @@ -50868,11 +57875,11 @@ private constructor( conversionRateConfig, createdAt, creditAllocation, + cumulativeGroupedBulkConfig, currency, discount, externalPriceId, fixedPriceQuantity, - groupedWithMinMaxThresholdsConfig, invoicingCycleConfiguration, item, maximum, @@ -50893,7 +57900,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "GroupedWithMinMaxThresholds{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "CumulativeGroupedBulk{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, cumulativeGroupedBulkConfig=$cumulativeGroupedBulkConfig, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" } class Minimum @@ -51160,12 +58167,16 @@ private constructor( fun minimumAmount(): String? = minimumAmount.getNullable("minimum_amount") /** + * Configuration for minimum pricing + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ fun minimumConfig(): MinimumConfig = minimumConfig.getRequired("minimum_config") /** + * The pricing model type + * * Expected to always return the following: * ```kotlin * JsonValue.from("minimum") @@ -51987,6 +58998,7 @@ private constructor( this.minimumAmount = minimumAmount } + /** Configuration for minimum pricing */ fun minimumConfig(minimumConfig: MinimumConfig) = minimumConfig(JsonField.of(minimumConfig)) @@ -52522,6 +59534,7 @@ private constructor( override fun toString() = "Metadata{additionalProperties=$additionalProperties}" } + /** Configuration for minimum pricing */ class MinimumConfig private constructor( private val minimumAmount: JsonField, @@ -52549,8 +59562,7 @@ private constructor( fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") /** - * By default, subtotals from minimum composite prices are prorated based on the service - * period. Set to false to disable proration. + * If true, subtotals from this price are prorated based on the service period * * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -52628,18 +59640,8 @@ private constructor( this.minimumAmount = minimumAmount } - /** - * By default, subtotals from minimum composite prices are prorated based on the - * service period. Set to false to disable proration. - */ - fun prorated(prorated: Boolean?) = prorated(JsonField.ofNullable(prorated)) - - /** - * Alias for [Builder.prorated]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun prorated(prorated: Boolean) = prorated(prorated as Boolean?) + /** If true, subtotals from this price are prorated based on the service period */ + fun prorated(prorated: Boolean) = prorated(JsonField.of(prorated)) /** * Sets [Builder.prorated] to an arbitrary JSON value. diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceCreateParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceCreateParams.kt index e7632cba6..4d175fa57 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceCreateParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceCreateParams.kt @@ -49,6 +49,7 @@ private constructor( private val additionalQueryParams: QueryParams, ) : Params { + /** New floating price request body params. */ fun body(): Body = body /** Additional headers to send with the request. */ @@ -85,27 +86,24 @@ private constructor( additionalQueryParams = priceCreateParams.additionalQueryParams.toBuilder() } + /** New floating price request body params. */ fun body(body: Body) = apply { this.body = body } /** Alias for calling [body] with `Body.ofUnit(unit)`. */ fun body(unit: NewFloatingUnitPrice) = body(Body.ofUnit(unit)) - /** Alias for calling [body] with `Body.ofPackage(package_)`. */ - fun body(package_: NewFloatingPackagePrice) = body(Body.ofPackage(package_)) - - /** Alias for calling [body] with `Body.ofMatrix(matrix)`. */ - fun body(matrix: NewFloatingMatrixPrice) = body(Body.ofMatrix(matrix)) - - /** Alias for calling [body] with `Body.ofMatrixWithAllocation(matrixWithAllocation)`. */ - fun body(matrixWithAllocation: NewFloatingMatrixWithAllocationPrice) = - body(Body.ofMatrixWithAllocation(matrixWithAllocation)) - /** Alias for calling [body] with `Body.ofTiered(tiered)`. */ fun body(tiered: NewFloatingTieredPrice) = body(Body.ofTiered(tiered)) /** Alias for calling [body] with `Body.ofBulk(bulk)`. */ fun body(bulk: NewFloatingBulkPrice) = body(Body.ofBulk(bulk)) + /** Alias for calling [body] with `Body.ofPackage(package_)`. */ + fun body(package_: NewFloatingPackagePrice) = body(Body.ofPackage(package_)) + + /** Alias for calling [body] with `Body.ofMatrix(matrix)`. */ + fun body(matrix: NewFloatingMatrixPrice) = body(Body.ofMatrix(matrix)) + /** Alias for calling [body] with `Body.ofThresholdTotalAmount(thresholdTotalAmount)`. */ fun body(thresholdTotalAmount: NewFloatingThresholdTotalAmountPrice) = body(Body.ofThresholdTotalAmount(thresholdTotalAmount)) @@ -114,21 +112,13 @@ private constructor( fun body(tieredPackage: NewFloatingTieredPackagePrice) = body(Body.ofTieredPackage(tieredPackage)) - /** Alias for calling [body] with `Body.ofGroupedTiered(groupedTiered)`. */ - fun body(groupedTiered: NewFloatingGroupedTieredPrice) = - body(Body.ofGroupedTiered(groupedTiered)) - - /** Alias for calling [body] with `Body.ofMaxGroupTieredPackage(maxGroupTieredPackage)`. */ - fun body(maxGroupTieredPackage: NewFloatingMaxGroupTieredPackagePrice) = - body(Body.ofMaxGroupTieredPackage(maxGroupTieredPackage)) - /** Alias for calling [body] with `Body.ofTieredWithMinimum(tieredWithMinimum)`. */ fun body(tieredWithMinimum: NewFloatingTieredWithMinimumPrice) = body(Body.ofTieredWithMinimum(tieredWithMinimum)) - /** Alias for calling [body] with `Body.ofPackageWithAllocation(packageWithAllocation)`. */ - fun body(packageWithAllocation: NewFloatingPackageWithAllocationPrice) = - body(Body.ofPackageWithAllocation(packageWithAllocation)) + /** Alias for calling [body] with `Body.ofGroupedTiered(groupedTiered)`. */ + fun body(groupedTiered: NewFloatingGroupedTieredPrice) = + body(Body.ofGroupedTiered(groupedTiered)) /** * Alias for calling [body] with @@ -137,10 +127,18 @@ private constructor( fun body(tieredPackageWithMinimum: NewFloatingTieredPackageWithMinimumPrice) = body(Body.ofTieredPackageWithMinimum(tieredPackageWithMinimum)) + /** Alias for calling [body] with `Body.ofPackageWithAllocation(packageWithAllocation)`. */ + fun body(packageWithAllocation: NewFloatingPackageWithAllocationPrice) = + body(Body.ofPackageWithAllocation(packageWithAllocation)) + /** Alias for calling [body] with `Body.ofUnitWithPercent(unitWithPercent)`. */ fun body(unitWithPercent: NewFloatingUnitWithPercentPrice) = body(Body.ofUnitWithPercent(unitWithPercent)) + /** Alias for calling [body] with `Body.ofMatrixWithAllocation(matrixWithAllocation)`. */ + fun body(matrixWithAllocation: NewFloatingMatrixWithAllocationPrice) = + body(Body.ofMatrixWithAllocation(matrixWithAllocation)) + /** Alias for calling [body] with `Body.ofTieredWithProration(tieredWithProration)`. */ fun body(tieredWithProration: NewFloatingTieredWithProrationPrice) = body(Body.ofTieredWithProration(tieredWithProration)) @@ -153,6 +151,10 @@ private constructor( fun body(groupedAllocation: NewFloatingGroupedAllocationPrice) = body(Body.ofGroupedAllocation(groupedAllocation)) + /** Alias for calling [body] with `Body.ofBulkWithProration(bulkWithProration)`. */ + fun body(bulkWithProration: NewFloatingBulkWithProrationPrice) = + body(Body.ofBulkWithProration(bulkWithProration)) + /** * Alias for calling [body] with * `Body.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)`. @@ -167,18 +169,25 @@ private constructor( fun body(groupedWithMeteredMinimum: NewFloatingGroupedWithMeteredMinimumPrice) = body(Body.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)) + /** + * Alias for calling [body] with + * `Body.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)`. + */ + fun body(groupedWithMinMaxThresholds: Body.GroupedWithMinMaxThresholds) = + body(Body.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)) + /** Alias for calling [body] with `Body.ofMatrixWithDisplayName(matrixWithDisplayName)`. */ fun body(matrixWithDisplayName: NewFloatingMatrixWithDisplayNamePrice) = body(Body.ofMatrixWithDisplayName(matrixWithDisplayName)) - /** Alias for calling [body] with `Body.ofBulkWithProration(bulkWithProration)`. */ - fun body(bulkWithProration: NewFloatingBulkWithProrationPrice) = - body(Body.ofBulkWithProration(bulkWithProration)) - /** Alias for calling [body] with `Body.ofGroupedTieredPackage(groupedTieredPackage)`. */ fun body(groupedTieredPackage: NewFloatingGroupedTieredPackagePrice) = body(Body.ofGroupedTieredPackage(groupedTieredPackage)) + /** Alias for calling [body] with `Body.ofMaxGroupTieredPackage(maxGroupTieredPackage)`. */ + fun body(maxGroupTieredPackage: NewFloatingMaxGroupTieredPackagePrice) = + body(Body.ofMaxGroupTieredPackage(maxGroupTieredPackage)) + /** * Alias for calling [body] with * `Body.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)`. @@ -197,13 +206,6 @@ private constructor( fun body(cumulativeGroupedBulk: NewFloatingCumulativeGroupedBulkPrice) = body(Body.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) - /** - * Alias for calling [body] with - * `Body.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)`. - */ - fun body(groupedWithMinMaxThresholds: Body.GroupedWithMinMaxThresholds) = - body(Body.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)) - /** Alias for calling [body] with `Body.ofMinimum(minimum)`. */ fun body(minimum: NewFloatingMinimumCompositePrice) = body(Body.ofMinimum(minimum)) @@ -331,90 +333,94 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams + /** New floating price request body params. */ @JsonDeserialize(using = Body.Deserializer::class) @JsonSerialize(using = Body.Serializer::class) class Body private constructor( private val unit: NewFloatingUnitPrice? = null, - private val package_: NewFloatingPackagePrice? = null, - private val matrix: NewFloatingMatrixPrice? = null, - private val matrixWithAllocation: NewFloatingMatrixWithAllocationPrice? = null, private val tiered: NewFloatingTieredPrice? = null, private val bulk: NewFloatingBulkPrice? = null, + private val package_: NewFloatingPackagePrice? = null, + private val matrix: NewFloatingMatrixPrice? = null, private val thresholdTotalAmount: NewFloatingThresholdTotalAmountPrice? = null, private val tieredPackage: NewFloatingTieredPackagePrice? = null, - private val groupedTiered: NewFloatingGroupedTieredPrice? = null, - private val maxGroupTieredPackage: NewFloatingMaxGroupTieredPackagePrice? = null, private val tieredWithMinimum: NewFloatingTieredWithMinimumPrice? = null, - private val packageWithAllocation: NewFloatingPackageWithAllocationPrice? = null, + private val groupedTiered: NewFloatingGroupedTieredPrice? = null, private val tieredPackageWithMinimum: NewFloatingTieredPackageWithMinimumPrice? = null, + private val packageWithAllocation: NewFloatingPackageWithAllocationPrice? = null, private val unitWithPercent: NewFloatingUnitWithPercentPrice? = null, + private val matrixWithAllocation: NewFloatingMatrixWithAllocationPrice? = null, private val tieredWithProration: NewFloatingTieredWithProrationPrice? = null, private val unitWithProration: NewFloatingUnitWithProrationPrice? = null, private val groupedAllocation: NewFloatingGroupedAllocationPrice? = null, + private val bulkWithProration: NewFloatingBulkWithProrationPrice? = null, private val groupedWithProratedMinimum: NewFloatingGroupedWithProratedMinimumPrice? = null, private val groupedWithMeteredMinimum: NewFloatingGroupedWithMeteredMinimumPrice? = null, + private val groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds? = null, private val matrixWithDisplayName: NewFloatingMatrixWithDisplayNamePrice? = null, - private val bulkWithProration: NewFloatingBulkWithProrationPrice? = null, private val groupedTieredPackage: NewFloatingGroupedTieredPackagePrice? = null, + private val maxGroupTieredPackage: NewFloatingMaxGroupTieredPackagePrice? = null, private val scalableMatrixWithUnitPricing: NewFloatingScalableMatrixWithUnitPricingPrice? = null, private val scalableMatrixWithTieredPricing: NewFloatingScalableMatrixWithTieredPricingPrice? = null, private val cumulativeGroupedBulk: NewFloatingCumulativeGroupedBulkPrice? = null, - private val groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds? = null, private val minimum: NewFloatingMinimumCompositePrice? = null, private val _json: JsonValue? = null, ) { fun unit(): NewFloatingUnitPrice? = unit - fun package_(): NewFloatingPackagePrice? = package_ - - fun matrix(): NewFloatingMatrixPrice? = matrix - - fun matrixWithAllocation(): NewFloatingMatrixWithAllocationPrice? = matrixWithAllocation - fun tiered(): NewFloatingTieredPrice? = tiered fun bulk(): NewFloatingBulkPrice? = bulk - fun thresholdTotalAmount(): NewFloatingThresholdTotalAmountPrice? = thresholdTotalAmount + fun package_(): NewFloatingPackagePrice? = package_ - fun tieredPackage(): NewFloatingTieredPackagePrice? = tieredPackage + fun matrix(): NewFloatingMatrixPrice? = matrix - fun groupedTiered(): NewFloatingGroupedTieredPrice? = groupedTiered + fun thresholdTotalAmount(): NewFloatingThresholdTotalAmountPrice? = thresholdTotalAmount - fun maxGroupTieredPackage(): NewFloatingMaxGroupTieredPackagePrice? = maxGroupTieredPackage + fun tieredPackage(): NewFloatingTieredPackagePrice? = tieredPackage fun tieredWithMinimum(): NewFloatingTieredWithMinimumPrice? = tieredWithMinimum - fun packageWithAllocation(): NewFloatingPackageWithAllocationPrice? = packageWithAllocation + fun groupedTiered(): NewFloatingGroupedTieredPrice? = groupedTiered fun tieredPackageWithMinimum(): NewFloatingTieredPackageWithMinimumPrice? = tieredPackageWithMinimum + fun packageWithAllocation(): NewFloatingPackageWithAllocationPrice? = packageWithAllocation + fun unitWithPercent(): NewFloatingUnitWithPercentPrice? = unitWithPercent + fun matrixWithAllocation(): NewFloatingMatrixWithAllocationPrice? = matrixWithAllocation + fun tieredWithProration(): NewFloatingTieredWithProrationPrice? = tieredWithProration fun unitWithProration(): NewFloatingUnitWithProrationPrice? = unitWithProration fun groupedAllocation(): NewFloatingGroupedAllocationPrice? = groupedAllocation + fun bulkWithProration(): NewFloatingBulkWithProrationPrice? = bulkWithProration + fun groupedWithProratedMinimum(): NewFloatingGroupedWithProratedMinimumPrice? = groupedWithProratedMinimum fun groupedWithMeteredMinimum(): NewFloatingGroupedWithMeteredMinimumPrice? = groupedWithMeteredMinimum - fun matrixWithDisplayName(): NewFloatingMatrixWithDisplayNamePrice? = matrixWithDisplayName + fun groupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds? = + groupedWithMinMaxThresholds - fun bulkWithProration(): NewFloatingBulkWithProrationPrice? = bulkWithProration + fun matrixWithDisplayName(): NewFloatingMatrixWithDisplayNamePrice? = matrixWithDisplayName fun groupedTieredPackage(): NewFloatingGroupedTieredPackagePrice? = groupedTieredPackage + fun maxGroupTieredPackage(): NewFloatingMaxGroupTieredPackagePrice? = maxGroupTieredPackage + fun scalableMatrixWithUnitPricing(): NewFloatingScalableMatrixWithUnitPricingPrice? = scalableMatrixWithUnitPricing @@ -423,102 +429,96 @@ private constructor( fun cumulativeGroupedBulk(): NewFloatingCumulativeGroupedBulkPrice? = cumulativeGroupedBulk - fun groupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds? = - groupedWithMinMaxThresholds - fun minimum(): NewFloatingMinimumCompositePrice? = minimum fun isUnit(): Boolean = unit != null - fun isPackage(): Boolean = package_ != null - - fun isMatrix(): Boolean = matrix != null - - fun isMatrixWithAllocation(): Boolean = matrixWithAllocation != null - fun isTiered(): Boolean = tiered != null fun isBulk(): Boolean = bulk != null - fun isThresholdTotalAmount(): Boolean = thresholdTotalAmount != null + fun isPackage(): Boolean = package_ != null - fun isTieredPackage(): Boolean = tieredPackage != null + fun isMatrix(): Boolean = matrix != null - fun isGroupedTiered(): Boolean = groupedTiered != null + fun isThresholdTotalAmount(): Boolean = thresholdTotalAmount != null - fun isMaxGroupTieredPackage(): Boolean = maxGroupTieredPackage != null + fun isTieredPackage(): Boolean = tieredPackage != null fun isTieredWithMinimum(): Boolean = tieredWithMinimum != null - fun isPackageWithAllocation(): Boolean = packageWithAllocation != null + fun isGroupedTiered(): Boolean = groupedTiered != null fun isTieredPackageWithMinimum(): Boolean = tieredPackageWithMinimum != null + fun isPackageWithAllocation(): Boolean = packageWithAllocation != null + fun isUnitWithPercent(): Boolean = unitWithPercent != null + fun isMatrixWithAllocation(): Boolean = matrixWithAllocation != null + fun isTieredWithProration(): Boolean = tieredWithProration != null fun isUnitWithProration(): Boolean = unitWithProration != null fun isGroupedAllocation(): Boolean = groupedAllocation != null + fun isBulkWithProration(): Boolean = bulkWithProration != null + fun isGroupedWithProratedMinimum(): Boolean = groupedWithProratedMinimum != null fun isGroupedWithMeteredMinimum(): Boolean = groupedWithMeteredMinimum != null - fun isMatrixWithDisplayName(): Boolean = matrixWithDisplayName != null + fun isGroupedWithMinMaxThresholds(): Boolean = groupedWithMinMaxThresholds != null - fun isBulkWithProration(): Boolean = bulkWithProration != null + fun isMatrixWithDisplayName(): Boolean = matrixWithDisplayName != null fun isGroupedTieredPackage(): Boolean = groupedTieredPackage != null + fun isMaxGroupTieredPackage(): Boolean = maxGroupTieredPackage != null + fun isScalableMatrixWithUnitPricing(): Boolean = scalableMatrixWithUnitPricing != null fun isScalableMatrixWithTieredPricing(): Boolean = scalableMatrixWithTieredPricing != null fun isCumulativeGroupedBulk(): Boolean = cumulativeGroupedBulk != null - fun isGroupedWithMinMaxThresholds(): Boolean = groupedWithMinMaxThresholds != null - fun isMinimum(): Boolean = minimum != null fun asUnit(): NewFloatingUnitPrice = unit.getOrThrow("unit") - fun asPackage(): NewFloatingPackagePrice = package_.getOrThrow("package_") - - fun asMatrix(): NewFloatingMatrixPrice = matrix.getOrThrow("matrix") - - fun asMatrixWithAllocation(): NewFloatingMatrixWithAllocationPrice = - matrixWithAllocation.getOrThrow("matrixWithAllocation") - fun asTiered(): NewFloatingTieredPrice = tiered.getOrThrow("tiered") fun asBulk(): NewFloatingBulkPrice = bulk.getOrThrow("bulk") + fun asPackage(): NewFloatingPackagePrice = package_.getOrThrow("package_") + + fun asMatrix(): NewFloatingMatrixPrice = matrix.getOrThrow("matrix") + fun asThresholdTotalAmount(): NewFloatingThresholdTotalAmountPrice = thresholdTotalAmount.getOrThrow("thresholdTotalAmount") fun asTieredPackage(): NewFloatingTieredPackagePrice = tieredPackage.getOrThrow("tieredPackage") - fun asGroupedTiered(): NewFloatingGroupedTieredPrice = - groupedTiered.getOrThrow("groupedTiered") - - fun asMaxGroupTieredPackage(): NewFloatingMaxGroupTieredPackagePrice = - maxGroupTieredPackage.getOrThrow("maxGroupTieredPackage") - fun asTieredWithMinimum(): NewFloatingTieredWithMinimumPrice = tieredWithMinimum.getOrThrow("tieredWithMinimum") - fun asPackageWithAllocation(): NewFloatingPackageWithAllocationPrice = - packageWithAllocation.getOrThrow("packageWithAllocation") + fun asGroupedTiered(): NewFloatingGroupedTieredPrice = + groupedTiered.getOrThrow("groupedTiered") fun asTieredPackageWithMinimum(): NewFloatingTieredPackageWithMinimumPrice = tieredPackageWithMinimum.getOrThrow("tieredPackageWithMinimum") + fun asPackageWithAllocation(): NewFloatingPackageWithAllocationPrice = + packageWithAllocation.getOrThrow("packageWithAllocation") + fun asUnitWithPercent(): NewFloatingUnitWithPercentPrice = unitWithPercent.getOrThrow("unitWithPercent") + fun asMatrixWithAllocation(): NewFloatingMatrixWithAllocationPrice = + matrixWithAllocation.getOrThrow("matrixWithAllocation") + fun asTieredWithProration(): NewFloatingTieredWithProrationPrice = tieredWithProration.getOrThrow("tieredWithProration") @@ -528,21 +528,27 @@ private constructor( fun asGroupedAllocation(): NewFloatingGroupedAllocationPrice = groupedAllocation.getOrThrow("groupedAllocation") + fun asBulkWithProration(): NewFloatingBulkWithProrationPrice = + bulkWithProration.getOrThrow("bulkWithProration") + fun asGroupedWithProratedMinimum(): NewFloatingGroupedWithProratedMinimumPrice = groupedWithProratedMinimum.getOrThrow("groupedWithProratedMinimum") fun asGroupedWithMeteredMinimum(): NewFloatingGroupedWithMeteredMinimumPrice = groupedWithMeteredMinimum.getOrThrow("groupedWithMeteredMinimum") + fun asGroupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds = + groupedWithMinMaxThresholds.getOrThrow("groupedWithMinMaxThresholds") + fun asMatrixWithDisplayName(): NewFloatingMatrixWithDisplayNamePrice = matrixWithDisplayName.getOrThrow("matrixWithDisplayName") - fun asBulkWithProration(): NewFloatingBulkWithProrationPrice = - bulkWithProration.getOrThrow("bulkWithProration") - fun asGroupedTieredPackage(): NewFloatingGroupedTieredPackagePrice = groupedTieredPackage.getOrThrow("groupedTieredPackage") + fun asMaxGroupTieredPackage(): NewFloatingMaxGroupTieredPackagePrice = + maxGroupTieredPackage.getOrThrow("maxGroupTieredPackage") + fun asScalableMatrixWithUnitPricing(): NewFloatingScalableMatrixWithUnitPricingPrice = scalableMatrixWithUnitPricing.getOrThrow("scalableMatrixWithUnitPricing") @@ -552,9 +558,6 @@ private constructor( fun asCumulativeGroupedBulk(): NewFloatingCumulativeGroupedBulkPrice = cumulativeGroupedBulk.getOrThrow("cumulativeGroupedBulk") - fun asGroupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds = - groupedWithMinMaxThresholds.getOrThrow("groupedWithMinMaxThresholds") - fun asMinimum(): NewFloatingMinimumCompositePrice = minimum.getOrThrow("minimum") fun _json(): JsonValue? = _json @@ -562,44 +565,44 @@ private constructor( fun accept(visitor: Visitor): T = when { unit != null -> visitor.visitUnit(unit) - package_ != null -> visitor.visitPackage(package_) - matrix != null -> visitor.visitMatrix(matrix) - matrixWithAllocation != null -> - visitor.visitMatrixWithAllocation(matrixWithAllocation) tiered != null -> visitor.visitTiered(tiered) bulk != null -> visitor.visitBulk(bulk) + package_ != null -> visitor.visitPackage(package_) + matrix != null -> visitor.visitMatrix(matrix) thresholdTotalAmount != null -> visitor.visitThresholdTotalAmount(thresholdTotalAmount) tieredPackage != null -> visitor.visitTieredPackage(tieredPackage) - groupedTiered != null -> visitor.visitGroupedTiered(groupedTiered) - maxGroupTieredPackage != null -> - visitor.visitMaxGroupTieredPackage(maxGroupTieredPackage) tieredWithMinimum != null -> visitor.visitTieredWithMinimum(tieredWithMinimum) - packageWithAllocation != null -> - visitor.visitPackageWithAllocation(packageWithAllocation) + groupedTiered != null -> visitor.visitGroupedTiered(groupedTiered) tieredPackageWithMinimum != null -> visitor.visitTieredPackageWithMinimum(tieredPackageWithMinimum) + packageWithAllocation != null -> + visitor.visitPackageWithAllocation(packageWithAllocation) unitWithPercent != null -> visitor.visitUnitWithPercent(unitWithPercent) + matrixWithAllocation != null -> + visitor.visitMatrixWithAllocation(matrixWithAllocation) tieredWithProration != null -> visitor.visitTieredWithProration(tieredWithProration) unitWithProration != null -> visitor.visitUnitWithProration(unitWithProration) groupedAllocation != null -> visitor.visitGroupedAllocation(groupedAllocation) + bulkWithProration != null -> visitor.visitBulkWithProration(bulkWithProration) groupedWithProratedMinimum != null -> visitor.visitGroupedWithProratedMinimum(groupedWithProratedMinimum) groupedWithMeteredMinimum != null -> visitor.visitGroupedWithMeteredMinimum(groupedWithMeteredMinimum) + groupedWithMinMaxThresholds != null -> + visitor.visitGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds) matrixWithDisplayName != null -> visitor.visitMatrixWithDisplayName(matrixWithDisplayName) - bulkWithProration != null -> visitor.visitBulkWithProration(bulkWithProration) groupedTieredPackage != null -> visitor.visitGroupedTieredPackage(groupedTieredPackage) + maxGroupTieredPackage != null -> + visitor.visitMaxGroupTieredPackage(maxGroupTieredPackage) scalableMatrixWithUnitPricing != null -> visitor.visitScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing) scalableMatrixWithTieredPricing != null -> visitor.visitScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing) cumulativeGroupedBulk != null -> visitor.visitCumulativeGroupedBulk(cumulativeGroupedBulk) - groupedWithMinMaxThresholds != null -> - visitor.visitGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds) minimum != null -> visitor.visitMinimum(minimum) else -> visitor.unknown(_json) } @@ -617,20 +620,6 @@ private constructor( unit.validate() } - override fun visitPackage(package_: NewFloatingPackagePrice) { - package_.validate() - } - - override fun visitMatrix(matrix: NewFloatingMatrixPrice) { - matrix.validate() - } - - override fun visitMatrixWithAllocation( - matrixWithAllocation: NewFloatingMatrixWithAllocationPrice - ) { - matrixWithAllocation.validate() - } - override fun visitTiered(tiered: NewFloatingTieredPrice) { tiered.validate() } @@ -639,6 +628,14 @@ private constructor( bulk.validate() } + override fun visitPackage(package_: NewFloatingPackagePrice) { + package_.validate() + } + + override fun visitMatrix(matrix: NewFloatingMatrixPrice) { + matrix.validate() + } + override fun visitThresholdTotalAmount( thresholdTotalAmount: NewFloatingThresholdTotalAmountPrice ) { @@ -649,26 +646,14 @@ private constructor( tieredPackage.validate() } - override fun visitGroupedTiered(groupedTiered: NewFloatingGroupedTieredPrice) { - groupedTiered.validate() - } - - override fun visitMaxGroupTieredPackage( - maxGroupTieredPackage: NewFloatingMaxGroupTieredPackagePrice - ) { - maxGroupTieredPackage.validate() - } - override fun visitTieredWithMinimum( tieredWithMinimum: NewFloatingTieredWithMinimumPrice ) { tieredWithMinimum.validate() } - override fun visitPackageWithAllocation( - packageWithAllocation: NewFloatingPackageWithAllocationPrice - ) { - packageWithAllocation.validate() + override fun visitGroupedTiered(groupedTiered: NewFloatingGroupedTieredPrice) { + groupedTiered.validate() } override fun visitTieredPackageWithMinimum( @@ -677,12 +662,24 @@ private constructor( tieredPackageWithMinimum.validate() } + override fun visitPackageWithAllocation( + packageWithAllocation: NewFloatingPackageWithAllocationPrice + ) { + packageWithAllocation.validate() + } + override fun visitUnitWithPercent( unitWithPercent: NewFloatingUnitWithPercentPrice ) { unitWithPercent.validate() } + override fun visitMatrixWithAllocation( + matrixWithAllocation: NewFloatingMatrixWithAllocationPrice + ) { + matrixWithAllocation.validate() + } + override fun visitTieredWithProration( tieredWithProration: NewFloatingTieredWithProrationPrice ) { @@ -701,6 +698,12 @@ private constructor( groupedAllocation.validate() } + override fun visitBulkWithProration( + bulkWithProration: NewFloatingBulkWithProrationPrice + ) { + bulkWithProration.validate() + } + override fun visitGroupedWithProratedMinimum( groupedWithProratedMinimum: NewFloatingGroupedWithProratedMinimumPrice ) { @@ -713,16 +716,16 @@ private constructor( groupedWithMeteredMinimum.validate() } - override fun visitMatrixWithDisplayName( - matrixWithDisplayName: NewFloatingMatrixWithDisplayNamePrice + override fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds ) { - matrixWithDisplayName.validate() + groupedWithMinMaxThresholds.validate() } - override fun visitBulkWithProration( - bulkWithProration: NewFloatingBulkWithProrationPrice + override fun visitMatrixWithDisplayName( + matrixWithDisplayName: NewFloatingMatrixWithDisplayNamePrice ) { - bulkWithProration.validate() + matrixWithDisplayName.validate() } override fun visitGroupedTieredPackage( @@ -731,6 +734,12 @@ private constructor( groupedTieredPackage.validate() } + override fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: NewFloatingMaxGroupTieredPackagePrice + ) { + maxGroupTieredPackage.validate() + } + override fun visitScalableMatrixWithUnitPricing( scalableMatrixWithUnitPricing: NewFloatingScalableMatrixWithUnitPricingPrice ) { @@ -750,12 +759,6 @@ private constructor( cumulativeGroupedBulk.validate() } - override fun visitGroupedWithMinMaxThresholds( - groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds - ) { - groupedWithMinMaxThresholds.validate() - } - override fun visitMinimum(minimum: NewFloatingMinimumCompositePrice) { minimum.validate() } @@ -783,19 +786,15 @@ private constructor( object : Visitor { override fun visitUnit(unit: NewFloatingUnitPrice) = unit.validity() + override fun visitTiered(tiered: NewFloatingTieredPrice) = tiered.validity() + + override fun visitBulk(bulk: NewFloatingBulkPrice) = bulk.validity() + override fun visitPackage(package_: NewFloatingPackagePrice) = package_.validity() override fun visitMatrix(matrix: NewFloatingMatrixPrice) = matrix.validity() - override fun visitMatrixWithAllocation( - matrixWithAllocation: NewFloatingMatrixWithAllocationPrice - ) = matrixWithAllocation.validity() - - override fun visitTiered(tiered: NewFloatingTieredPrice) = tiered.validity() - - override fun visitBulk(bulk: NewFloatingBulkPrice) = bulk.validity() - override fun visitThresholdTotalAmount( thresholdTotalAmount: NewFloatingThresholdTotalAmountPrice ) = thresholdTotalAmount.validity() @@ -803,29 +802,29 @@ private constructor( override fun visitTieredPackage(tieredPackage: NewFloatingTieredPackagePrice) = tieredPackage.validity() - override fun visitGroupedTiered(groupedTiered: NewFloatingGroupedTieredPrice) = - groupedTiered.validity() - - override fun visitMaxGroupTieredPackage( - maxGroupTieredPackage: NewFloatingMaxGroupTieredPackagePrice - ) = maxGroupTieredPackage.validity() - override fun visitTieredWithMinimum( tieredWithMinimum: NewFloatingTieredWithMinimumPrice ) = tieredWithMinimum.validity() - override fun visitPackageWithAllocation( - packageWithAllocation: NewFloatingPackageWithAllocationPrice - ) = packageWithAllocation.validity() + override fun visitGroupedTiered(groupedTiered: NewFloatingGroupedTieredPrice) = + groupedTiered.validity() override fun visitTieredPackageWithMinimum( tieredPackageWithMinimum: NewFloatingTieredPackageWithMinimumPrice ) = tieredPackageWithMinimum.validity() + override fun visitPackageWithAllocation( + packageWithAllocation: NewFloatingPackageWithAllocationPrice + ) = packageWithAllocation.validity() + override fun visitUnitWithPercent( unitWithPercent: NewFloatingUnitWithPercentPrice ) = unitWithPercent.validity() + override fun visitMatrixWithAllocation( + matrixWithAllocation: NewFloatingMatrixWithAllocationPrice + ) = matrixWithAllocation.validity() + override fun visitTieredWithProration( tieredWithProration: NewFloatingTieredWithProrationPrice ) = tieredWithProration.validity() @@ -838,6 +837,10 @@ private constructor( groupedAllocation: NewFloatingGroupedAllocationPrice ) = groupedAllocation.validity() + override fun visitBulkWithProration( + bulkWithProration: NewFloatingBulkWithProrationPrice + ) = bulkWithProration.validity() + override fun visitGroupedWithProratedMinimum( groupedWithProratedMinimum: NewFloatingGroupedWithProratedMinimumPrice ) = groupedWithProratedMinimum.validity() @@ -846,18 +849,22 @@ private constructor( groupedWithMeteredMinimum: NewFloatingGroupedWithMeteredMinimumPrice ) = groupedWithMeteredMinimum.validity() + override fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) = groupedWithMinMaxThresholds.validity() + override fun visitMatrixWithDisplayName( matrixWithDisplayName: NewFloatingMatrixWithDisplayNamePrice ) = matrixWithDisplayName.validity() - override fun visitBulkWithProration( - bulkWithProration: NewFloatingBulkWithProrationPrice - ) = bulkWithProration.validity() - override fun visitGroupedTieredPackage( groupedTieredPackage: NewFloatingGroupedTieredPackagePrice ) = groupedTieredPackage.validity() + override fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: NewFloatingMaxGroupTieredPackagePrice + ) = maxGroupTieredPackage.validity() + override fun visitScalableMatrixWithUnitPricing( scalableMatrixWithUnitPricing: NewFloatingScalableMatrixWithUnitPricingPrice ) = scalableMatrixWithUnitPricing.validity() @@ -871,10 +878,6 @@ private constructor( cumulativeGroupedBulk: NewFloatingCumulativeGroupedBulkPrice ) = cumulativeGroupedBulk.validity() - override fun visitGroupedWithMinMaxThresholds( - groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds - ) = groupedWithMinMaxThresholds.validity() - override fun visitMinimum(minimum: NewFloatingMinimumCompositePrice) = minimum.validity() @@ -889,103 +892,103 @@ private constructor( return other is Body && unit == other.unit && - package_ == other.package_ && - matrix == other.matrix && - matrixWithAllocation == other.matrixWithAllocation && tiered == other.tiered && bulk == other.bulk && + package_ == other.package_ && + matrix == other.matrix && thresholdTotalAmount == other.thresholdTotalAmount && tieredPackage == other.tieredPackage && - groupedTiered == other.groupedTiered && - maxGroupTieredPackage == other.maxGroupTieredPackage && tieredWithMinimum == other.tieredWithMinimum && - packageWithAllocation == other.packageWithAllocation && + groupedTiered == other.groupedTiered && tieredPackageWithMinimum == other.tieredPackageWithMinimum && + packageWithAllocation == other.packageWithAllocation && unitWithPercent == other.unitWithPercent && + matrixWithAllocation == other.matrixWithAllocation && tieredWithProration == other.tieredWithProration && unitWithProration == other.unitWithProration && groupedAllocation == other.groupedAllocation && + bulkWithProration == other.bulkWithProration && groupedWithProratedMinimum == other.groupedWithProratedMinimum && groupedWithMeteredMinimum == other.groupedWithMeteredMinimum && + groupedWithMinMaxThresholds == other.groupedWithMinMaxThresholds && matrixWithDisplayName == other.matrixWithDisplayName && - bulkWithProration == other.bulkWithProration && groupedTieredPackage == other.groupedTieredPackage && + maxGroupTieredPackage == other.maxGroupTieredPackage && scalableMatrixWithUnitPricing == other.scalableMatrixWithUnitPricing && scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && cumulativeGroupedBulk == other.cumulativeGroupedBulk && - groupedWithMinMaxThresholds == other.groupedWithMinMaxThresholds && minimum == other.minimum } override fun hashCode(): Int = Objects.hash( unit, - package_, - matrix, - matrixWithAllocation, tiered, bulk, + package_, + matrix, thresholdTotalAmount, tieredPackage, - groupedTiered, - maxGroupTieredPackage, tieredWithMinimum, - packageWithAllocation, + groupedTiered, tieredPackageWithMinimum, + packageWithAllocation, unitWithPercent, + matrixWithAllocation, tieredWithProration, unitWithProration, groupedAllocation, + bulkWithProration, groupedWithProratedMinimum, groupedWithMeteredMinimum, + groupedWithMinMaxThresholds, matrixWithDisplayName, - bulkWithProration, groupedTieredPackage, + maxGroupTieredPackage, scalableMatrixWithUnitPricing, scalableMatrixWithTieredPricing, cumulativeGroupedBulk, - groupedWithMinMaxThresholds, minimum, ) override fun toString(): String = when { unit != null -> "Body{unit=$unit}" - package_ != null -> "Body{package_=$package_}" - matrix != null -> "Body{matrix=$matrix}" - matrixWithAllocation != null -> "Body{matrixWithAllocation=$matrixWithAllocation}" tiered != null -> "Body{tiered=$tiered}" bulk != null -> "Body{bulk=$bulk}" + package_ != null -> "Body{package_=$package_}" + matrix != null -> "Body{matrix=$matrix}" thresholdTotalAmount != null -> "Body{thresholdTotalAmount=$thresholdTotalAmount}" tieredPackage != null -> "Body{tieredPackage=$tieredPackage}" - groupedTiered != null -> "Body{groupedTiered=$groupedTiered}" - maxGroupTieredPackage != null -> - "Body{maxGroupTieredPackage=$maxGroupTieredPackage}" tieredWithMinimum != null -> "Body{tieredWithMinimum=$tieredWithMinimum}" - packageWithAllocation != null -> - "Body{packageWithAllocation=$packageWithAllocation}" + groupedTiered != null -> "Body{groupedTiered=$groupedTiered}" tieredPackageWithMinimum != null -> "Body{tieredPackageWithMinimum=$tieredPackageWithMinimum}" + packageWithAllocation != null -> + "Body{packageWithAllocation=$packageWithAllocation}" unitWithPercent != null -> "Body{unitWithPercent=$unitWithPercent}" + matrixWithAllocation != null -> "Body{matrixWithAllocation=$matrixWithAllocation}" tieredWithProration != null -> "Body{tieredWithProration=$tieredWithProration}" unitWithProration != null -> "Body{unitWithProration=$unitWithProration}" groupedAllocation != null -> "Body{groupedAllocation=$groupedAllocation}" + bulkWithProration != null -> "Body{bulkWithProration=$bulkWithProration}" groupedWithProratedMinimum != null -> "Body{groupedWithProratedMinimum=$groupedWithProratedMinimum}" groupedWithMeteredMinimum != null -> "Body{groupedWithMeteredMinimum=$groupedWithMeteredMinimum}" + groupedWithMinMaxThresholds != null -> + "Body{groupedWithMinMaxThresholds=$groupedWithMinMaxThresholds}" matrixWithDisplayName != null -> "Body{matrixWithDisplayName=$matrixWithDisplayName}" - bulkWithProration != null -> "Body{bulkWithProration=$bulkWithProration}" groupedTieredPackage != null -> "Body{groupedTieredPackage=$groupedTieredPackage}" + maxGroupTieredPackage != null -> + "Body{maxGroupTieredPackage=$maxGroupTieredPackage}" scalableMatrixWithUnitPricing != null -> "Body{scalableMatrixWithUnitPricing=$scalableMatrixWithUnitPricing}" scalableMatrixWithTieredPricing != null -> "Body{scalableMatrixWithTieredPricing=$scalableMatrixWithTieredPricing}" cumulativeGroupedBulk != null -> "Body{cumulativeGroupedBulk=$cumulativeGroupedBulk}" - groupedWithMinMaxThresholds != null -> - "Body{groupedWithMinMaxThresholds=$groupedWithMinMaxThresholds}" minimum != null -> "Body{minimum=$minimum}" _json != null -> "Body{_unknown=$_json}" else -> throw IllegalStateException("Invalid Body") @@ -995,44 +998,40 @@ private constructor( fun ofUnit(unit: NewFloatingUnitPrice) = Body(unit = unit) - fun ofPackage(package_: NewFloatingPackagePrice) = Body(package_ = package_) - - fun ofMatrix(matrix: NewFloatingMatrixPrice) = Body(matrix = matrix) - - fun ofMatrixWithAllocation(matrixWithAllocation: NewFloatingMatrixWithAllocationPrice) = - Body(matrixWithAllocation = matrixWithAllocation) - fun ofTiered(tiered: NewFloatingTieredPrice) = Body(tiered = tiered) fun ofBulk(bulk: NewFloatingBulkPrice) = Body(bulk = bulk) + fun ofPackage(package_: NewFloatingPackagePrice) = Body(package_ = package_) + + fun ofMatrix(matrix: NewFloatingMatrixPrice) = Body(matrix = matrix) + fun ofThresholdTotalAmount(thresholdTotalAmount: NewFloatingThresholdTotalAmountPrice) = Body(thresholdTotalAmount = thresholdTotalAmount) fun ofTieredPackage(tieredPackage: NewFloatingTieredPackagePrice) = Body(tieredPackage = tieredPackage) - fun ofGroupedTiered(groupedTiered: NewFloatingGroupedTieredPrice) = - Body(groupedTiered = groupedTiered) - - fun ofMaxGroupTieredPackage( - maxGroupTieredPackage: NewFloatingMaxGroupTieredPackagePrice - ) = Body(maxGroupTieredPackage = maxGroupTieredPackage) - fun ofTieredWithMinimum(tieredWithMinimum: NewFloatingTieredWithMinimumPrice) = Body(tieredWithMinimum = tieredWithMinimum) - fun ofPackageWithAllocation( - packageWithAllocation: NewFloatingPackageWithAllocationPrice - ) = Body(packageWithAllocation = packageWithAllocation) + fun ofGroupedTiered(groupedTiered: NewFloatingGroupedTieredPrice) = + Body(groupedTiered = groupedTiered) fun ofTieredPackageWithMinimum( tieredPackageWithMinimum: NewFloatingTieredPackageWithMinimumPrice ) = Body(tieredPackageWithMinimum = tieredPackageWithMinimum) + fun ofPackageWithAllocation( + packageWithAllocation: NewFloatingPackageWithAllocationPrice + ) = Body(packageWithAllocation = packageWithAllocation) + fun ofUnitWithPercent(unitWithPercent: NewFloatingUnitWithPercentPrice) = Body(unitWithPercent = unitWithPercent) + fun ofMatrixWithAllocation(matrixWithAllocation: NewFloatingMatrixWithAllocationPrice) = + Body(matrixWithAllocation = matrixWithAllocation) + fun ofTieredWithProration(tieredWithProration: NewFloatingTieredWithProrationPrice) = Body(tieredWithProration = tieredWithProration) @@ -1042,6 +1041,9 @@ private constructor( fun ofGroupedAllocation(groupedAllocation: NewFloatingGroupedAllocationPrice) = Body(groupedAllocation = groupedAllocation) + fun ofBulkWithProration(bulkWithProration: NewFloatingBulkWithProrationPrice) = + Body(bulkWithProration = bulkWithProration) + fun ofGroupedWithProratedMinimum( groupedWithProratedMinimum: NewFloatingGroupedWithProratedMinimumPrice ) = Body(groupedWithProratedMinimum = groupedWithProratedMinimum) @@ -1050,16 +1052,21 @@ private constructor( groupedWithMeteredMinimum: NewFloatingGroupedWithMeteredMinimumPrice ) = Body(groupedWithMeteredMinimum = groupedWithMeteredMinimum) + fun ofGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) = Body(groupedWithMinMaxThresholds = groupedWithMinMaxThresholds) + fun ofMatrixWithDisplayName( matrixWithDisplayName: NewFloatingMatrixWithDisplayNamePrice ) = Body(matrixWithDisplayName = matrixWithDisplayName) - fun ofBulkWithProration(bulkWithProration: NewFloatingBulkWithProrationPrice) = - Body(bulkWithProration = bulkWithProration) - fun ofGroupedTieredPackage(groupedTieredPackage: NewFloatingGroupedTieredPackagePrice) = Body(groupedTieredPackage = groupedTieredPackage) + fun ofMaxGroupTieredPackage( + maxGroupTieredPackage: NewFloatingMaxGroupTieredPackagePrice + ) = Body(maxGroupTieredPackage = maxGroupTieredPackage) + fun ofScalableMatrixWithUnitPricing( scalableMatrixWithUnitPricing: NewFloatingScalableMatrixWithUnitPricingPrice ) = Body(scalableMatrixWithUnitPricing = scalableMatrixWithUnitPricing) @@ -1072,10 +1079,6 @@ private constructor( cumulativeGroupedBulk: NewFloatingCumulativeGroupedBulkPrice ) = Body(cumulativeGroupedBulk = cumulativeGroupedBulk) - fun ofGroupedWithMinMaxThresholds( - groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds - ) = Body(groupedWithMinMaxThresholds = groupedWithMinMaxThresholds) - fun ofMinimum(minimum: NewFloatingMinimumCompositePrice) = Body(minimum = minimum) } @@ -1084,42 +1087,38 @@ private constructor( fun visitUnit(unit: NewFloatingUnitPrice): T - fun visitPackage(package_: NewFloatingPackagePrice): T - - fun visitMatrix(matrix: NewFloatingMatrixPrice): T - - fun visitMatrixWithAllocation( - matrixWithAllocation: NewFloatingMatrixWithAllocationPrice - ): T - fun visitTiered(tiered: NewFloatingTieredPrice): T fun visitBulk(bulk: NewFloatingBulkPrice): T + fun visitPackage(package_: NewFloatingPackagePrice): T + + fun visitMatrix(matrix: NewFloatingMatrixPrice): T + fun visitThresholdTotalAmount( thresholdTotalAmount: NewFloatingThresholdTotalAmountPrice ): T fun visitTieredPackage(tieredPackage: NewFloatingTieredPackagePrice): T + fun visitTieredWithMinimum(tieredWithMinimum: NewFloatingTieredWithMinimumPrice): T + fun visitGroupedTiered(groupedTiered: NewFloatingGroupedTieredPrice): T - fun visitMaxGroupTieredPackage( - maxGroupTieredPackage: NewFloatingMaxGroupTieredPackagePrice + fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: NewFloatingTieredPackageWithMinimumPrice ): T - fun visitTieredWithMinimum(tieredWithMinimum: NewFloatingTieredWithMinimumPrice): T - fun visitPackageWithAllocation( packageWithAllocation: NewFloatingPackageWithAllocationPrice ): T - fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewFloatingTieredPackageWithMinimumPrice - ): T - fun visitUnitWithPercent(unitWithPercent: NewFloatingUnitWithPercentPrice): T + fun visitMatrixWithAllocation( + matrixWithAllocation: NewFloatingMatrixWithAllocationPrice + ): T + fun visitTieredWithProration( tieredWithProration: NewFloatingTieredWithProrationPrice ): T @@ -1128,6 +1127,8 @@ private constructor( fun visitGroupedAllocation(groupedAllocation: NewFloatingGroupedAllocationPrice): T + fun visitBulkWithProration(bulkWithProration: NewFloatingBulkWithProrationPrice): T + fun visitGroupedWithProratedMinimum( groupedWithProratedMinimum: NewFloatingGroupedWithProratedMinimumPrice ): T @@ -1136,16 +1137,22 @@ private constructor( groupedWithMeteredMinimum: NewFloatingGroupedWithMeteredMinimumPrice ): T + fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ): T + fun visitMatrixWithDisplayName( matrixWithDisplayName: NewFloatingMatrixWithDisplayNamePrice ): T - fun visitBulkWithProration(bulkWithProration: NewFloatingBulkWithProrationPrice): T - fun visitGroupedTieredPackage( groupedTieredPackage: NewFloatingGroupedTieredPackagePrice ): T + fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: NewFloatingMaxGroupTieredPackagePrice + ): T + fun visitScalableMatrixWithUnitPricing( scalableMatrixWithUnitPricing: NewFloatingScalableMatrixWithUnitPricingPrice ): T @@ -1158,10 +1165,6 @@ private constructor( cumulativeGroupedBulk: NewFloatingCumulativeGroupedBulkPrice ): T - fun visitGroupedWithMinMaxThresholds( - groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds - ): T - fun visitMinimum(minimum: NewFloatingMinimumCompositePrice): T /** @@ -1190,23 +1193,6 @@ private constructor( Body(unit = it, _json = json) } ?: Body(_json = json) } - "package" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Body(package_ = it, _json = json) } ?: Body(_json = json) - } - "matrix" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Body(matrix = it, _json = json) - } ?: Body(_json = json) - } - "matrix_with_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Body(matrixWithAllocation = it, _json = json) } - ?: Body(_json = json) - } "tiered" -> { return tryDeserialize(node, jacksonTypeRef())?.let { Body(tiered = it, _json = json) @@ -1217,6 +1203,15 @@ private constructor( Body(bulk = it, _json = json) } ?: Body(_json = json) } + "package" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Body(package_ = it, _json = json) } ?: Body(_json = json) + } + "matrix" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Body(matrix = it, _json = json) + } ?: Body(_json = json) + } "threshold_total_amount" -> { return tryDeserialize( node, @@ -1229,24 +1224,24 @@ private constructor( return tryDeserialize(node, jacksonTypeRef()) ?.let { Body(tieredPackage = it, _json = json) } ?: Body(_json = json) } - "grouped_tiered" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Body(groupedTiered = it, _json = json) } ?: Body(_json = json) - } - "max_group_tiered_package" -> { + "tiered_with_minimum" -> { return tryDeserialize( node, - jacksonTypeRef(), + jacksonTypeRef(), ) - ?.let { Body(maxGroupTieredPackage = it, _json = json) } + ?.let { Body(tieredWithMinimum = it, _json = json) } ?: Body(_json = json) } - "tiered_with_minimum" -> { + "grouped_tiered" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Body(groupedTiered = it, _json = json) } ?: Body(_json = json) + } + "tiered_package_with_minimum" -> { return tryDeserialize( node, - jacksonTypeRef(), + jacksonTypeRef(), ) - ?.let { Body(tieredWithMinimum = it, _json = json) } + ?.let { Body(tieredPackageWithMinimum = it, _json = json) } ?: Body(_json = json) } "package_with_allocation" -> { @@ -1257,20 +1252,20 @@ private constructor( ?.let { Body(packageWithAllocation = it, _json = json) } ?: Body(_json = json) } - "tiered_package_with_minimum" -> { + "unit_with_percent" -> { return tryDeserialize( node, - jacksonTypeRef(), + jacksonTypeRef(), ) - ?.let { Body(tieredPackageWithMinimum = it, _json = json) } - ?: Body(_json = json) + ?.let { Body(unitWithPercent = it, _json = json) } ?: Body(_json = json) } - "unit_with_percent" -> { + "matrix_with_allocation" -> { return tryDeserialize( node, - jacksonTypeRef(), + jacksonTypeRef(), ) - ?.let { Body(unitWithPercent = it, _json = json) } ?: Body(_json = json) + ?.let { Body(matrixWithAllocation = it, _json = json) } + ?: Body(_json = json) } "tiered_with_proration" -> { return tryDeserialize( @@ -1296,6 +1291,14 @@ private constructor( ?.let { Body(groupedAllocation = it, _json = json) } ?: Body(_json = json) } + "bulk_with_proration" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Body(bulkWithProration = it, _json = json) } + ?: Body(_json = json) + } "grouped_with_prorated_minimum" -> { return tryDeserialize( node, @@ -1312,6 +1315,11 @@ private constructor( ?.let { Body(groupedWithMeteredMinimum = it, _json = json) } ?: Body(_json = json) } + "grouped_with_min_max_thresholds" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Body(groupedWithMinMaxThresholds = it, _json = json) } + ?: Body(_json = json) + } "matrix_with_display_name" -> { return tryDeserialize( node, @@ -1320,20 +1328,20 @@ private constructor( ?.let { Body(matrixWithDisplayName = it, _json = json) } ?: Body(_json = json) } - "bulk_with_proration" -> { + "grouped_tiered_package" -> { return tryDeserialize( node, - jacksonTypeRef(), + jacksonTypeRef(), ) - ?.let { Body(bulkWithProration = it, _json = json) } + ?.let { Body(groupedTieredPackage = it, _json = json) } ?: Body(_json = json) } - "grouped_tiered_package" -> { + "max_group_tiered_package" -> { return tryDeserialize( node, - jacksonTypeRef(), + jacksonTypeRef(), ) - ?.let { Body(groupedTieredPackage = it, _json = json) } + ?.let { Body(maxGroupTieredPackage = it, _json = json) } ?: Body(_json = json) } "scalable_matrix_with_unit_pricing" -> { @@ -1360,11 +1368,6 @@ private constructor( ?.let { Body(cumulativeGroupedBulk = it, _json = json) } ?: Body(_json = json) } - "grouped_with_min_max_thresholds" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Body(groupedWithMinMaxThresholds = it, _json = json) } - ?: Body(_json = json) - } "minimum" -> { return tryDeserialize( node, @@ -1387,49 +1390,49 @@ private constructor( ) { when { value.unit != null -> generator.writeObject(value.unit) - value.package_ != null -> generator.writeObject(value.package_) - value.matrix != null -> generator.writeObject(value.matrix) - value.matrixWithAllocation != null -> - generator.writeObject(value.matrixWithAllocation) value.tiered != null -> generator.writeObject(value.tiered) value.bulk != null -> generator.writeObject(value.bulk) + value.package_ != null -> generator.writeObject(value.package_) + value.matrix != null -> generator.writeObject(value.matrix) value.thresholdTotalAmount != null -> generator.writeObject(value.thresholdTotalAmount) value.tieredPackage != null -> generator.writeObject(value.tieredPackage) - value.groupedTiered != null -> generator.writeObject(value.groupedTiered) - value.maxGroupTieredPackage != null -> - generator.writeObject(value.maxGroupTieredPackage) value.tieredWithMinimum != null -> generator.writeObject(value.tieredWithMinimum) - value.packageWithAllocation != null -> - generator.writeObject(value.packageWithAllocation) + value.groupedTiered != null -> generator.writeObject(value.groupedTiered) value.tieredPackageWithMinimum != null -> generator.writeObject(value.tieredPackageWithMinimum) + value.packageWithAllocation != null -> + generator.writeObject(value.packageWithAllocation) value.unitWithPercent != null -> generator.writeObject(value.unitWithPercent) + value.matrixWithAllocation != null -> + generator.writeObject(value.matrixWithAllocation) value.tieredWithProration != null -> generator.writeObject(value.tieredWithProration) value.unitWithProration != null -> generator.writeObject(value.unitWithProration) value.groupedAllocation != null -> generator.writeObject(value.groupedAllocation) + value.bulkWithProration != null -> + generator.writeObject(value.bulkWithProration) value.groupedWithProratedMinimum != null -> generator.writeObject(value.groupedWithProratedMinimum) value.groupedWithMeteredMinimum != null -> generator.writeObject(value.groupedWithMeteredMinimum) + value.groupedWithMinMaxThresholds != null -> + generator.writeObject(value.groupedWithMinMaxThresholds) value.matrixWithDisplayName != null -> generator.writeObject(value.matrixWithDisplayName) - value.bulkWithProration != null -> - generator.writeObject(value.bulkWithProration) value.groupedTieredPackage != null -> generator.writeObject(value.groupedTieredPackage) + value.maxGroupTieredPackage != null -> + generator.writeObject(value.maxGroupTieredPackage) value.scalableMatrixWithUnitPricing != null -> generator.writeObject(value.scalableMatrixWithUnitPricing) value.scalableMatrixWithTieredPricing != null -> generator.writeObject(value.scalableMatrixWithTieredPricing) value.cumulativeGroupedBulk != null -> generator.writeObject(value.cumulativeGroupedBulk) - value.groupedWithMinMaxThresholds != null -> - generator.writeObject(value.groupedWithMinMaxThresholds) value.minimum != null -> generator.writeObject(value.minimum) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid Body") @@ -1553,6 +1556,8 @@ private constructor( fun currency(): String = currency.getRequired("currency") /** + * Configuration for grouped_with_min_max_thresholds pricing + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected * value). @@ -1572,6 +1577,8 @@ private constructor( fun itemId(): String = itemId.getRequired("item_id") /** + * The pricing model type + * * Expected to always return the following: * ```kotlin * JsonValue.from("grouped_with_min_max_thresholds") @@ -1951,6 +1958,7 @@ private constructor( */ fun currency(currency: JsonField) = apply { this.currency = currency } + /** Configuration for grouped_with_min_max_thresholds pricing */ fun groupedWithMinMaxThresholdsConfig( groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig ) = @@ -2557,16 +2565,117 @@ private constructor( override fun toString() = value.toString() } + /** Configuration for grouped_with_min_max_thresholds pricing */ class GroupedWithMinMaxThresholdsConfig - @JsonCreator private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map + private val groupingKey: JsonField, + private val maximumCharge: JsonField, + private val minimumCharge: JsonField, + private val perUnitRate: JsonField, + private val additionalProperties: MutableMap, ) { + @JsonCreator + private constructor( + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("maximum_charge") + @ExcludeMissing + maximumCharge: JsonField = JsonMissing.of(), + @JsonProperty("minimum_charge") + @ExcludeMissing + minimumCharge: JsonField = JsonMissing.of(), + @JsonProperty("per_unit_rate") + @ExcludeMissing + perUnitRate: JsonField = JsonMissing.of(), + ) : this(groupingKey, maximumCharge, minimumCharge, perUnitRate, mutableMapOf()) + + /** + * The event property used to group before applying thresholds + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The maximum amount to charge each group + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun maximumCharge(): String = maximumCharge.getRequired("maximum_charge") + + /** + * The minimum amount to charge each group, regardless of usage + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun minimumCharge(): String = minimumCharge.getRequired("minimum_charge") + + /** + * The base price charged per group + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun perUnitRate(): String = perUnitRate.getRequired("per_unit_rate") + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [maximumCharge]. + * + * Unlike [maximumCharge], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("maximum_charge") + @ExcludeMissing + fun _maximumCharge(): JsonField = maximumCharge + + /** + * Returns the raw JSON value of [minimumCharge]. + * + * Unlike [minimumCharge], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("minimum_charge") + @ExcludeMissing + fun _minimumCharge(): JsonField = minimumCharge + + /** + * Returns the raw JSON value of [perUnitRate]. + * + * Unlike [perUnitRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("per_unit_rate") + @ExcludeMissing + fun _perUnitRate(): JsonField = perUnitRate + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) fun toBuilder() = Builder().from(this) @@ -2575,6 +2684,14 @@ private constructor( /** * Returns a mutable builder for constructing an instance of * [GroupedWithMinMaxThresholdsConfig]. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .maximumCharge() + * .minimumCharge() + * .perUnitRate() + * ``` */ fun builder() = Builder() } @@ -2582,15 +2699,81 @@ private constructor( /** A builder for [GroupedWithMinMaxThresholdsConfig]. */ class Builder internal constructor() { + private var groupingKey: JsonField? = null + private var maximumCharge: JsonField? = null + private var minimumCharge: JsonField? = null + private var perUnitRate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from( groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig ) = apply { + groupingKey = groupedWithMinMaxThresholdsConfig.groupingKey + maximumCharge = groupedWithMinMaxThresholdsConfig.maximumCharge + minimumCharge = groupedWithMinMaxThresholdsConfig.minimumCharge + perUnitRate = groupedWithMinMaxThresholdsConfig.perUnitRate additionalProperties = groupedWithMinMaxThresholdsConfig.additionalProperties.toMutableMap() } + /** The event property used to group before applying thresholds */ + fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The maximum amount to charge each group */ + fun maximumCharge(maximumCharge: String) = + maximumCharge(JsonField.of(maximumCharge)) + + /** + * Sets [Builder.maximumCharge] to an arbitrary JSON value. + * + * You should usually call [Builder.maximumCharge] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun maximumCharge(maximumCharge: JsonField) = apply { + this.maximumCharge = maximumCharge + } + + /** The minimum amount to charge each group, regardless of usage */ + fun minimumCharge(minimumCharge: String) = + minimumCharge(JsonField.of(minimumCharge)) + + /** + * Sets [Builder.minimumCharge] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumCharge] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun minimumCharge(minimumCharge: JsonField) = apply { + this.minimumCharge = minimumCharge + } + + /** The base price charged per group */ + fun perUnitRate(perUnitRate: String) = perUnitRate(JsonField.of(perUnitRate)) + + /** + * Sets [Builder.perUnitRate] to an arbitrary JSON value. + * + * You should usually call [Builder.perUnitRate] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun perUnitRate(perUnitRate: JsonField) = apply { + this.perUnitRate = perUnitRate + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -2617,9 +2800,25 @@ private constructor( * Returns an immutable instance of [GroupedWithMinMaxThresholdsConfig]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .maximumCharge() + * .minimumCharge() + * .perUnitRate() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ fun build(): GroupedWithMinMaxThresholdsConfig = - GroupedWithMinMaxThresholdsConfig(additionalProperties.toImmutable()) + GroupedWithMinMaxThresholdsConfig( + checkRequired("groupingKey", groupingKey), + checkRequired("maximumCharge", maximumCharge), + checkRequired("minimumCharge", minimumCharge), + checkRequired("perUnitRate", perUnitRate), + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false @@ -2629,6 +2828,10 @@ private constructor( return@apply } + groupingKey() + maximumCharge() + minimumCharge() + perUnitRate() validated = true } @@ -2647,9 +2850,10 @@ private constructor( * Used for best match union deserialization. */ internal fun validity(): Int = - additionalProperties.count { (_, value) -> - !value.isNull() && !value.isMissing() - } + (if (groupingKey.asKnown() == null) 0 else 1) + + (if (maximumCharge.asKnown() == null) 0 else 1) + + (if (minimumCharge.asKnown() == null) 0 else 1) + + (if (perUnitRate.asKnown() == null) 0 else 1) override fun equals(other: Any?): Boolean { if (this === other) { @@ -2657,15 +2861,27 @@ private constructor( } return other is GroupedWithMinMaxThresholdsConfig && + groupingKey == other.groupingKey && + maximumCharge == other.maximumCharge && + minimumCharge == other.minimumCharge && + perUnitRate == other.perUnitRate && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + private val hashCode: Int by lazy { + Objects.hash( + groupingKey, + maximumCharge, + minimumCharge, + perUnitRate, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode override fun toString() = - "GroupedWithMinMaxThresholdsConfig{additionalProperties=$additionalProperties}" + "GroupedWithMinMaxThresholdsConfig{groupingKey=$groupingKey, maximumCharge=$maximumCharge, minimumCharge=$minimumCharge, perUnitRate=$perUnitRate, additionalProperties=$additionalProperties}" } /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceEvaluateMultipleParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceEvaluateMultipleParams.kt index 38520ec04..20de54d19 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceEvaluateMultipleParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceEvaluateMultipleParams.kt @@ -836,8 +836,7 @@ private constructor( fun groupingKeys(): List? = groupingKeys.getNullable("grouping_keys") /** - * An inline price definition to evaluate, allowing you to test price configurations before - * adding them to Orb. + * New floating price request body params. * * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -990,10 +989,7 @@ private constructor( } } - /** - * An inline price definition to evaluate, allowing you to test price configurations - * before adding them to Orb. - */ + /** New floating price request body params. */ fun price(price: Price?) = price(JsonField.ofNullable(price)) /** @@ -1008,24 +1004,18 @@ private constructor( /** Alias for calling [price] with `Price.ofUnit(unit)`. */ fun price(unit: NewFloatingUnitPrice) = price(Price.ofUnit(unit)) - /** Alias for calling [price] with `Price.ofPackage(package_)`. */ - fun price(package_: NewFloatingPackagePrice) = price(Price.ofPackage(package_)) - - /** Alias for calling [price] with `Price.ofMatrix(matrix)`. */ - fun price(matrix: NewFloatingMatrixPrice) = price(Price.ofMatrix(matrix)) - - /** - * Alias for calling [price] with `Price.ofMatrixWithAllocation(matrixWithAllocation)`. - */ - fun price(matrixWithAllocation: NewFloatingMatrixWithAllocationPrice) = - price(Price.ofMatrixWithAllocation(matrixWithAllocation)) - /** Alias for calling [price] with `Price.ofTiered(tiered)`. */ fun price(tiered: NewFloatingTieredPrice) = price(Price.ofTiered(tiered)) /** Alias for calling [price] with `Price.ofBulk(bulk)`. */ fun price(bulk: NewFloatingBulkPrice) = price(Price.ofBulk(bulk)) + /** Alias for calling [price] with `Price.ofPackage(package_)`. */ + fun price(package_: NewFloatingPackagePrice) = price(Price.ofPackage(package_)) + + /** Alias for calling [price] with `Price.ofMatrix(matrix)`. */ + fun price(matrix: NewFloatingMatrixPrice) = price(Price.ofMatrix(matrix)) + /** * Alias for calling [price] with `Price.ofThresholdTotalAmount(thresholdTotalAmount)`. */ @@ -1036,20 +1026,20 @@ private constructor( fun price(tieredPackage: NewFloatingTieredPackagePrice) = price(Price.ofTieredPackage(tieredPackage)) + /** Alias for calling [price] with `Price.ofTieredWithMinimum(tieredWithMinimum)`. */ + fun price(tieredWithMinimum: NewFloatingTieredWithMinimumPrice) = + price(Price.ofTieredWithMinimum(tieredWithMinimum)) + /** Alias for calling [price] with `Price.ofGroupedTiered(groupedTiered)`. */ fun price(groupedTiered: NewFloatingGroupedTieredPrice) = price(Price.ofGroupedTiered(groupedTiered)) /** * Alias for calling [price] with - * `Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)`. + * `Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)`. */ - fun price(maxGroupTieredPackage: NewFloatingMaxGroupTieredPackagePrice) = - price(Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)) - - /** Alias for calling [price] with `Price.ofTieredWithMinimum(tieredWithMinimum)`. */ - fun price(tieredWithMinimum: NewFloatingTieredWithMinimumPrice) = - price(Price.ofTieredWithMinimum(tieredWithMinimum)) + fun price(tieredPackageWithMinimum: NewFloatingTieredPackageWithMinimumPrice) = + price(Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)) /** * Alias for calling [price] with @@ -1058,17 +1048,16 @@ private constructor( fun price(packageWithAllocation: NewFloatingPackageWithAllocationPrice) = price(Price.ofPackageWithAllocation(packageWithAllocation)) - /** - * Alias for calling [price] with - * `Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)`. - */ - fun price(tieredPackageWithMinimum: NewFloatingTieredPackageWithMinimumPrice) = - price(Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)) - /** Alias for calling [price] with `Price.ofUnitWithPercent(unitWithPercent)`. */ fun price(unitWithPercent: NewFloatingUnitWithPercentPrice) = price(Price.ofUnitWithPercent(unitWithPercent)) + /** + * Alias for calling [price] with `Price.ofMatrixWithAllocation(matrixWithAllocation)`. + */ + fun price(matrixWithAllocation: NewFloatingMatrixWithAllocationPrice) = + price(Price.ofMatrixWithAllocation(matrixWithAllocation)) + /** * Alias for calling [price] with `Price.ofTieredWithProration(tieredWithProration)`. */ @@ -1083,6 +1072,10 @@ private constructor( fun price(groupedAllocation: NewFloatingGroupedAllocationPrice) = price(Price.ofGroupedAllocation(groupedAllocation)) + /** Alias for calling [price] with `Price.ofBulkWithProration(bulkWithProration)`. */ + fun price(bulkWithProration: NewFloatingBulkWithProrationPrice) = + price(Price.ofBulkWithProration(bulkWithProration)) + /** * Alias for calling [price] with * `Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)`. @@ -1097,6 +1090,13 @@ private constructor( fun price(groupedWithMeteredMinimum: NewFloatingGroupedWithMeteredMinimumPrice) = price(Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)) + /** + * Alias for calling [price] with + * `Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)`. + */ + fun price(groupedWithMinMaxThresholds: Price.GroupedWithMinMaxThresholds) = + price(Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)) + /** * Alias for calling [price] with * `Price.ofMatrixWithDisplayName(matrixWithDisplayName)`. @@ -1104,16 +1104,19 @@ private constructor( fun price(matrixWithDisplayName: NewFloatingMatrixWithDisplayNamePrice) = price(Price.ofMatrixWithDisplayName(matrixWithDisplayName)) - /** Alias for calling [price] with `Price.ofBulkWithProration(bulkWithProration)`. */ - fun price(bulkWithProration: NewFloatingBulkWithProrationPrice) = - price(Price.ofBulkWithProration(bulkWithProration)) - /** * Alias for calling [price] with `Price.ofGroupedTieredPackage(groupedTieredPackage)`. */ fun price(groupedTieredPackage: NewFloatingGroupedTieredPackagePrice) = price(Price.ofGroupedTieredPackage(groupedTieredPackage)) + /** + * Alias for calling [price] with + * `Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)`. + */ + fun price(maxGroupTieredPackage: NewFloatingMaxGroupTieredPackagePrice) = + price(Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)) + /** * Alias for calling [price] with * `Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)`. @@ -1137,13 +1140,6 @@ private constructor( fun price(cumulativeGroupedBulk: NewFloatingCumulativeGroupedBulkPrice) = price(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) - /** - * Alias for calling [price] with - * `Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)`. - */ - fun price(groupedWithMinMaxThresholds: Price.GroupedWithMinMaxThresholds) = - price(Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)) - /** Alias for calling [price] with `Price.ofMinimum(minimum)`. */ fun price(minimum: NewFloatingMinimumCompositePrice) = price(Price.ofMinimum(minimum)) @@ -1230,38 +1226,36 @@ private constructor( (price.asKnown()?.validity() ?: 0) + (if (priceId.asKnown() == null) 0 else 1) - /** - * An inline price definition to evaluate, allowing you to test price configurations before - * adding them to Orb. - */ + /** New floating price request body params. */ @JsonDeserialize(using = Price.Deserializer::class) @JsonSerialize(using = Price.Serializer::class) class Price private constructor( private val unit: NewFloatingUnitPrice? = null, - private val package_: NewFloatingPackagePrice? = null, - private val matrix: NewFloatingMatrixPrice? = null, - private val matrixWithAllocation: NewFloatingMatrixWithAllocationPrice? = null, private val tiered: NewFloatingTieredPrice? = null, private val bulk: NewFloatingBulkPrice? = null, + private val package_: NewFloatingPackagePrice? = null, + private val matrix: NewFloatingMatrixPrice? = null, private val thresholdTotalAmount: NewFloatingThresholdTotalAmountPrice? = null, private val tieredPackage: NewFloatingTieredPackagePrice? = null, - private val groupedTiered: NewFloatingGroupedTieredPrice? = null, - private val maxGroupTieredPackage: NewFloatingMaxGroupTieredPackagePrice? = null, private val tieredWithMinimum: NewFloatingTieredWithMinimumPrice? = null, - private val packageWithAllocation: NewFloatingPackageWithAllocationPrice? = null, + private val groupedTiered: NewFloatingGroupedTieredPrice? = null, private val tieredPackageWithMinimum: NewFloatingTieredPackageWithMinimumPrice? = null, + private val packageWithAllocation: NewFloatingPackageWithAllocationPrice? = null, private val unitWithPercent: NewFloatingUnitWithPercentPrice? = null, + private val matrixWithAllocation: NewFloatingMatrixWithAllocationPrice? = null, private val tieredWithProration: NewFloatingTieredWithProrationPrice? = null, private val unitWithProration: NewFloatingUnitWithProrationPrice? = null, private val groupedAllocation: NewFloatingGroupedAllocationPrice? = null, + private val bulkWithProration: NewFloatingBulkWithProrationPrice? = null, private val groupedWithProratedMinimum: NewFloatingGroupedWithProratedMinimumPrice? = null, private val groupedWithMeteredMinimum: NewFloatingGroupedWithMeteredMinimumPrice? = null, + private val groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds? = null, private val matrixWithDisplayName: NewFloatingMatrixWithDisplayNamePrice? = null, - private val bulkWithProration: NewFloatingBulkWithProrationPrice? = null, private val groupedTieredPackage: NewFloatingGroupedTieredPackagePrice? = null, + private val maxGroupTieredPackage: NewFloatingMaxGroupTieredPackagePrice? = null, private val scalableMatrixWithUnitPricing: NewFloatingScalableMatrixWithUnitPricingPrice? = null, @@ -1269,61 +1263,63 @@ private constructor( NewFloatingScalableMatrixWithTieredPricingPrice? = null, private val cumulativeGroupedBulk: NewFloatingCumulativeGroupedBulkPrice? = null, - private val groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds? = null, private val minimum: NewFloatingMinimumCompositePrice? = null, private val _json: JsonValue? = null, ) { fun unit(): NewFloatingUnitPrice? = unit - fun package_(): NewFloatingPackagePrice? = package_ - - fun matrix(): NewFloatingMatrixPrice? = matrix - - fun matrixWithAllocation(): NewFloatingMatrixWithAllocationPrice? = matrixWithAllocation - fun tiered(): NewFloatingTieredPrice? = tiered fun bulk(): NewFloatingBulkPrice? = bulk - fun thresholdTotalAmount(): NewFloatingThresholdTotalAmountPrice? = thresholdTotalAmount + fun package_(): NewFloatingPackagePrice? = package_ - fun tieredPackage(): NewFloatingTieredPackagePrice? = tieredPackage + fun matrix(): NewFloatingMatrixPrice? = matrix - fun groupedTiered(): NewFloatingGroupedTieredPrice? = groupedTiered + fun thresholdTotalAmount(): NewFloatingThresholdTotalAmountPrice? = thresholdTotalAmount - fun maxGroupTieredPackage(): NewFloatingMaxGroupTieredPackagePrice? = - maxGroupTieredPackage + fun tieredPackage(): NewFloatingTieredPackagePrice? = tieredPackage fun tieredWithMinimum(): NewFloatingTieredWithMinimumPrice? = tieredWithMinimum - fun packageWithAllocation(): NewFloatingPackageWithAllocationPrice? = - packageWithAllocation + fun groupedTiered(): NewFloatingGroupedTieredPrice? = groupedTiered fun tieredPackageWithMinimum(): NewFloatingTieredPackageWithMinimumPrice? = tieredPackageWithMinimum + fun packageWithAllocation(): NewFloatingPackageWithAllocationPrice? = + packageWithAllocation + fun unitWithPercent(): NewFloatingUnitWithPercentPrice? = unitWithPercent + fun matrixWithAllocation(): NewFloatingMatrixWithAllocationPrice? = matrixWithAllocation + fun tieredWithProration(): NewFloatingTieredWithProrationPrice? = tieredWithProration fun unitWithProration(): NewFloatingUnitWithProrationPrice? = unitWithProration fun groupedAllocation(): NewFloatingGroupedAllocationPrice? = groupedAllocation + fun bulkWithProration(): NewFloatingBulkWithProrationPrice? = bulkWithProration + fun groupedWithProratedMinimum(): NewFloatingGroupedWithProratedMinimumPrice? = groupedWithProratedMinimum fun groupedWithMeteredMinimum(): NewFloatingGroupedWithMeteredMinimumPrice? = groupedWithMeteredMinimum + fun groupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds? = + groupedWithMinMaxThresholds + fun matrixWithDisplayName(): NewFloatingMatrixWithDisplayNamePrice? = matrixWithDisplayName - fun bulkWithProration(): NewFloatingBulkWithProrationPrice? = bulkWithProration - fun groupedTieredPackage(): NewFloatingGroupedTieredPackagePrice? = groupedTieredPackage + fun maxGroupTieredPackage(): NewFloatingMaxGroupTieredPackagePrice? = + maxGroupTieredPackage + fun scalableMatrixWithUnitPricing(): NewFloatingScalableMatrixWithUnitPricingPrice? = scalableMatrixWithUnitPricing @@ -1333,55 +1329,54 @@ private constructor( fun cumulativeGroupedBulk(): NewFloatingCumulativeGroupedBulkPrice? = cumulativeGroupedBulk - fun groupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds? = - groupedWithMinMaxThresholds - fun minimum(): NewFloatingMinimumCompositePrice? = minimum fun isUnit(): Boolean = unit != null - fun isPackage(): Boolean = package_ != null - - fun isMatrix(): Boolean = matrix != null - - fun isMatrixWithAllocation(): Boolean = matrixWithAllocation != null - fun isTiered(): Boolean = tiered != null fun isBulk(): Boolean = bulk != null - fun isThresholdTotalAmount(): Boolean = thresholdTotalAmount != null + fun isPackage(): Boolean = package_ != null - fun isTieredPackage(): Boolean = tieredPackage != null + fun isMatrix(): Boolean = matrix != null - fun isGroupedTiered(): Boolean = groupedTiered != null + fun isThresholdTotalAmount(): Boolean = thresholdTotalAmount != null - fun isMaxGroupTieredPackage(): Boolean = maxGroupTieredPackage != null + fun isTieredPackage(): Boolean = tieredPackage != null fun isTieredWithMinimum(): Boolean = tieredWithMinimum != null - fun isPackageWithAllocation(): Boolean = packageWithAllocation != null + fun isGroupedTiered(): Boolean = groupedTiered != null fun isTieredPackageWithMinimum(): Boolean = tieredPackageWithMinimum != null + fun isPackageWithAllocation(): Boolean = packageWithAllocation != null + fun isUnitWithPercent(): Boolean = unitWithPercent != null + fun isMatrixWithAllocation(): Boolean = matrixWithAllocation != null + fun isTieredWithProration(): Boolean = tieredWithProration != null fun isUnitWithProration(): Boolean = unitWithProration != null fun isGroupedAllocation(): Boolean = groupedAllocation != null + fun isBulkWithProration(): Boolean = bulkWithProration != null + fun isGroupedWithProratedMinimum(): Boolean = groupedWithProratedMinimum != null fun isGroupedWithMeteredMinimum(): Boolean = groupedWithMeteredMinimum != null - fun isMatrixWithDisplayName(): Boolean = matrixWithDisplayName != null + fun isGroupedWithMinMaxThresholds(): Boolean = groupedWithMinMaxThresholds != null - fun isBulkWithProration(): Boolean = bulkWithProration != null + fun isMatrixWithDisplayName(): Boolean = matrixWithDisplayName != null fun isGroupedTieredPackage(): Boolean = groupedTieredPackage != null + fun isMaxGroupTieredPackage(): Boolean = maxGroupTieredPackage != null + fun isScalableMatrixWithUnitPricing(): Boolean = scalableMatrixWithUnitPricing != null fun isScalableMatrixWithTieredPricing(): Boolean = @@ -1389,47 +1384,42 @@ private constructor( fun isCumulativeGroupedBulk(): Boolean = cumulativeGroupedBulk != null - fun isGroupedWithMinMaxThresholds(): Boolean = groupedWithMinMaxThresholds != null - fun isMinimum(): Boolean = minimum != null fun asUnit(): NewFloatingUnitPrice = unit.getOrThrow("unit") - fun asPackage(): NewFloatingPackagePrice = package_.getOrThrow("package_") - - fun asMatrix(): NewFloatingMatrixPrice = matrix.getOrThrow("matrix") - - fun asMatrixWithAllocation(): NewFloatingMatrixWithAllocationPrice = - matrixWithAllocation.getOrThrow("matrixWithAllocation") - fun asTiered(): NewFloatingTieredPrice = tiered.getOrThrow("tiered") fun asBulk(): NewFloatingBulkPrice = bulk.getOrThrow("bulk") + fun asPackage(): NewFloatingPackagePrice = package_.getOrThrow("package_") + + fun asMatrix(): NewFloatingMatrixPrice = matrix.getOrThrow("matrix") + fun asThresholdTotalAmount(): NewFloatingThresholdTotalAmountPrice = thresholdTotalAmount.getOrThrow("thresholdTotalAmount") fun asTieredPackage(): NewFloatingTieredPackagePrice = tieredPackage.getOrThrow("tieredPackage") - fun asGroupedTiered(): NewFloatingGroupedTieredPrice = - groupedTiered.getOrThrow("groupedTiered") - - fun asMaxGroupTieredPackage(): NewFloatingMaxGroupTieredPackagePrice = - maxGroupTieredPackage.getOrThrow("maxGroupTieredPackage") - fun asTieredWithMinimum(): NewFloatingTieredWithMinimumPrice = tieredWithMinimum.getOrThrow("tieredWithMinimum") - fun asPackageWithAllocation(): NewFloatingPackageWithAllocationPrice = - packageWithAllocation.getOrThrow("packageWithAllocation") + fun asGroupedTiered(): NewFloatingGroupedTieredPrice = + groupedTiered.getOrThrow("groupedTiered") fun asTieredPackageWithMinimum(): NewFloatingTieredPackageWithMinimumPrice = tieredPackageWithMinimum.getOrThrow("tieredPackageWithMinimum") + fun asPackageWithAllocation(): NewFloatingPackageWithAllocationPrice = + packageWithAllocation.getOrThrow("packageWithAllocation") + fun asUnitWithPercent(): NewFloatingUnitWithPercentPrice = unitWithPercent.getOrThrow("unitWithPercent") + fun asMatrixWithAllocation(): NewFloatingMatrixWithAllocationPrice = + matrixWithAllocation.getOrThrow("matrixWithAllocation") + fun asTieredWithProration(): NewFloatingTieredWithProrationPrice = tieredWithProration.getOrThrow("tieredWithProration") @@ -1439,21 +1429,27 @@ private constructor( fun asGroupedAllocation(): NewFloatingGroupedAllocationPrice = groupedAllocation.getOrThrow("groupedAllocation") + fun asBulkWithProration(): NewFloatingBulkWithProrationPrice = + bulkWithProration.getOrThrow("bulkWithProration") + fun asGroupedWithProratedMinimum(): NewFloatingGroupedWithProratedMinimumPrice = groupedWithProratedMinimum.getOrThrow("groupedWithProratedMinimum") fun asGroupedWithMeteredMinimum(): NewFloatingGroupedWithMeteredMinimumPrice = groupedWithMeteredMinimum.getOrThrow("groupedWithMeteredMinimum") + fun asGroupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds = + groupedWithMinMaxThresholds.getOrThrow("groupedWithMinMaxThresholds") + fun asMatrixWithDisplayName(): NewFloatingMatrixWithDisplayNamePrice = matrixWithDisplayName.getOrThrow("matrixWithDisplayName") - fun asBulkWithProration(): NewFloatingBulkWithProrationPrice = - bulkWithProration.getOrThrow("bulkWithProration") - fun asGroupedTieredPackage(): NewFloatingGroupedTieredPackagePrice = groupedTieredPackage.getOrThrow("groupedTieredPackage") + fun asMaxGroupTieredPackage(): NewFloatingMaxGroupTieredPackagePrice = + maxGroupTieredPackage.getOrThrow("maxGroupTieredPackage") + fun asScalableMatrixWithUnitPricing(): NewFloatingScalableMatrixWithUnitPricingPrice = scalableMatrixWithUnitPricing.getOrThrow("scalableMatrixWithUnitPricing") @@ -1464,9 +1460,6 @@ private constructor( fun asCumulativeGroupedBulk(): NewFloatingCumulativeGroupedBulkPrice = cumulativeGroupedBulk.getOrThrow("cumulativeGroupedBulk") - fun asGroupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds = - groupedWithMinMaxThresholds.getOrThrow("groupedWithMinMaxThresholds") - fun asMinimum(): NewFloatingMinimumCompositePrice = minimum.getOrThrow("minimum") fun _json(): JsonValue? = _json @@ -1474,37 +1467,39 @@ private constructor( fun accept(visitor: Visitor): T = when { unit != null -> visitor.visitUnit(unit) - package_ != null -> visitor.visitPackage(package_) - matrix != null -> visitor.visitMatrix(matrix) - matrixWithAllocation != null -> - visitor.visitMatrixWithAllocation(matrixWithAllocation) tiered != null -> visitor.visitTiered(tiered) bulk != null -> visitor.visitBulk(bulk) + package_ != null -> visitor.visitPackage(package_) + matrix != null -> visitor.visitMatrix(matrix) thresholdTotalAmount != null -> visitor.visitThresholdTotalAmount(thresholdTotalAmount) tieredPackage != null -> visitor.visitTieredPackage(tieredPackage) - groupedTiered != null -> visitor.visitGroupedTiered(groupedTiered) - maxGroupTieredPackage != null -> - visitor.visitMaxGroupTieredPackage(maxGroupTieredPackage) tieredWithMinimum != null -> visitor.visitTieredWithMinimum(tieredWithMinimum) - packageWithAllocation != null -> - visitor.visitPackageWithAllocation(packageWithAllocation) + groupedTiered != null -> visitor.visitGroupedTiered(groupedTiered) tieredPackageWithMinimum != null -> visitor.visitTieredPackageWithMinimum(tieredPackageWithMinimum) + packageWithAllocation != null -> + visitor.visitPackageWithAllocation(packageWithAllocation) unitWithPercent != null -> visitor.visitUnitWithPercent(unitWithPercent) + matrixWithAllocation != null -> + visitor.visitMatrixWithAllocation(matrixWithAllocation) tieredWithProration != null -> visitor.visitTieredWithProration(tieredWithProration) unitWithProration != null -> visitor.visitUnitWithProration(unitWithProration) groupedAllocation != null -> visitor.visitGroupedAllocation(groupedAllocation) + bulkWithProration != null -> visitor.visitBulkWithProration(bulkWithProration) groupedWithProratedMinimum != null -> visitor.visitGroupedWithProratedMinimum(groupedWithProratedMinimum) groupedWithMeteredMinimum != null -> visitor.visitGroupedWithMeteredMinimum(groupedWithMeteredMinimum) + groupedWithMinMaxThresholds != null -> + visitor.visitGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds) matrixWithDisplayName != null -> visitor.visitMatrixWithDisplayName(matrixWithDisplayName) - bulkWithProration != null -> visitor.visitBulkWithProration(bulkWithProration) groupedTieredPackage != null -> visitor.visitGroupedTieredPackage(groupedTieredPackage) + maxGroupTieredPackage != null -> + visitor.visitMaxGroupTieredPackage(maxGroupTieredPackage) scalableMatrixWithUnitPricing != null -> visitor.visitScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing) scalableMatrixWithTieredPricing != null -> @@ -1513,8 +1508,6 @@ private constructor( ) cumulativeGroupedBulk != null -> visitor.visitCumulativeGroupedBulk(cumulativeGroupedBulk) - groupedWithMinMaxThresholds != null -> - visitor.visitGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds) minimum != null -> visitor.visitMinimum(minimum) else -> visitor.unknown(_json) } @@ -1532,20 +1525,6 @@ private constructor( unit.validate() } - override fun visitPackage(package_: NewFloatingPackagePrice) { - package_.validate() - } - - override fun visitMatrix(matrix: NewFloatingMatrixPrice) { - matrix.validate() - } - - override fun visitMatrixWithAllocation( - matrixWithAllocation: NewFloatingMatrixWithAllocationPrice - ) { - matrixWithAllocation.validate() - } - override fun visitTiered(tiered: NewFloatingTieredPrice) { tiered.validate() } @@ -1554,6 +1533,14 @@ private constructor( bulk.validate() } + override fun visitPackage(package_: NewFloatingPackagePrice) { + package_.validate() + } + + override fun visitMatrix(matrix: NewFloatingMatrixPrice) { + matrix.validate() + } + override fun visitThresholdTotalAmount( thresholdTotalAmount: NewFloatingThresholdTotalAmountPrice ) { @@ -1566,28 +1553,16 @@ private constructor( tieredPackage.validate() } - override fun visitGroupedTiered( - groupedTiered: NewFloatingGroupedTieredPrice - ) { - groupedTiered.validate() - } - - override fun visitMaxGroupTieredPackage( - maxGroupTieredPackage: NewFloatingMaxGroupTieredPackagePrice - ) { - maxGroupTieredPackage.validate() - } - override fun visitTieredWithMinimum( tieredWithMinimum: NewFloatingTieredWithMinimumPrice ) { tieredWithMinimum.validate() } - override fun visitPackageWithAllocation( - packageWithAllocation: NewFloatingPackageWithAllocationPrice + override fun visitGroupedTiered( + groupedTiered: NewFloatingGroupedTieredPrice ) { - packageWithAllocation.validate() + groupedTiered.validate() } override fun visitTieredPackageWithMinimum( @@ -1596,12 +1571,24 @@ private constructor( tieredPackageWithMinimum.validate() } + override fun visitPackageWithAllocation( + packageWithAllocation: NewFloatingPackageWithAllocationPrice + ) { + packageWithAllocation.validate() + } + override fun visitUnitWithPercent( unitWithPercent: NewFloatingUnitWithPercentPrice ) { unitWithPercent.validate() } + override fun visitMatrixWithAllocation( + matrixWithAllocation: NewFloatingMatrixWithAllocationPrice + ) { + matrixWithAllocation.validate() + } + override fun visitTieredWithProration( tieredWithProration: NewFloatingTieredWithProrationPrice ) { @@ -1620,6 +1607,12 @@ private constructor( groupedAllocation.validate() } + override fun visitBulkWithProration( + bulkWithProration: NewFloatingBulkWithProrationPrice + ) { + bulkWithProration.validate() + } + override fun visitGroupedWithProratedMinimum( groupedWithProratedMinimum: NewFloatingGroupedWithProratedMinimumPrice ) { @@ -1632,16 +1625,16 @@ private constructor( groupedWithMeteredMinimum.validate() } - override fun visitMatrixWithDisplayName( - matrixWithDisplayName: NewFloatingMatrixWithDisplayNamePrice + override fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds ) { - matrixWithDisplayName.validate() + groupedWithMinMaxThresholds.validate() } - override fun visitBulkWithProration( - bulkWithProration: NewFloatingBulkWithProrationPrice + override fun visitMatrixWithDisplayName( + matrixWithDisplayName: NewFloatingMatrixWithDisplayNamePrice ) { - bulkWithProration.validate() + matrixWithDisplayName.validate() } override fun visitGroupedTieredPackage( @@ -1650,6 +1643,12 @@ private constructor( groupedTieredPackage.validate() } + override fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: NewFloatingMaxGroupTieredPackagePrice + ) { + maxGroupTieredPackage.validate() + } + override fun visitScalableMatrixWithUnitPricing( scalableMatrixWithUnitPricing: NewFloatingScalableMatrixWithUnitPricingPrice @@ -1670,12 +1669,6 @@ private constructor( cumulativeGroupedBulk.validate() } - override fun visitGroupedWithMinMaxThresholds( - groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds - ) { - groupedWithMinMaxThresholds.validate() - } - override fun visitMinimum(minimum: NewFloatingMinimumCompositePrice) { minimum.validate() } @@ -1703,19 +1696,15 @@ private constructor( object : Visitor { override fun visitUnit(unit: NewFloatingUnitPrice) = unit.validity() + override fun visitTiered(tiered: NewFloatingTieredPrice) = tiered.validity() + + override fun visitBulk(bulk: NewFloatingBulkPrice) = bulk.validity() + override fun visitPackage(package_: NewFloatingPackagePrice) = package_.validity() override fun visitMatrix(matrix: NewFloatingMatrixPrice) = matrix.validity() - override fun visitMatrixWithAllocation( - matrixWithAllocation: NewFloatingMatrixWithAllocationPrice - ) = matrixWithAllocation.validity() - - override fun visitTiered(tiered: NewFloatingTieredPrice) = tiered.validity() - - override fun visitBulk(bulk: NewFloatingBulkPrice) = bulk.validity() - override fun visitThresholdTotalAmount( thresholdTotalAmount: NewFloatingThresholdTotalAmountPrice ) = thresholdTotalAmount.validity() @@ -1724,30 +1713,30 @@ private constructor( tieredPackage: NewFloatingTieredPackagePrice ) = tieredPackage.validity() - override fun visitGroupedTiered( - groupedTiered: NewFloatingGroupedTieredPrice - ) = groupedTiered.validity() - - override fun visitMaxGroupTieredPackage( - maxGroupTieredPackage: NewFloatingMaxGroupTieredPackagePrice - ) = maxGroupTieredPackage.validity() - override fun visitTieredWithMinimum( tieredWithMinimum: NewFloatingTieredWithMinimumPrice ) = tieredWithMinimum.validity() - override fun visitPackageWithAllocation( - packageWithAllocation: NewFloatingPackageWithAllocationPrice - ) = packageWithAllocation.validity() + override fun visitGroupedTiered( + groupedTiered: NewFloatingGroupedTieredPrice + ) = groupedTiered.validity() override fun visitTieredPackageWithMinimum( tieredPackageWithMinimum: NewFloatingTieredPackageWithMinimumPrice ) = tieredPackageWithMinimum.validity() + override fun visitPackageWithAllocation( + packageWithAllocation: NewFloatingPackageWithAllocationPrice + ) = packageWithAllocation.validity() + override fun visitUnitWithPercent( unitWithPercent: NewFloatingUnitWithPercentPrice ) = unitWithPercent.validity() + override fun visitMatrixWithAllocation( + matrixWithAllocation: NewFloatingMatrixWithAllocationPrice + ) = matrixWithAllocation.validity() + override fun visitTieredWithProration( tieredWithProration: NewFloatingTieredWithProrationPrice ) = tieredWithProration.validity() @@ -1760,6 +1749,10 @@ private constructor( groupedAllocation: NewFloatingGroupedAllocationPrice ) = groupedAllocation.validity() + override fun visitBulkWithProration( + bulkWithProration: NewFloatingBulkWithProrationPrice + ) = bulkWithProration.validity() + override fun visitGroupedWithProratedMinimum( groupedWithProratedMinimum: NewFloatingGroupedWithProratedMinimumPrice ) = groupedWithProratedMinimum.validity() @@ -1768,18 +1761,22 @@ private constructor( groupedWithMeteredMinimum: NewFloatingGroupedWithMeteredMinimumPrice ) = groupedWithMeteredMinimum.validity() + override fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) = groupedWithMinMaxThresholds.validity() + override fun visitMatrixWithDisplayName( matrixWithDisplayName: NewFloatingMatrixWithDisplayNamePrice ) = matrixWithDisplayName.validity() - override fun visitBulkWithProration( - bulkWithProration: NewFloatingBulkWithProrationPrice - ) = bulkWithProration.validity() - override fun visitGroupedTieredPackage( groupedTieredPackage: NewFloatingGroupedTieredPackagePrice ) = groupedTieredPackage.validity() + override fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: NewFloatingMaxGroupTieredPackagePrice + ) = maxGroupTieredPackage.validity() + override fun visitScalableMatrixWithUnitPricing( scalableMatrixWithUnitPricing: NewFloatingScalableMatrixWithUnitPricingPrice @@ -1794,10 +1791,6 @@ private constructor( cumulativeGroupedBulk: NewFloatingCumulativeGroupedBulkPrice ) = cumulativeGroupedBulk.validity() - override fun visitGroupedWithMinMaxThresholds( - groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds - ) = groupedWithMinMaxThresholds.validity() - override fun visitMinimum(minimum: NewFloatingMinimumCompositePrice) = minimum.validity() @@ -1812,106 +1805,106 @@ private constructor( return other is Price && unit == other.unit && - package_ == other.package_ && - matrix == other.matrix && - matrixWithAllocation == other.matrixWithAllocation && tiered == other.tiered && bulk == other.bulk && + package_ == other.package_ && + matrix == other.matrix && thresholdTotalAmount == other.thresholdTotalAmount && tieredPackage == other.tieredPackage && - groupedTiered == other.groupedTiered && - maxGroupTieredPackage == other.maxGroupTieredPackage && tieredWithMinimum == other.tieredWithMinimum && - packageWithAllocation == other.packageWithAllocation && + groupedTiered == other.groupedTiered && tieredPackageWithMinimum == other.tieredPackageWithMinimum && + packageWithAllocation == other.packageWithAllocation && unitWithPercent == other.unitWithPercent && + matrixWithAllocation == other.matrixWithAllocation && tieredWithProration == other.tieredWithProration && unitWithProration == other.unitWithProration && groupedAllocation == other.groupedAllocation && + bulkWithProration == other.bulkWithProration && groupedWithProratedMinimum == other.groupedWithProratedMinimum && groupedWithMeteredMinimum == other.groupedWithMeteredMinimum && + groupedWithMinMaxThresholds == other.groupedWithMinMaxThresholds && matrixWithDisplayName == other.matrixWithDisplayName && - bulkWithProration == other.bulkWithProration && groupedTieredPackage == other.groupedTieredPackage && + maxGroupTieredPackage == other.maxGroupTieredPackage && scalableMatrixWithUnitPricing == other.scalableMatrixWithUnitPricing && scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && cumulativeGroupedBulk == other.cumulativeGroupedBulk && - groupedWithMinMaxThresholds == other.groupedWithMinMaxThresholds && minimum == other.minimum } override fun hashCode(): Int = Objects.hash( unit, - package_, - matrix, - matrixWithAllocation, tiered, bulk, + package_, + matrix, thresholdTotalAmount, tieredPackage, - groupedTiered, - maxGroupTieredPackage, tieredWithMinimum, - packageWithAllocation, + groupedTiered, tieredPackageWithMinimum, + packageWithAllocation, unitWithPercent, + matrixWithAllocation, tieredWithProration, unitWithProration, groupedAllocation, + bulkWithProration, groupedWithProratedMinimum, groupedWithMeteredMinimum, + groupedWithMinMaxThresholds, matrixWithDisplayName, - bulkWithProration, groupedTieredPackage, + maxGroupTieredPackage, scalableMatrixWithUnitPricing, scalableMatrixWithTieredPricing, cumulativeGroupedBulk, - groupedWithMinMaxThresholds, minimum, ) override fun toString(): String = when { unit != null -> "Price{unit=$unit}" - package_ != null -> "Price{package_=$package_}" - matrix != null -> "Price{matrix=$matrix}" - matrixWithAllocation != null -> - "Price{matrixWithAllocation=$matrixWithAllocation}" tiered != null -> "Price{tiered=$tiered}" bulk != null -> "Price{bulk=$bulk}" + package_ != null -> "Price{package_=$package_}" + matrix != null -> "Price{matrix=$matrix}" thresholdTotalAmount != null -> "Price{thresholdTotalAmount=$thresholdTotalAmount}" tieredPackage != null -> "Price{tieredPackage=$tieredPackage}" - groupedTiered != null -> "Price{groupedTiered=$groupedTiered}" - maxGroupTieredPackage != null -> - "Price{maxGroupTieredPackage=$maxGroupTieredPackage}" tieredWithMinimum != null -> "Price{tieredWithMinimum=$tieredWithMinimum}" - packageWithAllocation != null -> - "Price{packageWithAllocation=$packageWithAllocation}" + groupedTiered != null -> "Price{groupedTiered=$groupedTiered}" tieredPackageWithMinimum != null -> "Price{tieredPackageWithMinimum=$tieredPackageWithMinimum}" + packageWithAllocation != null -> + "Price{packageWithAllocation=$packageWithAllocation}" unitWithPercent != null -> "Price{unitWithPercent=$unitWithPercent}" + matrixWithAllocation != null -> + "Price{matrixWithAllocation=$matrixWithAllocation}" tieredWithProration != null -> "Price{tieredWithProration=$tieredWithProration}" unitWithProration != null -> "Price{unitWithProration=$unitWithProration}" groupedAllocation != null -> "Price{groupedAllocation=$groupedAllocation}" + bulkWithProration != null -> "Price{bulkWithProration=$bulkWithProration}" groupedWithProratedMinimum != null -> "Price{groupedWithProratedMinimum=$groupedWithProratedMinimum}" groupedWithMeteredMinimum != null -> "Price{groupedWithMeteredMinimum=$groupedWithMeteredMinimum}" + groupedWithMinMaxThresholds != null -> + "Price{groupedWithMinMaxThresholds=$groupedWithMinMaxThresholds}" matrixWithDisplayName != null -> "Price{matrixWithDisplayName=$matrixWithDisplayName}" - bulkWithProration != null -> "Price{bulkWithProration=$bulkWithProration}" groupedTieredPackage != null -> "Price{groupedTieredPackage=$groupedTieredPackage}" + maxGroupTieredPackage != null -> + "Price{maxGroupTieredPackage=$maxGroupTieredPackage}" scalableMatrixWithUnitPricing != null -> "Price{scalableMatrixWithUnitPricing=$scalableMatrixWithUnitPricing}" scalableMatrixWithTieredPricing != null -> "Price{scalableMatrixWithTieredPricing=$scalableMatrixWithTieredPricing}" cumulativeGroupedBulk != null -> "Price{cumulativeGroupedBulk=$cumulativeGroupedBulk}" - groupedWithMinMaxThresholds != null -> - "Price{groupedWithMinMaxThresholds=$groupedWithMinMaxThresholds}" minimum != null -> "Price{minimum=$minimum}" _json != null -> "Price{_unknown=$_json}" else -> throw IllegalStateException("Invalid Price") @@ -1921,18 +1914,14 @@ private constructor( fun ofUnit(unit: NewFloatingUnitPrice) = Price(unit = unit) - fun ofPackage(package_: NewFloatingPackagePrice) = Price(package_ = package_) - - fun ofMatrix(matrix: NewFloatingMatrixPrice) = Price(matrix = matrix) - - fun ofMatrixWithAllocation( - matrixWithAllocation: NewFloatingMatrixWithAllocationPrice - ) = Price(matrixWithAllocation = matrixWithAllocation) - fun ofTiered(tiered: NewFloatingTieredPrice) = Price(tiered = tiered) fun ofBulk(bulk: NewFloatingBulkPrice) = Price(bulk = bulk) + fun ofPackage(package_: NewFloatingPackagePrice) = Price(package_ = package_) + + fun ofMatrix(matrix: NewFloatingMatrixPrice) = Price(matrix = matrix) + fun ofThresholdTotalAmount( thresholdTotalAmount: NewFloatingThresholdTotalAmountPrice ) = Price(thresholdTotalAmount = thresholdTotalAmount) @@ -1940,27 +1929,27 @@ private constructor( fun ofTieredPackage(tieredPackage: NewFloatingTieredPackagePrice) = Price(tieredPackage = tieredPackage) - fun ofGroupedTiered(groupedTiered: NewFloatingGroupedTieredPrice) = - Price(groupedTiered = groupedTiered) - - fun ofMaxGroupTieredPackage( - maxGroupTieredPackage: NewFloatingMaxGroupTieredPackagePrice - ) = Price(maxGroupTieredPackage = maxGroupTieredPackage) - fun ofTieredWithMinimum(tieredWithMinimum: NewFloatingTieredWithMinimumPrice) = Price(tieredWithMinimum = tieredWithMinimum) - fun ofPackageWithAllocation( - packageWithAllocation: NewFloatingPackageWithAllocationPrice - ) = Price(packageWithAllocation = packageWithAllocation) + fun ofGroupedTiered(groupedTiered: NewFloatingGroupedTieredPrice) = + Price(groupedTiered = groupedTiered) fun ofTieredPackageWithMinimum( tieredPackageWithMinimum: NewFloatingTieredPackageWithMinimumPrice ) = Price(tieredPackageWithMinimum = tieredPackageWithMinimum) + fun ofPackageWithAllocation( + packageWithAllocation: NewFloatingPackageWithAllocationPrice + ) = Price(packageWithAllocation = packageWithAllocation) + fun ofUnitWithPercent(unitWithPercent: NewFloatingUnitWithPercentPrice) = Price(unitWithPercent = unitWithPercent) + fun ofMatrixWithAllocation( + matrixWithAllocation: NewFloatingMatrixWithAllocationPrice + ) = Price(matrixWithAllocation = matrixWithAllocation) + fun ofTieredWithProration( tieredWithProration: NewFloatingTieredWithProrationPrice ) = Price(tieredWithProration = tieredWithProration) @@ -1971,6 +1960,9 @@ private constructor( fun ofGroupedAllocation(groupedAllocation: NewFloatingGroupedAllocationPrice) = Price(groupedAllocation = groupedAllocation) + fun ofBulkWithProration(bulkWithProration: NewFloatingBulkWithProrationPrice) = + Price(bulkWithProration = bulkWithProration) + fun ofGroupedWithProratedMinimum( groupedWithProratedMinimum: NewFloatingGroupedWithProratedMinimumPrice ) = Price(groupedWithProratedMinimum = groupedWithProratedMinimum) @@ -1979,17 +1971,22 @@ private constructor( groupedWithMeteredMinimum: NewFloatingGroupedWithMeteredMinimumPrice ) = Price(groupedWithMeteredMinimum = groupedWithMeteredMinimum) + fun ofGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) = Price(groupedWithMinMaxThresholds = groupedWithMinMaxThresholds) + fun ofMatrixWithDisplayName( matrixWithDisplayName: NewFloatingMatrixWithDisplayNamePrice ) = Price(matrixWithDisplayName = matrixWithDisplayName) - fun ofBulkWithProration(bulkWithProration: NewFloatingBulkWithProrationPrice) = - Price(bulkWithProration = bulkWithProration) - fun ofGroupedTieredPackage( groupedTieredPackage: NewFloatingGroupedTieredPackagePrice ) = Price(groupedTieredPackage = groupedTieredPackage) + fun ofMaxGroupTieredPackage( + maxGroupTieredPackage: NewFloatingMaxGroupTieredPackagePrice + ) = Price(maxGroupTieredPackage = maxGroupTieredPackage) + fun ofScalableMatrixWithUnitPricing( scalableMatrixWithUnitPricing: NewFloatingScalableMatrixWithUnitPricingPrice ) = Price(scalableMatrixWithUnitPricing = scalableMatrixWithUnitPricing) @@ -2002,10 +1999,6 @@ private constructor( cumulativeGroupedBulk: NewFloatingCumulativeGroupedBulkPrice ) = Price(cumulativeGroupedBulk = cumulativeGroupedBulk) - fun ofGroupedWithMinMaxThresholds( - groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds - ) = Price(groupedWithMinMaxThresholds = groupedWithMinMaxThresholds) - fun ofMinimum(minimum: NewFloatingMinimumCompositePrice) = Price(minimum = minimum) } @@ -2016,42 +2009,38 @@ private constructor( fun visitUnit(unit: NewFloatingUnitPrice): T - fun visitPackage(package_: NewFloatingPackagePrice): T - - fun visitMatrix(matrix: NewFloatingMatrixPrice): T - - fun visitMatrixWithAllocation( - matrixWithAllocation: NewFloatingMatrixWithAllocationPrice - ): T - fun visitTiered(tiered: NewFloatingTieredPrice): T fun visitBulk(bulk: NewFloatingBulkPrice): T + fun visitPackage(package_: NewFloatingPackagePrice): T + + fun visitMatrix(matrix: NewFloatingMatrixPrice): T + fun visitThresholdTotalAmount( thresholdTotalAmount: NewFloatingThresholdTotalAmountPrice ): T fun visitTieredPackage(tieredPackage: NewFloatingTieredPackagePrice): T + fun visitTieredWithMinimum(tieredWithMinimum: NewFloatingTieredWithMinimumPrice): T + fun visitGroupedTiered(groupedTiered: NewFloatingGroupedTieredPrice): T - fun visitMaxGroupTieredPackage( - maxGroupTieredPackage: NewFloatingMaxGroupTieredPackagePrice + fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: NewFloatingTieredPackageWithMinimumPrice ): T - fun visitTieredWithMinimum(tieredWithMinimum: NewFloatingTieredWithMinimumPrice): T - fun visitPackageWithAllocation( packageWithAllocation: NewFloatingPackageWithAllocationPrice ): T - fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewFloatingTieredPackageWithMinimumPrice - ): T - fun visitUnitWithPercent(unitWithPercent: NewFloatingUnitWithPercentPrice): T + fun visitMatrixWithAllocation( + matrixWithAllocation: NewFloatingMatrixWithAllocationPrice + ): T + fun visitTieredWithProration( tieredWithProration: NewFloatingTieredWithProrationPrice ): T @@ -2060,6 +2049,8 @@ private constructor( fun visitGroupedAllocation(groupedAllocation: NewFloatingGroupedAllocationPrice): T + fun visitBulkWithProration(bulkWithProration: NewFloatingBulkWithProrationPrice): T + fun visitGroupedWithProratedMinimum( groupedWithProratedMinimum: NewFloatingGroupedWithProratedMinimumPrice ): T @@ -2068,16 +2059,22 @@ private constructor( groupedWithMeteredMinimum: NewFloatingGroupedWithMeteredMinimumPrice ): T + fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ): T + fun visitMatrixWithDisplayName( matrixWithDisplayName: NewFloatingMatrixWithDisplayNamePrice ): T - fun visitBulkWithProration(bulkWithProration: NewFloatingBulkWithProrationPrice): T - fun visitGroupedTieredPackage( groupedTieredPackage: NewFloatingGroupedTieredPackagePrice ): T + fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: NewFloatingMaxGroupTieredPackagePrice + ): T + fun visitScalableMatrixWithUnitPricing( scalableMatrixWithUnitPricing: NewFloatingScalableMatrixWithUnitPricingPrice ): T @@ -2090,10 +2087,6 @@ private constructor( cumulativeGroupedBulk: NewFloatingCumulativeGroupedBulkPrice ): T - fun visitGroupedWithMinMaxThresholds( - groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds - ): T - fun visitMinimum(minimum: NewFloatingMinimumCompositePrice): T /** @@ -2122,22 +2115,6 @@ private constructor( return tryDeserialize(node, jacksonTypeRef()) ?.let { Price(unit = it, _json = json) } ?: Price(_json = json) } - "package" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(package_ = it, _json = json) } ?: Price(_json = json) - } - "matrix" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(matrix = it, _json = json) } ?: Price(_json = json) - } - "matrix_with_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(matrixWithAllocation = it, _json = json) } - ?: Price(_json = json) - } "tiered" -> { return tryDeserialize(node, jacksonTypeRef()) ?.let { Price(tiered = it, _json = json) } ?: Price(_json = json) @@ -2146,6 +2123,14 @@ private constructor( return tryDeserialize(node, jacksonTypeRef()) ?.let { Price(bulk = it, _json = json) } ?: Price(_json = json) } + "package" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(package_ = it, _json = json) } ?: Price(_json = json) + } + "matrix" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(matrix = it, _json = json) } ?: Price(_json = json) + } "threshold_total_amount" -> { return tryDeserialize( node, @@ -2162,28 +2147,28 @@ private constructor( ?.let { Price(tieredPackage = it, _json = json) } ?: Price(_json = json) } - "grouped_tiered" -> { + "tiered_with_minimum" -> { return tryDeserialize( node, - jacksonTypeRef(), + jacksonTypeRef(), ) - ?.let { Price(groupedTiered = it, _json = json) } + ?.let { Price(tieredWithMinimum = it, _json = json) } ?: Price(_json = json) } - "max_group_tiered_package" -> { + "grouped_tiered" -> { return tryDeserialize( node, - jacksonTypeRef(), + jacksonTypeRef(), ) - ?.let { Price(maxGroupTieredPackage = it, _json = json) } + ?.let { Price(groupedTiered = it, _json = json) } ?: Price(_json = json) } - "tiered_with_minimum" -> { + "tiered_package_with_minimum" -> { return tryDeserialize( node, - jacksonTypeRef(), + jacksonTypeRef(), ) - ?.let { Price(tieredWithMinimum = it, _json = json) } + ?.let { Price(tieredPackageWithMinimum = it, _json = json) } ?: Price(_json = json) } "package_with_allocation" -> { @@ -2194,20 +2179,20 @@ private constructor( ?.let { Price(packageWithAllocation = it, _json = json) } ?: Price(_json = json) } - "tiered_package_with_minimum" -> { + "unit_with_percent" -> { return tryDeserialize( node, - jacksonTypeRef(), + jacksonTypeRef(), ) - ?.let { Price(tieredPackageWithMinimum = it, _json = json) } + ?.let { Price(unitWithPercent = it, _json = json) } ?: Price(_json = json) } - "unit_with_percent" -> { + "matrix_with_allocation" -> { return tryDeserialize( node, - jacksonTypeRef(), + jacksonTypeRef(), ) - ?.let { Price(unitWithPercent = it, _json = json) } + ?.let { Price(matrixWithAllocation = it, _json = json) } ?: Price(_json = json) } "tiered_with_proration" -> { @@ -2234,6 +2219,14 @@ private constructor( ?.let { Price(groupedAllocation = it, _json = json) } ?: Price(_json = json) } + "bulk_with_proration" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(bulkWithProration = it, _json = json) } + ?: Price(_json = json) + } "grouped_with_prorated_minimum" -> { return tryDeserialize( node, @@ -2250,20 +2243,20 @@ private constructor( ?.let { Price(groupedWithMeteredMinimum = it, _json = json) } ?: Price(_json = json) } - "matrix_with_display_name" -> { + "grouped_with_min_max_thresholds" -> { return tryDeserialize( node, - jacksonTypeRef(), + jacksonTypeRef(), ) - ?.let { Price(matrixWithDisplayName = it, _json = json) } + ?.let { Price(groupedWithMinMaxThresholds = it, _json = json) } ?: Price(_json = json) } - "bulk_with_proration" -> { + "matrix_with_display_name" -> { return tryDeserialize( node, - jacksonTypeRef(), + jacksonTypeRef(), ) - ?.let { Price(bulkWithProration = it, _json = json) } + ?.let { Price(matrixWithDisplayName = it, _json = json) } ?: Price(_json = json) } "grouped_tiered_package" -> { @@ -2274,6 +2267,14 @@ private constructor( ?.let { Price(groupedTieredPackage = it, _json = json) } ?: Price(_json = json) } + "max_group_tiered_package" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(maxGroupTieredPackage = it, _json = json) } + ?: Price(_json = json) + } "scalable_matrix_with_unit_pricing" -> { return tryDeserialize( node, @@ -2300,14 +2301,6 @@ private constructor( ?.let { Price(cumulativeGroupedBulk = it, _json = json) } ?: Price(_json = json) } - "grouped_with_min_max_thresholds" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedWithMinMaxThresholds = it, _json = json) } - ?: Price(_json = json) - } "minimum" -> { return tryDeserialize( node, @@ -2330,50 +2323,50 @@ private constructor( ) { when { value.unit != null -> generator.writeObject(value.unit) - value.package_ != null -> generator.writeObject(value.package_) - value.matrix != null -> generator.writeObject(value.matrix) - value.matrixWithAllocation != null -> - generator.writeObject(value.matrixWithAllocation) value.tiered != null -> generator.writeObject(value.tiered) value.bulk != null -> generator.writeObject(value.bulk) + value.package_ != null -> generator.writeObject(value.package_) + value.matrix != null -> generator.writeObject(value.matrix) value.thresholdTotalAmount != null -> generator.writeObject(value.thresholdTotalAmount) value.tieredPackage != null -> generator.writeObject(value.tieredPackage) - value.groupedTiered != null -> generator.writeObject(value.groupedTiered) - value.maxGroupTieredPackage != null -> - generator.writeObject(value.maxGroupTieredPackage) value.tieredWithMinimum != null -> generator.writeObject(value.tieredWithMinimum) - value.packageWithAllocation != null -> - generator.writeObject(value.packageWithAllocation) + value.groupedTiered != null -> generator.writeObject(value.groupedTiered) value.tieredPackageWithMinimum != null -> generator.writeObject(value.tieredPackageWithMinimum) + value.packageWithAllocation != null -> + generator.writeObject(value.packageWithAllocation) value.unitWithPercent != null -> generator.writeObject(value.unitWithPercent) + value.matrixWithAllocation != null -> + generator.writeObject(value.matrixWithAllocation) value.tieredWithProration != null -> generator.writeObject(value.tieredWithProration) value.unitWithProration != null -> generator.writeObject(value.unitWithProration) value.groupedAllocation != null -> generator.writeObject(value.groupedAllocation) + value.bulkWithProration != null -> + generator.writeObject(value.bulkWithProration) value.groupedWithProratedMinimum != null -> generator.writeObject(value.groupedWithProratedMinimum) value.groupedWithMeteredMinimum != null -> generator.writeObject(value.groupedWithMeteredMinimum) + value.groupedWithMinMaxThresholds != null -> + generator.writeObject(value.groupedWithMinMaxThresholds) value.matrixWithDisplayName != null -> generator.writeObject(value.matrixWithDisplayName) - value.bulkWithProration != null -> - generator.writeObject(value.bulkWithProration) value.groupedTieredPackage != null -> generator.writeObject(value.groupedTieredPackage) + value.maxGroupTieredPackage != null -> + generator.writeObject(value.maxGroupTieredPackage) value.scalableMatrixWithUnitPricing != null -> generator.writeObject(value.scalableMatrixWithUnitPricing) value.scalableMatrixWithTieredPricing != null -> generator.writeObject(value.scalableMatrixWithTieredPricing) value.cumulativeGroupedBulk != null -> generator.writeObject(value.cumulativeGroupedBulk) - value.groupedWithMinMaxThresholds != null -> - generator.writeObject(value.groupedWithMinMaxThresholds) value.minimum != null -> generator.writeObject(value.minimum) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid Price") @@ -2503,6 +2496,8 @@ private constructor( fun currency(): String = currency.getRequired("currency") /** + * Configuration for grouped_with_min_max_thresholds pricing + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected * value). @@ -2522,6 +2517,8 @@ private constructor( fun itemId(): String = itemId.getRequired("item_id") /** + * The pricing model type + * * Expected to always return the following: * ```kotlin * JsonValue.from("grouped_with_min_max_thresholds") @@ -2914,6 +2911,7 @@ private constructor( */ fun currency(currency: JsonField) = apply { this.currency = currency } + /** Configuration for grouped_with_min_max_thresholds pricing */ fun groupedWithMinMaxThresholdsConfig( groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig ) = @@ -3534,16 +3532,117 @@ private constructor( override fun toString() = value.toString() } + /** Configuration for grouped_with_min_max_thresholds pricing */ class GroupedWithMinMaxThresholdsConfig - @JsonCreator private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map + private val groupingKey: JsonField, + private val maximumCharge: JsonField, + private val minimumCharge: JsonField, + private val perUnitRate: JsonField, + private val additionalProperties: MutableMap, ) { + @JsonCreator + private constructor( + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("maximum_charge") + @ExcludeMissing + maximumCharge: JsonField = JsonMissing.of(), + @JsonProperty("minimum_charge") + @ExcludeMissing + minimumCharge: JsonField = JsonMissing.of(), + @JsonProperty("per_unit_rate") + @ExcludeMissing + perUnitRate: JsonField = JsonMissing.of(), + ) : this(groupingKey, maximumCharge, minimumCharge, perUnitRate, mutableMapOf()) + + /** + * The event property used to group before applying thresholds + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The maximum amount to charge each group + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun maximumCharge(): String = maximumCharge.getRequired("maximum_charge") + + /** + * The minimum amount to charge each group, regardless of usage + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun minimumCharge(): String = minimumCharge.getRequired("minimum_charge") + + /** + * The base price charged per group + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun perUnitRate(): String = perUnitRate.getRequired("per_unit_rate") + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [maximumCharge]. + * + * Unlike [maximumCharge], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("maximum_charge") + @ExcludeMissing + fun _maximumCharge(): JsonField = maximumCharge + + /** + * Returns the raw JSON value of [minimumCharge]. + * + * Unlike [minimumCharge], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("minimum_charge") + @ExcludeMissing + fun _minimumCharge(): JsonField = minimumCharge + + /** + * Returns the raw JSON value of [perUnitRate]. + * + * Unlike [perUnitRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("per_unit_rate") + @ExcludeMissing + fun _perUnitRate(): JsonField = perUnitRate + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) fun toBuilder() = Builder().from(this) @@ -3552,6 +3651,14 @@ private constructor( /** * Returns a mutable builder for constructing an instance of * [GroupedWithMinMaxThresholdsConfig]. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .maximumCharge() + * .minimumCharge() + * .perUnitRate() + * ``` */ fun builder() = Builder() } @@ -3559,17 +3666,85 @@ private constructor( /** A builder for [GroupedWithMinMaxThresholdsConfig]. */ class Builder internal constructor() { + private var groupingKey: JsonField? = null + private var maximumCharge: JsonField? = null + private var minimumCharge: JsonField? = null + private var perUnitRate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from( groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig ) = apply { + groupingKey = groupedWithMinMaxThresholdsConfig.groupingKey + maximumCharge = groupedWithMinMaxThresholdsConfig.maximumCharge + minimumCharge = groupedWithMinMaxThresholdsConfig.minimumCharge + perUnitRate = groupedWithMinMaxThresholdsConfig.perUnitRate additionalProperties = groupedWithMinMaxThresholdsConfig.additionalProperties .toMutableMap() } + /** The event property used to group before applying thresholds */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The maximum amount to charge each group */ + fun maximumCharge(maximumCharge: String) = + maximumCharge(JsonField.of(maximumCharge)) + + /** + * Sets [Builder.maximumCharge] to an arbitrary JSON value. + * + * You should usually call [Builder.maximumCharge] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun maximumCharge(maximumCharge: JsonField) = apply { + this.maximumCharge = maximumCharge + } + + /** The minimum amount to charge each group, regardless of usage */ + fun minimumCharge(minimumCharge: String) = + minimumCharge(JsonField.of(minimumCharge)) + + /** + * Sets [Builder.minimumCharge] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumCharge] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun minimumCharge(minimumCharge: JsonField) = apply { + this.minimumCharge = minimumCharge + } + + /** The base price charged per group */ + fun perUnitRate(perUnitRate: String) = + perUnitRate(JsonField.of(perUnitRate)) + + /** + * Sets [Builder.perUnitRate] to an arbitrary JSON value. + * + * You should usually call [Builder.perUnitRate] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun perUnitRate(perUnitRate: JsonField) = apply { + this.perUnitRate = perUnitRate + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -3596,9 +3771,25 @@ private constructor( * Returns an immutable instance of [GroupedWithMinMaxThresholdsConfig]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .maximumCharge() + * .minimumCharge() + * .perUnitRate() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ fun build(): GroupedWithMinMaxThresholdsConfig = - GroupedWithMinMaxThresholdsConfig(additionalProperties.toImmutable()) + GroupedWithMinMaxThresholdsConfig( + checkRequired("groupingKey", groupingKey), + checkRequired("maximumCharge", maximumCharge), + checkRequired("minimumCharge", minimumCharge), + checkRequired("perUnitRate", perUnitRate), + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false @@ -3608,6 +3799,10 @@ private constructor( return@apply } + groupingKey() + maximumCharge() + minimumCharge() + perUnitRate() validated = true } @@ -3626,9 +3821,10 @@ private constructor( * Used for best match union deserialization. */ internal fun validity(): Int = - additionalProperties.count { (_, value) -> - !value.isNull() && !value.isMissing() - } + (if (groupingKey.asKnown() == null) 0 else 1) + + (if (maximumCharge.asKnown() == null) 0 else 1) + + (if (minimumCharge.asKnown() == null) 0 else 1) + + (if (perUnitRate.asKnown() == null) 0 else 1) override fun equals(other: Any?): Boolean { if (this === other) { @@ -3636,15 +3832,27 @@ private constructor( } return other is GroupedWithMinMaxThresholdsConfig && + groupingKey == other.groupingKey && + maximumCharge == other.maximumCharge && + minimumCharge == other.minimumCharge && + perUnitRate == other.perUnitRate && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + private val hashCode: Int by lazy { + Objects.hash( + groupingKey, + maximumCharge, + minimumCharge, + perUnitRate, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode override fun toString() = - "GroupedWithMinMaxThresholdsConfig{additionalProperties=$additionalProperties}" + "GroupedWithMinMaxThresholdsConfig{groupingKey=$groupingKey, maximumCharge=$maximumCharge, minimumCharge=$minimumCharge, perUnitRate=$perUnitRate, additionalProperties=$additionalProperties}" } /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceEvaluatePreviewEventsParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceEvaluatePreviewEventsParams.kt index e611e8af1..6d6ab6634 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceEvaluatePreviewEventsParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceEvaluatePreviewEventsParams.kt @@ -1370,8 +1370,7 @@ private constructor( fun groupingKeys(): List? = groupingKeys.getNullable("grouping_keys") /** - * An inline price definition to evaluate, allowing you to test price configurations before - * adding them to Orb. + * New floating price request body params. * * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -1524,10 +1523,7 @@ private constructor( } } - /** - * An inline price definition to evaluate, allowing you to test price configurations - * before adding them to Orb. - */ + /** New floating price request body params. */ fun price(price: Price?) = price(JsonField.ofNullable(price)) /** @@ -1542,24 +1538,18 @@ private constructor( /** Alias for calling [price] with `Price.ofUnit(unit)`. */ fun price(unit: NewFloatingUnitPrice) = price(Price.ofUnit(unit)) - /** Alias for calling [price] with `Price.ofPackage(package_)`. */ - fun price(package_: NewFloatingPackagePrice) = price(Price.ofPackage(package_)) - - /** Alias for calling [price] with `Price.ofMatrix(matrix)`. */ - fun price(matrix: NewFloatingMatrixPrice) = price(Price.ofMatrix(matrix)) - - /** - * Alias for calling [price] with `Price.ofMatrixWithAllocation(matrixWithAllocation)`. - */ - fun price(matrixWithAllocation: NewFloatingMatrixWithAllocationPrice) = - price(Price.ofMatrixWithAllocation(matrixWithAllocation)) - /** Alias for calling [price] with `Price.ofTiered(tiered)`. */ fun price(tiered: NewFloatingTieredPrice) = price(Price.ofTiered(tiered)) /** Alias for calling [price] with `Price.ofBulk(bulk)`. */ fun price(bulk: NewFloatingBulkPrice) = price(Price.ofBulk(bulk)) + /** Alias for calling [price] with `Price.ofPackage(package_)`. */ + fun price(package_: NewFloatingPackagePrice) = price(Price.ofPackage(package_)) + + /** Alias for calling [price] with `Price.ofMatrix(matrix)`. */ + fun price(matrix: NewFloatingMatrixPrice) = price(Price.ofMatrix(matrix)) + /** * Alias for calling [price] with `Price.ofThresholdTotalAmount(thresholdTotalAmount)`. */ @@ -1570,20 +1560,20 @@ private constructor( fun price(tieredPackage: NewFloatingTieredPackagePrice) = price(Price.ofTieredPackage(tieredPackage)) + /** Alias for calling [price] with `Price.ofTieredWithMinimum(tieredWithMinimum)`. */ + fun price(tieredWithMinimum: NewFloatingTieredWithMinimumPrice) = + price(Price.ofTieredWithMinimum(tieredWithMinimum)) + /** Alias for calling [price] with `Price.ofGroupedTiered(groupedTiered)`. */ fun price(groupedTiered: NewFloatingGroupedTieredPrice) = price(Price.ofGroupedTiered(groupedTiered)) /** * Alias for calling [price] with - * `Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)`. + * `Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)`. */ - fun price(maxGroupTieredPackage: NewFloatingMaxGroupTieredPackagePrice) = - price(Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)) - - /** Alias for calling [price] with `Price.ofTieredWithMinimum(tieredWithMinimum)`. */ - fun price(tieredWithMinimum: NewFloatingTieredWithMinimumPrice) = - price(Price.ofTieredWithMinimum(tieredWithMinimum)) + fun price(tieredPackageWithMinimum: NewFloatingTieredPackageWithMinimumPrice) = + price(Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)) /** * Alias for calling [price] with @@ -1592,17 +1582,16 @@ private constructor( fun price(packageWithAllocation: NewFloatingPackageWithAllocationPrice) = price(Price.ofPackageWithAllocation(packageWithAllocation)) - /** - * Alias for calling [price] with - * `Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)`. - */ - fun price(tieredPackageWithMinimum: NewFloatingTieredPackageWithMinimumPrice) = - price(Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)) - /** Alias for calling [price] with `Price.ofUnitWithPercent(unitWithPercent)`. */ fun price(unitWithPercent: NewFloatingUnitWithPercentPrice) = price(Price.ofUnitWithPercent(unitWithPercent)) + /** + * Alias for calling [price] with `Price.ofMatrixWithAllocation(matrixWithAllocation)`. + */ + fun price(matrixWithAllocation: NewFloatingMatrixWithAllocationPrice) = + price(Price.ofMatrixWithAllocation(matrixWithAllocation)) + /** * Alias for calling [price] with `Price.ofTieredWithProration(tieredWithProration)`. */ @@ -1617,6 +1606,10 @@ private constructor( fun price(groupedAllocation: NewFloatingGroupedAllocationPrice) = price(Price.ofGroupedAllocation(groupedAllocation)) + /** Alias for calling [price] with `Price.ofBulkWithProration(bulkWithProration)`. */ + fun price(bulkWithProration: NewFloatingBulkWithProrationPrice) = + price(Price.ofBulkWithProration(bulkWithProration)) + /** * Alias for calling [price] with * `Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)`. @@ -1631,6 +1624,13 @@ private constructor( fun price(groupedWithMeteredMinimum: NewFloatingGroupedWithMeteredMinimumPrice) = price(Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)) + /** + * Alias for calling [price] with + * `Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)`. + */ + fun price(groupedWithMinMaxThresholds: Price.GroupedWithMinMaxThresholds) = + price(Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)) + /** * Alias for calling [price] with * `Price.ofMatrixWithDisplayName(matrixWithDisplayName)`. @@ -1638,16 +1638,19 @@ private constructor( fun price(matrixWithDisplayName: NewFloatingMatrixWithDisplayNamePrice) = price(Price.ofMatrixWithDisplayName(matrixWithDisplayName)) - /** Alias for calling [price] with `Price.ofBulkWithProration(bulkWithProration)`. */ - fun price(bulkWithProration: NewFloatingBulkWithProrationPrice) = - price(Price.ofBulkWithProration(bulkWithProration)) - /** * Alias for calling [price] with `Price.ofGroupedTieredPackage(groupedTieredPackage)`. */ fun price(groupedTieredPackage: NewFloatingGroupedTieredPackagePrice) = price(Price.ofGroupedTieredPackage(groupedTieredPackage)) + /** + * Alias for calling [price] with + * `Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)`. + */ + fun price(maxGroupTieredPackage: NewFloatingMaxGroupTieredPackagePrice) = + price(Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)) + /** * Alias for calling [price] with * `Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)`. @@ -1671,13 +1674,6 @@ private constructor( fun price(cumulativeGroupedBulk: NewFloatingCumulativeGroupedBulkPrice) = price(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) - /** - * Alias for calling [price] with - * `Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)`. - */ - fun price(groupedWithMinMaxThresholds: Price.GroupedWithMinMaxThresholds) = - price(Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)) - /** Alias for calling [price] with `Price.ofMinimum(minimum)`. */ fun price(minimum: NewFloatingMinimumCompositePrice) = price(Price.ofMinimum(minimum)) @@ -1764,38 +1760,36 @@ private constructor( (price.asKnown()?.validity() ?: 0) + (if (priceId.asKnown() == null) 0 else 1) - /** - * An inline price definition to evaluate, allowing you to test price configurations before - * adding them to Orb. - */ + /** New floating price request body params. */ @JsonDeserialize(using = Price.Deserializer::class) @JsonSerialize(using = Price.Serializer::class) class Price private constructor( private val unit: NewFloatingUnitPrice? = null, - private val package_: NewFloatingPackagePrice? = null, - private val matrix: NewFloatingMatrixPrice? = null, - private val matrixWithAllocation: NewFloatingMatrixWithAllocationPrice? = null, private val tiered: NewFloatingTieredPrice? = null, private val bulk: NewFloatingBulkPrice? = null, + private val package_: NewFloatingPackagePrice? = null, + private val matrix: NewFloatingMatrixPrice? = null, private val thresholdTotalAmount: NewFloatingThresholdTotalAmountPrice? = null, private val tieredPackage: NewFloatingTieredPackagePrice? = null, - private val groupedTiered: NewFloatingGroupedTieredPrice? = null, - private val maxGroupTieredPackage: NewFloatingMaxGroupTieredPackagePrice? = null, private val tieredWithMinimum: NewFloatingTieredWithMinimumPrice? = null, - private val packageWithAllocation: NewFloatingPackageWithAllocationPrice? = null, + private val groupedTiered: NewFloatingGroupedTieredPrice? = null, private val tieredPackageWithMinimum: NewFloatingTieredPackageWithMinimumPrice? = null, + private val packageWithAllocation: NewFloatingPackageWithAllocationPrice? = null, private val unitWithPercent: NewFloatingUnitWithPercentPrice? = null, + private val matrixWithAllocation: NewFloatingMatrixWithAllocationPrice? = null, private val tieredWithProration: NewFloatingTieredWithProrationPrice? = null, private val unitWithProration: NewFloatingUnitWithProrationPrice? = null, private val groupedAllocation: NewFloatingGroupedAllocationPrice? = null, + private val bulkWithProration: NewFloatingBulkWithProrationPrice? = null, private val groupedWithProratedMinimum: NewFloatingGroupedWithProratedMinimumPrice? = null, private val groupedWithMeteredMinimum: NewFloatingGroupedWithMeteredMinimumPrice? = null, + private val groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds? = null, private val matrixWithDisplayName: NewFloatingMatrixWithDisplayNamePrice? = null, - private val bulkWithProration: NewFloatingBulkWithProrationPrice? = null, private val groupedTieredPackage: NewFloatingGroupedTieredPackagePrice? = null, + private val maxGroupTieredPackage: NewFloatingMaxGroupTieredPackagePrice? = null, private val scalableMatrixWithUnitPricing: NewFloatingScalableMatrixWithUnitPricingPrice? = null, @@ -1803,61 +1797,63 @@ private constructor( NewFloatingScalableMatrixWithTieredPricingPrice? = null, private val cumulativeGroupedBulk: NewFloatingCumulativeGroupedBulkPrice? = null, - private val groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds? = null, private val minimum: NewFloatingMinimumCompositePrice? = null, private val _json: JsonValue? = null, ) { fun unit(): NewFloatingUnitPrice? = unit - fun package_(): NewFloatingPackagePrice? = package_ - - fun matrix(): NewFloatingMatrixPrice? = matrix - - fun matrixWithAllocation(): NewFloatingMatrixWithAllocationPrice? = matrixWithAllocation - fun tiered(): NewFloatingTieredPrice? = tiered fun bulk(): NewFloatingBulkPrice? = bulk - fun thresholdTotalAmount(): NewFloatingThresholdTotalAmountPrice? = thresholdTotalAmount + fun package_(): NewFloatingPackagePrice? = package_ - fun tieredPackage(): NewFloatingTieredPackagePrice? = tieredPackage + fun matrix(): NewFloatingMatrixPrice? = matrix - fun groupedTiered(): NewFloatingGroupedTieredPrice? = groupedTiered + fun thresholdTotalAmount(): NewFloatingThresholdTotalAmountPrice? = thresholdTotalAmount - fun maxGroupTieredPackage(): NewFloatingMaxGroupTieredPackagePrice? = - maxGroupTieredPackage + fun tieredPackage(): NewFloatingTieredPackagePrice? = tieredPackage fun tieredWithMinimum(): NewFloatingTieredWithMinimumPrice? = tieredWithMinimum - fun packageWithAllocation(): NewFloatingPackageWithAllocationPrice? = - packageWithAllocation + fun groupedTiered(): NewFloatingGroupedTieredPrice? = groupedTiered fun tieredPackageWithMinimum(): NewFloatingTieredPackageWithMinimumPrice? = tieredPackageWithMinimum + fun packageWithAllocation(): NewFloatingPackageWithAllocationPrice? = + packageWithAllocation + fun unitWithPercent(): NewFloatingUnitWithPercentPrice? = unitWithPercent + fun matrixWithAllocation(): NewFloatingMatrixWithAllocationPrice? = matrixWithAllocation + fun tieredWithProration(): NewFloatingTieredWithProrationPrice? = tieredWithProration fun unitWithProration(): NewFloatingUnitWithProrationPrice? = unitWithProration fun groupedAllocation(): NewFloatingGroupedAllocationPrice? = groupedAllocation + fun bulkWithProration(): NewFloatingBulkWithProrationPrice? = bulkWithProration + fun groupedWithProratedMinimum(): NewFloatingGroupedWithProratedMinimumPrice? = groupedWithProratedMinimum fun groupedWithMeteredMinimum(): NewFloatingGroupedWithMeteredMinimumPrice? = groupedWithMeteredMinimum + fun groupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds? = + groupedWithMinMaxThresholds + fun matrixWithDisplayName(): NewFloatingMatrixWithDisplayNamePrice? = matrixWithDisplayName - fun bulkWithProration(): NewFloatingBulkWithProrationPrice? = bulkWithProration - fun groupedTieredPackage(): NewFloatingGroupedTieredPackagePrice? = groupedTieredPackage + fun maxGroupTieredPackage(): NewFloatingMaxGroupTieredPackagePrice? = + maxGroupTieredPackage + fun scalableMatrixWithUnitPricing(): NewFloatingScalableMatrixWithUnitPricingPrice? = scalableMatrixWithUnitPricing @@ -1867,55 +1863,54 @@ private constructor( fun cumulativeGroupedBulk(): NewFloatingCumulativeGroupedBulkPrice? = cumulativeGroupedBulk - fun groupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds? = - groupedWithMinMaxThresholds - fun minimum(): NewFloatingMinimumCompositePrice? = minimum fun isUnit(): Boolean = unit != null - fun isPackage(): Boolean = package_ != null - - fun isMatrix(): Boolean = matrix != null - - fun isMatrixWithAllocation(): Boolean = matrixWithAllocation != null - fun isTiered(): Boolean = tiered != null fun isBulk(): Boolean = bulk != null - fun isThresholdTotalAmount(): Boolean = thresholdTotalAmount != null + fun isPackage(): Boolean = package_ != null - fun isTieredPackage(): Boolean = tieredPackage != null + fun isMatrix(): Boolean = matrix != null - fun isGroupedTiered(): Boolean = groupedTiered != null + fun isThresholdTotalAmount(): Boolean = thresholdTotalAmount != null - fun isMaxGroupTieredPackage(): Boolean = maxGroupTieredPackage != null + fun isTieredPackage(): Boolean = tieredPackage != null fun isTieredWithMinimum(): Boolean = tieredWithMinimum != null - fun isPackageWithAllocation(): Boolean = packageWithAllocation != null + fun isGroupedTiered(): Boolean = groupedTiered != null fun isTieredPackageWithMinimum(): Boolean = tieredPackageWithMinimum != null + fun isPackageWithAllocation(): Boolean = packageWithAllocation != null + fun isUnitWithPercent(): Boolean = unitWithPercent != null + fun isMatrixWithAllocation(): Boolean = matrixWithAllocation != null + fun isTieredWithProration(): Boolean = tieredWithProration != null fun isUnitWithProration(): Boolean = unitWithProration != null fun isGroupedAllocation(): Boolean = groupedAllocation != null + fun isBulkWithProration(): Boolean = bulkWithProration != null + fun isGroupedWithProratedMinimum(): Boolean = groupedWithProratedMinimum != null fun isGroupedWithMeteredMinimum(): Boolean = groupedWithMeteredMinimum != null - fun isMatrixWithDisplayName(): Boolean = matrixWithDisplayName != null + fun isGroupedWithMinMaxThresholds(): Boolean = groupedWithMinMaxThresholds != null - fun isBulkWithProration(): Boolean = bulkWithProration != null + fun isMatrixWithDisplayName(): Boolean = matrixWithDisplayName != null fun isGroupedTieredPackage(): Boolean = groupedTieredPackage != null + fun isMaxGroupTieredPackage(): Boolean = maxGroupTieredPackage != null + fun isScalableMatrixWithUnitPricing(): Boolean = scalableMatrixWithUnitPricing != null fun isScalableMatrixWithTieredPricing(): Boolean = @@ -1923,47 +1918,42 @@ private constructor( fun isCumulativeGroupedBulk(): Boolean = cumulativeGroupedBulk != null - fun isGroupedWithMinMaxThresholds(): Boolean = groupedWithMinMaxThresholds != null - fun isMinimum(): Boolean = minimum != null fun asUnit(): NewFloatingUnitPrice = unit.getOrThrow("unit") - fun asPackage(): NewFloatingPackagePrice = package_.getOrThrow("package_") - - fun asMatrix(): NewFloatingMatrixPrice = matrix.getOrThrow("matrix") - - fun asMatrixWithAllocation(): NewFloatingMatrixWithAllocationPrice = - matrixWithAllocation.getOrThrow("matrixWithAllocation") - fun asTiered(): NewFloatingTieredPrice = tiered.getOrThrow("tiered") fun asBulk(): NewFloatingBulkPrice = bulk.getOrThrow("bulk") + fun asPackage(): NewFloatingPackagePrice = package_.getOrThrow("package_") + + fun asMatrix(): NewFloatingMatrixPrice = matrix.getOrThrow("matrix") + fun asThresholdTotalAmount(): NewFloatingThresholdTotalAmountPrice = thresholdTotalAmount.getOrThrow("thresholdTotalAmount") fun asTieredPackage(): NewFloatingTieredPackagePrice = tieredPackage.getOrThrow("tieredPackage") - fun asGroupedTiered(): NewFloatingGroupedTieredPrice = - groupedTiered.getOrThrow("groupedTiered") - - fun asMaxGroupTieredPackage(): NewFloatingMaxGroupTieredPackagePrice = - maxGroupTieredPackage.getOrThrow("maxGroupTieredPackage") - fun asTieredWithMinimum(): NewFloatingTieredWithMinimumPrice = tieredWithMinimum.getOrThrow("tieredWithMinimum") - fun asPackageWithAllocation(): NewFloatingPackageWithAllocationPrice = - packageWithAllocation.getOrThrow("packageWithAllocation") + fun asGroupedTiered(): NewFloatingGroupedTieredPrice = + groupedTiered.getOrThrow("groupedTiered") fun asTieredPackageWithMinimum(): NewFloatingTieredPackageWithMinimumPrice = tieredPackageWithMinimum.getOrThrow("tieredPackageWithMinimum") + fun asPackageWithAllocation(): NewFloatingPackageWithAllocationPrice = + packageWithAllocation.getOrThrow("packageWithAllocation") + fun asUnitWithPercent(): NewFloatingUnitWithPercentPrice = unitWithPercent.getOrThrow("unitWithPercent") + fun asMatrixWithAllocation(): NewFloatingMatrixWithAllocationPrice = + matrixWithAllocation.getOrThrow("matrixWithAllocation") + fun asTieredWithProration(): NewFloatingTieredWithProrationPrice = tieredWithProration.getOrThrow("tieredWithProration") @@ -1973,21 +1963,27 @@ private constructor( fun asGroupedAllocation(): NewFloatingGroupedAllocationPrice = groupedAllocation.getOrThrow("groupedAllocation") + fun asBulkWithProration(): NewFloatingBulkWithProrationPrice = + bulkWithProration.getOrThrow("bulkWithProration") + fun asGroupedWithProratedMinimum(): NewFloatingGroupedWithProratedMinimumPrice = groupedWithProratedMinimum.getOrThrow("groupedWithProratedMinimum") fun asGroupedWithMeteredMinimum(): NewFloatingGroupedWithMeteredMinimumPrice = groupedWithMeteredMinimum.getOrThrow("groupedWithMeteredMinimum") + fun asGroupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds = + groupedWithMinMaxThresholds.getOrThrow("groupedWithMinMaxThresholds") + fun asMatrixWithDisplayName(): NewFloatingMatrixWithDisplayNamePrice = matrixWithDisplayName.getOrThrow("matrixWithDisplayName") - fun asBulkWithProration(): NewFloatingBulkWithProrationPrice = - bulkWithProration.getOrThrow("bulkWithProration") - fun asGroupedTieredPackage(): NewFloatingGroupedTieredPackagePrice = groupedTieredPackage.getOrThrow("groupedTieredPackage") + fun asMaxGroupTieredPackage(): NewFloatingMaxGroupTieredPackagePrice = + maxGroupTieredPackage.getOrThrow("maxGroupTieredPackage") + fun asScalableMatrixWithUnitPricing(): NewFloatingScalableMatrixWithUnitPricingPrice = scalableMatrixWithUnitPricing.getOrThrow("scalableMatrixWithUnitPricing") @@ -1998,9 +1994,6 @@ private constructor( fun asCumulativeGroupedBulk(): NewFloatingCumulativeGroupedBulkPrice = cumulativeGroupedBulk.getOrThrow("cumulativeGroupedBulk") - fun asGroupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds = - groupedWithMinMaxThresholds.getOrThrow("groupedWithMinMaxThresholds") - fun asMinimum(): NewFloatingMinimumCompositePrice = minimum.getOrThrow("minimum") fun _json(): JsonValue? = _json @@ -2008,37 +2001,39 @@ private constructor( fun accept(visitor: Visitor): T = when { unit != null -> visitor.visitUnit(unit) - package_ != null -> visitor.visitPackage(package_) - matrix != null -> visitor.visitMatrix(matrix) - matrixWithAllocation != null -> - visitor.visitMatrixWithAllocation(matrixWithAllocation) tiered != null -> visitor.visitTiered(tiered) bulk != null -> visitor.visitBulk(bulk) + package_ != null -> visitor.visitPackage(package_) + matrix != null -> visitor.visitMatrix(matrix) thresholdTotalAmount != null -> visitor.visitThresholdTotalAmount(thresholdTotalAmount) tieredPackage != null -> visitor.visitTieredPackage(tieredPackage) - groupedTiered != null -> visitor.visitGroupedTiered(groupedTiered) - maxGroupTieredPackage != null -> - visitor.visitMaxGroupTieredPackage(maxGroupTieredPackage) tieredWithMinimum != null -> visitor.visitTieredWithMinimum(tieredWithMinimum) - packageWithAllocation != null -> - visitor.visitPackageWithAllocation(packageWithAllocation) + groupedTiered != null -> visitor.visitGroupedTiered(groupedTiered) tieredPackageWithMinimum != null -> visitor.visitTieredPackageWithMinimum(tieredPackageWithMinimum) + packageWithAllocation != null -> + visitor.visitPackageWithAllocation(packageWithAllocation) unitWithPercent != null -> visitor.visitUnitWithPercent(unitWithPercent) + matrixWithAllocation != null -> + visitor.visitMatrixWithAllocation(matrixWithAllocation) tieredWithProration != null -> visitor.visitTieredWithProration(tieredWithProration) unitWithProration != null -> visitor.visitUnitWithProration(unitWithProration) groupedAllocation != null -> visitor.visitGroupedAllocation(groupedAllocation) + bulkWithProration != null -> visitor.visitBulkWithProration(bulkWithProration) groupedWithProratedMinimum != null -> visitor.visitGroupedWithProratedMinimum(groupedWithProratedMinimum) groupedWithMeteredMinimum != null -> visitor.visitGroupedWithMeteredMinimum(groupedWithMeteredMinimum) + groupedWithMinMaxThresholds != null -> + visitor.visitGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds) matrixWithDisplayName != null -> visitor.visitMatrixWithDisplayName(matrixWithDisplayName) - bulkWithProration != null -> visitor.visitBulkWithProration(bulkWithProration) groupedTieredPackage != null -> visitor.visitGroupedTieredPackage(groupedTieredPackage) + maxGroupTieredPackage != null -> + visitor.visitMaxGroupTieredPackage(maxGroupTieredPackage) scalableMatrixWithUnitPricing != null -> visitor.visitScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing) scalableMatrixWithTieredPricing != null -> @@ -2047,8 +2042,6 @@ private constructor( ) cumulativeGroupedBulk != null -> visitor.visitCumulativeGroupedBulk(cumulativeGroupedBulk) - groupedWithMinMaxThresholds != null -> - visitor.visitGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds) minimum != null -> visitor.visitMinimum(minimum) else -> visitor.unknown(_json) } @@ -2066,20 +2059,6 @@ private constructor( unit.validate() } - override fun visitPackage(package_: NewFloatingPackagePrice) { - package_.validate() - } - - override fun visitMatrix(matrix: NewFloatingMatrixPrice) { - matrix.validate() - } - - override fun visitMatrixWithAllocation( - matrixWithAllocation: NewFloatingMatrixWithAllocationPrice - ) { - matrixWithAllocation.validate() - } - override fun visitTiered(tiered: NewFloatingTieredPrice) { tiered.validate() } @@ -2088,6 +2067,14 @@ private constructor( bulk.validate() } + override fun visitPackage(package_: NewFloatingPackagePrice) { + package_.validate() + } + + override fun visitMatrix(matrix: NewFloatingMatrixPrice) { + matrix.validate() + } + override fun visitThresholdTotalAmount( thresholdTotalAmount: NewFloatingThresholdTotalAmountPrice ) { @@ -2100,28 +2087,16 @@ private constructor( tieredPackage.validate() } - override fun visitGroupedTiered( - groupedTiered: NewFloatingGroupedTieredPrice - ) { - groupedTiered.validate() - } - - override fun visitMaxGroupTieredPackage( - maxGroupTieredPackage: NewFloatingMaxGroupTieredPackagePrice - ) { - maxGroupTieredPackage.validate() - } - override fun visitTieredWithMinimum( tieredWithMinimum: NewFloatingTieredWithMinimumPrice ) { tieredWithMinimum.validate() } - override fun visitPackageWithAllocation( - packageWithAllocation: NewFloatingPackageWithAllocationPrice + override fun visitGroupedTiered( + groupedTiered: NewFloatingGroupedTieredPrice ) { - packageWithAllocation.validate() + groupedTiered.validate() } override fun visitTieredPackageWithMinimum( @@ -2130,12 +2105,24 @@ private constructor( tieredPackageWithMinimum.validate() } + override fun visitPackageWithAllocation( + packageWithAllocation: NewFloatingPackageWithAllocationPrice + ) { + packageWithAllocation.validate() + } + override fun visitUnitWithPercent( unitWithPercent: NewFloatingUnitWithPercentPrice ) { unitWithPercent.validate() } + override fun visitMatrixWithAllocation( + matrixWithAllocation: NewFloatingMatrixWithAllocationPrice + ) { + matrixWithAllocation.validate() + } + override fun visitTieredWithProration( tieredWithProration: NewFloatingTieredWithProrationPrice ) { @@ -2154,6 +2141,12 @@ private constructor( groupedAllocation.validate() } + override fun visitBulkWithProration( + bulkWithProration: NewFloatingBulkWithProrationPrice + ) { + bulkWithProration.validate() + } + override fun visitGroupedWithProratedMinimum( groupedWithProratedMinimum: NewFloatingGroupedWithProratedMinimumPrice ) { @@ -2166,16 +2159,16 @@ private constructor( groupedWithMeteredMinimum.validate() } - override fun visitMatrixWithDisplayName( - matrixWithDisplayName: NewFloatingMatrixWithDisplayNamePrice + override fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds ) { - matrixWithDisplayName.validate() + groupedWithMinMaxThresholds.validate() } - override fun visitBulkWithProration( - bulkWithProration: NewFloatingBulkWithProrationPrice + override fun visitMatrixWithDisplayName( + matrixWithDisplayName: NewFloatingMatrixWithDisplayNamePrice ) { - bulkWithProration.validate() + matrixWithDisplayName.validate() } override fun visitGroupedTieredPackage( @@ -2184,6 +2177,12 @@ private constructor( groupedTieredPackage.validate() } + override fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: NewFloatingMaxGroupTieredPackagePrice + ) { + maxGroupTieredPackage.validate() + } + override fun visitScalableMatrixWithUnitPricing( scalableMatrixWithUnitPricing: NewFloatingScalableMatrixWithUnitPricingPrice @@ -2204,12 +2203,6 @@ private constructor( cumulativeGroupedBulk.validate() } - override fun visitGroupedWithMinMaxThresholds( - groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds - ) { - groupedWithMinMaxThresholds.validate() - } - override fun visitMinimum(minimum: NewFloatingMinimumCompositePrice) { minimum.validate() } @@ -2237,19 +2230,15 @@ private constructor( object : Visitor { override fun visitUnit(unit: NewFloatingUnitPrice) = unit.validity() + override fun visitTiered(tiered: NewFloatingTieredPrice) = tiered.validity() + + override fun visitBulk(bulk: NewFloatingBulkPrice) = bulk.validity() + override fun visitPackage(package_: NewFloatingPackagePrice) = package_.validity() override fun visitMatrix(matrix: NewFloatingMatrixPrice) = matrix.validity() - override fun visitMatrixWithAllocation( - matrixWithAllocation: NewFloatingMatrixWithAllocationPrice - ) = matrixWithAllocation.validity() - - override fun visitTiered(tiered: NewFloatingTieredPrice) = tiered.validity() - - override fun visitBulk(bulk: NewFloatingBulkPrice) = bulk.validity() - override fun visitThresholdTotalAmount( thresholdTotalAmount: NewFloatingThresholdTotalAmountPrice ) = thresholdTotalAmount.validity() @@ -2258,30 +2247,30 @@ private constructor( tieredPackage: NewFloatingTieredPackagePrice ) = tieredPackage.validity() - override fun visitGroupedTiered( - groupedTiered: NewFloatingGroupedTieredPrice - ) = groupedTiered.validity() - - override fun visitMaxGroupTieredPackage( - maxGroupTieredPackage: NewFloatingMaxGroupTieredPackagePrice - ) = maxGroupTieredPackage.validity() - override fun visitTieredWithMinimum( tieredWithMinimum: NewFloatingTieredWithMinimumPrice ) = tieredWithMinimum.validity() - override fun visitPackageWithAllocation( - packageWithAllocation: NewFloatingPackageWithAllocationPrice - ) = packageWithAllocation.validity() + override fun visitGroupedTiered( + groupedTiered: NewFloatingGroupedTieredPrice + ) = groupedTiered.validity() override fun visitTieredPackageWithMinimum( tieredPackageWithMinimum: NewFloatingTieredPackageWithMinimumPrice ) = tieredPackageWithMinimum.validity() + override fun visitPackageWithAllocation( + packageWithAllocation: NewFloatingPackageWithAllocationPrice + ) = packageWithAllocation.validity() + override fun visitUnitWithPercent( unitWithPercent: NewFloatingUnitWithPercentPrice ) = unitWithPercent.validity() + override fun visitMatrixWithAllocation( + matrixWithAllocation: NewFloatingMatrixWithAllocationPrice + ) = matrixWithAllocation.validity() + override fun visitTieredWithProration( tieredWithProration: NewFloatingTieredWithProrationPrice ) = tieredWithProration.validity() @@ -2294,6 +2283,10 @@ private constructor( groupedAllocation: NewFloatingGroupedAllocationPrice ) = groupedAllocation.validity() + override fun visitBulkWithProration( + bulkWithProration: NewFloatingBulkWithProrationPrice + ) = bulkWithProration.validity() + override fun visitGroupedWithProratedMinimum( groupedWithProratedMinimum: NewFloatingGroupedWithProratedMinimumPrice ) = groupedWithProratedMinimum.validity() @@ -2302,18 +2295,22 @@ private constructor( groupedWithMeteredMinimum: NewFloatingGroupedWithMeteredMinimumPrice ) = groupedWithMeteredMinimum.validity() + override fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) = groupedWithMinMaxThresholds.validity() + override fun visitMatrixWithDisplayName( matrixWithDisplayName: NewFloatingMatrixWithDisplayNamePrice ) = matrixWithDisplayName.validity() - override fun visitBulkWithProration( - bulkWithProration: NewFloatingBulkWithProrationPrice - ) = bulkWithProration.validity() - override fun visitGroupedTieredPackage( groupedTieredPackage: NewFloatingGroupedTieredPackagePrice ) = groupedTieredPackage.validity() + override fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: NewFloatingMaxGroupTieredPackagePrice + ) = maxGroupTieredPackage.validity() + override fun visitScalableMatrixWithUnitPricing( scalableMatrixWithUnitPricing: NewFloatingScalableMatrixWithUnitPricingPrice @@ -2328,10 +2325,6 @@ private constructor( cumulativeGroupedBulk: NewFloatingCumulativeGroupedBulkPrice ) = cumulativeGroupedBulk.validity() - override fun visitGroupedWithMinMaxThresholds( - groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds - ) = groupedWithMinMaxThresholds.validity() - override fun visitMinimum(minimum: NewFloatingMinimumCompositePrice) = minimum.validity() @@ -2346,106 +2339,106 @@ private constructor( return other is Price && unit == other.unit && - package_ == other.package_ && - matrix == other.matrix && - matrixWithAllocation == other.matrixWithAllocation && tiered == other.tiered && bulk == other.bulk && + package_ == other.package_ && + matrix == other.matrix && thresholdTotalAmount == other.thresholdTotalAmount && tieredPackage == other.tieredPackage && - groupedTiered == other.groupedTiered && - maxGroupTieredPackage == other.maxGroupTieredPackage && tieredWithMinimum == other.tieredWithMinimum && - packageWithAllocation == other.packageWithAllocation && + groupedTiered == other.groupedTiered && tieredPackageWithMinimum == other.tieredPackageWithMinimum && + packageWithAllocation == other.packageWithAllocation && unitWithPercent == other.unitWithPercent && + matrixWithAllocation == other.matrixWithAllocation && tieredWithProration == other.tieredWithProration && unitWithProration == other.unitWithProration && groupedAllocation == other.groupedAllocation && + bulkWithProration == other.bulkWithProration && groupedWithProratedMinimum == other.groupedWithProratedMinimum && groupedWithMeteredMinimum == other.groupedWithMeteredMinimum && + groupedWithMinMaxThresholds == other.groupedWithMinMaxThresholds && matrixWithDisplayName == other.matrixWithDisplayName && - bulkWithProration == other.bulkWithProration && groupedTieredPackage == other.groupedTieredPackage && + maxGroupTieredPackage == other.maxGroupTieredPackage && scalableMatrixWithUnitPricing == other.scalableMatrixWithUnitPricing && scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && cumulativeGroupedBulk == other.cumulativeGroupedBulk && - groupedWithMinMaxThresholds == other.groupedWithMinMaxThresholds && minimum == other.minimum } override fun hashCode(): Int = Objects.hash( unit, - package_, - matrix, - matrixWithAllocation, tiered, bulk, + package_, + matrix, thresholdTotalAmount, tieredPackage, - groupedTiered, - maxGroupTieredPackage, tieredWithMinimum, - packageWithAllocation, + groupedTiered, tieredPackageWithMinimum, + packageWithAllocation, unitWithPercent, + matrixWithAllocation, tieredWithProration, unitWithProration, groupedAllocation, + bulkWithProration, groupedWithProratedMinimum, groupedWithMeteredMinimum, + groupedWithMinMaxThresholds, matrixWithDisplayName, - bulkWithProration, groupedTieredPackage, + maxGroupTieredPackage, scalableMatrixWithUnitPricing, scalableMatrixWithTieredPricing, cumulativeGroupedBulk, - groupedWithMinMaxThresholds, minimum, ) override fun toString(): String = when { unit != null -> "Price{unit=$unit}" - package_ != null -> "Price{package_=$package_}" - matrix != null -> "Price{matrix=$matrix}" - matrixWithAllocation != null -> - "Price{matrixWithAllocation=$matrixWithAllocation}" tiered != null -> "Price{tiered=$tiered}" bulk != null -> "Price{bulk=$bulk}" + package_ != null -> "Price{package_=$package_}" + matrix != null -> "Price{matrix=$matrix}" thresholdTotalAmount != null -> "Price{thresholdTotalAmount=$thresholdTotalAmount}" tieredPackage != null -> "Price{tieredPackage=$tieredPackage}" - groupedTiered != null -> "Price{groupedTiered=$groupedTiered}" - maxGroupTieredPackage != null -> - "Price{maxGroupTieredPackage=$maxGroupTieredPackage}" tieredWithMinimum != null -> "Price{tieredWithMinimum=$tieredWithMinimum}" - packageWithAllocation != null -> - "Price{packageWithAllocation=$packageWithAllocation}" + groupedTiered != null -> "Price{groupedTiered=$groupedTiered}" tieredPackageWithMinimum != null -> "Price{tieredPackageWithMinimum=$tieredPackageWithMinimum}" + packageWithAllocation != null -> + "Price{packageWithAllocation=$packageWithAllocation}" unitWithPercent != null -> "Price{unitWithPercent=$unitWithPercent}" + matrixWithAllocation != null -> + "Price{matrixWithAllocation=$matrixWithAllocation}" tieredWithProration != null -> "Price{tieredWithProration=$tieredWithProration}" unitWithProration != null -> "Price{unitWithProration=$unitWithProration}" groupedAllocation != null -> "Price{groupedAllocation=$groupedAllocation}" + bulkWithProration != null -> "Price{bulkWithProration=$bulkWithProration}" groupedWithProratedMinimum != null -> "Price{groupedWithProratedMinimum=$groupedWithProratedMinimum}" groupedWithMeteredMinimum != null -> "Price{groupedWithMeteredMinimum=$groupedWithMeteredMinimum}" + groupedWithMinMaxThresholds != null -> + "Price{groupedWithMinMaxThresholds=$groupedWithMinMaxThresholds}" matrixWithDisplayName != null -> "Price{matrixWithDisplayName=$matrixWithDisplayName}" - bulkWithProration != null -> "Price{bulkWithProration=$bulkWithProration}" groupedTieredPackage != null -> "Price{groupedTieredPackage=$groupedTieredPackage}" + maxGroupTieredPackage != null -> + "Price{maxGroupTieredPackage=$maxGroupTieredPackage}" scalableMatrixWithUnitPricing != null -> "Price{scalableMatrixWithUnitPricing=$scalableMatrixWithUnitPricing}" scalableMatrixWithTieredPricing != null -> "Price{scalableMatrixWithTieredPricing=$scalableMatrixWithTieredPricing}" cumulativeGroupedBulk != null -> "Price{cumulativeGroupedBulk=$cumulativeGroupedBulk}" - groupedWithMinMaxThresholds != null -> - "Price{groupedWithMinMaxThresholds=$groupedWithMinMaxThresholds}" minimum != null -> "Price{minimum=$minimum}" _json != null -> "Price{_unknown=$_json}" else -> throw IllegalStateException("Invalid Price") @@ -2455,18 +2448,14 @@ private constructor( fun ofUnit(unit: NewFloatingUnitPrice) = Price(unit = unit) - fun ofPackage(package_: NewFloatingPackagePrice) = Price(package_ = package_) - - fun ofMatrix(matrix: NewFloatingMatrixPrice) = Price(matrix = matrix) - - fun ofMatrixWithAllocation( - matrixWithAllocation: NewFloatingMatrixWithAllocationPrice - ) = Price(matrixWithAllocation = matrixWithAllocation) - fun ofTiered(tiered: NewFloatingTieredPrice) = Price(tiered = tiered) fun ofBulk(bulk: NewFloatingBulkPrice) = Price(bulk = bulk) + fun ofPackage(package_: NewFloatingPackagePrice) = Price(package_ = package_) + + fun ofMatrix(matrix: NewFloatingMatrixPrice) = Price(matrix = matrix) + fun ofThresholdTotalAmount( thresholdTotalAmount: NewFloatingThresholdTotalAmountPrice ) = Price(thresholdTotalAmount = thresholdTotalAmount) @@ -2474,27 +2463,27 @@ private constructor( fun ofTieredPackage(tieredPackage: NewFloatingTieredPackagePrice) = Price(tieredPackage = tieredPackage) - fun ofGroupedTiered(groupedTiered: NewFloatingGroupedTieredPrice) = - Price(groupedTiered = groupedTiered) - - fun ofMaxGroupTieredPackage( - maxGroupTieredPackage: NewFloatingMaxGroupTieredPackagePrice - ) = Price(maxGroupTieredPackage = maxGroupTieredPackage) - fun ofTieredWithMinimum(tieredWithMinimum: NewFloatingTieredWithMinimumPrice) = Price(tieredWithMinimum = tieredWithMinimum) - fun ofPackageWithAllocation( - packageWithAllocation: NewFloatingPackageWithAllocationPrice - ) = Price(packageWithAllocation = packageWithAllocation) + fun ofGroupedTiered(groupedTiered: NewFloatingGroupedTieredPrice) = + Price(groupedTiered = groupedTiered) fun ofTieredPackageWithMinimum( tieredPackageWithMinimum: NewFloatingTieredPackageWithMinimumPrice ) = Price(tieredPackageWithMinimum = tieredPackageWithMinimum) + fun ofPackageWithAllocation( + packageWithAllocation: NewFloatingPackageWithAllocationPrice + ) = Price(packageWithAllocation = packageWithAllocation) + fun ofUnitWithPercent(unitWithPercent: NewFloatingUnitWithPercentPrice) = Price(unitWithPercent = unitWithPercent) + fun ofMatrixWithAllocation( + matrixWithAllocation: NewFloatingMatrixWithAllocationPrice + ) = Price(matrixWithAllocation = matrixWithAllocation) + fun ofTieredWithProration( tieredWithProration: NewFloatingTieredWithProrationPrice ) = Price(tieredWithProration = tieredWithProration) @@ -2505,6 +2494,9 @@ private constructor( fun ofGroupedAllocation(groupedAllocation: NewFloatingGroupedAllocationPrice) = Price(groupedAllocation = groupedAllocation) + fun ofBulkWithProration(bulkWithProration: NewFloatingBulkWithProrationPrice) = + Price(bulkWithProration = bulkWithProration) + fun ofGroupedWithProratedMinimum( groupedWithProratedMinimum: NewFloatingGroupedWithProratedMinimumPrice ) = Price(groupedWithProratedMinimum = groupedWithProratedMinimum) @@ -2513,17 +2505,22 @@ private constructor( groupedWithMeteredMinimum: NewFloatingGroupedWithMeteredMinimumPrice ) = Price(groupedWithMeteredMinimum = groupedWithMeteredMinimum) + fun ofGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) = Price(groupedWithMinMaxThresholds = groupedWithMinMaxThresholds) + fun ofMatrixWithDisplayName( matrixWithDisplayName: NewFloatingMatrixWithDisplayNamePrice ) = Price(matrixWithDisplayName = matrixWithDisplayName) - fun ofBulkWithProration(bulkWithProration: NewFloatingBulkWithProrationPrice) = - Price(bulkWithProration = bulkWithProration) - fun ofGroupedTieredPackage( groupedTieredPackage: NewFloatingGroupedTieredPackagePrice ) = Price(groupedTieredPackage = groupedTieredPackage) + fun ofMaxGroupTieredPackage( + maxGroupTieredPackage: NewFloatingMaxGroupTieredPackagePrice + ) = Price(maxGroupTieredPackage = maxGroupTieredPackage) + fun ofScalableMatrixWithUnitPricing( scalableMatrixWithUnitPricing: NewFloatingScalableMatrixWithUnitPricingPrice ) = Price(scalableMatrixWithUnitPricing = scalableMatrixWithUnitPricing) @@ -2536,10 +2533,6 @@ private constructor( cumulativeGroupedBulk: NewFloatingCumulativeGroupedBulkPrice ) = Price(cumulativeGroupedBulk = cumulativeGroupedBulk) - fun ofGroupedWithMinMaxThresholds( - groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds - ) = Price(groupedWithMinMaxThresholds = groupedWithMinMaxThresholds) - fun ofMinimum(minimum: NewFloatingMinimumCompositePrice) = Price(minimum = minimum) } @@ -2550,42 +2543,38 @@ private constructor( fun visitUnit(unit: NewFloatingUnitPrice): T - fun visitPackage(package_: NewFloatingPackagePrice): T - - fun visitMatrix(matrix: NewFloatingMatrixPrice): T - - fun visitMatrixWithAllocation( - matrixWithAllocation: NewFloatingMatrixWithAllocationPrice - ): T - fun visitTiered(tiered: NewFloatingTieredPrice): T fun visitBulk(bulk: NewFloatingBulkPrice): T + fun visitPackage(package_: NewFloatingPackagePrice): T + + fun visitMatrix(matrix: NewFloatingMatrixPrice): T + fun visitThresholdTotalAmount( thresholdTotalAmount: NewFloatingThresholdTotalAmountPrice ): T fun visitTieredPackage(tieredPackage: NewFloatingTieredPackagePrice): T + fun visitTieredWithMinimum(tieredWithMinimum: NewFloatingTieredWithMinimumPrice): T + fun visitGroupedTiered(groupedTiered: NewFloatingGroupedTieredPrice): T - fun visitMaxGroupTieredPackage( - maxGroupTieredPackage: NewFloatingMaxGroupTieredPackagePrice + fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: NewFloatingTieredPackageWithMinimumPrice ): T - fun visitTieredWithMinimum(tieredWithMinimum: NewFloatingTieredWithMinimumPrice): T - fun visitPackageWithAllocation( packageWithAllocation: NewFloatingPackageWithAllocationPrice ): T - fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewFloatingTieredPackageWithMinimumPrice - ): T - fun visitUnitWithPercent(unitWithPercent: NewFloatingUnitWithPercentPrice): T + fun visitMatrixWithAllocation( + matrixWithAllocation: NewFloatingMatrixWithAllocationPrice + ): T + fun visitTieredWithProration( tieredWithProration: NewFloatingTieredWithProrationPrice ): T @@ -2594,6 +2583,8 @@ private constructor( fun visitGroupedAllocation(groupedAllocation: NewFloatingGroupedAllocationPrice): T + fun visitBulkWithProration(bulkWithProration: NewFloatingBulkWithProrationPrice): T + fun visitGroupedWithProratedMinimum( groupedWithProratedMinimum: NewFloatingGroupedWithProratedMinimumPrice ): T @@ -2602,16 +2593,22 @@ private constructor( groupedWithMeteredMinimum: NewFloatingGroupedWithMeteredMinimumPrice ): T + fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ): T + fun visitMatrixWithDisplayName( matrixWithDisplayName: NewFloatingMatrixWithDisplayNamePrice ): T - fun visitBulkWithProration(bulkWithProration: NewFloatingBulkWithProrationPrice): T - fun visitGroupedTieredPackage( groupedTieredPackage: NewFloatingGroupedTieredPackagePrice ): T + fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: NewFloatingMaxGroupTieredPackagePrice + ): T + fun visitScalableMatrixWithUnitPricing( scalableMatrixWithUnitPricing: NewFloatingScalableMatrixWithUnitPricingPrice ): T @@ -2624,10 +2621,6 @@ private constructor( cumulativeGroupedBulk: NewFloatingCumulativeGroupedBulkPrice ): T - fun visitGroupedWithMinMaxThresholds( - groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds - ): T - fun visitMinimum(minimum: NewFloatingMinimumCompositePrice): T /** @@ -2656,22 +2649,6 @@ private constructor( return tryDeserialize(node, jacksonTypeRef()) ?.let { Price(unit = it, _json = json) } ?: Price(_json = json) } - "package" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(package_ = it, _json = json) } ?: Price(_json = json) - } - "matrix" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(matrix = it, _json = json) } ?: Price(_json = json) - } - "matrix_with_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(matrixWithAllocation = it, _json = json) } - ?: Price(_json = json) - } "tiered" -> { return tryDeserialize(node, jacksonTypeRef()) ?.let { Price(tiered = it, _json = json) } ?: Price(_json = json) @@ -2680,6 +2657,14 @@ private constructor( return tryDeserialize(node, jacksonTypeRef()) ?.let { Price(bulk = it, _json = json) } ?: Price(_json = json) } + "package" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(package_ = it, _json = json) } ?: Price(_json = json) + } + "matrix" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(matrix = it, _json = json) } ?: Price(_json = json) + } "threshold_total_amount" -> { return tryDeserialize( node, @@ -2696,28 +2681,28 @@ private constructor( ?.let { Price(tieredPackage = it, _json = json) } ?: Price(_json = json) } - "grouped_tiered" -> { + "tiered_with_minimum" -> { return tryDeserialize( node, - jacksonTypeRef(), + jacksonTypeRef(), ) - ?.let { Price(groupedTiered = it, _json = json) } + ?.let { Price(tieredWithMinimum = it, _json = json) } ?: Price(_json = json) } - "max_group_tiered_package" -> { + "grouped_tiered" -> { return tryDeserialize( node, - jacksonTypeRef(), + jacksonTypeRef(), ) - ?.let { Price(maxGroupTieredPackage = it, _json = json) } + ?.let { Price(groupedTiered = it, _json = json) } ?: Price(_json = json) } - "tiered_with_minimum" -> { + "tiered_package_with_minimum" -> { return tryDeserialize( node, - jacksonTypeRef(), + jacksonTypeRef(), ) - ?.let { Price(tieredWithMinimum = it, _json = json) } + ?.let { Price(tieredPackageWithMinimum = it, _json = json) } ?: Price(_json = json) } "package_with_allocation" -> { @@ -2728,20 +2713,20 @@ private constructor( ?.let { Price(packageWithAllocation = it, _json = json) } ?: Price(_json = json) } - "tiered_package_with_minimum" -> { + "unit_with_percent" -> { return tryDeserialize( node, - jacksonTypeRef(), + jacksonTypeRef(), ) - ?.let { Price(tieredPackageWithMinimum = it, _json = json) } + ?.let { Price(unitWithPercent = it, _json = json) } ?: Price(_json = json) } - "unit_with_percent" -> { + "matrix_with_allocation" -> { return tryDeserialize( node, - jacksonTypeRef(), + jacksonTypeRef(), ) - ?.let { Price(unitWithPercent = it, _json = json) } + ?.let { Price(matrixWithAllocation = it, _json = json) } ?: Price(_json = json) } "tiered_with_proration" -> { @@ -2768,6 +2753,14 @@ private constructor( ?.let { Price(groupedAllocation = it, _json = json) } ?: Price(_json = json) } + "bulk_with_proration" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(bulkWithProration = it, _json = json) } + ?: Price(_json = json) + } "grouped_with_prorated_minimum" -> { return tryDeserialize( node, @@ -2784,20 +2777,20 @@ private constructor( ?.let { Price(groupedWithMeteredMinimum = it, _json = json) } ?: Price(_json = json) } - "matrix_with_display_name" -> { + "grouped_with_min_max_thresholds" -> { return tryDeserialize( node, - jacksonTypeRef(), + jacksonTypeRef(), ) - ?.let { Price(matrixWithDisplayName = it, _json = json) } + ?.let { Price(groupedWithMinMaxThresholds = it, _json = json) } ?: Price(_json = json) } - "bulk_with_proration" -> { + "matrix_with_display_name" -> { return tryDeserialize( node, - jacksonTypeRef(), + jacksonTypeRef(), ) - ?.let { Price(bulkWithProration = it, _json = json) } + ?.let { Price(matrixWithDisplayName = it, _json = json) } ?: Price(_json = json) } "grouped_tiered_package" -> { @@ -2808,6 +2801,14 @@ private constructor( ?.let { Price(groupedTieredPackage = it, _json = json) } ?: Price(_json = json) } + "max_group_tiered_package" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(maxGroupTieredPackage = it, _json = json) } + ?: Price(_json = json) + } "scalable_matrix_with_unit_pricing" -> { return tryDeserialize( node, @@ -2834,14 +2835,6 @@ private constructor( ?.let { Price(cumulativeGroupedBulk = it, _json = json) } ?: Price(_json = json) } - "grouped_with_min_max_thresholds" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedWithMinMaxThresholds = it, _json = json) } - ?: Price(_json = json) - } "minimum" -> { return tryDeserialize( node, @@ -2864,50 +2857,50 @@ private constructor( ) { when { value.unit != null -> generator.writeObject(value.unit) - value.package_ != null -> generator.writeObject(value.package_) - value.matrix != null -> generator.writeObject(value.matrix) - value.matrixWithAllocation != null -> - generator.writeObject(value.matrixWithAllocation) value.tiered != null -> generator.writeObject(value.tiered) value.bulk != null -> generator.writeObject(value.bulk) + value.package_ != null -> generator.writeObject(value.package_) + value.matrix != null -> generator.writeObject(value.matrix) value.thresholdTotalAmount != null -> generator.writeObject(value.thresholdTotalAmount) value.tieredPackage != null -> generator.writeObject(value.tieredPackage) - value.groupedTiered != null -> generator.writeObject(value.groupedTiered) - value.maxGroupTieredPackage != null -> - generator.writeObject(value.maxGroupTieredPackage) value.tieredWithMinimum != null -> generator.writeObject(value.tieredWithMinimum) - value.packageWithAllocation != null -> - generator.writeObject(value.packageWithAllocation) + value.groupedTiered != null -> generator.writeObject(value.groupedTiered) value.tieredPackageWithMinimum != null -> generator.writeObject(value.tieredPackageWithMinimum) + value.packageWithAllocation != null -> + generator.writeObject(value.packageWithAllocation) value.unitWithPercent != null -> generator.writeObject(value.unitWithPercent) + value.matrixWithAllocation != null -> + generator.writeObject(value.matrixWithAllocation) value.tieredWithProration != null -> generator.writeObject(value.tieredWithProration) value.unitWithProration != null -> generator.writeObject(value.unitWithProration) value.groupedAllocation != null -> generator.writeObject(value.groupedAllocation) + value.bulkWithProration != null -> + generator.writeObject(value.bulkWithProration) value.groupedWithProratedMinimum != null -> generator.writeObject(value.groupedWithProratedMinimum) value.groupedWithMeteredMinimum != null -> generator.writeObject(value.groupedWithMeteredMinimum) + value.groupedWithMinMaxThresholds != null -> + generator.writeObject(value.groupedWithMinMaxThresholds) value.matrixWithDisplayName != null -> generator.writeObject(value.matrixWithDisplayName) - value.bulkWithProration != null -> - generator.writeObject(value.bulkWithProration) value.groupedTieredPackage != null -> generator.writeObject(value.groupedTieredPackage) + value.maxGroupTieredPackage != null -> + generator.writeObject(value.maxGroupTieredPackage) value.scalableMatrixWithUnitPricing != null -> generator.writeObject(value.scalableMatrixWithUnitPricing) value.scalableMatrixWithTieredPricing != null -> generator.writeObject(value.scalableMatrixWithTieredPricing) value.cumulativeGroupedBulk != null -> generator.writeObject(value.cumulativeGroupedBulk) - value.groupedWithMinMaxThresholds != null -> - generator.writeObject(value.groupedWithMinMaxThresholds) value.minimum != null -> generator.writeObject(value.minimum) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid Price") @@ -3037,6 +3030,8 @@ private constructor( fun currency(): String = currency.getRequired("currency") /** + * Configuration for grouped_with_min_max_thresholds pricing + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected * value). @@ -3056,6 +3051,8 @@ private constructor( fun itemId(): String = itemId.getRequired("item_id") /** + * The pricing model type + * * Expected to always return the following: * ```kotlin * JsonValue.from("grouped_with_min_max_thresholds") @@ -3448,6 +3445,7 @@ private constructor( */ fun currency(currency: JsonField) = apply { this.currency = currency } + /** Configuration for grouped_with_min_max_thresholds pricing */ fun groupedWithMinMaxThresholdsConfig( groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig ) = @@ -4068,16 +4066,117 @@ private constructor( override fun toString() = value.toString() } + /** Configuration for grouped_with_min_max_thresholds pricing */ class GroupedWithMinMaxThresholdsConfig - @JsonCreator private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map + private val groupingKey: JsonField, + private val maximumCharge: JsonField, + private val minimumCharge: JsonField, + private val perUnitRate: JsonField, + private val additionalProperties: MutableMap, ) { + @JsonCreator + private constructor( + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("maximum_charge") + @ExcludeMissing + maximumCharge: JsonField = JsonMissing.of(), + @JsonProperty("minimum_charge") + @ExcludeMissing + minimumCharge: JsonField = JsonMissing.of(), + @JsonProperty("per_unit_rate") + @ExcludeMissing + perUnitRate: JsonField = JsonMissing.of(), + ) : this(groupingKey, maximumCharge, minimumCharge, perUnitRate, mutableMapOf()) + + /** + * The event property used to group before applying thresholds + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The maximum amount to charge each group + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun maximumCharge(): String = maximumCharge.getRequired("maximum_charge") + + /** + * The minimum amount to charge each group, regardless of usage + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun minimumCharge(): String = minimumCharge.getRequired("minimum_charge") + + /** + * The base price charged per group + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun perUnitRate(): String = perUnitRate.getRequired("per_unit_rate") + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [maximumCharge]. + * + * Unlike [maximumCharge], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("maximum_charge") + @ExcludeMissing + fun _maximumCharge(): JsonField = maximumCharge + + /** + * Returns the raw JSON value of [minimumCharge]. + * + * Unlike [minimumCharge], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("minimum_charge") + @ExcludeMissing + fun _minimumCharge(): JsonField = minimumCharge + + /** + * Returns the raw JSON value of [perUnitRate]. + * + * Unlike [perUnitRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("per_unit_rate") + @ExcludeMissing + fun _perUnitRate(): JsonField = perUnitRate + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) fun toBuilder() = Builder().from(this) @@ -4086,6 +4185,14 @@ private constructor( /** * Returns a mutable builder for constructing an instance of * [GroupedWithMinMaxThresholdsConfig]. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .maximumCharge() + * .minimumCharge() + * .perUnitRate() + * ``` */ fun builder() = Builder() } @@ -4093,17 +4200,85 @@ private constructor( /** A builder for [GroupedWithMinMaxThresholdsConfig]. */ class Builder internal constructor() { + private var groupingKey: JsonField? = null + private var maximumCharge: JsonField? = null + private var minimumCharge: JsonField? = null + private var perUnitRate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from( groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig ) = apply { + groupingKey = groupedWithMinMaxThresholdsConfig.groupingKey + maximumCharge = groupedWithMinMaxThresholdsConfig.maximumCharge + minimumCharge = groupedWithMinMaxThresholdsConfig.minimumCharge + perUnitRate = groupedWithMinMaxThresholdsConfig.perUnitRate additionalProperties = groupedWithMinMaxThresholdsConfig.additionalProperties .toMutableMap() } + /** The event property used to group before applying thresholds */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The maximum amount to charge each group */ + fun maximumCharge(maximumCharge: String) = + maximumCharge(JsonField.of(maximumCharge)) + + /** + * Sets [Builder.maximumCharge] to an arbitrary JSON value. + * + * You should usually call [Builder.maximumCharge] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun maximumCharge(maximumCharge: JsonField) = apply { + this.maximumCharge = maximumCharge + } + + /** The minimum amount to charge each group, regardless of usage */ + fun minimumCharge(minimumCharge: String) = + minimumCharge(JsonField.of(minimumCharge)) + + /** + * Sets [Builder.minimumCharge] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumCharge] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun minimumCharge(minimumCharge: JsonField) = apply { + this.minimumCharge = minimumCharge + } + + /** The base price charged per group */ + fun perUnitRate(perUnitRate: String) = + perUnitRate(JsonField.of(perUnitRate)) + + /** + * Sets [Builder.perUnitRate] to an arbitrary JSON value. + * + * You should usually call [Builder.perUnitRate] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun perUnitRate(perUnitRate: JsonField) = apply { + this.perUnitRate = perUnitRate + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -4130,9 +4305,25 @@ private constructor( * Returns an immutable instance of [GroupedWithMinMaxThresholdsConfig]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .maximumCharge() + * .minimumCharge() + * .perUnitRate() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ fun build(): GroupedWithMinMaxThresholdsConfig = - GroupedWithMinMaxThresholdsConfig(additionalProperties.toImmutable()) + GroupedWithMinMaxThresholdsConfig( + checkRequired("groupingKey", groupingKey), + checkRequired("maximumCharge", maximumCharge), + checkRequired("minimumCharge", minimumCharge), + checkRequired("perUnitRate", perUnitRate), + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false @@ -4142,6 +4333,10 @@ private constructor( return@apply } + groupingKey() + maximumCharge() + minimumCharge() + perUnitRate() validated = true } @@ -4160,9 +4355,10 @@ private constructor( * Used for best match union deserialization. */ internal fun validity(): Int = - additionalProperties.count { (_, value) -> - !value.isNull() && !value.isMissing() - } + (if (groupingKey.asKnown() == null) 0 else 1) + + (if (maximumCharge.asKnown() == null) 0 else 1) + + (if (minimumCharge.asKnown() == null) 0 else 1) + + (if (perUnitRate.asKnown() == null) 0 else 1) override fun equals(other: Any?): Boolean { if (this === other) { @@ -4170,15 +4366,27 @@ private constructor( } return other is GroupedWithMinMaxThresholdsConfig && + groupingKey == other.groupingKey && + maximumCharge == other.maximumCharge && + minimumCharge == other.minimumCharge && + perUnitRate == other.perUnitRate && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + private val hashCode: Int by lazy { + Objects.hash( + groupingKey, + maximumCharge, + minimumCharge, + perUnitRate, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode override fun toString() = - "GroupedWithMinMaxThresholdsConfig{additionalProperties=$additionalProperties}" + "GroupedWithMinMaxThresholdsConfig{groupingKey=$groupingKey, maximumCharge=$maximumCharge, minimumCharge=$minimumCharge, perUnitRate=$perUnitRate, additionalProperties=$additionalProperties}" } /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceInterval.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceInterval.kt index 2bf52b000..36fdff885 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceInterval.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceInterval.kt @@ -477,18 +477,18 @@ private constructor( /** Alias for calling [price] with `Price.ofUnit(unit)`. */ fun price(unit: Price.Unit) = price(Price.ofUnit(unit)) - /** Alias for calling [price] with `Price.ofPackage(package_)`. */ - fun price(package_: Price.Package) = price(Price.ofPackage(package_)) - - /** Alias for calling [price] with `Price.ofMatrix(matrix)`. */ - fun price(matrix: Price.Matrix) = price(Price.ofMatrix(matrix)) - /** Alias for calling [price] with `Price.ofTiered(tiered)`. */ fun price(tiered: Price.Tiered) = price(Price.ofTiered(tiered)) /** Alias for calling [price] with `Price.ofBulk(bulk)`. */ fun price(bulk: Price.Bulk) = price(Price.ofBulk(bulk)) + /** Alias for calling [price] with `Price.ofPackage(package_)`. */ + fun price(package_: Price.Package) = price(Price.ofPackage(package_)) + + /** Alias for calling [price] with `Price.ofMatrix(matrix)`. */ + fun price(matrix: Price.Matrix) = price(Price.ofMatrix(matrix)) + /** Alias for calling [price] with `Price.ofThresholdTotalAmount(thresholdTotalAmount)`. */ fun price(thresholdTotalAmount: Price.ThresholdTotalAmount) = price(Price.ofThresholdTotalAmount(thresholdTotalAmount)) @@ -496,13 +496,13 @@ private constructor( /** Alias for calling [price] with `Price.ofTieredPackage(tieredPackage)`. */ fun price(tieredPackage: Price.TieredPackage) = price(Price.ofTieredPackage(tieredPackage)) - /** Alias for calling [price] with `Price.ofGroupedTiered(groupedTiered)`. */ - fun price(groupedTiered: Price.GroupedTiered) = price(Price.ofGroupedTiered(groupedTiered)) - /** Alias for calling [price] with `Price.ofTieredWithMinimum(tieredWithMinimum)`. */ fun price(tieredWithMinimum: Price.TieredWithMinimum) = price(Price.ofTieredWithMinimum(tieredWithMinimum)) + /** Alias for calling [price] with `Price.ofGroupedTiered(groupedTiered)`. */ + fun price(groupedTiered: Price.GroupedTiered) = price(Price.ofGroupedTiered(groupedTiered)) + /** * Alias for calling [price] with * `Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)`. @@ -536,6 +536,10 @@ private constructor( fun price(groupedAllocation: Price.GroupedAllocation) = price(Price.ofGroupedAllocation(groupedAllocation)) + /** Alias for calling [price] with `Price.ofBulkWithProration(bulkWithProration)`. */ + fun price(bulkWithProration: Price.BulkWithProration) = + price(Price.ofBulkWithProration(bulkWithProration)) + /** * Alias for calling [price] with * `Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)`. @@ -550,16 +554,19 @@ private constructor( fun price(groupedWithMeteredMinimum: Price.GroupedWithMeteredMinimum) = price(Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)) + /** + * Alias for calling [price] with + * `Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)`. + */ + fun price(groupedWithMinMaxThresholds: Price.GroupedWithMinMaxThresholds) = + price(Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)) + /** * Alias for calling [price] with `Price.ofMatrixWithDisplayName(matrixWithDisplayName)`. */ fun price(matrixWithDisplayName: Price.MatrixWithDisplayName) = price(Price.ofMatrixWithDisplayName(matrixWithDisplayName)) - /** Alias for calling [price] with `Price.ofBulkWithProration(bulkWithProration)`. */ - fun price(bulkWithProration: Price.BulkWithProration) = - price(Price.ofBulkWithProration(bulkWithProration)) - /** Alias for calling [price] with `Price.ofGroupedTieredPackage(groupedTieredPackage)`. */ fun price(groupedTieredPackage: Price.GroupedTieredPackage) = price(Price.ofGroupedTieredPackage(groupedTieredPackage)) @@ -590,13 +597,6 @@ private constructor( fun price(cumulativeGroupedBulk: Price.CumulativeGroupedBulk) = price(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) - /** - * Alias for calling [price] with - * `Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)`. - */ - fun price(groupedWithMinMaxThresholds: Price.GroupedWithMinMaxThresholds) = - price(Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)) - /** Alias for calling [price] with `Price.ofMinimum(minimum)`. */ fun price(minimum: Price.Minimum) = price(Price.ofMinimum(minimum)) diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceListPageResponse.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceListPageResponse.kt index 46e7c76a5..6219ba88e 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceListPageResponse.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceListPageResponse.kt @@ -129,18 +129,18 @@ private constructor( /** Alias for calling [addData] with `Price.ofUnit(unit)`. */ fun addData(unit: Price.Unit) = addData(Price.ofUnit(unit)) - /** Alias for calling [addData] with `Price.ofPackage(package_)`. */ - fun addData(package_: Price.Package) = addData(Price.ofPackage(package_)) - - /** Alias for calling [addData] with `Price.ofMatrix(matrix)`. */ - fun addData(matrix: Price.Matrix) = addData(Price.ofMatrix(matrix)) - /** Alias for calling [addData] with `Price.ofTiered(tiered)`. */ fun addData(tiered: Price.Tiered) = addData(Price.ofTiered(tiered)) /** Alias for calling [addData] with `Price.ofBulk(bulk)`. */ fun addData(bulk: Price.Bulk) = addData(Price.ofBulk(bulk)) + /** Alias for calling [addData] with `Price.ofPackage(package_)`. */ + fun addData(package_: Price.Package) = addData(Price.ofPackage(package_)) + + /** Alias for calling [addData] with `Price.ofMatrix(matrix)`. */ + fun addData(matrix: Price.Matrix) = addData(Price.ofMatrix(matrix)) + /** * Alias for calling [addData] with `Price.ofThresholdTotalAmount(thresholdTotalAmount)`. */ @@ -151,14 +151,14 @@ private constructor( fun addData(tieredPackage: Price.TieredPackage) = addData(Price.ofTieredPackage(tieredPackage)) - /** Alias for calling [addData] with `Price.ofGroupedTiered(groupedTiered)`. */ - fun addData(groupedTiered: Price.GroupedTiered) = - addData(Price.ofGroupedTiered(groupedTiered)) - /** Alias for calling [addData] with `Price.ofTieredWithMinimum(tieredWithMinimum)`. */ fun addData(tieredWithMinimum: Price.TieredWithMinimum) = addData(Price.ofTieredWithMinimum(tieredWithMinimum)) + /** Alias for calling [addData] with `Price.ofGroupedTiered(groupedTiered)`. */ + fun addData(groupedTiered: Price.GroupedTiered) = + addData(Price.ofGroupedTiered(groupedTiered)) + /** * Alias for calling [addData] with * `Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)`. @@ -194,6 +194,10 @@ private constructor( fun addData(groupedAllocation: Price.GroupedAllocation) = addData(Price.ofGroupedAllocation(groupedAllocation)) + /** Alias for calling [addData] with `Price.ofBulkWithProration(bulkWithProration)`. */ + fun addData(bulkWithProration: Price.BulkWithProration) = + addData(Price.ofBulkWithProration(bulkWithProration)) + /** * Alias for calling [addData] with * `Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)`. @@ -208,16 +212,19 @@ private constructor( fun addData(groupedWithMeteredMinimum: Price.GroupedWithMeteredMinimum) = addData(Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)) + /** + * Alias for calling [addData] with + * `Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)`. + */ + fun addData(groupedWithMinMaxThresholds: Price.GroupedWithMinMaxThresholds) = + addData(Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)) + /** * Alias for calling [addData] with `Price.ofMatrixWithDisplayName(matrixWithDisplayName)`. */ fun addData(matrixWithDisplayName: Price.MatrixWithDisplayName) = addData(Price.ofMatrixWithDisplayName(matrixWithDisplayName)) - /** Alias for calling [addData] with `Price.ofBulkWithProration(bulkWithProration)`. */ - fun addData(bulkWithProration: Price.BulkWithProration) = - addData(Price.ofBulkWithProration(bulkWithProration)) - /** * Alias for calling [addData] with `Price.ofGroupedTieredPackage(groupedTieredPackage)`. */ @@ -250,13 +257,6 @@ private constructor( fun addData(cumulativeGroupedBulk: Price.CumulativeGroupedBulk) = addData(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) - /** - * Alias for calling [addData] with - * `Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)`. - */ - fun addData(groupedWithMinMaxThresholds: Price.GroupedWithMinMaxThresholds) = - addData(Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)) - /** Alias for calling [addData] with `Price.ofMinimum(minimum)`. */ fun addData(minimum: Price.Minimum) = addData(Price.ofMinimum(minimum)) diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionCreateParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionCreateParams.kt index b372b5e53..afe06561e 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionCreateParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionCreateParams.kt @@ -4237,7 +4237,7 @@ private constructor( fun planPhaseOrder(): Long? = planPhaseOrder.getNullable("plan_phase_order") /** - * The definition of a new price to create and add to the subscription. + * New subscription price request body params. * * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -4542,7 +4542,7 @@ private constructor( this.planPhaseOrder = planPhaseOrder } - /** The definition of a new price to create and add to the subscription. */ + /** New subscription price request body params. */ fun price(price: Price?) = price(JsonField.ofNullable(price)) /** @@ -4557,18 +4557,18 @@ private constructor( /** Alias for calling [price] with `Price.ofUnit(unit)`. */ fun price(unit: NewSubscriptionUnitPrice) = price(Price.ofUnit(unit)) - /** Alias for calling [price] with `Price.ofPackage(package_)`. */ - fun price(package_: NewSubscriptionPackagePrice) = price(Price.ofPackage(package_)) - - /** Alias for calling [price] with `Price.ofMatrix(matrix)`. */ - fun price(matrix: NewSubscriptionMatrixPrice) = price(Price.ofMatrix(matrix)) - /** Alias for calling [price] with `Price.ofTiered(tiered)`. */ fun price(tiered: NewSubscriptionTieredPrice) = price(Price.ofTiered(tiered)) /** Alias for calling [price] with `Price.ofBulk(bulk)`. */ fun price(bulk: NewSubscriptionBulkPrice) = price(Price.ofBulk(bulk)) + /** Alias for calling [price] with `Price.ofPackage(package_)`. */ + fun price(package_: NewSubscriptionPackagePrice) = price(Price.ofPackage(package_)) + + /** Alias for calling [price] with `Price.ofMatrix(matrix)`. */ + fun price(matrix: NewSubscriptionMatrixPrice) = price(Price.ofMatrix(matrix)) + /** * Alias for calling [price] with `Price.ofThresholdTotalAmount(thresholdTotalAmount)`. */ @@ -4583,9 +4583,16 @@ private constructor( fun price(tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice) = price(Price.ofTieredWithMinimum(tieredWithMinimum)) - /** Alias for calling [price] with `Price.ofUnitWithPercent(unitWithPercent)`. */ - fun price(unitWithPercent: NewSubscriptionUnitWithPercentPrice) = - price(Price.ofUnitWithPercent(unitWithPercent)) + /** Alias for calling [price] with `Price.ofGroupedTiered(groupedTiered)`. */ + fun price(groupedTiered: NewSubscriptionGroupedTieredPrice) = + price(Price.ofGroupedTiered(groupedTiered)) + + /** + * Alias for calling [price] with + * `Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)`. + */ + fun price(tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice) = + price(Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)) /** * Alias for calling [price] with @@ -4594,10 +4601,20 @@ private constructor( fun price(packageWithAllocation: NewSubscriptionPackageWithAllocationPrice) = price(Price.ofPackageWithAllocation(packageWithAllocation)) + /** Alias for calling [price] with `Price.ofUnitWithPercent(unitWithPercent)`. */ + fun price(unitWithPercent: NewSubscriptionUnitWithPercentPrice) = + price(Price.ofUnitWithPercent(unitWithPercent)) + + /** + * Alias for calling [price] with `Price.ofMatrixWithAllocation(matrixWithAllocation)`. + */ + fun price(matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice) = + price(Price.ofMatrixWithAllocation(matrixWithAllocation)) + /** * Alias for calling [price] with `Price.ofTieredWithProration(tieredWithProration)`. */ - fun price(tieredWithProration: NewSubscriptionTierWithProrationPrice) = + fun price(tieredWithProration: Price.TieredWithProration) = price(Price.ofTieredWithProration(tieredWithProration)) /** Alias for calling [price] with `Price.ofUnitWithProration(unitWithProration)`. */ @@ -4608,53 +4625,30 @@ private constructor( fun price(groupedAllocation: NewSubscriptionGroupedAllocationPrice) = price(Price.ofGroupedAllocation(groupedAllocation)) - /** - * Alias for calling [price] with - * `Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)`. - */ - fun price(groupedWithProratedMinimum: NewSubscriptionGroupedWithProratedMinimumPrice) = - price(Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)) - /** Alias for calling [price] with `Price.ofBulkWithProration(bulkWithProration)`. */ fun price(bulkWithProration: NewSubscriptionBulkWithProrationPrice) = price(Price.ofBulkWithProration(bulkWithProration)) /** * Alias for calling [price] with - * `Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)`. - */ - fun price( - scalableMatrixWithUnitPricing: NewSubscriptionScalableMatrixWithUnitPricingPrice - ) = price(Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)) - - /** - * Alias for calling [price] with - * `Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)`. - */ - fun price( - scalableMatrixWithTieredPricing: NewSubscriptionScalableMatrixWithTieredPricingPrice - ) = price(Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)) - - /** - * Alias for calling [price] with - * `Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)`. + * `Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)`. */ - fun price(cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice) = - price(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) + fun price(groupedWithProratedMinimum: NewSubscriptionGroupedWithProratedMinimumPrice) = + price(Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)) /** * Alias for calling [price] with - * `Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)`. + * `Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)`. */ - fun price(maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice) = - price(Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)) + fun price(groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice) = + price(Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)) /** * Alias for calling [price] with - * `Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)`. + * `Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)`. */ - fun price(groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice) = - price(Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)) + fun price(groupedWithMinMaxThresholds: Price.GroupedWithMinMaxThresholds) = + price(Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)) /** * Alias for calling [price] with @@ -4670,28 +4664,34 @@ private constructor( price(Price.ofGroupedTieredPackage(groupedTieredPackage)) /** - * Alias for calling [price] with `Price.ofMatrixWithAllocation(matrixWithAllocation)`. + * Alias for calling [price] with + * `Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)`. */ - fun price(matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice) = - price(Price.ofMatrixWithAllocation(matrixWithAllocation)) + fun price(maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice) = + price(Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)) /** * Alias for calling [price] with - * `Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)`. + * `Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)`. */ - fun price(tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice) = - price(Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)) + fun price( + scalableMatrixWithUnitPricing: NewSubscriptionScalableMatrixWithUnitPricingPrice + ) = price(Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)) - /** Alias for calling [price] with `Price.ofGroupedTiered(groupedTiered)`. */ - fun price(groupedTiered: NewSubscriptionGroupedTieredPrice) = - price(Price.ofGroupedTiered(groupedTiered)) + /** + * Alias for calling [price] with + * `Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)`. + */ + fun price( + scalableMatrixWithTieredPricing: NewSubscriptionScalableMatrixWithTieredPricingPrice + ) = price(Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)) /** * Alias for calling [price] with - * `Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)`. + * `Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)`. */ - fun price(groupedWithMinMaxThresholds: Price.GroupedWithMinMaxThresholds) = - price(Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)) + fun price(cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice) = + price(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) /** Alias for calling [price] with `Price.ofMinimum(minimum)`. */ fun price(minimum: NewSubscriptionMinimumCompositePrice) = @@ -4813,28 +4813,38 @@ private constructor( (if (priceId.asKnown() == null) 0 else 1) + (if (startDate.asKnown() == null) 0 else 1) - /** The definition of a new price to create and add to the subscription. */ + /** New subscription price request body params. */ @JsonDeserialize(using = Price.Deserializer::class) @JsonSerialize(using = Price.Serializer::class) class Price private constructor( private val unit: NewSubscriptionUnitPrice? = null, - private val package_: NewSubscriptionPackagePrice? = null, - private val matrix: NewSubscriptionMatrixPrice? = null, private val tiered: NewSubscriptionTieredPrice? = null, private val bulk: NewSubscriptionBulkPrice? = null, + private val package_: NewSubscriptionPackagePrice? = null, + private val matrix: NewSubscriptionMatrixPrice? = null, private val thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice? = null, private val tieredPackage: NewSubscriptionTieredPackagePrice? = null, private val tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice? = null, - private val unitWithPercent: NewSubscriptionUnitWithPercentPrice? = null, + private val groupedTiered: NewSubscriptionGroupedTieredPrice? = null, + private val tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice? = + null, private val packageWithAllocation: NewSubscriptionPackageWithAllocationPrice? = null, - private val tieredWithProration: NewSubscriptionTierWithProrationPrice? = null, + private val unitWithPercent: NewSubscriptionUnitWithPercentPrice? = null, + private val matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice? = null, + private val tieredWithProration: TieredWithProration? = null, private val unitWithProration: NewSubscriptionUnitWithProrationPrice? = null, private val groupedAllocation: NewSubscriptionGroupedAllocationPrice? = null, + private val bulkWithProration: NewSubscriptionBulkWithProrationPrice? = null, private val groupedWithProratedMinimum: NewSubscriptionGroupedWithProratedMinimumPrice? = null, - private val bulkWithProration: NewSubscriptionBulkWithProrationPrice? = null, + private val groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice? = + null, + private val groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds? = null, + private val matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice? = null, + private val groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice? = null, + private val maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice? = null, private val scalableMatrixWithUnitPricing: NewSubscriptionScalableMatrixWithUnitPricingPrice? = null, @@ -4842,30 +4852,20 @@ private constructor( NewSubscriptionScalableMatrixWithTieredPricingPrice? = null, private val cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice? = null, - private val maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice? = null, - private val groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice? = - null, - private val matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice? = null, - private val groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice? = null, - private val matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice? = null, - private val tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice? = - null, - private val groupedTiered: NewSubscriptionGroupedTieredPrice? = null, - private val groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds? = null, private val minimum: NewSubscriptionMinimumCompositePrice? = null, private val _json: JsonValue? = null, ) { fun unit(): NewSubscriptionUnitPrice? = unit - fun package_(): NewSubscriptionPackagePrice? = package_ - - fun matrix(): NewSubscriptionMatrixPrice? = matrix - fun tiered(): NewSubscriptionTieredPrice? = tiered fun bulk(): NewSubscriptionBulkPrice? = bulk + fun package_(): NewSubscriptionPackagePrice? = package_ + + fun matrix(): NewSubscriptionMatrixPrice? = matrix + fun thresholdTotalAmount(): NewSubscriptionThresholdTotalAmountPrice? = thresholdTotalAmount @@ -4873,122 +4873,122 @@ private constructor( fun tieredWithMinimum(): NewSubscriptionTieredWithMinimumPrice? = tieredWithMinimum - fun unitWithPercent(): NewSubscriptionUnitWithPercentPrice? = unitWithPercent + fun groupedTiered(): NewSubscriptionGroupedTieredPrice? = groupedTiered + + fun tieredPackageWithMinimum(): NewSubscriptionTieredPackageWithMinimumPrice? = + tieredPackageWithMinimum fun packageWithAllocation(): NewSubscriptionPackageWithAllocationPrice? = packageWithAllocation - fun tieredWithProration(): NewSubscriptionTierWithProrationPrice? = tieredWithProration + fun unitWithPercent(): NewSubscriptionUnitWithPercentPrice? = unitWithPercent + + fun matrixWithAllocation(): NewSubscriptionMatrixWithAllocationPrice? = + matrixWithAllocation + + fun tieredWithProration(): TieredWithProration? = tieredWithProration fun unitWithProration(): NewSubscriptionUnitWithProrationPrice? = unitWithProration fun groupedAllocation(): NewSubscriptionGroupedAllocationPrice? = groupedAllocation - fun groupedWithProratedMinimum(): NewSubscriptionGroupedWithProratedMinimumPrice? = - groupedWithProratedMinimum - fun bulkWithProration(): NewSubscriptionBulkWithProrationPrice? = bulkWithProration - fun scalableMatrixWithUnitPricing(): - NewSubscriptionScalableMatrixWithUnitPricingPrice? = scalableMatrixWithUnitPricing - - fun scalableMatrixWithTieredPricing(): - NewSubscriptionScalableMatrixWithTieredPricingPrice? = - scalableMatrixWithTieredPricing - - fun cumulativeGroupedBulk(): NewSubscriptionCumulativeGroupedBulkPrice? = - cumulativeGroupedBulk - - fun maxGroupTieredPackage(): NewSubscriptionMaxGroupTieredPackagePrice? = - maxGroupTieredPackage + fun groupedWithProratedMinimum(): NewSubscriptionGroupedWithProratedMinimumPrice? = + groupedWithProratedMinimum fun groupedWithMeteredMinimum(): NewSubscriptionGroupedWithMeteredMinimumPrice? = groupedWithMeteredMinimum + fun groupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds? = + groupedWithMinMaxThresholds + fun matrixWithDisplayName(): NewSubscriptionMatrixWithDisplayNamePrice? = matrixWithDisplayName fun groupedTieredPackage(): NewSubscriptionGroupedTieredPackagePrice? = groupedTieredPackage - fun matrixWithAllocation(): NewSubscriptionMatrixWithAllocationPrice? = - matrixWithAllocation + fun maxGroupTieredPackage(): NewSubscriptionMaxGroupTieredPackagePrice? = + maxGroupTieredPackage - fun tieredPackageWithMinimum(): NewSubscriptionTieredPackageWithMinimumPrice? = - tieredPackageWithMinimum + fun scalableMatrixWithUnitPricing(): + NewSubscriptionScalableMatrixWithUnitPricingPrice? = scalableMatrixWithUnitPricing - fun groupedTiered(): NewSubscriptionGroupedTieredPrice? = groupedTiered + fun scalableMatrixWithTieredPricing(): + NewSubscriptionScalableMatrixWithTieredPricingPrice? = + scalableMatrixWithTieredPricing - fun groupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds? = - groupedWithMinMaxThresholds + fun cumulativeGroupedBulk(): NewSubscriptionCumulativeGroupedBulkPrice? = + cumulativeGroupedBulk fun minimum(): NewSubscriptionMinimumCompositePrice? = minimum fun isUnit(): Boolean = unit != null - fun isPackage(): Boolean = package_ != null - - fun isMatrix(): Boolean = matrix != null - fun isTiered(): Boolean = tiered != null fun isBulk(): Boolean = bulk != null + fun isPackage(): Boolean = package_ != null + + fun isMatrix(): Boolean = matrix != null + fun isThresholdTotalAmount(): Boolean = thresholdTotalAmount != null fun isTieredPackage(): Boolean = tieredPackage != null fun isTieredWithMinimum(): Boolean = tieredWithMinimum != null - fun isUnitWithPercent(): Boolean = unitWithPercent != null + fun isGroupedTiered(): Boolean = groupedTiered != null + + fun isTieredPackageWithMinimum(): Boolean = tieredPackageWithMinimum != null fun isPackageWithAllocation(): Boolean = packageWithAllocation != null + fun isUnitWithPercent(): Boolean = unitWithPercent != null + + fun isMatrixWithAllocation(): Boolean = matrixWithAllocation != null + fun isTieredWithProration(): Boolean = tieredWithProration != null fun isUnitWithProration(): Boolean = unitWithProration != null fun isGroupedAllocation(): Boolean = groupedAllocation != null - fun isGroupedWithProratedMinimum(): Boolean = groupedWithProratedMinimum != null - fun isBulkWithProration(): Boolean = bulkWithProration != null - fun isScalableMatrixWithUnitPricing(): Boolean = scalableMatrixWithUnitPricing != null - - fun isScalableMatrixWithTieredPricing(): Boolean = - scalableMatrixWithTieredPricing != null - - fun isCumulativeGroupedBulk(): Boolean = cumulativeGroupedBulk != null - - fun isMaxGroupTieredPackage(): Boolean = maxGroupTieredPackage != null + fun isGroupedWithProratedMinimum(): Boolean = groupedWithProratedMinimum != null fun isGroupedWithMeteredMinimum(): Boolean = groupedWithMeteredMinimum != null + fun isGroupedWithMinMaxThresholds(): Boolean = groupedWithMinMaxThresholds != null + fun isMatrixWithDisplayName(): Boolean = matrixWithDisplayName != null fun isGroupedTieredPackage(): Boolean = groupedTieredPackage != null - fun isMatrixWithAllocation(): Boolean = matrixWithAllocation != null + fun isMaxGroupTieredPackage(): Boolean = maxGroupTieredPackage != null - fun isTieredPackageWithMinimum(): Boolean = tieredPackageWithMinimum != null + fun isScalableMatrixWithUnitPricing(): Boolean = scalableMatrixWithUnitPricing != null - fun isGroupedTiered(): Boolean = groupedTiered != null + fun isScalableMatrixWithTieredPricing(): Boolean = + scalableMatrixWithTieredPricing != null - fun isGroupedWithMinMaxThresholds(): Boolean = groupedWithMinMaxThresholds != null + fun isCumulativeGroupedBulk(): Boolean = cumulativeGroupedBulk != null fun isMinimum(): Boolean = minimum != null fun asUnit(): NewSubscriptionUnitPrice = unit.getOrThrow("unit") - fun asPackage(): NewSubscriptionPackagePrice = package_.getOrThrow("package_") - - fun asMatrix(): NewSubscriptionMatrixPrice = matrix.getOrThrow("matrix") - fun asTiered(): NewSubscriptionTieredPrice = tiered.getOrThrow("tiered") fun asBulk(): NewSubscriptionBulkPrice = bulk.getOrThrow("bulk") + fun asPackage(): NewSubscriptionPackagePrice = package_.getOrThrow("package_") + + fun asMatrix(): NewSubscriptionMatrixPrice = matrix.getOrThrow("matrix") + fun asThresholdTotalAmount(): NewSubscriptionThresholdTotalAmountPrice = thresholdTotalAmount.getOrThrow("thresholdTotalAmount") @@ -4998,13 +4998,22 @@ private constructor( fun asTieredWithMinimum(): NewSubscriptionTieredWithMinimumPrice = tieredWithMinimum.getOrThrow("tieredWithMinimum") - fun asUnitWithPercent(): NewSubscriptionUnitWithPercentPrice = - unitWithPercent.getOrThrow("unitWithPercent") + fun asGroupedTiered(): NewSubscriptionGroupedTieredPrice = + groupedTiered.getOrThrow("groupedTiered") + + fun asTieredPackageWithMinimum(): NewSubscriptionTieredPackageWithMinimumPrice = + tieredPackageWithMinimum.getOrThrow("tieredPackageWithMinimum") fun asPackageWithAllocation(): NewSubscriptionPackageWithAllocationPrice = packageWithAllocation.getOrThrow("packageWithAllocation") - fun asTieredWithProration(): NewSubscriptionTierWithProrationPrice = + fun asUnitWithPercent(): NewSubscriptionUnitWithPercentPrice = + unitWithPercent.getOrThrow("unitWithPercent") + + fun asMatrixWithAllocation(): NewSubscriptionMatrixWithAllocationPrice = + matrixWithAllocation.getOrThrow("matrixWithAllocation") + + fun asTieredWithProration(): TieredWithProration = tieredWithProration.getOrThrow("tieredWithProration") fun asUnitWithProration(): NewSubscriptionUnitWithProrationPrice = @@ -5013,46 +5022,37 @@ private constructor( fun asGroupedAllocation(): NewSubscriptionGroupedAllocationPrice = groupedAllocation.getOrThrow("groupedAllocation") - fun asGroupedWithProratedMinimum(): NewSubscriptionGroupedWithProratedMinimumPrice = - groupedWithProratedMinimum.getOrThrow("groupedWithProratedMinimum") - fun asBulkWithProration(): NewSubscriptionBulkWithProrationPrice = bulkWithProration.getOrThrow("bulkWithProration") - fun asScalableMatrixWithUnitPricing(): - NewSubscriptionScalableMatrixWithUnitPricingPrice = - scalableMatrixWithUnitPricing.getOrThrow("scalableMatrixWithUnitPricing") - - fun asScalableMatrixWithTieredPricing(): - NewSubscriptionScalableMatrixWithTieredPricingPrice = - scalableMatrixWithTieredPricing.getOrThrow("scalableMatrixWithTieredPricing") - - fun asCumulativeGroupedBulk(): NewSubscriptionCumulativeGroupedBulkPrice = - cumulativeGroupedBulk.getOrThrow("cumulativeGroupedBulk") - - fun asMaxGroupTieredPackage(): NewSubscriptionMaxGroupTieredPackagePrice = - maxGroupTieredPackage.getOrThrow("maxGroupTieredPackage") + fun asGroupedWithProratedMinimum(): NewSubscriptionGroupedWithProratedMinimumPrice = + groupedWithProratedMinimum.getOrThrow("groupedWithProratedMinimum") fun asGroupedWithMeteredMinimum(): NewSubscriptionGroupedWithMeteredMinimumPrice = groupedWithMeteredMinimum.getOrThrow("groupedWithMeteredMinimum") + fun asGroupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds = + groupedWithMinMaxThresholds.getOrThrow("groupedWithMinMaxThresholds") + fun asMatrixWithDisplayName(): NewSubscriptionMatrixWithDisplayNamePrice = matrixWithDisplayName.getOrThrow("matrixWithDisplayName") fun asGroupedTieredPackage(): NewSubscriptionGroupedTieredPackagePrice = groupedTieredPackage.getOrThrow("groupedTieredPackage") - fun asMatrixWithAllocation(): NewSubscriptionMatrixWithAllocationPrice = - matrixWithAllocation.getOrThrow("matrixWithAllocation") + fun asMaxGroupTieredPackage(): NewSubscriptionMaxGroupTieredPackagePrice = + maxGroupTieredPackage.getOrThrow("maxGroupTieredPackage") - fun asTieredPackageWithMinimum(): NewSubscriptionTieredPackageWithMinimumPrice = - tieredPackageWithMinimum.getOrThrow("tieredPackageWithMinimum") + fun asScalableMatrixWithUnitPricing(): + NewSubscriptionScalableMatrixWithUnitPricingPrice = + scalableMatrixWithUnitPricing.getOrThrow("scalableMatrixWithUnitPricing") - fun asGroupedTiered(): NewSubscriptionGroupedTieredPrice = - groupedTiered.getOrThrow("groupedTiered") + fun asScalableMatrixWithTieredPricing(): + NewSubscriptionScalableMatrixWithTieredPricingPrice = + scalableMatrixWithTieredPricing.getOrThrow("scalableMatrixWithTieredPricing") - fun asGroupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds = - groupedWithMinMaxThresholds.getOrThrow("groupedWithMinMaxThresholds") + fun asCumulativeGroupedBulk(): NewSubscriptionCumulativeGroupedBulkPrice = + cumulativeGroupedBulk.getOrThrow("cumulativeGroupedBulk") fun asMinimum(): NewSubscriptionMinimumCompositePrice = minimum.getOrThrow("minimum") @@ -5061,24 +5061,39 @@ private constructor( fun accept(visitor: Visitor): T = when { unit != null -> visitor.visitUnit(unit) - package_ != null -> visitor.visitPackage(package_) - matrix != null -> visitor.visitMatrix(matrix) tiered != null -> visitor.visitTiered(tiered) bulk != null -> visitor.visitBulk(bulk) + package_ != null -> visitor.visitPackage(package_) + matrix != null -> visitor.visitMatrix(matrix) thresholdTotalAmount != null -> visitor.visitThresholdTotalAmount(thresholdTotalAmount) tieredPackage != null -> visitor.visitTieredPackage(tieredPackage) tieredWithMinimum != null -> visitor.visitTieredWithMinimum(tieredWithMinimum) - unitWithPercent != null -> visitor.visitUnitWithPercent(unitWithPercent) + groupedTiered != null -> visitor.visitGroupedTiered(groupedTiered) + tieredPackageWithMinimum != null -> + visitor.visitTieredPackageWithMinimum(tieredPackageWithMinimum) packageWithAllocation != null -> visitor.visitPackageWithAllocation(packageWithAllocation) + unitWithPercent != null -> visitor.visitUnitWithPercent(unitWithPercent) + matrixWithAllocation != null -> + visitor.visitMatrixWithAllocation(matrixWithAllocation) tieredWithProration != null -> visitor.visitTieredWithProration(tieredWithProration) unitWithProration != null -> visitor.visitUnitWithProration(unitWithProration) groupedAllocation != null -> visitor.visitGroupedAllocation(groupedAllocation) + bulkWithProration != null -> visitor.visitBulkWithProration(bulkWithProration) groupedWithProratedMinimum != null -> visitor.visitGroupedWithProratedMinimum(groupedWithProratedMinimum) - bulkWithProration != null -> visitor.visitBulkWithProration(bulkWithProration) + groupedWithMeteredMinimum != null -> + visitor.visitGroupedWithMeteredMinimum(groupedWithMeteredMinimum) + groupedWithMinMaxThresholds != null -> + visitor.visitGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds) + matrixWithDisplayName != null -> + visitor.visitMatrixWithDisplayName(matrixWithDisplayName) + groupedTieredPackage != null -> + visitor.visitGroupedTieredPackage(groupedTieredPackage) + maxGroupTieredPackage != null -> + visitor.visitMaxGroupTieredPackage(maxGroupTieredPackage) scalableMatrixWithUnitPricing != null -> visitor.visitScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing) scalableMatrixWithTieredPricing != null -> @@ -5087,21 +5102,6 @@ private constructor( ) cumulativeGroupedBulk != null -> visitor.visitCumulativeGroupedBulk(cumulativeGroupedBulk) - maxGroupTieredPackage != null -> - visitor.visitMaxGroupTieredPackage(maxGroupTieredPackage) - groupedWithMeteredMinimum != null -> - visitor.visitGroupedWithMeteredMinimum(groupedWithMeteredMinimum) - matrixWithDisplayName != null -> - visitor.visitMatrixWithDisplayName(matrixWithDisplayName) - groupedTieredPackage != null -> - visitor.visitGroupedTieredPackage(groupedTieredPackage) - matrixWithAllocation != null -> - visitor.visitMatrixWithAllocation(matrixWithAllocation) - tieredPackageWithMinimum != null -> - visitor.visitTieredPackageWithMinimum(tieredPackageWithMinimum) - groupedTiered != null -> visitor.visitGroupedTiered(groupedTiered) - groupedWithMinMaxThresholds != null -> - visitor.visitGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds) minimum != null -> visitor.visitMinimum(minimum) else -> visitor.unknown(_json) } @@ -5119,14 +5119,6 @@ private constructor( unit.validate() } - override fun visitPackage(package_: NewSubscriptionPackagePrice) { - package_.validate() - } - - override fun visitMatrix(matrix: NewSubscriptionMatrixPrice) { - matrix.validate() - } - override fun visitTiered(tiered: NewSubscriptionTieredPrice) { tiered.validate() } @@ -5135,6 +5127,14 @@ private constructor( bulk.validate() } + override fun visitPackage(package_: NewSubscriptionPackagePrice) { + package_.validate() + } + + override fun visitMatrix(matrix: NewSubscriptionMatrixPrice) { + matrix.validate() + } + override fun visitThresholdTotalAmount( thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice ) { @@ -5153,10 +5153,16 @@ private constructor( tieredWithMinimum.validate() } - override fun visitUnitWithPercent( - unitWithPercent: NewSubscriptionUnitWithPercentPrice + override fun visitGroupedTiered( + groupedTiered: NewSubscriptionGroupedTieredPrice ) { - unitWithPercent.validate() + groupedTiered.validate() + } + + override fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice + ) { + tieredPackageWithMinimum.validate() } override fun visitPackageWithAllocation( @@ -5165,8 +5171,20 @@ private constructor( packageWithAllocation.validate() } + override fun visitUnitWithPercent( + unitWithPercent: NewSubscriptionUnitWithPercentPrice + ) { + unitWithPercent.validate() + } + + override fun visitMatrixWithAllocation( + matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice + ) { + matrixWithAllocation.validate() + } + override fun visitTieredWithProration( - tieredWithProration: NewSubscriptionTierWithProrationPrice + tieredWithProration: TieredWithProration ) { tieredWithProration.validate() } @@ -5183,43 +5201,17 @@ private constructor( groupedAllocation.validate() } - override fun visitGroupedWithProratedMinimum( - groupedWithProratedMinimum: - NewSubscriptionGroupedWithProratedMinimumPrice - ) { - groupedWithProratedMinimum.validate() - } - override fun visitBulkWithProration( bulkWithProration: NewSubscriptionBulkWithProrationPrice ) { bulkWithProration.validate() } - override fun visitScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: - NewSubscriptionScalableMatrixWithUnitPricingPrice - ) { - scalableMatrixWithUnitPricing.validate() - } - - override fun visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: - NewSubscriptionScalableMatrixWithTieredPricingPrice - ) { - scalableMatrixWithTieredPricing.validate() - } - - override fun visitCumulativeGroupedBulk( - cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice - ) { - cumulativeGroupedBulk.validate() - } - - override fun visitMaxGroupTieredPackage( - maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice + override fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: + NewSubscriptionGroupedWithProratedMinimumPrice ) { - maxGroupTieredPackage.validate() + groupedWithProratedMinimum.validate() } override fun visitGroupedWithMeteredMinimum( @@ -5228,6 +5220,12 @@ private constructor( groupedWithMeteredMinimum.validate() } + override fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) { + groupedWithMinMaxThresholds.validate() + } + override fun visitMatrixWithDisplayName( matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice ) { @@ -5240,28 +5238,30 @@ private constructor( groupedTieredPackage.validate() } - override fun visitMatrixWithAllocation( - matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice + override fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice ) { - matrixWithAllocation.validate() + maxGroupTieredPackage.validate() } - override fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice + override fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: + NewSubscriptionScalableMatrixWithUnitPricingPrice ) { - tieredPackageWithMinimum.validate() + scalableMatrixWithUnitPricing.validate() } - override fun visitGroupedTiered( - groupedTiered: NewSubscriptionGroupedTieredPrice + override fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: + NewSubscriptionScalableMatrixWithTieredPricingPrice ) { - groupedTiered.validate() + scalableMatrixWithTieredPricing.validate() } - override fun visitGroupedWithMinMaxThresholds( - groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + override fun visitCumulativeGroupedBulk( + cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice ) { - groupedWithMinMaxThresholds.validate() + cumulativeGroupedBulk.validate() } override fun visitMinimum(minimum: NewSubscriptionMinimumCompositePrice) { @@ -5291,17 +5291,17 @@ private constructor( object : Visitor { override fun visitUnit(unit: NewSubscriptionUnitPrice) = unit.validity() + override fun visitTiered(tiered: NewSubscriptionTieredPrice) = + tiered.validity() + + override fun visitBulk(bulk: NewSubscriptionBulkPrice) = bulk.validity() + override fun visitPackage(package_: NewSubscriptionPackagePrice) = package_.validity() override fun visitMatrix(matrix: NewSubscriptionMatrixPrice) = matrix.validity() - override fun visitTiered(tiered: NewSubscriptionTieredPrice) = - tiered.validity() - - override fun visitBulk(bulk: NewSubscriptionBulkPrice) = bulk.validity() - override fun visitThresholdTotalAmount( thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice ) = thresholdTotalAmount.validity() @@ -5314,16 +5314,28 @@ private constructor( tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice ) = tieredWithMinimum.validity() - override fun visitUnitWithPercent( - unitWithPercent: NewSubscriptionUnitWithPercentPrice - ) = unitWithPercent.validity() + override fun visitGroupedTiered( + groupedTiered: NewSubscriptionGroupedTieredPrice + ) = groupedTiered.validity() + + override fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice + ) = tieredPackageWithMinimum.validity() override fun visitPackageWithAllocation( packageWithAllocation: NewSubscriptionPackageWithAllocationPrice ) = packageWithAllocation.validity() + override fun visitUnitWithPercent( + unitWithPercent: NewSubscriptionUnitWithPercentPrice + ) = unitWithPercent.validity() + + override fun visitMatrixWithAllocation( + matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice + ) = matrixWithAllocation.validity() + override fun visitTieredWithProration( - tieredWithProration: NewSubscriptionTierWithProrationPrice + tieredWithProration: TieredWithProration ) = tieredWithProration.validity() override fun visitUnitWithProration( @@ -5334,14 +5346,34 @@ private constructor( groupedAllocation: NewSubscriptionGroupedAllocationPrice ) = groupedAllocation.validity() + override fun visitBulkWithProration( + bulkWithProration: NewSubscriptionBulkWithProrationPrice + ) = bulkWithProration.validity() + override fun visitGroupedWithProratedMinimum( groupedWithProratedMinimum: NewSubscriptionGroupedWithProratedMinimumPrice ) = groupedWithProratedMinimum.validity() - override fun visitBulkWithProration( - bulkWithProration: NewSubscriptionBulkWithProrationPrice - ) = bulkWithProration.validity() + override fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice + ) = groupedWithMeteredMinimum.validity() + + override fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) = groupedWithMinMaxThresholds.validity() + + override fun visitMatrixWithDisplayName( + matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice + ) = matrixWithDisplayName.validity() + + override fun visitGroupedTieredPackage( + groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice + ) = groupedTieredPackage.validity() + + override fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice + ) = maxGroupTieredPackage.validity() override fun visitScalableMatrixWithUnitPricing( scalableMatrixWithUnitPricing: @@ -5357,152 +5389,120 @@ private constructor( cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice ) = cumulativeGroupedBulk.validity() - override fun visitMaxGroupTieredPackage( - maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice - ) = maxGroupTieredPackage.validity() - - override fun visitGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice - ) = groupedWithMeteredMinimum.validity() - - override fun visitMatrixWithDisplayName( - matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice - ) = matrixWithDisplayName.validity() + override fun visitMinimum(minimum: NewSubscriptionMinimumCompositePrice) = + minimum.validity() - override fun visitGroupedTieredPackage( - groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice - ) = groupedTieredPackage.validity() + override fun unknown(json: JsonValue?) = 0 + } + ) - override fun visitMatrixWithAllocation( - matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice - ) = matrixWithAllocation.validity() - - override fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice - ) = tieredPackageWithMinimum.validity() - - override fun visitGroupedTiered( - groupedTiered: NewSubscriptionGroupedTieredPrice - ) = groupedTiered.validity() - - override fun visitGroupedWithMinMaxThresholds( - groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds - ) = groupedWithMinMaxThresholds.validity() - - override fun visitMinimum(minimum: NewSubscriptionMinimumCompositePrice) = - minimum.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } return other is Price && unit == other.unit && - package_ == other.package_ && - matrix == other.matrix && tiered == other.tiered && bulk == other.bulk && + package_ == other.package_ && + matrix == other.matrix && thresholdTotalAmount == other.thresholdTotalAmount && tieredPackage == other.tieredPackage && tieredWithMinimum == other.tieredWithMinimum && - unitWithPercent == other.unitWithPercent && + groupedTiered == other.groupedTiered && + tieredPackageWithMinimum == other.tieredPackageWithMinimum && packageWithAllocation == other.packageWithAllocation && + unitWithPercent == other.unitWithPercent && + matrixWithAllocation == other.matrixWithAllocation && tieredWithProration == other.tieredWithProration && unitWithProration == other.unitWithProration && groupedAllocation == other.groupedAllocation && - groupedWithProratedMinimum == other.groupedWithProratedMinimum && bulkWithProration == other.bulkWithProration && - scalableMatrixWithUnitPricing == other.scalableMatrixWithUnitPricing && - scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && - cumulativeGroupedBulk == other.cumulativeGroupedBulk && - maxGroupTieredPackage == other.maxGroupTieredPackage && + groupedWithProratedMinimum == other.groupedWithProratedMinimum && groupedWithMeteredMinimum == other.groupedWithMeteredMinimum && + groupedWithMinMaxThresholds == other.groupedWithMinMaxThresholds && matrixWithDisplayName == other.matrixWithDisplayName && groupedTieredPackage == other.groupedTieredPackage && - matrixWithAllocation == other.matrixWithAllocation && - tieredPackageWithMinimum == other.tieredPackageWithMinimum && - groupedTiered == other.groupedTiered && - groupedWithMinMaxThresholds == other.groupedWithMinMaxThresholds && + maxGroupTieredPackage == other.maxGroupTieredPackage && + scalableMatrixWithUnitPricing == other.scalableMatrixWithUnitPricing && + scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && + cumulativeGroupedBulk == other.cumulativeGroupedBulk && minimum == other.minimum } override fun hashCode(): Int = Objects.hash( unit, - package_, - matrix, tiered, bulk, + package_, + matrix, thresholdTotalAmount, tieredPackage, tieredWithMinimum, - unitWithPercent, + groupedTiered, + tieredPackageWithMinimum, packageWithAllocation, + unitWithPercent, + matrixWithAllocation, tieredWithProration, unitWithProration, groupedAllocation, - groupedWithProratedMinimum, bulkWithProration, - scalableMatrixWithUnitPricing, - scalableMatrixWithTieredPricing, - cumulativeGroupedBulk, - maxGroupTieredPackage, + groupedWithProratedMinimum, groupedWithMeteredMinimum, + groupedWithMinMaxThresholds, matrixWithDisplayName, groupedTieredPackage, - matrixWithAllocation, - tieredPackageWithMinimum, - groupedTiered, - groupedWithMinMaxThresholds, + maxGroupTieredPackage, + scalableMatrixWithUnitPricing, + scalableMatrixWithTieredPricing, + cumulativeGroupedBulk, minimum, ) override fun toString(): String = when { unit != null -> "Price{unit=$unit}" - package_ != null -> "Price{package_=$package_}" - matrix != null -> "Price{matrix=$matrix}" tiered != null -> "Price{tiered=$tiered}" bulk != null -> "Price{bulk=$bulk}" + package_ != null -> "Price{package_=$package_}" + matrix != null -> "Price{matrix=$matrix}" thresholdTotalAmount != null -> "Price{thresholdTotalAmount=$thresholdTotalAmount}" tieredPackage != null -> "Price{tieredPackage=$tieredPackage}" tieredWithMinimum != null -> "Price{tieredWithMinimum=$tieredWithMinimum}" - unitWithPercent != null -> "Price{unitWithPercent=$unitWithPercent}" + groupedTiered != null -> "Price{groupedTiered=$groupedTiered}" + tieredPackageWithMinimum != null -> + "Price{tieredPackageWithMinimum=$tieredPackageWithMinimum}" packageWithAllocation != null -> "Price{packageWithAllocation=$packageWithAllocation}" + unitWithPercent != null -> "Price{unitWithPercent=$unitWithPercent}" + matrixWithAllocation != null -> + "Price{matrixWithAllocation=$matrixWithAllocation}" tieredWithProration != null -> "Price{tieredWithProration=$tieredWithProration}" unitWithProration != null -> "Price{unitWithProration=$unitWithProration}" groupedAllocation != null -> "Price{groupedAllocation=$groupedAllocation}" + bulkWithProration != null -> "Price{bulkWithProration=$bulkWithProration}" groupedWithProratedMinimum != null -> "Price{groupedWithProratedMinimum=$groupedWithProratedMinimum}" - bulkWithProration != null -> "Price{bulkWithProration=$bulkWithProration}" - scalableMatrixWithUnitPricing != null -> - "Price{scalableMatrixWithUnitPricing=$scalableMatrixWithUnitPricing}" - scalableMatrixWithTieredPricing != null -> - "Price{scalableMatrixWithTieredPricing=$scalableMatrixWithTieredPricing}" - cumulativeGroupedBulk != null -> - "Price{cumulativeGroupedBulk=$cumulativeGroupedBulk}" - maxGroupTieredPackage != null -> - "Price{maxGroupTieredPackage=$maxGroupTieredPackage}" groupedWithMeteredMinimum != null -> "Price{groupedWithMeteredMinimum=$groupedWithMeteredMinimum}" + groupedWithMinMaxThresholds != null -> + "Price{groupedWithMinMaxThresholds=$groupedWithMinMaxThresholds}" matrixWithDisplayName != null -> "Price{matrixWithDisplayName=$matrixWithDisplayName}" groupedTieredPackage != null -> "Price{groupedTieredPackage=$groupedTieredPackage}" - matrixWithAllocation != null -> - "Price{matrixWithAllocation=$matrixWithAllocation}" - tieredPackageWithMinimum != null -> - "Price{tieredPackageWithMinimum=$tieredPackageWithMinimum}" - groupedTiered != null -> "Price{groupedTiered=$groupedTiered}" - groupedWithMinMaxThresholds != null -> - "Price{groupedWithMinMaxThresholds=$groupedWithMinMaxThresholds}" + maxGroupTieredPackage != null -> + "Price{maxGroupTieredPackage=$maxGroupTieredPackage}" + scalableMatrixWithUnitPricing != null -> + "Price{scalableMatrixWithUnitPricing=$scalableMatrixWithUnitPricing}" + scalableMatrixWithTieredPricing != null -> + "Price{scalableMatrixWithTieredPricing=$scalableMatrixWithTieredPricing}" + cumulativeGroupedBulk != null -> + "Price{cumulativeGroupedBulk=$cumulativeGroupedBulk}" minimum != null -> "Price{minimum=$minimum}" _json != null -> "Price{_unknown=$_json}" else -> throw IllegalStateException("Invalid Price") @@ -5512,14 +5512,14 @@ private constructor( fun ofUnit(unit: NewSubscriptionUnitPrice) = Price(unit = unit) - fun ofPackage(package_: NewSubscriptionPackagePrice) = Price(package_ = package_) - - fun ofMatrix(matrix: NewSubscriptionMatrixPrice) = Price(matrix = matrix) - fun ofTiered(tiered: NewSubscriptionTieredPrice) = Price(tiered = tiered) fun ofBulk(bulk: NewSubscriptionBulkPrice) = Price(bulk = bulk) + fun ofPackage(package_: NewSubscriptionPackagePrice) = Price(package_ = package_) + + fun ofMatrix(matrix: NewSubscriptionMatrixPrice) = Price(matrix = matrix) + fun ofThresholdTotalAmount( thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice ) = Price(thresholdTotalAmount = thresholdTotalAmount) @@ -5530,16 +5530,26 @@ private constructor( fun ofTieredWithMinimum(tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice) = Price(tieredWithMinimum = tieredWithMinimum) - fun ofUnitWithPercent(unitWithPercent: NewSubscriptionUnitWithPercentPrice) = - Price(unitWithPercent = unitWithPercent) + fun ofGroupedTiered(groupedTiered: NewSubscriptionGroupedTieredPrice) = + Price(groupedTiered = groupedTiered) + + fun ofTieredPackageWithMinimum( + tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice + ) = Price(tieredPackageWithMinimum = tieredPackageWithMinimum) fun ofPackageWithAllocation( packageWithAllocation: NewSubscriptionPackageWithAllocationPrice ) = Price(packageWithAllocation = packageWithAllocation) - fun ofTieredWithProration( - tieredWithProration: NewSubscriptionTierWithProrationPrice - ) = Price(tieredWithProration = tieredWithProration) + fun ofUnitWithPercent(unitWithPercent: NewSubscriptionUnitWithPercentPrice) = + Price(unitWithPercent = unitWithPercent) + + fun ofMatrixWithAllocation( + matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice + ) = Price(matrixWithAllocation = matrixWithAllocation) + + fun ofTieredWithProration(tieredWithProration: TieredWithProration) = + Price(tieredWithProration = tieredWithProration) fun ofUnitWithProration(unitWithProration: NewSubscriptionUnitWithProrationPrice) = Price(unitWithProration = unitWithProration) @@ -5547,34 +5557,21 @@ private constructor( fun ofGroupedAllocation(groupedAllocation: NewSubscriptionGroupedAllocationPrice) = Price(groupedAllocation = groupedAllocation) - fun ofGroupedWithProratedMinimum( - groupedWithProratedMinimum: NewSubscriptionGroupedWithProratedMinimumPrice - ) = Price(groupedWithProratedMinimum = groupedWithProratedMinimum) - fun ofBulkWithProration(bulkWithProration: NewSubscriptionBulkWithProrationPrice) = Price(bulkWithProration = bulkWithProration) - fun ofScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: NewSubscriptionScalableMatrixWithUnitPricingPrice - ) = Price(scalableMatrixWithUnitPricing = scalableMatrixWithUnitPricing) - - fun ofScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: - NewSubscriptionScalableMatrixWithTieredPricingPrice - ) = Price(scalableMatrixWithTieredPricing = scalableMatrixWithTieredPricing) - - fun ofCumulativeGroupedBulk( - cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice - ) = Price(cumulativeGroupedBulk = cumulativeGroupedBulk) - - fun ofMaxGroupTieredPackage( - maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice - ) = Price(maxGroupTieredPackage = maxGroupTieredPackage) + fun ofGroupedWithProratedMinimum( + groupedWithProratedMinimum: NewSubscriptionGroupedWithProratedMinimumPrice + ) = Price(groupedWithProratedMinimum = groupedWithProratedMinimum) fun ofGroupedWithMeteredMinimum( groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice ) = Price(groupedWithMeteredMinimum = groupedWithMeteredMinimum) + fun ofGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) = Price(groupedWithMinMaxThresholds = groupedWithMinMaxThresholds) + fun ofMatrixWithDisplayName( matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice ) = Price(matrixWithDisplayName = matrixWithDisplayName) @@ -5583,20 +5580,22 @@ private constructor( groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice ) = Price(groupedTieredPackage = groupedTieredPackage) - fun ofMatrixWithAllocation( - matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice - ) = Price(matrixWithAllocation = matrixWithAllocation) + fun ofMaxGroupTieredPackage( + maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice + ) = Price(maxGroupTieredPackage = maxGroupTieredPackage) - fun ofTieredPackageWithMinimum( - tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice - ) = Price(tieredPackageWithMinimum = tieredPackageWithMinimum) + fun ofScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: NewSubscriptionScalableMatrixWithUnitPricingPrice + ) = Price(scalableMatrixWithUnitPricing = scalableMatrixWithUnitPricing) - fun ofGroupedTiered(groupedTiered: NewSubscriptionGroupedTieredPrice) = - Price(groupedTiered = groupedTiered) + fun ofScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: + NewSubscriptionScalableMatrixWithTieredPricingPrice + ) = Price(scalableMatrixWithTieredPricing = scalableMatrixWithTieredPricing) - fun ofGroupedWithMinMaxThresholds( - groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds - ) = Price(groupedWithMinMaxThresholds = groupedWithMinMaxThresholds) + fun ofCumulativeGroupedBulk( + cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice + ) = Price(cumulativeGroupedBulk = cumulativeGroupedBulk) fun ofMinimum(minimum: NewSubscriptionMinimumCompositePrice) = Price(minimum = minimum) @@ -5609,14 +5608,14 @@ private constructor( fun visitUnit(unit: NewSubscriptionUnitPrice): T - fun visitPackage(package_: NewSubscriptionPackagePrice): T - - fun visitMatrix(matrix: NewSubscriptionMatrixPrice): T - fun visitTiered(tiered: NewSubscriptionTieredPrice): T fun visitBulk(bulk: NewSubscriptionBulkPrice): T + fun visitPackage(package_: NewSubscriptionPackagePrice): T + + fun visitMatrix(matrix: NewSubscriptionMatrixPrice): T + fun visitThresholdTotalAmount( thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice ): T @@ -5627,16 +5626,24 @@ private constructor( tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice ): T - fun visitUnitWithPercent(unitWithPercent: NewSubscriptionUnitWithPercentPrice): T + fun visitGroupedTiered(groupedTiered: NewSubscriptionGroupedTieredPrice): T + + fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice + ): T fun visitPackageWithAllocation( packageWithAllocation: NewSubscriptionPackageWithAllocationPrice ): T - fun visitTieredWithProration( - tieredWithProration: NewSubscriptionTierWithProrationPrice + fun visitUnitWithPercent(unitWithPercent: NewSubscriptionUnitWithPercentPrice): T + + fun visitMatrixWithAllocation( + matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice ): T + fun visitTieredWithProration(tieredWithProration: TieredWithProration): T + fun visitUnitWithProration( unitWithProration: NewSubscriptionUnitWithProrationPrice ): T @@ -5645,35 +5652,22 @@ private constructor( groupedAllocation: NewSubscriptionGroupedAllocationPrice ): T - fun visitGroupedWithProratedMinimum( - groupedWithProratedMinimum: NewSubscriptionGroupedWithProratedMinimumPrice - ): T - fun visitBulkWithProration( bulkWithProration: NewSubscriptionBulkWithProrationPrice ): T - fun visitScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: NewSubscriptionScalableMatrixWithUnitPricingPrice - ): T - - fun visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: - NewSubscriptionScalableMatrixWithTieredPricingPrice - ): T - - fun visitCumulativeGroupedBulk( - cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice - ): T - - fun visitMaxGroupTieredPackage( - maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice + fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: NewSubscriptionGroupedWithProratedMinimumPrice ): T fun visitGroupedWithMeteredMinimum( groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice ): T + fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ): T + fun visitMatrixWithDisplayName( matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice ): T @@ -5682,18 +5676,21 @@ private constructor( groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice ): T - fun visitMatrixWithAllocation( - matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice + fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice ): T - fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice + fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: NewSubscriptionScalableMatrixWithUnitPricingPrice ): T - fun visitGroupedTiered(groupedTiered: NewSubscriptionGroupedTieredPrice): T + fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: + NewSubscriptionScalableMatrixWithTieredPricingPrice + ): T - fun visitGroupedWithMinMaxThresholds( - groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + fun visitCumulativeGroupedBulk( + cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice ): T fun visitMinimum(minimum: NewSubscriptionMinimumCompositePrice): T @@ -5724,6 +5721,17 @@ private constructor( return tryDeserialize(node, jacksonTypeRef()) ?.let { Price(unit = it, _json = json) } ?: Price(_json = json) } + "tiered" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(tiered = it, _json = json) } ?: Price(_json = json) + } + "bulk" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(bulk = it, _json = json) } ?: Price(_json = json) + } "package" -> { return tryDeserialize( node, @@ -5738,18 +5746,7 @@ private constructor( ) ?.let { Price(matrix = it, _json = json) } ?: Price(_json = json) } - "tiered" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(tiered = it, _json = json) } ?: Price(_json = json) - } - "bulk" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(bulk = it, _json = json) } ?: Price(_json = json) - } - "threshold_total_amount" -> { + "threshold_total_amount" -> { return tryDeserialize( node, jacksonTypeRef(), @@ -5773,12 +5770,20 @@ private constructor( ?.let { Price(tieredWithMinimum = it, _json = json) } ?: Price(_json = json) } - "unit_with_percent" -> { + "grouped_tiered" -> { return tryDeserialize( node, - jacksonTypeRef(), + jacksonTypeRef(), ) - ?.let { Price(unitWithPercent = it, _json = json) } + ?.let { Price(groupedTiered = it, _json = json) } + ?: Price(_json = json) + } + "tiered_package_with_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(tieredPackageWithMinimum = it, _json = json) } ?: Price(_json = json) } "package_with_allocation" -> { @@ -5789,11 +5794,24 @@ private constructor( ?.let { Price(packageWithAllocation = it, _json = json) } ?: Price(_json = json) } - "tiered_with_proration" -> { + "unit_with_percent" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(unitWithPercent = it, _json = json) } + ?: Price(_json = json) + } + "matrix_with_allocation" -> { return tryDeserialize( node, - jacksonTypeRef(), + jacksonTypeRef(), ) + ?.let { Price(matrixWithAllocation = it, _json = json) } + ?: Price(_json = json) + } + "tiered_with_proration" -> { + return tryDeserialize(node, jacksonTypeRef()) ?.let { Price(tieredWithProration = it, _json = json) } ?: Price(_json = json) } @@ -5813,14 +5831,6 @@ private constructor( ?.let { Price(groupedAllocation = it, _json = json) } ?: Price(_json = json) } - "grouped_with_prorated_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedWithProratedMinimum = it, _json = json) } - ?: Price(_json = json) - } "bulk_with_proration" -> { return tryDeserialize( node, @@ -5829,48 +5839,28 @@ private constructor( ?.let { Price(bulkWithProration = it, _json = json) } ?: Price(_json = json) } - "scalable_matrix_with_unit_pricing" -> { - return tryDeserialize( - node, - jacksonTypeRef< - NewSubscriptionScalableMatrixWithUnitPricingPrice - >(), - ) - ?.let { Price(scalableMatrixWithUnitPricing = it, _json = json) } - ?: Price(_json = json) - } - "scalable_matrix_with_tiered_pricing" -> { - return tryDeserialize( - node, - jacksonTypeRef< - NewSubscriptionScalableMatrixWithTieredPricingPrice - >(), - ) - ?.let { Price(scalableMatrixWithTieredPricing = it, _json = json) } - ?: Price(_json = json) - } - "cumulative_grouped_bulk" -> { + "grouped_with_prorated_minimum" -> { return tryDeserialize( node, - jacksonTypeRef(), + jacksonTypeRef(), ) - ?.let { Price(cumulativeGroupedBulk = it, _json = json) } + ?.let { Price(groupedWithProratedMinimum = it, _json = json) } ?: Price(_json = json) } - "max_group_tiered_package" -> { + "grouped_with_metered_minimum" -> { return tryDeserialize( node, - jacksonTypeRef(), + jacksonTypeRef(), ) - ?.let { Price(maxGroupTieredPackage = it, _json = json) } + ?.let { Price(groupedWithMeteredMinimum = it, _json = json) } ?: Price(_json = json) } - "grouped_with_metered_minimum" -> { + "grouped_with_min_max_thresholds" -> { return tryDeserialize( node, - jacksonTypeRef(), + jacksonTypeRef(), ) - ?.let { Price(groupedWithMeteredMinimum = it, _json = json) } + ?.let { Price(groupedWithMinMaxThresholds = it, _json = json) } ?: Price(_json = json) } "matrix_with_display_name" -> { @@ -5889,36 +5879,40 @@ private constructor( ?.let { Price(groupedTieredPackage = it, _json = json) } ?: Price(_json = json) } - "matrix_with_allocation" -> { + "max_group_tiered_package" -> { return tryDeserialize( node, - jacksonTypeRef(), + jacksonTypeRef(), ) - ?.let { Price(matrixWithAllocation = it, _json = json) } + ?.let { Price(maxGroupTieredPackage = it, _json = json) } ?: Price(_json = json) } - "tiered_package_with_minimum" -> { + "scalable_matrix_with_unit_pricing" -> { return tryDeserialize( node, - jacksonTypeRef(), + jacksonTypeRef< + NewSubscriptionScalableMatrixWithUnitPricingPrice + >(), ) - ?.let { Price(tieredPackageWithMinimum = it, _json = json) } + ?.let { Price(scalableMatrixWithUnitPricing = it, _json = json) } ?: Price(_json = json) } - "grouped_tiered" -> { + "scalable_matrix_with_tiered_pricing" -> { return tryDeserialize( node, - jacksonTypeRef(), + jacksonTypeRef< + NewSubscriptionScalableMatrixWithTieredPricingPrice + >(), ) - ?.let { Price(groupedTiered = it, _json = json) } + ?.let { Price(scalableMatrixWithTieredPricing = it, _json = json) } ?: Price(_json = json) } - "grouped_with_min_max_thresholds" -> { + "cumulative_grouped_bulk" -> { return tryDeserialize( node, - jacksonTypeRef(), + jacksonTypeRef(), ) - ?.let { Price(groupedWithMinMaxThresholds = it, _json = json) } + ?.let { Price(cumulativeGroupedBulk = it, _json = json) } ?: Price(_json = json) } "minimum" -> { @@ -5943,50 +5937,50 @@ private constructor( ) { when { value.unit != null -> generator.writeObject(value.unit) - value.package_ != null -> generator.writeObject(value.package_) - value.matrix != null -> generator.writeObject(value.matrix) value.tiered != null -> generator.writeObject(value.tiered) value.bulk != null -> generator.writeObject(value.bulk) + value.package_ != null -> generator.writeObject(value.package_) + value.matrix != null -> generator.writeObject(value.matrix) value.thresholdTotalAmount != null -> generator.writeObject(value.thresholdTotalAmount) value.tieredPackage != null -> generator.writeObject(value.tieredPackage) value.tieredWithMinimum != null -> generator.writeObject(value.tieredWithMinimum) - value.unitWithPercent != null -> - generator.writeObject(value.unitWithPercent) + value.groupedTiered != null -> generator.writeObject(value.groupedTiered) + value.tieredPackageWithMinimum != null -> + generator.writeObject(value.tieredPackageWithMinimum) value.packageWithAllocation != null -> generator.writeObject(value.packageWithAllocation) + value.unitWithPercent != null -> + generator.writeObject(value.unitWithPercent) + value.matrixWithAllocation != null -> + generator.writeObject(value.matrixWithAllocation) value.tieredWithProration != null -> generator.writeObject(value.tieredWithProration) value.unitWithProration != null -> generator.writeObject(value.unitWithProration) value.groupedAllocation != null -> generator.writeObject(value.groupedAllocation) - value.groupedWithProratedMinimum != null -> - generator.writeObject(value.groupedWithProratedMinimum) value.bulkWithProration != null -> generator.writeObject(value.bulkWithProration) - value.scalableMatrixWithUnitPricing != null -> - generator.writeObject(value.scalableMatrixWithUnitPricing) - value.scalableMatrixWithTieredPricing != null -> - generator.writeObject(value.scalableMatrixWithTieredPricing) - value.cumulativeGroupedBulk != null -> - generator.writeObject(value.cumulativeGroupedBulk) - value.maxGroupTieredPackage != null -> - generator.writeObject(value.maxGroupTieredPackage) + value.groupedWithProratedMinimum != null -> + generator.writeObject(value.groupedWithProratedMinimum) value.groupedWithMeteredMinimum != null -> generator.writeObject(value.groupedWithMeteredMinimum) + value.groupedWithMinMaxThresholds != null -> + generator.writeObject(value.groupedWithMinMaxThresholds) value.matrixWithDisplayName != null -> generator.writeObject(value.matrixWithDisplayName) value.groupedTieredPackage != null -> generator.writeObject(value.groupedTieredPackage) - value.matrixWithAllocation != null -> - generator.writeObject(value.matrixWithAllocation) - value.tieredPackageWithMinimum != null -> - generator.writeObject(value.tieredPackageWithMinimum) - value.groupedTiered != null -> generator.writeObject(value.groupedTiered) - value.groupedWithMinMaxThresholds != null -> - generator.writeObject(value.groupedWithMinMaxThresholds) + value.maxGroupTieredPackage != null -> + generator.writeObject(value.maxGroupTieredPackage) + value.scalableMatrixWithUnitPricing != null -> + generator.writeObject(value.scalableMatrixWithUnitPricing) + value.scalableMatrixWithTieredPricing != null -> + generator.writeObject(value.scalableMatrixWithTieredPricing) + value.cumulativeGroupedBulk != null -> + generator.writeObject(value.cumulativeGroupedBulk) value.minimum != null -> generator.writeObject(value.minimum) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid Price") @@ -5994,14 +5988,13 @@ private constructor( } } - class GroupedWithMinMaxThresholds + class TieredWithProration private constructor( private val cadence: JsonField, - private val groupedWithMinMaxThresholdsConfig: - JsonField, private val itemId: JsonField, private val modelType: JsonValue, private val name: JsonField, + private val tieredWithProrationConfig: JsonField, private val billableMetricId: JsonField, private val billedInAdvance: JsonField, private val billingCycleConfiguration: JsonField, @@ -6024,11 +6017,6 @@ private constructor( @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), - @JsonProperty("grouped_with_min_max_thresholds_config") - @ExcludeMissing - groupedWithMinMaxThresholdsConfig: - JsonField = - JsonMissing.of(), @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), @@ -6038,6 +6026,10 @@ private constructor( @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("tiered_with_proration_config") + @ExcludeMissing + tieredWithProrationConfig: JsonField = + JsonMissing.of(), @JsonProperty("billable_metric_id") @ExcludeMissing billableMetricId: JsonField = JsonMissing.of(), @@ -6082,10 +6074,10 @@ private constructor( referenceId: JsonField = JsonMissing.of(), ) : this( cadence, - groupedWithMinMaxThresholdsConfig, itemId, modelType, name, + tieredWithProrationConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -6111,16 +6103,6 @@ private constructor( */ fun cadence(): Cadence = cadence.getRequired("cadence") - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun groupedWithMinMaxThresholdsConfig(): GroupedWithMinMaxThresholdsConfig = - groupedWithMinMaxThresholdsConfig.getRequired( - "grouped_with_min_max_thresholds_config" - ) - /** * The id of the item the price will be associated with. * @@ -6131,9 +6113,11 @@ private constructor( fun itemId(): String = itemId.getRequired("item_id") /** + * The pricing model type + * * Expected to always return the following: * ```kotlin - * JsonValue.from("grouped_with_min_max_thresholds") + * JsonValue.from("tiered_with_proration") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -6150,6 +6134,16 @@ private constructor( */ fun name(): String = name.getRequired("name") + /** + * Configuration for tiered_with_proration pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun tieredWithProrationConfig(): TieredWithProrationConfig = + tieredWithProrationConfig.getRequired("tiered_with_proration_config") + /** * The id of the billable metric for the price. Only needed if the price is * usage-based. @@ -6279,17 +6273,6 @@ private constructor( @ExcludeMissing fun _cadence(): JsonField = cadence - /** - * Returns the raw JSON value of [groupedWithMinMaxThresholdsConfig]. - * - * Unlike [groupedWithMinMaxThresholdsConfig], this method doesn't throw if the JSON - * field has an unexpected type. - */ - @JsonProperty("grouped_with_min_max_thresholds_config") - @ExcludeMissing - fun _groupedWithMinMaxThresholdsConfig(): - JsonField = groupedWithMinMaxThresholdsConfig - /** * Returns the raw JSON value of [itemId]. * @@ -6306,6 +6289,17 @@ private constructor( */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + /** + * Returns the raw JSON value of [tieredWithProrationConfig]. + * + * Unlike [tieredWithProrationConfig], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("tiered_with_proration_config") + @ExcludeMissing + fun _tieredWithProrationConfig(): JsonField = + tieredWithProrationConfig + /** * Returns the raw JSON value of [billableMetricId]. * @@ -6455,30 +6449,28 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [GroupedWithMinMaxThresholds]. + * [TieredWithProration]. * * The following fields are required: * ```kotlin * .cadence() - * .groupedWithMinMaxThresholdsConfig() * .itemId() * .name() + * .tieredWithProrationConfig() * ``` */ fun builder() = Builder() } - /** A builder for [GroupedWithMinMaxThresholds]. */ + /** A builder for [TieredWithProration]. */ class Builder internal constructor() { private var cadence: JsonField? = null - private var groupedWithMinMaxThresholdsConfig: - JsonField? = - null private var itemId: JsonField? = null - private var modelType: JsonValue = - JsonValue.from("grouped_with_min_max_thresholds") + private var modelType: JsonValue = JsonValue.from("tiered_with_proration") private var name: JsonField? = null + private var tieredWithProrationConfig: JsonField? = + null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() private var billingCycleConfiguration: JsonField = @@ -6500,33 +6492,30 @@ private constructor( private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds) = - apply { - cadence = groupedWithMinMaxThresholds.cadence - groupedWithMinMaxThresholdsConfig = - groupedWithMinMaxThresholds.groupedWithMinMaxThresholdsConfig - itemId = groupedWithMinMaxThresholds.itemId - modelType = groupedWithMinMaxThresholds.modelType - name = groupedWithMinMaxThresholds.name - billableMetricId = groupedWithMinMaxThresholds.billableMetricId - billedInAdvance = groupedWithMinMaxThresholds.billedInAdvance - billingCycleConfiguration = - groupedWithMinMaxThresholds.billingCycleConfiguration - conversionRate = groupedWithMinMaxThresholds.conversionRate - conversionRateConfig = groupedWithMinMaxThresholds.conversionRateConfig - currency = groupedWithMinMaxThresholds.currency - dimensionalPriceConfiguration = - groupedWithMinMaxThresholds.dimensionalPriceConfiguration - externalPriceId = groupedWithMinMaxThresholds.externalPriceId - fixedPriceQuantity = groupedWithMinMaxThresholds.fixedPriceQuantity - invoiceGroupingKey = groupedWithMinMaxThresholds.invoiceGroupingKey - invoicingCycleConfiguration = - groupedWithMinMaxThresholds.invoicingCycleConfiguration - metadata = groupedWithMinMaxThresholds.metadata - referenceId = groupedWithMinMaxThresholds.referenceId - additionalProperties = - groupedWithMinMaxThresholds.additionalProperties.toMutableMap() - } + internal fun from(tieredWithProration: TieredWithProration) = apply { + cadence = tieredWithProration.cadence + itemId = tieredWithProration.itemId + modelType = tieredWithProration.modelType + name = tieredWithProration.name + tieredWithProrationConfig = tieredWithProration.tieredWithProrationConfig + billableMetricId = tieredWithProration.billableMetricId + billedInAdvance = tieredWithProration.billedInAdvance + billingCycleConfiguration = tieredWithProration.billingCycleConfiguration + conversionRate = tieredWithProration.conversionRate + conversionRateConfig = tieredWithProration.conversionRateConfig + currency = tieredWithProration.currency + dimensionalPriceConfiguration = + tieredWithProration.dimensionalPriceConfiguration + externalPriceId = tieredWithProration.externalPriceId + fixedPriceQuantity = tieredWithProration.fixedPriceQuantity + invoiceGroupingKey = tieredWithProration.invoiceGroupingKey + invoicingCycleConfiguration = + tieredWithProration.invoicingCycleConfiguration + metadata = tieredWithProration.metadata + referenceId = tieredWithProration.referenceId + additionalProperties = + tieredWithProration.additionalProperties.toMutableMap() + } /** The cadence to bill for this price on. */ fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) @@ -6540,33 +6529,11 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - fun groupedWithMinMaxThresholdsConfig( - groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig - ) = - groupedWithMinMaxThresholdsConfig( - JsonField.of(groupedWithMinMaxThresholdsConfig) - ) + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) /** - * Sets [Builder.groupedWithMinMaxThresholdsConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.groupedWithMinMaxThresholdsConfig] with a - * well-typed [GroupedWithMinMaxThresholdsConfig] value instead. This method is - * primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun groupedWithMinMaxThresholdsConfig( - groupedWithMinMaxThresholdsConfig: - JsonField - ) = apply { - this.groupedWithMinMaxThresholdsConfig = groupedWithMinMaxThresholdsConfig - } - - /** The id of the item the price will be associated with. */ - fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - - /** - * Sets [Builder.itemId] to an arbitrary JSON value. + * Sets [Builder.itemId] to an arbitrary JSON value. * * You should usually call [Builder.itemId] with a well-typed [String] value * instead. This method is primarily for setting the field to an undocumented or @@ -6580,7 +6547,7 @@ private constructor( * It is usually unnecessary to call this method because the field defaults to * the following: * ```kotlin - * JsonValue.from("grouped_with_min_max_thresholds") + * JsonValue.from("tiered_with_proration") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -6600,6 +6567,22 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } + /** Configuration for tiered_with_proration pricing */ + fun tieredWithProrationConfig( + tieredWithProrationConfig: TieredWithProrationConfig + ) = tieredWithProrationConfig(JsonField.of(tieredWithProrationConfig)) + + /** + * Sets [Builder.tieredWithProrationConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.tieredWithProrationConfig] with a well-typed + * [TieredWithProrationConfig] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun tieredWithProrationConfig( + tieredWithProrationConfig: JsonField + ) = apply { this.tieredWithProrationConfig = tieredWithProrationConfig } + /** * The id of the billable metric for the price. Only needed if the price is * usage-based. @@ -6929,30 +6912,27 @@ private constructor( } /** - * Returns an immutable instance of [GroupedWithMinMaxThresholds]. + * Returns an immutable instance of [TieredWithProration]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```kotlin * .cadence() - * .groupedWithMinMaxThresholdsConfig() * .itemId() * .name() + * .tieredWithProrationConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): GroupedWithMinMaxThresholds = - GroupedWithMinMaxThresholds( + fun build(): TieredWithProration = + TieredWithProration( checkRequired("cadence", cadence), - checkRequired( - "groupedWithMinMaxThresholdsConfig", - groupedWithMinMaxThresholdsConfig, - ), checkRequired("itemId", itemId), modelType, checkRequired("name", name), + checkRequired("tieredWithProrationConfig", tieredWithProrationConfig), billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -6972,20 +6952,20 @@ private constructor( private var validated: Boolean = false - fun validate(): GroupedWithMinMaxThresholds = apply { + fun validate(): TieredWithProration = apply { if (validated) { return@apply } cadence().validate() - groupedWithMinMaxThresholdsConfig().validate() itemId() _modelType().let { - if (it != JsonValue.from("grouped_with_min_max_thresholds")) { + if (it != JsonValue.from("tiered_with_proration")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } name() + tieredWithProrationConfig().validate() billableMetricId() billedInAdvance() billingCycleConfiguration()?.validate() @@ -7018,12 +6998,12 @@ private constructor( */ internal fun validity(): Int = (cadence.asKnown()?.validity() ?: 0) + - (groupedWithMinMaxThresholdsConfig.asKnown()?.validity() ?: 0) + (if (itemId.asKnown() == null) 0 else 1) + modelType.let { - if (it == JsonValue.from("grouped_with_min_max_thresholds")) 1 else 0 + if (it == JsonValue.from("tiered_with_proration")) 1 else 0 } + (if (name.asKnown() == null) 0 else 1) + + (tieredWithProrationConfig.asKnown()?.validity() ?: 0) + (if (billableMetricId.asKnown() == null) 0 else 1) + (if (billedInAdvance.asKnown() == null) 0 else 1) + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + @@ -7195,16 +7175,49 @@ private constructor( override fun toString() = value.toString() } - class GroupedWithMinMaxThresholdsConfig - @JsonCreator + /** Configuration for tiered_with_proration pricing */ + class TieredWithProrationConfig private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map + private val tiers: JsonField>, + private val additionalProperties: MutableMap, ) { + @JsonCreator + private constructor( + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of() + ) : this(tiers, mutableMapOf()) + + /** + * Tiers for rating based on total usage quantities into the specified tier with + * proration + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun tiers(): List = tiers.getRequired("tiers") + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) fun toBuilder() = Builder().from(this) @@ -7212,23 +7225,58 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [GroupedWithMinMaxThresholdsConfig]. + * [TieredWithProrationConfig]. + * + * The following fields are required: + * ```kotlin + * .tiers() + * ``` */ fun builder() = Builder() } - /** A builder for [GroupedWithMinMaxThresholdsConfig]. */ + /** A builder for [TieredWithProrationConfig]. */ class Builder internal constructor() { + private var tiers: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() - internal fun from( - groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig - ) = apply { - additionalProperties = - groupedWithMinMaxThresholdsConfig.additionalProperties - .toMutableMap() + internal fun from(tieredWithProrationConfig: TieredWithProrationConfig) = + apply { + tiers = tieredWithProrationConfig.tiers.map { it.toMutableList() } + additionalProperties = + tieredWithProrationConfig.additionalProperties.toMutableMap() + } + + /** + * Tiers for rating based on total usage quantities into the specified tier + * with proration + */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } } fun additionalProperties(additionalProperties: Map) = @@ -7254,21 +7302,32 @@ private constructor( } /** - * Returns an immutable instance of [GroupedWithMinMaxThresholdsConfig]. + * Returns an immutable instance of [TieredWithProrationConfig]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ - fun build(): GroupedWithMinMaxThresholdsConfig = - GroupedWithMinMaxThresholdsConfig(additionalProperties.toImmutable()) + fun build(): TieredWithProrationConfig = + TieredWithProrationConfig( + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false - fun validate(): GroupedWithMinMaxThresholdsConfig = apply { + fun validate(): TieredWithProrationConfig = apply { if (validated) { return@apply } + tiers().forEach { it.validate() } validated = true } @@ -7287,25 +7346,246 @@ private constructor( * Used for best match union deserialization. */ internal fun validity(): Int = - additionalProperties.count { (_, value) -> - !value.isNull() && !value.isMissing() + (tiers.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single tiered with proration tier */ + class Tier + private constructor( + private val tierLowerBound: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(tierLowerBound, unitAmount, mutableMapOf()) + + /** + * Inclusive tier starting value + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun tierLowerBound(): String = + tierLowerBound.getRequired("tier_lower_bound") + + /** + * Amount per unit + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Tier]. + * + * The following fields are required: + * ```kotlin + * .tierLowerBound() + * .unitAmount() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var tierLowerBound: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(tier: Tier) = apply { + tierLowerBound = tier.tierLowerBound + unitAmount = tier.unitAmount + additionalProperties = tier.additionalProperties.toMutableMap() + } + + /** Inclusive tier starting value */ + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + /** Amount per unit */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```kotlin + * .tierLowerBound() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("tierLowerBound", tierLowerBound), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + tierLowerBound() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (tierLowerBound.asKnown() == null) 0 else 1) + + (if (unitAmount.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + tierLowerBound == other.tierLowerBound && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(tierLowerBound, unitAmount, additionalProperties) } + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is GroupedWithMinMaxThresholdsConfig && + return other is TieredWithProrationConfig && + tiers == other.tiers && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(tiers, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "GroupedWithMinMaxThresholdsConfig{additionalProperties=$additionalProperties}" + "TieredWithProrationConfig{tiers=$tiers, additionalProperties=$additionalProperties}" } /** @@ -7422,13 +7702,12 @@ private constructor( return true } - return other is GroupedWithMinMaxThresholds && + return other is TieredWithProration && cadence == other.cadence && - groupedWithMinMaxThresholdsConfig == - other.groupedWithMinMaxThresholdsConfig && itemId == other.itemId && modelType == other.modelType && name == other.name && + tieredWithProrationConfig == other.tieredWithProrationConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && @@ -7448,10 +7727,10 @@ private constructor( private val hashCode: Int by lazy { Objects.hash( cadence, - groupedWithMinMaxThresholdsConfig, itemId, modelType, name, + tieredWithProrationConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -7472,1178 +7751,1703 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "GroupedWithMinMaxThresholds{cadence=$cadence, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + "TieredWithProration{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredWithProrationConfig=$tieredWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - return other is AddPrice && - allocationPrice == other.allocationPrice && - discounts == other.discounts && - endDate == other.endDate && - externalPriceId == other.externalPriceId && - maximumAmount == other.maximumAmount && - minimumAmount == other.minimumAmount && - planPhaseOrder == other.planPhaseOrder && - price == other.price && - priceId == other.priceId && - startDate == other.startDate && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - allocationPrice, - discounts, - endDate, - externalPriceId, - maximumAmount, - minimumAmount, - planPhaseOrder, - price, - priceId, - startDate, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "AddPrice{allocationPrice=$allocationPrice, discounts=$discounts, endDate=$endDate, externalPriceId=$externalPriceId, maximumAmount=$maximumAmount, minimumAmount=$minimumAmount, planPhaseOrder=$planPhaseOrder, price=$price, priceId=$priceId, startDate=$startDate, additionalProperties=$additionalProperties}" - } - - @Deprecated("deprecated") - class ExternalMarketplace - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API may respond with new members that the SDK is - * unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - val GOOGLE = of("google") - - val AWS = of("aws") - - val AZURE = of("azure") - - fun of(value: String) = ExternalMarketplace(JsonField.of(value)) - } - - /** An enum containing [ExternalMarketplace]'s known values. */ - enum class Known { - GOOGLE, - AWS, - AZURE, - } + class GroupedWithMinMaxThresholds + private constructor( + private val cadence: JsonField, + private val groupedWithMinMaxThresholdsConfig: + JsonField, + private val itemId: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { - /** - * An enum containing [ExternalMarketplace]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [ExternalMarketplace] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if the - * SDK is on an older version than the API, then the API may respond with new members that - * the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - GOOGLE, - AWS, - AZURE, - /** - * An enum member indicating that [ExternalMarketplace] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("grouped_with_min_max_thresholds_config") + @ExcludeMissing + groupedWithMinMaxThresholdsConfig: + JsonField = + JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + groupedWithMinMaxThresholdsConfig, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + mutableMapOf(), + ) - /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you want - * to throw for the unknown case. - */ - fun value(): Value = - when (this) { - GOOGLE -> Value.GOOGLE - AWS -> Value.AWS - AZURE -> Value.AZURE - else -> Value._UNKNOWN - } + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and don't - * want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known member. - */ - fun known(): Known = - when (this) { - GOOGLE -> Known.GOOGLE - AWS -> Known.AWS - AZURE -> Known.AZURE - else -> throw OrbInvalidDataException("Unknown ExternalMarketplace: $value") - } + /** + * Configuration for grouped_with_min_max_thresholds pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupedWithMinMaxThresholdsConfig(): GroupedWithMinMaxThresholdsConfig = + groupedWithMinMaxThresholdsConfig.getRequired( + "grouped_with_min_max_thresholds_config" + ) - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the expected - * primitive type. - */ - fun asString(): String = - _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") - private var validated: Boolean = false + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("grouped_with_min_max_thresholds") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType - fun validate(): ExternalMarketplace = apply { - if (validated) { - return@apply - } + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") - known() - validated = true - } + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = billableMetricId.getNullable("billable_metric_id") - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") - return other is ExternalMarketplace && value == other.value - } + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") - override fun hashCode() = value.hashCode() + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") - override fun toString() = value.toString() - } + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by setting - * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to - * `null`. - */ - class Metadata - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") - fun toBuilder() = Builder().from(this) + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + invoiceGroupingKey.getNullable("invoice_grouping_key") - companion object { + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - /** Returns a mutable builder for constructing an instance of [Metadata]. */ - fun builder() = Builder() - } + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") - /** A builder for [Metadata]. */ - class Builder internal constructor() { + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") - private var additionalProperties: MutableMap = mutableMapOf() + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence - internal fun from(metadata: Metadata) = apply { - additionalProperties = metadata.additionalProperties.toMutableMap() - } + /** + * Returns the raw JSON value of [groupedWithMinMaxThresholdsConfig]. + * + * Unlike [groupedWithMinMaxThresholdsConfig], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("grouped_with_min_max_thresholds_config") + @ExcludeMissing + fun _groupedWithMinMaxThresholdsConfig(): + JsonField = groupedWithMinMaxThresholdsConfig - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration - /** - * Returns an immutable instance of [Metadata]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate - private var validated: Boolean = false + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig - fun validate(): Metadata = apply { - if (validated) { - return@apply - } + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency - validated = true - } + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - return other is Metadata && additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration - override fun hashCode(): Int = hashCode + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId - class RemoveAdjustment - private constructor( - private val adjustmentId: JsonField, - private val additionalProperties: MutableMap, - ) { + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - @JsonCreator - private constructor( - @JsonProperty("adjustment_id") - @ExcludeMissing - adjustmentId: JsonField = JsonMissing.of() - ) : this(adjustmentId, mutableMapOf()) + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - /** - * The id of the adjustment to remove on the subscription. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun adjustmentId(): String = adjustmentId.getRequired("adjustment_id") + fun toBuilder() = Builder().from(this) - /** - * Returns the raw JSON value of [adjustmentId]. - * - * Unlike [adjustmentId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("adjustment_id") - @ExcludeMissing - fun _adjustmentId(): JsonField = adjustmentId + companion object { - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** + * Returns a mutable builder for constructing an instance of + * [GroupedWithMinMaxThresholds]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .groupedWithMinMaxThresholdsConfig() + * .itemId() + * .name() + * ``` + */ + fun builder() = Builder() + } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** A builder for [GroupedWithMinMaxThresholds]. */ + class Builder internal constructor() { - fun toBuilder() = Builder().from(this) + private var cadence: JsonField? = null + private var groupedWithMinMaxThresholdsConfig: + JsonField? = + null + private var itemId: JsonField? = null + private var modelType: JsonValue = + JsonValue.from("grouped_with_min_max_thresholds") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - companion object { + internal fun from(groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds) = + apply { + cadence = groupedWithMinMaxThresholds.cadence + groupedWithMinMaxThresholdsConfig = + groupedWithMinMaxThresholds.groupedWithMinMaxThresholdsConfig + itemId = groupedWithMinMaxThresholds.itemId + modelType = groupedWithMinMaxThresholds.modelType + name = groupedWithMinMaxThresholds.name + billableMetricId = groupedWithMinMaxThresholds.billableMetricId + billedInAdvance = groupedWithMinMaxThresholds.billedInAdvance + billingCycleConfiguration = + groupedWithMinMaxThresholds.billingCycleConfiguration + conversionRate = groupedWithMinMaxThresholds.conversionRate + conversionRateConfig = groupedWithMinMaxThresholds.conversionRateConfig + currency = groupedWithMinMaxThresholds.currency + dimensionalPriceConfiguration = + groupedWithMinMaxThresholds.dimensionalPriceConfiguration + externalPriceId = groupedWithMinMaxThresholds.externalPriceId + fixedPriceQuantity = groupedWithMinMaxThresholds.fixedPriceQuantity + invoiceGroupingKey = groupedWithMinMaxThresholds.invoiceGroupingKey + invoicingCycleConfiguration = + groupedWithMinMaxThresholds.invoicingCycleConfiguration + metadata = groupedWithMinMaxThresholds.metadata + referenceId = groupedWithMinMaxThresholds.referenceId + additionalProperties = + groupedWithMinMaxThresholds.additionalProperties.toMutableMap() + } - /** - * Returns a mutable builder for constructing an instance of [RemoveAdjustment]. - * - * The following fields are required: - * ```kotlin - * .adjustmentId() - * ``` - */ - fun builder() = Builder() - } + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - /** A builder for [RemoveAdjustment]. */ - class Builder internal constructor() { + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - private var adjustmentId: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() + /** Configuration for grouped_with_min_max_thresholds pricing */ + fun groupedWithMinMaxThresholdsConfig( + groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + ) = + groupedWithMinMaxThresholdsConfig( + JsonField.of(groupedWithMinMaxThresholdsConfig) + ) - internal fun from(removeAdjustment: RemoveAdjustment) = apply { - adjustmentId = removeAdjustment.adjustmentId - additionalProperties = removeAdjustment.additionalProperties.toMutableMap() - } + /** + * Sets [Builder.groupedWithMinMaxThresholdsConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.groupedWithMinMaxThresholdsConfig] with a + * well-typed [GroupedWithMinMaxThresholdsConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun groupedWithMinMaxThresholdsConfig( + groupedWithMinMaxThresholdsConfig: + JsonField + ) = apply { + this.groupedWithMinMaxThresholdsConfig = groupedWithMinMaxThresholdsConfig + } - /** The id of the adjustment to remove on the subscription. */ - fun adjustmentId(adjustmentId: String) = adjustmentId(JsonField.of(adjustmentId)) + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - /** - * Sets [Builder.adjustmentId] to an arbitrary JSON value. - * - * You should usually call [Builder.adjustmentId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun adjustmentId(adjustmentId: JsonField) = apply { - this.adjustmentId = adjustmentId - } + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("grouped_with_min_max_thresholds") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) - /** - * Returns an immutable instance of [RemoveAdjustment]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```kotlin - * .adjustmentId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): RemoveAdjustment = - RemoveAdjustment( - checkRequired("adjustmentId", adjustmentId), - additionalProperties.toMutableMap(), - ) - } + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } - private var validated: Boolean = false + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) - fun validate(): RemoveAdjustment = apply { - if (validated) { - return@apply - } + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) - adjustmentId() - validated = true - } + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = (if (adjustmentId.asKnown() == null) 0 else 1) + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) - return other is RemoveAdjustment && - adjustmentId == other.adjustmentId && - additionalProperties == other.additionalProperties - } + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) - private val hashCode: Int by lazy { Objects.hash(adjustmentId, additionalProperties) } + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } - override fun hashCode(): Int = hashCode + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) - override fun toString() = - "RemoveAdjustment{adjustmentId=$adjustmentId, additionalProperties=$additionalProperties}" - } + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } - class RemovePrice - private constructor( - private val externalPriceId: JsonField, - private val priceId: JsonField, - private val additionalProperties: MutableMap, - ) { + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) - @JsonCreator - private constructor( - @JsonProperty("external_price_id") - @ExcludeMissing - externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("price_id") @ExcludeMissing priceId: JsonField = JsonMissing.of(), - ) : this(externalPriceId, priceId, mutableMapOf()) + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) - /** - * The external price id of the price to remove on the subscription. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) - /** - * The id of the price to remove on the subscription. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun priceId(): String? = priceId.getNullable("price_id") + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) - /** - * Returns the raw JSON value of [externalPriceId]. - * - * Unlike [externalPriceId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) - /** - * Returns the raw JSON value of [priceId]. - * - * Unlike [priceId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } - fun toBuilder() = Builder().from(this) + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) - companion object { + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } - /** Returns a mutable builder for constructing an instance of [RemovePrice]. */ - fun builder() = Builder() - } + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) - /** A builder for [RemovePrice]. */ - class Builder internal constructor() { + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) - private var externalPriceId: JsonField = JsonMissing.of() - private var priceId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } - internal fun from(removePrice: RemovePrice) = apply { - externalPriceId = removePrice.externalPriceId - priceId = removePrice.priceId - additionalProperties = removePrice.additionalProperties.toMutableMap() - } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) - /** The external price id of the price to remove on the subscription. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } - /** - * Sets [Builder.externalPriceId] to an arbitrary JSON value. - * - * You should usually call [Builder.externalPriceId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun externalPriceId(externalPriceId: JsonField) = apply { - this.externalPriceId = externalPriceId - } + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) - /** The id of the price to remove on the subscription. */ - fun priceId(priceId: String?) = priceId(JsonField.ofNullable(priceId)) + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - /** - * Sets [Builder.priceId] to an arbitrary JSON value. - * - * You should usually call [Builder.priceId] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun priceId(priceId: JsonField) = apply { this.priceId = priceId } + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * Returns an immutable instance of [RemovePrice]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): RemovePrice = - RemovePrice(externalPriceId, priceId, additionalProperties.toMutableMap()) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - private var validated: Boolean = false + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun validate(): RemovePrice = apply { - if (validated) { - return@apply - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - externalPriceId() - priceId() - validated = true - } + /** + * Returns an immutable instance of [GroupedWithMinMaxThresholds]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .groupedWithMinMaxThresholdsConfig() + * .itemId() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedWithMinMaxThresholds = + GroupedWithMinMaxThresholds( + checkRequired("cadence", cadence), + checkRequired( + "groupedWithMinMaxThresholdsConfig", + groupedWithMinMaxThresholdsConfig, + ), + checkRequired("itemId", itemId), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (if (externalPriceId.asKnown() == null) 0 else 1) + - (if (priceId.asKnown() == null) 0 else 1) + private var validated: Boolean = false - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + fun validate(): GroupedWithMinMaxThresholds = apply { + if (validated) { + return@apply + } - return other is RemovePrice && - externalPriceId == other.externalPriceId && - priceId == other.priceId && - additionalProperties == other.additionalProperties - } + cadence().validate() + groupedWithMinMaxThresholdsConfig().validate() + itemId() + _modelType().let { + if (it != JsonValue.from("grouped_with_min_max_thresholds")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + metadata()?.validate() + referenceId() + validated = true + } - private val hashCode: Int by lazy { - Objects.hash(externalPriceId, priceId, additionalProperties) - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - override fun hashCode(): Int = hashCode + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (groupedWithMinMaxThresholdsConfig.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + modelType.let { + if (it == JsonValue.from("grouped_with_min_max_thresholds")) 1 else 0 + } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) - override fun toString() = - "RemovePrice{externalPriceId=$externalPriceId, priceId=$priceId, additionalProperties=$additionalProperties}" - } + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { - class ReplaceAdjustment - private constructor( - private val adjustment: JsonField, - private val replacesAdjustmentId: JsonField, - private val additionalProperties: MutableMap, - ) { + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value - @JsonCreator - private constructor( - @JsonProperty("adjustment") - @ExcludeMissing - adjustment: JsonField = JsonMissing.of(), - @JsonProperty("replaces_adjustment_id") - @ExcludeMissing - replacesAdjustmentId: JsonField = JsonMissing.of(), - ) : this(adjustment, replacesAdjustmentId, mutableMapOf()) + companion object { - /** - * The definition of a new adjustment to create and add to the subscription. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun adjustment(): Adjustment = adjustment.getRequired("adjustment") + val ANNUAL = of("annual") - /** - * The id of the adjustment on the plan to replace in the subscription. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun replacesAdjustmentId(): String = - replacesAdjustmentId.getRequired("replaces_adjustment_id") + val SEMI_ANNUAL = of("semi_annual") - /** - * Returns the raw JSON value of [adjustment]. - * - * Unlike [adjustment], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("adjustment") - @ExcludeMissing - fun _adjustment(): JsonField = adjustment + val MONTHLY = of("monthly") - /** - * Returns the raw JSON value of [replacesAdjustmentId]. - * - * Unlike [replacesAdjustmentId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("replaces_adjustment_id") - @ExcludeMissing - fun _replacesAdjustmentId(): JsonField = replacesAdjustmentId + val QUARTERLY = of("quarterly") - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + val ONE_TIME = of("one_time") - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + val CUSTOM = of("custom") - fun toBuilder() = Builder().from(this) + fun of(value: String) = Cadence(JsonField.of(value)) + } - companion object { + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } - /** - * Returns a mutable builder for constructing an instance of [ReplaceAdjustment]. - * - * The following fields are required: - * ```kotlin - * .adjustment() - * .replacesAdjustmentId() - * ``` - */ - fun builder() = Builder() - } + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } - /** A builder for [ReplaceAdjustment]. */ - class Builder internal constructor() { + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } - private var adjustment: JsonField? = null - private var replacesAdjustmentId: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } - internal fun from(replaceAdjustment: ReplaceAdjustment) = apply { - adjustment = replaceAdjustment.adjustment - replacesAdjustmentId = replaceAdjustment.replacesAdjustmentId - additionalProperties = replaceAdjustment.additionalProperties.toMutableMap() - } + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") - /** The definition of a new adjustment to create and add to the subscription. */ - fun adjustment(adjustment: Adjustment) = adjustment(JsonField.of(adjustment)) + private var validated: Boolean = false - /** - * Sets [Builder.adjustment] to an arbitrary JSON value. - * - * You should usually call [Builder.adjustment] with a well-typed [Adjustment] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun adjustment(adjustment: JsonField) = apply { - this.adjustment = adjustment - } + fun validate(): Cadence = apply { + if (validated) { + return@apply + } - /** - * Alias for calling [adjustment] with - * `Adjustment.ofPercentageDiscount(percentageDiscount)`. - */ - fun adjustment(percentageDiscount: NewPercentageDiscount) = - adjustment(Adjustment.ofPercentageDiscount(percentageDiscount)) + known() + validated = true + } - /** - * Alias for calling [adjustment] with the following: - * ```kotlin - * NewPercentageDiscount.builder() - * .adjustmentType(NewPercentageDiscount.AdjustmentType.PERCENTAGE_DISCOUNT) - * .percentageDiscount(percentageDiscount) - * .build() - * ``` - */ - fun percentageDiscountAdjustment(percentageDiscount: Double) = - adjustment( - NewPercentageDiscount.builder() - .adjustmentType(NewPercentageDiscount.AdjustmentType.PERCENTAGE_DISCOUNT) - .percentageDiscount(percentageDiscount) - .build() - ) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - /** Alias for calling [adjustment] with `Adjustment.ofUsageDiscount(usageDiscount)`. */ - fun adjustment(usageDiscount: NewUsageDiscount) = - adjustment(Adjustment.ofUsageDiscount(usageDiscount)) + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - /** - * Alias for calling [adjustment] with the following: - * ```kotlin - * NewUsageDiscount.builder() - * .adjustmentType(NewUsageDiscount.AdjustmentType.USAGE_DISCOUNT) - * .usageDiscount(usageDiscount) - * .build() - * ``` - */ - fun usageDiscountAdjustment(usageDiscount: Double) = - adjustment( - NewUsageDiscount.builder() - .adjustmentType(NewUsageDiscount.AdjustmentType.USAGE_DISCOUNT) - .usageDiscount(usageDiscount) - .build() - ) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * Alias for calling [adjustment] with `Adjustment.ofAmountDiscount(amountDiscount)`. - */ - fun adjustment(amountDiscount: NewAmountDiscount) = - adjustment(Adjustment.ofAmountDiscount(amountDiscount)) + return other is Cadence && value == other.value + } - /** - * Alias for calling [adjustment] with the following: - * ```kotlin - * NewAmountDiscount.builder() - * .adjustmentType(NewAmountDiscount.AdjustmentType.AMOUNT_DISCOUNT) - * .amountDiscount(amountDiscount) - * .build() - * ``` - */ - fun amountDiscountAdjustment(amountDiscount: String) = - adjustment( - NewAmountDiscount.builder() - .adjustmentType(NewAmountDiscount.AdjustmentType.AMOUNT_DISCOUNT) - .amountDiscount(amountDiscount) - .build() - ) + override fun hashCode() = value.hashCode() - /** Alias for calling [adjustment] with `Adjustment.ofMinimum(minimum)`. */ - fun adjustment(minimum: NewMinimum) = adjustment(Adjustment.ofMinimum(minimum)) + override fun toString() = value.toString() + } - /** Alias for calling [adjustment] with `Adjustment.ofMaximum(maximum)`. */ - fun adjustment(maximum: NewMaximum) = adjustment(Adjustment.ofMaximum(maximum)) + /** Configuration for grouped_with_min_max_thresholds pricing */ + class GroupedWithMinMaxThresholdsConfig + private constructor( + private val groupingKey: JsonField, + private val maximumCharge: JsonField, + private val minimumCharge: JsonField, + private val perUnitRate: JsonField, + private val additionalProperties: MutableMap, + ) { - /** - * Alias for calling [adjustment] with the following: - * ```kotlin - * NewMaximum.builder() - * .adjustmentType(NewMaximum.AdjustmentType.MAXIMUM) - * .maximumAmount(maximumAmount) - * .build() - * ``` - */ - fun maximumAdjustment(maximumAmount: String) = - adjustment( - NewMaximum.builder() - .adjustmentType(NewMaximum.AdjustmentType.MAXIMUM) - .maximumAmount(maximumAmount) - .build() - ) + @JsonCreator + private constructor( + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("maximum_charge") + @ExcludeMissing + maximumCharge: JsonField = JsonMissing.of(), + @JsonProperty("minimum_charge") + @ExcludeMissing + minimumCharge: JsonField = JsonMissing.of(), + @JsonProperty("per_unit_rate") + @ExcludeMissing + perUnitRate: JsonField = JsonMissing.of(), + ) : this(groupingKey, maximumCharge, minimumCharge, perUnitRate, mutableMapOf()) - /** The id of the adjustment on the plan to replace in the subscription. */ - fun replacesAdjustmentId(replacesAdjustmentId: String) = - replacesAdjustmentId(JsonField.of(replacesAdjustmentId)) + /** + * The event property used to group before applying thresholds + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") - /** - * Sets [Builder.replacesAdjustmentId] to an arbitrary JSON value. - * - * You should usually call [Builder.replacesAdjustmentId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun replacesAdjustmentId(replacesAdjustmentId: JsonField) = apply { - this.replacesAdjustmentId = replacesAdjustmentId - } + /** + * The maximum amount to charge each group + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun maximumCharge(): String = maximumCharge.getRequired("maximum_charge") - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * The minimum amount to charge each group, regardless of usage + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun minimumCharge(): String = minimumCharge.getRequired("minimum_charge") - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * The base price charged per group + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun perUnitRate(): String = perUnitRate.getRequired("per_unit_rate") - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + /** + * Returns the raw JSON value of [maximumCharge]. + * + * Unlike [maximumCharge], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("maximum_charge") + @ExcludeMissing + fun _maximumCharge(): JsonField = maximumCharge - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * Returns the raw JSON value of [minimumCharge]. + * + * Unlike [minimumCharge], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("minimum_charge") + @ExcludeMissing + fun _minimumCharge(): JsonField = minimumCharge - /** - * Returns an immutable instance of [ReplaceAdjustment]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```kotlin - * .adjustment() - * .replacesAdjustmentId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): ReplaceAdjustment = - ReplaceAdjustment( - checkRequired("adjustment", adjustment), - checkRequired("replacesAdjustmentId", replacesAdjustmentId), - additionalProperties.toMutableMap(), - ) - } + /** + * Returns the raw JSON value of [perUnitRate]. + * + * Unlike [perUnitRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("per_unit_rate") + @ExcludeMissing + fun _perUnitRate(): JsonField = perUnitRate - private var validated: Boolean = false + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - fun validate(): ReplaceAdjustment = apply { - if (validated) { - return@apply - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - adjustment().validate() - replacesAdjustmentId() - validated = true - } + fun toBuilder() = Builder().from(this) - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + companion object { - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (adjustment.asKnown()?.validity() ?: 0) + - (if (replacesAdjustmentId.asKnown() == null) 0 else 1) + /** + * Returns a mutable builder for constructing an instance of + * [GroupedWithMinMaxThresholdsConfig]. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .maximumCharge() + * .minimumCharge() + * .perUnitRate() + * ``` + */ + fun builder() = Builder() + } - /** The definition of a new adjustment to create and add to the subscription. */ - @JsonDeserialize(using = Adjustment.Deserializer::class) - @JsonSerialize(using = Adjustment.Serializer::class) - class Adjustment - private constructor( - private val percentageDiscount: NewPercentageDiscount? = null, - private val usageDiscount: NewUsageDiscount? = null, - private val amountDiscount: NewAmountDiscount? = null, - private val minimum: NewMinimum? = null, - private val maximum: NewMaximum? = null, - private val _json: JsonValue? = null, - ) { + /** A builder for [GroupedWithMinMaxThresholdsConfig]. */ + class Builder internal constructor() { - fun percentageDiscount(): NewPercentageDiscount? = percentageDiscount + private var groupingKey: JsonField? = null + private var maximumCharge: JsonField? = null + private var minimumCharge: JsonField? = null + private var perUnitRate: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() - fun usageDiscount(): NewUsageDiscount? = usageDiscount + internal fun from( + groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + ) = apply { + groupingKey = groupedWithMinMaxThresholdsConfig.groupingKey + maximumCharge = groupedWithMinMaxThresholdsConfig.maximumCharge + minimumCharge = groupedWithMinMaxThresholdsConfig.minimumCharge + perUnitRate = groupedWithMinMaxThresholdsConfig.perUnitRate + additionalProperties = + groupedWithMinMaxThresholdsConfig.additionalProperties + .toMutableMap() + } - fun amountDiscount(): NewAmountDiscount? = amountDiscount + /** The event property used to group before applying thresholds */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) - fun minimum(): NewMinimum? = minimum + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } - fun maximum(): NewMaximum? = maximum + /** The maximum amount to charge each group */ + fun maximumCharge(maximumCharge: String) = + maximumCharge(JsonField.of(maximumCharge)) - fun isPercentageDiscount(): Boolean = percentageDiscount != null + /** + * Sets [Builder.maximumCharge] to an arbitrary JSON value. + * + * You should usually call [Builder.maximumCharge] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun maximumCharge(maximumCharge: JsonField) = apply { + this.maximumCharge = maximumCharge + } - fun isUsageDiscount(): Boolean = usageDiscount != null + /** The minimum amount to charge each group, regardless of usage */ + fun minimumCharge(minimumCharge: String) = + minimumCharge(JsonField.of(minimumCharge)) - fun isAmountDiscount(): Boolean = amountDiscount != null + /** + * Sets [Builder.minimumCharge] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumCharge] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun minimumCharge(minimumCharge: JsonField) = apply { + this.minimumCharge = minimumCharge + } - fun isMinimum(): Boolean = minimum != null + /** The base price charged per group */ + fun perUnitRate(perUnitRate: String) = + perUnitRate(JsonField.of(perUnitRate)) - fun isMaximum(): Boolean = maximum != null + /** + * Sets [Builder.perUnitRate] to an arbitrary JSON value. + * + * You should usually call [Builder.perUnitRate] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun perUnitRate(perUnitRate: JsonField) = apply { + this.perUnitRate = perUnitRate + } - fun asPercentageDiscount(): NewPercentageDiscount = - percentageDiscount.getOrThrow("percentageDiscount") + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun asUsageDiscount(): NewUsageDiscount = usageDiscount.getOrThrow("usageDiscount") + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun asAmountDiscount(): NewAmountDiscount = amountDiscount.getOrThrow("amountDiscount") + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun asMinimum(): NewMinimum = minimum.getOrThrow("minimum") + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun asMaximum(): NewMaximum = maximum.getOrThrow("maximum") + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - fun _json(): JsonValue? = _json + /** + * Returns an immutable instance of [GroupedWithMinMaxThresholdsConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .maximumCharge() + * .minimumCharge() + * .perUnitRate() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedWithMinMaxThresholdsConfig = + GroupedWithMinMaxThresholdsConfig( + checkRequired("groupingKey", groupingKey), + checkRequired("maximumCharge", maximumCharge), + checkRequired("minimumCharge", minimumCharge), + checkRequired("perUnitRate", perUnitRate), + additionalProperties.toMutableMap(), + ) + } - fun accept(visitor: Visitor): T = - when { - percentageDiscount != null -> - visitor.visitPercentageDiscount(percentageDiscount) - usageDiscount != null -> visitor.visitUsageDiscount(usageDiscount) - amountDiscount != null -> visitor.visitAmountDiscount(amountDiscount) - minimum != null -> visitor.visitMinimum(minimum) - maximum != null -> visitor.visitMaximum(maximum) - else -> visitor.unknown(_json) - } + private var validated: Boolean = false - private var validated: Boolean = false + fun validate(): GroupedWithMinMaxThresholdsConfig = apply { + if (validated) { + return@apply + } - fun validate(): Adjustment = apply { - if (validated) { - return@apply - } + groupingKey() + maximumCharge() + minimumCharge() + perUnitRate() + validated = true + } - accept( - object : Visitor { - override fun visitPercentageDiscount( - percentageDiscount: NewPercentageDiscount - ) { - percentageDiscount.validate() + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false } - override fun visitUsageDiscount(usageDiscount: NewUsageDiscount) { - usageDiscount.validate() - } + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (groupingKey.asKnown() == null) 0 else 1) + + (if (maximumCharge.asKnown() == null) 0 else 1) + + (if (minimumCharge.asKnown() == null) 0 else 1) + + (if (perUnitRate.asKnown() == null) 0 else 1) - override fun visitAmountDiscount(amountDiscount: NewAmountDiscount) { - amountDiscount.validate() + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - override fun visitMinimum(minimum: NewMinimum) { - minimum.validate() - } + return other is GroupedWithMinMaxThresholdsConfig && + groupingKey == other.groupingKey && + maximumCharge == other.maximumCharge && + minimumCharge == other.minimumCharge && + perUnitRate == other.perUnitRate && + additionalProperties == other.additionalProperties + } - override fun visitMaximum(maximum: NewMaximum) { - maximum.validate() - } + private val hashCode: Int by lazy { + Objects.hash( + groupingKey, + maximumCharge, + minimumCharge, + perUnitRate, + additionalProperties, + ) } - ) - validated = true - } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + override fun hashCode(): Int = hashCode - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitPercentageDiscount( - percentageDiscount: NewPercentageDiscount - ) = percentageDiscount.validity() + override fun toString() = + "GroupedWithMinMaxThresholdsConfig{groupingKey=$groupingKey, maximumCharge=$maximumCharge, minimumCharge=$minimumCharge, perUnitRate=$perUnitRate, additionalProperties=$additionalProperties}" + } - override fun visitUsageDiscount(usageDiscount: NewUsageDiscount) = - usageDiscount.validity() + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { - override fun visitAmountDiscount(amountDiscount: NewAmountDiscount) = - amountDiscount.validity() + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties - override fun visitMinimum(minimum: NewMinimum) = minimum.validity() + fun toBuilder() = Builder().from(this) - override fun visitMaximum(maximum: NewMaximum) = maximum.validity() + companion object { - override fun unknown(json: JsonValue?) = 0 + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() } - ) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** A builder for [Metadata]. */ + class Builder internal constructor() { - return other is Adjustment && - percentageDiscount == other.percentageDiscount && - usageDiscount == other.usageDiscount && - amountDiscount == other.amountDiscount && - minimum == other.minimum && - maximum == other.maximum - } + private var additionalProperties: MutableMap = + mutableMapOf() - override fun hashCode(): Int = - Objects.hash(percentageDiscount, usageDiscount, amountDiscount, minimum, maximum) + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } - override fun toString(): String = - when { - percentageDiscount != null -> - "Adjustment{percentageDiscount=$percentageDiscount}" - usageDiscount != null -> "Adjustment{usageDiscount=$usageDiscount}" - amountDiscount != null -> "Adjustment{amountDiscount=$amountDiscount}" - minimum != null -> "Adjustment{minimum=$minimum}" - maximum != null -> "Adjustment{maximum=$maximum}" - _json != null -> "Adjustment{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Adjustment") - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - companion object { + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun ofPercentageDiscount(percentageDiscount: NewPercentageDiscount) = - Adjustment(percentageDiscount = percentageDiscount) + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun ofUsageDiscount(usageDiscount: NewUsageDiscount) = - Adjustment(usageDiscount = usageDiscount) + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun ofAmountDiscount(amountDiscount: NewAmountDiscount) = - Adjustment(amountDiscount = amountDiscount) + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - fun ofMinimum(minimum: NewMinimum) = Adjustment(minimum = minimum) + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } - fun ofMaximum(maximum: NewMaximum) = Adjustment(maximum = maximum) - } + private var validated: Boolean = false - /** - * An interface that defines how to map each variant of [Adjustment] to a value of type - * [T]. - */ - interface Visitor { + fun validate(): Metadata = apply { + if (validated) { + return@apply + } - fun visitPercentageDiscount(percentageDiscount: NewPercentageDiscount): T + validated = true + } - fun visitUsageDiscount(usageDiscount: NewUsageDiscount): T + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - fun visitAmountDiscount(amountDiscount: NewAmountDiscount): T + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } - fun visitMinimum(minimum: NewMinimum): T + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun visitMaximum(maximum: NewMaximum): T + return other is Metadata && + additionalProperties == other.additionalProperties + } - /** - * Maps an unknown variant of [Adjustment] to a value of type [T]. - * - * An instance of [Adjustment] can contain an unknown variant if it was deserialized - * from data that doesn't match any known variant. For example, if the SDK is on an - * older version than the API, then the API may respond with new variants that the - * SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown Adjustment: $json") - } - } + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - internal class Deserializer : BaseDeserializer(Adjustment::class) { + override fun hashCode(): Int = hashCode - override fun ObjectCodec.deserialize(node: JsonNode): Adjustment { - val json = JsonValue.fromJsonNode(node) - val adjustmentType = json.asObject()?.get("adjustment_type")?.asString() + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } - when (adjustmentType) { - "percentage_discount" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Adjustment(percentageDiscount = it, _json = json) } - ?: Adjustment(_json = json) - } - "usage_discount" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(usageDiscount = it, _json = json) - } ?: Adjustment(_json = json) - } - "amount_discount" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(amountDiscount = it, _json = json) - } ?: Adjustment(_json = json) - } - "minimum" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(minimum = it, _json = json) - } ?: Adjustment(_json = json) - } - "maximum" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(maximum = it, _json = json) - } ?: Adjustment(_json = json) - } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - return Adjustment(_json = json) + return other is GroupedWithMinMaxThresholds && + cadence == other.cadence && + groupedWithMinMaxThresholdsConfig == + other.groupedWithMinMaxThresholdsConfig && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties } - } - internal class Serializer : BaseSerializer(Adjustment::class) { - - override fun serialize( - value: Adjustment, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.percentageDiscount != null -> - generator.writeObject(value.percentageDiscount) - value.usageDiscount != null -> generator.writeObject(value.usageDiscount) - value.amountDiscount != null -> generator.writeObject(value.amountDiscount) - value.minimum != null -> generator.writeObject(value.minimum) - value.maximum != null -> generator.writeObject(value.maximum) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Adjustment") - } + private val hashCode: Int by lazy { + Objects.hash( + cadence, + groupedWithMinMaxThresholdsConfig, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties, + ) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedWithMinMaxThresholds{cadence=$cadence, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } } @@ -8652,597 +9456,360 @@ private constructor( return true } - return other is ReplaceAdjustment && - adjustment == other.adjustment && - replacesAdjustmentId == other.replacesAdjustmentId && + return other is AddPrice && + allocationPrice == other.allocationPrice && + discounts == other.discounts && + endDate == other.endDate && + externalPriceId == other.externalPriceId && + maximumAmount == other.maximumAmount && + minimumAmount == other.minimumAmount && + planPhaseOrder == other.planPhaseOrder && + price == other.price && + priceId == other.priceId && + startDate == other.startDate && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(adjustment, replacesAdjustmentId, additionalProperties) + Objects.hash( + allocationPrice, + discounts, + endDate, + externalPriceId, + maximumAmount, + minimumAmount, + planPhaseOrder, + price, + priceId, + startDate, + additionalProperties, + ) } override fun hashCode(): Int = hashCode override fun toString() = - "ReplaceAdjustment{adjustment=$adjustment, replacesAdjustmentId=$replacesAdjustmentId, additionalProperties=$additionalProperties}" + "AddPrice{allocationPrice=$allocationPrice, discounts=$discounts, endDate=$endDate, externalPriceId=$externalPriceId, maximumAmount=$maximumAmount, minimumAmount=$minimumAmount, planPhaseOrder=$planPhaseOrder, price=$price, priceId=$priceId, startDate=$startDate, additionalProperties=$additionalProperties}" } - class ReplacePrice - private constructor( - private val replacesPriceId: JsonField, - private val allocationPrice: JsonField, - private val discounts: JsonField>, - private val externalPriceId: JsonField, - private val fixedPriceQuantity: JsonField, - private val maximumAmount: JsonField, - private val minimumAmount: JsonField, - private val price: JsonField, - private val priceId: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("replaces_price_id") - @ExcludeMissing - replacesPriceId: JsonField = JsonMissing.of(), - @JsonProperty("allocation_price") - @ExcludeMissing - allocationPrice: JsonField = JsonMissing.of(), - @JsonProperty("discounts") - @ExcludeMissing - discounts: JsonField> = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("maximum_amount") - @ExcludeMissing - maximumAmount: JsonField = JsonMissing.of(), - @JsonProperty("minimum_amount") - @ExcludeMissing - minimumAmount: JsonField = JsonMissing.of(), - @JsonProperty("price") @ExcludeMissing price: JsonField = JsonMissing.of(), - @JsonProperty("price_id") @ExcludeMissing priceId: JsonField = JsonMissing.of(), - ) : this( - replacesPriceId, - allocationPrice, - discounts, - externalPriceId, - fixedPriceQuantity, - maximumAmount, - minimumAmount, - price, - priceId, - mutableMapOf(), - ) + @Deprecated("deprecated") + class ExternalMarketplace + @JsonCreator + private constructor(private val value: JsonField) : Enum { /** - * The id of the price on the plan to replace in the subscription. + * Returns this class instance's raw value. * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. */ - fun replacesPriceId(): String = replacesPriceId.getRequired("replaces_price_id") + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - /** - * The definition of a new allocation price to create and add to the subscription. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun allocationPrice(): NewAllocationPrice? = allocationPrice.getNullable("allocation_price") + companion object { - /** - * [DEPRECATED] Use add_adjustments instead. The subscription's discounts for the - * replacement price. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - @Deprecated("deprecated") - fun discounts(): List? = discounts.getNullable("discounts") + val GOOGLE = of("google") - /** - * The external price id of the price to add to the subscription. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + val AWS = of("aws") - /** - * The new quantity of the price, if the price is a fixed price. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun fixedPriceQuantity(): Double? = fixedPriceQuantity.getNullable("fixed_price_quantity") + val AZURE = of("azure") - /** - * [DEPRECATED] Use add_adjustments instead. The subscription's maximum amount for the - * replacement price. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - @Deprecated("deprecated") - fun maximumAmount(): String? = maximumAmount.getNullable("maximum_amount") + fun of(value: String) = ExternalMarketplace(JsonField.of(value)) + } - /** - * [DEPRECATED] Use add_adjustments instead. The subscription's minimum amount for the - * replacement price. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - @Deprecated("deprecated") - fun minimumAmount(): String? = minimumAmount.getNullable("minimum_amount") + /** An enum containing [ExternalMarketplace]'s known values. */ + enum class Known { + GOOGLE, + AWS, + AZURE, + } /** - * The definition of a new price to create and add to the subscription. + * An enum containing [ExternalMarketplace]'s known values, as well as an [_UNKNOWN] member. * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). + * An instance of [ExternalMarketplace] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. */ - fun price(): Price? = price.getNullable("price") + enum class Value { + GOOGLE, + AWS, + AZURE, + /** + * An enum member indicating that [ExternalMarketplace] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } /** - * The id of the price to add to the subscription. + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. */ - fun priceId(): String? = priceId.getNullable("price_id") + fun value(): Value = + when (this) { + GOOGLE -> Value.GOOGLE + AWS -> Value.AWS + AZURE -> Value.AZURE + else -> Value._UNKNOWN + } /** - * Returns the raw JSON value of [replacesPriceId]. + * Returns an enum member corresponding to this class instance's value. * - * Unlike [replacesPriceId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("replaces_price_id") - @ExcludeMissing - fun _replacesPriceId(): JsonField = replacesPriceId - - /** - * Returns the raw JSON value of [allocationPrice]. + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. * - * Unlike [allocationPrice], this method doesn't throw if the JSON field has an unexpected - * type. + * @throws OrbInvalidDataException if this class instance's value is a not a known member. */ - @JsonProperty("allocation_price") - @ExcludeMissing - fun _allocationPrice(): JsonField = allocationPrice + fun known(): Known = + when (this) { + GOOGLE -> Known.GOOGLE + AWS -> Known.AWS + AZURE -> Known.AZURE + else -> throw OrbInvalidDataException("Unknown ExternalMarketplace: $value") + } /** - * Returns the raw JSON value of [discounts]. + * Returns this class instance's primitive wire representation. * - * Unlike [discounts], this method doesn't throw if the JSON field has an unexpected type. - */ - @Deprecated("deprecated") - @JsonProperty("discounts") - @ExcludeMissing - fun _discounts(): JsonField> = discounts - - /** - * Returns the raw JSON value of [externalPriceId]. + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. * - * Unlike [externalPriceId], this method doesn't throw if the JSON field has an unexpected - * type. + * @throws OrbInvalidDataException if this class instance's value does not have the expected + * primitive type. */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") - /** - * Returns the raw JSON value of [fixedPriceQuantity]. - * - * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + private var validated: Boolean = false - /** - * Returns the raw JSON value of [maximumAmount]. - * - * Unlike [maximumAmount], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @Deprecated("deprecated") - @JsonProperty("maximum_amount") - @ExcludeMissing - fun _maximumAmount(): JsonField = maximumAmount + fun validate(): ExternalMarketplace = apply { + if (validated) { + return@apply + } - /** - * Returns the raw JSON value of [minimumAmount]. - * - * Unlike [minimumAmount], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @Deprecated("deprecated") - @JsonProperty("minimum_amount") - @ExcludeMissing - fun _minimumAmount(): JsonField = minimumAmount + known() + validated = true + } - /** - * Returns the raw JSON value of [price]. - * - * Unlike [price], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("price") @ExcludeMissing fun _price(): JsonField = price + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } /** - * Returns the raw JSON value of [priceId]. + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * Unlike [priceId], this method doesn't throw if the JSON field has an unexpected type. + * Used for best match union deserialization. */ - @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ExternalMarketplace && value == other.value } + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by setting + * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to + * `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + fun _additionalProperties(): Map = additionalProperties fun toBuilder() = Builder().from(this) companion object { - /** - * Returns a mutable builder for constructing an instance of [ReplacePrice]. - * - * The following fields are required: - * ```kotlin - * .replacesPriceId() - * ``` - */ + /** Returns a mutable builder for constructing an instance of [Metadata]. */ fun builder() = Builder() } - /** A builder for [ReplacePrice]. */ + /** A builder for [Metadata]. */ class Builder internal constructor() { - private var replacesPriceId: JsonField? = null - private var allocationPrice: JsonField = JsonMissing.of() - private var discounts: JsonField>? = null - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var maximumAmount: JsonField = JsonMissing.of() - private var minimumAmount: JsonField = JsonMissing.of() - private var price: JsonField = JsonMissing.of() - private var priceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(replacePrice: ReplacePrice) = apply { - replacesPriceId = replacePrice.replacesPriceId - allocationPrice = replacePrice.allocationPrice - discounts = replacePrice.discounts.map { it.toMutableList() } - externalPriceId = replacePrice.externalPriceId - fixedPriceQuantity = replacePrice.fixedPriceQuantity - maximumAmount = replacePrice.maximumAmount - minimumAmount = replacePrice.minimumAmount - price = replacePrice.price - priceId = replacePrice.priceId - additionalProperties = replacePrice.additionalProperties.toMutableMap() + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() } - /** The id of the price on the plan to replace in the subscription. */ - fun replacesPriceId(replacesPriceId: String) = - replacesPriceId(JsonField.of(replacesPriceId)) - - /** - * Sets [Builder.replacesPriceId] to an arbitrary JSON value. - * - * You should usually call [Builder.replacesPriceId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun replacesPriceId(replacesPriceId: JsonField) = apply { - this.replacesPriceId = replacesPriceId + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) } - /** The definition of a new allocation price to create and add to the subscription. */ - fun allocationPrice(allocationPrice: NewAllocationPrice?) = - allocationPrice(JsonField.ofNullable(allocationPrice)) + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * Sets [Builder.allocationPrice] to an arbitrary JSON value. - * - * You should usually call [Builder.allocationPrice] with a well-typed - * [NewAllocationPrice] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun allocationPrice(allocationPrice: JsonField) = apply { - this.allocationPrice = allocationPrice + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) } - /** - * [DEPRECATED] Use add_adjustments instead. The subscription's discounts for the - * replacement price. - */ - @Deprecated("deprecated") - fun discounts(discounts: List?) = - discounts(JsonField.ofNullable(discounts)) + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - /** - * Sets [Builder.discounts] to an arbitrary JSON value. - * - * You should usually call [Builder.discounts] with a well-typed - * `List` value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - @Deprecated("deprecated") - fun discounts(discounts: JsonField>) = apply { - this.discounts = discounts.map { it.toMutableList() } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) } /** - * Adds a single [DiscountOverride] to [discounts]. + * Returns an immutable instance of [Metadata]. * - * @throws IllegalStateException if the field was previously set to a non-list. + * Further updates to this [Builder] will not mutate the returned instance. */ - @Deprecated("deprecated") - fun addDiscount(discount: DiscountOverride) = apply { - discounts = - (discounts ?: JsonField.of(mutableListOf())).also { - checkKnown("discounts", it).add(discount) - } - } + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } - /** The external price id of the price to add to the subscription. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) + private var validated: Boolean = false - /** - * Sets [Builder.externalPriceId] to an arbitrary JSON value. - * - * You should usually call [Builder.externalPriceId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun externalPriceId(externalPriceId: JsonField) = apply { - this.externalPriceId = externalPriceId + fun validate(): Metadata = apply { + if (validated) { + return@apply } - /** The new quantity of the price, if the price is a fixed price. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = - fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) - - /** - * Alias for [Builder.fixedPriceQuantity]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) + validated = true + } - /** - * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. - * - * You should usually call [Builder.fixedPriceQuantity] with a well-typed [Double] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { - this.fixedPriceQuantity = fixedPriceQuantity + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false } - /** - * [DEPRECATED] Use add_adjustments instead. The subscription's maximum amount for the - * replacement price. - */ - @Deprecated("deprecated") - fun maximumAmount(maximumAmount: String?) = - maximumAmount(JsonField.ofNullable(maximumAmount)) + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } - /** - * Sets [Builder.maximumAmount] to an arbitrary JSON value. - * - * You should usually call [Builder.maximumAmount] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - @Deprecated("deprecated") - fun maximumAmount(maximumAmount: JsonField) = apply { - this.maximumAmount = maximumAmount + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - /** - * [DEPRECATED] Use add_adjustments instead. The subscription's minimum amount for the - * replacement price. - */ - @Deprecated("deprecated") - fun minimumAmount(minimumAmount: String?) = - minimumAmount(JsonField.ofNullable(minimumAmount)) - - /** - * Sets [Builder.minimumAmount] to an arbitrary JSON value. - * - * You should usually call [Builder.minimumAmount] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - @Deprecated("deprecated") - fun minimumAmount(minimumAmount: JsonField) = apply { - this.minimumAmount = minimumAmount - } + return other is Metadata && additionalProperties == other.additionalProperties + } - /** The definition of a new price to create and add to the subscription. */ - fun price(price: Price?) = price(JsonField.ofNullable(price)) + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /** - * Sets [Builder.price] to an arbitrary JSON value. - * - * You should usually call [Builder.price] with a well-typed [Price] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun price(price: JsonField) = apply { this.price = price } + override fun hashCode(): Int = hashCode - /** Alias for calling [price] with `Price.ofUnit(unit)`. */ - fun price(unit: NewSubscriptionUnitPrice) = price(Price.ofUnit(unit)) + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } - /** Alias for calling [price] with `Price.ofPackage(package_)`. */ - fun price(package_: NewSubscriptionPackagePrice) = price(Price.ofPackage(package_)) + class RemoveAdjustment + private constructor( + private val adjustmentId: JsonField, + private val additionalProperties: MutableMap, + ) { - /** Alias for calling [price] with `Price.ofMatrix(matrix)`. */ - fun price(matrix: NewSubscriptionMatrixPrice) = price(Price.ofMatrix(matrix)) + @JsonCreator + private constructor( + @JsonProperty("adjustment_id") + @ExcludeMissing + adjustmentId: JsonField = JsonMissing.of() + ) : this(adjustmentId, mutableMapOf()) - /** Alias for calling [price] with `Price.ofTiered(tiered)`. */ - fun price(tiered: NewSubscriptionTieredPrice) = price(Price.ofTiered(tiered)) + /** + * The id of the adjustment to remove on the subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun adjustmentId(): String = adjustmentId.getRequired("adjustment_id") - /** Alias for calling [price] with `Price.ofBulk(bulk)`. */ - fun price(bulk: NewSubscriptionBulkPrice) = price(Price.ofBulk(bulk)) + /** + * Returns the raw JSON value of [adjustmentId]. + * + * Unlike [adjustmentId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("adjustment_id") + @ExcludeMissing + fun _adjustmentId(): JsonField = adjustmentId - /** - * Alias for calling [price] with `Price.ofThresholdTotalAmount(thresholdTotalAmount)`. - */ - fun price(thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice) = - price(Price.ofThresholdTotalAmount(thresholdTotalAmount)) + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - /** Alias for calling [price] with `Price.ofTieredPackage(tieredPackage)`. */ - fun price(tieredPackage: NewSubscriptionTieredPackagePrice) = - price(Price.ofTieredPackage(tieredPackage)) + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - /** Alias for calling [price] with `Price.ofTieredWithMinimum(tieredWithMinimum)`. */ - fun price(tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice) = - price(Price.ofTieredWithMinimum(tieredWithMinimum)) + fun toBuilder() = Builder().from(this) - /** Alias for calling [price] with `Price.ofUnitWithPercent(unitWithPercent)`. */ - fun price(unitWithPercent: NewSubscriptionUnitWithPercentPrice) = - price(Price.ofUnitWithPercent(unitWithPercent)) + companion object { /** - * Alias for calling [price] with - * `Price.ofPackageWithAllocation(packageWithAllocation)`. + * Returns a mutable builder for constructing an instance of [RemoveAdjustment]. + * + * The following fields are required: + * ```kotlin + * .adjustmentId() + * ``` */ - fun price(packageWithAllocation: NewSubscriptionPackageWithAllocationPrice) = - price(Price.ofPackageWithAllocation(packageWithAllocation)) + fun builder() = Builder() + } - /** - * Alias for calling [price] with `Price.ofTieredWithProration(tieredWithProration)`. - */ - fun price(tieredWithProration: NewSubscriptionTierWithProrationPrice) = - price(Price.ofTieredWithProration(tieredWithProration)) + /** A builder for [RemoveAdjustment]. */ + class Builder internal constructor() { - /** Alias for calling [price] with `Price.ofUnitWithProration(unitWithProration)`. */ - fun price(unitWithProration: NewSubscriptionUnitWithProrationPrice) = - price(Price.ofUnitWithProration(unitWithProration)) - - /** Alias for calling [price] with `Price.ofGroupedAllocation(groupedAllocation)`. */ - fun price(groupedAllocation: NewSubscriptionGroupedAllocationPrice) = - price(Price.ofGroupedAllocation(groupedAllocation)) - - /** - * Alias for calling [price] with - * `Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)`. - */ - fun price(groupedWithProratedMinimum: NewSubscriptionGroupedWithProratedMinimumPrice) = - price(Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)) - - /** Alias for calling [price] with `Price.ofBulkWithProration(bulkWithProration)`. */ - fun price(bulkWithProration: NewSubscriptionBulkWithProrationPrice) = - price(Price.ofBulkWithProration(bulkWithProration)) - - /** - * Alias for calling [price] with - * `Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)`. - */ - fun price( - scalableMatrixWithUnitPricing: NewSubscriptionScalableMatrixWithUnitPricingPrice - ) = price(Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)) - - /** - * Alias for calling [price] with - * `Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)`. - */ - fun price( - scalableMatrixWithTieredPricing: NewSubscriptionScalableMatrixWithTieredPricingPrice - ) = price(Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)) - - /** - * Alias for calling [price] with - * `Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)`. - */ - fun price(cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice) = - price(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) - - /** - * Alias for calling [price] with - * `Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)`. - */ - fun price(maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice) = - price(Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)) - - /** - * Alias for calling [price] with - * `Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)`. - */ - fun price(groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice) = - price(Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)) - - /** - * Alias for calling [price] with - * `Price.ofMatrixWithDisplayName(matrixWithDisplayName)`. - */ - fun price(matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice) = - price(Price.ofMatrixWithDisplayName(matrixWithDisplayName)) - - /** - * Alias for calling [price] with `Price.ofGroupedTieredPackage(groupedTieredPackage)`. - */ - fun price(groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice) = - price(Price.ofGroupedTieredPackage(groupedTieredPackage)) - - /** - * Alias for calling [price] with `Price.ofMatrixWithAllocation(matrixWithAllocation)`. - */ - fun price(matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice) = - price(Price.ofMatrixWithAllocation(matrixWithAllocation)) - - /** - * Alias for calling [price] with - * `Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)`. - */ - fun price(tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice) = - price(Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)) - - /** Alias for calling [price] with `Price.ofGroupedTiered(groupedTiered)`. */ - fun price(groupedTiered: NewSubscriptionGroupedTieredPrice) = - price(Price.ofGroupedTiered(groupedTiered)) - - /** - * Alias for calling [price] with - * `Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)`. - */ - fun price(groupedWithMinMaxThresholds: Price.GroupedWithMinMaxThresholds) = - price(Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)) + private var adjustmentId: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() - /** Alias for calling [price] with `Price.ofMinimum(minimum)`. */ - fun price(minimum: NewSubscriptionMinimumCompositePrice) = - price(Price.ofMinimum(minimum)) + internal fun from(removeAdjustment: RemoveAdjustment) = apply { + adjustmentId = removeAdjustment.adjustmentId + additionalProperties = removeAdjustment.additionalProperties.toMutableMap() + } - /** The id of the price to add to the subscription. */ - fun priceId(priceId: String?) = priceId(JsonField.ofNullable(priceId)) + /** The id of the adjustment to remove on the subscription. */ + fun adjustmentId(adjustmentId: String) = adjustmentId(JsonField.of(adjustmentId)) /** - * Sets [Builder.priceId] to an arbitrary JSON value. + * Sets [Builder.adjustmentId] to an arbitrary JSON value. * - * You should usually call [Builder.priceId] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet + * You should usually call [Builder.adjustmentId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun priceId(priceId: JsonField) = apply { this.priceId = priceId } + fun adjustmentId(adjustmentId: JsonField) = apply { + this.adjustmentId = adjustmentId + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -9264,48 +9831,32 @@ private constructor( } /** - * Returns an immutable instance of [ReplacePrice]. + * Returns an immutable instance of [RemoveAdjustment]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```kotlin - * .replacesPriceId() + * .adjustmentId() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): ReplacePrice = - ReplacePrice( - checkRequired("replacesPriceId", replacesPriceId), - allocationPrice, - (discounts ?: JsonMissing.of()).map { it.toImmutable() }, - externalPriceId, - fixedPriceQuantity, - maximumAmount, - minimumAmount, - price, - priceId, + fun build(): RemoveAdjustment = + RemoveAdjustment( + checkRequired("adjustmentId", adjustmentId), additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): ReplacePrice = apply { + fun validate(): RemoveAdjustment = apply { if (validated) { return@apply } - replacesPriceId() - allocationPrice()?.validate() - discounts()?.forEach { it.validate() } - externalPriceId() - fixedPriceQuantity() - maximumAmount() - minimumAmount() - price()?.validate() - priceId() + adjustmentId() validated = true } @@ -9323,1196 +9874,4380 @@ private constructor( * * Used for best match union deserialization. */ - internal fun validity(): Int = - (if (replacesPriceId.asKnown() == null) 0 else 1) + - (allocationPrice.asKnown()?.validity() ?: 0) + - (discounts.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + - (if (externalPriceId.asKnown() == null) 0 else 1) + - (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + - (if (maximumAmount.asKnown() == null) 0 else 1) + - (if (minimumAmount.asKnown() == null) 0 else 1) + - (price.asKnown()?.validity() ?: 0) + - (if (priceId.asKnown() == null) 0 else 1) + internal fun validity(): Int = (if (adjustmentId.asKnown() == null) 0 else 1) - /** The definition of a new price to create and add to the subscription. */ - @JsonDeserialize(using = Price.Deserializer::class) - @JsonSerialize(using = Price.Serializer::class) - class Price - private constructor( - private val unit: NewSubscriptionUnitPrice? = null, - private val package_: NewSubscriptionPackagePrice? = null, - private val matrix: NewSubscriptionMatrixPrice? = null, - private val tiered: NewSubscriptionTieredPrice? = null, - private val bulk: NewSubscriptionBulkPrice? = null, - private val thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice? = null, - private val tieredPackage: NewSubscriptionTieredPackagePrice? = null, - private val tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice? = null, - private val unitWithPercent: NewSubscriptionUnitWithPercentPrice? = null, - private val packageWithAllocation: NewSubscriptionPackageWithAllocationPrice? = null, - private val tieredWithProration: NewSubscriptionTierWithProrationPrice? = null, - private val unitWithProration: NewSubscriptionUnitWithProrationPrice? = null, - private val groupedAllocation: NewSubscriptionGroupedAllocationPrice? = null, - private val groupedWithProratedMinimum: - NewSubscriptionGroupedWithProratedMinimumPrice? = - null, - private val bulkWithProration: NewSubscriptionBulkWithProrationPrice? = null, - private val scalableMatrixWithUnitPricing: - NewSubscriptionScalableMatrixWithUnitPricingPrice? = - null, - private val scalableMatrixWithTieredPricing: - NewSubscriptionScalableMatrixWithTieredPricingPrice? = - null, - private val cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice? = null, - private val maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice? = null, - private val groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice? = - null, - private val matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice? = null, - private val groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice? = null, - private val matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice? = null, - private val tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice? = - null, - private val groupedTiered: NewSubscriptionGroupedTieredPrice? = null, - private val groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds? = null, - private val minimum: NewSubscriptionMinimumCompositePrice? = null, - private val _json: JsonValue? = null, - ) { + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun unit(): NewSubscriptionUnitPrice? = unit + return other is RemoveAdjustment && + adjustmentId == other.adjustmentId && + additionalProperties == other.additionalProperties + } - fun package_(): NewSubscriptionPackagePrice? = package_ + private val hashCode: Int by lazy { Objects.hash(adjustmentId, additionalProperties) } - fun matrix(): NewSubscriptionMatrixPrice? = matrix + override fun hashCode(): Int = hashCode - fun tiered(): NewSubscriptionTieredPrice? = tiered + override fun toString() = + "RemoveAdjustment{adjustmentId=$adjustmentId, additionalProperties=$additionalProperties}" + } - fun bulk(): NewSubscriptionBulkPrice? = bulk + class RemovePrice + private constructor( + private val externalPriceId: JsonField, + private val priceId: JsonField, + private val additionalProperties: MutableMap, + ) { - fun thresholdTotalAmount(): NewSubscriptionThresholdTotalAmountPrice? = - thresholdTotalAmount + @JsonCreator + private constructor( + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("price_id") @ExcludeMissing priceId: JsonField = JsonMissing.of(), + ) : this(externalPriceId, priceId, mutableMapOf()) - fun tieredPackage(): NewSubscriptionTieredPackagePrice? = tieredPackage + /** + * The external price id of the price to remove on the subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") - fun tieredWithMinimum(): NewSubscriptionTieredWithMinimumPrice? = tieredWithMinimum + /** + * The id of the price to remove on the subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun priceId(): String? = priceId.getNullable("price_id") - fun unitWithPercent(): NewSubscriptionUnitWithPercentPrice? = unitWithPercent + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId - fun packageWithAllocation(): NewSubscriptionPackageWithAllocationPrice? = - packageWithAllocation - - fun tieredWithProration(): NewSubscriptionTierWithProrationPrice? = tieredWithProration - - fun unitWithProration(): NewSubscriptionUnitWithProrationPrice? = unitWithProration - - fun groupedAllocation(): NewSubscriptionGroupedAllocationPrice? = groupedAllocation + /** + * Returns the raw JSON value of [priceId]. + * + * Unlike [priceId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId - fun groupedWithProratedMinimum(): NewSubscriptionGroupedWithProratedMinimumPrice? = - groupedWithProratedMinimum + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - fun bulkWithProration(): NewSubscriptionBulkWithProrationPrice? = bulkWithProration + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - fun scalableMatrixWithUnitPricing(): - NewSubscriptionScalableMatrixWithUnitPricingPrice? = scalableMatrixWithUnitPricing + fun toBuilder() = Builder().from(this) - fun scalableMatrixWithTieredPricing(): - NewSubscriptionScalableMatrixWithTieredPricingPrice? = - scalableMatrixWithTieredPricing + companion object { - fun cumulativeGroupedBulk(): NewSubscriptionCumulativeGroupedBulkPrice? = - cumulativeGroupedBulk + /** Returns a mutable builder for constructing an instance of [RemovePrice]. */ + fun builder() = Builder() + } - fun maxGroupTieredPackage(): NewSubscriptionMaxGroupTieredPackagePrice? = - maxGroupTieredPackage + /** A builder for [RemovePrice]. */ + class Builder internal constructor() { - fun groupedWithMeteredMinimum(): NewSubscriptionGroupedWithMeteredMinimumPrice? = - groupedWithMeteredMinimum + private var externalPriceId: JsonField = JsonMissing.of() + private var priceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - fun matrixWithDisplayName(): NewSubscriptionMatrixWithDisplayNamePrice? = - matrixWithDisplayName + internal fun from(removePrice: RemovePrice) = apply { + externalPriceId = removePrice.externalPriceId + priceId = removePrice.priceId + additionalProperties = removePrice.additionalProperties.toMutableMap() + } - fun groupedTieredPackage(): NewSubscriptionGroupedTieredPackagePrice? = - groupedTieredPackage + /** The external price id of the price to remove on the subscription. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) - fun matrixWithAllocation(): NewSubscriptionMatrixWithAllocationPrice? = - matrixWithAllocation + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } - fun tieredPackageWithMinimum(): NewSubscriptionTieredPackageWithMinimumPrice? = - tieredPackageWithMinimum + /** The id of the price to remove on the subscription. */ + fun priceId(priceId: String?) = priceId(JsonField.ofNullable(priceId)) - fun groupedTiered(): NewSubscriptionGroupedTieredPrice? = groupedTiered + /** + * Sets [Builder.priceId] to an arbitrary JSON value. + * + * You should usually call [Builder.priceId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun priceId(priceId: JsonField) = apply { this.priceId = priceId } - fun groupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds? = - groupedWithMinMaxThresholds + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun minimum(): NewSubscriptionMinimumCompositePrice? = minimum + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun isUnit(): Boolean = unit != null + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun isPackage(): Boolean = package_ != null + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - fun isMatrix(): Boolean = matrix != null + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - fun isTiered(): Boolean = tiered != null + /** + * Returns an immutable instance of [RemovePrice]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): RemovePrice = + RemovePrice(externalPriceId, priceId, additionalProperties.toMutableMap()) + } - fun isBulk(): Boolean = bulk != null + private var validated: Boolean = false - fun isThresholdTotalAmount(): Boolean = thresholdTotalAmount != null + fun validate(): RemovePrice = apply { + if (validated) { + return@apply + } - fun isTieredPackage(): Boolean = tieredPackage != null + externalPriceId() + priceId() + validated = true + } - fun isTieredWithMinimum(): Boolean = tieredWithMinimum != null + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - fun isUnitWithPercent(): Boolean = unitWithPercent != null + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (priceId.asKnown() == null) 0 else 1) - fun isPackageWithAllocation(): Boolean = packageWithAllocation != null + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun isTieredWithProration(): Boolean = tieredWithProration != null + return other is RemovePrice && + externalPriceId == other.externalPriceId && + priceId == other.priceId && + additionalProperties == other.additionalProperties + } - fun isUnitWithProration(): Boolean = unitWithProration != null + private val hashCode: Int by lazy { + Objects.hash(externalPriceId, priceId, additionalProperties) + } - fun isGroupedAllocation(): Boolean = groupedAllocation != null + override fun hashCode(): Int = hashCode - fun isGroupedWithProratedMinimum(): Boolean = groupedWithProratedMinimum != null + override fun toString() = + "RemovePrice{externalPriceId=$externalPriceId, priceId=$priceId, additionalProperties=$additionalProperties}" + } - fun isBulkWithProration(): Boolean = bulkWithProration != null + class ReplaceAdjustment + private constructor( + private val adjustment: JsonField, + private val replacesAdjustmentId: JsonField, + private val additionalProperties: MutableMap, + ) { - fun isScalableMatrixWithUnitPricing(): Boolean = scalableMatrixWithUnitPricing != null + @JsonCreator + private constructor( + @JsonProperty("adjustment") + @ExcludeMissing + adjustment: JsonField = JsonMissing.of(), + @JsonProperty("replaces_adjustment_id") + @ExcludeMissing + replacesAdjustmentId: JsonField = JsonMissing.of(), + ) : this(adjustment, replacesAdjustmentId, mutableMapOf()) - fun isScalableMatrixWithTieredPricing(): Boolean = - scalableMatrixWithTieredPricing != null + /** + * The definition of a new adjustment to create and add to the subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun adjustment(): Adjustment = adjustment.getRequired("adjustment") - fun isCumulativeGroupedBulk(): Boolean = cumulativeGroupedBulk != null + /** + * The id of the adjustment on the plan to replace in the subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun replacesAdjustmentId(): String = + replacesAdjustmentId.getRequired("replaces_adjustment_id") - fun isMaxGroupTieredPackage(): Boolean = maxGroupTieredPackage != null + /** + * Returns the raw JSON value of [adjustment]. + * + * Unlike [adjustment], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("adjustment") + @ExcludeMissing + fun _adjustment(): JsonField = adjustment - fun isGroupedWithMeteredMinimum(): Boolean = groupedWithMeteredMinimum != null + /** + * Returns the raw JSON value of [replacesAdjustmentId]. + * + * Unlike [replacesAdjustmentId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("replaces_adjustment_id") + @ExcludeMissing + fun _replacesAdjustmentId(): JsonField = replacesAdjustmentId - fun isMatrixWithDisplayName(): Boolean = matrixWithDisplayName != null + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - fun isGroupedTieredPackage(): Boolean = groupedTieredPackage != null + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - fun isMatrixWithAllocation(): Boolean = matrixWithAllocation != null + fun toBuilder() = Builder().from(this) - fun isTieredPackageWithMinimum(): Boolean = tieredPackageWithMinimum != null + companion object { - fun isGroupedTiered(): Boolean = groupedTiered != null + /** + * Returns a mutable builder for constructing an instance of [ReplaceAdjustment]. + * + * The following fields are required: + * ```kotlin + * .adjustment() + * .replacesAdjustmentId() + * ``` + */ + fun builder() = Builder() + } - fun isGroupedWithMinMaxThresholds(): Boolean = groupedWithMinMaxThresholds != null + /** A builder for [ReplaceAdjustment]. */ + class Builder internal constructor() { - fun isMinimum(): Boolean = minimum != null + private var adjustment: JsonField? = null + private var replacesAdjustmentId: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() - fun asUnit(): NewSubscriptionUnitPrice = unit.getOrThrow("unit") + internal fun from(replaceAdjustment: ReplaceAdjustment) = apply { + adjustment = replaceAdjustment.adjustment + replacesAdjustmentId = replaceAdjustment.replacesAdjustmentId + additionalProperties = replaceAdjustment.additionalProperties.toMutableMap() + } - fun asPackage(): NewSubscriptionPackagePrice = package_.getOrThrow("package_") + /** The definition of a new adjustment to create and add to the subscription. */ + fun adjustment(adjustment: Adjustment) = adjustment(JsonField.of(adjustment)) - fun asMatrix(): NewSubscriptionMatrixPrice = matrix.getOrThrow("matrix") + /** + * Sets [Builder.adjustment] to an arbitrary JSON value. + * + * You should usually call [Builder.adjustment] with a well-typed [Adjustment] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun adjustment(adjustment: JsonField) = apply { + this.adjustment = adjustment + } - fun asTiered(): NewSubscriptionTieredPrice = tiered.getOrThrow("tiered") + /** + * Alias for calling [adjustment] with + * `Adjustment.ofPercentageDiscount(percentageDiscount)`. + */ + fun adjustment(percentageDiscount: NewPercentageDiscount) = + adjustment(Adjustment.ofPercentageDiscount(percentageDiscount)) - fun asBulk(): NewSubscriptionBulkPrice = bulk.getOrThrow("bulk") + /** + * Alias for calling [adjustment] with the following: + * ```kotlin + * NewPercentageDiscount.builder() + * .adjustmentType(NewPercentageDiscount.AdjustmentType.PERCENTAGE_DISCOUNT) + * .percentageDiscount(percentageDiscount) + * .build() + * ``` + */ + fun percentageDiscountAdjustment(percentageDiscount: Double) = + adjustment( + NewPercentageDiscount.builder() + .adjustmentType(NewPercentageDiscount.AdjustmentType.PERCENTAGE_DISCOUNT) + .percentageDiscount(percentageDiscount) + .build() + ) - fun asThresholdTotalAmount(): NewSubscriptionThresholdTotalAmountPrice = - thresholdTotalAmount.getOrThrow("thresholdTotalAmount") + /** Alias for calling [adjustment] with `Adjustment.ofUsageDiscount(usageDiscount)`. */ + fun adjustment(usageDiscount: NewUsageDiscount) = + adjustment(Adjustment.ofUsageDiscount(usageDiscount)) - fun asTieredPackage(): NewSubscriptionTieredPackagePrice = - tieredPackage.getOrThrow("tieredPackage") + /** + * Alias for calling [adjustment] with the following: + * ```kotlin + * NewUsageDiscount.builder() + * .adjustmentType(NewUsageDiscount.AdjustmentType.USAGE_DISCOUNT) + * .usageDiscount(usageDiscount) + * .build() + * ``` + */ + fun usageDiscountAdjustment(usageDiscount: Double) = + adjustment( + NewUsageDiscount.builder() + .adjustmentType(NewUsageDiscount.AdjustmentType.USAGE_DISCOUNT) + .usageDiscount(usageDiscount) + .build() + ) - fun asTieredWithMinimum(): NewSubscriptionTieredWithMinimumPrice = - tieredWithMinimum.getOrThrow("tieredWithMinimum") + /** + * Alias for calling [adjustment] with `Adjustment.ofAmountDiscount(amountDiscount)`. + */ + fun adjustment(amountDiscount: NewAmountDiscount) = + adjustment(Adjustment.ofAmountDiscount(amountDiscount)) - fun asUnitWithPercent(): NewSubscriptionUnitWithPercentPrice = - unitWithPercent.getOrThrow("unitWithPercent") + /** + * Alias for calling [adjustment] with the following: + * ```kotlin + * NewAmountDiscount.builder() + * .adjustmentType(NewAmountDiscount.AdjustmentType.AMOUNT_DISCOUNT) + * .amountDiscount(amountDiscount) + * .build() + * ``` + */ + fun amountDiscountAdjustment(amountDiscount: String) = + adjustment( + NewAmountDiscount.builder() + .adjustmentType(NewAmountDiscount.AdjustmentType.AMOUNT_DISCOUNT) + .amountDiscount(amountDiscount) + .build() + ) - fun asPackageWithAllocation(): NewSubscriptionPackageWithAllocationPrice = - packageWithAllocation.getOrThrow("packageWithAllocation") + /** Alias for calling [adjustment] with `Adjustment.ofMinimum(minimum)`. */ + fun adjustment(minimum: NewMinimum) = adjustment(Adjustment.ofMinimum(minimum)) - fun asTieredWithProration(): NewSubscriptionTierWithProrationPrice = - tieredWithProration.getOrThrow("tieredWithProration") + /** Alias for calling [adjustment] with `Adjustment.ofMaximum(maximum)`. */ + fun adjustment(maximum: NewMaximum) = adjustment(Adjustment.ofMaximum(maximum)) - fun asUnitWithProration(): NewSubscriptionUnitWithProrationPrice = - unitWithProration.getOrThrow("unitWithProration") + /** + * Alias for calling [adjustment] with the following: + * ```kotlin + * NewMaximum.builder() + * .adjustmentType(NewMaximum.AdjustmentType.MAXIMUM) + * .maximumAmount(maximumAmount) + * .build() + * ``` + */ + fun maximumAdjustment(maximumAmount: String) = + adjustment( + NewMaximum.builder() + .adjustmentType(NewMaximum.AdjustmentType.MAXIMUM) + .maximumAmount(maximumAmount) + .build() + ) - fun asGroupedAllocation(): NewSubscriptionGroupedAllocationPrice = - groupedAllocation.getOrThrow("groupedAllocation") + /** The id of the adjustment on the plan to replace in the subscription. */ + fun replacesAdjustmentId(replacesAdjustmentId: String) = + replacesAdjustmentId(JsonField.of(replacesAdjustmentId)) - fun asGroupedWithProratedMinimum(): NewSubscriptionGroupedWithProratedMinimumPrice = - groupedWithProratedMinimum.getOrThrow("groupedWithProratedMinimum") + /** + * Sets [Builder.replacesAdjustmentId] to an arbitrary JSON value. + * + * You should usually call [Builder.replacesAdjustmentId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun replacesAdjustmentId(replacesAdjustmentId: JsonField) = apply { + this.replacesAdjustmentId = replacesAdjustmentId + } - fun asBulkWithProration(): NewSubscriptionBulkWithProrationPrice = - bulkWithProration.getOrThrow("bulkWithProration") + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun asScalableMatrixWithUnitPricing(): - NewSubscriptionScalableMatrixWithUnitPricingPrice = - scalableMatrixWithUnitPricing.getOrThrow("scalableMatrixWithUnitPricing") + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun asScalableMatrixWithTieredPricing(): - NewSubscriptionScalableMatrixWithTieredPricingPrice = - scalableMatrixWithTieredPricing.getOrThrow("scalableMatrixWithTieredPricing") + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun asCumulativeGroupedBulk(): NewSubscriptionCumulativeGroupedBulkPrice = - cumulativeGroupedBulk.getOrThrow("cumulativeGroupedBulk") + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - fun asMaxGroupTieredPackage(): NewSubscriptionMaxGroupTieredPackagePrice = - maxGroupTieredPackage.getOrThrow("maxGroupTieredPackage") + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ReplaceAdjustment]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .adjustment() + * .replacesAdjustmentId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ReplaceAdjustment = + ReplaceAdjustment( + checkRequired("adjustment", adjustment), + checkRequired("replacesAdjustmentId", replacesAdjustmentId), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ReplaceAdjustment = apply { + if (validated) { + return@apply + } + + adjustment().validate() + replacesAdjustmentId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (adjustment.asKnown()?.validity() ?: 0) + + (if (replacesAdjustmentId.asKnown() == null) 0 else 1) + + /** The definition of a new adjustment to create and add to the subscription. */ + @JsonDeserialize(using = Adjustment.Deserializer::class) + @JsonSerialize(using = Adjustment.Serializer::class) + class Adjustment + private constructor( + private val percentageDiscount: NewPercentageDiscount? = null, + private val usageDiscount: NewUsageDiscount? = null, + private val amountDiscount: NewAmountDiscount? = null, + private val minimum: NewMinimum? = null, + private val maximum: NewMaximum? = null, + private val _json: JsonValue? = null, + ) { + + fun percentageDiscount(): NewPercentageDiscount? = percentageDiscount + + fun usageDiscount(): NewUsageDiscount? = usageDiscount + + fun amountDiscount(): NewAmountDiscount? = amountDiscount + + fun minimum(): NewMinimum? = minimum + + fun maximum(): NewMaximum? = maximum + + fun isPercentageDiscount(): Boolean = percentageDiscount != null + + fun isUsageDiscount(): Boolean = usageDiscount != null + + fun isAmountDiscount(): Boolean = amountDiscount != null + + fun isMinimum(): Boolean = minimum != null + + fun isMaximum(): Boolean = maximum != null + + fun asPercentageDiscount(): NewPercentageDiscount = + percentageDiscount.getOrThrow("percentageDiscount") + + fun asUsageDiscount(): NewUsageDiscount = usageDiscount.getOrThrow("usageDiscount") + + fun asAmountDiscount(): NewAmountDiscount = amountDiscount.getOrThrow("amountDiscount") + + fun asMinimum(): NewMinimum = minimum.getOrThrow("minimum") + + fun asMaximum(): NewMaximum = maximum.getOrThrow("maximum") + + fun _json(): JsonValue? = _json + + fun accept(visitor: Visitor): T = + when { + percentageDiscount != null -> + visitor.visitPercentageDiscount(percentageDiscount) + usageDiscount != null -> visitor.visitUsageDiscount(usageDiscount) + amountDiscount != null -> visitor.visitAmountDiscount(amountDiscount) + minimum != null -> visitor.visitMinimum(minimum) + maximum != null -> visitor.visitMaximum(maximum) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Adjustment = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitPercentageDiscount( + percentageDiscount: NewPercentageDiscount + ) { + percentageDiscount.validate() + } + + override fun visitUsageDiscount(usageDiscount: NewUsageDiscount) { + usageDiscount.validate() + } + + override fun visitAmountDiscount(amountDiscount: NewAmountDiscount) { + amountDiscount.validate() + } + + override fun visitMinimum(minimum: NewMinimum) { + minimum.validate() + } + + override fun visitMaximum(maximum: NewMaximum) { + maximum.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitPercentageDiscount( + percentageDiscount: NewPercentageDiscount + ) = percentageDiscount.validity() + + override fun visitUsageDiscount(usageDiscount: NewUsageDiscount) = + usageDiscount.validity() + + override fun visitAmountDiscount(amountDiscount: NewAmountDiscount) = + amountDiscount.validity() + + override fun visitMinimum(minimum: NewMinimum) = minimum.validity() + + override fun visitMaximum(maximum: NewMaximum) = maximum.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Adjustment && + percentageDiscount == other.percentageDiscount && + usageDiscount == other.usageDiscount && + amountDiscount == other.amountDiscount && + minimum == other.minimum && + maximum == other.maximum + } + + override fun hashCode(): Int = + Objects.hash(percentageDiscount, usageDiscount, amountDiscount, minimum, maximum) + + override fun toString(): String = + when { + percentageDiscount != null -> + "Adjustment{percentageDiscount=$percentageDiscount}" + usageDiscount != null -> "Adjustment{usageDiscount=$usageDiscount}" + amountDiscount != null -> "Adjustment{amountDiscount=$amountDiscount}" + minimum != null -> "Adjustment{minimum=$minimum}" + maximum != null -> "Adjustment{maximum=$maximum}" + _json != null -> "Adjustment{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Adjustment") + } + + companion object { + + fun ofPercentageDiscount(percentageDiscount: NewPercentageDiscount) = + Adjustment(percentageDiscount = percentageDiscount) + + fun ofUsageDiscount(usageDiscount: NewUsageDiscount) = + Adjustment(usageDiscount = usageDiscount) + + fun ofAmountDiscount(amountDiscount: NewAmountDiscount) = + Adjustment(amountDiscount = amountDiscount) + + fun ofMinimum(minimum: NewMinimum) = Adjustment(minimum = minimum) + + fun ofMaximum(maximum: NewMaximum) = Adjustment(maximum = maximum) + } + + /** + * An interface that defines how to map each variant of [Adjustment] to a value of type + * [T]. + */ + interface Visitor { + + fun visitPercentageDiscount(percentageDiscount: NewPercentageDiscount): T + + fun visitUsageDiscount(usageDiscount: NewUsageDiscount): T + + fun visitAmountDiscount(amountDiscount: NewAmountDiscount): T + + fun visitMinimum(minimum: NewMinimum): T + + fun visitMaximum(maximum: NewMaximum): T + + /** + * Maps an unknown variant of [Adjustment] to a value of type [T]. + * + * An instance of [Adjustment] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the + * SDK is unaware of. + * + * @throws OrbInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw OrbInvalidDataException("Unknown Adjustment: $json") + } + } + + internal class Deserializer : BaseDeserializer(Adjustment::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Adjustment { + val json = JsonValue.fromJsonNode(node) + val adjustmentType = json.asObject()?.get("adjustment_type")?.asString() + + when (adjustmentType) { + "percentage_discount" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Adjustment(percentageDiscount = it, _json = json) } + ?: Adjustment(_json = json) + } + "usage_discount" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(usageDiscount = it, _json = json) + } ?: Adjustment(_json = json) + } + "amount_discount" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(amountDiscount = it, _json = json) + } ?: Adjustment(_json = json) + } + "minimum" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(minimum = it, _json = json) + } ?: Adjustment(_json = json) + } + "maximum" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(maximum = it, _json = json) + } ?: Adjustment(_json = json) + } + } + + return Adjustment(_json = json) + } + } + + internal class Serializer : BaseSerializer(Adjustment::class) { + + override fun serialize( + value: Adjustment, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.percentageDiscount != null -> + generator.writeObject(value.percentageDiscount) + value.usageDiscount != null -> generator.writeObject(value.usageDiscount) + value.amountDiscount != null -> generator.writeObject(value.amountDiscount) + value.minimum != null -> generator.writeObject(value.minimum) + value.maximum != null -> generator.writeObject(value.maximum) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Adjustment") + } + } + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ReplaceAdjustment && + adjustment == other.adjustment && + replacesAdjustmentId == other.replacesAdjustmentId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(adjustment, replacesAdjustmentId, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ReplaceAdjustment{adjustment=$adjustment, replacesAdjustmentId=$replacesAdjustmentId, additionalProperties=$additionalProperties}" + } + + class ReplacePrice + private constructor( + private val replacesPriceId: JsonField, + private val allocationPrice: JsonField, + private val discounts: JsonField>, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val maximumAmount: JsonField, + private val minimumAmount: JsonField, + private val price: JsonField, + private val priceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("replaces_price_id") + @ExcludeMissing + replacesPriceId: JsonField = JsonMissing.of(), + @JsonProperty("allocation_price") + @ExcludeMissing + allocationPrice: JsonField = JsonMissing.of(), + @JsonProperty("discounts") + @ExcludeMissing + discounts: JsonField> = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("maximum_amount") + @ExcludeMissing + maximumAmount: JsonField = JsonMissing.of(), + @JsonProperty("minimum_amount") + @ExcludeMissing + minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("price") @ExcludeMissing price: JsonField = JsonMissing.of(), + @JsonProperty("price_id") @ExcludeMissing priceId: JsonField = JsonMissing.of(), + ) : this( + replacesPriceId, + allocationPrice, + discounts, + externalPriceId, + fixedPriceQuantity, + maximumAmount, + minimumAmount, + price, + priceId, + mutableMapOf(), + ) + + /** + * The id of the price on the plan to replace in the subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun replacesPriceId(): String = replacesPriceId.getRequired("replaces_price_id") + + /** + * The definition of a new allocation price to create and add to the subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun allocationPrice(): NewAllocationPrice? = allocationPrice.getNullable("allocation_price") + + /** + * [DEPRECATED] Use add_adjustments instead. The subscription's discounts for the + * replacement price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + @Deprecated("deprecated") + fun discounts(): List? = discounts.getNullable("discounts") + + /** + * The external price id of the price to add to the subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * The new quantity of the price, if the price is a fixed price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * [DEPRECATED] Use add_adjustments instead. The subscription's maximum amount for the + * replacement price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + @Deprecated("deprecated") + fun maximumAmount(): String? = maximumAmount.getNullable("maximum_amount") + + /** + * [DEPRECATED] Use add_adjustments instead. The subscription's minimum amount for the + * replacement price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + @Deprecated("deprecated") + fun minimumAmount(): String? = minimumAmount.getNullable("minimum_amount") + + /** + * New subscription price request body params. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun price(): Price? = price.getNullable("price") + + /** + * The id of the price to add to the subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun priceId(): String? = priceId.getNullable("price_id") + + /** + * Returns the raw JSON value of [replacesPriceId]. + * + * Unlike [replacesPriceId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("replaces_price_id") + @ExcludeMissing + fun _replacesPriceId(): JsonField = replacesPriceId + + /** + * Returns the raw JSON value of [allocationPrice]. + * + * Unlike [allocationPrice], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("allocation_price") + @ExcludeMissing + fun _allocationPrice(): JsonField = allocationPrice + + /** + * Returns the raw JSON value of [discounts]. + * + * Unlike [discounts], this method doesn't throw if the JSON field has an unexpected type. + */ + @Deprecated("deprecated") + @JsonProperty("discounts") + @ExcludeMissing + fun _discounts(): JsonField> = discounts + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [maximumAmount]. + * + * Unlike [maximumAmount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @Deprecated("deprecated") + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount + + /** + * Returns the raw JSON value of [minimumAmount]. + * + * Unlike [minimumAmount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @Deprecated("deprecated") + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount + + /** + * Returns the raw JSON value of [price]. + * + * Unlike [price], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("price") @ExcludeMissing fun _price(): JsonField = price + + /** + * Returns the raw JSON value of [priceId]. + * + * Unlike [priceId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ReplacePrice]. + * + * The following fields are required: + * ```kotlin + * .replacesPriceId() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [ReplacePrice]. */ + class Builder internal constructor() { + + private var replacesPriceId: JsonField? = null + private var allocationPrice: JsonField = JsonMissing.of() + private var discounts: JsonField>? = null + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var maximumAmount: JsonField = JsonMissing.of() + private var minimumAmount: JsonField = JsonMissing.of() + private var price: JsonField = JsonMissing.of() + private var priceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(replacePrice: ReplacePrice) = apply { + replacesPriceId = replacePrice.replacesPriceId + allocationPrice = replacePrice.allocationPrice + discounts = replacePrice.discounts.map { it.toMutableList() } + externalPriceId = replacePrice.externalPriceId + fixedPriceQuantity = replacePrice.fixedPriceQuantity + maximumAmount = replacePrice.maximumAmount + minimumAmount = replacePrice.minimumAmount + price = replacePrice.price + priceId = replacePrice.priceId + additionalProperties = replacePrice.additionalProperties.toMutableMap() + } + + /** The id of the price on the plan to replace in the subscription. */ + fun replacesPriceId(replacesPriceId: String) = + replacesPriceId(JsonField.of(replacesPriceId)) + + /** + * Sets [Builder.replacesPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.replacesPriceId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun replacesPriceId(replacesPriceId: JsonField) = apply { + this.replacesPriceId = replacesPriceId + } + + /** The definition of a new allocation price to create and add to the subscription. */ + fun allocationPrice(allocationPrice: NewAllocationPrice?) = + allocationPrice(JsonField.ofNullable(allocationPrice)) + + /** + * Sets [Builder.allocationPrice] to an arbitrary JSON value. + * + * You should usually call [Builder.allocationPrice] with a well-typed + * [NewAllocationPrice] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun allocationPrice(allocationPrice: JsonField) = apply { + this.allocationPrice = allocationPrice + } + + /** + * [DEPRECATED] Use add_adjustments instead. The subscription's discounts for the + * replacement price. + */ + @Deprecated("deprecated") + fun discounts(discounts: List?) = + discounts(JsonField.ofNullable(discounts)) + + /** + * Sets [Builder.discounts] to an arbitrary JSON value. + * + * You should usually call [Builder.discounts] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + @Deprecated("deprecated") + fun discounts(discounts: JsonField>) = apply { + this.discounts = discounts.map { it.toMutableList() } + } + + /** + * Adds a single [DiscountOverride] to [discounts]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + @Deprecated("deprecated") + fun addDiscount(discount: DiscountOverride) = apply { + discounts = + (discounts ?: JsonField.of(mutableListOf())).also { + checkKnown("discounts", it).add(discount) + } + } + + /** The external price id of the price to add to the subscription. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** The new quantity of the price, if the price is a fixed price. */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** + * [DEPRECATED] Use add_adjustments instead. The subscription's maximum amount for the + * replacement price. + */ + @Deprecated("deprecated") + fun maximumAmount(maximumAmount: String?) = + maximumAmount(JsonField.ofNullable(maximumAmount)) + + /** + * Sets [Builder.maximumAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.maximumAmount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + @Deprecated("deprecated") + fun maximumAmount(maximumAmount: JsonField) = apply { + this.maximumAmount = maximumAmount + } + + /** + * [DEPRECATED] Use add_adjustments instead. The subscription's minimum amount for the + * replacement price. + */ + @Deprecated("deprecated") + fun minimumAmount(minimumAmount: String?) = + minimumAmount(JsonField.ofNullable(minimumAmount)) + + /** + * Sets [Builder.minimumAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumAmount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + @Deprecated("deprecated") + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount + } + + /** New subscription price request body params. */ + fun price(price: Price?) = price(JsonField.ofNullable(price)) + + /** + * Sets [Builder.price] to an arbitrary JSON value. + * + * You should usually call [Builder.price] with a well-typed [Price] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun price(price: JsonField) = apply { this.price = price } + + /** Alias for calling [price] with `Price.ofUnit(unit)`. */ + fun price(unit: NewSubscriptionUnitPrice) = price(Price.ofUnit(unit)) + + /** Alias for calling [price] with `Price.ofTiered(tiered)`. */ + fun price(tiered: NewSubscriptionTieredPrice) = price(Price.ofTiered(tiered)) + + /** Alias for calling [price] with `Price.ofBulk(bulk)`. */ + fun price(bulk: NewSubscriptionBulkPrice) = price(Price.ofBulk(bulk)) + + /** Alias for calling [price] with `Price.ofPackage(package_)`. */ + fun price(package_: NewSubscriptionPackagePrice) = price(Price.ofPackage(package_)) + + /** Alias for calling [price] with `Price.ofMatrix(matrix)`. */ + fun price(matrix: NewSubscriptionMatrixPrice) = price(Price.ofMatrix(matrix)) + + /** + * Alias for calling [price] with `Price.ofThresholdTotalAmount(thresholdTotalAmount)`. + */ + fun price(thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice) = + price(Price.ofThresholdTotalAmount(thresholdTotalAmount)) + + /** Alias for calling [price] with `Price.ofTieredPackage(tieredPackage)`. */ + fun price(tieredPackage: NewSubscriptionTieredPackagePrice) = + price(Price.ofTieredPackage(tieredPackage)) + + /** Alias for calling [price] with `Price.ofTieredWithMinimum(tieredWithMinimum)`. */ + fun price(tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice) = + price(Price.ofTieredWithMinimum(tieredWithMinimum)) + + /** Alias for calling [price] with `Price.ofGroupedTiered(groupedTiered)`. */ + fun price(groupedTiered: NewSubscriptionGroupedTieredPrice) = + price(Price.ofGroupedTiered(groupedTiered)) + + /** + * Alias for calling [price] with + * `Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)`. + */ + fun price(tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice) = + price(Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)) + + /** + * Alias for calling [price] with + * `Price.ofPackageWithAllocation(packageWithAllocation)`. + */ + fun price(packageWithAllocation: NewSubscriptionPackageWithAllocationPrice) = + price(Price.ofPackageWithAllocation(packageWithAllocation)) + + /** Alias for calling [price] with `Price.ofUnitWithPercent(unitWithPercent)`. */ + fun price(unitWithPercent: NewSubscriptionUnitWithPercentPrice) = + price(Price.ofUnitWithPercent(unitWithPercent)) + + /** + * Alias for calling [price] with `Price.ofMatrixWithAllocation(matrixWithAllocation)`. + */ + fun price(matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice) = + price(Price.ofMatrixWithAllocation(matrixWithAllocation)) + + /** + * Alias for calling [price] with `Price.ofTieredWithProration(tieredWithProration)`. + */ + fun price(tieredWithProration: Price.TieredWithProration) = + price(Price.ofTieredWithProration(tieredWithProration)) + + /** Alias for calling [price] with `Price.ofUnitWithProration(unitWithProration)`. */ + fun price(unitWithProration: NewSubscriptionUnitWithProrationPrice) = + price(Price.ofUnitWithProration(unitWithProration)) + + /** Alias for calling [price] with `Price.ofGroupedAllocation(groupedAllocation)`. */ + fun price(groupedAllocation: NewSubscriptionGroupedAllocationPrice) = + price(Price.ofGroupedAllocation(groupedAllocation)) + + /** Alias for calling [price] with `Price.ofBulkWithProration(bulkWithProration)`. */ + fun price(bulkWithProration: NewSubscriptionBulkWithProrationPrice) = + price(Price.ofBulkWithProration(bulkWithProration)) + + /** + * Alias for calling [price] with + * `Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)`. + */ + fun price(groupedWithProratedMinimum: NewSubscriptionGroupedWithProratedMinimumPrice) = + price(Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)) + + /** + * Alias for calling [price] with + * `Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)`. + */ + fun price(groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice) = + price(Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)) + + /** + * Alias for calling [price] with + * `Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)`. + */ + fun price(groupedWithMinMaxThresholds: Price.GroupedWithMinMaxThresholds) = + price(Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)) + + /** + * Alias for calling [price] with + * `Price.ofMatrixWithDisplayName(matrixWithDisplayName)`. + */ + fun price(matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice) = + price(Price.ofMatrixWithDisplayName(matrixWithDisplayName)) + + /** + * Alias for calling [price] with `Price.ofGroupedTieredPackage(groupedTieredPackage)`. + */ + fun price(groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice) = + price(Price.ofGroupedTieredPackage(groupedTieredPackage)) + + /** + * Alias for calling [price] with + * `Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)`. + */ + fun price(maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice) = + price(Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)) + + /** + * Alias for calling [price] with + * `Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)`. + */ + fun price( + scalableMatrixWithUnitPricing: NewSubscriptionScalableMatrixWithUnitPricingPrice + ) = price(Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)) + + /** + * Alias for calling [price] with + * `Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)`. + */ + fun price( + scalableMatrixWithTieredPricing: NewSubscriptionScalableMatrixWithTieredPricingPrice + ) = price(Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)) + + /** + * Alias for calling [price] with + * `Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)`. + */ + fun price(cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice) = + price(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) + + /** Alias for calling [price] with `Price.ofMinimum(minimum)`. */ + fun price(minimum: NewSubscriptionMinimumCompositePrice) = + price(Price.ofMinimum(minimum)) + + /** The id of the price to add to the subscription. */ + fun priceId(priceId: String?) = priceId(JsonField.ofNullable(priceId)) + + /** + * Sets [Builder.priceId] to an arbitrary JSON value. + * + * You should usually call [Builder.priceId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun priceId(priceId: JsonField) = apply { this.priceId = priceId } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ReplacePrice]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .replacesPriceId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ReplacePrice = + ReplacePrice( + checkRequired("replacesPriceId", replacesPriceId), + allocationPrice, + (discounts ?: JsonMissing.of()).map { it.toImmutable() }, + externalPriceId, + fixedPriceQuantity, + maximumAmount, + minimumAmount, + price, + priceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ReplacePrice = apply { + if (validated) { + return@apply + } + + replacesPriceId() + allocationPrice()?.validate() + discounts()?.forEach { it.validate() } + externalPriceId() + fixedPriceQuantity() + maximumAmount() + minimumAmount() + price()?.validate() + priceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (replacesPriceId.asKnown() == null) 0 else 1) + + (allocationPrice.asKnown()?.validity() ?: 0) + + (discounts.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (maximumAmount.asKnown() == null) 0 else 1) + + (if (minimumAmount.asKnown() == null) 0 else 1) + + (price.asKnown()?.validity() ?: 0) + + (if (priceId.asKnown() == null) 0 else 1) + + /** New subscription price request body params. */ + @JsonDeserialize(using = Price.Deserializer::class) + @JsonSerialize(using = Price.Serializer::class) + class Price + private constructor( + private val unit: NewSubscriptionUnitPrice? = null, + private val tiered: NewSubscriptionTieredPrice? = null, + private val bulk: NewSubscriptionBulkPrice? = null, + private val package_: NewSubscriptionPackagePrice? = null, + private val matrix: NewSubscriptionMatrixPrice? = null, + private val thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice? = null, + private val tieredPackage: NewSubscriptionTieredPackagePrice? = null, + private val tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice? = null, + private val groupedTiered: NewSubscriptionGroupedTieredPrice? = null, + private val tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice? = + null, + private val packageWithAllocation: NewSubscriptionPackageWithAllocationPrice? = null, + private val unitWithPercent: NewSubscriptionUnitWithPercentPrice? = null, + private val matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice? = null, + private val tieredWithProration: TieredWithProration? = null, + private val unitWithProration: NewSubscriptionUnitWithProrationPrice? = null, + private val groupedAllocation: NewSubscriptionGroupedAllocationPrice? = null, + private val bulkWithProration: NewSubscriptionBulkWithProrationPrice? = null, + private val groupedWithProratedMinimum: + NewSubscriptionGroupedWithProratedMinimumPrice? = + null, + private val groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice? = + null, + private val groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds? = null, + private val matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice? = null, + private val groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice? = null, + private val maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice? = null, + private val scalableMatrixWithUnitPricing: + NewSubscriptionScalableMatrixWithUnitPricingPrice? = + null, + private val scalableMatrixWithTieredPricing: + NewSubscriptionScalableMatrixWithTieredPricingPrice? = + null, + private val cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice? = null, + private val minimum: NewSubscriptionMinimumCompositePrice? = null, + private val _json: JsonValue? = null, + ) { + + fun unit(): NewSubscriptionUnitPrice? = unit + + fun tiered(): NewSubscriptionTieredPrice? = tiered + + fun bulk(): NewSubscriptionBulkPrice? = bulk + + fun package_(): NewSubscriptionPackagePrice? = package_ + + fun matrix(): NewSubscriptionMatrixPrice? = matrix + + fun thresholdTotalAmount(): NewSubscriptionThresholdTotalAmountPrice? = + thresholdTotalAmount + + fun tieredPackage(): NewSubscriptionTieredPackagePrice? = tieredPackage + + fun tieredWithMinimum(): NewSubscriptionTieredWithMinimumPrice? = tieredWithMinimum + + fun groupedTiered(): NewSubscriptionGroupedTieredPrice? = groupedTiered + + fun tieredPackageWithMinimum(): NewSubscriptionTieredPackageWithMinimumPrice? = + tieredPackageWithMinimum + + fun packageWithAllocation(): NewSubscriptionPackageWithAllocationPrice? = + packageWithAllocation + + fun unitWithPercent(): NewSubscriptionUnitWithPercentPrice? = unitWithPercent + + fun matrixWithAllocation(): NewSubscriptionMatrixWithAllocationPrice? = + matrixWithAllocation + + fun tieredWithProration(): TieredWithProration? = tieredWithProration + + fun unitWithProration(): NewSubscriptionUnitWithProrationPrice? = unitWithProration + + fun groupedAllocation(): NewSubscriptionGroupedAllocationPrice? = groupedAllocation + + fun bulkWithProration(): NewSubscriptionBulkWithProrationPrice? = bulkWithProration + + fun groupedWithProratedMinimum(): NewSubscriptionGroupedWithProratedMinimumPrice? = + groupedWithProratedMinimum + + fun groupedWithMeteredMinimum(): NewSubscriptionGroupedWithMeteredMinimumPrice? = + groupedWithMeteredMinimum + + fun groupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds? = + groupedWithMinMaxThresholds + + fun matrixWithDisplayName(): NewSubscriptionMatrixWithDisplayNamePrice? = + matrixWithDisplayName + + fun groupedTieredPackage(): NewSubscriptionGroupedTieredPackagePrice? = + groupedTieredPackage + + fun maxGroupTieredPackage(): NewSubscriptionMaxGroupTieredPackagePrice? = + maxGroupTieredPackage + + fun scalableMatrixWithUnitPricing(): + NewSubscriptionScalableMatrixWithUnitPricingPrice? = scalableMatrixWithUnitPricing + + fun scalableMatrixWithTieredPricing(): + NewSubscriptionScalableMatrixWithTieredPricingPrice? = + scalableMatrixWithTieredPricing + + fun cumulativeGroupedBulk(): NewSubscriptionCumulativeGroupedBulkPrice? = + cumulativeGroupedBulk + + fun minimum(): NewSubscriptionMinimumCompositePrice? = minimum + + fun isUnit(): Boolean = unit != null + + fun isTiered(): Boolean = tiered != null + + fun isBulk(): Boolean = bulk != null + + fun isPackage(): Boolean = package_ != null + + fun isMatrix(): Boolean = matrix != null + + fun isThresholdTotalAmount(): Boolean = thresholdTotalAmount != null + + fun isTieredPackage(): Boolean = tieredPackage != null + + fun isTieredWithMinimum(): Boolean = tieredWithMinimum != null + + fun isGroupedTiered(): Boolean = groupedTiered != null + + fun isTieredPackageWithMinimum(): Boolean = tieredPackageWithMinimum != null + + fun isPackageWithAllocation(): Boolean = packageWithAllocation != null + + fun isUnitWithPercent(): Boolean = unitWithPercent != null + + fun isMatrixWithAllocation(): Boolean = matrixWithAllocation != null + + fun isTieredWithProration(): Boolean = tieredWithProration != null + + fun isUnitWithProration(): Boolean = unitWithProration != null + + fun isGroupedAllocation(): Boolean = groupedAllocation != null + + fun isBulkWithProration(): Boolean = bulkWithProration != null + + fun isGroupedWithProratedMinimum(): Boolean = groupedWithProratedMinimum != null + + fun isGroupedWithMeteredMinimum(): Boolean = groupedWithMeteredMinimum != null + + fun isGroupedWithMinMaxThresholds(): Boolean = groupedWithMinMaxThresholds != null + + fun isMatrixWithDisplayName(): Boolean = matrixWithDisplayName != null + + fun isGroupedTieredPackage(): Boolean = groupedTieredPackage != null + + fun isMaxGroupTieredPackage(): Boolean = maxGroupTieredPackage != null + + fun isScalableMatrixWithUnitPricing(): Boolean = scalableMatrixWithUnitPricing != null + + fun isScalableMatrixWithTieredPricing(): Boolean = + scalableMatrixWithTieredPricing != null + + fun isCumulativeGroupedBulk(): Boolean = cumulativeGroupedBulk != null + + fun isMinimum(): Boolean = minimum != null + + fun asUnit(): NewSubscriptionUnitPrice = unit.getOrThrow("unit") + + fun asTiered(): NewSubscriptionTieredPrice = tiered.getOrThrow("tiered") + + fun asBulk(): NewSubscriptionBulkPrice = bulk.getOrThrow("bulk") + + fun asPackage(): NewSubscriptionPackagePrice = package_.getOrThrow("package_") + + fun asMatrix(): NewSubscriptionMatrixPrice = matrix.getOrThrow("matrix") + + fun asThresholdTotalAmount(): NewSubscriptionThresholdTotalAmountPrice = + thresholdTotalAmount.getOrThrow("thresholdTotalAmount") + + fun asTieredPackage(): NewSubscriptionTieredPackagePrice = + tieredPackage.getOrThrow("tieredPackage") + + fun asTieredWithMinimum(): NewSubscriptionTieredWithMinimumPrice = + tieredWithMinimum.getOrThrow("tieredWithMinimum") + + fun asGroupedTiered(): NewSubscriptionGroupedTieredPrice = + groupedTiered.getOrThrow("groupedTiered") + + fun asTieredPackageWithMinimum(): NewSubscriptionTieredPackageWithMinimumPrice = + tieredPackageWithMinimum.getOrThrow("tieredPackageWithMinimum") + + fun asPackageWithAllocation(): NewSubscriptionPackageWithAllocationPrice = + packageWithAllocation.getOrThrow("packageWithAllocation") + + fun asUnitWithPercent(): NewSubscriptionUnitWithPercentPrice = + unitWithPercent.getOrThrow("unitWithPercent") + + fun asMatrixWithAllocation(): NewSubscriptionMatrixWithAllocationPrice = + matrixWithAllocation.getOrThrow("matrixWithAllocation") + + fun asTieredWithProration(): TieredWithProration = + tieredWithProration.getOrThrow("tieredWithProration") + + fun asUnitWithProration(): NewSubscriptionUnitWithProrationPrice = + unitWithProration.getOrThrow("unitWithProration") + + fun asGroupedAllocation(): NewSubscriptionGroupedAllocationPrice = + groupedAllocation.getOrThrow("groupedAllocation") + + fun asBulkWithProration(): NewSubscriptionBulkWithProrationPrice = + bulkWithProration.getOrThrow("bulkWithProration") + + fun asGroupedWithProratedMinimum(): NewSubscriptionGroupedWithProratedMinimumPrice = + groupedWithProratedMinimum.getOrThrow("groupedWithProratedMinimum") + + fun asGroupedWithMeteredMinimum(): NewSubscriptionGroupedWithMeteredMinimumPrice = + groupedWithMeteredMinimum.getOrThrow("groupedWithMeteredMinimum") + + fun asGroupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds = + groupedWithMinMaxThresholds.getOrThrow("groupedWithMinMaxThresholds") + + fun asMatrixWithDisplayName(): NewSubscriptionMatrixWithDisplayNamePrice = + matrixWithDisplayName.getOrThrow("matrixWithDisplayName") + + fun asGroupedTieredPackage(): NewSubscriptionGroupedTieredPackagePrice = + groupedTieredPackage.getOrThrow("groupedTieredPackage") + + fun asMaxGroupTieredPackage(): NewSubscriptionMaxGroupTieredPackagePrice = + maxGroupTieredPackage.getOrThrow("maxGroupTieredPackage") + + fun asScalableMatrixWithUnitPricing(): + NewSubscriptionScalableMatrixWithUnitPricingPrice = + scalableMatrixWithUnitPricing.getOrThrow("scalableMatrixWithUnitPricing") + + fun asScalableMatrixWithTieredPricing(): + NewSubscriptionScalableMatrixWithTieredPricingPrice = + scalableMatrixWithTieredPricing.getOrThrow("scalableMatrixWithTieredPricing") + + fun asCumulativeGroupedBulk(): NewSubscriptionCumulativeGroupedBulkPrice = + cumulativeGroupedBulk.getOrThrow("cumulativeGroupedBulk") + + fun asMinimum(): NewSubscriptionMinimumCompositePrice = minimum.getOrThrow("minimum") + + fun _json(): JsonValue? = _json + + fun accept(visitor: Visitor): T = + when { + unit != null -> visitor.visitUnit(unit) + tiered != null -> visitor.visitTiered(tiered) + bulk != null -> visitor.visitBulk(bulk) + package_ != null -> visitor.visitPackage(package_) + matrix != null -> visitor.visitMatrix(matrix) + thresholdTotalAmount != null -> + visitor.visitThresholdTotalAmount(thresholdTotalAmount) + tieredPackage != null -> visitor.visitTieredPackage(tieredPackage) + tieredWithMinimum != null -> visitor.visitTieredWithMinimum(tieredWithMinimum) + groupedTiered != null -> visitor.visitGroupedTiered(groupedTiered) + tieredPackageWithMinimum != null -> + visitor.visitTieredPackageWithMinimum(tieredPackageWithMinimum) + packageWithAllocation != null -> + visitor.visitPackageWithAllocation(packageWithAllocation) + unitWithPercent != null -> visitor.visitUnitWithPercent(unitWithPercent) + matrixWithAllocation != null -> + visitor.visitMatrixWithAllocation(matrixWithAllocation) + tieredWithProration != null -> + visitor.visitTieredWithProration(tieredWithProration) + unitWithProration != null -> visitor.visitUnitWithProration(unitWithProration) + groupedAllocation != null -> visitor.visitGroupedAllocation(groupedAllocation) + bulkWithProration != null -> visitor.visitBulkWithProration(bulkWithProration) + groupedWithProratedMinimum != null -> + visitor.visitGroupedWithProratedMinimum(groupedWithProratedMinimum) + groupedWithMeteredMinimum != null -> + visitor.visitGroupedWithMeteredMinimum(groupedWithMeteredMinimum) + groupedWithMinMaxThresholds != null -> + visitor.visitGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds) + matrixWithDisplayName != null -> + visitor.visitMatrixWithDisplayName(matrixWithDisplayName) + groupedTieredPackage != null -> + visitor.visitGroupedTieredPackage(groupedTieredPackage) + maxGroupTieredPackage != null -> + visitor.visitMaxGroupTieredPackage(maxGroupTieredPackage) + scalableMatrixWithUnitPricing != null -> + visitor.visitScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing) + scalableMatrixWithTieredPricing != null -> + visitor.visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing + ) + cumulativeGroupedBulk != null -> + visitor.visitCumulativeGroupedBulk(cumulativeGroupedBulk) + minimum != null -> visitor.visitMinimum(minimum) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Price = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitUnit(unit: NewSubscriptionUnitPrice) { + unit.validate() + } + + override fun visitTiered(tiered: NewSubscriptionTieredPrice) { + tiered.validate() + } + + override fun visitBulk(bulk: NewSubscriptionBulkPrice) { + bulk.validate() + } + + override fun visitPackage(package_: NewSubscriptionPackagePrice) { + package_.validate() + } + + override fun visitMatrix(matrix: NewSubscriptionMatrixPrice) { + matrix.validate() + } + + override fun visitThresholdTotalAmount( + thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice + ) { + thresholdTotalAmount.validate() + } + + override fun visitTieredPackage( + tieredPackage: NewSubscriptionTieredPackagePrice + ) { + tieredPackage.validate() + } + + override fun visitTieredWithMinimum( + tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice + ) { + tieredWithMinimum.validate() + } + + override fun visitGroupedTiered( + groupedTiered: NewSubscriptionGroupedTieredPrice + ) { + groupedTiered.validate() + } + + override fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice + ) { + tieredPackageWithMinimum.validate() + } + + override fun visitPackageWithAllocation( + packageWithAllocation: NewSubscriptionPackageWithAllocationPrice + ) { + packageWithAllocation.validate() + } + + override fun visitUnitWithPercent( + unitWithPercent: NewSubscriptionUnitWithPercentPrice + ) { + unitWithPercent.validate() + } + + override fun visitMatrixWithAllocation( + matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice + ) { + matrixWithAllocation.validate() + } + + override fun visitTieredWithProration( + tieredWithProration: TieredWithProration + ) { + tieredWithProration.validate() + } + + override fun visitUnitWithProration( + unitWithProration: NewSubscriptionUnitWithProrationPrice + ) { + unitWithProration.validate() + } + + override fun visitGroupedAllocation( + groupedAllocation: NewSubscriptionGroupedAllocationPrice + ) { + groupedAllocation.validate() + } + + override fun visitBulkWithProration( + bulkWithProration: NewSubscriptionBulkWithProrationPrice + ) { + bulkWithProration.validate() + } + + override fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: + NewSubscriptionGroupedWithProratedMinimumPrice + ) { + groupedWithProratedMinimum.validate() + } + + override fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice + ) { + groupedWithMeteredMinimum.validate() + } + + override fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) { + groupedWithMinMaxThresholds.validate() + } + + override fun visitMatrixWithDisplayName( + matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice + ) { + matrixWithDisplayName.validate() + } + + override fun visitGroupedTieredPackage( + groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice + ) { + groupedTieredPackage.validate() + } + + override fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice + ) { + maxGroupTieredPackage.validate() + } + + override fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: + NewSubscriptionScalableMatrixWithUnitPricingPrice + ) { + scalableMatrixWithUnitPricing.validate() + } + + override fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: + NewSubscriptionScalableMatrixWithTieredPricingPrice + ) { + scalableMatrixWithTieredPricing.validate() + } + + override fun visitCumulativeGroupedBulk( + cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice + ) { + cumulativeGroupedBulk.validate() + } + + override fun visitMinimum(minimum: NewSubscriptionMinimumCompositePrice) { + minimum.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitUnit(unit: NewSubscriptionUnitPrice) = unit.validity() + + override fun visitTiered(tiered: NewSubscriptionTieredPrice) = + tiered.validity() + + override fun visitBulk(bulk: NewSubscriptionBulkPrice) = bulk.validity() + + override fun visitPackage(package_: NewSubscriptionPackagePrice) = + package_.validity() + + override fun visitMatrix(matrix: NewSubscriptionMatrixPrice) = + matrix.validity() + + override fun visitThresholdTotalAmount( + thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice + ) = thresholdTotalAmount.validity() + + override fun visitTieredPackage( + tieredPackage: NewSubscriptionTieredPackagePrice + ) = tieredPackage.validity() + + override fun visitTieredWithMinimum( + tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice + ) = tieredWithMinimum.validity() + + override fun visitGroupedTiered( + groupedTiered: NewSubscriptionGroupedTieredPrice + ) = groupedTiered.validity() + + override fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice + ) = tieredPackageWithMinimum.validity() + + override fun visitPackageWithAllocation( + packageWithAllocation: NewSubscriptionPackageWithAllocationPrice + ) = packageWithAllocation.validity() + + override fun visitUnitWithPercent( + unitWithPercent: NewSubscriptionUnitWithPercentPrice + ) = unitWithPercent.validity() + + override fun visitMatrixWithAllocation( + matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice + ) = matrixWithAllocation.validity() + + override fun visitTieredWithProration( + tieredWithProration: TieredWithProration + ) = tieredWithProration.validity() + + override fun visitUnitWithProration( + unitWithProration: NewSubscriptionUnitWithProrationPrice + ) = unitWithProration.validity() + + override fun visitGroupedAllocation( + groupedAllocation: NewSubscriptionGroupedAllocationPrice + ) = groupedAllocation.validity() + + override fun visitBulkWithProration( + bulkWithProration: NewSubscriptionBulkWithProrationPrice + ) = bulkWithProration.validity() + + override fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: + NewSubscriptionGroupedWithProratedMinimumPrice + ) = groupedWithProratedMinimum.validity() + + override fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice + ) = groupedWithMeteredMinimum.validity() + + override fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) = groupedWithMinMaxThresholds.validity() + + override fun visitMatrixWithDisplayName( + matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice + ) = matrixWithDisplayName.validity() + + override fun visitGroupedTieredPackage( + groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice + ) = groupedTieredPackage.validity() + + override fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice + ) = maxGroupTieredPackage.validity() + + override fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: + NewSubscriptionScalableMatrixWithUnitPricingPrice + ) = scalableMatrixWithUnitPricing.validity() + + override fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: + NewSubscriptionScalableMatrixWithTieredPricingPrice + ) = scalableMatrixWithTieredPricing.validity() + + override fun visitCumulativeGroupedBulk( + cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice + ) = cumulativeGroupedBulk.validity() + + override fun visitMinimum(minimum: NewSubscriptionMinimumCompositePrice) = + minimum.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Price && + unit == other.unit && + tiered == other.tiered && + bulk == other.bulk && + package_ == other.package_ && + matrix == other.matrix && + thresholdTotalAmount == other.thresholdTotalAmount && + tieredPackage == other.tieredPackage && + tieredWithMinimum == other.tieredWithMinimum && + groupedTiered == other.groupedTiered && + tieredPackageWithMinimum == other.tieredPackageWithMinimum && + packageWithAllocation == other.packageWithAllocation && + unitWithPercent == other.unitWithPercent && + matrixWithAllocation == other.matrixWithAllocation && + tieredWithProration == other.tieredWithProration && + unitWithProration == other.unitWithProration && + groupedAllocation == other.groupedAllocation && + bulkWithProration == other.bulkWithProration && + groupedWithProratedMinimum == other.groupedWithProratedMinimum && + groupedWithMeteredMinimum == other.groupedWithMeteredMinimum && + groupedWithMinMaxThresholds == other.groupedWithMinMaxThresholds && + matrixWithDisplayName == other.matrixWithDisplayName && + groupedTieredPackage == other.groupedTieredPackage && + maxGroupTieredPackage == other.maxGroupTieredPackage && + scalableMatrixWithUnitPricing == other.scalableMatrixWithUnitPricing && + scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && + cumulativeGroupedBulk == other.cumulativeGroupedBulk && + minimum == other.minimum + } + + override fun hashCode(): Int = + Objects.hash( + unit, + tiered, + bulk, + package_, + matrix, + thresholdTotalAmount, + tieredPackage, + tieredWithMinimum, + groupedTiered, + tieredPackageWithMinimum, + packageWithAllocation, + unitWithPercent, + matrixWithAllocation, + tieredWithProration, + unitWithProration, + groupedAllocation, + bulkWithProration, + groupedWithProratedMinimum, + groupedWithMeteredMinimum, + groupedWithMinMaxThresholds, + matrixWithDisplayName, + groupedTieredPackage, + maxGroupTieredPackage, + scalableMatrixWithUnitPricing, + scalableMatrixWithTieredPricing, + cumulativeGroupedBulk, + minimum, + ) + + override fun toString(): String = + when { + unit != null -> "Price{unit=$unit}" + tiered != null -> "Price{tiered=$tiered}" + bulk != null -> "Price{bulk=$bulk}" + package_ != null -> "Price{package_=$package_}" + matrix != null -> "Price{matrix=$matrix}" + thresholdTotalAmount != null -> + "Price{thresholdTotalAmount=$thresholdTotalAmount}" + tieredPackage != null -> "Price{tieredPackage=$tieredPackage}" + tieredWithMinimum != null -> "Price{tieredWithMinimum=$tieredWithMinimum}" + groupedTiered != null -> "Price{groupedTiered=$groupedTiered}" + tieredPackageWithMinimum != null -> + "Price{tieredPackageWithMinimum=$tieredPackageWithMinimum}" + packageWithAllocation != null -> + "Price{packageWithAllocation=$packageWithAllocation}" + unitWithPercent != null -> "Price{unitWithPercent=$unitWithPercent}" + matrixWithAllocation != null -> + "Price{matrixWithAllocation=$matrixWithAllocation}" + tieredWithProration != null -> "Price{tieredWithProration=$tieredWithProration}" + unitWithProration != null -> "Price{unitWithProration=$unitWithProration}" + groupedAllocation != null -> "Price{groupedAllocation=$groupedAllocation}" + bulkWithProration != null -> "Price{bulkWithProration=$bulkWithProration}" + groupedWithProratedMinimum != null -> + "Price{groupedWithProratedMinimum=$groupedWithProratedMinimum}" + groupedWithMeteredMinimum != null -> + "Price{groupedWithMeteredMinimum=$groupedWithMeteredMinimum}" + groupedWithMinMaxThresholds != null -> + "Price{groupedWithMinMaxThresholds=$groupedWithMinMaxThresholds}" + matrixWithDisplayName != null -> + "Price{matrixWithDisplayName=$matrixWithDisplayName}" + groupedTieredPackage != null -> + "Price{groupedTieredPackage=$groupedTieredPackage}" + maxGroupTieredPackage != null -> + "Price{maxGroupTieredPackage=$maxGroupTieredPackage}" + scalableMatrixWithUnitPricing != null -> + "Price{scalableMatrixWithUnitPricing=$scalableMatrixWithUnitPricing}" + scalableMatrixWithTieredPricing != null -> + "Price{scalableMatrixWithTieredPricing=$scalableMatrixWithTieredPricing}" + cumulativeGroupedBulk != null -> + "Price{cumulativeGroupedBulk=$cumulativeGroupedBulk}" + minimum != null -> "Price{minimum=$minimum}" + _json != null -> "Price{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Price") + } + + companion object { + + fun ofUnit(unit: NewSubscriptionUnitPrice) = Price(unit = unit) + + fun ofTiered(tiered: NewSubscriptionTieredPrice) = Price(tiered = tiered) + + fun ofBulk(bulk: NewSubscriptionBulkPrice) = Price(bulk = bulk) + + fun ofPackage(package_: NewSubscriptionPackagePrice) = Price(package_ = package_) + + fun ofMatrix(matrix: NewSubscriptionMatrixPrice) = Price(matrix = matrix) + + fun ofThresholdTotalAmount( + thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice + ) = Price(thresholdTotalAmount = thresholdTotalAmount) + + fun ofTieredPackage(tieredPackage: NewSubscriptionTieredPackagePrice) = + Price(tieredPackage = tieredPackage) + + fun ofTieredWithMinimum(tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice) = + Price(tieredWithMinimum = tieredWithMinimum) + + fun ofGroupedTiered(groupedTiered: NewSubscriptionGroupedTieredPrice) = + Price(groupedTiered = groupedTiered) + + fun ofTieredPackageWithMinimum( + tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice + ) = Price(tieredPackageWithMinimum = tieredPackageWithMinimum) + + fun ofPackageWithAllocation( + packageWithAllocation: NewSubscriptionPackageWithAllocationPrice + ) = Price(packageWithAllocation = packageWithAllocation) + + fun ofUnitWithPercent(unitWithPercent: NewSubscriptionUnitWithPercentPrice) = + Price(unitWithPercent = unitWithPercent) + + fun ofMatrixWithAllocation( + matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice + ) = Price(matrixWithAllocation = matrixWithAllocation) + + fun ofTieredWithProration(tieredWithProration: TieredWithProration) = + Price(tieredWithProration = tieredWithProration) + + fun ofUnitWithProration(unitWithProration: NewSubscriptionUnitWithProrationPrice) = + Price(unitWithProration = unitWithProration) + + fun ofGroupedAllocation(groupedAllocation: NewSubscriptionGroupedAllocationPrice) = + Price(groupedAllocation = groupedAllocation) + + fun ofBulkWithProration(bulkWithProration: NewSubscriptionBulkWithProrationPrice) = + Price(bulkWithProration = bulkWithProration) + + fun ofGroupedWithProratedMinimum( + groupedWithProratedMinimum: NewSubscriptionGroupedWithProratedMinimumPrice + ) = Price(groupedWithProratedMinimum = groupedWithProratedMinimum) + + fun ofGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice + ) = Price(groupedWithMeteredMinimum = groupedWithMeteredMinimum) + + fun ofGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) = Price(groupedWithMinMaxThresholds = groupedWithMinMaxThresholds) + + fun ofMatrixWithDisplayName( + matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice + ) = Price(matrixWithDisplayName = matrixWithDisplayName) + + fun ofGroupedTieredPackage( + groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice + ) = Price(groupedTieredPackage = groupedTieredPackage) + + fun ofMaxGroupTieredPackage( + maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice + ) = Price(maxGroupTieredPackage = maxGroupTieredPackage) + + fun ofScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: NewSubscriptionScalableMatrixWithUnitPricingPrice + ) = Price(scalableMatrixWithUnitPricing = scalableMatrixWithUnitPricing) + + fun ofScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: + NewSubscriptionScalableMatrixWithTieredPricingPrice + ) = Price(scalableMatrixWithTieredPricing = scalableMatrixWithTieredPricing) + + fun ofCumulativeGroupedBulk( + cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice + ) = Price(cumulativeGroupedBulk = cumulativeGroupedBulk) + + fun ofMinimum(minimum: NewSubscriptionMinimumCompositePrice) = + Price(minimum = minimum) + } + + /** + * An interface that defines how to map each variant of [Price] to a value of type [T]. + */ + interface Visitor { + + fun visitUnit(unit: NewSubscriptionUnitPrice): T + + fun visitTiered(tiered: NewSubscriptionTieredPrice): T + + fun visitBulk(bulk: NewSubscriptionBulkPrice): T + + fun visitPackage(package_: NewSubscriptionPackagePrice): T + + fun visitMatrix(matrix: NewSubscriptionMatrixPrice): T + + fun visitThresholdTotalAmount( + thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice + ): T + + fun visitTieredPackage(tieredPackage: NewSubscriptionTieredPackagePrice): T + + fun visitTieredWithMinimum( + tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice + ): T + + fun visitGroupedTiered(groupedTiered: NewSubscriptionGroupedTieredPrice): T + + fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice + ): T + + fun visitPackageWithAllocation( + packageWithAllocation: NewSubscriptionPackageWithAllocationPrice + ): T + + fun visitUnitWithPercent(unitWithPercent: NewSubscriptionUnitWithPercentPrice): T + + fun visitMatrixWithAllocation( + matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice + ): T + + fun visitTieredWithProration(tieredWithProration: TieredWithProration): T + + fun visitUnitWithProration( + unitWithProration: NewSubscriptionUnitWithProrationPrice + ): T + + fun visitGroupedAllocation( + groupedAllocation: NewSubscriptionGroupedAllocationPrice + ): T + + fun visitBulkWithProration( + bulkWithProration: NewSubscriptionBulkWithProrationPrice + ): T + + fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: NewSubscriptionGroupedWithProratedMinimumPrice + ): T + + fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice + ): T + + fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ): T + + fun visitMatrixWithDisplayName( + matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice + ): T + + fun visitGroupedTieredPackage( + groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice + ): T + + fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice + ): T + + fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: NewSubscriptionScalableMatrixWithUnitPricingPrice + ): T + + fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: + NewSubscriptionScalableMatrixWithTieredPricingPrice + ): T + + fun visitCumulativeGroupedBulk( + cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice + ): T + + fun visitMinimum(minimum: NewSubscriptionMinimumCompositePrice): T + + /** + * Maps an unknown variant of [Price] to a value of type [T]. + * + * An instance of [Price] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is + * unaware of. + * + * @throws OrbInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw OrbInvalidDataException("Unknown Price: $json") + } + } + + internal class Deserializer : BaseDeserializer(Price::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Price { + val json = JsonValue.fromJsonNode(node) + val modelType = json.asObject()?.get("model_type")?.asString() + + when (modelType) { + "unit" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(unit = it, _json = json) } ?: Price(_json = json) + } + "tiered" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(tiered = it, _json = json) } ?: Price(_json = json) + } + "bulk" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(bulk = it, _json = json) } ?: Price(_json = json) + } + "package" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(package_ = it, _json = json) } ?: Price(_json = json) + } + "matrix" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(matrix = it, _json = json) } ?: Price(_json = json) + } + "threshold_total_amount" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(thresholdTotalAmount = it, _json = json) } + ?: Price(_json = json) + } + "tiered_package" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(tieredPackage = it, _json = json) } + ?: Price(_json = json) + } + "tiered_with_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(tieredWithMinimum = it, _json = json) } + ?: Price(_json = json) + } + "grouped_tiered" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedTiered = it, _json = json) } + ?: Price(_json = json) + } + "tiered_package_with_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(tieredPackageWithMinimum = it, _json = json) } + ?: Price(_json = json) + } + "package_with_allocation" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(packageWithAllocation = it, _json = json) } + ?: Price(_json = json) + } + "unit_with_percent" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(unitWithPercent = it, _json = json) } + ?: Price(_json = json) + } + "matrix_with_allocation" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(matrixWithAllocation = it, _json = json) } + ?: Price(_json = json) + } + "tiered_with_proration" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(tieredWithProration = it, _json = json) } + ?: Price(_json = json) + } + "unit_with_proration" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(unitWithProration = it, _json = json) } + ?: Price(_json = json) + } + "grouped_allocation" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedAllocation = it, _json = json) } + ?: Price(_json = json) + } + "bulk_with_proration" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(bulkWithProration = it, _json = json) } + ?: Price(_json = json) + } + "grouped_with_prorated_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedWithProratedMinimum = it, _json = json) } + ?: Price(_json = json) + } + "grouped_with_metered_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedWithMeteredMinimum = it, _json = json) } + ?: Price(_json = json) + } + "grouped_with_min_max_thresholds" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedWithMinMaxThresholds = it, _json = json) } + ?: Price(_json = json) + } + "matrix_with_display_name" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(matrixWithDisplayName = it, _json = json) } + ?: Price(_json = json) + } + "grouped_tiered_package" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedTieredPackage = it, _json = json) } + ?: Price(_json = json) + } + "max_group_tiered_package" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(maxGroupTieredPackage = it, _json = json) } + ?: Price(_json = json) + } + "scalable_matrix_with_unit_pricing" -> { + return tryDeserialize( + node, + jacksonTypeRef< + NewSubscriptionScalableMatrixWithUnitPricingPrice + >(), + ) + ?.let { Price(scalableMatrixWithUnitPricing = it, _json = json) } + ?: Price(_json = json) + } + "scalable_matrix_with_tiered_pricing" -> { + return tryDeserialize( + node, + jacksonTypeRef< + NewSubscriptionScalableMatrixWithTieredPricingPrice + >(), + ) + ?.let { Price(scalableMatrixWithTieredPricing = it, _json = json) } + ?: Price(_json = json) + } + "cumulative_grouped_bulk" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(cumulativeGroupedBulk = it, _json = json) } + ?: Price(_json = json) + } + "minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(minimum = it, _json = json) } ?: Price(_json = json) + } + } + + return Price(_json = json) + } + } + + internal class Serializer : BaseSerializer(Price::class) { + + override fun serialize( + value: Price, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.unit != null -> generator.writeObject(value.unit) + value.tiered != null -> generator.writeObject(value.tiered) + value.bulk != null -> generator.writeObject(value.bulk) + value.package_ != null -> generator.writeObject(value.package_) + value.matrix != null -> generator.writeObject(value.matrix) + value.thresholdTotalAmount != null -> + generator.writeObject(value.thresholdTotalAmount) + value.tieredPackage != null -> generator.writeObject(value.tieredPackage) + value.tieredWithMinimum != null -> + generator.writeObject(value.tieredWithMinimum) + value.groupedTiered != null -> generator.writeObject(value.groupedTiered) + value.tieredPackageWithMinimum != null -> + generator.writeObject(value.tieredPackageWithMinimum) + value.packageWithAllocation != null -> + generator.writeObject(value.packageWithAllocation) + value.unitWithPercent != null -> + generator.writeObject(value.unitWithPercent) + value.matrixWithAllocation != null -> + generator.writeObject(value.matrixWithAllocation) + value.tieredWithProration != null -> + generator.writeObject(value.tieredWithProration) + value.unitWithProration != null -> + generator.writeObject(value.unitWithProration) + value.groupedAllocation != null -> + generator.writeObject(value.groupedAllocation) + value.bulkWithProration != null -> + generator.writeObject(value.bulkWithProration) + value.groupedWithProratedMinimum != null -> + generator.writeObject(value.groupedWithProratedMinimum) + value.groupedWithMeteredMinimum != null -> + generator.writeObject(value.groupedWithMeteredMinimum) + value.groupedWithMinMaxThresholds != null -> + generator.writeObject(value.groupedWithMinMaxThresholds) + value.matrixWithDisplayName != null -> + generator.writeObject(value.matrixWithDisplayName) + value.groupedTieredPackage != null -> + generator.writeObject(value.groupedTieredPackage) + value.maxGroupTieredPackage != null -> + generator.writeObject(value.maxGroupTieredPackage) + value.scalableMatrixWithUnitPricing != null -> + generator.writeObject(value.scalableMatrixWithUnitPricing) + value.scalableMatrixWithTieredPricing != null -> + generator.writeObject(value.scalableMatrixWithTieredPricing) + value.cumulativeGroupedBulk != null -> + generator.writeObject(value.cumulativeGroupedBulk) + value.minimum != null -> generator.writeObject(value.minimum) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Price") + } + } + } + + class TieredWithProration + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val tieredWithProrationConfig: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("tiered_with_proration_config") + @ExcludeMissing + tieredWithProrationConfig: JsonField = + JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + modelType, + name, + tieredWithProrationConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("tiered_with_proration") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") - fun asGroupedWithMeteredMinimum(): NewSubscriptionGroupedWithMeteredMinimumPrice = - groupedWithMeteredMinimum.getOrThrow("groupedWithMeteredMinimum") + /** + * Configuration for tiered_with_proration pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun tieredWithProrationConfig(): TieredWithProrationConfig = + tieredWithProrationConfig.getRequired("tiered_with_proration_config") - fun asMatrixWithDisplayName(): NewSubscriptionMatrixWithDisplayNamePrice = - matrixWithDisplayName.getOrThrow("matrixWithDisplayName") + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = billableMetricId.getNullable("billable_metric_id") - fun asGroupedTieredPackage(): NewSubscriptionGroupedTieredPackagePrice = - groupedTieredPackage.getOrThrow("groupedTieredPackage") + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") - fun asMatrixWithAllocation(): NewSubscriptionMatrixWithAllocationPrice = - matrixWithAllocation.getOrThrow("matrixWithAllocation") + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") - fun asTieredPackageWithMinimum(): NewSubscriptionTieredPackageWithMinimumPrice = - tieredPackageWithMinimum.getOrThrow("tieredPackageWithMinimum") + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") - fun asGroupedTiered(): NewSubscriptionGroupedTieredPrice = - groupedTiered.getOrThrow("groupedTiered") + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") - fun asGroupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds = - groupedWithMinMaxThresholds.getOrThrow("groupedWithMinMaxThresholds") + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") - fun asMinimum(): NewSubscriptionMinimumCompositePrice = minimum.getOrThrow("minimum") + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") - fun _json(): JsonValue? = _json + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - package_ != null -> visitor.visitPackage(package_) - matrix != null -> visitor.visitMatrix(matrix) - tiered != null -> visitor.visitTiered(tiered) - bulk != null -> visitor.visitBulk(bulk) - thresholdTotalAmount != null -> - visitor.visitThresholdTotalAmount(thresholdTotalAmount) - tieredPackage != null -> visitor.visitTieredPackage(tieredPackage) - tieredWithMinimum != null -> visitor.visitTieredWithMinimum(tieredWithMinimum) - unitWithPercent != null -> visitor.visitUnitWithPercent(unitWithPercent) - packageWithAllocation != null -> - visitor.visitPackageWithAllocation(packageWithAllocation) - tieredWithProration != null -> - visitor.visitTieredWithProration(tieredWithProration) - unitWithProration != null -> visitor.visitUnitWithProration(unitWithProration) - groupedAllocation != null -> visitor.visitGroupedAllocation(groupedAllocation) - groupedWithProratedMinimum != null -> - visitor.visitGroupedWithProratedMinimum(groupedWithProratedMinimum) - bulkWithProration != null -> visitor.visitBulkWithProration(bulkWithProration) - scalableMatrixWithUnitPricing != null -> - visitor.visitScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing) - scalableMatrixWithTieredPricing != null -> - visitor.visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing - ) - cumulativeGroupedBulk != null -> - visitor.visitCumulativeGroupedBulk(cumulativeGroupedBulk) - maxGroupTieredPackage != null -> - visitor.visitMaxGroupTieredPackage(maxGroupTieredPackage) - groupedWithMeteredMinimum != null -> - visitor.visitGroupedWithMeteredMinimum(groupedWithMeteredMinimum) - matrixWithDisplayName != null -> - visitor.visitMatrixWithDisplayName(matrixWithDisplayName) - groupedTieredPackage != null -> - visitor.visitGroupedTieredPackage(groupedTieredPackage) - matrixWithAllocation != null -> - visitor.visitMatrixWithAllocation(matrixWithAllocation) - tieredPackageWithMinimum != null -> - visitor.visitTieredPackageWithMinimum(tieredPackageWithMinimum) - groupedTiered != null -> visitor.visitGroupedTiered(groupedTiered) - groupedWithMinMaxThresholds != null -> - visitor.visitGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds) - minimum != null -> visitor.visitMinimum(minimum) - else -> visitor.unknown(_json) - } + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") - private var validated: Boolean = false + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + invoiceGroupingKey.getNullable("invoice_grouping_key") - fun validate(): Price = apply { - if (validated) { - return@apply - } + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - accept( - object : Visitor { - override fun visitUnit(unit: NewSubscriptionUnitPrice) { - unit.validate() - } + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") - override fun visitPackage(package_: NewSubscriptionPackagePrice) { - package_.validate() - } + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") - override fun visitMatrix(matrix: NewSubscriptionMatrixPrice) { - matrix.validate() - } + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence - override fun visitTiered(tiered: NewSubscriptionTieredPrice) { - tiered.validate() - } + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - override fun visitBulk(bulk: NewSubscriptionBulkPrice) { - bulk.validate() - } + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - override fun visitThresholdTotalAmount( - thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice - ) { - thresholdTotalAmount.validate() - } + /** + * Returns the raw JSON value of [tieredWithProrationConfig]. + * + * Unlike [tieredWithProrationConfig], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("tiered_with_proration_config") + @ExcludeMissing + fun _tieredWithProrationConfig(): JsonField = + tieredWithProrationConfig - override fun visitTieredPackage( - tieredPackage: NewSubscriptionTieredPackagePrice - ) { - tieredPackage.validate() - } + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId - override fun visitTieredWithMinimum( - tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice - ) { - tieredWithMinimum.validate() - } + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance - override fun visitUnitWithPercent( - unitWithPercent: NewSubscriptionUnitWithPercentPrice - ) { - unitWithPercent.validate() - } + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration - override fun visitPackageWithAllocation( - packageWithAllocation: NewSubscriptionPackageWithAllocationPrice - ) { - packageWithAllocation.validate() - } + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate - override fun visitTieredWithProration( - tieredWithProration: NewSubscriptionTierWithProrationPrice - ) { - tieredWithProration.validate() - } + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig - override fun visitUnitWithProration( - unitWithProration: NewSubscriptionUnitWithProrationPrice - ) { - unitWithProration.validate() - } + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency - override fun visitGroupedAllocation( - groupedAllocation: NewSubscriptionGroupedAllocationPrice - ) { - groupedAllocation.validate() - } + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration - override fun visitGroupedWithProratedMinimum( - groupedWithProratedMinimum: - NewSubscriptionGroupedWithProratedMinimumPrice - ) { - groupedWithProratedMinimum.validate() - } + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId - override fun visitBulkWithProration( - bulkWithProration: NewSubscriptionBulkWithProrationPrice - ) { - bulkWithProration.validate() - } + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - override fun visitScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: - NewSubscriptionScalableMatrixWithUnitPricingPrice - ) { - scalableMatrixWithUnitPricing.validate() - } + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - override fun visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: - NewSubscriptionScalableMatrixWithTieredPricingPrice - ) { - scalableMatrixWithTieredPricing.validate() - } + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration - override fun visitCumulativeGroupedBulk( - cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice - ) { - cumulativeGroupedBulk.validate() - } + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata - override fun visitMaxGroupTieredPackage( - maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice - ) { - maxGroupTieredPackage.validate() - } + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId - override fun visitGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice - ) { - groupedWithMeteredMinimum.validate() - } + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - override fun visitMatrixWithDisplayName( - matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice - ) { - matrixWithDisplayName.validate() - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - override fun visitGroupedTieredPackage( - groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice - ) { - groupedTieredPackage.validate() - } + fun toBuilder() = Builder().from(this) - override fun visitMatrixWithAllocation( - matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice - ) { - matrixWithAllocation.validate() - } + companion object { - override fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice - ) { - tieredPackageWithMinimum.validate() - } + /** + * Returns a mutable builder for constructing an instance of + * [TieredWithProration]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .name() + * .tieredWithProrationConfig() + * ``` + */ + fun builder() = Builder() + } - override fun visitGroupedTiered( - groupedTiered: NewSubscriptionGroupedTieredPrice - ) { - groupedTiered.validate() - } + /** A builder for [TieredWithProration]. */ + class Builder internal constructor() { - override fun visitGroupedWithMinMaxThresholds( - groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds - ) { - groupedWithMinMaxThresholds.validate() - } + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonValue = JsonValue.from("tiered_with_proration") + private var name: JsonField? = null + private var tieredWithProrationConfig: JsonField? = + null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - override fun visitMinimum(minimum: NewSubscriptionMinimumCompositePrice) { - minimum.validate() - } + internal fun from(tieredWithProration: TieredWithProration) = apply { + cadence = tieredWithProration.cadence + itemId = tieredWithProration.itemId + modelType = tieredWithProration.modelType + name = tieredWithProration.name + tieredWithProrationConfig = tieredWithProration.tieredWithProrationConfig + billableMetricId = tieredWithProration.billableMetricId + billedInAdvance = tieredWithProration.billedInAdvance + billingCycleConfiguration = tieredWithProration.billingCycleConfiguration + conversionRate = tieredWithProration.conversionRate + conversionRateConfig = tieredWithProration.conversionRateConfig + currency = tieredWithProration.currency + dimensionalPriceConfiguration = + tieredWithProration.dimensionalPriceConfiguration + externalPriceId = tieredWithProration.externalPriceId + fixedPriceQuantity = tieredWithProration.fixedPriceQuantity + invoiceGroupingKey = tieredWithProration.invoiceGroupingKey + invoicingCycleConfiguration = + tieredWithProration.invoicingCycleConfiguration + metadata = tieredWithProration.metadata + referenceId = tieredWithProration.referenceId + additionalProperties = + tieredWithProration.additionalProperties.toMutableMap() } - ) - validated = true - } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: NewSubscriptionUnitPrice) = unit.validity() + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - override fun visitPackage(package_: NewSubscriptionPackagePrice) = - package_.validity() + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - override fun visitMatrix(matrix: NewSubscriptionMatrixPrice) = - matrix.validity() + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - override fun visitTiered(tiered: NewSubscriptionTieredPrice) = - tiered.validity() + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("tiered_with_proration") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } - override fun visitBulk(bulk: NewSubscriptionBulkPrice) = bulk.validity() + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) - override fun visitThresholdTotalAmount( - thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice - ) = thresholdTotalAmount.validity() + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } - override fun visitTieredPackage( - tieredPackage: NewSubscriptionTieredPackagePrice - ) = tieredPackage.validity() + /** Configuration for tiered_with_proration pricing */ + fun tieredWithProrationConfig( + tieredWithProrationConfig: TieredWithProrationConfig + ) = tieredWithProrationConfig(JsonField.of(tieredWithProrationConfig)) - override fun visitTieredWithMinimum( - tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice - ) = tieredWithMinimum.validity() + /** + * Sets [Builder.tieredWithProrationConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.tieredWithProrationConfig] with a well-typed + * [TieredWithProrationConfig] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun tieredWithProrationConfig( + tieredWithProrationConfig: JsonField + ) = apply { this.tieredWithProrationConfig = tieredWithProrationConfig } - override fun visitUnitWithPercent( - unitWithPercent: NewSubscriptionUnitWithPercentPrice - ) = unitWithPercent.validity() + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) - override fun visitPackageWithAllocation( - packageWithAllocation: NewSubscriptionPackageWithAllocationPrice - ) = packageWithAllocation.validity() + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } - override fun visitTieredWithProration( - tieredWithProration: NewSubscriptionTierWithProrationPrice - ) = tieredWithProration.validity() + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) - override fun visitUnitWithProration( - unitWithProration: NewSubscriptionUnitWithProrationPrice - ) = unitWithProration.validity() + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) - override fun visitGroupedAllocation( - groupedAllocation: NewSubscriptionGroupedAllocationPrice - ) = groupedAllocation.validity() + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } - override fun visitGroupedWithProratedMinimum( - groupedWithProratedMinimum: - NewSubscriptionGroupedWithProratedMinimumPrice - ) = groupedWithProratedMinimum.validity() + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - override fun visitBulkWithProration( - bulkWithProration: NewSubscriptionBulkWithProrationPrice - ) = bulkWithProration.validity() + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } - override fun visitScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: - NewSubscriptionScalableMatrixWithUnitPricingPrice - ) = scalableMatrixWithUnitPricing.validity() + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) - override fun visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: - NewSubscriptionScalableMatrixWithTieredPricingPrice - ) = scalableMatrixWithTieredPricing.validity() + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) - override fun visitCumulativeGroupedBulk( - cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice - ) = cumulativeGroupedBulk.validity() + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } - override fun visitMaxGroupTieredPackage( - maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice - ) = maxGroupTieredPackage.validity() + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) - override fun visitGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice - ) = groupedWithMeteredMinimum.validity() + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } - override fun visitMatrixWithDisplayName( - matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice - ) = matrixWithDisplayName.validity() + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) - override fun visitGroupedTieredPackage( - groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice - ) = groupedTieredPackage.validity() + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) - override fun visitMatrixWithAllocation( - matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice - ) = matrixWithAllocation.validity() + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) - override fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice - ) = tieredPackageWithMinimum.validity() + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } - override fun visitGroupedTiered( - groupedTiered: NewSubscriptionGroupedTieredPrice - ) = groupedTiered.validity() + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) - override fun visitGroupedWithMinMaxThresholds( - groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds - ) = groupedWithMinMaxThresholds.validity() + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } - override fun visitMinimum(minimum: NewSubscriptionMinimumCompositePrice) = - minimum.validity() + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) - override fun unknown(json: JsonValue?) = 0 + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - return other is Price && - unit == other.unit && - package_ == other.package_ && - matrix == other.matrix && - tiered == other.tiered && - bulk == other.bulk && - thresholdTotalAmount == other.thresholdTotalAmount && - tieredPackage == other.tieredPackage && - tieredWithMinimum == other.tieredWithMinimum && - unitWithPercent == other.unitWithPercent && - packageWithAllocation == other.packageWithAllocation && - tieredWithProration == other.tieredWithProration && - unitWithProration == other.unitWithProration && - groupedAllocation == other.groupedAllocation && - groupedWithProratedMinimum == other.groupedWithProratedMinimum && - bulkWithProration == other.bulkWithProration && - scalableMatrixWithUnitPricing == other.scalableMatrixWithUnitPricing && - scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && - cumulativeGroupedBulk == other.cumulativeGroupedBulk && - maxGroupTieredPackage == other.maxGroupTieredPackage && - groupedWithMeteredMinimum == other.groupedWithMeteredMinimum && - matrixWithDisplayName == other.matrixWithDisplayName && - groupedTieredPackage == other.groupedTieredPackage && - matrixWithAllocation == other.matrixWithAllocation && - tieredPackageWithMinimum == other.tieredPackageWithMinimum && - groupedTiered == other.groupedTiered && - groupedWithMinMaxThresholds == other.groupedWithMinMaxThresholds && - minimum == other.minimum - } + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) - override fun hashCode(): Int = - Objects.hash( - unit, - package_, - matrix, - tiered, - bulk, - thresholdTotalAmount, - tieredPackage, - tieredWithMinimum, - unitWithPercent, - packageWithAllocation, - tieredWithProration, - unitWithProration, - groupedAllocation, - groupedWithProratedMinimum, - bulkWithProration, - scalableMatrixWithUnitPricing, - scalableMatrixWithTieredPricing, - cumulativeGroupedBulk, - maxGroupTieredPackage, - groupedWithMeteredMinimum, - matrixWithDisplayName, - groupedTieredPackage, - matrixWithAllocation, - tieredPackageWithMinimum, - groupedTiered, - groupedWithMinMaxThresholds, - minimum, - ) + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) - override fun toString(): String = - when { - unit != null -> "Price{unit=$unit}" - package_ != null -> "Price{package_=$package_}" - matrix != null -> "Price{matrix=$matrix}" - tiered != null -> "Price{tiered=$tiered}" - bulk != null -> "Price{bulk=$bulk}" - thresholdTotalAmount != null -> - "Price{thresholdTotalAmount=$thresholdTotalAmount}" - tieredPackage != null -> "Price{tieredPackage=$tieredPackage}" - tieredWithMinimum != null -> "Price{tieredWithMinimum=$tieredWithMinimum}" - unitWithPercent != null -> "Price{unitWithPercent=$unitWithPercent}" - packageWithAllocation != null -> - "Price{packageWithAllocation=$packageWithAllocation}" - tieredWithProration != null -> "Price{tieredWithProration=$tieredWithProration}" - unitWithProration != null -> "Price{unitWithProration=$unitWithProration}" - groupedAllocation != null -> "Price{groupedAllocation=$groupedAllocation}" - groupedWithProratedMinimum != null -> - "Price{groupedWithProratedMinimum=$groupedWithProratedMinimum}" - bulkWithProration != null -> "Price{bulkWithProration=$bulkWithProration}" - scalableMatrixWithUnitPricing != null -> - "Price{scalableMatrixWithUnitPricing=$scalableMatrixWithUnitPricing}" - scalableMatrixWithTieredPricing != null -> - "Price{scalableMatrixWithTieredPricing=$scalableMatrixWithTieredPricing}" - cumulativeGroupedBulk != null -> - "Price{cumulativeGroupedBulk=$cumulativeGroupedBulk}" - maxGroupTieredPackage != null -> - "Price{maxGroupTieredPackage=$maxGroupTieredPackage}" - groupedWithMeteredMinimum != null -> - "Price{groupedWithMeteredMinimum=$groupedWithMeteredMinimum}" - matrixWithDisplayName != null -> - "Price{matrixWithDisplayName=$matrixWithDisplayName}" - groupedTieredPackage != null -> - "Price{groupedTieredPackage=$groupedTieredPackage}" - matrixWithAllocation != null -> - "Price{matrixWithAllocation=$matrixWithAllocation}" - tieredPackageWithMinimum != null -> - "Price{tieredPackageWithMinimum=$tieredPackageWithMinimum}" - groupedTiered != null -> "Price{groupedTiered=$groupedTiered}" - groupedWithMinMaxThresholds != null -> - "Price{groupedWithMinMaxThresholds=$groupedWithMinMaxThresholds}" - minimum != null -> "Price{minimum=$minimum}" - _json != null -> "Price{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Price") - } + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } - companion object { + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) - fun ofUnit(unit: NewSubscriptionUnitPrice) = Price(unit = unit) + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } - fun ofPackage(package_: NewSubscriptionPackagePrice) = Price(package_ = package_) + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) - fun ofMatrix(matrix: NewSubscriptionMatrixPrice) = Price(matrix = matrix) + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - fun ofTiered(tiered: NewSubscriptionTieredPrice) = Price(tiered = tiered) + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - fun ofBulk(bulk: NewSubscriptionBulkPrice) = Price(bulk = bulk) + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - fun ofThresholdTotalAmount( - thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice - ) = Price(thresholdTotalAmount = thresholdTotalAmount) + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) - fun ofTieredPackage(tieredPackage: NewSubscriptionTieredPackagePrice) = - Price(tieredPackage = tieredPackage) + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } - fun ofTieredWithMinimum(tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice) = - Price(tieredWithMinimum = tieredWithMinimum) + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun ofUnitWithPercent(unitWithPercent: NewSubscriptionUnitWithPercentPrice) = - Price(unitWithPercent = unitWithPercent) + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun ofPackageWithAllocation( - packageWithAllocation: NewSubscriptionPackageWithAllocationPrice - ) = Price(packageWithAllocation = packageWithAllocation) + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun ofTieredWithProration( - tieredWithProration: NewSubscriptionTierWithProrationPrice - ) = Price(tieredWithProration = tieredWithProration) + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun ofUnitWithProration(unitWithProration: NewSubscriptionUnitWithProrationPrice) = - Price(unitWithProration = unitWithProration) + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - fun ofGroupedAllocation(groupedAllocation: NewSubscriptionGroupedAllocationPrice) = - Price(groupedAllocation = groupedAllocation) + /** + * Returns an immutable instance of [TieredWithProration]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .name() + * .tieredWithProrationConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TieredWithProration = + TieredWithProration( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + modelType, + checkRequired("name", name), + checkRequired("tieredWithProrationConfig", tieredWithProrationConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } - fun ofGroupedWithProratedMinimum( - groupedWithProratedMinimum: NewSubscriptionGroupedWithProratedMinimumPrice - ) = Price(groupedWithProratedMinimum = groupedWithProratedMinimum) + private var validated: Boolean = false - fun ofBulkWithProration(bulkWithProration: NewSubscriptionBulkWithProrationPrice) = - Price(bulkWithProration = bulkWithProration) + fun validate(): TieredWithProration = apply { + if (validated) { + return@apply + } - fun ofScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: NewSubscriptionScalableMatrixWithUnitPricingPrice - ) = Price(scalableMatrixWithUnitPricing = scalableMatrixWithUnitPricing) + cadence().validate() + itemId() + _modelType().let { + if (it != JsonValue.from("tiered_with_proration")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + tieredWithProrationConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + metadata()?.validate() + referenceId() + validated = true + } - fun ofScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: - NewSubscriptionScalableMatrixWithTieredPricingPrice - ) = Price(scalableMatrixWithTieredPricing = scalableMatrixWithTieredPricing) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - fun ofCumulativeGroupedBulk( - cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice - ) = Price(cumulativeGroupedBulk = cumulativeGroupedBulk) + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + modelType.let { + if (it == JsonValue.from("tiered_with_proration")) 1 else 0 + } + + (if (name.asKnown() == null) 0 else 1) + + (tieredWithProrationConfig.asKnown()?.validity() ?: 0) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) - fun ofMaxGroupTieredPackage( - maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice - ) = Price(maxGroupTieredPackage = maxGroupTieredPackage) + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { - fun ofGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice - ) = Price(groupedWithMeteredMinimum = groupedWithMeteredMinimum) + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value - fun ofMatrixWithDisplayName( - matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice - ) = Price(matrixWithDisplayName = matrixWithDisplayName) + companion object { - fun ofGroupedTieredPackage( - groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice - ) = Price(groupedTieredPackage = groupedTieredPackage) + val ANNUAL = of("annual") - fun ofMatrixWithAllocation( - matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice - ) = Price(matrixWithAllocation = matrixWithAllocation) + val SEMI_ANNUAL = of("semi_annual") - fun ofTieredPackageWithMinimum( - tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice - ) = Price(tieredPackageWithMinimum = tieredPackageWithMinimum) + val MONTHLY = of("monthly") - fun ofGroupedTiered(groupedTiered: NewSubscriptionGroupedTieredPrice) = - Price(groupedTiered = groupedTiered) + val QUARTERLY = of("quarterly") - fun ofGroupedWithMinMaxThresholds( - groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds - ) = Price(groupedWithMinMaxThresholds = groupedWithMinMaxThresholds) + val ONE_TIME = of("one_time") - fun ofMinimum(minimum: NewSubscriptionMinimumCompositePrice) = - Price(minimum = minimum) - } + val CUSTOM = of("custom") - /** - * An interface that defines how to map each variant of [Price] to a value of type [T]. - */ - interface Visitor { + fun of(value: String) = Cadence(JsonField.of(value)) + } - fun visitUnit(unit: NewSubscriptionUnitPrice): T + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } - fun visitPackage(package_: NewSubscriptionPackagePrice): T + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } - fun visitMatrix(matrix: NewSubscriptionMatrixPrice): T + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } - fun visitTiered(tiered: NewSubscriptionTieredPrice): T + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } - fun visitBulk(bulk: NewSubscriptionBulkPrice): T + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") - fun visitThresholdTotalAmount( - thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice - ): T + private var validated: Boolean = false - fun visitTieredPackage(tieredPackage: NewSubscriptionTieredPackagePrice): T + fun validate(): Cadence = apply { + if (validated) { + return@apply + } - fun visitTieredWithMinimum( - tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice - ): T + known() + validated = true + } - fun visitUnitWithPercent(unitWithPercent: NewSubscriptionUnitWithPercentPrice): T + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - fun visitPackageWithAllocation( - packageWithAllocation: NewSubscriptionPackageWithAllocationPrice - ): T + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - fun visitTieredWithProration( - tieredWithProration: NewSubscriptionTierWithProrationPrice - ): T + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun visitUnitWithProration( - unitWithProration: NewSubscriptionUnitWithProrationPrice - ): T + return other is Cadence && value == other.value + } - fun visitGroupedAllocation( - groupedAllocation: NewSubscriptionGroupedAllocationPrice - ): T + override fun hashCode() = value.hashCode() - fun visitGroupedWithProratedMinimum( - groupedWithProratedMinimum: NewSubscriptionGroupedWithProratedMinimumPrice - ): T + override fun toString() = value.toString() + } - fun visitBulkWithProration( - bulkWithProration: NewSubscriptionBulkWithProrationPrice - ): T + /** Configuration for tiered_with_proration pricing */ + class TieredWithProrationConfig + private constructor( + private val tiers: JsonField>, + private val additionalProperties: MutableMap, + ) { - fun visitScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: NewSubscriptionScalableMatrixWithUnitPricingPrice - ): T + @JsonCreator + private constructor( + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of() + ) : this(tiers, mutableMapOf()) - fun visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: - NewSubscriptionScalableMatrixWithTieredPricingPrice - ): T + /** + * Tiers for rating based on total usage quantities into the specified tier with + * proration + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun tiers(): List = tiers.getRequired("tiers") - fun visitCumulativeGroupedBulk( - cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice - ): T + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers - fun visitMaxGroupTieredPackage( - maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice - ): T + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - fun visitGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice - ): T + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - fun visitMatrixWithDisplayName( - matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice - ): T + fun toBuilder() = Builder().from(this) - fun visitGroupedTieredPackage( - groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice - ): T + companion object { - fun visitMatrixWithAllocation( - matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice - ): T + /** + * Returns a mutable builder for constructing an instance of + * [TieredWithProrationConfig]. + * + * The following fields are required: + * ```kotlin + * .tiers() + * ``` + */ + fun builder() = Builder() + } - fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice - ): T + /** A builder for [TieredWithProrationConfig]. */ + class Builder internal constructor() { - fun visitGroupedTiered(groupedTiered: NewSubscriptionGroupedTieredPrice): T + private var tiers: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() - fun visitGroupedWithMinMaxThresholds( - groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds - ): T + internal fun from(tieredWithProrationConfig: TieredWithProrationConfig) = + apply { + tiers = tieredWithProrationConfig.tiers.map { it.toMutableList() } + additionalProperties = + tieredWithProrationConfig.additionalProperties.toMutableMap() + } - fun visitMinimum(minimum: NewSubscriptionMinimumCompositePrice): T + /** + * Tiers for rating based on total usage quantities into the specified tier + * with proration + */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) - /** - * Maps an unknown variant of [Price] to a value of type [T]. - * - * An instance of [Price] can contain an unknown variant if it was deserialized from - * data that doesn't match any known variant. For example, if the SDK is on an older - * version than the API, then the API may respond with new variants that the SDK is - * unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown Price: $json") - } - } + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } - internal class Deserializer : BaseDeserializer(Price::class) { + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } - override fun ObjectCodec.deserialize(node: JsonNode): Price { - val json = JsonValue.fromJsonNode(node) - val modelType = json.asObject()?.get("model_type")?.asString() + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - when (modelType) { - "unit" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(unit = it, _json = json) } ?: Price(_json = json) - } - "package" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(package_ = it, _json = json) } ?: Price(_json = json) - } - "matrix" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(matrix = it, _json = json) } ?: Price(_json = json) - } - "tiered" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(tiered = it, _json = json) } ?: Price(_json = json) - } - "bulk" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(bulk = it, _json = json) } ?: Price(_json = json) - } - "threshold_total_amount" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(thresholdTotalAmount = it, _json = json) } - ?: Price(_json = json) - } - "tiered_package" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(tieredPackage = it, _json = json) } - ?: Price(_json = json) - } - "tiered_with_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(tieredWithMinimum = it, _json = json) } - ?: Price(_json = json) - } - "unit_with_percent" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(unitWithPercent = it, _json = json) } - ?: Price(_json = json) + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) } - "package_with_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(packageWithAllocation = it, _json = json) } - ?: Price(_json = json) + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) } - "tiered_with_proration" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(tieredWithProration = it, _json = json) } - ?: Price(_json = json) + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) } - "unit_with_proration" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(unitWithProration = it, _json = json) } - ?: Price(_json = json) + + /** + * Returns an immutable instance of [TieredWithProrationConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TieredWithProrationConfig = + TieredWithProrationConfig( + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TieredWithProrationConfig = apply { + if (validated) { + return@apply } - "grouped_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedAllocation = it, _json = json) } - ?: Price(_json = json) + + tiers().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false } - "grouped_with_prorated_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedWithProratedMinimum = it, _json = json) } - ?: Price(_json = json) + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (tiers.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single tiered with proration tier */ + class Tier + private constructor( + private val tierLowerBound: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(tierLowerBound, unitAmount, mutableMapOf()) + + /** + * Inclusive tier starting value + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun tierLowerBound(): String = + tierLowerBound.getRequired("tier_lower_bound") + + /** + * Amount per unit + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) } - "bulk_with_proration" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(bulkWithProration = it, _json = json) } - ?: Price(_json = json) + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Tier]. + * + * The following fields are required: + * ```kotlin + * .tierLowerBound() + * .unitAmount() + * ``` + */ + fun builder() = Builder() } - "scalable_matrix_with_unit_pricing" -> { - return tryDeserialize( - node, - jacksonTypeRef< - NewSubscriptionScalableMatrixWithUnitPricingPrice - >(), + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var tierLowerBound: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(tier: Tier) = apply { + tierLowerBound = tier.tierLowerBound + unitAmount = tier.unitAmount + additionalProperties = tier.additionalProperties.toMutableMap() + } + + /** Inclusive tier starting value */ + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + /** Amount per unit */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```kotlin + * .tierLowerBound() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("tierLowerBound", tierLowerBound), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), ) - ?.let { Price(scalableMatrixWithUnitPricing = it, _json = json) } - ?: Price(_json = json) } - "scalable_matrix_with_tiered_pricing" -> { - return tryDeserialize( - node, - jacksonTypeRef< - NewSubscriptionScalableMatrixWithTieredPricingPrice - >(), - ) - ?.let { Price(scalableMatrixWithTieredPricing = it, _json = json) } - ?: Price(_json = json) + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + tierLowerBound() + unitAmount() + validated = true } - "cumulative_grouped_bulk" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(cumulativeGroupedBulk = it, _json = json) } - ?: Price(_json = json) + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (tierLowerBound.asKnown() == null) 0 else 1) + + (if (unitAmount.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + tierLowerBound == other.tierLowerBound && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties } - "max_group_tiered_package" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(maxGroupTieredPackage = it, _json = json) } - ?: Price(_json = json) + + private val hashCode: Int by lazy { + Objects.hash(tierLowerBound, unitAmount, additionalProperties) } - "grouped_with_metered_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedWithMeteredMinimum = it, _json = json) } - ?: Price(_json = json) + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - "matrix_with_display_name" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(matrixWithDisplayName = it, _json = json) } - ?: Price(_json = json) + + return other is TieredWithProrationConfig && + tiers == other.tiers && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(tiers, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TieredWithProrationConfig{tiers=$tiers, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() } - "grouped_tiered_package" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedTieredPackage = it, _json = json) } - ?: Price(_json = json) + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) } - "matrix_with_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(matrixWithAllocation = it, _json = json) } - ?: Price(_json = json) + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) } - "tiered_package_with_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(tieredPackageWithMinimum = it, _json = json) } - ?: Price(_json = json) + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) } - "grouped_tiered" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedTiered = it, _json = json) } - ?: Price(_json = json) + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply } - "grouped_with_min_max_thresholds" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedWithMinMaxThresholds = it, _json = json) } - ?: Price(_json = json) + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false } - "minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(minimum = it, _json = json) } ?: Price(_json = json) + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } + + return other is Metadata && + additionalProperties == other.additionalProperties } - return Price(_json = json) - } - } + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - internal class Serializer : BaseSerializer(Price::class) { + override fun hashCode(): Int = hashCode - override fun serialize( - value: Price, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unit != null -> generator.writeObject(value.unit) - value.package_ != null -> generator.writeObject(value.package_) - value.matrix != null -> generator.writeObject(value.matrix) - value.tiered != null -> generator.writeObject(value.tiered) - value.bulk != null -> generator.writeObject(value.bulk) - value.thresholdTotalAmount != null -> - generator.writeObject(value.thresholdTotalAmount) - value.tieredPackage != null -> generator.writeObject(value.tieredPackage) - value.tieredWithMinimum != null -> - generator.writeObject(value.tieredWithMinimum) - value.unitWithPercent != null -> - generator.writeObject(value.unitWithPercent) - value.packageWithAllocation != null -> - generator.writeObject(value.packageWithAllocation) - value.tieredWithProration != null -> - generator.writeObject(value.tieredWithProration) - value.unitWithProration != null -> - generator.writeObject(value.unitWithProration) - value.groupedAllocation != null -> - generator.writeObject(value.groupedAllocation) - value.groupedWithProratedMinimum != null -> - generator.writeObject(value.groupedWithProratedMinimum) - value.bulkWithProration != null -> - generator.writeObject(value.bulkWithProration) - value.scalableMatrixWithUnitPricing != null -> - generator.writeObject(value.scalableMatrixWithUnitPricing) - value.scalableMatrixWithTieredPricing != null -> - generator.writeObject(value.scalableMatrixWithTieredPricing) - value.cumulativeGroupedBulk != null -> - generator.writeObject(value.cumulativeGroupedBulk) - value.maxGroupTieredPackage != null -> - generator.writeObject(value.maxGroupTieredPackage) - value.groupedWithMeteredMinimum != null -> - generator.writeObject(value.groupedWithMeteredMinimum) - value.matrixWithDisplayName != null -> - generator.writeObject(value.matrixWithDisplayName) - value.groupedTieredPackage != null -> - generator.writeObject(value.groupedTieredPackage) - value.matrixWithAllocation != null -> - generator.writeObject(value.matrixWithAllocation) - value.tieredPackageWithMinimum != null -> - generator.writeObject(value.tieredPackageWithMinimum) - value.groupedTiered != null -> generator.writeObject(value.groupedTiered) - value.groupedWithMinMaxThresholds != null -> - generator.writeObject(value.groupedWithMinMaxThresholds) - value.minimum != null -> generator.writeObject(value.minimum) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Price") + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } + + return other is TieredWithProration && + cadence == other.cadence && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + tieredWithProrationConfig == other.tieredWithProrationConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + modelType, + name, + tieredWithProrationConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties, + ) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TieredWithProration{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredWithProrationConfig=$tieredWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } class GroupedWithMinMaxThresholds @@ -10633,6 +14368,8 @@ private constructor( fun cadence(): Cadence = cadence.getRequired("cadence") /** + * Configuration for grouped_with_min_max_thresholds pricing + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected * value). @@ -10652,6 +14389,8 @@ private constructor( fun itemId(): String = itemId.getRequired("item_id") /** + * The pricing model type + * * Expected to always return the following: * ```kotlin * JsonValue.from("grouped_with_min_max_thresholds") @@ -11061,6 +14800,7 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + /** Configuration for grouped_with_min_max_thresholds pricing */ fun groupedWithMinMaxThresholdsConfig( groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig ) = @@ -11716,16 +15456,117 @@ private constructor( override fun toString() = value.toString() } + /** Configuration for grouped_with_min_max_thresholds pricing */ class GroupedWithMinMaxThresholdsConfig - @JsonCreator private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map + private val groupingKey: JsonField, + private val maximumCharge: JsonField, + private val minimumCharge: JsonField, + private val perUnitRate: JsonField, + private val additionalProperties: MutableMap, ) { + @JsonCreator + private constructor( + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("maximum_charge") + @ExcludeMissing + maximumCharge: JsonField = JsonMissing.of(), + @JsonProperty("minimum_charge") + @ExcludeMissing + minimumCharge: JsonField = JsonMissing.of(), + @JsonProperty("per_unit_rate") + @ExcludeMissing + perUnitRate: JsonField = JsonMissing.of(), + ) : this(groupingKey, maximumCharge, minimumCharge, perUnitRate, mutableMapOf()) + + /** + * The event property used to group before applying thresholds + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The maximum amount to charge each group + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun maximumCharge(): String = maximumCharge.getRequired("maximum_charge") + + /** + * The minimum amount to charge each group, regardless of usage + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun minimumCharge(): String = minimumCharge.getRequired("minimum_charge") + + /** + * The base price charged per group + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun perUnitRate(): String = perUnitRate.getRequired("per_unit_rate") + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [maximumCharge]. + * + * Unlike [maximumCharge], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("maximum_charge") + @ExcludeMissing + fun _maximumCharge(): JsonField = maximumCharge + + /** + * Returns the raw JSON value of [minimumCharge]. + * + * Unlike [minimumCharge], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("minimum_charge") + @ExcludeMissing + fun _minimumCharge(): JsonField = minimumCharge + + /** + * Returns the raw JSON value of [perUnitRate]. + * + * Unlike [perUnitRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("per_unit_rate") + @ExcludeMissing + fun _perUnitRate(): JsonField = perUnitRate + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) fun toBuilder() = Builder().from(this) @@ -11734,6 +15575,14 @@ private constructor( /** * Returns a mutable builder for constructing an instance of * [GroupedWithMinMaxThresholdsConfig]. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .maximumCharge() + * .minimumCharge() + * .perUnitRate() + * ``` */ fun builder() = Builder() } @@ -11741,17 +15590,85 @@ private constructor( /** A builder for [GroupedWithMinMaxThresholdsConfig]. */ class Builder internal constructor() { + private var groupingKey: JsonField? = null + private var maximumCharge: JsonField? = null + private var minimumCharge: JsonField? = null + private var perUnitRate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from( groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig ) = apply { + groupingKey = groupedWithMinMaxThresholdsConfig.groupingKey + maximumCharge = groupedWithMinMaxThresholdsConfig.maximumCharge + minimumCharge = groupedWithMinMaxThresholdsConfig.minimumCharge + perUnitRate = groupedWithMinMaxThresholdsConfig.perUnitRate additionalProperties = groupedWithMinMaxThresholdsConfig.additionalProperties .toMutableMap() } + /** The event property used to group before applying thresholds */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The maximum amount to charge each group */ + fun maximumCharge(maximumCharge: String) = + maximumCharge(JsonField.of(maximumCharge)) + + /** + * Sets [Builder.maximumCharge] to an arbitrary JSON value. + * + * You should usually call [Builder.maximumCharge] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun maximumCharge(maximumCharge: JsonField) = apply { + this.maximumCharge = maximumCharge + } + + /** The minimum amount to charge each group, regardless of usage */ + fun minimumCharge(minimumCharge: String) = + minimumCharge(JsonField.of(minimumCharge)) + + /** + * Sets [Builder.minimumCharge] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumCharge] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun minimumCharge(minimumCharge: JsonField) = apply { + this.minimumCharge = minimumCharge + } + + /** The base price charged per group */ + fun perUnitRate(perUnitRate: String) = + perUnitRate(JsonField.of(perUnitRate)) + + /** + * Sets [Builder.perUnitRate] to an arbitrary JSON value. + * + * You should usually call [Builder.perUnitRate] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun perUnitRate(perUnitRate: JsonField) = apply { + this.perUnitRate = perUnitRate + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -11778,9 +15695,25 @@ private constructor( * Returns an immutable instance of [GroupedWithMinMaxThresholdsConfig]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .maximumCharge() + * .minimumCharge() + * .perUnitRate() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ fun build(): GroupedWithMinMaxThresholdsConfig = - GroupedWithMinMaxThresholdsConfig(additionalProperties.toImmutable()) + GroupedWithMinMaxThresholdsConfig( + checkRequired("groupingKey", groupingKey), + checkRequired("maximumCharge", maximumCharge), + checkRequired("minimumCharge", minimumCharge), + checkRequired("perUnitRate", perUnitRate), + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false @@ -11790,6 +15723,10 @@ private constructor( return@apply } + groupingKey() + maximumCharge() + minimumCharge() + perUnitRate() validated = true } @@ -11808,9 +15745,10 @@ private constructor( * Used for best match union deserialization. */ internal fun validity(): Int = - additionalProperties.count { (_, value) -> - !value.isNull() && !value.isMissing() - } + (if (groupingKey.asKnown() == null) 0 else 1) + + (if (maximumCharge.asKnown() == null) 0 else 1) + + (if (minimumCharge.asKnown() == null) 0 else 1) + + (if (perUnitRate.asKnown() == null) 0 else 1) override fun equals(other: Any?): Boolean { if (this === other) { @@ -11818,15 +15756,27 @@ private constructor( } return other is GroupedWithMinMaxThresholdsConfig && + groupingKey == other.groupingKey && + maximumCharge == other.maximumCharge && + minimumCharge == other.minimumCharge && + perUnitRate == other.perUnitRate && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + private val hashCode: Int by lazy { + Objects.hash( + groupingKey, + maximumCharge, + minimumCharge, + perUnitRate, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode override fun toString() = - "GroupedWithMinMaxThresholdsConfig{additionalProperties=$additionalProperties}" + "GroupedWithMinMaxThresholdsConfig{groupingKey=$groupingKey, maximumCharge=$maximumCharge, minimumCharge=$minimumCharge, perUnitRate=$perUnitRate, additionalProperties=$additionalProperties}" } /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsParams.kt index 6eba17912..e52e6c471 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsParams.kt @@ -1033,7 +1033,7 @@ private constructor( fun minimumAmount(): Double? = minimumAmount.getNullable("minimum_amount") /** - * The definition of a new price to create and add to the subscription. + * New floating price request body params. * * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -1479,7 +1479,7 @@ private constructor( this.minimumAmount = minimumAmount } - /** The definition of a new price to create and add to the subscription. */ + /** New floating price request body params. */ fun price(price: Price?) = price(JsonField.ofNullable(price)) /** @@ -1494,24 +1494,18 @@ private constructor( /** Alias for calling [price] with `Price.ofUnit(unit)`. */ fun price(unit: NewFloatingUnitPrice) = price(Price.ofUnit(unit)) - /** Alias for calling [price] with `Price.ofPackage(package_)`. */ - fun price(package_: NewFloatingPackagePrice) = price(Price.ofPackage(package_)) - - /** Alias for calling [price] with `Price.ofMatrix(matrix)`. */ - fun price(matrix: NewFloatingMatrixPrice) = price(Price.ofMatrix(matrix)) - - /** - * Alias for calling [price] with `Price.ofMatrixWithAllocation(matrixWithAllocation)`. - */ - fun price(matrixWithAllocation: NewFloatingMatrixWithAllocationPrice) = - price(Price.ofMatrixWithAllocation(matrixWithAllocation)) - /** Alias for calling [price] with `Price.ofTiered(tiered)`. */ fun price(tiered: NewFloatingTieredPrice) = price(Price.ofTiered(tiered)) /** Alias for calling [price] with `Price.ofBulk(bulk)`. */ fun price(bulk: NewFloatingBulkPrice) = price(Price.ofBulk(bulk)) + /** Alias for calling [price] with `Price.ofPackage(package_)`. */ + fun price(package_: NewFloatingPackagePrice) = price(Price.ofPackage(package_)) + + /** Alias for calling [price] with `Price.ofMatrix(matrix)`. */ + fun price(matrix: NewFloatingMatrixPrice) = price(Price.ofMatrix(matrix)) + /** * Alias for calling [price] with `Price.ofThresholdTotalAmount(thresholdTotalAmount)`. */ @@ -1522,20 +1516,20 @@ private constructor( fun price(tieredPackage: NewFloatingTieredPackagePrice) = price(Price.ofTieredPackage(tieredPackage)) + /** Alias for calling [price] with `Price.ofTieredWithMinimum(tieredWithMinimum)`. */ + fun price(tieredWithMinimum: NewFloatingTieredWithMinimumPrice) = + price(Price.ofTieredWithMinimum(tieredWithMinimum)) + /** Alias for calling [price] with `Price.ofGroupedTiered(groupedTiered)`. */ fun price(groupedTiered: NewFloatingGroupedTieredPrice) = price(Price.ofGroupedTiered(groupedTiered)) /** * Alias for calling [price] with - * `Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)`. + * `Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)`. */ - fun price(maxGroupTieredPackage: NewFloatingMaxGroupTieredPackagePrice) = - price(Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)) - - /** Alias for calling [price] with `Price.ofTieredWithMinimum(tieredWithMinimum)`. */ - fun price(tieredWithMinimum: NewFloatingTieredWithMinimumPrice) = - price(Price.ofTieredWithMinimum(tieredWithMinimum)) + fun price(tieredPackageWithMinimum: NewFloatingTieredPackageWithMinimumPrice) = + price(Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)) /** * Alias for calling [price] with @@ -1544,17 +1538,16 @@ private constructor( fun price(packageWithAllocation: NewFloatingPackageWithAllocationPrice) = price(Price.ofPackageWithAllocation(packageWithAllocation)) - /** - * Alias for calling [price] with - * `Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)`. - */ - fun price(tieredPackageWithMinimum: NewFloatingTieredPackageWithMinimumPrice) = - price(Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)) - /** Alias for calling [price] with `Price.ofUnitWithPercent(unitWithPercent)`. */ fun price(unitWithPercent: NewFloatingUnitWithPercentPrice) = price(Price.ofUnitWithPercent(unitWithPercent)) + /** + * Alias for calling [price] with `Price.ofMatrixWithAllocation(matrixWithAllocation)`. + */ + fun price(matrixWithAllocation: NewFloatingMatrixWithAllocationPrice) = + price(Price.ofMatrixWithAllocation(matrixWithAllocation)) + /** * Alias for calling [price] with `Price.ofTieredWithProration(tieredWithProration)`. */ @@ -1569,6 +1562,10 @@ private constructor( fun price(groupedAllocation: NewFloatingGroupedAllocationPrice) = price(Price.ofGroupedAllocation(groupedAllocation)) + /** Alias for calling [price] with `Price.ofBulkWithProration(bulkWithProration)`. */ + fun price(bulkWithProration: NewFloatingBulkWithProrationPrice) = + price(Price.ofBulkWithProration(bulkWithProration)) + /** * Alias for calling [price] with * `Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)`. @@ -1583,6 +1580,13 @@ private constructor( fun price(groupedWithMeteredMinimum: NewFloatingGroupedWithMeteredMinimumPrice) = price(Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)) + /** + * Alias for calling [price] with + * `Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)`. + */ + fun price(groupedWithMinMaxThresholds: Price.GroupedWithMinMaxThresholds) = + price(Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)) + /** * Alias for calling [price] with * `Price.ofMatrixWithDisplayName(matrixWithDisplayName)`. @@ -1590,16 +1594,19 @@ private constructor( fun price(matrixWithDisplayName: NewFloatingMatrixWithDisplayNamePrice) = price(Price.ofMatrixWithDisplayName(matrixWithDisplayName)) - /** Alias for calling [price] with `Price.ofBulkWithProration(bulkWithProration)`. */ - fun price(bulkWithProration: NewFloatingBulkWithProrationPrice) = - price(Price.ofBulkWithProration(bulkWithProration)) - /** * Alias for calling [price] with `Price.ofGroupedTieredPackage(groupedTieredPackage)`. */ fun price(groupedTieredPackage: NewFloatingGroupedTieredPackagePrice) = price(Price.ofGroupedTieredPackage(groupedTieredPackage)) + /** + * Alias for calling [price] with + * `Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)`. + */ + fun price(maxGroupTieredPackage: NewFloatingMaxGroupTieredPackagePrice) = + price(Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)) + /** * Alias for calling [price] with * `Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)`. @@ -1623,13 +1630,6 @@ private constructor( fun price(cumulativeGroupedBulk: NewFloatingCumulativeGroupedBulkPrice) = price(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) - /** - * Alias for calling [price] with - * `Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)`. - */ - fun price(groupedWithMinMaxThresholds: Price.GroupedWithMinMaxThresholds) = - price(Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)) - /** Alias for calling [price] with `Price.ofMinimum(minimum)`. */ fun price(minimum: NewFloatingMinimumCompositePrice) = price(Price.ofMinimum(minimum)) @@ -3211,35 +3211,36 @@ private constructor( "FixedFeeQuantityTransition{effectiveDate=$effectiveDate, quantity=$quantity, additionalProperties=$additionalProperties}" } - /** The definition of a new price to create and add to the subscription. */ + /** New floating price request body params. */ @JsonDeserialize(using = Price.Deserializer::class) @JsonSerialize(using = Price.Serializer::class) class Price private constructor( private val unit: NewFloatingUnitPrice? = null, - private val package_: NewFloatingPackagePrice? = null, - private val matrix: NewFloatingMatrixPrice? = null, - private val matrixWithAllocation: NewFloatingMatrixWithAllocationPrice? = null, private val tiered: NewFloatingTieredPrice? = null, private val bulk: NewFloatingBulkPrice? = null, + private val package_: NewFloatingPackagePrice? = null, + private val matrix: NewFloatingMatrixPrice? = null, private val thresholdTotalAmount: NewFloatingThresholdTotalAmountPrice? = null, private val tieredPackage: NewFloatingTieredPackagePrice? = null, - private val groupedTiered: NewFloatingGroupedTieredPrice? = null, - private val maxGroupTieredPackage: NewFloatingMaxGroupTieredPackagePrice? = null, private val tieredWithMinimum: NewFloatingTieredWithMinimumPrice? = null, - private val packageWithAllocation: NewFloatingPackageWithAllocationPrice? = null, + private val groupedTiered: NewFloatingGroupedTieredPrice? = null, private val tieredPackageWithMinimum: NewFloatingTieredPackageWithMinimumPrice? = null, + private val packageWithAllocation: NewFloatingPackageWithAllocationPrice? = null, private val unitWithPercent: NewFloatingUnitWithPercentPrice? = null, + private val matrixWithAllocation: NewFloatingMatrixWithAllocationPrice? = null, private val tieredWithProration: NewFloatingTieredWithProrationPrice? = null, private val unitWithProration: NewFloatingUnitWithProrationPrice? = null, private val groupedAllocation: NewFloatingGroupedAllocationPrice? = null, + private val bulkWithProration: NewFloatingBulkWithProrationPrice? = null, private val groupedWithProratedMinimum: NewFloatingGroupedWithProratedMinimumPrice? = null, private val groupedWithMeteredMinimum: NewFloatingGroupedWithMeteredMinimumPrice? = null, + private val groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds? = null, private val matrixWithDisplayName: NewFloatingMatrixWithDisplayNamePrice? = null, - private val bulkWithProration: NewFloatingBulkWithProrationPrice? = null, private val groupedTieredPackage: NewFloatingGroupedTieredPackagePrice? = null, + private val maxGroupTieredPackage: NewFloatingMaxGroupTieredPackagePrice? = null, private val scalableMatrixWithUnitPricing: NewFloatingScalableMatrixWithUnitPricingPrice? = null, @@ -3247,61 +3248,63 @@ private constructor( NewFloatingScalableMatrixWithTieredPricingPrice? = null, private val cumulativeGroupedBulk: NewFloatingCumulativeGroupedBulkPrice? = null, - private val groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds? = null, private val minimum: NewFloatingMinimumCompositePrice? = null, private val _json: JsonValue? = null, ) { fun unit(): NewFloatingUnitPrice? = unit - fun package_(): NewFloatingPackagePrice? = package_ - - fun matrix(): NewFloatingMatrixPrice? = matrix - - fun matrixWithAllocation(): NewFloatingMatrixWithAllocationPrice? = matrixWithAllocation - fun tiered(): NewFloatingTieredPrice? = tiered fun bulk(): NewFloatingBulkPrice? = bulk - fun thresholdTotalAmount(): NewFloatingThresholdTotalAmountPrice? = thresholdTotalAmount + fun package_(): NewFloatingPackagePrice? = package_ - fun tieredPackage(): NewFloatingTieredPackagePrice? = tieredPackage + fun matrix(): NewFloatingMatrixPrice? = matrix - fun groupedTiered(): NewFloatingGroupedTieredPrice? = groupedTiered + fun thresholdTotalAmount(): NewFloatingThresholdTotalAmountPrice? = thresholdTotalAmount - fun maxGroupTieredPackage(): NewFloatingMaxGroupTieredPackagePrice? = - maxGroupTieredPackage + fun tieredPackage(): NewFloatingTieredPackagePrice? = tieredPackage fun tieredWithMinimum(): NewFloatingTieredWithMinimumPrice? = tieredWithMinimum - fun packageWithAllocation(): NewFloatingPackageWithAllocationPrice? = - packageWithAllocation + fun groupedTiered(): NewFloatingGroupedTieredPrice? = groupedTiered fun tieredPackageWithMinimum(): NewFloatingTieredPackageWithMinimumPrice? = tieredPackageWithMinimum + fun packageWithAllocation(): NewFloatingPackageWithAllocationPrice? = + packageWithAllocation + fun unitWithPercent(): NewFloatingUnitWithPercentPrice? = unitWithPercent + fun matrixWithAllocation(): NewFloatingMatrixWithAllocationPrice? = matrixWithAllocation + fun tieredWithProration(): NewFloatingTieredWithProrationPrice? = tieredWithProration fun unitWithProration(): NewFloatingUnitWithProrationPrice? = unitWithProration fun groupedAllocation(): NewFloatingGroupedAllocationPrice? = groupedAllocation + fun bulkWithProration(): NewFloatingBulkWithProrationPrice? = bulkWithProration + fun groupedWithProratedMinimum(): NewFloatingGroupedWithProratedMinimumPrice? = groupedWithProratedMinimum fun groupedWithMeteredMinimum(): NewFloatingGroupedWithMeteredMinimumPrice? = groupedWithMeteredMinimum + fun groupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds? = + groupedWithMinMaxThresholds + fun matrixWithDisplayName(): NewFloatingMatrixWithDisplayNamePrice? = matrixWithDisplayName - fun bulkWithProration(): NewFloatingBulkWithProrationPrice? = bulkWithProration - fun groupedTieredPackage(): NewFloatingGroupedTieredPackagePrice? = groupedTieredPackage + fun maxGroupTieredPackage(): NewFloatingMaxGroupTieredPackagePrice? = + maxGroupTieredPackage + fun scalableMatrixWithUnitPricing(): NewFloatingScalableMatrixWithUnitPricingPrice? = scalableMatrixWithUnitPricing @@ -3311,55 +3314,54 @@ private constructor( fun cumulativeGroupedBulk(): NewFloatingCumulativeGroupedBulkPrice? = cumulativeGroupedBulk - fun groupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds? = - groupedWithMinMaxThresholds - fun minimum(): NewFloatingMinimumCompositePrice? = minimum fun isUnit(): Boolean = unit != null - fun isPackage(): Boolean = package_ != null - - fun isMatrix(): Boolean = matrix != null - - fun isMatrixWithAllocation(): Boolean = matrixWithAllocation != null - fun isTiered(): Boolean = tiered != null fun isBulk(): Boolean = bulk != null - fun isThresholdTotalAmount(): Boolean = thresholdTotalAmount != null + fun isPackage(): Boolean = package_ != null - fun isTieredPackage(): Boolean = tieredPackage != null + fun isMatrix(): Boolean = matrix != null - fun isGroupedTiered(): Boolean = groupedTiered != null + fun isThresholdTotalAmount(): Boolean = thresholdTotalAmount != null - fun isMaxGroupTieredPackage(): Boolean = maxGroupTieredPackage != null + fun isTieredPackage(): Boolean = tieredPackage != null fun isTieredWithMinimum(): Boolean = tieredWithMinimum != null - fun isPackageWithAllocation(): Boolean = packageWithAllocation != null + fun isGroupedTiered(): Boolean = groupedTiered != null fun isTieredPackageWithMinimum(): Boolean = tieredPackageWithMinimum != null + fun isPackageWithAllocation(): Boolean = packageWithAllocation != null + fun isUnitWithPercent(): Boolean = unitWithPercent != null + fun isMatrixWithAllocation(): Boolean = matrixWithAllocation != null + fun isTieredWithProration(): Boolean = tieredWithProration != null fun isUnitWithProration(): Boolean = unitWithProration != null fun isGroupedAllocation(): Boolean = groupedAllocation != null + fun isBulkWithProration(): Boolean = bulkWithProration != null + fun isGroupedWithProratedMinimum(): Boolean = groupedWithProratedMinimum != null fun isGroupedWithMeteredMinimum(): Boolean = groupedWithMeteredMinimum != null - fun isMatrixWithDisplayName(): Boolean = matrixWithDisplayName != null + fun isGroupedWithMinMaxThresholds(): Boolean = groupedWithMinMaxThresholds != null - fun isBulkWithProration(): Boolean = bulkWithProration != null + fun isMatrixWithDisplayName(): Boolean = matrixWithDisplayName != null fun isGroupedTieredPackage(): Boolean = groupedTieredPackage != null + fun isMaxGroupTieredPackage(): Boolean = maxGroupTieredPackage != null + fun isScalableMatrixWithUnitPricing(): Boolean = scalableMatrixWithUnitPricing != null fun isScalableMatrixWithTieredPricing(): Boolean = @@ -3367,47 +3369,42 @@ private constructor( fun isCumulativeGroupedBulk(): Boolean = cumulativeGroupedBulk != null - fun isGroupedWithMinMaxThresholds(): Boolean = groupedWithMinMaxThresholds != null - fun isMinimum(): Boolean = minimum != null fun asUnit(): NewFloatingUnitPrice = unit.getOrThrow("unit") - fun asPackage(): NewFloatingPackagePrice = package_.getOrThrow("package_") - - fun asMatrix(): NewFloatingMatrixPrice = matrix.getOrThrow("matrix") - - fun asMatrixWithAllocation(): NewFloatingMatrixWithAllocationPrice = - matrixWithAllocation.getOrThrow("matrixWithAllocation") - fun asTiered(): NewFloatingTieredPrice = tiered.getOrThrow("tiered") fun asBulk(): NewFloatingBulkPrice = bulk.getOrThrow("bulk") + fun asPackage(): NewFloatingPackagePrice = package_.getOrThrow("package_") + + fun asMatrix(): NewFloatingMatrixPrice = matrix.getOrThrow("matrix") + fun asThresholdTotalAmount(): NewFloatingThresholdTotalAmountPrice = thresholdTotalAmount.getOrThrow("thresholdTotalAmount") fun asTieredPackage(): NewFloatingTieredPackagePrice = tieredPackage.getOrThrow("tieredPackage") - fun asGroupedTiered(): NewFloatingGroupedTieredPrice = - groupedTiered.getOrThrow("groupedTiered") - - fun asMaxGroupTieredPackage(): NewFloatingMaxGroupTieredPackagePrice = - maxGroupTieredPackage.getOrThrow("maxGroupTieredPackage") - fun asTieredWithMinimum(): NewFloatingTieredWithMinimumPrice = tieredWithMinimum.getOrThrow("tieredWithMinimum") - fun asPackageWithAllocation(): NewFloatingPackageWithAllocationPrice = - packageWithAllocation.getOrThrow("packageWithAllocation") + fun asGroupedTiered(): NewFloatingGroupedTieredPrice = + groupedTiered.getOrThrow("groupedTiered") fun asTieredPackageWithMinimum(): NewFloatingTieredPackageWithMinimumPrice = tieredPackageWithMinimum.getOrThrow("tieredPackageWithMinimum") + fun asPackageWithAllocation(): NewFloatingPackageWithAllocationPrice = + packageWithAllocation.getOrThrow("packageWithAllocation") + fun asUnitWithPercent(): NewFloatingUnitWithPercentPrice = unitWithPercent.getOrThrow("unitWithPercent") + fun asMatrixWithAllocation(): NewFloatingMatrixWithAllocationPrice = + matrixWithAllocation.getOrThrow("matrixWithAllocation") + fun asTieredWithProration(): NewFloatingTieredWithProrationPrice = tieredWithProration.getOrThrow("tieredWithProration") @@ -3417,21 +3414,27 @@ private constructor( fun asGroupedAllocation(): NewFloatingGroupedAllocationPrice = groupedAllocation.getOrThrow("groupedAllocation") + fun asBulkWithProration(): NewFloatingBulkWithProrationPrice = + bulkWithProration.getOrThrow("bulkWithProration") + fun asGroupedWithProratedMinimum(): NewFloatingGroupedWithProratedMinimumPrice = groupedWithProratedMinimum.getOrThrow("groupedWithProratedMinimum") fun asGroupedWithMeteredMinimum(): NewFloatingGroupedWithMeteredMinimumPrice = groupedWithMeteredMinimum.getOrThrow("groupedWithMeteredMinimum") + fun asGroupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds = + groupedWithMinMaxThresholds.getOrThrow("groupedWithMinMaxThresholds") + fun asMatrixWithDisplayName(): NewFloatingMatrixWithDisplayNamePrice = matrixWithDisplayName.getOrThrow("matrixWithDisplayName") - fun asBulkWithProration(): NewFloatingBulkWithProrationPrice = - bulkWithProration.getOrThrow("bulkWithProration") - fun asGroupedTieredPackage(): NewFloatingGroupedTieredPackagePrice = groupedTieredPackage.getOrThrow("groupedTieredPackage") + fun asMaxGroupTieredPackage(): NewFloatingMaxGroupTieredPackagePrice = + maxGroupTieredPackage.getOrThrow("maxGroupTieredPackage") + fun asScalableMatrixWithUnitPricing(): NewFloatingScalableMatrixWithUnitPricingPrice = scalableMatrixWithUnitPricing.getOrThrow("scalableMatrixWithUnitPricing") @@ -3442,9 +3445,6 @@ private constructor( fun asCumulativeGroupedBulk(): NewFloatingCumulativeGroupedBulkPrice = cumulativeGroupedBulk.getOrThrow("cumulativeGroupedBulk") - fun asGroupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds = - groupedWithMinMaxThresholds.getOrThrow("groupedWithMinMaxThresholds") - fun asMinimum(): NewFloatingMinimumCompositePrice = minimum.getOrThrow("minimum") fun _json(): JsonValue? = _json @@ -3452,37 +3452,39 @@ private constructor( fun accept(visitor: Visitor): T = when { unit != null -> visitor.visitUnit(unit) - package_ != null -> visitor.visitPackage(package_) - matrix != null -> visitor.visitMatrix(matrix) - matrixWithAllocation != null -> - visitor.visitMatrixWithAllocation(matrixWithAllocation) tiered != null -> visitor.visitTiered(tiered) bulk != null -> visitor.visitBulk(bulk) + package_ != null -> visitor.visitPackage(package_) + matrix != null -> visitor.visitMatrix(matrix) thresholdTotalAmount != null -> visitor.visitThresholdTotalAmount(thresholdTotalAmount) tieredPackage != null -> visitor.visitTieredPackage(tieredPackage) - groupedTiered != null -> visitor.visitGroupedTiered(groupedTiered) - maxGroupTieredPackage != null -> - visitor.visitMaxGroupTieredPackage(maxGroupTieredPackage) tieredWithMinimum != null -> visitor.visitTieredWithMinimum(tieredWithMinimum) - packageWithAllocation != null -> - visitor.visitPackageWithAllocation(packageWithAllocation) + groupedTiered != null -> visitor.visitGroupedTiered(groupedTiered) tieredPackageWithMinimum != null -> visitor.visitTieredPackageWithMinimum(tieredPackageWithMinimum) + packageWithAllocation != null -> + visitor.visitPackageWithAllocation(packageWithAllocation) unitWithPercent != null -> visitor.visitUnitWithPercent(unitWithPercent) + matrixWithAllocation != null -> + visitor.visitMatrixWithAllocation(matrixWithAllocation) tieredWithProration != null -> visitor.visitTieredWithProration(tieredWithProration) unitWithProration != null -> visitor.visitUnitWithProration(unitWithProration) groupedAllocation != null -> visitor.visitGroupedAllocation(groupedAllocation) + bulkWithProration != null -> visitor.visitBulkWithProration(bulkWithProration) groupedWithProratedMinimum != null -> visitor.visitGroupedWithProratedMinimum(groupedWithProratedMinimum) groupedWithMeteredMinimum != null -> visitor.visitGroupedWithMeteredMinimum(groupedWithMeteredMinimum) + groupedWithMinMaxThresholds != null -> + visitor.visitGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds) matrixWithDisplayName != null -> visitor.visitMatrixWithDisplayName(matrixWithDisplayName) - bulkWithProration != null -> visitor.visitBulkWithProration(bulkWithProration) groupedTieredPackage != null -> visitor.visitGroupedTieredPackage(groupedTieredPackage) + maxGroupTieredPackage != null -> + visitor.visitMaxGroupTieredPackage(maxGroupTieredPackage) scalableMatrixWithUnitPricing != null -> visitor.visitScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing) scalableMatrixWithTieredPricing != null -> @@ -3491,8 +3493,6 @@ private constructor( ) cumulativeGroupedBulk != null -> visitor.visitCumulativeGroupedBulk(cumulativeGroupedBulk) - groupedWithMinMaxThresholds != null -> - visitor.visitGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds) minimum != null -> visitor.visitMinimum(minimum) else -> visitor.unknown(_json) } @@ -3510,20 +3510,6 @@ private constructor( unit.validate() } - override fun visitPackage(package_: NewFloatingPackagePrice) { - package_.validate() - } - - override fun visitMatrix(matrix: NewFloatingMatrixPrice) { - matrix.validate() - } - - override fun visitMatrixWithAllocation( - matrixWithAllocation: NewFloatingMatrixWithAllocationPrice - ) { - matrixWithAllocation.validate() - } - override fun visitTiered(tiered: NewFloatingTieredPrice) { tiered.validate() } @@ -3532,6 +3518,14 @@ private constructor( bulk.validate() } + override fun visitPackage(package_: NewFloatingPackagePrice) { + package_.validate() + } + + override fun visitMatrix(matrix: NewFloatingMatrixPrice) { + matrix.validate() + } + override fun visitThresholdTotalAmount( thresholdTotalAmount: NewFloatingThresholdTotalAmountPrice ) { @@ -3544,22 +3538,22 @@ private constructor( tieredPackage.validate() } + override fun visitTieredWithMinimum( + tieredWithMinimum: NewFloatingTieredWithMinimumPrice + ) { + tieredWithMinimum.validate() + } + override fun visitGroupedTiered( groupedTiered: NewFloatingGroupedTieredPrice ) { groupedTiered.validate() } - override fun visitMaxGroupTieredPackage( - maxGroupTieredPackage: NewFloatingMaxGroupTieredPackagePrice + override fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: NewFloatingTieredPackageWithMinimumPrice ) { - maxGroupTieredPackage.validate() - } - - override fun visitTieredWithMinimum( - tieredWithMinimum: NewFloatingTieredWithMinimumPrice - ) { - tieredWithMinimum.validate() + tieredPackageWithMinimum.validate() } override fun visitPackageWithAllocation( @@ -3568,18 +3562,18 @@ private constructor( packageWithAllocation.validate() } - override fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewFloatingTieredPackageWithMinimumPrice - ) { - tieredPackageWithMinimum.validate() - } - override fun visitUnitWithPercent( unitWithPercent: NewFloatingUnitWithPercentPrice ) { unitWithPercent.validate() } + override fun visitMatrixWithAllocation( + matrixWithAllocation: NewFloatingMatrixWithAllocationPrice + ) { + matrixWithAllocation.validate() + } + override fun visitTieredWithProration( tieredWithProration: NewFloatingTieredWithProrationPrice ) { @@ -3598,6 +3592,12 @@ private constructor( groupedAllocation.validate() } + override fun visitBulkWithProration( + bulkWithProration: NewFloatingBulkWithProrationPrice + ) { + bulkWithProration.validate() + } + override fun visitGroupedWithProratedMinimum( groupedWithProratedMinimum: NewFloatingGroupedWithProratedMinimumPrice ) { @@ -3610,16 +3610,16 @@ private constructor( groupedWithMeteredMinimum.validate() } - override fun visitMatrixWithDisplayName( - matrixWithDisplayName: NewFloatingMatrixWithDisplayNamePrice + override fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds ) { - matrixWithDisplayName.validate() + groupedWithMinMaxThresholds.validate() } - override fun visitBulkWithProration( - bulkWithProration: NewFloatingBulkWithProrationPrice + override fun visitMatrixWithDisplayName( + matrixWithDisplayName: NewFloatingMatrixWithDisplayNamePrice ) { - bulkWithProration.validate() + matrixWithDisplayName.validate() } override fun visitGroupedTieredPackage( @@ -3628,6 +3628,12 @@ private constructor( groupedTieredPackage.validate() } + override fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: NewFloatingMaxGroupTieredPackagePrice + ) { + maxGroupTieredPackage.validate() + } + override fun visitScalableMatrixWithUnitPricing( scalableMatrixWithUnitPricing: NewFloatingScalableMatrixWithUnitPricingPrice @@ -3648,12 +3654,6 @@ private constructor( cumulativeGroupedBulk.validate() } - override fun visitGroupedWithMinMaxThresholds( - groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds - ) { - groupedWithMinMaxThresholds.validate() - } - override fun visitMinimum(minimum: NewFloatingMinimumCompositePrice) { minimum.validate() } @@ -3681,19 +3681,15 @@ private constructor( object : Visitor { override fun visitUnit(unit: NewFloatingUnitPrice) = unit.validity() + override fun visitTiered(tiered: NewFloatingTieredPrice) = tiered.validity() + + override fun visitBulk(bulk: NewFloatingBulkPrice) = bulk.validity() + override fun visitPackage(package_: NewFloatingPackagePrice) = package_.validity() override fun visitMatrix(matrix: NewFloatingMatrixPrice) = matrix.validity() - override fun visitMatrixWithAllocation( - matrixWithAllocation: NewFloatingMatrixWithAllocationPrice - ) = matrixWithAllocation.validity() - - override fun visitTiered(tiered: NewFloatingTieredPrice) = tiered.validity() - - override fun visitBulk(bulk: NewFloatingBulkPrice) = bulk.validity() - override fun visitThresholdTotalAmount( thresholdTotalAmount: NewFloatingThresholdTotalAmountPrice ) = thresholdTotalAmount.validity() @@ -3702,30 +3698,30 @@ private constructor( tieredPackage: NewFloatingTieredPackagePrice ) = tieredPackage.validity() - override fun visitGroupedTiered( - groupedTiered: NewFloatingGroupedTieredPrice - ) = groupedTiered.validity() - - override fun visitMaxGroupTieredPackage( - maxGroupTieredPackage: NewFloatingMaxGroupTieredPackagePrice - ) = maxGroupTieredPackage.validity() - override fun visitTieredWithMinimum( tieredWithMinimum: NewFloatingTieredWithMinimumPrice ) = tieredWithMinimum.validity() - override fun visitPackageWithAllocation( - packageWithAllocation: NewFloatingPackageWithAllocationPrice - ) = packageWithAllocation.validity() + override fun visitGroupedTiered( + groupedTiered: NewFloatingGroupedTieredPrice + ) = groupedTiered.validity() override fun visitTieredPackageWithMinimum( tieredPackageWithMinimum: NewFloatingTieredPackageWithMinimumPrice ) = tieredPackageWithMinimum.validity() + override fun visitPackageWithAllocation( + packageWithAllocation: NewFloatingPackageWithAllocationPrice + ) = packageWithAllocation.validity() + override fun visitUnitWithPercent( unitWithPercent: NewFloatingUnitWithPercentPrice ) = unitWithPercent.validity() + override fun visitMatrixWithAllocation( + matrixWithAllocation: NewFloatingMatrixWithAllocationPrice + ) = matrixWithAllocation.validity() + override fun visitTieredWithProration( tieredWithProration: NewFloatingTieredWithProrationPrice ) = tieredWithProration.validity() @@ -3738,6 +3734,10 @@ private constructor( groupedAllocation: NewFloatingGroupedAllocationPrice ) = groupedAllocation.validity() + override fun visitBulkWithProration( + bulkWithProration: NewFloatingBulkWithProrationPrice + ) = bulkWithProration.validity() + override fun visitGroupedWithProratedMinimum( groupedWithProratedMinimum: NewFloatingGroupedWithProratedMinimumPrice ) = groupedWithProratedMinimum.validity() @@ -3746,18 +3746,22 @@ private constructor( groupedWithMeteredMinimum: NewFloatingGroupedWithMeteredMinimumPrice ) = groupedWithMeteredMinimum.validity() + override fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) = groupedWithMinMaxThresholds.validity() + override fun visitMatrixWithDisplayName( matrixWithDisplayName: NewFloatingMatrixWithDisplayNamePrice ) = matrixWithDisplayName.validity() - override fun visitBulkWithProration( - bulkWithProration: NewFloatingBulkWithProrationPrice - ) = bulkWithProration.validity() - override fun visitGroupedTieredPackage( groupedTieredPackage: NewFloatingGroupedTieredPackagePrice ) = groupedTieredPackage.validity() + override fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: NewFloatingMaxGroupTieredPackagePrice + ) = maxGroupTieredPackage.validity() + override fun visitScalableMatrixWithUnitPricing( scalableMatrixWithUnitPricing: NewFloatingScalableMatrixWithUnitPricingPrice @@ -3772,10 +3776,6 @@ private constructor( cumulativeGroupedBulk: NewFloatingCumulativeGroupedBulkPrice ) = cumulativeGroupedBulk.validity() - override fun visitGroupedWithMinMaxThresholds( - groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds - ) = groupedWithMinMaxThresholds.validity() - override fun visitMinimum(minimum: NewFloatingMinimumCompositePrice) = minimum.validity() @@ -3790,106 +3790,106 @@ private constructor( return other is Price && unit == other.unit && - package_ == other.package_ && - matrix == other.matrix && - matrixWithAllocation == other.matrixWithAllocation && tiered == other.tiered && bulk == other.bulk && + package_ == other.package_ && + matrix == other.matrix && thresholdTotalAmount == other.thresholdTotalAmount && tieredPackage == other.tieredPackage && - groupedTiered == other.groupedTiered && - maxGroupTieredPackage == other.maxGroupTieredPackage && tieredWithMinimum == other.tieredWithMinimum && - packageWithAllocation == other.packageWithAllocation && + groupedTiered == other.groupedTiered && tieredPackageWithMinimum == other.tieredPackageWithMinimum && + packageWithAllocation == other.packageWithAllocation && unitWithPercent == other.unitWithPercent && + matrixWithAllocation == other.matrixWithAllocation && tieredWithProration == other.tieredWithProration && unitWithProration == other.unitWithProration && groupedAllocation == other.groupedAllocation && + bulkWithProration == other.bulkWithProration && groupedWithProratedMinimum == other.groupedWithProratedMinimum && groupedWithMeteredMinimum == other.groupedWithMeteredMinimum && + groupedWithMinMaxThresholds == other.groupedWithMinMaxThresholds && matrixWithDisplayName == other.matrixWithDisplayName && - bulkWithProration == other.bulkWithProration && groupedTieredPackage == other.groupedTieredPackage && + maxGroupTieredPackage == other.maxGroupTieredPackage && scalableMatrixWithUnitPricing == other.scalableMatrixWithUnitPricing && scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && cumulativeGroupedBulk == other.cumulativeGroupedBulk && - groupedWithMinMaxThresholds == other.groupedWithMinMaxThresholds && minimum == other.minimum } override fun hashCode(): Int = Objects.hash( unit, - package_, - matrix, - matrixWithAllocation, tiered, bulk, + package_, + matrix, thresholdTotalAmount, tieredPackage, - groupedTiered, - maxGroupTieredPackage, tieredWithMinimum, - packageWithAllocation, + groupedTiered, tieredPackageWithMinimum, + packageWithAllocation, unitWithPercent, + matrixWithAllocation, tieredWithProration, unitWithProration, groupedAllocation, + bulkWithProration, groupedWithProratedMinimum, groupedWithMeteredMinimum, + groupedWithMinMaxThresholds, matrixWithDisplayName, - bulkWithProration, groupedTieredPackage, + maxGroupTieredPackage, scalableMatrixWithUnitPricing, scalableMatrixWithTieredPricing, cumulativeGroupedBulk, - groupedWithMinMaxThresholds, minimum, ) override fun toString(): String = when { unit != null -> "Price{unit=$unit}" - package_ != null -> "Price{package_=$package_}" - matrix != null -> "Price{matrix=$matrix}" - matrixWithAllocation != null -> - "Price{matrixWithAllocation=$matrixWithAllocation}" tiered != null -> "Price{tiered=$tiered}" bulk != null -> "Price{bulk=$bulk}" + package_ != null -> "Price{package_=$package_}" + matrix != null -> "Price{matrix=$matrix}" thresholdTotalAmount != null -> "Price{thresholdTotalAmount=$thresholdTotalAmount}" tieredPackage != null -> "Price{tieredPackage=$tieredPackage}" - groupedTiered != null -> "Price{groupedTiered=$groupedTiered}" - maxGroupTieredPackage != null -> - "Price{maxGroupTieredPackage=$maxGroupTieredPackage}" tieredWithMinimum != null -> "Price{tieredWithMinimum=$tieredWithMinimum}" - packageWithAllocation != null -> - "Price{packageWithAllocation=$packageWithAllocation}" + groupedTiered != null -> "Price{groupedTiered=$groupedTiered}" tieredPackageWithMinimum != null -> "Price{tieredPackageWithMinimum=$tieredPackageWithMinimum}" + packageWithAllocation != null -> + "Price{packageWithAllocation=$packageWithAllocation}" unitWithPercent != null -> "Price{unitWithPercent=$unitWithPercent}" + matrixWithAllocation != null -> + "Price{matrixWithAllocation=$matrixWithAllocation}" tieredWithProration != null -> "Price{tieredWithProration=$tieredWithProration}" unitWithProration != null -> "Price{unitWithProration=$unitWithProration}" groupedAllocation != null -> "Price{groupedAllocation=$groupedAllocation}" + bulkWithProration != null -> "Price{bulkWithProration=$bulkWithProration}" groupedWithProratedMinimum != null -> "Price{groupedWithProratedMinimum=$groupedWithProratedMinimum}" groupedWithMeteredMinimum != null -> "Price{groupedWithMeteredMinimum=$groupedWithMeteredMinimum}" + groupedWithMinMaxThresholds != null -> + "Price{groupedWithMinMaxThresholds=$groupedWithMinMaxThresholds}" matrixWithDisplayName != null -> "Price{matrixWithDisplayName=$matrixWithDisplayName}" - bulkWithProration != null -> "Price{bulkWithProration=$bulkWithProration}" groupedTieredPackage != null -> "Price{groupedTieredPackage=$groupedTieredPackage}" + maxGroupTieredPackage != null -> + "Price{maxGroupTieredPackage=$maxGroupTieredPackage}" scalableMatrixWithUnitPricing != null -> "Price{scalableMatrixWithUnitPricing=$scalableMatrixWithUnitPricing}" scalableMatrixWithTieredPricing != null -> "Price{scalableMatrixWithTieredPricing=$scalableMatrixWithTieredPricing}" cumulativeGroupedBulk != null -> "Price{cumulativeGroupedBulk=$cumulativeGroupedBulk}" - groupedWithMinMaxThresholds != null -> - "Price{groupedWithMinMaxThresholds=$groupedWithMinMaxThresholds}" minimum != null -> "Price{minimum=$minimum}" _json != null -> "Price{_unknown=$_json}" else -> throw IllegalStateException("Invalid Price") @@ -3899,18 +3899,14 @@ private constructor( fun ofUnit(unit: NewFloatingUnitPrice) = Price(unit = unit) - fun ofPackage(package_: NewFloatingPackagePrice) = Price(package_ = package_) - - fun ofMatrix(matrix: NewFloatingMatrixPrice) = Price(matrix = matrix) - - fun ofMatrixWithAllocation( - matrixWithAllocation: NewFloatingMatrixWithAllocationPrice - ) = Price(matrixWithAllocation = matrixWithAllocation) - fun ofTiered(tiered: NewFloatingTieredPrice) = Price(tiered = tiered) fun ofBulk(bulk: NewFloatingBulkPrice) = Price(bulk = bulk) + fun ofPackage(package_: NewFloatingPackagePrice) = Price(package_ = package_) + + fun ofMatrix(matrix: NewFloatingMatrixPrice) = Price(matrix = matrix) + fun ofThresholdTotalAmount( thresholdTotalAmount: NewFloatingThresholdTotalAmountPrice ) = Price(thresholdTotalAmount = thresholdTotalAmount) @@ -3918,27 +3914,27 @@ private constructor( fun ofTieredPackage(tieredPackage: NewFloatingTieredPackagePrice) = Price(tieredPackage = tieredPackage) - fun ofGroupedTiered(groupedTiered: NewFloatingGroupedTieredPrice) = - Price(groupedTiered = groupedTiered) - - fun ofMaxGroupTieredPackage( - maxGroupTieredPackage: NewFloatingMaxGroupTieredPackagePrice - ) = Price(maxGroupTieredPackage = maxGroupTieredPackage) - fun ofTieredWithMinimum(tieredWithMinimum: NewFloatingTieredWithMinimumPrice) = Price(tieredWithMinimum = tieredWithMinimum) - fun ofPackageWithAllocation( - packageWithAllocation: NewFloatingPackageWithAllocationPrice - ) = Price(packageWithAllocation = packageWithAllocation) + fun ofGroupedTiered(groupedTiered: NewFloatingGroupedTieredPrice) = + Price(groupedTiered = groupedTiered) fun ofTieredPackageWithMinimum( tieredPackageWithMinimum: NewFloatingTieredPackageWithMinimumPrice ) = Price(tieredPackageWithMinimum = tieredPackageWithMinimum) + fun ofPackageWithAllocation( + packageWithAllocation: NewFloatingPackageWithAllocationPrice + ) = Price(packageWithAllocation = packageWithAllocation) + fun ofUnitWithPercent(unitWithPercent: NewFloatingUnitWithPercentPrice) = Price(unitWithPercent = unitWithPercent) + fun ofMatrixWithAllocation( + matrixWithAllocation: NewFloatingMatrixWithAllocationPrice + ) = Price(matrixWithAllocation = matrixWithAllocation) + fun ofTieredWithProration( tieredWithProration: NewFloatingTieredWithProrationPrice ) = Price(tieredWithProration = tieredWithProration) @@ -3949,6 +3945,9 @@ private constructor( fun ofGroupedAllocation(groupedAllocation: NewFloatingGroupedAllocationPrice) = Price(groupedAllocation = groupedAllocation) + fun ofBulkWithProration(bulkWithProration: NewFloatingBulkWithProrationPrice) = + Price(bulkWithProration = bulkWithProration) + fun ofGroupedWithProratedMinimum( groupedWithProratedMinimum: NewFloatingGroupedWithProratedMinimumPrice ) = Price(groupedWithProratedMinimum = groupedWithProratedMinimum) @@ -3957,17 +3956,22 @@ private constructor( groupedWithMeteredMinimum: NewFloatingGroupedWithMeteredMinimumPrice ) = Price(groupedWithMeteredMinimum = groupedWithMeteredMinimum) + fun ofGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) = Price(groupedWithMinMaxThresholds = groupedWithMinMaxThresholds) + fun ofMatrixWithDisplayName( matrixWithDisplayName: NewFloatingMatrixWithDisplayNamePrice ) = Price(matrixWithDisplayName = matrixWithDisplayName) - fun ofBulkWithProration(bulkWithProration: NewFloatingBulkWithProrationPrice) = - Price(bulkWithProration = bulkWithProration) - fun ofGroupedTieredPackage( groupedTieredPackage: NewFloatingGroupedTieredPackagePrice ) = Price(groupedTieredPackage = groupedTieredPackage) + fun ofMaxGroupTieredPackage( + maxGroupTieredPackage: NewFloatingMaxGroupTieredPackagePrice + ) = Price(maxGroupTieredPackage = maxGroupTieredPackage) + fun ofScalableMatrixWithUnitPricing( scalableMatrixWithUnitPricing: NewFloatingScalableMatrixWithUnitPricingPrice ) = Price(scalableMatrixWithUnitPricing = scalableMatrixWithUnitPricing) @@ -3980,10 +3984,6 @@ private constructor( cumulativeGroupedBulk: NewFloatingCumulativeGroupedBulkPrice ) = Price(cumulativeGroupedBulk = cumulativeGroupedBulk) - fun ofGroupedWithMinMaxThresholds( - groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds - ) = Price(groupedWithMinMaxThresholds = groupedWithMinMaxThresholds) - fun ofMinimum(minimum: NewFloatingMinimumCompositePrice) = Price(minimum = minimum) } @@ -3994,42 +3994,38 @@ private constructor( fun visitUnit(unit: NewFloatingUnitPrice): T - fun visitPackage(package_: NewFloatingPackagePrice): T - - fun visitMatrix(matrix: NewFloatingMatrixPrice): T - - fun visitMatrixWithAllocation( - matrixWithAllocation: NewFloatingMatrixWithAllocationPrice - ): T - fun visitTiered(tiered: NewFloatingTieredPrice): T fun visitBulk(bulk: NewFloatingBulkPrice): T + fun visitPackage(package_: NewFloatingPackagePrice): T + + fun visitMatrix(matrix: NewFloatingMatrixPrice): T + fun visitThresholdTotalAmount( thresholdTotalAmount: NewFloatingThresholdTotalAmountPrice ): T fun visitTieredPackage(tieredPackage: NewFloatingTieredPackagePrice): T + fun visitTieredWithMinimum(tieredWithMinimum: NewFloatingTieredWithMinimumPrice): T + fun visitGroupedTiered(groupedTiered: NewFloatingGroupedTieredPrice): T - fun visitMaxGroupTieredPackage( - maxGroupTieredPackage: NewFloatingMaxGroupTieredPackagePrice + fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: NewFloatingTieredPackageWithMinimumPrice ): T - fun visitTieredWithMinimum(tieredWithMinimum: NewFloatingTieredWithMinimumPrice): T - fun visitPackageWithAllocation( packageWithAllocation: NewFloatingPackageWithAllocationPrice ): T - fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewFloatingTieredPackageWithMinimumPrice - ): T - fun visitUnitWithPercent(unitWithPercent: NewFloatingUnitWithPercentPrice): T + fun visitMatrixWithAllocation( + matrixWithAllocation: NewFloatingMatrixWithAllocationPrice + ): T + fun visitTieredWithProration( tieredWithProration: NewFloatingTieredWithProrationPrice ): T @@ -4038,6 +4034,8 @@ private constructor( fun visitGroupedAllocation(groupedAllocation: NewFloatingGroupedAllocationPrice): T + fun visitBulkWithProration(bulkWithProration: NewFloatingBulkWithProrationPrice): T + fun visitGroupedWithProratedMinimum( groupedWithProratedMinimum: NewFloatingGroupedWithProratedMinimumPrice ): T @@ -4046,16 +4044,22 @@ private constructor( groupedWithMeteredMinimum: NewFloatingGroupedWithMeteredMinimumPrice ): T + fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ): T + fun visitMatrixWithDisplayName( matrixWithDisplayName: NewFloatingMatrixWithDisplayNamePrice ): T - fun visitBulkWithProration(bulkWithProration: NewFloatingBulkWithProrationPrice): T - fun visitGroupedTieredPackage( groupedTieredPackage: NewFloatingGroupedTieredPackagePrice ): T + fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: NewFloatingMaxGroupTieredPackagePrice + ): T + fun visitScalableMatrixWithUnitPricing( scalableMatrixWithUnitPricing: NewFloatingScalableMatrixWithUnitPricingPrice ): T @@ -4068,10 +4072,6 @@ private constructor( cumulativeGroupedBulk: NewFloatingCumulativeGroupedBulkPrice ): T - fun visitGroupedWithMinMaxThresholds( - groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds - ): T - fun visitMinimum(minimum: NewFloatingMinimumCompositePrice): T /** @@ -4100,22 +4100,6 @@ private constructor( return tryDeserialize(node, jacksonTypeRef()) ?.let { Price(unit = it, _json = json) } ?: Price(_json = json) } - "package" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(package_ = it, _json = json) } ?: Price(_json = json) - } - "matrix" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(matrix = it, _json = json) } ?: Price(_json = json) - } - "matrix_with_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(matrixWithAllocation = it, _json = json) } - ?: Price(_json = json) - } "tiered" -> { return tryDeserialize(node, jacksonTypeRef()) ?.let { Price(tiered = it, _json = json) } ?: Price(_json = json) @@ -4124,6 +4108,14 @@ private constructor( return tryDeserialize(node, jacksonTypeRef()) ?.let { Price(bulk = it, _json = json) } ?: Price(_json = json) } + "package" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(package_ = it, _json = json) } ?: Price(_json = json) + } + "matrix" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(matrix = it, _json = json) } ?: Price(_json = json) + } "threshold_total_amount" -> { return tryDeserialize( node, @@ -4140,28 +4132,28 @@ private constructor( ?.let { Price(tieredPackage = it, _json = json) } ?: Price(_json = json) } - "grouped_tiered" -> { + "tiered_with_minimum" -> { return tryDeserialize( node, - jacksonTypeRef(), + jacksonTypeRef(), ) - ?.let { Price(groupedTiered = it, _json = json) } + ?.let { Price(tieredWithMinimum = it, _json = json) } ?: Price(_json = json) } - "max_group_tiered_package" -> { + "grouped_tiered" -> { return tryDeserialize( node, - jacksonTypeRef(), + jacksonTypeRef(), ) - ?.let { Price(maxGroupTieredPackage = it, _json = json) } + ?.let { Price(groupedTiered = it, _json = json) } ?: Price(_json = json) } - "tiered_with_minimum" -> { + "tiered_package_with_minimum" -> { return tryDeserialize( node, - jacksonTypeRef(), + jacksonTypeRef(), ) - ?.let { Price(tieredWithMinimum = it, _json = json) } + ?.let { Price(tieredPackageWithMinimum = it, _json = json) } ?: Price(_json = json) } "package_with_allocation" -> { @@ -4172,20 +4164,20 @@ private constructor( ?.let { Price(packageWithAllocation = it, _json = json) } ?: Price(_json = json) } - "tiered_package_with_minimum" -> { + "unit_with_percent" -> { return tryDeserialize( node, - jacksonTypeRef(), + jacksonTypeRef(), ) - ?.let { Price(tieredPackageWithMinimum = it, _json = json) } + ?.let { Price(unitWithPercent = it, _json = json) } ?: Price(_json = json) } - "unit_with_percent" -> { + "matrix_with_allocation" -> { return tryDeserialize( node, - jacksonTypeRef(), + jacksonTypeRef(), ) - ?.let { Price(unitWithPercent = it, _json = json) } + ?.let { Price(matrixWithAllocation = it, _json = json) } ?: Price(_json = json) } "tiered_with_proration" -> { @@ -4212,6 +4204,14 @@ private constructor( ?.let { Price(groupedAllocation = it, _json = json) } ?: Price(_json = json) } + "bulk_with_proration" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(bulkWithProration = it, _json = json) } + ?: Price(_json = json) + } "grouped_with_prorated_minimum" -> { return tryDeserialize( node, @@ -4228,20 +4228,20 @@ private constructor( ?.let { Price(groupedWithMeteredMinimum = it, _json = json) } ?: Price(_json = json) } - "matrix_with_display_name" -> { + "grouped_with_min_max_thresholds" -> { return tryDeserialize( node, - jacksonTypeRef(), + jacksonTypeRef(), ) - ?.let { Price(matrixWithDisplayName = it, _json = json) } + ?.let { Price(groupedWithMinMaxThresholds = it, _json = json) } ?: Price(_json = json) } - "bulk_with_proration" -> { + "matrix_with_display_name" -> { return tryDeserialize( node, - jacksonTypeRef(), + jacksonTypeRef(), ) - ?.let { Price(bulkWithProration = it, _json = json) } + ?.let { Price(matrixWithDisplayName = it, _json = json) } ?: Price(_json = json) } "grouped_tiered_package" -> { @@ -4252,6 +4252,14 @@ private constructor( ?.let { Price(groupedTieredPackage = it, _json = json) } ?: Price(_json = json) } + "max_group_tiered_package" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(maxGroupTieredPackage = it, _json = json) } + ?: Price(_json = json) + } "scalable_matrix_with_unit_pricing" -> { return tryDeserialize( node, @@ -4278,14 +4286,6 @@ private constructor( ?.let { Price(cumulativeGroupedBulk = it, _json = json) } ?: Price(_json = json) } - "grouped_with_min_max_thresholds" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedWithMinMaxThresholds = it, _json = json) } - ?: Price(_json = json) - } "minimum" -> { return tryDeserialize( node, @@ -4308,50 +4308,50 @@ private constructor( ) { when { value.unit != null -> generator.writeObject(value.unit) - value.package_ != null -> generator.writeObject(value.package_) - value.matrix != null -> generator.writeObject(value.matrix) - value.matrixWithAllocation != null -> - generator.writeObject(value.matrixWithAllocation) value.tiered != null -> generator.writeObject(value.tiered) value.bulk != null -> generator.writeObject(value.bulk) + value.package_ != null -> generator.writeObject(value.package_) + value.matrix != null -> generator.writeObject(value.matrix) value.thresholdTotalAmount != null -> generator.writeObject(value.thresholdTotalAmount) value.tieredPackage != null -> generator.writeObject(value.tieredPackage) - value.groupedTiered != null -> generator.writeObject(value.groupedTiered) - value.maxGroupTieredPackage != null -> - generator.writeObject(value.maxGroupTieredPackage) value.tieredWithMinimum != null -> generator.writeObject(value.tieredWithMinimum) - value.packageWithAllocation != null -> - generator.writeObject(value.packageWithAllocation) + value.groupedTiered != null -> generator.writeObject(value.groupedTiered) value.tieredPackageWithMinimum != null -> generator.writeObject(value.tieredPackageWithMinimum) + value.packageWithAllocation != null -> + generator.writeObject(value.packageWithAllocation) value.unitWithPercent != null -> generator.writeObject(value.unitWithPercent) + value.matrixWithAllocation != null -> + generator.writeObject(value.matrixWithAllocation) value.tieredWithProration != null -> generator.writeObject(value.tieredWithProration) value.unitWithProration != null -> generator.writeObject(value.unitWithProration) value.groupedAllocation != null -> generator.writeObject(value.groupedAllocation) + value.bulkWithProration != null -> + generator.writeObject(value.bulkWithProration) value.groupedWithProratedMinimum != null -> generator.writeObject(value.groupedWithProratedMinimum) value.groupedWithMeteredMinimum != null -> generator.writeObject(value.groupedWithMeteredMinimum) + value.groupedWithMinMaxThresholds != null -> + generator.writeObject(value.groupedWithMinMaxThresholds) value.matrixWithDisplayName != null -> generator.writeObject(value.matrixWithDisplayName) - value.bulkWithProration != null -> - generator.writeObject(value.bulkWithProration) value.groupedTieredPackage != null -> generator.writeObject(value.groupedTieredPackage) + value.maxGroupTieredPackage != null -> + generator.writeObject(value.maxGroupTieredPackage) value.scalableMatrixWithUnitPricing != null -> generator.writeObject(value.scalableMatrixWithUnitPricing) value.scalableMatrixWithTieredPricing != null -> generator.writeObject(value.scalableMatrixWithTieredPricing) value.cumulativeGroupedBulk != null -> generator.writeObject(value.cumulativeGroupedBulk) - value.groupedWithMinMaxThresholds != null -> - generator.writeObject(value.groupedWithMinMaxThresholds) value.minimum != null -> generator.writeObject(value.minimum) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid Price") @@ -4481,6 +4481,8 @@ private constructor( fun currency(): String = currency.getRequired("currency") /** + * Configuration for grouped_with_min_max_thresholds pricing + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected * value). @@ -4500,6 +4502,8 @@ private constructor( fun itemId(): String = itemId.getRequired("item_id") /** + * The pricing model type + * * Expected to always return the following: * ```kotlin * JsonValue.from("grouped_with_min_max_thresholds") @@ -4892,6 +4896,7 @@ private constructor( */ fun currency(currency: JsonField) = apply { this.currency = currency } + /** Configuration for grouped_with_min_max_thresholds pricing */ fun groupedWithMinMaxThresholdsConfig( groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig ) = @@ -5512,16 +5517,117 @@ private constructor( override fun toString() = value.toString() } + /** Configuration for grouped_with_min_max_thresholds pricing */ class GroupedWithMinMaxThresholdsConfig - @JsonCreator private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map + private val groupingKey: JsonField, + private val maximumCharge: JsonField, + private val minimumCharge: JsonField, + private val perUnitRate: JsonField, + private val additionalProperties: MutableMap, ) { + @JsonCreator + private constructor( + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("maximum_charge") + @ExcludeMissing + maximumCharge: JsonField = JsonMissing.of(), + @JsonProperty("minimum_charge") + @ExcludeMissing + minimumCharge: JsonField = JsonMissing.of(), + @JsonProperty("per_unit_rate") + @ExcludeMissing + perUnitRate: JsonField = JsonMissing.of(), + ) : this(groupingKey, maximumCharge, minimumCharge, perUnitRate, mutableMapOf()) + + /** + * The event property used to group before applying thresholds + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The maximum amount to charge each group + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun maximumCharge(): String = maximumCharge.getRequired("maximum_charge") + + /** + * The minimum amount to charge each group, regardless of usage + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun minimumCharge(): String = minimumCharge.getRequired("minimum_charge") + + /** + * The base price charged per group + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun perUnitRate(): String = perUnitRate.getRequired("per_unit_rate") + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [maximumCharge]. + * + * Unlike [maximumCharge], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("maximum_charge") + @ExcludeMissing + fun _maximumCharge(): JsonField = maximumCharge + + /** + * Returns the raw JSON value of [minimumCharge]. + * + * Unlike [minimumCharge], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("minimum_charge") + @ExcludeMissing + fun _minimumCharge(): JsonField = minimumCharge + + /** + * Returns the raw JSON value of [perUnitRate]. + * + * Unlike [perUnitRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("per_unit_rate") + @ExcludeMissing + fun _perUnitRate(): JsonField = perUnitRate + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) fun toBuilder() = Builder().from(this) @@ -5530,6 +5636,14 @@ private constructor( /** * Returns a mutable builder for constructing an instance of * [GroupedWithMinMaxThresholdsConfig]. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .maximumCharge() + * .minimumCharge() + * .perUnitRate() + * ``` */ fun builder() = Builder() } @@ -5537,17 +5651,85 @@ private constructor( /** A builder for [GroupedWithMinMaxThresholdsConfig]. */ class Builder internal constructor() { + private var groupingKey: JsonField? = null + private var maximumCharge: JsonField? = null + private var minimumCharge: JsonField? = null + private var perUnitRate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from( groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig ) = apply { + groupingKey = groupedWithMinMaxThresholdsConfig.groupingKey + maximumCharge = groupedWithMinMaxThresholdsConfig.maximumCharge + minimumCharge = groupedWithMinMaxThresholdsConfig.minimumCharge + perUnitRate = groupedWithMinMaxThresholdsConfig.perUnitRate additionalProperties = groupedWithMinMaxThresholdsConfig.additionalProperties .toMutableMap() } + /** The event property used to group before applying thresholds */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The maximum amount to charge each group */ + fun maximumCharge(maximumCharge: String) = + maximumCharge(JsonField.of(maximumCharge)) + + /** + * Sets [Builder.maximumCharge] to an arbitrary JSON value. + * + * You should usually call [Builder.maximumCharge] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun maximumCharge(maximumCharge: JsonField) = apply { + this.maximumCharge = maximumCharge + } + + /** The minimum amount to charge each group, regardless of usage */ + fun minimumCharge(minimumCharge: String) = + minimumCharge(JsonField.of(minimumCharge)) + + /** + * Sets [Builder.minimumCharge] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumCharge] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun minimumCharge(minimumCharge: JsonField) = apply { + this.minimumCharge = minimumCharge + } + + /** The base price charged per group */ + fun perUnitRate(perUnitRate: String) = + perUnitRate(JsonField.of(perUnitRate)) + + /** + * Sets [Builder.perUnitRate] to an arbitrary JSON value. + * + * You should usually call [Builder.perUnitRate] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun perUnitRate(perUnitRate: JsonField) = apply { + this.perUnitRate = perUnitRate + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -5574,9 +5756,25 @@ private constructor( * Returns an immutable instance of [GroupedWithMinMaxThresholdsConfig]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .maximumCharge() + * .minimumCharge() + * .perUnitRate() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ fun build(): GroupedWithMinMaxThresholdsConfig = - GroupedWithMinMaxThresholdsConfig(additionalProperties.toImmutable()) + GroupedWithMinMaxThresholdsConfig( + checkRequired("groupingKey", groupingKey), + checkRequired("maximumCharge", maximumCharge), + checkRequired("minimumCharge", minimumCharge), + checkRequired("perUnitRate", perUnitRate), + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false @@ -5586,6 +5784,10 @@ private constructor( return@apply } + groupingKey() + maximumCharge() + minimumCharge() + perUnitRate() validated = true } @@ -5604,9 +5806,10 @@ private constructor( * Used for best match union deserialization. */ internal fun validity(): Int = - additionalProperties.count { (_, value) -> - !value.isNull() && !value.isMissing() - } + (if (groupingKey.asKnown() == null) 0 else 1) + + (if (maximumCharge.asKnown() == null) 0 else 1) + + (if (minimumCharge.asKnown() == null) 0 else 1) + + (if (perUnitRate.asKnown() == null) 0 else 1) override fun equals(other: Any?): Boolean { if (this === other) { @@ -5614,15 +5817,27 @@ private constructor( } return other is GroupedWithMinMaxThresholdsConfig && + groupingKey == other.groupingKey && + maximumCharge == other.maximumCharge && + minimumCharge == other.minimumCharge && + perUnitRate == other.perUnitRate && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + private val hashCode: Int by lazy { + Objects.hash( + groupingKey, + maximumCharge, + minimumCharge, + perUnitRate, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode override fun toString() = - "GroupedWithMinMaxThresholdsConfig{additionalProperties=$additionalProperties}" + "GroupedWithMinMaxThresholdsConfig{groupingKey=$groupingKey, maximumCharge=$maximumCharge, minimumCharge=$minimumCharge, perUnitRate=$perUnitRate, additionalProperties=$additionalProperties}" } /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionSchedulePlanChangeParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionSchedulePlanChangeParams.kt index 04a768f6b..e1d112ccb 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionSchedulePlanChangeParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionSchedulePlanChangeParams.kt @@ -3896,7 +3896,7 @@ private constructor( fun planPhaseOrder(): Long? = planPhaseOrder.getNullable("plan_phase_order") /** - * The definition of a new price to create and add to the subscription. + * New subscription price request body params. * * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -4201,7 +4201,7 @@ private constructor( this.planPhaseOrder = planPhaseOrder } - /** The definition of a new price to create and add to the subscription. */ + /** New subscription price request body params. */ fun price(price: Price?) = price(JsonField.ofNullable(price)) /** @@ -4216,18 +4216,18 @@ private constructor( /** Alias for calling [price] with `Price.ofUnit(unit)`. */ fun price(unit: NewSubscriptionUnitPrice) = price(Price.ofUnit(unit)) - /** Alias for calling [price] with `Price.ofPackage(package_)`. */ - fun price(package_: NewSubscriptionPackagePrice) = price(Price.ofPackage(package_)) - - /** Alias for calling [price] with `Price.ofMatrix(matrix)`. */ - fun price(matrix: NewSubscriptionMatrixPrice) = price(Price.ofMatrix(matrix)) - /** Alias for calling [price] with `Price.ofTiered(tiered)`. */ fun price(tiered: NewSubscriptionTieredPrice) = price(Price.ofTiered(tiered)) /** Alias for calling [price] with `Price.ofBulk(bulk)`. */ fun price(bulk: NewSubscriptionBulkPrice) = price(Price.ofBulk(bulk)) + /** Alias for calling [price] with `Price.ofPackage(package_)`. */ + fun price(package_: NewSubscriptionPackagePrice) = price(Price.ofPackage(package_)) + + /** Alias for calling [price] with `Price.ofMatrix(matrix)`. */ + fun price(matrix: NewSubscriptionMatrixPrice) = price(Price.ofMatrix(matrix)) + /** * Alias for calling [price] with `Price.ofThresholdTotalAmount(thresholdTotalAmount)`. */ @@ -4242,9 +4242,16 @@ private constructor( fun price(tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice) = price(Price.ofTieredWithMinimum(tieredWithMinimum)) - /** Alias for calling [price] with `Price.ofUnitWithPercent(unitWithPercent)`. */ - fun price(unitWithPercent: NewSubscriptionUnitWithPercentPrice) = - price(Price.ofUnitWithPercent(unitWithPercent)) + /** Alias for calling [price] with `Price.ofGroupedTiered(groupedTiered)`. */ + fun price(groupedTiered: NewSubscriptionGroupedTieredPrice) = + price(Price.ofGroupedTiered(groupedTiered)) + + /** + * Alias for calling [price] with + * `Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)`. + */ + fun price(tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice) = + price(Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)) /** * Alias for calling [price] with @@ -4253,10 +4260,20 @@ private constructor( fun price(packageWithAllocation: NewSubscriptionPackageWithAllocationPrice) = price(Price.ofPackageWithAllocation(packageWithAllocation)) + /** Alias for calling [price] with `Price.ofUnitWithPercent(unitWithPercent)`. */ + fun price(unitWithPercent: NewSubscriptionUnitWithPercentPrice) = + price(Price.ofUnitWithPercent(unitWithPercent)) + + /** + * Alias for calling [price] with `Price.ofMatrixWithAllocation(matrixWithAllocation)`. + */ + fun price(matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice) = + price(Price.ofMatrixWithAllocation(matrixWithAllocation)) + /** * Alias for calling [price] with `Price.ofTieredWithProration(tieredWithProration)`. */ - fun price(tieredWithProration: NewSubscriptionTierWithProrationPrice) = + fun price(tieredWithProration: Price.TieredWithProration) = price(Price.ofTieredWithProration(tieredWithProration)) /** Alias for calling [price] with `Price.ofUnitWithProration(unitWithProration)`. */ @@ -4267,53 +4284,30 @@ private constructor( fun price(groupedAllocation: NewSubscriptionGroupedAllocationPrice) = price(Price.ofGroupedAllocation(groupedAllocation)) - /** - * Alias for calling [price] with - * `Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)`. - */ - fun price(groupedWithProratedMinimum: NewSubscriptionGroupedWithProratedMinimumPrice) = - price(Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)) - /** Alias for calling [price] with `Price.ofBulkWithProration(bulkWithProration)`. */ fun price(bulkWithProration: NewSubscriptionBulkWithProrationPrice) = price(Price.ofBulkWithProration(bulkWithProration)) /** * Alias for calling [price] with - * `Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)`. - */ - fun price( - scalableMatrixWithUnitPricing: NewSubscriptionScalableMatrixWithUnitPricingPrice - ) = price(Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)) - - /** - * Alias for calling [price] with - * `Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)`. - */ - fun price( - scalableMatrixWithTieredPricing: NewSubscriptionScalableMatrixWithTieredPricingPrice - ) = price(Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)) - - /** - * Alias for calling [price] with - * `Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)`. + * `Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)`. */ - fun price(cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice) = - price(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) + fun price(groupedWithProratedMinimum: NewSubscriptionGroupedWithProratedMinimumPrice) = + price(Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)) /** * Alias for calling [price] with - * `Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)`. + * `Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)`. */ - fun price(maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice) = - price(Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)) + fun price(groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice) = + price(Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)) /** * Alias for calling [price] with - * `Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)`. + * `Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)`. */ - fun price(groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice) = - price(Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)) + fun price(groupedWithMinMaxThresholds: Price.GroupedWithMinMaxThresholds) = + price(Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)) /** * Alias for calling [price] with @@ -4329,28 +4323,34 @@ private constructor( price(Price.ofGroupedTieredPackage(groupedTieredPackage)) /** - * Alias for calling [price] with `Price.ofMatrixWithAllocation(matrixWithAllocation)`. + * Alias for calling [price] with + * `Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)`. */ - fun price(matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice) = - price(Price.ofMatrixWithAllocation(matrixWithAllocation)) + fun price(maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice) = + price(Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)) /** * Alias for calling [price] with - * `Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)`. + * `Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)`. */ - fun price(tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice) = - price(Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)) + fun price( + scalableMatrixWithUnitPricing: NewSubscriptionScalableMatrixWithUnitPricingPrice + ) = price(Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)) - /** Alias for calling [price] with `Price.ofGroupedTiered(groupedTiered)`. */ - fun price(groupedTiered: NewSubscriptionGroupedTieredPrice) = - price(Price.ofGroupedTiered(groupedTiered)) + /** + * Alias for calling [price] with + * `Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)`. + */ + fun price( + scalableMatrixWithTieredPricing: NewSubscriptionScalableMatrixWithTieredPricingPrice + ) = price(Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)) /** * Alias for calling [price] with - * `Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)`. + * `Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)`. */ - fun price(groupedWithMinMaxThresholds: Price.GroupedWithMinMaxThresholds) = - price(Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)) + fun price(cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice) = + price(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) /** Alias for calling [price] with `Price.ofMinimum(minimum)`. */ fun price(minimum: NewSubscriptionMinimumCompositePrice) = @@ -4472,28 +4472,38 @@ private constructor( (if (priceId.asKnown() == null) 0 else 1) + (if (startDate.asKnown() == null) 0 else 1) - /** The definition of a new price to create and add to the subscription. */ + /** New subscription price request body params. */ @JsonDeserialize(using = Price.Deserializer::class) @JsonSerialize(using = Price.Serializer::class) class Price private constructor( private val unit: NewSubscriptionUnitPrice? = null, - private val package_: NewSubscriptionPackagePrice? = null, - private val matrix: NewSubscriptionMatrixPrice? = null, private val tiered: NewSubscriptionTieredPrice? = null, private val bulk: NewSubscriptionBulkPrice? = null, + private val package_: NewSubscriptionPackagePrice? = null, + private val matrix: NewSubscriptionMatrixPrice? = null, private val thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice? = null, private val tieredPackage: NewSubscriptionTieredPackagePrice? = null, private val tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice? = null, - private val unitWithPercent: NewSubscriptionUnitWithPercentPrice? = null, + private val groupedTiered: NewSubscriptionGroupedTieredPrice? = null, + private val tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice? = + null, private val packageWithAllocation: NewSubscriptionPackageWithAllocationPrice? = null, - private val tieredWithProration: NewSubscriptionTierWithProrationPrice? = null, + private val unitWithPercent: NewSubscriptionUnitWithPercentPrice? = null, + private val matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice? = null, + private val tieredWithProration: TieredWithProration? = null, private val unitWithProration: NewSubscriptionUnitWithProrationPrice? = null, private val groupedAllocation: NewSubscriptionGroupedAllocationPrice? = null, + private val bulkWithProration: NewSubscriptionBulkWithProrationPrice? = null, private val groupedWithProratedMinimum: NewSubscriptionGroupedWithProratedMinimumPrice? = null, - private val bulkWithProration: NewSubscriptionBulkWithProrationPrice? = null, + private val groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice? = + null, + private val groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds? = null, + private val matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice? = null, + private val groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice? = null, + private val maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice? = null, private val scalableMatrixWithUnitPricing: NewSubscriptionScalableMatrixWithUnitPricingPrice? = null, @@ -4501,30 +4511,20 @@ private constructor( NewSubscriptionScalableMatrixWithTieredPricingPrice? = null, private val cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice? = null, - private val maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice? = null, - private val groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice? = - null, - private val matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice? = null, - private val groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice? = null, - private val matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice? = null, - private val tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice? = - null, - private val groupedTiered: NewSubscriptionGroupedTieredPrice? = null, - private val groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds? = null, private val minimum: NewSubscriptionMinimumCompositePrice? = null, private val _json: JsonValue? = null, ) { fun unit(): NewSubscriptionUnitPrice? = unit - fun package_(): NewSubscriptionPackagePrice? = package_ - - fun matrix(): NewSubscriptionMatrixPrice? = matrix - fun tiered(): NewSubscriptionTieredPrice? = tiered fun bulk(): NewSubscriptionBulkPrice? = bulk + fun package_(): NewSubscriptionPackagePrice? = package_ + + fun matrix(): NewSubscriptionMatrixPrice? = matrix + fun thresholdTotalAmount(): NewSubscriptionThresholdTotalAmountPrice? = thresholdTotalAmount @@ -4532,122 +4532,122 @@ private constructor( fun tieredWithMinimum(): NewSubscriptionTieredWithMinimumPrice? = tieredWithMinimum - fun unitWithPercent(): NewSubscriptionUnitWithPercentPrice? = unitWithPercent + fun groupedTiered(): NewSubscriptionGroupedTieredPrice? = groupedTiered + + fun tieredPackageWithMinimum(): NewSubscriptionTieredPackageWithMinimumPrice? = + tieredPackageWithMinimum fun packageWithAllocation(): NewSubscriptionPackageWithAllocationPrice? = packageWithAllocation - fun tieredWithProration(): NewSubscriptionTierWithProrationPrice? = tieredWithProration + fun unitWithPercent(): NewSubscriptionUnitWithPercentPrice? = unitWithPercent + + fun matrixWithAllocation(): NewSubscriptionMatrixWithAllocationPrice? = + matrixWithAllocation + + fun tieredWithProration(): TieredWithProration? = tieredWithProration fun unitWithProration(): NewSubscriptionUnitWithProrationPrice? = unitWithProration fun groupedAllocation(): NewSubscriptionGroupedAllocationPrice? = groupedAllocation - fun groupedWithProratedMinimum(): NewSubscriptionGroupedWithProratedMinimumPrice? = - groupedWithProratedMinimum - fun bulkWithProration(): NewSubscriptionBulkWithProrationPrice? = bulkWithProration - fun scalableMatrixWithUnitPricing(): - NewSubscriptionScalableMatrixWithUnitPricingPrice? = scalableMatrixWithUnitPricing - - fun scalableMatrixWithTieredPricing(): - NewSubscriptionScalableMatrixWithTieredPricingPrice? = - scalableMatrixWithTieredPricing - - fun cumulativeGroupedBulk(): NewSubscriptionCumulativeGroupedBulkPrice? = - cumulativeGroupedBulk - - fun maxGroupTieredPackage(): NewSubscriptionMaxGroupTieredPackagePrice? = - maxGroupTieredPackage + fun groupedWithProratedMinimum(): NewSubscriptionGroupedWithProratedMinimumPrice? = + groupedWithProratedMinimum fun groupedWithMeteredMinimum(): NewSubscriptionGroupedWithMeteredMinimumPrice? = groupedWithMeteredMinimum + fun groupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds? = + groupedWithMinMaxThresholds + fun matrixWithDisplayName(): NewSubscriptionMatrixWithDisplayNamePrice? = matrixWithDisplayName fun groupedTieredPackage(): NewSubscriptionGroupedTieredPackagePrice? = groupedTieredPackage - fun matrixWithAllocation(): NewSubscriptionMatrixWithAllocationPrice? = - matrixWithAllocation + fun maxGroupTieredPackage(): NewSubscriptionMaxGroupTieredPackagePrice? = + maxGroupTieredPackage - fun tieredPackageWithMinimum(): NewSubscriptionTieredPackageWithMinimumPrice? = - tieredPackageWithMinimum + fun scalableMatrixWithUnitPricing(): + NewSubscriptionScalableMatrixWithUnitPricingPrice? = scalableMatrixWithUnitPricing - fun groupedTiered(): NewSubscriptionGroupedTieredPrice? = groupedTiered + fun scalableMatrixWithTieredPricing(): + NewSubscriptionScalableMatrixWithTieredPricingPrice? = + scalableMatrixWithTieredPricing - fun groupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds? = - groupedWithMinMaxThresholds + fun cumulativeGroupedBulk(): NewSubscriptionCumulativeGroupedBulkPrice? = + cumulativeGroupedBulk fun minimum(): NewSubscriptionMinimumCompositePrice? = minimum fun isUnit(): Boolean = unit != null - fun isPackage(): Boolean = package_ != null - - fun isMatrix(): Boolean = matrix != null - fun isTiered(): Boolean = tiered != null fun isBulk(): Boolean = bulk != null + fun isPackage(): Boolean = package_ != null + + fun isMatrix(): Boolean = matrix != null + fun isThresholdTotalAmount(): Boolean = thresholdTotalAmount != null fun isTieredPackage(): Boolean = tieredPackage != null fun isTieredWithMinimum(): Boolean = tieredWithMinimum != null - fun isUnitWithPercent(): Boolean = unitWithPercent != null + fun isGroupedTiered(): Boolean = groupedTiered != null + + fun isTieredPackageWithMinimum(): Boolean = tieredPackageWithMinimum != null fun isPackageWithAllocation(): Boolean = packageWithAllocation != null + fun isUnitWithPercent(): Boolean = unitWithPercent != null + + fun isMatrixWithAllocation(): Boolean = matrixWithAllocation != null + fun isTieredWithProration(): Boolean = tieredWithProration != null fun isUnitWithProration(): Boolean = unitWithProration != null fun isGroupedAllocation(): Boolean = groupedAllocation != null - fun isGroupedWithProratedMinimum(): Boolean = groupedWithProratedMinimum != null - fun isBulkWithProration(): Boolean = bulkWithProration != null - fun isScalableMatrixWithUnitPricing(): Boolean = scalableMatrixWithUnitPricing != null - - fun isScalableMatrixWithTieredPricing(): Boolean = - scalableMatrixWithTieredPricing != null - - fun isCumulativeGroupedBulk(): Boolean = cumulativeGroupedBulk != null - - fun isMaxGroupTieredPackage(): Boolean = maxGroupTieredPackage != null + fun isGroupedWithProratedMinimum(): Boolean = groupedWithProratedMinimum != null fun isGroupedWithMeteredMinimum(): Boolean = groupedWithMeteredMinimum != null + fun isGroupedWithMinMaxThresholds(): Boolean = groupedWithMinMaxThresholds != null + fun isMatrixWithDisplayName(): Boolean = matrixWithDisplayName != null fun isGroupedTieredPackage(): Boolean = groupedTieredPackage != null - fun isMatrixWithAllocation(): Boolean = matrixWithAllocation != null + fun isMaxGroupTieredPackage(): Boolean = maxGroupTieredPackage != null - fun isTieredPackageWithMinimum(): Boolean = tieredPackageWithMinimum != null + fun isScalableMatrixWithUnitPricing(): Boolean = scalableMatrixWithUnitPricing != null - fun isGroupedTiered(): Boolean = groupedTiered != null + fun isScalableMatrixWithTieredPricing(): Boolean = + scalableMatrixWithTieredPricing != null - fun isGroupedWithMinMaxThresholds(): Boolean = groupedWithMinMaxThresholds != null + fun isCumulativeGroupedBulk(): Boolean = cumulativeGroupedBulk != null fun isMinimum(): Boolean = minimum != null fun asUnit(): NewSubscriptionUnitPrice = unit.getOrThrow("unit") - fun asPackage(): NewSubscriptionPackagePrice = package_.getOrThrow("package_") - - fun asMatrix(): NewSubscriptionMatrixPrice = matrix.getOrThrow("matrix") - fun asTiered(): NewSubscriptionTieredPrice = tiered.getOrThrow("tiered") fun asBulk(): NewSubscriptionBulkPrice = bulk.getOrThrow("bulk") + fun asPackage(): NewSubscriptionPackagePrice = package_.getOrThrow("package_") + + fun asMatrix(): NewSubscriptionMatrixPrice = matrix.getOrThrow("matrix") + fun asThresholdTotalAmount(): NewSubscriptionThresholdTotalAmountPrice = thresholdTotalAmount.getOrThrow("thresholdTotalAmount") @@ -4657,13 +4657,22 @@ private constructor( fun asTieredWithMinimum(): NewSubscriptionTieredWithMinimumPrice = tieredWithMinimum.getOrThrow("tieredWithMinimum") - fun asUnitWithPercent(): NewSubscriptionUnitWithPercentPrice = - unitWithPercent.getOrThrow("unitWithPercent") + fun asGroupedTiered(): NewSubscriptionGroupedTieredPrice = + groupedTiered.getOrThrow("groupedTiered") + + fun asTieredPackageWithMinimum(): NewSubscriptionTieredPackageWithMinimumPrice = + tieredPackageWithMinimum.getOrThrow("tieredPackageWithMinimum") fun asPackageWithAllocation(): NewSubscriptionPackageWithAllocationPrice = packageWithAllocation.getOrThrow("packageWithAllocation") - fun asTieredWithProration(): NewSubscriptionTierWithProrationPrice = + fun asUnitWithPercent(): NewSubscriptionUnitWithPercentPrice = + unitWithPercent.getOrThrow("unitWithPercent") + + fun asMatrixWithAllocation(): NewSubscriptionMatrixWithAllocationPrice = + matrixWithAllocation.getOrThrow("matrixWithAllocation") + + fun asTieredWithProration(): TieredWithProration = tieredWithProration.getOrThrow("tieredWithProration") fun asUnitWithProration(): NewSubscriptionUnitWithProrationPrice = @@ -4672,46 +4681,37 @@ private constructor( fun asGroupedAllocation(): NewSubscriptionGroupedAllocationPrice = groupedAllocation.getOrThrow("groupedAllocation") - fun asGroupedWithProratedMinimum(): NewSubscriptionGroupedWithProratedMinimumPrice = - groupedWithProratedMinimum.getOrThrow("groupedWithProratedMinimum") - fun asBulkWithProration(): NewSubscriptionBulkWithProrationPrice = bulkWithProration.getOrThrow("bulkWithProration") - fun asScalableMatrixWithUnitPricing(): - NewSubscriptionScalableMatrixWithUnitPricingPrice = - scalableMatrixWithUnitPricing.getOrThrow("scalableMatrixWithUnitPricing") - - fun asScalableMatrixWithTieredPricing(): - NewSubscriptionScalableMatrixWithTieredPricingPrice = - scalableMatrixWithTieredPricing.getOrThrow("scalableMatrixWithTieredPricing") - - fun asCumulativeGroupedBulk(): NewSubscriptionCumulativeGroupedBulkPrice = - cumulativeGroupedBulk.getOrThrow("cumulativeGroupedBulk") - - fun asMaxGroupTieredPackage(): NewSubscriptionMaxGroupTieredPackagePrice = - maxGroupTieredPackage.getOrThrow("maxGroupTieredPackage") + fun asGroupedWithProratedMinimum(): NewSubscriptionGroupedWithProratedMinimumPrice = + groupedWithProratedMinimum.getOrThrow("groupedWithProratedMinimum") fun asGroupedWithMeteredMinimum(): NewSubscriptionGroupedWithMeteredMinimumPrice = groupedWithMeteredMinimum.getOrThrow("groupedWithMeteredMinimum") + fun asGroupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds = + groupedWithMinMaxThresholds.getOrThrow("groupedWithMinMaxThresholds") + fun asMatrixWithDisplayName(): NewSubscriptionMatrixWithDisplayNamePrice = matrixWithDisplayName.getOrThrow("matrixWithDisplayName") fun asGroupedTieredPackage(): NewSubscriptionGroupedTieredPackagePrice = groupedTieredPackage.getOrThrow("groupedTieredPackage") - fun asMatrixWithAllocation(): NewSubscriptionMatrixWithAllocationPrice = - matrixWithAllocation.getOrThrow("matrixWithAllocation") + fun asMaxGroupTieredPackage(): NewSubscriptionMaxGroupTieredPackagePrice = + maxGroupTieredPackage.getOrThrow("maxGroupTieredPackage") - fun asTieredPackageWithMinimum(): NewSubscriptionTieredPackageWithMinimumPrice = - tieredPackageWithMinimum.getOrThrow("tieredPackageWithMinimum") + fun asScalableMatrixWithUnitPricing(): + NewSubscriptionScalableMatrixWithUnitPricingPrice = + scalableMatrixWithUnitPricing.getOrThrow("scalableMatrixWithUnitPricing") - fun asGroupedTiered(): NewSubscriptionGroupedTieredPrice = - groupedTiered.getOrThrow("groupedTiered") + fun asScalableMatrixWithTieredPricing(): + NewSubscriptionScalableMatrixWithTieredPricingPrice = + scalableMatrixWithTieredPricing.getOrThrow("scalableMatrixWithTieredPricing") - fun asGroupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds = - groupedWithMinMaxThresholds.getOrThrow("groupedWithMinMaxThresholds") + fun asCumulativeGroupedBulk(): NewSubscriptionCumulativeGroupedBulkPrice = + cumulativeGroupedBulk.getOrThrow("cumulativeGroupedBulk") fun asMinimum(): NewSubscriptionMinimumCompositePrice = minimum.getOrThrow("minimum") @@ -4720,24 +4720,39 @@ private constructor( fun accept(visitor: Visitor): T = when { unit != null -> visitor.visitUnit(unit) - package_ != null -> visitor.visitPackage(package_) - matrix != null -> visitor.visitMatrix(matrix) tiered != null -> visitor.visitTiered(tiered) bulk != null -> visitor.visitBulk(bulk) + package_ != null -> visitor.visitPackage(package_) + matrix != null -> visitor.visitMatrix(matrix) thresholdTotalAmount != null -> visitor.visitThresholdTotalAmount(thresholdTotalAmount) tieredPackage != null -> visitor.visitTieredPackage(tieredPackage) tieredWithMinimum != null -> visitor.visitTieredWithMinimum(tieredWithMinimum) - unitWithPercent != null -> visitor.visitUnitWithPercent(unitWithPercent) + groupedTiered != null -> visitor.visitGroupedTiered(groupedTiered) + tieredPackageWithMinimum != null -> + visitor.visitTieredPackageWithMinimum(tieredPackageWithMinimum) packageWithAllocation != null -> visitor.visitPackageWithAllocation(packageWithAllocation) + unitWithPercent != null -> visitor.visitUnitWithPercent(unitWithPercent) + matrixWithAllocation != null -> + visitor.visitMatrixWithAllocation(matrixWithAllocation) tieredWithProration != null -> visitor.visitTieredWithProration(tieredWithProration) unitWithProration != null -> visitor.visitUnitWithProration(unitWithProration) groupedAllocation != null -> visitor.visitGroupedAllocation(groupedAllocation) + bulkWithProration != null -> visitor.visitBulkWithProration(bulkWithProration) groupedWithProratedMinimum != null -> visitor.visitGroupedWithProratedMinimum(groupedWithProratedMinimum) - bulkWithProration != null -> visitor.visitBulkWithProration(bulkWithProration) + groupedWithMeteredMinimum != null -> + visitor.visitGroupedWithMeteredMinimum(groupedWithMeteredMinimum) + groupedWithMinMaxThresholds != null -> + visitor.visitGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds) + matrixWithDisplayName != null -> + visitor.visitMatrixWithDisplayName(matrixWithDisplayName) + groupedTieredPackage != null -> + visitor.visitGroupedTieredPackage(groupedTieredPackage) + maxGroupTieredPackage != null -> + visitor.visitMaxGroupTieredPackage(maxGroupTieredPackage) scalableMatrixWithUnitPricing != null -> visitor.visitScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing) scalableMatrixWithTieredPricing != null -> @@ -4746,21 +4761,6 @@ private constructor( ) cumulativeGroupedBulk != null -> visitor.visitCumulativeGroupedBulk(cumulativeGroupedBulk) - maxGroupTieredPackage != null -> - visitor.visitMaxGroupTieredPackage(maxGroupTieredPackage) - groupedWithMeteredMinimum != null -> - visitor.visitGroupedWithMeteredMinimum(groupedWithMeteredMinimum) - matrixWithDisplayName != null -> - visitor.visitMatrixWithDisplayName(matrixWithDisplayName) - groupedTieredPackage != null -> - visitor.visitGroupedTieredPackage(groupedTieredPackage) - matrixWithAllocation != null -> - visitor.visitMatrixWithAllocation(matrixWithAllocation) - tieredPackageWithMinimum != null -> - visitor.visitTieredPackageWithMinimum(tieredPackageWithMinimum) - groupedTiered != null -> visitor.visitGroupedTiered(groupedTiered) - groupedWithMinMaxThresholds != null -> - visitor.visitGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds) minimum != null -> visitor.visitMinimum(minimum) else -> visitor.unknown(_json) } @@ -4778,14 +4778,6 @@ private constructor( unit.validate() } - override fun visitPackage(package_: NewSubscriptionPackagePrice) { - package_.validate() - } - - override fun visitMatrix(matrix: NewSubscriptionMatrixPrice) { - matrix.validate() - } - override fun visitTiered(tiered: NewSubscriptionTieredPrice) { tiered.validate() } @@ -4794,6 +4786,14 @@ private constructor( bulk.validate() } + override fun visitPackage(package_: NewSubscriptionPackagePrice) { + package_.validate() + } + + override fun visitMatrix(matrix: NewSubscriptionMatrixPrice) { + matrix.validate() + } + override fun visitThresholdTotalAmount( thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice ) { @@ -4812,10 +4812,16 @@ private constructor( tieredWithMinimum.validate() } - override fun visitUnitWithPercent( - unitWithPercent: NewSubscriptionUnitWithPercentPrice + override fun visitGroupedTiered( + groupedTiered: NewSubscriptionGroupedTieredPrice ) { - unitWithPercent.validate() + groupedTiered.validate() + } + + override fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice + ) { + tieredPackageWithMinimum.validate() } override fun visitPackageWithAllocation( @@ -4824,8 +4830,20 @@ private constructor( packageWithAllocation.validate() } + override fun visitUnitWithPercent( + unitWithPercent: NewSubscriptionUnitWithPercentPrice + ) { + unitWithPercent.validate() + } + + override fun visitMatrixWithAllocation( + matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice + ) { + matrixWithAllocation.validate() + } + override fun visitTieredWithProration( - tieredWithProration: NewSubscriptionTierWithProrationPrice + tieredWithProration: TieredWithProration ) { tieredWithProration.validate() } @@ -4842,43 +4860,17 @@ private constructor( groupedAllocation.validate() } - override fun visitGroupedWithProratedMinimum( - groupedWithProratedMinimum: - NewSubscriptionGroupedWithProratedMinimumPrice - ) { - groupedWithProratedMinimum.validate() - } - override fun visitBulkWithProration( bulkWithProration: NewSubscriptionBulkWithProrationPrice ) { bulkWithProration.validate() } - override fun visitScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: - NewSubscriptionScalableMatrixWithUnitPricingPrice - ) { - scalableMatrixWithUnitPricing.validate() - } - - override fun visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: - NewSubscriptionScalableMatrixWithTieredPricingPrice - ) { - scalableMatrixWithTieredPricing.validate() - } - - override fun visitCumulativeGroupedBulk( - cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice - ) { - cumulativeGroupedBulk.validate() - } - - override fun visitMaxGroupTieredPackage( - maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice + override fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: + NewSubscriptionGroupedWithProratedMinimumPrice ) { - maxGroupTieredPackage.validate() + groupedWithProratedMinimum.validate() } override fun visitGroupedWithMeteredMinimum( @@ -4887,6 +4879,12 @@ private constructor( groupedWithMeteredMinimum.validate() } + override fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) { + groupedWithMinMaxThresholds.validate() + } + override fun visitMatrixWithDisplayName( matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice ) { @@ -4899,28 +4897,30 @@ private constructor( groupedTieredPackage.validate() } - override fun visitMatrixWithAllocation( - matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice + override fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice ) { - matrixWithAllocation.validate() + maxGroupTieredPackage.validate() } - override fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice + override fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: + NewSubscriptionScalableMatrixWithUnitPricingPrice ) { - tieredPackageWithMinimum.validate() + scalableMatrixWithUnitPricing.validate() } - override fun visitGroupedTiered( - groupedTiered: NewSubscriptionGroupedTieredPrice + override fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: + NewSubscriptionScalableMatrixWithTieredPricingPrice ) { - groupedTiered.validate() + scalableMatrixWithTieredPricing.validate() } - override fun visitGroupedWithMinMaxThresholds( - groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + override fun visitCumulativeGroupedBulk( + cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice ) { - groupedWithMinMaxThresholds.validate() + cumulativeGroupedBulk.validate() } override fun visitMinimum(minimum: NewSubscriptionMinimumCompositePrice) { @@ -4950,17 +4950,17 @@ private constructor( object : Visitor { override fun visitUnit(unit: NewSubscriptionUnitPrice) = unit.validity() + override fun visitTiered(tiered: NewSubscriptionTieredPrice) = + tiered.validity() + + override fun visitBulk(bulk: NewSubscriptionBulkPrice) = bulk.validity() + override fun visitPackage(package_: NewSubscriptionPackagePrice) = package_.validity() override fun visitMatrix(matrix: NewSubscriptionMatrixPrice) = matrix.validity() - override fun visitTiered(tiered: NewSubscriptionTieredPrice) = - tiered.validity() - - override fun visitBulk(bulk: NewSubscriptionBulkPrice) = bulk.validity() - override fun visitThresholdTotalAmount( thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice ) = thresholdTotalAmount.validity() @@ -4973,16 +4973,28 @@ private constructor( tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice ) = tieredWithMinimum.validity() - override fun visitUnitWithPercent( - unitWithPercent: NewSubscriptionUnitWithPercentPrice - ) = unitWithPercent.validity() + override fun visitGroupedTiered( + groupedTiered: NewSubscriptionGroupedTieredPrice + ) = groupedTiered.validity() + + override fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice + ) = tieredPackageWithMinimum.validity() override fun visitPackageWithAllocation( packageWithAllocation: NewSubscriptionPackageWithAllocationPrice ) = packageWithAllocation.validity() + override fun visitUnitWithPercent( + unitWithPercent: NewSubscriptionUnitWithPercentPrice + ) = unitWithPercent.validity() + + override fun visitMatrixWithAllocation( + matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice + ) = matrixWithAllocation.validity() + override fun visitTieredWithProration( - tieredWithProration: NewSubscriptionTierWithProrationPrice + tieredWithProration: TieredWithProration ) = tieredWithProration.validity() override fun visitUnitWithProration( @@ -4993,14 +5005,34 @@ private constructor( groupedAllocation: NewSubscriptionGroupedAllocationPrice ) = groupedAllocation.validity() + override fun visitBulkWithProration( + bulkWithProration: NewSubscriptionBulkWithProrationPrice + ) = bulkWithProration.validity() + override fun visitGroupedWithProratedMinimum( groupedWithProratedMinimum: NewSubscriptionGroupedWithProratedMinimumPrice ) = groupedWithProratedMinimum.validity() - override fun visitBulkWithProration( - bulkWithProration: NewSubscriptionBulkWithProrationPrice - ) = bulkWithProration.validity() + override fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice + ) = groupedWithMeteredMinimum.validity() + + override fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) = groupedWithMinMaxThresholds.validity() + + override fun visitMatrixWithDisplayName( + matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice + ) = matrixWithDisplayName.validity() + + override fun visitGroupedTieredPackage( + groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice + ) = groupedTieredPackage.validity() + + override fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice + ) = maxGroupTieredPackage.validity() override fun visitScalableMatrixWithUnitPricing( scalableMatrixWithUnitPricing: @@ -5016,152 +5048,120 @@ private constructor( cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice ) = cumulativeGroupedBulk.validity() - override fun visitMaxGroupTieredPackage( - maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice - ) = maxGroupTieredPackage.validity() - - override fun visitGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice - ) = groupedWithMeteredMinimum.validity() - - override fun visitMatrixWithDisplayName( - matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice - ) = matrixWithDisplayName.validity() + override fun visitMinimum(minimum: NewSubscriptionMinimumCompositePrice) = + minimum.validity() - override fun visitGroupedTieredPackage( - groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice - ) = groupedTieredPackage.validity() + override fun unknown(json: JsonValue?) = 0 + } + ) - override fun visitMatrixWithAllocation( - matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice - ) = matrixWithAllocation.validity() - - override fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice - ) = tieredPackageWithMinimum.validity() - - override fun visitGroupedTiered( - groupedTiered: NewSubscriptionGroupedTieredPrice - ) = groupedTiered.validity() - - override fun visitGroupedWithMinMaxThresholds( - groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds - ) = groupedWithMinMaxThresholds.validity() - - override fun visitMinimum(minimum: NewSubscriptionMinimumCompositePrice) = - minimum.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } return other is Price && unit == other.unit && - package_ == other.package_ && - matrix == other.matrix && tiered == other.tiered && bulk == other.bulk && + package_ == other.package_ && + matrix == other.matrix && thresholdTotalAmount == other.thresholdTotalAmount && tieredPackage == other.tieredPackage && tieredWithMinimum == other.tieredWithMinimum && - unitWithPercent == other.unitWithPercent && + groupedTiered == other.groupedTiered && + tieredPackageWithMinimum == other.tieredPackageWithMinimum && packageWithAllocation == other.packageWithAllocation && + unitWithPercent == other.unitWithPercent && + matrixWithAllocation == other.matrixWithAllocation && tieredWithProration == other.tieredWithProration && unitWithProration == other.unitWithProration && groupedAllocation == other.groupedAllocation && - groupedWithProratedMinimum == other.groupedWithProratedMinimum && bulkWithProration == other.bulkWithProration && - scalableMatrixWithUnitPricing == other.scalableMatrixWithUnitPricing && - scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && - cumulativeGroupedBulk == other.cumulativeGroupedBulk && - maxGroupTieredPackage == other.maxGroupTieredPackage && + groupedWithProratedMinimum == other.groupedWithProratedMinimum && groupedWithMeteredMinimum == other.groupedWithMeteredMinimum && + groupedWithMinMaxThresholds == other.groupedWithMinMaxThresholds && matrixWithDisplayName == other.matrixWithDisplayName && groupedTieredPackage == other.groupedTieredPackage && - matrixWithAllocation == other.matrixWithAllocation && - tieredPackageWithMinimum == other.tieredPackageWithMinimum && - groupedTiered == other.groupedTiered && - groupedWithMinMaxThresholds == other.groupedWithMinMaxThresholds && + maxGroupTieredPackage == other.maxGroupTieredPackage && + scalableMatrixWithUnitPricing == other.scalableMatrixWithUnitPricing && + scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && + cumulativeGroupedBulk == other.cumulativeGroupedBulk && minimum == other.minimum } override fun hashCode(): Int = Objects.hash( unit, - package_, - matrix, tiered, bulk, + package_, + matrix, thresholdTotalAmount, tieredPackage, tieredWithMinimum, - unitWithPercent, + groupedTiered, + tieredPackageWithMinimum, packageWithAllocation, + unitWithPercent, + matrixWithAllocation, tieredWithProration, unitWithProration, groupedAllocation, - groupedWithProratedMinimum, bulkWithProration, - scalableMatrixWithUnitPricing, - scalableMatrixWithTieredPricing, - cumulativeGroupedBulk, - maxGroupTieredPackage, + groupedWithProratedMinimum, groupedWithMeteredMinimum, + groupedWithMinMaxThresholds, matrixWithDisplayName, groupedTieredPackage, - matrixWithAllocation, - tieredPackageWithMinimum, - groupedTiered, - groupedWithMinMaxThresholds, + maxGroupTieredPackage, + scalableMatrixWithUnitPricing, + scalableMatrixWithTieredPricing, + cumulativeGroupedBulk, minimum, ) override fun toString(): String = when { unit != null -> "Price{unit=$unit}" - package_ != null -> "Price{package_=$package_}" - matrix != null -> "Price{matrix=$matrix}" tiered != null -> "Price{tiered=$tiered}" bulk != null -> "Price{bulk=$bulk}" + package_ != null -> "Price{package_=$package_}" + matrix != null -> "Price{matrix=$matrix}" thresholdTotalAmount != null -> "Price{thresholdTotalAmount=$thresholdTotalAmount}" tieredPackage != null -> "Price{tieredPackage=$tieredPackage}" tieredWithMinimum != null -> "Price{tieredWithMinimum=$tieredWithMinimum}" - unitWithPercent != null -> "Price{unitWithPercent=$unitWithPercent}" + groupedTiered != null -> "Price{groupedTiered=$groupedTiered}" + tieredPackageWithMinimum != null -> + "Price{tieredPackageWithMinimum=$tieredPackageWithMinimum}" packageWithAllocation != null -> "Price{packageWithAllocation=$packageWithAllocation}" + unitWithPercent != null -> "Price{unitWithPercent=$unitWithPercent}" + matrixWithAllocation != null -> + "Price{matrixWithAllocation=$matrixWithAllocation}" tieredWithProration != null -> "Price{tieredWithProration=$tieredWithProration}" unitWithProration != null -> "Price{unitWithProration=$unitWithProration}" groupedAllocation != null -> "Price{groupedAllocation=$groupedAllocation}" + bulkWithProration != null -> "Price{bulkWithProration=$bulkWithProration}" groupedWithProratedMinimum != null -> "Price{groupedWithProratedMinimum=$groupedWithProratedMinimum}" - bulkWithProration != null -> "Price{bulkWithProration=$bulkWithProration}" - scalableMatrixWithUnitPricing != null -> - "Price{scalableMatrixWithUnitPricing=$scalableMatrixWithUnitPricing}" - scalableMatrixWithTieredPricing != null -> - "Price{scalableMatrixWithTieredPricing=$scalableMatrixWithTieredPricing}" - cumulativeGroupedBulk != null -> - "Price{cumulativeGroupedBulk=$cumulativeGroupedBulk}" - maxGroupTieredPackage != null -> - "Price{maxGroupTieredPackage=$maxGroupTieredPackage}" groupedWithMeteredMinimum != null -> "Price{groupedWithMeteredMinimum=$groupedWithMeteredMinimum}" + groupedWithMinMaxThresholds != null -> + "Price{groupedWithMinMaxThresholds=$groupedWithMinMaxThresholds}" matrixWithDisplayName != null -> "Price{matrixWithDisplayName=$matrixWithDisplayName}" groupedTieredPackage != null -> "Price{groupedTieredPackage=$groupedTieredPackage}" - matrixWithAllocation != null -> - "Price{matrixWithAllocation=$matrixWithAllocation}" - tieredPackageWithMinimum != null -> - "Price{tieredPackageWithMinimum=$tieredPackageWithMinimum}" - groupedTiered != null -> "Price{groupedTiered=$groupedTiered}" - groupedWithMinMaxThresholds != null -> - "Price{groupedWithMinMaxThresholds=$groupedWithMinMaxThresholds}" + maxGroupTieredPackage != null -> + "Price{maxGroupTieredPackage=$maxGroupTieredPackage}" + scalableMatrixWithUnitPricing != null -> + "Price{scalableMatrixWithUnitPricing=$scalableMatrixWithUnitPricing}" + scalableMatrixWithTieredPricing != null -> + "Price{scalableMatrixWithTieredPricing=$scalableMatrixWithTieredPricing}" + cumulativeGroupedBulk != null -> + "Price{cumulativeGroupedBulk=$cumulativeGroupedBulk}" minimum != null -> "Price{minimum=$minimum}" _json != null -> "Price{_unknown=$_json}" else -> throw IllegalStateException("Invalid Price") @@ -5171,14 +5171,14 @@ private constructor( fun ofUnit(unit: NewSubscriptionUnitPrice) = Price(unit = unit) - fun ofPackage(package_: NewSubscriptionPackagePrice) = Price(package_ = package_) - - fun ofMatrix(matrix: NewSubscriptionMatrixPrice) = Price(matrix = matrix) - fun ofTiered(tiered: NewSubscriptionTieredPrice) = Price(tiered = tiered) fun ofBulk(bulk: NewSubscriptionBulkPrice) = Price(bulk = bulk) + fun ofPackage(package_: NewSubscriptionPackagePrice) = Price(package_ = package_) + + fun ofMatrix(matrix: NewSubscriptionMatrixPrice) = Price(matrix = matrix) + fun ofThresholdTotalAmount( thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice ) = Price(thresholdTotalAmount = thresholdTotalAmount) @@ -5189,16 +5189,26 @@ private constructor( fun ofTieredWithMinimum(tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice) = Price(tieredWithMinimum = tieredWithMinimum) - fun ofUnitWithPercent(unitWithPercent: NewSubscriptionUnitWithPercentPrice) = - Price(unitWithPercent = unitWithPercent) + fun ofGroupedTiered(groupedTiered: NewSubscriptionGroupedTieredPrice) = + Price(groupedTiered = groupedTiered) + + fun ofTieredPackageWithMinimum( + tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice + ) = Price(tieredPackageWithMinimum = tieredPackageWithMinimum) fun ofPackageWithAllocation( packageWithAllocation: NewSubscriptionPackageWithAllocationPrice ) = Price(packageWithAllocation = packageWithAllocation) - fun ofTieredWithProration( - tieredWithProration: NewSubscriptionTierWithProrationPrice - ) = Price(tieredWithProration = tieredWithProration) + fun ofUnitWithPercent(unitWithPercent: NewSubscriptionUnitWithPercentPrice) = + Price(unitWithPercent = unitWithPercent) + + fun ofMatrixWithAllocation( + matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice + ) = Price(matrixWithAllocation = matrixWithAllocation) + + fun ofTieredWithProration(tieredWithProration: TieredWithProration) = + Price(tieredWithProration = tieredWithProration) fun ofUnitWithProration(unitWithProration: NewSubscriptionUnitWithProrationPrice) = Price(unitWithProration = unitWithProration) @@ -5206,34 +5216,21 @@ private constructor( fun ofGroupedAllocation(groupedAllocation: NewSubscriptionGroupedAllocationPrice) = Price(groupedAllocation = groupedAllocation) - fun ofGroupedWithProratedMinimum( - groupedWithProratedMinimum: NewSubscriptionGroupedWithProratedMinimumPrice - ) = Price(groupedWithProratedMinimum = groupedWithProratedMinimum) - fun ofBulkWithProration(bulkWithProration: NewSubscriptionBulkWithProrationPrice) = Price(bulkWithProration = bulkWithProration) - fun ofScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: NewSubscriptionScalableMatrixWithUnitPricingPrice - ) = Price(scalableMatrixWithUnitPricing = scalableMatrixWithUnitPricing) - - fun ofScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: - NewSubscriptionScalableMatrixWithTieredPricingPrice - ) = Price(scalableMatrixWithTieredPricing = scalableMatrixWithTieredPricing) - - fun ofCumulativeGroupedBulk( - cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice - ) = Price(cumulativeGroupedBulk = cumulativeGroupedBulk) - - fun ofMaxGroupTieredPackage( - maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice - ) = Price(maxGroupTieredPackage = maxGroupTieredPackage) + fun ofGroupedWithProratedMinimum( + groupedWithProratedMinimum: NewSubscriptionGroupedWithProratedMinimumPrice + ) = Price(groupedWithProratedMinimum = groupedWithProratedMinimum) fun ofGroupedWithMeteredMinimum( groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice ) = Price(groupedWithMeteredMinimum = groupedWithMeteredMinimum) + fun ofGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) = Price(groupedWithMinMaxThresholds = groupedWithMinMaxThresholds) + fun ofMatrixWithDisplayName( matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice ) = Price(matrixWithDisplayName = matrixWithDisplayName) @@ -5242,20 +5239,22 @@ private constructor( groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice ) = Price(groupedTieredPackage = groupedTieredPackage) - fun ofMatrixWithAllocation( - matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice - ) = Price(matrixWithAllocation = matrixWithAllocation) + fun ofMaxGroupTieredPackage( + maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice + ) = Price(maxGroupTieredPackage = maxGroupTieredPackage) - fun ofTieredPackageWithMinimum( - tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice - ) = Price(tieredPackageWithMinimum = tieredPackageWithMinimum) + fun ofScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: NewSubscriptionScalableMatrixWithUnitPricingPrice + ) = Price(scalableMatrixWithUnitPricing = scalableMatrixWithUnitPricing) - fun ofGroupedTiered(groupedTiered: NewSubscriptionGroupedTieredPrice) = - Price(groupedTiered = groupedTiered) + fun ofScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: + NewSubscriptionScalableMatrixWithTieredPricingPrice + ) = Price(scalableMatrixWithTieredPricing = scalableMatrixWithTieredPricing) - fun ofGroupedWithMinMaxThresholds( - groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds - ) = Price(groupedWithMinMaxThresholds = groupedWithMinMaxThresholds) + fun ofCumulativeGroupedBulk( + cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice + ) = Price(cumulativeGroupedBulk = cumulativeGroupedBulk) fun ofMinimum(minimum: NewSubscriptionMinimumCompositePrice) = Price(minimum = minimum) @@ -5268,14 +5267,14 @@ private constructor( fun visitUnit(unit: NewSubscriptionUnitPrice): T - fun visitPackage(package_: NewSubscriptionPackagePrice): T - - fun visitMatrix(matrix: NewSubscriptionMatrixPrice): T - fun visitTiered(tiered: NewSubscriptionTieredPrice): T fun visitBulk(bulk: NewSubscriptionBulkPrice): T + fun visitPackage(package_: NewSubscriptionPackagePrice): T + + fun visitMatrix(matrix: NewSubscriptionMatrixPrice): T + fun visitThresholdTotalAmount( thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice ): T @@ -5286,16 +5285,24 @@ private constructor( tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice ): T - fun visitUnitWithPercent(unitWithPercent: NewSubscriptionUnitWithPercentPrice): T + fun visitGroupedTiered(groupedTiered: NewSubscriptionGroupedTieredPrice): T + + fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice + ): T fun visitPackageWithAllocation( packageWithAllocation: NewSubscriptionPackageWithAllocationPrice ): T - fun visitTieredWithProration( - tieredWithProration: NewSubscriptionTierWithProrationPrice + fun visitUnitWithPercent(unitWithPercent: NewSubscriptionUnitWithPercentPrice): T + + fun visitMatrixWithAllocation( + matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice ): T + fun visitTieredWithProration(tieredWithProration: TieredWithProration): T + fun visitUnitWithProration( unitWithProration: NewSubscriptionUnitWithProrationPrice ): T @@ -5304,35 +5311,22 @@ private constructor( groupedAllocation: NewSubscriptionGroupedAllocationPrice ): T - fun visitGroupedWithProratedMinimum( - groupedWithProratedMinimum: NewSubscriptionGroupedWithProratedMinimumPrice - ): T - fun visitBulkWithProration( bulkWithProration: NewSubscriptionBulkWithProrationPrice ): T - fun visitScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: NewSubscriptionScalableMatrixWithUnitPricingPrice - ): T - - fun visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: - NewSubscriptionScalableMatrixWithTieredPricingPrice - ): T - - fun visitCumulativeGroupedBulk( - cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice - ): T - - fun visitMaxGroupTieredPackage( - maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice + fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: NewSubscriptionGroupedWithProratedMinimumPrice ): T fun visitGroupedWithMeteredMinimum( groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice ): T + fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ): T + fun visitMatrixWithDisplayName( matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice ): T @@ -5341,18 +5335,21 @@ private constructor( groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice ): T - fun visitMatrixWithAllocation( - matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice + fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice ): T - fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice + fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: NewSubscriptionScalableMatrixWithUnitPricingPrice ): T - fun visitGroupedTiered(groupedTiered: NewSubscriptionGroupedTieredPrice): T + fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: + NewSubscriptionScalableMatrixWithTieredPricingPrice + ): T - fun visitGroupedWithMinMaxThresholds( - groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + fun visitCumulativeGroupedBulk( + cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice ): T fun visitMinimum(minimum: NewSubscriptionMinimumCompositePrice): T @@ -5383,6 +5380,17 @@ private constructor( return tryDeserialize(node, jacksonTypeRef()) ?.let { Price(unit = it, _json = json) } ?: Price(_json = json) } + "tiered" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(tiered = it, _json = json) } ?: Price(_json = json) + } + "bulk" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(bulk = it, _json = json) } ?: Price(_json = json) + } "package" -> { return tryDeserialize( node, @@ -5397,18 +5405,7 @@ private constructor( ) ?.let { Price(matrix = it, _json = json) } ?: Price(_json = json) } - "tiered" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(tiered = it, _json = json) } ?: Price(_json = json) - } - "bulk" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(bulk = it, _json = json) } ?: Price(_json = json) - } - "threshold_total_amount" -> { + "threshold_total_amount" -> { return tryDeserialize( node, jacksonTypeRef(), @@ -5432,12 +5429,20 @@ private constructor( ?.let { Price(tieredWithMinimum = it, _json = json) } ?: Price(_json = json) } - "unit_with_percent" -> { + "grouped_tiered" -> { return tryDeserialize( node, - jacksonTypeRef(), + jacksonTypeRef(), ) - ?.let { Price(unitWithPercent = it, _json = json) } + ?.let { Price(groupedTiered = it, _json = json) } + ?: Price(_json = json) + } + "tiered_package_with_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(tieredPackageWithMinimum = it, _json = json) } ?: Price(_json = json) } "package_with_allocation" -> { @@ -5448,11 +5453,24 @@ private constructor( ?.let { Price(packageWithAllocation = it, _json = json) } ?: Price(_json = json) } - "tiered_with_proration" -> { + "unit_with_percent" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(unitWithPercent = it, _json = json) } + ?: Price(_json = json) + } + "matrix_with_allocation" -> { return tryDeserialize( node, - jacksonTypeRef(), + jacksonTypeRef(), ) + ?.let { Price(matrixWithAllocation = it, _json = json) } + ?: Price(_json = json) + } + "tiered_with_proration" -> { + return tryDeserialize(node, jacksonTypeRef()) ?.let { Price(tieredWithProration = it, _json = json) } ?: Price(_json = json) } @@ -5472,14 +5490,6 @@ private constructor( ?.let { Price(groupedAllocation = it, _json = json) } ?: Price(_json = json) } - "grouped_with_prorated_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedWithProratedMinimum = it, _json = json) } - ?: Price(_json = json) - } "bulk_with_proration" -> { return tryDeserialize( node, @@ -5488,48 +5498,28 @@ private constructor( ?.let { Price(bulkWithProration = it, _json = json) } ?: Price(_json = json) } - "scalable_matrix_with_unit_pricing" -> { - return tryDeserialize( - node, - jacksonTypeRef< - NewSubscriptionScalableMatrixWithUnitPricingPrice - >(), - ) - ?.let { Price(scalableMatrixWithUnitPricing = it, _json = json) } - ?: Price(_json = json) - } - "scalable_matrix_with_tiered_pricing" -> { - return tryDeserialize( - node, - jacksonTypeRef< - NewSubscriptionScalableMatrixWithTieredPricingPrice - >(), - ) - ?.let { Price(scalableMatrixWithTieredPricing = it, _json = json) } - ?: Price(_json = json) - } - "cumulative_grouped_bulk" -> { + "grouped_with_prorated_minimum" -> { return tryDeserialize( node, - jacksonTypeRef(), + jacksonTypeRef(), ) - ?.let { Price(cumulativeGroupedBulk = it, _json = json) } + ?.let { Price(groupedWithProratedMinimum = it, _json = json) } ?: Price(_json = json) } - "max_group_tiered_package" -> { + "grouped_with_metered_minimum" -> { return tryDeserialize( node, - jacksonTypeRef(), + jacksonTypeRef(), ) - ?.let { Price(maxGroupTieredPackage = it, _json = json) } + ?.let { Price(groupedWithMeteredMinimum = it, _json = json) } ?: Price(_json = json) } - "grouped_with_metered_minimum" -> { + "grouped_with_min_max_thresholds" -> { return tryDeserialize( node, - jacksonTypeRef(), + jacksonTypeRef(), ) - ?.let { Price(groupedWithMeteredMinimum = it, _json = json) } + ?.let { Price(groupedWithMinMaxThresholds = it, _json = json) } ?: Price(_json = json) } "matrix_with_display_name" -> { @@ -5548,36 +5538,40 @@ private constructor( ?.let { Price(groupedTieredPackage = it, _json = json) } ?: Price(_json = json) } - "matrix_with_allocation" -> { + "max_group_tiered_package" -> { return tryDeserialize( node, - jacksonTypeRef(), + jacksonTypeRef(), ) - ?.let { Price(matrixWithAllocation = it, _json = json) } + ?.let { Price(maxGroupTieredPackage = it, _json = json) } ?: Price(_json = json) } - "tiered_package_with_minimum" -> { + "scalable_matrix_with_unit_pricing" -> { return tryDeserialize( node, - jacksonTypeRef(), + jacksonTypeRef< + NewSubscriptionScalableMatrixWithUnitPricingPrice + >(), ) - ?.let { Price(tieredPackageWithMinimum = it, _json = json) } + ?.let { Price(scalableMatrixWithUnitPricing = it, _json = json) } ?: Price(_json = json) } - "grouped_tiered" -> { + "scalable_matrix_with_tiered_pricing" -> { return tryDeserialize( node, - jacksonTypeRef(), + jacksonTypeRef< + NewSubscriptionScalableMatrixWithTieredPricingPrice + >(), ) - ?.let { Price(groupedTiered = it, _json = json) } + ?.let { Price(scalableMatrixWithTieredPricing = it, _json = json) } ?: Price(_json = json) } - "grouped_with_min_max_thresholds" -> { + "cumulative_grouped_bulk" -> { return tryDeserialize( node, - jacksonTypeRef(), + jacksonTypeRef(), ) - ?.let { Price(groupedWithMinMaxThresholds = it, _json = json) } + ?.let { Price(cumulativeGroupedBulk = it, _json = json) } ?: Price(_json = json) } "minimum" -> { @@ -5602,50 +5596,50 @@ private constructor( ) { when { value.unit != null -> generator.writeObject(value.unit) - value.package_ != null -> generator.writeObject(value.package_) - value.matrix != null -> generator.writeObject(value.matrix) value.tiered != null -> generator.writeObject(value.tiered) value.bulk != null -> generator.writeObject(value.bulk) + value.package_ != null -> generator.writeObject(value.package_) + value.matrix != null -> generator.writeObject(value.matrix) value.thresholdTotalAmount != null -> generator.writeObject(value.thresholdTotalAmount) value.tieredPackage != null -> generator.writeObject(value.tieredPackage) value.tieredWithMinimum != null -> generator.writeObject(value.tieredWithMinimum) - value.unitWithPercent != null -> - generator.writeObject(value.unitWithPercent) + value.groupedTiered != null -> generator.writeObject(value.groupedTiered) + value.tieredPackageWithMinimum != null -> + generator.writeObject(value.tieredPackageWithMinimum) value.packageWithAllocation != null -> generator.writeObject(value.packageWithAllocation) + value.unitWithPercent != null -> + generator.writeObject(value.unitWithPercent) + value.matrixWithAllocation != null -> + generator.writeObject(value.matrixWithAllocation) value.tieredWithProration != null -> generator.writeObject(value.tieredWithProration) value.unitWithProration != null -> generator.writeObject(value.unitWithProration) value.groupedAllocation != null -> generator.writeObject(value.groupedAllocation) - value.groupedWithProratedMinimum != null -> - generator.writeObject(value.groupedWithProratedMinimum) value.bulkWithProration != null -> generator.writeObject(value.bulkWithProration) - value.scalableMatrixWithUnitPricing != null -> - generator.writeObject(value.scalableMatrixWithUnitPricing) - value.scalableMatrixWithTieredPricing != null -> - generator.writeObject(value.scalableMatrixWithTieredPricing) - value.cumulativeGroupedBulk != null -> - generator.writeObject(value.cumulativeGroupedBulk) - value.maxGroupTieredPackage != null -> - generator.writeObject(value.maxGroupTieredPackage) + value.groupedWithProratedMinimum != null -> + generator.writeObject(value.groupedWithProratedMinimum) value.groupedWithMeteredMinimum != null -> generator.writeObject(value.groupedWithMeteredMinimum) + value.groupedWithMinMaxThresholds != null -> + generator.writeObject(value.groupedWithMinMaxThresholds) value.matrixWithDisplayName != null -> generator.writeObject(value.matrixWithDisplayName) value.groupedTieredPackage != null -> generator.writeObject(value.groupedTieredPackage) - value.matrixWithAllocation != null -> - generator.writeObject(value.matrixWithAllocation) - value.tieredPackageWithMinimum != null -> - generator.writeObject(value.tieredPackageWithMinimum) - value.groupedTiered != null -> generator.writeObject(value.groupedTiered) - value.groupedWithMinMaxThresholds != null -> - generator.writeObject(value.groupedWithMinMaxThresholds) + value.maxGroupTieredPackage != null -> + generator.writeObject(value.maxGroupTieredPackage) + value.scalableMatrixWithUnitPricing != null -> + generator.writeObject(value.scalableMatrixWithUnitPricing) + value.scalableMatrixWithTieredPricing != null -> + generator.writeObject(value.scalableMatrixWithTieredPricing) + value.cumulativeGroupedBulk != null -> + generator.writeObject(value.cumulativeGroupedBulk) value.minimum != null -> generator.writeObject(value.minimum) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid Price") @@ -5653,14 +5647,13 @@ private constructor( } } - class GroupedWithMinMaxThresholds + class TieredWithProration private constructor( private val cadence: JsonField, - private val groupedWithMinMaxThresholdsConfig: - JsonField, private val itemId: JsonField, private val modelType: JsonValue, private val name: JsonField, + private val tieredWithProrationConfig: JsonField, private val billableMetricId: JsonField, private val billedInAdvance: JsonField, private val billingCycleConfiguration: JsonField, @@ -5683,11 +5676,6 @@ private constructor( @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), - @JsonProperty("grouped_with_min_max_thresholds_config") - @ExcludeMissing - groupedWithMinMaxThresholdsConfig: - JsonField = - JsonMissing.of(), @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), @@ -5697,6 +5685,10 @@ private constructor( @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("tiered_with_proration_config") + @ExcludeMissing + tieredWithProrationConfig: JsonField = + JsonMissing.of(), @JsonProperty("billable_metric_id") @ExcludeMissing billableMetricId: JsonField = JsonMissing.of(), @@ -5741,10 +5733,10 @@ private constructor( referenceId: JsonField = JsonMissing.of(), ) : this( cadence, - groupedWithMinMaxThresholdsConfig, itemId, modelType, name, + tieredWithProrationConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -5770,16 +5762,6 @@ private constructor( */ fun cadence(): Cadence = cadence.getRequired("cadence") - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun groupedWithMinMaxThresholdsConfig(): GroupedWithMinMaxThresholdsConfig = - groupedWithMinMaxThresholdsConfig.getRequired( - "grouped_with_min_max_thresholds_config" - ) - /** * The id of the item the price will be associated with. * @@ -5790,9 +5772,11 @@ private constructor( fun itemId(): String = itemId.getRequired("item_id") /** + * The pricing model type + * * Expected to always return the following: * ```kotlin - * JsonValue.from("grouped_with_min_max_thresholds") + * JsonValue.from("tiered_with_proration") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -5809,6 +5793,16 @@ private constructor( */ fun name(): String = name.getRequired("name") + /** + * Configuration for tiered_with_proration pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun tieredWithProrationConfig(): TieredWithProrationConfig = + tieredWithProrationConfig.getRequired("tiered_with_proration_config") + /** * The id of the billable metric for the price. Only needed if the price is * usage-based. @@ -5938,17 +5932,6 @@ private constructor( @ExcludeMissing fun _cadence(): JsonField = cadence - /** - * Returns the raw JSON value of [groupedWithMinMaxThresholdsConfig]. - * - * Unlike [groupedWithMinMaxThresholdsConfig], this method doesn't throw if the JSON - * field has an unexpected type. - */ - @JsonProperty("grouped_with_min_max_thresholds_config") - @ExcludeMissing - fun _groupedWithMinMaxThresholdsConfig(): - JsonField = groupedWithMinMaxThresholdsConfig - /** * Returns the raw JSON value of [itemId]. * @@ -5965,6 +5948,17 @@ private constructor( */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + /** + * Returns the raw JSON value of [tieredWithProrationConfig]. + * + * Unlike [tieredWithProrationConfig], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("tiered_with_proration_config") + @ExcludeMissing + fun _tieredWithProrationConfig(): JsonField = + tieredWithProrationConfig + /** * Returns the raw JSON value of [billableMetricId]. * @@ -6114,30 +6108,28 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [GroupedWithMinMaxThresholds]. + * [TieredWithProration]. * * The following fields are required: * ```kotlin * .cadence() - * .groupedWithMinMaxThresholdsConfig() * .itemId() * .name() + * .tieredWithProrationConfig() * ``` */ fun builder() = Builder() } - /** A builder for [GroupedWithMinMaxThresholds]. */ + /** A builder for [TieredWithProration]. */ class Builder internal constructor() { private var cadence: JsonField? = null - private var groupedWithMinMaxThresholdsConfig: - JsonField? = - null private var itemId: JsonField? = null - private var modelType: JsonValue = - JsonValue.from("grouped_with_min_max_thresholds") + private var modelType: JsonValue = JsonValue.from("tiered_with_proration") private var name: JsonField? = null + private var tieredWithProrationConfig: JsonField? = + null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() private var billingCycleConfiguration: JsonField = @@ -6159,33 +6151,30 @@ private constructor( private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds) = - apply { - cadence = groupedWithMinMaxThresholds.cadence - groupedWithMinMaxThresholdsConfig = - groupedWithMinMaxThresholds.groupedWithMinMaxThresholdsConfig - itemId = groupedWithMinMaxThresholds.itemId - modelType = groupedWithMinMaxThresholds.modelType - name = groupedWithMinMaxThresholds.name - billableMetricId = groupedWithMinMaxThresholds.billableMetricId - billedInAdvance = groupedWithMinMaxThresholds.billedInAdvance - billingCycleConfiguration = - groupedWithMinMaxThresholds.billingCycleConfiguration - conversionRate = groupedWithMinMaxThresholds.conversionRate - conversionRateConfig = groupedWithMinMaxThresholds.conversionRateConfig - currency = groupedWithMinMaxThresholds.currency - dimensionalPriceConfiguration = - groupedWithMinMaxThresholds.dimensionalPriceConfiguration - externalPriceId = groupedWithMinMaxThresholds.externalPriceId - fixedPriceQuantity = groupedWithMinMaxThresholds.fixedPriceQuantity - invoiceGroupingKey = groupedWithMinMaxThresholds.invoiceGroupingKey - invoicingCycleConfiguration = - groupedWithMinMaxThresholds.invoicingCycleConfiguration - metadata = groupedWithMinMaxThresholds.metadata - referenceId = groupedWithMinMaxThresholds.referenceId - additionalProperties = - groupedWithMinMaxThresholds.additionalProperties.toMutableMap() - } + internal fun from(tieredWithProration: TieredWithProration) = apply { + cadence = tieredWithProration.cadence + itemId = tieredWithProration.itemId + modelType = tieredWithProration.modelType + name = tieredWithProration.name + tieredWithProrationConfig = tieredWithProration.tieredWithProrationConfig + billableMetricId = tieredWithProration.billableMetricId + billedInAdvance = tieredWithProration.billedInAdvance + billingCycleConfiguration = tieredWithProration.billingCycleConfiguration + conversionRate = tieredWithProration.conversionRate + conversionRateConfig = tieredWithProration.conversionRateConfig + currency = tieredWithProration.currency + dimensionalPriceConfiguration = + tieredWithProration.dimensionalPriceConfiguration + externalPriceId = tieredWithProration.externalPriceId + fixedPriceQuantity = tieredWithProration.fixedPriceQuantity + invoiceGroupingKey = tieredWithProration.invoiceGroupingKey + invoicingCycleConfiguration = + tieredWithProration.invoicingCycleConfiguration + metadata = tieredWithProration.metadata + referenceId = tieredWithProration.referenceId + additionalProperties = + tieredWithProration.additionalProperties.toMutableMap() + } /** The cadence to bill for this price on. */ fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) @@ -6199,33 +6188,11 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - fun groupedWithMinMaxThresholdsConfig( - groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig - ) = - groupedWithMinMaxThresholdsConfig( - JsonField.of(groupedWithMinMaxThresholdsConfig) - ) + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) /** - * Sets [Builder.groupedWithMinMaxThresholdsConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.groupedWithMinMaxThresholdsConfig] with a - * well-typed [GroupedWithMinMaxThresholdsConfig] value instead. This method is - * primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun groupedWithMinMaxThresholdsConfig( - groupedWithMinMaxThresholdsConfig: - JsonField - ) = apply { - this.groupedWithMinMaxThresholdsConfig = groupedWithMinMaxThresholdsConfig - } - - /** The id of the item the price will be associated with. */ - fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - - /** - * Sets [Builder.itemId] to an arbitrary JSON value. + * Sets [Builder.itemId] to an arbitrary JSON value. * * You should usually call [Builder.itemId] with a well-typed [String] value * instead. This method is primarily for setting the field to an undocumented or @@ -6239,7 +6206,7 @@ private constructor( * It is usually unnecessary to call this method because the field defaults to * the following: * ```kotlin - * JsonValue.from("grouped_with_min_max_thresholds") + * JsonValue.from("tiered_with_proration") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -6259,6 +6226,22 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } + /** Configuration for tiered_with_proration pricing */ + fun tieredWithProrationConfig( + tieredWithProrationConfig: TieredWithProrationConfig + ) = tieredWithProrationConfig(JsonField.of(tieredWithProrationConfig)) + + /** + * Sets [Builder.tieredWithProrationConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.tieredWithProrationConfig] with a well-typed + * [TieredWithProrationConfig] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun tieredWithProrationConfig( + tieredWithProrationConfig: JsonField + ) = apply { this.tieredWithProrationConfig = tieredWithProrationConfig } + /** * The id of the billable metric for the price. Only needed if the price is * usage-based. @@ -6588,30 +6571,27 @@ private constructor( } /** - * Returns an immutable instance of [GroupedWithMinMaxThresholds]. + * Returns an immutable instance of [TieredWithProration]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```kotlin * .cadence() - * .groupedWithMinMaxThresholdsConfig() * .itemId() * .name() + * .tieredWithProrationConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): GroupedWithMinMaxThresholds = - GroupedWithMinMaxThresholds( + fun build(): TieredWithProration = + TieredWithProration( checkRequired("cadence", cadence), - checkRequired( - "groupedWithMinMaxThresholdsConfig", - groupedWithMinMaxThresholdsConfig, - ), checkRequired("itemId", itemId), modelType, checkRequired("name", name), + checkRequired("tieredWithProrationConfig", tieredWithProrationConfig), billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -6631,20 +6611,20 @@ private constructor( private var validated: Boolean = false - fun validate(): GroupedWithMinMaxThresholds = apply { + fun validate(): TieredWithProration = apply { if (validated) { return@apply } cadence().validate() - groupedWithMinMaxThresholdsConfig().validate() itemId() _modelType().let { - if (it != JsonValue.from("grouped_with_min_max_thresholds")) { + if (it != JsonValue.from("tiered_with_proration")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } name() + tieredWithProrationConfig().validate() billableMetricId() billedInAdvance() billingCycleConfiguration()?.validate() @@ -6677,12 +6657,12 @@ private constructor( */ internal fun validity(): Int = (cadence.asKnown()?.validity() ?: 0) + - (groupedWithMinMaxThresholdsConfig.asKnown()?.validity() ?: 0) + (if (itemId.asKnown() == null) 0 else 1) + modelType.let { - if (it == JsonValue.from("grouped_with_min_max_thresholds")) 1 else 0 + if (it == JsonValue.from("tiered_with_proration")) 1 else 0 } + (if (name.asKnown() == null) 0 else 1) + + (tieredWithProrationConfig.asKnown()?.validity() ?: 0) + (if (billableMetricId.asKnown() == null) 0 else 1) + (if (billedInAdvance.asKnown() == null) 0 else 1) + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + @@ -6854,16 +6834,49 @@ private constructor( override fun toString() = value.toString() } - class GroupedWithMinMaxThresholdsConfig - @JsonCreator + /** Configuration for tiered_with_proration pricing */ + class TieredWithProrationConfig private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map + private val tiers: JsonField>, + private val additionalProperties: MutableMap, ) { + @JsonCreator + private constructor( + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of() + ) : this(tiers, mutableMapOf()) + + /** + * Tiers for rating based on total usage quantities into the specified tier with + * proration + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun tiers(): List = tiers.getRequired("tiers") + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) fun toBuilder() = Builder().from(this) @@ -6871,23 +6884,58 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [GroupedWithMinMaxThresholdsConfig]. + * [TieredWithProrationConfig]. + * + * The following fields are required: + * ```kotlin + * .tiers() + * ``` */ fun builder() = Builder() } - /** A builder for [GroupedWithMinMaxThresholdsConfig]. */ + /** A builder for [TieredWithProrationConfig]. */ class Builder internal constructor() { + private var tiers: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() - internal fun from( - groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig - ) = apply { - additionalProperties = - groupedWithMinMaxThresholdsConfig.additionalProperties - .toMutableMap() + internal fun from(tieredWithProrationConfig: TieredWithProrationConfig) = + apply { + tiers = tieredWithProrationConfig.tiers.map { it.toMutableList() } + additionalProperties = + tieredWithProrationConfig.additionalProperties.toMutableMap() + } + + /** + * Tiers for rating based on total usage quantities into the specified tier + * with proration + */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } } fun additionalProperties(additionalProperties: Map) = @@ -6913,21 +6961,32 @@ private constructor( } /** - * Returns an immutable instance of [GroupedWithMinMaxThresholdsConfig]. + * Returns an immutable instance of [TieredWithProrationConfig]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ - fun build(): GroupedWithMinMaxThresholdsConfig = - GroupedWithMinMaxThresholdsConfig(additionalProperties.toImmutable()) + fun build(): TieredWithProrationConfig = + TieredWithProrationConfig( + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false - fun validate(): GroupedWithMinMaxThresholdsConfig = apply { + fun validate(): TieredWithProrationConfig = apply { if (validated) { return@apply } + tiers().forEach { it.validate() } validated = true } @@ -6946,25 +7005,246 @@ private constructor( * Used for best match union deserialization. */ internal fun validity(): Int = - additionalProperties.count { (_, value) -> - !value.isNull() && !value.isMissing() + (tiers.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single tiered with proration tier */ + class Tier + private constructor( + private val tierLowerBound: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(tierLowerBound, unitAmount, mutableMapOf()) + + /** + * Inclusive tier starting value + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun tierLowerBound(): String = + tierLowerBound.getRequired("tier_lower_bound") + + /** + * Amount per unit + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Tier]. + * + * The following fields are required: + * ```kotlin + * .tierLowerBound() + * .unitAmount() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var tierLowerBound: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(tier: Tier) = apply { + tierLowerBound = tier.tierLowerBound + unitAmount = tier.unitAmount + additionalProperties = tier.additionalProperties.toMutableMap() + } + + /** Inclusive tier starting value */ + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + /** Amount per unit */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```kotlin + * .tierLowerBound() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("tierLowerBound", tierLowerBound), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + tierLowerBound() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (tierLowerBound.asKnown() == null) 0 else 1) + + (if (unitAmount.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + tierLowerBound == other.tierLowerBound && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(tierLowerBound, unitAmount, additionalProperties) } + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is GroupedWithMinMaxThresholdsConfig && + return other is TieredWithProrationConfig && + tiers == other.tiers && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(tiers, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "GroupedWithMinMaxThresholdsConfig{additionalProperties=$additionalProperties}" + "TieredWithProrationConfig{tiers=$tiers, additionalProperties=$additionalProperties}" } /** @@ -7081,13 +7361,12 @@ private constructor( return true } - return other is GroupedWithMinMaxThresholds && + return other is TieredWithProration && cadence == other.cadence && - groupedWithMinMaxThresholdsConfig == - other.groupedWithMinMaxThresholdsConfig && itemId == other.itemId && modelType == other.modelType && name == other.name && + tieredWithProrationConfig == other.tieredWithProrationConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && @@ -7107,10 +7386,10 @@ private constructor( private val hashCode: Int by lazy { Objects.hash( cadence, - groupedWithMinMaxThresholdsConfig, itemId, modelType, name, + tieredWithProrationConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -7131,1679 +7410,1967 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "GroupedWithMinMaxThresholds{cadence=$cadence, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + "TieredWithProration{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredWithProrationConfig=$tieredWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - return other is AddPrice && - allocationPrice == other.allocationPrice && - discounts == other.discounts && - endDate == other.endDate && - externalPriceId == other.externalPriceId && - maximumAmount == other.maximumAmount && - minimumAmount == other.minimumAmount && - planPhaseOrder == other.planPhaseOrder && - price == other.price && - priceId == other.priceId && - startDate == other.startDate && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - allocationPrice, - discounts, - endDate, - externalPriceId, - maximumAmount, - minimumAmount, - planPhaseOrder, - price, - priceId, - startDate, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "AddPrice{allocationPrice=$allocationPrice, discounts=$discounts, endDate=$endDate, externalPriceId=$externalPriceId, maximumAmount=$maximumAmount, minimumAmount=$minimumAmount, planPhaseOrder=$planPhaseOrder, price=$price, priceId=$priceId, startDate=$startDate, additionalProperties=$additionalProperties}" - } - - /** - * Reset billing periods to be aligned with the plan change's effective date or start of the - * month. Defaults to `unchanged` which keeps subscription's existing billing cycle alignment. - */ - class BillingCycleAlignment - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API may respond with new members that the SDK is - * unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - val UNCHANGED = of("unchanged") - - val PLAN_CHANGE_DATE = of("plan_change_date") - - val START_OF_MONTH = of("start_of_month") - - fun of(value: String) = BillingCycleAlignment(JsonField.of(value)) - } - - /** An enum containing [BillingCycleAlignment]'s known values. */ - enum class Known { - UNCHANGED, - PLAN_CHANGE_DATE, - START_OF_MONTH, - } + class GroupedWithMinMaxThresholds + private constructor( + private val cadence: JsonField, + private val groupedWithMinMaxThresholdsConfig: + JsonField, + private val itemId: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { - /** - * An enum containing [BillingCycleAlignment]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [BillingCycleAlignment] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if the - * SDK is on an older version than the API, then the API may respond with new members that - * the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - UNCHANGED, - PLAN_CHANGE_DATE, - START_OF_MONTH, - /** - * An enum member indicating that [BillingCycleAlignment] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you want - * to throw for the unknown case. - */ - fun value(): Value = - when (this) { - UNCHANGED -> Value.UNCHANGED - PLAN_CHANGE_DATE -> Value.PLAN_CHANGE_DATE - START_OF_MONTH -> Value.START_OF_MONTH - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and don't - * want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known member. - */ - fun known(): Known = - when (this) { - UNCHANGED -> Known.UNCHANGED - PLAN_CHANGE_DATE -> Known.PLAN_CHANGE_DATE - START_OF_MONTH -> Known.START_OF_MONTH - else -> throw OrbInvalidDataException("Unknown BillingCycleAlignment: $value") - } + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("grouped_with_min_max_thresholds_config") + @ExcludeMissing + groupedWithMinMaxThresholdsConfig: + JsonField = + JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + groupedWithMinMaxThresholdsConfig, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + mutableMapOf(), + ) - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the expected - * primitive type. - */ - fun asString(): String = - _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") - private var validated: Boolean = false + /** + * Configuration for grouped_with_min_max_thresholds pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupedWithMinMaxThresholdsConfig(): GroupedWithMinMaxThresholdsConfig = + groupedWithMinMaxThresholdsConfig.getRequired( + "grouped_with_min_max_thresholds_config" + ) - fun validate(): BillingCycleAlignment = apply { - if (validated) { - return@apply - } + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") - known() - validated = true - } + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("grouped_with_min_max_thresholds") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = billableMetricId.getNullable("billable_metric_id") - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") - return other is BillingCycleAlignment && value == other.value - } + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") - override fun hashCode() = value.hashCode() + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") - override fun toString() = value.toString() - } + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") - class RemoveAdjustment - private constructor( - private val adjustmentId: JsonField, - private val additionalProperties: MutableMap, - ) { + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") - @JsonCreator - private constructor( - @JsonProperty("adjustment_id") - @ExcludeMissing - adjustmentId: JsonField = JsonMissing.of() - ) : this(adjustmentId, mutableMapOf()) + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") - /** - * The id of the adjustment to remove on the subscription. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun adjustmentId(): String = adjustmentId.getRequired("adjustment_id") + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") - /** - * Returns the raw JSON value of [adjustmentId]. - * - * Unlike [adjustmentId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("adjustment_id") - @ExcludeMissing - fun _adjustmentId(): JsonField = adjustmentId + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + invoiceGroupingKey.getNullable("invoice_grouping_key") - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - fun toBuilder() = Builder().from(this) + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") - companion object { + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") - /** - * Returns a mutable builder for constructing an instance of [RemoveAdjustment]. - * - * The following fields are required: - * ```kotlin - * .adjustmentId() - * ``` - */ - fun builder() = Builder() - } + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence - /** A builder for [RemoveAdjustment]. */ - class Builder internal constructor() { + /** + * Returns the raw JSON value of [groupedWithMinMaxThresholdsConfig]. + * + * Unlike [groupedWithMinMaxThresholdsConfig], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("grouped_with_min_max_thresholds_config") + @ExcludeMissing + fun _groupedWithMinMaxThresholdsConfig(): + JsonField = groupedWithMinMaxThresholdsConfig - private var adjustmentId: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - internal fun from(removeAdjustment: RemoveAdjustment) = apply { - adjustmentId = removeAdjustment.adjustmentId - additionalProperties = removeAdjustment.additionalProperties.toMutableMap() - } + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - /** The id of the adjustment to remove on the subscription. */ - fun adjustmentId(adjustmentId: String) = adjustmentId(JsonField.of(adjustmentId)) + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId - /** - * Sets [Builder.adjustmentId] to an arbitrary JSON value. - * - * You should usually call [Builder.adjustmentId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun adjustmentId(adjustmentId: JsonField) = apply { - this.adjustmentId = adjustmentId - } + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration - /** - * Returns an immutable instance of [RemoveAdjustment]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```kotlin - * .adjustmentId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): RemoveAdjustment = - RemoveAdjustment( - checkRequired("adjustmentId", adjustmentId), - additionalProperties.toMutableMap(), - ) - } + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId - private var validated: Boolean = false + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - fun validate(): RemoveAdjustment = apply { - if (validated) { - return@apply - } + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - adjustmentId() - validated = true - } + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = (if (adjustmentId.asKnown() == null) 0 else 1) + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - return other is RemoveAdjustment && - adjustmentId == other.adjustmentId && - additionalProperties == other.additionalProperties - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - private val hashCode: Int by lazy { Objects.hash(adjustmentId, additionalProperties) } + fun toBuilder() = Builder().from(this) - override fun hashCode(): Int = hashCode + companion object { - override fun toString() = - "RemoveAdjustment{adjustmentId=$adjustmentId, additionalProperties=$additionalProperties}" - } + /** + * Returns a mutable builder for constructing an instance of + * [GroupedWithMinMaxThresholds]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .groupedWithMinMaxThresholdsConfig() + * .itemId() + * .name() + * ``` + */ + fun builder() = Builder() + } - class RemovePrice - private constructor( - private val externalPriceId: JsonField, - private val priceId: JsonField, - private val additionalProperties: MutableMap, - ) { + /** A builder for [GroupedWithMinMaxThresholds]. */ + class Builder internal constructor() { - @JsonCreator - private constructor( - @JsonProperty("external_price_id") - @ExcludeMissing - externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("price_id") @ExcludeMissing priceId: JsonField = JsonMissing.of(), - ) : this(externalPriceId, priceId, mutableMapOf()) + private var cadence: JsonField? = null + private var groupedWithMinMaxThresholdsConfig: + JsonField? = + null + private var itemId: JsonField? = null + private var modelType: JsonValue = + JsonValue.from("grouped_with_min_max_thresholds") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - /** - * The external price id of the price to remove on the subscription. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + internal fun from(groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds) = + apply { + cadence = groupedWithMinMaxThresholds.cadence + groupedWithMinMaxThresholdsConfig = + groupedWithMinMaxThresholds.groupedWithMinMaxThresholdsConfig + itemId = groupedWithMinMaxThresholds.itemId + modelType = groupedWithMinMaxThresholds.modelType + name = groupedWithMinMaxThresholds.name + billableMetricId = groupedWithMinMaxThresholds.billableMetricId + billedInAdvance = groupedWithMinMaxThresholds.billedInAdvance + billingCycleConfiguration = + groupedWithMinMaxThresholds.billingCycleConfiguration + conversionRate = groupedWithMinMaxThresholds.conversionRate + conversionRateConfig = groupedWithMinMaxThresholds.conversionRateConfig + currency = groupedWithMinMaxThresholds.currency + dimensionalPriceConfiguration = + groupedWithMinMaxThresholds.dimensionalPriceConfiguration + externalPriceId = groupedWithMinMaxThresholds.externalPriceId + fixedPriceQuantity = groupedWithMinMaxThresholds.fixedPriceQuantity + invoiceGroupingKey = groupedWithMinMaxThresholds.invoiceGroupingKey + invoicingCycleConfiguration = + groupedWithMinMaxThresholds.invoicingCycleConfiguration + metadata = groupedWithMinMaxThresholds.metadata + referenceId = groupedWithMinMaxThresholds.referenceId + additionalProperties = + groupedWithMinMaxThresholds.additionalProperties.toMutableMap() + } - /** - * The id of the price to remove on the subscription. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun priceId(): String? = priceId.getNullable("price_id") + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - /** - * Returns the raw JSON value of [externalPriceId]. - * - * Unlike [externalPriceId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - /** - * Returns the raw JSON value of [priceId]. - * - * Unlike [priceId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId + /** Configuration for grouped_with_min_max_thresholds pricing */ + fun groupedWithMinMaxThresholdsConfig( + groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + ) = + groupedWithMinMaxThresholdsConfig( + JsonField.of(groupedWithMinMaxThresholdsConfig) + ) - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** + * Sets [Builder.groupedWithMinMaxThresholdsConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.groupedWithMinMaxThresholdsConfig] with a + * well-typed [GroupedWithMinMaxThresholdsConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun groupedWithMinMaxThresholdsConfig( + groupedWithMinMaxThresholdsConfig: + JsonField + ) = apply { + this.groupedWithMinMaxThresholdsConfig = groupedWithMinMaxThresholdsConfig + } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - fun toBuilder() = Builder().from(this) + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - companion object { + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("grouped_with_min_max_thresholds") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } - /** Returns a mutable builder for constructing an instance of [RemovePrice]. */ - fun builder() = Builder() - } + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) - /** A builder for [RemovePrice]. */ - class Builder internal constructor() { + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } - private var externalPriceId: JsonField = JsonMissing.of() - private var priceId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) - internal fun from(removePrice: RemovePrice) = apply { - externalPriceId = removePrice.externalPriceId - priceId = removePrice.priceId - additionalProperties = removePrice.additionalProperties.toMutableMap() - } + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } - /** The external price id of the price to remove on the subscription. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) - /** - * Sets [Builder.externalPriceId] to an arbitrary JSON value. - * - * You should usually call [Builder.externalPriceId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun externalPriceId(externalPriceId: JsonField) = apply { - this.externalPriceId = externalPriceId - } + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) - /** The id of the price to remove on the subscription. */ - fun priceId(priceId: String?) = priceId(JsonField.ofNullable(priceId)) + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } - /** - * Sets [Builder.priceId] to an arbitrary JSON value. - * - * You should usually call [Builder.priceId] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun priceId(priceId: JsonField) = apply { this.priceId = priceId } + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) - /** - * Returns an immutable instance of [RemovePrice]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): RemovePrice = - RemovePrice(externalPriceId, priceId, additionalProperties.toMutableMap()) - } + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } - private var validated: Boolean = false + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) - fun validate(): RemovePrice = apply { - if (validated) { - return@apply - } + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) - externalPriceId() - priceId() - validated = true - } + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (if (externalPriceId.asKnown() == null) 0 else 1) + - (if (priceId.asKnown() == null) 0 else 1) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) - return other is RemovePrice && - externalPriceId == other.externalPriceId && - priceId == other.priceId && - additionalProperties == other.additionalProperties - } + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } - private val hashCode: Int by lazy { - Objects.hash(externalPriceId, priceId, additionalProperties) - } + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) - override fun hashCode(): Int = hashCode + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } - override fun toString() = - "RemovePrice{externalPriceId=$externalPriceId, priceId=$priceId, additionalProperties=$additionalProperties}" - } + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) - class ReplaceAdjustment - private constructor( - private val adjustment: JsonField, - private val replacesAdjustmentId: JsonField, - private val additionalProperties: MutableMap, - ) { + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } - @JsonCreator - private constructor( - @JsonProperty("adjustment") - @ExcludeMissing - adjustment: JsonField = JsonMissing.of(), - @JsonProperty("replaces_adjustment_id") - @ExcludeMissing - replacesAdjustmentId: JsonField = JsonMissing.of(), - ) : this(adjustment, replacesAdjustmentId, mutableMapOf()) + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) - /** - * The definition of a new adjustment to create and add to the subscription. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun adjustment(): Adjustment = adjustment.getRequired("adjustment") + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) - /** - * The id of the adjustment on the plan to replace in the subscription. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun replacesAdjustmentId(): String = - replacesAdjustmentId.getRequired("replaces_adjustment_id") + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } - /** - * Returns the raw JSON value of [adjustment]. - * - * Unlike [adjustment], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("adjustment") - @ExcludeMissing - fun _adjustment(): JsonField = adjustment + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) - /** - * Returns the raw JSON value of [replacesAdjustmentId]. - * - * Unlike [replacesAdjustmentId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("replaces_adjustment_id") - @ExcludeMissing - fun _replacesAdjustmentId(): JsonField = replacesAdjustmentId + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - fun toBuilder() = Builder().from(this) + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - companion object { + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - /** - * Returns a mutable builder for constructing an instance of [ReplaceAdjustment]. - * - * The following fields are required: - * ```kotlin - * .adjustment() - * .replacesAdjustmentId() - * ``` - */ - fun builder() = Builder() - } + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) - /** A builder for [ReplaceAdjustment]. */ - class Builder internal constructor() { + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } - private var adjustment: JsonField? = null - private var replacesAdjustmentId: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - internal fun from(replaceAdjustment: ReplaceAdjustment) = apply { - adjustment = replaceAdjustment.adjustment - replacesAdjustmentId = replaceAdjustment.replacesAdjustmentId - additionalProperties = replaceAdjustment.additionalProperties.toMutableMap() - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** The definition of a new adjustment to create and add to the subscription. */ - fun adjustment(adjustment: Adjustment) = adjustment(JsonField.of(adjustment)) + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - /** - * Sets [Builder.adjustment] to an arbitrary JSON value. - * - * You should usually call [Builder.adjustment] with a well-typed [Adjustment] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun adjustment(adjustment: JsonField) = apply { - this.adjustment = adjustment - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - /** - * Alias for calling [adjustment] with - * `Adjustment.ofPercentageDiscount(percentageDiscount)`. - */ - fun adjustment(percentageDiscount: NewPercentageDiscount) = - adjustment(Adjustment.ofPercentageDiscount(percentageDiscount)) + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - /** - * Alias for calling [adjustment] with the following: - * ```kotlin - * NewPercentageDiscount.builder() - * .adjustmentType(NewPercentageDiscount.AdjustmentType.PERCENTAGE_DISCOUNT) - * .percentageDiscount(percentageDiscount) - * .build() - * ``` - */ - fun percentageDiscountAdjustment(percentageDiscount: Double) = - adjustment( - NewPercentageDiscount.builder() - .adjustmentType(NewPercentageDiscount.AdjustmentType.PERCENTAGE_DISCOUNT) - .percentageDiscount(percentageDiscount) - .build() - ) + /** + * Returns an immutable instance of [GroupedWithMinMaxThresholds]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .groupedWithMinMaxThresholdsConfig() + * .itemId() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedWithMinMaxThresholds = + GroupedWithMinMaxThresholds( + checkRequired("cadence", cadence), + checkRequired( + "groupedWithMinMaxThresholdsConfig", + groupedWithMinMaxThresholdsConfig, + ), + checkRequired("itemId", itemId), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } - /** Alias for calling [adjustment] with `Adjustment.ofUsageDiscount(usageDiscount)`. */ - fun adjustment(usageDiscount: NewUsageDiscount) = - adjustment(Adjustment.ofUsageDiscount(usageDiscount)) + private var validated: Boolean = false - /** - * Alias for calling [adjustment] with the following: - * ```kotlin - * NewUsageDiscount.builder() - * .adjustmentType(NewUsageDiscount.AdjustmentType.USAGE_DISCOUNT) - * .usageDiscount(usageDiscount) - * .build() - * ``` - */ - fun usageDiscountAdjustment(usageDiscount: Double) = - adjustment( - NewUsageDiscount.builder() - .adjustmentType(NewUsageDiscount.AdjustmentType.USAGE_DISCOUNT) - .usageDiscount(usageDiscount) - .build() - ) + fun validate(): GroupedWithMinMaxThresholds = apply { + if (validated) { + return@apply + } - /** - * Alias for calling [adjustment] with `Adjustment.ofAmountDiscount(amountDiscount)`. - */ - fun adjustment(amountDiscount: NewAmountDiscount) = - adjustment(Adjustment.ofAmountDiscount(amountDiscount)) + cadence().validate() + groupedWithMinMaxThresholdsConfig().validate() + itemId() + _modelType().let { + if (it != JsonValue.from("grouped_with_min_max_thresholds")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + metadata()?.validate() + referenceId() + validated = true + } - /** - * Alias for calling [adjustment] with the following: - * ```kotlin - * NewAmountDiscount.builder() - * .adjustmentType(NewAmountDiscount.AdjustmentType.AMOUNT_DISCOUNT) - * .amountDiscount(amountDiscount) - * .build() - * ``` - */ - fun amountDiscountAdjustment(amountDiscount: String) = - adjustment( - NewAmountDiscount.builder() - .adjustmentType(NewAmountDiscount.AdjustmentType.AMOUNT_DISCOUNT) - .amountDiscount(amountDiscount) - .build() - ) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - /** Alias for calling [adjustment] with `Adjustment.ofMinimum(minimum)`. */ - fun adjustment(minimum: NewMinimum) = adjustment(Adjustment.ofMinimum(minimum)) + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (groupedWithMinMaxThresholdsConfig.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + modelType.let { + if (it == JsonValue.from("grouped_with_min_max_thresholds")) 1 else 0 + } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) - /** Alias for calling [adjustment] with `Adjustment.ofMaximum(maximum)`. */ - fun adjustment(maximum: NewMaximum) = adjustment(Adjustment.ofMaximum(maximum)) + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { - /** - * Alias for calling [adjustment] with the following: - * ```kotlin - * NewMaximum.builder() - * .adjustmentType(NewMaximum.AdjustmentType.MAXIMUM) - * .maximumAmount(maximumAmount) - * .build() - * ``` - */ - fun maximumAdjustment(maximumAmount: String) = - adjustment( - NewMaximum.builder() - .adjustmentType(NewMaximum.AdjustmentType.MAXIMUM) - .maximumAmount(maximumAmount) - .build() - ) + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value - /** The id of the adjustment on the plan to replace in the subscription. */ - fun replacesAdjustmentId(replacesAdjustmentId: String) = - replacesAdjustmentId(JsonField.of(replacesAdjustmentId)) + companion object { - /** - * Sets [Builder.replacesAdjustmentId] to an arbitrary JSON value. - * - * You should usually call [Builder.replacesAdjustmentId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun replacesAdjustmentId(replacesAdjustmentId: JsonField) = apply { - this.replacesAdjustmentId = replacesAdjustmentId - } + val ANNUAL = of("annual") - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + val SEMI_ANNUAL = of("semi_annual") - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + val MONTHLY = of("monthly") - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + val QUARTERLY = of("quarterly") - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + val ONE_TIME = of("one_time") - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + val CUSTOM = of("custom") - /** - * Returns an immutable instance of [ReplaceAdjustment]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```kotlin - * .adjustment() - * .replacesAdjustmentId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): ReplaceAdjustment = - ReplaceAdjustment( - checkRequired("adjustment", adjustment), - checkRequired("replacesAdjustmentId", replacesAdjustmentId), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false + fun of(value: String) = Cadence(JsonField.of(value)) + } - fun validate(): ReplaceAdjustment = apply { - if (validated) { - return@apply - } + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } - adjustment().validate() - replacesAdjustmentId() - validated = true - } + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (adjustment.asKnown()?.validity() ?: 0) + - (if (replacesAdjustmentId.asKnown() == null) 0 else 1) + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } - /** The definition of a new adjustment to create and add to the subscription. */ - @JsonDeserialize(using = Adjustment.Deserializer::class) - @JsonSerialize(using = Adjustment.Serializer::class) - class Adjustment - private constructor( - private val percentageDiscount: NewPercentageDiscount? = null, - private val usageDiscount: NewUsageDiscount? = null, - private val amountDiscount: NewAmountDiscount? = null, - private val minimum: NewMinimum? = null, - private val maximum: NewMaximum? = null, - private val _json: JsonValue? = null, - ) { + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") - fun percentageDiscount(): NewPercentageDiscount? = percentageDiscount + private var validated: Boolean = false - fun usageDiscount(): NewUsageDiscount? = usageDiscount + fun validate(): Cadence = apply { + if (validated) { + return@apply + } - fun amountDiscount(): NewAmountDiscount? = amountDiscount + known() + validated = true + } - fun minimum(): NewMinimum? = minimum + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - fun maximum(): NewMaximum? = maximum + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - fun isPercentageDiscount(): Boolean = percentageDiscount != null + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun isUsageDiscount(): Boolean = usageDiscount != null + return other is Cadence && value == other.value + } - fun isAmountDiscount(): Boolean = amountDiscount != null + override fun hashCode() = value.hashCode() - fun isMinimum(): Boolean = minimum != null + override fun toString() = value.toString() + } - fun isMaximum(): Boolean = maximum != null + /** Configuration for grouped_with_min_max_thresholds pricing */ + class GroupedWithMinMaxThresholdsConfig + private constructor( + private val groupingKey: JsonField, + private val maximumCharge: JsonField, + private val minimumCharge: JsonField, + private val perUnitRate: JsonField, + private val additionalProperties: MutableMap, + ) { - fun asPercentageDiscount(): NewPercentageDiscount = - percentageDiscount.getOrThrow("percentageDiscount") + @JsonCreator + private constructor( + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("maximum_charge") + @ExcludeMissing + maximumCharge: JsonField = JsonMissing.of(), + @JsonProperty("minimum_charge") + @ExcludeMissing + minimumCharge: JsonField = JsonMissing.of(), + @JsonProperty("per_unit_rate") + @ExcludeMissing + perUnitRate: JsonField = JsonMissing.of(), + ) : this(groupingKey, maximumCharge, minimumCharge, perUnitRate, mutableMapOf()) - fun asUsageDiscount(): NewUsageDiscount = usageDiscount.getOrThrow("usageDiscount") + /** + * The event property used to group before applying thresholds + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") - fun asAmountDiscount(): NewAmountDiscount = amountDiscount.getOrThrow("amountDiscount") + /** + * The maximum amount to charge each group + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun maximumCharge(): String = maximumCharge.getRequired("maximum_charge") - fun asMinimum(): NewMinimum = minimum.getOrThrow("minimum") + /** + * The minimum amount to charge each group, regardless of usage + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun minimumCharge(): String = minimumCharge.getRequired("minimum_charge") - fun asMaximum(): NewMaximum = maximum.getOrThrow("maximum") + /** + * The base price charged per group + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun perUnitRate(): String = perUnitRate.getRequired("per_unit_rate") - fun _json(): JsonValue? = _json + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey - fun accept(visitor: Visitor): T = - when { - percentageDiscount != null -> - visitor.visitPercentageDiscount(percentageDiscount) - usageDiscount != null -> visitor.visitUsageDiscount(usageDiscount) - amountDiscount != null -> visitor.visitAmountDiscount(amountDiscount) - minimum != null -> visitor.visitMinimum(minimum) - maximum != null -> visitor.visitMaximum(maximum) - else -> visitor.unknown(_json) - } + /** + * Returns the raw JSON value of [maximumCharge]. + * + * Unlike [maximumCharge], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("maximum_charge") + @ExcludeMissing + fun _maximumCharge(): JsonField = maximumCharge - private var validated: Boolean = false + /** + * Returns the raw JSON value of [minimumCharge]. + * + * Unlike [minimumCharge], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("minimum_charge") + @ExcludeMissing + fun _minimumCharge(): JsonField = minimumCharge - fun validate(): Adjustment = apply { - if (validated) { - return@apply - } + /** + * Returns the raw JSON value of [perUnitRate]. + * + * Unlike [perUnitRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("per_unit_rate") + @ExcludeMissing + fun _perUnitRate(): JsonField = perUnitRate - accept( - object : Visitor { - override fun visitPercentageDiscount( - percentageDiscount: NewPercentageDiscount - ) { - percentageDiscount.validate() - } + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - override fun visitUsageDiscount(usageDiscount: NewUsageDiscount) { - usageDiscount.validate() - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - override fun visitAmountDiscount(amountDiscount: NewAmountDiscount) { - amountDiscount.validate() - } + fun toBuilder() = Builder().from(this) - override fun visitMinimum(minimum: NewMinimum) { - minimum.validate() - } + companion object { - override fun visitMaximum(maximum: NewMaximum) { - maximum.validate() - } + /** + * Returns a mutable builder for constructing an instance of + * [GroupedWithMinMaxThresholdsConfig]. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .maximumCharge() + * .minimumCharge() + * .perUnitRate() + * ``` + */ + fun builder() = Builder() } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitPercentageDiscount( - percentageDiscount: NewPercentageDiscount - ) = percentageDiscount.validity() - - override fun visitUsageDiscount(usageDiscount: NewUsageDiscount) = - usageDiscount.validity() + /** A builder for [GroupedWithMinMaxThresholdsConfig]. */ + class Builder internal constructor() { - override fun visitAmountDiscount(amountDiscount: NewAmountDiscount) = - amountDiscount.validity() + private var groupingKey: JsonField? = null + private var maximumCharge: JsonField? = null + private var minimumCharge: JsonField? = null + private var perUnitRate: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() - override fun visitMinimum(minimum: NewMinimum) = minimum.validity() + internal fun from( + groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + ) = apply { + groupingKey = groupedWithMinMaxThresholdsConfig.groupingKey + maximumCharge = groupedWithMinMaxThresholdsConfig.maximumCharge + minimumCharge = groupedWithMinMaxThresholdsConfig.minimumCharge + perUnitRate = groupedWithMinMaxThresholdsConfig.perUnitRate + additionalProperties = + groupedWithMinMaxThresholdsConfig.additionalProperties + .toMutableMap() + } - override fun visitMaximum(maximum: NewMaximum) = maximum.validity() + /** The event property used to group before applying thresholds */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) - override fun unknown(json: JsonValue?) = 0 - } - ) + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** The maximum amount to charge each group */ + fun maximumCharge(maximumCharge: String) = + maximumCharge(JsonField.of(maximumCharge)) - return other is Adjustment && - percentageDiscount == other.percentageDiscount && - usageDiscount == other.usageDiscount && - amountDiscount == other.amountDiscount && - minimum == other.minimum && - maximum == other.maximum - } + /** + * Sets [Builder.maximumCharge] to an arbitrary JSON value. + * + * You should usually call [Builder.maximumCharge] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun maximumCharge(maximumCharge: JsonField) = apply { + this.maximumCharge = maximumCharge + } - override fun hashCode(): Int = - Objects.hash(percentageDiscount, usageDiscount, amountDiscount, minimum, maximum) + /** The minimum amount to charge each group, regardless of usage */ + fun minimumCharge(minimumCharge: String) = + minimumCharge(JsonField.of(minimumCharge)) - override fun toString(): String = - when { - percentageDiscount != null -> - "Adjustment{percentageDiscount=$percentageDiscount}" - usageDiscount != null -> "Adjustment{usageDiscount=$usageDiscount}" - amountDiscount != null -> "Adjustment{amountDiscount=$amountDiscount}" - minimum != null -> "Adjustment{minimum=$minimum}" - maximum != null -> "Adjustment{maximum=$maximum}" - _json != null -> "Adjustment{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Adjustment") - } + /** + * Sets [Builder.minimumCharge] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumCharge] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun minimumCharge(minimumCharge: JsonField) = apply { + this.minimumCharge = minimumCharge + } - companion object { + /** The base price charged per group */ + fun perUnitRate(perUnitRate: String) = + perUnitRate(JsonField.of(perUnitRate)) - fun ofPercentageDiscount(percentageDiscount: NewPercentageDiscount) = - Adjustment(percentageDiscount = percentageDiscount) + /** + * Sets [Builder.perUnitRate] to an arbitrary JSON value. + * + * You should usually call [Builder.perUnitRate] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun perUnitRate(perUnitRate: JsonField) = apply { + this.perUnitRate = perUnitRate + } - fun ofUsageDiscount(usageDiscount: NewUsageDiscount) = - Adjustment(usageDiscount = usageDiscount) + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun ofAmountDiscount(amountDiscount: NewAmountDiscount) = - Adjustment(amountDiscount = amountDiscount) + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun ofMinimum(minimum: NewMinimum) = Adjustment(minimum = minimum) + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun ofMaximum(maximum: NewMaximum) = Adjustment(maximum = maximum) - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - /** - * An interface that defines how to map each variant of [Adjustment] to a value of type - * [T]. - */ - interface Visitor { + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - fun visitPercentageDiscount(percentageDiscount: NewPercentageDiscount): T + /** + * Returns an immutable instance of [GroupedWithMinMaxThresholdsConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .maximumCharge() + * .minimumCharge() + * .perUnitRate() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedWithMinMaxThresholdsConfig = + GroupedWithMinMaxThresholdsConfig( + checkRequired("groupingKey", groupingKey), + checkRequired("maximumCharge", maximumCharge), + checkRequired("minimumCharge", minimumCharge), + checkRequired("perUnitRate", perUnitRate), + additionalProperties.toMutableMap(), + ) + } - fun visitUsageDiscount(usageDiscount: NewUsageDiscount): T + private var validated: Boolean = false - fun visitAmountDiscount(amountDiscount: NewAmountDiscount): T + fun validate(): GroupedWithMinMaxThresholdsConfig = apply { + if (validated) { + return@apply + } - fun visitMinimum(minimum: NewMinimum): T + groupingKey() + maximumCharge() + minimumCharge() + perUnitRate() + validated = true + } - fun visitMaximum(maximum: NewMaximum): T + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - /** - * Maps an unknown variant of [Adjustment] to a value of type [T]. - * - * An instance of [Adjustment] can contain an unknown variant if it was deserialized - * from data that doesn't match any known variant. For example, if the SDK is on an - * older version than the API, then the API may respond with new variants that the - * SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown Adjustment: $json") - } - } + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (groupingKey.asKnown() == null) 0 else 1) + + (if (maximumCharge.asKnown() == null) 0 else 1) + + (if (minimumCharge.asKnown() == null) 0 else 1) + + (if (perUnitRate.asKnown() == null) 0 else 1) - internal class Deserializer : BaseDeserializer(Adjustment::class) { + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - override fun ObjectCodec.deserialize(node: JsonNode): Adjustment { - val json = JsonValue.fromJsonNode(node) - val adjustmentType = json.asObject()?.get("adjustment_type")?.asString() + return other is GroupedWithMinMaxThresholdsConfig && + groupingKey == other.groupingKey && + maximumCharge == other.maximumCharge && + minimumCharge == other.minimumCharge && + perUnitRate == other.perUnitRate && + additionalProperties == other.additionalProperties + } - when (adjustmentType) { - "percentage_discount" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Adjustment(percentageDiscount = it, _json = json) } - ?: Adjustment(_json = json) - } - "usage_discount" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(usageDiscount = it, _json = json) - } ?: Adjustment(_json = json) - } - "amount_discount" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(amountDiscount = it, _json = json) - } ?: Adjustment(_json = json) - } - "minimum" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(minimum = it, _json = json) - } ?: Adjustment(_json = json) - } - "maximum" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(maximum = it, _json = json) - } ?: Adjustment(_json = json) - } + private val hashCode: Int by lazy { + Objects.hash( + groupingKey, + maximumCharge, + minimumCharge, + perUnitRate, + additionalProperties, + ) } - return Adjustment(_json = json) - } - } + override fun hashCode(): Int = hashCode - internal class Serializer : BaseSerializer(Adjustment::class) { + override fun toString() = + "GroupedWithMinMaxThresholdsConfig{groupingKey=$groupingKey, maximumCharge=$maximumCharge, minimumCharge=$minimumCharge, perUnitRate=$perUnitRate, additionalProperties=$additionalProperties}" + } - override fun serialize( - value: Adjustment, - generator: JsonGenerator, - provider: SerializerProvider, + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map ) { - when { - value.percentageDiscount != null -> - generator.writeObject(value.percentageDiscount) - value.usageDiscount != null -> generator.writeObject(value.usageDiscount) - value.amountDiscount != null -> generator.writeObject(value.amountDiscount) - value.minimum != null -> generator.writeObject(value.minimum) - value.maximum != null -> generator.writeObject(value.maximum) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Adjustment") - } - } - } - } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties - return other is ReplaceAdjustment && - adjustment == other.adjustment && - replacesAdjustmentId == other.replacesAdjustmentId && - additionalProperties == other.additionalProperties - } + fun toBuilder() = Builder().from(this) - private val hashCode: Int by lazy { - Objects.hash(adjustment, replacesAdjustmentId, additionalProperties) - } + companion object { - override fun hashCode(): Int = hashCode + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } - override fun toString() = - "ReplaceAdjustment{adjustment=$adjustment, replacesAdjustmentId=$replacesAdjustmentId, additionalProperties=$additionalProperties}" - } + /** A builder for [Metadata]. */ + class Builder internal constructor() { - class ReplacePrice - private constructor( - private val replacesPriceId: JsonField, - private val allocationPrice: JsonField, - private val discounts: JsonField>, - private val externalPriceId: JsonField, - private val fixedPriceQuantity: JsonField, - private val maximumAmount: JsonField, - private val minimumAmount: JsonField, - private val price: JsonField, - private val priceId: JsonField, - private val additionalProperties: MutableMap, - ) { + private var additionalProperties: MutableMap = + mutableMapOf() - @JsonCreator - private constructor( - @JsonProperty("replaces_price_id") - @ExcludeMissing - replacesPriceId: JsonField = JsonMissing.of(), - @JsonProperty("allocation_price") - @ExcludeMissing - allocationPrice: JsonField = JsonMissing.of(), - @JsonProperty("discounts") - @ExcludeMissing - discounts: JsonField> = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("maximum_amount") - @ExcludeMissing - maximumAmount: JsonField = JsonMissing.of(), - @JsonProperty("minimum_amount") - @ExcludeMissing - minimumAmount: JsonField = JsonMissing.of(), - @JsonProperty("price") @ExcludeMissing price: JsonField = JsonMissing.of(), - @JsonProperty("price_id") @ExcludeMissing priceId: JsonField = JsonMissing.of(), - ) : this( - replacesPriceId, - allocationPrice, - discounts, - externalPriceId, - fixedPriceQuantity, - maximumAmount, - minimumAmount, - price, - priceId, - mutableMapOf(), - ) + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } - /** - * The id of the price on the plan to replace in the subscription. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun replacesPriceId(): String = replacesPriceId.getRequired("replaces_price_id") + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** - * The definition of a new allocation price to create and add to the subscription. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun allocationPrice(): NewAllocationPrice? = allocationPrice.getNullable("allocation_price") + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * [DEPRECATED] Use add_adjustments instead. The subscription's discounts for the - * replacement price. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - @Deprecated("deprecated") - fun discounts(): List? = discounts.getNullable("discounts") + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - /** - * The external price id of the price to add to the subscription. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - /** - * The new quantity of the price, if the price is a fixed price. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun fixedPriceQuantity(): Double? = fixedPriceQuantity.getNullable("fixed_price_quantity") + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - /** - * [DEPRECATED] Use add_adjustments instead. The subscription's maximum amount for the - * replacement price. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - @Deprecated("deprecated") - fun maximumAmount(): String? = maximumAmount.getNullable("maximum_amount") + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } - /** - * [DEPRECATED] Use add_adjustments instead. The subscription's minimum amount for the - * replacement price. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - @Deprecated("deprecated") - fun minimumAmount(): String? = minimumAmount.getNullable("minimum_amount") + private var validated: Boolean = false - /** - * The definition of a new price to create and add to the subscription. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun price(): Price? = price.getNullable("price") + fun validate(): Metadata = apply { + if (validated) { + return@apply + } - /** - * The id of the price to add to the subscription. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun priceId(): String? = priceId.getNullable("price_id") + validated = true + } - /** - * Returns the raw JSON value of [replacesPriceId]. - * - * Unlike [replacesPriceId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("replaces_price_id") - @ExcludeMissing - fun _replacesPriceId(): JsonField = replacesPriceId + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - /** - * Returns the raw JSON value of [allocationPrice]. - * - * Unlike [allocationPrice], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("allocation_price") - @ExcludeMissing - fun _allocationPrice(): JsonField = allocationPrice + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } - /** - * Returns the raw JSON value of [discounts]. - * - * Unlike [discounts], this method doesn't throw if the JSON field has an unexpected type. - */ - @Deprecated("deprecated") - @JsonProperty("discounts") - @ExcludeMissing - fun _discounts(): JsonField> = discounts + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * Returns the raw JSON value of [externalPriceId]. - * - * Unlike [externalPriceId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId + return other is Metadata && + additionalProperties == other.additionalProperties + } - /** - * Returns the raw JSON value of [fixedPriceQuantity]. - * - * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /** - * Returns the raw JSON value of [maximumAmount]. - * - * Unlike [maximumAmount], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @Deprecated("deprecated") - @JsonProperty("maximum_amount") - @ExcludeMissing - fun _maximumAmount(): JsonField = maximumAmount + override fun hashCode(): Int = hashCode - /** - * Returns the raw JSON value of [minimumAmount]. - * - * Unlike [minimumAmount], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @Deprecated("deprecated") - @JsonProperty("minimum_amount") - @ExcludeMissing - fun _minimumAmount(): JsonField = minimumAmount + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } - /** - * Returns the raw JSON value of [price]. - * - * Unlike [price], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("price") @ExcludeMissing fun _price(): JsonField = price + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * Returns the raw JSON value of [priceId]. - * - * Unlike [priceId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + return other is GroupedWithMinMaxThresholds && + cadence == other.cadence && + groupedWithMinMaxThresholdsConfig == + other.groupedWithMinMaxThresholdsConfig && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } - fun toBuilder() = Builder().from(this) + private val hashCode: Int by lazy { + Objects.hash( + cadence, + groupedWithMinMaxThresholdsConfig, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties, + ) + } - companion object { + override fun hashCode(): Int = hashCode - /** - * Returns a mutable builder for constructing an instance of [ReplacePrice]. - * - * The following fields are required: - * ```kotlin - * .replacesPriceId() - * ``` - */ - fun builder() = Builder() + override fun toString() = + "GroupedWithMinMaxThresholds{cadence=$cadence, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } } - /** A builder for [ReplacePrice]. */ - class Builder internal constructor() { + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - private var replacesPriceId: JsonField? = null - private var allocationPrice: JsonField = JsonMissing.of() - private var discounts: JsonField>? = null - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var maximumAmount: JsonField = JsonMissing.of() - private var minimumAmount: JsonField = JsonMissing.of() - private var price: JsonField = JsonMissing.of() - private var priceId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + return other is AddPrice && + allocationPrice == other.allocationPrice && + discounts == other.discounts && + endDate == other.endDate && + externalPriceId == other.externalPriceId && + maximumAmount == other.maximumAmount && + minimumAmount == other.minimumAmount && + planPhaseOrder == other.planPhaseOrder && + price == other.price && + priceId == other.priceId && + startDate == other.startDate && + additionalProperties == other.additionalProperties + } - internal fun from(replacePrice: ReplacePrice) = apply { - replacesPriceId = replacePrice.replacesPriceId - allocationPrice = replacePrice.allocationPrice - discounts = replacePrice.discounts.map { it.toMutableList() } - externalPriceId = replacePrice.externalPriceId - fixedPriceQuantity = replacePrice.fixedPriceQuantity - maximumAmount = replacePrice.maximumAmount - minimumAmount = replacePrice.minimumAmount - price = replacePrice.price - priceId = replacePrice.priceId - additionalProperties = replacePrice.additionalProperties.toMutableMap() - } + private val hashCode: Int by lazy { + Objects.hash( + allocationPrice, + discounts, + endDate, + externalPriceId, + maximumAmount, + minimumAmount, + planPhaseOrder, + price, + priceId, + startDate, + additionalProperties, + ) + } - /** The id of the price on the plan to replace in the subscription. */ - fun replacesPriceId(replacesPriceId: String) = - replacesPriceId(JsonField.of(replacesPriceId)) + override fun hashCode(): Int = hashCode - /** - * Sets [Builder.replacesPriceId] to an arbitrary JSON value. - * - * You should usually call [Builder.replacesPriceId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun replacesPriceId(replacesPriceId: JsonField) = apply { - this.replacesPriceId = replacesPriceId - } + override fun toString() = + "AddPrice{allocationPrice=$allocationPrice, discounts=$discounts, endDate=$endDate, externalPriceId=$externalPriceId, maximumAmount=$maximumAmount, minimumAmount=$minimumAmount, planPhaseOrder=$planPhaseOrder, price=$price, priceId=$priceId, startDate=$startDate, additionalProperties=$additionalProperties}" + } - /** The definition of a new allocation price to create and add to the subscription. */ - fun allocationPrice(allocationPrice: NewAllocationPrice?) = - allocationPrice(JsonField.ofNullable(allocationPrice)) + /** + * Reset billing periods to be aligned with the plan change's effective date or start of the + * month. Defaults to `unchanged` which keeps subscription's existing billing cycle alignment. + */ + class BillingCycleAlignment + @JsonCreator + private constructor(private val value: JsonField) : Enum { - /** - * Sets [Builder.allocationPrice] to an arbitrary JSON value. - * - * You should usually call [Builder.allocationPrice] with a well-typed - * [NewAllocationPrice] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun allocationPrice(allocationPrice: JsonField) = apply { - this.allocationPrice = allocationPrice - } + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - /** - * [DEPRECATED] Use add_adjustments instead. The subscription's discounts for the - * replacement price. - */ - @Deprecated("deprecated") - fun discounts(discounts: List?) = - discounts(JsonField.ofNullable(discounts)) + companion object { - /** - * Sets [Builder.discounts] to an arbitrary JSON value. - * - * You should usually call [Builder.discounts] with a well-typed - * `List` value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - @Deprecated("deprecated") - fun discounts(discounts: JsonField>) = apply { - this.discounts = discounts.map { it.toMutableList() } - } + val UNCHANGED = of("unchanged") - /** - * Adds a single [DiscountOverride] to [discounts]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - @Deprecated("deprecated") - fun addDiscount(discount: DiscountOverride) = apply { - discounts = - (discounts ?: JsonField.of(mutableListOf())).also { - checkKnown("discounts", it).add(discount) - } - } + val PLAN_CHANGE_DATE = of("plan_change_date") - /** The external price id of the price to add to the subscription. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) + val START_OF_MONTH = of("start_of_month") - /** - * Sets [Builder.externalPriceId] to an arbitrary JSON value. - * - * You should usually call [Builder.externalPriceId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun externalPriceId(externalPriceId: JsonField) = apply { - this.externalPriceId = externalPriceId - } + fun of(value: String) = BillingCycleAlignment(JsonField.of(value)) + } - /** The new quantity of the price, if the price is a fixed price. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = - fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + /** An enum containing [BillingCycleAlignment]'s known values. */ + enum class Known { + UNCHANGED, + PLAN_CHANGE_DATE, + START_OF_MONTH, + } + /** + * An enum containing [BillingCycleAlignment]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [BillingCycleAlignment] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + UNCHANGED, + PLAN_CHANGE_DATE, + START_OF_MONTH, /** - * Alias for [Builder.fixedPriceQuantity]. - * - * This unboxed primitive overload exists for backwards compatibility. + * An enum member indicating that [BillingCycleAlignment] was instantiated with an + * unknown value. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) + _UNKNOWN, + } - /** - * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. - * - * You should usually call [Builder.fixedPriceQuantity] with a well-typed [Double] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { - this.fixedPriceQuantity = fixedPriceQuantity + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + UNCHANGED -> Value.UNCHANGED + PLAN_CHANGE_DATE -> Value.PLAN_CHANGE_DATE + START_OF_MONTH -> Value.START_OF_MONTH + else -> Value._UNKNOWN } - /** - * [DEPRECATED] Use add_adjustments instead. The subscription's maximum amount for the - * replacement price. - */ - @Deprecated("deprecated") - fun maximumAmount(maximumAmount: String?) = - maximumAmount(JsonField.ofNullable(maximumAmount)) - - /** - * Sets [Builder.maximumAmount] to an arbitrary JSON value. - * - * You should usually call [Builder.maximumAmount] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - @Deprecated("deprecated") - fun maximumAmount(maximumAmount: JsonField) = apply { - this.maximumAmount = maximumAmount + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known member. + */ + fun known(): Known = + when (this) { + UNCHANGED -> Known.UNCHANGED + PLAN_CHANGE_DATE -> Known.PLAN_CHANGE_DATE + START_OF_MONTH -> Known.START_OF_MONTH + else -> throw OrbInvalidDataException("Unknown BillingCycleAlignment: $value") } - /** - * [DEPRECATED] Use add_adjustments instead. The subscription's minimum amount for the - * replacement price. - */ - @Deprecated("deprecated") - fun minimumAmount(minimumAmount: String?) = - minimumAmount(JsonField.ofNullable(minimumAmount)) + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the expected + * primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") - /** - * Sets [Builder.minimumAmount] to an arbitrary JSON value. - * - * You should usually call [Builder.minimumAmount] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - @Deprecated("deprecated") - fun minimumAmount(minimumAmount: JsonField) = apply { - this.minimumAmount = minimumAmount + private var validated: Boolean = false + + fun validate(): BillingCycleAlignment = apply { + if (validated) { + return@apply } - /** The definition of a new price to create and add to the subscription. */ - fun price(price: Price?) = price(JsonField.ofNullable(price)) + known() + validated = true + } - /** - * Sets [Builder.price] to an arbitrary JSON value. - * - * You should usually call [Builder.price] with a well-typed [Price] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun price(price: JsonField) = apply { this.price = price } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - /** Alias for calling [price] with `Price.ofUnit(unit)`. */ - fun price(unit: NewSubscriptionUnitPrice) = price(Price.ofUnit(unit)) + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - /** Alias for calling [price] with `Price.ofPackage(package_)`. */ - fun price(package_: NewSubscriptionPackagePrice) = price(Price.ofPackage(package_)) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** Alias for calling [price] with `Price.ofMatrix(matrix)`. */ - fun price(matrix: NewSubscriptionMatrixPrice) = price(Price.ofMatrix(matrix)) + return other is BillingCycleAlignment && value == other.value + } - /** Alias for calling [price] with `Price.ofTiered(tiered)`. */ - fun price(tiered: NewSubscriptionTieredPrice) = price(Price.ofTiered(tiered)) + override fun hashCode() = value.hashCode() - /** Alias for calling [price] with `Price.ofBulk(bulk)`. */ - fun price(bulk: NewSubscriptionBulkPrice) = price(Price.ofBulk(bulk)) + override fun toString() = value.toString() + } - /** - * Alias for calling [price] with `Price.ofThresholdTotalAmount(thresholdTotalAmount)`. - */ - fun price(thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice) = - price(Price.ofThresholdTotalAmount(thresholdTotalAmount)) + class RemoveAdjustment + private constructor( + private val adjustmentId: JsonField, + private val additionalProperties: MutableMap, + ) { - /** Alias for calling [price] with `Price.ofTieredPackage(tieredPackage)`. */ - fun price(tieredPackage: NewSubscriptionTieredPackagePrice) = - price(Price.ofTieredPackage(tieredPackage)) + @JsonCreator + private constructor( + @JsonProperty("adjustment_id") + @ExcludeMissing + adjustmentId: JsonField = JsonMissing.of() + ) : this(adjustmentId, mutableMapOf()) - /** Alias for calling [price] with `Price.ofTieredWithMinimum(tieredWithMinimum)`. */ - fun price(tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice) = - price(Price.ofTieredWithMinimum(tieredWithMinimum)) + /** + * The id of the adjustment to remove on the subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun adjustmentId(): String = adjustmentId.getRequired("adjustment_id") - /** Alias for calling [price] with `Price.ofUnitWithPercent(unitWithPercent)`. */ - fun price(unitWithPercent: NewSubscriptionUnitWithPercentPrice) = - price(Price.ofUnitWithPercent(unitWithPercent)) + /** + * Returns the raw JSON value of [adjustmentId]. + * + * Unlike [adjustmentId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("adjustment_id") + @ExcludeMissing + fun _adjustmentId(): JsonField = adjustmentId - /** - * Alias for calling [price] with - * `Price.ofPackageWithAllocation(packageWithAllocation)`. - */ - fun price(packageWithAllocation: NewSubscriptionPackageWithAllocationPrice) = - price(Price.ofPackageWithAllocation(packageWithAllocation)) + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - /** - * Alias for calling [price] with `Price.ofTieredWithProration(tieredWithProration)`. - */ - fun price(tieredWithProration: NewSubscriptionTierWithProrationPrice) = - price(Price.ofTieredWithProration(tieredWithProration)) + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - /** Alias for calling [price] with `Price.ofUnitWithProration(unitWithProration)`. */ - fun price(unitWithProration: NewSubscriptionUnitWithProrationPrice) = - price(Price.ofUnitWithProration(unitWithProration)) + fun toBuilder() = Builder().from(this) - /** Alias for calling [price] with `Price.ofGroupedAllocation(groupedAllocation)`. */ - fun price(groupedAllocation: NewSubscriptionGroupedAllocationPrice) = - price(Price.ofGroupedAllocation(groupedAllocation)) + companion object { /** - * Alias for calling [price] with - * `Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)`. + * Returns a mutable builder for constructing an instance of [RemoveAdjustment]. + * + * The following fields are required: + * ```kotlin + * .adjustmentId() + * ``` */ - fun price(groupedWithProratedMinimum: NewSubscriptionGroupedWithProratedMinimumPrice) = - price(Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)) + fun builder() = Builder() + } - /** Alias for calling [price] with `Price.ofBulkWithProration(bulkWithProration)`. */ - fun price(bulkWithProration: NewSubscriptionBulkWithProrationPrice) = - price(Price.ofBulkWithProration(bulkWithProration)) + /** A builder for [RemoveAdjustment]. */ + class Builder internal constructor() { - /** - * Alias for calling [price] with - * `Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)`. - */ - fun price( - scalableMatrixWithUnitPricing: NewSubscriptionScalableMatrixWithUnitPricingPrice - ) = price(Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)) + private var adjustmentId: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() - /** - * Alias for calling [price] with - * `Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)`. - */ - fun price( - scalableMatrixWithTieredPricing: NewSubscriptionScalableMatrixWithTieredPricingPrice - ) = price(Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)) + internal fun from(removeAdjustment: RemoveAdjustment) = apply { + adjustmentId = removeAdjustment.adjustmentId + additionalProperties = removeAdjustment.additionalProperties.toMutableMap() + } - /** - * Alias for calling [price] with - * `Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)`. - */ - fun price(cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice) = - price(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) + /** The id of the adjustment to remove on the subscription. */ + fun adjustmentId(adjustmentId: String) = adjustmentId(JsonField.of(adjustmentId)) /** - * Alias for calling [price] with - * `Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)`. + * Sets [Builder.adjustmentId] to an arbitrary JSON value. + * + * You should usually call [Builder.adjustmentId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun price(maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice) = - price(Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)) - - /** - * Alias for calling [price] with - * `Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)`. - */ - fun price(groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice) = - price(Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)) - - /** - * Alias for calling [price] with - * `Price.ofMatrixWithDisplayName(matrixWithDisplayName)`. - */ - fun price(matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice) = - price(Price.ofMatrixWithDisplayName(matrixWithDisplayName)) - - /** - * Alias for calling [price] with `Price.ofGroupedTieredPackage(groupedTieredPackage)`. - */ - fun price(groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice) = - price(Price.ofGroupedTieredPackage(groupedTieredPackage)) - - /** - * Alias for calling [price] with `Price.ofMatrixWithAllocation(matrixWithAllocation)`. - */ - fun price(matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice) = - price(Price.ofMatrixWithAllocation(matrixWithAllocation)) - - /** - * Alias for calling [price] with - * `Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)`. - */ - fun price(tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice) = - price(Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)) - - /** Alias for calling [price] with `Price.ofGroupedTiered(groupedTiered)`. */ - fun price(groupedTiered: NewSubscriptionGroupedTieredPrice) = - price(Price.ofGroupedTiered(groupedTiered)) - - /** - * Alias for calling [price] with - * `Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)`. - */ - fun price(groupedWithMinMaxThresholds: Price.GroupedWithMinMaxThresholds) = - price(Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)) - - /** Alias for calling [price] with `Price.ofMinimum(minimum)`. */ - fun price(minimum: NewSubscriptionMinimumCompositePrice) = - price(Price.ofMinimum(minimum)) - - /** The id of the price to add to the subscription. */ - fun priceId(priceId: String?) = priceId(JsonField.ofNullable(priceId)) - - /** - * Sets [Builder.priceId] to an arbitrary JSON value. - * - * You should usually call [Builder.priceId] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun priceId(priceId: JsonField) = apply { this.priceId = priceId } + fun adjustmentId(adjustmentId: JsonField) = apply { + this.adjustmentId = adjustmentId + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -8825,48 +9392,32 @@ private constructor( } /** - * Returns an immutable instance of [ReplacePrice]. + * Returns an immutable instance of [RemoveAdjustment]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```kotlin - * .replacesPriceId() + * .adjustmentId() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): ReplacePrice = - ReplacePrice( - checkRequired("replacesPriceId", replacesPriceId), - allocationPrice, - (discounts ?: JsonMissing.of()).map { it.toImmutable() }, - externalPriceId, - fixedPriceQuantity, - maximumAmount, - minimumAmount, - price, - priceId, + fun build(): RemoveAdjustment = + RemoveAdjustment( + checkRequired("adjustmentId", adjustmentId), additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): ReplacePrice = apply { + fun validate(): RemoveAdjustment = apply { if (validated) { return@apply } - replacesPriceId() - allocationPrice()?.validate() - discounts()?.forEach { it.validate() } - externalPriceId() - fixedPriceQuantity() - maximumAmount() - minimumAmount() - price()?.validate() - priceId() + adjustmentId() validated = true } @@ -8884,1196 +9435,4380 @@ private constructor( * * Used for best match union deserialization. */ - internal fun validity(): Int = - (if (replacesPriceId.asKnown() == null) 0 else 1) + - (allocationPrice.asKnown()?.validity() ?: 0) + - (discounts.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + - (if (externalPriceId.asKnown() == null) 0 else 1) + - (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + - (if (maximumAmount.asKnown() == null) 0 else 1) + - (if (minimumAmount.asKnown() == null) 0 else 1) + - (price.asKnown()?.validity() ?: 0) + - (if (priceId.asKnown() == null) 0 else 1) - - /** The definition of a new price to create and add to the subscription. */ - @JsonDeserialize(using = Price.Deserializer::class) - @JsonSerialize(using = Price.Serializer::class) - class Price - private constructor( - private val unit: NewSubscriptionUnitPrice? = null, - private val package_: NewSubscriptionPackagePrice? = null, - private val matrix: NewSubscriptionMatrixPrice? = null, - private val tiered: NewSubscriptionTieredPrice? = null, - private val bulk: NewSubscriptionBulkPrice? = null, - private val thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice? = null, - private val tieredPackage: NewSubscriptionTieredPackagePrice? = null, - private val tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice? = null, - private val unitWithPercent: NewSubscriptionUnitWithPercentPrice? = null, - private val packageWithAllocation: NewSubscriptionPackageWithAllocationPrice? = null, - private val tieredWithProration: NewSubscriptionTierWithProrationPrice? = null, - private val unitWithProration: NewSubscriptionUnitWithProrationPrice? = null, - private val groupedAllocation: NewSubscriptionGroupedAllocationPrice? = null, - private val groupedWithProratedMinimum: - NewSubscriptionGroupedWithProratedMinimumPrice? = - null, - private val bulkWithProration: NewSubscriptionBulkWithProrationPrice? = null, - private val scalableMatrixWithUnitPricing: - NewSubscriptionScalableMatrixWithUnitPricingPrice? = - null, - private val scalableMatrixWithTieredPricing: - NewSubscriptionScalableMatrixWithTieredPricingPrice? = - null, - private val cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice? = null, - private val maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice? = null, - private val groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice? = - null, - private val matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice? = null, - private val groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice? = null, - private val matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice? = null, - private val tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice? = - null, - private val groupedTiered: NewSubscriptionGroupedTieredPrice? = null, - private val groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds? = null, - private val minimum: NewSubscriptionMinimumCompositePrice? = null, - private val _json: JsonValue? = null, - ) { - - fun unit(): NewSubscriptionUnitPrice? = unit + internal fun validity(): Int = (if (adjustmentId.asKnown() == null) 0 else 1) - fun package_(): NewSubscriptionPackagePrice? = package_ + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun matrix(): NewSubscriptionMatrixPrice? = matrix + return other is RemoveAdjustment && + adjustmentId == other.adjustmentId && + additionalProperties == other.additionalProperties + } - fun tiered(): NewSubscriptionTieredPrice? = tiered + private val hashCode: Int by lazy { Objects.hash(adjustmentId, additionalProperties) } - fun bulk(): NewSubscriptionBulkPrice? = bulk + override fun hashCode(): Int = hashCode - fun thresholdTotalAmount(): NewSubscriptionThresholdTotalAmountPrice? = - thresholdTotalAmount + override fun toString() = + "RemoveAdjustment{adjustmentId=$adjustmentId, additionalProperties=$additionalProperties}" + } - fun tieredPackage(): NewSubscriptionTieredPackagePrice? = tieredPackage + class RemovePrice + private constructor( + private val externalPriceId: JsonField, + private val priceId: JsonField, + private val additionalProperties: MutableMap, + ) { - fun tieredWithMinimum(): NewSubscriptionTieredWithMinimumPrice? = tieredWithMinimum + @JsonCreator + private constructor( + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("price_id") @ExcludeMissing priceId: JsonField = JsonMissing.of(), + ) : this(externalPriceId, priceId, mutableMapOf()) - fun unitWithPercent(): NewSubscriptionUnitWithPercentPrice? = unitWithPercent + /** + * The external price id of the price to remove on the subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") - fun packageWithAllocation(): NewSubscriptionPackageWithAllocationPrice? = - packageWithAllocation + /** + * The id of the price to remove on the subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun priceId(): String? = priceId.getNullable("price_id") - fun tieredWithProration(): NewSubscriptionTierWithProrationPrice? = tieredWithProration + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId - fun unitWithProration(): NewSubscriptionUnitWithProrationPrice? = unitWithProration + /** + * Returns the raw JSON value of [priceId]. + * + * Unlike [priceId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId - fun groupedAllocation(): NewSubscriptionGroupedAllocationPrice? = groupedAllocation + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - fun groupedWithProratedMinimum(): NewSubscriptionGroupedWithProratedMinimumPrice? = - groupedWithProratedMinimum + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - fun bulkWithProration(): NewSubscriptionBulkWithProrationPrice? = bulkWithProration + fun toBuilder() = Builder().from(this) - fun scalableMatrixWithUnitPricing(): - NewSubscriptionScalableMatrixWithUnitPricingPrice? = scalableMatrixWithUnitPricing + companion object { - fun scalableMatrixWithTieredPricing(): - NewSubscriptionScalableMatrixWithTieredPricingPrice? = - scalableMatrixWithTieredPricing + /** Returns a mutable builder for constructing an instance of [RemovePrice]. */ + fun builder() = Builder() + } - fun cumulativeGroupedBulk(): NewSubscriptionCumulativeGroupedBulkPrice? = - cumulativeGroupedBulk + /** A builder for [RemovePrice]. */ + class Builder internal constructor() { - fun maxGroupTieredPackage(): NewSubscriptionMaxGroupTieredPackagePrice? = - maxGroupTieredPackage + private var externalPriceId: JsonField = JsonMissing.of() + private var priceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - fun groupedWithMeteredMinimum(): NewSubscriptionGroupedWithMeteredMinimumPrice? = - groupedWithMeteredMinimum + internal fun from(removePrice: RemovePrice) = apply { + externalPriceId = removePrice.externalPriceId + priceId = removePrice.priceId + additionalProperties = removePrice.additionalProperties.toMutableMap() + } - fun matrixWithDisplayName(): NewSubscriptionMatrixWithDisplayNamePrice? = - matrixWithDisplayName + /** The external price id of the price to remove on the subscription. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) - fun groupedTieredPackage(): NewSubscriptionGroupedTieredPackagePrice? = - groupedTieredPackage - - fun matrixWithAllocation(): NewSubscriptionMatrixWithAllocationPrice? = - matrixWithAllocation - - fun tieredPackageWithMinimum(): NewSubscriptionTieredPackageWithMinimumPrice? = - tieredPackageWithMinimum - - fun groupedTiered(): NewSubscriptionGroupedTieredPrice? = groupedTiered - - fun groupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds? = - groupedWithMinMaxThresholds - - fun minimum(): NewSubscriptionMinimumCompositePrice? = minimum - - fun isUnit(): Boolean = unit != null + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } - fun isPackage(): Boolean = package_ != null + /** The id of the price to remove on the subscription. */ + fun priceId(priceId: String?) = priceId(JsonField.ofNullable(priceId)) - fun isMatrix(): Boolean = matrix != null + /** + * Sets [Builder.priceId] to an arbitrary JSON value. + * + * You should usually call [Builder.priceId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun priceId(priceId: JsonField) = apply { this.priceId = priceId } - fun isTiered(): Boolean = tiered != null + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun isBulk(): Boolean = bulk != null + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun isThresholdTotalAmount(): Boolean = thresholdTotalAmount != null + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun isTieredPackage(): Boolean = tieredPackage != null + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - fun isTieredWithMinimum(): Boolean = tieredWithMinimum != null + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - fun isUnitWithPercent(): Boolean = unitWithPercent != null + /** + * Returns an immutable instance of [RemovePrice]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): RemovePrice = + RemovePrice(externalPriceId, priceId, additionalProperties.toMutableMap()) + } - fun isPackageWithAllocation(): Boolean = packageWithAllocation != null + private var validated: Boolean = false - fun isTieredWithProration(): Boolean = tieredWithProration != null + fun validate(): RemovePrice = apply { + if (validated) { + return@apply + } - fun isUnitWithProration(): Boolean = unitWithProration != null + externalPriceId() + priceId() + validated = true + } - fun isGroupedAllocation(): Boolean = groupedAllocation != null + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - fun isGroupedWithProratedMinimum(): Boolean = groupedWithProratedMinimum != null + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (priceId.asKnown() == null) 0 else 1) - fun isBulkWithProration(): Boolean = bulkWithProration != null + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun isScalableMatrixWithUnitPricing(): Boolean = scalableMatrixWithUnitPricing != null + return other is RemovePrice && + externalPriceId == other.externalPriceId && + priceId == other.priceId && + additionalProperties == other.additionalProperties + } - fun isScalableMatrixWithTieredPricing(): Boolean = - scalableMatrixWithTieredPricing != null + private val hashCode: Int by lazy { + Objects.hash(externalPriceId, priceId, additionalProperties) + } - fun isCumulativeGroupedBulk(): Boolean = cumulativeGroupedBulk != null + override fun hashCode(): Int = hashCode - fun isMaxGroupTieredPackage(): Boolean = maxGroupTieredPackage != null + override fun toString() = + "RemovePrice{externalPriceId=$externalPriceId, priceId=$priceId, additionalProperties=$additionalProperties}" + } - fun isGroupedWithMeteredMinimum(): Boolean = groupedWithMeteredMinimum != null + class ReplaceAdjustment + private constructor( + private val adjustment: JsonField, + private val replacesAdjustmentId: JsonField, + private val additionalProperties: MutableMap, + ) { - fun isMatrixWithDisplayName(): Boolean = matrixWithDisplayName != null + @JsonCreator + private constructor( + @JsonProperty("adjustment") + @ExcludeMissing + adjustment: JsonField = JsonMissing.of(), + @JsonProperty("replaces_adjustment_id") + @ExcludeMissing + replacesAdjustmentId: JsonField = JsonMissing.of(), + ) : this(adjustment, replacesAdjustmentId, mutableMapOf()) - fun isGroupedTieredPackage(): Boolean = groupedTieredPackage != null + /** + * The definition of a new adjustment to create and add to the subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun adjustment(): Adjustment = adjustment.getRequired("adjustment") - fun isMatrixWithAllocation(): Boolean = matrixWithAllocation != null + /** + * The id of the adjustment on the plan to replace in the subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun replacesAdjustmentId(): String = + replacesAdjustmentId.getRequired("replaces_adjustment_id") - fun isTieredPackageWithMinimum(): Boolean = tieredPackageWithMinimum != null + /** + * Returns the raw JSON value of [adjustment]. + * + * Unlike [adjustment], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("adjustment") + @ExcludeMissing + fun _adjustment(): JsonField = adjustment - fun isGroupedTiered(): Boolean = groupedTiered != null + /** + * Returns the raw JSON value of [replacesAdjustmentId]. + * + * Unlike [replacesAdjustmentId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("replaces_adjustment_id") + @ExcludeMissing + fun _replacesAdjustmentId(): JsonField = replacesAdjustmentId - fun isGroupedWithMinMaxThresholds(): Boolean = groupedWithMinMaxThresholds != null + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - fun isMinimum(): Boolean = minimum != null + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - fun asUnit(): NewSubscriptionUnitPrice = unit.getOrThrow("unit") + fun toBuilder() = Builder().from(this) - fun asPackage(): NewSubscriptionPackagePrice = package_.getOrThrow("package_") + companion object { - fun asMatrix(): NewSubscriptionMatrixPrice = matrix.getOrThrow("matrix") + /** + * Returns a mutable builder for constructing an instance of [ReplaceAdjustment]. + * + * The following fields are required: + * ```kotlin + * .adjustment() + * .replacesAdjustmentId() + * ``` + */ + fun builder() = Builder() + } - fun asTiered(): NewSubscriptionTieredPrice = tiered.getOrThrow("tiered") + /** A builder for [ReplaceAdjustment]. */ + class Builder internal constructor() { - fun asBulk(): NewSubscriptionBulkPrice = bulk.getOrThrow("bulk") + private var adjustment: JsonField? = null + private var replacesAdjustmentId: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() - fun asThresholdTotalAmount(): NewSubscriptionThresholdTotalAmountPrice = - thresholdTotalAmount.getOrThrow("thresholdTotalAmount") + internal fun from(replaceAdjustment: ReplaceAdjustment) = apply { + adjustment = replaceAdjustment.adjustment + replacesAdjustmentId = replaceAdjustment.replacesAdjustmentId + additionalProperties = replaceAdjustment.additionalProperties.toMutableMap() + } - fun asTieredPackage(): NewSubscriptionTieredPackagePrice = - tieredPackage.getOrThrow("tieredPackage") + /** The definition of a new adjustment to create and add to the subscription. */ + fun adjustment(adjustment: Adjustment) = adjustment(JsonField.of(adjustment)) - fun asTieredWithMinimum(): NewSubscriptionTieredWithMinimumPrice = - tieredWithMinimum.getOrThrow("tieredWithMinimum") + /** + * Sets [Builder.adjustment] to an arbitrary JSON value. + * + * You should usually call [Builder.adjustment] with a well-typed [Adjustment] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun adjustment(adjustment: JsonField) = apply { + this.adjustment = adjustment + } - fun asUnitWithPercent(): NewSubscriptionUnitWithPercentPrice = - unitWithPercent.getOrThrow("unitWithPercent") + /** + * Alias for calling [adjustment] with + * `Adjustment.ofPercentageDiscount(percentageDiscount)`. + */ + fun adjustment(percentageDiscount: NewPercentageDiscount) = + adjustment(Adjustment.ofPercentageDiscount(percentageDiscount)) - fun asPackageWithAllocation(): NewSubscriptionPackageWithAllocationPrice = - packageWithAllocation.getOrThrow("packageWithAllocation") + /** + * Alias for calling [adjustment] with the following: + * ```kotlin + * NewPercentageDiscount.builder() + * .adjustmentType(NewPercentageDiscount.AdjustmentType.PERCENTAGE_DISCOUNT) + * .percentageDiscount(percentageDiscount) + * .build() + * ``` + */ + fun percentageDiscountAdjustment(percentageDiscount: Double) = + adjustment( + NewPercentageDiscount.builder() + .adjustmentType(NewPercentageDiscount.AdjustmentType.PERCENTAGE_DISCOUNT) + .percentageDiscount(percentageDiscount) + .build() + ) - fun asTieredWithProration(): NewSubscriptionTierWithProrationPrice = - tieredWithProration.getOrThrow("tieredWithProration") + /** Alias for calling [adjustment] with `Adjustment.ofUsageDiscount(usageDiscount)`. */ + fun adjustment(usageDiscount: NewUsageDiscount) = + adjustment(Adjustment.ofUsageDiscount(usageDiscount)) + + /** + * Alias for calling [adjustment] with the following: + * ```kotlin + * NewUsageDiscount.builder() + * .adjustmentType(NewUsageDiscount.AdjustmentType.USAGE_DISCOUNT) + * .usageDiscount(usageDiscount) + * .build() + * ``` + */ + fun usageDiscountAdjustment(usageDiscount: Double) = + adjustment( + NewUsageDiscount.builder() + .adjustmentType(NewUsageDiscount.AdjustmentType.USAGE_DISCOUNT) + .usageDiscount(usageDiscount) + .build() + ) + + /** + * Alias for calling [adjustment] with `Adjustment.ofAmountDiscount(amountDiscount)`. + */ + fun adjustment(amountDiscount: NewAmountDiscount) = + adjustment(Adjustment.ofAmountDiscount(amountDiscount)) + + /** + * Alias for calling [adjustment] with the following: + * ```kotlin + * NewAmountDiscount.builder() + * .adjustmentType(NewAmountDiscount.AdjustmentType.AMOUNT_DISCOUNT) + * .amountDiscount(amountDiscount) + * .build() + * ``` + */ + fun amountDiscountAdjustment(amountDiscount: String) = + adjustment( + NewAmountDiscount.builder() + .adjustmentType(NewAmountDiscount.AdjustmentType.AMOUNT_DISCOUNT) + .amountDiscount(amountDiscount) + .build() + ) + + /** Alias for calling [adjustment] with `Adjustment.ofMinimum(minimum)`. */ + fun adjustment(minimum: NewMinimum) = adjustment(Adjustment.ofMinimum(minimum)) + + /** Alias for calling [adjustment] with `Adjustment.ofMaximum(maximum)`. */ + fun adjustment(maximum: NewMaximum) = adjustment(Adjustment.ofMaximum(maximum)) + + /** + * Alias for calling [adjustment] with the following: + * ```kotlin + * NewMaximum.builder() + * .adjustmentType(NewMaximum.AdjustmentType.MAXIMUM) + * .maximumAmount(maximumAmount) + * .build() + * ``` + */ + fun maximumAdjustment(maximumAmount: String) = + adjustment( + NewMaximum.builder() + .adjustmentType(NewMaximum.AdjustmentType.MAXIMUM) + .maximumAmount(maximumAmount) + .build() + ) + + /** The id of the adjustment on the plan to replace in the subscription. */ + fun replacesAdjustmentId(replacesAdjustmentId: String) = + replacesAdjustmentId(JsonField.of(replacesAdjustmentId)) + + /** + * Sets [Builder.replacesAdjustmentId] to an arbitrary JSON value. + * + * You should usually call [Builder.replacesAdjustmentId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun replacesAdjustmentId(replacesAdjustmentId: JsonField) = apply { + this.replacesAdjustmentId = replacesAdjustmentId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ReplaceAdjustment]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .adjustment() + * .replacesAdjustmentId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ReplaceAdjustment = + ReplaceAdjustment( + checkRequired("adjustment", adjustment), + checkRequired("replacesAdjustmentId", replacesAdjustmentId), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ReplaceAdjustment = apply { + if (validated) { + return@apply + } + + adjustment().validate() + replacesAdjustmentId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (adjustment.asKnown()?.validity() ?: 0) + + (if (replacesAdjustmentId.asKnown() == null) 0 else 1) + + /** The definition of a new adjustment to create and add to the subscription. */ + @JsonDeserialize(using = Adjustment.Deserializer::class) + @JsonSerialize(using = Adjustment.Serializer::class) + class Adjustment + private constructor( + private val percentageDiscount: NewPercentageDiscount? = null, + private val usageDiscount: NewUsageDiscount? = null, + private val amountDiscount: NewAmountDiscount? = null, + private val minimum: NewMinimum? = null, + private val maximum: NewMaximum? = null, + private val _json: JsonValue? = null, + ) { + + fun percentageDiscount(): NewPercentageDiscount? = percentageDiscount + + fun usageDiscount(): NewUsageDiscount? = usageDiscount + + fun amountDiscount(): NewAmountDiscount? = amountDiscount + + fun minimum(): NewMinimum? = minimum + + fun maximum(): NewMaximum? = maximum + + fun isPercentageDiscount(): Boolean = percentageDiscount != null + + fun isUsageDiscount(): Boolean = usageDiscount != null + + fun isAmountDiscount(): Boolean = amountDiscount != null + + fun isMinimum(): Boolean = minimum != null + + fun isMaximum(): Boolean = maximum != null + + fun asPercentageDiscount(): NewPercentageDiscount = + percentageDiscount.getOrThrow("percentageDiscount") + + fun asUsageDiscount(): NewUsageDiscount = usageDiscount.getOrThrow("usageDiscount") + + fun asAmountDiscount(): NewAmountDiscount = amountDiscount.getOrThrow("amountDiscount") + + fun asMinimum(): NewMinimum = minimum.getOrThrow("minimum") + + fun asMaximum(): NewMaximum = maximum.getOrThrow("maximum") + + fun _json(): JsonValue? = _json + + fun accept(visitor: Visitor): T = + when { + percentageDiscount != null -> + visitor.visitPercentageDiscount(percentageDiscount) + usageDiscount != null -> visitor.visitUsageDiscount(usageDiscount) + amountDiscount != null -> visitor.visitAmountDiscount(amountDiscount) + minimum != null -> visitor.visitMinimum(minimum) + maximum != null -> visitor.visitMaximum(maximum) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Adjustment = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitPercentageDiscount( + percentageDiscount: NewPercentageDiscount + ) { + percentageDiscount.validate() + } + + override fun visitUsageDiscount(usageDiscount: NewUsageDiscount) { + usageDiscount.validate() + } + + override fun visitAmountDiscount(amountDiscount: NewAmountDiscount) { + amountDiscount.validate() + } + + override fun visitMinimum(minimum: NewMinimum) { + minimum.validate() + } + + override fun visitMaximum(maximum: NewMaximum) { + maximum.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitPercentageDiscount( + percentageDiscount: NewPercentageDiscount + ) = percentageDiscount.validity() + + override fun visitUsageDiscount(usageDiscount: NewUsageDiscount) = + usageDiscount.validity() + + override fun visitAmountDiscount(amountDiscount: NewAmountDiscount) = + amountDiscount.validity() + + override fun visitMinimum(minimum: NewMinimum) = minimum.validity() + + override fun visitMaximum(maximum: NewMaximum) = maximum.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Adjustment && + percentageDiscount == other.percentageDiscount && + usageDiscount == other.usageDiscount && + amountDiscount == other.amountDiscount && + minimum == other.minimum && + maximum == other.maximum + } + + override fun hashCode(): Int = + Objects.hash(percentageDiscount, usageDiscount, amountDiscount, minimum, maximum) + + override fun toString(): String = + when { + percentageDiscount != null -> + "Adjustment{percentageDiscount=$percentageDiscount}" + usageDiscount != null -> "Adjustment{usageDiscount=$usageDiscount}" + amountDiscount != null -> "Adjustment{amountDiscount=$amountDiscount}" + minimum != null -> "Adjustment{minimum=$minimum}" + maximum != null -> "Adjustment{maximum=$maximum}" + _json != null -> "Adjustment{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Adjustment") + } + + companion object { + + fun ofPercentageDiscount(percentageDiscount: NewPercentageDiscount) = + Adjustment(percentageDiscount = percentageDiscount) + + fun ofUsageDiscount(usageDiscount: NewUsageDiscount) = + Adjustment(usageDiscount = usageDiscount) + + fun ofAmountDiscount(amountDiscount: NewAmountDiscount) = + Adjustment(amountDiscount = amountDiscount) + + fun ofMinimum(minimum: NewMinimum) = Adjustment(minimum = minimum) + + fun ofMaximum(maximum: NewMaximum) = Adjustment(maximum = maximum) + } + + /** + * An interface that defines how to map each variant of [Adjustment] to a value of type + * [T]. + */ + interface Visitor { + + fun visitPercentageDiscount(percentageDiscount: NewPercentageDiscount): T + + fun visitUsageDiscount(usageDiscount: NewUsageDiscount): T + + fun visitAmountDiscount(amountDiscount: NewAmountDiscount): T + + fun visitMinimum(minimum: NewMinimum): T + + fun visitMaximum(maximum: NewMaximum): T + + /** + * Maps an unknown variant of [Adjustment] to a value of type [T]. + * + * An instance of [Adjustment] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the + * SDK is unaware of. + * + * @throws OrbInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw OrbInvalidDataException("Unknown Adjustment: $json") + } + } + + internal class Deserializer : BaseDeserializer(Adjustment::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Adjustment { + val json = JsonValue.fromJsonNode(node) + val adjustmentType = json.asObject()?.get("adjustment_type")?.asString() + + when (adjustmentType) { + "percentage_discount" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Adjustment(percentageDiscount = it, _json = json) } + ?: Adjustment(_json = json) + } + "usage_discount" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(usageDiscount = it, _json = json) + } ?: Adjustment(_json = json) + } + "amount_discount" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(amountDiscount = it, _json = json) + } ?: Adjustment(_json = json) + } + "minimum" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(minimum = it, _json = json) + } ?: Adjustment(_json = json) + } + "maximum" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(maximum = it, _json = json) + } ?: Adjustment(_json = json) + } + } + + return Adjustment(_json = json) + } + } + + internal class Serializer : BaseSerializer(Adjustment::class) { + + override fun serialize( + value: Adjustment, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.percentageDiscount != null -> + generator.writeObject(value.percentageDiscount) + value.usageDiscount != null -> generator.writeObject(value.usageDiscount) + value.amountDiscount != null -> generator.writeObject(value.amountDiscount) + value.minimum != null -> generator.writeObject(value.minimum) + value.maximum != null -> generator.writeObject(value.maximum) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Adjustment") + } + } + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ReplaceAdjustment && + adjustment == other.adjustment && + replacesAdjustmentId == other.replacesAdjustmentId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(adjustment, replacesAdjustmentId, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ReplaceAdjustment{adjustment=$adjustment, replacesAdjustmentId=$replacesAdjustmentId, additionalProperties=$additionalProperties}" + } + + class ReplacePrice + private constructor( + private val replacesPriceId: JsonField, + private val allocationPrice: JsonField, + private val discounts: JsonField>, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val maximumAmount: JsonField, + private val minimumAmount: JsonField, + private val price: JsonField, + private val priceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("replaces_price_id") + @ExcludeMissing + replacesPriceId: JsonField = JsonMissing.of(), + @JsonProperty("allocation_price") + @ExcludeMissing + allocationPrice: JsonField = JsonMissing.of(), + @JsonProperty("discounts") + @ExcludeMissing + discounts: JsonField> = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("maximum_amount") + @ExcludeMissing + maximumAmount: JsonField = JsonMissing.of(), + @JsonProperty("minimum_amount") + @ExcludeMissing + minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("price") @ExcludeMissing price: JsonField = JsonMissing.of(), + @JsonProperty("price_id") @ExcludeMissing priceId: JsonField = JsonMissing.of(), + ) : this( + replacesPriceId, + allocationPrice, + discounts, + externalPriceId, + fixedPriceQuantity, + maximumAmount, + minimumAmount, + price, + priceId, + mutableMapOf(), + ) + + /** + * The id of the price on the plan to replace in the subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun replacesPriceId(): String = replacesPriceId.getRequired("replaces_price_id") + + /** + * The definition of a new allocation price to create and add to the subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun allocationPrice(): NewAllocationPrice? = allocationPrice.getNullable("allocation_price") + + /** + * [DEPRECATED] Use add_adjustments instead. The subscription's discounts for the + * replacement price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + @Deprecated("deprecated") + fun discounts(): List? = discounts.getNullable("discounts") + + /** + * The external price id of the price to add to the subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * The new quantity of the price, if the price is a fixed price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * [DEPRECATED] Use add_adjustments instead. The subscription's maximum amount for the + * replacement price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + @Deprecated("deprecated") + fun maximumAmount(): String? = maximumAmount.getNullable("maximum_amount") + + /** + * [DEPRECATED] Use add_adjustments instead. The subscription's minimum amount for the + * replacement price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + @Deprecated("deprecated") + fun minimumAmount(): String? = minimumAmount.getNullable("minimum_amount") + + /** + * New subscription price request body params. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun price(): Price? = price.getNullable("price") + + /** + * The id of the price to add to the subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun priceId(): String? = priceId.getNullable("price_id") + + /** + * Returns the raw JSON value of [replacesPriceId]. + * + * Unlike [replacesPriceId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("replaces_price_id") + @ExcludeMissing + fun _replacesPriceId(): JsonField = replacesPriceId + + /** + * Returns the raw JSON value of [allocationPrice]. + * + * Unlike [allocationPrice], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("allocation_price") + @ExcludeMissing + fun _allocationPrice(): JsonField = allocationPrice + + /** + * Returns the raw JSON value of [discounts]. + * + * Unlike [discounts], this method doesn't throw if the JSON field has an unexpected type. + */ + @Deprecated("deprecated") + @JsonProperty("discounts") + @ExcludeMissing + fun _discounts(): JsonField> = discounts + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [maximumAmount]. + * + * Unlike [maximumAmount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @Deprecated("deprecated") + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount + + /** + * Returns the raw JSON value of [minimumAmount]. + * + * Unlike [minimumAmount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @Deprecated("deprecated") + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount + + /** + * Returns the raw JSON value of [price]. + * + * Unlike [price], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("price") @ExcludeMissing fun _price(): JsonField = price + + /** + * Returns the raw JSON value of [priceId]. + * + * Unlike [priceId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ReplacePrice]. + * + * The following fields are required: + * ```kotlin + * .replacesPriceId() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [ReplacePrice]. */ + class Builder internal constructor() { + + private var replacesPriceId: JsonField? = null + private var allocationPrice: JsonField = JsonMissing.of() + private var discounts: JsonField>? = null + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var maximumAmount: JsonField = JsonMissing.of() + private var minimumAmount: JsonField = JsonMissing.of() + private var price: JsonField = JsonMissing.of() + private var priceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(replacePrice: ReplacePrice) = apply { + replacesPriceId = replacePrice.replacesPriceId + allocationPrice = replacePrice.allocationPrice + discounts = replacePrice.discounts.map { it.toMutableList() } + externalPriceId = replacePrice.externalPriceId + fixedPriceQuantity = replacePrice.fixedPriceQuantity + maximumAmount = replacePrice.maximumAmount + minimumAmount = replacePrice.minimumAmount + price = replacePrice.price + priceId = replacePrice.priceId + additionalProperties = replacePrice.additionalProperties.toMutableMap() + } + + /** The id of the price on the plan to replace in the subscription. */ + fun replacesPriceId(replacesPriceId: String) = + replacesPriceId(JsonField.of(replacesPriceId)) + + /** + * Sets [Builder.replacesPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.replacesPriceId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun replacesPriceId(replacesPriceId: JsonField) = apply { + this.replacesPriceId = replacesPriceId + } + + /** The definition of a new allocation price to create and add to the subscription. */ + fun allocationPrice(allocationPrice: NewAllocationPrice?) = + allocationPrice(JsonField.ofNullable(allocationPrice)) + + /** + * Sets [Builder.allocationPrice] to an arbitrary JSON value. + * + * You should usually call [Builder.allocationPrice] with a well-typed + * [NewAllocationPrice] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun allocationPrice(allocationPrice: JsonField) = apply { + this.allocationPrice = allocationPrice + } + + /** + * [DEPRECATED] Use add_adjustments instead. The subscription's discounts for the + * replacement price. + */ + @Deprecated("deprecated") + fun discounts(discounts: List?) = + discounts(JsonField.ofNullable(discounts)) + + /** + * Sets [Builder.discounts] to an arbitrary JSON value. + * + * You should usually call [Builder.discounts] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + @Deprecated("deprecated") + fun discounts(discounts: JsonField>) = apply { + this.discounts = discounts.map { it.toMutableList() } + } + + /** + * Adds a single [DiscountOverride] to [discounts]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + @Deprecated("deprecated") + fun addDiscount(discount: DiscountOverride) = apply { + discounts = + (discounts ?: JsonField.of(mutableListOf())).also { + checkKnown("discounts", it).add(discount) + } + } + + /** The external price id of the price to add to the subscription. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** The new quantity of the price, if the price is a fixed price. */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** + * [DEPRECATED] Use add_adjustments instead. The subscription's maximum amount for the + * replacement price. + */ + @Deprecated("deprecated") + fun maximumAmount(maximumAmount: String?) = + maximumAmount(JsonField.ofNullable(maximumAmount)) + + /** + * Sets [Builder.maximumAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.maximumAmount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + @Deprecated("deprecated") + fun maximumAmount(maximumAmount: JsonField) = apply { + this.maximumAmount = maximumAmount + } + + /** + * [DEPRECATED] Use add_adjustments instead. The subscription's minimum amount for the + * replacement price. + */ + @Deprecated("deprecated") + fun minimumAmount(minimumAmount: String?) = + minimumAmount(JsonField.ofNullable(minimumAmount)) + + /** + * Sets [Builder.minimumAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumAmount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + @Deprecated("deprecated") + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount + } + + /** New subscription price request body params. */ + fun price(price: Price?) = price(JsonField.ofNullable(price)) + + /** + * Sets [Builder.price] to an arbitrary JSON value. + * + * You should usually call [Builder.price] with a well-typed [Price] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun price(price: JsonField) = apply { this.price = price } + + /** Alias for calling [price] with `Price.ofUnit(unit)`. */ + fun price(unit: NewSubscriptionUnitPrice) = price(Price.ofUnit(unit)) + + /** Alias for calling [price] with `Price.ofTiered(tiered)`. */ + fun price(tiered: NewSubscriptionTieredPrice) = price(Price.ofTiered(tiered)) + + /** Alias for calling [price] with `Price.ofBulk(bulk)`. */ + fun price(bulk: NewSubscriptionBulkPrice) = price(Price.ofBulk(bulk)) + + /** Alias for calling [price] with `Price.ofPackage(package_)`. */ + fun price(package_: NewSubscriptionPackagePrice) = price(Price.ofPackage(package_)) + + /** Alias for calling [price] with `Price.ofMatrix(matrix)`. */ + fun price(matrix: NewSubscriptionMatrixPrice) = price(Price.ofMatrix(matrix)) + + /** + * Alias for calling [price] with `Price.ofThresholdTotalAmount(thresholdTotalAmount)`. + */ + fun price(thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice) = + price(Price.ofThresholdTotalAmount(thresholdTotalAmount)) + + /** Alias for calling [price] with `Price.ofTieredPackage(tieredPackage)`. */ + fun price(tieredPackage: NewSubscriptionTieredPackagePrice) = + price(Price.ofTieredPackage(tieredPackage)) + + /** Alias for calling [price] with `Price.ofTieredWithMinimum(tieredWithMinimum)`. */ + fun price(tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice) = + price(Price.ofTieredWithMinimum(tieredWithMinimum)) + + /** Alias for calling [price] with `Price.ofGroupedTiered(groupedTiered)`. */ + fun price(groupedTiered: NewSubscriptionGroupedTieredPrice) = + price(Price.ofGroupedTiered(groupedTiered)) + + /** + * Alias for calling [price] with + * `Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)`. + */ + fun price(tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice) = + price(Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)) + + /** + * Alias for calling [price] with + * `Price.ofPackageWithAllocation(packageWithAllocation)`. + */ + fun price(packageWithAllocation: NewSubscriptionPackageWithAllocationPrice) = + price(Price.ofPackageWithAllocation(packageWithAllocation)) + + /** Alias for calling [price] with `Price.ofUnitWithPercent(unitWithPercent)`. */ + fun price(unitWithPercent: NewSubscriptionUnitWithPercentPrice) = + price(Price.ofUnitWithPercent(unitWithPercent)) + + /** + * Alias for calling [price] with `Price.ofMatrixWithAllocation(matrixWithAllocation)`. + */ + fun price(matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice) = + price(Price.ofMatrixWithAllocation(matrixWithAllocation)) + + /** + * Alias for calling [price] with `Price.ofTieredWithProration(tieredWithProration)`. + */ + fun price(tieredWithProration: Price.TieredWithProration) = + price(Price.ofTieredWithProration(tieredWithProration)) + + /** Alias for calling [price] with `Price.ofUnitWithProration(unitWithProration)`. */ + fun price(unitWithProration: NewSubscriptionUnitWithProrationPrice) = + price(Price.ofUnitWithProration(unitWithProration)) + + /** Alias for calling [price] with `Price.ofGroupedAllocation(groupedAllocation)`. */ + fun price(groupedAllocation: NewSubscriptionGroupedAllocationPrice) = + price(Price.ofGroupedAllocation(groupedAllocation)) + + /** Alias for calling [price] with `Price.ofBulkWithProration(bulkWithProration)`. */ + fun price(bulkWithProration: NewSubscriptionBulkWithProrationPrice) = + price(Price.ofBulkWithProration(bulkWithProration)) + + /** + * Alias for calling [price] with + * `Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)`. + */ + fun price(groupedWithProratedMinimum: NewSubscriptionGroupedWithProratedMinimumPrice) = + price(Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)) + + /** + * Alias for calling [price] with + * `Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)`. + */ + fun price(groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice) = + price(Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)) + + /** + * Alias for calling [price] with + * `Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)`. + */ + fun price(groupedWithMinMaxThresholds: Price.GroupedWithMinMaxThresholds) = + price(Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)) + + /** + * Alias for calling [price] with + * `Price.ofMatrixWithDisplayName(matrixWithDisplayName)`. + */ + fun price(matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice) = + price(Price.ofMatrixWithDisplayName(matrixWithDisplayName)) + + /** + * Alias for calling [price] with `Price.ofGroupedTieredPackage(groupedTieredPackage)`. + */ + fun price(groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice) = + price(Price.ofGroupedTieredPackage(groupedTieredPackage)) + + /** + * Alias for calling [price] with + * `Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)`. + */ + fun price(maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice) = + price(Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)) + + /** + * Alias for calling [price] with + * `Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)`. + */ + fun price( + scalableMatrixWithUnitPricing: NewSubscriptionScalableMatrixWithUnitPricingPrice + ) = price(Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)) + + /** + * Alias for calling [price] with + * `Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)`. + */ + fun price( + scalableMatrixWithTieredPricing: NewSubscriptionScalableMatrixWithTieredPricingPrice + ) = price(Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)) + + /** + * Alias for calling [price] with + * `Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)`. + */ + fun price(cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice) = + price(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) + + /** Alias for calling [price] with `Price.ofMinimum(minimum)`. */ + fun price(minimum: NewSubscriptionMinimumCompositePrice) = + price(Price.ofMinimum(minimum)) + + /** The id of the price to add to the subscription. */ + fun priceId(priceId: String?) = priceId(JsonField.ofNullable(priceId)) + + /** + * Sets [Builder.priceId] to an arbitrary JSON value. + * + * You should usually call [Builder.priceId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun priceId(priceId: JsonField) = apply { this.priceId = priceId } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ReplacePrice]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .replacesPriceId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ReplacePrice = + ReplacePrice( + checkRequired("replacesPriceId", replacesPriceId), + allocationPrice, + (discounts ?: JsonMissing.of()).map { it.toImmutable() }, + externalPriceId, + fixedPriceQuantity, + maximumAmount, + minimumAmount, + price, + priceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ReplacePrice = apply { + if (validated) { + return@apply + } + + replacesPriceId() + allocationPrice()?.validate() + discounts()?.forEach { it.validate() } + externalPriceId() + fixedPriceQuantity() + maximumAmount() + minimumAmount() + price()?.validate() + priceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (replacesPriceId.asKnown() == null) 0 else 1) + + (allocationPrice.asKnown()?.validity() ?: 0) + + (discounts.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (maximumAmount.asKnown() == null) 0 else 1) + + (if (minimumAmount.asKnown() == null) 0 else 1) + + (price.asKnown()?.validity() ?: 0) + + (if (priceId.asKnown() == null) 0 else 1) + + /** New subscription price request body params. */ + @JsonDeserialize(using = Price.Deserializer::class) + @JsonSerialize(using = Price.Serializer::class) + class Price + private constructor( + private val unit: NewSubscriptionUnitPrice? = null, + private val tiered: NewSubscriptionTieredPrice? = null, + private val bulk: NewSubscriptionBulkPrice? = null, + private val package_: NewSubscriptionPackagePrice? = null, + private val matrix: NewSubscriptionMatrixPrice? = null, + private val thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice? = null, + private val tieredPackage: NewSubscriptionTieredPackagePrice? = null, + private val tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice? = null, + private val groupedTiered: NewSubscriptionGroupedTieredPrice? = null, + private val tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice? = + null, + private val packageWithAllocation: NewSubscriptionPackageWithAllocationPrice? = null, + private val unitWithPercent: NewSubscriptionUnitWithPercentPrice? = null, + private val matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice? = null, + private val tieredWithProration: TieredWithProration? = null, + private val unitWithProration: NewSubscriptionUnitWithProrationPrice? = null, + private val groupedAllocation: NewSubscriptionGroupedAllocationPrice? = null, + private val bulkWithProration: NewSubscriptionBulkWithProrationPrice? = null, + private val groupedWithProratedMinimum: + NewSubscriptionGroupedWithProratedMinimumPrice? = + null, + private val groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice? = + null, + private val groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds? = null, + private val matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice? = null, + private val groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice? = null, + private val maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice? = null, + private val scalableMatrixWithUnitPricing: + NewSubscriptionScalableMatrixWithUnitPricingPrice? = + null, + private val scalableMatrixWithTieredPricing: + NewSubscriptionScalableMatrixWithTieredPricingPrice? = + null, + private val cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice? = null, + private val minimum: NewSubscriptionMinimumCompositePrice? = null, + private val _json: JsonValue? = null, + ) { + + fun unit(): NewSubscriptionUnitPrice? = unit + + fun tiered(): NewSubscriptionTieredPrice? = tiered + + fun bulk(): NewSubscriptionBulkPrice? = bulk + + fun package_(): NewSubscriptionPackagePrice? = package_ + + fun matrix(): NewSubscriptionMatrixPrice? = matrix + + fun thresholdTotalAmount(): NewSubscriptionThresholdTotalAmountPrice? = + thresholdTotalAmount + + fun tieredPackage(): NewSubscriptionTieredPackagePrice? = tieredPackage + + fun tieredWithMinimum(): NewSubscriptionTieredWithMinimumPrice? = tieredWithMinimum + + fun groupedTiered(): NewSubscriptionGroupedTieredPrice? = groupedTiered + + fun tieredPackageWithMinimum(): NewSubscriptionTieredPackageWithMinimumPrice? = + tieredPackageWithMinimum + + fun packageWithAllocation(): NewSubscriptionPackageWithAllocationPrice? = + packageWithAllocation + + fun unitWithPercent(): NewSubscriptionUnitWithPercentPrice? = unitWithPercent + + fun matrixWithAllocation(): NewSubscriptionMatrixWithAllocationPrice? = + matrixWithAllocation + + fun tieredWithProration(): TieredWithProration? = tieredWithProration + + fun unitWithProration(): NewSubscriptionUnitWithProrationPrice? = unitWithProration + + fun groupedAllocation(): NewSubscriptionGroupedAllocationPrice? = groupedAllocation + + fun bulkWithProration(): NewSubscriptionBulkWithProrationPrice? = bulkWithProration + + fun groupedWithProratedMinimum(): NewSubscriptionGroupedWithProratedMinimumPrice? = + groupedWithProratedMinimum + + fun groupedWithMeteredMinimum(): NewSubscriptionGroupedWithMeteredMinimumPrice? = + groupedWithMeteredMinimum + + fun groupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds? = + groupedWithMinMaxThresholds + + fun matrixWithDisplayName(): NewSubscriptionMatrixWithDisplayNamePrice? = + matrixWithDisplayName + + fun groupedTieredPackage(): NewSubscriptionGroupedTieredPackagePrice? = + groupedTieredPackage + + fun maxGroupTieredPackage(): NewSubscriptionMaxGroupTieredPackagePrice? = + maxGroupTieredPackage + + fun scalableMatrixWithUnitPricing(): + NewSubscriptionScalableMatrixWithUnitPricingPrice? = scalableMatrixWithUnitPricing + + fun scalableMatrixWithTieredPricing(): + NewSubscriptionScalableMatrixWithTieredPricingPrice? = + scalableMatrixWithTieredPricing + + fun cumulativeGroupedBulk(): NewSubscriptionCumulativeGroupedBulkPrice? = + cumulativeGroupedBulk + + fun minimum(): NewSubscriptionMinimumCompositePrice? = minimum + + fun isUnit(): Boolean = unit != null + + fun isTiered(): Boolean = tiered != null + + fun isBulk(): Boolean = bulk != null + + fun isPackage(): Boolean = package_ != null + + fun isMatrix(): Boolean = matrix != null + + fun isThresholdTotalAmount(): Boolean = thresholdTotalAmount != null + + fun isTieredPackage(): Boolean = tieredPackage != null + + fun isTieredWithMinimum(): Boolean = tieredWithMinimum != null + + fun isGroupedTiered(): Boolean = groupedTiered != null + + fun isTieredPackageWithMinimum(): Boolean = tieredPackageWithMinimum != null + + fun isPackageWithAllocation(): Boolean = packageWithAllocation != null + + fun isUnitWithPercent(): Boolean = unitWithPercent != null + + fun isMatrixWithAllocation(): Boolean = matrixWithAllocation != null + + fun isTieredWithProration(): Boolean = tieredWithProration != null + + fun isUnitWithProration(): Boolean = unitWithProration != null + + fun isGroupedAllocation(): Boolean = groupedAllocation != null + + fun isBulkWithProration(): Boolean = bulkWithProration != null + + fun isGroupedWithProratedMinimum(): Boolean = groupedWithProratedMinimum != null + + fun isGroupedWithMeteredMinimum(): Boolean = groupedWithMeteredMinimum != null + + fun isGroupedWithMinMaxThresholds(): Boolean = groupedWithMinMaxThresholds != null + + fun isMatrixWithDisplayName(): Boolean = matrixWithDisplayName != null + + fun isGroupedTieredPackage(): Boolean = groupedTieredPackage != null + + fun isMaxGroupTieredPackage(): Boolean = maxGroupTieredPackage != null + + fun isScalableMatrixWithUnitPricing(): Boolean = scalableMatrixWithUnitPricing != null + + fun isScalableMatrixWithTieredPricing(): Boolean = + scalableMatrixWithTieredPricing != null + + fun isCumulativeGroupedBulk(): Boolean = cumulativeGroupedBulk != null + + fun isMinimum(): Boolean = minimum != null + + fun asUnit(): NewSubscriptionUnitPrice = unit.getOrThrow("unit") + + fun asTiered(): NewSubscriptionTieredPrice = tiered.getOrThrow("tiered") + + fun asBulk(): NewSubscriptionBulkPrice = bulk.getOrThrow("bulk") + + fun asPackage(): NewSubscriptionPackagePrice = package_.getOrThrow("package_") + + fun asMatrix(): NewSubscriptionMatrixPrice = matrix.getOrThrow("matrix") + + fun asThresholdTotalAmount(): NewSubscriptionThresholdTotalAmountPrice = + thresholdTotalAmount.getOrThrow("thresholdTotalAmount") + + fun asTieredPackage(): NewSubscriptionTieredPackagePrice = + tieredPackage.getOrThrow("tieredPackage") + + fun asTieredWithMinimum(): NewSubscriptionTieredWithMinimumPrice = + tieredWithMinimum.getOrThrow("tieredWithMinimum") + + fun asGroupedTiered(): NewSubscriptionGroupedTieredPrice = + groupedTiered.getOrThrow("groupedTiered") + + fun asTieredPackageWithMinimum(): NewSubscriptionTieredPackageWithMinimumPrice = + tieredPackageWithMinimum.getOrThrow("tieredPackageWithMinimum") + + fun asPackageWithAllocation(): NewSubscriptionPackageWithAllocationPrice = + packageWithAllocation.getOrThrow("packageWithAllocation") + + fun asUnitWithPercent(): NewSubscriptionUnitWithPercentPrice = + unitWithPercent.getOrThrow("unitWithPercent") + + fun asMatrixWithAllocation(): NewSubscriptionMatrixWithAllocationPrice = + matrixWithAllocation.getOrThrow("matrixWithAllocation") + + fun asTieredWithProration(): TieredWithProration = + tieredWithProration.getOrThrow("tieredWithProration") fun asUnitWithProration(): NewSubscriptionUnitWithProrationPrice = unitWithProration.getOrThrow("unitWithProration") - fun asGroupedAllocation(): NewSubscriptionGroupedAllocationPrice = - groupedAllocation.getOrThrow("groupedAllocation") + fun asGroupedAllocation(): NewSubscriptionGroupedAllocationPrice = + groupedAllocation.getOrThrow("groupedAllocation") + + fun asBulkWithProration(): NewSubscriptionBulkWithProrationPrice = + bulkWithProration.getOrThrow("bulkWithProration") + + fun asGroupedWithProratedMinimum(): NewSubscriptionGroupedWithProratedMinimumPrice = + groupedWithProratedMinimum.getOrThrow("groupedWithProratedMinimum") + + fun asGroupedWithMeteredMinimum(): NewSubscriptionGroupedWithMeteredMinimumPrice = + groupedWithMeteredMinimum.getOrThrow("groupedWithMeteredMinimum") + + fun asGroupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds = + groupedWithMinMaxThresholds.getOrThrow("groupedWithMinMaxThresholds") + + fun asMatrixWithDisplayName(): NewSubscriptionMatrixWithDisplayNamePrice = + matrixWithDisplayName.getOrThrow("matrixWithDisplayName") + + fun asGroupedTieredPackage(): NewSubscriptionGroupedTieredPackagePrice = + groupedTieredPackage.getOrThrow("groupedTieredPackage") + + fun asMaxGroupTieredPackage(): NewSubscriptionMaxGroupTieredPackagePrice = + maxGroupTieredPackage.getOrThrow("maxGroupTieredPackage") + + fun asScalableMatrixWithUnitPricing(): + NewSubscriptionScalableMatrixWithUnitPricingPrice = + scalableMatrixWithUnitPricing.getOrThrow("scalableMatrixWithUnitPricing") + + fun asScalableMatrixWithTieredPricing(): + NewSubscriptionScalableMatrixWithTieredPricingPrice = + scalableMatrixWithTieredPricing.getOrThrow("scalableMatrixWithTieredPricing") + + fun asCumulativeGroupedBulk(): NewSubscriptionCumulativeGroupedBulkPrice = + cumulativeGroupedBulk.getOrThrow("cumulativeGroupedBulk") + + fun asMinimum(): NewSubscriptionMinimumCompositePrice = minimum.getOrThrow("minimum") + + fun _json(): JsonValue? = _json + + fun accept(visitor: Visitor): T = + when { + unit != null -> visitor.visitUnit(unit) + tiered != null -> visitor.visitTiered(tiered) + bulk != null -> visitor.visitBulk(bulk) + package_ != null -> visitor.visitPackage(package_) + matrix != null -> visitor.visitMatrix(matrix) + thresholdTotalAmount != null -> + visitor.visitThresholdTotalAmount(thresholdTotalAmount) + tieredPackage != null -> visitor.visitTieredPackage(tieredPackage) + tieredWithMinimum != null -> visitor.visitTieredWithMinimum(tieredWithMinimum) + groupedTiered != null -> visitor.visitGroupedTiered(groupedTiered) + tieredPackageWithMinimum != null -> + visitor.visitTieredPackageWithMinimum(tieredPackageWithMinimum) + packageWithAllocation != null -> + visitor.visitPackageWithAllocation(packageWithAllocation) + unitWithPercent != null -> visitor.visitUnitWithPercent(unitWithPercent) + matrixWithAllocation != null -> + visitor.visitMatrixWithAllocation(matrixWithAllocation) + tieredWithProration != null -> + visitor.visitTieredWithProration(tieredWithProration) + unitWithProration != null -> visitor.visitUnitWithProration(unitWithProration) + groupedAllocation != null -> visitor.visitGroupedAllocation(groupedAllocation) + bulkWithProration != null -> visitor.visitBulkWithProration(bulkWithProration) + groupedWithProratedMinimum != null -> + visitor.visitGroupedWithProratedMinimum(groupedWithProratedMinimum) + groupedWithMeteredMinimum != null -> + visitor.visitGroupedWithMeteredMinimum(groupedWithMeteredMinimum) + groupedWithMinMaxThresholds != null -> + visitor.visitGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds) + matrixWithDisplayName != null -> + visitor.visitMatrixWithDisplayName(matrixWithDisplayName) + groupedTieredPackage != null -> + visitor.visitGroupedTieredPackage(groupedTieredPackage) + maxGroupTieredPackage != null -> + visitor.visitMaxGroupTieredPackage(maxGroupTieredPackage) + scalableMatrixWithUnitPricing != null -> + visitor.visitScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing) + scalableMatrixWithTieredPricing != null -> + visitor.visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing + ) + cumulativeGroupedBulk != null -> + visitor.visitCumulativeGroupedBulk(cumulativeGroupedBulk) + minimum != null -> visitor.visitMinimum(minimum) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Price = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitUnit(unit: NewSubscriptionUnitPrice) { + unit.validate() + } + + override fun visitTiered(tiered: NewSubscriptionTieredPrice) { + tiered.validate() + } + + override fun visitBulk(bulk: NewSubscriptionBulkPrice) { + bulk.validate() + } + + override fun visitPackage(package_: NewSubscriptionPackagePrice) { + package_.validate() + } + + override fun visitMatrix(matrix: NewSubscriptionMatrixPrice) { + matrix.validate() + } + + override fun visitThresholdTotalAmount( + thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice + ) { + thresholdTotalAmount.validate() + } + + override fun visitTieredPackage( + tieredPackage: NewSubscriptionTieredPackagePrice + ) { + tieredPackage.validate() + } + + override fun visitTieredWithMinimum( + tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice + ) { + tieredWithMinimum.validate() + } + + override fun visitGroupedTiered( + groupedTiered: NewSubscriptionGroupedTieredPrice + ) { + groupedTiered.validate() + } + + override fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice + ) { + tieredPackageWithMinimum.validate() + } + + override fun visitPackageWithAllocation( + packageWithAllocation: NewSubscriptionPackageWithAllocationPrice + ) { + packageWithAllocation.validate() + } + + override fun visitUnitWithPercent( + unitWithPercent: NewSubscriptionUnitWithPercentPrice + ) { + unitWithPercent.validate() + } + + override fun visitMatrixWithAllocation( + matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice + ) { + matrixWithAllocation.validate() + } + + override fun visitTieredWithProration( + tieredWithProration: TieredWithProration + ) { + tieredWithProration.validate() + } + + override fun visitUnitWithProration( + unitWithProration: NewSubscriptionUnitWithProrationPrice + ) { + unitWithProration.validate() + } + + override fun visitGroupedAllocation( + groupedAllocation: NewSubscriptionGroupedAllocationPrice + ) { + groupedAllocation.validate() + } + + override fun visitBulkWithProration( + bulkWithProration: NewSubscriptionBulkWithProrationPrice + ) { + bulkWithProration.validate() + } + + override fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: + NewSubscriptionGroupedWithProratedMinimumPrice + ) { + groupedWithProratedMinimum.validate() + } + + override fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice + ) { + groupedWithMeteredMinimum.validate() + } + + override fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) { + groupedWithMinMaxThresholds.validate() + } + + override fun visitMatrixWithDisplayName( + matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice + ) { + matrixWithDisplayName.validate() + } + + override fun visitGroupedTieredPackage( + groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice + ) { + groupedTieredPackage.validate() + } + + override fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice + ) { + maxGroupTieredPackage.validate() + } + + override fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: + NewSubscriptionScalableMatrixWithUnitPricingPrice + ) { + scalableMatrixWithUnitPricing.validate() + } + + override fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: + NewSubscriptionScalableMatrixWithTieredPricingPrice + ) { + scalableMatrixWithTieredPricing.validate() + } + + override fun visitCumulativeGroupedBulk( + cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice + ) { + cumulativeGroupedBulk.validate() + } + + override fun visitMinimum(minimum: NewSubscriptionMinimumCompositePrice) { + minimum.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitUnit(unit: NewSubscriptionUnitPrice) = unit.validity() + + override fun visitTiered(tiered: NewSubscriptionTieredPrice) = + tiered.validity() + + override fun visitBulk(bulk: NewSubscriptionBulkPrice) = bulk.validity() + + override fun visitPackage(package_: NewSubscriptionPackagePrice) = + package_.validity() + + override fun visitMatrix(matrix: NewSubscriptionMatrixPrice) = + matrix.validity() + + override fun visitThresholdTotalAmount( + thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice + ) = thresholdTotalAmount.validity() + + override fun visitTieredPackage( + tieredPackage: NewSubscriptionTieredPackagePrice + ) = tieredPackage.validity() + + override fun visitTieredWithMinimum( + tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice + ) = tieredWithMinimum.validity() + + override fun visitGroupedTiered( + groupedTiered: NewSubscriptionGroupedTieredPrice + ) = groupedTiered.validity() + + override fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice + ) = tieredPackageWithMinimum.validity() + + override fun visitPackageWithAllocation( + packageWithAllocation: NewSubscriptionPackageWithAllocationPrice + ) = packageWithAllocation.validity() + + override fun visitUnitWithPercent( + unitWithPercent: NewSubscriptionUnitWithPercentPrice + ) = unitWithPercent.validity() + + override fun visitMatrixWithAllocation( + matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice + ) = matrixWithAllocation.validity() + + override fun visitTieredWithProration( + tieredWithProration: TieredWithProration + ) = tieredWithProration.validity() + + override fun visitUnitWithProration( + unitWithProration: NewSubscriptionUnitWithProrationPrice + ) = unitWithProration.validity() + + override fun visitGroupedAllocation( + groupedAllocation: NewSubscriptionGroupedAllocationPrice + ) = groupedAllocation.validity() + + override fun visitBulkWithProration( + bulkWithProration: NewSubscriptionBulkWithProrationPrice + ) = bulkWithProration.validity() + + override fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: + NewSubscriptionGroupedWithProratedMinimumPrice + ) = groupedWithProratedMinimum.validity() + + override fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice + ) = groupedWithMeteredMinimum.validity() + + override fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) = groupedWithMinMaxThresholds.validity() + + override fun visitMatrixWithDisplayName( + matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice + ) = matrixWithDisplayName.validity() + + override fun visitGroupedTieredPackage( + groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice + ) = groupedTieredPackage.validity() + + override fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice + ) = maxGroupTieredPackage.validity() + + override fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: + NewSubscriptionScalableMatrixWithUnitPricingPrice + ) = scalableMatrixWithUnitPricing.validity() + + override fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: + NewSubscriptionScalableMatrixWithTieredPricingPrice + ) = scalableMatrixWithTieredPricing.validity() + + override fun visitCumulativeGroupedBulk( + cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice + ) = cumulativeGroupedBulk.validity() + + override fun visitMinimum(minimum: NewSubscriptionMinimumCompositePrice) = + minimum.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Price && + unit == other.unit && + tiered == other.tiered && + bulk == other.bulk && + package_ == other.package_ && + matrix == other.matrix && + thresholdTotalAmount == other.thresholdTotalAmount && + tieredPackage == other.tieredPackage && + tieredWithMinimum == other.tieredWithMinimum && + groupedTiered == other.groupedTiered && + tieredPackageWithMinimum == other.tieredPackageWithMinimum && + packageWithAllocation == other.packageWithAllocation && + unitWithPercent == other.unitWithPercent && + matrixWithAllocation == other.matrixWithAllocation && + tieredWithProration == other.tieredWithProration && + unitWithProration == other.unitWithProration && + groupedAllocation == other.groupedAllocation && + bulkWithProration == other.bulkWithProration && + groupedWithProratedMinimum == other.groupedWithProratedMinimum && + groupedWithMeteredMinimum == other.groupedWithMeteredMinimum && + groupedWithMinMaxThresholds == other.groupedWithMinMaxThresholds && + matrixWithDisplayName == other.matrixWithDisplayName && + groupedTieredPackage == other.groupedTieredPackage && + maxGroupTieredPackage == other.maxGroupTieredPackage && + scalableMatrixWithUnitPricing == other.scalableMatrixWithUnitPricing && + scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && + cumulativeGroupedBulk == other.cumulativeGroupedBulk && + minimum == other.minimum + } + + override fun hashCode(): Int = + Objects.hash( + unit, + tiered, + bulk, + package_, + matrix, + thresholdTotalAmount, + tieredPackage, + tieredWithMinimum, + groupedTiered, + tieredPackageWithMinimum, + packageWithAllocation, + unitWithPercent, + matrixWithAllocation, + tieredWithProration, + unitWithProration, + groupedAllocation, + bulkWithProration, + groupedWithProratedMinimum, + groupedWithMeteredMinimum, + groupedWithMinMaxThresholds, + matrixWithDisplayName, + groupedTieredPackage, + maxGroupTieredPackage, + scalableMatrixWithUnitPricing, + scalableMatrixWithTieredPricing, + cumulativeGroupedBulk, + minimum, + ) + + override fun toString(): String = + when { + unit != null -> "Price{unit=$unit}" + tiered != null -> "Price{tiered=$tiered}" + bulk != null -> "Price{bulk=$bulk}" + package_ != null -> "Price{package_=$package_}" + matrix != null -> "Price{matrix=$matrix}" + thresholdTotalAmount != null -> + "Price{thresholdTotalAmount=$thresholdTotalAmount}" + tieredPackage != null -> "Price{tieredPackage=$tieredPackage}" + tieredWithMinimum != null -> "Price{tieredWithMinimum=$tieredWithMinimum}" + groupedTiered != null -> "Price{groupedTiered=$groupedTiered}" + tieredPackageWithMinimum != null -> + "Price{tieredPackageWithMinimum=$tieredPackageWithMinimum}" + packageWithAllocation != null -> + "Price{packageWithAllocation=$packageWithAllocation}" + unitWithPercent != null -> "Price{unitWithPercent=$unitWithPercent}" + matrixWithAllocation != null -> + "Price{matrixWithAllocation=$matrixWithAllocation}" + tieredWithProration != null -> "Price{tieredWithProration=$tieredWithProration}" + unitWithProration != null -> "Price{unitWithProration=$unitWithProration}" + groupedAllocation != null -> "Price{groupedAllocation=$groupedAllocation}" + bulkWithProration != null -> "Price{bulkWithProration=$bulkWithProration}" + groupedWithProratedMinimum != null -> + "Price{groupedWithProratedMinimum=$groupedWithProratedMinimum}" + groupedWithMeteredMinimum != null -> + "Price{groupedWithMeteredMinimum=$groupedWithMeteredMinimum}" + groupedWithMinMaxThresholds != null -> + "Price{groupedWithMinMaxThresholds=$groupedWithMinMaxThresholds}" + matrixWithDisplayName != null -> + "Price{matrixWithDisplayName=$matrixWithDisplayName}" + groupedTieredPackage != null -> + "Price{groupedTieredPackage=$groupedTieredPackage}" + maxGroupTieredPackage != null -> + "Price{maxGroupTieredPackage=$maxGroupTieredPackage}" + scalableMatrixWithUnitPricing != null -> + "Price{scalableMatrixWithUnitPricing=$scalableMatrixWithUnitPricing}" + scalableMatrixWithTieredPricing != null -> + "Price{scalableMatrixWithTieredPricing=$scalableMatrixWithTieredPricing}" + cumulativeGroupedBulk != null -> + "Price{cumulativeGroupedBulk=$cumulativeGroupedBulk}" + minimum != null -> "Price{minimum=$minimum}" + _json != null -> "Price{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Price") + } + + companion object { + + fun ofUnit(unit: NewSubscriptionUnitPrice) = Price(unit = unit) + + fun ofTiered(tiered: NewSubscriptionTieredPrice) = Price(tiered = tiered) + + fun ofBulk(bulk: NewSubscriptionBulkPrice) = Price(bulk = bulk) + + fun ofPackage(package_: NewSubscriptionPackagePrice) = Price(package_ = package_) + + fun ofMatrix(matrix: NewSubscriptionMatrixPrice) = Price(matrix = matrix) + + fun ofThresholdTotalAmount( + thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice + ) = Price(thresholdTotalAmount = thresholdTotalAmount) + + fun ofTieredPackage(tieredPackage: NewSubscriptionTieredPackagePrice) = + Price(tieredPackage = tieredPackage) + + fun ofTieredWithMinimum(tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice) = + Price(tieredWithMinimum = tieredWithMinimum) + + fun ofGroupedTiered(groupedTiered: NewSubscriptionGroupedTieredPrice) = + Price(groupedTiered = groupedTiered) + + fun ofTieredPackageWithMinimum( + tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice + ) = Price(tieredPackageWithMinimum = tieredPackageWithMinimum) + + fun ofPackageWithAllocation( + packageWithAllocation: NewSubscriptionPackageWithAllocationPrice + ) = Price(packageWithAllocation = packageWithAllocation) + + fun ofUnitWithPercent(unitWithPercent: NewSubscriptionUnitWithPercentPrice) = + Price(unitWithPercent = unitWithPercent) + + fun ofMatrixWithAllocation( + matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice + ) = Price(matrixWithAllocation = matrixWithAllocation) + + fun ofTieredWithProration(tieredWithProration: TieredWithProration) = + Price(tieredWithProration = tieredWithProration) + + fun ofUnitWithProration(unitWithProration: NewSubscriptionUnitWithProrationPrice) = + Price(unitWithProration = unitWithProration) + + fun ofGroupedAllocation(groupedAllocation: NewSubscriptionGroupedAllocationPrice) = + Price(groupedAllocation = groupedAllocation) + + fun ofBulkWithProration(bulkWithProration: NewSubscriptionBulkWithProrationPrice) = + Price(bulkWithProration = bulkWithProration) + + fun ofGroupedWithProratedMinimum( + groupedWithProratedMinimum: NewSubscriptionGroupedWithProratedMinimumPrice + ) = Price(groupedWithProratedMinimum = groupedWithProratedMinimum) + + fun ofGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice + ) = Price(groupedWithMeteredMinimum = groupedWithMeteredMinimum) + + fun ofGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) = Price(groupedWithMinMaxThresholds = groupedWithMinMaxThresholds) + + fun ofMatrixWithDisplayName( + matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice + ) = Price(matrixWithDisplayName = matrixWithDisplayName) + + fun ofGroupedTieredPackage( + groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice + ) = Price(groupedTieredPackage = groupedTieredPackage) + + fun ofMaxGroupTieredPackage( + maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice + ) = Price(maxGroupTieredPackage = maxGroupTieredPackage) + + fun ofScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: NewSubscriptionScalableMatrixWithUnitPricingPrice + ) = Price(scalableMatrixWithUnitPricing = scalableMatrixWithUnitPricing) + + fun ofScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: + NewSubscriptionScalableMatrixWithTieredPricingPrice + ) = Price(scalableMatrixWithTieredPricing = scalableMatrixWithTieredPricing) + + fun ofCumulativeGroupedBulk( + cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice + ) = Price(cumulativeGroupedBulk = cumulativeGroupedBulk) + + fun ofMinimum(minimum: NewSubscriptionMinimumCompositePrice) = + Price(minimum = minimum) + } + + /** + * An interface that defines how to map each variant of [Price] to a value of type [T]. + */ + interface Visitor { + + fun visitUnit(unit: NewSubscriptionUnitPrice): T + + fun visitTiered(tiered: NewSubscriptionTieredPrice): T + + fun visitBulk(bulk: NewSubscriptionBulkPrice): T + + fun visitPackage(package_: NewSubscriptionPackagePrice): T + + fun visitMatrix(matrix: NewSubscriptionMatrixPrice): T + + fun visitThresholdTotalAmount( + thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice + ): T + + fun visitTieredPackage(tieredPackage: NewSubscriptionTieredPackagePrice): T + + fun visitTieredWithMinimum( + tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice + ): T + + fun visitGroupedTiered(groupedTiered: NewSubscriptionGroupedTieredPrice): T + + fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice + ): T + + fun visitPackageWithAllocation( + packageWithAllocation: NewSubscriptionPackageWithAllocationPrice + ): T + + fun visitUnitWithPercent(unitWithPercent: NewSubscriptionUnitWithPercentPrice): T + + fun visitMatrixWithAllocation( + matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice + ): T + + fun visitTieredWithProration(tieredWithProration: TieredWithProration): T + + fun visitUnitWithProration( + unitWithProration: NewSubscriptionUnitWithProrationPrice + ): T + + fun visitGroupedAllocation( + groupedAllocation: NewSubscriptionGroupedAllocationPrice + ): T + + fun visitBulkWithProration( + bulkWithProration: NewSubscriptionBulkWithProrationPrice + ): T + + fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: NewSubscriptionGroupedWithProratedMinimumPrice + ): T + + fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice + ): T + + fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ): T + + fun visitMatrixWithDisplayName( + matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice + ): T + + fun visitGroupedTieredPackage( + groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice + ): T + + fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice + ): T + + fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: NewSubscriptionScalableMatrixWithUnitPricingPrice + ): T + + fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: + NewSubscriptionScalableMatrixWithTieredPricingPrice + ): T + + fun visitCumulativeGroupedBulk( + cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice + ): T + + fun visitMinimum(minimum: NewSubscriptionMinimumCompositePrice): T + + /** + * Maps an unknown variant of [Price] to a value of type [T]. + * + * An instance of [Price] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is + * unaware of. + * + * @throws OrbInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw OrbInvalidDataException("Unknown Price: $json") + } + } + + internal class Deserializer : BaseDeserializer(Price::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Price { + val json = JsonValue.fromJsonNode(node) + val modelType = json.asObject()?.get("model_type")?.asString() + + when (modelType) { + "unit" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(unit = it, _json = json) } ?: Price(_json = json) + } + "tiered" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(tiered = it, _json = json) } ?: Price(_json = json) + } + "bulk" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(bulk = it, _json = json) } ?: Price(_json = json) + } + "package" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(package_ = it, _json = json) } ?: Price(_json = json) + } + "matrix" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(matrix = it, _json = json) } ?: Price(_json = json) + } + "threshold_total_amount" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(thresholdTotalAmount = it, _json = json) } + ?: Price(_json = json) + } + "tiered_package" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(tieredPackage = it, _json = json) } + ?: Price(_json = json) + } + "tiered_with_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(tieredWithMinimum = it, _json = json) } + ?: Price(_json = json) + } + "grouped_tiered" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedTiered = it, _json = json) } + ?: Price(_json = json) + } + "tiered_package_with_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(tieredPackageWithMinimum = it, _json = json) } + ?: Price(_json = json) + } + "package_with_allocation" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(packageWithAllocation = it, _json = json) } + ?: Price(_json = json) + } + "unit_with_percent" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(unitWithPercent = it, _json = json) } + ?: Price(_json = json) + } + "matrix_with_allocation" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(matrixWithAllocation = it, _json = json) } + ?: Price(_json = json) + } + "tiered_with_proration" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(tieredWithProration = it, _json = json) } + ?: Price(_json = json) + } + "unit_with_proration" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(unitWithProration = it, _json = json) } + ?: Price(_json = json) + } + "grouped_allocation" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedAllocation = it, _json = json) } + ?: Price(_json = json) + } + "bulk_with_proration" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(bulkWithProration = it, _json = json) } + ?: Price(_json = json) + } + "grouped_with_prorated_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedWithProratedMinimum = it, _json = json) } + ?: Price(_json = json) + } + "grouped_with_metered_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedWithMeteredMinimum = it, _json = json) } + ?: Price(_json = json) + } + "grouped_with_min_max_thresholds" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedWithMinMaxThresholds = it, _json = json) } + ?: Price(_json = json) + } + "matrix_with_display_name" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(matrixWithDisplayName = it, _json = json) } + ?: Price(_json = json) + } + "grouped_tiered_package" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedTieredPackage = it, _json = json) } + ?: Price(_json = json) + } + "max_group_tiered_package" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(maxGroupTieredPackage = it, _json = json) } + ?: Price(_json = json) + } + "scalable_matrix_with_unit_pricing" -> { + return tryDeserialize( + node, + jacksonTypeRef< + NewSubscriptionScalableMatrixWithUnitPricingPrice + >(), + ) + ?.let { Price(scalableMatrixWithUnitPricing = it, _json = json) } + ?: Price(_json = json) + } + "scalable_matrix_with_tiered_pricing" -> { + return tryDeserialize( + node, + jacksonTypeRef< + NewSubscriptionScalableMatrixWithTieredPricingPrice + >(), + ) + ?.let { Price(scalableMatrixWithTieredPricing = it, _json = json) } + ?: Price(_json = json) + } + "cumulative_grouped_bulk" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(cumulativeGroupedBulk = it, _json = json) } + ?: Price(_json = json) + } + "minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(minimum = it, _json = json) } ?: Price(_json = json) + } + } + + return Price(_json = json) + } + } - fun asGroupedWithProratedMinimum(): NewSubscriptionGroupedWithProratedMinimumPrice = - groupedWithProratedMinimum.getOrThrow("groupedWithProratedMinimum") + internal class Serializer : BaseSerializer(Price::class) { - fun asBulkWithProration(): NewSubscriptionBulkWithProrationPrice = - bulkWithProration.getOrThrow("bulkWithProration") + override fun serialize( + value: Price, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.unit != null -> generator.writeObject(value.unit) + value.tiered != null -> generator.writeObject(value.tiered) + value.bulk != null -> generator.writeObject(value.bulk) + value.package_ != null -> generator.writeObject(value.package_) + value.matrix != null -> generator.writeObject(value.matrix) + value.thresholdTotalAmount != null -> + generator.writeObject(value.thresholdTotalAmount) + value.tieredPackage != null -> generator.writeObject(value.tieredPackage) + value.tieredWithMinimum != null -> + generator.writeObject(value.tieredWithMinimum) + value.groupedTiered != null -> generator.writeObject(value.groupedTiered) + value.tieredPackageWithMinimum != null -> + generator.writeObject(value.tieredPackageWithMinimum) + value.packageWithAllocation != null -> + generator.writeObject(value.packageWithAllocation) + value.unitWithPercent != null -> + generator.writeObject(value.unitWithPercent) + value.matrixWithAllocation != null -> + generator.writeObject(value.matrixWithAllocation) + value.tieredWithProration != null -> + generator.writeObject(value.tieredWithProration) + value.unitWithProration != null -> + generator.writeObject(value.unitWithProration) + value.groupedAllocation != null -> + generator.writeObject(value.groupedAllocation) + value.bulkWithProration != null -> + generator.writeObject(value.bulkWithProration) + value.groupedWithProratedMinimum != null -> + generator.writeObject(value.groupedWithProratedMinimum) + value.groupedWithMeteredMinimum != null -> + generator.writeObject(value.groupedWithMeteredMinimum) + value.groupedWithMinMaxThresholds != null -> + generator.writeObject(value.groupedWithMinMaxThresholds) + value.matrixWithDisplayName != null -> + generator.writeObject(value.matrixWithDisplayName) + value.groupedTieredPackage != null -> + generator.writeObject(value.groupedTieredPackage) + value.maxGroupTieredPackage != null -> + generator.writeObject(value.maxGroupTieredPackage) + value.scalableMatrixWithUnitPricing != null -> + generator.writeObject(value.scalableMatrixWithUnitPricing) + value.scalableMatrixWithTieredPricing != null -> + generator.writeObject(value.scalableMatrixWithTieredPricing) + value.cumulativeGroupedBulk != null -> + generator.writeObject(value.cumulativeGroupedBulk) + value.minimum != null -> generator.writeObject(value.minimum) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Price") + } + } + } - fun asScalableMatrixWithUnitPricing(): - NewSubscriptionScalableMatrixWithUnitPricingPrice = - scalableMatrixWithUnitPricing.getOrThrow("scalableMatrixWithUnitPricing") + class TieredWithProration + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val tieredWithProrationConfig: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { - fun asScalableMatrixWithTieredPricing(): - NewSubscriptionScalableMatrixWithTieredPricingPrice = - scalableMatrixWithTieredPricing.getOrThrow("scalableMatrixWithTieredPricing") + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("tiered_with_proration_config") + @ExcludeMissing + tieredWithProrationConfig: JsonField = + JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + modelType, + name, + tieredWithProrationConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + mutableMapOf(), + ) - fun asCumulativeGroupedBulk(): NewSubscriptionCumulativeGroupedBulkPrice = - cumulativeGroupedBulk.getOrThrow("cumulativeGroupedBulk") + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") - fun asMaxGroupTieredPackage(): NewSubscriptionMaxGroupTieredPackagePrice = - maxGroupTieredPackage.getOrThrow("maxGroupTieredPackage") + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("tiered_with_proration") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") - fun asGroupedWithMeteredMinimum(): NewSubscriptionGroupedWithMeteredMinimumPrice = - groupedWithMeteredMinimum.getOrThrow("groupedWithMeteredMinimum") + /** + * Configuration for tiered_with_proration pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun tieredWithProrationConfig(): TieredWithProrationConfig = + tieredWithProrationConfig.getRequired("tiered_with_proration_config") - fun asMatrixWithDisplayName(): NewSubscriptionMatrixWithDisplayNamePrice = - matrixWithDisplayName.getOrThrow("matrixWithDisplayName") + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = billableMetricId.getNullable("billable_metric_id") - fun asGroupedTieredPackage(): NewSubscriptionGroupedTieredPackagePrice = - groupedTieredPackage.getOrThrow("groupedTieredPackage") + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") - fun asMatrixWithAllocation(): NewSubscriptionMatrixWithAllocationPrice = - matrixWithAllocation.getOrThrow("matrixWithAllocation") + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") - fun asTieredPackageWithMinimum(): NewSubscriptionTieredPackageWithMinimumPrice = - tieredPackageWithMinimum.getOrThrow("tieredPackageWithMinimum") + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") - fun asGroupedTiered(): NewSubscriptionGroupedTieredPrice = - groupedTiered.getOrThrow("groupedTiered") + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") - fun asGroupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds = - groupedWithMinMaxThresholds.getOrThrow("groupedWithMinMaxThresholds") + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") - fun asMinimum(): NewSubscriptionMinimumCompositePrice = minimum.getOrThrow("minimum") + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") - fun _json(): JsonValue? = _json + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - package_ != null -> visitor.visitPackage(package_) - matrix != null -> visitor.visitMatrix(matrix) - tiered != null -> visitor.visitTiered(tiered) - bulk != null -> visitor.visitBulk(bulk) - thresholdTotalAmount != null -> - visitor.visitThresholdTotalAmount(thresholdTotalAmount) - tieredPackage != null -> visitor.visitTieredPackage(tieredPackage) - tieredWithMinimum != null -> visitor.visitTieredWithMinimum(tieredWithMinimum) - unitWithPercent != null -> visitor.visitUnitWithPercent(unitWithPercent) - packageWithAllocation != null -> - visitor.visitPackageWithAllocation(packageWithAllocation) - tieredWithProration != null -> - visitor.visitTieredWithProration(tieredWithProration) - unitWithProration != null -> visitor.visitUnitWithProration(unitWithProration) - groupedAllocation != null -> visitor.visitGroupedAllocation(groupedAllocation) - groupedWithProratedMinimum != null -> - visitor.visitGroupedWithProratedMinimum(groupedWithProratedMinimum) - bulkWithProration != null -> visitor.visitBulkWithProration(bulkWithProration) - scalableMatrixWithUnitPricing != null -> - visitor.visitScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing) - scalableMatrixWithTieredPricing != null -> - visitor.visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing - ) - cumulativeGroupedBulk != null -> - visitor.visitCumulativeGroupedBulk(cumulativeGroupedBulk) - maxGroupTieredPackage != null -> - visitor.visitMaxGroupTieredPackage(maxGroupTieredPackage) - groupedWithMeteredMinimum != null -> - visitor.visitGroupedWithMeteredMinimum(groupedWithMeteredMinimum) - matrixWithDisplayName != null -> - visitor.visitMatrixWithDisplayName(matrixWithDisplayName) - groupedTieredPackage != null -> - visitor.visitGroupedTieredPackage(groupedTieredPackage) - matrixWithAllocation != null -> - visitor.visitMatrixWithAllocation(matrixWithAllocation) - tieredPackageWithMinimum != null -> - visitor.visitTieredPackageWithMinimum(tieredPackageWithMinimum) - groupedTiered != null -> visitor.visitGroupedTiered(groupedTiered) - groupedWithMinMaxThresholds != null -> - visitor.visitGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds) - minimum != null -> visitor.visitMinimum(minimum) - else -> visitor.unknown(_json) - } + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") - private var validated: Boolean = false + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + invoiceGroupingKey.getNullable("invoice_grouping_key") - fun validate(): Price = apply { - if (validated) { - return@apply - } + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - accept( - object : Visitor { - override fun visitUnit(unit: NewSubscriptionUnitPrice) { - unit.validate() - } + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") - override fun visitPackage(package_: NewSubscriptionPackagePrice) { - package_.validate() - } + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") - override fun visitMatrix(matrix: NewSubscriptionMatrixPrice) { - matrix.validate() - } + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence - override fun visitTiered(tiered: NewSubscriptionTieredPrice) { - tiered.validate() - } + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - override fun visitBulk(bulk: NewSubscriptionBulkPrice) { - bulk.validate() - } + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - override fun visitThresholdTotalAmount( - thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice - ) { - thresholdTotalAmount.validate() - } + /** + * Returns the raw JSON value of [tieredWithProrationConfig]. + * + * Unlike [tieredWithProrationConfig], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("tiered_with_proration_config") + @ExcludeMissing + fun _tieredWithProrationConfig(): JsonField = + tieredWithProrationConfig - override fun visitTieredPackage( - tieredPackage: NewSubscriptionTieredPackagePrice - ) { - tieredPackage.validate() - } + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId - override fun visitTieredWithMinimum( - tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice - ) { - tieredWithMinimum.validate() - } + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance - override fun visitUnitWithPercent( - unitWithPercent: NewSubscriptionUnitWithPercentPrice - ) { - unitWithPercent.validate() - } + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration - override fun visitPackageWithAllocation( - packageWithAllocation: NewSubscriptionPackageWithAllocationPrice - ) { - packageWithAllocation.validate() - } + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate - override fun visitTieredWithProration( - tieredWithProration: NewSubscriptionTierWithProrationPrice - ) { - tieredWithProration.validate() - } + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig - override fun visitUnitWithProration( - unitWithProration: NewSubscriptionUnitWithProrationPrice - ) { - unitWithProration.validate() - } + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency - override fun visitGroupedAllocation( - groupedAllocation: NewSubscriptionGroupedAllocationPrice - ) { - groupedAllocation.validate() - } + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration - override fun visitGroupedWithProratedMinimum( - groupedWithProratedMinimum: - NewSubscriptionGroupedWithProratedMinimumPrice - ) { - groupedWithProratedMinimum.validate() - } + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId - override fun visitBulkWithProration( - bulkWithProration: NewSubscriptionBulkWithProrationPrice - ) { - bulkWithProration.validate() - } + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - override fun visitScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: - NewSubscriptionScalableMatrixWithUnitPricingPrice - ) { - scalableMatrixWithUnitPricing.validate() - } + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - override fun visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: - NewSubscriptionScalableMatrixWithTieredPricingPrice - ) { - scalableMatrixWithTieredPricing.validate() - } + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration - override fun visitCumulativeGroupedBulk( - cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice - ) { - cumulativeGroupedBulk.validate() - } + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata - override fun visitMaxGroupTieredPackage( - maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice - ) { - maxGroupTieredPackage.validate() - } + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId - override fun visitGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice - ) { - groupedWithMeteredMinimum.validate() - } + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - override fun visitMatrixWithDisplayName( - matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice - ) { - matrixWithDisplayName.validate() - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - override fun visitGroupedTieredPackage( - groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice - ) { - groupedTieredPackage.validate() - } + fun toBuilder() = Builder().from(this) - override fun visitMatrixWithAllocation( - matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice - ) { - matrixWithAllocation.validate() - } + companion object { - override fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice - ) { - tieredPackageWithMinimum.validate() - } + /** + * Returns a mutable builder for constructing an instance of + * [TieredWithProration]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .name() + * .tieredWithProrationConfig() + * ``` + */ + fun builder() = Builder() + } - override fun visitGroupedTiered( - groupedTiered: NewSubscriptionGroupedTieredPrice - ) { - groupedTiered.validate() - } + /** A builder for [TieredWithProration]. */ + class Builder internal constructor() { - override fun visitGroupedWithMinMaxThresholds( - groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds - ) { - groupedWithMinMaxThresholds.validate() - } + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonValue = JsonValue.from("tiered_with_proration") + private var name: JsonField? = null + private var tieredWithProrationConfig: JsonField? = + null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - override fun visitMinimum(minimum: NewSubscriptionMinimumCompositePrice) { - minimum.validate() - } + internal fun from(tieredWithProration: TieredWithProration) = apply { + cadence = tieredWithProration.cadence + itemId = tieredWithProration.itemId + modelType = tieredWithProration.modelType + name = tieredWithProration.name + tieredWithProrationConfig = tieredWithProration.tieredWithProrationConfig + billableMetricId = tieredWithProration.billableMetricId + billedInAdvance = tieredWithProration.billedInAdvance + billingCycleConfiguration = tieredWithProration.billingCycleConfiguration + conversionRate = tieredWithProration.conversionRate + conversionRateConfig = tieredWithProration.conversionRateConfig + currency = tieredWithProration.currency + dimensionalPriceConfiguration = + tieredWithProration.dimensionalPriceConfiguration + externalPriceId = tieredWithProration.externalPriceId + fixedPriceQuantity = tieredWithProration.fixedPriceQuantity + invoiceGroupingKey = tieredWithProration.invoiceGroupingKey + invoicingCycleConfiguration = + tieredWithProration.invoicingCycleConfiguration + metadata = tieredWithProration.metadata + referenceId = tieredWithProration.referenceId + additionalProperties = + tieredWithProration.additionalProperties.toMutableMap() } - ) - validated = true - } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: NewSubscriptionUnitPrice) = unit.validity() + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - override fun visitPackage(package_: NewSubscriptionPackagePrice) = - package_.validity() + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - override fun visitMatrix(matrix: NewSubscriptionMatrixPrice) = - matrix.validity() + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - override fun visitTiered(tiered: NewSubscriptionTieredPrice) = - tiered.validity() + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("tiered_with_proration") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } - override fun visitBulk(bulk: NewSubscriptionBulkPrice) = bulk.validity() + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) - override fun visitThresholdTotalAmount( - thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice - ) = thresholdTotalAmount.validity() + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } - override fun visitTieredPackage( - tieredPackage: NewSubscriptionTieredPackagePrice - ) = tieredPackage.validity() + /** Configuration for tiered_with_proration pricing */ + fun tieredWithProrationConfig( + tieredWithProrationConfig: TieredWithProrationConfig + ) = tieredWithProrationConfig(JsonField.of(tieredWithProrationConfig)) - override fun visitTieredWithMinimum( - tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice - ) = tieredWithMinimum.validity() + /** + * Sets [Builder.tieredWithProrationConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.tieredWithProrationConfig] with a well-typed + * [TieredWithProrationConfig] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun tieredWithProrationConfig( + tieredWithProrationConfig: JsonField + ) = apply { this.tieredWithProrationConfig = tieredWithProrationConfig } - override fun visitUnitWithPercent( - unitWithPercent: NewSubscriptionUnitWithPercentPrice - ) = unitWithPercent.validity() + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) - override fun visitPackageWithAllocation( - packageWithAllocation: NewSubscriptionPackageWithAllocationPrice - ) = packageWithAllocation.validity() + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } - override fun visitTieredWithProration( - tieredWithProration: NewSubscriptionTierWithProrationPrice - ) = tieredWithProration.validity() + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) - override fun visitUnitWithProration( - unitWithProration: NewSubscriptionUnitWithProrationPrice - ) = unitWithProration.validity() + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) - override fun visitGroupedAllocation( - groupedAllocation: NewSubscriptionGroupedAllocationPrice - ) = groupedAllocation.validity() + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } - override fun visitGroupedWithProratedMinimum( - groupedWithProratedMinimum: - NewSubscriptionGroupedWithProratedMinimumPrice - ) = groupedWithProratedMinimum.validity() + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - override fun visitBulkWithProration( - bulkWithProration: NewSubscriptionBulkWithProrationPrice - ) = bulkWithProration.validity() + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } - override fun visitScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: - NewSubscriptionScalableMatrixWithUnitPricingPrice - ) = scalableMatrixWithUnitPricing.validity() + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) - override fun visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: - NewSubscriptionScalableMatrixWithTieredPricingPrice - ) = scalableMatrixWithTieredPricing.validity() + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) - override fun visitCumulativeGroupedBulk( - cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice - ) = cumulativeGroupedBulk.validity() + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } - override fun visitMaxGroupTieredPackage( - maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice - ) = maxGroupTieredPackage.validity() + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) - override fun visitGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice - ) = groupedWithMeteredMinimum.validity() + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } - override fun visitMatrixWithDisplayName( - matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice - ) = matrixWithDisplayName.validity() + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) - override fun visitGroupedTieredPackage( - groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice - ) = groupedTieredPackage.validity() + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) - override fun visitMatrixWithAllocation( - matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice - ) = matrixWithAllocation.validity() + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) - override fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice - ) = tieredPackageWithMinimum.validity() + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } - override fun visitGroupedTiered( - groupedTiered: NewSubscriptionGroupedTieredPrice - ) = groupedTiered.validity() + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) - override fun visitGroupedWithMinMaxThresholds( - groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds - ) = groupedWithMinMaxThresholds.validity() + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } - override fun visitMinimum(minimum: NewSubscriptionMinimumCompositePrice) = - minimum.validity() + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) - override fun unknown(json: JsonValue?) = 0 + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - return other is Price && - unit == other.unit && - package_ == other.package_ && - matrix == other.matrix && - tiered == other.tiered && - bulk == other.bulk && - thresholdTotalAmount == other.thresholdTotalAmount && - tieredPackage == other.tieredPackage && - tieredWithMinimum == other.tieredWithMinimum && - unitWithPercent == other.unitWithPercent && - packageWithAllocation == other.packageWithAllocation && - tieredWithProration == other.tieredWithProration && - unitWithProration == other.unitWithProration && - groupedAllocation == other.groupedAllocation && - groupedWithProratedMinimum == other.groupedWithProratedMinimum && - bulkWithProration == other.bulkWithProration && - scalableMatrixWithUnitPricing == other.scalableMatrixWithUnitPricing && - scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && - cumulativeGroupedBulk == other.cumulativeGroupedBulk && - maxGroupTieredPackage == other.maxGroupTieredPackage && - groupedWithMeteredMinimum == other.groupedWithMeteredMinimum && - matrixWithDisplayName == other.matrixWithDisplayName && - groupedTieredPackage == other.groupedTieredPackage && - matrixWithAllocation == other.matrixWithAllocation && - tieredPackageWithMinimum == other.tieredPackageWithMinimum && - groupedTiered == other.groupedTiered && - groupedWithMinMaxThresholds == other.groupedWithMinMaxThresholds && - minimum == other.minimum - } + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) - override fun hashCode(): Int = - Objects.hash( - unit, - package_, - matrix, - tiered, - bulk, - thresholdTotalAmount, - tieredPackage, - tieredWithMinimum, - unitWithPercent, - packageWithAllocation, - tieredWithProration, - unitWithProration, - groupedAllocation, - groupedWithProratedMinimum, - bulkWithProration, - scalableMatrixWithUnitPricing, - scalableMatrixWithTieredPricing, - cumulativeGroupedBulk, - maxGroupTieredPackage, - groupedWithMeteredMinimum, - matrixWithDisplayName, - groupedTieredPackage, - matrixWithAllocation, - tieredPackageWithMinimum, - groupedTiered, - groupedWithMinMaxThresholds, - minimum, - ) + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) - override fun toString(): String = - when { - unit != null -> "Price{unit=$unit}" - package_ != null -> "Price{package_=$package_}" - matrix != null -> "Price{matrix=$matrix}" - tiered != null -> "Price{tiered=$tiered}" - bulk != null -> "Price{bulk=$bulk}" - thresholdTotalAmount != null -> - "Price{thresholdTotalAmount=$thresholdTotalAmount}" - tieredPackage != null -> "Price{tieredPackage=$tieredPackage}" - tieredWithMinimum != null -> "Price{tieredWithMinimum=$tieredWithMinimum}" - unitWithPercent != null -> "Price{unitWithPercent=$unitWithPercent}" - packageWithAllocation != null -> - "Price{packageWithAllocation=$packageWithAllocation}" - tieredWithProration != null -> "Price{tieredWithProration=$tieredWithProration}" - unitWithProration != null -> "Price{unitWithProration=$unitWithProration}" - groupedAllocation != null -> "Price{groupedAllocation=$groupedAllocation}" - groupedWithProratedMinimum != null -> - "Price{groupedWithProratedMinimum=$groupedWithProratedMinimum}" - bulkWithProration != null -> "Price{bulkWithProration=$bulkWithProration}" - scalableMatrixWithUnitPricing != null -> - "Price{scalableMatrixWithUnitPricing=$scalableMatrixWithUnitPricing}" - scalableMatrixWithTieredPricing != null -> - "Price{scalableMatrixWithTieredPricing=$scalableMatrixWithTieredPricing}" - cumulativeGroupedBulk != null -> - "Price{cumulativeGroupedBulk=$cumulativeGroupedBulk}" - maxGroupTieredPackage != null -> - "Price{maxGroupTieredPackage=$maxGroupTieredPackage}" - groupedWithMeteredMinimum != null -> - "Price{groupedWithMeteredMinimum=$groupedWithMeteredMinimum}" - matrixWithDisplayName != null -> - "Price{matrixWithDisplayName=$matrixWithDisplayName}" - groupedTieredPackage != null -> - "Price{groupedTieredPackage=$groupedTieredPackage}" - matrixWithAllocation != null -> - "Price{matrixWithAllocation=$matrixWithAllocation}" - tieredPackageWithMinimum != null -> - "Price{tieredPackageWithMinimum=$tieredPackageWithMinimum}" - groupedTiered != null -> "Price{groupedTiered=$groupedTiered}" - groupedWithMinMaxThresholds != null -> - "Price{groupedWithMinMaxThresholds=$groupedWithMinMaxThresholds}" - minimum != null -> "Price{minimum=$minimum}" - _json != null -> "Price{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Price") - } + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } - companion object { + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) - fun ofUnit(unit: NewSubscriptionUnitPrice) = Price(unit = unit) + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } - fun ofPackage(package_: NewSubscriptionPackagePrice) = Price(package_ = package_) + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) - fun ofMatrix(matrix: NewSubscriptionMatrixPrice) = Price(matrix = matrix) + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - fun ofTiered(tiered: NewSubscriptionTieredPrice) = Price(tiered = tiered) + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - fun ofBulk(bulk: NewSubscriptionBulkPrice) = Price(bulk = bulk) + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - fun ofThresholdTotalAmount( - thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice - ) = Price(thresholdTotalAmount = thresholdTotalAmount) + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) - fun ofTieredPackage(tieredPackage: NewSubscriptionTieredPackagePrice) = - Price(tieredPackage = tieredPackage) + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } - fun ofTieredWithMinimum(tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice) = - Price(tieredWithMinimum = tieredWithMinimum) + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun ofUnitWithPercent(unitWithPercent: NewSubscriptionUnitWithPercentPrice) = - Price(unitWithPercent = unitWithPercent) + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun ofPackageWithAllocation( - packageWithAllocation: NewSubscriptionPackageWithAllocationPrice - ) = Price(packageWithAllocation = packageWithAllocation) + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun ofTieredWithProration( - tieredWithProration: NewSubscriptionTierWithProrationPrice - ) = Price(tieredWithProration = tieredWithProration) + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun ofUnitWithProration(unitWithProration: NewSubscriptionUnitWithProrationPrice) = - Price(unitWithProration = unitWithProration) + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - fun ofGroupedAllocation(groupedAllocation: NewSubscriptionGroupedAllocationPrice) = - Price(groupedAllocation = groupedAllocation) + /** + * Returns an immutable instance of [TieredWithProration]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .name() + * .tieredWithProrationConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TieredWithProration = + TieredWithProration( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + modelType, + checkRequired("name", name), + checkRequired("tieredWithProrationConfig", tieredWithProrationConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } - fun ofGroupedWithProratedMinimum( - groupedWithProratedMinimum: NewSubscriptionGroupedWithProratedMinimumPrice - ) = Price(groupedWithProratedMinimum = groupedWithProratedMinimum) + private var validated: Boolean = false - fun ofBulkWithProration(bulkWithProration: NewSubscriptionBulkWithProrationPrice) = - Price(bulkWithProration = bulkWithProration) + fun validate(): TieredWithProration = apply { + if (validated) { + return@apply + } - fun ofScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: NewSubscriptionScalableMatrixWithUnitPricingPrice - ) = Price(scalableMatrixWithUnitPricing = scalableMatrixWithUnitPricing) + cadence().validate() + itemId() + _modelType().let { + if (it != JsonValue.from("tiered_with_proration")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + tieredWithProrationConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + metadata()?.validate() + referenceId() + validated = true + } - fun ofScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: - NewSubscriptionScalableMatrixWithTieredPricingPrice - ) = Price(scalableMatrixWithTieredPricing = scalableMatrixWithTieredPricing) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - fun ofCumulativeGroupedBulk( - cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice - ) = Price(cumulativeGroupedBulk = cumulativeGroupedBulk) + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + modelType.let { + if (it == JsonValue.from("tiered_with_proration")) 1 else 0 + } + + (if (name.asKnown() == null) 0 else 1) + + (tieredWithProrationConfig.asKnown()?.validity() ?: 0) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) - fun ofMaxGroupTieredPackage( - maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice - ) = Price(maxGroupTieredPackage = maxGroupTieredPackage) + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { - fun ofGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice - ) = Price(groupedWithMeteredMinimum = groupedWithMeteredMinimum) + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value - fun ofMatrixWithDisplayName( - matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice - ) = Price(matrixWithDisplayName = matrixWithDisplayName) + companion object { - fun ofGroupedTieredPackage( - groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice - ) = Price(groupedTieredPackage = groupedTieredPackage) + val ANNUAL = of("annual") - fun ofMatrixWithAllocation( - matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice - ) = Price(matrixWithAllocation = matrixWithAllocation) + val SEMI_ANNUAL = of("semi_annual") - fun ofTieredPackageWithMinimum( - tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice - ) = Price(tieredPackageWithMinimum = tieredPackageWithMinimum) + val MONTHLY = of("monthly") - fun ofGroupedTiered(groupedTiered: NewSubscriptionGroupedTieredPrice) = - Price(groupedTiered = groupedTiered) + val QUARTERLY = of("quarterly") - fun ofGroupedWithMinMaxThresholds( - groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds - ) = Price(groupedWithMinMaxThresholds = groupedWithMinMaxThresholds) + val ONE_TIME = of("one_time") - fun ofMinimum(minimum: NewSubscriptionMinimumCompositePrice) = - Price(minimum = minimum) - } + val CUSTOM = of("custom") - /** - * An interface that defines how to map each variant of [Price] to a value of type [T]. - */ - interface Visitor { + fun of(value: String) = Cadence(JsonField.of(value)) + } - fun visitUnit(unit: NewSubscriptionUnitPrice): T + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } - fun visitPackage(package_: NewSubscriptionPackagePrice): T + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } - fun visitMatrix(matrix: NewSubscriptionMatrixPrice): T + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } - fun visitTiered(tiered: NewSubscriptionTieredPrice): T + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } - fun visitBulk(bulk: NewSubscriptionBulkPrice): T + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") - fun visitThresholdTotalAmount( - thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice - ): T + private var validated: Boolean = false - fun visitTieredPackage(tieredPackage: NewSubscriptionTieredPackagePrice): T + fun validate(): Cadence = apply { + if (validated) { + return@apply + } - fun visitTieredWithMinimum( - tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice - ): T + known() + validated = true + } - fun visitUnitWithPercent(unitWithPercent: NewSubscriptionUnitWithPercentPrice): T + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - fun visitPackageWithAllocation( - packageWithAllocation: NewSubscriptionPackageWithAllocationPrice - ): T + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - fun visitTieredWithProration( - tieredWithProration: NewSubscriptionTierWithProrationPrice - ): T + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun visitUnitWithProration( - unitWithProration: NewSubscriptionUnitWithProrationPrice - ): T + return other is Cadence && value == other.value + } - fun visitGroupedAllocation( - groupedAllocation: NewSubscriptionGroupedAllocationPrice - ): T + override fun hashCode() = value.hashCode() - fun visitGroupedWithProratedMinimum( - groupedWithProratedMinimum: NewSubscriptionGroupedWithProratedMinimumPrice - ): T + override fun toString() = value.toString() + } - fun visitBulkWithProration( - bulkWithProration: NewSubscriptionBulkWithProrationPrice - ): T + /** Configuration for tiered_with_proration pricing */ + class TieredWithProrationConfig + private constructor( + private val tiers: JsonField>, + private val additionalProperties: MutableMap, + ) { - fun visitScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: NewSubscriptionScalableMatrixWithUnitPricingPrice - ): T + @JsonCreator + private constructor( + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of() + ) : this(tiers, mutableMapOf()) - fun visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: - NewSubscriptionScalableMatrixWithTieredPricingPrice - ): T + /** + * Tiers for rating based on total usage quantities into the specified tier with + * proration + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun tiers(): List = tiers.getRequired("tiers") - fun visitCumulativeGroupedBulk( - cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice - ): T + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers - fun visitMaxGroupTieredPackage( - maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice - ): T + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - fun visitGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice - ): T + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - fun visitMatrixWithDisplayName( - matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice - ): T + fun toBuilder() = Builder().from(this) - fun visitGroupedTieredPackage( - groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice - ): T + companion object { - fun visitMatrixWithAllocation( - matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice - ): T + /** + * Returns a mutable builder for constructing an instance of + * [TieredWithProrationConfig]. + * + * The following fields are required: + * ```kotlin + * .tiers() + * ``` + */ + fun builder() = Builder() + } - fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice - ): T + /** A builder for [TieredWithProrationConfig]. */ + class Builder internal constructor() { - fun visitGroupedTiered(groupedTiered: NewSubscriptionGroupedTieredPrice): T + private var tiers: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() - fun visitGroupedWithMinMaxThresholds( - groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds - ): T + internal fun from(tieredWithProrationConfig: TieredWithProrationConfig) = + apply { + tiers = tieredWithProrationConfig.tiers.map { it.toMutableList() } + additionalProperties = + tieredWithProrationConfig.additionalProperties.toMutableMap() + } - fun visitMinimum(minimum: NewSubscriptionMinimumCompositePrice): T + /** + * Tiers for rating based on total usage quantities into the specified tier + * with proration + */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) - /** - * Maps an unknown variant of [Price] to a value of type [T]. - * - * An instance of [Price] can contain an unknown variant if it was deserialized from - * data that doesn't match any known variant. For example, if the SDK is on an older - * version than the API, then the API may respond with new variants that the SDK is - * unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown Price: $json") - } - } + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } - internal class Deserializer : BaseDeserializer(Price::class) { + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } - override fun ObjectCodec.deserialize(node: JsonNode): Price { - val json = JsonValue.fromJsonNode(node) - val modelType = json.asObject()?.get("model_type")?.asString() + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - when (modelType) { - "unit" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(unit = it, _json = json) } ?: Price(_json = json) - } - "package" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(package_ = it, _json = json) } ?: Price(_json = json) - } - "matrix" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(matrix = it, _json = json) } ?: Price(_json = json) - } - "tiered" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(tiered = it, _json = json) } ?: Price(_json = json) - } - "bulk" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(bulk = it, _json = json) } ?: Price(_json = json) - } - "threshold_total_amount" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(thresholdTotalAmount = it, _json = json) } - ?: Price(_json = json) - } - "tiered_package" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(tieredPackage = it, _json = json) } - ?: Price(_json = json) - } - "tiered_with_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(tieredWithMinimum = it, _json = json) } - ?: Price(_json = json) - } - "unit_with_percent" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(unitWithPercent = it, _json = json) } - ?: Price(_json = json) + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) } - "package_with_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(packageWithAllocation = it, _json = json) } - ?: Price(_json = json) + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) } - "tiered_with_proration" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(tieredWithProration = it, _json = json) } - ?: Price(_json = json) + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) } - "unit_with_proration" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(unitWithProration = it, _json = json) } - ?: Price(_json = json) + + /** + * Returns an immutable instance of [TieredWithProrationConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TieredWithProrationConfig = + TieredWithProrationConfig( + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TieredWithProrationConfig = apply { + if (validated) { + return@apply } - "grouped_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedAllocation = it, _json = json) } - ?: Price(_json = json) + + tiers().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false } - "grouped_with_prorated_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedWithProratedMinimum = it, _json = json) } - ?: Price(_json = json) + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (tiers.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single tiered with proration tier */ + class Tier + private constructor( + private val tierLowerBound: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(tierLowerBound, unitAmount, mutableMapOf()) + + /** + * Inclusive tier starting value + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun tierLowerBound(): String = + tierLowerBound.getRequired("tier_lower_bound") + + /** + * Amount per unit + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) } - "bulk_with_proration" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(bulkWithProration = it, _json = json) } - ?: Price(_json = json) + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Tier]. + * + * The following fields are required: + * ```kotlin + * .tierLowerBound() + * .unitAmount() + * ``` + */ + fun builder() = Builder() } - "scalable_matrix_with_unit_pricing" -> { - return tryDeserialize( - node, - jacksonTypeRef< - NewSubscriptionScalableMatrixWithUnitPricingPrice - >(), + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var tierLowerBound: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(tier: Tier) = apply { + tierLowerBound = tier.tierLowerBound + unitAmount = tier.unitAmount + additionalProperties = tier.additionalProperties.toMutableMap() + } + + /** Inclusive tier starting value */ + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + /** Amount per unit */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```kotlin + * .tierLowerBound() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("tierLowerBound", tierLowerBound), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), ) - ?.let { Price(scalableMatrixWithUnitPricing = it, _json = json) } - ?: Price(_json = json) } - "scalable_matrix_with_tiered_pricing" -> { - return tryDeserialize( - node, - jacksonTypeRef< - NewSubscriptionScalableMatrixWithTieredPricingPrice - >(), - ) - ?.let { Price(scalableMatrixWithTieredPricing = it, _json = json) } - ?: Price(_json = json) + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + tierLowerBound() + unitAmount() + validated = true } - "cumulative_grouped_bulk" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(cumulativeGroupedBulk = it, _json = json) } - ?: Price(_json = json) + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (tierLowerBound.asKnown() == null) 0 else 1) + + (if (unitAmount.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + tierLowerBound == other.tierLowerBound && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties } - "max_group_tiered_package" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(maxGroupTieredPackage = it, _json = json) } - ?: Price(_json = json) + + private val hashCode: Int by lazy { + Objects.hash(tierLowerBound, unitAmount, additionalProperties) } - "grouped_with_metered_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedWithMeteredMinimum = it, _json = json) } - ?: Price(_json = json) + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - "matrix_with_display_name" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(matrixWithDisplayName = it, _json = json) } - ?: Price(_json = json) + + return other is TieredWithProrationConfig && + tiers == other.tiers && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(tiers, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TieredWithProrationConfig{tiers=$tiers, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() } - "grouped_tiered_package" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedTieredPackage = it, _json = json) } - ?: Price(_json = json) + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) } - "matrix_with_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(matrixWithAllocation = it, _json = json) } - ?: Price(_json = json) + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) } - "tiered_package_with_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(tieredPackageWithMinimum = it, _json = json) } - ?: Price(_json = json) + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) } - "grouped_tiered" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedTiered = it, _json = json) } - ?: Price(_json = json) + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply } - "grouped_with_min_max_thresholds" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedWithMinMaxThresholds = it, _json = json) } - ?: Price(_json = json) + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false } - "minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(minimum = it, _json = json) } ?: Price(_json = json) + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } + + return other is Metadata && + additionalProperties == other.additionalProperties } - return Price(_json = json) - } - } + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - internal class Serializer : BaseSerializer(Price::class) { + override fun hashCode(): Int = hashCode - override fun serialize( - value: Price, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unit != null -> generator.writeObject(value.unit) - value.package_ != null -> generator.writeObject(value.package_) - value.matrix != null -> generator.writeObject(value.matrix) - value.tiered != null -> generator.writeObject(value.tiered) - value.bulk != null -> generator.writeObject(value.bulk) - value.thresholdTotalAmount != null -> - generator.writeObject(value.thresholdTotalAmount) - value.tieredPackage != null -> generator.writeObject(value.tieredPackage) - value.tieredWithMinimum != null -> - generator.writeObject(value.tieredWithMinimum) - value.unitWithPercent != null -> - generator.writeObject(value.unitWithPercent) - value.packageWithAllocation != null -> - generator.writeObject(value.packageWithAllocation) - value.tieredWithProration != null -> - generator.writeObject(value.tieredWithProration) - value.unitWithProration != null -> - generator.writeObject(value.unitWithProration) - value.groupedAllocation != null -> - generator.writeObject(value.groupedAllocation) - value.groupedWithProratedMinimum != null -> - generator.writeObject(value.groupedWithProratedMinimum) - value.bulkWithProration != null -> - generator.writeObject(value.bulkWithProration) - value.scalableMatrixWithUnitPricing != null -> - generator.writeObject(value.scalableMatrixWithUnitPricing) - value.scalableMatrixWithTieredPricing != null -> - generator.writeObject(value.scalableMatrixWithTieredPricing) - value.cumulativeGroupedBulk != null -> - generator.writeObject(value.cumulativeGroupedBulk) - value.maxGroupTieredPackage != null -> - generator.writeObject(value.maxGroupTieredPackage) - value.groupedWithMeteredMinimum != null -> - generator.writeObject(value.groupedWithMeteredMinimum) - value.matrixWithDisplayName != null -> - generator.writeObject(value.matrixWithDisplayName) - value.groupedTieredPackage != null -> - generator.writeObject(value.groupedTieredPackage) - value.matrixWithAllocation != null -> - generator.writeObject(value.matrixWithAllocation) - value.tieredPackageWithMinimum != null -> - generator.writeObject(value.tieredPackageWithMinimum) - value.groupedTiered != null -> generator.writeObject(value.groupedTiered) - value.groupedWithMinMaxThresholds != null -> - generator.writeObject(value.groupedWithMinMaxThresholds) - value.minimum != null -> generator.writeObject(value.minimum) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Price") + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } + + return other is TieredWithProration && + cadence == other.cadence && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + tieredWithProrationConfig == other.tieredWithProrationConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + modelType, + name, + tieredWithProrationConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties, + ) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TieredWithProration{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredWithProrationConfig=$tieredWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } class GroupedWithMinMaxThresholds @@ -10194,6 +13929,8 @@ private constructor( fun cadence(): Cadence = cadence.getRequired("cadence") /** + * Configuration for grouped_with_min_max_thresholds pricing + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected * value). @@ -10213,6 +13950,8 @@ private constructor( fun itemId(): String = itemId.getRequired("item_id") /** + * The pricing model type + * * Expected to always return the following: * ```kotlin * JsonValue.from("grouped_with_min_max_thresholds") @@ -10622,6 +14361,7 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + /** Configuration for grouped_with_min_max_thresholds pricing */ fun groupedWithMinMaxThresholdsConfig( groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig ) = @@ -11277,16 +15017,117 @@ private constructor( override fun toString() = value.toString() } + /** Configuration for grouped_with_min_max_thresholds pricing */ class GroupedWithMinMaxThresholdsConfig - @JsonCreator private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map + private val groupingKey: JsonField, + private val maximumCharge: JsonField, + private val minimumCharge: JsonField, + private val perUnitRate: JsonField, + private val additionalProperties: MutableMap, ) { + @JsonCreator + private constructor( + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("maximum_charge") + @ExcludeMissing + maximumCharge: JsonField = JsonMissing.of(), + @JsonProperty("minimum_charge") + @ExcludeMissing + minimumCharge: JsonField = JsonMissing.of(), + @JsonProperty("per_unit_rate") + @ExcludeMissing + perUnitRate: JsonField = JsonMissing.of(), + ) : this(groupingKey, maximumCharge, minimumCharge, perUnitRate, mutableMapOf()) + + /** + * The event property used to group before applying thresholds + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The maximum amount to charge each group + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun maximumCharge(): String = maximumCharge.getRequired("maximum_charge") + + /** + * The minimum amount to charge each group, regardless of usage + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun minimumCharge(): String = minimumCharge.getRequired("minimum_charge") + + /** + * The base price charged per group + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun perUnitRate(): String = perUnitRate.getRequired("per_unit_rate") + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [maximumCharge]. + * + * Unlike [maximumCharge], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("maximum_charge") + @ExcludeMissing + fun _maximumCharge(): JsonField = maximumCharge + + /** + * Returns the raw JSON value of [minimumCharge]. + * + * Unlike [minimumCharge], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("minimum_charge") + @ExcludeMissing + fun _minimumCharge(): JsonField = minimumCharge + + /** + * Returns the raw JSON value of [perUnitRate]. + * + * Unlike [perUnitRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("per_unit_rate") + @ExcludeMissing + fun _perUnitRate(): JsonField = perUnitRate + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) fun toBuilder() = Builder().from(this) @@ -11295,6 +15136,14 @@ private constructor( /** * Returns a mutable builder for constructing an instance of * [GroupedWithMinMaxThresholdsConfig]. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .maximumCharge() + * .minimumCharge() + * .perUnitRate() + * ``` */ fun builder() = Builder() } @@ -11302,17 +15151,85 @@ private constructor( /** A builder for [GroupedWithMinMaxThresholdsConfig]. */ class Builder internal constructor() { + private var groupingKey: JsonField? = null + private var maximumCharge: JsonField? = null + private var minimumCharge: JsonField? = null + private var perUnitRate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from( groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig ) = apply { + groupingKey = groupedWithMinMaxThresholdsConfig.groupingKey + maximumCharge = groupedWithMinMaxThresholdsConfig.maximumCharge + minimumCharge = groupedWithMinMaxThresholdsConfig.minimumCharge + perUnitRate = groupedWithMinMaxThresholdsConfig.perUnitRate additionalProperties = groupedWithMinMaxThresholdsConfig.additionalProperties .toMutableMap() } + /** The event property used to group before applying thresholds */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The maximum amount to charge each group */ + fun maximumCharge(maximumCharge: String) = + maximumCharge(JsonField.of(maximumCharge)) + + /** + * Sets [Builder.maximumCharge] to an arbitrary JSON value. + * + * You should usually call [Builder.maximumCharge] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun maximumCharge(maximumCharge: JsonField) = apply { + this.maximumCharge = maximumCharge + } + + /** The minimum amount to charge each group, regardless of usage */ + fun minimumCharge(minimumCharge: String) = + minimumCharge(JsonField.of(minimumCharge)) + + /** + * Sets [Builder.minimumCharge] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumCharge] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun minimumCharge(minimumCharge: JsonField) = apply { + this.minimumCharge = minimumCharge + } + + /** The base price charged per group */ + fun perUnitRate(perUnitRate: String) = + perUnitRate(JsonField.of(perUnitRate)) + + /** + * Sets [Builder.perUnitRate] to an arbitrary JSON value. + * + * You should usually call [Builder.perUnitRate] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun perUnitRate(perUnitRate: JsonField) = apply { + this.perUnitRate = perUnitRate + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -11339,9 +15256,25 @@ private constructor( * Returns an immutable instance of [GroupedWithMinMaxThresholdsConfig]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .maximumCharge() + * .minimumCharge() + * .perUnitRate() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ fun build(): GroupedWithMinMaxThresholdsConfig = - GroupedWithMinMaxThresholdsConfig(additionalProperties.toImmutable()) + GroupedWithMinMaxThresholdsConfig( + checkRequired("groupingKey", groupingKey), + checkRequired("maximumCharge", maximumCharge), + checkRequired("minimumCharge", minimumCharge), + checkRequired("perUnitRate", perUnitRate), + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false @@ -11351,6 +15284,10 @@ private constructor( return@apply } + groupingKey() + maximumCharge() + minimumCharge() + perUnitRate() validated = true } @@ -11369,9 +15306,10 @@ private constructor( * Used for best match union deserialization. */ internal fun validity(): Int = - additionalProperties.count { (_, value) -> - !value.isNull() && !value.isMissing() - } + (if (groupingKey.asKnown() == null) 0 else 1) + + (if (maximumCharge.asKnown() == null) 0 else 1) + + (if (minimumCharge.asKnown() == null) 0 else 1) + + (if (perUnitRate.asKnown() == null) 0 else 1) override fun equals(other: Any?): Boolean { if (this === other) { @@ -11379,15 +15317,27 @@ private constructor( } return other is GroupedWithMinMaxThresholdsConfig && + groupingKey == other.groupingKey && + maximumCharge == other.maximumCharge && + minimumCharge == other.minimumCharge && + perUnitRate == other.perUnitRate && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + private val hashCode: Int by lazy { + Objects.hash( + groupingKey, + maximumCharge, + minimumCharge, + perUnitRate, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode override fun toString() = - "GroupedWithMinMaxThresholdsConfig{additionalProperties=$additionalProperties}" + "GroupedWithMinMaxThresholdsConfig{groupingKey=$groupingKey, maximumCharge=$maximumCharge, minimumCharge=$minimumCharge, perUnitRate=$perUnitRate, additionalProperties=$additionalProperties}" } /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Tier.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Tier.kt index 87680845d..940a94599 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Tier.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Tier.kt @@ -15,6 +15,7 @@ import com.withorb.api.errors.OrbInvalidDataException import java.util.Collections import java.util.Objects +/** Configuration for a single tier */ class Tier private constructor( private val firstUnit: JsonField, @@ -49,7 +50,7 @@ private constructor( fun unitAmount(): String = unitAmount.getRequired("unit_amount") /** - * Inclusive tier ending value. If null, this is treated as the last tier + * Inclusive tier ending value. This value is null if and only if this is the last tier. * * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server * responded with an unexpected value). @@ -142,7 +143,7 @@ private constructor( */ fun unitAmount(unitAmount: JsonField) = apply { this.unitAmount = unitAmount } - /** Inclusive tier ending value. If null, this is treated as the last tier */ + /** Inclusive tier ending value. This value is null if and only if this is the last tier. */ fun lastUnit(lastUnit: Double?) = lastUnit(JsonField.ofNullable(lastUnit)) /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/TierConfig.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/TierConfig.kt deleted file mode 100644 index 9e9448b13..000000000 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/TierConfig.kt +++ /dev/null @@ -1,248 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.withorb.api.models - -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import com.withorb.api.core.ExcludeMissing -import com.withorb.api.core.JsonField -import com.withorb.api.core.JsonMissing -import com.withorb.api.core.JsonValue -import com.withorb.api.core.checkRequired -import com.withorb.api.errors.OrbInvalidDataException -import java.util.Collections -import java.util.Objects - -class TierConfig -private constructor( - private val firstUnit: JsonField, - private val lastUnit: JsonField, - private val unitAmount: JsonField, - private val additionalProperties: MutableMap, -) { - - @JsonCreator - private constructor( - @JsonProperty("first_unit") @ExcludeMissing firstUnit: JsonField = JsonMissing.of(), - @JsonProperty("last_unit") @ExcludeMissing lastUnit: JsonField = JsonMissing.of(), - @JsonProperty("unit_amount") - @ExcludeMissing - unitAmount: JsonField = JsonMissing.of(), - ) : this(firstUnit, lastUnit, unitAmount, mutableMapOf()) - - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly - * missing or null (e.g. if the server responded with an unexpected value). - */ - fun firstUnit(): Double = firstUnit.getRequired("first_unit") - - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - fun lastUnit(): Double? = lastUnit.getNullable("last_unit") - - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly - * missing or null (e.g. if the server responded with an unexpected value). - */ - fun unitAmount(): String = unitAmount.getRequired("unit_amount") - - /** - * Returns the raw JSON value of [firstUnit]. - * - * Unlike [firstUnit], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("first_unit") @ExcludeMissing fun _firstUnit(): JsonField = firstUnit - - /** - * Returns the raw JSON value of [lastUnit]. - * - * Unlike [lastUnit], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("last_unit") @ExcludeMissing fun _lastUnit(): JsonField = lastUnit - - /** - * Returns the raw JSON value of [unitAmount]. - * - * Unlike [unitAmount], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("unit_amount") @ExcludeMissing fun _unitAmount(): JsonField = unitAmount - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [TierConfig]. - * - * The following fields are required: - * ```kotlin - * .firstUnit() - * .lastUnit() - * .unitAmount() - * ``` - */ - fun builder() = Builder() - } - - /** A builder for [TierConfig]. */ - class Builder internal constructor() { - - private var firstUnit: JsonField? = null - private var lastUnit: JsonField? = null - private var unitAmount: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(tierConfig: TierConfig) = apply { - firstUnit = tierConfig.firstUnit - lastUnit = tierConfig.lastUnit - unitAmount = tierConfig.unitAmount - additionalProperties = tierConfig.additionalProperties.toMutableMap() - } - - fun firstUnit(firstUnit: Double) = firstUnit(JsonField.of(firstUnit)) - - /** - * Sets [Builder.firstUnit] to an arbitrary JSON value. - * - * You should usually call [Builder.firstUnit] with a well-typed [Double] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun firstUnit(firstUnit: JsonField) = apply { this.firstUnit = firstUnit } - - fun lastUnit(lastUnit: Double?) = lastUnit(JsonField.ofNullable(lastUnit)) - - /** - * Alias for [Builder.lastUnit]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun lastUnit(lastUnit: Double) = lastUnit(lastUnit as Double?) - - /** - * Sets [Builder.lastUnit] to an arbitrary JSON value. - * - * You should usually call [Builder.lastUnit] with a well-typed [Double] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun lastUnit(lastUnit: JsonField) = apply { this.lastUnit = lastUnit } - - fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) - - /** - * Sets [Builder.unitAmount] to an arbitrary JSON value. - * - * You should usually call [Builder.unitAmount] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun unitAmount(unitAmount: JsonField) = apply { this.unitAmount = unitAmount } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [TierConfig]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```kotlin - * .firstUnit() - * .lastUnit() - * .unitAmount() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): TierConfig = - TierConfig( - checkRequired("firstUnit", firstUnit), - checkRequired("lastUnit", lastUnit), - checkRequired("unitAmount", unitAmount), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): TierConfig = apply { - if (validated) { - return@apply - } - - firstUnit() - lastUnit() - unitAmount() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (if (firstUnit.asKnown() == null) 0 else 1) + - (if (lastUnit.asKnown() == null) 0 else 1) + - (if (unitAmount.asKnown() == null) 0 else 1) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is TierConfig && - firstUnit == other.firstUnit && - lastUnit == other.lastUnit && - unitAmount == other.unitAmount && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(firstUnit, lastUnit, unitAmount, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "TierConfig{firstUnit=$firstUnit, lastUnit=$lastUnit, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" -} diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/TierSubLineItem.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/TierSubLineItem.kt index b69858b8c..04204455f 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/TierSubLineItem.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/TierSubLineItem.kt @@ -324,6 +324,246 @@ private constructor( (tierConfig.asKnown()?.validity() ?: 0) + (type.asKnown()?.validity() ?: 0) + class TierConfig + private constructor( + private val firstUnit: JsonField, + private val lastUnit: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("first_unit") + @ExcludeMissing + firstUnit: JsonField = JsonMissing.of(), + @JsonProperty("last_unit") + @ExcludeMissing + lastUnit: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(firstUnit, lastUnit, unitAmount, mutableMapOf()) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun firstUnit(): Double = firstUnit.getRequired("first_unit") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun lastUnit(): Double? = lastUnit.getNullable("last_unit") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [firstUnit]. + * + * Unlike [firstUnit], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("first_unit") @ExcludeMissing fun _firstUnit(): JsonField = firstUnit + + /** + * Returns the raw JSON value of [lastUnit]. + * + * Unlike [lastUnit], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("last_unit") @ExcludeMissing fun _lastUnit(): JsonField = lastUnit + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [TierConfig]. + * + * The following fields are required: + * ```kotlin + * .firstUnit() + * .lastUnit() + * .unitAmount() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [TierConfig]. */ + class Builder internal constructor() { + + private var firstUnit: JsonField? = null + private var lastUnit: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(tierConfig: TierConfig) = apply { + firstUnit = tierConfig.firstUnit + lastUnit = tierConfig.lastUnit + unitAmount = tierConfig.unitAmount + additionalProperties = tierConfig.additionalProperties.toMutableMap() + } + + fun firstUnit(firstUnit: Double) = firstUnit(JsonField.of(firstUnit)) + + /** + * Sets [Builder.firstUnit] to an arbitrary JSON value. + * + * You should usually call [Builder.firstUnit] with a well-typed [Double] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun firstUnit(firstUnit: JsonField) = apply { this.firstUnit = firstUnit } + + fun lastUnit(lastUnit: Double?) = lastUnit(JsonField.ofNullable(lastUnit)) + + /** + * Alias for [Builder.lastUnit]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun lastUnit(lastUnit: Double) = lastUnit(lastUnit as Double?) + + /** + * Sets [Builder.lastUnit] to an arbitrary JSON value. + * + * You should usually call [Builder.lastUnit] with a well-typed [Double] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun lastUnit(lastUnit: JsonField) = apply { this.lastUnit = lastUnit } + + fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { this.unitAmount = unitAmount } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [TierConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .firstUnit() + * .lastUnit() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TierConfig = + TierConfig( + checkRequired("firstUnit", firstUnit), + checkRequired("lastUnit", lastUnit), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TierConfig = apply { + if (validated) { + return@apply + } + + firstUnit() + lastUnit() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (firstUnit.asKnown() == null) 0 else 1) + + (if (lastUnit.asKnown() == null) 0 else 1) + + (if (unitAmount.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TierConfig && + firstUnit == other.firstUnit && + lastUnit == other.lastUnit && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(firstUnit, lastUnit, unitAmount, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TierConfig{firstUnit=$firstUnit, lastUnit=$lastUnit, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } + class Type @JsonCreator private constructor(private val value: JsonField) : Enum { /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/TieredConfig.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/TieredConfig.kt index 3e91cf412..bf59ed7a1 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/TieredConfig.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/TieredConfig.kt @@ -17,6 +17,7 @@ import com.withorb.api.errors.OrbInvalidDataException import java.util.Collections import java.util.Objects +/** Configuration for tiered pricing */ class TieredConfig private constructor( private val tiers: JsonField>, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/UnitConfig.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/UnitConfig.kt index 8de72ac8b..6c0ea6e81 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/UnitConfig.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/UnitConfig.kt @@ -15,9 +15,11 @@ import com.withorb.api.errors.OrbInvalidDataException import java.util.Collections import java.util.Objects +/** Configuration for unit pricing */ class UnitConfig private constructor( private val unitAmount: JsonField, + private val scalingFactor: JsonField, private val additionalProperties: MutableMap, ) { @@ -25,8 +27,11 @@ private constructor( private constructor( @JsonProperty("unit_amount") @ExcludeMissing - unitAmount: JsonField = JsonMissing.of() - ) : this(unitAmount, mutableMapOf()) + unitAmount: JsonField = JsonMissing.of(), + @JsonProperty("scaling_factor") + @ExcludeMissing + scalingFactor: JsonField = JsonMissing.of(), + ) : this(unitAmount, scalingFactor, mutableMapOf()) /** * Rate per unit of usage @@ -36,6 +41,14 @@ private constructor( */ fun unitAmount(): String = unitAmount.getRequired("unit_amount") + /** + * Multiplier to scale rated quantity by + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun scalingFactor(): Double? = scalingFactor.getNullable("scaling_factor") + /** * Returns the raw JSON value of [unitAmount]. * @@ -43,6 +56,15 @@ private constructor( */ @JsonProperty("unit_amount") @ExcludeMissing fun _unitAmount(): JsonField = unitAmount + /** + * Returns the raw JSON value of [scalingFactor]. + * + * Unlike [scalingFactor], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("scaling_factor") + @ExcludeMissing + fun _scalingFactor(): JsonField = scalingFactor + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -72,10 +94,12 @@ private constructor( class Builder internal constructor() { private var unitAmount: JsonField? = null + private var scalingFactor: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() internal fun from(unitConfig: UnitConfig) = apply { unitAmount = unitConfig.unitAmount + scalingFactor = unitConfig.scalingFactor additionalProperties = unitConfig.additionalProperties.toMutableMap() } @@ -91,6 +115,28 @@ private constructor( */ fun unitAmount(unitAmount: JsonField) = apply { this.unitAmount = unitAmount } + /** Multiplier to scale rated quantity by */ + fun scalingFactor(scalingFactor: Double?) = + scalingFactor(JsonField.ofNullable(scalingFactor)) + + /** + * Alias for [Builder.scalingFactor]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun scalingFactor(scalingFactor: Double) = scalingFactor(scalingFactor as Double?) + + /** + * Sets [Builder.scalingFactor] to an arbitrary JSON value. + * + * You should usually call [Builder.scalingFactor] with a well-typed [Double] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun scalingFactor(scalingFactor: JsonField) = apply { + this.scalingFactor = scalingFactor + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -123,7 +169,11 @@ private constructor( * @throws IllegalStateException if any required field is unset. */ fun build(): UnitConfig = - UnitConfig(checkRequired("unitAmount", unitAmount), additionalProperties.toMutableMap()) + UnitConfig( + checkRequired("unitAmount", unitAmount), + scalingFactor, + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false @@ -134,6 +184,7 @@ private constructor( } unitAmount() + scalingFactor() validated = true } @@ -150,7 +201,9 @@ private constructor( * * Used for best match union deserialization. */ - internal fun validity(): Int = (if (unitAmount.asKnown() == null) 0 else 1) + internal fun validity(): Int = + (if (unitAmount.asKnown() == null) 0 else 1) + + (if (scalingFactor.asKnown() == null) 0 else 1) override fun equals(other: Any?): Boolean { if (this === other) { @@ -159,13 +212,16 @@ private constructor( return other is UnitConfig && unitAmount == other.unitAmount && + scalingFactor == other.scalingFactor && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(unitAmount, additionalProperties) } + private val hashCode: Int by lazy { + Objects.hash(unitAmount, scalingFactor, additionalProperties) + } override fun hashCode(): Int = hashCode override fun toString() = - "UnitConfig{unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + "UnitConfig{unitAmount=$unitAmount, scalingFactor=$scalingFactor, additionalProperties=$additionalProperties}" } diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/AggregatedCostTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/AggregatedCostTest.kt index b517b9a41..b665b618c 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/AggregatedCostTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/AggregatedCostTest.kt @@ -117,7 +117,12 @@ internal class AggregatedCostTest { .planPhaseOrder(0L) .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .scalingFactor(0.0) + .build() + ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") @@ -239,7 +244,12 @@ internal class AggregatedCostTest { .planPhaseOrder(0L) .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .scalingFactor(0.0) + .build() + ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") @@ -369,7 +379,12 @@ internal class AggregatedCostTest { .planPhaseOrder(0L) .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .scalingFactor(0.0) + .build() + ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/BetaCreatePlanVersionParamsTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/BetaCreatePlanVersionParamsTest.kt index 641af6239..c2d6921a7 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/BetaCreatePlanVersionParamsTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/BetaCreatePlanVersionParamsTest.kt @@ -64,7 +64,12 @@ internal class BetaCreatePlanVersionParamsTest { .itemId("item_id") .modelType(NewPlanUnitPrice.ModelType.UNIT) .name("Annual fee") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .scalingFactor(0.0) + .build() + ) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( @@ -171,7 +176,12 @@ internal class BetaCreatePlanVersionParamsTest { .itemId("item_id") .modelType(NewPlanUnitPrice.ModelType.UNIT) .name("Annual fee") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .scalingFactor(0.0) + .build() + ) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( @@ -283,7 +293,12 @@ internal class BetaCreatePlanVersionParamsTest { .itemId("item_id") .modelType(NewPlanUnitPrice.ModelType.UNIT) .name("Annual fee") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .scalingFactor(0.0) + .build() + ) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( @@ -392,7 +407,12 @@ internal class BetaCreatePlanVersionParamsTest { .itemId("item_id") .modelType(NewPlanUnitPrice.ModelType.UNIT) .name("Annual fee") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .scalingFactor(0.0) + .build() + ) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( @@ -495,7 +515,12 @@ internal class BetaCreatePlanVersionParamsTest { .itemId("item_id") .modelType(NewPlanUnitPrice.ModelType.UNIT) .name("Annual fee") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .scalingFactor(0.0) + .build() + ) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( @@ -606,7 +631,12 @@ internal class BetaCreatePlanVersionParamsTest { .itemId("item_id") .modelType(NewPlanUnitPrice.ModelType.UNIT) .name("Annual fee") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .scalingFactor(0.0) + .build() + ) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/BetaExternalPlanIdCreatePlanVersionParamsTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/BetaExternalPlanIdCreatePlanVersionParamsTest.kt index c05f7acc8..6576c7b0c 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/BetaExternalPlanIdCreatePlanVersionParamsTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/BetaExternalPlanIdCreatePlanVersionParamsTest.kt @@ -64,7 +64,12 @@ internal class BetaExternalPlanIdCreatePlanVersionParamsTest { .itemId("item_id") .modelType(NewPlanUnitPrice.ModelType.UNIT) .name("Annual fee") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .scalingFactor(0.0) + .build() + ) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( @@ -171,7 +176,12 @@ internal class BetaExternalPlanIdCreatePlanVersionParamsTest { .itemId("item_id") .modelType(NewPlanUnitPrice.ModelType.UNIT) .name("Annual fee") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .scalingFactor(0.0) + .build() + ) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( @@ -287,7 +297,12 @@ internal class BetaExternalPlanIdCreatePlanVersionParamsTest { .itemId("item_id") .modelType(NewPlanUnitPrice.ModelType.UNIT) .name("Annual fee") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .scalingFactor(0.0) + .build() + ) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( @@ -396,7 +411,12 @@ internal class BetaExternalPlanIdCreatePlanVersionParamsTest { .itemId("item_id") .modelType(NewPlanUnitPrice.ModelType.UNIT) .name("Annual fee") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .scalingFactor(0.0) + .build() + ) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( @@ -499,7 +519,12 @@ internal class BetaExternalPlanIdCreatePlanVersionParamsTest { .itemId("item_id") .modelType(NewPlanUnitPrice.ModelType.UNIT) .name("Annual fee") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .scalingFactor(0.0) + .build() + ) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( @@ -610,7 +635,12 @@ internal class BetaExternalPlanIdCreatePlanVersionParamsTest { .itemId("item_id") .modelType(NewPlanUnitPrice.ModelType.UNIT) .name("Annual fee") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .scalingFactor(0.0) + .build() + ) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/ChangedSubscriptionResourcesTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/ChangedSubscriptionResourcesTest.kt index afbfabd98..9422a5980 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/ChangedSubscriptionResourcesTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/ChangedSubscriptionResourcesTest.kt @@ -392,7 +392,10 @@ internal class ChangedSubscriptionResourcesTest { .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( - UnitConfig.builder().unitAmount("unit_amount").build() + UnitConfig.builder() + .unitAmount("unit_amount") + .scalingFactor(0.0) + .build() ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -883,7 +886,10 @@ internal class ChangedSubscriptionResourcesTest { .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( - UnitConfig.builder().unitAmount("unit_amount").build() + UnitConfig.builder() + .unitAmount("unit_amount") + .scalingFactor(0.0) + .build() ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -1365,7 +1371,10 @@ internal class ChangedSubscriptionResourcesTest { .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( - UnitConfig.builder().unitAmount("unit_amount").build() + UnitConfig.builder() + .unitAmount("unit_amount") + .scalingFactor(0.0) + .build() ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -1843,7 +1852,10 @@ internal class ChangedSubscriptionResourcesTest { .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( - UnitConfig.builder().unitAmount("unit_amount").build() + UnitConfig.builder() + .unitAmount("unit_amount") + .scalingFactor(0.0) + .build() ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -2339,7 +2351,10 @@ internal class ChangedSubscriptionResourcesTest { .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( - UnitConfig.builder().unitAmount("unit_amount").build() + UnitConfig.builder() + .unitAmount("unit_amount") + .scalingFactor(0.0) + .build() ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -2830,7 +2845,10 @@ internal class ChangedSubscriptionResourcesTest { .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( - UnitConfig.builder().unitAmount("unit_amount").build() + UnitConfig.builder() + .unitAmount("unit_amount") + .scalingFactor(0.0) + .build() ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCostListByExternalIdResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCostListByExternalIdResponseTest.kt index 22ba89f9b..a74562924 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCostListByExternalIdResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCostListByExternalIdResponseTest.kt @@ -139,7 +139,10 @@ internal class CustomerCostListByExternalIdResponseTest { .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( - UnitConfig.builder().unitAmount("unit_amount").build() + UnitConfig.builder() + .unitAmount("unit_amount") + .scalingFactor(0.0) + .build() ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -283,7 +286,10 @@ internal class CustomerCostListByExternalIdResponseTest { .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( - UnitConfig.builder().unitAmount("unit_amount").build() + UnitConfig.builder() + .unitAmount("unit_amount") + .scalingFactor(0.0) + .build() ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -436,7 +442,10 @@ internal class CustomerCostListByExternalIdResponseTest { .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( - UnitConfig.builder().unitAmount("unit_amount").build() + UnitConfig.builder() + .unitAmount("unit_amount") + .scalingFactor(0.0) + .build() ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCostListResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCostListResponseTest.kt index 5f0071abc..6cd4faed7 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCostListResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCostListResponseTest.kt @@ -139,7 +139,10 @@ internal class CustomerCostListResponseTest { .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( - UnitConfig.builder().unitAmount("unit_amount").build() + UnitConfig.builder() + .unitAmount("unit_amount") + .scalingFactor(0.0) + .build() ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -283,7 +286,10 @@ internal class CustomerCostListResponseTest { .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( - UnitConfig.builder().unitAmount("unit_amount").build() + UnitConfig.builder() + .unitAmount("unit_amount") + .scalingFactor(0.0) + .build() ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -436,7 +442,10 @@ internal class CustomerCostListResponseTest { .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( - UnitConfig.builder().unitAmount("unit_amount").build() + UnitConfig.builder() + .unitAmount("unit_amount") + .scalingFactor(0.0) + .build() ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdResponseTest.kt index c3b9ebc9a..35a8c93f1 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdResponseTest.kt @@ -338,7 +338,10 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdResponseTest { .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( - UnitConfig.builder().unitAmount("unit_amount").build() + UnitConfig.builder() + .unitAmount("unit_amount") + .scalingFactor(0.0) + .build() ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -817,6 +820,7 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdResponseTest { .unitConfig( UnitConfig.builder() .unitAmount("unit_amount") + .scalingFactor(0.0) .build() ) .dimensionalPriceConfiguration( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryResponseTest.kt index 54bd808cc..91310b859 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryResponseTest.kt @@ -338,7 +338,10 @@ internal class CustomerCreditLedgerCreateEntryResponseTest { .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( - UnitConfig.builder().unitAmount("unit_amount").build() + UnitConfig.builder() + .unitAmount("unit_amount") + .scalingFactor(0.0) + .build() ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -816,6 +819,7 @@ internal class CustomerCreditLedgerCreateEntryResponseTest { .unitConfig( UnitConfig.builder() .unitAmount("unit_amount") + .scalingFactor(0.0) .build() ) .dimensionalPriceConfiguration( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdPageResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdPageResponseTest.kt index f5bda2071..9af956b30 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdPageResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdPageResponseTest.kt @@ -377,6 +377,7 @@ internal class CustomerCreditLedgerListByExternalIdPageResponseTest { .unitConfig( UnitConfig.builder() .unitAmount("unit_amount") + .scalingFactor(0.0) .build() ) .dimensionalPriceConfiguration( @@ -868,6 +869,7 @@ internal class CustomerCreditLedgerListByExternalIdPageResponseTest { .unitConfig( UnitConfig.builder() .unitAmount("unit_amount") + .scalingFactor(0.0) .build() ) .dimensionalPriceConfiguration( @@ -1362,6 +1364,7 @@ internal class CustomerCreditLedgerListByExternalIdPageResponseTest { .unitConfig( UnitConfig.builder() .unitAmount("unit_amount") + .scalingFactor(0.0) .build() ) .dimensionalPriceConfiguration( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdResponseTest.kt index ced450523..52e1877d0 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdResponseTest.kt @@ -338,7 +338,10 @@ internal class CustomerCreditLedgerListByExternalIdResponseTest { .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( - UnitConfig.builder().unitAmount("unit_amount").build() + UnitConfig.builder() + .unitAmount("unit_amount") + .scalingFactor(0.0) + .build() ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -816,6 +819,7 @@ internal class CustomerCreditLedgerListByExternalIdResponseTest { .unitConfig( UnitConfig.builder() .unitAmount("unit_amount") + .scalingFactor(0.0) .build() ) .dimensionalPriceConfiguration( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListPageResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListPageResponseTest.kt index cfc8ff742..289f72481 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListPageResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListPageResponseTest.kt @@ -377,6 +377,7 @@ internal class CustomerCreditLedgerListPageResponseTest { .unitConfig( UnitConfig.builder() .unitAmount("unit_amount") + .scalingFactor(0.0) .build() ) .dimensionalPriceConfiguration( @@ -868,6 +869,7 @@ internal class CustomerCreditLedgerListPageResponseTest { .unitConfig( UnitConfig.builder() .unitAmount("unit_amount") + .scalingFactor(0.0) .build() ) .dimensionalPriceConfiguration( @@ -1362,6 +1364,7 @@ internal class CustomerCreditLedgerListPageResponseTest { .unitConfig( UnitConfig.builder() .unitAmount("unit_amount") + .scalingFactor(0.0) .build() ) .dimensionalPriceConfiguration( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListResponseTest.kt index 6e196c30f..1ce21f4f0 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListResponseTest.kt @@ -338,7 +338,10 @@ internal class CustomerCreditLedgerListResponseTest { .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( - UnitConfig.builder().unitAmount("unit_amount").build() + UnitConfig.builder() + .unitAmount("unit_amount") + .scalingFactor(0.0) + .build() ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -816,6 +819,7 @@ internal class CustomerCreditLedgerListResponseTest { .unitConfig( UnitConfig.builder() .unitAmount("unit_amount") + .scalingFactor(0.0) .build() ) .dimensionalPriceConfiguration( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/IncrementLedgerEntryTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/IncrementLedgerEntryTest.kt index 771b8f657..fc48bf767 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/IncrementLedgerEntryTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/IncrementLedgerEntryTest.kt @@ -334,7 +334,10 @@ internal class IncrementLedgerEntryTest { .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( - UnitConfig.builder().unitAmount("unit_amount").build() + UnitConfig.builder() + .unitAmount("unit_amount") + .scalingFactor(0.0) + .build() ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -765,7 +768,10 @@ internal class IncrementLedgerEntryTest { .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( - UnitConfig.builder().unitAmount("unit_amount").build() + UnitConfig.builder() + .unitAmount("unit_amount") + .scalingFactor(0.0) + .build() ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -1203,7 +1209,10 @@ internal class IncrementLedgerEntryTest { .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( - UnitConfig.builder().unitAmount("unit_amount").build() + UnitConfig.builder() + .unitAmount("unit_amount") + .scalingFactor(0.0) + .build() ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceCreateParamsTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceCreateParamsTest.kt index 62bd0eca3..8ed08a6c7 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceCreateParamsTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceCreateParamsTest.kt @@ -23,7 +23,9 @@ internal class InvoiceCreateParamsTest { .name("Line Item Name") .quantity(1.0) .startDate(LocalDate.parse("2023-09-22")) - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder().unitAmount("unit_amount").scalingFactor(0.0).build() + ) .build() ) .customerId("4khy3nwzktxv7") @@ -70,7 +72,12 @@ internal class InvoiceCreateParamsTest { .name("Line Item Name") .quantity(1.0) .startDate(LocalDate.parse("2023-09-22")) - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .scalingFactor(0.0) + .build() + ) .build() ) .customerId("4khy3nwzktxv7") @@ -115,7 +122,9 @@ internal class InvoiceCreateParamsTest { .name("Line Item Name") .quantity(1.0) .startDate(LocalDate.parse("2023-09-22")) - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder().unitAmount("unit_amount").scalingFactor(0.0).build() + ) .build() ) assertThat(body.customerId()).isEqualTo("4khy3nwzktxv7") diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceFetchUpcomingResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceFetchUpcomingResponseTest.kt index df7d09080..3db504962 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceFetchUpcomingResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceFetchUpcomingResponseTest.kt @@ -281,7 +281,12 @@ internal class InvoiceFetchUpcomingResponseTest { .planPhaseOrder(0L) .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .scalingFactor(0.0) + .build() + ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") @@ -675,7 +680,12 @@ internal class InvoiceFetchUpcomingResponseTest { .planPhaseOrder(0L) .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .scalingFactor(0.0) + .build() + ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") @@ -1071,7 +1081,12 @@ internal class InvoiceFetchUpcomingResponseTest { .planPhaseOrder(0L) .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .scalingFactor(0.0) + .build() + ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceLineItemCreateResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceLineItemCreateResponseTest.kt index b8af213f2..a81e9aa32 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceLineItemCreateResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceLineItemCreateResponseTest.kt @@ -187,7 +187,12 @@ internal class InvoiceLineItemCreateResponseTest { .planPhaseOrder(0L) .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .scalingFactor(0.0) + .build() + ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") @@ -404,7 +409,12 @@ internal class InvoiceLineItemCreateResponseTest { .planPhaseOrder(0L) .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .scalingFactor(0.0) + .build() + ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") @@ -621,7 +631,12 @@ internal class InvoiceLineItemCreateResponseTest { .planPhaseOrder(0L) .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .scalingFactor(0.0) + .build() + ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceListPageResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceListPageResponseTest.kt index df19d6dbe..84d51e6ce 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceListPageResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceListPageResponseTest.kt @@ -306,7 +306,10 @@ internal class InvoiceListPageResponseTest { .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( - UnitConfig.builder().unitAmount("unit_amount").build() + UnitConfig.builder() + .unitAmount("unit_amount") + .scalingFactor(0.0) + .build() ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -706,7 +709,10 @@ internal class InvoiceListPageResponseTest { .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( - UnitConfig.builder().unitAmount("unit_amount").build() + UnitConfig.builder() + .unitAmount("unit_amount") + .scalingFactor(0.0) + .build() ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -1118,7 +1124,10 @@ internal class InvoiceListPageResponseTest { .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( - UnitConfig.builder().unitAmount("unit_amount").build() + UnitConfig.builder() + .unitAmount("unit_amount") + .scalingFactor(0.0) + .build() ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceTest.kt index 3f3ca5071..62e9d066d 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceTest.kt @@ -277,7 +277,12 @@ internal class InvoiceTest { .planPhaseOrder(0L) .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .scalingFactor(0.0) + .build() + ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") @@ -662,7 +667,12 @@ internal class InvoiceTest { .planPhaseOrder(0L) .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .scalingFactor(0.0) + .build() + ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") @@ -1047,7 +1057,12 @@ internal class InvoiceTest { .planPhaseOrder(0L) .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .scalingFactor(0.0) + .build() + ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/MatrixWithAllocationConfigTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/MatrixWithAllocationConfigTest.kt index 8f3374699..7afd7e9d6 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/MatrixWithAllocationConfigTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/MatrixWithAllocationConfigTest.kt @@ -13,23 +13,26 @@ internal class MatrixWithAllocationConfigTest { fun create() { val matrixWithAllocationConfig = MatrixWithAllocationConfig.builder() - .allocation(0.0) + .allocation("allocation") .defaultUnitAmount("default_unit_amount") .addDimension("string") .addMatrixValue( - MatrixValue.builder() + MatrixWithAllocationConfig.MatrixValue.builder() .addDimensionValue("string") .unitAmount("unit_amount") .build() ) .build() - assertThat(matrixWithAllocationConfig.allocation()).isEqualTo(0.0) + assertThat(matrixWithAllocationConfig.allocation()).isEqualTo("allocation") assertThat(matrixWithAllocationConfig.defaultUnitAmount()).isEqualTo("default_unit_amount") assertThat(matrixWithAllocationConfig.dimensions()).containsExactly("string") assertThat(matrixWithAllocationConfig.matrixValues()) .containsExactly( - MatrixValue.builder().addDimensionValue("string").unitAmount("unit_amount").build() + MatrixWithAllocationConfig.MatrixValue.builder() + .addDimensionValue("string") + .unitAmount("unit_amount") + .build() ) } @@ -38,11 +41,11 @@ internal class MatrixWithAllocationConfigTest { val jsonMapper = jsonMapper() val matrixWithAllocationConfig = MatrixWithAllocationConfig.builder() - .allocation(0.0) + .allocation("allocation") .defaultUnitAmount("default_unit_amount") .addDimension("string") .addMatrixValue( - MatrixValue.builder() + MatrixWithAllocationConfig.MatrixValue.builder() .addDimensionValue("string") .unitAmount("unit_amount") .build() diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/MutatedSubscriptionTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/MutatedSubscriptionTest.kt index 048a69546..94af8b8c9 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/MutatedSubscriptionTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/MutatedSubscriptionTest.kt @@ -449,7 +449,12 @@ internal class MutatedSubscriptionTest { .planPhaseOrder(0L) .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .scalingFactor(0.0) + .build() + ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") @@ -594,7 +599,12 @@ internal class MutatedSubscriptionTest { .planPhaseOrder(0L) .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .scalingFactor(0.0) + .build() + ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") @@ -1046,6 +1056,7 @@ internal class MutatedSubscriptionTest { .unitConfig( UnitConfig.builder() .unitAmount("unit_amount") + .scalingFactor(0.0) .build() ) .dimensionalPriceConfiguration( @@ -1589,6 +1600,7 @@ internal class MutatedSubscriptionTest { .unitConfig( UnitConfig.builder() .unitAmount("unit_amount") + .scalingFactor(0.0) .build() ) .dimensionalPriceConfiguration( @@ -2158,7 +2170,12 @@ internal class MutatedSubscriptionTest { .planPhaseOrder(0L) .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .scalingFactor(0.0) + .build() + ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") @@ -2298,7 +2315,12 @@ internal class MutatedSubscriptionTest { .planPhaseOrder(0L) .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .scalingFactor(0.0) + .build() + ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") @@ -2735,6 +2757,7 @@ internal class MutatedSubscriptionTest { .unitConfig( UnitConfig.builder() .unitAmount("unit_amount") + .scalingFactor(0.0) .build() ) .dimensionalPriceConfiguration( @@ -3255,6 +3278,7 @@ internal class MutatedSubscriptionTest { .unitConfig( UnitConfig.builder() .unitAmount("unit_amount") + .scalingFactor(0.0) .build() ) .dimensionalPriceConfiguration( @@ -3814,7 +3838,12 @@ internal class MutatedSubscriptionTest { .planPhaseOrder(0L) .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .scalingFactor(0.0) + .build() + ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") @@ -3959,7 +3988,12 @@ internal class MutatedSubscriptionTest { .planPhaseOrder(0L) .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .scalingFactor(0.0) + .build() + ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") @@ -4411,6 +4445,7 @@ internal class MutatedSubscriptionTest { .unitConfig( UnitConfig.builder() .unitAmount("unit_amount") + .scalingFactor(0.0) .build() ) .dimensionalPriceConfiguration( @@ -4954,6 +4989,7 @@ internal class MutatedSubscriptionTest { .unitConfig( UnitConfig.builder() .unitAmount("unit_amount") + .scalingFactor(0.0) .build() ) .dimensionalPriceConfiguration( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingBulkWithProrationPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingBulkWithProrationPriceTest.kt index fcae04997..1326341ce 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingBulkWithProrationPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingBulkWithProrationPriceTest.kt @@ -16,7 +16,18 @@ internal class NewFloatingBulkWithProrationPriceTest { NewFloatingBulkWithProrationPrice.builder() .bulkWithProrationConfig( NewFloatingBulkWithProrationPrice.BulkWithProrationConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .addTier( + NewFloatingBulkWithProrationPrice.BulkWithProrationConfig.Tier.builder() + .unitAmount("unit_amount") + .tierLowerBound("tier_lower_bound") + .build() + ) + .addTier( + NewFloatingBulkWithProrationPrice.BulkWithProrationConfig.Tier.builder() + .unitAmount("unit_amount") + .tierLowerBound("tier_lower_bound") + .build() + ) .build() ) .cadence(NewFloatingBulkWithProrationPrice.Cadence.ANNUAL) @@ -62,7 +73,18 @@ internal class NewFloatingBulkWithProrationPriceTest { assertThat(newFloatingBulkWithProrationPrice.bulkWithProrationConfig()) .isEqualTo( NewFloatingBulkWithProrationPrice.BulkWithProrationConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .addTier( + NewFloatingBulkWithProrationPrice.BulkWithProrationConfig.Tier.builder() + .unitAmount("unit_amount") + .tierLowerBound("tier_lower_bound") + .build() + ) + .addTier( + NewFloatingBulkWithProrationPrice.BulkWithProrationConfig.Tier.builder() + .unitAmount("unit_amount") + .tierLowerBound("tier_lower_bound") + .build() + ) .build() ) assertThat(newFloatingBulkWithProrationPrice.cadence()) @@ -128,7 +150,18 @@ internal class NewFloatingBulkWithProrationPriceTest { NewFloatingBulkWithProrationPrice.builder() .bulkWithProrationConfig( NewFloatingBulkWithProrationPrice.BulkWithProrationConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .addTier( + NewFloatingBulkWithProrationPrice.BulkWithProrationConfig.Tier.builder() + .unitAmount("unit_amount") + .tierLowerBound("tier_lower_bound") + .build() + ) + .addTier( + NewFloatingBulkWithProrationPrice.BulkWithProrationConfig.Tier.builder() + .unitAmount("unit_amount") + .tierLowerBound("tier_lower_bound") + .build() + ) .build() ) .cadence(NewFloatingBulkWithProrationPrice.Cadence.ANNUAL) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingCumulativeGroupedBulkPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingCumulativeGroupedBulkPriceTest.kt index b62bbfe86..bc31d68ab 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingCumulativeGroupedBulkPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingCumulativeGroupedBulkPriceTest.kt @@ -17,7 +17,16 @@ internal class NewFloatingCumulativeGroupedBulkPriceTest { .cadence(NewFloatingCumulativeGroupedBulkPrice.Cadence.ANNUAL) .cumulativeGroupedBulkConfig( NewFloatingCumulativeGroupedBulkPrice.CumulativeGroupedBulkConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .addDimensionValue( + NewFloatingCumulativeGroupedBulkPrice.CumulativeGroupedBulkConfig + .DimensionValue + .builder() + .groupingKey("x") + .tierLowerBound("tier_lower_bound") + .unitAmount("unit_amount") + .build() + ) + .group("group") .build() ) .currency("currency") @@ -64,7 +73,16 @@ internal class NewFloatingCumulativeGroupedBulkPriceTest { assertThat(newFloatingCumulativeGroupedBulkPrice.cumulativeGroupedBulkConfig()) .isEqualTo( NewFloatingCumulativeGroupedBulkPrice.CumulativeGroupedBulkConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .addDimensionValue( + NewFloatingCumulativeGroupedBulkPrice.CumulativeGroupedBulkConfig + .DimensionValue + .builder() + .groupingKey("x") + .tierLowerBound("tier_lower_bound") + .unitAmount("unit_amount") + .build() + ) + .group("group") .build() ) assertThat(newFloatingCumulativeGroupedBulkPrice.currency()).isEqualTo("currency") @@ -129,7 +147,16 @@ internal class NewFloatingCumulativeGroupedBulkPriceTest { .cadence(NewFloatingCumulativeGroupedBulkPrice.Cadence.ANNUAL) .cumulativeGroupedBulkConfig( NewFloatingCumulativeGroupedBulkPrice.CumulativeGroupedBulkConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .addDimensionValue( + NewFloatingCumulativeGroupedBulkPrice.CumulativeGroupedBulkConfig + .DimensionValue + .builder() + .groupingKey("x") + .tierLowerBound("tier_lower_bound") + .unitAmount("unit_amount") + .build() + ) + .group("group") .build() ) .currency("currency") diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingGroupedAllocationPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingGroupedAllocationPriceTest.kt index ddfc001a7..cebafb107 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingGroupedAllocationPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingGroupedAllocationPriceTest.kt @@ -18,7 +18,9 @@ internal class NewFloatingGroupedAllocationPriceTest { .currency("currency") .groupedAllocationConfig( NewFloatingGroupedAllocationPrice.GroupedAllocationConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .allocation("allocation") + .groupingKey("x") + .overageUnitRate("overage_unit_rate") .build() ) .itemId("item_id") @@ -65,7 +67,9 @@ internal class NewFloatingGroupedAllocationPriceTest { assertThat(newFloatingGroupedAllocationPrice.groupedAllocationConfig()) .isEqualTo( NewFloatingGroupedAllocationPrice.GroupedAllocationConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .allocation("allocation") + .groupingKey("x") + .overageUnitRate("overage_unit_rate") .build() ) assertThat(newFloatingGroupedAllocationPrice.itemId()).isEqualTo("item_id") @@ -130,7 +134,9 @@ internal class NewFloatingGroupedAllocationPriceTest { .currency("currency") .groupedAllocationConfig( NewFloatingGroupedAllocationPrice.GroupedAllocationConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .allocation("allocation") + .groupingKey("x") + .overageUnitRate("overage_unit_rate") .build() ) .itemId("item_id") diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingGroupedTieredPackagePriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingGroupedTieredPackagePriceTest.kt index d72265739..5024114f4 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingGroupedTieredPackagePriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingGroupedTieredPackagePriceTest.kt @@ -18,7 +18,22 @@ internal class NewFloatingGroupedTieredPackagePriceTest { .currency("currency") .groupedTieredPackageConfig( NewFloatingGroupedTieredPackagePrice.GroupedTieredPackageConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .groupingKey("x") + .packageSize("package_size") + .addTier( + NewFloatingGroupedTieredPackagePrice.GroupedTieredPackageConfig.Tier + .builder() + .perUnit("per_unit") + .tierLowerBound("tier_lower_bound") + .build() + ) + .addTier( + NewFloatingGroupedTieredPackagePrice.GroupedTieredPackageConfig.Tier + .builder() + .perUnit("per_unit") + .tierLowerBound("tier_lower_bound") + .build() + ) .build() ) .itemId("item_id") @@ -65,7 +80,22 @@ internal class NewFloatingGroupedTieredPackagePriceTest { assertThat(newFloatingGroupedTieredPackagePrice.groupedTieredPackageConfig()) .isEqualTo( NewFloatingGroupedTieredPackagePrice.GroupedTieredPackageConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .groupingKey("x") + .packageSize("package_size") + .addTier( + NewFloatingGroupedTieredPackagePrice.GroupedTieredPackageConfig.Tier + .builder() + .perUnit("per_unit") + .tierLowerBound("tier_lower_bound") + .build() + ) + .addTier( + NewFloatingGroupedTieredPackagePrice.GroupedTieredPackageConfig.Tier + .builder() + .perUnit("per_unit") + .tierLowerBound("tier_lower_bound") + .build() + ) .build() ) assertThat(newFloatingGroupedTieredPackagePrice.itemId()).isEqualTo("item_id") @@ -130,7 +160,22 @@ internal class NewFloatingGroupedTieredPackagePriceTest { .currency("currency") .groupedTieredPackageConfig( NewFloatingGroupedTieredPackagePrice.GroupedTieredPackageConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .groupingKey("x") + .packageSize("package_size") + .addTier( + NewFloatingGroupedTieredPackagePrice.GroupedTieredPackageConfig.Tier + .builder() + .perUnit("per_unit") + .tierLowerBound("tier_lower_bound") + .build() + ) + .addTier( + NewFloatingGroupedTieredPackagePrice.GroupedTieredPackageConfig.Tier + .builder() + .perUnit("per_unit") + .tierLowerBound("tier_lower_bound") + .build() + ) .build() ) .itemId("item_id") diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingGroupedTieredPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingGroupedTieredPriceTest.kt index 5bf01cc90..2c5b7e5b4 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingGroupedTieredPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingGroupedTieredPriceTest.kt @@ -18,7 +18,19 @@ internal class NewFloatingGroupedTieredPriceTest { .currency("currency") .groupedTieredConfig( NewFloatingGroupedTieredPrice.GroupedTieredConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .groupingKey("x") + .addTier( + NewFloatingGroupedTieredPrice.GroupedTieredConfig.Tier.builder() + .tierLowerBound("tier_lower_bound") + .unitAmount("unit_amount") + .build() + ) + .addTier( + NewFloatingGroupedTieredPrice.GroupedTieredConfig.Tier.builder() + .tierLowerBound("tier_lower_bound") + .unitAmount("unit_amount") + .build() + ) .build() ) .itemId("item_id") @@ -65,7 +77,19 @@ internal class NewFloatingGroupedTieredPriceTest { assertThat(newFloatingGroupedTieredPrice.groupedTieredConfig()) .isEqualTo( NewFloatingGroupedTieredPrice.GroupedTieredConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .groupingKey("x") + .addTier( + NewFloatingGroupedTieredPrice.GroupedTieredConfig.Tier.builder() + .tierLowerBound("tier_lower_bound") + .unitAmount("unit_amount") + .build() + ) + .addTier( + NewFloatingGroupedTieredPrice.GroupedTieredConfig.Tier.builder() + .tierLowerBound("tier_lower_bound") + .unitAmount("unit_amount") + .build() + ) .build() ) assertThat(newFloatingGroupedTieredPrice.itemId()).isEqualTo("item_id") @@ -128,7 +152,19 @@ internal class NewFloatingGroupedTieredPriceTest { .currency("currency") .groupedTieredConfig( NewFloatingGroupedTieredPrice.GroupedTieredConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .groupingKey("x") + .addTier( + NewFloatingGroupedTieredPrice.GroupedTieredConfig.Tier.builder() + .tierLowerBound("tier_lower_bound") + .unitAmount("unit_amount") + .build() + ) + .addTier( + NewFloatingGroupedTieredPrice.GroupedTieredConfig.Tier.builder() + .tierLowerBound("tier_lower_bound") + .unitAmount("unit_amount") + .build() + ) .build() ) .itemId("item_id") diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingGroupedWithMeteredMinimumPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingGroupedWithMeteredMinimumPriceTest.kt index 43b4ebb13..086f81e57 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingGroupedWithMeteredMinimumPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingGroupedWithMeteredMinimumPriceTest.kt @@ -19,7 +19,28 @@ internal class NewFloatingGroupedWithMeteredMinimumPriceTest { .groupedWithMeteredMinimumConfig( NewFloatingGroupedWithMeteredMinimumPrice.GroupedWithMeteredMinimumConfig .builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .groupingKey("x") + .minimumUnitAmount("minimum_unit_amount") + .pricingKey("pricing_key") + .addScalingFactor( + NewFloatingGroupedWithMeteredMinimumPrice + .GroupedWithMeteredMinimumConfig + .ScalingFactor + .builder() + .scalingFactor("scaling_factor") + .scalingValue("scaling_value") + .build() + ) + .scalingKey("scaling_key") + .addUnitAmount( + NewFloatingGroupedWithMeteredMinimumPrice + .GroupedWithMeteredMinimumConfig + .UnitAmount + .builder() + .pricingValue("pricing_value") + .unitAmount("unit_amount") + .build() + ) .build() ) .itemId("item_id") @@ -68,7 +89,26 @@ internal class NewFloatingGroupedWithMeteredMinimumPriceTest { assertThat(newFloatingGroupedWithMeteredMinimumPrice.groupedWithMeteredMinimumConfig()) .isEqualTo( NewFloatingGroupedWithMeteredMinimumPrice.GroupedWithMeteredMinimumConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .groupingKey("x") + .minimumUnitAmount("minimum_unit_amount") + .pricingKey("pricing_key") + .addScalingFactor( + NewFloatingGroupedWithMeteredMinimumPrice.GroupedWithMeteredMinimumConfig + .ScalingFactor + .builder() + .scalingFactor("scaling_factor") + .scalingValue("scaling_value") + .build() + ) + .scalingKey("scaling_key") + .addUnitAmount( + NewFloatingGroupedWithMeteredMinimumPrice.GroupedWithMeteredMinimumConfig + .UnitAmount + .builder() + .pricingValue("pricing_value") + .unitAmount("unit_amount") + .build() + ) .build() ) assertThat(newFloatingGroupedWithMeteredMinimumPrice.itemId()).isEqualTo("item_id") @@ -136,7 +176,28 @@ internal class NewFloatingGroupedWithMeteredMinimumPriceTest { .groupedWithMeteredMinimumConfig( NewFloatingGroupedWithMeteredMinimumPrice.GroupedWithMeteredMinimumConfig .builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .groupingKey("x") + .minimumUnitAmount("minimum_unit_amount") + .pricingKey("pricing_key") + .addScalingFactor( + NewFloatingGroupedWithMeteredMinimumPrice + .GroupedWithMeteredMinimumConfig + .ScalingFactor + .builder() + .scalingFactor("scaling_factor") + .scalingValue("scaling_value") + .build() + ) + .scalingKey("scaling_key") + .addUnitAmount( + NewFloatingGroupedWithMeteredMinimumPrice + .GroupedWithMeteredMinimumConfig + .UnitAmount + .builder() + .pricingValue("pricing_value") + .unitAmount("unit_amount") + .build() + ) .build() ) .itemId("item_id") diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingGroupedWithProratedMinimumPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingGroupedWithProratedMinimumPriceTest.kt index 80baa9fa2..c3483007b 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingGroupedWithProratedMinimumPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingGroupedWithProratedMinimumPriceTest.kt @@ -19,7 +19,9 @@ internal class NewFloatingGroupedWithProratedMinimumPriceTest { .groupedWithProratedMinimumConfig( NewFloatingGroupedWithProratedMinimumPrice.GroupedWithProratedMinimumConfig .builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .groupingKey("x") + .minimum("minimum") + .unitRate("unit_rate") .build() ) .itemId("item_id") @@ -70,7 +72,9 @@ internal class NewFloatingGroupedWithProratedMinimumPriceTest { .isEqualTo( NewFloatingGroupedWithProratedMinimumPrice.GroupedWithProratedMinimumConfig .builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .groupingKey("x") + .minimum("minimum") + .unitRate("unit_rate") .build() ) assertThat(newFloatingGroupedWithProratedMinimumPrice.itemId()).isEqualTo("item_id") @@ -138,7 +142,9 @@ internal class NewFloatingGroupedWithProratedMinimumPriceTest { .groupedWithProratedMinimumConfig( NewFloatingGroupedWithProratedMinimumPrice.GroupedWithProratedMinimumConfig .builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .groupingKey("x") + .minimum("minimum") + .unitRate("unit_rate") .build() ) .itemId("item_id") diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingMatrixWithAllocationPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingMatrixWithAllocationPriceTest.kt index 1fc48df96..52190e650 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingMatrixWithAllocationPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingMatrixWithAllocationPriceTest.kt @@ -19,11 +19,11 @@ internal class NewFloatingMatrixWithAllocationPriceTest { .itemId("item_id") .matrixWithAllocationConfig( MatrixWithAllocationConfig.builder() - .allocation(0.0) + .allocation("allocation") .defaultUnitAmount("default_unit_amount") .addDimension("string") .addMatrixValue( - MatrixValue.builder() + MatrixWithAllocationConfig.MatrixValue.builder() .addDimensionValue("string") .unitAmount("unit_amount") .build() @@ -74,11 +74,11 @@ internal class NewFloatingMatrixWithAllocationPriceTest { assertThat(newFloatingMatrixWithAllocationPrice.matrixWithAllocationConfig()) .isEqualTo( MatrixWithAllocationConfig.builder() - .allocation(0.0) + .allocation("allocation") .defaultUnitAmount("default_unit_amount") .addDimension("string") .addMatrixValue( - MatrixValue.builder() + MatrixWithAllocationConfig.MatrixValue.builder() .addDimensionValue("string") .unitAmount("unit_amount") .build() @@ -147,11 +147,11 @@ internal class NewFloatingMatrixWithAllocationPriceTest { .itemId("item_id") .matrixWithAllocationConfig( MatrixWithAllocationConfig.builder() - .allocation(0.0) + .allocation("allocation") .defaultUnitAmount("default_unit_amount") .addDimension("string") .addMatrixValue( - MatrixValue.builder() + MatrixWithAllocationConfig.MatrixValue.builder() .addDimensionValue("string") .unitAmount("unit_amount") .build() diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingMatrixWithDisplayNamePriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingMatrixWithDisplayNamePriceTest.kt index 3a87f45b3..ab4dc60e7 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingMatrixWithDisplayNamePriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingMatrixWithDisplayNamePriceTest.kt @@ -19,7 +19,16 @@ internal class NewFloatingMatrixWithDisplayNamePriceTest { .itemId("item_id") .matrixWithDisplayNameConfig( NewFloatingMatrixWithDisplayNamePrice.MatrixWithDisplayNameConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .dimension("dimension") + .addUnitAmount( + NewFloatingMatrixWithDisplayNamePrice.MatrixWithDisplayNameConfig + .UnitAmount + .builder() + .dimensionValue("dimension_value") + .displayName("display_name") + .unitAmount("unit_amount") + .build() + ) .build() ) .modelType(NewFloatingMatrixWithDisplayNamePrice.ModelType.MATRIX_WITH_DISPLAY_NAME) @@ -66,7 +75,15 @@ internal class NewFloatingMatrixWithDisplayNamePriceTest { assertThat(newFloatingMatrixWithDisplayNamePrice.matrixWithDisplayNameConfig()) .isEqualTo( NewFloatingMatrixWithDisplayNamePrice.MatrixWithDisplayNameConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .dimension("dimension") + .addUnitAmount( + NewFloatingMatrixWithDisplayNamePrice.MatrixWithDisplayNameConfig.UnitAmount + .builder() + .dimensionValue("dimension_value") + .displayName("display_name") + .unitAmount("unit_amount") + .build() + ) .build() ) assertThat(newFloatingMatrixWithDisplayNamePrice.modelType()) @@ -131,7 +148,16 @@ internal class NewFloatingMatrixWithDisplayNamePriceTest { .itemId("item_id") .matrixWithDisplayNameConfig( NewFloatingMatrixWithDisplayNamePrice.MatrixWithDisplayNameConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .dimension("dimension") + .addUnitAmount( + NewFloatingMatrixWithDisplayNamePrice.MatrixWithDisplayNameConfig + .UnitAmount + .builder() + .dimensionValue("dimension_value") + .displayName("display_name") + .unitAmount("unit_amount") + .build() + ) .build() ) .modelType(NewFloatingMatrixWithDisplayNamePrice.ModelType.MATRIX_WITH_DISPLAY_NAME) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingMaxGroupTieredPackagePriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingMaxGroupTieredPackagePriceTest.kt index 4842737b8..bb504e15b 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingMaxGroupTieredPackagePriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingMaxGroupTieredPackagePriceTest.kt @@ -19,7 +19,22 @@ internal class NewFloatingMaxGroupTieredPackagePriceTest { .itemId("item_id") .maxGroupTieredPackageConfig( NewFloatingMaxGroupTieredPackagePrice.MaxGroupTieredPackageConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .groupingKey("x") + .packageSize("package_size") + .addTier( + NewFloatingMaxGroupTieredPackagePrice.MaxGroupTieredPackageConfig.Tier + .builder() + .tierLowerBound("tier_lower_bound") + .unitAmount("unit_amount") + .build() + ) + .addTier( + NewFloatingMaxGroupTieredPackagePrice.MaxGroupTieredPackageConfig.Tier + .builder() + .tierLowerBound("tier_lower_bound") + .unitAmount("unit_amount") + .build() + ) .build() ) .modelType(NewFloatingMaxGroupTieredPackagePrice.ModelType.MAX_GROUP_TIERED_PACKAGE) @@ -66,7 +81,22 @@ internal class NewFloatingMaxGroupTieredPackagePriceTest { assertThat(newFloatingMaxGroupTieredPackagePrice.maxGroupTieredPackageConfig()) .isEqualTo( NewFloatingMaxGroupTieredPackagePrice.MaxGroupTieredPackageConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .groupingKey("x") + .packageSize("package_size") + .addTier( + NewFloatingMaxGroupTieredPackagePrice.MaxGroupTieredPackageConfig.Tier + .builder() + .tierLowerBound("tier_lower_bound") + .unitAmount("unit_amount") + .build() + ) + .addTier( + NewFloatingMaxGroupTieredPackagePrice.MaxGroupTieredPackageConfig.Tier + .builder() + .tierLowerBound("tier_lower_bound") + .unitAmount("unit_amount") + .build() + ) .build() ) assertThat(newFloatingMaxGroupTieredPackagePrice.modelType()) @@ -131,7 +161,22 @@ internal class NewFloatingMaxGroupTieredPackagePriceTest { .itemId("item_id") .maxGroupTieredPackageConfig( NewFloatingMaxGroupTieredPackagePrice.MaxGroupTieredPackageConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .groupingKey("x") + .packageSize("package_size") + .addTier( + NewFloatingMaxGroupTieredPackagePrice.MaxGroupTieredPackageConfig.Tier + .builder() + .tierLowerBound("tier_lower_bound") + .unitAmount("unit_amount") + .build() + ) + .addTier( + NewFloatingMaxGroupTieredPackagePrice.MaxGroupTieredPackageConfig.Tier + .builder() + .tierLowerBound("tier_lower_bound") + .unitAmount("unit_amount") + .build() + ) .build() ) .modelType(NewFloatingMaxGroupTieredPackagePrice.ModelType.MAX_GROUP_TIERED_PACKAGE) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingPackagePriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingPackagePriceTest.kt index fb0a6dcad..f19650a2a 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingPackagePriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingPackagePriceTest.kt @@ -20,7 +20,7 @@ internal class NewFloatingPackagePriceTest { .modelType(NewFloatingPackagePrice.ModelType.PACKAGE) .name("Annual fee") .packageConfig( - PackageConfig.builder().packageAmount("package_amount").packageSize(0L).build() + PackageConfig.builder().packageAmount("package_amount").packageSize(1L).build() ) .billableMetricId("billable_metric_id") .billedInAdvance(true) @@ -66,7 +66,7 @@ internal class NewFloatingPackagePriceTest { assertThat(newFloatingPackagePrice.name()).isEqualTo("Annual fee") assertThat(newFloatingPackagePrice.packageConfig()) .isEqualTo( - PackageConfig.builder().packageAmount("package_amount").packageSize(0L).build() + PackageConfig.builder().packageAmount("package_amount").packageSize(1L).build() ) assertThat(newFloatingPackagePrice.billableMetricId()).isEqualTo("billable_metric_id") assertThat(newFloatingPackagePrice.billedInAdvance()).isEqualTo(true) @@ -126,7 +126,7 @@ internal class NewFloatingPackagePriceTest { .modelType(NewFloatingPackagePrice.ModelType.PACKAGE) .name("Annual fee") .packageConfig( - PackageConfig.builder().packageAmount("package_amount").packageSize(0L).build() + PackageConfig.builder().packageAmount("package_amount").packageSize(1L).build() ) .billableMetricId("billable_metric_id") .billedInAdvance(true) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingPackageWithAllocationPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingPackageWithAllocationPriceTest.kt index 90a5dd2c2..29e99f0e2 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingPackageWithAllocationPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingPackageWithAllocationPriceTest.kt @@ -21,7 +21,9 @@ internal class NewFloatingPackageWithAllocationPriceTest { .name("Annual fee") .packageWithAllocationConfig( NewFloatingPackageWithAllocationPrice.PackageWithAllocationConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .allocation("allocation") + .packageAmount("package_amount") + .packageSize("package_size") .build() ) .billableMetricId("billable_metric_id") @@ -69,7 +71,9 @@ internal class NewFloatingPackageWithAllocationPriceTest { assertThat(newFloatingPackageWithAllocationPrice.packageWithAllocationConfig()) .isEqualTo( NewFloatingPackageWithAllocationPrice.PackageWithAllocationConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .allocation("allocation") + .packageAmount("package_amount") + .packageSize("package_size") .build() ) assertThat(newFloatingPackageWithAllocationPrice.billableMetricId()) @@ -133,7 +137,9 @@ internal class NewFloatingPackageWithAllocationPriceTest { .name("Annual fee") .packageWithAllocationConfig( NewFloatingPackageWithAllocationPrice.PackageWithAllocationConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .allocation("allocation") + .packageAmount("package_amount") + .packageSize("package_size") .build() ) .billableMetricId("billable_metric_id") diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingScalableMatrixWithTieredPricingPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingScalableMatrixWithTieredPricingPriceTest.kt index 0dee6df5e..b7c746752 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingScalableMatrixWithTieredPricingPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingScalableMatrixWithTieredPricingPriceTest.kt @@ -26,7 +26,36 @@ internal class NewFloatingScalableMatrixWithTieredPricingPriceTest { NewFloatingScalableMatrixWithTieredPricingPrice .ScalableMatrixWithTieredPricingConfig .builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .firstDimension("first_dimension") + .addMatrixScalingFactor( + NewFloatingScalableMatrixWithTieredPricingPrice + .ScalableMatrixWithTieredPricingConfig + .MatrixScalingFactor + .builder() + .firstDimensionValue("first_dimension_value") + .scalingFactor("scaling_factor") + .secondDimensionValue("second_dimension_value") + .build() + ) + .addTier( + NewFloatingScalableMatrixWithTieredPricingPrice + .ScalableMatrixWithTieredPricingConfig + .Tier + .builder() + .tierLowerBound("tier_lower_bound") + .unitAmount("unit_amount") + .build() + ) + .addTier( + NewFloatingScalableMatrixWithTieredPricingPrice + .ScalableMatrixWithTieredPricingConfig + .Tier + .builder() + .tierLowerBound("tier_lower_bound") + .unitAmount("unit_amount") + .build() + ) + .secondDimension("second_dimension") .build() ) .billableMetricId("billable_metric_id") @@ -82,7 +111,36 @@ internal class NewFloatingScalableMatrixWithTieredPricingPriceTest { NewFloatingScalableMatrixWithTieredPricingPrice .ScalableMatrixWithTieredPricingConfig .builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .firstDimension("first_dimension") + .addMatrixScalingFactor( + NewFloatingScalableMatrixWithTieredPricingPrice + .ScalableMatrixWithTieredPricingConfig + .MatrixScalingFactor + .builder() + .firstDimensionValue("first_dimension_value") + .scalingFactor("scaling_factor") + .secondDimensionValue("second_dimension_value") + .build() + ) + .addTier( + NewFloatingScalableMatrixWithTieredPricingPrice + .ScalableMatrixWithTieredPricingConfig + .Tier + .builder() + .tierLowerBound("tier_lower_bound") + .unitAmount("unit_amount") + .build() + ) + .addTier( + NewFloatingScalableMatrixWithTieredPricingPrice + .ScalableMatrixWithTieredPricingConfig + .Tier + .builder() + .tierLowerBound("tier_lower_bound") + .unitAmount("unit_amount") + .build() + ) + .secondDimension("second_dimension") .build() ) assertThat(newFloatingScalableMatrixWithTieredPricingPrice.billableMetricId()) @@ -154,7 +212,36 @@ internal class NewFloatingScalableMatrixWithTieredPricingPriceTest { NewFloatingScalableMatrixWithTieredPricingPrice .ScalableMatrixWithTieredPricingConfig .builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .firstDimension("first_dimension") + .addMatrixScalingFactor( + NewFloatingScalableMatrixWithTieredPricingPrice + .ScalableMatrixWithTieredPricingConfig + .MatrixScalingFactor + .builder() + .firstDimensionValue("first_dimension_value") + .scalingFactor("scaling_factor") + .secondDimensionValue("second_dimension_value") + .build() + ) + .addTier( + NewFloatingScalableMatrixWithTieredPricingPrice + .ScalableMatrixWithTieredPricingConfig + .Tier + .builder() + .tierLowerBound("tier_lower_bound") + .unitAmount("unit_amount") + .build() + ) + .addTier( + NewFloatingScalableMatrixWithTieredPricingPrice + .ScalableMatrixWithTieredPricingConfig + .Tier + .builder() + .tierLowerBound("tier_lower_bound") + .unitAmount("unit_amount") + .build() + ) + .secondDimension("second_dimension") .build() ) .billableMetricId("billable_metric_id") diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingScalableMatrixWithUnitPricingPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingScalableMatrixWithUnitPricingPriceTest.kt index 6bfe37e36..a387a2126 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingScalableMatrixWithUnitPricingPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingScalableMatrixWithUnitPricingPriceTest.kt @@ -26,7 +26,20 @@ internal class NewFloatingScalableMatrixWithUnitPricingPriceTest { NewFloatingScalableMatrixWithUnitPricingPrice .ScalableMatrixWithUnitPricingConfig .builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .firstDimension("first_dimension") + .addMatrixScalingFactor( + NewFloatingScalableMatrixWithUnitPricingPrice + .ScalableMatrixWithUnitPricingConfig + .MatrixScalingFactor + .builder() + .firstDimensionValue("first_dimension_value") + .scalingFactor("scaling_factor") + .secondDimensionValue("second_dimension_value") + .build() + ) + .unitPrice("unit_price") + .prorate(true) + .secondDimension("second_dimension") .build() ) .billableMetricId("billable_metric_id") @@ -80,7 +93,20 @@ internal class NewFloatingScalableMatrixWithUnitPricingPriceTest { .isEqualTo( NewFloatingScalableMatrixWithUnitPricingPrice.ScalableMatrixWithUnitPricingConfig .builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .firstDimension("first_dimension") + .addMatrixScalingFactor( + NewFloatingScalableMatrixWithUnitPricingPrice + .ScalableMatrixWithUnitPricingConfig + .MatrixScalingFactor + .builder() + .firstDimensionValue("first_dimension_value") + .scalingFactor("scaling_factor") + .secondDimensionValue("second_dimension_value") + .build() + ) + .unitPrice("unit_price") + .prorate(true) + .secondDimension("second_dimension") .build() ) assertThat(newFloatingScalableMatrixWithUnitPricingPrice.billableMetricId()) @@ -151,7 +177,20 @@ internal class NewFloatingScalableMatrixWithUnitPricingPriceTest { NewFloatingScalableMatrixWithUnitPricingPrice .ScalableMatrixWithUnitPricingConfig .builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .firstDimension("first_dimension") + .addMatrixScalingFactor( + NewFloatingScalableMatrixWithUnitPricingPrice + .ScalableMatrixWithUnitPricingConfig + .MatrixScalingFactor + .builder() + .firstDimensionValue("first_dimension_value") + .scalingFactor("scaling_factor") + .secondDimensionValue("second_dimension_value") + .build() + ) + .unitPrice("unit_price") + .prorate(true) + .secondDimension("second_dimension") .build() ) .billableMetricId("billable_metric_id") diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingThresholdTotalAmountPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingThresholdTotalAmountPriceTest.kt index 67dc54605..e40323719 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingThresholdTotalAmountPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingThresholdTotalAmountPriceTest.kt @@ -21,7 +21,23 @@ internal class NewFloatingThresholdTotalAmountPriceTest { .name("Annual fee") .thresholdTotalAmountConfig( NewFloatingThresholdTotalAmountPrice.ThresholdTotalAmountConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .addConsumptionTable( + NewFloatingThresholdTotalAmountPrice.ThresholdTotalAmountConfig + .ConsumptionTable + .builder() + .threshold("threshold") + .totalAmount("total_amount") + .build() + ) + .addConsumptionTable( + NewFloatingThresholdTotalAmountPrice.ThresholdTotalAmountConfig + .ConsumptionTable + .builder() + .threshold("threshold") + .totalAmount("total_amount") + .build() + ) + .prorate(true) .build() ) .billableMetricId("billable_metric_id") @@ -69,7 +85,23 @@ internal class NewFloatingThresholdTotalAmountPriceTest { assertThat(newFloatingThresholdTotalAmountPrice.thresholdTotalAmountConfig()) .isEqualTo( NewFloatingThresholdTotalAmountPrice.ThresholdTotalAmountConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .addConsumptionTable( + NewFloatingThresholdTotalAmountPrice.ThresholdTotalAmountConfig + .ConsumptionTable + .builder() + .threshold("threshold") + .totalAmount("total_amount") + .build() + ) + .addConsumptionTable( + NewFloatingThresholdTotalAmountPrice.ThresholdTotalAmountConfig + .ConsumptionTable + .builder() + .threshold("threshold") + .totalAmount("total_amount") + .build() + ) + .prorate(true) .build() ) assertThat(newFloatingThresholdTotalAmountPrice.billableMetricId()) @@ -133,7 +165,23 @@ internal class NewFloatingThresholdTotalAmountPriceTest { .name("Annual fee") .thresholdTotalAmountConfig( NewFloatingThresholdTotalAmountPrice.ThresholdTotalAmountConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .addConsumptionTable( + NewFloatingThresholdTotalAmountPrice.ThresholdTotalAmountConfig + .ConsumptionTable + .builder() + .threshold("threshold") + .totalAmount("total_amount") + .build() + ) + .addConsumptionTable( + NewFloatingThresholdTotalAmountPrice.ThresholdTotalAmountConfig + .ConsumptionTable + .builder() + .threshold("threshold") + .totalAmount("total_amount") + .build() + ) + .prorate(true) .build() ) .billableMetricId("billable_metric_id") diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingTieredPackagePriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingTieredPackagePriceTest.kt index e9c8fc8ee..9222c9858 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingTieredPackagePriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingTieredPackagePriceTest.kt @@ -21,7 +21,19 @@ internal class NewFloatingTieredPackagePriceTest { .name("Annual fee") .tieredPackageConfig( NewFloatingTieredPackagePrice.TieredPackageConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .packageSize("package_size") + .addTier( + NewFloatingTieredPackagePrice.TieredPackageConfig.Tier.builder() + .perUnit("per_unit") + .tierLowerBound("tier_lower_bound") + .build() + ) + .addTier( + NewFloatingTieredPackagePrice.TieredPackageConfig.Tier.builder() + .perUnit("per_unit") + .tierLowerBound("tier_lower_bound") + .build() + ) .build() ) .billableMetricId("billable_metric_id") @@ -69,7 +81,19 @@ internal class NewFloatingTieredPackagePriceTest { assertThat(newFloatingTieredPackagePrice.tieredPackageConfig()) .isEqualTo( NewFloatingTieredPackagePrice.TieredPackageConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .packageSize("package_size") + .addTier( + NewFloatingTieredPackagePrice.TieredPackageConfig.Tier.builder() + .perUnit("per_unit") + .tierLowerBound("tier_lower_bound") + .build() + ) + .addTier( + NewFloatingTieredPackagePrice.TieredPackageConfig.Tier.builder() + .perUnit("per_unit") + .tierLowerBound("tier_lower_bound") + .build() + ) .build() ) assertThat(newFloatingTieredPackagePrice.billableMetricId()).isEqualTo("billable_metric_id") @@ -131,7 +155,19 @@ internal class NewFloatingTieredPackagePriceTest { .name("Annual fee") .tieredPackageConfig( NewFloatingTieredPackagePrice.TieredPackageConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .packageSize("package_size") + .addTier( + NewFloatingTieredPackagePrice.TieredPackageConfig.Tier.builder() + .perUnit("per_unit") + .tierLowerBound("tier_lower_bound") + .build() + ) + .addTier( + NewFloatingTieredPackagePrice.TieredPackageConfig.Tier.builder() + .perUnit("per_unit") + .tierLowerBound("tier_lower_bound") + .build() + ) .build() ) .billableMetricId("billable_metric_id") diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingTieredPackageWithMinimumPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingTieredPackageWithMinimumPriceTest.kt index d687100a0..70db94c44 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingTieredPackageWithMinimumPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingTieredPackageWithMinimumPriceTest.kt @@ -24,7 +24,25 @@ internal class NewFloatingTieredPackageWithMinimumPriceTest { .tieredPackageWithMinimumConfig( NewFloatingTieredPackageWithMinimumPrice.TieredPackageWithMinimumConfig .builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .packageSize(0.0) + .addTier( + NewFloatingTieredPackageWithMinimumPrice.TieredPackageWithMinimumConfig + .Tier + .builder() + .minimumAmount("minimum_amount") + .perUnit("per_unit") + .tierLowerBound("tier_lower_bound") + .build() + ) + .addTier( + NewFloatingTieredPackageWithMinimumPrice.TieredPackageWithMinimumConfig + .Tier + .builder() + .minimumAmount("minimum_amount") + .perUnit("per_unit") + .tierLowerBound("tier_lower_bound") + .build() + ) .build() ) .billableMetricId("billable_metric_id") @@ -74,7 +92,23 @@ internal class NewFloatingTieredPackageWithMinimumPriceTest { assertThat(newFloatingTieredPackageWithMinimumPrice.tieredPackageWithMinimumConfig()) .isEqualTo( NewFloatingTieredPackageWithMinimumPrice.TieredPackageWithMinimumConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .packageSize(0.0) + .addTier( + NewFloatingTieredPackageWithMinimumPrice.TieredPackageWithMinimumConfig.Tier + .builder() + .minimumAmount("minimum_amount") + .perUnit("per_unit") + .tierLowerBound("tier_lower_bound") + .build() + ) + .addTier( + NewFloatingTieredPackageWithMinimumPrice.TieredPackageWithMinimumConfig.Tier + .builder() + .minimumAmount("minimum_amount") + .perUnit("per_unit") + .tierLowerBound("tier_lower_bound") + .build() + ) .build() ) assertThat(newFloatingTieredPackageWithMinimumPrice.billableMetricId()) @@ -141,7 +175,25 @@ internal class NewFloatingTieredPackageWithMinimumPriceTest { .tieredPackageWithMinimumConfig( NewFloatingTieredPackageWithMinimumPrice.TieredPackageWithMinimumConfig .builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .packageSize(0.0) + .addTier( + NewFloatingTieredPackageWithMinimumPrice.TieredPackageWithMinimumConfig + .Tier + .builder() + .minimumAmount("minimum_amount") + .perUnit("per_unit") + .tierLowerBound("tier_lower_bound") + .build() + ) + .addTier( + NewFloatingTieredPackageWithMinimumPrice.TieredPackageWithMinimumConfig + .Tier + .builder() + .minimumAmount("minimum_amount") + .perUnit("per_unit") + .tierLowerBound("tier_lower_bound") + .build() + ) .build() ) .billableMetricId("billable_metric_id") diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingTieredWithMinimumPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingTieredWithMinimumPriceTest.kt index 26fba3368..4c1244951 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingTieredWithMinimumPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingTieredWithMinimumPriceTest.kt @@ -21,7 +21,22 @@ internal class NewFloatingTieredWithMinimumPriceTest { .name("Annual fee") .tieredWithMinimumConfig( NewFloatingTieredWithMinimumPrice.TieredWithMinimumConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .addTier( + NewFloatingTieredWithMinimumPrice.TieredWithMinimumConfig.Tier.builder() + .minimumAmount("minimum_amount") + .tierLowerBound("tier_lower_bound") + .unitAmount("unit_amount") + .build() + ) + .addTier( + NewFloatingTieredWithMinimumPrice.TieredWithMinimumConfig.Tier.builder() + .minimumAmount("minimum_amount") + .tierLowerBound("tier_lower_bound") + .unitAmount("unit_amount") + .build() + ) + .hideZeroAmountTiers(true) + .prorate(true) .build() ) .billableMetricId("billable_metric_id") @@ -69,7 +84,22 @@ internal class NewFloatingTieredWithMinimumPriceTest { assertThat(newFloatingTieredWithMinimumPrice.tieredWithMinimumConfig()) .isEqualTo( NewFloatingTieredWithMinimumPrice.TieredWithMinimumConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .addTier( + NewFloatingTieredWithMinimumPrice.TieredWithMinimumConfig.Tier.builder() + .minimumAmount("minimum_amount") + .tierLowerBound("tier_lower_bound") + .unitAmount("unit_amount") + .build() + ) + .addTier( + NewFloatingTieredWithMinimumPrice.TieredWithMinimumConfig.Tier.builder() + .minimumAmount("minimum_amount") + .tierLowerBound("tier_lower_bound") + .unitAmount("unit_amount") + .build() + ) + .hideZeroAmountTiers(true) + .prorate(true) .build() ) assertThat(newFloatingTieredWithMinimumPrice.billableMetricId()) @@ -133,7 +163,22 @@ internal class NewFloatingTieredWithMinimumPriceTest { .name("Annual fee") .tieredWithMinimumConfig( NewFloatingTieredWithMinimumPrice.TieredWithMinimumConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .addTier( + NewFloatingTieredWithMinimumPrice.TieredWithMinimumConfig.Tier.builder() + .minimumAmount("minimum_amount") + .tierLowerBound("tier_lower_bound") + .unitAmount("unit_amount") + .build() + ) + .addTier( + NewFloatingTieredWithMinimumPrice.TieredWithMinimumConfig.Tier.builder() + .minimumAmount("minimum_amount") + .tierLowerBound("tier_lower_bound") + .unitAmount("unit_amount") + .build() + ) + .hideZeroAmountTiers(true) + .prorate(true) .build() ) .billableMetricId("billable_metric_id") diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingTieredWithProrationPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingTieredWithProrationPriceTest.kt index f251344a1..a2fce3448 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingTieredWithProrationPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingTieredWithProrationPriceTest.kt @@ -21,7 +21,13 @@ internal class NewFloatingTieredWithProrationPriceTest { .name("Annual fee") .tieredWithProrationConfig( NewFloatingTieredWithProrationPrice.TieredWithProrationConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .addTier( + NewFloatingTieredWithProrationPrice.TieredWithProrationConfig.Tier + .builder() + .tierLowerBound("tier_lower_bound") + .unitAmount("unit_amount") + .build() + ) .build() ) .billableMetricId("billable_metric_id") @@ -69,7 +75,12 @@ internal class NewFloatingTieredWithProrationPriceTest { assertThat(newFloatingTieredWithProrationPrice.tieredWithProrationConfig()) .isEqualTo( NewFloatingTieredWithProrationPrice.TieredWithProrationConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .addTier( + NewFloatingTieredWithProrationPrice.TieredWithProrationConfig.Tier.builder() + .tierLowerBound("tier_lower_bound") + .unitAmount("unit_amount") + .build() + ) .build() ) assertThat(newFloatingTieredWithProrationPrice.billableMetricId()) @@ -133,7 +144,13 @@ internal class NewFloatingTieredWithProrationPriceTest { .name("Annual fee") .tieredWithProrationConfig( NewFloatingTieredWithProrationPrice.TieredWithProrationConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .addTier( + NewFloatingTieredWithProrationPrice.TieredWithProrationConfig.Tier + .builder() + .tierLowerBound("tier_lower_bound") + .unitAmount("unit_amount") + .build() + ) .build() ) .billableMetricId("billable_metric_id") diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingUnitPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingUnitPriceTest.kt index e5ecea168..b83e5452f 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingUnitPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingUnitPriceTest.kt @@ -19,7 +19,9 @@ internal class NewFloatingUnitPriceTest { .itemId("item_id") .modelType(NewFloatingUnitPrice.ModelType.UNIT) .name("Annual fee") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder().unitAmount("unit_amount").scalingFactor(0.0).build() + ) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( @@ -61,7 +63,7 @@ internal class NewFloatingUnitPriceTest { assertThat(newFloatingUnitPrice.modelType()).isEqualTo(NewFloatingUnitPrice.ModelType.UNIT) assertThat(newFloatingUnitPrice.name()).isEqualTo("Annual fee") assertThat(newFloatingUnitPrice.unitConfig()) - .isEqualTo(UnitConfig.builder().unitAmount("unit_amount").build()) + .isEqualTo(UnitConfig.builder().unitAmount("unit_amount").scalingFactor(0.0).build()) assertThat(newFloatingUnitPrice.billableMetricId()).isEqualTo("billable_metric_id") assertThat(newFloatingUnitPrice.billedInAdvance()).isEqualTo(true) assertThat(newFloatingUnitPrice.billingCycleConfiguration()) @@ -119,7 +121,9 @@ internal class NewFloatingUnitPriceTest { .itemId("item_id") .modelType(NewFloatingUnitPrice.ModelType.UNIT) .name("Annual fee") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder().unitAmount("unit_amount").scalingFactor(0.0).build() + ) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingUnitWithPercentPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingUnitWithPercentPriceTest.kt index a7ce0b825..b27455cc1 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingUnitWithPercentPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingUnitWithPercentPriceTest.kt @@ -21,7 +21,8 @@ internal class NewFloatingUnitWithPercentPriceTest { .name("Annual fee") .unitWithPercentConfig( NewFloatingUnitWithPercentPrice.UnitWithPercentConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .percent("percent") + .unitAmount("unit_amount") .build() ) .billableMetricId("billable_metric_id") @@ -69,7 +70,8 @@ internal class NewFloatingUnitWithPercentPriceTest { assertThat(newFloatingUnitWithPercentPrice.unitWithPercentConfig()) .isEqualTo( NewFloatingUnitWithPercentPrice.UnitWithPercentConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .percent("percent") + .unitAmount("unit_amount") .build() ) assertThat(newFloatingUnitWithPercentPrice.billableMetricId()) @@ -132,7 +134,8 @@ internal class NewFloatingUnitWithPercentPriceTest { .name("Annual fee") .unitWithPercentConfig( NewFloatingUnitWithPercentPrice.UnitWithPercentConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .percent("percent") + .unitAmount("unit_amount") .build() ) .billableMetricId("billable_metric_id") diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingUnitWithProrationPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingUnitWithProrationPriceTest.kt index 77e29580c..5d92ac1a6 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingUnitWithProrationPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingUnitWithProrationPriceTest.kt @@ -21,7 +21,7 @@ internal class NewFloatingUnitWithProrationPriceTest { .name("Annual fee") .unitWithProrationConfig( NewFloatingUnitWithProrationPrice.UnitWithProrationConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .unitAmount("unit_amount") .build() ) .billableMetricId("billable_metric_id") @@ -69,7 +69,7 @@ internal class NewFloatingUnitWithProrationPriceTest { assertThat(newFloatingUnitWithProrationPrice.unitWithProrationConfig()) .isEqualTo( NewFloatingUnitWithProrationPrice.UnitWithProrationConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .unitAmount("unit_amount") .build() ) assertThat(newFloatingUnitWithProrationPrice.billableMetricId()) @@ -133,7 +133,7 @@ internal class NewFloatingUnitWithProrationPriceTest { .name("Annual fee") .unitWithProrationConfig( NewFloatingUnitWithProrationPrice.UnitWithProrationConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .unitAmount("unit_amount") .build() ) .billableMetricId("billable_metric_id") diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanBulkWithProrationPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanBulkWithProrationPriceTest.kt index e1eb61503..2fcf10a24 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanBulkWithProrationPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanBulkWithProrationPriceTest.kt @@ -16,7 +16,18 @@ internal class NewPlanBulkWithProrationPriceTest { NewPlanBulkWithProrationPrice.builder() .bulkWithProrationConfig( NewPlanBulkWithProrationPrice.BulkWithProrationConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .addTier( + NewPlanBulkWithProrationPrice.BulkWithProrationConfig.Tier.builder() + .unitAmount("unit_amount") + .tierLowerBound("tier_lower_bound") + .build() + ) + .addTier( + NewPlanBulkWithProrationPrice.BulkWithProrationConfig.Tier.builder() + .unitAmount("unit_amount") + .tierLowerBound("tier_lower_bound") + .build() + ) .build() ) .cadence(NewPlanBulkWithProrationPrice.Cadence.ANNUAL) @@ -63,7 +74,18 @@ internal class NewPlanBulkWithProrationPriceTest { assertThat(newPlanBulkWithProrationPrice.bulkWithProrationConfig()) .isEqualTo( NewPlanBulkWithProrationPrice.BulkWithProrationConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .addTier( + NewPlanBulkWithProrationPrice.BulkWithProrationConfig.Tier.builder() + .unitAmount("unit_amount") + .tierLowerBound("tier_lower_bound") + .build() + ) + .addTier( + NewPlanBulkWithProrationPrice.BulkWithProrationConfig.Tier.builder() + .unitAmount("unit_amount") + .tierLowerBound("tier_lower_bound") + .build() + ) .build() ) assertThat(newPlanBulkWithProrationPrice.cadence()) @@ -128,7 +150,18 @@ internal class NewPlanBulkWithProrationPriceTest { NewPlanBulkWithProrationPrice.builder() .bulkWithProrationConfig( NewPlanBulkWithProrationPrice.BulkWithProrationConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .addTier( + NewPlanBulkWithProrationPrice.BulkWithProrationConfig.Tier.builder() + .unitAmount("unit_amount") + .tierLowerBound("tier_lower_bound") + .build() + ) + .addTier( + NewPlanBulkWithProrationPrice.BulkWithProrationConfig.Tier.builder() + .unitAmount("unit_amount") + .tierLowerBound("tier_lower_bound") + .build() + ) .build() ) .cadence(NewPlanBulkWithProrationPrice.Cadence.ANNUAL) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanCumulativeGroupedBulkPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanCumulativeGroupedBulkPriceTest.kt index 1e4b0cfa8..36c501bb0 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanCumulativeGroupedBulkPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanCumulativeGroupedBulkPriceTest.kt @@ -17,7 +17,16 @@ internal class NewPlanCumulativeGroupedBulkPriceTest { .cadence(NewPlanCumulativeGroupedBulkPrice.Cadence.ANNUAL) .cumulativeGroupedBulkConfig( NewPlanCumulativeGroupedBulkPrice.CumulativeGroupedBulkConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .addDimensionValue( + NewPlanCumulativeGroupedBulkPrice.CumulativeGroupedBulkConfig + .DimensionValue + .builder() + .groupingKey("x") + .tierLowerBound("tier_lower_bound") + .unitAmount("unit_amount") + .build() + ) + .group("group") .build() ) .itemId("item_id") @@ -65,7 +74,15 @@ internal class NewPlanCumulativeGroupedBulkPriceTest { assertThat(newPlanCumulativeGroupedBulkPrice.cumulativeGroupedBulkConfig()) .isEqualTo( NewPlanCumulativeGroupedBulkPrice.CumulativeGroupedBulkConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .addDimensionValue( + NewPlanCumulativeGroupedBulkPrice.CumulativeGroupedBulkConfig.DimensionValue + .builder() + .groupingKey("x") + .tierLowerBound("tier_lower_bound") + .unitAmount("unit_amount") + .build() + ) + .group("group") .build() ) assertThat(newPlanCumulativeGroupedBulkPrice.itemId()).isEqualTo("item_id") @@ -131,7 +148,16 @@ internal class NewPlanCumulativeGroupedBulkPriceTest { .cadence(NewPlanCumulativeGroupedBulkPrice.Cadence.ANNUAL) .cumulativeGroupedBulkConfig( NewPlanCumulativeGroupedBulkPrice.CumulativeGroupedBulkConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .addDimensionValue( + NewPlanCumulativeGroupedBulkPrice.CumulativeGroupedBulkConfig + .DimensionValue + .builder() + .groupingKey("x") + .tierLowerBound("tier_lower_bound") + .unitAmount("unit_amount") + .build() + ) + .group("group") .build() ) .itemId("item_id") diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanGroupedAllocationPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanGroupedAllocationPriceTest.kt index 24a383615..5e22b6837 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanGroupedAllocationPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanGroupedAllocationPriceTest.kt @@ -17,7 +17,9 @@ internal class NewPlanGroupedAllocationPriceTest { .cadence(NewPlanGroupedAllocationPrice.Cadence.ANNUAL) .groupedAllocationConfig( NewPlanGroupedAllocationPrice.GroupedAllocationConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .allocation("allocation") + .groupingKey("x") + .overageUnitRate("overage_unit_rate") .build() ) .itemId("item_id") @@ -65,7 +67,9 @@ internal class NewPlanGroupedAllocationPriceTest { assertThat(newPlanGroupedAllocationPrice.groupedAllocationConfig()) .isEqualTo( NewPlanGroupedAllocationPrice.GroupedAllocationConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .allocation("allocation") + .groupingKey("x") + .overageUnitRate("overage_unit_rate") .build() ) assertThat(newPlanGroupedAllocationPrice.itemId()).isEqualTo("item_id") @@ -129,7 +133,9 @@ internal class NewPlanGroupedAllocationPriceTest { .cadence(NewPlanGroupedAllocationPrice.Cadence.ANNUAL) .groupedAllocationConfig( NewPlanGroupedAllocationPrice.GroupedAllocationConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .allocation("allocation") + .groupingKey("x") + .overageUnitRate("overage_unit_rate") .build() ) .itemId("item_id") diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanGroupedTieredPackagePriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanGroupedTieredPackagePriceTest.kt index a51b98f34..fe2768ed2 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanGroupedTieredPackagePriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanGroupedTieredPackagePriceTest.kt @@ -17,7 +17,22 @@ internal class NewPlanGroupedTieredPackagePriceTest { .cadence(NewPlanGroupedTieredPackagePrice.Cadence.ANNUAL) .groupedTieredPackageConfig( NewPlanGroupedTieredPackagePrice.GroupedTieredPackageConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .groupingKey("x") + .packageSize("package_size") + .addTier( + NewPlanGroupedTieredPackagePrice.GroupedTieredPackageConfig.Tier + .builder() + .perUnit("per_unit") + .tierLowerBound("tier_lower_bound") + .build() + ) + .addTier( + NewPlanGroupedTieredPackagePrice.GroupedTieredPackageConfig.Tier + .builder() + .perUnit("per_unit") + .tierLowerBound("tier_lower_bound") + .build() + ) .build() ) .itemId("item_id") @@ -65,7 +80,20 @@ internal class NewPlanGroupedTieredPackagePriceTest { assertThat(newPlanGroupedTieredPackagePrice.groupedTieredPackageConfig()) .isEqualTo( NewPlanGroupedTieredPackagePrice.GroupedTieredPackageConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .groupingKey("x") + .packageSize("package_size") + .addTier( + NewPlanGroupedTieredPackagePrice.GroupedTieredPackageConfig.Tier.builder() + .perUnit("per_unit") + .tierLowerBound("tier_lower_bound") + .build() + ) + .addTier( + NewPlanGroupedTieredPackagePrice.GroupedTieredPackageConfig.Tier.builder() + .perUnit("per_unit") + .tierLowerBound("tier_lower_bound") + .build() + ) .build() ) assertThat(newPlanGroupedTieredPackagePrice.itemId()).isEqualTo("item_id") @@ -131,7 +159,22 @@ internal class NewPlanGroupedTieredPackagePriceTest { .cadence(NewPlanGroupedTieredPackagePrice.Cadence.ANNUAL) .groupedTieredPackageConfig( NewPlanGroupedTieredPackagePrice.GroupedTieredPackageConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .groupingKey("x") + .packageSize("package_size") + .addTier( + NewPlanGroupedTieredPackagePrice.GroupedTieredPackageConfig.Tier + .builder() + .perUnit("per_unit") + .tierLowerBound("tier_lower_bound") + .build() + ) + .addTier( + NewPlanGroupedTieredPackagePrice.GroupedTieredPackageConfig.Tier + .builder() + .perUnit("per_unit") + .tierLowerBound("tier_lower_bound") + .build() + ) .build() ) .itemId("item_id") diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanGroupedTieredPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanGroupedTieredPriceTest.kt index 8e512fffe..b2cfcba91 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanGroupedTieredPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanGroupedTieredPriceTest.kt @@ -17,7 +17,19 @@ internal class NewPlanGroupedTieredPriceTest { .cadence(NewPlanGroupedTieredPrice.Cadence.ANNUAL) .groupedTieredConfig( NewPlanGroupedTieredPrice.GroupedTieredConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .groupingKey("x") + .addTier( + NewPlanGroupedTieredPrice.GroupedTieredConfig.Tier.builder() + .tierLowerBound("tier_lower_bound") + .unitAmount("unit_amount") + .build() + ) + .addTier( + NewPlanGroupedTieredPrice.GroupedTieredConfig.Tier.builder() + .tierLowerBound("tier_lower_bound") + .unitAmount("unit_amount") + .build() + ) .build() ) .itemId("item_id") @@ -65,7 +77,19 @@ internal class NewPlanGroupedTieredPriceTest { assertThat(newPlanGroupedTieredPrice.groupedTieredConfig()) .isEqualTo( NewPlanGroupedTieredPrice.GroupedTieredConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .groupingKey("x") + .addTier( + NewPlanGroupedTieredPrice.GroupedTieredConfig.Tier.builder() + .tierLowerBound("tier_lower_bound") + .unitAmount("unit_amount") + .build() + ) + .addTier( + NewPlanGroupedTieredPrice.GroupedTieredConfig.Tier.builder() + .tierLowerBound("tier_lower_bound") + .unitAmount("unit_amount") + .build() + ) .build() ) assertThat(newPlanGroupedTieredPrice.itemId()).isEqualTo("item_id") @@ -129,7 +153,19 @@ internal class NewPlanGroupedTieredPriceTest { .cadence(NewPlanGroupedTieredPrice.Cadence.ANNUAL) .groupedTieredConfig( NewPlanGroupedTieredPrice.GroupedTieredConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .groupingKey("x") + .addTier( + NewPlanGroupedTieredPrice.GroupedTieredConfig.Tier.builder() + .tierLowerBound("tier_lower_bound") + .unitAmount("unit_amount") + .build() + ) + .addTier( + NewPlanGroupedTieredPrice.GroupedTieredConfig.Tier.builder() + .tierLowerBound("tier_lower_bound") + .unitAmount("unit_amount") + .build() + ) .build() ) .itemId("item_id") diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanGroupedWithMeteredMinimumPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanGroupedWithMeteredMinimumPriceTest.kt index 450e7b9a8..8f45e3f76 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanGroupedWithMeteredMinimumPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanGroupedWithMeteredMinimumPriceTest.kt @@ -17,7 +17,26 @@ internal class NewPlanGroupedWithMeteredMinimumPriceTest { .cadence(NewPlanGroupedWithMeteredMinimumPrice.Cadence.ANNUAL) .groupedWithMeteredMinimumConfig( NewPlanGroupedWithMeteredMinimumPrice.GroupedWithMeteredMinimumConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .groupingKey("x") + .minimumUnitAmount("minimum_unit_amount") + .pricingKey("pricing_key") + .addScalingFactor( + NewPlanGroupedWithMeteredMinimumPrice.GroupedWithMeteredMinimumConfig + .ScalingFactor + .builder() + .scalingFactor("scaling_factor") + .scalingValue("scaling_value") + .build() + ) + .scalingKey("scaling_key") + .addUnitAmount( + NewPlanGroupedWithMeteredMinimumPrice.GroupedWithMeteredMinimumConfig + .UnitAmount + .builder() + .pricingValue("pricing_value") + .unitAmount("unit_amount") + .build() + ) .build() ) .itemId("item_id") @@ -67,7 +86,26 @@ internal class NewPlanGroupedWithMeteredMinimumPriceTest { assertThat(newPlanGroupedWithMeteredMinimumPrice.groupedWithMeteredMinimumConfig()) .isEqualTo( NewPlanGroupedWithMeteredMinimumPrice.GroupedWithMeteredMinimumConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .groupingKey("x") + .minimumUnitAmount("minimum_unit_amount") + .pricingKey("pricing_key") + .addScalingFactor( + NewPlanGroupedWithMeteredMinimumPrice.GroupedWithMeteredMinimumConfig + .ScalingFactor + .builder() + .scalingFactor("scaling_factor") + .scalingValue("scaling_value") + .build() + ) + .scalingKey("scaling_key") + .addUnitAmount( + NewPlanGroupedWithMeteredMinimumPrice.GroupedWithMeteredMinimumConfig + .UnitAmount + .builder() + .pricingValue("pricing_value") + .unitAmount("unit_amount") + .build() + ) .build() ) assertThat(newPlanGroupedWithMeteredMinimumPrice.itemId()).isEqualTo("item_id") @@ -133,7 +171,26 @@ internal class NewPlanGroupedWithMeteredMinimumPriceTest { .cadence(NewPlanGroupedWithMeteredMinimumPrice.Cadence.ANNUAL) .groupedWithMeteredMinimumConfig( NewPlanGroupedWithMeteredMinimumPrice.GroupedWithMeteredMinimumConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .groupingKey("x") + .minimumUnitAmount("minimum_unit_amount") + .pricingKey("pricing_key") + .addScalingFactor( + NewPlanGroupedWithMeteredMinimumPrice.GroupedWithMeteredMinimumConfig + .ScalingFactor + .builder() + .scalingFactor("scaling_factor") + .scalingValue("scaling_value") + .build() + ) + .scalingKey("scaling_key") + .addUnitAmount( + NewPlanGroupedWithMeteredMinimumPrice.GroupedWithMeteredMinimumConfig + .UnitAmount + .builder() + .pricingValue("pricing_value") + .unitAmount("unit_amount") + .build() + ) .build() ) .itemId("item_id") diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanGroupedWithProratedMinimumPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanGroupedWithProratedMinimumPriceTest.kt index e36cfcbb2..9caace8da 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanGroupedWithProratedMinimumPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanGroupedWithProratedMinimumPriceTest.kt @@ -18,7 +18,9 @@ internal class NewPlanGroupedWithProratedMinimumPriceTest { .groupedWithProratedMinimumConfig( NewPlanGroupedWithProratedMinimumPrice.GroupedWithProratedMinimumConfig .builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .groupingKey("x") + .minimum("minimum") + .unitRate("unit_rate") .build() ) .itemId("item_id") @@ -68,7 +70,9 @@ internal class NewPlanGroupedWithProratedMinimumPriceTest { assertThat(newPlanGroupedWithProratedMinimumPrice.groupedWithProratedMinimumConfig()) .isEqualTo( NewPlanGroupedWithProratedMinimumPrice.GroupedWithProratedMinimumConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .groupingKey("x") + .minimum("minimum") + .unitRate("unit_rate") .build() ) assertThat(newPlanGroupedWithProratedMinimumPrice.itemId()).isEqualTo("item_id") @@ -137,7 +141,9 @@ internal class NewPlanGroupedWithProratedMinimumPriceTest { .groupedWithProratedMinimumConfig( NewPlanGroupedWithProratedMinimumPrice.GroupedWithProratedMinimumConfig .builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .groupingKey("x") + .minimum("minimum") + .unitRate("unit_rate") .build() ) .itemId("item_id") diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanMatrixWithAllocationPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanMatrixWithAllocationPriceTest.kt index e31012642..dfbe75165 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanMatrixWithAllocationPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanMatrixWithAllocationPriceTest.kt @@ -18,11 +18,11 @@ internal class NewPlanMatrixWithAllocationPriceTest { .itemId("item_id") .matrixWithAllocationConfig( MatrixWithAllocationConfig.builder() - .allocation(0.0) + .allocation("allocation") .defaultUnitAmount("default_unit_amount") .addDimension("string") .addMatrixValue( - MatrixValue.builder() + MatrixWithAllocationConfig.MatrixValue.builder() .addDimensionValue("string") .unitAmount("unit_amount") .build() @@ -74,11 +74,11 @@ internal class NewPlanMatrixWithAllocationPriceTest { assertThat(newPlanMatrixWithAllocationPrice.matrixWithAllocationConfig()) .isEqualTo( MatrixWithAllocationConfig.builder() - .allocation(0.0) + .allocation("allocation") .defaultUnitAmount("default_unit_amount") .addDimension("string") .addMatrixValue( - MatrixValue.builder() + MatrixWithAllocationConfig.MatrixValue.builder() .addDimensionValue("string") .unitAmount("unit_amount") .build() @@ -148,11 +148,11 @@ internal class NewPlanMatrixWithAllocationPriceTest { .itemId("item_id") .matrixWithAllocationConfig( MatrixWithAllocationConfig.builder() - .allocation(0.0) + .allocation("allocation") .defaultUnitAmount("default_unit_amount") .addDimension("string") .addMatrixValue( - MatrixValue.builder() + MatrixWithAllocationConfig.MatrixValue.builder() .addDimensionValue("string") .unitAmount("unit_amount") .build() diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanMatrixWithDisplayNamePriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanMatrixWithDisplayNamePriceTest.kt index 310d40633..97c177e28 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanMatrixWithDisplayNamePriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanMatrixWithDisplayNamePriceTest.kt @@ -18,7 +18,15 @@ internal class NewPlanMatrixWithDisplayNamePriceTest { .itemId("item_id") .matrixWithDisplayNameConfig( NewPlanMatrixWithDisplayNamePrice.MatrixWithDisplayNameConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .dimension("dimension") + .addUnitAmount( + NewPlanMatrixWithDisplayNamePrice.MatrixWithDisplayNameConfig.UnitAmount + .builder() + .dimensionValue("dimension_value") + .displayName("display_name") + .unitAmount("unit_amount") + .build() + ) .build() ) .modelType(NewPlanMatrixWithDisplayNamePrice.ModelType.MATRIX_WITH_DISPLAY_NAME) @@ -66,7 +74,15 @@ internal class NewPlanMatrixWithDisplayNamePriceTest { assertThat(newPlanMatrixWithDisplayNamePrice.matrixWithDisplayNameConfig()) .isEqualTo( NewPlanMatrixWithDisplayNamePrice.MatrixWithDisplayNameConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .dimension("dimension") + .addUnitAmount( + NewPlanMatrixWithDisplayNamePrice.MatrixWithDisplayNameConfig.UnitAmount + .builder() + .dimensionValue("dimension_value") + .displayName("display_name") + .unitAmount("unit_amount") + .build() + ) .build() ) assertThat(newPlanMatrixWithDisplayNamePrice.modelType()) @@ -132,7 +148,15 @@ internal class NewPlanMatrixWithDisplayNamePriceTest { .itemId("item_id") .matrixWithDisplayNameConfig( NewPlanMatrixWithDisplayNamePrice.MatrixWithDisplayNameConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .dimension("dimension") + .addUnitAmount( + NewPlanMatrixWithDisplayNamePrice.MatrixWithDisplayNameConfig.UnitAmount + .builder() + .dimensionValue("dimension_value") + .displayName("display_name") + .unitAmount("unit_amount") + .build() + ) .build() ) .modelType(NewPlanMatrixWithDisplayNamePrice.ModelType.MATRIX_WITH_DISPLAY_NAME) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanMaxGroupTieredPackagePriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanMaxGroupTieredPackagePriceTest.kt index a4adeec7c..908236f45 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanMaxGroupTieredPackagePriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanMaxGroupTieredPackagePriceTest.kt @@ -18,7 +18,22 @@ internal class NewPlanMaxGroupTieredPackagePriceTest { .itemId("item_id") .maxGroupTieredPackageConfig( NewPlanMaxGroupTieredPackagePrice.MaxGroupTieredPackageConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .groupingKey("x") + .packageSize("package_size") + .addTier( + NewPlanMaxGroupTieredPackagePrice.MaxGroupTieredPackageConfig.Tier + .builder() + .tierLowerBound("tier_lower_bound") + .unitAmount("unit_amount") + .build() + ) + .addTier( + NewPlanMaxGroupTieredPackagePrice.MaxGroupTieredPackageConfig.Tier + .builder() + .tierLowerBound("tier_lower_bound") + .unitAmount("unit_amount") + .build() + ) .build() ) .modelType(NewPlanMaxGroupTieredPackagePrice.ModelType.MAX_GROUP_TIERED_PACKAGE) @@ -66,7 +81,20 @@ internal class NewPlanMaxGroupTieredPackagePriceTest { assertThat(newPlanMaxGroupTieredPackagePrice.maxGroupTieredPackageConfig()) .isEqualTo( NewPlanMaxGroupTieredPackagePrice.MaxGroupTieredPackageConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .groupingKey("x") + .packageSize("package_size") + .addTier( + NewPlanMaxGroupTieredPackagePrice.MaxGroupTieredPackageConfig.Tier.builder() + .tierLowerBound("tier_lower_bound") + .unitAmount("unit_amount") + .build() + ) + .addTier( + NewPlanMaxGroupTieredPackagePrice.MaxGroupTieredPackageConfig.Tier.builder() + .tierLowerBound("tier_lower_bound") + .unitAmount("unit_amount") + .build() + ) .build() ) assertThat(newPlanMaxGroupTieredPackagePrice.modelType()) @@ -132,7 +160,22 @@ internal class NewPlanMaxGroupTieredPackagePriceTest { .itemId("item_id") .maxGroupTieredPackageConfig( NewPlanMaxGroupTieredPackagePrice.MaxGroupTieredPackageConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .groupingKey("x") + .packageSize("package_size") + .addTier( + NewPlanMaxGroupTieredPackagePrice.MaxGroupTieredPackageConfig.Tier + .builder() + .tierLowerBound("tier_lower_bound") + .unitAmount("unit_amount") + .build() + ) + .addTier( + NewPlanMaxGroupTieredPackagePrice.MaxGroupTieredPackageConfig.Tier + .builder() + .tierLowerBound("tier_lower_bound") + .unitAmount("unit_amount") + .build() + ) .build() ) .modelType(NewPlanMaxGroupTieredPackagePrice.ModelType.MAX_GROUP_TIERED_PACKAGE) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanPackagePriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanPackagePriceTest.kt index a2d8d797c..bf2b79b77 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanPackagePriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanPackagePriceTest.kt @@ -19,7 +19,7 @@ internal class NewPlanPackagePriceTest { .modelType(NewPlanPackagePrice.ModelType.PACKAGE) .name("Annual fee") .packageConfig( - PackageConfig.builder().packageAmount("package_amount").packageSize(0L).build() + PackageConfig.builder().packageAmount("package_amount").packageSize(1L).build() ) .billableMetricId("billable_metric_id") .billedInAdvance(true) @@ -64,7 +64,7 @@ internal class NewPlanPackagePriceTest { assertThat(newPlanPackagePrice.name()).isEqualTo("Annual fee") assertThat(newPlanPackagePrice.packageConfig()) .isEqualTo( - PackageConfig.builder().packageAmount("package_amount").packageSize(0L).build() + PackageConfig.builder().packageAmount("package_amount").packageSize(1L).build() ) assertThat(newPlanPackagePrice.billableMetricId()).isEqualTo("billable_metric_id") assertThat(newPlanPackagePrice.billedInAdvance()).isEqualTo(true) @@ -125,7 +125,7 @@ internal class NewPlanPackagePriceTest { .modelType(NewPlanPackagePrice.ModelType.PACKAGE) .name("Annual fee") .packageConfig( - PackageConfig.builder().packageAmount("package_amount").packageSize(0L).build() + PackageConfig.builder().packageAmount("package_amount").packageSize(1L).build() ) .billableMetricId("billable_metric_id") .billedInAdvance(true) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanPackageWithAllocationPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanPackageWithAllocationPriceTest.kt index df2ec42bf..98a49d888 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanPackageWithAllocationPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanPackageWithAllocationPriceTest.kt @@ -20,7 +20,9 @@ internal class NewPlanPackageWithAllocationPriceTest { .name("Annual fee") .packageWithAllocationConfig( NewPlanPackageWithAllocationPrice.PackageWithAllocationConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .allocation("allocation") + .packageAmount("package_amount") + .packageSize("package_size") .build() ) .billableMetricId("billable_metric_id") @@ -69,7 +71,9 @@ internal class NewPlanPackageWithAllocationPriceTest { assertThat(newPlanPackageWithAllocationPrice.packageWithAllocationConfig()) .isEqualTo( NewPlanPackageWithAllocationPrice.PackageWithAllocationConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .allocation("allocation") + .packageAmount("package_amount") + .packageSize("package_size") .build() ) assertThat(newPlanPackageWithAllocationPrice.billableMetricId()) @@ -134,7 +138,9 @@ internal class NewPlanPackageWithAllocationPriceTest { .name("Annual fee") .packageWithAllocationConfig( NewPlanPackageWithAllocationPrice.PackageWithAllocationConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .allocation("allocation") + .packageAmount("package_amount") + .packageSize("package_size") .build() ) .billableMetricId("billable_metric_id") diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanScalableMatrixWithTieredPricingPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanScalableMatrixWithTieredPricingPriceTest.kt index 005a88a70..6316d5afd 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanScalableMatrixWithTieredPricingPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanScalableMatrixWithTieredPricingPriceTest.kt @@ -25,7 +25,36 @@ internal class NewPlanScalableMatrixWithTieredPricingPriceTest { NewPlanScalableMatrixWithTieredPricingPrice .ScalableMatrixWithTieredPricingConfig .builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .firstDimension("first_dimension") + .addMatrixScalingFactor( + NewPlanScalableMatrixWithTieredPricingPrice + .ScalableMatrixWithTieredPricingConfig + .MatrixScalingFactor + .builder() + .firstDimensionValue("first_dimension_value") + .scalingFactor("scaling_factor") + .secondDimensionValue("second_dimension_value") + .build() + ) + .addTier( + NewPlanScalableMatrixWithTieredPricingPrice + .ScalableMatrixWithTieredPricingConfig + .Tier + .builder() + .tierLowerBound("tier_lower_bound") + .unitAmount("unit_amount") + .build() + ) + .addTier( + NewPlanScalableMatrixWithTieredPricingPrice + .ScalableMatrixWithTieredPricingConfig + .Tier + .builder() + .tierLowerBound("tier_lower_bound") + .unitAmount("unit_amount") + .build() + ) + .secondDimension("second_dimension") .build() ) .billableMetricId("billable_metric_id") @@ -80,7 +109,36 @@ internal class NewPlanScalableMatrixWithTieredPricingPriceTest { .isEqualTo( NewPlanScalableMatrixWithTieredPricingPrice.ScalableMatrixWithTieredPricingConfig .builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .firstDimension("first_dimension") + .addMatrixScalingFactor( + NewPlanScalableMatrixWithTieredPricingPrice + .ScalableMatrixWithTieredPricingConfig + .MatrixScalingFactor + .builder() + .firstDimensionValue("first_dimension_value") + .scalingFactor("scaling_factor") + .secondDimensionValue("second_dimension_value") + .build() + ) + .addTier( + NewPlanScalableMatrixWithTieredPricingPrice + .ScalableMatrixWithTieredPricingConfig + .Tier + .builder() + .tierLowerBound("tier_lower_bound") + .unitAmount("unit_amount") + .build() + ) + .addTier( + NewPlanScalableMatrixWithTieredPricingPrice + .ScalableMatrixWithTieredPricingConfig + .Tier + .builder() + .tierLowerBound("tier_lower_bound") + .unitAmount("unit_amount") + .build() + ) + .secondDimension("second_dimension") .build() ) assertThat(newPlanScalableMatrixWithTieredPricingPrice.billableMetricId()) @@ -151,7 +209,36 @@ internal class NewPlanScalableMatrixWithTieredPricingPriceTest { NewPlanScalableMatrixWithTieredPricingPrice .ScalableMatrixWithTieredPricingConfig .builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .firstDimension("first_dimension") + .addMatrixScalingFactor( + NewPlanScalableMatrixWithTieredPricingPrice + .ScalableMatrixWithTieredPricingConfig + .MatrixScalingFactor + .builder() + .firstDimensionValue("first_dimension_value") + .scalingFactor("scaling_factor") + .secondDimensionValue("second_dimension_value") + .build() + ) + .addTier( + NewPlanScalableMatrixWithTieredPricingPrice + .ScalableMatrixWithTieredPricingConfig + .Tier + .builder() + .tierLowerBound("tier_lower_bound") + .unitAmount("unit_amount") + .build() + ) + .addTier( + NewPlanScalableMatrixWithTieredPricingPrice + .ScalableMatrixWithTieredPricingConfig + .Tier + .builder() + .tierLowerBound("tier_lower_bound") + .unitAmount("unit_amount") + .build() + ) + .secondDimension("second_dimension") .build() ) .billableMetricId("billable_metric_id") diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanScalableMatrixWithUnitPricingPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanScalableMatrixWithUnitPricingPriceTest.kt index a91769877..b6c1600b0 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanScalableMatrixWithUnitPricingPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanScalableMatrixWithUnitPricingPriceTest.kt @@ -24,7 +24,20 @@ internal class NewPlanScalableMatrixWithUnitPricingPriceTest { .scalableMatrixWithUnitPricingConfig( NewPlanScalableMatrixWithUnitPricingPrice.ScalableMatrixWithUnitPricingConfig .builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .firstDimension("first_dimension") + .addMatrixScalingFactor( + NewPlanScalableMatrixWithUnitPricingPrice + .ScalableMatrixWithUnitPricingConfig + .MatrixScalingFactor + .builder() + .firstDimensionValue("first_dimension_value") + .scalingFactor("scaling_factor") + .secondDimensionValue("second_dimension_value") + .build() + ) + .unitPrice("unit_price") + .prorate(true) + .secondDimension("second_dimension") .build() ) .billableMetricId("billable_metric_id") @@ -77,7 +90,20 @@ internal class NewPlanScalableMatrixWithUnitPricingPriceTest { .isEqualTo( NewPlanScalableMatrixWithUnitPricingPrice.ScalableMatrixWithUnitPricingConfig .builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .firstDimension("first_dimension") + .addMatrixScalingFactor( + NewPlanScalableMatrixWithUnitPricingPrice + .ScalableMatrixWithUnitPricingConfig + .MatrixScalingFactor + .builder() + .firstDimensionValue("first_dimension_value") + .scalingFactor("scaling_factor") + .secondDimensionValue("second_dimension_value") + .build() + ) + .unitPrice("unit_price") + .prorate(true) + .secondDimension("second_dimension") .build() ) assertThat(newPlanScalableMatrixWithUnitPricingPrice.billableMetricId()) @@ -147,7 +173,20 @@ internal class NewPlanScalableMatrixWithUnitPricingPriceTest { .scalableMatrixWithUnitPricingConfig( NewPlanScalableMatrixWithUnitPricingPrice.ScalableMatrixWithUnitPricingConfig .builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .firstDimension("first_dimension") + .addMatrixScalingFactor( + NewPlanScalableMatrixWithUnitPricingPrice + .ScalableMatrixWithUnitPricingConfig + .MatrixScalingFactor + .builder() + .firstDimensionValue("first_dimension_value") + .scalingFactor("scaling_factor") + .secondDimensionValue("second_dimension_value") + .build() + ) + .unitPrice("unit_price") + .prorate(true) + .secondDimension("second_dimension") .build() ) .billableMetricId("billable_metric_id") diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanThresholdTotalAmountPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanThresholdTotalAmountPriceTest.kt index 50ae1807f..b0652a089 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanThresholdTotalAmountPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanThresholdTotalAmountPriceTest.kt @@ -20,7 +20,23 @@ internal class NewPlanThresholdTotalAmountPriceTest { .name("Annual fee") .thresholdTotalAmountConfig( NewPlanThresholdTotalAmountPrice.ThresholdTotalAmountConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .addConsumptionTable( + NewPlanThresholdTotalAmountPrice.ThresholdTotalAmountConfig + .ConsumptionTable + .builder() + .threshold("threshold") + .totalAmount("total_amount") + .build() + ) + .addConsumptionTable( + NewPlanThresholdTotalAmountPrice.ThresholdTotalAmountConfig + .ConsumptionTable + .builder() + .threshold("threshold") + .totalAmount("total_amount") + .build() + ) + .prorate(true) .build() ) .billableMetricId("billable_metric_id") @@ -69,7 +85,21 @@ internal class NewPlanThresholdTotalAmountPriceTest { assertThat(newPlanThresholdTotalAmountPrice.thresholdTotalAmountConfig()) .isEqualTo( NewPlanThresholdTotalAmountPrice.ThresholdTotalAmountConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .addConsumptionTable( + NewPlanThresholdTotalAmountPrice.ThresholdTotalAmountConfig.ConsumptionTable + .builder() + .threshold("threshold") + .totalAmount("total_amount") + .build() + ) + .addConsumptionTable( + NewPlanThresholdTotalAmountPrice.ThresholdTotalAmountConfig.ConsumptionTable + .builder() + .threshold("threshold") + .totalAmount("total_amount") + .build() + ) + .prorate(true) .build() ) assertThat(newPlanThresholdTotalAmountPrice.billableMetricId()) @@ -134,7 +164,23 @@ internal class NewPlanThresholdTotalAmountPriceTest { .name("Annual fee") .thresholdTotalAmountConfig( NewPlanThresholdTotalAmountPrice.ThresholdTotalAmountConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .addConsumptionTable( + NewPlanThresholdTotalAmountPrice.ThresholdTotalAmountConfig + .ConsumptionTable + .builder() + .threshold("threshold") + .totalAmount("total_amount") + .build() + ) + .addConsumptionTable( + NewPlanThresholdTotalAmountPrice.ThresholdTotalAmountConfig + .ConsumptionTable + .builder() + .threshold("threshold") + .totalAmount("total_amount") + .build() + ) + .prorate(true) .build() ) .billableMetricId("billable_metric_id") diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanTierWithProrationPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanTierWithProrationPriceTest.kt deleted file mode 100644 index 99ad6c06d..000000000 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanTierWithProrationPriceTest.kt +++ /dev/null @@ -1,184 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.withorb.api.models - -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.withorb.api.core.JsonValue -import com.withorb.api.core.jsonMapper -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class NewPlanTierWithProrationPriceTest { - - @Test - fun create() { - val newPlanTierWithProrationPrice = - NewPlanTierWithProrationPrice.builder() - .cadence(NewPlanTierWithProrationPrice.Cadence.ANNUAL) - .itemId("item_id") - .modelType(NewPlanTierWithProrationPrice.ModelType.TIERED_WITH_PRORATION) - .name("Annual fee") - .tieredWithProrationConfig( - NewPlanTierWithProrationPrice.TieredWithProrationConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .billableMetricId("billable_metric_id") - .billedInAdvance(true) - .billingCycleConfiguration( - NewBillingCycleConfiguration.builder() - .duration(0L) - .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) - .build() - ) - .conversionRate(0.0) - .unitConversionRateConfig( - ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() - ) - .currency("currency") - .dimensionalPriceConfiguration( - NewDimensionalPriceConfiguration.builder() - .addDimensionValue("string") - .dimensionalPriceGroupId("dimensional_price_group_id") - .externalDimensionalPriceGroupId("external_dimensional_price_group_id") - .build() - ) - .externalPriceId("external_price_id") - .fixedPriceQuantity(0.0) - .invoiceGroupingKey("x") - .invoicingCycleConfiguration( - NewBillingCycleConfiguration.builder() - .duration(0L) - .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) - .build() - ) - .metadata( - NewPlanTierWithProrationPrice.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - .referenceId("reference_id") - .build() - - assertThat(newPlanTierWithProrationPrice.cadence()) - .isEqualTo(NewPlanTierWithProrationPrice.Cadence.ANNUAL) - assertThat(newPlanTierWithProrationPrice.itemId()).isEqualTo("item_id") - assertThat(newPlanTierWithProrationPrice.modelType()) - .isEqualTo(NewPlanTierWithProrationPrice.ModelType.TIERED_WITH_PRORATION) - assertThat(newPlanTierWithProrationPrice.name()).isEqualTo("Annual fee") - assertThat(newPlanTierWithProrationPrice.tieredWithProrationConfig()) - .isEqualTo( - NewPlanTierWithProrationPrice.TieredWithProrationConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - assertThat(newPlanTierWithProrationPrice.billableMetricId()).isEqualTo("billable_metric_id") - assertThat(newPlanTierWithProrationPrice.billedInAdvance()).isEqualTo(true) - assertThat(newPlanTierWithProrationPrice.billingCycleConfiguration()) - .isEqualTo( - NewBillingCycleConfiguration.builder() - .duration(0L) - .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) - .build() - ) - assertThat(newPlanTierWithProrationPrice.conversionRate()).isEqualTo(0.0) - assertThat(newPlanTierWithProrationPrice.conversionRateConfig()) - .isEqualTo( - ConversionRateConfig.ofUnit( - UnitConversionRateConfig.builder() - .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) - .unitConfig( - ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() - ) - .build() - ) - ) - assertThat(newPlanTierWithProrationPrice.currency()).isEqualTo("currency") - assertThat(newPlanTierWithProrationPrice.dimensionalPriceConfiguration()) - .isEqualTo( - NewDimensionalPriceConfiguration.builder() - .addDimensionValue("string") - .dimensionalPriceGroupId("dimensional_price_group_id") - .externalDimensionalPriceGroupId("external_dimensional_price_group_id") - .build() - ) - assertThat(newPlanTierWithProrationPrice.externalPriceId()).isEqualTo("external_price_id") - assertThat(newPlanTierWithProrationPrice.fixedPriceQuantity()).isEqualTo(0.0) - assertThat(newPlanTierWithProrationPrice.invoiceGroupingKey()).isEqualTo("x") - assertThat(newPlanTierWithProrationPrice.invoicingCycleConfiguration()) - .isEqualTo( - NewBillingCycleConfiguration.builder() - .duration(0L) - .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) - .build() - ) - assertThat(newPlanTierWithProrationPrice.metadata()) - .isEqualTo( - NewPlanTierWithProrationPrice.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - assertThat(newPlanTierWithProrationPrice.referenceId()).isEqualTo("reference_id") - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val newPlanTierWithProrationPrice = - NewPlanTierWithProrationPrice.builder() - .cadence(NewPlanTierWithProrationPrice.Cadence.ANNUAL) - .itemId("item_id") - .modelType(NewPlanTierWithProrationPrice.ModelType.TIERED_WITH_PRORATION) - .name("Annual fee") - .tieredWithProrationConfig( - NewPlanTierWithProrationPrice.TieredWithProrationConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .billableMetricId("billable_metric_id") - .billedInAdvance(true) - .billingCycleConfiguration( - NewBillingCycleConfiguration.builder() - .duration(0L) - .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) - .build() - ) - .conversionRate(0.0) - .unitConversionRateConfig( - ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() - ) - .currency("currency") - .dimensionalPriceConfiguration( - NewDimensionalPriceConfiguration.builder() - .addDimensionValue("string") - .dimensionalPriceGroupId("dimensional_price_group_id") - .externalDimensionalPriceGroupId("external_dimensional_price_group_id") - .build() - ) - .externalPriceId("external_price_id") - .fixedPriceQuantity(0.0) - .invoiceGroupingKey("x") - .invoicingCycleConfiguration( - NewBillingCycleConfiguration.builder() - .duration(0L) - .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) - .build() - ) - .metadata( - NewPlanTierWithProrationPrice.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - .referenceId("reference_id") - .build() - - val roundtrippedNewPlanTierWithProrationPrice = - jsonMapper.readValue( - jsonMapper.writeValueAsString(newPlanTierWithProrationPrice), - jacksonTypeRef(), - ) - - assertThat(roundtrippedNewPlanTierWithProrationPrice) - .isEqualTo(newPlanTierWithProrationPrice) - } -} diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanTieredPackagePriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanTieredPackagePriceTest.kt index 8afa74012..30bbe4959 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanTieredPackagePriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanTieredPackagePriceTest.kt @@ -20,7 +20,19 @@ internal class NewPlanTieredPackagePriceTest { .name("Annual fee") .tieredPackageConfig( NewPlanTieredPackagePrice.TieredPackageConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .packageSize("package_size") + .addTier( + NewPlanTieredPackagePrice.TieredPackageConfig.Tier.builder() + .perUnit("per_unit") + .tierLowerBound("tier_lower_bound") + .build() + ) + .addTier( + NewPlanTieredPackagePrice.TieredPackageConfig.Tier.builder() + .perUnit("per_unit") + .tierLowerBound("tier_lower_bound") + .build() + ) .build() ) .billableMetricId("billable_metric_id") @@ -69,7 +81,19 @@ internal class NewPlanTieredPackagePriceTest { assertThat(newPlanTieredPackagePrice.tieredPackageConfig()) .isEqualTo( NewPlanTieredPackagePrice.TieredPackageConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .packageSize("package_size") + .addTier( + NewPlanTieredPackagePrice.TieredPackageConfig.Tier.builder() + .perUnit("per_unit") + .tierLowerBound("tier_lower_bound") + .build() + ) + .addTier( + NewPlanTieredPackagePrice.TieredPackageConfig.Tier.builder() + .perUnit("per_unit") + .tierLowerBound("tier_lower_bound") + .build() + ) .build() ) assertThat(newPlanTieredPackagePrice.billableMetricId()).isEqualTo("billable_metric_id") @@ -132,7 +156,19 @@ internal class NewPlanTieredPackagePriceTest { .name("Annual fee") .tieredPackageConfig( NewPlanTieredPackagePrice.TieredPackageConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .packageSize("package_size") + .addTier( + NewPlanTieredPackagePrice.TieredPackageConfig.Tier.builder() + .perUnit("per_unit") + .tierLowerBound("tier_lower_bound") + .build() + ) + .addTier( + NewPlanTieredPackagePrice.TieredPackageConfig.Tier.builder() + .perUnit("per_unit") + .tierLowerBound("tier_lower_bound") + .build() + ) .build() ) .billableMetricId("billable_metric_id") diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanTieredPackageWithMinimumPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanTieredPackageWithMinimumPriceTest.kt index 31154f1f0..73e9780e2 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanTieredPackageWithMinimumPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanTieredPackageWithMinimumPriceTest.kt @@ -22,7 +22,23 @@ internal class NewPlanTieredPackageWithMinimumPriceTest { .name("Annual fee") .tieredPackageWithMinimumConfig( NewPlanTieredPackageWithMinimumPrice.TieredPackageWithMinimumConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .packageSize(0.0) + .addTier( + NewPlanTieredPackageWithMinimumPrice.TieredPackageWithMinimumConfig.Tier + .builder() + .minimumAmount("minimum_amount") + .perUnit("per_unit") + .tierLowerBound("tier_lower_bound") + .build() + ) + .addTier( + NewPlanTieredPackageWithMinimumPrice.TieredPackageWithMinimumConfig.Tier + .builder() + .minimumAmount("minimum_amount") + .perUnit("per_unit") + .tierLowerBound("tier_lower_bound") + .build() + ) .build() ) .billableMetricId("billable_metric_id") @@ -71,7 +87,23 @@ internal class NewPlanTieredPackageWithMinimumPriceTest { assertThat(newPlanTieredPackageWithMinimumPrice.tieredPackageWithMinimumConfig()) .isEqualTo( NewPlanTieredPackageWithMinimumPrice.TieredPackageWithMinimumConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .packageSize(0.0) + .addTier( + NewPlanTieredPackageWithMinimumPrice.TieredPackageWithMinimumConfig.Tier + .builder() + .minimumAmount("minimum_amount") + .perUnit("per_unit") + .tierLowerBound("tier_lower_bound") + .build() + ) + .addTier( + NewPlanTieredPackageWithMinimumPrice.TieredPackageWithMinimumConfig.Tier + .builder() + .minimumAmount("minimum_amount") + .perUnit("per_unit") + .tierLowerBound("tier_lower_bound") + .build() + ) .build() ) assertThat(newPlanTieredPackageWithMinimumPrice.billableMetricId()) @@ -138,7 +170,23 @@ internal class NewPlanTieredPackageWithMinimumPriceTest { .name("Annual fee") .tieredPackageWithMinimumConfig( NewPlanTieredPackageWithMinimumPrice.TieredPackageWithMinimumConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .packageSize(0.0) + .addTier( + NewPlanTieredPackageWithMinimumPrice.TieredPackageWithMinimumConfig.Tier + .builder() + .minimumAmount("minimum_amount") + .perUnit("per_unit") + .tierLowerBound("tier_lower_bound") + .build() + ) + .addTier( + NewPlanTieredPackageWithMinimumPrice.TieredPackageWithMinimumConfig.Tier + .builder() + .minimumAmount("minimum_amount") + .perUnit("per_unit") + .tierLowerBound("tier_lower_bound") + .build() + ) .build() ) .billableMetricId("billable_metric_id") diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanTieredWithMinimumPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanTieredWithMinimumPriceTest.kt index 03317d225..b3e9ee8ea 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanTieredWithMinimumPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanTieredWithMinimumPriceTest.kt @@ -20,7 +20,22 @@ internal class NewPlanTieredWithMinimumPriceTest { .name("Annual fee") .tieredWithMinimumConfig( NewPlanTieredWithMinimumPrice.TieredWithMinimumConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .addTier( + NewPlanTieredWithMinimumPrice.TieredWithMinimumConfig.Tier.builder() + .minimumAmount("minimum_amount") + .tierLowerBound("tier_lower_bound") + .unitAmount("unit_amount") + .build() + ) + .addTier( + NewPlanTieredWithMinimumPrice.TieredWithMinimumConfig.Tier.builder() + .minimumAmount("minimum_amount") + .tierLowerBound("tier_lower_bound") + .unitAmount("unit_amount") + .build() + ) + .hideZeroAmountTiers(true) + .prorate(true) .build() ) .billableMetricId("billable_metric_id") @@ -69,7 +84,22 @@ internal class NewPlanTieredWithMinimumPriceTest { assertThat(newPlanTieredWithMinimumPrice.tieredWithMinimumConfig()) .isEqualTo( NewPlanTieredWithMinimumPrice.TieredWithMinimumConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .addTier( + NewPlanTieredWithMinimumPrice.TieredWithMinimumConfig.Tier.builder() + .minimumAmount("minimum_amount") + .tierLowerBound("tier_lower_bound") + .unitAmount("unit_amount") + .build() + ) + .addTier( + NewPlanTieredWithMinimumPrice.TieredWithMinimumConfig.Tier.builder() + .minimumAmount("minimum_amount") + .tierLowerBound("tier_lower_bound") + .unitAmount("unit_amount") + .build() + ) + .hideZeroAmountTiers(true) + .prorate(true) .build() ) assertThat(newPlanTieredWithMinimumPrice.billableMetricId()).isEqualTo("billable_metric_id") @@ -132,7 +162,22 @@ internal class NewPlanTieredWithMinimumPriceTest { .name("Annual fee") .tieredWithMinimumConfig( NewPlanTieredWithMinimumPrice.TieredWithMinimumConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .addTier( + NewPlanTieredWithMinimumPrice.TieredWithMinimumConfig.Tier.builder() + .minimumAmount("minimum_amount") + .tierLowerBound("tier_lower_bound") + .unitAmount("unit_amount") + .build() + ) + .addTier( + NewPlanTieredWithMinimumPrice.TieredWithMinimumConfig.Tier.builder() + .minimumAmount("minimum_amount") + .tierLowerBound("tier_lower_bound") + .unitAmount("unit_amount") + .build() + ) + .hideZeroAmountTiers(true) + .prorate(true) .build() ) .billableMetricId("billable_metric_id") diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanUnitPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanUnitPriceTest.kt index ba6443d6a..5ffce4a5b 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanUnitPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanUnitPriceTest.kt @@ -18,7 +18,9 @@ internal class NewPlanUnitPriceTest { .itemId("item_id") .modelType(NewPlanUnitPrice.ModelType.UNIT) .name("Annual fee") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder().unitAmount("unit_amount").scalingFactor(0.0).build() + ) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( @@ -61,7 +63,7 @@ internal class NewPlanUnitPriceTest { assertThat(newPlanUnitPrice.modelType()).isEqualTo(NewPlanUnitPrice.ModelType.UNIT) assertThat(newPlanUnitPrice.name()).isEqualTo("Annual fee") assertThat(newPlanUnitPrice.unitConfig()) - .isEqualTo(UnitConfig.builder().unitAmount("unit_amount").build()) + .isEqualTo(UnitConfig.builder().unitAmount("unit_amount").scalingFactor(0.0).build()) assertThat(newPlanUnitPrice.billableMetricId()).isEqualTo("billable_metric_id") assertThat(newPlanUnitPrice.billedInAdvance()).isEqualTo(true) assertThat(newPlanUnitPrice.billingCycleConfiguration()) @@ -120,7 +122,9 @@ internal class NewPlanUnitPriceTest { .itemId("item_id") .modelType(NewPlanUnitPrice.ModelType.UNIT) .name("Annual fee") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder().unitAmount("unit_amount").scalingFactor(0.0).build() + ) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanUnitWithPercentPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanUnitWithPercentPriceTest.kt index 2af2acfb9..87ac558d8 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanUnitWithPercentPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanUnitWithPercentPriceTest.kt @@ -20,7 +20,8 @@ internal class NewPlanUnitWithPercentPriceTest { .name("Annual fee") .unitWithPercentConfig( NewPlanUnitWithPercentPrice.UnitWithPercentConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .percent("percent") + .unitAmount("unit_amount") .build() ) .billableMetricId("billable_metric_id") @@ -69,7 +70,8 @@ internal class NewPlanUnitWithPercentPriceTest { assertThat(newPlanUnitWithPercentPrice.unitWithPercentConfig()) .isEqualTo( NewPlanUnitWithPercentPrice.UnitWithPercentConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .percent("percent") + .unitAmount("unit_amount") .build() ) assertThat(newPlanUnitWithPercentPrice.billableMetricId()).isEqualTo("billable_metric_id") @@ -132,7 +134,8 @@ internal class NewPlanUnitWithPercentPriceTest { .name("Annual fee") .unitWithPercentConfig( NewPlanUnitWithPercentPrice.UnitWithPercentConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .percent("percent") + .unitAmount("unit_amount") .build() ) .billableMetricId("billable_metric_id") diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanUnitWithProrationPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanUnitWithProrationPriceTest.kt index 1f018915c..fe6f859e6 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanUnitWithProrationPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanUnitWithProrationPriceTest.kt @@ -20,7 +20,7 @@ internal class NewPlanUnitWithProrationPriceTest { .name("Annual fee") .unitWithProrationConfig( NewPlanUnitWithProrationPrice.UnitWithProrationConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .unitAmount("unit_amount") .build() ) .billableMetricId("billable_metric_id") @@ -69,7 +69,7 @@ internal class NewPlanUnitWithProrationPriceTest { assertThat(newPlanUnitWithProrationPrice.unitWithProrationConfig()) .isEqualTo( NewPlanUnitWithProrationPrice.UnitWithProrationConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .unitAmount("unit_amount") .build() ) assertThat(newPlanUnitWithProrationPrice.billableMetricId()).isEqualTo("billable_metric_id") @@ -132,7 +132,7 @@ internal class NewPlanUnitWithProrationPriceTest { .name("Annual fee") .unitWithProrationConfig( NewPlanUnitWithProrationPrice.UnitWithProrationConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .unitAmount("unit_amount") .build() ) .billableMetricId("billable_metric_id") diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionBulkWithProrationPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionBulkWithProrationPriceTest.kt index 2fd55e653..db304f963 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionBulkWithProrationPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionBulkWithProrationPriceTest.kt @@ -16,7 +16,20 @@ internal class NewSubscriptionBulkWithProrationPriceTest { NewSubscriptionBulkWithProrationPrice.builder() .bulkWithProrationConfig( NewSubscriptionBulkWithProrationPrice.BulkWithProrationConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .addTier( + NewSubscriptionBulkWithProrationPrice.BulkWithProrationConfig.Tier + .builder() + .unitAmount("unit_amount") + .tierLowerBound("tier_lower_bound") + .build() + ) + .addTier( + NewSubscriptionBulkWithProrationPrice.BulkWithProrationConfig.Tier + .builder() + .unitAmount("unit_amount") + .tierLowerBound("tier_lower_bound") + .build() + ) .build() ) .cadence(NewSubscriptionBulkWithProrationPrice.Cadence.ANNUAL) @@ -63,7 +76,18 @@ internal class NewSubscriptionBulkWithProrationPriceTest { assertThat(newSubscriptionBulkWithProrationPrice.bulkWithProrationConfig()) .isEqualTo( NewSubscriptionBulkWithProrationPrice.BulkWithProrationConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .addTier( + NewSubscriptionBulkWithProrationPrice.BulkWithProrationConfig.Tier.builder() + .unitAmount("unit_amount") + .tierLowerBound("tier_lower_bound") + .build() + ) + .addTier( + NewSubscriptionBulkWithProrationPrice.BulkWithProrationConfig.Tier.builder() + .unitAmount("unit_amount") + .tierLowerBound("tier_lower_bound") + .build() + ) .build() ) assertThat(newSubscriptionBulkWithProrationPrice.cadence()) @@ -130,7 +154,20 @@ internal class NewSubscriptionBulkWithProrationPriceTest { NewSubscriptionBulkWithProrationPrice.builder() .bulkWithProrationConfig( NewSubscriptionBulkWithProrationPrice.BulkWithProrationConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .addTier( + NewSubscriptionBulkWithProrationPrice.BulkWithProrationConfig.Tier + .builder() + .unitAmount("unit_amount") + .tierLowerBound("tier_lower_bound") + .build() + ) + .addTier( + NewSubscriptionBulkWithProrationPrice.BulkWithProrationConfig.Tier + .builder() + .unitAmount("unit_amount") + .tierLowerBound("tier_lower_bound") + .build() + ) .build() ) .cadence(NewSubscriptionBulkWithProrationPrice.Cadence.ANNUAL) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionCumulativeGroupedBulkPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionCumulativeGroupedBulkPriceTest.kt index 77219cf57..34dec871b 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionCumulativeGroupedBulkPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionCumulativeGroupedBulkPriceTest.kt @@ -17,7 +17,16 @@ internal class NewSubscriptionCumulativeGroupedBulkPriceTest { .cadence(NewSubscriptionCumulativeGroupedBulkPrice.Cadence.ANNUAL) .cumulativeGroupedBulkConfig( NewSubscriptionCumulativeGroupedBulkPrice.CumulativeGroupedBulkConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .addDimensionValue( + NewSubscriptionCumulativeGroupedBulkPrice.CumulativeGroupedBulkConfig + .DimensionValue + .builder() + .groupingKey("x") + .tierLowerBound("tier_lower_bound") + .unitAmount("unit_amount") + .build() + ) + .group("group") .build() ) .itemId("item_id") @@ -67,7 +76,16 @@ internal class NewSubscriptionCumulativeGroupedBulkPriceTest { assertThat(newSubscriptionCumulativeGroupedBulkPrice.cumulativeGroupedBulkConfig()) .isEqualTo( NewSubscriptionCumulativeGroupedBulkPrice.CumulativeGroupedBulkConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .addDimensionValue( + NewSubscriptionCumulativeGroupedBulkPrice.CumulativeGroupedBulkConfig + .DimensionValue + .builder() + .groupingKey("x") + .tierLowerBound("tier_lower_bound") + .unitAmount("unit_amount") + .build() + ) + .group("group") .build() ) assertThat(newSubscriptionCumulativeGroupedBulkPrice.itemId()).isEqualTo("item_id") @@ -134,7 +152,16 @@ internal class NewSubscriptionCumulativeGroupedBulkPriceTest { .cadence(NewSubscriptionCumulativeGroupedBulkPrice.Cadence.ANNUAL) .cumulativeGroupedBulkConfig( NewSubscriptionCumulativeGroupedBulkPrice.CumulativeGroupedBulkConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .addDimensionValue( + NewSubscriptionCumulativeGroupedBulkPrice.CumulativeGroupedBulkConfig + .DimensionValue + .builder() + .groupingKey("x") + .tierLowerBound("tier_lower_bound") + .unitAmount("unit_amount") + .build() + ) + .group("group") .build() ) .itemId("item_id") diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionGroupedAllocationPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionGroupedAllocationPriceTest.kt index aaaa79790..0917f44d5 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionGroupedAllocationPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionGroupedAllocationPriceTest.kt @@ -17,7 +17,9 @@ internal class NewSubscriptionGroupedAllocationPriceTest { .cadence(NewSubscriptionGroupedAllocationPrice.Cadence.ANNUAL) .groupedAllocationConfig( NewSubscriptionGroupedAllocationPrice.GroupedAllocationConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .allocation("allocation") + .groupingKey("x") + .overageUnitRate("overage_unit_rate") .build() ) .itemId("item_id") @@ -65,7 +67,9 @@ internal class NewSubscriptionGroupedAllocationPriceTest { assertThat(newSubscriptionGroupedAllocationPrice.groupedAllocationConfig()) .isEqualTo( NewSubscriptionGroupedAllocationPrice.GroupedAllocationConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .allocation("allocation") + .groupingKey("x") + .overageUnitRate("overage_unit_rate") .build() ) assertThat(newSubscriptionGroupedAllocationPrice.itemId()).isEqualTo("item_id") @@ -131,7 +135,9 @@ internal class NewSubscriptionGroupedAllocationPriceTest { .cadence(NewSubscriptionGroupedAllocationPrice.Cadence.ANNUAL) .groupedAllocationConfig( NewSubscriptionGroupedAllocationPrice.GroupedAllocationConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .allocation("allocation") + .groupingKey("x") + .overageUnitRate("overage_unit_rate") .build() ) .itemId("item_id") diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionGroupedTieredPackagePriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionGroupedTieredPackagePriceTest.kt index aa4f448e7..ddf18d03a 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionGroupedTieredPackagePriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionGroupedTieredPackagePriceTest.kt @@ -17,7 +17,22 @@ internal class NewSubscriptionGroupedTieredPackagePriceTest { .cadence(NewSubscriptionGroupedTieredPackagePrice.Cadence.ANNUAL) .groupedTieredPackageConfig( NewSubscriptionGroupedTieredPackagePrice.GroupedTieredPackageConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .groupingKey("x") + .packageSize("package_size") + .addTier( + NewSubscriptionGroupedTieredPackagePrice.GroupedTieredPackageConfig.Tier + .builder() + .perUnit("per_unit") + .tierLowerBound("tier_lower_bound") + .build() + ) + .addTier( + NewSubscriptionGroupedTieredPackagePrice.GroupedTieredPackageConfig.Tier + .builder() + .perUnit("per_unit") + .tierLowerBound("tier_lower_bound") + .build() + ) .build() ) .itemId("item_id") @@ -67,7 +82,22 @@ internal class NewSubscriptionGroupedTieredPackagePriceTest { assertThat(newSubscriptionGroupedTieredPackagePrice.groupedTieredPackageConfig()) .isEqualTo( NewSubscriptionGroupedTieredPackagePrice.GroupedTieredPackageConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .groupingKey("x") + .packageSize("package_size") + .addTier( + NewSubscriptionGroupedTieredPackagePrice.GroupedTieredPackageConfig.Tier + .builder() + .perUnit("per_unit") + .tierLowerBound("tier_lower_bound") + .build() + ) + .addTier( + NewSubscriptionGroupedTieredPackagePrice.GroupedTieredPackageConfig.Tier + .builder() + .perUnit("per_unit") + .tierLowerBound("tier_lower_bound") + .build() + ) .build() ) assertThat(newSubscriptionGroupedTieredPackagePrice.itemId()).isEqualTo("item_id") @@ -133,7 +163,22 @@ internal class NewSubscriptionGroupedTieredPackagePriceTest { .cadence(NewSubscriptionGroupedTieredPackagePrice.Cadence.ANNUAL) .groupedTieredPackageConfig( NewSubscriptionGroupedTieredPackagePrice.GroupedTieredPackageConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .groupingKey("x") + .packageSize("package_size") + .addTier( + NewSubscriptionGroupedTieredPackagePrice.GroupedTieredPackageConfig.Tier + .builder() + .perUnit("per_unit") + .tierLowerBound("tier_lower_bound") + .build() + ) + .addTier( + NewSubscriptionGroupedTieredPackagePrice.GroupedTieredPackageConfig.Tier + .builder() + .perUnit("per_unit") + .tierLowerBound("tier_lower_bound") + .build() + ) .build() ) .itemId("item_id") diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionGroupedTieredPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionGroupedTieredPriceTest.kt index 7d31e884e..c587b8e07 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionGroupedTieredPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionGroupedTieredPriceTest.kt @@ -17,7 +17,19 @@ internal class NewSubscriptionGroupedTieredPriceTest { .cadence(NewSubscriptionGroupedTieredPrice.Cadence.ANNUAL) .groupedTieredConfig( NewSubscriptionGroupedTieredPrice.GroupedTieredConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .groupingKey("x") + .addTier( + NewSubscriptionGroupedTieredPrice.GroupedTieredConfig.Tier.builder() + .tierLowerBound("tier_lower_bound") + .unitAmount("unit_amount") + .build() + ) + .addTier( + NewSubscriptionGroupedTieredPrice.GroupedTieredConfig.Tier.builder() + .tierLowerBound("tier_lower_bound") + .unitAmount("unit_amount") + .build() + ) .build() ) .itemId("item_id") @@ -65,7 +77,19 @@ internal class NewSubscriptionGroupedTieredPriceTest { assertThat(newSubscriptionGroupedTieredPrice.groupedTieredConfig()) .isEqualTo( NewSubscriptionGroupedTieredPrice.GroupedTieredConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .groupingKey("x") + .addTier( + NewSubscriptionGroupedTieredPrice.GroupedTieredConfig.Tier.builder() + .tierLowerBound("tier_lower_bound") + .unitAmount("unit_amount") + .build() + ) + .addTier( + NewSubscriptionGroupedTieredPrice.GroupedTieredConfig.Tier.builder() + .tierLowerBound("tier_lower_bound") + .unitAmount("unit_amount") + .build() + ) .build() ) assertThat(newSubscriptionGroupedTieredPrice.itemId()).isEqualTo("item_id") @@ -131,7 +155,19 @@ internal class NewSubscriptionGroupedTieredPriceTest { .cadence(NewSubscriptionGroupedTieredPrice.Cadence.ANNUAL) .groupedTieredConfig( NewSubscriptionGroupedTieredPrice.GroupedTieredConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .groupingKey("x") + .addTier( + NewSubscriptionGroupedTieredPrice.GroupedTieredConfig.Tier.builder() + .tierLowerBound("tier_lower_bound") + .unitAmount("unit_amount") + .build() + ) + .addTier( + NewSubscriptionGroupedTieredPrice.GroupedTieredConfig.Tier.builder() + .tierLowerBound("tier_lower_bound") + .unitAmount("unit_amount") + .build() + ) .build() ) .itemId("item_id") diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionGroupedWithMeteredMinimumPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionGroupedWithMeteredMinimumPriceTest.kt index f465f4cb0..ad2499640 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionGroupedWithMeteredMinimumPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionGroupedWithMeteredMinimumPriceTest.kt @@ -18,7 +18,28 @@ internal class NewSubscriptionGroupedWithMeteredMinimumPriceTest { .groupedWithMeteredMinimumConfig( NewSubscriptionGroupedWithMeteredMinimumPrice.GroupedWithMeteredMinimumConfig .builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .groupingKey("x") + .minimumUnitAmount("minimum_unit_amount") + .pricingKey("pricing_key") + .addScalingFactor( + NewSubscriptionGroupedWithMeteredMinimumPrice + .GroupedWithMeteredMinimumConfig + .ScalingFactor + .builder() + .scalingFactor("scaling_factor") + .scalingValue("scaling_value") + .build() + ) + .scalingKey("scaling_key") + .addUnitAmount( + NewSubscriptionGroupedWithMeteredMinimumPrice + .GroupedWithMeteredMinimumConfig + .UnitAmount + .builder() + .pricingValue("pricing_value") + .unitAmount("unit_amount") + .build() + ) .build() ) .itemId("item_id") @@ -70,7 +91,28 @@ internal class NewSubscriptionGroupedWithMeteredMinimumPriceTest { .isEqualTo( NewSubscriptionGroupedWithMeteredMinimumPrice.GroupedWithMeteredMinimumConfig .builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .groupingKey("x") + .minimumUnitAmount("minimum_unit_amount") + .pricingKey("pricing_key") + .addScalingFactor( + NewSubscriptionGroupedWithMeteredMinimumPrice + .GroupedWithMeteredMinimumConfig + .ScalingFactor + .builder() + .scalingFactor("scaling_factor") + .scalingValue("scaling_value") + .build() + ) + .scalingKey("scaling_key") + .addUnitAmount( + NewSubscriptionGroupedWithMeteredMinimumPrice + .GroupedWithMeteredMinimumConfig + .UnitAmount + .builder() + .pricingValue("pricing_value") + .unitAmount("unit_amount") + .build() + ) .build() ) assertThat(newSubscriptionGroupedWithMeteredMinimumPrice.itemId()).isEqualTo("item_id") @@ -142,7 +184,28 @@ internal class NewSubscriptionGroupedWithMeteredMinimumPriceTest { .groupedWithMeteredMinimumConfig( NewSubscriptionGroupedWithMeteredMinimumPrice.GroupedWithMeteredMinimumConfig .builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .groupingKey("x") + .minimumUnitAmount("minimum_unit_amount") + .pricingKey("pricing_key") + .addScalingFactor( + NewSubscriptionGroupedWithMeteredMinimumPrice + .GroupedWithMeteredMinimumConfig + .ScalingFactor + .builder() + .scalingFactor("scaling_factor") + .scalingValue("scaling_value") + .build() + ) + .scalingKey("scaling_key") + .addUnitAmount( + NewSubscriptionGroupedWithMeteredMinimumPrice + .GroupedWithMeteredMinimumConfig + .UnitAmount + .builder() + .pricingValue("pricing_value") + .unitAmount("unit_amount") + .build() + ) .build() ) .itemId("item_id") diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionGroupedWithProratedMinimumPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionGroupedWithProratedMinimumPriceTest.kt index 3eae9f908..08a681998 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionGroupedWithProratedMinimumPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionGroupedWithProratedMinimumPriceTest.kt @@ -18,7 +18,9 @@ internal class NewSubscriptionGroupedWithProratedMinimumPriceTest { .groupedWithProratedMinimumConfig( NewSubscriptionGroupedWithProratedMinimumPrice.GroupedWithProratedMinimumConfig .builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .groupingKey("x") + .minimum("minimum") + .unitRate("unit_rate") .build() ) .itemId("item_id") @@ -72,7 +74,9 @@ internal class NewSubscriptionGroupedWithProratedMinimumPriceTest { .isEqualTo( NewSubscriptionGroupedWithProratedMinimumPrice.GroupedWithProratedMinimumConfig .builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .groupingKey("x") + .minimum("minimum") + .unitRate("unit_rate") .build() ) assertThat(newSubscriptionGroupedWithProratedMinimumPrice.itemId()).isEqualTo("item_id") @@ -145,7 +149,9 @@ internal class NewSubscriptionGroupedWithProratedMinimumPriceTest { .groupedWithProratedMinimumConfig( NewSubscriptionGroupedWithProratedMinimumPrice.GroupedWithProratedMinimumConfig .builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .groupingKey("x") + .minimum("minimum") + .unitRate("unit_rate") .build() ) .itemId("item_id") diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionMatrixWithAllocationPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionMatrixWithAllocationPriceTest.kt index f249a99f0..500e0edf8 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionMatrixWithAllocationPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionMatrixWithAllocationPriceTest.kt @@ -18,11 +18,11 @@ internal class NewSubscriptionMatrixWithAllocationPriceTest { .itemId("item_id") .matrixWithAllocationConfig( MatrixWithAllocationConfig.builder() - .allocation(0.0) + .allocation("allocation") .defaultUnitAmount("default_unit_amount") .addDimension("string") .addMatrixValue( - MatrixValue.builder() + MatrixWithAllocationConfig.MatrixValue.builder() .addDimensionValue("string") .unitAmount("unit_amount") .build() @@ -76,11 +76,11 @@ internal class NewSubscriptionMatrixWithAllocationPriceTest { assertThat(newSubscriptionMatrixWithAllocationPrice.matrixWithAllocationConfig()) .isEqualTo( MatrixWithAllocationConfig.builder() - .allocation(0.0) + .allocation("allocation") .defaultUnitAmount("default_unit_amount") .addDimension("string") .addMatrixValue( - MatrixValue.builder() + MatrixWithAllocationConfig.MatrixValue.builder() .addDimensionValue("string") .unitAmount("unit_amount") .build() @@ -150,11 +150,11 @@ internal class NewSubscriptionMatrixWithAllocationPriceTest { .itemId("item_id") .matrixWithAllocationConfig( MatrixWithAllocationConfig.builder() - .allocation(0.0) + .allocation("allocation") .defaultUnitAmount("default_unit_amount") .addDimension("string") .addMatrixValue( - MatrixValue.builder() + MatrixWithAllocationConfig.MatrixValue.builder() .addDimensionValue("string") .unitAmount("unit_amount") .build() diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionMatrixWithDisplayNamePriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionMatrixWithDisplayNamePriceTest.kt index 8ce5ca5f6..22e5656f9 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionMatrixWithDisplayNamePriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionMatrixWithDisplayNamePriceTest.kt @@ -18,7 +18,16 @@ internal class NewSubscriptionMatrixWithDisplayNamePriceTest { .itemId("item_id") .matrixWithDisplayNameConfig( NewSubscriptionMatrixWithDisplayNamePrice.MatrixWithDisplayNameConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .dimension("dimension") + .addUnitAmount( + NewSubscriptionMatrixWithDisplayNamePrice.MatrixWithDisplayNameConfig + .UnitAmount + .builder() + .dimensionValue("dimension_value") + .displayName("display_name") + .unitAmount("unit_amount") + .build() + ) .build() ) .modelType( @@ -68,7 +77,16 @@ internal class NewSubscriptionMatrixWithDisplayNamePriceTest { assertThat(newSubscriptionMatrixWithDisplayNamePrice.matrixWithDisplayNameConfig()) .isEqualTo( NewSubscriptionMatrixWithDisplayNamePrice.MatrixWithDisplayNameConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .dimension("dimension") + .addUnitAmount( + NewSubscriptionMatrixWithDisplayNamePrice.MatrixWithDisplayNameConfig + .UnitAmount + .builder() + .dimensionValue("dimension_value") + .displayName("display_name") + .unitAmount("unit_amount") + .build() + ) .build() ) assertThat(newSubscriptionMatrixWithDisplayNamePrice.modelType()) @@ -135,7 +153,16 @@ internal class NewSubscriptionMatrixWithDisplayNamePriceTest { .itemId("item_id") .matrixWithDisplayNameConfig( NewSubscriptionMatrixWithDisplayNamePrice.MatrixWithDisplayNameConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .dimension("dimension") + .addUnitAmount( + NewSubscriptionMatrixWithDisplayNamePrice.MatrixWithDisplayNameConfig + .UnitAmount + .builder() + .dimensionValue("dimension_value") + .displayName("display_name") + .unitAmount("unit_amount") + .build() + ) .build() ) .modelType( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionMaxGroupTieredPackagePriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionMaxGroupTieredPackagePriceTest.kt index f36b33ed9..f5ed48d10 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionMaxGroupTieredPackagePriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionMaxGroupTieredPackagePriceTest.kt @@ -18,7 +18,24 @@ internal class NewSubscriptionMaxGroupTieredPackagePriceTest { .itemId("item_id") .maxGroupTieredPackageConfig( NewSubscriptionMaxGroupTieredPackagePrice.MaxGroupTieredPackageConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .groupingKey("x") + .packageSize("package_size") + .addTier( + NewSubscriptionMaxGroupTieredPackagePrice.MaxGroupTieredPackageConfig + .Tier + .builder() + .tierLowerBound("tier_lower_bound") + .unitAmount("unit_amount") + .build() + ) + .addTier( + NewSubscriptionMaxGroupTieredPackagePrice.MaxGroupTieredPackageConfig + .Tier + .builder() + .tierLowerBound("tier_lower_bound") + .unitAmount("unit_amount") + .build() + ) .build() ) .modelType( @@ -68,7 +85,22 @@ internal class NewSubscriptionMaxGroupTieredPackagePriceTest { assertThat(newSubscriptionMaxGroupTieredPackagePrice.maxGroupTieredPackageConfig()) .isEqualTo( NewSubscriptionMaxGroupTieredPackagePrice.MaxGroupTieredPackageConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .groupingKey("x") + .packageSize("package_size") + .addTier( + NewSubscriptionMaxGroupTieredPackagePrice.MaxGroupTieredPackageConfig.Tier + .builder() + .tierLowerBound("tier_lower_bound") + .unitAmount("unit_amount") + .build() + ) + .addTier( + NewSubscriptionMaxGroupTieredPackagePrice.MaxGroupTieredPackageConfig.Tier + .builder() + .tierLowerBound("tier_lower_bound") + .unitAmount("unit_amount") + .build() + ) .build() ) assertThat(newSubscriptionMaxGroupTieredPackagePrice.modelType()) @@ -135,7 +167,24 @@ internal class NewSubscriptionMaxGroupTieredPackagePriceTest { .itemId("item_id") .maxGroupTieredPackageConfig( NewSubscriptionMaxGroupTieredPackagePrice.MaxGroupTieredPackageConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .groupingKey("x") + .packageSize("package_size") + .addTier( + NewSubscriptionMaxGroupTieredPackagePrice.MaxGroupTieredPackageConfig + .Tier + .builder() + .tierLowerBound("tier_lower_bound") + .unitAmount("unit_amount") + .build() + ) + .addTier( + NewSubscriptionMaxGroupTieredPackagePrice.MaxGroupTieredPackageConfig + .Tier + .builder() + .tierLowerBound("tier_lower_bound") + .unitAmount("unit_amount") + .build() + ) .build() ) .modelType( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionPackagePriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionPackagePriceTest.kt index f3d9051f2..89db836da 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionPackagePriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionPackagePriceTest.kt @@ -19,7 +19,7 @@ internal class NewSubscriptionPackagePriceTest { .modelType(NewSubscriptionPackagePrice.ModelType.PACKAGE) .name("Annual fee") .packageConfig( - PackageConfig.builder().packageAmount("package_amount").packageSize(0L).build() + PackageConfig.builder().packageAmount("package_amount").packageSize(1L).build() ) .billableMetricId("billable_metric_id") .billedInAdvance(true) @@ -66,7 +66,7 @@ internal class NewSubscriptionPackagePriceTest { assertThat(newSubscriptionPackagePrice.name()).isEqualTo("Annual fee") assertThat(newSubscriptionPackagePrice.packageConfig()) .isEqualTo( - PackageConfig.builder().packageAmount("package_amount").packageSize(0L).build() + PackageConfig.builder().packageAmount("package_amount").packageSize(1L).build() ) assertThat(newSubscriptionPackagePrice.billableMetricId()).isEqualTo("billable_metric_id") assertThat(newSubscriptionPackagePrice.billedInAdvance()).isEqualTo(true) @@ -127,7 +127,7 @@ internal class NewSubscriptionPackagePriceTest { .modelType(NewSubscriptionPackagePrice.ModelType.PACKAGE) .name("Annual fee") .packageConfig( - PackageConfig.builder().packageAmount("package_amount").packageSize(0L).build() + PackageConfig.builder().packageAmount("package_amount").packageSize(1L).build() ) .billableMetricId("billable_metric_id") .billedInAdvance(true) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionPackageWithAllocationPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionPackageWithAllocationPriceTest.kt index 3c37f47eb..fd0a8c31a 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionPackageWithAllocationPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionPackageWithAllocationPriceTest.kt @@ -22,7 +22,9 @@ internal class NewSubscriptionPackageWithAllocationPriceTest { .name("Annual fee") .packageWithAllocationConfig( NewSubscriptionPackageWithAllocationPrice.PackageWithAllocationConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .allocation("allocation") + .packageAmount("package_amount") + .packageSize("package_size") .build() ) .billableMetricId("billable_metric_id") @@ -71,7 +73,9 @@ internal class NewSubscriptionPackageWithAllocationPriceTest { assertThat(newSubscriptionPackageWithAllocationPrice.packageWithAllocationConfig()) .isEqualTo( NewSubscriptionPackageWithAllocationPrice.PackageWithAllocationConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .allocation("allocation") + .packageAmount("package_amount") + .packageSize("package_size") .build() ) assertThat(newSubscriptionPackageWithAllocationPrice.billableMetricId()) @@ -139,7 +143,9 @@ internal class NewSubscriptionPackageWithAllocationPriceTest { .name("Annual fee") .packageWithAllocationConfig( NewSubscriptionPackageWithAllocationPrice.PackageWithAllocationConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .allocation("allocation") + .packageAmount("package_amount") + .packageSize("package_size") .build() ) .billableMetricId("billable_metric_id") diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionScalableMatrixWithTieredPricingPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionScalableMatrixWithTieredPricingPriceTest.kt index bc283c763..d18079001 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionScalableMatrixWithTieredPricingPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionScalableMatrixWithTieredPricingPriceTest.kt @@ -25,7 +25,36 @@ internal class NewSubscriptionScalableMatrixWithTieredPricingPriceTest { NewSubscriptionScalableMatrixWithTieredPricingPrice .ScalableMatrixWithTieredPricingConfig .builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .firstDimension("first_dimension") + .addMatrixScalingFactor( + NewSubscriptionScalableMatrixWithTieredPricingPrice + .ScalableMatrixWithTieredPricingConfig + .MatrixScalingFactor + .builder() + .firstDimensionValue("first_dimension_value") + .scalingFactor("scaling_factor") + .secondDimensionValue("second_dimension_value") + .build() + ) + .addTier( + NewSubscriptionScalableMatrixWithTieredPricingPrice + .ScalableMatrixWithTieredPricingConfig + .Tier + .builder() + .tierLowerBound("tier_lower_bound") + .unitAmount("unit_amount") + .build() + ) + .addTier( + NewSubscriptionScalableMatrixWithTieredPricingPrice + .ScalableMatrixWithTieredPricingConfig + .Tier + .builder() + .tierLowerBound("tier_lower_bound") + .unitAmount("unit_amount") + .build() + ) + .secondDimension("second_dimension") .build() ) .billableMetricId("billable_metric_id") @@ -84,7 +113,36 @@ internal class NewSubscriptionScalableMatrixWithTieredPricingPriceTest { NewSubscriptionScalableMatrixWithTieredPricingPrice .ScalableMatrixWithTieredPricingConfig .builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .firstDimension("first_dimension") + .addMatrixScalingFactor( + NewSubscriptionScalableMatrixWithTieredPricingPrice + .ScalableMatrixWithTieredPricingConfig + .MatrixScalingFactor + .builder() + .firstDimensionValue("first_dimension_value") + .scalingFactor("scaling_factor") + .secondDimensionValue("second_dimension_value") + .build() + ) + .addTier( + NewSubscriptionScalableMatrixWithTieredPricingPrice + .ScalableMatrixWithTieredPricingConfig + .Tier + .builder() + .tierLowerBound("tier_lower_bound") + .unitAmount("unit_amount") + .build() + ) + .addTier( + NewSubscriptionScalableMatrixWithTieredPricingPrice + .ScalableMatrixWithTieredPricingConfig + .Tier + .builder() + .tierLowerBound("tier_lower_bound") + .unitAmount("unit_amount") + .build() + ) + .secondDimension("second_dimension") .build() ) assertThat(newSubscriptionScalableMatrixWithTieredPricingPrice.billableMetricId()) @@ -164,7 +222,36 @@ internal class NewSubscriptionScalableMatrixWithTieredPricingPriceTest { NewSubscriptionScalableMatrixWithTieredPricingPrice .ScalableMatrixWithTieredPricingConfig .builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .firstDimension("first_dimension") + .addMatrixScalingFactor( + NewSubscriptionScalableMatrixWithTieredPricingPrice + .ScalableMatrixWithTieredPricingConfig + .MatrixScalingFactor + .builder() + .firstDimensionValue("first_dimension_value") + .scalingFactor("scaling_factor") + .secondDimensionValue("second_dimension_value") + .build() + ) + .addTier( + NewSubscriptionScalableMatrixWithTieredPricingPrice + .ScalableMatrixWithTieredPricingConfig + .Tier + .builder() + .tierLowerBound("tier_lower_bound") + .unitAmount("unit_amount") + .build() + ) + .addTier( + NewSubscriptionScalableMatrixWithTieredPricingPrice + .ScalableMatrixWithTieredPricingConfig + .Tier + .builder() + .tierLowerBound("tier_lower_bound") + .unitAmount("unit_amount") + .build() + ) + .secondDimension("second_dimension") .build() ) .billableMetricId("billable_metric_id") diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionScalableMatrixWithUnitPricingPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionScalableMatrixWithUnitPricingPriceTest.kt index c9f70db92..88521ee0c 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionScalableMatrixWithUnitPricingPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionScalableMatrixWithUnitPricingPriceTest.kt @@ -25,7 +25,20 @@ internal class NewSubscriptionScalableMatrixWithUnitPricingPriceTest { NewSubscriptionScalableMatrixWithUnitPricingPrice .ScalableMatrixWithUnitPricingConfig .builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .firstDimension("first_dimension") + .addMatrixScalingFactor( + NewSubscriptionScalableMatrixWithUnitPricingPrice + .ScalableMatrixWithUnitPricingConfig + .MatrixScalingFactor + .builder() + .firstDimensionValue("first_dimension_value") + .scalingFactor("scaling_factor") + .secondDimensionValue("second_dimension_value") + .build() + ) + .unitPrice("unit_price") + .prorate(true) + .secondDimension("second_dimension") .build() ) .billableMetricId("billable_metric_id") @@ -82,7 +95,20 @@ internal class NewSubscriptionScalableMatrixWithUnitPricingPriceTest { NewSubscriptionScalableMatrixWithUnitPricingPrice .ScalableMatrixWithUnitPricingConfig .builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .firstDimension("first_dimension") + .addMatrixScalingFactor( + NewSubscriptionScalableMatrixWithUnitPricingPrice + .ScalableMatrixWithUnitPricingConfig + .MatrixScalingFactor + .builder() + .firstDimensionValue("first_dimension_value") + .scalingFactor("scaling_factor") + .secondDimensionValue("second_dimension_value") + .build() + ) + .unitPrice("unit_price") + .prorate(true) + .secondDimension("second_dimension") .build() ) assertThat(newSubscriptionScalableMatrixWithUnitPricingPrice.billableMetricId()) @@ -160,7 +186,20 @@ internal class NewSubscriptionScalableMatrixWithUnitPricingPriceTest { NewSubscriptionScalableMatrixWithUnitPricingPrice .ScalableMatrixWithUnitPricingConfig .builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .firstDimension("first_dimension") + .addMatrixScalingFactor( + NewSubscriptionScalableMatrixWithUnitPricingPrice + .ScalableMatrixWithUnitPricingConfig + .MatrixScalingFactor + .builder() + .firstDimensionValue("first_dimension_value") + .scalingFactor("scaling_factor") + .secondDimensionValue("second_dimension_value") + .build() + ) + .unitPrice("unit_price") + .prorate(true) + .secondDimension("second_dimension") .build() ) .billableMetricId("billable_metric_id") diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionThresholdTotalAmountPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionThresholdTotalAmountPriceTest.kt index 1efd55765..420a96ce9 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionThresholdTotalAmountPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionThresholdTotalAmountPriceTest.kt @@ -22,7 +22,23 @@ internal class NewSubscriptionThresholdTotalAmountPriceTest { .name("Annual fee") .thresholdTotalAmountConfig( NewSubscriptionThresholdTotalAmountPrice.ThresholdTotalAmountConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .addConsumptionTable( + NewSubscriptionThresholdTotalAmountPrice.ThresholdTotalAmountConfig + .ConsumptionTable + .builder() + .threshold("threshold") + .totalAmount("total_amount") + .build() + ) + .addConsumptionTable( + NewSubscriptionThresholdTotalAmountPrice.ThresholdTotalAmountConfig + .ConsumptionTable + .builder() + .threshold("threshold") + .totalAmount("total_amount") + .build() + ) + .prorate(true) .build() ) .billableMetricId("billable_metric_id") @@ -71,7 +87,23 @@ internal class NewSubscriptionThresholdTotalAmountPriceTest { assertThat(newSubscriptionThresholdTotalAmountPrice.thresholdTotalAmountConfig()) .isEqualTo( NewSubscriptionThresholdTotalAmountPrice.ThresholdTotalAmountConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .addConsumptionTable( + NewSubscriptionThresholdTotalAmountPrice.ThresholdTotalAmountConfig + .ConsumptionTable + .builder() + .threshold("threshold") + .totalAmount("total_amount") + .build() + ) + .addConsumptionTable( + NewSubscriptionThresholdTotalAmountPrice.ThresholdTotalAmountConfig + .ConsumptionTable + .builder() + .threshold("threshold") + .totalAmount("total_amount") + .build() + ) + .prorate(true) .build() ) assertThat(newSubscriptionThresholdTotalAmountPrice.billableMetricId()) @@ -138,7 +170,23 @@ internal class NewSubscriptionThresholdTotalAmountPriceTest { .name("Annual fee") .thresholdTotalAmountConfig( NewSubscriptionThresholdTotalAmountPrice.ThresholdTotalAmountConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .addConsumptionTable( + NewSubscriptionThresholdTotalAmountPrice.ThresholdTotalAmountConfig + .ConsumptionTable + .builder() + .threshold("threshold") + .totalAmount("total_amount") + .build() + ) + .addConsumptionTable( + NewSubscriptionThresholdTotalAmountPrice.ThresholdTotalAmountConfig + .ConsumptionTable + .builder() + .threshold("threshold") + .totalAmount("total_amount") + .build() + ) + .prorate(true) .build() ) .billableMetricId("billable_metric_id") diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionTierWithProrationPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionTierWithProrationPriceTest.kt deleted file mode 100644 index e79ecec2e..000000000 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionTierWithProrationPriceTest.kt +++ /dev/null @@ -1,186 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.withorb.api.models - -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.withorb.api.core.JsonValue -import com.withorb.api.core.jsonMapper -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class NewSubscriptionTierWithProrationPriceTest { - - @Test - fun create() { - val newSubscriptionTierWithProrationPrice = - NewSubscriptionTierWithProrationPrice.builder() - .cadence(NewSubscriptionTierWithProrationPrice.Cadence.ANNUAL) - .itemId("item_id") - .modelType(NewSubscriptionTierWithProrationPrice.ModelType.TIERED_WITH_PRORATION) - .name("Annual fee") - .tieredWithProrationConfig( - NewSubscriptionTierWithProrationPrice.TieredWithProrationConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .billableMetricId("billable_metric_id") - .billedInAdvance(true) - .billingCycleConfiguration( - NewBillingCycleConfiguration.builder() - .duration(0L) - .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) - .build() - ) - .conversionRate(0.0) - .unitConversionRateConfig( - ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() - ) - .currency("currency") - .dimensionalPriceConfiguration( - NewDimensionalPriceConfiguration.builder() - .addDimensionValue("string") - .dimensionalPriceGroupId("dimensional_price_group_id") - .externalDimensionalPriceGroupId("external_dimensional_price_group_id") - .build() - ) - .externalPriceId("external_price_id") - .fixedPriceQuantity(0.0) - .invoiceGroupingKey("x") - .invoicingCycleConfiguration( - NewBillingCycleConfiguration.builder() - .duration(0L) - .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) - .build() - ) - .metadata( - NewSubscriptionTierWithProrationPrice.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - .referenceId("reference_id") - .build() - - assertThat(newSubscriptionTierWithProrationPrice.cadence()) - .isEqualTo(NewSubscriptionTierWithProrationPrice.Cadence.ANNUAL) - assertThat(newSubscriptionTierWithProrationPrice.itemId()).isEqualTo("item_id") - assertThat(newSubscriptionTierWithProrationPrice.modelType()) - .isEqualTo(NewSubscriptionTierWithProrationPrice.ModelType.TIERED_WITH_PRORATION) - assertThat(newSubscriptionTierWithProrationPrice.name()).isEqualTo("Annual fee") - assertThat(newSubscriptionTierWithProrationPrice.tieredWithProrationConfig()) - .isEqualTo( - NewSubscriptionTierWithProrationPrice.TieredWithProrationConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - assertThat(newSubscriptionTierWithProrationPrice.billableMetricId()) - .isEqualTo("billable_metric_id") - assertThat(newSubscriptionTierWithProrationPrice.billedInAdvance()).isEqualTo(true) - assertThat(newSubscriptionTierWithProrationPrice.billingCycleConfiguration()) - .isEqualTo( - NewBillingCycleConfiguration.builder() - .duration(0L) - .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) - .build() - ) - assertThat(newSubscriptionTierWithProrationPrice.conversionRate()).isEqualTo(0.0) - assertThat(newSubscriptionTierWithProrationPrice.conversionRateConfig()) - .isEqualTo( - ConversionRateConfig.ofUnit( - UnitConversionRateConfig.builder() - .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) - .unitConfig( - ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() - ) - .build() - ) - ) - assertThat(newSubscriptionTierWithProrationPrice.currency()).isEqualTo("currency") - assertThat(newSubscriptionTierWithProrationPrice.dimensionalPriceConfiguration()) - .isEqualTo( - NewDimensionalPriceConfiguration.builder() - .addDimensionValue("string") - .dimensionalPriceGroupId("dimensional_price_group_id") - .externalDimensionalPriceGroupId("external_dimensional_price_group_id") - .build() - ) - assertThat(newSubscriptionTierWithProrationPrice.externalPriceId()) - .isEqualTo("external_price_id") - assertThat(newSubscriptionTierWithProrationPrice.fixedPriceQuantity()).isEqualTo(0.0) - assertThat(newSubscriptionTierWithProrationPrice.invoiceGroupingKey()).isEqualTo("x") - assertThat(newSubscriptionTierWithProrationPrice.invoicingCycleConfiguration()) - .isEqualTo( - NewBillingCycleConfiguration.builder() - .duration(0L) - .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) - .build() - ) - assertThat(newSubscriptionTierWithProrationPrice.metadata()) - .isEqualTo( - NewSubscriptionTierWithProrationPrice.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - assertThat(newSubscriptionTierWithProrationPrice.referenceId()).isEqualTo("reference_id") - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val newSubscriptionTierWithProrationPrice = - NewSubscriptionTierWithProrationPrice.builder() - .cadence(NewSubscriptionTierWithProrationPrice.Cadence.ANNUAL) - .itemId("item_id") - .modelType(NewSubscriptionTierWithProrationPrice.ModelType.TIERED_WITH_PRORATION) - .name("Annual fee") - .tieredWithProrationConfig( - NewSubscriptionTierWithProrationPrice.TieredWithProrationConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .billableMetricId("billable_metric_id") - .billedInAdvance(true) - .billingCycleConfiguration( - NewBillingCycleConfiguration.builder() - .duration(0L) - .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) - .build() - ) - .conversionRate(0.0) - .unitConversionRateConfig( - ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() - ) - .currency("currency") - .dimensionalPriceConfiguration( - NewDimensionalPriceConfiguration.builder() - .addDimensionValue("string") - .dimensionalPriceGroupId("dimensional_price_group_id") - .externalDimensionalPriceGroupId("external_dimensional_price_group_id") - .build() - ) - .externalPriceId("external_price_id") - .fixedPriceQuantity(0.0) - .invoiceGroupingKey("x") - .invoicingCycleConfiguration( - NewBillingCycleConfiguration.builder() - .duration(0L) - .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) - .build() - ) - .metadata( - NewSubscriptionTierWithProrationPrice.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - .referenceId("reference_id") - .build() - - val roundtrippedNewSubscriptionTierWithProrationPrice = - jsonMapper.readValue( - jsonMapper.writeValueAsString(newSubscriptionTierWithProrationPrice), - jacksonTypeRef(), - ) - - assertThat(roundtrippedNewSubscriptionTierWithProrationPrice) - .isEqualTo(newSubscriptionTierWithProrationPrice) - } -} diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionTieredPackagePriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionTieredPackagePriceTest.kt index 3ba77b0a3..ea2ffaee5 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionTieredPackagePriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionTieredPackagePriceTest.kt @@ -20,7 +20,19 @@ internal class NewSubscriptionTieredPackagePriceTest { .name("Annual fee") .tieredPackageConfig( NewSubscriptionTieredPackagePrice.TieredPackageConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .packageSize("package_size") + .addTier( + NewSubscriptionTieredPackagePrice.TieredPackageConfig.Tier.builder() + .perUnit("per_unit") + .tierLowerBound("tier_lower_bound") + .build() + ) + .addTier( + NewSubscriptionTieredPackagePrice.TieredPackageConfig.Tier.builder() + .perUnit("per_unit") + .tierLowerBound("tier_lower_bound") + .build() + ) .build() ) .billableMetricId("billable_metric_id") @@ -69,7 +81,19 @@ internal class NewSubscriptionTieredPackagePriceTest { assertThat(newSubscriptionTieredPackagePrice.tieredPackageConfig()) .isEqualTo( NewSubscriptionTieredPackagePrice.TieredPackageConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .packageSize("package_size") + .addTier( + NewSubscriptionTieredPackagePrice.TieredPackageConfig.Tier.builder() + .perUnit("per_unit") + .tierLowerBound("tier_lower_bound") + .build() + ) + .addTier( + NewSubscriptionTieredPackagePrice.TieredPackageConfig.Tier.builder() + .perUnit("per_unit") + .tierLowerBound("tier_lower_bound") + .build() + ) .build() ) assertThat(newSubscriptionTieredPackagePrice.billableMetricId()) @@ -134,7 +158,19 @@ internal class NewSubscriptionTieredPackagePriceTest { .name("Annual fee") .tieredPackageConfig( NewSubscriptionTieredPackagePrice.TieredPackageConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .packageSize("package_size") + .addTier( + NewSubscriptionTieredPackagePrice.TieredPackageConfig.Tier.builder() + .perUnit("per_unit") + .tierLowerBound("tier_lower_bound") + .build() + ) + .addTier( + NewSubscriptionTieredPackagePrice.TieredPackageConfig.Tier.builder() + .perUnit("per_unit") + .tierLowerBound("tier_lower_bound") + .build() + ) .build() ) .billableMetricId("billable_metric_id") diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionTieredPackageWithMinimumPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionTieredPackageWithMinimumPriceTest.kt index 4f5c3525a..5c439c752 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionTieredPackageWithMinimumPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionTieredPackageWithMinimumPriceTest.kt @@ -24,7 +24,27 @@ internal class NewSubscriptionTieredPackageWithMinimumPriceTest { .tieredPackageWithMinimumConfig( NewSubscriptionTieredPackageWithMinimumPrice.TieredPackageWithMinimumConfig .builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .packageSize(0.0) + .addTier( + NewSubscriptionTieredPackageWithMinimumPrice + .TieredPackageWithMinimumConfig + .Tier + .builder() + .minimumAmount("minimum_amount") + .perUnit("per_unit") + .tierLowerBound("tier_lower_bound") + .build() + ) + .addTier( + NewSubscriptionTieredPackageWithMinimumPrice + .TieredPackageWithMinimumConfig + .Tier + .builder() + .minimumAmount("minimum_amount") + .perUnit("per_unit") + .tierLowerBound("tier_lower_bound") + .build() + ) .build() ) .billableMetricId("billable_metric_id") @@ -76,7 +96,25 @@ internal class NewSubscriptionTieredPackageWithMinimumPriceTest { .isEqualTo( NewSubscriptionTieredPackageWithMinimumPrice.TieredPackageWithMinimumConfig .builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .packageSize(0.0) + .addTier( + NewSubscriptionTieredPackageWithMinimumPrice.TieredPackageWithMinimumConfig + .Tier + .builder() + .minimumAmount("minimum_amount") + .perUnit("per_unit") + .tierLowerBound("tier_lower_bound") + .build() + ) + .addTier( + NewSubscriptionTieredPackageWithMinimumPrice.TieredPackageWithMinimumConfig + .Tier + .builder() + .minimumAmount("minimum_amount") + .perUnit("per_unit") + .tierLowerBound("tier_lower_bound") + .build() + ) .build() ) assertThat(newSubscriptionTieredPackageWithMinimumPrice.billableMetricId()) @@ -146,7 +184,27 @@ internal class NewSubscriptionTieredPackageWithMinimumPriceTest { .tieredPackageWithMinimumConfig( NewSubscriptionTieredPackageWithMinimumPrice.TieredPackageWithMinimumConfig .builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .packageSize(0.0) + .addTier( + NewSubscriptionTieredPackageWithMinimumPrice + .TieredPackageWithMinimumConfig + .Tier + .builder() + .minimumAmount("minimum_amount") + .perUnit("per_unit") + .tierLowerBound("tier_lower_bound") + .build() + ) + .addTier( + NewSubscriptionTieredPackageWithMinimumPrice + .TieredPackageWithMinimumConfig + .Tier + .builder() + .minimumAmount("minimum_amount") + .perUnit("per_unit") + .tierLowerBound("tier_lower_bound") + .build() + ) .build() ) .billableMetricId("billable_metric_id") diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionTieredWithMinimumPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionTieredWithMinimumPriceTest.kt index 31d129161..90bdb5722 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionTieredWithMinimumPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionTieredWithMinimumPriceTest.kt @@ -20,7 +20,24 @@ internal class NewSubscriptionTieredWithMinimumPriceTest { .name("Annual fee") .tieredWithMinimumConfig( NewSubscriptionTieredWithMinimumPrice.TieredWithMinimumConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .addTier( + NewSubscriptionTieredWithMinimumPrice.TieredWithMinimumConfig.Tier + .builder() + .minimumAmount("minimum_amount") + .tierLowerBound("tier_lower_bound") + .unitAmount("unit_amount") + .build() + ) + .addTier( + NewSubscriptionTieredWithMinimumPrice.TieredWithMinimumConfig.Tier + .builder() + .minimumAmount("minimum_amount") + .tierLowerBound("tier_lower_bound") + .unitAmount("unit_amount") + .build() + ) + .hideZeroAmountTiers(true) + .prorate(true) .build() ) .billableMetricId("billable_metric_id") @@ -69,7 +86,22 @@ internal class NewSubscriptionTieredWithMinimumPriceTest { assertThat(newSubscriptionTieredWithMinimumPrice.tieredWithMinimumConfig()) .isEqualTo( NewSubscriptionTieredWithMinimumPrice.TieredWithMinimumConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .addTier( + NewSubscriptionTieredWithMinimumPrice.TieredWithMinimumConfig.Tier.builder() + .minimumAmount("minimum_amount") + .tierLowerBound("tier_lower_bound") + .unitAmount("unit_amount") + .build() + ) + .addTier( + NewSubscriptionTieredWithMinimumPrice.TieredWithMinimumConfig.Tier.builder() + .minimumAmount("minimum_amount") + .tierLowerBound("tier_lower_bound") + .unitAmount("unit_amount") + .build() + ) + .hideZeroAmountTiers(true) + .prorate(true) .build() ) assertThat(newSubscriptionTieredWithMinimumPrice.billableMetricId()) @@ -134,7 +166,24 @@ internal class NewSubscriptionTieredWithMinimumPriceTest { .name("Annual fee") .tieredWithMinimumConfig( NewSubscriptionTieredWithMinimumPrice.TieredWithMinimumConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .addTier( + NewSubscriptionTieredWithMinimumPrice.TieredWithMinimumConfig.Tier + .builder() + .minimumAmount("minimum_amount") + .tierLowerBound("tier_lower_bound") + .unitAmount("unit_amount") + .build() + ) + .addTier( + NewSubscriptionTieredWithMinimumPrice.TieredWithMinimumConfig.Tier + .builder() + .minimumAmount("minimum_amount") + .tierLowerBound("tier_lower_bound") + .unitAmount("unit_amount") + .build() + ) + .hideZeroAmountTiers(true) + .prorate(true) .build() ) .billableMetricId("billable_metric_id") diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionUnitPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionUnitPriceTest.kt index 8d1121afc..d6af88ef3 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionUnitPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionUnitPriceTest.kt @@ -18,7 +18,9 @@ internal class NewSubscriptionUnitPriceTest { .itemId("item_id") .modelType(NewSubscriptionUnitPrice.ModelType.UNIT) .name("Annual fee") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder().unitAmount("unit_amount").scalingFactor(0.0).build() + ) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( @@ -63,7 +65,7 @@ internal class NewSubscriptionUnitPriceTest { .isEqualTo(NewSubscriptionUnitPrice.ModelType.UNIT) assertThat(newSubscriptionUnitPrice.name()).isEqualTo("Annual fee") assertThat(newSubscriptionUnitPrice.unitConfig()) - .isEqualTo(UnitConfig.builder().unitAmount("unit_amount").build()) + .isEqualTo(UnitConfig.builder().unitAmount("unit_amount").scalingFactor(0.0).build()) assertThat(newSubscriptionUnitPrice.billableMetricId()).isEqualTo("billable_metric_id") assertThat(newSubscriptionUnitPrice.billedInAdvance()).isEqualTo(true) assertThat(newSubscriptionUnitPrice.billingCycleConfiguration()) @@ -122,7 +124,9 @@ internal class NewSubscriptionUnitPriceTest { .itemId("item_id") .modelType(NewSubscriptionUnitPrice.ModelType.UNIT) .name("Annual fee") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder().unitAmount("unit_amount").scalingFactor(0.0).build() + ) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionUnitWithPercentPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionUnitWithPercentPriceTest.kt index 300e7a20d..7b99e00b2 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionUnitWithPercentPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionUnitWithPercentPriceTest.kt @@ -20,7 +20,8 @@ internal class NewSubscriptionUnitWithPercentPriceTest { .name("Annual fee") .unitWithPercentConfig( NewSubscriptionUnitWithPercentPrice.UnitWithPercentConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .percent("percent") + .unitAmount("unit_amount") .build() ) .billableMetricId("billable_metric_id") @@ -69,7 +70,8 @@ internal class NewSubscriptionUnitWithPercentPriceTest { assertThat(newSubscriptionUnitWithPercentPrice.unitWithPercentConfig()) .isEqualTo( NewSubscriptionUnitWithPercentPrice.UnitWithPercentConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .percent("percent") + .unitAmount("unit_amount") .build() ) assertThat(newSubscriptionUnitWithPercentPrice.billableMetricId()) @@ -134,7 +136,8 @@ internal class NewSubscriptionUnitWithPercentPriceTest { .name("Annual fee") .unitWithPercentConfig( NewSubscriptionUnitWithPercentPrice.UnitWithPercentConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .percent("percent") + .unitAmount("unit_amount") .build() ) .billableMetricId("billable_metric_id") diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionUnitWithProrationPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionUnitWithProrationPriceTest.kt index a92b95bb2..9922c5992 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionUnitWithProrationPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionUnitWithProrationPriceTest.kt @@ -20,7 +20,7 @@ internal class NewSubscriptionUnitWithProrationPriceTest { .name("Annual fee") .unitWithProrationConfig( NewSubscriptionUnitWithProrationPrice.UnitWithProrationConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .unitAmount("unit_amount") .build() ) .billableMetricId("billable_metric_id") @@ -69,7 +69,7 @@ internal class NewSubscriptionUnitWithProrationPriceTest { assertThat(newSubscriptionUnitWithProrationPrice.unitWithProrationConfig()) .isEqualTo( NewSubscriptionUnitWithProrationPrice.UnitWithProrationConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .unitAmount("unit_amount") .build() ) assertThat(newSubscriptionUnitWithProrationPrice.billableMetricId()) @@ -134,7 +134,7 @@ internal class NewSubscriptionUnitWithProrationPriceTest { .name("Annual fee") .unitWithProrationConfig( NewSubscriptionUnitWithProrationPrice.UnitWithProrationConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .unitAmount("unit_amount") .build() ) .billableMetricId("billable_metric_id") diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PackageConfigTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PackageConfigTest.kt index 9a21cd29a..e615c4bdc 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PackageConfigTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PackageConfigTest.kt @@ -12,17 +12,17 @@ internal class PackageConfigTest { @Test fun create() { val packageConfig = - PackageConfig.builder().packageAmount("package_amount").packageSize(0L).build() + PackageConfig.builder().packageAmount("package_amount").packageSize(1L).build() assertThat(packageConfig.packageAmount()).isEqualTo("package_amount") - assertThat(packageConfig.packageSize()).isEqualTo(0L) + assertThat(packageConfig.packageSize()).isEqualTo(1L) } @Test fun roundtrip() { val jsonMapper = jsonMapper() val packageConfig = - PackageConfig.builder().packageAmount("package_amount").packageSize(0L).build() + PackageConfig.builder().packageAmount("package_amount").packageSize(1L).build() val roundtrippedPackageConfig = jsonMapper.readValue( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PerPriceCostTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PerPriceCostTest.kt index 119a6eca6..88343781f 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PerPriceCostTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PerPriceCostTest.kt @@ -113,7 +113,12 @@ internal class PerPriceCostTest { .planPhaseOrder(0L) .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .scalingFactor(0.0) + .build() + ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") @@ -228,7 +233,12 @@ internal class PerPriceCostTest { .planPhaseOrder(0L) .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .scalingFactor(0.0) + .build() + ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") @@ -347,7 +357,12 @@ internal class PerPriceCostTest { .planPhaseOrder(0L) .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .scalingFactor(0.0) + .build() + ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanCreateParamsTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanCreateParamsTest.kt index a10615880..d9434d3e0 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanCreateParamsTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanCreateParamsTest.kt @@ -36,7 +36,12 @@ internal class PlanCreateParamsTest { .itemId("item_id") .modelType(NewPlanUnitPrice.ModelType.UNIT) .name("Annual fee") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .scalingFactor(0.0) + .build() + ) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( @@ -155,7 +160,12 @@ internal class PlanCreateParamsTest { .itemId("item_id") .modelType(NewPlanUnitPrice.ModelType.UNIT) .name("Annual fee") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .scalingFactor(0.0) + .build() + ) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( @@ -274,7 +284,12 @@ internal class PlanCreateParamsTest { .itemId("item_id") .modelType(NewPlanUnitPrice.ModelType.UNIT) .name("Annual fee") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .scalingFactor(0.0) + .build() + ) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanListPageResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanListPageResponseTest.kt index c79c68717..76d819dc5 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanListPageResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanListPageResponseTest.kt @@ -258,7 +258,12 @@ internal class PlanListPageResponseTest { .planPhaseOrder(0L) .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .scalingFactor(0.0) + .build() + ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") @@ -531,7 +536,12 @@ internal class PlanListPageResponseTest { .planPhaseOrder(0L) .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .scalingFactor(0.0) + .build() + ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") @@ -809,7 +819,12 @@ internal class PlanListPageResponseTest { .planPhaseOrder(0L) .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .scalingFactor(0.0) + .build() + ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanTest.kt index ad947c798..5a81695fb 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanTest.kt @@ -254,7 +254,12 @@ internal class PlanTest { .planPhaseOrder(0L) .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .scalingFactor(0.0) + .build() + ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") @@ -532,7 +537,12 @@ internal class PlanTest { .planPhaseOrder(0L) .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .scalingFactor(0.0) + .build() + ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") @@ -805,7 +815,12 @@ internal class PlanTest { .planPhaseOrder(0L) .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .scalingFactor(0.0) + .build() + ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanVersionTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanVersionTest.kt index 78b6080c2..783944ed4 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanVersionTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanVersionTest.kt @@ -145,7 +145,12 @@ internal class PlanVersionTest { .planPhaseOrder(0L) .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .scalingFactor(0.0) + .build() + ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") @@ -294,7 +299,12 @@ internal class PlanVersionTest { .planPhaseOrder(0L) .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .scalingFactor(0.0) + .build() + ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") @@ -442,7 +452,12 @@ internal class PlanVersionTest { .planPhaseOrder(0L) .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .scalingFactor(0.0) + .build() + ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceCreateParamsTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceCreateParamsTest.kt index 8b457c08d..cc0038547 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceCreateParamsTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceCreateParamsTest.kt @@ -18,7 +18,9 @@ internal class PriceCreateParamsTest { .itemId("item_id") .modelType(NewFloatingUnitPrice.ModelType.UNIT) .name("Annual fee") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder().unitAmount("unit_amount").scalingFactor(0.0).build() + ) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( @@ -68,7 +70,12 @@ internal class PriceCreateParamsTest { .itemId("item_id") .modelType(NewFloatingUnitPrice.ModelType.UNIT) .name("Annual fee") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .scalingFactor(0.0) + .build() + ) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( @@ -119,7 +126,12 @@ internal class PriceCreateParamsTest { .itemId("item_id") .modelType(NewFloatingUnitPrice.ModelType.UNIT) .name("Annual fee") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .scalingFactor(0.0) + .build() + ) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceEvaluateMultipleParamsTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceEvaluateMultipleParamsTest.kt index 0b559e17e..52abfbd7b 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceEvaluateMultipleParamsTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceEvaluateMultipleParamsTest.kt @@ -28,7 +28,12 @@ internal class PriceEvaluateMultipleParamsTest { .itemId("item_id") .modelType(NewFloatingUnitPrice.ModelType.UNIT) .name("Annual fee") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .scalingFactor(0.0) + .build() + ) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( @@ -92,7 +97,12 @@ internal class PriceEvaluateMultipleParamsTest { .itemId("item_id") .modelType(NewFloatingUnitPrice.ModelType.UNIT) .name("Annual fee") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .scalingFactor(0.0) + .build() + ) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( @@ -157,7 +167,12 @@ internal class PriceEvaluateMultipleParamsTest { .itemId("item_id") .modelType(NewFloatingUnitPrice.ModelType.UNIT) .name("Annual fee") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .scalingFactor(0.0) + .build() + ) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceEvaluatePreviewEventsParamsTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceEvaluatePreviewEventsParamsTest.kt index 0dff1be2a..64b03261b 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceEvaluatePreviewEventsParamsTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceEvaluatePreviewEventsParamsTest.kt @@ -41,7 +41,12 @@ internal class PriceEvaluatePreviewEventsParamsTest { .itemId("item_id") .modelType(NewFloatingUnitPrice.ModelType.UNIT) .name("Annual fee") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .scalingFactor(0.0) + .build() + ) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( @@ -118,7 +123,12 @@ internal class PriceEvaluatePreviewEventsParamsTest { .itemId("item_id") .modelType(NewFloatingUnitPrice.ModelType.UNIT) .name("Annual fee") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .scalingFactor(0.0) + .build() + ) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( @@ -197,7 +207,12 @@ internal class PriceEvaluatePreviewEventsParamsTest { .itemId("item_id") .modelType(NewFloatingUnitPrice.ModelType.UNIT) .name("Annual fee") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .scalingFactor(0.0) + .build() + ) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceIntervalTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceIntervalTest.kt index 809d3e08f..7400228b9 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceIntervalTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceIntervalTest.kt @@ -126,7 +126,12 @@ internal class PriceIntervalTest { .planPhaseOrder(0L) .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .scalingFactor(0.0) + .build() + ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") @@ -256,7 +261,12 @@ internal class PriceIntervalTest { .planPhaseOrder(0L) .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .scalingFactor(0.0) + .build() + ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") @@ -387,7 +397,12 @@ internal class PriceIntervalTest { .planPhaseOrder(0L) .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .scalingFactor(0.0) + .build() + ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceListPageResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceListPageResponseTest.kt index 6d692d39a..d3e712a46 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceListPageResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceListPageResponseTest.kt @@ -113,7 +113,12 @@ internal class PriceListPageResponseTest { .planPhaseOrder(0L) .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .scalingFactor(0.0) + .build() + ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") @@ -227,7 +232,12 @@ internal class PriceListPageResponseTest { .planPhaseOrder(0L) .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .scalingFactor(0.0) + .build() + ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") @@ -344,7 +354,12 @@ internal class PriceListPageResponseTest { .planPhaseOrder(0L) .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .scalingFactor(0.0) + .build() + ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceTest.kt index fc86fda89..da134e6f5 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceTest.kt @@ -115,7 +115,9 @@ internal class PriceTest { .planPhaseOrder(0L) .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder().unitAmount("unit_amount").scalingFactor(0.0).build() + ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") @@ -127,14 +129,14 @@ internal class PriceTest { val price = Price.ofUnit(unit) assertThat(price.unit()).isEqualTo(unit) - assertThat(price.package_()).isNull() - assertThat(price.matrix()).isNull() assertThat(price.tiered()).isNull() assertThat(price.bulk()).isNull() + assertThat(price.package_()).isNull() + assertThat(price.matrix()).isNull() assertThat(price.thresholdTotalAmount()).isNull() assertThat(price.tieredPackage()).isNull() - assertThat(price.groupedTiered()).isNull() assertThat(price.tieredWithMinimum()).isNull() + assertThat(price.groupedTiered()).isNull() assertThat(price.tieredPackageWithMinimum()).isNull() assertThat(price.packageWithAllocation()).isNull() assertThat(price.unitWithPercent()).isNull() @@ -142,16 +144,16 @@ internal class PriceTest { assertThat(price.tieredWithProration()).isNull() assertThat(price.unitWithProration()).isNull() assertThat(price.groupedAllocation()).isNull() + assertThat(price.bulkWithProration()).isNull() assertThat(price.groupedWithProratedMinimum()).isNull() assertThat(price.groupedWithMeteredMinimum()).isNull() + assertThat(price.groupedWithMinMaxThresholds()).isNull() assertThat(price.matrixWithDisplayName()).isNull() - assertThat(price.bulkWithProration()).isNull() assertThat(price.groupedTieredPackage()).isNull() assertThat(price.maxGroupTieredPackage()).isNull() assertThat(price.scalableMatrixWithUnitPricing()).isNull() assertThat(price.scalableMatrixWithTieredPricing()).isNull() assertThat(price.cumulativeGroupedBulk()).isNull() - assertThat(price.groupedWithMinMaxThresholds()).isNull() assertThat(price.minimum()).isNull() } @@ -257,7 +259,9 @@ internal class PriceTest { .planPhaseOrder(0L) .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder().unitAmount("unit_amount").scalingFactor(0.0).build() + ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") @@ -274,9 +278,9 @@ internal class PriceTest { } @Test - fun ofPackage() { - val package_ = - Price.Package.builder() + fun ofTiered() { + val tiered = + Price.Tiered.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -285,7 +289,7 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .cadence(Price.Package.Cadence.ONE_TIME) + .cadence(Price.Tiered.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() .field(TransformPriceFilter.Field.PRICE_ID) @@ -351,7 +355,7 @@ internal class PriceTest { ) .maximumAmount("maximum_amount") .metadata( - Price.Package.Metadata.builder() + Price.Tiered.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -370,12 +374,20 @@ internal class PriceTest { ) .minimumAmount("minimum_amount") .name("name") - .packageConfig( - PackageConfig.builder().packageAmount("package_amount").packageSize(0L).build() - ) .planPhaseOrder(0L) - .priceType(Price.Package.PriceType.USAGE_PRICE) + .priceType(Price.Tiered.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") + .tieredConfig( + TieredConfig.builder() + .addTier( + Tier.builder() + .firstUnit(0.0) + .unitAmount("unit_amount") + .lastUnit(0.0) + .build() + ) + .build() + ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") @@ -384,17 +396,17 @@ internal class PriceTest { ) .build() - val price = Price.ofPackage(package_) + val price = Price.ofTiered(tiered) assertThat(price.unit()).isNull() - assertThat(price.package_()).isEqualTo(package_) - assertThat(price.matrix()).isNull() - assertThat(price.tiered()).isNull() + assertThat(price.tiered()).isEqualTo(tiered) assertThat(price.bulk()).isNull() + assertThat(price.package_()).isNull() + assertThat(price.matrix()).isNull() assertThat(price.thresholdTotalAmount()).isNull() assertThat(price.tieredPackage()).isNull() - assertThat(price.groupedTiered()).isNull() assertThat(price.tieredWithMinimum()).isNull() + assertThat(price.groupedTiered()).isNull() assertThat(price.tieredPackageWithMinimum()).isNull() assertThat(price.packageWithAllocation()).isNull() assertThat(price.unitWithPercent()).isNull() @@ -402,25 +414,25 @@ internal class PriceTest { assertThat(price.tieredWithProration()).isNull() assertThat(price.unitWithProration()).isNull() assertThat(price.groupedAllocation()).isNull() + assertThat(price.bulkWithProration()).isNull() assertThat(price.groupedWithProratedMinimum()).isNull() assertThat(price.groupedWithMeteredMinimum()).isNull() + assertThat(price.groupedWithMinMaxThresholds()).isNull() assertThat(price.matrixWithDisplayName()).isNull() - assertThat(price.bulkWithProration()).isNull() assertThat(price.groupedTieredPackage()).isNull() assertThat(price.maxGroupTieredPackage()).isNull() assertThat(price.scalableMatrixWithUnitPricing()).isNull() assertThat(price.scalableMatrixWithTieredPricing()).isNull() assertThat(price.cumulativeGroupedBulk()).isNull() - assertThat(price.groupedWithMinMaxThresholds()).isNull() assertThat(price.minimum()).isNull() } @Test - fun ofPackageRoundtrip() { + fun ofTieredRoundtrip() { val jsonMapper = jsonMapper() val price = - Price.ofPackage( - Price.Package.builder() + Price.ofTiered( + Price.Tiered.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -429,7 +441,7 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .cadence(Price.Package.Cadence.ONE_TIME) + .cadence(Price.Tiered.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() .field(TransformPriceFilter.Field.PRICE_ID) @@ -495,7 +507,7 @@ internal class PriceTest { ) .maximumAmount("maximum_amount") .metadata( - Price.Package.Metadata.builder() + Price.Tiered.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -514,15 +526,20 @@ internal class PriceTest { ) .minimumAmount("minimum_amount") .name("name") - .packageConfig( - PackageConfig.builder() - .packageAmount("package_amount") - .packageSize(0L) - .build() - ) .planPhaseOrder(0L) - .priceType(Price.Package.PriceType.USAGE_PRICE) + .priceType(Price.Tiered.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") + .tieredConfig( + TieredConfig.builder() + .addTier( + Tier.builder() + .firstUnit(0.0) + .unitAmount("unit_amount") + .lastUnit(0.0) + .build() + ) + .build() + ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") @@ -539,9 +556,9 @@ internal class PriceTest { } @Test - fun ofMatrix() { - val matrix = - Price.Matrix.builder() + fun ofBulk() { + val bulk = + Price.Bulk.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -550,7 +567,14 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .cadence(Price.Matrix.Cadence.ONE_TIME) + .bulkConfig( + BulkConfig.builder() + .addTier( + BulkTier.builder().unitAmount("unit_amount").maximumUnits(0.0).build() + ) + .build() + ) + .cadence(Price.Bulk.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() .field(TransformPriceFilter.Field.PRICE_ID) @@ -601,18 +625,6 @@ internal class PriceTest { .build() ) .item(ItemSlim.builder().id("id").name("name").build()) - .matrixConfig( - MatrixConfig.builder() - .defaultUnitAmount("default_unit_amount") - .addDimension("string") - .addMatrixValue( - MatrixValue.builder() - .addDimensionValue("string") - .unitAmount("unit_amount") - .build() - ) - .build() - ) .maximum( Maximum.builder() .addAppliesToPriceId("string") @@ -628,7 +640,7 @@ internal class PriceTest { ) .maximumAmount("maximum_amount") .metadata( - Price.Matrix.Metadata.builder() + Price.Bulk.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -648,7 +660,7 @@ internal class PriceTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.Matrix.PriceType.USAGE_PRICE) + .priceType(Price.Bulk.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -658,17 +670,17 @@ internal class PriceTest { ) .build() - val price = Price.ofMatrix(matrix) + val price = Price.ofBulk(bulk) assertThat(price.unit()).isNull() - assertThat(price.package_()).isNull() - assertThat(price.matrix()).isEqualTo(matrix) assertThat(price.tiered()).isNull() - assertThat(price.bulk()).isNull() + assertThat(price.bulk()).isEqualTo(bulk) + assertThat(price.package_()).isNull() + assertThat(price.matrix()).isNull() assertThat(price.thresholdTotalAmount()).isNull() assertThat(price.tieredPackage()).isNull() - assertThat(price.groupedTiered()).isNull() assertThat(price.tieredWithMinimum()).isNull() + assertThat(price.groupedTiered()).isNull() assertThat(price.tieredPackageWithMinimum()).isNull() assertThat(price.packageWithAllocation()).isNull() assertThat(price.unitWithPercent()).isNull() @@ -676,25 +688,25 @@ internal class PriceTest { assertThat(price.tieredWithProration()).isNull() assertThat(price.unitWithProration()).isNull() assertThat(price.groupedAllocation()).isNull() + assertThat(price.bulkWithProration()).isNull() assertThat(price.groupedWithProratedMinimum()).isNull() assertThat(price.groupedWithMeteredMinimum()).isNull() + assertThat(price.groupedWithMinMaxThresholds()).isNull() assertThat(price.matrixWithDisplayName()).isNull() - assertThat(price.bulkWithProration()).isNull() assertThat(price.groupedTieredPackage()).isNull() assertThat(price.maxGroupTieredPackage()).isNull() assertThat(price.scalableMatrixWithUnitPricing()).isNull() assertThat(price.scalableMatrixWithTieredPricing()).isNull() assertThat(price.cumulativeGroupedBulk()).isNull() - assertThat(price.groupedWithMinMaxThresholds()).isNull() assertThat(price.minimum()).isNull() } @Test - fun ofMatrixRoundtrip() { + fun ofBulkRoundtrip() { val jsonMapper = jsonMapper() val price = - Price.ofMatrix( - Price.Matrix.builder() + Price.ofBulk( + Price.Bulk.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -703,7 +715,17 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .cadence(Price.Matrix.Cadence.ONE_TIME) + .bulkConfig( + BulkConfig.builder() + .addTier( + BulkTier.builder() + .unitAmount("unit_amount") + .maximumUnits(0.0) + .build() + ) + .build() + ) + .cadence(Price.Bulk.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() .field(TransformPriceFilter.Field.PRICE_ID) @@ -754,18 +776,6 @@ internal class PriceTest { .build() ) .item(ItemSlim.builder().id("id").name("name").build()) - .matrixConfig( - MatrixConfig.builder() - .defaultUnitAmount("default_unit_amount") - .addDimension("string") - .addMatrixValue( - MatrixValue.builder() - .addDimensionValue("string") - .unitAmount("unit_amount") - .build() - ) - .build() - ) .maximum( Maximum.builder() .addAppliesToPriceId("string") @@ -781,7 +791,7 @@ internal class PriceTest { ) .maximumAmount("maximum_amount") .metadata( - Price.Matrix.Metadata.builder() + Price.Bulk.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -801,7 +811,7 @@ internal class PriceTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.Matrix.PriceType.USAGE_PRICE) + .priceType(Price.Bulk.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -819,9 +829,9 @@ internal class PriceTest { } @Test - fun ofTiered() { - val tiered = - Price.Tiered.builder() + fun ofPackage() { + val package_ = + Price.Package.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -830,7 +840,7 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .cadence(Price.Tiered.Cadence.ONE_TIME) + .cadence(Price.Package.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() .field(TransformPriceFilter.Field.PRICE_ID) @@ -896,7 +906,7 @@ internal class PriceTest { ) .maximumAmount("maximum_amount") .metadata( - Price.Tiered.Metadata.builder() + Price.Package.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -915,20 +925,12 @@ internal class PriceTest { ) .minimumAmount("minimum_amount") .name("name") + .packageConfig( + PackageConfig.builder().packageAmount("package_amount").packageSize(1L).build() + ) .planPhaseOrder(0L) - .priceType(Price.Tiered.PriceType.USAGE_PRICE) + .priceType(Price.Package.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .tieredConfig( - TieredConfig.builder() - .addTier( - Tier.builder() - .firstUnit(0.0) - .unitAmount("unit_amount") - .lastUnit(0.0) - .build() - ) - .build() - ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") @@ -937,17 +939,17 @@ internal class PriceTest { ) .build() - val price = Price.ofTiered(tiered) + val price = Price.ofPackage(package_) assertThat(price.unit()).isNull() - assertThat(price.package_()).isNull() - assertThat(price.matrix()).isNull() - assertThat(price.tiered()).isEqualTo(tiered) + assertThat(price.tiered()).isNull() assertThat(price.bulk()).isNull() + assertThat(price.package_()).isEqualTo(package_) + assertThat(price.matrix()).isNull() assertThat(price.thresholdTotalAmount()).isNull() assertThat(price.tieredPackage()).isNull() - assertThat(price.groupedTiered()).isNull() assertThat(price.tieredWithMinimum()).isNull() + assertThat(price.groupedTiered()).isNull() assertThat(price.tieredPackageWithMinimum()).isNull() assertThat(price.packageWithAllocation()).isNull() assertThat(price.unitWithPercent()).isNull() @@ -955,25 +957,25 @@ internal class PriceTest { assertThat(price.tieredWithProration()).isNull() assertThat(price.unitWithProration()).isNull() assertThat(price.groupedAllocation()).isNull() + assertThat(price.bulkWithProration()).isNull() assertThat(price.groupedWithProratedMinimum()).isNull() assertThat(price.groupedWithMeteredMinimum()).isNull() + assertThat(price.groupedWithMinMaxThresholds()).isNull() assertThat(price.matrixWithDisplayName()).isNull() - assertThat(price.bulkWithProration()).isNull() assertThat(price.groupedTieredPackage()).isNull() assertThat(price.maxGroupTieredPackage()).isNull() assertThat(price.scalableMatrixWithUnitPricing()).isNull() assertThat(price.scalableMatrixWithTieredPricing()).isNull() assertThat(price.cumulativeGroupedBulk()).isNull() - assertThat(price.groupedWithMinMaxThresholds()).isNull() assertThat(price.minimum()).isNull() } @Test - fun ofTieredRoundtrip() { + fun ofPackageRoundtrip() { val jsonMapper = jsonMapper() val price = - Price.ofTiered( - Price.Tiered.builder() + Price.ofPackage( + Price.Package.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -982,7 +984,7 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .cadence(Price.Tiered.Cadence.ONE_TIME) + .cadence(Price.Package.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() .field(TransformPriceFilter.Field.PRICE_ID) @@ -1048,7 +1050,7 @@ internal class PriceTest { ) .maximumAmount("maximum_amount") .metadata( - Price.Tiered.Metadata.builder() + Price.Package.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -1067,20 +1069,15 @@ internal class PriceTest { ) .minimumAmount("minimum_amount") .name("name") - .planPhaseOrder(0L) - .priceType(Price.Tiered.PriceType.USAGE_PRICE) - .replacesPriceId("replaces_price_id") - .tieredConfig( - TieredConfig.builder() - .addTier( - Tier.builder() - .firstUnit(0.0) - .unitAmount("unit_amount") - .lastUnit(0.0) - .build() - ) + .packageConfig( + PackageConfig.builder() + .packageAmount("package_amount") + .packageSize(1L) .build() ) + .planPhaseOrder(0L) + .priceType(Price.Package.PriceType.USAGE_PRICE) + .replacesPriceId("replaces_price_id") .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") @@ -1097,9 +1094,9 @@ internal class PriceTest { } @Test - fun ofBulk() { - val bulk = - Price.Bulk.builder() + fun ofMatrix() { + val matrix = + Price.Matrix.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -1108,14 +1105,7 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .bulkConfig( - BulkConfig.builder() - .addTier( - BulkTier.builder().unitAmount("unit_amount").maximumUnits(0.0).build() - ) - .build() - ) - .cadence(Price.Bulk.Cadence.ONE_TIME) + .cadence(Price.Matrix.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() .field(TransformPriceFilter.Field.PRICE_ID) @@ -1166,6 +1156,18 @@ internal class PriceTest { .build() ) .item(ItemSlim.builder().id("id").name("name").build()) + .matrixConfig( + MatrixConfig.builder() + .defaultUnitAmount("default_unit_amount") + .addDimension("string") + .addMatrixValue( + MatrixValue.builder() + .addDimensionValue("string") + .unitAmount("unit_amount") + .build() + ) + .build() + ) .maximum( Maximum.builder() .addAppliesToPriceId("string") @@ -1181,7 +1183,7 @@ internal class PriceTest { ) .maximumAmount("maximum_amount") .metadata( - Price.Bulk.Metadata.builder() + Price.Matrix.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -1201,7 +1203,7 @@ internal class PriceTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.Bulk.PriceType.USAGE_PRICE) + .priceType(Price.Matrix.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -1211,17 +1213,17 @@ internal class PriceTest { ) .build() - val price = Price.ofBulk(bulk) + val price = Price.ofMatrix(matrix) assertThat(price.unit()).isNull() - assertThat(price.package_()).isNull() - assertThat(price.matrix()).isNull() assertThat(price.tiered()).isNull() - assertThat(price.bulk()).isEqualTo(bulk) + assertThat(price.bulk()).isNull() + assertThat(price.package_()).isNull() + assertThat(price.matrix()).isEqualTo(matrix) assertThat(price.thresholdTotalAmount()).isNull() assertThat(price.tieredPackage()).isNull() - assertThat(price.groupedTiered()).isNull() assertThat(price.tieredWithMinimum()).isNull() + assertThat(price.groupedTiered()).isNull() assertThat(price.tieredPackageWithMinimum()).isNull() assertThat(price.packageWithAllocation()).isNull() assertThat(price.unitWithPercent()).isNull() @@ -1229,25 +1231,25 @@ internal class PriceTest { assertThat(price.tieredWithProration()).isNull() assertThat(price.unitWithProration()).isNull() assertThat(price.groupedAllocation()).isNull() + assertThat(price.bulkWithProration()).isNull() assertThat(price.groupedWithProratedMinimum()).isNull() assertThat(price.groupedWithMeteredMinimum()).isNull() + assertThat(price.groupedWithMinMaxThresholds()).isNull() assertThat(price.matrixWithDisplayName()).isNull() - assertThat(price.bulkWithProration()).isNull() assertThat(price.groupedTieredPackage()).isNull() assertThat(price.maxGroupTieredPackage()).isNull() assertThat(price.scalableMatrixWithUnitPricing()).isNull() assertThat(price.scalableMatrixWithTieredPricing()).isNull() assertThat(price.cumulativeGroupedBulk()).isNull() - assertThat(price.groupedWithMinMaxThresholds()).isNull() assertThat(price.minimum()).isNull() } @Test - fun ofBulkRoundtrip() { + fun ofMatrixRoundtrip() { val jsonMapper = jsonMapper() val price = - Price.ofBulk( - Price.Bulk.builder() + Price.ofMatrix( + Price.Matrix.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -1256,17 +1258,7 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .bulkConfig( - BulkConfig.builder() - .addTier( - BulkTier.builder() - .unitAmount("unit_amount") - .maximumUnits(0.0) - .build() - ) - .build() - ) - .cadence(Price.Bulk.Cadence.ONE_TIME) + .cadence(Price.Matrix.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() .field(TransformPriceFilter.Field.PRICE_ID) @@ -1317,6 +1309,18 @@ internal class PriceTest { .build() ) .item(ItemSlim.builder().id("id").name("name").build()) + .matrixConfig( + MatrixConfig.builder() + .defaultUnitAmount("default_unit_amount") + .addDimension("string") + .addMatrixValue( + MatrixValue.builder() + .addDimensionValue("string") + .unitAmount("unit_amount") + .build() + ) + .build() + ) .maximum( Maximum.builder() .addAppliesToPriceId("string") @@ -1332,7 +1336,7 @@ internal class PriceTest { ) .maximumAmount("maximum_amount") .metadata( - Price.Bulk.Metadata.builder() + Price.Matrix.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -1352,7 +1356,7 @@ internal class PriceTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.Bulk.PriceType.USAGE_PRICE) + .priceType(Price.Matrix.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -1471,7 +1475,21 @@ internal class PriceTest { .replacesPriceId("replaces_price_id") .thresholdTotalAmountConfig( Price.ThresholdTotalAmount.ThresholdTotalAmountConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .addConsumptionTable( + Price.ThresholdTotalAmount.ThresholdTotalAmountConfig.ConsumptionTable + .builder() + .threshold("threshold") + .totalAmount("total_amount") + .build() + ) + .addConsumptionTable( + Price.ThresholdTotalAmount.ThresholdTotalAmountConfig.ConsumptionTable + .builder() + .threshold("threshold") + .totalAmount("total_amount") + .build() + ) + .prorate(true) .build() ) .dimensionalPriceConfiguration( @@ -1485,14 +1503,14 @@ internal class PriceTest { val price = Price.ofThresholdTotalAmount(thresholdTotalAmount) assertThat(price.unit()).isNull() - assertThat(price.package_()).isNull() - assertThat(price.matrix()).isNull() assertThat(price.tiered()).isNull() assertThat(price.bulk()).isNull() + assertThat(price.package_()).isNull() + assertThat(price.matrix()).isNull() assertThat(price.thresholdTotalAmount()).isEqualTo(thresholdTotalAmount) assertThat(price.tieredPackage()).isNull() - assertThat(price.groupedTiered()).isNull() assertThat(price.tieredWithMinimum()).isNull() + assertThat(price.groupedTiered()).isNull() assertThat(price.tieredPackageWithMinimum()).isNull() assertThat(price.packageWithAllocation()).isNull() assertThat(price.unitWithPercent()).isNull() @@ -1500,16 +1518,16 @@ internal class PriceTest { assertThat(price.tieredWithProration()).isNull() assertThat(price.unitWithProration()).isNull() assertThat(price.groupedAllocation()).isNull() + assertThat(price.bulkWithProration()).isNull() assertThat(price.groupedWithProratedMinimum()).isNull() assertThat(price.groupedWithMeteredMinimum()).isNull() + assertThat(price.groupedWithMinMaxThresholds()).isNull() assertThat(price.matrixWithDisplayName()).isNull() - assertThat(price.bulkWithProration()).isNull() assertThat(price.groupedTieredPackage()).isNull() assertThat(price.maxGroupTieredPackage()).isNull() assertThat(price.scalableMatrixWithUnitPricing()).isNull() assertThat(price.scalableMatrixWithTieredPricing()).isNull() assertThat(price.cumulativeGroupedBulk()).isNull() - assertThat(price.groupedWithMinMaxThresholds()).isNull() assertThat(price.minimum()).isNull() } @@ -1617,7 +1635,23 @@ internal class PriceTest { .replacesPriceId("replaces_price_id") .thresholdTotalAmountConfig( Price.ThresholdTotalAmount.ThresholdTotalAmountConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .addConsumptionTable( + Price.ThresholdTotalAmount.ThresholdTotalAmountConfig + .ConsumptionTable + .builder() + .threshold("threshold") + .totalAmount("total_amount") + .build() + ) + .addConsumptionTable( + Price.ThresholdTotalAmount.ThresholdTotalAmountConfig + .ConsumptionTable + .builder() + .threshold("threshold") + .totalAmount("total_amount") + .build() + ) + .prorate(true) .build() ) .dimensionalPriceConfiguration( @@ -1737,7 +1771,19 @@ internal class PriceTest { .replacesPriceId("replaces_price_id") .tieredPackageConfig( Price.TieredPackage.TieredPackageConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .packageSize("package_size") + .addTier( + Price.TieredPackage.TieredPackageConfig.Tier.builder() + .perUnit("per_unit") + .tierLowerBound("tier_lower_bound") + .build() + ) + .addTier( + Price.TieredPackage.TieredPackageConfig.Tier.builder() + .perUnit("per_unit") + .tierLowerBound("tier_lower_bound") + .build() + ) .build() ) .dimensionalPriceConfiguration( @@ -1751,14 +1797,14 @@ internal class PriceTest { val price = Price.ofTieredPackage(tieredPackage) assertThat(price.unit()).isNull() - assertThat(price.package_()).isNull() - assertThat(price.matrix()).isNull() assertThat(price.tiered()).isNull() assertThat(price.bulk()).isNull() + assertThat(price.package_()).isNull() + assertThat(price.matrix()).isNull() assertThat(price.thresholdTotalAmount()).isNull() assertThat(price.tieredPackage()).isEqualTo(tieredPackage) - assertThat(price.groupedTiered()).isNull() assertThat(price.tieredWithMinimum()).isNull() + assertThat(price.groupedTiered()).isNull() assertThat(price.tieredPackageWithMinimum()).isNull() assertThat(price.packageWithAllocation()).isNull() assertThat(price.unitWithPercent()).isNull() @@ -1766,16 +1812,16 @@ internal class PriceTest { assertThat(price.tieredWithProration()).isNull() assertThat(price.unitWithProration()).isNull() assertThat(price.groupedAllocation()).isNull() + assertThat(price.bulkWithProration()).isNull() assertThat(price.groupedWithProratedMinimum()).isNull() assertThat(price.groupedWithMeteredMinimum()).isNull() + assertThat(price.groupedWithMinMaxThresholds()).isNull() assertThat(price.matrixWithDisplayName()).isNull() - assertThat(price.bulkWithProration()).isNull() assertThat(price.groupedTieredPackage()).isNull() assertThat(price.maxGroupTieredPackage()).isNull() assertThat(price.scalableMatrixWithUnitPricing()).isNull() assertThat(price.scalableMatrixWithTieredPricing()).isNull() assertThat(price.cumulativeGroupedBulk()).isNull() - assertThat(price.groupedWithMinMaxThresholds()).isNull() assertThat(price.minimum()).isNull() } @@ -1883,7 +1929,19 @@ internal class PriceTest { .replacesPriceId("replaces_price_id") .tieredPackageConfig( Price.TieredPackage.TieredPackageConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .packageSize("package_size") + .addTier( + Price.TieredPackage.TieredPackageConfig.Tier.builder() + .perUnit("per_unit") + .tierLowerBound("tier_lower_bound") + .build() + ) + .addTier( + Price.TieredPackage.TieredPackageConfig.Tier.builder() + .perUnit("per_unit") + .tierLowerBound("tier_lower_bound") + .build() + ) .build() ) .dimensionalPriceConfiguration( @@ -1902,9 +1960,9 @@ internal class PriceTest { } @Test - fun ofGroupedTiered() { - val groupedTiered = - Price.GroupedTiered.builder() + fun ofTieredWithMinimum() { + val tieredWithMinimum = + Price.TieredWithMinimum.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -1913,7 +1971,7 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .cadence(Price.GroupedTiered.Cadence.ONE_TIME) + .cadence(Price.TieredWithMinimum.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() .field(TransformPriceFilter.Field.PRICE_ID) @@ -1957,11 +2015,6 @@ internal class PriceTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) - .groupedTieredConfig( - Price.GroupedTiered.GroupedTieredConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -1984,7 +2037,7 @@ internal class PriceTest { ) .maximumAmount("maximum_amount") .metadata( - Price.GroupedTiered.Metadata.builder() + Price.TieredWithMinimum.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -2004,8 +2057,28 @@ internal class PriceTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.GroupedTiered.PriceType.USAGE_PRICE) + .priceType(Price.TieredWithMinimum.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") + .tieredWithMinimumConfig( + Price.TieredWithMinimum.TieredWithMinimumConfig.builder() + .addTier( + Price.TieredWithMinimum.TieredWithMinimumConfig.Tier.builder() + .minimumAmount("minimum_amount") + .tierLowerBound("tier_lower_bound") + .unitAmount("unit_amount") + .build() + ) + .addTier( + Price.TieredWithMinimum.TieredWithMinimumConfig.Tier.builder() + .minimumAmount("minimum_amount") + .tierLowerBound("tier_lower_bound") + .unitAmount("unit_amount") + .build() + ) + .hideZeroAmountTiers(true) + .prorate(true) + .build() + ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") @@ -2014,17 +2087,17 @@ internal class PriceTest { ) .build() - val price = Price.ofGroupedTiered(groupedTiered) + val price = Price.ofTieredWithMinimum(tieredWithMinimum) assertThat(price.unit()).isNull() - assertThat(price.package_()).isNull() - assertThat(price.matrix()).isNull() assertThat(price.tiered()).isNull() assertThat(price.bulk()).isNull() + assertThat(price.package_()).isNull() + assertThat(price.matrix()).isNull() assertThat(price.thresholdTotalAmount()).isNull() assertThat(price.tieredPackage()).isNull() - assertThat(price.groupedTiered()).isEqualTo(groupedTiered) - assertThat(price.tieredWithMinimum()).isNull() + assertThat(price.tieredWithMinimum()).isEqualTo(tieredWithMinimum) + assertThat(price.groupedTiered()).isNull() assertThat(price.tieredPackageWithMinimum()).isNull() assertThat(price.packageWithAllocation()).isNull() assertThat(price.unitWithPercent()).isNull() @@ -2032,25 +2105,25 @@ internal class PriceTest { assertThat(price.tieredWithProration()).isNull() assertThat(price.unitWithProration()).isNull() assertThat(price.groupedAllocation()).isNull() + assertThat(price.bulkWithProration()).isNull() assertThat(price.groupedWithProratedMinimum()).isNull() assertThat(price.groupedWithMeteredMinimum()).isNull() + assertThat(price.groupedWithMinMaxThresholds()).isNull() assertThat(price.matrixWithDisplayName()).isNull() - assertThat(price.bulkWithProration()).isNull() assertThat(price.groupedTieredPackage()).isNull() assertThat(price.maxGroupTieredPackage()).isNull() assertThat(price.scalableMatrixWithUnitPricing()).isNull() assertThat(price.scalableMatrixWithTieredPricing()).isNull() assertThat(price.cumulativeGroupedBulk()).isNull() - assertThat(price.groupedWithMinMaxThresholds()).isNull() assertThat(price.minimum()).isNull() } @Test - fun ofGroupedTieredRoundtrip() { + fun ofTieredWithMinimumRoundtrip() { val jsonMapper = jsonMapper() val price = - Price.ofGroupedTiered( - Price.GroupedTiered.builder() + Price.ofTieredWithMinimum( + Price.TieredWithMinimum.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -2059,7 +2132,7 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .cadence(Price.GroupedTiered.Cadence.ONE_TIME) + .cadence(Price.TieredWithMinimum.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() .field(TransformPriceFilter.Field.PRICE_ID) @@ -2103,11 +2176,6 @@ internal class PriceTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) - .groupedTieredConfig( - Price.GroupedTiered.GroupedTieredConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -2130,7 +2198,7 @@ internal class PriceTest { ) .maximumAmount("maximum_amount") .metadata( - Price.GroupedTiered.Metadata.builder() + Price.TieredWithMinimum.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -2150,8 +2218,28 @@ internal class PriceTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.GroupedTiered.PriceType.USAGE_PRICE) + .priceType(Price.TieredWithMinimum.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") + .tieredWithMinimumConfig( + Price.TieredWithMinimum.TieredWithMinimumConfig.builder() + .addTier( + Price.TieredWithMinimum.TieredWithMinimumConfig.Tier.builder() + .minimumAmount("minimum_amount") + .tierLowerBound("tier_lower_bound") + .unitAmount("unit_amount") + .build() + ) + .addTier( + Price.TieredWithMinimum.TieredWithMinimumConfig.Tier.builder() + .minimumAmount("minimum_amount") + .tierLowerBound("tier_lower_bound") + .unitAmount("unit_amount") + .build() + ) + .hideZeroAmountTiers(true) + .prorate(true) + .build() + ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") @@ -2168,9 +2256,9 @@ internal class PriceTest { } @Test - fun ofTieredWithMinimum() { - val tieredWithMinimum = - Price.TieredWithMinimum.builder() + fun ofGroupedTiered() { + val groupedTiered = + Price.GroupedTiered.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -2179,7 +2267,7 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .cadence(Price.TieredWithMinimum.Cadence.ONE_TIME) + .cadence(Price.GroupedTiered.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() .field(TransformPriceFilter.Field.PRICE_ID) @@ -2223,6 +2311,23 @@ internal class PriceTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .groupedTieredConfig( + Price.GroupedTiered.GroupedTieredConfig.builder() + .groupingKey("x") + .addTier( + Price.GroupedTiered.GroupedTieredConfig.Tier.builder() + .tierLowerBound("tier_lower_bound") + .unitAmount("unit_amount") + .build() + ) + .addTier( + Price.GroupedTiered.GroupedTieredConfig.Tier.builder() + .tierLowerBound("tier_lower_bound") + .unitAmount("unit_amount") + .build() + ) + .build() + ) .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -2245,7 +2350,7 @@ internal class PriceTest { ) .maximumAmount("maximum_amount") .metadata( - Price.TieredWithMinimum.Metadata.builder() + Price.GroupedTiered.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -2265,13 +2370,8 @@ internal class PriceTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.TieredWithMinimum.PriceType.USAGE_PRICE) + .priceType(Price.GroupedTiered.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .tieredWithMinimumConfig( - Price.TieredWithMinimum.TieredWithMinimumConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") @@ -2280,17 +2380,17 @@ internal class PriceTest { ) .build() - val price = Price.ofTieredWithMinimum(tieredWithMinimum) + val price = Price.ofGroupedTiered(groupedTiered) assertThat(price.unit()).isNull() - assertThat(price.package_()).isNull() - assertThat(price.matrix()).isNull() assertThat(price.tiered()).isNull() assertThat(price.bulk()).isNull() + assertThat(price.package_()).isNull() + assertThat(price.matrix()).isNull() assertThat(price.thresholdTotalAmount()).isNull() assertThat(price.tieredPackage()).isNull() - assertThat(price.groupedTiered()).isNull() - assertThat(price.tieredWithMinimum()).isEqualTo(tieredWithMinimum) + assertThat(price.tieredWithMinimum()).isNull() + assertThat(price.groupedTiered()).isEqualTo(groupedTiered) assertThat(price.tieredPackageWithMinimum()).isNull() assertThat(price.packageWithAllocation()).isNull() assertThat(price.unitWithPercent()).isNull() @@ -2298,25 +2398,25 @@ internal class PriceTest { assertThat(price.tieredWithProration()).isNull() assertThat(price.unitWithProration()).isNull() assertThat(price.groupedAllocation()).isNull() + assertThat(price.bulkWithProration()).isNull() assertThat(price.groupedWithProratedMinimum()).isNull() assertThat(price.groupedWithMeteredMinimum()).isNull() + assertThat(price.groupedWithMinMaxThresholds()).isNull() assertThat(price.matrixWithDisplayName()).isNull() - assertThat(price.bulkWithProration()).isNull() assertThat(price.groupedTieredPackage()).isNull() assertThat(price.maxGroupTieredPackage()).isNull() assertThat(price.scalableMatrixWithUnitPricing()).isNull() assertThat(price.scalableMatrixWithTieredPricing()).isNull() assertThat(price.cumulativeGroupedBulk()).isNull() - assertThat(price.groupedWithMinMaxThresholds()).isNull() assertThat(price.minimum()).isNull() } @Test - fun ofTieredWithMinimumRoundtrip() { + fun ofGroupedTieredRoundtrip() { val jsonMapper = jsonMapper() - val price = - Price.ofTieredWithMinimum( - Price.TieredWithMinimum.builder() + val price = + Price.ofGroupedTiered( + Price.GroupedTiered.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -2325,7 +2425,7 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .cadence(Price.TieredWithMinimum.Cadence.ONE_TIME) + .cadence(Price.GroupedTiered.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() .field(TransformPriceFilter.Field.PRICE_ID) @@ -2369,6 +2469,23 @@ internal class PriceTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .groupedTieredConfig( + Price.GroupedTiered.GroupedTieredConfig.builder() + .groupingKey("x") + .addTier( + Price.GroupedTiered.GroupedTieredConfig.Tier.builder() + .tierLowerBound("tier_lower_bound") + .unitAmount("unit_amount") + .build() + ) + .addTier( + Price.GroupedTiered.GroupedTieredConfig.Tier.builder() + .tierLowerBound("tier_lower_bound") + .unitAmount("unit_amount") + .build() + ) + .build() + ) .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -2391,7 +2508,7 @@ internal class PriceTest { ) .maximumAmount("maximum_amount") .metadata( - Price.TieredWithMinimum.Metadata.builder() + Price.GroupedTiered.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -2411,13 +2528,8 @@ internal class PriceTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.TieredWithMinimum.PriceType.USAGE_PRICE) + .priceType(Price.GroupedTiered.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .tieredWithMinimumConfig( - Price.TieredWithMinimum.TieredWithMinimumConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") @@ -2535,7 +2647,23 @@ internal class PriceTest { .replacesPriceId("replaces_price_id") .tieredPackageWithMinimumConfig( Price.TieredPackageWithMinimum.TieredPackageWithMinimumConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .packageSize(0.0) + .addTier( + Price.TieredPackageWithMinimum.TieredPackageWithMinimumConfig.Tier + .builder() + .minimumAmount("minimum_amount") + .perUnit("per_unit") + .tierLowerBound("tier_lower_bound") + .build() + ) + .addTier( + Price.TieredPackageWithMinimum.TieredPackageWithMinimumConfig.Tier + .builder() + .minimumAmount("minimum_amount") + .perUnit("per_unit") + .tierLowerBound("tier_lower_bound") + .build() + ) .build() ) .dimensionalPriceConfiguration( @@ -2549,14 +2677,14 @@ internal class PriceTest { val price = Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum) assertThat(price.unit()).isNull() - assertThat(price.package_()).isNull() - assertThat(price.matrix()).isNull() assertThat(price.tiered()).isNull() assertThat(price.bulk()).isNull() + assertThat(price.package_()).isNull() + assertThat(price.matrix()).isNull() assertThat(price.thresholdTotalAmount()).isNull() assertThat(price.tieredPackage()).isNull() - assertThat(price.groupedTiered()).isNull() assertThat(price.tieredWithMinimum()).isNull() + assertThat(price.groupedTiered()).isNull() assertThat(price.tieredPackageWithMinimum()).isEqualTo(tieredPackageWithMinimum) assertThat(price.packageWithAllocation()).isNull() assertThat(price.unitWithPercent()).isNull() @@ -2564,16 +2692,16 @@ internal class PriceTest { assertThat(price.tieredWithProration()).isNull() assertThat(price.unitWithProration()).isNull() assertThat(price.groupedAllocation()).isNull() + assertThat(price.bulkWithProration()).isNull() assertThat(price.groupedWithProratedMinimum()).isNull() assertThat(price.groupedWithMeteredMinimum()).isNull() + assertThat(price.groupedWithMinMaxThresholds()).isNull() assertThat(price.matrixWithDisplayName()).isNull() - assertThat(price.bulkWithProration()).isNull() assertThat(price.groupedTieredPackage()).isNull() assertThat(price.maxGroupTieredPackage()).isNull() assertThat(price.scalableMatrixWithUnitPricing()).isNull() assertThat(price.scalableMatrixWithTieredPricing()).isNull() assertThat(price.cumulativeGroupedBulk()).isNull() - assertThat(price.groupedWithMinMaxThresholds()).isNull() assertThat(price.minimum()).isNull() } @@ -2681,7 +2809,23 @@ internal class PriceTest { .replacesPriceId("replaces_price_id") .tieredPackageWithMinimumConfig( Price.TieredPackageWithMinimum.TieredPackageWithMinimumConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .packageSize(0.0) + .addTier( + Price.TieredPackageWithMinimum.TieredPackageWithMinimumConfig.Tier + .builder() + .minimumAmount("minimum_amount") + .perUnit("per_unit") + .tierLowerBound("tier_lower_bound") + .build() + ) + .addTier( + Price.TieredPackageWithMinimum.TieredPackageWithMinimumConfig.Tier + .builder() + .minimumAmount("minimum_amount") + .perUnit("per_unit") + .tierLowerBound("tier_lower_bound") + .build() + ) .build() ) .dimensionalPriceConfiguration( @@ -2798,7 +2942,9 @@ internal class PriceTest { .name("name") .packageWithAllocationConfig( Price.PackageWithAllocation.PackageWithAllocationConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .allocation("allocation") + .packageAmount("package_amount") + .packageSize("package_size") .build() ) .planPhaseOrder(0L) @@ -2815,14 +2961,14 @@ internal class PriceTest { val price = Price.ofPackageWithAllocation(packageWithAllocation) assertThat(price.unit()).isNull() - assertThat(price.package_()).isNull() - assertThat(price.matrix()).isNull() assertThat(price.tiered()).isNull() assertThat(price.bulk()).isNull() + assertThat(price.package_()).isNull() + assertThat(price.matrix()).isNull() assertThat(price.thresholdTotalAmount()).isNull() assertThat(price.tieredPackage()).isNull() - assertThat(price.groupedTiered()).isNull() assertThat(price.tieredWithMinimum()).isNull() + assertThat(price.groupedTiered()).isNull() assertThat(price.tieredPackageWithMinimum()).isNull() assertThat(price.packageWithAllocation()).isEqualTo(packageWithAllocation) assertThat(price.unitWithPercent()).isNull() @@ -2830,16 +2976,16 @@ internal class PriceTest { assertThat(price.tieredWithProration()).isNull() assertThat(price.unitWithProration()).isNull() assertThat(price.groupedAllocation()).isNull() + assertThat(price.bulkWithProration()).isNull() assertThat(price.groupedWithProratedMinimum()).isNull() assertThat(price.groupedWithMeteredMinimum()).isNull() + assertThat(price.groupedWithMinMaxThresholds()).isNull() assertThat(price.matrixWithDisplayName()).isNull() - assertThat(price.bulkWithProration()).isNull() assertThat(price.groupedTieredPackage()).isNull() assertThat(price.maxGroupTieredPackage()).isNull() assertThat(price.scalableMatrixWithUnitPricing()).isNull() assertThat(price.scalableMatrixWithTieredPricing()).isNull() assertThat(price.cumulativeGroupedBulk()).isNull() - assertThat(price.groupedWithMinMaxThresholds()).isNull() assertThat(price.minimum()).isNull() } @@ -2944,7 +3090,9 @@ internal class PriceTest { .name("name") .packageWithAllocationConfig( Price.PackageWithAllocation.PackageWithAllocationConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .allocation("allocation") + .packageAmount("package_amount") + .packageSize("package_size") .build() ) .planPhaseOrder(0L) @@ -3067,7 +3215,8 @@ internal class PriceTest { .replacesPriceId("replaces_price_id") .unitWithPercentConfig( Price.UnitWithPercent.UnitWithPercentConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .percent("percent") + .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( @@ -3081,14 +3230,14 @@ internal class PriceTest { val price = Price.ofUnitWithPercent(unitWithPercent) assertThat(price.unit()).isNull() - assertThat(price.package_()).isNull() - assertThat(price.matrix()).isNull() assertThat(price.tiered()).isNull() assertThat(price.bulk()).isNull() + assertThat(price.package_()).isNull() + assertThat(price.matrix()).isNull() assertThat(price.thresholdTotalAmount()).isNull() assertThat(price.tieredPackage()).isNull() - assertThat(price.groupedTiered()).isNull() assertThat(price.tieredWithMinimum()).isNull() + assertThat(price.groupedTiered()).isNull() assertThat(price.tieredPackageWithMinimum()).isNull() assertThat(price.packageWithAllocation()).isNull() assertThat(price.unitWithPercent()).isEqualTo(unitWithPercent) @@ -3096,16 +3245,16 @@ internal class PriceTest { assertThat(price.tieredWithProration()).isNull() assertThat(price.unitWithProration()).isNull() assertThat(price.groupedAllocation()).isNull() + assertThat(price.bulkWithProration()).isNull() assertThat(price.groupedWithProratedMinimum()).isNull() assertThat(price.groupedWithMeteredMinimum()).isNull() + assertThat(price.groupedWithMinMaxThresholds()).isNull() assertThat(price.matrixWithDisplayName()).isNull() - assertThat(price.bulkWithProration()).isNull() assertThat(price.groupedTieredPackage()).isNull() assertThat(price.maxGroupTieredPackage()).isNull() assertThat(price.scalableMatrixWithUnitPricing()).isNull() assertThat(price.scalableMatrixWithTieredPricing()).isNull() assertThat(price.cumulativeGroupedBulk()).isNull() - assertThat(price.groupedWithMinMaxThresholds()).isNull() assertThat(price.minimum()).isNull() } @@ -3213,7 +3362,8 @@ internal class PriceTest { .replacesPriceId("replaces_price_id") .unitWithPercentConfig( Price.UnitWithPercent.UnitWithPercentConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .percent("percent") + .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( @@ -3296,11 +3446,11 @@ internal class PriceTest { .item(ItemSlim.builder().id("id").name("name").build()) .matrixWithAllocationConfig( MatrixWithAllocationConfig.builder() - .allocation(0.0) + .allocation("allocation") .defaultUnitAmount("default_unit_amount") .addDimension("string") .addMatrixValue( - MatrixValue.builder() + MatrixWithAllocationConfig.MatrixValue.builder() .addDimensionValue("string") .unitAmount("unit_amount") .build() @@ -3355,14 +3505,14 @@ internal class PriceTest { val price = Price.ofMatrixWithAllocation(matrixWithAllocation) assertThat(price.unit()).isNull() - assertThat(price.package_()).isNull() - assertThat(price.matrix()).isNull() assertThat(price.tiered()).isNull() assertThat(price.bulk()).isNull() + assertThat(price.package_()).isNull() + assertThat(price.matrix()).isNull() assertThat(price.thresholdTotalAmount()).isNull() assertThat(price.tieredPackage()).isNull() - assertThat(price.groupedTiered()).isNull() assertThat(price.tieredWithMinimum()).isNull() + assertThat(price.groupedTiered()).isNull() assertThat(price.tieredPackageWithMinimum()).isNull() assertThat(price.packageWithAllocation()).isNull() assertThat(price.unitWithPercent()).isNull() @@ -3370,16 +3520,16 @@ internal class PriceTest { assertThat(price.tieredWithProration()).isNull() assertThat(price.unitWithProration()).isNull() assertThat(price.groupedAllocation()).isNull() + assertThat(price.bulkWithProration()).isNull() assertThat(price.groupedWithProratedMinimum()).isNull() assertThat(price.groupedWithMeteredMinimum()).isNull() + assertThat(price.groupedWithMinMaxThresholds()).isNull() assertThat(price.matrixWithDisplayName()).isNull() - assertThat(price.bulkWithProration()).isNull() assertThat(price.groupedTieredPackage()).isNull() assertThat(price.maxGroupTieredPackage()).isNull() assertThat(price.scalableMatrixWithUnitPricing()).isNull() assertThat(price.scalableMatrixWithTieredPricing()).isNull() assertThat(price.cumulativeGroupedBulk()).isNull() - assertThat(price.groupedWithMinMaxThresholds()).isNull() assertThat(price.minimum()).isNull() } @@ -3450,11 +3600,11 @@ internal class PriceTest { .item(ItemSlim.builder().id("id").name("name").build()) .matrixWithAllocationConfig( MatrixWithAllocationConfig.builder() - .allocation(0.0) + .allocation("allocation") .defaultUnitAmount("default_unit_amount") .addDimension("string") .addMatrixValue( - MatrixValue.builder() + MatrixWithAllocationConfig.MatrixValue.builder() .addDimensionValue("string") .unitAmount("unit_amount") .build() @@ -3615,7 +3765,12 @@ internal class PriceTest { .replacesPriceId("replaces_price_id") .tieredWithProrationConfig( Price.TieredWithProration.TieredWithProrationConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .addTier( + Price.TieredWithProration.TieredWithProrationConfig.Tier.builder() + .tierLowerBound("tier_lower_bound") + .unitAmount("unit_amount") + .build() + ) .build() ) .dimensionalPriceConfiguration( @@ -3629,14 +3784,14 @@ internal class PriceTest { val price = Price.ofTieredWithProration(tieredWithProration) assertThat(price.unit()).isNull() - assertThat(price.package_()).isNull() - assertThat(price.matrix()).isNull() assertThat(price.tiered()).isNull() assertThat(price.bulk()).isNull() + assertThat(price.package_()).isNull() + assertThat(price.matrix()).isNull() assertThat(price.thresholdTotalAmount()).isNull() assertThat(price.tieredPackage()).isNull() - assertThat(price.groupedTiered()).isNull() assertThat(price.tieredWithMinimum()).isNull() + assertThat(price.groupedTiered()).isNull() assertThat(price.tieredPackageWithMinimum()).isNull() assertThat(price.packageWithAllocation()).isNull() assertThat(price.unitWithPercent()).isNull() @@ -3644,16 +3799,16 @@ internal class PriceTest { assertThat(price.tieredWithProration()).isEqualTo(tieredWithProration) assertThat(price.unitWithProration()).isNull() assertThat(price.groupedAllocation()).isNull() + assertThat(price.bulkWithProration()).isNull() assertThat(price.groupedWithProratedMinimum()).isNull() assertThat(price.groupedWithMeteredMinimum()).isNull() + assertThat(price.groupedWithMinMaxThresholds()).isNull() assertThat(price.matrixWithDisplayName()).isNull() - assertThat(price.bulkWithProration()).isNull() assertThat(price.groupedTieredPackage()).isNull() assertThat(price.maxGroupTieredPackage()).isNull() assertThat(price.scalableMatrixWithUnitPricing()).isNull() assertThat(price.scalableMatrixWithTieredPricing()).isNull() assertThat(price.cumulativeGroupedBulk()).isNull() - assertThat(price.groupedWithMinMaxThresholds()).isNull() assertThat(price.minimum()).isNull() } @@ -3761,7 +3916,12 @@ internal class PriceTest { .replacesPriceId("replaces_price_id") .tieredWithProrationConfig( Price.TieredWithProration.TieredWithProrationConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .addTier( + Price.TieredWithProration.TieredWithProrationConfig.Tier.builder() + .tierLowerBound("tier_lower_bound") + .unitAmount("unit_amount") + .build() + ) .build() ) .dimensionalPriceConfiguration( @@ -3881,7 +4041,7 @@ internal class PriceTest { .replacesPriceId("replaces_price_id") .unitWithProrationConfig( Price.UnitWithProration.UnitWithProrationConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( @@ -3895,14 +4055,14 @@ internal class PriceTest { val price = Price.ofUnitWithProration(unitWithProration) assertThat(price.unit()).isNull() - assertThat(price.package_()).isNull() - assertThat(price.matrix()).isNull() assertThat(price.tiered()).isNull() assertThat(price.bulk()).isNull() + assertThat(price.package_()).isNull() + assertThat(price.matrix()).isNull() assertThat(price.thresholdTotalAmount()).isNull() assertThat(price.tieredPackage()).isNull() - assertThat(price.groupedTiered()).isNull() assertThat(price.tieredWithMinimum()).isNull() + assertThat(price.groupedTiered()).isNull() assertThat(price.tieredPackageWithMinimum()).isNull() assertThat(price.packageWithAllocation()).isNull() assertThat(price.unitWithPercent()).isNull() @@ -3910,16 +4070,16 @@ internal class PriceTest { assertThat(price.tieredWithProration()).isNull() assertThat(price.unitWithProration()).isEqualTo(unitWithProration) assertThat(price.groupedAllocation()).isNull() + assertThat(price.bulkWithProration()).isNull() assertThat(price.groupedWithProratedMinimum()).isNull() assertThat(price.groupedWithMeteredMinimum()).isNull() + assertThat(price.groupedWithMinMaxThresholds()).isNull() assertThat(price.matrixWithDisplayName()).isNull() - assertThat(price.bulkWithProration()).isNull() assertThat(price.groupedTieredPackage()).isNull() assertThat(price.maxGroupTieredPackage()).isNull() assertThat(price.scalableMatrixWithUnitPricing()).isNull() assertThat(price.scalableMatrixWithTieredPricing()).isNull() assertThat(price.cumulativeGroupedBulk()).isNull() - assertThat(price.groupedWithMinMaxThresholds()).isNull() assertThat(price.minimum()).isNull() } @@ -4027,7 +4187,7 @@ internal class PriceTest { .replacesPriceId("replaces_price_id") .unitWithProrationConfig( Price.UnitWithProration.UnitWithProrationConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( @@ -4103,7 +4263,9 @@ internal class PriceTest { .fixedPriceQuantity(0.0) .groupedAllocationConfig( Price.GroupedAllocation.GroupedAllocationConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .allocation("allocation") + .groupingKey("x") + .overageUnitRate("overage_unit_rate") .build() ) .invoicingCycleConfiguration( @@ -4161,14 +4323,14 @@ internal class PriceTest { val price = Price.ofGroupedAllocation(groupedAllocation) assertThat(price.unit()).isNull() - assertThat(price.package_()).isNull() - assertThat(price.matrix()).isNull() assertThat(price.tiered()).isNull() assertThat(price.bulk()).isNull() + assertThat(price.package_()).isNull() + assertThat(price.matrix()).isNull() assertThat(price.thresholdTotalAmount()).isNull() assertThat(price.tieredPackage()).isNull() - assertThat(price.groupedTiered()).isNull() assertThat(price.tieredWithMinimum()).isNull() + assertThat(price.groupedTiered()).isNull() assertThat(price.tieredPackageWithMinimum()).isNull() assertThat(price.packageWithAllocation()).isNull() assertThat(price.unitWithPercent()).isNull() @@ -4176,16 +4338,16 @@ internal class PriceTest { assertThat(price.tieredWithProration()).isNull() assertThat(price.unitWithProration()).isNull() assertThat(price.groupedAllocation()).isEqualTo(groupedAllocation) + assertThat(price.bulkWithProration()).isNull() assertThat(price.groupedWithProratedMinimum()).isNull() assertThat(price.groupedWithMeteredMinimum()).isNull() + assertThat(price.groupedWithMinMaxThresholds()).isNull() assertThat(price.matrixWithDisplayName()).isNull() - assertThat(price.bulkWithProration()).isNull() assertThat(price.groupedTieredPackage()).isNull() assertThat(price.maxGroupTieredPackage()).isNull() assertThat(price.scalableMatrixWithUnitPricing()).isNull() assertThat(price.scalableMatrixWithTieredPricing()).isNull() assertThat(price.cumulativeGroupedBulk()).isNull() - assertThat(price.groupedWithMinMaxThresholds()).isNull() assertThat(price.minimum()).isNull() } @@ -4249,7 +4411,9 @@ internal class PriceTest { .fixedPriceQuantity(0.0) .groupedAllocationConfig( Price.GroupedAllocation.GroupedAllocationConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .allocation("allocation") + .groupingKey("x") + .overageUnitRate("overage_unit_rate") .build() ) .invoicingCycleConfiguration( @@ -4312,9 +4476,9 @@ internal class PriceTest { } @Test - fun ofGroupedWithProratedMinimum() { - val groupedWithProratedMinimum = - Price.GroupedWithProratedMinimum.builder() + fun ofBulkWithProration() { + val bulkWithProration = + Price.BulkWithProration.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -4323,7 +4487,23 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .cadence(Price.GroupedWithProratedMinimum.Cadence.ONE_TIME) + .bulkWithProrationConfig( + Price.BulkWithProration.BulkWithProrationConfig.builder() + .addTier( + Price.BulkWithProration.BulkWithProrationConfig.Tier.builder() + .unitAmount("unit_amount") + .tierLowerBound("tier_lower_bound") + .build() + ) + .addTier( + Price.BulkWithProration.BulkWithProrationConfig.Tier.builder() + .unitAmount("unit_amount") + .tierLowerBound("tier_lower_bound") + .build() + ) + .build() + ) + .cadence(Price.BulkWithProration.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() .field(TransformPriceFilter.Field.PRICE_ID) @@ -4367,11 +4547,6 @@ internal class PriceTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) - .groupedWithProratedMinimumConfig( - Price.GroupedWithProratedMinimum.GroupedWithProratedMinimumConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -4394,7 +4569,7 @@ internal class PriceTest { ) .maximumAmount("maximum_amount") .metadata( - Price.GroupedWithProratedMinimum.Metadata.builder() + Price.BulkWithProration.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -4414,7 +4589,7 @@ internal class PriceTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.GroupedWithProratedMinimum.PriceType.USAGE_PRICE) + .priceType(Price.BulkWithProration.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -4424,17 +4599,17 @@ internal class PriceTest { ) .build() - val price = Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum) + val price = Price.ofBulkWithProration(bulkWithProration) assertThat(price.unit()).isNull() - assertThat(price.package_()).isNull() - assertThat(price.matrix()).isNull() assertThat(price.tiered()).isNull() assertThat(price.bulk()).isNull() + assertThat(price.package_()).isNull() + assertThat(price.matrix()).isNull() assertThat(price.thresholdTotalAmount()).isNull() assertThat(price.tieredPackage()).isNull() - assertThat(price.groupedTiered()).isNull() assertThat(price.tieredWithMinimum()).isNull() + assertThat(price.groupedTiered()).isNull() assertThat(price.tieredPackageWithMinimum()).isNull() assertThat(price.packageWithAllocation()).isNull() assertThat(price.unitWithPercent()).isNull() @@ -4442,25 +4617,25 @@ internal class PriceTest { assertThat(price.tieredWithProration()).isNull() assertThat(price.unitWithProration()).isNull() assertThat(price.groupedAllocation()).isNull() - assertThat(price.groupedWithProratedMinimum()).isEqualTo(groupedWithProratedMinimum) + assertThat(price.bulkWithProration()).isEqualTo(bulkWithProration) + assertThat(price.groupedWithProratedMinimum()).isNull() assertThat(price.groupedWithMeteredMinimum()).isNull() + assertThat(price.groupedWithMinMaxThresholds()).isNull() assertThat(price.matrixWithDisplayName()).isNull() - assertThat(price.bulkWithProration()).isNull() assertThat(price.groupedTieredPackage()).isNull() assertThat(price.maxGroupTieredPackage()).isNull() assertThat(price.scalableMatrixWithUnitPricing()).isNull() assertThat(price.scalableMatrixWithTieredPricing()).isNull() assertThat(price.cumulativeGroupedBulk()).isNull() - assertThat(price.groupedWithMinMaxThresholds()).isNull() assertThat(price.minimum()).isNull() } @Test - fun ofGroupedWithProratedMinimumRoundtrip() { + fun ofBulkWithProrationRoundtrip() { val jsonMapper = jsonMapper() val price = - Price.ofGroupedWithProratedMinimum( - Price.GroupedWithProratedMinimum.builder() + Price.ofBulkWithProration( + Price.BulkWithProration.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -4469,7 +4644,23 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .cadence(Price.GroupedWithProratedMinimum.Cadence.ONE_TIME) + .bulkWithProrationConfig( + Price.BulkWithProration.BulkWithProrationConfig.builder() + .addTier( + Price.BulkWithProration.BulkWithProrationConfig.Tier.builder() + .unitAmount("unit_amount") + .tierLowerBound("tier_lower_bound") + .build() + ) + .addTier( + Price.BulkWithProration.BulkWithProrationConfig.Tier.builder() + .unitAmount("unit_amount") + .tierLowerBound("tier_lower_bound") + .build() + ) + .build() + ) + .cadence(Price.BulkWithProration.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() .field(TransformPriceFilter.Field.PRICE_ID) @@ -4513,11 +4704,6 @@ internal class PriceTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) - .groupedWithProratedMinimumConfig( - Price.GroupedWithProratedMinimum.GroupedWithProratedMinimumConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -4540,7 +4726,7 @@ internal class PriceTest { ) .maximumAmount("maximum_amount") .metadata( - Price.GroupedWithProratedMinimum.Metadata.builder() + Price.BulkWithProration.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -4560,7 +4746,7 @@ internal class PriceTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.GroupedWithProratedMinimum.PriceType.USAGE_PRICE) + .priceType(Price.BulkWithProration.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -4578,9 +4764,9 @@ internal class PriceTest { } @Test - fun ofGroupedWithMeteredMinimum() { - val groupedWithMeteredMinimum = - Price.GroupedWithMeteredMinimum.builder() + fun ofGroupedWithProratedMinimum() { + val groupedWithProratedMinimum = + Price.GroupedWithProratedMinimum.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -4589,7 +4775,7 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .cadence(Price.GroupedWithMeteredMinimum.Cadence.ONE_TIME) + .cadence(Price.GroupedWithProratedMinimum.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() .field(TransformPriceFilter.Field.PRICE_ID) @@ -4633,9 +4819,11 @@ internal class PriceTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) - .groupedWithMeteredMinimumConfig( - Price.GroupedWithMeteredMinimum.GroupedWithMeteredMinimumConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .groupedWithProratedMinimumConfig( + Price.GroupedWithProratedMinimum.GroupedWithProratedMinimumConfig.builder() + .groupingKey("x") + .minimum("minimum") + .unitRate("unit_rate") .build() ) .invoicingCycleConfiguration( @@ -4660,7 +4848,7 @@ internal class PriceTest { ) .maximumAmount("maximum_amount") .metadata( - Price.GroupedWithMeteredMinimum.Metadata.builder() + Price.GroupedWithProratedMinimum.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -4680,7 +4868,7 @@ internal class PriceTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.GroupedWithMeteredMinimum.PriceType.USAGE_PRICE) + .priceType(Price.GroupedWithProratedMinimum.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -4690,17 +4878,17 @@ internal class PriceTest { ) .build() - val price = Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum) + val price = Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum) assertThat(price.unit()).isNull() - assertThat(price.package_()).isNull() - assertThat(price.matrix()).isNull() assertThat(price.tiered()).isNull() assertThat(price.bulk()).isNull() + assertThat(price.package_()).isNull() + assertThat(price.matrix()).isNull() assertThat(price.thresholdTotalAmount()).isNull() assertThat(price.tieredPackage()).isNull() - assertThat(price.groupedTiered()).isNull() assertThat(price.tieredWithMinimum()).isNull() + assertThat(price.groupedTiered()).isNull() assertThat(price.tieredPackageWithMinimum()).isNull() assertThat(price.packageWithAllocation()).isNull() assertThat(price.unitWithPercent()).isNull() @@ -4708,25 +4896,25 @@ internal class PriceTest { assertThat(price.tieredWithProration()).isNull() assertThat(price.unitWithProration()).isNull() assertThat(price.groupedAllocation()).isNull() - assertThat(price.groupedWithProratedMinimum()).isNull() - assertThat(price.groupedWithMeteredMinimum()).isEqualTo(groupedWithMeteredMinimum) - assertThat(price.matrixWithDisplayName()).isNull() assertThat(price.bulkWithProration()).isNull() + assertThat(price.groupedWithProratedMinimum()).isEqualTo(groupedWithProratedMinimum) + assertThat(price.groupedWithMeteredMinimum()).isNull() + assertThat(price.groupedWithMinMaxThresholds()).isNull() + assertThat(price.matrixWithDisplayName()).isNull() assertThat(price.groupedTieredPackage()).isNull() assertThat(price.maxGroupTieredPackage()).isNull() assertThat(price.scalableMatrixWithUnitPricing()).isNull() assertThat(price.scalableMatrixWithTieredPricing()).isNull() assertThat(price.cumulativeGroupedBulk()).isNull() - assertThat(price.groupedWithMinMaxThresholds()).isNull() assertThat(price.minimum()).isNull() } @Test - fun ofGroupedWithMeteredMinimumRoundtrip() { + fun ofGroupedWithProratedMinimumRoundtrip() { val jsonMapper = jsonMapper() val price = - Price.ofGroupedWithMeteredMinimum( - Price.GroupedWithMeteredMinimum.builder() + Price.ofGroupedWithProratedMinimum( + Price.GroupedWithProratedMinimum.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -4735,7 +4923,7 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .cadence(Price.GroupedWithMeteredMinimum.Cadence.ONE_TIME) + .cadence(Price.GroupedWithProratedMinimum.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() .field(TransformPriceFilter.Field.PRICE_ID) @@ -4779,9 +4967,11 @@ internal class PriceTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) - .groupedWithMeteredMinimumConfig( - Price.GroupedWithMeteredMinimum.GroupedWithMeteredMinimumConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .groupedWithProratedMinimumConfig( + Price.GroupedWithProratedMinimum.GroupedWithProratedMinimumConfig.builder() + .groupingKey("x") + .minimum("minimum") + .unitRate("unit_rate") .build() ) .invoicingCycleConfiguration( @@ -4806,7 +4996,7 @@ internal class PriceTest { ) .maximumAmount("maximum_amount") .metadata( - Price.GroupedWithMeteredMinimum.Metadata.builder() + Price.GroupedWithProratedMinimum.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -4826,7 +5016,7 @@ internal class PriceTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.GroupedWithMeteredMinimum.PriceType.USAGE_PRICE) + .priceType(Price.GroupedWithProratedMinimum.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -4844,9 +5034,9 @@ internal class PriceTest { } @Test - fun ofMatrixWithDisplayName() { - val matrixWithDisplayName = - Price.MatrixWithDisplayName.builder() + fun ofGroupedWithMeteredMinimum() { + val groupedWithMeteredMinimum = + Price.GroupedWithMeteredMinimum.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -4855,7 +5045,7 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .cadence(Price.MatrixWithDisplayName.Cadence.ONE_TIME) + .cadence(Price.GroupedWithMeteredMinimum.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() .field(TransformPriceFilter.Field.PRICE_ID) @@ -4894,11 +5084,35 @@ internal class PriceTest { .addValue("string") .build() ) - .reason("reason") + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .groupedWithMeteredMinimumConfig( + Price.GroupedWithMeteredMinimum.GroupedWithMeteredMinimumConfig.builder() + .groupingKey("x") + .minimumUnitAmount("minimum_unit_amount") + .pricingKey("pricing_key") + .addScalingFactor( + Price.GroupedWithMeteredMinimum.GroupedWithMeteredMinimumConfig + .ScalingFactor + .builder() + .scalingFactor("scaling_factor") + .scalingValue("scaling_value") + .build() + ) + .scalingKey("scaling_key") + .addUnitAmount( + Price.GroupedWithMeteredMinimum.GroupedWithMeteredMinimumConfig + .UnitAmount + .builder() + .pricingValue("pricing_value") + .unitAmount("unit_amount") + .build() + ) .build() ) - .externalPriceId("external_price_id") - .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -4906,11 +5120,6 @@ internal class PriceTest { .build() ) .item(ItemSlim.builder().id("id").name("name").build()) - .matrixWithDisplayNameConfig( - Price.MatrixWithDisplayName.MatrixWithDisplayNameConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) .maximum( Maximum.builder() .addAppliesToPriceId("string") @@ -4926,7 +5135,7 @@ internal class PriceTest { ) .maximumAmount("maximum_amount") .metadata( - Price.MatrixWithDisplayName.Metadata.builder() + Price.GroupedWithMeteredMinimum.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -4946,7 +5155,7 @@ internal class PriceTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.MatrixWithDisplayName.PriceType.USAGE_PRICE) + .priceType(Price.GroupedWithMeteredMinimum.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -4956,17 +5165,17 @@ internal class PriceTest { ) .build() - val price = Price.ofMatrixWithDisplayName(matrixWithDisplayName) + val price = Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum) assertThat(price.unit()).isNull() - assertThat(price.package_()).isNull() - assertThat(price.matrix()).isNull() assertThat(price.tiered()).isNull() assertThat(price.bulk()).isNull() + assertThat(price.package_()).isNull() + assertThat(price.matrix()).isNull() assertThat(price.thresholdTotalAmount()).isNull() assertThat(price.tieredPackage()).isNull() - assertThat(price.groupedTiered()).isNull() assertThat(price.tieredWithMinimum()).isNull() + assertThat(price.groupedTiered()).isNull() assertThat(price.tieredPackageWithMinimum()).isNull() assertThat(price.packageWithAllocation()).isNull() assertThat(price.unitWithPercent()).isNull() @@ -4974,25 +5183,25 @@ internal class PriceTest { assertThat(price.tieredWithProration()).isNull() assertThat(price.unitWithProration()).isNull() assertThat(price.groupedAllocation()).isNull() - assertThat(price.groupedWithProratedMinimum()).isNull() - assertThat(price.groupedWithMeteredMinimum()).isNull() - assertThat(price.matrixWithDisplayName()).isEqualTo(matrixWithDisplayName) assertThat(price.bulkWithProration()).isNull() + assertThat(price.groupedWithProratedMinimum()).isNull() + assertThat(price.groupedWithMeteredMinimum()).isEqualTo(groupedWithMeteredMinimum) + assertThat(price.groupedWithMinMaxThresholds()).isNull() + assertThat(price.matrixWithDisplayName()).isNull() assertThat(price.groupedTieredPackage()).isNull() assertThat(price.maxGroupTieredPackage()).isNull() assertThat(price.scalableMatrixWithUnitPricing()).isNull() assertThat(price.scalableMatrixWithTieredPricing()).isNull() assertThat(price.cumulativeGroupedBulk()).isNull() - assertThat(price.groupedWithMinMaxThresholds()).isNull() assertThat(price.minimum()).isNull() } @Test - fun ofMatrixWithDisplayNameRoundtrip() { + fun ofGroupedWithMeteredMinimumRoundtrip() { val jsonMapper = jsonMapper() val price = - Price.ofMatrixWithDisplayName( - Price.MatrixWithDisplayName.builder() + Price.ofGroupedWithMeteredMinimum( + Price.GroupedWithMeteredMinimum.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -5001,7 +5210,7 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .cadence(Price.MatrixWithDisplayName.Cadence.ONE_TIME) + .cadence(Price.GroupedWithMeteredMinimum.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() .field(TransformPriceFilter.Field.PRICE_ID) @@ -5045,6 +5254,30 @@ internal class PriceTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .groupedWithMeteredMinimumConfig( + Price.GroupedWithMeteredMinimum.GroupedWithMeteredMinimumConfig.builder() + .groupingKey("x") + .minimumUnitAmount("minimum_unit_amount") + .pricingKey("pricing_key") + .addScalingFactor( + Price.GroupedWithMeteredMinimum.GroupedWithMeteredMinimumConfig + .ScalingFactor + .builder() + .scalingFactor("scaling_factor") + .scalingValue("scaling_value") + .build() + ) + .scalingKey("scaling_key") + .addUnitAmount( + Price.GroupedWithMeteredMinimum.GroupedWithMeteredMinimumConfig + .UnitAmount + .builder() + .pricingValue("pricing_value") + .unitAmount("unit_amount") + .build() + ) + .build() + ) .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -5052,11 +5285,6 @@ internal class PriceTest { .build() ) .item(ItemSlim.builder().id("id").name("name").build()) - .matrixWithDisplayNameConfig( - Price.MatrixWithDisplayName.MatrixWithDisplayNameConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) .maximum( Maximum.builder() .addAppliesToPriceId("string") @@ -5072,7 +5300,7 @@ internal class PriceTest { ) .maximumAmount("maximum_amount") .metadata( - Price.MatrixWithDisplayName.Metadata.builder() + Price.GroupedWithMeteredMinimum.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -5092,7 +5320,7 @@ internal class PriceTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.MatrixWithDisplayName.PriceType.USAGE_PRICE) + .priceType(Price.GroupedWithMeteredMinimum.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -5110,9 +5338,9 @@ internal class PriceTest { } @Test - fun ofBulkWithProration() { - val bulkWithProration = - Price.BulkWithProration.builder() + fun ofGroupedWithMinMaxThresholds() { + val groupedWithMinMaxThresholds = + Price.GroupedWithMinMaxThresholds.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -5121,12 +5349,7 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .bulkWithProrationConfig( - Price.BulkWithProration.BulkWithProrationConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .cadence(Price.BulkWithProration.Cadence.ONE_TIME) + .cadence(Price.GroupedWithMinMaxThresholds.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() .field(TransformPriceFilter.Field.PRICE_ID) @@ -5170,6 +5393,14 @@ internal class PriceTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .groupedWithMinMaxThresholdsConfig( + Price.GroupedWithMinMaxThresholds.GroupedWithMinMaxThresholdsConfig.builder() + .groupingKey("x") + .maximumCharge("maximum_charge") + .minimumCharge("minimum_charge") + .perUnitRate("per_unit_rate") + .build() + ) .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -5192,7 +5423,7 @@ internal class PriceTest { ) .maximumAmount("maximum_amount") .metadata( - Price.BulkWithProration.Metadata.builder() + Price.GroupedWithMinMaxThresholds.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -5212,7 +5443,7 @@ internal class PriceTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.BulkWithProration.PriceType.USAGE_PRICE) + .priceType(Price.GroupedWithMinMaxThresholds.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -5222,17 +5453,17 @@ internal class PriceTest { ) .build() - val price = Price.ofBulkWithProration(bulkWithProration) + val price = Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds) assertThat(price.unit()).isNull() - assertThat(price.package_()).isNull() - assertThat(price.matrix()).isNull() assertThat(price.tiered()).isNull() assertThat(price.bulk()).isNull() + assertThat(price.package_()).isNull() + assertThat(price.matrix()).isNull() assertThat(price.thresholdTotalAmount()).isNull() assertThat(price.tieredPackage()).isNull() - assertThat(price.groupedTiered()).isNull() assertThat(price.tieredWithMinimum()).isNull() + assertThat(price.groupedTiered()).isNull() assertThat(price.tieredPackageWithMinimum()).isNull() assertThat(price.packageWithAllocation()).isNull() assertThat(price.unitWithPercent()).isNull() @@ -5240,25 +5471,25 @@ internal class PriceTest { assertThat(price.tieredWithProration()).isNull() assertThat(price.unitWithProration()).isNull() assertThat(price.groupedAllocation()).isNull() + assertThat(price.bulkWithProration()).isNull() assertThat(price.groupedWithProratedMinimum()).isNull() assertThat(price.groupedWithMeteredMinimum()).isNull() + assertThat(price.groupedWithMinMaxThresholds()).isEqualTo(groupedWithMinMaxThresholds) assertThat(price.matrixWithDisplayName()).isNull() - assertThat(price.bulkWithProration()).isEqualTo(bulkWithProration) assertThat(price.groupedTieredPackage()).isNull() assertThat(price.maxGroupTieredPackage()).isNull() assertThat(price.scalableMatrixWithUnitPricing()).isNull() assertThat(price.scalableMatrixWithTieredPricing()).isNull() assertThat(price.cumulativeGroupedBulk()).isNull() - assertThat(price.groupedWithMinMaxThresholds()).isNull() assertThat(price.minimum()).isNull() } @Test - fun ofBulkWithProrationRoundtrip() { + fun ofGroupedWithMinMaxThresholdsRoundtrip() { val jsonMapper = jsonMapper() val price = - Price.ofBulkWithProration( - Price.BulkWithProration.builder() + Price.ofGroupedWithMinMaxThresholds( + Price.GroupedWithMinMaxThresholds.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -5267,12 +5498,7 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .bulkWithProrationConfig( - Price.BulkWithProration.BulkWithProrationConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .cadence(Price.BulkWithProration.Cadence.ONE_TIME) + .cadence(Price.GroupedWithMinMaxThresholds.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() .field(TransformPriceFilter.Field.PRICE_ID) @@ -5316,6 +5542,15 @@ internal class PriceTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .groupedWithMinMaxThresholdsConfig( + Price.GroupedWithMinMaxThresholds.GroupedWithMinMaxThresholdsConfig + .builder() + .groupingKey("x") + .maximumCharge("maximum_charge") + .minimumCharge("minimum_charge") + .perUnitRate("per_unit_rate") + .build() + ) .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -5338,7 +5573,7 @@ internal class PriceTest { ) .maximumAmount("maximum_amount") .metadata( - Price.BulkWithProration.Metadata.builder() + Price.GroupedWithMinMaxThresholds.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -5358,7 +5593,7 @@ internal class PriceTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.BulkWithProration.PriceType.USAGE_PRICE) + .priceType(Price.GroupedWithMinMaxThresholds.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -5376,9 +5611,9 @@ internal class PriceTest { } @Test - fun ofGroupedTieredPackage() { - val groupedTieredPackage = - Price.GroupedTieredPackage.builder() + fun ofMatrixWithDisplayName() { + val matrixWithDisplayName = + Price.MatrixWithDisplayName.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -5387,7 +5622,7 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .cadence(Price.GroupedTieredPackage.Cadence.ONE_TIME) + .cadence(Price.MatrixWithDisplayName.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() .field(TransformPriceFilter.Field.PRICE_ID) @@ -5431,11 +5666,6 @@ internal class PriceTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) - .groupedTieredPackageConfig( - Price.GroupedTieredPackage.GroupedTieredPackageConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -5443,6 +5673,19 @@ internal class PriceTest { .build() ) .item(ItemSlim.builder().id("id").name("name").build()) + .matrixWithDisplayNameConfig( + Price.MatrixWithDisplayName.MatrixWithDisplayNameConfig.builder() + .dimension("dimension") + .addUnitAmount( + Price.MatrixWithDisplayName.MatrixWithDisplayNameConfig.UnitAmount + .builder() + .dimensionValue("dimension_value") + .displayName("display_name") + .unitAmount("unit_amount") + .build() + ) + .build() + ) .maximum( Maximum.builder() .addAppliesToPriceId("string") @@ -5458,7 +5701,7 @@ internal class PriceTest { ) .maximumAmount("maximum_amount") .metadata( - Price.GroupedTieredPackage.Metadata.builder() + Price.MatrixWithDisplayName.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -5478,7 +5721,7 @@ internal class PriceTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.GroupedTieredPackage.PriceType.USAGE_PRICE) + .priceType(Price.MatrixWithDisplayName.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -5488,17 +5731,17 @@ internal class PriceTest { ) .build() - val price = Price.ofGroupedTieredPackage(groupedTieredPackage) + val price = Price.ofMatrixWithDisplayName(matrixWithDisplayName) assertThat(price.unit()).isNull() - assertThat(price.package_()).isNull() - assertThat(price.matrix()).isNull() assertThat(price.tiered()).isNull() assertThat(price.bulk()).isNull() + assertThat(price.package_()).isNull() + assertThat(price.matrix()).isNull() assertThat(price.thresholdTotalAmount()).isNull() assertThat(price.tieredPackage()).isNull() - assertThat(price.groupedTiered()).isNull() assertThat(price.tieredWithMinimum()).isNull() + assertThat(price.groupedTiered()).isNull() assertThat(price.tieredPackageWithMinimum()).isNull() assertThat(price.packageWithAllocation()).isNull() assertThat(price.unitWithPercent()).isNull() @@ -5506,25 +5749,25 @@ internal class PriceTest { assertThat(price.tieredWithProration()).isNull() assertThat(price.unitWithProration()).isNull() assertThat(price.groupedAllocation()).isNull() + assertThat(price.bulkWithProration()).isNull() assertThat(price.groupedWithProratedMinimum()).isNull() assertThat(price.groupedWithMeteredMinimum()).isNull() - assertThat(price.matrixWithDisplayName()).isNull() - assertThat(price.bulkWithProration()).isNull() - assertThat(price.groupedTieredPackage()).isEqualTo(groupedTieredPackage) + assertThat(price.groupedWithMinMaxThresholds()).isNull() + assertThat(price.matrixWithDisplayName()).isEqualTo(matrixWithDisplayName) + assertThat(price.groupedTieredPackage()).isNull() assertThat(price.maxGroupTieredPackage()).isNull() assertThat(price.scalableMatrixWithUnitPricing()).isNull() assertThat(price.scalableMatrixWithTieredPricing()).isNull() assertThat(price.cumulativeGroupedBulk()).isNull() - assertThat(price.groupedWithMinMaxThresholds()).isNull() assertThat(price.minimum()).isNull() } @Test - fun ofGroupedTieredPackageRoundtrip() { + fun ofMatrixWithDisplayNameRoundtrip() { val jsonMapper = jsonMapper() val price = - Price.ofGroupedTieredPackage( - Price.GroupedTieredPackage.builder() + Price.ofMatrixWithDisplayName( + Price.MatrixWithDisplayName.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -5533,7 +5776,7 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .cadence(Price.GroupedTieredPackage.Cadence.ONE_TIME) + .cadence(Price.MatrixWithDisplayName.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() .field(TransformPriceFilter.Field.PRICE_ID) @@ -5577,11 +5820,6 @@ internal class PriceTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) - .groupedTieredPackageConfig( - Price.GroupedTieredPackage.GroupedTieredPackageConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -5589,6 +5827,19 @@ internal class PriceTest { .build() ) .item(ItemSlim.builder().id("id").name("name").build()) + .matrixWithDisplayNameConfig( + Price.MatrixWithDisplayName.MatrixWithDisplayNameConfig.builder() + .dimension("dimension") + .addUnitAmount( + Price.MatrixWithDisplayName.MatrixWithDisplayNameConfig.UnitAmount + .builder() + .dimensionValue("dimension_value") + .displayName("display_name") + .unitAmount("unit_amount") + .build() + ) + .build() + ) .maximum( Maximum.builder() .addAppliesToPriceId("string") @@ -5604,7 +5855,7 @@ internal class PriceTest { ) .maximumAmount("maximum_amount") .metadata( - Price.GroupedTieredPackage.Metadata.builder() + Price.MatrixWithDisplayName.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -5624,7 +5875,7 @@ internal class PriceTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.GroupedTieredPackage.PriceType.USAGE_PRICE) + .priceType(Price.MatrixWithDisplayName.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -5642,9 +5893,9 @@ internal class PriceTest { } @Test - fun ofMaxGroupTieredPackage() { - val maxGroupTieredPackage = - Price.MaxGroupTieredPackage.builder() + fun ofGroupedTieredPackage() { + val groupedTieredPackage = + Price.GroupedTieredPackage.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -5653,7 +5904,7 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .cadence(Price.MaxGroupTieredPackage.Cadence.ONE_TIME) + .cadence(Price.GroupedTieredPackage.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() .field(TransformPriceFilter.Field.PRICE_ID) @@ -5697,6 +5948,24 @@ internal class PriceTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .groupedTieredPackageConfig( + Price.GroupedTieredPackage.GroupedTieredPackageConfig.builder() + .groupingKey("x") + .packageSize("package_size") + .addTier( + Price.GroupedTieredPackage.GroupedTieredPackageConfig.Tier.builder() + .perUnit("per_unit") + .tierLowerBound("tier_lower_bound") + .build() + ) + .addTier( + Price.GroupedTieredPackage.GroupedTieredPackageConfig.Tier.builder() + .perUnit("per_unit") + .tierLowerBound("tier_lower_bound") + .build() + ) + .build() + ) .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -5704,11 +5973,6 @@ internal class PriceTest { .build() ) .item(ItemSlim.builder().id("id").name("name").build()) - .maxGroupTieredPackageConfig( - Price.MaxGroupTieredPackage.MaxGroupTieredPackageConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) .maximum( Maximum.builder() .addAppliesToPriceId("string") @@ -5724,7 +5988,7 @@ internal class PriceTest { ) .maximumAmount("maximum_amount") .metadata( - Price.MaxGroupTieredPackage.Metadata.builder() + Price.GroupedTieredPackage.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -5744,7 +6008,7 @@ internal class PriceTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.MaxGroupTieredPackage.PriceType.USAGE_PRICE) + .priceType(Price.GroupedTieredPackage.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -5754,17 +6018,17 @@ internal class PriceTest { ) .build() - val price = Price.ofMaxGroupTieredPackage(maxGroupTieredPackage) + val price = Price.ofGroupedTieredPackage(groupedTieredPackage) assertThat(price.unit()).isNull() - assertThat(price.package_()).isNull() - assertThat(price.matrix()).isNull() assertThat(price.tiered()).isNull() assertThat(price.bulk()).isNull() + assertThat(price.package_()).isNull() + assertThat(price.matrix()).isNull() assertThat(price.thresholdTotalAmount()).isNull() assertThat(price.tieredPackage()).isNull() - assertThat(price.groupedTiered()).isNull() assertThat(price.tieredWithMinimum()).isNull() + assertThat(price.groupedTiered()).isNull() assertThat(price.tieredPackageWithMinimum()).isNull() assertThat(price.packageWithAllocation()).isNull() assertThat(price.unitWithPercent()).isNull() @@ -5772,25 +6036,25 @@ internal class PriceTest { assertThat(price.tieredWithProration()).isNull() assertThat(price.unitWithProration()).isNull() assertThat(price.groupedAllocation()).isNull() + assertThat(price.bulkWithProration()).isNull() assertThat(price.groupedWithProratedMinimum()).isNull() assertThat(price.groupedWithMeteredMinimum()).isNull() + assertThat(price.groupedWithMinMaxThresholds()).isNull() assertThat(price.matrixWithDisplayName()).isNull() - assertThat(price.bulkWithProration()).isNull() - assertThat(price.groupedTieredPackage()).isNull() - assertThat(price.maxGroupTieredPackage()).isEqualTo(maxGroupTieredPackage) + assertThat(price.groupedTieredPackage()).isEqualTo(groupedTieredPackage) + assertThat(price.maxGroupTieredPackage()).isNull() assertThat(price.scalableMatrixWithUnitPricing()).isNull() assertThat(price.scalableMatrixWithTieredPricing()).isNull() assertThat(price.cumulativeGroupedBulk()).isNull() - assertThat(price.groupedWithMinMaxThresholds()).isNull() assertThat(price.minimum()).isNull() } @Test - fun ofMaxGroupTieredPackageRoundtrip() { + fun ofGroupedTieredPackageRoundtrip() { val jsonMapper = jsonMapper() val price = - Price.ofMaxGroupTieredPackage( - Price.MaxGroupTieredPackage.builder() + Price.ofGroupedTieredPackage( + Price.GroupedTieredPackage.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -5799,7 +6063,7 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .cadence(Price.MaxGroupTieredPackage.Cadence.ONE_TIME) + .cadence(Price.GroupedTieredPackage.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() .field(TransformPriceFilter.Field.PRICE_ID) @@ -5843,6 +6107,24 @@ internal class PriceTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .groupedTieredPackageConfig( + Price.GroupedTieredPackage.GroupedTieredPackageConfig.builder() + .groupingKey("x") + .packageSize("package_size") + .addTier( + Price.GroupedTieredPackage.GroupedTieredPackageConfig.Tier.builder() + .perUnit("per_unit") + .tierLowerBound("tier_lower_bound") + .build() + ) + .addTier( + Price.GroupedTieredPackage.GroupedTieredPackageConfig.Tier.builder() + .perUnit("per_unit") + .tierLowerBound("tier_lower_bound") + .build() + ) + .build() + ) .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -5850,11 +6132,6 @@ internal class PriceTest { .build() ) .item(ItemSlim.builder().id("id").name("name").build()) - .maxGroupTieredPackageConfig( - Price.MaxGroupTieredPackage.MaxGroupTieredPackageConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) .maximum( Maximum.builder() .addAppliesToPriceId("string") @@ -5870,7 +6147,7 @@ internal class PriceTest { ) .maximumAmount("maximum_amount") .metadata( - Price.MaxGroupTieredPackage.Metadata.builder() + Price.GroupedTieredPackage.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -5890,7 +6167,7 @@ internal class PriceTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.MaxGroupTieredPackage.PriceType.USAGE_PRICE) + .priceType(Price.GroupedTieredPackage.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -5908,9 +6185,9 @@ internal class PriceTest { } @Test - fun ofScalableMatrixWithUnitPricing() { - val scalableMatrixWithUnitPricing = - Price.ScalableMatrixWithUnitPricing.builder() + fun ofMaxGroupTieredPackage() { + val maxGroupTieredPackage = + Price.MaxGroupTieredPackage.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -5919,7 +6196,7 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .cadence(Price.ScalableMatrixWithUnitPricing.Cadence.ONE_TIME) + .cadence(Price.MaxGroupTieredPackage.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() .field(TransformPriceFilter.Field.PRICE_ID) @@ -5970,6 +6247,24 @@ internal class PriceTest { .build() ) .item(ItemSlim.builder().id("id").name("name").build()) + .maxGroupTieredPackageConfig( + Price.MaxGroupTieredPackage.MaxGroupTieredPackageConfig.builder() + .groupingKey("x") + .packageSize("package_size") + .addTier( + Price.MaxGroupTieredPackage.MaxGroupTieredPackageConfig.Tier.builder() + .tierLowerBound("tier_lower_bound") + .unitAmount("unit_amount") + .build() + ) + .addTier( + Price.MaxGroupTieredPackage.MaxGroupTieredPackageConfig.Tier.builder() + .tierLowerBound("tier_lower_bound") + .unitAmount("unit_amount") + .build() + ) + .build() + ) .maximum( Maximum.builder() .addAppliesToPriceId("string") @@ -5985,7 +6280,7 @@ internal class PriceTest { ) .maximumAmount("maximum_amount") .metadata( - Price.ScalableMatrixWithUnitPricing.Metadata.builder() + Price.MaxGroupTieredPackage.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -6005,14 +6300,8 @@ internal class PriceTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.ScalableMatrixWithUnitPricing.PriceType.USAGE_PRICE) + .priceType(Price.MaxGroupTieredPackage.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .scalableMatrixWithUnitPricingConfig( - Price.ScalableMatrixWithUnitPricing.ScalableMatrixWithUnitPricingConfig - .builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") @@ -6021,17 +6310,17 @@ internal class PriceTest { ) .build() - val price = Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing) + val price = Price.ofMaxGroupTieredPackage(maxGroupTieredPackage) assertThat(price.unit()).isNull() - assertThat(price.package_()).isNull() - assertThat(price.matrix()).isNull() assertThat(price.tiered()).isNull() assertThat(price.bulk()).isNull() + assertThat(price.package_()).isNull() + assertThat(price.matrix()).isNull() assertThat(price.thresholdTotalAmount()).isNull() assertThat(price.tieredPackage()).isNull() - assertThat(price.groupedTiered()).isNull() assertThat(price.tieredWithMinimum()).isNull() + assertThat(price.groupedTiered()).isNull() assertThat(price.tieredPackageWithMinimum()).isNull() assertThat(price.packageWithAllocation()).isNull() assertThat(price.unitWithPercent()).isNull() @@ -6039,25 +6328,25 @@ internal class PriceTest { assertThat(price.tieredWithProration()).isNull() assertThat(price.unitWithProration()).isNull() assertThat(price.groupedAllocation()).isNull() + assertThat(price.bulkWithProration()).isNull() assertThat(price.groupedWithProratedMinimum()).isNull() assertThat(price.groupedWithMeteredMinimum()).isNull() + assertThat(price.groupedWithMinMaxThresholds()).isNull() assertThat(price.matrixWithDisplayName()).isNull() - assertThat(price.bulkWithProration()).isNull() assertThat(price.groupedTieredPackage()).isNull() - assertThat(price.maxGroupTieredPackage()).isNull() - assertThat(price.scalableMatrixWithUnitPricing()).isEqualTo(scalableMatrixWithUnitPricing) + assertThat(price.maxGroupTieredPackage()).isEqualTo(maxGroupTieredPackage) + assertThat(price.scalableMatrixWithUnitPricing()).isNull() assertThat(price.scalableMatrixWithTieredPricing()).isNull() assertThat(price.cumulativeGroupedBulk()).isNull() - assertThat(price.groupedWithMinMaxThresholds()).isNull() assertThat(price.minimum()).isNull() } @Test - fun ofScalableMatrixWithUnitPricingRoundtrip() { + fun ofMaxGroupTieredPackageRoundtrip() { val jsonMapper = jsonMapper() val price = - Price.ofScalableMatrixWithUnitPricing( - Price.ScalableMatrixWithUnitPricing.builder() + Price.ofMaxGroupTieredPackage( + Price.MaxGroupTieredPackage.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -6066,7 +6355,7 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .cadence(Price.ScalableMatrixWithUnitPricing.Cadence.ONE_TIME) + .cadence(Price.MaxGroupTieredPackage.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() .field(TransformPriceFilter.Field.PRICE_ID) @@ -6117,6 +6406,26 @@ internal class PriceTest { .build() ) .item(ItemSlim.builder().id("id").name("name").build()) + .maxGroupTieredPackageConfig( + Price.MaxGroupTieredPackage.MaxGroupTieredPackageConfig.builder() + .groupingKey("x") + .packageSize("package_size") + .addTier( + Price.MaxGroupTieredPackage.MaxGroupTieredPackageConfig.Tier + .builder() + .tierLowerBound("tier_lower_bound") + .unitAmount("unit_amount") + .build() + ) + .addTier( + Price.MaxGroupTieredPackage.MaxGroupTieredPackageConfig.Tier + .builder() + .tierLowerBound("tier_lower_bound") + .unitAmount("unit_amount") + .build() + ) + .build() + ) .maximum( Maximum.builder() .addAppliesToPriceId("string") @@ -6132,7 +6441,7 @@ internal class PriceTest { ) .maximumAmount("maximum_amount") .metadata( - Price.ScalableMatrixWithUnitPricing.Metadata.builder() + Price.MaxGroupTieredPackage.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -6152,14 +6461,8 @@ internal class PriceTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.ScalableMatrixWithUnitPricing.PriceType.USAGE_PRICE) + .priceType(Price.MaxGroupTieredPackage.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .scalableMatrixWithUnitPricingConfig( - Price.ScalableMatrixWithUnitPricing.ScalableMatrixWithUnitPricingConfig - .builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") @@ -6176,9 +6479,9 @@ internal class PriceTest { } @Test - fun ofScalableMatrixWithTieredPricing() { - val scalableMatrixWithTieredPricing = - Price.ScalableMatrixWithTieredPricing.builder() + fun ofScalableMatrixWithUnitPricing() { + val scalableMatrixWithUnitPricing = + Price.ScalableMatrixWithUnitPricing.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -6187,7 +6490,7 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .cadence(Price.ScalableMatrixWithTieredPricing.Cadence.ONE_TIME) + .cadence(Price.ScalableMatrixWithUnitPricing.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() .field(TransformPriceFilter.Field.PRICE_ID) @@ -6253,7 +6556,7 @@ internal class PriceTest { ) .maximumAmount("maximum_amount") .metadata( - Price.ScalableMatrixWithTieredPricing.Metadata.builder() + Price.ScalableMatrixWithUnitPricing.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -6273,12 +6576,24 @@ internal class PriceTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.ScalableMatrixWithTieredPricing.PriceType.USAGE_PRICE) + .priceType(Price.ScalableMatrixWithUnitPricing.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .scalableMatrixWithTieredPricingConfig( - Price.ScalableMatrixWithTieredPricing.ScalableMatrixWithTieredPricingConfig + .scalableMatrixWithUnitPricingConfig( + Price.ScalableMatrixWithUnitPricing.ScalableMatrixWithUnitPricingConfig .builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .firstDimension("first_dimension") + .addMatrixScalingFactor( + Price.ScalableMatrixWithUnitPricing.ScalableMatrixWithUnitPricingConfig + .MatrixScalingFactor + .builder() + .firstDimensionValue("first_dimension_value") + .scalingFactor("scaling_factor") + .secondDimensionValue("second_dimension_value") + .build() + ) + .unitPrice("unit_price") + .prorate(true) + .secondDimension("second_dimension") .build() ) .dimensionalPriceConfiguration( @@ -6289,17 +6604,17 @@ internal class PriceTest { ) .build() - val price = Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing) + val price = Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing) assertThat(price.unit()).isNull() - assertThat(price.package_()).isNull() - assertThat(price.matrix()).isNull() assertThat(price.tiered()).isNull() assertThat(price.bulk()).isNull() + assertThat(price.package_()).isNull() + assertThat(price.matrix()).isNull() assertThat(price.thresholdTotalAmount()).isNull() assertThat(price.tieredPackage()).isNull() - assertThat(price.groupedTiered()).isNull() assertThat(price.tieredWithMinimum()).isNull() + assertThat(price.groupedTiered()).isNull() assertThat(price.tieredPackageWithMinimum()).isNull() assertThat(price.packageWithAllocation()).isNull() assertThat(price.unitWithPercent()).isNull() @@ -6307,26 +6622,25 @@ internal class PriceTest { assertThat(price.tieredWithProration()).isNull() assertThat(price.unitWithProration()).isNull() assertThat(price.groupedAllocation()).isNull() + assertThat(price.bulkWithProration()).isNull() assertThat(price.groupedWithProratedMinimum()).isNull() assertThat(price.groupedWithMeteredMinimum()).isNull() + assertThat(price.groupedWithMinMaxThresholds()).isNull() assertThat(price.matrixWithDisplayName()).isNull() - assertThat(price.bulkWithProration()).isNull() assertThat(price.groupedTieredPackage()).isNull() assertThat(price.maxGroupTieredPackage()).isNull() - assertThat(price.scalableMatrixWithUnitPricing()).isNull() - assertThat(price.scalableMatrixWithTieredPricing()) - .isEqualTo(scalableMatrixWithTieredPricing) + assertThat(price.scalableMatrixWithUnitPricing()).isEqualTo(scalableMatrixWithUnitPricing) + assertThat(price.scalableMatrixWithTieredPricing()).isNull() assertThat(price.cumulativeGroupedBulk()).isNull() - assertThat(price.groupedWithMinMaxThresholds()).isNull() assertThat(price.minimum()).isNull() } @Test - fun ofScalableMatrixWithTieredPricingRoundtrip() { + fun ofScalableMatrixWithUnitPricingRoundtrip() { val jsonMapper = jsonMapper() val price = - Price.ofScalableMatrixWithTieredPricing( - Price.ScalableMatrixWithTieredPricing.builder() + Price.ofScalableMatrixWithUnitPricing( + Price.ScalableMatrixWithUnitPricing.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -6335,7 +6649,7 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .cadence(Price.ScalableMatrixWithTieredPricing.Cadence.ONE_TIME) + .cadence(Price.ScalableMatrixWithUnitPricing.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() .field(TransformPriceFilter.Field.PRICE_ID) @@ -6401,7 +6715,7 @@ internal class PriceTest { ) .maximumAmount("maximum_amount") .metadata( - Price.ScalableMatrixWithTieredPricing.Metadata.builder() + Price.ScalableMatrixWithUnitPricing.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -6421,12 +6735,25 @@ internal class PriceTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.ScalableMatrixWithTieredPricing.PriceType.USAGE_PRICE) + .priceType(Price.ScalableMatrixWithUnitPricing.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .scalableMatrixWithTieredPricingConfig( - Price.ScalableMatrixWithTieredPricing.ScalableMatrixWithTieredPricingConfig + .scalableMatrixWithUnitPricingConfig( + Price.ScalableMatrixWithUnitPricing.ScalableMatrixWithUnitPricingConfig .builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .firstDimension("first_dimension") + .addMatrixScalingFactor( + Price.ScalableMatrixWithUnitPricing + .ScalableMatrixWithUnitPricingConfig + .MatrixScalingFactor + .builder() + .firstDimensionValue("first_dimension_value") + .scalingFactor("scaling_factor") + .secondDimensionValue("second_dimension_value") + .build() + ) + .unitPrice("unit_price") + .prorate(true) + .secondDimension("second_dimension") .build() ) .dimensionalPriceConfiguration( @@ -6445,9 +6772,9 @@ internal class PriceTest { } @Test - fun ofCumulativeGroupedBulk() { - val cumulativeGroupedBulk = - Price.CumulativeGroupedBulk.builder() + fun ofScalableMatrixWithTieredPricing() { + val scalableMatrixWithTieredPricing = + Price.ScalableMatrixWithTieredPricing.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -6456,7 +6783,7 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .cadence(Price.CumulativeGroupedBulk.Cadence.ONE_TIME) + .cadence(Price.ScalableMatrixWithTieredPricing.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() .field(TransformPriceFilter.Field.PRICE_ID) @@ -6481,11 +6808,6 @@ internal class PriceTest { ) .build() ) - .cumulativeGroupedBulkConfig( - Price.CumulativeGroupedBulk.CumulativeGroupedBulkConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) .currency("currency") .discount( PercentageDiscount.builder() @@ -6527,7 +6849,7 @@ internal class PriceTest { ) .maximumAmount("maximum_amount") .metadata( - Price.CumulativeGroupedBulk.Metadata.builder() + Price.ScalableMatrixWithTieredPricing.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -6547,8 +6869,43 @@ internal class PriceTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.CumulativeGroupedBulk.PriceType.USAGE_PRICE) + .priceType(Price.ScalableMatrixWithTieredPricing.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") + .scalableMatrixWithTieredPricingConfig( + Price.ScalableMatrixWithTieredPricing.ScalableMatrixWithTieredPricingConfig + .builder() + .firstDimension("first_dimension") + .addMatrixScalingFactor( + Price.ScalableMatrixWithTieredPricing + .ScalableMatrixWithTieredPricingConfig + .MatrixScalingFactor + .builder() + .firstDimensionValue("first_dimension_value") + .scalingFactor("scaling_factor") + .secondDimensionValue("second_dimension_value") + .build() + ) + .addTier( + Price.ScalableMatrixWithTieredPricing + .ScalableMatrixWithTieredPricingConfig + .Tier + .builder() + .tierLowerBound("tier_lower_bound") + .unitAmount("unit_amount") + .build() + ) + .addTier( + Price.ScalableMatrixWithTieredPricing + .ScalableMatrixWithTieredPricingConfig + .Tier + .builder() + .tierLowerBound("tier_lower_bound") + .unitAmount("unit_amount") + .build() + ) + .secondDimension("second_dimension") + .build() + ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") @@ -6557,17 +6914,17 @@ internal class PriceTest { ) .build() - val price = Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk) + val price = Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing) assertThat(price.unit()).isNull() - assertThat(price.package_()).isNull() - assertThat(price.matrix()).isNull() assertThat(price.tiered()).isNull() assertThat(price.bulk()).isNull() + assertThat(price.package_()).isNull() + assertThat(price.matrix()).isNull() assertThat(price.thresholdTotalAmount()).isNull() assertThat(price.tieredPackage()).isNull() - assertThat(price.groupedTiered()).isNull() assertThat(price.tieredWithMinimum()).isNull() + assertThat(price.groupedTiered()).isNull() assertThat(price.tieredPackageWithMinimum()).isNull() assertThat(price.packageWithAllocation()).isNull() assertThat(price.unitWithPercent()).isNull() @@ -6575,25 +6932,26 @@ internal class PriceTest { assertThat(price.tieredWithProration()).isNull() assertThat(price.unitWithProration()).isNull() assertThat(price.groupedAllocation()).isNull() + assertThat(price.bulkWithProration()).isNull() assertThat(price.groupedWithProratedMinimum()).isNull() assertThat(price.groupedWithMeteredMinimum()).isNull() + assertThat(price.groupedWithMinMaxThresholds()).isNull() assertThat(price.matrixWithDisplayName()).isNull() - assertThat(price.bulkWithProration()).isNull() assertThat(price.groupedTieredPackage()).isNull() assertThat(price.maxGroupTieredPackage()).isNull() assertThat(price.scalableMatrixWithUnitPricing()).isNull() - assertThat(price.scalableMatrixWithTieredPricing()).isNull() - assertThat(price.cumulativeGroupedBulk()).isEqualTo(cumulativeGroupedBulk) - assertThat(price.groupedWithMinMaxThresholds()).isNull() + assertThat(price.scalableMatrixWithTieredPricing()) + .isEqualTo(scalableMatrixWithTieredPricing) + assertThat(price.cumulativeGroupedBulk()).isNull() assertThat(price.minimum()).isNull() } @Test - fun ofCumulativeGroupedBulkRoundtrip() { + fun ofScalableMatrixWithTieredPricingRoundtrip() { val jsonMapper = jsonMapper() val price = - Price.ofCumulativeGroupedBulk( - Price.CumulativeGroupedBulk.builder() + Price.ofScalableMatrixWithTieredPricing( + Price.ScalableMatrixWithTieredPricing.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -6602,7 +6960,7 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .cadence(Price.CumulativeGroupedBulk.Cadence.ONE_TIME) + .cadence(Price.ScalableMatrixWithTieredPricing.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() .field(TransformPriceFilter.Field.PRICE_ID) @@ -6627,11 +6985,6 @@ internal class PriceTest { ) .build() ) - .cumulativeGroupedBulkConfig( - Price.CumulativeGroupedBulk.CumulativeGroupedBulkConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) .currency("currency") .discount( PercentageDiscount.builder() @@ -6673,7 +7026,7 @@ internal class PriceTest { ) .maximumAmount("maximum_amount") .metadata( - Price.CumulativeGroupedBulk.Metadata.builder() + Price.ScalableMatrixWithTieredPricing.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -6693,8 +7046,43 @@ internal class PriceTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.CumulativeGroupedBulk.PriceType.USAGE_PRICE) + .priceType(Price.ScalableMatrixWithTieredPricing.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") + .scalableMatrixWithTieredPricingConfig( + Price.ScalableMatrixWithTieredPricing.ScalableMatrixWithTieredPricingConfig + .builder() + .firstDimension("first_dimension") + .addMatrixScalingFactor( + Price.ScalableMatrixWithTieredPricing + .ScalableMatrixWithTieredPricingConfig + .MatrixScalingFactor + .builder() + .firstDimensionValue("first_dimension_value") + .scalingFactor("scaling_factor") + .secondDimensionValue("second_dimension_value") + .build() + ) + .addTier( + Price.ScalableMatrixWithTieredPricing + .ScalableMatrixWithTieredPricingConfig + .Tier + .builder() + .tierLowerBound("tier_lower_bound") + .unitAmount("unit_amount") + .build() + ) + .addTier( + Price.ScalableMatrixWithTieredPricing + .ScalableMatrixWithTieredPricingConfig + .Tier + .builder() + .tierLowerBound("tier_lower_bound") + .unitAmount("unit_amount") + .build() + ) + .secondDimension("second_dimension") + .build() + ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") @@ -6711,9 +7099,9 @@ internal class PriceTest { } @Test - fun ofGroupedWithMinMaxThresholds() { - val groupedWithMinMaxThresholds = - Price.GroupedWithMinMaxThresholds.builder() + fun ofCumulativeGroupedBulk() { + val cumulativeGroupedBulk = + Price.CumulativeGroupedBulk.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -6722,7 +7110,7 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .cadence(Price.GroupedWithMinMaxThresholds.Cadence.ONE_TIME) + .cadence(Price.CumulativeGroupedBulk.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() .field(TransformPriceFilter.Field.PRICE_ID) @@ -6747,6 +7135,19 @@ internal class PriceTest { ) .build() ) + .cumulativeGroupedBulkConfig( + Price.CumulativeGroupedBulk.CumulativeGroupedBulkConfig.builder() + .addDimensionValue( + Price.CumulativeGroupedBulk.CumulativeGroupedBulkConfig.DimensionValue + .builder() + .groupingKey("x") + .tierLowerBound("tier_lower_bound") + .unitAmount("unit_amount") + .build() + ) + .group("group") + .build() + ) .currency("currency") .discount( PercentageDiscount.builder() @@ -6766,11 +7167,6 @@ internal class PriceTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) - .groupedWithMinMaxThresholdsConfig( - Price.GroupedWithMinMaxThresholds.GroupedWithMinMaxThresholdsConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -6793,7 +7189,7 @@ internal class PriceTest { ) .maximumAmount("maximum_amount") .metadata( - Price.GroupedWithMinMaxThresholds.Metadata.builder() + Price.CumulativeGroupedBulk.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -6813,7 +7209,7 @@ internal class PriceTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.GroupedWithMinMaxThresholds.PriceType.USAGE_PRICE) + .priceType(Price.CumulativeGroupedBulk.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -6823,17 +7219,17 @@ internal class PriceTest { ) .build() - val price = Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds) + val price = Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk) assertThat(price.unit()).isNull() - assertThat(price.package_()).isNull() - assertThat(price.matrix()).isNull() assertThat(price.tiered()).isNull() assertThat(price.bulk()).isNull() + assertThat(price.package_()).isNull() + assertThat(price.matrix()).isNull() assertThat(price.thresholdTotalAmount()).isNull() assertThat(price.tieredPackage()).isNull() - assertThat(price.groupedTiered()).isNull() assertThat(price.tieredWithMinimum()).isNull() + assertThat(price.groupedTiered()).isNull() assertThat(price.tieredPackageWithMinimum()).isNull() assertThat(price.packageWithAllocation()).isNull() assertThat(price.unitWithPercent()).isNull() @@ -6841,25 +7237,25 @@ internal class PriceTest { assertThat(price.tieredWithProration()).isNull() assertThat(price.unitWithProration()).isNull() assertThat(price.groupedAllocation()).isNull() + assertThat(price.bulkWithProration()).isNull() assertThat(price.groupedWithProratedMinimum()).isNull() assertThat(price.groupedWithMeteredMinimum()).isNull() + assertThat(price.groupedWithMinMaxThresholds()).isNull() assertThat(price.matrixWithDisplayName()).isNull() - assertThat(price.bulkWithProration()).isNull() assertThat(price.groupedTieredPackage()).isNull() assertThat(price.maxGroupTieredPackage()).isNull() assertThat(price.scalableMatrixWithUnitPricing()).isNull() assertThat(price.scalableMatrixWithTieredPricing()).isNull() - assertThat(price.cumulativeGroupedBulk()).isNull() - assertThat(price.groupedWithMinMaxThresholds()).isEqualTo(groupedWithMinMaxThresholds) + assertThat(price.cumulativeGroupedBulk()).isEqualTo(cumulativeGroupedBulk) assertThat(price.minimum()).isNull() } @Test - fun ofGroupedWithMinMaxThresholdsRoundtrip() { + fun ofCumulativeGroupedBulkRoundtrip() { val jsonMapper = jsonMapper() val price = - Price.ofGroupedWithMinMaxThresholds( - Price.GroupedWithMinMaxThresholds.builder() + Price.ofCumulativeGroupedBulk( + Price.CumulativeGroupedBulk.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -6868,7 +7264,7 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .cadence(Price.GroupedWithMinMaxThresholds.Cadence.ONE_TIME) + .cadence(Price.CumulativeGroupedBulk.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() .field(TransformPriceFilter.Field.PRICE_ID) @@ -6893,6 +7289,20 @@ internal class PriceTest { ) .build() ) + .cumulativeGroupedBulkConfig( + Price.CumulativeGroupedBulk.CumulativeGroupedBulkConfig.builder() + .addDimensionValue( + Price.CumulativeGroupedBulk.CumulativeGroupedBulkConfig + .DimensionValue + .builder() + .groupingKey("x") + .tierLowerBound("tier_lower_bound") + .unitAmount("unit_amount") + .build() + ) + .group("group") + .build() + ) .currency("currency") .discount( PercentageDiscount.builder() @@ -6912,12 +7322,6 @@ internal class PriceTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) - .groupedWithMinMaxThresholdsConfig( - Price.GroupedWithMinMaxThresholds.GroupedWithMinMaxThresholdsConfig - .builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -6940,7 +7344,7 @@ internal class PriceTest { ) .maximumAmount("maximum_amount") .metadata( - Price.GroupedWithMinMaxThresholds.Metadata.builder() + Price.CumulativeGroupedBulk.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -6960,7 +7364,7 @@ internal class PriceTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.GroupedWithMinMaxThresholds.PriceType.USAGE_PRICE) + .priceType(Price.CumulativeGroupedBulk.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -7094,14 +7498,14 @@ internal class PriceTest { val price = Price.ofMinimum(minimum) assertThat(price.unit()).isNull() - assertThat(price.package_()).isNull() - assertThat(price.matrix()).isNull() assertThat(price.tiered()).isNull() assertThat(price.bulk()).isNull() + assertThat(price.package_()).isNull() + assertThat(price.matrix()).isNull() assertThat(price.thresholdTotalAmount()).isNull() assertThat(price.tieredPackage()).isNull() - assertThat(price.groupedTiered()).isNull() assertThat(price.tieredWithMinimum()).isNull() + assertThat(price.groupedTiered()).isNull() assertThat(price.tieredPackageWithMinimum()).isNull() assertThat(price.packageWithAllocation()).isNull() assertThat(price.unitWithPercent()).isNull() @@ -7109,16 +7513,16 @@ internal class PriceTest { assertThat(price.tieredWithProration()).isNull() assertThat(price.unitWithProration()).isNull() assertThat(price.groupedAllocation()).isNull() + assertThat(price.bulkWithProration()).isNull() assertThat(price.groupedWithProratedMinimum()).isNull() assertThat(price.groupedWithMeteredMinimum()).isNull() + assertThat(price.groupedWithMinMaxThresholds()).isNull() assertThat(price.matrixWithDisplayName()).isNull() - assertThat(price.bulkWithProration()).isNull() assertThat(price.groupedTieredPackage()).isNull() assertThat(price.maxGroupTieredPackage()).isNull() assertThat(price.scalableMatrixWithUnitPricing()).isNull() assertThat(price.scalableMatrixWithTieredPricing()).isNull() assertThat(price.cumulativeGroupedBulk()).isNull() - assertThat(price.groupedWithMinMaxThresholds()).isNull() assertThat(price.minimum()).isEqualTo(minimum) } diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeApplyResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeApplyResponseTest.kt index 195269460..46e4293f5 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeApplyResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeApplyResponseTest.kt @@ -495,7 +495,10 @@ internal class SubscriptionChangeApplyResponseTest { .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( - UnitConfig.builder().unitAmount("unit_amount").build() + UnitConfig.builder() + .unitAmount("unit_amount") + .scalingFactor(0.0) + .build() ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -665,7 +668,10 @@ internal class SubscriptionChangeApplyResponseTest { .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( - UnitConfig.builder().unitAmount("unit_amount").build() + UnitConfig.builder() + .unitAmount("unit_amount") + .scalingFactor(0.0) + .build() ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -1197,6 +1203,7 @@ internal class SubscriptionChangeApplyResponseTest { .unitConfig( UnitConfig.builder() .unitAmount("unit_amount") + .scalingFactor(0.0) .build() ) .dimensionalPriceConfiguration( @@ -1838,6 +1845,7 @@ internal class SubscriptionChangeApplyResponseTest { .unitConfig( UnitConfig.builder() .unitAmount("unit_amount") + .scalingFactor(0.0) .build() ) .dimensionalPriceConfiguration( @@ -2455,7 +2463,10 @@ internal class SubscriptionChangeApplyResponseTest { .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( - UnitConfig.builder().unitAmount("unit_amount").build() + UnitConfig.builder() + .unitAmount("unit_amount") + .scalingFactor(0.0) + .build() ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -2614,7 +2625,10 @@ internal class SubscriptionChangeApplyResponseTest { .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( - UnitConfig.builder().unitAmount("unit_amount").build() + UnitConfig.builder() + .unitAmount("unit_amount") + .scalingFactor(0.0) + .build() ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -3108,6 +3122,7 @@ internal class SubscriptionChangeApplyResponseTest { .unitConfig( UnitConfig.builder() .unitAmount("unit_amount") + .scalingFactor(0.0) .build() ) .dimensionalPriceConfiguration( @@ -3706,6 +3721,7 @@ internal class SubscriptionChangeApplyResponseTest { .unitConfig( UnitConfig.builder() .unitAmount("unit_amount") + .scalingFactor(0.0) .build() ) .dimensionalPriceConfiguration( @@ -4335,7 +4351,10 @@ internal class SubscriptionChangeApplyResponseTest { .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( - UnitConfig.builder().unitAmount("unit_amount").build() + UnitConfig.builder() + .unitAmount("unit_amount") + .scalingFactor(0.0) + .build() ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -4505,7 +4524,10 @@ internal class SubscriptionChangeApplyResponseTest { .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( - UnitConfig.builder().unitAmount("unit_amount").build() + UnitConfig.builder() + .unitAmount("unit_amount") + .scalingFactor(0.0) + .build() ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -5037,6 +5059,7 @@ internal class SubscriptionChangeApplyResponseTest { .unitConfig( UnitConfig.builder() .unitAmount("unit_amount") + .scalingFactor(0.0) .build() ) .dimensionalPriceConfiguration( @@ -5678,6 +5701,7 @@ internal class SubscriptionChangeApplyResponseTest { .unitConfig( UnitConfig.builder() .unitAmount("unit_amount") + .scalingFactor(0.0) .build() ) .dimensionalPriceConfiguration( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeCancelResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeCancelResponseTest.kt index de8503ace..f53010db1 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeCancelResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeCancelResponseTest.kt @@ -495,7 +495,10 @@ internal class SubscriptionChangeCancelResponseTest { .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( - UnitConfig.builder().unitAmount("unit_amount").build() + UnitConfig.builder() + .unitAmount("unit_amount") + .scalingFactor(0.0) + .build() ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -665,7 +668,10 @@ internal class SubscriptionChangeCancelResponseTest { .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( - UnitConfig.builder().unitAmount("unit_amount").build() + UnitConfig.builder() + .unitAmount("unit_amount") + .scalingFactor(0.0) + .build() ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -1197,6 +1203,7 @@ internal class SubscriptionChangeCancelResponseTest { .unitConfig( UnitConfig.builder() .unitAmount("unit_amount") + .scalingFactor(0.0) .build() ) .dimensionalPriceConfiguration( @@ -1838,6 +1845,7 @@ internal class SubscriptionChangeCancelResponseTest { .unitConfig( UnitConfig.builder() .unitAmount("unit_amount") + .scalingFactor(0.0) .build() ) .dimensionalPriceConfiguration( @@ -2455,7 +2463,10 @@ internal class SubscriptionChangeCancelResponseTest { .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( - UnitConfig.builder().unitAmount("unit_amount").build() + UnitConfig.builder() + .unitAmount("unit_amount") + .scalingFactor(0.0) + .build() ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -2614,7 +2625,10 @@ internal class SubscriptionChangeCancelResponseTest { .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( - UnitConfig.builder().unitAmount("unit_amount").build() + UnitConfig.builder() + .unitAmount("unit_amount") + .scalingFactor(0.0) + .build() ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -3108,6 +3122,7 @@ internal class SubscriptionChangeCancelResponseTest { .unitConfig( UnitConfig.builder() .unitAmount("unit_amount") + .scalingFactor(0.0) .build() ) .dimensionalPriceConfiguration( @@ -3706,6 +3721,7 @@ internal class SubscriptionChangeCancelResponseTest { .unitConfig( UnitConfig.builder() .unitAmount("unit_amount") + .scalingFactor(0.0) .build() ) .dimensionalPriceConfiguration( @@ -4335,7 +4351,10 @@ internal class SubscriptionChangeCancelResponseTest { .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( - UnitConfig.builder().unitAmount("unit_amount").build() + UnitConfig.builder() + .unitAmount("unit_amount") + .scalingFactor(0.0) + .build() ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -4505,7 +4524,10 @@ internal class SubscriptionChangeCancelResponseTest { .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( - UnitConfig.builder().unitAmount("unit_amount").build() + UnitConfig.builder() + .unitAmount("unit_amount") + .scalingFactor(0.0) + .build() ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -5037,6 +5059,7 @@ internal class SubscriptionChangeCancelResponseTest { .unitConfig( UnitConfig.builder() .unitAmount("unit_amount") + .scalingFactor(0.0) .build() ) .dimensionalPriceConfiguration( @@ -5678,6 +5701,7 @@ internal class SubscriptionChangeCancelResponseTest { .unitConfig( UnitConfig.builder() .unitAmount("unit_amount") + .scalingFactor(0.0) .build() ) .dimensionalPriceConfiguration( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeRetrieveResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeRetrieveResponseTest.kt index 7f8cf2c2c..1e1668632 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeRetrieveResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeRetrieveResponseTest.kt @@ -495,7 +495,10 @@ internal class SubscriptionChangeRetrieveResponseTest { .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( - UnitConfig.builder().unitAmount("unit_amount").build() + UnitConfig.builder() + .unitAmount("unit_amount") + .scalingFactor(0.0) + .build() ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -665,7 +668,10 @@ internal class SubscriptionChangeRetrieveResponseTest { .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( - UnitConfig.builder().unitAmount("unit_amount").build() + UnitConfig.builder() + .unitAmount("unit_amount") + .scalingFactor(0.0) + .build() ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -1197,6 +1203,7 @@ internal class SubscriptionChangeRetrieveResponseTest { .unitConfig( UnitConfig.builder() .unitAmount("unit_amount") + .scalingFactor(0.0) .build() ) .dimensionalPriceConfiguration( @@ -1838,6 +1845,7 @@ internal class SubscriptionChangeRetrieveResponseTest { .unitConfig( UnitConfig.builder() .unitAmount("unit_amount") + .scalingFactor(0.0) .build() ) .dimensionalPriceConfiguration( @@ -2455,7 +2463,10 @@ internal class SubscriptionChangeRetrieveResponseTest { .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( - UnitConfig.builder().unitAmount("unit_amount").build() + UnitConfig.builder() + .unitAmount("unit_amount") + .scalingFactor(0.0) + .build() ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -2614,7 +2625,10 @@ internal class SubscriptionChangeRetrieveResponseTest { .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( - UnitConfig.builder().unitAmount("unit_amount").build() + UnitConfig.builder() + .unitAmount("unit_amount") + .scalingFactor(0.0) + .build() ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -3108,6 +3122,7 @@ internal class SubscriptionChangeRetrieveResponseTest { .unitConfig( UnitConfig.builder() .unitAmount("unit_amount") + .scalingFactor(0.0) .build() ) .dimensionalPriceConfiguration( @@ -3706,6 +3721,7 @@ internal class SubscriptionChangeRetrieveResponseTest { .unitConfig( UnitConfig.builder() .unitAmount("unit_amount") + .scalingFactor(0.0) .build() ) .dimensionalPriceConfiguration( @@ -4335,7 +4351,10 @@ internal class SubscriptionChangeRetrieveResponseTest { .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( - UnitConfig.builder().unitAmount("unit_amount").build() + UnitConfig.builder() + .unitAmount("unit_amount") + .scalingFactor(0.0) + .build() ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -4505,7 +4524,10 @@ internal class SubscriptionChangeRetrieveResponseTest { .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( - UnitConfig.builder().unitAmount("unit_amount").build() + UnitConfig.builder() + .unitAmount("unit_amount") + .scalingFactor(0.0) + .build() ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -5037,6 +5059,7 @@ internal class SubscriptionChangeRetrieveResponseTest { .unitConfig( UnitConfig.builder() .unitAmount("unit_amount") + .scalingFactor(0.0) .build() ) .dimensionalPriceConfiguration( @@ -5678,6 +5701,7 @@ internal class SubscriptionChangeRetrieveResponseTest { .unitConfig( UnitConfig.builder() .unitAmount("unit_amount") + .scalingFactor(0.0) .build() ) .dimensionalPriceConfiguration( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionCreateParamsTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionCreateParamsTest.kt index d3bc4d6d3..30903c852 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionCreateParamsTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionCreateParamsTest.kt @@ -77,7 +77,12 @@ internal class SubscriptionCreateParamsTest { .itemId("item_id") .modelType(NewSubscriptionUnitPrice.ModelType.UNIT) .name("Annual fee") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .scalingFactor(0.0) + .build() + ) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( @@ -225,7 +230,12 @@ internal class SubscriptionCreateParamsTest { .itemId("item_id") .modelType(NewSubscriptionUnitPrice.ModelType.UNIT) .name("Annual fee") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .scalingFactor(0.0) + .build() + ) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( @@ -343,7 +353,12 @@ internal class SubscriptionCreateParamsTest { .itemId("item_id") .modelType(NewSubscriptionUnitPrice.ModelType.UNIT) .name("Annual fee") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .scalingFactor(0.0) + .build() + ) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( @@ -493,7 +508,12 @@ internal class SubscriptionCreateParamsTest { .itemId("item_id") .modelType(NewSubscriptionUnitPrice.ModelType.UNIT) .name("Annual fee") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .scalingFactor(0.0) + .build() + ) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( @@ -612,7 +632,12 @@ internal class SubscriptionCreateParamsTest { .itemId("item_id") .modelType(NewSubscriptionUnitPrice.ModelType.UNIT) .name("Annual fee") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .scalingFactor(0.0) + .build() + ) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( @@ -766,7 +791,12 @@ internal class SubscriptionCreateParamsTest { .itemId("item_id") .modelType(NewSubscriptionUnitPrice.ModelType.UNIT) .name("Annual fee") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .scalingFactor(0.0) + .build() + ) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionFetchCostsResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionFetchCostsResponseTest.kt index 3b49cad21..eb256d66d 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionFetchCostsResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionFetchCostsResponseTest.kt @@ -139,7 +139,10 @@ internal class SubscriptionFetchCostsResponseTest { .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( - UnitConfig.builder().unitAmount("unit_amount").build() + UnitConfig.builder() + .unitAmount("unit_amount") + .scalingFactor(0.0) + .build() ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -283,7 +286,10 @@ internal class SubscriptionFetchCostsResponseTest { .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( - UnitConfig.builder().unitAmount("unit_amount").build() + UnitConfig.builder() + .unitAmount("unit_amount") + .scalingFactor(0.0) + .build() ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -436,7 +442,10 @@ internal class SubscriptionFetchCostsResponseTest { .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( - UnitConfig.builder().unitAmount("unit_amount").build() + UnitConfig.builder() + .unitAmount("unit_amount") + .scalingFactor(0.0) + .build() ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsParamsTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsParamsTest.kt index 4e49452d1..0452ccef8 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsParamsTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsParamsTest.kt @@ -49,7 +49,12 @@ internal class SubscriptionPriceIntervalsParamsTest { .itemId("item_id") .modelType(NewFloatingUnitPrice.ModelType.UNIT) .name("Annual fee") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .scalingFactor(0.0) + .build() + ) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( @@ -200,7 +205,12 @@ internal class SubscriptionPriceIntervalsParamsTest { .itemId("item_id") .modelType(NewFloatingUnitPrice.ModelType.UNIT) .name("Annual fee") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .scalingFactor(0.0) + .build() + ) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( @@ -340,7 +350,12 @@ internal class SubscriptionPriceIntervalsParamsTest { .itemId("item_id") .modelType(NewFloatingUnitPrice.ModelType.UNIT) .name("Annual fee") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .scalingFactor(0.0) + .build() + ) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionSchedulePlanChangeParamsTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionSchedulePlanChangeParamsTest.kt index 31bd5b8f7..a44de48ec 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionSchedulePlanChangeParamsTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionSchedulePlanChangeParamsTest.kt @@ -79,7 +79,12 @@ internal class SubscriptionSchedulePlanChangeParamsTest { .itemId("item_id") .modelType(NewSubscriptionUnitPrice.ModelType.UNIT) .name("Annual fee") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .scalingFactor(0.0) + .build() + ) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( @@ -218,7 +223,12 @@ internal class SubscriptionSchedulePlanChangeParamsTest { .itemId("item_id") .modelType(NewSubscriptionUnitPrice.ModelType.UNIT) .name("Annual fee") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .scalingFactor(0.0) + .build() + ) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( @@ -350,7 +360,12 @@ internal class SubscriptionSchedulePlanChangeParamsTest { .itemId("item_id") .modelType(NewSubscriptionUnitPrice.ModelType.UNIT) .name("Annual fee") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .scalingFactor(0.0) + .build() + ) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( @@ -491,7 +506,12 @@ internal class SubscriptionSchedulePlanChangeParamsTest { .itemId("item_id") .modelType(NewSubscriptionUnitPrice.ModelType.UNIT) .name("Annual fee") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .scalingFactor(0.0) + .build() + ) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( @@ -611,7 +631,12 @@ internal class SubscriptionSchedulePlanChangeParamsTest { .itemId("item_id") .modelType(NewSubscriptionUnitPrice.ModelType.UNIT) .name("Annual fee") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .scalingFactor(0.0) + .build() + ) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( @@ -752,7 +777,12 @@ internal class SubscriptionSchedulePlanChangeParamsTest { .itemId("item_id") .modelType(NewSubscriptionUnitPrice.ModelType.UNIT) .name("Annual fee") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .scalingFactor(0.0) + .build() + ) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionTest.kt index 353428029..3e43e496b 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionTest.kt @@ -449,7 +449,12 @@ internal class SubscriptionTest { .planPhaseOrder(0L) .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .scalingFactor(0.0) + .build() + ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") @@ -594,7 +599,12 @@ internal class SubscriptionTest { .planPhaseOrder(0L) .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .scalingFactor(0.0) + .build() + ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") @@ -1068,7 +1078,12 @@ internal class SubscriptionTest { .planPhaseOrder(0L) .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .scalingFactor(0.0) + .build() + ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") @@ -1208,7 +1223,12 @@ internal class SubscriptionTest { .planPhaseOrder(0L) .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .scalingFactor(0.0) + .build() + ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") @@ -1679,7 +1699,12 @@ internal class SubscriptionTest { .planPhaseOrder(0L) .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .scalingFactor(0.0) + .build() + ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") @@ -1824,7 +1849,12 @@ internal class SubscriptionTest { .planPhaseOrder(0L) .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .scalingFactor(0.0) + .build() + ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionsTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionsTest.kt index 55b855b26..d6fc76ebc 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionsTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionsTest.kt @@ -492,7 +492,10 @@ internal class SubscriptionsTest { .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( - UnitConfig.builder().unitAmount("unit_amount").build() + UnitConfig.builder() + .unitAmount("unit_amount") + .scalingFactor(0.0) + .build() ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -662,7 +665,10 @@ internal class SubscriptionsTest { .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( - UnitConfig.builder().unitAmount("unit_amount").build() + UnitConfig.builder() + .unitAmount("unit_amount") + .scalingFactor(0.0) + .build() ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -1162,7 +1168,10 @@ internal class SubscriptionsTest { .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( - UnitConfig.builder().unitAmount("unit_amount").build() + UnitConfig.builder() + .unitAmount("unit_amount") + .scalingFactor(0.0) + .build() ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -1321,7 +1330,10 @@ internal class SubscriptionsTest { .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( - UnitConfig.builder().unitAmount("unit_amount").build() + UnitConfig.builder() + .unitAmount("unit_amount") + .scalingFactor(0.0) + .build() ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -1837,7 +1849,10 @@ internal class SubscriptionsTest { .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( - UnitConfig.builder().unitAmount("unit_amount").build() + UnitConfig.builder() + .unitAmount("unit_amount") + .scalingFactor(0.0) + .build() ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -2007,7 +2022,10 @@ internal class SubscriptionsTest { .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( - UnitConfig.builder().unitAmount("unit_amount").build() + UnitConfig.builder() + .unitAmount("unit_amount") + .scalingFactor(0.0) + .build() ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/TierConfigTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/TierConfigTest.kt deleted file mode 100644 index 2651c40fc..000000000 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/TierConfigTest.kt +++ /dev/null @@ -1,36 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.withorb.api.models - -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.withorb.api.core.jsonMapper -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class TierConfigTest { - - @Test - fun create() { - val tierConfig = - TierConfig.builder().firstUnit(1.0).lastUnit(1000.0).unitAmount("3.00").build() - - assertThat(tierConfig.firstUnit()).isEqualTo(1.0) - assertThat(tierConfig.lastUnit()).isEqualTo(1000.0) - assertThat(tierConfig.unitAmount()).isEqualTo("3.00") - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val tierConfig = - TierConfig.builder().firstUnit(1.0).lastUnit(1000.0).unitAmount("3.00").build() - - val roundtrippedTierConfig = - jsonMapper.readValue( - jsonMapper.writeValueAsString(tierConfig), - jacksonTypeRef(), - ) - - assertThat(roundtrippedTierConfig).isEqualTo(tierConfig) - } -} diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/TierSubLineItemTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/TierSubLineItemTest.kt index db434dc1a..40aafa23b 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/TierSubLineItemTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/TierSubLineItemTest.kt @@ -18,7 +18,11 @@ internal class TierSubLineItemTest { .name("Tier One") .quantity(5.0) .tierConfig( - TierConfig.builder().firstUnit(1.0).lastUnit(1000.0).unitAmount("3.00").build() + TierSubLineItem.TierConfig.builder() + .firstUnit(1.0) + .lastUnit(1000.0) + .unitAmount("3.00") + .build() ) .type(TierSubLineItem.Type.TIER) .build() @@ -30,7 +34,11 @@ internal class TierSubLineItemTest { assertThat(tierSubLineItem.quantity()).isEqualTo(5.0) assertThat(tierSubLineItem.tierConfig()) .isEqualTo( - TierConfig.builder().firstUnit(1.0).lastUnit(1000.0).unitAmount("3.00").build() + TierSubLineItem.TierConfig.builder() + .firstUnit(1.0) + .lastUnit(1000.0) + .unitAmount("3.00") + .build() ) assertThat(tierSubLineItem.type()).isEqualTo(TierSubLineItem.Type.TIER) } @@ -45,7 +53,11 @@ internal class TierSubLineItemTest { .name("Tier One") .quantity(5.0) .tierConfig( - TierConfig.builder().firstUnit(1.0).lastUnit(1000.0).unitAmount("3.00").build() + TierSubLineItem.TierConfig.builder() + .firstUnit(1.0) + .lastUnit(1000.0) + .unitAmount("3.00") + .build() ) .type(TierSubLineItem.Type.TIER) .build() diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/UnitConfigTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/UnitConfigTest.kt index 98fcacade..fda8c0772 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/UnitConfigTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/UnitConfigTest.kt @@ -11,15 +11,16 @@ internal class UnitConfigTest { @Test fun create() { - val unitConfig = UnitConfig.builder().unitAmount("unit_amount").build() + val unitConfig = UnitConfig.builder().unitAmount("unit_amount").scalingFactor(0.0).build() assertThat(unitConfig.unitAmount()).isEqualTo("unit_amount") + assertThat(unitConfig.scalingFactor()).isEqualTo(0.0) } @Test fun roundtrip() { val jsonMapper = jsonMapper() - val unitConfig = UnitConfig.builder().unitAmount("unit_amount").build() + val unitConfig = UnitConfig.builder().unitAmount("unit_amount").scalingFactor(0.0).build() val roundtrippedUnitConfig = jsonMapper.readValue( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/BetaServiceAsyncTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/BetaServiceAsyncTest.kt index d0753d065..0da1859c4 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/BetaServiceAsyncTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/BetaServiceAsyncTest.kt @@ -89,7 +89,10 @@ internal class BetaServiceAsyncTest { .modelType(NewPlanUnitPrice.ModelType.UNIT) .name("Annual fee") .unitConfig( - UnitConfig.builder().unitAmount("unit_amount").build() + UnitConfig.builder() + .unitAmount("unit_amount") + .scalingFactor(0.0) + .build() ) .billableMetricId("billable_metric_id") .billedInAdvance(true) @@ -204,7 +207,10 @@ internal class BetaServiceAsyncTest { .modelType(NewPlanUnitPrice.ModelType.UNIT) .name("Annual fee") .unitConfig( - UnitConfig.builder().unitAmount("unit_amount").build() + UnitConfig.builder() + .unitAmount("unit_amount") + .scalingFactor(0.0) + .build() ) .billableMetricId("billable_metric_id") .billedInAdvance(true) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/InvoiceServiceAsyncTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/InvoiceServiceAsyncTest.kt index 6a2b53fda..ea1bfda7f 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/InvoiceServiceAsyncTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/InvoiceServiceAsyncTest.kt @@ -43,7 +43,12 @@ internal class InvoiceServiceAsyncTest { .name("Line Item Name") .quantity(1.0) .startDate(LocalDate.parse("2023-09-22")) - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .scalingFactor(0.0) + .build() + ) .build() ) .customerId("4khy3nwzktxv7") diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/PlanServiceAsyncTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/PlanServiceAsyncTest.kt index f3e9737d4..163916ec5 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/PlanServiceAsyncTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/PlanServiceAsyncTest.kt @@ -60,7 +60,10 @@ internal class PlanServiceAsyncTest { .modelType(NewPlanUnitPrice.ModelType.UNIT) .name("Annual fee") .unitConfig( - UnitConfig.builder().unitAmount("unit_amount").build() + UnitConfig.builder() + .unitAmount("unit_amount") + .scalingFactor(0.0) + .build() ) .billableMetricId("billable_metric_id") .billedInAdvance(true) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/PriceServiceAsyncTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/PriceServiceAsyncTest.kt index 5fa67c856..fc3d64472 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/PriceServiceAsyncTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/PriceServiceAsyncTest.kt @@ -41,7 +41,12 @@ internal class PriceServiceAsyncTest { .itemId("item_id") .modelType(NewFloatingUnitPrice.ModelType.UNIT) .name("Annual fee") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .scalingFactor(0.0) + .build() + ) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( @@ -179,7 +184,10 @@ internal class PriceServiceAsyncTest { .modelType(NewFloatingUnitPrice.ModelType.UNIT) .name("Annual fee") .unitConfig( - UnitConfig.builder().unitAmount("unit_amount").build() + UnitConfig.builder() + .unitAmount("unit_amount") + .scalingFactor(0.0) + .build() ) .billableMetricId("billable_metric_id") .billedInAdvance(true) @@ -277,7 +285,10 @@ internal class PriceServiceAsyncTest { .modelType(NewFloatingUnitPrice.ModelType.UNIT) .name("Annual fee") .unitConfig( - UnitConfig.builder().unitAmount("unit_amount").build() + UnitConfig.builder() + .unitAmount("unit_amount") + .scalingFactor(0.0) + .build() ) .billableMetricId("billable_metric_id") .billedInAdvance(true) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/SubscriptionServiceAsyncTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/SubscriptionServiceAsyncTest.kt index 4c51566b2..f03b5c503 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/SubscriptionServiceAsyncTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/SubscriptionServiceAsyncTest.kt @@ -116,7 +116,10 @@ internal class SubscriptionServiceAsyncTest { .modelType(NewSubscriptionUnitPrice.ModelType.UNIT) .name("Annual fee") .unitConfig( - UnitConfig.builder().unitAmount("unit_amount").build() + UnitConfig.builder() + .unitAmount("unit_amount") + .scalingFactor(0.0) + .build() ) .billableMetricId("billable_metric_id") .billedInAdvance(true) @@ -272,7 +275,10 @@ internal class SubscriptionServiceAsyncTest { .modelType(NewSubscriptionUnitPrice.ModelType.UNIT) .name("Annual fee") .unitConfig( - UnitConfig.builder().unitAmount("unit_amount").build() + UnitConfig.builder() + .unitAmount("unit_amount") + .scalingFactor(0.0) + .build() ) .billableMetricId("billable_metric_id") .billedInAdvance(true) @@ -528,7 +534,10 @@ internal class SubscriptionServiceAsyncTest { .modelType(NewFloatingUnitPrice.ModelType.UNIT) .name("Annual fee") .unitConfig( - UnitConfig.builder().unitAmount("unit_amount").build() + UnitConfig.builder() + .unitAmount("unit_amount") + .scalingFactor(0.0) + .build() ) .billableMetricId("billable_metric_id") .billedInAdvance(true) @@ -742,7 +751,10 @@ internal class SubscriptionServiceAsyncTest { .modelType(NewSubscriptionUnitPrice.ModelType.UNIT) .name("Annual fee") .unitConfig( - UnitConfig.builder().unitAmount("unit_amount").build() + UnitConfig.builder() + .unitAmount("unit_amount") + .scalingFactor(0.0) + .build() ) .billableMetricId("billable_metric_id") .billedInAdvance(true) @@ -889,7 +901,10 @@ internal class SubscriptionServiceAsyncTest { .modelType(NewSubscriptionUnitPrice.ModelType.UNIT) .name("Annual fee") .unitConfig( - UnitConfig.builder().unitAmount("unit_amount").build() + UnitConfig.builder() + .unitAmount("unit_amount") + .scalingFactor(0.0) + .build() ) .billableMetricId("billable_metric_id") .billedInAdvance(true) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/beta/ExternalPlanIdServiceAsyncTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/beta/ExternalPlanIdServiceAsyncTest.kt index 2b99ad625..12bff3091 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/beta/ExternalPlanIdServiceAsyncTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/beta/ExternalPlanIdServiceAsyncTest.kt @@ -89,7 +89,10 @@ internal class ExternalPlanIdServiceAsyncTest { .modelType(NewPlanUnitPrice.ModelType.UNIT) .name("Annual fee") .unitConfig( - UnitConfig.builder().unitAmount("unit_amount").build() + UnitConfig.builder() + .unitAmount("unit_amount") + .scalingFactor(0.0) + .build() ) .billableMetricId("billable_metric_id") .billedInAdvance(true) @@ -204,7 +207,10 @@ internal class ExternalPlanIdServiceAsyncTest { .modelType(NewPlanUnitPrice.ModelType.UNIT) .name("Annual fee") .unitConfig( - UnitConfig.builder().unitAmount("unit_amount").build() + UnitConfig.builder() + .unitAmount("unit_amount") + .scalingFactor(0.0) + .build() ) .billableMetricId("billable_metric_id") .billedInAdvance(true) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/BetaServiceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/BetaServiceTest.kt index 24e977345..a868b67a2 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/BetaServiceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/BetaServiceTest.kt @@ -89,7 +89,10 @@ internal class BetaServiceTest { .modelType(NewPlanUnitPrice.ModelType.UNIT) .name("Annual fee") .unitConfig( - UnitConfig.builder().unitAmount("unit_amount").build() + UnitConfig.builder() + .unitAmount("unit_amount") + .scalingFactor(0.0) + .build() ) .billableMetricId("billable_metric_id") .billedInAdvance(true) @@ -204,7 +207,10 @@ internal class BetaServiceTest { .modelType(NewPlanUnitPrice.ModelType.UNIT) .name("Annual fee") .unitConfig( - UnitConfig.builder().unitAmount("unit_amount").build() + UnitConfig.builder() + .unitAmount("unit_amount") + .scalingFactor(0.0) + .build() ) .billableMetricId("billable_metric_id") .billedInAdvance(true) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/InvoiceServiceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/InvoiceServiceTest.kt index 367768764..ba4667c8e 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/InvoiceServiceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/InvoiceServiceTest.kt @@ -43,7 +43,12 @@ internal class InvoiceServiceTest { .name("Line Item Name") .quantity(1.0) .startDate(LocalDate.parse("2023-09-22")) - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .scalingFactor(0.0) + .build() + ) .build() ) .customerId("4khy3nwzktxv7") diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/PlanServiceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/PlanServiceTest.kt index b3af60641..3b962be3d 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/PlanServiceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/PlanServiceTest.kt @@ -60,7 +60,10 @@ internal class PlanServiceTest { .modelType(NewPlanUnitPrice.ModelType.UNIT) .name("Annual fee") .unitConfig( - UnitConfig.builder().unitAmount("unit_amount").build() + UnitConfig.builder() + .unitAmount("unit_amount") + .scalingFactor(0.0) + .build() ) .billableMetricId("billable_metric_id") .billedInAdvance(true) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/PriceServiceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/PriceServiceTest.kt index e11ed1229..defea2442 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/PriceServiceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/PriceServiceTest.kt @@ -41,7 +41,12 @@ internal class PriceServiceTest { .itemId("item_id") .modelType(NewFloatingUnitPrice.ModelType.UNIT) .name("Annual fee") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .scalingFactor(0.0) + .build() + ) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( @@ -179,7 +184,10 @@ internal class PriceServiceTest { .modelType(NewFloatingUnitPrice.ModelType.UNIT) .name("Annual fee") .unitConfig( - UnitConfig.builder().unitAmount("unit_amount").build() + UnitConfig.builder() + .unitAmount("unit_amount") + .scalingFactor(0.0) + .build() ) .billableMetricId("billable_metric_id") .billedInAdvance(true) @@ -277,7 +285,10 @@ internal class PriceServiceTest { .modelType(NewFloatingUnitPrice.ModelType.UNIT) .name("Annual fee") .unitConfig( - UnitConfig.builder().unitAmount("unit_amount").build() + UnitConfig.builder() + .unitAmount("unit_amount") + .scalingFactor(0.0) + .build() ) .billableMetricId("billable_metric_id") .billedInAdvance(true) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/SubscriptionServiceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/SubscriptionServiceTest.kt index 2d6d063a8..3e86edebd 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/SubscriptionServiceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/SubscriptionServiceTest.kt @@ -116,7 +116,10 @@ internal class SubscriptionServiceTest { .modelType(NewSubscriptionUnitPrice.ModelType.UNIT) .name("Annual fee") .unitConfig( - UnitConfig.builder().unitAmount("unit_amount").build() + UnitConfig.builder() + .unitAmount("unit_amount") + .scalingFactor(0.0) + .build() ) .billableMetricId("billable_metric_id") .billedInAdvance(true) @@ -272,7 +275,10 @@ internal class SubscriptionServiceTest { .modelType(NewSubscriptionUnitPrice.ModelType.UNIT) .name("Annual fee") .unitConfig( - UnitConfig.builder().unitAmount("unit_amount").build() + UnitConfig.builder() + .unitAmount("unit_amount") + .scalingFactor(0.0) + .build() ) .billableMetricId("billable_metric_id") .billedInAdvance(true) @@ -528,7 +534,10 @@ internal class SubscriptionServiceTest { .modelType(NewFloatingUnitPrice.ModelType.UNIT) .name("Annual fee") .unitConfig( - UnitConfig.builder().unitAmount("unit_amount").build() + UnitConfig.builder() + .unitAmount("unit_amount") + .scalingFactor(0.0) + .build() ) .billableMetricId("billable_metric_id") .billedInAdvance(true) @@ -742,7 +751,10 @@ internal class SubscriptionServiceTest { .modelType(NewSubscriptionUnitPrice.ModelType.UNIT) .name("Annual fee") .unitConfig( - UnitConfig.builder().unitAmount("unit_amount").build() + UnitConfig.builder() + .unitAmount("unit_amount") + .scalingFactor(0.0) + .build() ) .billableMetricId("billable_metric_id") .billedInAdvance(true) @@ -889,7 +901,10 @@ internal class SubscriptionServiceTest { .modelType(NewSubscriptionUnitPrice.ModelType.UNIT) .name("Annual fee") .unitConfig( - UnitConfig.builder().unitAmount("unit_amount").build() + UnitConfig.builder() + .unitAmount("unit_amount") + .scalingFactor(0.0) + .build() ) .billableMetricId("billable_metric_id") .billedInAdvance(true) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/beta/ExternalPlanIdServiceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/beta/ExternalPlanIdServiceTest.kt index f8208215c..c5c7b9948 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/beta/ExternalPlanIdServiceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/beta/ExternalPlanIdServiceTest.kt @@ -89,7 +89,10 @@ internal class ExternalPlanIdServiceTest { .modelType(NewPlanUnitPrice.ModelType.UNIT) .name("Annual fee") .unitConfig( - UnitConfig.builder().unitAmount("unit_amount").build() + UnitConfig.builder() + .unitAmount("unit_amount") + .scalingFactor(0.0) + .build() ) .billableMetricId("billable_metric_id") .billedInAdvance(true) @@ -204,7 +207,10 @@ internal class ExternalPlanIdServiceTest { .modelType(NewPlanUnitPrice.ModelType.UNIT) .name("Annual fee") .unitConfig( - UnitConfig.builder().unitAmount("unit_amount").build() + UnitConfig.builder() + .unitAmount("unit_amount") + .scalingFactor(0.0) + .build() ) .billableMetricId("billable_metric_id") .billedInAdvance(true) From ee76ab871131d964501afbc390d2ba11595003bd Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 5 Sep 2025 00:32:46 +0000 Subject: [PATCH 13/68] feat(api): api update --- .stats.yml | 4 +- .../kotlin/com/withorb/api/models/Price.kt | 162 ++++++++++++++++++ 2 files changed, 164 insertions(+), 2 deletions(-) diff --git a/.stats.yml b/.stats.yml index 9f1d47fda..f45717774 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 118 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-9dda3e74d276c581c08bea0cad47ae390143d94640f267d827caf234301f2721.yml -openapi_spec_hash: 60daf7a378cdf7dd1f7338c303e2d661 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-d63c8075b48441663736b457f8ad859c58cc3e31dfbffb68db44c3f00562012c.yml +openapi_spec_hash: c47dbff685a0a449bfc1ad729c13a72e config_hash: 1f73a949b649ecfe6ec68ba1bb459dc2 diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Price.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Price.kt index e3217ab4f..5a03b75c3 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Price.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Price.kt @@ -2658,6 +2658,8 @@ private constructor( val FIXED_PRICE = of("fixed_price") + val COMPOSITE_PRICE = of("composite_price") + fun of(value: String) = PriceType(JsonField.of(value)) } @@ -2665,6 +2667,7 @@ private constructor( enum class Known { USAGE_PRICE, FIXED_PRICE, + COMPOSITE_PRICE, } /** @@ -2679,6 +2682,7 @@ private constructor( enum class Value { USAGE_PRICE, FIXED_PRICE, + COMPOSITE_PRICE, /** * An enum member indicating that [PriceType] was instantiated with an unknown * value. @@ -2697,6 +2701,7 @@ private constructor( when (this) { USAGE_PRICE -> Value.USAGE_PRICE FIXED_PRICE -> Value.FIXED_PRICE + COMPOSITE_PRICE -> Value.COMPOSITE_PRICE else -> Value._UNKNOWN } @@ -2713,6 +2718,7 @@ private constructor( when (this) { USAGE_PRICE -> Known.USAGE_PRICE FIXED_PRICE -> Known.FIXED_PRICE + COMPOSITE_PRICE -> Known.COMPOSITE_PRICE else -> throw OrbInvalidDataException("Unknown PriceType: $value") } @@ -4492,6 +4498,8 @@ private constructor( val FIXED_PRICE = of("fixed_price") + val COMPOSITE_PRICE = of("composite_price") + fun of(value: String) = PriceType(JsonField.of(value)) } @@ -4499,6 +4507,7 @@ private constructor( enum class Known { USAGE_PRICE, FIXED_PRICE, + COMPOSITE_PRICE, } /** @@ -4513,6 +4522,7 @@ private constructor( enum class Value { USAGE_PRICE, FIXED_PRICE, + COMPOSITE_PRICE, /** * An enum member indicating that [PriceType] was instantiated with an unknown * value. @@ -4531,6 +4541,7 @@ private constructor( when (this) { USAGE_PRICE -> Value.USAGE_PRICE FIXED_PRICE -> Value.FIXED_PRICE + COMPOSITE_PRICE -> Value.COMPOSITE_PRICE else -> Value._UNKNOWN } @@ -4547,6 +4558,7 @@ private constructor( when (this) { USAGE_PRICE -> Known.USAGE_PRICE FIXED_PRICE -> Known.FIXED_PRICE + COMPOSITE_PRICE -> Known.COMPOSITE_PRICE else -> throw OrbInvalidDataException("Unknown PriceType: $value") } @@ -6325,6 +6337,8 @@ private constructor( val FIXED_PRICE = of("fixed_price") + val COMPOSITE_PRICE = of("composite_price") + fun of(value: String) = PriceType(JsonField.of(value)) } @@ -6332,6 +6346,7 @@ private constructor( enum class Known { USAGE_PRICE, FIXED_PRICE, + COMPOSITE_PRICE, } /** @@ -6346,6 +6361,7 @@ private constructor( enum class Value { USAGE_PRICE, FIXED_PRICE, + COMPOSITE_PRICE, /** * An enum member indicating that [PriceType] was instantiated with an unknown * value. @@ -6364,6 +6380,7 @@ private constructor( when (this) { USAGE_PRICE -> Value.USAGE_PRICE FIXED_PRICE -> Value.FIXED_PRICE + COMPOSITE_PRICE -> Value.COMPOSITE_PRICE else -> Value._UNKNOWN } @@ -6380,6 +6397,7 @@ private constructor( when (this) { USAGE_PRICE -> Known.USAGE_PRICE FIXED_PRICE -> Known.FIXED_PRICE + COMPOSITE_PRICE -> Known.COMPOSITE_PRICE else -> throw OrbInvalidDataException("Unknown PriceType: $value") } @@ -8160,6 +8178,8 @@ private constructor( val FIXED_PRICE = of("fixed_price") + val COMPOSITE_PRICE = of("composite_price") + fun of(value: String) = PriceType(JsonField.of(value)) } @@ -8167,6 +8187,7 @@ private constructor( enum class Known { USAGE_PRICE, FIXED_PRICE, + COMPOSITE_PRICE, } /** @@ -8181,6 +8202,7 @@ private constructor( enum class Value { USAGE_PRICE, FIXED_PRICE, + COMPOSITE_PRICE, /** * An enum member indicating that [PriceType] was instantiated with an unknown * value. @@ -8199,6 +8221,7 @@ private constructor( when (this) { USAGE_PRICE -> Value.USAGE_PRICE FIXED_PRICE -> Value.FIXED_PRICE + COMPOSITE_PRICE -> Value.COMPOSITE_PRICE else -> Value._UNKNOWN } @@ -8215,6 +8238,7 @@ private constructor( when (this) { USAGE_PRICE -> Known.USAGE_PRICE FIXED_PRICE -> Known.FIXED_PRICE + COMPOSITE_PRICE -> Known.COMPOSITE_PRICE else -> throw OrbInvalidDataException("Unknown PriceType: $value") } @@ -9994,6 +10018,8 @@ private constructor( val FIXED_PRICE = of("fixed_price") + val COMPOSITE_PRICE = of("composite_price") + fun of(value: String) = PriceType(JsonField.of(value)) } @@ -10001,6 +10027,7 @@ private constructor( enum class Known { USAGE_PRICE, FIXED_PRICE, + COMPOSITE_PRICE, } /** @@ -10015,6 +10042,7 @@ private constructor( enum class Value { USAGE_PRICE, FIXED_PRICE, + COMPOSITE_PRICE, /** * An enum member indicating that [PriceType] was instantiated with an unknown * value. @@ -10033,6 +10061,7 @@ private constructor( when (this) { USAGE_PRICE -> Value.USAGE_PRICE FIXED_PRICE -> Value.FIXED_PRICE + COMPOSITE_PRICE -> Value.COMPOSITE_PRICE else -> Value._UNKNOWN } @@ -10049,6 +10078,7 @@ private constructor( when (this) { USAGE_PRICE -> Known.USAGE_PRICE FIXED_PRICE -> Known.FIXED_PRICE + COMPOSITE_PRICE -> Known.COMPOSITE_PRICE else -> throw OrbInvalidDataException("Unknown PriceType: $value") } @@ -11832,6 +11862,8 @@ private constructor( val FIXED_PRICE = of("fixed_price") + val COMPOSITE_PRICE = of("composite_price") + fun of(value: String) = PriceType(JsonField.of(value)) } @@ -11839,6 +11871,7 @@ private constructor( enum class Known { USAGE_PRICE, FIXED_PRICE, + COMPOSITE_PRICE, } /** @@ -11853,6 +11886,7 @@ private constructor( enum class Value { USAGE_PRICE, FIXED_PRICE, + COMPOSITE_PRICE, /** * An enum member indicating that [PriceType] was instantiated with an unknown * value. @@ -11871,6 +11905,7 @@ private constructor( when (this) { USAGE_PRICE -> Value.USAGE_PRICE FIXED_PRICE -> Value.FIXED_PRICE + COMPOSITE_PRICE -> Value.COMPOSITE_PRICE else -> Value._UNKNOWN } @@ -11887,6 +11922,7 @@ private constructor( when (this) { USAGE_PRICE -> Known.USAGE_PRICE FIXED_PRICE -> Known.FIXED_PRICE + COMPOSITE_PRICE -> Known.COMPOSITE_PRICE else -> throw OrbInvalidDataException("Unknown PriceType: $value") } @@ -14125,6 +14161,8 @@ private constructor( val FIXED_PRICE = of("fixed_price") + val COMPOSITE_PRICE = of("composite_price") + fun of(value: String) = PriceType(JsonField.of(value)) } @@ -14132,6 +14170,7 @@ private constructor( enum class Known { USAGE_PRICE, FIXED_PRICE, + COMPOSITE_PRICE, } /** @@ -14146,6 +14185,7 @@ private constructor( enum class Value { USAGE_PRICE, FIXED_PRICE, + COMPOSITE_PRICE, /** * An enum member indicating that [PriceType] was instantiated with an unknown * value. @@ -14164,6 +14204,7 @@ private constructor( when (this) { USAGE_PRICE -> Value.USAGE_PRICE FIXED_PRICE -> Value.FIXED_PRICE + COMPOSITE_PRICE -> Value.COMPOSITE_PRICE else -> Value._UNKNOWN } @@ -14180,6 +14221,7 @@ private constructor( when (this) { USAGE_PRICE -> Known.USAGE_PRICE FIXED_PRICE -> Known.FIXED_PRICE + COMPOSITE_PRICE -> Known.COMPOSITE_PRICE else -> throw OrbInvalidDataException("Unknown PriceType: $value") } @@ -16408,6 +16450,8 @@ private constructor( val FIXED_PRICE = of("fixed_price") + val COMPOSITE_PRICE = of("composite_price") + fun of(value: String) = PriceType(JsonField.of(value)) } @@ -16415,6 +16459,7 @@ private constructor( enum class Known { USAGE_PRICE, FIXED_PRICE, + COMPOSITE_PRICE, } /** @@ -16429,6 +16474,7 @@ private constructor( enum class Value { USAGE_PRICE, FIXED_PRICE, + COMPOSITE_PRICE, /** * An enum member indicating that [PriceType] was instantiated with an unknown * value. @@ -16447,6 +16493,7 @@ private constructor( when (this) { USAGE_PRICE -> Value.USAGE_PRICE FIXED_PRICE -> Value.FIXED_PRICE + COMPOSITE_PRICE -> Value.COMPOSITE_PRICE else -> Value._UNKNOWN } @@ -16463,6 +16510,7 @@ private constructor( when (this) { USAGE_PRICE -> Known.USAGE_PRICE FIXED_PRICE -> Known.FIXED_PRICE + COMPOSITE_PRICE -> Known.COMPOSITE_PRICE else -> throw OrbInvalidDataException("Unknown PriceType: $value") } @@ -19226,6 +19274,8 @@ private constructor( val FIXED_PRICE = of("fixed_price") + val COMPOSITE_PRICE = of("composite_price") + fun of(value: String) = PriceType(JsonField.of(value)) } @@ -19233,6 +19283,7 @@ private constructor( enum class Known { USAGE_PRICE, FIXED_PRICE, + COMPOSITE_PRICE, } /** @@ -19247,6 +19298,7 @@ private constructor( enum class Value { USAGE_PRICE, FIXED_PRICE, + COMPOSITE_PRICE, /** * An enum member indicating that [PriceType] was instantiated with an unknown * value. @@ -19265,6 +19317,7 @@ private constructor( when (this) { USAGE_PRICE -> Value.USAGE_PRICE FIXED_PRICE -> Value.FIXED_PRICE + COMPOSITE_PRICE -> Value.COMPOSITE_PRICE else -> Value._UNKNOWN } @@ -19281,6 +19334,7 @@ private constructor( when (this) { USAGE_PRICE -> Known.USAGE_PRICE FIXED_PRICE -> Known.FIXED_PRICE + COMPOSITE_PRICE -> Known.COMPOSITE_PRICE else -> throw OrbInvalidDataException("Unknown PriceType: $value") } @@ -21071,6 +21125,8 @@ private constructor( val FIXED_PRICE = of("fixed_price") + val COMPOSITE_PRICE = of("composite_price") + fun of(value: String) = PriceType(JsonField.of(value)) } @@ -21078,6 +21134,7 @@ private constructor( enum class Known { USAGE_PRICE, FIXED_PRICE, + COMPOSITE_PRICE, } /** @@ -21092,6 +21149,7 @@ private constructor( enum class Value { USAGE_PRICE, FIXED_PRICE, + COMPOSITE_PRICE, /** * An enum member indicating that [PriceType] was instantiated with an unknown * value. @@ -21110,6 +21168,7 @@ private constructor( when (this) { USAGE_PRICE -> Value.USAGE_PRICE FIXED_PRICE -> Value.FIXED_PRICE + COMPOSITE_PRICE -> Value.COMPOSITE_PRICE else -> Value._UNKNOWN } @@ -21126,6 +21185,7 @@ private constructor( when (this) { USAGE_PRICE -> Known.USAGE_PRICE FIXED_PRICE -> Known.FIXED_PRICE + COMPOSITE_PRICE -> Known.COMPOSITE_PRICE else -> throw OrbInvalidDataException("Unknown PriceType: $value") } @@ -23671,6 +23731,8 @@ private constructor( val FIXED_PRICE = of("fixed_price") + val COMPOSITE_PRICE = of("composite_price") + fun of(value: String) = PriceType(JsonField.of(value)) } @@ -23678,6 +23740,7 @@ private constructor( enum class Known { USAGE_PRICE, FIXED_PRICE, + COMPOSITE_PRICE, } /** @@ -23692,6 +23755,7 @@ private constructor( enum class Value { USAGE_PRICE, FIXED_PRICE, + COMPOSITE_PRICE, /** * An enum member indicating that [PriceType] was instantiated with an unknown * value. @@ -23710,6 +23774,7 @@ private constructor( when (this) { USAGE_PRICE -> Value.USAGE_PRICE FIXED_PRICE -> Value.FIXED_PRICE + COMPOSITE_PRICE -> Value.COMPOSITE_PRICE else -> Value._UNKNOWN } @@ -23726,6 +23791,7 @@ private constructor( when (this) { USAGE_PRICE -> Known.USAGE_PRICE FIXED_PRICE -> Known.FIXED_PRICE + COMPOSITE_PRICE -> Known.COMPOSITE_PRICE else -> throw OrbInvalidDataException("Unknown PriceType: $value") } @@ -25509,6 +25575,8 @@ private constructor( val FIXED_PRICE = of("fixed_price") + val COMPOSITE_PRICE = of("composite_price") + fun of(value: String) = PriceType(JsonField.of(value)) } @@ -25516,6 +25584,7 @@ private constructor( enum class Known { USAGE_PRICE, FIXED_PRICE, + COMPOSITE_PRICE, } /** @@ -25530,6 +25599,7 @@ private constructor( enum class Value { USAGE_PRICE, FIXED_PRICE, + COMPOSITE_PRICE, /** * An enum member indicating that [PriceType] was instantiated with an unknown * value. @@ -25548,6 +25618,7 @@ private constructor( when (this) { USAGE_PRICE -> Value.USAGE_PRICE FIXED_PRICE -> Value.FIXED_PRICE + COMPOSITE_PRICE -> Value.COMPOSITE_PRICE else -> Value._UNKNOWN } @@ -25564,6 +25635,7 @@ private constructor( when (this) { USAGE_PRICE -> Known.USAGE_PRICE FIXED_PRICE -> Known.FIXED_PRICE + COMPOSITE_PRICE -> Known.COMPOSITE_PRICE else -> throw OrbInvalidDataException("Unknown PriceType: $value") } @@ -27560,6 +27632,8 @@ private constructor( val FIXED_PRICE = of("fixed_price") + val COMPOSITE_PRICE = of("composite_price") + fun of(value: String) = PriceType(JsonField.of(value)) } @@ -27567,6 +27641,7 @@ private constructor( enum class Known { USAGE_PRICE, FIXED_PRICE, + COMPOSITE_PRICE, } /** @@ -27581,6 +27656,7 @@ private constructor( enum class Value { USAGE_PRICE, FIXED_PRICE, + COMPOSITE_PRICE, /** * An enum member indicating that [PriceType] was instantiated with an unknown * value. @@ -27599,6 +27675,7 @@ private constructor( when (this) { USAGE_PRICE -> Value.USAGE_PRICE FIXED_PRICE -> Value.FIXED_PRICE + COMPOSITE_PRICE -> Value.COMPOSITE_PRICE else -> Value._UNKNOWN } @@ -27615,6 +27692,7 @@ private constructor( when (this) { USAGE_PRICE -> Known.USAGE_PRICE FIXED_PRICE -> Known.FIXED_PRICE + COMPOSITE_PRICE -> Known.COMPOSITE_PRICE else -> throw OrbInvalidDataException("Unknown PriceType: $value") } @@ -29398,6 +29476,8 @@ private constructor( val FIXED_PRICE = of("fixed_price") + val COMPOSITE_PRICE = of("composite_price") + fun of(value: String) = PriceType(JsonField.of(value)) } @@ -29405,6 +29485,7 @@ private constructor( enum class Known { USAGE_PRICE, FIXED_PRICE, + COMPOSITE_PRICE, } /** @@ -29419,6 +29500,7 @@ private constructor( enum class Value { USAGE_PRICE, FIXED_PRICE, + COMPOSITE_PRICE, /** * An enum member indicating that [PriceType] was instantiated with an unknown * value. @@ -29437,6 +29519,7 @@ private constructor( when (this) { USAGE_PRICE -> Value.USAGE_PRICE FIXED_PRICE -> Value.FIXED_PRICE + COMPOSITE_PRICE -> Value.COMPOSITE_PRICE else -> Value._UNKNOWN } @@ -29453,6 +29536,7 @@ private constructor( when (this) { USAGE_PRICE -> Known.USAGE_PRICE FIXED_PRICE -> Known.FIXED_PRICE + COMPOSITE_PRICE -> Known.COMPOSITE_PRICE else -> throw OrbInvalidDataException("Unknown PriceType: $value") } @@ -31637,6 +31721,8 @@ private constructor( val FIXED_PRICE = of("fixed_price") + val COMPOSITE_PRICE = of("composite_price") + fun of(value: String) = PriceType(JsonField.of(value)) } @@ -31644,6 +31730,7 @@ private constructor( enum class Known { USAGE_PRICE, FIXED_PRICE, + COMPOSITE_PRICE, } /** @@ -31658,6 +31745,7 @@ private constructor( enum class Value { USAGE_PRICE, FIXED_PRICE, + COMPOSITE_PRICE, /** * An enum member indicating that [PriceType] was instantiated with an unknown * value. @@ -31676,6 +31764,7 @@ private constructor( when (this) { USAGE_PRICE -> Value.USAGE_PRICE FIXED_PRICE -> Value.FIXED_PRICE + COMPOSITE_PRICE -> Value.COMPOSITE_PRICE else -> Value._UNKNOWN } @@ -31692,6 +31781,7 @@ private constructor( when (this) { USAGE_PRICE -> Known.USAGE_PRICE FIXED_PRICE -> Known.FIXED_PRICE + COMPOSITE_PRICE -> Known.COMPOSITE_PRICE else -> throw OrbInvalidDataException("Unknown PriceType: $value") } @@ -33910,6 +34000,8 @@ private constructor( val FIXED_PRICE = of("fixed_price") + val COMPOSITE_PRICE = of("composite_price") + fun of(value: String) = PriceType(JsonField.of(value)) } @@ -33917,6 +34009,7 @@ private constructor( enum class Known { USAGE_PRICE, FIXED_PRICE, + COMPOSITE_PRICE, } /** @@ -33931,6 +34024,7 @@ private constructor( enum class Value { USAGE_PRICE, FIXED_PRICE, + COMPOSITE_PRICE, /** * An enum member indicating that [PriceType] was instantiated with an unknown * value. @@ -33949,6 +34043,7 @@ private constructor( when (this) { USAGE_PRICE -> Value.USAGE_PRICE FIXED_PRICE -> Value.FIXED_PRICE + COMPOSITE_PRICE -> Value.COMPOSITE_PRICE else -> Value._UNKNOWN } @@ -33965,6 +34060,7 @@ private constructor( when (this) { USAGE_PRICE -> Known.USAGE_PRICE FIXED_PRICE -> Known.FIXED_PRICE + COMPOSITE_PRICE -> Known.COMPOSITE_PRICE else -> throw OrbInvalidDataException("Unknown PriceType: $value") } @@ -36142,6 +36238,8 @@ private constructor( val FIXED_PRICE = of("fixed_price") + val COMPOSITE_PRICE = of("composite_price") + fun of(value: String) = PriceType(JsonField.of(value)) } @@ -36149,6 +36247,7 @@ private constructor( enum class Known { USAGE_PRICE, FIXED_PRICE, + COMPOSITE_PRICE, } /** @@ -36163,6 +36262,7 @@ private constructor( enum class Value { USAGE_PRICE, FIXED_PRICE, + COMPOSITE_PRICE, /** * An enum member indicating that [PriceType] was instantiated with an unknown * value. @@ -36181,6 +36281,7 @@ private constructor( when (this) { USAGE_PRICE -> Value.USAGE_PRICE FIXED_PRICE -> Value.FIXED_PRICE + COMPOSITE_PRICE -> Value.COMPOSITE_PRICE else -> Value._UNKNOWN } @@ -36197,6 +36298,7 @@ private constructor( when (this) { USAGE_PRICE -> Known.USAGE_PRICE FIXED_PRICE -> Known.FIXED_PRICE + COMPOSITE_PRICE -> Known.COMPOSITE_PRICE else -> throw OrbInvalidDataException("Unknown PriceType: $value") } @@ -38250,6 +38352,8 @@ private constructor( val FIXED_PRICE = of("fixed_price") + val COMPOSITE_PRICE = of("composite_price") + fun of(value: String) = PriceType(JsonField.of(value)) } @@ -38257,6 +38361,7 @@ private constructor( enum class Known { USAGE_PRICE, FIXED_PRICE, + COMPOSITE_PRICE, } /** @@ -38271,6 +38376,7 @@ private constructor( enum class Value { USAGE_PRICE, FIXED_PRICE, + COMPOSITE_PRICE, /** * An enum member indicating that [PriceType] was instantiated with an unknown * value. @@ -38289,6 +38395,7 @@ private constructor( when (this) { USAGE_PRICE -> Value.USAGE_PRICE FIXED_PRICE -> Value.FIXED_PRICE + COMPOSITE_PRICE -> Value.COMPOSITE_PRICE else -> Value._UNKNOWN } @@ -38305,6 +38412,7 @@ private constructor( when (this) { USAGE_PRICE -> Known.USAGE_PRICE FIXED_PRICE -> Known.FIXED_PRICE + COMPOSITE_PRICE -> Known.COMPOSITE_PRICE else -> throw OrbInvalidDataException("Unknown PriceType: $value") } @@ -40991,6 +41099,8 @@ private constructor( val FIXED_PRICE = of("fixed_price") + val COMPOSITE_PRICE = of("composite_price") + fun of(value: String) = PriceType(JsonField.of(value)) } @@ -40998,6 +41108,7 @@ private constructor( enum class Known { USAGE_PRICE, FIXED_PRICE, + COMPOSITE_PRICE, } /** @@ -41012,6 +41123,7 @@ private constructor( enum class Value { USAGE_PRICE, FIXED_PRICE, + COMPOSITE_PRICE, /** * An enum member indicating that [PriceType] was instantiated with an unknown * value. @@ -41030,6 +41142,7 @@ private constructor( when (this) { USAGE_PRICE -> Value.USAGE_PRICE FIXED_PRICE -> Value.FIXED_PRICE + COMPOSITE_PRICE -> Value.COMPOSITE_PRICE else -> Value._UNKNOWN } @@ -41046,6 +41159,7 @@ private constructor( when (this) { USAGE_PRICE -> Known.USAGE_PRICE FIXED_PRICE -> Known.FIXED_PRICE + COMPOSITE_PRICE -> Known.COMPOSITE_PRICE else -> throw OrbInvalidDataException("Unknown PriceType: $value") } @@ -43162,6 +43276,8 @@ private constructor( val FIXED_PRICE = of("fixed_price") + val COMPOSITE_PRICE = of("composite_price") + fun of(value: String) = PriceType(JsonField.of(value)) } @@ -43169,6 +43285,7 @@ private constructor( enum class Known { USAGE_PRICE, FIXED_PRICE, + COMPOSITE_PRICE, } /** @@ -43183,6 +43300,7 @@ private constructor( enum class Value { USAGE_PRICE, FIXED_PRICE, + COMPOSITE_PRICE, /** * An enum member indicating that [PriceType] was instantiated with an unknown * value. @@ -43201,6 +43319,7 @@ private constructor( when (this) { USAGE_PRICE -> Value.USAGE_PRICE FIXED_PRICE -> Value.FIXED_PRICE + COMPOSITE_PRICE -> Value.COMPOSITE_PRICE else -> Value._UNKNOWN } @@ -43217,6 +43336,7 @@ private constructor( when (this) { USAGE_PRICE -> Known.USAGE_PRICE FIXED_PRICE -> Known.FIXED_PRICE + COMPOSITE_PRICE -> Known.COMPOSITE_PRICE else -> throw OrbInvalidDataException("Unknown PriceType: $value") } @@ -45496,6 +45616,8 @@ private constructor( val FIXED_PRICE = of("fixed_price") + val COMPOSITE_PRICE = of("composite_price") + fun of(value: String) = PriceType(JsonField.of(value)) } @@ -45503,6 +45625,7 @@ private constructor( enum class Known { USAGE_PRICE, FIXED_PRICE, + COMPOSITE_PRICE, } /** @@ -45517,6 +45640,7 @@ private constructor( enum class Value { USAGE_PRICE, FIXED_PRICE, + COMPOSITE_PRICE, /** * An enum member indicating that [PriceType] was instantiated with an unknown * value. @@ -45535,6 +45659,7 @@ private constructor( when (this) { USAGE_PRICE -> Value.USAGE_PRICE FIXED_PRICE -> Value.FIXED_PRICE + COMPOSITE_PRICE -> Value.COMPOSITE_PRICE else -> Value._UNKNOWN } @@ -45551,6 +45676,7 @@ private constructor( when (this) { USAGE_PRICE -> Known.USAGE_PRICE FIXED_PRICE -> Known.FIXED_PRICE + COMPOSITE_PRICE -> Known.COMPOSITE_PRICE else -> throw OrbInvalidDataException("Unknown PriceType: $value") } @@ -47827,6 +47953,8 @@ private constructor( val FIXED_PRICE = of("fixed_price") + val COMPOSITE_PRICE = of("composite_price") + fun of(value: String) = PriceType(JsonField.of(value)) } @@ -47834,6 +47962,7 @@ private constructor( enum class Known { USAGE_PRICE, FIXED_PRICE, + COMPOSITE_PRICE, } /** @@ -47848,6 +47977,7 @@ private constructor( enum class Value { USAGE_PRICE, FIXED_PRICE, + COMPOSITE_PRICE, /** * An enum member indicating that [PriceType] was instantiated with an unknown * value. @@ -47866,6 +47996,7 @@ private constructor( when (this) { USAGE_PRICE -> Value.USAGE_PRICE FIXED_PRICE -> Value.FIXED_PRICE + COMPOSITE_PRICE -> Value.COMPOSITE_PRICE else -> Value._UNKNOWN } @@ -47882,6 +48013,7 @@ private constructor( when (this) { USAGE_PRICE -> Known.USAGE_PRICE FIXED_PRICE -> Known.FIXED_PRICE + COMPOSITE_PRICE -> Known.COMPOSITE_PRICE else -> throw OrbInvalidDataException("Unknown PriceType: $value") } @@ -50162,6 +50294,8 @@ private constructor( val FIXED_PRICE = of("fixed_price") + val COMPOSITE_PRICE = of("composite_price") + fun of(value: String) = PriceType(JsonField.of(value)) } @@ -50169,6 +50303,7 @@ private constructor( enum class Known { USAGE_PRICE, FIXED_PRICE, + COMPOSITE_PRICE, } /** @@ -50183,6 +50318,7 @@ private constructor( enum class Value { USAGE_PRICE, FIXED_PRICE, + COMPOSITE_PRICE, /** * An enum member indicating that [PriceType] was instantiated with an unknown * value. @@ -50201,6 +50337,7 @@ private constructor( when (this) { USAGE_PRICE -> Value.USAGE_PRICE FIXED_PRICE -> Value.FIXED_PRICE + COMPOSITE_PRICE -> Value.COMPOSITE_PRICE else -> Value._UNKNOWN } @@ -50217,6 +50354,7 @@ private constructor( when (this) { USAGE_PRICE -> Known.USAGE_PRICE FIXED_PRICE -> Known.FIXED_PRICE + COMPOSITE_PRICE -> Known.COMPOSITE_PRICE else -> throw OrbInvalidDataException("Unknown PriceType: $value") } @@ -52026,6 +52164,8 @@ private constructor( val FIXED_PRICE = of("fixed_price") + val COMPOSITE_PRICE = of("composite_price") + fun of(value: String) = PriceType(JsonField.of(value)) } @@ -52033,6 +52173,7 @@ private constructor( enum class Known { USAGE_PRICE, FIXED_PRICE, + COMPOSITE_PRICE, } /** @@ -52047,6 +52188,7 @@ private constructor( enum class Value { USAGE_PRICE, FIXED_PRICE, + COMPOSITE_PRICE, /** * An enum member indicating that [PriceType] was instantiated with an unknown * value. @@ -52065,6 +52207,7 @@ private constructor( when (this) { USAGE_PRICE -> Value.USAGE_PRICE FIXED_PRICE -> Value.FIXED_PRICE + COMPOSITE_PRICE -> Value.COMPOSITE_PRICE else -> Value._UNKNOWN } @@ -52081,6 +52224,7 @@ private constructor( when (this) { USAGE_PRICE -> Known.USAGE_PRICE FIXED_PRICE -> Known.FIXED_PRICE + COMPOSITE_PRICE -> Known.COMPOSITE_PRICE else -> throw OrbInvalidDataException("Unknown PriceType: $value") } @@ -54551,6 +54695,8 @@ private constructor( val FIXED_PRICE = of("fixed_price") + val COMPOSITE_PRICE = of("composite_price") + fun of(value: String) = PriceType(JsonField.of(value)) } @@ -54558,6 +54704,7 @@ private constructor( enum class Known { USAGE_PRICE, FIXED_PRICE, + COMPOSITE_PRICE, } /** @@ -54572,6 +54719,7 @@ private constructor( enum class Value { USAGE_PRICE, FIXED_PRICE, + COMPOSITE_PRICE, /** * An enum member indicating that [PriceType] was instantiated with an unknown * value. @@ -54590,6 +54738,7 @@ private constructor( when (this) { USAGE_PRICE -> Value.USAGE_PRICE FIXED_PRICE -> Value.FIXED_PRICE + COMPOSITE_PRICE -> Value.COMPOSITE_PRICE else -> Value._UNKNOWN } @@ -54606,6 +54755,7 @@ private constructor( when (this) { USAGE_PRICE -> Known.USAGE_PRICE FIXED_PRICE -> Known.FIXED_PRICE + COMPOSITE_PRICE -> Known.COMPOSITE_PRICE else -> throw OrbInvalidDataException("Unknown PriceType: $value") } @@ -57718,6 +57868,8 @@ private constructor( val FIXED_PRICE = of("fixed_price") + val COMPOSITE_PRICE = of("composite_price") + fun of(value: String) = PriceType(JsonField.of(value)) } @@ -57725,6 +57877,7 @@ private constructor( enum class Known { USAGE_PRICE, FIXED_PRICE, + COMPOSITE_PRICE, } /** @@ -57739,6 +57892,7 @@ private constructor( enum class Value { USAGE_PRICE, FIXED_PRICE, + COMPOSITE_PRICE, /** * An enum member indicating that [PriceType] was instantiated with an unknown * value. @@ -57757,6 +57911,7 @@ private constructor( when (this) { USAGE_PRICE -> Value.USAGE_PRICE FIXED_PRICE -> Value.FIXED_PRICE + COMPOSITE_PRICE -> Value.COMPOSITE_PRICE else -> Value._UNKNOWN } @@ -57773,6 +57928,7 @@ private constructor( when (this) { USAGE_PRICE -> Known.USAGE_PRICE FIXED_PRICE -> Known.FIXED_PRICE + COMPOSITE_PRICE -> Known.COMPOSITE_PRICE else -> throw OrbInvalidDataException("Unknown PriceType: $value") } @@ -59764,6 +59920,8 @@ private constructor( val FIXED_PRICE = of("fixed_price") + val COMPOSITE_PRICE = of("composite_price") + fun of(value: String) = PriceType(JsonField.of(value)) } @@ -59771,6 +59929,7 @@ private constructor( enum class Known { USAGE_PRICE, FIXED_PRICE, + COMPOSITE_PRICE, } /** @@ -59785,6 +59944,7 @@ private constructor( enum class Value { USAGE_PRICE, FIXED_PRICE, + COMPOSITE_PRICE, /** * An enum member indicating that [PriceType] was instantiated with an unknown * value. @@ -59803,6 +59963,7 @@ private constructor( when (this) { USAGE_PRICE -> Value.USAGE_PRICE FIXED_PRICE -> Value.FIXED_PRICE + COMPOSITE_PRICE -> Value.COMPOSITE_PRICE else -> Value._UNKNOWN } @@ -59819,6 +59980,7 @@ private constructor( when (this) { USAGE_PRICE -> Known.USAGE_PRICE FIXED_PRICE -> Known.FIXED_PRICE + COMPOSITE_PRICE -> Known.COMPOSITE_PRICE else -> throw OrbInvalidDataException("Unknown PriceType: $value") } From a790d458789e5a7336dc8510510b593b0d36ce73 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 10 Sep 2025 20:33:12 +0000 Subject: [PATCH 14/68] feat(api): api update --- .stats.yml | 4 ++-- .../withorb/api/models/NewFloatingTieredPackagePrice.kt | 8 ++++++-- .../com/withorb/api/models/NewPlanTieredPackagePrice.kt | 8 ++++++-- .../api/models/NewSubscriptionTieredPackagePrice.kt | 8 ++++++-- .../src/main/kotlin/com/withorb/api/models/Price.kt | 8 ++++++-- 5 files changed, 26 insertions(+), 10 deletions(-) diff --git a/.stats.yml b/.stats.yml index f45717774..43e826264 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 118 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-d63c8075b48441663736b457f8ad859c58cc3e31dfbffb68db44c3f00562012c.yml -openapi_spec_hash: c47dbff685a0a449bfc1ad729c13a72e +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-2c9291de1fd876908ebe56144e90762ab6e390e3f25102da815ab3fca6335d38.yml +openapi_spec_hash: eabe2d8e58ceed1d61d41fe7a44020ca config_hash: 1f73a949b649ecfe6ec68ba1bb459dc2 diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredPackagePrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredPackagePrice.kt index 3b48e3f94..8961b0d8b 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredPackagePrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredPackagePrice.kt @@ -1205,7 +1205,9 @@ private constructor( /** * Apply tiered pricing after rounding up the quantity to the package size. Tiers are - * defined using exclusive lower bounds. + * defined using exclusive lower bounds. The tier bounds are defined based on the total + * quantity rather than the number of packages, so they must be multiples of the package + * size. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). @@ -1283,7 +1285,9 @@ private constructor( /** * Apply tiered pricing after rounding up the quantity to the package size. Tiers are - * defined using exclusive lower bounds. + * defined using exclusive lower bounds. The tier bounds are defined based on the total + * quantity rather than the number of packages, so they must be multiples of the package + * size. */ fun tiers(tiers: List) = tiers(JsonField.of(tiers)) diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanTieredPackagePrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanTieredPackagePrice.kt index 7e147d55d..b7aa634ba 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanTieredPackagePrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanTieredPackagePrice.kt @@ -1248,7 +1248,9 @@ private constructor( /** * Apply tiered pricing after rounding up the quantity to the package size. Tiers are - * defined using exclusive lower bounds. + * defined using exclusive lower bounds. The tier bounds are defined based on the total + * quantity rather than the number of packages, so they must be multiples of the package + * size. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). @@ -1326,7 +1328,9 @@ private constructor( /** * Apply tiered pricing after rounding up the quantity to the package size. Tiers are - * defined using exclusive lower bounds. + * defined using exclusive lower bounds. The tier bounds are defined based on the total + * quantity rather than the number of packages, so they must be multiples of the package + * size. */ fun tiers(tiers: List) = tiers(JsonField.of(tiers)) diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTieredPackagePrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTieredPackagePrice.kt index b673bd3fd..b309fa66a 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTieredPackagePrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTieredPackagePrice.kt @@ -1254,7 +1254,9 @@ private constructor( /** * Apply tiered pricing after rounding up the quantity to the package size. Tiers are - * defined using exclusive lower bounds. + * defined using exclusive lower bounds. The tier bounds are defined based on the total + * quantity rather than the number of packages, so they must be multiples of the package + * size. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). @@ -1332,7 +1334,9 @@ private constructor( /** * Apply tiered pricing after rounding up the quantity to the package size. Tiers are - * defined using exclusive lower bounds. + * defined using exclusive lower bounds. The tier bounds are defined based on the total + * quantity rather than the number of packages, so they must be multiples of the package + * size. */ fun tiers(tiers: List) = tiers(JsonField.of(tiers)) diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Price.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Price.kt index 5a03b75c3..5aa312e65 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Price.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Price.kt @@ -14306,7 +14306,9 @@ private constructor( /** * Apply tiered pricing after rounding up the quantity to the package size. Tiers are - * defined using exclusive lower bounds. + * defined using exclusive lower bounds. The tier bounds are defined based on the total + * quantity rather than the number of packages, so they must be multiples of the package + * size. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected @@ -14386,7 +14388,9 @@ private constructor( /** * Apply tiered pricing after rounding up the quantity to the package size. Tiers - * are defined using exclusive lower bounds. + * are defined using exclusive lower bounds. The tier bounds are defined based on + * the total quantity rather than the number of packages, so they must be multiples + * of the package size. */ fun tiers(tiers: List) = tiers(JsonField.of(tiers)) From e2b7b1ee8a2594a363552c3289326b63a87112ec Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 12 Sep 2025 00:32:36 +0000 Subject: [PATCH 15/68] feat(api): api update --- .stats.yml | 4 ++-- .../src/main/kotlin/com/withorb/api/models/Item.kt | 6 ++++++ .../main/kotlin/com/withorb/api/models/ItemUpdateParams.kt | 6 ++++++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/.stats.yml b/.stats.yml index 43e826264..5076b7f79 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 118 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-2c9291de1fd876908ebe56144e90762ab6e390e3f25102da815ab3fca6335d38.yml -openapi_spec_hash: eabe2d8e58ceed1d61d41fe7a44020ca +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-d661add554c414c758c2ab668ddfe60da8b4c5cd81c44e59ccca1c2c5c91e898.yml +openapi_spec_hash: 3765a1f72610d1018727f51138dfffc3 config_hash: 1f73a949b649ecfe6ec68ba1bb459dc2 diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Item.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Item.kt index 0249ae5f1..8f5eb9b5a 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Item.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Item.kt @@ -542,6 +542,8 @@ private constructor( val ANROK = of("anrok") + val NUMERAL = of("numeral") + fun of(value: String) = ExternalConnectionName(JsonField.of(value)) } @@ -554,6 +556,7 @@ private constructor( TAXJAR, AVALARA, ANROK, + NUMERAL, } /** @@ -575,6 +578,7 @@ private constructor( TAXJAR, AVALARA, ANROK, + NUMERAL, /** * An enum member indicating that [ExternalConnectionName] was instantiated with an * unknown value. @@ -598,6 +602,7 @@ private constructor( TAXJAR -> Value.TAXJAR AVALARA -> Value.AVALARA ANROK -> Value.ANROK + NUMERAL -> Value.NUMERAL else -> Value._UNKNOWN } @@ -619,6 +624,7 @@ private constructor( TAXJAR -> Known.TAXJAR AVALARA -> Known.AVALARA ANROK -> Known.ANROK + NUMERAL -> Known.NUMERAL else -> throw OrbInvalidDataException("Unknown ExternalConnectionName: $value") } diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/ItemUpdateParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/ItemUpdateParams.kt index 854f01c7e..73d0b1673 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/ItemUpdateParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/ItemUpdateParams.kt @@ -778,6 +778,8 @@ private constructor( val ANROK = of("anrok") + val NUMERAL = of("numeral") + fun of(value: String) = ExternalConnectionName(JsonField.of(value)) } @@ -790,6 +792,7 @@ private constructor( TAXJAR, AVALARA, ANROK, + NUMERAL, } /** @@ -811,6 +814,7 @@ private constructor( TAXJAR, AVALARA, ANROK, + NUMERAL, /** * An enum member indicating that [ExternalConnectionName] was instantiated with an * unknown value. @@ -834,6 +838,7 @@ private constructor( TAXJAR -> Value.TAXJAR AVALARA -> Value.AVALARA ANROK -> Value.ANROK + NUMERAL -> Value.NUMERAL else -> Value._UNKNOWN } @@ -855,6 +860,7 @@ private constructor( TAXJAR -> Known.TAXJAR AVALARA -> Known.AVALARA ANROK -> Known.ANROK + NUMERAL -> Known.NUMERAL else -> throw OrbInvalidDataException("Unknown ExternalConnectionName: $value") } From 1612dd121630d64f7d0ba6cfad7807e38765eda3 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 15 Sep 2025 14:59:54 +0000 Subject: [PATCH 16/68] fix(client): incorrect `getPackageVersion` impl --- .../src/main/kotlin/com/withorb/api/core/Properties.kt | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/core/Properties.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/core/Properties.kt index 9045e4dbf..f0f63ba44 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/core/Properties.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/core/Properties.kt @@ -2,7 +2,7 @@ package com.withorb.api.core -import java.util.Properties +import com.withorb.api.client.OrbClient fun getOsArch(): String { val osArch = System.getProperty("os.arch") @@ -16,7 +16,7 @@ fun getOsArch(): String { "x86_64" -> "x64" "arm" -> "arm" "aarch64" -> "arm64" - else -> "other:${osArch}" + else -> "other:$osArch" } } @@ -30,13 +30,12 @@ fun getOsName(): String { osName.startsWith("Linux") -> "Linux" osName.startsWith("Mac OS") -> "MacOS" osName.startsWith("Windows") -> "Windows" - else -> "Other:${osName}" + else -> "Other:$osName" } } fun getOsVersion(): String = System.getProperty("os.version", "unknown") -fun getPackageVersion(): String = - Properties::class.java.`package`.implementationVersion ?: "unknown" +fun getPackageVersion(): String = OrbClient::class.java.`package`.implementationVersion ?: "unknown" fun getJavaVersion(): String = System.getProperty("java.version", "unknown") From f06d033e7331f839b77ae33d33b878be2c797e5f Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 16 Sep 2025 00:33:13 +0000 Subject: [PATCH 17/68] feat(api): api update --- .stats.yml | 4 +- .../models/ChangedSubscriptionResources.kt | 7009 ++++++++++++++++- .../kotlin/com/withorb/api/models/Price.kt | 4671 ++++++++++- .../withorb/api/models/AggregatedCostTest.kt | 3 + .../ChangedSubscriptionResourcesTest.kt | 128 +- ...ustomerCostListByExternalIdResponseTest.kt | 3 + .../models/CustomerCostListResponseTest.kt | 3 + ...dgerCreateEntryByExternalIdResponseTest.kt | 2 + ...omerCreditLedgerCreateEntryResponseTest.kt | 2 + ...tLedgerListByExternalIdPageResponseTest.kt | 3 + ...reditLedgerListByExternalIdResponseTest.kt | 2 + ...ustomerCreditLedgerListPageResponseTest.kt | 3 + .../CustomerCreditLedgerListResponseTest.kt | 2 + .../api/models/IncrementLedgerEntryTest.kt | 3 + .../InvoiceFetchUpcomingResponseTest.kt | 3 + .../InvoiceLineItemCreateResponseTest.kt | 3 + .../api/models/InvoiceListPageResponseTest.kt | 3 + .../com/withorb/api/models/InvoiceTest.kt | 3 + .../api/models/MutatedSubscriptionTest.kt | 138 +- .../withorb/api/models/PerPriceCostTest.kt | 3 + .../api/models/PlanListPageResponseTest.kt | 3 + .../kotlin/com/withorb/api/models/PlanTest.kt | 3 + .../com/withorb/api/models/PlanVersionTest.kt | 3 + .../withorb/api/models/PriceIntervalTest.kt | 3 + .../api/models/PriceListPageResponseTest.kt | 3 + .../com/withorb/api/models/PriceTest.kt | 54 + .../SubscriptionChangeApplyResponseTest.kt | 163 +- .../SubscriptionChangeCancelResponseTest.kt | 163 +- .../SubscriptionChangeRetrieveResponseTest.kt | 163 +- .../SubscriptionFetchCostsResponseTest.kt | 3 + .../withorb/api/models/SubscriptionTest.kt | 6 + .../withorb/api/models/SubscriptionsTest.kt | 6 + 32 files changed, 12343 insertions(+), 221 deletions(-) diff --git a/.stats.yml b/.stats.yml index 5076b7f79..232a1ab71 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 118 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-d661add554c414c758c2ab668ddfe60da8b4c5cd81c44e59ccca1c2c5c91e898.yml -openapi_spec_hash: 3765a1f72610d1018727f51138dfffc3 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-96a2f34503f9348f8d7ce82035fe09c917860d77e17bc6817e034b891902599a.yml +openapi_spec_hash: 3719dd8f962e6b0051a95015aecb0e53 config_hash: 1f73a949b649ecfe6ec68ba1bb459dc2 diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/ChangedSubscriptionResources.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/ChangedSubscriptionResources.kt index 11c95eec3..9eb31ad40 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/ChangedSubscriptionResources.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/ChangedSubscriptionResources.kt @@ -6,21 +6,33 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.withorb.api.core.BaseDeserializer +import com.withorb.api.core.BaseSerializer +import com.withorb.api.core.Enum import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.checkKnown import com.withorb.api.core.checkRequired +import com.withorb.api.core.getOrThrow import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException +import java.time.OffsetDateTime import java.util.Collections import java.util.Objects class ChangedSubscriptionResources private constructor( private val createdCreditNotes: JsonField>, - private val createdInvoices: JsonField>, + private val createdInvoices: JsonField>, private val voidedCreditNotes: JsonField>, private val voidedInvoices: JsonField>, private val additionalProperties: MutableMap, @@ -33,7 +45,7 @@ private constructor( createdCreditNotes: JsonField> = JsonMissing.of(), @JsonProperty("created_invoices") @ExcludeMissing - createdInvoices: JsonField> = JsonMissing.of(), + createdInvoices: JsonField> = JsonMissing.of(), @JsonProperty("voided_credit_notes") @ExcludeMissing voidedCreditNotes: JsonField> = JsonMissing.of(), @@ -57,7 +69,7 @@ private constructor( * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ - fun createdInvoices(): List = createdInvoices.getRequired("created_invoices") + fun createdInvoices(): List = createdInvoices.getRequired("created_invoices") /** * The credit notes that were voided as part of this operation. @@ -92,7 +104,7 @@ private constructor( */ @JsonProperty("created_invoices") @ExcludeMissing - fun _createdInvoices(): JsonField> = createdInvoices + fun _createdInvoices(): JsonField> = createdInvoices /** * Returns the raw JSON value of [voidedCreditNotes]. @@ -145,7 +157,7 @@ private constructor( class Builder internal constructor() { private var createdCreditNotes: JsonField>? = null - private var createdInvoices: JsonField>? = null + private var createdInvoices: JsonField>? = null private var voidedCreditNotes: JsonField>? = null private var voidedInvoices: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -189,26 +201,26 @@ private constructor( } /** The invoices that were created as part of this operation. */ - fun createdInvoices(createdInvoices: List) = + fun createdInvoices(createdInvoices: List) = createdInvoices(JsonField.of(createdInvoices)) /** * Sets [Builder.createdInvoices] to an arbitrary JSON value. * - * You should usually call [Builder.createdInvoices] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. + * You should usually call [Builder.createdInvoices] with a well-typed + * `List` value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. */ - fun createdInvoices(createdInvoices: JsonField>) = apply { + fun createdInvoices(createdInvoices: JsonField>) = apply { this.createdInvoices = createdInvoices.map { it.toMutableList() } } /** - * Adds a single [Invoice] to [createdInvoices]. + * Adds a single [CreatedInvoice] to [createdInvoices]. * * @throws IllegalStateException if the field was previously set to a non-list. */ - fun addCreatedInvoice(createdInvoice: Invoice) = apply { + fun addCreatedInvoice(createdInvoice: CreatedInvoice) = apply { createdInvoices = (createdInvoices ?: JsonField.of(mutableListOf())).also { checkKnown("createdInvoices", it).add(createdInvoice) @@ -346,6 +358,6979 @@ private constructor( (voidedCreditNotes.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + (voidedInvoices.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + class CreatedInvoice + private constructor( + private val id: JsonField, + private val amountDue: JsonField, + private val autoCollection: JsonField, + private val billingAddress: JsonField
, + private val createdAt: JsonField, + private val creditNotes: JsonField>, + private val currency: JsonField, + private val customer: JsonField, + private val customerBalanceTransactions: JsonField>, + private val customerTaxId: JsonField, + private val discount: JsonValue, + private val discounts: JsonField>, + private val dueDate: JsonField, + private val eligibleToIssueAt: JsonField, + private val hostedInvoiceUrl: JsonField, + private val invoiceDate: JsonField, + private val invoiceNumber: JsonField, + private val invoicePdf: JsonField, + private val invoiceSource: JsonField, + private val isPayableNow: JsonField, + private val issueFailedAt: JsonField, + private val issuedAt: JsonField, + private val lineItems: JsonField>, + private val maximum: JsonField, + private val maximumAmount: JsonField, + private val memo: JsonField, + private val metadata: JsonField, + private val minimum: JsonField, + private val minimumAmount: JsonField, + private val paidAt: JsonField, + private val paymentAttempts: JsonField>, + private val paymentFailedAt: JsonField, + private val paymentStartedAt: JsonField, + private val scheduledIssueAt: JsonField, + private val shippingAddress: JsonField
, + private val status: JsonField, + private val subscription: JsonField, + private val subtotal: JsonField, + private val syncFailedAt: JsonField, + private val total: JsonField, + private val voidedAt: JsonField, + private val willAutoIssue: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("amount_due") + @ExcludeMissing + amountDue: JsonField = JsonMissing.of(), + @JsonProperty("auto_collection") + @ExcludeMissing + autoCollection: JsonField = JsonMissing.of(), + @JsonProperty("billing_address") + @ExcludeMissing + billingAddress: JsonField
= JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + createdAt: JsonField = JsonMissing.of(), + @JsonProperty("credit_notes") + @ExcludeMissing + creditNotes: JsonField> = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("customer") + @ExcludeMissing + customer: JsonField = JsonMissing.of(), + @JsonProperty("customer_balance_transactions") + @ExcludeMissing + customerBalanceTransactions: JsonField> = + JsonMissing.of(), + @JsonProperty("customer_tax_id") + @ExcludeMissing + customerTaxId: JsonField = JsonMissing.of(), + @JsonProperty("discount") @ExcludeMissing discount: JsonValue = JsonMissing.of(), + @JsonProperty("discounts") + @ExcludeMissing + discounts: JsonField> = JsonMissing.of(), + @JsonProperty("due_date") + @ExcludeMissing + dueDate: JsonField = JsonMissing.of(), + @JsonProperty("eligible_to_issue_at") + @ExcludeMissing + eligibleToIssueAt: JsonField = JsonMissing.of(), + @JsonProperty("hosted_invoice_url") + @ExcludeMissing + hostedInvoiceUrl: JsonField = JsonMissing.of(), + @JsonProperty("invoice_date") + @ExcludeMissing + invoiceDate: JsonField = JsonMissing.of(), + @JsonProperty("invoice_number") + @ExcludeMissing + invoiceNumber: JsonField = JsonMissing.of(), + @JsonProperty("invoice_pdf") + @ExcludeMissing + invoicePdf: JsonField = JsonMissing.of(), + @JsonProperty("invoice_source") + @ExcludeMissing + invoiceSource: JsonField = JsonMissing.of(), + @JsonProperty("is_payable_now") + @ExcludeMissing + isPayableNow: JsonField = JsonMissing.of(), + @JsonProperty("issue_failed_at") + @ExcludeMissing + issueFailedAt: JsonField = JsonMissing.of(), + @JsonProperty("issued_at") + @ExcludeMissing + issuedAt: JsonField = JsonMissing.of(), + @JsonProperty("line_items") + @ExcludeMissing + lineItems: JsonField> = JsonMissing.of(), + @JsonProperty("maximum") @ExcludeMissing maximum: JsonField = JsonMissing.of(), + @JsonProperty("maximum_amount") + @ExcludeMissing + maximumAmount: JsonField = JsonMissing.of(), + @JsonProperty("memo") @ExcludeMissing memo: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("minimum") @ExcludeMissing minimum: JsonField = JsonMissing.of(), + @JsonProperty("minimum_amount") + @ExcludeMissing + minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("paid_at") + @ExcludeMissing + paidAt: JsonField = JsonMissing.of(), + @JsonProperty("payment_attempts") + @ExcludeMissing + paymentAttempts: JsonField> = JsonMissing.of(), + @JsonProperty("payment_failed_at") + @ExcludeMissing + paymentFailedAt: JsonField = JsonMissing.of(), + @JsonProperty("payment_started_at") + @ExcludeMissing + paymentStartedAt: JsonField = JsonMissing.of(), + @JsonProperty("scheduled_issue_at") + @ExcludeMissing + scheduledIssueAt: JsonField = JsonMissing.of(), + @JsonProperty("shipping_address") + @ExcludeMissing + shippingAddress: JsonField
= JsonMissing.of(), + @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), + @JsonProperty("subscription") + @ExcludeMissing + subscription: JsonField = JsonMissing.of(), + @JsonProperty("subtotal") + @ExcludeMissing + subtotal: JsonField = JsonMissing.of(), + @JsonProperty("sync_failed_at") + @ExcludeMissing + syncFailedAt: JsonField = JsonMissing.of(), + @JsonProperty("total") @ExcludeMissing total: JsonField = JsonMissing.of(), + @JsonProperty("voided_at") + @ExcludeMissing + voidedAt: JsonField = JsonMissing.of(), + @JsonProperty("will_auto_issue") + @ExcludeMissing + willAutoIssue: JsonField = JsonMissing.of(), + ) : this( + id, + amountDue, + autoCollection, + billingAddress, + createdAt, + creditNotes, + currency, + customer, + customerBalanceTransactions, + customerTaxId, + discount, + discounts, + dueDate, + eligibleToIssueAt, + hostedInvoiceUrl, + invoiceDate, + invoiceNumber, + invoicePdf, + invoiceSource, + isPayableNow, + issueFailedAt, + issuedAt, + lineItems, + maximum, + maximumAmount, + memo, + metadata, + minimum, + minimumAmount, + paidAt, + paymentAttempts, + paymentFailedAt, + paymentStartedAt, + scheduledIssueAt, + shippingAddress, + status, + subscription, + subtotal, + syncFailedAt, + total, + voidedAt, + willAutoIssue, + mutableMapOf(), + ) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * This is the final amount required to be charged to the customer and reflects the + * application of the customer balance to the `total` of the invoice. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun amountDue(): String = amountDue.getRequired("amount_due") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun autoCollection(): AutoCollection = autoCollection.getRequired("auto_collection") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun billingAddress(): Address? = billingAddress.getNullable("billing_address") + + /** + * The creation time of the resource in Orb. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") + + /** + * A list of credit notes associated with the invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun creditNotes(): List = creditNotes.getRequired("credit_notes") + + /** + * An ISO 4217 currency string or `credits` + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun customer(): CustomerMinified = customer.getRequired("customer") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun customerBalanceTransactions(): List = + customerBalanceTransactions.getRequired("customer_balance_transactions") + + /** + * Tax IDs are commonly required to be displayed on customer invoices, which are added to + * the headers of invoices. + * + * ### Supported Tax ID Countries and Types + * |Country |Type |Description | + * |----------------------|------------|-------------------------------------------------------------------------------------------------------| + * |Albania |`al_tin` |Albania Tax Identification Number | + * |Andorra |`ad_nrt` |Andorran NRT Number | + * |Angola |`ao_tin` |Angola Tax Identification Number | + * |Argentina |`ar_cuit` |Argentinian Tax ID Number | + * |Armenia |`am_tin` |Armenia Tax Identification Number | + * |Aruba |`aw_tin` |Aruba Tax Identification Number | + * |Australia |`au_abn` |Australian Business Number (AU ABN) | + * |Australia |`au_arn` |Australian Taxation Office Reference Number | + * |Austria |`eu_vat` |European VAT Number | + * |Azerbaijan |`az_tin` |Azerbaijan Tax Identification Number | + * |Bahamas |`bs_tin` |Bahamas Tax Identification Number | + * |Bahrain |`bh_vat` |Bahraini VAT Number | + * |Bangladesh |`bd_bin` |Bangladesh Business Identification Number | + * |Barbados |`bb_tin` |Barbados Tax Identification Number | + * |Belarus |`by_tin` |Belarus TIN Number | + * |Belgium |`eu_vat` |European VAT Number | + * |Benin |`bj_ifu` |Benin Tax Identification Number (Identifiant Fiscal Unique) | + * |Bolivia |`bo_tin` |Bolivian Tax ID | + * |Bosnia and Herzegovina|`ba_tin` |Bosnia and Herzegovina Tax Identification Number | + * |Brazil |`br_cnpj` |Brazilian CNPJ Number | + * |Brazil |`br_cpf` |Brazilian CPF Number | + * |Bulgaria |`bg_uic` |Bulgaria Unified Identification Code | + * |Bulgaria |`eu_vat` |European VAT Number | + * |Burkina Faso |`bf_ifu` |Burkina Faso Tax Identification Number (Numéro d'Identifiant Fiscal Unique) | + * |Cambodia |`kh_tin` |Cambodia Tax Identification Number | + * |Cameroon |`cm_niu` |Cameroon Tax Identification Number (Numéro d'Identifiant fiscal Unique) | + * |Canada |`ca_bn` |Canadian BN | + * |Canada |`ca_gst_hst`|Canadian GST/HST Number | + * |Canada |`ca_pst_bc` |Canadian PST Number (British Columbia) | + * |Canada |`ca_pst_mb` |Canadian PST Number (Manitoba) | + * |Canada |`ca_pst_sk` |Canadian PST Number (Saskatchewan) | + * |Canada |`ca_qst` |Canadian QST Number (Québec) | + * |Cape Verde |`cv_nif` |Cape Verde Tax Identification Number (Número de Identificação Fiscal) | + * |Chile |`cl_tin` |Chilean TIN | + * |China |`cn_tin` |Chinese Tax ID | + * |Colombia |`co_nit` |Colombian NIT Number | + * |Congo-Kinshasa |`cd_nif` |Congo (DR) Tax Identification Number (Número de Identificação Fiscal) | + * |Costa Rica |`cr_tin` |Costa Rican Tax ID | + * |Croatia |`eu_vat` |European VAT Number | + * |Croatia |`hr_oib` |Croatian Personal Identification Number (OIB) | + * |Cyprus |`eu_vat` |European VAT Number | + * |Czech Republic |`eu_vat` |European VAT Number | + * |Denmark |`eu_vat` |European VAT Number | + * |Dominican Republic |`do_rcn` |Dominican RCN Number | + * |Ecuador |`ec_ruc` |Ecuadorian RUC Number | + * |Egypt |`eg_tin` |Egyptian Tax Identification Number | + * |El Salvador |`sv_nit` |El Salvadorian NIT Number | + * |Estonia |`eu_vat` |European VAT Number | + * |Ethiopia |`et_tin` |Ethiopia Tax Identification Number | + * |European Union |`eu_oss_vat`|European One Stop Shop VAT Number for non-Union scheme | + * |Finland |`eu_vat` |European VAT Number | + * |France |`eu_vat` |European VAT Number | + * |Georgia |`ge_vat` |Georgian VAT | + * |Germany |`de_stn` |German Tax Number (Steuernummer) | + * |Germany |`eu_vat` |European VAT Number | + * |Greece |`eu_vat` |European VAT Number | + * |Guinea |`gn_nif` |Guinea Tax Identification Number (Número de Identificação Fiscal) | + * |Hong Kong |`hk_br` |Hong Kong BR Number | + * |Hungary |`eu_vat` |European VAT Number | + * |Hungary |`hu_tin` |Hungary Tax Number (adószám) | + * |Iceland |`is_vat` |Icelandic VAT | + * |India |`in_gst` |Indian GST Number | + * |Indonesia |`id_npwp` |Indonesian NPWP Number | + * |Ireland |`eu_vat` |European VAT Number | + * |Israel |`il_vat` |Israel VAT | + * |Italy |`eu_vat` |European VAT Number | + * |Japan |`jp_cn` |Japanese Corporate Number (_Hōjin Bangō_) | + * |Japan |`jp_rn` |Japanese Registered Foreign Businesses' Registration Number (_Tōroku Kokugai Jigyōsha no Tōroku Bangō_)| + * |Japan |`jp_trn` |Japanese Tax Registration Number (_Tōroku Bangō_) | + * |Kazakhstan |`kz_bin` |Kazakhstani Business Identification Number | + * |Kenya |`ke_pin` |Kenya Revenue Authority Personal Identification Number | + * |Kyrgyzstan |`kg_tin` |Kyrgyzstan Tax Identification Number | + * |Laos |`la_tin` |Laos Tax Identification Number | + * |Latvia |`eu_vat` |European VAT Number | + * |Liechtenstein |`li_uid` |Liechtensteinian UID Number | + * |Liechtenstein |`li_vat` |Liechtenstein VAT Number | + * |Lithuania |`eu_vat` |European VAT Number | + * |Luxembourg |`eu_vat` |European VAT Number | + * |Malaysia |`my_frp` |Malaysian FRP Number | + * |Malaysia |`my_itn` |Malaysian ITN | + * |Malaysia |`my_sst` |Malaysian SST Number | + * |Malta |`eu_vat` |European VAT Number | + * |Mauritania |`mr_nif` |Mauritania Tax Identification Number (Número de Identificação Fiscal) | + * |Mexico |`mx_rfc` |Mexican RFC Number | + * |Moldova |`md_vat` |Moldova VAT Number | + * |Montenegro |`me_pib` |Montenegro PIB Number | + * |Morocco |`ma_vat` |Morocco VAT Number | + * |Nepal |`np_pan` |Nepal PAN Number | + * |Netherlands |`eu_vat` |European VAT Number | + * |New Zealand |`nz_gst` |New Zealand GST Number | + * |Nigeria |`ng_tin` |Nigerian Tax Identification Number | + * |North Macedonia |`mk_vat` |North Macedonia VAT Number | + * |Northern Ireland |`eu_vat` |Northern Ireland VAT Number | + * |Norway |`no_vat` |Norwegian VAT Number | + * |Norway |`no_voec` |Norwegian VAT on e-commerce Number | + * |Oman |`om_vat` |Omani VAT Number | + * |Peru |`pe_ruc` |Peruvian RUC Number | + * |Philippines |`ph_tin` |Philippines Tax Identification Number | + * |Poland |`eu_vat` |European VAT Number | + * |Portugal |`eu_vat` |European VAT Number | + * |Romania |`eu_vat` |European VAT Number | + * |Romania |`ro_tin` |Romanian Tax ID Number | + * |Russia |`ru_inn` |Russian INN | + * |Russia |`ru_kpp` |Russian KPP | + * |Saudi Arabia |`sa_vat` |Saudi Arabia VAT | + * |Senegal |`sn_ninea` |Senegal NINEA Number | + * |Serbia |`rs_pib` |Serbian PIB Number | + * |Singapore |`sg_gst` |Singaporean GST | + * |Singapore |`sg_uen` |Singaporean UEN | + * |Slovakia |`eu_vat` |European VAT Number | + * |Slovenia |`eu_vat` |European VAT Number | + * |Slovenia |`si_tin` |Slovenia Tax Number (davčna številka) | + * |South Africa |`za_vat` |South African VAT Number | + * |South Korea |`kr_brn` |Korean BRN | + * |Spain |`es_cif` |Spanish NIF Number (previously Spanish CIF Number) | + * |Spain |`eu_vat` |European VAT Number | + * |Suriname |`sr_fin` |Suriname FIN Number | + * |Sweden |`eu_vat` |European VAT Number | + * |Switzerland |`ch_uid` |Switzerland UID Number | + * |Switzerland |`ch_vat` |Switzerland VAT Number | + * |Taiwan |`tw_vat` |Taiwanese VAT | + * |Tajikistan |`tj_tin` |Tajikistan Tax Identification Number | + * |Tanzania |`tz_vat` |Tanzania VAT Number | + * |Thailand |`th_vat` |Thai VAT | + * |Turkey |`tr_tin` |Turkish Tax Identification Number | + * |Uganda |`ug_tin` |Uganda Tax Identification Number | + * |Ukraine |`ua_vat` |Ukrainian VAT | + * |United Arab Emirates |`ae_trn` |United Arab Emirates TRN | + * |United Kingdom |`gb_vat` |United Kingdom VAT Number | + * |United States |`us_ein` |United States EIN | + * |Uruguay |`uy_ruc` |Uruguayan RUC Number | + * |Uzbekistan |`uz_tin` |Uzbekistan TIN Number | + * |Uzbekistan |`uz_vat` |Uzbekistan VAT Number | + * |Venezuela |`ve_rif` |Venezuelan RIF Number | + * |Vietnam |`vn_tin` |Vietnamese Tax ID Number | + * |Zambia |`zm_tin` |Zambia Tax Identification Number | + * |Zimbabwe |`zw_tin` |Zimbabwe Tax Identification Number | + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun customerTaxId(): CustomerTaxId? = customerTaxId.getNullable("customer_tax_id") + + /** + * This field is deprecated in favor of `discounts`. If a `discounts` list is provided, the + * first discount in the list will be returned. If the list is empty, `None` will be + * returned. + */ + @Deprecated("deprecated") + @JsonProperty("discount") + @ExcludeMissing + fun _discount(): JsonValue = discount + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun discounts(): List = discounts.getRequired("discounts") + + /** + * When the invoice payment is due. The due date is null if the invoice is not yet + * finalized. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun dueDate(): OffsetDateTime? = dueDate.getNullable("due_date") + + /** + * If the invoice has a status of `draft`, this will be the time that the invoice will be + * eligible to be issued, otherwise it will be `null`. If `auto-issue` is true, the invoice + * will automatically begin issuing at this time. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun eligibleToIssueAt(): OffsetDateTime? = + eligibleToIssueAt.getNullable("eligible_to_issue_at") + + /** + * A URL for the customer-facing invoice portal. This URL expires 30 days after the + * invoice's due date, or 60 days after being re-generated through the UI. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun hostedInvoiceUrl(): String? = hostedInvoiceUrl.getNullable("hosted_invoice_url") + + /** + * The scheduled date of the invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun invoiceDate(): OffsetDateTime = invoiceDate.getRequired("invoice_date") + + /** + * Automatically generated invoice number to help track and reconcile invoices. Invoice + * numbers have a prefix such as `RFOBWG`. These can be sequential per account or customer. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun invoiceNumber(): String = invoiceNumber.getRequired("invoice_number") + + /** + * The link to download the PDF representation of the `Invoice`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun invoicePdf(): String? = invoicePdf.getNullable("invoice_pdf") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun invoiceSource(): InvoiceSource = invoiceSource.getRequired("invoice_source") + + /** + * True if the invoice has only in-advance fixed fees and is payable now + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun isPayableNow(): Boolean = isPayableNow.getRequired("is_payable_now") + + /** + * If the invoice failed to issue, this will be the last time it failed to issue (even if it + * is now in a different state.) + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun issueFailedAt(): OffsetDateTime? = issueFailedAt.getNullable("issue_failed_at") + + /** + * If the invoice has been issued, this will be the time it transitioned to `issued` (even + * if it is now in a different state.) + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun issuedAt(): OffsetDateTime? = issuedAt.getNullable("issued_at") + + /** + * The breakdown of prices in this invoice. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun lineItems(): List = lineItems.getRequired("line_items") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun maximum(): Maximum? = maximum.getNullable("maximum") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun maximumAmount(): String? = maximumAmount.getNullable("maximum_amount") + + /** + * Free-form text which is available on the invoice PDF and the Orb invoice portal. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun memo(): String? = memo.getNullable("memo") + + /** + * User specified key-value pairs for the resource. If not present, this defaults to an + * empty dictionary. Individual keys can be removed by setting the value to `null`, and the + * entire metadata mapping can be cleared by setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun metadata(): Metadata = metadata.getRequired("metadata") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun minimum(): Minimum? = minimum.getNullable("minimum") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun minimumAmount(): String? = minimumAmount.getNullable("minimum_amount") + + /** + * If the invoice has a status of `paid`, this gives a timestamp when the invoice was paid. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun paidAt(): OffsetDateTime? = paidAt.getNullable("paid_at") + + /** + * A list of payment attempts associated with the invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun paymentAttempts(): List = + paymentAttempts.getRequired("payment_attempts") + + /** + * If payment was attempted on this invoice but failed, this will be the time of the most + * recent attempt. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun paymentFailedAt(): OffsetDateTime? = paymentFailedAt.getNullable("payment_failed_at") + + /** + * If payment was attempted on this invoice, this will be the start time of the most recent + * attempt. This field is especially useful for delayed-notification payment mechanisms + * (like bank transfers), where payment can take 3 days or more. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun paymentStartedAt(): OffsetDateTime? = paymentStartedAt.getNullable("payment_started_at") + + /** + * If the invoice is in draft, this timestamp will reflect when the invoice is scheduled to + * be issued. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun scheduledIssueAt(): OffsetDateTime? = scheduledIssueAt.getNullable("scheduled_issue_at") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun shippingAddress(): Address? = shippingAddress.getNullable("shipping_address") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun status(): Status = status.getRequired("status") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun subscription(): SubscriptionMinified? = subscription.getNullable("subscription") + + /** + * The total before any discounts and minimums are applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun subtotal(): String = subtotal.getRequired("subtotal") + + /** + * If the invoice failed to sync, this will be the last time an external invoicing provider + * sync was attempted. This field will always be `null` for invoices using Orb Invoicing. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun syncFailedAt(): OffsetDateTime? = syncFailedAt.getNullable("sync_failed_at") + + /** + * The total after any minimums and discounts have been applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun total(): String = total.getRequired("total") + + /** + * If the invoice has a status of `void`, this gives a timestamp when the invoice was + * voided. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun voidedAt(): OffsetDateTime? = voidedAt.getNullable("voided_at") + + /** + * This is true if the invoice will be automatically issued in the future, and false + * otherwise. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun willAutoIssue(): Boolean = willAutoIssue.getRequired("will_auto_issue") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [amountDue]. + * + * Unlike [amountDue], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("amount_due") @ExcludeMissing fun _amountDue(): JsonField = amountDue + + /** + * Returns the raw JSON value of [autoCollection]. + * + * Unlike [autoCollection], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("auto_collection") + @ExcludeMissing + fun _autoCollection(): JsonField = autoCollection + + /** + * Returns the raw JSON value of [billingAddress]. + * + * Unlike [billingAddress], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("billing_address") + @ExcludeMissing + fun _billingAddress(): JsonField
= billingAddress + + /** + * Returns the raw JSON value of [createdAt]. + * + * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt + + /** + * Returns the raw JSON value of [creditNotes]. + * + * Unlike [creditNotes], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("credit_notes") + @ExcludeMissing + fun _creditNotes(): JsonField> = creditNotes + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [customer]. + * + * Unlike [customer], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("customer") + @ExcludeMissing + fun _customer(): JsonField = customer + + /** + * Returns the raw JSON value of [customerBalanceTransactions]. + * + * Unlike [customerBalanceTransactions], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("customer_balance_transactions") + @ExcludeMissing + fun _customerBalanceTransactions(): JsonField> = + customerBalanceTransactions + + /** + * Returns the raw JSON value of [customerTaxId]. + * + * Unlike [customerTaxId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("customer_tax_id") + @ExcludeMissing + fun _customerTaxId(): JsonField = customerTaxId + + /** + * Returns the raw JSON value of [discounts]. + * + * Unlike [discounts], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("discounts") + @ExcludeMissing + fun _discounts(): JsonField> = discounts + + /** + * Returns the raw JSON value of [dueDate]. + * + * Unlike [dueDate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("due_date") + @ExcludeMissing + fun _dueDate(): JsonField = dueDate + + /** + * Returns the raw JSON value of [eligibleToIssueAt]. + * + * Unlike [eligibleToIssueAt], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("eligible_to_issue_at") + @ExcludeMissing + fun _eligibleToIssueAt(): JsonField = eligibleToIssueAt + + /** + * Returns the raw JSON value of [hostedInvoiceUrl]. + * + * Unlike [hostedInvoiceUrl], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("hosted_invoice_url") + @ExcludeMissing + fun _hostedInvoiceUrl(): JsonField = hostedInvoiceUrl + + /** + * Returns the raw JSON value of [invoiceDate]. + * + * Unlike [invoiceDate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("invoice_date") + @ExcludeMissing + fun _invoiceDate(): JsonField = invoiceDate + + /** + * Returns the raw JSON value of [invoiceNumber]. + * + * Unlike [invoiceNumber], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("invoice_number") + @ExcludeMissing + fun _invoiceNumber(): JsonField = invoiceNumber + + /** + * Returns the raw JSON value of [invoicePdf]. + * + * Unlike [invoicePdf], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("invoice_pdf") + @ExcludeMissing + fun _invoicePdf(): JsonField = invoicePdf + + /** + * Returns the raw JSON value of [invoiceSource]. + * + * Unlike [invoiceSource], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("invoice_source") + @ExcludeMissing + fun _invoiceSource(): JsonField = invoiceSource + + /** + * Returns the raw JSON value of [isPayableNow]. + * + * Unlike [isPayableNow], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("is_payable_now") + @ExcludeMissing + fun _isPayableNow(): JsonField = isPayableNow + + /** + * Returns the raw JSON value of [issueFailedAt]. + * + * Unlike [issueFailedAt], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("issue_failed_at") + @ExcludeMissing + fun _issueFailedAt(): JsonField = issueFailedAt + + /** + * Returns the raw JSON value of [issuedAt]. + * + * Unlike [issuedAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("issued_at") + @ExcludeMissing + fun _issuedAt(): JsonField = issuedAt + + /** + * Returns the raw JSON value of [lineItems]. + * + * Unlike [lineItems], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("line_items") + @ExcludeMissing + fun _lineItems(): JsonField> = lineItems + + /** + * Returns the raw JSON value of [maximum]. + * + * Unlike [maximum], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("maximum") @ExcludeMissing fun _maximum(): JsonField = maximum + + /** + * Returns the raw JSON value of [maximumAmount]. + * + * Unlike [maximumAmount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount + + /** + * Returns the raw JSON value of [memo]. + * + * Unlike [memo], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("memo") @ExcludeMissing fun _memo(): JsonField = memo + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [minimum]. + * + * Unlike [minimum], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("minimum") @ExcludeMissing fun _minimum(): JsonField = minimum + + /** + * Returns the raw JSON value of [minimumAmount]. + * + * Unlike [minimumAmount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount + + /** + * Returns the raw JSON value of [paidAt]. + * + * Unlike [paidAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("paid_at") @ExcludeMissing fun _paidAt(): JsonField = paidAt + + /** + * Returns the raw JSON value of [paymentAttempts]. + * + * Unlike [paymentAttempts], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("payment_attempts") + @ExcludeMissing + fun _paymentAttempts(): JsonField> = paymentAttempts + + /** + * Returns the raw JSON value of [paymentFailedAt]. + * + * Unlike [paymentFailedAt], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("payment_failed_at") + @ExcludeMissing + fun _paymentFailedAt(): JsonField = paymentFailedAt + + /** + * Returns the raw JSON value of [paymentStartedAt]. + * + * Unlike [paymentStartedAt], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("payment_started_at") + @ExcludeMissing + fun _paymentStartedAt(): JsonField = paymentStartedAt + + /** + * Returns the raw JSON value of [scheduledIssueAt]. + * + * Unlike [scheduledIssueAt], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("scheduled_issue_at") + @ExcludeMissing + fun _scheduledIssueAt(): JsonField = scheduledIssueAt + + /** + * Returns the raw JSON value of [shippingAddress]. + * + * Unlike [shippingAddress], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("shipping_address") + @ExcludeMissing + fun _shippingAddress(): JsonField
= shippingAddress + + /** + * Returns the raw JSON value of [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status + + /** + * Returns the raw JSON value of [subscription]. + * + * Unlike [subscription], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("subscription") + @ExcludeMissing + fun _subscription(): JsonField = subscription + + /** + * Returns the raw JSON value of [subtotal]. + * + * Unlike [subtotal], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("subtotal") @ExcludeMissing fun _subtotal(): JsonField = subtotal + + /** + * Returns the raw JSON value of [syncFailedAt]. + * + * Unlike [syncFailedAt], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("sync_failed_at") + @ExcludeMissing + fun _syncFailedAt(): JsonField = syncFailedAt + + /** + * Returns the raw JSON value of [total]. + * + * Unlike [total], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("total") @ExcludeMissing fun _total(): JsonField = total + + /** + * Returns the raw JSON value of [voidedAt]. + * + * Unlike [voidedAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("voided_at") + @ExcludeMissing + fun _voidedAt(): JsonField = voidedAt + + /** + * Returns the raw JSON value of [willAutoIssue]. + * + * Unlike [willAutoIssue], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("will_auto_issue") + @ExcludeMissing + fun _willAutoIssue(): JsonField = willAutoIssue + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [CreatedInvoice]. + * + * The following fields are required: + * ```kotlin + * .id() + * .amountDue() + * .autoCollection() + * .billingAddress() + * .createdAt() + * .creditNotes() + * .currency() + * .customer() + * .customerBalanceTransactions() + * .customerTaxId() + * .discount() + * .discounts() + * .dueDate() + * .eligibleToIssueAt() + * .hostedInvoiceUrl() + * .invoiceDate() + * .invoiceNumber() + * .invoicePdf() + * .invoiceSource() + * .isPayableNow() + * .issueFailedAt() + * .issuedAt() + * .lineItems() + * .maximum() + * .maximumAmount() + * .memo() + * .metadata() + * .minimum() + * .minimumAmount() + * .paidAt() + * .paymentAttempts() + * .paymentFailedAt() + * .paymentStartedAt() + * .scheduledIssueAt() + * .shippingAddress() + * .status() + * .subscription() + * .subtotal() + * .syncFailedAt() + * .total() + * .voidedAt() + * .willAutoIssue() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [CreatedInvoice]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var amountDue: JsonField? = null + private var autoCollection: JsonField? = null + private var billingAddress: JsonField
? = null + private var createdAt: JsonField? = null + private var creditNotes: JsonField>? = null + private var currency: JsonField? = null + private var customer: JsonField? = null + private var customerBalanceTransactions: + JsonField>? = + null + private var customerTaxId: JsonField? = null + private var discount: JsonValue? = null + private var discounts: JsonField>? = null + private var dueDate: JsonField? = null + private var eligibleToIssueAt: JsonField? = null + private var hostedInvoiceUrl: JsonField? = null + private var invoiceDate: JsonField? = null + private var invoiceNumber: JsonField? = null + private var invoicePdf: JsonField? = null + private var invoiceSource: JsonField? = null + private var isPayableNow: JsonField? = null + private var issueFailedAt: JsonField? = null + private var issuedAt: JsonField? = null + private var lineItems: JsonField>? = null + private var maximum: JsonField? = null + private var maximumAmount: JsonField? = null + private var memo: JsonField? = null + private var metadata: JsonField? = null + private var minimum: JsonField? = null + private var minimumAmount: JsonField? = null + private var paidAt: JsonField? = null + private var paymentAttempts: JsonField>? = null + private var paymentFailedAt: JsonField? = null + private var paymentStartedAt: JsonField? = null + private var scheduledIssueAt: JsonField? = null + private var shippingAddress: JsonField
? = null + private var status: JsonField? = null + private var subscription: JsonField? = null + private var subtotal: JsonField? = null + private var syncFailedAt: JsonField? = null + private var total: JsonField? = null + private var voidedAt: JsonField? = null + private var willAutoIssue: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(createdInvoice: CreatedInvoice) = apply { + id = createdInvoice.id + amountDue = createdInvoice.amountDue + autoCollection = createdInvoice.autoCollection + billingAddress = createdInvoice.billingAddress + createdAt = createdInvoice.createdAt + creditNotes = createdInvoice.creditNotes.map { it.toMutableList() } + currency = createdInvoice.currency + customer = createdInvoice.customer + customerBalanceTransactions = + createdInvoice.customerBalanceTransactions.map { it.toMutableList() } + customerTaxId = createdInvoice.customerTaxId + discount = createdInvoice.discount + discounts = createdInvoice.discounts.map { it.toMutableList() } + dueDate = createdInvoice.dueDate + eligibleToIssueAt = createdInvoice.eligibleToIssueAt + hostedInvoiceUrl = createdInvoice.hostedInvoiceUrl + invoiceDate = createdInvoice.invoiceDate + invoiceNumber = createdInvoice.invoiceNumber + invoicePdf = createdInvoice.invoicePdf + invoiceSource = createdInvoice.invoiceSource + isPayableNow = createdInvoice.isPayableNow + issueFailedAt = createdInvoice.issueFailedAt + issuedAt = createdInvoice.issuedAt + lineItems = createdInvoice.lineItems.map { it.toMutableList() } + maximum = createdInvoice.maximum + maximumAmount = createdInvoice.maximumAmount + memo = createdInvoice.memo + metadata = createdInvoice.metadata + minimum = createdInvoice.minimum + minimumAmount = createdInvoice.minimumAmount + paidAt = createdInvoice.paidAt + paymentAttempts = createdInvoice.paymentAttempts.map { it.toMutableList() } + paymentFailedAt = createdInvoice.paymentFailedAt + paymentStartedAt = createdInvoice.paymentStartedAt + scheduledIssueAt = createdInvoice.scheduledIssueAt + shippingAddress = createdInvoice.shippingAddress + status = createdInvoice.status + subscription = createdInvoice.subscription + subtotal = createdInvoice.subtotal + syncFailedAt = createdInvoice.syncFailedAt + total = createdInvoice.total + voidedAt = createdInvoice.voidedAt + willAutoIssue = createdInvoice.willAutoIssue + additionalProperties = createdInvoice.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun id(id: JsonField) = apply { this.id = id } + + /** + * This is the final amount required to be charged to the customer and reflects the + * application of the customer balance to the `total` of the invoice. + */ + fun amountDue(amountDue: String) = amountDue(JsonField.of(amountDue)) + + /** + * Sets [Builder.amountDue] to an arbitrary JSON value. + * + * You should usually call [Builder.amountDue] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun amountDue(amountDue: JsonField) = apply { this.amountDue = amountDue } + + fun autoCollection(autoCollection: AutoCollection) = + autoCollection(JsonField.of(autoCollection)) + + /** + * Sets [Builder.autoCollection] to an arbitrary JSON value. + * + * You should usually call [Builder.autoCollection] with a well-typed [AutoCollection] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun autoCollection(autoCollection: JsonField) = apply { + this.autoCollection = autoCollection + } + + fun billingAddress(billingAddress: Address?) = + billingAddress(JsonField.ofNullable(billingAddress)) + + /** + * Sets [Builder.billingAddress] to an arbitrary JSON value. + * + * You should usually call [Builder.billingAddress] with a well-typed [Address] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun billingAddress(billingAddress: JsonField
) = apply { + this.billingAddress = billingAddress + } + + /** The creation time of the resource in Orb. */ + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + + /** + * Sets [Builder.createdAt] to an arbitrary JSON value. + * + * You should usually call [Builder.createdAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun createdAt(createdAt: JsonField) = apply { + this.createdAt = createdAt + } + + /** A list of credit notes associated with the invoice */ + fun creditNotes(creditNotes: List) = creditNotes(JsonField.of(creditNotes)) + + /** + * Sets [Builder.creditNotes] to an arbitrary JSON value. + * + * You should usually call [Builder.creditNotes] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun creditNotes(creditNotes: JsonField>) = apply { + this.creditNotes = creditNotes.map { it.toMutableList() } + } + + /** + * Adds a single [CreditNote] to [creditNotes]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addCreditNote(creditNote: CreditNote) = apply { + creditNotes = + (creditNotes ?: JsonField.of(mutableListOf())).also { + checkKnown("creditNotes", it).add(creditNote) + } + } + + /** An ISO 4217 currency string or `credits` */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + fun customer(customer: CustomerMinified) = customer(JsonField.of(customer)) + + /** + * Sets [Builder.customer] to an arbitrary JSON value. + * + * You should usually call [Builder.customer] with a well-typed [CustomerMinified] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun customer(customer: JsonField) = apply { this.customer = customer } + + fun customerBalanceTransactions( + customerBalanceTransactions: List + ) = customerBalanceTransactions(JsonField.of(customerBalanceTransactions)) + + /** + * Sets [Builder.customerBalanceTransactions] to an arbitrary JSON value. + * + * You should usually call [Builder.customerBalanceTransactions] with a well-typed + * `List` value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun customerBalanceTransactions( + customerBalanceTransactions: JsonField> + ) = apply { + this.customerBalanceTransactions = + customerBalanceTransactions.map { it.toMutableList() } + } + + /** + * Adds a single [CustomerBalanceTransaction] to [customerBalanceTransactions]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addCustomerBalanceTransaction( + customerBalanceTransaction: CustomerBalanceTransaction + ) = apply { + customerBalanceTransactions = + (customerBalanceTransactions ?: JsonField.of(mutableListOf())).also { + checkKnown("customerBalanceTransactions", it) + .add(customerBalanceTransaction) + } + } + + /** + * Tax IDs are commonly required to be displayed on customer invoices, which are added + * to the headers of invoices. + * + * ### Supported Tax ID Countries and Types + * |Country |Type |Description | + * |----------------------|------------|-------------------------------------------------------------------------------------------------------| + * |Albania |`al_tin` |Albania Tax Identification Number | + * |Andorra |`ad_nrt` |Andorran NRT Number | + * |Angola |`ao_tin` |Angola Tax Identification Number | + * |Argentina |`ar_cuit` |Argentinian Tax ID Number | + * |Armenia |`am_tin` |Armenia Tax Identification Number | + * |Aruba |`aw_tin` |Aruba Tax Identification Number | + * |Australia |`au_abn` |Australian Business Number (AU ABN) | + * |Australia |`au_arn` |Australian Taxation Office Reference Number | + * |Austria |`eu_vat` |European VAT Number | + * |Azerbaijan |`az_tin` |Azerbaijan Tax Identification Number | + * |Bahamas |`bs_tin` |Bahamas Tax Identification Number | + * |Bahrain |`bh_vat` |Bahraini VAT Number | + * |Bangladesh |`bd_bin` |Bangladesh Business Identification Number | + * |Barbados |`bb_tin` |Barbados Tax Identification Number | + * |Belarus |`by_tin` |Belarus TIN Number | + * |Belgium |`eu_vat` |European VAT Number | + * |Benin |`bj_ifu` |Benin Tax Identification Number (Identifiant Fiscal Unique) | + * |Bolivia |`bo_tin` |Bolivian Tax ID | + * |Bosnia and Herzegovina|`ba_tin` |Bosnia and Herzegovina Tax Identification Number | + * |Brazil |`br_cnpj` |Brazilian CNPJ Number | + * |Brazil |`br_cpf` |Brazilian CPF Number | + * |Bulgaria |`bg_uic` |Bulgaria Unified Identification Code | + * |Bulgaria |`eu_vat` |European VAT Number | + * |Burkina Faso |`bf_ifu` |Burkina Faso Tax Identification Number (Numéro d'Identifiant Fiscal Unique) | + * |Cambodia |`kh_tin` |Cambodia Tax Identification Number | + * |Cameroon |`cm_niu` |Cameroon Tax Identification Number (Numéro d'Identifiant fiscal Unique) | + * |Canada |`ca_bn` |Canadian BN | + * |Canada |`ca_gst_hst`|Canadian GST/HST Number | + * |Canada |`ca_pst_bc` |Canadian PST Number (British Columbia) | + * |Canada |`ca_pst_mb` |Canadian PST Number (Manitoba) | + * |Canada |`ca_pst_sk` |Canadian PST Number (Saskatchewan) | + * |Canada |`ca_qst` |Canadian QST Number (Québec) | + * |Cape Verde |`cv_nif` |Cape Verde Tax Identification Number (Número de Identificação Fiscal) | + * |Chile |`cl_tin` |Chilean TIN | + * |China |`cn_tin` |Chinese Tax ID | + * |Colombia |`co_nit` |Colombian NIT Number | + * |Congo-Kinshasa |`cd_nif` |Congo (DR) Tax Identification Number (Número de Identificação Fiscal) | + * |Costa Rica |`cr_tin` |Costa Rican Tax ID | + * |Croatia |`eu_vat` |European VAT Number | + * |Croatia |`hr_oib` |Croatian Personal Identification Number (OIB) | + * |Cyprus |`eu_vat` |European VAT Number | + * |Czech Republic |`eu_vat` |European VAT Number | + * |Denmark |`eu_vat` |European VAT Number | + * |Dominican Republic |`do_rcn` |Dominican RCN Number | + * |Ecuador |`ec_ruc` |Ecuadorian RUC Number | + * |Egypt |`eg_tin` |Egyptian Tax Identification Number | + * |El Salvador |`sv_nit` |El Salvadorian NIT Number | + * |Estonia |`eu_vat` |European VAT Number | + * |Ethiopia |`et_tin` |Ethiopia Tax Identification Number | + * |European Union |`eu_oss_vat`|European One Stop Shop VAT Number for non-Union scheme | + * |Finland |`eu_vat` |European VAT Number | + * |France |`eu_vat` |European VAT Number | + * |Georgia |`ge_vat` |Georgian VAT | + * |Germany |`de_stn` |German Tax Number (Steuernummer) | + * |Germany |`eu_vat` |European VAT Number | + * |Greece |`eu_vat` |European VAT Number | + * |Guinea |`gn_nif` |Guinea Tax Identification Number (Número de Identificação Fiscal) | + * |Hong Kong |`hk_br` |Hong Kong BR Number | + * |Hungary |`eu_vat` |European VAT Number | + * |Hungary |`hu_tin` |Hungary Tax Number (adószám) | + * |Iceland |`is_vat` |Icelandic VAT | + * |India |`in_gst` |Indian GST Number | + * |Indonesia |`id_npwp` |Indonesian NPWP Number | + * |Ireland |`eu_vat` |European VAT Number | + * |Israel |`il_vat` |Israel VAT | + * |Italy |`eu_vat` |European VAT Number | + * |Japan |`jp_cn` |Japanese Corporate Number (_Hōjin Bangō_) | + * |Japan |`jp_rn` |Japanese Registered Foreign Businesses' Registration Number (_Tōroku Kokugai Jigyōsha no Tōroku Bangō_)| + * |Japan |`jp_trn` |Japanese Tax Registration Number (_Tōroku Bangō_) | + * |Kazakhstan |`kz_bin` |Kazakhstani Business Identification Number | + * |Kenya |`ke_pin` |Kenya Revenue Authority Personal Identification Number | + * |Kyrgyzstan |`kg_tin` |Kyrgyzstan Tax Identification Number | + * |Laos |`la_tin` |Laos Tax Identification Number | + * |Latvia |`eu_vat` |European VAT Number | + * |Liechtenstein |`li_uid` |Liechtensteinian UID Number | + * |Liechtenstein |`li_vat` |Liechtenstein VAT Number | + * |Lithuania |`eu_vat` |European VAT Number | + * |Luxembourg |`eu_vat` |European VAT Number | + * |Malaysia |`my_frp` |Malaysian FRP Number | + * |Malaysia |`my_itn` |Malaysian ITN | + * |Malaysia |`my_sst` |Malaysian SST Number | + * |Malta |`eu_vat` |European VAT Number | + * |Mauritania |`mr_nif` |Mauritania Tax Identification Number (Número de Identificação Fiscal) | + * |Mexico |`mx_rfc` |Mexican RFC Number | + * |Moldova |`md_vat` |Moldova VAT Number | + * |Montenegro |`me_pib` |Montenegro PIB Number | + * |Morocco |`ma_vat` |Morocco VAT Number | + * |Nepal |`np_pan` |Nepal PAN Number | + * |Netherlands |`eu_vat` |European VAT Number | + * |New Zealand |`nz_gst` |New Zealand GST Number | + * |Nigeria |`ng_tin` |Nigerian Tax Identification Number | + * |North Macedonia |`mk_vat` |North Macedonia VAT Number | + * |Northern Ireland |`eu_vat` |Northern Ireland VAT Number | + * |Norway |`no_vat` |Norwegian VAT Number | + * |Norway |`no_voec` |Norwegian VAT on e-commerce Number | + * |Oman |`om_vat` |Omani VAT Number | + * |Peru |`pe_ruc` |Peruvian RUC Number | + * |Philippines |`ph_tin` |Philippines Tax Identification Number | + * |Poland |`eu_vat` |European VAT Number | + * |Portugal |`eu_vat` |European VAT Number | + * |Romania |`eu_vat` |European VAT Number | + * |Romania |`ro_tin` |Romanian Tax ID Number | + * |Russia |`ru_inn` |Russian INN | + * |Russia |`ru_kpp` |Russian KPP | + * |Saudi Arabia |`sa_vat` |Saudi Arabia VAT | + * |Senegal |`sn_ninea` |Senegal NINEA Number | + * |Serbia |`rs_pib` |Serbian PIB Number | + * |Singapore |`sg_gst` |Singaporean GST | + * |Singapore |`sg_uen` |Singaporean UEN | + * |Slovakia |`eu_vat` |European VAT Number | + * |Slovenia |`eu_vat` |European VAT Number | + * |Slovenia |`si_tin` |Slovenia Tax Number (davčna številka) | + * |South Africa |`za_vat` |South African VAT Number | + * |South Korea |`kr_brn` |Korean BRN | + * |Spain |`es_cif` |Spanish NIF Number (previously Spanish CIF Number) | + * |Spain |`eu_vat` |European VAT Number | + * |Suriname |`sr_fin` |Suriname FIN Number | + * |Sweden |`eu_vat` |European VAT Number | + * |Switzerland |`ch_uid` |Switzerland UID Number | + * |Switzerland |`ch_vat` |Switzerland VAT Number | + * |Taiwan |`tw_vat` |Taiwanese VAT | + * |Tajikistan |`tj_tin` |Tajikistan Tax Identification Number | + * |Tanzania |`tz_vat` |Tanzania VAT Number | + * |Thailand |`th_vat` |Thai VAT | + * |Turkey |`tr_tin` |Turkish Tax Identification Number | + * |Uganda |`ug_tin` |Uganda Tax Identification Number | + * |Ukraine |`ua_vat` |Ukrainian VAT | + * |United Arab Emirates |`ae_trn` |United Arab Emirates TRN | + * |United Kingdom |`gb_vat` |United Kingdom VAT Number | + * |United States |`us_ein` |United States EIN | + * |Uruguay |`uy_ruc` |Uruguayan RUC Number | + * |Uzbekistan |`uz_tin` |Uzbekistan TIN Number | + * |Uzbekistan |`uz_vat` |Uzbekistan VAT Number | + * |Venezuela |`ve_rif` |Venezuelan RIF Number | + * |Vietnam |`vn_tin` |Vietnamese Tax ID Number | + * |Zambia |`zm_tin` |Zambia Tax Identification Number | + * |Zimbabwe |`zw_tin` |Zimbabwe Tax Identification Number | + */ + fun customerTaxId(customerTaxId: CustomerTaxId?) = + customerTaxId(JsonField.ofNullable(customerTaxId)) + + /** + * Sets [Builder.customerTaxId] to an arbitrary JSON value. + * + * You should usually call [Builder.customerTaxId] with a well-typed [CustomerTaxId] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun customerTaxId(customerTaxId: JsonField) = apply { + this.customerTaxId = customerTaxId + } + + /** + * This field is deprecated in favor of `discounts`. If a `discounts` list is provided, + * the first discount in the list will be returned. If the list is empty, `None` will be + * returned. + */ + @Deprecated("deprecated") + fun discount(discount: JsonValue) = apply { this.discount = discount } + + fun discounts(discounts: List) = + discounts(JsonField.of(discounts)) + + /** + * Sets [Builder.discounts] to an arbitrary JSON value. + * + * You should usually call [Builder.discounts] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun discounts(discounts: JsonField>) = apply { + this.discounts = discounts.map { it.toMutableList() } + } + + /** + * Adds a single [InvoiceLevelDiscount] to [discounts]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addDiscount(discount: InvoiceLevelDiscount) = apply { + discounts = + (discounts ?: JsonField.of(mutableListOf())).also { + checkKnown("discounts", it).add(discount) + } + } + + /** + * Alias for calling [addDiscount] with `InvoiceLevelDiscount.ofPercentage(percentage)`. + */ + fun addDiscount(percentage: PercentageDiscount) = + addDiscount(InvoiceLevelDiscount.ofPercentage(percentage)) + + /** + * Alias for calling [addDiscount] with the following: + * ```kotlin + * PercentageDiscount.builder() + * .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + * .percentageDiscount(percentageDiscount) + * .build() + * ``` + */ + fun addPercentageDiscount(percentageDiscount: Double) = + addDiscount( + PercentageDiscount.builder() + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(percentageDiscount) + .build() + ) + + /** Alias for calling [addDiscount] with `InvoiceLevelDiscount.ofAmount(amount)`. */ + fun addDiscount(amount: AmountDiscount) = + addDiscount(InvoiceLevelDiscount.ofAmount(amount)) + + /** + * Alias for calling [addDiscount] with the following: + * ```kotlin + * AmountDiscount.builder() + * .discountType(AmountDiscount.DiscountType.AMOUNT) + * .amountDiscount(amountDiscount) + * .build() + * ``` + */ + fun addAmountDiscount(amountDiscount: String) = + addDiscount( + AmountDiscount.builder() + .discountType(AmountDiscount.DiscountType.AMOUNT) + .amountDiscount(amountDiscount) + .build() + ) + + /** Alias for calling [addDiscount] with `InvoiceLevelDiscount.ofTrial(trial)`. */ + fun addDiscount(trial: TrialDiscount) = addDiscount(InvoiceLevelDiscount.ofTrial(trial)) + + /** + * When the invoice payment is due. The due date is null if the invoice is not yet + * finalized. + */ + fun dueDate(dueDate: OffsetDateTime?) = dueDate(JsonField.ofNullable(dueDate)) + + /** + * Sets [Builder.dueDate] to an arbitrary JSON value. + * + * You should usually call [Builder.dueDate] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun dueDate(dueDate: JsonField) = apply { this.dueDate = dueDate } + + /** + * If the invoice has a status of `draft`, this will be the time that the invoice will + * be eligible to be issued, otherwise it will be `null`. If `auto-issue` is true, the + * invoice will automatically begin issuing at this time. + */ + fun eligibleToIssueAt(eligibleToIssueAt: OffsetDateTime?) = + eligibleToIssueAt(JsonField.ofNullable(eligibleToIssueAt)) + + /** + * Sets [Builder.eligibleToIssueAt] to an arbitrary JSON value. + * + * You should usually call [Builder.eligibleToIssueAt] with a well-typed + * [OffsetDateTime] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun eligibleToIssueAt(eligibleToIssueAt: JsonField) = apply { + this.eligibleToIssueAt = eligibleToIssueAt + } + + /** + * A URL for the customer-facing invoice portal. This URL expires 30 days after the + * invoice's due date, or 60 days after being re-generated through the UI. + */ + fun hostedInvoiceUrl(hostedInvoiceUrl: String?) = + hostedInvoiceUrl(JsonField.ofNullable(hostedInvoiceUrl)) + + /** + * Sets [Builder.hostedInvoiceUrl] to an arbitrary JSON value. + * + * You should usually call [Builder.hostedInvoiceUrl] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun hostedInvoiceUrl(hostedInvoiceUrl: JsonField) = apply { + this.hostedInvoiceUrl = hostedInvoiceUrl + } + + /** The scheduled date of the invoice */ + fun invoiceDate(invoiceDate: OffsetDateTime) = invoiceDate(JsonField.of(invoiceDate)) + + /** + * Sets [Builder.invoiceDate] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceDate] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun invoiceDate(invoiceDate: JsonField) = apply { + this.invoiceDate = invoiceDate + } + + /** + * Automatically generated invoice number to help track and reconcile invoices. Invoice + * numbers have a prefix such as `RFOBWG`. These can be sequential per account or + * customer. + */ + fun invoiceNumber(invoiceNumber: String) = invoiceNumber(JsonField.of(invoiceNumber)) + + /** + * Sets [Builder.invoiceNumber] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceNumber] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun invoiceNumber(invoiceNumber: JsonField) = apply { + this.invoiceNumber = invoiceNumber + } + + /** The link to download the PDF representation of the `Invoice`. */ + fun invoicePdf(invoicePdf: String?) = invoicePdf(JsonField.ofNullable(invoicePdf)) + + /** + * Sets [Builder.invoicePdf] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicePdf] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun invoicePdf(invoicePdf: JsonField) = apply { this.invoicePdf = invoicePdf } + + fun invoiceSource(invoiceSource: InvoiceSource) = + invoiceSource(JsonField.of(invoiceSource)) + + /** + * Sets [Builder.invoiceSource] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceSource] with a well-typed [InvoiceSource] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun invoiceSource(invoiceSource: JsonField) = apply { + this.invoiceSource = invoiceSource + } + + /** True if the invoice has only in-advance fixed fees and is payable now */ + fun isPayableNow(isPayableNow: Boolean) = isPayableNow(JsonField.of(isPayableNow)) + + /** + * Sets [Builder.isPayableNow] to an arbitrary JSON value. + * + * You should usually call [Builder.isPayableNow] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun isPayableNow(isPayableNow: JsonField) = apply { + this.isPayableNow = isPayableNow + } + + /** + * If the invoice failed to issue, this will be the last time it failed to issue (even + * if it is now in a different state.) + */ + fun issueFailedAt(issueFailedAt: OffsetDateTime?) = + issueFailedAt(JsonField.ofNullable(issueFailedAt)) + + /** + * Sets [Builder.issueFailedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.issueFailedAt] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun issueFailedAt(issueFailedAt: JsonField) = apply { + this.issueFailedAt = issueFailedAt + } + + /** + * If the invoice has been issued, this will be the time it transitioned to `issued` + * (even if it is now in a different state.) + */ + fun issuedAt(issuedAt: OffsetDateTime?) = issuedAt(JsonField.ofNullable(issuedAt)) + + /** + * Sets [Builder.issuedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.issuedAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun issuedAt(issuedAt: JsonField) = apply { this.issuedAt = issuedAt } + + /** The breakdown of prices in this invoice. */ + fun lineItems(lineItems: List) = lineItems(JsonField.of(lineItems)) + + /** + * Sets [Builder.lineItems] to an arbitrary JSON value. + * + * You should usually call [Builder.lineItems] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun lineItems(lineItems: JsonField>) = apply { + this.lineItems = lineItems.map { it.toMutableList() } + } + + /** + * Adds a single [LineItem] to [lineItems]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLineItem(lineItem: LineItem) = apply { + lineItems = + (lineItems ?: JsonField.of(mutableListOf())).also { + checkKnown("lineItems", it).add(lineItem) + } + } + + fun maximum(maximum: Maximum?) = maximum(JsonField.ofNullable(maximum)) + + /** + * Sets [Builder.maximum] to an arbitrary JSON value. + * + * You should usually call [Builder.maximum] with a well-typed [Maximum] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun maximum(maximum: JsonField) = apply { this.maximum = maximum } + + fun maximumAmount(maximumAmount: String?) = + maximumAmount(JsonField.ofNullable(maximumAmount)) + + /** + * Sets [Builder.maximumAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.maximumAmount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun maximumAmount(maximumAmount: JsonField) = apply { + this.maximumAmount = maximumAmount + } + + /** Free-form text which is available on the invoice PDF and the Orb invoice portal. */ + fun memo(memo: String?) = memo(JsonField.ofNullable(memo)) + + /** + * Sets [Builder.memo] to an arbitrary JSON value. + * + * You should usually call [Builder.memo] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun memo(memo: JsonField) = apply { this.memo = memo } + + /** + * User specified key-value pairs for the resource. If not present, this defaults to an + * empty dictionary. Individual keys can be removed by setting the value to `null`, and + * the entire metadata mapping can be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + fun minimum(minimum: Minimum?) = minimum(JsonField.ofNullable(minimum)) + + /** + * Sets [Builder.minimum] to an arbitrary JSON value. + * + * You should usually call [Builder.minimum] with a well-typed [Minimum] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun minimum(minimum: JsonField) = apply { this.minimum = minimum } + + fun minimumAmount(minimumAmount: String?) = + minimumAmount(JsonField.ofNullable(minimumAmount)) + + /** + * Sets [Builder.minimumAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumAmount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount + } + + /** + * If the invoice has a status of `paid`, this gives a timestamp when the invoice was + * paid. + */ + fun paidAt(paidAt: OffsetDateTime?) = paidAt(JsonField.ofNullable(paidAt)) + + /** + * Sets [Builder.paidAt] to an arbitrary JSON value. + * + * You should usually call [Builder.paidAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun paidAt(paidAt: JsonField) = apply { this.paidAt = paidAt } + + /** A list of payment attempts associated with the invoice */ + fun paymentAttempts(paymentAttempts: List) = + paymentAttempts(JsonField.of(paymentAttempts)) + + /** + * Sets [Builder.paymentAttempts] to an arbitrary JSON value. + * + * You should usually call [Builder.paymentAttempts] with a well-typed + * `List` value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun paymentAttempts(paymentAttempts: JsonField>) = apply { + this.paymentAttempts = paymentAttempts.map { it.toMutableList() } + } + + /** + * Adds a single [PaymentAttempt] to [paymentAttempts]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addPaymentAttempt(paymentAttempt: PaymentAttempt) = apply { + paymentAttempts = + (paymentAttempts ?: JsonField.of(mutableListOf())).also { + checkKnown("paymentAttempts", it).add(paymentAttempt) + } + } + + /** + * If payment was attempted on this invoice but failed, this will be the time of the + * most recent attempt. + */ + fun paymentFailedAt(paymentFailedAt: OffsetDateTime?) = + paymentFailedAt(JsonField.ofNullable(paymentFailedAt)) + + /** + * Sets [Builder.paymentFailedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.paymentFailedAt] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun paymentFailedAt(paymentFailedAt: JsonField) = apply { + this.paymentFailedAt = paymentFailedAt + } + + /** + * If payment was attempted on this invoice, this will be the start time of the most + * recent attempt. This field is especially useful for delayed-notification payment + * mechanisms (like bank transfers), where payment can take 3 days or more. + */ + fun paymentStartedAt(paymentStartedAt: OffsetDateTime?) = + paymentStartedAt(JsonField.ofNullable(paymentStartedAt)) + + /** + * Sets [Builder.paymentStartedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.paymentStartedAt] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun paymentStartedAt(paymentStartedAt: JsonField) = apply { + this.paymentStartedAt = paymentStartedAt + } + + /** + * If the invoice is in draft, this timestamp will reflect when the invoice is scheduled + * to be issued. + */ + fun scheduledIssueAt(scheduledIssueAt: OffsetDateTime?) = + scheduledIssueAt(JsonField.ofNullable(scheduledIssueAt)) + + /** + * Sets [Builder.scheduledIssueAt] to an arbitrary JSON value. + * + * You should usually call [Builder.scheduledIssueAt] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun scheduledIssueAt(scheduledIssueAt: JsonField) = apply { + this.scheduledIssueAt = scheduledIssueAt + } + + fun shippingAddress(shippingAddress: Address?) = + shippingAddress(JsonField.ofNullable(shippingAddress)) + + /** + * Sets [Builder.shippingAddress] to an arbitrary JSON value. + * + * You should usually call [Builder.shippingAddress] with a well-typed [Address] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun shippingAddress(shippingAddress: JsonField
) = apply { + this.shippingAddress = shippingAddress + } + + fun status(status: Status) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [Status] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun status(status: JsonField) = apply { this.status = status } + + fun subscription(subscription: SubscriptionMinified?) = + subscription(JsonField.ofNullable(subscription)) + + /** + * Sets [Builder.subscription] to an arbitrary JSON value. + * + * You should usually call [Builder.subscription] with a well-typed + * [SubscriptionMinified] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun subscription(subscription: JsonField) = apply { + this.subscription = subscription + } + + /** The total before any discounts and minimums are applied. */ + fun subtotal(subtotal: String) = subtotal(JsonField.of(subtotal)) + + /** + * Sets [Builder.subtotal] to an arbitrary JSON value. + * + * You should usually call [Builder.subtotal] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun subtotal(subtotal: JsonField) = apply { this.subtotal = subtotal } + + /** + * If the invoice failed to sync, this will be the last time an external invoicing + * provider sync was attempted. This field will always be `null` for invoices using Orb + * Invoicing. + */ + fun syncFailedAt(syncFailedAt: OffsetDateTime?) = + syncFailedAt(JsonField.ofNullable(syncFailedAt)) + + /** + * Sets [Builder.syncFailedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.syncFailedAt] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun syncFailedAt(syncFailedAt: JsonField) = apply { + this.syncFailedAt = syncFailedAt + } + + /** The total after any minimums and discounts have been applied. */ + fun total(total: String) = total(JsonField.of(total)) + + /** + * Sets [Builder.total] to an arbitrary JSON value. + * + * You should usually call [Builder.total] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun total(total: JsonField) = apply { this.total = total } + + /** + * If the invoice has a status of `void`, this gives a timestamp when the invoice was + * voided. + */ + fun voidedAt(voidedAt: OffsetDateTime?) = voidedAt(JsonField.ofNullable(voidedAt)) + + /** + * Sets [Builder.voidedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.voidedAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun voidedAt(voidedAt: JsonField) = apply { this.voidedAt = voidedAt } + + /** + * This is true if the invoice will be automatically issued in the future, and false + * otherwise. + */ + fun willAutoIssue(willAutoIssue: Boolean) = willAutoIssue(JsonField.of(willAutoIssue)) + + /** + * Sets [Builder.willAutoIssue] to an arbitrary JSON value. + * + * You should usually call [Builder.willAutoIssue] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun willAutoIssue(willAutoIssue: JsonField) = apply { + this.willAutoIssue = willAutoIssue + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CreatedInvoice]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .id() + * .amountDue() + * .autoCollection() + * .billingAddress() + * .createdAt() + * .creditNotes() + * .currency() + * .customer() + * .customerBalanceTransactions() + * .customerTaxId() + * .discount() + * .discounts() + * .dueDate() + * .eligibleToIssueAt() + * .hostedInvoiceUrl() + * .invoiceDate() + * .invoiceNumber() + * .invoicePdf() + * .invoiceSource() + * .isPayableNow() + * .issueFailedAt() + * .issuedAt() + * .lineItems() + * .maximum() + * .maximumAmount() + * .memo() + * .metadata() + * .minimum() + * .minimumAmount() + * .paidAt() + * .paymentAttempts() + * .paymentFailedAt() + * .paymentStartedAt() + * .scheduledIssueAt() + * .shippingAddress() + * .status() + * .subscription() + * .subtotal() + * .syncFailedAt() + * .total() + * .voidedAt() + * .willAutoIssue() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CreatedInvoice = + CreatedInvoice( + checkRequired("id", id), + checkRequired("amountDue", amountDue), + checkRequired("autoCollection", autoCollection), + checkRequired("billingAddress", billingAddress), + checkRequired("createdAt", createdAt), + checkRequired("creditNotes", creditNotes).map { it.toImmutable() }, + checkRequired("currency", currency), + checkRequired("customer", customer), + checkRequired("customerBalanceTransactions", customerBalanceTransactions).map { + it.toImmutable() + }, + checkRequired("customerTaxId", customerTaxId), + checkRequired("discount", discount), + checkRequired("discounts", discounts).map { it.toImmutable() }, + checkRequired("dueDate", dueDate), + checkRequired("eligibleToIssueAt", eligibleToIssueAt), + checkRequired("hostedInvoiceUrl", hostedInvoiceUrl), + checkRequired("invoiceDate", invoiceDate), + checkRequired("invoiceNumber", invoiceNumber), + checkRequired("invoicePdf", invoicePdf), + checkRequired("invoiceSource", invoiceSource), + checkRequired("isPayableNow", isPayableNow), + checkRequired("issueFailedAt", issueFailedAt), + checkRequired("issuedAt", issuedAt), + checkRequired("lineItems", lineItems).map { it.toImmutable() }, + checkRequired("maximum", maximum), + checkRequired("maximumAmount", maximumAmount), + checkRequired("memo", memo), + checkRequired("metadata", metadata), + checkRequired("minimum", minimum), + checkRequired("minimumAmount", minimumAmount), + checkRequired("paidAt", paidAt), + checkRequired("paymentAttempts", paymentAttempts).map { it.toImmutable() }, + checkRequired("paymentFailedAt", paymentFailedAt), + checkRequired("paymentStartedAt", paymentStartedAt), + checkRequired("scheduledIssueAt", scheduledIssueAt), + checkRequired("shippingAddress", shippingAddress), + checkRequired("status", status), + checkRequired("subscription", subscription), + checkRequired("subtotal", subtotal), + checkRequired("syncFailedAt", syncFailedAt), + checkRequired("total", total), + checkRequired("voidedAt", voidedAt), + checkRequired("willAutoIssue", willAutoIssue), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CreatedInvoice = apply { + if (validated) { + return@apply + } + + id() + amountDue() + autoCollection().validate() + billingAddress()?.validate() + createdAt() + creditNotes().forEach { it.validate() } + currency() + customer().validate() + customerBalanceTransactions().forEach { it.validate() } + customerTaxId()?.validate() + discounts().forEach { it.validate() } + dueDate() + eligibleToIssueAt() + hostedInvoiceUrl() + invoiceDate() + invoiceNumber() + invoicePdf() + invoiceSource().validate() + isPayableNow() + issueFailedAt() + issuedAt() + lineItems().forEach { it.validate() } + maximum()?.validate() + maximumAmount() + memo() + metadata().validate() + minimum()?.validate() + minimumAmount() + paidAt() + paymentAttempts().forEach { it.validate() } + paymentFailedAt() + paymentStartedAt() + scheduledIssueAt() + shippingAddress()?.validate() + status().validate() + subscription()?.validate() + subtotal() + syncFailedAt() + total() + voidedAt() + willAutoIssue() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (id.asKnown() == null) 0 else 1) + + (if (amountDue.asKnown() == null) 0 else 1) + + (autoCollection.asKnown()?.validity() ?: 0) + + (billingAddress.asKnown()?.validity() ?: 0) + + (if (createdAt.asKnown() == null) 0 else 1) + + (creditNotes.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (customer.asKnown()?.validity() ?: 0) + + (customerBalanceTransactions.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + (customerTaxId.asKnown()?.validity() ?: 0) + + (discounts.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + (if (dueDate.asKnown() == null) 0 else 1) + + (if (eligibleToIssueAt.asKnown() == null) 0 else 1) + + (if (hostedInvoiceUrl.asKnown() == null) 0 else 1) + + (if (invoiceDate.asKnown() == null) 0 else 1) + + (if (invoiceNumber.asKnown() == null) 0 else 1) + + (if (invoicePdf.asKnown() == null) 0 else 1) + + (invoiceSource.asKnown()?.validity() ?: 0) + + (if (isPayableNow.asKnown() == null) 0 else 1) + + (if (issueFailedAt.asKnown() == null) 0 else 1) + + (if (issuedAt.asKnown() == null) 0 else 1) + + (lineItems.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + (maximum.asKnown()?.validity() ?: 0) + + (if (maximumAmount.asKnown() == null) 0 else 1) + + (if (memo.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (minimum.asKnown()?.validity() ?: 0) + + (if (minimumAmount.asKnown() == null) 0 else 1) + + (if (paidAt.asKnown() == null) 0 else 1) + + (paymentAttempts.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + (if (paymentFailedAt.asKnown() == null) 0 else 1) + + (if (paymentStartedAt.asKnown() == null) 0 else 1) + + (if (scheduledIssueAt.asKnown() == null) 0 else 1) + + (shippingAddress.asKnown()?.validity() ?: 0) + + (status.asKnown()?.validity() ?: 0) + + (subscription.asKnown()?.validity() ?: 0) + + (if (subtotal.asKnown() == null) 0 else 1) + + (if (syncFailedAt.asKnown() == null) 0 else 1) + + (if (total.asKnown() == null) 0 else 1) + + (if (voidedAt.asKnown() == null) 0 else 1) + + (if (willAutoIssue.asKnown() == null) 0 else 1) + + class AutoCollection + private constructor( + private val enabled: JsonField, + private val nextAttemptAt: JsonField, + private val numAttempts: JsonField, + private val previouslyAttemptedAt: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("enabled") + @ExcludeMissing + enabled: JsonField = JsonMissing.of(), + @JsonProperty("next_attempt_at") + @ExcludeMissing + nextAttemptAt: JsonField = JsonMissing.of(), + @JsonProperty("num_attempts") + @ExcludeMissing + numAttempts: JsonField = JsonMissing.of(), + @JsonProperty("previously_attempted_at") + @ExcludeMissing + previouslyAttemptedAt: JsonField = JsonMissing.of(), + ) : this(enabled, nextAttemptAt, numAttempts, previouslyAttemptedAt, mutableMapOf()) + + /** + * True only if auto-collection is enabled for this invoice. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun enabled(): Boolean? = enabled.getNullable("enabled") + + /** + * If the invoice is scheduled for auto-collection, this field will reflect when the + * next attempt will occur. If dunning has been exhausted, or auto-collection is not + * enabled for this invoice, this field will be `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun nextAttemptAt(): OffsetDateTime? = nextAttemptAt.getNullable("next_attempt_at") + + /** + * Number of auto-collection payment attempts. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun numAttempts(): Long? = numAttempts.getNullable("num_attempts") + + /** + * If Orb has ever attempted payment auto-collection for this invoice, this field will + * reflect when that attempt occurred. In conjunction with `next_attempt_at`, this can + * be used to tell whether the invoice is currently in dunning (that is, + * `previously_attempted_at` is non-null, and `next_attempt_time` is non-null), or if + * dunning has been exhausted (`previously_attempted_at` is non-null, but + * `next_attempt_time` is null). + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun previouslyAttemptedAt(): OffsetDateTime? = + previouslyAttemptedAt.getNullable("previously_attempted_at") + + /** + * Returns the raw JSON value of [enabled]. + * + * Unlike [enabled], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("enabled") @ExcludeMissing fun _enabled(): JsonField = enabled + + /** + * Returns the raw JSON value of [nextAttemptAt]. + * + * Unlike [nextAttemptAt], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("next_attempt_at") + @ExcludeMissing + fun _nextAttemptAt(): JsonField = nextAttemptAt + + /** + * Returns the raw JSON value of [numAttempts]. + * + * Unlike [numAttempts], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("num_attempts") + @ExcludeMissing + fun _numAttempts(): JsonField = numAttempts + + /** + * Returns the raw JSON value of [previouslyAttemptedAt]. + * + * Unlike [previouslyAttemptedAt], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("previously_attempted_at") + @ExcludeMissing + fun _previouslyAttemptedAt(): JsonField = previouslyAttemptedAt + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [AutoCollection]. + * + * The following fields are required: + * ```kotlin + * .enabled() + * .nextAttemptAt() + * .numAttempts() + * .previouslyAttemptedAt() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [AutoCollection]. */ + class Builder internal constructor() { + + private var enabled: JsonField? = null + private var nextAttemptAt: JsonField? = null + private var numAttempts: JsonField? = null + private var previouslyAttemptedAt: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(autoCollection: AutoCollection) = apply { + enabled = autoCollection.enabled + nextAttemptAt = autoCollection.nextAttemptAt + numAttempts = autoCollection.numAttempts + previouslyAttemptedAt = autoCollection.previouslyAttemptedAt + additionalProperties = autoCollection.additionalProperties.toMutableMap() + } + + /** True only if auto-collection is enabled for this invoice. */ + fun enabled(enabled: Boolean?) = enabled(JsonField.ofNullable(enabled)) + + /** + * Alias for [Builder.enabled]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun enabled(enabled: Boolean) = enabled(enabled as Boolean?) + + /** + * Sets [Builder.enabled] to an arbitrary JSON value. + * + * You should usually call [Builder.enabled] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun enabled(enabled: JsonField) = apply { this.enabled = enabled } + + /** + * If the invoice is scheduled for auto-collection, this field will reflect when the + * next attempt will occur. If dunning has been exhausted, or auto-collection is not + * enabled for this invoice, this field will be `null`. + */ + fun nextAttemptAt(nextAttemptAt: OffsetDateTime?) = + nextAttemptAt(JsonField.ofNullable(nextAttemptAt)) + + /** + * Sets [Builder.nextAttemptAt] to an arbitrary JSON value. + * + * You should usually call [Builder.nextAttemptAt] with a well-typed + * [OffsetDateTime] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun nextAttemptAt(nextAttemptAt: JsonField) = apply { + this.nextAttemptAt = nextAttemptAt + } + + /** Number of auto-collection payment attempts. */ + fun numAttempts(numAttempts: Long?) = numAttempts(JsonField.ofNullable(numAttempts)) + + /** + * Alias for [Builder.numAttempts]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun numAttempts(numAttempts: Long) = numAttempts(numAttempts as Long?) + + /** + * Sets [Builder.numAttempts] to an arbitrary JSON value. + * + * You should usually call [Builder.numAttempts] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun numAttempts(numAttempts: JsonField) = apply { + this.numAttempts = numAttempts + } + + /** + * If Orb has ever attempted payment auto-collection for this invoice, this field + * will reflect when that attempt occurred. In conjunction with `next_attempt_at`, + * this can be used to tell whether the invoice is currently in dunning (that is, + * `previously_attempted_at` is non-null, and `next_attempt_time` is non-null), or + * if dunning has been exhausted (`previously_attempted_at` is non-null, but + * `next_attempt_time` is null). + */ + fun previouslyAttemptedAt(previouslyAttemptedAt: OffsetDateTime?) = + previouslyAttemptedAt(JsonField.ofNullable(previouslyAttemptedAt)) + + /** + * Sets [Builder.previouslyAttemptedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.previouslyAttemptedAt] with a well-typed + * [OffsetDateTime] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun previouslyAttemptedAt(previouslyAttemptedAt: JsonField) = + apply { + this.previouslyAttemptedAt = previouslyAttemptedAt + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [AutoCollection]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .enabled() + * .nextAttemptAt() + * .numAttempts() + * .previouslyAttemptedAt() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): AutoCollection = + AutoCollection( + checkRequired("enabled", enabled), + checkRequired("nextAttemptAt", nextAttemptAt), + checkRequired("numAttempts", numAttempts), + checkRequired("previouslyAttemptedAt", previouslyAttemptedAt), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): AutoCollection = apply { + if (validated) { + return@apply + } + + enabled() + nextAttemptAt() + numAttempts() + previouslyAttemptedAt() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (enabled.asKnown() == null) 0 else 1) + + (if (nextAttemptAt.asKnown() == null) 0 else 1) + + (if (numAttempts.asKnown() == null) 0 else 1) + + (if (previouslyAttemptedAt.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AutoCollection && + enabled == other.enabled && + nextAttemptAt == other.nextAttemptAt && + numAttempts == other.numAttempts && + previouslyAttemptedAt == other.previouslyAttemptedAt && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + enabled, + nextAttemptAt, + numAttempts, + previouslyAttemptedAt, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AutoCollection{enabled=$enabled, nextAttemptAt=$nextAttemptAt, numAttempts=$numAttempts, previouslyAttemptedAt=$previouslyAttemptedAt, additionalProperties=$additionalProperties}" + } + + class CreditNote + private constructor( + private val id: JsonField, + private val creditNoteNumber: JsonField, + private val memo: JsonField, + private val reason: JsonField, + private val total: JsonField, + private val type: JsonField, + private val voidedAt: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("credit_note_number") + @ExcludeMissing + creditNoteNumber: JsonField = JsonMissing.of(), + @JsonProperty("memo") @ExcludeMissing memo: JsonField = JsonMissing.of(), + @JsonProperty("reason") + @ExcludeMissing + reason: JsonField = JsonMissing.of(), + @JsonProperty("total") @ExcludeMissing total: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("voided_at") + @ExcludeMissing + voidedAt: JsonField = JsonMissing.of(), + ) : this(id, creditNoteNumber, memo, reason, total, type, voidedAt, mutableMapOf()) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun id(): String = id.getRequired("id") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun creditNoteNumber(): String = creditNoteNumber.getRequired("credit_note_number") + + /** + * An optional memo supplied on the credit note. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun memo(): String? = memo.getNullable("memo") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun reason(): String = reason.getRequired("reason") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun total(): String = total.getRequired("total") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun type(): String = type.getRequired("type") + + /** + * If the credit note has a status of `void`, this gives a timestamp when the credit + * note was voided. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun voidedAt(): OffsetDateTime? = voidedAt.getNullable("voided_at") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [creditNoteNumber]. + * + * Unlike [creditNoteNumber], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("credit_note_number") + @ExcludeMissing + fun _creditNoteNumber(): JsonField = creditNoteNumber + + /** + * Returns the raw JSON value of [memo]. + * + * Unlike [memo], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("memo") @ExcludeMissing fun _memo(): JsonField = memo + + /** + * Returns the raw JSON value of [reason]. + * + * Unlike [reason], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason + + /** + * Returns the raw JSON value of [total]. + * + * Unlike [total], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("total") @ExcludeMissing fun _total(): JsonField = total + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + /** + * Returns the raw JSON value of [voidedAt]. + * + * Unlike [voidedAt], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("voided_at") + @ExcludeMissing + fun _voidedAt(): JsonField = voidedAt + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [CreditNote]. + * + * The following fields are required: + * ```kotlin + * .id() + * .creditNoteNumber() + * .memo() + * .reason() + * .total() + * .type() + * .voidedAt() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [CreditNote]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var creditNoteNumber: JsonField? = null + private var memo: JsonField? = null + private var reason: JsonField? = null + private var total: JsonField? = null + private var type: JsonField? = null + private var voidedAt: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(creditNote: CreditNote) = apply { + id = creditNote.id + creditNoteNumber = creditNote.creditNoteNumber + memo = creditNote.memo + reason = creditNote.reason + total = creditNote.total + type = creditNote.type + voidedAt = creditNote.voidedAt + additionalProperties = creditNote.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + fun creditNoteNumber(creditNoteNumber: String) = + creditNoteNumber(JsonField.of(creditNoteNumber)) + + /** + * Sets [Builder.creditNoteNumber] to an arbitrary JSON value. + * + * You should usually call [Builder.creditNoteNumber] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun creditNoteNumber(creditNoteNumber: JsonField) = apply { + this.creditNoteNumber = creditNoteNumber + } + + /** An optional memo supplied on the credit note. */ + fun memo(memo: String?) = memo(JsonField.ofNullable(memo)) + + /** + * Sets [Builder.memo] to an arbitrary JSON value. + * + * You should usually call [Builder.memo] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun memo(memo: JsonField) = apply { this.memo = memo } + + fun reason(reason: String) = reason(JsonField.of(reason)) + + /** + * Sets [Builder.reason] to an arbitrary JSON value. + * + * You should usually call [Builder.reason] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun reason(reason: JsonField) = apply { this.reason = reason } + + fun total(total: String) = total(JsonField.of(total)) + + /** + * Sets [Builder.total] to an arbitrary JSON value. + * + * You should usually call [Builder.total] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun total(total: JsonField) = apply { this.total = total } + + fun type(type: String) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun type(type: JsonField) = apply { this.type = type } + + /** + * If the credit note has a status of `void`, this gives a timestamp when the credit + * note was voided. + */ + fun voidedAt(voidedAt: OffsetDateTime?) = voidedAt(JsonField.ofNullable(voidedAt)) + + /** + * Sets [Builder.voidedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.voidedAt] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun voidedAt(voidedAt: JsonField) = apply { + this.voidedAt = voidedAt + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CreditNote]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .id() + * .creditNoteNumber() + * .memo() + * .reason() + * .total() + * .type() + * .voidedAt() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CreditNote = + CreditNote( + checkRequired("id", id), + checkRequired("creditNoteNumber", creditNoteNumber), + checkRequired("memo", memo), + checkRequired("reason", reason), + checkRequired("total", total), + checkRequired("type", type), + checkRequired("voidedAt", voidedAt), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CreditNote = apply { + if (validated) { + return@apply + } + + id() + creditNoteNumber() + memo() + reason() + total() + type() + voidedAt() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (id.asKnown() == null) 0 else 1) + + (if (creditNoteNumber.asKnown() == null) 0 else 1) + + (if (memo.asKnown() == null) 0 else 1) + + (if (reason.asKnown() == null) 0 else 1) + + (if (total.asKnown() == null) 0 else 1) + + (if (type.asKnown() == null) 0 else 1) + + (if (voidedAt.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CreditNote && + id == other.id && + creditNoteNumber == other.creditNoteNumber && + memo == other.memo && + reason == other.reason && + total == other.total && + type == other.type && + voidedAt == other.voidedAt && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + creditNoteNumber, + memo, + reason, + total, + type, + voidedAt, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CreditNote{id=$id, creditNoteNumber=$creditNoteNumber, memo=$memo, reason=$reason, total=$total, type=$type, voidedAt=$voidedAt, additionalProperties=$additionalProperties}" + } + + class CustomerBalanceTransaction + private constructor( + private val id: JsonField, + private val action: JsonField, + private val amount: JsonField, + private val createdAt: JsonField, + private val creditNote: JsonField, + private val description: JsonField, + private val endingBalance: JsonField, + private val invoice: JsonField, + private val startingBalance: JsonField, + private val type: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("action") + @ExcludeMissing + action: JsonField = JsonMissing.of(), + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + createdAt: JsonField = JsonMissing.of(), + @JsonProperty("credit_note") + @ExcludeMissing + creditNote: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + description: JsonField = JsonMissing.of(), + @JsonProperty("ending_balance") + @ExcludeMissing + endingBalance: JsonField = JsonMissing.of(), + @JsonProperty("invoice") + @ExcludeMissing + invoice: JsonField = JsonMissing.of(), + @JsonProperty("starting_balance") + @ExcludeMissing + startingBalance: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + ) : this( + id, + action, + amount, + createdAt, + creditNote, + description, + endingBalance, + invoice, + startingBalance, + type, + mutableMapOf(), + ) + + /** + * A unique id for this transaction. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun id(): String = id.getRequired("id") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun action(): Action = action.getRequired("action") + + /** + * The value of the amount changed in the transaction. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun amount(): String = amount.getRequired("amount") + + /** + * The creation time of this transaction. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun creditNote(): CreditNoteTiny? = creditNote.getNullable("credit_note") + + /** + * An optional description provided for manual customer balance adjustments. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun description(): String? = description.getNullable("description") + + /** + * The new value of the customer's balance prior to the transaction, in the customer's + * currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun endingBalance(): String = endingBalance.getRequired("ending_balance") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun invoice(): InvoiceTiny? = invoice.getNullable("invoice") + + /** + * The original value of the customer's balance prior to the transaction, in the + * customer's currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun startingBalance(): String = startingBalance.getRequired("starting_balance") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun type(): Type = type.getRequired("type") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [action]. + * + * Unlike [action], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("action") @ExcludeMissing fun _action(): JsonField = action + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [createdAt]. + * + * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt + + /** + * Returns the raw JSON value of [creditNote]. + * + * Unlike [creditNote], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("credit_note") + @ExcludeMissing + fun _creditNote(): JsonField = creditNote + + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description + + /** + * Returns the raw JSON value of [endingBalance]. + * + * Unlike [endingBalance], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("ending_balance") + @ExcludeMissing + fun _endingBalance(): JsonField = endingBalance + + /** + * Returns the raw JSON value of [invoice]. + * + * Unlike [invoice], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("invoice") + @ExcludeMissing + fun _invoice(): JsonField = invoice + + /** + * Returns the raw JSON value of [startingBalance]. + * + * Unlike [startingBalance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("starting_balance") + @ExcludeMissing + fun _startingBalance(): JsonField = startingBalance + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [CustomerBalanceTransaction]. + * + * The following fields are required: + * ```kotlin + * .id() + * .action() + * .amount() + * .createdAt() + * .creditNote() + * .description() + * .endingBalance() + * .invoice() + * .startingBalance() + * .type() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [CustomerBalanceTransaction]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var action: JsonField? = null + private var amount: JsonField? = null + private var createdAt: JsonField? = null + private var creditNote: JsonField? = null + private var description: JsonField? = null + private var endingBalance: JsonField? = null + private var invoice: JsonField? = null + private var startingBalance: JsonField? = null + private var type: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(customerBalanceTransaction: CustomerBalanceTransaction) = apply { + id = customerBalanceTransaction.id + action = customerBalanceTransaction.action + amount = customerBalanceTransaction.amount + createdAt = customerBalanceTransaction.createdAt + creditNote = customerBalanceTransaction.creditNote + description = customerBalanceTransaction.description + endingBalance = customerBalanceTransaction.endingBalance + invoice = customerBalanceTransaction.invoice + startingBalance = customerBalanceTransaction.startingBalance + type = customerBalanceTransaction.type + additionalProperties = + customerBalanceTransaction.additionalProperties.toMutableMap() + } + + /** A unique id for this transaction. */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + fun action(action: Action) = action(JsonField.of(action)) + + /** + * Sets [Builder.action] to an arbitrary JSON value. + * + * You should usually call [Builder.action] with a well-typed [Action] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun action(action: JsonField) = apply { this.action = action } + + /** The value of the amount changed in the transaction. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The creation time of this transaction. */ + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + + /** + * Sets [Builder.createdAt] to an arbitrary JSON value. + * + * You should usually call [Builder.createdAt] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun createdAt(createdAt: JsonField) = apply { + this.createdAt = createdAt + } + + fun creditNote(creditNote: CreditNoteTiny?) = + creditNote(JsonField.ofNullable(creditNote)) + + /** + * Sets [Builder.creditNote] to an arbitrary JSON value. + * + * You should usually call [Builder.creditNote] with a well-typed [CreditNoteTiny] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun creditNote(creditNote: JsonField) = apply { + this.creditNote = creditNote + } + + /** An optional description provided for manual customer balance adjustments. */ + fun description(description: String?) = + description(JsonField.ofNullable(description)) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun description(description: JsonField) = apply { + this.description = description + } + + /** + * The new value of the customer's balance prior to the transaction, in the + * customer's currency. + */ + fun endingBalance(endingBalance: String) = + endingBalance(JsonField.of(endingBalance)) + + /** + * Sets [Builder.endingBalance] to an arbitrary JSON value. + * + * You should usually call [Builder.endingBalance] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun endingBalance(endingBalance: JsonField) = apply { + this.endingBalance = endingBalance + } + + fun invoice(invoice: InvoiceTiny?) = invoice(JsonField.ofNullable(invoice)) + + /** + * Sets [Builder.invoice] to an arbitrary JSON value. + * + * You should usually call [Builder.invoice] with a well-typed [InvoiceTiny] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun invoice(invoice: JsonField) = apply { this.invoice = invoice } + + /** + * The original value of the customer's balance prior to the transaction, in the + * customer's currency. + */ + fun startingBalance(startingBalance: String) = + startingBalance(JsonField.of(startingBalance)) + + /** + * Sets [Builder.startingBalance] to an arbitrary JSON value. + * + * You should usually call [Builder.startingBalance] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun startingBalance(startingBalance: JsonField) = apply { + this.startingBalance = startingBalance + } + + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun type(type: JsonField) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CustomerBalanceTransaction]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .id() + * .action() + * .amount() + * .createdAt() + * .creditNote() + * .description() + * .endingBalance() + * .invoice() + * .startingBalance() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CustomerBalanceTransaction = + CustomerBalanceTransaction( + checkRequired("id", id), + checkRequired("action", action), + checkRequired("amount", amount), + checkRequired("createdAt", createdAt), + checkRequired("creditNote", creditNote), + checkRequired("description", description), + checkRequired("endingBalance", endingBalance), + checkRequired("invoice", invoice), + checkRequired("startingBalance", startingBalance), + checkRequired("type", type), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CustomerBalanceTransaction = apply { + if (validated) { + return@apply + } + + id() + action().validate() + amount() + createdAt() + creditNote()?.validate() + description() + endingBalance() + invoice()?.validate() + startingBalance() + type().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (id.asKnown() == null) 0 else 1) + + (action.asKnown()?.validity() ?: 0) + + (if (amount.asKnown() == null) 0 else 1) + + (if (createdAt.asKnown() == null) 0 else 1) + + (creditNote.asKnown()?.validity() ?: 0) + + (if (description.asKnown() == null) 0 else 1) + + (if (endingBalance.asKnown() == null) 0 else 1) + + (invoice.asKnown()?.validity() ?: 0) + + (if (startingBalance.asKnown() == null) 0 else 1) + + (type.asKnown()?.validity() ?: 0) + + class Action @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val APPLIED_TO_INVOICE = of("applied_to_invoice") + + val MANUAL_ADJUSTMENT = of("manual_adjustment") + + val PRORATED_REFUND = of("prorated_refund") + + val REVERT_PRORATED_REFUND = of("revert_prorated_refund") + + val RETURN_FROM_VOIDING = of("return_from_voiding") + + val CREDIT_NOTE_APPLIED = of("credit_note_applied") + + val CREDIT_NOTE_VOIDED = of("credit_note_voided") + + val OVERPAYMENT_REFUND = of("overpayment_refund") + + val EXTERNAL_PAYMENT = of("external_payment") + + val SMALL_INVOICE_CARRYOVER = of("small_invoice_carryover") + + fun of(value: String) = Action(JsonField.of(value)) + } + + /** An enum containing [Action]'s known values. */ + enum class Known { + APPLIED_TO_INVOICE, + MANUAL_ADJUSTMENT, + PRORATED_REFUND, + REVERT_PRORATED_REFUND, + RETURN_FROM_VOIDING, + CREDIT_NOTE_APPLIED, + CREDIT_NOTE_VOIDED, + OVERPAYMENT_REFUND, + EXTERNAL_PAYMENT, + SMALL_INVOICE_CARRYOVER, + } + + /** + * An enum containing [Action]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Action] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + APPLIED_TO_INVOICE, + MANUAL_ADJUSTMENT, + PRORATED_REFUND, + REVERT_PRORATED_REFUND, + RETURN_FROM_VOIDING, + CREDIT_NOTE_APPLIED, + CREDIT_NOTE_VOIDED, + OVERPAYMENT_REFUND, + EXTERNAL_PAYMENT, + SMALL_INVOICE_CARRYOVER, + /** + * An enum member indicating that [Action] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + APPLIED_TO_INVOICE -> Value.APPLIED_TO_INVOICE + MANUAL_ADJUSTMENT -> Value.MANUAL_ADJUSTMENT + PRORATED_REFUND -> Value.PRORATED_REFUND + REVERT_PRORATED_REFUND -> Value.REVERT_PRORATED_REFUND + RETURN_FROM_VOIDING -> Value.RETURN_FROM_VOIDING + CREDIT_NOTE_APPLIED -> Value.CREDIT_NOTE_APPLIED + CREDIT_NOTE_VOIDED -> Value.CREDIT_NOTE_VOIDED + OVERPAYMENT_REFUND -> Value.OVERPAYMENT_REFUND + EXTERNAL_PAYMENT -> Value.EXTERNAL_PAYMENT + SMALL_INVOICE_CARRYOVER -> Value.SMALL_INVOICE_CARRYOVER + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + APPLIED_TO_INVOICE -> Known.APPLIED_TO_INVOICE + MANUAL_ADJUSTMENT -> Known.MANUAL_ADJUSTMENT + PRORATED_REFUND -> Known.PRORATED_REFUND + REVERT_PRORATED_REFUND -> Known.REVERT_PRORATED_REFUND + RETURN_FROM_VOIDING -> Known.RETURN_FROM_VOIDING + CREDIT_NOTE_APPLIED -> Known.CREDIT_NOTE_APPLIED + CREDIT_NOTE_VOIDED -> Known.CREDIT_NOTE_VOIDED + OVERPAYMENT_REFUND -> Known.OVERPAYMENT_REFUND + EXTERNAL_PAYMENT -> Known.EXTERNAL_PAYMENT + SMALL_INVOICE_CARRYOVER -> Known.SMALL_INVOICE_CARRYOVER + else -> throw OrbInvalidDataException("Unknown Action: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Action = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Action && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class Type @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val INCREMENT = of("increment") + + val DECREMENT = of("decrement") + + fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + INCREMENT, + DECREMENT, + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + INCREMENT, + DECREMENT, + /** + * An enum member indicating that [Type] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + INCREMENT -> Value.INCREMENT + DECREMENT -> Value.DECREMENT + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + INCREMENT -> Known.INCREMENT + DECREMENT -> Known.DECREMENT + else -> throw OrbInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CustomerBalanceTransaction && + id == other.id && + action == other.action && + amount == other.amount && + createdAt == other.createdAt && + creditNote == other.creditNote && + description == other.description && + endingBalance == other.endingBalance && + invoice == other.invoice && + startingBalance == other.startingBalance && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + action, + amount, + createdAt, + creditNote, + description, + endingBalance, + invoice, + startingBalance, + type, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CustomerBalanceTransaction{id=$id, action=$action, amount=$amount, createdAt=$createdAt, creditNote=$creditNote, description=$description, endingBalance=$endingBalance, invoice=$invoice, startingBalance=$startingBalance, type=$type, additionalProperties=$additionalProperties}" + } + + class InvoiceSource @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val SUBSCRIPTION = of("subscription") + + val PARTIAL = of("partial") + + val ONE_OFF = of("one_off") + + fun of(value: String) = InvoiceSource(JsonField.of(value)) + } + + /** An enum containing [InvoiceSource]'s known values. */ + enum class Known { + SUBSCRIPTION, + PARTIAL, + ONE_OFF, + } + + /** + * An enum containing [InvoiceSource]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [InvoiceSource] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + SUBSCRIPTION, + PARTIAL, + ONE_OFF, + /** + * An enum member indicating that [InvoiceSource] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + SUBSCRIPTION -> Value.SUBSCRIPTION + PARTIAL -> Value.PARTIAL + ONE_OFF -> Value.ONE_OFF + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + SUBSCRIPTION -> Known.SUBSCRIPTION + PARTIAL -> Known.PARTIAL + ONE_OFF -> Known.ONE_OFF + else -> throw OrbInvalidDataException("Unknown InvoiceSource: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): InvoiceSource = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is InvoiceSource && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class LineItem + private constructor( + private val id: JsonField, + private val adjustedSubtotal: JsonField, + private val adjustments: JsonField>, + private val amount: JsonField, + private val creditsApplied: JsonField, + private val discount: JsonField, + private val endDate: JsonField, + private val filter: JsonField, + private val grouping: JsonField, + private val maximum: JsonField, + private val maximumAmount: JsonField, + private val minimum: JsonField, + private val minimumAmount: JsonField, + private val name: JsonField, + private val partiallyInvoicedAmount: JsonField, + private val price: JsonField, + private val quantity: JsonField, + private val startDate: JsonField, + private val subLineItems: JsonField>, + private val subtotal: JsonField, + private val taxAmounts: JsonField>, + private val usageCustomerIds: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("adjusted_subtotal") + @ExcludeMissing + adjustedSubtotal: JsonField = JsonMissing.of(), + @JsonProperty("adjustments") + @ExcludeMissing + adjustments: JsonField> = JsonMissing.of(), + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("credits_applied") + @ExcludeMissing + creditsApplied: JsonField = JsonMissing.of(), + @JsonProperty("discount") + @ExcludeMissing + discount: JsonField = JsonMissing.of(), + @JsonProperty("end_date") + @ExcludeMissing + endDate: JsonField = JsonMissing.of(), + @JsonProperty("filter") + @ExcludeMissing + filter: JsonField = JsonMissing.of(), + @JsonProperty("grouping") + @ExcludeMissing + grouping: JsonField = JsonMissing.of(), + @JsonProperty("maximum") + @ExcludeMissing + maximum: JsonField = JsonMissing.of(), + @JsonProperty("maximum_amount") + @ExcludeMissing + maximumAmount: JsonField = JsonMissing.of(), + @JsonProperty("minimum") + @ExcludeMissing + minimum: JsonField = JsonMissing.of(), + @JsonProperty("minimum_amount") + @ExcludeMissing + minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("partially_invoiced_amount") + @ExcludeMissing + partiallyInvoicedAmount: JsonField = JsonMissing.of(), + @JsonProperty("price") @ExcludeMissing price: JsonField = JsonMissing.of(), + @JsonProperty("quantity") + @ExcludeMissing + quantity: JsonField = JsonMissing.of(), + @JsonProperty("start_date") + @ExcludeMissing + startDate: JsonField = JsonMissing.of(), + @JsonProperty("sub_line_items") + @ExcludeMissing + subLineItems: JsonField> = JsonMissing.of(), + @JsonProperty("subtotal") + @ExcludeMissing + subtotal: JsonField = JsonMissing.of(), + @JsonProperty("tax_amounts") + @ExcludeMissing + taxAmounts: JsonField> = JsonMissing.of(), + @JsonProperty("usage_customer_ids") + @ExcludeMissing + usageCustomerIds: JsonField> = JsonMissing.of(), + ) : this( + id, + adjustedSubtotal, + adjustments, + amount, + creditsApplied, + discount, + endDate, + filter, + grouping, + maximum, + maximumAmount, + minimum, + minimumAmount, + name, + partiallyInvoicedAmount, + price, + quantity, + startDate, + subLineItems, + subtotal, + taxAmounts, + usageCustomerIds, + mutableMapOf(), + ) + + /** + * A unique ID for this line item. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun id(): String = id.getRequired("id") + + /** + * The line amount after any adjustments and before overage conversion, credits and + * partial invoicing. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun adjustedSubtotal(): String = adjustedSubtotal.getRequired("adjusted_subtotal") + + /** + * All adjustments applied to the line item in the order they were applied based on + * invoice calculations (ie. usage discounts -> amount discounts -> percentage discounts + * -> minimums -> maximums). + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun adjustments(): List = adjustments.getRequired("adjustments") + + /** + * The final amount for a line item after all adjustments and pre paid credits have been + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun amount(): String = amount.getRequired("amount") + + /** + * The number of prepaid credits applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun creditsApplied(): String = creditsApplied.getRequired("credits_applied") + + /** + * This field is deprecated in favor of `adjustments` + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + @Deprecated("deprecated") fun discount(): Discount? = discount.getNullable("discount") + + /** + * The end date of the range of time applied for this line item's price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun endDate(): OffsetDateTime = endDate.getRequired("end_date") + + /** + * An additional filter that was used to calculate the usage for this line item. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun filter(): String? = filter.getNullable("filter") + + /** + * [DEPRECATED] For configured prices that are split by a grouping key, this will be + * populated with the key and a value. The `amount` and `subtotal` will be the values + * for this particular grouping. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun grouping(): String? = grouping.getNullable("grouping") + + /** + * This field is deprecated in favor of `adjustments`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + @Deprecated("deprecated") fun maximum(): Maximum? = maximum.getNullable("maximum") + + /** + * This field is deprecated in favor of `adjustments`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + @Deprecated("deprecated") + fun maximumAmount(): String? = maximumAmount.getNullable("maximum_amount") + + /** + * This field is deprecated in favor of `adjustments`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + @Deprecated("deprecated") fun minimum(): Minimum? = minimum.getNullable("minimum") + + /** + * This field is deprecated in favor of `adjustments`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + @Deprecated("deprecated") + fun minimumAmount(): String? = minimumAmount.getNullable("minimum_amount") + + /** + * The name of the price associated with this line item. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * Any amount applied from a partial invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun partiallyInvoicedAmount(): String = + partiallyInvoicedAmount.getRequired("partially_invoiced_amount") + + /** + * The Price resource represents a price that can be billed on a subscription, resulting + * in a charge on an invoice in the form of an invoice line item. Prices take a quantity + * and determine an amount to bill. + * + * Orb supports a few different pricing models out of the box. Each of these models is + * serialized differently in a given Price object. The model_type field determines the + * key for the configuration object that is present. + * + * For more on the types of prices, see + * [the core concepts documentation](/core-concepts#plan-and-price) + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun price(): Price = price.getRequired("price") + + /** + * Either the fixed fee quantity or the usage during the service period. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun quantity(): Double = quantity.getRequired("quantity") + + /** + * The start date of the range of time applied for this line item's price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun startDate(): OffsetDateTime = startDate.getRequired("start_date") + + /** + * For complex pricing structures, the line item can be broken down further in + * `sub_line_items`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun subLineItems(): List = subLineItems.getRequired("sub_line_items") + + /** + * The line amount before any adjustments. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun subtotal(): String = subtotal.getRequired("subtotal") + + /** + * An array of tax rates and their incurred tax amounts. Empty if no tax integration is + * configured. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun taxAmounts(): List = taxAmounts.getRequired("tax_amounts") + + /** + * A list of customer ids that were used to calculate the usage for this line item. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun usageCustomerIds(): List? = + usageCustomerIds.getNullable("usage_customer_ids") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [adjustedSubtotal]. + * + * Unlike [adjustedSubtotal], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("adjusted_subtotal") + @ExcludeMissing + fun _adjustedSubtotal(): JsonField = adjustedSubtotal + + /** + * Returns the raw JSON value of [adjustments]. + * + * Unlike [adjustments], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("adjustments") + @ExcludeMissing + fun _adjustments(): JsonField> = adjustments + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [creditsApplied]. + * + * Unlike [creditsApplied], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("credits_applied") + @ExcludeMissing + fun _creditsApplied(): JsonField = creditsApplied + + /** + * Returns the raw JSON value of [discount]. + * + * Unlike [discount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @Deprecated("deprecated") + @JsonProperty("discount") + @ExcludeMissing + fun _discount(): JsonField = discount + + /** + * Returns the raw JSON value of [endDate]. + * + * Unlike [endDate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("end_date") + @ExcludeMissing + fun _endDate(): JsonField = endDate + + /** + * Returns the raw JSON value of [filter]. + * + * Unlike [filter], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("filter") @ExcludeMissing fun _filter(): JsonField = filter + + /** + * Returns the raw JSON value of [grouping]. + * + * Unlike [grouping], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("grouping") @ExcludeMissing fun _grouping(): JsonField = grouping + + /** + * Returns the raw JSON value of [maximum]. + * + * Unlike [maximum], this method doesn't throw if the JSON field has an unexpected type. + */ + @Deprecated("deprecated") + @JsonProperty("maximum") + @ExcludeMissing + fun _maximum(): JsonField = maximum + + /** + * Returns the raw JSON value of [maximumAmount]. + * + * Unlike [maximumAmount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @Deprecated("deprecated") + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount + + /** + * Returns the raw JSON value of [minimum]. + * + * Unlike [minimum], this method doesn't throw if the JSON field has an unexpected type. + */ + @Deprecated("deprecated") + @JsonProperty("minimum") + @ExcludeMissing + fun _minimum(): JsonField = minimum + + /** + * Returns the raw JSON value of [minimumAmount]. + * + * Unlike [minimumAmount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @Deprecated("deprecated") + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [partiallyInvoicedAmount]. + * + * Unlike [partiallyInvoicedAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("partially_invoiced_amount") + @ExcludeMissing + fun _partiallyInvoicedAmount(): JsonField = partiallyInvoicedAmount + + /** + * Returns the raw JSON value of [price]. + * + * Unlike [price], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("price") @ExcludeMissing fun _price(): JsonField = price + + /** + * Returns the raw JSON value of [quantity]. + * + * Unlike [quantity], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("quantity") @ExcludeMissing fun _quantity(): JsonField = quantity + + /** + * Returns the raw JSON value of [startDate]. + * + * Unlike [startDate], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate + + /** + * Returns the raw JSON value of [subLineItems]. + * + * Unlike [subLineItems], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("sub_line_items") + @ExcludeMissing + fun _subLineItems(): JsonField> = subLineItems + + /** + * Returns the raw JSON value of [subtotal]. + * + * Unlike [subtotal], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("subtotal") @ExcludeMissing fun _subtotal(): JsonField = subtotal + + /** + * Returns the raw JSON value of [taxAmounts]. + * + * Unlike [taxAmounts], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tax_amounts") + @ExcludeMissing + fun _taxAmounts(): JsonField> = taxAmounts + + /** + * Returns the raw JSON value of [usageCustomerIds]. + * + * Unlike [usageCustomerIds], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("usage_customer_ids") + @ExcludeMissing + fun _usageCustomerIds(): JsonField> = usageCustomerIds + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [LineItem]. + * + * The following fields are required: + * ```kotlin + * .id() + * .adjustedSubtotal() + * .adjustments() + * .amount() + * .creditsApplied() + * .discount() + * .endDate() + * .filter() + * .grouping() + * .maximum() + * .maximumAmount() + * .minimum() + * .minimumAmount() + * .name() + * .partiallyInvoicedAmount() + * .price() + * .quantity() + * .startDate() + * .subLineItems() + * .subtotal() + * .taxAmounts() + * .usageCustomerIds() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LineItem]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var adjustedSubtotal: JsonField? = null + private var adjustments: JsonField>? = null + private var amount: JsonField? = null + private var creditsApplied: JsonField? = null + private var discount: JsonField? = null + private var endDate: JsonField? = null + private var filter: JsonField? = null + private var grouping: JsonField? = null + private var maximum: JsonField? = null + private var maximumAmount: JsonField? = null + private var minimum: JsonField? = null + private var minimumAmount: JsonField? = null + private var name: JsonField? = null + private var partiallyInvoicedAmount: JsonField? = null + private var price: JsonField? = null + private var quantity: JsonField? = null + private var startDate: JsonField? = null + private var subLineItems: JsonField>? = null + private var subtotal: JsonField? = null + private var taxAmounts: JsonField>? = null + private var usageCustomerIds: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(lineItem: LineItem) = apply { + id = lineItem.id + adjustedSubtotal = lineItem.adjustedSubtotal + adjustments = lineItem.adjustments.map { it.toMutableList() } + amount = lineItem.amount + creditsApplied = lineItem.creditsApplied + discount = lineItem.discount + endDate = lineItem.endDate + filter = lineItem.filter + grouping = lineItem.grouping + maximum = lineItem.maximum + maximumAmount = lineItem.maximumAmount + minimum = lineItem.minimum + minimumAmount = lineItem.minimumAmount + name = lineItem.name + partiallyInvoicedAmount = lineItem.partiallyInvoicedAmount + price = lineItem.price + quantity = lineItem.quantity + startDate = lineItem.startDate + subLineItems = lineItem.subLineItems.map { it.toMutableList() } + subtotal = lineItem.subtotal + taxAmounts = lineItem.taxAmounts.map { it.toMutableList() } + usageCustomerIds = lineItem.usageCustomerIds.map { it.toMutableList() } + additionalProperties = lineItem.additionalProperties.toMutableMap() + } + + /** A unique ID for this line item. */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + /** + * The line amount after any adjustments and before overage conversion, credits and + * partial invoicing. + */ + fun adjustedSubtotal(adjustedSubtotal: String) = + adjustedSubtotal(JsonField.of(adjustedSubtotal)) + + /** + * Sets [Builder.adjustedSubtotal] to an arbitrary JSON value. + * + * You should usually call [Builder.adjustedSubtotal] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun adjustedSubtotal(adjustedSubtotal: JsonField) = apply { + this.adjustedSubtotal = adjustedSubtotal + } + + /** + * All adjustments applied to the line item in the order they were applied based on + * invoice calculations (ie. usage discounts -> amount discounts -> percentage + * discounts -> minimums -> maximums). + */ + fun adjustments(adjustments: List) = + adjustments(JsonField.of(adjustments)) + + /** + * Sets [Builder.adjustments] to an arbitrary JSON value. + * + * You should usually call [Builder.adjustments] with a well-typed + * `List` value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun adjustments(adjustments: JsonField>) = apply { + this.adjustments = adjustments.map { it.toMutableList() } + } + + /** + * Adds a single [Adjustment] to [adjustments]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addAdjustment(adjustment: Adjustment) = apply { + adjustments = + (adjustments ?: JsonField.of(mutableListOf())).also { + checkKnown("adjustments", it).add(adjustment) + } + } + + /** + * Alias for calling [addAdjustment] with + * `Adjustment.ofUsageDiscount(usageDiscount)`. + */ + fun addAdjustment(usageDiscount: MonetaryUsageDiscountAdjustment) = + addAdjustment(Adjustment.ofUsageDiscount(usageDiscount)) + + /** + * Alias for calling [addAdjustment] with + * `Adjustment.ofAmountDiscount(amountDiscount)`. + */ + fun addAdjustment(amountDiscount: MonetaryAmountDiscountAdjustment) = + addAdjustment(Adjustment.ofAmountDiscount(amountDiscount)) + + /** + * Alias for calling [addAdjustment] with + * `Adjustment.ofPercentageDiscount(percentageDiscount)`. + */ + fun addAdjustment(percentageDiscount: MonetaryPercentageDiscountAdjustment) = + addAdjustment(Adjustment.ofPercentageDiscount(percentageDiscount)) + + /** Alias for calling [addAdjustment] with `Adjustment.ofMinimum(minimum)`. */ + fun addAdjustment(minimum: MonetaryMinimumAdjustment) = + addAdjustment(Adjustment.ofMinimum(minimum)) + + /** Alias for calling [addAdjustment] with `Adjustment.ofMaximum(maximum)`. */ + fun addAdjustment(maximum: MonetaryMaximumAdjustment) = + addAdjustment(Adjustment.ofMaximum(maximum)) + + /** + * The final amount for a line item after all adjustments and pre paid credits have + * been applied. + */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The number of prepaid credits applied. */ + fun creditsApplied(creditsApplied: String) = + creditsApplied(JsonField.of(creditsApplied)) + + /** + * Sets [Builder.creditsApplied] to an arbitrary JSON value. + * + * You should usually call [Builder.creditsApplied] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun creditsApplied(creditsApplied: JsonField) = apply { + this.creditsApplied = creditsApplied + } + + /** This field is deprecated in favor of `adjustments` */ + @Deprecated("deprecated") + fun discount(discount: Discount?) = discount(JsonField.ofNullable(discount)) + + /** + * Sets [Builder.discount] to an arbitrary JSON value. + * + * You should usually call [Builder.discount] with a well-typed [Discount] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + @Deprecated("deprecated") + fun discount(discount: JsonField) = apply { this.discount = discount } + + /** Alias for calling [discount] with `Discount.ofPercentage(percentage)`. */ + @Deprecated("deprecated") + fun discount(percentage: PercentageDiscount) = + discount(Discount.ofPercentage(percentage)) + + /** + * Alias for calling [discount] with the following: + * ```kotlin + * PercentageDiscount.builder() + * .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + * .percentageDiscount(percentageDiscount) + * .build() + * ``` + */ + @Deprecated("deprecated") + fun percentageDiscount(percentageDiscount: Double) = + discount( + PercentageDiscount.builder() + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(percentageDiscount) + .build() + ) + + /** Alias for calling [discount] with `Discount.ofTrial(trial)`. */ + @Deprecated("deprecated") + fun discount(trial: TrialDiscount) = discount(Discount.ofTrial(trial)) + + /** Alias for calling [discount] with `Discount.ofUsage(usage)`. */ + @Deprecated("deprecated") + fun discount(usage: UsageDiscount) = discount(Discount.ofUsage(usage)) + + /** + * Alias for calling [discount] with the following: + * ```kotlin + * UsageDiscount.builder() + * .discountType(UsageDiscount.DiscountType.USAGE) + * .usageDiscount(usageDiscount) + * .build() + * ``` + */ + @Deprecated("deprecated") + fun usageDiscount(usageDiscount: Double) = + discount( + UsageDiscount.builder() + .discountType(UsageDiscount.DiscountType.USAGE) + .usageDiscount(usageDiscount) + .build() + ) + + /** Alias for calling [discount] with `Discount.ofAmount(amount)`. */ + @Deprecated("deprecated") + fun discount(amount: AmountDiscount) = discount(Discount.ofAmount(amount)) + + /** + * Alias for calling [discount] with the following: + * ```kotlin + * AmountDiscount.builder() + * .discountType(AmountDiscount.DiscountType.AMOUNT) + * .amountDiscount(amountDiscount) + * .build() + * ``` + */ + @Deprecated("deprecated") + fun amountDiscount(amountDiscount: String) = + discount( + AmountDiscount.builder() + .discountType(AmountDiscount.DiscountType.AMOUNT) + .amountDiscount(amountDiscount) + .build() + ) + + /** The end date of the range of time applied for this line item's price. */ + fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + + /** + * Sets [Builder.endDate] to an arbitrary JSON value. + * + * You should usually call [Builder.endDate] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + /** An additional filter that was used to calculate the usage for this line item. */ + fun filter(filter: String?) = filter(JsonField.ofNullable(filter)) + + /** + * Sets [Builder.filter] to an arbitrary JSON value. + * + * You should usually call [Builder.filter] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun filter(filter: JsonField) = apply { this.filter = filter } + + /** + * [DEPRECATED] For configured prices that are split by a grouping key, this will be + * populated with the key and a value. The `amount` and `subtotal` will be the + * values for this particular grouping. + */ + fun grouping(grouping: String?) = grouping(JsonField.ofNullable(grouping)) + + /** + * Sets [Builder.grouping] to an arbitrary JSON value. + * + * You should usually call [Builder.grouping] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun grouping(grouping: JsonField) = apply { this.grouping = grouping } + + /** This field is deprecated in favor of `adjustments`. */ + @Deprecated("deprecated") + fun maximum(maximum: Maximum?) = maximum(JsonField.ofNullable(maximum)) + + /** + * Sets [Builder.maximum] to an arbitrary JSON value. + * + * You should usually call [Builder.maximum] with a well-typed [Maximum] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + @Deprecated("deprecated") + fun maximum(maximum: JsonField) = apply { this.maximum = maximum } + + /** This field is deprecated in favor of `adjustments`. */ + @Deprecated("deprecated") + fun maximumAmount(maximumAmount: String?) = + maximumAmount(JsonField.ofNullable(maximumAmount)) + + /** + * Sets [Builder.maximumAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.maximumAmount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + @Deprecated("deprecated") + fun maximumAmount(maximumAmount: JsonField) = apply { + this.maximumAmount = maximumAmount + } + + /** This field is deprecated in favor of `adjustments`. */ + @Deprecated("deprecated") + fun minimum(minimum: Minimum?) = minimum(JsonField.ofNullable(minimum)) + + /** + * Sets [Builder.minimum] to an arbitrary JSON value. + * + * You should usually call [Builder.minimum] with a well-typed [Minimum] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + @Deprecated("deprecated") + fun minimum(minimum: JsonField) = apply { this.minimum = minimum } + + /** This field is deprecated in favor of `adjustments`. */ + @Deprecated("deprecated") + fun minimumAmount(minimumAmount: String?) = + minimumAmount(JsonField.ofNullable(minimumAmount)) + + /** + * Sets [Builder.minimumAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumAmount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + @Deprecated("deprecated") + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount + } + + /** The name of the price associated with this line item. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Any amount applied from a partial invoice */ + fun partiallyInvoicedAmount(partiallyInvoicedAmount: String) = + partiallyInvoicedAmount(JsonField.of(partiallyInvoicedAmount)) + + /** + * Sets [Builder.partiallyInvoicedAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.partiallyInvoicedAmount] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun partiallyInvoicedAmount(partiallyInvoicedAmount: JsonField) = apply { + this.partiallyInvoicedAmount = partiallyInvoicedAmount + } + + /** + * The Price resource represents a price that can be billed on a subscription, + * resulting in a charge on an invoice in the form of an invoice line item. Prices + * take a quantity and determine an amount to bill. + * + * Orb supports a few different pricing models out of the box. Each of these models + * is serialized differently in a given Price object. The model_type field + * determines the key for the configuration object that is present. + * + * For more on the types of prices, see + * [the core concepts documentation](/core-concepts#plan-and-price) + */ + fun price(price: Price) = price(JsonField.of(price)) + + /** + * Sets [Builder.price] to an arbitrary JSON value. + * + * You should usually call [Builder.price] with a well-typed [Price] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun price(price: JsonField) = apply { this.price = price } + + /** Alias for calling [price] with `Price.ofUnit(unit)`. */ + fun price(unit: Price.Unit) = price(Price.ofUnit(unit)) + + /** Alias for calling [price] with `Price.ofTiered(tiered)`. */ + fun price(tiered: Price.Tiered) = price(Price.ofTiered(tiered)) + + /** Alias for calling [price] with `Price.ofBulk(bulk)`. */ + fun price(bulk: Price.Bulk) = price(Price.ofBulk(bulk)) + + /** Alias for calling [price] with `Price.ofPackage(package_)`. */ + fun price(package_: Price.Package) = price(Price.ofPackage(package_)) + + /** Alias for calling [price] with `Price.ofMatrix(matrix)`. */ + fun price(matrix: Price.Matrix) = price(Price.ofMatrix(matrix)) + + /** + * Alias for calling [price] with + * `Price.ofThresholdTotalAmount(thresholdTotalAmount)`. + */ + fun price(thresholdTotalAmount: Price.ThresholdTotalAmount) = + price(Price.ofThresholdTotalAmount(thresholdTotalAmount)) + + /** Alias for calling [price] with `Price.ofTieredPackage(tieredPackage)`. */ + fun price(tieredPackage: Price.TieredPackage) = + price(Price.ofTieredPackage(tieredPackage)) + + /** + * Alias for calling [price] with `Price.ofTieredWithMinimum(tieredWithMinimum)`. + */ + fun price(tieredWithMinimum: Price.TieredWithMinimum) = + price(Price.ofTieredWithMinimum(tieredWithMinimum)) + + /** Alias for calling [price] with `Price.ofGroupedTiered(groupedTiered)`. */ + fun price(groupedTiered: Price.GroupedTiered) = + price(Price.ofGroupedTiered(groupedTiered)) + + /** + * Alias for calling [price] with + * `Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)`. + */ + fun price(tieredPackageWithMinimum: Price.TieredPackageWithMinimum) = + price(Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)) + + /** + * Alias for calling [price] with + * `Price.ofPackageWithAllocation(packageWithAllocation)`. + */ + fun price(packageWithAllocation: Price.PackageWithAllocation) = + price(Price.ofPackageWithAllocation(packageWithAllocation)) + + /** Alias for calling [price] with `Price.ofUnitWithPercent(unitWithPercent)`. */ + fun price(unitWithPercent: Price.UnitWithPercent) = + price(Price.ofUnitWithPercent(unitWithPercent)) + + /** + * Alias for calling [price] with + * `Price.ofMatrixWithAllocation(matrixWithAllocation)`. + */ + fun price(matrixWithAllocation: Price.MatrixWithAllocation) = + price(Price.ofMatrixWithAllocation(matrixWithAllocation)) + + /** + * Alias for calling [price] with + * `Price.ofTieredWithProration(tieredWithProration)`. + */ + fun price(tieredWithProration: Price.TieredWithProration) = + price(Price.ofTieredWithProration(tieredWithProration)) + + /** + * Alias for calling [price] with `Price.ofUnitWithProration(unitWithProration)`. + */ + fun price(unitWithProration: Price.UnitWithProration) = + price(Price.ofUnitWithProration(unitWithProration)) + + /** + * Alias for calling [price] with `Price.ofGroupedAllocation(groupedAllocation)`. + */ + fun price(groupedAllocation: Price.GroupedAllocation) = + price(Price.ofGroupedAllocation(groupedAllocation)) + + /** + * Alias for calling [price] with `Price.ofBulkWithProration(bulkWithProration)`. + */ + fun price(bulkWithProration: Price.BulkWithProration) = + price(Price.ofBulkWithProration(bulkWithProration)) + + /** + * Alias for calling [price] with + * `Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)`. + */ + fun price(groupedWithProratedMinimum: Price.GroupedWithProratedMinimum) = + price(Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)) + + /** + * Alias for calling [price] with + * `Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)`. + */ + fun price(groupedWithMeteredMinimum: Price.GroupedWithMeteredMinimum) = + price(Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)) + + /** + * Alias for calling [price] with + * `Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)`. + */ + fun price(groupedWithMinMaxThresholds: Price.GroupedWithMinMaxThresholds) = + price(Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)) + + /** + * Alias for calling [price] with + * `Price.ofMatrixWithDisplayName(matrixWithDisplayName)`. + */ + fun price(matrixWithDisplayName: Price.MatrixWithDisplayName) = + price(Price.ofMatrixWithDisplayName(matrixWithDisplayName)) + + /** + * Alias for calling [price] with + * `Price.ofGroupedTieredPackage(groupedTieredPackage)`. + */ + fun price(groupedTieredPackage: Price.GroupedTieredPackage) = + price(Price.ofGroupedTieredPackage(groupedTieredPackage)) + + /** + * Alias for calling [price] with + * `Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)`. + */ + fun price(maxGroupTieredPackage: Price.MaxGroupTieredPackage) = + price(Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)) + + /** + * Alias for calling [price] with + * `Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)`. + */ + fun price(scalableMatrixWithUnitPricing: Price.ScalableMatrixWithUnitPricing) = + price(Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)) + + /** + * Alias for calling [price] with + * `Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)`. + */ + fun price(scalableMatrixWithTieredPricing: Price.ScalableMatrixWithTieredPricing) = + price(Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)) + + /** + * Alias for calling [price] with + * `Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)`. + */ + fun price(cumulativeGroupedBulk: Price.CumulativeGroupedBulk) = + price(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) + + /** Alias for calling [price] with `Price.ofMinimum(minimum)`. */ + fun price(minimum: Price.Minimum) = price(Price.ofMinimum(minimum)) + + /** Either the fixed fee quantity or the usage during the service period. */ + fun quantity(quantity: Double) = quantity(JsonField.of(quantity)) + + /** + * Sets [Builder.quantity] to an arbitrary JSON value. + * + * You should usually call [Builder.quantity] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun quantity(quantity: JsonField) = apply { this.quantity = quantity } + + /** The start date of the range of time applied for this line item's price. */ + fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) + + /** + * Sets [Builder.startDate] to an arbitrary JSON value. + * + * You should usually call [Builder.startDate] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun startDate(startDate: JsonField) = apply { + this.startDate = startDate + } + + /** + * For complex pricing structures, the line item can be broken down further in + * `sub_line_items`. + */ + fun subLineItems(subLineItems: List) = + subLineItems(JsonField.of(subLineItems)) + + /** + * Sets [Builder.subLineItems] to an arbitrary JSON value. + * + * You should usually call [Builder.subLineItems] with a well-typed + * `List` value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun subLineItems(subLineItems: JsonField>) = apply { + this.subLineItems = subLineItems.map { it.toMutableList() } + } + + /** + * Adds a single [SubLineItem] to [subLineItems]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addSubLineItem(subLineItem: SubLineItem) = apply { + subLineItems = + (subLineItems ?: JsonField.of(mutableListOf())).also { + checkKnown("subLineItems", it).add(subLineItem) + } + } + + /** Alias for calling [addSubLineItem] with `SubLineItem.ofMatrix(matrix)`. */ + fun addSubLineItem(matrix: MatrixSubLineItem) = + addSubLineItem(SubLineItem.ofMatrix(matrix)) + + /** Alias for calling [addSubLineItem] with `SubLineItem.ofTier(tier)`. */ + fun addSubLineItem(tier: TierSubLineItem) = addSubLineItem(SubLineItem.ofTier(tier)) + + /** Alias for calling [addSubLineItem] with `SubLineItem.ofNull(null_)`. */ + fun addSubLineItem(null_: OtherSubLineItem) = + addSubLineItem(SubLineItem.ofNull(null_)) + + /** The line amount before any adjustments. */ + fun subtotal(subtotal: String) = subtotal(JsonField.of(subtotal)) + + /** + * Sets [Builder.subtotal] to an arbitrary JSON value. + * + * You should usually call [Builder.subtotal] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun subtotal(subtotal: JsonField) = apply { this.subtotal = subtotal } + + /** + * An array of tax rates and their incurred tax amounts. Empty if no tax integration + * is configured. + */ + fun taxAmounts(taxAmounts: List) = taxAmounts(JsonField.of(taxAmounts)) + + /** + * Sets [Builder.taxAmounts] to an arbitrary JSON value. + * + * You should usually call [Builder.taxAmounts] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun taxAmounts(taxAmounts: JsonField>) = apply { + this.taxAmounts = taxAmounts.map { it.toMutableList() } + } + + /** + * Adds a single [TaxAmount] to [taxAmounts]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTaxAmount(taxAmount: TaxAmount) = apply { + taxAmounts = + (taxAmounts ?: JsonField.of(mutableListOf())).also { + checkKnown("taxAmounts", it).add(taxAmount) + } + } + + /** + * A list of customer ids that were used to calculate the usage for this line item. + */ + fun usageCustomerIds(usageCustomerIds: List?) = + usageCustomerIds(JsonField.ofNullable(usageCustomerIds)) + + /** + * Sets [Builder.usageCustomerIds] to an arbitrary JSON value. + * + * You should usually call [Builder.usageCustomerIds] with a well-typed + * `List` value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun usageCustomerIds(usageCustomerIds: JsonField>) = apply { + this.usageCustomerIds = usageCustomerIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [usageCustomerIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addUsageCustomerId(usageCustomerId: String) = apply { + usageCustomerIds = + (usageCustomerIds ?: JsonField.of(mutableListOf())).also { + checkKnown("usageCustomerIds", it).add(usageCustomerId) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LineItem]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .id() + * .adjustedSubtotal() + * .adjustments() + * .amount() + * .creditsApplied() + * .discount() + * .endDate() + * .filter() + * .grouping() + * .maximum() + * .maximumAmount() + * .minimum() + * .minimumAmount() + * .name() + * .partiallyInvoicedAmount() + * .price() + * .quantity() + * .startDate() + * .subLineItems() + * .subtotal() + * .taxAmounts() + * .usageCustomerIds() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LineItem = + LineItem( + checkRequired("id", id), + checkRequired("adjustedSubtotal", adjustedSubtotal), + checkRequired("adjustments", adjustments).map { it.toImmutable() }, + checkRequired("amount", amount), + checkRequired("creditsApplied", creditsApplied), + checkRequired("discount", discount), + checkRequired("endDate", endDate), + checkRequired("filter", filter), + checkRequired("grouping", grouping), + checkRequired("maximum", maximum), + checkRequired("maximumAmount", maximumAmount), + checkRequired("minimum", minimum), + checkRequired("minimumAmount", minimumAmount), + checkRequired("name", name), + checkRequired("partiallyInvoicedAmount", partiallyInvoicedAmount), + checkRequired("price", price), + checkRequired("quantity", quantity), + checkRequired("startDate", startDate), + checkRequired("subLineItems", subLineItems).map { it.toImmutable() }, + checkRequired("subtotal", subtotal), + checkRequired("taxAmounts", taxAmounts).map { it.toImmutable() }, + checkRequired("usageCustomerIds", usageCustomerIds).map { + it.toImmutable() + }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LineItem = apply { + if (validated) { + return@apply + } + + id() + adjustedSubtotal() + adjustments().forEach { it.validate() } + amount() + creditsApplied() + discount()?.validate() + endDate() + filter() + grouping() + maximum()?.validate() + maximumAmount() + minimum()?.validate() + minimumAmount() + name() + partiallyInvoicedAmount() + price().validate() + quantity() + startDate() + subLineItems().forEach { it.validate() } + subtotal() + taxAmounts().forEach { it.validate() } + usageCustomerIds() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (id.asKnown() == null) 0 else 1) + + (if (adjustedSubtotal.asKnown() == null) 0 else 1) + + (adjustments.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + (if (amount.asKnown() == null) 0 else 1) + + (if (creditsApplied.asKnown() == null) 0 else 1) + + (discount.asKnown()?.validity() ?: 0) + + (if (endDate.asKnown() == null) 0 else 1) + + (if (filter.asKnown() == null) 0 else 1) + + (if (grouping.asKnown() == null) 0 else 1) + + (maximum.asKnown()?.validity() ?: 0) + + (if (maximumAmount.asKnown() == null) 0 else 1) + + (minimum.asKnown()?.validity() ?: 0) + + (if (minimumAmount.asKnown() == null) 0 else 1) + + (if (name.asKnown() == null) 0 else 1) + + (if (partiallyInvoicedAmount.asKnown() == null) 0 else 1) + + (price.asKnown()?.validity() ?: 0) + + (if (quantity.asKnown() == null) 0 else 1) + + (if (startDate.asKnown() == null) 0 else 1) + + (subLineItems.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + (if (subtotal.asKnown() == null) 0 else 1) + + (taxAmounts.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + (usageCustomerIds.asKnown()?.size ?: 0) + + @JsonDeserialize(using = Adjustment.Deserializer::class) + @JsonSerialize(using = Adjustment.Serializer::class) + class Adjustment + private constructor( + private val usageDiscount: MonetaryUsageDiscountAdjustment? = null, + private val amountDiscount: MonetaryAmountDiscountAdjustment? = null, + private val percentageDiscount: MonetaryPercentageDiscountAdjustment? = null, + private val minimum: MonetaryMinimumAdjustment? = null, + private val maximum: MonetaryMaximumAdjustment? = null, + private val _json: JsonValue? = null, + ) { + + fun usageDiscount(): MonetaryUsageDiscountAdjustment? = usageDiscount + + fun amountDiscount(): MonetaryAmountDiscountAdjustment? = amountDiscount + + fun percentageDiscount(): MonetaryPercentageDiscountAdjustment? = percentageDiscount + + fun minimum(): MonetaryMinimumAdjustment? = minimum + + fun maximum(): MonetaryMaximumAdjustment? = maximum + + fun isUsageDiscount(): Boolean = usageDiscount != null + + fun isAmountDiscount(): Boolean = amountDiscount != null + + fun isPercentageDiscount(): Boolean = percentageDiscount != null + + fun isMinimum(): Boolean = minimum != null + + fun isMaximum(): Boolean = maximum != null + + fun asUsageDiscount(): MonetaryUsageDiscountAdjustment = + usageDiscount.getOrThrow("usageDiscount") + + fun asAmountDiscount(): MonetaryAmountDiscountAdjustment = + amountDiscount.getOrThrow("amountDiscount") + + fun asPercentageDiscount(): MonetaryPercentageDiscountAdjustment = + percentageDiscount.getOrThrow("percentageDiscount") + + fun asMinimum(): MonetaryMinimumAdjustment = minimum.getOrThrow("minimum") + + fun asMaximum(): MonetaryMaximumAdjustment = maximum.getOrThrow("maximum") + + fun _json(): JsonValue? = _json + + fun accept(visitor: Visitor): T = + when { + usageDiscount != null -> visitor.visitUsageDiscount(usageDiscount) + amountDiscount != null -> visitor.visitAmountDiscount(amountDiscount) + percentageDiscount != null -> + visitor.visitPercentageDiscount(percentageDiscount) + minimum != null -> visitor.visitMinimum(minimum) + maximum != null -> visitor.visitMaximum(maximum) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Adjustment = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitUsageDiscount( + usageDiscount: MonetaryUsageDiscountAdjustment + ) { + usageDiscount.validate() + } + + override fun visitAmountDiscount( + amountDiscount: MonetaryAmountDiscountAdjustment + ) { + amountDiscount.validate() + } + + override fun visitPercentageDiscount( + percentageDiscount: MonetaryPercentageDiscountAdjustment + ) { + percentageDiscount.validate() + } + + override fun visitMinimum(minimum: MonetaryMinimumAdjustment) { + minimum.validate() + } + + override fun visitMaximum(maximum: MonetaryMaximumAdjustment) { + maximum.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitUsageDiscount( + usageDiscount: MonetaryUsageDiscountAdjustment + ) = usageDiscount.validity() + + override fun visitAmountDiscount( + amountDiscount: MonetaryAmountDiscountAdjustment + ) = amountDiscount.validity() + + override fun visitPercentageDiscount( + percentageDiscount: MonetaryPercentageDiscountAdjustment + ) = percentageDiscount.validity() + + override fun visitMinimum(minimum: MonetaryMinimumAdjustment) = + minimum.validity() + + override fun visitMaximum(maximum: MonetaryMaximumAdjustment) = + maximum.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Adjustment && + usageDiscount == other.usageDiscount && + amountDiscount == other.amountDiscount && + percentageDiscount == other.percentageDiscount && + minimum == other.minimum && + maximum == other.maximum + } + + override fun hashCode(): Int = + Objects.hash( + usageDiscount, + amountDiscount, + percentageDiscount, + minimum, + maximum, + ) + + override fun toString(): String = + when { + usageDiscount != null -> "Adjustment{usageDiscount=$usageDiscount}" + amountDiscount != null -> "Adjustment{amountDiscount=$amountDiscount}" + percentageDiscount != null -> + "Adjustment{percentageDiscount=$percentageDiscount}" + minimum != null -> "Adjustment{minimum=$minimum}" + maximum != null -> "Adjustment{maximum=$maximum}" + _json != null -> "Adjustment{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Adjustment") + } + + companion object { + + fun ofUsageDiscount(usageDiscount: MonetaryUsageDiscountAdjustment) = + Adjustment(usageDiscount = usageDiscount) + + fun ofAmountDiscount(amountDiscount: MonetaryAmountDiscountAdjustment) = + Adjustment(amountDiscount = amountDiscount) + + fun ofPercentageDiscount( + percentageDiscount: MonetaryPercentageDiscountAdjustment + ) = Adjustment(percentageDiscount = percentageDiscount) + + fun ofMinimum(minimum: MonetaryMinimumAdjustment) = + Adjustment(minimum = minimum) + + fun ofMaximum(maximum: MonetaryMaximumAdjustment) = + Adjustment(maximum = maximum) + } + + /** + * An interface that defines how to map each variant of [Adjustment] to a value of + * type [T]. + */ + interface Visitor { + + fun visitUsageDiscount(usageDiscount: MonetaryUsageDiscountAdjustment): T + + fun visitAmountDiscount(amountDiscount: MonetaryAmountDiscountAdjustment): T + + fun visitPercentageDiscount( + percentageDiscount: MonetaryPercentageDiscountAdjustment + ): T + + fun visitMinimum(minimum: MonetaryMinimumAdjustment): T + + fun visitMaximum(maximum: MonetaryMaximumAdjustment): T + + /** + * Maps an unknown variant of [Adjustment] to a value of type [T]. + * + * An instance of [Adjustment] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For example, if + * the SDK is on an older version than the API, then the API may respond with + * new variants that the SDK is unaware of. + * + * @throws OrbInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw OrbInvalidDataException("Unknown Adjustment: $json") + } + } + + internal class Deserializer : BaseDeserializer(Adjustment::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Adjustment { + val json = JsonValue.fromJsonNode(node) + val adjustmentType = json.asObject()?.get("adjustment_type")?.asString() + + when (adjustmentType) { + "usage_discount" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Adjustment(usageDiscount = it, _json = json) } + ?: Adjustment(_json = json) + } + "amount_discount" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Adjustment(amountDiscount = it, _json = json) } + ?: Adjustment(_json = json) + } + "percentage_discount" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Adjustment(percentageDiscount = it, _json = json) } + ?: Adjustment(_json = json) + } + "minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Adjustment(minimum = it, _json = json) } + ?: Adjustment(_json = json) + } + "maximum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Adjustment(maximum = it, _json = json) } + ?: Adjustment(_json = json) + } + } + + return Adjustment(_json = json) + } + } + + internal class Serializer : BaseSerializer(Adjustment::class) { + + override fun serialize( + value: Adjustment, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.usageDiscount != null -> + generator.writeObject(value.usageDiscount) + value.amountDiscount != null -> + generator.writeObject(value.amountDiscount) + value.percentageDiscount != null -> + generator.writeObject(value.percentageDiscount) + value.minimum != null -> generator.writeObject(value.minimum) + value.maximum != null -> generator.writeObject(value.maximum) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Adjustment") + } + } + } + } + + @JsonDeserialize(using = SubLineItem.Deserializer::class) + @JsonSerialize(using = SubLineItem.Serializer::class) + class SubLineItem + private constructor( + private val matrix: MatrixSubLineItem? = null, + private val tier: TierSubLineItem? = null, + private val null_: OtherSubLineItem? = null, + private val _json: JsonValue? = null, + ) { + + fun matrix(): MatrixSubLineItem? = matrix + + fun tier(): TierSubLineItem? = tier + + fun null_(): OtherSubLineItem? = null_ + + fun isMatrix(): Boolean = matrix != null + + fun isTier(): Boolean = tier != null + + fun isNull(): Boolean = null_ != null + + fun asMatrix(): MatrixSubLineItem = matrix.getOrThrow("matrix") + + fun asTier(): TierSubLineItem = tier.getOrThrow("tier") + + fun asNull(): OtherSubLineItem = null_.getOrThrow("null_") + + fun _json(): JsonValue? = _json + + fun accept(visitor: Visitor): T = + when { + matrix != null -> visitor.visitMatrix(matrix) + tier != null -> visitor.visitTier(tier) + null_ != null -> visitor.visitNull(null_) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): SubLineItem = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitMatrix(matrix: MatrixSubLineItem) { + matrix.validate() + } + + override fun visitTier(tier: TierSubLineItem) { + tier.validate() + } + + override fun visitNull(null_: OtherSubLineItem) { + null_.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitMatrix(matrix: MatrixSubLineItem) = matrix.validity() + + override fun visitTier(tier: TierSubLineItem) = tier.validity() + + override fun visitNull(null_: OtherSubLineItem) = null_.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SubLineItem && + matrix == other.matrix && + tier == other.tier && + null_ == other.null_ + } + + override fun hashCode(): Int = Objects.hash(matrix, tier, null_) + + override fun toString(): String = + when { + matrix != null -> "SubLineItem{matrix=$matrix}" + tier != null -> "SubLineItem{tier=$tier}" + null_ != null -> "SubLineItem{null_=$null_}" + _json != null -> "SubLineItem{_unknown=$_json}" + else -> throw IllegalStateException("Invalid SubLineItem") + } + + companion object { + + fun ofMatrix(matrix: MatrixSubLineItem) = SubLineItem(matrix = matrix) + + fun ofTier(tier: TierSubLineItem) = SubLineItem(tier = tier) + + fun ofNull(null_: OtherSubLineItem) = SubLineItem(null_ = null_) + } + + /** + * An interface that defines how to map each variant of [SubLineItem] to a value of + * type [T]. + */ + interface Visitor { + + fun visitMatrix(matrix: MatrixSubLineItem): T + + fun visitTier(tier: TierSubLineItem): T + + fun visitNull(null_: OtherSubLineItem): T + + /** + * Maps an unknown variant of [SubLineItem] to a value of type [T]. + * + * An instance of [SubLineItem] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For example, if + * the SDK is on an older version than the API, then the API may respond with + * new variants that the SDK is unaware of. + * + * @throws OrbInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw OrbInvalidDataException("Unknown SubLineItem: $json") + } + } + + internal class Deserializer : BaseDeserializer(SubLineItem::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): SubLineItem { + val json = JsonValue.fromJsonNode(node) + val type = json.asObject()?.get("type")?.asString() + + when (type) { + "matrix" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { SubLineItem(matrix = it, _json = json) } + ?: SubLineItem(_json = json) + } + "tier" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { SubLineItem(tier = it, _json = json) } + ?: SubLineItem(_json = json) + } + "'null'" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { SubLineItem(null_ = it, _json = json) } + ?: SubLineItem(_json = json) + } + } + + return SubLineItem(_json = json) + } + } + + internal class Serializer : BaseSerializer(SubLineItem::class) { + + override fun serialize( + value: SubLineItem, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.matrix != null -> generator.writeObject(value.matrix) + value.tier != null -> generator.writeObject(value.tier) + value.null_ != null -> generator.writeObject(value.null_) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid SubLineItem") + } + } + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LineItem && + id == other.id && + adjustedSubtotal == other.adjustedSubtotal && + adjustments == other.adjustments && + amount == other.amount && + creditsApplied == other.creditsApplied && + discount == other.discount && + endDate == other.endDate && + filter == other.filter && + grouping == other.grouping && + maximum == other.maximum && + maximumAmount == other.maximumAmount && + minimum == other.minimum && + minimumAmount == other.minimumAmount && + name == other.name && + partiallyInvoicedAmount == other.partiallyInvoicedAmount && + price == other.price && + quantity == other.quantity && + startDate == other.startDate && + subLineItems == other.subLineItems && + subtotal == other.subtotal && + taxAmounts == other.taxAmounts && + usageCustomerIds == other.usageCustomerIds && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + adjustedSubtotal, + adjustments, + amount, + creditsApplied, + discount, + endDate, + filter, + grouping, + maximum, + maximumAmount, + minimum, + minimumAmount, + name, + partiallyInvoicedAmount, + price, + quantity, + startDate, + subLineItems, + subtotal, + taxAmounts, + usageCustomerIds, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LineItem{id=$id, adjustedSubtotal=$adjustedSubtotal, adjustments=$adjustments, amount=$amount, creditsApplied=$creditsApplied, discount=$discount, endDate=$endDate, filter=$filter, grouping=$grouping, maximum=$maximum, maximumAmount=$maximumAmount, minimum=$minimum, minimumAmount=$minimumAmount, name=$name, partiallyInvoicedAmount=$partiallyInvoicedAmount, price=$price, quantity=$quantity, startDate=$startDate, subLineItems=$subLineItems, subtotal=$subtotal, taxAmounts=$taxAmounts, usageCustomerIds=$usageCustomerIds, additionalProperties=$additionalProperties}" + } + + /** + * User specified key-value pairs for the resource. If not present, this defaults to an + * empty dictionary. Individual keys can be removed by setting the value to `null`, and the + * entire metadata mapping can be cleared by setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + class PaymentAttempt + private constructor( + private val id: JsonField, + private val amount: JsonField, + private val createdAt: JsonField, + private val paymentProvider: JsonField, + private val paymentProviderId: JsonField, + private val receiptPdf: JsonField, + private val succeeded: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + createdAt: JsonField = JsonMissing.of(), + @JsonProperty("payment_provider") + @ExcludeMissing + paymentProvider: JsonField = JsonMissing.of(), + @JsonProperty("payment_provider_id") + @ExcludeMissing + paymentProviderId: JsonField = JsonMissing.of(), + @JsonProperty("receipt_pdf") + @ExcludeMissing + receiptPdf: JsonField = JsonMissing.of(), + @JsonProperty("succeeded") + @ExcludeMissing + succeeded: JsonField = JsonMissing.of(), + ) : this( + id, + amount, + createdAt, + paymentProvider, + paymentProviderId, + receiptPdf, + succeeded, + mutableMapOf(), + ) + + /** + * The ID of the payment attempt. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun id(): String = id.getRequired("id") + + /** + * The amount of the payment attempt. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun amount(): String = amount.getRequired("amount") + + /** + * The time at which the payment attempt was created. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") + + /** + * The payment provider that attempted to collect the payment. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun paymentProvider(): PaymentProvider? = + paymentProvider.getNullable("payment_provider") + + /** + * The ID of the payment attempt in the payment provider. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun paymentProviderId(): String? = paymentProviderId.getNullable("payment_provider_id") + + /** + * URL to the downloadable PDF version of the receipt. This field will be `null` for + * payment attempts that did not succeed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun receiptPdf(): String? = receiptPdf.getNullable("receipt_pdf") + + /** + * Whether the payment attempt succeeded. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun succeeded(): Boolean = succeeded.getRequired("succeeded") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [createdAt]. + * + * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt + + /** + * Returns the raw JSON value of [paymentProvider]. + * + * Unlike [paymentProvider], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("payment_provider") + @ExcludeMissing + fun _paymentProvider(): JsonField = paymentProvider + + /** + * Returns the raw JSON value of [paymentProviderId]. + * + * Unlike [paymentProviderId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("payment_provider_id") + @ExcludeMissing + fun _paymentProviderId(): JsonField = paymentProviderId + + /** + * Returns the raw JSON value of [receiptPdf]. + * + * Unlike [receiptPdf], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("receipt_pdf") + @ExcludeMissing + fun _receiptPdf(): JsonField = receiptPdf + + /** + * Returns the raw JSON value of [succeeded]. + * + * Unlike [succeeded], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("succeeded") + @ExcludeMissing + fun _succeeded(): JsonField = succeeded + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [PaymentAttempt]. + * + * The following fields are required: + * ```kotlin + * .id() + * .amount() + * .createdAt() + * .paymentProvider() + * .paymentProviderId() + * .receiptPdf() + * .succeeded() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [PaymentAttempt]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var amount: JsonField? = null + private var createdAt: JsonField? = null + private var paymentProvider: JsonField? = null + private var paymentProviderId: JsonField? = null + private var receiptPdf: JsonField? = null + private var succeeded: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(paymentAttempt: PaymentAttempt) = apply { + id = paymentAttempt.id + amount = paymentAttempt.amount + createdAt = paymentAttempt.createdAt + paymentProvider = paymentAttempt.paymentProvider + paymentProviderId = paymentAttempt.paymentProviderId + receiptPdf = paymentAttempt.receiptPdf + succeeded = paymentAttempt.succeeded + additionalProperties = paymentAttempt.additionalProperties.toMutableMap() + } + + /** The ID of the payment attempt. */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + /** The amount of the payment attempt. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The time at which the payment attempt was created. */ + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + + /** + * Sets [Builder.createdAt] to an arbitrary JSON value. + * + * You should usually call [Builder.createdAt] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun createdAt(createdAt: JsonField) = apply { + this.createdAt = createdAt + } + + /** The payment provider that attempted to collect the payment. */ + fun paymentProvider(paymentProvider: PaymentProvider?) = + paymentProvider(JsonField.ofNullable(paymentProvider)) + + /** + * Sets [Builder.paymentProvider] to an arbitrary JSON value. + * + * You should usually call [Builder.paymentProvider] with a well-typed + * [PaymentProvider] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun paymentProvider(paymentProvider: JsonField) = apply { + this.paymentProvider = paymentProvider + } + + /** The ID of the payment attempt in the payment provider. */ + fun paymentProviderId(paymentProviderId: String?) = + paymentProviderId(JsonField.ofNullable(paymentProviderId)) + + /** + * Sets [Builder.paymentProviderId] to an arbitrary JSON value. + * + * You should usually call [Builder.paymentProviderId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun paymentProviderId(paymentProviderId: JsonField) = apply { + this.paymentProviderId = paymentProviderId + } + + /** + * URL to the downloadable PDF version of the receipt. This field will be `null` for + * payment attempts that did not succeed. + */ + fun receiptPdf(receiptPdf: String?) = receiptPdf(JsonField.ofNullable(receiptPdf)) + + /** + * Sets [Builder.receiptPdf] to an arbitrary JSON value. + * + * You should usually call [Builder.receiptPdf] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun receiptPdf(receiptPdf: JsonField) = apply { + this.receiptPdf = receiptPdf + } + + /** Whether the payment attempt succeeded. */ + fun succeeded(succeeded: Boolean) = succeeded(JsonField.of(succeeded)) + + /** + * Sets [Builder.succeeded] to an arbitrary JSON value. + * + * You should usually call [Builder.succeeded] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun succeeded(succeeded: JsonField) = apply { this.succeeded = succeeded } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [PaymentAttempt]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .id() + * .amount() + * .createdAt() + * .paymentProvider() + * .paymentProviderId() + * .receiptPdf() + * .succeeded() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): PaymentAttempt = + PaymentAttempt( + checkRequired("id", id), + checkRequired("amount", amount), + checkRequired("createdAt", createdAt), + checkRequired("paymentProvider", paymentProvider), + checkRequired("paymentProviderId", paymentProviderId), + checkRequired("receiptPdf", receiptPdf), + checkRequired("succeeded", succeeded), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): PaymentAttempt = apply { + if (validated) { + return@apply + } + + id() + amount() + createdAt() + paymentProvider()?.validate() + paymentProviderId() + receiptPdf() + succeeded() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (id.asKnown() == null) 0 else 1) + + (if (amount.asKnown() == null) 0 else 1) + + (if (createdAt.asKnown() == null) 0 else 1) + + (paymentProvider.asKnown()?.validity() ?: 0) + + (if (paymentProviderId.asKnown() == null) 0 else 1) + + (if (receiptPdf.asKnown() == null) 0 else 1) + + (if (succeeded.asKnown() == null) 0 else 1) + + /** The payment provider that attempted to collect the payment. */ + class PaymentProvider + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val STRIPE = of("stripe") + + fun of(value: String) = PaymentProvider(JsonField.of(value)) + } + + /** An enum containing [PaymentProvider]'s known values. */ + enum class Known { + STRIPE + } + + /** + * An enum containing [PaymentProvider]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [PaymentProvider] can contain an unknown value in a couple of + * cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + STRIPE, + /** + * An enum member indicating that [PaymentProvider] was instantiated with an + * unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + STRIPE -> Value.STRIPE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + STRIPE -> Known.STRIPE + else -> throw OrbInvalidDataException("Unknown PaymentProvider: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): PaymentProvider = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PaymentProvider && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PaymentAttempt && + id == other.id && + amount == other.amount && + createdAt == other.createdAt && + paymentProvider == other.paymentProvider && + paymentProviderId == other.paymentProviderId && + receiptPdf == other.receiptPdf && + succeeded == other.succeeded && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + amount, + createdAt, + paymentProvider, + paymentProviderId, + receiptPdf, + succeeded, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "PaymentAttempt{id=$id, amount=$amount, createdAt=$createdAt, paymentProvider=$paymentProvider, paymentProviderId=$paymentProviderId, receiptPdf=$receiptPdf, succeeded=$succeeded, additionalProperties=$additionalProperties}" + } + + class Status @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val ISSUED = of("issued") + + val PAID = of("paid") + + val SYNCED = of("synced") + + val VOID = of("void") + + val DRAFT = of("draft") + + fun of(value: String) = Status(JsonField.of(value)) + } + + /** An enum containing [Status]'s known values. */ + enum class Known { + ISSUED, + PAID, + SYNCED, + VOID, + DRAFT, + } + + /** + * An enum containing [Status]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Status] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ISSUED, + PAID, + SYNCED, + VOID, + DRAFT, + /** + * An enum member indicating that [Status] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ISSUED -> Value.ISSUED + PAID -> Value.PAID + SYNCED -> Value.SYNCED + VOID -> Value.VOID + DRAFT -> Value.DRAFT + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + ISSUED -> Known.ISSUED + PAID -> Known.PAID + SYNCED -> Known.SYNCED + VOID -> Known.VOID + DRAFT -> Known.DRAFT + else -> throw OrbInvalidDataException("Unknown Status: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Status = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Status && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CreatedInvoice && + id == other.id && + amountDue == other.amountDue && + autoCollection == other.autoCollection && + billingAddress == other.billingAddress && + createdAt == other.createdAt && + creditNotes == other.creditNotes && + currency == other.currency && + customer == other.customer && + customerBalanceTransactions == other.customerBalanceTransactions && + customerTaxId == other.customerTaxId && + discount == other.discount && + discounts == other.discounts && + dueDate == other.dueDate && + eligibleToIssueAt == other.eligibleToIssueAt && + hostedInvoiceUrl == other.hostedInvoiceUrl && + invoiceDate == other.invoiceDate && + invoiceNumber == other.invoiceNumber && + invoicePdf == other.invoicePdf && + invoiceSource == other.invoiceSource && + isPayableNow == other.isPayableNow && + issueFailedAt == other.issueFailedAt && + issuedAt == other.issuedAt && + lineItems == other.lineItems && + maximum == other.maximum && + maximumAmount == other.maximumAmount && + memo == other.memo && + metadata == other.metadata && + minimum == other.minimum && + minimumAmount == other.minimumAmount && + paidAt == other.paidAt && + paymentAttempts == other.paymentAttempts && + paymentFailedAt == other.paymentFailedAt && + paymentStartedAt == other.paymentStartedAt && + scheduledIssueAt == other.scheduledIssueAt && + shippingAddress == other.shippingAddress && + status == other.status && + subscription == other.subscription && + subtotal == other.subtotal && + syncFailedAt == other.syncFailedAt && + total == other.total && + voidedAt == other.voidedAt && + willAutoIssue == other.willAutoIssue && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + amountDue, + autoCollection, + billingAddress, + createdAt, + creditNotes, + currency, + customer, + customerBalanceTransactions, + customerTaxId, + discount, + discounts, + dueDate, + eligibleToIssueAt, + hostedInvoiceUrl, + invoiceDate, + invoiceNumber, + invoicePdf, + invoiceSource, + isPayableNow, + issueFailedAt, + issuedAt, + lineItems, + maximum, + maximumAmount, + memo, + metadata, + minimum, + minimumAmount, + paidAt, + paymentAttempts, + paymentFailedAt, + paymentStartedAt, + scheduledIssueAt, + shippingAddress, + status, + subscription, + subtotal, + syncFailedAt, + total, + voidedAt, + willAutoIssue, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CreatedInvoice{id=$id, amountDue=$amountDue, autoCollection=$autoCollection, billingAddress=$billingAddress, createdAt=$createdAt, creditNotes=$creditNotes, currency=$currency, customer=$customer, customerBalanceTransactions=$customerBalanceTransactions, customerTaxId=$customerTaxId, discount=$discount, discounts=$discounts, dueDate=$dueDate, eligibleToIssueAt=$eligibleToIssueAt, hostedInvoiceUrl=$hostedInvoiceUrl, invoiceDate=$invoiceDate, invoiceNumber=$invoiceNumber, invoicePdf=$invoicePdf, invoiceSource=$invoiceSource, isPayableNow=$isPayableNow, issueFailedAt=$issueFailedAt, issuedAt=$issuedAt, lineItems=$lineItems, maximum=$maximum, maximumAmount=$maximumAmount, memo=$memo, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, paidAt=$paidAt, paymentAttempts=$paymentAttempts, paymentFailedAt=$paymentFailedAt, paymentStartedAt=$paymentStartedAt, scheduledIssueAt=$scheduledIssueAt, shippingAddress=$shippingAddress, status=$status, subscription=$subscription, subtotal=$subtotal, syncFailedAt=$syncFailedAt, total=$total, voidedAt=$voidedAt, willAutoIssue=$willAutoIssue, additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Price.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Price.kt index 5aa312e65..6d2c10cda 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Price.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Price.kt @@ -1015,6 +1015,7 @@ private constructor( private val id: JsonField, private val billableMetric: JsonField, private val billingCycleConfiguration: JsonField, + private val billingMode: JsonField, private val cadence: JsonField, private val compositePriceFilters: JsonField>, private val conversionRate: JsonField, @@ -1051,6 +1052,9 @@ private constructor( @JsonProperty("billing_cycle_configuration") @ExcludeMissing billingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("billing_mode") + @ExcludeMissing + billingMode: JsonField = JsonMissing.of(), @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), @JsonProperty("composite_price_filters") @ExcludeMissing @@ -1116,6 +1120,7 @@ private constructor( id, billableMetric, billingCycleConfiguration, + billingMode, cadence, compositePriceFilters, conversionRate, @@ -1162,6 +1167,12 @@ private constructor( fun billingCycleConfiguration(): BillingCycleConfiguration = billingCycleConfiguration.getRequired("billing_cycle_configuration") + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun billingMode(): BillingMode = billingMode.getRequired("billing_mode") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). @@ -1356,6 +1367,15 @@ private constructor( fun _billingCycleConfiguration(): JsonField = billingCycleConfiguration + /** + * Returns the raw JSON value of [billingMode]. + * + * Unlike [billingMode], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("billing_mode") + @ExcludeMissing + fun _billingMode(): JsonField = billingMode + /** * Returns the raw JSON value of [cadence]. * @@ -1594,6 +1614,7 @@ private constructor( * .id() * .billableMetric() * .billingCycleConfiguration() + * .billingMode() * .cadence() * .compositePriceFilters() * .conversionRate() @@ -1627,6 +1648,7 @@ private constructor( private var id: JsonField? = null private var billableMetric: JsonField? = null private var billingCycleConfiguration: JsonField? = null + private var billingMode: JsonField? = null private var cadence: JsonField? = null private var compositePriceFilters: JsonField>? = null private var conversionRate: JsonField? = null @@ -1658,6 +1680,7 @@ private constructor( id = unit.id billableMetric = unit.billableMetric billingCycleConfiguration = unit.billingCycleConfiguration + billingMode = unit.billingMode cadence = unit.cadence compositePriceFilters = unit.compositePriceFilters.map { it.toMutableList() } conversionRate = unit.conversionRate @@ -1724,6 +1747,19 @@ private constructor( billingCycleConfiguration: JsonField ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + fun billingMode(billingMode: BillingMode) = billingMode(JsonField.of(billingMode)) + + /** + * Sets [Builder.billingMode] to an arbitrary JSON value. + * + * You should usually call [Builder.billingMode] with a well-typed [BillingMode] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun billingMode(billingMode: JsonField) = apply { + this.billingMode = billingMode + } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) /** @@ -2237,6 +2273,7 @@ private constructor( * .id() * .billableMetric() * .billingCycleConfiguration() + * .billingMode() * .cadence() * .compositePriceFilters() * .conversionRate() @@ -2268,6 +2305,7 @@ private constructor( checkRequired("id", id), checkRequired("billableMetric", billableMetric), checkRequired("billingCycleConfiguration", billingCycleConfiguration), + checkRequired("billingMode", billingMode), checkRequired("cadence", cadence), checkRequired("compositePriceFilters", compositePriceFilters).map { it.toImmutable() @@ -2308,6 +2346,7 @@ private constructor( id() billableMetric()?.validate() billingCycleConfiguration().validate() + billingMode().validate() cadence().validate() compositePriceFilters()?.forEach { it.validate() } conversionRate() @@ -2357,6 +2396,7 @@ private constructor( (if (id.asKnown() == null) 0 else 1) + (billableMetric.asKnown()?.validity() ?: 0) + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (billingMode.asKnown()?.validity() ?: 0) + (cadence.asKnown()?.validity() ?: 0) + (compositePriceFilters.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + (if (conversionRate.asKnown() == null) 0 else 1) + @@ -2382,6 +2422,135 @@ private constructor( (unitConfig.asKnown()?.validity() ?: 0) + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + class BillingMode @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val IN_ADVANCE = of("in_advance") + + val IN_ARREAR = of("in_arrear") + + fun of(value: String) = BillingMode(JsonField.of(value)) + } + + /** An enum containing [BillingMode]'s known values. */ + enum class Known { + IN_ADVANCE, + IN_ARREAR, + } + + /** + * An enum containing [BillingMode]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [BillingMode] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + IN_ADVANCE, + IN_ARREAR, + /** + * An enum member indicating that [BillingMode] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + IN_ADVANCE -> Value.IN_ADVANCE + IN_ARREAR -> Value.IN_ARREAR + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + IN_ADVANCE -> Known.IN_ADVANCE + IN_ARREAR -> Known.IN_ARREAR + else -> throw OrbInvalidDataException("Unknown BillingMode: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): BillingMode = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BillingMode && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + class Cadence @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -2783,6 +2952,7 @@ private constructor( id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && + billingMode == other.billingMode && cadence == other.cadence && compositePriceFilters == other.compositePriceFilters && conversionRate == other.conversionRate && @@ -2815,6 +2985,7 @@ private constructor( id, billableMetric, billingCycleConfiguration, + billingMode, cadence, compositePriceFilters, conversionRate, @@ -2846,7 +3017,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Unit{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, unitConfig=$unitConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "Unit{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, unitConfig=$unitConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" } class Tiered @@ -2854,6 +3025,7 @@ private constructor( private val id: JsonField, private val billableMetric: JsonField, private val billingCycleConfiguration: JsonField, + private val billingMode: JsonField, private val cadence: JsonField, private val compositePriceFilters: JsonField>, private val conversionRate: JsonField, @@ -2890,6 +3062,9 @@ private constructor( @JsonProperty("billing_cycle_configuration") @ExcludeMissing billingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("billing_mode") + @ExcludeMissing + billingMode: JsonField = JsonMissing.of(), @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), @JsonProperty("composite_price_filters") @ExcludeMissing @@ -2955,6 +3130,7 @@ private constructor( id, billableMetric, billingCycleConfiguration, + billingMode, cadence, compositePriceFilters, conversionRate, @@ -3001,6 +3177,12 @@ private constructor( fun billingCycleConfiguration(): BillingCycleConfiguration = billingCycleConfiguration.getRequired("billing_cycle_configuration") + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun billingMode(): BillingMode = billingMode.getRequired("billing_mode") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). @@ -3195,6 +3377,15 @@ private constructor( fun _billingCycleConfiguration(): JsonField = billingCycleConfiguration + /** + * Returns the raw JSON value of [billingMode]. + * + * Unlike [billingMode], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("billing_mode") + @ExcludeMissing + fun _billingMode(): JsonField = billingMode + /** * Returns the raw JSON value of [cadence]. * @@ -3434,6 +3625,7 @@ private constructor( * .id() * .billableMetric() * .billingCycleConfiguration() + * .billingMode() * .cadence() * .compositePriceFilters() * .conversionRate() @@ -3467,6 +3659,7 @@ private constructor( private var id: JsonField? = null private var billableMetric: JsonField? = null private var billingCycleConfiguration: JsonField? = null + private var billingMode: JsonField? = null private var cadence: JsonField? = null private var compositePriceFilters: JsonField>? = null private var conversionRate: JsonField? = null @@ -3498,6 +3691,7 @@ private constructor( id = tiered.id billableMetric = tiered.billableMetric billingCycleConfiguration = tiered.billingCycleConfiguration + billingMode = tiered.billingMode cadence = tiered.cadence compositePriceFilters = tiered.compositePriceFilters.map { it.toMutableList() } conversionRate = tiered.conversionRate @@ -3564,6 +3758,19 @@ private constructor( billingCycleConfiguration: JsonField ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + fun billingMode(billingMode: BillingMode) = billingMode(JsonField.of(billingMode)) + + /** + * Sets [Builder.billingMode] to an arbitrary JSON value. + * + * You should usually call [Builder.billingMode] with a well-typed [BillingMode] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun billingMode(billingMode: JsonField) = apply { + this.billingMode = billingMode + } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) /** @@ -4077,6 +4284,7 @@ private constructor( * .id() * .billableMetric() * .billingCycleConfiguration() + * .billingMode() * .cadence() * .compositePriceFilters() * .conversionRate() @@ -4108,6 +4316,7 @@ private constructor( checkRequired("id", id), checkRequired("billableMetric", billableMetric), checkRequired("billingCycleConfiguration", billingCycleConfiguration), + checkRequired("billingMode", billingMode), checkRequired("cadence", cadence), checkRequired("compositePriceFilters", compositePriceFilters).map { it.toImmutable() @@ -4148,6 +4357,7 @@ private constructor( id() billableMetric()?.validate() billingCycleConfiguration().validate() + billingMode().validate() cadence().validate() compositePriceFilters()?.forEach { it.validate() } conversionRate() @@ -4197,6 +4407,7 @@ private constructor( (if (id.asKnown() == null) 0 else 1) + (billableMetric.asKnown()?.validity() ?: 0) + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (billingMode.asKnown()?.validity() ?: 0) + (cadence.asKnown()?.validity() ?: 0) + (compositePriceFilters.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + (if (conversionRate.asKnown() == null) 0 else 1) + @@ -4222,6 +4433,135 @@ private constructor( (tieredConfig.asKnown()?.validity() ?: 0) + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + class BillingMode @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val IN_ADVANCE = of("in_advance") + + val IN_ARREAR = of("in_arrear") + + fun of(value: String) = BillingMode(JsonField.of(value)) + } + + /** An enum containing [BillingMode]'s known values. */ + enum class Known { + IN_ADVANCE, + IN_ARREAR, + } + + /** + * An enum containing [BillingMode]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [BillingMode] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + IN_ADVANCE, + IN_ARREAR, + /** + * An enum member indicating that [BillingMode] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + IN_ADVANCE -> Value.IN_ADVANCE + IN_ARREAR -> Value.IN_ARREAR + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + IN_ADVANCE -> Known.IN_ADVANCE + IN_ARREAR -> Known.IN_ARREAR + else -> throw OrbInvalidDataException("Unknown BillingMode: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): BillingMode = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BillingMode && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + class Cadence @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -4623,6 +4963,7 @@ private constructor( id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && + billingMode == other.billingMode && cadence == other.cadence && compositePriceFilters == other.compositePriceFilters && conversionRate == other.conversionRate && @@ -4655,6 +4996,7 @@ private constructor( id, billableMetric, billingCycleConfiguration, + billingMode, cadence, compositePriceFilters, conversionRate, @@ -4686,7 +5028,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Tiered{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, tieredConfig=$tieredConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "Tiered{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, tieredConfig=$tieredConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" } class Bulk @@ -4694,6 +5036,7 @@ private constructor( private val id: JsonField, private val billableMetric: JsonField, private val billingCycleConfiguration: JsonField, + private val billingMode: JsonField, private val bulkConfig: JsonField, private val cadence: JsonField, private val compositePriceFilters: JsonField>, @@ -4730,6 +5073,9 @@ private constructor( @JsonProperty("billing_cycle_configuration") @ExcludeMissing billingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("billing_mode") + @ExcludeMissing + billingMode: JsonField = JsonMissing.of(), @JsonProperty("bulk_config") @ExcludeMissing bulkConfig: JsonField = JsonMissing.of(), @@ -4795,6 +5141,7 @@ private constructor( id, billableMetric, billingCycleConfiguration, + billingMode, bulkConfig, cadence, compositePriceFilters, @@ -4841,6 +5188,12 @@ private constructor( fun billingCycleConfiguration(): BillingCycleConfiguration = billingCycleConfiguration.getRequired("billing_cycle_configuration") + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun billingMode(): BillingMode = billingMode.getRequired("billing_mode") + /** * Configuration for bulk pricing * @@ -5035,6 +5388,15 @@ private constructor( fun _billingCycleConfiguration(): JsonField = billingCycleConfiguration + /** + * Returns the raw JSON value of [billingMode]. + * + * Unlike [billingMode], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("billing_mode") + @ExcludeMissing + fun _billingMode(): JsonField = billingMode + /** * Returns the raw JSON value of [bulkConfig]. * @@ -5273,6 +5635,7 @@ private constructor( * .id() * .billableMetric() * .billingCycleConfiguration() + * .billingMode() * .bulkConfig() * .cadence() * .compositePriceFilters() @@ -5306,6 +5669,7 @@ private constructor( private var id: JsonField? = null private var billableMetric: JsonField? = null private var billingCycleConfiguration: JsonField? = null + private var billingMode: JsonField? = null private var bulkConfig: JsonField? = null private var cadence: JsonField? = null private var compositePriceFilters: JsonField>? = null @@ -5337,6 +5701,7 @@ private constructor( id = bulk.id billableMetric = bulk.billableMetric billingCycleConfiguration = bulk.billingCycleConfiguration + billingMode = bulk.billingMode bulkConfig = bulk.bulkConfig cadence = bulk.cadence compositePriceFilters = bulk.compositePriceFilters.map { it.toMutableList() } @@ -5403,6 +5768,19 @@ private constructor( billingCycleConfiguration: JsonField ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + fun billingMode(billingMode: BillingMode) = billingMode(JsonField.of(billingMode)) + + /** + * Sets [Builder.billingMode] to an arbitrary JSON value. + * + * You should usually call [Builder.billingMode] with a well-typed [BillingMode] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun billingMode(billingMode: JsonField) = apply { + this.billingMode = billingMode + } + /** Configuration for bulk pricing */ fun bulkConfig(bulkConfig: BulkConfig) = bulkConfig(JsonField.of(bulkConfig)) @@ -5916,6 +6294,7 @@ private constructor( * .id() * .billableMetric() * .billingCycleConfiguration() + * .billingMode() * .bulkConfig() * .cadence() * .compositePriceFilters() @@ -5947,6 +6326,7 @@ private constructor( checkRequired("id", id), checkRequired("billableMetric", billableMetric), checkRequired("billingCycleConfiguration", billingCycleConfiguration), + checkRequired("billingMode", billingMode), checkRequired("bulkConfig", bulkConfig), checkRequired("cadence", cadence), checkRequired("compositePriceFilters", compositePriceFilters).map { @@ -5987,6 +6367,7 @@ private constructor( id() billableMetric()?.validate() billingCycleConfiguration().validate() + billingMode().validate() bulkConfig().validate() cadence().validate() compositePriceFilters()?.forEach { it.validate() } @@ -6036,6 +6417,7 @@ private constructor( (if (id.asKnown() == null) 0 else 1) + (billableMetric.asKnown()?.validity() ?: 0) + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (billingMode.asKnown()?.validity() ?: 0) + (bulkConfig.asKnown()?.validity() ?: 0) + (cadence.asKnown()?.validity() ?: 0) + (compositePriceFilters.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + @@ -6061,6 +6443,135 @@ private constructor( (if (replacesPriceId.asKnown() == null) 0 else 1) + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + class BillingMode @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val IN_ADVANCE = of("in_advance") + + val IN_ARREAR = of("in_arrear") + + fun of(value: String) = BillingMode(JsonField.of(value)) + } + + /** An enum containing [BillingMode]'s known values. */ + enum class Known { + IN_ADVANCE, + IN_ARREAR, + } + + /** + * An enum containing [BillingMode]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [BillingMode] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + IN_ADVANCE, + IN_ARREAR, + /** + * An enum member indicating that [BillingMode] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + IN_ADVANCE -> Value.IN_ADVANCE + IN_ARREAR -> Value.IN_ARREAR + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + IN_ADVANCE -> Known.IN_ADVANCE + IN_ARREAR -> Known.IN_ARREAR + else -> throw OrbInvalidDataException("Unknown BillingMode: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): BillingMode = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BillingMode && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + class Cadence @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -6462,6 +6973,7 @@ private constructor( id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && + billingMode == other.billingMode && bulkConfig == other.bulkConfig && cadence == other.cadence && compositePriceFilters == other.compositePriceFilters && @@ -6494,6 +7006,7 @@ private constructor( id, billableMetric, billingCycleConfiguration, + billingMode, bulkConfig, cadence, compositePriceFilters, @@ -6525,7 +7038,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Bulk{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, bulkConfig=$bulkConfig, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "Bulk{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, bulkConfig=$bulkConfig, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" } class Package @@ -6533,6 +7046,7 @@ private constructor( private val id: JsonField, private val billableMetric: JsonField, private val billingCycleConfiguration: JsonField, + private val billingMode: JsonField, private val cadence: JsonField, private val compositePriceFilters: JsonField>, private val conversionRate: JsonField, @@ -6569,6 +7083,9 @@ private constructor( @JsonProperty("billing_cycle_configuration") @ExcludeMissing billingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("billing_mode") + @ExcludeMissing + billingMode: JsonField = JsonMissing.of(), @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), @JsonProperty("composite_price_filters") @ExcludeMissing @@ -6634,6 +7151,7 @@ private constructor( id, billableMetric, billingCycleConfiguration, + billingMode, cadence, compositePriceFilters, conversionRate, @@ -6680,6 +7198,12 @@ private constructor( fun billingCycleConfiguration(): BillingCycleConfiguration = billingCycleConfiguration.getRequired("billing_cycle_configuration") + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun billingMode(): BillingMode = billingMode.getRequired("billing_mode") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). @@ -6874,6 +7398,15 @@ private constructor( fun _billingCycleConfiguration(): JsonField = billingCycleConfiguration + /** + * Returns the raw JSON value of [billingMode]. + * + * Unlike [billingMode], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("billing_mode") + @ExcludeMissing + fun _billingMode(): JsonField = billingMode + /** * Returns the raw JSON value of [cadence]. * @@ -7113,6 +7646,7 @@ private constructor( * .id() * .billableMetric() * .billingCycleConfiguration() + * .billingMode() * .cadence() * .compositePriceFilters() * .conversionRate() @@ -7146,6 +7680,7 @@ private constructor( private var id: JsonField? = null private var billableMetric: JsonField? = null private var billingCycleConfiguration: JsonField? = null + private var billingMode: JsonField? = null private var cadence: JsonField? = null private var compositePriceFilters: JsonField>? = null private var conversionRate: JsonField? = null @@ -7177,6 +7712,7 @@ private constructor( id = package_.id billableMetric = package_.billableMetric billingCycleConfiguration = package_.billingCycleConfiguration + billingMode = package_.billingMode cadence = package_.cadence compositePriceFilters = package_.compositePriceFilters.map { it.toMutableList() } conversionRate = package_.conversionRate @@ -7243,6 +7779,19 @@ private constructor( billingCycleConfiguration: JsonField ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + fun billingMode(billingMode: BillingMode) = billingMode(JsonField.of(billingMode)) + + /** + * Sets [Builder.billingMode] to an arbitrary JSON value. + * + * You should usually call [Builder.billingMode] with a well-typed [BillingMode] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun billingMode(billingMode: JsonField) = apply { + this.billingMode = billingMode + } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) /** @@ -7757,6 +8306,7 @@ private constructor( * .id() * .billableMetric() * .billingCycleConfiguration() + * .billingMode() * .cadence() * .compositePriceFilters() * .conversionRate() @@ -7788,6 +8338,7 @@ private constructor( checkRequired("id", id), checkRequired("billableMetric", billableMetric), checkRequired("billingCycleConfiguration", billingCycleConfiguration), + checkRequired("billingMode", billingMode), checkRequired("cadence", cadence), checkRequired("compositePriceFilters", compositePriceFilters).map { it.toImmutable() @@ -7828,6 +8379,7 @@ private constructor( id() billableMetric()?.validate() billingCycleConfiguration().validate() + billingMode().validate() cadence().validate() compositePriceFilters()?.forEach { it.validate() } conversionRate() @@ -7877,6 +8429,7 @@ private constructor( (if (id.asKnown() == null) 0 else 1) + (billableMetric.asKnown()?.validity() ?: 0) + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (billingMode.asKnown()?.validity() ?: 0) + (cadence.asKnown()?.validity() ?: 0) + (compositePriceFilters.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + (if (conversionRate.asKnown() == null) 0 else 1) + @@ -7902,6 +8455,135 @@ private constructor( (if (replacesPriceId.asKnown() == null) 0 else 1) + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + class BillingMode @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val IN_ADVANCE = of("in_advance") + + val IN_ARREAR = of("in_arrear") + + fun of(value: String) = BillingMode(JsonField.of(value)) + } + + /** An enum containing [BillingMode]'s known values. */ + enum class Known { + IN_ADVANCE, + IN_ARREAR, + } + + /** + * An enum containing [BillingMode]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [BillingMode] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + IN_ADVANCE, + IN_ARREAR, + /** + * An enum member indicating that [BillingMode] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + IN_ADVANCE -> Value.IN_ADVANCE + IN_ARREAR -> Value.IN_ARREAR + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + IN_ADVANCE -> Known.IN_ADVANCE + IN_ARREAR -> Known.IN_ARREAR + else -> throw OrbInvalidDataException("Unknown BillingMode: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): BillingMode = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BillingMode && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + class Cadence @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -8303,6 +8985,7 @@ private constructor( id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && + billingMode == other.billingMode && cadence == other.cadence && compositePriceFilters == other.compositePriceFilters && conversionRate == other.conversionRate && @@ -8335,6 +9018,7 @@ private constructor( id, billableMetric, billingCycleConfiguration, + billingMode, cadence, compositePriceFilters, conversionRate, @@ -8366,7 +9050,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Package{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, packageConfig=$packageConfig, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "Package{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, packageConfig=$packageConfig, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" } class Matrix @@ -8374,6 +9058,7 @@ private constructor( private val id: JsonField, private val billableMetric: JsonField, private val billingCycleConfiguration: JsonField, + private val billingMode: JsonField, private val cadence: JsonField, private val compositePriceFilters: JsonField>, private val conversionRate: JsonField, @@ -8410,6 +9095,9 @@ private constructor( @JsonProperty("billing_cycle_configuration") @ExcludeMissing billingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("billing_mode") + @ExcludeMissing + billingMode: JsonField = JsonMissing.of(), @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), @JsonProperty("composite_price_filters") @ExcludeMissing @@ -8475,6 +9163,7 @@ private constructor( id, billableMetric, billingCycleConfiguration, + billingMode, cadence, compositePriceFilters, conversionRate, @@ -8521,6 +9210,12 @@ private constructor( fun billingCycleConfiguration(): BillingCycleConfiguration = billingCycleConfiguration.getRequired("billing_cycle_configuration") + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun billingMode(): BillingMode = billingMode.getRequired("billing_mode") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). @@ -8715,6 +9410,15 @@ private constructor( fun _billingCycleConfiguration(): JsonField = billingCycleConfiguration + /** + * Returns the raw JSON value of [billingMode]. + * + * Unlike [billingMode], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("billing_mode") + @ExcludeMissing + fun _billingMode(): JsonField = billingMode + /** * Returns the raw JSON value of [cadence]. * @@ -8954,6 +9658,7 @@ private constructor( * .id() * .billableMetric() * .billingCycleConfiguration() + * .billingMode() * .cadence() * .compositePriceFilters() * .conversionRate() @@ -8987,6 +9692,7 @@ private constructor( private var id: JsonField? = null private var billableMetric: JsonField? = null private var billingCycleConfiguration: JsonField? = null + private var billingMode: JsonField? = null private var cadence: JsonField? = null private var compositePriceFilters: JsonField>? = null private var conversionRate: JsonField? = null @@ -9018,6 +9724,7 @@ private constructor( id = matrix.id billableMetric = matrix.billableMetric billingCycleConfiguration = matrix.billingCycleConfiguration + billingMode = matrix.billingMode cadence = matrix.cadence compositePriceFilters = matrix.compositePriceFilters.map { it.toMutableList() } conversionRate = matrix.conversionRate @@ -9084,6 +9791,19 @@ private constructor( billingCycleConfiguration: JsonField ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + fun billingMode(billingMode: BillingMode) = billingMode(JsonField.of(billingMode)) + + /** + * Sets [Builder.billingMode] to an arbitrary JSON value. + * + * You should usually call [Builder.billingMode] with a well-typed [BillingMode] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun billingMode(billingMode: JsonField) = apply { + this.billingMode = billingMode + } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) /** @@ -9597,6 +10317,7 @@ private constructor( * .id() * .billableMetric() * .billingCycleConfiguration() + * .billingMode() * .cadence() * .compositePriceFilters() * .conversionRate() @@ -9628,6 +10349,7 @@ private constructor( checkRequired("id", id), checkRequired("billableMetric", billableMetric), checkRequired("billingCycleConfiguration", billingCycleConfiguration), + checkRequired("billingMode", billingMode), checkRequired("cadence", cadence), checkRequired("compositePriceFilters", compositePriceFilters).map { it.toImmutable() @@ -9668,6 +10390,7 @@ private constructor( id() billableMetric()?.validate() billingCycleConfiguration().validate() + billingMode().validate() cadence().validate() compositePriceFilters()?.forEach { it.validate() } conversionRate() @@ -9717,6 +10440,7 @@ private constructor( (if (id.asKnown() == null) 0 else 1) + (billableMetric.asKnown()?.validity() ?: 0) + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (billingMode.asKnown()?.validity() ?: 0) + (cadence.asKnown()?.validity() ?: 0) + (compositePriceFilters.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + (if (conversionRate.asKnown() == null) 0 else 1) + @@ -9742,6 +10466,135 @@ private constructor( (if (replacesPriceId.asKnown() == null) 0 else 1) + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + class BillingMode @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val IN_ADVANCE = of("in_advance") + + val IN_ARREAR = of("in_arrear") + + fun of(value: String) = BillingMode(JsonField.of(value)) + } + + /** An enum containing [BillingMode]'s known values. */ + enum class Known { + IN_ADVANCE, + IN_ARREAR, + } + + /** + * An enum containing [BillingMode]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [BillingMode] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + IN_ADVANCE, + IN_ARREAR, + /** + * An enum member indicating that [BillingMode] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + IN_ADVANCE -> Value.IN_ADVANCE + IN_ARREAR -> Value.IN_ARREAR + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + IN_ADVANCE -> Known.IN_ADVANCE + IN_ARREAR -> Known.IN_ARREAR + else -> throw OrbInvalidDataException("Unknown BillingMode: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): BillingMode = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BillingMode && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + class Cadence @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -10143,6 +10996,7 @@ private constructor( id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && + billingMode == other.billingMode && cadence == other.cadence && compositePriceFilters == other.compositePriceFilters && conversionRate == other.conversionRate && @@ -10175,6 +11029,7 @@ private constructor( id, billableMetric, billingCycleConfiguration, + billingMode, cadence, compositePriceFilters, conversionRate, @@ -10206,7 +11061,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Matrix{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, matrixConfig=$matrixConfig, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "Matrix{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, matrixConfig=$matrixConfig, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" } class ThresholdTotalAmount @@ -10214,6 +11069,7 @@ private constructor( private val id: JsonField, private val billableMetric: JsonField, private val billingCycleConfiguration: JsonField, + private val billingMode: JsonField, private val cadence: JsonField, private val compositePriceFilters: JsonField>, private val conversionRate: JsonField, @@ -10250,6 +11106,9 @@ private constructor( @JsonProperty("billing_cycle_configuration") @ExcludeMissing billingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("billing_mode") + @ExcludeMissing + billingMode: JsonField = JsonMissing.of(), @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), @JsonProperty("composite_price_filters") @ExcludeMissing @@ -10315,6 +11174,7 @@ private constructor( id, billableMetric, billingCycleConfiguration, + billingMode, cadence, compositePriceFilters, conversionRate, @@ -10361,6 +11221,12 @@ private constructor( fun billingCycleConfiguration(): BillingCycleConfiguration = billingCycleConfiguration.getRequired("billing_cycle_configuration") + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun billingMode(): BillingMode = billingMode.getRequired("billing_mode") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). @@ -10556,6 +11422,15 @@ private constructor( fun _billingCycleConfiguration(): JsonField = billingCycleConfiguration + /** + * Returns the raw JSON value of [billingMode]. + * + * Unlike [billingMode], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("billing_mode") + @ExcludeMissing + fun _billingMode(): JsonField = billingMode + /** * Returns the raw JSON value of [cadence]. * @@ -10796,6 +11671,7 @@ private constructor( * .id() * .billableMetric() * .billingCycleConfiguration() + * .billingMode() * .cadence() * .compositePriceFilters() * .conversionRate() @@ -10829,6 +11705,7 @@ private constructor( private var id: JsonField? = null private var billableMetric: JsonField? = null private var billingCycleConfiguration: JsonField? = null + private var billingMode: JsonField? = null private var cadence: JsonField? = null private var compositePriceFilters: JsonField>? = null private var conversionRate: JsonField? = null @@ -10860,6 +11737,7 @@ private constructor( id = thresholdTotalAmount.id billableMetric = thresholdTotalAmount.billableMetric billingCycleConfiguration = thresholdTotalAmount.billingCycleConfiguration + billingMode = thresholdTotalAmount.billingMode cadence = thresholdTotalAmount.cadence compositePriceFilters = thresholdTotalAmount.compositePriceFilters.map { it.toMutableList() } @@ -10927,6 +11805,19 @@ private constructor( billingCycleConfiguration: JsonField ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + fun billingMode(billingMode: BillingMode) = billingMode(JsonField.of(billingMode)) + + /** + * Sets [Builder.billingMode] to an arbitrary JSON value. + * + * You should usually call [Builder.billingMode] with a well-typed [BillingMode] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun billingMode(billingMode: JsonField) = apply { + this.billingMode = billingMode + } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) /** @@ -11441,6 +12332,7 @@ private constructor( * .id() * .billableMetric() * .billingCycleConfiguration() + * .billingMode() * .cadence() * .compositePriceFilters() * .conversionRate() @@ -11472,6 +12364,7 @@ private constructor( checkRequired("id", id), checkRequired("billableMetric", billableMetric), checkRequired("billingCycleConfiguration", billingCycleConfiguration), + checkRequired("billingMode", billingMode), checkRequired("cadence", cadence), checkRequired("compositePriceFilters", compositePriceFilters).map { it.toImmutable() @@ -11512,6 +12405,7 @@ private constructor( id() billableMetric()?.validate() billingCycleConfiguration().validate() + billingMode().validate() cadence().validate() compositePriceFilters()?.forEach { it.validate() } conversionRate() @@ -11561,6 +12455,7 @@ private constructor( (if (id.asKnown() == null) 0 else 1) + (billableMetric.asKnown()?.validity() ?: 0) + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (billingMode.asKnown()?.validity() ?: 0) + (cadence.asKnown()?.validity() ?: 0) + (compositePriceFilters.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + (if (conversionRate.asKnown() == null) 0 else 1) + @@ -11586,6 +12481,135 @@ private constructor( (thresholdTotalAmountConfig.asKnown()?.validity() ?: 0) + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + class BillingMode @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val IN_ADVANCE = of("in_advance") + + val IN_ARREAR = of("in_arrear") + + fun of(value: String) = BillingMode(JsonField.of(value)) + } + + /** An enum containing [BillingMode]'s known values. */ + enum class Known { + IN_ADVANCE, + IN_ARREAR, + } + + /** + * An enum containing [BillingMode]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [BillingMode] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + IN_ADVANCE, + IN_ARREAR, + /** + * An enum member indicating that [BillingMode] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + IN_ADVANCE -> Value.IN_ADVANCE + IN_ARREAR -> Value.IN_ARREAR + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + IN_ADVANCE -> Known.IN_ADVANCE + IN_ARREAR -> Known.IN_ARREAR + else -> throw OrbInvalidDataException("Unknown BillingMode: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): BillingMode = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BillingMode && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + class Cadence @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -12443,6 +13467,7 @@ private constructor( id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && + billingMode == other.billingMode && cadence == other.cadence && compositePriceFilters == other.compositePriceFilters && conversionRate == other.conversionRate && @@ -12475,6 +13500,7 @@ private constructor( id, billableMetric, billingCycleConfiguration, + billingMode, cadence, compositePriceFilters, conversionRate, @@ -12506,7 +13532,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "ThresholdTotalAmount{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, thresholdTotalAmountConfig=$thresholdTotalAmountConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "ThresholdTotalAmount{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, thresholdTotalAmountConfig=$thresholdTotalAmountConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" } class TieredPackage @@ -12514,6 +13540,7 @@ private constructor( private val id: JsonField, private val billableMetric: JsonField, private val billingCycleConfiguration: JsonField, + private val billingMode: JsonField, private val cadence: JsonField, private val compositePriceFilters: JsonField>, private val conversionRate: JsonField, @@ -12550,6 +13577,9 @@ private constructor( @JsonProperty("billing_cycle_configuration") @ExcludeMissing billingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("billing_mode") + @ExcludeMissing + billingMode: JsonField = JsonMissing.of(), @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), @JsonProperty("composite_price_filters") @ExcludeMissing @@ -12615,6 +13645,7 @@ private constructor( id, billableMetric, billingCycleConfiguration, + billingMode, cadence, compositePriceFilters, conversionRate, @@ -12661,6 +13692,12 @@ private constructor( fun billingCycleConfiguration(): BillingCycleConfiguration = billingCycleConfiguration.getRequired("billing_cycle_configuration") + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun billingMode(): BillingMode = billingMode.getRequired("billing_mode") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). @@ -12856,6 +13893,15 @@ private constructor( fun _billingCycleConfiguration(): JsonField = billingCycleConfiguration + /** + * Returns the raw JSON value of [billingMode]. + * + * Unlike [billingMode], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("billing_mode") + @ExcludeMissing + fun _billingMode(): JsonField = billingMode + /** * Returns the raw JSON value of [cadence]. * @@ -13095,6 +14141,7 @@ private constructor( * .id() * .billableMetric() * .billingCycleConfiguration() + * .billingMode() * .cadence() * .compositePriceFilters() * .conversionRate() @@ -13128,6 +14175,7 @@ private constructor( private var id: JsonField? = null private var billableMetric: JsonField? = null private var billingCycleConfiguration: JsonField? = null + private var billingMode: JsonField? = null private var cadence: JsonField? = null private var compositePriceFilters: JsonField>? = null private var conversionRate: JsonField? = null @@ -13159,6 +14207,7 @@ private constructor( id = tieredPackage.id billableMetric = tieredPackage.billableMetric billingCycleConfiguration = tieredPackage.billingCycleConfiguration + billingMode = tieredPackage.billingMode cadence = tieredPackage.cadence compositePriceFilters = tieredPackage.compositePriceFilters.map { it.toMutableList() } @@ -13226,6 +14275,19 @@ private constructor( billingCycleConfiguration: JsonField ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + fun billingMode(billingMode: BillingMode) = billingMode(JsonField.of(billingMode)) + + /** + * Sets [Builder.billingMode] to an arbitrary JSON value. + * + * You should usually call [Builder.billingMode] with a well-typed [BillingMode] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun billingMode(billingMode: JsonField) = apply { + this.billingMode = billingMode + } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) /** @@ -13740,6 +14802,7 @@ private constructor( * .id() * .billableMetric() * .billingCycleConfiguration() + * .billingMode() * .cadence() * .compositePriceFilters() * .conversionRate() @@ -13771,6 +14834,7 @@ private constructor( checkRequired("id", id), checkRequired("billableMetric", billableMetric), checkRequired("billingCycleConfiguration", billingCycleConfiguration), + checkRequired("billingMode", billingMode), checkRequired("cadence", cadence), checkRequired("compositePriceFilters", compositePriceFilters).map { it.toImmutable() @@ -13811,6 +14875,7 @@ private constructor( id() billableMetric()?.validate() billingCycleConfiguration().validate() + billingMode().validate() cadence().validate() compositePriceFilters()?.forEach { it.validate() } conversionRate() @@ -13860,6 +14925,7 @@ private constructor( (if (id.asKnown() == null) 0 else 1) + (billableMetric.asKnown()?.validity() ?: 0) + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (billingMode.asKnown()?.validity() ?: 0) + (cadence.asKnown()?.validity() ?: 0) + (compositePriceFilters.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + (if (conversionRate.asKnown() == null) 0 else 1) + @@ -13885,6 +14951,135 @@ private constructor( (tieredPackageConfig.asKnown()?.validity() ?: 0) + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + class BillingMode @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val IN_ADVANCE = of("in_advance") + + val IN_ARREAR = of("in_arrear") + + fun of(value: String) = BillingMode(JsonField.of(value)) + } + + /** An enum containing [BillingMode]'s known values. */ + enum class Known { + IN_ADVANCE, + IN_ARREAR, + } + + /** + * An enum containing [BillingMode]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [BillingMode] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + IN_ADVANCE, + IN_ARREAR, + /** + * An enum member indicating that [BillingMode] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + IN_ADVANCE -> Value.IN_ADVANCE + IN_ARREAR -> Value.IN_ARREAR + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + IN_ADVANCE -> Known.IN_ADVANCE + IN_ARREAR -> Known.IN_ARREAR + else -> throw OrbInvalidDataException("Unknown BillingMode: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): BillingMode = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BillingMode && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + class Cadence @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -14736,6 +15931,7 @@ private constructor( id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && + billingMode == other.billingMode && cadence == other.cadence && compositePriceFilters == other.compositePriceFilters && conversionRate == other.conversionRate && @@ -14768,6 +15964,7 @@ private constructor( id, billableMetric, billingCycleConfiguration, + billingMode, cadence, compositePriceFilters, conversionRate, @@ -14799,7 +15996,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "TieredPackage{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, tieredPackageConfig=$tieredPackageConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "TieredPackage{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, tieredPackageConfig=$tieredPackageConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" } class TieredWithMinimum @@ -14807,6 +16004,7 @@ private constructor( private val id: JsonField, private val billableMetric: JsonField, private val billingCycleConfiguration: JsonField, + private val billingMode: JsonField, private val cadence: JsonField, private val compositePriceFilters: JsonField>, private val conversionRate: JsonField, @@ -14843,6 +16041,9 @@ private constructor( @JsonProperty("billing_cycle_configuration") @ExcludeMissing billingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("billing_mode") + @ExcludeMissing + billingMode: JsonField = JsonMissing.of(), @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), @JsonProperty("composite_price_filters") @ExcludeMissing @@ -14908,6 +16109,7 @@ private constructor( id, billableMetric, billingCycleConfiguration, + billingMode, cadence, compositePriceFilters, conversionRate, @@ -14954,6 +16156,12 @@ private constructor( fun billingCycleConfiguration(): BillingCycleConfiguration = billingCycleConfiguration.getRequired("billing_cycle_configuration") + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun billingMode(): BillingMode = billingMode.getRequired("billing_mode") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). @@ -15149,6 +16357,15 @@ private constructor( fun _billingCycleConfiguration(): JsonField = billingCycleConfiguration + /** + * Returns the raw JSON value of [billingMode]. + * + * Unlike [billingMode], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("billing_mode") + @ExcludeMissing + fun _billingMode(): JsonField = billingMode + /** * Returns the raw JSON value of [cadence]. * @@ -15388,6 +16605,7 @@ private constructor( * .id() * .billableMetric() * .billingCycleConfiguration() + * .billingMode() * .cadence() * .compositePriceFilters() * .conversionRate() @@ -15421,6 +16639,7 @@ private constructor( private var id: JsonField? = null private var billableMetric: JsonField? = null private var billingCycleConfiguration: JsonField? = null + private var billingMode: JsonField? = null private var cadence: JsonField? = null private var compositePriceFilters: JsonField>? = null private var conversionRate: JsonField? = null @@ -15452,6 +16671,7 @@ private constructor( id = tieredWithMinimum.id billableMetric = tieredWithMinimum.billableMetric billingCycleConfiguration = tieredWithMinimum.billingCycleConfiguration + billingMode = tieredWithMinimum.billingMode cadence = tieredWithMinimum.cadence compositePriceFilters = tieredWithMinimum.compositePriceFilters.map { it.toMutableList() } @@ -15519,6 +16739,19 @@ private constructor( billingCycleConfiguration: JsonField ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + fun billingMode(billingMode: BillingMode) = billingMode(JsonField.of(billingMode)) + + /** + * Sets [Builder.billingMode] to an arbitrary JSON value. + * + * You should usually call [Builder.billingMode] with a well-typed [BillingMode] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun billingMode(billingMode: JsonField) = apply { + this.billingMode = billingMode + } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) /** @@ -16033,6 +17266,7 @@ private constructor( * .id() * .billableMetric() * .billingCycleConfiguration() + * .billingMode() * .cadence() * .compositePriceFilters() * .conversionRate() @@ -16064,6 +17298,7 @@ private constructor( checkRequired("id", id), checkRequired("billableMetric", billableMetric), checkRequired("billingCycleConfiguration", billingCycleConfiguration), + checkRequired("billingMode", billingMode), checkRequired("cadence", cadence), checkRequired("compositePriceFilters", compositePriceFilters).map { it.toImmutable() @@ -16104,6 +17339,7 @@ private constructor( id() billableMetric()?.validate() billingCycleConfiguration().validate() + billingMode().validate() cadence().validate() compositePriceFilters()?.forEach { it.validate() } conversionRate() @@ -16153,6 +17389,7 @@ private constructor( (if (id.asKnown() == null) 0 else 1) + (billableMetric.asKnown()?.validity() ?: 0) + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (billingMode.asKnown()?.validity() ?: 0) + (cadence.asKnown()?.validity() ?: 0) + (compositePriceFilters.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + (if (conversionRate.asKnown() == null) 0 else 1) + @@ -16178,6 +17415,135 @@ private constructor( (tieredWithMinimumConfig.asKnown()?.validity() ?: 0) + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + class BillingMode @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val IN_ADVANCE = of("in_advance") + + val IN_ARREAR = of("in_arrear") + + fun of(value: String) = BillingMode(JsonField.of(value)) + } + + /** An enum containing [BillingMode]'s known values. */ + enum class Known { + IN_ADVANCE, + IN_ARREAR, + } + + /** + * An enum containing [BillingMode]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [BillingMode] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + IN_ADVANCE, + IN_ARREAR, + /** + * An enum member indicating that [BillingMode] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + IN_ADVANCE -> Value.IN_ADVANCE + IN_ARREAR -> Value.IN_ARREAR + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + IN_ADVANCE -> Known.IN_ADVANCE + IN_ARREAR -> Known.IN_ARREAR + else -> throw OrbInvalidDataException("Unknown BillingMode: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): BillingMode = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BillingMode && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + class Cadence @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -17113,6 +18479,7 @@ private constructor( id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && + billingMode == other.billingMode && cadence == other.cadence && compositePriceFilters == other.compositePriceFilters && conversionRate == other.conversionRate && @@ -17145,6 +18512,7 @@ private constructor( id, billableMetric, billingCycleConfiguration, + billingMode, cadence, compositePriceFilters, conversionRate, @@ -17176,7 +18544,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "TieredWithMinimum{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, tieredWithMinimumConfig=$tieredWithMinimumConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "TieredWithMinimum{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, tieredWithMinimumConfig=$tieredWithMinimumConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" } class GroupedTiered @@ -17184,6 +18552,7 @@ private constructor( private val id: JsonField, private val billableMetric: JsonField, private val billingCycleConfiguration: JsonField, + private val billingMode: JsonField, private val cadence: JsonField, private val compositePriceFilters: JsonField>, private val conversionRate: JsonField, @@ -17220,6 +18589,9 @@ private constructor( @JsonProperty("billing_cycle_configuration") @ExcludeMissing billingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("billing_mode") + @ExcludeMissing + billingMode: JsonField = JsonMissing.of(), @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), @JsonProperty("composite_price_filters") @ExcludeMissing @@ -17285,6 +18657,7 @@ private constructor( id, billableMetric, billingCycleConfiguration, + billingMode, cadence, compositePriceFilters, conversionRate, @@ -17331,6 +18704,12 @@ private constructor( fun billingCycleConfiguration(): BillingCycleConfiguration = billingCycleConfiguration.getRequired("billing_cycle_configuration") + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun billingMode(): BillingMode = billingMode.getRequired("billing_mode") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). @@ -17526,6 +18905,15 @@ private constructor( fun _billingCycleConfiguration(): JsonField = billingCycleConfiguration + /** + * Returns the raw JSON value of [billingMode]. + * + * Unlike [billingMode], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("billing_mode") + @ExcludeMissing + fun _billingMode(): JsonField = billingMode + /** * Returns the raw JSON value of [cadence]. * @@ -17765,6 +19153,7 @@ private constructor( * .id() * .billableMetric() * .billingCycleConfiguration() + * .billingMode() * .cadence() * .compositePriceFilters() * .conversionRate() @@ -17798,6 +19187,7 @@ private constructor( private var id: JsonField? = null private var billableMetric: JsonField? = null private var billingCycleConfiguration: JsonField? = null + private var billingMode: JsonField? = null private var cadence: JsonField? = null private var compositePriceFilters: JsonField>? = null private var conversionRate: JsonField? = null @@ -17829,6 +19219,7 @@ private constructor( id = groupedTiered.id billableMetric = groupedTiered.billableMetric billingCycleConfiguration = groupedTiered.billingCycleConfiguration + billingMode = groupedTiered.billingMode cadence = groupedTiered.cadence compositePriceFilters = groupedTiered.compositePriceFilters.map { it.toMutableList() } @@ -17896,6 +19287,19 @@ private constructor( billingCycleConfiguration: JsonField ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + fun billingMode(billingMode: BillingMode) = billingMode(JsonField.of(billingMode)) + + /** + * Sets [Builder.billingMode] to an arbitrary JSON value. + * + * You should usually call [Builder.billingMode] with a well-typed [BillingMode] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun billingMode(billingMode: JsonField) = apply { + this.billingMode = billingMode + } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) /** @@ -18410,6 +19814,7 @@ private constructor( * .id() * .billableMetric() * .billingCycleConfiguration() + * .billingMode() * .cadence() * .compositePriceFilters() * .conversionRate() @@ -18441,6 +19846,7 @@ private constructor( checkRequired("id", id), checkRequired("billableMetric", billableMetric), checkRequired("billingCycleConfiguration", billingCycleConfiguration), + checkRequired("billingMode", billingMode), checkRequired("cadence", cadence), checkRequired("compositePriceFilters", compositePriceFilters).map { it.toImmutable() @@ -18481,6 +19887,7 @@ private constructor( id() billableMetric()?.validate() billingCycleConfiguration().validate() + billingMode().validate() cadence().validate() compositePriceFilters()?.forEach { it.validate() } conversionRate() @@ -18530,6 +19937,7 @@ private constructor( (if (id.asKnown() == null) 0 else 1) + (billableMetric.asKnown()?.validity() ?: 0) + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (billingMode.asKnown()?.validity() ?: 0) + (cadence.asKnown()?.validity() ?: 0) + (compositePriceFilters.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + (if (conversionRate.asKnown() == null) 0 else 1) + @@ -18555,6 +19963,135 @@ private constructor( (if (replacesPriceId.asKnown() == null) 0 else 1) + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + class BillingMode @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val IN_ADVANCE = of("in_advance") + + val IN_ARREAR = of("in_arrear") + + fun of(value: String) = BillingMode(JsonField.of(value)) + } + + /** An enum containing [BillingMode]'s known values. */ + enum class Known { + IN_ADVANCE, + IN_ARREAR, + } + + /** + * An enum containing [BillingMode]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [BillingMode] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + IN_ADVANCE, + IN_ARREAR, + /** + * An enum member indicating that [BillingMode] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + IN_ADVANCE -> Value.IN_ADVANCE + IN_ARREAR -> Value.IN_ARREAR + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + IN_ADVANCE -> Known.IN_ADVANCE + IN_ARREAR -> Known.IN_ARREAR + else -> throw OrbInvalidDataException("Unknown BillingMode: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): BillingMode = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BillingMode && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + class Cadence @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -19403,6 +20940,7 @@ private constructor( id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && + billingMode == other.billingMode && cadence == other.cadence && compositePriceFilters == other.compositePriceFilters && conversionRate == other.conversionRate && @@ -19435,6 +20973,7 @@ private constructor( id, billableMetric, billingCycleConfiguration, + billingMode, cadence, compositePriceFilters, conversionRate, @@ -19466,7 +21005,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "GroupedTiered{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, groupedTieredConfig=$groupedTieredConfig, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "GroupedTiered{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, groupedTieredConfig=$groupedTieredConfig, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" } class TieredPackageWithMinimum @@ -19474,6 +21013,7 @@ private constructor( private val id: JsonField, private val billableMetric: JsonField, private val billingCycleConfiguration: JsonField, + private val billingMode: JsonField, private val cadence: JsonField, private val compositePriceFilters: JsonField>, private val conversionRate: JsonField, @@ -19510,6 +21050,9 @@ private constructor( @JsonProperty("billing_cycle_configuration") @ExcludeMissing billingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("billing_mode") + @ExcludeMissing + billingMode: JsonField = JsonMissing.of(), @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), @JsonProperty("composite_price_filters") @ExcludeMissing @@ -19576,6 +21119,7 @@ private constructor( id, billableMetric, billingCycleConfiguration, + billingMode, cadence, compositePriceFilters, conversionRate, @@ -19622,6 +21166,12 @@ private constructor( fun billingCycleConfiguration(): BillingCycleConfiguration = billingCycleConfiguration.getRequired("billing_cycle_configuration") + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun billingMode(): BillingMode = billingMode.getRequired("billing_mode") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). @@ -19817,6 +21367,15 @@ private constructor( fun _billingCycleConfiguration(): JsonField = billingCycleConfiguration + /** + * Returns the raw JSON value of [billingMode]. + * + * Unlike [billingMode], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("billing_mode") + @ExcludeMissing + fun _billingMode(): JsonField = billingMode + /** * Returns the raw JSON value of [cadence]. * @@ -20057,6 +21616,7 @@ private constructor( * .id() * .billableMetric() * .billingCycleConfiguration() + * .billingMode() * .cadence() * .compositePriceFilters() * .conversionRate() @@ -20090,6 +21650,7 @@ private constructor( private var id: JsonField? = null private var billableMetric: JsonField? = null private var billingCycleConfiguration: JsonField? = null + private var billingMode: JsonField? = null private var cadence: JsonField? = null private var compositePriceFilters: JsonField>? = null private var conversionRate: JsonField? = null @@ -20122,6 +21683,7 @@ private constructor( id = tieredPackageWithMinimum.id billableMetric = tieredPackageWithMinimum.billableMetric billingCycleConfiguration = tieredPackageWithMinimum.billingCycleConfiguration + billingMode = tieredPackageWithMinimum.billingMode cadence = tieredPackageWithMinimum.cadence compositePriceFilters = tieredPackageWithMinimum.compositePriceFilters.map { it.toMutableList() } @@ -20191,6 +21753,19 @@ private constructor( billingCycleConfiguration: JsonField ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + fun billingMode(billingMode: BillingMode) = billingMode(JsonField.of(billingMode)) + + /** + * Sets [Builder.billingMode] to an arbitrary JSON value. + * + * You should usually call [Builder.billingMode] with a well-typed [BillingMode] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun billingMode(billingMode: JsonField) = apply { + this.billingMode = billingMode + } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) /** @@ -20706,6 +22281,7 @@ private constructor( * .id() * .billableMetric() * .billingCycleConfiguration() + * .billingMode() * .cadence() * .compositePriceFilters() * .conversionRate() @@ -20737,6 +22313,7 @@ private constructor( checkRequired("id", id), checkRequired("billableMetric", billableMetric), checkRequired("billingCycleConfiguration", billingCycleConfiguration), + checkRequired("billingMode", billingMode), checkRequired("cadence", cadence), checkRequired("compositePriceFilters", compositePriceFilters).map { it.toImmutable() @@ -20777,6 +22354,7 @@ private constructor( id() billableMetric()?.validate() billingCycleConfiguration().validate() + billingMode().validate() cadence().validate() compositePriceFilters()?.forEach { it.validate() } conversionRate() @@ -20826,6 +22404,7 @@ private constructor( (if (id.asKnown() == null) 0 else 1) + (billableMetric.asKnown()?.validity() ?: 0) + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (billingMode.asKnown()?.validity() ?: 0) + (cadence.asKnown()?.validity() ?: 0) + (compositePriceFilters.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + (if (conversionRate.asKnown() == null) 0 else 1) + @@ -20853,6 +22432,135 @@ private constructor( (tieredPackageWithMinimumConfig.asKnown()?.validity() ?: 0) + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + class BillingMode @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val IN_ADVANCE = of("in_advance") + + val IN_ARREAR = of("in_arrear") + + fun of(value: String) = BillingMode(JsonField.of(value)) + } + + /** An enum containing [BillingMode]'s known values. */ + enum class Known { + IN_ADVANCE, + IN_ARREAR, + } + + /** + * An enum containing [BillingMode]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [BillingMode] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + IN_ADVANCE, + IN_ARREAR, + /** + * An enum member indicating that [BillingMode] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + IN_ADVANCE -> Value.IN_ADVANCE + IN_ARREAR -> Value.IN_ARREAR + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + IN_ADVANCE -> Known.IN_ADVANCE + IN_ARREAR -> Known.IN_ARREAR + else -> throw OrbInvalidDataException("Unknown BillingMode: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): BillingMode = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BillingMode && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + class Cadence @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -21749,6 +23457,7 @@ private constructor( id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && + billingMode == other.billingMode && cadence == other.cadence && compositePriceFilters == other.compositePriceFilters && conversionRate == other.conversionRate && @@ -21781,6 +23490,7 @@ private constructor( id, billableMetric, billingCycleConfiguration, + billingMode, cadence, compositePriceFilters, conversionRate, @@ -21812,7 +23522,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "TieredPackageWithMinimum{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, tieredPackageWithMinimumConfig=$tieredPackageWithMinimumConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "TieredPackageWithMinimum{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, tieredPackageWithMinimumConfig=$tieredPackageWithMinimumConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" } class PackageWithAllocation @@ -21820,6 +23530,7 @@ private constructor( private val id: JsonField, private val billableMetric: JsonField, private val billingCycleConfiguration: JsonField, + private val billingMode: JsonField, private val cadence: JsonField, private val compositePriceFilters: JsonField>, private val conversionRate: JsonField, @@ -21856,6 +23567,9 @@ private constructor( @JsonProperty("billing_cycle_configuration") @ExcludeMissing billingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("billing_mode") + @ExcludeMissing + billingMode: JsonField = JsonMissing.of(), @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), @JsonProperty("composite_price_filters") @ExcludeMissing @@ -21921,6 +23635,7 @@ private constructor( id, billableMetric, billingCycleConfiguration, + billingMode, cadence, compositePriceFilters, conversionRate, @@ -21967,6 +23682,12 @@ private constructor( fun billingCycleConfiguration(): BillingCycleConfiguration = billingCycleConfiguration.getRequired("billing_cycle_configuration") + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun billingMode(): BillingMode = billingMode.getRequired("billing_mode") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). @@ -22162,6 +23883,15 @@ private constructor( fun _billingCycleConfiguration(): JsonField = billingCycleConfiguration + /** + * Returns the raw JSON value of [billingMode]. + * + * Unlike [billingMode], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("billing_mode") + @ExcludeMissing + fun _billingMode(): JsonField = billingMode + /** * Returns the raw JSON value of [cadence]. * @@ -22402,6 +24132,7 @@ private constructor( * .id() * .billableMetric() * .billingCycleConfiguration() + * .billingMode() * .cadence() * .compositePriceFilters() * .conversionRate() @@ -22435,6 +24166,7 @@ private constructor( private var id: JsonField? = null private var billableMetric: JsonField? = null private var billingCycleConfiguration: JsonField? = null + private var billingMode: JsonField? = null private var cadence: JsonField? = null private var compositePriceFilters: JsonField>? = null private var conversionRate: JsonField? = null @@ -22466,6 +24198,7 @@ private constructor( id = packageWithAllocation.id billableMetric = packageWithAllocation.billableMetric billingCycleConfiguration = packageWithAllocation.billingCycleConfiguration + billingMode = packageWithAllocation.billingMode cadence = packageWithAllocation.cadence compositePriceFilters = packageWithAllocation.compositePriceFilters.map { it.toMutableList() } @@ -22533,6 +24266,19 @@ private constructor( billingCycleConfiguration: JsonField ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + fun billingMode(billingMode: BillingMode) = billingMode(JsonField.of(billingMode)) + + /** + * Sets [Builder.billingMode] to an arbitrary JSON value. + * + * You should usually call [Builder.billingMode] with a well-typed [BillingMode] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun billingMode(billingMode: JsonField) = apply { + this.billingMode = billingMode + } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) /** @@ -23048,6 +24794,7 @@ private constructor( * .id() * .billableMetric() * .billingCycleConfiguration() + * .billingMode() * .cadence() * .compositePriceFilters() * .conversionRate() @@ -23079,6 +24826,7 @@ private constructor( checkRequired("id", id), checkRequired("billableMetric", billableMetric), checkRequired("billingCycleConfiguration", billingCycleConfiguration), + checkRequired("billingMode", billingMode), checkRequired("cadence", cadence), checkRequired("compositePriceFilters", compositePriceFilters).map { it.toImmutable() @@ -23119,6 +24867,7 @@ private constructor( id() billableMetric()?.validate() billingCycleConfiguration().validate() + billingMode().validate() cadence().validate() compositePriceFilters()?.forEach { it.validate() } conversionRate() @@ -23168,6 +24917,7 @@ private constructor( (if (id.asKnown() == null) 0 else 1) + (billableMetric.asKnown()?.validity() ?: 0) + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (billingMode.asKnown()?.validity() ?: 0) + (cadence.asKnown()?.validity() ?: 0) + (compositePriceFilters.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + (if (conversionRate.asKnown() == null) 0 else 1) + @@ -23193,6 +24943,135 @@ private constructor( (if (replacesPriceId.asKnown() == null) 0 else 1) + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + class BillingMode @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val IN_ADVANCE = of("in_advance") + + val IN_ARREAR = of("in_arrear") + + fun of(value: String) = BillingMode(JsonField.of(value)) + } + + /** An enum containing [BillingMode]'s known values. */ + enum class Known { + IN_ADVANCE, + IN_ARREAR, + } + + /** + * An enum containing [BillingMode]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [BillingMode] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + IN_ADVANCE, + IN_ARREAR, + /** + * An enum member indicating that [BillingMode] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + IN_ADVANCE -> Value.IN_ADVANCE + IN_ARREAR -> Value.IN_ARREAR + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + IN_ADVANCE -> Known.IN_ADVANCE + IN_ARREAR -> Known.IN_ARREAR + else -> throw OrbInvalidDataException("Unknown BillingMode: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): BillingMode = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BillingMode && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + class Cadence @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -23860,6 +25739,7 @@ private constructor( id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && + billingMode == other.billingMode && cadence == other.cadence && compositePriceFilters == other.compositePriceFilters && conversionRate == other.conversionRate && @@ -23892,6 +25772,7 @@ private constructor( id, billableMetric, billingCycleConfiguration, + billingMode, cadence, compositePriceFilters, conversionRate, @@ -23923,7 +25804,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "PackageWithAllocation{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, packageWithAllocationConfig=$packageWithAllocationConfig, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "PackageWithAllocation{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, packageWithAllocationConfig=$packageWithAllocationConfig, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" } class UnitWithPercent @@ -23931,6 +25812,7 @@ private constructor( private val id: JsonField, private val billableMetric: JsonField, private val billingCycleConfiguration: JsonField, + private val billingMode: JsonField, private val cadence: JsonField, private val compositePriceFilters: JsonField>, private val conversionRate: JsonField, @@ -23967,6 +25849,9 @@ private constructor( @JsonProperty("billing_cycle_configuration") @ExcludeMissing billingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("billing_mode") + @ExcludeMissing + billingMode: JsonField = JsonMissing.of(), @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), @JsonProperty("composite_price_filters") @ExcludeMissing @@ -24032,6 +25917,7 @@ private constructor( id, billableMetric, billingCycleConfiguration, + billingMode, cadence, compositePriceFilters, conversionRate, @@ -24078,6 +25964,12 @@ private constructor( fun billingCycleConfiguration(): BillingCycleConfiguration = billingCycleConfiguration.getRequired("billing_cycle_configuration") + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun billingMode(): BillingMode = billingMode.getRequired("billing_mode") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). @@ -24273,6 +26165,15 @@ private constructor( fun _billingCycleConfiguration(): JsonField = billingCycleConfiguration + /** + * Returns the raw JSON value of [billingMode]. + * + * Unlike [billingMode], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("billing_mode") + @ExcludeMissing + fun _billingMode(): JsonField = billingMode + /** * Returns the raw JSON value of [cadence]. * @@ -24512,6 +26413,7 @@ private constructor( * .id() * .billableMetric() * .billingCycleConfiguration() + * .billingMode() * .cadence() * .compositePriceFilters() * .conversionRate() @@ -24545,6 +26447,7 @@ private constructor( private var id: JsonField? = null private var billableMetric: JsonField? = null private var billingCycleConfiguration: JsonField? = null + private var billingMode: JsonField? = null private var cadence: JsonField? = null private var compositePriceFilters: JsonField>? = null private var conversionRate: JsonField? = null @@ -24576,6 +26479,7 @@ private constructor( id = unitWithPercent.id billableMetric = unitWithPercent.billableMetric billingCycleConfiguration = unitWithPercent.billingCycleConfiguration + billingMode = unitWithPercent.billingMode cadence = unitWithPercent.cadence compositePriceFilters = unitWithPercent.compositePriceFilters.map { it.toMutableList() } @@ -24643,6 +26547,19 @@ private constructor( billingCycleConfiguration: JsonField ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + fun billingMode(billingMode: BillingMode) = billingMode(JsonField.of(billingMode)) + + /** + * Sets [Builder.billingMode] to an arbitrary JSON value. + * + * You should usually call [Builder.billingMode] with a well-typed [BillingMode] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun billingMode(billingMode: JsonField) = apply { + this.billingMode = billingMode + } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) /** @@ -25158,6 +27075,7 @@ private constructor( * .id() * .billableMetric() * .billingCycleConfiguration() + * .billingMode() * .cadence() * .compositePriceFilters() * .conversionRate() @@ -25189,6 +27107,7 @@ private constructor( checkRequired("id", id), checkRequired("billableMetric", billableMetric), checkRequired("billingCycleConfiguration", billingCycleConfiguration), + checkRequired("billingMode", billingMode), checkRequired("cadence", cadence), checkRequired("compositePriceFilters", compositePriceFilters).map { it.toImmutable() @@ -25229,6 +27148,7 @@ private constructor( id() billableMetric()?.validate() billingCycleConfiguration().validate() + billingMode().validate() cadence().validate() compositePriceFilters()?.forEach { it.validate() } conversionRate() @@ -25278,6 +27198,7 @@ private constructor( (if (id.asKnown() == null) 0 else 1) + (billableMetric.asKnown()?.validity() ?: 0) + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (billingMode.asKnown()?.validity() ?: 0) + (cadence.asKnown()?.validity() ?: 0) + (compositePriceFilters.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + (if (conversionRate.asKnown() == null) 0 else 1) + @@ -25303,6 +27224,135 @@ private constructor( (unitWithPercentConfig.asKnown()?.validity() ?: 0) + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + class BillingMode @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val IN_ADVANCE = of("in_advance") + + val IN_ARREAR = of("in_arrear") + + fun of(value: String) = BillingMode(JsonField.of(value)) + } + + /** An enum containing [BillingMode]'s known values. */ + enum class Known { + IN_ADVANCE, + IN_ARREAR, + } + + /** + * An enum containing [BillingMode]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [BillingMode] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + IN_ADVANCE, + IN_ARREAR, + /** + * An enum member indicating that [BillingMode] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + IN_ADVANCE -> Value.IN_ADVANCE + IN_ARREAR -> Value.IN_ARREAR + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + IN_ADVANCE -> Known.IN_ADVANCE + IN_ARREAR -> Known.IN_ARREAR + else -> throw OrbInvalidDataException("Unknown BillingMode: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): BillingMode = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BillingMode && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + class Cadence @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -25917,6 +27967,7 @@ private constructor( id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && + billingMode == other.billingMode && cadence == other.cadence && compositePriceFilters == other.compositePriceFilters && conversionRate == other.conversionRate && @@ -25949,6 +28000,7 @@ private constructor( id, billableMetric, billingCycleConfiguration, + billingMode, cadence, compositePriceFilters, conversionRate, @@ -25980,7 +28032,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "UnitWithPercent{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, unitWithPercentConfig=$unitWithPercentConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "UnitWithPercent{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, unitWithPercentConfig=$unitWithPercentConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" } class MatrixWithAllocation @@ -25988,6 +28040,7 @@ private constructor( private val id: JsonField, private val billableMetric: JsonField, private val billingCycleConfiguration: JsonField, + private val billingMode: JsonField, private val cadence: JsonField, private val compositePriceFilters: JsonField>, private val conversionRate: JsonField, @@ -26024,6 +28077,9 @@ private constructor( @JsonProperty("billing_cycle_configuration") @ExcludeMissing billingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("billing_mode") + @ExcludeMissing + billingMode: JsonField = JsonMissing.of(), @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), @JsonProperty("composite_price_filters") @ExcludeMissing @@ -26089,6 +28145,7 @@ private constructor( id, billableMetric, billingCycleConfiguration, + billingMode, cadence, compositePriceFilters, conversionRate, @@ -26135,6 +28192,12 @@ private constructor( fun billingCycleConfiguration(): BillingCycleConfiguration = billingCycleConfiguration.getRequired("billing_cycle_configuration") + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun billingMode(): BillingMode = billingMode.getRequired("billing_mode") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). @@ -26330,6 +28393,15 @@ private constructor( fun _billingCycleConfiguration(): JsonField = billingCycleConfiguration + /** + * Returns the raw JSON value of [billingMode]. + * + * Unlike [billingMode], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("billing_mode") + @ExcludeMissing + fun _billingMode(): JsonField = billingMode + /** * Returns the raw JSON value of [cadence]. * @@ -26570,6 +28642,7 @@ private constructor( * .id() * .billableMetric() * .billingCycleConfiguration() + * .billingMode() * .cadence() * .compositePriceFilters() * .conversionRate() @@ -26603,6 +28676,7 @@ private constructor( private var id: JsonField? = null private var billableMetric: JsonField? = null private var billingCycleConfiguration: JsonField? = null + private var billingMode: JsonField? = null private var cadence: JsonField? = null private var compositePriceFilters: JsonField>? = null private var conversionRate: JsonField? = null @@ -26634,6 +28708,7 @@ private constructor( id = matrixWithAllocation.id billableMetric = matrixWithAllocation.billableMetric billingCycleConfiguration = matrixWithAllocation.billingCycleConfiguration + billingMode = matrixWithAllocation.billingMode cadence = matrixWithAllocation.cadence compositePriceFilters = matrixWithAllocation.compositePriceFilters.map { it.toMutableList() } @@ -26701,6 +28776,19 @@ private constructor( billingCycleConfiguration: JsonField ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + fun billingMode(billingMode: BillingMode) = billingMode(JsonField.of(billingMode)) + + /** + * Sets [Builder.billingMode] to an arbitrary JSON value. + * + * You should usually call [Builder.billingMode] with a well-typed [BillingMode] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun billingMode(billingMode: JsonField) = apply { + this.billingMode = billingMode + } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) /** @@ -27215,6 +29303,7 @@ private constructor( * .id() * .billableMetric() * .billingCycleConfiguration() + * .billingMode() * .cadence() * .compositePriceFilters() * .conversionRate() @@ -27246,6 +29335,7 @@ private constructor( checkRequired("id", id), checkRequired("billableMetric", billableMetric), checkRequired("billingCycleConfiguration", billingCycleConfiguration), + checkRequired("billingMode", billingMode), checkRequired("cadence", cadence), checkRequired("compositePriceFilters", compositePriceFilters).map { it.toImmutable() @@ -27286,6 +29376,7 @@ private constructor( id() billableMetric()?.validate() billingCycleConfiguration().validate() + billingMode().validate() cadence().validate() compositePriceFilters()?.forEach { it.validate() } conversionRate() @@ -27335,6 +29426,7 @@ private constructor( (if (id.asKnown() == null) 0 else 1) + (billableMetric.asKnown()?.validity() ?: 0) + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (billingMode.asKnown()?.validity() ?: 0) + (cadence.asKnown()?.validity() ?: 0) + (compositePriceFilters.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + (if (conversionRate.asKnown() == null) 0 else 1) + @@ -27360,6 +29452,135 @@ private constructor( (if (replacesPriceId.asKnown() == null) 0 else 1) + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + class BillingMode @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val IN_ADVANCE = of("in_advance") + + val IN_ARREAR = of("in_arrear") + + fun of(value: String) = BillingMode(JsonField.of(value)) + } + + /** An enum containing [BillingMode]'s known values. */ + enum class Known { + IN_ADVANCE, + IN_ARREAR, + } + + /** + * An enum containing [BillingMode]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [BillingMode] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + IN_ADVANCE, + IN_ARREAR, + /** + * An enum member indicating that [BillingMode] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + IN_ADVANCE -> Value.IN_ADVANCE + IN_ARREAR -> Value.IN_ARREAR + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + IN_ADVANCE -> Known.IN_ADVANCE + IN_ARREAR -> Known.IN_ARREAR + else -> throw OrbInvalidDataException("Unknown BillingMode: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): BillingMode = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BillingMode && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + class Cadence @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -27761,6 +29982,7 @@ private constructor( id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && + billingMode == other.billingMode && cadence == other.cadence && compositePriceFilters == other.compositePriceFilters && conversionRate == other.conversionRate && @@ -27793,6 +30015,7 @@ private constructor( id, billableMetric, billingCycleConfiguration, + billingMode, cadence, compositePriceFilters, conversionRate, @@ -27824,7 +30047,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "MatrixWithAllocation{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, matrixWithAllocationConfig=$matrixWithAllocationConfig, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "MatrixWithAllocation{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, matrixWithAllocationConfig=$matrixWithAllocationConfig, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" } class TieredWithProration @@ -27832,6 +30055,7 @@ private constructor( private val id: JsonField, private val billableMetric: JsonField, private val billingCycleConfiguration: JsonField, + private val billingMode: JsonField, private val cadence: JsonField, private val compositePriceFilters: JsonField>, private val conversionRate: JsonField, @@ -27868,6 +30092,9 @@ private constructor( @JsonProperty("billing_cycle_configuration") @ExcludeMissing billingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("billing_mode") + @ExcludeMissing + billingMode: JsonField = JsonMissing.of(), @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), @JsonProperty("composite_price_filters") @ExcludeMissing @@ -27933,6 +30160,7 @@ private constructor( id, billableMetric, billingCycleConfiguration, + billingMode, cadence, compositePriceFilters, conversionRate, @@ -27979,6 +30207,12 @@ private constructor( fun billingCycleConfiguration(): BillingCycleConfiguration = billingCycleConfiguration.getRequired("billing_cycle_configuration") + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun billingMode(): BillingMode = billingMode.getRequired("billing_mode") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). @@ -28174,6 +30408,15 @@ private constructor( fun _billingCycleConfiguration(): JsonField = billingCycleConfiguration + /** + * Returns the raw JSON value of [billingMode]. + * + * Unlike [billingMode], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("billing_mode") + @ExcludeMissing + fun _billingMode(): JsonField = billingMode + /** * Returns the raw JSON value of [cadence]. * @@ -28414,6 +30657,7 @@ private constructor( * .id() * .billableMetric() * .billingCycleConfiguration() + * .billingMode() * .cadence() * .compositePriceFilters() * .conversionRate() @@ -28447,6 +30691,7 @@ private constructor( private var id: JsonField? = null private var billableMetric: JsonField? = null private var billingCycleConfiguration: JsonField? = null + private var billingMode: JsonField? = null private var cadence: JsonField? = null private var compositePriceFilters: JsonField>? = null private var conversionRate: JsonField? = null @@ -28478,6 +30723,7 @@ private constructor( id = tieredWithProration.id billableMetric = tieredWithProration.billableMetric billingCycleConfiguration = tieredWithProration.billingCycleConfiguration + billingMode = tieredWithProration.billingMode cadence = tieredWithProration.cadence compositePriceFilters = tieredWithProration.compositePriceFilters.map { it.toMutableList() } @@ -28545,6 +30791,19 @@ private constructor( billingCycleConfiguration: JsonField ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + fun billingMode(billingMode: BillingMode) = billingMode(JsonField.of(billingMode)) + + /** + * Sets [Builder.billingMode] to an arbitrary JSON value. + * + * You should usually call [Builder.billingMode] with a well-typed [BillingMode] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun billingMode(billingMode: JsonField) = apply { + this.billingMode = billingMode + } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) /** @@ -29059,6 +31318,7 @@ private constructor( * .id() * .billableMetric() * .billingCycleConfiguration() + * .billingMode() * .cadence() * .compositePriceFilters() * .conversionRate() @@ -29090,6 +31350,7 @@ private constructor( checkRequired("id", id), checkRequired("billableMetric", billableMetric), checkRequired("billingCycleConfiguration", billingCycleConfiguration), + checkRequired("billingMode", billingMode), checkRequired("cadence", cadence), checkRequired("compositePriceFilters", compositePriceFilters).map { it.toImmutable() @@ -29130,6 +31391,7 @@ private constructor( id() billableMetric()?.validate() billingCycleConfiguration().validate() + billingMode().validate() cadence().validate() compositePriceFilters()?.forEach { it.validate() } conversionRate() @@ -29179,6 +31441,7 @@ private constructor( (if (id.asKnown() == null) 0 else 1) + (billableMetric.asKnown()?.validity() ?: 0) + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (billingMode.asKnown()?.validity() ?: 0) + (cadence.asKnown()?.validity() ?: 0) + (compositePriceFilters.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + (if (conversionRate.asKnown() == null) 0 else 1) + @@ -29204,6 +31467,135 @@ private constructor( (tieredWithProrationConfig.asKnown()?.validity() ?: 0) + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + class BillingMode @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val IN_ADVANCE = of("in_advance") + + val IN_ARREAR = of("in_arrear") + + fun of(value: String) = BillingMode(JsonField.of(value)) + } + + /** An enum containing [BillingMode]'s known values. */ + enum class Known { + IN_ADVANCE, + IN_ARREAR, + } + + /** + * An enum containing [BillingMode]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [BillingMode] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + IN_ADVANCE, + IN_ARREAR, + /** + * An enum member indicating that [BillingMode] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + IN_ADVANCE -> Value.IN_ADVANCE + IN_ARREAR -> Value.IN_ARREAR + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + IN_ADVANCE -> Known.IN_ADVANCE + IN_ARREAR -> Known.IN_ARREAR + else -> throw OrbInvalidDataException("Unknown BillingMode: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): BillingMode = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BillingMode && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + class Cadence @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -30007,6 +32399,7 @@ private constructor( id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && + billingMode == other.billingMode && cadence == other.cadence && compositePriceFilters == other.compositePriceFilters && conversionRate == other.conversionRate && @@ -30039,6 +32432,7 @@ private constructor( id, billableMetric, billingCycleConfiguration, + billingMode, cadence, compositePriceFilters, conversionRate, @@ -30070,7 +32464,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "TieredWithProration{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, tieredWithProrationConfig=$tieredWithProrationConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "TieredWithProration{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, tieredWithProrationConfig=$tieredWithProrationConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" } class UnitWithProration @@ -30078,6 +32472,7 @@ private constructor( private val id: JsonField, private val billableMetric: JsonField, private val billingCycleConfiguration: JsonField, + private val billingMode: JsonField, private val cadence: JsonField, private val compositePriceFilters: JsonField>, private val conversionRate: JsonField, @@ -30114,6 +32509,9 @@ private constructor( @JsonProperty("billing_cycle_configuration") @ExcludeMissing billingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("billing_mode") + @ExcludeMissing + billingMode: JsonField = JsonMissing.of(), @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), @JsonProperty("composite_price_filters") @ExcludeMissing @@ -30179,6 +32577,7 @@ private constructor( id, billableMetric, billingCycleConfiguration, + billingMode, cadence, compositePriceFilters, conversionRate, @@ -30225,6 +32624,12 @@ private constructor( fun billingCycleConfiguration(): BillingCycleConfiguration = billingCycleConfiguration.getRequired("billing_cycle_configuration") + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun billingMode(): BillingMode = billingMode.getRequired("billing_mode") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). @@ -30420,6 +32825,15 @@ private constructor( fun _billingCycleConfiguration(): JsonField = billingCycleConfiguration + /** + * Returns the raw JSON value of [billingMode]. + * + * Unlike [billingMode], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("billing_mode") + @ExcludeMissing + fun _billingMode(): JsonField = billingMode + /** * Returns the raw JSON value of [cadence]. * @@ -30659,6 +33073,7 @@ private constructor( * .id() * .billableMetric() * .billingCycleConfiguration() + * .billingMode() * .cadence() * .compositePriceFilters() * .conversionRate() @@ -30692,6 +33107,7 @@ private constructor( private var id: JsonField? = null private var billableMetric: JsonField? = null private var billingCycleConfiguration: JsonField? = null + private var billingMode: JsonField? = null private var cadence: JsonField? = null private var compositePriceFilters: JsonField>? = null private var conversionRate: JsonField? = null @@ -30723,6 +33139,7 @@ private constructor( id = unitWithProration.id billableMetric = unitWithProration.billableMetric billingCycleConfiguration = unitWithProration.billingCycleConfiguration + billingMode = unitWithProration.billingMode cadence = unitWithProration.cadence compositePriceFilters = unitWithProration.compositePriceFilters.map { it.toMutableList() } @@ -30790,6 +33207,19 @@ private constructor( billingCycleConfiguration: JsonField ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + fun billingMode(billingMode: BillingMode) = billingMode(JsonField.of(billingMode)) + + /** + * Sets [Builder.billingMode] to an arbitrary JSON value. + * + * You should usually call [Builder.billingMode] with a well-typed [BillingMode] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun billingMode(billingMode: JsonField) = apply { + this.billingMode = billingMode + } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) /** @@ -31304,6 +33734,7 @@ private constructor( * .id() * .billableMetric() * .billingCycleConfiguration() + * .billingMode() * .cadence() * .compositePriceFilters() * .conversionRate() @@ -31335,6 +33766,7 @@ private constructor( checkRequired("id", id), checkRequired("billableMetric", billableMetric), checkRequired("billingCycleConfiguration", billingCycleConfiguration), + checkRequired("billingMode", billingMode), checkRequired("cadence", cadence), checkRequired("compositePriceFilters", compositePriceFilters).map { it.toImmutable() @@ -31375,6 +33807,7 @@ private constructor( id() billableMetric()?.validate() billingCycleConfiguration().validate() + billingMode().validate() cadence().validate() compositePriceFilters()?.forEach { it.validate() } conversionRate() @@ -31424,6 +33857,7 @@ private constructor( (if (id.asKnown() == null) 0 else 1) + (billableMetric.asKnown()?.validity() ?: 0) + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (billingMode.asKnown()?.validity() ?: 0) + (cadence.asKnown()?.validity() ?: 0) + (compositePriceFilters.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + (if (conversionRate.asKnown() == null) 0 else 1) + @@ -31449,6 +33883,135 @@ private constructor( (unitWithProrationConfig.asKnown()?.validity() ?: 0) + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + class BillingMode @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val IN_ADVANCE = of("in_advance") + + val IN_ARREAR = of("in_arrear") + + fun of(value: String) = BillingMode(JsonField.of(value)) + } + + /** An enum containing [BillingMode]'s known values. */ + enum class Known { + IN_ADVANCE, + IN_ARREAR, + } + + /** + * An enum containing [BillingMode]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [BillingMode] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + IN_ADVANCE, + IN_ARREAR, + /** + * An enum member indicating that [BillingMode] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + IN_ADVANCE -> Value.IN_ADVANCE + IN_ARREAR -> Value.IN_ARREAR + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + IN_ADVANCE -> Known.IN_ADVANCE + IN_ARREAR -> Known.IN_ARREAR + else -> throw OrbInvalidDataException("Unknown BillingMode: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): BillingMode = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BillingMode && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + class Cadence @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -32021,6 +34584,7 @@ private constructor( id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && + billingMode == other.billingMode && cadence == other.cadence && compositePriceFilters == other.compositePriceFilters && conversionRate == other.conversionRate && @@ -32053,6 +34617,7 @@ private constructor( id, billableMetric, billingCycleConfiguration, + billingMode, cadence, compositePriceFilters, conversionRate, @@ -32084,7 +34649,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "UnitWithProration{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, unitWithProrationConfig=$unitWithProrationConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "UnitWithProration{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, unitWithProrationConfig=$unitWithProrationConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" } class GroupedAllocation @@ -32092,6 +34657,7 @@ private constructor( private val id: JsonField, private val billableMetric: JsonField, private val billingCycleConfiguration: JsonField, + private val billingMode: JsonField, private val cadence: JsonField, private val compositePriceFilters: JsonField>, private val conversionRate: JsonField, @@ -32128,6 +34694,9 @@ private constructor( @JsonProperty("billing_cycle_configuration") @ExcludeMissing billingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("billing_mode") + @ExcludeMissing + billingMode: JsonField = JsonMissing.of(), @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), @JsonProperty("composite_price_filters") @ExcludeMissing @@ -32193,6 +34762,7 @@ private constructor( id, billableMetric, billingCycleConfiguration, + billingMode, cadence, compositePriceFilters, conversionRate, @@ -32239,6 +34809,12 @@ private constructor( fun billingCycleConfiguration(): BillingCycleConfiguration = billingCycleConfiguration.getRequired("billing_cycle_configuration") + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun billingMode(): BillingMode = billingMode.getRequired("billing_mode") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). @@ -32434,6 +35010,15 @@ private constructor( fun _billingCycleConfiguration(): JsonField = billingCycleConfiguration + /** + * Returns the raw JSON value of [billingMode]. + * + * Unlike [billingMode], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("billing_mode") + @ExcludeMissing + fun _billingMode(): JsonField = billingMode + /** * Returns the raw JSON value of [cadence]. * @@ -32673,6 +35258,7 @@ private constructor( * .id() * .billableMetric() * .billingCycleConfiguration() + * .billingMode() * .cadence() * .compositePriceFilters() * .conversionRate() @@ -32706,6 +35292,7 @@ private constructor( private var id: JsonField? = null private var billableMetric: JsonField? = null private var billingCycleConfiguration: JsonField? = null + private var billingMode: JsonField? = null private var cadence: JsonField? = null private var compositePriceFilters: JsonField>? = null private var conversionRate: JsonField? = null @@ -32737,6 +35324,7 @@ private constructor( id = groupedAllocation.id billableMetric = groupedAllocation.billableMetric billingCycleConfiguration = groupedAllocation.billingCycleConfiguration + billingMode = groupedAllocation.billingMode cadence = groupedAllocation.cadence compositePriceFilters = groupedAllocation.compositePriceFilters.map { it.toMutableList() } @@ -32804,6 +35392,19 @@ private constructor( billingCycleConfiguration: JsonField ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + fun billingMode(billingMode: BillingMode) = billingMode(JsonField.of(billingMode)) + + /** + * Sets [Builder.billingMode] to an arbitrary JSON value. + * + * You should usually call [Builder.billingMode] with a well-typed [BillingMode] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun billingMode(billingMode: JsonField) = apply { + this.billingMode = billingMode + } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) /** @@ -33318,6 +35919,7 @@ private constructor( * .id() * .billableMetric() * .billingCycleConfiguration() + * .billingMode() * .cadence() * .compositePriceFilters() * .conversionRate() @@ -33349,6 +35951,7 @@ private constructor( checkRequired("id", id), checkRequired("billableMetric", billableMetric), checkRequired("billingCycleConfiguration", billingCycleConfiguration), + checkRequired("billingMode", billingMode), checkRequired("cadence", cadence), checkRequired("compositePriceFilters", compositePriceFilters).map { it.toImmutable() @@ -33389,6 +35992,7 @@ private constructor( id() billableMetric()?.validate() billingCycleConfiguration().validate() + billingMode().validate() cadence().validate() compositePriceFilters()?.forEach { it.validate() } conversionRate() @@ -33438,6 +36042,7 @@ private constructor( (if (id.asKnown() == null) 0 else 1) + (billableMetric.asKnown()?.validity() ?: 0) + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (billingMode.asKnown()?.validity() ?: 0) + (cadence.asKnown()?.validity() ?: 0) + (compositePriceFilters.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + (if (conversionRate.asKnown() == null) 0 else 1) + @@ -33463,6 +36068,135 @@ private constructor( (if (replacesPriceId.asKnown() == null) 0 else 1) + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + class BillingMode @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val IN_ADVANCE = of("in_advance") + + val IN_ARREAR = of("in_arrear") + + fun of(value: String) = BillingMode(JsonField.of(value)) + } + + /** An enum containing [BillingMode]'s known values. */ + enum class Known { + IN_ADVANCE, + IN_ARREAR, + } + + /** + * An enum containing [BillingMode]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [BillingMode] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + IN_ADVANCE, + IN_ARREAR, + /** + * An enum member indicating that [BillingMode] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + IN_ADVANCE -> Value.IN_ADVANCE + IN_ARREAR -> Value.IN_ARREAR + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + IN_ADVANCE -> Known.IN_ADVANCE + IN_ARREAR -> Known.IN_ARREAR + else -> throw OrbInvalidDataException("Unknown BillingMode: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): BillingMode = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BillingMode && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + class Cadence @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -34129,6 +36863,7 @@ private constructor( id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && + billingMode == other.billingMode && cadence == other.cadence && compositePriceFilters == other.compositePriceFilters && conversionRate == other.conversionRate && @@ -34161,6 +36896,7 @@ private constructor( id, billableMetric, billingCycleConfiguration, + billingMode, cadence, compositePriceFilters, conversionRate, @@ -34192,7 +36928,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "GroupedAllocation{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, groupedAllocationConfig=$groupedAllocationConfig, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "GroupedAllocation{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, groupedAllocationConfig=$groupedAllocationConfig, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" } class BulkWithProration @@ -34200,6 +36936,7 @@ private constructor( private val id: JsonField, private val billableMetric: JsonField, private val billingCycleConfiguration: JsonField, + private val billingMode: JsonField, private val bulkWithProrationConfig: JsonField, private val cadence: JsonField, private val compositePriceFilters: JsonField>, @@ -34236,6 +36973,9 @@ private constructor( @JsonProperty("billing_cycle_configuration") @ExcludeMissing billingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("billing_mode") + @ExcludeMissing + billingMode: JsonField = JsonMissing.of(), @JsonProperty("bulk_with_proration_config") @ExcludeMissing bulkWithProrationConfig: JsonField = JsonMissing.of(), @@ -34301,6 +37041,7 @@ private constructor( id, billableMetric, billingCycleConfiguration, + billingMode, bulkWithProrationConfig, cadence, compositePriceFilters, @@ -34347,6 +37088,12 @@ private constructor( fun billingCycleConfiguration(): BillingCycleConfiguration = billingCycleConfiguration.getRequired("billing_cycle_configuration") + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun billingMode(): BillingMode = billingMode.getRequired("billing_mode") + /** * Configuration for bulk_with_proration pricing * @@ -34542,6 +37289,15 @@ private constructor( fun _billingCycleConfiguration(): JsonField = billingCycleConfiguration + /** + * Returns the raw JSON value of [billingMode]. + * + * Unlike [billingMode], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("billing_mode") + @ExcludeMissing + fun _billingMode(): JsonField = billingMode + /** * Returns the raw JSON value of [bulkWithProrationConfig]. * @@ -34781,6 +37537,7 @@ private constructor( * .id() * .billableMetric() * .billingCycleConfiguration() + * .billingMode() * .bulkWithProrationConfig() * .cadence() * .compositePriceFilters() @@ -34814,6 +37571,7 @@ private constructor( private var id: JsonField? = null private var billableMetric: JsonField? = null private var billingCycleConfiguration: JsonField? = null + private var billingMode: JsonField? = null private var bulkWithProrationConfig: JsonField? = null private var cadence: JsonField? = null private var compositePriceFilters: JsonField>? = null @@ -34845,6 +37603,7 @@ private constructor( id = bulkWithProration.id billableMetric = bulkWithProration.billableMetric billingCycleConfiguration = bulkWithProration.billingCycleConfiguration + billingMode = bulkWithProration.billingMode bulkWithProrationConfig = bulkWithProration.bulkWithProrationConfig cadence = bulkWithProration.cadence compositePriceFilters = @@ -34912,6 +37671,19 @@ private constructor( billingCycleConfiguration: JsonField ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + fun billingMode(billingMode: BillingMode) = billingMode(JsonField.of(billingMode)) + + /** + * Sets [Builder.billingMode] to an arbitrary JSON value. + * + * You should usually call [Builder.billingMode] with a well-typed [BillingMode] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun billingMode(billingMode: JsonField) = apply { + this.billingMode = billingMode + } + /** Configuration for bulk_with_proration pricing */ fun bulkWithProrationConfig(bulkWithProrationConfig: BulkWithProrationConfig) = bulkWithProrationConfig(JsonField.of(bulkWithProrationConfig)) @@ -35426,6 +38198,7 @@ private constructor( * .id() * .billableMetric() * .billingCycleConfiguration() + * .billingMode() * .bulkWithProrationConfig() * .cadence() * .compositePriceFilters() @@ -35457,6 +38230,7 @@ private constructor( checkRequired("id", id), checkRequired("billableMetric", billableMetric), checkRequired("billingCycleConfiguration", billingCycleConfiguration), + checkRequired("billingMode", billingMode), checkRequired("bulkWithProrationConfig", bulkWithProrationConfig), checkRequired("cadence", cadence), checkRequired("compositePriceFilters", compositePriceFilters).map { @@ -35497,6 +38271,7 @@ private constructor( id() billableMetric()?.validate() billingCycleConfiguration().validate() + billingMode().validate() bulkWithProrationConfig().validate() cadence().validate() compositePriceFilters()?.forEach { it.validate() } @@ -35546,6 +38321,7 @@ private constructor( (if (id.asKnown() == null) 0 else 1) + (billableMetric.asKnown()?.validity() ?: 0) + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (billingMode.asKnown()?.validity() ?: 0) + (bulkWithProrationConfig.asKnown()?.validity() ?: 0) + (cadence.asKnown()?.validity() ?: 0) + (compositePriceFilters.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + @@ -35571,6 +38347,135 @@ private constructor( (if (replacesPriceId.asKnown() == null) 0 else 1) + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + class BillingMode @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val IN_ADVANCE = of("in_advance") + + val IN_ARREAR = of("in_arrear") + + fun of(value: String) = BillingMode(JsonField.of(value)) + } + + /** An enum containing [BillingMode]'s known values. */ + enum class Known { + IN_ADVANCE, + IN_ARREAR, + } + + /** + * An enum containing [BillingMode]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [BillingMode] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + IN_ADVANCE, + IN_ARREAR, + /** + * An enum member indicating that [BillingMode] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + IN_ADVANCE -> Value.IN_ADVANCE + IN_ARREAR -> Value.IN_ARREAR + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + IN_ADVANCE -> Known.IN_ADVANCE + IN_ARREAR -> Known.IN_ARREAR + else -> throw OrbInvalidDataException("Unknown BillingMode: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): BillingMode = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BillingMode && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + /** Configuration for bulk_with_proration pricing */ class BulkWithProrationConfig private constructor( @@ -36367,6 +39272,7 @@ private constructor( id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && + billingMode == other.billingMode && bulkWithProrationConfig == other.bulkWithProrationConfig && cadence == other.cadence && compositePriceFilters == other.compositePriceFilters && @@ -36399,6 +39305,7 @@ private constructor( id, billableMetric, billingCycleConfiguration, + billingMode, bulkWithProrationConfig, cadence, compositePriceFilters, @@ -36430,7 +39337,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "BulkWithProration{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, bulkWithProrationConfig=$bulkWithProrationConfig, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "BulkWithProration{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, bulkWithProrationConfig=$bulkWithProrationConfig, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" } class GroupedWithProratedMinimum @@ -36438,6 +39345,7 @@ private constructor( private val id: JsonField, private val billableMetric: JsonField, private val billingCycleConfiguration: JsonField, + private val billingMode: JsonField, private val cadence: JsonField, private val compositePriceFilters: JsonField>, private val conversionRate: JsonField, @@ -36474,6 +39382,9 @@ private constructor( @JsonProperty("billing_cycle_configuration") @ExcludeMissing billingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("billing_mode") + @ExcludeMissing + billingMode: JsonField = JsonMissing.of(), @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), @JsonProperty("composite_price_filters") @ExcludeMissing @@ -36540,6 +39451,7 @@ private constructor( id, billableMetric, billingCycleConfiguration, + billingMode, cadence, compositePriceFilters, conversionRate, @@ -36586,6 +39498,12 @@ private constructor( fun billingCycleConfiguration(): BillingCycleConfiguration = billingCycleConfiguration.getRequired("billing_cycle_configuration") + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun billingMode(): BillingMode = billingMode.getRequired("billing_mode") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). @@ -36781,6 +39699,15 @@ private constructor( fun _billingCycleConfiguration(): JsonField = billingCycleConfiguration + /** + * Returns the raw JSON value of [billingMode]. + * + * Unlike [billingMode], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("billing_mode") + @ExcludeMissing + fun _billingMode(): JsonField = billingMode + /** * Returns the raw JSON value of [cadence]. * @@ -37022,6 +39949,7 @@ private constructor( * .id() * .billableMetric() * .billingCycleConfiguration() + * .billingMode() * .cadence() * .compositePriceFilters() * .conversionRate() @@ -37055,6 +39983,7 @@ private constructor( private var id: JsonField? = null private var billableMetric: JsonField? = null private var billingCycleConfiguration: JsonField? = null + private var billingMode: JsonField? = null private var cadence: JsonField? = null private var compositePriceFilters: JsonField>? = null private var conversionRate: JsonField? = null @@ -37088,6 +40017,7 @@ private constructor( id = groupedWithProratedMinimum.id billableMetric = groupedWithProratedMinimum.billableMetric billingCycleConfiguration = groupedWithProratedMinimum.billingCycleConfiguration + billingMode = groupedWithProratedMinimum.billingMode cadence = groupedWithProratedMinimum.cadence compositePriceFilters = groupedWithProratedMinimum.compositePriceFilters.map { it.toMutableList() } @@ -37158,6 +40088,19 @@ private constructor( billingCycleConfiguration: JsonField ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + fun billingMode(billingMode: BillingMode) = billingMode(JsonField.of(billingMode)) + + /** + * Sets [Builder.billingMode] to an arbitrary JSON value. + * + * You should usually call [Builder.billingMode] with a well-typed [BillingMode] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun billingMode(billingMode: JsonField) = apply { + this.billingMode = billingMode + } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) /** @@ -37673,6 +40616,7 @@ private constructor( * .id() * .billableMetric() * .billingCycleConfiguration() + * .billingMode() * .cadence() * .compositePriceFilters() * .conversionRate() @@ -37704,6 +40648,7 @@ private constructor( checkRequired("id", id), checkRequired("billableMetric", billableMetric), checkRequired("billingCycleConfiguration", billingCycleConfiguration), + checkRequired("billingMode", billingMode), checkRequired("cadence", cadence), checkRequired("compositePriceFilters", compositePriceFilters).map { it.toImmutable() @@ -37747,6 +40692,7 @@ private constructor( id() billableMetric()?.validate() billingCycleConfiguration().validate() + billingMode().validate() cadence().validate() compositePriceFilters()?.forEach { it.validate() } conversionRate() @@ -37796,6 +40742,7 @@ private constructor( (if (id.asKnown() == null) 0 else 1) + (billableMetric.asKnown()?.validity() ?: 0) + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (billingMode.asKnown()?.validity() ?: 0) + (cadence.asKnown()?.validity() ?: 0) + (compositePriceFilters.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + (if (conversionRate.asKnown() == null) 0 else 1) + @@ -37823,6 +40770,135 @@ private constructor( (if (replacesPriceId.asKnown() == null) 0 else 1) + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + class BillingMode @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val IN_ADVANCE = of("in_advance") + + val IN_ARREAR = of("in_arrear") + + fun of(value: String) = BillingMode(JsonField.of(value)) + } + + /** An enum containing [BillingMode]'s known values. */ + enum class Known { + IN_ADVANCE, + IN_ARREAR, + } + + /** + * An enum containing [BillingMode]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [BillingMode] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + IN_ADVANCE, + IN_ARREAR, + /** + * An enum member indicating that [BillingMode] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + IN_ADVANCE -> Value.IN_ADVANCE + IN_ARREAR -> Value.IN_ARREAR + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + IN_ADVANCE -> Known.IN_ADVANCE + IN_ARREAR -> Known.IN_ARREAR + else -> throw OrbInvalidDataException("Unknown BillingMode: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): BillingMode = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BillingMode && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + class Cadence @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -38481,6 +41557,7 @@ private constructor( id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && + billingMode == other.billingMode && cadence == other.cadence && compositePriceFilters == other.compositePriceFilters && conversionRate == other.conversionRate && @@ -38513,6 +41590,7 @@ private constructor( id, billableMetric, billingCycleConfiguration, + billingMode, cadence, compositePriceFilters, conversionRate, @@ -38544,7 +41622,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "GroupedWithProratedMinimum{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, groupedWithProratedMinimumConfig=$groupedWithProratedMinimumConfig, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "GroupedWithProratedMinimum{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, groupedWithProratedMinimumConfig=$groupedWithProratedMinimumConfig, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" } class GroupedWithMeteredMinimum @@ -38552,6 +41630,7 @@ private constructor( private val id: JsonField, private val billableMetric: JsonField, private val billingCycleConfiguration: JsonField, + private val billingMode: JsonField, private val cadence: JsonField, private val compositePriceFilters: JsonField>, private val conversionRate: JsonField, @@ -38588,6 +41667,9 @@ private constructor( @JsonProperty("billing_cycle_configuration") @ExcludeMissing billingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("billing_mode") + @ExcludeMissing + billingMode: JsonField = JsonMissing.of(), @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), @JsonProperty("composite_price_filters") @ExcludeMissing @@ -38654,6 +41736,7 @@ private constructor( id, billableMetric, billingCycleConfiguration, + billingMode, cadence, compositePriceFilters, conversionRate, @@ -38700,6 +41783,12 @@ private constructor( fun billingCycleConfiguration(): BillingCycleConfiguration = billingCycleConfiguration.getRequired("billing_cycle_configuration") + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun billingMode(): BillingMode = billingMode.getRequired("billing_mode") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). @@ -38895,6 +41984,15 @@ private constructor( fun _billingCycleConfiguration(): JsonField = billingCycleConfiguration + /** + * Returns the raw JSON value of [billingMode]. + * + * Unlike [billingMode], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("billing_mode") + @ExcludeMissing + fun _billingMode(): JsonField = billingMode + /** * Returns the raw JSON value of [cadence]. * @@ -39136,6 +42234,7 @@ private constructor( * .id() * .billableMetric() * .billingCycleConfiguration() + * .billingMode() * .cadence() * .compositePriceFilters() * .conversionRate() @@ -39169,6 +42268,7 @@ private constructor( private var id: JsonField? = null private var billableMetric: JsonField? = null private var billingCycleConfiguration: JsonField? = null + private var billingMode: JsonField? = null private var cadence: JsonField? = null private var compositePriceFilters: JsonField>? = null private var conversionRate: JsonField? = null @@ -39202,6 +42302,7 @@ private constructor( id = groupedWithMeteredMinimum.id billableMetric = groupedWithMeteredMinimum.billableMetric billingCycleConfiguration = groupedWithMeteredMinimum.billingCycleConfiguration + billingMode = groupedWithMeteredMinimum.billingMode cadence = groupedWithMeteredMinimum.cadence compositePriceFilters = groupedWithMeteredMinimum.compositePriceFilters.map { it.toMutableList() } @@ -39271,6 +42372,19 @@ private constructor( billingCycleConfiguration: JsonField ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + fun billingMode(billingMode: BillingMode) = billingMode(JsonField.of(billingMode)) + + /** + * Sets [Builder.billingMode] to an arbitrary JSON value. + * + * You should usually call [Builder.billingMode] with a well-typed [BillingMode] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun billingMode(billingMode: JsonField) = apply { + this.billingMode = billingMode + } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) /** @@ -39786,6 +42900,7 @@ private constructor( * .id() * .billableMetric() * .billingCycleConfiguration() + * .billingMode() * .cadence() * .compositePriceFilters() * .conversionRate() @@ -39817,6 +42932,7 @@ private constructor( checkRequired("id", id), checkRequired("billableMetric", billableMetric), checkRequired("billingCycleConfiguration", billingCycleConfiguration), + checkRequired("billingMode", billingMode), checkRequired("cadence", cadence), checkRequired("compositePriceFilters", compositePriceFilters).map { it.toImmutable() @@ -39860,6 +42976,7 @@ private constructor( id() billableMetric()?.validate() billingCycleConfiguration().validate() + billingMode().validate() cadence().validate() compositePriceFilters()?.forEach { it.validate() } conversionRate() @@ -39909,6 +43026,7 @@ private constructor( (if (id.asKnown() == null) 0 else 1) + (billableMetric.asKnown()?.validity() ?: 0) + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (billingMode.asKnown()?.validity() ?: 0) + (cadence.asKnown()?.validity() ?: 0) + (compositePriceFilters.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + (if (conversionRate.asKnown() == null) 0 else 1) + @@ -39936,6 +43054,135 @@ private constructor( (if (replacesPriceId.asKnown() == null) 0 else 1) + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + class BillingMode @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val IN_ADVANCE = of("in_advance") + + val IN_ARREAR = of("in_arrear") + + fun of(value: String) = BillingMode(JsonField.of(value)) + } + + /** An enum containing [BillingMode]'s known values. */ + enum class Known { + IN_ADVANCE, + IN_ARREAR, + } + + /** + * An enum containing [BillingMode]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [BillingMode] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + IN_ADVANCE, + IN_ARREAR, + /** + * An enum member indicating that [BillingMode] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + IN_ADVANCE -> Value.IN_ADVANCE + IN_ARREAR -> Value.IN_ARREAR + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + IN_ADVANCE -> Known.IN_ADVANCE + IN_ARREAR -> Known.IN_ARREAR + else -> throw OrbInvalidDataException("Unknown BillingMode: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): BillingMode = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BillingMode && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + class Cadence @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -41228,6 +44475,7 @@ private constructor( id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && + billingMode == other.billingMode && cadence == other.cadence && compositePriceFilters == other.compositePriceFilters && conversionRate == other.conversionRate && @@ -41260,6 +44508,7 @@ private constructor( id, billableMetric, billingCycleConfiguration, + billingMode, cadence, compositePriceFilters, conversionRate, @@ -41291,7 +44540,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "GroupedWithMeteredMinimum{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, groupedWithMeteredMinimumConfig=$groupedWithMeteredMinimumConfig, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "GroupedWithMeteredMinimum{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, groupedWithMeteredMinimumConfig=$groupedWithMeteredMinimumConfig, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" } class GroupedWithMinMaxThresholds @@ -41299,6 +44548,7 @@ private constructor( private val id: JsonField, private val billableMetric: JsonField, private val billingCycleConfiguration: JsonField, + private val billingMode: JsonField, private val cadence: JsonField, private val compositePriceFilters: JsonField>, private val conversionRate: JsonField, @@ -41335,6 +44585,9 @@ private constructor( @JsonProperty("billing_cycle_configuration") @ExcludeMissing billingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("billing_mode") + @ExcludeMissing + billingMode: JsonField = JsonMissing.of(), @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), @JsonProperty("composite_price_filters") @ExcludeMissing @@ -41401,6 +44654,7 @@ private constructor( id, billableMetric, billingCycleConfiguration, + billingMode, cadence, compositePriceFilters, conversionRate, @@ -41447,6 +44701,12 @@ private constructor( fun billingCycleConfiguration(): BillingCycleConfiguration = billingCycleConfiguration.getRequired("billing_cycle_configuration") + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun billingMode(): BillingMode = billingMode.getRequired("billing_mode") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). @@ -41642,6 +44902,15 @@ private constructor( fun _billingCycleConfiguration(): JsonField = billingCycleConfiguration + /** + * Returns the raw JSON value of [billingMode]. + * + * Unlike [billingMode], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("billing_mode") + @ExcludeMissing + fun _billingMode(): JsonField = billingMode + /** * Returns the raw JSON value of [cadence]. * @@ -41883,6 +45152,7 @@ private constructor( * .id() * .billableMetric() * .billingCycleConfiguration() + * .billingMode() * .cadence() * .compositePriceFilters() * .conversionRate() @@ -41916,6 +45186,7 @@ private constructor( private var id: JsonField? = null private var billableMetric: JsonField? = null private var billingCycleConfiguration: JsonField? = null + private var billingMode: JsonField? = null private var cadence: JsonField? = null private var compositePriceFilters: JsonField>? = null private var conversionRate: JsonField? = null @@ -41949,6 +45220,7 @@ private constructor( id = groupedWithMinMaxThresholds.id billableMetric = groupedWithMinMaxThresholds.billableMetric billingCycleConfiguration = groupedWithMinMaxThresholds.billingCycleConfiguration + billingMode = groupedWithMinMaxThresholds.billingMode cadence = groupedWithMinMaxThresholds.cadence compositePriceFilters = groupedWithMinMaxThresholds.compositePriceFilters.map { it.toMutableList() } @@ -42020,6 +45292,19 @@ private constructor( billingCycleConfiguration: JsonField ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + fun billingMode(billingMode: BillingMode) = billingMode(JsonField.of(billingMode)) + + /** + * Sets [Builder.billingMode] to an arbitrary JSON value. + * + * You should usually call [Builder.billingMode] with a well-typed [BillingMode] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun billingMode(billingMode: JsonField) = apply { + this.billingMode = billingMode + } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) /** @@ -42535,6 +45820,7 @@ private constructor( * .id() * .billableMetric() * .billingCycleConfiguration() + * .billingMode() * .cadence() * .compositePriceFilters() * .conversionRate() @@ -42566,6 +45852,7 @@ private constructor( checkRequired("id", id), checkRequired("billableMetric", billableMetric), checkRequired("billingCycleConfiguration", billingCycleConfiguration), + checkRequired("billingMode", billingMode), checkRequired("cadence", cadence), checkRequired("compositePriceFilters", compositePriceFilters).map { it.toImmutable() @@ -42609,6 +45896,7 @@ private constructor( id() billableMetric()?.validate() billingCycleConfiguration().validate() + billingMode().validate() cadence().validate() compositePriceFilters()?.forEach { it.validate() } conversionRate() @@ -42658,6 +45946,7 @@ private constructor( (if (id.asKnown() == null) 0 else 1) + (billableMetric.asKnown()?.validity() ?: 0) + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (billingMode.asKnown()?.validity() ?: 0) + (cadence.asKnown()?.validity() ?: 0) + (compositePriceFilters.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + (if (conversionRate.asKnown() == null) 0 else 1) + @@ -42685,6 +45974,135 @@ private constructor( (if (replacesPriceId.asKnown() == null) 0 else 1) + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + class BillingMode @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val IN_ADVANCE = of("in_advance") + + val IN_ARREAR = of("in_arrear") + + fun of(value: String) = BillingMode(JsonField.of(value)) + } + + /** An enum containing [BillingMode]'s known values. */ + enum class Known { + IN_ADVANCE, + IN_ARREAR, + } + + /** + * An enum containing [BillingMode]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [BillingMode] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + IN_ADVANCE, + IN_ARREAR, + /** + * An enum member indicating that [BillingMode] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + IN_ADVANCE -> Value.IN_ADVANCE + IN_ARREAR -> Value.IN_ARREAR + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + IN_ADVANCE -> Known.IN_ADVANCE + IN_ARREAR -> Known.IN_ARREAR + else -> throw OrbInvalidDataException("Unknown BillingMode: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): BillingMode = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BillingMode && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + class Cadence @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -43405,6 +46823,7 @@ private constructor( id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && + billingMode == other.billingMode && cadence == other.cadence && compositePriceFilters == other.compositePriceFilters && conversionRate == other.conversionRate && @@ -43437,6 +46856,7 @@ private constructor( id, billableMetric, billingCycleConfiguration, + billingMode, cadence, compositePriceFilters, conversionRate, @@ -43468,7 +46888,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "GroupedWithMinMaxThresholds{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "GroupedWithMinMaxThresholds{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" } class MatrixWithDisplayName @@ -43476,6 +46896,7 @@ private constructor( private val id: JsonField, private val billableMetric: JsonField, private val billingCycleConfiguration: JsonField, + private val billingMode: JsonField, private val cadence: JsonField, private val compositePriceFilters: JsonField>, private val conversionRate: JsonField, @@ -43512,6 +46933,9 @@ private constructor( @JsonProperty("billing_cycle_configuration") @ExcludeMissing billingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("billing_mode") + @ExcludeMissing + billingMode: JsonField = JsonMissing.of(), @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), @JsonProperty("composite_price_filters") @ExcludeMissing @@ -43577,6 +47001,7 @@ private constructor( id, billableMetric, billingCycleConfiguration, + billingMode, cadence, compositePriceFilters, conversionRate, @@ -43623,6 +47048,12 @@ private constructor( fun billingCycleConfiguration(): BillingCycleConfiguration = billingCycleConfiguration.getRequired("billing_cycle_configuration") + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun billingMode(): BillingMode = billingMode.getRequired("billing_mode") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). @@ -43818,6 +47249,15 @@ private constructor( fun _billingCycleConfiguration(): JsonField = billingCycleConfiguration + /** + * Returns the raw JSON value of [billingMode]. + * + * Unlike [billingMode], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("billing_mode") + @ExcludeMissing + fun _billingMode(): JsonField = billingMode + /** * Returns the raw JSON value of [cadence]. * @@ -44058,6 +47498,7 @@ private constructor( * .id() * .billableMetric() * .billingCycleConfiguration() + * .billingMode() * .cadence() * .compositePriceFilters() * .conversionRate() @@ -44091,6 +47532,7 @@ private constructor( private var id: JsonField? = null private var billableMetric: JsonField? = null private var billingCycleConfiguration: JsonField? = null + private var billingMode: JsonField? = null private var cadence: JsonField? = null private var compositePriceFilters: JsonField>? = null private var conversionRate: JsonField? = null @@ -44122,6 +47564,7 @@ private constructor( id = matrixWithDisplayName.id billableMetric = matrixWithDisplayName.billableMetric billingCycleConfiguration = matrixWithDisplayName.billingCycleConfiguration + billingMode = matrixWithDisplayName.billingMode cadence = matrixWithDisplayName.cadence compositePriceFilters = matrixWithDisplayName.compositePriceFilters.map { it.toMutableList() } @@ -44189,6 +47632,19 @@ private constructor( billingCycleConfiguration: JsonField ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + fun billingMode(billingMode: BillingMode) = billingMode(JsonField.of(billingMode)) + + /** + * Sets [Builder.billingMode] to an arbitrary JSON value. + * + * You should usually call [Builder.billingMode] with a well-typed [BillingMode] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun billingMode(billingMode: JsonField) = apply { + this.billingMode = billingMode + } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) /** @@ -44704,6 +48160,7 @@ private constructor( * .id() * .billableMetric() * .billingCycleConfiguration() + * .billingMode() * .cadence() * .compositePriceFilters() * .conversionRate() @@ -44735,6 +48192,7 @@ private constructor( checkRequired("id", id), checkRequired("billableMetric", billableMetric), checkRequired("billingCycleConfiguration", billingCycleConfiguration), + checkRequired("billingMode", billingMode), checkRequired("cadence", cadence), checkRequired("compositePriceFilters", compositePriceFilters).map { it.toImmutable() @@ -44775,6 +48233,7 @@ private constructor( id() billableMetric()?.validate() billingCycleConfiguration().validate() + billingMode().validate() cadence().validate() compositePriceFilters()?.forEach { it.validate() } conversionRate() @@ -44824,6 +48283,7 @@ private constructor( (if (id.asKnown() == null) 0 else 1) + (billableMetric.asKnown()?.validity() ?: 0) + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (billingMode.asKnown()?.validity() ?: 0) + (cadence.asKnown()?.validity() ?: 0) + (compositePriceFilters.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + (if (conversionRate.asKnown() == null) 0 else 1) + @@ -44849,6 +48309,135 @@ private constructor( (if (replacesPriceId.asKnown() == null) 0 else 1) + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + class BillingMode @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val IN_ADVANCE = of("in_advance") + + val IN_ARREAR = of("in_arrear") + + fun of(value: String) = BillingMode(JsonField.of(value)) + } + + /** An enum containing [BillingMode]'s known values. */ + enum class Known { + IN_ADVANCE, + IN_ARREAR, + } + + /** + * An enum containing [BillingMode]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [BillingMode] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + IN_ADVANCE, + IN_ARREAR, + /** + * An enum member indicating that [BillingMode] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + IN_ADVANCE -> Value.IN_ADVANCE + IN_ARREAR -> Value.IN_ARREAR + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + IN_ADVANCE -> Known.IN_ADVANCE + IN_ARREAR -> Known.IN_ARREAR + else -> throw OrbInvalidDataException("Unknown BillingMode: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): BillingMode = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BillingMode && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + class Cadence @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -45745,6 +49334,7 @@ private constructor( id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && + billingMode == other.billingMode && cadence == other.cadence && compositePriceFilters == other.compositePriceFilters && conversionRate == other.conversionRate && @@ -45777,6 +49367,7 @@ private constructor( id, billableMetric, billingCycleConfiguration, + billingMode, cadence, compositePriceFilters, conversionRate, @@ -45808,7 +49399,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "MatrixWithDisplayName{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, matrixWithDisplayNameConfig=$matrixWithDisplayNameConfig, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "MatrixWithDisplayName{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, matrixWithDisplayNameConfig=$matrixWithDisplayNameConfig, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" } class GroupedTieredPackage @@ -45816,6 +49407,7 @@ private constructor( private val id: JsonField, private val billableMetric: JsonField, private val billingCycleConfiguration: JsonField, + private val billingMode: JsonField, private val cadence: JsonField, private val compositePriceFilters: JsonField>, private val conversionRate: JsonField, @@ -45852,6 +49444,9 @@ private constructor( @JsonProperty("billing_cycle_configuration") @ExcludeMissing billingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("billing_mode") + @ExcludeMissing + billingMode: JsonField = JsonMissing.of(), @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), @JsonProperty("composite_price_filters") @ExcludeMissing @@ -45917,6 +49512,7 @@ private constructor( id, billableMetric, billingCycleConfiguration, + billingMode, cadence, compositePriceFilters, conversionRate, @@ -45963,6 +49559,12 @@ private constructor( fun billingCycleConfiguration(): BillingCycleConfiguration = billingCycleConfiguration.getRequired("billing_cycle_configuration") + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun billingMode(): BillingMode = billingMode.getRequired("billing_mode") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). @@ -46158,6 +49760,15 @@ private constructor( fun _billingCycleConfiguration(): JsonField = billingCycleConfiguration + /** + * Returns the raw JSON value of [billingMode]. + * + * Unlike [billingMode], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("billing_mode") + @ExcludeMissing + fun _billingMode(): JsonField = billingMode + /** * Returns the raw JSON value of [cadence]. * @@ -46398,6 +50009,7 @@ private constructor( * .id() * .billableMetric() * .billingCycleConfiguration() + * .billingMode() * .cadence() * .compositePriceFilters() * .conversionRate() @@ -46431,6 +50043,7 @@ private constructor( private var id: JsonField? = null private var billableMetric: JsonField? = null private var billingCycleConfiguration: JsonField? = null + private var billingMode: JsonField? = null private var cadence: JsonField? = null private var compositePriceFilters: JsonField>? = null private var conversionRate: JsonField? = null @@ -46462,6 +50075,7 @@ private constructor( id = groupedTieredPackage.id billableMetric = groupedTieredPackage.billableMetric billingCycleConfiguration = groupedTieredPackage.billingCycleConfiguration + billingMode = groupedTieredPackage.billingMode cadence = groupedTieredPackage.cadence compositePriceFilters = groupedTieredPackage.compositePriceFilters.map { it.toMutableList() } @@ -46529,6 +50143,19 @@ private constructor( billingCycleConfiguration: JsonField ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + fun billingMode(billingMode: BillingMode) = billingMode(JsonField.of(billingMode)) + + /** + * Sets [Builder.billingMode] to an arbitrary JSON value. + * + * You should usually call [Builder.billingMode] with a well-typed [BillingMode] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun billingMode(billingMode: JsonField) = apply { + this.billingMode = billingMode + } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) /** @@ -47043,6 +50670,7 @@ private constructor( * .id() * .billableMetric() * .billingCycleConfiguration() + * .billingMode() * .cadence() * .compositePriceFilters() * .conversionRate() @@ -47074,6 +50702,7 @@ private constructor( checkRequired("id", id), checkRequired("billableMetric", billableMetric), checkRequired("billingCycleConfiguration", billingCycleConfiguration), + checkRequired("billingMode", billingMode), checkRequired("cadence", cadence), checkRequired("compositePriceFilters", compositePriceFilters).map { it.toImmutable() @@ -47114,6 +50743,7 @@ private constructor( id() billableMetric()?.validate() billingCycleConfiguration().validate() + billingMode().validate() cadence().validate() compositePriceFilters()?.forEach { it.validate() } conversionRate() @@ -47163,6 +50793,7 @@ private constructor( (if (id.asKnown() == null) 0 else 1) + (billableMetric.asKnown()?.validity() ?: 0) + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (billingMode.asKnown()?.validity() ?: 0) + (cadence.asKnown()?.validity() ?: 0) + (compositePriceFilters.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + (if (conversionRate.asKnown() == null) 0 else 1) + @@ -47188,6 +50819,135 @@ private constructor( (if (replacesPriceId.asKnown() == null) 0 else 1) + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + class BillingMode @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val IN_ADVANCE = of("in_advance") + + val IN_ARREAR = of("in_arrear") + + fun of(value: String) = BillingMode(JsonField.of(value)) + } + + /** An enum containing [BillingMode]'s known values. */ + enum class Known { + IN_ADVANCE, + IN_ARREAR, + } + + /** + * An enum containing [BillingMode]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [BillingMode] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + IN_ADVANCE, + IN_ARREAR, + /** + * An enum member indicating that [BillingMode] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + IN_ADVANCE -> Value.IN_ADVANCE + IN_ARREAR -> Value.IN_ARREAR + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + IN_ADVANCE -> Known.IN_ADVANCE + IN_ARREAR -> Known.IN_ARREAR + else -> throw OrbInvalidDataException("Unknown BillingMode: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): BillingMode = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BillingMode && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + class Cadence @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -48082,6 +51842,7 @@ private constructor( id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && + billingMode == other.billingMode && cadence == other.cadence && compositePriceFilters == other.compositePriceFilters && conversionRate == other.conversionRate && @@ -48114,6 +51875,7 @@ private constructor( id, billableMetric, billingCycleConfiguration, + billingMode, cadence, compositePriceFilters, conversionRate, @@ -48145,7 +51907,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "GroupedTieredPackage{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, groupedTieredPackageConfig=$groupedTieredPackageConfig, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "GroupedTieredPackage{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, groupedTieredPackageConfig=$groupedTieredPackageConfig, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" } class MaxGroupTieredPackage @@ -48153,6 +51915,7 @@ private constructor( private val id: JsonField, private val billableMetric: JsonField, private val billingCycleConfiguration: JsonField, + private val billingMode: JsonField, private val cadence: JsonField, private val compositePriceFilters: JsonField>, private val conversionRate: JsonField, @@ -48189,6 +51952,9 @@ private constructor( @JsonProperty("billing_cycle_configuration") @ExcludeMissing billingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("billing_mode") + @ExcludeMissing + billingMode: JsonField = JsonMissing.of(), @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), @JsonProperty("composite_price_filters") @ExcludeMissing @@ -48254,6 +52020,7 @@ private constructor( id, billableMetric, billingCycleConfiguration, + billingMode, cadence, compositePriceFilters, conversionRate, @@ -48300,6 +52067,12 @@ private constructor( fun billingCycleConfiguration(): BillingCycleConfiguration = billingCycleConfiguration.getRequired("billing_cycle_configuration") + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun billingMode(): BillingMode = billingMode.getRequired("billing_mode") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). @@ -48495,6 +52268,15 @@ private constructor( fun _billingCycleConfiguration(): JsonField = billingCycleConfiguration + /** + * Returns the raw JSON value of [billingMode]. + * + * Unlike [billingMode], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("billing_mode") + @ExcludeMissing + fun _billingMode(): JsonField = billingMode + /** * Returns the raw JSON value of [cadence]. * @@ -48735,6 +52517,7 @@ private constructor( * .id() * .billableMetric() * .billingCycleConfiguration() + * .billingMode() * .cadence() * .compositePriceFilters() * .conversionRate() @@ -48768,6 +52551,7 @@ private constructor( private var id: JsonField? = null private var billableMetric: JsonField? = null private var billingCycleConfiguration: JsonField? = null + private var billingMode: JsonField? = null private var cadence: JsonField? = null private var compositePriceFilters: JsonField>? = null private var conversionRate: JsonField? = null @@ -48799,6 +52583,7 @@ private constructor( id = maxGroupTieredPackage.id billableMetric = maxGroupTieredPackage.billableMetric billingCycleConfiguration = maxGroupTieredPackage.billingCycleConfiguration + billingMode = maxGroupTieredPackage.billingMode cadence = maxGroupTieredPackage.cadence compositePriceFilters = maxGroupTieredPackage.compositePriceFilters.map { it.toMutableList() } @@ -48866,6 +52651,19 @@ private constructor( billingCycleConfiguration: JsonField ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + fun billingMode(billingMode: BillingMode) = billingMode(JsonField.of(billingMode)) + + /** + * Sets [Builder.billingMode] to an arbitrary JSON value. + * + * You should usually call [Builder.billingMode] with a well-typed [BillingMode] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun billingMode(billingMode: JsonField) = apply { + this.billingMode = billingMode + } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) /** @@ -49381,6 +53179,7 @@ private constructor( * .id() * .billableMetric() * .billingCycleConfiguration() + * .billingMode() * .cadence() * .compositePriceFilters() * .conversionRate() @@ -49412,6 +53211,7 @@ private constructor( checkRequired("id", id), checkRequired("billableMetric", billableMetric), checkRequired("billingCycleConfiguration", billingCycleConfiguration), + checkRequired("billingMode", billingMode), checkRequired("cadence", cadence), checkRequired("compositePriceFilters", compositePriceFilters).map { it.toImmutable() @@ -49452,6 +53252,7 @@ private constructor( id() billableMetric()?.validate() billingCycleConfiguration().validate() + billingMode().validate() cadence().validate() compositePriceFilters()?.forEach { it.validate() } conversionRate() @@ -49501,6 +53302,7 @@ private constructor( (if (id.asKnown() == null) 0 else 1) + (billableMetric.asKnown()?.validity() ?: 0) + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (billingMode.asKnown()?.validity() ?: 0) + (cadence.asKnown()?.validity() ?: 0) + (compositePriceFilters.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + (if (conversionRate.asKnown() == null) 0 else 1) + @@ -49526,6 +53328,135 @@ private constructor( (if (replacesPriceId.asKnown() == null) 0 else 1) + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + class BillingMode @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val IN_ADVANCE = of("in_advance") + + val IN_ARREAR = of("in_arrear") + + fun of(value: String) = BillingMode(JsonField.of(value)) + } + + /** An enum containing [BillingMode]'s known values. */ + enum class Known { + IN_ADVANCE, + IN_ARREAR, + } + + /** + * An enum containing [BillingMode]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [BillingMode] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + IN_ADVANCE, + IN_ARREAR, + /** + * An enum member indicating that [BillingMode] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + IN_ADVANCE -> Value.IN_ADVANCE + IN_ARREAR -> Value.IN_ARREAR + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + IN_ADVANCE -> Known.IN_ADVANCE + IN_ARREAR -> Known.IN_ARREAR + else -> throw OrbInvalidDataException("Unknown BillingMode: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): BillingMode = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BillingMode && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + class Cadence @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -50423,6 +54354,7 @@ private constructor( id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && + billingMode == other.billingMode && cadence == other.cadence && compositePriceFilters == other.compositePriceFilters && conversionRate == other.conversionRate && @@ -50455,6 +54387,7 @@ private constructor( id, billableMetric, billingCycleConfiguration, + billingMode, cadence, compositePriceFilters, conversionRate, @@ -50486,7 +54419,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "MaxGroupTieredPackage{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maxGroupTieredPackageConfig=$maxGroupTieredPackageConfig, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "MaxGroupTieredPackage{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maxGroupTieredPackageConfig=$maxGroupTieredPackageConfig, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" } class ScalableMatrixWithUnitPricing @@ -50494,6 +54427,7 @@ private constructor( private val id: JsonField, private val billableMetric: JsonField, private val billingCycleConfiguration: JsonField, + private val billingMode: JsonField, private val cadence: JsonField, private val compositePriceFilters: JsonField>, private val conversionRate: JsonField, @@ -50531,6 +54465,9 @@ private constructor( @JsonProperty("billing_cycle_configuration") @ExcludeMissing billingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("billing_mode") + @ExcludeMissing + billingMode: JsonField = JsonMissing.of(), @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), @JsonProperty("composite_price_filters") @ExcludeMissing @@ -50597,6 +54534,7 @@ private constructor( id, billableMetric, billingCycleConfiguration, + billingMode, cadence, compositePriceFilters, conversionRate, @@ -50643,6 +54581,12 @@ private constructor( fun billingCycleConfiguration(): BillingCycleConfiguration = billingCycleConfiguration.getRequired("billing_cycle_configuration") + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun billingMode(): BillingMode = billingMode.getRequired("billing_mode") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). @@ -50840,6 +54784,15 @@ private constructor( fun _billingCycleConfiguration(): JsonField = billingCycleConfiguration + /** + * Returns the raw JSON value of [billingMode]. + * + * Unlike [billingMode], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("billing_mode") + @ExcludeMissing + fun _billingMode(): JsonField = billingMode + /** * Returns the raw JSON value of [cadence]. * @@ -51081,6 +55034,7 @@ private constructor( * .id() * .billableMetric() * .billingCycleConfiguration() + * .billingMode() * .cadence() * .compositePriceFilters() * .conversionRate() @@ -51114,6 +55068,7 @@ private constructor( private var id: JsonField? = null private var billableMetric: JsonField? = null private var billingCycleConfiguration: JsonField? = null + private var billingMode: JsonField? = null private var cadence: JsonField? = null private var compositePriceFilters: JsonField>? = null private var conversionRate: JsonField? = null @@ -51149,6 +55104,7 @@ private constructor( billableMetric = scalableMatrixWithUnitPricing.billableMetric billingCycleConfiguration = scalableMatrixWithUnitPricing.billingCycleConfiguration + billingMode = scalableMatrixWithUnitPricing.billingMode cadence = scalableMatrixWithUnitPricing.cadence compositePriceFilters = scalableMatrixWithUnitPricing.compositePriceFilters.map { @@ -51222,6 +55178,19 @@ private constructor( billingCycleConfiguration: JsonField ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + fun billingMode(billingMode: BillingMode) = billingMode(JsonField.of(billingMode)) + + /** + * Sets [Builder.billingMode] to an arbitrary JSON value. + * + * You should usually call [Builder.billingMode] with a well-typed [BillingMode] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun billingMode(billingMode: JsonField) = apply { + this.billingMode = billingMode + } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) /** @@ -51742,6 +55711,7 @@ private constructor( * .id() * .billableMetric() * .billingCycleConfiguration() + * .billingMode() * .cadence() * .compositePriceFilters() * .conversionRate() @@ -51773,6 +55743,7 @@ private constructor( checkRequired("id", id), checkRequired("billableMetric", billableMetric), checkRequired("billingCycleConfiguration", billingCycleConfiguration), + checkRequired("billingMode", billingMode), checkRequired("cadence", cadence), checkRequired("compositePriceFilters", compositePriceFilters).map { it.toImmutable() @@ -51816,6 +55787,7 @@ private constructor( id() billableMetric()?.validate() billingCycleConfiguration().validate() + billingMode().validate() cadence().validate() compositePriceFilters()?.forEach { it.validate() } conversionRate() @@ -51865,6 +55837,7 @@ private constructor( (if (id.asKnown() == null) 0 else 1) + (billableMetric.asKnown()?.validity() ?: 0) + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (billingMode.asKnown()?.validity() ?: 0) + (cadence.asKnown()?.validity() ?: 0) + (compositePriceFilters.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + (if (conversionRate.asKnown() == null) 0 else 1) + @@ -51892,6 +55865,135 @@ private constructor( (scalableMatrixWithUnitPricingConfig.asKnown()?.validity() ?: 0) + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + class BillingMode @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val IN_ADVANCE = of("in_advance") + + val IN_ARREAR = of("in_arrear") + + fun of(value: String) = BillingMode(JsonField.of(value)) + } + + /** An enum containing [BillingMode]'s known values. */ + enum class Known { + IN_ADVANCE, + IN_ARREAR, + } + + /** + * An enum containing [BillingMode]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [BillingMode] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + IN_ADVANCE, + IN_ARREAR, + /** + * An enum member indicating that [BillingMode] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + IN_ADVANCE -> Value.IN_ADVANCE + IN_ARREAR -> Value.IN_ARREAR + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + IN_ADVANCE -> Known.IN_ADVANCE + IN_ARREAR -> Known.IN_ARREAR + else -> throw OrbInvalidDataException("Unknown BillingMode: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): BillingMode = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BillingMode && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + class Cadence @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -52952,6 +57054,7 @@ private constructor( id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && + billingMode == other.billingMode && cadence == other.cadence && compositePriceFilters == other.compositePriceFilters && conversionRate == other.conversionRate && @@ -52984,6 +57087,7 @@ private constructor( id, billableMetric, billingCycleConfiguration, + billingMode, cadence, compositePriceFilters, conversionRate, @@ -53015,7 +57119,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "ScalableMatrixWithUnitPricing{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, scalableMatrixWithUnitPricingConfig=$scalableMatrixWithUnitPricingConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "ScalableMatrixWithUnitPricing{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, scalableMatrixWithUnitPricingConfig=$scalableMatrixWithUnitPricingConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" } class ScalableMatrixWithTieredPricing @@ -53023,6 +57127,7 @@ private constructor( private val id: JsonField, private val billableMetric: JsonField, private val billingCycleConfiguration: JsonField, + private val billingMode: JsonField, private val cadence: JsonField, private val compositePriceFilters: JsonField>, private val conversionRate: JsonField, @@ -53060,6 +57165,9 @@ private constructor( @JsonProperty("billing_cycle_configuration") @ExcludeMissing billingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("billing_mode") + @ExcludeMissing + billingMode: JsonField = JsonMissing.of(), @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), @JsonProperty("composite_price_filters") @ExcludeMissing @@ -53127,6 +57235,7 @@ private constructor( id, billableMetric, billingCycleConfiguration, + billingMode, cadence, compositePriceFilters, conversionRate, @@ -53173,6 +57282,12 @@ private constructor( fun billingCycleConfiguration(): BillingCycleConfiguration = billingCycleConfiguration.getRequired("billing_cycle_configuration") + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun billingMode(): BillingMode = billingMode.getRequired("billing_mode") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). @@ -53370,6 +57485,15 @@ private constructor( fun _billingCycleConfiguration(): JsonField = billingCycleConfiguration + /** + * Returns the raw JSON value of [billingMode]. + * + * Unlike [billingMode], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("billing_mode") + @ExcludeMissing + fun _billingMode(): JsonField = billingMode + /** * Returns the raw JSON value of [cadence]. * @@ -53611,6 +57735,7 @@ private constructor( * .id() * .billableMetric() * .billingCycleConfiguration() + * .billingMode() * .cadence() * .compositePriceFilters() * .conversionRate() @@ -53644,6 +57769,7 @@ private constructor( private var id: JsonField? = null private var billableMetric: JsonField? = null private var billingCycleConfiguration: JsonField? = null + private var billingMode: JsonField? = null private var cadence: JsonField? = null private var compositePriceFilters: JsonField>? = null private var conversionRate: JsonField? = null @@ -53679,6 +57805,7 @@ private constructor( billableMetric = scalableMatrixWithTieredPricing.billableMetric billingCycleConfiguration = scalableMatrixWithTieredPricing.billingCycleConfiguration + billingMode = scalableMatrixWithTieredPricing.billingMode cadence = scalableMatrixWithTieredPricing.cadence compositePriceFilters = scalableMatrixWithTieredPricing.compositePriceFilters.map { @@ -53752,6 +57879,19 @@ private constructor( billingCycleConfiguration: JsonField ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + fun billingMode(billingMode: BillingMode) = billingMode(JsonField.of(billingMode)) + + /** + * Sets [Builder.billingMode] to an arbitrary JSON value. + * + * You should usually call [Builder.billingMode] with a well-typed [BillingMode] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun billingMode(billingMode: JsonField) = apply { + this.billingMode = billingMode + } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) /** @@ -54273,6 +58413,7 @@ private constructor( * .id() * .billableMetric() * .billingCycleConfiguration() + * .billingMode() * .cadence() * .compositePriceFilters() * .conversionRate() @@ -54304,6 +58445,7 @@ private constructor( checkRequired("id", id), checkRequired("billableMetric", billableMetric), checkRequired("billingCycleConfiguration", billingCycleConfiguration), + checkRequired("billingMode", billingMode), checkRequired("cadence", cadence), checkRequired("compositePriceFilters", compositePriceFilters).map { it.toImmutable() @@ -54347,6 +58489,7 @@ private constructor( id() billableMetric()?.validate() billingCycleConfiguration().validate() + billingMode().validate() cadence().validate() compositePriceFilters()?.forEach { it.validate() } conversionRate() @@ -54396,6 +58539,7 @@ private constructor( (if (id.asKnown() == null) 0 else 1) + (billableMetric.asKnown()?.validity() ?: 0) + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (billingMode.asKnown()?.validity() ?: 0) + (cadence.asKnown()?.validity() ?: 0) + (compositePriceFilters.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + (if (conversionRate.asKnown() == null) 0 else 1) + @@ -54423,6 +58567,135 @@ private constructor( (scalableMatrixWithTieredPricingConfig.asKnown()?.validity() ?: 0) + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + class BillingMode @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val IN_ADVANCE = of("in_advance") + + val IN_ARREAR = of("in_arrear") + + fun of(value: String) = BillingMode(JsonField.of(value)) + } + + /** An enum containing [BillingMode]'s known values. */ + enum class Known { + IN_ADVANCE, + IN_ARREAR, + } + + /** + * An enum containing [BillingMode]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [BillingMode] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + IN_ADVANCE, + IN_ARREAR, + /** + * An enum member indicating that [BillingMode] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + IN_ADVANCE -> Value.IN_ADVANCE + IN_ARREAR -> Value.IN_ARREAR + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + IN_ADVANCE -> Known.IN_ADVANCE + IN_ARREAR -> Known.IN_ARREAR + else -> throw OrbInvalidDataException("Unknown BillingMode: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): BillingMode = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BillingMode && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + class Cadence @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -55660,6 +59933,7 @@ private constructor( id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && + billingMode == other.billingMode && cadence == other.cadence && compositePriceFilters == other.compositePriceFilters && conversionRate == other.conversionRate && @@ -55693,6 +59967,7 @@ private constructor( id, billableMetric, billingCycleConfiguration, + billingMode, cadence, compositePriceFilters, conversionRate, @@ -55724,7 +59999,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "ScalableMatrixWithTieredPricing{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, scalableMatrixWithTieredPricingConfig=$scalableMatrixWithTieredPricingConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "ScalableMatrixWithTieredPricing{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, scalableMatrixWithTieredPricingConfig=$scalableMatrixWithTieredPricingConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" } class CumulativeGroupedBulk @@ -55732,6 +60007,7 @@ private constructor( private val id: JsonField, private val billableMetric: JsonField, private val billingCycleConfiguration: JsonField, + private val billingMode: JsonField, private val cadence: JsonField, private val compositePriceFilters: JsonField>, private val conversionRate: JsonField, @@ -55768,6 +60044,9 @@ private constructor( @JsonProperty("billing_cycle_configuration") @ExcludeMissing billingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("billing_mode") + @ExcludeMissing + billingMode: JsonField = JsonMissing.of(), @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), @JsonProperty("composite_price_filters") @ExcludeMissing @@ -55833,6 +60112,7 @@ private constructor( id, billableMetric, billingCycleConfiguration, + billingMode, cadence, compositePriceFilters, conversionRate, @@ -55879,6 +60159,12 @@ private constructor( fun billingCycleConfiguration(): BillingCycleConfiguration = billingCycleConfiguration.getRequired("billing_cycle_configuration") + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun billingMode(): BillingMode = billingMode.getRequired("billing_mode") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). @@ -56074,6 +60360,15 @@ private constructor( fun _billingCycleConfiguration(): JsonField = billingCycleConfiguration + /** + * Returns the raw JSON value of [billingMode]. + * + * Unlike [billingMode], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("billing_mode") + @ExcludeMissing + fun _billingMode(): JsonField = billingMode + /** * Returns the raw JSON value of [cadence]. * @@ -56314,6 +60609,7 @@ private constructor( * .id() * .billableMetric() * .billingCycleConfiguration() + * .billingMode() * .cadence() * .compositePriceFilters() * .conversionRate() @@ -56347,6 +60643,7 @@ private constructor( private var id: JsonField? = null private var billableMetric: JsonField? = null private var billingCycleConfiguration: JsonField? = null + private var billingMode: JsonField? = null private var cadence: JsonField? = null private var compositePriceFilters: JsonField>? = null private var conversionRate: JsonField? = null @@ -56378,6 +60675,7 @@ private constructor( id = cumulativeGroupedBulk.id billableMetric = cumulativeGroupedBulk.billableMetric billingCycleConfiguration = cumulativeGroupedBulk.billingCycleConfiguration + billingMode = cumulativeGroupedBulk.billingMode cadence = cumulativeGroupedBulk.cadence compositePriceFilters = cumulativeGroupedBulk.compositePriceFilters.map { it.toMutableList() } @@ -56445,6 +60743,19 @@ private constructor( billingCycleConfiguration: JsonField ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + fun billingMode(billingMode: BillingMode) = billingMode(JsonField.of(billingMode)) + + /** + * Sets [Builder.billingMode] to an arbitrary JSON value. + * + * You should usually call [Builder.billingMode] with a well-typed [BillingMode] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun billingMode(billingMode: JsonField) = apply { + this.billingMode = billingMode + } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) /** @@ -56960,6 +61271,7 @@ private constructor( * .id() * .billableMetric() * .billingCycleConfiguration() + * .billingMode() * .cadence() * .compositePriceFilters() * .conversionRate() @@ -56991,6 +61303,7 @@ private constructor( checkRequired("id", id), checkRequired("billableMetric", billableMetric), checkRequired("billingCycleConfiguration", billingCycleConfiguration), + checkRequired("billingMode", billingMode), checkRequired("cadence", cadence), checkRequired("compositePriceFilters", compositePriceFilters).map { it.toImmutable() @@ -57031,6 +61344,7 @@ private constructor( id() billableMetric()?.validate() billingCycleConfiguration().validate() + billingMode().validate() cadence().validate() compositePriceFilters()?.forEach { it.validate() } conversionRate() @@ -57080,6 +61394,7 @@ private constructor( (if (id.asKnown() == null) 0 else 1) + (billableMetric.asKnown()?.validity() ?: 0) + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (billingMode.asKnown()?.validity() ?: 0) + (cadence.asKnown()?.validity() ?: 0) + (compositePriceFilters.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + (if (conversionRate.asKnown() == null) 0 else 1) + @@ -57105,6 +61420,135 @@ private constructor( (if (replacesPriceId.asKnown() == null) 0 else 1) + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + class BillingMode @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val IN_ADVANCE = of("in_advance") + + val IN_ARREAR = of("in_arrear") + + fun of(value: String) = BillingMode(JsonField.of(value)) + } + + /** An enum containing [BillingMode]'s known values. */ + enum class Known { + IN_ADVANCE, + IN_ARREAR, + } + + /** + * An enum containing [BillingMode]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [BillingMode] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + IN_ADVANCE, + IN_ARREAR, + /** + * An enum member indicating that [BillingMode] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + IN_ADVANCE -> Value.IN_ADVANCE + IN_ARREAR -> Value.IN_ARREAR + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + IN_ADVANCE -> Known.IN_ADVANCE + IN_ARREAR -> Known.IN_ARREAR + else -> throw OrbInvalidDataException("Unknown BillingMode: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): BillingMode = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BillingMode && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + class Cadence @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -57997,6 +62441,7 @@ private constructor( id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && + billingMode == other.billingMode && cadence == other.cadence && compositePriceFilters == other.compositePriceFilters && conversionRate == other.conversionRate && @@ -58029,6 +62474,7 @@ private constructor( id, billableMetric, billingCycleConfiguration, + billingMode, cadence, compositePriceFilters, conversionRate, @@ -58060,7 +62506,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "CumulativeGroupedBulk{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, cumulativeGroupedBulkConfig=$cumulativeGroupedBulkConfig, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "CumulativeGroupedBulk{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, cumulativeGroupedBulkConfig=$cumulativeGroupedBulkConfig, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" } class Minimum @@ -58068,6 +62514,7 @@ private constructor( private val id: JsonField, private val billableMetric: JsonField, private val billingCycleConfiguration: JsonField, + private val billingMode: JsonField, private val cadence: JsonField, private val compositePriceFilters: JsonField>, private val conversionRate: JsonField, @@ -58104,6 +62551,9 @@ private constructor( @JsonProperty("billing_cycle_configuration") @ExcludeMissing billingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("billing_mode") + @ExcludeMissing + billingMode: JsonField = JsonMissing.of(), @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), @JsonProperty("composite_price_filters") @ExcludeMissing @@ -58169,6 +62619,7 @@ private constructor( id, billableMetric, billingCycleConfiguration, + billingMode, cadence, compositePriceFilters, conversionRate, @@ -58215,6 +62666,12 @@ private constructor( fun billingCycleConfiguration(): BillingCycleConfiguration = billingCycleConfiguration.getRequired("billing_cycle_configuration") + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun billingMode(): BillingMode = billingMode.getRequired("billing_mode") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). @@ -58409,6 +62866,15 @@ private constructor( fun _billingCycleConfiguration(): JsonField = billingCycleConfiguration + /** + * Returns the raw JSON value of [billingMode]. + * + * Unlike [billingMode], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("billing_mode") + @ExcludeMissing + fun _billingMode(): JsonField = billingMode + /** * Returns the raw JSON value of [cadence]. * @@ -58648,6 +63114,7 @@ private constructor( * .id() * .billableMetric() * .billingCycleConfiguration() + * .billingMode() * .cadence() * .compositePriceFilters() * .conversionRate() @@ -58681,6 +63148,7 @@ private constructor( private var id: JsonField? = null private var billableMetric: JsonField? = null private var billingCycleConfiguration: JsonField? = null + private var billingMode: JsonField? = null private var cadence: JsonField? = null private var compositePriceFilters: JsonField>? = null private var conversionRate: JsonField? = null @@ -58712,6 +63180,7 @@ private constructor( id = minimum.id billableMetric = minimum.billableMetric billingCycleConfiguration = minimum.billingCycleConfiguration + billingMode = minimum.billingMode cadence = minimum.cadence compositePriceFilters = minimum.compositePriceFilters.map { it.toMutableList() } conversionRate = minimum.conversionRate @@ -58778,6 +63247,19 @@ private constructor( billingCycleConfiguration: JsonField ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + fun billingMode(billingMode: BillingMode) = billingMode(JsonField.of(billingMode)) + + /** + * Sets [Builder.billingMode] to an arbitrary JSON value. + * + * You should usually call [Builder.billingMode] with a well-typed [BillingMode] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun billingMode(billingMode: JsonField) = apply { + this.billingMode = billingMode + } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) /** @@ -59292,6 +63774,7 @@ private constructor( * .id() * .billableMetric() * .billingCycleConfiguration() + * .billingMode() * .cadence() * .compositePriceFilters() * .conversionRate() @@ -59323,6 +63806,7 @@ private constructor( checkRequired("id", id), checkRequired("billableMetric", billableMetric), checkRequired("billingCycleConfiguration", billingCycleConfiguration), + checkRequired("billingMode", billingMode), checkRequired("cadence", cadence), checkRequired("compositePriceFilters", compositePriceFilters).map { it.toImmutable() @@ -59363,6 +63847,7 @@ private constructor( id() billableMetric()?.validate() billingCycleConfiguration().validate() + billingMode().validate() cadence().validate() compositePriceFilters()?.forEach { it.validate() } conversionRate() @@ -59412,6 +63897,7 @@ private constructor( (if (id.asKnown() == null) 0 else 1) + (billableMetric.asKnown()?.validity() ?: 0) + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (billingMode.asKnown()?.validity() ?: 0) + (cadence.asKnown()?.validity() ?: 0) + (compositePriceFilters.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + (if (conversionRate.asKnown() == null) 0 else 1) + @@ -59437,6 +63923,135 @@ private constructor( (if (replacesPriceId.asKnown() == null) 0 else 1) + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + class BillingMode @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val IN_ADVANCE = of("in_advance") + + val IN_ARREAR = of("in_arrear") + + fun of(value: String) = BillingMode(JsonField.of(value)) + } + + /** An enum containing [BillingMode]'s known values. */ + enum class Known { + IN_ADVANCE, + IN_ARREAR, + } + + /** + * An enum containing [BillingMode]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [BillingMode] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + IN_ADVANCE, + IN_ARREAR, + /** + * An enum member indicating that [BillingMode] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + IN_ADVANCE -> Value.IN_ADVANCE + IN_ARREAR -> Value.IN_ARREAR + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + IN_ADVANCE -> Known.IN_ADVANCE + IN_ARREAR -> Known.IN_ARREAR + else -> throw OrbInvalidDataException("Unknown BillingMode: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): BillingMode = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BillingMode && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + class Cadence @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -60049,6 +64664,7 @@ private constructor( id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && + billingMode == other.billingMode && cadence == other.cadence && compositePriceFilters == other.compositePriceFilters && conversionRate == other.conversionRate && @@ -60081,6 +64697,7 @@ private constructor( id, billableMetric, billingCycleConfiguration, + billingMode, cadence, compositePriceFilters, conversionRate, @@ -60112,6 +64729,6 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Minimum{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, minimumConfig=$minimumConfig, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "Minimum{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, minimumConfig=$minimumConfig, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" } } diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/AggregatedCostTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/AggregatedCostTest.kt index b665b618c..b980ffa1a 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/AggregatedCostTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/AggregatedCostTest.kt @@ -27,6 +27,7 @@ internal class AggregatedCostTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() @@ -156,6 +157,7 @@ internal class AggregatedCostTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() @@ -289,6 +291,7 @@ internal class AggregatedCostTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/ChangedSubscriptionResourcesTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/ChangedSubscriptionResourcesTest.kt index 9422a5980..a8b44a3d6 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/ChangedSubscriptionResourcesTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/ChangedSubscriptionResourcesTest.kt @@ -102,11 +102,11 @@ internal class ChangedSubscriptionResourcesTest { .build() ) .addCreatedInvoice( - Invoice.builder() + ChangedSubscriptionResources.CreatedInvoice.builder() .id("id") .amountDue("8.00") .autoCollection( - Invoice.AutoCollection.builder() + ChangedSubscriptionResources.CreatedInvoice.AutoCollection.builder() .enabled(true) .nextAttemptAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .numAttempts(0L) @@ -127,7 +127,7 @@ internal class ChangedSubscriptionResourcesTest { ) .createdAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) .addCreditNote( - Invoice.CreditNote.builder() + ChangedSubscriptionResources.CreatedInvoice.CreditNote.builder() .id("id") .creditNoteNumber("credit_note_number") .memo("memo") @@ -145,10 +145,14 @@ internal class ChangedSubscriptionResourcesTest { .build() ) .addCustomerBalanceTransaction( - Invoice.CustomerBalanceTransaction.builder() + ChangedSubscriptionResources.CreatedInvoice.CustomerBalanceTransaction + .builder() .id("cgZa3SXcsPTVyC4Y") .action( - Invoice.CustomerBalanceTransaction.Action.APPLIED_TO_INVOICE + ChangedSubscriptionResources.CreatedInvoice + .CustomerBalanceTransaction + .Action + .APPLIED_TO_INVOICE ) .amount("11.00") .createdAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) @@ -157,7 +161,12 @@ internal class ChangedSubscriptionResourcesTest { .endingBalance("22.00") .invoice(InvoiceTiny.builder().id("gXcsPTVyC4YZa3Sc").build()) .startingBalance("33.00") - .type(Invoice.CustomerBalanceTransaction.Type.INCREMENT) + .type( + ChangedSubscriptionResources.CreatedInvoice + .CustomerBalanceTransaction + .Type + .INCREMENT + ) .build() ) .customerTaxId( @@ -192,11 +201,14 @@ internal class ChangedSubscriptionResourcesTest { .invoicePdf( "https://assets.withorb.com/invoice/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" ) - .invoiceSource(Invoice.InvoiceSource.SUBSCRIPTION) + .invoiceSource( + ChangedSubscriptionResources.CreatedInvoice.InvoiceSource.SUBSCRIPTION + ) + .isPayableNow(true) .issueFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .issuedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addLineItem( - Invoice.LineItem.builder() + ChangedSubscriptionResources.CreatedInvoice.LineItem.builder() .id("id") .adjustedSubtotal("5.00") .addAdjustment( @@ -286,6 +298,7 @@ internal class ChangedSubscriptionResourcesTest { ) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() @@ -455,7 +468,7 @@ internal class ChangedSubscriptionResourcesTest { .maximumAmount("maximum_amount") .memo("memo") .metadata( - Invoice.Metadata.builder() + ChangedSubscriptionResources.CreatedInvoice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -475,11 +488,15 @@ internal class ChangedSubscriptionResourcesTest { .minimumAmount("minimum_amount") .paidAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addPaymentAttempt( - Invoice.PaymentAttempt.builder() + ChangedSubscriptionResources.CreatedInvoice.PaymentAttempt.builder() .id("id") .amount("amount") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .paymentProvider(Invoice.PaymentAttempt.PaymentProvider.STRIPE) + .paymentProvider( + ChangedSubscriptionResources.CreatedInvoice.PaymentAttempt + .PaymentProvider + .STRIPE + ) .paymentProviderId("payment_provider_id") .receiptPdf( "https://assets.withorb.com/receipt/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" @@ -500,7 +517,7 @@ internal class ChangedSubscriptionResourcesTest { .state("state") .build() ) - .status(Invoice.Status.ISSUED) + .status(ChangedSubscriptionResources.CreatedInvoice.Status.ISSUED) .subscription(SubscriptionMinified.builder().id("VDGsT23osdLb84KD").build()) .subtotal("8.00") .syncFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) @@ -780,6 +797,7 @@ internal class ChangedSubscriptionResourcesTest { ) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() @@ -1092,11 +1110,11 @@ internal class ChangedSubscriptionResourcesTest { ) assertThat(changedSubscriptionResources.createdInvoices()) .containsExactly( - Invoice.builder() + ChangedSubscriptionResources.CreatedInvoice.builder() .id("id") .amountDue("8.00") .autoCollection( - Invoice.AutoCollection.builder() + ChangedSubscriptionResources.CreatedInvoice.AutoCollection.builder() .enabled(true) .nextAttemptAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .numAttempts(0L) @@ -1115,7 +1133,7 @@ internal class ChangedSubscriptionResourcesTest { ) .createdAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) .addCreditNote( - Invoice.CreditNote.builder() + ChangedSubscriptionResources.CreatedInvoice.CreditNote.builder() .id("id") .creditNoteNumber("credit_note_number") .memo("memo") @@ -1133,9 +1151,15 @@ internal class ChangedSubscriptionResourcesTest { .build() ) .addCustomerBalanceTransaction( - Invoice.CustomerBalanceTransaction.builder() + ChangedSubscriptionResources.CreatedInvoice.CustomerBalanceTransaction + .builder() .id("cgZa3SXcsPTVyC4Y") - .action(Invoice.CustomerBalanceTransaction.Action.APPLIED_TO_INVOICE) + .action( + ChangedSubscriptionResources.CreatedInvoice + .CustomerBalanceTransaction + .Action + .APPLIED_TO_INVOICE + ) .amount("11.00") .createdAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) .creditNote(CreditNoteTiny.builder().id("id").build()) @@ -1143,7 +1167,12 @@ internal class ChangedSubscriptionResourcesTest { .endingBalance("22.00") .invoice(InvoiceTiny.builder().id("gXcsPTVyC4YZa3Sc").build()) .startingBalance("33.00") - .type(Invoice.CustomerBalanceTransaction.Type.INCREMENT) + .type( + ChangedSubscriptionResources.CreatedInvoice + .CustomerBalanceTransaction + .Type + .INCREMENT + ) .build() ) .customerTaxId( @@ -1178,11 +1207,14 @@ internal class ChangedSubscriptionResourcesTest { .invoicePdf( "https://assets.withorb.com/invoice/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" ) - .invoiceSource(Invoice.InvoiceSource.SUBSCRIPTION) + .invoiceSource( + ChangedSubscriptionResources.CreatedInvoice.InvoiceSource.SUBSCRIPTION + ) + .isPayableNow(true) .issueFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .issuedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addLineItem( - Invoice.LineItem.builder() + ChangedSubscriptionResources.CreatedInvoice.LineItem.builder() .id("id") .adjustedSubtotal("5.00") .addAdjustment( @@ -1270,6 +1302,7 @@ internal class ChangedSubscriptionResourcesTest { ) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() @@ -1432,7 +1465,7 @@ internal class ChangedSubscriptionResourcesTest { .maximumAmount("maximum_amount") .memo("memo") .metadata( - Invoice.Metadata.builder() + ChangedSubscriptionResources.CreatedInvoice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -1452,11 +1485,15 @@ internal class ChangedSubscriptionResourcesTest { .minimumAmount("minimum_amount") .paidAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addPaymentAttempt( - Invoice.PaymentAttempt.builder() + ChangedSubscriptionResources.CreatedInvoice.PaymentAttempt.builder() .id("id") .amount("amount") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .paymentProvider(Invoice.PaymentAttempt.PaymentProvider.STRIPE) + .paymentProvider( + ChangedSubscriptionResources.CreatedInvoice.PaymentAttempt + .PaymentProvider + .STRIPE + ) .paymentProviderId("payment_provider_id") .receiptPdf( "https://assets.withorb.com/receipt/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" @@ -1477,7 +1514,7 @@ internal class ChangedSubscriptionResourcesTest { .state("state") .build() ) - .status(Invoice.Status.ISSUED) + .status(ChangedSubscriptionResources.CreatedInvoice.Status.ISSUED) .subscription(SubscriptionMinified.builder().id("VDGsT23osdLb84KD").build()) .subtotal("8.00") .syncFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) @@ -1751,6 +1788,7 @@ internal class ChangedSubscriptionResourcesTest { ) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() @@ -2061,11 +2099,11 @@ internal class ChangedSubscriptionResourcesTest { .build() ) .addCreatedInvoice( - Invoice.builder() + ChangedSubscriptionResources.CreatedInvoice.builder() .id("id") .amountDue("8.00") .autoCollection( - Invoice.AutoCollection.builder() + ChangedSubscriptionResources.CreatedInvoice.AutoCollection.builder() .enabled(true) .nextAttemptAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .numAttempts(0L) @@ -2086,7 +2124,7 @@ internal class ChangedSubscriptionResourcesTest { ) .createdAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) .addCreditNote( - Invoice.CreditNote.builder() + ChangedSubscriptionResources.CreatedInvoice.CreditNote.builder() .id("id") .creditNoteNumber("credit_note_number") .memo("memo") @@ -2104,10 +2142,14 @@ internal class ChangedSubscriptionResourcesTest { .build() ) .addCustomerBalanceTransaction( - Invoice.CustomerBalanceTransaction.builder() + ChangedSubscriptionResources.CreatedInvoice.CustomerBalanceTransaction + .builder() .id("cgZa3SXcsPTVyC4Y") .action( - Invoice.CustomerBalanceTransaction.Action.APPLIED_TO_INVOICE + ChangedSubscriptionResources.CreatedInvoice + .CustomerBalanceTransaction + .Action + .APPLIED_TO_INVOICE ) .amount("11.00") .createdAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) @@ -2116,7 +2158,12 @@ internal class ChangedSubscriptionResourcesTest { .endingBalance("22.00") .invoice(InvoiceTiny.builder().id("gXcsPTVyC4YZa3Sc").build()) .startingBalance("33.00") - .type(Invoice.CustomerBalanceTransaction.Type.INCREMENT) + .type( + ChangedSubscriptionResources.CreatedInvoice + .CustomerBalanceTransaction + .Type + .INCREMENT + ) .build() ) .customerTaxId( @@ -2151,11 +2198,14 @@ internal class ChangedSubscriptionResourcesTest { .invoicePdf( "https://assets.withorb.com/invoice/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" ) - .invoiceSource(Invoice.InvoiceSource.SUBSCRIPTION) + .invoiceSource( + ChangedSubscriptionResources.CreatedInvoice.InvoiceSource.SUBSCRIPTION + ) + .isPayableNow(true) .issueFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .issuedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addLineItem( - Invoice.LineItem.builder() + ChangedSubscriptionResources.CreatedInvoice.LineItem.builder() .id("id") .adjustedSubtotal("5.00") .addAdjustment( @@ -2245,6 +2295,7 @@ internal class ChangedSubscriptionResourcesTest { ) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() @@ -2414,7 +2465,7 @@ internal class ChangedSubscriptionResourcesTest { .maximumAmount("maximum_amount") .memo("memo") .metadata( - Invoice.Metadata.builder() + ChangedSubscriptionResources.CreatedInvoice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -2434,11 +2485,15 @@ internal class ChangedSubscriptionResourcesTest { .minimumAmount("minimum_amount") .paidAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addPaymentAttempt( - Invoice.PaymentAttempt.builder() + ChangedSubscriptionResources.CreatedInvoice.PaymentAttempt.builder() .id("id") .amount("amount") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .paymentProvider(Invoice.PaymentAttempt.PaymentProvider.STRIPE) + .paymentProvider( + ChangedSubscriptionResources.CreatedInvoice.PaymentAttempt + .PaymentProvider + .STRIPE + ) .paymentProviderId("payment_provider_id") .receiptPdf( "https://assets.withorb.com/receipt/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" @@ -2459,7 +2514,7 @@ internal class ChangedSubscriptionResourcesTest { .state("state") .build() ) - .status(Invoice.Status.ISSUED) + .status(ChangedSubscriptionResources.CreatedInvoice.Status.ISSUED) .subscription(SubscriptionMinified.builder().id("VDGsT23osdLb84KD").build()) .subtotal("8.00") .syncFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) @@ -2739,6 +2794,7 @@ internal class ChangedSubscriptionResourcesTest { ) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCostListByExternalIdResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCostListByExternalIdResponseTest.kt index a74562924..9d4b5d941 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCostListByExternalIdResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCostListByExternalIdResponseTest.kt @@ -33,6 +33,7 @@ internal class CustomerCostListByExternalIdResponseTest { ) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() @@ -185,6 +186,7 @@ internal class CustomerCostListByExternalIdResponseTest { ) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() @@ -336,6 +338,7 @@ internal class CustomerCostListByExternalIdResponseTest { ) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCostListResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCostListResponseTest.kt index 6cd4faed7..47de57efe 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCostListResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCostListResponseTest.kt @@ -33,6 +33,7 @@ internal class CustomerCostListResponseTest { ) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() @@ -185,6 +186,7 @@ internal class CustomerCostListResponseTest { ) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() @@ -336,6 +338,7 @@ internal class CustomerCostListResponseTest { ) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdResponseTest.kt index 35a8c93f1..5342d2f00 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdResponseTest.kt @@ -232,6 +232,7 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdResponseTest { ) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() @@ -699,6 +700,7 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdResponseTest { ) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryResponseTest.kt index 91310b859..c498bcc45 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryResponseTest.kt @@ -232,6 +232,7 @@ internal class CustomerCreditLedgerCreateEntryResponseTest { ) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() @@ -698,6 +699,7 @@ internal class CustomerCreditLedgerCreateEntryResponseTest { ) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdPageResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdPageResponseTest.kt index 9af956b30..e8ae023f9 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdPageResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdPageResponseTest.kt @@ -248,6 +248,7 @@ internal class CustomerCreditLedgerListByExternalIdPageResponseTest { ) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() @@ -740,6 +741,7 @@ internal class CustomerCreditLedgerListByExternalIdPageResponseTest { ) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() @@ -1235,6 +1237,7 @@ internal class CustomerCreditLedgerListByExternalIdPageResponseTest { ) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdResponseTest.kt index 52e1877d0..c7f92d2a0 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdResponseTest.kt @@ -232,6 +232,7 @@ internal class CustomerCreditLedgerListByExternalIdResponseTest { ) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() @@ -698,6 +699,7 @@ internal class CustomerCreditLedgerListByExternalIdResponseTest { ) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListPageResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListPageResponseTest.kt index 289f72481..3b4ff8ad5 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListPageResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListPageResponseTest.kt @@ -248,6 +248,7 @@ internal class CustomerCreditLedgerListPageResponseTest { ) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() @@ -740,6 +741,7 @@ internal class CustomerCreditLedgerListPageResponseTest { ) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() @@ -1235,6 +1237,7 @@ internal class CustomerCreditLedgerListPageResponseTest { ) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListResponseTest.kt index 1ce21f4f0..00f597ee3 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListResponseTest.kt @@ -232,6 +232,7 @@ internal class CustomerCreditLedgerListResponseTest { ) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() @@ -698,6 +699,7 @@ internal class CustomerCreditLedgerListResponseTest { ) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/IncrementLedgerEntryTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/IncrementLedgerEntryTest.kt index fc48bf767..f90d87221 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/IncrementLedgerEntryTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/IncrementLedgerEntryTest.kt @@ -228,6 +228,7 @@ internal class IncrementLedgerEntryTest { ) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() @@ -667,6 +668,7 @@ internal class IncrementLedgerEntryTest { ) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() @@ -1103,6 +1105,7 @@ internal class IncrementLedgerEntryTest { ) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceFetchUpcomingResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceFetchUpcomingResponseTest.kt index 3db504962..cc409dc93 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceFetchUpcomingResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceFetchUpcomingResponseTest.kt @@ -191,6 +191,7 @@ internal class InvoiceFetchUpcomingResponseTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() @@ -592,6 +593,7 @@ internal class InvoiceFetchUpcomingResponseTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() @@ -991,6 +993,7 @@ internal class InvoiceFetchUpcomingResponseTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceLineItemCreateResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceLineItemCreateResponseTest.kt index a81e9aa32..a68417130 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceLineItemCreateResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceLineItemCreateResponseTest.kt @@ -99,6 +99,7 @@ internal class InvoiceLineItemCreateResponseTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() @@ -321,6 +322,7 @@ internal class InvoiceLineItemCreateResponseTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() @@ -543,6 +545,7 @@ internal class InvoiceLineItemCreateResponseTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceListPageResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceListPageResponseTest.kt index 84d51e6ce..ab9c81358 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceListPageResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceListPageResponseTest.kt @@ -200,6 +200,7 @@ internal class InvoiceListPageResponseTest { ) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() @@ -608,6 +609,7 @@ internal class InvoiceListPageResponseTest { ) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() @@ -1018,6 +1020,7 @@ internal class InvoiceListPageResponseTest { ) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceTest.kt index 62e9d066d..e02163864 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceTest.kt @@ -187,6 +187,7 @@ internal class InvoiceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() @@ -579,6 +580,7 @@ internal class InvoiceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() @@ -967,6 +969,7 @@ internal class InvoiceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/MutatedSubscriptionTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/MutatedSubscriptionTest.kt index 94af8b8c9..4a79dd989 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/MutatedSubscriptionTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/MutatedSubscriptionTest.kt @@ -359,6 +359,7 @@ internal class MutatedSubscriptionTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() @@ -509,6 +510,7 @@ internal class MutatedSubscriptionTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() @@ -725,11 +727,12 @@ internal class MutatedSubscriptionTest { .build() ) .addCreatedInvoice( - Invoice.builder() + ChangedSubscriptionResources.CreatedInvoice.builder() .id("id") .amountDue("8.00") .autoCollection( - Invoice.AutoCollection.builder() + ChangedSubscriptionResources.CreatedInvoice.AutoCollection + .builder() .enabled(true) .nextAttemptAt( OffsetDateTime.parse("2019-12-27T18:11:19.117Z") @@ -752,7 +755,7 @@ internal class MutatedSubscriptionTest { ) .createdAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) .addCreditNote( - Invoice.CreditNote.builder() + ChangedSubscriptionResources.CreatedInvoice.CreditNote.builder() .id("id") .creditNoteNumber("credit_note_number") .memo("memo") @@ -770,10 +773,14 @@ internal class MutatedSubscriptionTest { .build() ) .addCustomerBalanceTransaction( - Invoice.CustomerBalanceTransaction.builder() + ChangedSubscriptionResources.CreatedInvoice + .CustomerBalanceTransaction + .builder() .id("cgZa3SXcsPTVyC4Y") .action( - Invoice.CustomerBalanceTransaction.Action + ChangedSubscriptionResources.CreatedInvoice + .CustomerBalanceTransaction + .Action .APPLIED_TO_INVOICE ) .amount("11.00") @@ -787,7 +794,12 @@ internal class MutatedSubscriptionTest { InvoiceTiny.builder().id("gXcsPTVyC4YZa3Sc").build() ) .startingBalance("33.00") - .type(Invoice.CustomerBalanceTransaction.Type.INCREMENT) + .type( + ChangedSubscriptionResources.CreatedInvoice + .CustomerBalanceTransaction + .Type + .INCREMENT + ) .build() ) .customerTaxId( @@ -822,11 +834,15 @@ internal class MutatedSubscriptionTest { .invoicePdf( "https://assets.withorb.com/invoice/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" ) - .invoiceSource(Invoice.InvoiceSource.SUBSCRIPTION) + .invoiceSource( + ChangedSubscriptionResources.CreatedInvoice.InvoiceSource + .SUBSCRIPTION + ) + .isPayableNow(true) .issueFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .issuedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addLineItem( - Invoice.LineItem.builder() + ChangedSubscriptionResources.CreatedInvoice.LineItem.builder() .id("id") .adjustedSubtotal("5.00") .addAdjustment( @@ -927,6 +943,7 @@ internal class MutatedSubscriptionTest { ) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() @@ -1119,7 +1136,7 @@ internal class MutatedSubscriptionTest { .maximumAmount("maximum_amount") .memo("memo") .metadata( - Invoice.Metadata.builder() + ChangedSubscriptionResources.CreatedInvoice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -1139,12 +1156,16 @@ internal class MutatedSubscriptionTest { .minimumAmount("minimum_amount") .paidAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addPaymentAttempt( - Invoice.PaymentAttempt.builder() + ChangedSubscriptionResources.CreatedInvoice.PaymentAttempt + .builder() .id("id") .amount("amount") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .paymentProvider( - Invoice.PaymentAttempt.PaymentProvider.STRIPE + ChangedSubscriptionResources.CreatedInvoice + .PaymentAttempt + .PaymentProvider + .STRIPE ) .paymentProviderId("payment_provider_id") .receiptPdf( @@ -1166,7 +1187,7 @@ internal class MutatedSubscriptionTest { .state("state") .build() ) - .status(Invoice.Status.ISSUED) + .status(ChangedSubscriptionResources.CreatedInvoice.Status.ISSUED) .subscription( SubscriptionMinified.builder().id("VDGsT23osdLb84KD").build() ) @@ -1471,6 +1492,7 @@ internal class MutatedSubscriptionTest { ) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() @@ -2082,6 +2104,7 @@ internal class MutatedSubscriptionTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() @@ -2227,6 +2250,7 @@ internal class MutatedSubscriptionTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() @@ -2442,11 +2466,11 @@ internal class MutatedSubscriptionTest { .build() ) .addCreatedInvoice( - Invoice.builder() + ChangedSubscriptionResources.CreatedInvoice.builder() .id("id") .amountDue("8.00") .autoCollection( - Invoice.AutoCollection.builder() + ChangedSubscriptionResources.CreatedInvoice.AutoCollection.builder() .enabled(true) .nextAttemptAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .numAttempts(0L) @@ -2467,7 +2491,7 @@ internal class MutatedSubscriptionTest { ) .createdAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) .addCreditNote( - Invoice.CreditNote.builder() + ChangedSubscriptionResources.CreatedInvoice.CreditNote.builder() .id("id") .creditNoteNumber("credit_note_number") .memo("memo") @@ -2485,10 +2509,15 @@ internal class MutatedSubscriptionTest { .build() ) .addCustomerBalanceTransaction( - Invoice.CustomerBalanceTransaction.builder() + ChangedSubscriptionResources.CreatedInvoice + .CustomerBalanceTransaction + .builder() .id("cgZa3SXcsPTVyC4Y") .action( - Invoice.CustomerBalanceTransaction.Action.APPLIED_TO_INVOICE + ChangedSubscriptionResources.CreatedInvoice + .CustomerBalanceTransaction + .Action + .APPLIED_TO_INVOICE ) .amount("11.00") .createdAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) @@ -2497,7 +2526,12 @@ internal class MutatedSubscriptionTest { .endingBalance("22.00") .invoice(InvoiceTiny.builder().id("gXcsPTVyC4YZa3Sc").build()) .startingBalance("33.00") - .type(Invoice.CustomerBalanceTransaction.Type.INCREMENT) + .type( + ChangedSubscriptionResources.CreatedInvoice + .CustomerBalanceTransaction + .Type + .INCREMENT + ) .build() ) .customerTaxId( @@ -2532,11 +2566,15 @@ internal class MutatedSubscriptionTest { .invoicePdf( "https://assets.withorb.com/invoice/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" ) - .invoiceSource(Invoice.InvoiceSource.SUBSCRIPTION) + .invoiceSource( + ChangedSubscriptionResources.CreatedInvoice.InvoiceSource + .SUBSCRIPTION + ) + .isPayableNow(true) .issueFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .issuedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addLineItem( - Invoice.LineItem.builder() + ChangedSubscriptionResources.CreatedInvoice.LineItem.builder() .id("id") .adjustedSubtotal("5.00") .addAdjustment( @@ -2636,6 +2674,7 @@ internal class MutatedSubscriptionTest { ) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() @@ -2818,7 +2857,7 @@ internal class MutatedSubscriptionTest { .maximumAmount("maximum_amount") .memo("memo") .metadata( - Invoice.Metadata.builder() + ChangedSubscriptionResources.CreatedInvoice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -2838,11 +2877,15 @@ internal class MutatedSubscriptionTest { .minimumAmount("minimum_amount") .paidAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addPaymentAttempt( - Invoice.PaymentAttempt.builder() + ChangedSubscriptionResources.CreatedInvoice.PaymentAttempt.builder() .id("id") .amount("amount") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .paymentProvider(Invoice.PaymentAttempt.PaymentProvider.STRIPE) + .paymentProvider( + ChangedSubscriptionResources.CreatedInvoice.PaymentAttempt + .PaymentProvider + .STRIPE + ) .paymentProviderId("payment_provider_id") .receiptPdf( "https://assets.withorb.com/receipt/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" @@ -2863,7 +2906,7 @@ internal class MutatedSubscriptionTest { .state("state") .build() ) - .status(Invoice.Status.ISSUED) + .status(ChangedSubscriptionResources.CreatedInvoice.Status.ISSUED) .subscription( SubscriptionMinified.builder().id("VDGsT23osdLb84KD").build() ) @@ -3157,6 +3200,7 @@ internal class MutatedSubscriptionTest { ) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() @@ -3748,6 +3792,7 @@ internal class MutatedSubscriptionTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() @@ -3898,6 +3943,7 @@ internal class MutatedSubscriptionTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() @@ -4114,11 +4160,12 @@ internal class MutatedSubscriptionTest { .build() ) .addCreatedInvoice( - Invoice.builder() + ChangedSubscriptionResources.CreatedInvoice.builder() .id("id") .amountDue("8.00") .autoCollection( - Invoice.AutoCollection.builder() + ChangedSubscriptionResources.CreatedInvoice.AutoCollection + .builder() .enabled(true) .nextAttemptAt( OffsetDateTime.parse("2019-12-27T18:11:19.117Z") @@ -4141,7 +4188,7 @@ internal class MutatedSubscriptionTest { ) .createdAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) .addCreditNote( - Invoice.CreditNote.builder() + ChangedSubscriptionResources.CreatedInvoice.CreditNote.builder() .id("id") .creditNoteNumber("credit_note_number") .memo("memo") @@ -4159,10 +4206,14 @@ internal class MutatedSubscriptionTest { .build() ) .addCustomerBalanceTransaction( - Invoice.CustomerBalanceTransaction.builder() + ChangedSubscriptionResources.CreatedInvoice + .CustomerBalanceTransaction + .builder() .id("cgZa3SXcsPTVyC4Y") .action( - Invoice.CustomerBalanceTransaction.Action + ChangedSubscriptionResources.CreatedInvoice + .CustomerBalanceTransaction + .Action .APPLIED_TO_INVOICE ) .amount("11.00") @@ -4176,7 +4227,12 @@ internal class MutatedSubscriptionTest { InvoiceTiny.builder().id("gXcsPTVyC4YZa3Sc").build() ) .startingBalance("33.00") - .type(Invoice.CustomerBalanceTransaction.Type.INCREMENT) + .type( + ChangedSubscriptionResources.CreatedInvoice + .CustomerBalanceTransaction + .Type + .INCREMENT + ) .build() ) .customerTaxId( @@ -4211,11 +4267,15 @@ internal class MutatedSubscriptionTest { .invoicePdf( "https://assets.withorb.com/invoice/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" ) - .invoiceSource(Invoice.InvoiceSource.SUBSCRIPTION) + .invoiceSource( + ChangedSubscriptionResources.CreatedInvoice.InvoiceSource + .SUBSCRIPTION + ) + .isPayableNow(true) .issueFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .issuedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addLineItem( - Invoice.LineItem.builder() + ChangedSubscriptionResources.CreatedInvoice.LineItem.builder() .id("id") .adjustedSubtotal("5.00") .addAdjustment( @@ -4316,6 +4376,7 @@ internal class MutatedSubscriptionTest { ) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() @@ -4508,7 +4569,7 @@ internal class MutatedSubscriptionTest { .maximumAmount("maximum_amount") .memo("memo") .metadata( - Invoice.Metadata.builder() + ChangedSubscriptionResources.CreatedInvoice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -4528,12 +4589,16 @@ internal class MutatedSubscriptionTest { .minimumAmount("minimum_amount") .paidAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addPaymentAttempt( - Invoice.PaymentAttempt.builder() + ChangedSubscriptionResources.CreatedInvoice.PaymentAttempt + .builder() .id("id") .amount("amount") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .paymentProvider( - Invoice.PaymentAttempt.PaymentProvider.STRIPE + ChangedSubscriptionResources.CreatedInvoice + .PaymentAttempt + .PaymentProvider + .STRIPE ) .paymentProviderId("payment_provider_id") .receiptPdf( @@ -4555,7 +4620,7 @@ internal class MutatedSubscriptionTest { .state("state") .build() ) - .status(Invoice.Status.ISSUED) + .status(ChangedSubscriptionResources.CreatedInvoice.Status.ISSUED) .subscription( SubscriptionMinified.builder().id("VDGsT23osdLb84KD").build() ) @@ -4860,6 +4925,7 @@ internal class MutatedSubscriptionTest { ) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PerPriceCostTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PerPriceCostTest.kt index 88343781f..9dd016b7e 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PerPriceCostTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PerPriceCostTest.kt @@ -25,6 +25,7 @@ internal class PerPriceCostTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() @@ -145,6 +146,7 @@ internal class PerPriceCostTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() @@ -269,6 +271,7 @@ internal class PerPriceCostTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanListPageResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanListPageResponseTest.kt index 76d819dc5..ffcba9f19 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanListPageResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanListPageResponseTest.kt @@ -168,6 +168,7 @@ internal class PlanListPageResponseTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() @@ -448,6 +449,7 @@ internal class PlanListPageResponseTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() @@ -729,6 +731,7 @@ internal class PlanListPageResponseTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanTest.kt index 5a81695fb..39a0bb191 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanTest.kt @@ -166,6 +166,7 @@ internal class PlanTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() @@ -449,6 +450,7 @@ internal class PlanTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() @@ -727,6 +729,7 @@ internal class PlanTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanVersionTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanVersionTest.kt index 783944ed4..f1d70364e 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanVersionTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanVersionTest.kt @@ -57,6 +57,7 @@ internal class PlanVersionTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() @@ -211,6 +212,7 @@ internal class PlanVersionTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() @@ -364,6 +366,7 @@ internal class PlanVersionTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceIntervalTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceIntervalTest.kt index 7400228b9..0e0e0223a 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceIntervalTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceIntervalTest.kt @@ -38,6 +38,7 @@ internal class PriceIntervalTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() @@ -173,6 +174,7 @@ internal class PriceIntervalTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() @@ -309,6 +311,7 @@ internal class PriceIntervalTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceListPageResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceListPageResponseTest.kt index d3e712a46..267cea090 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceListPageResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceListPageResponseTest.kt @@ -25,6 +25,7 @@ internal class PriceListPageResponseTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() @@ -144,6 +145,7 @@ internal class PriceListPageResponseTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() @@ -266,6 +268,7 @@ internal class PriceListPageResponseTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceTest.kt index da134e6f5..2c4c8e3f4 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceTest.kt @@ -27,6 +27,7 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() @@ -171,6 +172,7 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() @@ -289,6 +291,7 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) + .billingMode(Price.Tiered.BillingMode.IN_ADVANCE) .cadence(Price.Tiered.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() @@ -441,6 +444,7 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) + .billingMode(Price.Tiered.BillingMode.IN_ADVANCE) .cadence(Price.Tiered.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() @@ -567,6 +571,7 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) + .billingMode(Price.Bulk.BillingMode.IN_ADVANCE) .bulkConfig( BulkConfig.builder() .addTier( @@ -715,6 +720,7 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) + .billingMode(Price.Bulk.BillingMode.IN_ADVANCE) .bulkConfig( BulkConfig.builder() .addTier( @@ -840,6 +846,7 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) + .billingMode(Price.Package.BillingMode.IN_ADVANCE) .cadence(Price.Package.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() @@ -984,6 +991,7 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) + .billingMode(Price.Package.BillingMode.IN_ADVANCE) .cadence(Price.Package.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() @@ -1105,6 +1113,7 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) + .billingMode(Price.Matrix.BillingMode.IN_ADVANCE) .cadence(Price.Matrix.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() @@ -1258,6 +1267,7 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) + .billingMode(Price.Matrix.BillingMode.IN_ADVANCE) .cadence(Price.Matrix.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() @@ -1385,6 +1395,7 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) + .billingMode(Price.ThresholdTotalAmount.BillingMode.IN_ADVANCE) .cadence(Price.ThresholdTotalAmount.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() @@ -1545,6 +1556,7 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) + .billingMode(Price.ThresholdTotalAmount.BillingMode.IN_ADVANCE) .cadence(Price.ThresholdTotalAmount.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() @@ -1681,6 +1693,7 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) + .billingMode(Price.TieredPackage.BillingMode.IN_ADVANCE) .cadence(Price.TieredPackage.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() @@ -1839,6 +1852,7 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) + .billingMode(Price.TieredPackage.BillingMode.IN_ADVANCE) .cadence(Price.TieredPackage.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() @@ -1971,6 +1985,7 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) + .billingMode(Price.TieredWithMinimum.BillingMode.IN_ADVANCE) .cadence(Price.TieredWithMinimum.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() @@ -2132,6 +2147,7 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) + .billingMode(Price.TieredWithMinimum.BillingMode.IN_ADVANCE) .cadence(Price.TieredWithMinimum.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() @@ -2267,6 +2283,7 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) + .billingMode(Price.GroupedTiered.BillingMode.IN_ADVANCE) .cadence(Price.GroupedTiered.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() @@ -2425,6 +2442,7 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) + .billingMode(Price.GroupedTiered.BillingMode.IN_ADVANCE) .cadence(Price.GroupedTiered.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() @@ -2557,6 +2575,7 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) + .billingMode(Price.TieredPackageWithMinimum.BillingMode.IN_ADVANCE) .cadence(Price.TieredPackageWithMinimum.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() @@ -2719,6 +2738,7 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) + .billingMode(Price.TieredPackageWithMinimum.BillingMode.IN_ADVANCE) .cadence(Price.TieredPackageWithMinimum.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() @@ -2855,6 +2875,7 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) + .billingMode(Price.PackageWithAllocation.BillingMode.IN_ADVANCE) .cadence(Price.PackageWithAllocation.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() @@ -3003,6 +3024,7 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) + .billingMode(Price.PackageWithAllocation.BillingMode.IN_ADVANCE) .cadence(Price.PackageWithAllocation.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() @@ -3125,6 +3147,7 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) + .billingMode(Price.UnitWithPercent.BillingMode.IN_ADVANCE) .cadence(Price.UnitWithPercent.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() @@ -3272,6 +3295,7 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) + .billingMode(Price.UnitWithPercent.BillingMode.IN_ADVANCE) .cadence(Price.UnitWithPercent.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() @@ -3393,6 +3417,7 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) + .billingMode(Price.MatrixWithAllocation.BillingMode.IN_ADVANCE) .cadence(Price.MatrixWithAllocation.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() @@ -3547,6 +3572,7 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) + .billingMode(Price.MatrixWithAllocation.BillingMode.IN_ADVANCE) .cadence(Price.MatrixWithAllocation.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() @@ -3675,6 +3701,7 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) + .billingMode(Price.TieredWithProration.BillingMode.IN_ADVANCE) .cadence(Price.TieredWithProration.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() @@ -3826,6 +3853,7 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) + .billingMode(Price.TieredWithProration.BillingMode.IN_ADVANCE) .cadence(Price.TieredWithProration.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() @@ -3951,6 +3979,7 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) + .billingMode(Price.UnitWithProration.BillingMode.IN_ADVANCE) .cadence(Price.UnitWithProration.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() @@ -4097,6 +4126,7 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) + .billingMode(Price.UnitWithProration.BillingMode.IN_ADVANCE) .cadence(Price.UnitWithProration.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() @@ -4217,6 +4247,7 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) + .billingMode(Price.GroupedAllocation.BillingMode.IN_ADVANCE) .cadence(Price.GroupedAllocation.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() @@ -4365,6 +4396,7 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) + .billingMode(Price.GroupedAllocation.BillingMode.IN_ADVANCE) .cadence(Price.GroupedAllocation.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() @@ -4487,6 +4519,7 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) + .billingMode(Price.BulkWithProration.BillingMode.IN_ADVANCE) .bulkWithProrationConfig( Price.BulkWithProration.BulkWithProrationConfig.builder() .addTier( @@ -4644,6 +4677,7 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) + .billingMode(Price.BulkWithProration.BillingMode.IN_ADVANCE) .bulkWithProrationConfig( Price.BulkWithProration.BulkWithProrationConfig.builder() .addTier( @@ -4775,6 +4809,7 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) + .billingMode(Price.GroupedWithProratedMinimum.BillingMode.IN_ADVANCE) .cadence(Price.GroupedWithProratedMinimum.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() @@ -4923,6 +4958,7 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) + .billingMode(Price.GroupedWithProratedMinimum.BillingMode.IN_ADVANCE) .cadence(Price.GroupedWithProratedMinimum.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() @@ -5045,6 +5081,7 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) + .billingMode(Price.GroupedWithMeteredMinimum.BillingMode.IN_ADVANCE) .cadence(Price.GroupedWithMeteredMinimum.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() @@ -5210,6 +5247,7 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) + .billingMode(Price.GroupedWithMeteredMinimum.BillingMode.IN_ADVANCE) .cadence(Price.GroupedWithMeteredMinimum.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() @@ -5349,6 +5387,7 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) + .billingMode(Price.GroupedWithMinMaxThresholds.BillingMode.IN_ADVANCE) .cadence(Price.GroupedWithMinMaxThresholds.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() @@ -5498,6 +5537,7 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) + .billingMode(Price.GroupedWithMinMaxThresholds.BillingMode.IN_ADVANCE) .cadence(Price.GroupedWithMinMaxThresholds.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() @@ -5622,6 +5662,7 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) + .billingMode(Price.MatrixWithDisplayName.BillingMode.IN_ADVANCE) .cadence(Price.MatrixWithDisplayName.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() @@ -5776,6 +5817,7 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) + .billingMode(Price.MatrixWithDisplayName.BillingMode.IN_ADVANCE) .cadence(Price.MatrixWithDisplayName.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() @@ -5904,6 +5946,7 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) + .billingMode(Price.GroupedTieredPackage.BillingMode.IN_ADVANCE) .cadence(Price.GroupedTieredPackage.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() @@ -6063,6 +6106,7 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) + .billingMode(Price.GroupedTieredPackage.BillingMode.IN_ADVANCE) .cadence(Price.GroupedTieredPackage.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() @@ -6196,6 +6240,7 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) + .billingMode(Price.MaxGroupTieredPackage.BillingMode.IN_ADVANCE) .cadence(Price.MaxGroupTieredPackage.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() @@ -6355,6 +6400,7 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) + .billingMode(Price.MaxGroupTieredPackage.BillingMode.IN_ADVANCE) .cadence(Price.MaxGroupTieredPackage.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() @@ -6490,6 +6536,7 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) + .billingMode(Price.ScalableMatrixWithUnitPricing.BillingMode.IN_ADVANCE) .cadence(Price.ScalableMatrixWithUnitPricing.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() @@ -6649,6 +6696,7 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) + .billingMode(Price.ScalableMatrixWithUnitPricing.BillingMode.IN_ADVANCE) .cadence(Price.ScalableMatrixWithUnitPricing.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() @@ -6783,6 +6831,7 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) + .billingMode(Price.ScalableMatrixWithTieredPricing.BillingMode.IN_ADVANCE) .cadence(Price.ScalableMatrixWithTieredPricing.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() @@ -6960,6 +7009,7 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) + .billingMode(Price.ScalableMatrixWithTieredPricing.BillingMode.IN_ADVANCE) .cadence(Price.ScalableMatrixWithTieredPricing.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() @@ -7110,6 +7160,7 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) + .billingMode(Price.CumulativeGroupedBulk.BillingMode.IN_ADVANCE) .cadence(Price.CumulativeGroupedBulk.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() @@ -7264,6 +7315,7 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) + .billingMode(Price.CumulativeGroupedBulk.BillingMode.IN_ADVANCE) .cadence(Price.CumulativeGroupedBulk.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() @@ -7393,6 +7445,7 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) + .billingMode(Price.Minimum.BillingMode.IN_ADVANCE) .cadence(Price.Minimum.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() @@ -7540,6 +7593,7 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) + .billingMode(Price.Minimum.BillingMode.IN_ADVANCE) .cadence(Price.Minimum.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeApplyResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeApplyResponseTest.kt index 46e4293f5..84c5eb627 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeApplyResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeApplyResponseTest.kt @@ -389,6 +389,7 @@ internal class SubscriptionChangeApplyResponseTest { ) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() @@ -562,6 +563,7 @@ internal class SubscriptionChangeApplyResponseTest { ) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() @@ -799,11 +801,13 @@ internal class SubscriptionChangeApplyResponseTest { .build() ) .addCreatedInvoice( - Invoice.builder() + ChangedSubscriptionResources.CreatedInvoice.builder() .id("id") .amountDue("8.00") .autoCollection( - Invoice.AutoCollection.builder() + ChangedSubscriptionResources.CreatedInvoice + .AutoCollection + .builder() .enabled(true) .nextAttemptAt( OffsetDateTime.parse("2019-12-27T18:11:19.117Z") @@ -828,7 +832,8 @@ internal class SubscriptionChangeApplyResponseTest { OffsetDateTime.parse("2022-05-01T07:01:31+00:00") ) .addCreditNote( - Invoice.CreditNote.builder() + ChangedSubscriptionResources.CreatedInvoice.CreditNote + .builder() .id("id") .creditNoteNumber("credit_note_number") .memo("memo") @@ -850,10 +855,14 @@ internal class SubscriptionChangeApplyResponseTest { .build() ) .addCustomerBalanceTransaction( - Invoice.CustomerBalanceTransaction.builder() + ChangedSubscriptionResources.CreatedInvoice + .CustomerBalanceTransaction + .builder() .id("cgZa3SXcsPTVyC4Y") .action( - Invoice.CustomerBalanceTransaction.Action + ChangedSubscriptionResources.CreatedInvoice + .CustomerBalanceTransaction + .Action .APPLIED_TO_INVOICE ) .amount("11.00") @@ -874,7 +883,9 @@ internal class SubscriptionChangeApplyResponseTest { ) .startingBalance("33.00") .type( - Invoice.CustomerBalanceTransaction.Type + ChangedSubscriptionResources.CreatedInvoice + .CustomerBalanceTransaction + .Type .INCREMENT ) .build() @@ -919,13 +930,19 @@ internal class SubscriptionChangeApplyResponseTest { .invoicePdf( "https://assets.withorb.com/invoice/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" ) - .invoiceSource(Invoice.InvoiceSource.SUBSCRIPTION) + .invoiceSource( + ChangedSubscriptionResources.CreatedInvoice + .InvoiceSource + .SUBSCRIPTION + ) + .isPayableNow(true) .issueFailedAt( OffsetDateTime.parse("2019-12-27T18:11:19.117Z") ) .issuedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addLineItem( - Invoice.LineItem.builder() + ChangedSubscriptionResources.CreatedInvoice.LineItem + .builder() .id("id") .adjustedSubtotal("5.00") .addAdjustment( @@ -1053,6 +1070,9 @@ internal class SubscriptionChangeApplyResponseTest { ) .build() ) + .billingMode( + Price.Unit.BillingMode.IN_ADVANCE + ) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() @@ -1270,7 +1290,8 @@ internal class SubscriptionChangeApplyResponseTest { .maximumAmount("maximum_amount") .memo("memo") .metadata( - Invoice.Metadata.builder() + ChangedSubscriptionResources.CreatedInvoice.Metadata + .builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -1295,14 +1316,19 @@ internal class SubscriptionChangeApplyResponseTest { .minimumAmount("minimum_amount") .paidAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addPaymentAttempt( - Invoice.PaymentAttempt.builder() + ChangedSubscriptionResources.CreatedInvoice + .PaymentAttempt + .builder() .id("id") .amount("amount") .createdAt( OffsetDateTime.parse("2019-12-27T18:11:19.117Z") ) .paymentProvider( - Invoice.PaymentAttempt.PaymentProvider.STRIPE + ChangedSubscriptionResources.CreatedInvoice + .PaymentAttempt + .PaymentProvider + .STRIPE ) .paymentProviderId("payment_provider_id") .receiptPdf( @@ -1330,7 +1356,10 @@ internal class SubscriptionChangeApplyResponseTest { .state("state") .build() ) - .status(Invoice.Status.ISSUED) + .status( + ChangedSubscriptionResources.CreatedInvoice.Status + .ISSUED + ) .subscription( SubscriptionMinified.builder() .id("VDGsT23osdLb84KD") @@ -1695,6 +1724,9 @@ internal class SubscriptionChangeApplyResponseTest { ) .build() ) + .billingMode( + Price.Unit.BillingMode.IN_ADVANCE + ) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() @@ -2362,6 +2394,7 @@ internal class SubscriptionChangeApplyResponseTest { ) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() @@ -2524,6 +2557,7 @@ internal class SubscriptionChangeApplyResponseTest { ) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() @@ -2752,11 +2786,12 @@ internal class SubscriptionChangeApplyResponseTest { .build() ) .addCreatedInvoice( - Invoice.builder() + ChangedSubscriptionResources.CreatedInvoice.builder() .id("id") .amountDue("8.00") .autoCollection( - Invoice.AutoCollection.builder() + ChangedSubscriptionResources.CreatedInvoice.AutoCollection + .builder() .enabled(true) .nextAttemptAt( OffsetDateTime.parse("2019-12-27T18:11:19.117Z") @@ -2779,7 +2814,8 @@ internal class SubscriptionChangeApplyResponseTest { ) .createdAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) .addCreditNote( - Invoice.CreditNote.builder() + ChangedSubscriptionResources.CreatedInvoice.CreditNote + .builder() .id("id") .creditNoteNumber("credit_note_number") .memo("memo") @@ -2799,10 +2835,14 @@ internal class SubscriptionChangeApplyResponseTest { .build() ) .addCustomerBalanceTransaction( - Invoice.CustomerBalanceTransaction.builder() + ChangedSubscriptionResources.CreatedInvoice + .CustomerBalanceTransaction + .builder() .id("cgZa3SXcsPTVyC4Y") .action( - Invoice.CustomerBalanceTransaction.Action + ChangedSubscriptionResources.CreatedInvoice + .CustomerBalanceTransaction + .Action .APPLIED_TO_INVOICE ) .amount("11.00") @@ -2816,7 +2856,12 @@ internal class SubscriptionChangeApplyResponseTest { InvoiceTiny.builder().id("gXcsPTVyC4YZa3Sc").build() ) .startingBalance("33.00") - .type(Invoice.CustomerBalanceTransaction.Type.INCREMENT) + .type( + ChangedSubscriptionResources.CreatedInvoice + .CustomerBalanceTransaction + .Type + .INCREMENT + ) .build() ) .customerTaxId( @@ -2857,11 +2902,16 @@ internal class SubscriptionChangeApplyResponseTest { .invoicePdf( "https://assets.withorb.com/invoice/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" ) - .invoiceSource(Invoice.InvoiceSource.SUBSCRIPTION) + .invoiceSource( + ChangedSubscriptionResources.CreatedInvoice.InvoiceSource + .SUBSCRIPTION + ) + .isPayableNow(true) .issueFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .issuedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addLineItem( - Invoice.LineItem.builder() + ChangedSubscriptionResources.CreatedInvoice.LineItem + .builder() .id("id") .adjustedSubtotal("5.00") .addAdjustment( @@ -2980,6 +3030,7 @@ internal class SubscriptionChangeApplyResponseTest { ) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() @@ -3187,7 +3238,8 @@ internal class SubscriptionChangeApplyResponseTest { .maximumAmount("maximum_amount") .memo("memo") .metadata( - Invoice.Metadata.builder() + ChangedSubscriptionResources.CreatedInvoice.Metadata + .builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -3209,14 +3261,18 @@ internal class SubscriptionChangeApplyResponseTest { .minimumAmount("minimum_amount") .paidAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addPaymentAttempt( - Invoice.PaymentAttempt.builder() + ChangedSubscriptionResources.CreatedInvoice.PaymentAttempt + .builder() .id("id") .amount("amount") .createdAt( OffsetDateTime.parse("2019-12-27T18:11:19.117Z") ) .paymentProvider( - Invoice.PaymentAttempt.PaymentProvider.STRIPE + ChangedSubscriptionResources.CreatedInvoice + .PaymentAttempt + .PaymentProvider + .STRIPE ) .paymentProviderId("payment_provider_id") .receiptPdf( @@ -3244,7 +3300,9 @@ internal class SubscriptionChangeApplyResponseTest { .state("state") .build() ) - .status(Invoice.Status.ISSUED) + .status( + ChangedSubscriptionResources.CreatedInvoice.Status.ISSUED + ) .subscription( SubscriptionMinified.builder() .id("VDGsT23osdLb84KD") @@ -3579,6 +3637,7 @@ internal class SubscriptionChangeApplyResponseTest { ) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() @@ -4245,6 +4304,7 @@ internal class SubscriptionChangeApplyResponseTest { ) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() @@ -4418,6 +4478,7 @@ internal class SubscriptionChangeApplyResponseTest { ) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() @@ -4655,11 +4716,13 @@ internal class SubscriptionChangeApplyResponseTest { .build() ) .addCreatedInvoice( - Invoice.builder() + ChangedSubscriptionResources.CreatedInvoice.builder() .id("id") .amountDue("8.00") .autoCollection( - Invoice.AutoCollection.builder() + ChangedSubscriptionResources.CreatedInvoice + .AutoCollection + .builder() .enabled(true) .nextAttemptAt( OffsetDateTime.parse("2019-12-27T18:11:19.117Z") @@ -4684,7 +4747,8 @@ internal class SubscriptionChangeApplyResponseTest { OffsetDateTime.parse("2022-05-01T07:01:31+00:00") ) .addCreditNote( - Invoice.CreditNote.builder() + ChangedSubscriptionResources.CreatedInvoice.CreditNote + .builder() .id("id") .creditNoteNumber("credit_note_number") .memo("memo") @@ -4706,10 +4770,14 @@ internal class SubscriptionChangeApplyResponseTest { .build() ) .addCustomerBalanceTransaction( - Invoice.CustomerBalanceTransaction.builder() + ChangedSubscriptionResources.CreatedInvoice + .CustomerBalanceTransaction + .builder() .id("cgZa3SXcsPTVyC4Y") .action( - Invoice.CustomerBalanceTransaction.Action + ChangedSubscriptionResources.CreatedInvoice + .CustomerBalanceTransaction + .Action .APPLIED_TO_INVOICE ) .amount("11.00") @@ -4730,7 +4798,9 @@ internal class SubscriptionChangeApplyResponseTest { ) .startingBalance("33.00") .type( - Invoice.CustomerBalanceTransaction.Type + ChangedSubscriptionResources.CreatedInvoice + .CustomerBalanceTransaction + .Type .INCREMENT ) .build() @@ -4775,13 +4845,19 @@ internal class SubscriptionChangeApplyResponseTest { .invoicePdf( "https://assets.withorb.com/invoice/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" ) - .invoiceSource(Invoice.InvoiceSource.SUBSCRIPTION) + .invoiceSource( + ChangedSubscriptionResources.CreatedInvoice + .InvoiceSource + .SUBSCRIPTION + ) + .isPayableNow(true) .issueFailedAt( OffsetDateTime.parse("2019-12-27T18:11:19.117Z") ) .issuedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addLineItem( - Invoice.LineItem.builder() + ChangedSubscriptionResources.CreatedInvoice.LineItem + .builder() .id("id") .adjustedSubtotal("5.00") .addAdjustment( @@ -4909,6 +4985,9 @@ internal class SubscriptionChangeApplyResponseTest { ) .build() ) + .billingMode( + Price.Unit.BillingMode.IN_ADVANCE + ) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() @@ -5126,7 +5205,8 @@ internal class SubscriptionChangeApplyResponseTest { .maximumAmount("maximum_amount") .memo("memo") .metadata( - Invoice.Metadata.builder() + ChangedSubscriptionResources.CreatedInvoice.Metadata + .builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -5151,14 +5231,19 @@ internal class SubscriptionChangeApplyResponseTest { .minimumAmount("minimum_amount") .paidAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addPaymentAttempt( - Invoice.PaymentAttempt.builder() + ChangedSubscriptionResources.CreatedInvoice + .PaymentAttempt + .builder() .id("id") .amount("amount") .createdAt( OffsetDateTime.parse("2019-12-27T18:11:19.117Z") ) .paymentProvider( - Invoice.PaymentAttempt.PaymentProvider.STRIPE + ChangedSubscriptionResources.CreatedInvoice + .PaymentAttempt + .PaymentProvider + .STRIPE ) .paymentProviderId("payment_provider_id") .receiptPdf( @@ -5186,7 +5271,10 @@ internal class SubscriptionChangeApplyResponseTest { .state("state") .build() ) - .status(Invoice.Status.ISSUED) + .status( + ChangedSubscriptionResources.CreatedInvoice.Status + .ISSUED + ) .subscription( SubscriptionMinified.builder() .id("VDGsT23osdLb84KD") @@ -5551,6 +5639,9 @@ internal class SubscriptionChangeApplyResponseTest { ) .build() ) + .billingMode( + Price.Unit.BillingMode.IN_ADVANCE + ) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeCancelResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeCancelResponseTest.kt index f53010db1..a5aa5f98b 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeCancelResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeCancelResponseTest.kt @@ -389,6 +389,7 @@ internal class SubscriptionChangeCancelResponseTest { ) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() @@ -562,6 +563,7 @@ internal class SubscriptionChangeCancelResponseTest { ) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() @@ -799,11 +801,13 @@ internal class SubscriptionChangeCancelResponseTest { .build() ) .addCreatedInvoice( - Invoice.builder() + ChangedSubscriptionResources.CreatedInvoice.builder() .id("id") .amountDue("8.00") .autoCollection( - Invoice.AutoCollection.builder() + ChangedSubscriptionResources.CreatedInvoice + .AutoCollection + .builder() .enabled(true) .nextAttemptAt( OffsetDateTime.parse("2019-12-27T18:11:19.117Z") @@ -828,7 +832,8 @@ internal class SubscriptionChangeCancelResponseTest { OffsetDateTime.parse("2022-05-01T07:01:31+00:00") ) .addCreditNote( - Invoice.CreditNote.builder() + ChangedSubscriptionResources.CreatedInvoice.CreditNote + .builder() .id("id") .creditNoteNumber("credit_note_number") .memo("memo") @@ -850,10 +855,14 @@ internal class SubscriptionChangeCancelResponseTest { .build() ) .addCustomerBalanceTransaction( - Invoice.CustomerBalanceTransaction.builder() + ChangedSubscriptionResources.CreatedInvoice + .CustomerBalanceTransaction + .builder() .id("cgZa3SXcsPTVyC4Y") .action( - Invoice.CustomerBalanceTransaction.Action + ChangedSubscriptionResources.CreatedInvoice + .CustomerBalanceTransaction + .Action .APPLIED_TO_INVOICE ) .amount("11.00") @@ -874,7 +883,9 @@ internal class SubscriptionChangeCancelResponseTest { ) .startingBalance("33.00") .type( - Invoice.CustomerBalanceTransaction.Type + ChangedSubscriptionResources.CreatedInvoice + .CustomerBalanceTransaction + .Type .INCREMENT ) .build() @@ -919,13 +930,19 @@ internal class SubscriptionChangeCancelResponseTest { .invoicePdf( "https://assets.withorb.com/invoice/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" ) - .invoiceSource(Invoice.InvoiceSource.SUBSCRIPTION) + .invoiceSource( + ChangedSubscriptionResources.CreatedInvoice + .InvoiceSource + .SUBSCRIPTION + ) + .isPayableNow(true) .issueFailedAt( OffsetDateTime.parse("2019-12-27T18:11:19.117Z") ) .issuedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addLineItem( - Invoice.LineItem.builder() + ChangedSubscriptionResources.CreatedInvoice.LineItem + .builder() .id("id") .adjustedSubtotal("5.00") .addAdjustment( @@ -1053,6 +1070,9 @@ internal class SubscriptionChangeCancelResponseTest { ) .build() ) + .billingMode( + Price.Unit.BillingMode.IN_ADVANCE + ) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() @@ -1270,7 +1290,8 @@ internal class SubscriptionChangeCancelResponseTest { .maximumAmount("maximum_amount") .memo("memo") .metadata( - Invoice.Metadata.builder() + ChangedSubscriptionResources.CreatedInvoice.Metadata + .builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -1295,14 +1316,19 @@ internal class SubscriptionChangeCancelResponseTest { .minimumAmount("minimum_amount") .paidAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addPaymentAttempt( - Invoice.PaymentAttempt.builder() + ChangedSubscriptionResources.CreatedInvoice + .PaymentAttempt + .builder() .id("id") .amount("amount") .createdAt( OffsetDateTime.parse("2019-12-27T18:11:19.117Z") ) .paymentProvider( - Invoice.PaymentAttempt.PaymentProvider.STRIPE + ChangedSubscriptionResources.CreatedInvoice + .PaymentAttempt + .PaymentProvider + .STRIPE ) .paymentProviderId("payment_provider_id") .receiptPdf( @@ -1330,7 +1356,10 @@ internal class SubscriptionChangeCancelResponseTest { .state("state") .build() ) - .status(Invoice.Status.ISSUED) + .status( + ChangedSubscriptionResources.CreatedInvoice.Status + .ISSUED + ) .subscription( SubscriptionMinified.builder() .id("VDGsT23osdLb84KD") @@ -1695,6 +1724,9 @@ internal class SubscriptionChangeCancelResponseTest { ) .build() ) + .billingMode( + Price.Unit.BillingMode.IN_ADVANCE + ) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() @@ -2362,6 +2394,7 @@ internal class SubscriptionChangeCancelResponseTest { ) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() @@ -2524,6 +2557,7 @@ internal class SubscriptionChangeCancelResponseTest { ) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() @@ -2752,11 +2786,12 @@ internal class SubscriptionChangeCancelResponseTest { .build() ) .addCreatedInvoice( - Invoice.builder() + ChangedSubscriptionResources.CreatedInvoice.builder() .id("id") .amountDue("8.00") .autoCollection( - Invoice.AutoCollection.builder() + ChangedSubscriptionResources.CreatedInvoice.AutoCollection + .builder() .enabled(true) .nextAttemptAt( OffsetDateTime.parse("2019-12-27T18:11:19.117Z") @@ -2779,7 +2814,8 @@ internal class SubscriptionChangeCancelResponseTest { ) .createdAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) .addCreditNote( - Invoice.CreditNote.builder() + ChangedSubscriptionResources.CreatedInvoice.CreditNote + .builder() .id("id") .creditNoteNumber("credit_note_number") .memo("memo") @@ -2799,10 +2835,14 @@ internal class SubscriptionChangeCancelResponseTest { .build() ) .addCustomerBalanceTransaction( - Invoice.CustomerBalanceTransaction.builder() + ChangedSubscriptionResources.CreatedInvoice + .CustomerBalanceTransaction + .builder() .id("cgZa3SXcsPTVyC4Y") .action( - Invoice.CustomerBalanceTransaction.Action + ChangedSubscriptionResources.CreatedInvoice + .CustomerBalanceTransaction + .Action .APPLIED_TO_INVOICE ) .amount("11.00") @@ -2816,7 +2856,12 @@ internal class SubscriptionChangeCancelResponseTest { InvoiceTiny.builder().id("gXcsPTVyC4YZa3Sc").build() ) .startingBalance("33.00") - .type(Invoice.CustomerBalanceTransaction.Type.INCREMENT) + .type( + ChangedSubscriptionResources.CreatedInvoice + .CustomerBalanceTransaction + .Type + .INCREMENT + ) .build() ) .customerTaxId( @@ -2857,11 +2902,16 @@ internal class SubscriptionChangeCancelResponseTest { .invoicePdf( "https://assets.withorb.com/invoice/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" ) - .invoiceSource(Invoice.InvoiceSource.SUBSCRIPTION) + .invoiceSource( + ChangedSubscriptionResources.CreatedInvoice.InvoiceSource + .SUBSCRIPTION + ) + .isPayableNow(true) .issueFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .issuedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addLineItem( - Invoice.LineItem.builder() + ChangedSubscriptionResources.CreatedInvoice.LineItem + .builder() .id("id") .adjustedSubtotal("5.00") .addAdjustment( @@ -2980,6 +3030,7 @@ internal class SubscriptionChangeCancelResponseTest { ) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() @@ -3187,7 +3238,8 @@ internal class SubscriptionChangeCancelResponseTest { .maximumAmount("maximum_amount") .memo("memo") .metadata( - Invoice.Metadata.builder() + ChangedSubscriptionResources.CreatedInvoice.Metadata + .builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -3209,14 +3261,18 @@ internal class SubscriptionChangeCancelResponseTest { .minimumAmount("minimum_amount") .paidAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addPaymentAttempt( - Invoice.PaymentAttempt.builder() + ChangedSubscriptionResources.CreatedInvoice.PaymentAttempt + .builder() .id("id") .amount("amount") .createdAt( OffsetDateTime.parse("2019-12-27T18:11:19.117Z") ) .paymentProvider( - Invoice.PaymentAttempt.PaymentProvider.STRIPE + ChangedSubscriptionResources.CreatedInvoice + .PaymentAttempt + .PaymentProvider + .STRIPE ) .paymentProviderId("payment_provider_id") .receiptPdf( @@ -3244,7 +3300,9 @@ internal class SubscriptionChangeCancelResponseTest { .state("state") .build() ) - .status(Invoice.Status.ISSUED) + .status( + ChangedSubscriptionResources.CreatedInvoice.Status.ISSUED + ) .subscription( SubscriptionMinified.builder() .id("VDGsT23osdLb84KD") @@ -3579,6 +3637,7 @@ internal class SubscriptionChangeCancelResponseTest { ) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() @@ -4245,6 +4304,7 @@ internal class SubscriptionChangeCancelResponseTest { ) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() @@ -4418,6 +4478,7 @@ internal class SubscriptionChangeCancelResponseTest { ) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() @@ -4655,11 +4716,13 @@ internal class SubscriptionChangeCancelResponseTest { .build() ) .addCreatedInvoice( - Invoice.builder() + ChangedSubscriptionResources.CreatedInvoice.builder() .id("id") .amountDue("8.00") .autoCollection( - Invoice.AutoCollection.builder() + ChangedSubscriptionResources.CreatedInvoice + .AutoCollection + .builder() .enabled(true) .nextAttemptAt( OffsetDateTime.parse("2019-12-27T18:11:19.117Z") @@ -4684,7 +4747,8 @@ internal class SubscriptionChangeCancelResponseTest { OffsetDateTime.parse("2022-05-01T07:01:31+00:00") ) .addCreditNote( - Invoice.CreditNote.builder() + ChangedSubscriptionResources.CreatedInvoice.CreditNote + .builder() .id("id") .creditNoteNumber("credit_note_number") .memo("memo") @@ -4706,10 +4770,14 @@ internal class SubscriptionChangeCancelResponseTest { .build() ) .addCustomerBalanceTransaction( - Invoice.CustomerBalanceTransaction.builder() + ChangedSubscriptionResources.CreatedInvoice + .CustomerBalanceTransaction + .builder() .id("cgZa3SXcsPTVyC4Y") .action( - Invoice.CustomerBalanceTransaction.Action + ChangedSubscriptionResources.CreatedInvoice + .CustomerBalanceTransaction + .Action .APPLIED_TO_INVOICE ) .amount("11.00") @@ -4730,7 +4798,9 @@ internal class SubscriptionChangeCancelResponseTest { ) .startingBalance("33.00") .type( - Invoice.CustomerBalanceTransaction.Type + ChangedSubscriptionResources.CreatedInvoice + .CustomerBalanceTransaction + .Type .INCREMENT ) .build() @@ -4775,13 +4845,19 @@ internal class SubscriptionChangeCancelResponseTest { .invoicePdf( "https://assets.withorb.com/invoice/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" ) - .invoiceSource(Invoice.InvoiceSource.SUBSCRIPTION) + .invoiceSource( + ChangedSubscriptionResources.CreatedInvoice + .InvoiceSource + .SUBSCRIPTION + ) + .isPayableNow(true) .issueFailedAt( OffsetDateTime.parse("2019-12-27T18:11:19.117Z") ) .issuedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addLineItem( - Invoice.LineItem.builder() + ChangedSubscriptionResources.CreatedInvoice.LineItem + .builder() .id("id") .adjustedSubtotal("5.00") .addAdjustment( @@ -4909,6 +4985,9 @@ internal class SubscriptionChangeCancelResponseTest { ) .build() ) + .billingMode( + Price.Unit.BillingMode.IN_ADVANCE + ) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() @@ -5126,7 +5205,8 @@ internal class SubscriptionChangeCancelResponseTest { .maximumAmount("maximum_amount") .memo("memo") .metadata( - Invoice.Metadata.builder() + ChangedSubscriptionResources.CreatedInvoice.Metadata + .builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -5151,14 +5231,19 @@ internal class SubscriptionChangeCancelResponseTest { .minimumAmount("minimum_amount") .paidAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addPaymentAttempt( - Invoice.PaymentAttempt.builder() + ChangedSubscriptionResources.CreatedInvoice + .PaymentAttempt + .builder() .id("id") .amount("amount") .createdAt( OffsetDateTime.parse("2019-12-27T18:11:19.117Z") ) .paymentProvider( - Invoice.PaymentAttempt.PaymentProvider.STRIPE + ChangedSubscriptionResources.CreatedInvoice + .PaymentAttempt + .PaymentProvider + .STRIPE ) .paymentProviderId("payment_provider_id") .receiptPdf( @@ -5186,7 +5271,10 @@ internal class SubscriptionChangeCancelResponseTest { .state("state") .build() ) - .status(Invoice.Status.ISSUED) + .status( + ChangedSubscriptionResources.CreatedInvoice.Status + .ISSUED + ) .subscription( SubscriptionMinified.builder() .id("VDGsT23osdLb84KD") @@ -5551,6 +5639,9 @@ internal class SubscriptionChangeCancelResponseTest { ) .build() ) + .billingMode( + Price.Unit.BillingMode.IN_ADVANCE + ) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeRetrieveResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeRetrieveResponseTest.kt index 1e1668632..07d523174 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeRetrieveResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeRetrieveResponseTest.kt @@ -389,6 +389,7 @@ internal class SubscriptionChangeRetrieveResponseTest { ) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() @@ -562,6 +563,7 @@ internal class SubscriptionChangeRetrieveResponseTest { ) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() @@ -799,11 +801,13 @@ internal class SubscriptionChangeRetrieveResponseTest { .build() ) .addCreatedInvoice( - Invoice.builder() + ChangedSubscriptionResources.CreatedInvoice.builder() .id("id") .amountDue("8.00") .autoCollection( - Invoice.AutoCollection.builder() + ChangedSubscriptionResources.CreatedInvoice + .AutoCollection + .builder() .enabled(true) .nextAttemptAt( OffsetDateTime.parse("2019-12-27T18:11:19.117Z") @@ -828,7 +832,8 @@ internal class SubscriptionChangeRetrieveResponseTest { OffsetDateTime.parse("2022-05-01T07:01:31+00:00") ) .addCreditNote( - Invoice.CreditNote.builder() + ChangedSubscriptionResources.CreatedInvoice.CreditNote + .builder() .id("id") .creditNoteNumber("credit_note_number") .memo("memo") @@ -850,10 +855,14 @@ internal class SubscriptionChangeRetrieveResponseTest { .build() ) .addCustomerBalanceTransaction( - Invoice.CustomerBalanceTransaction.builder() + ChangedSubscriptionResources.CreatedInvoice + .CustomerBalanceTransaction + .builder() .id("cgZa3SXcsPTVyC4Y") .action( - Invoice.CustomerBalanceTransaction.Action + ChangedSubscriptionResources.CreatedInvoice + .CustomerBalanceTransaction + .Action .APPLIED_TO_INVOICE ) .amount("11.00") @@ -874,7 +883,9 @@ internal class SubscriptionChangeRetrieveResponseTest { ) .startingBalance("33.00") .type( - Invoice.CustomerBalanceTransaction.Type + ChangedSubscriptionResources.CreatedInvoice + .CustomerBalanceTransaction + .Type .INCREMENT ) .build() @@ -919,13 +930,19 @@ internal class SubscriptionChangeRetrieveResponseTest { .invoicePdf( "https://assets.withorb.com/invoice/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" ) - .invoiceSource(Invoice.InvoiceSource.SUBSCRIPTION) + .invoiceSource( + ChangedSubscriptionResources.CreatedInvoice + .InvoiceSource + .SUBSCRIPTION + ) + .isPayableNow(true) .issueFailedAt( OffsetDateTime.parse("2019-12-27T18:11:19.117Z") ) .issuedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addLineItem( - Invoice.LineItem.builder() + ChangedSubscriptionResources.CreatedInvoice.LineItem + .builder() .id("id") .adjustedSubtotal("5.00") .addAdjustment( @@ -1053,6 +1070,9 @@ internal class SubscriptionChangeRetrieveResponseTest { ) .build() ) + .billingMode( + Price.Unit.BillingMode.IN_ADVANCE + ) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() @@ -1270,7 +1290,8 @@ internal class SubscriptionChangeRetrieveResponseTest { .maximumAmount("maximum_amount") .memo("memo") .metadata( - Invoice.Metadata.builder() + ChangedSubscriptionResources.CreatedInvoice.Metadata + .builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -1295,14 +1316,19 @@ internal class SubscriptionChangeRetrieveResponseTest { .minimumAmount("minimum_amount") .paidAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addPaymentAttempt( - Invoice.PaymentAttempt.builder() + ChangedSubscriptionResources.CreatedInvoice + .PaymentAttempt + .builder() .id("id") .amount("amount") .createdAt( OffsetDateTime.parse("2019-12-27T18:11:19.117Z") ) .paymentProvider( - Invoice.PaymentAttempt.PaymentProvider.STRIPE + ChangedSubscriptionResources.CreatedInvoice + .PaymentAttempt + .PaymentProvider + .STRIPE ) .paymentProviderId("payment_provider_id") .receiptPdf( @@ -1330,7 +1356,10 @@ internal class SubscriptionChangeRetrieveResponseTest { .state("state") .build() ) - .status(Invoice.Status.ISSUED) + .status( + ChangedSubscriptionResources.CreatedInvoice.Status + .ISSUED + ) .subscription( SubscriptionMinified.builder() .id("VDGsT23osdLb84KD") @@ -1695,6 +1724,9 @@ internal class SubscriptionChangeRetrieveResponseTest { ) .build() ) + .billingMode( + Price.Unit.BillingMode.IN_ADVANCE + ) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() @@ -2362,6 +2394,7 @@ internal class SubscriptionChangeRetrieveResponseTest { ) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() @@ -2524,6 +2557,7 @@ internal class SubscriptionChangeRetrieveResponseTest { ) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() @@ -2752,11 +2786,12 @@ internal class SubscriptionChangeRetrieveResponseTest { .build() ) .addCreatedInvoice( - Invoice.builder() + ChangedSubscriptionResources.CreatedInvoice.builder() .id("id") .amountDue("8.00") .autoCollection( - Invoice.AutoCollection.builder() + ChangedSubscriptionResources.CreatedInvoice.AutoCollection + .builder() .enabled(true) .nextAttemptAt( OffsetDateTime.parse("2019-12-27T18:11:19.117Z") @@ -2779,7 +2814,8 @@ internal class SubscriptionChangeRetrieveResponseTest { ) .createdAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) .addCreditNote( - Invoice.CreditNote.builder() + ChangedSubscriptionResources.CreatedInvoice.CreditNote + .builder() .id("id") .creditNoteNumber("credit_note_number") .memo("memo") @@ -2799,10 +2835,14 @@ internal class SubscriptionChangeRetrieveResponseTest { .build() ) .addCustomerBalanceTransaction( - Invoice.CustomerBalanceTransaction.builder() + ChangedSubscriptionResources.CreatedInvoice + .CustomerBalanceTransaction + .builder() .id("cgZa3SXcsPTVyC4Y") .action( - Invoice.CustomerBalanceTransaction.Action + ChangedSubscriptionResources.CreatedInvoice + .CustomerBalanceTransaction + .Action .APPLIED_TO_INVOICE ) .amount("11.00") @@ -2816,7 +2856,12 @@ internal class SubscriptionChangeRetrieveResponseTest { InvoiceTiny.builder().id("gXcsPTVyC4YZa3Sc").build() ) .startingBalance("33.00") - .type(Invoice.CustomerBalanceTransaction.Type.INCREMENT) + .type( + ChangedSubscriptionResources.CreatedInvoice + .CustomerBalanceTransaction + .Type + .INCREMENT + ) .build() ) .customerTaxId( @@ -2857,11 +2902,16 @@ internal class SubscriptionChangeRetrieveResponseTest { .invoicePdf( "https://assets.withorb.com/invoice/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" ) - .invoiceSource(Invoice.InvoiceSource.SUBSCRIPTION) + .invoiceSource( + ChangedSubscriptionResources.CreatedInvoice.InvoiceSource + .SUBSCRIPTION + ) + .isPayableNow(true) .issueFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .issuedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addLineItem( - Invoice.LineItem.builder() + ChangedSubscriptionResources.CreatedInvoice.LineItem + .builder() .id("id") .adjustedSubtotal("5.00") .addAdjustment( @@ -2980,6 +3030,7 @@ internal class SubscriptionChangeRetrieveResponseTest { ) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() @@ -3187,7 +3238,8 @@ internal class SubscriptionChangeRetrieveResponseTest { .maximumAmount("maximum_amount") .memo("memo") .metadata( - Invoice.Metadata.builder() + ChangedSubscriptionResources.CreatedInvoice.Metadata + .builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -3209,14 +3261,18 @@ internal class SubscriptionChangeRetrieveResponseTest { .minimumAmount("minimum_amount") .paidAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addPaymentAttempt( - Invoice.PaymentAttempt.builder() + ChangedSubscriptionResources.CreatedInvoice.PaymentAttempt + .builder() .id("id") .amount("amount") .createdAt( OffsetDateTime.parse("2019-12-27T18:11:19.117Z") ) .paymentProvider( - Invoice.PaymentAttempt.PaymentProvider.STRIPE + ChangedSubscriptionResources.CreatedInvoice + .PaymentAttempt + .PaymentProvider + .STRIPE ) .paymentProviderId("payment_provider_id") .receiptPdf( @@ -3244,7 +3300,9 @@ internal class SubscriptionChangeRetrieveResponseTest { .state("state") .build() ) - .status(Invoice.Status.ISSUED) + .status( + ChangedSubscriptionResources.CreatedInvoice.Status.ISSUED + ) .subscription( SubscriptionMinified.builder() .id("VDGsT23osdLb84KD") @@ -3579,6 +3637,7 @@ internal class SubscriptionChangeRetrieveResponseTest { ) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() @@ -4245,6 +4304,7 @@ internal class SubscriptionChangeRetrieveResponseTest { ) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() @@ -4418,6 +4478,7 @@ internal class SubscriptionChangeRetrieveResponseTest { ) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() @@ -4655,11 +4716,13 @@ internal class SubscriptionChangeRetrieveResponseTest { .build() ) .addCreatedInvoice( - Invoice.builder() + ChangedSubscriptionResources.CreatedInvoice.builder() .id("id") .amountDue("8.00") .autoCollection( - Invoice.AutoCollection.builder() + ChangedSubscriptionResources.CreatedInvoice + .AutoCollection + .builder() .enabled(true) .nextAttemptAt( OffsetDateTime.parse("2019-12-27T18:11:19.117Z") @@ -4684,7 +4747,8 @@ internal class SubscriptionChangeRetrieveResponseTest { OffsetDateTime.parse("2022-05-01T07:01:31+00:00") ) .addCreditNote( - Invoice.CreditNote.builder() + ChangedSubscriptionResources.CreatedInvoice.CreditNote + .builder() .id("id") .creditNoteNumber("credit_note_number") .memo("memo") @@ -4706,10 +4770,14 @@ internal class SubscriptionChangeRetrieveResponseTest { .build() ) .addCustomerBalanceTransaction( - Invoice.CustomerBalanceTransaction.builder() + ChangedSubscriptionResources.CreatedInvoice + .CustomerBalanceTransaction + .builder() .id("cgZa3SXcsPTVyC4Y") .action( - Invoice.CustomerBalanceTransaction.Action + ChangedSubscriptionResources.CreatedInvoice + .CustomerBalanceTransaction + .Action .APPLIED_TO_INVOICE ) .amount("11.00") @@ -4730,7 +4798,9 @@ internal class SubscriptionChangeRetrieveResponseTest { ) .startingBalance("33.00") .type( - Invoice.CustomerBalanceTransaction.Type + ChangedSubscriptionResources.CreatedInvoice + .CustomerBalanceTransaction + .Type .INCREMENT ) .build() @@ -4775,13 +4845,19 @@ internal class SubscriptionChangeRetrieveResponseTest { .invoicePdf( "https://assets.withorb.com/invoice/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" ) - .invoiceSource(Invoice.InvoiceSource.SUBSCRIPTION) + .invoiceSource( + ChangedSubscriptionResources.CreatedInvoice + .InvoiceSource + .SUBSCRIPTION + ) + .isPayableNow(true) .issueFailedAt( OffsetDateTime.parse("2019-12-27T18:11:19.117Z") ) .issuedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addLineItem( - Invoice.LineItem.builder() + ChangedSubscriptionResources.CreatedInvoice.LineItem + .builder() .id("id") .adjustedSubtotal("5.00") .addAdjustment( @@ -4909,6 +4985,9 @@ internal class SubscriptionChangeRetrieveResponseTest { ) .build() ) + .billingMode( + Price.Unit.BillingMode.IN_ADVANCE + ) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() @@ -5126,7 +5205,8 @@ internal class SubscriptionChangeRetrieveResponseTest { .maximumAmount("maximum_amount") .memo("memo") .metadata( - Invoice.Metadata.builder() + ChangedSubscriptionResources.CreatedInvoice.Metadata + .builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -5151,14 +5231,19 @@ internal class SubscriptionChangeRetrieveResponseTest { .minimumAmount("minimum_amount") .paidAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addPaymentAttempt( - Invoice.PaymentAttempt.builder() + ChangedSubscriptionResources.CreatedInvoice + .PaymentAttempt + .builder() .id("id") .amount("amount") .createdAt( OffsetDateTime.parse("2019-12-27T18:11:19.117Z") ) .paymentProvider( - Invoice.PaymentAttempt.PaymentProvider.STRIPE + ChangedSubscriptionResources.CreatedInvoice + .PaymentAttempt + .PaymentProvider + .STRIPE ) .paymentProviderId("payment_provider_id") .receiptPdf( @@ -5186,7 +5271,10 @@ internal class SubscriptionChangeRetrieveResponseTest { .state("state") .build() ) - .status(Invoice.Status.ISSUED) + .status( + ChangedSubscriptionResources.CreatedInvoice.Status + .ISSUED + ) .subscription( SubscriptionMinified.builder() .id("VDGsT23osdLb84KD") @@ -5551,6 +5639,9 @@ internal class SubscriptionChangeRetrieveResponseTest { ) .build() ) + .billingMode( + Price.Unit.BillingMode.IN_ADVANCE + ) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionFetchCostsResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionFetchCostsResponseTest.kt index eb256d66d..d2d82de47 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionFetchCostsResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionFetchCostsResponseTest.kt @@ -33,6 +33,7 @@ internal class SubscriptionFetchCostsResponseTest { ) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() @@ -185,6 +186,7 @@ internal class SubscriptionFetchCostsResponseTest { ) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() @@ -336,6 +338,7 @@ internal class SubscriptionFetchCostsResponseTest { ) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionTest.kt index 3e43e496b..6e994bed7 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionTest.kt @@ -359,6 +359,7 @@ internal class SubscriptionTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() @@ -509,6 +510,7 @@ internal class SubscriptionTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() @@ -990,6 +992,7 @@ internal class SubscriptionTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() @@ -1135,6 +1138,7 @@ internal class SubscriptionTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() @@ -1609,6 +1613,7 @@ internal class SubscriptionTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() @@ -1759,6 +1764,7 @@ internal class SubscriptionTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionsTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionsTest.kt index d6fc76ebc..7d0b0937e 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionsTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionsTest.kt @@ -386,6 +386,7 @@ internal class SubscriptionsTest { ) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() @@ -559,6 +560,7 @@ internal class SubscriptionsTest { ) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() @@ -1067,6 +1069,7 @@ internal class SubscriptionsTest { ) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() @@ -1229,6 +1232,7 @@ internal class SubscriptionsTest { ) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() @@ -1743,6 +1747,7 @@ internal class SubscriptionsTest { ) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() @@ -1916,6 +1921,7 @@ internal class SubscriptionsTest { ) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( TransformPriceFilter.builder() From 1bc798369b1883ba86b50ac4829ccb9f5331bca5 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 19 Sep 2025 15:58:27 +0000 Subject: [PATCH 18/68] feat(client): expose sleeper option fix(client): ensure single timer is created per client --- .../api/client/okhttp/OrbOkHttpClient.kt | 12 ++++++++ .../api/client/okhttp/OrbOkHttpClientAsync.kt | 12 ++++++++ .../com/withorb/api/core/ClientOptions.kt | 27 +++++++++++++++++ .../com/withorb/api/core/DefaultSleeper.kt | 14 +++++++++ .../api/core/PhantomReachableSleeper.kt | 21 ++++++++++++++ .../kotlin/com/withorb/api/core/Sleeper.kt | 17 +++++++++++ .../api/core/http/RetryingHttpClient.kt | 29 ++++++------------- .../api/core/http/RetryingHttpClientTest.kt | 9 ++++-- 8 files changed, 119 insertions(+), 22 deletions(-) create mode 100644 orb-kotlin-core/src/main/kotlin/com/withorb/api/core/DefaultSleeper.kt create mode 100644 orb-kotlin-core/src/main/kotlin/com/withorb/api/core/PhantomReachableSleeper.kt create mode 100644 orb-kotlin-core/src/main/kotlin/com/withorb/api/core/Sleeper.kt diff --git a/orb-kotlin-client-okhttp/src/main/kotlin/com/withorb/api/client/okhttp/OrbOkHttpClient.kt b/orb-kotlin-client-okhttp/src/main/kotlin/com/withorb/api/client/okhttp/OrbOkHttpClient.kt index 13caa41b5..b9706f4b6 100644 --- a/orb-kotlin-client-okhttp/src/main/kotlin/com/withorb/api/client/okhttp/OrbOkHttpClient.kt +++ b/orb-kotlin-client-okhttp/src/main/kotlin/com/withorb/api/client/okhttp/OrbOkHttpClient.kt @@ -6,6 +6,7 @@ import com.fasterxml.jackson.databind.json.JsonMapper import com.withorb.api.client.OrbClient import com.withorb.api.client.OrbClientImpl import com.withorb.api.core.ClientOptions +import com.withorb.api.core.Sleeper import com.withorb.api.core.Timeout import com.withorb.api.core.http.Headers import com.withorb.api.core.http.HttpClient @@ -103,6 +104,17 @@ class OrbOkHttpClient private constructor() { */ fun jsonMapper(jsonMapper: JsonMapper) = apply { clientOptions.jsonMapper(jsonMapper) } + /** + * The interface to use for delaying execution, like during retries. + * + * This is primarily useful for using fake delays in tests. + * + * Defaults to real execution delays. + * + * This class takes ownership of the sleeper and closes it when closed. + */ + fun sleeper(sleeper: Sleeper) = apply { clientOptions.sleeper(sleeper) } + /** * The clock to use for operations that require timing, like retries. * diff --git a/orb-kotlin-client-okhttp/src/main/kotlin/com/withorb/api/client/okhttp/OrbOkHttpClientAsync.kt b/orb-kotlin-client-okhttp/src/main/kotlin/com/withorb/api/client/okhttp/OrbOkHttpClientAsync.kt index bb1291a78..c53344999 100644 --- a/orb-kotlin-client-okhttp/src/main/kotlin/com/withorb/api/client/okhttp/OrbOkHttpClientAsync.kt +++ b/orb-kotlin-client-okhttp/src/main/kotlin/com/withorb/api/client/okhttp/OrbOkHttpClientAsync.kt @@ -6,6 +6,7 @@ import com.fasterxml.jackson.databind.json.JsonMapper import com.withorb.api.client.OrbClientAsync import com.withorb.api.client.OrbClientAsyncImpl import com.withorb.api.core.ClientOptions +import com.withorb.api.core.Sleeper import com.withorb.api.core.Timeout import com.withorb.api.core.http.Headers import com.withorb.api.core.http.HttpClient @@ -103,6 +104,17 @@ class OrbOkHttpClientAsync private constructor() { */ fun jsonMapper(jsonMapper: JsonMapper) = apply { clientOptions.jsonMapper(jsonMapper) } + /** + * The interface to use for delaying execution, like during retries. + * + * This is primarily useful for using fake delays in tests. + * + * Defaults to real execution delays. + * + * This class takes ownership of the sleeper and closes it when closed. + */ + fun sleeper(sleeper: Sleeper) = apply { clientOptions.sleeper(sleeper) } + /** * The clock to use for operations that require timing, like retries. * diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/core/ClientOptions.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/core/ClientOptions.kt index 705f9308c..64002c6f0 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/core/ClientOptions.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/core/ClientOptions.kt @@ -38,6 +38,16 @@ private constructor( * needs to be overridden. */ val jsonMapper: JsonMapper, + /** + * The interface to use for delaying execution, like during retries. + * + * This is primarily useful for using fake delays in tests. + * + * Defaults to real execution delays. + * + * This class takes ownership of the sleeper and closes it when closed. + */ + val sleeper: Sleeper, /** * The clock to use for operations that require timing, like retries. * @@ -129,6 +139,7 @@ private constructor( private var httpClient: HttpClient? = null private var checkJacksonVersionCompatibility: Boolean = true private var jsonMapper: JsonMapper = jsonMapper() + private var sleeper: Sleeper? = null private var clock: Clock = Clock.systemUTC() private var baseUrl: String? = null private var headers: Headers.Builder = Headers.builder() @@ -143,6 +154,7 @@ private constructor( httpClient = clientOptions.originalHttpClient checkJacksonVersionCompatibility = clientOptions.checkJacksonVersionCompatibility jsonMapper = clientOptions.jsonMapper + sleeper = clientOptions.sleeper clock = clientOptions.clock baseUrl = clientOptions.baseUrl headers = clientOptions.headers.toBuilder() @@ -184,6 +196,17 @@ private constructor( */ fun jsonMapper(jsonMapper: JsonMapper) = apply { this.jsonMapper = jsonMapper } + /** + * The interface to use for delaying execution, like during retries. + * + * This is primarily useful for using fake delays in tests. + * + * Defaults to real execution delays. + * + * This class takes ownership of the sleeper and closes it when closed. + */ + fun sleeper(sleeper: Sleeper) = apply { this.sleeper = PhantomReachableSleeper(sleeper) } + /** * The clock to use for operations that require timing, like retries. * @@ -368,6 +391,7 @@ private constructor( */ fun build(): ClientOptions { val httpClient = checkRequired("httpClient", httpClient) + val sleeper = sleeper ?: PhantomReachableSleeper(DefaultSleeper()) val apiKey = checkRequired("apiKey", apiKey) val headers = Headers.builder() @@ -391,12 +415,14 @@ private constructor( httpClient, RetryingHttpClient.builder() .httpClient(httpClient) + .sleeper(sleeper) .clock(clock) .maxRetries(maxRetries) .idempotencyHeader("Idempotency-Key") .build(), checkJacksonVersionCompatibility, jsonMapper, + sleeper, clock, baseUrl, headers.build(), @@ -422,5 +448,6 @@ private constructor( */ fun close() { httpClient.close() + sleeper.close() } } diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/core/DefaultSleeper.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/core/DefaultSleeper.kt new file mode 100644 index 000000000..8222607cb --- /dev/null +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/core/DefaultSleeper.kt @@ -0,0 +1,14 @@ +package com.withorb.api.core + +import java.time.Duration +import kotlin.time.toKotlinDuration +import kotlinx.coroutines.delay + +class DefaultSleeper : Sleeper { + + override fun sleep(duration: Duration) = Thread.sleep(duration.toMillis()) + + override suspend fun sleepAsync(duration: Duration) = delay(duration.toKotlinDuration()) + + override fun close() {} +} diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/core/PhantomReachableSleeper.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/core/PhantomReachableSleeper.kt new file mode 100644 index 000000000..f3742aa51 --- /dev/null +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/core/PhantomReachableSleeper.kt @@ -0,0 +1,21 @@ +package com.withorb.api.core + +import java.time.Duration + +/** + * A delegating wrapper around a [Sleeper] that closes it once it's only phantom reachable. + * + * This class ensures the [Sleeper] is closed even if the user forgets to do it. + */ +internal class PhantomReachableSleeper(private val sleeper: Sleeper) : Sleeper { + + init { + closeWhenPhantomReachable(this, sleeper) + } + + override fun sleep(duration: Duration) = sleeper.sleep(duration) + + override suspend fun sleepAsync(duration: Duration) = sleeper.sleepAsync(duration) + + override fun close() = sleeper.close() +} diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/core/Sleeper.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/core/Sleeper.kt new file mode 100644 index 000000000..ae005b7b9 --- /dev/null +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/core/Sleeper.kt @@ -0,0 +1,17 @@ +package com.withorb.api.core + +import java.time.Duration + +/** + * An interface for delaying execution for a specified amount of time. + * + * Useful for testing and cleaning up resources. + */ +interface Sleeper : AutoCloseable { + + /** Synchronously pauses execution for the given [duration]. */ + fun sleep(duration: Duration) + + /** Asynchronously pauses execution for the given [duration]. */ + suspend fun sleepAsync(duration: Duration) +} diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/core/http/RetryingHttpClient.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/core/http/RetryingHttpClient.kt index fd18082fc..37aadd1df 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/core/http/RetryingHttpClient.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/core/http/RetryingHttpClient.kt @@ -1,6 +1,8 @@ package com.withorb.api.core.http +import com.withorb.api.core.DefaultSleeper import com.withorb.api.core.RequestOptions +import com.withorb.api.core.Sleeper import com.withorb.api.core.checkRequired import com.withorb.api.errors.OrbIoException import com.withorb.api.errors.OrbRetryableException @@ -16,8 +18,6 @@ import java.util.concurrent.ThreadLocalRandom import java.util.concurrent.TimeUnit import kotlin.math.min import kotlin.math.pow -import kotlin.time.toKotlinDuration -import kotlinx.coroutines.delay class RetryingHttpClient private constructor( @@ -113,7 +113,10 @@ private constructor( } } - override fun close() = httpClient.close() + override fun close() { + httpClient.close() + sleeper.close() + } private fun isRetryable(request: HttpRequest): Boolean = // Some requests, such as when a request body is being streamed, cannot be retried because @@ -218,21 +221,14 @@ private constructor( class Builder internal constructor() { private var httpClient: HttpClient? = null - private var sleeper: Sleeper = - object : Sleeper { - - override fun sleep(duration: Duration) = Thread.sleep(duration.toMillis()) - - override suspend fun sleepAsync(duration: Duration) = - delay(duration.toKotlinDuration()) - } + private var sleeper: Sleeper? = null private var clock: Clock = Clock.systemUTC() private var maxRetries: Int = 2 private var idempotencyHeader: String? = null fun httpClient(httpClient: HttpClient) = apply { this.httpClient = httpClient } - internal fun sleeper(sleeper: Sleeper) = apply { this.sleeper = sleeper } + fun sleeper(sleeper: Sleeper) = apply { this.sleeper = sleeper } fun clock(clock: Clock) = apply { this.clock = clock } @@ -243,17 +239,10 @@ private constructor( fun build(): HttpClient = RetryingHttpClient( checkRequired("httpClient", httpClient), - sleeper, + sleeper ?: DefaultSleeper(), clock, maxRetries, idempotencyHeader, ) } - - internal interface Sleeper { - - fun sleep(duration: Duration) - - suspend fun sleepAsync(duration: Duration) - } } diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/core/http/RetryingHttpClientTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/core/http/RetryingHttpClientTest.kt index 263929503..e0b8d001c 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/core/http/RetryingHttpClientTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/core/http/RetryingHttpClientTest.kt @@ -6,6 +6,7 @@ import com.github.tomakehurst.wiremock.junit5.WireMockTest import com.github.tomakehurst.wiremock.stubbing.Scenario import com.withorb.api.client.okhttp.OkHttpClient import com.withorb.api.core.RequestOptions +import com.withorb.api.core.Sleeper import com.withorb.api.errors.OrbRetryableException import java.io.InputStream import java.time.Duration @@ -289,11 +290,13 @@ internal class RetryingHttpClientTest { .httpClient(failingHttpClient) .maxRetries(2) .sleeper( - object : RetryingHttpClient.Sleeper { + object : Sleeper { override fun sleep(duration: Duration) {} override suspend fun sleepAsync(duration: Duration) {} + + override fun close() {} } ) .build() @@ -327,11 +330,13 @@ internal class RetryingHttpClientTest { .httpClient(httpClient) // Use a no-op `Sleeper` to make the test fast. .sleeper( - object : RetryingHttpClient.Sleeper { + object : Sleeper { override fun sleep(duration: Duration) {} override suspend fun sleepAsync(duration: Duration) {} + + override fun close() {} } ) From d631c4dd6dbf3657a11731eebdb772ed770ad154 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 19 Sep 2025 22:32:48 +0000 Subject: [PATCH 19/68] feat(api): api update --- .stats.yml | 4 ++-- .../com/withorb/api/models/BetaCreatePlanVersionParams.kt | 7 +------ .../models/BetaExternalPlanIdCreatePlanVersionParams.kt | 7 +------ .../com/withorb/api/services/async/BetaServiceAsync.kt | 7 +------ .../api/services/async/beta/ExternalPlanIdServiceAsync.kt | 7 +------ .../com/withorb/api/services/blocking/BetaService.kt | 7 +------ .../api/services/blocking/beta/ExternalPlanIdService.kt | 7 +------ 7 files changed, 8 insertions(+), 38 deletions(-) diff --git a/.stats.yml b/.stats.yml index 232a1ab71..d522ff7be 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 118 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-96a2f34503f9348f8d7ce82035fe09c917860d77e17bc6817e034b891902599a.yml -openapi_spec_hash: 3719dd8f962e6b0051a95015aecb0e53 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-42aa43f3893eef31a351e066bf0cf8c56da8c857ccbb45eb7dd58739ad43bd86.yml +openapi_spec_hash: e6b8c1e707036539d88a7b79af864a49 config_hash: 1f73a949b649ecfe6ec68ba1bb459dc2 diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BetaCreatePlanVersionParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BetaCreatePlanVersionParams.kt index 45596201b..830ad2fde 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BetaCreatePlanVersionParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BetaCreatePlanVersionParams.kt @@ -31,12 +31,7 @@ import com.withorb.api.errors.OrbInvalidDataException import java.util.Collections import java.util.Objects -/** - * This API endpoint is in beta and its interface may change. It is recommended for use only in test - * mode. - * - * This endpoint allows the creation of a new plan version for an existing plan. - */ +/** This endpoint allows the creation of a new plan version for an existing plan. */ class BetaCreatePlanVersionParams private constructor( private val planId: String?, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BetaExternalPlanIdCreatePlanVersionParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BetaExternalPlanIdCreatePlanVersionParams.kt index e0f688def..384d8ce26 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BetaExternalPlanIdCreatePlanVersionParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BetaExternalPlanIdCreatePlanVersionParams.kt @@ -31,12 +31,7 @@ import com.withorb.api.errors.OrbInvalidDataException import java.util.Collections import java.util.Objects -/** - * This API endpoint is in beta and its interface may change. It is recommended for use only in test - * mode. - * - * This endpoint allows the creation of a new plan version for an existing plan. - */ +/** This endpoint allows the creation of a new plan version for an existing plan. */ class BetaExternalPlanIdCreatePlanVersionParams private constructor( private val externalPlanId: String?, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/BetaServiceAsync.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/BetaServiceAsync.kt index e922e4a07..81216af06 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/BetaServiceAsync.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/BetaServiceAsync.kt @@ -29,12 +29,7 @@ interface BetaServiceAsync { fun externalPlanId(): ExternalPlanIdServiceAsync - /** - * This API endpoint is in beta and its interface may change. It is recommended for use only in - * test mode. - * - * This endpoint allows the creation of a new plan version for an existing plan. - */ + /** This endpoint allows the creation of a new plan version for an existing plan. */ suspend fun createPlanVersion( planId: String, params: BetaCreatePlanVersionParams, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/beta/ExternalPlanIdServiceAsync.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/beta/ExternalPlanIdServiceAsync.kt index 5bee1ad76..cdac8d707 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/beta/ExternalPlanIdServiceAsync.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/beta/ExternalPlanIdServiceAsync.kt @@ -26,12 +26,7 @@ interface ExternalPlanIdServiceAsync { */ fun withOptions(modifier: (ClientOptions.Builder) -> Unit): ExternalPlanIdServiceAsync - /** - * This API endpoint is in beta and its interface may change. It is recommended for use only in - * test mode. - * - * This endpoint allows the creation of a new plan version for an existing plan. - */ + /** This endpoint allows the creation of a new plan version for an existing plan. */ suspend fun createPlanVersion( externalPlanId: String, params: BetaExternalPlanIdCreatePlanVersionParams, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/BetaService.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/BetaService.kt index f9dac8e7b..24d7a0440 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/BetaService.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/BetaService.kt @@ -29,12 +29,7 @@ interface BetaService { fun externalPlanId(): ExternalPlanIdService - /** - * This API endpoint is in beta and its interface may change. It is recommended for use only in - * test mode. - * - * This endpoint allows the creation of a new plan version for an existing plan. - */ + /** This endpoint allows the creation of a new plan version for an existing plan. */ fun createPlanVersion( planId: String, params: BetaCreatePlanVersionParams, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/beta/ExternalPlanIdService.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/beta/ExternalPlanIdService.kt index debd080e3..a2eb8639f 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/beta/ExternalPlanIdService.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/beta/ExternalPlanIdService.kt @@ -26,12 +26,7 @@ interface ExternalPlanIdService { */ fun withOptions(modifier: (ClientOptions.Builder) -> Unit): ExternalPlanIdService - /** - * This API endpoint is in beta and its interface may change. It is recommended for use only in - * test mode. - * - * This endpoint allows the creation of a new plan version for an existing plan. - */ + /** This endpoint allows the creation of a new plan version for an existing plan. */ fun createPlanVersion( externalPlanId: String, params: BetaExternalPlanIdCreatePlanVersionParams, From 537aba177c709243ce291115eb15e8c1fd0adfa4 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 23 Sep 2025 21:11:36 +0000 Subject: [PATCH 20/68] chore(internal): change some comment formatting --- .../models/ChangedSubscriptionResources.kt | 12 +++---- .../kotlin/com/withorb/api/models/Customer.kt | 12 +++---- .../CustomerCostListByExternalIdParams.kt | 8 +---- .../api/models/CustomerCostListParams.kt | 8 +---- .../api/models/CustomerCreateParams.kt | 30 ++++++++-------- ...editLedgerCreateEntryByExternalIdParams.kt | 4 --- .../CustomerCreditLedgerCreateEntryParams.kt | 4 --- ...tomerCreditLedgerListByExternalIdParams.kt | 13 ++----- .../models/CustomerCreditLedgerListParams.kt | 13 ++----- .../com/withorb/api/models/CustomerTaxId.kt | 6 ++-- .../CustomerUpdateByExternalIdParams.kt | 24 ++++++------- .../api/models/CustomerUpdateParams.kt | 24 ++++++------- .../api/models/EventDeprecateParams.kt | 12 +++---- .../withorb/api/models/EventIngestParams.kt | 10 +++--- .../withorb/api/models/EventUpdateParams.kt | 14 ++++---- .../kotlin/com/withorb/api/models/Invoice.kt | 12 +++---- .../models/InvoiceFetchUpcomingResponse.kt | 12 +++---- .../models/PlanExternalPlanIdFetchParams.kt | 1 - .../com/withorb/api/models/PlanFetchParams.kt | 2 -- .../api/models/SubscriptionCancelParams.kt | 1 - .../api/models/SubscriptionCreateParams.kt | 2 -- .../models/SubscriptionFetchUsageParams.kt | 6 ---- .../SubscriptionPriceIntervalsParams.kt | 1 - .../SubscriptionSchedulePlanChangeParams.kt | 3 -- .../services/async/CustomerServiceAsync.kt | 6 ++-- .../api/services/async/EventServiceAsync.kt | 36 +++++++++---------- .../api/services/async/PlanServiceAsync.kt | 2 -- .../async/SubscriptionServiceAsync.kt | 13 ------- .../async/customers/CostServiceAsync.kt | 16 ++------- .../customers/credits/LedgerServiceAsync.kt | 34 ++++-------------- .../async/plans/ExternalPlanIdServiceAsync.kt | 1 - .../api/services/blocking/CustomerService.kt | 6 ++-- .../api/services/blocking/EventService.kt | 36 +++++++++---------- .../api/services/blocking/PlanService.kt | 2 -- .../services/blocking/SubscriptionService.kt | 13 ------- .../blocking/customers/CostService.kt | 16 ++------- .../customers/credits/LedgerService.kt | 34 ++++-------------- .../blocking/plans/ExternalPlanIdService.kt | 1 - 38 files changed, 150 insertions(+), 300 deletions(-) diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/ChangedSubscriptionResources.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/ChangedSubscriptionResources.kt index 9eb31ad40..cd54e43dc 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/ChangedSubscriptionResources.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/ChangedSubscriptionResources.kt @@ -703,9 +703,9 @@ private constructor( * |Ireland |`eu_vat` |European VAT Number | * |Israel |`il_vat` |Israel VAT | * |Italy |`eu_vat` |European VAT Number | - * |Japan |`jp_cn` |Japanese Corporate Number (_Hōjin Bangō_) | - * |Japan |`jp_rn` |Japanese Registered Foreign Businesses' Registration Number (_Tōroku Kokugai Jigyōsha no Tōroku Bangō_)| - * |Japan |`jp_trn` |Japanese Tax Registration Number (_Tōroku Bangō_) | + * |Japan |`jp_cn` |Japanese Corporate Number (*Hōjin Bangō*) | + * |Japan |`jp_rn` |Japanese Registered Foreign Businesses' Registration Number (*Tōroku Kokugai Jigyōsha no Tōroku Bangō*)| + * |Japan |`jp_trn` |Japanese Tax Registration Number (*Tōroku Bangō*) | * |Kazakhstan |`kz_bin` |Kazakhstani Business Identification Number | * |Kenya |`ke_pin` |Kenya Revenue Authority Personal Identification Number | * |Kyrgyzstan |`kg_tin` |Kyrgyzstan Tax Identification Number | @@ -1791,9 +1791,9 @@ private constructor( * |Ireland |`eu_vat` |European VAT Number | * |Israel |`il_vat` |Israel VAT | * |Italy |`eu_vat` |European VAT Number | - * |Japan |`jp_cn` |Japanese Corporate Number (_Hōjin Bangō_) | - * |Japan |`jp_rn` |Japanese Registered Foreign Businesses' Registration Number (_Tōroku Kokugai Jigyōsha no Tōroku Bangō_)| - * |Japan |`jp_trn` |Japanese Tax Registration Number (_Tōroku Bangō_) | + * |Japan |`jp_cn` |Japanese Corporate Number (*Hōjin Bangō*) | + * |Japan |`jp_rn` |Japanese Registered Foreign Businesses' Registration Number (*Tōroku Kokugai Jigyōsha no Tōroku Bangō*)| + * |Japan |`jp_trn` |Japanese Tax Registration Number (*Tōroku Bangō*) | * |Kazakhstan |`kz_bin` |Kazakhstani Business Identification Number | * |Kenya |`ke_pin` |Kenya Revenue Authority Personal Identification Number | * |Kyrgyzstan |`kg_tin` |Kyrgyzstan Tax Identification Number | diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Customer.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Customer.kt index b353a5f48..4931eec10 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Customer.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Customer.kt @@ -360,9 +360,9 @@ private constructor( * |Ireland |`eu_vat` |European VAT Number | * |Israel |`il_vat` |Israel VAT | * |Italy |`eu_vat` |European VAT Number | - * |Japan |`jp_cn` |Japanese Corporate Number (_Hōjin Bangō_) | - * |Japan |`jp_rn` |Japanese Registered Foreign Businesses' Registration Number (_Tōroku Kokugai Jigyōsha no Tōroku Bangō_)| - * |Japan |`jp_trn` |Japanese Tax Registration Number (_Tōroku Bangō_) | + * |Japan |`jp_cn` |Japanese Corporate Number (*Hōjin Bangō*) | + * |Japan |`jp_rn` |Japanese Registered Foreign Businesses' Registration Number (*Tōroku Kokugai Jigyōsha no Tōroku Bangō*)| + * |Japan |`jp_trn` |Japanese Tax Registration Number (*Tōroku Bangō*) | * |Kazakhstan |`kz_bin` |Kazakhstani Business Identification Number | * |Kenya |`ke_pin` |Kenya Revenue Authority Personal Identification Number | * |Kyrgyzstan |`kg_tin` |Kyrgyzstan Tax Identification Number | @@ -1117,9 +1117,9 @@ private constructor( * |Ireland |`eu_vat` |European VAT Number | * |Israel |`il_vat` |Israel VAT | * |Italy |`eu_vat` |European VAT Number | - * |Japan |`jp_cn` |Japanese Corporate Number (_Hōjin Bangō_) | - * |Japan |`jp_rn` |Japanese Registered Foreign Businesses' Registration Number (_Tōroku Kokugai Jigyōsha no Tōroku Bangō_)| - * |Japan |`jp_trn` |Japanese Tax Registration Number (_Tōroku Bangō_) | + * |Japan |`jp_cn` |Japanese Corporate Number (*Hōjin Bangō*) | + * |Japan |`jp_rn` |Japanese Registered Foreign Businesses' Registration Number (*Tōroku Kokugai Jigyōsha no Tōroku Bangō*)| + * |Japan |`jp_trn` |Japanese Tax Registration Number (*Tōroku Bangō*) | * |Kazakhstan |`kz_bin` |Kazakhstani Business Identification Number | * |Kenya |`ke_pin` |Kenya Revenue Authority Personal Identification Number | * |Kyrgyzstan |`kg_tin` |Kyrgyzstan Tax Identification Number | diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCostListByExternalIdParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCostListByExternalIdParams.kt index 38fa906b9..e99215b2f 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCostListByExternalIdParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCostListByExternalIdParams.kt @@ -33,7 +33,6 @@ import java.util.Objects * committed spend. * * ## Fetching subscriptions - * * By default, this endpoint fetches the currently active subscription for the customer, and returns * cost information for the subscription's current billing period, broken down by each participating * price. If there are no currently active subscriptions, this will instead default to the most @@ -46,17 +45,15 @@ import java.util.Objects * and prices for both subscriptions will be included in the breakdown. * * ## Prepaid plans - * * For plans that include prices which deduct credits rather than accrue in-arrears charges in a * billable currency, this endpoint will return the total deduction amount, in credits, for the * specified timeframe. * * ## Cumulative subtotals and totals - * * Since the subtotal and total must factor in any billing-period level discounts and minimums, it's * most meaningful to consider costs relative to the start of the subscription's billing period. As * a result, by default this endpoint returns cumulative totals since the beginning of the billing - * period. In particular, the `timeframe_start` of a returned timeframe window is _always_ the + * period. In particular, the `timeframe_start` of a returned timeframe window is *always* the * beginning of the billing period and `timeframe_end` is incremented one day at a time to build the * result. * @@ -74,7 +71,6 @@ import java.util.Objects * | 2023-02-01 | 2023-02-06 | 36 | \$90.00 | \$90.00 | * * ### Periodic values - * * When the query parameter `view_mode=periodic` is specified, Orb will return an incremental * day-by-day view of costs. In this case, there will always be a one-day difference between * `timeframe_start` and `timeframe_end` for the timeframes returned. This is a transform on top of @@ -84,7 +80,6 @@ import java.util.Objects * cost. * * ## Timeframe bounds - * * For an active subscription, both timeframes should be specified in the request. If a subscription * starts or ends within the timeframe, the response will only include windows where the * subscription is active. If a subscription has ended, no timeframe bounds need to be specified and @@ -115,7 +110,6 @@ import java.util.Objects * You can see this sliced timeframe visualized [here](https://i.imgur.com/TXhYgme.png). * * ### Matrix prices - * * When a price uses matrix pricing, it's important to view costs grouped by those matrix * dimensions. Orb will return `price_groups` with the `grouping_key` and `secondary_grouping_key` * based on the matrix price definition, for each `grouping_value` and `secondary_grouping_value` diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCostListParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCostListParams.kt index 33b8c0034..78abea34f 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCostListParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCostListParams.kt @@ -33,7 +33,6 @@ import java.util.Objects * committed spend. * * ## Fetching subscriptions - * * By default, this endpoint fetches the currently active subscription for the customer, and returns * cost information for the subscription's current billing period, broken down by each participating * price. If there are no currently active subscriptions, this will instead default to the most @@ -46,17 +45,15 @@ import java.util.Objects * and prices for both subscriptions will be included in the breakdown. * * ## Prepaid plans - * * For plans that include prices which deduct credits rather than accrue in-arrears charges in a * billable currency, this endpoint will return the total deduction amount, in credits, for the * specified timeframe. * * ## Cumulative subtotals and totals - * * Since the subtotal and total must factor in any billing-period level discounts and minimums, it's * most meaningful to consider costs relative to the start of the subscription's billing period. As * a result, by default this endpoint returns cumulative totals since the beginning of the billing - * period. In particular, the `timeframe_start` of a returned timeframe window is _always_ the + * period. In particular, the `timeframe_start` of a returned timeframe window is *always* the * beginning of the billing period and `timeframe_end` is incremented one day at a time to build the * result. * @@ -74,7 +71,6 @@ import java.util.Objects * | 2023-02-01 | 2023-02-06 | 36 | \$90.00 | \$90.00 | * * ### Periodic values - * * When the query parameter `view_mode=periodic` is specified, Orb will return an incremental * day-by-day view of costs. In this case, there will always be a one-day difference between * `timeframe_start` and `timeframe_end` for the timeframes returned. This is a transform on top of @@ -84,7 +80,6 @@ import java.util.Objects * cost. * * ## Timeframe bounds - * * For an active subscription, both timeframes should be specified in the request. If a subscription * starts or ends within the timeframe, the response will only include windows where the * subscription is active. If a subscription has ended, no timeframe bounds need to be specified and @@ -115,7 +110,6 @@ import java.util.Objects * You can see this sliced timeframe visualized [here](https://i.imgur.com/TXhYgme.png). * * ### Matrix prices - * * When a price uses matrix pricing, it's important to view costs grouped by those matrix * dimensions. Orb will return `price_groups` with the `grouping_key` and `secondary_grouping_key` * based on the matrix price definition, for each `grouping_value` and `secondary_grouping_value` diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreateParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreateParams.kt index f393a59b8..230dcc18e 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreateParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreateParams.kt @@ -36,11 +36,11 @@ import java.util.Objects * See [Customer](/core-concepts##customer) for an overview of the customer resource. * * This endpoint is critical in the following Orb functionality: - * - Automated charges can be configured by setting `payment_provider` and `payment_provider_id` to + * * Automated charges can be configured by setting `payment_provider` and `payment_provider_id` to * automatically issue invoices - * - [Customer ID Aliases](/events-and-metrics/customer-aliases) can be configured by setting + * * [Customer ID Aliases](/events-and-metrics/customer-aliases) can be configured by setting * `external_customer_id` - * - [Timezone localization](/essentials/timezones) can be configured on a per-customer basis by + * * [Timezone localization](/essentials/timezones) can be configured on a per-customer basis by * setting the `timezone` parameter */ class CustomerCreateParams @@ -263,9 +263,9 @@ private constructor( * |Ireland |`eu_vat` |European VAT Number | * |Israel |`il_vat` |Israel VAT | * |Italy |`eu_vat` |European VAT Number | - * |Japan |`jp_cn` |Japanese Corporate Number (_Hōjin Bangō_) | - * |Japan |`jp_rn` |Japanese Registered Foreign Businesses' Registration Number (_Tōroku Kokugai Jigyōsha no Tōroku Bangō_)| - * |Japan |`jp_trn` |Japanese Tax Registration Number (_Tōroku Bangō_) | + * |Japan |`jp_cn` |Japanese Corporate Number (*Hōjin Bangō*) | + * |Japan |`jp_rn` |Japanese Registered Foreign Businesses' Registration Number (*Tōroku Kokugai Jigyōsha no Tōroku Bangō*)| + * |Japan |`jp_trn` |Japanese Tax Registration Number (*Tōroku Bangō*) | * |Kazakhstan |`kz_bin` |Kazakhstani Business Identification Number | * |Kenya |`ke_pin` |Kenya Revenue Authority Personal Identification Number | * |Kyrgyzstan |`kg_tin` |Kyrgyzstan Tax Identification Number | @@ -989,9 +989,9 @@ private constructor( * |Ireland |`eu_vat` |European VAT Number | * |Israel |`il_vat` |Israel VAT | * |Italy |`eu_vat` |European VAT Number | - * |Japan |`jp_cn` |Japanese Corporate Number (_Hōjin Bangō_) | - * |Japan |`jp_rn` |Japanese Registered Foreign Businesses' Registration Number (_Tōroku Kokugai Jigyōsha no Tōroku Bangō_)| - * |Japan |`jp_trn` |Japanese Tax Registration Number (_Tōroku Bangō_) | + * |Japan |`jp_cn` |Japanese Corporate Number (*Hōjin Bangō*) | + * |Japan |`jp_rn` |Japanese Registered Foreign Businesses' Registration Number (*Tōroku Kokugai Jigyōsha no Tōroku Bangō*)| + * |Japan |`jp_trn` |Japanese Tax Registration Number (*Tōroku Bangō*) | * |Kazakhstan |`kz_bin` |Kazakhstani Business Identification Number | * |Kenya |`ke_pin` |Kenya Revenue Authority Personal Identification Number | * |Kyrgyzstan |`kg_tin` |Kyrgyzstan Tax Identification Number | @@ -1547,9 +1547,9 @@ private constructor( * |Ireland |`eu_vat` |European VAT Number | * |Israel |`il_vat` |Israel VAT | * |Italy |`eu_vat` |European VAT Number | - * |Japan |`jp_cn` |Japanese Corporate Number (_Hōjin Bangō_) | - * |Japan |`jp_rn` |Japanese Registered Foreign Businesses' Registration Number (_Tōroku Kokugai Jigyōsha no Tōroku Bangō_)| - * |Japan |`jp_trn` |Japanese Tax Registration Number (_Tōroku Bangō_) | + * |Japan |`jp_cn` |Japanese Corporate Number (*Hōjin Bangō*) | + * |Japan |`jp_rn` |Japanese Registered Foreign Businesses' Registration Number (*Tōroku Kokugai Jigyōsha no Tōroku Bangō*)| + * |Japan |`jp_trn` |Japanese Tax Registration Number (*Tōroku Bangō*) | * |Kazakhstan |`kz_bin` |Kazakhstani Business Identification Number | * |Kenya |`ke_pin` |Kenya Revenue Authority Personal Identification Number | * |Kyrgyzstan |`kg_tin` |Kyrgyzstan Tax Identification Number | @@ -2337,9 +2337,9 @@ private constructor( * |Ireland |`eu_vat` |European VAT Number | * |Israel |`il_vat` |Israel VAT | * |Italy |`eu_vat` |European VAT Number | - * |Japan |`jp_cn` |Japanese Corporate Number (_Hōjin Bangō_) | - * |Japan |`jp_rn` |Japanese Registered Foreign Businesses' Registration Number (_Tōroku Kokugai Jigyōsha no Tōroku Bangō_)| - * |Japan |`jp_trn` |Japanese Tax Registration Number (_Tōroku Bangō_) | + * |Japan |`jp_cn` |Japanese Corporate Number (*Hōjin Bangō*) | + * |Japan |`jp_rn` |Japanese Registered Foreign Businesses' Registration Number (*Tōroku Kokugai Jigyōsha no Tōroku Bangō*)| + * |Japan |`jp_trn` |Japanese Tax Registration Number (*Tōroku Bangō*) | * |Kazakhstan |`kz_bin` |Kazakhstani Business Identification Number | * |Kenya |`ke_pin` |Kenya Revenue Authority Personal Identification Number | * |Kyrgyzstan |`kg_tin` |Kyrgyzstan Tax Identification Number | diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdParams.kt index 12dc1f1c6..dc0e65a74 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdParams.kt @@ -48,7 +48,6 @@ import java.util.Objects * credits (based on `amount` and `per_unit_cost_basis`). * * ## Adding credits - * * Adding credits is done by creating an entry of type `increment`. This requires the caller to * specify a number of credits as well as an optional expiry date in `YYYY-MM-DD` format. Orb also * recommends specifying a description to assist with auditing. When adding credits, the caller can @@ -72,7 +71,6 @@ import java.util.Objects * before adding the remaining amount to the desired credit block. * * ### Invoicing for credits - * * By default, Orb manipulates the credit ledger but does not charge for credits. However, if you * pass `invoice_settings` in the body of this request, Orb will also generate a one-off invoice for * the customer for the credits pre-purchase. Note that you _must_ provide the @@ -80,7 +78,6 @@ import java.util.Objects * cost basis with the number of credit units added. * * ## Deducting Credits - * * Orb allows you to deduct credits from a customer by creating an entry of type `decrement`. Orb * matches the algorithm for automatic deductions for determining which credit blocks to decrement * from. In the case that the deduction leads to multiple ledger entries, the response from this @@ -98,7 +95,6 @@ import java.util.Objects * ``` * * ## Changing credits expiry - * * If you'd like to change when existing credits expire, you should create a ledger entry of type * `expiration_change`. For this entry, the required parameter `expiry_date` identifies the * _originating_ block, and the required parameter `target_expiry_date` identifies when the diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryParams.kt index c3cfe9bef..5e8c49996 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryParams.kt @@ -48,7 +48,6 @@ import java.util.Objects * credits (based on `amount` and `per_unit_cost_basis`). * * ## Adding credits - * * Adding credits is done by creating an entry of type `increment`. This requires the caller to * specify a number of credits as well as an optional expiry date in `YYYY-MM-DD` format. Orb also * recommends specifying a description to assist with auditing. When adding credits, the caller can @@ -72,7 +71,6 @@ import java.util.Objects * before adding the remaining amount to the desired credit block. * * ### Invoicing for credits - * * By default, Orb manipulates the credit ledger but does not charge for credits. However, if you * pass `invoice_settings` in the body of this request, Orb will also generate a one-off invoice for * the customer for the credits pre-purchase. Note that you _must_ provide the @@ -80,7 +78,6 @@ import java.util.Objects * cost basis with the number of credit units added. * * ## Deducting Credits - * * Orb allows you to deduct credits from a customer by creating an entry of type `decrement`. Orb * matches the algorithm for automatic deductions for determining which credit blocks to decrement * from. In the case that the deduction leads to multiple ledger entries, the response from this @@ -98,7 +95,6 @@ import java.util.Objects * ``` * * ## Changing credits expiry - * * If you'd like to change when existing credits expire, you should create a ledger entry of type * `expiration_change`. For this entry, the required parameter `expiry_date` identifies the * _originating_ block, and the required parameter `target_expiry_date` identifies when the diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdParams.kt index 8fffec10b..cde28d925 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdParams.kt @@ -24,14 +24,12 @@ import java.util.Objects * There are four major types of modifications to credit balance, detailed below. * * ## Increment - * * Credits (which optionally expire on a future date) can be added via the API ([Add Ledger * Entry](create-ledger-entry)). The ledger entry for such an action will always contain the total * eligible starting and ending balance for the customer at the time the entry was added to the * ledger. * * ## Decrement - * * Deductions can occur as a result of an API call to create a ledger entry (see * [Add Ledger Entry](create-ledger-entry)), or automatically as a result of incurring usage. Both * ledger entries present the `decrement` entry type. @@ -43,13 +41,13 @@ import java.util.Objects * ingestion, used to pinpoint _why_ credit deduction took place and to ensure that credits are * never deducted without an associated usage event. * - * By default, Orb uses an algorithm that automatically deducts from the _soonest expiring credit - * block_ first in order to ensure that all credits are utilized appropriately. As an example, if + * By default, Orb uses an algorithm that automatically deducts from the *soonest expiring credit + * block* first in order to ensure that all credits are utilized appropriately. As an example, if * trial credits with an expiration date of 2 weeks from now are present for a customer, they will * be used before any deductions take place from a non-expiring credit block. * * If there are multiple blocks with the same expiration date, Orb will deduct from the block with - * the _lower cost basis_ first (e.g. trial credits with a \$0 cost basis before paid credits with a + * the *lower cost basis* first (e.g. trial credits with a \$0 cost basis before paid credits with a * \$5.00 cost basis). * * It's also possible for a single usage event's deduction to _span_ credit blocks. In this case, @@ -59,7 +57,6 @@ import java.util.Objects * a result of a decrement. * * ## Expiration change - * * The expiry of credits can be changed as a result of the API (See * [Add Ledger Entry](create-ledger-entry)). This will create a ledger entry that specifies the * balance as well as the initial and target expiry dates. @@ -69,24 +66,20 @@ import java.util.Objects * credit block from which there was an expiration change. * * ## Credits expiry - * * When a set of credits expire on pre-set expiration date, the customer's balance automatically * reflects this change and adds an entry to the ledger indicating this event. Note that credit * expiry should always happen close to a date boundary in the customer's timezone. * * ## Void initiated - * * Credit blocks can be voided via the API. The `amount` on this entry corresponds to the number of * credits that were remaining in the block at time of void. `void_reason` will be populated if the * void is created with a reason. * * ## Void - * * When a set of credits is voided, the customer's balance automatically reflects this change and * adds an entry to the ledger indicating this event. * * ## Amendment - * * When credits are added to a customer's balance as a result of a correction, this entry will be * added to the ledger to indicate the adjustment of credits. */ diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListParams.kt index e976557b7..fdb2c0b13 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListParams.kt @@ -24,14 +24,12 @@ import java.util.Objects * There are four major types of modifications to credit balance, detailed below. * * ## Increment - * * Credits (which optionally expire on a future date) can be added via the API ([Add Ledger * Entry](create-ledger-entry)). The ledger entry for such an action will always contain the total * eligible starting and ending balance for the customer at the time the entry was added to the * ledger. * * ## Decrement - * * Deductions can occur as a result of an API call to create a ledger entry (see * [Add Ledger Entry](create-ledger-entry)), or automatically as a result of incurring usage. Both * ledger entries present the `decrement` entry type. @@ -43,13 +41,13 @@ import java.util.Objects * ingestion, used to pinpoint _why_ credit deduction took place and to ensure that credits are * never deducted without an associated usage event. * - * By default, Orb uses an algorithm that automatically deducts from the _soonest expiring credit - * block_ first in order to ensure that all credits are utilized appropriately. As an example, if + * By default, Orb uses an algorithm that automatically deducts from the *soonest expiring credit + * block* first in order to ensure that all credits are utilized appropriately. As an example, if * trial credits with an expiration date of 2 weeks from now are present for a customer, they will * be used before any deductions take place from a non-expiring credit block. * * If there are multiple blocks with the same expiration date, Orb will deduct from the block with - * the _lower cost basis_ first (e.g. trial credits with a \$0 cost basis before paid credits with a + * the *lower cost basis* first (e.g. trial credits with a \$0 cost basis before paid credits with a * \$5.00 cost basis). * * It's also possible for a single usage event's deduction to _span_ credit blocks. In this case, @@ -59,7 +57,6 @@ import java.util.Objects * a result of a decrement. * * ## Expiration change - * * The expiry of credits can be changed as a result of the API (See * [Add Ledger Entry](create-ledger-entry)). This will create a ledger entry that specifies the * balance as well as the initial and target expiry dates. @@ -69,24 +66,20 @@ import java.util.Objects * credit block from which there was an expiration change. * * ## Credits expiry - * * When a set of credits expire on pre-set expiration date, the customer's balance automatically * reflects this change and adds an entry to the ledger indicating this event. Note that credit * expiry should always happen close to a date boundary in the customer's timezone. * * ## Void initiated - * * Credit blocks can be voided via the API. The `amount` on this entry corresponds to the number of * credits that were remaining in the block at time of void. `void_reason` will be populated if the * void is created with a reason. * * ## Void - * * When a set of credits is voided, the customer's balance automatically reflects this change and * adds an entry to the ledger indicating this event. * * ## Amendment - * * When credits are added to a customer's balance as a result of a correction, this entry will be * added to the ledger to indicate the adjustment of credits. */ diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerTaxId.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerTaxId.kt index e1e66410d..90c7b56d3 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerTaxId.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerTaxId.kt @@ -89,9 +89,9 @@ import java.util.Objects * |Ireland |`eu_vat` |European VAT Number | * |Israel |`il_vat` |Israel VAT | * |Italy |`eu_vat` |European VAT Number | - * |Japan |`jp_cn` |Japanese Corporate Number (_Hōjin Bangō_) | - * |Japan |`jp_rn` |Japanese Registered Foreign Businesses' Registration Number (_Tōroku Kokugai Jigyōsha no Tōroku Bangō_)| - * |Japan |`jp_trn` |Japanese Tax Registration Number (_Tōroku Bangō_) | + * |Japan |`jp_cn` |Japanese Corporate Number (*Hōjin Bangō*) | + * |Japan |`jp_rn` |Japanese Registered Foreign Businesses' Registration Number (*Tōroku Kokugai Jigyōsha no Tōroku Bangō*)| + * |Japan |`jp_trn` |Japanese Tax Registration Number (*Tōroku Bangō*) | * |Kazakhstan |`kz_bin` |Kazakhstani Business Identification Number | * |Kenya |`ke_pin` |Kenya Revenue Authority Personal Identification Number | * |Kyrgyzstan |`kg_tin` |Kyrgyzstan Tax Identification Number | diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerUpdateByExternalIdParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerUpdateByExternalIdParams.kt index cc7e088f4..e3c5bdfe9 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerUpdateByExternalIdParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerUpdateByExternalIdParams.kt @@ -262,9 +262,9 @@ private constructor( * |Ireland |`eu_vat` |European VAT Number | * |Israel |`il_vat` |Israel VAT | * |Italy |`eu_vat` |European VAT Number | - * |Japan |`jp_cn` |Japanese Corporate Number (_Hōjin Bangō_) | - * |Japan |`jp_rn` |Japanese Registered Foreign Businesses' Registration Number (_Tōroku Kokugai Jigyōsha no Tōroku Bangō_)| - * |Japan |`jp_trn` |Japanese Tax Registration Number (_Tōroku Bangō_) | + * |Japan |`jp_cn` |Japanese Corporate Number (*Hōjin Bangō*) | + * |Japan |`jp_rn` |Japanese Registered Foreign Businesses' Registration Number (*Tōroku Kokugai Jigyōsha no Tōroku Bangō*)| + * |Japan |`jp_trn` |Japanese Tax Registration Number (*Tōroku Bangō*) | * |Kazakhstan |`kz_bin` |Kazakhstani Business Identification Number | * |Kenya |`ke_pin` |Kenya Revenue Authority Personal Identification Number | * |Kyrgyzstan |`kg_tin` |Kyrgyzstan Tax Identification Number | @@ -975,9 +975,9 @@ private constructor( * |Ireland |`eu_vat` |European VAT Number | * |Israel |`il_vat` |Israel VAT | * |Italy |`eu_vat` |European VAT Number | - * |Japan |`jp_cn` |Japanese Corporate Number (_Hōjin Bangō_) | - * |Japan |`jp_rn` |Japanese Registered Foreign Businesses' Registration Number (_Tōroku Kokugai Jigyōsha no Tōroku Bangō_)| - * |Japan |`jp_trn` |Japanese Tax Registration Number (_Tōroku Bangō_) | + * |Japan |`jp_cn` |Japanese Corporate Number (*Hōjin Bangō*) | + * |Japan |`jp_rn` |Japanese Registered Foreign Businesses' Registration Number (*Tōroku Kokugai Jigyōsha no Tōroku Bangō*)| + * |Japan |`jp_trn` |Japanese Tax Registration Number (*Tōroku Bangō*) | * |Kazakhstan |`kz_bin` |Kazakhstani Business Identification Number | * |Kenya |`ke_pin` |Kenya Revenue Authority Personal Identification Number | * |Kyrgyzstan |`kg_tin` |Kyrgyzstan Tax Identification Number | @@ -1517,9 +1517,9 @@ private constructor( * |Ireland |`eu_vat` |European VAT Number | * |Israel |`il_vat` |Israel VAT | * |Italy |`eu_vat` |European VAT Number | - * |Japan |`jp_cn` |Japanese Corporate Number (_Hōjin Bangō_) | - * |Japan |`jp_rn` |Japanese Registered Foreign Businesses' Registration Number (_Tōroku Kokugai Jigyōsha no Tōroku Bangō_)| - * |Japan |`jp_trn` |Japanese Tax Registration Number (_Tōroku Bangō_) | + * |Japan |`jp_cn` |Japanese Corporate Number (*Hōjin Bangō*) | + * |Japan |`jp_rn` |Japanese Registered Foreign Businesses' Registration Number (*Tōroku Kokugai Jigyōsha no Tōroku Bangō*)| + * |Japan |`jp_trn` |Japanese Tax Registration Number (*Tōroku Bangō*) | * |Kazakhstan |`kz_bin` |Kazakhstani Business Identification Number | * |Kenya |`ke_pin` |Kenya Revenue Authority Personal Identification Number | * |Kyrgyzstan |`kg_tin` |Kyrgyzstan Tax Identification Number | @@ -2281,9 +2281,9 @@ private constructor( * |Ireland |`eu_vat` |European VAT Number | * |Israel |`il_vat` |Israel VAT | * |Italy |`eu_vat` |European VAT Number | - * |Japan |`jp_cn` |Japanese Corporate Number (_Hōjin Bangō_) | - * |Japan |`jp_rn` |Japanese Registered Foreign Businesses' Registration Number (_Tōroku Kokugai Jigyōsha no Tōroku Bangō_)| - * |Japan |`jp_trn` |Japanese Tax Registration Number (_Tōroku Bangō_) | + * |Japan |`jp_cn` |Japanese Corporate Number (*Hōjin Bangō*) | + * |Japan |`jp_rn` |Japanese Registered Foreign Businesses' Registration Number (*Tōroku Kokugai Jigyōsha no Tōroku Bangō*)| + * |Japan |`jp_trn` |Japanese Tax Registration Number (*Tōroku Bangō*) | * |Kazakhstan |`kz_bin` |Kazakhstani Business Identification Number | * |Kenya |`ke_pin` |Kenya Revenue Authority Personal Identification Number | * |Kyrgyzstan |`kg_tin` |Kyrgyzstan Tax Identification Number | diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerUpdateParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerUpdateParams.kt index df1deeba5..2ef76c208 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerUpdateParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerUpdateParams.kt @@ -263,9 +263,9 @@ private constructor( * |Ireland |`eu_vat` |European VAT Number | * |Israel |`il_vat` |Israel VAT | * |Italy |`eu_vat` |European VAT Number | - * |Japan |`jp_cn` |Japanese Corporate Number (_Hōjin Bangō_) | - * |Japan |`jp_rn` |Japanese Registered Foreign Businesses' Registration Number (_Tōroku Kokugai Jigyōsha no Tōroku Bangō_)| - * |Japan |`jp_trn` |Japanese Tax Registration Number (_Tōroku Bangō_) | + * |Japan |`jp_cn` |Japanese Corporate Number (*Hōjin Bangō*) | + * |Japan |`jp_rn` |Japanese Registered Foreign Businesses' Registration Number (*Tōroku Kokugai Jigyōsha no Tōroku Bangō*)| + * |Japan |`jp_trn` |Japanese Tax Registration Number (*Tōroku Bangō*) | * |Kazakhstan |`kz_bin` |Kazakhstani Business Identification Number | * |Kenya |`ke_pin` |Kenya Revenue Authority Personal Identification Number | * |Kyrgyzstan |`kg_tin` |Kyrgyzstan Tax Identification Number | @@ -971,9 +971,9 @@ private constructor( * |Ireland |`eu_vat` |European VAT Number | * |Israel |`il_vat` |Israel VAT | * |Italy |`eu_vat` |European VAT Number | - * |Japan |`jp_cn` |Japanese Corporate Number (_Hōjin Bangō_) | - * |Japan |`jp_rn` |Japanese Registered Foreign Businesses' Registration Number (_Tōroku Kokugai Jigyōsha no Tōroku Bangō_)| - * |Japan |`jp_trn` |Japanese Tax Registration Number (_Tōroku Bangō_) | + * |Japan |`jp_cn` |Japanese Corporate Number (*Hōjin Bangō*) | + * |Japan |`jp_rn` |Japanese Registered Foreign Businesses' Registration Number (*Tōroku Kokugai Jigyōsha no Tōroku Bangō*)| + * |Japan |`jp_trn` |Japanese Tax Registration Number (*Tōroku Bangō*) | * |Kazakhstan |`kz_bin` |Kazakhstani Business Identification Number | * |Kenya |`ke_pin` |Kenya Revenue Authority Personal Identification Number | * |Kyrgyzstan |`kg_tin` |Kyrgyzstan Tax Identification Number | @@ -1513,9 +1513,9 @@ private constructor( * |Ireland |`eu_vat` |European VAT Number | * |Israel |`il_vat` |Israel VAT | * |Italy |`eu_vat` |European VAT Number | - * |Japan |`jp_cn` |Japanese Corporate Number (_Hōjin Bangō_) | - * |Japan |`jp_rn` |Japanese Registered Foreign Businesses' Registration Number (_Tōroku Kokugai Jigyōsha no Tōroku Bangō_)| - * |Japan |`jp_trn` |Japanese Tax Registration Number (_Tōroku Bangō_) | + * |Japan |`jp_cn` |Japanese Corporate Number (*Hōjin Bangō*) | + * |Japan |`jp_rn` |Japanese Registered Foreign Businesses' Registration Number (*Tōroku Kokugai Jigyōsha no Tōroku Bangō*)| + * |Japan |`jp_trn` |Japanese Tax Registration Number (*Tōroku Bangō*) | * |Kazakhstan |`kz_bin` |Kazakhstani Business Identification Number | * |Kenya |`ke_pin` |Kenya Revenue Authority Personal Identification Number | * |Kyrgyzstan |`kg_tin` |Kyrgyzstan Tax Identification Number | @@ -2277,9 +2277,9 @@ private constructor( * |Ireland |`eu_vat` |European VAT Number | * |Israel |`il_vat` |Israel VAT | * |Italy |`eu_vat` |European VAT Number | - * |Japan |`jp_cn` |Japanese Corporate Number (_Hōjin Bangō_) | - * |Japan |`jp_rn` |Japanese Registered Foreign Businesses' Registration Number (_Tōroku Kokugai Jigyōsha no Tōroku Bangō_)| - * |Japan |`jp_trn` |Japanese Tax Registration Number (_Tōroku Bangō_) | + * |Japan |`jp_cn` |Japanese Corporate Number (*Hōjin Bangō*) | + * |Japan |`jp_rn` |Japanese Registered Foreign Businesses' Registration Number (*Tōroku Kokugai Jigyōsha no Tōroku Bangō*)| + * |Japan |`jp_trn` |Japanese Tax Registration Number (*Tōroku Bangō*) | * |Kazakhstan |`kz_bin` |Kazakhstani Business Identification Number | * |Kenya |`ke_pin` |Kenya Revenue Authority Personal Identification Number | * |Kyrgyzstan |`kg_tin` |Kyrgyzstan Tax Identification Number | diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventDeprecateParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventDeprecateParams.kt index 64487a783..fe99bc1a8 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventDeprecateParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventDeprecateParams.kt @@ -18,8 +18,8 @@ import java.util.Objects * * This is a powerful and audit-safe mechanism to retroactively deprecate a single event in cases * where you need to: - * - no longer bill for an event that was improperly reported - * - no longer bill for an event based on the result of an external API call (e.g. call to a payment + * * no longer bill for an event that was improperly reported + * * no longer bill for an event based on the result of an external API call (e.g. call to a payment * gateway failed and the user should not be billed) * * If you want to only change specific properties of an event, but keep the event as part of the @@ -30,16 +30,16 @@ import java.util.Objects * overwrites or permanently deletes ingested usage data. * * ## Request validation - * - Orb does not accept an `idempotency_key` with the event in this endpoint, since this request is + * * Orb does not accept an `idempotency_key` with the event in this endpoint, since this request is * by design idempotent. On retryable errors, you should retry the request and assume the * deprecation operation has not succeeded until receipt of a 2xx. - * - The event's `timestamp` must fall within the customer's current subscription's billing period, + * * The event's `timestamp` must fall within the customer's current subscription's billing period, * or within the grace period of the customer's current subscription's previous billing period. * Orb does not allow deprecating events for billing periods that have already invoiced customers. - * - The `customer_id` or the `external_customer_id` of the original event ingestion request must + * * The `customer_id` or the `external_customer_id` of the original event ingestion request must * identify a Customer resource within Orb, even if this event was ingested during the initial * integration period. We do not allow deprecating events for customers not in the Orb system. - * - By default, no more than 100 events can be deprecated for a single customer in a 100 day + * * By default, no more than 100 events can be deprecated for a single customer in a 100 day * period. For higher volume updates, consider using the [event backfill](create-backfill) * endpoint. */ diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventIngestParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventIngestParams.kt index 19f2c65d4..86c03be14 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventIngestParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventIngestParams.kt @@ -78,7 +78,6 @@ import java.util.Objects * ``` * * ## Required fields - * * Because events streamed to Orb are meant to be as flexible as possible, there are only a few * required fields in every event. * - We recommend that `idempotency_key` are unique strings that you generated with V4 UUIDs, but @@ -108,7 +107,6 @@ import java.util.Objects * numeric type in the event. * * ## Determining event timestamp - * * For cases where usage is being reported in real time as it is occurring, timestamp should * correspond to the time that usage occurred. * @@ -162,7 +160,6 @@ import java.util.Objects * should be retried in their entirety. * * ## API usage and limits - * * The ingestion API is designed made for real-time streaming ingestion and architected for high * throughput. Even if events are later deemed unnecessary or filtered out, we encourage you to log * them to Orb if they may be relevant to billing calculations in the future. @@ -176,7 +173,6 @@ import java.util.Objects * from initial setup. * * ## Testing in debug mode - * * The ingestion API supports a debug mode, which returns additional verbose output to indicate * which event idempotency keys were newly ingested or duplicates from previous requests. To enable * this mode, mark `debug=true` as a query parameter. @@ -195,7 +191,11 @@ import java.util.Objects * { * "debug": { * "duplicate": [], - * "ingested": ["B7E83HDMfJPAunXW", "SJs5DQJ3TnwSqEZE", "8SivfDsNKwCeAXim"] + * "ingested": [ + * "B7E83HDMfJPAunXW", + * "SJs5DQJ3TnwSqEZE", + * "8SivfDsNKwCeAXim" + * ] * }, * "validation_failed": [] * } diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventUpdateParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventUpdateParams.kt index 2cc0207d1..e0c763677 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventUpdateParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventUpdateParams.kt @@ -33,8 +33,8 @@ import java.util.Objects * * This is a powerful and audit-safe mechanism to retroactively update a single event in cases where * you need to: - * - update an event with new metadata as you iterate on your pricing model - * - update an event based on the result of an external API call (e.g. call to a payment gateway + * * update an event with new metadata as you iterate on your pricing model + * * update an event based on the result of an external API call (e.g. call to a payment gateway * succeeded or failed) * * This amendment API is always audit-safe. The process will still retain the original event, though @@ -42,21 +42,21 @@ import java.util.Objects * overwrites or permanently deletes ingested usage data. * * ## Request validation - * - The `timestamp` of the new event must match the `timestamp` of the existing event already + * * The `timestamp` of the new event must match the `timestamp` of the existing event already * ingested. As with ingestion, all timestamps must be sent in ISO8601 format with UTC timezone * offset. - * - The `customer_id` or `external_customer_id` of the new event must match the `customer_id` or + * * The `customer_id` or `external_customer_id` of the new event must match the `customer_id` or * `external_customer_id` of the existing event already ingested. Exactly one of `customer_id` and * `external_customer_id` should be specified, and similar to ingestion, the ID must identify a * Customer resource within Orb. Unlike ingestion, for event amendment, we strictly enforce that * the Customer must be in the Orb system, even during the initial integration period. We do not * allow updating the `Customer` an event is associated with. - * - Orb does not accept an `idempotency_key` with the event in this endpoint, since this request is + * * Orb does not accept an `idempotency_key` with the event in this endpoint, since this request is * by design idempotent. On retryable errors, you should retry the request and assume the * amendment operation has not succeeded until receipt of a 2xx. - * - The event's `timestamp` must fall within the customer's current subscription's billing period, + * * The event's `timestamp` must fall within the customer's current subscription's billing period, * or within the grace period of the customer's current subscription's previous billing period. - * - By default, no more than 100 events can be amended for a single customer in a 100 day period. + * * By default, no more than 100 events can be amended for a single customer in a 100 day period. * For higher volume updates, consider using the [event backfill](create-backfill) endpoint. */ class EventUpdateParams diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Invoice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Invoice.kt index ab948f2e0..16f7c0e71 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Invoice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Invoice.kt @@ -367,9 +367,9 @@ private constructor( * |Ireland |`eu_vat` |European VAT Number | * |Israel |`il_vat` |Israel VAT | * |Italy |`eu_vat` |European VAT Number | - * |Japan |`jp_cn` |Japanese Corporate Number (_Hōjin Bangō_) | - * |Japan |`jp_rn` |Japanese Registered Foreign Businesses' Registration Number (_Tōroku Kokugai Jigyōsha no Tōroku Bangō_)| - * |Japan |`jp_trn` |Japanese Tax Registration Number (_Tōroku Bangō_) | + * |Japan |`jp_cn` |Japanese Corporate Number (*Hōjin Bangō*) | + * |Japan |`jp_rn` |Japanese Registered Foreign Businesses' Registration Number (*Tōroku Kokugai Jigyōsha no Tōroku Bangō*)| + * |Japan |`jp_trn` |Japanese Tax Registration Number (*Tōroku Bangō*) | * |Kazakhstan |`kz_bin` |Kazakhstani Business Identification Number | * |Kenya |`ke_pin` |Kenya Revenue Authority Personal Identification Number | * |Kyrgyzstan |`kg_tin` |Kyrgyzstan Tax Identification Number | @@ -1401,9 +1401,9 @@ private constructor( * |Ireland |`eu_vat` |European VAT Number | * |Israel |`il_vat` |Israel VAT | * |Italy |`eu_vat` |European VAT Number | - * |Japan |`jp_cn` |Japanese Corporate Number (_Hōjin Bangō_) | - * |Japan |`jp_rn` |Japanese Registered Foreign Businesses' Registration Number (_Tōroku Kokugai Jigyōsha no Tōroku Bangō_)| - * |Japan |`jp_trn` |Japanese Tax Registration Number (_Tōroku Bangō_) | + * |Japan |`jp_cn` |Japanese Corporate Number (*Hōjin Bangō*) | + * |Japan |`jp_rn` |Japanese Registered Foreign Businesses' Registration Number (*Tōroku Kokugai Jigyōsha no Tōroku Bangō*)| + * |Japan |`jp_trn` |Japanese Tax Registration Number (*Tōroku Bangō*) | * |Kazakhstan |`kz_bin` |Kazakhstani Business Identification Number | * |Kenya |`ke_pin` |Kenya Revenue Authority Personal Identification Number | * |Kyrgyzstan |`kg_tin` |Kyrgyzstan Tax Identification Number | diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceFetchUpcomingResponse.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceFetchUpcomingResponse.kt index 2428d7bd6..896e8a236 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceFetchUpcomingResponse.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceFetchUpcomingResponse.kt @@ -360,9 +360,9 @@ private constructor( * |Ireland |`eu_vat` |European VAT Number | * |Israel |`il_vat` |Israel VAT | * |Italy |`eu_vat` |European VAT Number | - * |Japan |`jp_cn` |Japanese Corporate Number (_Hōjin Bangō_) | - * |Japan |`jp_rn` |Japanese Registered Foreign Businesses' Registration Number (_Tōroku Kokugai Jigyōsha no Tōroku Bangō_)| - * |Japan |`jp_trn` |Japanese Tax Registration Number (_Tōroku Bangō_) | + * |Japan |`jp_cn` |Japanese Corporate Number (*Hōjin Bangō*) | + * |Japan |`jp_rn` |Japanese Registered Foreign Businesses' Registration Number (*Tōroku Kokugai Jigyōsha no Tōroku Bangō*)| + * |Japan |`jp_trn` |Japanese Tax Registration Number (*Tōroku Bangō*) | * |Kazakhstan |`kz_bin` |Kazakhstani Business Identification Number | * |Kenya |`ke_pin` |Kenya Revenue Authority Personal Identification Number | * |Kyrgyzstan |`kg_tin` |Kyrgyzstan Tax Identification Number | @@ -1395,9 +1395,9 @@ private constructor( * |Ireland |`eu_vat` |European VAT Number | * |Israel |`il_vat` |Israel VAT | * |Italy |`eu_vat` |European VAT Number | - * |Japan |`jp_cn` |Japanese Corporate Number (_Hōjin Bangō_) | - * |Japan |`jp_rn` |Japanese Registered Foreign Businesses' Registration Number (_Tōroku Kokugai Jigyōsha no Tōroku Bangō_)| - * |Japan |`jp_trn` |Japanese Tax Registration Number (_Tōroku Bangō_) | + * |Japan |`jp_cn` |Japanese Corporate Number (*Hōjin Bangō*) | + * |Japan |`jp_rn` |Japanese Registered Foreign Businesses' Registration Number (*Tōroku Kokugai Jigyōsha no Tōroku Bangō*)| + * |Japan |`jp_trn` |Japanese Tax Registration Number (*Tōroku Bangō*) | * |Kazakhstan |`kz_bin` |Kazakhstani Business Identification Number | * |Kenya |`ke_pin` |Kenya Revenue Authority Personal Identification Number | * |Kyrgyzstan |`kg_tin` |Kyrgyzstan Tax Identification Number | diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanExternalPlanIdFetchParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanExternalPlanIdFetchParams.kt index 5c4ff453e..b2e385a59 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanExternalPlanIdFetchParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanExternalPlanIdFetchParams.kt @@ -17,7 +17,6 @@ import java.util.Objects * plan. * * ## Serialized prices - * * Orb supports a few different pricing models out of the box. Each of these models is serialized * differently in a given [Price](/core-concepts#plan-and-price) object. The `model_type` field * determines the key for the configuration object that is present. A detailed explanation of price diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanFetchParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanFetchParams.kt index 46ee62501..cb52dea1c 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanFetchParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanFetchParams.kt @@ -13,14 +13,12 @@ import java.util.Objects * as well as the product that the plan is attached to. * * ## Serialized prices - * * Orb supports a few different pricing models out of the box. Each of these models is serialized * differently in a given [Price](/core-concepts#plan-and-price) object. The `model_type` field * determines the key for the configuration object that is present. A detailed explanation of price * types can be found in the [Price schema](/core-concepts#plan-and-price). * * ## Phases - * * Orb supports plan phases, also known as contract ramps. For plans with phases, the serialized * prices refer to all prices across all phases. */ diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionCancelParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionCancelParams.kt index d03a14d6e..c32bfeaf5 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionCancelParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionCancelParams.kt @@ -63,7 +63,6 @@ import java.util.Objects * `end_date` equal to the `start_date` upon cancellation. * * ## Backdated cancellations - * * Orb allows you to cancel a subscription in the past as long as there are no paid invoices between * the `requested_date` and the current time. If the cancellation is after the latest issued * invoice, Orb will generate a balance refund for the current period. If the cancellation is before diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionCreateParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionCreateParams.kt index afe06561e..72c3a0357 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionCreateParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionCreateParams.kt @@ -168,7 +168,6 @@ import java.util.Objects * the billable metric, cadence, type, and name of a price can not be overridden. * * ### Maximums and Minimums - * * Minimums and maximums, much like price overrides, can be useful when a new customer has * negotiated a new or different minimum or maximum spend cap than the default for a given price. If * one exists for a price and null is provided for the minimum/maximum override on creation, then @@ -213,7 +212,6 @@ import java.util.Objects * ``` * * ### Discounts - * * Discounts, like price overrides, can be useful when a new customer has negotiated a new or * different discount than the default for a price. If a discount exists for a price and a null * discount is provided on creation, then there will be no discount on the new subscription. diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchUsageParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchUsageParams.kt index 5df20f4f7..93cbae60d 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchUsageParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchUsageParams.kt @@ -24,7 +24,6 @@ import java.util.Objects * customer's billing period. * * ### Default response shape - * * Orb returns a `data` array with an object corresponding to each billable metric. Nested within * this object is a `usage` array which has a `quantity` value and a corresponding `timeframe_start` * and `timeframe_end`. The `quantity` value represents the calculated usage value for the billable @@ -41,7 +40,6 @@ import java.util.Objects * with each other, e.g. to display grouped usage on a custom timeframe. * * ## Custom timeframe - * * In order to view usage for a custom timeframe rather than the current billing period, specify a * `timeframe_start` and `timeframe_end`. This will calculate quantities for usage incurred between * timeframe_start (inclusive) and timeframe_end (exclusive), i.e. `[timeframe_start, @@ -53,7 +51,6 @@ import java.util.Objects * - Both parameters must be specified if either is specified. * * ## Grouping by custom attributes - * * In order to view a single metric grouped by a specific _attribute_ that each event is tagged with * (e.g. `cluster`), you must additionally specify a `billable_metric_id` and a `group_by` key. The * `group_by` key denotes the event property on which to group. @@ -102,7 +99,6 @@ import java.util.Objects * ``` * * ## Windowed usage - * * The `granularity` parameter can be used to _window_ the usage `quantity` value into periods. When * not specified, usage is returned for the entirety of the time range. * @@ -157,7 +153,6 @@ import java.util.Objects * ``` * * ## Decomposable vs. non-decomposable metrics - * * Billable metrics fall into one of two categories: decomposable and non-decomposable. A * decomposable billable metric, such as a sum or a count, can be displayed and aggregated across * arbitrary timescales. On the other hand, a non-decomposable metric is not meaningful when only a @@ -176,7 +171,6 @@ import java.util.Objects * If no invoice grouping key is present, the metric does not support `group_by`. * * ## Matrix prices - * * When a billable metric is attached to a price that uses matrix pricing, it's important to view * usage grouped by those matrix dimensions. In this case, use the query parameters * `first_dimension_key`, `first_dimension_value` and `second_dimension_key`, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsParams.kt index e52e6c471..82652d6b3 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsParams.kt @@ -82,7 +82,6 @@ import java.util.Objects * interval entirely from a subscription, set the `end_date` to be equivalent to the `start_date`. * * ## Fixed fee quantity transitions - * * The fixed fee quantity transitions for a fixed fee price interval can also be specified when * adding or editing by passing an array for `fixed_fee_quantity_transitions`. A fixed fee quantity * transition must have a `quantity` and an `effective_date`, which is the date after which the new diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionSchedulePlanChangeParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionSchedulePlanChangeParams.kt index e1d112ccb..a58fce9a4 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionSchedulePlanChangeParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionSchedulePlanChangeParams.kt @@ -175,19 +175,16 @@ import java.util.Objects * the billable metric, cadence, type, and name of a price can not be overridden. * * ### Maximums, and minimums - * * Price overrides are used to update some or all prices in the target plan. Minimums and maximums, * much like price overrides, can be useful when a new customer has negotiated a new or different * minimum or maximum spend cap than the default for the plan. The request format for maximums and * minimums is the same as those in [subscription creation](create-subscription). * * ## Scheduling multiple plan changes - * * When scheduling multiple plan changes with the same date, the latest plan change on that day * takes effect. * * ## Prorations for in-advance fees - * * By default, Orb calculates the prorated difference in any fixed fees when making a plan change, * adjusting the customer balance as needed. For details on this behavior, see * [Modifying subscriptions](/product-catalog/modifying-subscriptions#prorations-for-in-advance-fees). diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/CustomerServiceAsync.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/CustomerServiceAsync.kt index 80627f858..fda804288 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/CustomerServiceAsync.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/CustomerServiceAsync.kt @@ -48,11 +48,11 @@ interface CustomerServiceAsync { * resource. * * This endpoint is critical in the following Orb functionality: - * - Automated charges can be configured by setting `payment_provider` and `payment_provider_id` + * * Automated charges can be configured by setting `payment_provider` and `payment_provider_id` * to automatically issue invoices - * - [Customer ID Aliases](/events-and-metrics/customer-aliases) can be configured by setting + * * [Customer ID Aliases](/events-and-metrics/customer-aliases) can be configured by setting * `external_customer_id` - * - [Timezone localization](/essentials/timezones) can be configured on a per-customer basis by + * * [Timezone localization](/essentials/timezones) can be configured on a per-customer basis by * setting the `timezone` parameter */ suspend fun create( diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/EventServiceAsync.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/EventServiceAsync.kt index 356bc960a..997d016de 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/EventServiceAsync.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/EventServiceAsync.kt @@ -48,8 +48,8 @@ interface EventServiceAsync { * * This is a powerful and audit-safe mechanism to retroactively update a single event in cases * where you need to: - * - update an event with new metadata as you iterate on your pricing model - * - update an event based on the result of an external API call (e.g. call to a payment gateway + * * update an event with new metadata as you iterate on your pricing model + * * update an event based on the result of an external API call (e.g. call to a payment gateway * succeeded or failed) * * This amendment API is always audit-safe. The process will still retain the original event, @@ -57,22 +57,22 @@ interface EventServiceAsync { * Orb never overwrites or permanently deletes ingested usage data. * * ## Request validation - * - The `timestamp` of the new event must match the `timestamp` of the existing event already + * * The `timestamp` of the new event must match the `timestamp` of the existing event already * ingested. As with ingestion, all timestamps must be sent in ISO8601 format with UTC * timezone offset. - * - The `customer_id` or `external_customer_id` of the new event must match the `customer_id` + * * The `customer_id` or `external_customer_id` of the new event must match the `customer_id` * or `external_customer_id` of the existing event already ingested. Exactly one of * `customer_id` and `external_customer_id` should be specified, and similar to ingestion, the * ID must identify a Customer resource within Orb. Unlike ingestion, for event amendment, we * strictly enforce that the Customer must be in the Orb system, even during the initial * integration period. We do not allow updating the `Customer` an event is associated with. - * - Orb does not accept an `idempotency_key` with the event in this endpoint, since this + * * Orb does not accept an `idempotency_key` with the event in this endpoint, since this * request is by design idempotent. On retryable errors, you should retry the request and * assume the amendment operation has not succeeded until receipt of a 2xx. - * - The event's `timestamp` must fall within the customer's current subscription's billing + * * The event's `timestamp` must fall within the customer's current subscription's billing * period, or within the grace period of the customer's current subscription's previous * billing period. - * - By default, no more than 100 events can be amended for a single customer in a 100 day + * * By default, no more than 100 events can be amended for a single customer in a 100 day * period. For higher volume updates, consider using the [event backfill](create-backfill) * endpoint. */ @@ -97,8 +97,8 @@ interface EventServiceAsync { * * This is a powerful and audit-safe mechanism to retroactively deprecate a single event in * cases where you need to: - * - no longer bill for an event that was improperly reported - * - no longer bill for an event based on the result of an external API call (e.g. call to a + * * no longer bill for an event that was improperly reported + * * no longer bill for an event based on the result of an external API call (e.g. call to a * payment gateway failed and the user should not be billed) * * If you want to only change specific properties of an event, but keep the event as part of the @@ -109,18 +109,18 @@ interface EventServiceAsync { * overwrites or permanently deletes ingested usage data. * * ## Request validation - * - Orb does not accept an `idempotency_key` with the event in this endpoint, since this + * * Orb does not accept an `idempotency_key` with the event in this endpoint, since this * request is by design idempotent. On retryable errors, you should retry the request and * assume the deprecation operation has not succeeded until receipt of a 2xx. - * - The event's `timestamp` must fall within the customer's current subscription's billing + * * The event's `timestamp` must fall within the customer's current subscription's billing * period, or within the grace period of the customer's current subscription's previous * billing period. Orb does not allow deprecating events for billing periods that have already * invoiced customers. - * - The `customer_id` or the `external_customer_id` of the original event ingestion request + * * The `customer_id` or the `external_customer_id` of the original event ingestion request * must identify a Customer resource within Orb, even if this event was ingested during the * initial integration period. We do not allow deprecating events for customers not in the Orb * system. - * - By default, no more than 100 events can be deprecated for a single customer in a 100 day + * * By default, no more than 100 events can be deprecated for a single customer in a 100 day * period. For higher volume updates, consider using the [event backfill](create-backfill) * endpoint. */ @@ -199,7 +199,6 @@ interface EventServiceAsync { * ``` * * ## Required fields - * * Because events streamed to Orb are meant to be as flexible as possible, there are only a few * required fields in every event. * - We recommend that `idempotency_key` are unique strings that you generated with V4 UUIDs, @@ -229,7 +228,6 @@ interface EventServiceAsync { * aggregate should be of numeric type in the event. * * ## Determining event timestamp - * * For cases where usage is being reported in real time as it is occurring, timestamp should * correspond to the time that usage occurred. * @@ -284,7 +282,6 @@ interface EventServiceAsync { * requests should be retried in their entirety. * * ## API usage and limits - * * The ingestion API is designed made for real-time streaming ingestion and architected for high * throughput. Even if events are later deemed unnecessary or filtered out, we encourage you to * log them to Orb if they may be relevant to billing calculations in the future. @@ -299,7 +296,6 @@ interface EventServiceAsync { * magnitude from initial setup. * * ## Testing in debug mode - * * The ingestion API supports a debug mode, which returns additional verbose output to indicate * which event idempotency keys were newly ingested or duplicates from previous requests. To * enable this mode, mark `debug=true` as a query parameter. @@ -318,7 +314,11 @@ interface EventServiceAsync { * { * "debug": { * "duplicate": [], - * "ingested": ["B7E83HDMfJPAunXW", "SJs5DQJ3TnwSqEZE", "8SivfDsNKwCeAXim"] + * "ingested": [ + * "B7E83HDMfJPAunXW", + * "SJs5DQJ3TnwSqEZE", + * "8SivfDsNKwCeAXim" + * ] * }, * "validation_failed": [] * } diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/PlanServiceAsync.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/PlanServiceAsync.kt index 080bff190..e0adc82db 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/PlanServiceAsync.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/PlanServiceAsync.kt @@ -79,7 +79,6 @@ interface PlanServiceAsync { * configuration, as well as the product that the plan is attached to. * * ## Serialized prices - * * Orb supports a few different pricing models out of the box. Each of these models is * serialized differently in a given [Price](/core-concepts#plan-and-price) object. The * `model_type` field determines the key for the configuration object that is present. A @@ -87,7 +86,6 @@ interface PlanServiceAsync { * [Price schema](/core-concepts#plan-and-price). * * ## Phases - * * Orb supports plan phases, also known as contract ramps. For plans with phases, the serialized * prices refer to all prices across all phases. */ diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/SubscriptionServiceAsync.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/SubscriptionServiceAsync.kt index 825529d4d..fa7b3672d 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/SubscriptionServiceAsync.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/SubscriptionServiceAsync.kt @@ -186,7 +186,6 @@ interface SubscriptionServiceAsync { * cadence, type, and name of a price can not be overridden. * * ### Maximums and Minimums - * * Minimums and maximums, much like price overrides, can be useful when a new customer has * negotiated a new or different minimum or maximum spend cap than the default for a given * price. If one exists for a price and null is provided for the minimum/maximum override on @@ -231,7 +230,6 @@ interface SubscriptionServiceAsync { * ``` * * ### Discounts - * * Discounts, like price overrides, can be useful when a new customer has negotiated a new or * different discount than the default for a price. If a discount exists for a price and a null * discount is provided on creation, then there will be no discount on the new subscription. @@ -376,7 +374,6 @@ interface SubscriptionServiceAsync { * `end_date` equal to the `start_date` upon cancellation. * * ## Backdated cancellations - * * Orb allows you to cancel a subscription in the past as long as there are no paid invoices * between the `requested_date` and the current time. If the cancellation is after the latest * issued invoice, Orb will generate a balance refund for the current period. If the @@ -485,7 +482,6 @@ interface SubscriptionServiceAsync { * of the customer's billing period. * * ### Default response shape - * * Orb returns a `data` array with an object corresponding to each billable metric. Nested * within this object is a `usage` array which has a `quantity` value and a corresponding * `timeframe_start` and `timeframe_end`. The `quantity` value represents the calculated usage @@ -502,7 +498,6 @@ interface SubscriptionServiceAsync { * conjunction_ with each other, e.g. to display grouped usage on a custom timeframe. * * ## Custom timeframe - * * In order to view usage for a custom timeframe rather than the current billing period, specify * a `timeframe_start` and `timeframe_end`. This will calculate quantities for usage incurred * between timeframe_start (inclusive) and timeframe_end (exclusive), i.e. `[timeframe_start, @@ -514,7 +509,6 @@ interface SubscriptionServiceAsync { * - Both parameters must be specified if either is specified. * * ## Grouping by custom attributes - * * In order to view a single metric grouped by a specific _attribute_ that each event is tagged * with (e.g. `cluster`), you must additionally specify a `billable_metric_id` and a `group_by` * key. The `group_by` key denotes the event property on which to group. @@ -564,7 +558,6 @@ interface SubscriptionServiceAsync { * ``` * * ## Windowed usage - * * The `granularity` parameter can be used to _window_ the usage `quantity` value into periods. * When not specified, usage is returned for the entirety of the time range. * @@ -619,7 +612,6 @@ interface SubscriptionServiceAsync { * ``` * * ## Decomposable vs. non-decomposable metrics - * * Billable metrics fall into one of two categories: decomposable and non-decomposable. A * decomposable billable metric, such as a sum or a count, can be displayed and aggregated * across arbitrary timescales. On the other hand, a non-decomposable metric is not meaningful @@ -638,7 +630,6 @@ interface SubscriptionServiceAsync { * key. If no invoice grouping key is present, the metric does not support `group_by`. * * ## Matrix prices - * * When a billable metric is attached to a price that uses matrix pricing, it's important to * view usage grouped by those matrix dimensions. In this case, use the query parameters * `first_dimension_key`, `first_dimension_value` and `second_dimension_key`, @@ -721,7 +712,6 @@ interface SubscriptionServiceAsync { * `start_date`. * * ## Fixed fee quantity transitions - * * The fixed fee quantity transitions for a fixed fee price interval can also be specified when * adding or editing by passing an array for `fixed_fee_quantity_transitions`. A fixed fee * quantity transition must have a `quantity` and an `effective_date`, which is the date after @@ -920,7 +910,6 @@ interface SubscriptionServiceAsync { * cadence, type, and name of a price can not be overridden. * * ### Maximums, and minimums - * * Price overrides are used to update some or all prices in the target plan. Minimums and * maximums, much like price overrides, can be useful when a new customer has negotiated a new * or different minimum or maximum spend cap than the default for the plan. The request format @@ -928,12 +917,10 @@ interface SubscriptionServiceAsync { * [subscription creation](create-subscription). * * ## Scheduling multiple plan changes - * * When scheduling multiple plan changes with the same date, the latest plan change on that day * takes effect. * * ## Prorations for in-advance fees - * * By default, Orb calculates the prorated difference in any fixed fees when making a plan * change, adjusting the customer balance as needed. For details on this behavior, see * [Modifying subscriptions](/product-catalog/modifying-subscriptions#prorations-for-in-advance-fees). diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/customers/CostServiceAsync.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/customers/CostServiceAsync.kt index 558767a4a..330f3190f 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/customers/CostServiceAsync.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/customers/CostServiceAsync.kt @@ -45,7 +45,6 @@ interface CostServiceAsync { * minimum committed spend. * * ## Fetching subscriptions - * * By default, this endpoint fetches the currently active subscription for the customer, and * returns cost information for the subscription's current billing period, broken down by each * participating price. If there are no currently active subscriptions, this will instead @@ -58,18 +57,16 @@ interface CostServiceAsync { * summed, and prices for both subscriptions will be included in the breakdown. * * ## Prepaid plans - * * For plans that include prices which deduct credits rather than accrue in-arrears charges in a * billable currency, this endpoint will return the total deduction amount, in credits, for the * specified timeframe. * * ## Cumulative subtotals and totals - * * Since the subtotal and total must factor in any billing-period level discounts and minimums, * it's most meaningful to consider costs relative to the start of the subscription's billing * period. As a result, by default this endpoint returns cumulative totals since the beginning * of the billing period. In particular, the `timeframe_start` of a returned timeframe window is - * _always_ the beginning of the billing period and `timeframe_end` is incremented one day at a + * *always* the beginning of the billing period and `timeframe_end` is incremented one day at a * time to build the result. * * A customer that uses a few API calls a day but has a minimum commitment might exhibit the @@ -87,7 +84,6 @@ interface CostServiceAsync { * | 2023-02-01 | 2023-02-06 | 36 | \$90.00 | \$90.00 | * * ### Periodic values - * * When the query parameter `view_mode=periodic` is specified, Orb will return an incremental * day-by-day view of costs. In this case, there will always be a one-day difference between * `timeframe_start` and `timeframe_end` for the timeframes returned. This is a transform on top @@ -97,7 +93,6 @@ interface CostServiceAsync { * to the total cost. * * ## Timeframe bounds - * * For an active subscription, both timeframes should be specified in the request. If a * subscription starts or ends within the timeframe, the response will only include windows * where the subscription is active. If a subscription has ended, no timeframe bounds need to be @@ -129,7 +124,6 @@ interface CostServiceAsync { * You can see this sliced timeframe visualized [here](https://i.imgur.com/TXhYgme.png). * * ### Matrix prices - * * When a price uses matrix pricing, it's important to view costs grouped by those matrix * dimensions. Orb will return `price_groups` with the `grouping_key` and * `secondary_grouping_key` based on the matrix price definition, for each `grouping_value` and @@ -172,7 +166,6 @@ interface CostServiceAsync { * minimum committed spend. * * ## Fetching subscriptions - * * By default, this endpoint fetches the currently active subscription for the customer, and * returns cost information for the subscription's current billing period, broken down by each * participating price. If there are no currently active subscriptions, this will instead @@ -185,18 +178,16 @@ interface CostServiceAsync { * summed, and prices for both subscriptions will be included in the breakdown. * * ## Prepaid plans - * * For plans that include prices which deduct credits rather than accrue in-arrears charges in a * billable currency, this endpoint will return the total deduction amount, in credits, for the * specified timeframe. * * ## Cumulative subtotals and totals - * * Since the subtotal and total must factor in any billing-period level discounts and minimums, * it's most meaningful to consider costs relative to the start of the subscription's billing * period. As a result, by default this endpoint returns cumulative totals since the beginning * of the billing period. In particular, the `timeframe_start` of a returned timeframe window is - * _always_ the beginning of the billing period and `timeframe_end` is incremented one day at a + * *always* the beginning of the billing period and `timeframe_end` is incremented one day at a * time to build the result. * * A customer that uses a few API calls a day but has a minimum commitment might exhibit the @@ -214,7 +205,6 @@ interface CostServiceAsync { * | 2023-02-01 | 2023-02-06 | 36 | \$90.00 | \$90.00 | * * ### Periodic values - * * When the query parameter `view_mode=periodic` is specified, Orb will return an incremental * day-by-day view of costs. In this case, there will always be a one-day difference between * `timeframe_start` and `timeframe_end` for the timeframes returned. This is a transform on top @@ -224,7 +214,6 @@ interface CostServiceAsync { * to the total cost. * * ## Timeframe bounds - * * For an active subscription, both timeframes should be specified in the request. If a * subscription starts or ends within the timeframe, the response will only include windows * where the subscription is active. If a subscription has ended, no timeframe bounds need to be @@ -256,7 +245,6 @@ interface CostServiceAsync { * You can see this sliced timeframe visualized [here](https://i.imgur.com/TXhYgme.png). * * ### Matrix prices - * * When a price uses matrix pricing, it's important to view costs grouped by those matrix * dimensions. Orb will return `price_groups` with the `grouping_key` and * `secondary_grouping_key` based on the matrix price definition, for each `grouping_value` and diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/customers/credits/LedgerServiceAsync.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/customers/credits/LedgerServiceAsync.kt index 32a819d9c..d54a5d0a3 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/customers/credits/LedgerServiceAsync.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/customers/credits/LedgerServiceAsync.kt @@ -41,14 +41,12 @@ interface LedgerServiceAsync { * There are four major types of modifications to credit balance, detailed below. * * ## Increment - * * Credits (which optionally expire on a future date) can be added via the API ([Add Ledger * Entry](create-ledger-entry)). The ledger entry for such an action will always contain the * total eligible starting and ending balance for the customer at the time the entry was added * to the ledger. * * ## Decrement - * * Deductions can occur as a result of an API call to create a ledger entry (see * [Add Ledger Entry](create-ledger-entry)), or automatically as a result of incurring usage. * Both ledger entries present the `decrement` entry type. @@ -60,14 +58,14 @@ interface LedgerServiceAsync { * the `event_id` at the time of ingestion, used to pinpoint _why_ credit deduction took place * and to ensure that credits are never deducted without an associated usage event. * - * By default, Orb uses an algorithm that automatically deducts from the _soonest expiring - * credit block_ first in order to ensure that all credits are utilized appropriately. As an + * By default, Orb uses an algorithm that automatically deducts from the *soonest expiring + * credit block* first in order to ensure that all credits are utilized appropriately. As an * example, if trial credits with an expiration date of 2 weeks from now are present for a * customer, they will be used before any deductions take place from a non-expiring credit * block. * * If there are multiple blocks with the same expiration date, Orb will deduct from the block - * with the _lower cost basis_ first (e.g. trial credits with a \$0 cost basis before paid + * with the *lower cost basis* first (e.g. trial credits with a \$0 cost basis before paid * credits with a \$5.00 cost basis). * * It's also possible for a single usage event's deduction to _span_ credit blocks. In this @@ -77,7 +75,6 @@ interface LedgerServiceAsync { * can be negative as a result of a decrement. * * ## Expiration change - * * The expiry of credits can be changed as a result of the API (See * [Add Ledger Entry](create-ledger-entry)). This will create a ledger entry that specifies the * balance as well as the initial and target expiry dates. @@ -87,24 +84,20 @@ interface LedgerServiceAsync { * the source credit block from which there was an expiration change. * * ## Credits expiry - * * When a set of credits expire on pre-set expiration date, the customer's balance automatically * reflects this change and adds an entry to the ledger indicating this event. Note that credit * expiry should always happen close to a date boundary in the customer's timezone. * * ## Void initiated - * * Credit blocks can be voided via the API. The `amount` on this entry corresponds to the number * of credits that were remaining in the block at time of void. `void_reason` will be populated * if the void is created with a reason. * * ## Void - * * When a set of credits is voided, the customer's balance automatically reflects this change * and adds an entry to the ledger indicating this event. * * ## Amendment - * * When credits are added to a customer's balance as a result of a correction, this entry will * be added to the ledger to indicate the adjustment of credits. */ @@ -144,7 +137,6 @@ interface LedgerServiceAsync { * the credits (based on `amount` and `per_unit_cost_basis`). * * ## Adding credits - * * Adding credits is done by creating an entry of type `increment`. This requires the caller to * specify a number of credits as well as an optional expiry date in `YYYY-MM-DD` format. Orb * also recommends specifying a description to assist with auditing. When adding credits, the @@ -168,7 +160,6 @@ interface LedgerServiceAsync { * blocks before adding the remaining amount to the desired credit block. * * ### Invoicing for credits - * * By default, Orb manipulates the credit ledger but does not charge for credits. However, if * you pass `invoice_settings` in the body of this request, Orb will also generate a one-off * invoice for the customer for the credits pre-purchase. Note that you _must_ provide the @@ -176,7 +167,6 @@ interface LedgerServiceAsync { * the cost basis with the number of credit units added. * * ## Deducting Credits - * * Orb allows you to deduct credits from a customer by creating an entry of type `decrement`. * Orb matches the algorithm for automatic deductions for determining which credit blocks to * decrement from. In the case that the deduction leads to multiple ledger entries, the response @@ -194,7 +184,6 @@ interface LedgerServiceAsync { * ``` * * ## Changing credits expiry - * * If you'd like to change when existing credits expire, you should create a ledger entry of * type `expiration_change`. For this entry, the required parameter `expiry_date` identifies the * _originating_ block, and the required parameter `target_expiry_date` identifies when the @@ -260,7 +249,6 @@ interface LedgerServiceAsync { * the credits (based on `amount` and `per_unit_cost_basis`). * * ## Adding credits - * * Adding credits is done by creating an entry of type `increment`. This requires the caller to * specify a number of credits as well as an optional expiry date in `YYYY-MM-DD` format. Orb * also recommends specifying a description to assist with auditing. When adding credits, the @@ -284,7 +272,6 @@ interface LedgerServiceAsync { * blocks before adding the remaining amount to the desired credit block. * * ### Invoicing for credits - * * By default, Orb manipulates the credit ledger but does not charge for credits. However, if * you pass `invoice_settings` in the body of this request, Orb will also generate a one-off * invoice for the customer for the credits pre-purchase. Note that you _must_ provide the @@ -292,7 +279,6 @@ interface LedgerServiceAsync { * the cost basis with the number of credit units added. * * ## Deducting Credits - * * Orb allows you to deduct credits from a customer by creating an entry of type `decrement`. * Orb matches the algorithm for automatic deductions for determining which credit blocks to * decrement from. In the case that the deduction leads to multiple ledger entries, the response @@ -310,7 +296,6 @@ interface LedgerServiceAsync { * ``` * * ## Changing credits expiry - * * If you'd like to change when existing credits expire, you should create a ledger entry of * type `expiration_change`. For this entry, the required parameter `expiry_date` identifies the * _originating_ block, and the required parameter `target_expiry_date` identifies when the @@ -375,14 +360,12 @@ interface LedgerServiceAsync { * There are four major types of modifications to credit balance, detailed below. * * ## Increment - * * Credits (which optionally expire on a future date) can be added via the API ([Add Ledger * Entry](create-ledger-entry)). The ledger entry for such an action will always contain the * total eligible starting and ending balance for the customer at the time the entry was added * to the ledger. * * ## Decrement - * * Deductions can occur as a result of an API call to create a ledger entry (see * [Add Ledger Entry](create-ledger-entry)), or automatically as a result of incurring usage. * Both ledger entries present the `decrement` entry type. @@ -394,14 +377,14 @@ interface LedgerServiceAsync { * the `event_id` at the time of ingestion, used to pinpoint _why_ credit deduction took place * and to ensure that credits are never deducted without an associated usage event. * - * By default, Orb uses an algorithm that automatically deducts from the _soonest expiring - * credit block_ first in order to ensure that all credits are utilized appropriately. As an + * By default, Orb uses an algorithm that automatically deducts from the *soonest expiring + * credit block* first in order to ensure that all credits are utilized appropriately. As an * example, if trial credits with an expiration date of 2 weeks from now are present for a * customer, they will be used before any deductions take place from a non-expiring credit * block. * * If there are multiple blocks with the same expiration date, Orb will deduct from the block - * with the _lower cost basis_ first (e.g. trial credits with a \$0 cost basis before paid + * with the *lower cost basis* first (e.g. trial credits with a \$0 cost basis before paid * credits with a \$5.00 cost basis). * * It's also possible for a single usage event's deduction to _span_ credit blocks. In this @@ -411,7 +394,6 @@ interface LedgerServiceAsync { * can be negative as a result of a decrement. * * ## Expiration change - * * The expiry of credits can be changed as a result of the API (See * [Add Ledger Entry](create-ledger-entry)). This will create a ledger entry that specifies the * balance as well as the initial and target expiry dates. @@ -421,24 +403,20 @@ interface LedgerServiceAsync { * the source credit block from which there was an expiration change. * * ## Credits expiry - * * When a set of credits expire on pre-set expiration date, the customer's balance automatically * reflects this change and adds an entry to the ledger indicating this event. Note that credit * expiry should always happen close to a date boundary in the customer's timezone. * * ## Void initiated - * * Credit blocks can be voided via the API. The `amount` on this entry corresponds to the number * of credits that were remaining in the block at time of void. `void_reason` will be populated * if the void is created with a reason. * * ## Void - * * When a set of credits is voided, the customer's balance automatically reflects this change * and adds an entry to the ledger indicating this event. * * ## Amendment - * * When credits are added to a customer's balance as a result of a correction, this entry will * be added to the ledger to indicate the adjustment of credits. */ diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/plans/ExternalPlanIdServiceAsync.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/plans/ExternalPlanIdServiceAsync.kt index 81dea5025..65eef1201 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/plans/ExternalPlanIdServiceAsync.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/plans/ExternalPlanIdServiceAsync.kt @@ -57,7 +57,6 @@ interface ExternalPlanIdServiceAsync { * created plan. * * ## Serialized prices - * * Orb supports a few different pricing models out of the box. Each of these models is * serialized differently in a given [Price](/core-concepts#plan-and-price) object. The * `model_type` field determines the key for the configuration object that is present. A diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/CustomerService.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/CustomerService.kt index 4ef4554c4..bc4ade3dc 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/CustomerService.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/CustomerService.kt @@ -48,11 +48,11 @@ interface CustomerService { * resource. * * This endpoint is critical in the following Orb functionality: - * - Automated charges can be configured by setting `payment_provider` and `payment_provider_id` + * * Automated charges can be configured by setting `payment_provider` and `payment_provider_id` * to automatically issue invoices - * - [Customer ID Aliases](/events-and-metrics/customer-aliases) can be configured by setting + * * [Customer ID Aliases](/events-and-metrics/customer-aliases) can be configured by setting * `external_customer_id` - * - [Timezone localization](/essentials/timezones) can be configured on a per-customer basis by + * * [Timezone localization](/essentials/timezones) can be configured on a per-customer basis by * setting the `timezone` parameter */ fun create( diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/EventService.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/EventService.kt index be75f242c..34966dccd 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/EventService.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/EventService.kt @@ -48,8 +48,8 @@ interface EventService { * * This is a powerful and audit-safe mechanism to retroactively update a single event in cases * where you need to: - * - update an event with new metadata as you iterate on your pricing model - * - update an event based on the result of an external API call (e.g. call to a payment gateway + * * update an event with new metadata as you iterate on your pricing model + * * update an event based on the result of an external API call (e.g. call to a payment gateway * succeeded or failed) * * This amendment API is always audit-safe. The process will still retain the original event, @@ -57,22 +57,22 @@ interface EventService { * Orb never overwrites or permanently deletes ingested usage data. * * ## Request validation - * - The `timestamp` of the new event must match the `timestamp` of the existing event already + * * The `timestamp` of the new event must match the `timestamp` of the existing event already * ingested. As with ingestion, all timestamps must be sent in ISO8601 format with UTC * timezone offset. - * - The `customer_id` or `external_customer_id` of the new event must match the `customer_id` + * * The `customer_id` or `external_customer_id` of the new event must match the `customer_id` * or `external_customer_id` of the existing event already ingested. Exactly one of * `customer_id` and `external_customer_id` should be specified, and similar to ingestion, the * ID must identify a Customer resource within Orb. Unlike ingestion, for event amendment, we * strictly enforce that the Customer must be in the Orb system, even during the initial * integration period. We do not allow updating the `Customer` an event is associated with. - * - Orb does not accept an `idempotency_key` with the event in this endpoint, since this + * * Orb does not accept an `idempotency_key` with the event in this endpoint, since this * request is by design idempotent. On retryable errors, you should retry the request and * assume the amendment operation has not succeeded until receipt of a 2xx. - * - The event's `timestamp` must fall within the customer's current subscription's billing + * * The event's `timestamp` must fall within the customer's current subscription's billing * period, or within the grace period of the customer's current subscription's previous * billing period. - * - By default, no more than 100 events can be amended for a single customer in a 100 day + * * By default, no more than 100 events can be amended for a single customer in a 100 day * period. For higher volume updates, consider using the [event backfill](create-backfill) * endpoint. */ @@ -97,8 +97,8 @@ interface EventService { * * This is a powerful and audit-safe mechanism to retroactively deprecate a single event in * cases where you need to: - * - no longer bill for an event that was improperly reported - * - no longer bill for an event based on the result of an external API call (e.g. call to a + * * no longer bill for an event that was improperly reported + * * no longer bill for an event based on the result of an external API call (e.g. call to a * payment gateway failed and the user should not be billed) * * If you want to only change specific properties of an event, but keep the event as part of the @@ -109,18 +109,18 @@ interface EventService { * overwrites or permanently deletes ingested usage data. * * ## Request validation - * - Orb does not accept an `idempotency_key` with the event in this endpoint, since this + * * Orb does not accept an `idempotency_key` with the event in this endpoint, since this * request is by design idempotent. On retryable errors, you should retry the request and * assume the deprecation operation has not succeeded until receipt of a 2xx. - * - The event's `timestamp` must fall within the customer's current subscription's billing + * * The event's `timestamp` must fall within the customer's current subscription's billing * period, or within the grace period of the customer's current subscription's previous * billing period. Orb does not allow deprecating events for billing periods that have already * invoiced customers. - * - The `customer_id` or the `external_customer_id` of the original event ingestion request + * * The `customer_id` or the `external_customer_id` of the original event ingestion request * must identify a Customer resource within Orb, even if this event was ingested during the * initial integration period. We do not allow deprecating events for customers not in the Orb * system. - * - By default, no more than 100 events can be deprecated for a single customer in a 100 day + * * By default, no more than 100 events can be deprecated for a single customer in a 100 day * period. For higher volume updates, consider using the [event backfill](create-backfill) * endpoint. */ @@ -199,7 +199,6 @@ interface EventService { * ``` * * ## Required fields - * * Because events streamed to Orb are meant to be as flexible as possible, there are only a few * required fields in every event. * - We recommend that `idempotency_key` are unique strings that you generated with V4 UUIDs, @@ -229,7 +228,6 @@ interface EventService { * aggregate should be of numeric type in the event. * * ## Determining event timestamp - * * For cases where usage is being reported in real time as it is occurring, timestamp should * correspond to the time that usage occurred. * @@ -284,7 +282,6 @@ interface EventService { * requests should be retried in their entirety. * * ## API usage and limits - * * The ingestion API is designed made for real-time streaming ingestion and architected for high * throughput. Even if events are later deemed unnecessary or filtered out, we encourage you to * log them to Orb if they may be relevant to billing calculations in the future. @@ -299,7 +296,6 @@ interface EventService { * magnitude from initial setup. * * ## Testing in debug mode - * * The ingestion API supports a debug mode, which returns additional verbose output to indicate * which event idempotency keys were newly ingested or duplicates from previous requests. To * enable this mode, mark `debug=true` as a query parameter. @@ -318,7 +314,11 @@ interface EventService { * { * "debug": { * "duplicate": [], - * "ingested": ["B7E83HDMfJPAunXW", "SJs5DQJ3TnwSqEZE", "8SivfDsNKwCeAXim"] + * "ingested": [ + * "B7E83HDMfJPAunXW", + * "SJs5DQJ3TnwSqEZE", + * "8SivfDsNKwCeAXim" + * ] * }, * "validation_failed": [] * } diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/PlanService.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/PlanService.kt index 022634e48..29f7ccd39 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/PlanService.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/PlanService.kt @@ -79,7 +79,6 @@ interface PlanService { * configuration, as well as the product that the plan is attached to. * * ## Serialized prices - * * Orb supports a few different pricing models out of the box. Each of these models is * serialized differently in a given [Price](/core-concepts#plan-and-price) object. The * `model_type` field determines the key for the configuration object that is present. A @@ -87,7 +86,6 @@ interface PlanService { * [Price schema](/core-concepts#plan-and-price). * * ## Phases - * * Orb supports plan phases, also known as contract ramps. For plans with phases, the serialized * prices refer to all prices across all phases. */ diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/SubscriptionService.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/SubscriptionService.kt index 1461e89b9..69647eca8 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/SubscriptionService.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/SubscriptionService.kt @@ -186,7 +186,6 @@ interface SubscriptionService { * cadence, type, and name of a price can not be overridden. * * ### Maximums and Minimums - * * Minimums and maximums, much like price overrides, can be useful when a new customer has * negotiated a new or different minimum or maximum spend cap than the default for a given * price. If one exists for a price and null is provided for the minimum/maximum override on @@ -231,7 +230,6 @@ interface SubscriptionService { * ``` * * ### Discounts - * * Discounts, like price overrides, can be useful when a new customer has negotiated a new or * different discount than the default for a price. If a discount exists for a price and a null * discount is provided on creation, then there will be no discount on the new subscription. @@ -376,7 +374,6 @@ interface SubscriptionService { * `end_date` equal to the `start_date` upon cancellation. * * ## Backdated cancellations - * * Orb allows you to cancel a subscription in the past as long as there are no paid invoices * between the `requested_date` and the current time. If the cancellation is after the latest * issued invoice, Orb will generate a balance refund for the current period. If the @@ -485,7 +482,6 @@ interface SubscriptionService { * of the customer's billing period. * * ### Default response shape - * * Orb returns a `data` array with an object corresponding to each billable metric. Nested * within this object is a `usage` array which has a `quantity` value and a corresponding * `timeframe_start` and `timeframe_end`. The `quantity` value represents the calculated usage @@ -502,7 +498,6 @@ interface SubscriptionService { * conjunction_ with each other, e.g. to display grouped usage on a custom timeframe. * * ## Custom timeframe - * * In order to view usage for a custom timeframe rather than the current billing period, specify * a `timeframe_start` and `timeframe_end`. This will calculate quantities for usage incurred * between timeframe_start (inclusive) and timeframe_end (exclusive), i.e. `[timeframe_start, @@ -514,7 +509,6 @@ interface SubscriptionService { * - Both parameters must be specified if either is specified. * * ## Grouping by custom attributes - * * In order to view a single metric grouped by a specific _attribute_ that each event is tagged * with (e.g. `cluster`), you must additionally specify a `billable_metric_id` and a `group_by` * key. The `group_by` key denotes the event property on which to group. @@ -564,7 +558,6 @@ interface SubscriptionService { * ``` * * ## Windowed usage - * * The `granularity` parameter can be used to _window_ the usage `quantity` value into periods. * When not specified, usage is returned for the entirety of the time range. * @@ -619,7 +612,6 @@ interface SubscriptionService { * ``` * * ## Decomposable vs. non-decomposable metrics - * * Billable metrics fall into one of two categories: decomposable and non-decomposable. A * decomposable billable metric, such as a sum or a count, can be displayed and aggregated * across arbitrary timescales. On the other hand, a non-decomposable metric is not meaningful @@ -638,7 +630,6 @@ interface SubscriptionService { * key. If no invoice grouping key is present, the metric does not support `group_by`. * * ## Matrix prices - * * When a billable metric is attached to a price that uses matrix pricing, it's important to * view usage grouped by those matrix dimensions. In this case, use the query parameters * `first_dimension_key`, `first_dimension_value` and `second_dimension_key`, @@ -718,7 +709,6 @@ interface SubscriptionService { * `start_date`. * * ## Fixed fee quantity transitions - * * The fixed fee quantity transitions for a fixed fee price interval can also be specified when * adding or editing by passing an array for `fixed_fee_quantity_transitions`. A fixed fee * quantity transition must have a `quantity` and an `effective_date`, which is the date after @@ -917,7 +907,6 @@ interface SubscriptionService { * cadence, type, and name of a price can not be overridden. * * ### Maximums, and minimums - * * Price overrides are used to update some or all prices in the target plan. Minimums and * maximums, much like price overrides, can be useful when a new customer has negotiated a new * or different minimum or maximum spend cap than the default for the plan. The request format @@ -925,12 +914,10 @@ interface SubscriptionService { * [subscription creation](create-subscription). * * ## Scheduling multiple plan changes - * * When scheduling multiple plan changes with the same date, the latest plan change on that day * takes effect. * * ## Prorations for in-advance fees - * * By default, Orb calculates the prorated difference in any fixed fees when making a plan * change, adjusting the customer balance as needed. For details on this behavior, see * [Modifying subscriptions](/product-catalog/modifying-subscriptions#prorations-for-in-advance-fees). diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/customers/CostService.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/customers/CostService.kt index fa039e1c6..55da94ad8 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/customers/CostService.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/customers/CostService.kt @@ -45,7 +45,6 @@ interface CostService { * minimum committed spend. * * ## Fetching subscriptions - * * By default, this endpoint fetches the currently active subscription for the customer, and * returns cost information for the subscription's current billing period, broken down by each * participating price. If there are no currently active subscriptions, this will instead @@ -58,18 +57,16 @@ interface CostService { * summed, and prices for both subscriptions will be included in the breakdown. * * ## Prepaid plans - * * For plans that include prices which deduct credits rather than accrue in-arrears charges in a * billable currency, this endpoint will return the total deduction amount, in credits, for the * specified timeframe. * * ## Cumulative subtotals and totals - * * Since the subtotal and total must factor in any billing-period level discounts and minimums, * it's most meaningful to consider costs relative to the start of the subscription's billing * period. As a result, by default this endpoint returns cumulative totals since the beginning * of the billing period. In particular, the `timeframe_start` of a returned timeframe window is - * _always_ the beginning of the billing period and `timeframe_end` is incremented one day at a + * *always* the beginning of the billing period and `timeframe_end` is incremented one day at a * time to build the result. * * A customer that uses a few API calls a day but has a minimum commitment might exhibit the @@ -87,7 +84,6 @@ interface CostService { * | 2023-02-01 | 2023-02-06 | 36 | \$90.00 | \$90.00 | * * ### Periodic values - * * When the query parameter `view_mode=periodic` is specified, Orb will return an incremental * day-by-day view of costs. In this case, there will always be a one-day difference between * `timeframe_start` and `timeframe_end` for the timeframes returned. This is a transform on top @@ -97,7 +93,6 @@ interface CostService { * to the total cost. * * ## Timeframe bounds - * * For an active subscription, both timeframes should be specified in the request. If a * subscription starts or ends within the timeframe, the response will only include windows * where the subscription is active. If a subscription has ended, no timeframe bounds need to be @@ -129,7 +124,6 @@ interface CostService { * You can see this sliced timeframe visualized [here](https://i.imgur.com/TXhYgme.png). * * ### Matrix prices - * * When a price uses matrix pricing, it's important to view costs grouped by those matrix * dimensions. Orb will return `price_groups` with the `grouping_key` and * `secondary_grouping_key` based on the matrix price definition, for each `grouping_value` and @@ -172,7 +166,6 @@ interface CostService { * minimum committed spend. * * ## Fetching subscriptions - * * By default, this endpoint fetches the currently active subscription for the customer, and * returns cost information for the subscription's current billing period, broken down by each * participating price. If there are no currently active subscriptions, this will instead @@ -185,18 +178,16 @@ interface CostService { * summed, and prices for both subscriptions will be included in the breakdown. * * ## Prepaid plans - * * For plans that include prices which deduct credits rather than accrue in-arrears charges in a * billable currency, this endpoint will return the total deduction amount, in credits, for the * specified timeframe. * * ## Cumulative subtotals and totals - * * Since the subtotal and total must factor in any billing-period level discounts and minimums, * it's most meaningful to consider costs relative to the start of the subscription's billing * period. As a result, by default this endpoint returns cumulative totals since the beginning * of the billing period. In particular, the `timeframe_start` of a returned timeframe window is - * _always_ the beginning of the billing period and `timeframe_end` is incremented one day at a + * *always* the beginning of the billing period and `timeframe_end` is incremented one day at a * time to build the result. * * A customer that uses a few API calls a day but has a minimum commitment might exhibit the @@ -214,7 +205,6 @@ interface CostService { * | 2023-02-01 | 2023-02-06 | 36 | \$90.00 | \$90.00 | * * ### Periodic values - * * When the query parameter `view_mode=periodic` is specified, Orb will return an incremental * day-by-day view of costs. In this case, there will always be a one-day difference between * `timeframe_start` and `timeframe_end` for the timeframes returned. This is a transform on top @@ -224,7 +214,6 @@ interface CostService { * to the total cost. * * ## Timeframe bounds - * * For an active subscription, both timeframes should be specified in the request. If a * subscription starts or ends within the timeframe, the response will only include windows * where the subscription is active. If a subscription has ended, no timeframe bounds need to be @@ -256,7 +245,6 @@ interface CostService { * You can see this sliced timeframe visualized [here](https://i.imgur.com/TXhYgme.png). * * ### Matrix prices - * * When a price uses matrix pricing, it's important to view costs grouped by those matrix * dimensions. Orb will return `price_groups` with the `grouping_key` and * `secondary_grouping_key` based on the matrix price definition, for each `grouping_value` and diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/customers/credits/LedgerService.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/customers/credits/LedgerService.kt index 58074adf5..4f474397f 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/customers/credits/LedgerService.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/customers/credits/LedgerService.kt @@ -41,14 +41,12 @@ interface LedgerService { * There are four major types of modifications to credit balance, detailed below. * * ## Increment - * * Credits (which optionally expire on a future date) can be added via the API ([Add Ledger * Entry](create-ledger-entry)). The ledger entry for such an action will always contain the * total eligible starting and ending balance for the customer at the time the entry was added * to the ledger. * * ## Decrement - * * Deductions can occur as a result of an API call to create a ledger entry (see * [Add Ledger Entry](create-ledger-entry)), or automatically as a result of incurring usage. * Both ledger entries present the `decrement` entry type. @@ -60,14 +58,14 @@ interface LedgerService { * the `event_id` at the time of ingestion, used to pinpoint _why_ credit deduction took place * and to ensure that credits are never deducted without an associated usage event. * - * By default, Orb uses an algorithm that automatically deducts from the _soonest expiring - * credit block_ first in order to ensure that all credits are utilized appropriately. As an + * By default, Orb uses an algorithm that automatically deducts from the *soonest expiring + * credit block* first in order to ensure that all credits are utilized appropriately. As an * example, if trial credits with an expiration date of 2 weeks from now are present for a * customer, they will be used before any deductions take place from a non-expiring credit * block. * * If there are multiple blocks with the same expiration date, Orb will deduct from the block - * with the _lower cost basis_ first (e.g. trial credits with a \$0 cost basis before paid + * with the *lower cost basis* first (e.g. trial credits with a \$0 cost basis before paid * credits with a \$5.00 cost basis). * * It's also possible for a single usage event's deduction to _span_ credit blocks. In this @@ -77,7 +75,6 @@ interface LedgerService { * can be negative as a result of a decrement. * * ## Expiration change - * * The expiry of credits can be changed as a result of the API (See * [Add Ledger Entry](create-ledger-entry)). This will create a ledger entry that specifies the * balance as well as the initial and target expiry dates. @@ -87,24 +84,20 @@ interface LedgerService { * the source credit block from which there was an expiration change. * * ## Credits expiry - * * When a set of credits expire on pre-set expiration date, the customer's balance automatically * reflects this change and adds an entry to the ledger indicating this event. Note that credit * expiry should always happen close to a date boundary in the customer's timezone. * * ## Void initiated - * * Credit blocks can be voided via the API. The `amount` on this entry corresponds to the number * of credits that were remaining in the block at time of void. `void_reason` will be populated * if the void is created with a reason. * * ## Void - * * When a set of credits is voided, the customer's balance automatically reflects this change * and adds an entry to the ledger indicating this event. * * ## Amendment - * * When credits are added to a customer's balance as a result of a correction, this entry will * be added to the ledger to indicate the adjustment of credits. */ @@ -141,7 +134,6 @@ interface LedgerService { * the credits (based on `amount` and `per_unit_cost_basis`). * * ## Adding credits - * * Adding credits is done by creating an entry of type `increment`. This requires the caller to * specify a number of credits as well as an optional expiry date in `YYYY-MM-DD` format. Orb * also recommends specifying a description to assist with auditing. When adding credits, the @@ -165,7 +157,6 @@ interface LedgerService { * blocks before adding the remaining amount to the desired credit block. * * ### Invoicing for credits - * * By default, Orb manipulates the credit ledger but does not charge for credits. However, if * you pass `invoice_settings` in the body of this request, Orb will also generate a one-off * invoice for the customer for the credits pre-purchase. Note that you _must_ provide the @@ -173,7 +164,6 @@ interface LedgerService { * the cost basis with the number of credit units added. * * ## Deducting Credits - * * Orb allows you to deduct credits from a customer by creating an entry of type `decrement`. * Orb matches the algorithm for automatic deductions for determining which credit blocks to * decrement from. In the case that the deduction leads to multiple ledger entries, the response @@ -191,7 +181,6 @@ interface LedgerService { * ``` * * ## Changing credits expiry - * * If you'd like to change when existing credits expire, you should create a ledger entry of * type `expiration_change`. For this entry, the required parameter `expiry_date` identifies the * _originating_ block, and the required parameter `target_expiry_date` identifies when the @@ -257,7 +246,6 @@ interface LedgerService { * the credits (based on `amount` and `per_unit_cost_basis`). * * ## Adding credits - * * Adding credits is done by creating an entry of type `increment`. This requires the caller to * specify a number of credits as well as an optional expiry date in `YYYY-MM-DD` format. Orb * also recommends specifying a description to assist with auditing. When adding credits, the @@ -281,7 +269,6 @@ interface LedgerService { * blocks before adding the remaining amount to the desired credit block. * * ### Invoicing for credits - * * By default, Orb manipulates the credit ledger but does not charge for credits. However, if * you pass `invoice_settings` in the body of this request, Orb will also generate a one-off * invoice for the customer for the credits pre-purchase. Note that you _must_ provide the @@ -289,7 +276,6 @@ interface LedgerService { * the cost basis with the number of credit units added. * * ## Deducting Credits - * * Orb allows you to deduct credits from a customer by creating an entry of type `decrement`. * Orb matches the algorithm for automatic deductions for determining which credit blocks to * decrement from. In the case that the deduction leads to multiple ledger entries, the response @@ -307,7 +293,6 @@ interface LedgerService { * ``` * * ## Changing credits expiry - * * If you'd like to change when existing credits expire, you should create a ledger entry of * type `expiration_change`. For this entry, the required parameter `expiry_date` identifies the * _originating_ block, and the required parameter `target_expiry_date` identifies when the @@ -372,14 +357,12 @@ interface LedgerService { * There are four major types of modifications to credit balance, detailed below. * * ## Increment - * * Credits (which optionally expire on a future date) can be added via the API ([Add Ledger * Entry](create-ledger-entry)). The ledger entry for such an action will always contain the * total eligible starting and ending balance for the customer at the time the entry was added * to the ledger. * * ## Decrement - * * Deductions can occur as a result of an API call to create a ledger entry (see * [Add Ledger Entry](create-ledger-entry)), or automatically as a result of incurring usage. * Both ledger entries present the `decrement` entry type. @@ -391,14 +374,14 @@ interface LedgerService { * the `event_id` at the time of ingestion, used to pinpoint _why_ credit deduction took place * and to ensure that credits are never deducted without an associated usage event. * - * By default, Orb uses an algorithm that automatically deducts from the _soonest expiring - * credit block_ first in order to ensure that all credits are utilized appropriately. As an + * By default, Orb uses an algorithm that automatically deducts from the *soonest expiring + * credit block* first in order to ensure that all credits are utilized appropriately. As an * example, if trial credits with an expiration date of 2 weeks from now are present for a * customer, they will be used before any deductions take place from a non-expiring credit * block. * * If there are multiple blocks with the same expiration date, Orb will deduct from the block - * with the _lower cost basis_ first (e.g. trial credits with a \$0 cost basis before paid + * with the *lower cost basis* first (e.g. trial credits with a \$0 cost basis before paid * credits with a \$5.00 cost basis). * * It's also possible for a single usage event's deduction to _span_ credit blocks. In this @@ -408,7 +391,6 @@ interface LedgerService { * can be negative as a result of a decrement. * * ## Expiration change - * * The expiry of credits can be changed as a result of the API (See * [Add Ledger Entry](create-ledger-entry)). This will create a ledger entry that specifies the * balance as well as the initial and target expiry dates. @@ -418,24 +400,20 @@ interface LedgerService { * the source credit block from which there was an expiration change. * * ## Credits expiry - * * When a set of credits expire on pre-set expiration date, the customer's balance automatically * reflects this change and adds an entry to the ledger indicating this event. Note that credit * expiry should always happen close to a date boundary in the customer's timezone. * * ## Void initiated - * * Credit blocks can be voided via the API. The `amount` on this entry corresponds to the number * of credits that were remaining in the block at time of void. `void_reason` will be populated * if the void is created with a reason. * * ## Void - * * When a set of credits is voided, the customer's balance automatically reflects this change * and adds an entry to the ledger indicating this event. * * ## Amendment - * * When credits are added to a customer's balance as a result of a correction, this entry will * be added to the ledger to indicate the adjustment of credits. */ diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/plans/ExternalPlanIdService.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/plans/ExternalPlanIdService.kt index bcc8e244c..1c1f345d6 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/plans/ExternalPlanIdService.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/plans/ExternalPlanIdService.kt @@ -57,7 +57,6 @@ interface ExternalPlanIdService { * created plan. * * ## Serialized prices - * * Orb supports a few different pricing models out of the box. Each of these models is * serialized differently in a given [Price](/core-concepts#plan-and-price) object. The * `model_type` field determines the key for the configuration object that is present. A From d4ef4acd10993041451835b56cf0d1ce4d145f71 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 25 Sep 2025 18:12:01 +0000 Subject: [PATCH 21/68] fix(client): deserialization of empty objects --- .../api/models/AccountingProviderConfig.kt | 1 + .../kotlin/com/withorb/api/models/Address.kt | 1 + .../com/withorb/api/models/AddressInput.kt | 1 + .../withorb/api/models/AdjustmentInterval.kt | 1 + .../com/withorb/api/models/AffectedBlock.kt | 1 + .../com/withorb/api/models/AggregatedCost.kt | 1 + .../kotlin/com/withorb/api/models/Alert.kt | 4 ++ .../models/AlertCreateForCustomerParams.kt | 1 + .../AlertCreateForExternalCustomerParams.kt | 1 + .../AlertCreateForSubscriptionParams.kt | 1 + .../api/models/AlertListPageResponse.kt | 1 + .../withorb/api/models/AlertUpdateParams.kt | 1 + .../com/withorb/api/models/Allocation.kt | 1 + .../api/models/AmendmentLedgerEntry.kt | 1 + .../com/withorb/api/models/AmountDiscount.kt | 1 + .../api/models/AmountDiscountInterval.kt | 1 + .../api/models/BetaCreatePlanVersionParams.kt | 17 +++++ ...taExternalPlanIdCreatePlanVersionParams.kt | 17 +++++ ...ternalPlanIdSetDefaultPlanVersionParams.kt | 1 + .../models/BetaSetDefaultPlanVersionParams.kt | 1 + .../com/withorb/api/models/BillableMetric.kt | 1 + .../withorb/api/models/BillableMetricTiny.kt | 1 + .../models/BillingCycleAnchorConfiguration.kt | 1 + .../api/models/BillingCycleConfiguration.kt | 1 + .../com/withorb/api/models/BulkConfig.kt | 1 + .../kotlin/com/withorb/api/models/BulkTier.kt | 1 + .../models/ChangedSubscriptionResources.kt | 7 ++ .../withorb/api/models/ConversionRateTier.kt | 1 + .../api/models/ConversionRateTieredConfig.kt | 1 + .../api/models/ConversionRateUnitConfig.kt | 1 + .../kotlin/com/withorb/api/models/Coupon.kt | 1 + .../withorb/api/models/CouponCreateParams.kt | 3 + .../api/models/CouponListPageResponse.kt | 1 + .../withorb/api/models/CouponRedemption.kt | 1 + .../models/CreditBlockExpiryLedgerEntry.kt | 1 + .../com/withorb/api/models/CreditNote.kt | 7 ++ .../api/models/CreditNoteCreateParams.kt | 2 + .../api/models/CreditNoteListPageResponse.kt | 1 + .../com/withorb/api/models/CreditNoteTiny.kt | 1 + .../withorb/api/models/CustomExpiration.kt | 1 + .../kotlin/com/withorb/api/models/Customer.kt | 5 ++ .../CustomerBalanceTransactionCreateParams.kt | 1 + ...ustomerBalanceTransactionCreateResponse.kt | 1 + ...tomerBalanceTransactionListPageResponse.kt | 1 + .../CustomerBalanceTransactionListResponse.kt | 1 + .../CustomerCostListByExternalIdResponse.kt | 1 + .../api/models/CustomerCostListResponse.kt | 1 + .../api/models/CustomerCreateParams.kt | 2 + ...editLedgerCreateEntryByExternalIdParams.kt | 6 ++ .../CustomerCreditLedgerCreateEntryParams.kt | 6 ++ ...reditLedgerListByExternalIdPageResponse.kt | 1 + .../CustomerCreditLedgerListPageResponse.kt | 1 + ...tomerCreditListByExternalIdPageResponse.kt | 1 + .../CustomerCreditListByExternalIdResponse.kt | 1 + .../models/CustomerCreditListPageResponse.kt | 1 + .../api/models/CustomerCreditListResponse.kt | 1 + ...omerCreditTopUpCreateByExternalIdParams.kt | 2 + ...erCreditTopUpCreateByExternalIdResponse.kt | 1 + .../models/CustomerCreditTopUpCreateParams.kt | 2 + .../CustomerCreditTopUpCreateResponse.kt | 1 + ...CreditTopUpListByExternalIdPageResponse.kt | 1 + ...omerCreditTopUpListByExternalIdResponse.kt | 1 + .../CustomerCreditTopUpListPageResponse.kt | 1 + .../models/CustomerCreditTopUpListResponse.kt | 1 + .../api/models/CustomerHierarchyConfig.kt | 1 + .../api/models/CustomerListPageResponse.kt | 1 + .../withorb/api/models/CustomerMinified.kt | 1 + .../com/withorb/api/models/CustomerTaxId.kt | 1 + .../CustomerUpdateByExternalIdParams.kt | 2 + .../api/models/CustomerUpdateParams.kt | 2 + .../api/models/DecrementLedgerEntry.kt | 1 + .../models/DimensionalPriceConfiguration.kt | 1 + .../api/models/DimensionalPriceGroup.kt | 1 + .../DimensionalPriceGroupCreateParams.kt | 1 + ...rnalDimensionalPriceGroupIdUpdateParams.kt | 1 + .../DimensionalPriceGroupUpdateParams.kt | 1 + .../api/models/DimensionalPriceGroups.kt | 1 + .../withorb/api/models/DiscountOverride.kt | 1 + .../withorb/api/models/EvaluatePriceGroup.kt | 1 + .../api/models/EventBackfillCloseResponse.kt | 1 + .../api/models/EventBackfillCreateParams.kt | 1 + .../api/models/EventBackfillCreateResponse.kt | 1 + .../api/models/EventBackfillFetchResponse.kt | 1 + .../models/EventBackfillListPageResponse.kt | 1 + .../api/models/EventBackfillListResponse.kt | 1 + .../api/models/EventBackfillRevertResponse.kt | 1 + .../api/models/EventDeprecateResponse.kt | 1 + .../withorb/api/models/EventIngestParams.kt | 2 + .../withorb/api/models/EventIngestResponse.kt | 3 + .../withorb/api/models/EventSearchParams.kt | 1 + .../withorb/api/models/EventSearchResponse.kt | 2 + .../withorb/api/models/EventUpdateParams.kt | 1 + .../withorb/api/models/EventUpdateResponse.kt | 1 + .../com/withorb/api/models/EventVolumes.kt | 2 + .../api/models/ExpirationChangeLedgerEntry.kt | 1 + .../models/FixedFeeQuantityScheduleEntry.kt | 1 + .../api/models/FixedFeeQuantityTransition.kt | 1 + .../api/models/IncrementLedgerEntry.kt | 1 + .../kotlin/com/withorb/api/models/Invoice.kt | 6 ++ .../withorb/api/models/InvoiceCreateParams.kt | 2 + .../models/InvoiceFetchUpcomingResponse.kt | 6 ++ .../withorb/api/models/InvoiceIssueParams.kt | 1 + .../api/models/InvoiceLineItemCreateParams.kt | 1 + .../models/InvoiceLineItemCreateResponse.kt | 1 + .../api/models/InvoiceListPageResponse.kt | 1 + .../api/models/InvoiceMarkPaidParams.kt | 1 + .../com/withorb/api/models/InvoiceTiny.kt | 1 + .../withorb/api/models/InvoiceUpdateParams.kt | 1 + .../kotlin/com/withorb/api/models/Item.kt | 2 + .../withorb/api/models/ItemCreateParams.kt | 1 + .../api/models/ItemListPageResponse.kt | 1 + .../kotlin/com/withorb/api/models/ItemSlim.kt | 1 + .../withorb/api/models/ItemUpdateParams.kt | 2 + .../com/withorb/api/models/MatrixConfig.kt | 1 + .../withorb/api/models/MatrixSubLineItem.kt | 1 + .../com/withorb/api/models/MatrixValue.kt | 1 + .../api/models/MatrixWithAllocationConfig.kt | 2 + .../kotlin/com/withorb/api/models/Maximum.kt | 1 + .../com/withorb/api/models/MaximumInterval.kt | 1 + .../withorb/api/models/MetricCreateParams.kt | 1 + .../api/models/MetricListPageResponse.kt | 1 + .../withorb/api/models/MetricUpdateParams.kt | 1 + .../kotlin/com/withorb/api/models/Minimum.kt | 1 + .../com/withorb/api/models/MinimumInterval.kt | 1 + .../MonetaryAmountDiscountAdjustment.kt | 1 + .../api/models/MonetaryMaximumAdjustment.kt | 1 + .../api/models/MonetaryMinimumAdjustment.kt | 1 + .../MonetaryPercentageDiscountAdjustment.kt | 1 + .../models/MonetaryUsageDiscountAdjustment.kt | 1 + .../withorb/api/models/MutatedSubscription.kt | 1 + .../models/NewAccountingSyncConfiguration.kt | 1 + .../withorb/api/models/NewAllocationPrice.kt | 1 + .../withorb/api/models/NewAmountDiscount.kt | 1 + .../api/models/NewAvalaraTaxConfiguration.kt | 1 + .../models/NewBillingCycleConfiguration.kt | 1 + .../NewDimensionalPriceConfiguration.kt | 1 + .../api/models/NewFloatingBulkPrice.kt | 1 + .../NewFloatingBulkWithProrationPrice.kt | 3 + .../NewFloatingCumulativeGroupedBulkPrice.kt | 3 + .../NewFloatingGroupedAllocationPrice.kt | 2 + .../NewFloatingGroupedTieredPackagePrice.kt | 3 + .../models/NewFloatingGroupedTieredPrice.kt | 3 + ...wFloatingGroupedWithMeteredMinimumPrice.kt | 4 ++ ...FloatingGroupedWithProratedMinimumPrice.kt | 2 + .../api/models/NewFloatingMatrixPrice.kt | 1 + .../NewFloatingMatrixWithAllocationPrice.kt | 1 + .../NewFloatingMatrixWithDisplayNamePrice.kt | 3 + .../NewFloatingMaxGroupTieredPackagePrice.kt | 3 + .../NewFloatingMinimumCompositePrice.kt | 2 + .../api/models/NewFloatingPackagePrice.kt | 1 + .../NewFloatingPackageWithAllocationPrice.kt | 2 + ...ingScalableMatrixWithTieredPricingPrice.kt | 4 ++ ...atingScalableMatrixWithUnitPricingPrice.kt | 3 + .../NewFloatingThresholdTotalAmountPrice.kt | 3 + .../models/NewFloatingTieredPackagePrice.kt | 3 + ...ewFloatingTieredPackageWithMinimumPrice.kt | 3 + .../api/models/NewFloatingTieredPrice.kt | 1 + .../NewFloatingTieredWithMinimumPrice.kt | 3 + .../NewFloatingTieredWithProrationPrice.kt | 3 + .../api/models/NewFloatingUnitPrice.kt | 1 + .../models/NewFloatingUnitWithPercentPrice.kt | 2 + .../NewFloatingUnitWithProrationPrice.kt | 2 + .../com/withorb/api/models/NewMaximum.kt | 1 + .../com/withorb/api/models/NewMinimum.kt | 1 + .../api/models/NewPercentageDiscount.kt | 1 + .../withorb/api/models/NewPlanBulkPrice.kt | 1 + .../models/NewPlanBulkWithProrationPrice.kt | 3 + .../NewPlanCumulativeGroupedBulkPrice.kt | 3 + .../models/NewPlanGroupedAllocationPrice.kt | 2 + .../NewPlanGroupedTieredPackagePrice.kt | 3 + .../api/models/NewPlanGroupedTieredPrice.kt | 3 + .../NewPlanGroupedWithMeteredMinimumPrice.kt | 4 ++ .../NewPlanGroupedWithProratedMinimumPrice.kt | 2 + .../withorb/api/models/NewPlanMatrixPrice.kt | 1 + .../NewPlanMatrixWithAllocationPrice.kt | 1 + .../NewPlanMatrixWithDisplayNamePrice.kt | 3 + .../NewPlanMaxGroupTieredPackagePrice.kt | 3 + .../models/NewPlanMinimumCompositePrice.kt | 2 + .../withorb/api/models/NewPlanPackagePrice.kt | 1 + .../NewPlanPackageWithAllocationPrice.kt | 2 + ...lanScalableMatrixWithTieredPricingPrice.kt | 4 ++ ...wPlanScalableMatrixWithUnitPricingPrice.kt | 3 + .../NewPlanThresholdTotalAmountPrice.kt | 3 + .../api/models/NewPlanTieredPackagePrice.kt | 3 + .../NewPlanTieredPackageWithMinimumPrice.kt | 3 + .../withorb/api/models/NewPlanTieredPrice.kt | 1 + .../models/NewPlanTieredWithMinimumPrice.kt | 3 + .../withorb/api/models/NewPlanUnitPrice.kt | 1 + .../api/models/NewPlanUnitWithPercentPrice.kt | 2 + .../models/NewPlanUnitWithProrationPrice.kt | 2 + .../api/models/NewReportingConfiguration.kt | 1 + .../api/models/NewSphereConfiguration.kt | 1 + .../api/models/NewSubscriptionBulkPrice.kt | 1 + .../NewSubscriptionBulkWithProrationPrice.kt | 3 + ...wSubscriptionCumulativeGroupedBulkPrice.kt | 3 + .../NewSubscriptionGroupedAllocationPrice.kt | 2 + ...ewSubscriptionGroupedTieredPackagePrice.kt | 3 + .../NewSubscriptionGroupedTieredPrice.kt | 3 + ...scriptionGroupedWithMeteredMinimumPrice.kt | 4 ++ ...criptionGroupedWithProratedMinimumPrice.kt | 2 + .../api/models/NewSubscriptionMatrixPrice.kt | 1 + ...ewSubscriptionMatrixWithAllocationPrice.kt | 1 + ...wSubscriptionMatrixWithDisplayNamePrice.kt | 3 + ...wSubscriptionMaxGroupTieredPackagePrice.kt | 3 + .../NewSubscriptionMinimumCompositePrice.kt | 2 + .../api/models/NewSubscriptionPackagePrice.kt | 1 + ...wSubscriptionPackageWithAllocationPrice.kt | 2 + ...ionScalableMatrixWithTieredPricingPrice.kt | 4 ++ ...ptionScalableMatrixWithUnitPricingPrice.kt | 3 + ...ewSubscriptionThresholdTotalAmountPrice.kt | 3 + .../NewSubscriptionTieredPackagePrice.kt | 3 + ...bscriptionTieredPackageWithMinimumPrice.kt | 3 + .../api/models/NewSubscriptionTieredPrice.kt | 1 + .../NewSubscriptionTieredWithMinimumPrice.kt | 3 + .../api/models/NewSubscriptionUnitPrice.kt | 1 + .../NewSubscriptionUnitWithPercentPrice.kt | 2 + .../NewSubscriptionUnitWithProrationPrice.kt | 2 + .../api/models/NewTaxJarConfiguration.kt | 1 + .../withorb/api/models/NewUsageDiscount.kt | 1 + .../withorb/api/models/OtherSubLineItem.kt | 1 + .../com/withorb/api/models/PackageConfig.kt | 1 + .../withorb/api/models/PaginationMetadata.kt | 1 + .../com/withorb/api/models/PerPriceCost.kt | 1 + .../withorb/api/models/PercentageDiscount.kt | 1 + .../api/models/PercentageDiscountInterval.kt | 1 + .../kotlin/com/withorb/api/models/Plan.kt | 5 ++ .../withorb/api/models/PlanCreateParams.kt | 9 +++ .../models/PlanExternalPlanIdUpdateParams.kt | 1 + .../api/models/PlanListPageResponse.kt | 1 + .../PlanPhaseAmountDiscountAdjustment.kt | 1 + .../api/models/PlanPhaseMaximumAdjustment.kt | 1 + .../api/models/PlanPhaseMinimumAdjustment.kt | 1 + .../PlanPhasePercentageDiscountAdjustment.kt | 1 + .../PlanPhaseUsageDiscountAdjustment.kt | 1 + .../withorb/api/models/PlanUpdateParams.kt | 1 + .../com/withorb/api/models/PlanVersion.kt | 1 + .../withorb/api/models/PlanVersionPhase.kt | 1 + .../kotlin/com/withorb/api/models/Price.kt | 64 +++++++++++++++++++ .../withorb/api/models/PriceCreateParams.kt | 2 + .../api/models/PriceEvaluateMultipleParams.kt | 4 ++ .../models/PriceEvaluateMultipleResponse.kt | 2 + .../withorb/api/models/PriceEvaluateParams.kt | 1 + .../PriceEvaluatePreviewEventsParams.kt | 5 ++ .../PriceEvaluatePreviewEventsResponse.kt | 2 + .../api/models/PriceEvaluateResponse.kt | 1 + .../PriceExternalPriceIdUpdateParams.kt | 1 + .../com/withorb/api/models/PriceInterval.kt | 1 + .../api/models/PriceListPageResponse.kt | 1 + .../withorb/api/models/PriceUpdateParams.kt | 1 + .../withorb/api/models/SubLineItemGrouping.kt | 1 + .../api/models/SubLineItemMatrixConfig.kt | 1 + .../com/withorb/api/models/Subscription.kt | 1 + .../api/models/SubscriptionCancelParams.kt | 1 + .../models/SubscriptionChangeApplyParams.kt | 1 + .../models/SubscriptionChangeApplyResponse.kt | 1 + .../SubscriptionChangeCancelResponse.kt | 1 + .../api/models/SubscriptionChangeMinified.kt | 1 + .../SubscriptionChangeRetrieveResponse.kt | 1 + .../api/models/SubscriptionCreateParams.kt | 17 +++++ .../models/SubscriptionFetchCostsResponse.kt | 1 + .../SubscriptionFetchSchedulePageResponse.kt | 1 + .../SubscriptionFetchScheduleResponse.kt | 2 + .../api/models/SubscriptionMinified.kt | 1 + .../SubscriptionPriceIntervalsParams.kt | 12 ++++ .../models/SubscriptionRedeemCouponParams.kt | 1 + .../SubscriptionSchedulePlanChangeParams.kt | 17 +++++ .../api/models/SubscriptionTrialInfo.kt | 1 + .../models/SubscriptionTriggerPhaseParams.kt | 1 + ...UnscheduleFixedFeeQuantityUpdatesParams.kt | 1 + ...ubscriptionUpdateFixedFeeQuantityParams.kt | 1 + .../api/models/SubscriptionUpdateParams.kt | 1 + .../models/SubscriptionUpdateTrialParams.kt | 1 + .../withorb/api/models/SubscriptionUsage.kt | 9 +++ .../com/withorb/api/models/Subscriptions.kt | 1 + .../com/withorb/api/models/TaxAmount.kt | 1 + .../com/withorb/api/models/Threshold.kt | 1 + .../kotlin/com/withorb/api/models/Tier.kt | 1 + .../com/withorb/api/models/TierSubLineItem.kt | 2 + .../com/withorb/api/models/TieredConfig.kt | 1 + .../api/models/TieredConversionRateConfig.kt | 1 + .../api/models/TopLevelPingResponse.kt | 1 + .../api/models/TopUpInvoiceSettings.kt | 1 + .../api/models/TransformPriceFilter.kt | 1 + .../com/withorb/api/models/TrialDiscount.kt | 1 + .../com/withorb/api/models/UnitConfig.kt | 1 + .../api/models/UnitConversionRateConfig.kt | 1 + .../com/withorb/api/models/UsageDiscount.kt | 1 + .../api/models/UsageDiscountInterval.kt | 1 + .../api/models/VoidInitiatedLedgerEntry.kt | 1 + .../com/withorb/api/models/VoidLedgerEntry.kt | 1 + 290 files changed, 620 insertions(+) diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/AccountingProviderConfig.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/AccountingProviderConfig.kt index 6f0112ce8..1883cd288 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/AccountingProviderConfig.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/AccountingProviderConfig.kt @@ -16,6 +16,7 @@ import java.util.Collections import java.util.Objects class AccountingProviderConfig +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val externalProviderId: JsonField, private val providerType: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Address.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Address.kt index 5ea66523f..932fcb73f 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Address.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Address.kt @@ -16,6 +16,7 @@ import java.util.Collections import java.util.Objects class Address +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val city: JsonField, private val country: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/AddressInput.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/AddressInput.kt index 2aa876645..a57985530 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/AddressInput.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/AddressInput.kt @@ -15,6 +15,7 @@ import java.util.Collections import java.util.Objects class AddressInput +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val city: JsonField, private val country: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/AdjustmentInterval.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/AdjustmentInterval.kt index 00de333b1..e9ffe44d3 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/AdjustmentInterval.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/AdjustmentInterval.kt @@ -29,6 +29,7 @@ import java.util.Collections import java.util.Objects class AdjustmentInterval +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val adjustment: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/AffectedBlock.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/AffectedBlock.kt index 49e3f7acb..9e634a515 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/AffectedBlock.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/AffectedBlock.kt @@ -17,6 +17,7 @@ import java.util.Collections import java.util.Objects class AffectedBlock +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val expiryDate: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/AggregatedCost.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/AggregatedCost.kt index fa60381c2..9a1d32c42 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/AggregatedCost.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/AggregatedCost.kt @@ -19,6 +19,7 @@ import java.util.Collections import java.util.Objects class AggregatedCost +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val perPriceCosts: JsonField>, private val subtotal: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Alert.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Alert.kt index fe13e7cdd..5f3c0a922 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Alert.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Alert.kt @@ -26,6 +26,7 @@ import java.util.Objects * Alerts created through the API can be scoped to either customers or subscriptions. */ class Alert +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val createdAt: JsonField, @@ -587,6 +588,7 @@ private constructor( /** The metric the alert applies to. */ class Metric + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val additionalProperties: MutableMap, @@ -738,6 +740,7 @@ private constructor( /** The plan the alert applies to. */ class Plan + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val externalPlanId: JsonField, @@ -1164,6 +1167,7 @@ private constructor( /** Alert status is used to determine if an alert is currently in-alert or not. */ class BalanceAlertStatus + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val inAlert: JsonField, private val thresholdValue: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/AlertCreateForCustomerParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/AlertCreateForCustomerParams.kt index eca8723ac..1a5474c90 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/AlertCreateForCustomerParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/AlertCreateForCustomerParams.kt @@ -331,6 +331,7 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val currency: JsonField, private val type: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/AlertCreateForExternalCustomerParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/AlertCreateForExternalCustomerParams.kt index c5069db66..4c85b34c6 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/AlertCreateForExternalCustomerParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/AlertCreateForExternalCustomerParams.kt @@ -337,6 +337,7 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val currency: JsonField, private val type: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/AlertCreateForSubscriptionParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/AlertCreateForSubscriptionParams.kt index 380352c36..d0130f701 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/AlertCreateForSubscriptionParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/AlertCreateForSubscriptionParams.kt @@ -338,6 +338,7 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val thresholds: JsonField>, private val type: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/AlertListPageResponse.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/AlertListPageResponse.kt index 74c818258..249d4fd9e 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/AlertListPageResponse.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/AlertListPageResponse.kt @@ -18,6 +18,7 @@ import java.util.Collections import java.util.Objects class AlertListPageResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val data: JsonField>, private val paginationMetadata: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/AlertUpdateParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/AlertUpdateParams.kt index e2572f113..015670473 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/AlertUpdateParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/AlertUpdateParams.kt @@ -269,6 +269,7 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val thresholds: JsonField>, private val additionalProperties: MutableMap, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Allocation.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Allocation.kt index 77c2ccb5b..066f0ba1c 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Allocation.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Allocation.kt @@ -16,6 +16,7 @@ import java.util.Collections import java.util.Objects class Allocation +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val allowsRollover: JsonField, private val currency: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/AmendmentLedgerEntry.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/AmendmentLedgerEntry.kt index 467678df1..bf3f011b5 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/AmendmentLedgerEntry.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/AmendmentLedgerEntry.kt @@ -19,6 +19,7 @@ import java.util.Collections import java.util.Objects class AmendmentLedgerEntry +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val amount: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/AmountDiscount.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/AmountDiscount.kt index c386552e8..a921b4f73 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/AmountDiscount.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/AmountDiscount.kt @@ -19,6 +19,7 @@ import java.util.Collections import java.util.Objects class AmountDiscount +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val amountDiscount: JsonField, private val discountType: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/AmountDiscountInterval.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/AmountDiscountInterval.kt index d8b903e3d..a1fff5676 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/AmountDiscountInterval.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/AmountDiscountInterval.kt @@ -20,6 +20,7 @@ import java.util.Collections import java.util.Objects class AmountDiscountInterval +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val amountDiscount: JsonField, private val appliesToPriceIntervalIds: JsonField>, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BetaCreatePlanVersionParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BetaCreatePlanVersionParams.kt index 830ad2fde..4131bea64 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BetaCreatePlanVersionParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BetaCreatePlanVersionParams.kt @@ -543,6 +543,7 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val version: JsonField, private val addAdjustments: JsonField>, @@ -1103,6 +1104,7 @@ private constructor( } class AddAdjustment + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val adjustment: JsonField, private val planPhaseOrder: JsonField, @@ -1671,6 +1673,7 @@ private constructor( } class AddPrice + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val allocationPrice: JsonField, private val planPhaseOrder: JsonField, @@ -3148,6 +3151,7 @@ private constructor( } class TieredWithProration + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val itemId: JsonField, @@ -4336,6 +4340,7 @@ private constructor( /** Configuration for tiered_with_proration pricing */ class TieredWithProrationConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val tiers: JsonField>, private val additionalProperties: MutableMap, @@ -4509,6 +4514,7 @@ private constructor( /** Configuration for a single tiered with proration tier */ class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val tierLowerBound: JsonField, private val unitAmount: JsonField, @@ -4914,6 +4920,7 @@ private constructor( } class GroupedWithMinMaxThresholds + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val groupedWithMinMaxThresholdsConfig: @@ -6121,6 +6128,7 @@ private constructor( /** Configuration for grouped_with_min_max_thresholds pricing */ class GroupedWithMinMaxThresholdsConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val groupingKey: JsonField, private val maximumCharge: JsonField, @@ -6633,6 +6641,7 @@ private constructor( } class RemoveAdjustment + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val adjustmentId: JsonField, private val planPhaseOrder: JsonField, @@ -6850,6 +6859,7 @@ private constructor( } class RemovePrice + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val priceId: JsonField, private val planPhaseOrder: JsonField, @@ -7060,6 +7070,7 @@ private constructor( } class ReplaceAdjustment + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val adjustment: JsonField, private val replacesAdjustmentId: JsonField, @@ -7674,6 +7685,7 @@ private constructor( } class ReplacePrice + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val replacesPriceId: JsonField, private val allocationPrice: JsonField, @@ -9207,6 +9219,7 @@ private constructor( } class TieredWithProration + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val itemId: JsonField, @@ -10395,6 +10408,7 @@ private constructor( /** Configuration for tiered_with_proration pricing */ class TieredWithProrationConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val tiers: JsonField>, private val additionalProperties: MutableMap, @@ -10568,6 +10582,7 @@ private constructor( /** Configuration for a single tiered with proration tier */ class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val tierLowerBound: JsonField, private val unitAmount: JsonField, @@ -10973,6 +10988,7 @@ private constructor( } class GroupedWithMinMaxThresholds + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val groupedWithMinMaxThresholdsConfig: @@ -12180,6 +12196,7 @@ private constructor( /** Configuration for grouped_with_min_max_thresholds pricing */ class GroupedWithMinMaxThresholdsConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val groupingKey: JsonField, private val maximumCharge: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BetaExternalPlanIdCreatePlanVersionParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BetaExternalPlanIdCreatePlanVersionParams.kt index 384d8ce26..a69f5c200 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BetaExternalPlanIdCreatePlanVersionParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BetaExternalPlanIdCreatePlanVersionParams.kt @@ -548,6 +548,7 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val version: JsonField, private val addAdjustments: JsonField>, @@ -1108,6 +1109,7 @@ private constructor( } class AddAdjustment + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val adjustment: JsonField, private val planPhaseOrder: JsonField, @@ -1676,6 +1678,7 @@ private constructor( } class AddPrice + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val allocationPrice: JsonField, private val planPhaseOrder: JsonField, @@ -3153,6 +3156,7 @@ private constructor( } class TieredWithProration + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val itemId: JsonField, @@ -4341,6 +4345,7 @@ private constructor( /** Configuration for tiered_with_proration pricing */ class TieredWithProrationConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val tiers: JsonField>, private val additionalProperties: MutableMap, @@ -4514,6 +4519,7 @@ private constructor( /** Configuration for a single tiered with proration tier */ class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val tierLowerBound: JsonField, private val unitAmount: JsonField, @@ -4919,6 +4925,7 @@ private constructor( } class GroupedWithMinMaxThresholds + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val groupedWithMinMaxThresholdsConfig: @@ -6126,6 +6133,7 @@ private constructor( /** Configuration for grouped_with_min_max_thresholds pricing */ class GroupedWithMinMaxThresholdsConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val groupingKey: JsonField, private val maximumCharge: JsonField, @@ -6638,6 +6646,7 @@ private constructor( } class RemoveAdjustment + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val adjustmentId: JsonField, private val planPhaseOrder: JsonField, @@ -6855,6 +6864,7 @@ private constructor( } class RemovePrice + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val priceId: JsonField, private val planPhaseOrder: JsonField, @@ -7065,6 +7075,7 @@ private constructor( } class ReplaceAdjustment + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val adjustment: JsonField, private val replacesAdjustmentId: JsonField, @@ -7679,6 +7690,7 @@ private constructor( } class ReplacePrice + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val replacesPriceId: JsonField, private val allocationPrice: JsonField, @@ -9212,6 +9224,7 @@ private constructor( } class TieredWithProration + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val itemId: JsonField, @@ -10400,6 +10413,7 @@ private constructor( /** Configuration for tiered_with_proration pricing */ class TieredWithProrationConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val tiers: JsonField>, private val additionalProperties: MutableMap, @@ -10573,6 +10587,7 @@ private constructor( /** Configuration for a single tiered with proration tier */ class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val tierLowerBound: JsonField, private val unitAmount: JsonField, @@ -10978,6 +10993,7 @@ private constructor( } class GroupedWithMinMaxThresholds + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val groupedWithMinMaxThresholdsConfig: @@ -12185,6 +12201,7 @@ private constructor( /** Configuration for grouped_with_min_max_thresholds pricing */ class GroupedWithMinMaxThresholdsConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val groupingKey: JsonField, private val maximumCharge: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BetaExternalPlanIdSetDefaultPlanVersionParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BetaExternalPlanIdSetDefaultPlanVersionParams.kt index d51060f57..22035a2a6 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BetaExternalPlanIdSetDefaultPlanVersionParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BetaExternalPlanIdSetDefaultPlanVersionParams.kt @@ -266,6 +266,7 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val version: JsonField, private val additionalProperties: MutableMap, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BetaSetDefaultPlanVersionParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BetaSetDefaultPlanVersionParams.kt index d0323da90..414351332 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BetaSetDefaultPlanVersionParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BetaSetDefaultPlanVersionParams.kt @@ -263,6 +263,7 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val version: JsonField, private val additionalProperties: MutableMap, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BillableMetric.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BillableMetric.kt index e5cb8020d..532508cf2 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BillableMetric.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BillableMetric.kt @@ -22,6 +22,7 @@ import java.util.Objects * by the query that transforms raw usage events into meaningful values for your customers. */ class BillableMetric +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val description: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BillableMetricTiny.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BillableMetricTiny.kt index 985f4e6ae..9ced8583f 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BillableMetricTiny.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BillableMetricTiny.kt @@ -16,6 +16,7 @@ import java.util.Collections import java.util.Objects class BillableMetricTiny +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val additionalProperties: MutableMap, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BillingCycleAnchorConfiguration.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BillingCycleAnchorConfiguration.kt index 6e531ce23..f7e797c97 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BillingCycleAnchorConfiguration.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BillingCycleAnchorConfiguration.kt @@ -16,6 +16,7 @@ import java.util.Collections import java.util.Objects class BillingCycleAnchorConfiguration +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val day: JsonField, private val month: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BillingCycleConfiguration.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BillingCycleConfiguration.kt index 63235a347..a803a9166 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BillingCycleConfiguration.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BillingCycleConfiguration.kt @@ -17,6 +17,7 @@ import java.util.Collections import java.util.Objects class BillingCycleConfiguration +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val duration: JsonField, private val durationUnit: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BulkConfig.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BulkConfig.kt index 16c86e250..49850b0e7 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BulkConfig.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BulkConfig.kt @@ -19,6 +19,7 @@ import java.util.Objects /** Configuration for bulk pricing */ class BulkConfig +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val tiers: JsonField>, private val additionalProperties: MutableMap, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BulkTier.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BulkTier.kt index f87f68722..28666fb0b 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BulkTier.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BulkTier.kt @@ -17,6 +17,7 @@ import java.util.Objects /** Configuration for a single bulk pricing tier */ class BulkTier +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val unitAmount: JsonField, private val maximumUnits: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/ChangedSubscriptionResources.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/ChangedSubscriptionResources.kt index cd54e43dc..8602b1d09 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/ChangedSubscriptionResources.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/ChangedSubscriptionResources.kt @@ -30,6 +30,7 @@ import java.util.Collections import java.util.Objects class ChangedSubscriptionResources +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val createdCreditNotes: JsonField>, private val createdInvoices: JsonField>, @@ -359,6 +360,7 @@ private constructor( (voidedInvoices.asKnown()?.sumOf { it.validity().toInt() } ?: 0) class CreatedInvoice + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val amountDue: JsonField, @@ -2661,6 +2663,7 @@ private constructor( (if (willAutoIssue.asKnown() == null) 0 else 1) class AutoCollection + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val enabled: JsonField, private val nextAttemptAt: JsonField, @@ -3000,6 +3003,7 @@ private constructor( } class CreditNote + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val creditNoteNumber: JsonField, @@ -3405,6 +3409,7 @@ private constructor( } class CustomerBalanceTransaction + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val action: JsonField, @@ -4417,6 +4422,7 @@ private constructor( } class LineItem + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val adjustedSubtotal: JsonField, @@ -6506,6 +6512,7 @@ private constructor( } class PaymentAttempt + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val amount: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/ConversionRateTier.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/ConversionRateTier.kt index 33dc047f5..8c1a6758e 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/ConversionRateTier.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/ConversionRateTier.kt @@ -16,6 +16,7 @@ import java.util.Collections import java.util.Objects class ConversionRateTier +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val firstUnit: JsonField, private val unitAmount: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/ConversionRateTieredConfig.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/ConversionRateTieredConfig.kt index cfd6a2c16..e0b163c3b 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/ConversionRateTieredConfig.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/ConversionRateTieredConfig.kt @@ -18,6 +18,7 @@ import java.util.Collections import java.util.Objects class ConversionRateTieredConfig +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val tiers: JsonField>, private val additionalProperties: MutableMap, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/ConversionRateUnitConfig.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/ConversionRateUnitConfig.kt index e32462932..210c25c18 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/ConversionRateUnitConfig.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/ConversionRateUnitConfig.kt @@ -16,6 +16,7 @@ import java.util.Collections import java.util.Objects class ConversionRateUnitConfig +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val unitAmount: JsonField, private val additionalProperties: MutableMap, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Coupon.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Coupon.kt index d3a0ba2fc..8a438565c 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Coupon.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Coupon.kt @@ -33,6 +33,7 @@ import java.util.Objects * long it remains available for use by end users. */ class Coupon +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val archivedAt: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CouponCreateParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CouponCreateParams.kt index c9c164517..d0749f79d 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CouponCreateParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CouponCreateParams.kt @@ -397,6 +397,7 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val discount: JsonField, private val redemptionCode: JsonField, @@ -911,6 +912,7 @@ private constructor( } class Percentage + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val discountType: JsonValue, private val percentageDiscount: JsonField, @@ -1123,6 +1125,7 @@ private constructor( } class Amount + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val amountDiscount: JsonField, private val discountType: JsonValue, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CouponListPageResponse.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CouponListPageResponse.kt index be79cf3a3..87e2ab472 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CouponListPageResponse.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CouponListPageResponse.kt @@ -18,6 +18,7 @@ import java.util.Collections import java.util.Objects class CouponListPageResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val data: JsonField>, private val paginationMetadata: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CouponRedemption.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CouponRedemption.kt index 5090071d0..033ad5b57 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CouponRedemption.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CouponRedemption.kt @@ -17,6 +17,7 @@ import java.util.Collections import java.util.Objects class CouponRedemption +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val couponId: JsonField, private val endDate: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CreditBlockExpiryLedgerEntry.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CreditBlockExpiryLedgerEntry.kt index feb6de526..ecd3224cc 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CreditBlockExpiryLedgerEntry.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CreditBlockExpiryLedgerEntry.kt @@ -19,6 +19,7 @@ import java.util.Collections import java.util.Objects class CreditBlockExpiryLedgerEntry +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val amount: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CreditNote.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CreditNote.kt index a98a7f892..4518992f5 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CreditNote.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CreditNote.kt @@ -24,6 +24,7 @@ import java.util.Objects * a particular invoice. */ class CreditNote +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val createdAt: JsonField, @@ -784,6 +785,7 @@ private constructor( (discounts.asKnown()?.sumOf { it.validity().toInt() } ?: 0) class LineItem + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val amount: JsonField, @@ -1318,6 +1320,7 @@ private constructor( (if (startTimeInclusive.asKnown() == null) 0 else 1) class Discount + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val amountApplied: JsonField, @@ -1929,6 +1932,7 @@ private constructor( /** The maximum amount applied on the original invoice */ class MaximumAmountAdjustment + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val amountApplied: JsonField, private val discountType: JsonField, @@ -2367,6 +2371,7 @@ private constructor( } class AppliesToPrice + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val name: JsonField, @@ -2851,6 +2856,7 @@ private constructor( } class Discount + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val amountApplied: JsonField, private val discountType: JsonField, @@ -3289,6 +3295,7 @@ private constructor( } class AppliesToPrice + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val name: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CreditNoteCreateParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CreditNoteCreateParams.kt index 5c0c74029..bc3100336 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CreditNoteCreateParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CreditNoteCreateParams.kt @@ -401,6 +401,7 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val lineItems: JsonField>, private val reason: JsonField, @@ -740,6 +741,7 @@ private constructor( } class LineItem + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val amount: JsonField, private val invoiceLineItemId: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CreditNoteListPageResponse.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CreditNoteListPageResponse.kt index c65672853..33ef8e858 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CreditNoteListPageResponse.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CreditNoteListPageResponse.kt @@ -18,6 +18,7 @@ import java.util.Collections import java.util.Objects class CreditNoteListPageResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val data: JsonField>, private val paginationMetadata: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CreditNoteTiny.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CreditNoteTiny.kt index d4c875ce8..150c55699 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CreditNoteTiny.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CreditNoteTiny.kt @@ -16,6 +16,7 @@ import java.util.Collections import java.util.Objects class CreditNoteTiny +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val additionalProperties: MutableMap, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomExpiration.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomExpiration.kt index e2a79a9c8..6ba138519 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomExpiration.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomExpiration.kt @@ -17,6 +17,7 @@ import java.util.Collections import java.util.Objects class CustomExpiration +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val duration: JsonField, private val durationUnit: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Customer.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Customer.kt index 4931eec10..90d1497ae 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Customer.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Customer.kt @@ -38,6 +38,7 @@ import java.util.Objects * timezone parameter influences within Orb. */ class Customer +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val additionalEmails: JsonField>, @@ -1397,6 +1398,7 @@ private constructor( /** The hierarchical relationships for this customer. */ class Hierarchy + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val children: JsonField>, private val parent: JsonField, @@ -1858,6 +1860,7 @@ private constructor( } class AccountingSyncConfiguration + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val accountingProviders: JsonField>, private val excluded: JsonField, @@ -2057,6 +2060,7 @@ private constructor( (if (excluded.asKnown() == null) 0 else 1) class AccountingProvider + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val externalProviderId: JsonField, private val providerType: JsonField, @@ -2421,6 +2425,7 @@ private constructor( } class ReportingConfiguration + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val exempt: JsonField, private val additionalProperties: MutableMap, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionCreateParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionCreateParams.kt index b080f30b0..af42ee80d 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionCreateParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionCreateParams.kt @@ -314,6 +314,7 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val amount: JsonField, private val type: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionCreateResponse.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionCreateResponse.kt index 7dbc64468..6e64798aa 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionCreateResponse.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionCreateResponse.kt @@ -18,6 +18,7 @@ import java.util.Collections import java.util.Objects class CustomerBalanceTransactionCreateResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val action: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionListPageResponse.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionListPageResponse.kt index 36e8cd899..b8f418d9e 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionListPageResponse.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionListPageResponse.kt @@ -18,6 +18,7 @@ import java.util.Collections import java.util.Objects class CustomerBalanceTransactionListPageResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val data: JsonField>, private val paginationMetadata: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionListResponse.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionListResponse.kt index 4172434b7..1a36133da 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionListResponse.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionListResponse.kt @@ -18,6 +18,7 @@ import java.util.Collections import java.util.Objects class CustomerBalanceTransactionListResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val action: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCostListByExternalIdResponse.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCostListByExternalIdResponse.kt index 272e34f1c..3f59a5344 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCostListByExternalIdResponse.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCostListByExternalIdResponse.kt @@ -18,6 +18,7 @@ import java.util.Collections import java.util.Objects class CustomerCostListByExternalIdResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val data: JsonField>, private val additionalProperties: MutableMap, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCostListResponse.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCostListResponse.kt index aadfd81e2..085343418 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCostListResponse.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCostListResponse.kt @@ -18,6 +18,7 @@ import java.util.Collections import java.util.Objects class CustomerCostListResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val data: JsonField>, private val additionalProperties: MutableMap, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreateParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreateParams.kt index 230dcc18e..b716b3821 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreateParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreateParams.kt @@ -1232,6 +1232,7 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val email: JsonField, private val name: JsonField, @@ -3089,6 +3090,7 @@ private constructor( } class Numeral + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val taxExempt: JsonField, private val taxProvider: JsonValue, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdParams.kt index dc0e65a74..6437950b4 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdParams.kt @@ -615,6 +615,7 @@ private constructor( } class Increment + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val amount: JsonField, private val entryType: JsonValue, @@ -1134,6 +1135,7 @@ private constructor( * the calculation of the invoice total is done on that basis. */ class InvoiceSettings + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val autoCollection: JsonField, private val netTerms: JsonField, @@ -2088,6 +2090,7 @@ private constructor( } class Decrement + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val amount: JsonField, private val entryType: JsonValue, @@ -2546,6 +2549,7 @@ private constructor( } class ExpirationChange + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val entryType: JsonValue, private val targetExpiryDate: JsonField, @@ -3158,6 +3162,7 @@ private constructor( } class Void + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val amount: JsonField, private val blockId: JsonField, @@ -3835,6 +3840,7 @@ private constructor( } class Amendment + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val amount: JsonField, private val blockId: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryParams.kt index 5e8c49996..53d7256e3 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryParams.kt @@ -610,6 +610,7 @@ private constructor( } class Increment + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val amount: JsonField, private val entryType: JsonValue, @@ -1129,6 +1130,7 @@ private constructor( * the calculation of the invoice total is done on that basis. */ class InvoiceSettings + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val autoCollection: JsonField, private val netTerms: JsonField, @@ -2083,6 +2085,7 @@ private constructor( } class Decrement + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val amount: JsonField, private val entryType: JsonValue, @@ -2541,6 +2544,7 @@ private constructor( } class ExpirationChange + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val entryType: JsonValue, private val targetExpiryDate: JsonField, @@ -3153,6 +3157,7 @@ private constructor( } class Void + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val amount: JsonField, private val blockId: JsonField, @@ -3830,6 +3835,7 @@ private constructor( } class Amendment + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val amount: JsonField, private val blockId: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdPageResponse.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdPageResponse.kt index da019361d..97914623d 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdPageResponse.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdPageResponse.kt @@ -18,6 +18,7 @@ import java.util.Collections import java.util.Objects class CustomerCreditLedgerListByExternalIdPageResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val data: JsonField>, private val paginationMetadata: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListPageResponse.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListPageResponse.kt index 9a4ce4176..8c1f2daa3 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListPageResponse.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListPageResponse.kt @@ -18,6 +18,7 @@ import java.util.Collections import java.util.Objects class CustomerCreditLedgerListPageResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val data: JsonField>, private val paginationMetadata: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdPageResponse.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdPageResponse.kt index fe4444ead..2da2b405a 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdPageResponse.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdPageResponse.kt @@ -18,6 +18,7 @@ import java.util.Collections import java.util.Objects class CustomerCreditListByExternalIdPageResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val data: JsonField>, private val paginationMetadata: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdResponse.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdResponse.kt index 97f093015..12d7b7cc2 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdResponse.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdResponse.kt @@ -18,6 +18,7 @@ import java.util.Collections import java.util.Objects class CustomerCreditListByExternalIdResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val balance: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListPageResponse.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListPageResponse.kt index cc4d3f143..1c8bf0023 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListPageResponse.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListPageResponse.kt @@ -18,6 +18,7 @@ import java.util.Collections import java.util.Objects class CustomerCreditListPageResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val data: JsonField>, private val paginationMetadata: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListResponse.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListResponse.kt index 4c8617e4b..12fcc9a07 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListResponse.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListResponse.kt @@ -18,6 +18,7 @@ import java.util.Collections import java.util.Objects class CustomerCreditListResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val balance: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpCreateByExternalIdParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpCreateByExternalIdParams.kt index 82bd83504..cd3048b14 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpCreateByExternalIdParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpCreateByExternalIdParams.kt @@ -511,6 +511,7 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val amount: JsonField, private val currency: JsonField, @@ -1011,6 +1012,7 @@ private constructor( /** Settings for invoices generated by triggered top-ups. */ class InvoiceSettings + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val autoCollection: JsonField, private val netTerms: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpCreateByExternalIdResponse.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpCreateByExternalIdResponse.kt index 065786212..8859a6e07 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpCreateByExternalIdResponse.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpCreateByExternalIdResponse.kt @@ -17,6 +17,7 @@ import java.util.Collections import java.util.Objects class CustomerCreditTopUpCreateByExternalIdResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val amount: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpCreateParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpCreateParams.kt index 1e3c579a3..c01272718 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpCreateParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpCreateParams.kt @@ -507,6 +507,7 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val amount: JsonField, private val currency: JsonField, @@ -1007,6 +1008,7 @@ private constructor( /** Settings for invoices generated by triggered top-ups. */ class InvoiceSettings + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val autoCollection: JsonField, private val netTerms: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpCreateResponse.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpCreateResponse.kt index d76a547b4..51e385def 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpCreateResponse.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpCreateResponse.kt @@ -17,6 +17,7 @@ import java.util.Collections import java.util.Objects class CustomerCreditTopUpCreateResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val amount: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListByExternalIdPageResponse.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListByExternalIdPageResponse.kt index d24512049..2ddf634ad 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListByExternalIdPageResponse.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListByExternalIdPageResponse.kt @@ -18,6 +18,7 @@ import java.util.Collections import java.util.Objects class CustomerCreditTopUpListByExternalIdPageResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val data: JsonField>, private val paginationMetadata: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListByExternalIdResponse.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListByExternalIdResponse.kt index 2715c1ab3..f88cb1588 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListByExternalIdResponse.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListByExternalIdResponse.kt @@ -17,6 +17,7 @@ import java.util.Collections import java.util.Objects class CustomerCreditTopUpListByExternalIdResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val amount: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListPageResponse.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListPageResponse.kt index 4682a91f0..91a2363cf 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListPageResponse.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListPageResponse.kt @@ -18,6 +18,7 @@ import java.util.Collections import java.util.Objects class CustomerCreditTopUpListPageResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val data: JsonField>, private val paginationMetadata: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListResponse.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListResponse.kt index 56bce2465..e69eeaafd 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListResponse.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListResponse.kt @@ -17,6 +17,7 @@ import java.util.Collections import java.util.Objects class CustomerCreditTopUpListResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val amount: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerHierarchyConfig.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerHierarchyConfig.kt index cf699aa71..97156aa30 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerHierarchyConfig.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerHierarchyConfig.kt @@ -17,6 +17,7 @@ import java.util.Collections import java.util.Objects class CustomerHierarchyConfig +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val childCustomerIds: JsonField>, private val parentCustomerId: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerListPageResponse.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerListPageResponse.kt index 7e514fb09..61c03dc7a 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerListPageResponse.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerListPageResponse.kt @@ -18,6 +18,7 @@ import java.util.Collections import java.util.Objects class CustomerListPageResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val data: JsonField>, private val paginationMetadata: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerMinified.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerMinified.kt index 7305e46e5..ad20e3643 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerMinified.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerMinified.kt @@ -16,6 +16,7 @@ import java.util.Collections import java.util.Objects class CustomerMinified +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val externalCustomerId: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerTaxId.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerTaxId.kt index 90c7b56d3..789be664d 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerTaxId.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerTaxId.kt @@ -162,6 +162,7 @@ import java.util.Objects * |Zimbabwe |`zw_tin` |Zimbabwe Tax Identification Number | */ class CustomerTaxId +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val country: JsonField, private val type: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerUpdateByExternalIdParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerUpdateByExternalIdParams.kt index e3c5bdfe9..c66f03d3a 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerUpdateByExternalIdParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerUpdateByExternalIdParams.kt @@ -1202,6 +1202,7 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val accountingSyncConfiguration: JsonField, private val additionalEmails: JsonField>, @@ -3007,6 +3008,7 @@ private constructor( } class Numeral + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val taxExempt: JsonField, private val taxProvider: JsonValue, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerUpdateParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerUpdateParams.kt index 2ef76c208..9030dabd2 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerUpdateParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerUpdateParams.kt @@ -1198,6 +1198,7 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val accountingSyncConfiguration: JsonField, private val additionalEmails: JsonField>, @@ -3003,6 +3004,7 @@ private constructor( } class Numeral + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val taxExempt: JsonField, private val taxProvider: JsonValue, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/DecrementLedgerEntry.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/DecrementLedgerEntry.kt index 1ec2a430e..6d0b26325 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/DecrementLedgerEntry.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/DecrementLedgerEntry.kt @@ -19,6 +19,7 @@ import java.util.Collections import java.util.Objects class DecrementLedgerEntry +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val amount: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceConfiguration.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceConfiguration.kt index 0cd09de02..bdebb97b8 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceConfiguration.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceConfiguration.kt @@ -18,6 +18,7 @@ import java.util.Collections import java.util.Objects class DimensionalPriceConfiguration +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val dimensionValues: JsonField>, private val dimensionalPriceGroupId: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroup.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroup.kt index 15f9aa955..7f20c1500 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroup.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroup.kt @@ -22,6 +22,7 @@ import java.util.Objects * dimensions. Prices in a price group must specify the parition used to derive their usage. */ class DimensionalPriceGroup +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val billableMetricId: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroupCreateParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroupCreateParams.kt index 981b62372..192835cad 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroupCreateParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroupCreateParams.kt @@ -387,6 +387,7 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val billableMetricId: JsonField, private val dimensions: JsonField>, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroupExternalDimensionalPriceGroupIdUpdateParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroupExternalDimensionalPriceGroupIdUpdateParams.kt index 1febf873a..681ece4ba 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroupExternalDimensionalPriceGroupIdUpdateParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroupExternalDimensionalPriceGroupIdUpdateParams.kt @@ -313,6 +313,7 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val bodyExternalDimensionalPriceGroupId: JsonField, private val metadata: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroupUpdateParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroupUpdateParams.kt index a82c3b3c1..9ba8b805a 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroupUpdateParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroupUpdateParams.kt @@ -302,6 +302,7 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val externalDimensionalPriceGroupId: JsonField, private val metadata: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroups.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroups.kt index 75d7344f2..82e9c1212 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroups.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroups.kt @@ -18,6 +18,7 @@ import java.util.Collections import java.util.Objects class DimensionalPriceGroups +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val data: JsonField>, private val paginationMetadata: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/DiscountOverride.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/DiscountOverride.kt index a7bd9e31d..6b7970b5d 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/DiscountOverride.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/DiscountOverride.kt @@ -17,6 +17,7 @@ import java.util.Collections import java.util.Objects class DiscountOverride +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val discountType: JsonField, private val amountDiscount: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EvaluatePriceGroup.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EvaluatePriceGroup.kt index 6c92a6a59..e89a6ce43 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EvaluatePriceGroup.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EvaluatePriceGroup.kt @@ -29,6 +29,7 @@ import java.util.Collections import java.util.Objects class EvaluatePriceGroup +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val amount: JsonField, private val groupingValues: JsonField>, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventBackfillCloseResponse.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventBackfillCloseResponse.kt index 74a8023df..50219ab9a 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventBackfillCloseResponse.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventBackfillCloseResponse.kt @@ -22,6 +22,7 @@ import java.util.Objects * timeframe. */ class EventBackfillCloseResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val closeTime: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventBackfillCreateParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventBackfillCreateParams.kt index a27f555ed..f09382e8e 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventBackfillCreateParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventBackfillCreateParams.kt @@ -496,6 +496,7 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val timeframeEnd: JsonField, private val timeframeStart: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventBackfillCreateResponse.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventBackfillCreateResponse.kt index 0bd9c59d5..6c2b86ccd 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventBackfillCreateResponse.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventBackfillCreateResponse.kt @@ -22,6 +22,7 @@ import java.util.Objects * timeframe. */ class EventBackfillCreateResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val closeTime: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventBackfillFetchResponse.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventBackfillFetchResponse.kt index 1fbb32e43..46d1dfd4a 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventBackfillFetchResponse.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventBackfillFetchResponse.kt @@ -22,6 +22,7 @@ import java.util.Objects * timeframe. */ class EventBackfillFetchResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val closeTime: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventBackfillListPageResponse.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventBackfillListPageResponse.kt index 0a9442c5e..5c6dddd35 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventBackfillListPageResponse.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventBackfillListPageResponse.kt @@ -18,6 +18,7 @@ import java.util.Collections import java.util.Objects class EventBackfillListPageResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val data: JsonField>, private val paginationMetadata: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventBackfillListResponse.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventBackfillListResponse.kt index f0347cd2b..89a70c831 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventBackfillListResponse.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventBackfillListResponse.kt @@ -22,6 +22,7 @@ import java.util.Objects * timeframe. */ class EventBackfillListResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val closeTime: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventBackfillRevertResponse.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventBackfillRevertResponse.kt index d057db10c..ec2db19f7 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventBackfillRevertResponse.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventBackfillRevertResponse.kt @@ -22,6 +22,7 @@ import java.util.Objects * timeframe. */ class EventBackfillRevertResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val closeTime: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventDeprecateResponse.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventDeprecateResponse.kt index 3613faf98..c786d6ed8 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventDeprecateResponse.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventDeprecateResponse.kt @@ -16,6 +16,7 @@ import java.util.Collections import java.util.Objects class EventDeprecateResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val deprecated: JsonField, private val additionalProperties: MutableMap, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventIngestParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventIngestParams.kt index 86c03be14..c39062d41 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventIngestParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventIngestParams.kt @@ -476,6 +476,7 @@ private constructor( .build() class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val events: JsonField>, private val additionalProperties: MutableMap, @@ -645,6 +646,7 @@ private constructor( } class Event + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val eventName: JsonField, private val idempotencyKey: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventIngestResponse.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventIngestResponse.kt index 49baff79d..c79fbc638 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventIngestResponse.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventIngestResponse.kt @@ -18,6 +18,7 @@ import java.util.Collections import java.util.Objects class EventIngestResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val validationFailed: JsonField>, private val debug: JsonField, @@ -219,6 +220,7 @@ private constructor( (debug.asKnown()?.validity() ?: 0) class ValidationFailed + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val idempotencyKey: JsonField, private val validationErrors: JsonField>, @@ -450,6 +452,7 @@ private constructor( * ingested and duplicate event idempotency keys. */ class Debug + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val duplicate: JsonField>, private val ingested: JsonField>, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventSearchParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventSearchParams.kt index 1588735c1..84d4db66f 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventSearchParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventSearchParams.kt @@ -341,6 +341,7 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val eventIds: JsonField>, private val timeframeEnd: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventSearchResponse.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventSearchResponse.kt index 2afcf1f1c..6839236de 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventSearchResponse.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventSearchResponse.kt @@ -19,6 +19,7 @@ import java.util.Collections import java.util.Objects class EventSearchResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val data: JsonField>, private val additionalProperties: MutableMap, @@ -172,6 +173,7 @@ private constructor( * the usage charges for a given billing period. */ class Data + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val customerId: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventUpdateParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventUpdateParams.kt index e0c763677..507414c8d 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventUpdateParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventUpdateParams.kt @@ -428,6 +428,7 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val eventName: JsonField, private val properties: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventUpdateResponse.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventUpdateResponse.kt index 3ebe8cc8e..5b55f1a5e 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventUpdateResponse.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventUpdateResponse.kt @@ -16,6 +16,7 @@ import java.util.Collections import java.util.Objects class EventUpdateResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val amended: JsonField, private val additionalProperties: MutableMap, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventVolumes.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventVolumes.kt index 8c1340f69..cab0c8cbd 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventVolumes.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventVolumes.kt @@ -19,6 +19,7 @@ import java.util.Collections import java.util.Objects class EventVolumes +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val data: JsonField>, private val additionalProperties: MutableMap, @@ -171,6 +172,7 @@ private constructor( * the aggregation is the `timestamp` datetime field on events. */ class Data + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val count: JsonField, private val timeframeEnd: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/ExpirationChangeLedgerEntry.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/ExpirationChangeLedgerEntry.kt index 7cdf2354e..c2f47fc30 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/ExpirationChangeLedgerEntry.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/ExpirationChangeLedgerEntry.kt @@ -19,6 +19,7 @@ import java.util.Collections import java.util.Objects class ExpirationChangeLedgerEntry +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val amount: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/FixedFeeQuantityScheduleEntry.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/FixedFeeQuantityScheduleEntry.kt index b78c08073..fcedfc94e 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/FixedFeeQuantityScheduleEntry.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/FixedFeeQuantityScheduleEntry.kt @@ -17,6 +17,7 @@ import java.util.Collections import java.util.Objects class FixedFeeQuantityScheduleEntry +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val endDate: JsonField, private val priceId: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/FixedFeeQuantityTransition.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/FixedFeeQuantityTransition.kt index 1f40f7693..37a3f6c98 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/FixedFeeQuantityTransition.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/FixedFeeQuantityTransition.kt @@ -17,6 +17,7 @@ import java.util.Collections import java.util.Objects class FixedFeeQuantityTransition +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val effectiveDate: JsonField, private val priceId: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/IncrementLedgerEntry.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/IncrementLedgerEntry.kt index 2dbd5b4da..a6eb27650 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/IncrementLedgerEntry.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/IncrementLedgerEntry.kt @@ -20,6 +20,7 @@ import java.util.Collections import java.util.Objects class IncrementLedgerEntry +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val amount: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Invoice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Invoice.kt index 16f7c0e71..b2b66b8b3 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Invoice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Invoice.kt @@ -37,6 +37,7 @@ import java.util.Objects * cancellation. */ class Invoice +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val amountDue: JsonField, @@ -2238,6 +2239,7 @@ private constructor( (if (willAutoIssue.asKnown() == null) 0 else 1) class AutoCollection + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val enabled: JsonField, private val nextAttemptAt: JsonField, @@ -2568,6 +2570,7 @@ private constructor( } class CreditNote + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val creditNoteNumber: JsonField, @@ -2960,6 +2963,7 @@ private constructor( } class CustomerBalanceTransaction + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val action: JsonField, @@ -3945,6 +3949,7 @@ private constructor( } class LineItem + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val adjustedSubtotal: JsonField, @@ -5961,6 +5966,7 @@ private constructor( } class PaymentAttempt + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val amount: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceCreateParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceCreateParams.kt index 1cfb06679..613a3f96b 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceCreateParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceCreateParams.kt @@ -648,6 +648,7 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val currency: JsonField, private val invoiceDate: JsonField, @@ -1356,6 +1357,7 @@ private constructor( } class LineItem + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val endDate: JsonField, private val itemId: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceFetchUpcomingResponse.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceFetchUpcomingResponse.kt index 896e8a236..37a678e73 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceFetchUpcomingResponse.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceFetchUpcomingResponse.kt @@ -30,6 +30,7 @@ import java.util.Collections import java.util.Objects class InvoiceFetchUpcomingResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val amountDue: JsonField, @@ -2232,6 +2233,7 @@ private constructor( (if (willAutoIssue.asKnown() == null) 0 else 1) class AutoCollection + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val enabled: JsonField, private val nextAttemptAt: JsonField, @@ -2562,6 +2564,7 @@ private constructor( } class CreditNote + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val creditNoteNumber: JsonField, @@ -2954,6 +2957,7 @@ private constructor( } class CustomerBalanceTransaction + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val action: JsonField, @@ -3939,6 +3943,7 @@ private constructor( } class LineItem + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val adjustedSubtotal: JsonField, @@ -5955,6 +5960,7 @@ private constructor( } class PaymentAttempt + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val amount: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceIssueParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceIssueParams.kt index 32bddb49f..efc0c2aee 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceIssueParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceIssueParams.kt @@ -257,6 +257,7 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val synchronous: JsonField, private val additionalProperties: MutableMap, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceLineItemCreateParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceLineItemCreateParams.kt index 0accc2cf6..dc7334883 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceLineItemCreateParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceLineItemCreateParams.kt @@ -397,6 +397,7 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val amount: JsonField, private val endDate: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceLineItemCreateResponse.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceLineItemCreateResponse.kt index 61e610846..c41d8f094 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceLineItemCreateResponse.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceLineItemCreateResponse.kt @@ -29,6 +29,7 @@ import java.util.Collections import java.util.Objects class InvoiceLineItemCreateResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val adjustedSubtotal: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceListPageResponse.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceListPageResponse.kt index fcb1cf666..14455bd37 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceListPageResponse.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceListPageResponse.kt @@ -18,6 +18,7 @@ import java.util.Collections import java.util.Objects class InvoiceListPageResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val data: JsonField>, private val paginationMetadata: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceMarkPaidParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceMarkPaidParams.kt index 46a2b356d..ea39f03c7 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceMarkPaidParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceMarkPaidParams.kt @@ -320,6 +320,7 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val paymentReceivedDate: JsonField, private val externalId: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceTiny.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceTiny.kt index 5bab311e2..aed6adb9e 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceTiny.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceTiny.kt @@ -16,6 +16,7 @@ import java.util.Collections import java.util.Objects class InvoiceTiny +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val additionalProperties: MutableMap, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceUpdateParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceUpdateParams.kt index 8e1b4a1f7..5a3a8db24 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceUpdateParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceUpdateParams.kt @@ -351,6 +351,7 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val dueDate: JsonField, private val metadata: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Item.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Item.kt index 8f5eb9b5a..4d2b31a31 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Item.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Item.kt @@ -25,6 +25,7 @@ import java.util.Objects * and tax calculation purposes. */ class Item +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val createdAt: JsonField, @@ -325,6 +326,7 @@ private constructor( (if (name.asKnown() == null) 0 else 1) class ExternalConnection + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val externalConnectionName: JsonField, private val externalEntityId: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/ItemCreateParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/ItemCreateParams.kt index 6c0150e71..99a353fb6 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/ItemCreateParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/ItemCreateParams.kt @@ -272,6 +272,7 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val name: JsonField, private val metadata: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/ItemListPageResponse.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/ItemListPageResponse.kt index 71d2063ce..aa627cf09 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/ItemListPageResponse.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/ItemListPageResponse.kt @@ -18,6 +18,7 @@ import java.util.Collections import java.util.Objects class ItemListPageResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val data: JsonField>, private val paginationMetadata: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/ItemSlim.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/ItemSlim.kt index ffa37fdd9..568f85d90 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/ItemSlim.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/ItemSlim.kt @@ -16,6 +16,7 @@ import java.util.Collections import java.util.Objects class ItemSlim +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val name: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/ItemUpdateParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/ItemUpdateParams.kt index 73d0b1673..a7ca005ad 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/ItemUpdateParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/ItemUpdateParams.kt @@ -321,6 +321,7 @@ private constructor( * replace the existing item mappings. */ class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val externalConnections: JsonField>, private val metadata: JsonField, @@ -561,6 +562,7 @@ private constructor( } class ExternalConnection + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val externalConnectionName: JsonField, private val externalEntityId: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MatrixConfig.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MatrixConfig.kt index 49eea695f..2174f5b94 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MatrixConfig.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MatrixConfig.kt @@ -19,6 +19,7 @@ import java.util.Objects /** Configuration for matrix pricing */ class MatrixConfig +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val defaultUnitAmount: JsonField, private val dimensions: JsonField>, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MatrixSubLineItem.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MatrixSubLineItem.kt index a43c4e064..e90ba657b 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MatrixSubLineItem.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MatrixSubLineItem.kt @@ -17,6 +17,7 @@ import java.util.Collections import java.util.Objects class MatrixSubLineItem +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val amount: JsonField, private val grouping: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MatrixValue.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MatrixValue.kt index 1d4c1ff7a..acb4e7b98 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MatrixValue.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MatrixValue.kt @@ -19,6 +19,7 @@ import java.util.Objects /** Configuration for a single matrix value */ class MatrixValue +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val dimensionValues: JsonField>, private val unitAmount: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MatrixWithAllocationConfig.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MatrixWithAllocationConfig.kt index 8a3454a40..03e8c83d3 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MatrixWithAllocationConfig.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MatrixWithAllocationConfig.kt @@ -19,6 +19,7 @@ import java.util.Objects /** Configuration for matrix pricing with usage allocation */ class MatrixWithAllocationConfig +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val allocation: JsonField, private val defaultUnitAmount: JsonField, @@ -313,6 +314,7 @@ private constructor( /** Configuration for a single matrix value */ class MatrixValue + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val dimensionValues: JsonField>, private val unitAmount: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Maximum.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Maximum.kt index 6c3f797f0..88df14fb7 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Maximum.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Maximum.kt @@ -18,6 +18,7 @@ import java.util.Collections import java.util.Objects class Maximum +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val appliesToPriceIds: JsonField>, private val filters: JsonField>, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MaximumInterval.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MaximumInterval.kt index 024f2110f..31790bbc1 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MaximumInterval.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MaximumInterval.kt @@ -19,6 +19,7 @@ import java.util.Collections import java.util.Objects class MaximumInterval +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val appliesToPriceIntervalIds: JsonField>, private val endDate: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MetricCreateParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MetricCreateParams.kt index ee54ab4d3..a6f20a939 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MetricCreateParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MetricCreateParams.kt @@ -369,6 +369,7 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val description: JsonField, private val itemId: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MetricListPageResponse.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MetricListPageResponse.kt index ccccf45aa..0fc606b02 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MetricListPageResponse.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MetricListPageResponse.kt @@ -18,6 +18,7 @@ import java.util.Collections import java.util.Objects class MetricListPageResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val data: JsonField>, private val paginationMetadata: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MetricUpdateParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MetricUpdateParams.kt index 2cf32a02c..f8d11b24f 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MetricUpdateParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MetricUpdateParams.kt @@ -253,6 +253,7 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val metadata: JsonField, private val additionalProperties: MutableMap, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Minimum.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Minimum.kt index e6c1a9e84..81dc73944 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Minimum.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Minimum.kt @@ -18,6 +18,7 @@ import java.util.Collections import java.util.Objects class Minimum +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val appliesToPriceIds: JsonField>, private val filters: JsonField>, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MinimumInterval.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MinimumInterval.kt index 4f6929321..89d0f106f 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MinimumInterval.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MinimumInterval.kt @@ -19,6 +19,7 @@ import java.util.Collections import java.util.Objects class MinimumInterval +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val appliesToPriceIntervalIds: JsonField>, private val endDate: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MonetaryAmountDiscountAdjustment.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MonetaryAmountDiscountAdjustment.kt index f7de6d732..9eb874d20 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MonetaryAmountDiscountAdjustment.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MonetaryAmountDiscountAdjustment.kt @@ -19,6 +19,7 @@ import java.util.Collections import java.util.Objects class MonetaryAmountDiscountAdjustment +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val adjustmentType: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MonetaryMaximumAdjustment.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MonetaryMaximumAdjustment.kt index 55b70f78d..de8229531 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MonetaryMaximumAdjustment.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MonetaryMaximumAdjustment.kt @@ -19,6 +19,7 @@ import java.util.Collections import java.util.Objects class MonetaryMaximumAdjustment +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val adjustmentType: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MonetaryMinimumAdjustment.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MonetaryMinimumAdjustment.kt index 3589f5606..630a06ca6 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MonetaryMinimumAdjustment.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MonetaryMinimumAdjustment.kt @@ -19,6 +19,7 @@ import java.util.Collections import java.util.Objects class MonetaryMinimumAdjustment +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val adjustmentType: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MonetaryPercentageDiscountAdjustment.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MonetaryPercentageDiscountAdjustment.kt index e88a208f4..334086584 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MonetaryPercentageDiscountAdjustment.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MonetaryPercentageDiscountAdjustment.kt @@ -19,6 +19,7 @@ import java.util.Collections import java.util.Objects class MonetaryPercentageDiscountAdjustment +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val adjustmentType: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MonetaryUsageDiscountAdjustment.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MonetaryUsageDiscountAdjustment.kt index b18464077..667eec5ed 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MonetaryUsageDiscountAdjustment.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MonetaryUsageDiscountAdjustment.kt @@ -19,6 +19,7 @@ import java.util.Collections import java.util.Objects class MonetaryUsageDiscountAdjustment +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val adjustmentType: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MutatedSubscription.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MutatedSubscription.kt index 3392c7225..12aeeccd9 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MutatedSubscription.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MutatedSubscription.kt @@ -30,6 +30,7 @@ import java.util.Collections import java.util.Objects class MutatedSubscription +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val activePlanPhaseOrder: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewAccountingSyncConfiguration.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewAccountingSyncConfiguration.kt index 5268983e0..1674ea40f 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewAccountingSyncConfiguration.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewAccountingSyncConfiguration.kt @@ -17,6 +17,7 @@ import java.util.Collections import java.util.Objects class NewAccountingSyncConfiguration +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val accountingProviders: JsonField>, private val excluded: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewAllocationPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewAllocationPrice.kt index bb8b5808d..18c13df03 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewAllocationPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewAllocationPrice.kt @@ -17,6 +17,7 @@ import java.util.Collections import java.util.Objects class NewAllocationPrice +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val amount: JsonField, private val cadence: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewAmountDiscount.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewAmountDiscount.kt index c384b3181..2c741bf25 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewAmountDiscount.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewAmountDiscount.kt @@ -19,6 +19,7 @@ import java.util.Collections import java.util.Objects class NewAmountDiscount +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val adjustmentType: JsonField, private val amountDiscount: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewAvalaraTaxConfiguration.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewAvalaraTaxConfiguration.kt index 1ae5e7ea8..709d9b883 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewAvalaraTaxConfiguration.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewAvalaraTaxConfiguration.kt @@ -17,6 +17,7 @@ import java.util.Collections import java.util.Objects class NewAvalaraTaxConfiguration +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val taxExempt: JsonField, private val taxProvider: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewBillingCycleConfiguration.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewBillingCycleConfiguration.kt index 7ddb38a6b..0070f7c1d 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewBillingCycleConfiguration.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewBillingCycleConfiguration.kt @@ -17,6 +17,7 @@ import java.util.Collections import java.util.Objects class NewBillingCycleConfiguration +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val duration: JsonField, private val durationUnit: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewDimensionalPriceConfiguration.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewDimensionalPriceConfiguration.kt index c83f14fcd..463245414 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewDimensionalPriceConfiguration.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewDimensionalPriceConfiguration.kt @@ -18,6 +18,7 @@ import java.util.Collections import java.util.Objects class NewDimensionalPriceConfiguration +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val dimensionValues: JsonField>, private val dimensionalPriceGroupId: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingBulkPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingBulkPrice.kt index ff78ce223..64a979ece 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingBulkPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingBulkPrice.kt @@ -18,6 +18,7 @@ import java.util.Collections import java.util.Objects class NewFloatingBulkPrice +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val bulkConfig: JsonField, private val cadence: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingBulkWithProrationPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingBulkWithProrationPrice.kt index 3c46c9857..79143b0ba 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingBulkWithProrationPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingBulkWithProrationPrice.kt @@ -19,6 +19,7 @@ import java.util.Collections import java.util.Objects class NewFloatingBulkWithProrationPrice +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val bulkWithProrationConfig: JsonField, private val cadence: JsonField, @@ -916,6 +917,7 @@ private constructor( /** Configuration for bulk_with_proration pricing */ class BulkWithProrationConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val tiers: JsonField>, private val additionalProperties: MutableMap, @@ -1070,6 +1072,7 @@ private constructor( /** Configuration for a single bulk pricing tier with proration */ class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val unitAmount: JsonField, private val tierLowerBound: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingCumulativeGroupedBulkPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingCumulativeGroupedBulkPrice.kt index cf2baf868..56c456f24 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingCumulativeGroupedBulkPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingCumulativeGroupedBulkPrice.kt @@ -19,6 +19,7 @@ import java.util.Collections import java.util.Objects class NewFloatingCumulativeGroupedBulkPrice +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val cumulativeGroupedBulkConfig: JsonField, @@ -1067,6 +1068,7 @@ private constructor( /** Configuration for cumulative_grouped_bulk pricing */ class CumulativeGroupedBulkConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val dimensionValues: JsonField>, private val group: JsonField, @@ -1268,6 +1270,7 @@ private constructor( /** Configuration for a dimension value entry */ class DimensionValue + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val groupingKey: JsonField, private val tierLowerBound: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingGroupedAllocationPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingGroupedAllocationPrice.kt index 7046cad33..8462624bb 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingGroupedAllocationPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingGroupedAllocationPrice.kt @@ -18,6 +18,7 @@ import java.util.Collections import java.util.Objects class NewFloatingGroupedAllocationPrice +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val currency: JsonField, @@ -1064,6 +1065,7 @@ private constructor( /** Configuration for grouped_allocation pricing */ class GroupedAllocationConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val allocation: JsonField, private val groupingKey: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingGroupedTieredPackagePrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingGroupedTieredPackagePrice.kt index 647ba532b..e7ce8f3aa 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingGroupedTieredPackagePrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingGroupedTieredPackagePrice.kt @@ -19,6 +19,7 @@ import java.util.Collections import java.util.Objects class NewFloatingGroupedTieredPackagePrice +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val currency: JsonField, @@ -1067,6 +1068,7 @@ private constructor( /** Configuration for grouped_tiered_package pricing */ class GroupedTieredPackageConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val groupingKey: JsonField, private val packageSize: JsonField, @@ -1312,6 +1314,7 @@ private constructor( /** Configuration for a single tier */ class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val perUnit: JsonField, private val tierLowerBound: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingGroupedTieredPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingGroupedTieredPrice.kt index 204446e99..7cae4bdfe 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingGroupedTieredPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingGroupedTieredPrice.kt @@ -19,6 +19,7 @@ import java.util.Collections import java.util.Objects class NewFloatingGroupedTieredPrice +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val currency: JsonField, @@ -1060,6 +1061,7 @@ private constructor( /** Configuration for grouped_tiered pricing */ class GroupedTieredConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val groupingKey: JsonField, private val tiers: JsonField>, @@ -1259,6 +1261,7 @@ private constructor( /** Configuration for a single tier */ class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val tierLowerBound: JsonField, private val unitAmount: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingGroupedWithMeteredMinimumPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingGroupedWithMeteredMinimumPrice.kt index 48b30ee9e..e398dbe78 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingGroupedWithMeteredMinimumPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingGroupedWithMeteredMinimumPrice.kt @@ -19,6 +19,7 @@ import java.util.Collections import java.util.Objects class NewFloatingGroupedWithMeteredMinimumPrice +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val currency: JsonField, @@ -1070,6 +1071,7 @@ private constructor( /** Configuration for grouped_with_metered_minimum pricing */ class GroupedWithMeteredMinimumConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val groupingKey: JsonField, private val minimumUnitAmount: JsonField, @@ -1470,6 +1472,7 @@ private constructor( /** Configuration for a scaling factor */ class ScalingFactor + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val scalingFactor: JsonField, private val scalingValue: JsonField, @@ -1688,6 +1691,7 @@ private constructor( /** Configuration for a unit amount */ class UnitAmount + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val pricingValue: JsonField, private val unitAmount: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingGroupedWithProratedMinimumPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingGroupedWithProratedMinimumPrice.kt index 6d06d7192..2b2c17136 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingGroupedWithProratedMinimumPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingGroupedWithProratedMinimumPrice.kt @@ -18,6 +18,7 @@ import java.util.Collections import java.util.Objects class NewFloatingGroupedWithProratedMinimumPrice +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val currency: JsonField, @@ -1069,6 +1070,7 @@ private constructor( /** Configuration for grouped_with_prorated_minimum pricing */ class GroupedWithProratedMinimumConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val groupingKey: JsonField, private val minimum: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingMatrixPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingMatrixPrice.kt index 12fcd4e34..22a6cb68e 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingMatrixPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingMatrixPrice.kt @@ -18,6 +18,7 @@ import java.util.Collections import java.util.Objects class NewFloatingMatrixPrice +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val currency: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingMatrixWithAllocationPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingMatrixWithAllocationPrice.kt index 9e92652dd..3dc9bdce0 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingMatrixWithAllocationPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingMatrixWithAllocationPrice.kt @@ -18,6 +18,7 @@ import java.util.Collections import java.util.Objects class NewFloatingMatrixWithAllocationPrice +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val currency: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingMatrixWithDisplayNamePrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingMatrixWithDisplayNamePrice.kt index 52fc0b8d0..4f282c571 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingMatrixWithDisplayNamePrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingMatrixWithDisplayNamePrice.kt @@ -19,6 +19,7 @@ import java.util.Collections import java.util.Objects class NewFloatingMatrixWithDisplayNamePrice +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val currency: JsonField, @@ -1067,6 +1068,7 @@ private constructor( /** Configuration for matrix_with_display_name pricing */ class MatrixWithDisplayNameConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val dimension: JsonField, private val unitAmounts: JsonField>, @@ -1266,6 +1268,7 @@ private constructor( /** Configuration for a unit amount item */ class UnitAmount + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val dimensionValue: JsonField, private val displayName: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingMaxGroupTieredPackagePrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingMaxGroupTieredPackagePrice.kt index 8e681e430..884401bca 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingMaxGroupTieredPackagePrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingMaxGroupTieredPackagePrice.kt @@ -19,6 +19,7 @@ import java.util.Collections import java.util.Objects class NewFloatingMaxGroupTieredPackagePrice +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val currency: JsonField, @@ -1067,6 +1068,7 @@ private constructor( /** Configuration for max_group_tiered_package pricing */ class MaxGroupTieredPackageConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val groupingKey: JsonField, private val packageSize: JsonField, @@ -1308,6 +1310,7 @@ private constructor( /** Configuration for a single tier */ class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val tierLowerBound: JsonField, private val unitAmount: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingMinimumCompositePrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingMinimumCompositePrice.kt index ed367990e..9df1bffff 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingMinimumCompositePrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingMinimumCompositePrice.kt @@ -18,6 +18,7 @@ import java.util.Collections import java.util.Objects class NewFloatingMinimumCompositePrice +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val currency: JsonField, @@ -1060,6 +1061,7 @@ private constructor( /** Configuration for minimum pricing */ class MinimumConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val minimumAmount: JsonField, private val prorated: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingPackagePrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingPackagePrice.kt index 6f5daf5f9..deae399c2 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingPackagePrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingPackagePrice.kt @@ -18,6 +18,7 @@ import java.util.Collections import java.util.Objects class NewFloatingPackagePrice +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val currency: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingPackageWithAllocationPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingPackageWithAllocationPrice.kt index aab035939..6a9305b4f 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingPackageWithAllocationPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingPackageWithAllocationPrice.kt @@ -18,6 +18,7 @@ import java.util.Collections import java.util.Objects class NewFloatingPackageWithAllocationPrice +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val currency: JsonField, @@ -1187,6 +1188,7 @@ private constructor( /** Configuration for package_with_allocation pricing */ class PackageWithAllocationConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val allocation: JsonField, private val packageAmount: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingScalableMatrixWithTieredPricingPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingScalableMatrixWithTieredPricingPrice.kt index 5967337f1..68517093f 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingScalableMatrixWithTieredPricingPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingScalableMatrixWithTieredPricingPrice.kt @@ -19,6 +19,7 @@ import java.util.Collections import java.util.Objects class NewFloatingScalableMatrixWithTieredPricingPrice +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val currency: JsonField, @@ -1206,6 +1207,7 @@ private constructor( /** Configuration for scalable_matrix_with_tiered_pricing pricing */ class ScalableMatrixWithTieredPricingConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val firstDimension: JsonField, private val matrixScalingFactors: JsonField>, @@ -1514,6 +1516,7 @@ private constructor( /** Configuration for a single matrix scaling factor */ class MatrixScalingFactor + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val firstDimensionValue: JsonField, private val scalingFactor: JsonField, @@ -1783,6 +1786,7 @@ private constructor( /** Configuration for a single tier entry with business logic */ class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val tierLowerBound: JsonField, private val unitAmount: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingScalableMatrixWithUnitPricingPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingScalableMatrixWithUnitPricingPrice.kt index 14baf1c26..4d390fb36 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingScalableMatrixWithUnitPricingPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingScalableMatrixWithUnitPricingPrice.kt @@ -19,6 +19,7 @@ import java.util.Collections import java.util.Objects class NewFloatingScalableMatrixWithUnitPricingPrice +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val currency: JsonField, @@ -1197,6 +1198,7 @@ private constructor( /** Configuration for scalable_matrix_with_unit_pricing pricing */ class ScalableMatrixWithUnitPricingConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val firstDimension: JsonField, private val matrixScalingFactors: JsonField>, @@ -1541,6 +1543,7 @@ private constructor( /** Configuration for a single matrix scaling factor */ class MatrixScalingFactor + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val firstDimensionValue: JsonField, private val scalingFactor: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingThresholdTotalAmountPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingThresholdTotalAmountPrice.kt index a0f350a38..beb755da1 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingThresholdTotalAmountPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingThresholdTotalAmountPrice.kt @@ -19,6 +19,7 @@ import java.util.Collections import java.util.Objects class NewFloatingThresholdTotalAmountPrice +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val currency: JsonField, @@ -1188,6 +1189,7 @@ private constructor( /** Configuration for threshold_total_amount pricing */ class ThresholdTotalAmountConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val consumptionTable: JsonField>, private val prorate: JsonField, @@ -1398,6 +1400,7 @@ private constructor( /** Configuration for a single threshold */ class ConsumptionTable + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val threshold: JsonField, private val totalAmount: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredPackagePrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredPackagePrice.kt index 8961b0d8b..2536207f8 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredPackagePrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredPackagePrice.kt @@ -19,6 +19,7 @@ import java.util.Collections import java.util.Objects class NewFloatingTieredPackagePrice +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val currency: JsonField, @@ -1181,6 +1182,7 @@ private constructor( /** Configuration for tiered_package pricing */ class TieredPackageConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val packageSize: JsonField, private val tiers: JsonField>, @@ -1386,6 +1388,7 @@ private constructor( /** Configuration for a single tier with business logic */ class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val perUnit: JsonField, private val tierLowerBound: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredPackageWithMinimumPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredPackageWithMinimumPrice.kt index 33a6c9594..6d208f201 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredPackageWithMinimumPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredPackageWithMinimumPrice.kt @@ -19,6 +19,7 @@ import java.util.Collections import java.util.Objects class NewFloatingTieredPackageWithMinimumPrice +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val currency: JsonField, @@ -1191,6 +1192,7 @@ private constructor( /** Configuration for tiered_package_with_minimum pricing */ class TieredPackageWithMinimumConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val packageSize: JsonField, private val tiers: JsonField>, @@ -1395,6 +1397,7 @@ private constructor( /** Configuration for a single tier */ class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val minimumAmount: JsonField, private val perUnit: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredPrice.kt index 3d16dd498..88f9c93dc 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredPrice.kt @@ -18,6 +18,7 @@ import java.util.Collections import java.util.Objects class NewFloatingTieredPrice +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val currency: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredWithMinimumPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredWithMinimumPrice.kt index 1b166c417..34af1a3ab 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredWithMinimumPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredWithMinimumPrice.kt @@ -19,6 +19,7 @@ import java.util.Collections import java.util.Objects class NewFloatingTieredWithMinimumPrice +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val currency: JsonField, @@ -1186,6 +1187,7 @@ private constructor( /** Configuration for tiered_with_minimum pricing */ class TieredWithMinimumConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val tiers: JsonField>, private val hideZeroAmountTiers: JsonField, @@ -1422,6 +1424,7 @@ private constructor( /** Configuration for a single tier */ class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val minimumAmount: JsonField, private val tierLowerBound: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredWithProrationPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredWithProrationPrice.kt index 47eb82db3..20ff69406 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredWithProrationPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredWithProrationPrice.kt @@ -19,6 +19,7 @@ import java.util.Collections import java.util.Objects class NewFloatingTieredWithProrationPrice +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val currency: JsonField, @@ -1188,6 +1189,7 @@ private constructor( /** Configuration for tiered_with_proration pricing */ class TieredWithProrationConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val tiers: JsonField>, private val additionalProperties: MutableMap, @@ -1346,6 +1348,7 @@ private constructor( /** Configuration for a single tiered with proration tier */ class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val tierLowerBound: JsonField, private val unitAmount: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingUnitPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingUnitPrice.kt index 156ef8cb5..d3bed4168 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingUnitPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingUnitPrice.kt @@ -18,6 +18,7 @@ import java.util.Collections import java.util.Objects class NewFloatingUnitPrice +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val currency: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingUnitWithPercentPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingUnitWithPercentPrice.kt index 91bda2272..d557569fb 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingUnitWithPercentPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingUnitWithPercentPrice.kt @@ -18,6 +18,7 @@ import java.util.Collections import java.util.Objects class NewFloatingUnitWithPercentPrice +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val currency: JsonField, @@ -1184,6 +1185,7 @@ private constructor( /** Configuration for unit_with_percent pricing */ class UnitWithPercentConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val percent: JsonField, private val unitAmount: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingUnitWithProrationPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingUnitWithProrationPrice.kt index 48892d987..055f55045 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingUnitWithProrationPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingUnitWithProrationPrice.kt @@ -18,6 +18,7 @@ import java.util.Collections import java.util.Objects class NewFloatingUnitWithProrationPrice +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val currency: JsonField, @@ -1185,6 +1186,7 @@ private constructor( /** Configuration for unit_with_proration pricing */ class UnitWithProrationConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val unitAmount: JsonField, private val additionalProperties: MutableMap, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewMaximum.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewMaximum.kt index 2cbea1804..0293f4b14 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewMaximum.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewMaximum.kt @@ -19,6 +19,7 @@ import java.util.Collections import java.util.Objects class NewMaximum +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val adjustmentType: JsonField, private val maximumAmount: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewMinimum.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewMinimum.kt index 7a4c87fda..b5350f944 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewMinimum.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewMinimum.kt @@ -19,6 +19,7 @@ import java.util.Collections import java.util.Objects class NewMinimum +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val adjustmentType: JsonField, private val itemId: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPercentageDiscount.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPercentageDiscount.kt index 32ba4e4ba..f73f61633 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPercentageDiscount.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPercentageDiscount.kt @@ -19,6 +19,7 @@ import java.util.Collections import java.util.Objects class NewPercentageDiscount +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val adjustmentType: JsonField, private val percentageDiscount: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanBulkPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanBulkPrice.kt index 51fb48aab..4a73e7f90 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanBulkPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanBulkPrice.kt @@ -18,6 +18,7 @@ import java.util.Collections import java.util.Objects class NewPlanBulkPrice +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val bulkConfig: JsonField, private val cadence: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanBulkWithProrationPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanBulkWithProrationPrice.kt index 6bba819fb..8eec7d2f0 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanBulkWithProrationPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanBulkWithProrationPrice.kt @@ -19,6 +19,7 @@ import java.util.Collections import java.util.Objects class NewPlanBulkWithProrationPrice +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val bulkWithProrationConfig: JsonField, private val cadence: JsonField, @@ -957,6 +958,7 @@ private constructor( /** Configuration for bulk_with_proration pricing */ class BulkWithProrationConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val tiers: JsonField>, private val additionalProperties: MutableMap, @@ -1111,6 +1113,7 @@ private constructor( /** Configuration for a single bulk pricing tier with proration */ class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val unitAmount: JsonField, private val tierLowerBound: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanCumulativeGroupedBulkPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanCumulativeGroupedBulkPrice.kt index 6584cee77..58a6e2be7 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanCumulativeGroupedBulkPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanCumulativeGroupedBulkPrice.kt @@ -19,6 +19,7 @@ import java.util.Collections import java.util.Objects class NewPlanCumulativeGroupedBulkPrice +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val cumulativeGroupedBulkConfig: JsonField, @@ -1111,6 +1112,7 @@ private constructor( /** Configuration for cumulative_grouped_bulk pricing */ class CumulativeGroupedBulkConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val dimensionValues: JsonField>, private val group: JsonField, @@ -1312,6 +1314,7 @@ private constructor( /** Configuration for a dimension value entry */ class DimensionValue + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val groupingKey: JsonField, private val tierLowerBound: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanGroupedAllocationPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanGroupedAllocationPrice.kt index 4c175c430..142851c2e 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanGroupedAllocationPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanGroupedAllocationPrice.kt @@ -18,6 +18,7 @@ import java.util.Collections import java.util.Objects class NewPlanGroupedAllocationPrice +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val groupedAllocationConfig: JsonField, @@ -1105,6 +1106,7 @@ private constructor( /** Configuration for grouped_allocation pricing */ class GroupedAllocationConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val allocation: JsonField, private val groupingKey: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanGroupedTieredPackagePrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanGroupedTieredPackagePrice.kt index 8df304a44..05ea0e8c9 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanGroupedTieredPackagePrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanGroupedTieredPackagePrice.kt @@ -19,6 +19,7 @@ import java.util.Collections import java.util.Objects class NewPlanGroupedTieredPackagePrice +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val groupedTieredPackageConfig: JsonField, @@ -1111,6 +1112,7 @@ private constructor( /** Configuration for grouped_tiered_package pricing */ class GroupedTieredPackageConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val groupingKey: JsonField, private val packageSize: JsonField, @@ -1356,6 +1358,7 @@ private constructor( /** Configuration for a single tier */ class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val perUnit: JsonField, private val tierLowerBound: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanGroupedTieredPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanGroupedTieredPrice.kt index c58f93ecd..2b6bbaabc 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanGroupedTieredPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanGroupedTieredPrice.kt @@ -19,6 +19,7 @@ import java.util.Collections import java.util.Objects class NewPlanGroupedTieredPrice +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val groupedTieredConfig: JsonField, @@ -1103,6 +1104,7 @@ private constructor( /** Configuration for grouped_tiered pricing */ class GroupedTieredConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val groupingKey: JsonField, private val tiers: JsonField>, @@ -1302,6 +1304,7 @@ private constructor( /** Configuration for a single tier */ class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val tierLowerBound: JsonField, private val unitAmount: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanGroupedWithMeteredMinimumPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanGroupedWithMeteredMinimumPrice.kt index a694be46a..0cc06b219 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanGroupedWithMeteredMinimumPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanGroupedWithMeteredMinimumPrice.kt @@ -19,6 +19,7 @@ import java.util.Collections import java.util.Objects class NewPlanGroupedWithMeteredMinimumPrice +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val groupedWithMeteredMinimumConfig: JsonField, @@ -1115,6 +1116,7 @@ private constructor( /** Configuration for grouped_with_metered_minimum pricing */ class GroupedWithMeteredMinimumConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val groupingKey: JsonField, private val minimumUnitAmount: JsonField, @@ -1515,6 +1517,7 @@ private constructor( /** Configuration for a scaling factor */ class ScalingFactor + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val scalingFactor: JsonField, private val scalingValue: JsonField, @@ -1733,6 +1736,7 @@ private constructor( /** Configuration for a unit amount */ class UnitAmount + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val pricingValue: JsonField, private val unitAmount: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanGroupedWithProratedMinimumPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanGroupedWithProratedMinimumPrice.kt index 30a5bb14a..366a7d409 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanGroupedWithProratedMinimumPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanGroupedWithProratedMinimumPrice.kt @@ -18,6 +18,7 @@ import java.util.Collections import java.util.Objects class NewPlanGroupedWithProratedMinimumPrice +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val groupedWithProratedMinimumConfig: JsonField, @@ -1114,6 +1115,7 @@ private constructor( /** Configuration for grouped_with_prorated_minimum pricing */ class GroupedWithProratedMinimumConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val groupingKey: JsonField, private val minimum: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanMatrixPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanMatrixPrice.kt index a3b83d4c1..e4bfc7ad3 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanMatrixPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanMatrixPrice.kt @@ -18,6 +18,7 @@ import java.util.Collections import java.util.Objects class NewPlanMatrixPrice +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val itemId: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanMatrixWithAllocationPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanMatrixWithAllocationPrice.kt index d266b1229..874f616fd 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanMatrixWithAllocationPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanMatrixWithAllocationPrice.kt @@ -18,6 +18,7 @@ import java.util.Collections import java.util.Objects class NewPlanMatrixWithAllocationPrice +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val itemId: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanMatrixWithDisplayNamePrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanMatrixWithDisplayNamePrice.kt index ed312d182..6ab4c5193 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanMatrixWithDisplayNamePrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanMatrixWithDisplayNamePrice.kt @@ -19,6 +19,7 @@ import java.util.Collections import java.util.Objects class NewPlanMatrixWithDisplayNamePrice +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val itemId: JsonField, @@ -1111,6 +1112,7 @@ private constructor( /** Configuration for matrix_with_display_name pricing */ class MatrixWithDisplayNameConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val dimension: JsonField, private val unitAmounts: JsonField>, @@ -1310,6 +1312,7 @@ private constructor( /** Configuration for a unit amount item */ class UnitAmount + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val dimensionValue: JsonField, private val displayName: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanMaxGroupTieredPackagePrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanMaxGroupTieredPackagePrice.kt index df6fbdb54..ee0b9bc4b 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanMaxGroupTieredPackagePrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanMaxGroupTieredPackagePrice.kt @@ -19,6 +19,7 @@ import java.util.Collections import java.util.Objects class NewPlanMaxGroupTieredPackagePrice +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val itemId: JsonField, @@ -1111,6 +1112,7 @@ private constructor( /** Configuration for max_group_tiered_package pricing */ class MaxGroupTieredPackageConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val groupingKey: JsonField, private val packageSize: JsonField, @@ -1352,6 +1354,7 @@ private constructor( /** Configuration for a single tier */ class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val tierLowerBound: JsonField, private val unitAmount: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanMinimumCompositePrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanMinimumCompositePrice.kt index 0eecc0913..459349ce0 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanMinimumCompositePrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanMinimumCompositePrice.kt @@ -18,6 +18,7 @@ import java.util.Collections import java.util.Objects class NewPlanMinimumCompositePrice +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val itemId: JsonField, @@ -1100,6 +1101,7 @@ private constructor( /** Configuration for minimum pricing */ class MinimumConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val minimumAmount: JsonField, private val prorated: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanPackagePrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanPackagePrice.kt index 42f613675..e068235e9 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanPackagePrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanPackagePrice.kt @@ -18,6 +18,7 @@ import java.util.Collections import java.util.Objects class NewPlanPackagePrice +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val itemId: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanPackageWithAllocationPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanPackageWithAllocationPrice.kt index 9fc1505af..01b128cc4 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanPackageWithAllocationPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanPackageWithAllocationPrice.kt @@ -18,6 +18,7 @@ import java.util.Collections import java.util.Objects class NewPlanPackageWithAllocationPrice +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val itemId: JsonField, @@ -1231,6 +1232,7 @@ private constructor( /** Configuration for package_with_allocation pricing */ class PackageWithAllocationConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val allocation: JsonField, private val packageAmount: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanScalableMatrixWithTieredPricingPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanScalableMatrixWithTieredPricingPrice.kt index 754ade139..90a7ba681 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanScalableMatrixWithTieredPricingPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanScalableMatrixWithTieredPricingPrice.kt @@ -19,6 +19,7 @@ import java.util.Collections import java.util.Objects class NewPlanScalableMatrixWithTieredPricingPrice +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val itemId: JsonField, @@ -1248,6 +1249,7 @@ private constructor( /** Configuration for scalable_matrix_with_tiered_pricing pricing */ class ScalableMatrixWithTieredPricingConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val firstDimension: JsonField, private val matrixScalingFactors: JsonField>, @@ -1556,6 +1558,7 @@ private constructor( /** Configuration for a single matrix scaling factor */ class MatrixScalingFactor + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val firstDimensionValue: JsonField, private val scalingFactor: JsonField, @@ -1825,6 +1828,7 @@ private constructor( /** Configuration for a single tier entry with business logic */ class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val tierLowerBound: JsonField, private val unitAmount: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanScalableMatrixWithUnitPricingPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanScalableMatrixWithUnitPricingPrice.kt index 32d04d426..3c2e3374d 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanScalableMatrixWithUnitPricingPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanScalableMatrixWithUnitPricingPrice.kt @@ -19,6 +19,7 @@ import java.util.Collections import java.util.Objects class NewPlanScalableMatrixWithUnitPricingPrice +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val itemId: JsonField, @@ -1240,6 +1241,7 @@ private constructor( /** Configuration for scalable_matrix_with_unit_pricing pricing */ class ScalableMatrixWithUnitPricingConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val firstDimension: JsonField, private val matrixScalingFactors: JsonField>, @@ -1584,6 +1586,7 @@ private constructor( /** Configuration for a single matrix scaling factor */ class MatrixScalingFactor + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val firstDimensionValue: JsonField, private val scalingFactor: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanThresholdTotalAmountPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanThresholdTotalAmountPrice.kt index b27136cfd..5cac439fe 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanThresholdTotalAmountPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanThresholdTotalAmountPrice.kt @@ -19,6 +19,7 @@ import java.util.Collections import java.util.Objects class NewPlanThresholdTotalAmountPrice +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val itemId: JsonField, @@ -1232,6 +1233,7 @@ private constructor( /** Configuration for threshold_total_amount pricing */ class ThresholdTotalAmountConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val consumptionTable: JsonField>, private val prorate: JsonField, @@ -1442,6 +1444,7 @@ private constructor( /** Configuration for a single threshold */ class ConsumptionTable + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val threshold: JsonField, private val totalAmount: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanTieredPackagePrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanTieredPackagePrice.kt index b7aa634ba..c02e0bbb8 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanTieredPackagePrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanTieredPackagePrice.kt @@ -19,6 +19,7 @@ import java.util.Collections import java.util.Objects class NewPlanTieredPackagePrice +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val itemId: JsonField, @@ -1224,6 +1225,7 @@ private constructor( /** Configuration for tiered_package pricing */ class TieredPackageConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val packageSize: JsonField, private val tiers: JsonField>, @@ -1429,6 +1431,7 @@ private constructor( /** Configuration for a single tier with business logic */ class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val perUnit: JsonField, private val tierLowerBound: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanTieredPackageWithMinimumPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanTieredPackageWithMinimumPrice.kt index 66c2a20b8..be4505a9c 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanTieredPackageWithMinimumPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanTieredPackageWithMinimumPrice.kt @@ -19,6 +19,7 @@ import java.util.Collections import java.util.Objects class NewPlanTieredPackageWithMinimumPrice +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val itemId: JsonField, @@ -1236,6 +1237,7 @@ private constructor( /** Configuration for tiered_package_with_minimum pricing */ class TieredPackageWithMinimumConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val packageSize: JsonField, private val tiers: JsonField>, @@ -1440,6 +1442,7 @@ private constructor( /** Configuration for a single tier */ class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val minimumAmount: JsonField, private val perUnit: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanTieredPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanTieredPrice.kt index f91ff9ee9..579e9ce80 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanTieredPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanTieredPrice.kt @@ -18,6 +18,7 @@ import java.util.Collections import java.util.Objects class NewPlanTieredPrice +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val itemId: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanTieredWithMinimumPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanTieredWithMinimumPrice.kt index ac14f2e41..a36fcb093 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanTieredWithMinimumPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanTieredWithMinimumPrice.kt @@ -19,6 +19,7 @@ import java.util.Collections import java.util.Objects class NewPlanTieredWithMinimumPrice +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val itemId: JsonField, @@ -1227,6 +1228,7 @@ private constructor( /** Configuration for tiered_with_minimum pricing */ class TieredWithMinimumConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val tiers: JsonField>, private val hideZeroAmountTiers: JsonField, @@ -1463,6 +1465,7 @@ private constructor( /** Configuration for a single tier */ class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val minimumAmount: JsonField, private val tierLowerBound: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanUnitPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanUnitPrice.kt index 42fea98f7..670c157ef 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanUnitPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanUnitPrice.kt @@ -18,6 +18,7 @@ import java.util.Collections import java.util.Objects class NewPlanUnitPrice +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val itemId: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanUnitWithPercentPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanUnitWithPercentPrice.kt index 37a59f63c..2f83db737 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanUnitWithPercentPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanUnitWithPercentPrice.kt @@ -18,6 +18,7 @@ import java.util.Collections import java.util.Objects class NewPlanUnitWithPercentPrice +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val itemId: JsonField, @@ -1224,6 +1225,7 @@ private constructor( /** Configuration for unit_with_percent pricing */ class UnitWithPercentConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val percent: JsonField, private val unitAmount: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanUnitWithProrationPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanUnitWithProrationPrice.kt index 287164cff..ed0113c20 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanUnitWithProrationPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanUnitWithProrationPrice.kt @@ -18,6 +18,7 @@ import java.util.Collections import java.util.Objects class NewPlanUnitWithProrationPrice +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val itemId: JsonField, @@ -1226,6 +1227,7 @@ private constructor( /** Configuration for unit_with_proration pricing */ class UnitWithProrationConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val unitAmount: JsonField, private val additionalProperties: MutableMap, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewReportingConfiguration.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewReportingConfiguration.kt index 13166ace1..e91776826 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewReportingConfiguration.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewReportingConfiguration.kt @@ -16,6 +16,7 @@ import java.util.Collections import java.util.Objects class NewReportingConfiguration +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val exempt: JsonField, private val additionalProperties: MutableMap, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSphereConfiguration.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSphereConfiguration.kt index 15ebd33e8..15865457e 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSphereConfiguration.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSphereConfiguration.kt @@ -17,6 +17,7 @@ import java.util.Collections import java.util.Objects class NewSphereConfiguration +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val taxExempt: JsonField, private val taxProvider: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionBulkPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionBulkPrice.kt index 5a07abc42..444fd4b50 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionBulkPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionBulkPrice.kt @@ -18,6 +18,7 @@ import java.util.Collections import java.util.Objects class NewSubscriptionBulkPrice +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val bulkConfig: JsonField, private val cadence: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionBulkWithProrationPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionBulkWithProrationPrice.kt index dffafead4..5d5d26545 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionBulkWithProrationPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionBulkWithProrationPrice.kt @@ -19,6 +19,7 @@ import java.util.Collections import java.util.Objects class NewSubscriptionBulkWithProrationPrice +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val bulkWithProrationConfig: JsonField, private val cadence: JsonField, @@ -962,6 +963,7 @@ private constructor( /** Configuration for bulk_with_proration pricing */ class BulkWithProrationConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val tiers: JsonField>, private val additionalProperties: MutableMap, @@ -1116,6 +1118,7 @@ private constructor( /** Configuration for a single bulk pricing tier with proration */ class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val unitAmount: JsonField, private val tierLowerBound: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionCumulativeGroupedBulkPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionCumulativeGroupedBulkPrice.kt index 089f4741b..5e6c7823d 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionCumulativeGroupedBulkPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionCumulativeGroupedBulkPrice.kt @@ -19,6 +19,7 @@ import java.util.Collections import java.util.Objects class NewSubscriptionCumulativeGroupedBulkPrice +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val cumulativeGroupedBulkConfig: JsonField, @@ -1112,6 +1113,7 @@ private constructor( /** Configuration for cumulative_grouped_bulk pricing */ class CumulativeGroupedBulkConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val dimensionValues: JsonField>, private val group: JsonField, @@ -1313,6 +1315,7 @@ private constructor( /** Configuration for a dimension value entry */ class DimensionValue + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val groupingKey: JsonField, private val tierLowerBound: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionGroupedAllocationPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionGroupedAllocationPrice.kt index 15750b2a7..1376a2207 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionGroupedAllocationPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionGroupedAllocationPrice.kt @@ -18,6 +18,7 @@ import java.util.Collections import java.util.Objects class NewSubscriptionGroupedAllocationPrice +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val groupedAllocationConfig: JsonField, @@ -1110,6 +1111,7 @@ private constructor( /** Configuration for grouped_allocation pricing */ class GroupedAllocationConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val allocation: JsonField, private val groupingKey: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionGroupedTieredPackagePrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionGroupedTieredPackagePrice.kt index 41f69acb5..b89fb3b05 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionGroupedTieredPackagePrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionGroupedTieredPackagePrice.kt @@ -19,6 +19,7 @@ import java.util.Collections import java.util.Objects class NewSubscriptionGroupedTieredPackagePrice +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val groupedTieredPackageConfig: JsonField, @@ -1112,6 +1113,7 @@ private constructor( /** Configuration for grouped_tiered_package pricing */ class GroupedTieredPackageConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val groupingKey: JsonField, private val packageSize: JsonField, @@ -1357,6 +1359,7 @@ private constructor( /** Configuration for a single tier */ class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val perUnit: JsonField, private val tierLowerBound: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionGroupedTieredPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionGroupedTieredPrice.kt index b40665d23..58474f9e3 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionGroupedTieredPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionGroupedTieredPrice.kt @@ -19,6 +19,7 @@ import java.util.Collections import java.util.Objects class NewSubscriptionGroupedTieredPrice +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val groupedTieredConfig: JsonField, @@ -1109,6 +1110,7 @@ private constructor( /** Configuration for grouped_tiered pricing */ class GroupedTieredConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val groupingKey: JsonField, private val tiers: JsonField>, @@ -1308,6 +1310,7 @@ private constructor( /** Configuration for a single tier */ class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val tierLowerBound: JsonField, private val unitAmount: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionGroupedWithMeteredMinimumPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionGroupedWithMeteredMinimumPrice.kt index 1c18ffe36..218580f21 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionGroupedWithMeteredMinimumPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionGroupedWithMeteredMinimumPrice.kt @@ -19,6 +19,7 @@ import java.util.Collections import java.util.Objects class NewSubscriptionGroupedWithMeteredMinimumPrice +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val groupedWithMeteredMinimumConfig: JsonField, @@ -1117,6 +1118,7 @@ private constructor( /** Configuration for grouped_with_metered_minimum pricing */ class GroupedWithMeteredMinimumConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val groupingKey: JsonField, private val minimumUnitAmount: JsonField, @@ -1517,6 +1519,7 @@ private constructor( /** Configuration for a scaling factor */ class ScalingFactor + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val scalingFactor: JsonField, private val scalingValue: JsonField, @@ -1735,6 +1738,7 @@ private constructor( /** Configuration for a unit amount */ class UnitAmount + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val pricingValue: JsonField, private val unitAmount: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionGroupedWithProratedMinimumPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionGroupedWithProratedMinimumPrice.kt index 5f92b1ef5..61a7ad018 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionGroupedWithProratedMinimumPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionGroupedWithProratedMinimumPrice.kt @@ -18,6 +18,7 @@ import java.util.Collections import java.util.Objects class NewSubscriptionGroupedWithProratedMinimumPrice +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val groupedWithProratedMinimumConfig: JsonField, @@ -1116,6 +1117,7 @@ private constructor( /** Configuration for grouped_with_prorated_minimum pricing */ class GroupedWithProratedMinimumConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val groupingKey: JsonField, private val minimum: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionMatrixPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionMatrixPrice.kt index 9928a7429..1d22f90f4 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionMatrixPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionMatrixPrice.kt @@ -18,6 +18,7 @@ import java.util.Collections import java.util.Objects class NewSubscriptionMatrixPrice +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val itemId: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionMatrixWithAllocationPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionMatrixWithAllocationPrice.kt index a14f0cf99..f15a1c497 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionMatrixWithAllocationPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionMatrixWithAllocationPrice.kt @@ -18,6 +18,7 @@ import java.util.Collections import java.util.Objects class NewSubscriptionMatrixWithAllocationPrice +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val itemId: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionMatrixWithDisplayNamePrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionMatrixWithDisplayNamePrice.kt index e1e4604f1..9ab1f5275 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionMatrixWithDisplayNamePrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionMatrixWithDisplayNamePrice.kt @@ -19,6 +19,7 @@ import java.util.Collections import java.util.Objects class NewSubscriptionMatrixWithDisplayNamePrice +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val itemId: JsonField, @@ -1112,6 +1113,7 @@ private constructor( /** Configuration for matrix_with_display_name pricing */ class MatrixWithDisplayNameConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val dimension: JsonField, private val unitAmounts: JsonField>, @@ -1311,6 +1313,7 @@ private constructor( /** Configuration for a unit amount item */ class UnitAmount + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val dimensionValue: JsonField, private val displayName: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionMaxGroupTieredPackagePrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionMaxGroupTieredPackagePrice.kt index dbd7d1758..d0ed2ee87 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionMaxGroupTieredPackagePrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionMaxGroupTieredPackagePrice.kt @@ -19,6 +19,7 @@ import java.util.Collections import java.util.Objects class NewSubscriptionMaxGroupTieredPackagePrice +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val itemId: JsonField, @@ -1112,6 +1113,7 @@ private constructor( /** Configuration for max_group_tiered_package pricing */ class MaxGroupTieredPackageConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val groupingKey: JsonField, private val packageSize: JsonField, @@ -1353,6 +1355,7 @@ private constructor( /** Configuration for a single tier */ class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val tierLowerBound: JsonField, private val unitAmount: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionMinimumCompositePrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionMinimumCompositePrice.kt index 40a12cef5..a769ead59 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionMinimumCompositePrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionMinimumCompositePrice.kt @@ -18,6 +18,7 @@ import java.util.Collections import java.util.Objects class NewSubscriptionMinimumCompositePrice +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val itemId: JsonField, @@ -1106,6 +1107,7 @@ private constructor( /** Configuration for minimum pricing */ class MinimumConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val minimumAmount: JsonField, private val prorated: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionPackagePrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionPackagePrice.kt index 581a8af22..4692905c4 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionPackagePrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionPackagePrice.kt @@ -18,6 +18,7 @@ import java.util.Collections import java.util.Objects class NewSubscriptionPackagePrice +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val itemId: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionPackageWithAllocationPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionPackageWithAllocationPrice.kt index 4f15f85b7..38aba0da0 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionPackageWithAllocationPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionPackageWithAllocationPrice.kt @@ -18,6 +18,7 @@ import java.util.Collections import java.util.Objects class NewSubscriptionPackageWithAllocationPrice +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val itemId: JsonField, @@ -1232,6 +1233,7 @@ private constructor( /** Configuration for package_with_allocation pricing */ class PackageWithAllocationConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val allocation: JsonField, private val packageAmount: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionScalableMatrixWithTieredPricingPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionScalableMatrixWithTieredPricingPrice.kt index 2ef27833a..6330dac3d 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionScalableMatrixWithTieredPricingPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionScalableMatrixWithTieredPricingPrice.kt @@ -19,6 +19,7 @@ import java.util.Collections import java.util.Objects class NewSubscriptionScalableMatrixWithTieredPricingPrice +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val itemId: JsonField, @@ -1254,6 +1255,7 @@ private constructor( /** Configuration for scalable_matrix_with_tiered_pricing pricing */ class ScalableMatrixWithTieredPricingConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val firstDimension: JsonField, private val matrixScalingFactors: JsonField>, @@ -1562,6 +1564,7 @@ private constructor( /** Configuration for a single matrix scaling factor */ class MatrixScalingFactor + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val firstDimensionValue: JsonField, private val scalingFactor: JsonField, @@ -1831,6 +1834,7 @@ private constructor( /** Configuration for a single tier entry with business logic */ class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val tierLowerBound: JsonField, private val unitAmount: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionScalableMatrixWithUnitPricingPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionScalableMatrixWithUnitPricingPrice.kt index 5c687de68..96db4f2f1 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionScalableMatrixWithUnitPricingPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionScalableMatrixWithUnitPricingPrice.kt @@ -19,6 +19,7 @@ import java.util.Collections import java.util.Objects class NewSubscriptionScalableMatrixWithUnitPricingPrice +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val itemId: JsonField, @@ -1246,6 +1247,7 @@ private constructor( /** Configuration for scalable_matrix_with_unit_pricing pricing */ class ScalableMatrixWithUnitPricingConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val firstDimension: JsonField, private val matrixScalingFactors: JsonField>, @@ -1590,6 +1592,7 @@ private constructor( /** Configuration for a single matrix scaling factor */ class MatrixScalingFactor + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val firstDimensionValue: JsonField, private val scalingFactor: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionThresholdTotalAmountPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionThresholdTotalAmountPrice.kt index ffb89053d..ee5d55cfa 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionThresholdTotalAmountPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionThresholdTotalAmountPrice.kt @@ -19,6 +19,7 @@ import java.util.Collections import java.util.Objects class NewSubscriptionThresholdTotalAmountPrice +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val itemId: JsonField, @@ -1233,6 +1234,7 @@ private constructor( /** Configuration for threshold_total_amount pricing */ class ThresholdTotalAmountConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val consumptionTable: JsonField>, private val prorate: JsonField, @@ -1443,6 +1445,7 @@ private constructor( /** Configuration for a single threshold */ class ConsumptionTable + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val threshold: JsonField, private val totalAmount: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTieredPackagePrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTieredPackagePrice.kt index b309fa66a..471edb763 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTieredPackagePrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTieredPackagePrice.kt @@ -19,6 +19,7 @@ import java.util.Collections import java.util.Objects class NewSubscriptionTieredPackagePrice +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val itemId: JsonField, @@ -1230,6 +1231,7 @@ private constructor( /** Configuration for tiered_package pricing */ class TieredPackageConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val packageSize: JsonField, private val tiers: JsonField>, @@ -1435,6 +1437,7 @@ private constructor( /** Configuration for a single tier with business logic */ class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val perUnit: JsonField, private val tierLowerBound: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTieredPackageWithMinimumPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTieredPackageWithMinimumPrice.kt index 664f83455..304afa795 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTieredPackageWithMinimumPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTieredPackageWithMinimumPrice.kt @@ -19,6 +19,7 @@ import java.util.Collections import java.util.Objects class NewSubscriptionTieredPackageWithMinimumPrice +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val itemId: JsonField, @@ -1237,6 +1238,7 @@ private constructor( /** Configuration for tiered_package_with_minimum pricing */ class TieredPackageWithMinimumConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val packageSize: JsonField, private val tiers: JsonField>, @@ -1441,6 +1443,7 @@ private constructor( /** Configuration for a single tier */ class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val minimumAmount: JsonField, private val perUnit: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTieredPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTieredPrice.kt index 7ccc05bef..aad8a711d 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTieredPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTieredPrice.kt @@ -18,6 +18,7 @@ import java.util.Collections import java.util.Objects class NewSubscriptionTieredPrice +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val itemId: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTieredWithMinimumPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTieredWithMinimumPrice.kt index ad9720aa4..2067c6d3f 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTieredWithMinimumPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTieredWithMinimumPrice.kt @@ -19,6 +19,7 @@ import java.util.Collections import java.util.Objects class NewSubscriptionTieredWithMinimumPrice +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val itemId: JsonField, @@ -1232,6 +1233,7 @@ private constructor( /** Configuration for tiered_with_minimum pricing */ class TieredWithMinimumConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val tiers: JsonField>, private val hideZeroAmountTiers: JsonField, @@ -1468,6 +1470,7 @@ private constructor( /** Configuration for a single tier */ class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val minimumAmount: JsonField, private val tierLowerBound: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionUnitPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionUnitPrice.kt index 4aa43ab33..74787c1d4 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionUnitPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionUnitPrice.kt @@ -18,6 +18,7 @@ import java.util.Collections import java.util.Objects class NewSubscriptionUnitPrice +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val itemId: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionUnitWithPercentPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionUnitWithPercentPrice.kt index 4c6d350e1..7c407f78f 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionUnitWithPercentPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionUnitWithPercentPrice.kt @@ -18,6 +18,7 @@ import java.util.Collections import java.util.Objects class NewSubscriptionUnitWithPercentPrice +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val itemId: JsonField, @@ -1230,6 +1231,7 @@ private constructor( /** Configuration for unit_with_percent pricing */ class UnitWithPercentConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val percent: JsonField, private val unitAmount: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionUnitWithProrationPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionUnitWithProrationPrice.kt index b0403713c..3ef3b34ae 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionUnitWithProrationPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionUnitWithProrationPrice.kt @@ -18,6 +18,7 @@ import java.util.Collections import java.util.Objects class NewSubscriptionUnitWithProrationPrice +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val itemId: JsonField, @@ -1231,6 +1232,7 @@ private constructor( /** Configuration for unit_with_proration pricing */ class UnitWithProrationConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val unitAmount: JsonField, private val additionalProperties: MutableMap, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewTaxJarConfiguration.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewTaxJarConfiguration.kt index 1065e973b..fd91ad0bc 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewTaxJarConfiguration.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewTaxJarConfiguration.kt @@ -17,6 +17,7 @@ import java.util.Collections import java.util.Objects class NewTaxJarConfiguration +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val taxExempt: JsonField, private val taxProvider: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewUsageDiscount.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewUsageDiscount.kt index 9a9f0af1a..09d595afa 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewUsageDiscount.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewUsageDiscount.kt @@ -19,6 +19,7 @@ import java.util.Collections import java.util.Objects class NewUsageDiscount +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val adjustmentType: JsonField, private val usageDiscount: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/OtherSubLineItem.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/OtherSubLineItem.kt index ddc75ff26..fe8a7b58f 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/OtherSubLineItem.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/OtherSubLineItem.kt @@ -17,6 +17,7 @@ import java.util.Collections import java.util.Objects class OtherSubLineItem +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val amount: JsonField, private val grouping: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PackageConfig.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PackageConfig.kt index 505639b60..abcf97778 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PackageConfig.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PackageConfig.kt @@ -17,6 +17,7 @@ import java.util.Objects /** Configuration for package pricing */ class PackageConfig +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val packageAmount: JsonField, private val packageSize: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PaginationMetadata.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PaginationMetadata.kt index 37436bee7..19445fdb2 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PaginationMetadata.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PaginationMetadata.kt @@ -16,6 +16,7 @@ import java.util.Collections import java.util.Objects class PaginationMetadata +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val hasMore: JsonField, private val nextCursor: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PerPriceCost.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PerPriceCost.kt index 5ba4efb39..8aee5fe08 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PerPriceCost.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PerPriceCost.kt @@ -16,6 +16,7 @@ import java.util.Collections import java.util.Objects class PerPriceCost +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val price: JsonField, private val priceId: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PercentageDiscount.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PercentageDiscount.kt index 7d4c3727d..b423b3db6 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PercentageDiscount.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PercentageDiscount.kt @@ -19,6 +19,7 @@ import java.util.Collections import java.util.Objects class PercentageDiscount +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val discountType: JsonField, private val percentageDiscount: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PercentageDiscountInterval.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PercentageDiscountInterval.kt index 24a15d96c..c56edae4e 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PercentageDiscountInterval.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PercentageDiscountInterval.kt @@ -20,6 +20,7 @@ import java.util.Collections import java.util.Objects class PercentageDiscountInterval +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val appliesToPriceIntervalIds: JsonField>, private val discountType: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Plan.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Plan.kt index dcf467b1d..ba78de44e 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Plan.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Plan.kt @@ -35,6 +35,7 @@ import java.util.Objects * configure prices in the [Price resource](/reference/price). */ class Plan +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val adjustments: JsonField>, @@ -1655,6 +1656,7 @@ private constructor( } class BasePlan + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val externalPlanId: JsonField, @@ -1999,6 +2001,7 @@ private constructor( } class PlanPhase + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val description: JsonField, @@ -2782,6 +2785,7 @@ private constructor( } class Product + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val createdAt: JsonField, @@ -3143,6 +3147,7 @@ private constructor( } class TrialConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val trialPeriod: JsonField, private val trialPeriodUnit: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanCreateParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanCreateParams.kt index 69f259f8e..be50862bc 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanCreateParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanCreateParams.kt @@ -558,6 +558,7 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val currency: JsonField, private val name: JsonField, @@ -1162,6 +1163,7 @@ private constructor( } class Price + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val allocationPrice: JsonField, private val planPhaseOrder: JsonField, @@ -2652,6 +2654,7 @@ private constructor( } class TieredWithProration + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val itemId: JsonField, @@ -3840,6 +3843,7 @@ private constructor( /** Configuration for tiered_with_proration pricing */ class TieredWithProrationConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val tiers: JsonField>, private val additionalProperties: MutableMap, @@ -4013,6 +4017,7 @@ private constructor( /** Configuration for a single tiered with proration tier */ class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val tierLowerBound: JsonField, private val unitAmount: JsonField, @@ -4418,6 +4423,7 @@ private constructor( } class GroupedWithMinMaxThresholds + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val groupedWithMinMaxThresholdsConfig: @@ -5625,6 +5631,7 @@ private constructor( /** Configuration for grouped_with_min_max_thresholds pricing */ class GroupedWithMinMaxThresholdsConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val groupingKey: JsonField, private val maximumCharge: JsonField, @@ -6137,6 +6144,7 @@ private constructor( } class Adjustment + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val adjustment: JsonField, private val planPhaseOrder: JsonField, @@ -6811,6 +6819,7 @@ private constructor( } class PlanPhase + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val order: JsonField, private val alignBillingWithPhaseStartDate: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanExternalPlanIdUpdateParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanExternalPlanIdUpdateParams.kt index 0893ed42f..949b884f1 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanExternalPlanIdUpdateParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanExternalPlanIdUpdateParams.kt @@ -294,6 +294,7 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val externalPlanId: JsonField, private val metadata: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanListPageResponse.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanListPageResponse.kt index 1e3b0b692..d6524a41a 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanListPageResponse.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanListPageResponse.kt @@ -18,6 +18,7 @@ import java.util.Collections import java.util.Objects class PlanListPageResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val data: JsonField>, private val paginationMetadata: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanPhaseAmountDiscountAdjustment.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanPhaseAmountDiscountAdjustment.kt index 8f456cf9c..511242156 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanPhaseAmountDiscountAdjustment.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanPhaseAmountDiscountAdjustment.kt @@ -19,6 +19,7 @@ import java.util.Collections import java.util.Objects class PlanPhaseAmountDiscountAdjustment +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val adjustmentType: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanPhaseMaximumAdjustment.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanPhaseMaximumAdjustment.kt index e53659954..984d006cb 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanPhaseMaximumAdjustment.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanPhaseMaximumAdjustment.kt @@ -19,6 +19,7 @@ import java.util.Collections import java.util.Objects class PlanPhaseMaximumAdjustment +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val adjustmentType: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanPhaseMinimumAdjustment.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanPhaseMinimumAdjustment.kt index 074926d15..a2c11586d 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanPhaseMinimumAdjustment.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanPhaseMinimumAdjustment.kt @@ -19,6 +19,7 @@ import java.util.Collections import java.util.Objects class PlanPhaseMinimumAdjustment +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val adjustmentType: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanPhasePercentageDiscountAdjustment.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanPhasePercentageDiscountAdjustment.kt index 9d4ca23ba..39acfaa4f 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanPhasePercentageDiscountAdjustment.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanPhasePercentageDiscountAdjustment.kt @@ -19,6 +19,7 @@ import java.util.Collections import java.util.Objects class PlanPhasePercentageDiscountAdjustment +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val adjustmentType: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanPhaseUsageDiscountAdjustment.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanPhaseUsageDiscountAdjustment.kt index 056db50d8..aa1e6e912 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanPhaseUsageDiscountAdjustment.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanPhaseUsageDiscountAdjustment.kt @@ -19,6 +19,7 @@ import java.util.Collections import java.util.Objects class PlanPhaseUsageDiscountAdjustment +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val adjustmentType: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanUpdateParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanUpdateParams.kt index 8cbd6facf..6bf89eb94 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanUpdateParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanUpdateParams.kt @@ -289,6 +289,7 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val externalPlanId: JsonField, private val metadata: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanVersion.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanVersion.kt index 2bea6f329..cdcdf4194 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanVersion.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanVersion.kt @@ -33,6 +33,7 @@ import java.util.Objects * plan. */ class PlanVersion +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val adjustments: JsonField>, private val createdAt: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanVersionPhase.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanVersionPhase.kt index 86f58dfff..61eb5e4b1 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanVersionPhase.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanVersionPhase.kt @@ -17,6 +17,7 @@ import java.util.Collections import java.util.Objects class PlanVersionPhase +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val description: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Price.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Price.kt index 6d2c10cda..492c18195 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Price.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Price.kt @@ -1011,6 +1011,7 @@ private constructor( } class Unit + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val billableMetric: JsonField, @@ -3021,6 +3022,7 @@ private constructor( } class Tiered + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val billableMetric: JsonField, @@ -5032,6 +5034,7 @@ private constructor( } class Bulk + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val billableMetric: JsonField, @@ -7042,6 +7045,7 @@ private constructor( } class Package + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val billableMetric: JsonField, @@ -9054,6 +9058,7 @@ private constructor( } class Matrix + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val billableMetric: JsonField, @@ -11065,6 +11070,7 @@ private constructor( } class ThresholdTotalAmount + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val billableMetric: JsonField, @@ -13004,6 +13010,7 @@ private constructor( /** Configuration for threshold_total_amount pricing */ class ThresholdTotalAmountConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val consumptionTable: JsonField>, private val prorate: JsonField, @@ -13222,6 +13229,7 @@ private constructor( /** Configuration for a single threshold */ class ConsumptionTable + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val threshold: JsonField, private val totalAmount: JsonField, @@ -13536,6 +13544,7 @@ private constructor( } class TieredPackage + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val billableMetric: JsonField, @@ -15474,6 +15483,7 @@ private constructor( /** Configuration for tiered_package pricing */ class TieredPackageConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val packageSize: JsonField, private val tiers: JsonField>, @@ -15687,6 +15697,7 @@ private constructor( /** Configuration for a single tier with business logic */ class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val perUnit: JsonField, private val tierLowerBound: JsonField, @@ -16000,6 +16011,7 @@ private constructor( } class TieredWithMinimum + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val billableMetric: JsonField, @@ -17938,6 +17950,7 @@ private constructor( /** Configuration for tiered_with_minimum pricing */ class TieredWithMinimumConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val tiers: JsonField>, private val hideZeroAmountTiers: JsonField, @@ -18186,6 +18199,7 @@ private constructor( /** Configuration for a single tier */ class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val minimumAmount: JsonField, private val tierLowerBound: JsonField, @@ -18548,6 +18562,7 @@ private constructor( } class GroupedTiered + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val billableMetric: JsonField, @@ -20246,6 +20261,7 @@ private constructor( /** Configuration for grouped_tiered pricing */ class GroupedTieredConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val groupingKey: JsonField, private val tiers: JsonField>, @@ -20454,6 +20470,7 @@ private constructor( /** Configuration for a single tier */ class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val tierLowerBound: JsonField, private val unitAmount: JsonField, @@ -21009,6 +21026,7 @@ private constructor( } class TieredPackageWithMinimum + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val billableMetric: JsonField, @@ -22955,6 +22973,7 @@ private constructor( /** Configuration for tiered_package_with_minimum pricing */ class TieredPackageWithMinimumConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val packageSize: JsonField, private val tiers: JsonField>, @@ -23167,6 +23186,7 @@ private constructor( /** Configuration for a single tier */ class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val minimumAmount: JsonField, private val perUnit: JsonField, @@ -23526,6 +23546,7 @@ private constructor( } class PackageWithAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val billableMetric: JsonField, @@ -25331,6 +25352,7 @@ private constructor( /** Configuration for package_with_allocation pricing */ class PackageWithAllocationConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val allocation: JsonField, private val packageAmount: JsonField, @@ -25808,6 +25830,7 @@ private constructor( } class UnitWithPercent + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val billableMetric: JsonField, @@ -27747,6 +27770,7 @@ private constructor( /** Configuration for unit_with_percent pricing */ class UnitWithPercentConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val percent: JsonField, private val unitAmount: JsonField, @@ -28036,6 +28060,7 @@ private constructor( } class MatrixWithAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val billableMetric: JsonField, @@ -30051,6 +30076,7 @@ private constructor( } class TieredWithProration + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val billableMetric: JsonField, @@ -31990,6 +32016,7 @@ private constructor( /** Configuration for tiered_with_proration pricing */ class TieredWithProrationConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val tiers: JsonField>, private val additionalProperties: MutableMap, @@ -32156,6 +32183,7 @@ private constructor( /** Configuration for a single tiered with proration tier */ class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val tierLowerBound: JsonField, private val unitAmount: JsonField, @@ -32468,6 +32496,7 @@ private constructor( } class UnitWithProration + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val billableMetric: JsonField, @@ -34406,6 +34435,7 @@ private constructor( /** Configuration for unit_with_proration pricing */ class UnitWithProrationConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val unitAmount: JsonField, private val additionalProperties: MutableMap, @@ -34653,6 +34683,7 @@ private constructor( } class GroupedAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val billableMetric: JsonField, @@ -36351,6 +36382,7 @@ private constructor( /** Configuration for grouped_allocation pricing */ class GroupedAllocationConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val allocation: JsonField, private val groupingKey: JsonField, @@ -36932,6 +36964,7 @@ private constructor( } class BulkWithProration + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val billableMetric: JsonField, @@ -38478,6 +38511,7 @@ private constructor( /** Configuration for bulk_with_proration pricing */ class BulkWithProrationConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val tiers: JsonField>, private val additionalProperties: MutableMap, @@ -38640,6 +38674,7 @@ private constructor( /** Configuration for a single bulk pricing tier with proration */ class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val unitAmount: JsonField, private val tierLowerBound: JsonField, @@ -39341,6 +39376,7 @@ private constructor( } class GroupedWithProratedMinimum + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val billableMetric: JsonField, @@ -41053,6 +41089,7 @@ private constructor( /** Configuration for grouped_with_prorated_minimum pricing */ class GroupedWithProratedMinimumConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val groupingKey: JsonField, private val minimum: JsonField, @@ -41626,6 +41663,7 @@ private constructor( } class GroupedWithMeteredMinimum + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val billableMetric: JsonField, @@ -43337,6 +43375,7 @@ private constructor( /** Configuration for grouped_with_metered_minimum pricing */ class GroupedWithMeteredMinimumConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val groupingKey: JsonField, private val minimumUnitAmount: JsonField, @@ -43758,6 +43797,7 @@ private constructor( /** Configuration for a scaling factor */ class ScalingFactor + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val scalingFactor: JsonField, private val scalingValue: JsonField, @@ -43977,6 +44017,7 @@ private constructor( /** Configuration for a unit amount */ class UnitAmount + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val pricingValue: JsonField, private val unitAmount: JsonField, @@ -44544,6 +44585,7 @@ private constructor( } class GroupedWithMinMaxThresholds + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val billableMetric: JsonField, @@ -46257,6 +46299,7 @@ private constructor( /** Configuration for grouped_with_min_max_thresholds pricing */ class GroupedWithMinMaxThresholdsConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val groupingKey: JsonField, private val maximumCharge: JsonField, @@ -46892,6 +46935,7 @@ private constructor( } class MatrixWithDisplayName + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val billableMetric: JsonField, @@ -48592,6 +48636,7 @@ private constructor( /** Configuration for matrix_with_display_name pricing */ class MatrixWithDisplayNameConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val dimension: JsonField, private val unitAmounts: JsonField>, @@ -48803,6 +48848,7 @@ private constructor( /** Configuration for a unit amount item */ class UnitAmount + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val dimensionValue: JsonField, private val displayName: JsonField, @@ -49403,6 +49449,7 @@ private constructor( } class GroupedTieredPackage + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val billableMetric: JsonField, @@ -51102,6 +51149,7 @@ private constructor( /** Configuration for grouped_tiered_package pricing */ class GroupedTieredPackageConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val groupingKey: JsonField, private val packageSize: JsonField, @@ -51357,6 +51405,7 @@ private constructor( /** Configuration for a single tier */ class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val perUnit: JsonField, private val tierLowerBound: JsonField, @@ -51911,6 +51960,7 @@ private constructor( } class MaxGroupTieredPackage + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val billableMetric: JsonField, @@ -53611,6 +53661,7 @@ private constructor( /** Configuration for max_group_tiered_package pricing */ class MaxGroupTieredPackageConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val groupingKey: JsonField, private val packageSize: JsonField, @@ -53867,6 +53918,7 @@ private constructor( /** Configuration for a single tier */ class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val tierLowerBound: JsonField, private val unitAmount: JsonField, @@ -54423,6 +54475,7 @@ private constructor( } class ScalableMatrixWithUnitPricing + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val billableMetric: JsonField, @@ -56388,6 +56441,7 @@ private constructor( /** Configuration for scalable_matrix_with_unit_pricing pricing */ class ScalableMatrixWithUnitPricingConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val firstDimension: JsonField, private val matrixScalingFactors: JsonField>, @@ -56745,6 +56799,7 @@ private constructor( /** Configuration for a single matrix scaling factor */ class MatrixScalingFactor + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val firstDimensionValue: JsonField, private val scalingFactor: JsonField, @@ -57123,6 +57178,7 @@ private constructor( } class ScalableMatrixWithTieredPricing + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val billableMetric: JsonField, @@ -59090,6 +59146,7 @@ private constructor( /** Configuration for scalable_matrix_with_tiered_pricing pricing */ class ScalableMatrixWithTieredPricingConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val firstDimension: JsonField, private val matrixScalingFactors: JsonField>, @@ -59408,6 +59465,7 @@ private constructor( /** Configuration for a single matrix scaling factor */ class MatrixScalingFactor + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val firstDimensionValue: JsonField, private val scalingFactor: JsonField, @@ -59679,6 +59737,7 @@ private constructor( /** Configuration for a single tier entry with business logic */ class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val tierLowerBound: JsonField, private val unitAmount: JsonField, @@ -60003,6 +60062,7 @@ private constructor( } class CumulativeGroupedBulk + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val billableMetric: JsonField, @@ -61703,6 +61763,7 @@ private constructor( /** Configuration for cumulative_grouped_bulk pricing */ class CumulativeGroupedBulkConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val dimensionValues: JsonField>, private val group: JsonField, @@ -61910,6 +61971,7 @@ private constructor( /** Configuration for a dimension value entry */ class DimensionValue + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val groupingKey: JsonField, private val tierLowerBound: JsonField, @@ -62510,6 +62572,7 @@ private constructor( } class Minimum + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val billableMetric: JsonField, @@ -64311,6 +64374,7 @@ private constructor( /** Configuration for minimum pricing */ class MinimumConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val minimumAmount: JsonField, private val prorated: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceCreateParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceCreateParams.kt index 4d175fa57..a7d168177 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceCreateParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceCreateParams.kt @@ -1441,6 +1441,7 @@ private constructor( } class GroupedWithMinMaxThresholds + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val currency: JsonField, @@ -2567,6 +2568,7 @@ private constructor( /** Configuration for grouped_with_min_max_thresholds pricing */ class GroupedWithMinMaxThresholdsConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val groupingKey: JsonField, private val maximumCharge: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceEvaluateMultipleParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceEvaluateMultipleParams.kt index 20de54d19..5f80cecae 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceEvaluateMultipleParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceEvaluateMultipleParams.kt @@ -421,6 +421,7 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val timeframeEnd: JsonField, private val timeframeStart: JsonField, @@ -786,6 +787,7 @@ private constructor( } class PriceEvaluation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val externalPriceId: JsonField, private val filter: JsonField, @@ -2375,6 +2377,7 @@ private constructor( } class GroupedWithMinMaxThresholds + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val currency: JsonField, @@ -3534,6 +3537,7 @@ private constructor( /** Configuration for grouped_with_min_max_thresholds pricing */ class GroupedWithMinMaxThresholdsConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val groupingKey: JsonField, private val maximumCharge: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceEvaluateMultipleResponse.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceEvaluateMultipleResponse.kt index 2f3cd01b9..f4891fd0c 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceEvaluateMultipleResponse.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceEvaluateMultipleResponse.kt @@ -18,6 +18,7 @@ import java.util.Collections import java.util.Objects class PriceEvaluateMultipleResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val data: JsonField>, private val additionalProperties: MutableMap, @@ -167,6 +168,7 @@ private constructor( internal fun validity(): Int = (data.asKnown()?.sumOf { it.validity().toInt() } ?: 0) class Data + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val currency: JsonField, private val priceGroups: JsonField>, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceEvaluateParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceEvaluateParams.kt index 57b24f069..e0731f439 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceEvaluateParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceEvaluateParams.kt @@ -450,6 +450,7 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val timeframeEnd: JsonField, private val timeframeStart: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceEvaluatePreviewEventsParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceEvaluatePreviewEventsParams.kt index 6d6ab6634..dbbf9971a 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceEvaluatePreviewEventsParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceEvaluatePreviewEventsParams.kt @@ -449,6 +449,7 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val timeframeEnd: JsonField, private val timeframeStart: JsonField, @@ -867,6 +868,7 @@ private constructor( } class Event + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val eventName: JsonField, private val properties: JsonField, @@ -1320,6 +1322,7 @@ private constructor( } class PriceEvaluation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val externalPriceId: JsonField, private val filter: JsonField, @@ -2909,6 +2912,7 @@ private constructor( } class GroupedWithMinMaxThresholds + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val currency: JsonField, @@ -4068,6 +4072,7 @@ private constructor( /** Configuration for grouped_with_min_max_thresholds pricing */ class GroupedWithMinMaxThresholdsConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val groupingKey: JsonField, private val maximumCharge: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceEvaluatePreviewEventsResponse.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceEvaluatePreviewEventsResponse.kt index 0c26cd8b1..b1b6f3c15 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceEvaluatePreviewEventsResponse.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceEvaluatePreviewEventsResponse.kt @@ -18,6 +18,7 @@ import java.util.Collections import java.util.Objects class PriceEvaluatePreviewEventsResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val data: JsonField>, private val additionalProperties: MutableMap, @@ -169,6 +170,7 @@ private constructor( internal fun validity(): Int = (data.asKnown()?.sumOf { it.validity().toInt() } ?: 0) class Data + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val currency: JsonField, private val priceGroups: JsonField>, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceEvaluateResponse.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceEvaluateResponse.kt index 4e7398a99..b872f4dbd 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceEvaluateResponse.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceEvaluateResponse.kt @@ -18,6 +18,7 @@ import java.util.Collections import java.util.Objects class PriceEvaluateResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val data: JsonField>, private val additionalProperties: MutableMap, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceExternalPriceIdUpdateParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceExternalPriceIdUpdateParams.kt index d88c0e717..bbc17fe46 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceExternalPriceIdUpdateParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceExternalPriceIdUpdateParams.kt @@ -260,6 +260,7 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val metadata: JsonField, private val additionalProperties: MutableMap, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceInterval.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceInterval.kt index 36fdff885..73d0c7762 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceInterval.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceInterval.kt @@ -23,6 +23,7 @@ import java.util.Objects * subscription. A subscription’s price intervals define its billing behavior. */ class PriceInterval +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val billingCycleDay: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceListPageResponse.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceListPageResponse.kt index 6219ba88e..af0175d43 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceListPageResponse.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceListPageResponse.kt @@ -18,6 +18,7 @@ import java.util.Collections import java.util.Objects class PriceListPageResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val data: JsonField>, private val paginationMetadata: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceUpdateParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceUpdateParams.kt index 837a11fd9..e283530e6 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceUpdateParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceUpdateParams.kt @@ -253,6 +253,7 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val metadata: JsonField, private val additionalProperties: MutableMap, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubLineItemGrouping.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubLineItemGrouping.kt index ff20d0f47..6abe60f1d 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubLineItemGrouping.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubLineItemGrouping.kt @@ -16,6 +16,7 @@ import java.util.Collections import java.util.Objects class SubLineItemGrouping +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val key: JsonField, private val value: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubLineItemMatrixConfig.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubLineItemMatrixConfig.kt index 3aedd4de2..7f6bb8b4d 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubLineItemMatrixConfig.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubLineItemMatrixConfig.kt @@ -18,6 +18,7 @@ import java.util.Collections import java.util.Objects class SubLineItemMatrixConfig +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val dimensionValues: JsonField>, private val additionalProperties: MutableMap, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Subscription.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Subscription.kt index 7f49cc517..91585358b 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Subscription.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Subscription.kt @@ -47,6 +47,7 @@ import java.util.Objects * a recurring fee for the following period. */ class Subscription +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val activePlanPhaseOrder: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionCancelParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionCancelParams.kt index c32bfeaf5..328f96d37 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionCancelParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionCancelParams.kt @@ -393,6 +393,7 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cancelOption: JsonField, private val allowInvoiceCreditOrVoid: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionChangeApplyParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionChangeApplyParams.kt index a267e2a0f..d2f82a33d 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionChangeApplyParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionChangeApplyParams.kt @@ -285,6 +285,7 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val description: JsonField, private val previouslyCollectedAmount: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionChangeApplyResponse.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionChangeApplyResponse.kt index 2b1bbd9a5..bf7eb5b3f 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionChangeApplyResponse.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionChangeApplyResponse.kt @@ -23,6 +23,7 @@ import java.util.Objects * changes/creation of invoices (see `subscription.changed_resources`). */ class SubscriptionChangeApplyResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val expirationTime: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionChangeCancelResponse.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionChangeCancelResponse.kt index 4ec329113..87f4638eb 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionChangeCancelResponse.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionChangeCancelResponse.kt @@ -23,6 +23,7 @@ import java.util.Objects * changes/creation of invoices (see `subscription.changed_resources`). */ class SubscriptionChangeCancelResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val expirationTime: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionChangeMinified.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionChangeMinified.kt index 36a7d285f..0dcaddf53 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionChangeMinified.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionChangeMinified.kt @@ -16,6 +16,7 @@ import java.util.Collections import java.util.Objects class SubscriptionChangeMinified +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val additionalProperties: MutableMap, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionChangeRetrieveResponse.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionChangeRetrieveResponse.kt index 661823286..4f75a7eb3 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionChangeRetrieveResponse.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionChangeRetrieveResponse.kt @@ -23,6 +23,7 @@ import java.util.Objects * changes/creation of invoices (see `subscription.changed_resources`). */ class SubscriptionChangeRetrieveResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val expirationTime: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionCreateParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionCreateParams.kt index 72c3a0357..38f2b579e 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionCreateParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionCreateParams.kt @@ -1651,6 +1651,7 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val addAdjustments: JsonField>, private val addPrices: JsonField>, @@ -3458,6 +3459,7 @@ private constructor( } class AddAdjustment + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val adjustment: JsonField, private val endDate: JsonField, @@ -4116,6 +4118,7 @@ private constructor( } class AddPrice + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val allocationPrice: JsonField, private val discounts: JsonField>, @@ -5987,6 +5990,7 @@ private constructor( } class TieredWithProration + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val itemId: JsonField, @@ -7175,6 +7179,7 @@ private constructor( /** Configuration for tiered_with_proration pricing */ class TieredWithProrationConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val tiers: JsonField>, private val additionalProperties: MutableMap, @@ -7348,6 +7353,7 @@ private constructor( /** Configuration for a single tiered with proration tier */ class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val tierLowerBound: JsonField, private val unitAmount: JsonField, @@ -7753,6 +7759,7 @@ private constructor( } class GroupedWithMinMaxThresholds + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val groupedWithMinMaxThresholdsConfig: @@ -8960,6 +8967,7 @@ private constructor( /** Configuration for grouped_with_min_max_thresholds pricing */ class GroupedWithMinMaxThresholdsConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val groupingKey: JsonField, private val maximumCharge: JsonField, @@ -9729,6 +9737,7 @@ private constructor( } class RemoveAdjustment + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val adjustmentId: JsonField, private val additionalProperties: MutableMap, @@ -9893,6 +9902,7 @@ private constructor( } class RemovePrice + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val externalPriceId: JsonField, private val priceId: JsonField, @@ -10078,6 +10088,7 @@ private constructor( } class ReplaceAdjustment + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val adjustment: JsonField, private val replacesAdjustmentId: JsonField, @@ -10642,6 +10653,7 @@ private constructor( } class ReplacePrice + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val replacesPriceId: JsonField, private val allocationPrice: JsonField, @@ -12483,6 +12495,7 @@ private constructor( } class TieredWithProration + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val itemId: JsonField, @@ -13671,6 +13684,7 @@ private constructor( /** Configuration for tiered_with_proration pricing */ class TieredWithProrationConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val tiers: JsonField>, private val additionalProperties: MutableMap, @@ -13844,6 +13858,7 @@ private constructor( /** Configuration for a single tiered with proration tier */ class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val tierLowerBound: JsonField, private val unitAmount: JsonField, @@ -14249,6 +14264,7 @@ private constructor( } class GroupedWithMinMaxThresholds + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val groupedWithMinMaxThresholdsConfig: @@ -15456,6 +15472,7 @@ private constructor( /** Configuration for grouped_with_min_max_thresholds pricing */ class GroupedWithMinMaxThresholdsConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val groupingKey: JsonField, private val maximumCharge: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchCostsResponse.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchCostsResponse.kt index 1b901fc72..8fc613442 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchCostsResponse.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchCostsResponse.kt @@ -18,6 +18,7 @@ import java.util.Collections import java.util.Objects class SubscriptionFetchCostsResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val data: JsonField>, private val additionalProperties: MutableMap, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchSchedulePageResponse.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchSchedulePageResponse.kt index 58a19fe19..27a2ca581 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchSchedulePageResponse.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchSchedulePageResponse.kt @@ -18,6 +18,7 @@ import java.util.Collections import java.util.Objects class SubscriptionFetchSchedulePageResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val data: JsonField>, private val paginationMetadata: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchScheduleResponse.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchScheduleResponse.kt index 04aa641ed..a7f4bc11b 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchScheduleResponse.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchScheduleResponse.kt @@ -17,6 +17,7 @@ import java.util.Collections import java.util.Objects class SubscriptionFetchScheduleResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val createdAt: JsonField, private val endDate: JsonField, @@ -264,6 +265,7 @@ private constructor( (if (startDate.asKnown() == null) 0 else 1) class Plan + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val externalPlanId: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionMinified.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionMinified.kt index 682241e20..e506f9cf1 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionMinified.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionMinified.kt @@ -16,6 +16,7 @@ import java.util.Collections import java.util.Objects class SubscriptionMinified +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val additionalProperties: MutableMap, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsParams.kt index 82652d6b3..b3b2f49e4 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsParams.kt @@ -497,6 +497,7 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val add: JsonField>, private val addAdjustments: JsonField>, @@ -887,6 +888,7 @@ private constructor( } class Add + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val startDate: JsonField, private val allocationPrice: JsonField, @@ -2156,6 +2158,7 @@ private constructor( } class Amount + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val amountDiscount: JsonField, private val discountType: JsonValue, @@ -2371,6 +2374,7 @@ private constructor( } class Percentage + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val discountType: JsonValue, private val percentageDiscount: JsonField, @@ -2591,6 +2595,7 @@ private constructor( } class Usage + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val discountType: JsonValue, private val usageDiscount: JsonField, @@ -2996,6 +3001,7 @@ private constructor( } class FixedFeeQuantityTransition + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val effectiveDate: JsonField, private val quantity: JsonField, @@ -4359,6 +4365,7 @@ private constructor( } class GroupedWithMinMaxThresholds + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val currency: JsonField, @@ -5518,6 +5525,7 @@ private constructor( /** Configuration for grouped_with_min_max_thresholds pricing */ class GroupedWithMinMaxThresholdsConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val groupingKey: JsonField, private val maximumCharge: JsonField, @@ -6051,6 +6059,7 @@ private constructor( } class AddAdjustment + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val startDate: JsonField, private val adjustment: JsonField, @@ -7102,6 +7111,7 @@ private constructor( } class Edit + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val priceIntervalId: JsonField, private val billingCycleDay: JsonField, @@ -7778,6 +7788,7 @@ private constructor( } class FixedFeeQuantityTransition + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val effectiveDate: JsonField, private val quantity: JsonField, @@ -8213,6 +8224,7 @@ private constructor( } class EditAdjustment + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val adjustmentIntervalId: JsonField, private val endDate: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionRedeemCouponParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionRedeemCouponParams.kt index 4d9141ea5..a384196b1 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionRedeemCouponParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionRedeemCouponParams.kt @@ -400,6 +400,7 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val changeOption: JsonField, private val allowInvoiceCreditOrVoid: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionSchedulePlanChangeParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionSchedulePlanChangeParams.kt index a58fce9a4..0b2a16f47 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionSchedulePlanChangeParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionSchedulePlanChangeParams.kt @@ -1433,6 +1433,7 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val changeOption: JsonField, private val addAdjustments: JsonField>, @@ -3116,6 +3117,7 @@ private constructor( } class AddAdjustment + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val adjustment: JsonField, private val endDate: JsonField, @@ -3774,6 +3776,7 @@ private constructor( } class AddPrice + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val allocationPrice: JsonField, private val discounts: JsonField>, @@ -5645,6 +5648,7 @@ private constructor( } class TieredWithProration + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val itemId: JsonField, @@ -6833,6 +6837,7 @@ private constructor( /** Configuration for tiered_with_proration pricing */ class TieredWithProrationConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val tiers: JsonField>, private val additionalProperties: MutableMap, @@ -7006,6 +7011,7 @@ private constructor( /** Configuration for a single tiered with proration tier */ class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val tierLowerBound: JsonField, private val unitAmount: JsonField, @@ -7411,6 +7417,7 @@ private constructor( } class GroupedWithMinMaxThresholds + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val groupedWithMinMaxThresholdsConfig: @@ -8618,6 +8625,7 @@ private constructor( /** Configuration for grouped_with_min_max_thresholds pricing */ class GroupedWithMinMaxThresholdsConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val groupingKey: JsonField, private val maximumCharge: JsonField, @@ -9289,6 +9297,7 @@ private constructor( } class RemoveAdjustment + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val adjustmentId: JsonField, private val additionalProperties: MutableMap, @@ -9453,6 +9462,7 @@ private constructor( } class RemovePrice + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val externalPriceId: JsonField, private val priceId: JsonField, @@ -9638,6 +9648,7 @@ private constructor( } class ReplaceAdjustment + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val adjustment: JsonField, private val replacesAdjustmentId: JsonField, @@ -10202,6 +10213,7 @@ private constructor( } class ReplacePrice + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val replacesPriceId: JsonField, private val allocationPrice: JsonField, @@ -12043,6 +12055,7 @@ private constructor( } class TieredWithProration + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val itemId: JsonField, @@ -13231,6 +13244,7 @@ private constructor( /** Configuration for tiered_with_proration pricing */ class TieredWithProrationConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val tiers: JsonField>, private val additionalProperties: MutableMap, @@ -13404,6 +13418,7 @@ private constructor( /** Configuration for a single tiered with proration tier */ class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val tierLowerBound: JsonField, private val unitAmount: JsonField, @@ -13809,6 +13824,7 @@ private constructor( } class GroupedWithMinMaxThresholds + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val groupedWithMinMaxThresholdsConfig: @@ -15016,6 +15032,7 @@ private constructor( /** Configuration for grouped_with_min_max_thresholds pricing */ class GroupedWithMinMaxThresholdsConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val groupingKey: JsonField, private val maximumCharge: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionTrialInfo.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionTrialInfo.kt index ba59760f7..8a1682d0c 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionTrialInfo.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionTrialInfo.kt @@ -17,6 +17,7 @@ import java.util.Collections import java.util.Objects class SubscriptionTrialInfo +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val endDate: JsonField, private val additionalProperties: MutableMap, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionTriggerPhaseParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionTriggerPhaseParams.kt index 7500185ab..6da97359f 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionTriggerPhaseParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionTriggerPhaseParams.kt @@ -300,6 +300,7 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val allowInvoiceCreditOrVoid: JsonField, private val effectiveDate: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionUnscheduleFixedFeeQuantityUpdatesParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionUnscheduleFixedFeeQuantityUpdatesParams.kt index ca0b4a719..38c5ef573 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionUnscheduleFixedFeeQuantityUpdatesParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionUnscheduleFixedFeeQuantityUpdatesParams.kt @@ -267,6 +267,7 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val priceId: JsonField, private val additionalProperties: MutableMap, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionUpdateFixedFeeQuantityParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionUpdateFixedFeeQuantityParams.kt index 6fd2f305f..4b4e0f576 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionUpdateFixedFeeQuantityParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionUpdateFixedFeeQuantityParams.kt @@ -421,6 +421,7 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val priceId: JsonField, private val quantity: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionUpdateParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionUpdateParams.kt index 200c4a543..0998c1de4 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionUpdateParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionUpdateParams.kt @@ -412,6 +412,7 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val autoCollection: JsonField, private val defaultInvoiceMemo: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionUpdateTrialParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionUpdateTrialParams.kt index fdde9ae03..c6389573c 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionUpdateTrialParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionUpdateTrialParams.kt @@ -336,6 +336,7 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val trialEndDate: JsonField, private val shift: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionUsage.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionUsage.kt index 90290ccaa..257da5315 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionUsage.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionUsage.kt @@ -205,6 +205,7 @@ private constructor( } class UngroupedSubscriptionUsage + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val data: JsonField>, private val additionalProperties: MutableMap, @@ -357,6 +358,7 @@ private constructor( internal fun validity(): Int = (data.asKnown()?.sumOf { it.validity().toInt() } ?: 0) class Data + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val billableMetric: JsonField, private val usage: JsonField>, @@ -595,6 +597,7 @@ private constructor( (viewMode.asKnown()?.validity() ?: 0) class BillableMetric + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val name: JsonField, @@ -789,6 +792,7 @@ private constructor( } class Usage + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val quantity: JsonField, private val timeframeEnd: JsonField, @@ -1210,6 +1214,7 @@ private constructor( } class GroupedSubscriptionUsage + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val data: JsonField>, private val paginationMetadata: JsonField, @@ -1401,6 +1406,7 @@ private constructor( (paginationMetadata.asKnown()?.validity() ?: 0) class Data + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val billableMetric: JsonField, private val metricGroup: JsonField, @@ -1680,6 +1686,7 @@ private constructor( (viewMode.asKnown()?.validity() ?: 0) class BillableMetric + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val name: JsonField, @@ -1874,6 +1881,7 @@ private constructor( } class MetricGroup + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val propertyKey: JsonField, private val propertyValue: JsonField, @@ -2085,6 +2093,7 @@ private constructor( } class Usage + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val quantity: JsonField, private val timeframeEnd: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Subscriptions.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Subscriptions.kt index 66a15fdb9..52fa8d023 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Subscriptions.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Subscriptions.kt @@ -18,6 +18,7 @@ import java.util.Collections import java.util.Objects class Subscriptions +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val data: JsonField>, private val paginationMetadata: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/TaxAmount.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/TaxAmount.kt index 76025a6fd..ae94b814d 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/TaxAmount.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/TaxAmount.kt @@ -16,6 +16,7 @@ import java.util.Collections import java.util.Objects class TaxAmount +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val amount: JsonField, private val taxRateDescription: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Threshold.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Threshold.kt index 7ea71ba27..383b0107e 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Threshold.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Threshold.kt @@ -17,6 +17,7 @@ import java.util.Objects /** Thresholds are used to define the conditions under which an alert will be triggered. */ class Threshold +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val value: JsonField, private val additionalProperties: MutableMap, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Tier.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Tier.kt index 940a94599..150266f14 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Tier.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Tier.kt @@ -17,6 +17,7 @@ import java.util.Objects /** Configuration for a single tier */ class Tier +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val firstUnit: JsonField, private val unitAmount: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/TierSubLineItem.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/TierSubLineItem.kt index 04204455f..b4a02b4f3 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/TierSubLineItem.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/TierSubLineItem.kt @@ -17,6 +17,7 @@ import java.util.Collections import java.util.Objects class TierSubLineItem +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val amount: JsonField, private val grouping: JsonField, @@ -325,6 +326,7 @@ private constructor( (type.asKnown()?.validity() ?: 0) class TierConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val firstUnit: JsonField, private val lastUnit: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/TieredConfig.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/TieredConfig.kt index bf59ed7a1..083335ed1 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/TieredConfig.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/TieredConfig.kt @@ -19,6 +19,7 @@ import java.util.Objects /** Configuration for tiered pricing */ class TieredConfig +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val tiers: JsonField>, private val additionalProperties: MutableMap, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/TieredConversionRateConfig.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/TieredConversionRateConfig.kt index cdfaa4420..f1cc5d2c5 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/TieredConversionRateConfig.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/TieredConversionRateConfig.kt @@ -17,6 +17,7 @@ import java.util.Collections import java.util.Objects class TieredConversionRateConfig +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val conversionRateType: JsonField, private val tieredConfig: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/TopLevelPingResponse.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/TopLevelPingResponse.kt index 5d0ef4811..7c41350c0 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/TopLevelPingResponse.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/TopLevelPingResponse.kt @@ -16,6 +16,7 @@ import java.util.Collections import java.util.Objects class TopLevelPingResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val response: JsonField, private val additionalProperties: MutableMap, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/TopUpInvoiceSettings.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/TopUpInvoiceSettings.kt index f0f83be14..82792f392 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/TopUpInvoiceSettings.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/TopUpInvoiceSettings.kt @@ -16,6 +16,7 @@ import java.util.Collections import java.util.Objects class TopUpInvoiceSettings +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val autoCollection: JsonField, private val netTerms: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/TransformPriceFilter.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/TransformPriceFilter.kt index 18b88e1d7..12c402f4c 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/TransformPriceFilter.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/TransformPriceFilter.kt @@ -19,6 +19,7 @@ import java.util.Collections import java.util.Objects class TransformPriceFilter +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val field: JsonField, private val operator: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/TrialDiscount.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/TrialDiscount.kt index e4ea852ed..69d9031fe 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/TrialDiscount.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/TrialDiscount.kt @@ -19,6 +19,7 @@ import java.util.Collections import java.util.Objects class TrialDiscount +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val discountType: JsonField, private val appliesToPriceIds: JsonField>, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/UnitConfig.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/UnitConfig.kt index 6c0ea6e81..26150406a 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/UnitConfig.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/UnitConfig.kt @@ -17,6 +17,7 @@ import java.util.Objects /** Configuration for unit pricing */ class UnitConfig +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val unitAmount: JsonField, private val scalingFactor: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/UnitConversionRateConfig.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/UnitConversionRateConfig.kt index 137b5b655..f5737831d 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/UnitConversionRateConfig.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/UnitConversionRateConfig.kt @@ -17,6 +17,7 @@ import java.util.Collections import java.util.Objects class UnitConversionRateConfig +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val conversionRateType: JsonField, private val unitConfig: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/UsageDiscount.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/UsageDiscount.kt index 7a022de7a..c4c91b584 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/UsageDiscount.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/UsageDiscount.kt @@ -19,6 +19,7 @@ import java.util.Collections import java.util.Objects class UsageDiscount +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val discountType: JsonField, private val usageDiscount: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/UsageDiscountInterval.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/UsageDiscountInterval.kt index bb9acdb0c..e2cf8b9c9 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/UsageDiscountInterval.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/UsageDiscountInterval.kt @@ -20,6 +20,7 @@ import java.util.Collections import java.util.Objects class UsageDiscountInterval +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val appliesToPriceIntervalIds: JsonField>, private val discountType: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/VoidInitiatedLedgerEntry.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/VoidInitiatedLedgerEntry.kt index 76713a0c3..7871bcf7e 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/VoidInitiatedLedgerEntry.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/VoidInitiatedLedgerEntry.kt @@ -19,6 +19,7 @@ import java.util.Collections import java.util.Objects class VoidInitiatedLedgerEntry +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val amount: JsonField, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/VoidLedgerEntry.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/VoidLedgerEntry.kt index 7435195a7..ada0c53b7 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/VoidLedgerEntry.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/VoidLedgerEntry.kt @@ -19,6 +19,7 @@ import java.util.Collections import java.util.Objects class VoidLedgerEntry +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val amount: JsonField, From a05fab462983dba1d6c3755e1e1a65d24a527f60 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 29 Sep 2025 18:32:52 +0000 Subject: [PATCH 22/68] feat(api): api update --- .stats.yml | 4 +- .../models/SubscriptionChangeApplyParams.kt | 117 ++++++++++++++++-- .../SubscriptionChangeApplyParamsTest.kt | 3 + .../SubscriptionChangeServiceAsyncTest.kt | 1 + .../blocking/SubscriptionChangeServiceTest.kt | 1 + 5 files changed, 116 insertions(+), 10 deletions(-) diff --git a/.stats.yml b/.stats.yml index d522ff7be..b0dfd8e38 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 118 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-42aa43f3893eef31a351e066bf0cf8c56da8c857ccbb45eb7dd58739ad43bd86.yml -openapi_spec_hash: e6b8c1e707036539d88a7b79af864a49 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-c075f748a7de8ecdccf11a8f2374682b0efd84f1318147274a838bf2fdd73b58.yml +openapi_spec_hash: ae918b8f348f1b7d3252a59dac36c453 config_hash: 1f73a949b649ecfe6ec68ba1bb459dc2 diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionChangeApplyParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionChangeApplyParams.kt index d2f82a33d..7f169e4d0 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionChangeApplyParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionChangeApplyParams.kt @@ -41,7 +41,17 @@ private constructor( fun description(): String? = body.description() /** - * Amount already collected to apply to the customer's balance. + * Mark all pending invoices that are payable as paid. If amount is also provided, mark as paid + * and credit the difference to the customer's balance. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun markAsPaid(): Boolean? = body.markAsPaid() + + /** + * Amount already collected to apply to the customer's balance. If mark_as_paid is also + * provided, credit the difference to the customer's balance. * * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server * responded with an unexpected value). @@ -55,6 +65,13 @@ private constructor( */ fun _description(): JsonField = body._description() + /** + * Returns the raw JSON value of [markAsPaid]. + * + * Unlike [markAsPaid], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _markAsPaid(): JsonField = body._markAsPaid() + /** * Returns the raw JSON value of [previouslyCollectedAmount]. * @@ -109,6 +126,7 @@ private constructor( * This is generally only useful if you are already constructing the body separately. * Otherwise, it's more convenient to use the top-level setters instead: * - [description] + * - [markAsPaid] * - [previouslyCollectedAmount] */ fun body(body: Body) = apply { this.body = body.toBuilder() } @@ -125,7 +143,32 @@ private constructor( */ fun description(description: JsonField) = apply { body.description(description) } - /** Amount already collected to apply to the customer's balance. */ + /** + * Mark all pending invoices that are payable as paid. If amount is also provided, mark as + * paid and credit the difference to the customer's balance. + */ + fun markAsPaid(markAsPaid: Boolean?) = apply { body.markAsPaid(markAsPaid) } + + /** + * Alias for [Builder.markAsPaid]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun markAsPaid(markAsPaid: Boolean) = markAsPaid(markAsPaid as Boolean?) + + /** + * Sets [Builder.markAsPaid] to an arbitrary JSON value. + * + * You should usually call [Builder.markAsPaid] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun markAsPaid(markAsPaid: JsonField) = apply { body.markAsPaid(markAsPaid) } + + /** + * Amount already collected to apply to the customer's balance. If mark_as_paid is also + * provided, credit the difference to the customer's balance. + */ fun previouslyCollectedAmount(previouslyCollectedAmount: String?) = apply { body.previouslyCollectedAmount(previouslyCollectedAmount) } @@ -288,6 +331,7 @@ private constructor( @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val description: JsonField, + private val markAsPaid: JsonField, private val previouslyCollectedAmount: JsonField, private val additionalProperties: MutableMap, ) { @@ -297,10 +341,13 @@ private constructor( @JsonProperty("description") @ExcludeMissing description: JsonField = JsonMissing.of(), + @JsonProperty("mark_as_paid") + @ExcludeMissing + markAsPaid: JsonField = JsonMissing.of(), @JsonProperty("previously_collected_amount") @ExcludeMissing previouslyCollectedAmount: JsonField = JsonMissing.of(), - ) : this(description, previouslyCollectedAmount, mutableMapOf()) + ) : this(description, markAsPaid, previouslyCollectedAmount, mutableMapOf()) /** * Description to apply to the balance transaction representing this credit. @@ -311,7 +358,17 @@ private constructor( fun description(): String? = description.getNullable("description") /** - * Amount already collected to apply to the customer's balance. + * Mark all pending invoices that are payable as paid. If amount is also provided, mark as + * paid and credit the difference to the customer's balance. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun markAsPaid(): Boolean? = markAsPaid.getNullable("mark_as_paid") + + /** + * Amount already collected to apply to the customer's balance. If mark_as_paid is also + * provided, credit the difference to the customer's balance. * * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -328,6 +385,15 @@ private constructor( @ExcludeMissing fun _description(): JsonField = description + /** + * Returns the raw JSON value of [markAsPaid]. + * + * Unlike [markAsPaid], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("mark_as_paid") + @ExcludeMissing + fun _markAsPaid(): JsonField = markAsPaid + /** * Returns the raw JSON value of [previouslyCollectedAmount]. * @@ -360,11 +426,13 @@ private constructor( class Builder internal constructor() { private var description: JsonField = JsonMissing.of() + private var markAsPaid: JsonField = JsonMissing.of() private var previouslyCollectedAmount: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() internal fun from(body: Body) = apply { description = body.description + markAsPaid = body.markAsPaid previouslyCollectedAmount = body.previouslyCollectedAmount additionalProperties = body.additionalProperties.toMutableMap() } @@ -383,7 +451,32 @@ private constructor( this.description = description } - /** Amount already collected to apply to the customer's balance. */ + /** + * Mark all pending invoices that are payable as paid. If amount is also provided, mark + * as paid and credit the difference to the customer's balance. + */ + fun markAsPaid(markAsPaid: Boolean?) = markAsPaid(JsonField.ofNullable(markAsPaid)) + + /** + * Alias for [Builder.markAsPaid]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun markAsPaid(markAsPaid: Boolean) = markAsPaid(markAsPaid as Boolean?) + + /** + * Sets [Builder.markAsPaid] to an arbitrary JSON value. + * + * You should usually call [Builder.markAsPaid] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun markAsPaid(markAsPaid: JsonField) = apply { this.markAsPaid = markAsPaid } + + /** + * Amount already collected to apply to the customer's balance. If mark_as_paid is also + * provided, credit the difference to the customer's balance. + */ fun previouslyCollectedAmount(previouslyCollectedAmount: String?) = previouslyCollectedAmount(JsonField.ofNullable(previouslyCollectedAmount)) @@ -423,7 +516,12 @@ private constructor( * Further updates to this [Builder] will not mutate the returned instance. */ fun build(): Body = - Body(description, previouslyCollectedAmount, additionalProperties.toMutableMap()) + Body( + description, + markAsPaid, + previouslyCollectedAmount, + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false @@ -434,6 +532,7 @@ private constructor( } description() + markAsPaid() previouslyCollectedAmount() validated = true } @@ -454,6 +553,7 @@ private constructor( */ internal fun validity(): Int = (if (description.asKnown() == null) 0 else 1) + + (if (markAsPaid.asKnown() == null) 0 else 1) + (if (previouslyCollectedAmount.asKnown() == null) 0 else 1) override fun equals(other: Any?): Boolean { @@ -463,18 +563,19 @@ private constructor( return other is Body && description == other.description && + markAsPaid == other.markAsPaid && previouslyCollectedAmount == other.previouslyCollectedAmount && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(description, previouslyCollectedAmount, additionalProperties) + Objects.hash(description, markAsPaid, previouslyCollectedAmount, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "Body{description=$description, previouslyCollectedAmount=$previouslyCollectedAmount, additionalProperties=$additionalProperties}" + "Body{description=$description, markAsPaid=$markAsPaid, previouslyCollectedAmount=$previouslyCollectedAmount, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeApplyParamsTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeApplyParamsTest.kt index 112683b79..b7c625c41 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeApplyParamsTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeApplyParamsTest.kt @@ -12,6 +12,7 @@ internal class SubscriptionChangeApplyParamsTest { SubscriptionChangeApplyParams.builder() .subscriptionChangeId("subscription_change_id") .description("description") + .markAsPaid(true) .previouslyCollectedAmount("previously_collected_amount") .build() } @@ -34,12 +35,14 @@ internal class SubscriptionChangeApplyParamsTest { SubscriptionChangeApplyParams.builder() .subscriptionChangeId("subscription_change_id") .description("description") + .markAsPaid(true) .previouslyCollectedAmount("previously_collected_amount") .build() val body = params._body() assertThat(body.description()).isEqualTo("description") + assertThat(body.markAsPaid()).isEqualTo(true) assertThat(body.previouslyCollectedAmount()).isEqualTo("previously_collected_amount") } diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/SubscriptionChangeServiceAsyncTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/SubscriptionChangeServiceAsyncTest.kt index 8cd31699a..bdb2c1555 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/SubscriptionChangeServiceAsyncTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/SubscriptionChangeServiceAsyncTest.kt @@ -39,6 +39,7 @@ internal class SubscriptionChangeServiceAsyncTest { SubscriptionChangeApplyParams.builder() .subscriptionChangeId("subscription_change_id") .description("description") + .markAsPaid(true) .previouslyCollectedAmount("previously_collected_amount") .build() ) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/SubscriptionChangeServiceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/SubscriptionChangeServiceTest.kt index 4fe649e82..e4ab8a931 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/SubscriptionChangeServiceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/SubscriptionChangeServiceTest.kt @@ -39,6 +39,7 @@ internal class SubscriptionChangeServiceTest { SubscriptionChangeApplyParams.builder() .subscriptionChangeId("subscription_change_id") .description("description") + .markAsPaid(true) .previouslyCollectedAmount("previously_collected_amount") .build() ) From db43b8704deef90ccf75561c24ec28cc9e254a0f Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 29 Sep 2025 21:32:57 +0000 Subject: [PATCH 23/68] codegen metadata --- .stats.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.stats.yml b/.stats.yml index b0dfd8e38..b104a7d73 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 118 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-c075f748a7de8ecdccf11a8f2374682b0efd84f1318147274a838bf2fdd73b58.yml -openapi_spec_hash: ae918b8f348f1b7d3252a59dac36c453 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-ab79d1df8310a4fc3089fcf814f9fb00c7341acc254aafe34479af0f871d244b.yml +openapi_spec_hash: 9416d6718ca4eeb3c20790187348b5b0 config_hash: 1f73a949b649ecfe6ec68ba1bb459dc2 From c4c96c6e42c74985376828b8efe6d03e0dcb91b5 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 30 Sep 2025 22:33:15 +0000 Subject: [PATCH 24/68] feat(api): api update --- .stats.yml | 4 ++-- .../api/models/SubscriptionListParams.kt | 24 ++++++++++++++++++- .../api/models/SubscriptionListParamsTest.kt | 6 +++++ 3 files changed, 31 insertions(+), 3 deletions(-) diff --git a/.stats.yml b/.stats.yml index b104a7d73..4975db477 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 118 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-ab79d1df8310a4fc3089fcf814f9fb00c7341acc254aafe34479af0f871d244b.yml -openapi_spec_hash: 9416d6718ca4eeb3c20790187348b5b0 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-b6ec9a6bf40b74575d917ab145b2413bc61dcd6989bb9d1aa41624bf3437599e.yml +openapi_spec_hash: 53cf9363c3bd9649e0af5f713abdcba7 config_hash: 1f73a949b649ecfe6ec68ba1bb459dc2 diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionListParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionListParams.kt index 1a4a2561e..2548aeaa9 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionListParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionListParams.kt @@ -33,7 +33,9 @@ private constructor( private val cursor: String?, private val customerId: List?, private val externalCustomerId: List?, + private val externalPlanId: String?, private val limit: Long?, + private val planId: String?, private val status: Status?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, @@ -57,9 +59,13 @@ private constructor( fun externalCustomerId(): List? = externalCustomerId + fun externalPlanId(): String? = externalPlanId + /** The number of items to fetch. Defaults to 20. */ fun limit(): Long? = limit + fun planId(): String? = planId + fun status(): Status? = status /** Additional headers to send with the request. */ @@ -88,7 +94,9 @@ private constructor( private var cursor: String? = null private var customerId: MutableList? = null private var externalCustomerId: MutableList? = null + private var externalPlanId: String? = null private var limit: Long? = null + private var planId: String? = null private var status: Status? = null private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @@ -101,7 +109,9 @@ private constructor( cursor = subscriptionListParams.cursor customerId = subscriptionListParams.customerId?.toMutableList() externalCustomerId = subscriptionListParams.externalCustomerId?.toMutableList() + externalPlanId = subscriptionListParams.externalPlanId limit = subscriptionListParams.limit + planId = subscriptionListParams.planId status = subscriptionListParams.status additionalHeaders = subscriptionListParams.additionalHeaders.toBuilder() additionalQueryParams = subscriptionListParams.additionalQueryParams.toBuilder() @@ -148,6 +158,8 @@ private constructor( (this.externalCustomerId ?: mutableListOf()).apply { add(externalCustomerId) } } + fun externalPlanId(externalPlanId: String?) = apply { this.externalPlanId = externalPlanId } + /** The number of items to fetch. Defaults to 20. */ fun limit(limit: Long?) = apply { this.limit = limit } @@ -158,6 +170,8 @@ private constructor( */ fun limit(limit: Long) = limit(limit as Long?) + fun planId(planId: String?) = apply { this.planId = planId } + fun status(status: Status?) = apply { this.status = status } fun additionalHeaders(additionalHeaders: Headers) = apply { @@ -272,7 +286,9 @@ private constructor( cursor, customerId?.toImmutable(), externalCustomerId?.toImmutable(), + externalPlanId, limit, + planId, status, additionalHeaders.build(), additionalQueryParams.build(), @@ -299,7 +315,9 @@ private constructor( cursor?.let { put("cursor", it) } customerId?.forEach { put("customer_id[]", it) } externalCustomerId?.forEach { put("external_customer_id[]", it) } + externalPlanId?.let { put("external_plan_id", it) } limit?.let { put("limit", it.toString()) } + planId?.let { put("plan_id", it) } status?.let { put("status", it.toString()) } putAll(additionalQueryParams) } @@ -448,7 +466,9 @@ private constructor( cursor == other.cursor && customerId == other.customerId && externalCustomerId == other.externalCustomerId && + externalPlanId == other.externalPlanId && limit == other.limit && + planId == other.planId && status == other.status && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams @@ -463,12 +483,14 @@ private constructor( cursor, customerId, externalCustomerId, + externalPlanId, limit, + planId, status, additionalHeaders, additionalQueryParams, ) override fun toString() = - "SubscriptionListParams{createdAtGt=$createdAtGt, createdAtGte=$createdAtGte, createdAtLt=$createdAtLt, createdAtLte=$createdAtLte, cursor=$cursor, customerId=$customerId, externalCustomerId=$externalCustomerId, limit=$limit, status=$status, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + "SubscriptionListParams{createdAtGt=$createdAtGt, createdAtGte=$createdAtGte, createdAtLt=$createdAtLt, createdAtLte=$createdAtLte, cursor=$cursor, customerId=$customerId, externalCustomerId=$externalCustomerId, externalPlanId=$externalPlanId, limit=$limit, planId=$planId, status=$status, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionListParamsTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionListParamsTest.kt index 1c1c73dd5..2fdd22e5b 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionListParamsTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionListParamsTest.kt @@ -19,7 +19,9 @@ internal class SubscriptionListParamsTest { .cursor("cursor") .addCustomerId("string") .addExternalCustomerId("string") + .externalPlanId("external_plan_id") .limit(1L) + .planId("plan_id") .status(SubscriptionListParams.Status.ACTIVE) .build() } @@ -35,7 +37,9 @@ internal class SubscriptionListParamsTest { .cursor("cursor") .addCustomerId("string") .addExternalCustomerId("string") + .externalPlanId("external_plan_id") .limit(1L) + .planId("plan_id") .status(SubscriptionListParams.Status.ACTIVE) .build() @@ -51,7 +55,9 @@ internal class SubscriptionListParamsTest { .put("cursor", "cursor") .put("customer_id[]", "string") .put("external_customer_id[]", "string") + .put("external_plan_id", "external_plan_id") .put("limit", "1") + .put("plan_id", "plan_id") .put("status", "active") .build() ) From c427776d050d0cc71128bbd7c1f985bf70df342c Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 3 Oct 2025 18:33:17 +0000 Subject: [PATCH 25/68] feat(api): api update --- .stats.yml | 4 +- .../com/withorb/api/models/UnitConfig.kt | 67 ++----------------- .../withorb/api/models/AggregatedCostTest.kt | 21 +----- .../models/BetaCreatePlanVersionParamsTest.kt | 42 ++---------- ...ternalPlanIdCreatePlanVersionParamsTest.kt | 42 ++---------- .../ChangedSubscriptionResourcesTest.kt | 30 ++------- ...ustomerCostListByExternalIdResponseTest.kt | 15 +---- .../models/CustomerCostListResponseTest.kt | 15 +---- ...dgerCreateEntryByExternalIdResponseTest.kt | 6 +- ...omerCreditLedgerCreateEntryResponseTest.kt | 6 +- ...tLedgerListByExternalIdPageResponseTest.kt | 3 - ...reditLedgerListByExternalIdResponseTest.kt | 6 +- ...ustomerCreditLedgerListPageResponseTest.kt | 3 - .../CustomerCreditLedgerListResponseTest.kt | 6 +- .../api/models/IncrementLedgerEntryTest.kt | 15 +---- .../api/models/InvoiceCreateParamsTest.kt | 15 +---- .../InvoiceFetchUpcomingResponseTest.kt | 21 +----- .../InvoiceLineItemCreateResponseTest.kt | 21 +----- .../api/models/InvoiceListPageResponseTest.kt | 15 +---- .../com/withorb/api/models/InvoiceTest.kt | 21 +----- .../api/models/MutatedSubscriptionTest.kt | 48 ++----------- .../api/models/NewFloatingUnitPriceTest.kt | 10 +-- .../api/models/NewPlanUnitPriceTest.kt | 10 +-- .../models/NewSubscriptionUnitPriceTest.kt | 10 +-- .../withorb/api/models/PerPriceCostTest.kt | 21 +----- .../api/models/PlanCreateParamsTest.kt | 21 +----- .../api/models/PlanListPageResponseTest.kt | 21 +----- .../kotlin/com/withorb/api/models/PlanTest.kt | 21 +----- .../com/withorb/api/models/PlanVersionTest.kt | 21 +----- .../api/models/PriceCreateParamsTest.kt | 18 +---- .../models/PriceEvaluateMultipleParamsTest.kt | 21 +----- .../PriceEvaluatePreviewEventsParamsTest.kt | 21 +----- .../withorb/api/models/PriceIntervalTest.kt | 21 +----- .../api/models/PriceListPageResponseTest.kt | 21 +----- .../com/withorb/api/models/PriceTest.kt | 8 +-- .../SubscriptionChangeApplyResponseTest.kt | 36 ++-------- .../SubscriptionChangeCancelResponseTest.kt | 36 ++-------- .../SubscriptionChangeRetrieveResponseTest.kt | 36 ++-------- .../models/SubscriptionCreateParamsTest.kt | 42 ++---------- .../SubscriptionFetchCostsResponseTest.kt | 15 +---- .../SubscriptionPriceIntervalsParamsTest.kt | 21 +----- ...ubscriptionSchedulePlanChangeParamsTest.kt | 42 ++---------- .../withorb/api/models/SubscriptionTest.kt | 42 ++---------- .../withorb/api/models/SubscriptionsTest.kt | 30 ++------- .../com/withorb/api/models/UnitConfigTest.kt | 5 +- .../services/async/BetaServiceAsyncTest.kt | 10 +-- .../services/async/InvoiceServiceAsyncTest.kt | 7 +- .../services/async/PlanServiceAsyncTest.kt | 5 +- .../services/async/PriceServiceAsyncTest.kt | 17 +---- .../async/SubscriptionServiceAsyncTest.kt | 25 ++----- .../beta/ExternalPlanIdServiceAsyncTest.kt | 10 +-- .../api/services/blocking/BetaServiceTest.kt | 10 +-- .../services/blocking/InvoiceServiceTest.kt | 7 +- .../api/services/blocking/PlanServiceTest.kt | 5 +- .../api/services/blocking/PriceServiceTest.kt | 17 +---- .../blocking/SubscriptionServiceTest.kt | 25 ++----- .../beta/ExternalPlanIdServiceTest.kt | 10 +-- 57 files changed, 182 insertions(+), 938 deletions(-) diff --git a/.stats.yml b/.stats.yml index 4975db477..05461dff9 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 118 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-b6ec9a6bf40b74575d917ab145b2413bc61dcd6989bb9d1aa41624bf3437599e.yml -openapi_spec_hash: 53cf9363c3bd9649e0af5f713abdcba7 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-b330498c2bfb80605f4c406e8b228c0a4ece85247b21f62f93273a00abb53d35.yml +openapi_spec_hash: 16a82d0eb23b68218d584e385bee43da config_hash: 1f73a949b649ecfe6ec68ba1bb459dc2 diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/UnitConfig.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/UnitConfig.kt index 26150406a..f0863274a 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/UnitConfig.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/UnitConfig.kt @@ -20,7 +20,6 @@ class UnitConfig @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val unitAmount: JsonField, - private val scalingFactor: JsonField, private val additionalProperties: MutableMap, ) { @@ -28,11 +27,8 @@ private constructor( private constructor( @JsonProperty("unit_amount") @ExcludeMissing - unitAmount: JsonField = JsonMissing.of(), - @JsonProperty("scaling_factor") - @ExcludeMissing - scalingFactor: JsonField = JsonMissing.of(), - ) : this(unitAmount, scalingFactor, mutableMapOf()) + unitAmount: JsonField = JsonMissing.of() + ) : this(unitAmount, mutableMapOf()) /** * Rate per unit of usage @@ -42,14 +38,6 @@ private constructor( */ fun unitAmount(): String = unitAmount.getRequired("unit_amount") - /** - * Multiplier to scale rated quantity by - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - fun scalingFactor(): Double? = scalingFactor.getNullable("scaling_factor") - /** * Returns the raw JSON value of [unitAmount]. * @@ -57,15 +45,6 @@ private constructor( */ @JsonProperty("unit_amount") @ExcludeMissing fun _unitAmount(): JsonField = unitAmount - /** - * Returns the raw JSON value of [scalingFactor]. - * - * Unlike [scalingFactor], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("scaling_factor") - @ExcludeMissing - fun _scalingFactor(): JsonField = scalingFactor - @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -95,12 +74,10 @@ private constructor( class Builder internal constructor() { private var unitAmount: JsonField? = null - private var scalingFactor: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() internal fun from(unitConfig: UnitConfig) = apply { unitAmount = unitConfig.unitAmount - scalingFactor = unitConfig.scalingFactor additionalProperties = unitConfig.additionalProperties.toMutableMap() } @@ -116,28 +93,6 @@ private constructor( */ fun unitAmount(unitAmount: JsonField) = apply { this.unitAmount = unitAmount } - /** Multiplier to scale rated quantity by */ - fun scalingFactor(scalingFactor: Double?) = - scalingFactor(JsonField.ofNullable(scalingFactor)) - - /** - * Alias for [Builder.scalingFactor]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun scalingFactor(scalingFactor: Double) = scalingFactor(scalingFactor as Double?) - - /** - * Sets [Builder.scalingFactor] to an arbitrary JSON value. - * - * You should usually call [Builder.scalingFactor] with a well-typed [Double] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun scalingFactor(scalingFactor: JsonField) = apply { - this.scalingFactor = scalingFactor - } - fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -170,11 +125,7 @@ private constructor( * @throws IllegalStateException if any required field is unset. */ fun build(): UnitConfig = - UnitConfig( - checkRequired("unitAmount", unitAmount), - scalingFactor, - additionalProperties.toMutableMap(), - ) + UnitConfig(checkRequired("unitAmount", unitAmount), additionalProperties.toMutableMap()) } private var validated: Boolean = false @@ -185,7 +136,6 @@ private constructor( } unitAmount() - scalingFactor() validated = true } @@ -202,9 +152,7 @@ private constructor( * * Used for best match union deserialization. */ - internal fun validity(): Int = - (if (unitAmount.asKnown() == null) 0 else 1) + - (if (scalingFactor.asKnown() == null) 0 else 1) + internal fun validity(): Int = (if (unitAmount.asKnown() == null) 0 else 1) override fun equals(other: Any?): Boolean { if (this === other) { @@ -213,16 +161,13 @@ private constructor( return other is UnitConfig && unitAmount == other.unitAmount && - scalingFactor == other.scalingFactor && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { - Objects.hash(unitAmount, scalingFactor, additionalProperties) - } + private val hashCode: Int by lazy { Objects.hash(unitAmount, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "UnitConfig{unitAmount=$unitAmount, scalingFactor=$scalingFactor, additionalProperties=$additionalProperties}" + "UnitConfig{unitAmount=$unitAmount, additionalProperties=$additionalProperties}" } diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/AggregatedCostTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/AggregatedCostTest.kt index b980ffa1a..d6819e955 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/AggregatedCostTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/AggregatedCostTest.kt @@ -118,12 +118,7 @@ internal class AggregatedCostTest { .planPhaseOrder(0L) .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .scalingFactor(0.0) - .build() - ) + .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") @@ -246,12 +241,7 @@ internal class AggregatedCostTest { .planPhaseOrder(0L) .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .scalingFactor(0.0) - .build() - ) + .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") @@ -382,12 +372,7 @@ internal class AggregatedCostTest { .planPhaseOrder(0L) .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .scalingFactor(0.0) - .build() - ) + .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/BetaCreatePlanVersionParamsTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/BetaCreatePlanVersionParamsTest.kt index c2d6921a7..641af6239 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/BetaCreatePlanVersionParamsTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/BetaCreatePlanVersionParamsTest.kt @@ -64,12 +64,7 @@ internal class BetaCreatePlanVersionParamsTest { .itemId("item_id") .modelType(NewPlanUnitPrice.ModelType.UNIT) .name("Annual fee") - .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .scalingFactor(0.0) - .build() - ) + .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( @@ -176,12 +171,7 @@ internal class BetaCreatePlanVersionParamsTest { .itemId("item_id") .modelType(NewPlanUnitPrice.ModelType.UNIT) .name("Annual fee") - .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .scalingFactor(0.0) - .build() - ) + .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( @@ -293,12 +283,7 @@ internal class BetaCreatePlanVersionParamsTest { .itemId("item_id") .modelType(NewPlanUnitPrice.ModelType.UNIT) .name("Annual fee") - .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .scalingFactor(0.0) - .build() - ) + .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( @@ -407,12 +392,7 @@ internal class BetaCreatePlanVersionParamsTest { .itemId("item_id") .modelType(NewPlanUnitPrice.ModelType.UNIT) .name("Annual fee") - .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .scalingFactor(0.0) - .build() - ) + .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( @@ -515,12 +495,7 @@ internal class BetaCreatePlanVersionParamsTest { .itemId("item_id") .modelType(NewPlanUnitPrice.ModelType.UNIT) .name("Annual fee") - .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .scalingFactor(0.0) - .build() - ) + .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( @@ -631,12 +606,7 @@ internal class BetaCreatePlanVersionParamsTest { .itemId("item_id") .modelType(NewPlanUnitPrice.ModelType.UNIT) .name("Annual fee") - .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .scalingFactor(0.0) - .build() - ) + .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/BetaExternalPlanIdCreatePlanVersionParamsTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/BetaExternalPlanIdCreatePlanVersionParamsTest.kt index 6576c7b0c..c05f7acc8 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/BetaExternalPlanIdCreatePlanVersionParamsTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/BetaExternalPlanIdCreatePlanVersionParamsTest.kt @@ -64,12 +64,7 @@ internal class BetaExternalPlanIdCreatePlanVersionParamsTest { .itemId("item_id") .modelType(NewPlanUnitPrice.ModelType.UNIT) .name("Annual fee") - .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .scalingFactor(0.0) - .build() - ) + .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( @@ -176,12 +171,7 @@ internal class BetaExternalPlanIdCreatePlanVersionParamsTest { .itemId("item_id") .modelType(NewPlanUnitPrice.ModelType.UNIT) .name("Annual fee") - .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .scalingFactor(0.0) - .build() - ) + .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( @@ -297,12 +287,7 @@ internal class BetaExternalPlanIdCreatePlanVersionParamsTest { .itemId("item_id") .modelType(NewPlanUnitPrice.ModelType.UNIT) .name("Annual fee") - .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .scalingFactor(0.0) - .build() - ) + .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( @@ -411,12 +396,7 @@ internal class BetaExternalPlanIdCreatePlanVersionParamsTest { .itemId("item_id") .modelType(NewPlanUnitPrice.ModelType.UNIT) .name("Annual fee") - .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .scalingFactor(0.0) - .build() - ) + .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( @@ -519,12 +499,7 @@ internal class BetaExternalPlanIdCreatePlanVersionParamsTest { .itemId("item_id") .modelType(NewPlanUnitPrice.ModelType.UNIT) .name("Annual fee") - .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .scalingFactor(0.0) - .build() - ) + .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( @@ -635,12 +610,7 @@ internal class BetaExternalPlanIdCreatePlanVersionParamsTest { .itemId("item_id") .modelType(NewPlanUnitPrice.ModelType.UNIT) .name("Annual fee") - .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .scalingFactor(0.0) - .build() - ) + .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/ChangedSubscriptionResourcesTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/ChangedSubscriptionResourcesTest.kt index a8b44a3d6..fefd02ee2 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/ChangedSubscriptionResourcesTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/ChangedSubscriptionResourcesTest.kt @@ -405,10 +405,7 @@ internal class ChangedSubscriptionResourcesTest { .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .scalingFactor(0.0) - .build() + UnitConfig.builder().unitAmount("unit_amount").build() ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -904,10 +901,7 @@ internal class ChangedSubscriptionResourcesTest { .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .scalingFactor(0.0) - .build() + UnitConfig.builder().unitAmount("unit_amount").build() ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -1404,10 +1398,7 @@ internal class ChangedSubscriptionResourcesTest { .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .scalingFactor(0.0) - .build() + UnitConfig.builder().unitAmount("unit_amount").build() ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -1890,10 +1881,7 @@ internal class ChangedSubscriptionResourcesTest { .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .scalingFactor(0.0) - .build() + UnitConfig.builder().unitAmount("unit_amount").build() ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -2402,10 +2390,7 @@ internal class ChangedSubscriptionResourcesTest { .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .scalingFactor(0.0) - .build() + UnitConfig.builder().unitAmount("unit_amount").build() ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -2901,10 +2886,7 @@ internal class ChangedSubscriptionResourcesTest { .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .scalingFactor(0.0) - .build() + UnitConfig.builder().unitAmount("unit_amount").build() ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCostListByExternalIdResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCostListByExternalIdResponseTest.kt index 9d4b5d941..fcf910455 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCostListByExternalIdResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCostListByExternalIdResponseTest.kt @@ -140,10 +140,7 @@ internal class CustomerCostListByExternalIdResponseTest { .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .scalingFactor(0.0) - .build() + UnitConfig.builder().unitAmount("unit_amount").build() ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -288,10 +285,7 @@ internal class CustomerCostListByExternalIdResponseTest { .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .scalingFactor(0.0) - .build() + UnitConfig.builder().unitAmount("unit_amount").build() ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -445,10 +439,7 @@ internal class CustomerCostListByExternalIdResponseTest { .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .scalingFactor(0.0) - .build() + UnitConfig.builder().unitAmount("unit_amount").build() ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCostListResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCostListResponseTest.kt index 47de57efe..8dd14fcdc 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCostListResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCostListResponseTest.kt @@ -140,10 +140,7 @@ internal class CustomerCostListResponseTest { .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .scalingFactor(0.0) - .build() + UnitConfig.builder().unitAmount("unit_amount").build() ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -288,10 +285,7 @@ internal class CustomerCostListResponseTest { .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .scalingFactor(0.0) - .build() + UnitConfig.builder().unitAmount("unit_amount").build() ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -445,10 +439,7 @@ internal class CustomerCostListResponseTest { .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .scalingFactor(0.0) - .build() + UnitConfig.builder().unitAmount("unit_amount").build() ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdResponseTest.kt index 5342d2f00..b72688f60 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdResponseTest.kt @@ -339,10 +339,7 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdResponseTest { .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .scalingFactor(0.0) - .build() + UnitConfig.builder().unitAmount("unit_amount").build() ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -822,7 +819,6 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdResponseTest { .unitConfig( UnitConfig.builder() .unitAmount("unit_amount") - .scalingFactor(0.0) .build() ) .dimensionalPriceConfiguration( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryResponseTest.kt index c498bcc45..af34816ba 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryResponseTest.kt @@ -339,10 +339,7 @@ internal class CustomerCreditLedgerCreateEntryResponseTest { .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .scalingFactor(0.0) - .build() + UnitConfig.builder().unitAmount("unit_amount").build() ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -821,7 +818,6 @@ internal class CustomerCreditLedgerCreateEntryResponseTest { .unitConfig( UnitConfig.builder() .unitAmount("unit_amount") - .scalingFactor(0.0) .build() ) .dimensionalPriceConfiguration( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdPageResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdPageResponseTest.kt index e8ae023f9..3384e8e2a 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdPageResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdPageResponseTest.kt @@ -378,7 +378,6 @@ internal class CustomerCreditLedgerListByExternalIdPageResponseTest { .unitConfig( UnitConfig.builder() .unitAmount("unit_amount") - .scalingFactor(0.0) .build() ) .dimensionalPriceConfiguration( @@ -871,7 +870,6 @@ internal class CustomerCreditLedgerListByExternalIdPageResponseTest { .unitConfig( UnitConfig.builder() .unitAmount("unit_amount") - .scalingFactor(0.0) .build() ) .dimensionalPriceConfiguration( @@ -1367,7 +1365,6 @@ internal class CustomerCreditLedgerListByExternalIdPageResponseTest { .unitConfig( UnitConfig.builder() .unitAmount("unit_amount") - .scalingFactor(0.0) .build() ) .dimensionalPriceConfiguration( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdResponseTest.kt index c7f92d2a0..9c087823a 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdResponseTest.kt @@ -339,10 +339,7 @@ internal class CustomerCreditLedgerListByExternalIdResponseTest { .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .scalingFactor(0.0) - .build() + UnitConfig.builder().unitAmount("unit_amount").build() ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -821,7 +818,6 @@ internal class CustomerCreditLedgerListByExternalIdResponseTest { .unitConfig( UnitConfig.builder() .unitAmount("unit_amount") - .scalingFactor(0.0) .build() ) .dimensionalPriceConfiguration( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListPageResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListPageResponseTest.kt index 3b4ff8ad5..9d4802ae4 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListPageResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListPageResponseTest.kt @@ -378,7 +378,6 @@ internal class CustomerCreditLedgerListPageResponseTest { .unitConfig( UnitConfig.builder() .unitAmount("unit_amount") - .scalingFactor(0.0) .build() ) .dimensionalPriceConfiguration( @@ -871,7 +870,6 @@ internal class CustomerCreditLedgerListPageResponseTest { .unitConfig( UnitConfig.builder() .unitAmount("unit_amount") - .scalingFactor(0.0) .build() ) .dimensionalPriceConfiguration( @@ -1367,7 +1365,6 @@ internal class CustomerCreditLedgerListPageResponseTest { .unitConfig( UnitConfig.builder() .unitAmount("unit_amount") - .scalingFactor(0.0) .build() ) .dimensionalPriceConfiguration( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListResponseTest.kt index 00f597ee3..eb8236292 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListResponseTest.kt @@ -339,10 +339,7 @@ internal class CustomerCreditLedgerListResponseTest { .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .scalingFactor(0.0) - .build() + UnitConfig.builder().unitAmount("unit_amount").build() ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -821,7 +818,6 @@ internal class CustomerCreditLedgerListResponseTest { .unitConfig( UnitConfig.builder() .unitAmount("unit_amount") - .scalingFactor(0.0) .build() ) .dimensionalPriceConfiguration( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/IncrementLedgerEntryTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/IncrementLedgerEntryTest.kt index f90d87221..7e756911f 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/IncrementLedgerEntryTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/IncrementLedgerEntryTest.kt @@ -335,10 +335,7 @@ internal class IncrementLedgerEntryTest { .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .scalingFactor(0.0) - .build() + UnitConfig.builder().unitAmount("unit_amount").build() ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -770,10 +767,7 @@ internal class IncrementLedgerEntryTest { .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .scalingFactor(0.0) - .build() + UnitConfig.builder().unitAmount("unit_amount").build() ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -1212,10 +1206,7 @@ internal class IncrementLedgerEntryTest { .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .scalingFactor(0.0) - .build() + UnitConfig.builder().unitAmount("unit_amount").build() ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceCreateParamsTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceCreateParamsTest.kt index 8ed08a6c7..62bd0eca3 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceCreateParamsTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceCreateParamsTest.kt @@ -23,9 +23,7 @@ internal class InvoiceCreateParamsTest { .name("Line Item Name") .quantity(1.0) .startDate(LocalDate.parse("2023-09-22")) - .unitConfig( - UnitConfig.builder().unitAmount("unit_amount").scalingFactor(0.0).build() - ) + .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) .build() ) .customerId("4khy3nwzktxv7") @@ -72,12 +70,7 @@ internal class InvoiceCreateParamsTest { .name("Line Item Name") .quantity(1.0) .startDate(LocalDate.parse("2023-09-22")) - .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .scalingFactor(0.0) - .build() - ) + .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) .build() ) .customerId("4khy3nwzktxv7") @@ -122,9 +115,7 @@ internal class InvoiceCreateParamsTest { .name("Line Item Name") .quantity(1.0) .startDate(LocalDate.parse("2023-09-22")) - .unitConfig( - UnitConfig.builder().unitAmount("unit_amount").scalingFactor(0.0).build() - ) + .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) .build() ) assertThat(body.customerId()).isEqualTo("4khy3nwzktxv7") diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceFetchUpcomingResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceFetchUpcomingResponseTest.kt index cc409dc93..b1b3f3234 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceFetchUpcomingResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceFetchUpcomingResponseTest.kt @@ -282,12 +282,7 @@ internal class InvoiceFetchUpcomingResponseTest { .planPhaseOrder(0L) .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .scalingFactor(0.0) - .build() - ) + .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") @@ -682,12 +677,7 @@ internal class InvoiceFetchUpcomingResponseTest { .planPhaseOrder(0L) .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .scalingFactor(0.0) - .build() - ) + .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") @@ -1084,12 +1074,7 @@ internal class InvoiceFetchUpcomingResponseTest { .planPhaseOrder(0L) .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .scalingFactor(0.0) - .build() - ) + .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceLineItemCreateResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceLineItemCreateResponseTest.kt index a68417130..b576c8676 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceLineItemCreateResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceLineItemCreateResponseTest.kt @@ -188,12 +188,7 @@ internal class InvoiceLineItemCreateResponseTest { .planPhaseOrder(0L) .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .scalingFactor(0.0) - .build() - ) + .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") @@ -411,12 +406,7 @@ internal class InvoiceLineItemCreateResponseTest { .planPhaseOrder(0L) .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .scalingFactor(0.0) - .build() - ) + .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") @@ -634,12 +624,7 @@ internal class InvoiceLineItemCreateResponseTest { .planPhaseOrder(0L) .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .scalingFactor(0.0) - .build() - ) + .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceListPageResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceListPageResponseTest.kt index ab9c81358..94f9ec183 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceListPageResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceListPageResponseTest.kt @@ -307,10 +307,7 @@ internal class InvoiceListPageResponseTest { .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .scalingFactor(0.0) - .build() + UnitConfig.builder().unitAmount("unit_amount").build() ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -711,10 +708,7 @@ internal class InvoiceListPageResponseTest { .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .scalingFactor(0.0) - .build() + UnitConfig.builder().unitAmount("unit_amount").build() ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -1127,10 +1121,7 @@ internal class InvoiceListPageResponseTest { .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .scalingFactor(0.0) - .build() + UnitConfig.builder().unitAmount("unit_amount").build() ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceTest.kt index e02163864..e67672e2f 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceTest.kt @@ -278,12 +278,7 @@ internal class InvoiceTest { .planPhaseOrder(0L) .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .scalingFactor(0.0) - .build() - ) + .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") @@ -669,12 +664,7 @@ internal class InvoiceTest { .planPhaseOrder(0L) .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .scalingFactor(0.0) - .build() - ) + .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") @@ -1060,12 +1050,7 @@ internal class InvoiceTest { .planPhaseOrder(0L) .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .scalingFactor(0.0) - .build() - ) + .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/MutatedSubscriptionTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/MutatedSubscriptionTest.kt index 4a79dd989..20b7cdc72 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/MutatedSubscriptionTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/MutatedSubscriptionTest.kt @@ -450,12 +450,7 @@ internal class MutatedSubscriptionTest { .planPhaseOrder(0L) .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .scalingFactor(0.0) - .build() - ) + .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") @@ -601,12 +596,7 @@ internal class MutatedSubscriptionTest { .planPhaseOrder(0L) .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .scalingFactor(0.0) - .build() - ) + .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") @@ -1073,7 +1063,6 @@ internal class MutatedSubscriptionTest { .unitConfig( UnitConfig.builder() .unitAmount("unit_amount") - .scalingFactor(0.0) .build() ) .dimensionalPriceConfiguration( @@ -1622,7 +1611,6 @@ internal class MutatedSubscriptionTest { .unitConfig( UnitConfig.builder() .unitAmount("unit_amount") - .scalingFactor(0.0) .build() ) .dimensionalPriceConfiguration( @@ -2193,12 +2181,7 @@ internal class MutatedSubscriptionTest { .planPhaseOrder(0L) .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .scalingFactor(0.0) - .build() - ) + .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") @@ -2339,12 +2322,7 @@ internal class MutatedSubscriptionTest { .planPhaseOrder(0L) .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .scalingFactor(0.0) - .build() - ) + .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") @@ -2796,7 +2774,6 @@ internal class MutatedSubscriptionTest { .unitConfig( UnitConfig.builder() .unitAmount("unit_amount") - .scalingFactor(0.0) .build() ) .dimensionalPriceConfiguration( @@ -3322,7 +3299,6 @@ internal class MutatedSubscriptionTest { .unitConfig( UnitConfig.builder() .unitAmount("unit_amount") - .scalingFactor(0.0) .build() ) .dimensionalPriceConfiguration( @@ -3883,12 +3859,7 @@ internal class MutatedSubscriptionTest { .planPhaseOrder(0L) .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .scalingFactor(0.0) - .build() - ) + .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") @@ -4034,12 +4005,7 @@ internal class MutatedSubscriptionTest { .planPhaseOrder(0L) .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .scalingFactor(0.0) - .build() - ) + .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") @@ -4506,7 +4472,6 @@ internal class MutatedSubscriptionTest { .unitConfig( UnitConfig.builder() .unitAmount("unit_amount") - .scalingFactor(0.0) .build() ) .dimensionalPriceConfiguration( @@ -5055,7 +5020,6 @@ internal class MutatedSubscriptionTest { .unitConfig( UnitConfig.builder() .unitAmount("unit_amount") - .scalingFactor(0.0) .build() ) .dimensionalPriceConfiguration( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingUnitPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingUnitPriceTest.kt index b83e5452f..e5ecea168 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingUnitPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingUnitPriceTest.kt @@ -19,9 +19,7 @@ internal class NewFloatingUnitPriceTest { .itemId("item_id") .modelType(NewFloatingUnitPrice.ModelType.UNIT) .name("Annual fee") - .unitConfig( - UnitConfig.builder().unitAmount("unit_amount").scalingFactor(0.0).build() - ) + .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( @@ -63,7 +61,7 @@ internal class NewFloatingUnitPriceTest { assertThat(newFloatingUnitPrice.modelType()).isEqualTo(NewFloatingUnitPrice.ModelType.UNIT) assertThat(newFloatingUnitPrice.name()).isEqualTo("Annual fee") assertThat(newFloatingUnitPrice.unitConfig()) - .isEqualTo(UnitConfig.builder().unitAmount("unit_amount").scalingFactor(0.0).build()) + .isEqualTo(UnitConfig.builder().unitAmount("unit_amount").build()) assertThat(newFloatingUnitPrice.billableMetricId()).isEqualTo("billable_metric_id") assertThat(newFloatingUnitPrice.billedInAdvance()).isEqualTo(true) assertThat(newFloatingUnitPrice.billingCycleConfiguration()) @@ -121,9 +119,7 @@ internal class NewFloatingUnitPriceTest { .itemId("item_id") .modelType(NewFloatingUnitPrice.ModelType.UNIT) .name("Annual fee") - .unitConfig( - UnitConfig.builder().unitAmount("unit_amount").scalingFactor(0.0).build() - ) + .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanUnitPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanUnitPriceTest.kt index 5ffce4a5b..ba6443d6a 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanUnitPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanUnitPriceTest.kt @@ -18,9 +18,7 @@ internal class NewPlanUnitPriceTest { .itemId("item_id") .modelType(NewPlanUnitPrice.ModelType.UNIT) .name("Annual fee") - .unitConfig( - UnitConfig.builder().unitAmount("unit_amount").scalingFactor(0.0).build() - ) + .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( @@ -63,7 +61,7 @@ internal class NewPlanUnitPriceTest { assertThat(newPlanUnitPrice.modelType()).isEqualTo(NewPlanUnitPrice.ModelType.UNIT) assertThat(newPlanUnitPrice.name()).isEqualTo("Annual fee") assertThat(newPlanUnitPrice.unitConfig()) - .isEqualTo(UnitConfig.builder().unitAmount("unit_amount").scalingFactor(0.0).build()) + .isEqualTo(UnitConfig.builder().unitAmount("unit_amount").build()) assertThat(newPlanUnitPrice.billableMetricId()).isEqualTo("billable_metric_id") assertThat(newPlanUnitPrice.billedInAdvance()).isEqualTo(true) assertThat(newPlanUnitPrice.billingCycleConfiguration()) @@ -122,9 +120,7 @@ internal class NewPlanUnitPriceTest { .itemId("item_id") .modelType(NewPlanUnitPrice.ModelType.UNIT) .name("Annual fee") - .unitConfig( - UnitConfig.builder().unitAmount("unit_amount").scalingFactor(0.0).build() - ) + .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionUnitPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionUnitPriceTest.kt index d6af88ef3..8d1121afc 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionUnitPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionUnitPriceTest.kt @@ -18,9 +18,7 @@ internal class NewSubscriptionUnitPriceTest { .itemId("item_id") .modelType(NewSubscriptionUnitPrice.ModelType.UNIT) .name("Annual fee") - .unitConfig( - UnitConfig.builder().unitAmount("unit_amount").scalingFactor(0.0).build() - ) + .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( @@ -65,7 +63,7 @@ internal class NewSubscriptionUnitPriceTest { .isEqualTo(NewSubscriptionUnitPrice.ModelType.UNIT) assertThat(newSubscriptionUnitPrice.name()).isEqualTo("Annual fee") assertThat(newSubscriptionUnitPrice.unitConfig()) - .isEqualTo(UnitConfig.builder().unitAmount("unit_amount").scalingFactor(0.0).build()) + .isEqualTo(UnitConfig.builder().unitAmount("unit_amount").build()) assertThat(newSubscriptionUnitPrice.billableMetricId()).isEqualTo("billable_metric_id") assertThat(newSubscriptionUnitPrice.billedInAdvance()).isEqualTo(true) assertThat(newSubscriptionUnitPrice.billingCycleConfiguration()) @@ -124,9 +122,7 @@ internal class NewSubscriptionUnitPriceTest { .itemId("item_id") .modelType(NewSubscriptionUnitPrice.ModelType.UNIT) .name("Annual fee") - .unitConfig( - UnitConfig.builder().unitAmount("unit_amount").scalingFactor(0.0).build() - ) + .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PerPriceCostTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PerPriceCostTest.kt index 9dd016b7e..b1d2cd01c 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PerPriceCostTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PerPriceCostTest.kt @@ -114,12 +114,7 @@ internal class PerPriceCostTest { .planPhaseOrder(0L) .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .scalingFactor(0.0) - .build() - ) + .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") @@ -235,12 +230,7 @@ internal class PerPriceCostTest { .planPhaseOrder(0L) .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .scalingFactor(0.0) - .build() - ) + .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") @@ -360,12 +350,7 @@ internal class PerPriceCostTest { .planPhaseOrder(0L) .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .scalingFactor(0.0) - .build() - ) + .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanCreateParamsTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanCreateParamsTest.kt index d9434d3e0..a10615880 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanCreateParamsTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanCreateParamsTest.kt @@ -36,12 +36,7 @@ internal class PlanCreateParamsTest { .itemId("item_id") .modelType(NewPlanUnitPrice.ModelType.UNIT) .name("Annual fee") - .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .scalingFactor(0.0) - .build() - ) + .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( @@ -160,12 +155,7 @@ internal class PlanCreateParamsTest { .itemId("item_id") .modelType(NewPlanUnitPrice.ModelType.UNIT) .name("Annual fee") - .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .scalingFactor(0.0) - .build() - ) + .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( @@ -284,12 +274,7 @@ internal class PlanCreateParamsTest { .itemId("item_id") .modelType(NewPlanUnitPrice.ModelType.UNIT) .name("Annual fee") - .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .scalingFactor(0.0) - .build() - ) + .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanListPageResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanListPageResponseTest.kt index ffcba9f19..7e8669f24 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanListPageResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanListPageResponseTest.kt @@ -259,12 +259,7 @@ internal class PlanListPageResponseTest { .planPhaseOrder(0L) .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .scalingFactor(0.0) - .build() - ) + .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") @@ -538,12 +533,7 @@ internal class PlanListPageResponseTest { .planPhaseOrder(0L) .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .scalingFactor(0.0) - .build() - ) + .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") @@ -822,12 +812,7 @@ internal class PlanListPageResponseTest { .planPhaseOrder(0L) .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .scalingFactor(0.0) - .build() - ) + .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanTest.kt index 39a0bb191..06c2a540e 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanTest.kt @@ -255,12 +255,7 @@ internal class PlanTest { .planPhaseOrder(0L) .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .scalingFactor(0.0) - .build() - ) + .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") @@ -539,12 +534,7 @@ internal class PlanTest { .planPhaseOrder(0L) .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .scalingFactor(0.0) - .build() - ) + .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") @@ -818,12 +808,7 @@ internal class PlanTest { .planPhaseOrder(0L) .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .scalingFactor(0.0) - .build() - ) + .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanVersionTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanVersionTest.kt index f1d70364e..8ec46f075 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanVersionTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanVersionTest.kt @@ -146,12 +146,7 @@ internal class PlanVersionTest { .planPhaseOrder(0L) .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .scalingFactor(0.0) - .build() - ) + .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") @@ -301,12 +296,7 @@ internal class PlanVersionTest { .planPhaseOrder(0L) .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .scalingFactor(0.0) - .build() - ) + .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") @@ -455,12 +445,7 @@ internal class PlanVersionTest { .planPhaseOrder(0L) .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .scalingFactor(0.0) - .build() - ) + .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceCreateParamsTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceCreateParamsTest.kt index cc0038547..8b457c08d 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceCreateParamsTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceCreateParamsTest.kt @@ -18,9 +18,7 @@ internal class PriceCreateParamsTest { .itemId("item_id") .modelType(NewFloatingUnitPrice.ModelType.UNIT) .name("Annual fee") - .unitConfig( - UnitConfig.builder().unitAmount("unit_amount").scalingFactor(0.0).build() - ) + .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( @@ -70,12 +68,7 @@ internal class PriceCreateParamsTest { .itemId("item_id") .modelType(NewFloatingUnitPrice.ModelType.UNIT) .name("Annual fee") - .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .scalingFactor(0.0) - .build() - ) + .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( @@ -126,12 +119,7 @@ internal class PriceCreateParamsTest { .itemId("item_id") .modelType(NewFloatingUnitPrice.ModelType.UNIT) .name("Annual fee") - .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .scalingFactor(0.0) - .build() - ) + .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceEvaluateMultipleParamsTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceEvaluateMultipleParamsTest.kt index 52abfbd7b..0b559e17e 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceEvaluateMultipleParamsTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceEvaluateMultipleParamsTest.kt @@ -28,12 +28,7 @@ internal class PriceEvaluateMultipleParamsTest { .itemId("item_id") .modelType(NewFloatingUnitPrice.ModelType.UNIT) .name("Annual fee") - .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .scalingFactor(0.0) - .build() - ) + .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( @@ -97,12 +92,7 @@ internal class PriceEvaluateMultipleParamsTest { .itemId("item_id") .modelType(NewFloatingUnitPrice.ModelType.UNIT) .name("Annual fee") - .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .scalingFactor(0.0) - .build() - ) + .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( @@ -167,12 +157,7 @@ internal class PriceEvaluateMultipleParamsTest { .itemId("item_id") .modelType(NewFloatingUnitPrice.ModelType.UNIT) .name("Annual fee") - .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .scalingFactor(0.0) - .build() - ) + .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceEvaluatePreviewEventsParamsTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceEvaluatePreviewEventsParamsTest.kt index 64b03261b..0dff1be2a 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceEvaluatePreviewEventsParamsTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceEvaluatePreviewEventsParamsTest.kt @@ -41,12 +41,7 @@ internal class PriceEvaluatePreviewEventsParamsTest { .itemId("item_id") .modelType(NewFloatingUnitPrice.ModelType.UNIT) .name("Annual fee") - .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .scalingFactor(0.0) - .build() - ) + .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( @@ -123,12 +118,7 @@ internal class PriceEvaluatePreviewEventsParamsTest { .itemId("item_id") .modelType(NewFloatingUnitPrice.ModelType.UNIT) .name("Annual fee") - .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .scalingFactor(0.0) - .build() - ) + .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( @@ -207,12 +197,7 @@ internal class PriceEvaluatePreviewEventsParamsTest { .itemId("item_id") .modelType(NewFloatingUnitPrice.ModelType.UNIT) .name("Annual fee") - .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .scalingFactor(0.0) - .build() - ) + .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceIntervalTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceIntervalTest.kt index 0e0e0223a..cbb5d6234 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceIntervalTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceIntervalTest.kt @@ -127,12 +127,7 @@ internal class PriceIntervalTest { .planPhaseOrder(0L) .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .scalingFactor(0.0) - .build() - ) + .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") @@ -263,12 +258,7 @@ internal class PriceIntervalTest { .planPhaseOrder(0L) .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .scalingFactor(0.0) - .build() - ) + .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") @@ -400,12 +390,7 @@ internal class PriceIntervalTest { .planPhaseOrder(0L) .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .scalingFactor(0.0) - .build() - ) + .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceListPageResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceListPageResponseTest.kt index 267cea090..70fec704d 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceListPageResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceListPageResponseTest.kt @@ -114,12 +114,7 @@ internal class PriceListPageResponseTest { .planPhaseOrder(0L) .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .scalingFactor(0.0) - .build() - ) + .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") @@ -234,12 +229,7 @@ internal class PriceListPageResponseTest { .planPhaseOrder(0L) .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .scalingFactor(0.0) - .build() - ) + .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") @@ -357,12 +347,7 @@ internal class PriceListPageResponseTest { .planPhaseOrder(0L) .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .scalingFactor(0.0) - .build() - ) + .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceTest.kt index 2c4c8e3f4..078dec1f3 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceTest.kt @@ -116,9 +116,7 @@ internal class PriceTest { .planPhaseOrder(0L) .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .unitConfig( - UnitConfig.builder().unitAmount("unit_amount").scalingFactor(0.0).build() - ) + .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") @@ -261,9 +259,7 @@ internal class PriceTest { .planPhaseOrder(0L) .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .unitConfig( - UnitConfig.builder().unitAmount("unit_amount").scalingFactor(0.0).build() - ) + .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeApplyResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeApplyResponseTest.kt index 84c5eb627..d518cf627 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeApplyResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeApplyResponseTest.kt @@ -496,10 +496,7 @@ internal class SubscriptionChangeApplyResponseTest { .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .scalingFactor(0.0) - .build() + UnitConfig.builder().unitAmount("unit_amount").build() ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -670,10 +667,7 @@ internal class SubscriptionChangeApplyResponseTest { .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .scalingFactor(0.0) - .build() + UnitConfig.builder().unitAmount("unit_amount").build() ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -1223,7 +1217,6 @@ internal class SubscriptionChangeApplyResponseTest { .unitConfig( UnitConfig.builder() .unitAmount("unit_amount") - .scalingFactor(0.0) .build() ) .dimensionalPriceConfiguration( @@ -1877,7 +1870,6 @@ internal class SubscriptionChangeApplyResponseTest { .unitConfig( UnitConfig.builder() .unitAmount("unit_amount") - .scalingFactor(0.0) .build() ) .dimensionalPriceConfiguration( @@ -2496,10 +2488,7 @@ internal class SubscriptionChangeApplyResponseTest { .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .scalingFactor(0.0) - .build() + UnitConfig.builder().unitAmount("unit_amount").build() ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -2659,10 +2648,7 @@ internal class SubscriptionChangeApplyResponseTest { .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .scalingFactor(0.0) - .build() + UnitConfig.builder().unitAmount("unit_amount").build() ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -3173,7 +3159,6 @@ internal class SubscriptionChangeApplyResponseTest { .unitConfig( UnitConfig.builder() .unitAmount("unit_amount") - .scalingFactor(0.0) .build() ) .dimensionalPriceConfiguration( @@ -3780,7 +3765,6 @@ internal class SubscriptionChangeApplyResponseTest { .unitConfig( UnitConfig.builder() .unitAmount("unit_amount") - .scalingFactor(0.0) .build() ) .dimensionalPriceConfiguration( @@ -4411,10 +4395,7 @@ internal class SubscriptionChangeApplyResponseTest { .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .scalingFactor(0.0) - .build() + UnitConfig.builder().unitAmount("unit_amount").build() ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -4585,10 +4566,7 @@ internal class SubscriptionChangeApplyResponseTest { .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .scalingFactor(0.0) - .build() + UnitConfig.builder().unitAmount("unit_amount").build() ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -5138,7 +5116,6 @@ internal class SubscriptionChangeApplyResponseTest { .unitConfig( UnitConfig.builder() .unitAmount("unit_amount") - .scalingFactor(0.0) .build() ) .dimensionalPriceConfiguration( @@ -5792,7 +5769,6 @@ internal class SubscriptionChangeApplyResponseTest { .unitConfig( UnitConfig.builder() .unitAmount("unit_amount") - .scalingFactor(0.0) .build() ) .dimensionalPriceConfiguration( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeCancelResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeCancelResponseTest.kt index a5aa5f98b..136f482bd 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeCancelResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeCancelResponseTest.kt @@ -496,10 +496,7 @@ internal class SubscriptionChangeCancelResponseTest { .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .scalingFactor(0.0) - .build() + UnitConfig.builder().unitAmount("unit_amount").build() ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -670,10 +667,7 @@ internal class SubscriptionChangeCancelResponseTest { .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .scalingFactor(0.0) - .build() + UnitConfig.builder().unitAmount("unit_amount").build() ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -1223,7 +1217,6 @@ internal class SubscriptionChangeCancelResponseTest { .unitConfig( UnitConfig.builder() .unitAmount("unit_amount") - .scalingFactor(0.0) .build() ) .dimensionalPriceConfiguration( @@ -1877,7 +1870,6 @@ internal class SubscriptionChangeCancelResponseTest { .unitConfig( UnitConfig.builder() .unitAmount("unit_amount") - .scalingFactor(0.0) .build() ) .dimensionalPriceConfiguration( @@ -2496,10 +2488,7 @@ internal class SubscriptionChangeCancelResponseTest { .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .scalingFactor(0.0) - .build() + UnitConfig.builder().unitAmount("unit_amount").build() ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -2659,10 +2648,7 @@ internal class SubscriptionChangeCancelResponseTest { .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .scalingFactor(0.0) - .build() + UnitConfig.builder().unitAmount("unit_amount").build() ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -3173,7 +3159,6 @@ internal class SubscriptionChangeCancelResponseTest { .unitConfig( UnitConfig.builder() .unitAmount("unit_amount") - .scalingFactor(0.0) .build() ) .dimensionalPriceConfiguration( @@ -3780,7 +3765,6 @@ internal class SubscriptionChangeCancelResponseTest { .unitConfig( UnitConfig.builder() .unitAmount("unit_amount") - .scalingFactor(0.0) .build() ) .dimensionalPriceConfiguration( @@ -4411,10 +4395,7 @@ internal class SubscriptionChangeCancelResponseTest { .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .scalingFactor(0.0) - .build() + UnitConfig.builder().unitAmount("unit_amount").build() ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -4585,10 +4566,7 @@ internal class SubscriptionChangeCancelResponseTest { .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .scalingFactor(0.0) - .build() + UnitConfig.builder().unitAmount("unit_amount").build() ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -5138,7 +5116,6 @@ internal class SubscriptionChangeCancelResponseTest { .unitConfig( UnitConfig.builder() .unitAmount("unit_amount") - .scalingFactor(0.0) .build() ) .dimensionalPriceConfiguration( @@ -5792,7 +5769,6 @@ internal class SubscriptionChangeCancelResponseTest { .unitConfig( UnitConfig.builder() .unitAmount("unit_amount") - .scalingFactor(0.0) .build() ) .dimensionalPriceConfiguration( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeRetrieveResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeRetrieveResponseTest.kt index 07d523174..3e5d022d6 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeRetrieveResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeRetrieveResponseTest.kt @@ -496,10 +496,7 @@ internal class SubscriptionChangeRetrieveResponseTest { .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .scalingFactor(0.0) - .build() + UnitConfig.builder().unitAmount("unit_amount").build() ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -670,10 +667,7 @@ internal class SubscriptionChangeRetrieveResponseTest { .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .scalingFactor(0.0) - .build() + UnitConfig.builder().unitAmount("unit_amount").build() ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -1223,7 +1217,6 @@ internal class SubscriptionChangeRetrieveResponseTest { .unitConfig( UnitConfig.builder() .unitAmount("unit_amount") - .scalingFactor(0.0) .build() ) .dimensionalPriceConfiguration( @@ -1877,7 +1870,6 @@ internal class SubscriptionChangeRetrieveResponseTest { .unitConfig( UnitConfig.builder() .unitAmount("unit_amount") - .scalingFactor(0.0) .build() ) .dimensionalPriceConfiguration( @@ -2496,10 +2488,7 @@ internal class SubscriptionChangeRetrieveResponseTest { .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .scalingFactor(0.0) - .build() + UnitConfig.builder().unitAmount("unit_amount").build() ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -2659,10 +2648,7 @@ internal class SubscriptionChangeRetrieveResponseTest { .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .scalingFactor(0.0) - .build() + UnitConfig.builder().unitAmount("unit_amount").build() ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -3173,7 +3159,6 @@ internal class SubscriptionChangeRetrieveResponseTest { .unitConfig( UnitConfig.builder() .unitAmount("unit_amount") - .scalingFactor(0.0) .build() ) .dimensionalPriceConfiguration( @@ -3780,7 +3765,6 @@ internal class SubscriptionChangeRetrieveResponseTest { .unitConfig( UnitConfig.builder() .unitAmount("unit_amount") - .scalingFactor(0.0) .build() ) .dimensionalPriceConfiguration( @@ -4411,10 +4395,7 @@ internal class SubscriptionChangeRetrieveResponseTest { .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .scalingFactor(0.0) - .build() + UnitConfig.builder().unitAmount("unit_amount").build() ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -4585,10 +4566,7 @@ internal class SubscriptionChangeRetrieveResponseTest { .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .scalingFactor(0.0) - .build() + UnitConfig.builder().unitAmount("unit_amount").build() ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -5138,7 +5116,6 @@ internal class SubscriptionChangeRetrieveResponseTest { .unitConfig( UnitConfig.builder() .unitAmount("unit_amount") - .scalingFactor(0.0) .build() ) .dimensionalPriceConfiguration( @@ -5792,7 +5769,6 @@ internal class SubscriptionChangeRetrieveResponseTest { .unitConfig( UnitConfig.builder() .unitAmount("unit_amount") - .scalingFactor(0.0) .build() ) .dimensionalPriceConfiguration( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionCreateParamsTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionCreateParamsTest.kt index 30903c852..d3bc4d6d3 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionCreateParamsTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionCreateParamsTest.kt @@ -77,12 +77,7 @@ internal class SubscriptionCreateParamsTest { .itemId("item_id") .modelType(NewSubscriptionUnitPrice.ModelType.UNIT) .name("Annual fee") - .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .scalingFactor(0.0) - .build() - ) + .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( @@ -230,12 +225,7 @@ internal class SubscriptionCreateParamsTest { .itemId("item_id") .modelType(NewSubscriptionUnitPrice.ModelType.UNIT) .name("Annual fee") - .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .scalingFactor(0.0) - .build() - ) + .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( @@ -353,12 +343,7 @@ internal class SubscriptionCreateParamsTest { .itemId("item_id") .modelType(NewSubscriptionUnitPrice.ModelType.UNIT) .name("Annual fee") - .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .scalingFactor(0.0) - .build() - ) + .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( @@ -508,12 +493,7 @@ internal class SubscriptionCreateParamsTest { .itemId("item_id") .modelType(NewSubscriptionUnitPrice.ModelType.UNIT) .name("Annual fee") - .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .scalingFactor(0.0) - .build() - ) + .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( @@ -632,12 +612,7 @@ internal class SubscriptionCreateParamsTest { .itemId("item_id") .modelType(NewSubscriptionUnitPrice.ModelType.UNIT) .name("Annual fee") - .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .scalingFactor(0.0) - .build() - ) + .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( @@ -791,12 +766,7 @@ internal class SubscriptionCreateParamsTest { .itemId("item_id") .modelType(NewSubscriptionUnitPrice.ModelType.UNIT) .name("Annual fee") - .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .scalingFactor(0.0) - .build() - ) + .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionFetchCostsResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionFetchCostsResponseTest.kt index d2d82de47..26f07d4c0 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionFetchCostsResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionFetchCostsResponseTest.kt @@ -140,10 +140,7 @@ internal class SubscriptionFetchCostsResponseTest { .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .scalingFactor(0.0) - .build() + UnitConfig.builder().unitAmount("unit_amount").build() ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -288,10 +285,7 @@ internal class SubscriptionFetchCostsResponseTest { .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .scalingFactor(0.0) - .build() + UnitConfig.builder().unitAmount("unit_amount").build() ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -445,10 +439,7 @@ internal class SubscriptionFetchCostsResponseTest { .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .scalingFactor(0.0) - .build() + UnitConfig.builder().unitAmount("unit_amount").build() ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsParamsTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsParamsTest.kt index 0452ccef8..4e49452d1 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsParamsTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsParamsTest.kt @@ -49,12 +49,7 @@ internal class SubscriptionPriceIntervalsParamsTest { .itemId("item_id") .modelType(NewFloatingUnitPrice.ModelType.UNIT) .name("Annual fee") - .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .scalingFactor(0.0) - .build() - ) + .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( @@ -205,12 +200,7 @@ internal class SubscriptionPriceIntervalsParamsTest { .itemId("item_id") .modelType(NewFloatingUnitPrice.ModelType.UNIT) .name("Annual fee") - .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .scalingFactor(0.0) - .build() - ) + .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( @@ -350,12 +340,7 @@ internal class SubscriptionPriceIntervalsParamsTest { .itemId("item_id") .modelType(NewFloatingUnitPrice.ModelType.UNIT) .name("Annual fee") - .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .scalingFactor(0.0) - .build() - ) + .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionSchedulePlanChangeParamsTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionSchedulePlanChangeParamsTest.kt index a44de48ec..31bd5b8f7 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionSchedulePlanChangeParamsTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionSchedulePlanChangeParamsTest.kt @@ -79,12 +79,7 @@ internal class SubscriptionSchedulePlanChangeParamsTest { .itemId("item_id") .modelType(NewSubscriptionUnitPrice.ModelType.UNIT) .name("Annual fee") - .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .scalingFactor(0.0) - .build() - ) + .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( @@ -223,12 +218,7 @@ internal class SubscriptionSchedulePlanChangeParamsTest { .itemId("item_id") .modelType(NewSubscriptionUnitPrice.ModelType.UNIT) .name("Annual fee") - .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .scalingFactor(0.0) - .build() - ) + .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( @@ -360,12 +350,7 @@ internal class SubscriptionSchedulePlanChangeParamsTest { .itemId("item_id") .modelType(NewSubscriptionUnitPrice.ModelType.UNIT) .name("Annual fee") - .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .scalingFactor(0.0) - .build() - ) + .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( @@ -506,12 +491,7 @@ internal class SubscriptionSchedulePlanChangeParamsTest { .itemId("item_id") .modelType(NewSubscriptionUnitPrice.ModelType.UNIT) .name("Annual fee") - .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .scalingFactor(0.0) - .build() - ) + .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( @@ -631,12 +611,7 @@ internal class SubscriptionSchedulePlanChangeParamsTest { .itemId("item_id") .modelType(NewSubscriptionUnitPrice.ModelType.UNIT) .name("Annual fee") - .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .scalingFactor(0.0) - .build() - ) + .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( @@ -777,12 +752,7 @@ internal class SubscriptionSchedulePlanChangeParamsTest { .itemId("item_id") .modelType(NewSubscriptionUnitPrice.ModelType.UNIT) .name("Annual fee") - .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .scalingFactor(0.0) - .build() - ) + .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionTest.kt index 6e994bed7..fadd92e9b 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionTest.kt @@ -450,12 +450,7 @@ internal class SubscriptionTest { .planPhaseOrder(0L) .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .scalingFactor(0.0) - .build() - ) + .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") @@ -601,12 +596,7 @@ internal class SubscriptionTest { .planPhaseOrder(0L) .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .scalingFactor(0.0) - .build() - ) + .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") @@ -1081,12 +1071,7 @@ internal class SubscriptionTest { .planPhaseOrder(0L) .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .scalingFactor(0.0) - .build() - ) + .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") @@ -1227,12 +1212,7 @@ internal class SubscriptionTest { .planPhaseOrder(0L) .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .scalingFactor(0.0) - .build() - ) + .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") @@ -1704,12 +1684,7 @@ internal class SubscriptionTest { .planPhaseOrder(0L) .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .scalingFactor(0.0) - .build() - ) + .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") @@ -1855,12 +1830,7 @@ internal class SubscriptionTest { .planPhaseOrder(0L) .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .scalingFactor(0.0) - .build() - ) + .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionsTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionsTest.kt index 7d0b0937e..5616656c5 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionsTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionsTest.kt @@ -493,10 +493,7 @@ internal class SubscriptionsTest { .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .scalingFactor(0.0) - .build() + UnitConfig.builder().unitAmount("unit_amount").build() ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -667,10 +664,7 @@ internal class SubscriptionsTest { .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .scalingFactor(0.0) - .build() + UnitConfig.builder().unitAmount("unit_amount").build() ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -1171,10 +1165,7 @@ internal class SubscriptionsTest { .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .scalingFactor(0.0) - .build() + UnitConfig.builder().unitAmount("unit_amount").build() ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -1334,10 +1325,7 @@ internal class SubscriptionsTest { .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .scalingFactor(0.0) - .build() + UnitConfig.builder().unitAmount("unit_amount").build() ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -1854,10 +1842,7 @@ internal class SubscriptionsTest { .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .scalingFactor(0.0) - .build() + UnitConfig.builder().unitAmount("unit_amount").build() ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -2028,10 +2013,7 @@ internal class SubscriptionsTest { .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .scalingFactor(0.0) - .build() + UnitConfig.builder().unitAmount("unit_amount").build() ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/UnitConfigTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/UnitConfigTest.kt index fda8c0772..98fcacade 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/UnitConfigTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/UnitConfigTest.kt @@ -11,16 +11,15 @@ internal class UnitConfigTest { @Test fun create() { - val unitConfig = UnitConfig.builder().unitAmount("unit_amount").scalingFactor(0.0).build() + val unitConfig = UnitConfig.builder().unitAmount("unit_amount").build() assertThat(unitConfig.unitAmount()).isEqualTo("unit_amount") - assertThat(unitConfig.scalingFactor()).isEqualTo(0.0) } @Test fun roundtrip() { val jsonMapper = jsonMapper() - val unitConfig = UnitConfig.builder().unitAmount("unit_amount").scalingFactor(0.0).build() + val unitConfig = UnitConfig.builder().unitAmount("unit_amount").build() val roundtrippedUnitConfig = jsonMapper.readValue( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/BetaServiceAsyncTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/BetaServiceAsyncTest.kt index 0da1859c4..d0753d065 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/BetaServiceAsyncTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/BetaServiceAsyncTest.kt @@ -89,10 +89,7 @@ internal class BetaServiceAsyncTest { .modelType(NewPlanUnitPrice.ModelType.UNIT) .name("Annual fee") .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .scalingFactor(0.0) - .build() + UnitConfig.builder().unitAmount("unit_amount").build() ) .billableMetricId("billable_metric_id") .billedInAdvance(true) @@ -207,10 +204,7 @@ internal class BetaServiceAsyncTest { .modelType(NewPlanUnitPrice.ModelType.UNIT) .name("Annual fee") .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .scalingFactor(0.0) - .build() + UnitConfig.builder().unitAmount("unit_amount").build() ) .billableMetricId("billable_metric_id") .billedInAdvance(true) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/InvoiceServiceAsyncTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/InvoiceServiceAsyncTest.kt index ea1bfda7f..6a2b53fda 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/InvoiceServiceAsyncTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/InvoiceServiceAsyncTest.kt @@ -43,12 +43,7 @@ internal class InvoiceServiceAsyncTest { .name("Line Item Name") .quantity(1.0) .startDate(LocalDate.parse("2023-09-22")) - .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .scalingFactor(0.0) - .build() - ) + .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) .build() ) .customerId("4khy3nwzktxv7") diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/PlanServiceAsyncTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/PlanServiceAsyncTest.kt index 163916ec5..f3e9737d4 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/PlanServiceAsyncTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/PlanServiceAsyncTest.kt @@ -60,10 +60,7 @@ internal class PlanServiceAsyncTest { .modelType(NewPlanUnitPrice.ModelType.UNIT) .name("Annual fee") .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .scalingFactor(0.0) - .build() + UnitConfig.builder().unitAmount("unit_amount").build() ) .billableMetricId("billable_metric_id") .billedInAdvance(true) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/PriceServiceAsyncTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/PriceServiceAsyncTest.kt index fc3d64472..5fa67c856 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/PriceServiceAsyncTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/PriceServiceAsyncTest.kt @@ -41,12 +41,7 @@ internal class PriceServiceAsyncTest { .itemId("item_id") .modelType(NewFloatingUnitPrice.ModelType.UNIT) .name("Annual fee") - .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .scalingFactor(0.0) - .build() - ) + .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( @@ -184,10 +179,7 @@ internal class PriceServiceAsyncTest { .modelType(NewFloatingUnitPrice.ModelType.UNIT) .name("Annual fee") .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .scalingFactor(0.0) - .build() + UnitConfig.builder().unitAmount("unit_amount").build() ) .billableMetricId("billable_metric_id") .billedInAdvance(true) @@ -285,10 +277,7 @@ internal class PriceServiceAsyncTest { .modelType(NewFloatingUnitPrice.ModelType.UNIT) .name("Annual fee") .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .scalingFactor(0.0) - .build() + UnitConfig.builder().unitAmount("unit_amount").build() ) .billableMetricId("billable_metric_id") .billedInAdvance(true) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/SubscriptionServiceAsyncTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/SubscriptionServiceAsyncTest.kt index f03b5c503..4c51566b2 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/SubscriptionServiceAsyncTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/SubscriptionServiceAsyncTest.kt @@ -116,10 +116,7 @@ internal class SubscriptionServiceAsyncTest { .modelType(NewSubscriptionUnitPrice.ModelType.UNIT) .name("Annual fee") .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .scalingFactor(0.0) - .build() + UnitConfig.builder().unitAmount("unit_amount").build() ) .billableMetricId("billable_metric_id") .billedInAdvance(true) @@ -275,10 +272,7 @@ internal class SubscriptionServiceAsyncTest { .modelType(NewSubscriptionUnitPrice.ModelType.UNIT) .name("Annual fee") .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .scalingFactor(0.0) - .build() + UnitConfig.builder().unitAmount("unit_amount").build() ) .billableMetricId("billable_metric_id") .billedInAdvance(true) @@ -534,10 +528,7 @@ internal class SubscriptionServiceAsyncTest { .modelType(NewFloatingUnitPrice.ModelType.UNIT) .name("Annual fee") .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .scalingFactor(0.0) - .build() + UnitConfig.builder().unitAmount("unit_amount").build() ) .billableMetricId("billable_metric_id") .billedInAdvance(true) @@ -751,10 +742,7 @@ internal class SubscriptionServiceAsyncTest { .modelType(NewSubscriptionUnitPrice.ModelType.UNIT) .name("Annual fee") .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .scalingFactor(0.0) - .build() + UnitConfig.builder().unitAmount("unit_amount").build() ) .billableMetricId("billable_metric_id") .billedInAdvance(true) @@ -901,10 +889,7 @@ internal class SubscriptionServiceAsyncTest { .modelType(NewSubscriptionUnitPrice.ModelType.UNIT) .name("Annual fee") .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .scalingFactor(0.0) - .build() + UnitConfig.builder().unitAmount("unit_amount").build() ) .billableMetricId("billable_metric_id") .billedInAdvance(true) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/beta/ExternalPlanIdServiceAsyncTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/beta/ExternalPlanIdServiceAsyncTest.kt index 12bff3091..2b99ad625 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/beta/ExternalPlanIdServiceAsyncTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/beta/ExternalPlanIdServiceAsyncTest.kt @@ -89,10 +89,7 @@ internal class ExternalPlanIdServiceAsyncTest { .modelType(NewPlanUnitPrice.ModelType.UNIT) .name("Annual fee") .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .scalingFactor(0.0) - .build() + UnitConfig.builder().unitAmount("unit_amount").build() ) .billableMetricId("billable_metric_id") .billedInAdvance(true) @@ -207,10 +204,7 @@ internal class ExternalPlanIdServiceAsyncTest { .modelType(NewPlanUnitPrice.ModelType.UNIT) .name("Annual fee") .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .scalingFactor(0.0) - .build() + UnitConfig.builder().unitAmount("unit_amount").build() ) .billableMetricId("billable_metric_id") .billedInAdvance(true) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/BetaServiceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/BetaServiceTest.kt index a868b67a2..24e977345 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/BetaServiceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/BetaServiceTest.kt @@ -89,10 +89,7 @@ internal class BetaServiceTest { .modelType(NewPlanUnitPrice.ModelType.UNIT) .name("Annual fee") .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .scalingFactor(0.0) - .build() + UnitConfig.builder().unitAmount("unit_amount").build() ) .billableMetricId("billable_metric_id") .billedInAdvance(true) @@ -207,10 +204,7 @@ internal class BetaServiceTest { .modelType(NewPlanUnitPrice.ModelType.UNIT) .name("Annual fee") .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .scalingFactor(0.0) - .build() + UnitConfig.builder().unitAmount("unit_amount").build() ) .billableMetricId("billable_metric_id") .billedInAdvance(true) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/InvoiceServiceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/InvoiceServiceTest.kt index ba4667c8e..367768764 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/InvoiceServiceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/InvoiceServiceTest.kt @@ -43,12 +43,7 @@ internal class InvoiceServiceTest { .name("Line Item Name") .quantity(1.0) .startDate(LocalDate.parse("2023-09-22")) - .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .scalingFactor(0.0) - .build() - ) + .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) .build() ) .customerId("4khy3nwzktxv7") diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/PlanServiceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/PlanServiceTest.kt index 3b962be3d..b3af60641 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/PlanServiceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/PlanServiceTest.kt @@ -60,10 +60,7 @@ internal class PlanServiceTest { .modelType(NewPlanUnitPrice.ModelType.UNIT) .name("Annual fee") .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .scalingFactor(0.0) - .build() + UnitConfig.builder().unitAmount("unit_amount").build() ) .billableMetricId("billable_metric_id") .billedInAdvance(true) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/PriceServiceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/PriceServiceTest.kt index defea2442..e11ed1229 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/PriceServiceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/PriceServiceTest.kt @@ -41,12 +41,7 @@ internal class PriceServiceTest { .itemId("item_id") .modelType(NewFloatingUnitPrice.ModelType.UNIT) .name("Annual fee") - .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .scalingFactor(0.0) - .build() - ) + .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( @@ -184,10 +179,7 @@ internal class PriceServiceTest { .modelType(NewFloatingUnitPrice.ModelType.UNIT) .name("Annual fee") .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .scalingFactor(0.0) - .build() + UnitConfig.builder().unitAmount("unit_amount").build() ) .billableMetricId("billable_metric_id") .billedInAdvance(true) @@ -285,10 +277,7 @@ internal class PriceServiceTest { .modelType(NewFloatingUnitPrice.ModelType.UNIT) .name("Annual fee") .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .scalingFactor(0.0) - .build() + UnitConfig.builder().unitAmount("unit_amount").build() ) .billableMetricId("billable_metric_id") .billedInAdvance(true) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/SubscriptionServiceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/SubscriptionServiceTest.kt index 3e86edebd..2d6d063a8 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/SubscriptionServiceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/SubscriptionServiceTest.kt @@ -116,10 +116,7 @@ internal class SubscriptionServiceTest { .modelType(NewSubscriptionUnitPrice.ModelType.UNIT) .name("Annual fee") .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .scalingFactor(0.0) - .build() + UnitConfig.builder().unitAmount("unit_amount").build() ) .billableMetricId("billable_metric_id") .billedInAdvance(true) @@ -275,10 +272,7 @@ internal class SubscriptionServiceTest { .modelType(NewSubscriptionUnitPrice.ModelType.UNIT) .name("Annual fee") .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .scalingFactor(0.0) - .build() + UnitConfig.builder().unitAmount("unit_amount").build() ) .billableMetricId("billable_metric_id") .billedInAdvance(true) @@ -534,10 +528,7 @@ internal class SubscriptionServiceTest { .modelType(NewFloatingUnitPrice.ModelType.UNIT) .name("Annual fee") .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .scalingFactor(0.0) - .build() + UnitConfig.builder().unitAmount("unit_amount").build() ) .billableMetricId("billable_metric_id") .billedInAdvance(true) @@ -751,10 +742,7 @@ internal class SubscriptionServiceTest { .modelType(NewSubscriptionUnitPrice.ModelType.UNIT) .name("Annual fee") .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .scalingFactor(0.0) - .build() + UnitConfig.builder().unitAmount("unit_amount").build() ) .billableMetricId("billable_metric_id") .billedInAdvance(true) @@ -901,10 +889,7 @@ internal class SubscriptionServiceTest { .modelType(NewSubscriptionUnitPrice.ModelType.UNIT) .name("Annual fee") .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .scalingFactor(0.0) - .build() + UnitConfig.builder().unitAmount("unit_amount").build() ) .billableMetricId("billable_metric_id") .billedInAdvance(true) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/beta/ExternalPlanIdServiceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/beta/ExternalPlanIdServiceTest.kt index c5c7b9948..f8208215c 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/beta/ExternalPlanIdServiceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/beta/ExternalPlanIdServiceTest.kt @@ -89,10 +89,7 @@ internal class ExternalPlanIdServiceTest { .modelType(NewPlanUnitPrice.ModelType.UNIT) .name("Annual fee") .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .scalingFactor(0.0) - .build() + UnitConfig.builder().unitAmount("unit_amount").build() ) .billableMetricId("billable_metric_id") .billedInAdvance(true) @@ -207,10 +204,7 @@ internal class ExternalPlanIdServiceTest { .modelType(NewPlanUnitPrice.ModelType.UNIT) .name("Annual fee") .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .scalingFactor(0.0) - .build() + UnitConfig.builder().unitAmount("unit_amount").build() ) .billableMetricId("billable_metric_id") .billedInAdvance(true) From a9326c1fc925f51377493ccb1d50cdbcd444df07 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 3 Oct 2025 22:33:08 +0000 Subject: [PATCH 26/68] feat(api): api update --- .stats.yml | 4 +- .../withorb/api/models/MatrixSubLineItem.kt | 66 +++++++++++++++++-- .../ChangedSubscriptionResourcesTest.kt | 6 ++ ...dgerCreateEntryByExternalIdResponseTest.kt | 2 + ...omerCreditLedgerCreateEntryResponseTest.kt | 2 + ...tLedgerListByExternalIdPageResponseTest.kt | 3 + ...reditLedgerListByExternalIdResponseTest.kt | 2 + ...ustomerCreditLedgerListPageResponseTest.kt | 3 + .../CustomerCreditLedgerListResponseTest.kt | 2 + .../api/models/IncrementLedgerEntryTest.kt | 3 + .../InvoiceFetchUpcomingResponseTest.kt | 3 + .../InvoiceLineItemCreateResponseTest.kt | 3 + .../api/models/InvoiceListPageResponseTest.kt | 3 + .../com/withorb/api/models/InvoiceTest.kt | 3 + .../api/models/MatrixSubLineItemTest.kt | 3 + .../api/models/MutatedSubscriptionTest.kt | 6 ++ .../SubscriptionChangeApplyResponseTest.kt | 6 ++ .../SubscriptionChangeCancelResponseTest.kt | 6 ++ .../SubscriptionChangeRetrieveResponseTest.kt | 6 ++ 19 files changed, 126 insertions(+), 6 deletions(-) diff --git a/.stats.yml b/.stats.yml index 05461dff9..fd40002fd 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 118 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-b330498c2bfb80605f4c406e8b228c0a4ece85247b21f62f93273a00abb53d35.yml -openapi_spec_hash: 16a82d0eb23b68218d584e385bee43da +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-26020bd285825dac04bf642a414ea07c786fc6e42ee6bbcf795e11f8db426519.yml +openapi_spec_hash: 897fedec83f0960539b3aa4ec0e3308d config_hash: 1f73a949b649ecfe6ec68ba1bb459dc2 diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MatrixSubLineItem.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MatrixSubLineItem.kt index e90ba657b..ad71d156d 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MatrixSubLineItem.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MatrixSubLineItem.kt @@ -25,6 +25,7 @@ private constructor( private val name: JsonField, private val quantity: JsonField, private val type: JsonField, + private val scaledQuantity: JsonField, private val additionalProperties: MutableMap, ) { @@ -40,7 +41,10 @@ private constructor( @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @JsonProperty("quantity") @ExcludeMissing quantity: JsonField = JsonMissing.of(), @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), - ) : this(amount, grouping, matrixConfig, name, quantity, type, mutableMapOf()) + @JsonProperty("scaled_quantity") + @ExcludeMissing + scaledQuantity: JsonField = JsonMissing.of(), + ) : this(amount, grouping, matrixConfig, name, quantity, type, scaledQuantity, mutableMapOf()) /** * The total amount for this sub line item. @@ -80,6 +84,14 @@ private constructor( */ fun type(): Type = type.getRequired("type") + /** + * The scaled quantity for this line item for specific pricing structures + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun scaledQuantity(): Double? = scaledQuantity.getNullable("scaled_quantity") + /** * Returns the raw JSON value of [amount]. * @@ -126,6 +138,15 @@ private constructor( */ @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + /** + * Returns the raw JSON value of [scaledQuantity]. + * + * Unlike [scaledQuantity], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("scaled_quantity") + @ExcludeMissing + fun _scaledQuantity(): JsonField = scaledQuantity + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -165,6 +186,7 @@ private constructor( private var name: JsonField? = null private var quantity: JsonField? = null private var type: JsonField? = null + private var scaledQuantity: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() internal fun from(matrixSubLineItem: MatrixSubLineItem) = apply { @@ -174,6 +196,7 @@ private constructor( name = matrixSubLineItem.name quantity = matrixSubLineItem.quantity type = matrixSubLineItem.type + scaledQuantity = matrixSubLineItem.scaledQuantity additionalProperties = matrixSubLineItem.additionalProperties.toMutableMap() } @@ -243,6 +266,28 @@ private constructor( */ fun type(type: JsonField) = apply { this.type = type } + /** The scaled quantity for this line item for specific pricing structures */ + fun scaledQuantity(scaledQuantity: Double?) = + scaledQuantity(JsonField.ofNullable(scaledQuantity)) + + /** + * Alias for [Builder.scaledQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun scaledQuantity(scaledQuantity: Double) = scaledQuantity(scaledQuantity as Double?) + + /** + * Sets [Builder.scaledQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.scaledQuantity] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun scaledQuantity(scaledQuantity: JsonField) = apply { + this.scaledQuantity = scaledQuantity + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -287,6 +332,7 @@ private constructor( checkRequired("name", name), checkRequired("quantity", quantity), checkRequired("type", type), + scaledQuantity, additionalProperties.toMutableMap(), ) } @@ -304,6 +350,7 @@ private constructor( name() quantity() type().validate() + scaledQuantity() validated = true } @@ -326,7 +373,8 @@ private constructor( (matrixConfig.asKnown()?.validity() ?: 0) + (if (name.asKnown() == null) 0 else 1) + (if (quantity.asKnown() == null) 0 else 1) + - (type.asKnown()?.validity() ?: 0) + (type.asKnown()?.validity() ?: 0) + + (if (scaledQuantity.asKnown() == null) 0 else 1) class Type @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -458,15 +506,25 @@ private constructor( name == other.name && quantity == other.quantity && type == other.type && + scaledQuantity == other.scaledQuantity && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(amount, grouping, matrixConfig, name, quantity, type, additionalProperties) + Objects.hash( + amount, + grouping, + matrixConfig, + name, + quantity, + type, + scaledQuantity, + additionalProperties, + ) } override fun hashCode(): Int = hashCode override fun toString() = - "MatrixSubLineItem{amount=$amount, grouping=$grouping, matrixConfig=$matrixConfig, name=$name, quantity=$quantity, type=$type, additionalProperties=$additionalProperties}" + "MatrixSubLineItem{amount=$amount, grouping=$grouping, matrixConfig=$matrixConfig, name=$name, quantity=$quantity, type=$type, scaledQuantity=$scaledQuantity, additionalProperties=$additionalProperties}" } diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/ChangedSubscriptionResourcesTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/ChangedSubscriptionResourcesTest.kt index fefd02ee2..a1ac50821 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/ChangedSubscriptionResourcesTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/ChangedSubscriptionResourcesTest.kt @@ -436,6 +436,7 @@ internal class ChangedSubscriptionResourcesTest { .name("Tier One") .quantity(5.0) .type(MatrixSubLineItem.Type.MATRIX) + .scaledQuantity(0.0) .build() ) .subtotal("9.00") @@ -932,6 +933,7 @@ internal class ChangedSubscriptionResourcesTest { .name("Tier One") .quantity(5.0) .type(MatrixSubLineItem.Type.MATRIX) + .scaledQuantity(0.0) .build() ) .subtotal("9.00") @@ -1427,6 +1429,7 @@ internal class ChangedSubscriptionResourcesTest { .name("Tier One") .quantity(5.0) .type(MatrixSubLineItem.Type.MATRIX) + .scaledQuantity(0.0) .build() ) .subtotal("9.00") @@ -1910,6 +1913,7 @@ internal class ChangedSubscriptionResourcesTest { .name("Tier One") .quantity(5.0) .type(MatrixSubLineItem.Type.MATRIX) + .scaledQuantity(0.0) .build() ) .subtotal("9.00") @@ -2421,6 +2425,7 @@ internal class ChangedSubscriptionResourcesTest { .name("Tier One") .quantity(5.0) .type(MatrixSubLineItem.Type.MATRIX) + .scaledQuantity(0.0) .build() ) .subtotal("9.00") @@ -2917,6 +2922,7 @@ internal class ChangedSubscriptionResourcesTest { .name("Tier One") .quantity(5.0) .type(MatrixSubLineItem.Type.MATRIX) + .scaledQuantity(0.0) .build() ) .subtotal("9.00") diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdResponseTest.kt index b72688f60..ab76f0a34 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdResponseTest.kt @@ -370,6 +370,7 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdResponseTest { .name("Tier One") .quantity(5.0) .type(MatrixSubLineItem.Type.MATRIX) + .scaledQuantity(0.0) .build() ) .subtotal("9.00") @@ -850,6 +851,7 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdResponseTest { .name("Tier One") .quantity(5.0) .type(MatrixSubLineItem.Type.MATRIX) + .scaledQuantity(0.0) .build() ) .subtotal("9.00") diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryResponseTest.kt index af34816ba..5099bf445 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryResponseTest.kt @@ -370,6 +370,7 @@ internal class CustomerCreditLedgerCreateEntryResponseTest { .name("Tier One") .quantity(5.0) .type(MatrixSubLineItem.Type.MATRIX) + .scaledQuantity(0.0) .build() ) .subtotal("9.00") @@ -849,6 +850,7 @@ internal class CustomerCreditLedgerCreateEntryResponseTest { .name("Tier One") .quantity(5.0) .type(MatrixSubLineItem.Type.MATRIX) + .scaledQuantity(0.0) .build() ) .subtotal("9.00") diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdPageResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdPageResponseTest.kt index 3384e8e2a..98d0f59b4 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdPageResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdPageResponseTest.kt @@ -411,6 +411,7 @@ internal class CustomerCreditLedgerListByExternalIdPageResponseTest { .name("Tier One") .quantity(5.0) .type(MatrixSubLineItem.Type.MATRIX) + .scaledQuantity(0.0) .build() ) .subtotal("9.00") @@ -903,6 +904,7 @@ internal class CustomerCreditLedgerListByExternalIdPageResponseTest { .name("Tier One") .quantity(5.0) .type(MatrixSubLineItem.Type.MATRIX) + .scaledQuantity(0.0) .build() ) .subtotal("9.00") @@ -1398,6 +1400,7 @@ internal class CustomerCreditLedgerListByExternalIdPageResponseTest { .name("Tier One") .quantity(5.0) .type(MatrixSubLineItem.Type.MATRIX) + .scaledQuantity(0.0) .build() ) .subtotal("9.00") diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdResponseTest.kt index 9c087823a..6c3341fdc 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdResponseTest.kt @@ -370,6 +370,7 @@ internal class CustomerCreditLedgerListByExternalIdResponseTest { .name("Tier One") .quantity(5.0) .type(MatrixSubLineItem.Type.MATRIX) + .scaledQuantity(0.0) .build() ) .subtotal("9.00") @@ -849,6 +850,7 @@ internal class CustomerCreditLedgerListByExternalIdResponseTest { .name("Tier One") .quantity(5.0) .type(MatrixSubLineItem.Type.MATRIX) + .scaledQuantity(0.0) .build() ) .subtotal("9.00") diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListPageResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListPageResponseTest.kt index 9d4802ae4..ed59e99ea 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListPageResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListPageResponseTest.kt @@ -411,6 +411,7 @@ internal class CustomerCreditLedgerListPageResponseTest { .name("Tier One") .quantity(5.0) .type(MatrixSubLineItem.Type.MATRIX) + .scaledQuantity(0.0) .build() ) .subtotal("9.00") @@ -903,6 +904,7 @@ internal class CustomerCreditLedgerListPageResponseTest { .name("Tier One") .quantity(5.0) .type(MatrixSubLineItem.Type.MATRIX) + .scaledQuantity(0.0) .build() ) .subtotal("9.00") @@ -1398,6 +1400,7 @@ internal class CustomerCreditLedgerListPageResponseTest { .name("Tier One") .quantity(5.0) .type(MatrixSubLineItem.Type.MATRIX) + .scaledQuantity(0.0) .build() ) .subtotal("9.00") diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListResponseTest.kt index eb8236292..650235b26 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListResponseTest.kt @@ -370,6 +370,7 @@ internal class CustomerCreditLedgerListResponseTest { .name("Tier One") .quantity(5.0) .type(MatrixSubLineItem.Type.MATRIX) + .scaledQuantity(0.0) .build() ) .subtotal("9.00") @@ -849,6 +850,7 @@ internal class CustomerCreditLedgerListResponseTest { .name("Tier One") .quantity(5.0) .type(MatrixSubLineItem.Type.MATRIX) + .scaledQuantity(0.0) .build() ) .subtotal("9.00") diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/IncrementLedgerEntryTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/IncrementLedgerEntryTest.kt index 7e756911f..a11f01251 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/IncrementLedgerEntryTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/IncrementLedgerEntryTest.kt @@ -366,6 +366,7 @@ internal class IncrementLedgerEntryTest { .name("Tier One") .quantity(5.0) .type(MatrixSubLineItem.Type.MATRIX) + .scaledQuantity(0.0) .build() ) .subtotal("9.00") @@ -796,6 +797,7 @@ internal class IncrementLedgerEntryTest { .name("Tier One") .quantity(5.0) .type(MatrixSubLineItem.Type.MATRIX) + .scaledQuantity(0.0) .build() ) .subtotal("9.00") @@ -1237,6 +1239,7 @@ internal class IncrementLedgerEntryTest { .name("Tier One") .quantity(5.0) .type(MatrixSubLineItem.Type.MATRIX) + .scaledQuantity(0.0) .build() ) .subtotal("9.00") diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceFetchUpcomingResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceFetchUpcomingResponseTest.kt index b1b3f3234..600ba9d0e 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceFetchUpcomingResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceFetchUpcomingResponseTest.kt @@ -310,6 +310,7 @@ internal class InvoiceFetchUpcomingResponseTest { .name("Tier One") .quantity(5.0) .type(MatrixSubLineItem.Type.MATRIX) + .scaledQuantity(0.0) .build() ) .subtotal("9.00") @@ -702,6 +703,7 @@ internal class InvoiceFetchUpcomingResponseTest { .name("Tier One") .quantity(5.0) .type(MatrixSubLineItem.Type.MATRIX) + .scaledQuantity(0.0) .build() ) .subtotal("9.00") @@ -1102,6 +1104,7 @@ internal class InvoiceFetchUpcomingResponseTest { .name("Tier One") .quantity(5.0) .type(MatrixSubLineItem.Type.MATRIX) + .scaledQuantity(0.0) .build() ) .subtotal("9.00") diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceLineItemCreateResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceLineItemCreateResponseTest.kt index b576c8676..ad1f6a593 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceLineItemCreateResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceLineItemCreateResponseTest.kt @@ -209,6 +209,7 @@ internal class InvoiceLineItemCreateResponseTest { .name("Tier One") .quantity(5.0) .type(MatrixSubLineItem.Type.MATRIX) + .scaledQuantity(0.0) .build() ) .subtotal("9.00") @@ -431,6 +432,7 @@ internal class InvoiceLineItemCreateResponseTest { .name("Tier One") .quantity(5.0) .type(MatrixSubLineItem.Type.MATRIX) + .scaledQuantity(0.0) .build() ) ) @@ -645,6 +647,7 @@ internal class InvoiceLineItemCreateResponseTest { .name("Tier One") .quantity(5.0) .type(MatrixSubLineItem.Type.MATRIX) + .scaledQuantity(0.0) .build() ) .subtotal("9.00") diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceListPageResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceListPageResponseTest.kt index 94f9ec183..e4d0df0a4 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceListPageResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceListPageResponseTest.kt @@ -338,6 +338,7 @@ internal class InvoiceListPageResponseTest { .name("Tier One") .quantity(5.0) .type(MatrixSubLineItem.Type.MATRIX) + .scaledQuantity(0.0) .build() ) .subtotal("9.00") @@ -737,6 +738,7 @@ internal class InvoiceListPageResponseTest { .name("Tier One") .quantity(5.0) .type(MatrixSubLineItem.Type.MATRIX) + .scaledQuantity(0.0) .build() ) .subtotal("9.00") @@ -1152,6 +1154,7 @@ internal class InvoiceListPageResponseTest { .name("Tier One") .quantity(5.0) .type(MatrixSubLineItem.Type.MATRIX) + .scaledQuantity(0.0) .build() ) .subtotal("9.00") diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceTest.kt index e67672e2f..5c7177b38 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceTest.kt @@ -306,6 +306,7 @@ internal class InvoiceTest { .name("Tier One") .quantity(5.0) .type(MatrixSubLineItem.Type.MATRIX) + .scaledQuantity(0.0) .build() ) .subtotal("9.00") @@ -689,6 +690,7 @@ internal class InvoiceTest { .name("Tier One") .quantity(5.0) .type(MatrixSubLineItem.Type.MATRIX) + .scaledQuantity(0.0) .build() ) .subtotal("9.00") @@ -1078,6 +1080,7 @@ internal class InvoiceTest { .name("Tier One") .quantity(5.0) .type(MatrixSubLineItem.Type.MATRIX) + .scaledQuantity(0.0) .build() ) .subtotal("9.00") diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/MatrixSubLineItemTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/MatrixSubLineItemTest.kt index 1347f76e2..5744b22ce 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/MatrixSubLineItemTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/MatrixSubLineItemTest.kt @@ -19,6 +19,7 @@ internal class MatrixSubLineItemTest { .name("Tier One") .quantity(5.0) .type(MatrixSubLineItem.Type.MATRIX) + .scaledQuantity(0.0) .build() assertThat(matrixSubLineItem.amount()).isEqualTo("9.00") @@ -29,6 +30,7 @@ internal class MatrixSubLineItemTest { assertThat(matrixSubLineItem.name()).isEqualTo("Tier One") assertThat(matrixSubLineItem.quantity()).isEqualTo(5.0) assertThat(matrixSubLineItem.type()).isEqualTo(MatrixSubLineItem.Type.MATRIX) + assertThat(matrixSubLineItem.scaledQuantity()).isEqualTo(0.0) } @Test @@ -42,6 +44,7 @@ internal class MatrixSubLineItemTest { .name("Tier One") .quantity(5.0) .type(MatrixSubLineItem.Type.MATRIX) + .scaledQuantity(0.0) .build() val roundtrippedMatrixSubLineItem = diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/MutatedSubscriptionTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/MutatedSubscriptionTest.kt index 20b7cdc72..f95b60461 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/MutatedSubscriptionTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/MutatedSubscriptionTest.kt @@ -1096,6 +1096,7 @@ internal class MutatedSubscriptionTest { .name("Tier One") .quantity(5.0) .type(MatrixSubLineItem.Type.MATRIX) + .scaledQuantity(0.0) .build() ) .subtotal("9.00") @@ -1644,6 +1645,7 @@ internal class MutatedSubscriptionTest { .name("Tier One") .quantity(5.0) .type(MatrixSubLineItem.Type.MATRIX) + .scaledQuantity(0.0) .build() ) .subtotal("9.00") @@ -2805,6 +2807,7 @@ internal class MutatedSubscriptionTest { .name("Tier One") .quantity(5.0) .type(MatrixSubLineItem.Type.MATRIX) + .scaledQuantity(0.0) .build() ) .subtotal("9.00") @@ -3330,6 +3333,7 @@ internal class MutatedSubscriptionTest { .name("Tier One") .quantity(5.0) .type(MatrixSubLineItem.Type.MATRIX) + .scaledQuantity(0.0) .build() ) .subtotal("9.00") @@ -4505,6 +4509,7 @@ internal class MutatedSubscriptionTest { .name("Tier One") .quantity(5.0) .type(MatrixSubLineItem.Type.MATRIX) + .scaledQuantity(0.0) .build() ) .subtotal("9.00") @@ -5053,6 +5058,7 @@ internal class MutatedSubscriptionTest { .name("Tier One") .quantity(5.0) .type(MatrixSubLineItem.Type.MATRIX) + .scaledQuantity(0.0) .build() ) .subtotal("9.00") diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeApplyResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeApplyResponseTest.kt index d518cf627..dd1b414f1 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeApplyResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeApplyResponseTest.kt @@ -1252,6 +1252,7 @@ internal class SubscriptionChangeApplyResponseTest { .name("Tier One") .quantity(5.0) .type(MatrixSubLineItem.Type.MATRIX) + .scaledQuantity(0.0) .build() ) .subtotal("9.00") @@ -1905,6 +1906,7 @@ internal class SubscriptionChangeApplyResponseTest { .name("Tier One") .quantity(5.0) .type(MatrixSubLineItem.Type.MATRIX) + .scaledQuantity(0.0) .build() ) .subtotal("9.00") @@ -3192,6 +3194,7 @@ internal class SubscriptionChangeApplyResponseTest { .name("Tier One") .quantity(5.0) .type(MatrixSubLineItem.Type.MATRIX) + .scaledQuantity(0.0) .build() ) .subtotal("9.00") @@ -3798,6 +3801,7 @@ internal class SubscriptionChangeApplyResponseTest { .name("Tier One") .quantity(5.0) .type(MatrixSubLineItem.Type.MATRIX) + .scaledQuantity(0.0) .build() ) .subtotal("9.00") @@ -5151,6 +5155,7 @@ internal class SubscriptionChangeApplyResponseTest { .name("Tier One") .quantity(5.0) .type(MatrixSubLineItem.Type.MATRIX) + .scaledQuantity(0.0) .build() ) .subtotal("9.00") @@ -5804,6 +5809,7 @@ internal class SubscriptionChangeApplyResponseTest { .name("Tier One") .quantity(5.0) .type(MatrixSubLineItem.Type.MATRIX) + .scaledQuantity(0.0) .build() ) .subtotal("9.00") diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeCancelResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeCancelResponseTest.kt index 136f482bd..0870f8c8a 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeCancelResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeCancelResponseTest.kt @@ -1252,6 +1252,7 @@ internal class SubscriptionChangeCancelResponseTest { .name("Tier One") .quantity(5.0) .type(MatrixSubLineItem.Type.MATRIX) + .scaledQuantity(0.0) .build() ) .subtotal("9.00") @@ -1905,6 +1906,7 @@ internal class SubscriptionChangeCancelResponseTest { .name("Tier One") .quantity(5.0) .type(MatrixSubLineItem.Type.MATRIX) + .scaledQuantity(0.0) .build() ) .subtotal("9.00") @@ -3192,6 +3194,7 @@ internal class SubscriptionChangeCancelResponseTest { .name("Tier One") .quantity(5.0) .type(MatrixSubLineItem.Type.MATRIX) + .scaledQuantity(0.0) .build() ) .subtotal("9.00") @@ -3798,6 +3801,7 @@ internal class SubscriptionChangeCancelResponseTest { .name("Tier One") .quantity(5.0) .type(MatrixSubLineItem.Type.MATRIX) + .scaledQuantity(0.0) .build() ) .subtotal("9.00") @@ -5151,6 +5155,7 @@ internal class SubscriptionChangeCancelResponseTest { .name("Tier One") .quantity(5.0) .type(MatrixSubLineItem.Type.MATRIX) + .scaledQuantity(0.0) .build() ) .subtotal("9.00") @@ -5804,6 +5809,7 @@ internal class SubscriptionChangeCancelResponseTest { .name("Tier One") .quantity(5.0) .type(MatrixSubLineItem.Type.MATRIX) + .scaledQuantity(0.0) .build() ) .subtotal("9.00") diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeRetrieveResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeRetrieveResponseTest.kt index 3e5d022d6..b25a4a4f8 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeRetrieveResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeRetrieveResponseTest.kt @@ -1252,6 +1252,7 @@ internal class SubscriptionChangeRetrieveResponseTest { .name("Tier One") .quantity(5.0) .type(MatrixSubLineItem.Type.MATRIX) + .scaledQuantity(0.0) .build() ) .subtotal("9.00") @@ -1905,6 +1906,7 @@ internal class SubscriptionChangeRetrieveResponseTest { .name("Tier One") .quantity(5.0) .type(MatrixSubLineItem.Type.MATRIX) + .scaledQuantity(0.0) .build() ) .subtotal("9.00") @@ -3192,6 +3194,7 @@ internal class SubscriptionChangeRetrieveResponseTest { .name("Tier One") .quantity(5.0) .type(MatrixSubLineItem.Type.MATRIX) + .scaledQuantity(0.0) .build() ) .subtotal("9.00") @@ -3798,6 +3801,7 @@ internal class SubscriptionChangeRetrieveResponseTest { .name("Tier One") .quantity(5.0) .type(MatrixSubLineItem.Type.MATRIX) + .scaledQuantity(0.0) .build() ) .subtotal("9.00") @@ -5151,6 +5155,7 @@ internal class SubscriptionChangeRetrieveResponseTest { .name("Tier One") .quantity(5.0) .type(MatrixSubLineItem.Type.MATRIX) + .scaledQuantity(0.0) .build() ) .subtotal("9.00") @@ -5804,6 +5809,7 @@ internal class SubscriptionChangeRetrieveResponseTest { .name("Tier One") .quantity(5.0) .type(MatrixSubLineItem.Type.MATRIX) + .scaledQuantity(0.0) .build() ) .subtotal("9.00") From 11cfcca024a9abce1fbe8d3097c3d3aeb66eee34 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 6 Oct 2025 22:33:50 +0000 Subject: [PATCH 27/68] feat(api): api update --- .stats.yml | 4 +- .../api/models/BetaCreatePlanVersionParams.kt | 8718 ++++++++++----- ...taExternalPlanIdCreatePlanVersionParams.kt | 8718 ++++++++++----- .../models/ChangedSubscriptionResources.kt | 3 + .../kotlin/com/withorb/api/models/Invoice.kt | 3 + .../models/InvoiceFetchUpcomingResponse.kt | 3 + .../models/InvoiceLineItemCreateResponse.kt | 3 + .../kotlin/com/withorb/api/models/Item.kt | 84 +- .../kotlin/com/withorb/api/models/ItemSlim.kt | 7 + .../withorb/api/models/ItemUpdateParams.kt | 11 + .../com/withorb/api/models/PerPriceCost.kt | 3 + .../kotlin/com/withorb/api/models/Plan.kt | 3 + .../withorb/api/models/PlanCreateParams.kt | 1602 ++- .../com/withorb/api/models/PlanVersion.kt | 3 + .../kotlin/com/withorb/api/models/Price.kt | 2946 ++++- .../withorb/api/models/PriceCreateParams.kt | 1517 ++- .../api/models/PriceEvaluateMultipleParams.kt | 1551 ++- .../PriceEvaluatePreviewEventsParams.kt | 1551 ++- .../com/withorb/api/models/PriceInterval.kt | 3 + .../api/models/PriceListPageResponse.kt | 3 + .../api/models/SubscriptionCreateParams.kt | 9534 +++++++++++------ .../SubscriptionPriceIntervalsParams.kt | 1551 ++- .../SubscriptionSchedulePlanChangeParams.kt | 9224 ++++++++++------ .../withorb/api/models/BillableMetricTest.kt | 3 + .../api/models/ItemListPageResponseTest.kt | 3 + .../kotlin/com/withorb/api/models/ItemTest.kt | 3 + .../api/models/MetricListPageResponseTest.kt | 3 + .../com/withorb/api/models/PriceTest.kt | 298 + 28 files changed, 35399 insertions(+), 11956 deletions(-) diff --git a/.stats.yml b/.stats.yml index fd40002fd..4b69c08ad 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 118 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-26020bd285825dac04bf642a414ea07c786fc6e42ee6bbcf795e11f8db426519.yml -openapi_spec_hash: 897fedec83f0960539b3aa4ec0e3308d +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-297c7ce95bc0aa1ac6f324a487515f49b8a30b74eb9d39ca9dcd2d9cf065f0ef.yml +openapi_spec_hash: 29e9af981bc78379336079bb4208c54d config_hash: 1f73a949b649ecfe6ec68ba1bb459dc2 diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BetaCreatePlanVersionParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BetaCreatePlanVersionParams.kt index 4131bea64..a39a0e8ea 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BetaCreatePlanVersionParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BetaCreatePlanVersionParams.kt @@ -1966,6 +1966,9 @@ private constructor( /** Alias for calling [price] with `Price.ofMinimum(minimum)`. */ fun price(minimum: NewPlanMinimumCompositePrice) = price(Price.ofMinimum(minimum)) + /** Alias for calling [price] with `Price.ofEventOutput(eventOutput)`. */ + fun price(eventOutput: Price.EventOutput) = price(Price.ofEventOutput(eventOutput)) + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -2066,6 +2069,7 @@ private constructor( null, private val cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice? = null, private val minimum: NewPlanMinimumCompositePrice? = null, + private val eventOutput: EventOutput? = null, private val _json: JsonValue? = null, ) { @@ -2129,6 +2133,8 @@ private constructor( fun minimum(): NewPlanMinimumCompositePrice? = minimum + fun eventOutput(): EventOutput? = eventOutput + fun isUnit(): Boolean = unit != null fun isTiered(): Boolean = tiered != null @@ -2184,6 +2190,8 @@ private constructor( fun isMinimum(): Boolean = minimum != null + fun isEventOutput(): Boolean = eventOutput != null + fun asUnit(): NewPlanUnitPrice = unit.getOrThrow("unit") fun asTiered(): NewPlanTieredPrice = tiered.getOrThrow("tiered") @@ -2259,6 +2267,8 @@ private constructor( fun asMinimum(): NewPlanMinimumCompositePrice = minimum.getOrThrow("minimum") + fun asEventOutput(): EventOutput = eventOutput.getOrThrow("eventOutput") + fun _json(): JsonValue? = _json fun accept(visitor: Visitor): T = @@ -2306,6 +2316,7 @@ private constructor( cumulativeGroupedBulk != null -> visitor.visitCumulativeGroupedBulk(cumulativeGroupedBulk) minimum != null -> visitor.visitMinimum(minimum) + eventOutput != null -> visitor.visitEventOutput(eventOutput) else -> visitor.unknown(_json) } @@ -2464,6 +2475,10 @@ private constructor( override fun visitMinimum(minimum: NewPlanMinimumCompositePrice) { minimum.validate() } + + override fun visitEventOutput(eventOutput: EventOutput) { + eventOutput.validate() + } } ) validated = true @@ -2583,6 +2598,9 @@ private constructor( override fun visitMinimum(minimum: NewPlanMinimumCompositePrice) = minimum.validity() + override fun visitEventOutput(eventOutput: EventOutput) = + eventOutput.validity() + override fun unknown(json: JsonValue?) = 0 } ) @@ -2619,7 +2637,8 @@ private constructor( scalableMatrixWithUnitPricing == other.scalableMatrixWithUnitPricing && scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && cumulativeGroupedBulk == other.cumulativeGroupedBulk && - minimum == other.minimum + minimum == other.minimum && + eventOutput == other.eventOutput } override fun hashCode(): Int = @@ -2651,6 +2670,7 @@ private constructor( scalableMatrixWithTieredPricing, cumulativeGroupedBulk, minimum, + eventOutput, ) override fun toString(): String = @@ -2695,6 +2715,7 @@ private constructor( cumulativeGroupedBulk != null -> "Price{cumulativeGroupedBulk=$cumulativeGroupedBulk}" minimum != null -> "Price{minimum=$minimum}" + eventOutput != null -> "Price{eventOutput=$eventOutput}" _json != null -> "Price{_unknown=$_json}" else -> throw IllegalStateException("Invalid Price") } @@ -2785,6 +2806,8 @@ private constructor( ) = Price(cumulativeGroupedBulk = cumulativeGroupedBulk) fun ofMinimum(minimum: NewPlanMinimumCompositePrice) = Price(minimum = minimum) + + fun ofEventOutput(eventOutput: EventOutput) = Price(eventOutput = eventOutput) } /** @@ -2872,6 +2895,8 @@ private constructor( fun visitMinimum(minimum: NewPlanMinimumCompositePrice): T + fun visitEventOutput(eventOutput: EventOutput): T + /** * Maps an unknown variant of [Price] to a value of type [T]. * @@ -3084,6 +3109,11 @@ private constructor( ) ?.let { Price(minimum = it, _json = json) } ?: Price(_json = json) } + "event_output" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(eventOutput = it, _json = json) + } ?: Price(_json = json) + } } return Price(_json = json) @@ -3144,6 +3174,7 @@ private constructor( value.cumulativeGroupedBulk != null -> generator.writeObject(value.cumulativeGroupedBulk) value.minimum != null -> generator.writeObject(value.minimum) + value.eventOutput != null -> generator.writeObject(value.eventOutput) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid Price") } @@ -6616,1049 +6647,1573 @@ private constructor( override fun toString() = "GroupedWithMinMaxThresholds{cadence=$cadence, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - return other is AddPrice && - allocationPrice == other.allocationPrice && - planPhaseOrder == other.planPhaseOrder && - price == other.price && - additionalProperties == other.additionalProperties - } + class EventOutput + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val eventOutputConfig: JsonField, + private val itemId: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { - private val hashCode: Int by lazy { - Objects.hash(allocationPrice, planPhaseOrder, price, additionalProperties) - } + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("event_output_config") + @ExcludeMissing + eventOutputConfig: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + eventOutputConfig, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + mutableMapOf(), + ) - override fun hashCode(): Int = hashCode + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") - override fun toString() = - "AddPrice{allocationPrice=$allocationPrice, planPhaseOrder=$planPhaseOrder, price=$price, additionalProperties=$additionalProperties}" - } + /** + * Configuration for event_output pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun eventOutputConfig(): EventOutputConfig = + eventOutputConfig.getRequired("event_output_config") - class RemoveAdjustment - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val adjustmentId: JsonField, - private val planPhaseOrder: JsonField, - private val additionalProperties: MutableMap, - ) { + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") - @JsonCreator - private constructor( - @JsonProperty("adjustment_id") - @ExcludeMissing - adjustmentId: JsonField = JsonMissing.of(), - @JsonProperty("plan_phase_order") - @ExcludeMissing - planPhaseOrder: JsonField = JsonMissing.of(), - ) : this(adjustmentId, planPhaseOrder, mutableMapOf()) + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("event_output") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType - /** - * The id of the adjustment to remove from on the plan. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun adjustmentId(): String = adjustmentId.getRequired("adjustment_id") + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") - /** - * The phase to remove this adjustment from. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun planPhaseOrder(): Long? = planPhaseOrder.getNullable("plan_phase_order") + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = billableMetricId.getNullable("billable_metric_id") - /** - * Returns the raw JSON value of [adjustmentId]. - * - * Unlike [adjustmentId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("adjustment_id") - @ExcludeMissing - fun _adjustmentId(): JsonField = adjustmentId + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") - /** - * Returns the raw JSON value of [planPhaseOrder]. - * - * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("plan_phase_order") - @ExcludeMissing - fun _planPhaseOrder(): JsonField = planPhaseOrder + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") - companion object { + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") - /** - * Returns a mutable builder for constructing an instance of [RemoveAdjustment]. - * - * The following fields are required: - * ```kotlin - * .adjustmentId() - * ``` - */ - fun builder() = Builder() - } + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") - /** A builder for [RemoveAdjustment]. */ - class Builder internal constructor() { + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") - private var adjustmentId: JsonField? = null - private var planPhaseOrder: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") - internal fun from(removeAdjustment: RemoveAdjustment) = apply { - adjustmentId = removeAdjustment.adjustmentId - planPhaseOrder = removeAdjustment.planPhaseOrder - additionalProperties = removeAdjustment.additionalProperties.toMutableMap() - } + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + invoiceGroupingKey.getNullable("invoice_grouping_key") - /** The id of the adjustment to remove from on the plan. */ - fun adjustmentId(adjustmentId: String) = adjustmentId(JsonField.of(adjustmentId)) + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - /** - * Sets [Builder.adjustmentId] to an arbitrary JSON value. - * - * You should usually call [Builder.adjustmentId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun adjustmentId(adjustmentId: JsonField) = apply { - this.adjustmentId = adjustmentId - } + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") - /** The phase to remove this adjustment from. */ - fun planPhaseOrder(planPhaseOrder: Long?) = - planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") - /** - * Alias for [Builder.planPhaseOrder]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence - /** - * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. - * - * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun planPhaseOrder(planPhaseOrder: JsonField) = apply { - this.planPhaseOrder = planPhaseOrder - } + /** + * Returns the raw JSON value of [eventOutputConfig]. + * + * Unlike [eventOutputConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("event_output_config") + @ExcludeMissing + fun _eventOutputConfig(): JsonField = eventOutputConfig - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration - /** - * Returns an immutable instance of [RemoveAdjustment]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```kotlin - * .adjustmentId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): RemoveAdjustment = - RemoveAdjustment( - checkRequired("adjustmentId", adjustmentId), - planPhaseOrder, - additionalProperties.toMutableMap(), - ) - } + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate - private var validated: Boolean = false + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig - fun validate(): RemoveAdjustment = apply { - if (validated) { - return@apply - } + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency - adjustmentId() - planPhaseOrder() - validated = true - } + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (if (adjustmentId.asKnown() == null) 0 else 1) + - (if (planPhaseOrder.asKnown() == null) 0 else 1) + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - return other is RemoveAdjustment && - adjustmentId == other.adjustmentId && - planPhaseOrder == other.planPhaseOrder && - additionalProperties == other.additionalProperties - } + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration - private val hashCode: Int by lazy { - Objects.hash(adjustmentId, planPhaseOrder, additionalProperties) - } + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata - override fun hashCode(): Int = hashCode + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId - override fun toString() = - "RemoveAdjustment{adjustmentId=$adjustmentId, planPhaseOrder=$planPhaseOrder, additionalProperties=$additionalProperties}" - } + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - class RemovePrice - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val priceId: JsonField, - private val planPhaseOrder: JsonField, - private val additionalProperties: MutableMap, - ) { + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - @JsonCreator - private constructor( - @JsonProperty("price_id") @ExcludeMissing priceId: JsonField = JsonMissing.of(), - @JsonProperty("plan_phase_order") - @ExcludeMissing - planPhaseOrder: JsonField = JsonMissing.of(), - ) : this(priceId, planPhaseOrder, mutableMapOf()) + fun toBuilder() = Builder().from(this) - /** - * The id of the price to remove from the plan. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun priceId(): String = priceId.getRequired("price_id") + companion object { - /** - * The phase to remove this price from. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun planPhaseOrder(): Long? = planPhaseOrder.getNullable("plan_phase_order") + /** + * Returns a mutable builder for constructing an instance of [EventOutput]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .eventOutputConfig() + * .itemId() + * .name() + * ``` + */ + fun builder() = Builder() + } - /** - * Returns the raw JSON value of [priceId]. - * - * Unlike [priceId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId + /** A builder for [EventOutput]. */ + class Builder internal constructor() { - /** - * Returns the raw JSON value of [planPhaseOrder]. - * - * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("plan_phase_order") - @ExcludeMissing - fun _planPhaseOrder(): JsonField = planPhaseOrder + private var cadence: JsonField? = null + private var eventOutputConfig: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonValue = JsonValue.from("event_output") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + internal fun from(eventOutput: EventOutput) = apply { + cadence = eventOutput.cadence + eventOutputConfig = eventOutput.eventOutputConfig + itemId = eventOutput.itemId + modelType = eventOutput.modelType + name = eventOutput.name + billableMetricId = eventOutput.billableMetricId + billedInAdvance = eventOutput.billedInAdvance + billingCycleConfiguration = eventOutput.billingCycleConfiguration + conversionRate = eventOutput.conversionRate + conversionRateConfig = eventOutput.conversionRateConfig + currency = eventOutput.currency + dimensionalPriceConfiguration = eventOutput.dimensionalPriceConfiguration + externalPriceId = eventOutput.externalPriceId + fixedPriceQuantity = eventOutput.fixedPriceQuantity + invoiceGroupingKey = eventOutput.invoiceGroupingKey + invoicingCycleConfiguration = eventOutput.invoicingCycleConfiguration + metadata = eventOutput.metadata + referenceId = eventOutput.referenceId + additionalProperties = eventOutput.additionalProperties.toMutableMap() + } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - fun toBuilder() = Builder().from(this) + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - companion object { + /** Configuration for event_output pricing */ + fun eventOutputConfig(eventOutputConfig: EventOutputConfig) = + eventOutputConfig(JsonField.of(eventOutputConfig)) - /** - * Returns a mutable builder for constructing an instance of [RemovePrice]. - * - * The following fields are required: - * ```kotlin - * .priceId() - * ``` - */ - fun builder() = Builder() - } + /** + * Sets [Builder.eventOutputConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.eventOutputConfig] with a well-typed + * [EventOutputConfig] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun eventOutputConfig(eventOutputConfig: JsonField) = apply { + this.eventOutputConfig = eventOutputConfig + } - /** A builder for [RemovePrice]. */ - class Builder internal constructor() { + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - private var priceId: JsonField? = null - private var planPhaseOrder: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - internal fun from(removePrice: RemovePrice) = apply { - priceId = removePrice.priceId - planPhaseOrder = removePrice.planPhaseOrder - additionalProperties = removePrice.additionalProperties.toMutableMap() - } + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("event_output") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } - /** The id of the price to remove from the plan. */ - fun priceId(priceId: String) = priceId(JsonField.of(priceId)) + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) - /** - * Sets [Builder.priceId] to an arbitrary JSON value. - * - * You should usually call [Builder.priceId] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun priceId(priceId: JsonField) = apply { this.priceId = priceId } - - /** The phase to remove this price from. */ - fun planPhaseOrder(planPhaseOrder: Long?) = - planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } - /** - * Alias for [Builder.planPhaseOrder]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) - /** - * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. - * - * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun planPhaseOrder(planPhaseOrder: JsonField) = apply { - this.planPhaseOrder = planPhaseOrder - } + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } - /** - * Returns an immutable instance of [RemovePrice]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```kotlin - * .priceId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): RemovePrice = - RemovePrice( - checkRequired("priceId", priceId), - planPhaseOrder, - additionalProperties.toMutableMap(), - ) - } + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) - private var validated: Boolean = false + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) - fun validate(): RemovePrice = apply { - if (validated) { - return@apply - } + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } - priceId() - planPhaseOrder() - validated = true - } + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (if (priceId.asKnown() == null) 0 else 1) + - (if (planPhaseOrder.asKnown() == null) 0 else 1) + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) - return other is RemovePrice && - priceId == other.priceId && - planPhaseOrder == other.planPhaseOrder && - additionalProperties == other.additionalProperties - } + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) - private val hashCode: Int by lazy { - Objects.hash(priceId, planPhaseOrder, additionalProperties) - } + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) - override fun hashCode(): Int = hashCode + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) - override fun toString() = - "RemovePrice{priceId=$priceId, planPhaseOrder=$planPhaseOrder, additionalProperties=$additionalProperties}" - } + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } - class ReplaceAdjustment - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val adjustment: JsonField, - private val replacesAdjustmentId: JsonField, - private val planPhaseOrder: JsonField, - private val additionalProperties: MutableMap, - ) { + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) - @JsonCreator - private constructor( - @JsonProperty("adjustment") - @ExcludeMissing - adjustment: JsonField = JsonMissing.of(), - @JsonProperty("replaces_adjustment_id") - @ExcludeMissing - replacesAdjustmentId: JsonField = JsonMissing.of(), - @JsonProperty("plan_phase_order") - @ExcludeMissing - planPhaseOrder: JsonField = JsonMissing.of(), - ) : this(adjustment, replacesAdjustmentId, planPhaseOrder, mutableMapOf()) + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } - /** - * The definition of a new adjustment to create and add to the plan. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun adjustment(): Adjustment = adjustment.getRequired("adjustment") + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) - /** - * The id of the adjustment on the plan to replace in the plan. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun replacesAdjustmentId(): String = - replacesAdjustmentId.getRequired("replaces_adjustment_id") + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } - /** - * The phase to replace this adjustment from. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun planPhaseOrder(): Long? = planPhaseOrder.getNullable("plan_phase_order") + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) - /** - * Returns the raw JSON value of [adjustment]. - * - * Unlike [adjustment], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("adjustment") - @ExcludeMissing - fun _adjustment(): JsonField = adjustment + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) - /** - * Returns the raw JSON value of [replacesAdjustmentId]. - * - * Unlike [replacesAdjustmentId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("replaces_adjustment_id") - @ExcludeMissing - fun _replacesAdjustmentId(): JsonField = replacesAdjustmentId + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } - /** - * Returns the raw JSON value of [planPhaseOrder]. - * - * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("plan_phase_order") - @ExcludeMissing - fun _planPhaseOrder(): JsonField = planPhaseOrder + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) - fun toBuilder() = Builder().from(this) + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - companion object { + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - /** - * Returns a mutable builder for constructing an instance of [ReplaceAdjustment]. - * - * The following fields are required: - * ```kotlin - * .adjustment() - * .replacesAdjustmentId() - * ``` - */ - fun builder() = Builder() - } + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - /** A builder for [ReplaceAdjustment]. */ - class Builder internal constructor() { + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) - private var adjustment: JsonField? = null - private var replacesAdjustmentId: JsonField? = null - private var planPhaseOrder: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } - internal fun from(replaceAdjustment: ReplaceAdjustment) = apply { - adjustment = replaceAdjustment.adjustment - replacesAdjustmentId = replaceAdjustment.replacesAdjustmentId - planPhaseOrder = replaceAdjustment.planPhaseOrder - additionalProperties = replaceAdjustment.additionalProperties.toMutableMap() - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** The definition of a new adjustment to create and add to the plan. */ - fun adjustment(adjustment: Adjustment) = adjustment(JsonField.of(adjustment)) + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * Sets [Builder.adjustment] to an arbitrary JSON value. - * - * You should usually call [Builder.adjustment] with a well-typed [Adjustment] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun adjustment(adjustment: JsonField) = apply { - this.adjustment = adjustment - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - /** - * Alias for calling [adjustment] with - * `Adjustment.ofPercentageDiscount(percentageDiscount)`. - */ - fun adjustment(percentageDiscount: NewPercentageDiscount) = - adjustment(Adjustment.ofPercentageDiscount(percentageDiscount)) + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - /** - * Alias for calling [adjustment] with the following: - * ```kotlin - * NewPercentageDiscount.builder() - * .adjustmentType(NewPercentageDiscount.AdjustmentType.PERCENTAGE_DISCOUNT) - * .percentageDiscount(percentageDiscount) - * .build() - * ``` - */ - fun percentageDiscountAdjustment(percentageDiscount: Double) = - adjustment( - NewPercentageDiscount.builder() - .adjustmentType(NewPercentageDiscount.AdjustmentType.PERCENTAGE_DISCOUNT) - .percentageDiscount(percentageDiscount) - .build() - ) + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - /** Alias for calling [adjustment] with `Adjustment.ofUsageDiscount(usageDiscount)`. */ - fun adjustment(usageDiscount: NewUsageDiscount) = - adjustment(Adjustment.ofUsageDiscount(usageDiscount)) + /** + * Returns an immutable instance of [EventOutput]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .eventOutputConfig() + * .itemId() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): EventOutput = + EventOutput( + checkRequired("cadence", cadence), + checkRequired("eventOutputConfig", eventOutputConfig), + checkRequired("itemId", itemId), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } - /** - * Alias for calling [adjustment] with the following: - * ```kotlin - * NewUsageDiscount.builder() - * .adjustmentType(NewUsageDiscount.AdjustmentType.USAGE_DISCOUNT) - * .usageDiscount(usageDiscount) - * .build() - * ``` - */ - fun usageDiscountAdjustment(usageDiscount: Double) = - adjustment( - NewUsageDiscount.builder() - .adjustmentType(NewUsageDiscount.AdjustmentType.USAGE_DISCOUNT) - .usageDiscount(usageDiscount) - .build() - ) + private var validated: Boolean = false - /** - * Alias for calling [adjustment] with `Adjustment.ofAmountDiscount(amountDiscount)`. - */ - fun adjustment(amountDiscount: NewAmountDiscount) = - adjustment(Adjustment.ofAmountDiscount(amountDiscount)) + fun validate(): EventOutput = apply { + if (validated) { + return@apply + } - /** - * Alias for calling [adjustment] with the following: - * ```kotlin - * NewAmountDiscount.builder() - * .adjustmentType(NewAmountDiscount.AdjustmentType.AMOUNT_DISCOUNT) - * .amountDiscount(amountDiscount) - * .build() - * ``` - */ - fun amountDiscountAdjustment(amountDiscount: String) = - adjustment( - NewAmountDiscount.builder() - .adjustmentType(NewAmountDiscount.AdjustmentType.AMOUNT_DISCOUNT) - .amountDiscount(amountDiscount) - .build() - ) + cadence().validate() + eventOutputConfig().validate() + itemId() + _modelType().let { + if (it != JsonValue.from("event_output")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + metadata()?.validate() + referenceId() + validated = true + } - /** Alias for calling [adjustment] with `Adjustment.ofMinimum(minimum)`. */ - fun adjustment(minimum: NewMinimum) = adjustment(Adjustment.ofMinimum(minimum)) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - /** Alias for calling [adjustment] with `Adjustment.ofMaximum(maximum)`. */ - fun adjustment(maximum: NewMaximum) = adjustment(Adjustment.ofMaximum(maximum)) + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (eventOutputConfig.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + modelType.let { if (it == JsonValue.from("event_output")) 1 else 0 } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) - /** - * Alias for calling [adjustment] with the following: - * ```kotlin - * NewMaximum.builder() - * .adjustmentType(NewMaximum.AdjustmentType.MAXIMUM) - * .maximumAmount(maximumAmount) - * .build() - * ``` - */ - fun maximumAdjustment(maximumAmount: String) = - adjustment( - NewMaximum.builder() - .adjustmentType(NewMaximum.AdjustmentType.MAXIMUM) - .maximumAmount(maximumAmount) - .build() - ) + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { - /** The id of the adjustment on the plan to replace in the plan. */ - fun replacesAdjustmentId(replacesAdjustmentId: String) = - replacesAdjustmentId(JsonField.of(replacesAdjustmentId)) + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value - /** - * Sets [Builder.replacesAdjustmentId] to an arbitrary JSON value. - * - * You should usually call [Builder.replacesAdjustmentId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun replacesAdjustmentId(replacesAdjustmentId: JsonField) = apply { - this.replacesAdjustmentId = replacesAdjustmentId - } + companion object { - /** The phase to replace this adjustment from. */ - fun planPhaseOrder(planPhaseOrder: Long?) = - planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + val ANNUAL = of("annual") - /** - * Alias for [Builder.planPhaseOrder]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + val SEMI_ANNUAL = of("semi_annual") - /** - * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. - * - * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun planPhaseOrder(planPhaseOrder: JsonField) = apply { - this.planPhaseOrder = planPhaseOrder - } + val MONTHLY = of("monthly") - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + val QUARTERLY = of("quarterly") - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + val ONE_TIME = of("one_time") - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + val CUSTOM = of("custom") - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun of(value: String) = Cadence(JsonField.of(value)) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } - /** - * Returns an immutable instance of [ReplaceAdjustment]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```kotlin - * .adjustment() - * .replacesAdjustmentId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): ReplaceAdjustment = - ReplaceAdjustment( - checkRequired("adjustment", adjustment), - checkRequired("replacesAdjustmentId", replacesAdjustmentId), - planPhaseOrder, - additionalProperties.toMutableMap(), - ) - } + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } - private var validated: Boolean = false + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } - fun validate(): ReplaceAdjustment = apply { - if (validated) { - return@apply - } + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } - adjustment().validate() - replacesAdjustmentId() - planPhaseOrder() - validated = true - } + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + private var validated: Boolean = false - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (adjustment.asKnown()?.validity() ?: 0) + - (if (replacesAdjustmentId.asKnown() == null) 0 else 1) + - (if (planPhaseOrder.asKnown() == null) 0 else 1) + fun validate(): Cadence = apply { + if (validated) { + return@apply + } - /** The definition of a new adjustment to create and add to the plan. */ - @JsonDeserialize(using = Adjustment.Deserializer::class) - @JsonSerialize(using = Adjustment.Serializer::class) - class Adjustment - private constructor( - private val percentageDiscount: NewPercentageDiscount? = null, - private val usageDiscount: NewUsageDiscount? = null, - private val amountDiscount: NewAmountDiscount? = null, - private val minimum: NewMinimum? = null, - private val maximum: NewMaximum? = null, - private val _json: JsonValue? = null, - ) { + known() + validated = true + } - fun percentageDiscount(): NewPercentageDiscount? = percentageDiscount + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - fun usageDiscount(): NewUsageDiscount? = usageDiscount + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - fun amountDiscount(): NewAmountDiscount? = amountDiscount + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun minimum(): NewMinimum? = minimum + return other is Cadence && value == other.value + } - fun maximum(): NewMaximum? = maximum + override fun hashCode() = value.hashCode() - fun isPercentageDiscount(): Boolean = percentageDiscount != null + override fun toString() = value.toString() + } - fun isUsageDiscount(): Boolean = usageDiscount != null + /** Configuration for event_output pricing */ + class EventOutputConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val unitRatingKey: JsonField, + private val groupingKey: JsonField, + private val additionalProperties: MutableMap, + ) { - fun isAmountDiscount(): Boolean = amountDiscount != null + @JsonCreator + private constructor( + @JsonProperty("unit_rating_key") + @ExcludeMissing + unitRatingKey: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + ) : this(unitRatingKey, groupingKey, mutableMapOf()) - fun isMinimum(): Boolean = minimum != null + /** + * The key in the event data to extract the unit rate from. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun unitRatingKey(): String = unitRatingKey.getRequired("unit_rating_key") - fun isMaximum(): Boolean = maximum != null + /** + * An optional key in the event data to group by (e.g., event ID). All events + * will also be grouped by their unit rate. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun groupingKey(): String? = groupingKey.getNullable("grouping_key") - fun asPercentageDiscount(): NewPercentageDiscount = - percentageDiscount.getOrThrow("percentageDiscount") + /** + * Returns the raw JSON value of [unitRatingKey]. + * + * Unlike [unitRatingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_rating_key") + @ExcludeMissing + fun _unitRatingKey(): JsonField = unitRatingKey - fun asUsageDiscount(): NewUsageDiscount = usageDiscount.getOrThrow("usageDiscount") + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey - fun asAmountDiscount(): NewAmountDiscount = amountDiscount.getOrThrow("amountDiscount") + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - fun asMinimum(): NewMinimum = minimum.getOrThrow("minimum") + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - fun asMaximum(): NewMaximum = maximum.getOrThrow("maximum") + fun toBuilder() = Builder().from(this) - fun _json(): JsonValue? = _json + companion object { - fun accept(visitor: Visitor): T = - when { - percentageDiscount != null -> - visitor.visitPercentageDiscount(percentageDiscount) - usageDiscount != null -> visitor.visitUsageDiscount(usageDiscount) - amountDiscount != null -> visitor.visitAmountDiscount(amountDiscount) - minimum != null -> visitor.visitMinimum(minimum) - maximum != null -> visitor.visitMaximum(maximum) - else -> visitor.unknown(_json) - } + /** + * Returns a mutable builder for constructing an instance of + * [EventOutputConfig]. + * + * The following fields are required: + * ```kotlin + * .unitRatingKey() + * ``` + */ + fun builder() = Builder() + } - private var validated: Boolean = false + /** A builder for [EventOutputConfig]. */ + class Builder internal constructor() { - fun validate(): Adjustment = apply { - if (validated) { - return@apply - } + private var unitRatingKey: JsonField? = null + private var groupingKey: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() - accept( - object : Visitor { - override fun visitPercentageDiscount( - percentageDiscount: NewPercentageDiscount - ) { - percentageDiscount.validate() + internal fun from(eventOutputConfig: EventOutputConfig) = apply { + unitRatingKey = eventOutputConfig.unitRatingKey + groupingKey = eventOutputConfig.groupingKey + additionalProperties = + eventOutputConfig.additionalProperties.toMutableMap() } - override fun visitUsageDiscount(usageDiscount: NewUsageDiscount) { - usageDiscount.validate() - } + /** The key in the event data to extract the unit rate from. */ + fun unitRatingKey(unitRatingKey: String) = + unitRatingKey(JsonField.of(unitRatingKey)) - override fun visitAmountDiscount(amountDiscount: NewAmountDiscount) { - amountDiscount.validate() - } - - override fun visitMinimum(minimum: NewMinimum) { - minimum.validate() + /** + * Sets [Builder.unitRatingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.unitRatingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun unitRatingKey(unitRatingKey: JsonField) = apply { + this.unitRatingKey = unitRatingKey } - override fun visitMaximum(maximum: NewMaximum) { - maximum.validate() - } - } - ) - validated = true - } + /** + * An optional key in the event data to group by (e.g., event ID). All + * events will also be grouped by their unit rate. + */ + fun groupingKey(groupingKey: String?) = + groupingKey(JsonField.ofNullable(groupingKey)) - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitPercentageDiscount( - percentageDiscount: NewPercentageDiscount - ) = percentageDiscount.validity() + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - override fun visitUsageDiscount(usageDiscount: NewUsageDiscount) = - usageDiscount.validity() + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - override fun visitAmountDiscount(amountDiscount: NewAmountDiscount) = - amountDiscount.validity() + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - override fun visitMinimum(minimum: NewMinimum) = minimum.validity() + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - override fun visitMaximum(maximum: NewMaximum) = maximum.validity() + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - override fun unknown(json: JsonValue?) = 0 + /** + * Returns an immutable instance of [EventOutputConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .unitRatingKey() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): EventOutputConfig = + EventOutputConfig( + checkRequired("unitRatingKey", unitRatingKey), + groupingKey, + additionalProperties.toMutableMap(), + ) } - ) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + private var validated: Boolean = false - return other is Adjustment && - percentageDiscount == other.percentageDiscount && - usageDiscount == other.usageDiscount && - amountDiscount == other.amountDiscount && - minimum == other.minimum && - maximum == other.maximum - } + fun validate(): EventOutputConfig = apply { + if (validated) { + return@apply + } - override fun hashCode(): Int = - Objects.hash(percentageDiscount, usageDiscount, amountDiscount, minimum, maximum) + unitRatingKey() + groupingKey() + validated = true + } - override fun toString(): String = - when { - percentageDiscount != null -> - "Adjustment{percentageDiscount=$percentageDiscount}" - usageDiscount != null -> "Adjustment{usageDiscount=$usageDiscount}" - amountDiscount != null -> "Adjustment{amountDiscount=$amountDiscount}" - minimum != null -> "Adjustment{minimum=$minimum}" - maximum != null -> "Adjustment{maximum=$maximum}" - _json != null -> "Adjustment{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Adjustment") - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - companion object { + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (unitRatingKey.asKnown() == null) 0 else 1) + + (if (groupingKey.asKnown() == null) 0 else 1) - fun ofPercentageDiscount(percentageDiscount: NewPercentageDiscount) = - Adjustment(percentageDiscount = percentageDiscount) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun ofUsageDiscount(usageDiscount: NewUsageDiscount) = - Adjustment(usageDiscount = usageDiscount) + return other is EventOutputConfig && + unitRatingKey == other.unitRatingKey && + groupingKey == other.groupingKey && + additionalProperties == other.additionalProperties + } - fun ofAmountDiscount(amountDiscount: NewAmountDiscount) = - Adjustment(amountDiscount = amountDiscount) + private val hashCode: Int by lazy { + Objects.hash(unitRatingKey, groupingKey, additionalProperties) + } - fun ofMinimum(minimum: NewMinimum) = Adjustment(minimum = minimum) + override fun hashCode(): Int = hashCode - fun ofMaximum(maximum: NewMaximum) = Adjustment(maximum = maximum) - } + override fun toString() = + "EventOutputConfig{unitRatingKey=$unitRatingKey, groupingKey=$groupingKey, additionalProperties=$additionalProperties}" + } - /** - * An interface that defines how to map each variant of [Adjustment] to a value of type - * [T]. - */ - interface Visitor { + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { - fun visitPercentageDiscount(percentageDiscount: NewPercentageDiscount): T + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties - fun visitUsageDiscount(usageDiscount: NewUsageDiscount): T + fun toBuilder() = Builder().from(this) - fun visitAmountDiscount(amountDiscount: NewAmountDiscount): T + companion object { - fun visitMinimum(minimum: NewMinimum): T + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } - fun visitMaximum(maximum: NewMaximum): T + /** A builder for [Metadata]. */ + class Builder internal constructor() { - /** - * Maps an unknown variant of [Adjustment] to a value of type [T]. - * - * An instance of [Adjustment] can contain an unknown variant if it was deserialized - * from data that doesn't match any known variant. For example, if the SDK is on an - * older version than the API, then the API may respond with new variants that the - * SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown Adjustment: $json") - } - } + private var additionalProperties: MutableMap = + mutableMapOf() - internal class Deserializer : BaseDeserializer(Adjustment::class) { + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } - override fun ObjectCodec.deserialize(node: JsonNode): Adjustment { - val json = JsonValue.fromJsonNode(node) - val adjustmentType = json.asObject()?.get("adjustment_type")?.asString() + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - when (adjustmentType) { - "percentage_discount" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Adjustment(percentageDiscount = it, _json = json) } - ?: Adjustment(_json = json) - } - "usage_discount" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(usageDiscount = it, _json = json) - } ?: Adjustment(_json = json) - } - "amount_discount" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(amountDiscount = it, _json = json) - } ?: Adjustment(_json = json) + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) } - "minimum" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(minimum = it, _json = json) - } ?: Adjustment(_json = json) + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) } - "maximum" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(maximum = it, _json = json) - } ?: Adjustment(_json = json) + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } - return Adjustment(_json = json) - } - } + private var validated: Boolean = false - internal class Serializer : BaseSerializer(Adjustment::class) { + fun validate(): Metadata = apply { + if (validated) { + return@apply + } - override fun serialize( - value: Adjustment, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.percentageDiscount != null -> - generator.writeObject(value.percentageDiscount) - value.usageDiscount != null -> generator.writeObject(value.usageDiscount) - value.amountDiscount != null -> generator.writeObject(value.amountDiscount) - value.minimum != null -> generator.writeObject(value.minimum) - value.maximum != null -> generator.writeObject(value.maximum) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Adjustment") + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } + + return other is EventOutput && + cadence == other.cadence && + eventOutputConfig == other.eventOutputConfig && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + eventOutputConfig, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties, + ) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "EventOutput{cadence=$cadence, eventOutputConfig=$eventOutputConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } } @@ -7667,65 +8222,51 @@ private constructor( return true } - return other is ReplaceAdjustment && - adjustment == other.adjustment && - replacesAdjustmentId == other.replacesAdjustmentId && + return other is AddPrice && + allocationPrice == other.allocationPrice && planPhaseOrder == other.planPhaseOrder && + price == other.price && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(adjustment, replacesAdjustmentId, planPhaseOrder, additionalProperties) + Objects.hash(allocationPrice, planPhaseOrder, price, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "ReplaceAdjustment{adjustment=$adjustment, replacesAdjustmentId=$replacesAdjustmentId, planPhaseOrder=$planPhaseOrder, additionalProperties=$additionalProperties}" + "AddPrice{allocationPrice=$allocationPrice, planPhaseOrder=$planPhaseOrder, price=$price, additionalProperties=$additionalProperties}" } - class ReplacePrice + class RemoveAdjustment @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val replacesPriceId: JsonField, - private val allocationPrice: JsonField, + private val adjustmentId: JsonField, private val planPhaseOrder: JsonField, - private val price: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("replaces_price_id") - @ExcludeMissing - replacesPriceId: JsonField = JsonMissing.of(), - @JsonProperty("allocation_price") + @JsonProperty("adjustment_id") @ExcludeMissing - allocationPrice: JsonField = JsonMissing.of(), + adjustmentId: JsonField = JsonMissing.of(), @JsonProperty("plan_phase_order") @ExcludeMissing planPhaseOrder: JsonField = JsonMissing.of(), - @JsonProperty("price") @ExcludeMissing price: JsonField = JsonMissing.of(), - ) : this(replacesPriceId, allocationPrice, planPhaseOrder, price, mutableMapOf()) + ) : this(adjustmentId, planPhaseOrder, mutableMapOf()) /** - * The id of the price on the plan to replace in the plan. + * The id of the adjustment to remove from on the plan. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ - fun replacesPriceId(): String = replacesPriceId.getRequired("replaces_price_id") - - /** - * The allocation price to add to the plan. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun allocationPrice(): NewAllocationPrice? = allocationPrice.getNullable("allocation_price") + fun adjustmentId(): String = adjustmentId.getRequired("adjustment_id") /** - * The phase to replace this price from. + * The phase to remove this adjustment from. * * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -7733,32 +8274,14 @@ private constructor( fun planPhaseOrder(): Long? = planPhaseOrder.getNullable("plan_phase_order") /** - * New plan price request body params. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun price(): Price? = price.getNullable("price") - - /** - * Returns the raw JSON value of [replacesPriceId]. - * - * Unlike [replacesPriceId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("replaces_price_id") - @ExcludeMissing - fun _replacesPriceId(): JsonField = replacesPriceId - - /** - * Returns the raw JSON value of [allocationPrice]. + * Returns the raw JSON value of [adjustmentId]. * - * Unlike [allocationPrice], this method doesn't throw if the JSON field has an unexpected + * Unlike [adjustmentId], this method doesn't throw if the JSON field has an unexpected * type. */ - @JsonProperty("allocation_price") + @JsonProperty("adjustment_id") @ExcludeMissing - fun _allocationPrice(): JsonField = allocationPrice + fun _adjustmentId(): JsonField = adjustmentId /** * Returns the raw JSON value of [planPhaseOrder]. @@ -7770,13 +8293,6 @@ private constructor( @ExcludeMissing fun _planPhaseOrder(): JsonField = planPhaseOrder - /** - * Returns the raw JSON value of [price]. - * - * Unlike [price], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("price") @ExcludeMissing fun _price(): JsonField = price - @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -7792,64 +8308,44 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [ReplacePrice]. + * Returns a mutable builder for constructing an instance of [RemoveAdjustment]. * * The following fields are required: * ```kotlin - * .replacesPriceId() + * .adjustmentId() * ``` */ fun builder() = Builder() } - /** A builder for [ReplacePrice]. */ + /** A builder for [RemoveAdjustment]. */ class Builder internal constructor() { - private var replacesPriceId: JsonField? = null - private var allocationPrice: JsonField = JsonMissing.of() + private var adjustmentId: JsonField? = null private var planPhaseOrder: JsonField = JsonMissing.of() - private var price: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(replacePrice: ReplacePrice) = apply { - replacesPriceId = replacePrice.replacesPriceId - allocationPrice = replacePrice.allocationPrice - planPhaseOrder = replacePrice.planPhaseOrder - price = replacePrice.price - additionalProperties = replacePrice.additionalProperties.toMutableMap() + internal fun from(removeAdjustment: RemoveAdjustment) = apply { + adjustmentId = removeAdjustment.adjustmentId + planPhaseOrder = removeAdjustment.planPhaseOrder + additionalProperties = removeAdjustment.additionalProperties.toMutableMap() } - /** The id of the price on the plan to replace in the plan. */ - fun replacesPriceId(replacesPriceId: String) = - replacesPriceId(JsonField.of(replacesPriceId)) + /** The id of the adjustment to remove from on the plan. */ + fun adjustmentId(adjustmentId: String) = adjustmentId(JsonField.of(adjustmentId)) /** - * Sets [Builder.replacesPriceId] to an arbitrary JSON value. + * Sets [Builder.adjustmentId] to an arbitrary JSON value. * - * You should usually call [Builder.replacesPriceId] with a well-typed [String] value + * You should usually call [Builder.adjustmentId] with a well-typed [String] value * instead. This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun replacesPriceId(replacesPriceId: JsonField) = apply { - this.replacesPriceId = replacesPriceId - } - - /** The allocation price to add to the plan. */ - fun allocationPrice(allocationPrice: NewAllocationPrice?) = - allocationPrice(JsonField.ofNullable(allocationPrice)) - - /** - * Sets [Builder.allocationPrice] to an arbitrary JSON value. - * - * You should usually call [Builder.allocationPrice] with a well-typed - * [NewAllocationPrice] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun allocationPrice(allocationPrice: JsonField) = apply { - this.allocationPrice = allocationPrice + fun adjustmentId(adjustmentId: JsonField) = apply { + this.adjustmentId = adjustmentId } - /** The phase to replace this price from. */ + /** The phase to remove this adjustment from. */ fun planPhaseOrder(planPhaseOrder: Long?) = planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) @@ -7871,211 +8367,54 @@ private constructor( this.planPhaseOrder = planPhaseOrder } - /** New plan price request body params. */ - fun price(price: Price?) = price(JsonField.ofNullable(price)) - - /** - * Sets [Builder.price] to an arbitrary JSON value. - * - * You should usually call [Builder.price] with a well-typed [Price] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun price(price: JsonField) = apply { this.price = price } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** Alias for calling [price] with `Price.ofUnit(unit)`. */ - fun price(unit: NewPlanUnitPrice) = price(Price.ofUnit(unit)) + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** Alias for calling [price] with `Price.ofTiered(tiered)`. */ - fun price(tiered: NewPlanTieredPrice) = price(Price.ofTiered(tiered)) + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - /** Alias for calling [price] with `Price.ofBulk(bulk)`. */ - fun price(bulk: NewPlanBulkPrice) = price(Price.ofBulk(bulk)) - - /** Alias for calling [price] with `Price.ofPackage(package_)`. */ - fun price(package_: NewPlanPackagePrice) = price(Price.ofPackage(package_)) - - /** Alias for calling [price] with `Price.ofMatrix(matrix)`. */ - fun price(matrix: NewPlanMatrixPrice) = price(Price.ofMatrix(matrix)) - - /** - * Alias for calling [price] with `Price.ofThresholdTotalAmount(thresholdTotalAmount)`. - */ - fun price(thresholdTotalAmount: NewPlanThresholdTotalAmountPrice) = - price(Price.ofThresholdTotalAmount(thresholdTotalAmount)) - - /** Alias for calling [price] with `Price.ofTieredPackage(tieredPackage)`. */ - fun price(tieredPackage: NewPlanTieredPackagePrice) = - price(Price.ofTieredPackage(tieredPackage)) - - /** Alias for calling [price] with `Price.ofTieredWithMinimum(tieredWithMinimum)`. */ - fun price(tieredWithMinimum: NewPlanTieredWithMinimumPrice) = - price(Price.ofTieredWithMinimum(tieredWithMinimum)) - - /** Alias for calling [price] with `Price.ofGroupedTiered(groupedTiered)`. */ - fun price(groupedTiered: NewPlanGroupedTieredPrice) = - price(Price.ofGroupedTiered(groupedTiered)) - - /** - * Alias for calling [price] with - * `Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)`. - */ - fun price(tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice) = - price(Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)) - - /** - * Alias for calling [price] with - * `Price.ofPackageWithAllocation(packageWithAllocation)`. - */ - fun price(packageWithAllocation: NewPlanPackageWithAllocationPrice) = - price(Price.ofPackageWithAllocation(packageWithAllocation)) - - /** Alias for calling [price] with `Price.ofUnitWithPercent(unitWithPercent)`. */ - fun price(unitWithPercent: NewPlanUnitWithPercentPrice) = - price(Price.ofUnitWithPercent(unitWithPercent)) - - /** - * Alias for calling [price] with `Price.ofMatrixWithAllocation(matrixWithAllocation)`. - */ - fun price(matrixWithAllocation: NewPlanMatrixWithAllocationPrice) = - price(Price.ofMatrixWithAllocation(matrixWithAllocation)) - - /** - * Alias for calling [price] with `Price.ofTieredWithProration(tieredWithProration)`. - */ - fun price(tieredWithProration: Price.TieredWithProration) = - price(Price.ofTieredWithProration(tieredWithProration)) - - /** Alias for calling [price] with `Price.ofUnitWithProration(unitWithProration)`. */ - fun price(unitWithProration: NewPlanUnitWithProrationPrice) = - price(Price.ofUnitWithProration(unitWithProration)) - - /** Alias for calling [price] with `Price.ofGroupedAllocation(groupedAllocation)`. */ - fun price(groupedAllocation: NewPlanGroupedAllocationPrice) = - price(Price.ofGroupedAllocation(groupedAllocation)) - - /** Alias for calling [price] with `Price.ofBulkWithProration(bulkWithProration)`. */ - fun price(bulkWithProration: NewPlanBulkWithProrationPrice) = - price(Price.ofBulkWithProration(bulkWithProration)) - - /** - * Alias for calling [price] with - * `Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)`. - */ - fun price(groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice) = - price(Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)) - - /** - * Alias for calling [price] with - * `Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)`. - */ - fun price(groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice) = - price(Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)) - - /** - * Alias for calling [price] with - * `Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)`. - */ - fun price(groupedWithMinMaxThresholds: Price.GroupedWithMinMaxThresholds) = - price(Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)) - - /** - * Alias for calling [price] with - * `Price.ofMatrixWithDisplayName(matrixWithDisplayName)`. - */ - fun price(matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice) = - price(Price.ofMatrixWithDisplayName(matrixWithDisplayName)) - - /** - * Alias for calling [price] with `Price.ofGroupedTieredPackage(groupedTieredPackage)`. - */ - fun price(groupedTieredPackage: NewPlanGroupedTieredPackagePrice) = - price(Price.ofGroupedTieredPackage(groupedTieredPackage)) - - /** - * Alias for calling [price] with - * `Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)`. - */ - fun price(maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice) = - price(Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)) - - /** - * Alias for calling [price] with - * `Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)`. - */ - fun price(scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice) = - price(Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)) - - /** - * Alias for calling [price] with - * `Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)`. - */ - fun price( - scalableMatrixWithTieredPricing: NewPlanScalableMatrixWithTieredPricingPrice - ) = price(Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)) - - /** - * Alias for calling [price] with - * `Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)`. - */ - fun price(cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice) = - price(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) - - /** Alias for calling [price] with `Price.ofMinimum(minimum)`. */ - fun price(minimum: NewPlanMinimumCompositePrice) = price(Price.ofMinimum(minimum)) - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } fun removeAllAdditionalProperties(keys: Set) = apply { keys.forEach(::removeAdditionalProperty) } /** - * Returns an immutable instance of [ReplacePrice]. + * Returns an immutable instance of [RemoveAdjustment]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```kotlin - * .replacesPriceId() + * .adjustmentId() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): ReplacePrice = - ReplacePrice( - checkRequired("replacesPriceId", replacesPriceId), - allocationPrice, + fun build(): RemoveAdjustment = + RemoveAdjustment( + checkRequired("adjustmentId", adjustmentId), planPhaseOrder, - price, additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): ReplacePrice = apply { + fun validate(): RemoveAdjustment = apply { if (validated) { return@apply } - replacesPriceId() - allocationPrice()?.validate() + adjustmentId() planPhaseOrder() - price()?.validate() validated = true } @@ -8094,443 +8433,659 @@ private constructor( * Used for best match union deserialization. */ internal fun validity(): Int = - (if (replacesPriceId.asKnown() == null) 0 else 1) + - (allocationPrice.asKnown()?.validity() ?: 0) + - (if (planPhaseOrder.asKnown() == null) 0 else 1) + - (price.asKnown()?.validity() ?: 0) - - /** New plan price request body params. */ - @JsonDeserialize(using = Price.Deserializer::class) - @JsonSerialize(using = Price.Serializer::class) - class Price - private constructor( - private val unit: NewPlanUnitPrice? = null, - private val tiered: NewPlanTieredPrice? = null, - private val bulk: NewPlanBulkPrice? = null, - private val package_: NewPlanPackagePrice? = null, - private val matrix: NewPlanMatrixPrice? = null, - private val thresholdTotalAmount: NewPlanThresholdTotalAmountPrice? = null, - private val tieredPackage: NewPlanTieredPackagePrice? = null, - private val tieredWithMinimum: NewPlanTieredWithMinimumPrice? = null, - private val groupedTiered: NewPlanGroupedTieredPrice? = null, - private val tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice? = null, - private val packageWithAllocation: NewPlanPackageWithAllocationPrice? = null, - private val unitWithPercent: NewPlanUnitWithPercentPrice? = null, - private val matrixWithAllocation: NewPlanMatrixWithAllocationPrice? = null, - private val tieredWithProration: TieredWithProration? = null, - private val unitWithProration: NewPlanUnitWithProrationPrice? = null, - private val groupedAllocation: NewPlanGroupedAllocationPrice? = null, - private val bulkWithProration: NewPlanBulkWithProrationPrice? = null, - private val groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice? = null, - private val groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice? = null, - private val groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds? = null, - private val matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice? = null, - private val groupedTieredPackage: NewPlanGroupedTieredPackagePrice? = null, - private val maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice? = null, - private val scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice? = - null, - private val scalableMatrixWithTieredPricing: - NewPlanScalableMatrixWithTieredPricingPrice? = - null, - private val cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice? = null, - private val minimum: NewPlanMinimumCompositePrice? = null, - private val _json: JsonValue? = null, - ) { - - fun unit(): NewPlanUnitPrice? = unit + (if (adjustmentId.asKnown() == null) 0 else 1) + + (if (planPhaseOrder.asKnown() == null) 0 else 1) - fun tiered(): NewPlanTieredPrice? = tiered + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun bulk(): NewPlanBulkPrice? = bulk + return other is RemoveAdjustment && + adjustmentId == other.adjustmentId && + planPhaseOrder == other.planPhaseOrder && + additionalProperties == other.additionalProperties + } - fun package_(): NewPlanPackagePrice? = package_ + private val hashCode: Int by lazy { + Objects.hash(adjustmentId, planPhaseOrder, additionalProperties) + } - fun matrix(): NewPlanMatrixPrice? = matrix + override fun hashCode(): Int = hashCode - fun thresholdTotalAmount(): NewPlanThresholdTotalAmountPrice? = thresholdTotalAmount + override fun toString() = + "RemoveAdjustment{adjustmentId=$adjustmentId, planPhaseOrder=$planPhaseOrder, additionalProperties=$additionalProperties}" + } - fun tieredPackage(): NewPlanTieredPackagePrice? = tieredPackage + class RemovePrice + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val priceId: JsonField, + private val planPhaseOrder: JsonField, + private val additionalProperties: MutableMap, + ) { - fun tieredWithMinimum(): NewPlanTieredWithMinimumPrice? = tieredWithMinimum + @JsonCreator + private constructor( + @JsonProperty("price_id") @ExcludeMissing priceId: JsonField = JsonMissing.of(), + @JsonProperty("plan_phase_order") + @ExcludeMissing + planPhaseOrder: JsonField = JsonMissing.of(), + ) : this(priceId, planPhaseOrder, mutableMapOf()) - fun groupedTiered(): NewPlanGroupedTieredPrice? = groupedTiered + /** + * The id of the price to remove from the plan. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun priceId(): String = priceId.getRequired("price_id") - fun tieredPackageWithMinimum(): NewPlanTieredPackageWithMinimumPrice? = - tieredPackageWithMinimum - - fun packageWithAllocation(): NewPlanPackageWithAllocationPrice? = packageWithAllocation - - fun unitWithPercent(): NewPlanUnitWithPercentPrice? = unitWithPercent - - fun matrixWithAllocation(): NewPlanMatrixWithAllocationPrice? = matrixWithAllocation + /** + * The phase to remove this price from. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun planPhaseOrder(): Long? = planPhaseOrder.getNullable("plan_phase_order") - fun tieredWithProration(): TieredWithProration? = tieredWithProration + /** + * Returns the raw JSON value of [priceId]. + * + * Unlike [priceId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId - fun unitWithProration(): NewPlanUnitWithProrationPrice? = unitWithProration + /** + * Returns the raw JSON value of [planPhaseOrder]. + * + * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder - fun groupedAllocation(): NewPlanGroupedAllocationPrice? = groupedAllocation + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - fun bulkWithProration(): NewPlanBulkWithProrationPrice? = bulkWithProration + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - fun groupedWithProratedMinimum(): NewPlanGroupedWithProratedMinimumPrice? = - groupedWithProratedMinimum + fun toBuilder() = Builder().from(this) - fun groupedWithMeteredMinimum(): NewPlanGroupedWithMeteredMinimumPrice? = - groupedWithMeteredMinimum + companion object { - fun groupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds? = - groupedWithMinMaxThresholds + /** + * Returns a mutable builder for constructing an instance of [RemovePrice]. + * + * The following fields are required: + * ```kotlin + * .priceId() + * ``` + */ + fun builder() = Builder() + } - fun matrixWithDisplayName(): NewPlanMatrixWithDisplayNamePrice? = matrixWithDisplayName + /** A builder for [RemovePrice]. */ + class Builder internal constructor() { - fun groupedTieredPackage(): NewPlanGroupedTieredPackagePrice? = groupedTieredPackage + private var priceId: JsonField? = null + private var planPhaseOrder: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - fun maxGroupTieredPackage(): NewPlanMaxGroupTieredPackagePrice? = maxGroupTieredPackage + internal fun from(removePrice: RemovePrice) = apply { + priceId = removePrice.priceId + planPhaseOrder = removePrice.planPhaseOrder + additionalProperties = removePrice.additionalProperties.toMutableMap() + } - fun scalableMatrixWithUnitPricing(): NewPlanScalableMatrixWithUnitPricingPrice? = - scalableMatrixWithUnitPricing + /** The id of the price to remove from the plan. */ + fun priceId(priceId: String) = priceId(JsonField.of(priceId)) - fun scalableMatrixWithTieredPricing(): NewPlanScalableMatrixWithTieredPricingPrice? = - scalableMatrixWithTieredPricing + /** + * Sets [Builder.priceId] to an arbitrary JSON value. + * + * You should usually call [Builder.priceId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun priceId(priceId: JsonField) = apply { this.priceId = priceId } - fun cumulativeGroupedBulk(): NewPlanCumulativeGroupedBulkPrice? = cumulativeGroupedBulk + /** The phase to remove this price from. */ + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) - fun minimum(): NewPlanMinimumCompositePrice? = minimum + /** + * Alias for [Builder.planPhaseOrder]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) - fun isUnit(): Boolean = unit != null + /** + * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. + * + * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun planPhaseOrder(planPhaseOrder: JsonField) = apply { + this.planPhaseOrder = planPhaseOrder + } - fun isTiered(): Boolean = tiered != null + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun isBulk(): Boolean = bulk != null + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun isPackage(): Boolean = package_ != null + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun isMatrix(): Boolean = matrix != null + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - fun isThresholdTotalAmount(): Boolean = thresholdTotalAmount != null + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - fun isTieredPackage(): Boolean = tieredPackage != null + /** + * Returns an immutable instance of [RemovePrice]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .priceId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): RemovePrice = + RemovePrice( + checkRequired("priceId", priceId), + planPhaseOrder, + additionalProperties.toMutableMap(), + ) + } - fun isTieredWithMinimum(): Boolean = tieredWithMinimum != null + private var validated: Boolean = false - fun isGroupedTiered(): Boolean = groupedTiered != null + fun validate(): RemovePrice = apply { + if (validated) { + return@apply + } - fun isTieredPackageWithMinimum(): Boolean = tieredPackageWithMinimum != null + priceId() + planPhaseOrder() + validated = true + } - fun isPackageWithAllocation(): Boolean = packageWithAllocation != null + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - fun isUnitWithPercent(): Boolean = unitWithPercent != null + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (priceId.asKnown() == null) 0 else 1) + + (if (planPhaseOrder.asKnown() == null) 0 else 1) - fun isMatrixWithAllocation(): Boolean = matrixWithAllocation != null + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun isTieredWithProration(): Boolean = tieredWithProration != null + return other is RemovePrice && + priceId == other.priceId && + planPhaseOrder == other.planPhaseOrder && + additionalProperties == other.additionalProperties + } - fun isUnitWithProration(): Boolean = unitWithProration != null + private val hashCode: Int by lazy { + Objects.hash(priceId, planPhaseOrder, additionalProperties) + } - fun isGroupedAllocation(): Boolean = groupedAllocation != null + override fun hashCode(): Int = hashCode - fun isBulkWithProration(): Boolean = bulkWithProration != null + override fun toString() = + "RemovePrice{priceId=$priceId, planPhaseOrder=$planPhaseOrder, additionalProperties=$additionalProperties}" + } - fun isGroupedWithProratedMinimum(): Boolean = groupedWithProratedMinimum != null + class ReplaceAdjustment + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val adjustment: JsonField, + private val replacesAdjustmentId: JsonField, + private val planPhaseOrder: JsonField, + private val additionalProperties: MutableMap, + ) { - fun isGroupedWithMeteredMinimum(): Boolean = groupedWithMeteredMinimum != null + @JsonCreator + private constructor( + @JsonProperty("adjustment") + @ExcludeMissing + adjustment: JsonField = JsonMissing.of(), + @JsonProperty("replaces_adjustment_id") + @ExcludeMissing + replacesAdjustmentId: JsonField = JsonMissing.of(), + @JsonProperty("plan_phase_order") + @ExcludeMissing + planPhaseOrder: JsonField = JsonMissing.of(), + ) : this(adjustment, replacesAdjustmentId, planPhaseOrder, mutableMapOf()) - fun isGroupedWithMinMaxThresholds(): Boolean = groupedWithMinMaxThresholds != null + /** + * The definition of a new adjustment to create and add to the plan. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun adjustment(): Adjustment = adjustment.getRequired("adjustment") - fun isMatrixWithDisplayName(): Boolean = matrixWithDisplayName != null + /** + * The id of the adjustment on the plan to replace in the plan. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun replacesAdjustmentId(): String = + replacesAdjustmentId.getRequired("replaces_adjustment_id") - fun isGroupedTieredPackage(): Boolean = groupedTieredPackage != null + /** + * The phase to replace this adjustment from. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun planPhaseOrder(): Long? = planPhaseOrder.getNullable("plan_phase_order") - fun isMaxGroupTieredPackage(): Boolean = maxGroupTieredPackage != null + /** + * Returns the raw JSON value of [adjustment]. + * + * Unlike [adjustment], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("adjustment") + @ExcludeMissing + fun _adjustment(): JsonField = adjustment - fun isScalableMatrixWithUnitPricing(): Boolean = scalableMatrixWithUnitPricing != null - - fun isScalableMatrixWithTieredPricing(): Boolean = - scalableMatrixWithTieredPricing != null + /** + * Returns the raw JSON value of [replacesAdjustmentId]. + * + * Unlike [replacesAdjustmentId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("replaces_adjustment_id") + @ExcludeMissing + fun _replacesAdjustmentId(): JsonField = replacesAdjustmentId - fun isCumulativeGroupedBulk(): Boolean = cumulativeGroupedBulk != null + /** + * Returns the raw JSON value of [planPhaseOrder]. + * + * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder - fun isMinimum(): Boolean = minimum != null + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - fun asUnit(): NewPlanUnitPrice = unit.getOrThrow("unit") + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - fun asTiered(): NewPlanTieredPrice = tiered.getOrThrow("tiered") + fun toBuilder() = Builder().from(this) - fun asBulk(): NewPlanBulkPrice = bulk.getOrThrow("bulk") + companion object { - fun asPackage(): NewPlanPackagePrice = package_.getOrThrow("package_") + /** + * Returns a mutable builder for constructing an instance of [ReplaceAdjustment]. + * + * The following fields are required: + * ```kotlin + * .adjustment() + * .replacesAdjustmentId() + * ``` + */ + fun builder() = Builder() + } - fun asMatrix(): NewPlanMatrixPrice = matrix.getOrThrow("matrix") + /** A builder for [ReplaceAdjustment]. */ + class Builder internal constructor() { - fun asThresholdTotalAmount(): NewPlanThresholdTotalAmountPrice = - thresholdTotalAmount.getOrThrow("thresholdTotalAmount") + private var adjustment: JsonField? = null + private var replacesAdjustmentId: JsonField? = null + private var planPhaseOrder: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - fun asTieredPackage(): NewPlanTieredPackagePrice = - tieredPackage.getOrThrow("tieredPackage") + internal fun from(replaceAdjustment: ReplaceAdjustment) = apply { + adjustment = replaceAdjustment.adjustment + replacesAdjustmentId = replaceAdjustment.replacesAdjustmentId + planPhaseOrder = replaceAdjustment.planPhaseOrder + additionalProperties = replaceAdjustment.additionalProperties.toMutableMap() + } - fun asTieredWithMinimum(): NewPlanTieredWithMinimumPrice = - tieredWithMinimum.getOrThrow("tieredWithMinimum") + /** The definition of a new adjustment to create and add to the plan. */ + fun adjustment(adjustment: Adjustment) = adjustment(JsonField.of(adjustment)) - fun asGroupedTiered(): NewPlanGroupedTieredPrice = - groupedTiered.getOrThrow("groupedTiered") + /** + * Sets [Builder.adjustment] to an arbitrary JSON value. + * + * You should usually call [Builder.adjustment] with a well-typed [Adjustment] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun adjustment(adjustment: JsonField) = apply { + this.adjustment = adjustment + } - fun asTieredPackageWithMinimum(): NewPlanTieredPackageWithMinimumPrice = - tieredPackageWithMinimum.getOrThrow("tieredPackageWithMinimum") + /** + * Alias for calling [adjustment] with + * `Adjustment.ofPercentageDiscount(percentageDiscount)`. + */ + fun adjustment(percentageDiscount: NewPercentageDiscount) = + adjustment(Adjustment.ofPercentageDiscount(percentageDiscount)) - fun asPackageWithAllocation(): NewPlanPackageWithAllocationPrice = - packageWithAllocation.getOrThrow("packageWithAllocation") + /** + * Alias for calling [adjustment] with the following: + * ```kotlin + * NewPercentageDiscount.builder() + * .adjustmentType(NewPercentageDiscount.AdjustmentType.PERCENTAGE_DISCOUNT) + * .percentageDiscount(percentageDiscount) + * .build() + * ``` + */ + fun percentageDiscountAdjustment(percentageDiscount: Double) = + adjustment( + NewPercentageDiscount.builder() + .adjustmentType(NewPercentageDiscount.AdjustmentType.PERCENTAGE_DISCOUNT) + .percentageDiscount(percentageDiscount) + .build() + ) - fun asUnitWithPercent(): NewPlanUnitWithPercentPrice = - unitWithPercent.getOrThrow("unitWithPercent") + /** Alias for calling [adjustment] with `Adjustment.ofUsageDiscount(usageDiscount)`. */ + fun adjustment(usageDiscount: NewUsageDiscount) = + adjustment(Adjustment.ofUsageDiscount(usageDiscount)) - fun asMatrixWithAllocation(): NewPlanMatrixWithAllocationPrice = - matrixWithAllocation.getOrThrow("matrixWithAllocation") + /** + * Alias for calling [adjustment] with the following: + * ```kotlin + * NewUsageDiscount.builder() + * .adjustmentType(NewUsageDiscount.AdjustmentType.USAGE_DISCOUNT) + * .usageDiscount(usageDiscount) + * .build() + * ``` + */ + fun usageDiscountAdjustment(usageDiscount: Double) = + adjustment( + NewUsageDiscount.builder() + .adjustmentType(NewUsageDiscount.AdjustmentType.USAGE_DISCOUNT) + .usageDiscount(usageDiscount) + .build() + ) - fun asTieredWithProration(): TieredWithProration = - tieredWithProration.getOrThrow("tieredWithProration") + /** + * Alias for calling [adjustment] with `Adjustment.ofAmountDiscount(amountDiscount)`. + */ + fun adjustment(amountDiscount: NewAmountDiscount) = + adjustment(Adjustment.ofAmountDiscount(amountDiscount)) - fun asUnitWithProration(): NewPlanUnitWithProrationPrice = - unitWithProration.getOrThrow("unitWithProration") + /** + * Alias for calling [adjustment] with the following: + * ```kotlin + * NewAmountDiscount.builder() + * .adjustmentType(NewAmountDiscount.AdjustmentType.AMOUNT_DISCOUNT) + * .amountDiscount(amountDiscount) + * .build() + * ``` + */ + fun amountDiscountAdjustment(amountDiscount: String) = + adjustment( + NewAmountDiscount.builder() + .adjustmentType(NewAmountDiscount.AdjustmentType.AMOUNT_DISCOUNT) + .amountDiscount(amountDiscount) + .build() + ) - fun asGroupedAllocation(): NewPlanGroupedAllocationPrice = - groupedAllocation.getOrThrow("groupedAllocation") + /** Alias for calling [adjustment] with `Adjustment.ofMinimum(minimum)`. */ + fun adjustment(minimum: NewMinimum) = adjustment(Adjustment.ofMinimum(minimum)) - fun asBulkWithProration(): NewPlanBulkWithProrationPrice = - bulkWithProration.getOrThrow("bulkWithProration") + /** Alias for calling [adjustment] with `Adjustment.ofMaximum(maximum)`. */ + fun adjustment(maximum: NewMaximum) = adjustment(Adjustment.ofMaximum(maximum)) - fun asGroupedWithProratedMinimum(): NewPlanGroupedWithProratedMinimumPrice = - groupedWithProratedMinimum.getOrThrow("groupedWithProratedMinimum") + /** + * Alias for calling [adjustment] with the following: + * ```kotlin + * NewMaximum.builder() + * .adjustmentType(NewMaximum.AdjustmentType.MAXIMUM) + * .maximumAmount(maximumAmount) + * .build() + * ``` + */ + fun maximumAdjustment(maximumAmount: String) = + adjustment( + NewMaximum.builder() + .adjustmentType(NewMaximum.AdjustmentType.MAXIMUM) + .maximumAmount(maximumAmount) + .build() + ) - fun asGroupedWithMeteredMinimum(): NewPlanGroupedWithMeteredMinimumPrice = - groupedWithMeteredMinimum.getOrThrow("groupedWithMeteredMinimum") + /** The id of the adjustment on the plan to replace in the plan. */ + fun replacesAdjustmentId(replacesAdjustmentId: String) = + replacesAdjustmentId(JsonField.of(replacesAdjustmentId)) - fun asGroupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds = - groupedWithMinMaxThresholds.getOrThrow("groupedWithMinMaxThresholds") + /** + * Sets [Builder.replacesAdjustmentId] to an arbitrary JSON value. + * + * You should usually call [Builder.replacesAdjustmentId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun replacesAdjustmentId(replacesAdjustmentId: JsonField) = apply { + this.replacesAdjustmentId = replacesAdjustmentId + } - fun asMatrixWithDisplayName(): NewPlanMatrixWithDisplayNamePrice = - matrixWithDisplayName.getOrThrow("matrixWithDisplayName") + /** The phase to replace this adjustment from. */ + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) - fun asGroupedTieredPackage(): NewPlanGroupedTieredPackagePrice = - groupedTieredPackage.getOrThrow("groupedTieredPackage") + /** + * Alias for [Builder.planPhaseOrder]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) - fun asMaxGroupTieredPackage(): NewPlanMaxGroupTieredPackagePrice = - maxGroupTieredPackage.getOrThrow("maxGroupTieredPackage") + /** + * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. + * + * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun planPhaseOrder(planPhaseOrder: JsonField) = apply { + this.planPhaseOrder = planPhaseOrder + } - fun asScalableMatrixWithUnitPricing(): NewPlanScalableMatrixWithUnitPricingPrice = - scalableMatrixWithUnitPricing.getOrThrow("scalableMatrixWithUnitPricing") + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun asScalableMatrixWithTieredPricing(): NewPlanScalableMatrixWithTieredPricingPrice = - scalableMatrixWithTieredPricing.getOrThrow("scalableMatrixWithTieredPricing") + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun asCumulativeGroupedBulk(): NewPlanCumulativeGroupedBulkPrice = - cumulativeGroupedBulk.getOrThrow("cumulativeGroupedBulk") + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun asMinimum(): NewPlanMinimumCompositePrice = minimum.getOrThrow("minimum") + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - fun _json(): JsonValue? = _json + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - bulk != null -> visitor.visitBulk(bulk) - package_ != null -> visitor.visitPackage(package_) - matrix != null -> visitor.visitMatrix(matrix) - thresholdTotalAmount != null -> - visitor.visitThresholdTotalAmount(thresholdTotalAmount) - tieredPackage != null -> visitor.visitTieredPackage(tieredPackage) - tieredWithMinimum != null -> visitor.visitTieredWithMinimum(tieredWithMinimum) - groupedTiered != null -> visitor.visitGroupedTiered(groupedTiered) - tieredPackageWithMinimum != null -> - visitor.visitTieredPackageWithMinimum(tieredPackageWithMinimum) - packageWithAllocation != null -> - visitor.visitPackageWithAllocation(packageWithAllocation) - unitWithPercent != null -> visitor.visitUnitWithPercent(unitWithPercent) - matrixWithAllocation != null -> - visitor.visitMatrixWithAllocation(matrixWithAllocation) - tieredWithProration != null -> - visitor.visitTieredWithProration(tieredWithProration) - unitWithProration != null -> visitor.visitUnitWithProration(unitWithProration) - groupedAllocation != null -> visitor.visitGroupedAllocation(groupedAllocation) - bulkWithProration != null -> visitor.visitBulkWithProration(bulkWithProration) - groupedWithProratedMinimum != null -> - visitor.visitGroupedWithProratedMinimum(groupedWithProratedMinimum) - groupedWithMeteredMinimum != null -> - visitor.visitGroupedWithMeteredMinimum(groupedWithMeteredMinimum) - groupedWithMinMaxThresholds != null -> - visitor.visitGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds) - matrixWithDisplayName != null -> - visitor.visitMatrixWithDisplayName(matrixWithDisplayName) - groupedTieredPackage != null -> - visitor.visitGroupedTieredPackage(groupedTieredPackage) - maxGroupTieredPackage != null -> - visitor.visitMaxGroupTieredPackage(maxGroupTieredPackage) - scalableMatrixWithUnitPricing != null -> - visitor.visitScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing) - scalableMatrixWithTieredPricing != null -> - visitor.visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing - ) - cumulativeGroupedBulk != null -> - visitor.visitCumulativeGroupedBulk(cumulativeGroupedBulk) - minimum != null -> visitor.visitMinimum(minimum) - else -> visitor.unknown(_json) - } + /** + * Returns an immutable instance of [ReplaceAdjustment]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .adjustment() + * .replacesAdjustmentId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ReplaceAdjustment = + ReplaceAdjustment( + checkRequired("adjustment", adjustment), + checkRequired("replacesAdjustmentId", replacesAdjustmentId), + planPhaseOrder, + additionalProperties.toMutableMap(), + ) + } - private var validated: Boolean = false + private var validated: Boolean = false - fun validate(): Price = apply { - if (validated) { - return@apply - } + fun validate(): ReplaceAdjustment = apply { + if (validated) { + return@apply + } - accept( - object : Visitor { - override fun visitUnit(unit: NewPlanUnitPrice) { - unit.validate() - } + adjustment().validate() + replacesAdjustmentId() + planPhaseOrder() + validated = true + } - override fun visitTiered(tiered: NewPlanTieredPrice) { - tiered.validate() - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - override fun visitBulk(bulk: NewPlanBulkPrice) { - bulk.validate() - } + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (adjustment.asKnown()?.validity() ?: 0) + + (if (replacesAdjustmentId.asKnown() == null) 0 else 1) + + (if (planPhaseOrder.asKnown() == null) 0 else 1) - override fun visitPackage(package_: NewPlanPackagePrice) { - package_.validate() - } + /** The definition of a new adjustment to create and add to the plan. */ + @JsonDeserialize(using = Adjustment.Deserializer::class) + @JsonSerialize(using = Adjustment.Serializer::class) + class Adjustment + private constructor( + private val percentageDiscount: NewPercentageDiscount? = null, + private val usageDiscount: NewUsageDiscount? = null, + private val amountDiscount: NewAmountDiscount? = null, + private val minimum: NewMinimum? = null, + private val maximum: NewMaximum? = null, + private val _json: JsonValue? = null, + ) { - override fun visitMatrix(matrix: NewPlanMatrixPrice) { - matrix.validate() - } + fun percentageDiscount(): NewPercentageDiscount? = percentageDiscount - override fun visitThresholdTotalAmount( - thresholdTotalAmount: NewPlanThresholdTotalAmountPrice - ) { - thresholdTotalAmount.validate() - } + fun usageDiscount(): NewUsageDiscount? = usageDiscount - override fun visitTieredPackage(tieredPackage: NewPlanTieredPackagePrice) { - tieredPackage.validate() - } + fun amountDiscount(): NewAmountDiscount? = amountDiscount - override fun visitTieredWithMinimum( - tieredWithMinimum: NewPlanTieredWithMinimumPrice - ) { - tieredWithMinimum.validate() - } + fun minimum(): NewMinimum? = minimum - override fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) { - groupedTiered.validate() - } + fun maximum(): NewMaximum? = maximum - override fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice - ) { - tieredPackageWithMinimum.validate() - } + fun isPercentageDiscount(): Boolean = percentageDiscount != null - override fun visitPackageWithAllocation( - packageWithAllocation: NewPlanPackageWithAllocationPrice - ) { - packageWithAllocation.validate() - } + fun isUsageDiscount(): Boolean = usageDiscount != null - override fun visitUnitWithPercent( - unitWithPercent: NewPlanUnitWithPercentPrice - ) { - unitWithPercent.validate() - } + fun isAmountDiscount(): Boolean = amountDiscount != null - override fun visitMatrixWithAllocation( - matrixWithAllocation: NewPlanMatrixWithAllocationPrice - ) { - matrixWithAllocation.validate() - } + fun isMinimum(): Boolean = minimum != null - override fun visitTieredWithProration( - tieredWithProration: TieredWithProration - ) { - tieredWithProration.validate() - } + fun isMaximum(): Boolean = maximum != null - override fun visitUnitWithProration( - unitWithProration: NewPlanUnitWithProrationPrice - ) { - unitWithProration.validate() - } + fun asPercentageDiscount(): NewPercentageDiscount = + percentageDiscount.getOrThrow("percentageDiscount") - override fun visitGroupedAllocation( - groupedAllocation: NewPlanGroupedAllocationPrice - ) { - groupedAllocation.validate() - } + fun asUsageDiscount(): NewUsageDiscount = usageDiscount.getOrThrow("usageDiscount") - override fun visitBulkWithProration( - bulkWithProration: NewPlanBulkWithProrationPrice - ) { - bulkWithProration.validate() - } + fun asAmountDiscount(): NewAmountDiscount = amountDiscount.getOrThrow("amountDiscount") - override fun visitGroupedWithProratedMinimum( - groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice - ) { - groupedWithProratedMinimum.validate() - } + fun asMinimum(): NewMinimum = minimum.getOrThrow("minimum") - override fun visitGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice - ) { - groupedWithMeteredMinimum.validate() - } + fun asMaximum(): NewMaximum = maximum.getOrThrow("maximum") - override fun visitGroupedWithMinMaxThresholds( - groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds - ) { - groupedWithMinMaxThresholds.validate() - } + fun _json(): JsonValue? = _json - override fun visitMatrixWithDisplayName( - matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice - ) { - matrixWithDisplayName.validate() - } + fun accept(visitor: Visitor): T = + when { + percentageDiscount != null -> + visitor.visitPercentageDiscount(percentageDiscount) + usageDiscount != null -> visitor.visitUsageDiscount(usageDiscount) + amountDiscount != null -> visitor.visitAmountDiscount(amountDiscount) + minimum != null -> visitor.visitMinimum(minimum) + maximum != null -> visitor.visitMaximum(maximum) + else -> visitor.unknown(_json) + } - override fun visitGroupedTieredPackage( - groupedTieredPackage: NewPlanGroupedTieredPackagePrice + private var validated: Boolean = false + + fun validate(): Adjustment = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitPercentageDiscount( + percentageDiscount: NewPercentageDiscount ) { - groupedTieredPackage.validate() + percentageDiscount.validate() } - override fun visitMaxGroupTieredPackage( - maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice - ) { - maxGroupTieredPackage.validate() + override fun visitUsageDiscount(usageDiscount: NewUsageDiscount) { + usageDiscount.validate() } - override fun visitScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice - ) { - scalableMatrixWithUnitPricing.validate() + override fun visitAmountDiscount(amountDiscount: NewAmountDiscount) { + amountDiscount.validate() } - override fun visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: - NewPlanScalableMatrixWithTieredPricingPrice - ) { - scalableMatrixWithTieredPricing.validate() + override fun visitMinimum(minimum: NewMinimum) { + minimum.validate() } - override fun visitCumulativeGroupedBulk( - cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice - ) { - cumulativeGroupedBulk.validate() - } - - override fun visitMinimum(minimum: NewPlanMinimumCompositePrice) { - minimum.validate() + override fun visitMaximum(maximum: NewMaximum) { + maximum.validate() } } ) @@ -8554,102 +9109,19 @@ private constructor( internal fun validity(): Int = accept( object : Visitor { - override fun visitUnit(unit: NewPlanUnitPrice) = unit.validity() - - override fun visitTiered(tiered: NewPlanTieredPrice) = tiered.validity() - - override fun visitBulk(bulk: NewPlanBulkPrice) = bulk.validity() - - override fun visitPackage(package_: NewPlanPackagePrice) = - package_.validity() - - override fun visitMatrix(matrix: NewPlanMatrixPrice) = matrix.validity() - - override fun visitThresholdTotalAmount( - thresholdTotalAmount: NewPlanThresholdTotalAmountPrice - ) = thresholdTotalAmount.validity() - - override fun visitTieredPackage(tieredPackage: NewPlanTieredPackagePrice) = - tieredPackage.validity() - - override fun visitTieredWithMinimum( - tieredWithMinimum: NewPlanTieredWithMinimumPrice - ) = tieredWithMinimum.validity() - - override fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) = - groupedTiered.validity() - - override fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice - ) = tieredPackageWithMinimum.validity() - - override fun visitPackageWithAllocation( - packageWithAllocation: NewPlanPackageWithAllocationPrice - ) = packageWithAllocation.validity() - - override fun visitUnitWithPercent( - unitWithPercent: NewPlanUnitWithPercentPrice - ) = unitWithPercent.validity() - - override fun visitMatrixWithAllocation( - matrixWithAllocation: NewPlanMatrixWithAllocationPrice - ) = matrixWithAllocation.validity() - - override fun visitTieredWithProration( - tieredWithProration: TieredWithProration - ) = tieredWithProration.validity() - - override fun visitUnitWithProration( - unitWithProration: NewPlanUnitWithProrationPrice - ) = unitWithProration.validity() - - override fun visitGroupedAllocation( - groupedAllocation: NewPlanGroupedAllocationPrice - ) = groupedAllocation.validity() - - override fun visitBulkWithProration( - bulkWithProration: NewPlanBulkWithProrationPrice - ) = bulkWithProration.validity() - - override fun visitGroupedWithProratedMinimum( - groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice - ) = groupedWithProratedMinimum.validity() - - override fun visitGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice - ) = groupedWithMeteredMinimum.validity() - - override fun visitGroupedWithMinMaxThresholds( - groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds - ) = groupedWithMinMaxThresholds.validity() - - override fun visitMatrixWithDisplayName( - matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice - ) = matrixWithDisplayName.validity() - - override fun visitGroupedTieredPackage( - groupedTieredPackage: NewPlanGroupedTieredPackagePrice - ) = groupedTieredPackage.validity() - - override fun visitMaxGroupTieredPackage( - maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice - ) = maxGroupTieredPackage.validity() + override fun visitPercentageDiscount( + percentageDiscount: NewPercentageDiscount + ) = percentageDiscount.validity() - override fun visitScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice - ) = scalableMatrixWithUnitPricing.validity() + override fun visitUsageDiscount(usageDiscount: NewUsageDiscount) = + usageDiscount.validity() - override fun visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: - NewPlanScalableMatrixWithTieredPricingPrice - ) = scalableMatrixWithTieredPricing.validity() + override fun visitAmountDiscount(amountDiscount: NewAmountDiscount) = + amountDiscount.validity() - override fun visitCumulativeGroupedBulk( - cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice - ) = cumulativeGroupedBulk.validity() + override fun visitMinimum(minimum: NewMinimum) = minimum.validity() - override fun visitMinimum(minimum: NewPlanMinimumCompositePrice) = - minimum.validity() + override fun visitMaximum(maximum: NewMaximum) = maximum.validity() override fun unknown(json: JsonValue?) = 0 } @@ -8660,572 +9132,3500 @@ private constructor( return true } - return other is Price && - unit == other.unit && - tiered == other.tiered && - bulk == other.bulk && - package_ == other.package_ && - matrix == other.matrix && - thresholdTotalAmount == other.thresholdTotalAmount && - tieredPackage == other.tieredPackage && - tieredWithMinimum == other.tieredWithMinimum && - groupedTiered == other.groupedTiered && - tieredPackageWithMinimum == other.tieredPackageWithMinimum && - packageWithAllocation == other.packageWithAllocation && - unitWithPercent == other.unitWithPercent && - matrixWithAllocation == other.matrixWithAllocation && - tieredWithProration == other.tieredWithProration && - unitWithProration == other.unitWithProration && - groupedAllocation == other.groupedAllocation && - bulkWithProration == other.bulkWithProration && - groupedWithProratedMinimum == other.groupedWithProratedMinimum && - groupedWithMeteredMinimum == other.groupedWithMeteredMinimum && - groupedWithMinMaxThresholds == other.groupedWithMinMaxThresholds && - matrixWithDisplayName == other.matrixWithDisplayName && - groupedTieredPackage == other.groupedTieredPackage && - maxGroupTieredPackage == other.maxGroupTieredPackage && - scalableMatrixWithUnitPricing == other.scalableMatrixWithUnitPricing && - scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && - cumulativeGroupedBulk == other.cumulativeGroupedBulk && - minimum == other.minimum + return other is Adjustment && + percentageDiscount == other.percentageDiscount && + usageDiscount == other.usageDiscount && + amountDiscount == other.amountDiscount && + minimum == other.minimum && + maximum == other.maximum } override fun hashCode(): Int = - Objects.hash( - unit, - tiered, - bulk, - package_, - matrix, - thresholdTotalAmount, - tieredPackage, - tieredWithMinimum, - groupedTiered, - tieredPackageWithMinimum, - packageWithAllocation, - unitWithPercent, - matrixWithAllocation, - tieredWithProration, - unitWithProration, - groupedAllocation, - bulkWithProration, - groupedWithProratedMinimum, - groupedWithMeteredMinimum, - groupedWithMinMaxThresholds, - matrixWithDisplayName, - groupedTieredPackage, - maxGroupTieredPackage, - scalableMatrixWithUnitPricing, - scalableMatrixWithTieredPricing, - cumulativeGroupedBulk, - minimum, - ) + Objects.hash(percentageDiscount, usageDiscount, amountDiscount, minimum, maximum) override fun toString(): String = when { - unit != null -> "Price{unit=$unit}" - tiered != null -> "Price{tiered=$tiered}" - bulk != null -> "Price{bulk=$bulk}" - package_ != null -> "Price{package_=$package_}" - matrix != null -> "Price{matrix=$matrix}" - thresholdTotalAmount != null -> - "Price{thresholdTotalAmount=$thresholdTotalAmount}" - tieredPackage != null -> "Price{tieredPackage=$tieredPackage}" - tieredWithMinimum != null -> "Price{tieredWithMinimum=$tieredWithMinimum}" - groupedTiered != null -> "Price{groupedTiered=$groupedTiered}" - tieredPackageWithMinimum != null -> - "Price{tieredPackageWithMinimum=$tieredPackageWithMinimum}" - packageWithAllocation != null -> - "Price{packageWithAllocation=$packageWithAllocation}" - unitWithPercent != null -> "Price{unitWithPercent=$unitWithPercent}" - matrixWithAllocation != null -> - "Price{matrixWithAllocation=$matrixWithAllocation}" - tieredWithProration != null -> "Price{tieredWithProration=$tieredWithProration}" - unitWithProration != null -> "Price{unitWithProration=$unitWithProration}" - groupedAllocation != null -> "Price{groupedAllocation=$groupedAllocation}" - bulkWithProration != null -> "Price{bulkWithProration=$bulkWithProration}" - groupedWithProratedMinimum != null -> - "Price{groupedWithProratedMinimum=$groupedWithProratedMinimum}" - groupedWithMeteredMinimum != null -> - "Price{groupedWithMeteredMinimum=$groupedWithMeteredMinimum}" - groupedWithMinMaxThresholds != null -> - "Price{groupedWithMinMaxThresholds=$groupedWithMinMaxThresholds}" - matrixWithDisplayName != null -> - "Price{matrixWithDisplayName=$matrixWithDisplayName}" - groupedTieredPackage != null -> - "Price{groupedTieredPackage=$groupedTieredPackage}" - maxGroupTieredPackage != null -> - "Price{maxGroupTieredPackage=$maxGroupTieredPackage}" - scalableMatrixWithUnitPricing != null -> - "Price{scalableMatrixWithUnitPricing=$scalableMatrixWithUnitPricing}" - scalableMatrixWithTieredPricing != null -> - "Price{scalableMatrixWithTieredPricing=$scalableMatrixWithTieredPricing}" - cumulativeGroupedBulk != null -> - "Price{cumulativeGroupedBulk=$cumulativeGroupedBulk}" - minimum != null -> "Price{minimum=$minimum}" - _json != null -> "Price{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Price") + percentageDiscount != null -> + "Adjustment{percentageDiscount=$percentageDiscount}" + usageDiscount != null -> "Adjustment{usageDiscount=$usageDiscount}" + amountDiscount != null -> "Adjustment{amountDiscount=$amountDiscount}" + minimum != null -> "Adjustment{minimum=$minimum}" + maximum != null -> "Adjustment{maximum=$maximum}" + _json != null -> "Adjustment{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Adjustment") } companion object { - fun ofUnit(unit: NewPlanUnitPrice) = Price(unit = unit) + fun ofPercentageDiscount(percentageDiscount: NewPercentageDiscount) = + Adjustment(percentageDiscount = percentageDiscount) - fun ofTiered(tiered: NewPlanTieredPrice) = Price(tiered = tiered) + fun ofUsageDiscount(usageDiscount: NewUsageDiscount) = + Adjustment(usageDiscount = usageDiscount) - fun ofBulk(bulk: NewPlanBulkPrice) = Price(bulk = bulk) + fun ofAmountDiscount(amountDiscount: NewAmountDiscount) = + Adjustment(amountDiscount = amountDiscount) - fun ofPackage(package_: NewPlanPackagePrice) = Price(package_ = package_) + fun ofMinimum(minimum: NewMinimum) = Adjustment(minimum = minimum) - fun ofMatrix(matrix: NewPlanMatrixPrice) = Price(matrix = matrix) + fun ofMaximum(maximum: NewMaximum) = Adjustment(maximum = maximum) + } - fun ofThresholdTotalAmount(thresholdTotalAmount: NewPlanThresholdTotalAmountPrice) = - Price(thresholdTotalAmount = thresholdTotalAmount) + /** + * An interface that defines how to map each variant of [Adjustment] to a value of type + * [T]. + */ + interface Visitor { - fun ofTieredPackage(tieredPackage: NewPlanTieredPackagePrice) = - Price(tieredPackage = tieredPackage) + fun visitPercentageDiscount(percentageDiscount: NewPercentageDiscount): T - fun ofTieredWithMinimum(tieredWithMinimum: NewPlanTieredWithMinimumPrice) = - Price(tieredWithMinimum = tieredWithMinimum) + fun visitUsageDiscount(usageDiscount: NewUsageDiscount): T - fun ofGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) = - Price(groupedTiered = groupedTiered) + fun visitAmountDiscount(amountDiscount: NewAmountDiscount): T - fun ofTieredPackageWithMinimum( - tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice - ) = Price(tieredPackageWithMinimum = tieredPackageWithMinimum) + fun visitMinimum(minimum: NewMinimum): T - fun ofPackageWithAllocation( - packageWithAllocation: NewPlanPackageWithAllocationPrice - ) = Price(packageWithAllocation = packageWithAllocation) + fun visitMaximum(maximum: NewMaximum): T - fun ofUnitWithPercent(unitWithPercent: NewPlanUnitWithPercentPrice) = - Price(unitWithPercent = unitWithPercent) + /** + * Maps an unknown variant of [Adjustment] to a value of type [T]. + * + * An instance of [Adjustment] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the + * SDK is unaware of. + * + * @throws OrbInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw OrbInvalidDataException("Unknown Adjustment: $json") + } + } - fun ofMatrixWithAllocation(matrixWithAllocation: NewPlanMatrixWithAllocationPrice) = - Price(matrixWithAllocation = matrixWithAllocation) + internal class Deserializer : BaseDeserializer(Adjustment::class) { - fun ofTieredWithProration(tieredWithProration: TieredWithProration) = - Price(tieredWithProration = tieredWithProration) + override fun ObjectCodec.deserialize(node: JsonNode): Adjustment { + val json = JsonValue.fromJsonNode(node) + val adjustmentType = json.asObject()?.get("adjustment_type")?.asString() - fun ofUnitWithProration(unitWithProration: NewPlanUnitWithProrationPrice) = - Price(unitWithProration = unitWithProration) + when (adjustmentType) { + "percentage_discount" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Adjustment(percentageDiscount = it, _json = json) } + ?: Adjustment(_json = json) + } + "usage_discount" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(usageDiscount = it, _json = json) + } ?: Adjustment(_json = json) + } + "amount_discount" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(amountDiscount = it, _json = json) + } ?: Adjustment(_json = json) + } + "minimum" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(minimum = it, _json = json) + } ?: Adjustment(_json = json) + } + "maximum" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(maximum = it, _json = json) + } ?: Adjustment(_json = json) + } + } - fun ofGroupedAllocation(groupedAllocation: NewPlanGroupedAllocationPrice) = - Price(groupedAllocation = groupedAllocation) + return Adjustment(_json = json) + } + } - fun ofBulkWithProration(bulkWithProration: NewPlanBulkWithProrationPrice) = - Price(bulkWithProration = bulkWithProration) + internal class Serializer : BaseSerializer(Adjustment::class) { - fun ofGroupedWithProratedMinimum( - groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice - ) = Price(groupedWithProratedMinimum = groupedWithProratedMinimum) + override fun serialize( + value: Adjustment, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.percentageDiscount != null -> + generator.writeObject(value.percentageDiscount) + value.usageDiscount != null -> generator.writeObject(value.usageDiscount) + value.amountDiscount != null -> generator.writeObject(value.amountDiscount) + value.minimum != null -> generator.writeObject(value.minimum) + value.maximum != null -> generator.writeObject(value.maximum) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Adjustment") + } + } + } + } - fun ofGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice - ) = Price(groupedWithMeteredMinimum = groupedWithMeteredMinimum) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun ofGroupedWithMinMaxThresholds( - groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds - ) = Price(groupedWithMinMaxThresholds = groupedWithMinMaxThresholds) + return other is ReplaceAdjustment && + adjustment == other.adjustment && + replacesAdjustmentId == other.replacesAdjustmentId && + planPhaseOrder == other.planPhaseOrder && + additionalProperties == other.additionalProperties + } - fun ofMatrixWithDisplayName( - matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice - ) = Price(matrixWithDisplayName = matrixWithDisplayName) + private val hashCode: Int by lazy { + Objects.hash(adjustment, replacesAdjustmentId, planPhaseOrder, additionalProperties) + } - fun ofGroupedTieredPackage(groupedTieredPackage: NewPlanGroupedTieredPackagePrice) = - Price(groupedTieredPackage = groupedTieredPackage) + override fun hashCode(): Int = hashCode - fun ofMaxGroupTieredPackage( - maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice - ) = Price(maxGroupTieredPackage = maxGroupTieredPackage) + override fun toString() = + "ReplaceAdjustment{adjustment=$adjustment, replacesAdjustmentId=$replacesAdjustmentId, planPhaseOrder=$planPhaseOrder, additionalProperties=$additionalProperties}" + } - fun ofScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice - ) = Price(scalableMatrixWithUnitPricing = scalableMatrixWithUnitPricing) + class ReplacePrice + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val replacesPriceId: JsonField, + private val allocationPrice: JsonField, + private val planPhaseOrder: JsonField, + private val price: JsonField, + private val additionalProperties: MutableMap, + ) { - fun ofScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: NewPlanScalableMatrixWithTieredPricingPrice - ) = Price(scalableMatrixWithTieredPricing = scalableMatrixWithTieredPricing) + @JsonCreator + private constructor( + @JsonProperty("replaces_price_id") + @ExcludeMissing + replacesPriceId: JsonField = JsonMissing.of(), + @JsonProperty("allocation_price") + @ExcludeMissing + allocationPrice: JsonField = JsonMissing.of(), + @JsonProperty("plan_phase_order") + @ExcludeMissing + planPhaseOrder: JsonField = JsonMissing.of(), + @JsonProperty("price") @ExcludeMissing price: JsonField = JsonMissing.of(), + ) : this(replacesPriceId, allocationPrice, planPhaseOrder, price, mutableMapOf()) - fun ofCumulativeGroupedBulk( - cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice - ) = Price(cumulativeGroupedBulk = cumulativeGroupedBulk) + /** + * The id of the price on the plan to replace in the plan. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun replacesPriceId(): String = replacesPriceId.getRequired("replaces_price_id") - fun ofMinimum(minimum: NewPlanMinimumCompositePrice) = Price(minimum = minimum) - } + /** + * The allocation price to add to the plan. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun allocationPrice(): NewAllocationPrice? = allocationPrice.getNullable("allocation_price") - /** - * An interface that defines how to map each variant of [Price] to a value of type [T]. - */ - interface Visitor { + /** + * The phase to replace this price from. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun planPhaseOrder(): Long? = planPhaseOrder.getNullable("plan_phase_order") - fun visitUnit(unit: NewPlanUnitPrice): T + /** + * New plan price request body params. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun price(): Price? = price.getNullable("price") - fun visitTiered(tiered: NewPlanTieredPrice): T + /** + * Returns the raw JSON value of [replacesPriceId]. + * + * Unlike [replacesPriceId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("replaces_price_id") + @ExcludeMissing + fun _replacesPriceId(): JsonField = replacesPriceId - fun visitBulk(bulk: NewPlanBulkPrice): T + /** + * Returns the raw JSON value of [allocationPrice]. + * + * Unlike [allocationPrice], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("allocation_price") + @ExcludeMissing + fun _allocationPrice(): JsonField = allocationPrice - fun visitPackage(package_: NewPlanPackagePrice): T + /** + * Returns the raw JSON value of [planPhaseOrder]. + * + * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder - fun visitMatrix(matrix: NewPlanMatrixPrice): T + /** + * Returns the raw JSON value of [price]. + * + * Unlike [price], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("price") @ExcludeMissing fun _price(): JsonField = price - fun visitThresholdTotalAmount( - thresholdTotalAmount: NewPlanThresholdTotalAmountPrice - ): T + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - fun visitTieredPackage(tieredPackage: NewPlanTieredPackagePrice): T + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - fun visitTieredWithMinimum(tieredWithMinimum: NewPlanTieredWithMinimumPrice): T + fun toBuilder() = Builder().from(this) - fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice): T + companion object { - fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice - ): T + /** + * Returns a mutable builder for constructing an instance of [ReplacePrice]. + * + * The following fields are required: + * ```kotlin + * .replacesPriceId() + * ``` + */ + fun builder() = Builder() + } - fun visitPackageWithAllocation( - packageWithAllocation: NewPlanPackageWithAllocationPrice - ): T + /** A builder for [ReplacePrice]. */ + class Builder internal constructor() { - fun visitUnitWithPercent(unitWithPercent: NewPlanUnitWithPercentPrice): T + private var replacesPriceId: JsonField? = null + private var allocationPrice: JsonField = JsonMissing.of() + private var planPhaseOrder: JsonField = JsonMissing.of() + private var price: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - fun visitMatrixWithAllocation( - matrixWithAllocation: NewPlanMatrixWithAllocationPrice - ): T + internal fun from(replacePrice: ReplacePrice) = apply { + replacesPriceId = replacePrice.replacesPriceId + allocationPrice = replacePrice.allocationPrice + planPhaseOrder = replacePrice.planPhaseOrder + price = replacePrice.price + additionalProperties = replacePrice.additionalProperties.toMutableMap() + } - fun visitTieredWithProration(tieredWithProration: TieredWithProration): T + /** The id of the price on the plan to replace in the plan. */ + fun replacesPriceId(replacesPriceId: String) = + replacesPriceId(JsonField.of(replacesPriceId)) - fun visitUnitWithProration(unitWithProration: NewPlanUnitWithProrationPrice): T + /** + * Sets [Builder.replacesPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.replacesPriceId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun replacesPriceId(replacesPriceId: JsonField) = apply { + this.replacesPriceId = replacesPriceId + } - fun visitGroupedAllocation(groupedAllocation: NewPlanGroupedAllocationPrice): T + /** The allocation price to add to the plan. */ + fun allocationPrice(allocationPrice: NewAllocationPrice?) = + allocationPrice(JsonField.ofNullable(allocationPrice)) - fun visitBulkWithProration(bulkWithProration: NewPlanBulkWithProrationPrice): T + /** + * Sets [Builder.allocationPrice] to an arbitrary JSON value. + * + * You should usually call [Builder.allocationPrice] with a well-typed + * [NewAllocationPrice] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun allocationPrice(allocationPrice: JsonField) = apply { + this.allocationPrice = allocationPrice + } - fun visitGroupedWithProratedMinimum( - groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice - ): T + /** The phase to replace this price from. */ + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) - fun visitGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice - ): T + /** + * Alias for [Builder.planPhaseOrder]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) - fun visitGroupedWithMinMaxThresholds( - groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds - ): T + /** + * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. + * + * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun planPhaseOrder(planPhaseOrder: JsonField) = apply { + this.planPhaseOrder = planPhaseOrder + } - fun visitMatrixWithDisplayName( - matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice - ): T + /** New plan price request body params. */ + fun price(price: Price?) = price(JsonField.ofNullable(price)) - fun visitGroupedTieredPackage( - groupedTieredPackage: NewPlanGroupedTieredPackagePrice - ): T + /** + * Sets [Builder.price] to an arbitrary JSON value. + * + * You should usually call [Builder.price] with a well-typed [Price] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun price(price: JsonField) = apply { this.price = price } - fun visitMaxGroupTieredPackage( - maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice - ): T + /** Alias for calling [price] with `Price.ofUnit(unit)`. */ + fun price(unit: NewPlanUnitPrice) = price(Price.ofUnit(unit)) - fun visitScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice - ): T + /** Alias for calling [price] with `Price.ofTiered(tiered)`. */ + fun price(tiered: NewPlanTieredPrice) = price(Price.ofTiered(tiered)) - fun visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: NewPlanScalableMatrixWithTieredPricingPrice - ): T + /** Alias for calling [price] with `Price.ofBulk(bulk)`. */ + fun price(bulk: NewPlanBulkPrice) = price(Price.ofBulk(bulk)) - fun visitCumulativeGroupedBulk( - cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice - ): T + /** Alias for calling [price] with `Price.ofPackage(package_)`. */ + fun price(package_: NewPlanPackagePrice) = price(Price.ofPackage(package_)) - fun visitMinimum(minimum: NewPlanMinimumCompositePrice): T + /** Alias for calling [price] with `Price.ofMatrix(matrix)`. */ + fun price(matrix: NewPlanMatrixPrice) = price(Price.ofMatrix(matrix)) - /** - * Maps an unknown variant of [Price] to a value of type [T]. - * - * An instance of [Price] can contain an unknown variant if it was deserialized from - * data that doesn't match any known variant. For example, if the SDK is on an older - * version than the API, then the API may respond with new variants that the SDK is - * unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown Price: $json") - } - } + /** + * Alias for calling [price] with `Price.ofThresholdTotalAmount(thresholdTotalAmount)`. + */ + fun price(thresholdTotalAmount: NewPlanThresholdTotalAmountPrice) = + price(Price.ofThresholdTotalAmount(thresholdTotalAmount)) - internal class Deserializer : BaseDeserializer(Price::class) { + /** Alias for calling [price] with `Price.ofTieredPackage(tieredPackage)`. */ + fun price(tieredPackage: NewPlanTieredPackagePrice) = + price(Price.ofTieredPackage(tieredPackage)) - override fun ObjectCodec.deserialize(node: JsonNode): Price { - val json = JsonValue.fromJsonNode(node) - val modelType = json.asObject()?.get("model_type")?.asString() + /** Alias for calling [price] with `Price.ofTieredWithMinimum(tieredWithMinimum)`. */ + fun price(tieredWithMinimum: NewPlanTieredWithMinimumPrice) = + price(Price.ofTieredWithMinimum(tieredWithMinimum)) - when (modelType) { - "unit" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(unit = it, _json = json) - } ?: Price(_json = json) - } - "tiered" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(tiered = it, _json = json) - } ?: Price(_json = json) - } - "bulk" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(bulk = it, _json = json) - } ?: Price(_json = json) - } - "package" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(package_ = it, _json = json) } ?: Price(_json = json) - } - "matrix" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(matrix = it, _json = json) - } ?: Price(_json = json) - } - "threshold_total_amount" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(thresholdTotalAmount = it, _json = json) } - ?: Price(_json = json) - } - "tiered_package" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(tieredPackage = it, _json = json) } - ?: Price(_json = json) - } - "tiered_with_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(tieredWithMinimum = it, _json = json) } - ?: Price(_json = json) - } - "grouped_tiered" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(groupedTiered = it, _json = json) } - ?: Price(_json = json) - } - "tiered_package_with_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(tieredPackageWithMinimum = it, _json = json) } - ?: Price(_json = json) - } - "package_with_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(packageWithAllocation = it, _json = json) } - ?: Price(_json = json) - } - "unit_with_percent" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(unitWithPercent = it, _json = json) } - ?: Price(_json = json) - } - "matrix_with_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(matrixWithAllocation = it, _json = json) } - ?: Price(_json = json) - } - "tiered_with_proration" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(tieredWithProration = it, _json = json) } - ?: Price(_json = json) - } - "unit_with_proration" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(unitWithProration = it, _json = json) } - ?: Price(_json = json) - } - "grouped_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedAllocation = it, _json = json) } - ?: Price(_json = json) - } - "bulk_with_proration" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(bulkWithProration = it, _json = json) } - ?: Price(_json = json) - } - "grouped_with_prorated_minimum" -> { - return tryDeserialize( - node, + /** Alias for calling [price] with `Price.ofGroupedTiered(groupedTiered)`. */ + fun price(groupedTiered: NewPlanGroupedTieredPrice) = + price(Price.ofGroupedTiered(groupedTiered)) + + /** + * Alias for calling [price] with + * `Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)`. + */ + fun price(tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice) = + price(Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)) + + /** + * Alias for calling [price] with + * `Price.ofPackageWithAllocation(packageWithAllocation)`. + */ + fun price(packageWithAllocation: NewPlanPackageWithAllocationPrice) = + price(Price.ofPackageWithAllocation(packageWithAllocation)) + + /** Alias for calling [price] with `Price.ofUnitWithPercent(unitWithPercent)`. */ + fun price(unitWithPercent: NewPlanUnitWithPercentPrice) = + price(Price.ofUnitWithPercent(unitWithPercent)) + + /** + * Alias for calling [price] with `Price.ofMatrixWithAllocation(matrixWithAllocation)`. + */ + fun price(matrixWithAllocation: NewPlanMatrixWithAllocationPrice) = + price(Price.ofMatrixWithAllocation(matrixWithAllocation)) + + /** + * Alias for calling [price] with `Price.ofTieredWithProration(tieredWithProration)`. + */ + fun price(tieredWithProration: Price.TieredWithProration) = + price(Price.ofTieredWithProration(tieredWithProration)) + + /** Alias for calling [price] with `Price.ofUnitWithProration(unitWithProration)`. */ + fun price(unitWithProration: NewPlanUnitWithProrationPrice) = + price(Price.ofUnitWithProration(unitWithProration)) + + /** Alias for calling [price] with `Price.ofGroupedAllocation(groupedAllocation)`. */ + fun price(groupedAllocation: NewPlanGroupedAllocationPrice) = + price(Price.ofGroupedAllocation(groupedAllocation)) + + /** Alias for calling [price] with `Price.ofBulkWithProration(bulkWithProration)`. */ + fun price(bulkWithProration: NewPlanBulkWithProrationPrice) = + price(Price.ofBulkWithProration(bulkWithProration)) + + /** + * Alias for calling [price] with + * `Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)`. + */ + fun price(groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice) = + price(Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)) + + /** + * Alias for calling [price] with + * `Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)`. + */ + fun price(groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice) = + price(Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)) + + /** + * Alias for calling [price] with + * `Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)`. + */ + fun price(groupedWithMinMaxThresholds: Price.GroupedWithMinMaxThresholds) = + price(Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)) + + /** + * Alias for calling [price] with + * `Price.ofMatrixWithDisplayName(matrixWithDisplayName)`. + */ + fun price(matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice) = + price(Price.ofMatrixWithDisplayName(matrixWithDisplayName)) + + /** + * Alias for calling [price] with `Price.ofGroupedTieredPackage(groupedTieredPackage)`. + */ + fun price(groupedTieredPackage: NewPlanGroupedTieredPackagePrice) = + price(Price.ofGroupedTieredPackage(groupedTieredPackage)) + + /** + * Alias for calling [price] with + * `Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)`. + */ + fun price(maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice) = + price(Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)) + + /** + * Alias for calling [price] with + * `Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)`. + */ + fun price(scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice) = + price(Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)) + + /** + * Alias for calling [price] with + * `Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)`. + */ + fun price( + scalableMatrixWithTieredPricing: NewPlanScalableMatrixWithTieredPricingPrice + ) = price(Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)) + + /** + * Alias for calling [price] with + * `Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)`. + */ + fun price(cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice) = + price(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) + + /** Alias for calling [price] with `Price.ofMinimum(minimum)`. */ + fun price(minimum: NewPlanMinimumCompositePrice) = price(Price.ofMinimum(minimum)) + + /** Alias for calling [price] with `Price.ofEventOutput(eventOutput)`. */ + fun price(eventOutput: Price.EventOutput) = price(Price.ofEventOutput(eventOutput)) + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ReplacePrice]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .replacesPriceId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ReplacePrice = + ReplacePrice( + checkRequired("replacesPriceId", replacesPriceId), + allocationPrice, + planPhaseOrder, + price, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ReplacePrice = apply { + if (validated) { + return@apply + } + + replacesPriceId() + allocationPrice()?.validate() + planPhaseOrder() + price()?.validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (replacesPriceId.asKnown() == null) 0 else 1) + + (allocationPrice.asKnown()?.validity() ?: 0) + + (if (planPhaseOrder.asKnown() == null) 0 else 1) + + (price.asKnown()?.validity() ?: 0) + + /** New plan price request body params. */ + @JsonDeserialize(using = Price.Deserializer::class) + @JsonSerialize(using = Price.Serializer::class) + class Price + private constructor( + private val unit: NewPlanUnitPrice? = null, + private val tiered: NewPlanTieredPrice? = null, + private val bulk: NewPlanBulkPrice? = null, + private val package_: NewPlanPackagePrice? = null, + private val matrix: NewPlanMatrixPrice? = null, + private val thresholdTotalAmount: NewPlanThresholdTotalAmountPrice? = null, + private val tieredPackage: NewPlanTieredPackagePrice? = null, + private val tieredWithMinimum: NewPlanTieredWithMinimumPrice? = null, + private val groupedTiered: NewPlanGroupedTieredPrice? = null, + private val tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice? = null, + private val packageWithAllocation: NewPlanPackageWithAllocationPrice? = null, + private val unitWithPercent: NewPlanUnitWithPercentPrice? = null, + private val matrixWithAllocation: NewPlanMatrixWithAllocationPrice? = null, + private val tieredWithProration: TieredWithProration? = null, + private val unitWithProration: NewPlanUnitWithProrationPrice? = null, + private val groupedAllocation: NewPlanGroupedAllocationPrice? = null, + private val bulkWithProration: NewPlanBulkWithProrationPrice? = null, + private val groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice? = null, + private val groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice? = null, + private val groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds? = null, + private val matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice? = null, + private val groupedTieredPackage: NewPlanGroupedTieredPackagePrice? = null, + private val maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice? = null, + private val scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice? = + null, + private val scalableMatrixWithTieredPricing: + NewPlanScalableMatrixWithTieredPricingPrice? = + null, + private val cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice? = null, + private val minimum: NewPlanMinimumCompositePrice? = null, + private val eventOutput: EventOutput? = null, + private val _json: JsonValue? = null, + ) { + + fun unit(): NewPlanUnitPrice? = unit + + fun tiered(): NewPlanTieredPrice? = tiered + + fun bulk(): NewPlanBulkPrice? = bulk + + fun package_(): NewPlanPackagePrice? = package_ + + fun matrix(): NewPlanMatrixPrice? = matrix + + fun thresholdTotalAmount(): NewPlanThresholdTotalAmountPrice? = thresholdTotalAmount + + fun tieredPackage(): NewPlanTieredPackagePrice? = tieredPackage + + fun tieredWithMinimum(): NewPlanTieredWithMinimumPrice? = tieredWithMinimum + + fun groupedTiered(): NewPlanGroupedTieredPrice? = groupedTiered + + fun tieredPackageWithMinimum(): NewPlanTieredPackageWithMinimumPrice? = + tieredPackageWithMinimum + + fun packageWithAllocation(): NewPlanPackageWithAllocationPrice? = packageWithAllocation + + fun unitWithPercent(): NewPlanUnitWithPercentPrice? = unitWithPercent + + fun matrixWithAllocation(): NewPlanMatrixWithAllocationPrice? = matrixWithAllocation + + fun tieredWithProration(): TieredWithProration? = tieredWithProration + + fun unitWithProration(): NewPlanUnitWithProrationPrice? = unitWithProration + + fun groupedAllocation(): NewPlanGroupedAllocationPrice? = groupedAllocation + + fun bulkWithProration(): NewPlanBulkWithProrationPrice? = bulkWithProration + + fun groupedWithProratedMinimum(): NewPlanGroupedWithProratedMinimumPrice? = + groupedWithProratedMinimum + + fun groupedWithMeteredMinimum(): NewPlanGroupedWithMeteredMinimumPrice? = + groupedWithMeteredMinimum + + fun groupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds? = + groupedWithMinMaxThresholds + + fun matrixWithDisplayName(): NewPlanMatrixWithDisplayNamePrice? = matrixWithDisplayName + + fun groupedTieredPackage(): NewPlanGroupedTieredPackagePrice? = groupedTieredPackage + + fun maxGroupTieredPackage(): NewPlanMaxGroupTieredPackagePrice? = maxGroupTieredPackage + + fun scalableMatrixWithUnitPricing(): NewPlanScalableMatrixWithUnitPricingPrice? = + scalableMatrixWithUnitPricing + + fun scalableMatrixWithTieredPricing(): NewPlanScalableMatrixWithTieredPricingPrice? = + scalableMatrixWithTieredPricing + + fun cumulativeGroupedBulk(): NewPlanCumulativeGroupedBulkPrice? = cumulativeGroupedBulk + + fun minimum(): NewPlanMinimumCompositePrice? = minimum + + fun eventOutput(): EventOutput? = eventOutput + + fun isUnit(): Boolean = unit != null + + fun isTiered(): Boolean = tiered != null + + fun isBulk(): Boolean = bulk != null + + fun isPackage(): Boolean = package_ != null + + fun isMatrix(): Boolean = matrix != null + + fun isThresholdTotalAmount(): Boolean = thresholdTotalAmount != null + + fun isTieredPackage(): Boolean = tieredPackage != null + + fun isTieredWithMinimum(): Boolean = tieredWithMinimum != null + + fun isGroupedTiered(): Boolean = groupedTiered != null + + fun isTieredPackageWithMinimum(): Boolean = tieredPackageWithMinimum != null + + fun isPackageWithAllocation(): Boolean = packageWithAllocation != null + + fun isUnitWithPercent(): Boolean = unitWithPercent != null + + fun isMatrixWithAllocation(): Boolean = matrixWithAllocation != null + + fun isTieredWithProration(): Boolean = tieredWithProration != null + + fun isUnitWithProration(): Boolean = unitWithProration != null + + fun isGroupedAllocation(): Boolean = groupedAllocation != null + + fun isBulkWithProration(): Boolean = bulkWithProration != null + + fun isGroupedWithProratedMinimum(): Boolean = groupedWithProratedMinimum != null + + fun isGroupedWithMeteredMinimum(): Boolean = groupedWithMeteredMinimum != null + + fun isGroupedWithMinMaxThresholds(): Boolean = groupedWithMinMaxThresholds != null + + fun isMatrixWithDisplayName(): Boolean = matrixWithDisplayName != null + + fun isGroupedTieredPackage(): Boolean = groupedTieredPackage != null + + fun isMaxGroupTieredPackage(): Boolean = maxGroupTieredPackage != null + + fun isScalableMatrixWithUnitPricing(): Boolean = scalableMatrixWithUnitPricing != null + + fun isScalableMatrixWithTieredPricing(): Boolean = + scalableMatrixWithTieredPricing != null + + fun isCumulativeGroupedBulk(): Boolean = cumulativeGroupedBulk != null + + fun isMinimum(): Boolean = minimum != null + + fun isEventOutput(): Boolean = eventOutput != null + + fun asUnit(): NewPlanUnitPrice = unit.getOrThrow("unit") + + fun asTiered(): NewPlanTieredPrice = tiered.getOrThrow("tiered") + + fun asBulk(): NewPlanBulkPrice = bulk.getOrThrow("bulk") + + fun asPackage(): NewPlanPackagePrice = package_.getOrThrow("package_") + + fun asMatrix(): NewPlanMatrixPrice = matrix.getOrThrow("matrix") + + fun asThresholdTotalAmount(): NewPlanThresholdTotalAmountPrice = + thresholdTotalAmount.getOrThrow("thresholdTotalAmount") + + fun asTieredPackage(): NewPlanTieredPackagePrice = + tieredPackage.getOrThrow("tieredPackage") + + fun asTieredWithMinimum(): NewPlanTieredWithMinimumPrice = + tieredWithMinimum.getOrThrow("tieredWithMinimum") + + fun asGroupedTiered(): NewPlanGroupedTieredPrice = + groupedTiered.getOrThrow("groupedTiered") + + fun asTieredPackageWithMinimum(): NewPlanTieredPackageWithMinimumPrice = + tieredPackageWithMinimum.getOrThrow("tieredPackageWithMinimum") + + fun asPackageWithAllocation(): NewPlanPackageWithAllocationPrice = + packageWithAllocation.getOrThrow("packageWithAllocation") + + fun asUnitWithPercent(): NewPlanUnitWithPercentPrice = + unitWithPercent.getOrThrow("unitWithPercent") + + fun asMatrixWithAllocation(): NewPlanMatrixWithAllocationPrice = + matrixWithAllocation.getOrThrow("matrixWithAllocation") + + fun asTieredWithProration(): TieredWithProration = + tieredWithProration.getOrThrow("tieredWithProration") + + fun asUnitWithProration(): NewPlanUnitWithProrationPrice = + unitWithProration.getOrThrow("unitWithProration") + + fun asGroupedAllocation(): NewPlanGroupedAllocationPrice = + groupedAllocation.getOrThrow("groupedAllocation") + + fun asBulkWithProration(): NewPlanBulkWithProrationPrice = + bulkWithProration.getOrThrow("bulkWithProration") + + fun asGroupedWithProratedMinimum(): NewPlanGroupedWithProratedMinimumPrice = + groupedWithProratedMinimum.getOrThrow("groupedWithProratedMinimum") + + fun asGroupedWithMeteredMinimum(): NewPlanGroupedWithMeteredMinimumPrice = + groupedWithMeteredMinimum.getOrThrow("groupedWithMeteredMinimum") + + fun asGroupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds = + groupedWithMinMaxThresholds.getOrThrow("groupedWithMinMaxThresholds") + + fun asMatrixWithDisplayName(): NewPlanMatrixWithDisplayNamePrice = + matrixWithDisplayName.getOrThrow("matrixWithDisplayName") + + fun asGroupedTieredPackage(): NewPlanGroupedTieredPackagePrice = + groupedTieredPackage.getOrThrow("groupedTieredPackage") + + fun asMaxGroupTieredPackage(): NewPlanMaxGroupTieredPackagePrice = + maxGroupTieredPackage.getOrThrow("maxGroupTieredPackage") + + fun asScalableMatrixWithUnitPricing(): NewPlanScalableMatrixWithUnitPricingPrice = + scalableMatrixWithUnitPricing.getOrThrow("scalableMatrixWithUnitPricing") + + fun asScalableMatrixWithTieredPricing(): NewPlanScalableMatrixWithTieredPricingPrice = + scalableMatrixWithTieredPricing.getOrThrow("scalableMatrixWithTieredPricing") + + fun asCumulativeGroupedBulk(): NewPlanCumulativeGroupedBulkPrice = + cumulativeGroupedBulk.getOrThrow("cumulativeGroupedBulk") + + fun asMinimum(): NewPlanMinimumCompositePrice = minimum.getOrThrow("minimum") + + fun asEventOutput(): EventOutput = eventOutput.getOrThrow("eventOutput") + + fun _json(): JsonValue? = _json + + fun accept(visitor: Visitor): T = + when { + unit != null -> visitor.visitUnit(unit) + tiered != null -> visitor.visitTiered(tiered) + bulk != null -> visitor.visitBulk(bulk) + package_ != null -> visitor.visitPackage(package_) + matrix != null -> visitor.visitMatrix(matrix) + thresholdTotalAmount != null -> + visitor.visitThresholdTotalAmount(thresholdTotalAmount) + tieredPackage != null -> visitor.visitTieredPackage(tieredPackage) + tieredWithMinimum != null -> visitor.visitTieredWithMinimum(tieredWithMinimum) + groupedTiered != null -> visitor.visitGroupedTiered(groupedTiered) + tieredPackageWithMinimum != null -> + visitor.visitTieredPackageWithMinimum(tieredPackageWithMinimum) + packageWithAllocation != null -> + visitor.visitPackageWithAllocation(packageWithAllocation) + unitWithPercent != null -> visitor.visitUnitWithPercent(unitWithPercent) + matrixWithAllocation != null -> + visitor.visitMatrixWithAllocation(matrixWithAllocation) + tieredWithProration != null -> + visitor.visitTieredWithProration(tieredWithProration) + unitWithProration != null -> visitor.visitUnitWithProration(unitWithProration) + groupedAllocation != null -> visitor.visitGroupedAllocation(groupedAllocation) + bulkWithProration != null -> visitor.visitBulkWithProration(bulkWithProration) + groupedWithProratedMinimum != null -> + visitor.visitGroupedWithProratedMinimum(groupedWithProratedMinimum) + groupedWithMeteredMinimum != null -> + visitor.visitGroupedWithMeteredMinimum(groupedWithMeteredMinimum) + groupedWithMinMaxThresholds != null -> + visitor.visitGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds) + matrixWithDisplayName != null -> + visitor.visitMatrixWithDisplayName(matrixWithDisplayName) + groupedTieredPackage != null -> + visitor.visitGroupedTieredPackage(groupedTieredPackage) + maxGroupTieredPackage != null -> + visitor.visitMaxGroupTieredPackage(maxGroupTieredPackage) + scalableMatrixWithUnitPricing != null -> + visitor.visitScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing) + scalableMatrixWithTieredPricing != null -> + visitor.visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing + ) + cumulativeGroupedBulk != null -> + visitor.visitCumulativeGroupedBulk(cumulativeGroupedBulk) + minimum != null -> visitor.visitMinimum(minimum) + eventOutput != null -> visitor.visitEventOutput(eventOutput) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Price = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitUnit(unit: NewPlanUnitPrice) { + unit.validate() + } + + override fun visitTiered(tiered: NewPlanTieredPrice) { + tiered.validate() + } + + override fun visitBulk(bulk: NewPlanBulkPrice) { + bulk.validate() + } + + override fun visitPackage(package_: NewPlanPackagePrice) { + package_.validate() + } + + override fun visitMatrix(matrix: NewPlanMatrixPrice) { + matrix.validate() + } + + override fun visitThresholdTotalAmount( + thresholdTotalAmount: NewPlanThresholdTotalAmountPrice + ) { + thresholdTotalAmount.validate() + } + + override fun visitTieredPackage(tieredPackage: NewPlanTieredPackagePrice) { + tieredPackage.validate() + } + + override fun visitTieredWithMinimum( + tieredWithMinimum: NewPlanTieredWithMinimumPrice + ) { + tieredWithMinimum.validate() + } + + override fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) { + groupedTiered.validate() + } + + override fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice + ) { + tieredPackageWithMinimum.validate() + } + + override fun visitPackageWithAllocation( + packageWithAllocation: NewPlanPackageWithAllocationPrice + ) { + packageWithAllocation.validate() + } + + override fun visitUnitWithPercent( + unitWithPercent: NewPlanUnitWithPercentPrice + ) { + unitWithPercent.validate() + } + + override fun visitMatrixWithAllocation( + matrixWithAllocation: NewPlanMatrixWithAllocationPrice + ) { + matrixWithAllocation.validate() + } + + override fun visitTieredWithProration( + tieredWithProration: TieredWithProration + ) { + tieredWithProration.validate() + } + + override fun visitUnitWithProration( + unitWithProration: NewPlanUnitWithProrationPrice + ) { + unitWithProration.validate() + } + + override fun visitGroupedAllocation( + groupedAllocation: NewPlanGroupedAllocationPrice + ) { + groupedAllocation.validate() + } + + override fun visitBulkWithProration( + bulkWithProration: NewPlanBulkWithProrationPrice + ) { + bulkWithProration.validate() + } + + override fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice + ) { + groupedWithProratedMinimum.validate() + } + + override fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice + ) { + groupedWithMeteredMinimum.validate() + } + + override fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) { + groupedWithMinMaxThresholds.validate() + } + + override fun visitMatrixWithDisplayName( + matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice + ) { + matrixWithDisplayName.validate() + } + + override fun visitGroupedTieredPackage( + groupedTieredPackage: NewPlanGroupedTieredPackagePrice + ) { + groupedTieredPackage.validate() + } + + override fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice + ) { + maxGroupTieredPackage.validate() + } + + override fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice + ) { + scalableMatrixWithUnitPricing.validate() + } + + override fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: + NewPlanScalableMatrixWithTieredPricingPrice + ) { + scalableMatrixWithTieredPricing.validate() + } + + override fun visitCumulativeGroupedBulk( + cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice + ) { + cumulativeGroupedBulk.validate() + } + + override fun visitMinimum(minimum: NewPlanMinimumCompositePrice) { + minimum.validate() + } + + override fun visitEventOutput(eventOutput: EventOutput) { + eventOutput.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitUnit(unit: NewPlanUnitPrice) = unit.validity() + + override fun visitTiered(tiered: NewPlanTieredPrice) = tiered.validity() + + override fun visitBulk(bulk: NewPlanBulkPrice) = bulk.validity() + + override fun visitPackage(package_: NewPlanPackagePrice) = + package_.validity() + + override fun visitMatrix(matrix: NewPlanMatrixPrice) = matrix.validity() + + override fun visitThresholdTotalAmount( + thresholdTotalAmount: NewPlanThresholdTotalAmountPrice + ) = thresholdTotalAmount.validity() + + override fun visitTieredPackage(tieredPackage: NewPlanTieredPackagePrice) = + tieredPackage.validity() + + override fun visitTieredWithMinimum( + tieredWithMinimum: NewPlanTieredWithMinimumPrice + ) = tieredWithMinimum.validity() + + override fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) = + groupedTiered.validity() + + override fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice + ) = tieredPackageWithMinimum.validity() + + override fun visitPackageWithAllocation( + packageWithAllocation: NewPlanPackageWithAllocationPrice + ) = packageWithAllocation.validity() + + override fun visitUnitWithPercent( + unitWithPercent: NewPlanUnitWithPercentPrice + ) = unitWithPercent.validity() + + override fun visitMatrixWithAllocation( + matrixWithAllocation: NewPlanMatrixWithAllocationPrice + ) = matrixWithAllocation.validity() + + override fun visitTieredWithProration( + tieredWithProration: TieredWithProration + ) = tieredWithProration.validity() + + override fun visitUnitWithProration( + unitWithProration: NewPlanUnitWithProrationPrice + ) = unitWithProration.validity() + + override fun visitGroupedAllocation( + groupedAllocation: NewPlanGroupedAllocationPrice + ) = groupedAllocation.validity() + + override fun visitBulkWithProration( + bulkWithProration: NewPlanBulkWithProrationPrice + ) = bulkWithProration.validity() + + override fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice + ) = groupedWithProratedMinimum.validity() + + override fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice + ) = groupedWithMeteredMinimum.validity() + + override fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) = groupedWithMinMaxThresholds.validity() + + override fun visitMatrixWithDisplayName( + matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice + ) = matrixWithDisplayName.validity() + + override fun visitGroupedTieredPackage( + groupedTieredPackage: NewPlanGroupedTieredPackagePrice + ) = groupedTieredPackage.validity() + + override fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice + ) = maxGroupTieredPackage.validity() + + override fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice + ) = scalableMatrixWithUnitPricing.validity() + + override fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: + NewPlanScalableMatrixWithTieredPricingPrice + ) = scalableMatrixWithTieredPricing.validity() + + override fun visitCumulativeGroupedBulk( + cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice + ) = cumulativeGroupedBulk.validity() + + override fun visitMinimum(minimum: NewPlanMinimumCompositePrice) = + minimum.validity() + + override fun visitEventOutput(eventOutput: EventOutput) = + eventOutput.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Price && + unit == other.unit && + tiered == other.tiered && + bulk == other.bulk && + package_ == other.package_ && + matrix == other.matrix && + thresholdTotalAmount == other.thresholdTotalAmount && + tieredPackage == other.tieredPackage && + tieredWithMinimum == other.tieredWithMinimum && + groupedTiered == other.groupedTiered && + tieredPackageWithMinimum == other.tieredPackageWithMinimum && + packageWithAllocation == other.packageWithAllocation && + unitWithPercent == other.unitWithPercent && + matrixWithAllocation == other.matrixWithAllocation && + tieredWithProration == other.tieredWithProration && + unitWithProration == other.unitWithProration && + groupedAllocation == other.groupedAllocation && + bulkWithProration == other.bulkWithProration && + groupedWithProratedMinimum == other.groupedWithProratedMinimum && + groupedWithMeteredMinimum == other.groupedWithMeteredMinimum && + groupedWithMinMaxThresholds == other.groupedWithMinMaxThresholds && + matrixWithDisplayName == other.matrixWithDisplayName && + groupedTieredPackage == other.groupedTieredPackage && + maxGroupTieredPackage == other.maxGroupTieredPackage && + scalableMatrixWithUnitPricing == other.scalableMatrixWithUnitPricing && + scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && + cumulativeGroupedBulk == other.cumulativeGroupedBulk && + minimum == other.minimum && + eventOutput == other.eventOutput + } + + override fun hashCode(): Int = + Objects.hash( + unit, + tiered, + bulk, + package_, + matrix, + thresholdTotalAmount, + tieredPackage, + tieredWithMinimum, + groupedTiered, + tieredPackageWithMinimum, + packageWithAllocation, + unitWithPercent, + matrixWithAllocation, + tieredWithProration, + unitWithProration, + groupedAllocation, + bulkWithProration, + groupedWithProratedMinimum, + groupedWithMeteredMinimum, + groupedWithMinMaxThresholds, + matrixWithDisplayName, + groupedTieredPackage, + maxGroupTieredPackage, + scalableMatrixWithUnitPricing, + scalableMatrixWithTieredPricing, + cumulativeGroupedBulk, + minimum, + eventOutput, + ) + + override fun toString(): String = + when { + unit != null -> "Price{unit=$unit}" + tiered != null -> "Price{tiered=$tiered}" + bulk != null -> "Price{bulk=$bulk}" + package_ != null -> "Price{package_=$package_}" + matrix != null -> "Price{matrix=$matrix}" + thresholdTotalAmount != null -> + "Price{thresholdTotalAmount=$thresholdTotalAmount}" + tieredPackage != null -> "Price{tieredPackage=$tieredPackage}" + tieredWithMinimum != null -> "Price{tieredWithMinimum=$tieredWithMinimum}" + groupedTiered != null -> "Price{groupedTiered=$groupedTiered}" + tieredPackageWithMinimum != null -> + "Price{tieredPackageWithMinimum=$tieredPackageWithMinimum}" + packageWithAllocation != null -> + "Price{packageWithAllocation=$packageWithAllocation}" + unitWithPercent != null -> "Price{unitWithPercent=$unitWithPercent}" + matrixWithAllocation != null -> + "Price{matrixWithAllocation=$matrixWithAllocation}" + tieredWithProration != null -> "Price{tieredWithProration=$tieredWithProration}" + unitWithProration != null -> "Price{unitWithProration=$unitWithProration}" + groupedAllocation != null -> "Price{groupedAllocation=$groupedAllocation}" + bulkWithProration != null -> "Price{bulkWithProration=$bulkWithProration}" + groupedWithProratedMinimum != null -> + "Price{groupedWithProratedMinimum=$groupedWithProratedMinimum}" + groupedWithMeteredMinimum != null -> + "Price{groupedWithMeteredMinimum=$groupedWithMeteredMinimum}" + groupedWithMinMaxThresholds != null -> + "Price{groupedWithMinMaxThresholds=$groupedWithMinMaxThresholds}" + matrixWithDisplayName != null -> + "Price{matrixWithDisplayName=$matrixWithDisplayName}" + groupedTieredPackage != null -> + "Price{groupedTieredPackage=$groupedTieredPackage}" + maxGroupTieredPackage != null -> + "Price{maxGroupTieredPackage=$maxGroupTieredPackage}" + scalableMatrixWithUnitPricing != null -> + "Price{scalableMatrixWithUnitPricing=$scalableMatrixWithUnitPricing}" + scalableMatrixWithTieredPricing != null -> + "Price{scalableMatrixWithTieredPricing=$scalableMatrixWithTieredPricing}" + cumulativeGroupedBulk != null -> + "Price{cumulativeGroupedBulk=$cumulativeGroupedBulk}" + minimum != null -> "Price{minimum=$minimum}" + eventOutput != null -> "Price{eventOutput=$eventOutput}" + _json != null -> "Price{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Price") + } + + companion object { + + fun ofUnit(unit: NewPlanUnitPrice) = Price(unit = unit) + + fun ofTiered(tiered: NewPlanTieredPrice) = Price(tiered = tiered) + + fun ofBulk(bulk: NewPlanBulkPrice) = Price(bulk = bulk) + + fun ofPackage(package_: NewPlanPackagePrice) = Price(package_ = package_) + + fun ofMatrix(matrix: NewPlanMatrixPrice) = Price(matrix = matrix) + + fun ofThresholdTotalAmount(thresholdTotalAmount: NewPlanThresholdTotalAmountPrice) = + Price(thresholdTotalAmount = thresholdTotalAmount) + + fun ofTieredPackage(tieredPackage: NewPlanTieredPackagePrice) = + Price(tieredPackage = tieredPackage) + + fun ofTieredWithMinimum(tieredWithMinimum: NewPlanTieredWithMinimumPrice) = + Price(tieredWithMinimum = tieredWithMinimum) + + fun ofGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) = + Price(groupedTiered = groupedTiered) + + fun ofTieredPackageWithMinimum( + tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice + ) = Price(tieredPackageWithMinimum = tieredPackageWithMinimum) + + fun ofPackageWithAllocation( + packageWithAllocation: NewPlanPackageWithAllocationPrice + ) = Price(packageWithAllocation = packageWithAllocation) + + fun ofUnitWithPercent(unitWithPercent: NewPlanUnitWithPercentPrice) = + Price(unitWithPercent = unitWithPercent) + + fun ofMatrixWithAllocation(matrixWithAllocation: NewPlanMatrixWithAllocationPrice) = + Price(matrixWithAllocation = matrixWithAllocation) + + fun ofTieredWithProration(tieredWithProration: TieredWithProration) = + Price(tieredWithProration = tieredWithProration) + + fun ofUnitWithProration(unitWithProration: NewPlanUnitWithProrationPrice) = + Price(unitWithProration = unitWithProration) + + fun ofGroupedAllocation(groupedAllocation: NewPlanGroupedAllocationPrice) = + Price(groupedAllocation = groupedAllocation) + + fun ofBulkWithProration(bulkWithProration: NewPlanBulkWithProrationPrice) = + Price(bulkWithProration = bulkWithProration) + + fun ofGroupedWithProratedMinimum( + groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice + ) = Price(groupedWithProratedMinimum = groupedWithProratedMinimum) + + fun ofGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice + ) = Price(groupedWithMeteredMinimum = groupedWithMeteredMinimum) + + fun ofGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) = Price(groupedWithMinMaxThresholds = groupedWithMinMaxThresholds) + + fun ofMatrixWithDisplayName( + matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice + ) = Price(matrixWithDisplayName = matrixWithDisplayName) + + fun ofGroupedTieredPackage(groupedTieredPackage: NewPlanGroupedTieredPackagePrice) = + Price(groupedTieredPackage = groupedTieredPackage) + + fun ofMaxGroupTieredPackage( + maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice + ) = Price(maxGroupTieredPackage = maxGroupTieredPackage) + + fun ofScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice + ) = Price(scalableMatrixWithUnitPricing = scalableMatrixWithUnitPricing) + + fun ofScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: NewPlanScalableMatrixWithTieredPricingPrice + ) = Price(scalableMatrixWithTieredPricing = scalableMatrixWithTieredPricing) + + fun ofCumulativeGroupedBulk( + cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice + ) = Price(cumulativeGroupedBulk = cumulativeGroupedBulk) + + fun ofMinimum(minimum: NewPlanMinimumCompositePrice) = Price(minimum = minimum) + + fun ofEventOutput(eventOutput: EventOutput) = Price(eventOutput = eventOutput) + } + + /** + * An interface that defines how to map each variant of [Price] to a value of type [T]. + */ + interface Visitor { + + fun visitUnit(unit: NewPlanUnitPrice): T + + fun visitTiered(tiered: NewPlanTieredPrice): T + + fun visitBulk(bulk: NewPlanBulkPrice): T + + fun visitPackage(package_: NewPlanPackagePrice): T + + fun visitMatrix(matrix: NewPlanMatrixPrice): T + + fun visitThresholdTotalAmount( + thresholdTotalAmount: NewPlanThresholdTotalAmountPrice + ): T + + fun visitTieredPackage(tieredPackage: NewPlanTieredPackagePrice): T + + fun visitTieredWithMinimum(tieredWithMinimum: NewPlanTieredWithMinimumPrice): T + + fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice): T + + fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice + ): T + + fun visitPackageWithAllocation( + packageWithAllocation: NewPlanPackageWithAllocationPrice + ): T + + fun visitUnitWithPercent(unitWithPercent: NewPlanUnitWithPercentPrice): T + + fun visitMatrixWithAllocation( + matrixWithAllocation: NewPlanMatrixWithAllocationPrice + ): T + + fun visitTieredWithProration(tieredWithProration: TieredWithProration): T + + fun visitUnitWithProration(unitWithProration: NewPlanUnitWithProrationPrice): T + + fun visitGroupedAllocation(groupedAllocation: NewPlanGroupedAllocationPrice): T + + fun visitBulkWithProration(bulkWithProration: NewPlanBulkWithProrationPrice): T + + fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice + ): T + + fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice + ): T + + fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ): T + + fun visitMatrixWithDisplayName( + matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice + ): T + + fun visitGroupedTieredPackage( + groupedTieredPackage: NewPlanGroupedTieredPackagePrice + ): T + + fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice + ): T + + fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice + ): T + + fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: NewPlanScalableMatrixWithTieredPricingPrice + ): T + + fun visitCumulativeGroupedBulk( + cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice + ): T + + fun visitMinimum(minimum: NewPlanMinimumCompositePrice): T + + fun visitEventOutput(eventOutput: EventOutput): T + + /** + * Maps an unknown variant of [Price] to a value of type [T]. + * + * An instance of [Price] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is + * unaware of. + * + * @throws OrbInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw OrbInvalidDataException("Unknown Price: $json") + } + } + + internal class Deserializer : BaseDeserializer(Price::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Price { + val json = JsonValue.fromJsonNode(node) + val modelType = json.asObject()?.get("model_type")?.asString() + + when (modelType) { + "unit" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(unit = it, _json = json) + } ?: Price(_json = json) + } + "tiered" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(tiered = it, _json = json) + } ?: Price(_json = json) + } + "bulk" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(bulk = it, _json = json) + } ?: Price(_json = json) + } + "package" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(package_ = it, _json = json) } ?: Price(_json = json) + } + "matrix" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(matrix = it, _json = json) + } ?: Price(_json = json) + } + "threshold_total_amount" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(thresholdTotalAmount = it, _json = json) } + ?: Price(_json = json) + } + "tiered_package" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(tieredPackage = it, _json = json) } + ?: Price(_json = json) + } + "tiered_with_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(tieredWithMinimum = it, _json = json) } + ?: Price(_json = json) + } + "grouped_tiered" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(groupedTiered = it, _json = json) } + ?: Price(_json = json) + } + "tiered_package_with_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(tieredPackageWithMinimum = it, _json = json) } + ?: Price(_json = json) + } + "package_with_allocation" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(packageWithAllocation = it, _json = json) } + ?: Price(_json = json) + } + "unit_with_percent" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(unitWithPercent = it, _json = json) } + ?: Price(_json = json) + } + "matrix_with_allocation" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(matrixWithAllocation = it, _json = json) } + ?: Price(_json = json) + } + "tiered_with_proration" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(tieredWithProration = it, _json = json) } + ?: Price(_json = json) + } + "unit_with_proration" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(unitWithProration = it, _json = json) } + ?: Price(_json = json) + } + "grouped_allocation" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedAllocation = it, _json = json) } + ?: Price(_json = json) + } + "bulk_with_proration" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(bulkWithProration = it, _json = json) } + ?: Price(_json = json) + } + "grouped_with_prorated_minimum" -> { + return tryDeserialize( + node, jacksonTypeRef(), ) - ?.let { Price(groupedWithProratedMinimum = it, _json = json) } - ?: Price(_json = json) + ?.let { Price(groupedWithProratedMinimum = it, _json = json) } + ?: Price(_json = json) + } + "grouped_with_metered_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedWithMeteredMinimum = it, _json = json) } + ?: Price(_json = json) + } + "grouped_with_min_max_thresholds" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedWithMinMaxThresholds = it, _json = json) } + ?: Price(_json = json) + } + "matrix_with_display_name" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(matrixWithDisplayName = it, _json = json) } + ?: Price(_json = json) + } + "grouped_tiered_package" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedTieredPackage = it, _json = json) } + ?: Price(_json = json) + } + "max_group_tiered_package" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(maxGroupTieredPackage = it, _json = json) } + ?: Price(_json = json) + } + "scalable_matrix_with_unit_pricing" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(scalableMatrixWithUnitPricing = it, _json = json) } + ?: Price(_json = json) + } + "scalable_matrix_with_tiered_pricing" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(scalableMatrixWithTieredPricing = it, _json = json) } + ?: Price(_json = json) + } + "cumulative_grouped_bulk" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(cumulativeGroupedBulk = it, _json = json) } + ?: Price(_json = json) + } + "minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(minimum = it, _json = json) } ?: Price(_json = json) + } + "event_output" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(eventOutput = it, _json = json) + } ?: Price(_json = json) + } + } + + return Price(_json = json) + } + } + + internal class Serializer : BaseSerializer(Price::class) { + + override fun serialize( + value: Price, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.unit != null -> generator.writeObject(value.unit) + value.tiered != null -> generator.writeObject(value.tiered) + value.bulk != null -> generator.writeObject(value.bulk) + value.package_ != null -> generator.writeObject(value.package_) + value.matrix != null -> generator.writeObject(value.matrix) + value.thresholdTotalAmount != null -> + generator.writeObject(value.thresholdTotalAmount) + value.tieredPackage != null -> generator.writeObject(value.tieredPackage) + value.tieredWithMinimum != null -> + generator.writeObject(value.tieredWithMinimum) + value.groupedTiered != null -> generator.writeObject(value.groupedTiered) + value.tieredPackageWithMinimum != null -> + generator.writeObject(value.tieredPackageWithMinimum) + value.packageWithAllocation != null -> + generator.writeObject(value.packageWithAllocation) + value.unitWithPercent != null -> + generator.writeObject(value.unitWithPercent) + value.matrixWithAllocation != null -> + generator.writeObject(value.matrixWithAllocation) + value.tieredWithProration != null -> + generator.writeObject(value.tieredWithProration) + value.unitWithProration != null -> + generator.writeObject(value.unitWithProration) + value.groupedAllocation != null -> + generator.writeObject(value.groupedAllocation) + value.bulkWithProration != null -> + generator.writeObject(value.bulkWithProration) + value.groupedWithProratedMinimum != null -> + generator.writeObject(value.groupedWithProratedMinimum) + value.groupedWithMeteredMinimum != null -> + generator.writeObject(value.groupedWithMeteredMinimum) + value.groupedWithMinMaxThresholds != null -> + generator.writeObject(value.groupedWithMinMaxThresholds) + value.matrixWithDisplayName != null -> + generator.writeObject(value.matrixWithDisplayName) + value.groupedTieredPackage != null -> + generator.writeObject(value.groupedTieredPackage) + value.maxGroupTieredPackage != null -> + generator.writeObject(value.maxGroupTieredPackage) + value.scalableMatrixWithUnitPricing != null -> + generator.writeObject(value.scalableMatrixWithUnitPricing) + value.scalableMatrixWithTieredPricing != null -> + generator.writeObject(value.scalableMatrixWithTieredPricing) + value.cumulativeGroupedBulk != null -> + generator.writeObject(value.cumulativeGroupedBulk) + value.minimum != null -> generator.writeObject(value.minimum) + value.eventOutput != null -> generator.writeObject(value.eventOutput) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Price") + } + } + } + + class TieredWithProration + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val tieredWithProrationConfig: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("tiered_with_proration_config") + @ExcludeMissing + tieredWithProrationConfig: JsonField = + JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + modelType, + name, + tieredWithProrationConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("tiered_with_proration") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * Configuration for tiered_with_proration pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun tieredWithProrationConfig(): TieredWithProrationConfig = + tieredWithProrationConfig.getRequired("tiered_with_proration_config") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = billableMetricId.getNullable("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + invoiceGroupingKey.getNullable("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [tieredWithProrationConfig]. + * + * Unlike [tieredWithProrationConfig], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("tiered_with_proration_config") + @ExcludeMissing + fun _tieredWithProrationConfig(): JsonField = + tieredWithProrationConfig + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [TieredWithProration]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .name() + * .tieredWithProrationConfig() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [TieredWithProration]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonValue = JsonValue.from("tiered_with_proration") + private var name: JsonField? = null + private var tieredWithProrationConfig: JsonField? = + null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(tieredWithProration: TieredWithProration) = apply { + cadence = tieredWithProration.cadence + itemId = tieredWithProration.itemId + modelType = tieredWithProration.modelType + name = tieredWithProration.name + tieredWithProrationConfig = tieredWithProration.tieredWithProrationConfig + billableMetricId = tieredWithProration.billableMetricId + billedInAdvance = tieredWithProration.billedInAdvance + billingCycleConfiguration = tieredWithProration.billingCycleConfiguration + conversionRate = tieredWithProration.conversionRate + conversionRateConfig = tieredWithProration.conversionRateConfig + currency = tieredWithProration.currency + dimensionalPriceConfiguration = + tieredWithProration.dimensionalPriceConfiguration + externalPriceId = tieredWithProration.externalPriceId + fixedPriceQuantity = tieredWithProration.fixedPriceQuantity + invoiceGroupingKey = tieredWithProration.invoiceGroupingKey + invoicingCycleConfiguration = + tieredWithProration.invoicingCycleConfiguration + metadata = tieredWithProration.metadata + referenceId = tieredWithProration.referenceId + additionalProperties = + tieredWithProration.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("tiered_with_proration") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for tiered_with_proration pricing */ + fun tieredWithProrationConfig( + tieredWithProrationConfig: TieredWithProrationConfig + ) = tieredWithProrationConfig(JsonField.of(tieredWithProrationConfig)) + + /** + * Sets [Builder.tieredWithProrationConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.tieredWithProrationConfig] with a well-typed + * [TieredWithProrationConfig] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun tieredWithProrationConfig( + tieredWithProrationConfig: JsonField + ) = apply { this.tieredWithProrationConfig = tieredWithProrationConfig } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [TieredWithProration]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .name() + * .tieredWithProrationConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TieredWithProration = + TieredWithProration( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + modelType, + checkRequired("name", name), + checkRequired("tieredWithProrationConfig", tieredWithProrationConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TieredWithProration = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + _modelType().let { + if (it != JsonValue.from("tiered_with_proration")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + tieredWithProrationConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + modelType.let { + if (it == JsonValue.from("tiered_with_proration")) 1 else 0 + } + + (if (name.asKnown() == null) 0 else 1) + + (tieredWithProrationConfig.asKnown()?.validity() ?: 0) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Configuration for tiered_with_proration pricing */ + class TieredWithProrationConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val tiers: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of() + ) : this(tiers, mutableMapOf()) + + /** + * Tiers for rating based on total usage quantities into the specified tier with + * proration + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun tiers(): List = tiers.getRequired("tiers") + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [TieredWithProrationConfig]. + * + * The following fields are required: + * ```kotlin + * .tiers() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [TieredWithProrationConfig]. */ + class Builder internal constructor() { + + private var tiers: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(tieredWithProrationConfig: TieredWithProrationConfig) = + apply { + tiers = tieredWithProrationConfig.tiers.map { it.toMutableList() } + additionalProperties = + tieredWithProrationConfig.additionalProperties.toMutableMap() + } + + /** + * Tiers for rating based on total usage quantities into the specified tier + * with proration + */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [TieredWithProrationConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TieredWithProrationConfig = + TieredWithProrationConfig( + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TieredWithProrationConfig = apply { + if (validated) { + return@apply + } + + tiers().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (tiers.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single tiered with proration tier */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val tierLowerBound: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(tierLowerBound, unitAmount, mutableMapOf()) + + /** + * Inclusive tier starting value + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun tierLowerBound(): String = + tierLowerBound.getRequired("tier_lower_bound") + + /** + * Amount per unit + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Tier]. + * + * The following fields are required: + * ```kotlin + * .tierLowerBound() + * .unitAmount() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var tierLowerBound: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(tier: Tier) = apply { + tierLowerBound = tier.tierLowerBound + unitAmount = tier.unitAmount + additionalProperties = tier.additionalProperties.toMutableMap() + } + + /** Inclusive tier starting value */ + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + /** Amount per unit */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```kotlin + * .tierLowerBound() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("tierLowerBound", tierLowerBound), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) } - "grouped_with_metered_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedWithMeteredMinimum = it, _json = json) } - ?: Price(_json = json) + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + tierLowerBound() + unitAmount() + validated = true } - "grouped_with_min_max_thresholds" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedWithMinMaxThresholds = it, _json = json) } - ?: Price(_json = json) + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (tierLowerBound.asKnown() == null) 0 else 1) + + (if (unitAmount.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + tierLowerBound == other.tierLowerBound && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties } - "matrix_with_display_name" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(matrixWithDisplayName = it, _json = json) } - ?: Price(_json = json) + + private val hashCode: Int by lazy { + Objects.hash(tierLowerBound, unitAmount, additionalProperties) } - "grouped_tiered_package" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedTieredPackage = it, _json = json) } - ?: Price(_json = json) + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - "max_group_tiered_package" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(maxGroupTieredPackage = it, _json = json) } - ?: Price(_json = json) + + return other is TieredWithProrationConfig && + tiers == other.tiers && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(tiers, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TieredWithProrationConfig{tiers=$tiers, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() } - "scalable_matrix_with_unit_pricing" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(scalableMatrixWithUnitPricing = it, _json = json) } - ?: Price(_json = json) + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) } - "scalable_matrix_with_tiered_pricing" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(scalableMatrixWithTieredPricing = it, _json = json) } - ?: Price(_json = json) + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) } - "cumulative_grouped_bulk" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(cumulativeGroupedBulk = it, _json = json) } - ?: Price(_json = json) + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) } - "minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(minimum = it, _json = json) } ?: Price(_json = json) + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties } - return Price(_json = json) - } - } + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode - internal class Serializer : BaseSerializer(Price::class) { + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } - override fun serialize( - value: Price, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unit != null -> generator.writeObject(value.unit) - value.tiered != null -> generator.writeObject(value.tiered) - value.bulk != null -> generator.writeObject(value.bulk) - value.package_ != null -> generator.writeObject(value.package_) - value.matrix != null -> generator.writeObject(value.matrix) - value.thresholdTotalAmount != null -> - generator.writeObject(value.thresholdTotalAmount) - value.tieredPackage != null -> generator.writeObject(value.tieredPackage) - value.tieredWithMinimum != null -> - generator.writeObject(value.tieredWithMinimum) - value.groupedTiered != null -> generator.writeObject(value.groupedTiered) - value.tieredPackageWithMinimum != null -> - generator.writeObject(value.tieredPackageWithMinimum) - value.packageWithAllocation != null -> - generator.writeObject(value.packageWithAllocation) - value.unitWithPercent != null -> - generator.writeObject(value.unitWithPercent) - value.matrixWithAllocation != null -> - generator.writeObject(value.matrixWithAllocation) - value.tieredWithProration != null -> - generator.writeObject(value.tieredWithProration) - value.unitWithProration != null -> - generator.writeObject(value.unitWithProration) - value.groupedAllocation != null -> - generator.writeObject(value.groupedAllocation) - value.bulkWithProration != null -> - generator.writeObject(value.bulkWithProration) - value.groupedWithProratedMinimum != null -> - generator.writeObject(value.groupedWithProratedMinimum) - value.groupedWithMeteredMinimum != null -> - generator.writeObject(value.groupedWithMeteredMinimum) - value.groupedWithMinMaxThresholds != null -> - generator.writeObject(value.groupedWithMinMaxThresholds) - value.matrixWithDisplayName != null -> - generator.writeObject(value.matrixWithDisplayName) - value.groupedTieredPackage != null -> - generator.writeObject(value.groupedTieredPackage) - value.maxGroupTieredPackage != null -> - generator.writeObject(value.maxGroupTieredPackage) - value.scalableMatrixWithUnitPricing != null -> - generator.writeObject(value.scalableMatrixWithUnitPricing) - value.scalableMatrixWithTieredPricing != null -> - generator.writeObject(value.scalableMatrixWithTieredPricing) - value.cumulativeGroupedBulk != null -> - generator.writeObject(value.cumulativeGroupedBulk) - value.minimum != null -> generator.writeObject(value.minimum) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Price") + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } + + return other is TieredWithProration && + cadence == other.cadence && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + tieredWithProrationConfig == other.tieredWithProrationConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + modelType, + name, + tieredWithProrationConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties, + ) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TieredWithProration{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredWithProrationConfig=$tieredWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class TieredWithProration + class GroupedWithMinMaxThresholds @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, + private val groupedWithMinMaxThresholdsConfig: + JsonField, private val itemId: JsonField, private val modelType: JsonValue, private val name: JsonField, - private val tieredWithProrationConfig: JsonField, private val billableMetricId: JsonField, private val billedInAdvance: JsonField, private val billingCycleConfiguration: JsonField, @@ -9248,6 +12648,11 @@ private constructor( @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), + @JsonProperty("grouped_with_min_max_thresholds_config") + @ExcludeMissing + groupedWithMinMaxThresholdsConfig: + JsonField = + JsonMissing.of(), @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), @@ -9257,10 +12662,6 @@ private constructor( @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("tiered_with_proration_config") - @ExcludeMissing - tieredWithProrationConfig: JsonField = - JsonMissing.of(), @JsonProperty("billable_metric_id") @ExcludeMissing billableMetricId: JsonField = JsonMissing.of(), @@ -9305,10 +12706,10 @@ private constructor( referenceId: JsonField = JsonMissing.of(), ) : this( cadence, + groupedWithMinMaxThresholdsConfig, itemId, modelType, name, - tieredWithProrationConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -9334,6 +12735,18 @@ private constructor( */ fun cadence(): Cadence = cadence.getRequired("cadence") + /** + * Configuration for grouped_with_min_max_thresholds pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupedWithMinMaxThresholdsConfig(): GroupedWithMinMaxThresholdsConfig = + groupedWithMinMaxThresholdsConfig.getRequired( + "grouped_with_min_max_thresholds_config" + ) + /** * The id of the item the price will be associated with. * @@ -9348,7 +12761,7 @@ private constructor( * * Expected to always return the following: * ```kotlin - * JsonValue.from("tiered_with_proration") + * JsonValue.from("grouped_with_min_max_thresholds") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -9365,16 +12778,6 @@ private constructor( */ fun name(): String = name.getRequired("name") - /** - * Configuration for tiered_with_proration pricing - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun tieredWithProrationConfig(): TieredWithProrationConfig = - tieredWithProrationConfig.getRequired("tiered_with_proration_config") - /** * The id of the billable metric for the price. Only needed if the price is * usage-based. @@ -9504,6 +12907,17 @@ private constructor( @ExcludeMissing fun _cadence(): JsonField = cadence + /** + * Returns the raw JSON value of [groupedWithMinMaxThresholdsConfig]. + * + * Unlike [groupedWithMinMaxThresholdsConfig], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("grouped_with_min_max_thresholds_config") + @ExcludeMissing + fun _groupedWithMinMaxThresholdsConfig(): + JsonField = groupedWithMinMaxThresholdsConfig + /** * Returns the raw JSON value of [itemId]. * @@ -9520,17 +12934,6 @@ private constructor( */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - /** - * Returns the raw JSON value of [tieredWithProrationConfig]. - * - * Unlike [tieredWithProrationConfig], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("tiered_with_proration_config") - @ExcludeMissing - fun _tieredWithProrationConfig(): JsonField = - tieredWithProrationConfig - /** * Returns the raw JSON value of [billableMetricId]. * @@ -9680,28 +13083,30 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [TieredWithProration]. + * [GroupedWithMinMaxThresholds]. * * The following fields are required: * ```kotlin * .cadence() + * .groupedWithMinMaxThresholdsConfig() * .itemId() * .name() - * .tieredWithProrationConfig() * ``` */ fun builder() = Builder() } - /** A builder for [TieredWithProration]. */ + /** A builder for [GroupedWithMinMaxThresholds]. */ class Builder internal constructor() { private var cadence: JsonField? = null + private var groupedWithMinMaxThresholdsConfig: + JsonField? = + null private var itemId: JsonField? = null - private var modelType: JsonValue = JsonValue.from("tiered_with_proration") + private var modelType: JsonValue = + JsonValue.from("grouped_with_min_max_thresholds") private var name: JsonField? = null - private var tieredWithProrationConfig: JsonField? = - null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() private var billingCycleConfiguration: JsonField = @@ -9723,30 +13128,33 @@ private constructor( private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(tieredWithProration: TieredWithProration) = apply { - cadence = tieredWithProration.cadence - itemId = tieredWithProration.itemId - modelType = tieredWithProration.modelType - name = tieredWithProration.name - tieredWithProrationConfig = tieredWithProration.tieredWithProrationConfig - billableMetricId = tieredWithProration.billableMetricId - billedInAdvance = tieredWithProration.billedInAdvance - billingCycleConfiguration = tieredWithProration.billingCycleConfiguration - conversionRate = tieredWithProration.conversionRate - conversionRateConfig = tieredWithProration.conversionRateConfig - currency = tieredWithProration.currency - dimensionalPriceConfiguration = - tieredWithProration.dimensionalPriceConfiguration - externalPriceId = tieredWithProration.externalPriceId - fixedPriceQuantity = tieredWithProration.fixedPriceQuantity - invoiceGroupingKey = tieredWithProration.invoiceGroupingKey - invoicingCycleConfiguration = - tieredWithProration.invoicingCycleConfiguration - metadata = tieredWithProration.metadata - referenceId = tieredWithProration.referenceId - additionalProperties = - tieredWithProration.additionalProperties.toMutableMap() - } + internal fun from(groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds) = + apply { + cadence = groupedWithMinMaxThresholds.cadence + groupedWithMinMaxThresholdsConfig = + groupedWithMinMaxThresholds.groupedWithMinMaxThresholdsConfig + itemId = groupedWithMinMaxThresholds.itemId + modelType = groupedWithMinMaxThresholds.modelType + name = groupedWithMinMaxThresholds.name + billableMetricId = groupedWithMinMaxThresholds.billableMetricId + billedInAdvance = groupedWithMinMaxThresholds.billedInAdvance + billingCycleConfiguration = + groupedWithMinMaxThresholds.billingCycleConfiguration + conversionRate = groupedWithMinMaxThresholds.conversionRate + conversionRateConfig = groupedWithMinMaxThresholds.conversionRateConfig + currency = groupedWithMinMaxThresholds.currency + dimensionalPriceConfiguration = + groupedWithMinMaxThresholds.dimensionalPriceConfiguration + externalPriceId = groupedWithMinMaxThresholds.externalPriceId + fixedPriceQuantity = groupedWithMinMaxThresholds.fixedPriceQuantity + invoiceGroupingKey = groupedWithMinMaxThresholds.invoiceGroupingKey + invoicingCycleConfiguration = + groupedWithMinMaxThresholds.invoicingCycleConfiguration + metadata = groupedWithMinMaxThresholds.metadata + referenceId = groupedWithMinMaxThresholds.referenceId + additionalProperties = + groupedWithMinMaxThresholds.additionalProperties.toMutableMap() + } /** The cadence to bill for this price on. */ fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) @@ -9758,7 +13166,30 @@ private constructor( * instead. This method is primarily for setting the field to an undocumented or * not yet supported value. */ - fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** Configuration for grouped_with_min_max_thresholds pricing */ + fun groupedWithMinMaxThresholdsConfig( + groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + ) = + groupedWithMinMaxThresholdsConfig( + JsonField.of(groupedWithMinMaxThresholdsConfig) + ) + + /** + * Sets [Builder.groupedWithMinMaxThresholdsConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.groupedWithMinMaxThresholdsConfig] with a + * well-typed [GroupedWithMinMaxThresholdsConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun groupedWithMinMaxThresholdsConfig( + groupedWithMinMaxThresholdsConfig: + JsonField + ) = apply { + this.groupedWithMinMaxThresholdsConfig = groupedWithMinMaxThresholdsConfig + } /** The id of the item the price will be associated with. */ fun itemId(itemId: String) = itemId(JsonField.of(itemId)) @@ -9778,7 +13209,7 @@ private constructor( * It is usually unnecessary to call this method because the field defaults to * the following: * ```kotlin - * JsonValue.from("tiered_with_proration") + * JsonValue.from("grouped_with_min_max_thresholds") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -9798,22 +13229,6 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } - /** Configuration for tiered_with_proration pricing */ - fun tieredWithProrationConfig( - tieredWithProrationConfig: TieredWithProrationConfig - ) = tieredWithProrationConfig(JsonField.of(tieredWithProrationConfig)) - - /** - * Sets [Builder.tieredWithProrationConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.tieredWithProrationConfig] with a well-typed - * [TieredWithProrationConfig] value instead. This method is primarily for - * setting the field to an undocumented or not yet supported value. - */ - fun tieredWithProrationConfig( - tieredWithProrationConfig: JsonField - ) = apply { this.tieredWithProrationConfig = tieredWithProrationConfig } - /** * The id of the billable metric for the price. Only needed if the price is * usage-based. @@ -10143,27 +13558,30 @@ private constructor( } /** - * Returns an immutable instance of [TieredWithProration]. + * Returns an immutable instance of [GroupedWithMinMaxThresholds]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```kotlin * .cadence() + * .groupedWithMinMaxThresholdsConfig() * .itemId() * .name() - * .tieredWithProrationConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): TieredWithProration = - TieredWithProration( + fun build(): GroupedWithMinMaxThresholds = + GroupedWithMinMaxThresholds( checkRequired("cadence", cadence), + checkRequired( + "groupedWithMinMaxThresholdsConfig", + groupedWithMinMaxThresholdsConfig, + ), checkRequired("itemId", itemId), modelType, checkRequired("name", name), - checkRequired("tieredWithProrationConfig", tieredWithProrationConfig), billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -10183,20 +13601,20 @@ private constructor( private var validated: Boolean = false - fun validate(): TieredWithProration = apply { + fun validate(): GroupedWithMinMaxThresholds = apply { if (validated) { return@apply } cadence().validate() + groupedWithMinMaxThresholdsConfig().validate() itemId() _modelType().let { - if (it != JsonValue.from("tiered_with_proration")) { + if (it != JsonValue.from("grouped_with_min_max_thresholds")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } name() - tieredWithProrationConfig().validate() billableMetricId() billedInAdvance() billingCycleConfiguration()?.validate() @@ -10229,12 +13647,12 @@ private constructor( */ internal fun validity(): Int = (cadence.asKnown()?.validity() ?: 0) + + (groupedWithMinMaxThresholdsConfig.asKnown()?.validity() ?: 0) + (if (itemId.asKnown() == null) 0 else 1) + modelType.let { - if (it == JsonValue.from("tiered_with_proration")) 1 else 0 + if (it == JsonValue.from("grouped_with_min_max_thresholds")) 1 else 0 } + (if (name.asKnown() == null) 0 else 1) + - (tieredWithProrationConfig.asKnown()?.validity() ?: 0) + (if (billableMetricId.asKnown() == null) 0 else 1) + (if (billedInAdvance.asKnown() == null) 0 else 1) + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + @@ -10346,220 +13764,34 @@ private constructor( when (this) { ANNUAL -> Known.ANNUAL SEMI_ANNUAL -> Known.SEMI_ANNUAL - MONTHLY -> Known.MONTHLY - QUARTERLY -> Known.QUARTERLY - ONE_TIME -> Known.ONE_TIME - CUSTOM -> Known.CUSTOM - else -> throw OrbInvalidDataException("Unknown Cadence: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString() - ?: throw OrbInvalidDataException("Value is not a String") - - private var validated: Boolean = false - - fun validate(): Cadence = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Cadence && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** Configuration for tiered_with_proration pricing */ - class TieredWithProrationConfig - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val tiers: JsonField>, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("tiers") - @ExcludeMissing - tiers: JsonField> = JsonMissing.of() - ) : this(tiers, mutableMapOf()) - - /** - * Tiers for rating based on total usage quantities into the specified tier with - * proration - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun tiers(): List = tiers.getRequired("tiers") - - /** - * Returns the raw JSON value of [tiers]. - * - * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("tiers") - @ExcludeMissing - fun _tiers(): JsonField> = tiers - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [TieredWithProrationConfig]. - * - * The following fields are required: - * ```kotlin - * .tiers() - * ``` - */ - fun builder() = Builder() - } - - /** A builder for [TieredWithProrationConfig]. */ - class Builder internal constructor() { - - private var tiers: JsonField>? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - internal fun from(tieredWithProrationConfig: TieredWithProrationConfig) = - apply { - tiers = tieredWithProrationConfig.tiers.map { it.toMutableList() } - additionalProperties = - tieredWithProrationConfig.additionalProperties.toMutableMap() - } - - /** - * Tiers for rating based on total usage quantities into the specified tier - * with proration - */ - fun tiers(tiers: List) = tiers(JsonField.of(tiers)) - - /** - * Sets [Builder.tiers] to an arbitrary JSON value. - * - * You should usually call [Builder.tiers] with a well-typed `List` - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun tiers(tiers: JsonField>) = apply { - this.tiers = tiers.map { it.toMutableList() } - } - - /** - * Adds a single [Tier] to [tiers]. - * - * @throws IllegalStateException if the field was previously set to a - * non-list. - */ - fun addTier(tier: Tier) = apply { - tiers = - (tiers ?: JsonField.of(mutableListOf())).also { - checkKnown("tiers", it).add(tier) - } - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [TieredWithProrationConfig]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```kotlin - * .tiers() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): TieredWithProrationConfig = - TieredWithProrationConfig( - checkRequired("tiers", tiers).map { it.toImmutable() }, - additionalProperties.toMutableMap(), - ) - } + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") private var validated: Boolean = false - fun validate(): TieredWithProrationConfig = apply { + fun validate(): Cadence = apply { if (validated) { return@apply } - tiers().forEach { it.validate() } + known() validated = true } @@ -10577,248 +13809,343 @@ private constructor( * * Used for best match union deserialization. */ - internal fun validity(): Int = - (tiers.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - /** Configuration for a single tiered with proration tier */ - class Tier - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val tierLowerBound: JsonField, - private val unitAmount: JsonField, - private val additionalProperties: MutableMap, - ) { + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - @JsonCreator - private constructor( - @JsonProperty("tier_lower_bound") - @ExcludeMissing - tierLowerBound: JsonField = JsonMissing.of(), - @JsonProperty("unit_amount") - @ExcludeMissing - unitAmount: JsonField = JsonMissing.of(), - ) : this(tierLowerBound, unitAmount, mutableMapOf()) + return other is Cadence && value == other.value + } - /** - * Inclusive tier starting value - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type - * or is unexpectedly missing or null (e.g. if the server responded with - * an unexpected value). - */ - fun tierLowerBound(): String = - tierLowerBound.getRequired("tier_lower_bound") + override fun hashCode() = value.hashCode() - /** - * Amount per unit - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type - * or is unexpectedly missing or null (e.g. if the server responded with - * an unexpected value). - */ - fun unitAmount(): String = unitAmount.getRequired("unit_amount") + override fun toString() = value.toString() + } - /** - * Returns the raw JSON value of [tierLowerBound]. - * - * Unlike [tierLowerBound], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("tier_lower_bound") - @ExcludeMissing - fun _tierLowerBound(): JsonField = tierLowerBound + /** Configuration for grouped_with_min_max_thresholds pricing */ + class GroupedWithMinMaxThresholdsConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val groupingKey: JsonField, + private val maximumCharge: JsonField, + private val minimumCharge: JsonField, + private val perUnitRate: JsonField, + private val additionalProperties: MutableMap, + ) { - /** - * Returns the raw JSON value of [unitAmount]. - * - * Unlike [unitAmount], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("unit_amount") + @JsonCreator + private constructor( + @JsonProperty("grouping_key") @ExcludeMissing - fun _unitAmount(): JsonField = unitAmount + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("maximum_charge") + @ExcludeMissing + maximumCharge: JsonField = JsonMissing.of(), + @JsonProperty("minimum_charge") + @ExcludeMissing + minimumCharge: JsonField = JsonMissing.of(), + @JsonProperty("per_unit_rate") + @ExcludeMissing + perUnitRate: JsonField = JsonMissing.of(), + ) : this(groupingKey, maximumCharge, minimumCharge, perUnitRate, mutableMapOf()) - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** + * The event property used to group before applying thresholds + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** + * The maximum amount to charge each group + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun maximumCharge(): String = maximumCharge.getRequired("maximum_charge") - fun toBuilder() = Builder().from(this) + /** + * The minimum amount to charge each group, regardless of usage + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun minimumCharge(): String = minimumCharge.getRequired("minimum_charge") - companion object { + /** + * The base price charged per group + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun perUnitRate(): String = perUnitRate.getRequired("per_unit_rate") - /** - * Returns a mutable builder for constructing an instance of [Tier]. - * - * The following fields are required: - * ```kotlin - * .tierLowerBound() - * .unitAmount() - * ``` - */ - fun builder() = Builder() - } + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey - /** A builder for [Tier]. */ - class Builder internal constructor() { + /** + * Returns the raw JSON value of [maximumCharge]. + * + * Unlike [maximumCharge], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("maximum_charge") + @ExcludeMissing + fun _maximumCharge(): JsonField = maximumCharge - private var tierLowerBound: JsonField? = null - private var unitAmount: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() + /** + * Returns the raw JSON value of [minimumCharge]. + * + * Unlike [minimumCharge], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("minimum_charge") + @ExcludeMissing + fun _minimumCharge(): JsonField = minimumCharge - internal fun from(tier: Tier) = apply { - tierLowerBound = tier.tierLowerBound - unitAmount = tier.unitAmount - additionalProperties = tier.additionalProperties.toMutableMap() - } + /** + * Returns the raw JSON value of [perUnitRate]. + * + * Unlike [perUnitRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("per_unit_rate") + @ExcludeMissing + fun _perUnitRate(): JsonField = perUnitRate + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [GroupedWithMinMaxThresholdsConfig]. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .maximumCharge() + * .minimumCharge() + * .perUnitRate() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [GroupedWithMinMaxThresholdsConfig]. */ + class Builder internal constructor() { + + private var groupingKey: JsonField? = null + private var maximumCharge: JsonField? = null + private var minimumCharge: JsonField? = null + private var perUnitRate: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from( + groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + ) = apply { + groupingKey = groupedWithMinMaxThresholdsConfig.groupingKey + maximumCharge = groupedWithMinMaxThresholdsConfig.maximumCharge + minimumCharge = groupedWithMinMaxThresholdsConfig.minimumCharge + perUnitRate = groupedWithMinMaxThresholdsConfig.perUnitRate + additionalProperties = + groupedWithMinMaxThresholdsConfig.additionalProperties + .toMutableMap() + } - /** Inclusive tier starting value */ - fun tierLowerBound(tierLowerBound: String) = - tierLowerBound(JsonField.of(tierLowerBound)) + /** The event property used to group before applying thresholds */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) - /** - * Sets [Builder.tierLowerBound] to an arbitrary JSON value. - * - * You should usually call [Builder.tierLowerBound] with a well-typed - * [String] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun tierLowerBound(tierLowerBound: JsonField) = apply { - this.tierLowerBound = tierLowerBound - } + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } - /** Amount per unit */ - fun unitAmount(unitAmount: String) = - unitAmount(JsonField.of(unitAmount)) + /** The maximum amount to charge each group */ + fun maximumCharge(maximumCharge: String) = + maximumCharge(JsonField.of(maximumCharge)) - /** - * Sets [Builder.unitAmount] to an arbitrary JSON value. - * - * You should usually call [Builder.unitAmount] with a well-typed - * [String] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun unitAmount(unitAmount: JsonField) = apply { - this.unitAmount = unitAmount - } + /** + * Sets [Builder.maximumCharge] to an arbitrary JSON value. + * + * You should usually call [Builder.maximumCharge] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun maximumCharge(maximumCharge: JsonField) = apply { + this.maximumCharge = maximumCharge + } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** The minimum amount to charge each group, regardless of usage */ + fun minimumCharge(minimumCharge: String) = + minimumCharge(JsonField.of(minimumCharge)) - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * Sets [Builder.minimumCharge] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumCharge] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun minimumCharge(minimumCharge: JsonField) = apply { + this.minimumCharge = minimumCharge + } - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + /** The base price charged per group */ + fun perUnitRate(perUnitRate: String) = + perUnitRate(JsonField.of(perUnitRate)) - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + /** + * Sets [Builder.perUnitRate] to an arbitrary JSON value. + * + * You should usually call [Builder.perUnitRate] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun perUnitRate(perUnitRate: JsonField) = apply { + this.perUnitRate = perUnitRate + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) } - /** - * Returns an immutable instance of [Tier]. - * - * Further updates to this [Builder] will not mutate the returned - * instance. - * - * The following fields are required: - * ```kotlin - * .tierLowerBound() - * .unitAmount() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Tier = - Tier( - checkRequired("tierLowerBound", tierLowerBound), - checkRequired("unitAmount", unitAmount), - additionalProperties.toMutableMap(), - ) + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) } - private var validated: Boolean = false - - fun validate(): Tier = apply { - if (validated) { - return@apply - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - tierLowerBound() - unitAmount() - validated = true + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } /** - * Returns a score indicating how many valid values are contained in this - * object recursively. + * Returns an immutable instance of [GroupedWithMinMaxThresholdsConfig]. * - * Used for best match union deserialization. + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .maximumCharge() + * .minimumCharge() + * .perUnitRate() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ - internal fun validity(): Int = - (if (tierLowerBound.asKnown() == null) 0 else 1) + - (if (unitAmount.asKnown() == null) 0 else 1) + fun build(): GroupedWithMinMaxThresholdsConfig = + GroupedWithMinMaxThresholdsConfig( + checkRequired("groupingKey", groupingKey), + checkRequired("maximumCharge", maximumCharge), + checkRequired("minimumCharge", minimumCharge), + checkRequired("perUnitRate", perUnitRate), + additionalProperties.toMutableMap(), + ) + } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + private var validated: Boolean = false - return other is Tier && - tierLowerBound == other.tierLowerBound && - unitAmount == other.unitAmount && - additionalProperties == other.additionalProperties + fun validate(): GroupedWithMinMaxThresholdsConfig = apply { + if (validated) { + return@apply } - private val hashCode: Int by lazy { - Objects.hash(tierLowerBound, unitAmount, additionalProperties) - } + groupingKey() + maximumCharge() + minimumCharge() + perUnitRate() + validated = true + } - override fun hashCode(): Int = hashCode + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - override fun toString() = - "Tier{tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" - } + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (groupingKey.asKnown() == null) 0 else 1) + + (if (maximumCharge.asKnown() == null) 0 else 1) + + (if (minimumCharge.asKnown() == null) 0 else 1) + + (if (perUnitRate.asKnown() == null) 0 else 1) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is TieredWithProrationConfig && - tiers == other.tiers && + return other is GroupedWithMinMaxThresholdsConfig && + groupingKey == other.groupingKey && + maximumCharge == other.maximumCharge && + minimumCharge == other.minimumCharge && + perUnitRate == other.perUnitRate && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(tiers, additionalProperties) } + private val hashCode: Int by lazy { + Objects.hash( + groupingKey, + maximumCharge, + minimumCharge, + perUnitRate, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode override fun toString() = - "TieredWithProrationConfig{tiers=$tiers, additionalProperties=$additionalProperties}" + "GroupedWithMinMaxThresholdsConfig{groupingKey=$groupingKey, maximumCharge=$maximumCharge, minimumCharge=$minimumCharge, perUnitRate=$perUnitRate, additionalProperties=$additionalProperties}" } /** @@ -10935,12 +14262,13 @@ private constructor( return true } - return other is TieredWithProration && + return other is GroupedWithMinMaxThresholds && cadence == other.cadence && + groupedWithMinMaxThresholdsConfig == + other.groupedWithMinMaxThresholdsConfig && itemId == other.itemId && modelType == other.modelType && name == other.name && - tieredWithProrationConfig == other.tieredWithProrationConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && @@ -10960,10 +14288,10 @@ private constructor( private val hashCode: Int by lazy { Objects.hash( cadence, + groupedWithMinMaxThresholdsConfig, itemId, modelType, name, - tieredWithProrationConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -10984,15 +14312,14 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "TieredWithProration{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredWithProrationConfig=$tieredWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "GroupedWithMinMaxThresholds{cadence=$cadence, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class GroupedWithMinMaxThresholds + class EventOutput @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, - private val groupedWithMinMaxThresholdsConfig: - JsonField, + private val eventOutputConfig: JsonField, private val itemId: JsonField, private val modelType: JsonValue, private val name: JsonField, @@ -11017,12 +14344,10 @@ private constructor( private constructor( @JsonProperty("cadence") @ExcludeMissing - cadence: JsonField = JsonMissing.of(), - @JsonProperty("grouped_with_min_max_thresholds_config") - @ExcludeMissing - groupedWithMinMaxThresholdsConfig: - JsonField = - JsonMissing.of(), + cadence: JsonField = JsonMissing.of(), + @JsonProperty("event_output_config") + @ExcludeMissing + eventOutputConfig: JsonField = JsonMissing.of(), @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), @@ -11076,7 +14401,7 @@ private constructor( referenceId: JsonField = JsonMissing.of(), ) : this( cadence, - groupedWithMinMaxThresholdsConfig, + eventOutputConfig, itemId, modelType, name, @@ -11106,16 +14431,14 @@ private constructor( fun cadence(): Cadence = cadence.getRequired("cadence") /** - * Configuration for grouped_with_min_max_thresholds pricing + * Configuration for event_output pricing * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected * value). */ - fun groupedWithMinMaxThresholdsConfig(): GroupedWithMinMaxThresholdsConfig = - groupedWithMinMaxThresholdsConfig.getRequired( - "grouped_with_min_max_thresholds_config" - ) + fun eventOutputConfig(): EventOutputConfig = + eventOutputConfig.getRequired("event_output_config") /** * The id of the item the price will be associated with. @@ -11131,7 +14454,7 @@ private constructor( * * Expected to always return the following: * ```kotlin - * JsonValue.from("grouped_with_min_max_thresholds") + * JsonValue.from("event_output") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -11278,15 +14601,14 @@ private constructor( fun _cadence(): JsonField = cadence /** - * Returns the raw JSON value of [groupedWithMinMaxThresholdsConfig]. + * Returns the raw JSON value of [eventOutputConfig]. * - * Unlike [groupedWithMinMaxThresholdsConfig], this method doesn't throw if the JSON - * field has an unexpected type. + * Unlike [eventOutputConfig], this method doesn't throw if the JSON field has an + * unexpected type. */ - @JsonProperty("grouped_with_min_max_thresholds_config") + @JsonProperty("event_output_config") @ExcludeMissing - fun _groupedWithMinMaxThresholdsConfig(): - JsonField = groupedWithMinMaxThresholdsConfig + fun _eventOutputConfig(): JsonField = eventOutputConfig /** * Returns the raw JSON value of [itemId]. @@ -11452,13 +14774,12 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [GroupedWithMinMaxThresholds]. + * Returns a mutable builder for constructing an instance of [EventOutput]. * * The following fields are required: * ```kotlin * .cadence() - * .groupedWithMinMaxThresholdsConfig() + * .eventOutputConfig() * .itemId() * .name() * ``` @@ -11466,16 +14787,13 @@ private constructor( fun builder() = Builder() } - /** A builder for [GroupedWithMinMaxThresholds]. */ + /** A builder for [EventOutput]. */ class Builder internal constructor() { private var cadence: JsonField? = null - private var groupedWithMinMaxThresholdsConfig: - JsonField? = - null + private var eventOutputConfig: JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonValue = - JsonValue.from("grouped_with_min_max_thresholds") + private var modelType: JsonValue = JsonValue.from("event_output") private var name: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() @@ -11498,33 +14816,27 @@ private constructor( private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds) = - apply { - cadence = groupedWithMinMaxThresholds.cadence - groupedWithMinMaxThresholdsConfig = - groupedWithMinMaxThresholds.groupedWithMinMaxThresholdsConfig - itemId = groupedWithMinMaxThresholds.itemId - modelType = groupedWithMinMaxThresholds.modelType - name = groupedWithMinMaxThresholds.name - billableMetricId = groupedWithMinMaxThresholds.billableMetricId - billedInAdvance = groupedWithMinMaxThresholds.billedInAdvance - billingCycleConfiguration = - groupedWithMinMaxThresholds.billingCycleConfiguration - conversionRate = groupedWithMinMaxThresholds.conversionRate - conversionRateConfig = groupedWithMinMaxThresholds.conversionRateConfig - currency = groupedWithMinMaxThresholds.currency - dimensionalPriceConfiguration = - groupedWithMinMaxThresholds.dimensionalPriceConfiguration - externalPriceId = groupedWithMinMaxThresholds.externalPriceId - fixedPriceQuantity = groupedWithMinMaxThresholds.fixedPriceQuantity - invoiceGroupingKey = groupedWithMinMaxThresholds.invoiceGroupingKey - invoicingCycleConfiguration = - groupedWithMinMaxThresholds.invoicingCycleConfiguration - metadata = groupedWithMinMaxThresholds.metadata - referenceId = groupedWithMinMaxThresholds.referenceId - additionalProperties = - groupedWithMinMaxThresholds.additionalProperties.toMutableMap() - } + internal fun from(eventOutput: EventOutput) = apply { + cadence = eventOutput.cadence + eventOutputConfig = eventOutput.eventOutputConfig + itemId = eventOutput.itemId + modelType = eventOutput.modelType + name = eventOutput.name + billableMetricId = eventOutput.billableMetricId + billedInAdvance = eventOutput.billedInAdvance + billingCycleConfiguration = eventOutput.billingCycleConfiguration + conversionRate = eventOutput.conversionRate + conversionRateConfig = eventOutput.conversionRateConfig + currency = eventOutput.currency + dimensionalPriceConfiguration = eventOutput.dimensionalPriceConfiguration + externalPriceId = eventOutput.externalPriceId + fixedPriceQuantity = eventOutput.fixedPriceQuantity + invoiceGroupingKey = eventOutput.invoiceGroupingKey + invoicingCycleConfiguration = eventOutput.invoicingCycleConfiguration + metadata = eventOutput.metadata + referenceId = eventOutput.referenceId + additionalProperties = eventOutput.additionalProperties.toMutableMap() + } /** The cadence to bill for this price on. */ fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) @@ -11538,27 +14850,19 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - /** Configuration for grouped_with_min_max_thresholds pricing */ - fun groupedWithMinMaxThresholdsConfig( - groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig - ) = - groupedWithMinMaxThresholdsConfig( - JsonField.of(groupedWithMinMaxThresholdsConfig) - ) + /** Configuration for event_output pricing */ + fun eventOutputConfig(eventOutputConfig: EventOutputConfig) = + eventOutputConfig(JsonField.of(eventOutputConfig)) /** - * Sets [Builder.groupedWithMinMaxThresholdsConfig] to an arbitrary JSON value. + * Sets [Builder.eventOutputConfig] to an arbitrary JSON value. * - * You should usually call [Builder.groupedWithMinMaxThresholdsConfig] with a - * well-typed [GroupedWithMinMaxThresholdsConfig] value instead. This method is - * primarily for setting the field to an undocumented or not yet supported - * value. + * You should usually call [Builder.eventOutputConfig] with a well-typed + * [EventOutputConfig] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. */ - fun groupedWithMinMaxThresholdsConfig( - groupedWithMinMaxThresholdsConfig: - JsonField - ) = apply { - this.groupedWithMinMaxThresholdsConfig = groupedWithMinMaxThresholdsConfig + fun eventOutputConfig(eventOutputConfig: JsonField) = apply { + this.eventOutputConfig = eventOutputConfig } /** The id of the item the price will be associated with. */ @@ -11579,7 +14883,7 @@ private constructor( * It is usually unnecessary to call this method because the field defaults to * the following: * ```kotlin - * JsonValue.from("grouped_with_min_max_thresholds") + * JsonValue.from("event_output") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -11928,27 +15232,24 @@ private constructor( } /** - * Returns an immutable instance of [GroupedWithMinMaxThresholds]. + * Returns an immutable instance of [EventOutput]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```kotlin * .cadence() - * .groupedWithMinMaxThresholdsConfig() + * .eventOutputConfig() * .itemId() * .name() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): GroupedWithMinMaxThresholds = - GroupedWithMinMaxThresholds( + fun build(): EventOutput = + EventOutput( checkRequired("cadence", cadence), - checkRequired( - "groupedWithMinMaxThresholdsConfig", - groupedWithMinMaxThresholdsConfig, - ), + checkRequired("eventOutputConfig", eventOutputConfig), checkRequired("itemId", itemId), modelType, checkRequired("name", name), @@ -11971,16 +15272,16 @@ private constructor( private var validated: Boolean = false - fun validate(): GroupedWithMinMaxThresholds = apply { + fun validate(): EventOutput = apply { if (validated) { return@apply } cadence().validate() - groupedWithMinMaxThresholdsConfig().validate() + eventOutputConfig().validate() itemId() _modelType().let { - if (it != JsonValue.from("grouped_with_min_max_thresholds")) { + if (it != JsonValue.from("event_output")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } @@ -12017,11 +15318,9 @@ private constructor( */ internal fun validity(): Int = (cadence.asKnown()?.validity() ?: 0) + - (groupedWithMinMaxThresholdsConfig.asKnown()?.validity() ?: 0) + + (eventOutputConfig.asKnown()?.validity() ?: 0) + (if (itemId.asKnown() == null) 0 else 1) + - modelType.let { - if (it == JsonValue.from("grouped_with_min_max_thresholds")) 1 else 0 - } + + modelType.let { if (it == JsonValue.from("event_output")) 1 else 0 } + (if (name.asKnown() == null) 0 else 1) + (if (billableMetricId.asKnown() == null) 0 else 1) + (if (billedInAdvance.asKnown() == null) 0 else 1) + @@ -12194,68 +15493,52 @@ private constructor( override fun toString() = value.toString() } - /** Configuration for grouped_with_min_max_thresholds pricing */ - class GroupedWithMinMaxThresholdsConfig + /** Configuration for event_output pricing */ + class EventOutputConfig @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( + private val unitRatingKey: JsonField, private val groupingKey: JsonField, - private val maximumCharge: JsonField, - private val minimumCharge: JsonField, - private val perUnitRate: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( + @JsonProperty("unit_rating_key") + @ExcludeMissing + unitRatingKey: JsonField = JsonMissing.of(), @JsonProperty("grouping_key") @ExcludeMissing groupingKey: JsonField = JsonMissing.of(), - @JsonProperty("maximum_charge") - @ExcludeMissing - maximumCharge: JsonField = JsonMissing.of(), - @JsonProperty("minimum_charge") - @ExcludeMissing - minimumCharge: JsonField = JsonMissing.of(), - @JsonProperty("per_unit_rate") - @ExcludeMissing - perUnitRate: JsonField = JsonMissing.of(), - ) : this(groupingKey, maximumCharge, minimumCharge, perUnitRate, mutableMapOf()) - - /** - * The event property used to group before applying thresholds - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun groupingKey(): String = groupingKey.getRequired("grouping_key") + ) : this(unitRatingKey, groupingKey, mutableMapOf()) /** - * The maximum amount to charge each group + * The key in the event data to extract the unit rate from. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). */ - fun maximumCharge(): String = maximumCharge.getRequired("maximum_charge") + fun unitRatingKey(): String = unitRatingKey.getRequired("unit_rating_key") /** - * The minimum amount to charge each group, regardless of usage + * An optional key in the event data to group by (e.g., event ID). All events + * will also be grouped by their unit rate. * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). */ - fun minimumCharge(): String = minimumCharge.getRequired("minimum_charge") + fun groupingKey(): String? = groupingKey.getNullable("grouping_key") /** - * The base price charged per group + * Returns the raw JSON value of [unitRatingKey]. * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). + * Unlike [unitRatingKey], this method doesn't throw if the JSON field has an + * unexpected type. */ - fun perUnitRate(): String = perUnitRate.getRequired("per_unit_rate") + @JsonProperty("unit_rating_key") + @ExcludeMissing + fun _unitRatingKey(): JsonField = unitRatingKey /** * Returns the raw JSON value of [groupingKey]. @@ -12267,36 +15550,6 @@ private constructor( @ExcludeMissing fun _groupingKey(): JsonField = groupingKey - /** - * Returns the raw JSON value of [maximumCharge]. - * - * Unlike [maximumCharge], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("maximum_charge") - @ExcludeMissing - fun _maximumCharge(): JsonField = maximumCharge - - /** - * Returns the raw JSON value of [minimumCharge]. - * - * Unlike [minimumCharge], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("minimum_charge") - @ExcludeMissing - fun _minimumCharge(): JsonField = minimumCharge - - /** - * Returns the raw JSON value of [perUnitRate]. - * - * Unlike [perUnitRate], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("per_unit_rate") - @ExcludeMissing - fun _perUnitRate(): JsonField = perUnitRate - @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -12313,99 +15566,62 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [GroupedWithMinMaxThresholdsConfig]. + * [EventOutputConfig]. * * The following fields are required: * ```kotlin - * .groupingKey() - * .maximumCharge() - * .minimumCharge() - * .perUnitRate() + * .unitRatingKey() * ``` */ fun builder() = Builder() } - /** A builder for [GroupedWithMinMaxThresholdsConfig]. */ + /** A builder for [EventOutputConfig]. */ class Builder internal constructor() { - private var groupingKey: JsonField? = null - private var maximumCharge: JsonField? = null - private var minimumCharge: JsonField? = null - private var perUnitRate: JsonField? = null + private var unitRatingKey: JsonField? = null + private var groupingKey: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() - internal fun from( - groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig - ) = apply { - groupingKey = groupedWithMinMaxThresholdsConfig.groupingKey - maximumCharge = groupedWithMinMaxThresholdsConfig.maximumCharge - minimumCharge = groupedWithMinMaxThresholdsConfig.minimumCharge - perUnitRate = groupedWithMinMaxThresholdsConfig.perUnitRate + internal fun from(eventOutputConfig: EventOutputConfig) = apply { + unitRatingKey = eventOutputConfig.unitRatingKey + groupingKey = eventOutputConfig.groupingKey additionalProperties = - groupedWithMinMaxThresholdsConfig.additionalProperties - .toMutableMap() - } - - /** The event property used to group before applying thresholds */ - fun groupingKey(groupingKey: String) = - groupingKey(JsonField.of(groupingKey)) - - /** - * Sets [Builder.groupingKey] to an arbitrary JSON value. - * - * You should usually call [Builder.groupingKey] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun groupingKey(groupingKey: JsonField) = apply { - this.groupingKey = groupingKey + eventOutputConfig.additionalProperties.toMutableMap() } - /** The maximum amount to charge each group */ - fun maximumCharge(maximumCharge: String) = - maximumCharge(JsonField.of(maximumCharge)) + /** The key in the event data to extract the unit rate from. */ + fun unitRatingKey(unitRatingKey: String) = + unitRatingKey(JsonField.of(unitRatingKey)) /** - * Sets [Builder.maximumCharge] to an arbitrary JSON value. + * Sets [Builder.unitRatingKey] to an arbitrary JSON value. * - * You should usually call [Builder.maximumCharge] with a well-typed + * You should usually call [Builder.unitRatingKey] with a well-typed * [String] value instead. This method is primarily for setting the field to * an undocumented or not yet supported value. */ - fun maximumCharge(maximumCharge: JsonField) = apply { - this.maximumCharge = maximumCharge + fun unitRatingKey(unitRatingKey: JsonField) = apply { + this.unitRatingKey = unitRatingKey } - /** The minimum amount to charge each group, regardless of usage */ - fun minimumCharge(minimumCharge: String) = - minimumCharge(JsonField.of(minimumCharge)) - /** - * Sets [Builder.minimumCharge] to an arbitrary JSON value. - * - * You should usually call [Builder.minimumCharge] with a well-typed - * [String] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. + * An optional key in the event data to group by (e.g., event ID). All + * events will also be grouped by their unit rate. */ - fun minimumCharge(minimumCharge: JsonField) = apply { - this.minimumCharge = minimumCharge - } - - /** The base price charged per group */ - fun perUnitRate(perUnitRate: String) = - perUnitRate(JsonField.of(perUnitRate)) + fun groupingKey(groupingKey: String?) = + groupingKey(JsonField.ofNullable(groupingKey)) /** - * Sets [Builder.perUnitRate] to an arbitrary JSON value. + * Sets [Builder.groupingKey] to an arbitrary JSON value. * - * You should usually call [Builder.perUnitRate] with a well-typed [String] + * You should usually call [Builder.groupingKey] with a well-typed [String] * value instead. This method is primarily for setting the field to an * undocumented or not yet supported value. */ - fun perUnitRate(perUnitRate: JsonField) = apply { - this.perUnitRate = perUnitRate + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey } fun additionalProperties(additionalProperties: Map) = @@ -12431,41 +15647,34 @@ private constructor( } /** - * Returns an immutable instance of [GroupedWithMinMaxThresholdsConfig]. + * Returns an immutable instance of [EventOutputConfig]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```kotlin - * .groupingKey() - * .maximumCharge() - * .minimumCharge() - * .perUnitRate() + * .unitRatingKey() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): GroupedWithMinMaxThresholdsConfig = - GroupedWithMinMaxThresholdsConfig( - checkRequired("groupingKey", groupingKey), - checkRequired("maximumCharge", maximumCharge), - checkRequired("minimumCharge", minimumCharge), - checkRequired("perUnitRate", perUnitRate), + fun build(): EventOutputConfig = + EventOutputConfig( + checkRequired("unitRatingKey", unitRatingKey), + groupingKey, additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): GroupedWithMinMaxThresholdsConfig = apply { + fun validate(): EventOutputConfig = apply { if (validated) { return@apply } + unitRatingKey() groupingKey() - maximumCharge() - minimumCharge() - perUnitRate() validated = true } @@ -12484,38 +15693,28 @@ private constructor( * Used for best match union deserialization. */ internal fun validity(): Int = - (if (groupingKey.asKnown() == null) 0 else 1) + - (if (maximumCharge.asKnown() == null) 0 else 1) + - (if (minimumCharge.asKnown() == null) 0 else 1) + - (if (perUnitRate.asKnown() == null) 0 else 1) + (if (unitRatingKey.asKnown() == null) 0 else 1) + + (if (groupingKey.asKnown() == null) 0 else 1) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is GroupedWithMinMaxThresholdsConfig && + return other is EventOutputConfig && + unitRatingKey == other.unitRatingKey && groupingKey == other.groupingKey && - maximumCharge == other.maximumCharge && - minimumCharge == other.minimumCharge && - perUnitRate == other.perUnitRate && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash( - groupingKey, - maximumCharge, - minimumCharge, - perUnitRate, - additionalProperties, - ) + Objects.hash(unitRatingKey, groupingKey, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "GroupedWithMinMaxThresholdsConfig{groupingKey=$groupingKey, maximumCharge=$maximumCharge, minimumCharge=$minimumCharge, perUnitRate=$perUnitRate, additionalProperties=$additionalProperties}" + "EventOutputConfig{unitRatingKey=$unitRatingKey, groupingKey=$groupingKey, additionalProperties=$additionalProperties}" } /** @@ -12632,10 +15831,9 @@ private constructor( return true } - return other is GroupedWithMinMaxThresholds && + return other is EventOutput && cadence == other.cadence && - groupedWithMinMaxThresholdsConfig == - other.groupedWithMinMaxThresholdsConfig && + eventOutputConfig == other.eventOutputConfig && itemId == other.itemId && modelType == other.modelType && name == other.name && @@ -12658,7 +15856,7 @@ private constructor( private val hashCode: Int by lazy { Objects.hash( cadence, - groupedWithMinMaxThresholdsConfig, + eventOutputConfig, itemId, modelType, name, @@ -12682,7 +15880,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "GroupedWithMinMaxThresholds{cadence=$cadence, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "EventOutput{cadence=$cadence, eventOutputConfig=$eventOutputConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } } diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BetaExternalPlanIdCreatePlanVersionParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BetaExternalPlanIdCreatePlanVersionParams.kt index a69f5c200..56a93152b 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BetaExternalPlanIdCreatePlanVersionParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BetaExternalPlanIdCreatePlanVersionParams.kt @@ -1971,6 +1971,9 @@ private constructor( /** Alias for calling [price] with `Price.ofMinimum(minimum)`. */ fun price(minimum: NewPlanMinimumCompositePrice) = price(Price.ofMinimum(minimum)) + /** Alias for calling [price] with `Price.ofEventOutput(eventOutput)`. */ + fun price(eventOutput: Price.EventOutput) = price(Price.ofEventOutput(eventOutput)) + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -2071,6 +2074,7 @@ private constructor( null, private val cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice? = null, private val minimum: NewPlanMinimumCompositePrice? = null, + private val eventOutput: EventOutput? = null, private val _json: JsonValue? = null, ) { @@ -2134,6 +2138,8 @@ private constructor( fun minimum(): NewPlanMinimumCompositePrice? = minimum + fun eventOutput(): EventOutput? = eventOutput + fun isUnit(): Boolean = unit != null fun isTiered(): Boolean = tiered != null @@ -2189,6 +2195,8 @@ private constructor( fun isMinimum(): Boolean = minimum != null + fun isEventOutput(): Boolean = eventOutput != null + fun asUnit(): NewPlanUnitPrice = unit.getOrThrow("unit") fun asTiered(): NewPlanTieredPrice = tiered.getOrThrow("tiered") @@ -2264,6 +2272,8 @@ private constructor( fun asMinimum(): NewPlanMinimumCompositePrice = minimum.getOrThrow("minimum") + fun asEventOutput(): EventOutput = eventOutput.getOrThrow("eventOutput") + fun _json(): JsonValue? = _json fun accept(visitor: Visitor): T = @@ -2311,6 +2321,7 @@ private constructor( cumulativeGroupedBulk != null -> visitor.visitCumulativeGroupedBulk(cumulativeGroupedBulk) minimum != null -> visitor.visitMinimum(minimum) + eventOutput != null -> visitor.visitEventOutput(eventOutput) else -> visitor.unknown(_json) } @@ -2469,6 +2480,10 @@ private constructor( override fun visitMinimum(minimum: NewPlanMinimumCompositePrice) { minimum.validate() } + + override fun visitEventOutput(eventOutput: EventOutput) { + eventOutput.validate() + } } ) validated = true @@ -2588,6 +2603,9 @@ private constructor( override fun visitMinimum(minimum: NewPlanMinimumCompositePrice) = minimum.validity() + override fun visitEventOutput(eventOutput: EventOutput) = + eventOutput.validity() + override fun unknown(json: JsonValue?) = 0 } ) @@ -2624,7 +2642,8 @@ private constructor( scalableMatrixWithUnitPricing == other.scalableMatrixWithUnitPricing && scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && cumulativeGroupedBulk == other.cumulativeGroupedBulk && - minimum == other.minimum + minimum == other.minimum && + eventOutput == other.eventOutput } override fun hashCode(): Int = @@ -2656,6 +2675,7 @@ private constructor( scalableMatrixWithTieredPricing, cumulativeGroupedBulk, minimum, + eventOutput, ) override fun toString(): String = @@ -2700,6 +2720,7 @@ private constructor( cumulativeGroupedBulk != null -> "Price{cumulativeGroupedBulk=$cumulativeGroupedBulk}" minimum != null -> "Price{minimum=$minimum}" + eventOutput != null -> "Price{eventOutput=$eventOutput}" _json != null -> "Price{_unknown=$_json}" else -> throw IllegalStateException("Invalid Price") } @@ -2790,6 +2811,8 @@ private constructor( ) = Price(cumulativeGroupedBulk = cumulativeGroupedBulk) fun ofMinimum(minimum: NewPlanMinimumCompositePrice) = Price(minimum = minimum) + + fun ofEventOutput(eventOutput: EventOutput) = Price(eventOutput = eventOutput) } /** @@ -2877,6 +2900,8 @@ private constructor( fun visitMinimum(minimum: NewPlanMinimumCompositePrice): T + fun visitEventOutput(eventOutput: EventOutput): T + /** * Maps an unknown variant of [Price] to a value of type [T]. * @@ -3089,6 +3114,11 @@ private constructor( ) ?.let { Price(minimum = it, _json = json) } ?: Price(_json = json) } + "event_output" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(eventOutput = it, _json = json) + } ?: Price(_json = json) + } } return Price(_json = json) @@ -3149,6 +3179,7 @@ private constructor( value.cumulativeGroupedBulk != null -> generator.writeObject(value.cumulativeGroupedBulk) value.minimum != null -> generator.writeObject(value.minimum) + value.eventOutput != null -> generator.writeObject(value.eventOutput) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid Price") } @@ -6621,1049 +6652,1573 @@ private constructor( override fun toString() = "GroupedWithMinMaxThresholds{cadence=$cadence, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - return other is AddPrice && - allocationPrice == other.allocationPrice && - planPhaseOrder == other.planPhaseOrder && - price == other.price && - additionalProperties == other.additionalProperties - } + class EventOutput + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val eventOutputConfig: JsonField, + private val itemId: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { - private val hashCode: Int by lazy { - Objects.hash(allocationPrice, planPhaseOrder, price, additionalProperties) - } + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("event_output_config") + @ExcludeMissing + eventOutputConfig: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + eventOutputConfig, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + mutableMapOf(), + ) - override fun hashCode(): Int = hashCode + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") - override fun toString() = - "AddPrice{allocationPrice=$allocationPrice, planPhaseOrder=$planPhaseOrder, price=$price, additionalProperties=$additionalProperties}" - } + /** + * Configuration for event_output pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun eventOutputConfig(): EventOutputConfig = + eventOutputConfig.getRequired("event_output_config") - class RemoveAdjustment - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val adjustmentId: JsonField, - private val planPhaseOrder: JsonField, - private val additionalProperties: MutableMap, - ) { + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") - @JsonCreator - private constructor( - @JsonProperty("adjustment_id") - @ExcludeMissing - adjustmentId: JsonField = JsonMissing.of(), - @JsonProperty("plan_phase_order") - @ExcludeMissing - planPhaseOrder: JsonField = JsonMissing.of(), - ) : this(adjustmentId, planPhaseOrder, mutableMapOf()) + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("event_output") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType - /** - * The id of the adjustment to remove from on the plan. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun adjustmentId(): String = adjustmentId.getRequired("adjustment_id") + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") - /** - * The phase to remove this adjustment from. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun planPhaseOrder(): Long? = planPhaseOrder.getNullable("plan_phase_order") + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = billableMetricId.getNullable("billable_metric_id") - /** - * Returns the raw JSON value of [adjustmentId]. - * - * Unlike [adjustmentId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("adjustment_id") - @ExcludeMissing - fun _adjustmentId(): JsonField = adjustmentId + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") - /** - * Returns the raw JSON value of [planPhaseOrder]. - * - * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("plan_phase_order") - @ExcludeMissing - fun _planPhaseOrder(): JsonField = planPhaseOrder + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") - companion object { + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") - /** - * Returns a mutable builder for constructing an instance of [RemoveAdjustment]. - * - * The following fields are required: - * ```kotlin - * .adjustmentId() - * ``` - */ - fun builder() = Builder() - } + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") - /** A builder for [RemoveAdjustment]. */ - class Builder internal constructor() { + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") - private var adjustmentId: JsonField? = null - private var planPhaseOrder: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") - internal fun from(removeAdjustment: RemoveAdjustment) = apply { - adjustmentId = removeAdjustment.adjustmentId - planPhaseOrder = removeAdjustment.planPhaseOrder - additionalProperties = removeAdjustment.additionalProperties.toMutableMap() - } + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + invoiceGroupingKey.getNullable("invoice_grouping_key") - /** The id of the adjustment to remove from on the plan. */ - fun adjustmentId(adjustmentId: String) = adjustmentId(JsonField.of(adjustmentId)) + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - /** - * Sets [Builder.adjustmentId] to an arbitrary JSON value. - * - * You should usually call [Builder.adjustmentId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun adjustmentId(adjustmentId: JsonField) = apply { - this.adjustmentId = adjustmentId - } + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") - /** The phase to remove this adjustment from. */ - fun planPhaseOrder(planPhaseOrder: Long?) = - planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") - /** - * Alias for [Builder.planPhaseOrder]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence - /** - * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. - * - * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun planPhaseOrder(planPhaseOrder: JsonField) = apply { - this.planPhaseOrder = planPhaseOrder - } + /** + * Returns the raw JSON value of [eventOutputConfig]. + * + * Unlike [eventOutputConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("event_output_config") + @ExcludeMissing + fun _eventOutputConfig(): JsonField = eventOutputConfig - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration - /** - * Returns an immutable instance of [RemoveAdjustment]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```kotlin - * .adjustmentId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): RemoveAdjustment = - RemoveAdjustment( - checkRequired("adjustmentId", adjustmentId), - planPhaseOrder, - additionalProperties.toMutableMap(), - ) - } + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate - private var validated: Boolean = false + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig - fun validate(): RemoveAdjustment = apply { - if (validated) { - return@apply - } + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency - adjustmentId() - planPhaseOrder() - validated = true - } + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (if (adjustmentId.asKnown() == null) 0 else 1) + - (if (planPhaseOrder.asKnown() == null) 0 else 1) + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - return other is RemoveAdjustment && - adjustmentId == other.adjustmentId && - planPhaseOrder == other.planPhaseOrder && - additionalProperties == other.additionalProperties - } + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration - private val hashCode: Int by lazy { - Objects.hash(adjustmentId, planPhaseOrder, additionalProperties) - } + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata - override fun hashCode(): Int = hashCode + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId - override fun toString() = - "RemoveAdjustment{adjustmentId=$adjustmentId, planPhaseOrder=$planPhaseOrder, additionalProperties=$additionalProperties}" - } + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - class RemovePrice - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val priceId: JsonField, - private val planPhaseOrder: JsonField, - private val additionalProperties: MutableMap, - ) { + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - @JsonCreator - private constructor( - @JsonProperty("price_id") @ExcludeMissing priceId: JsonField = JsonMissing.of(), - @JsonProperty("plan_phase_order") - @ExcludeMissing - planPhaseOrder: JsonField = JsonMissing.of(), - ) : this(priceId, planPhaseOrder, mutableMapOf()) + fun toBuilder() = Builder().from(this) - /** - * The id of the price to remove from the plan. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun priceId(): String = priceId.getRequired("price_id") + companion object { - /** - * The phase to remove this price from. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun planPhaseOrder(): Long? = planPhaseOrder.getNullable("plan_phase_order") + /** + * Returns a mutable builder for constructing an instance of [EventOutput]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .eventOutputConfig() + * .itemId() + * .name() + * ``` + */ + fun builder() = Builder() + } - /** - * Returns the raw JSON value of [priceId]. - * - * Unlike [priceId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId + /** A builder for [EventOutput]. */ + class Builder internal constructor() { - /** - * Returns the raw JSON value of [planPhaseOrder]. - * - * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("plan_phase_order") - @ExcludeMissing - fun _planPhaseOrder(): JsonField = planPhaseOrder + private var cadence: JsonField? = null + private var eventOutputConfig: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonValue = JsonValue.from("event_output") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + internal fun from(eventOutput: EventOutput) = apply { + cadence = eventOutput.cadence + eventOutputConfig = eventOutput.eventOutputConfig + itemId = eventOutput.itemId + modelType = eventOutput.modelType + name = eventOutput.name + billableMetricId = eventOutput.billableMetricId + billedInAdvance = eventOutput.billedInAdvance + billingCycleConfiguration = eventOutput.billingCycleConfiguration + conversionRate = eventOutput.conversionRate + conversionRateConfig = eventOutput.conversionRateConfig + currency = eventOutput.currency + dimensionalPriceConfiguration = eventOutput.dimensionalPriceConfiguration + externalPriceId = eventOutput.externalPriceId + fixedPriceQuantity = eventOutput.fixedPriceQuantity + invoiceGroupingKey = eventOutput.invoiceGroupingKey + invoicingCycleConfiguration = eventOutput.invoicingCycleConfiguration + metadata = eventOutput.metadata + referenceId = eventOutput.referenceId + additionalProperties = eventOutput.additionalProperties.toMutableMap() + } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - fun toBuilder() = Builder().from(this) + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - companion object { + /** Configuration for event_output pricing */ + fun eventOutputConfig(eventOutputConfig: EventOutputConfig) = + eventOutputConfig(JsonField.of(eventOutputConfig)) - /** - * Returns a mutable builder for constructing an instance of [RemovePrice]. - * - * The following fields are required: - * ```kotlin - * .priceId() - * ``` - */ - fun builder() = Builder() - } + /** + * Sets [Builder.eventOutputConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.eventOutputConfig] with a well-typed + * [EventOutputConfig] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun eventOutputConfig(eventOutputConfig: JsonField) = apply { + this.eventOutputConfig = eventOutputConfig + } - /** A builder for [RemovePrice]. */ - class Builder internal constructor() { + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - private var priceId: JsonField? = null - private var planPhaseOrder: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - internal fun from(removePrice: RemovePrice) = apply { - priceId = removePrice.priceId - planPhaseOrder = removePrice.planPhaseOrder - additionalProperties = removePrice.additionalProperties.toMutableMap() - } + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("event_output") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } - /** The id of the price to remove from the plan. */ - fun priceId(priceId: String) = priceId(JsonField.of(priceId)) + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) - /** - * Sets [Builder.priceId] to an arbitrary JSON value. - * - * You should usually call [Builder.priceId] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun priceId(priceId: JsonField) = apply { this.priceId = priceId } - - /** The phase to remove this price from. */ - fun planPhaseOrder(planPhaseOrder: Long?) = - planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } - /** - * Alias for [Builder.planPhaseOrder]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) - /** - * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. - * - * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun planPhaseOrder(planPhaseOrder: JsonField) = apply { - this.planPhaseOrder = planPhaseOrder - } + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } - /** - * Returns an immutable instance of [RemovePrice]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```kotlin - * .priceId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): RemovePrice = - RemovePrice( - checkRequired("priceId", priceId), - planPhaseOrder, - additionalProperties.toMutableMap(), - ) - } + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) - private var validated: Boolean = false + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) - fun validate(): RemovePrice = apply { - if (validated) { - return@apply - } + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } - priceId() - planPhaseOrder() - validated = true - } + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (if (priceId.asKnown() == null) 0 else 1) + - (if (planPhaseOrder.asKnown() == null) 0 else 1) + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) - return other is RemovePrice && - priceId == other.priceId && - planPhaseOrder == other.planPhaseOrder && - additionalProperties == other.additionalProperties - } + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) - private val hashCode: Int by lazy { - Objects.hash(priceId, planPhaseOrder, additionalProperties) - } + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) - override fun hashCode(): Int = hashCode + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) - override fun toString() = - "RemovePrice{priceId=$priceId, planPhaseOrder=$planPhaseOrder, additionalProperties=$additionalProperties}" - } + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } - class ReplaceAdjustment - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val adjustment: JsonField, - private val replacesAdjustmentId: JsonField, - private val planPhaseOrder: JsonField, - private val additionalProperties: MutableMap, - ) { + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) - @JsonCreator - private constructor( - @JsonProperty("adjustment") - @ExcludeMissing - adjustment: JsonField = JsonMissing.of(), - @JsonProperty("replaces_adjustment_id") - @ExcludeMissing - replacesAdjustmentId: JsonField = JsonMissing.of(), - @JsonProperty("plan_phase_order") - @ExcludeMissing - planPhaseOrder: JsonField = JsonMissing.of(), - ) : this(adjustment, replacesAdjustmentId, planPhaseOrder, mutableMapOf()) + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } - /** - * The definition of a new adjustment to create and add to the plan. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun adjustment(): Adjustment = adjustment.getRequired("adjustment") + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) - /** - * The id of the adjustment on the plan to replace in the plan. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun replacesAdjustmentId(): String = - replacesAdjustmentId.getRequired("replaces_adjustment_id") + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } - /** - * The phase to replace this adjustment from. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun planPhaseOrder(): Long? = planPhaseOrder.getNullable("plan_phase_order") + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) - /** - * Returns the raw JSON value of [adjustment]. - * - * Unlike [adjustment], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("adjustment") - @ExcludeMissing - fun _adjustment(): JsonField = adjustment + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) - /** - * Returns the raw JSON value of [replacesAdjustmentId]. - * - * Unlike [replacesAdjustmentId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("replaces_adjustment_id") - @ExcludeMissing - fun _replacesAdjustmentId(): JsonField = replacesAdjustmentId + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } - /** - * Returns the raw JSON value of [planPhaseOrder]. - * - * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("plan_phase_order") - @ExcludeMissing - fun _planPhaseOrder(): JsonField = planPhaseOrder + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) - fun toBuilder() = Builder().from(this) + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - companion object { + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - /** - * Returns a mutable builder for constructing an instance of [ReplaceAdjustment]. - * - * The following fields are required: - * ```kotlin - * .adjustment() - * .replacesAdjustmentId() - * ``` - */ - fun builder() = Builder() - } + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - /** A builder for [ReplaceAdjustment]. */ - class Builder internal constructor() { + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) - private var adjustment: JsonField? = null - private var replacesAdjustmentId: JsonField? = null - private var planPhaseOrder: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } - internal fun from(replaceAdjustment: ReplaceAdjustment) = apply { - adjustment = replaceAdjustment.adjustment - replacesAdjustmentId = replaceAdjustment.replacesAdjustmentId - planPhaseOrder = replaceAdjustment.planPhaseOrder - additionalProperties = replaceAdjustment.additionalProperties.toMutableMap() - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** The definition of a new adjustment to create and add to the plan. */ - fun adjustment(adjustment: Adjustment) = adjustment(JsonField.of(adjustment)) + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * Sets [Builder.adjustment] to an arbitrary JSON value. - * - * You should usually call [Builder.adjustment] with a well-typed [Adjustment] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun adjustment(adjustment: JsonField) = apply { - this.adjustment = adjustment - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - /** - * Alias for calling [adjustment] with - * `Adjustment.ofPercentageDiscount(percentageDiscount)`. - */ - fun adjustment(percentageDiscount: NewPercentageDiscount) = - adjustment(Adjustment.ofPercentageDiscount(percentageDiscount)) + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - /** - * Alias for calling [adjustment] with the following: - * ```kotlin - * NewPercentageDiscount.builder() - * .adjustmentType(NewPercentageDiscount.AdjustmentType.PERCENTAGE_DISCOUNT) - * .percentageDiscount(percentageDiscount) - * .build() - * ``` - */ - fun percentageDiscountAdjustment(percentageDiscount: Double) = - adjustment( - NewPercentageDiscount.builder() - .adjustmentType(NewPercentageDiscount.AdjustmentType.PERCENTAGE_DISCOUNT) - .percentageDiscount(percentageDiscount) - .build() - ) + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - /** Alias for calling [adjustment] with `Adjustment.ofUsageDiscount(usageDiscount)`. */ - fun adjustment(usageDiscount: NewUsageDiscount) = - adjustment(Adjustment.ofUsageDiscount(usageDiscount)) + /** + * Returns an immutable instance of [EventOutput]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .eventOutputConfig() + * .itemId() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): EventOutput = + EventOutput( + checkRequired("cadence", cadence), + checkRequired("eventOutputConfig", eventOutputConfig), + checkRequired("itemId", itemId), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } - /** - * Alias for calling [adjustment] with the following: - * ```kotlin - * NewUsageDiscount.builder() - * .adjustmentType(NewUsageDiscount.AdjustmentType.USAGE_DISCOUNT) - * .usageDiscount(usageDiscount) - * .build() - * ``` - */ - fun usageDiscountAdjustment(usageDiscount: Double) = - adjustment( - NewUsageDiscount.builder() - .adjustmentType(NewUsageDiscount.AdjustmentType.USAGE_DISCOUNT) - .usageDiscount(usageDiscount) - .build() - ) + private var validated: Boolean = false - /** - * Alias for calling [adjustment] with `Adjustment.ofAmountDiscount(amountDiscount)`. - */ - fun adjustment(amountDiscount: NewAmountDiscount) = - adjustment(Adjustment.ofAmountDiscount(amountDiscount)) + fun validate(): EventOutput = apply { + if (validated) { + return@apply + } - /** - * Alias for calling [adjustment] with the following: - * ```kotlin - * NewAmountDiscount.builder() - * .adjustmentType(NewAmountDiscount.AdjustmentType.AMOUNT_DISCOUNT) - * .amountDiscount(amountDiscount) - * .build() - * ``` - */ - fun amountDiscountAdjustment(amountDiscount: String) = - adjustment( - NewAmountDiscount.builder() - .adjustmentType(NewAmountDiscount.AdjustmentType.AMOUNT_DISCOUNT) - .amountDiscount(amountDiscount) - .build() - ) + cadence().validate() + eventOutputConfig().validate() + itemId() + _modelType().let { + if (it != JsonValue.from("event_output")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + metadata()?.validate() + referenceId() + validated = true + } - /** Alias for calling [adjustment] with `Adjustment.ofMinimum(minimum)`. */ - fun adjustment(minimum: NewMinimum) = adjustment(Adjustment.ofMinimum(minimum)) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - /** Alias for calling [adjustment] with `Adjustment.ofMaximum(maximum)`. */ - fun adjustment(maximum: NewMaximum) = adjustment(Adjustment.ofMaximum(maximum)) + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (eventOutputConfig.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + modelType.let { if (it == JsonValue.from("event_output")) 1 else 0 } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) - /** - * Alias for calling [adjustment] with the following: - * ```kotlin - * NewMaximum.builder() - * .adjustmentType(NewMaximum.AdjustmentType.MAXIMUM) - * .maximumAmount(maximumAmount) - * .build() - * ``` - */ - fun maximumAdjustment(maximumAmount: String) = - adjustment( - NewMaximum.builder() - .adjustmentType(NewMaximum.AdjustmentType.MAXIMUM) - .maximumAmount(maximumAmount) - .build() - ) + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { - /** The id of the adjustment on the plan to replace in the plan. */ - fun replacesAdjustmentId(replacesAdjustmentId: String) = - replacesAdjustmentId(JsonField.of(replacesAdjustmentId)) + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value - /** - * Sets [Builder.replacesAdjustmentId] to an arbitrary JSON value. - * - * You should usually call [Builder.replacesAdjustmentId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun replacesAdjustmentId(replacesAdjustmentId: JsonField) = apply { - this.replacesAdjustmentId = replacesAdjustmentId - } + companion object { - /** The phase to replace this adjustment from. */ - fun planPhaseOrder(planPhaseOrder: Long?) = - planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + val ANNUAL = of("annual") - /** - * Alias for [Builder.planPhaseOrder]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + val SEMI_ANNUAL = of("semi_annual") - /** - * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. - * - * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun planPhaseOrder(planPhaseOrder: JsonField) = apply { - this.planPhaseOrder = planPhaseOrder - } + val MONTHLY = of("monthly") - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + val QUARTERLY = of("quarterly") - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + val ONE_TIME = of("one_time") - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + val CUSTOM = of("custom") - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun of(value: String) = Cadence(JsonField.of(value)) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } - /** - * Returns an immutable instance of [ReplaceAdjustment]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```kotlin - * .adjustment() - * .replacesAdjustmentId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): ReplaceAdjustment = - ReplaceAdjustment( - checkRequired("adjustment", adjustment), - checkRequired("replacesAdjustmentId", replacesAdjustmentId), - planPhaseOrder, - additionalProperties.toMutableMap(), - ) - } + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } - private var validated: Boolean = false + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } - fun validate(): ReplaceAdjustment = apply { - if (validated) { - return@apply - } + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } - adjustment().validate() - replacesAdjustmentId() - planPhaseOrder() - validated = true - } + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + private var validated: Boolean = false - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (adjustment.asKnown()?.validity() ?: 0) + - (if (replacesAdjustmentId.asKnown() == null) 0 else 1) + - (if (planPhaseOrder.asKnown() == null) 0 else 1) + fun validate(): Cadence = apply { + if (validated) { + return@apply + } - /** The definition of a new adjustment to create and add to the plan. */ - @JsonDeserialize(using = Adjustment.Deserializer::class) - @JsonSerialize(using = Adjustment.Serializer::class) - class Adjustment - private constructor( - private val percentageDiscount: NewPercentageDiscount? = null, - private val usageDiscount: NewUsageDiscount? = null, - private val amountDiscount: NewAmountDiscount? = null, - private val minimum: NewMinimum? = null, - private val maximum: NewMaximum? = null, - private val _json: JsonValue? = null, - ) { + known() + validated = true + } - fun percentageDiscount(): NewPercentageDiscount? = percentageDiscount + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - fun usageDiscount(): NewUsageDiscount? = usageDiscount + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - fun amountDiscount(): NewAmountDiscount? = amountDiscount + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun minimum(): NewMinimum? = minimum + return other is Cadence && value == other.value + } - fun maximum(): NewMaximum? = maximum + override fun hashCode() = value.hashCode() - fun isPercentageDiscount(): Boolean = percentageDiscount != null + override fun toString() = value.toString() + } - fun isUsageDiscount(): Boolean = usageDiscount != null + /** Configuration for event_output pricing */ + class EventOutputConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val unitRatingKey: JsonField, + private val groupingKey: JsonField, + private val additionalProperties: MutableMap, + ) { - fun isAmountDiscount(): Boolean = amountDiscount != null + @JsonCreator + private constructor( + @JsonProperty("unit_rating_key") + @ExcludeMissing + unitRatingKey: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + ) : this(unitRatingKey, groupingKey, mutableMapOf()) - fun isMinimum(): Boolean = minimum != null + /** + * The key in the event data to extract the unit rate from. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun unitRatingKey(): String = unitRatingKey.getRequired("unit_rating_key") - fun isMaximum(): Boolean = maximum != null + /** + * An optional key in the event data to group by (e.g., event ID). All events + * will also be grouped by their unit rate. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun groupingKey(): String? = groupingKey.getNullable("grouping_key") - fun asPercentageDiscount(): NewPercentageDiscount = - percentageDiscount.getOrThrow("percentageDiscount") + /** + * Returns the raw JSON value of [unitRatingKey]. + * + * Unlike [unitRatingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_rating_key") + @ExcludeMissing + fun _unitRatingKey(): JsonField = unitRatingKey - fun asUsageDiscount(): NewUsageDiscount = usageDiscount.getOrThrow("usageDiscount") + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey - fun asAmountDiscount(): NewAmountDiscount = amountDiscount.getOrThrow("amountDiscount") + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - fun asMinimum(): NewMinimum = minimum.getOrThrow("minimum") + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - fun asMaximum(): NewMaximum = maximum.getOrThrow("maximum") + fun toBuilder() = Builder().from(this) - fun _json(): JsonValue? = _json + companion object { - fun accept(visitor: Visitor): T = - when { - percentageDiscount != null -> - visitor.visitPercentageDiscount(percentageDiscount) - usageDiscount != null -> visitor.visitUsageDiscount(usageDiscount) - amountDiscount != null -> visitor.visitAmountDiscount(amountDiscount) - minimum != null -> visitor.visitMinimum(minimum) - maximum != null -> visitor.visitMaximum(maximum) - else -> visitor.unknown(_json) - } + /** + * Returns a mutable builder for constructing an instance of + * [EventOutputConfig]. + * + * The following fields are required: + * ```kotlin + * .unitRatingKey() + * ``` + */ + fun builder() = Builder() + } - private var validated: Boolean = false + /** A builder for [EventOutputConfig]. */ + class Builder internal constructor() { - fun validate(): Adjustment = apply { - if (validated) { - return@apply - } + private var unitRatingKey: JsonField? = null + private var groupingKey: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() - accept( - object : Visitor { - override fun visitPercentageDiscount( - percentageDiscount: NewPercentageDiscount - ) { - percentageDiscount.validate() + internal fun from(eventOutputConfig: EventOutputConfig) = apply { + unitRatingKey = eventOutputConfig.unitRatingKey + groupingKey = eventOutputConfig.groupingKey + additionalProperties = + eventOutputConfig.additionalProperties.toMutableMap() } - override fun visitUsageDiscount(usageDiscount: NewUsageDiscount) { - usageDiscount.validate() - } + /** The key in the event data to extract the unit rate from. */ + fun unitRatingKey(unitRatingKey: String) = + unitRatingKey(JsonField.of(unitRatingKey)) - override fun visitAmountDiscount(amountDiscount: NewAmountDiscount) { - amountDiscount.validate() - } - - override fun visitMinimum(minimum: NewMinimum) { - minimum.validate() + /** + * Sets [Builder.unitRatingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.unitRatingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun unitRatingKey(unitRatingKey: JsonField) = apply { + this.unitRatingKey = unitRatingKey } - override fun visitMaximum(maximum: NewMaximum) { - maximum.validate() - } - } - ) - validated = true - } + /** + * An optional key in the event data to group by (e.g., event ID). All + * events will also be grouped by their unit rate. + */ + fun groupingKey(groupingKey: String?) = + groupingKey(JsonField.ofNullable(groupingKey)) - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitPercentageDiscount( - percentageDiscount: NewPercentageDiscount - ) = percentageDiscount.validity() + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - override fun visitUsageDiscount(usageDiscount: NewUsageDiscount) = - usageDiscount.validity() + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - override fun visitAmountDiscount(amountDiscount: NewAmountDiscount) = - amountDiscount.validity() + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - override fun visitMinimum(minimum: NewMinimum) = minimum.validity() + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - override fun visitMaximum(maximum: NewMaximum) = maximum.validity() + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - override fun unknown(json: JsonValue?) = 0 + /** + * Returns an immutable instance of [EventOutputConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .unitRatingKey() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): EventOutputConfig = + EventOutputConfig( + checkRequired("unitRatingKey", unitRatingKey), + groupingKey, + additionalProperties.toMutableMap(), + ) } - ) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + private var validated: Boolean = false - return other is Adjustment && - percentageDiscount == other.percentageDiscount && - usageDiscount == other.usageDiscount && - amountDiscount == other.amountDiscount && - minimum == other.minimum && - maximum == other.maximum - } + fun validate(): EventOutputConfig = apply { + if (validated) { + return@apply + } - override fun hashCode(): Int = - Objects.hash(percentageDiscount, usageDiscount, amountDiscount, minimum, maximum) + unitRatingKey() + groupingKey() + validated = true + } - override fun toString(): String = - when { - percentageDiscount != null -> - "Adjustment{percentageDiscount=$percentageDiscount}" - usageDiscount != null -> "Adjustment{usageDiscount=$usageDiscount}" - amountDiscount != null -> "Adjustment{amountDiscount=$amountDiscount}" - minimum != null -> "Adjustment{minimum=$minimum}" - maximum != null -> "Adjustment{maximum=$maximum}" - _json != null -> "Adjustment{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Adjustment") - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - companion object { + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (unitRatingKey.asKnown() == null) 0 else 1) + + (if (groupingKey.asKnown() == null) 0 else 1) - fun ofPercentageDiscount(percentageDiscount: NewPercentageDiscount) = - Adjustment(percentageDiscount = percentageDiscount) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun ofUsageDiscount(usageDiscount: NewUsageDiscount) = - Adjustment(usageDiscount = usageDiscount) + return other is EventOutputConfig && + unitRatingKey == other.unitRatingKey && + groupingKey == other.groupingKey && + additionalProperties == other.additionalProperties + } - fun ofAmountDiscount(amountDiscount: NewAmountDiscount) = - Adjustment(amountDiscount = amountDiscount) + private val hashCode: Int by lazy { + Objects.hash(unitRatingKey, groupingKey, additionalProperties) + } - fun ofMinimum(minimum: NewMinimum) = Adjustment(minimum = minimum) + override fun hashCode(): Int = hashCode - fun ofMaximum(maximum: NewMaximum) = Adjustment(maximum = maximum) - } + override fun toString() = + "EventOutputConfig{unitRatingKey=$unitRatingKey, groupingKey=$groupingKey, additionalProperties=$additionalProperties}" + } - /** - * An interface that defines how to map each variant of [Adjustment] to a value of type - * [T]. - */ - interface Visitor { + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { - fun visitPercentageDiscount(percentageDiscount: NewPercentageDiscount): T + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties - fun visitUsageDiscount(usageDiscount: NewUsageDiscount): T + fun toBuilder() = Builder().from(this) - fun visitAmountDiscount(amountDiscount: NewAmountDiscount): T + companion object { - fun visitMinimum(minimum: NewMinimum): T + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } - fun visitMaximum(maximum: NewMaximum): T + /** A builder for [Metadata]. */ + class Builder internal constructor() { - /** - * Maps an unknown variant of [Adjustment] to a value of type [T]. - * - * An instance of [Adjustment] can contain an unknown variant if it was deserialized - * from data that doesn't match any known variant. For example, if the SDK is on an - * older version than the API, then the API may respond with new variants that the - * SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown Adjustment: $json") - } - } + private var additionalProperties: MutableMap = + mutableMapOf() - internal class Deserializer : BaseDeserializer(Adjustment::class) { + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } - override fun ObjectCodec.deserialize(node: JsonNode): Adjustment { - val json = JsonValue.fromJsonNode(node) - val adjustmentType = json.asObject()?.get("adjustment_type")?.asString() + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - when (adjustmentType) { - "percentage_discount" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Adjustment(percentageDiscount = it, _json = json) } - ?: Adjustment(_json = json) - } - "usage_discount" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(usageDiscount = it, _json = json) - } ?: Adjustment(_json = json) - } - "amount_discount" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(amountDiscount = it, _json = json) - } ?: Adjustment(_json = json) + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) } - "minimum" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(minimum = it, _json = json) - } ?: Adjustment(_json = json) + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) } - "maximum" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(maximum = it, _json = json) - } ?: Adjustment(_json = json) + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } - return Adjustment(_json = json) - } - } + private var validated: Boolean = false - internal class Serializer : BaseSerializer(Adjustment::class) { + fun validate(): Metadata = apply { + if (validated) { + return@apply + } - override fun serialize( - value: Adjustment, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.percentageDiscount != null -> - generator.writeObject(value.percentageDiscount) - value.usageDiscount != null -> generator.writeObject(value.usageDiscount) - value.amountDiscount != null -> generator.writeObject(value.amountDiscount) - value.minimum != null -> generator.writeObject(value.minimum) - value.maximum != null -> generator.writeObject(value.maximum) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Adjustment") + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } + + return other is EventOutput && + cadence == other.cadence && + eventOutputConfig == other.eventOutputConfig && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + eventOutputConfig, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties, + ) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "EventOutput{cadence=$cadence, eventOutputConfig=$eventOutputConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } } @@ -7672,65 +8227,51 @@ private constructor( return true } - return other is ReplaceAdjustment && - adjustment == other.adjustment && - replacesAdjustmentId == other.replacesAdjustmentId && + return other is AddPrice && + allocationPrice == other.allocationPrice && planPhaseOrder == other.planPhaseOrder && + price == other.price && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(adjustment, replacesAdjustmentId, planPhaseOrder, additionalProperties) + Objects.hash(allocationPrice, planPhaseOrder, price, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "ReplaceAdjustment{adjustment=$adjustment, replacesAdjustmentId=$replacesAdjustmentId, planPhaseOrder=$planPhaseOrder, additionalProperties=$additionalProperties}" + "AddPrice{allocationPrice=$allocationPrice, planPhaseOrder=$planPhaseOrder, price=$price, additionalProperties=$additionalProperties}" } - class ReplacePrice + class RemoveAdjustment @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val replacesPriceId: JsonField, - private val allocationPrice: JsonField, + private val adjustmentId: JsonField, private val planPhaseOrder: JsonField, - private val price: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("replaces_price_id") - @ExcludeMissing - replacesPriceId: JsonField = JsonMissing.of(), - @JsonProperty("allocation_price") + @JsonProperty("adjustment_id") @ExcludeMissing - allocationPrice: JsonField = JsonMissing.of(), + adjustmentId: JsonField = JsonMissing.of(), @JsonProperty("plan_phase_order") @ExcludeMissing planPhaseOrder: JsonField = JsonMissing.of(), - @JsonProperty("price") @ExcludeMissing price: JsonField = JsonMissing.of(), - ) : this(replacesPriceId, allocationPrice, planPhaseOrder, price, mutableMapOf()) + ) : this(adjustmentId, planPhaseOrder, mutableMapOf()) /** - * The id of the price on the plan to replace in the plan. + * The id of the adjustment to remove from on the plan. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ - fun replacesPriceId(): String = replacesPriceId.getRequired("replaces_price_id") - - /** - * The allocation price to add to the plan. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun allocationPrice(): NewAllocationPrice? = allocationPrice.getNullable("allocation_price") + fun adjustmentId(): String = adjustmentId.getRequired("adjustment_id") /** - * The phase to replace this price from. + * The phase to remove this adjustment from. * * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -7738,32 +8279,14 @@ private constructor( fun planPhaseOrder(): Long? = planPhaseOrder.getNullable("plan_phase_order") /** - * New plan price request body params. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun price(): Price? = price.getNullable("price") - - /** - * Returns the raw JSON value of [replacesPriceId]. - * - * Unlike [replacesPriceId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("replaces_price_id") - @ExcludeMissing - fun _replacesPriceId(): JsonField = replacesPriceId - - /** - * Returns the raw JSON value of [allocationPrice]. + * Returns the raw JSON value of [adjustmentId]. * - * Unlike [allocationPrice], this method doesn't throw if the JSON field has an unexpected + * Unlike [adjustmentId], this method doesn't throw if the JSON field has an unexpected * type. */ - @JsonProperty("allocation_price") + @JsonProperty("adjustment_id") @ExcludeMissing - fun _allocationPrice(): JsonField = allocationPrice + fun _adjustmentId(): JsonField = adjustmentId /** * Returns the raw JSON value of [planPhaseOrder]. @@ -7775,13 +8298,6 @@ private constructor( @ExcludeMissing fun _planPhaseOrder(): JsonField = planPhaseOrder - /** - * Returns the raw JSON value of [price]. - * - * Unlike [price], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("price") @ExcludeMissing fun _price(): JsonField = price - @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -7797,64 +8313,44 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [ReplacePrice]. + * Returns a mutable builder for constructing an instance of [RemoveAdjustment]. * * The following fields are required: * ```kotlin - * .replacesPriceId() + * .adjustmentId() * ``` */ fun builder() = Builder() } - /** A builder for [ReplacePrice]. */ + /** A builder for [RemoveAdjustment]. */ class Builder internal constructor() { - private var replacesPriceId: JsonField? = null - private var allocationPrice: JsonField = JsonMissing.of() + private var adjustmentId: JsonField? = null private var planPhaseOrder: JsonField = JsonMissing.of() - private var price: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(replacePrice: ReplacePrice) = apply { - replacesPriceId = replacePrice.replacesPriceId - allocationPrice = replacePrice.allocationPrice - planPhaseOrder = replacePrice.planPhaseOrder - price = replacePrice.price - additionalProperties = replacePrice.additionalProperties.toMutableMap() + internal fun from(removeAdjustment: RemoveAdjustment) = apply { + adjustmentId = removeAdjustment.adjustmentId + planPhaseOrder = removeAdjustment.planPhaseOrder + additionalProperties = removeAdjustment.additionalProperties.toMutableMap() } - /** The id of the price on the plan to replace in the plan. */ - fun replacesPriceId(replacesPriceId: String) = - replacesPriceId(JsonField.of(replacesPriceId)) + /** The id of the adjustment to remove from on the plan. */ + fun adjustmentId(adjustmentId: String) = adjustmentId(JsonField.of(adjustmentId)) /** - * Sets [Builder.replacesPriceId] to an arbitrary JSON value. + * Sets [Builder.adjustmentId] to an arbitrary JSON value. * - * You should usually call [Builder.replacesPriceId] with a well-typed [String] value + * You should usually call [Builder.adjustmentId] with a well-typed [String] value * instead. This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun replacesPriceId(replacesPriceId: JsonField) = apply { - this.replacesPriceId = replacesPriceId - } - - /** The allocation price to add to the plan. */ - fun allocationPrice(allocationPrice: NewAllocationPrice?) = - allocationPrice(JsonField.ofNullable(allocationPrice)) - - /** - * Sets [Builder.allocationPrice] to an arbitrary JSON value. - * - * You should usually call [Builder.allocationPrice] with a well-typed - * [NewAllocationPrice] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun allocationPrice(allocationPrice: JsonField) = apply { - this.allocationPrice = allocationPrice + fun adjustmentId(adjustmentId: JsonField) = apply { + this.adjustmentId = adjustmentId } - /** The phase to replace this price from. */ + /** The phase to remove this adjustment from. */ fun planPhaseOrder(planPhaseOrder: Long?) = planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) @@ -7876,211 +8372,54 @@ private constructor( this.planPhaseOrder = planPhaseOrder } - /** New plan price request body params. */ - fun price(price: Price?) = price(JsonField.ofNullable(price)) - - /** - * Sets [Builder.price] to an arbitrary JSON value. - * - * You should usually call [Builder.price] with a well-typed [Price] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun price(price: JsonField) = apply { this.price = price } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** Alias for calling [price] with `Price.ofUnit(unit)`. */ - fun price(unit: NewPlanUnitPrice) = price(Price.ofUnit(unit)) + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** Alias for calling [price] with `Price.ofTiered(tiered)`. */ - fun price(tiered: NewPlanTieredPrice) = price(Price.ofTiered(tiered)) + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - /** Alias for calling [price] with `Price.ofBulk(bulk)`. */ - fun price(bulk: NewPlanBulkPrice) = price(Price.ofBulk(bulk)) - - /** Alias for calling [price] with `Price.ofPackage(package_)`. */ - fun price(package_: NewPlanPackagePrice) = price(Price.ofPackage(package_)) - - /** Alias for calling [price] with `Price.ofMatrix(matrix)`. */ - fun price(matrix: NewPlanMatrixPrice) = price(Price.ofMatrix(matrix)) - - /** - * Alias for calling [price] with `Price.ofThresholdTotalAmount(thresholdTotalAmount)`. - */ - fun price(thresholdTotalAmount: NewPlanThresholdTotalAmountPrice) = - price(Price.ofThresholdTotalAmount(thresholdTotalAmount)) - - /** Alias for calling [price] with `Price.ofTieredPackage(tieredPackage)`. */ - fun price(tieredPackage: NewPlanTieredPackagePrice) = - price(Price.ofTieredPackage(tieredPackage)) - - /** Alias for calling [price] with `Price.ofTieredWithMinimum(tieredWithMinimum)`. */ - fun price(tieredWithMinimum: NewPlanTieredWithMinimumPrice) = - price(Price.ofTieredWithMinimum(tieredWithMinimum)) - - /** Alias for calling [price] with `Price.ofGroupedTiered(groupedTiered)`. */ - fun price(groupedTiered: NewPlanGroupedTieredPrice) = - price(Price.ofGroupedTiered(groupedTiered)) - - /** - * Alias for calling [price] with - * `Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)`. - */ - fun price(tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice) = - price(Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)) - - /** - * Alias for calling [price] with - * `Price.ofPackageWithAllocation(packageWithAllocation)`. - */ - fun price(packageWithAllocation: NewPlanPackageWithAllocationPrice) = - price(Price.ofPackageWithAllocation(packageWithAllocation)) - - /** Alias for calling [price] with `Price.ofUnitWithPercent(unitWithPercent)`. */ - fun price(unitWithPercent: NewPlanUnitWithPercentPrice) = - price(Price.ofUnitWithPercent(unitWithPercent)) - - /** - * Alias for calling [price] with `Price.ofMatrixWithAllocation(matrixWithAllocation)`. - */ - fun price(matrixWithAllocation: NewPlanMatrixWithAllocationPrice) = - price(Price.ofMatrixWithAllocation(matrixWithAllocation)) - - /** - * Alias for calling [price] with `Price.ofTieredWithProration(tieredWithProration)`. - */ - fun price(tieredWithProration: Price.TieredWithProration) = - price(Price.ofTieredWithProration(tieredWithProration)) - - /** Alias for calling [price] with `Price.ofUnitWithProration(unitWithProration)`. */ - fun price(unitWithProration: NewPlanUnitWithProrationPrice) = - price(Price.ofUnitWithProration(unitWithProration)) - - /** Alias for calling [price] with `Price.ofGroupedAllocation(groupedAllocation)`. */ - fun price(groupedAllocation: NewPlanGroupedAllocationPrice) = - price(Price.ofGroupedAllocation(groupedAllocation)) - - /** Alias for calling [price] with `Price.ofBulkWithProration(bulkWithProration)`. */ - fun price(bulkWithProration: NewPlanBulkWithProrationPrice) = - price(Price.ofBulkWithProration(bulkWithProration)) - - /** - * Alias for calling [price] with - * `Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)`. - */ - fun price(groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice) = - price(Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)) - - /** - * Alias for calling [price] with - * `Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)`. - */ - fun price(groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice) = - price(Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)) - - /** - * Alias for calling [price] with - * `Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)`. - */ - fun price(groupedWithMinMaxThresholds: Price.GroupedWithMinMaxThresholds) = - price(Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)) - - /** - * Alias for calling [price] with - * `Price.ofMatrixWithDisplayName(matrixWithDisplayName)`. - */ - fun price(matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice) = - price(Price.ofMatrixWithDisplayName(matrixWithDisplayName)) - - /** - * Alias for calling [price] with `Price.ofGroupedTieredPackage(groupedTieredPackage)`. - */ - fun price(groupedTieredPackage: NewPlanGroupedTieredPackagePrice) = - price(Price.ofGroupedTieredPackage(groupedTieredPackage)) - - /** - * Alias for calling [price] with - * `Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)`. - */ - fun price(maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice) = - price(Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)) - - /** - * Alias for calling [price] with - * `Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)`. - */ - fun price(scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice) = - price(Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)) - - /** - * Alias for calling [price] with - * `Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)`. - */ - fun price( - scalableMatrixWithTieredPricing: NewPlanScalableMatrixWithTieredPricingPrice - ) = price(Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)) - - /** - * Alias for calling [price] with - * `Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)`. - */ - fun price(cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice) = - price(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) - - /** Alias for calling [price] with `Price.ofMinimum(minimum)`. */ - fun price(minimum: NewPlanMinimumCompositePrice) = price(Price.ofMinimum(minimum)) - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } fun removeAllAdditionalProperties(keys: Set) = apply { keys.forEach(::removeAdditionalProperty) } /** - * Returns an immutable instance of [ReplacePrice]. + * Returns an immutable instance of [RemoveAdjustment]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```kotlin - * .replacesPriceId() + * .adjustmentId() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): ReplacePrice = - ReplacePrice( - checkRequired("replacesPriceId", replacesPriceId), - allocationPrice, + fun build(): RemoveAdjustment = + RemoveAdjustment( + checkRequired("adjustmentId", adjustmentId), planPhaseOrder, - price, additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): ReplacePrice = apply { + fun validate(): RemoveAdjustment = apply { if (validated) { return@apply } - replacesPriceId() - allocationPrice()?.validate() + adjustmentId() planPhaseOrder() - price()?.validate() validated = true } @@ -8099,443 +8438,659 @@ private constructor( * Used for best match union deserialization. */ internal fun validity(): Int = - (if (replacesPriceId.asKnown() == null) 0 else 1) + - (allocationPrice.asKnown()?.validity() ?: 0) + - (if (planPhaseOrder.asKnown() == null) 0 else 1) + - (price.asKnown()?.validity() ?: 0) - - /** New plan price request body params. */ - @JsonDeserialize(using = Price.Deserializer::class) - @JsonSerialize(using = Price.Serializer::class) - class Price - private constructor( - private val unit: NewPlanUnitPrice? = null, - private val tiered: NewPlanTieredPrice? = null, - private val bulk: NewPlanBulkPrice? = null, - private val package_: NewPlanPackagePrice? = null, - private val matrix: NewPlanMatrixPrice? = null, - private val thresholdTotalAmount: NewPlanThresholdTotalAmountPrice? = null, - private val tieredPackage: NewPlanTieredPackagePrice? = null, - private val tieredWithMinimum: NewPlanTieredWithMinimumPrice? = null, - private val groupedTiered: NewPlanGroupedTieredPrice? = null, - private val tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice? = null, - private val packageWithAllocation: NewPlanPackageWithAllocationPrice? = null, - private val unitWithPercent: NewPlanUnitWithPercentPrice? = null, - private val matrixWithAllocation: NewPlanMatrixWithAllocationPrice? = null, - private val tieredWithProration: TieredWithProration? = null, - private val unitWithProration: NewPlanUnitWithProrationPrice? = null, - private val groupedAllocation: NewPlanGroupedAllocationPrice? = null, - private val bulkWithProration: NewPlanBulkWithProrationPrice? = null, - private val groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice? = null, - private val groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice? = null, - private val groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds? = null, - private val matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice? = null, - private val groupedTieredPackage: NewPlanGroupedTieredPackagePrice? = null, - private val maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice? = null, - private val scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice? = - null, - private val scalableMatrixWithTieredPricing: - NewPlanScalableMatrixWithTieredPricingPrice? = - null, - private val cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice? = null, - private val minimum: NewPlanMinimumCompositePrice? = null, - private val _json: JsonValue? = null, - ) { - - fun unit(): NewPlanUnitPrice? = unit + (if (adjustmentId.asKnown() == null) 0 else 1) + + (if (planPhaseOrder.asKnown() == null) 0 else 1) - fun tiered(): NewPlanTieredPrice? = tiered + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun bulk(): NewPlanBulkPrice? = bulk + return other is RemoveAdjustment && + adjustmentId == other.adjustmentId && + planPhaseOrder == other.planPhaseOrder && + additionalProperties == other.additionalProperties + } - fun package_(): NewPlanPackagePrice? = package_ + private val hashCode: Int by lazy { + Objects.hash(adjustmentId, planPhaseOrder, additionalProperties) + } - fun matrix(): NewPlanMatrixPrice? = matrix + override fun hashCode(): Int = hashCode - fun thresholdTotalAmount(): NewPlanThresholdTotalAmountPrice? = thresholdTotalAmount + override fun toString() = + "RemoveAdjustment{adjustmentId=$adjustmentId, planPhaseOrder=$planPhaseOrder, additionalProperties=$additionalProperties}" + } - fun tieredPackage(): NewPlanTieredPackagePrice? = tieredPackage + class RemovePrice + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val priceId: JsonField, + private val planPhaseOrder: JsonField, + private val additionalProperties: MutableMap, + ) { - fun tieredWithMinimum(): NewPlanTieredWithMinimumPrice? = tieredWithMinimum + @JsonCreator + private constructor( + @JsonProperty("price_id") @ExcludeMissing priceId: JsonField = JsonMissing.of(), + @JsonProperty("plan_phase_order") + @ExcludeMissing + planPhaseOrder: JsonField = JsonMissing.of(), + ) : this(priceId, planPhaseOrder, mutableMapOf()) - fun groupedTiered(): NewPlanGroupedTieredPrice? = groupedTiered + /** + * The id of the price to remove from the plan. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun priceId(): String = priceId.getRequired("price_id") - fun tieredPackageWithMinimum(): NewPlanTieredPackageWithMinimumPrice? = - tieredPackageWithMinimum - - fun packageWithAllocation(): NewPlanPackageWithAllocationPrice? = packageWithAllocation - - fun unitWithPercent(): NewPlanUnitWithPercentPrice? = unitWithPercent - - fun matrixWithAllocation(): NewPlanMatrixWithAllocationPrice? = matrixWithAllocation + /** + * The phase to remove this price from. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun planPhaseOrder(): Long? = planPhaseOrder.getNullable("plan_phase_order") - fun tieredWithProration(): TieredWithProration? = tieredWithProration + /** + * Returns the raw JSON value of [priceId]. + * + * Unlike [priceId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId - fun unitWithProration(): NewPlanUnitWithProrationPrice? = unitWithProration + /** + * Returns the raw JSON value of [planPhaseOrder]. + * + * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder - fun groupedAllocation(): NewPlanGroupedAllocationPrice? = groupedAllocation + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - fun bulkWithProration(): NewPlanBulkWithProrationPrice? = bulkWithProration + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - fun groupedWithProratedMinimum(): NewPlanGroupedWithProratedMinimumPrice? = - groupedWithProratedMinimum + fun toBuilder() = Builder().from(this) - fun groupedWithMeteredMinimum(): NewPlanGroupedWithMeteredMinimumPrice? = - groupedWithMeteredMinimum + companion object { - fun groupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds? = - groupedWithMinMaxThresholds + /** + * Returns a mutable builder for constructing an instance of [RemovePrice]. + * + * The following fields are required: + * ```kotlin + * .priceId() + * ``` + */ + fun builder() = Builder() + } - fun matrixWithDisplayName(): NewPlanMatrixWithDisplayNamePrice? = matrixWithDisplayName + /** A builder for [RemovePrice]. */ + class Builder internal constructor() { - fun groupedTieredPackage(): NewPlanGroupedTieredPackagePrice? = groupedTieredPackage + private var priceId: JsonField? = null + private var planPhaseOrder: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - fun maxGroupTieredPackage(): NewPlanMaxGroupTieredPackagePrice? = maxGroupTieredPackage + internal fun from(removePrice: RemovePrice) = apply { + priceId = removePrice.priceId + planPhaseOrder = removePrice.planPhaseOrder + additionalProperties = removePrice.additionalProperties.toMutableMap() + } - fun scalableMatrixWithUnitPricing(): NewPlanScalableMatrixWithUnitPricingPrice? = - scalableMatrixWithUnitPricing + /** The id of the price to remove from the plan. */ + fun priceId(priceId: String) = priceId(JsonField.of(priceId)) - fun scalableMatrixWithTieredPricing(): NewPlanScalableMatrixWithTieredPricingPrice? = - scalableMatrixWithTieredPricing + /** + * Sets [Builder.priceId] to an arbitrary JSON value. + * + * You should usually call [Builder.priceId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun priceId(priceId: JsonField) = apply { this.priceId = priceId } - fun cumulativeGroupedBulk(): NewPlanCumulativeGroupedBulkPrice? = cumulativeGroupedBulk + /** The phase to remove this price from. */ + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) - fun minimum(): NewPlanMinimumCompositePrice? = minimum + /** + * Alias for [Builder.planPhaseOrder]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) - fun isUnit(): Boolean = unit != null + /** + * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. + * + * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun planPhaseOrder(planPhaseOrder: JsonField) = apply { + this.planPhaseOrder = planPhaseOrder + } - fun isTiered(): Boolean = tiered != null + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun isBulk(): Boolean = bulk != null + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun isPackage(): Boolean = package_ != null + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun isMatrix(): Boolean = matrix != null + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - fun isThresholdTotalAmount(): Boolean = thresholdTotalAmount != null + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - fun isTieredPackage(): Boolean = tieredPackage != null + /** + * Returns an immutable instance of [RemovePrice]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .priceId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): RemovePrice = + RemovePrice( + checkRequired("priceId", priceId), + planPhaseOrder, + additionalProperties.toMutableMap(), + ) + } - fun isTieredWithMinimum(): Boolean = tieredWithMinimum != null + private var validated: Boolean = false - fun isGroupedTiered(): Boolean = groupedTiered != null + fun validate(): RemovePrice = apply { + if (validated) { + return@apply + } - fun isTieredPackageWithMinimum(): Boolean = tieredPackageWithMinimum != null + priceId() + planPhaseOrder() + validated = true + } - fun isPackageWithAllocation(): Boolean = packageWithAllocation != null + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - fun isUnitWithPercent(): Boolean = unitWithPercent != null + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (priceId.asKnown() == null) 0 else 1) + + (if (planPhaseOrder.asKnown() == null) 0 else 1) - fun isMatrixWithAllocation(): Boolean = matrixWithAllocation != null + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun isTieredWithProration(): Boolean = tieredWithProration != null + return other is RemovePrice && + priceId == other.priceId && + planPhaseOrder == other.planPhaseOrder && + additionalProperties == other.additionalProperties + } - fun isUnitWithProration(): Boolean = unitWithProration != null + private val hashCode: Int by lazy { + Objects.hash(priceId, planPhaseOrder, additionalProperties) + } - fun isGroupedAllocation(): Boolean = groupedAllocation != null + override fun hashCode(): Int = hashCode - fun isBulkWithProration(): Boolean = bulkWithProration != null + override fun toString() = + "RemovePrice{priceId=$priceId, planPhaseOrder=$planPhaseOrder, additionalProperties=$additionalProperties}" + } - fun isGroupedWithProratedMinimum(): Boolean = groupedWithProratedMinimum != null + class ReplaceAdjustment + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val adjustment: JsonField, + private val replacesAdjustmentId: JsonField, + private val planPhaseOrder: JsonField, + private val additionalProperties: MutableMap, + ) { - fun isGroupedWithMeteredMinimum(): Boolean = groupedWithMeteredMinimum != null + @JsonCreator + private constructor( + @JsonProperty("adjustment") + @ExcludeMissing + adjustment: JsonField = JsonMissing.of(), + @JsonProperty("replaces_adjustment_id") + @ExcludeMissing + replacesAdjustmentId: JsonField = JsonMissing.of(), + @JsonProperty("plan_phase_order") + @ExcludeMissing + planPhaseOrder: JsonField = JsonMissing.of(), + ) : this(adjustment, replacesAdjustmentId, planPhaseOrder, mutableMapOf()) - fun isGroupedWithMinMaxThresholds(): Boolean = groupedWithMinMaxThresholds != null + /** + * The definition of a new adjustment to create and add to the plan. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun adjustment(): Adjustment = adjustment.getRequired("adjustment") - fun isMatrixWithDisplayName(): Boolean = matrixWithDisplayName != null + /** + * The id of the adjustment on the plan to replace in the plan. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun replacesAdjustmentId(): String = + replacesAdjustmentId.getRequired("replaces_adjustment_id") - fun isGroupedTieredPackage(): Boolean = groupedTieredPackage != null + /** + * The phase to replace this adjustment from. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun planPhaseOrder(): Long? = planPhaseOrder.getNullable("plan_phase_order") - fun isMaxGroupTieredPackage(): Boolean = maxGroupTieredPackage != null + /** + * Returns the raw JSON value of [adjustment]. + * + * Unlike [adjustment], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("adjustment") + @ExcludeMissing + fun _adjustment(): JsonField = adjustment - fun isScalableMatrixWithUnitPricing(): Boolean = scalableMatrixWithUnitPricing != null - - fun isScalableMatrixWithTieredPricing(): Boolean = - scalableMatrixWithTieredPricing != null + /** + * Returns the raw JSON value of [replacesAdjustmentId]. + * + * Unlike [replacesAdjustmentId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("replaces_adjustment_id") + @ExcludeMissing + fun _replacesAdjustmentId(): JsonField = replacesAdjustmentId - fun isCumulativeGroupedBulk(): Boolean = cumulativeGroupedBulk != null + /** + * Returns the raw JSON value of [planPhaseOrder]. + * + * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder - fun isMinimum(): Boolean = minimum != null + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - fun asUnit(): NewPlanUnitPrice = unit.getOrThrow("unit") + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - fun asTiered(): NewPlanTieredPrice = tiered.getOrThrow("tiered") + fun toBuilder() = Builder().from(this) - fun asBulk(): NewPlanBulkPrice = bulk.getOrThrow("bulk") + companion object { - fun asPackage(): NewPlanPackagePrice = package_.getOrThrow("package_") + /** + * Returns a mutable builder for constructing an instance of [ReplaceAdjustment]. + * + * The following fields are required: + * ```kotlin + * .adjustment() + * .replacesAdjustmentId() + * ``` + */ + fun builder() = Builder() + } - fun asMatrix(): NewPlanMatrixPrice = matrix.getOrThrow("matrix") + /** A builder for [ReplaceAdjustment]. */ + class Builder internal constructor() { - fun asThresholdTotalAmount(): NewPlanThresholdTotalAmountPrice = - thresholdTotalAmount.getOrThrow("thresholdTotalAmount") + private var adjustment: JsonField? = null + private var replacesAdjustmentId: JsonField? = null + private var planPhaseOrder: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - fun asTieredPackage(): NewPlanTieredPackagePrice = - tieredPackage.getOrThrow("tieredPackage") + internal fun from(replaceAdjustment: ReplaceAdjustment) = apply { + adjustment = replaceAdjustment.adjustment + replacesAdjustmentId = replaceAdjustment.replacesAdjustmentId + planPhaseOrder = replaceAdjustment.planPhaseOrder + additionalProperties = replaceAdjustment.additionalProperties.toMutableMap() + } - fun asTieredWithMinimum(): NewPlanTieredWithMinimumPrice = - tieredWithMinimum.getOrThrow("tieredWithMinimum") + /** The definition of a new adjustment to create and add to the plan. */ + fun adjustment(adjustment: Adjustment) = adjustment(JsonField.of(adjustment)) - fun asGroupedTiered(): NewPlanGroupedTieredPrice = - groupedTiered.getOrThrow("groupedTiered") + /** + * Sets [Builder.adjustment] to an arbitrary JSON value. + * + * You should usually call [Builder.adjustment] with a well-typed [Adjustment] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun adjustment(adjustment: JsonField) = apply { + this.adjustment = adjustment + } - fun asTieredPackageWithMinimum(): NewPlanTieredPackageWithMinimumPrice = - tieredPackageWithMinimum.getOrThrow("tieredPackageWithMinimum") + /** + * Alias for calling [adjustment] with + * `Adjustment.ofPercentageDiscount(percentageDiscount)`. + */ + fun adjustment(percentageDiscount: NewPercentageDiscount) = + adjustment(Adjustment.ofPercentageDiscount(percentageDiscount)) - fun asPackageWithAllocation(): NewPlanPackageWithAllocationPrice = - packageWithAllocation.getOrThrow("packageWithAllocation") + /** + * Alias for calling [adjustment] with the following: + * ```kotlin + * NewPercentageDiscount.builder() + * .adjustmentType(NewPercentageDiscount.AdjustmentType.PERCENTAGE_DISCOUNT) + * .percentageDiscount(percentageDiscount) + * .build() + * ``` + */ + fun percentageDiscountAdjustment(percentageDiscount: Double) = + adjustment( + NewPercentageDiscount.builder() + .adjustmentType(NewPercentageDiscount.AdjustmentType.PERCENTAGE_DISCOUNT) + .percentageDiscount(percentageDiscount) + .build() + ) - fun asUnitWithPercent(): NewPlanUnitWithPercentPrice = - unitWithPercent.getOrThrow("unitWithPercent") + /** Alias for calling [adjustment] with `Adjustment.ofUsageDiscount(usageDiscount)`. */ + fun adjustment(usageDiscount: NewUsageDiscount) = + adjustment(Adjustment.ofUsageDiscount(usageDiscount)) - fun asMatrixWithAllocation(): NewPlanMatrixWithAllocationPrice = - matrixWithAllocation.getOrThrow("matrixWithAllocation") + /** + * Alias for calling [adjustment] with the following: + * ```kotlin + * NewUsageDiscount.builder() + * .adjustmentType(NewUsageDiscount.AdjustmentType.USAGE_DISCOUNT) + * .usageDiscount(usageDiscount) + * .build() + * ``` + */ + fun usageDiscountAdjustment(usageDiscount: Double) = + adjustment( + NewUsageDiscount.builder() + .adjustmentType(NewUsageDiscount.AdjustmentType.USAGE_DISCOUNT) + .usageDiscount(usageDiscount) + .build() + ) - fun asTieredWithProration(): TieredWithProration = - tieredWithProration.getOrThrow("tieredWithProration") + /** + * Alias for calling [adjustment] with `Adjustment.ofAmountDiscount(amountDiscount)`. + */ + fun adjustment(amountDiscount: NewAmountDiscount) = + adjustment(Adjustment.ofAmountDiscount(amountDiscount)) - fun asUnitWithProration(): NewPlanUnitWithProrationPrice = - unitWithProration.getOrThrow("unitWithProration") + /** + * Alias for calling [adjustment] with the following: + * ```kotlin + * NewAmountDiscount.builder() + * .adjustmentType(NewAmountDiscount.AdjustmentType.AMOUNT_DISCOUNT) + * .amountDiscount(amountDiscount) + * .build() + * ``` + */ + fun amountDiscountAdjustment(amountDiscount: String) = + adjustment( + NewAmountDiscount.builder() + .adjustmentType(NewAmountDiscount.AdjustmentType.AMOUNT_DISCOUNT) + .amountDiscount(amountDiscount) + .build() + ) - fun asGroupedAllocation(): NewPlanGroupedAllocationPrice = - groupedAllocation.getOrThrow("groupedAllocation") + /** Alias for calling [adjustment] with `Adjustment.ofMinimum(minimum)`. */ + fun adjustment(minimum: NewMinimum) = adjustment(Adjustment.ofMinimum(minimum)) - fun asBulkWithProration(): NewPlanBulkWithProrationPrice = - bulkWithProration.getOrThrow("bulkWithProration") + /** Alias for calling [adjustment] with `Adjustment.ofMaximum(maximum)`. */ + fun adjustment(maximum: NewMaximum) = adjustment(Adjustment.ofMaximum(maximum)) - fun asGroupedWithProratedMinimum(): NewPlanGroupedWithProratedMinimumPrice = - groupedWithProratedMinimum.getOrThrow("groupedWithProratedMinimum") + /** + * Alias for calling [adjustment] with the following: + * ```kotlin + * NewMaximum.builder() + * .adjustmentType(NewMaximum.AdjustmentType.MAXIMUM) + * .maximumAmount(maximumAmount) + * .build() + * ``` + */ + fun maximumAdjustment(maximumAmount: String) = + adjustment( + NewMaximum.builder() + .adjustmentType(NewMaximum.AdjustmentType.MAXIMUM) + .maximumAmount(maximumAmount) + .build() + ) - fun asGroupedWithMeteredMinimum(): NewPlanGroupedWithMeteredMinimumPrice = - groupedWithMeteredMinimum.getOrThrow("groupedWithMeteredMinimum") + /** The id of the adjustment on the plan to replace in the plan. */ + fun replacesAdjustmentId(replacesAdjustmentId: String) = + replacesAdjustmentId(JsonField.of(replacesAdjustmentId)) - fun asGroupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds = - groupedWithMinMaxThresholds.getOrThrow("groupedWithMinMaxThresholds") + /** + * Sets [Builder.replacesAdjustmentId] to an arbitrary JSON value. + * + * You should usually call [Builder.replacesAdjustmentId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun replacesAdjustmentId(replacesAdjustmentId: JsonField) = apply { + this.replacesAdjustmentId = replacesAdjustmentId + } - fun asMatrixWithDisplayName(): NewPlanMatrixWithDisplayNamePrice = - matrixWithDisplayName.getOrThrow("matrixWithDisplayName") + /** The phase to replace this adjustment from. */ + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) - fun asGroupedTieredPackage(): NewPlanGroupedTieredPackagePrice = - groupedTieredPackage.getOrThrow("groupedTieredPackage") + /** + * Alias for [Builder.planPhaseOrder]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) - fun asMaxGroupTieredPackage(): NewPlanMaxGroupTieredPackagePrice = - maxGroupTieredPackage.getOrThrow("maxGroupTieredPackage") + /** + * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. + * + * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun planPhaseOrder(planPhaseOrder: JsonField) = apply { + this.planPhaseOrder = planPhaseOrder + } - fun asScalableMatrixWithUnitPricing(): NewPlanScalableMatrixWithUnitPricingPrice = - scalableMatrixWithUnitPricing.getOrThrow("scalableMatrixWithUnitPricing") + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun asScalableMatrixWithTieredPricing(): NewPlanScalableMatrixWithTieredPricingPrice = - scalableMatrixWithTieredPricing.getOrThrow("scalableMatrixWithTieredPricing") + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun asCumulativeGroupedBulk(): NewPlanCumulativeGroupedBulkPrice = - cumulativeGroupedBulk.getOrThrow("cumulativeGroupedBulk") + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun asMinimum(): NewPlanMinimumCompositePrice = minimum.getOrThrow("minimum") + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - fun _json(): JsonValue? = _json + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - bulk != null -> visitor.visitBulk(bulk) - package_ != null -> visitor.visitPackage(package_) - matrix != null -> visitor.visitMatrix(matrix) - thresholdTotalAmount != null -> - visitor.visitThresholdTotalAmount(thresholdTotalAmount) - tieredPackage != null -> visitor.visitTieredPackage(tieredPackage) - tieredWithMinimum != null -> visitor.visitTieredWithMinimum(tieredWithMinimum) - groupedTiered != null -> visitor.visitGroupedTiered(groupedTiered) - tieredPackageWithMinimum != null -> - visitor.visitTieredPackageWithMinimum(tieredPackageWithMinimum) - packageWithAllocation != null -> - visitor.visitPackageWithAllocation(packageWithAllocation) - unitWithPercent != null -> visitor.visitUnitWithPercent(unitWithPercent) - matrixWithAllocation != null -> - visitor.visitMatrixWithAllocation(matrixWithAllocation) - tieredWithProration != null -> - visitor.visitTieredWithProration(tieredWithProration) - unitWithProration != null -> visitor.visitUnitWithProration(unitWithProration) - groupedAllocation != null -> visitor.visitGroupedAllocation(groupedAllocation) - bulkWithProration != null -> visitor.visitBulkWithProration(bulkWithProration) - groupedWithProratedMinimum != null -> - visitor.visitGroupedWithProratedMinimum(groupedWithProratedMinimum) - groupedWithMeteredMinimum != null -> - visitor.visitGroupedWithMeteredMinimum(groupedWithMeteredMinimum) - groupedWithMinMaxThresholds != null -> - visitor.visitGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds) - matrixWithDisplayName != null -> - visitor.visitMatrixWithDisplayName(matrixWithDisplayName) - groupedTieredPackage != null -> - visitor.visitGroupedTieredPackage(groupedTieredPackage) - maxGroupTieredPackage != null -> - visitor.visitMaxGroupTieredPackage(maxGroupTieredPackage) - scalableMatrixWithUnitPricing != null -> - visitor.visitScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing) - scalableMatrixWithTieredPricing != null -> - visitor.visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing - ) - cumulativeGroupedBulk != null -> - visitor.visitCumulativeGroupedBulk(cumulativeGroupedBulk) - minimum != null -> visitor.visitMinimum(minimum) - else -> visitor.unknown(_json) - } + /** + * Returns an immutable instance of [ReplaceAdjustment]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .adjustment() + * .replacesAdjustmentId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ReplaceAdjustment = + ReplaceAdjustment( + checkRequired("adjustment", adjustment), + checkRequired("replacesAdjustmentId", replacesAdjustmentId), + planPhaseOrder, + additionalProperties.toMutableMap(), + ) + } - private var validated: Boolean = false + private var validated: Boolean = false - fun validate(): Price = apply { - if (validated) { - return@apply - } + fun validate(): ReplaceAdjustment = apply { + if (validated) { + return@apply + } - accept( - object : Visitor { - override fun visitUnit(unit: NewPlanUnitPrice) { - unit.validate() - } + adjustment().validate() + replacesAdjustmentId() + planPhaseOrder() + validated = true + } - override fun visitTiered(tiered: NewPlanTieredPrice) { - tiered.validate() - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - override fun visitBulk(bulk: NewPlanBulkPrice) { - bulk.validate() - } + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (adjustment.asKnown()?.validity() ?: 0) + + (if (replacesAdjustmentId.asKnown() == null) 0 else 1) + + (if (planPhaseOrder.asKnown() == null) 0 else 1) - override fun visitPackage(package_: NewPlanPackagePrice) { - package_.validate() - } + /** The definition of a new adjustment to create and add to the plan. */ + @JsonDeserialize(using = Adjustment.Deserializer::class) + @JsonSerialize(using = Adjustment.Serializer::class) + class Adjustment + private constructor( + private val percentageDiscount: NewPercentageDiscount? = null, + private val usageDiscount: NewUsageDiscount? = null, + private val amountDiscount: NewAmountDiscount? = null, + private val minimum: NewMinimum? = null, + private val maximum: NewMaximum? = null, + private val _json: JsonValue? = null, + ) { - override fun visitMatrix(matrix: NewPlanMatrixPrice) { - matrix.validate() - } + fun percentageDiscount(): NewPercentageDiscount? = percentageDiscount - override fun visitThresholdTotalAmount( - thresholdTotalAmount: NewPlanThresholdTotalAmountPrice - ) { - thresholdTotalAmount.validate() - } + fun usageDiscount(): NewUsageDiscount? = usageDiscount - override fun visitTieredPackage(tieredPackage: NewPlanTieredPackagePrice) { - tieredPackage.validate() - } + fun amountDiscount(): NewAmountDiscount? = amountDiscount - override fun visitTieredWithMinimum( - tieredWithMinimum: NewPlanTieredWithMinimumPrice - ) { - tieredWithMinimum.validate() - } + fun minimum(): NewMinimum? = minimum - override fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) { - groupedTiered.validate() - } + fun maximum(): NewMaximum? = maximum - override fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice - ) { - tieredPackageWithMinimum.validate() - } + fun isPercentageDiscount(): Boolean = percentageDiscount != null - override fun visitPackageWithAllocation( - packageWithAllocation: NewPlanPackageWithAllocationPrice - ) { - packageWithAllocation.validate() - } + fun isUsageDiscount(): Boolean = usageDiscount != null - override fun visitUnitWithPercent( - unitWithPercent: NewPlanUnitWithPercentPrice - ) { - unitWithPercent.validate() - } + fun isAmountDiscount(): Boolean = amountDiscount != null - override fun visitMatrixWithAllocation( - matrixWithAllocation: NewPlanMatrixWithAllocationPrice - ) { - matrixWithAllocation.validate() - } + fun isMinimum(): Boolean = minimum != null - override fun visitTieredWithProration( - tieredWithProration: TieredWithProration - ) { - tieredWithProration.validate() - } + fun isMaximum(): Boolean = maximum != null - override fun visitUnitWithProration( - unitWithProration: NewPlanUnitWithProrationPrice - ) { - unitWithProration.validate() - } + fun asPercentageDiscount(): NewPercentageDiscount = + percentageDiscount.getOrThrow("percentageDiscount") - override fun visitGroupedAllocation( - groupedAllocation: NewPlanGroupedAllocationPrice - ) { - groupedAllocation.validate() - } + fun asUsageDiscount(): NewUsageDiscount = usageDiscount.getOrThrow("usageDiscount") - override fun visitBulkWithProration( - bulkWithProration: NewPlanBulkWithProrationPrice - ) { - bulkWithProration.validate() - } + fun asAmountDiscount(): NewAmountDiscount = amountDiscount.getOrThrow("amountDiscount") - override fun visitGroupedWithProratedMinimum( - groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice - ) { - groupedWithProratedMinimum.validate() - } + fun asMinimum(): NewMinimum = minimum.getOrThrow("minimum") - override fun visitGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice - ) { - groupedWithMeteredMinimum.validate() - } + fun asMaximum(): NewMaximum = maximum.getOrThrow("maximum") - override fun visitGroupedWithMinMaxThresholds( - groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds - ) { - groupedWithMinMaxThresholds.validate() - } + fun _json(): JsonValue? = _json - override fun visitMatrixWithDisplayName( - matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice - ) { - matrixWithDisplayName.validate() - } + fun accept(visitor: Visitor): T = + when { + percentageDiscount != null -> + visitor.visitPercentageDiscount(percentageDiscount) + usageDiscount != null -> visitor.visitUsageDiscount(usageDiscount) + amountDiscount != null -> visitor.visitAmountDiscount(amountDiscount) + minimum != null -> visitor.visitMinimum(minimum) + maximum != null -> visitor.visitMaximum(maximum) + else -> visitor.unknown(_json) + } - override fun visitGroupedTieredPackage( - groupedTieredPackage: NewPlanGroupedTieredPackagePrice + private var validated: Boolean = false + + fun validate(): Adjustment = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitPercentageDiscount( + percentageDiscount: NewPercentageDiscount ) { - groupedTieredPackage.validate() + percentageDiscount.validate() } - override fun visitMaxGroupTieredPackage( - maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice - ) { - maxGroupTieredPackage.validate() + override fun visitUsageDiscount(usageDiscount: NewUsageDiscount) { + usageDiscount.validate() } - override fun visitScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice - ) { - scalableMatrixWithUnitPricing.validate() + override fun visitAmountDiscount(amountDiscount: NewAmountDiscount) { + amountDiscount.validate() } - override fun visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: - NewPlanScalableMatrixWithTieredPricingPrice - ) { - scalableMatrixWithTieredPricing.validate() + override fun visitMinimum(minimum: NewMinimum) { + minimum.validate() } - override fun visitCumulativeGroupedBulk( - cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice - ) { - cumulativeGroupedBulk.validate() - } - - override fun visitMinimum(minimum: NewPlanMinimumCompositePrice) { - minimum.validate() + override fun visitMaximum(maximum: NewMaximum) { + maximum.validate() } } ) @@ -8559,102 +9114,19 @@ private constructor( internal fun validity(): Int = accept( object : Visitor { - override fun visitUnit(unit: NewPlanUnitPrice) = unit.validity() - - override fun visitTiered(tiered: NewPlanTieredPrice) = tiered.validity() - - override fun visitBulk(bulk: NewPlanBulkPrice) = bulk.validity() - - override fun visitPackage(package_: NewPlanPackagePrice) = - package_.validity() - - override fun visitMatrix(matrix: NewPlanMatrixPrice) = matrix.validity() - - override fun visitThresholdTotalAmount( - thresholdTotalAmount: NewPlanThresholdTotalAmountPrice - ) = thresholdTotalAmount.validity() - - override fun visitTieredPackage(tieredPackage: NewPlanTieredPackagePrice) = - tieredPackage.validity() - - override fun visitTieredWithMinimum( - tieredWithMinimum: NewPlanTieredWithMinimumPrice - ) = tieredWithMinimum.validity() - - override fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) = - groupedTiered.validity() - - override fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice - ) = tieredPackageWithMinimum.validity() - - override fun visitPackageWithAllocation( - packageWithAllocation: NewPlanPackageWithAllocationPrice - ) = packageWithAllocation.validity() - - override fun visitUnitWithPercent( - unitWithPercent: NewPlanUnitWithPercentPrice - ) = unitWithPercent.validity() - - override fun visitMatrixWithAllocation( - matrixWithAllocation: NewPlanMatrixWithAllocationPrice - ) = matrixWithAllocation.validity() - - override fun visitTieredWithProration( - tieredWithProration: TieredWithProration - ) = tieredWithProration.validity() - - override fun visitUnitWithProration( - unitWithProration: NewPlanUnitWithProrationPrice - ) = unitWithProration.validity() - - override fun visitGroupedAllocation( - groupedAllocation: NewPlanGroupedAllocationPrice - ) = groupedAllocation.validity() - - override fun visitBulkWithProration( - bulkWithProration: NewPlanBulkWithProrationPrice - ) = bulkWithProration.validity() - - override fun visitGroupedWithProratedMinimum( - groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice - ) = groupedWithProratedMinimum.validity() - - override fun visitGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice - ) = groupedWithMeteredMinimum.validity() - - override fun visitGroupedWithMinMaxThresholds( - groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds - ) = groupedWithMinMaxThresholds.validity() - - override fun visitMatrixWithDisplayName( - matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice - ) = matrixWithDisplayName.validity() - - override fun visitGroupedTieredPackage( - groupedTieredPackage: NewPlanGroupedTieredPackagePrice - ) = groupedTieredPackage.validity() - - override fun visitMaxGroupTieredPackage( - maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice - ) = maxGroupTieredPackage.validity() + override fun visitPercentageDiscount( + percentageDiscount: NewPercentageDiscount + ) = percentageDiscount.validity() - override fun visitScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice - ) = scalableMatrixWithUnitPricing.validity() + override fun visitUsageDiscount(usageDiscount: NewUsageDiscount) = + usageDiscount.validity() - override fun visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: - NewPlanScalableMatrixWithTieredPricingPrice - ) = scalableMatrixWithTieredPricing.validity() + override fun visitAmountDiscount(amountDiscount: NewAmountDiscount) = + amountDiscount.validity() - override fun visitCumulativeGroupedBulk( - cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice - ) = cumulativeGroupedBulk.validity() + override fun visitMinimum(minimum: NewMinimum) = minimum.validity() - override fun visitMinimum(minimum: NewPlanMinimumCompositePrice) = - minimum.validity() + override fun visitMaximum(maximum: NewMaximum) = maximum.validity() override fun unknown(json: JsonValue?) = 0 } @@ -8665,572 +9137,3500 @@ private constructor( return true } - return other is Price && - unit == other.unit && - tiered == other.tiered && - bulk == other.bulk && - package_ == other.package_ && - matrix == other.matrix && - thresholdTotalAmount == other.thresholdTotalAmount && - tieredPackage == other.tieredPackage && - tieredWithMinimum == other.tieredWithMinimum && - groupedTiered == other.groupedTiered && - tieredPackageWithMinimum == other.tieredPackageWithMinimum && - packageWithAllocation == other.packageWithAllocation && - unitWithPercent == other.unitWithPercent && - matrixWithAllocation == other.matrixWithAllocation && - tieredWithProration == other.tieredWithProration && - unitWithProration == other.unitWithProration && - groupedAllocation == other.groupedAllocation && - bulkWithProration == other.bulkWithProration && - groupedWithProratedMinimum == other.groupedWithProratedMinimum && - groupedWithMeteredMinimum == other.groupedWithMeteredMinimum && - groupedWithMinMaxThresholds == other.groupedWithMinMaxThresholds && - matrixWithDisplayName == other.matrixWithDisplayName && - groupedTieredPackage == other.groupedTieredPackage && - maxGroupTieredPackage == other.maxGroupTieredPackage && - scalableMatrixWithUnitPricing == other.scalableMatrixWithUnitPricing && - scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && - cumulativeGroupedBulk == other.cumulativeGroupedBulk && - minimum == other.minimum + return other is Adjustment && + percentageDiscount == other.percentageDiscount && + usageDiscount == other.usageDiscount && + amountDiscount == other.amountDiscount && + minimum == other.minimum && + maximum == other.maximum } override fun hashCode(): Int = - Objects.hash( - unit, - tiered, - bulk, - package_, - matrix, - thresholdTotalAmount, - tieredPackage, - tieredWithMinimum, - groupedTiered, - tieredPackageWithMinimum, - packageWithAllocation, - unitWithPercent, - matrixWithAllocation, - tieredWithProration, - unitWithProration, - groupedAllocation, - bulkWithProration, - groupedWithProratedMinimum, - groupedWithMeteredMinimum, - groupedWithMinMaxThresholds, - matrixWithDisplayName, - groupedTieredPackage, - maxGroupTieredPackage, - scalableMatrixWithUnitPricing, - scalableMatrixWithTieredPricing, - cumulativeGroupedBulk, - minimum, - ) + Objects.hash(percentageDiscount, usageDiscount, amountDiscount, minimum, maximum) override fun toString(): String = when { - unit != null -> "Price{unit=$unit}" - tiered != null -> "Price{tiered=$tiered}" - bulk != null -> "Price{bulk=$bulk}" - package_ != null -> "Price{package_=$package_}" - matrix != null -> "Price{matrix=$matrix}" - thresholdTotalAmount != null -> - "Price{thresholdTotalAmount=$thresholdTotalAmount}" - tieredPackage != null -> "Price{tieredPackage=$tieredPackage}" - tieredWithMinimum != null -> "Price{tieredWithMinimum=$tieredWithMinimum}" - groupedTiered != null -> "Price{groupedTiered=$groupedTiered}" - tieredPackageWithMinimum != null -> - "Price{tieredPackageWithMinimum=$tieredPackageWithMinimum}" - packageWithAllocation != null -> - "Price{packageWithAllocation=$packageWithAllocation}" - unitWithPercent != null -> "Price{unitWithPercent=$unitWithPercent}" - matrixWithAllocation != null -> - "Price{matrixWithAllocation=$matrixWithAllocation}" - tieredWithProration != null -> "Price{tieredWithProration=$tieredWithProration}" - unitWithProration != null -> "Price{unitWithProration=$unitWithProration}" - groupedAllocation != null -> "Price{groupedAllocation=$groupedAllocation}" - bulkWithProration != null -> "Price{bulkWithProration=$bulkWithProration}" - groupedWithProratedMinimum != null -> - "Price{groupedWithProratedMinimum=$groupedWithProratedMinimum}" - groupedWithMeteredMinimum != null -> - "Price{groupedWithMeteredMinimum=$groupedWithMeteredMinimum}" - groupedWithMinMaxThresholds != null -> - "Price{groupedWithMinMaxThresholds=$groupedWithMinMaxThresholds}" - matrixWithDisplayName != null -> - "Price{matrixWithDisplayName=$matrixWithDisplayName}" - groupedTieredPackage != null -> - "Price{groupedTieredPackage=$groupedTieredPackage}" - maxGroupTieredPackage != null -> - "Price{maxGroupTieredPackage=$maxGroupTieredPackage}" - scalableMatrixWithUnitPricing != null -> - "Price{scalableMatrixWithUnitPricing=$scalableMatrixWithUnitPricing}" - scalableMatrixWithTieredPricing != null -> - "Price{scalableMatrixWithTieredPricing=$scalableMatrixWithTieredPricing}" - cumulativeGroupedBulk != null -> - "Price{cumulativeGroupedBulk=$cumulativeGroupedBulk}" - minimum != null -> "Price{minimum=$minimum}" - _json != null -> "Price{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Price") + percentageDiscount != null -> + "Adjustment{percentageDiscount=$percentageDiscount}" + usageDiscount != null -> "Adjustment{usageDiscount=$usageDiscount}" + amountDiscount != null -> "Adjustment{amountDiscount=$amountDiscount}" + minimum != null -> "Adjustment{minimum=$minimum}" + maximum != null -> "Adjustment{maximum=$maximum}" + _json != null -> "Adjustment{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Adjustment") } companion object { - fun ofUnit(unit: NewPlanUnitPrice) = Price(unit = unit) + fun ofPercentageDiscount(percentageDiscount: NewPercentageDiscount) = + Adjustment(percentageDiscount = percentageDiscount) - fun ofTiered(tiered: NewPlanTieredPrice) = Price(tiered = tiered) + fun ofUsageDiscount(usageDiscount: NewUsageDiscount) = + Adjustment(usageDiscount = usageDiscount) - fun ofBulk(bulk: NewPlanBulkPrice) = Price(bulk = bulk) + fun ofAmountDiscount(amountDiscount: NewAmountDiscount) = + Adjustment(amountDiscount = amountDiscount) - fun ofPackage(package_: NewPlanPackagePrice) = Price(package_ = package_) + fun ofMinimum(minimum: NewMinimum) = Adjustment(minimum = minimum) - fun ofMatrix(matrix: NewPlanMatrixPrice) = Price(matrix = matrix) + fun ofMaximum(maximum: NewMaximum) = Adjustment(maximum = maximum) + } - fun ofThresholdTotalAmount(thresholdTotalAmount: NewPlanThresholdTotalAmountPrice) = - Price(thresholdTotalAmount = thresholdTotalAmount) + /** + * An interface that defines how to map each variant of [Adjustment] to a value of type + * [T]. + */ + interface Visitor { - fun ofTieredPackage(tieredPackage: NewPlanTieredPackagePrice) = - Price(tieredPackage = tieredPackage) + fun visitPercentageDiscount(percentageDiscount: NewPercentageDiscount): T - fun ofTieredWithMinimum(tieredWithMinimum: NewPlanTieredWithMinimumPrice) = - Price(tieredWithMinimum = tieredWithMinimum) + fun visitUsageDiscount(usageDiscount: NewUsageDiscount): T - fun ofGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) = - Price(groupedTiered = groupedTiered) + fun visitAmountDiscount(amountDiscount: NewAmountDiscount): T - fun ofTieredPackageWithMinimum( - tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice - ) = Price(tieredPackageWithMinimum = tieredPackageWithMinimum) + fun visitMinimum(minimum: NewMinimum): T - fun ofPackageWithAllocation( - packageWithAllocation: NewPlanPackageWithAllocationPrice - ) = Price(packageWithAllocation = packageWithAllocation) + fun visitMaximum(maximum: NewMaximum): T - fun ofUnitWithPercent(unitWithPercent: NewPlanUnitWithPercentPrice) = - Price(unitWithPercent = unitWithPercent) + /** + * Maps an unknown variant of [Adjustment] to a value of type [T]. + * + * An instance of [Adjustment] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the + * SDK is unaware of. + * + * @throws OrbInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw OrbInvalidDataException("Unknown Adjustment: $json") + } + } - fun ofMatrixWithAllocation(matrixWithAllocation: NewPlanMatrixWithAllocationPrice) = - Price(matrixWithAllocation = matrixWithAllocation) + internal class Deserializer : BaseDeserializer(Adjustment::class) { - fun ofTieredWithProration(tieredWithProration: TieredWithProration) = - Price(tieredWithProration = tieredWithProration) + override fun ObjectCodec.deserialize(node: JsonNode): Adjustment { + val json = JsonValue.fromJsonNode(node) + val adjustmentType = json.asObject()?.get("adjustment_type")?.asString() - fun ofUnitWithProration(unitWithProration: NewPlanUnitWithProrationPrice) = - Price(unitWithProration = unitWithProration) + when (adjustmentType) { + "percentage_discount" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Adjustment(percentageDiscount = it, _json = json) } + ?: Adjustment(_json = json) + } + "usage_discount" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(usageDiscount = it, _json = json) + } ?: Adjustment(_json = json) + } + "amount_discount" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(amountDiscount = it, _json = json) + } ?: Adjustment(_json = json) + } + "minimum" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(minimum = it, _json = json) + } ?: Adjustment(_json = json) + } + "maximum" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(maximum = it, _json = json) + } ?: Adjustment(_json = json) + } + } - fun ofGroupedAllocation(groupedAllocation: NewPlanGroupedAllocationPrice) = - Price(groupedAllocation = groupedAllocation) + return Adjustment(_json = json) + } + } - fun ofBulkWithProration(bulkWithProration: NewPlanBulkWithProrationPrice) = - Price(bulkWithProration = bulkWithProration) + internal class Serializer : BaseSerializer(Adjustment::class) { - fun ofGroupedWithProratedMinimum( - groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice - ) = Price(groupedWithProratedMinimum = groupedWithProratedMinimum) + override fun serialize( + value: Adjustment, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.percentageDiscount != null -> + generator.writeObject(value.percentageDiscount) + value.usageDiscount != null -> generator.writeObject(value.usageDiscount) + value.amountDiscount != null -> generator.writeObject(value.amountDiscount) + value.minimum != null -> generator.writeObject(value.minimum) + value.maximum != null -> generator.writeObject(value.maximum) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Adjustment") + } + } + } + } - fun ofGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice - ) = Price(groupedWithMeteredMinimum = groupedWithMeteredMinimum) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun ofGroupedWithMinMaxThresholds( - groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds - ) = Price(groupedWithMinMaxThresholds = groupedWithMinMaxThresholds) + return other is ReplaceAdjustment && + adjustment == other.adjustment && + replacesAdjustmentId == other.replacesAdjustmentId && + planPhaseOrder == other.planPhaseOrder && + additionalProperties == other.additionalProperties + } - fun ofMatrixWithDisplayName( - matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice - ) = Price(matrixWithDisplayName = matrixWithDisplayName) + private val hashCode: Int by lazy { + Objects.hash(adjustment, replacesAdjustmentId, planPhaseOrder, additionalProperties) + } - fun ofGroupedTieredPackage(groupedTieredPackage: NewPlanGroupedTieredPackagePrice) = - Price(groupedTieredPackage = groupedTieredPackage) + override fun hashCode(): Int = hashCode - fun ofMaxGroupTieredPackage( - maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice - ) = Price(maxGroupTieredPackage = maxGroupTieredPackage) + override fun toString() = + "ReplaceAdjustment{adjustment=$adjustment, replacesAdjustmentId=$replacesAdjustmentId, planPhaseOrder=$planPhaseOrder, additionalProperties=$additionalProperties}" + } - fun ofScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice - ) = Price(scalableMatrixWithUnitPricing = scalableMatrixWithUnitPricing) + class ReplacePrice + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val replacesPriceId: JsonField, + private val allocationPrice: JsonField, + private val planPhaseOrder: JsonField, + private val price: JsonField, + private val additionalProperties: MutableMap, + ) { - fun ofScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: NewPlanScalableMatrixWithTieredPricingPrice - ) = Price(scalableMatrixWithTieredPricing = scalableMatrixWithTieredPricing) + @JsonCreator + private constructor( + @JsonProperty("replaces_price_id") + @ExcludeMissing + replacesPriceId: JsonField = JsonMissing.of(), + @JsonProperty("allocation_price") + @ExcludeMissing + allocationPrice: JsonField = JsonMissing.of(), + @JsonProperty("plan_phase_order") + @ExcludeMissing + planPhaseOrder: JsonField = JsonMissing.of(), + @JsonProperty("price") @ExcludeMissing price: JsonField = JsonMissing.of(), + ) : this(replacesPriceId, allocationPrice, planPhaseOrder, price, mutableMapOf()) - fun ofCumulativeGroupedBulk( - cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice - ) = Price(cumulativeGroupedBulk = cumulativeGroupedBulk) + /** + * The id of the price on the plan to replace in the plan. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun replacesPriceId(): String = replacesPriceId.getRequired("replaces_price_id") - fun ofMinimum(minimum: NewPlanMinimumCompositePrice) = Price(minimum = minimum) - } + /** + * The allocation price to add to the plan. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun allocationPrice(): NewAllocationPrice? = allocationPrice.getNullable("allocation_price") - /** - * An interface that defines how to map each variant of [Price] to a value of type [T]. - */ - interface Visitor { + /** + * The phase to replace this price from. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun planPhaseOrder(): Long? = planPhaseOrder.getNullable("plan_phase_order") - fun visitUnit(unit: NewPlanUnitPrice): T + /** + * New plan price request body params. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun price(): Price? = price.getNullable("price") - fun visitTiered(tiered: NewPlanTieredPrice): T + /** + * Returns the raw JSON value of [replacesPriceId]. + * + * Unlike [replacesPriceId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("replaces_price_id") + @ExcludeMissing + fun _replacesPriceId(): JsonField = replacesPriceId - fun visitBulk(bulk: NewPlanBulkPrice): T + /** + * Returns the raw JSON value of [allocationPrice]. + * + * Unlike [allocationPrice], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("allocation_price") + @ExcludeMissing + fun _allocationPrice(): JsonField = allocationPrice - fun visitPackage(package_: NewPlanPackagePrice): T + /** + * Returns the raw JSON value of [planPhaseOrder]. + * + * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder - fun visitMatrix(matrix: NewPlanMatrixPrice): T + /** + * Returns the raw JSON value of [price]. + * + * Unlike [price], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("price") @ExcludeMissing fun _price(): JsonField = price - fun visitThresholdTotalAmount( - thresholdTotalAmount: NewPlanThresholdTotalAmountPrice - ): T + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - fun visitTieredPackage(tieredPackage: NewPlanTieredPackagePrice): T + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - fun visitTieredWithMinimum(tieredWithMinimum: NewPlanTieredWithMinimumPrice): T + fun toBuilder() = Builder().from(this) - fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice): T + companion object { - fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice - ): T + /** + * Returns a mutable builder for constructing an instance of [ReplacePrice]. + * + * The following fields are required: + * ```kotlin + * .replacesPriceId() + * ``` + */ + fun builder() = Builder() + } - fun visitPackageWithAllocation( - packageWithAllocation: NewPlanPackageWithAllocationPrice - ): T + /** A builder for [ReplacePrice]. */ + class Builder internal constructor() { - fun visitUnitWithPercent(unitWithPercent: NewPlanUnitWithPercentPrice): T + private var replacesPriceId: JsonField? = null + private var allocationPrice: JsonField = JsonMissing.of() + private var planPhaseOrder: JsonField = JsonMissing.of() + private var price: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - fun visitMatrixWithAllocation( - matrixWithAllocation: NewPlanMatrixWithAllocationPrice - ): T + internal fun from(replacePrice: ReplacePrice) = apply { + replacesPriceId = replacePrice.replacesPriceId + allocationPrice = replacePrice.allocationPrice + planPhaseOrder = replacePrice.planPhaseOrder + price = replacePrice.price + additionalProperties = replacePrice.additionalProperties.toMutableMap() + } - fun visitTieredWithProration(tieredWithProration: TieredWithProration): T + /** The id of the price on the plan to replace in the plan. */ + fun replacesPriceId(replacesPriceId: String) = + replacesPriceId(JsonField.of(replacesPriceId)) - fun visitUnitWithProration(unitWithProration: NewPlanUnitWithProrationPrice): T + /** + * Sets [Builder.replacesPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.replacesPriceId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun replacesPriceId(replacesPriceId: JsonField) = apply { + this.replacesPriceId = replacesPriceId + } - fun visitGroupedAllocation(groupedAllocation: NewPlanGroupedAllocationPrice): T + /** The allocation price to add to the plan. */ + fun allocationPrice(allocationPrice: NewAllocationPrice?) = + allocationPrice(JsonField.ofNullable(allocationPrice)) - fun visitBulkWithProration(bulkWithProration: NewPlanBulkWithProrationPrice): T + /** + * Sets [Builder.allocationPrice] to an arbitrary JSON value. + * + * You should usually call [Builder.allocationPrice] with a well-typed + * [NewAllocationPrice] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun allocationPrice(allocationPrice: JsonField) = apply { + this.allocationPrice = allocationPrice + } - fun visitGroupedWithProratedMinimum( - groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice - ): T + /** The phase to replace this price from. */ + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) - fun visitGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice - ): T + /** + * Alias for [Builder.planPhaseOrder]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) - fun visitGroupedWithMinMaxThresholds( - groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds - ): T + /** + * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. + * + * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun planPhaseOrder(planPhaseOrder: JsonField) = apply { + this.planPhaseOrder = planPhaseOrder + } - fun visitMatrixWithDisplayName( - matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice - ): T + /** New plan price request body params. */ + fun price(price: Price?) = price(JsonField.ofNullable(price)) - fun visitGroupedTieredPackage( - groupedTieredPackage: NewPlanGroupedTieredPackagePrice - ): T + /** + * Sets [Builder.price] to an arbitrary JSON value. + * + * You should usually call [Builder.price] with a well-typed [Price] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun price(price: JsonField) = apply { this.price = price } - fun visitMaxGroupTieredPackage( - maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice - ): T + /** Alias for calling [price] with `Price.ofUnit(unit)`. */ + fun price(unit: NewPlanUnitPrice) = price(Price.ofUnit(unit)) - fun visitScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice - ): T + /** Alias for calling [price] with `Price.ofTiered(tiered)`. */ + fun price(tiered: NewPlanTieredPrice) = price(Price.ofTiered(tiered)) - fun visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: NewPlanScalableMatrixWithTieredPricingPrice - ): T + /** Alias for calling [price] with `Price.ofBulk(bulk)`. */ + fun price(bulk: NewPlanBulkPrice) = price(Price.ofBulk(bulk)) - fun visitCumulativeGroupedBulk( - cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice - ): T + /** Alias for calling [price] with `Price.ofPackage(package_)`. */ + fun price(package_: NewPlanPackagePrice) = price(Price.ofPackage(package_)) - fun visitMinimum(minimum: NewPlanMinimumCompositePrice): T + /** Alias for calling [price] with `Price.ofMatrix(matrix)`. */ + fun price(matrix: NewPlanMatrixPrice) = price(Price.ofMatrix(matrix)) - /** - * Maps an unknown variant of [Price] to a value of type [T]. - * - * An instance of [Price] can contain an unknown variant if it was deserialized from - * data that doesn't match any known variant. For example, if the SDK is on an older - * version than the API, then the API may respond with new variants that the SDK is - * unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown Price: $json") - } - } + /** + * Alias for calling [price] with `Price.ofThresholdTotalAmount(thresholdTotalAmount)`. + */ + fun price(thresholdTotalAmount: NewPlanThresholdTotalAmountPrice) = + price(Price.ofThresholdTotalAmount(thresholdTotalAmount)) - internal class Deserializer : BaseDeserializer(Price::class) { + /** Alias for calling [price] with `Price.ofTieredPackage(tieredPackage)`. */ + fun price(tieredPackage: NewPlanTieredPackagePrice) = + price(Price.ofTieredPackage(tieredPackage)) - override fun ObjectCodec.deserialize(node: JsonNode): Price { - val json = JsonValue.fromJsonNode(node) - val modelType = json.asObject()?.get("model_type")?.asString() + /** Alias for calling [price] with `Price.ofTieredWithMinimum(tieredWithMinimum)`. */ + fun price(tieredWithMinimum: NewPlanTieredWithMinimumPrice) = + price(Price.ofTieredWithMinimum(tieredWithMinimum)) - when (modelType) { - "unit" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(unit = it, _json = json) - } ?: Price(_json = json) - } - "tiered" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(tiered = it, _json = json) - } ?: Price(_json = json) - } - "bulk" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(bulk = it, _json = json) - } ?: Price(_json = json) - } - "package" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(package_ = it, _json = json) } ?: Price(_json = json) - } - "matrix" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(matrix = it, _json = json) - } ?: Price(_json = json) - } - "threshold_total_amount" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(thresholdTotalAmount = it, _json = json) } - ?: Price(_json = json) - } - "tiered_package" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(tieredPackage = it, _json = json) } - ?: Price(_json = json) - } - "tiered_with_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(tieredWithMinimum = it, _json = json) } - ?: Price(_json = json) - } - "grouped_tiered" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(groupedTiered = it, _json = json) } - ?: Price(_json = json) - } - "tiered_package_with_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(tieredPackageWithMinimum = it, _json = json) } - ?: Price(_json = json) - } - "package_with_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(packageWithAllocation = it, _json = json) } - ?: Price(_json = json) - } - "unit_with_percent" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(unitWithPercent = it, _json = json) } - ?: Price(_json = json) - } - "matrix_with_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(matrixWithAllocation = it, _json = json) } - ?: Price(_json = json) - } - "tiered_with_proration" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(tieredWithProration = it, _json = json) } - ?: Price(_json = json) - } - "unit_with_proration" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(unitWithProration = it, _json = json) } - ?: Price(_json = json) - } - "grouped_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedAllocation = it, _json = json) } - ?: Price(_json = json) - } - "bulk_with_proration" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(bulkWithProration = it, _json = json) } - ?: Price(_json = json) - } - "grouped_with_prorated_minimum" -> { - return tryDeserialize( - node, + /** Alias for calling [price] with `Price.ofGroupedTiered(groupedTiered)`. */ + fun price(groupedTiered: NewPlanGroupedTieredPrice) = + price(Price.ofGroupedTiered(groupedTiered)) + + /** + * Alias for calling [price] with + * `Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)`. + */ + fun price(tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice) = + price(Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)) + + /** + * Alias for calling [price] with + * `Price.ofPackageWithAllocation(packageWithAllocation)`. + */ + fun price(packageWithAllocation: NewPlanPackageWithAllocationPrice) = + price(Price.ofPackageWithAllocation(packageWithAllocation)) + + /** Alias for calling [price] with `Price.ofUnitWithPercent(unitWithPercent)`. */ + fun price(unitWithPercent: NewPlanUnitWithPercentPrice) = + price(Price.ofUnitWithPercent(unitWithPercent)) + + /** + * Alias for calling [price] with `Price.ofMatrixWithAllocation(matrixWithAllocation)`. + */ + fun price(matrixWithAllocation: NewPlanMatrixWithAllocationPrice) = + price(Price.ofMatrixWithAllocation(matrixWithAllocation)) + + /** + * Alias for calling [price] with `Price.ofTieredWithProration(tieredWithProration)`. + */ + fun price(tieredWithProration: Price.TieredWithProration) = + price(Price.ofTieredWithProration(tieredWithProration)) + + /** Alias for calling [price] with `Price.ofUnitWithProration(unitWithProration)`. */ + fun price(unitWithProration: NewPlanUnitWithProrationPrice) = + price(Price.ofUnitWithProration(unitWithProration)) + + /** Alias for calling [price] with `Price.ofGroupedAllocation(groupedAllocation)`. */ + fun price(groupedAllocation: NewPlanGroupedAllocationPrice) = + price(Price.ofGroupedAllocation(groupedAllocation)) + + /** Alias for calling [price] with `Price.ofBulkWithProration(bulkWithProration)`. */ + fun price(bulkWithProration: NewPlanBulkWithProrationPrice) = + price(Price.ofBulkWithProration(bulkWithProration)) + + /** + * Alias for calling [price] with + * `Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)`. + */ + fun price(groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice) = + price(Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)) + + /** + * Alias for calling [price] with + * `Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)`. + */ + fun price(groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice) = + price(Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)) + + /** + * Alias for calling [price] with + * `Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)`. + */ + fun price(groupedWithMinMaxThresholds: Price.GroupedWithMinMaxThresholds) = + price(Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)) + + /** + * Alias for calling [price] with + * `Price.ofMatrixWithDisplayName(matrixWithDisplayName)`. + */ + fun price(matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice) = + price(Price.ofMatrixWithDisplayName(matrixWithDisplayName)) + + /** + * Alias for calling [price] with `Price.ofGroupedTieredPackage(groupedTieredPackage)`. + */ + fun price(groupedTieredPackage: NewPlanGroupedTieredPackagePrice) = + price(Price.ofGroupedTieredPackage(groupedTieredPackage)) + + /** + * Alias for calling [price] with + * `Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)`. + */ + fun price(maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice) = + price(Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)) + + /** + * Alias for calling [price] with + * `Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)`. + */ + fun price(scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice) = + price(Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)) + + /** + * Alias for calling [price] with + * `Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)`. + */ + fun price( + scalableMatrixWithTieredPricing: NewPlanScalableMatrixWithTieredPricingPrice + ) = price(Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)) + + /** + * Alias for calling [price] with + * `Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)`. + */ + fun price(cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice) = + price(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) + + /** Alias for calling [price] with `Price.ofMinimum(minimum)`. */ + fun price(minimum: NewPlanMinimumCompositePrice) = price(Price.ofMinimum(minimum)) + + /** Alias for calling [price] with `Price.ofEventOutput(eventOutput)`. */ + fun price(eventOutput: Price.EventOutput) = price(Price.ofEventOutput(eventOutput)) + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ReplacePrice]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .replacesPriceId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ReplacePrice = + ReplacePrice( + checkRequired("replacesPriceId", replacesPriceId), + allocationPrice, + planPhaseOrder, + price, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ReplacePrice = apply { + if (validated) { + return@apply + } + + replacesPriceId() + allocationPrice()?.validate() + planPhaseOrder() + price()?.validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (replacesPriceId.asKnown() == null) 0 else 1) + + (allocationPrice.asKnown()?.validity() ?: 0) + + (if (planPhaseOrder.asKnown() == null) 0 else 1) + + (price.asKnown()?.validity() ?: 0) + + /** New plan price request body params. */ + @JsonDeserialize(using = Price.Deserializer::class) + @JsonSerialize(using = Price.Serializer::class) + class Price + private constructor( + private val unit: NewPlanUnitPrice? = null, + private val tiered: NewPlanTieredPrice? = null, + private val bulk: NewPlanBulkPrice? = null, + private val package_: NewPlanPackagePrice? = null, + private val matrix: NewPlanMatrixPrice? = null, + private val thresholdTotalAmount: NewPlanThresholdTotalAmountPrice? = null, + private val tieredPackage: NewPlanTieredPackagePrice? = null, + private val tieredWithMinimum: NewPlanTieredWithMinimumPrice? = null, + private val groupedTiered: NewPlanGroupedTieredPrice? = null, + private val tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice? = null, + private val packageWithAllocation: NewPlanPackageWithAllocationPrice? = null, + private val unitWithPercent: NewPlanUnitWithPercentPrice? = null, + private val matrixWithAllocation: NewPlanMatrixWithAllocationPrice? = null, + private val tieredWithProration: TieredWithProration? = null, + private val unitWithProration: NewPlanUnitWithProrationPrice? = null, + private val groupedAllocation: NewPlanGroupedAllocationPrice? = null, + private val bulkWithProration: NewPlanBulkWithProrationPrice? = null, + private val groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice? = null, + private val groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice? = null, + private val groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds? = null, + private val matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice? = null, + private val groupedTieredPackage: NewPlanGroupedTieredPackagePrice? = null, + private val maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice? = null, + private val scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice? = + null, + private val scalableMatrixWithTieredPricing: + NewPlanScalableMatrixWithTieredPricingPrice? = + null, + private val cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice? = null, + private val minimum: NewPlanMinimumCompositePrice? = null, + private val eventOutput: EventOutput? = null, + private val _json: JsonValue? = null, + ) { + + fun unit(): NewPlanUnitPrice? = unit + + fun tiered(): NewPlanTieredPrice? = tiered + + fun bulk(): NewPlanBulkPrice? = bulk + + fun package_(): NewPlanPackagePrice? = package_ + + fun matrix(): NewPlanMatrixPrice? = matrix + + fun thresholdTotalAmount(): NewPlanThresholdTotalAmountPrice? = thresholdTotalAmount + + fun tieredPackage(): NewPlanTieredPackagePrice? = tieredPackage + + fun tieredWithMinimum(): NewPlanTieredWithMinimumPrice? = tieredWithMinimum + + fun groupedTiered(): NewPlanGroupedTieredPrice? = groupedTiered + + fun tieredPackageWithMinimum(): NewPlanTieredPackageWithMinimumPrice? = + tieredPackageWithMinimum + + fun packageWithAllocation(): NewPlanPackageWithAllocationPrice? = packageWithAllocation + + fun unitWithPercent(): NewPlanUnitWithPercentPrice? = unitWithPercent + + fun matrixWithAllocation(): NewPlanMatrixWithAllocationPrice? = matrixWithAllocation + + fun tieredWithProration(): TieredWithProration? = tieredWithProration + + fun unitWithProration(): NewPlanUnitWithProrationPrice? = unitWithProration + + fun groupedAllocation(): NewPlanGroupedAllocationPrice? = groupedAllocation + + fun bulkWithProration(): NewPlanBulkWithProrationPrice? = bulkWithProration + + fun groupedWithProratedMinimum(): NewPlanGroupedWithProratedMinimumPrice? = + groupedWithProratedMinimum + + fun groupedWithMeteredMinimum(): NewPlanGroupedWithMeteredMinimumPrice? = + groupedWithMeteredMinimum + + fun groupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds? = + groupedWithMinMaxThresholds + + fun matrixWithDisplayName(): NewPlanMatrixWithDisplayNamePrice? = matrixWithDisplayName + + fun groupedTieredPackage(): NewPlanGroupedTieredPackagePrice? = groupedTieredPackage + + fun maxGroupTieredPackage(): NewPlanMaxGroupTieredPackagePrice? = maxGroupTieredPackage + + fun scalableMatrixWithUnitPricing(): NewPlanScalableMatrixWithUnitPricingPrice? = + scalableMatrixWithUnitPricing + + fun scalableMatrixWithTieredPricing(): NewPlanScalableMatrixWithTieredPricingPrice? = + scalableMatrixWithTieredPricing + + fun cumulativeGroupedBulk(): NewPlanCumulativeGroupedBulkPrice? = cumulativeGroupedBulk + + fun minimum(): NewPlanMinimumCompositePrice? = minimum + + fun eventOutput(): EventOutput? = eventOutput + + fun isUnit(): Boolean = unit != null + + fun isTiered(): Boolean = tiered != null + + fun isBulk(): Boolean = bulk != null + + fun isPackage(): Boolean = package_ != null + + fun isMatrix(): Boolean = matrix != null + + fun isThresholdTotalAmount(): Boolean = thresholdTotalAmount != null + + fun isTieredPackage(): Boolean = tieredPackage != null + + fun isTieredWithMinimum(): Boolean = tieredWithMinimum != null + + fun isGroupedTiered(): Boolean = groupedTiered != null + + fun isTieredPackageWithMinimum(): Boolean = tieredPackageWithMinimum != null + + fun isPackageWithAllocation(): Boolean = packageWithAllocation != null + + fun isUnitWithPercent(): Boolean = unitWithPercent != null + + fun isMatrixWithAllocation(): Boolean = matrixWithAllocation != null + + fun isTieredWithProration(): Boolean = tieredWithProration != null + + fun isUnitWithProration(): Boolean = unitWithProration != null + + fun isGroupedAllocation(): Boolean = groupedAllocation != null + + fun isBulkWithProration(): Boolean = bulkWithProration != null + + fun isGroupedWithProratedMinimum(): Boolean = groupedWithProratedMinimum != null + + fun isGroupedWithMeteredMinimum(): Boolean = groupedWithMeteredMinimum != null + + fun isGroupedWithMinMaxThresholds(): Boolean = groupedWithMinMaxThresholds != null + + fun isMatrixWithDisplayName(): Boolean = matrixWithDisplayName != null + + fun isGroupedTieredPackage(): Boolean = groupedTieredPackage != null + + fun isMaxGroupTieredPackage(): Boolean = maxGroupTieredPackage != null + + fun isScalableMatrixWithUnitPricing(): Boolean = scalableMatrixWithUnitPricing != null + + fun isScalableMatrixWithTieredPricing(): Boolean = + scalableMatrixWithTieredPricing != null + + fun isCumulativeGroupedBulk(): Boolean = cumulativeGroupedBulk != null + + fun isMinimum(): Boolean = minimum != null + + fun isEventOutput(): Boolean = eventOutput != null + + fun asUnit(): NewPlanUnitPrice = unit.getOrThrow("unit") + + fun asTiered(): NewPlanTieredPrice = tiered.getOrThrow("tiered") + + fun asBulk(): NewPlanBulkPrice = bulk.getOrThrow("bulk") + + fun asPackage(): NewPlanPackagePrice = package_.getOrThrow("package_") + + fun asMatrix(): NewPlanMatrixPrice = matrix.getOrThrow("matrix") + + fun asThresholdTotalAmount(): NewPlanThresholdTotalAmountPrice = + thresholdTotalAmount.getOrThrow("thresholdTotalAmount") + + fun asTieredPackage(): NewPlanTieredPackagePrice = + tieredPackage.getOrThrow("tieredPackage") + + fun asTieredWithMinimum(): NewPlanTieredWithMinimumPrice = + tieredWithMinimum.getOrThrow("tieredWithMinimum") + + fun asGroupedTiered(): NewPlanGroupedTieredPrice = + groupedTiered.getOrThrow("groupedTiered") + + fun asTieredPackageWithMinimum(): NewPlanTieredPackageWithMinimumPrice = + tieredPackageWithMinimum.getOrThrow("tieredPackageWithMinimum") + + fun asPackageWithAllocation(): NewPlanPackageWithAllocationPrice = + packageWithAllocation.getOrThrow("packageWithAllocation") + + fun asUnitWithPercent(): NewPlanUnitWithPercentPrice = + unitWithPercent.getOrThrow("unitWithPercent") + + fun asMatrixWithAllocation(): NewPlanMatrixWithAllocationPrice = + matrixWithAllocation.getOrThrow("matrixWithAllocation") + + fun asTieredWithProration(): TieredWithProration = + tieredWithProration.getOrThrow("tieredWithProration") + + fun asUnitWithProration(): NewPlanUnitWithProrationPrice = + unitWithProration.getOrThrow("unitWithProration") + + fun asGroupedAllocation(): NewPlanGroupedAllocationPrice = + groupedAllocation.getOrThrow("groupedAllocation") + + fun asBulkWithProration(): NewPlanBulkWithProrationPrice = + bulkWithProration.getOrThrow("bulkWithProration") + + fun asGroupedWithProratedMinimum(): NewPlanGroupedWithProratedMinimumPrice = + groupedWithProratedMinimum.getOrThrow("groupedWithProratedMinimum") + + fun asGroupedWithMeteredMinimum(): NewPlanGroupedWithMeteredMinimumPrice = + groupedWithMeteredMinimum.getOrThrow("groupedWithMeteredMinimum") + + fun asGroupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds = + groupedWithMinMaxThresholds.getOrThrow("groupedWithMinMaxThresholds") + + fun asMatrixWithDisplayName(): NewPlanMatrixWithDisplayNamePrice = + matrixWithDisplayName.getOrThrow("matrixWithDisplayName") + + fun asGroupedTieredPackage(): NewPlanGroupedTieredPackagePrice = + groupedTieredPackage.getOrThrow("groupedTieredPackage") + + fun asMaxGroupTieredPackage(): NewPlanMaxGroupTieredPackagePrice = + maxGroupTieredPackage.getOrThrow("maxGroupTieredPackage") + + fun asScalableMatrixWithUnitPricing(): NewPlanScalableMatrixWithUnitPricingPrice = + scalableMatrixWithUnitPricing.getOrThrow("scalableMatrixWithUnitPricing") + + fun asScalableMatrixWithTieredPricing(): NewPlanScalableMatrixWithTieredPricingPrice = + scalableMatrixWithTieredPricing.getOrThrow("scalableMatrixWithTieredPricing") + + fun asCumulativeGroupedBulk(): NewPlanCumulativeGroupedBulkPrice = + cumulativeGroupedBulk.getOrThrow("cumulativeGroupedBulk") + + fun asMinimum(): NewPlanMinimumCompositePrice = minimum.getOrThrow("minimum") + + fun asEventOutput(): EventOutput = eventOutput.getOrThrow("eventOutput") + + fun _json(): JsonValue? = _json + + fun accept(visitor: Visitor): T = + when { + unit != null -> visitor.visitUnit(unit) + tiered != null -> visitor.visitTiered(tiered) + bulk != null -> visitor.visitBulk(bulk) + package_ != null -> visitor.visitPackage(package_) + matrix != null -> visitor.visitMatrix(matrix) + thresholdTotalAmount != null -> + visitor.visitThresholdTotalAmount(thresholdTotalAmount) + tieredPackage != null -> visitor.visitTieredPackage(tieredPackage) + tieredWithMinimum != null -> visitor.visitTieredWithMinimum(tieredWithMinimum) + groupedTiered != null -> visitor.visitGroupedTiered(groupedTiered) + tieredPackageWithMinimum != null -> + visitor.visitTieredPackageWithMinimum(tieredPackageWithMinimum) + packageWithAllocation != null -> + visitor.visitPackageWithAllocation(packageWithAllocation) + unitWithPercent != null -> visitor.visitUnitWithPercent(unitWithPercent) + matrixWithAllocation != null -> + visitor.visitMatrixWithAllocation(matrixWithAllocation) + tieredWithProration != null -> + visitor.visitTieredWithProration(tieredWithProration) + unitWithProration != null -> visitor.visitUnitWithProration(unitWithProration) + groupedAllocation != null -> visitor.visitGroupedAllocation(groupedAllocation) + bulkWithProration != null -> visitor.visitBulkWithProration(bulkWithProration) + groupedWithProratedMinimum != null -> + visitor.visitGroupedWithProratedMinimum(groupedWithProratedMinimum) + groupedWithMeteredMinimum != null -> + visitor.visitGroupedWithMeteredMinimum(groupedWithMeteredMinimum) + groupedWithMinMaxThresholds != null -> + visitor.visitGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds) + matrixWithDisplayName != null -> + visitor.visitMatrixWithDisplayName(matrixWithDisplayName) + groupedTieredPackage != null -> + visitor.visitGroupedTieredPackage(groupedTieredPackage) + maxGroupTieredPackage != null -> + visitor.visitMaxGroupTieredPackage(maxGroupTieredPackage) + scalableMatrixWithUnitPricing != null -> + visitor.visitScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing) + scalableMatrixWithTieredPricing != null -> + visitor.visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing + ) + cumulativeGroupedBulk != null -> + visitor.visitCumulativeGroupedBulk(cumulativeGroupedBulk) + minimum != null -> visitor.visitMinimum(minimum) + eventOutput != null -> visitor.visitEventOutput(eventOutput) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Price = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitUnit(unit: NewPlanUnitPrice) { + unit.validate() + } + + override fun visitTiered(tiered: NewPlanTieredPrice) { + tiered.validate() + } + + override fun visitBulk(bulk: NewPlanBulkPrice) { + bulk.validate() + } + + override fun visitPackage(package_: NewPlanPackagePrice) { + package_.validate() + } + + override fun visitMatrix(matrix: NewPlanMatrixPrice) { + matrix.validate() + } + + override fun visitThresholdTotalAmount( + thresholdTotalAmount: NewPlanThresholdTotalAmountPrice + ) { + thresholdTotalAmount.validate() + } + + override fun visitTieredPackage(tieredPackage: NewPlanTieredPackagePrice) { + tieredPackage.validate() + } + + override fun visitTieredWithMinimum( + tieredWithMinimum: NewPlanTieredWithMinimumPrice + ) { + tieredWithMinimum.validate() + } + + override fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) { + groupedTiered.validate() + } + + override fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice + ) { + tieredPackageWithMinimum.validate() + } + + override fun visitPackageWithAllocation( + packageWithAllocation: NewPlanPackageWithAllocationPrice + ) { + packageWithAllocation.validate() + } + + override fun visitUnitWithPercent( + unitWithPercent: NewPlanUnitWithPercentPrice + ) { + unitWithPercent.validate() + } + + override fun visitMatrixWithAllocation( + matrixWithAllocation: NewPlanMatrixWithAllocationPrice + ) { + matrixWithAllocation.validate() + } + + override fun visitTieredWithProration( + tieredWithProration: TieredWithProration + ) { + tieredWithProration.validate() + } + + override fun visitUnitWithProration( + unitWithProration: NewPlanUnitWithProrationPrice + ) { + unitWithProration.validate() + } + + override fun visitGroupedAllocation( + groupedAllocation: NewPlanGroupedAllocationPrice + ) { + groupedAllocation.validate() + } + + override fun visitBulkWithProration( + bulkWithProration: NewPlanBulkWithProrationPrice + ) { + bulkWithProration.validate() + } + + override fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice + ) { + groupedWithProratedMinimum.validate() + } + + override fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice + ) { + groupedWithMeteredMinimum.validate() + } + + override fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) { + groupedWithMinMaxThresholds.validate() + } + + override fun visitMatrixWithDisplayName( + matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice + ) { + matrixWithDisplayName.validate() + } + + override fun visitGroupedTieredPackage( + groupedTieredPackage: NewPlanGroupedTieredPackagePrice + ) { + groupedTieredPackage.validate() + } + + override fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice + ) { + maxGroupTieredPackage.validate() + } + + override fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice + ) { + scalableMatrixWithUnitPricing.validate() + } + + override fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: + NewPlanScalableMatrixWithTieredPricingPrice + ) { + scalableMatrixWithTieredPricing.validate() + } + + override fun visitCumulativeGroupedBulk( + cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice + ) { + cumulativeGroupedBulk.validate() + } + + override fun visitMinimum(minimum: NewPlanMinimumCompositePrice) { + minimum.validate() + } + + override fun visitEventOutput(eventOutput: EventOutput) { + eventOutput.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitUnit(unit: NewPlanUnitPrice) = unit.validity() + + override fun visitTiered(tiered: NewPlanTieredPrice) = tiered.validity() + + override fun visitBulk(bulk: NewPlanBulkPrice) = bulk.validity() + + override fun visitPackage(package_: NewPlanPackagePrice) = + package_.validity() + + override fun visitMatrix(matrix: NewPlanMatrixPrice) = matrix.validity() + + override fun visitThresholdTotalAmount( + thresholdTotalAmount: NewPlanThresholdTotalAmountPrice + ) = thresholdTotalAmount.validity() + + override fun visitTieredPackage(tieredPackage: NewPlanTieredPackagePrice) = + tieredPackage.validity() + + override fun visitTieredWithMinimum( + tieredWithMinimum: NewPlanTieredWithMinimumPrice + ) = tieredWithMinimum.validity() + + override fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) = + groupedTiered.validity() + + override fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice + ) = tieredPackageWithMinimum.validity() + + override fun visitPackageWithAllocation( + packageWithAllocation: NewPlanPackageWithAllocationPrice + ) = packageWithAllocation.validity() + + override fun visitUnitWithPercent( + unitWithPercent: NewPlanUnitWithPercentPrice + ) = unitWithPercent.validity() + + override fun visitMatrixWithAllocation( + matrixWithAllocation: NewPlanMatrixWithAllocationPrice + ) = matrixWithAllocation.validity() + + override fun visitTieredWithProration( + tieredWithProration: TieredWithProration + ) = tieredWithProration.validity() + + override fun visitUnitWithProration( + unitWithProration: NewPlanUnitWithProrationPrice + ) = unitWithProration.validity() + + override fun visitGroupedAllocation( + groupedAllocation: NewPlanGroupedAllocationPrice + ) = groupedAllocation.validity() + + override fun visitBulkWithProration( + bulkWithProration: NewPlanBulkWithProrationPrice + ) = bulkWithProration.validity() + + override fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice + ) = groupedWithProratedMinimum.validity() + + override fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice + ) = groupedWithMeteredMinimum.validity() + + override fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) = groupedWithMinMaxThresholds.validity() + + override fun visitMatrixWithDisplayName( + matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice + ) = matrixWithDisplayName.validity() + + override fun visitGroupedTieredPackage( + groupedTieredPackage: NewPlanGroupedTieredPackagePrice + ) = groupedTieredPackage.validity() + + override fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice + ) = maxGroupTieredPackage.validity() + + override fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice + ) = scalableMatrixWithUnitPricing.validity() + + override fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: + NewPlanScalableMatrixWithTieredPricingPrice + ) = scalableMatrixWithTieredPricing.validity() + + override fun visitCumulativeGroupedBulk( + cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice + ) = cumulativeGroupedBulk.validity() + + override fun visitMinimum(minimum: NewPlanMinimumCompositePrice) = + minimum.validity() + + override fun visitEventOutput(eventOutput: EventOutput) = + eventOutput.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Price && + unit == other.unit && + tiered == other.tiered && + bulk == other.bulk && + package_ == other.package_ && + matrix == other.matrix && + thresholdTotalAmount == other.thresholdTotalAmount && + tieredPackage == other.tieredPackage && + tieredWithMinimum == other.tieredWithMinimum && + groupedTiered == other.groupedTiered && + tieredPackageWithMinimum == other.tieredPackageWithMinimum && + packageWithAllocation == other.packageWithAllocation && + unitWithPercent == other.unitWithPercent && + matrixWithAllocation == other.matrixWithAllocation && + tieredWithProration == other.tieredWithProration && + unitWithProration == other.unitWithProration && + groupedAllocation == other.groupedAllocation && + bulkWithProration == other.bulkWithProration && + groupedWithProratedMinimum == other.groupedWithProratedMinimum && + groupedWithMeteredMinimum == other.groupedWithMeteredMinimum && + groupedWithMinMaxThresholds == other.groupedWithMinMaxThresholds && + matrixWithDisplayName == other.matrixWithDisplayName && + groupedTieredPackage == other.groupedTieredPackage && + maxGroupTieredPackage == other.maxGroupTieredPackage && + scalableMatrixWithUnitPricing == other.scalableMatrixWithUnitPricing && + scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && + cumulativeGroupedBulk == other.cumulativeGroupedBulk && + minimum == other.minimum && + eventOutput == other.eventOutput + } + + override fun hashCode(): Int = + Objects.hash( + unit, + tiered, + bulk, + package_, + matrix, + thresholdTotalAmount, + tieredPackage, + tieredWithMinimum, + groupedTiered, + tieredPackageWithMinimum, + packageWithAllocation, + unitWithPercent, + matrixWithAllocation, + tieredWithProration, + unitWithProration, + groupedAllocation, + bulkWithProration, + groupedWithProratedMinimum, + groupedWithMeteredMinimum, + groupedWithMinMaxThresholds, + matrixWithDisplayName, + groupedTieredPackage, + maxGroupTieredPackage, + scalableMatrixWithUnitPricing, + scalableMatrixWithTieredPricing, + cumulativeGroupedBulk, + minimum, + eventOutput, + ) + + override fun toString(): String = + when { + unit != null -> "Price{unit=$unit}" + tiered != null -> "Price{tiered=$tiered}" + bulk != null -> "Price{bulk=$bulk}" + package_ != null -> "Price{package_=$package_}" + matrix != null -> "Price{matrix=$matrix}" + thresholdTotalAmount != null -> + "Price{thresholdTotalAmount=$thresholdTotalAmount}" + tieredPackage != null -> "Price{tieredPackage=$tieredPackage}" + tieredWithMinimum != null -> "Price{tieredWithMinimum=$tieredWithMinimum}" + groupedTiered != null -> "Price{groupedTiered=$groupedTiered}" + tieredPackageWithMinimum != null -> + "Price{tieredPackageWithMinimum=$tieredPackageWithMinimum}" + packageWithAllocation != null -> + "Price{packageWithAllocation=$packageWithAllocation}" + unitWithPercent != null -> "Price{unitWithPercent=$unitWithPercent}" + matrixWithAllocation != null -> + "Price{matrixWithAllocation=$matrixWithAllocation}" + tieredWithProration != null -> "Price{tieredWithProration=$tieredWithProration}" + unitWithProration != null -> "Price{unitWithProration=$unitWithProration}" + groupedAllocation != null -> "Price{groupedAllocation=$groupedAllocation}" + bulkWithProration != null -> "Price{bulkWithProration=$bulkWithProration}" + groupedWithProratedMinimum != null -> + "Price{groupedWithProratedMinimum=$groupedWithProratedMinimum}" + groupedWithMeteredMinimum != null -> + "Price{groupedWithMeteredMinimum=$groupedWithMeteredMinimum}" + groupedWithMinMaxThresholds != null -> + "Price{groupedWithMinMaxThresholds=$groupedWithMinMaxThresholds}" + matrixWithDisplayName != null -> + "Price{matrixWithDisplayName=$matrixWithDisplayName}" + groupedTieredPackage != null -> + "Price{groupedTieredPackage=$groupedTieredPackage}" + maxGroupTieredPackage != null -> + "Price{maxGroupTieredPackage=$maxGroupTieredPackage}" + scalableMatrixWithUnitPricing != null -> + "Price{scalableMatrixWithUnitPricing=$scalableMatrixWithUnitPricing}" + scalableMatrixWithTieredPricing != null -> + "Price{scalableMatrixWithTieredPricing=$scalableMatrixWithTieredPricing}" + cumulativeGroupedBulk != null -> + "Price{cumulativeGroupedBulk=$cumulativeGroupedBulk}" + minimum != null -> "Price{minimum=$minimum}" + eventOutput != null -> "Price{eventOutput=$eventOutput}" + _json != null -> "Price{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Price") + } + + companion object { + + fun ofUnit(unit: NewPlanUnitPrice) = Price(unit = unit) + + fun ofTiered(tiered: NewPlanTieredPrice) = Price(tiered = tiered) + + fun ofBulk(bulk: NewPlanBulkPrice) = Price(bulk = bulk) + + fun ofPackage(package_: NewPlanPackagePrice) = Price(package_ = package_) + + fun ofMatrix(matrix: NewPlanMatrixPrice) = Price(matrix = matrix) + + fun ofThresholdTotalAmount(thresholdTotalAmount: NewPlanThresholdTotalAmountPrice) = + Price(thresholdTotalAmount = thresholdTotalAmount) + + fun ofTieredPackage(tieredPackage: NewPlanTieredPackagePrice) = + Price(tieredPackage = tieredPackage) + + fun ofTieredWithMinimum(tieredWithMinimum: NewPlanTieredWithMinimumPrice) = + Price(tieredWithMinimum = tieredWithMinimum) + + fun ofGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) = + Price(groupedTiered = groupedTiered) + + fun ofTieredPackageWithMinimum( + tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice + ) = Price(tieredPackageWithMinimum = tieredPackageWithMinimum) + + fun ofPackageWithAllocation( + packageWithAllocation: NewPlanPackageWithAllocationPrice + ) = Price(packageWithAllocation = packageWithAllocation) + + fun ofUnitWithPercent(unitWithPercent: NewPlanUnitWithPercentPrice) = + Price(unitWithPercent = unitWithPercent) + + fun ofMatrixWithAllocation(matrixWithAllocation: NewPlanMatrixWithAllocationPrice) = + Price(matrixWithAllocation = matrixWithAllocation) + + fun ofTieredWithProration(tieredWithProration: TieredWithProration) = + Price(tieredWithProration = tieredWithProration) + + fun ofUnitWithProration(unitWithProration: NewPlanUnitWithProrationPrice) = + Price(unitWithProration = unitWithProration) + + fun ofGroupedAllocation(groupedAllocation: NewPlanGroupedAllocationPrice) = + Price(groupedAllocation = groupedAllocation) + + fun ofBulkWithProration(bulkWithProration: NewPlanBulkWithProrationPrice) = + Price(bulkWithProration = bulkWithProration) + + fun ofGroupedWithProratedMinimum( + groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice + ) = Price(groupedWithProratedMinimum = groupedWithProratedMinimum) + + fun ofGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice + ) = Price(groupedWithMeteredMinimum = groupedWithMeteredMinimum) + + fun ofGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) = Price(groupedWithMinMaxThresholds = groupedWithMinMaxThresholds) + + fun ofMatrixWithDisplayName( + matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice + ) = Price(matrixWithDisplayName = matrixWithDisplayName) + + fun ofGroupedTieredPackage(groupedTieredPackage: NewPlanGroupedTieredPackagePrice) = + Price(groupedTieredPackage = groupedTieredPackage) + + fun ofMaxGroupTieredPackage( + maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice + ) = Price(maxGroupTieredPackage = maxGroupTieredPackage) + + fun ofScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice + ) = Price(scalableMatrixWithUnitPricing = scalableMatrixWithUnitPricing) + + fun ofScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: NewPlanScalableMatrixWithTieredPricingPrice + ) = Price(scalableMatrixWithTieredPricing = scalableMatrixWithTieredPricing) + + fun ofCumulativeGroupedBulk( + cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice + ) = Price(cumulativeGroupedBulk = cumulativeGroupedBulk) + + fun ofMinimum(minimum: NewPlanMinimumCompositePrice) = Price(minimum = minimum) + + fun ofEventOutput(eventOutput: EventOutput) = Price(eventOutput = eventOutput) + } + + /** + * An interface that defines how to map each variant of [Price] to a value of type [T]. + */ + interface Visitor { + + fun visitUnit(unit: NewPlanUnitPrice): T + + fun visitTiered(tiered: NewPlanTieredPrice): T + + fun visitBulk(bulk: NewPlanBulkPrice): T + + fun visitPackage(package_: NewPlanPackagePrice): T + + fun visitMatrix(matrix: NewPlanMatrixPrice): T + + fun visitThresholdTotalAmount( + thresholdTotalAmount: NewPlanThresholdTotalAmountPrice + ): T + + fun visitTieredPackage(tieredPackage: NewPlanTieredPackagePrice): T + + fun visitTieredWithMinimum(tieredWithMinimum: NewPlanTieredWithMinimumPrice): T + + fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice): T + + fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice + ): T + + fun visitPackageWithAllocation( + packageWithAllocation: NewPlanPackageWithAllocationPrice + ): T + + fun visitUnitWithPercent(unitWithPercent: NewPlanUnitWithPercentPrice): T + + fun visitMatrixWithAllocation( + matrixWithAllocation: NewPlanMatrixWithAllocationPrice + ): T + + fun visitTieredWithProration(tieredWithProration: TieredWithProration): T + + fun visitUnitWithProration(unitWithProration: NewPlanUnitWithProrationPrice): T + + fun visitGroupedAllocation(groupedAllocation: NewPlanGroupedAllocationPrice): T + + fun visitBulkWithProration(bulkWithProration: NewPlanBulkWithProrationPrice): T + + fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice + ): T + + fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice + ): T + + fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ): T + + fun visitMatrixWithDisplayName( + matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice + ): T + + fun visitGroupedTieredPackage( + groupedTieredPackage: NewPlanGroupedTieredPackagePrice + ): T + + fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice + ): T + + fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice + ): T + + fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: NewPlanScalableMatrixWithTieredPricingPrice + ): T + + fun visitCumulativeGroupedBulk( + cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice + ): T + + fun visitMinimum(minimum: NewPlanMinimumCompositePrice): T + + fun visitEventOutput(eventOutput: EventOutput): T + + /** + * Maps an unknown variant of [Price] to a value of type [T]. + * + * An instance of [Price] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is + * unaware of. + * + * @throws OrbInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw OrbInvalidDataException("Unknown Price: $json") + } + } + + internal class Deserializer : BaseDeserializer(Price::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Price { + val json = JsonValue.fromJsonNode(node) + val modelType = json.asObject()?.get("model_type")?.asString() + + when (modelType) { + "unit" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(unit = it, _json = json) + } ?: Price(_json = json) + } + "tiered" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(tiered = it, _json = json) + } ?: Price(_json = json) + } + "bulk" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(bulk = it, _json = json) + } ?: Price(_json = json) + } + "package" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(package_ = it, _json = json) } ?: Price(_json = json) + } + "matrix" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(matrix = it, _json = json) + } ?: Price(_json = json) + } + "threshold_total_amount" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(thresholdTotalAmount = it, _json = json) } + ?: Price(_json = json) + } + "tiered_package" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(tieredPackage = it, _json = json) } + ?: Price(_json = json) + } + "tiered_with_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(tieredWithMinimum = it, _json = json) } + ?: Price(_json = json) + } + "grouped_tiered" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(groupedTiered = it, _json = json) } + ?: Price(_json = json) + } + "tiered_package_with_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(tieredPackageWithMinimum = it, _json = json) } + ?: Price(_json = json) + } + "package_with_allocation" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(packageWithAllocation = it, _json = json) } + ?: Price(_json = json) + } + "unit_with_percent" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(unitWithPercent = it, _json = json) } + ?: Price(_json = json) + } + "matrix_with_allocation" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(matrixWithAllocation = it, _json = json) } + ?: Price(_json = json) + } + "tiered_with_proration" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(tieredWithProration = it, _json = json) } + ?: Price(_json = json) + } + "unit_with_proration" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(unitWithProration = it, _json = json) } + ?: Price(_json = json) + } + "grouped_allocation" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedAllocation = it, _json = json) } + ?: Price(_json = json) + } + "bulk_with_proration" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(bulkWithProration = it, _json = json) } + ?: Price(_json = json) + } + "grouped_with_prorated_minimum" -> { + return tryDeserialize( + node, jacksonTypeRef(), ) - ?.let { Price(groupedWithProratedMinimum = it, _json = json) } - ?: Price(_json = json) + ?.let { Price(groupedWithProratedMinimum = it, _json = json) } + ?: Price(_json = json) + } + "grouped_with_metered_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedWithMeteredMinimum = it, _json = json) } + ?: Price(_json = json) + } + "grouped_with_min_max_thresholds" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedWithMinMaxThresholds = it, _json = json) } + ?: Price(_json = json) + } + "matrix_with_display_name" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(matrixWithDisplayName = it, _json = json) } + ?: Price(_json = json) + } + "grouped_tiered_package" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedTieredPackage = it, _json = json) } + ?: Price(_json = json) + } + "max_group_tiered_package" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(maxGroupTieredPackage = it, _json = json) } + ?: Price(_json = json) + } + "scalable_matrix_with_unit_pricing" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(scalableMatrixWithUnitPricing = it, _json = json) } + ?: Price(_json = json) + } + "scalable_matrix_with_tiered_pricing" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(scalableMatrixWithTieredPricing = it, _json = json) } + ?: Price(_json = json) + } + "cumulative_grouped_bulk" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(cumulativeGroupedBulk = it, _json = json) } + ?: Price(_json = json) + } + "minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(minimum = it, _json = json) } ?: Price(_json = json) + } + "event_output" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(eventOutput = it, _json = json) + } ?: Price(_json = json) + } + } + + return Price(_json = json) + } + } + + internal class Serializer : BaseSerializer(Price::class) { + + override fun serialize( + value: Price, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.unit != null -> generator.writeObject(value.unit) + value.tiered != null -> generator.writeObject(value.tiered) + value.bulk != null -> generator.writeObject(value.bulk) + value.package_ != null -> generator.writeObject(value.package_) + value.matrix != null -> generator.writeObject(value.matrix) + value.thresholdTotalAmount != null -> + generator.writeObject(value.thresholdTotalAmount) + value.tieredPackage != null -> generator.writeObject(value.tieredPackage) + value.tieredWithMinimum != null -> + generator.writeObject(value.tieredWithMinimum) + value.groupedTiered != null -> generator.writeObject(value.groupedTiered) + value.tieredPackageWithMinimum != null -> + generator.writeObject(value.tieredPackageWithMinimum) + value.packageWithAllocation != null -> + generator.writeObject(value.packageWithAllocation) + value.unitWithPercent != null -> + generator.writeObject(value.unitWithPercent) + value.matrixWithAllocation != null -> + generator.writeObject(value.matrixWithAllocation) + value.tieredWithProration != null -> + generator.writeObject(value.tieredWithProration) + value.unitWithProration != null -> + generator.writeObject(value.unitWithProration) + value.groupedAllocation != null -> + generator.writeObject(value.groupedAllocation) + value.bulkWithProration != null -> + generator.writeObject(value.bulkWithProration) + value.groupedWithProratedMinimum != null -> + generator.writeObject(value.groupedWithProratedMinimum) + value.groupedWithMeteredMinimum != null -> + generator.writeObject(value.groupedWithMeteredMinimum) + value.groupedWithMinMaxThresholds != null -> + generator.writeObject(value.groupedWithMinMaxThresholds) + value.matrixWithDisplayName != null -> + generator.writeObject(value.matrixWithDisplayName) + value.groupedTieredPackage != null -> + generator.writeObject(value.groupedTieredPackage) + value.maxGroupTieredPackage != null -> + generator.writeObject(value.maxGroupTieredPackage) + value.scalableMatrixWithUnitPricing != null -> + generator.writeObject(value.scalableMatrixWithUnitPricing) + value.scalableMatrixWithTieredPricing != null -> + generator.writeObject(value.scalableMatrixWithTieredPricing) + value.cumulativeGroupedBulk != null -> + generator.writeObject(value.cumulativeGroupedBulk) + value.minimum != null -> generator.writeObject(value.minimum) + value.eventOutput != null -> generator.writeObject(value.eventOutput) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Price") + } + } + } + + class TieredWithProration + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val tieredWithProrationConfig: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("tiered_with_proration_config") + @ExcludeMissing + tieredWithProrationConfig: JsonField = + JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + modelType, + name, + tieredWithProrationConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("tiered_with_proration") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * Configuration for tiered_with_proration pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun tieredWithProrationConfig(): TieredWithProrationConfig = + tieredWithProrationConfig.getRequired("tiered_with_proration_config") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = billableMetricId.getNullable("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + invoiceGroupingKey.getNullable("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [tieredWithProrationConfig]. + * + * Unlike [tieredWithProrationConfig], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("tiered_with_proration_config") + @ExcludeMissing + fun _tieredWithProrationConfig(): JsonField = + tieredWithProrationConfig + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [TieredWithProration]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .name() + * .tieredWithProrationConfig() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [TieredWithProration]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonValue = JsonValue.from("tiered_with_proration") + private var name: JsonField? = null + private var tieredWithProrationConfig: JsonField? = + null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(tieredWithProration: TieredWithProration) = apply { + cadence = tieredWithProration.cadence + itemId = tieredWithProration.itemId + modelType = tieredWithProration.modelType + name = tieredWithProration.name + tieredWithProrationConfig = tieredWithProration.tieredWithProrationConfig + billableMetricId = tieredWithProration.billableMetricId + billedInAdvance = tieredWithProration.billedInAdvance + billingCycleConfiguration = tieredWithProration.billingCycleConfiguration + conversionRate = tieredWithProration.conversionRate + conversionRateConfig = tieredWithProration.conversionRateConfig + currency = tieredWithProration.currency + dimensionalPriceConfiguration = + tieredWithProration.dimensionalPriceConfiguration + externalPriceId = tieredWithProration.externalPriceId + fixedPriceQuantity = tieredWithProration.fixedPriceQuantity + invoiceGroupingKey = tieredWithProration.invoiceGroupingKey + invoicingCycleConfiguration = + tieredWithProration.invoicingCycleConfiguration + metadata = tieredWithProration.metadata + referenceId = tieredWithProration.referenceId + additionalProperties = + tieredWithProration.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("tiered_with_proration") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for tiered_with_proration pricing */ + fun tieredWithProrationConfig( + tieredWithProrationConfig: TieredWithProrationConfig + ) = tieredWithProrationConfig(JsonField.of(tieredWithProrationConfig)) + + /** + * Sets [Builder.tieredWithProrationConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.tieredWithProrationConfig] with a well-typed + * [TieredWithProrationConfig] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun tieredWithProrationConfig( + tieredWithProrationConfig: JsonField + ) = apply { this.tieredWithProrationConfig = tieredWithProrationConfig } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [TieredWithProration]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .name() + * .tieredWithProrationConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TieredWithProration = + TieredWithProration( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + modelType, + checkRequired("name", name), + checkRequired("tieredWithProrationConfig", tieredWithProrationConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TieredWithProration = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + _modelType().let { + if (it != JsonValue.from("tiered_with_proration")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + tieredWithProrationConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + modelType.let { + if (it == JsonValue.from("tiered_with_proration")) 1 else 0 + } + + (if (name.asKnown() == null) 0 else 1) + + (tieredWithProrationConfig.asKnown()?.validity() ?: 0) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Configuration for tiered_with_proration pricing */ + class TieredWithProrationConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val tiers: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of() + ) : this(tiers, mutableMapOf()) + + /** + * Tiers for rating based on total usage quantities into the specified tier with + * proration + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun tiers(): List = tiers.getRequired("tiers") + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [TieredWithProrationConfig]. + * + * The following fields are required: + * ```kotlin + * .tiers() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [TieredWithProrationConfig]. */ + class Builder internal constructor() { + + private var tiers: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(tieredWithProrationConfig: TieredWithProrationConfig) = + apply { + tiers = tieredWithProrationConfig.tiers.map { it.toMutableList() } + additionalProperties = + tieredWithProrationConfig.additionalProperties.toMutableMap() + } + + /** + * Tiers for rating based on total usage quantities into the specified tier + * with proration + */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [TieredWithProrationConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TieredWithProrationConfig = + TieredWithProrationConfig( + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TieredWithProrationConfig = apply { + if (validated) { + return@apply + } + + tiers().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (tiers.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single tiered with proration tier */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val tierLowerBound: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(tierLowerBound, unitAmount, mutableMapOf()) + + /** + * Inclusive tier starting value + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun tierLowerBound(): String = + tierLowerBound.getRequired("tier_lower_bound") + + /** + * Amount per unit + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Tier]. + * + * The following fields are required: + * ```kotlin + * .tierLowerBound() + * .unitAmount() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var tierLowerBound: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(tier: Tier) = apply { + tierLowerBound = tier.tierLowerBound + unitAmount = tier.unitAmount + additionalProperties = tier.additionalProperties.toMutableMap() + } + + /** Inclusive tier starting value */ + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + /** Amount per unit */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```kotlin + * .tierLowerBound() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("tierLowerBound", tierLowerBound), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) } - "grouped_with_metered_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedWithMeteredMinimum = it, _json = json) } - ?: Price(_json = json) + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + tierLowerBound() + unitAmount() + validated = true } - "grouped_with_min_max_thresholds" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedWithMinMaxThresholds = it, _json = json) } - ?: Price(_json = json) + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (tierLowerBound.asKnown() == null) 0 else 1) + + (if (unitAmount.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + tierLowerBound == other.tierLowerBound && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties } - "matrix_with_display_name" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(matrixWithDisplayName = it, _json = json) } - ?: Price(_json = json) + + private val hashCode: Int by lazy { + Objects.hash(tierLowerBound, unitAmount, additionalProperties) } - "grouped_tiered_package" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedTieredPackage = it, _json = json) } - ?: Price(_json = json) + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - "max_group_tiered_package" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(maxGroupTieredPackage = it, _json = json) } - ?: Price(_json = json) + + return other is TieredWithProrationConfig && + tiers == other.tiers && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(tiers, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TieredWithProrationConfig{tiers=$tiers, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() } - "scalable_matrix_with_unit_pricing" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(scalableMatrixWithUnitPricing = it, _json = json) } - ?: Price(_json = json) + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) } - "scalable_matrix_with_tiered_pricing" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(scalableMatrixWithTieredPricing = it, _json = json) } - ?: Price(_json = json) + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) } - "cumulative_grouped_bulk" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(cumulativeGroupedBulk = it, _json = json) } - ?: Price(_json = json) + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) } - "minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(minimum = it, _json = json) } ?: Price(_json = json) + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties } - return Price(_json = json) - } - } + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode - internal class Serializer : BaseSerializer(Price::class) { + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } - override fun serialize( - value: Price, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unit != null -> generator.writeObject(value.unit) - value.tiered != null -> generator.writeObject(value.tiered) - value.bulk != null -> generator.writeObject(value.bulk) - value.package_ != null -> generator.writeObject(value.package_) - value.matrix != null -> generator.writeObject(value.matrix) - value.thresholdTotalAmount != null -> - generator.writeObject(value.thresholdTotalAmount) - value.tieredPackage != null -> generator.writeObject(value.tieredPackage) - value.tieredWithMinimum != null -> - generator.writeObject(value.tieredWithMinimum) - value.groupedTiered != null -> generator.writeObject(value.groupedTiered) - value.tieredPackageWithMinimum != null -> - generator.writeObject(value.tieredPackageWithMinimum) - value.packageWithAllocation != null -> - generator.writeObject(value.packageWithAllocation) - value.unitWithPercent != null -> - generator.writeObject(value.unitWithPercent) - value.matrixWithAllocation != null -> - generator.writeObject(value.matrixWithAllocation) - value.tieredWithProration != null -> - generator.writeObject(value.tieredWithProration) - value.unitWithProration != null -> - generator.writeObject(value.unitWithProration) - value.groupedAllocation != null -> - generator.writeObject(value.groupedAllocation) - value.bulkWithProration != null -> - generator.writeObject(value.bulkWithProration) - value.groupedWithProratedMinimum != null -> - generator.writeObject(value.groupedWithProratedMinimum) - value.groupedWithMeteredMinimum != null -> - generator.writeObject(value.groupedWithMeteredMinimum) - value.groupedWithMinMaxThresholds != null -> - generator.writeObject(value.groupedWithMinMaxThresholds) - value.matrixWithDisplayName != null -> - generator.writeObject(value.matrixWithDisplayName) - value.groupedTieredPackage != null -> - generator.writeObject(value.groupedTieredPackage) - value.maxGroupTieredPackage != null -> - generator.writeObject(value.maxGroupTieredPackage) - value.scalableMatrixWithUnitPricing != null -> - generator.writeObject(value.scalableMatrixWithUnitPricing) - value.scalableMatrixWithTieredPricing != null -> - generator.writeObject(value.scalableMatrixWithTieredPricing) - value.cumulativeGroupedBulk != null -> - generator.writeObject(value.cumulativeGroupedBulk) - value.minimum != null -> generator.writeObject(value.minimum) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Price") + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } + + return other is TieredWithProration && + cadence == other.cadence && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + tieredWithProrationConfig == other.tieredWithProrationConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + modelType, + name, + tieredWithProrationConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties, + ) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TieredWithProration{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredWithProrationConfig=$tieredWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class TieredWithProration + class GroupedWithMinMaxThresholds @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, + private val groupedWithMinMaxThresholdsConfig: + JsonField, private val itemId: JsonField, private val modelType: JsonValue, private val name: JsonField, - private val tieredWithProrationConfig: JsonField, private val billableMetricId: JsonField, private val billedInAdvance: JsonField, private val billingCycleConfiguration: JsonField, @@ -9253,6 +12653,11 @@ private constructor( @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), + @JsonProperty("grouped_with_min_max_thresholds_config") + @ExcludeMissing + groupedWithMinMaxThresholdsConfig: + JsonField = + JsonMissing.of(), @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), @@ -9262,10 +12667,6 @@ private constructor( @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("tiered_with_proration_config") - @ExcludeMissing - tieredWithProrationConfig: JsonField = - JsonMissing.of(), @JsonProperty("billable_metric_id") @ExcludeMissing billableMetricId: JsonField = JsonMissing.of(), @@ -9310,10 +12711,10 @@ private constructor( referenceId: JsonField = JsonMissing.of(), ) : this( cadence, + groupedWithMinMaxThresholdsConfig, itemId, modelType, name, - tieredWithProrationConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -9339,6 +12740,18 @@ private constructor( */ fun cadence(): Cadence = cadence.getRequired("cadence") + /** + * Configuration for grouped_with_min_max_thresholds pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupedWithMinMaxThresholdsConfig(): GroupedWithMinMaxThresholdsConfig = + groupedWithMinMaxThresholdsConfig.getRequired( + "grouped_with_min_max_thresholds_config" + ) + /** * The id of the item the price will be associated with. * @@ -9353,7 +12766,7 @@ private constructor( * * Expected to always return the following: * ```kotlin - * JsonValue.from("tiered_with_proration") + * JsonValue.from("grouped_with_min_max_thresholds") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -9370,16 +12783,6 @@ private constructor( */ fun name(): String = name.getRequired("name") - /** - * Configuration for tiered_with_proration pricing - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun tieredWithProrationConfig(): TieredWithProrationConfig = - tieredWithProrationConfig.getRequired("tiered_with_proration_config") - /** * The id of the billable metric for the price. Only needed if the price is * usage-based. @@ -9509,6 +12912,17 @@ private constructor( @ExcludeMissing fun _cadence(): JsonField = cadence + /** + * Returns the raw JSON value of [groupedWithMinMaxThresholdsConfig]. + * + * Unlike [groupedWithMinMaxThresholdsConfig], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("grouped_with_min_max_thresholds_config") + @ExcludeMissing + fun _groupedWithMinMaxThresholdsConfig(): + JsonField = groupedWithMinMaxThresholdsConfig + /** * Returns the raw JSON value of [itemId]. * @@ -9525,17 +12939,6 @@ private constructor( */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - /** - * Returns the raw JSON value of [tieredWithProrationConfig]. - * - * Unlike [tieredWithProrationConfig], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("tiered_with_proration_config") - @ExcludeMissing - fun _tieredWithProrationConfig(): JsonField = - tieredWithProrationConfig - /** * Returns the raw JSON value of [billableMetricId]. * @@ -9685,28 +13088,30 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [TieredWithProration]. + * [GroupedWithMinMaxThresholds]. * * The following fields are required: * ```kotlin * .cadence() + * .groupedWithMinMaxThresholdsConfig() * .itemId() * .name() - * .tieredWithProrationConfig() * ``` */ fun builder() = Builder() } - /** A builder for [TieredWithProration]. */ + /** A builder for [GroupedWithMinMaxThresholds]. */ class Builder internal constructor() { private var cadence: JsonField? = null + private var groupedWithMinMaxThresholdsConfig: + JsonField? = + null private var itemId: JsonField? = null - private var modelType: JsonValue = JsonValue.from("tiered_with_proration") + private var modelType: JsonValue = + JsonValue.from("grouped_with_min_max_thresholds") private var name: JsonField? = null - private var tieredWithProrationConfig: JsonField? = - null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() private var billingCycleConfiguration: JsonField = @@ -9728,30 +13133,33 @@ private constructor( private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(tieredWithProration: TieredWithProration) = apply { - cadence = tieredWithProration.cadence - itemId = tieredWithProration.itemId - modelType = tieredWithProration.modelType - name = tieredWithProration.name - tieredWithProrationConfig = tieredWithProration.tieredWithProrationConfig - billableMetricId = tieredWithProration.billableMetricId - billedInAdvance = tieredWithProration.billedInAdvance - billingCycleConfiguration = tieredWithProration.billingCycleConfiguration - conversionRate = tieredWithProration.conversionRate - conversionRateConfig = tieredWithProration.conversionRateConfig - currency = tieredWithProration.currency - dimensionalPriceConfiguration = - tieredWithProration.dimensionalPriceConfiguration - externalPriceId = tieredWithProration.externalPriceId - fixedPriceQuantity = tieredWithProration.fixedPriceQuantity - invoiceGroupingKey = tieredWithProration.invoiceGroupingKey - invoicingCycleConfiguration = - tieredWithProration.invoicingCycleConfiguration - metadata = tieredWithProration.metadata - referenceId = tieredWithProration.referenceId - additionalProperties = - tieredWithProration.additionalProperties.toMutableMap() - } + internal fun from(groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds) = + apply { + cadence = groupedWithMinMaxThresholds.cadence + groupedWithMinMaxThresholdsConfig = + groupedWithMinMaxThresholds.groupedWithMinMaxThresholdsConfig + itemId = groupedWithMinMaxThresholds.itemId + modelType = groupedWithMinMaxThresholds.modelType + name = groupedWithMinMaxThresholds.name + billableMetricId = groupedWithMinMaxThresholds.billableMetricId + billedInAdvance = groupedWithMinMaxThresholds.billedInAdvance + billingCycleConfiguration = + groupedWithMinMaxThresholds.billingCycleConfiguration + conversionRate = groupedWithMinMaxThresholds.conversionRate + conversionRateConfig = groupedWithMinMaxThresholds.conversionRateConfig + currency = groupedWithMinMaxThresholds.currency + dimensionalPriceConfiguration = + groupedWithMinMaxThresholds.dimensionalPriceConfiguration + externalPriceId = groupedWithMinMaxThresholds.externalPriceId + fixedPriceQuantity = groupedWithMinMaxThresholds.fixedPriceQuantity + invoiceGroupingKey = groupedWithMinMaxThresholds.invoiceGroupingKey + invoicingCycleConfiguration = + groupedWithMinMaxThresholds.invoicingCycleConfiguration + metadata = groupedWithMinMaxThresholds.metadata + referenceId = groupedWithMinMaxThresholds.referenceId + additionalProperties = + groupedWithMinMaxThresholds.additionalProperties.toMutableMap() + } /** The cadence to bill for this price on. */ fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) @@ -9763,7 +13171,30 @@ private constructor( * instead. This method is primarily for setting the field to an undocumented or * not yet supported value. */ - fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** Configuration for grouped_with_min_max_thresholds pricing */ + fun groupedWithMinMaxThresholdsConfig( + groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + ) = + groupedWithMinMaxThresholdsConfig( + JsonField.of(groupedWithMinMaxThresholdsConfig) + ) + + /** + * Sets [Builder.groupedWithMinMaxThresholdsConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.groupedWithMinMaxThresholdsConfig] with a + * well-typed [GroupedWithMinMaxThresholdsConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun groupedWithMinMaxThresholdsConfig( + groupedWithMinMaxThresholdsConfig: + JsonField + ) = apply { + this.groupedWithMinMaxThresholdsConfig = groupedWithMinMaxThresholdsConfig + } /** The id of the item the price will be associated with. */ fun itemId(itemId: String) = itemId(JsonField.of(itemId)) @@ -9783,7 +13214,7 @@ private constructor( * It is usually unnecessary to call this method because the field defaults to * the following: * ```kotlin - * JsonValue.from("tiered_with_proration") + * JsonValue.from("grouped_with_min_max_thresholds") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -9803,22 +13234,6 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } - /** Configuration for tiered_with_proration pricing */ - fun tieredWithProrationConfig( - tieredWithProrationConfig: TieredWithProrationConfig - ) = tieredWithProrationConfig(JsonField.of(tieredWithProrationConfig)) - - /** - * Sets [Builder.tieredWithProrationConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.tieredWithProrationConfig] with a well-typed - * [TieredWithProrationConfig] value instead. This method is primarily for - * setting the field to an undocumented or not yet supported value. - */ - fun tieredWithProrationConfig( - tieredWithProrationConfig: JsonField - ) = apply { this.tieredWithProrationConfig = tieredWithProrationConfig } - /** * The id of the billable metric for the price. Only needed if the price is * usage-based. @@ -10148,27 +13563,30 @@ private constructor( } /** - * Returns an immutable instance of [TieredWithProration]. + * Returns an immutable instance of [GroupedWithMinMaxThresholds]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```kotlin * .cadence() + * .groupedWithMinMaxThresholdsConfig() * .itemId() * .name() - * .tieredWithProrationConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): TieredWithProration = - TieredWithProration( + fun build(): GroupedWithMinMaxThresholds = + GroupedWithMinMaxThresholds( checkRequired("cadence", cadence), + checkRequired( + "groupedWithMinMaxThresholdsConfig", + groupedWithMinMaxThresholdsConfig, + ), checkRequired("itemId", itemId), modelType, checkRequired("name", name), - checkRequired("tieredWithProrationConfig", tieredWithProrationConfig), billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -10188,20 +13606,20 @@ private constructor( private var validated: Boolean = false - fun validate(): TieredWithProration = apply { + fun validate(): GroupedWithMinMaxThresholds = apply { if (validated) { return@apply } cadence().validate() + groupedWithMinMaxThresholdsConfig().validate() itemId() _modelType().let { - if (it != JsonValue.from("tiered_with_proration")) { + if (it != JsonValue.from("grouped_with_min_max_thresholds")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } name() - tieredWithProrationConfig().validate() billableMetricId() billedInAdvance() billingCycleConfiguration()?.validate() @@ -10234,12 +13652,12 @@ private constructor( */ internal fun validity(): Int = (cadence.asKnown()?.validity() ?: 0) + + (groupedWithMinMaxThresholdsConfig.asKnown()?.validity() ?: 0) + (if (itemId.asKnown() == null) 0 else 1) + modelType.let { - if (it == JsonValue.from("tiered_with_proration")) 1 else 0 + if (it == JsonValue.from("grouped_with_min_max_thresholds")) 1 else 0 } + (if (name.asKnown() == null) 0 else 1) + - (tieredWithProrationConfig.asKnown()?.validity() ?: 0) + (if (billableMetricId.asKnown() == null) 0 else 1) + (if (billedInAdvance.asKnown() == null) 0 else 1) + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + @@ -10351,220 +13769,34 @@ private constructor( when (this) { ANNUAL -> Known.ANNUAL SEMI_ANNUAL -> Known.SEMI_ANNUAL - MONTHLY -> Known.MONTHLY - QUARTERLY -> Known.QUARTERLY - ONE_TIME -> Known.ONE_TIME - CUSTOM -> Known.CUSTOM - else -> throw OrbInvalidDataException("Unknown Cadence: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString() - ?: throw OrbInvalidDataException("Value is not a String") - - private var validated: Boolean = false - - fun validate(): Cadence = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Cadence && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** Configuration for tiered_with_proration pricing */ - class TieredWithProrationConfig - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val tiers: JsonField>, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("tiers") - @ExcludeMissing - tiers: JsonField> = JsonMissing.of() - ) : this(tiers, mutableMapOf()) - - /** - * Tiers for rating based on total usage quantities into the specified tier with - * proration - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun tiers(): List = tiers.getRequired("tiers") - - /** - * Returns the raw JSON value of [tiers]. - * - * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("tiers") - @ExcludeMissing - fun _tiers(): JsonField> = tiers - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [TieredWithProrationConfig]. - * - * The following fields are required: - * ```kotlin - * .tiers() - * ``` - */ - fun builder() = Builder() - } - - /** A builder for [TieredWithProrationConfig]. */ - class Builder internal constructor() { - - private var tiers: JsonField>? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - internal fun from(tieredWithProrationConfig: TieredWithProrationConfig) = - apply { - tiers = tieredWithProrationConfig.tiers.map { it.toMutableList() } - additionalProperties = - tieredWithProrationConfig.additionalProperties.toMutableMap() - } - - /** - * Tiers for rating based on total usage quantities into the specified tier - * with proration - */ - fun tiers(tiers: List) = tiers(JsonField.of(tiers)) - - /** - * Sets [Builder.tiers] to an arbitrary JSON value. - * - * You should usually call [Builder.tiers] with a well-typed `List` - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun tiers(tiers: JsonField>) = apply { - this.tiers = tiers.map { it.toMutableList() } - } - - /** - * Adds a single [Tier] to [tiers]. - * - * @throws IllegalStateException if the field was previously set to a - * non-list. - */ - fun addTier(tier: Tier) = apply { - tiers = - (tiers ?: JsonField.of(mutableListOf())).also { - checkKnown("tiers", it).add(tier) - } - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [TieredWithProrationConfig]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```kotlin - * .tiers() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): TieredWithProrationConfig = - TieredWithProrationConfig( - checkRequired("tiers", tiers).map { it.toImmutable() }, - additionalProperties.toMutableMap(), - ) - } + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") private var validated: Boolean = false - fun validate(): TieredWithProrationConfig = apply { + fun validate(): Cadence = apply { if (validated) { return@apply } - tiers().forEach { it.validate() } + known() validated = true } @@ -10582,248 +13814,343 @@ private constructor( * * Used for best match union deserialization. */ - internal fun validity(): Int = - (tiers.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - /** Configuration for a single tiered with proration tier */ - class Tier - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val tierLowerBound: JsonField, - private val unitAmount: JsonField, - private val additionalProperties: MutableMap, - ) { + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - @JsonCreator - private constructor( - @JsonProperty("tier_lower_bound") - @ExcludeMissing - tierLowerBound: JsonField = JsonMissing.of(), - @JsonProperty("unit_amount") - @ExcludeMissing - unitAmount: JsonField = JsonMissing.of(), - ) : this(tierLowerBound, unitAmount, mutableMapOf()) + return other is Cadence && value == other.value + } - /** - * Inclusive tier starting value - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type - * or is unexpectedly missing or null (e.g. if the server responded with - * an unexpected value). - */ - fun tierLowerBound(): String = - tierLowerBound.getRequired("tier_lower_bound") + override fun hashCode() = value.hashCode() - /** - * Amount per unit - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type - * or is unexpectedly missing or null (e.g. if the server responded with - * an unexpected value). - */ - fun unitAmount(): String = unitAmount.getRequired("unit_amount") + override fun toString() = value.toString() + } - /** - * Returns the raw JSON value of [tierLowerBound]. - * - * Unlike [tierLowerBound], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("tier_lower_bound") - @ExcludeMissing - fun _tierLowerBound(): JsonField = tierLowerBound + /** Configuration for grouped_with_min_max_thresholds pricing */ + class GroupedWithMinMaxThresholdsConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val groupingKey: JsonField, + private val maximumCharge: JsonField, + private val minimumCharge: JsonField, + private val perUnitRate: JsonField, + private val additionalProperties: MutableMap, + ) { - /** - * Returns the raw JSON value of [unitAmount]. - * - * Unlike [unitAmount], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("unit_amount") + @JsonCreator + private constructor( + @JsonProperty("grouping_key") @ExcludeMissing - fun _unitAmount(): JsonField = unitAmount + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("maximum_charge") + @ExcludeMissing + maximumCharge: JsonField = JsonMissing.of(), + @JsonProperty("minimum_charge") + @ExcludeMissing + minimumCharge: JsonField = JsonMissing.of(), + @JsonProperty("per_unit_rate") + @ExcludeMissing + perUnitRate: JsonField = JsonMissing.of(), + ) : this(groupingKey, maximumCharge, minimumCharge, perUnitRate, mutableMapOf()) - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** + * The event property used to group before applying thresholds + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** + * The maximum amount to charge each group + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun maximumCharge(): String = maximumCharge.getRequired("maximum_charge") - fun toBuilder() = Builder().from(this) + /** + * The minimum amount to charge each group, regardless of usage + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun minimumCharge(): String = minimumCharge.getRequired("minimum_charge") - companion object { + /** + * The base price charged per group + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun perUnitRate(): String = perUnitRate.getRequired("per_unit_rate") - /** - * Returns a mutable builder for constructing an instance of [Tier]. - * - * The following fields are required: - * ```kotlin - * .tierLowerBound() - * .unitAmount() - * ``` - */ - fun builder() = Builder() - } + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey - /** A builder for [Tier]. */ - class Builder internal constructor() { + /** + * Returns the raw JSON value of [maximumCharge]. + * + * Unlike [maximumCharge], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("maximum_charge") + @ExcludeMissing + fun _maximumCharge(): JsonField = maximumCharge - private var tierLowerBound: JsonField? = null - private var unitAmount: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() + /** + * Returns the raw JSON value of [minimumCharge]. + * + * Unlike [minimumCharge], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("minimum_charge") + @ExcludeMissing + fun _minimumCharge(): JsonField = minimumCharge - internal fun from(tier: Tier) = apply { - tierLowerBound = tier.tierLowerBound - unitAmount = tier.unitAmount - additionalProperties = tier.additionalProperties.toMutableMap() - } + /** + * Returns the raw JSON value of [perUnitRate]. + * + * Unlike [perUnitRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("per_unit_rate") + @ExcludeMissing + fun _perUnitRate(): JsonField = perUnitRate + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [GroupedWithMinMaxThresholdsConfig]. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .maximumCharge() + * .minimumCharge() + * .perUnitRate() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [GroupedWithMinMaxThresholdsConfig]. */ + class Builder internal constructor() { + + private var groupingKey: JsonField? = null + private var maximumCharge: JsonField? = null + private var minimumCharge: JsonField? = null + private var perUnitRate: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from( + groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + ) = apply { + groupingKey = groupedWithMinMaxThresholdsConfig.groupingKey + maximumCharge = groupedWithMinMaxThresholdsConfig.maximumCharge + minimumCharge = groupedWithMinMaxThresholdsConfig.minimumCharge + perUnitRate = groupedWithMinMaxThresholdsConfig.perUnitRate + additionalProperties = + groupedWithMinMaxThresholdsConfig.additionalProperties + .toMutableMap() + } - /** Inclusive tier starting value */ - fun tierLowerBound(tierLowerBound: String) = - tierLowerBound(JsonField.of(tierLowerBound)) + /** The event property used to group before applying thresholds */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) - /** - * Sets [Builder.tierLowerBound] to an arbitrary JSON value. - * - * You should usually call [Builder.tierLowerBound] with a well-typed - * [String] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun tierLowerBound(tierLowerBound: JsonField) = apply { - this.tierLowerBound = tierLowerBound - } + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } - /** Amount per unit */ - fun unitAmount(unitAmount: String) = - unitAmount(JsonField.of(unitAmount)) + /** The maximum amount to charge each group */ + fun maximumCharge(maximumCharge: String) = + maximumCharge(JsonField.of(maximumCharge)) - /** - * Sets [Builder.unitAmount] to an arbitrary JSON value. - * - * You should usually call [Builder.unitAmount] with a well-typed - * [String] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun unitAmount(unitAmount: JsonField) = apply { - this.unitAmount = unitAmount - } + /** + * Sets [Builder.maximumCharge] to an arbitrary JSON value. + * + * You should usually call [Builder.maximumCharge] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun maximumCharge(maximumCharge: JsonField) = apply { + this.maximumCharge = maximumCharge + } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** The minimum amount to charge each group, regardless of usage */ + fun minimumCharge(minimumCharge: String) = + minimumCharge(JsonField.of(minimumCharge)) - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * Sets [Builder.minimumCharge] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumCharge] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun minimumCharge(minimumCharge: JsonField) = apply { + this.minimumCharge = minimumCharge + } - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + /** The base price charged per group */ + fun perUnitRate(perUnitRate: String) = + perUnitRate(JsonField.of(perUnitRate)) - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + /** + * Sets [Builder.perUnitRate] to an arbitrary JSON value. + * + * You should usually call [Builder.perUnitRate] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun perUnitRate(perUnitRate: JsonField) = apply { + this.perUnitRate = perUnitRate + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) } - /** - * Returns an immutable instance of [Tier]. - * - * Further updates to this [Builder] will not mutate the returned - * instance. - * - * The following fields are required: - * ```kotlin - * .tierLowerBound() - * .unitAmount() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Tier = - Tier( - checkRequired("tierLowerBound", tierLowerBound), - checkRequired("unitAmount", unitAmount), - additionalProperties.toMutableMap(), - ) + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) } - private var validated: Boolean = false - - fun validate(): Tier = apply { - if (validated) { - return@apply - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - tierLowerBound() - unitAmount() - validated = true + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } /** - * Returns a score indicating how many valid values are contained in this - * object recursively. + * Returns an immutable instance of [GroupedWithMinMaxThresholdsConfig]. * - * Used for best match union deserialization. + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .maximumCharge() + * .minimumCharge() + * .perUnitRate() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ - internal fun validity(): Int = - (if (tierLowerBound.asKnown() == null) 0 else 1) + - (if (unitAmount.asKnown() == null) 0 else 1) + fun build(): GroupedWithMinMaxThresholdsConfig = + GroupedWithMinMaxThresholdsConfig( + checkRequired("groupingKey", groupingKey), + checkRequired("maximumCharge", maximumCharge), + checkRequired("minimumCharge", minimumCharge), + checkRequired("perUnitRate", perUnitRate), + additionalProperties.toMutableMap(), + ) + } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + private var validated: Boolean = false - return other is Tier && - tierLowerBound == other.tierLowerBound && - unitAmount == other.unitAmount && - additionalProperties == other.additionalProperties + fun validate(): GroupedWithMinMaxThresholdsConfig = apply { + if (validated) { + return@apply } - private val hashCode: Int by lazy { - Objects.hash(tierLowerBound, unitAmount, additionalProperties) - } + groupingKey() + maximumCharge() + minimumCharge() + perUnitRate() + validated = true + } - override fun hashCode(): Int = hashCode + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - override fun toString() = - "Tier{tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" - } + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (groupingKey.asKnown() == null) 0 else 1) + + (if (maximumCharge.asKnown() == null) 0 else 1) + + (if (minimumCharge.asKnown() == null) 0 else 1) + + (if (perUnitRate.asKnown() == null) 0 else 1) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is TieredWithProrationConfig && - tiers == other.tiers && + return other is GroupedWithMinMaxThresholdsConfig && + groupingKey == other.groupingKey && + maximumCharge == other.maximumCharge && + minimumCharge == other.minimumCharge && + perUnitRate == other.perUnitRate && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(tiers, additionalProperties) } + private val hashCode: Int by lazy { + Objects.hash( + groupingKey, + maximumCharge, + minimumCharge, + perUnitRate, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode override fun toString() = - "TieredWithProrationConfig{tiers=$tiers, additionalProperties=$additionalProperties}" + "GroupedWithMinMaxThresholdsConfig{groupingKey=$groupingKey, maximumCharge=$maximumCharge, minimumCharge=$minimumCharge, perUnitRate=$perUnitRate, additionalProperties=$additionalProperties}" } /** @@ -10940,12 +14267,13 @@ private constructor( return true } - return other is TieredWithProration && + return other is GroupedWithMinMaxThresholds && cadence == other.cadence && + groupedWithMinMaxThresholdsConfig == + other.groupedWithMinMaxThresholdsConfig && itemId == other.itemId && modelType == other.modelType && name == other.name && - tieredWithProrationConfig == other.tieredWithProrationConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && @@ -10965,10 +14293,10 @@ private constructor( private val hashCode: Int by lazy { Objects.hash( cadence, + groupedWithMinMaxThresholdsConfig, itemId, modelType, name, - tieredWithProrationConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -10989,15 +14317,14 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "TieredWithProration{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredWithProrationConfig=$tieredWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "GroupedWithMinMaxThresholds{cadence=$cadence, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class GroupedWithMinMaxThresholds + class EventOutput @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, - private val groupedWithMinMaxThresholdsConfig: - JsonField, + private val eventOutputConfig: JsonField, private val itemId: JsonField, private val modelType: JsonValue, private val name: JsonField, @@ -11022,12 +14349,10 @@ private constructor( private constructor( @JsonProperty("cadence") @ExcludeMissing - cadence: JsonField = JsonMissing.of(), - @JsonProperty("grouped_with_min_max_thresholds_config") - @ExcludeMissing - groupedWithMinMaxThresholdsConfig: - JsonField = - JsonMissing.of(), + cadence: JsonField = JsonMissing.of(), + @JsonProperty("event_output_config") + @ExcludeMissing + eventOutputConfig: JsonField = JsonMissing.of(), @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), @@ -11081,7 +14406,7 @@ private constructor( referenceId: JsonField = JsonMissing.of(), ) : this( cadence, - groupedWithMinMaxThresholdsConfig, + eventOutputConfig, itemId, modelType, name, @@ -11111,16 +14436,14 @@ private constructor( fun cadence(): Cadence = cadence.getRequired("cadence") /** - * Configuration for grouped_with_min_max_thresholds pricing + * Configuration for event_output pricing * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected * value). */ - fun groupedWithMinMaxThresholdsConfig(): GroupedWithMinMaxThresholdsConfig = - groupedWithMinMaxThresholdsConfig.getRequired( - "grouped_with_min_max_thresholds_config" - ) + fun eventOutputConfig(): EventOutputConfig = + eventOutputConfig.getRequired("event_output_config") /** * The id of the item the price will be associated with. @@ -11136,7 +14459,7 @@ private constructor( * * Expected to always return the following: * ```kotlin - * JsonValue.from("grouped_with_min_max_thresholds") + * JsonValue.from("event_output") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -11283,15 +14606,14 @@ private constructor( fun _cadence(): JsonField = cadence /** - * Returns the raw JSON value of [groupedWithMinMaxThresholdsConfig]. + * Returns the raw JSON value of [eventOutputConfig]. * - * Unlike [groupedWithMinMaxThresholdsConfig], this method doesn't throw if the JSON - * field has an unexpected type. + * Unlike [eventOutputConfig], this method doesn't throw if the JSON field has an + * unexpected type. */ - @JsonProperty("grouped_with_min_max_thresholds_config") + @JsonProperty("event_output_config") @ExcludeMissing - fun _groupedWithMinMaxThresholdsConfig(): - JsonField = groupedWithMinMaxThresholdsConfig + fun _eventOutputConfig(): JsonField = eventOutputConfig /** * Returns the raw JSON value of [itemId]. @@ -11457,13 +14779,12 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [GroupedWithMinMaxThresholds]. + * Returns a mutable builder for constructing an instance of [EventOutput]. * * The following fields are required: * ```kotlin * .cadence() - * .groupedWithMinMaxThresholdsConfig() + * .eventOutputConfig() * .itemId() * .name() * ``` @@ -11471,16 +14792,13 @@ private constructor( fun builder() = Builder() } - /** A builder for [GroupedWithMinMaxThresholds]. */ + /** A builder for [EventOutput]. */ class Builder internal constructor() { private var cadence: JsonField? = null - private var groupedWithMinMaxThresholdsConfig: - JsonField? = - null + private var eventOutputConfig: JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonValue = - JsonValue.from("grouped_with_min_max_thresholds") + private var modelType: JsonValue = JsonValue.from("event_output") private var name: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() @@ -11503,33 +14821,27 @@ private constructor( private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds) = - apply { - cadence = groupedWithMinMaxThresholds.cadence - groupedWithMinMaxThresholdsConfig = - groupedWithMinMaxThresholds.groupedWithMinMaxThresholdsConfig - itemId = groupedWithMinMaxThresholds.itemId - modelType = groupedWithMinMaxThresholds.modelType - name = groupedWithMinMaxThresholds.name - billableMetricId = groupedWithMinMaxThresholds.billableMetricId - billedInAdvance = groupedWithMinMaxThresholds.billedInAdvance - billingCycleConfiguration = - groupedWithMinMaxThresholds.billingCycleConfiguration - conversionRate = groupedWithMinMaxThresholds.conversionRate - conversionRateConfig = groupedWithMinMaxThresholds.conversionRateConfig - currency = groupedWithMinMaxThresholds.currency - dimensionalPriceConfiguration = - groupedWithMinMaxThresholds.dimensionalPriceConfiguration - externalPriceId = groupedWithMinMaxThresholds.externalPriceId - fixedPriceQuantity = groupedWithMinMaxThresholds.fixedPriceQuantity - invoiceGroupingKey = groupedWithMinMaxThresholds.invoiceGroupingKey - invoicingCycleConfiguration = - groupedWithMinMaxThresholds.invoicingCycleConfiguration - metadata = groupedWithMinMaxThresholds.metadata - referenceId = groupedWithMinMaxThresholds.referenceId - additionalProperties = - groupedWithMinMaxThresholds.additionalProperties.toMutableMap() - } + internal fun from(eventOutput: EventOutput) = apply { + cadence = eventOutput.cadence + eventOutputConfig = eventOutput.eventOutputConfig + itemId = eventOutput.itemId + modelType = eventOutput.modelType + name = eventOutput.name + billableMetricId = eventOutput.billableMetricId + billedInAdvance = eventOutput.billedInAdvance + billingCycleConfiguration = eventOutput.billingCycleConfiguration + conversionRate = eventOutput.conversionRate + conversionRateConfig = eventOutput.conversionRateConfig + currency = eventOutput.currency + dimensionalPriceConfiguration = eventOutput.dimensionalPriceConfiguration + externalPriceId = eventOutput.externalPriceId + fixedPriceQuantity = eventOutput.fixedPriceQuantity + invoiceGroupingKey = eventOutput.invoiceGroupingKey + invoicingCycleConfiguration = eventOutput.invoicingCycleConfiguration + metadata = eventOutput.metadata + referenceId = eventOutput.referenceId + additionalProperties = eventOutput.additionalProperties.toMutableMap() + } /** The cadence to bill for this price on. */ fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) @@ -11543,27 +14855,19 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - /** Configuration for grouped_with_min_max_thresholds pricing */ - fun groupedWithMinMaxThresholdsConfig( - groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig - ) = - groupedWithMinMaxThresholdsConfig( - JsonField.of(groupedWithMinMaxThresholdsConfig) - ) + /** Configuration for event_output pricing */ + fun eventOutputConfig(eventOutputConfig: EventOutputConfig) = + eventOutputConfig(JsonField.of(eventOutputConfig)) /** - * Sets [Builder.groupedWithMinMaxThresholdsConfig] to an arbitrary JSON value. + * Sets [Builder.eventOutputConfig] to an arbitrary JSON value. * - * You should usually call [Builder.groupedWithMinMaxThresholdsConfig] with a - * well-typed [GroupedWithMinMaxThresholdsConfig] value instead. This method is - * primarily for setting the field to an undocumented or not yet supported - * value. + * You should usually call [Builder.eventOutputConfig] with a well-typed + * [EventOutputConfig] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. */ - fun groupedWithMinMaxThresholdsConfig( - groupedWithMinMaxThresholdsConfig: - JsonField - ) = apply { - this.groupedWithMinMaxThresholdsConfig = groupedWithMinMaxThresholdsConfig + fun eventOutputConfig(eventOutputConfig: JsonField) = apply { + this.eventOutputConfig = eventOutputConfig } /** The id of the item the price will be associated with. */ @@ -11584,7 +14888,7 @@ private constructor( * It is usually unnecessary to call this method because the field defaults to * the following: * ```kotlin - * JsonValue.from("grouped_with_min_max_thresholds") + * JsonValue.from("event_output") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -11933,27 +15237,24 @@ private constructor( } /** - * Returns an immutable instance of [GroupedWithMinMaxThresholds]. + * Returns an immutable instance of [EventOutput]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```kotlin * .cadence() - * .groupedWithMinMaxThresholdsConfig() + * .eventOutputConfig() * .itemId() * .name() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): GroupedWithMinMaxThresholds = - GroupedWithMinMaxThresholds( + fun build(): EventOutput = + EventOutput( checkRequired("cadence", cadence), - checkRequired( - "groupedWithMinMaxThresholdsConfig", - groupedWithMinMaxThresholdsConfig, - ), + checkRequired("eventOutputConfig", eventOutputConfig), checkRequired("itemId", itemId), modelType, checkRequired("name", name), @@ -11976,16 +15277,16 @@ private constructor( private var validated: Boolean = false - fun validate(): GroupedWithMinMaxThresholds = apply { + fun validate(): EventOutput = apply { if (validated) { return@apply } cadence().validate() - groupedWithMinMaxThresholdsConfig().validate() + eventOutputConfig().validate() itemId() _modelType().let { - if (it != JsonValue.from("grouped_with_min_max_thresholds")) { + if (it != JsonValue.from("event_output")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } @@ -12022,11 +15323,9 @@ private constructor( */ internal fun validity(): Int = (cadence.asKnown()?.validity() ?: 0) + - (groupedWithMinMaxThresholdsConfig.asKnown()?.validity() ?: 0) + + (eventOutputConfig.asKnown()?.validity() ?: 0) + (if (itemId.asKnown() == null) 0 else 1) + - modelType.let { - if (it == JsonValue.from("grouped_with_min_max_thresholds")) 1 else 0 - } + + modelType.let { if (it == JsonValue.from("event_output")) 1 else 0 } + (if (name.asKnown() == null) 0 else 1) + (if (billableMetricId.asKnown() == null) 0 else 1) + (if (billedInAdvance.asKnown() == null) 0 else 1) + @@ -12199,68 +15498,52 @@ private constructor( override fun toString() = value.toString() } - /** Configuration for grouped_with_min_max_thresholds pricing */ - class GroupedWithMinMaxThresholdsConfig + /** Configuration for event_output pricing */ + class EventOutputConfig @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( + private val unitRatingKey: JsonField, private val groupingKey: JsonField, - private val maximumCharge: JsonField, - private val minimumCharge: JsonField, - private val perUnitRate: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( + @JsonProperty("unit_rating_key") + @ExcludeMissing + unitRatingKey: JsonField = JsonMissing.of(), @JsonProperty("grouping_key") @ExcludeMissing groupingKey: JsonField = JsonMissing.of(), - @JsonProperty("maximum_charge") - @ExcludeMissing - maximumCharge: JsonField = JsonMissing.of(), - @JsonProperty("minimum_charge") - @ExcludeMissing - minimumCharge: JsonField = JsonMissing.of(), - @JsonProperty("per_unit_rate") - @ExcludeMissing - perUnitRate: JsonField = JsonMissing.of(), - ) : this(groupingKey, maximumCharge, minimumCharge, perUnitRate, mutableMapOf()) - - /** - * The event property used to group before applying thresholds - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun groupingKey(): String = groupingKey.getRequired("grouping_key") + ) : this(unitRatingKey, groupingKey, mutableMapOf()) /** - * The maximum amount to charge each group + * The key in the event data to extract the unit rate from. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). */ - fun maximumCharge(): String = maximumCharge.getRequired("maximum_charge") + fun unitRatingKey(): String = unitRatingKey.getRequired("unit_rating_key") /** - * The minimum amount to charge each group, regardless of usage + * An optional key in the event data to group by (e.g., event ID). All events + * will also be grouped by their unit rate. * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). */ - fun minimumCharge(): String = minimumCharge.getRequired("minimum_charge") + fun groupingKey(): String? = groupingKey.getNullable("grouping_key") /** - * The base price charged per group + * Returns the raw JSON value of [unitRatingKey]. * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). + * Unlike [unitRatingKey], this method doesn't throw if the JSON field has an + * unexpected type. */ - fun perUnitRate(): String = perUnitRate.getRequired("per_unit_rate") + @JsonProperty("unit_rating_key") + @ExcludeMissing + fun _unitRatingKey(): JsonField = unitRatingKey /** * Returns the raw JSON value of [groupingKey]. @@ -12272,36 +15555,6 @@ private constructor( @ExcludeMissing fun _groupingKey(): JsonField = groupingKey - /** - * Returns the raw JSON value of [maximumCharge]. - * - * Unlike [maximumCharge], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("maximum_charge") - @ExcludeMissing - fun _maximumCharge(): JsonField = maximumCharge - - /** - * Returns the raw JSON value of [minimumCharge]. - * - * Unlike [minimumCharge], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("minimum_charge") - @ExcludeMissing - fun _minimumCharge(): JsonField = minimumCharge - - /** - * Returns the raw JSON value of [perUnitRate]. - * - * Unlike [perUnitRate], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("per_unit_rate") - @ExcludeMissing - fun _perUnitRate(): JsonField = perUnitRate - @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -12318,99 +15571,62 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [GroupedWithMinMaxThresholdsConfig]. + * [EventOutputConfig]. * * The following fields are required: * ```kotlin - * .groupingKey() - * .maximumCharge() - * .minimumCharge() - * .perUnitRate() + * .unitRatingKey() * ``` */ fun builder() = Builder() } - /** A builder for [GroupedWithMinMaxThresholdsConfig]. */ + /** A builder for [EventOutputConfig]. */ class Builder internal constructor() { - private var groupingKey: JsonField? = null - private var maximumCharge: JsonField? = null - private var minimumCharge: JsonField? = null - private var perUnitRate: JsonField? = null + private var unitRatingKey: JsonField? = null + private var groupingKey: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() - internal fun from( - groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig - ) = apply { - groupingKey = groupedWithMinMaxThresholdsConfig.groupingKey - maximumCharge = groupedWithMinMaxThresholdsConfig.maximumCharge - minimumCharge = groupedWithMinMaxThresholdsConfig.minimumCharge - perUnitRate = groupedWithMinMaxThresholdsConfig.perUnitRate + internal fun from(eventOutputConfig: EventOutputConfig) = apply { + unitRatingKey = eventOutputConfig.unitRatingKey + groupingKey = eventOutputConfig.groupingKey additionalProperties = - groupedWithMinMaxThresholdsConfig.additionalProperties - .toMutableMap() - } - - /** The event property used to group before applying thresholds */ - fun groupingKey(groupingKey: String) = - groupingKey(JsonField.of(groupingKey)) - - /** - * Sets [Builder.groupingKey] to an arbitrary JSON value. - * - * You should usually call [Builder.groupingKey] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun groupingKey(groupingKey: JsonField) = apply { - this.groupingKey = groupingKey + eventOutputConfig.additionalProperties.toMutableMap() } - /** The maximum amount to charge each group */ - fun maximumCharge(maximumCharge: String) = - maximumCharge(JsonField.of(maximumCharge)) + /** The key in the event data to extract the unit rate from. */ + fun unitRatingKey(unitRatingKey: String) = + unitRatingKey(JsonField.of(unitRatingKey)) /** - * Sets [Builder.maximumCharge] to an arbitrary JSON value. + * Sets [Builder.unitRatingKey] to an arbitrary JSON value. * - * You should usually call [Builder.maximumCharge] with a well-typed + * You should usually call [Builder.unitRatingKey] with a well-typed * [String] value instead. This method is primarily for setting the field to * an undocumented or not yet supported value. */ - fun maximumCharge(maximumCharge: JsonField) = apply { - this.maximumCharge = maximumCharge + fun unitRatingKey(unitRatingKey: JsonField) = apply { + this.unitRatingKey = unitRatingKey } - /** The minimum amount to charge each group, regardless of usage */ - fun minimumCharge(minimumCharge: String) = - minimumCharge(JsonField.of(minimumCharge)) - /** - * Sets [Builder.minimumCharge] to an arbitrary JSON value. - * - * You should usually call [Builder.minimumCharge] with a well-typed - * [String] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. + * An optional key in the event data to group by (e.g., event ID). All + * events will also be grouped by their unit rate. */ - fun minimumCharge(minimumCharge: JsonField) = apply { - this.minimumCharge = minimumCharge - } - - /** The base price charged per group */ - fun perUnitRate(perUnitRate: String) = - perUnitRate(JsonField.of(perUnitRate)) + fun groupingKey(groupingKey: String?) = + groupingKey(JsonField.ofNullable(groupingKey)) /** - * Sets [Builder.perUnitRate] to an arbitrary JSON value. + * Sets [Builder.groupingKey] to an arbitrary JSON value. * - * You should usually call [Builder.perUnitRate] with a well-typed [String] + * You should usually call [Builder.groupingKey] with a well-typed [String] * value instead. This method is primarily for setting the field to an * undocumented or not yet supported value. */ - fun perUnitRate(perUnitRate: JsonField) = apply { - this.perUnitRate = perUnitRate + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey } fun additionalProperties(additionalProperties: Map) = @@ -12436,41 +15652,34 @@ private constructor( } /** - * Returns an immutable instance of [GroupedWithMinMaxThresholdsConfig]. + * Returns an immutable instance of [EventOutputConfig]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```kotlin - * .groupingKey() - * .maximumCharge() - * .minimumCharge() - * .perUnitRate() + * .unitRatingKey() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): GroupedWithMinMaxThresholdsConfig = - GroupedWithMinMaxThresholdsConfig( - checkRequired("groupingKey", groupingKey), - checkRequired("maximumCharge", maximumCharge), - checkRequired("minimumCharge", minimumCharge), - checkRequired("perUnitRate", perUnitRate), + fun build(): EventOutputConfig = + EventOutputConfig( + checkRequired("unitRatingKey", unitRatingKey), + groupingKey, additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): GroupedWithMinMaxThresholdsConfig = apply { + fun validate(): EventOutputConfig = apply { if (validated) { return@apply } + unitRatingKey() groupingKey() - maximumCharge() - minimumCharge() - perUnitRate() validated = true } @@ -12489,38 +15698,28 @@ private constructor( * Used for best match union deserialization. */ internal fun validity(): Int = - (if (groupingKey.asKnown() == null) 0 else 1) + - (if (maximumCharge.asKnown() == null) 0 else 1) + - (if (minimumCharge.asKnown() == null) 0 else 1) + - (if (perUnitRate.asKnown() == null) 0 else 1) + (if (unitRatingKey.asKnown() == null) 0 else 1) + + (if (groupingKey.asKnown() == null) 0 else 1) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is GroupedWithMinMaxThresholdsConfig && + return other is EventOutputConfig && + unitRatingKey == other.unitRatingKey && groupingKey == other.groupingKey && - maximumCharge == other.maximumCharge && - minimumCharge == other.minimumCharge && - perUnitRate == other.perUnitRate && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash( - groupingKey, - maximumCharge, - minimumCharge, - perUnitRate, - additionalProperties, - ) + Objects.hash(unitRatingKey, groupingKey, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "GroupedWithMinMaxThresholdsConfig{groupingKey=$groupingKey, maximumCharge=$maximumCharge, minimumCharge=$minimumCharge, perUnitRate=$perUnitRate, additionalProperties=$additionalProperties}" + "EventOutputConfig{unitRatingKey=$unitRatingKey, groupingKey=$groupingKey, additionalProperties=$additionalProperties}" } /** @@ -12637,10 +15836,9 @@ private constructor( return true } - return other is GroupedWithMinMaxThresholds && + return other is EventOutput && cadence == other.cadence && - groupedWithMinMaxThresholdsConfig == - other.groupedWithMinMaxThresholdsConfig && + eventOutputConfig == other.eventOutputConfig && itemId == other.itemId && modelType == other.modelType && name == other.name && @@ -12663,7 +15861,7 @@ private constructor( private val hashCode: Int by lazy { Objects.hash( cadence, - groupedWithMinMaxThresholdsConfig, + eventOutputConfig, itemId, modelType, name, @@ -12687,7 +15885,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "GroupedWithMinMaxThresholds{cadence=$cadence, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "EventOutput{cadence=$cadence, eventOutputConfig=$eventOutputConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } } diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/ChangedSubscriptionResources.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/ChangedSubscriptionResources.kt index 8602b1d09..8cee6ff23 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/ChangedSubscriptionResources.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/ChangedSubscriptionResources.kt @@ -5557,6 +5557,9 @@ private constructor( /** Alias for calling [price] with `Price.ofMinimum(minimum)`. */ fun price(minimum: Price.Minimum) = price(Price.ofMinimum(minimum)) + /** Alias for calling [price] with `Price.ofEventOutput(eventOutput)`. */ + fun price(eventOutput: Price.EventOutput) = price(Price.ofEventOutput(eventOutput)) + /** Either the fixed fee quantity or the usage during the service period. */ fun quantity(quantity: Double) = quantity(JsonField.of(quantity)) diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Invoice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Invoice.kt index b2b66b8b3..5157d935e 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Invoice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Invoice.kt @@ -5039,6 +5039,9 @@ private constructor( /** Alias for calling [price] with `Price.ofMinimum(minimum)`. */ fun price(minimum: Price.Minimum) = price(Price.ofMinimum(minimum)) + /** Alias for calling [price] with `Price.ofEventOutput(eventOutput)`. */ + fun price(eventOutput: Price.EventOutput) = price(Price.ofEventOutput(eventOutput)) + /** Either the fixed fee quantity or the usage during the service period. */ fun quantity(quantity: Double) = quantity(JsonField.of(quantity)) diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceFetchUpcomingResponse.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceFetchUpcomingResponse.kt index 37a678e73..a39f5b710 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceFetchUpcomingResponse.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceFetchUpcomingResponse.kt @@ -5033,6 +5033,9 @@ private constructor( /** Alias for calling [price] with `Price.ofMinimum(minimum)`. */ fun price(minimum: Price.Minimum) = price(Price.ofMinimum(minimum)) + /** Alias for calling [price] with `Price.ofEventOutput(eventOutput)`. */ + fun price(eventOutput: Price.EventOutput) = price(Price.ofEventOutput(eventOutput)) + /** Either the fixed fee quantity or the usage during the service period. */ fun quantity(quantity: Double) = quantity(JsonField.of(quantity)) diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceLineItemCreateResponse.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceLineItemCreateResponse.kt index c41d8f094..54affc459 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceLineItemCreateResponse.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceLineItemCreateResponse.kt @@ -1078,6 +1078,9 @@ private constructor( /** Alias for calling [price] with `Price.ofMinimum(minimum)`. */ fun price(minimum: Price.Minimum) = price(Price.ofMinimum(minimum)) + /** Alias for calling [price] with `Price.ofEventOutput(eventOutput)`. */ + fun price(eventOutput: Price.EventOutput) = price(Price.ofEventOutput(eventOutput)) + /** Either the fixed fee quantity or the usage during the service period. */ fun quantity(quantity: Double) = quantity(JsonField.of(quantity)) diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Item.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Item.kt index 4d2b31a31..92c529fe8 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Item.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Item.kt @@ -32,6 +32,7 @@ private constructor( private val externalConnections: JsonField>, private val metadata: JsonField, private val name: JsonField, + private val archivedAt: JsonField, private val additionalProperties: MutableMap, ) { @@ -46,21 +47,31 @@ private constructor( externalConnections: JsonField> = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - ) : this(id, createdAt, externalConnections, metadata, name, mutableMapOf()) + @JsonProperty("archived_at") + @ExcludeMissing + archivedAt: JsonField = JsonMissing.of(), + ) : this(id, createdAt, externalConnections, metadata, name, archivedAt, mutableMapOf()) /** + * The Orb-assigned unique identifier for the item. + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ fun id(): String = id.getRequired("id") /** + * The time at which the item was created. + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") /** + * A list of external connections for this item, used to sync with external invoicing and tax + * systems. + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ @@ -78,11 +89,21 @@ private constructor( fun metadata(): Metadata = metadata.getRequired("metadata") /** + * The name of the item. + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ fun name(): String = name.getRequired("name") + /** + * The time at which the item was archived. If null, the item is not archived. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun archivedAt(): OffsetDateTime? = archivedAt.getNullable("archived_at") + /** * Returns the raw JSON value of [id]. * @@ -123,6 +144,15 @@ private constructor( */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + /** + * Returns the raw JSON value of [archivedAt]. + * + * Unlike [archivedAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("archived_at") + @ExcludeMissing + fun _archivedAt(): JsonField = archivedAt + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -160,6 +190,7 @@ private constructor( private var externalConnections: JsonField>? = null private var metadata: JsonField? = null private var name: JsonField? = null + private var archivedAt: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() internal fun from(item: Item) = apply { @@ -168,9 +199,11 @@ private constructor( externalConnections = item.externalConnections.map { it.toMutableList() } metadata = item.metadata name = item.name + archivedAt = item.archivedAt additionalProperties = item.additionalProperties.toMutableMap() } + /** The Orb-assigned unique identifier for the item. */ fun id(id: String) = id(JsonField.of(id)) /** @@ -181,6 +214,7 @@ private constructor( */ fun id(id: JsonField) = apply { this.id = id } + /** The time at which the item was created. */ fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) /** @@ -192,6 +226,10 @@ private constructor( */ fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } + /** + * A list of external connections for this item, used to sync with external invoicing and + * tax systems. + */ fun externalConnections(externalConnections: List) = externalConnections(JsonField.of(externalConnections)) @@ -234,6 +272,7 @@ private constructor( */ fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + /** The name of the item. */ fun name(name: String) = name(JsonField.of(name)) /** @@ -244,6 +283,20 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } + /** The time at which the item was archived. If null, the item is not archived. */ + fun archivedAt(archivedAt: OffsetDateTime?) = archivedAt(JsonField.ofNullable(archivedAt)) + + /** + * Sets [Builder.archivedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.archivedAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun archivedAt(archivedAt: JsonField) = apply { + this.archivedAt = archivedAt + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -286,6 +339,7 @@ private constructor( checkRequired("externalConnections", externalConnections).map { it.toImmutable() }, checkRequired("metadata", metadata), checkRequired("name", name), + archivedAt, additionalProperties.toMutableMap(), ) } @@ -302,6 +356,7 @@ private constructor( externalConnections().forEach { it.validate() } metadata().validate() name() + archivedAt() validated = true } @@ -323,8 +378,13 @@ private constructor( (if (createdAt.asKnown() == null) 0 else 1) + (externalConnections.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + (metadata.asKnown()?.validity() ?: 0) + - (if (name.asKnown() == null) 0 else 1) + (if (name.asKnown() == null) 0 else 1) + + (if (archivedAt.asKnown() == null) 0 else 1) + /** + * Represents a connection between an Item and an external system for invoicing or tax + * calculation purposes. + */ class ExternalConnection @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( @@ -344,6 +404,8 @@ private constructor( ) : this(externalConnectionName, externalEntityId, mutableMapOf()) /** + * The name of the external system this item is connected to. + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ @@ -351,6 +413,8 @@ private constructor( externalConnectionName.getRequired("external_connection_name") /** + * The identifier of this item in the external system. + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ @@ -415,6 +479,7 @@ private constructor( additionalProperties = externalConnection.additionalProperties.toMutableMap() } + /** The name of the external system this item is connected to. */ fun externalConnectionName(externalConnectionName: ExternalConnectionName) = externalConnectionName(JsonField.of(externalConnectionName)) @@ -430,6 +495,7 @@ private constructor( this.externalConnectionName = externalConnectionName } + /** The identifier of this item in the external system. */ fun externalEntityId(externalEntityId: String) = externalEntityId(JsonField.of(externalEntityId)) @@ -514,6 +580,7 @@ private constructor( (externalConnectionName.asKnown()?.validity() ?: 0) + (if (externalEntityId.asKnown() == null) 0 else 1) + /** The name of the external system this item is connected to. */ class ExternalConnectionName @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -816,15 +883,24 @@ private constructor( externalConnections == other.externalConnections && metadata == other.metadata && name == other.name && + archivedAt == other.archivedAt && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(id, createdAt, externalConnections, metadata, name, additionalProperties) + Objects.hash( + id, + createdAt, + externalConnections, + metadata, + name, + archivedAt, + additionalProperties, + ) } override fun hashCode(): Int = hashCode override fun toString() = - "Item{id=$id, createdAt=$createdAt, externalConnections=$externalConnections, metadata=$metadata, name=$name, additionalProperties=$additionalProperties}" + "Item{id=$id, createdAt=$createdAt, externalConnections=$externalConnections, metadata=$metadata, name=$name, archivedAt=$archivedAt, additionalProperties=$additionalProperties}" } diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/ItemSlim.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/ItemSlim.kt index 568f85d90..5d9ad4ba2 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/ItemSlim.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/ItemSlim.kt @@ -15,6 +15,7 @@ import com.withorb.api.errors.OrbInvalidDataException import java.util.Collections import java.util.Objects +/** A minimal representation of an Item containing only the essential identifying information. */ class ItemSlim @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( @@ -30,12 +31,16 @@ private constructor( ) : this(id, name, mutableMapOf()) /** + * The Orb-assigned unique identifier for the item. + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ fun id(): String = id.getRequired("id") /** + * The name of the item. + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ @@ -94,6 +99,7 @@ private constructor( additionalProperties = itemSlim.additionalProperties.toMutableMap() } + /** The Orb-assigned unique identifier for the item. */ fun id(id: String) = id(JsonField.of(id)) /** @@ -104,6 +110,7 @@ private constructor( */ fun id(id: JsonField) = apply { this.id = id } + /** The name of the item. */ fun name(name: String) = name(JsonField.of(name)) /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/ItemUpdateParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/ItemUpdateParams.kt index a7ca005ad..8a68183ae 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/ItemUpdateParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/ItemUpdateParams.kt @@ -561,6 +561,10 @@ private constructor( "Body{externalConnections=$externalConnections, metadata=$metadata, name=$name, additionalProperties=$additionalProperties}" } + /** + * Represents a connection between an Item and an external system for invoicing or tax + * calculation purposes. + */ class ExternalConnection @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( @@ -580,6 +584,8 @@ private constructor( ) : this(externalConnectionName, externalEntityId, mutableMapOf()) /** + * The name of the external system this item is connected to. + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ @@ -587,6 +593,8 @@ private constructor( externalConnectionName.getRequired("external_connection_name") /** + * The identifier of this item in the external system. + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ @@ -651,6 +659,7 @@ private constructor( additionalProperties = externalConnection.additionalProperties.toMutableMap() } + /** The name of the external system this item is connected to. */ fun externalConnectionName(externalConnectionName: ExternalConnectionName) = externalConnectionName(JsonField.of(externalConnectionName)) @@ -666,6 +675,7 @@ private constructor( this.externalConnectionName = externalConnectionName } + /** The identifier of this item in the external system. */ fun externalEntityId(externalEntityId: String) = externalEntityId(JsonField.of(externalEntityId)) @@ -750,6 +760,7 @@ private constructor( (externalConnectionName.asKnown()?.validity() ?: 0) + (if (externalEntityId.asKnown() == null) 0 else 1) + /** The name of the external system this item is connected to. */ class ExternalConnectionName @JsonCreator private constructor(private val value: JsonField) : Enum { diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PerPriceCost.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PerPriceCost.kt index 8aee5fe08..3abf8398a 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PerPriceCost.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PerPriceCost.kt @@ -294,6 +294,9 @@ private constructor( /** Alias for calling [price] with `Price.ofMinimum(minimum)`. */ fun price(minimum: Price.Minimum) = price(Price.ofMinimum(minimum)) + /** Alias for calling [price] with `Price.ofEventOutput(eventOutput)`. */ + fun price(eventOutput: Price.EventOutput) = price(Price.ofEventOutput(eventOutput)) + /** The price the cost is associated with */ fun priceId(priceId: String) = priceId(JsonField.of(priceId)) diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Plan.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Plan.kt index ba78de44e..05d9421fc 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Plan.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Plan.kt @@ -1177,6 +1177,9 @@ private constructor( /** Alias for calling [addPrice] with `Price.ofMinimum(minimum)`. */ fun addPrice(minimum: Price.Minimum) = addPrice(Price.ofMinimum(minimum)) + /** Alias for calling [addPrice] with `Price.ofEventOutput(eventOutput)`. */ + fun addPrice(eventOutput: Price.EventOutput) = addPrice(Price.ofEventOutput(eventOutput)) + fun product(product: Product) = product(JsonField.of(product)) /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanCreateParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanCreateParams.kt index be50862bc..f6dbbec45 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanCreateParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanCreateParams.kt @@ -1468,6 +1468,10 @@ private constructor( /** Alias for calling [price] with `InnerPrice.ofMinimum(minimum)`. */ fun price(minimum: NewPlanMinimumCompositePrice) = price(InnerPrice.ofMinimum(minimum)) + /** Alias for calling [price] with `InnerPrice.ofEventOutput(eventOutput)`. */ + fun price(eventOutput: InnerPrice.EventOutput) = + price(InnerPrice.ofEventOutput(eventOutput)) + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -1563,6 +1567,7 @@ private constructor( null, private val cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice? = null, private val minimum: NewPlanMinimumCompositePrice? = null, + private val eventOutput: EventOutput? = null, private val _json: JsonValue? = null, ) { @@ -1626,6 +1631,8 @@ private constructor( fun minimum(): NewPlanMinimumCompositePrice? = minimum + fun eventOutput(): EventOutput? = eventOutput + fun isUnit(): Boolean = unit != null fun isTiered(): Boolean = tiered != null @@ -1681,6 +1688,8 @@ private constructor( fun isMinimum(): Boolean = minimum != null + fun isEventOutput(): Boolean = eventOutput != null + fun asUnit(): NewPlanUnitPrice = unit.getOrThrow("unit") fun asTiered(): NewPlanTieredPrice = tiered.getOrThrow("tiered") @@ -1756,6 +1765,8 @@ private constructor( fun asMinimum(): NewPlanMinimumCompositePrice = minimum.getOrThrow("minimum") + fun asEventOutput(): EventOutput = eventOutput.getOrThrow("eventOutput") + fun _json(): JsonValue? = _json fun accept(visitor: Visitor): T = @@ -1803,6 +1814,7 @@ private constructor( cumulativeGroupedBulk != null -> visitor.visitCumulativeGroupedBulk(cumulativeGroupedBulk) minimum != null -> visitor.visitMinimum(minimum) + eventOutput != null -> visitor.visitEventOutput(eventOutput) else -> visitor.unknown(_json) } @@ -1961,6 +1973,10 @@ private constructor( override fun visitMinimum(minimum: NewPlanMinimumCompositePrice) { minimum.validate() } + + override fun visitEventOutput(eventOutput: EventOutput) { + eventOutput.validate() + } } ) validated = true @@ -2080,6 +2096,9 @@ private constructor( override fun visitMinimum(minimum: NewPlanMinimumCompositePrice) = minimum.validity() + override fun visitEventOutput(eventOutput: EventOutput) = + eventOutput.validity() + override fun unknown(json: JsonValue?) = 0 } ) @@ -2116,7 +2135,8 @@ private constructor( scalableMatrixWithUnitPricing == other.scalableMatrixWithUnitPricing && scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && cumulativeGroupedBulk == other.cumulativeGroupedBulk && - minimum == other.minimum + minimum == other.minimum && + eventOutput == other.eventOutput } override fun hashCode(): Int = @@ -2148,6 +2168,7 @@ private constructor( scalableMatrixWithTieredPricing, cumulativeGroupedBulk, minimum, + eventOutput, ) override fun toString(): String = @@ -2193,6 +2214,7 @@ private constructor( cumulativeGroupedBulk != null -> "InnerPrice{cumulativeGroupedBulk=$cumulativeGroupedBulk}" minimum != null -> "InnerPrice{minimum=$minimum}" + eventOutput != null -> "InnerPrice{eventOutput=$eventOutput}" _json != null -> "InnerPrice{_unknown=$_json}" else -> throw IllegalStateException("Invalid InnerPrice") } @@ -2283,6 +2305,8 @@ private constructor( ) = InnerPrice(cumulativeGroupedBulk = cumulativeGroupedBulk) fun ofMinimum(minimum: NewPlanMinimumCompositePrice) = InnerPrice(minimum = minimum) + + fun ofEventOutput(eventOutput: EventOutput) = InnerPrice(eventOutput = eventOutput) } /** @@ -2371,6 +2395,8 @@ private constructor( fun visitMinimum(minimum: NewPlanMinimumCompositePrice): T + fun visitEventOutput(eventOutput: EventOutput): T + /** * Maps an unknown variant of [InnerPrice] to a value of type [T]. * @@ -2587,6 +2613,11 @@ private constructor( ?.let { InnerPrice(minimum = it, _json = json) } ?: InnerPrice(_json = json) } + "event_output" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + InnerPrice(eventOutput = it, _json = json) + } ?: InnerPrice(_json = json) + } } return InnerPrice(_json = json) @@ -2647,6 +2678,7 @@ private constructor( value.cumulativeGroupedBulk != null -> generator.writeObject(value.cumulativeGroupedBulk) value.minimum != null -> generator.writeObject(value.minimum) + value.eventOutput != null -> generator.writeObject(value.eventOutput) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid InnerPrice") } @@ -6119,6 +6151,1574 @@ private constructor( override fun toString() = "GroupedWithMinMaxThresholds{cadence=$cadence, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } + + class EventOutput + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val eventOutputConfig: JsonField, + private val itemId: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("event_output_config") + @ExcludeMissing + eventOutputConfig: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + eventOutputConfig, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * Configuration for event_output pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun eventOutputConfig(): EventOutputConfig = + eventOutputConfig.getRequired("event_output_config") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("event_output") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = billableMetricId.getNullable("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + invoiceGroupingKey.getNullable("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [eventOutputConfig]. + * + * Unlike [eventOutputConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("event_output_config") + @ExcludeMissing + fun _eventOutputConfig(): JsonField = eventOutputConfig + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [EventOutput]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .eventOutputConfig() + * .itemId() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [EventOutput]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var eventOutputConfig: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonValue = JsonValue.from("event_output") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(eventOutput: EventOutput) = apply { + cadence = eventOutput.cadence + eventOutputConfig = eventOutput.eventOutputConfig + itemId = eventOutput.itemId + modelType = eventOutput.modelType + name = eventOutput.name + billableMetricId = eventOutput.billableMetricId + billedInAdvance = eventOutput.billedInAdvance + billingCycleConfiguration = eventOutput.billingCycleConfiguration + conversionRate = eventOutput.conversionRate + conversionRateConfig = eventOutput.conversionRateConfig + currency = eventOutput.currency + dimensionalPriceConfiguration = eventOutput.dimensionalPriceConfiguration + externalPriceId = eventOutput.externalPriceId + fixedPriceQuantity = eventOutput.fixedPriceQuantity + invoiceGroupingKey = eventOutput.invoiceGroupingKey + invoicingCycleConfiguration = eventOutput.invoicingCycleConfiguration + metadata = eventOutput.metadata + referenceId = eventOutput.referenceId + additionalProperties = eventOutput.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** Configuration for event_output pricing */ + fun eventOutputConfig(eventOutputConfig: EventOutputConfig) = + eventOutputConfig(JsonField.of(eventOutputConfig)) + + /** + * Sets [Builder.eventOutputConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.eventOutputConfig] with a well-typed + * [EventOutputConfig] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun eventOutputConfig(eventOutputConfig: JsonField) = apply { + this.eventOutputConfig = eventOutputConfig + } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("event_output") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [EventOutput]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .eventOutputConfig() + * .itemId() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): EventOutput = + EventOutput( + checkRequired("cadence", cadence), + checkRequired("eventOutputConfig", eventOutputConfig), + checkRequired("itemId", itemId), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): EventOutput = apply { + if (validated) { + return@apply + } + + cadence().validate() + eventOutputConfig().validate() + itemId() + _modelType().let { + if (it != JsonValue.from("event_output")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (eventOutputConfig.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + modelType.let { if (it == JsonValue.from("event_output")) 1 else 0 } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Configuration for event_output pricing */ + class EventOutputConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val unitRatingKey: JsonField, + private val groupingKey: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("unit_rating_key") + @ExcludeMissing + unitRatingKey: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + ) : this(unitRatingKey, groupingKey, mutableMapOf()) + + /** + * The key in the event data to extract the unit rate from. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun unitRatingKey(): String = unitRatingKey.getRequired("unit_rating_key") + + /** + * An optional key in the event data to group by (e.g., event ID). All events + * will also be grouped by their unit rate. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun groupingKey(): String? = groupingKey.getNullable("grouping_key") + + /** + * Returns the raw JSON value of [unitRatingKey]. + * + * Unlike [unitRatingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_rating_key") + @ExcludeMissing + fun _unitRatingKey(): JsonField = unitRatingKey + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [EventOutputConfig]. + * + * The following fields are required: + * ```kotlin + * .unitRatingKey() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [EventOutputConfig]. */ + class Builder internal constructor() { + + private var unitRatingKey: JsonField? = null + private var groupingKey: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(eventOutputConfig: EventOutputConfig) = apply { + unitRatingKey = eventOutputConfig.unitRatingKey + groupingKey = eventOutputConfig.groupingKey + additionalProperties = + eventOutputConfig.additionalProperties.toMutableMap() + } + + /** The key in the event data to extract the unit rate from. */ + fun unitRatingKey(unitRatingKey: String) = + unitRatingKey(JsonField.of(unitRatingKey)) + + /** + * Sets [Builder.unitRatingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.unitRatingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun unitRatingKey(unitRatingKey: JsonField) = apply { + this.unitRatingKey = unitRatingKey + } + + /** + * An optional key in the event data to group by (e.g., event ID). All + * events will also be grouped by their unit rate. + */ + fun groupingKey(groupingKey: String?) = + groupingKey(JsonField.ofNullable(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [EventOutputConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .unitRatingKey() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): EventOutputConfig = + EventOutputConfig( + checkRequired("unitRatingKey", unitRatingKey), + groupingKey, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): EventOutputConfig = apply { + if (validated) { + return@apply + } + + unitRatingKey() + groupingKey() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (unitRatingKey.asKnown() == null) 0 else 1) + + (if (groupingKey.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is EventOutputConfig && + unitRatingKey == other.unitRatingKey && + groupingKey == other.groupingKey && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(unitRatingKey, groupingKey, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "EventOutputConfig{unitRatingKey=$unitRatingKey, groupingKey=$groupingKey, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is EventOutput && + cadence == other.cadence && + eventOutputConfig == other.eventOutputConfig && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + eventOutputConfig, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "EventOutput{cadence=$cadence, eventOutputConfig=$eventOutputConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } } override fun equals(other: Any?): Boolean { diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanVersion.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanVersion.kt index cdcdf4194..015adf4b9 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanVersion.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanVersion.kt @@ -435,6 +435,9 @@ private constructor( /** Alias for calling [addPrice] with `Price.ofMinimum(minimum)`. */ fun addPrice(minimum: Price.Minimum) = addPrice(Price.ofMinimum(minimum)) + /** Alias for calling [addPrice] with `Price.ofEventOutput(eventOutput)`. */ + fun addPrice(eventOutput: Price.EventOutput) = addPrice(Price.ofEventOutput(eventOutput)) + fun version(version: Long) = version(JsonField.of(version)) /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Price.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Price.kt index 492c18195..e491cbfd8 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Price.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Price.kt @@ -73,6 +73,7 @@ private constructor( private val scalableMatrixWithTieredPricing: ScalableMatrixWithTieredPricing? = null, private val cumulativeGroupedBulk: CumulativeGroupedBulk? = null, private val minimum: Minimum? = null, + private val eventOutput: EventOutput? = null, private val _json: JsonValue? = null, ) { @@ -132,6 +133,8 @@ private constructor( fun minimum(): Minimum? = minimum + fun eventOutput(): EventOutput? = eventOutput + fun isUnit(): Boolean = unit != null fun isTiered(): Boolean = tiered != null @@ -186,6 +189,8 @@ private constructor( fun isMinimum(): Boolean = minimum != null + fun isEventOutput(): Boolean = eventOutput != null + fun asUnit(): Unit = unit.getOrThrow("unit") fun asTiered(): Tiered = tiered.getOrThrow("tiered") @@ -254,6 +259,8 @@ private constructor( fun asMinimum(): Minimum = minimum.getOrThrow("minimum") + fun asEventOutput(): EventOutput = eventOutput.getOrThrow("eventOutput") + fun _json(): JsonValue? = _json fun accept(visitor: Visitor): T = @@ -295,6 +302,7 @@ private constructor( cumulativeGroupedBulk != null -> visitor.visitCumulativeGroupedBulk(cumulativeGroupedBulk) minimum != null -> visitor.visitMinimum(minimum) + eventOutput != null -> visitor.visitEventOutput(eventOutput) else -> visitor.unknown(_json) } @@ -434,6 +442,10 @@ private constructor( override fun visitMinimum(minimum: Minimum) { minimum.validate() } + + override fun visitEventOutput(eventOutput: EventOutput) { + eventOutput.validate() + } } ) validated = true @@ -540,6 +552,8 @@ private constructor( override fun visitMinimum(minimum: Minimum) = minimum.validity() + override fun visitEventOutput(eventOutput: EventOutput) = eventOutput.validity() + override fun unknown(json: JsonValue?) = 0 } ) @@ -576,7 +590,8 @@ private constructor( scalableMatrixWithUnitPricing == other.scalableMatrixWithUnitPricing && scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && cumulativeGroupedBulk == other.cumulativeGroupedBulk && - minimum == other.minimum + minimum == other.minimum && + eventOutput == other.eventOutput } override fun hashCode(): Int = @@ -608,6 +623,7 @@ private constructor( scalableMatrixWithTieredPricing, cumulativeGroupedBulk, minimum, + eventOutput, ) override fun toString(): String = @@ -645,6 +661,7 @@ private constructor( "Price{scalableMatrixWithTieredPricing=$scalableMatrixWithTieredPricing}" cumulativeGroupedBulk != null -> "Price{cumulativeGroupedBulk=$cumulativeGroupedBulk}" minimum != null -> "Price{minimum=$minimum}" + eventOutput != null -> "Price{eventOutput=$eventOutput}" _json != null -> "Price{_unknown=$_json}" else -> throw IllegalStateException("Invalid Price") } @@ -726,6 +743,8 @@ private constructor( Price(cumulativeGroupedBulk = cumulativeGroupedBulk) fun ofMinimum(minimum: Minimum) = Price(minimum = minimum) + + fun ofEventOutput(eventOutput: EventOutput) = Price(eventOutput = eventOutput) } /** An interface that defines how to map each variant of [Price] to a value of type [T]. */ @@ -793,6 +812,8 @@ private constructor( fun visitMinimum(minimum: Minimum): T + fun visitEventOutput(eventOutput: EventOutput): T + /** * Maps an unknown variant of [Price] to a value of type [T]. * @@ -949,6 +970,11 @@ private constructor( Price(minimum = it, _json = json) } ?: Price(_json = json) } + "event_output" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(eventOutput = it, _json = json) + } ?: Price(_json = json) + } } return Price(_json = json) @@ -1004,6 +1030,7 @@ private constructor( value.cumulativeGroupedBulk != null -> generator.writeObject(value.cumulativeGroupedBulk) value.minimum != null -> generator.writeObject(value.minimum) + value.eventOutput != null -> generator.writeObject(value.eventOutput) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid Price") } @@ -1244,6 +1271,9 @@ private constructor( invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") /** + * A minimal representation of an Item containing only the essential identifying + * information. + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ @@ -2056,6 +2086,10 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** + * A minimal representation of an Item containing only the essential identifying + * information. + */ fun item(item: ItemSlim) = item(JsonField.of(item)) /** @@ -3255,6 +3289,9 @@ private constructor( invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") /** + * A minimal representation of an Item containing only the essential identifying + * information. + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ @@ -4068,6 +4105,10 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** + * A minimal representation of an Item containing only the essential identifying + * information. + */ fun item(item: ItemSlim) = item(JsonField.of(item)) /** @@ -5275,6 +5316,9 @@ private constructor( invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") /** + * A minimal representation of an Item containing only the essential identifying + * information. + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ @@ -6093,6 +6137,10 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** + * A minimal representation of an Item containing only the essential identifying + * information. + */ fun item(item: ItemSlim) = item(JsonField.of(item)) /** @@ -7278,6 +7326,9 @@ private constructor( invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") /** + * A minimal representation of an Item containing only the essential identifying + * information. + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ @@ -8091,6 +8142,10 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** + * A minimal representation of an Item containing only the essential identifying + * information. + */ fun item(item: ItemSlim) = item(JsonField.of(item)) /** @@ -9291,6 +9346,9 @@ private constructor( invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") /** + * A minimal representation of an Item containing only the essential identifying + * information. + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ @@ -10104,6 +10162,10 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** + * A minimal representation of an Item containing only the essential identifying + * information. + */ fun item(item: ItemSlim) = item(JsonField.of(item)) /** @@ -11303,6 +11365,9 @@ private constructor( invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") /** + * A minimal representation of an Item containing only the essential identifying + * information. + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ @@ -12119,6 +12184,10 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** + * A minimal representation of an Item containing only the essential identifying + * information. + */ fun item(item: ItemSlim) = item(JsonField.of(item)) /** @@ -13777,6 +13846,9 @@ private constructor( invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") /** + * A minimal representation of an Item containing only the essential identifying + * information. + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ @@ -14592,6 +14664,10 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** + * A minimal representation of an Item containing only the essential identifying + * information. + */ fun item(item: ItemSlim) = item(JsonField.of(item)) /** @@ -16244,6 +16320,9 @@ private constructor( invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") /** + * A minimal representation of an Item containing only the essential identifying + * information. + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ @@ -17059,6 +17138,10 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** + * A minimal representation of an Item containing only the essential identifying + * information. + */ fun item(item: ItemSlim) = item(JsonField.of(item)) /** @@ -18804,6 +18887,9 @@ private constructor( invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") /** + * A minimal representation of an Item containing only the essential identifying + * information. + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ @@ -19625,6 +19711,10 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** + * A minimal representation of an Item containing only the essential identifying + * information. + */ fun item(item: ItemSlim) = item(JsonField.of(item)) /** @@ -21260,6 +21350,9 @@ private constructor( invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") /** + * A minimal representation of an Item containing only the essential identifying + * information. + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ @@ -22079,6 +22172,10 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** + * A minimal representation of an Item containing only the essential identifying + * information. + */ fun item(item: ItemSlim) = item(JsonField.of(item)) /** @@ -23779,6 +23876,9 @@ private constructor( invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") /** + * A minimal representation of an Item containing only the essential identifying + * information. + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ @@ -24595,6 +24695,10 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** + * A minimal representation of an Item containing only the essential identifying + * information. + */ fun item(item: ItemSlim) = item(JsonField.of(item)) /** @@ -26063,6 +26167,9 @@ private constructor( invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") /** + * A minimal representation of an Item containing only the essential identifying + * information. + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ @@ -26878,6 +26985,10 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** + * A minimal representation of an Item containing only the essential identifying + * information. + */ fun item(item: ItemSlim) = item(JsonField.of(item)) /** @@ -28293,6 +28404,9 @@ private constructor( invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") /** + * A minimal representation of an Item containing only the essential identifying + * information. + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ @@ -29109,6 +29223,10 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** + * A minimal representation of an Item containing only the essential identifying + * information. + */ fun item(item: ItemSlim) = item(JsonField.of(item)) /** @@ -30309,6 +30427,9 @@ private constructor( invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") /** + * A minimal representation of an Item containing only the essential identifying + * information. + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ @@ -31125,6 +31246,10 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** + * A minimal representation of an Item containing only the essential identifying + * information. + */ fun item(item: ItemSlim) = item(JsonField.of(item)) /** @@ -32729,6 +32854,9 @@ private constructor( invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") /** + * A minimal representation of an Item containing only the essential identifying + * information. + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ @@ -33544,6 +33672,10 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** + * A minimal representation of an Item containing only the essential identifying + * information. + */ fun item(item: ItemSlim) = item(JsonField.of(item)) /** @@ -34925,6 +35057,9 @@ private constructor( invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") /** + * A minimal representation of an Item containing only the essential identifying + * information. + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ @@ -35746,6 +35881,10 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** + * A minimal representation of an Item containing only the essential identifying + * information. + */ fun item(item: ItemSlim) = item(JsonField.of(item)) /** @@ -37206,6 +37345,9 @@ private constructor( invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") /** + * A minimal representation of an Item containing only the essential identifying + * information. + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ @@ -38027,6 +38169,10 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** + * A minimal representation of an Item containing only the essential identifying + * information. + */ fun item(item: ItemSlim) = item(JsonField.of(item)) /** @@ -39619,6 +39765,9 @@ private constructor( invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") /** + * A minimal representation of an Item containing only the essential identifying + * information. + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ @@ -40448,6 +40597,10 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** + * A minimal representation of an Item containing only the essential identifying + * information. + */ fun item(item: ItemSlim) = item(JsonField.of(item)) /** @@ -41906,6 +42059,9 @@ private constructor( invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") /** + * A minimal representation of an Item containing only the essential identifying + * information. + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ @@ -42734,6 +42890,10 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** + * A minimal representation of an Item containing only the essential identifying + * information. + */ fun item(item: ItemSlim) = item(JsonField.of(item)) /** @@ -44828,6 +44988,9 @@ private constructor( invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") /** + * A minimal representation of an Item containing only the essential identifying + * information. + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ @@ -45658,6 +45821,10 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** + * A minimal representation of an Item containing only the essential identifying + * information. + */ fun item(item: ItemSlim) = item(JsonField.of(item)) /** @@ -47168,6 +47335,9 @@ private constructor( invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") /** + * A minimal representation of an Item containing only the essential identifying + * information. + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ @@ -47984,6 +48154,10 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** + * A minimal representation of an Item containing only the essential identifying + * information. + */ fun item(item: ItemSlim) = item(JsonField.of(item)) /** @@ -49691,6 +49865,9 @@ private constructor( invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") /** + * A minimal representation of an Item containing only the essential identifying + * information. + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ @@ -50513,6 +50690,10 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** + * A minimal representation of an Item containing only the essential identifying + * information. + */ fun item(item: ItemSlim) = item(JsonField.of(item)) /** @@ -52193,6 +52374,9 @@ private constructor( invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") /** + * A minimal representation of an Item containing only the essential identifying + * information. + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ @@ -53009,6 +53193,10 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** + * A minimal representation of an Item containing only the essential identifying + * information. + */ fun item(item: ItemSlim) = item(JsonField.of(item)) /** @@ -54710,6 +54898,9 @@ private constructor( invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") /** + * A minimal representation of an Item containing only the essential identifying + * information. + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ @@ -55539,6 +55730,10 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** + * A minimal representation of an Item containing only the essential identifying + * information. + */ fun item(item: ItemSlim) = item(JsonField.of(item)) /** @@ -57414,6 +57609,9 @@ private constructor( invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") /** + * A minimal representation of an Item containing only the essential identifying + * information. + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ @@ -58243,6 +58441,10 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** + * A minimal representation of an Item containing only the essential identifying + * information. + */ fun item(item: ItemSlim) = item(JsonField.of(item)) /** @@ -60304,6 +60506,9 @@ private constructor( invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") /** + * A minimal representation of an Item containing only the essential identifying + * information. + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ @@ -61127,6 +61332,10 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** + * A minimal representation of an Item containing only the essential identifying + * information. + */ fun item(item: ItemSlim) = item(JsonField.of(item)) /** @@ -62499,7 +62708,2239 @@ private constructor( return true } - return other is CumulativeGroupedBulk && + return other is CumulativeGroupedBulk && + id == other.id && + billableMetric == other.billableMetric && + billingCycleConfiguration == other.billingCycleConfiguration && + billingMode == other.billingMode && + cadence == other.cadence && + compositePriceFilters == other.compositePriceFilters && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + createdAt == other.createdAt && + creditAllocation == other.creditAllocation && + cumulativeGroupedBulkConfig == other.cumulativeGroupedBulkConfig && + currency == other.currency && + discount == other.discount && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + item == other.item && + maximum == other.maximum && + maximumAmount == other.maximumAmount && + metadata == other.metadata && + minimum == other.minimum && + minimumAmount == other.minimumAmount && + modelType == other.modelType && + name == other.name && + planPhaseOrder == other.planPhaseOrder && + priceType == other.priceType && + replacesPriceId == other.replacesPriceId && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + billableMetric, + billingCycleConfiguration, + billingMode, + cadence, + compositePriceFilters, + conversionRate, + conversionRateConfig, + createdAt, + creditAllocation, + cumulativeGroupedBulkConfig, + currency, + discount, + externalPriceId, + fixedPriceQuantity, + invoicingCycleConfiguration, + item, + maximum, + maximumAmount, + metadata, + minimum, + minimumAmount, + modelType, + name, + planPhaseOrder, + priceType, + replacesPriceId, + dimensionalPriceConfiguration, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CumulativeGroupedBulk{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, cumulativeGroupedBulkConfig=$cumulativeGroupedBulkConfig, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + } + + class Minimum + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val billableMetric: JsonField, + private val billingCycleConfiguration: JsonField, + private val billingMode: JsonField, + private val cadence: JsonField, + private val compositePriceFilters: JsonField>, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val createdAt: JsonField, + private val creditAllocation: JsonField, + private val currency: JsonField, + private val discount: JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val item: JsonField, + private val maximum: JsonField, + private val maximumAmount: JsonField, + private val metadata: JsonField, + private val minimum: JsonField, + private val minimumAmount: JsonField, + private val minimumConfig: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val planPhaseOrder: JsonField, + private val priceType: JsonField, + private val replacesPriceId: JsonField, + private val dimensionalPriceConfiguration: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric") + @ExcludeMissing + billableMetric: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("billing_mode") + @ExcludeMissing + billingMode: JsonField = JsonMissing.of(), + @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), + @JsonProperty("composite_price_filters") + @ExcludeMissing + compositePriceFilters: JsonField> = JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + createdAt: JsonField = JsonMissing.of(), + @JsonProperty("credit_allocation") + @ExcludeMissing + creditAllocation: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("discount") + @ExcludeMissing + discount: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("item") @ExcludeMissing item: JsonField = JsonMissing.of(), + @JsonProperty("maximum") @ExcludeMissing maximum: JsonField = JsonMissing.of(), + @JsonProperty("maximum_amount") + @ExcludeMissing + maximumAmount: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("minimum") @ExcludeMissing minimum: JsonField = JsonMissing.of(), + @JsonProperty("minimum_amount") + @ExcludeMissing + minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("minimum_config") + @ExcludeMissing + minimumConfig: JsonField = JsonMissing.of(), + @JsonProperty("model_type") @ExcludeMissing modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("plan_phase_order") + @ExcludeMissing + planPhaseOrder: JsonField = JsonMissing.of(), + @JsonProperty("price_type") + @ExcludeMissing + priceType: JsonField = JsonMissing.of(), + @JsonProperty("replaces_price_id") + @ExcludeMissing + replacesPriceId: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + ) : this( + id, + billableMetric, + billingCycleConfiguration, + billingMode, + cadence, + compositePriceFilters, + conversionRate, + conversionRateConfig, + createdAt, + creditAllocation, + currency, + discount, + externalPriceId, + fixedPriceQuantity, + invoicingCycleConfiguration, + item, + maximum, + maximumAmount, + metadata, + minimum, + minimumAmount, + minimumConfig, + modelType, + name, + planPhaseOrder, + priceType, + replacesPriceId, + dimensionalPriceConfiguration, + mutableMapOf(), + ) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun billableMetric(): BillableMetricTiny? = billableMetric.getNullable("billable_metric") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): BillingCycleConfiguration = + billingCycleConfiguration.getRequired("billing_cycle_configuration") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun billingMode(): BillingMode = billingMode.getRequired("billing_mode") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun compositePriceFilters(): List? = + compositePriceFilters.getNullable("composite_price_filters") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun creditAllocation(): Allocation? = creditAllocation.getNullable("credit_allocation") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + @Deprecated("deprecated") fun discount(): Discount? = discount.getNullable("discount") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): BillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * A minimal representation of an Item containing only the essential identifying + * information. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun item(): ItemSlim = item.getRequired("item") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + @Deprecated("deprecated") fun maximum(): Maximum? = maximum.getNullable("maximum") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + @Deprecated("deprecated") + fun maximumAmount(): String? = maximumAmount.getNullable("maximum_amount") + + /** + * User specified key-value pairs for the resource. If not present, this defaults to an + * empty dictionary. Individual keys can be removed by setting the value to `null`, and the + * entire metadata mapping can be cleared by setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun metadata(): Metadata = metadata.getRequired("metadata") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + @Deprecated("deprecated") fun minimum(): Minimum? = minimum.getNullable("minimum") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + @Deprecated("deprecated") + fun minimumAmount(): String? = minimumAmount.getNullable("minimum_amount") + + /** + * Configuration for minimum pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun minimumConfig(): MinimumConfig = minimumConfig.getRequired("minimum_config") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("minimum") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun name(): String = name.getRequired("name") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun planPhaseOrder(): Long? = planPhaseOrder.getNullable("plan_phase_order") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun priceType(): PriceType = priceType.getRequired("price_type") + + /** + * The price id this price replaces. This price will take the place of the replaced price in + * plan version migrations. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun replacesPriceId(): String? = replacesPriceId.getNullable("replaces_price_id") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): DimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [billableMetric]. + * + * Unlike [billableMetric], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("billable_metric") + @ExcludeMissing + fun _billableMetric(): JsonField = billableMetric + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [billingMode]. + * + * Unlike [billingMode], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("billing_mode") + @ExcludeMissing + fun _billingMode(): JsonField = billingMode + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [compositePriceFilters]. + * + * Unlike [compositePriceFilters], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("composite_price_filters") + @ExcludeMissing + fun _compositePriceFilters(): JsonField> = compositePriceFilters + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [createdAt]. + * + * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt + + /** + * Returns the raw JSON value of [creditAllocation]. + * + * Unlike [creditAllocation], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("credit_allocation") + @ExcludeMissing + fun _creditAllocation(): JsonField = creditAllocation + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [discount]. + * + * Unlike [discount], this method doesn't throw if the JSON field has an unexpected type. + */ + @Deprecated("deprecated") + @JsonProperty("discount") + @ExcludeMissing + fun _discount(): JsonField = discount + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [item]. + * + * Unlike [item], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("item") @ExcludeMissing fun _item(): JsonField = item + + /** + * Returns the raw JSON value of [maximum]. + * + * Unlike [maximum], this method doesn't throw if the JSON field has an unexpected type. + */ + @Deprecated("deprecated") + @JsonProperty("maximum") + @ExcludeMissing + fun _maximum(): JsonField = maximum + + /** + * Returns the raw JSON value of [maximumAmount]. + * + * Unlike [maximumAmount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @Deprecated("deprecated") + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [minimum]. + * + * Unlike [minimum], this method doesn't throw if the JSON field has an unexpected type. + */ + @Deprecated("deprecated") + @JsonProperty("minimum") + @ExcludeMissing + fun _minimum(): JsonField = minimum + + /** + * Returns the raw JSON value of [minimumAmount]. + * + * Unlike [minimumAmount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @Deprecated("deprecated") + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount + + /** + * Returns the raw JSON value of [minimumConfig]. + * + * Unlike [minimumConfig], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("minimum_config") + @ExcludeMissing + fun _minimumConfig(): JsonField = minimumConfig + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [planPhaseOrder]. + * + * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder + + /** + * Returns the raw JSON value of [priceType]. + * + * Unlike [priceType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("price_type") + @ExcludeMissing + fun _priceType(): JsonField = priceType + + /** + * Returns the raw JSON value of [replacesPriceId]. + * + * Unlike [replacesPriceId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("replaces_price_id") + @ExcludeMissing + fun _replacesPriceId(): JsonField = replacesPriceId + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Minimum]. + * + * The following fields are required: + * ```kotlin + * .id() + * .billableMetric() + * .billingCycleConfiguration() + * .billingMode() + * .cadence() + * .compositePriceFilters() + * .conversionRate() + * .conversionRateConfig() + * .createdAt() + * .creditAllocation() + * .currency() + * .discount() + * .externalPriceId() + * .fixedPriceQuantity() + * .invoicingCycleConfiguration() + * .item() + * .maximum() + * .maximumAmount() + * .metadata() + * .minimum() + * .minimumAmount() + * .minimumConfig() + * .name() + * .planPhaseOrder() + * .priceType() + * .replacesPriceId() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Minimum]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var billableMetric: JsonField? = null + private var billingCycleConfiguration: JsonField? = null + private var billingMode: JsonField? = null + private var cadence: JsonField? = null + private var compositePriceFilters: JsonField>? = null + private var conversionRate: JsonField? = null + private var conversionRateConfig: JsonField? = null + private var createdAt: JsonField? = null + private var creditAllocation: JsonField? = null + private var currency: JsonField? = null + private var discount: JsonField? = null + private var externalPriceId: JsonField? = null + private var fixedPriceQuantity: JsonField? = null + private var invoicingCycleConfiguration: JsonField? = null + private var item: JsonField? = null + private var maximum: JsonField? = null + private var maximumAmount: JsonField? = null + private var metadata: JsonField? = null + private var minimum: JsonField? = null + private var minimumAmount: JsonField? = null + private var minimumConfig: JsonField? = null + private var modelType: JsonValue = JsonValue.from("minimum") + private var name: JsonField? = null + private var planPhaseOrder: JsonField? = null + private var priceType: JsonField? = null + private var replacesPriceId: JsonField? = null + private var dimensionalPriceConfiguration: JsonField = + JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(minimum: Minimum) = apply { + id = minimum.id + billableMetric = minimum.billableMetric + billingCycleConfiguration = minimum.billingCycleConfiguration + billingMode = minimum.billingMode + cadence = minimum.cadence + compositePriceFilters = minimum.compositePriceFilters.map { it.toMutableList() } + conversionRate = minimum.conversionRate + conversionRateConfig = minimum.conversionRateConfig + createdAt = minimum.createdAt + creditAllocation = minimum.creditAllocation + currency = minimum.currency + discount = minimum.discount + externalPriceId = minimum.externalPriceId + fixedPriceQuantity = minimum.fixedPriceQuantity + invoicingCycleConfiguration = minimum.invoicingCycleConfiguration + item = minimum.item + maximum = minimum.maximum + maximumAmount = minimum.maximumAmount + metadata = minimum.metadata + this.minimum = minimum.minimum + minimumAmount = minimum.minimumAmount + minimumConfig = minimum.minimumConfig + modelType = minimum.modelType + name = minimum.name + planPhaseOrder = minimum.planPhaseOrder + priceType = minimum.priceType + replacesPriceId = minimum.replacesPriceId + dimensionalPriceConfiguration = minimum.dimensionalPriceConfiguration + additionalProperties = minimum.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun id(id: JsonField) = apply { this.id = id } + + fun billableMetric(billableMetric: BillableMetricTiny?) = + billableMetric(JsonField.ofNullable(billableMetric)) + + /** + * Sets [Builder.billableMetric] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetric] with a well-typed + * [BillableMetricTiny] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun billableMetric(billableMetric: JsonField) = apply { + this.billableMetric = billableMetric + } + + fun billingCycleConfiguration(billingCycleConfiguration: BillingCycleConfiguration) = + billingCycleConfiguration(JsonField.of(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [BillingCycleConfiguration] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + fun billingMode(billingMode: BillingMode) = billingMode(JsonField.of(billingMode)) + + /** + * Sets [Builder.billingMode] to an arbitrary JSON value. + * + * You should usually call [Builder.billingMode] with a well-typed [BillingMode] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun billingMode(billingMode: JsonField) = apply { + this.billingMode = billingMode + } + + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + fun compositePriceFilters(compositePriceFilters: List?) = + compositePriceFilters(JsonField.ofNullable(compositePriceFilters)) + + /** + * Sets [Builder.compositePriceFilters] to an arbitrary JSON value. + * + * You should usually call [Builder.compositePriceFilters] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun compositePriceFilters( + compositePriceFilters: JsonField> + ) = apply { + this.compositePriceFilters = compositePriceFilters.map { it.toMutableList() } + } + + /** + * Adds a single [TransformPriceFilter] to [compositePriceFilters]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addCompositePriceFilter(compositePriceFilter: TransformPriceFilter) = apply { + compositePriceFilters = + (compositePriceFilters ?: JsonField.of(mutableListOf())).also { + checkKnown("compositePriceFilters", it).add(compositePriceFilter) + } + } + + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun conversionRateConfig(conversionRateConfig: JsonField) = + apply { + this.conversionRateConfig = conversionRateConfig + } + + /** + * Alias for calling [conversionRateConfig] with `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + .tieredConfig(tieredConfig) + .build() + ) + + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + + /** + * Sets [Builder.createdAt] to an arbitrary JSON value. + * + * You should usually call [Builder.createdAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun createdAt(createdAt: JsonField) = apply { + this.createdAt = createdAt + } + + fun creditAllocation(creditAllocation: Allocation?) = + creditAllocation(JsonField.ofNullable(creditAllocation)) + + /** + * Sets [Builder.creditAllocation] to an arbitrary JSON value. + * + * You should usually call [Builder.creditAllocation] with a well-typed [Allocation] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun creditAllocation(creditAllocation: JsonField) = apply { + this.creditAllocation = creditAllocation + } + + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + @Deprecated("deprecated") + fun discount(discount: Discount?) = discount(JsonField.ofNullable(discount)) + + /** + * Sets [Builder.discount] to an arbitrary JSON value. + * + * You should usually call [Builder.discount] with a well-typed [Discount] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + @Deprecated("deprecated") + fun discount(discount: JsonField) = apply { this.discount = discount } + + /** Alias for calling [discount] with `Discount.ofPercentage(percentage)`. */ + @Deprecated("deprecated") + fun discount(percentage: PercentageDiscount) = + discount(Discount.ofPercentage(percentage)) + + /** + * Alias for calling [discount] with the following: + * ```kotlin + * PercentageDiscount.builder() + * .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + * .percentageDiscount(percentageDiscount) + * .build() + * ``` + */ + @Deprecated("deprecated") + fun percentageDiscount(percentageDiscount: Double) = + discount( + PercentageDiscount.builder() + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(percentageDiscount) + .build() + ) + + /** Alias for calling [discount] with `Discount.ofTrial(trial)`. */ + @Deprecated("deprecated") + fun discount(trial: TrialDiscount) = discount(Discount.ofTrial(trial)) + + /** Alias for calling [discount] with `Discount.ofUsage(usage)`. */ + @Deprecated("deprecated") + fun discount(usage: UsageDiscount) = discount(Discount.ofUsage(usage)) + + /** + * Alias for calling [discount] with the following: + * ```kotlin + * UsageDiscount.builder() + * .discountType(UsageDiscount.DiscountType.USAGE) + * .usageDiscount(usageDiscount) + * .build() + * ``` + */ + @Deprecated("deprecated") + fun usageDiscount(usageDiscount: Double) = + discount( + UsageDiscount.builder() + .discountType(UsageDiscount.DiscountType.USAGE) + .usageDiscount(usageDiscount) + .build() + ) + + /** Alias for calling [discount] with `Discount.ofAmount(amount)`. */ + @Deprecated("deprecated") + fun discount(amount: AmountDiscount) = discount(Discount.ofAmount(amount)) + + /** + * Alias for calling [discount] with the following: + * ```kotlin + * AmountDiscount.builder() + * .discountType(AmountDiscount.DiscountType.AMOUNT) + * .amountDiscount(amountDiscount) + * .build() + * ``` + */ + @Deprecated("deprecated") + fun amountDiscount(amountDiscount: String) = + discount( + AmountDiscount.builder() + .discountType(AmountDiscount.DiscountType.AMOUNT) + .amountDiscount(amountDiscount) + .build() + ) + + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: BillingCycleConfiguration? + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a well-typed + * [BillingCycleConfiguration] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** + * A minimal representation of an Item containing only the essential identifying + * information. + */ + fun item(item: ItemSlim) = item(JsonField.of(item)) + + /** + * Sets [Builder.item] to an arbitrary JSON value. + * + * You should usually call [Builder.item] with a well-typed [ItemSlim] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun item(item: JsonField) = apply { this.item = item } + + @Deprecated("deprecated") + fun maximum(maximum: Maximum?) = maximum(JsonField.ofNullable(maximum)) + + /** + * Sets [Builder.maximum] to an arbitrary JSON value. + * + * You should usually call [Builder.maximum] with a well-typed [Maximum] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + @Deprecated("deprecated") + fun maximum(maximum: JsonField) = apply { this.maximum = maximum } + + @Deprecated("deprecated") + fun maximumAmount(maximumAmount: String?) = + maximumAmount(JsonField.ofNullable(maximumAmount)) + + /** + * Sets [Builder.maximumAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.maximumAmount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + @Deprecated("deprecated") + fun maximumAmount(maximumAmount: JsonField) = apply { + this.maximumAmount = maximumAmount + } + + /** + * User specified key-value pairs for the resource. If not present, this defaults to an + * empty dictionary. Individual keys can be removed by setting the value to `null`, and + * the entire metadata mapping can be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + @Deprecated("deprecated") + fun minimum(minimum: Minimum?) = minimum(JsonField.ofNullable(minimum)) + + /** + * Sets [Builder.minimum] to an arbitrary JSON value. + * + * You should usually call [Builder.minimum] with a well-typed [Minimum] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + @Deprecated("deprecated") + fun minimum(minimum: JsonField) = apply { this.minimum = minimum } + + @Deprecated("deprecated") + fun minimumAmount(minimumAmount: String?) = + minimumAmount(JsonField.ofNullable(minimumAmount)) + + /** + * Sets [Builder.minimumAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumAmount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + @Deprecated("deprecated") + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount + } + + /** Configuration for minimum pricing */ + fun minimumConfig(minimumConfig: MinimumConfig) = + minimumConfig(JsonField.of(minimumConfig)) + + /** + * Sets [Builder.minimumConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumConfig] with a well-typed [MinimumConfig] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun minimumConfig(minimumConfig: JsonField) = apply { + this.minimumConfig = minimumConfig + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```kotlin + * JsonValue.from("minimum") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + + /** + * Alias for [Builder.planPhaseOrder]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + + /** + * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. + * + * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun planPhaseOrder(planPhaseOrder: JsonField) = apply { + this.planPhaseOrder = planPhaseOrder + } + + fun priceType(priceType: PriceType) = priceType(JsonField.of(priceType)) + + /** + * Sets [Builder.priceType] to an arbitrary JSON value. + * + * You should usually call [Builder.priceType] with a well-typed [PriceType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun priceType(priceType: JsonField) = apply { this.priceType = priceType } + + /** + * The price id this price replaces. This price will take the place of the replaced + * price in plan version migrations. + */ + fun replacesPriceId(replacesPriceId: String?) = + replacesPriceId(JsonField.ofNullable(replacesPriceId)) + + /** + * Sets [Builder.replacesPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.replacesPriceId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun replacesPriceId(replacesPriceId: JsonField) = apply { + this.replacesPriceId = replacesPriceId + } + + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: DimensionalPriceConfiguration? + ) = dimensionalPriceConfiguration(JsonField.ofNullable(dimensionalPriceConfiguration)) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a well-typed + * [DimensionalPriceConfiguration] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Minimum]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .id() + * .billableMetric() + * .billingCycleConfiguration() + * .billingMode() + * .cadence() + * .compositePriceFilters() + * .conversionRate() + * .conversionRateConfig() + * .createdAt() + * .creditAllocation() + * .currency() + * .discount() + * .externalPriceId() + * .fixedPriceQuantity() + * .invoicingCycleConfiguration() + * .item() + * .maximum() + * .maximumAmount() + * .metadata() + * .minimum() + * .minimumAmount() + * .minimumConfig() + * .name() + * .planPhaseOrder() + * .priceType() + * .replacesPriceId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Minimum = + Minimum( + checkRequired("id", id), + checkRequired("billableMetric", billableMetric), + checkRequired("billingCycleConfiguration", billingCycleConfiguration), + checkRequired("billingMode", billingMode), + checkRequired("cadence", cadence), + checkRequired("compositePriceFilters", compositePriceFilters).map { + it.toImmutable() + }, + checkRequired("conversionRate", conversionRate), + checkRequired("conversionRateConfig", conversionRateConfig), + checkRequired("createdAt", createdAt), + checkRequired("creditAllocation", creditAllocation), + checkRequired("currency", currency), + checkRequired("discount", discount), + checkRequired("externalPriceId", externalPriceId), + checkRequired("fixedPriceQuantity", fixedPriceQuantity), + checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), + checkRequired("item", item), + checkRequired("maximum", maximum), + checkRequired("maximumAmount", maximumAmount), + checkRequired("metadata", metadata), + checkRequired("minimum", minimum), + checkRequired("minimumAmount", minimumAmount), + checkRequired("minimumConfig", minimumConfig), + modelType, + checkRequired("name", name), + checkRequired("planPhaseOrder", planPhaseOrder), + checkRequired("priceType", priceType), + checkRequired("replacesPriceId", replacesPriceId), + dimensionalPriceConfiguration, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Minimum = apply { + if (validated) { + return@apply + } + + id() + billableMetric()?.validate() + billingCycleConfiguration().validate() + billingMode().validate() + cadence().validate() + compositePriceFilters()?.forEach { it.validate() } + conversionRate() + conversionRateConfig()?.validate() + createdAt() + creditAllocation()?.validate() + currency() + discount()?.validate() + externalPriceId() + fixedPriceQuantity() + invoicingCycleConfiguration()?.validate() + item().validate() + maximum()?.validate() + maximumAmount() + metadata().validate() + minimum()?.validate() + minimumAmount() + minimumConfig().validate() + _modelType().let { + if (it != JsonValue.from("minimum")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + planPhaseOrder() + priceType().validate() + replacesPriceId() + dimensionalPriceConfiguration()?.validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (id.asKnown() == null) 0 else 1) + + (billableMetric.asKnown()?.validity() ?: 0) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (billingMode.asKnown()?.validity() ?: 0) + + (cadence.asKnown()?.validity() ?: 0) + + (compositePriceFilters.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (createdAt.asKnown() == null) 0 else 1) + + (creditAllocation.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (discount.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (item.asKnown()?.validity() ?: 0) + + (maximum.asKnown()?.validity() ?: 0) + + (if (maximumAmount.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (minimum.asKnown()?.validity() ?: 0) + + (if (minimumAmount.asKnown() == null) 0 else 1) + + (minimumConfig.asKnown()?.validity() ?: 0) + + modelType.let { if (it == JsonValue.from("minimum")) 1 else 0 } + + (if (name.asKnown() == null) 0 else 1) + + (if (planPhaseOrder.asKnown() == null) 0 else 1) + + (priceType.asKnown()?.validity() ?: 0) + + (if (replacesPriceId.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + class BillingMode @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val IN_ADVANCE = of("in_advance") + + val IN_ARREAR = of("in_arrear") + + fun of(value: String) = BillingMode(JsonField.of(value)) + } + + /** An enum containing [BillingMode]'s known values. */ + enum class Known { + IN_ADVANCE, + IN_ARREAR, + } + + /** + * An enum containing [BillingMode]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [BillingMode] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + IN_ADVANCE, + IN_ARREAR, + /** + * An enum member indicating that [BillingMode] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + IN_ADVANCE -> Value.IN_ADVANCE + IN_ARREAR -> Value.IN_ARREAR + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + IN_ADVANCE -> Known.IN_ADVANCE + IN_ARREAR -> Known.IN_ARREAR + else -> throw OrbInvalidDataException("Unknown BillingMode: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): BillingMode = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BillingMode && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class Cadence @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val ONE_TIME = of("one_time") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val SEMI_ANNUAL = of("semi_annual") + + val ANNUAL = of("annual") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ONE_TIME, + MONTHLY, + QUARTERLY, + SEMI_ANNUAL, + ANNUAL, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ONE_TIME, + MONTHLY, + QUARTERLY, + SEMI_ANNUAL, + ANNUAL, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ONE_TIME -> Value.ONE_TIME + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + SEMI_ANNUAL -> Value.SEMI_ANNUAL + ANNUAL -> Value.ANNUAL + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + ONE_TIME -> Known.ONE_TIME + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + SEMI_ANNUAL -> Known.SEMI_ANNUAL + ANNUAL -> Known.ANNUAL + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * User specified key-value pairs for the resource. If not present, this defaults to an + * empty dictionary. Individual keys can be removed by setting the value to `null`, and the + * entire metadata mapping can be cleared by setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + /** Configuration for minimum pricing */ + class MinimumConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val minimumAmount: JsonField, + private val prorated: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("minimum_amount") + @ExcludeMissing + minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("prorated") + @ExcludeMissing + prorated: JsonField = JsonMissing.of(), + ) : this(minimumAmount, prorated, mutableMapOf()) + + /** + * The minimum amount to apply + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") + + /** + * If true, subtotals from this price are prorated based on the service period + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun prorated(): Boolean? = prorated.getNullable("prorated") + + /** + * Returns the raw JSON value of [minimumAmount]. + * + * Unlike [minimumAmount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount + + /** + * Returns the raw JSON value of [prorated]. + * + * Unlike [prorated], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("prorated") @ExcludeMissing fun _prorated(): JsonField = prorated + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [MinimumConfig]. + * + * The following fields are required: + * ```kotlin + * .minimumAmount() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [MinimumConfig]. */ + class Builder internal constructor() { + + private var minimumAmount: JsonField? = null + private var prorated: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(minimumConfig: MinimumConfig) = apply { + minimumAmount = minimumConfig.minimumAmount + prorated = minimumConfig.prorated + additionalProperties = minimumConfig.additionalProperties.toMutableMap() + } + + /** The minimum amount to apply */ + fun minimumAmount(minimumAmount: String) = + minimumAmount(JsonField.of(minimumAmount)) + + /** + * Sets [Builder.minimumAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumAmount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount + } + + /** If true, subtotals from this price are prorated based on the service period */ + fun prorated(prorated: Boolean) = prorated(JsonField.of(prorated)) + + /** + * Sets [Builder.prorated] to an arbitrary JSON value. + * + * You should usually call [Builder.prorated] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun prorated(prorated: JsonField) = apply { this.prorated = prorated } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [MinimumConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .minimumAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MinimumConfig = + MinimumConfig( + checkRequired("minimumAmount", minimumAmount), + prorated, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MinimumConfig = apply { + if (validated) { + return@apply + } + + minimumAmount() + prorated() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (minimumAmount.asKnown() == null) 0 else 1) + + (if (prorated.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MinimumConfig && + minimumAmount == other.minimumAmount && + prorated == other.prorated && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(minimumAmount, prorated, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MinimumConfig{minimumAmount=$minimumAmount, prorated=$prorated, additionalProperties=$additionalProperties}" + } + + class PriceType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val USAGE_PRICE = of("usage_price") + + val FIXED_PRICE = of("fixed_price") + + val COMPOSITE_PRICE = of("composite_price") + + fun of(value: String) = PriceType(JsonField.of(value)) + } + + /** An enum containing [PriceType]'s known values. */ + enum class Known { + USAGE_PRICE, + FIXED_PRICE, + COMPOSITE_PRICE, + } + + /** + * An enum containing [PriceType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [PriceType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + USAGE_PRICE, + FIXED_PRICE, + COMPOSITE_PRICE, + /** + * An enum member indicating that [PriceType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + USAGE_PRICE -> Value.USAGE_PRICE + FIXED_PRICE -> Value.FIXED_PRICE + COMPOSITE_PRICE -> Value.COMPOSITE_PRICE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + USAGE_PRICE -> Known.USAGE_PRICE + FIXED_PRICE -> Known.FIXED_PRICE + COMPOSITE_PRICE -> Known.COMPOSITE_PRICE + else -> throw OrbInvalidDataException("Unknown PriceType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): PriceType = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PriceType && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Minimum && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && @@ -62510,7 +64951,6 @@ private constructor( conversionRateConfig == other.conversionRateConfig && createdAt == other.createdAt && creditAllocation == other.creditAllocation && - cumulativeGroupedBulkConfig == other.cumulativeGroupedBulkConfig && currency == other.currency && discount == other.discount && externalPriceId == other.externalPriceId && @@ -62522,6 +64962,7 @@ private constructor( metadata == other.metadata && minimum == other.minimum && minimumAmount == other.minimumAmount && + minimumConfig == other.minimumConfig && modelType == other.modelType && name == other.name && planPhaseOrder == other.planPhaseOrder && @@ -62543,7 +64984,6 @@ private constructor( conversionRateConfig, createdAt, creditAllocation, - cumulativeGroupedBulkConfig, currency, discount, externalPriceId, @@ -62555,6 +64995,7 @@ private constructor( metadata, minimum, minimumAmount, + minimumConfig, modelType, name, planPhaseOrder, @@ -62568,10 +65009,10 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "CumulativeGroupedBulk{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, cumulativeGroupedBulkConfig=$cumulativeGroupedBulkConfig, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "Minimum{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, minimumConfig=$minimumConfig, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" } - class Minimum + class EventOutput @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, @@ -62586,6 +65027,7 @@ private constructor( private val creditAllocation: JsonField, private val currency: JsonField, private val discount: JsonField, + private val eventOutputConfig: JsonField, private val externalPriceId: JsonField, private val fixedPriceQuantity: JsonField, private val invoicingCycleConfiguration: JsonField, @@ -62595,7 +65037,6 @@ private constructor( private val metadata: JsonField, private val minimum: JsonField, private val minimumAmount: JsonField, - private val minimumConfig: JsonField, private val modelType: JsonValue, private val name: JsonField, private val planPhaseOrder: JsonField, @@ -62639,6 +65080,9 @@ private constructor( @JsonProperty("discount") @ExcludeMissing discount: JsonField = JsonMissing.of(), + @JsonProperty("event_output_config") + @ExcludeMissing + eventOutputConfig: JsonField = JsonMissing.of(), @JsonProperty("external_price_id") @ExcludeMissing externalPriceId: JsonField = JsonMissing.of(), @@ -62660,9 +65104,6 @@ private constructor( @JsonProperty("minimum_amount") @ExcludeMissing minimumAmount: JsonField = JsonMissing.of(), - @JsonProperty("minimum_config") - @ExcludeMissing - minimumConfig: JsonField = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @JsonProperty("plan_phase_order") @@ -62691,6 +65132,7 @@ private constructor( creditAllocation, currency, discount, + eventOutputConfig, externalPriceId, fixedPriceQuantity, invoicingCycleConfiguration, @@ -62700,7 +65142,6 @@ private constructor( metadata, minimum, minimumAmount, - minimumConfig, modelType, name, planPhaseOrder, @@ -62785,6 +65226,15 @@ private constructor( */ @Deprecated("deprecated") fun discount(): Discount? = discount.getNullable("discount") + /** + * Configuration for event_output pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun eventOutputConfig(): EventOutputConfig = + eventOutputConfig.getRequired("event_output_config") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -62805,6 +65255,9 @@ private constructor( invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") /** + * A minimal representation of an Item containing only the essential identifying + * information. + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ @@ -62846,20 +65299,12 @@ private constructor( @Deprecated("deprecated") fun minimumAmount(): String? = minimumAmount.getNullable("minimum_amount") - /** - * Configuration for minimum pricing - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun minimumConfig(): MinimumConfig = minimumConfig.getRequired("minimum_config") - /** * The pricing model type * * Expected to always return the following: * ```kotlin - * JsonValue.from("minimum") + * JsonValue.from("event_output") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -63011,6 +65456,16 @@ private constructor( @ExcludeMissing fun _discount(): JsonField = discount + /** + * Returns the raw JSON value of [eventOutputConfig]. + * + * Unlike [eventOutputConfig], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("event_output_config") + @ExcludeMissing + fun _eventOutputConfig(): JsonField = eventOutputConfig + /** * Returns the raw JSON value of [externalPriceId]. * @@ -63098,16 +65553,6 @@ private constructor( @ExcludeMissing fun _minimumAmount(): JsonField = minimumAmount - /** - * Returns the raw JSON value of [minimumConfig]. - * - * Unlike [minimumConfig], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("minimum_config") - @ExcludeMissing - fun _minimumConfig(): JsonField = minimumConfig - /** * Returns the raw JSON value of [name]. * @@ -63170,7 +65615,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [Minimum]. + * Returns a mutable builder for constructing an instance of [EventOutput]. * * The following fields are required: * ```kotlin @@ -63186,6 +65631,7 @@ private constructor( * .creditAllocation() * .currency() * .discount() + * .eventOutputConfig() * .externalPriceId() * .fixedPriceQuantity() * .invoicingCycleConfiguration() @@ -63195,7 +65641,6 @@ private constructor( * .metadata() * .minimum() * .minimumAmount() - * .minimumConfig() * .name() * .planPhaseOrder() * .priceType() @@ -63205,7 +65650,7 @@ private constructor( fun builder() = Builder() } - /** A builder for [Minimum]. */ + /** A builder for [EventOutput]. */ class Builder internal constructor() { private var id: JsonField? = null @@ -63220,6 +65665,7 @@ private constructor( private var creditAllocation: JsonField? = null private var currency: JsonField? = null private var discount: JsonField? = null + private var eventOutputConfig: JsonField? = null private var externalPriceId: JsonField? = null private var fixedPriceQuantity: JsonField? = null private var invoicingCycleConfiguration: JsonField? = null @@ -63229,8 +65675,7 @@ private constructor( private var metadata: JsonField? = null private var minimum: JsonField? = null private var minimumAmount: JsonField? = null - private var minimumConfig: JsonField? = null - private var modelType: JsonValue = JsonValue.from("minimum") + private var modelType: JsonValue = JsonValue.from("event_output") private var name: JsonField? = null private var planPhaseOrder: JsonField? = null private var priceType: JsonField? = null @@ -63239,36 +65684,36 @@ private constructor( JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(minimum: Minimum) = apply { - id = minimum.id - billableMetric = minimum.billableMetric - billingCycleConfiguration = minimum.billingCycleConfiguration - billingMode = minimum.billingMode - cadence = minimum.cadence - compositePriceFilters = minimum.compositePriceFilters.map { it.toMutableList() } - conversionRate = minimum.conversionRate - conversionRateConfig = minimum.conversionRateConfig - createdAt = minimum.createdAt - creditAllocation = minimum.creditAllocation - currency = minimum.currency - discount = minimum.discount - externalPriceId = minimum.externalPriceId - fixedPriceQuantity = minimum.fixedPriceQuantity - invoicingCycleConfiguration = minimum.invoicingCycleConfiguration - item = minimum.item - maximum = minimum.maximum - maximumAmount = minimum.maximumAmount - metadata = minimum.metadata - this.minimum = minimum.minimum - minimumAmount = minimum.minimumAmount - minimumConfig = minimum.minimumConfig - modelType = minimum.modelType - name = minimum.name - planPhaseOrder = minimum.planPhaseOrder - priceType = minimum.priceType - replacesPriceId = minimum.replacesPriceId - dimensionalPriceConfiguration = minimum.dimensionalPriceConfiguration - additionalProperties = minimum.additionalProperties.toMutableMap() + internal fun from(eventOutput: EventOutput) = apply { + id = eventOutput.id + billableMetric = eventOutput.billableMetric + billingCycleConfiguration = eventOutput.billingCycleConfiguration + billingMode = eventOutput.billingMode + cadence = eventOutput.cadence + compositePriceFilters = eventOutput.compositePriceFilters.map { it.toMutableList() } + conversionRate = eventOutput.conversionRate + conversionRateConfig = eventOutput.conversionRateConfig + createdAt = eventOutput.createdAt + creditAllocation = eventOutput.creditAllocation + currency = eventOutput.currency + discount = eventOutput.discount + eventOutputConfig = eventOutput.eventOutputConfig + externalPriceId = eventOutput.externalPriceId + fixedPriceQuantity = eventOutput.fixedPriceQuantity + invoicingCycleConfiguration = eventOutput.invoicingCycleConfiguration + item = eventOutput.item + maximum = eventOutput.maximum + maximumAmount = eventOutput.maximumAmount + metadata = eventOutput.metadata + minimum = eventOutput.minimum + minimumAmount = eventOutput.minimumAmount + modelType = eventOutput.modelType + name = eventOutput.name + planPhaseOrder = eventOutput.planPhaseOrder + priceType = eventOutput.priceType + replacesPriceId = eventOutput.replacesPriceId + dimensionalPriceConfiguration = eventOutput.dimensionalPriceConfiguration + additionalProperties = eventOutput.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) @@ -63567,6 +66012,21 @@ private constructor( .build() ) + /** Configuration for event_output pricing */ + fun eventOutputConfig(eventOutputConfig: EventOutputConfig) = + eventOutputConfig(JsonField.of(eventOutputConfig)) + + /** + * Sets [Builder.eventOutputConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.eventOutputConfig] with a well-typed + * [EventOutputConfig] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun eventOutputConfig(eventOutputConfig: JsonField) = apply { + this.eventOutputConfig = eventOutputConfig + } + fun externalPriceId(externalPriceId: String?) = externalPriceId(JsonField.ofNullable(externalPriceId)) @@ -63618,6 +66078,10 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** + * A minimal representation of an Item containing only the essential identifying + * information. + */ fun item(item: ItemSlim) = item(JsonField.of(item)) /** @@ -63703,28 +66167,13 @@ private constructor( this.minimumAmount = minimumAmount } - /** Configuration for minimum pricing */ - fun minimumConfig(minimumConfig: MinimumConfig) = - minimumConfig(JsonField.of(minimumConfig)) - - /** - * Sets [Builder.minimumConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.minimumConfig] with a well-typed [MinimumConfig] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun minimumConfig(minimumConfig: JsonField) = apply { - this.minimumConfig = minimumConfig - } - /** * Sets the field to an arbitrary JSON value. * * It is usually unnecessary to call this method because the field defaults to the * following: * ```kotlin - * JsonValue.from("minimum") + * JsonValue.from("event_output") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -63828,7 +66277,7 @@ private constructor( } /** - * Returns an immutable instance of [Minimum]. + * Returns an immutable instance of [EventOutput]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -63846,6 +66295,7 @@ private constructor( * .creditAllocation() * .currency() * .discount() + * .eventOutputConfig() * .externalPriceId() * .fixedPriceQuantity() * .invoicingCycleConfiguration() @@ -63855,7 +66305,6 @@ private constructor( * .metadata() * .minimum() * .minimumAmount() - * .minimumConfig() * .name() * .planPhaseOrder() * .priceType() @@ -63864,8 +66313,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): Minimum = - Minimum( + fun build(): EventOutput = + EventOutput( checkRequired("id", id), checkRequired("billableMetric", billableMetric), checkRequired("billingCycleConfiguration", billingCycleConfiguration), @@ -63880,6 +66329,7 @@ private constructor( checkRequired("creditAllocation", creditAllocation), checkRequired("currency", currency), checkRequired("discount", discount), + checkRequired("eventOutputConfig", eventOutputConfig), checkRequired("externalPriceId", externalPriceId), checkRequired("fixedPriceQuantity", fixedPriceQuantity), checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), @@ -63889,7 +66339,6 @@ private constructor( checkRequired("metadata", metadata), checkRequired("minimum", minimum), checkRequired("minimumAmount", minimumAmount), - checkRequired("minimumConfig", minimumConfig), modelType, checkRequired("name", name), checkRequired("planPhaseOrder", planPhaseOrder), @@ -63902,7 +66351,7 @@ private constructor( private var validated: Boolean = false - fun validate(): Minimum = apply { + fun validate(): EventOutput = apply { if (validated) { return@apply } @@ -63919,6 +66368,7 @@ private constructor( creditAllocation()?.validate() currency() discount()?.validate() + eventOutputConfig().validate() externalPriceId() fixedPriceQuantity() invoicingCycleConfiguration()?.validate() @@ -63928,9 +66378,8 @@ private constructor( metadata().validate() minimum()?.validate() minimumAmount() - minimumConfig().validate() _modelType().let { - if (it != JsonValue.from("minimum")) { + if (it != JsonValue.from("event_output")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } @@ -63969,6 +66418,7 @@ private constructor( (creditAllocation.asKnown()?.validity() ?: 0) + (if (currency.asKnown() == null) 0 else 1) + (discount.asKnown()?.validity() ?: 0) + + (eventOutputConfig.asKnown()?.validity() ?: 0) + (if (externalPriceId.asKnown() == null) 0 else 1) + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + @@ -63978,8 +66428,7 @@ private constructor( (metadata.asKnown()?.validity() ?: 0) + (minimum.asKnown()?.validity() ?: 0) + (if (minimumAmount.asKnown() == null) 0 else 1) + - (minimumConfig.asKnown()?.validity() ?: 0) + - modelType.let { if (it == JsonValue.from("minimum")) 1 else 0 } + + modelType.let { if (it == JsonValue.from("event_output")) 1 else 0 } + (if (name.asKnown() == null) 0 else 1) + (if (planPhaseOrder.asKnown() == null) 0 else 1) + (priceType.asKnown()?.validity() ?: 0) + @@ -64267,37 +66716,132 @@ private constructor( override fun toString() = value.toString() } - /** - * User specified key-value pairs for the resource. If not present, this defaults to an - * empty dictionary. Individual keys can be removed by setting the value to `null`, and the - * entire metadata mapping can be cleared by setting `metadata` to `null`. - */ - class Metadata - @JsonCreator + /** Configuration for event_output pricing */ + class EventOutputConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map + private val unitRatingKey: JsonField, + private val groupingKey: JsonField, + private val additionalProperties: MutableMap, ) { + @JsonCreator + private constructor( + @JsonProperty("unit_rating_key") + @ExcludeMissing + unitRatingKey: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + ) : this(unitRatingKey, groupingKey, mutableMapOf()) + + /** + * The key in the event data to extract the unit rate from. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun unitRatingKey(): String = unitRatingKey.getRequired("unit_rating_key") + + /** + * An optional key in the event data to group by (e.g., event ID). All events will also + * be grouped by their unit rate. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun groupingKey(): String? = groupingKey.getNullable("grouping_key") + + /** + * Returns the raw JSON value of [unitRatingKey]. + * + * Unlike [unitRatingKey], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("unit_rating_key") + @ExcludeMissing + fun _unitRatingKey(): JsonField = unitRatingKey + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) fun toBuilder() = Builder().from(this) companion object { - /** Returns a mutable builder for constructing an instance of [Metadata]. */ + /** + * Returns a mutable builder for constructing an instance of [EventOutputConfig]. + * + * The following fields are required: + * ```kotlin + * .unitRatingKey() + * ``` + */ fun builder() = Builder() } - /** A builder for [Metadata]. */ + /** A builder for [EventOutputConfig]. */ class Builder internal constructor() { + private var unitRatingKey: JsonField? = null + private var groupingKey: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(metadata: Metadata) = apply { - additionalProperties = metadata.additionalProperties.toMutableMap() + internal fun from(eventOutputConfig: EventOutputConfig) = apply { + unitRatingKey = eventOutputConfig.unitRatingKey + groupingKey = eventOutputConfig.groupingKey + additionalProperties = eventOutputConfig.additionalProperties.toMutableMap() + } + + /** The key in the event data to extract the unit rate from. */ + fun unitRatingKey(unitRatingKey: String) = + unitRatingKey(JsonField.of(unitRatingKey)) + + /** + * Sets [Builder.unitRatingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.unitRatingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun unitRatingKey(unitRatingKey: JsonField) = apply { + this.unitRatingKey = unitRatingKey + } + + /** + * An optional key in the event data to group by (e.g., event ID). All events will + * also be grouped by their unit rate. + */ + fun groupingKey(groupingKey: String?) = + groupingKey(JsonField.ofNullable(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey } fun additionalProperties(additionalProperties: Map) = apply { @@ -64323,20 +66867,34 @@ private constructor( } /** - * Returns an immutable instance of [Metadata]. + * Returns an immutable instance of [EventOutputConfig]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .unitRatingKey() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + fun build(): EventOutputConfig = + EventOutputConfig( + checkRequired("unitRatingKey", unitRatingKey), + groupingKey, + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false - fun validate(): Metadata = apply { + fun validate(): EventOutputConfig = apply { if (validated) { return@apply } + unitRatingKey() + groupingKey() validated = true } @@ -64355,142 +66913,63 @@ private constructor( * Used for best match union deserialization. */ internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + (if (unitRatingKey.asKnown() == null) 0 else 1) + + (if (groupingKey.asKnown() == null) 0 else 1) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is Metadata && additionalProperties == other.additionalProperties + return other is EventOutputConfig && + unitRatingKey == other.unitRatingKey && + groupingKey == other.groupingKey && + additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + private val hashCode: Int by lazy { + Objects.hash(unitRatingKey, groupingKey, additionalProperties) + } override fun hashCode(): Int = hashCode - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + override fun toString() = + "EventOutputConfig{unitRatingKey=$unitRatingKey, groupingKey=$groupingKey, additionalProperties=$additionalProperties}" } - /** Configuration for minimum pricing */ - class MinimumConfig - @JsonCreator(mode = JsonCreator.Mode.DISABLED) + /** + * User specified key-value pairs for the resource. If not present, this defaults to an + * empty dictionary. Individual keys can be removed by setting the value to `null`, and the + * entire metadata mapping can be cleared by setting `metadata` to `null`. + */ + class Metadata + @JsonCreator private constructor( - private val minimumAmount: JsonField, - private val prorated: JsonField, - private val additionalProperties: MutableMap, + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map ) { - @JsonCreator - private constructor( - @JsonProperty("minimum_amount") - @ExcludeMissing - minimumAmount: JsonField = JsonMissing.of(), - @JsonProperty("prorated") - @ExcludeMissing - prorated: JsonField = JsonMissing.of(), - ) : this(minimumAmount, prorated, mutableMapOf()) - - /** - * The minimum amount to apply - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") - - /** - * If true, subtotals from this price are prorated based on the service period - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun prorated(): Boolean? = prorated.getNullable("prorated") - - /** - * Returns the raw JSON value of [minimumAmount]. - * - * Unlike [minimumAmount], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("minimum_amount") - @ExcludeMissing - fun _minimumAmount(): JsonField = minimumAmount - - /** - * Returns the raw JSON value of [prorated]. - * - * Unlike [prorated], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("prorated") @ExcludeMissing fun _prorated(): JsonField = prorated - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + fun _additionalProperties(): Map = additionalProperties fun toBuilder() = Builder().from(this) companion object { - /** - * Returns a mutable builder for constructing an instance of [MinimumConfig]. - * - * The following fields are required: - * ```kotlin - * .minimumAmount() - * ``` - */ + /** Returns a mutable builder for constructing an instance of [Metadata]. */ fun builder() = Builder() } - /** A builder for [MinimumConfig]. */ + /** A builder for [Metadata]. */ class Builder internal constructor() { - private var minimumAmount: JsonField? = null - private var prorated: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(minimumConfig: MinimumConfig) = apply { - minimumAmount = minimumConfig.minimumAmount - prorated = minimumConfig.prorated - additionalProperties = minimumConfig.additionalProperties.toMutableMap() - } - - /** The minimum amount to apply */ - fun minimumAmount(minimumAmount: String) = - minimumAmount(JsonField.of(minimumAmount)) - - /** - * Sets [Builder.minimumAmount] to an arbitrary JSON value. - * - * You should usually call [Builder.minimumAmount] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun minimumAmount(minimumAmount: JsonField) = apply { - this.minimumAmount = minimumAmount + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() } - /** If true, subtotals from this price are prorated based on the service period */ - fun prorated(prorated: Boolean) = prorated(JsonField.of(prorated)) - - /** - * Sets [Builder.prorated] to an arbitrary JSON value. - * - * You should usually call [Builder.prorated] with a well-typed [Boolean] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun prorated(prorated: JsonField) = apply { this.prorated = prorated } - fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -64514,34 +66993,20 @@ private constructor( } /** - * Returns an immutable instance of [MinimumConfig]. + * Returns an immutable instance of [Metadata]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```kotlin - * .minimumAmount() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ - fun build(): MinimumConfig = - MinimumConfig( - checkRequired("minimumAmount", minimumAmount), - prorated, - additionalProperties.toMutableMap(), - ) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } private var validated: Boolean = false - fun validate(): MinimumConfig = apply { + fun validate(): Metadata = apply { if (validated) { return@apply } - minimumAmount() - prorated() validated = true } @@ -64560,28 +67025,21 @@ private constructor( * Used for best match union deserialization. */ internal fun validity(): Int = - (if (minimumAmount.asKnown() == null) 0 else 1) + - (if (prorated.asKnown() == null) 0 else 1) + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is MinimumConfig && - minimumAmount == other.minimumAmount && - prorated == other.prorated && - additionalProperties == other.additionalProperties + return other is Metadata && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { - Objects.hash(minimumAmount, prorated, additionalProperties) - } + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } override fun hashCode(): Int = hashCode - override fun toString() = - "MinimumConfig{minimumAmount=$minimumAmount, prorated=$prorated, additionalProperties=$additionalProperties}" + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" } class PriceType @JsonCreator private constructor(private val value: JsonField) : @@ -64724,7 +67182,7 @@ private constructor( return true } - return other is Minimum && + return other is EventOutput && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && @@ -64737,6 +67195,7 @@ private constructor( creditAllocation == other.creditAllocation && currency == other.currency && discount == other.discount && + eventOutputConfig == other.eventOutputConfig && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoicingCycleConfiguration == other.invoicingCycleConfiguration && @@ -64746,7 +67205,6 @@ private constructor( metadata == other.metadata && minimum == other.minimum && minimumAmount == other.minimumAmount && - minimumConfig == other.minimumConfig && modelType == other.modelType && name == other.name && planPhaseOrder == other.planPhaseOrder && @@ -64770,6 +67228,7 @@ private constructor( creditAllocation, currency, discount, + eventOutputConfig, externalPriceId, fixedPriceQuantity, invoicingCycleConfiguration, @@ -64779,7 +67238,6 @@ private constructor( metadata, minimum, minimumAmount, - minimumConfig, modelType, name, planPhaseOrder, @@ -64793,6 +67251,6 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Minimum{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, minimumConfig=$minimumConfig, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "EventOutput{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, eventOutputConfig=$eventOutputConfig, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" } } diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceCreateParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceCreateParams.kt index a7d168177..cb9b7c5a6 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceCreateParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceCreateParams.kt @@ -209,6 +209,9 @@ private constructor( /** Alias for calling [body] with `Body.ofMinimum(minimum)`. */ fun body(minimum: NewFloatingMinimumCompositePrice) = body(Body.ofMinimum(minimum)) + /** Alias for calling [body] with `Body.ofEventOutput(eventOutput)`. */ + fun body(eventOutput: Body.EventOutput) = body(Body.ofEventOutput(eventOutput)) + fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -368,6 +371,7 @@ private constructor( null, private val cumulativeGroupedBulk: NewFloatingCumulativeGroupedBulkPrice? = null, private val minimum: NewFloatingMinimumCompositePrice? = null, + private val eventOutput: EventOutput? = null, private val _json: JsonValue? = null, ) { @@ -431,6 +435,8 @@ private constructor( fun minimum(): NewFloatingMinimumCompositePrice? = minimum + fun eventOutput(): EventOutput? = eventOutput + fun isUnit(): Boolean = unit != null fun isTiered(): Boolean = tiered != null @@ -485,6 +491,8 @@ private constructor( fun isMinimum(): Boolean = minimum != null + fun isEventOutput(): Boolean = eventOutput != null + fun asUnit(): NewFloatingUnitPrice = unit.getOrThrow("unit") fun asTiered(): NewFloatingTieredPrice = tiered.getOrThrow("tiered") @@ -560,6 +568,8 @@ private constructor( fun asMinimum(): NewFloatingMinimumCompositePrice = minimum.getOrThrow("minimum") + fun asEventOutput(): EventOutput = eventOutput.getOrThrow("eventOutput") + fun _json(): JsonValue? = _json fun accept(visitor: Visitor): T = @@ -604,6 +614,7 @@ private constructor( cumulativeGroupedBulk != null -> visitor.visitCumulativeGroupedBulk(cumulativeGroupedBulk) minimum != null -> visitor.visitMinimum(minimum) + eventOutput != null -> visitor.visitEventOutput(eventOutput) else -> visitor.unknown(_json) } @@ -762,6 +773,10 @@ private constructor( override fun visitMinimum(minimum: NewFloatingMinimumCompositePrice) { minimum.validate() } + + override fun visitEventOutput(eventOutput: EventOutput) { + eventOutput.validate() + } } ) validated = true @@ -881,6 +896,8 @@ private constructor( override fun visitMinimum(minimum: NewFloatingMinimumCompositePrice) = minimum.validity() + override fun visitEventOutput(eventOutput: EventOutput) = eventOutput.validity() + override fun unknown(json: JsonValue?) = 0 } ) @@ -917,7 +934,8 @@ private constructor( scalableMatrixWithUnitPricing == other.scalableMatrixWithUnitPricing && scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && cumulativeGroupedBulk == other.cumulativeGroupedBulk && - minimum == other.minimum + minimum == other.minimum && + eventOutput == other.eventOutput } override fun hashCode(): Int = @@ -949,6 +967,7 @@ private constructor( scalableMatrixWithTieredPricing, cumulativeGroupedBulk, minimum, + eventOutput, ) override fun toString(): String = @@ -990,6 +1009,7 @@ private constructor( cumulativeGroupedBulk != null -> "Body{cumulativeGroupedBulk=$cumulativeGroupedBulk}" minimum != null -> "Body{minimum=$minimum}" + eventOutput != null -> "Body{eventOutput=$eventOutput}" _json != null -> "Body{_unknown=$_json}" else -> throw IllegalStateException("Invalid Body") } @@ -1080,6 +1100,8 @@ private constructor( ) = Body(cumulativeGroupedBulk = cumulativeGroupedBulk) fun ofMinimum(minimum: NewFloatingMinimumCompositePrice) = Body(minimum = minimum) + + fun ofEventOutput(eventOutput: EventOutput) = Body(eventOutput = eventOutput) } /** An interface that defines how to map each variant of [Body] to a value of type [T]. */ @@ -1167,6 +1189,8 @@ private constructor( fun visitMinimum(minimum: NewFloatingMinimumCompositePrice): T + fun visitEventOutput(eventOutput: EventOutput): T + /** * Maps an unknown variant of [Body] to a value of type [T]. * @@ -1375,6 +1399,11 @@ private constructor( ) ?.let { Body(minimum = it, _json = json) } ?: Body(_json = json) } + "event_output" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Body(eventOutput = it, _json = json) + } ?: Body(_json = json) + } } return Body(_json = json) @@ -1434,6 +1463,7 @@ private constructor( value.cumulativeGroupedBulk != null -> generator.writeObject(value.cumulativeGroupedBulk) value.minimum != null -> generator.writeObject(value.minimum) + value.eventOutput != null -> generator.writeObject(value.eventOutput) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid Body") } @@ -3047,6 +3077,1491 @@ private constructor( override fun toString() = "GroupedWithMinMaxThresholds{cadence=$cadence, currency=$currency, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" } + + class EventOutput + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val currency: JsonField, + private val eventOutputConfig: JsonField, + private val itemId: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val dimensionalPriceConfiguration: JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val metadata: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("event_output_config") + @ExcludeMissing + eventOutputConfig: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") @ExcludeMissing modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + ) : this( + cadence, + currency, + eventOutputConfig, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * An ISO 4217 currency string for which this price is billed in. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * Configuration for event_output pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun eventOutputConfig(): EventOutputConfig = + eventOutputConfig.getRequired("event_output_config") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("event_output") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun billableMetricId(): String? = billableMetricId.getNullable("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + invoiceGroupingKey.getNullable("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [eventOutputConfig]. + * + * Unlike [eventOutputConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("event_output_config") + @ExcludeMissing + fun _eventOutputConfig(): JsonField = eventOutputConfig + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [EventOutput]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .currency() + * .eventOutputConfig() + * .itemId() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [EventOutput]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var currency: JsonField? = null + private var eventOutputConfig: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonValue = JsonValue.from("event_output") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(eventOutput: EventOutput) = apply { + cadence = eventOutput.cadence + currency = eventOutput.currency + eventOutputConfig = eventOutput.eventOutputConfig + itemId = eventOutput.itemId + modelType = eventOutput.modelType + name = eventOutput.name + billableMetricId = eventOutput.billableMetricId + billedInAdvance = eventOutput.billedInAdvance + billingCycleConfiguration = eventOutput.billingCycleConfiguration + conversionRate = eventOutput.conversionRate + conversionRateConfig = eventOutput.conversionRateConfig + dimensionalPriceConfiguration = eventOutput.dimensionalPriceConfiguration + externalPriceId = eventOutput.externalPriceId + fixedPriceQuantity = eventOutput.fixedPriceQuantity + invoiceGroupingKey = eventOutput.invoiceGroupingKey + invoicingCycleConfiguration = eventOutput.invoicingCycleConfiguration + metadata = eventOutput.metadata + additionalProperties = eventOutput.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** Configuration for event_output pricing */ + fun eventOutputConfig(eventOutputConfig: EventOutputConfig) = + eventOutputConfig(JsonField.of(eventOutputConfig)) + + /** + * Sets [Builder.eventOutputConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.eventOutputConfig] with a well-typed + * [EventOutputConfig] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun eventOutputConfig(eventOutputConfig: JsonField) = apply { + this.eventOutputConfig = eventOutputConfig + } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```kotlin + * JsonValue.from("event_output") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun conversionRateConfig(conversionRateConfig: JsonField) = + apply { + this.conversionRateConfig = conversionRateConfig + } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a well-typed + * [NewDimensionalPriceConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [EventOutput]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .currency() + * .eventOutputConfig() + * .itemId() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): EventOutput = + EventOutput( + checkRequired("cadence", cadence), + checkRequired("currency", currency), + checkRequired("eventOutputConfig", eventOutputConfig), + checkRequired("itemId", itemId), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): EventOutput = apply { + if (validated) { + return@apply + } + + cadence().validate() + currency() + eventOutputConfig().validate() + itemId() + _modelType().let { + if (it != JsonValue.from("event_output")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + metadata()?.validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (eventOutputConfig.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + modelType.let { if (it == JsonValue.from("event_output")) 1 else 0 } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (metadata.asKnown()?.validity() ?: 0) + + /** The cadence to bill for this price on. */ + class Cadence @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Configuration for event_output pricing */ + class EventOutputConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val unitRatingKey: JsonField, + private val groupingKey: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("unit_rating_key") + @ExcludeMissing + unitRatingKey: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + ) : this(unitRatingKey, groupingKey, mutableMapOf()) + + /** + * The key in the event data to extract the unit rate from. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun unitRatingKey(): String = unitRatingKey.getRequired("unit_rating_key") + + /** + * An optional key in the event data to group by (e.g., event ID). All events will + * also be grouped by their unit rate. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun groupingKey(): String? = groupingKey.getNullable("grouping_key") + + /** + * Returns the raw JSON value of [unitRatingKey]. + * + * Unlike [unitRatingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_rating_key") + @ExcludeMissing + fun _unitRatingKey(): JsonField = unitRatingKey + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [EventOutputConfig]. + * + * The following fields are required: + * ```kotlin + * .unitRatingKey() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [EventOutputConfig]. */ + class Builder internal constructor() { + + private var unitRatingKey: JsonField? = null + private var groupingKey: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(eventOutputConfig: EventOutputConfig) = apply { + unitRatingKey = eventOutputConfig.unitRatingKey + groupingKey = eventOutputConfig.groupingKey + additionalProperties = eventOutputConfig.additionalProperties.toMutableMap() + } + + /** The key in the event data to extract the unit rate from. */ + fun unitRatingKey(unitRatingKey: String) = + unitRatingKey(JsonField.of(unitRatingKey)) + + /** + * Sets [Builder.unitRatingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.unitRatingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun unitRatingKey(unitRatingKey: JsonField) = apply { + this.unitRatingKey = unitRatingKey + } + + /** + * An optional key in the event data to group by (e.g., event ID). All events + * will also be grouped by their unit rate. + */ + fun groupingKey(groupingKey: String?) = + groupingKey(JsonField.ofNullable(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [EventOutputConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .unitRatingKey() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): EventOutputConfig = + EventOutputConfig( + checkRequired("unitRatingKey", unitRatingKey), + groupingKey, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): EventOutputConfig = apply { + if (validated) { + return@apply + } + + unitRatingKey() + groupingKey() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (unitRatingKey.asKnown() == null) 0 else 1) + + (if (groupingKey.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is EventOutputConfig && + unitRatingKey == other.unitRatingKey && + groupingKey == other.groupingKey && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(unitRatingKey, groupingKey, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "EventOutputConfig{unitRatingKey=$unitRatingKey, groupingKey=$groupingKey, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is EventOutput && + cadence == other.cadence && + currency == other.currency && + eventOutputConfig == other.eventOutputConfig && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + currency, + eventOutputConfig, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "EventOutput{cadence=$cadence, currency=$currency, eventOutputConfig=$eventOutputConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + } } override fun equals(other: Any?): Boolean { diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceEvaluateMultipleParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceEvaluateMultipleParams.kt index 5f80cecae..baf734779 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceEvaluateMultipleParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceEvaluateMultipleParams.kt @@ -1145,6 +1145,9 @@ private constructor( /** Alias for calling [price] with `Price.ofMinimum(minimum)`. */ fun price(minimum: NewFloatingMinimumCompositePrice) = price(Price.ofMinimum(minimum)) + /** Alias for calling [price] with `Price.ofEventOutput(eventOutput)`. */ + fun price(eventOutput: Price.EventOutput) = price(Price.ofEventOutput(eventOutput)) + /** The ID of a price to evaluate that exists in your Orb account. */ fun priceId(priceId: String?) = priceId(JsonField.ofNullable(priceId)) @@ -1266,6 +1269,7 @@ private constructor( null, private val cumulativeGroupedBulk: NewFloatingCumulativeGroupedBulkPrice? = null, private val minimum: NewFloatingMinimumCompositePrice? = null, + private val eventOutput: EventOutput? = null, private val _json: JsonValue? = null, ) { @@ -1333,6 +1337,8 @@ private constructor( fun minimum(): NewFloatingMinimumCompositePrice? = minimum + fun eventOutput(): EventOutput? = eventOutput + fun isUnit(): Boolean = unit != null fun isTiered(): Boolean = tiered != null @@ -1388,6 +1394,8 @@ private constructor( fun isMinimum(): Boolean = minimum != null + fun isEventOutput(): Boolean = eventOutput != null + fun asUnit(): NewFloatingUnitPrice = unit.getOrThrow("unit") fun asTiered(): NewFloatingTieredPrice = tiered.getOrThrow("tiered") @@ -1464,6 +1472,8 @@ private constructor( fun asMinimum(): NewFloatingMinimumCompositePrice = minimum.getOrThrow("minimum") + fun asEventOutput(): EventOutput = eventOutput.getOrThrow("eventOutput") + fun _json(): JsonValue? = _json fun accept(visitor: Visitor): T = @@ -1511,6 +1521,7 @@ private constructor( cumulativeGroupedBulk != null -> visitor.visitCumulativeGroupedBulk(cumulativeGroupedBulk) minimum != null -> visitor.visitMinimum(minimum) + eventOutput != null -> visitor.visitEventOutput(eventOutput) else -> visitor.unknown(_json) } @@ -1674,6 +1685,10 @@ private constructor( override fun visitMinimum(minimum: NewFloatingMinimumCompositePrice) { minimum.validate() } + + override fun visitEventOutput(eventOutput: EventOutput) { + eventOutput.validate() + } } ) validated = true @@ -1796,6 +1811,9 @@ private constructor( override fun visitMinimum(minimum: NewFloatingMinimumCompositePrice) = minimum.validity() + override fun visitEventOutput(eventOutput: EventOutput) = + eventOutput.validity() + override fun unknown(json: JsonValue?) = 0 } ) @@ -1832,7 +1850,8 @@ private constructor( scalableMatrixWithUnitPricing == other.scalableMatrixWithUnitPricing && scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && cumulativeGroupedBulk == other.cumulativeGroupedBulk && - minimum == other.minimum + minimum == other.minimum && + eventOutput == other.eventOutput } override fun hashCode(): Int = @@ -1864,6 +1883,7 @@ private constructor( scalableMatrixWithTieredPricing, cumulativeGroupedBulk, minimum, + eventOutput, ) override fun toString(): String = @@ -1908,6 +1928,7 @@ private constructor( cumulativeGroupedBulk != null -> "Price{cumulativeGroupedBulk=$cumulativeGroupedBulk}" minimum != null -> "Price{minimum=$minimum}" + eventOutput != null -> "Price{eventOutput=$eventOutput}" _json != null -> "Price{_unknown=$_json}" else -> throw IllegalStateException("Invalid Price") } @@ -2002,6 +2023,8 @@ private constructor( ) = Price(cumulativeGroupedBulk = cumulativeGroupedBulk) fun ofMinimum(minimum: NewFloatingMinimumCompositePrice) = Price(minimum = minimum) + + fun ofEventOutput(eventOutput: EventOutput) = Price(eventOutput = eventOutput) } /** @@ -2091,6 +2114,8 @@ private constructor( fun visitMinimum(minimum: NewFloatingMinimumCompositePrice): T + fun visitEventOutput(eventOutput: EventOutput): T + /** * Maps an unknown variant of [Price] to a value of type [T]. * @@ -2310,6 +2335,11 @@ private constructor( ) ?.let { Price(minimum = it, _json = json) } ?: Price(_json = json) } + "event_output" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(eventOutput = it, _json = json) + } ?: Price(_json = json) + } } return Price(_json = json) @@ -2370,6 +2400,7 @@ private constructor( value.cumulativeGroupedBulk != null -> generator.writeObject(value.cumulativeGroupedBulk) value.minimum != null -> generator.writeObject(value.minimum) + value.eventOutput != null -> generator.writeObject(value.eventOutput) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid Price") } @@ -4023,6 +4054,1524 @@ private constructor( override fun toString() = "GroupedWithMinMaxThresholds{cadence=$cadence, currency=$currency, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" } + + class EventOutput + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val currency: JsonField, + private val eventOutputConfig: JsonField, + private val itemId: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val metadata: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("event_output_config") + @ExcludeMissing + eventOutputConfig: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + ) : this( + cadence, + currency, + eventOutputConfig, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * An ISO 4217 currency string for which this price is billed in. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * Configuration for event_output pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun eventOutputConfig(): EventOutputConfig = + eventOutputConfig.getRequired("event_output_config") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("event_output") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = billableMetricId.getNullable("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + invoiceGroupingKey.getNullable("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [eventOutputConfig]. + * + * Unlike [eventOutputConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("event_output_config") + @ExcludeMissing + fun _eventOutputConfig(): JsonField = eventOutputConfig + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [EventOutput]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .currency() + * .eventOutputConfig() + * .itemId() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [EventOutput]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var currency: JsonField? = null + private var eventOutputConfig: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonValue = JsonValue.from("event_output") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(eventOutput: EventOutput) = apply { + cadence = eventOutput.cadence + currency = eventOutput.currency + eventOutputConfig = eventOutput.eventOutputConfig + itemId = eventOutput.itemId + modelType = eventOutput.modelType + name = eventOutput.name + billableMetricId = eventOutput.billableMetricId + billedInAdvance = eventOutput.billedInAdvance + billingCycleConfiguration = eventOutput.billingCycleConfiguration + conversionRate = eventOutput.conversionRate + conversionRateConfig = eventOutput.conversionRateConfig + dimensionalPriceConfiguration = eventOutput.dimensionalPriceConfiguration + externalPriceId = eventOutput.externalPriceId + fixedPriceQuantity = eventOutput.fixedPriceQuantity + invoiceGroupingKey = eventOutput.invoiceGroupingKey + invoicingCycleConfiguration = eventOutput.invoicingCycleConfiguration + metadata = eventOutput.metadata + additionalProperties = eventOutput.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** Configuration for event_output pricing */ + fun eventOutputConfig(eventOutputConfig: EventOutputConfig) = + eventOutputConfig(JsonField.of(eventOutputConfig)) + + /** + * Sets [Builder.eventOutputConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.eventOutputConfig] with a well-typed + * [EventOutputConfig] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun eventOutputConfig(eventOutputConfig: JsonField) = apply { + this.eventOutputConfig = eventOutputConfig + } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("event_output") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [EventOutput]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .currency() + * .eventOutputConfig() + * .itemId() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): EventOutput = + EventOutput( + checkRequired("cadence", cadence), + checkRequired("currency", currency), + checkRequired("eventOutputConfig", eventOutputConfig), + checkRequired("itemId", itemId), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): EventOutput = apply { + if (validated) { + return@apply + } + + cadence().validate() + currency() + eventOutputConfig().validate() + itemId() + _modelType().let { + if (it != JsonValue.from("event_output")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + metadata()?.validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (eventOutputConfig.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + modelType.let { if (it == JsonValue.from("event_output")) 1 else 0 } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (metadata.asKnown()?.validity() ?: 0) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Configuration for event_output pricing */ + class EventOutputConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val unitRatingKey: JsonField, + private val groupingKey: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("unit_rating_key") + @ExcludeMissing + unitRatingKey: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + ) : this(unitRatingKey, groupingKey, mutableMapOf()) + + /** + * The key in the event data to extract the unit rate from. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun unitRatingKey(): String = unitRatingKey.getRequired("unit_rating_key") + + /** + * An optional key in the event data to group by (e.g., event ID). All events + * will also be grouped by their unit rate. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun groupingKey(): String? = groupingKey.getNullable("grouping_key") + + /** + * Returns the raw JSON value of [unitRatingKey]. + * + * Unlike [unitRatingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_rating_key") + @ExcludeMissing + fun _unitRatingKey(): JsonField = unitRatingKey + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [EventOutputConfig]. + * + * The following fields are required: + * ```kotlin + * .unitRatingKey() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [EventOutputConfig]. */ + class Builder internal constructor() { + + private var unitRatingKey: JsonField? = null + private var groupingKey: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(eventOutputConfig: EventOutputConfig) = apply { + unitRatingKey = eventOutputConfig.unitRatingKey + groupingKey = eventOutputConfig.groupingKey + additionalProperties = + eventOutputConfig.additionalProperties.toMutableMap() + } + + /** The key in the event data to extract the unit rate from. */ + fun unitRatingKey(unitRatingKey: String) = + unitRatingKey(JsonField.of(unitRatingKey)) + + /** + * Sets [Builder.unitRatingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.unitRatingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun unitRatingKey(unitRatingKey: JsonField) = apply { + this.unitRatingKey = unitRatingKey + } + + /** + * An optional key in the event data to group by (e.g., event ID). All + * events will also be grouped by their unit rate. + */ + fun groupingKey(groupingKey: String?) = + groupingKey(JsonField.ofNullable(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [EventOutputConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .unitRatingKey() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): EventOutputConfig = + EventOutputConfig( + checkRequired("unitRatingKey", unitRatingKey), + groupingKey, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): EventOutputConfig = apply { + if (validated) { + return@apply + } + + unitRatingKey() + groupingKey() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (unitRatingKey.asKnown() == null) 0 else 1) + + (if (groupingKey.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is EventOutputConfig && + unitRatingKey == other.unitRatingKey && + groupingKey == other.groupingKey && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(unitRatingKey, groupingKey, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "EventOutputConfig{unitRatingKey=$unitRatingKey, groupingKey=$groupingKey, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is EventOutput && + cadence == other.cadence && + currency == other.currency && + eventOutputConfig == other.eventOutputConfig && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + currency, + eventOutputConfig, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "EventOutput{cadence=$cadence, currency=$currency, eventOutputConfig=$eventOutputConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + } } override fun equals(other: Any?): Boolean { diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceEvaluatePreviewEventsParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceEvaluatePreviewEventsParams.kt index dbbf9971a..b7b458d47 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceEvaluatePreviewEventsParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceEvaluatePreviewEventsParams.kt @@ -1680,6 +1680,9 @@ private constructor( /** Alias for calling [price] with `Price.ofMinimum(minimum)`. */ fun price(minimum: NewFloatingMinimumCompositePrice) = price(Price.ofMinimum(minimum)) + /** Alias for calling [price] with `Price.ofEventOutput(eventOutput)`. */ + fun price(eventOutput: Price.EventOutput) = price(Price.ofEventOutput(eventOutput)) + /** The ID of a price to evaluate that exists in your Orb account. */ fun priceId(priceId: String?) = priceId(JsonField.ofNullable(priceId)) @@ -1801,6 +1804,7 @@ private constructor( null, private val cumulativeGroupedBulk: NewFloatingCumulativeGroupedBulkPrice? = null, private val minimum: NewFloatingMinimumCompositePrice? = null, + private val eventOutput: EventOutput? = null, private val _json: JsonValue? = null, ) { @@ -1868,6 +1872,8 @@ private constructor( fun minimum(): NewFloatingMinimumCompositePrice? = minimum + fun eventOutput(): EventOutput? = eventOutput + fun isUnit(): Boolean = unit != null fun isTiered(): Boolean = tiered != null @@ -1923,6 +1929,8 @@ private constructor( fun isMinimum(): Boolean = minimum != null + fun isEventOutput(): Boolean = eventOutput != null + fun asUnit(): NewFloatingUnitPrice = unit.getOrThrow("unit") fun asTiered(): NewFloatingTieredPrice = tiered.getOrThrow("tiered") @@ -1999,6 +2007,8 @@ private constructor( fun asMinimum(): NewFloatingMinimumCompositePrice = minimum.getOrThrow("minimum") + fun asEventOutput(): EventOutput = eventOutput.getOrThrow("eventOutput") + fun _json(): JsonValue? = _json fun accept(visitor: Visitor): T = @@ -2046,6 +2056,7 @@ private constructor( cumulativeGroupedBulk != null -> visitor.visitCumulativeGroupedBulk(cumulativeGroupedBulk) minimum != null -> visitor.visitMinimum(minimum) + eventOutput != null -> visitor.visitEventOutput(eventOutput) else -> visitor.unknown(_json) } @@ -2209,6 +2220,10 @@ private constructor( override fun visitMinimum(minimum: NewFloatingMinimumCompositePrice) { minimum.validate() } + + override fun visitEventOutput(eventOutput: EventOutput) { + eventOutput.validate() + } } ) validated = true @@ -2331,6 +2346,9 @@ private constructor( override fun visitMinimum(minimum: NewFloatingMinimumCompositePrice) = minimum.validity() + override fun visitEventOutput(eventOutput: EventOutput) = + eventOutput.validity() + override fun unknown(json: JsonValue?) = 0 } ) @@ -2367,7 +2385,8 @@ private constructor( scalableMatrixWithUnitPricing == other.scalableMatrixWithUnitPricing && scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && cumulativeGroupedBulk == other.cumulativeGroupedBulk && - minimum == other.minimum + minimum == other.minimum && + eventOutput == other.eventOutput } override fun hashCode(): Int = @@ -2399,6 +2418,7 @@ private constructor( scalableMatrixWithTieredPricing, cumulativeGroupedBulk, minimum, + eventOutput, ) override fun toString(): String = @@ -2443,6 +2463,7 @@ private constructor( cumulativeGroupedBulk != null -> "Price{cumulativeGroupedBulk=$cumulativeGroupedBulk}" minimum != null -> "Price{minimum=$minimum}" + eventOutput != null -> "Price{eventOutput=$eventOutput}" _json != null -> "Price{_unknown=$_json}" else -> throw IllegalStateException("Invalid Price") } @@ -2537,6 +2558,8 @@ private constructor( ) = Price(cumulativeGroupedBulk = cumulativeGroupedBulk) fun ofMinimum(minimum: NewFloatingMinimumCompositePrice) = Price(minimum = minimum) + + fun ofEventOutput(eventOutput: EventOutput) = Price(eventOutput = eventOutput) } /** @@ -2626,6 +2649,8 @@ private constructor( fun visitMinimum(minimum: NewFloatingMinimumCompositePrice): T + fun visitEventOutput(eventOutput: EventOutput): T + /** * Maps an unknown variant of [Price] to a value of type [T]. * @@ -2845,6 +2870,11 @@ private constructor( ) ?.let { Price(minimum = it, _json = json) } ?: Price(_json = json) } + "event_output" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(eventOutput = it, _json = json) + } ?: Price(_json = json) + } } return Price(_json = json) @@ -2905,6 +2935,7 @@ private constructor( value.cumulativeGroupedBulk != null -> generator.writeObject(value.cumulativeGroupedBulk) value.minimum != null -> generator.writeObject(value.minimum) + value.eventOutput != null -> generator.writeObject(value.eventOutput) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid Price") } @@ -4558,6 +4589,1524 @@ private constructor( override fun toString() = "GroupedWithMinMaxThresholds{cadence=$cadence, currency=$currency, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" } + + class EventOutput + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val currency: JsonField, + private val eventOutputConfig: JsonField, + private val itemId: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val metadata: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("event_output_config") + @ExcludeMissing + eventOutputConfig: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + ) : this( + cadence, + currency, + eventOutputConfig, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * An ISO 4217 currency string for which this price is billed in. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * Configuration for event_output pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun eventOutputConfig(): EventOutputConfig = + eventOutputConfig.getRequired("event_output_config") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("event_output") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = billableMetricId.getNullable("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + invoiceGroupingKey.getNullable("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [eventOutputConfig]. + * + * Unlike [eventOutputConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("event_output_config") + @ExcludeMissing + fun _eventOutputConfig(): JsonField = eventOutputConfig + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [EventOutput]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .currency() + * .eventOutputConfig() + * .itemId() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [EventOutput]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var currency: JsonField? = null + private var eventOutputConfig: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonValue = JsonValue.from("event_output") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(eventOutput: EventOutput) = apply { + cadence = eventOutput.cadence + currency = eventOutput.currency + eventOutputConfig = eventOutput.eventOutputConfig + itemId = eventOutput.itemId + modelType = eventOutput.modelType + name = eventOutput.name + billableMetricId = eventOutput.billableMetricId + billedInAdvance = eventOutput.billedInAdvance + billingCycleConfiguration = eventOutput.billingCycleConfiguration + conversionRate = eventOutput.conversionRate + conversionRateConfig = eventOutput.conversionRateConfig + dimensionalPriceConfiguration = eventOutput.dimensionalPriceConfiguration + externalPriceId = eventOutput.externalPriceId + fixedPriceQuantity = eventOutput.fixedPriceQuantity + invoiceGroupingKey = eventOutput.invoiceGroupingKey + invoicingCycleConfiguration = eventOutput.invoicingCycleConfiguration + metadata = eventOutput.metadata + additionalProperties = eventOutput.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** Configuration for event_output pricing */ + fun eventOutputConfig(eventOutputConfig: EventOutputConfig) = + eventOutputConfig(JsonField.of(eventOutputConfig)) + + /** + * Sets [Builder.eventOutputConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.eventOutputConfig] with a well-typed + * [EventOutputConfig] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun eventOutputConfig(eventOutputConfig: JsonField) = apply { + this.eventOutputConfig = eventOutputConfig + } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("event_output") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [EventOutput]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .currency() + * .eventOutputConfig() + * .itemId() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): EventOutput = + EventOutput( + checkRequired("cadence", cadence), + checkRequired("currency", currency), + checkRequired("eventOutputConfig", eventOutputConfig), + checkRequired("itemId", itemId), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): EventOutput = apply { + if (validated) { + return@apply + } + + cadence().validate() + currency() + eventOutputConfig().validate() + itemId() + _modelType().let { + if (it != JsonValue.from("event_output")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + metadata()?.validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (eventOutputConfig.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + modelType.let { if (it == JsonValue.from("event_output")) 1 else 0 } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (metadata.asKnown()?.validity() ?: 0) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Configuration for event_output pricing */ + class EventOutputConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val unitRatingKey: JsonField, + private val groupingKey: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("unit_rating_key") + @ExcludeMissing + unitRatingKey: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + ) : this(unitRatingKey, groupingKey, mutableMapOf()) + + /** + * The key in the event data to extract the unit rate from. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun unitRatingKey(): String = unitRatingKey.getRequired("unit_rating_key") + + /** + * An optional key in the event data to group by (e.g., event ID). All events + * will also be grouped by their unit rate. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun groupingKey(): String? = groupingKey.getNullable("grouping_key") + + /** + * Returns the raw JSON value of [unitRatingKey]. + * + * Unlike [unitRatingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_rating_key") + @ExcludeMissing + fun _unitRatingKey(): JsonField = unitRatingKey + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [EventOutputConfig]. + * + * The following fields are required: + * ```kotlin + * .unitRatingKey() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [EventOutputConfig]. */ + class Builder internal constructor() { + + private var unitRatingKey: JsonField? = null + private var groupingKey: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(eventOutputConfig: EventOutputConfig) = apply { + unitRatingKey = eventOutputConfig.unitRatingKey + groupingKey = eventOutputConfig.groupingKey + additionalProperties = + eventOutputConfig.additionalProperties.toMutableMap() + } + + /** The key in the event data to extract the unit rate from. */ + fun unitRatingKey(unitRatingKey: String) = + unitRatingKey(JsonField.of(unitRatingKey)) + + /** + * Sets [Builder.unitRatingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.unitRatingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun unitRatingKey(unitRatingKey: JsonField) = apply { + this.unitRatingKey = unitRatingKey + } + + /** + * An optional key in the event data to group by (e.g., event ID). All + * events will also be grouped by their unit rate. + */ + fun groupingKey(groupingKey: String?) = + groupingKey(JsonField.ofNullable(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [EventOutputConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .unitRatingKey() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): EventOutputConfig = + EventOutputConfig( + checkRequired("unitRatingKey", unitRatingKey), + groupingKey, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): EventOutputConfig = apply { + if (validated) { + return@apply + } + + unitRatingKey() + groupingKey() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (unitRatingKey.asKnown() == null) 0 else 1) + + (if (groupingKey.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is EventOutputConfig && + unitRatingKey == other.unitRatingKey && + groupingKey == other.groupingKey && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(unitRatingKey, groupingKey, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "EventOutputConfig{unitRatingKey=$unitRatingKey, groupingKey=$groupingKey, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is EventOutput && + cadence == other.cadence && + currency == other.currency && + eventOutputConfig == other.eventOutputConfig && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + currency, + eventOutputConfig, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "EventOutput{cadence=$cadence, currency=$currency, eventOutputConfig=$eventOutputConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + } } override fun equals(other: Any?): Boolean { diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceInterval.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceInterval.kt index 73d0c7762..7f415be7c 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceInterval.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceInterval.kt @@ -601,6 +601,9 @@ private constructor( /** Alias for calling [price] with `Price.ofMinimum(minimum)`. */ fun price(minimum: Price.Minimum) = price(Price.ofMinimum(minimum)) + /** Alias for calling [price] with `Price.ofEventOutput(eventOutput)`. */ + fun price(eventOutput: Price.EventOutput) = price(Price.ofEventOutput(eventOutput)) + /** * The start date of the price interval. This is the date that Orb starts billing for this * price. diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceListPageResponse.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceListPageResponse.kt index af0175d43..0711bf958 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceListPageResponse.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceListPageResponse.kt @@ -261,6 +261,9 @@ private constructor( /** Alias for calling [addData] with `Price.ofMinimum(minimum)`. */ fun addData(minimum: Price.Minimum) = addData(Price.ofMinimum(minimum)) + /** Alias for calling [addData] with `Price.ofEventOutput(eventOutput)`. */ + fun addData(eventOutput: Price.EventOutput) = addData(Price.ofEventOutput(eventOutput)) + fun paginationMetadata(paginationMetadata: PaginationMetadata) = paginationMetadata(JsonField.of(paginationMetadata)) diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionCreateParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionCreateParams.kt index 38f2b579e..27b2040c9 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionCreateParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionCreateParams.kt @@ -4698,6 +4698,9 @@ private constructor( fun price(minimum: NewSubscriptionMinimumCompositePrice) = price(Price.ofMinimum(minimum)) + /** Alias for calling [price] with `Price.ofEventOutput(eventOutput)`. */ + fun price(eventOutput: Price.EventOutput) = price(Price.ofEventOutput(eventOutput)) + /** The id of the price to add to the subscription. */ fun priceId(priceId: String?) = priceId(JsonField.ofNullable(priceId)) @@ -4854,6 +4857,7 @@ private constructor( null, private val cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice? = null, private val minimum: NewSubscriptionMinimumCompositePrice? = null, + private val eventOutput: EventOutput? = null, private val _json: JsonValue? = null, ) { @@ -4925,6 +4929,8 @@ private constructor( fun minimum(): NewSubscriptionMinimumCompositePrice? = minimum + fun eventOutput(): EventOutput? = eventOutput + fun isUnit(): Boolean = unit != null fun isTiered(): Boolean = tiered != null @@ -4980,6 +4986,8 @@ private constructor( fun isMinimum(): Boolean = minimum != null + fun isEventOutput(): Boolean = eventOutput != null + fun asUnit(): NewSubscriptionUnitPrice = unit.getOrThrow("unit") fun asTiered(): NewSubscriptionTieredPrice = tiered.getOrThrow("tiered") @@ -5057,6 +5065,8 @@ private constructor( fun asMinimum(): NewSubscriptionMinimumCompositePrice = minimum.getOrThrow("minimum") + fun asEventOutput(): EventOutput = eventOutput.getOrThrow("eventOutput") + fun _json(): JsonValue? = _json fun accept(visitor: Visitor): T = @@ -5104,6 +5114,7 @@ private constructor( cumulativeGroupedBulk != null -> visitor.visitCumulativeGroupedBulk(cumulativeGroupedBulk) minimum != null -> visitor.visitMinimum(minimum) + eventOutput != null -> visitor.visitEventOutput(eventOutput) else -> visitor.unknown(_json) } @@ -5268,6 +5279,10 @@ private constructor( override fun visitMinimum(minimum: NewSubscriptionMinimumCompositePrice) { minimum.validate() } + + override fun visitEventOutput(eventOutput: EventOutput) { + eventOutput.validate() + } } ) validated = true @@ -5393,6 +5408,9 @@ private constructor( override fun visitMinimum(minimum: NewSubscriptionMinimumCompositePrice) = minimum.validity() + override fun visitEventOutput(eventOutput: EventOutput) = + eventOutput.validity() + override fun unknown(json: JsonValue?) = 0 } ) @@ -5429,7 +5447,8 @@ private constructor( scalableMatrixWithUnitPricing == other.scalableMatrixWithUnitPricing && scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && cumulativeGroupedBulk == other.cumulativeGroupedBulk && - minimum == other.minimum + minimum == other.minimum && + eventOutput == other.eventOutput } override fun hashCode(): Int = @@ -5461,6 +5480,7 @@ private constructor( scalableMatrixWithTieredPricing, cumulativeGroupedBulk, minimum, + eventOutput, ) override fun toString(): String = @@ -5505,6 +5525,7 @@ private constructor( cumulativeGroupedBulk != null -> "Price{cumulativeGroupedBulk=$cumulativeGroupedBulk}" minimum != null -> "Price{minimum=$minimum}" + eventOutput != null -> "Price{eventOutput=$eventOutput}" _json != null -> "Price{_unknown=$_json}" else -> throw IllegalStateException("Invalid Price") } @@ -5600,6 +5621,8 @@ private constructor( fun ofMinimum(minimum: NewSubscriptionMinimumCompositePrice) = Price(minimum = minimum) + + fun ofEventOutput(eventOutput: EventOutput) = Price(eventOutput = eventOutput) } /** @@ -5696,6 +5719,8 @@ private constructor( fun visitMinimum(minimum: NewSubscriptionMinimumCompositePrice): T + fun visitEventOutput(eventOutput: EventOutput): T + /** * Maps an unknown variant of [Price] to a value of type [T]. * @@ -5923,6 +5948,11 @@ private constructor( ) ?.let { Price(minimum = it, _json = json) } ?: Price(_json = json) } + "event_output" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(eventOutput = it, _json = json) + } ?: Price(_json = json) + } } return Price(_json = json) @@ -5983,6 +6013,7 @@ private constructor( value.cumulativeGroupedBulk != null -> generator.writeObject(value.cumulativeGroupedBulk) value.minimum != null -> generator.writeObject(value.minimum) + value.eventOutput != null -> generator.writeObject(value.eventOutput) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid Price") } @@ -9455,1179 +9486,1573 @@ private constructor( override fun toString() = "GroupedWithMinMaxThresholds{cadence=$cadence, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - return other is AddPrice && - allocationPrice == other.allocationPrice && - discounts == other.discounts && - endDate == other.endDate && - externalPriceId == other.externalPriceId && - maximumAmount == other.maximumAmount && - minimumAmount == other.minimumAmount && - planPhaseOrder == other.planPhaseOrder && - price == other.price && - priceId == other.priceId && - startDate == other.startDate && - additionalProperties == other.additionalProperties - } + class EventOutput + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val eventOutputConfig: JsonField, + private val itemId: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { - private val hashCode: Int by lazy { - Objects.hash( - allocationPrice, - discounts, - endDate, - externalPriceId, - maximumAmount, - minimumAmount, - planPhaseOrder, - price, - priceId, - startDate, - additionalProperties, - ) - } + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("event_output_config") + @ExcludeMissing + eventOutputConfig: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + eventOutputConfig, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + mutableMapOf(), + ) - override fun hashCode(): Int = hashCode + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") - override fun toString() = - "AddPrice{allocationPrice=$allocationPrice, discounts=$discounts, endDate=$endDate, externalPriceId=$externalPriceId, maximumAmount=$maximumAmount, minimumAmount=$minimumAmount, planPhaseOrder=$planPhaseOrder, price=$price, priceId=$priceId, startDate=$startDate, additionalProperties=$additionalProperties}" - } + /** + * Configuration for event_output pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun eventOutputConfig(): EventOutputConfig = + eventOutputConfig.getRequired("event_output_config") - @Deprecated("deprecated") - class ExternalMarketplace - @JsonCreator - private constructor(private val value: JsonField) : Enum { + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API may respond with new members that the SDK is - * unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("event_output") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType - companion object { + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") - val GOOGLE = of("google") + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = billableMetricId.getNullable("billable_metric_id") - val AWS = of("aws") + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") - val AZURE = of("azure") + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") - fun of(value: String) = ExternalMarketplace(JsonField.of(value)) - } + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") - /** An enum containing [ExternalMarketplace]'s known values. */ - enum class Known { - GOOGLE, - AWS, - AZURE, - } + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") - /** - * An enum containing [ExternalMarketplace]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [ExternalMarketplace] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if the - * SDK is on an older version than the API, then the API may respond with new members that - * the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - GOOGLE, - AWS, - AZURE, - /** - * An enum member indicating that [ExternalMarketplace] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") - /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you want - * to throw for the unknown case. - */ - fun value(): Value = - when (this) { - GOOGLE -> Value.GOOGLE - AWS -> Value.AWS - AZURE -> Value.AZURE - else -> Value._UNKNOWN - } + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and don't - * want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known member. - */ - fun known(): Known = - when (this) { - GOOGLE -> Known.GOOGLE - AWS -> Known.AWS - AZURE -> Known.AZURE - else -> throw OrbInvalidDataException("Unknown ExternalMarketplace: $value") - } + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the expected - * primitive type. - */ - fun asString(): String = - _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") - private var validated: Boolean = false + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + invoiceGroupingKey.getNullable("invoice_grouping_key") - fun validate(): ExternalMarketplace = apply { - if (validated) { - return@apply - } + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - known() - validated = true - } + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * Returns the raw JSON value of [eventOutputConfig]. + * + * Unlike [eventOutputConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("event_output_config") + @ExcludeMissing + fun _eventOutputConfig(): JsonField = eventOutputConfig - return other is ExternalMarketplace && value == other.value - } + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - override fun hashCode() = value.hashCode() + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - override fun toString() = value.toString() - } + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by setting - * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to - * `null`. - */ - class Metadata - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration - fun toBuilder() = Builder().from(this) + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate - companion object { + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig - /** Returns a mutable builder for constructing an instance of [Metadata]. */ - fun builder() = Builder() - } + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency - /** A builder for [Metadata]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(metadata: Metadata) = apply { - additionalProperties = metadata.additionalProperties.toMutableMap() - } + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata - /** - * Returns an immutable instance of [Metadata]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId - private var validated: Boolean = false + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - fun validate(): Metadata = apply { - if (validated) { - return@apply - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - validated = true - } + fun toBuilder() = Builder().from(this) - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + companion object { - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + /** + * Returns a mutable builder for constructing an instance of [EventOutput]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .eventOutputConfig() + * .itemId() + * .name() + * ``` + */ + fun builder() = Builder() + } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** A builder for [EventOutput]. */ + class Builder internal constructor() { - return other is Metadata && additionalProperties == other.additionalProperties - } + private var cadence: JsonField? = null + private var eventOutputConfig: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonValue = JsonValue.from("event_output") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + internal fun from(eventOutput: EventOutput) = apply { + cadence = eventOutput.cadence + eventOutputConfig = eventOutput.eventOutputConfig + itemId = eventOutput.itemId + modelType = eventOutput.modelType + name = eventOutput.name + billableMetricId = eventOutput.billableMetricId + billedInAdvance = eventOutput.billedInAdvance + billingCycleConfiguration = eventOutput.billingCycleConfiguration + conversionRate = eventOutput.conversionRate + conversionRateConfig = eventOutput.conversionRateConfig + currency = eventOutput.currency + dimensionalPriceConfiguration = eventOutput.dimensionalPriceConfiguration + externalPriceId = eventOutput.externalPriceId + fixedPriceQuantity = eventOutput.fixedPriceQuantity + invoiceGroupingKey = eventOutput.invoiceGroupingKey + invoicingCycleConfiguration = eventOutput.invoicingCycleConfiguration + metadata = eventOutput.metadata + referenceId = eventOutput.referenceId + additionalProperties = eventOutput.additionalProperties.toMutableMap() + } - override fun hashCode(): Int = hashCode + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - class RemoveAdjustment - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val adjustmentId: JsonField, - private val additionalProperties: MutableMap, - ) { + /** Configuration for event_output pricing */ + fun eventOutputConfig(eventOutputConfig: EventOutputConfig) = + eventOutputConfig(JsonField.of(eventOutputConfig)) - @JsonCreator - private constructor( - @JsonProperty("adjustment_id") - @ExcludeMissing - adjustmentId: JsonField = JsonMissing.of() - ) : this(adjustmentId, mutableMapOf()) + /** + * Sets [Builder.eventOutputConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.eventOutputConfig] with a well-typed + * [EventOutputConfig] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun eventOutputConfig(eventOutputConfig: JsonField) = apply { + this.eventOutputConfig = eventOutputConfig + } - /** - * The id of the adjustment to remove on the subscription. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun adjustmentId(): String = adjustmentId.getRequired("adjustment_id") + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - /** - * Returns the raw JSON value of [adjustmentId]. - * - * Unlike [adjustmentId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("adjustment_id") - @ExcludeMissing - fun _adjustmentId(): JsonField = adjustmentId + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("event_output") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) - fun toBuilder() = Builder().from(this) + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } - companion object { - - /** - * Returns a mutable builder for constructing an instance of [RemoveAdjustment]. - * - * The following fields are required: - * ```kotlin - * .adjustmentId() - * ``` - */ - fun builder() = Builder() - } + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) - /** A builder for [RemoveAdjustment]. */ - class Builder internal constructor() { + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } - private var adjustmentId: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) - internal fun from(removeAdjustment: RemoveAdjustment) = apply { - adjustmentId = removeAdjustment.adjustmentId - additionalProperties = removeAdjustment.additionalProperties.toMutableMap() - } + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) - /** The id of the adjustment to remove on the subscription. */ - fun adjustmentId(adjustmentId: String) = adjustmentId(JsonField.of(adjustmentId)) + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } - /** - * Sets [Builder.adjustmentId] to an arbitrary JSON value. - * - * You should usually call [Builder.adjustmentId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun adjustmentId(adjustmentId: JsonField) = apply { - this.adjustmentId = adjustmentId - } + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) - /** - * Returns an immutable instance of [RemoveAdjustment]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```kotlin - * .adjustmentId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): RemoveAdjustment = - RemoveAdjustment( - checkRequired("adjustmentId", adjustmentId), - additionalProperties.toMutableMap(), - ) - } + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } - private var validated: Boolean = false + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) - fun validate(): RemoveAdjustment = apply { - if (validated) { - return@apply - } + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) - adjustmentId() - validated = true - } + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = (if (adjustmentId.asKnown() == null) 0 else 1) + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } - return other is RemoveAdjustment && - adjustmentId == other.adjustmentId && - additionalProperties == other.additionalProperties - } + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) - private val hashCode: Int by lazy { Objects.hash(adjustmentId, additionalProperties) } + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } - override fun hashCode(): Int = hashCode + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) - override fun toString() = - "RemoveAdjustment{adjustmentId=$adjustmentId, additionalProperties=$additionalProperties}" - } + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } - class RemovePrice - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val externalPriceId: JsonField, - private val priceId: JsonField, - private val additionalProperties: MutableMap, - ) { + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) - @JsonCreator - private constructor( - @JsonProperty("external_price_id") - @ExcludeMissing - externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("price_id") @ExcludeMissing priceId: JsonField = JsonMissing.of(), - ) : this(externalPriceId, priceId, mutableMapOf()) + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) - /** - * The external price id of the price to remove on the subscription. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } - /** - * The id of the price to remove on the subscription. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun priceId(): String? = priceId.getNullable("price_id") + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) - /** - * Returns the raw JSON value of [externalPriceId]. - * - * Unlike [externalPriceId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } - /** - * Returns the raw JSON value of [priceId]. - * - * Unlike [priceId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - fun toBuilder() = Builder().from(this) + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - companion object { + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) - /** Returns a mutable builder for constructing an instance of [RemovePrice]. */ - fun builder() = Builder() - } + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } - /** A builder for [RemovePrice]. */ - class Builder internal constructor() { + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - private var externalPriceId: JsonField = JsonMissing.of() - private var priceId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - internal fun from(removePrice: RemovePrice) = apply { - externalPriceId = removePrice.externalPriceId - priceId = removePrice.priceId - additionalProperties = removePrice.additionalProperties.toMutableMap() - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - /** The external price id of the price to remove on the subscription. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - /** - * Sets [Builder.externalPriceId] to an arbitrary JSON value. - * - * You should usually call [Builder.externalPriceId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun externalPriceId(externalPriceId: JsonField) = apply { - this.externalPriceId = externalPriceId - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - /** The id of the price to remove on the subscription. */ - fun priceId(priceId: String?) = priceId(JsonField.ofNullable(priceId)) + /** + * Returns an immutable instance of [EventOutput]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .eventOutputConfig() + * .itemId() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): EventOutput = + EventOutput( + checkRequired("cadence", cadence), + checkRequired("eventOutputConfig", eventOutputConfig), + checkRequired("itemId", itemId), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } - /** - * Sets [Builder.priceId] to an arbitrary JSON value. - * - * You should usually call [Builder.priceId] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun priceId(priceId: JsonField) = apply { this.priceId = priceId } + private var validated: Boolean = false - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun validate(): EventOutput = apply { + if (validated) { + return@apply + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + cadence().validate() + eventOutputConfig().validate() + itemId() + _modelType().let { + if (it != JsonValue.from("event_output")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + metadata()?.validate() + referenceId() + validated = true + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (eventOutputConfig.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + modelType.let { if (it == JsonValue.from("event_output")) 1 else 0 } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { - /** - * Returns an immutable instance of [RemovePrice]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): RemovePrice = - RemovePrice(externalPriceId, priceId, additionalProperties.toMutableMap()) - } + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value - private var validated: Boolean = false + companion object { - fun validate(): RemovePrice = apply { - if (validated) { - return@apply - } + val ANNUAL = of("annual") - externalPriceId() - priceId() - validated = true - } + val SEMI_ANNUAL = of("semi_annual") - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + val MONTHLY = of("monthly") - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (if (externalPriceId.asKnown() == null) 0 else 1) + - (if (priceId.asKnown() == null) 0 else 1) + val QUARTERLY = of("quarterly") - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + val ONE_TIME = of("one_time") - return other is RemovePrice && - externalPriceId == other.externalPriceId && - priceId == other.priceId && - additionalProperties == other.additionalProperties - } + val CUSTOM = of("custom") - private val hashCode: Int by lazy { - Objects.hash(externalPriceId, priceId, additionalProperties) - } + fun of(value: String) = Cadence(JsonField.of(value)) + } - override fun hashCode(): Int = hashCode + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } - override fun toString() = - "RemovePrice{externalPriceId=$externalPriceId, priceId=$priceId, additionalProperties=$additionalProperties}" - } + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } - class ReplaceAdjustment - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val adjustment: JsonField, - private val replacesAdjustmentId: JsonField, - private val additionalProperties: MutableMap, - ) { + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } - @JsonCreator - private constructor( - @JsonProperty("adjustment") - @ExcludeMissing - adjustment: JsonField = JsonMissing.of(), - @JsonProperty("replaces_adjustment_id") - @ExcludeMissing - replacesAdjustmentId: JsonField = JsonMissing.of(), - ) : this(adjustment, replacesAdjustmentId, mutableMapOf()) + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } - /** - * The definition of a new adjustment to create and add to the subscription. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun adjustment(): Adjustment = adjustment.getRequired("adjustment") + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") - /** - * The id of the adjustment on the plan to replace in the subscription. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun replacesAdjustmentId(): String = - replacesAdjustmentId.getRequired("replaces_adjustment_id") + private var validated: Boolean = false - /** - * Returns the raw JSON value of [adjustment]. - * - * Unlike [adjustment], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("adjustment") - @ExcludeMissing - fun _adjustment(): JsonField = adjustment + fun validate(): Cadence = apply { + if (validated) { + return@apply + } - /** - * Returns the raw JSON value of [replacesAdjustmentId]. - * - * Unlike [replacesAdjustmentId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("replaces_adjustment_id") - @ExcludeMissing - fun _replacesAdjustmentId(): JsonField = replacesAdjustmentId + known() + validated = true + } - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - fun toBuilder() = Builder().from(this) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - companion object { + return other is Cadence && value == other.value + } - /** - * Returns a mutable builder for constructing an instance of [ReplaceAdjustment]. - * - * The following fields are required: - * ```kotlin - * .adjustment() - * .replacesAdjustmentId() - * ``` - */ - fun builder() = Builder() - } + override fun hashCode() = value.hashCode() - /** A builder for [ReplaceAdjustment]. */ - class Builder internal constructor() { + override fun toString() = value.toString() + } - private var adjustment: JsonField? = null - private var replacesAdjustmentId: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() + /** Configuration for event_output pricing */ + class EventOutputConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val unitRatingKey: JsonField, + private val groupingKey: JsonField, + private val additionalProperties: MutableMap, + ) { - internal fun from(replaceAdjustment: ReplaceAdjustment) = apply { - adjustment = replaceAdjustment.adjustment - replacesAdjustmentId = replaceAdjustment.replacesAdjustmentId - additionalProperties = replaceAdjustment.additionalProperties.toMutableMap() - } + @JsonCreator + private constructor( + @JsonProperty("unit_rating_key") + @ExcludeMissing + unitRatingKey: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + ) : this(unitRatingKey, groupingKey, mutableMapOf()) - /** The definition of a new adjustment to create and add to the subscription. */ - fun adjustment(adjustment: Adjustment) = adjustment(JsonField.of(adjustment)) + /** + * The key in the event data to extract the unit rate from. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun unitRatingKey(): String = unitRatingKey.getRequired("unit_rating_key") - /** - * Sets [Builder.adjustment] to an arbitrary JSON value. - * - * You should usually call [Builder.adjustment] with a well-typed [Adjustment] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun adjustment(adjustment: JsonField) = apply { - this.adjustment = adjustment - } + /** + * An optional key in the event data to group by (e.g., event ID). All events + * will also be grouped by their unit rate. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun groupingKey(): String? = groupingKey.getNullable("grouping_key") - /** - * Alias for calling [adjustment] with - * `Adjustment.ofPercentageDiscount(percentageDiscount)`. - */ - fun adjustment(percentageDiscount: NewPercentageDiscount) = - adjustment(Adjustment.ofPercentageDiscount(percentageDiscount)) + /** + * Returns the raw JSON value of [unitRatingKey]. + * + * Unlike [unitRatingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_rating_key") + @ExcludeMissing + fun _unitRatingKey(): JsonField = unitRatingKey - /** - * Alias for calling [adjustment] with the following: - * ```kotlin - * NewPercentageDiscount.builder() - * .adjustmentType(NewPercentageDiscount.AdjustmentType.PERCENTAGE_DISCOUNT) - * .percentageDiscount(percentageDiscount) - * .build() - * ``` - */ - fun percentageDiscountAdjustment(percentageDiscount: Double) = - adjustment( - NewPercentageDiscount.builder() - .adjustmentType(NewPercentageDiscount.AdjustmentType.PERCENTAGE_DISCOUNT) - .percentageDiscount(percentageDiscount) - .build() - ) + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey - /** Alias for calling [adjustment] with `Adjustment.ofUsageDiscount(usageDiscount)`. */ - fun adjustment(usageDiscount: NewUsageDiscount) = - adjustment(Adjustment.ofUsageDiscount(usageDiscount)) + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - /** - * Alias for calling [adjustment] with the following: - * ```kotlin - * NewUsageDiscount.builder() - * .adjustmentType(NewUsageDiscount.AdjustmentType.USAGE_DISCOUNT) - * .usageDiscount(usageDiscount) - * .build() - * ``` - */ - fun usageDiscountAdjustment(usageDiscount: Double) = - adjustment( - NewUsageDiscount.builder() - .adjustmentType(NewUsageDiscount.AdjustmentType.USAGE_DISCOUNT) - .usageDiscount(usageDiscount) - .build() - ) + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - /** - * Alias for calling [adjustment] with `Adjustment.ofAmountDiscount(amountDiscount)`. - */ - fun adjustment(amountDiscount: NewAmountDiscount) = - adjustment(Adjustment.ofAmountDiscount(amountDiscount)) + fun toBuilder() = Builder().from(this) - /** - * Alias for calling [adjustment] with the following: - * ```kotlin - * NewAmountDiscount.builder() - * .adjustmentType(NewAmountDiscount.AdjustmentType.AMOUNT_DISCOUNT) - * .amountDiscount(amountDiscount) - * .build() - * ``` - */ - fun amountDiscountAdjustment(amountDiscount: String) = - adjustment( - NewAmountDiscount.builder() - .adjustmentType(NewAmountDiscount.AdjustmentType.AMOUNT_DISCOUNT) - .amountDiscount(amountDiscount) - .build() - ) + companion object { - /** Alias for calling [adjustment] with `Adjustment.ofMinimum(minimum)`. */ - fun adjustment(minimum: NewMinimum) = adjustment(Adjustment.ofMinimum(minimum)) + /** + * Returns a mutable builder for constructing an instance of + * [EventOutputConfig]. + * + * The following fields are required: + * ```kotlin + * .unitRatingKey() + * ``` + */ + fun builder() = Builder() + } - /** Alias for calling [adjustment] with `Adjustment.ofMaximum(maximum)`. */ - fun adjustment(maximum: NewMaximum) = adjustment(Adjustment.ofMaximum(maximum)) + /** A builder for [EventOutputConfig]. */ + class Builder internal constructor() { - /** - * Alias for calling [adjustment] with the following: - * ```kotlin - * NewMaximum.builder() - * .adjustmentType(NewMaximum.AdjustmentType.MAXIMUM) - * .maximumAmount(maximumAmount) - * .build() - * ``` - */ - fun maximumAdjustment(maximumAmount: String) = - adjustment( - NewMaximum.builder() - .adjustmentType(NewMaximum.AdjustmentType.MAXIMUM) - .maximumAmount(maximumAmount) - .build() - ) + private var unitRatingKey: JsonField? = null + private var groupingKey: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() - /** The id of the adjustment on the plan to replace in the subscription. */ - fun replacesAdjustmentId(replacesAdjustmentId: String) = - replacesAdjustmentId(JsonField.of(replacesAdjustmentId)) + internal fun from(eventOutputConfig: EventOutputConfig) = apply { + unitRatingKey = eventOutputConfig.unitRatingKey + groupingKey = eventOutputConfig.groupingKey + additionalProperties = + eventOutputConfig.additionalProperties.toMutableMap() + } - /** - * Sets [Builder.replacesAdjustmentId] to an arbitrary JSON value. - * - * You should usually call [Builder.replacesAdjustmentId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun replacesAdjustmentId(replacesAdjustmentId: JsonField) = apply { - this.replacesAdjustmentId = replacesAdjustmentId - } + /** The key in the event data to extract the unit rate from. */ + fun unitRatingKey(unitRatingKey: String) = + unitRatingKey(JsonField.of(unitRatingKey)) - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * Sets [Builder.unitRatingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.unitRatingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun unitRatingKey(unitRatingKey: JsonField) = apply { + this.unitRatingKey = unitRatingKey + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * An optional key in the event data to group by (e.g., event ID). All + * events will also be grouped by their unit rate. + */ + fun groupingKey(groupingKey: String?) = + groupingKey(JsonField.ofNullable(groupingKey)) - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** - * Returns an immutable instance of [ReplaceAdjustment]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```kotlin - * .adjustment() - * .replacesAdjustmentId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): ReplaceAdjustment = - ReplaceAdjustment( - checkRequired("adjustment", adjustment), - checkRequired("replacesAdjustmentId", replacesAdjustmentId), - additionalProperties.toMutableMap(), - ) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - private var validated: Boolean = false + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun validate(): ReplaceAdjustment = apply { - if (validated) { - return@apply - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - adjustment().validate() - replacesAdjustmentId() - validated = true - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** + * Returns an immutable instance of [EventOutputConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .unitRatingKey() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): EventOutputConfig = + EventOutputConfig( + checkRequired("unitRatingKey", unitRatingKey), + groupingKey, + additionalProperties.toMutableMap(), + ) + } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (adjustment.asKnown()?.validity() ?: 0) + - (if (replacesAdjustmentId.asKnown() == null) 0 else 1) + private var validated: Boolean = false - /** The definition of a new adjustment to create and add to the subscription. */ - @JsonDeserialize(using = Adjustment.Deserializer::class) - @JsonSerialize(using = Adjustment.Serializer::class) - class Adjustment - private constructor( - private val percentageDiscount: NewPercentageDiscount? = null, - private val usageDiscount: NewUsageDiscount? = null, - private val amountDiscount: NewAmountDiscount? = null, - private val minimum: NewMinimum? = null, - private val maximum: NewMaximum? = null, - private val _json: JsonValue? = null, - ) { + fun validate(): EventOutputConfig = apply { + if (validated) { + return@apply + } - fun percentageDiscount(): NewPercentageDiscount? = percentageDiscount + unitRatingKey() + groupingKey() + validated = true + } - fun usageDiscount(): NewUsageDiscount? = usageDiscount + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - fun amountDiscount(): NewAmountDiscount? = amountDiscount + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (unitRatingKey.asKnown() == null) 0 else 1) + + (if (groupingKey.asKnown() == null) 0 else 1) - fun minimum(): NewMinimum? = minimum + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun maximum(): NewMaximum? = maximum + return other is EventOutputConfig && + unitRatingKey == other.unitRatingKey && + groupingKey == other.groupingKey && + additionalProperties == other.additionalProperties + } - fun isPercentageDiscount(): Boolean = percentageDiscount != null + private val hashCode: Int by lazy { + Objects.hash(unitRatingKey, groupingKey, additionalProperties) + } - fun isUsageDiscount(): Boolean = usageDiscount != null + override fun hashCode(): Int = hashCode - fun isAmountDiscount(): Boolean = amountDiscount != null + override fun toString() = + "EventOutputConfig{unitRatingKey=$unitRatingKey, groupingKey=$groupingKey, additionalProperties=$additionalProperties}" + } - fun isMinimum(): Boolean = minimum != null + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { - fun isMaximum(): Boolean = maximum != null + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties - fun asPercentageDiscount(): NewPercentageDiscount = - percentageDiscount.getOrThrow("percentageDiscount") + fun toBuilder() = Builder().from(this) - fun asUsageDiscount(): NewUsageDiscount = usageDiscount.getOrThrow("usageDiscount") + companion object { - fun asAmountDiscount(): NewAmountDiscount = amountDiscount.getOrThrow("amountDiscount") + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } - fun asMinimum(): NewMinimum = minimum.getOrThrow("minimum") + /** A builder for [Metadata]. */ + class Builder internal constructor() { - fun asMaximum(): NewMaximum = maximum.getOrThrow("maximum") + private var additionalProperties: MutableMap = + mutableMapOf() - fun _json(): JsonValue? = _json + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } - fun accept(visitor: Visitor): T = - when { - percentageDiscount != null -> - visitor.visitPercentageDiscount(percentageDiscount) - usageDiscount != null -> visitor.visitUsageDiscount(usageDiscount) - amountDiscount != null -> visitor.visitAmountDiscount(amountDiscount) - minimum != null -> visitor.visitMinimum(minimum) - maximum != null -> visitor.visitMaximum(maximum) - else -> visitor.unknown(_json) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - private var validated: Boolean = false + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun validate(): Adjustment = apply { - if (validated) { - return@apply - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - accept( - object : Visitor { - override fun visitPercentageDiscount( - percentageDiscount: NewPercentageDiscount - ) { - percentageDiscount.validate() + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) } - override fun visitUsageDiscount(usageDiscount: NewUsageDiscount) { - usageDiscount.validate() + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) } - override fun visitAmountDiscount(amountDiscount: NewAmountDiscount) { - amountDiscount.validate() - } + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } - override fun visitMinimum(minimum: NewMinimum) { - minimum.validate() - } + private var validated: Boolean = false - override fun visitMaximum(maximum: NewMaximum) { - maximum.validate() + fun validate(): Metadata = apply { + if (validated) { + return@apply } + + validated = true } - ) - validated = true - } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitPercentageDiscount( - percentageDiscount: NewPercentageDiscount - ) = percentageDiscount.validity() - - override fun visitUsageDiscount(usageDiscount: NewUsageDiscount) = - usageDiscount.validity() - - override fun visitAmountDiscount(amountDiscount: NewAmountDiscount) = - amountDiscount.validity() - - override fun visitMinimum(minimum: NewMinimum) = minimum.validity() + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } - override fun visitMaximum(maximum: NewMaximum) = maximum.validity() + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - override fun unknown(json: JsonValue?) = 0 + return other is Metadata && + additionalProperties == other.additionalProperties } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - return other is Adjustment && - percentageDiscount == other.percentageDiscount && - usageDiscount == other.usageDiscount && - amountDiscount == other.amountDiscount && - minimum == other.minimum && - maximum == other.maximum - } + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - override fun hashCode(): Int = - Objects.hash(percentageDiscount, usageDiscount, amountDiscount, minimum, maximum) + override fun hashCode(): Int = hashCode - override fun toString(): String = - when { - percentageDiscount != null -> - "Adjustment{percentageDiscount=$percentageDiscount}" - usageDiscount != null -> "Adjustment{usageDiscount=$usageDiscount}" - amountDiscount != null -> "Adjustment{amountDiscount=$amountDiscount}" - minimum != null -> "Adjustment{minimum=$minimum}" - maximum != null -> "Adjustment{maximum=$maximum}" - _json != null -> "Adjustment{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Adjustment") + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" } - companion object { - - fun ofPercentageDiscount(percentageDiscount: NewPercentageDiscount) = - Adjustment(percentageDiscount = percentageDiscount) - - fun ofUsageDiscount(usageDiscount: NewUsageDiscount) = - Adjustment(usageDiscount = usageDiscount) - - fun ofAmountDiscount(amountDiscount: NewAmountDiscount) = - Adjustment(amountDiscount = amountDiscount) - - fun ofMinimum(minimum: NewMinimum) = Adjustment(minimum = minimum) - - fun ofMaximum(maximum: NewMaximum) = Adjustment(maximum = maximum) - } - - /** - * An interface that defines how to map each variant of [Adjustment] to a value of type - * [T]. - */ - interface Visitor { - - fun visitPercentageDiscount(percentageDiscount: NewPercentageDiscount): T - - fun visitUsageDiscount(usageDiscount: NewUsageDiscount): T - - fun visitAmountDiscount(amountDiscount: NewAmountDiscount): T - - fun visitMinimum(minimum: NewMinimum): T - - fun visitMaximum(maximum: NewMaximum): T + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * Maps an unknown variant of [Adjustment] to a value of type [T]. - * - * An instance of [Adjustment] can contain an unknown variant if it was deserialized - * from data that doesn't match any known variant. For example, if the SDK is on an - * older version than the API, then the API may respond with new variants that the - * SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown Adjustment: $json") + return other is EventOutput && + cadence == other.cadence && + eventOutputConfig == other.eventOutputConfig && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties } - } - - internal class Deserializer : BaseDeserializer(Adjustment::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): Adjustment { - val json = JsonValue.fromJsonNode(node) - val adjustmentType = json.asObject()?.get("adjustment_type")?.asString() - - when (adjustmentType) { - "percentage_discount" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Adjustment(percentageDiscount = it, _json = json) } - ?: Adjustment(_json = json) - } - "usage_discount" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(usageDiscount = it, _json = json) - } ?: Adjustment(_json = json) - } - "amount_discount" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(amountDiscount = it, _json = json) - } ?: Adjustment(_json = json) - } - "minimum" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(minimum = it, _json = json) - } ?: Adjustment(_json = json) - } - "maximum" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(maximum = it, _json = json) - } ?: Adjustment(_json = json) - } - } - return Adjustment(_json = json) + private val hashCode: Int by lazy { + Objects.hash( + cadence, + eventOutputConfig, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties, + ) } - } - internal class Serializer : BaseSerializer(Adjustment::class) { + override fun hashCode(): Int = hashCode - override fun serialize( - value: Adjustment, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.percentageDiscount != null -> - generator.writeObject(value.percentageDiscount) - value.usageDiscount != null -> generator.writeObject(value.usageDiscount) - value.amountDiscount != null -> generator.writeObject(value.amountDiscount) - value.minimum != null -> generator.writeObject(value.minimum) - value.maximum != null -> generator.writeObject(value.maximum) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Adjustment") - } - } + override fun toString() = + "EventOutput{cadence=$cadence, eventOutputConfig=$eventOutputConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } } @@ -10636,598 +11061,361 @@ private constructor( return true } - return other is ReplaceAdjustment && - adjustment == other.adjustment && - replacesAdjustmentId == other.replacesAdjustmentId && + return other is AddPrice && + allocationPrice == other.allocationPrice && + discounts == other.discounts && + endDate == other.endDate && + externalPriceId == other.externalPriceId && + maximumAmount == other.maximumAmount && + minimumAmount == other.minimumAmount && + planPhaseOrder == other.planPhaseOrder && + price == other.price && + priceId == other.priceId && + startDate == other.startDate && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(adjustment, replacesAdjustmentId, additionalProperties) + Objects.hash( + allocationPrice, + discounts, + endDate, + externalPriceId, + maximumAmount, + minimumAmount, + planPhaseOrder, + price, + priceId, + startDate, + additionalProperties, + ) } override fun hashCode(): Int = hashCode override fun toString() = - "ReplaceAdjustment{adjustment=$adjustment, replacesAdjustmentId=$replacesAdjustmentId, additionalProperties=$additionalProperties}" + "AddPrice{allocationPrice=$allocationPrice, discounts=$discounts, endDate=$endDate, externalPriceId=$externalPriceId, maximumAmount=$maximumAmount, minimumAmount=$minimumAmount, planPhaseOrder=$planPhaseOrder, price=$price, priceId=$priceId, startDate=$startDate, additionalProperties=$additionalProperties}" } - class ReplacePrice - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val replacesPriceId: JsonField, - private val allocationPrice: JsonField, - private val discounts: JsonField>, - private val externalPriceId: JsonField, - private val fixedPriceQuantity: JsonField, - private val maximumAmount: JsonField, - private val minimumAmount: JsonField, - private val price: JsonField, - private val priceId: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("replaces_price_id") - @ExcludeMissing - replacesPriceId: JsonField = JsonMissing.of(), - @JsonProperty("allocation_price") - @ExcludeMissing - allocationPrice: JsonField = JsonMissing.of(), - @JsonProperty("discounts") - @ExcludeMissing - discounts: JsonField> = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("maximum_amount") - @ExcludeMissing - maximumAmount: JsonField = JsonMissing.of(), - @JsonProperty("minimum_amount") - @ExcludeMissing - minimumAmount: JsonField = JsonMissing.of(), - @JsonProperty("price") @ExcludeMissing price: JsonField = JsonMissing.of(), - @JsonProperty("price_id") @ExcludeMissing priceId: JsonField = JsonMissing.of(), - ) : this( - replacesPriceId, - allocationPrice, - discounts, - externalPriceId, - fixedPriceQuantity, - maximumAmount, - minimumAmount, - price, - priceId, - mutableMapOf(), - ) + @Deprecated("deprecated") + class ExternalMarketplace + @JsonCreator + private constructor(private val value: JsonField) : Enum { /** - * The id of the price on the plan to replace in the subscription. + * Returns this class instance's raw value. * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. */ - fun replacesPriceId(): String = replacesPriceId.getRequired("replaces_price_id") + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - /** - * The definition of a new allocation price to create and add to the subscription. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun allocationPrice(): NewAllocationPrice? = allocationPrice.getNullable("allocation_price") + companion object { - /** - * [DEPRECATED] Use add_adjustments instead. The subscription's discounts for the - * replacement price. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - @Deprecated("deprecated") - fun discounts(): List? = discounts.getNullable("discounts") + val GOOGLE = of("google") - /** - * The external price id of the price to add to the subscription. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + val AWS = of("aws") - /** - * The new quantity of the price, if the price is a fixed price. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun fixedPriceQuantity(): Double? = fixedPriceQuantity.getNullable("fixed_price_quantity") + val AZURE = of("azure") - /** - * [DEPRECATED] Use add_adjustments instead. The subscription's maximum amount for the - * replacement price. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - @Deprecated("deprecated") - fun maximumAmount(): String? = maximumAmount.getNullable("maximum_amount") + fun of(value: String) = ExternalMarketplace(JsonField.of(value)) + } - /** - * [DEPRECATED] Use add_adjustments instead. The subscription's minimum amount for the - * replacement price. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - @Deprecated("deprecated") - fun minimumAmount(): String? = minimumAmount.getNullable("minimum_amount") + /** An enum containing [ExternalMarketplace]'s known values. */ + enum class Known { + GOOGLE, + AWS, + AZURE, + } /** - * New subscription price request body params. + * An enum containing [ExternalMarketplace]'s known values, as well as an [_UNKNOWN] member. * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). + * An instance of [ExternalMarketplace] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. */ - fun price(): Price? = price.getNullable("price") + enum class Value { + GOOGLE, + AWS, + AZURE, + /** + * An enum member indicating that [ExternalMarketplace] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } /** - * The id of the price to add to the subscription. + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. */ - fun priceId(): String? = priceId.getNullable("price_id") + fun value(): Value = + when (this) { + GOOGLE -> Value.GOOGLE + AWS -> Value.AWS + AZURE -> Value.AZURE + else -> Value._UNKNOWN + } /** - * Returns the raw JSON value of [replacesPriceId]. + * Returns an enum member corresponding to this class instance's value. * - * Unlike [replacesPriceId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("replaces_price_id") - @ExcludeMissing - fun _replacesPriceId(): JsonField = replacesPriceId - - /** - * Returns the raw JSON value of [allocationPrice]. + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. * - * Unlike [allocationPrice], this method doesn't throw if the JSON field has an unexpected - * type. + * @throws OrbInvalidDataException if this class instance's value is a not a known member. */ - @JsonProperty("allocation_price") - @ExcludeMissing - fun _allocationPrice(): JsonField = allocationPrice + fun known(): Known = + when (this) { + GOOGLE -> Known.GOOGLE + AWS -> Known.AWS + AZURE -> Known.AZURE + else -> throw OrbInvalidDataException("Unknown ExternalMarketplace: $value") + } /** - * Returns the raw JSON value of [discounts]. + * Returns this class instance's primitive wire representation. * - * Unlike [discounts], this method doesn't throw if the JSON field has an unexpected type. - */ - @Deprecated("deprecated") - @JsonProperty("discounts") - @ExcludeMissing - fun _discounts(): JsonField> = discounts - - /** - * Returns the raw JSON value of [externalPriceId]. + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. * - * Unlike [externalPriceId], this method doesn't throw if the JSON field has an unexpected - * type. + * @throws OrbInvalidDataException if this class instance's value does not have the expected + * primitive type. */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") - /** - * Returns the raw JSON value of [fixedPriceQuantity]. - * - * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + private var validated: Boolean = false - /** - * Returns the raw JSON value of [maximumAmount]. - * - * Unlike [maximumAmount], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @Deprecated("deprecated") - @JsonProperty("maximum_amount") - @ExcludeMissing - fun _maximumAmount(): JsonField = maximumAmount + fun validate(): ExternalMarketplace = apply { + if (validated) { + return@apply + } - /** - * Returns the raw JSON value of [minimumAmount]. - * - * Unlike [minimumAmount], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @Deprecated("deprecated") - @JsonProperty("minimum_amount") - @ExcludeMissing - fun _minimumAmount(): JsonField = minimumAmount + known() + validated = true + } - /** - * Returns the raw JSON value of [price]. - * - * Unlike [price], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("price") @ExcludeMissing fun _price(): JsonField = price + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } /** - * Returns the raw JSON value of [priceId]. + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * Unlike [priceId], this method doesn't throw if the JSON field has an unexpected type. + * Used for best match union deserialization. */ - @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ExternalMarketplace && value == other.value } - @JsonAnyGetter + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by setting + * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to + * `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + fun _additionalProperties(): Map = additionalProperties fun toBuilder() = Builder().from(this) companion object { - /** - * Returns a mutable builder for constructing an instance of [ReplacePrice]. - * - * The following fields are required: - * ```kotlin - * .replacesPriceId() - * ``` - */ + /** Returns a mutable builder for constructing an instance of [Metadata]. */ fun builder() = Builder() } - /** A builder for [ReplacePrice]. */ + /** A builder for [Metadata]. */ class Builder internal constructor() { - private var replacesPriceId: JsonField? = null - private var allocationPrice: JsonField = JsonMissing.of() - private var discounts: JsonField>? = null - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var maximumAmount: JsonField = JsonMissing.of() - private var minimumAmount: JsonField = JsonMissing.of() - private var price: JsonField = JsonMissing.of() - private var priceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(replacePrice: ReplacePrice) = apply { - replacesPriceId = replacePrice.replacesPriceId - allocationPrice = replacePrice.allocationPrice - discounts = replacePrice.discounts.map { it.toMutableList() } - externalPriceId = replacePrice.externalPriceId - fixedPriceQuantity = replacePrice.fixedPriceQuantity - maximumAmount = replacePrice.maximumAmount - minimumAmount = replacePrice.minimumAmount - price = replacePrice.price - priceId = replacePrice.priceId - additionalProperties = replacePrice.additionalProperties.toMutableMap() + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() } - /** The id of the price on the plan to replace in the subscription. */ - fun replacesPriceId(replacesPriceId: String) = - replacesPriceId(JsonField.of(replacesPriceId)) - - /** - * Sets [Builder.replacesPriceId] to an arbitrary JSON value. - * - * You should usually call [Builder.replacesPriceId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun replacesPriceId(replacesPriceId: JsonField) = apply { - this.replacesPriceId = replacesPriceId + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) } - /** The definition of a new allocation price to create and add to the subscription. */ - fun allocationPrice(allocationPrice: NewAllocationPrice?) = - allocationPrice(JsonField.ofNullable(allocationPrice)) + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * Sets [Builder.allocationPrice] to an arbitrary JSON value. - * - * You should usually call [Builder.allocationPrice] with a well-typed - * [NewAllocationPrice] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun allocationPrice(allocationPrice: JsonField) = apply { - this.allocationPrice = allocationPrice + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) } - /** - * [DEPRECATED] Use add_adjustments instead. The subscription's discounts for the - * replacement price. - */ - @Deprecated("deprecated") - fun discounts(discounts: List?) = - discounts(JsonField.ofNullable(discounts)) + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - /** - * Sets [Builder.discounts] to an arbitrary JSON value. - * - * You should usually call [Builder.discounts] with a well-typed - * `List` value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - @Deprecated("deprecated") - fun discounts(discounts: JsonField>) = apply { - this.discounts = discounts.map { it.toMutableList() } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) } /** - * Adds a single [DiscountOverride] to [discounts]. + * Returns an immutable instance of [Metadata]. * - * @throws IllegalStateException if the field was previously set to a non-list. + * Further updates to this [Builder] will not mutate the returned instance. */ - @Deprecated("deprecated") - fun addDiscount(discount: DiscountOverride) = apply { - discounts = - (discounts ?: JsonField.of(mutableListOf())).also { - checkKnown("discounts", it).add(discount) - } - } + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } - /** The external price id of the price to add to the subscription. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) + private var validated: Boolean = false - /** - * Sets [Builder.externalPriceId] to an arbitrary JSON value. - * - * You should usually call [Builder.externalPriceId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun externalPriceId(externalPriceId: JsonField) = apply { - this.externalPriceId = externalPriceId + fun validate(): Metadata = apply { + if (validated) { + return@apply } - /** The new quantity of the price, if the price is a fixed price. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = - fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) - - /** - * Alias for [Builder.fixedPriceQuantity]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) + validated = true + } - /** - * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. - * - * You should usually call [Builder.fixedPriceQuantity] with a well-typed [Double] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { - this.fixedPriceQuantity = fixedPriceQuantity + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false } - /** - * [DEPRECATED] Use add_adjustments instead. The subscription's maximum amount for the - * replacement price. - */ - @Deprecated("deprecated") - fun maximumAmount(maximumAmount: String?) = - maximumAmount(JsonField.ofNullable(maximumAmount)) + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } - /** - * Sets [Builder.maximumAmount] to an arbitrary JSON value. - * - * You should usually call [Builder.maximumAmount] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - @Deprecated("deprecated") - fun maximumAmount(maximumAmount: JsonField) = apply { - this.maximumAmount = maximumAmount + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - /** - * [DEPRECATED] Use add_adjustments instead. The subscription's minimum amount for the - * replacement price. - */ - @Deprecated("deprecated") - fun minimumAmount(minimumAmount: String?) = - minimumAmount(JsonField.ofNullable(minimumAmount)) - - /** - * Sets [Builder.minimumAmount] to an arbitrary JSON value. - * - * You should usually call [Builder.minimumAmount] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - @Deprecated("deprecated") - fun minimumAmount(minimumAmount: JsonField) = apply { - this.minimumAmount = minimumAmount - } + return other is Metadata && additionalProperties == other.additionalProperties + } - /** New subscription price request body params. */ - fun price(price: Price?) = price(JsonField.ofNullable(price)) + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /** - * Sets [Builder.price] to an arbitrary JSON value. - * - * You should usually call [Builder.price] with a well-typed [Price] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun price(price: JsonField) = apply { this.price = price } + override fun hashCode(): Int = hashCode - /** Alias for calling [price] with `Price.ofUnit(unit)`. */ - fun price(unit: NewSubscriptionUnitPrice) = price(Price.ofUnit(unit)) + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } - /** Alias for calling [price] with `Price.ofTiered(tiered)`. */ - fun price(tiered: NewSubscriptionTieredPrice) = price(Price.ofTiered(tiered)) + class RemoveAdjustment + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val adjustmentId: JsonField, + private val additionalProperties: MutableMap, + ) { - /** Alias for calling [price] with `Price.ofBulk(bulk)`. */ - fun price(bulk: NewSubscriptionBulkPrice) = price(Price.ofBulk(bulk)) + @JsonCreator + private constructor( + @JsonProperty("adjustment_id") + @ExcludeMissing + adjustmentId: JsonField = JsonMissing.of() + ) : this(adjustmentId, mutableMapOf()) - /** Alias for calling [price] with `Price.ofPackage(package_)`. */ - fun price(package_: NewSubscriptionPackagePrice) = price(Price.ofPackage(package_)) + /** + * The id of the adjustment to remove on the subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun adjustmentId(): String = adjustmentId.getRequired("adjustment_id") - /** Alias for calling [price] with `Price.ofMatrix(matrix)`. */ - fun price(matrix: NewSubscriptionMatrixPrice) = price(Price.ofMatrix(matrix)) - - /** - * Alias for calling [price] with `Price.ofThresholdTotalAmount(thresholdTotalAmount)`. - */ - fun price(thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice) = - price(Price.ofThresholdTotalAmount(thresholdTotalAmount)) - - /** Alias for calling [price] with `Price.ofTieredPackage(tieredPackage)`. */ - fun price(tieredPackage: NewSubscriptionTieredPackagePrice) = - price(Price.ofTieredPackage(tieredPackage)) - - /** Alias for calling [price] with `Price.ofTieredWithMinimum(tieredWithMinimum)`. */ - fun price(tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice) = - price(Price.ofTieredWithMinimum(tieredWithMinimum)) - - /** Alias for calling [price] with `Price.ofGroupedTiered(groupedTiered)`. */ - fun price(groupedTiered: NewSubscriptionGroupedTieredPrice) = - price(Price.ofGroupedTiered(groupedTiered)) - - /** - * Alias for calling [price] with - * `Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)`. - */ - fun price(tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice) = - price(Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)) - - /** - * Alias for calling [price] with - * `Price.ofPackageWithAllocation(packageWithAllocation)`. - */ - fun price(packageWithAllocation: NewSubscriptionPackageWithAllocationPrice) = - price(Price.ofPackageWithAllocation(packageWithAllocation)) - - /** Alias for calling [price] with `Price.ofUnitWithPercent(unitWithPercent)`. */ - fun price(unitWithPercent: NewSubscriptionUnitWithPercentPrice) = - price(Price.ofUnitWithPercent(unitWithPercent)) - - /** - * Alias for calling [price] with `Price.ofMatrixWithAllocation(matrixWithAllocation)`. - */ - fun price(matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice) = - price(Price.ofMatrixWithAllocation(matrixWithAllocation)) - - /** - * Alias for calling [price] with `Price.ofTieredWithProration(tieredWithProration)`. - */ - fun price(tieredWithProration: Price.TieredWithProration) = - price(Price.ofTieredWithProration(tieredWithProration)) - - /** Alias for calling [price] with `Price.ofUnitWithProration(unitWithProration)`. */ - fun price(unitWithProration: NewSubscriptionUnitWithProrationPrice) = - price(Price.ofUnitWithProration(unitWithProration)) - - /** Alias for calling [price] with `Price.ofGroupedAllocation(groupedAllocation)`. */ - fun price(groupedAllocation: NewSubscriptionGroupedAllocationPrice) = - price(Price.ofGroupedAllocation(groupedAllocation)) - - /** Alias for calling [price] with `Price.ofBulkWithProration(bulkWithProration)`. */ - fun price(bulkWithProration: NewSubscriptionBulkWithProrationPrice) = - price(Price.ofBulkWithProration(bulkWithProration)) - - /** - * Alias for calling [price] with - * `Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)`. - */ - fun price(groupedWithProratedMinimum: NewSubscriptionGroupedWithProratedMinimumPrice) = - price(Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)) - - /** - * Alias for calling [price] with - * `Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)`. - */ - fun price(groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice) = - price(Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)) + /** + * Returns the raw JSON value of [adjustmentId]. + * + * Unlike [adjustmentId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("adjustment_id") + @ExcludeMissing + fun _adjustmentId(): JsonField = adjustmentId - /** - * Alias for calling [price] with - * `Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)`. - */ - fun price(groupedWithMinMaxThresholds: Price.GroupedWithMinMaxThresholds) = - price(Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)) + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - /** - * Alias for calling [price] with - * `Price.ofMatrixWithDisplayName(matrixWithDisplayName)`. - */ - fun price(matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice) = - price(Price.ofMatrixWithDisplayName(matrixWithDisplayName)) + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - /** - * Alias for calling [price] with `Price.ofGroupedTieredPackage(groupedTieredPackage)`. - */ - fun price(groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice) = - price(Price.ofGroupedTieredPackage(groupedTieredPackage)) + fun toBuilder() = Builder().from(this) - /** - * Alias for calling [price] with - * `Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)`. - */ - fun price(maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice) = - price(Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)) + companion object { /** - * Alias for calling [price] with - * `Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)`. + * Returns a mutable builder for constructing an instance of [RemoveAdjustment]. + * + * The following fields are required: + * ```kotlin + * .adjustmentId() + * ``` */ - fun price( - scalableMatrixWithUnitPricing: NewSubscriptionScalableMatrixWithUnitPricingPrice - ) = price(Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)) + fun builder() = Builder() + } - /** - * Alias for calling [price] with - * `Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)`. - */ - fun price( - scalableMatrixWithTieredPricing: NewSubscriptionScalableMatrixWithTieredPricingPrice - ) = price(Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)) + /** A builder for [RemoveAdjustment]. */ + class Builder internal constructor() { - /** - * Alias for calling [price] with - * `Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)`. - */ - fun price(cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice) = - price(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) + private var adjustmentId: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() - /** Alias for calling [price] with `Price.ofMinimum(minimum)`. */ - fun price(minimum: NewSubscriptionMinimumCompositePrice) = - price(Price.ofMinimum(minimum)) + internal fun from(removeAdjustment: RemoveAdjustment) = apply { + adjustmentId = removeAdjustment.adjustmentId + additionalProperties = removeAdjustment.additionalProperties.toMutableMap() + } - /** The id of the price to add to the subscription. */ - fun priceId(priceId: String?) = priceId(JsonField.ofNullable(priceId)) + /** The id of the adjustment to remove on the subscription. */ + fun adjustmentId(adjustmentId: String) = adjustmentId(JsonField.of(adjustmentId)) /** - * Sets [Builder.priceId] to an arbitrary JSON value. + * Sets [Builder.adjustmentId] to an arbitrary JSON value. * - * You should usually call [Builder.priceId] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet + * You should usually call [Builder.adjustmentId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun priceId(priceId: JsonField) = apply { this.priceId = priceId } + fun adjustmentId(adjustmentId: JsonField) = apply { + this.adjustmentId = adjustmentId + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -11249,48 +11437,32 @@ private constructor( } /** - * Returns an immutable instance of [ReplacePrice]. + * Returns an immutable instance of [RemoveAdjustment]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```kotlin - * .replacesPriceId() + * .adjustmentId() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): ReplacePrice = - ReplacePrice( - checkRequired("replacesPriceId", replacesPriceId), - allocationPrice, - (discounts ?: JsonMissing.of()).map { it.toImmutable() }, - externalPriceId, - fixedPriceQuantity, - maximumAmount, - minimumAmount, - price, - priceId, + fun build(): RemoveAdjustment = + RemoveAdjustment( + checkRequired("adjustmentId", adjustmentId), additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): ReplacePrice = apply { + fun validate(): RemoveAdjustment = apply { if (validated) { return@apply } - replacesPriceId() - allocationPrice()?.validate() - discounts()?.forEach { it.validate() } - externalPriceId() - fixedPriceQuantity() - maximumAmount() - minimumAmount() - price()?.validate() - priceId() + adjustmentId() validated = true } @@ -11308,470 +11480,581 @@ private constructor( * * Used for best match union deserialization. */ - internal fun validity(): Int = - (if (replacesPriceId.asKnown() == null) 0 else 1) + - (allocationPrice.asKnown()?.validity() ?: 0) + - (discounts.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + - (if (externalPriceId.asKnown() == null) 0 else 1) + - (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + - (if (maximumAmount.asKnown() == null) 0 else 1) + - (if (minimumAmount.asKnown() == null) 0 else 1) + - (price.asKnown()?.validity() ?: 0) + - (if (priceId.asKnown() == null) 0 else 1) - - /** New subscription price request body params. */ - @JsonDeserialize(using = Price.Deserializer::class) - @JsonSerialize(using = Price.Serializer::class) - class Price - private constructor( - private val unit: NewSubscriptionUnitPrice? = null, - private val tiered: NewSubscriptionTieredPrice? = null, - private val bulk: NewSubscriptionBulkPrice? = null, - private val package_: NewSubscriptionPackagePrice? = null, - private val matrix: NewSubscriptionMatrixPrice? = null, - private val thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice? = null, - private val tieredPackage: NewSubscriptionTieredPackagePrice? = null, - private val tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice? = null, - private val groupedTiered: NewSubscriptionGroupedTieredPrice? = null, - private val tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice? = - null, - private val packageWithAllocation: NewSubscriptionPackageWithAllocationPrice? = null, - private val unitWithPercent: NewSubscriptionUnitWithPercentPrice? = null, - private val matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice? = null, - private val tieredWithProration: TieredWithProration? = null, - private val unitWithProration: NewSubscriptionUnitWithProrationPrice? = null, - private val groupedAllocation: NewSubscriptionGroupedAllocationPrice? = null, - private val bulkWithProration: NewSubscriptionBulkWithProrationPrice? = null, - private val groupedWithProratedMinimum: - NewSubscriptionGroupedWithProratedMinimumPrice? = - null, - private val groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice? = - null, - private val groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds? = null, - private val matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice? = null, - private val groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice? = null, - private val maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice? = null, - private val scalableMatrixWithUnitPricing: - NewSubscriptionScalableMatrixWithUnitPricingPrice? = - null, - private val scalableMatrixWithTieredPricing: - NewSubscriptionScalableMatrixWithTieredPricingPrice? = - null, - private val cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice? = null, - private val minimum: NewSubscriptionMinimumCompositePrice? = null, - private val _json: JsonValue? = null, - ) { + internal fun validity(): Int = (if (adjustmentId.asKnown() == null) 0 else 1) - fun unit(): NewSubscriptionUnitPrice? = unit + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun tiered(): NewSubscriptionTieredPrice? = tiered - - fun bulk(): NewSubscriptionBulkPrice? = bulk - - fun package_(): NewSubscriptionPackagePrice? = package_ - - fun matrix(): NewSubscriptionMatrixPrice? = matrix - - fun thresholdTotalAmount(): NewSubscriptionThresholdTotalAmountPrice? = - thresholdTotalAmount + return other is RemoveAdjustment && + adjustmentId == other.adjustmentId && + additionalProperties == other.additionalProperties + } - fun tieredPackage(): NewSubscriptionTieredPackagePrice? = tieredPackage + private val hashCode: Int by lazy { Objects.hash(adjustmentId, additionalProperties) } - fun tieredWithMinimum(): NewSubscriptionTieredWithMinimumPrice? = tieredWithMinimum + override fun hashCode(): Int = hashCode - fun groupedTiered(): NewSubscriptionGroupedTieredPrice? = groupedTiered + override fun toString() = + "RemoveAdjustment{adjustmentId=$adjustmentId, additionalProperties=$additionalProperties}" + } - fun tieredPackageWithMinimum(): NewSubscriptionTieredPackageWithMinimumPrice? = - tieredPackageWithMinimum + class RemovePrice + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val externalPriceId: JsonField, + private val priceId: JsonField, + private val additionalProperties: MutableMap, + ) { - fun packageWithAllocation(): NewSubscriptionPackageWithAllocationPrice? = - packageWithAllocation + @JsonCreator + private constructor( + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("price_id") @ExcludeMissing priceId: JsonField = JsonMissing.of(), + ) : this(externalPriceId, priceId, mutableMapOf()) - fun unitWithPercent(): NewSubscriptionUnitWithPercentPrice? = unitWithPercent + /** + * The external price id of the price to remove on the subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") - fun matrixWithAllocation(): NewSubscriptionMatrixWithAllocationPrice? = - matrixWithAllocation + /** + * The id of the price to remove on the subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun priceId(): String? = priceId.getNullable("price_id") - fun tieredWithProration(): TieredWithProration? = tieredWithProration + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId - fun unitWithProration(): NewSubscriptionUnitWithProrationPrice? = unitWithProration + /** + * Returns the raw JSON value of [priceId]. + * + * Unlike [priceId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId - fun groupedAllocation(): NewSubscriptionGroupedAllocationPrice? = groupedAllocation + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - fun bulkWithProration(): NewSubscriptionBulkWithProrationPrice? = bulkWithProration + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - fun groupedWithProratedMinimum(): NewSubscriptionGroupedWithProratedMinimumPrice? = - groupedWithProratedMinimum + fun toBuilder() = Builder().from(this) - fun groupedWithMeteredMinimum(): NewSubscriptionGroupedWithMeteredMinimumPrice? = - groupedWithMeteredMinimum + companion object { - fun groupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds? = - groupedWithMinMaxThresholds + /** Returns a mutable builder for constructing an instance of [RemovePrice]. */ + fun builder() = Builder() + } - fun matrixWithDisplayName(): NewSubscriptionMatrixWithDisplayNamePrice? = - matrixWithDisplayName + /** A builder for [RemovePrice]. */ + class Builder internal constructor() { - fun groupedTieredPackage(): NewSubscriptionGroupedTieredPackagePrice? = - groupedTieredPackage + private var externalPriceId: JsonField = JsonMissing.of() + private var priceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - fun maxGroupTieredPackage(): NewSubscriptionMaxGroupTieredPackagePrice? = - maxGroupTieredPackage + internal fun from(removePrice: RemovePrice) = apply { + externalPriceId = removePrice.externalPriceId + priceId = removePrice.priceId + additionalProperties = removePrice.additionalProperties.toMutableMap() + } - fun scalableMatrixWithUnitPricing(): - NewSubscriptionScalableMatrixWithUnitPricingPrice? = scalableMatrixWithUnitPricing + /** The external price id of the price to remove on the subscription. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) - fun scalableMatrixWithTieredPricing(): - NewSubscriptionScalableMatrixWithTieredPricingPrice? = - scalableMatrixWithTieredPricing + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } - fun cumulativeGroupedBulk(): NewSubscriptionCumulativeGroupedBulkPrice? = - cumulativeGroupedBulk + /** The id of the price to remove on the subscription. */ + fun priceId(priceId: String?) = priceId(JsonField.ofNullable(priceId)) - fun minimum(): NewSubscriptionMinimumCompositePrice? = minimum + /** + * Sets [Builder.priceId] to an arbitrary JSON value. + * + * You should usually call [Builder.priceId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun priceId(priceId: JsonField) = apply { this.priceId = priceId } - fun isUnit(): Boolean = unit != null + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun isTiered(): Boolean = tiered != null + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun isBulk(): Boolean = bulk != null + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun isPackage(): Boolean = package_ != null + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - fun isMatrix(): Boolean = matrix != null + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - fun isThresholdTotalAmount(): Boolean = thresholdTotalAmount != null + /** + * Returns an immutable instance of [RemovePrice]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): RemovePrice = + RemovePrice(externalPriceId, priceId, additionalProperties.toMutableMap()) + } - fun isTieredPackage(): Boolean = tieredPackage != null + private var validated: Boolean = false - fun isTieredWithMinimum(): Boolean = tieredWithMinimum != null + fun validate(): RemovePrice = apply { + if (validated) { + return@apply + } - fun isGroupedTiered(): Boolean = groupedTiered != null + externalPriceId() + priceId() + validated = true + } - fun isTieredPackageWithMinimum(): Boolean = tieredPackageWithMinimum != null + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - fun isPackageWithAllocation(): Boolean = packageWithAllocation != null + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (priceId.asKnown() == null) 0 else 1) - fun isUnitWithPercent(): Boolean = unitWithPercent != null + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun isMatrixWithAllocation(): Boolean = matrixWithAllocation != null + return other is RemovePrice && + externalPriceId == other.externalPriceId && + priceId == other.priceId && + additionalProperties == other.additionalProperties + } - fun isTieredWithProration(): Boolean = tieredWithProration != null + private val hashCode: Int by lazy { + Objects.hash(externalPriceId, priceId, additionalProperties) + } - fun isUnitWithProration(): Boolean = unitWithProration != null + override fun hashCode(): Int = hashCode - fun isGroupedAllocation(): Boolean = groupedAllocation != null + override fun toString() = + "RemovePrice{externalPriceId=$externalPriceId, priceId=$priceId, additionalProperties=$additionalProperties}" + } - fun isBulkWithProration(): Boolean = bulkWithProration != null + class ReplaceAdjustment + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val adjustment: JsonField, + private val replacesAdjustmentId: JsonField, + private val additionalProperties: MutableMap, + ) { - fun isGroupedWithProratedMinimum(): Boolean = groupedWithProratedMinimum != null + @JsonCreator + private constructor( + @JsonProperty("adjustment") + @ExcludeMissing + adjustment: JsonField = JsonMissing.of(), + @JsonProperty("replaces_adjustment_id") + @ExcludeMissing + replacesAdjustmentId: JsonField = JsonMissing.of(), + ) : this(adjustment, replacesAdjustmentId, mutableMapOf()) - fun isGroupedWithMeteredMinimum(): Boolean = groupedWithMeteredMinimum != null + /** + * The definition of a new adjustment to create and add to the subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun adjustment(): Adjustment = adjustment.getRequired("adjustment") - fun isGroupedWithMinMaxThresholds(): Boolean = groupedWithMinMaxThresholds != null + /** + * The id of the adjustment on the plan to replace in the subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun replacesAdjustmentId(): String = + replacesAdjustmentId.getRequired("replaces_adjustment_id") - fun isMatrixWithDisplayName(): Boolean = matrixWithDisplayName != null - - fun isGroupedTieredPackage(): Boolean = groupedTieredPackage != null + /** + * Returns the raw JSON value of [adjustment]. + * + * Unlike [adjustment], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("adjustment") + @ExcludeMissing + fun _adjustment(): JsonField = adjustment - fun isMaxGroupTieredPackage(): Boolean = maxGroupTieredPackage != null + /** + * Returns the raw JSON value of [replacesAdjustmentId]. + * + * Unlike [replacesAdjustmentId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("replaces_adjustment_id") + @ExcludeMissing + fun _replacesAdjustmentId(): JsonField = replacesAdjustmentId - fun isScalableMatrixWithUnitPricing(): Boolean = scalableMatrixWithUnitPricing != null + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - fun isScalableMatrixWithTieredPricing(): Boolean = - scalableMatrixWithTieredPricing != null + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - fun isCumulativeGroupedBulk(): Boolean = cumulativeGroupedBulk != null + fun toBuilder() = Builder().from(this) - fun isMinimum(): Boolean = minimum != null + companion object { - fun asUnit(): NewSubscriptionUnitPrice = unit.getOrThrow("unit") + /** + * Returns a mutable builder for constructing an instance of [ReplaceAdjustment]. + * + * The following fields are required: + * ```kotlin + * .adjustment() + * .replacesAdjustmentId() + * ``` + */ + fun builder() = Builder() + } - fun asTiered(): NewSubscriptionTieredPrice = tiered.getOrThrow("tiered") + /** A builder for [ReplaceAdjustment]. */ + class Builder internal constructor() { - fun asBulk(): NewSubscriptionBulkPrice = bulk.getOrThrow("bulk") + private var adjustment: JsonField? = null + private var replacesAdjustmentId: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() - fun asPackage(): NewSubscriptionPackagePrice = package_.getOrThrow("package_") + internal fun from(replaceAdjustment: ReplaceAdjustment) = apply { + adjustment = replaceAdjustment.adjustment + replacesAdjustmentId = replaceAdjustment.replacesAdjustmentId + additionalProperties = replaceAdjustment.additionalProperties.toMutableMap() + } - fun asMatrix(): NewSubscriptionMatrixPrice = matrix.getOrThrow("matrix") + /** The definition of a new adjustment to create and add to the subscription. */ + fun adjustment(adjustment: Adjustment) = adjustment(JsonField.of(adjustment)) - fun asThresholdTotalAmount(): NewSubscriptionThresholdTotalAmountPrice = - thresholdTotalAmount.getOrThrow("thresholdTotalAmount") + /** + * Sets [Builder.adjustment] to an arbitrary JSON value. + * + * You should usually call [Builder.adjustment] with a well-typed [Adjustment] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun adjustment(adjustment: JsonField) = apply { + this.adjustment = adjustment + } - fun asTieredPackage(): NewSubscriptionTieredPackagePrice = - tieredPackage.getOrThrow("tieredPackage") + /** + * Alias for calling [adjustment] with + * `Adjustment.ofPercentageDiscount(percentageDiscount)`. + */ + fun adjustment(percentageDiscount: NewPercentageDiscount) = + adjustment(Adjustment.ofPercentageDiscount(percentageDiscount)) - fun asTieredWithMinimum(): NewSubscriptionTieredWithMinimumPrice = - tieredWithMinimum.getOrThrow("tieredWithMinimum") + /** + * Alias for calling [adjustment] with the following: + * ```kotlin + * NewPercentageDiscount.builder() + * .adjustmentType(NewPercentageDiscount.AdjustmentType.PERCENTAGE_DISCOUNT) + * .percentageDiscount(percentageDiscount) + * .build() + * ``` + */ + fun percentageDiscountAdjustment(percentageDiscount: Double) = + adjustment( + NewPercentageDiscount.builder() + .adjustmentType(NewPercentageDiscount.AdjustmentType.PERCENTAGE_DISCOUNT) + .percentageDiscount(percentageDiscount) + .build() + ) - fun asGroupedTiered(): NewSubscriptionGroupedTieredPrice = - groupedTiered.getOrThrow("groupedTiered") + /** Alias for calling [adjustment] with `Adjustment.ofUsageDiscount(usageDiscount)`. */ + fun adjustment(usageDiscount: NewUsageDiscount) = + adjustment(Adjustment.ofUsageDiscount(usageDiscount)) - fun asTieredPackageWithMinimum(): NewSubscriptionTieredPackageWithMinimumPrice = - tieredPackageWithMinimum.getOrThrow("tieredPackageWithMinimum") + /** + * Alias for calling [adjustment] with the following: + * ```kotlin + * NewUsageDiscount.builder() + * .adjustmentType(NewUsageDiscount.AdjustmentType.USAGE_DISCOUNT) + * .usageDiscount(usageDiscount) + * .build() + * ``` + */ + fun usageDiscountAdjustment(usageDiscount: Double) = + adjustment( + NewUsageDiscount.builder() + .adjustmentType(NewUsageDiscount.AdjustmentType.USAGE_DISCOUNT) + .usageDiscount(usageDiscount) + .build() + ) - fun asPackageWithAllocation(): NewSubscriptionPackageWithAllocationPrice = - packageWithAllocation.getOrThrow("packageWithAllocation") + /** + * Alias for calling [adjustment] with `Adjustment.ofAmountDiscount(amountDiscount)`. + */ + fun adjustment(amountDiscount: NewAmountDiscount) = + adjustment(Adjustment.ofAmountDiscount(amountDiscount)) - fun asUnitWithPercent(): NewSubscriptionUnitWithPercentPrice = - unitWithPercent.getOrThrow("unitWithPercent") + /** + * Alias for calling [adjustment] with the following: + * ```kotlin + * NewAmountDiscount.builder() + * .adjustmentType(NewAmountDiscount.AdjustmentType.AMOUNT_DISCOUNT) + * .amountDiscount(amountDiscount) + * .build() + * ``` + */ + fun amountDiscountAdjustment(amountDiscount: String) = + adjustment( + NewAmountDiscount.builder() + .adjustmentType(NewAmountDiscount.AdjustmentType.AMOUNT_DISCOUNT) + .amountDiscount(amountDiscount) + .build() + ) - fun asMatrixWithAllocation(): NewSubscriptionMatrixWithAllocationPrice = - matrixWithAllocation.getOrThrow("matrixWithAllocation") + /** Alias for calling [adjustment] with `Adjustment.ofMinimum(minimum)`. */ + fun adjustment(minimum: NewMinimum) = adjustment(Adjustment.ofMinimum(minimum)) - fun asTieredWithProration(): TieredWithProration = - tieredWithProration.getOrThrow("tieredWithProration") + /** Alias for calling [adjustment] with `Adjustment.ofMaximum(maximum)`. */ + fun adjustment(maximum: NewMaximum) = adjustment(Adjustment.ofMaximum(maximum)) - fun asUnitWithProration(): NewSubscriptionUnitWithProrationPrice = - unitWithProration.getOrThrow("unitWithProration") + /** + * Alias for calling [adjustment] with the following: + * ```kotlin + * NewMaximum.builder() + * .adjustmentType(NewMaximum.AdjustmentType.MAXIMUM) + * .maximumAmount(maximumAmount) + * .build() + * ``` + */ + fun maximumAdjustment(maximumAmount: String) = + adjustment( + NewMaximum.builder() + .adjustmentType(NewMaximum.AdjustmentType.MAXIMUM) + .maximumAmount(maximumAmount) + .build() + ) - fun asGroupedAllocation(): NewSubscriptionGroupedAllocationPrice = - groupedAllocation.getOrThrow("groupedAllocation") + /** The id of the adjustment on the plan to replace in the subscription. */ + fun replacesAdjustmentId(replacesAdjustmentId: String) = + replacesAdjustmentId(JsonField.of(replacesAdjustmentId)) - fun asBulkWithProration(): NewSubscriptionBulkWithProrationPrice = - bulkWithProration.getOrThrow("bulkWithProration") + /** + * Sets [Builder.replacesAdjustmentId] to an arbitrary JSON value. + * + * You should usually call [Builder.replacesAdjustmentId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun replacesAdjustmentId(replacesAdjustmentId: JsonField) = apply { + this.replacesAdjustmentId = replacesAdjustmentId + } - fun asGroupedWithProratedMinimum(): NewSubscriptionGroupedWithProratedMinimumPrice = - groupedWithProratedMinimum.getOrThrow("groupedWithProratedMinimum") + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun asGroupedWithMeteredMinimum(): NewSubscriptionGroupedWithMeteredMinimumPrice = - groupedWithMeteredMinimum.getOrThrow("groupedWithMeteredMinimum") + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun asGroupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds = - groupedWithMinMaxThresholds.getOrThrow("groupedWithMinMaxThresholds") + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun asMatrixWithDisplayName(): NewSubscriptionMatrixWithDisplayNamePrice = - matrixWithDisplayName.getOrThrow("matrixWithDisplayName") + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - fun asGroupedTieredPackage(): NewSubscriptionGroupedTieredPackagePrice = - groupedTieredPackage.getOrThrow("groupedTieredPackage") + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - fun asMaxGroupTieredPackage(): NewSubscriptionMaxGroupTieredPackagePrice = - maxGroupTieredPackage.getOrThrow("maxGroupTieredPackage") + /** + * Returns an immutable instance of [ReplaceAdjustment]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .adjustment() + * .replacesAdjustmentId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ReplaceAdjustment = + ReplaceAdjustment( + checkRequired("adjustment", adjustment), + checkRequired("replacesAdjustmentId", replacesAdjustmentId), + additionalProperties.toMutableMap(), + ) + } - fun asScalableMatrixWithUnitPricing(): - NewSubscriptionScalableMatrixWithUnitPricingPrice = - scalableMatrixWithUnitPricing.getOrThrow("scalableMatrixWithUnitPricing") + private var validated: Boolean = false - fun asScalableMatrixWithTieredPricing(): - NewSubscriptionScalableMatrixWithTieredPricingPrice = - scalableMatrixWithTieredPricing.getOrThrow("scalableMatrixWithTieredPricing") + fun validate(): ReplaceAdjustment = apply { + if (validated) { + return@apply + } - fun asCumulativeGroupedBulk(): NewSubscriptionCumulativeGroupedBulkPrice = - cumulativeGroupedBulk.getOrThrow("cumulativeGroupedBulk") + adjustment().validate() + replacesAdjustmentId() + validated = true + } - fun asMinimum(): NewSubscriptionMinimumCompositePrice = minimum.getOrThrow("minimum") - - fun _json(): JsonValue? = _json - - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - bulk != null -> visitor.visitBulk(bulk) - package_ != null -> visitor.visitPackage(package_) - matrix != null -> visitor.visitMatrix(matrix) - thresholdTotalAmount != null -> - visitor.visitThresholdTotalAmount(thresholdTotalAmount) - tieredPackage != null -> visitor.visitTieredPackage(tieredPackage) - tieredWithMinimum != null -> visitor.visitTieredWithMinimum(tieredWithMinimum) - groupedTiered != null -> visitor.visitGroupedTiered(groupedTiered) - tieredPackageWithMinimum != null -> - visitor.visitTieredPackageWithMinimum(tieredPackageWithMinimum) - packageWithAllocation != null -> - visitor.visitPackageWithAllocation(packageWithAllocation) - unitWithPercent != null -> visitor.visitUnitWithPercent(unitWithPercent) - matrixWithAllocation != null -> - visitor.visitMatrixWithAllocation(matrixWithAllocation) - tieredWithProration != null -> - visitor.visitTieredWithProration(tieredWithProration) - unitWithProration != null -> visitor.visitUnitWithProration(unitWithProration) - groupedAllocation != null -> visitor.visitGroupedAllocation(groupedAllocation) - bulkWithProration != null -> visitor.visitBulkWithProration(bulkWithProration) - groupedWithProratedMinimum != null -> - visitor.visitGroupedWithProratedMinimum(groupedWithProratedMinimum) - groupedWithMeteredMinimum != null -> - visitor.visitGroupedWithMeteredMinimum(groupedWithMeteredMinimum) - groupedWithMinMaxThresholds != null -> - visitor.visitGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds) - matrixWithDisplayName != null -> - visitor.visitMatrixWithDisplayName(matrixWithDisplayName) - groupedTieredPackage != null -> - visitor.visitGroupedTieredPackage(groupedTieredPackage) - maxGroupTieredPackage != null -> - visitor.visitMaxGroupTieredPackage(maxGroupTieredPackage) - scalableMatrixWithUnitPricing != null -> - visitor.visitScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing) - scalableMatrixWithTieredPricing != null -> - visitor.visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing - ) - cumulativeGroupedBulk != null -> - visitor.visitCumulativeGroupedBulk(cumulativeGroupedBulk) - minimum != null -> visitor.visitMinimum(minimum) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): Price = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitUnit(unit: NewSubscriptionUnitPrice) { - unit.validate() - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - override fun visitTiered(tiered: NewSubscriptionTieredPrice) { - tiered.validate() - } + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (adjustment.asKnown()?.validity() ?: 0) + + (if (replacesAdjustmentId.asKnown() == null) 0 else 1) - override fun visitBulk(bulk: NewSubscriptionBulkPrice) { - bulk.validate() - } + /** The definition of a new adjustment to create and add to the subscription. */ + @JsonDeserialize(using = Adjustment.Deserializer::class) + @JsonSerialize(using = Adjustment.Serializer::class) + class Adjustment + private constructor( + private val percentageDiscount: NewPercentageDiscount? = null, + private val usageDiscount: NewUsageDiscount? = null, + private val amountDiscount: NewAmountDiscount? = null, + private val minimum: NewMinimum? = null, + private val maximum: NewMaximum? = null, + private val _json: JsonValue? = null, + ) { - override fun visitPackage(package_: NewSubscriptionPackagePrice) { - package_.validate() - } + fun percentageDiscount(): NewPercentageDiscount? = percentageDiscount - override fun visitMatrix(matrix: NewSubscriptionMatrixPrice) { - matrix.validate() - } + fun usageDiscount(): NewUsageDiscount? = usageDiscount - override fun visitThresholdTotalAmount( - thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice - ) { - thresholdTotalAmount.validate() - } + fun amountDiscount(): NewAmountDiscount? = amountDiscount - override fun visitTieredPackage( - tieredPackage: NewSubscriptionTieredPackagePrice - ) { - tieredPackage.validate() - } + fun minimum(): NewMinimum? = minimum - override fun visitTieredWithMinimum( - tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice - ) { - tieredWithMinimum.validate() - } + fun maximum(): NewMaximum? = maximum - override fun visitGroupedTiered( - groupedTiered: NewSubscriptionGroupedTieredPrice - ) { - groupedTiered.validate() - } + fun isPercentageDiscount(): Boolean = percentageDiscount != null - override fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice - ) { - tieredPackageWithMinimum.validate() - } + fun isUsageDiscount(): Boolean = usageDiscount != null - override fun visitPackageWithAllocation( - packageWithAllocation: NewSubscriptionPackageWithAllocationPrice - ) { - packageWithAllocation.validate() - } + fun isAmountDiscount(): Boolean = amountDiscount != null - override fun visitUnitWithPercent( - unitWithPercent: NewSubscriptionUnitWithPercentPrice - ) { - unitWithPercent.validate() - } + fun isMinimum(): Boolean = minimum != null - override fun visitMatrixWithAllocation( - matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice - ) { - matrixWithAllocation.validate() - } + fun isMaximum(): Boolean = maximum != null - override fun visitTieredWithProration( - tieredWithProration: TieredWithProration - ) { - tieredWithProration.validate() - } + fun asPercentageDiscount(): NewPercentageDiscount = + percentageDiscount.getOrThrow("percentageDiscount") - override fun visitUnitWithProration( - unitWithProration: NewSubscriptionUnitWithProrationPrice - ) { - unitWithProration.validate() - } + fun asUsageDiscount(): NewUsageDiscount = usageDiscount.getOrThrow("usageDiscount") - override fun visitGroupedAllocation( - groupedAllocation: NewSubscriptionGroupedAllocationPrice - ) { - groupedAllocation.validate() - } + fun asAmountDiscount(): NewAmountDiscount = amountDiscount.getOrThrow("amountDiscount") - override fun visitBulkWithProration( - bulkWithProration: NewSubscriptionBulkWithProrationPrice - ) { - bulkWithProration.validate() - } + fun asMinimum(): NewMinimum = minimum.getOrThrow("minimum") - override fun visitGroupedWithProratedMinimum( - groupedWithProratedMinimum: - NewSubscriptionGroupedWithProratedMinimumPrice - ) { - groupedWithProratedMinimum.validate() - } + fun asMaximum(): NewMaximum = maximum.getOrThrow("maximum") - override fun visitGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice - ) { - groupedWithMeteredMinimum.validate() - } + fun _json(): JsonValue? = _json - override fun visitGroupedWithMinMaxThresholds( - groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds - ) { - groupedWithMinMaxThresholds.validate() - } + fun accept(visitor: Visitor): T = + when { + percentageDiscount != null -> + visitor.visitPercentageDiscount(percentageDiscount) + usageDiscount != null -> visitor.visitUsageDiscount(usageDiscount) + amountDiscount != null -> visitor.visitAmountDiscount(amountDiscount) + minimum != null -> visitor.visitMinimum(minimum) + maximum != null -> visitor.visitMaximum(maximum) + else -> visitor.unknown(_json) + } - override fun visitMatrixWithDisplayName( - matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice - ) { - matrixWithDisplayName.validate() - } + private var validated: Boolean = false - override fun visitGroupedTieredPackage( - groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice - ) { - groupedTieredPackage.validate() - } + fun validate(): Adjustment = apply { + if (validated) { + return@apply + } - override fun visitMaxGroupTieredPackage( - maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice + accept( + object : Visitor { + override fun visitPercentageDiscount( + percentageDiscount: NewPercentageDiscount ) { - maxGroupTieredPackage.validate() + percentageDiscount.validate() } - override fun visitScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: - NewSubscriptionScalableMatrixWithUnitPricingPrice - ) { - scalableMatrixWithUnitPricing.validate() + override fun visitUsageDiscount(usageDiscount: NewUsageDiscount) { + usageDiscount.validate() } - override fun visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: - NewSubscriptionScalableMatrixWithTieredPricingPrice - ) { - scalableMatrixWithTieredPricing.validate() + override fun visitAmountDiscount(amountDiscount: NewAmountDiscount) { + amountDiscount.validate() } - override fun visitCumulativeGroupedBulk( - cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice - ) { - cumulativeGroupedBulk.validate() + override fun visitMinimum(minimum: NewMinimum) { + minimum.validate() } - override fun visitMinimum(minimum: NewSubscriptionMinimumCompositePrice) { - minimum.validate() + override fun visitMaximum(maximum: NewMaximum) { + maximum.validate() } } ) @@ -11795,108 +12078,19 @@ private constructor( internal fun validity(): Int = accept( object : Visitor { - override fun visitUnit(unit: NewSubscriptionUnitPrice) = unit.validity() - - override fun visitTiered(tiered: NewSubscriptionTieredPrice) = - tiered.validity() - - override fun visitBulk(bulk: NewSubscriptionBulkPrice) = bulk.validity() - - override fun visitPackage(package_: NewSubscriptionPackagePrice) = - package_.validity() - - override fun visitMatrix(matrix: NewSubscriptionMatrixPrice) = - matrix.validity() - - override fun visitThresholdTotalAmount( - thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice - ) = thresholdTotalAmount.validity() - - override fun visitTieredPackage( - tieredPackage: NewSubscriptionTieredPackagePrice - ) = tieredPackage.validity() - - override fun visitTieredWithMinimum( - tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice - ) = tieredWithMinimum.validity() - - override fun visitGroupedTiered( - groupedTiered: NewSubscriptionGroupedTieredPrice - ) = groupedTiered.validity() - - override fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice - ) = tieredPackageWithMinimum.validity() - - override fun visitPackageWithAllocation( - packageWithAllocation: NewSubscriptionPackageWithAllocationPrice - ) = packageWithAllocation.validity() - - override fun visitUnitWithPercent( - unitWithPercent: NewSubscriptionUnitWithPercentPrice - ) = unitWithPercent.validity() - - override fun visitMatrixWithAllocation( - matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice - ) = matrixWithAllocation.validity() - - override fun visitTieredWithProration( - tieredWithProration: TieredWithProration - ) = tieredWithProration.validity() - - override fun visitUnitWithProration( - unitWithProration: NewSubscriptionUnitWithProrationPrice - ) = unitWithProration.validity() - - override fun visitGroupedAllocation( - groupedAllocation: NewSubscriptionGroupedAllocationPrice - ) = groupedAllocation.validity() - - override fun visitBulkWithProration( - bulkWithProration: NewSubscriptionBulkWithProrationPrice - ) = bulkWithProration.validity() - - override fun visitGroupedWithProratedMinimum( - groupedWithProratedMinimum: - NewSubscriptionGroupedWithProratedMinimumPrice - ) = groupedWithProratedMinimum.validity() - - override fun visitGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice - ) = groupedWithMeteredMinimum.validity() - - override fun visitGroupedWithMinMaxThresholds( - groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds - ) = groupedWithMinMaxThresholds.validity() - - override fun visitMatrixWithDisplayName( - matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice - ) = matrixWithDisplayName.validity() - - override fun visitGroupedTieredPackage( - groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice - ) = groupedTieredPackage.validity() - - override fun visitMaxGroupTieredPackage( - maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice - ) = maxGroupTieredPackage.validity() + override fun visitPercentageDiscount( + percentageDiscount: NewPercentageDiscount + ) = percentageDiscount.validity() - override fun visitScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: - NewSubscriptionScalableMatrixWithUnitPricingPrice - ) = scalableMatrixWithUnitPricing.validity() + override fun visitUsageDiscount(usageDiscount: NewUsageDiscount) = + usageDiscount.validity() - override fun visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: - NewSubscriptionScalableMatrixWithTieredPricingPrice - ) = scalableMatrixWithTieredPricing.validity() + override fun visitAmountDiscount(amountDiscount: NewAmountDiscount) = + amountDiscount.validity() - override fun visitCumulativeGroupedBulk( - cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice - ) = cumulativeGroupedBulk.validity() + override fun visitMinimum(minimum: NewMinimum) = minimum.validity() - override fun visitMinimum(minimum: NewSubscriptionMinimumCompositePrice) = - minimum.validity() + override fun visitMaximum(maximum: NewMaximum) = maximum.validity() override fun unknown(json: JsonValue?) = 0 } @@ -11907,601 +12101,3807 @@ private constructor( return true } - return other is Price && - unit == other.unit && - tiered == other.tiered && - bulk == other.bulk && - package_ == other.package_ && - matrix == other.matrix && - thresholdTotalAmount == other.thresholdTotalAmount && - tieredPackage == other.tieredPackage && - tieredWithMinimum == other.tieredWithMinimum && - groupedTiered == other.groupedTiered && - tieredPackageWithMinimum == other.tieredPackageWithMinimum && - packageWithAllocation == other.packageWithAllocation && - unitWithPercent == other.unitWithPercent && - matrixWithAllocation == other.matrixWithAllocation && - tieredWithProration == other.tieredWithProration && - unitWithProration == other.unitWithProration && - groupedAllocation == other.groupedAllocation && - bulkWithProration == other.bulkWithProration && - groupedWithProratedMinimum == other.groupedWithProratedMinimum && - groupedWithMeteredMinimum == other.groupedWithMeteredMinimum && - groupedWithMinMaxThresholds == other.groupedWithMinMaxThresholds && - matrixWithDisplayName == other.matrixWithDisplayName && - groupedTieredPackage == other.groupedTieredPackage && - maxGroupTieredPackage == other.maxGroupTieredPackage && - scalableMatrixWithUnitPricing == other.scalableMatrixWithUnitPricing && - scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && - cumulativeGroupedBulk == other.cumulativeGroupedBulk && - minimum == other.minimum + return other is Adjustment && + percentageDiscount == other.percentageDiscount && + usageDiscount == other.usageDiscount && + amountDiscount == other.amountDiscount && + minimum == other.minimum && + maximum == other.maximum } override fun hashCode(): Int = - Objects.hash( - unit, - tiered, - bulk, - package_, - matrix, - thresholdTotalAmount, - tieredPackage, - tieredWithMinimum, - groupedTiered, - tieredPackageWithMinimum, - packageWithAllocation, - unitWithPercent, - matrixWithAllocation, - tieredWithProration, - unitWithProration, - groupedAllocation, - bulkWithProration, - groupedWithProratedMinimum, - groupedWithMeteredMinimum, - groupedWithMinMaxThresholds, - matrixWithDisplayName, - groupedTieredPackage, - maxGroupTieredPackage, - scalableMatrixWithUnitPricing, - scalableMatrixWithTieredPricing, - cumulativeGroupedBulk, - minimum, - ) + Objects.hash(percentageDiscount, usageDiscount, amountDiscount, minimum, maximum) override fun toString(): String = when { - unit != null -> "Price{unit=$unit}" - tiered != null -> "Price{tiered=$tiered}" - bulk != null -> "Price{bulk=$bulk}" - package_ != null -> "Price{package_=$package_}" - matrix != null -> "Price{matrix=$matrix}" - thresholdTotalAmount != null -> - "Price{thresholdTotalAmount=$thresholdTotalAmount}" - tieredPackage != null -> "Price{tieredPackage=$tieredPackage}" - tieredWithMinimum != null -> "Price{tieredWithMinimum=$tieredWithMinimum}" - groupedTiered != null -> "Price{groupedTiered=$groupedTiered}" - tieredPackageWithMinimum != null -> - "Price{tieredPackageWithMinimum=$tieredPackageWithMinimum}" - packageWithAllocation != null -> - "Price{packageWithAllocation=$packageWithAllocation}" - unitWithPercent != null -> "Price{unitWithPercent=$unitWithPercent}" - matrixWithAllocation != null -> - "Price{matrixWithAllocation=$matrixWithAllocation}" - tieredWithProration != null -> "Price{tieredWithProration=$tieredWithProration}" - unitWithProration != null -> "Price{unitWithProration=$unitWithProration}" - groupedAllocation != null -> "Price{groupedAllocation=$groupedAllocation}" - bulkWithProration != null -> "Price{bulkWithProration=$bulkWithProration}" - groupedWithProratedMinimum != null -> - "Price{groupedWithProratedMinimum=$groupedWithProratedMinimum}" - groupedWithMeteredMinimum != null -> - "Price{groupedWithMeteredMinimum=$groupedWithMeteredMinimum}" - groupedWithMinMaxThresholds != null -> - "Price{groupedWithMinMaxThresholds=$groupedWithMinMaxThresholds}" - matrixWithDisplayName != null -> - "Price{matrixWithDisplayName=$matrixWithDisplayName}" - groupedTieredPackage != null -> - "Price{groupedTieredPackage=$groupedTieredPackage}" - maxGroupTieredPackage != null -> - "Price{maxGroupTieredPackage=$maxGroupTieredPackage}" - scalableMatrixWithUnitPricing != null -> - "Price{scalableMatrixWithUnitPricing=$scalableMatrixWithUnitPricing}" - scalableMatrixWithTieredPricing != null -> - "Price{scalableMatrixWithTieredPricing=$scalableMatrixWithTieredPricing}" - cumulativeGroupedBulk != null -> - "Price{cumulativeGroupedBulk=$cumulativeGroupedBulk}" - minimum != null -> "Price{minimum=$minimum}" - _json != null -> "Price{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Price") + percentageDiscount != null -> + "Adjustment{percentageDiscount=$percentageDiscount}" + usageDiscount != null -> "Adjustment{usageDiscount=$usageDiscount}" + amountDiscount != null -> "Adjustment{amountDiscount=$amountDiscount}" + minimum != null -> "Adjustment{minimum=$minimum}" + maximum != null -> "Adjustment{maximum=$maximum}" + _json != null -> "Adjustment{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Adjustment") } companion object { - fun ofUnit(unit: NewSubscriptionUnitPrice) = Price(unit = unit) + fun ofPercentageDiscount(percentageDiscount: NewPercentageDiscount) = + Adjustment(percentageDiscount = percentageDiscount) - fun ofTiered(tiered: NewSubscriptionTieredPrice) = Price(tiered = tiered) + fun ofUsageDiscount(usageDiscount: NewUsageDiscount) = + Adjustment(usageDiscount = usageDiscount) - fun ofBulk(bulk: NewSubscriptionBulkPrice) = Price(bulk = bulk) + fun ofAmountDiscount(amountDiscount: NewAmountDiscount) = + Adjustment(amountDiscount = amountDiscount) - fun ofPackage(package_: NewSubscriptionPackagePrice) = Price(package_ = package_) + fun ofMinimum(minimum: NewMinimum) = Adjustment(minimum = minimum) - fun ofMatrix(matrix: NewSubscriptionMatrixPrice) = Price(matrix = matrix) + fun ofMaximum(maximum: NewMaximum) = Adjustment(maximum = maximum) + } - fun ofThresholdTotalAmount( - thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice - ) = Price(thresholdTotalAmount = thresholdTotalAmount) + /** + * An interface that defines how to map each variant of [Adjustment] to a value of type + * [T]. + */ + interface Visitor { - fun ofTieredPackage(tieredPackage: NewSubscriptionTieredPackagePrice) = - Price(tieredPackage = tieredPackage) + fun visitPercentageDiscount(percentageDiscount: NewPercentageDiscount): T - fun ofTieredWithMinimum(tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice) = - Price(tieredWithMinimum = tieredWithMinimum) + fun visitUsageDiscount(usageDiscount: NewUsageDiscount): T - fun ofGroupedTiered(groupedTiered: NewSubscriptionGroupedTieredPrice) = - Price(groupedTiered = groupedTiered) + fun visitAmountDiscount(amountDiscount: NewAmountDiscount): T - fun ofTieredPackageWithMinimum( - tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice - ) = Price(tieredPackageWithMinimum = tieredPackageWithMinimum) + fun visitMinimum(minimum: NewMinimum): T - fun ofPackageWithAllocation( - packageWithAllocation: NewSubscriptionPackageWithAllocationPrice - ) = Price(packageWithAllocation = packageWithAllocation) - - fun ofUnitWithPercent(unitWithPercent: NewSubscriptionUnitWithPercentPrice) = - Price(unitWithPercent = unitWithPercent) - - fun ofMatrixWithAllocation( - matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice - ) = Price(matrixWithAllocation = matrixWithAllocation) + fun visitMaximum(maximum: NewMaximum): T - fun ofTieredWithProration(tieredWithProration: TieredWithProration) = - Price(tieredWithProration = tieredWithProration) + /** + * Maps an unknown variant of [Adjustment] to a value of type [T]. + * + * An instance of [Adjustment] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the + * SDK is unaware of. + * + * @throws OrbInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw OrbInvalidDataException("Unknown Adjustment: $json") + } + } - fun ofUnitWithProration(unitWithProration: NewSubscriptionUnitWithProrationPrice) = - Price(unitWithProration = unitWithProration) + internal class Deserializer : BaseDeserializer(Adjustment::class) { - fun ofGroupedAllocation(groupedAllocation: NewSubscriptionGroupedAllocationPrice) = - Price(groupedAllocation = groupedAllocation) + override fun ObjectCodec.deserialize(node: JsonNode): Adjustment { + val json = JsonValue.fromJsonNode(node) + val adjustmentType = json.asObject()?.get("adjustment_type")?.asString() - fun ofBulkWithProration(bulkWithProration: NewSubscriptionBulkWithProrationPrice) = - Price(bulkWithProration = bulkWithProration) + when (adjustmentType) { + "percentage_discount" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Adjustment(percentageDiscount = it, _json = json) } + ?: Adjustment(_json = json) + } + "usage_discount" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(usageDiscount = it, _json = json) + } ?: Adjustment(_json = json) + } + "amount_discount" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(amountDiscount = it, _json = json) + } ?: Adjustment(_json = json) + } + "minimum" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(minimum = it, _json = json) + } ?: Adjustment(_json = json) + } + "maximum" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(maximum = it, _json = json) + } ?: Adjustment(_json = json) + } + } - fun ofGroupedWithProratedMinimum( - groupedWithProratedMinimum: NewSubscriptionGroupedWithProratedMinimumPrice - ) = Price(groupedWithProratedMinimum = groupedWithProratedMinimum) + return Adjustment(_json = json) + } + } - fun ofGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice - ) = Price(groupedWithMeteredMinimum = groupedWithMeteredMinimum) + internal class Serializer : BaseSerializer(Adjustment::class) { - fun ofGroupedWithMinMaxThresholds( - groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds - ) = Price(groupedWithMinMaxThresholds = groupedWithMinMaxThresholds) + override fun serialize( + value: Adjustment, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.percentageDiscount != null -> + generator.writeObject(value.percentageDiscount) + value.usageDiscount != null -> generator.writeObject(value.usageDiscount) + value.amountDiscount != null -> generator.writeObject(value.amountDiscount) + value.minimum != null -> generator.writeObject(value.minimum) + value.maximum != null -> generator.writeObject(value.maximum) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Adjustment") + } + } + } + } - fun ofMatrixWithDisplayName( - matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice - ) = Price(matrixWithDisplayName = matrixWithDisplayName) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun ofGroupedTieredPackage( - groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice - ) = Price(groupedTieredPackage = groupedTieredPackage) + return other is ReplaceAdjustment && + adjustment == other.adjustment && + replacesAdjustmentId == other.replacesAdjustmentId && + additionalProperties == other.additionalProperties + } - fun ofMaxGroupTieredPackage( - maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice - ) = Price(maxGroupTieredPackage = maxGroupTieredPackage) + private val hashCode: Int by lazy { + Objects.hash(adjustment, replacesAdjustmentId, additionalProperties) + } - fun ofScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: NewSubscriptionScalableMatrixWithUnitPricingPrice - ) = Price(scalableMatrixWithUnitPricing = scalableMatrixWithUnitPricing) + override fun hashCode(): Int = hashCode - fun ofScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: - NewSubscriptionScalableMatrixWithTieredPricingPrice - ) = Price(scalableMatrixWithTieredPricing = scalableMatrixWithTieredPricing) + override fun toString() = + "ReplaceAdjustment{adjustment=$adjustment, replacesAdjustmentId=$replacesAdjustmentId, additionalProperties=$additionalProperties}" + } - fun ofCumulativeGroupedBulk( - cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice - ) = Price(cumulativeGroupedBulk = cumulativeGroupedBulk) + class ReplacePrice + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val replacesPriceId: JsonField, + private val allocationPrice: JsonField, + private val discounts: JsonField>, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val maximumAmount: JsonField, + private val minimumAmount: JsonField, + private val price: JsonField, + private val priceId: JsonField, + private val additionalProperties: MutableMap, + ) { - fun ofMinimum(minimum: NewSubscriptionMinimumCompositePrice) = - Price(minimum = minimum) - } + @JsonCreator + private constructor( + @JsonProperty("replaces_price_id") + @ExcludeMissing + replacesPriceId: JsonField = JsonMissing.of(), + @JsonProperty("allocation_price") + @ExcludeMissing + allocationPrice: JsonField = JsonMissing.of(), + @JsonProperty("discounts") + @ExcludeMissing + discounts: JsonField> = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("maximum_amount") + @ExcludeMissing + maximumAmount: JsonField = JsonMissing.of(), + @JsonProperty("minimum_amount") + @ExcludeMissing + minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("price") @ExcludeMissing price: JsonField = JsonMissing.of(), + @JsonProperty("price_id") @ExcludeMissing priceId: JsonField = JsonMissing.of(), + ) : this( + replacesPriceId, + allocationPrice, + discounts, + externalPriceId, + fixedPriceQuantity, + maximumAmount, + minimumAmount, + price, + priceId, + mutableMapOf(), + ) - /** - * An interface that defines how to map each variant of [Price] to a value of type [T]. - */ - interface Visitor { + /** + * The id of the price on the plan to replace in the subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun replacesPriceId(): String = replacesPriceId.getRequired("replaces_price_id") - fun visitUnit(unit: NewSubscriptionUnitPrice): T + /** + * The definition of a new allocation price to create and add to the subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun allocationPrice(): NewAllocationPrice? = allocationPrice.getNullable("allocation_price") - fun visitTiered(tiered: NewSubscriptionTieredPrice): T + /** + * [DEPRECATED] Use add_adjustments instead. The subscription's discounts for the + * replacement price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + @Deprecated("deprecated") + fun discounts(): List? = discounts.getNullable("discounts") - fun visitBulk(bulk: NewSubscriptionBulkPrice): T + /** + * The external price id of the price to add to the subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") - fun visitPackage(package_: NewSubscriptionPackagePrice): T + /** + * The new quantity of the price, if the price is a fixed price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = fixedPriceQuantity.getNullable("fixed_price_quantity") - fun visitMatrix(matrix: NewSubscriptionMatrixPrice): T + /** + * [DEPRECATED] Use add_adjustments instead. The subscription's maximum amount for the + * replacement price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + @Deprecated("deprecated") + fun maximumAmount(): String? = maximumAmount.getNullable("maximum_amount") - fun visitThresholdTotalAmount( - thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice - ): T + /** + * [DEPRECATED] Use add_adjustments instead. The subscription's minimum amount for the + * replacement price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + @Deprecated("deprecated") + fun minimumAmount(): String? = minimumAmount.getNullable("minimum_amount") - fun visitTieredPackage(tieredPackage: NewSubscriptionTieredPackagePrice): T + /** + * New subscription price request body params. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun price(): Price? = price.getNullable("price") - fun visitTieredWithMinimum( - tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice - ): T + /** + * The id of the price to add to the subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun priceId(): String? = priceId.getNullable("price_id") - fun visitGroupedTiered(groupedTiered: NewSubscriptionGroupedTieredPrice): T + /** + * Returns the raw JSON value of [replacesPriceId]. + * + * Unlike [replacesPriceId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("replaces_price_id") + @ExcludeMissing + fun _replacesPriceId(): JsonField = replacesPriceId - fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice - ): T + /** + * Returns the raw JSON value of [allocationPrice]. + * + * Unlike [allocationPrice], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("allocation_price") + @ExcludeMissing + fun _allocationPrice(): JsonField = allocationPrice - fun visitPackageWithAllocation( - packageWithAllocation: NewSubscriptionPackageWithAllocationPrice - ): T + /** + * Returns the raw JSON value of [discounts]. + * + * Unlike [discounts], this method doesn't throw if the JSON field has an unexpected type. + */ + @Deprecated("deprecated") + @JsonProperty("discounts") + @ExcludeMissing + fun _discounts(): JsonField> = discounts - fun visitUnitWithPercent(unitWithPercent: NewSubscriptionUnitWithPercentPrice): T + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId - fun visitMatrixWithAllocation( - matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice - ): T + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - fun visitTieredWithProration(tieredWithProration: TieredWithProration): T + /** + * Returns the raw JSON value of [maximumAmount]. + * + * Unlike [maximumAmount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @Deprecated("deprecated") + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount - fun visitUnitWithProration( - unitWithProration: NewSubscriptionUnitWithProrationPrice - ): T + /** + * Returns the raw JSON value of [minimumAmount]. + * + * Unlike [minimumAmount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @Deprecated("deprecated") + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount - fun visitGroupedAllocation( - groupedAllocation: NewSubscriptionGroupedAllocationPrice - ): T + /** + * Returns the raw JSON value of [price]. + * + * Unlike [price], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("price") @ExcludeMissing fun _price(): JsonField = price - fun visitBulkWithProration( - bulkWithProration: NewSubscriptionBulkWithProrationPrice - ): T + /** + * Returns the raw JSON value of [priceId]. + * + * Unlike [priceId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId - fun visitGroupedWithProratedMinimum( - groupedWithProratedMinimum: NewSubscriptionGroupedWithProratedMinimumPrice - ): T + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - fun visitGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice - ): T + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - fun visitGroupedWithMinMaxThresholds( - groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds - ): T + fun toBuilder() = Builder().from(this) - fun visitMatrixWithDisplayName( - matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice - ): T + companion object { - fun visitGroupedTieredPackage( - groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice - ): T + /** + * Returns a mutable builder for constructing an instance of [ReplacePrice]. + * + * The following fields are required: + * ```kotlin + * .replacesPriceId() + * ``` + */ + fun builder() = Builder() + } - fun visitMaxGroupTieredPackage( - maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice - ): T + /** A builder for [ReplacePrice]. */ + class Builder internal constructor() { - fun visitScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: NewSubscriptionScalableMatrixWithUnitPricingPrice - ): T + private var replacesPriceId: JsonField? = null + private var allocationPrice: JsonField = JsonMissing.of() + private var discounts: JsonField>? = null + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var maximumAmount: JsonField = JsonMissing.of() + private var minimumAmount: JsonField = JsonMissing.of() + private var price: JsonField = JsonMissing.of() + private var priceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - fun visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: - NewSubscriptionScalableMatrixWithTieredPricingPrice - ): T + internal fun from(replacePrice: ReplacePrice) = apply { + replacesPriceId = replacePrice.replacesPriceId + allocationPrice = replacePrice.allocationPrice + discounts = replacePrice.discounts.map { it.toMutableList() } + externalPriceId = replacePrice.externalPriceId + fixedPriceQuantity = replacePrice.fixedPriceQuantity + maximumAmount = replacePrice.maximumAmount + minimumAmount = replacePrice.minimumAmount + price = replacePrice.price + priceId = replacePrice.priceId + additionalProperties = replacePrice.additionalProperties.toMutableMap() + } - fun visitCumulativeGroupedBulk( - cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice - ): T + /** The id of the price on the plan to replace in the subscription. */ + fun replacesPriceId(replacesPriceId: String) = + replacesPriceId(JsonField.of(replacesPriceId)) - fun visitMinimum(minimum: NewSubscriptionMinimumCompositePrice): T + /** + * Sets [Builder.replacesPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.replacesPriceId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun replacesPriceId(replacesPriceId: JsonField) = apply { + this.replacesPriceId = replacesPriceId + } - /** - * Maps an unknown variant of [Price] to a value of type [T]. - * - * An instance of [Price] can contain an unknown variant if it was deserialized from - * data that doesn't match any known variant. For example, if the SDK is on an older - * version than the API, then the API may respond with new variants that the SDK is - * unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown Price: $json") - } + /** The definition of a new allocation price to create and add to the subscription. */ + fun allocationPrice(allocationPrice: NewAllocationPrice?) = + allocationPrice(JsonField.ofNullable(allocationPrice)) + + /** + * Sets [Builder.allocationPrice] to an arbitrary JSON value. + * + * You should usually call [Builder.allocationPrice] with a well-typed + * [NewAllocationPrice] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun allocationPrice(allocationPrice: JsonField) = apply { + this.allocationPrice = allocationPrice } - internal class Deserializer : BaseDeserializer(Price::class) { + /** + * [DEPRECATED] Use add_adjustments instead. The subscription's discounts for the + * replacement price. + */ + @Deprecated("deprecated") + fun discounts(discounts: List?) = + discounts(JsonField.ofNullable(discounts)) - override fun ObjectCodec.deserialize(node: JsonNode): Price { - val json = JsonValue.fromJsonNode(node) - val modelType = json.asObject()?.get("model_type")?.asString() + /** + * Sets [Builder.discounts] to an arbitrary JSON value. + * + * You should usually call [Builder.discounts] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + @Deprecated("deprecated") + fun discounts(discounts: JsonField>) = apply { + this.discounts = discounts.map { it.toMutableList() } + } - when (modelType) { - "unit" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(unit = it, _json = json) } ?: Price(_json = json) - } - "tiered" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(tiered = it, _json = json) } ?: Price(_json = json) - } - "bulk" -> { - return tryDeserialize(node, jacksonTypeRef()) + /** + * Adds a single [DiscountOverride] to [discounts]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + @Deprecated("deprecated") + fun addDiscount(discount: DiscountOverride) = apply { + discounts = + (discounts ?: JsonField.of(mutableListOf())).also { + checkKnown("discounts", it).add(discount) + } + } + + /** The external price id of the price to add to the subscription. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** The new quantity of the price, if the price is a fixed price. */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** + * [DEPRECATED] Use add_adjustments instead. The subscription's maximum amount for the + * replacement price. + */ + @Deprecated("deprecated") + fun maximumAmount(maximumAmount: String?) = + maximumAmount(JsonField.ofNullable(maximumAmount)) + + /** + * Sets [Builder.maximumAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.maximumAmount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + @Deprecated("deprecated") + fun maximumAmount(maximumAmount: JsonField) = apply { + this.maximumAmount = maximumAmount + } + + /** + * [DEPRECATED] Use add_adjustments instead. The subscription's minimum amount for the + * replacement price. + */ + @Deprecated("deprecated") + fun minimumAmount(minimumAmount: String?) = + minimumAmount(JsonField.ofNullable(minimumAmount)) + + /** + * Sets [Builder.minimumAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumAmount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + @Deprecated("deprecated") + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount + } + + /** New subscription price request body params. */ + fun price(price: Price?) = price(JsonField.ofNullable(price)) + + /** + * Sets [Builder.price] to an arbitrary JSON value. + * + * You should usually call [Builder.price] with a well-typed [Price] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun price(price: JsonField) = apply { this.price = price } + + /** Alias for calling [price] with `Price.ofUnit(unit)`. */ + fun price(unit: NewSubscriptionUnitPrice) = price(Price.ofUnit(unit)) + + /** Alias for calling [price] with `Price.ofTiered(tiered)`. */ + fun price(tiered: NewSubscriptionTieredPrice) = price(Price.ofTiered(tiered)) + + /** Alias for calling [price] with `Price.ofBulk(bulk)`. */ + fun price(bulk: NewSubscriptionBulkPrice) = price(Price.ofBulk(bulk)) + + /** Alias for calling [price] with `Price.ofPackage(package_)`. */ + fun price(package_: NewSubscriptionPackagePrice) = price(Price.ofPackage(package_)) + + /** Alias for calling [price] with `Price.ofMatrix(matrix)`. */ + fun price(matrix: NewSubscriptionMatrixPrice) = price(Price.ofMatrix(matrix)) + + /** + * Alias for calling [price] with `Price.ofThresholdTotalAmount(thresholdTotalAmount)`. + */ + fun price(thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice) = + price(Price.ofThresholdTotalAmount(thresholdTotalAmount)) + + /** Alias for calling [price] with `Price.ofTieredPackage(tieredPackage)`. */ + fun price(tieredPackage: NewSubscriptionTieredPackagePrice) = + price(Price.ofTieredPackage(tieredPackage)) + + /** Alias for calling [price] with `Price.ofTieredWithMinimum(tieredWithMinimum)`. */ + fun price(tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice) = + price(Price.ofTieredWithMinimum(tieredWithMinimum)) + + /** Alias for calling [price] with `Price.ofGroupedTiered(groupedTiered)`. */ + fun price(groupedTiered: NewSubscriptionGroupedTieredPrice) = + price(Price.ofGroupedTiered(groupedTiered)) + + /** + * Alias for calling [price] with + * `Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)`. + */ + fun price(tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice) = + price(Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)) + + /** + * Alias for calling [price] with + * `Price.ofPackageWithAllocation(packageWithAllocation)`. + */ + fun price(packageWithAllocation: NewSubscriptionPackageWithAllocationPrice) = + price(Price.ofPackageWithAllocation(packageWithAllocation)) + + /** Alias for calling [price] with `Price.ofUnitWithPercent(unitWithPercent)`. */ + fun price(unitWithPercent: NewSubscriptionUnitWithPercentPrice) = + price(Price.ofUnitWithPercent(unitWithPercent)) + + /** + * Alias for calling [price] with `Price.ofMatrixWithAllocation(matrixWithAllocation)`. + */ + fun price(matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice) = + price(Price.ofMatrixWithAllocation(matrixWithAllocation)) + + /** + * Alias for calling [price] with `Price.ofTieredWithProration(tieredWithProration)`. + */ + fun price(tieredWithProration: Price.TieredWithProration) = + price(Price.ofTieredWithProration(tieredWithProration)) + + /** Alias for calling [price] with `Price.ofUnitWithProration(unitWithProration)`. */ + fun price(unitWithProration: NewSubscriptionUnitWithProrationPrice) = + price(Price.ofUnitWithProration(unitWithProration)) + + /** Alias for calling [price] with `Price.ofGroupedAllocation(groupedAllocation)`. */ + fun price(groupedAllocation: NewSubscriptionGroupedAllocationPrice) = + price(Price.ofGroupedAllocation(groupedAllocation)) + + /** Alias for calling [price] with `Price.ofBulkWithProration(bulkWithProration)`. */ + fun price(bulkWithProration: NewSubscriptionBulkWithProrationPrice) = + price(Price.ofBulkWithProration(bulkWithProration)) + + /** + * Alias for calling [price] with + * `Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)`. + */ + fun price(groupedWithProratedMinimum: NewSubscriptionGroupedWithProratedMinimumPrice) = + price(Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)) + + /** + * Alias for calling [price] with + * `Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)`. + */ + fun price(groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice) = + price(Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)) + + /** + * Alias for calling [price] with + * `Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)`. + */ + fun price(groupedWithMinMaxThresholds: Price.GroupedWithMinMaxThresholds) = + price(Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)) + + /** + * Alias for calling [price] with + * `Price.ofMatrixWithDisplayName(matrixWithDisplayName)`. + */ + fun price(matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice) = + price(Price.ofMatrixWithDisplayName(matrixWithDisplayName)) + + /** + * Alias for calling [price] with `Price.ofGroupedTieredPackage(groupedTieredPackage)`. + */ + fun price(groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice) = + price(Price.ofGroupedTieredPackage(groupedTieredPackage)) + + /** + * Alias for calling [price] with + * `Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)`. + */ + fun price(maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice) = + price(Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)) + + /** + * Alias for calling [price] with + * `Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)`. + */ + fun price( + scalableMatrixWithUnitPricing: NewSubscriptionScalableMatrixWithUnitPricingPrice + ) = price(Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)) + + /** + * Alias for calling [price] with + * `Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)`. + */ + fun price( + scalableMatrixWithTieredPricing: NewSubscriptionScalableMatrixWithTieredPricingPrice + ) = price(Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)) + + /** + * Alias for calling [price] with + * `Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)`. + */ + fun price(cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice) = + price(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) + + /** Alias for calling [price] with `Price.ofMinimum(minimum)`. */ + fun price(minimum: NewSubscriptionMinimumCompositePrice) = + price(Price.ofMinimum(minimum)) + + /** Alias for calling [price] with `Price.ofEventOutput(eventOutput)`. */ + fun price(eventOutput: Price.EventOutput) = price(Price.ofEventOutput(eventOutput)) + + /** The id of the price to add to the subscription. */ + fun priceId(priceId: String?) = priceId(JsonField.ofNullable(priceId)) + + /** + * Sets [Builder.priceId] to an arbitrary JSON value. + * + * You should usually call [Builder.priceId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun priceId(priceId: JsonField) = apply { this.priceId = priceId } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ReplacePrice]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .replacesPriceId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ReplacePrice = + ReplacePrice( + checkRequired("replacesPriceId", replacesPriceId), + allocationPrice, + (discounts ?: JsonMissing.of()).map { it.toImmutable() }, + externalPriceId, + fixedPriceQuantity, + maximumAmount, + minimumAmount, + price, + priceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ReplacePrice = apply { + if (validated) { + return@apply + } + + replacesPriceId() + allocationPrice()?.validate() + discounts()?.forEach { it.validate() } + externalPriceId() + fixedPriceQuantity() + maximumAmount() + minimumAmount() + price()?.validate() + priceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (replacesPriceId.asKnown() == null) 0 else 1) + + (allocationPrice.asKnown()?.validity() ?: 0) + + (discounts.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (maximumAmount.asKnown() == null) 0 else 1) + + (if (minimumAmount.asKnown() == null) 0 else 1) + + (price.asKnown()?.validity() ?: 0) + + (if (priceId.asKnown() == null) 0 else 1) + + /** New subscription price request body params. */ + @JsonDeserialize(using = Price.Deserializer::class) + @JsonSerialize(using = Price.Serializer::class) + class Price + private constructor( + private val unit: NewSubscriptionUnitPrice? = null, + private val tiered: NewSubscriptionTieredPrice? = null, + private val bulk: NewSubscriptionBulkPrice? = null, + private val package_: NewSubscriptionPackagePrice? = null, + private val matrix: NewSubscriptionMatrixPrice? = null, + private val thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice? = null, + private val tieredPackage: NewSubscriptionTieredPackagePrice? = null, + private val tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice? = null, + private val groupedTiered: NewSubscriptionGroupedTieredPrice? = null, + private val tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice? = + null, + private val packageWithAllocation: NewSubscriptionPackageWithAllocationPrice? = null, + private val unitWithPercent: NewSubscriptionUnitWithPercentPrice? = null, + private val matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice? = null, + private val tieredWithProration: TieredWithProration? = null, + private val unitWithProration: NewSubscriptionUnitWithProrationPrice? = null, + private val groupedAllocation: NewSubscriptionGroupedAllocationPrice? = null, + private val bulkWithProration: NewSubscriptionBulkWithProrationPrice? = null, + private val groupedWithProratedMinimum: + NewSubscriptionGroupedWithProratedMinimumPrice? = + null, + private val groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice? = + null, + private val groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds? = null, + private val matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice? = null, + private val groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice? = null, + private val maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice? = null, + private val scalableMatrixWithUnitPricing: + NewSubscriptionScalableMatrixWithUnitPricingPrice? = + null, + private val scalableMatrixWithTieredPricing: + NewSubscriptionScalableMatrixWithTieredPricingPrice? = + null, + private val cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice? = null, + private val minimum: NewSubscriptionMinimumCompositePrice? = null, + private val eventOutput: EventOutput? = null, + private val _json: JsonValue? = null, + ) { + + fun unit(): NewSubscriptionUnitPrice? = unit + + fun tiered(): NewSubscriptionTieredPrice? = tiered + + fun bulk(): NewSubscriptionBulkPrice? = bulk + + fun package_(): NewSubscriptionPackagePrice? = package_ + + fun matrix(): NewSubscriptionMatrixPrice? = matrix + + fun thresholdTotalAmount(): NewSubscriptionThresholdTotalAmountPrice? = + thresholdTotalAmount + + fun tieredPackage(): NewSubscriptionTieredPackagePrice? = tieredPackage + + fun tieredWithMinimum(): NewSubscriptionTieredWithMinimumPrice? = tieredWithMinimum + + fun groupedTiered(): NewSubscriptionGroupedTieredPrice? = groupedTiered + + fun tieredPackageWithMinimum(): NewSubscriptionTieredPackageWithMinimumPrice? = + tieredPackageWithMinimum + + fun packageWithAllocation(): NewSubscriptionPackageWithAllocationPrice? = + packageWithAllocation + + fun unitWithPercent(): NewSubscriptionUnitWithPercentPrice? = unitWithPercent + + fun matrixWithAllocation(): NewSubscriptionMatrixWithAllocationPrice? = + matrixWithAllocation + + fun tieredWithProration(): TieredWithProration? = tieredWithProration + + fun unitWithProration(): NewSubscriptionUnitWithProrationPrice? = unitWithProration + + fun groupedAllocation(): NewSubscriptionGroupedAllocationPrice? = groupedAllocation + + fun bulkWithProration(): NewSubscriptionBulkWithProrationPrice? = bulkWithProration + + fun groupedWithProratedMinimum(): NewSubscriptionGroupedWithProratedMinimumPrice? = + groupedWithProratedMinimum + + fun groupedWithMeteredMinimum(): NewSubscriptionGroupedWithMeteredMinimumPrice? = + groupedWithMeteredMinimum + + fun groupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds? = + groupedWithMinMaxThresholds + + fun matrixWithDisplayName(): NewSubscriptionMatrixWithDisplayNamePrice? = + matrixWithDisplayName + + fun groupedTieredPackage(): NewSubscriptionGroupedTieredPackagePrice? = + groupedTieredPackage + + fun maxGroupTieredPackage(): NewSubscriptionMaxGroupTieredPackagePrice? = + maxGroupTieredPackage + + fun scalableMatrixWithUnitPricing(): + NewSubscriptionScalableMatrixWithUnitPricingPrice? = scalableMatrixWithUnitPricing + + fun scalableMatrixWithTieredPricing(): + NewSubscriptionScalableMatrixWithTieredPricingPrice? = + scalableMatrixWithTieredPricing + + fun cumulativeGroupedBulk(): NewSubscriptionCumulativeGroupedBulkPrice? = + cumulativeGroupedBulk + + fun minimum(): NewSubscriptionMinimumCompositePrice? = minimum + + fun eventOutput(): EventOutput? = eventOutput + + fun isUnit(): Boolean = unit != null + + fun isTiered(): Boolean = tiered != null + + fun isBulk(): Boolean = bulk != null + + fun isPackage(): Boolean = package_ != null + + fun isMatrix(): Boolean = matrix != null + + fun isThresholdTotalAmount(): Boolean = thresholdTotalAmount != null + + fun isTieredPackage(): Boolean = tieredPackage != null + + fun isTieredWithMinimum(): Boolean = tieredWithMinimum != null + + fun isGroupedTiered(): Boolean = groupedTiered != null + + fun isTieredPackageWithMinimum(): Boolean = tieredPackageWithMinimum != null + + fun isPackageWithAllocation(): Boolean = packageWithAllocation != null + + fun isUnitWithPercent(): Boolean = unitWithPercent != null + + fun isMatrixWithAllocation(): Boolean = matrixWithAllocation != null + + fun isTieredWithProration(): Boolean = tieredWithProration != null + + fun isUnitWithProration(): Boolean = unitWithProration != null + + fun isGroupedAllocation(): Boolean = groupedAllocation != null + + fun isBulkWithProration(): Boolean = bulkWithProration != null + + fun isGroupedWithProratedMinimum(): Boolean = groupedWithProratedMinimum != null + + fun isGroupedWithMeteredMinimum(): Boolean = groupedWithMeteredMinimum != null + + fun isGroupedWithMinMaxThresholds(): Boolean = groupedWithMinMaxThresholds != null + + fun isMatrixWithDisplayName(): Boolean = matrixWithDisplayName != null + + fun isGroupedTieredPackage(): Boolean = groupedTieredPackage != null + + fun isMaxGroupTieredPackage(): Boolean = maxGroupTieredPackage != null + + fun isScalableMatrixWithUnitPricing(): Boolean = scalableMatrixWithUnitPricing != null + + fun isScalableMatrixWithTieredPricing(): Boolean = + scalableMatrixWithTieredPricing != null + + fun isCumulativeGroupedBulk(): Boolean = cumulativeGroupedBulk != null + + fun isMinimum(): Boolean = minimum != null + + fun isEventOutput(): Boolean = eventOutput != null + + fun asUnit(): NewSubscriptionUnitPrice = unit.getOrThrow("unit") + + fun asTiered(): NewSubscriptionTieredPrice = tiered.getOrThrow("tiered") + + fun asBulk(): NewSubscriptionBulkPrice = bulk.getOrThrow("bulk") + + fun asPackage(): NewSubscriptionPackagePrice = package_.getOrThrow("package_") + + fun asMatrix(): NewSubscriptionMatrixPrice = matrix.getOrThrow("matrix") + + fun asThresholdTotalAmount(): NewSubscriptionThresholdTotalAmountPrice = + thresholdTotalAmount.getOrThrow("thresholdTotalAmount") + + fun asTieredPackage(): NewSubscriptionTieredPackagePrice = + tieredPackage.getOrThrow("tieredPackage") + + fun asTieredWithMinimum(): NewSubscriptionTieredWithMinimumPrice = + tieredWithMinimum.getOrThrow("tieredWithMinimum") + + fun asGroupedTiered(): NewSubscriptionGroupedTieredPrice = + groupedTiered.getOrThrow("groupedTiered") + + fun asTieredPackageWithMinimum(): NewSubscriptionTieredPackageWithMinimumPrice = + tieredPackageWithMinimum.getOrThrow("tieredPackageWithMinimum") + + fun asPackageWithAllocation(): NewSubscriptionPackageWithAllocationPrice = + packageWithAllocation.getOrThrow("packageWithAllocation") + + fun asUnitWithPercent(): NewSubscriptionUnitWithPercentPrice = + unitWithPercent.getOrThrow("unitWithPercent") + + fun asMatrixWithAllocation(): NewSubscriptionMatrixWithAllocationPrice = + matrixWithAllocation.getOrThrow("matrixWithAllocation") + + fun asTieredWithProration(): TieredWithProration = + tieredWithProration.getOrThrow("tieredWithProration") + + fun asUnitWithProration(): NewSubscriptionUnitWithProrationPrice = + unitWithProration.getOrThrow("unitWithProration") + + fun asGroupedAllocation(): NewSubscriptionGroupedAllocationPrice = + groupedAllocation.getOrThrow("groupedAllocation") + + fun asBulkWithProration(): NewSubscriptionBulkWithProrationPrice = + bulkWithProration.getOrThrow("bulkWithProration") + + fun asGroupedWithProratedMinimum(): NewSubscriptionGroupedWithProratedMinimumPrice = + groupedWithProratedMinimum.getOrThrow("groupedWithProratedMinimum") + + fun asGroupedWithMeteredMinimum(): NewSubscriptionGroupedWithMeteredMinimumPrice = + groupedWithMeteredMinimum.getOrThrow("groupedWithMeteredMinimum") + + fun asGroupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds = + groupedWithMinMaxThresholds.getOrThrow("groupedWithMinMaxThresholds") + + fun asMatrixWithDisplayName(): NewSubscriptionMatrixWithDisplayNamePrice = + matrixWithDisplayName.getOrThrow("matrixWithDisplayName") + + fun asGroupedTieredPackage(): NewSubscriptionGroupedTieredPackagePrice = + groupedTieredPackage.getOrThrow("groupedTieredPackage") + + fun asMaxGroupTieredPackage(): NewSubscriptionMaxGroupTieredPackagePrice = + maxGroupTieredPackage.getOrThrow("maxGroupTieredPackage") + + fun asScalableMatrixWithUnitPricing(): + NewSubscriptionScalableMatrixWithUnitPricingPrice = + scalableMatrixWithUnitPricing.getOrThrow("scalableMatrixWithUnitPricing") + + fun asScalableMatrixWithTieredPricing(): + NewSubscriptionScalableMatrixWithTieredPricingPrice = + scalableMatrixWithTieredPricing.getOrThrow("scalableMatrixWithTieredPricing") + + fun asCumulativeGroupedBulk(): NewSubscriptionCumulativeGroupedBulkPrice = + cumulativeGroupedBulk.getOrThrow("cumulativeGroupedBulk") + + fun asMinimum(): NewSubscriptionMinimumCompositePrice = minimum.getOrThrow("minimum") + + fun asEventOutput(): EventOutput = eventOutput.getOrThrow("eventOutput") + + fun _json(): JsonValue? = _json + + fun accept(visitor: Visitor): T = + when { + unit != null -> visitor.visitUnit(unit) + tiered != null -> visitor.visitTiered(tiered) + bulk != null -> visitor.visitBulk(bulk) + package_ != null -> visitor.visitPackage(package_) + matrix != null -> visitor.visitMatrix(matrix) + thresholdTotalAmount != null -> + visitor.visitThresholdTotalAmount(thresholdTotalAmount) + tieredPackage != null -> visitor.visitTieredPackage(tieredPackage) + tieredWithMinimum != null -> visitor.visitTieredWithMinimum(tieredWithMinimum) + groupedTiered != null -> visitor.visitGroupedTiered(groupedTiered) + tieredPackageWithMinimum != null -> + visitor.visitTieredPackageWithMinimum(tieredPackageWithMinimum) + packageWithAllocation != null -> + visitor.visitPackageWithAllocation(packageWithAllocation) + unitWithPercent != null -> visitor.visitUnitWithPercent(unitWithPercent) + matrixWithAllocation != null -> + visitor.visitMatrixWithAllocation(matrixWithAllocation) + tieredWithProration != null -> + visitor.visitTieredWithProration(tieredWithProration) + unitWithProration != null -> visitor.visitUnitWithProration(unitWithProration) + groupedAllocation != null -> visitor.visitGroupedAllocation(groupedAllocation) + bulkWithProration != null -> visitor.visitBulkWithProration(bulkWithProration) + groupedWithProratedMinimum != null -> + visitor.visitGroupedWithProratedMinimum(groupedWithProratedMinimum) + groupedWithMeteredMinimum != null -> + visitor.visitGroupedWithMeteredMinimum(groupedWithMeteredMinimum) + groupedWithMinMaxThresholds != null -> + visitor.visitGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds) + matrixWithDisplayName != null -> + visitor.visitMatrixWithDisplayName(matrixWithDisplayName) + groupedTieredPackage != null -> + visitor.visitGroupedTieredPackage(groupedTieredPackage) + maxGroupTieredPackage != null -> + visitor.visitMaxGroupTieredPackage(maxGroupTieredPackage) + scalableMatrixWithUnitPricing != null -> + visitor.visitScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing) + scalableMatrixWithTieredPricing != null -> + visitor.visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing + ) + cumulativeGroupedBulk != null -> + visitor.visitCumulativeGroupedBulk(cumulativeGroupedBulk) + minimum != null -> visitor.visitMinimum(minimum) + eventOutput != null -> visitor.visitEventOutput(eventOutput) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Price = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitUnit(unit: NewSubscriptionUnitPrice) { + unit.validate() + } + + override fun visitTiered(tiered: NewSubscriptionTieredPrice) { + tiered.validate() + } + + override fun visitBulk(bulk: NewSubscriptionBulkPrice) { + bulk.validate() + } + + override fun visitPackage(package_: NewSubscriptionPackagePrice) { + package_.validate() + } + + override fun visitMatrix(matrix: NewSubscriptionMatrixPrice) { + matrix.validate() + } + + override fun visitThresholdTotalAmount( + thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice + ) { + thresholdTotalAmount.validate() + } + + override fun visitTieredPackage( + tieredPackage: NewSubscriptionTieredPackagePrice + ) { + tieredPackage.validate() + } + + override fun visitTieredWithMinimum( + tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice + ) { + tieredWithMinimum.validate() + } + + override fun visitGroupedTiered( + groupedTiered: NewSubscriptionGroupedTieredPrice + ) { + groupedTiered.validate() + } + + override fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice + ) { + tieredPackageWithMinimum.validate() + } + + override fun visitPackageWithAllocation( + packageWithAllocation: NewSubscriptionPackageWithAllocationPrice + ) { + packageWithAllocation.validate() + } + + override fun visitUnitWithPercent( + unitWithPercent: NewSubscriptionUnitWithPercentPrice + ) { + unitWithPercent.validate() + } + + override fun visitMatrixWithAllocation( + matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice + ) { + matrixWithAllocation.validate() + } + + override fun visitTieredWithProration( + tieredWithProration: TieredWithProration + ) { + tieredWithProration.validate() + } + + override fun visitUnitWithProration( + unitWithProration: NewSubscriptionUnitWithProrationPrice + ) { + unitWithProration.validate() + } + + override fun visitGroupedAllocation( + groupedAllocation: NewSubscriptionGroupedAllocationPrice + ) { + groupedAllocation.validate() + } + + override fun visitBulkWithProration( + bulkWithProration: NewSubscriptionBulkWithProrationPrice + ) { + bulkWithProration.validate() + } + + override fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: + NewSubscriptionGroupedWithProratedMinimumPrice + ) { + groupedWithProratedMinimum.validate() + } + + override fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice + ) { + groupedWithMeteredMinimum.validate() + } + + override fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) { + groupedWithMinMaxThresholds.validate() + } + + override fun visitMatrixWithDisplayName( + matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice + ) { + matrixWithDisplayName.validate() + } + + override fun visitGroupedTieredPackage( + groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice + ) { + groupedTieredPackage.validate() + } + + override fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice + ) { + maxGroupTieredPackage.validate() + } + + override fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: + NewSubscriptionScalableMatrixWithUnitPricingPrice + ) { + scalableMatrixWithUnitPricing.validate() + } + + override fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: + NewSubscriptionScalableMatrixWithTieredPricingPrice + ) { + scalableMatrixWithTieredPricing.validate() + } + + override fun visitCumulativeGroupedBulk( + cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice + ) { + cumulativeGroupedBulk.validate() + } + + override fun visitMinimum(minimum: NewSubscriptionMinimumCompositePrice) { + minimum.validate() + } + + override fun visitEventOutput(eventOutput: EventOutput) { + eventOutput.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitUnit(unit: NewSubscriptionUnitPrice) = unit.validity() + + override fun visitTiered(tiered: NewSubscriptionTieredPrice) = + tiered.validity() + + override fun visitBulk(bulk: NewSubscriptionBulkPrice) = bulk.validity() + + override fun visitPackage(package_: NewSubscriptionPackagePrice) = + package_.validity() + + override fun visitMatrix(matrix: NewSubscriptionMatrixPrice) = + matrix.validity() + + override fun visitThresholdTotalAmount( + thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice + ) = thresholdTotalAmount.validity() + + override fun visitTieredPackage( + tieredPackage: NewSubscriptionTieredPackagePrice + ) = tieredPackage.validity() + + override fun visitTieredWithMinimum( + tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice + ) = tieredWithMinimum.validity() + + override fun visitGroupedTiered( + groupedTiered: NewSubscriptionGroupedTieredPrice + ) = groupedTiered.validity() + + override fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice + ) = tieredPackageWithMinimum.validity() + + override fun visitPackageWithAllocation( + packageWithAllocation: NewSubscriptionPackageWithAllocationPrice + ) = packageWithAllocation.validity() + + override fun visitUnitWithPercent( + unitWithPercent: NewSubscriptionUnitWithPercentPrice + ) = unitWithPercent.validity() + + override fun visitMatrixWithAllocation( + matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice + ) = matrixWithAllocation.validity() + + override fun visitTieredWithProration( + tieredWithProration: TieredWithProration + ) = tieredWithProration.validity() + + override fun visitUnitWithProration( + unitWithProration: NewSubscriptionUnitWithProrationPrice + ) = unitWithProration.validity() + + override fun visitGroupedAllocation( + groupedAllocation: NewSubscriptionGroupedAllocationPrice + ) = groupedAllocation.validity() + + override fun visitBulkWithProration( + bulkWithProration: NewSubscriptionBulkWithProrationPrice + ) = bulkWithProration.validity() + + override fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: + NewSubscriptionGroupedWithProratedMinimumPrice + ) = groupedWithProratedMinimum.validity() + + override fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice + ) = groupedWithMeteredMinimum.validity() + + override fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) = groupedWithMinMaxThresholds.validity() + + override fun visitMatrixWithDisplayName( + matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice + ) = matrixWithDisplayName.validity() + + override fun visitGroupedTieredPackage( + groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice + ) = groupedTieredPackage.validity() + + override fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice + ) = maxGroupTieredPackage.validity() + + override fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: + NewSubscriptionScalableMatrixWithUnitPricingPrice + ) = scalableMatrixWithUnitPricing.validity() + + override fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: + NewSubscriptionScalableMatrixWithTieredPricingPrice + ) = scalableMatrixWithTieredPricing.validity() + + override fun visitCumulativeGroupedBulk( + cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice + ) = cumulativeGroupedBulk.validity() + + override fun visitMinimum(minimum: NewSubscriptionMinimumCompositePrice) = + minimum.validity() + + override fun visitEventOutput(eventOutput: EventOutput) = + eventOutput.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Price && + unit == other.unit && + tiered == other.tiered && + bulk == other.bulk && + package_ == other.package_ && + matrix == other.matrix && + thresholdTotalAmount == other.thresholdTotalAmount && + tieredPackage == other.tieredPackage && + tieredWithMinimum == other.tieredWithMinimum && + groupedTiered == other.groupedTiered && + tieredPackageWithMinimum == other.tieredPackageWithMinimum && + packageWithAllocation == other.packageWithAllocation && + unitWithPercent == other.unitWithPercent && + matrixWithAllocation == other.matrixWithAllocation && + tieredWithProration == other.tieredWithProration && + unitWithProration == other.unitWithProration && + groupedAllocation == other.groupedAllocation && + bulkWithProration == other.bulkWithProration && + groupedWithProratedMinimum == other.groupedWithProratedMinimum && + groupedWithMeteredMinimum == other.groupedWithMeteredMinimum && + groupedWithMinMaxThresholds == other.groupedWithMinMaxThresholds && + matrixWithDisplayName == other.matrixWithDisplayName && + groupedTieredPackage == other.groupedTieredPackage && + maxGroupTieredPackage == other.maxGroupTieredPackage && + scalableMatrixWithUnitPricing == other.scalableMatrixWithUnitPricing && + scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && + cumulativeGroupedBulk == other.cumulativeGroupedBulk && + minimum == other.minimum && + eventOutput == other.eventOutput + } + + override fun hashCode(): Int = + Objects.hash( + unit, + tiered, + bulk, + package_, + matrix, + thresholdTotalAmount, + tieredPackage, + tieredWithMinimum, + groupedTiered, + tieredPackageWithMinimum, + packageWithAllocation, + unitWithPercent, + matrixWithAllocation, + tieredWithProration, + unitWithProration, + groupedAllocation, + bulkWithProration, + groupedWithProratedMinimum, + groupedWithMeteredMinimum, + groupedWithMinMaxThresholds, + matrixWithDisplayName, + groupedTieredPackage, + maxGroupTieredPackage, + scalableMatrixWithUnitPricing, + scalableMatrixWithTieredPricing, + cumulativeGroupedBulk, + minimum, + eventOutput, + ) + + override fun toString(): String = + when { + unit != null -> "Price{unit=$unit}" + tiered != null -> "Price{tiered=$tiered}" + bulk != null -> "Price{bulk=$bulk}" + package_ != null -> "Price{package_=$package_}" + matrix != null -> "Price{matrix=$matrix}" + thresholdTotalAmount != null -> + "Price{thresholdTotalAmount=$thresholdTotalAmount}" + tieredPackage != null -> "Price{tieredPackage=$tieredPackage}" + tieredWithMinimum != null -> "Price{tieredWithMinimum=$tieredWithMinimum}" + groupedTiered != null -> "Price{groupedTiered=$groupedTiered}" + tieredPackageWithMinimum != null -> + "Price{tieredPackageWithMinimum=$tieredPackageWithMinimum}" + packageWithAllocation != null -> + "Price{packageWithAllocation=$packageWithAllocation}" + unitWithPercent != null -> "Price{unitWithPercent=$unitWithPercent}" + matrixWithAllocation != null -> + "Price{matrixWithAllocation=$matrixWithAllocation}" + tieredWithProration != null -> "Price{tieredWithProration=$tieredWithProration}" + unitWithProration != null -> "Price{unitWithProration=$unitWithProration}" + groupedAllocation != null -> "Price{groupedAllocation=$groupedAllocation}" + bulkWithProration != null -> "Price{bulkWithProration=$bulkWithProration}" + groupedWithProratedMinimum != null -> + "Price{groupedWithProratedMinimum=$groupedWithProratedMinimum}" + groupedWithMeteredMinimum != null -> + "Price{groupedWithMeteredMinimum=$groupedWithMeteredMinimum}" + groupedWithMinMaxThresholds != null -> + "Price{groupedWithMinMaxThresholds=$groupedWithMinMaxThresholds}" + matrixWithDisplayName != null -> + "Price{matrixWithDisplayName=$matrixWithDisplayName}" + groupedTieredPackage != null -> + "Price{groupedTieredPackage=$groupedTieredPackage}" + maxGroupTieredPackage != null -> + "Price{maxGroupTieredPackage=$maxGroupTieredPackage}" + scalableMatrixWithUnitPricing != null -> + "Price{scalableMatrixWithUnitPricing=$scalableMatrixWithUnitPricing}" + scalableMatrixWithTieredPricing != null -> + "Price{scalableMatrixWithTieredPricing=$scalableMatrixWithTieredPricing}" + cumulativeGroupedBulk != null -> + "Price{cumulativeGroupedBulk=$cumulativeGroupedBulk}" + minimum != null -> "Price{minimum=$minimum}" + eventOutput != null -> "Price{eventOutput=$eventOutput}" + _json != null -> "Price{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Price") + } + + companion object { + + fun ofUnit(unit: NewSubscriptionUnitPrice) = Price(unit = unit) + + fun ofTiered(tiered: NewSubscriptionTieredPrice) = Price(tiered = tiered) + + fun ofBulk(bulk: NewSubscriptionBulkPrice) = Price(bulk = bulk) + + fun ofPackage(package_: NewSubscriptionPackagePrice) = Price(package_ = package_) + + fun ofMatrix(matrix: NewSubscriptionMatrixPrice) = Price(matrix = matrix) + + fun ofThresholdTotalAmount( + thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice + ) = Price(thresholdTotalAmount = thresholdTotalAmount) + + fun ofTieredPackage(tieredPackage: NewSubscriptionTieredPackagePrice) = + Price(tieredPackage = tieredPackage) + + fun ofTieredWithMinimum(tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice) = + Price(tieredWithMinimum = tieredWithMinimum) + + fun ofGroupedTiered(groupedTiered: NewSubscriptionGroupedTieredPrice) = + Price(groupedTiered = groupedTiered) + + fun ofTieredPackageWithMinimum( + tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice + ) = Price(tieredPackageWithMinimum = tieredPackageWithMinimum) + + fun ofPackageWithAllocation( + packageWithAllocation: NewSubscriptionPackageWithAllocationPrice + ) = Price(packageWithAllocation = packageWithAllocation) + + fun ofUnitWithPercent(unitWithPercent: NewSubscriptionUnitWithPercentPrice) = + Price(unitWithPercent = unitWithPercent) + + fun ofMatrixWithAllocation( + matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice + ) = Price(matrixWithAllocation = matrixWithAllocation) + + fun ofTieredWithProration(tieredWithProration: TieredWithProration) = + Price(tieredWithProration = tieredWithProration) + + fun ofUnitWithProration(unitWithProration: NewSubscriptionUnitWithProrationPrice) = + Price(unitWithProration = unitWithProration) + + fun ofGroupedAllocation(groupedAllocation: NewSubscriptionGroupedAllocationPrice) = + Price(groupedAllocation = groupedAllocation) + + fun ofBulkWithProration(bulkWithProration: NewSubscriptionBulkWithProrationPrice) = + Price(bulkWithProration = bulkWithProration) + + fun ofGroupedWithProratedMinimum( + groupedWithProratedMinimum: NewSubscriptionGroupedWithProratedMinimumPrice + ) = Price(groupedWithProratedMinimum = groupedWithProratedMinimum) + + fun ofGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice + ) = Price(groupedWithMeteredMinimum = groupedWithMeteredMinimum) + + fun ofGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) = Price(groupedWithMinMaxThresholds = groupedWithMinMaxThresholds) + + fun ofMatrixWithDisplayName( + matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice + ) = Price(matrixWithDisplayName = matrixWithDisplayName) + + fun ofGroupedTieredPackage( + groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice + ) = Price(groupedTieredPackage = groupedTieredPackage) + + fun ofMaxGroupTieredPackage( + maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice + ) = Price(maxGroupTieredPackage = maxGroupTieredPackage) + + fun ofScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: NewSubscriptionScalableMatrixWithUnitPricingPrice + ) = Price(scalableMatrixWithUnitPricing = scalableMatrixWithUnitPricing) + + fun ofScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: + NewSubscriptionScalableMatrixWithTieredPricingPrice + ) = Price(scalableMatrixWithTieredPricing = scalableMatrixWithTieredPricing) + + fun ofCumulativeGroupedBulk( + cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice + ) = Price(cumulativeGroupedBulk = cumulativeGroupedBulk) + + fun ofMinimum(minimum: NewSubscriptionMinimumCompositePrice) = + Price(minimum = minimum) + + fun ofEventOutput(eventOutput: EventOutput) = Price(eventOutput = eventOutput) + } + + /** + * An interface that defines how to map each variant of [Price] to a value of type [T]. + */ + interface Visitor { + + fun visitUnit(unit: NewSubscriptionUnitPrice): T + + fun visitTiered(tiered: NewSubscriptionTieredPrice): T + + fun visitBulk(bulk: NewSubscriptionBulkPrice): T + + fun visitPackage(package_: NewSubscriptionPackagePrice): T + + fun visitMatrix(matrix: NewSubscriptionMatrixPrice): T + + fun visitThresholdTotalAmount( + thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice + ): T + + fun visitTieredPackage(tieredPackage: NewSubscriptionTieredPackagePrice): T + + fun visitTieredWithMinimum( + tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice + ): T + + fun visitGroupedTiered(groupedTiered: NewSubscriptionGroupedTieredPrice): T + + fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice + ): T + + fun visitPackageWithAllocation( + packageWithAllocation: NewSubscriptionPackageWithAllocationPrice + ): T + + fun visitUnitWithPercent(unitWithPercent: NewSubscriptionUnitWithPercentPrice): T + + fun visitMatrixWithAllocation( + matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice + ): T + + fun visitTieredWithProration(tieredWithProration: TieredWithProration): T + + fun visitUnitWithProration( + unitWithProration: NewSubscriptionUnitWithProrationPrice + ): T + + fun visitGroupedAllocation( + groupedAllocation: NewSubscriptionGroupedAllocationPrice + ): T + + fun visitBulkWithProration( + bulkWithProration: NewSubscriptionBulkWithProrationPrice + ): T + + fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: NewSubscriptionGroupedWithProratedMinimumPrice + ): T + + fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice + ): T + + fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ): T + + fun visitMatrixWithDisplayName( + matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice + ): T + + fun visitGroupedTieredPackage( + groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice + ): T + + fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice + ): T + + fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: NewSubscriptionScalableMatrixWithUnitPricingPrice + ): T + + fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: + NewSubscriptionScalableMatrixWithTieredPricingPrice + ): T + + fun visitCumulativeGroupedBulk( + cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice + ): T + + fun visitMinimum(minimum: NewSubscriptionMinimumCompositePrice): T + + fun visitEventOutput(eventOutput: EventOutput): T + + /** + * Maps an unknown variant of [Price] to a value of type [T]. + * + * An instance of [Price] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is + * unaware of. + * + * @throws OrbInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw OrbInvalidDataException("Unknown Price: $json") + } + } + + internal class Deserializer : BaseDeserializer(Price::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Price { + val json = JsonValue.fromJsonNode(node) + val modelType = json.asObject()?.get("model_type")?.asString() + + when (modelType) { + "unit" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(unit = it, _json = json) } ?: Price(_json = json) + } + "tiered" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(tiered = it, _json = json) } ?: Price(_json = json) + } + "bulk" -> { + return tryDeserialize(node, jacksonTypeRef()) ?.let { Price(bulk = it, _json = json) } ?: Price(_json = json) } - "package" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(package_ = it, _json = json) } ?: Price(_json = json) + "package" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(package_ = it, _json = json) } ?: Price(_json = json) + } + "matrix" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(matrix = it, _json = json) } ?: Price(_json = json) + } + "threshold_total_amount" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(thresholdTotalAmount = it, _json = json) } + ?: Price(_json = json) + } + "tiered_package" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(tieredPackage = it, _json = json) } + ?: Price(_json = json) + } + "tiered_with_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(tieredWithMinimum = it, _json = json) } + ?: Price(_json = json) + } + "grouped_tiered" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedTiered = it, _json = json) } + ?: Price(_json = json) + } + "tiered_package_with_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(tieredPackageWithMinimum = it, _json = json) } + ?: Price(_json = json) + } + "package_with_allocation" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(packageWithAllocation = it, _json = json) } + ?: Price(_json = json) + } + "unit_with_percent" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(unitWithPercent = it, _json = json) } + ?: Price(_json = json) + } + "matrix_with_allocation" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(matrixWithAllocation = it, _json = json) } + ?: Price(_json = json) + } + "tiered_with_proration" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(tieredWithProration = it, _json = json) } + ?: Price(_json = json) + } + "unit_with_proration" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(unitWithProration = it, _json = json) } + ?: Price(_json = json) + } + "grouped_allocation" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedAllocation = it, _json = json) } + ?: Price(_json = json) + } + "bulk_with_proration" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(bulkWithProration = it, _json = json) } + ?: Price(_json = json) + } + "grouped_with_prorated_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedWithProratedMinimum = it, _json = json) } + ?: Price(_json = json) + } + "grouped_with_metered_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedWithMeteredMinimum = it, _json = json) } + ?: Price(_json = json) + } + "grouped_with_min_max_thresholds" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedWithMinMaxThresholds = it, _json = json) } + ?: Price(_json = json) + } + "matrix_with_display_name" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(matrixWithDisplayName = it, _json = json) } + ?: Price(_json = json) + } + "grouped_tiered_package" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedTieredPackage = it, _json = json) } + ?: Price(_json = json) + } + "max_group_tiered_package" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(maxGroupTieredPackage = it, _json = json) } + ?: Price(_json = json) + } + "scalable_matrix_with_unit_pricing" -> { + return tryDeserialize( + node, + jacksonTypeRef< + NewSubscriptionScalableMatrixWithUnitPricingPrice + >(), + ) + ?.let { Price(scalableMatrixWithUnitPricing = it, _json = json) } + ?: Price(_json = json) + } + "scalable_matrix_with_tiered_pricing" -> { + return tryDeserialize( + node, + jacksonTypeRef< + NewSubscriptionScalableMatrixWithTieredPricingPrice + >(), + ) + ?.let { Price(scalableMatrixWithTieredPricing = it, _json = json) } + ?: Price(_json = json) + } + "cumulative_grouped_bulk" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(cumulativeGroupedBulk = it, _json = json) } + ?: Price(_json = json) + } + "minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(minimum = it, _json = json) } ?: Price(_json = json) + } + "event_output" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(eventOutput = it, _json = json) + } ?: Price(_json = json) + } + } + + return Price(_json = json) + } + } + + internal class Serializer : BaseSerializer(Price::class) { + + override fun serialize( + value: Price, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.unit != null -> generator.writeObject(value.unit) + value.tiered != null -> generator.writeObject(value.tiered) + value.bulk != null -> generator.writeObject(value.bulk) + value.package_ != null -> generator.writeObject(value.package_) + value.matrix != null -> generator.writeObject(value.matrix) + value.thresholdTotalAmount != null -> + generator.writeObject(value.thresholdTotalAmount) + value.tieredPackage != null -> generator.writeObject(value.tieredPackage) + value.tieredWithMinimum != null -> + generator.writeObject(value.tieredWithMinimum) + value.groupedTiered != null -> generator.writeObject(value.groupedTiered) + value.tieredPackageWithMinimum != null -> + generator.writeObject(value.tieredPackageWithMinimum) + value.packageWithAllocation != null -> + generator.writeObject(value.packageWithAllocation) + value.unitWithPercent != null -> + generator.writeObject(value.unitWithPercent) + value.matrixWithAllocation != null -> + generator.writeObject(value.matrixWithAllocation) + value.tieredWithProration != null -> + generator.writeObject(value.tieredWithProration) + value.unitWithProration != null -> + generator.writeObject(value.unitWithProration) + value.groupedAllocation != null -> + generator.writeObject(value.groupedAllocation) + value.bulkWithProration != null -> + generator.writeObject(value.bulkWithProration) + value.groupedWithProratedMinimum != null -> + generator.writeObject(value.groupedWithProratedMinimum) + value.groupedWithMeteredMinimum != null -> + generator.writeObject(value.groupedWithMeteredMinimum) + value.groupedWithMinMaxThresholds != null -> + generator.writeObject(value.groupedWithMinMaxThresholds) + value.matrixWithDisplayName != null -> + generator.writeObject(value.matrixWithDisplayName) + value.groupedTieredPackage != null -> + generator.writeObject(value.groupedTieredPackage) + value.maxGroupTieredPackage != null -> + generator.writeObject(value.maxGroupTieredPackage) + value.scalableMatrixWithUnitPricing != null -> + generator.writeObject(value.scalableMatrixWithUnitPricing) + value.scalableMatrixWithTieredPricing != null -> + generator.writeObject(value.scalableMatrixWithTieredPricing) + value.cumulativeGroupedBulk != null -> + generator.writeObject(value.cumulativeGroupedBulk) + value.minimum != null -> generator.writeObject(value.minimum) + value.eventOutput != null -> generator.writeObject(value.eventOutput) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Price") + } + } + } + + class TieredWithProration + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val tieredWithProrationConfig: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("tiered_with_proration_config") + @ExcludeMissing + tieredWithProrationConfig: JsonField = + JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + modelType, + name, + tieredWithProrationConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("tiered_with_proration") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * Configuration for tiered_with_proration pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun tieredWithProrationConfig(): TieredWithProrationConfig = + tieredWithProrationConfig.getRequired("tiered_with_proration_config") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = billableMetricId.getNullable("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + invoiceGroupingKey.getNullable("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [tieredWithProrationConfig]. + * + * Unlike [tieredWithProrationConfig], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("tiered_with_proration_config") + @ExcludeMissing + fun _tieredWithProrationConfig(): JsonField = + tieredWithProrationConfig + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [TieredWithProration]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .name() + * .tieredWithProrationConfig() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [TieredWithProration]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonValue = JsonValue.from("tiered_with_proration") + private var name: JsonField? = null + private var tieredWithProrationConfig: JsonField? = + null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(tieredWithProration: TieredWithProration) = apply { + cadence = tieredWithProration.cadence + itemId = tieredWithProration.itemId + modelType = tieredWithProration.modelType + name = tieredWithProration.name + tieredWithProrationConfig = tieredWithProration.tieredWithProrationConfig + billableMetricId = tieredWithProration.billableMetricId + billedInAdvance = tieredWithProration.billedInAdvance + billingCycleConfiguration = tieredWithProration.billingCycleConfiguration + conversionRate = tieredWithProration.conversionRate + conversionRateConfig = tieredWithProration.conversionRateConfig + currency = tieredWithProration.currency + dimensionalPriceConfiguration = + tieredWithProration.dimensionalPriceConfiguration + externalPriceId = tieredWithProration.externalPriceId + fixedPriceQuantity = tieredWithProration.fixedPriceQuantity + invoiceGroupingKey = tieredWithProration.invoiceGroupingKey + invoicingCycleConfiguration = + tieredWithProration.invoicingCycleConfiguration + metadata = tieredWithProration.metadata + referenceId = tieredWithProration.referenceId + additionalProperties = + tieredWithProration.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("tiered_with_proration") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for tiered_with_proration pricing */ + fun tieredWithProrationConfig( + tieredWithProrationConfig: TieredWithProrationConfig + ) = tieredWithProrationConfig(JsonField.of(tieredWithProrationConfig)) + + /** + * Sets [Builder.tieredWithProrationConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.tieredWithProrationConfig] with a well-typed + * [TieredWithProrationConfig] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun tieredWithProrationConfig( + tieredWithProrationConfig: JsonField + ) = apply { this.tieredWithProrationConfig = tieredWithProrationConfig } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [TieredWithProration]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .name() + * .tieredWithProrationConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TieredWithProration = + TieredWithProration( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + modelType, + checkRequired("name", name), + checkRequired("tieredWithProrationConfig", tieredWithProrationConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TieredWithProration = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + _modelType().let { + if (it != JsonValue.from("tiered_with_proration")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + tieredWithProrationConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + modelType.let { + if (it == JsonValue.from("tiered_with_proration")) 1 else 0 + } + + (if (name.asKnown() == null) 0 else 1) + + (tieredWithProrationConfig.asKnown()?.validity() ?: 0) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") } - "matrix" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(matrix = it, _json = json) } ?: Price(_json = json) + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply } - "threshold_total_amount" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(thresholdTotalAmount = it, _json = json) } - ?: Price(_json = json) + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false } - "tiered_package" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(tieredPackage = it, _json = json) } - ?: Price(_json = json) + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - "tiered_with_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(tieredWithMinimum = it, _json = json) } - ?: Price(_json = json) + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Configuration for tiered_with_proration pricing */ + class TieredWithProrationConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val tiers: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of() + ) : this(tiers, mutableMapOf()) + + /** + * Tiers for rating based on total usage quantities into the specified tier with + * proration + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun tiers(): List = tiers.getRequired("tiers") + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [TieredWithProrationConfig]. + * + * The following fields are required: + * ```kotlin + * .tiers() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [TieredWithProrationConfig]. */ + class Builder internal constructor() { + + private var tiers: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(tieredWithProrationConfig: TieredWithProrationConfig) = + apply { + tiers = tieredWithProrationConfig.tiers.map { it.toMutableList() } + additionalProperties = + tieredWithProrationConfig.additionalProperties.toMutableMap() + } + + /** + * Tiers for rating based on total usage quantities into the specified tier + * with proration + */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } } - "grouped_tiered" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedTiered = it, _json = json) } - ?: Price(_json = json) + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) } - "tiered_package_with_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(tieredPackageWithMinimum = it, _json = json) } - ?: Price(_json = json) + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) } - "package_with_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(packageWithAllocation = it, _json = json) } - ?: Price(_json = json) + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) } - "unit_with_percent" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(unitWithPercent = it, _json = json) } - ?: Price(_json = json) + + /** + * Returns an immutable instance of [TieredWithProrationConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TieredWithProrationConfig = + TieredWithProrationConfig( + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TieredWithProrationConfig = apply { + if (validated) { + return@apply } - "matrix_with_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(matrixWithAllocation = it, _json = json) } - ?: Price(_json = json) + + tiers().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false } - "tiered_with_proration" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(tieredWithProration = it, _json = json) } - ?: Price(_json = json) + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (tiers.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single tiered with proration tier */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val tierLowerBound: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(tierLowerBound, unitAmount, mutableMapOf()) + + /** + * Inclusive tier starting value + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun tierLowerBound(): String = + tierLowerBound.getRequired("tier_lower_bound") + + /** + * Amount per unit + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) } - "unit_with_proration" -> { - return tryDeserialize( - node, - jacksonTypeRef(), + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Tier]. + * + * The following fields are required: + * ```kotlin + * .tierLowerBound() + * .unitAmount() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var tierLowerBound: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(tier: Tier) = apply { + tierLowerBound = tier.tierLowerBound + unitAmount = tier.unitAmount + additionalProperties = tier.additionalProperties.toMutableMap() + } + + /** Inclusive tier starting value */ + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + /** Amount per unit */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```kotlin + * .tierLowerBound() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("tierLowerBound", tierLowerBound), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), ) - ?.let { Price(unitWithProration = it, _json = json) } - ?: Price(_json = json) } - "grouped_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedAllocation = it, _json = json) } - ?: Price(_json = json) + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + tierLowerBound() + unitAmount() + validated = true } - "bulk_with_proration" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(bulkWithProration = it, _json = json) } - ?: Price(_json = json) + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (tierLowerBound.asKnown() == null) 0 else 1) + + (if (unitAmount.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + tierLowerBound == other.tierLowerBound && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties } - "grouped_with_prorated_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedWithProratedMinimum = it, _json = json) } - ?: Price(_json = json) + + private val hashCode: Int by lazy { + Objects.hash(tierLowerBound, unitAmount, additionalProperties) } - "grouped_with_metered_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedWithMeteredMinimum = it, _json = json) } - ?: Price(_json = json) + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - "grouped_with_min_max_thresholds" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedWithMinMaxThresholds = it, _json = json) } - ?: Price(_json = json) + + return other is TieredWithProrationConfig && + tiers == other.tiers && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(tiers, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TieredWithProrationConfig{tiers=$tiers, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() } - "matrix_with_display_name" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(matrixWithDisplayName = it, _json = json) } - ?: Price(_json = json) + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) } - "grouped_tiered_package" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedTieredPackage = it, _json = json) } - ?: Price(_json = json) + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) } - "max_group_tiered_package" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(maxGroupTieredPackage = it, _json = json) } - ?: Price(_json = json) + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) } - "scalable_matrix_with_unit_pricing" -> { - return tryDeserialize( - node, - jacksonTypeRef< - NewSubscriptionScalableMatrixWithUnitPricingPrice - >(), - ) - ?.let { Price(scalableMatrixWithUnitPricing = it, _json = json) } - ?: Price(_json = json) + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply } - "scalable_matrix_with_tiered_pricing" -> { - return tryDeserialize( - node, - jacksonTypeRef< - NewSubscriptionScalableMatrixWithTieredPricingPrice - >(), - ) - ?.let { Price(scalableMatrixWithTieredPricing = it, _json = json) } - ?: Price(_json = json) + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false } - "cumulative_grouped_bulk" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(cumulativeGroupedBulk = it, _json = json) } - ?: Price(_json = json) + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() } - "minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(minimum = it, _json = json) } ?: Price(_json = json) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } + + return other is Metadata && + additionalProperties == other.additionalProperties } - return Price(_json = json) - } - } + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode - internal class Serializer : BaseSerializer(Price::class) { + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } - override fun serialize( - value: Price, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unit != null -> generator.writeObject(value.unit) - value.tiered != null -> generator.writeObject(value.tiered) - value.bulk != null -> generator.writeObject(value.bulk) - value.package_ != null -> generator.writeObject(value.package_) - value.matrix != null -> generator.writeObject(value.matrix) - value.thresholdTotalAmount != null -> - generator.writeObject(value.thresholdTotalAmount) - value.tieredPackage != null -> generator.writeObject(value.tieredPackage) - value.tieredWithMinimum != null -> - generator.writeObject(value.tieredWithMinimum) - value.groupedTiered != null -> generator.writeObject(value.groupedTiered) - value.tieredPackageWithMinimum != null -> - generator.writeObject(value.tieredPackageWithMinimum) - value.packageWithAllocation != null -> - generator.writeObject(value.packageWithAllocation) - value.unitWithPercent != null -> - generator.writeObject(value.unitWithPercent) - value.matrixWithAllocation != null -> - generator.writeObject(value.matrixWithAllocation) - value.tieredWithProration != null -> - generator.writeObject(value.tieredWithProration) - value.unitWithProration != null -> - generator.writeObject(value.unitWithProration) - value.groupedAllocation != null -> - generator.writeObject(value.groupedAllocation) - value.bulkWithProration != null -> - generator.writeObject(value.bulkWithProration) - value.groupedWithProratedMinimum != null -> - generator.writeObject(value.groupedWithProratedMinimum) - value.groupedWithMeteredMinimum != null -> - generator.writeObject(value.groupedWithMeteredMinimum) - value.groupedWithMinMaxThresholds != null -> - generator.writeObject(value.groupedWithMinMaxThresholds) - value.matrixWithDisplayName != null -> - generator.writeObject(value.matrixWithDisplayName) - value.groupedTieredPackage != null -> - generator.writeObject(value.groupedTieredPackage) - value.maxGroupTieredPackage != null -> - generator.writeObject(value.maxGroupTieredPackage) - value.scalableMatrixWithUnitPricing != null -> - generator.writeObject(value.scalableMatrixWithUnitPricing) - value.scalableMatrixWithTieredPricing != null -> - generator.writeObject(value.scalableMatrixWithTieredPricing) - value.cumulativeGroupedBulk != null -> - generator.writeObject(value.cumulativeGroupedBulk) - value.minimum != null -> generator.writeObject(value.minimum) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Price") + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } + + return other is TieredWithProration && + cadence == other.cadence && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + tieredWithProrationConfig == other.tieredWithProrationConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + modelType, + name, + tieredWithProrationConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties, + ) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TieredWithProration{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredWithProrationConfig=$tieredWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class TieredWithProration + class GroupedWithMinMaxThresholds @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, + private val groupedWithMinMaxThresholdsConfig: + JsonField, private val itemId: JsonField, private val modelType: JsonValue, private val name: JsonField, - private val tieredWithProrationConfig: JsonField, private val billableMetricId: JsonField, private val billedInAdvance: JsonField, private val billingCycleConfiguration: JsonField, @@ -12524,6 +15924,11 @@ private constructor( @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), + @JsonProperty("grouped_with_min_max_thresholds_config") + @ExcludeMissing + groupedWithMinMaxThresholdsConfig: + JsonField = + JsonMissing.of(), @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), @@ -12533,10 +15938,6 @@ private constructor( @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("tiered_with_proration_config") - @ExcludeMissing - tieredWithProrationConfig: JsonField = - JsonMissing.of(), @JsonProperty("billable_metric_id") @ExcludeMissing billableMetricId: JsonField = JsonMissing.of(), @@ -12581,10 +15982,10 @@ private constructor( referenceId: JsonField = JsonMissing.of(), ) : this( cadence, + groupedWithMinMaxThresholdsConfig, itemId, modelType, name, - tieredWithProrationConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -12610,6 +16011,18 @@ private constructor( */ fun cadence(): Cadence = cadence.getRequired("cadence") + /** + * Configuration for grouped_with_min_max_thresholds pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupedWithMinMaxThresholdsConfig(): GroupedWithMinMaxThresholdsConfig = + groupedWithMinMaxThresholdsConfig.getRequired( + "grouped_with_min_max_thresholds_config" + ) + /** * The id of the item the price will be associated with. * @@ -12624,7 +16037,7 @@ private constructor( * * Expected to always return the following: * ```kotlin - * JsonValue.from("tiered_with_proration") + * JsonValue.from("grouped_with_min_max_thresholds") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -12641,16 +16054,6 @@ private constructor( */ fun name(): String = name.getRequired("name") - /** - * Configuration for tiered_with_proration pricing - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun tieredWithProrationConfig(): TieredWithProrationConfig = - tieredWithProrationConfig.getRequired("tiered_with_proration_config") - /** * The id of the billable metric for the price. Only needed if the price is * usage-based. @@ -12780,6 +16183,17 @@ private constructor( @ExcludeMissing fun _cadence(): JsonField = cadence + /** + * Returns the raw JSON value of [groupedWithMinMaxThresholdsConfig]. + * + * Unlike [groupedWithMinMaxThresholdsConfig], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("grouped_with_min_max_thresholds_config") + @ExcludeMissing + fun _groupedWithMinMaxThresholdsConfig(): + JsonField = groupedWithMinMaxThresholdsConfig + /** * Returns the raw JSON value of [itemId]. * @@ -12796,17 +16210,6 @@ private constructor( */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - /** - * Returns the raw JSON value of [tieredWithProrationConfig]. - * - * Unlike [tieredWithProrationConfig], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("tiered_with_proration_config") - @ExcludeMissing - fun _tieredWithProrationConfig(): JsonField = - tieredWithProrationConfig - /** * Returns the raw JSON value of [billableMetricId]. * @@ -12956,28 +16359,30 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [TieredWithProration]. + * [GroupedWithMinMaxThresholds]. * * The following fields are required: * ```kotlin * .cadence() + * .groupedWithMinMaxThresholdsConfig() * .itemId() * .name() - * .tieredWithProrationConfig() * ``` */ fun builder() = Builder() } - /** A builder for [TieredWithProration]. */ + /** A builder for [GroupedWithMinMaxThresholds]. */ class Builder internal constructor() { private var cadence: JsonField? = null + private var groupedWithMinMaxThresholdsConfig: + JsonField? = + null private var itemId: JsonField? = null - private var modelType: JsonValue = JsonValue.from("tiered_with_proration") + private var modelType: JsonValue = + JsonValue.from("grouped_with_min_max_thresholds") private var name: JsonField? = null - private var tieredWithProrationConfig: JsonField? = - null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() private var billingCycleConfiguration: JsonField = @@ -12999,30 +16404,33 @@ private constructor( private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(tieredWithProration: TieredWithProration) = apply { - cadence = tieredWithProration.cadence - itemId = tieredWithProration.itemId - modelType = tieredWithProration.modelType - name = tieredWithProration.name - tieredWithProrationConfig = tieredWithProration.tieredWithProrationConfig - billableMetricId = tieredWithProration.billableMetricId - billedInAdvance = tieredWithProration.billedInAdvance - billingCycleConfiguration = tieredWithProration.billingCycleConfiguration - conversionRate = tieredWithProration.conversionRate - conversionRateConfig = tieredWithProration.conversionRateConfig - currency = tieredWithProration.currency - dimensionalPriceConfiguration = - tieredWithProration.dimensionalPriceConfiguration - externalPriceId = tieredWithProration.externalPriceId - fixedPriceQuantity = tieredWithProration.fixedPriceQuantity - invoiceGroupingKey = tieredWithProration.invoiceGroupingKey - invoicingCycleConfiguration = - tieredWithProration.invoicingCycleConfiguration - metadata = tieredWithProration.metadata - referenceId = tieredWithProration.referenceId - additionalProperties = - tieredWithProration.additionalProperties.toMutableMap() - } + internal fun from(groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds) = + apply { + cadence = groupedWithMinMaxThresholds.cadence + groupedWithMinMaxThresholdsConfig = + groupedWithMinMaxThresholds.groupedWithMinMaxThresholdsConfig + itemId = groupedWithMinMaxThresholds.itemId + modelType = groupedWithMinMaxThresholds.modelType + name = groupedWithMinMaxThresholds.name + billableMetricId = groupedWithMinMaxThresholds.billableMetricId + billedInAdvance = groupedWithMinMaxThresholds.billedInAdvance + billingCycleConfiguration = + groupedWithMinMaxThresholds.billingCycleConfiguration + conversionRate = groupedWithMinMaxThresholds.conversionRate + conversionRateConfig = groupedWithMinMaxThresholds.conversionRateConfig + currency = groupedWithMinMaxThresholds.currency + dimensionalPriceConfiguration = + groupedWithMinMaxThresholds.dimensionalPriceConfiguration + externalPriceId = groupedWithMinMaxThresholds.externalPriceId + fixedPriceQuantity = groupedWithMinMaxThresholds.fixedPriceQuantity + invoiceGroupingKey = groupedWithMinMaxThresholds.invoiceGroupingKey + invoicingCycleConfiguration = + groupedWithMinMaxThresholds.invoicingCycleConfiguration + metadata = groupedWithMinMaxThresholds.metadata + referenceId = groupedWithMinMaxThresholds.referenceId + additionalProperties = + groupedWithMinMaxThresholds.additionalProperties.toMutableMap() + } /** The cadence to bill for this price on. */ fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) @@ -13034,7 +16442,30 @@ private constructor( * instead. This method is primarily for setting the field to an undocumented or * not yet supported value. */ - fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** Configuration for grouped_with_min_max_thresholds pricing */ + fun groupedWithMinMaxThresholdsConfig( + groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + ) = + groupedWithMinMaxThresholdsConfig( + JsonField.of(groupedWithMinMaxThresholdsConfig) + ) + + /** + * Sets [Builder.groupedWithMinMaxThresholdsConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.groupedWithMinMaxThresholdsConfig] with a + * well-typed [GroupedWithMinMaxThresholdsConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun groupedWithMinMaxThresholdsConfig( + groupedWithMinMaxThresholdsConfig: + JsonField + ) = apply { + this.groupedWithMinMaxThresholdsConfig = groupedWithMinMaxThresholdsConfig + } /** The id of the item the price will be associated with. */ fun itemId(itemId: String) = itemId(JsonField.of(itemId)) @@ -13054,7 +16485,7 @@ private constructor( * It is usually unnecessary to call this method because the field defaults to * the following: * ```kotlin - * JsonValue.from("tiered_with_proration") + * JsonValue.from("grouped_with_min_max_thresholds") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -13074,22 +16505,6 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } - /** Configuration for tiered_with_proration pricing */ - fun tieredWithProrationConfig( - tieredWithProrationConfig: TieredWithProrationConfig - ) = tieredWithProrationConfig(JsonField.of(tieredWithProrationConfig)) - - /** - * Sets [Builder.tieredWithProrationConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.tieredWithProrationConfig] with a well-typed - * [TieredWithProrationConfig] value instead. This method is primarily for - * setting the field to an undocumented or not yet supported value. - */ - fun tieredWithProrationConfig( - tieredWithProrationConfig: JsonField - ) = apply { this.tieredWithProrationConfig = tieredWithProrationConfig } - /** * The id of the billable metric for the price. Only needed if the price is * usage-based. @@ -13419,27 +16834,30 @@ private constructor( } /** - * Returns an immutable instance of [TieredWithProration]. + * Returns an immutable instance of [GroupedWithMinMaxThresholds]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```kotlin * .cadence() + * .groupedWithMinMaxThresholdsConfig() * .itemId() * .name() - * .tieredWithProrationConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): TieredWithProration = - TieredWithProration( + fun build(): GroupedWithMinMaxThresholds = + GroupedWithMinMaxThresholds( checkRequired("cadence", cadence), + checkRequired( + "groupedWithMinMaxThresholdsConfig", + groupedWithMinMaxThresholdsConfig, + ), checkRequired("itemId", itemId), modelType, checkRequired("name", name), - checkRequired("tieredWithProrationConfig", tieredWithProrationConfig), billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -13459,20 +16877,20 @@ private constructor( private var validated: Boolean = false - fun validate(): TieredWithProration = apply { + fun validate(): GroupedWithMinMaxThresholds = apply { if (validated) { return@apply } cadence().validate() + groupedWithMinMaxThresholdsConfig().validate() itemId() _modelType().let { - if (it != JsonValue.from("tiered_with_proration")) { + if (it != JsonValue.from("grouped_with_min_max_thresholds")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } name() - tieredWithProrationConfig().validate() billableMetricId() billedInAdvance() billingCycleConfiguration()?.validate() @@ -13505,12 +16923,12 @@ private constructor( */ internal fun validity(): Int = (cadence.asKnown()?.validity() ?: 0) + + (groupedWithMinMaxThresholdsConfig.asKnown()?.validity() ?: 0) + (if (itemId.asKnown() == null) 0 else 1) + modelType.let { - if (it == JsonValue.from("tiered_with_proration")) 1 else 0 + if (it == JsonValue.from("grouped_with_min_max_thresholds")) 1 else 0 } + (if (name.asKnown() == null) 0 else 1) + - (tieredWithProrationConfig.asKnown()?.validity() ?: 0) + (if (billableMetricId.asKnown() == null) 0 else 1) + (if (billedInAdvance.asKnown() == null) 0 else 1) + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + @@ -13622,220 +17040,34 @@ private constructor( when (this) { ANNUAL -> Known.ANNUAL SEMI_ANNUAL -> Known.SEMI_ANNUAL - MONTHLY -> Known.MONTHLY - QUARTERLY -> Known.QUARTERLY - ONE_TIME -> Known.ONE_TIME - CUSTOM -> Known.CUSTOM - else -> throw OrbInvalidDataException("Unknown Cadence: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString() - ?: throw OrbInvalidDataException("Value is not a String") - - private var validated: Boolean = false - - fun validate(): Cadence = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Cadence && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** Configuration for tiered_with_proration pricing */ - class TieredWithProrationConfig - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val tiers: JsonField>, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("tiers") - @ExcludeMissing - tiers: JsonField> = JsonMissing.of() - ) : this(tiers, mutableMapOf()) - - /** - * Tiers for rating based on total usage quantities into the specified tier with - * proration - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun tiers(): List = tiers.getRequired("tiers") - - /** - * Returns the raw JSON value of [tiers]. - * - * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("tiers") - @ExcludeMissing - fun _tiers(): JsonField> = tiers - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [TieredWithProrationConfig]. - * - * The following fields are required: - * ```kotlin - * .tiers() - * ``` - */ - fun builder() = Builder() - } - - /** A builder for [TieredWithProrationConfig]. */ - class Builder internal constructor() { - - private var tiers: JsonField>? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - internal fun from(tieredWithProrationConfig: TieredWithProrationConfig) = - apply { - tiers = tieredWithProrationConfig.tiers.map { it.toMutableList() } - additionalProperties = - tieredWithProrationConfig.additionalProperties.toMutableMap() - } - - /** - * Tiers for rating based on total usage quantities into the specified tier - * with proration - */ - fun tiers(tiers: List) = tiers(JsonField.of(tiers)) - - /** - * Sets [Builder.tiers] to an arbitrary JSON value. - * - * You should usually call [Builder.tiers] with a well-typed `List` - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun tiers(tiers: JsonField>) = apply { - this.tiers = tiers.map { it.toMutableList() } - } - - /** - * Adds a single [Tier] to [tiers]. - * - * @throws IllegalStateException if the field was previously set to a - * non-list. - */ - fun addTier(tier: Tier) = apply { - tiers = - (tiers ?: JsonField.of(mutableListOf())).also { - checkKnown("tiers", it).add(tier) - } - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [TieredWithProrationConfig]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```kotlin - * .tiers() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): TieredWithProrationConfig = - TieredWithProrationConfig( - checkRequired("tiers", tiers).map { it.toImmutable() }, - additionalProperties.toMutableMap(), - ) - } + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") private var validated: Boolean = false - fun validate(): TieredWithProrationConfig = apply { + fun validate(): Cadence = apply { if (validated) { return@apply } - tiers().forEach { it.validate() } + known() validated = true } @@ -13853,248 +17085,343 @@ private constructor( * * Used for best match union deserialization. */ - internal fun validity(): Int = - (tiers.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - /** Configuration for a single tiered with proration tier */ - class Tier - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val tierLowerBound: JsonField, - private val unitAmount: JsonField, - private val additionalProperties: MutableMap, - ) { + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - @JsonCreator - private constructor( - @JsonProperty("tier_lower_bound") - @ExcludeMissing - tierLowerBound: JsonField = JsonMissing.of(), - @JsonProperty("unit_amount") - @ExcludeMissing - unitAmount: JsonField = JsonMissing.of(), - ) : this(tierLowerBound, unitAmount, mutableMapOf()) + return other is Cadence && value == other.value + } - /** - * Inclusive tier starting value - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type - * or is unexpectedly missing or null (e.g. if the server responded with - * an unexpected value). - */ - fun tierLowerBound(): String = - tierLowerBound.getRequired("tier_lower_bound") + override fun hashCode() = value.hashCode() - /** - * Amount per unit - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type - * or is unexpectedly missing or null (e.g. if the server responded with - * an unexpected value). - */ - fun unitAmount(): String = unitAmount.getRequired("unit_amount") + override fun toString() = value.toString() + } - /** - * Returns the raw JSON value of [tierLowerBound]. - * - * Unlike [tierLowerBound], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("tier_lower_bound") - @ExcludeMissing - fun _tierLowerBound(): JsonField = tierLowerBound + /** Configuration for grouped_with_min_max_thresholds pricing */ + class GroupedWithMinMaxThresholdsConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val groupingKey: JsonField, + private val maximumCharge: JsonField, + private val minimumCharge: JsonField, + private val perUnitRate: JsonField, + private val additionalProperties: MutableMap, + ) { - /** - * Returns the raw JSON value of [unitAmount]. - * - * Unlike [unitAmount], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("unit_amount") + @JsonCreator + private constructor( + @JsonProperty("grouping_key") @ExcludeMissing - fun _unitAmount(): JsonField = unitAmount + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("maximum_charge") + @ExcludeMissing + maximumCharge: JsonField = JsonMissing.of(), + @JsonProperty("minimum_charge") + @ExcludeMissing + minimumCharge: JsonField = JsonMissing.of(), + @JsonProperty("per_unit_rate") + @ExcludeMissing + perUnitRate: JsonField = JsonMissing.of(), + ) : this(groupingKey, maximumCharge, minimumCharge, perUnitRate, mutableMapOf()) - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** + * The event property used to group before applying thresholds + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** + * The maximum amount to charge each group + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun maximumCharge(): String = maximumCharge.getRequired("maximum_charge") - fun toBuilder() = Builder().from(this) + /** + * The minimum amount to charge each group, regardless of usage + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun minimumCharge(): String = minimumCharge.getRequired("minimum_charge") - companion object { + /** + * The base price charged per group + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun perUnitRate(): String = perUnitRate.getRequired("per_unit_rate") - /** - * Returns a mutable builder for constructing an instance of [Tier]. - * - * The following fields are required: - * ```kotlin - * .tierLowerBound() - * .unitAmount() - * ``` - */ - fun builder() = Builder() - } + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey - /** A builder for [Tier]. */ - class Builder internal constructor() { + /** + * Returns the raw JSON value of [maximumCharge]. + * + * Unlike [maximumCharge], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("maximum_charge") + @ExcludeMissing + fun _maximumCharge(): JsonField = maximumCharge - private var tierLowerBound: JsonField? = null - private var unitAmount: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() + /** + * Returns the raw JSON value of [minimumCharge]. + * + * Unlike [minimumCharge], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("minimum_charge") + @ExcludeMissing + fun _minimumCharge(): JsonField = minimumCharge - internal fun from(tier: Tier) = apply { - tierLowerBound = tier.tierLowerBound - unitAmount = tier.unitAmount - additionalProperties = tier.additionalProperties.toMutableMap() - } + /** + * Returns the raw JSON value of [perUnitRate]. + * + * Unlike [perUnitRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("per_unit_rate") + @ExcludeMissing + fun _perUnitRate(): JsonField = perUnitRate + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [GroupedWithMinMaxThresholdsConfig]. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .maximumCharge() + * .minimumCharge() + * .perUnitRate() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [GroupedWithMinMaxThresholdsConfig]. */ + class Builder internal constructor() { + + private var groupingKey: JsonField? = null + private var maximumCharge: JsonField? = null + private var minimumCharge: JsonField? = null + private var perUnitRate: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from( + groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + ) = apply { + groupingKey = groupedWithMinMaxThresholdsConfig.groupingKey + maximumCharge = groupedWithMinMaxThresholdsConfig.maximumCharge + minimumCharge = groupedWithMinMaxThresholdsConfig.minimumCharge + perUnitRate = groupedWithMinMaxThresholdsConfig.perUnitRate + additionalProperties = + groupedWithMinMaxThresholdsConfig.additionalProperties + .toMutableMap() + } - /** Inclusive tier starting value */ - fun tierLowerBound(tierLowerBound: String) = - tierLowerBound(JsonField.of(tierLowerBound)) + /** The event property used to group before applying thresholds */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) - /** - * Sets [Builder.tierLowerBound] to an arbitrary JSON value. - * - * You should usually call [Builder.tierLowerBound] with a well-typed - * [String] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun tierLowerBound(tierLowerBound: JsonField) = apply { - this.tierLowerBound = tierLowerBound - } + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } - /** Amount per unit */ - fun unitAmount(unitAmount: String) = - unitAmount(JsonField.of(unitAmount)) + /** The maximum amount to charge each group */ + fun maximumCharge(maximumCharge: String) = + maximumCharge(JsonField.of(maximumCharge)) - /** - * Sets [Builder.unitAmount] to an arbitrary JSON value. - * - * You should usually call [Builder.unitAmount] with a well-typed - * [String] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun unitAmount(unitAmount: JsonField) = apply { - this.unitAmount = unitAmount - } + /** + * Sets [Builder.maximumCharge] to an arbitrary JSON value. + * + * You should usually call [Builder.maximumCharge] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun maximumCharge(maximumCharge: JsonField) = apply { + this.maximumCharge = maximumCharge + } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** The minimum amount to charge each group, regardless of usage */ + fun minimumCharge(minimumCharge: String) = + minimumCharge(JsonField.of(minimumCharge)) - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * Sets [Builder.minimumCharge] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumCharge] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun minimumCharge(minimumCharge: JsonField) = apply { + this.minimumCharge = minimumCharge + } - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + /** The base price charged per group */ + fun perUnitRate(perUnitRate: String) = + perUnitRate(JsonField.of(perUnitRate)) - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + /** + * Sets [Builder.perUnitRate] to an arbitrary JSON value. + * + * You should usually call [Builder.perUnitRate] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun perUnitRate(perUnitRate: JsonField) = apply { + this.perUnitRate = perUnitRate + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) } - /** - * Returns an immutable instance of [Tier]. - * - * Further updates to this [Builder] will not mutate the returned - * instance. - * - * The following fields are required: - * ```kotlin - * .tierLowerBound() - * .unitAmount() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Tier = - Tier( - checkRequired("tierLowerBound", tierLowerBound), - checkRequired("unitAmount", unitAmount), - additionalProperties.toMutableMap(), - ) + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) } - private var validated: Boolean = false - - fun validate(): Tier = apply { - if (validated) { - return@apply - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - tierLowerBound() - unitAmount() - validated = true + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } /** - * Returns a score indicating how many valid values are contained in this - * object recursively. + * Returns an immutable instance of [GroupedWithMinMaxThresholdsConfig]. * - * Used for best match union deserialization. + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .maximumCharge() + * .minimumCharge() + * .perUnitRate() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ - internal fun validity(): Int = - (if (tierLowerBound.asKnown() == null) 0 else 1) + - (if (unitAmount.asKnown() == null) 0 else 1) + fun build(): GroupedWithMinMaxThresholdsConfig = + GroupedWithMinMaxThresholdsConfig( + checkRequired("groupingKey", groupingKey), + checkRequired("maximumCharge", maximumCharge), + checkRequired("minimumCharge", minimumCharge), + checkRequired("perUnitRate", perUnitRate), + additionalProperties.toMutableMap(), + ) + } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + private var validated: Boolean = false - return other is Tier && - tierLowerBound == other.tierLowerBound && - unitAmount == other.unitAmount && - additionalProperties == other.additionalProperties + fun validate(): GroupedWithMinMaxThresholdsConfig = apply { + if (validated) { + return@apply } - private val hashCode: Int by lazy { - Objects.hash(tierLowerBound, unitAmount, additionalProperties) - } + groupingKey() + maximumCharge() + minimumCharge() + perUnitRate() + validated = true + } - override fun hashCode(): Int = hashCode + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - override fun toString() = - "Tier{tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" - } + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (groupingKey.asKnown() == null) 0 else 1) + + (if (maximumCharge.asKnown() == null) 0 else 1) + + (if (minimumCharge.asKnown() == null) 0 else 1) + + (if (perUnitRate.asKnown() == null) 0 else 1) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is TieredWithProrationConfig && - tiers == other.tiers && + return other is GroupedWithMinMaxThresholdsConfig && + groupingKey == other.groupingKey && + maximumCharge == other.maximumCharge && + minimumCharge == other.minimumCharge && + perUnitRate == other.perUnitRate && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(tiers, additionalProperties) } + private val hashCode: Int by lazy { + Objects.hash( + groupingKey, + maximumCharge, + minimumCharge, + perUnitRate, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode override fun toString() = - "TieredWithProrationConfig{tiers=$tiers, additionalProperties=$additionalProperties}" + "GroupedWithMinMaxThresholdsConfig{groupingKey=$groupingKey, maximumCharge=$maximumCharge, minimumCharge=$minimumCharge, perUnitRate=$perUnitRate, additionalProperties=$additionalProperties}" } /** @@ -14211,12 +17538,13 @@ private constructor( return true } - return other is TieredWithProration && + return other is GroupedWithMinMaxThresholds && cadence == other.cadence && + groupedWithMinMaxThresholdsConfig == + other.groupedWithMinMaxThresholdsConfig && itemId == other.itemId && modelType == other.modelType && name == other.name && - tieredWithProrationConfig == other.tieredWithProrationConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && @@ -14236,10 +17564,10 @@ private constructor( private val hashCode: Int by lazy { Objects.hash( cadence, + groupedWithMinMaxThresholdsConfig, itemId, modelType, name, - tieredWithProrationConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -14260,15 +17588,14 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "TieredWithProration{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredWithProrationConfig=$tieredWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "GroupedWithMinMaxThresholds{cadence=$cadence, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class GroupedWithMinMaxThresholds + class EventOutput @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, - private val groupedWithMinMaxThresholdsConfig: - JsonField, + private val eventOutputConfig: JsonField, private val itemId: JsonField, private val modelType: JsonValue, private val name: JsonField, @@ -14293,12 +17620,10 @@ private constructor( private constructor( @JsonProperty("cadence") @ExcludeMissing - cadence: JsonField = JsonMissing.of(), - @JsonProperty("grouped_with_min_max_thresholds_config") - @ExcludeMissing - groupedWithMinMaxThresholdsConfig: - JsonField = - JsonMissing.of(), + cadence: JsonField = JsonMissing.of(), + @JsonProperty("event_output_config") + @ExcludeMissing + eventOutputConfig: JsonField = JsonMissing.of(), @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), @@ -14352,7 +17677,7 @@ private constructor( referenceId: JsonField = JsonMissing.of(), ) : this( cadence, - groupedWithMinMaxThresholdsConfig, + eventOutputConfig, itemId, modelType, name, @@ -14382,16 +17707,14 @@ private constructor( fun cadence(): Cadence = cadence.getRequired("cadence") /** - * Configuration for grouped_with_min_max_thresholds pricing + * Configuration for event_output pricing * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected * value). */ - fun groupedWithMinMaxThresholdsConfig(): GroupedWithMinMaxThresholdsConfig = - groupedWithMinMaxThresholdsConfig.getRequired( - "grouped_with_min_max_thresholds_config" - ) + fun eventOutputConfig(): EventOutputConfig = + eventOutputConfig.getRequired("event_output_config") /** * The id of the item the price will be associated with. @@ -14407,7 +17730,7 @@ private constructor( * * Expected to always return the following: * ```kotlin - * JsonValue.from("grouped_with_min_max_thresholds") + * JsonValue.from("event_output") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -14554,15 +17877,14 @@ private constructor( fun _cadence(): JsonField = cadence /** - * Returns the raw JSON value of [groupedWithMinMaxThresholdsConfig]. + * Returns the raw JSON value of [eventOutputConfig]. * - * Unlike [groupedWithMinMaxThresholdsConfig], this method doesn't throw if the JSON - * field has an unexpected type. + * Unlike [eventOutputConfig], this method doesn't throw if the JSON field has an + * unexpected type. */ - @JsonProperty("grouped_with_min_max_thresholds_config") + @JsonProperty("event_output_config") @ExcludeMissing - fun _groupedWithMinMaxThresholdsConfig(): - JsonField = groupedWithMinMaxThresholdsConfig + fun _eventOutputConfig(): JsonField = eventOutputConfig /** * Returns the raw JSON value of [itemId]. @@ -14728,13 +18050,12 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [GroupedWithMinMaxThresholds]. + * Returns a mutable builder for constructing an instance of [EventOutput]. * * The following fields are required: * ```kotlin * .cadence() - * .groupedWithMinMaxThresholdsConfig() + * .eventOutputConfig() * .itemId() * .name() * ``` @@ -14742,16 +18063,13 @@ private constructor( fun builder() = Builder() } - /** A builder for [GroupedWithMinMaxThresholds]. */ + /** A builder for [EventOutput]. */ class Builder internal constructor() { private var cadence: JsonField? = null - private var groupedWithMinMaxThresholdsConfig: - JsonField? = - null + private var eventOutputConfig: JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonValue = - JsonValue.from("grouped_with_min_max_thresholds") + private var modelType: JsonValue = JsonValue.from("event_output") private var name: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() @@ -14774,33 +18092,27 @@ private constructor( private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds) = - apply { - cadence = groupedWithMinMaxThresholds.cadence - groupedWithMinMaxThresholdsConfig = - groupedWithMinMaxThresholds.groupedWithMinMaxThresholdsConfig - itemId = groupedWithMinMaxThresholds.itemId - modelType = groupedWithMinMaxThresholds.modelType - name = groupedWithMinMaxThresholds.name - billableMetricId = groupedWithMinMaxThresholds.billableMetricId - billedInAdvance = groupedWithMinMaxThresholds.billedInAdvance - billingCycleConfiguration = - groupedWithMinMaxThresholds.billingCycleConfiguration - conversionRate = groupedWithMinMaxThresholds.conversionRate - conversionRateConfig = groupedWithMinMaxThresholds.conversionRateConfig - currency = groupedWithMinMaxThresholds.currency - dimensionalPriceConfiguration = - groupedWithMinMaxThresholds.dimensionalPriceConfiguration - externalPriceId = groupedWithMinMaxThresholds.externalPriceId - fixedPriceQuantity = groupedWithMinMaxThresholds.fixedPriceQuantity - invoiceGroupingKey = groupedWithMinMaxThresholds.invoiceGroupingKey - invoicingCycleConfiguration = - groupedWithMinMaxThresholds.invoicingCycleConfiguration - metadata = groupedWithMinMaxThresholds.metadata - referenceId = groupedWithMinMaxThresholds.referenceId - additionalProperties = - groupedWithMinMaxThresholds.additionalProperties.toMutableMap() - } + internal fun from(eventOutput: EventOutput) = apply { + cadence = eventOutput.cadence + eventOutputConfig = eventOutput.eventOutputConfig + itemId = eventOutput.itemId + modelType = eventOutput.modelType + name = eventOutput.name + billableMetricId = eventOutput.billableMetricId + billedInAdvance = eventOutput.billedInAdvance + billingCycleConfiguration = eventOutput.billingCycleConfiguration + conversionRate = eventOutput.conversionRate + conversionRateConfig = eventOutput.conversionRateConfig + currency = eventOutput.currency + dimensionalPriceConfiguration = eventOutput.dimensionalPriceConfiguration + externalPriceId = eventOutput.externalPriceId + fixedPriceQuantity = eventOutput.fixedPriceQuantity + invoiceGroupingKey = eventOutput.invoiceGroupingKey + invoicingCycleConfiguration = eventOutput.invoicingCycleConfiguration + metadata = eventOutput.metadata + referenceId = eventOutput.referenceId + additionalProperties = eventOutput.additionalProperties.toMutableMap() + } /** The cadence to bill for this price on. */ fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) @@ -14814,27 +18126,19 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - /** Configuration for grouped_with_min_max_thresholds pricing */ - fun groupedWithMinMaxThresholdsConfig( - groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig - ) = - groupedWithMinMaxThresholdsConfig( - JsonField.of(groupedWithMinMaxThresholdsConfig) - ) + /** Configuration for event_output pricing */ + fun eventOutputConfig(eventOutputConfig: EventOutputConfig) = + eventOutputConfig(JsonField.of(eventOutputConfig)) /** - * Sets [Builder.groupedWithMinMaxThresholdsConfig] to an arbitrary JSON value. + * Sets [Builder.eventOutputConfig] to an arbitrary JSON value. * - * You should usually call [Builder.groupedWithMinMaxThresholdsConfig] with a - * well-typed [GroupedWithMinMaxThresholdsConfig] value instead. This method is - * primarily for setting the field to an undocumented or not yet supported - * value. + * You should usually call [Builder.eventOutputConfig] with a well-typed + * [EventOutputConfig] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. */ - fun groupedWithMinMaxThresholdsConfig( - groupedWithMinMaxThresholdsConfig: - JsonField - ) = apply { - this.groupedWithMinMaxThresholdsConfig = groupedWithMinMaxThresholdsConfig + fun eventOutputConfig(eventOutputConfig: JsonField) = apply { + this.eventOutputConfig = eventOutputConfig } /** The id of the item the price will be associated with. */ @@ -14855,7 +18159,7 @@ private constructor( * It is usually unnecessary to call this method because the field defaults to * the following: * ```kotlin - * JsonValue.from("grouped_with_min_max_thresholds") + * JsonValue.from("event_output") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -15204,27 +18508,24 @@ private constructor( } /** - * Returns an immutable instance of [GroupedWithMinMaxThresholds]. + * Returns an immutable instance of [EventOutput]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```kotlin * .cadence() - * .groupedWithMinMaxThresholdsConfig() + * .eventOutputConfig() * .itemId() * .name() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): GroupedWithMinMaxThresholds = - GroupedWithMinMaxThresholds( + fun build(): EventOutput = + EventOutput( checkRequired("cadence", cadence), - checkRequired( - "groupedWithMinMaxThresholdsConfig", - groupedWithMinMaxThresholdsConfig, - ), + checkRequired("eventOutputConfig", eventOutputConfig), checkRequired("itemId", itemId), modelType, checkRequired("name", name), @@ -15247,16 +18548,16 @@ private constructor( private var validated: Boolean = false - fun validate(): GroupedWithMinMaxThresholds = apply { + fun validate(): EventOutput = apply { if (validated) { return@apply } cadence().validate() - groupedWithMinMaxThresholdsConfig().validate() + eventOutputConfig().validate() itemId() _modelType().let { - if (it != JsonValue.from("grouped_with_min_max_thresholds")) { + if (it != JsonValue.from("event_output")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } @@ -15293,11 +18594,9 @@ private constructor( */ internal fun validity(): Int = (cadence.asKnown()?.validity() ?: 0) + - (groupedWithMinMaxThresholdsConfig.asKnown()?.validity() ?: 0) + + (eventOutputConfig.asKnown()?.validity() ?: 0) + (if (itemId.asKnown() == null) 0 else 1) + - modelType.let { - if (it == JsonValue.from("grouped_with_min_max_thresholds")) 1 else 0 - } + + modelType.let { if (it == JsonValue.from("event_output")) 1 else 0 } + (if (name.asKnown() == null) 0 else 1) + (if (billableMetricId.asKnown() == null) 0 else 1) + (if (billedInAdvance.asKnown() == null) 0 else 1) + @@ -15470,68 +18769,52 @@ private constructor( override fun toString() = value.toString() } - /** Configuration for grouped_with_min_max_thresholds pricing */ - class GroupedWithMinMaxThresholdsConfig + /** Configuration for event_output pricing */ + class EventOutputConfig @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( + private val unitRatingKey: JsonField, private val groupingKey: JsonField, - private val maximumCharge: JsonField, - private val minimumCharge: JsonField, - private val perUnitRate: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( + @JsonProperty("unit_rating_key") + @ExcludeMissing + unitRatingKey: JsonField = JsonMissing.of(), @JsonProperty("grouping_key") @ExcludeMissing groupingKey: JsonField = JsonMissing.of(), - @JsonProperty("maximum_charge") - @ExcludeMissing - maximumCharge: JsonField = JsonMissing.of(), - @JsonProperty("minimum_charge") - @ExcludeMissing - minimumCharge: JsonField = JsonMissing.of(), - @JsonProperty("per_unit_rate") - @ExcludeMissing - perUnitRate: JsonField = JsonMissing.of(), - ) : this(groupingKey, maximumCharge, minimumCharge, perUnitRate, mutableMapOf()) - - /** - * The event property used to group before applying thresholds - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun groupingKey(): String = groupingKey.getRequired("grouping_key") + ) : this(unitRatingKey, groupingKey, mutableMapOf()) /** - * The maximum amount to charge each group + * The key in the event data to extract the unit rate from. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). */ - fun maximumCharge(): String = maximumCharge.getRequired("maximum_charge") + fun unitRatingKey(): String = unitRatingKey.getRequired("unit_rating_key") /** - * The minimum amount to charge each group, regardless of usage + * An optional key in the event data to group by (e.g., event ID). All events + * will also be grouped by their unit rate. * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). */ - fun minimumCharge(): String = minimumCharge.getRequired("minimum_charge") + fun groupingKey(): String? = groupingKey.getNullable("grouping_key") /** - * The base price charged per group + * Returns the raw JSON value of [unitRatingKey]. * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). + * Unlike [unitRatingKey], this method doesn't throw if the JSON field has an + * unexpected type. */ - fun perUnitRate(): String = perUnitRate.getRequired("per_unit_rate") + @JsonProperty("unit_rating_key") + @ExcludeMissing + fun _unitRatingKey(): JsonField = unitRatingKey /** * Returns the raw JSON value of [groupingKey]. @@ -15543,36 +18826,6 @@ private constructor( @ExcludeMissing fun _groupingKey(): JsonField = groupingKey - /** - * Returns the raw JSON value of [maximumCharge]. - * - * Unlike [maximumCharge], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("maximum_charge") - @ExcludeMissing - fun _maximumCharge(): JsonField = maximumCharge - - /** - * Returns the raw JSON value of [minimumCharge]. - * - * Unlike [minimumCharge], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("minimum_charge") - @ExcludeMissing - fun _minimumCharge(): JsonField = minimumCharge - - /** - * Returns the raw JSON value of [perUnitRate]. - * - * Unlike [perUnitRate], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("per_unit_rate") - @ExcludeMissing - fun _perUnitRate(): JsonField = perUnitRate - @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -15589,99 +18842,62 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [GroupedWithMinMaxThresholdsConfig]. + * [EventOutputConfig]. * * The following fields are required: * ```kotlin - * .groupingKey() - * .maximumCharge() - * .minimumCharge() - * .perUnitRate() + * .unitRatingKey() * ``` */ fun builder() = Builder() } - /** A builder for [GroupedWithMinMaxThresholdsConfig]. */ + /** A builder for [EventOutputConfig]. */ class Builder internal constructor() { - private var groupingKey: JsonField? = null - private var maximumCharge: JsonField? = null - private var minimumCharge: JsonField? = null - private var perUnitRate: JsonField? = null + private var unitRatingKey: JsonField? = null + private var groupingKey: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() - internal fun from( - groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig - ) = apply { - groupingKey = groupedWithMinMaxThresholdsConfig.groupingKey - maximumCharge = groupedWithMinMaxThresholdsConfig.maximumCharge - minimumCharge = groupedWithMinMaxThresholdsConfig.minimumCharge - perUnitRate = groupedWithMinMaxThresholdsConfig.perUnitRate + internal fun from(eventOutputConfig: EventOutputConfig) = apply { + unitRatingKey = eventOutputConfig.unitRatingKey + groupingKey = eventOutputConfig.groupingKey additionalProperties = - groupedWithMinMaxThresholdsConfig.additionalProperties - .toMutableMap() - } - - /** The event property used to group before applying thresholds */ - fun groupingKey(groupingKey: String) = - groupingKey(JsonField.of(groupingKey)) - - /** - * Sets [Builder.groupingKey] to an arbitrary JSON value. - * - * You should usually call [Builder.groupingKey] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun groupingKey(groupingKey: JsonField) = apply { - this.groupingKey = groupingKey + eventOutputConfig.additionalProperties.toMutableMap() } - /** The maximum amount to charge each group */ - fun maximumCharge(maximumCharge: String) = - maximumCharge(JsonField.of(maximumCharge)) + /** The key in the event data to extract the unit rate from. */ + fun unitRatingKey(unitRatingKey: String) = + unitRatingKey(JsonField.of(unitRatingKey)) /** - * Sets [Builder.maximumCharge] to an arbitrary JSON value. + * Sets [Builder.unitRatingKey] to an arbitrary JSON value. * - * You should usually call [Builder.maximumCharge] with a well-typed + * You should usually call [Builder.unitRatingKey] with a well-typed * [String] value instead. This method is primarily for setting the field to * an undocumented or not yet supported value. */ - fun maximumCharge(maximumCharge: JsonField) = apply { - this.maximumCharge = maximumCharge + fun unitRatingKey(unitRatingKey: JsonField) = apply { + this.unitRatingKey = unitRatingKey } - /** The minimum amount to charge each group, regardless of usage */ - fun minimumCharge(minimumCharge: String) = - minimumCharge(JsonField.of(minimumCharge)) - /** - * Sets [Builder.minimumCharge] to an arbitrary JSON value. - * - * You should usually call [Builder.minimumCharge] with a well-typed - * [String] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. + * An optional key in the event data to group by (e.g., event ID). All + * events will also be grouped by their unit rate. */ - fun minimumCharge(minimumCharge: JsonField) = apply { - this.minimumCharge = minimumCharge - } - - /** The base price charged per group */ - fun perUnitRate(perUnitRate: String) = - perUnitRate(JsonField.of(perUnitRate)) + fun groupingKey(groupingKey: String?) = + groupingKey(JsonField.ofNullable(groupingKey)) /** - * Sets [Builder.perUnitRate] to an arbitrary JSON value. + * Sets [Builder.groupingKey] to an arbitrary JSON value. * - * You should usually call [Builder.perUnitRate] with a well-typed [String] + * You should usually call [Builder.groupingKey] with a well-typed [String] * value instead. This method is primarily for setting the field to an * undocumented or not yet supported value. */ - fun perUnitRate(perUnitRate: JsonField) = apply { - this.perUnitRate = perUnitRate + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey } fun additionalProperties(additionalProperties: Map) = @@ -15707,41 +18923,34 @@ private constructor( } /** - * Returns an immutable instance of [GroupedWithMinMaxThresholdsConfig]. + * Returns an immutable instance of [EventOutputConfig]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```kotlin - * .groupingKey() - * .maximumCharge() - * .minimumCharge() - * .perUnitRate() + * .unitRatingKey() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): GroupedWithMinMaxThresholdsConfig = - GroupedWithMinMaxThresholdsConfig( - checkRequired("groupingKey", groupingKey), - checkRequired("maximumCharge", maximumCharge), - checkRequired("minimumCharge", minimumCharge), - checkRequired("perUnitRate", perUnitRate), + fun build(): EventOutputConfig = + EventOutputConfig( + checkRequired("unitRatingKey", unitRatingKey), + groupingKey, additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): GroupedWithMinMaxThresholdsConfig = apply { + fun validate(): EventOutputConfig = apply { if (validated) { return@apply } + unitRatingKey() groupingKey() - maximumCharge() - minimumCharge() - perUnitRate() validated = true } @@ -15760,38 +18969,28 @@ private constructor( * Used for best match union deserialization. */ internal fun validity(): Int = - (if (groupingKey.asKnown() == null) 0 else 1) + - (if (maximumCharge.asKnown() == null) 0 else 1) + - (if (minimumCharge.asKnown() == null) 0 else 1) + - (if (perUnitRate.asKnown() == null) 0 else 1) + (if (unitRatingKey.asKnown() == null) 0 else 1) + + (if (groupingKey.asKnown() == null) 0 else 1) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is GroupedWithMinMaxThresholdsConfig && + return other is EventOutputConfig && + unitRatingKey == other.unitRatingKey && groupingKey == other.groupingKey && - maximumCharge == other.maximumCharge && - minimumCharge == other.minimumCharge && - perUnitRate == other.perUnitRate && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash( - groupingKey, - maximumCharge, - minimumCharge, - perUnitRate, - additionalProperties, - ) + Objects.hash(unitRatingKey, groupingKey, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "GroupedWithMinMaxThresholdsConfig{groupingKey=$groupingKey, maximumCharge=$maximumCharge, minimumCharge=$minimumCharge, perUnitRate=$perUnitRate, additionalProperties=$additionalProperties}" + "EventOutputConfig{unitRatingKey=$unitRatingKey, groupingKey=$groupingKey, additionalProperties=$additionalProperties}" } /** @@ -15908,10 +19107,9 @@ private constructor( return true } - return other is GroupedWithMinMaxThresholds && + return other is EventOutput && cadence == other.cadence && - groupedWithMinMaxThresholdsConfig == - other.groupedWithMinMaxThresholdsConfig && + eventOutputConfig == other.eventOutputConfig && itemId == other.itemId && modelType == other.modelType && name == other.name && @@ -15934,7 +19132,7 @@ private constructor( private val hashCode: Int by lazy { Objects.hash( cadence, - groupedWithMinMaxThresholdsConfig, + eventOutputConfig, itemId, modelType, name, @@ -15958,7 +19156,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "GroupedWithMinMaxThresholds{cadence=$cadence, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "EventOutput{cadence=$cadence, eventOutputConfig=$eventOutputConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } } diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsParams.kt index b3b2f49e4..044c92d74 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsParams.kt @@ -1634,6 +1634,9 @@ private constructor( /** Alias for calling [price] with `Price.ofMinimum(minimum)`. */ fun price(minimum: NewFloatingMinimumCompositePrice) = price(Price.ofMinimum(minimum)) + /** Alias for calling [price] with `Price.ofEventOutput(eventOutput)`. */ + fun price(eventOutput: Price.EventOutput) = price(Price.ofEventOutput(eventOutput)) + /** The id of the price to add to the subscription. */ fun priceId(priceId: String?) = priceId(JsonField.ofNullable(priceId)) @@ -3254,6 +3257,7 @@ private constructor( null, private val cumulativeGroupedBulk: NewFloatingCumulativeGroupedBulkPrice? = null, private val minimum: NewFloatingMinimumCompositePrice? = null, + private val eventOutput: EventOutput? = null, private val _json: JsonValue? = null, ) { @@ -3321,6 +3325,8 @@ private constructor( fun minimum(): NewFloatingMinimumCompositePrice? = minimum + fun eventOutput(): EventOutput? = eventOutput + fun isUnit(): Boolean = unit != null fun isTiered(): Boolean = tiered != null @@ -3376,6 +3382,8 @@ private constructor( fun isMinimum(): Boolean = minimum != null + fun isEventOutput(): Boolean = eventOutput != null + fun asUnit(): NewFloatingUnitPrice = unit.getOrThrow("unit") fun asTiered(): NewFloatingTieredPrice = tiered.getOrThrow("tiered") @@ -3452,6 +3460,8 @@ private constructor( fun asMinimum(): NewFloatingMinimumCompositePrice = minimum.getOrThrow("minimum") + fun asEventOutput(): EventOutput = eventOutput.getOrThrow("eventOutput") + fun _json(): JsonValue? = _json fun accept(visitor: Visitor): T = @@ -3499,6 +3509,7 @@ private constructor( cumulativeGroupedBulk != null -> visitor.visitCumulativeGroupedBulk(cumulativeGroupedBulk) minimum != null -> visitor.visitMinimum(minimum) + eventOutput != null -> visitor.visitEventOutput(eventOutput) else -> visitor.unknown(_json) } @@ -3662,6 +3673,10 @@ private constructor( override fun visitMinimum(minimum: NewFloatingMinimumCompositePrice) { minimum.validate() } + + override fun visitEventOutput(eventOutput: EventOutput) { + eventOutput.validate() + } } ) validated = true @@ -3784,6 +3799,9 @@ private constructor( override fun visitMinimum(minimum: NewFloatingMinimumCompositePrice) = minimum.validity() + override fun visitEventOutput(eventOutput: EventOutput) = + eventOutput.validity() + override fun unknown(json: JsonValue?) = 0 } ) @@ -3820,7 +3838,8 @@ private constructor( scalableMatrixWithUnitPricing == other.scalableMatrixWithUnitPricing && scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && cumulativeGroupedBulk == other.cumulativeGroupedBulk && - minimum == other.minimum + minimum == other.minimum && + eventOutput == other.eventOutput } override fun hashCode(): Int = @@ -3852,6 +3871,7 @@ private constructor( scalableMatrixWithTieredPricing, cumulativeGroupedBulk, minimum, + eventOutput, ) override fun toString(): String = @@ -3896,6 +3916,7 @@ private constructor( cumulativeGroupedBulk != null -> "Price{cumulativeGroupedBulk=$cumulativeGroupedBulk}" minimum != null -> "Price{minimum=$minimum}" + eventOutput != null -> "Price{eventOutput=$eventOutput}" _json != null -> "Price{_unknown=$_json}" else -> throw IllegalStateException("Invalid Price") } @@ -3990,6 +4011,8 @@ private constructor( ) = Price(cumulativeGroupedBulk = cumulativeGroupedBulk) fun ofMinimum(minimum: NewFloatingMinimumCompositePrice) = Price(minimum = minimum) + + fun ofEventOutput(eventOutput: EventOutput) = Price(eventOutput = eventOutput) } /** @@ -4079,6 +4102,8 @@ private constructor( fun visitMinimum(minimum: NewFloatingMinimumCompositePrice): T + fun visitEventOutput(eventOutput: EventOutput): T + /** * Maps an unknown variant of [Price] to a value of type [T]. * @@ -4298,6 +4323,11 @@ private constructor( ) ?.let { Price(minimum = it, _json = json) } ?: Price(_json = json) } + "event_output" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(eventOutput = it, _json = json) + } ?: Price(_json = json) + } } return Price(_json = json) @@ -4358,6 +4388,7 @@ private constructor( value.cumulativeGroupedBulk != null -> generator.writeObject(value.cumulativeGroupedBulk) value.minimum != null -> generator.writeObject(value.minimum) + value.eventOutput != null -> generator.writeObject(value.eventOutput) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid Price") } @@ -6011,6 +6042,1524 @@ private constructor( override fun toString() = "GroupedWithMinMaxThresholds{cadence=$cadence, currency=$currency, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" } + + class EventOutput + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val currency: JsonField, + private val eventOutputConfig: JsonField, + private val itemId: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val metadata: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("event_output_config") + @ExcludeMissing + eventOutputConfig: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + ) : this( + cadence, + currency, + eventOutputConfig, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * An ISO 4217 currency string for which this price is billed in. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * Configuration for event_output pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun eventOutputConfig(): EventOutputConfig = + eventOutputConfig.getRequired("event_output_config") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("event_output") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = billableMetricId.getNullable("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + invoiceGroupingKey.getNullable("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [eventOutputConfig]. + * + * Unlike [eventOutputConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("event_output_config") + @ExcludeMissing + fun _eventOutputConfig(): JsonField = eventOutputConfig + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [EventOutput]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .currency() + * .eventOutputConfig() + * .itemId() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [EventOutput]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var currency: JsonField? = null + private var eventOutputConfig: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonValue = JsonValue.from("event_output") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(eventOutput: EventOutput) = apply { + cadence = eventOutput.cadence + currency = eventOutput.currency + eventOutputConfig = eventOutput.eventOutputConfig + itemId = eventOutput.itemId + modelType = eventOutput.modelType + name = eventOutput.name + billableMetricId = eventOutput.billableMetricId + billedInAdvance = eventOutput.billedInAdvance + billingCycleConfiguration = eventOutput.billingCycleConfiguration + conversionRate = eventOutput.conversionRate + conversionRateConfig = eventOutput.conversionRateConfig + dimensionalPriceConfiguration = eventOutput.dimensionalPriceConfiguration + externalPriceId = eventOutput.externalPriceId + fixedPriceQuantity = eventOutput.fixedPriceQuantity + invoiceGroupingKey = eventOutput.invoiceGroupingKey + invoicingCycleConfiguration = eventOutput.invoicingCycleConfiguration + metadata = eventOutput.metadata + additionalProperties = eventOutput.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** Configuration for event_output pricing */ + fun eventOutputConfig(eventOutputConfig: EventOutputConfig) = + eventOutputConfig(JsonField.of(eventOutputConfig)) + + /** + * Sets [Builder.eventOutputConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.eventOutputConfig] with a well-typed + * [EventOutputConfig] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun eventOutputConfig(eventOutputConfig: JsonField) = apply { + this.eventOutputConfig = eventOutputConfig + } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("event_output") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [EventOutput]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .currency() + * .eventOutputConfig() + * .itemId() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): EventOutput = + EventOutput( + checkRequired("cadence", cadence), + checkRequired("currency", currency), + checkRequired("eventOutputConfig", eventOutputConfig), + checkRequired("itemId", itemId), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): EventOutput = apply { + if (validated) { + return@apply + } + + cadence().validate() + currency() + eventOutputConfig().validate() + itemId() + _modelType().let { + if (it != JsonValue.from("event_output")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + metadata()?.validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (eventOutputConfig.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + modelType.let { if (it == JsonValue.from("event_output")) 1 else 0 } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (metadata.asKnown()?.validity() ?: 0) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Configuration for event_output pricing */ + class EventOutputConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val unitRatingKey: JsonField, + private val groupingKey: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("unit_rating_key") + @ExcludeMissing + unitRatingKey: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + ) : this(unitRatingKey, groupingKey, mutableMapOf()) + + /** + * The key in the event data to extract the unit rate from. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun unitRatingKey(): String = unitRatingKey.getRequired("unit_rating_key") + + /** + * An optional key in the event data to group by (e.g., event ID). All events + * will also be grouped by their unit rate. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun groupingKey(): String? = groupingKey.getNullable("grouping_key") + + /** + * Returns the raw JSON value of [unitRatingKey]. + * + * Unlike [unitRatingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_rating_key") + @ExcludeMissing + fun _unitRatingKey(): JsonField = unitRatingKey + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [EventOutputConfig]. + * + * The following fields are required: + * ```kotlin + * .unitRatingKey() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [EventOutputConfig]. */ + class Builder internal constructor() { + + private var unitRatingKey: JsonField? = null + private var groupingKey: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(eventOutputConfig: EventOutputConfig) = apply { + unitRatingKey = eventOutputConfig.unitRatingKey + groupingKey = eventOutputConfig.groupingKey + additionalProperties = + eventOutputConfig.additionalProperties.toMutableMap() + } + + /** The key in the event data to extract the unit rate from. */ + fun unitRatingKey(unitRatingKey: String) = + unitRatingKey(JsonField.of(unitRatingKey)) + + /** + * Sets [Builder.unitRatingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.unitRatingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun unitRatingKey(unitRatingKey: JsonField) = apply { + this.unitRatingKey = unitRatingKey + } + + /** + * An optional key in the event data to group by (e.g., event ID). All + * events will also be grouped by their unit rate. + */ + fun groupingKey(groupingKey: String?) = + groupingKey(JsonField.ofNullable(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [EventOutputConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .unitRatingKey() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): EventOutputConfig = + EventOutputConfig( + checkRequired("unitRatingKey", unitRatingKey), + groupingKey, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): EventOutputConfig = apply { + if (validated) { + return@apply + } + + unitRatingKey() + groupingKey() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (unitRatingKey.asKnown() == null) 0 else 1) + + (if (groupingKey.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is EventOutputConfig && + unitRatingKey == other.unitRatingKey && + groupingKey == other.groupingKey && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(unitRatingKey, groupingKey, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "EventOutputConfig{unitRatingKey=$unitRatingKey, groupingKey=$groupingKey, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is EventOutput && + cadence == other.cadence && + currency == other.currency && + eventOutputConfig == other.eventOutputConfig && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + currency, + eventOutputConfig, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "EventOutput{cadence=$cadence, currency=$currency, eventOutputConfig=$eventOutputConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + } } override fun equals(other: Any?): Boolean { diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionSchedulePlanChangeParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionSchedulePlanChangeParams.kt index 0b2a16f47..38e8b5100 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionSchedulePlanChangeParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionSchedulePlanChangeParams.kt @@ -4356,6 +4356,9 @@ private constructor( fun price(minimum: NewSubscriptionMinimumCompositePrice) = price(Price.ofMinimum(minimum)) + /** Alias for calling [price] with `Price.ofEventOutput(eventOutput)`. */ + fun price(eventOutput: Price.EventOutput) = price(Price.ofEventOutput(eventOutput)) + /** The id of the price to add to the subscription. */ fun priceId(priceId: String?) = priceId(JsonField.ofNullable(priceId)) @@ -4512,6 +4515,7 @@ private constructor( null, private val cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice? = null, private val minimum: NewSubscriptionMinimumCompositePrice? = null, + private val eventOutput: EventOutput? = null, private val _json: JsonValue? = null, ) { @@ -4583,6 +4587,8 @@ private constructor( fun minimum(): NewSubscriptionMinimumCompositePrice? = minimum + fun eventOutput(): EventOutput? = eventOutput + fun isUnit(): Boolean = unit != null fun isTiered(): Boolean = tiered != null @@ -4638,6 +4644,8 @@ private constructor( fun isMinimum(): Boolean = minimum != null + fun isEventOutput(): Boolean = eventOutput != null + fun asUnit(): NewSubscriptionUnitPrice = unit.getOrThrow("unit") fun asTiered(): NewSubscriptionTieredPrice = tiered.getOrThrow("tiered") @@ -4715,6 +4723,8 @@ private constructor( fun asMinimum(): NewSubscriptionMinimumCompositePrice = minimum.getOrThrow("minimum") + fun asEventOutput(): EventOutput = eventOutput.getOrThrow("eventOutput") + fun _json(): JsonValue? = _json fun accept(visitor: Visitor): T = @@ -4762,6 +4772,7 @@ private constructor( cumulativeGroupedBulk != null -> visitor.visitCumulativeGroupedBulk(cumulativeGroupedBulk) minimum != null -> visitor.visitMinimum(minimum) + eventOutput != null -> visitor.visitEventOutput(eventOutput) else -> visitor.unknown(_json) } @@ -4926,6 +4937,10 @@ private constructor( override fun visitMinimum(minimum: NewSubscriptionMinimumCompositePrice) { minimum.validate() } + + override fun visitEventOutput(eventOutput: EventOutput) { + eventOutput.validate() + } } ) validated = true @@ -5051,6 +5066,9 @@ private constructor( override fun visitMinimum(minimum: NewSubscriptionMinimumCompositePrice) = minimum.validity() + override fun visitEventOutput(eventOutput: EventOutput) = + eventOutput.validity() + override fun unknown(json: JsonValue?) = 0 } ) @@ -5087,7 +5105,8 @@ private constructor( scalableMatrixWithUnitPricing == other.scalableMatrixWithUnitPricing && scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && cumulativeGroupedBulk == other.cumulativeGroupedBulk && - minimum == other.minimum + minimum == other.minimum && + eventOutput == other.eventOutput } override fun hashCode(): Int = @@ -5119,6 +5138,7 @@ private constructor( scalableMatrixWithTieredPricing, cumulativeGroupedBulk, minimum, + eventOutput, ) override fun toString(): String = @@ -5163,6 +5183,7 @@ private constructor( cumulativeGroupedBulk != null -> "Price{cumulativeGroupedBulk=$cumulativeGroupedBulk}" minimum != null -> "Price{minimum=$minimum}" + eventOutput != null -> "Price{eventOutput=$eventOutput}" _json != null -> "Price{_unknown=$_json}" else -> throw IllegalStateException("Invalid Price") } @@ -5258,6 +5279,8 @@ private constructor( fun ofMinimum(minimum: NewSubscriptionMinimumCompositePrice) = Price(minimum = minimum) + + fun ofEventOutput(eventOutput: EventOutput) = Price(eventOutput = eventOutput) } /** @@ -5354,6 +5377,8 @@ private constructor( fun visitMinimum(minimum: NewSubscriptionMinimumCompositePrice): T + fun visitEventOutput(eventOutput: EventOutput): T + /** * Maps an unknown variant of [Price] to a value of type [T]. * @@ -5581,6 +5606,11 @@ private constructor( ) ?.let { Price(minimum = it, _json = json) } ?: Price(_json = json) } + "event_output" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(eventOutput = it, _json = json) + } ?: Price(_json = json) + } } return Price(_json = json) @@ -5641,6 +5671,7 @@ private constructor( value.cumulativeGroupedBulk != null -> generator.writeObject(value.cumulativeGroupedBulk) value.minimum != null -> generator.writeObject(value.minimum) + value.eventOutput != null -> generator.writeObject(value.eventOutput) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid Price") } @@ -9113,1081 +9144,1573 @@ private constructor( override fun toString() = "GroupedWithMinMaxThresholds{cadence=$cadence, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + class EventOutput + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val eventOutputConfig: JsonField, + private val itemId: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { - return other is AddPrice && - allocationPrice == other.allocationPrice && - discounts == other.discounts && - endDate == other.endDate && - externalPriceId == other.externalPriceId && - maximumAmount == other.maximumAmount && - minimumAmount == other.minimumAmount && - planPhaseOrder == other.planPhaseOrder && - price == other.price && - priceId == other.priceId && - startDate == other.startDate && - additionalProperties == other.additionalProperties - } + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("event_output_config") + @ExcludeMissing + eventOutputConfig: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + eventOutputConfig, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + mutableMapOf(), + ) - private val hashCode: Int by lazy { - Objects.hash( - allocationPrice, - discounts, - endDate, - externalPriceId, - maximumAmount, - minimumAmount, - planPhaseOrder, - price, - priceId, - startDate, - additionalProperties, - ) - } + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") - override fun hashCode(): Int = hashCode + /** + * Configuration for event_output pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun eventOutputConfig(): EventOutputConfig = + eventOutputConfig.getRequired("event_output_config") - override fun toString() = - "AddPrice{allocationPrice=$allocationPrice, discounts=$discounts, endDate=$endDate, externalPriceId=$externalPriceId, maximumAmount=$maximumAmount, minimumAmount=$minimumAmount, planPhaseOrder=$planPhaseOrder, price=$price, priceId=$priceId, startDate=$startDate, additionalProperties=$additionalProperties}" - } + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") - /** - * Reset billing periods to be aligned with the plan change's effective date or start of the - * month. Defaults to `unchanged` which keeps subscription's existing billing cycle alignment. - */ - class BillingCycleAlignment - @JsonCreator - private constructor(private val value: JsonField) : Enum { + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("event_output") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API may respond with new members that the SDK is - * unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") - companion object { + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = billableMetricId.getNullable("billable_metric_id") - val UNCHANGED = of("unchanged") + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") - val PLAN_CHANGE_DATE = of("plan_change_date") + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") - val START_OF_MONTH = of("start_of_month") + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") - fun of(value: String) = BillingCycleAlignment(JsonField.of(value)) - } + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") - /** An enum containing [BillingCycleAlignment]'s known values. */ - enum class Known { - UNCHANGED, - PLAN_CHANGE_DATE, - START_OF_MONTH, - } + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") - /** - * An enum containing [BillingCycleAlignment]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [BillingCycleAlignment] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if the - * SDK is on an older version than the API, then the API may respond with new members that - * the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - UNCHANGED, - PLAN_CHANGE_DATE, - START_OF_MONTH, - /** - * An enum member indicating that [BillingCycleAlignment] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") - /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you want - * to throw for the unknown case. - */ - fun value(): Value = - when (this) { - UNCHANGED -> Value.UNCHANGED - PLAN_CHANGE_DATE -> Value.PLAN_CHANGE_DATE - START_OF_MONTH -> Value.START_OF_MONTH - else -> Value._UNKNOWN - } + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and don't - * want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known member. - */ - fun known(): Known = - when (this) { - UNCHANGED -> Known.UNCHANGED - PLAN_CHANGE_DATE -> Known.PLAN_CHANGE_DATE - START_OF_MONTH -> Known.START_OF_MONTH - else -> throw OrbInvalidDataException("Unknown BillingCycleAlignment: $value") - } + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the expected - * primitive type. - */ - fun asString(): String = - _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + invoiceGroupingKey.getNullable("invoice_grouping_key") - private var validated: Boolean = false + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - fun validate(): BillingCycleAlignment = apply { - if (validated) { - return@apply - } + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") - known() - validated = true - } + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + /** + * Returns the raw JSON value of [eventOutputConfig]. + * + * Unlike [eventOutputConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("event_output_config") + @ExcludeMissing + fun _eventOutputConfig(): JsonField = eventOutputConfig - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - return other is BillingCycleAlignment && value == other.value - } + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - override fun hashCode() = value.hashCode() + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId - override fun toString() = value.toString() - } + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance - class RemoveAdjustment - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val adjustmentId: JsonField, - private val additionalProperties: MutableMap, - ) { + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("adjustment_id") - @ExcludeMissing - adjustmentId: JsonField = JsonMissing.of() - ) : this(adjustmentId, mutableMapOf()) + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate - /** - * The id of the adjustment to remove on the subscription. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun adjustmentId(): String = adjustmentId.getRequired("adjustment_id") + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig - /** - * Returns the raw JSON value of [adjustmentId]. - * - * Unlike [adjustmentId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("adjustment_id") - @ExcludeMissing - fun _adjustmentId(): JsonField = adjustmentId - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency - /** - * Returns a mutable builder for constructing an instance of [RemoveAdjustment]. - * - * The following fields are required: - * ```kotlin - * .adjustmentId() - * ``` - */ - fun builder() = Builder() - } + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration - /** A builder for [RemoveAdjustment]. */ - class Builder internal constructor() { + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId - private var adjustmentId: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - internal fun from(removeAdjustment: RemoveAdjustment) = apply { - adjustmentId = removeAdjustment.adjustmentId - additionalProperties = removeAdjustment.additionalProperties.toMutableMap() - } + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - /** The id of the adjustment to remove on the subscription. */ - fun adjustmentId(adjustmentId: String) = adjustmentId(JsonField.of(adjustmentId)) + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration - /** - * Sets [Builder.adjustmentId] to an arbitrary JSON value. - * - * You should usually call [Builder.adjustmentId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun adjustmentId(adjustmentId: JsonField) = apply { - this.adjustmentId = adjustmentId - } + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun toBuilder() = Builder().from(this) - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + companion object { - /** - * Returns an immutable instance of [RemoveAdjustment]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```kotlin - * .adjustmentId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): RemoveAdjustment = - RemoveAdjustment( - checkRequired("adjustmentId", adjustmentId), - additionalProperties.toMutableMap(), - ) - } + /** + * Returns a mutable builder for constructing an instance of [EventOutput]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .eventOutputConfig() + * .itemId() + * .name() + * ``` + */ + fun builder() = Builder() + } - private var validated: Boolean = false + /** A builder for [EventOutput]. */ + class Builder internal constructor() { - fun validate(): RemoveAdjustment = apply { - if (validated) { - return@apply - } + private var cadence: JsonField? = null + private var eventOutputConfig: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonValue = JsonValue.from("event_output") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - adjustmentId() - validated = true - } + internal fun from(eventOutput: EventOutput) = apply { + cadence = eventOutput.cadence + eventOutputConfig = eventOutput.eventOutputConfig + itemId = eventOutput.itemId + modelType = eventOutput.modelType + name = eventOutput.name + billableMetricId = eventOutput.billableMetricId + billedInAdvance = eventOutput.billedInAdvance + billingCycleConfiguration = eventOutput.billingCycleConfiguration + conversionRate = eventOutput.conversionRate + conversionRateConfig = eventOutput.conversionRateConfig + currency = eventOutput.currency + dimensionalPriceConfiguration = eventOutput.dimensionalPriceConfiguration + externalPriceId = eventOutput.externalPriceId + fixedPriceQuantity = eventOutput.fixedPriceQuantity + invoiceGroupingKey = eventOutput.invoiceGroupingKey + invoicingCycleConfiguration = eventOutput.invoicingCycleConfiguration + metadata = eventOutput.metadata + referenceId = eventOutput.referenceId + additionalProperties = eventOutput.additionalProperties.toMutableMap() + } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = (if (adjustmentId.asKnown() == null) 0 else 1) + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** Configuration for event_output pricing */ + fun eventOutputConfig(eventOutputConfig: EventOutputConfig) = + eventOutputConfig(JsonField.of(eventOutputConfig)) - return other is RemoveAdjustment && - adjustmentId == other.adjustmentId && - additionalProperties == other.additionalProperties - } + /** + * Sets [Builder.eventOutputConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.eventOutputConfig] with a well-typed + * [EventOutputConfig] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun eventOutputConfig(eventOutputConfig: JsonField) = apply { + this.eventOutputConfig = eventOutputConfig + } - private val hashCode: Int by lazy { Objects.hash(adjustmentId, additionalProperties) } + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - override fun hashCode(): Int = hashCode + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - override fun toString() = - "RemoveAdjustment{adjustmentId=$adjustmentId, additionalProperties=$additionalProperties}" - } + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("event_output") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } - class RemovePrice - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val externalPriceId: JsonField, - private val priceId: JsonField, - private val additionalProperties: MutableMap, - ) { + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) - @JsonCreator - private constructor( - @JsonProperty("external_price_id") - @ExcludeMissing - externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("price_id") @ExcludeMissing priceId: JsonField = JsonMissing.of(), - ) : this(externalPriceId, priceId, mutableMapOf()) + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } - /** - * The external price id of the price to remove on the subscription. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) - /** - * The id of the price to remove on the subscription. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun priceId(): String? = priceId.getNullable("price_id") + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } - /** - * Returns the raw JSON value of [externalPriceId]. - * - * Unlike [externalPriceId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) - /** - * Returns the raw JSON value of [priceId]. - * - * Unlike [priceId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - fun toBuilder() = Builder().from(this) + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } - companion object { + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) - /** Returns a mutable builder for constructing an instance of [RemovePrice]. */ - fun builder() = Builder() - } + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) - /** A builder for [RemovePrice]. */ - class Builder internal constructor() { + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } - private var externalPriceId: JsonField = JsonMissing.of() - private var priceId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) - internal fun from(removePrice: RemovePrice) = apply { - externalPriceId = removePrice.externalPriceId - priceId = removePrice.priceId - additionalProperties = removePrice.additionalProperties.toMutableMap() - } + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } - /** The external price id of the price to remove on the subscription. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) - /** - * Sets [Builder.externalPriceId] to an arbitrary JSON value. - * - * You should usually call [Builder.externalPriceId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun externalPriceId(externalPriceId: JsonField) = apply { - this.externalPriceId = externalPriceId - } + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) - /** The id of the price to remove on the subscription. */ - fun priceId(priceId: String?) = priceId(JsonField.ofNullable(priceId)) + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) - /** - * Sets [Builder.priceId] to an arbitrary JSON value. - * - * You should usually call [Builder.priceId] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun priceId(priceId: JsonField) = apply { this.priceId = priceId } + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } - /** - * Returns an immutable instance of [RemovePrice]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): RemovePrice = - RemovePrice(externalPriceId, priceId, additionalProperties.toMutableMap()) - } + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) - private var validated: Boolean = false + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } - fun validate(): RemovePrice = apply { - if (validated) { - return@apply - } + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) - externalPriceId() - priceId() - validated = true - } + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (if (externalPriceId.asKnown() == null) 0 else 1) + - (if (priceId.asKnown() == null) 0 else 1) + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } - return other is RemovePrice && - externalPriceId == other.externalPriceId && - priceId == other.priceId && - additionalProperties == other.additionalProperties - } + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) - private val hashCode: Int by lazy { - Objects.hash(externalPriceId, priceId, additionalProperties) - } + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - override fun hashCode(): Int = hashCode + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - override fun toString() = - "RemovePrice{externalPriceId=$externalPriceId, priceId=$priceId, additionalProperties=$additionalProperties}" - } + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - class ReplaceAdjustment - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val adjustment: JsonField, - private val replacesAdjustmentId: JsonField, - private val additionalProperties: MutableMap, - ) { + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) - @JsonCreator - private constructor( - @JsonProperty("adjustment") - @ExcludeMissing - adjustment: JsonField = JsonMissing.of(), - @JsonProperty("replaces_adjustment_id") - @ExcludeMissing - replacesAdjustmentId: JsonField = JsonMissing.of(), - ) : this(adjustment, replacesAdjustmentId, mutableMapOf()) + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } - /** - * The definition of a new adjustment to create and add to the subscription. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun adjustment(): Adjustment = adjustment.getRequired("adjustment") + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** - * The id of the adjustment on the plan to replace in the subscription. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun replacesAdjustmentId(): String = - replacesAdjustmentId.getRequired("replaces_adjustment_id") + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * Returns the raw JSON value of [adjustment]. - * - * Unlike [adjustment], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("adjustment") - @ExcludeMissing - fun _adjustment(): JsonField = adjustment + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - /** - * Returns the raw JSON value of [replacesAdjustmentId]. - * - * Unlike [replacesAdjustmentId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("replaces_adjustment_id") - @ExcludeMissing - fun _replacesAdjustmentId(): JsonField = replacesAdjustmentId + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - companion object { + /** + * Returns an immutable instance of [EventOutput]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .eventOutputConfig() + * .itemId() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): EventOutput = + EventOutput( + checkRequired("cadence", cadence), + checkRequired("eventOutputConfig", eventOutputConfig), + checkRequired("itemId", itemId), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } - /** - * Returns a mutable builder for constructing an instance of [ReplaceAdjustment]. - * - * The following fields are required: - * ```kotlin - * .adjustment() - * .replacesAdjustmentId() - * ``` - */ - fun builder() = Builder() - } + private var validated: Boolean = false - /** A builder for [ReplaceAdjustment]. */ - class Builder internal constructor() { + fun validate(): EventOutput = apply { + if (validated) { + return@apply + } - private var adjustment: JsonField? = null - private var replacesAdjustmentId: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() + cadence().validate() + eventOutputConfig().validate() + itemId() + _modelType().let { + if (it != JsonValue.from("event_output")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + metadata()?.validate() + referenceId() + validated = true + } - internal fun from(replaceAdjustment: ReplaceAdjustment) = apply { - adjustment = replaceAdjustment.adjustment - replacesAdjustmentId = replaceAdjustment.replacesAdjustmentId - additionalProperties = replaceAdjustment.additionalProperties.toMutableMap() - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - /** The definition of a new adjustment to create and add to the subscription. */ - fun adjustment(adjustment: Adjustment) = adjustment(JsonField.of(adjustment)) + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (eventOutputConfig.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + modelType.let { if (it == JsonValue.from("event_output")) 1 else 0 } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) - /** - * Sets [Builder.adjustment] to an arbitrary JSON value. - * - * You should usually call [Builder.adjustment] with a well-typed [Adjustment] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun adjustment(adjustment: JsonField) = apply { - this.adjustment = adjustment - } + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { - /** - * Alias for calling [adjustment] with - * `Adjustment.ofPercentageDiscount(percentageDiscount)`. - */ - fun adjustment(percentageDiscount: NewPercentageDiscount) = - adjustment(Adjustment.ofPercentageDiscount(percentageDiscount)) + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value - /** - * Alias for calling [adjustment] with the following: - * ```kotlin - * NewPercentageDiscount.builder() - * .adjustmentType(NewPercentageDiscount.AdjustmentType.PERCENTAGE_DISCOUNT) - * .percentageDiscount(percentageDiscount) - * .build() - * ``` - */ - fun percentageDiscountAdjustment(percentageDiscount: Double) = - adjustment( - NewPercentageDiscount.builder() - .adjustmentType(NewPercentageDiscount.AdjustmentType.PERCENTAGE_DISCOUNT) - .percentageDiscount(percentageDiscount) - .build() - ) + companion object { - /** Alias for calling [adjustment] with `Adjustment.ofUsageDiscount(usageDiscount)`. */ - fun adjustment(usageDiscount: NewUsageDiscount) = - adjustment(Adjustment.ofUsageDiscount(usageDiscount)) + val ANNUAL = of("annual") - /** - * Alias for calling [adjustment] with the following: - * ```kotlin - * NewUsageDiscount.builder() - * .adjustmentType(NewUsageDiscount.AdjustmentType.USAGE_DISCOUNT) - * .usageDiscount(usageDiscount) - * .build() - * ``` - */ - fun usageDiscountAdjustment(usageDiscount: Double) = - adjustment( - NewUsageDiscount.builder() - .adjustmentType(NewUsageDiscount.AdjustmentType.USAGE_DISCOUNT) - .usageDiscount(usageDiscount) - .build() - ) + val SEMI_ANNUAL = of("semi_annual") - /** - * Alias for calling [adjustment] with `Adjustment.ofAmountDiscount(amountDiscount)`. - */ - fun adjustment(amountDiscount: NewAmountDiscount) = - adjustment(Adjustment.ofAmountDiscount(amountDiscount)) + val MONTHLY = of("monthly") - /** - * Alias for calling [adjustment] with the following: - * ```kotlin - * NewAmountDiscount.builder() - * .adjustmentType(NewAmountDiscount.AdjustmentType.AMOUNT_DISCOUNT) - * .amountDiscount(amountDiscount) - * .build() - * ``` - */ - fun amountDiscountAdjustment(amountDiscount: String) = - adjustment( - NewAmountDiscount.builder() - .adjustmentType(NewAmountDiscount.AdjustmentType.AMOUNT_DISCOUNT) - .amountDiscount(amountDiscount) - .build() - ) + val QUARTERLY = of("quarterly") - /** Alias for calling [adjustment] with `Adjustment.ofMinimum(minimum)`. */ - fun adjustment(minimum: NewMinimum) = adjustment(Adjustment.ofMinimum(minimum)) + val ONE_TIME = of("one_time") - /** Alias for calling [adjustment] with `Adjustment.ofMaximum(maximum)`. */ - fun adjustment(maximum: NewMaximum) = adjustment(Adjustment.ofMaximum(maximum)) + val CUSTOM = of("custom") - /** - * Alias for calling [adjustment] with the following: - * ```kotlin - * NewMaximum.builder() - * .adjustmentType(NewMaximum.AdjustmentType.MAXIMUM) - * .maximumAmount(maximumAmount) - * .build() - * ``` - */ - fun maximumAdjustment(maximumAmount: String) = - adjustment( - NewMaximum.builder() - .adjustmentType(NewMaximum.AdjustmentType.MAXIMUM) - .maximumAmount(maximumAmount) - .build() - ) + fun of(value: String) = Cadence(JsonField.of(value)) + } - /** The id of the adjustment on the plan to replace in the subscription. */ - fun replacesAdjustmentId(replacesAdjustmentId: String) = - replacesAdjustmentId(JsonField.of(replacesAdjustmentId)) + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } - /** - * Sets [Builder.replacesAdjustmentId] to an arbitrary JSON value. - * - * You should usually call [Builder.replacesAdjustmentId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun replacesAdjustmentId(replacesAdjustmentId: JsonField) = apply { - this.replacesAdjustmentId = replacesAdjustmentId - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + private var validated: Boolean = false - /** - * Returns an immutable instance of [ReplaceAdjustment]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```kotlin - * .adjustment() - * .replacesAdjustmentId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): ReplaceAdjustment = - ReplaceAdjustment( - checkRequired("adjustment", adjustment), - checkRequired("replacesAdjustmentId", replacesAdjustmentId), - additionalProperties.toMutableMap(), - ) - } + fun validate(): Cadence = apply { + if (validated) { + return@apply + } - private var validated: Boolean = false + known() + validated = true + } - fun validate(): ReplaceAdjustment = apply { - if (validated) { - return@apply - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - adjustment().validate() - replacesAdjustmentId() - validated = true - } + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (adjustment.asKnown()?.validity() ?: 0) + - (if (replacesAdjustmentId.asKnown() == null) 0 else 1) + return other is Cadence && value == other.value + } - /** The definition of a new adjustment to create and add to the subscription. */ - @JsonDeserialize(using = Adjustment.Deserializer::class) - @JsonSerialize(using = Adjustment.Serializer::class) - class Adjustment - private constructor( - private val percentageDiscount: NewPercentageDiscount? = null, - private val usageDiscount: NewUsageDiscount? = null, - private val amountDiscount: NewAmountDiscount? = null, - private val minimum: NewMinimum? = null, - private val maximum: NewMaximum? = null, - private val _json: JsonValue? = null, - ) { + override fun hashCode() = value.hashCode() - fun percentageDiscount(): NewPercentageDiscount? = percentageDiscount + override fun toString() = value.toString() + } - fun usageDiscount(): NewUsageDiscount? = usageDiscount + /** Configuration for event_output pricing */ + class EventOutputConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val unitRatingKey: JsonField, + private val groupingKey: JsonField, + private val additionalProperties: MutableMap, + ) { - fun amountDiscount(): NewAmountDiscount? = amountDiscount + @JsonCreator + private constructor( + @JsonProperty("unit_rating_key") + @ExcludeMissing + unitRatingKey: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + ) : this(unitRatingKey, groupingKey, mutableMapOf()) - fun minimum(): NewMinimum? = minimum + /** + * The key in the event data to extract the unit rate from. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun unitRatingKey(): String = unitRatingKey.getRequired("unit_rating_key") - fun maximum(): NewMaximum? = maximum + /** + * An optional key in the event data to group by (e.g., event ID). All events + * will also be grouped by their unit rate. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun groupingKey(): String? = groupingKey.getNullable("grouping_key") - fun isPercentageDiscount(): Boolean = percentageDiscount != null + /** + * Returns the raw JSON value of [unitRatingKey]. + * + * Unlike [unitRatingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_rating_key") + @ExcludeMissing + fun _unitRatingKey(): JsonField = unitRatingKey - fun isUsageDiscount(): Boolean = usageDiscount != null + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey - fun isAmountDiscount(): Boolean = amountDiscount != null + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - fun isMinimum(): Boolean = minimum != null + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - fun isMaximum(): Boolean = maximum != null + fun toBuilder() = Builder().from(this) - fun asPercentageDiscount(): NewPercentageDiscount = - percentageDiscount.getOrThrow("percentageDiscount") + companion object { - fun asUsageDiscount(): NewUsageDiscount = usageDiscount.getOrThrow("usageDiscount") + /** + * Returns a mutable builder for constructing an instance of + * [EventOutputConfig]. + * + * The following fields are required: + * ```kotlin + * .unitRatingKey() + * ``` + */ + fun builder() = Builder() + } - fun asAmountDiscount(): NewAmountDiscount = amountDiscount.getOrThrow("amountDiscount") + /** A builder for [EventOutputConfig]. */ + class Builder internal constructor() { - fun asMinimum(): NewMinimum = minimum.getOrThrow("minimum") + private var unitRatingKey: JsonField? = null + private var groupingKey: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() - fun asMaximum(): NewMaximum = maximum.getOrThrow("maximum") + internal fun from(eventOutputConfig: EventOutputConfig) = apply { + unitRatingKey = eventOutputConfig.unitRatingKey + groupingKey = eventOutputConfig.groupingKey + additionalProperties = + eventOutputConfig.additionalProperties.toMutableMap() + } - fun _json(): JsonValue? = _json + /** The key in the event data to extract the unit rate from. */ + fun unitRatingKey(unitRatingKey: String) = + unitRatingKey(JsonField.of(unitRatingKey)) - fun accept(visitor: Visitor): T = - when { - percentageDiscount != null -> - visitor.visitPercentageDiscount(percentageDiscount) - usageDiscount != null -> visitor.visitUsageDiscount(usageDiscount) - amountDiscount != null -> visitor.visitAmountDiscount(amountDiscount) - minimum != null -> visitor.visitMinimum(minimum) - maximum != null -> visitor.visitMaximum(maximum) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false + /** + * Sets [Builder.unitRatingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.unitRatingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun unitRatingKey(unitRatingKey: JsonField) = apply { + this.unitRatingKey = unitRatingKey + } - fun validate(): Adjustment = apply { - if (validated) { - return@apply - } + /** + * An optional key in the event data to group by (e.g., event ID). All + * events will also be grouped by their unit rate. + */ + fun groupingKey(groupingKey: String?) = + groupingKey(JsonField.ofNullable(groupingKey)) - accept( - object : Visitor { - override fun visitPercentageDiscount( - percentageDiscount: NewPercentageDiscount - ) { - percentageDiscount.validate() + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey } - override fun visitUsageDiscount(usageDiscount: NewUsageDiscount) { - usageDiscount.validate() - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - override fun visitAmountDiscount(amountDiscount: NewAmountDiscount) { - amountDiscount.validate() + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) } - override fun visitMinimum(minimum: NewMinimum) { - minimum.validate() + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) } - override fun visitMaximum(maximum: NewMaximum) { - maximum.validate() + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) } + + /** + * Returns an immutable instance of [EventOutputConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .unitRatingKey() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): EventOutputConfig = + EventOutputConfig( + checkRequired("unitRatingKey", unitRatingKey), + groupingKey, + additionalProperties.toMutableMap(), + ) } - ) - validated = true - } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + private var validated: Boolean = false - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitPercentageDiscount( - percentageDiscount: NewPercentageDiscount - ) = percentageDiscount.validity() + fun validate(): EventOutputConfig = apply { + if (validated) { + return@apply + } - override fun visitUsageDiscount(usageDiscount: NewUsageDiscount) = - usageDiscount.validity() + unitRatingKey() + groupingKey() + validated = true + } - override fun visitAmountDiscount(amountDiscount: NewAmountDiscount) = - amountDiscount.validity() + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - override fun visitMinimum(minimum: NewMinimum) = minimum.validity() + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (unitRatingKey.asKnown() == null) 0 else 1) + + (if (groupingKey.asKnown() == null) 0 else 1) - override fun visitMaximum(maximum: NewMaximum) = maximum.validity() + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - override fun unknown(json: JsonValue?) = 0 + return other is EventOutputConfig && + unitRatingKey == other.unitRatingKey && + groupingKey == other.groupingKey && + additionalProperties == other.additionalProperties } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - return other is Adjustment && - percentageDiscount == other.percentageDiscount && - usageDiscount == other.usageDiscount && - amountDiscount == other.amountDiscount && - minimum == other.minimum && - maximum == other.maximum - } + private val hashCode: Int by lazy { + Objects.hash(unitRatingKey, groupingKey, additionalProperties) + } - override fun hashCode(): Int = - Objects.hash(percentageDiscount, usageDiscount, amountDiscount, minimum, maximum) + override fun hashCode(): Int = hashCode - override fun toString(): String = - when { - percentageDiscount != null -> - "Adjustment{percentageDiscount=$percentageDiscount}" - usageDiscount != null -> "Adjustment{usageDiscount=$usageDiscount}" - amountDiscount != null -> "Adjustment{amountDiscount=$amountDiscount}" - minimum != null -> "Adjustment{minimum=$minimum}" - maximum != null -> "Adjustment{maximum=$maximum}" - _json != null -> "Adjustment{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Adjustment") + override fun toString() = + "EventOutputConfig{unitRatingKey=$unitRatingKey, groupingKey=$groupingKey, additionalProperties=$additionalProperties}" } - companion object { + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { - fun ofPercentageDiscount(percentageDiscount: NewPercentageDiscount) = - Adjustment(percentageDiscount = percentageDiscount) + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties - fun ofUsageDiscount(usageDiscount: NewUsageDiscount) = - Adjustment(usageDiscount = usageDiscount) + fun toBuilder() = Builder().from(this) - fun ofAmountDiscount(amountDiscount: NewAmountDiscount) = - Adjustment(amountDiscount = amountDiscount) + companion object { - fun ofMinimum(minimum: NewMinimum) = Adjustment(minimum = minimum) + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } - fun ofMaximum(maximum: NewMaximum) = Adjustment(maximum = maximum) - } + /** A builder for [Metadata]. */ + class Builder internal constructor() { - /** - * An interface that defines how to map each variant of [Adjustment] to a value of type - * [T]. - */ - interface Visitor { + private var additionalProperties: MutableMap = + mutableMapOf() - fun visitPercentageDiscount(percentageDiscount: NewPercentageDiscount): T + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } - fun visitUsageDiscount(usageDiscount: NewUsageDiscount): T + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun visitAmountDiscount(amountDiscount: NewAmountDiscount): T + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun visitMinimum(minimum: NewMinimum): T + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun visitMaximum(maximum: NewMaximum): T + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - /** - * Maps an unknown variant of [Adjustment] to a value of type [T]. - * - * An instance of [Adjustment] can contain an unknown variant if it was deserialized - * from data that doesn't match any known variant. For example, if the SDK is on an - * older version than the API, then the API may respond with new variants that the - * SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown Adjustment: $json") - } - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - internal class Deserializer : BaseDeserializer(Adjustment::class) { + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } - override fun ObjectCodec.deserialize(node: JsonNode): Adjustment { - val json = JsonValue.fromJsonNode(node) - val adjustmentType = json.asObject()?.get("adjustment_type")?.asString() + private var validated: Boolean = false - when (adjustmentType) { - "percentage_discount" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Adjustment(percentageDiscount = it, _json = json) } - ?: Adjustment(_json = json) - } - "usage_discount" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(usageDiscount = it, _json = json) - } ?: Adjustment(_json = json) + fun validate(): Metadata = apply { + if (validated) { + return@apply } - "amount_discount" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(amountDiscount = it, _json = json) - } ?: Adjustment(_json = json) + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false } - "minimum" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(minimum = it, _json = json) - } ?: Adjustment(_json = json) + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() } - "maximum" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(maximum = it, _json = json) - } ?: Adjustment(_json = json) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } + + return other is Metadata && + additionalProperties == other.additionalProperties } - return Adjustment(_json = json) - } - } + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - internal class Serializer : BaseSerializer(Adjustment::class) { + override fun hashCode(): Int = hashCode - override fun serialize( - value: Adjustment, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.percentageDiscount != null -> - generator.writeObject(value.percentageDiscount) - value.usageDiscount != null -> generator.writeObject(value.usageDiscount) - value.amountDiscount != null -> generator.writeObject(value.amountDiscount) - value.minimum != null -> generator.writeObject(value.minimum) - value.maximum != null -> generator.writeObject(value.maximum) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Adjustment") + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } + + return other is EventOutput && + cadence == other.cadence && + eventOutputConfig == other.eventOutputConfig && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + eventOutputConfig, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties, + ) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "EventOutput{cadence=$cadence, eventOutputConfig=$eventOutputConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } } @@ -10196,238 +10719,213 @@ private constructor( return true } - return other is ReplaceAdjustment && - adjustment == other.adjustment && - replacesAdjustmentId == other.replacesAdjustmentId && + return other is AddPrice && + allocationPrice == other.allocationPrice && + discounts == other.discounts && + endDate == other.endDate && + externalPriceId == other.externalPriceId && + maximumAmount == other.maximumAmount && + minimumAmount == other.minimumAmount && + planPhaseOrder == other.planPhaseOrder && + price == other.price && + priceId == other.priceId && + startDate == other.startDate && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(adjustment, replacesAdjustmentId, additionalProperties) + Objects.hash( + allocationPrice, + discounts, + endDate, + externalPriceId, + maximumAmount, + minimumAmount, + planPhaseOrder, + price, + priceId, + startDate, + additionalProperties, + ) } override fun hashCode(): Int = hashCode override fun toString() = - "ReplaceAdjustment{adjustment=$adjustment, replacesAdjustmentId=$replacesAdjustmentId, additionalProperties=$additionalProperties}" + "AddPrice{allocationPrice=$allocationPrice, discounts=$discounts, endDate=$endDate, externalPriceId=$externalPriceId, maximumAmount=$maximumAmount, minimumAmount=$minimumAmount, planPhaseOrder=$planPhaseOrder, price=$price, priceId=$priceId, startDate=$startDate, additionalProperties=$additionalProperties}" } - class ReplacePrice - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val replacesPriceId: JsonField, - private val allocationPrice: JsonField, - private val discounts: JsonField>, - private val externalPriceId: JsonField, - private val fixedPriceQuantity: JsonField, - private val maximumAmount: JsonField, - private val minimumAmount: JsonField, - private val price: JsonField, - private val priceId: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("replaces_price_id") - @ExcludeMissing - replacesPriceId: JsonField = JsonMissing.of(), - @JsonProperty("allocation_price") - @ExcludeMissing - allocationPrice: JsonField = JsonMissing.of(), - @JsonProperty("discounts") - @ExcludeMissing - discounts: JsonField> = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("maximum_amount") - @ExcludeMissing - maximumAmount: JsonField = JsonMissing.of(), - @JsonProperty("minimum_amount") - @ExcludeMissing - minimumAmount: JsonField = JsonMissing.of(), - @JsonProperty("price") @ExcludeMissing price: JsonField = JsonMissing.of(), - @JsonProperty("price_id") @ExcludeMissing priceId: JsonField = JsonMissing.of(), - ) : this( - replacesPriceId, - allocationPrice, - discounts, - externalPriceId, - fixedPriceQuantity, - maximumAmount, - minimumAmount, - price, - priceId, - mutableMapOf(), - ) + /** + * Reset billing periods to be aligned with the plan change's effective date or start of the + * month. Defaults to `unchanged` which keeps subscription's existing billing cycle alignment. + */ + class BillingCycleAlignment + @JsonCreator + private constructor(private val value: JsonField) : Enum { /** - * The id of the price on the plan to replace in the subscription. + * Returns this class instance's raw value. * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. */ - fun replacesPriceId(): String = replacesPriceId.getRequired("replaces_price_id") + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val UNCHANGED = of("unchanged") + + val PLAN_CHANGE_DATE = of("plan_change_date") + + val START_OF_MONTH = of("start_of_month") + + fun of(value: String) = BillingCycleAlignment(JsonField.of(value)) + } + + /** An enum containing [BillingCycleAlignment]'s known values. */ + enum class Known { + UNCHANGED, + PLAN_CHANGE_DATE, + START_OF_MONTH, + } /** - * The definition of a new allocation price to create and add to the subscription. + * An enum containing [BillingCycleAlignment]'s known values, as well as an [_UNKNOWN] + * member. * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). + * An instance of [BillingCycleAlignment] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. */ - fun allocationPrice(): NewAllocationPrice? = allocationPrice.getNullable("allocation_price") + enum class Value { + UNCHANGED, + PLAN_CHANGE_DATE, + START_OF_MONTH, + /** + * An enum member indicating that [BillingCycleAlignment] was instantiated with an + * unknown value. + */ + _UNKNOWN, + } /** - * [DEPRECATED] Use add_adjustments instead. The subscription's discounts for the - * replacement price. + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. */ - @Deprecated("deprecated") - fun discounts(): List? = discounts.getNullable("discounts") + fun value(): Value = + when (this) { + UNCHANGED -> Value.UNCHANGED + PLAN_CHANGE_DATE -> Value.PLAN_CHANGE_DATE + START_OF_MONTH -> Value.START_OF_MONTH + else -> Value._UNKNOWN + } /** - * The external price id of the price to add to the subscription. + * Returns an enum member corresponding to this class instance's value. * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") - - /** - * The new quantity of the price, if the price is a fixed price. + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). + * @throws OrbInvalidDataException if this class instance's value is a not a known member. */ - fun fixedPriceQuantity(): Double? = fixedPriceQuantity.getNullable("fixed_price_quantity") + fun known(): Known = + when (this) { + UNCHANGED -> Known.UNCHANGED + PLAN_CHANGE_DATE -> Known.PLAN_CHANGE_DATE + START_OF_MONTH -> Known.START_OF_MONTH + else -> throw OrbInvalidDataException("Unknown BillingCycleAlignment: $value") + } /** - * [DEPRECATED] Use add_adjustments instead. The subscription's maximum amount for the - * replacement price. + * Returns this class instance's primitive wire representation. * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - @Deprecated("deprecated") - fun maximumAmount(): String? = maximumAmount.getNullable("maximum_amount") - - /** - * [DEPRECATED] Use add_adjustments instead. The subscription's minimum amount for the - * replacement price. + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). + * @throws OrbInvalidDataException if this class instance's value does not have the expected + * primitive type. */ - @Deprecated("deprecated") - fun minimumAmount(): String? = minimumAmount.getNullable("minimum_amount") + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") - /** - * New subscription price request body params. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun price(): Price? = price.getNullable("price") + private var validated: Boolean = false - /** - * The id of the price to add to the subscription. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun priceId(): String? = priceId.getNullable("price_id") + fun validate(): BillingCycleAlignment = apply { + if (validated) { + return@apply + } - /** - * Returns the raw JSON value of [replacesPriceId]. - * - * Unlike [replacesPriceId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("replaces_price_id") - @ExcludeMissing - fun _replacesPriceId(): JsonField = replacesPriceId + known() + validated = true + } - /** - * Returns the raw JSON value of [allocationPrice]. - * - * Unlike [allocationPrice], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("allocation_price") - @ExcludeMissing - fun _allocationPrice(): JsonField = allocationPrice + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } /** - * Returns the raw JSON value of [discounts]. + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * Unlike [discounts], this method doesn't throw if the JSON field has an unexpected type. + * Used for best match union deserialization. */ - @Deprecated("deprecated") - @JsonProperty("discounts") - @ExcludeMissing - fun _discounts(): JsonField> = discounts + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - /** - * Returns the raw JSON value of [externalPriceId]. - * - * Unlike [externalPriceId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * Returns the raw JSON value of [fixedPriceQuantity]. - * - * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + return other is BillingCycleAlignment && value == other.value + } - /** - * Returns the raw JSON value of [maximumAmount]. - * - * Unlike [maximumAmount], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @Deprecated("deprecated") - @JsonProperty("maximum_amount") - @ExcludeMissing - fun _maximumAmount(): JsonField = maximumAmount + override fun hashCode() = value.hashCode() - /** - * Returns the raw JSON value of [minimumAmount]. - * - * Unlike [minimumAmount], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @Deprecated("deprecated") - @JsonProperty("minimum_amount") - @ExcludeMissing - fun _minimumAmount(): JsonField = minimumAmount + override fun toString() = value.toString() + } + + class RemoveAdjustment + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val adjustmentId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("adjustment_id") + @ExcludeMissing + adjustmentId: JsonField = JsonMissing.of() + ) : this(adjustmentId, mutableMapOf()) /** - * Returns the raw JSON value of [price]. + * The id of the adjustment to remove on the subscription. * - * Unlike [price], this method doesn't throw if the JSON field has an unexpected type. + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ - @JsonProperty("price") @ExcludeMissing fun _price(): JsonField = price + fun adjustmentId(): String = adjustmentId.getRequired("adjustment_id") /** - * Returns the raw JSON value of [priceId]. + * Returns the raw JSON value of [adjustmentId]. * - * Unlike [priceId], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [adjustmentId], this method doesn't throw if the JSON field has an unexpected + * type. */ - @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId + @JsonProperty("adjustment_id") + @ExcludeMissing + fun _adjustmentId(): JsonField = adjustmentId @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -10444,107 +10942,205 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [ReplacePrice]. + * Returns a mutable builder for constructing an instance of [RemoveAdjustment]. * * The following fields are required: * ```kotlin - * .replacesPriceId() + * .adjustmentId() * ``` */ fun builder() = Builder() } - /** A builder for [ReplacePrice]. */ + /** A builder for [RemoveAdjustment]. */ class Builder internal constructor() { - private var replacesPriceId: JsonField? = null - private var allocationPrice: JsonField = JsonMissing.of() - private var discounts: JsonField>? = null - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var maximumAmount: JsonField = JsonMissing.of() - private var minimumAmount: JsonField = JsonMissing.of() - private var price: JsonField = JsonMissing.of() - private var priceId: JsonField = JsonMissing.of() + private var adjustmentId: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(replacePrice: ReplacePrice) = apply { - replacesPriceId = replacePrice.replacesPriceId - allocationPrice = replacePrice.allocationPrice - discounts = replacePrice.discounts.map { it.toMutableList() } - externalPriceId = replacePrice.externalPriceId - fixedPriceQuantity = replacePrice.fixedPriceQuantity - maximumAmount = replacePrice.maximumAmount - minimumAmount = replacePrice.minimumAmount - price = replacePrice.price - priceId = replacePrice.priceId - additionalProperties = replacePrice.additionalProperties.toMutableMap() + internal fun from(removeAdjustment: RemoveAdjustment) = apply { + adjustmentId = removeAdjustment.adjustmentId + additionalProperties = removeAdjustment.additionalProperties.toMutableMap() } - /** The id of the price on the plan to replace in the subscription. */ - fun replacesPriceId(replacesPriceId: String) = - replacesPriceId(JsonField.of(replacesPriceId)) + /** The id of the adjustment to remove on the subscription. */ + fun adjustmentId(adjustmentId: String) = adjustmentId(JsonField.of(adjustmentId)) /** - * Sets [Builder.replacesPriceId] to an arbitrary JSON value. + * Sets [Builder.adjustmentId] to an arbitrary JSON value. * - * You should usually call [Builder.replacesPriceId] with a well-typed [String] value + * You should usually call [Builder.adjustmentId] with a well-typed [String] value * instead. This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun replacesPriceId(replacesPriceId: JsonField) = apply { - this.replacesPriceId = replacesPriceId + fun adjustmentId(adjustmentId: JsonField) = apply { + this.adjustmentId = adjustmentId } - /** The definition of a new allocation price to create and add to the subscription. */ - fun allocationPrice(allocationPrice: NewAllocationPrice?) = - allocationPrice(JsonField.ofNullable(allocationPrice)) + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** - * Sets [Builder.allocationPrice] to an arbitrary JSON value. - * - * You should usually call [Builder.allocationPrice] with a well-typed - * [NewAllocationPrice] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun allocationPrice(allocationPrice: JsonField) = apply { - this.allocationPrice = allocationPrice + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) } - /** - * [DEPRECATED] Use add_adjustments instead. The subscription's discounts for the - * replacement price. - */ - @Deprecated("deprecated") - fun discounts(discounts: List?) = - discounts(JsonField.ofNullable(discounts)) + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - /** - * Sets [Builder.discounts] to an arbitrary JSON value. - * - * You should usually call [Builder.discounts] with a well-typed - * `List` value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - @Deprecated("deprecated") - fun discounts(discounts: JsonField>) = apply { - this.discounts = discounts.map { it.toMutableList() } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) } /** - * Adds a single [DiscountOverride] to [discounts]. + * Returns an immutable instance of [RemoveAdjustment]. * - * @throws IllegalStateException if the field was previously set to a non-list. + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .adjustmentId() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ - @Deprecated("deprecated") - fun addDiscount(discount: DiscountOverride) = apply { - discounts = - (discounts ?: JsonField.of(mutableListOf())).also { - checkKnown("discounts", it).add(discount) - } + fun build(): RemoveAdjustment = + RemoveAdjustment( + checkRequired("adjustmentId", adjustmentId), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): RemoveAdjustment = apply { + if (validated) { + return@apply } - /** The external price id of the price to add to the subscription. */ + adjustmentId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = (if (adjustmentId.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RemoveAdjustment && + adjustmentId == other.adjustmentId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(adjustmentId, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "RemoveAdjustment{adjustmentId=$adjustmentId, additionalProperties=$additionalProperties}" + } + + class RemovePrice + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val externalPriceId: JsonField, + private val priceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("price_id") @ExcludeMissing priceId: JsonField = JsonMissing.of(), + ) : this(externalPriceId, priceId, mutableMapOf()) + + /** + * The external price id of the price to remove on the subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * The id of the price to remove on the subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun priceId(): String? = priceId.getNullable("price_id") + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [priceId]. + * + * Unlike [priceId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [RemovePrice]. */ + fun builder() = Builder() + } + + /** A builder for [RemovePrice]. */ + class Builder internal constructor() { + + private var externalPriceId: JsonField = JsonMissing.of() + private var priceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(removePrice: RemovePrice) = apply { + externalPriceId = removePrice.externalPriceId + priceId = removePrice.priceId + additionalProperties = removePrice.additionalProperties.toMutableMap() + } + + /** The external price id of the price to remove on the subscription. */ fun externalPriceId(externalPriceId: String?) = externalPriceId(JsonField.ofNullable(externalPriceId)) @@ -10559,235 +11155,309 @@ private constructor( this.externalPriceId = externalPriceId } - /** The new quantity of the price, if the price is a fixed price. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = - fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) - - /** - * Alias for [Builder.fixedPriceQuantity]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) + /** The id of the price to remove on the subscription. */ + fun priceId(priceId: String?) = priceId(JsonField.ofNullable(priceId)) /** - * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * Sets [Builder.priceId] to an arbitrary JSON value. * - * You should usually call [Builder.fixedPriceQuantity] with a well-typed [Double] value - * instead. This method is primarily for setting the field to an undocumented or not yet + * You should usually call [Builder.priceId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { - this.fixedPriceQuantity = fixedPriceQuantity + fun priceId(priceId: JsonField) = apply { this.priceId = priceId } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) } - /** - * [DEPRECATED] Use add_adjustments instead. The subscription's maximum amount for the - * replacement price. - */ - @Deprecated("deprecated") - fun maximumAmount(maximumAmount: String?) = - maximumAmount(JsonField.ofNullable(maximumAmount)) + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * Sets [Builder.maximumAmount] to an arbitrary JSON value. - * - * You should usually call [Builder.maximumAmount] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - @Deprecated("deprecated") - fun maximumAmount(maximumAmount: JsonField) = apply { - this.maximumAmount = maximumAmount + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) } - /** - * [DEPRECATED] Use add_adjustments instead. The subscription's minimum amount for the - * replacement price. - */ - @Deprecated("deprecated") - fun minimumAmount(minimumAmount: String?) = - minimumAmount(JsonField.ofNullable(minimumAmount)) + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - /** - * Sets [Builder.minimumAmount] to an arbitrary JSON value. - * - * You should usually call [Builder.minimumAmount] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - @Deprecated("deprecated") - fun minimumAmount(minimumAmount: JsonField) = apply { - this.minimumAmount = minimumAmount + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) } - /** New subscription price request body params. */ - fun price(price: Price?) = price(JsonField.ofNullable(price)) - /** - * Sets [Builder.price] to an arbitrary JSON value. + * Returns an immutable instance of [RemovePrice]. * - * You should usually call [Builder.price] with a well-typed [Price] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. + * Further updates to this [Builder] will not mutate the returned instance. */ - fun price(price: JsonField) = apply { this.price = price } + fun build(): RemovePrice = + RemovePrice(externalPriceId, priceId, additionalProperties.toMutableMap()) + } - /** Alias for calling [price] with `Price.ofUnit(unit)`. */ - fun price(unit: NewSubscriptionUnitPrice) = price(Price.ofUnit(unit)) + private var validated: Boolean = false - /** Alias for calling [price] with `Price.ofTiered(tiered)`. */ - fun price(tiered: NewSubscriptionTieredPrice) = price(Price.ofTiered(tiered)) + fun validate(): RemovePrice = apply { + if (validated) { + return@apply + } - /** Alias for calling [price] with `Price.ofBulk(bulk)`. */ - fun price(bulk: NewSubscriptionBulkPrice) = price(Price.ofBulk(bulk)) + externalPriceId() + priceId() + validated = true + } - /** Alias for calling [price] with `Price.ofPackage(package_)`. */ - fun price(package_: NewSubscriptionPackagePrice) = price(Price.ofPackage(package_)) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - /** Alias for calling [price] with `Price.ofMatrix(matrix)`. */ - fun price(matrix: NewSubscriptionMatrixPrice) = price(Price.ofMatrix(matrix)) + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (priceId.asKnown() == null) 0 else 1) - /** - * Alias for calling [price] with `Price.ofThresholdTotalAmount(thresholdTotalAmount)`. - */ - fun price(thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice) = - price(Price.ofThresholdTotalAmount(thresholdTotalAmount)) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** Alias for calling [price] with `Price.ofTieredPackage(tieredPackage)`. */ - fun price(tieredPackage: NewSubscriptionTieredPackagePrice) = - price(Price.ofTieredPackage(tieredPackage)) + return other is RemovePrice && + externalPriceId == other.externalPriceId && + priceId == other.priceId && + additionalProperties == other.additionalProperties + } - /** Alias for calling [price] with `Price.ofTieredWithMinimum(tieredWithMinimum)`. */ - fun price(tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice) = - price(Price.ofTieredWithMinimum(tieredWithMinimum)) + private val hashCode: Int by lazy { + Objects.hash(externalPriceId, priceId, additionalProperties) + } - /** Alias for calling [price] with `Price.ofGroupedTiered(groupedTiered)`. */ - fun price(groupedTiered: NewSubscriptionGroupedTieredPrice) = - price(Price.ofGroupedTiered(groupedTiered)) + override fun hashCode(): Int = hashCode - /** - * Alias for calling [price] with - * `Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)`. - */ - fun price(tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice) = - price(Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)) + override fun toString() = + "RemovePrice{externalPriceId=$externalPriceId, priceId=$priceId, additionalProperties=$additionalProperties}" + } - /** - * Alias for calling [price] with - * `Price.ofPackageWithAllocation(packageWithAllocation)`. - */ - fun price(packageWithAllocation: NewSubscriptionPackageWithAllocationPrice) = - price(Price.ofPackageWithAllocation(packageWithAllocation)) + class ReplaceAdjustment + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val adjustment: JsonField, + private val replacesAdjustmentId: JsonField, + private val additionalProperties: MutableMap, + ) { - /** Alias for calling [price] with `Price.ofUnitWithPercent(unitWithPercent)`. */ - fun price(unitWithPercent: NewSubscriptionUnitWithPercentPrice) = - price(Price.ofUnitWithPercent(unitWithPercent)) + @JsonCreator + private constructor( + @JsonProperty("adjustment") + @ExcludeMissing + adjustment: JsonField = JsonMissing.of(), + @JsonProperty("replaces_adjustment_id") + @ExcludeMissing + replacesAdjustmentId: JsonField = JsonMissing.of(), + ) : this(adjustment, replacesAdjustmentId, mutableMapOf()) - /** - * Alias for calling [price] with `Price.ofMatrixWithAllocation(matrixWithAllocation)`. - */ - fun price(matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice) = - price(Price.ofMatrixWithAllocation(matrixWithAllocation)) + /** + * The definition of a new adjustment to create and add to the subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun adjustment(): Adjustment = adjustment.getRequired("adjustment") - /** - * Alias for calling [price] with `Price.ofTieredWithProration(tieredWithProration)`. - */ - fun price(tieredWithProration: Price.TieredWithProration) = - price(Price.ofTieredWithProration(tieredWithProration)) + /** + * The id of the adjustment on the plan to replace in the subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun replacesAdjustmentId(): String = + replacesAdjustmentId.getRequired("replaces_adjustment_id") - /** Alias for calling [price] with `Price.ofUnitWithProration(unitWithProration)`. */ - fun price(unitWithProration: NewSubscriptionUnitWithProrationPrice) = - price(Price.ofUnitWithProration(unitWithProration)) + /** + * Returns the raw JSON value of [adjustment]. + * + * Unlike [adjustment], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("adjustment") + @ExcludeMissing + fun _adjustment(): JsonField = adjustment - /** Alias for calling [price] with `Price.ofGroupedAllocation(groupedAllocation)`. */ - fun price(groupedAllocation: NewSubscriptionGroupedAllocationPrice) = - price(Price.ofGroupedAllocation(groupedAllocation)) + /** + * Returns the raw JSON value of [replacesAdjustmentId]. + * + * Unlike [replacesAdjustmentId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("replaces_adjustment_id") + @ExcludeMissing + fun _replacesAdjustmentId(): JsonField = replacesAdjustmentId - /** Alias for calling [price] with `Price.ofBulkWithProration(bulkWithProration)`. */ - fun price(bulkWithProration: NewSubscriptionBulkWithProrationPrice) = - price(Price.ofBulkWithProration(bulkWithProration)) + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { /** - * Alias for calling [price] with - * `Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)`. + * Returns a mutable builder for constructing an instance of [ReplaceAdjustment]. + * + * The following fields are required: + * ```kotlin + * .adjustment() + * .replacesAdjustmentId() + * ``` */ - fun price(groupedWithProratedMinimum: NewSubscriptionGroupedWithProratedMinimumPrice) = - price(Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)) + fun builder() = Builder() + } + + /** A builder for [ReplaceAdjustment]. */ + class Builder internal constructor() { + + private var adjustment: JsonField? = null + private var replacesAdjustmentId: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(replaceAdjustment: ReplaceAdjustment) = apply { + adjustment = replaceAdjustment.adjustment + replacesAdjustmentId = replaceAdjustment.replacesAdjustmentId + additionalProperties = replaceAdjustment.additionalProperties.toMutableMap() + } + + /** The definition of a new adjustment to create and add to the subscription. */ + fun adjustment(adjustment: Adjustment) = adjustment(JsonField.of(adjustment)) /** - * Alias for calling [price] with - * `Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)`. + * Sets [Builder.adjustment] to an arbitrary JSON value. + * + * You should usually call [Builder.adjustment] with a well-typed [Adjustment] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun price(groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice) = - price(Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)) + fun adjustment(adjustment: JsonField) = apply { + this.adjustment = adjustment + } /** - * Alias for calling [price] with - * `Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)`. + * Alias for calling [adjustment] with + * `Adjustment.ofPercentageDiscount(percentageDiscount)`. */ - fun price(groupedWithMinMaxThresholds: Price.GroupedWithMinMaxThresholds) = - price(Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)) + fun adjustment(percentageDiscount: NewPercentageDiscount) = + adjustment(Adjustment.ofPercentageDiscount(percentageDiscount)) /** - * Alias for calling [price] with - * `Price.ofMatrixWithDisplayName(matrixWithDisplayName)`. + * Alias for calling [adjustment] with the following: + * ```kotlin + * NewPercentageDiscount.builder() + * .adjustmentType(NewPercentageDiscount.AdjustmentType.PERCENTAGE_DISCOUNT) + * .percentageDiscount(percentageDiscount) + * .build() + * ``` */ - fun price(matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice) = - price(Price.ofMatrixWithDisplayName(matrixWithDisplayName)) + fun percentageDiscountAdjustment(percentageDiscount: Double) = + adjustment( + NewPercentageDiscount.builder() + .adjustmentType(NewPercentageDiscount.AdjustmentType.PERCENTAGE_DISCOUNT) + .percentageDiscount(percentageDiscount) + .build() + ) + + /** Alias for calling [adjustment] with `Adjustment.ofUsageDiscount(usageDiscount)`. */ + fun adjustment(usageDiscount: NewUsageDiscount) = + adjustment(Adjustment.ofUsageDiscount(usageDiscount)) /** - * Alias for calling [price] with `Price.ofGroupedTieredPackage(groupedTieredPackage)`. + * Alias for calling [adjustment] with the following: + * ```kotlin + * NewUsageDiscount.builder() + * .adjustmentType(NewUsageDiscount.AdjustmentType.USAGE_DISCOUNT) + * .usageDiscount(usageDiscount) + * .build() + * ``` */ - fun price(groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice) = - price(Price.ofGroupedTieredPackage(groupedTieredPackage)) + fun usageDiscountAdjustment(usageDiscount: Double) = + adjustment( + NewUsageDiscount.builder() + .adjustmentType(NewUsageDiscount.AdjustmentType.USAGE_DISCOUNT) + .usageDiscount(usageDiscount) + .build() + ) /** - * Alias for calling [price] with - * `Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)`. + * Alias for calling [adjustment] with `Adjustment.ofAmountDiscount(amountDiscount)`. */ - fun price(maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice) = - price(Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)) + fun adjustment(amountDiscount: NewAmountDiscount) = + adjustment(Adjustment.ofAmountDiscount(amountDiscount)) /** - * Alias for calling [price] with - * `Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)`. - */ - fun price( - scalableMatrixWithUnitPricing: NewSubscriptionScalableMatrixWithUnitPricingPrice - ) = price(Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)) - - /** - * Alias for calling [price] with - * `Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)`. + * Alias for calling [adjustment] with the following: + * ```kotlin + * NewAmountDiscount.builder() + * .adjustmentType(NewAmountDiscount.AdjustmentType.AMOUNT_DISCOUNT) + * .amountDiscount(amountDiscount) + * .build() + * ``` */ - fun price( - scalableMatrixWithTieredPricing: NewSubscriptionScalableMatrixWithTieredPricingPrice - ) = price(Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)) + fun amountDiscountAdjustment(amountDiscount: String) = + adjustment( + NewAmountDiscount.builder() + .adjustmentType(NewAmountDiscount.AdjustmentType.AMOUNT_DISCOUNT) + .amountDiscount(amountDiscount) + .build() + ) + + /** Alias for calling [adjustment] with `Adjustment.ofMinimum(minimum)`. */ + fun adjustment(minimum: NewMinimum) = adjustment(Adjustment.ofMinimum(minimum)) + + /** Alias for calling [adjustment] with `Adjustment.ofMaximum(maximum)`. */ + fun adjustment(maximum: NewMaximum) = adjustment(Adjustment.ofMaximum(maximum)) /** - * Alias for calling [price] with - * `Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)`. + * Alias for calling [adjustment] with the following: + * ```kotlin + * NewMaximum.builder() + * .adjustmentType(NewMaximum.AdjustmentType.MAXIMUM) + * .maximumAmount(maximumAmount) + * .build() + * ``` */ - fun price(cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice) = - price(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) - - /** Alias for calling [price] with `Price.ofMinimum(minimum)`. */ - fun price(minimum: NewSubscriptionMinimumCompositePrice) = - price(Price.ofMinimum(minimum)) + fun maximumAdjustment(maximumAmount: String) = + adjustment( + NewMaximum.builder() + .adjustmentType(NewMaximum.AdjustmentType.MAXIMUM) + .maximumAmount(maximumAmount) + .build() + ) - /** The id of the price to add to the subscription. */ - fun priceId(priceId: String?) = priceId(JsonField.ofNullable(priceId)) + /** The id of the adjustment on the plan to replace in the subscription. */ + fun replacesAdjustmentId(replacesAdjustmentId: String) = + replacesAdjustmentId(JsonField.of(replacesAdjustmentId)) /** - * Sets [Builder.priceId] to an arbitrary JSON value. + * Sets [Builder.replacesAdjustmentId] to an arbitrary JSON value. * - * You should usually call [Builder.priceId] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. + * You should usually call [Builder.replacesAdjustmentId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. */ - fun priceId(priceId: JsonField) = apply { this.priceId = priceId } + fun replacesAdjustmentId(replacesAdjustmentId: JsonField) = apply { + this.replacesAdjustmentId = replacesAdjustmentId + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -10809,48 +11479,35 @@ private constructor( } /** - * Returns an immutable instance of [ReplacePrice]. + * Returns an immutable instance of [ReplaceAdjustment]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```kotlin - * .replacesPriceId() + * .adjustment() + * .replacesAdjustmentId() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): ReplacePrice = - ReplacePrice( - checkRequired("replacesPriceId", replacesPriceId), - allocationPrice, - (discounts ?: JsonMissing.of()).map { it.toImmutable() }, - externalPriceId, - fixedPriceQuantity, - maximumAmount, - minimumAmount, - price, - priceId, + fun build(): ReplaceAdjustment = + ReplaceAdjustment( + checkRequired("adjustment", adjustment), + checkRequired("replacesAdjustmentId", replacesAdjustmentId), additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): ReplacePrice = apply { + fun validate(): ReplaceAdjustment = apply { if (validated) { return@apply } - replacesPriceId() - allocationPrice()?.validate() - discounts()?.forEach { it.validate() } - externalPriceId() - fixedPriceQuantity() - maximumAmount() - minimumAmount() - price()?.validate() - priceId() + adjustment().validate() + replacesAdjustmentId() validated = true } @@ -10869,1199 +11526,3942 @@ private constructor( * Used for best match union deserialization. */ internal fun validity(): Int = - (if (replacesPriceId.asKnown() == null) 0 else 1) + - (allocationPrice.asKnown()?.validity() ?: 0) + - (discounts.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + - (if (externalPriceId.asKnown() == null) 0 else 1) + - (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + - (if (maximumAmount.asKnown() == null) 0 else 1) + - (if (minimumAmount.asKnown() == null) 0 else 1) + - (price.asKnown()?.validity() ?: 0) + - (if (priceId.asKnown() == null) 0 else 1) + (adjustment.asKnown()?.validity() ?: 0) + + (if (replacesAdjustmentId.asKnown() == null) 0 else 1) - /** New subscription price request body params. */ - @JsonDeserialize(using = Price.Deserializer::class) - @JsonSerialize(using = Price.Serializer::class) - class Price + /** The definition of a new adjustment to create and add to the subscription. */ + @JsonDeserialize(using = Adjustment.Deserializer::class) + @JsonSerialize(using = Adjustment.Serializer::class) + class Adjustment private constructor( - private val unit: NewSubscriptionUnitPrice? = null, - private val tiered: NewSubscriptionTieredPrice? = null, - private val bulk: NewSubscriptionBulkPrice? = null, - private val package_: NewSubscriptionPackagePrice? = null, - private val matrix: NewSubscriptionMatrixPrice? = null, - private val thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice? = null, - private val tieredPackage: NewSubscriptionTieredPackagePrice? = null, - private val tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice? = null, - private val groupedTiered: NewSubscriptionGroupedTieredPrice? = null, - private val tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice? = - null, - private val packageWithAllocation: NewSubscriptionPackageWithAllocationPrice? = null, - private val unitWithPercent: NewSubscriptionUnitWithPercentPrice? = null, - private val matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice? = null, - private val tieredWithProration: TieredWithProration? = null, - private val unitWithProration: NewSubscriptionUnitWithProrationPrice? = null, - private val groupedAllocation: NewSubscriptionGroupedAllocationPrice? = null, - private val bulkWithProration: NewSubscriptionBulkWithProrationPrice? = null, - private val groupedWithProratedMinimum: - NewSubscriptionGroupedWithProratedMinimumPrice? = - null, - private val groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice? = - null, - private val groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds? = null, - private val matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice? = null, - private val groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice? = null, - private val maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice? = null, - private val scalableMatrixWithUnitPricing: - NewSubscriptionScalableMatrixWithUnitPricingPrice? = - null, - private val scalableMatrixWithTieredPricing: - NewSubscriptionScalableMatrixWithTieredPricingPrice? = - null, - private val cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice? = null, - private val minimum: NewSubscriptionMinimumCompositePrice? = null, + private val percentageDiscount: NewPercentageDiscount? = null, + private val usageDiscount: NewUsageDiscount? = null, + private val amountDiscount: NewAmountDiscount? = null, + private val minimum: NewMinimum? = null, + private val maximum: NewMaximum? = null, private val _json: JsonValue? = null, ) { - fun unit(): NewSubscriptionUnitPrice? = unit - - fun tiered(): NewSubscriptionTieredPrice? = tiered + fun percentageDiscount(): NewPercentageDiscount? = percentageDiscount - fun bulk(): NewSubscriptionBulkPrice? = bulk + fun usageDiscount(): NewUsageDiscount? = usageDiscount - fun package_(): NewSubscriptionPackagePrice? = package_ + fun amountDiscount(): NewAmountDiscount? = amountDiscount - fun matrix(): NewSubscriptionMatrixPrice? = matrix + fun minimum(): NewMinimum? = minimum - fun thresholdTotalAmount(): NewSubscriptionThresholdTotalAmountPrice? = - thresholdTotalAmount + fun maximum(): NewMaximum? = maximum - fun tieredPackage(): NewSubscriptionTieredPackagePrice? = tieredPackage + fun isPercentageDiscount(): Boolean = percentageDiscount != null - fun tieredWithMinimum(): NewSubscriptionTieredWithMinimumPrice? = tieredWithMinimum + fun isUsageDiscount(): Boolean = usageDiscount != null - fun groupedTiered(): NewSubscriptionGroupedTieredPrice? = groupedTiered + fun isAmountDiscount(): Boolean = amountDiscount != null - fun tieredPackageWithMinimum(): NewSubscriptionTieredPackageWithMinimumPrice? = - tieredPackageWithMinimum + fun isMinimum(): Boolean = minimum != null - fun packageWithAllocation(): NewSubscriptionPackageWithAllocationPrice? = - packageWithAllocation + fun isMaximum(): Boolean = maximum != null - fun unitWithPercent(): NewSubscriptionUnitWithPercentPrice? = unitWithPercent + fun asPercentageDiscount(): NewPercentageDiscount = + percentageDiscount.getOrThrow("percentageDiscount") - fun matrixWithAllocation(): NewSubscriptionMatrixWithAllocationPrice? = - matrixWithAllocation + fun asUsageDiscount(): NewUsageDiscount = usageDiscount.getOrThrow("usageDiscount") - fun tieredWithProration(): TieredWithProration? = tieredWithProration + fun asAmountDiscount(): NewAmountDiscount = amountDiscount.getOrThrow("amountDiscount") - fun unitWithProration(): NewSubscriptionUnitWithProrationPrice? = unitWithProration + fun asMinimum(): NewMinimum = minimum.getOrThrow("minimum") - fun groupedAllocation(): NewSubscriptionGroupedAllocationPrice? = groupedAllocation + fun asMaximum(): NewMaximum = maximum.getOrThrow("maximum") - fun bulkWithProration(): NewSubscriptionBulkWithProrationPrice? = bulkWithProration + fun _json(): JsonValue? = _json - fun groupedWithProratedMinimum(): NewSubscriptionGroupedWithProratedMinimumPrice? = - groupedWithProratedMinimum + fun accept(visitor: Visitor): T = + when { + percentageDiscount != null -> + visitor.visitPercentageDiscount(percentageDiscount) + usageDiscount != null -> visitor.visitUsageDiscount(usageDiscount) + amountDiscount != null -> visitor.visitAmountDiscount(amountDiscount) + minimum != null -> visitor.visitMinimum(minimum) + maximum != null -> visitor.visitMaximum(maximum) + else -> visitor.unknown(_json) + } - fun groupedWithMeteredMinimum(): NewSubscriptionGroupedWithMeteredMinimumPrice? = - groupedWithMeteredMinimum + private var validated: Boolean = false - fun groupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds? = - groupedWithMinMaxThresholds + fun validate(): Adjustment = apply { + if (validated) { + return@apply + } - fun matrixWithDisplayName(): NewSubscriptionMatrixWithDisplayNamePrice? = - matrixWithDisplayName + accept( + object : Visitor { + override fun visitPercentageDiscount( + percentageDiscount: NewPercentageDiscount + ) { + percentageDiscount.validate() + } - fun groupedTieredPackage(): NewSubscriptionGroupedTieredPackagePrice? = - groupedTieredPackage + override fun visitUsageDiscount(usageDiscount: NewUsageDiscount) { + usageDiscount.validate() + } - fun maxGroupTieredPackage(): NewSubscriptionMaxGroupTieredPackagePrice? = - maxGroupTieredPackage + override fun visitAmountDiscount(amountDiscount: NewAmountDiscount) { + amountDiscount.validate() + } - fun scalableMatrixWithUnitPricing(): - NewSubscriptionScalableMatrixWithUnitPricingPrice? = scalableMatrixWithUnitPricing + override fun visitMinimum(minimum: NewMinimum) { + minimum.validate() + } - fun scalableMatrixWithTieredPricing(): - NewSubscriptionScalableMatrixWithTieredPricingPrice? = - scalableMatrixWithTieredPricing + override fun visitMaximum(maximum: NewMaximum) { + maximum.validate() + } + } + ) + validated = true + } - fun cumulativeGroupedBulk(): NewSubscriptionCumulativeGroupedBulkPrice? = - cumulativeGroupedBulk + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - fun minimum(): NewSubscriptionMinimumCompositePrice? = minimum + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitPercentageDiscount( + percentageDiscount: NewPercentageDiscount + ) = percentageDiscount.validity() - fun isUnit(): Boolean = unit != null + override fun visitUsageDiscount(usageDiscount: NewUsageDiscount) = + usageDiscount.validity() - fun isTiered(): Boolean = tiered != null + override fun visitAmountDiscount(amountDiscount: NewAmountDiscount) = + amountDiscount.validity() - fun isBulk(): Boolean = bulk != null + override fun visitMinimum(minimum: NewMinimum) = minimum.validity() - fun isPackage(): Boolean = package_ != null + override fun visitMaximum(maximum: NewMaximum) = maximum.validity() - fun isMatrix(): Boolean = matrix != null + override fun unknown(json: JsonValue?) = 0 + } + ) - fun isThresholdTotalAmount(): Boolean = thresholdTotalAmount != null + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun isTieredPackage(): Boolean = tieredPackage != null + return other is Adjustment && + percentageDiscount == other.percentageDiscount && + usageDiscount == other.usageDiscount && + amountDiscount == other.amountDiscount && + minimum == other.minimum && + maximum == other.maximum + } - fun isTieredWithMinimum(): Boolean = tieredWithMinimum != null + override fun hashCode(): Int = + Objects.hash(percentageDiscount, usageDiscount, amountDiscount, minimum, maximum) - fun isGroupedTiered(): Boolean = groupedTiered != null + override fun toString(): String = + when { + percentageDiscount != null -> + "Adjustment{percentageDiscount=$percentageDiscount}" + usageDiscount != null -> "Adjustment{usageDiscount=$usageDiscount}" + amountDiscount != null -> "Adjustment{amountDiscount=$amountDiscount}" + minimum != null -> "Adjustment{minimum=$minimum}" + maximum != null -> "Adjustment{maximum=$maximum}" + _json != null -> "Adjustment{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Adjustment") + } - fun isTieredPackageWithMinimum(): Boolean = tieredPackageWithMinimum != null + companion object { - fun isPackageWithAllocation(): Boolean = packageWithAllocation != null + fun ofPercentageDiscount(percentageDiscount: NewPercentageDiscount) = + Adjustment(percentageDiscount = percentageDiscount) - fun isUnitWithPercent(): Boolean = unitWithPercent != null + fun ofUsageDiscount(usageDiscount: NewUsageDiscount) = + Adjustment(usageDiscount = usageDiscount) - fun isMatrixWithAllocation(): Boolean = matrixWithAllocation != null + fun ofAmountDiscount(amountDiscount: NewAmountDiscount) = + Adjustment(amountDiscount = amountDiscount) - fun isTieredWithProration(): Boolean = tieredWithProration != null + fun ofMinimum(minimum: NewMinimum) = Adjustment(minimum = minimum) - fun isUnitWithProration(): Boolean = unitWithProration != null + fun ofMaximum(maximum: NewMaximum) = Adjustment(maximum = maximum) + } - fun isGroupedAllocation(): Boolean = groupedAllocation != null + /** + * An interface that defines how to map each variant of [Adjustment] to a value of type + * [T]. + */ + interface Visitor { - fun isBulkWithProration(): Boolean = bulkWithProration != null + fun visitPercentageDiscount(percentageDiscount: NewPercentageDiscount): T - fun isGroupedWithProratedMinimum(): Boolean = groupedWithProratedMinimum != null + fun visitUsageDiscount(usageDiscount: NewUsageDiscount): T - fun isGroupedWithMeteredMinimum(): Boolean = groupedWithMeteredMinimum != null + fun visitAmountDiscount(amountDiscount: NewAmountDiscount): T - fun isGroupedWithMinMaxThresholds(): Boolean = groupedWithMinMaxThresholds != null + fun visitMinimum(minimum: NewMinimum): T - fun isMatrixWithDisplayName(): Boolean = matrixWithDisplayName != null + fun visitMaximum(maximum: NewMaximum): T - fun isGroupedTieredPackage(): Boolean = groupedTieredPackage != null + /** + * Maps an unknown variant of [Adjustment] to a value of type [T]. + * + * An instance of [Adjustment] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the + * SDK is unaware of. + * + * @throws OrbInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw OrbInvalidDataException("Unknown Adjustment: $json") + } + } - fun isMaxGroupTieredPackage(): Boolean = maxGroupTieredPackage != null + internal class Deserializer : BaseDeserializer(Adjustment::class) { - fun isScalableMatrixWithUnitPricing(): Boolean = scalableMatrixWithUnitPricing != null + override fun ObjectCodec.deserialize(node: JsonNode): Adjustment { + val json = JsonValue.fromJsonNode(node) + val adjustmentType = json.asObject()?.get("adjustment_type")?.asString() - fun isScalableMatrixWithTieredPricing(): Boolean = - scalableMatrixWithTieredPricing != null + when (adjustmentType) { + "percentage_discount" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Adjustment(percentageDiscount = it, _json = json) } + ?: Adjustment(_json = json) + } + "usage_discount" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(usageDiscount = it, _json = json) + } ?: Adjustment(_json = json) + } + "amount_discount" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(amountDiscount = it, _json = json) + } ?: Adjustment(_json = json) + } + "minimum" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(minimum = it, _json = json) + } ?: Adjustment(_json = json) + } + "maximum" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(maximum = it, _json = json) + } ?: Adjustment(_json = json) + } + } - fun isCumulativeGroupedBulk(): Boolean = cumulativeGroupedBulk != null + return Adjustment(_json = json) + } + } - fun isMinimum(): Boolean = minimum != null + internal class Serializer : BaseSerializer(Adjustment::class) { - fun asUnit(): NewSubscriptionUnitPrice = unit.getOrThrow("unit") + override fun serialize( + value: Adjustment, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.percentageDiscount != null -> + generator.writeObject(value.percentageDiscount) + value.usageDiscount != null -> generator.writeObject(value.usageDiscount) + value.amountDiscount != null -> generator.writeObject(value.amountDiscount) + value.minimum != null -> generator.writeObject(value.minimum) + value.maximum != null -> generator.writeObject(value.maximum) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Adjustment") + } + } + } + } - fun asTiered(): NewSubscriptionTieredPrice = tiered.getOrThrow("tiered") + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun asBulk(): NewSubscriptionBulkPrice = bulk.getOrThrow("bulk") + return other is ReplaceAdjustment && + adjustment == other.adjustment && + replacesAdjustmentId == other.replacesAdjustmentId && + additionalProperties == other.additionalProperties + } - fun asPackage(): NewSubscriptionPackagePrice = package_.getOrThrow("package_") + private val hashCode: Int by lazy { + Objects.hash(adjustment, replacesAdjustmentId, additionalProperties) + } - fun asMatrix(): NewSubscriptionMatrixPrice = matrix.getOrThrow("matrix") + override fun hashCode(): Int = hashCode - fun asThresholdTotalAmount(): NewSubscriptionThresholdTotalAmountPrice = - thresholdTotalAmount.getOrThrow("thresholdTotalAmount") + override fun toString() = + "ReplaceAdjustment{adjustment=$adjustment, replacesAdjustmentId=$replacesAdjustmentId, additionalProperties=$additionalProperties}" + } - fun asTieredPackage(): NewSubscriptionTieredPackagePrice = - tieredPackage.getOrThrow("tieredPackage") + class ReplacePrice + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val replacesPriceId: JsonField, + private val allocationPrice: JsonField, + private val discounts: JsonField>, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val maximumAmount: JsonField, + private val minimumAmount: JsonField, + private val price: JsonField, + private val priceId: JsonField, + private val additionalProperties: MutableMap, + ) { - fun asTieredWithMinimum(): NewSubscriptionTieredWithMinimumPrice = - tieredWithMinimum.getOrThrow("tieredWithMinimum") + @JsonCreator + private constructor( + @JsonProperty("replaces_price_id") + @ExcludeMissing + replacesPriceId: JsonField = JsonMissing.of(), + @JsonProperty("allocation_price") + @ExcludeMissing + allocationPrice: JsonField = JsonMissing.of(), + @JsonProperty("discounts") + @ExcludeMissing + discounts: JsonField> = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("maximum_amount") + @ExcludeMissing + maximumAmount: JsonField = JsonMissing.of(), + @JsonProperty("minimum_amount") + @ExcludeMissing + minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("price") @ExcludeMissing price: JsonField = JsonMissing.of(), + @JsonProperty("price_id") @ExcludeMissing priceId: JsonField = JsonMissing.of(), + ) : this( + replacesPriceId, + allocationPrice, + discounts, + externalPriceId, + fixedPriceQuantity, + maximumAmount, + minimumAmount, + price, + priceId, + mutableMapOf(), + ) - fun asGroupedTiered(): NewSubscriptionGroupedTieredPrice = - groupedTiered.getOrThrow("groupedTiered") + /** + * The id of the price on the plan to replace in the subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun replacesPriceId(): String = replacesPriceId.getRequired("replaces_price_id") - fun asTieredPackageWithMinimum(): NewSubscriptionTieredPackageWithMinimumPrice = - tieredPackageWithMinimum.getOrThrow("tieredPackageWithMinimum") + /** + * The definition of a new allocation price to create and add to the subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun allocationPrice(): NewAllocationPrice? = allocationPrice.getNullable("allocation_price") - fun asPackageWithAllocation(): NewSubscriptionPackageWithAllocationPrice = - packageWithAllocation.getOrThrow("packageWithAllocation") + /** + * [DEPRECATED] Use add_adjustments instead. The subscription's discounts for the + * replacement price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + @Deprecated("deprecated") + fun discounts(): List? = discounts.getNullable("discounts") - fun asUnitWithPercent(): NewSubscriptionUnitWithPercentPrice = - unitWithPercent.getOrThrow("unitWithPercent") + /** + * The external price id of the price to add to the subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") - fun asMatrixWithAllocation(): NewSubscriptionMatrixWithAllocationPrice = - matrixWithAllocation.getOrThrow("matrixWithAllocation") + /** + * The new quantity of the price, if the price is a fixed price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = fixedPriceQuantity.getNullable("fixed_price_quantity") - fun asTieredWithProration(): TieredWithProration = - tieredWithProration.getOrThrow("tieredWithProration") + /** + * [DEPRECATED] Use add_adjustments instead. The subscription's maximum amount for the + * replacement price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + @Deprecated("deprecated") + fun maximumAmount(): String? = maximumAmount.getNullable("maximum_amount") - fun asUnitWithProration(): NewSubscriptionUnitWithProrationPrice = - unitWithProration.getOrThrow("unitWithProration") + /** + * [DEPRECATED] Use add_adjustments instead. The subscription's minimum amount for the + * replacement price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + @Deprecated("deprecated") + fun minimumAmount(): String? = minimumAmount.getNullable("minimum_amount") - fun asGroupedAllocation(): NewSubscriptionGroupedAllocationPrice = - groupedAllocation.getOrThrow("groupedAllocation") + /** + * New subscription price request body params. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun price(): Price? = price.getNullable("price") - fun asBulkWithProration(): NewSubscriptionBulkWithProrationPrice = - bulkWithProration.getOrThrow("bulkWithProration") + /** + * The id of the price to add to the subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun priceId(): String? = priceId.getNullable("price_id") - fun asGroupedWithProratedMinimum(): NewSubscriptionGroupedWithProratedMinimumPrice = - groupedWithProratedMinimum.getOrThrow("groupedWithProratedMinimum") + /** + * Returns the raw JSON value of [replacesPriceId]. + * + * Unlike [replacesPriceId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("replaces_price_id") + @ExcludeMissing + fun _replacesPriceId(): JsonField = replacesPriceId - fun asGroupedWithMeteredMinimum(): NewSubscriptionGroupedWithMeteredMinimumPrice = - groupedWithMeteredMinimum.getOrThrow("groupedWithMeteredMinimum") + /** + * Returns the raw JSON value of [allocationPrice]. + * + * Unlike [allocationPrice], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("allocation_price") + @ExcludeMissing + fun _allocationPrice(): JsonField = allocationPrice - fun asGroupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds = - groupedWithMinMaxThresholds.getOrThrow("groupedWithMinMaxThresholds") + /** + * Returns the raw JSON value of [discounts]. + * + * Unlike [discounts], this method doesn't throw if the JSON field has an unexpected type. + */ + @Deprecated("deprecated") + @JsonProperty("discounts") + @ExcludeMissing + fun _discounts(): JsonField> = discounts - fun asMatrixWithDisplayName(): NewSubscriptionMatrixWithDisplayNamePrice = - matrixWithDisplayName.getOrThrow("matrixWithDisplayName") + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId - fun asGroupedTieredPackage(): NewSubscriptionGroupedTieredPackagePrice = - groupedTieredPackage.getOrThrow("groupedTieredPackage") + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - fun asMaxGroupTieredPackage(): NewSubscriptionMaxGroupTieredPackagePrice = - maxGroupTieredPackage.getOrThrow("maxGroupTieredPackage") + /** + * Returns the raw JSON value of [maximumAmount]. + * + * Unlike [maximumAmount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @Deprecated("deprecated") + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount - fun asScalableMatrixWithUnitPricing(): - NewSubscriptionScalableMatrixWithUnitPricingPrice = - scalableMatrixWithUnitPricing.getOrThrow("scalableMatrixWithUnitPricing") + /** + * Returns the raw JSON value of [minimumAmount]. + * + * Unlike [minimumAmount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @Deprecated("deprecated") + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount - fun asScalableMatrixWithTieredPricing(): - NewSubscriptionScalableMatrixWithTieredPricingPrice = - scalableMatrixWithTieredPricing.getOrThrow("scalableMatrixWithTieredPricing") + /** + * Returns the raw JSON value of [price]. + * + * Unlike [price], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("price") @ExcludeMissing fun _price(): JsonField = price - fun asCumulativeGroupedBulk(): NewSubscriptionCumulativeGroupedBulkPrice = - cumulativeGroupedBulk.getOrThrow("cumulativeGroupedBulk") + /** + * Returns the raw JSON value of [priceId]. + * + * Unlike [priceId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId - fun asMinimum(): NewSubscriptionMinimumCompositePrice = minimum.getOrThrow("minimum") + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - fun _json(): JsonValue? = _json + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - bulk != null -> visitor.visitBulk(bulk) - package_ != null -> visitor.visitPackage(package_) - matrix != null -> visitor.visitMatrix(matrix) - thresholdTotalAmount != null -> - visitor.visitThresholdTotalAmount(thresholdTotalAmount) - tieredPackage != null -> visitor.visitTieredPackage(tieredPackage) - tieredWithMinimum != null -> visitor.visitTieredWithMinimum(tieredWithMinimum) - groupedTiered != null -> visitor.visitGroupedTiered(groupedTiered) - tieredPackageWithMinimum != null -> - visitor.visitTieredPackageWithMinimum(tieredPackageWithMinimum) - packageWithAllocation != null -> - visitor.visitPackageWithAllocation(packageWithAllocation) - unitWithPercent != null -> visitor.visitUnitWithPercent(unitWithPercent) - matrixWithAllocation != null -> - visitor.visitMatrixWithAllocation(matrixWithAllocation) - tieredWithProration != null -> - visitor.visitTieredWithProration(tieredWithProration) - unitWithProration != null -> visitor.visitUnitWithProration(unitWithProration) - groupedAllocation != null -> visitor.visitGroupedAllocation(groupedAllocation) - bulkWithProration != null -> visitor.visitBulkWithProration(bulkWithProration) - groupedWithProratedMinimum != null -> - visitor.visitGroupedWithProratedMinimum(groupedWithProratedMinimum) - groupedWithMeteredMinimum != null -> - visitor.visitGroupedWithMeteredMinimum(groupedWithMeteredMinimum) - groupedWithMinMaxThresholds != null -> - visitor.visitGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds) - matrixWithDisplayName != null -> - visitor.visitMatrixWithDisplayName(matrixWithDisplayName) - groupedTieredPackage != null -> - visitor.visitGroupedTieredPackage(groupedTieredPackage) - maxGroupTieredPackage != null -> - visitor.visitMaxGroupTieredPackage(maxGroupTieredPackage) - scalableMatrixWithUnitPricing != null -> - visitor.visitScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing) - scalableMatrixWithTieredPricing != null -> - visitor.visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing - ) - cumulativeGroupedBulk != null -> - visitor.visitCumulativeGroupedBulk(cumulativeGroupedBulk) - minimum != null -> visitor.visitMinimum(minimum) - else -> visitor.unknown(_json) - } + fun toBuilder() = Builder().from(this) - private var validated: Boolean = false + companion object { - fun validate(): Price = apply { - if (validated) { - return@apply - } + /** + * Returns a mutable builder for constructing an instance of [ReplacePrice]. + * + * The following fields are required: + * ```kotlin + * .replacesPriceId() + * ``` + */ + fun builder() = Builder() + } - accept( - object : Visitor { - override fun visitUnit(unit: NewSubscriptionUnitPrice) { - unit.validate() - } + /** A builder for [ReplacePrice]. */ + class Builder internal constructor() { - override fun visitTiered(tiered: NewSubscriptionTieredPrice) { - tiered.validate() - } - - override fun visitBulk(bulk: NewSubscriptionBulkPrice) { - bulk.validate() - } + private var replacesPriceId: JsonField? = null + private var allocationPrice: JsonField = JsonMissing.of() + private var discounts: JsonField>? = null + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var maximumAmount: JsonField = JsonMissing.of() + private var minimumAmount: JsonField = JsonMissing.of() + private var price: JsonField = JsonMissing.of() + private var priceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - override fun visitPackage(package_: NewSubscriptionPackagePrice) { - package_.validate() - } + internal fun from(replacePrice: ReplacePrice) = apply { + replacesPriceId = replacePrice.replacesPriceId + allocationPrice = replacePrice.allocationPrice + discounts = replacePrice.discounts.map { it.toMutableList() } + externalPriceId = replacePrice.externalPriceId + fixedPriceQuantity = replacePrice.fixedPriceQuantity + maximumAmount = replacePrice.maximumAmount + minimumAmount = replacePrice.minimumAmount + price = replacePrice.price + priceId = replacePrice.priceId + additionalProperties = replacePrice.additionalProperties.toMutableMap() + } - override fun visitMatrix(matrix: NewSubscriptionMatrixPrice) { - matrix.validate() - } + /** The id of the price on the plan to replace in the subscription. */ + fun replacesPriceId(replacesPriceId: String) = + replacesPriceId(JsonField.of(replacesPriceId)) - override fun visitThresholdTotalAmount( - thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice - ) { - thresholdTotalAmount.validate() - } + /** + * Sets [Builder.replacesPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.replacesPriceId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun replacesPriceId(replacesPriceId: JsonField) = apply { + this.replacesPriceId = replacesPriceId + } - override fun visitTieredPackage( - tieredPackage: NewSubscriptionTieredPackagePrice - ) { - tieredPackage.validate() - } + /** The definition of a new allocation price to create and add to the subscription. */ + fun allocationPrice(allocationPrice: NewAllocationPrice?) = + allocationPrice(JsonField.ofNullable(allocationPrice)) - override fun visitTieredWithMinimum( - tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice - ) { - tieredWithMinimum.validate() - } + /** + * Sets [Builder.allocationPrice] to an arbitrary JSON value. + * + * You should usually call [Builder.allocationPrice] with a well-typed + * [NewAllocationPrice] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun allocationPrice(allocationPrice: JsonField) = apply { + this.allocationPrice = allocationPrice + } - override fun visitGroupedTiered( - groupedTiered: NewSubscriptionGroupedTieredPrice - ) { - groupedTiered.validate() - } + /** + * [DEPRECATED] Use add_adjustments instead. The subscription's discounts for the + * replacement price. + */ + @Deprecated("deprecated") + fun discounts(discounts: List?) = + discounts(JsonField.ofNullable(discounts)) - override fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice - ) { - tieredPackageWithMinimum.validate() - } + /** + * Sets [Builder.discounts] to an arbitrary JSON value. + * + * You should usually call [Builder.discounts] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + @Deprecated("deprecated") + fun discounts(discounts: JsonField>) = apply { + this.discounts = discounts.map { it.toMutableList() } + } - override fun visitPackageWithAllocation( - packageWithAllocation: NewSubscriptionPackageWithAllocationPrice - ) { - packageWithAllocation.validate() - } + /** + * Adds a single [DiscountOverride] to [discounts]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + @Deprecated("deprecated") + fun addDiscount(discount: DiscountOverride) = apply { + discounts = + (discounts ?: JsonField.of(mutableListOf())).also { + checkKnown("discounts", it).add(discount) + } + } - override fun visitUnitWithPercent( - unitWithPercent: NewSubscriptionUnitWithPercentPrice - ) { - unitWithPercent.validate() - } + /** The external price id of the price to add to the subscription. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) - override fun visitMatrixWithAllocation( - matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice - ) { - matrixWithAllocation.validate() - } + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } - override fun visitTieredWithProration( - tieredWithProration: TieredWithProration - ) { - tieredWithProration.validate() - } + /** The new quantity of the price, if the price is a fixed price. */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) - override fun visitUnitWithProration( - unitWithProration: NewSubscriptionUnitWithProrationPrice - ) { - unitWithProration.validate() - } + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) - override fun visitGroupedAllocation( - groupedAllocation: NewSubscriptionGroupedAllocationPrice - ) { - groupedAllocation.validate() - } + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } - override fun visitBulkWithProration( - bulkWithProration: NewSubscriptionBulkWithProrationPrice - ) { - bulkWithProration.validate() - } + /** + * [DEPRECATED] Use add_adjustments instead. The subscription's maximum amount for the + * replacement price. + */ + @Deprecated("deprecated") + fun maximumAmount(maximumAmount: String?) = + maximumAmount(JsonField.ofNullable(maximumAmount)) - override fun visitGroupedWithProratedMinimum( - groupedWithProratedMinimum: - NewSubscriptionGroupedWithProratedMinimumPrice - ) { - groupedWithProratedMinimum.validate() - } + /** + * Sets [Builder.maximumAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.maximumAmount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + @Deprecated("deprecated") + fun maximumAmount(maximumAmount: JsonField) = apply { + this.maximumAmount = maximumAmount + } - override fun visitGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice - ) { - groupedWithMeteredMinimum.validate() - } + /** + * [DEPRECATED] Use add_adjustments instead. The subscription's minimum amount for the + * replacement price. + */ + @Deprecated("deprecated") + fun minimumAmount(minimumAmount: String?) = + minimumAmount(JsonField.ofNullable(minimumAmount)) - override fun visitGroupedWithMinMaxThresholds( - groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds - ) { - groupedWithMinMaxThresholds.validate() - } + /** + * Sets [Builder.minimumAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumAmount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + @Deprecated("deprecated") + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount + } - override fun visitMatrixWithDisplayName( - matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice - ) { - matrixWithDisplayName.validate() - } + /** New subscription price request body params. */ + fun price(price: Price?) = price(JsonField.ofNullable(price)) - override fun visitGroupedTieredPackage( - groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice - ) { - groupedTieredPackage.validate() - } + /** + * Sets [Builder.price] to an arbitrary JSON value. + * + * You should usually call [Builder.price] with a well-typed [Price] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun price(price: JsonField) = apply { this.price = price } - override fun visitMaxGroupTieredPackage( - maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice - ) { - maxGroupTieredPackage.validate() - } - - override fun visitScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: - NewSubscriptionScalableMatrixWithUnitPricingPrice - ) { - scalableMatrixWithUnitPricing.validate() - } + /** Alias for calling [price] with `Price.ofUnit(unit)`. */ + fun price(unit: NewSubscriptionUnitPrice) = price(Price.ofUnit(unit)) - override fun visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: - NewSubscriptionScalableMatrixWithTieredPricingPrice - ) { - scalableMatrixWithTieredPricing.validate() - } + /** Alias for calling [price] with `Price.ofTiered(tiered)`. */ + fun price(tiered: NewSubscriptionTieredPrice) = price(Price.ofTiered(tiered)) - override fun visitCumulativeGroupedBulk( - cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice - ) { - cumulativeGroupedBulk.validate() - } + /** Alias for calling [price] with `Price.ofBulk(bulk)`. */ + fun price(bulk: NewSubscriptionBulkPrice) = price(Price.ofBulk(bulk)) - override fun visitMinimum(minimum: NewSubscriptionMinimumCompositePrice) { - minimum.validate() - } - } - ) - validated = true - } + /** Alias for calling [price] with `Price.ofPackage(package_)`. */ + fun price(package_: NewSubscriptionPackagePrice) = price(Price.ofPackage(package_)) - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** Alias for calling [price] with `Price.ofMatrix(matrix)`. */ + fun price(matrix: NewSubscriptionMatrixPrice) = price(Price.ofMatrix(matrix)) /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. + * Alias for calling [price] with `Price.ofThresholdTotalAmount(thresholdTotalAmount)`. */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: NewSubscriptionUnitPrice) = unit.validity() - - override fun visitTiered(tiered: NewSubscriptionTieredPrice) = - tiered.validity() + fun price(thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice) = + price(Price.ofThresholdTotalAmount(thresholdTotalAmount)) - override fun visitBulk(bulk: NewSubscriptionBulkPrice) = bulk.validity() + /** Alias for calling [price] with `Price.ofTieredPackage(tieredPackage)`. */ + fun price(tieredPackage: NewSubscriptionTieredPackagePrice) = + price(Price.ofTieredPackage(tieredPackage)) - override fun visitPackage(package_: NewSubscriptionPackagePrice) = - package_.validity() + /** Alias for calling [price] with `Price.ofTieredWithMinimum(tieredWithMinimum)`. */ + fun price(tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice) = + price(Price.ofTieredWithMinimum(tieredWithMinimum)) - override fun visitMatrix(matrix: NewSubscriptionMatrixPrice) = - matrix.validity() + /** Alias for calling [price] with `Price.ofGroupedTiered(groupedTiered)`. */ + fun price(groupedTiered: NewSubscriptionGroupedTieredPrice) = + price(Price.ofGroupedTiered(groupedTiered)) - override fun visitThresholdTotalAmount( - thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice - ) = thresholdTotalAmount.validity() + /** + * Alias for calling [price] with + * `Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)`. + */ + fun price(tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice) = + price(Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)) - override fun visitTieredPackage( - tieredPackage: NewSubscriptionTieredPackagePrice - ) = tieredPackage.validity() + /** + * Alias for calling [price] with + * `Price.ofPackageWithAllocation(packageWithAllocation)`. + */ + fun price(packageWithAllocation: NewSubscriptionPackageWithAllocationPrice) = + price(Price.ofPackageWithAllocation(packageWithAllocation)) - override fun visitTieredWithMinimum( - tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice - ) = tieredWithMinimum.validity() + /** Alias for calling [price] with `Price.ofUnitWithPercent(unitWithPercent)`. */ + fun price(unitWithPercent: NewSubscriptionUnitWithPercentPrice) = + price(Price.ofUnitWithPercent(unitWithPercent)) - override fun visitGroupedTiered( - groupedTiered: NewSubscriptionGroupedTieredPrice - ) = groupedTiered.validity() + /** + * Alias for calling [price] with `Price.ofMatrixWithAllocation(matrixWithAllocation)`. + */ + fun price(matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice) = + price(Price.ofMatrixWithAllocation(matrixWithAllocation)) - override fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice - ) = tieredPackageWithMinimum.validity() + /** + * Alias for calling [price] with `Price.ofTieredWithProration(tieredWithProration)`. + */ + fun price(tieredWithProration: Price.TieredWithProration) = + price(Price.ofTieredWithProration(tieredWithProration)) - override fun visitPackageWithAllocation( - packageWithAllocation: NewSubscriptionPackageWithAllocationPrice - ) = packageWithAllocation.validity() + /** Alias for calling [price] with `Price.ofUnitWithProration(unitWithProration)`. */ + fun price(unitWithProration: NewSubscriptionUnitWithProrationPrice) = + price(Price.ofUnitWithProration(unitWithProration)) - override fun visitUnitWithPercent( - unitWithPercent: NewSubscriptionUnitWithPercentPrice - ) = unitWithPercent.validity() + /** Alias for calling [price] with `Price.ofGroupedAllocation(groupedAllocation)`. */ + fun price(groupedAllocation: NewSubscriptionGroupedAllocationPrice) = + price(Price.ofGroupedAllocation(groupedAllocation)) - override fun visitMatrixWithAllocation( - matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice - ) = matrixWithAllocation.validity() + /** Alias for calling [price] with `Price.ofBulkWithProration(bulkWithProration)`. */ + fun price(bulkWithProration: NewSubscriptionBulkWithProrationPrice) = + price(Price.ofBulkWithProration(bulkWithProration)) - override fun visitTieredWithProration( - tieredWithProration: TieredWithProration - ) = tieredWithProration.validity() + /** + * Alias for calling [price] with + * `Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)`. + */ + fun price(groupedWithProratedMinimum: NewSubscriptionGroupedWithProratedMinimumPrice) = + price(Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)) - override fun visitUnitWithProration( - unitWithProration: NewSubscriptionUnitWithProrationPrice - ) = unitWithProration.validity() + /** + * Alias for calling [price] with + * `Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)`. + */ + fun price(groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice) = + price(Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)) - override fun visitGroupedAllocation( - groupedAllocation: NewSubscriptionGroupedAllocationPrice - ) = groupedAllocation.validity() + /** + * Alias for calling [price] with + * `Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)`. + */ + fun price(groupedWithMinMaxThresholds: Price.GroupedWithMinMaxThresholds) = + price(Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)) - override fun visitBulkWithProration( - bulkWithProration: NewSubscriptionBulkWithProrationPrice - ) = bulkWithProration.validity() + /** + * Alias for calling [price] with + * `Price.ofMatrixWithDisplayName(matrixWithDisplayName)`. + */ + fun price(matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice) = + price(Price.ofMatrixWithDisplayName(matrixWithDisplayName)) - override fun visitGroupedWithProratedMinimum( - groupedWithProratedMinimum: - NewSubscriptionGroupedWithProratedMinimumPrice - ) = groupedWithProratedMinimum.validity() + /** + * Alias for calling [price] with `Price.ofGroupedTieredPackage(groupedTieredPackage)`. + */ + fun price(groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice) = + price(Price.ofGroupedTieredPackage(groupedTieredPackage)) - override fun visitGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice - ) = groupedWithMeteredMinimum.validity() + /** + * Alias for calling [price] with + * `Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)`. + */ + fun price(maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice) = + price(Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)) - override fun visitGroupedWithMinMaxThresholds( - groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds - ) = groupedWithMinMaxThresholds.validity() + /** + * Alias for calling [price] with + * `Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)`. + */ + fun price( + scalableMatrixWithUnitPricing: NewSubscriptionScalableMatrixWithUnitPricingPrice + ) = price(Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)) - override fun visitMatrixWithDisplayName( - matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice - ) = matrixWithDisplayName.validity() + /** + * Alias for calling [price] with + * `Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)`. + */ + fun price( + scalableMatrixWithTieredPricing: NewSubscriptionScalableMatrixWithTieredPricingPrice + ) = price(Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)) - override fun visitGroupedTieredPackage( - groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice - ) = groupedTieredPackage.validity() + /** + * Alias for calling [price] with + * `Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)`. + */ + fun price(cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice) = + price(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) - override fun visitMaxGroupTieredPackage( - maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice - ) = maxGroupTieredPackage.validity() + /** Alias for calling [price] with `Price.ofMinimum(minimum)`. */ + fun price(minimum: NewSubscriptionMinimumCompositePrice) = + price(Price.ofMinimum(minimum)) - override fun visitScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: - NewSubscriptionScalableMatrixWithUnitPricingPrice - ) = scalableMatrixWithUnitPricing.validity() + /** Alias for calling [price] with `Price.ofEventOutput(eventOutput)`. */ + fun price(eventOutput: Price.EventOutput) = price(Price.ofEventOutput(eventOutput)) - override fun visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: - NewSubscriptionScalableMatrixWithTieredPricingPrice - ) = scalableMatrixWithTieredPricing.validity() + /** The id of the price to add to the subscription. */ + fun priceId(priceId: String?) = priceId(JsonField.ofNullable(priceId)) - override fun visitCumulativeGroupedBulk( - cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice - ) = cumulativeGroupedBulk.validity() + /** + * Sets [Builder.priceId] to an arbitrary JSON value. + * + * You should usually call [Builder.priceId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun priceId(priceId: JsonField) = apply { this.priceId = priceId } - override fun visitMinimum(minimum: NewSubscriptionMinimumCompositePrice) = - minimum.validity() + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - override fun unknown(json: JsonValue?) = 0 - } - ) + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - return other is Price && - unit == other.unit && - tiered == other.tiered && - bulk == other.bulk && - package_ == other.package_ && - matrix == other.matrix && - thresholdTotalAmount == other.thresholdTotalAmount && - tieredPackage == other.tieredPackage && - tieredWithMinimum == other.tieredWithMinimum && - groupedTiered == other.groupedTiered && - tieredPackageWithMinimum == other.tieredPackageWithMinimum && - packageWithAllocation == other.packageWithAllocation && - unitWithPercent == other.unitWithPercent && - matrixWithAllocation == other.matrixWithAllocation && - tieredWithProration == other.tieredWithProration && - unitWithProration == other.unitWithProration && - groupedAllocation == other.groupedAllocation && - bulkWithProration == other.bulkWithProration && - groupedWithProratedMinimum == other.groupedWithProratedMinimum && - groupedWithMeteredMinimum == other.groupedWithMeteredMinimum && - groupedWithMinMaxThresholds == other.groupedWithMinMaxThresholds && - matrixWithDisplayName == other.matrixWithDisplayName && - groupedTieredPackage == other.groupedTieredPackage && - maxGroupTieredPackage == other.maxGroupTieredPackage && - scalableMatrixWithUnitPricing == other.scalableMatrixWithUnitPricing && - scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && - cumulativeGroupedBulk == other.cumulativeGroupedBulk && - minimum == other.minimum + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) } - override fun hashCode(): Int = - Objects.hash( - unit, - tiered, - bulk, - package_, - matrix, - thresholdTotalAmount, - tieredPackage, - tieredWithMinimum, - groupedTiered, - tieredPackageWithMinimum, - packageWithAllocation, - unitWithPercent, - matrixWithAllocation, - tieredWithProration, - unitWithProration, - groupedAllocation, - bulkWithProration, - groupedWithProratedMinimum, - groupedWithMeteredMinimum, - groupedWithMinMaxThresholds, - matrixWithDisplayName, - groupedTieredPackage, - maxGroupTieredPackage, - scalableMatrixWithUnitPricing, - scalableMatrixWithTieredPricing, - cumulativeGroupedBulk, - minimum, + /** + * Returns an immutable instance of [ReplacePrice]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .replacesPriceId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ReplacePrice = + ReplacePrice( + checkRequired("replacesPriceId", replacesPriceId), + allocationPrice, + (discounts ?: JsonMissing.of()).map { it.toImmutable() }, + externalPriceId, + fixedPriceQuantity, + maximumAmount, + minimumAmount, + price, + priceId, + additionalProperties.toMutableMap(), ) + } - override fun toString(): String = - when { - unit != null -> "Price{unit=$unit}" - tiered != null -> "Price{tiered=$tiered}" - bulk != null -> "Price{bulk=$bulk}" - package_ != null -> "Price{package_=$package_}" - matrix != null -> "Price{matrix=$matrix}" - thresholdTotalAmount != null -> - "Price{thresholdTotalAmount=$thresholdTotalAmount}" - tieredPackage != null -> "Price{tieredPackage=$tieredPackage}" - tieredWithMinimum != null -> "Price{tieredWithMinimum=$tieredWithMinimum}" - groupedTiered != null -> "Price{groupedTiered=$groupedTiered}" - tieredPackageWithMinimum != null -> - "Price{tieredPackageWithMinimum=$tieredPackageWithMinimum}" - packageWithAllocation != null -> - "Price{packageWithAllocation=$packageWithAllocation}" - unitWithPercent != null -> "Price{unitWithPercent=$unitWithPercent}" - matrixWithAllocation != null -> - "Price{matrixWithAllocation=$matrixWithAllocation}" - tieredWithProration != null -> "Price{tieredWithProration=$tieredWithProration}" - unitWithProration != null -> "Price{unitWithProration=$unitWithProration}" - groupedAllocation != null -> "Price{groupedAllocation=$groupedAllocation}" - bulkWithProration != null -> "Price{bulkWithProration=$bulkWithProration}" - groupedWithProratedMinimum != null -> - "Price{groupedWithProratedMinimum=$groupedWithProratedMinimum}" - groupedWithMeteredMinimum != null -> - "Price{groupedWithMeteredMinimum=$groupedWithMeteredMinimum}" - groupedWithMinMaxThresholds != null -> - "Price{groupedWithMinMaxThresholds=$groupedWithMinMaxThresholds}" - matrixWithDisplayName != null -> - "Price{matrixWithDisplayName=$matrixWithDisplayName}" - groupedTieredPackage != null -> - "Price{groupedTieredPackage=$groupedTieredPackage}" - maxGroupTieredPackage != null -> - "Price{maxGroupTieredPackage=$maxGroupTieredPackage}" - scalableMatrixWithUnitPricing != null -> - "Price{scalableMatrixWithUnitPricing=$scalableMatrixWithUnitPricing}" - scalableMatrixWithTieredPricing != null -> - "Price{scalableMatrixWithTieredPricing=$scalableMatrixWithTieredPricing}" - cumulativeGroupedBulk != null -> - "Price{cumulativeGroupedBulk=$cumulativeGroupedBulk}" - minimum != null -> "Price{minimum=$minimum}" - _json != null -> "Price{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Price") - } - - companion object { + private var validated: Boolean = false - fun ofUnit(unit: NewSubscriptionUnitPrice) = Price(unit = unit) + fun validate(): ReplacePrice = apply { + if (validated) { + return@apply + } - fun ofTiered(tiered: NewSubscriptionTieredPrice) = Price(tiered = tiered) + replacesPriceId() + allocationPrice()?.validate() + discounts()?.forEach { it.validate() } + externalPriceId() + fixedPriceQuantity() + maximumAmount() + minimumAmount() + price()?.validate() + priceId() + validated = true + } - fun ofBulk(bulk: NewSubscriptionBulkPrice) = Price(bulk = bulk) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - fun ofPackage(package_: NewSubscriptionPackagePrice) = Price(package_ = package_) + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (replacesPriceId.asKnown() == null) 0 else 1) + + (allocationPrice.asKnown()?.validity() ?: 0) + + (discounts.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (maximumAmount.asKnown() == null) 0 else 1) + + (if (minimumAmount.asKnown() == null) 0 else 1) + + (price.asKnown()?.validity() ?: 0) + + (if (priceId.asKnown() == null) 0 else 1) - fun ofMatrix(matrix: NewSubscriptionMatrixPrice) = Price(matrix = matrix) + /** New subscription price request body params. */ + @JsonDeserialize(using = Price.Deserializer::class) + @JsonSerialize(using = Price.Serializer::class) + class Price + private constructor( + private val unit: NewSubscriptionUnitPrice? = null, + private val tiered: NewSubscriptionTieredPrice? = null, + private val bulk: NewSubscriptionBulkPrice? = null, + private val package_: NewSubscriptionPackagePrice? = null, + private val matrix: NewSubscriptionMatrixPrice? = null, + private val thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice? = null, + private val tieredPackage: NewSubscriptionTieredPackagePrice? = null, + private val tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice? = null, + private val groupedTiered: NewSubscriptionGroupedTieredPrice? = null, + private val tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice? = + null, + private val packageWithAllocation: NewSubscriptionPackageWithAllocationPrice? = null, + private val unitWithPercent: NewSubscriptionUnitWithPercentPrice? = null, + private val matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice? = null, + private val tieredWithProration: TieredWithProration? = null, + private val unitWithProration: NewSubscriptionUnitWithProrationPrice? = null, + private val groupedAllocation: NewSubscriptionGroupedAllocationPrice? = null, + private val bulkWithProration: NewSubscriptionBulkWithProrationPrice? = null, + private val groupedWithProratedMinimum: + NewSubscriptionGroupedWithProratedMinimumPrice? = + null, + private val groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice? = + null, + private val groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds? = null, + private val matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice? = null, + private val groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice? = null, + private val maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice? = null, + private val scalableMatrixWithUnitPricing: + NewSubscriptionScalableMatrixWithUnitPricingPrice? = + null, + private val scalableMatrixWithTieredPricing: + NewSubscriptionScalableMatrixWithTieredPricingPrice? = + null, + private val cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice? = null, + private val minimum: NewSubscriptionMinimumCompositePrice? = null, + private val eventOutput: EventOutput? = null, + private val _json: JsonValue? = null, + ) { - fun ofThresholdTotalAmount( - thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice - ) = Price(thresholdTotalAmount = thresholdTotalAmount) + fun unit(): NewSubscriptionUnitPrice? = unit - fun ofTieredPackage(tieredPackage: NewSubscriptionTieredPackagePrice) = - Price(tieredPackage = tieredPackage) + fun tiered(): NewSubscriptionTieredPrice? = tiered - fun ofTieredWithMinimum(tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice) = - Price(tieredWithMinimum = tieredWithMinimum) + fun bulk(): NewSubscriptionBulkPrice? = bulk - fun ofGroupedTiered(groupedTiered: NewSubscriptionGroupedTieredPrice) = - Price(groupedTiered = groupedTiered) + fun package_(): NewSubscriptionPackagePrice? = package_ - fun ofTieredPackageWithMinimum( - tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice - ) = Price(tieredPackageWithMinimum = tieredPackageWithMinimum) + fun matrix(): NewSubscriptionMatrixPrice? = matrix - fun ofPackageWithAllocation( - packageWithAllocation: NewSubscriptionPackageWithAllocationPrice - ) = Price(packageWithAllocation = packageWithAllocation) + fun thresholdTotalAmount(): NewSubscriptionThresholdTotalAmountPrice? = + thresholdTotalAmount - fun ofUnitWithPercent(unitWithPercent: NewSubscriptionUnitWithPercentPrice) = - Price(unitWithPercent = unitWithPercent) + fun tieredPackage(): NewSubscriptionTieredPackagePrice? = tieredPackage - fun ofMatrixWithAllocation( - matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice - ) = Price(matrixWithAllocation = matrixWithAllocation) + fun tieredWithMinimum(): NewSubscriptionTieredWithMinimumPrice? = tieredWithMinimum - fun ofTieredWithProration(tieredWithProration: TieredWithProration) = - Price(tieredWithProration = tieredWithProration) + fun groupedTiered(): NewSubscriptionGroupedTieredPrice? = groupedTiered - fun ofUnitWithProration(unitWithProration: NewSubscriptionUnitWithProrationPrice) = - Price(unitWithProration = unitWithProration) + fun tieredPackageWithMinimum(): NewSubscriptionTieredPackageWithMinimumPrice? = + tieredPackageWithMinimum - fun ofGroupedAllocation(groupedAllocation: NewSubscriptionGroupedAllocationPrice) = - Price(groupedAllocation = groupedAllocation) + fun packageWithAllocation(): NewSubscriptionPackageWithAllocationPrice? = + packageWithAllocation - fun ofBulkWithProration(bulkWithProration: NewSubscriptionBulkWithProrationPrice) = - Price(bulkWithProration = bulkWithProration) + fun unitWithPercent(): NewSubscriptionUnitWithPercentPrice? = unitWithPercent - fun ofGroupedWithProratedMinimum( - groupedWithProratedMinimum: NewSubscriptionGroupedWithProratedMinimumPrice - ) = Price(groupedWithProratedMinimum = groupedWithProratedMinimum) + fun matrixWithAllocation(): NewSubscriptionMatrixWithAllocationPrice? = + matrixWithAllocation - fun ofGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice - ) = Price(groupedWithMeteredMinimum = groupedWithMeteredMinimum) + fun tieredWithProration(): TieredWithProration? = tieredWithProration - fun ofGroupedWithMinMaxThresholds( - groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds - ) = Price(groupedWithMinMaxThresholds = groupedWithMinMaxThresholds) + fun unitWithProration(): NewSubscriptionUnitWithProrationPrice? = unitWithProration - fun ofMatrixWithDisplayName( - matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice - ) = Price(matrixWithDisplayName = matrixWithDisplayName) + fun groupedAllocation(): NewSubscriptionGroupedAllocationPrice? = groupedAllocation - fun ofGroupedTieredPackage( - groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice - ) = Price(groupedTieredPackage = groupedTieredPackage) + fun bulkWithProration(): NewSubscriptionBulkWithProrationPrice? = bulkWithProration - fun ofMaxGroupTieredPackage( - maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice - ) = Price(maxGroupTieredPackage = maxGroupTieredPackage) + fun groupedWithProratedMinimum(): NewSubscriptionGroupedWithProratedMinimumPrice? = + groupedWithProratedMinimum - fun ofScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: NewSubscriptionScalableMatrixWithUnitPricingPrice - ) = Price(scalableMatrixWithUnitPricing = scalableMatrixWithUnitPricing) + fun groupedWithMeteredMinimum(): NewSubscriptionGroupedWithMeteredMinimumPrice? = + groupedWithMeteredMinimum - fun ofScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: - NewSubscriptionScalableMatrixWithTieredPricingPrice - ) = Price(scalableMatrixWithTieredPricing = scalableMatrixWithTieredPricing) + fun groupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds? = + groupedWithMinMaxThresholds - fun ofCumulativeGroupedBulk( - cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice - ) = Price(cumulativeGroupedBulk = cumulativeGroupedBulk) + fun matrixWithDisplayName(): NewSubscriptionMatrixWithDisplayNamePrice? = + matrixWithDisplayName - fun ofMinimum(minimum: NewSubscriptionMinimumCompositePrice) = - Price(minimum = minimum) - } + fun groupedTieredPackage(): NewSubscriptionGroupedTieredPackagePrice? = + groupedTieredPackage - /** - * An interface that defines how to map each variant of [Price] to a value of type [T]. - */ - interface Visitor { + fun maxGroupTieredPackage(): NewSubscriptionMaxGroupTieredPackagePrice? = + maxGroupTieredPackage - fun visitUnit(unit: NewSubscriptionUnitPrice): T + fun scalableMatrixWithUnitPricing(): + NewSubscriptionScalableMatrixWithUnitPricingPrice? = scalableMatrixWithUnitPricing - fun visitTiered(tiered: NewSubscriptionTieredPrice): T + fun scalableMatrixWithTieredPricing(): + NewSubscriptionScalableMatrixWithTieredPricingPrice? = + scalableMatrixWithTieredPricing - fun visitBulk(bulk: NewSubscriptionBulkPrice): T + fun cumulativeGroupedBulk(): NewSubscriptionCumulativeGroupedBulkPrice? = + cumulativeGroupedBulk - fun visitPackage(package_: NewSubscriptionPackagePrice): T + fun minimum(): NewSubscriptionMinimumCompositePrice? = minimum - fun visitMatrix(matrix: NewSubscriptionMatrixPrice): T + fun eventOutput(): EventOutput? = eventOutput - fun visitThresholdTotalAmount( - thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice - ): T + fun isUnit(): Boolean = unit != null - fun visitTieredPackage(tieredPackage: NewSubscriptionTieredPackagePrice): T + fun isTiered(): Boolean = tiered != null - fun visitTieredWithMinimum( - tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice - ): T + fun isBulk(): Boolean = bulk != null - fun visitGroupedTiered(groupedTiered: NewSubscriptionGroupedTieredPrice): T + fun isPackage(): Boolean = package_ != null - fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice - ): T + fun isMatrix(): Boolean = matrix != null - fun visitPackageWithAllocation( - packageWithAllocation: NewSubscriptionPackageWithAllocationPrice - ): T + fun isThresholdTotalAmount(): Boolean = thresholdTotalAmount != null - fun visitUnitWithPercent(unitWithPercent: NewSubscriptionUnitWithPercentPrice): T + fun isTieredPackage(): Boolean = tieredPackage != null - fun visitMatrixWithAllocation( - matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice - ): T + fun isTieredWithMinimum(): Boolean = tieredWithMinimum != null - fun visitTieredWithProration(tieredWithProration: TieredWithProration): T + fun isGroupedTiered(): Boolean = groupedTiered != null - fun visitUnitWithProration( - unitWithProration: NewSubscriptionUnitWithProrationPrice - ): T + fun isTieredPackageWithMinimum(): Boolean = tieredPackageWithMinimum != null - fun visitGroupedAllocation( - groupedAllocation: NewSubscriptionGroupedAllocationPrice - ): T + fun isPackageWithAllocation(): Boolean = packageWithAllocation != null - fun visitBulkWithProration( - bulkWithProration: NewSubscriptionBulkWithProrationPrice - ): T + fun isUnitWithPercent(): Boolean = unitWithPercent != null - fun visitGroupedWithProratedMinimum( - groupedWithProratedMinimum: NewSubscriptionGroupedWithProratedMinimumPrice - ): T + fun isMatrixWithAllocation(): Boolean = matrixWithAllocation != null - fun visitGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice - ): T + fun isTieredWithProration(): Boolean = tieredWithProration != null - fun visitGroupedWithMinMaxThresholds( - groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds - ): T + fun isUnitWithProration(): Boolean = unitWithProration != null - fun visitMatrixWithDisplayName( - matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice - ): T + fun isGroupedAllocation(): Boolean = groupedAllocation != null - fun visitGroupedTieredPackage( - groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice - ): T + fun isBulkWithProration(): Boolean = bulkWithProration != null - fun visitMaxGroupTieredPackage( - maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice - ): T + fun isGroupedWithProratedMinimum(): Boolean = groupedWithProratedMinimum != null - fun visitScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: NewSubscriptionScalableMatrixWithUnitPricingPrice - ): T + fun isGroupedWithMeteredMinimum(): Boolean = groupedWithMeteredMinimum != null - fun visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: - NewSubscriptionScalableMatrixWithTieredPricingPrice - ): T + fun isGroupedWithMinMaxThresholds(): Boolean = groupedWithMinMaxThresholds != null - fun visitCumulativeGroupedBulk( - cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice - ): T + fun isMatrixWithDisplayName(): Boolean = matrixWithDisplayName != null - fun visitMinimum(minimum: NewSubscriptionMinimumCompositePrice): T + fun isGroupedTieredPackage(): Boolean = groupedTieredPackage != null - /** - * Maps an unknown variant of [Price] to a value of type [T]. - * - * An instance of [Price] can contain an unknown variant if it was deserialized from - * data that doesn't match any known variant. For example, if the SDK is on an older - * version than the API, then the API may respond with new variants that the SDK is - * unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown Price: $json") - } - } + fun isMaxGroupTieredPackage(): Boolean = maxGroupTieredPackage != null - internal class Deserializer : BaseDeserializer(Price::class) { + fun isScalableMatrixWithUnitPricing(): Boolean = scalableMatrixWithUnitPricing != null - override fun ObjectCodec.deserialize(node: JsonNode): Price { - val json = JsonValue.fromJsonNode(node) - val modelType = json.asObject()?.get("model_type")?.asString() + fun isScalableMatrixWithTieredPricing(): Boolean = + scalableMatrixWithTieredPricing != null - when (modelType) { - "unit" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(unit = it, _json = json) } ?: Price(_json = json) - } - "tiered" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(tiered = it, _json = json) } ?: Price(_json = json) - } - "bulk" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(bulk = it, _json = json) } ?: Price(_json = json) - } - "package" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(package_ = it, _json = json) } ?: Price(_json = json) - } - "matrix" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(matrix = it, _json = json) } ?: Price(_json = json) - } - "threshold_total_amount" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(thresholdTotalAmount = it, _json = json) } - ?: Price(_json = json) - } - "tiered_package" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(tieredPackage = it, _json = json) } - ?: Price(_json = json) - } - "tiered_with_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(tieredWithMinimum = it, _json = json) } - ?: Price(_json = json) - } - "grouped_tiered" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedTiered = it, _json = json) } - ?: Price(_json = json) - } - "tiered_package_with_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(tieredPackageWithMinimum = it, _json = json) } - ?: Price(_json = json) - } - "package_with_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(packageWithAllocation = it, _json = json) } - ?: Price(_json = json) - } + fun isCumulativeGroupedBulk(): Boolean = cumulativeGroupedBulk != null + + fun isMinimum(): Boolean = minimum != null + + fun isEventOutput(): Boolean = eventOutput != null + + fun asUnit(): NewSubscriptionUnitPrice = unit.getOrThrow("unit") + + fun asTiered(): NewSubscriptionTieredPrice = tiered.getOrThrow("tiered") + + fun asBulk(): NewSubscriptionBulkPrice = bulk.getOrThrow("bulk") + + fun asPackage(): NewSubscriptionPackagePrice = package_.getOrThrow("package_") + + fun asMatrix(): NewSubscriptionMatrixPrice = matrix.getOrThrow("matrix") + + fun asThresholdTotalAmount(): NewSubscriptionThresholdTotalAmountPrice = + thresholdTotalAmount.getOrThrow("thresholdTotalAmount") + + fun asTieredPackage(): NewSubscriptionTieredPackagePrice = + tieredPackage.getOrThrow("tieredPackage") + + fun asTieredWithMinimum(): NewSubscriptionTieredWithMinimumPrice = + tieredWithMinimum.getOrThrow("tieredWithMinimum") + + fun asGroupedTiered(): NewSubscriptionGroupedTieredPrice = + groupedTiered.getOrThrow("groupedTiered") + + fun asTieredPackageWithMinimum(): NewSubscriptionTieredPackageWithMinimumPrice = + tieredPackageWithMinimum.getOrThrow("tieredPackageWithMinimum") + + fun asPackageWithAllocation(): NewSubscriptionPackageWithAllocationPrice = + packageWithAllocation.getOrThrow("packageWithAllocation") + + fun asUnitWithPercent(): NewSubscriptionUnitWithPercentPrice = + unitWithPercent.getOrThrow("unitWithPercent") + + fun asMatrixWithAllocation(): NewSubscriptionMatrixWithAllocationPrice = + matrixWithAllocation.getOrThrow("matrixWithAllocation") + + fun asTieredWithProration(): TieredWithProration = + tieredWithProration.getOrThrow("tieredWithProration") + + fun asUnitWithProration(): NewSubscriptionUnitWithProrationPrice = + unitWithProration.getOrThrow("unitWithProration") + + fun asGroupedAllocation(): NewSubscriptionGroupedAllocationPrice = + groupedAllocation.getOrThrow("groupedAllocation") + + fun asBulkWithProration(): NewSubscriptionBulkWithProrationPrice = + bulkWithProration.getOrThrow("bulkWithProration") + + fun asGroupedWithProratedMinimum(): NewSubscriptionGroupedWithProratedMinimumPrice = + groupedWithProratedMinimum.getOrThrow("groupedWithProratedMinimum") + + fun asGroupedWithMeteredMinimum(): NewSubscriptionGroupedWithMeteredMinimumPrice = + groupedWithMeteredMinimum.getOrThrow("groupedWithMeteredMinimum") + + fun asGroupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds = + groupedWithMinMaxThresholds.getOrThrow("groupedWithMinMaxThresholds") + + fun asMatrixWithDisplayName(): NewSubscriptionMatrixWithDisplayNamePrice = + matrixWithDisplayName.getOrThrow("matrixWithDisplayName") + + fun asGroupedTieredPackage(): NewSubscriptionGroupedTieredPackagePrice = + groupedTieredPackage.getOrThrow("groupedTieredPackage") + + fun asMaxGroupTieredPackage(): NewSubscriptionMaxGroupTieredPackagePrice = + maxGroupTieredPackage.getOrThrow("maxGroupTieredPackage") + + fun asScalableMatrixWithUnitPricing(): + NewSubscriptionScalableMatrixWithUnitPricingPrice = + scalableMatrixWithUnitPricing.getOrThrow("scalableMatrixWithUnitPricing") + + fun asScalableMatrixWithTieredPricing(): + NewSubscriptionScalableMatrixWithTieredPricingPrice = + scalableMatrixWithTieredPricing.getOrThrow("scalableMatrixWithTieredPricing") + + fun asCumulativeGroupedBulk(): NewSubscriptionCumulativeGroupedBulkPrice = + cumulativeGroupedBulk.getOrThrow("cumulativeGroupedBulk") + + fun asMinimum(): NewSubscriptionMinimumCompositePrice = minimum.getOrThrow("minimum") + + fun asEventOutput(): EventOutput = eventOutput.getOrThrow("eventOutput") + + fun _json(): JsonValue? = _json + + fun accept(visitor: Visitor): T = + when { + unit != null -> visitor.visitUnit(unit) + tiered != null -> visitor.visitTiered(tiered) + bulk != null -> visitor.visitBulk(bulk) + package_ != null -> visitor.visitPackage(package_) + matrix != null -> visitor.visitMatrix(matrix) + thresholdTotalAmount != null -> + visitor.visitThresholdTotalAmount(thresholdTotalAmount) + tieredPackage != null -> visitor.visitTieredPackage(tieredPackage) + tieredWithMinimum != null -> visitor.visitTieredWithMinimum(tieredWithMinimum) + groupedTiered != null -> visitor.visitGroupedTiered(groupedTiered) + tieredPackageWithMinimum != null -> + visitor.visitTieredPackageWithMinimum(tieredPackageWithMinimum) + packageWithAllocation != null -> + visitor.visitPackageWithAllocation(packageWithAllocation) + unitWithPercent != null -> visitor.visitUnitWithPercent(unitWithPercent) + matrixWithAllocation != null -> + visitor.visitMatrixWithAllocation(matrixWithAllocation) + tieredWithProration != null -> + visitor.visitTieredWithProration(tieredWithProration) + unitWithProration != null -> visitor.visitUnitWithProration(unitWithProration) + groupedAllocation != null -> visitor.visitGroupedAllocation(groupedAllocation) + bulkWithProration != null -> visitor.visitBulkWithProration(bulkWithProration) + groupedWithProratedMinimum != null -> + visitor.visitGroupedWithProratedMinimum(groupedWithProratedMinimum) + groupedWithMeteredMinimum != null -> + visitor.visitGroupedWithMeteredMinimum(groupedWithMeteredMinimum) + groupedWithMinMaxThresholds != null -> + visitor.visitGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds) + matrixWithDisplayName != null -> + visitor.visitMatrixWithDisplayName(matrixWithDisplayName) + groupedTieredPackage != null -> + visitor.visitGroupedTieredPackage(groupedTieredPackage) + maxGroupTieredPackage != null -> + visitor.visitMaxGroupTieredPackage(maxGroupTieredPackage) + scalableMatrixWithUnitPricing != null -> + visitor.visitScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing) + scalableMatrixWithTieredPricing != null -> + visitor.visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing + ) + cumulativeGroupedBulk != null -> + visitor.visitCumulativeGroupedBulk(cumulativeGroupedBulk) + minimum != null -> visitor.visitMinimum(minimum) + eventOutput != null -> visitor.visitEventOutput(eventOutput) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Price = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitUnit(unit: NewSubscriptionUnitPrice) { + unit.validate() + } + + override fun visitTiered(tiered: NewSubscriptionTieredPrice) { + tiered.validate() + } + + override fun visitBulk(bulk: NewSubscriptionBulkPrice) { + bulk.validate() + } + + override fun visitPackage(package_: NewSubscriptionPackagePrice) { + package_.validate() + } + + override fun visitMatrix(matrix: NewSubscriptionMatrixPrice) { + matrix.validate() + } + + override fun visitThresholdTotalAmount( + thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice + ) { + thresholdTotalAmount.validate() + } + + override fun visitTieredPackage( + tieredPackage: NewSubscriptionTieredPackagePrice + ) { + tieredPackage.validate() + } + + override fun visitTieredWithMinimum( + tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice + ) { + tieredWithMinimum.validate() + } + + override fun visitGroupedTiered( + groupedTiered: NewSubscriptionGroupedTieredPrice + ) { + groupedTiered.validate() + } + + override fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice + ) { + tieredPackageWithMinimum.validate() + } + + override fun visitPackageWithAllocation( + packageWithAllocation: NewSubscriptionPackageWithAllocationPrice + ) { + packageWithAllocation.validate() + } + + override fun visitUnitWithPercent( + unitWithPercent: NewSubscriptionUnitWithPercentPrice + ) { + unitWithPercent.validate() + } + + override fun visitMatrixWithAllocation( + matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice + ) { + matrixWithAllocation.validate() + } + + override fun visitTieredWithProration( + tieredWithProration: TieredWithProration + ) { + tieredWithProration.validate() + } + + override fun visitUnitWithProration( + unitWithProration: NewSubscriptionUnitWithProrationPrice + ) { + unitWithProration.validate() + } + + override fun visitGroupedAllocation( + groupedAllocation: NewSubscriptionGroupedAllocationPrice + ) { + groupedAllocation.validate() + } + + override fun visitBulkWithProration( + bulkWithProration: NewSubscriptionBulkWithProrationPrice + ) { + bulkWithProration.validate() + } + + override fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: + NewSubscriptionGroupedWithProratedMinimumPrice + ) { + groupedWithProratedMinimum.validate() + } + + override fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice + ) { + groupedWithMeteredMinimum.validate() + } + + override fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) { + groupedWithMinMaxThresholds.validate() + } + + override fun visitMatrixWithDisplayName( + matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice + ) { + matrixWithDisplayName.validate() + } + + override fun visitGroupedTieredPackage( + groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice + ) { + groupedTieredPackage.validate() + } + + override fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice + ) { + maxGroupTieredPackage.validate() + } + + override fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: + NewSubscriptionScalableMatrixWithUnitPricingPrice + ) { + scalableMatrixWithUnitPricing.validate() + } + + override fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: + NewSubscriptionScalableMatrixWithTieredPricingPrice + ) { + scalableMatrixWithTieredPricing.validate() + } + + override fun visitCumulativeGroupedBulk( + cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice + ) { + cumulativeGroupedBulk.validate() + } + + override fun visitMinimum(minimum: NewSubscriptionMinimumCompositePrice) { + minimum.validate() + } + + override fun visitEventOutput(eventOutput: EventOutput) { + eventOutput.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitUnit(unit: NewSubscriptionUnitPrice) = unit.validity() + + override fun visitTiered(tiered: NewSubscriptionTieredPrice) = + tiered.validity() + + override fun visitBulk(bulk: NewSubscriptionBulkPrice) = bulk.validity() + + override fun visitPackage(package_: NewSubscriptionPackagePrice) = + package_.validity() + + override fun visitMatrix(matrix: NewSubscriptionMatrixPrice) = + matrix.validity() + + override fun visitThresholdTotalAmount( + thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice + ) = thresholdTotalAmount.validity() + + override fun visitTieredPackage( + tieredPackage: NewSubscriptionTieredPackagePrice + ) = tieredPackage.validity() + + override fun visitTieredWithMinimum( + tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice + ) = tieredWithMinimum.validity() + + override fun visitGroupedTiered( + groupedTiered: NewSubscriptionGroupedTieredPrice + ) = groupedTiered.validity() + + override fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice + ) = tieredPackageWithMinimum.validity() + + override fun visitPackageWithAllocation( + packageWithAllocation: NewSubscriptionPackageWithAllocationPrice + ) = packageWithAllocation.validity() + + override fun visitUnitWithPercent( + unitWithPercent: NewSubscriptionUnitWithPercentPrice + ) = unitWithPercent.validity() + + override fun visitMatrixWithAllocation( + matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice + ) = matrixWithAllocation.validity() + + override fun visitTieredWithProration( + tieredWithProration: TieredWithProration + ) = tieredWithProration.validity() + + override fun visitUnitWithProration( + unitWithProration: NewSubscriptionUnitWithProrationPrice + ) = unitWithProration.validity() + + override fun visitGroupedAllocation( + groupedAllocation: NewSubscriptionGroupedAllocationPrice + ) = groupedAllocation.validity() + + override fun visitBulkWithProration( + bulkWithProration: NewSubscriptionBulkWithProrationPrice + ) = bulkWithProration.validity() + + override fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: + NewSubscriptionGroupedWithProratedMinimumPrice + ) = groupedWithProratedMinimum.validity() + + override fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice + ) = groupedWithMeteredMinimum.validity() + + override fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) = groupedWithMinMaxThresholds.validity() + + override fun visitMatrixWithDisplayName( + matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice + ) = matrixWithDisplayName.validity() + + override fun visitGroupedTieredPackage( + groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice + ) = groupedTieredPackage.validity() + + override fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice + ) = maxGroupTieredPackage.validity() + + override fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: + NewSubscriptionScalableMatrixWithUnitPricingPrice + ) = scalableMatrixWithUnitPricing.validity() + + override fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: + NewSubscriptionScalableMatrixWithTieredPricingPrice + ) = scalableMatrixWithTieredPricing.validity() + + override fun visitCumulativeGroupedBulk( + cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice + ) = cumulativeGroupedBulk.validity() + + override fun visitMinimum(minimum: NewSubscriptionMinimumCompositePrice) = + minimum.validity() + + override fun visitEventOutput(eventOutput: EventOutput) = + eventOutput.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Price && + unit == other.unit && + tiered == other.tiered && + bulk == other.bulk && + package_ == other.package_ && + matrix == other.matrix && + thresholdTotalAmount == other.thresholdTotalAmount && + tieredPackage == other.tieredPackage && + tieredWithMinimum == other.tieredWithMinimum && + groupedTiered == other.groupedTiered && + tieredPackageWithMinimum == other.tieredPackageWithMinimum && + packageWithAllocation == other.packageWithAllocation && + unitWithPercent == other.unitWithPercent && + matrixWithAllocation == other.matrixWithAllocation && + tieredWithProration == other.tieredWithProration && + unitWithProration == other.unitWithProration && + groupedAllocation == other.groupedAllocation && + bulkWithProration == other.bulkWithProration && + groupedWithProratedMinimum == other.groupedWithProratedMinimum && + groupedWithMeteredMinimum == other.groupedWithMeteredMinimum && + groupedWithMinMaxThresholds == other.groupedWithMinMaxThresholds && + matrixWithDisplayName == other.matrixWithDisplayName && + groupedTieredPackage == other.groupedTieredPackage && + maxGroupTieredPackage == other.maxGroupTieredPackage && + scalableMatrixWithUnitPricing == other.scalableMatrixWithUnitPricing && + scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && + cumulativeGroupedBulk == other.cumulativeGroupedBulk && + minimum == other.minimum && + eventOutput == other.eventOutput + } + + override fun hashCode(): Int = + Objects.hash( + unit, + tiered, + bulk, + package_, + matrix, + thresholdTotalAmount, + tieredPackage, + tieredWithMinimum, + groupedTiered, + tieredPackageWithMinimum, + packageWithAllocation, + unitWithPercent, + matrixWithAllocation, + tieredWithProration, + unitWithProration, + groupedAllocation, + bulkWithProration, + groupedWithProratedMinimum, + groupedWithMeteredMinimum, + groupedWithMinMaxThresholds, + matrixWithDisplayName, + groupedTieredPackage, + maxGroupTieredPackage, + scalableMatrixWithUnitPricing, + scalableMatrixWithTieredPricing, + cumulativeGroupedBulk, + minimum, + eventOutput, + ) + + override fun toString(): String = + when { + unit != null -> "Price{unit=$unit}" + tiered != null -> "Price{tiered=$tiered}" + bulk != null -> "Price{bulk=$bulk}" + package_ != null -> "Price{package_=$package_}" + matrix != null -> "Price{matrix=$matrix}" + thresholdTotalAmount != null -> + "Price{thresholdTotalAmount=$thresholdTotalAmount}" + tieredPackage != null -> "Price{tieredPackage=$tieredPackage}" + tieredWithMinimum != null -> "Price{tieredWithMinimum=$tieredWithMinimum}" + groupedTiered != null -> "Price{groupedTiered=$groupedTiered}" + tieredPackageWithMinimum != null -> + "Price{tieredPackageWithMinimum=$tieredPackageWithMinimum}" + packageWithAllocation != null -> + "Price{packageWithAllocation=$packageWithAllocation}" + unitWithPercent != null -> "Price{unitWithPercent=$unitWithPercent}" + matrixWithAllocation != null -> + "Price{matrixWithAllocation=$matrixWithAllocation}" + tieredWithProration != null -> "Price{tieredWithProration=$tieredWithProration}" + unitWithProration != null -> "Price{unitWithProration=$unitWithProration}" + groupedAllocation != null -> "Price{groupedAllocation=$groupedAllocation}" + bulkWithProration != null -> "Price{bulkWithProration=$bulkWithProration}" + groupedWithProratedMinimum != null -> + "Price{groupedWithProratedMinimum=$groupedWithProratedMinimum}" + groupedWithMeteredMinimum != null -> + "Price{groupedWithMeteredMinimum=$groupedWithMeteredMinimum}" + groupedWithMinMaxThresholds != null -> + "Price{groupedWithMinMaxThresholds=$groupedWithMinMaxThresholds}" + matrixWithDisplayName != null -> + "Price{matrixWithDisplayName=$matrixWithDisplayName}" + groupedTieredPackage != null -> + "Price{groupedTieredPackage=$groupedTieredPackage}" + maxGroupTieredPackage != null -> + "Price{maxGroupTieredPackage=$maxGroupTieredPackage}" + scalableMatrixWithUnitPricing != null -> + "Price{scalableMatrixWithUnitPricing=$scalableMatrixWithUnitPricing}" + scalableMatrixWithTieredPricing != null -> + "Price{scalableMatrixWithTieredPricing=$scalableMatrixWithTieredPricing}" + cumulativeGroupedBulk != null -> + "Price{cumulativeGroupedBulk=$cumulativeGroupedBulk}" + minimum != null -> "Price{minimum=$minimum}" + eventOutput != null -> "Price{eventOutput=$eventOutput}" + _json != null -> "Price{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Price") + } + + companion object { + + fun ofUnit(unit: NewSubscriptionUnitPrice) = Price(unit = unit) + + fun ofTiered(tiered: NewSubscriptionTieredPrice) = Price(tiered = tiered) + + fun ofBulk(bulk: NewSubscriptionBulkPrice) = Price(bulk = bulk) + + fun ofPackage(package_: NewSubscriptionPackagePrice) = Price(package_ = package_) + + fun ofMatrix(matrix: NewSubscriptionMatrixPrice) = Price(matrix = matrix) + + fun ofThresholdTotalAmount( + thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice + ) = Price(thresholdTotalAmount = thresholdTotalAmount) + + fun ofTieredPackage(tieredPackage: NewSubscriptionTieredPackagePrice) = + Price(tieredPackage = tieredPackage) + + fun ofTieredWithMinimum(tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice) = + Price(tieredWithMinimum = tieredWithMinimum) + + fun ofGroupedTiered(groupedTiered: NewSubscriptionGroupedTieredPrice) = + Price(groupedTiered = groupedTiered) + + fun ofTieredPackageWithMinimum( + tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice + ) = Price(tieredPackageWithMinimum = tieredPackageWithMinimum) + + fun ofPackageWithAllocation( + packageWithAllocation: NewSubscriptionPackageWithAllocationPrice + ) = Price(packageWithAllocation = packageWithAllocation) + + fun ofUnitWithPercent(unitWithPercent: NewSubscriptionUnitWithPercentPrice) = + Price(unitWithPercent = unitWithPercent) + + fun ofMatrixWithAllocation( + matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice + ) = Price(matrixWithAllocation = matrixWithAllocation) + + fun ofTieredWithProration(tieredWithProration: TieredWithProration) = + Price(tieredWithProration = tieredWithProration) + + fun ofUnitWithProration(unitWithProration: NewSubscriptionUnitWithProrationPrice) = + Price(unitWithProration = unitWithProration) + + fun ofGroupedAllocation(groupedAllocation: NewSubscriptionGroupedAllocationPrice) = + Price(groupedAllocation = groupedAllocation) + + fun ofBulkWithProration(bulkWithProration: NewSubscriptionBulkWithProrationPrice) = + Price(bulkWithProration = bulkWithProration) + + fun ofGroupedWithProratedMinimum( + groupedWithProratedMinimum: NewSubscriptionGroupedWithProratedMinimumPrice + ) = Price(groupedWithProratedMinimum = groupedWithProratedMinimum) + + fun ofGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice + ) = Price(groupedWithMeteredMinimum = groupedWithMeteredMinimum) + + fun ofGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) = Price(groupedWithMinMaxThresholds = groupedWithMinMaxThresholds) + + fun ofMatrixWithDisplayName( + matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice + ) = Price(matrixWithDisplayName = matrixWithDisplayName) + + fun ofGroupedTieredPackage( + groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice + ) = Price(groupedTieredPackage = groupedTieredPackage) + + fun ofMaxGroupTieredPackage( + maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice + ) = Price(maxGroupTieredPackage = maxGroupTieredPackage) + + fun ofScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: NewSubscriptionScalableMatrixWithUnitPricingPrice + ) = Price(scalableMatrixWithUnitPricing = scalableMatrixWithUnitPricing) + + fun ofScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: + NewSubscriptionScalableMatrixWithTieredPricingPrice + ) = Price(scalableMatrixWithTieredPricing = scalableMatrixWithTieredPricing) + + fun ofCumulativeGroupedBulk( + cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice + ) = Price(cumulativeGroupedBulk = cumulativeGroupedBulk) + + fun ofMinimum(minimum: NewSubscriptionMinimumCompositePrice) = + Price(minimum = minimum) + + fun ofEventOutput(eventOutput: EventOutput) = Price(eventOutput = eventOutput) + } + + /** + * An interface that defines how to map each variant of [Price] to a value of type [T]. + */ + interface Visitor { + + fun visitUnit(unit: NewSubscriptionUnitPrice): T + + fun visitTiered(tiered: NewSubscriptionTieredPrice): T + + fun visitBulk(bulk: NewSubscriptionBulkPrice): T + + fun visitPackage(package_: NewSubscriptionPackagePrice): T + + fun visitMatrix(matrix: NewSubscriptionMatrixPrice): T + + fun visitThresholdTotalAmount( + thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice + ): T + + fun visitTieredPackage(tieredPackage: NewSubscriptionTieredPackagePrice): T + + fun visitTieredWithMinimum( + tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice + ): T + + fun visitGroupedTiered(groupedTiered: NewSubscriptionGroupedTieredPrice): T + + fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice + ): T + + fun visitPackageWithAllocation( + packageWithAllocation: NewSubscriptionPackageWithAllocationPrice + ): T + + fun visitUnitWithPercent(unitWithPercent: NewSubscriptionUnitWithPercentPrice): T + + fun visitMatrixWithAllocation( + matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice + ): T + + fun visitTieredWithProration(tieredWithProration: TieredWithProration): T + + fun visitUnitWithProration( + unitWithProration: NewSubscriptionUnitWithProrationPrice + ): T + + fun visitGroupedAllocation( + groupedAllocation: NewSubscriptionGroupedAllocationPrice + ): T + + fun visitBulkWithProration( + bulkWithProration: NewSubscriptionBulkWithProrationPrice + ): T + + fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: NewSubscriptionGroupedWithProratedMinimumPrice + ): T + + fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice + ): T + + fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ): T + + fun visitMatrixWithDisplayName( + matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice + ): T + + fun visitGroupedTieredPackage( + groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice + ): T + + fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice + ): T + + fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: NewSubscriptionScalableMatrixWithUnitPricingPrice + ): T + + fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: + NewSubscriptionScalableMatrixWithTieredPricingPrice + ): T + + fun visitCumulativeGroupedBulk( + cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice + ): T + + fun visitMinimum(minimum: NewSubscriptionMinimumCompositePrice): T + + fun visitEventOutput(eventOutput: EventOutput): T + + /** + * Maps an unknown variant of [Price] to a value of type [T]. + * + * An instance of [Price] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is + * unaware of. + * + * @throws OrbInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw OrbInvalidDataException("Unknown Price: $json") + } + } + + internal class Deserializer : BaseDeserializer(Price::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Price { + val json = JsonValue.fromJsonNode(node) + val modelType = json.asObject()?.get("model_type")?.asString() + + when (modelType) { + "unit" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(unit = it, _json = json) } ?: Price(_json = json) + } + "tiered" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(tiered = it, _json = json) } ?: Price(_json = json) + } + "bulk" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(bulk = it, _json = json) } ?: Price(_json = json) + } + "package" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(package_ = it, _json = json) } ?: Price(_json = json) + } + "matrix" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(matrix = it, _json = json) } ?: Price(_json = json) + } + "threshold_total_amount" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(thresholdTotalAmount = it, _json = json) } + ?: Price(_json = json) + } + "tiered_package" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(tieredPackage = it, _json = json) } + ?: Price(_json = json) + } + "tiered_with_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(tieredWithMinimum = it, _json = json) } + ?: Price(_json = json) + } + "grouped_tiered" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedTiered = it, _json = json) } + ?: Price(_json = json) + } + "tiered_package_with_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(tieredPackageWithMinimum = it, _json = json) } + ?: Price(_json = json) + } + "package_with_allocation" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(packageWithAllocation = it, _json = json) } + ?: Price(_json = json) + } "unit_with_percent" -> { return tryDeserialize( node, jacksonTypeRef(), ) - ?.let { Price(unitWithPercent = it, _json = json) } - ?: Price(_json = json) + ?.let { Price(unitWithPercent = it, _json = json) } + ?: Price(_json = json) + } + "matrix_with_allocation" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(matrixWithAllocation = it, _json = json) } + ?: Price(_json = json) + } + "tiered_with_proration" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(tieredWithProration = it, _json = json) } + ?: Price(_json = json) + } + "unit_with_proration" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(unitWithProration = it, _json = json) } + ?: Price(_json = json) + } + "grouped_allocation" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedAllocation = it, _json = json) } + ?: Price(_json = json) + } + "bulk_with_proration" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(bulkWithProration = it, _json = json) } + ?: Price(_json = json) + } + "grouped_with_prorated_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedWithProratedMinimum = it, _json = json) } + ?: Price(_json = json) + } + "grouped_with_metered_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedWithMeteredMinimum = it, _json = json) } + ?: Price(_json = json) + } + "grouped_with_min_max_thresholds" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedWithMinMaxThresholds = it, _json = json) } + ?: Price(_json = json) + } + "matrix_with_display_name" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(matrixWithDisplayName = it, _json = json) } + ?: Price(_json = json) + } + "grouped_tiered_package" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedTieredPackage = it, _json = json) } + ?: Price(_json = json) + } + "max_group_tiered_package" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(maxGroupTieredPackage = it, _json = json) } + ?: Price(_json = json) + } + "scalable_matrix_with_unit_pricing" -> { + return tryDeserialize( + node, + jacksonTypeRef< + NewSubscriptionScalableMatrixWithUnitPricingPrice + >(), + ) + ?.let { Price(scalableMatrixWithUnitPricing = it, _json = json) } + ?: Price(_json = json) + } + "scalable_matrix_with_tiered_pricing" -> { + return tryDeserialize( + node, + jacksonTypeRef< + NewSubscriptionScalableMatrixWithTieredPricingPrice + >(), + ) + ?.let { Price(scalableMatrixWithTieredPricing = it, _json = json) } + ?: Price(_json = json) + } + "cumulative_grouped_bulk" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(cumulativeGroupedBulk = it, _json = json) } + ?: Price(_json = json) + } + "minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(minimum = it, _json = json) } ?: Price(_json = json) + } + "event_output" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(eventOutput = it, _json = json) + } ?: Price(_json = json) + } + } + + return Price(_json = json) + } + } + + internal class Serializer : BaseSerializer(Price::class) { + + override fun serialize( + value: Price, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.unit != null -> generator.writeObject(value.unit) + value.tiered != null -> generator.writeObject(value.tiered) + value.bulk != null -> generator.writeObject(value.bulk) + value.package_ != null -> generator.writeObject(value.package_) + value.matrix != null -> generator.writeObject(value.matrix) + value.thresholdTotalAmount != null -> + generator.writeObject(value.thresholdTotalAmount) + value.tieredPackage != null -> generator.writeObject(value.tieredPackage) + value.tieredWithMinimum != null -> + generator.writeObject(value.tieredWithMinimum) + value.groupedTiered != null -> generator.writeObject(value.groupedTiered) + value.tieredPackageWithMinimum != null -> + generator.writeObject(value.tieredPackageWithMinimum) + value.packageWithAllocation != null -> + generator.writeObject(value.packageWithAllocation) + value.unitWithPercent != null -> + generator.writeObject(value.unitWithPercent) + value.matrixWithAllocation != null -> + generator.writeObject(value.matrixWithAllocation) + value.tieredWithProration != null -> + generator.writeObject(value.tieredWithProration) + value.unitWithProration != null -> + generator.writeObject(value.unitWithProration) + value.groupedAllocation != null -> + generator.writeObject(value.groupedAllocation) + value.bulkWithProration != null -> + generator.writeObject(value.bulkWithProration) + value.groupedWithProratedMinimum != null -> + generator.writeObject(value.groupedWithProratedMinimum) + value.groupedWithMeteredMinimum != null -> + generator.writeObject(value.groupedWithMeteredMinimum) + value.groupedWithMinMaxThresholds != null -> + generator.writeObject(value.groupedWithMinMaxThresholds) + value.matrixWithDisplayName != null -> + generator.writeObject(value.matrixWithDisplayName) + value.groupedTieredPackage != null -> + generator.writeObject(value.groupedTieredPackage) + value.maxGroupTieredPackage != null -> + generator.writeObject(value.maxGroupTieredPackage) + value.scalableMatrixWithUnitPricing != null -> + generator.writeObject(value.scalableMatrixWithUnitPricing) + value.scalableMatrixWithTieredPricing != null -> + generator.writeObject(value.scalableMatrixWithTieredPricing) + value.cumulativeGroupedBulk != null -> + generator.writeObject(value.cumulativeGroupedBulk) + value.minimum != null -> generator.writeObject(value.minimum) + value.eventOutput != null -> generator.writeObject(value.eventOutput) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Price") + } + } + } + + class TieredWithProration + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val tieredWithProrationConfig: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("tiered_with_proration_config") + @ExcludeMissing + tieredWithProrationConfig: JsonField = + JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + modelType, + name, + tieredWithProrationConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("tiered_with_proration") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * Configuration for tiered_with_proration pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun tieredWithProrationConfig(): TieredWithProrationConfig = + tieredWithProrationConfig.getRequired("tiered_with_proration_config") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = billableMetricId.getNullable("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + invoiceGroupingKey.getNullable("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [tieredWithProrationConfig]. + * + * Unlike [tieredWithProrationConfig], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("tiered_with_proration_config") + @ExcludeMissing + fun _tieredWithProrationConfig(): JsonField = + tieredWithProrationConfig + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [TieredWithProration]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .name() + * .tieredWithProrationConfig() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [TieredWithProration]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonValue = JsonValue.from("tiered_with_proration") + private var name: JsonField? = null + private var tieredWithProrationConfig: JsonField? = + null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(tieredWithProration: TieredWithProration) = apply { + cadence = tieredWithProration.cadence + itemId = tieredWithProration.itemId + modelType = tieredWithProration.modelType + name = tieredWithProration.name + tieredWithProrationConfig = tieredWithProration.tieredWithProrationConfig + billableMetricId = tieredWithProration.billableMetricId + billedInAdvance = tieredWithProration.billedInAdvance + billingCycleConfiguration = tieredWithProration.billingCycleConfiguration + conversionRate = tieredWithProration.conversionRate + conversionRateConfig = tieredWithProration.conversionRateConfig + currency = tieredWithProration.currency + dimensionalPriceConfiguration = + tieredWithProration.dimensionalPriceConfiguration + externalPriceId = tieredWithProration.externalPriceId + fixedPriceQuantity = tieredWithProration.fixedPriceQuantity + invoiceGroupingKey = tieredWithProration.invoiceGroupingKey + invoicingCycleConfiguration = + tieredWithProration.invoicingCycleConfiguration + metadata = tieredWithProration.metadata + referenceId = tieredWithProration.referenceId + additionalProperties = + tieredWithProration.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("tiered_with_proration") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for tiered_with_proration pricing */ + fun tieredWithProrationConfig( + tieredWithProrationConfig: TieredWithProrationConfig + ) = tieredWithProrationConfig(JsonField.of(tieredWithProrationConfig)) + + /** + * Sets [Builder.tieredWithProrationConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.tieredWithProrationConfig] with a well-typed + * [TieredWithProrationConfig] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun tieredWithProrationConfig( + tieredWithProrationConfig: JsonField + ) = apply { this.tieredWithProrationConfig = tieredWithProrationConfig } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [TieredWithProration]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .name() + * .tieredWithProrationConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TieredWithProration = + TieredWithProration( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + modelType, + checkRequired("name", name), + checkRequired("tieredWithProrationConfig", tieredWithProrationConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TieredWithProration = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + _modelType().let { + if (it != JsonValue.from("tiered_with_proration")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + tieredWithProrationConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + modelType.let { + if (it == JsonValue.from("tiered_with_proration")) 1 else 0 + } + + (if (name.asKnown() == null) 0 else 1) + + (tieredWithProrationConfig.asKnown()?.validity() ?: 0) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Configuration for tiered_with_proration pricing */ + class TieredWithProrationConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val tiers: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of() + ) : this(tiers, mutableMapOf()) + + /** + * Tiers for rating based on total usage quantities into the specified tier with + * proration + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun tiers(): List = tiers.getRequired("tiers") + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [TieredWithProrationConfig]. + * + * The following fields are required: + * ```kotlin + * .tiers() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [TieredWithProrationConfig]. */ + class Builder internal constructor() { + + private var tiers: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(tieredWithProrationConfig: TieredWithProrationConfig) = + apply { + tiers = tieredWithProrationConfig.tiers.map { it.toMutableList() } + additionalProperties = + tieredWithProrationConfig.additionalProperties.toMutableMap() + } + + /** + * Tiers for rating based on total usage quantities into the specified tier + * with proration + */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } } - "matrix_with_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(matrixWithAllocation = it, _json = json) } - ?: Price(_json = json) + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) } - "tiered_with_proration" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(tieredWithProration = it, _json = json) } - ?: Price(_json = json) + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) } - "unit_with_proration" -> { - return tryDeserialize( - node, - jacksonTypeRef(), + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [TieredWithProrationConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TieredWithProrationConfig = + TieredWithProrationConfig( + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TieredWithProrationConfig = apply { + if (validated) { + return@apply + } + + tiers().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (tiers.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single tiered with proration tier */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val tierLowerBound: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(tierLowerBound, unitAmount, mutableMapOf()) + + /** + * Inclusive tier starting value + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun tierLowerBound(): String = + tierLowerBound.getRequired("tier_lower_bound") + + /** + * Amount per unit + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Tier]. + * + * The following fields are required: + * ```kotlin + * .tierLowerBound() + * .unitAmount() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var tierLowerBound: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(tier: Tier) = apply { + tierLowerBound = tier.tierLowerBound + unitAmount = tier.unitAmount + additionalProperties = tier.additionalProperties.toMutableMap() + } + + /** Inclusive tier starting value */ + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + /** Amount per unit */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```kotlin + * .tierLowerBound() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("tierLowerBound", tierLowerBound), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), ) - ?.let { Price(unitWithProration = it, _json = json) } - ?: Price(_json = json) } - "grouped_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedAllocation = it, _json = json) } - ?: Price(_json = json) + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + tierLowerBound() + unitAmount() + validated = true } - "bulk_with_proration" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(bulkWithProration = it, _json = json) } - ?: Price(_json = json) + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (tierLowerBound.asKnown() == null) 0 else 1) + + (if (unitAmount.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + tierLowerBound == other.tierLowerBound && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties } - "grouped_with_prorated_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedWithProratedMinimum = it, _json = json) } - ?: Price(_json = json) + + private val hashCode: Int by lazy { + Objects.hash(tierLowerBound, unitAmount, additionalProperties) } - "grouped_with_metered_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedWithMeteredMinimum = it, _json = json) } - ?: Price(_json = json) + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - "grouped_with_min_max_thresholds" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedWithMinMaxThresholds = it, _json = json) } - ?: Price(_json = json) + + return other is TieredWithProrationConfig && + tiers == other.tiers && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(tiers, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TieredWithProrationConfig{tiers=$tiers, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() } - "matrix_with_display_name" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(matrixWithDisplayName = it, _json = json) } - ?: Price(_json = json) + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) } - "grouped_tiered_package" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedTieredPackage = it, _json = json) } - ?: Price(_json = json) + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) } - "max_group_tiered_package" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(maxGroupTieredPackage = it, _json = json) } - ?: Price(_json = json) + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) } - "scalable_matrix_with_unit_pricing" -> { - return tryDeserialize( - node, - jacksonTypeRef< - NewSubscriptionScalableMatrixWithUnitPricingPrice - >(), - ) - ?.let { Price(scalableMatrixWithUnitPricing = it, _json = json) } - ?: Price(_json = json) + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply } - "scalable_matrix_with_tiered_pricing" -> { - return tryDeserialize( - node, - jacksonTypeRef< - NewSubscriptionScalableMatrixWithTieredPricingPrice - >(), - ) - ?.let { Price(scalableMatrixWithTieredPricing = it, _json = json) } - ?: Price(_json = json) + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false } - "cumulative_grouped_bulk" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(cumulativeGroupedBulk = it, _json = json) } - ?: Price(_json = json) + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() } - "minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(minimum = it, _json = json) } ?: Price(_json = json) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } + + return other is Metadata && + additionalProperties == other.additionalProperties } - return Price(_json = json) - } - } + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode - internal class Serializer : BaseSerializer(Price::class) { + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } - override fun serialize( - value: Price, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unit != null -> generator.writeObject(value.unit) - value.tiered != null -> generator.writeObject(value.tiered) - value.bulk != null -> generator.writeObject(value.bulk) - value.package_ != null -> generator.writeObject(value.package_) - value.matrix != null -> generator.writeObject(value.matrix) - value.thresholdTotalAmount != null -> - generator.writeObject(value.thresholdTotalAmount) - value.tieredPackage != null -> generator.writeObject(value.tieredPackage) - value.tieredWithMinimum != null -> - generator.writeObject(value.tieredWithMinimum) - value.groupedTiered != null -> generator.writeObject(value.groupedTiered) - value.tieredPackageWithMinimum != null -> - generator.writeObject(value.tieredPackageWithMinimum) - value.packageWithAllocation != null -> - generator.writeObject(value.packageWithAllocation) - value.unitWithPercent != null -> - generator.writeObject(value.unitWithPercent) - value.matrixWithAllocation != null -> - generator.writeObject(value.matrixWithAllocation) - value.tieredWithProration != null -> - generator.writeObject(value.tieredWithProration) - value.unitWithProration != null -> - generator.writeObject(value.unitWithProration) - value.groupedAllocation != null -> - generator.writeObject(value.groupedAllocation) - value.bulkWithProration != null -> - generator.writeObject(value.bulkWithProration) - value.groupedWithProratedMinimum != null -> - generator.writeObject(value.groupedWithProratedMinimum) - value.groupedWithMeteredMinimum != null -> - generator.writeObject(value.groupedWithMeteredMinimum) - value.groupedWithMinMaxThresholds != null -> - generator.writeObject(value.groupedWithMinMaxThresholds) - value.matrixWithDisplayName != null -> - generator.writeObject(value.matrixWithDisplayName) - value.groupedTieredPackage != null -> - generator.writeObject(value.groupedTieredPackage) - value.maxGroupTieredPackage != null -> - generator.writeObject(value.maxGroupTieredPackage) - value.scalableMatrixWithUnitPricing != null -> - generator.writeObject(value.scalableMatrixWithUnitPricing) - value.scalableMatrixWithTieredPricing != null -> - generator.writeObject(value.scalableMatrixWithTieredPricing) - value.cumulativeGroupedBulk != null -> - generator.writeObject(value.cumulativeGroupedBulk) - value.minimum != null -> generator.writeObject(value.minimum) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Price") + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } + + return other is TieredWithProration && + cadence == other.cadence && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + tieredWithProrationConfig == other.tieredWithProrationConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + modelType, + name, + tieredWithProrationConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties, + ) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TieredWithProration{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredWithProrationConfig=$tieredWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class TieredWithProration + class GroupedWithMinMaxThresholds @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, + private val groupedWithMinMaxThresholdsConfig: + JsonField, private val itemId: JsonField, private val modelType: JsonValue, private val name: JsonField, - private val tieredWithProrationConfig: JsonField, private val billableMetricId: JsonField, private val billedInAdvance: JsonField, private val billingCycleConfiguration: JsonField, @@ -12084,6 +15484,11 @@ private constructor( @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), + @JsonProperty("grouped_with_min_max_thresholds_config") + @ExcludeMissing + groupedWithMinMaxThresholdsConfig: + JsonField = + JsonMissing.of(), @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), @@ -12093,10 +15498,6 @@ private constructor( @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("tiered_with_proration_config") - @ExcludeMissing - tieredWithProrationConfig: JsonField = - JsonMissing.of(), @JsonProperty("billable_metric_id") @ExcludeMissing billableMetricId: JsonField = JsonMissing.of(), @@ -12141,10 +15542,10 @@ private constructor( referenceId: JsonField = JsonMissing.of(), ) : this( cadence, + groupedWithMinMaxThresholdsConfig, itemId, modelType, name, - tieredWithProrationConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -12170,6 +15571,18 @@ private constructor( */ fun cadence(): Cadence = cadence.getRequired("cadence") + /** + * Configuration for grouped_with_min_max_thresholds pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupedWithMinMaxThresholdsConfig(): GroupedWithMinMaxThresholdsConfig = + groupedWithMinMaxThresholdsConfig.getRequired( + "grouped_with_min_max_thresholds_config" + ) + /** * The id of the item the price will be associated with. * @@ -12184,7 +15597,7 @@ private constructor( * * Expected to always return the following: * ```kotlin - * JsonValue.from("tiered_with_proration") + * JsonValue.from("grouped_with_min_max_thresholds") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -12201,16 +15614,6 @@ private constructor( */ fun name(): String = name.getRequired("name") - /** - * Configuration for tiered_with_proration pricing - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun tieredWithProrationConfig(): TieredWithProrationConfig = - tieredWithProrationConfig.getRequired("tiered_with_proration_config") - /** * The id of the billable metric for the price. Only needed if the price is * usage-based. @@ -12340,6 +15743,17 @@ private constructor( @ExcludeMissing fun _cadence(): JsonField = cadence + /** + * Returns the raw JSON value of [groupedWithMinMaxThresholdsConfig]. + * + * Unlike [groupedWithMinMaxThresholdsConfig], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("grouped_with_min_max_thresholds_config") + @ExcludeMissing + fun _groupedWithMinMaxThresholdsConfig(): + JsonField = groupedWithMinMaxThresholdsConfig + /** * Returns the raw JSON value of [itemId]. * @@ -12356,17 +15770,6 @@ private constructor( */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - /** - * Returns the raw JSON value of [tieredWithProrationConfig]. - * - * Unlike [tieredWithProrationConfig], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("tiered_with_proration_config") - @ExcludeMissing - fun _tieredWithProrationConfig(): JsonField = - tieredWithProrationConfig - /** * Returns the raw JSON value of [billableMetricId]. * @@ -12516,28 +15919,30 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [TieredWithProration]. + * [GroupedWithMinMaxThresholds]. * * The following fields are required: * ```kotlin * .cadence() + * .groupedWithMinMaxThresholdsConfig() * .itemId() * .name() - * .tieredWithProrationConfig() * ``` */ fun builder() = Builder() } - /** A builder for [TieredWithProration]. */ + /** A builder for [GroupedWithMinMaxThresholds]. */ class Builder internal constructor() { private var cadence: JsonField? = null + private var groupedWithMinMaxThresholdsConfig: + JsonField? = + null private var itemId: JsonField? = null - private var modelType: JsonValue = JsonValue.from("tiered_with_proration") + private var modelType: JsonValue = + JsonValue.from("grouped_with_min_max_thresholds") private var name: JsonField? = null - private var tieredWithProrationConfig: JsonField? = - null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() private var billingCycleConfiguration: JsonField = @@ -12559,30 +15964,33 @@ private constructor( private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(tieredWithProration: TieredWithProration) = apply { - cadence = tieredWithProration.cadence - itemId = tieredWithProration.itemId - modelType = tieredWithProration.modelType - name = tieredWithProration.name - tieredWithProrationConfig = tieredWithProration.tieredWithProrationConfig - billableMetricId = tieredWithProration.billableMetricId - billedInAdvance = tieredWithProration.billedInAdvance - billingCycleConfiguration = tieredWithProration.billingCycleConfiguration - conversionRate = tieredWithProration.conversionRate - conversionRateConfig = tieredWithProration.conversionRateConfig - currency = tieredWithProration.currency - dimensionalPriceConfiguration = - tieredWithProration.dimensionalPriceConfiguration - externalPriceId = tieredWithProration.externalPriceId - fixedPriceQuantity = tieredWithProration.fixedPriceQuantity - invoiceGroupingKey = tieredWithProration.invoiceGroupingKey - invoicingCycleConfiguration = - tieredWithProration.invoicingCycleConfiguration - metadata = tieredWithProration.metadata - referenceId = tieredWithProration.referenceId - additionalProperties = - tieredWithProration.additionalProperties.toMutableMap() - } + internal fun from(groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds) = + apply { + cadence = groupedWithMinMaxThresholds.cadence + groupedWithMinMaxThresholdsConfig = + groupedWithMinMaxThresholds.groupedWithMinMaxThresholdsConfig + itemId = groupedWithMinMaxThresholds.itemId + modelType = groupedWithMinMaxThresholds.modelType + name = groupedWithMinMaxThresholds.name + billableMetricId = groupedWithMinMaxThresholds.billableMetricId + billedInAdvance = groupedWithMinMaxThresholds.billedInAdvance + billingCycleConfiguration = + groupedWithMinMaxThresholds.billingCycleConfiguration + conversionRate = groupedWithMinMaxThresholds.conversionRate + conversionRateConfig = groupedWithMinMaxThresholds.conversionRateConfig + currency = groupedWithMinMaxThresholds.currency + dimensionalPriceConfiguration = + groupedWithMinMaxThresholds.dimensionalPriceConfiguration + externalPriceId = groupedWithMinMaxThresholds.externalPriceId + fixedPriceQuantity = groupedWithMinMaxThresholds.fixedPriceQuantity + invoiceGroupingKey = groupedWithMinMaxThresholds.invoiceGroupingKey + invoicingCycleConfiguration = + groupedWithMinMaxThresholds.invoicingCycleConfiguration + metadata = groupedWithMinMaxThresholds.metadata + referenceId = groupedWithMinMaxThresholds.referenceId + additionalProperties = + groupedWithMinMaxThresholds.additionalProperties.toMutableMap() + } /** The cadence to bill for this price on. */ fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) @@ -12594,7 +16002,30 @@ private constructor( * instead. This method is primarily for setting the field to an undocumented or * not yet supported value. */ - fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** Configuration for grouped_with_min_max_thresholds pricing */ + fun groupedWithMinMaxThresholdsConfig( + groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + ) = + groupedWithMinMaxThresholdsConfig( + JsonField.of(groupedWithMinMaxThresholdsConfig) + ) + + /** + * Sets [Builder.groupedWithMinMaxThresholdsConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.groupedWithMinMaxThresholdsConfig] with a + * well-typed [GroupedWithMinMaxThresholdsConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun groupedWithMinMaxThresholdsConfig( + groupedWithMinMaxThresholdsConfig: + JsonField + ) = apply { + this.groupedWithMinMaxThresholdsConfig = groupedWithMinMaxThresholdsConfig + } /** The id of the item the price will be associated with. */ fun itemId(itemId: String) = itemId(JsonField.of(itemId)) @@ -12614,7 +16045,7 @@ private constructor( * It is usually unnecessary to call this method because the field defaults to * the following: * ```kotlin - * JsonValue.from("tiered_with_proration") + * JsonValue.from("grouped_with_min_max_thresholds") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -12634,22 +16065,6 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } - /** Configuration for tiered_with_proration pricing */ - fun tieredWithProrationConfig( - tieredWithProrationConfig: TieredWithProrationConfig - ) = tieredWithProrationConfig(JsonField.of(tieredWithProrationConfig)) - - /** - * Sets [Builder.tieredWithProrationConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.tieredWithProrationConfig] with a well-typed - * [TieredWithProrationConfig] value instead. This method is primarily for - * setting the field to an undocumented or not yet supported value. - */ - fun tieredWithProrationConfig( - tieredWithProrationConfig: JsonField - ) = apply { this.tieredWithProrationConfig = tieredWithProrationConfig } - /** * The id of the billable metric for the price. Only needed if the price is * usage-based. @@ -12979,27 +16394,30 @@ private constructor( } /** - * Returns an immutable instance of [TieredWithProration]. + * Returns an immutable instance of [GroupedWithMinMaxThresholds]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```kotlin * .cadence() + * .groupedWithMinMaxThresholdsConfig() * .itemId() * .name() - * .tieredWithProrationConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): TieredWithProration = - TieredWithProration( + fun build(): GroupedWithMinMaxThresholds = + GroupedWithMinMaxThresholds( checkRequired("cadence", cadence), + checkRequired( + "groupedWithMinMaxThresholdsConfig", + groupedWithMinMaxThresholdsConfig, + ), checkRequired("itemId", itemId), modelType, checkRequired("name", name), - checkRequired("tieredWithProrationConfig", tieredWithProrationConfig), billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -13019,20 +16437,20 @@ private constructor( private var validated: Boolean = false - fun validate(): TieredWithProration = apply { + fun validate(): GroupedWithMinMaxThresholds = apply { if (validated) { return@apply } cadence().validate() + groupedWithMinMaxThresholdsConfig().validate() itemId() _modelType().let { - if (it != JsonValue.from("tiered_with_proration")) { + if (it != JsonValue.from("grouped_with_min_max_thresholds")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } name() - tieredWithProrationConfig().validate() billableMetricId() billedInAdvance() billingCycleConfiguration()?.validate() @@ -13065,12 +16483,12 @@ private constructor( */ internal fun validity(): Int = (cadence.asKnown()?.validity() ?: 0) + + (groupedWithMinMaxThresholdsConfig.asKnown()?.validity() ?: 0) + (if (itemId.asKnown() == null) 0 else 1) + modelType.let { - if (it == JsonValue.from("tiered_with_proration")) 1 else 0 + if (it == JsonValue.from("grouped_with_min_max_thresholds")) 1 else 0 } + (if (name.asKnown() == null) 0 else 1) + - (tieredWithProrationConfig.asKnown()?.validity() ?: 0) + (if (billableMetricId.asKnown() == null) 0 else 1) + (if (billedInAdvance.asKnown() == null) 0 else 1) + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + @@ -13182,220 +16600,34 @@ private constructor( when (this) { ANNUAL -> Known.ANNUAL SEMI_ANNUAL -> Known.SEMI_ANNUAL - MONTHLY -> Known.MONTHLY - QUARTERLY -> Known.QUARTERLY - ONE_TIME -> Known.ONE_TIME - CUSTOM -> Known.CUSTOM - else -> throw OrbInvalidDataException("Unknown Cadence: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString() - ?: throw OrbInvalidDataException("Value is not a String") - - private var validated: Boolean = false - - fun validate(): Cadence = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Cadence && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** Configuration for tiered_with_proration pricing */ - class TieredWithProrationConfig - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val tiers: JsonField>, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("tiers") - @ExcludeMissing - tiers: JsonField> = JsonMissing.of() - ) : this(tiers, mutableMapOf()) - - /** - * Tiers for rating based on total usage quantities into the specified tier with - * proration - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun tiers(): List = tiers.getRequired("tiers") - - /** - * Returns the raw JSON value of [tiers]. - * - * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("tiers") - @ExcludeMissing - fun _tiers(): JsonField> = tiers - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [TieredWithProrationConfig]. - * - * The following fields are required: - * ```kotlin - * .tiers() - * ``` - */ - fun builder() = Builder() - } - - /** A builder for [TieredWithProrationConfig]. */ - class Builder internal constructor() { - - private var tiers: JsonField>? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - internal fun from(tieredWithProrationConfig: TieredWithProrationConfig) = - apply { - tiers = tieredWithProrationConfig.tiers.map { it.toMutableList() } - additionalProperties = - tieredWithProrationConfig.additionalProperties.toMutableMap() - } - - /** - * Tiers for rating based on total usage quantities into the specified tier - * with proration - */ - fun tiers(tiers: List) = tiers(JsonField.of(tiers)) - - /** - * Sets [Builder.tiers] to an arbitrary JSON value. - * - * You should usually call [Builder.tiers] with a well-typed `List` - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun tiers(tiers: JsonField>) = apply { - this.tiers = tiers.map { it.toMutableList() } - } - - /** - * Adds a single [Tier] to [tiers]. - * - * @throws IllegalStateException if the field was previously set to a - * non-list. - */ - fun addTier(tier: Tier) = apply { - tiers = - (tiers ?: JsonField.of(mutableListOf())).also { - checkKnown("tiers", it).add(tier) - } - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [TieredWithProrationConfig]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```kotlin - * .tiers() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): TieredWithProrationConfig = - TieredWithProrationConfig( - checkRequired("tiers", tiers).map { it.toImmutable() }, - additionalProperties.toMutableMap(), - ) - } + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") private var validated: Boolean = false - fun validate(): TieredWithProrationConfig = apply { + fun validate(): Cadence = apply { if (validated) { return@apply } - tiers().forEach { it.validate() } + known() validated = true } @@ -13413,248 +16645,343 @@ private constructor( * * Used for best match union deserialization. */ - internal fun validity(): Int = - (tiers.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - /** Configuration for a single tiered with proration tier */ - class Tier - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val tierLowerBound: JsonField, - private val unitAmount: JsonField, - private val additionalProperties: MutableMap, - ) { + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - @JsonCreator - private constructor( - @JsonProperty("tier_lower_bound") - @ExcludeMissing - tierLowerBound: JsonField = JsonMissing.of(), - @JsonProperty("unit_amount") - @ExcludeMissing - unitAmount: JsonField = JsonMissing.of(), - ) : this(tierLowerBound, unitAmount, mutableMapOf()) + return other is Cadence && value == other.value + } - /** - * Inclusive tier starting value - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type - * or is unexpectedly missing or null (e.g. if the server responded with - * an unexpected value). - */ - fun tierLowerBound(): String = - tierLowerBound.getRequired("tier_lower_bound") + override fun hashCode() = value.hashCode() - /** - * Amount per unit - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type - * or is unexpectedly missing or null (e.g. if the server responded with - * an unexpected value). - */ - fun unitAmount(): String = unitAmount.getRequired("unit_amount") + override fun toString() = value.toString() + } - /** - * Returns the raw JSON value of [tierLowerBound]. - * - * Unlike [tierLowerBound], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("tier_lower_bound") - @ExcludeMissing - fun _tierLowerBound(): JsonField = tierLowerBound + /** Configuration for grouped_with_min_max_thresholds pricing */ + class GroupedWithMinMaxThresholdsConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val groupingKey: JsonField, + private val maximumCharge: JsonField, + private val minimumCharge: JsonField, + private val perUnitRate: JsonField, + private val additionalProperties: MutableMap, + ) { - /** - * Returns the raw JSON value of [unitAmount]. - * - * Unlike [unitAmount], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("unit_amount") + @JsonCreator + private constructor( + @JsonProperty("grouping_key") @ExcludeMissing - fun _unitAmount(): JsonField = unitAmount + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("maximum_charge") + @ExcludeMissing + maximumCharge: JsonField = JsonMissing.of(), + @JsonProperty("minimum_charge") + @ExcludeMissing + minimumCharge: JsonField = JsonMissing.of(), + @JsonProperty("per_unit_rate") + @ExcludeMissing + perUnitRate: JsonField = JsonMissing.of(), + ) : this(groupingKey, maximumCharge, minimumCharge, perUnitRate, mutableMapOf()) - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** + * The event property used to group before applying thresholds + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** + * The maximum amount to charge each group + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun maximumCharge(): String = maximumCharge.getRequired("maximum_charge") - fun toBuilder() = Builder().from(this) + /** + * The minimum amount to charge each group, regardless of usage + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun minimumCharge(): String = minimumCharge.getRequired("minimum_charge") - companion object { + /** + * The base price charged per group + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun perUnitRate(): String = perUnitRate.getRequired("per_unit_rate") - /** - * Returns a mutable builder for constructing an instance of [Tier]. - * - * The following fields are required: - * ```kotlin - * .tierLowerBound() - * .unitAmount() - * ``` - */ - fun builder() = Builder() - } + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey - /** A builder for [Tier]. */ - class Builder internal constructor() { + /** + * Returns the raw JSON value of [maximumCharge]. + * + * Unlike [maximumCharge], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("maximum_charge") + @ExcludeMissing + fun _maximumCharge(): JsonField = maximumCharge - private var tierLowerBound: JsonField? = null - private var unitAmount: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() + /** + * Returns the raw JSON value of [minimumCharge]. + * + * Unlike [minimumCharge], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("minimum_charge") + @ExcludeMissing + fun _minimumCharge(): JsonField = minimumCharge - internal fun from(tier: Tier) = apply { - tierLowerBound = tier.tierLowerBound - unitAmount = tier.unitAmount - additionalProperties = tier.additionalProperties.toMutableMap() - } + /** + * Returns the raw JSON value of [perUnitRate]. + * + * Unlike [perUnitRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("per_unit_rate") + @ExcludeMissing + fun _perUnitRate(): JsonField = perUnitRate + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [GroupedWithMinMaxThresholdsConfig]. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .maximumCharge() + * .minimumCharge() + * .perUnitRate() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [GroupedWithMinMaxThresholdsConfig]. */ + class Builder internal constructor() { + + private var groupingKey: JsonField? = null + private var maximumCharge: JsonField? = null + private var minimumCharge: JsonField? = null + private var perUnitRate: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from( + groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + ) = apply { + groupingKey = groupedWithMinMaxThresholdsConfig.groupingKey + maximumCharge = groupedWithMinMaxThresholdsConfig.maximumCharge + minimumCharge = groupedWithMinMaxThresholdsConfig.minimumCharge + perUnitRate = groupedWithMinMaxThresholdsConfig.perUnitRate + additionalProperties = + groupedWithMinMaxThresholdsConfig.additionalProperties + .toMutableMap() + } - /** Inclusive tier starting value */ - fun tierLowerBound(tierLowerBound: String) = - tierLowerBound(JsonField.of(tierLowerBound)) + /** The event property used to group before applying thresholds */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) - /** - * Sets [Builder.tierLowerBound] to an arbitrary JSON value. - * - * You should usually call [Builder.tierLowerBound] with a well-typed - * [String] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun tierLowerBound(tierLowerBound: JsonField) = apply { - this.tierLowerBound = tierLowerBound - } + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } - /** Amount per unit */ - fun unitAmount(unitAmount: String) = - unitAmount(JsonField.of(unitAmount)) + /** The maximum amount to charge each group */ + fun maximumCharge(maximumCharge: String) = + maximumCharge(JsonField.of(maximumCharge)) - /** - * Sets [Builder.unitAmount] to an arbitrary JSON value. - * - * You should usually call [Builder.unitAmount] with a well-typed - * [String] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun unitAmount(unitAmount: JsonField) = apply { - this.unitAmount = unitAmount - } + /** + * Sets [Builder.maximumCharge] to an arbitrary JSON value. + * + * You should usually call [Builder.maximumCharge] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun maximumCharge(maximumCharge: JsonField) = apply { + this.maximumCharge = maximumCharge + } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** The minimum amount to charge each group, regardless of usage */ + fun minimumCharge(minimumCharge: String) = + minimumCharge(JsonField.of(minimumCharge)) - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * Sets [Builder.minimumCharge] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumCharge] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun minimumCharge(minimumCharge: JsonField) = apply { + this.minimumCharge = minimumCharge + } - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + /** The base price charged per group */ + fun perUnitRate(perUnitRate: String) = + perUnitRate(JsonField.of(perUnitRate)) - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + /** + * Sets [Builder.perUnitRate] to an arbitrary JSON value. + * + * You should usually call [Builder.perUnitRate] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun perUnitRate(perUnitRate: JsonField) = apply { + this.perUnitRate = perUnitRate + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) } - /** - * Returns an immutable instance of [Tier]. - * - * Further updates to this [Builder] will not mutate the returned - * instance. - * - * The following fields are required: - * ```kotlin - * .tierLowerBound() - * .unitAmount() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Tier = - Tier( - checkRequired("tierLowerBound", tierLowerBound), - checkRequired("unitAmount", unitAmount), - additionalProperties.toMutableMap(), - ) + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) } - private var validated: Boolean = false - - fun validate(): Tier = apply { - if (validated) { - return@apply - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - tierLowerBound() - unitAmount() - validated = true + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } /** - * Returns a score indicating how many valid values are contained in this - * object recursively. + * Returns an immutable instance of [GroupedWithMinMaxThresholdsConfig]. * - * Used for best match union deserialization. + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .maximumCharge() + * .minimumCharge() + * .perUnitRate() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ - internal fun validity(): Int = - (if (tierLowerBound.asKnown() == null) 0 else 1) + - (if (unitAmount.asKnown() == null) 0 else 1) + fun build(): GroupedWithMinMaxThresholdsConfig = + GroupedWithMinMaxThresholdsConfig( + checkRequired("groupingKey", groupingKey), + checkRequired("maximumCharge", maximumCharge), + checkRequired("minimumCharge", minimumCharge), + checkRequired("perUnitRate", perUnitRate), + additionalProperties.toMutableMap(), + ) + } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + private var validated: Boolean = false - return other is Tier && - tierLowerBound == other.tierLowerBound && - unitAmount == other.unitAmount && - additionalProperties == other.additionalProperties + fun validate(): GroupedWithMinMaxThresholdsConfig = apply { + if (validated) { + return@apply } - private val hashCode: Int by lazy { - Objects.hash(tierLowerBound, unitAmount, additionalProperties) - } + groupingKey() + maximumCharge() + minimumCharge() + perUnitRate() + validated = true + } - override fun hashCode(): Int = hashCode + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - override fun toString() = - "Tier{tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" - } + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (groupingKey.asKnown() == null) 0 else 1) + + (if (maximumCharge.asKnown() == null) 0 else 1) + + (if (minimumCharge.asKnown() == null) 0 else 1) + + (if (perUnitRate.asKnown() == null) 0 else 1) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is TieredWithProrationConfig && - tiers == other.tiers && + return other is GroupedWithMinMaxThresholdsConfig && + groupingKey == other.groupingKey && + maximumCharge == other.maximumCharge && + minimumCharge == other.minimumCharge && + perUnitRate == other.perUnitRate && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(tiers, additionalProperties) } + private val hashCode: Int by lazy { + Objects.hash( + groupingKey, + maximumCharge, + minimumCharge, + perUnitRate, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode override fun toString() = - "TieredWithProrationConfig{tiers=$tiers, additionalProperties=$additionalProperties}" + "GroupedWithMinMaxThresholdsConfig{groupingKey=$groupingKey, maximumCharge=$maximumCharge, minimumCharge=$minimumCharge, perUnitRate=$perUnitRate, additionalProperties=$additionalProperties}" } /** @@ -13771,12 +17098,13 @@ private constructor( return true } - return other is TieredWithProration && + return other is GroupedWithMinMaxThresholds && cadence == other.cadence && + groupedWithMinMaxThresholdsConfig == + other.groupedWithMinMaxThresholdsConfig && itemId == other.itemId && modelType == other.modelType && name == other.name && - tieredWithProrationConfig == other.tieredWithProrationConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && @@ -13796,10 +17124,10 @@ private constructor( private val hashCode: Int by lazy { Objects.hash( cadence, + groupedWithMinMaxThresholdsConfig, itemId, modelType, name, - tieredWithProrationConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -13820,15 +17148,14 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "TieredWithProration{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredWithProrationConfig=$tieredWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "GroupedWithMinMaxThresholds{cadence=$cadence, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class GroupedWithMinMaxThresholds + class EventOutput @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, - private val groupedWithMinMaxThresholdsConfig: - JsonField, + private val eventOutputConfig: JsonField, private val itemId: JsonField, private val modelType: JsonValue, private val name: JsonField, @@ -13853,12 +17180,10 @@ private constructor( private constructor( @JsonProperty("cadence") @ExcludeMissing - cadence: JsonField = JsonMissing.of(), - @JsonProperty("grouped_with_min_max_thresholds_config") - @ExcludeMissing - groupedWithMinMaxThresholdsConfig: - JsonField = - JsonMissing.of(), + cadence: JsonField = JsonMissing.of(), + @JsonProperty("event_output_config") + @ExcludeMissing + eventOutputConfig: JsonField = JsonMissing.of(), @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), @@ -13912,7 +17237,7 @@ private constructor( referenceId: JsonField = JsonMissing.of(), ) : this( cadence, - groupedWithMinMaxThresholdsConfig, + eventOutputConfig, itemId, modelType, name, @@ -13942,16 +17267,14 @@ private constructor( fun cadence(): Cadence = cadence.getRequired("cadence") /** - * Configuration for grouped_with_min_max_thresholds pricing + * Configuration for event_output pricing * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected * value). */ - fun groupedWithMinMaxThresholdsConfig(): GroupedWithMinMaxThresholdsConfig = - groupedWithMinMaxThresholdsConfig.getRequired( - "grouped_with_min_max_thresholds_config" - ) + fun eventOutputConfig(): EventOutputConfig = + eventOutputConfig.getRequired("event_output_config") /** * The id of the item the price will be associated with. @@ -13967,7 +17290,7 @@ private constructor( * * Expected to always return the following: * ```kotlin - * JsonValue.from("grouped_with_min_max_thresholds") + * JsonValue.from("event_output") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -14114,15 +17437,14 @@ private constructor( fun _cadence(): JsonField = cadence /** - * Returns the raw JSON value of [groupedWithMinMaxThresholdsConfig]. + * Returns the raw JSON value of [eventOutputConfig]. * - * Unlike [groupedWithMinMaxThresholdsConfig], this method doesn't throw if the JSON - * field has an unexpected type. + * Unlike [eventOutputConfig], this method doesn't throw if the JSON field has an + * unexpected type. */ - @JsonProperty("grouped_with_min_max_thresholds_config") + @JsonProperty("event_output_config") @ExcludeMissing - fun _groupedWithMinMaxThresholdsConfig(): - JsonField = groupedWithMinMaxThresholdsConfig + fun _eventOutputConfig(): JsonField = eventOutputConfig /** * Returns the raw JSON value of [itemId]. @@ -14288,13 +17610,12 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [GroupedWithMinMaxThresholds]. + * Returns a mutable builder for constructing an instance of [EventOutput]. * * The following fields are required: * ```kotlin * .cadence() - * .groupedWithMinMaxThresholdsConfig() + * .eventOutputConfig() * .itemId() * .name() * ``` @@ -14302,16 +17623,13 @@ private constructor( fun builder() = Builder() } - /** A builder for [GroupedWithMinMaxThresholds]. */ + /** A builder for [EventOutput]. */ class Builder internal constructor() { private var cadence: JsonField? = null - private var groupedWithMinMaxThresholdsConfig: - JsonField? = - null + private var eventOutputConfig: JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonValue = - JsonValue.from("grouped_with_min_max_thresholds") + private var modelType: JsonValue = JsonValue.from("event_output") private var name: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() @@ -14334,33 +17652,27 @@ private constructor( private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds) = - apply { - cadence = groupedWithMinMaxThresholds.cadence - groupedWithMinMaxThresholdsConfig = - groupedWithMinMaxThresholds.groupedWithMinMaxThresholdsConfig - itemId = groupedWithMinMaxThresholds.itemId - modelType = groupedWithMinMaxThresholds.modelType - name = groupedWithMinMaxThresholds.name - billableMetricId = groupedWithMinMaxThresholds.billableMetricId - billedInAdvance = groupedWithMinMaxThresholds.billedInAdvance - billingCycleConfiguration = - groupedWithMinMaxThresholds.billingCycleConfiguration - conversionRate = groupedWithMinMaxThresholds.conversionRate - conversionRateConfig = groupedWithMinMaxThresholds.conversionRateConfig - currency = groupedWithMinMaxThresholds.currency - dimensionalPriceConfiguration = - groupedWithMinMaxThresholds.dimensionalPriceConfiguration - externalPriceId = groupedWithMinMaxThresholds.externalPriceId - fixedPriceQuantity = groupedWithMinMaxThresholds.fixedPriceQuantity - invoiceGroupingKey = groupedWithMinMaxThresholds.invoiceGroupingKey - invoicingCycleConfiguration = - groupedWithMinMaxThresholds.invoicingCycleConfiguration - metadata = groupedWithMinMaxThresholds.metadata - referenceId = groupedWithMinMaxThresholds.referenceId - additionalProperties = - groupedWithMinMaxThresholds.additionalProperties.toMutableMap() - } + internal fun from(eventOutput: EventOutput) = apply { + cadence = eventOutput.cadence + eventOutputConfig = eventOutput.eventOutputConfig + itemId = eventOutput.itemId + modelType = eventOutput.modelType + name = eventOutput.name + billableMetricId = eventOutput.billableMetricId + billedInAdvance = eventOutput.billedInAdvance + billingCycleConfiguration = eventOutput.billingCycleConfiguration + conversionRate = eventOutput.conversionRate + conversionRateConfig = eventOutput.conversionRateConfig + currency = eventOutput.currency + dimensionalPriceConfiguration = eventOutput.dimensionalPriceConfiguration + externalPriceId = eventOutput.externalPriceId + fixedPriceQuantity = eventOutput.fixedPriceQuantity + invoiceGroupingKey = eventOutput.invoiceGroupingKey + invoicingCycleConfiguration = eventOutput.invoicingCycleConfiguration + metadata = eventOutput.metadata + referenceId = eventOutput.referenceId + additionalProperties = eventOutput.additionalProperties.toMutableMap() + } /** The cadence to bill for this price on. */ fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) @@ -14374,27 +17686,19 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - /** Configuration for grouped_with_min_max_thresholds pricing */ - fun groupedWithMinMaxThresholdsConfig( - groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig - ) = - groupedWithMinMaxThresholdsConfig( - JsonField.of(groupedWithMinMaxThresholdsConfig) - ) + /** Configuration for event_output pricing */ + fun eventOutputConfig(eventOutputConfig: EventOutputConfig) = + eventOutputConfig(JsonField.of(eventOutputConfig)) /** - * Sets [Builder.groupedWithMinMaxThresholdsConfig] to an arbitrary JSON value. + * Sets [Builder.eventOutputConfig] to an arbitrary JSON value. * - * You should usually call [Builder.groupedWithMinMaxThresholdsConfig] with a - * well-typed [GroupedWithMinMaxThresholdsConfig] value instead. This method is - * primarily for setting the field to an undocumented or not yet supported - * value. + * You should usually call [Builder.eventOutputConfig] with a well-typed + * [EventOutputConfig] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. */ - fun groupedWithMinMaxThresholdsConfig( - groupedWithMinMaxThresholdsConfig: - JsonField - ) = apply { - this.groupedWithMinMaxThresholdsConfig = groupedWithMinMaxThresholdsConfig + fun eventOutputConfig(eventOutputConfig: JsonField) = apply { + this.eventOutputConfig = eventOutputConfig } /** The id of the item the price will be associated with. */ @@ -14415,7 +17719,7 @@ private constructor( * It is usually unnecessary to call this method because the field defaults to * the following: * ```kotlin - * JsonValue.from("grouped_with_min_max_thresholds") + * JsonValue.from("event_output") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -14764,27 +18068,24 @@ private constructor( } /** - * Returns an immutable instance of [GroupedWithMinMaxThresholds]. + * Returns an immutable instance of [EventOutput]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```kotlin * .cadence() - * .groupedWithMinMaxThresholdsConfig() + * .eventOutputConfig() * .itemId() * .name() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): GroupedWithMinMaxThresholds = - GroupedWithMinMaxThresholds( + fun build(): EventOutput = + EventOutput( checkRequired("cadence", cadence), - checkRequired( - "groupedWithMinMaxThresholdsConfig", - groupedWithMinMaxThresholdsConfig, - ), + checkRequired("eventOutputConfig", eventOutputConfig), checkRequired("itemId", itemId), modelType, checkRequired("name", name), @@ -14807,16 +18108,16 @@ private constructor( private var validated: Boolean = false - fun validate(): GroupedWithMinMaxThresholds = apply { + fun validate(): EventOutput = apply { if (validated) { return@apply } cadence().validate() - groupedWithMinMaxThresholdsConfig().validate() + eventOutputConfig().validate() itemId() _modelType().let { - if (it != JsonValue.from("grouped_with_min_max_thresholds")) { + if (it != JsonValue.from("event_output")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } @@ -14853,11 +18154,9 @@ private constructor( */ internal fun validity(): Int = (cadence.asKnown()?.validity() ?: 0) + - (groupedWithMinMaxThresholdsConfig.asKnown()?.validity() ?: 0) + + (eventOutputConfig.asKnown()?.validity() ?: 0) + (if (itemId.asKnown() == null) 0 else 1) + - modelType.let { - if (it == JsonValue.from("grouped_with_min_max_thresholds")) 1 else 0 - } + + modelType.let { if (it == JsonValue.from("event_output")) 1 else 0 } + (if (name.asKnown() == null) 0 else 1) + (if (billableMetricId.asKnown() == null) 0 else 1) + (if (billedInAdvance.asKnown() == null) 0 else 1) + @@ -15030,68 +18329,52 @@ private constructor( override fun toString() = value.toString() } - /** Configuration for grouped_with_min_max_thresholds pricing */ - class GroupedWithMinMaxThresholdsConfig + /** Configuration for event_output pricing */ + class EventOutputConfig @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( + private val unitRatingKey: JsonField, private val groupingKey: JsonField, - private val maximumCharge: JsonField, - private val minimumCharge: JsonField, - private val perUnitRate: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( + @JsonProperty("unit_rating_key") + @ExcludeMissing + unitRatingKey: JsonField = JsonMissing.of(), @JsonProperty("grouping_key") @ExcludeMissing groupingKey: JsonField = JsonMissing.of(), - @JsonProperty("maximum_charge") - @ExcludeMissing - maximumCharge: JsonField = JsonMissing.of(), - @JsonProperty("minimum_charge") - @ExcludeMissing - minimumCharge: JsonField = JsonMissing.of(), - @JsonProperty("per_unit_rate") - @ExcludeMissing - perUnitRate: JsonField = JsonMissing.of(), - ) : this(groupingKey, maximumCharge, minimumCharge, perUnitRate, mutableMapOf()) - - /** - * The event property used to group before applying thresholds - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun groupingKey(): String = groupingKey.getRequired("grouping_key") + ) : this(unitRatingKey, groupingKey, mutableMapOf()) /** - * The maximum amount to charge each group + * The key in the event data to extract the unit rate from. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). */ - fun maximumCharge(): String = maximumCharge.getRequired("maximum_charge") + fun unitRatingKey(): String = unitRatingKey.getRequired("unit_rating_key") /** - * The minimum amount to charge each group, regardless of usage + * An optional key in the event data to group by (e.g., event ID). All events + * will also be grouped by their unit rate. * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). */ - fun minimumCharge(): String = minimumCharge.getRequired("minimum_charge") + fun groupingKey(): String? = groupingKey.getNullable("grouping_key") /** - * The base price charged per group + * Returns the raw JSON value of [unitRatingKey]. * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). + * Unlike [unitRatingKey], this method doesn't throw if the JSON field has an + * unexpected type. */ - fun perUnitRate(): String = perUnitRate.getRequired("per_unit_rate") + @JsonProperty("unit_rating_key") + @ExcludeMissing + fun _unitRatingKey(): JsonField = unitRatingKey /** * Returns the raw JSON value of [groupingKey]. @@ -15103,36 +18386,6 @@ private constructor( @ExcludeMissing fun _groupingKey(): JsonField = groupingKey - /** - * Returns the raw JSON value of [maximumCharge]. - * - * Unlike [maximumCharge], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("maximum_charge") - @ExcludeMissing - fun _maximumCharge(): JsonField = maximumCharge - - /** - * Returns the raw JSON value of [minimumCharge]. - * - * Unlike [minimumCharge], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("minimum_charge") - @ExcludeMissing - fun _minimumCharge(): JsonField = minimumCharge - - /** - * Returns the raw JSON value of [perUnitRate]. - * - * Unlike [perUnitRate], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("per_unit_rate") - @ExcludeMissing - fun _perUnitRate(): JsonField = perUnitRate - @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -15149,99 +18402,62 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [GroupedWithMinMaxThresholdsConfig]. + * [EventOutputConfig]. * * The following fields are required: * ```kotlin - * .groupingKey() - * .maximumCharge() - * .minimumCharge() - * .perUnitRate() + * .unitRatingKey() * ``` */ fun builder() = Builder() } - /** A builder for [GroupedWithMinMaxThresholdsConfig]. */ + /** A builder for [EventOutputConfig]. */ class Builder internal constructor() { - private var groupingKey: JsonField? = null - private var maximumCharge: JsonField? = null - private var minimumCharge: JsonField? = null - private var perUnitRate: JsonField? = null + private var unitRatingKey: JsonField? = null + private var groupingKey: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() - internal fun from( - groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig - ) = apply { - groupingKey = groupedWithMinMaxThresholdsConfig.groupingKey - maximumCharge = groupedWithMinMaxThresholdsConfig.maximumCharge - minimumCharge = groupedWithMinMaxThresholdsConfig.minimumCharge - perUnitRate = groupedWithMinMaxThresholdsConfig.perUnitRate + internal fun from(eventOutputConfig: EventOutputConfig) = apply { + unitRatingKey = eventOutputConfig.unitRatingKey + groupingKey = eventOutputConfig.groupingKey additionalProperties = - groupedWithMinMaxThresholdsConfig.additionalProperties - .toMutableMap() - } - - /** The event property used to group before applying thresholds */ - fun groupingKey(groupingKey: String) = - groupingKey(JsonField.of(groupingKey)) - - /** - * Sets [Builder.groupingKey] to an arbitrary JSON value. - * - * You should usually call [Builder.groupingKey] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun groupingKey(groupingKey: JsonField) = apply { - this.groupingKey = groupingKey + eventOutputConfig.additionalProperties.toMutableMap() } - /** The maximum amount to charge each group */ - fun maximumCharge(maximumCharge: String) = - maximumCharge(JsonField.of(maximumCharge)) + /** The key in the event data to extract the unit rate from. */ + fun unitRatingKey(unitRatingKey: String) = + unitRatingKey(JsonField.of(unitRatingKey)) /** - * Sets [Builder.maximumCharge] to an arbitrary JSON value. + * Sets [Builder.unitRatingKey] to an arbitrary JSON value. * - * You should usually call [Builder.maximumCharge] with a well-typed + * You should usually call [Builder.unitRatingKey] with a well-typed * [String] value instead. This method is primarily for setting the field to * an undocumented or not yet supported value. */ - fun maximumCharge(maximumCharge: JsonField) = apply { - this.maximumCharge = maximumCharge + fun unitRatingKey(unitRatingKey: JsonField) = apply { + this.unitRatingKey = unitRatingKey } - /** The minimum amount to charge each group, regardless of usage */ - fun minimumCharge(minimumCharge: String) = - minimumCharge(JsonField.of(minimumCharge)) - /** - * Sets [Builder.minimumCharge] to an arbitrary JSON value. - * - * You should usually call [Builder.minimumCharge] with a well-typed - * [String] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. + * An optional key in the event data to group by (e.g., event ID). All + * events will also be grouped by their unit rate. */ - fun minimumCharge(minimumCharge: JsonField) = apply { - this.minimumCharge = minimumCharge - } - - /** The base price charged per group */ - fun perUnitRate(perUnitRate: String) = - perUnitRate(JsonField.of(perUnitRate)) + fun groupingKey(groupingKey: String?) = + groupingKey(JsonField.ofNullable(groupingKey)) /** - * Sets [Builder.perUnitRate] to an arbitrary JSON value. + * Sets [Builder.groupingKey] to an arbitrary JSON value. * - * You should usually call [Builder.perUnitRate] with a well-typed [String] + * You should usually call [Builder.groupingKey] with a well-typed [String] * value instead. This method is primarily for setting the field to an * undocumented or not yet supported value. */ - fun perUnitRate(perUnitRate: JsonField) = apply { - this.perUnitRate = perUnitRate + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey } fun additionalProperties(additionalProperties: Map) = @@ -15267,41 +18483,34 @@ private constructor( } /** - * Returns an immutable instance of [GroupedWithMinMaxThresholdsConfig]. + * Returns an immutable instance of [EventOutputConfig]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```kotlin - * .groupingKey() - * .maximumCharge() - * .minimumCharge() - * .perUnitRate() + * .unitRatingKey() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): GroupedWithMinMaxThresholdsConfig = - GroupedWithMinMaxThresholdsConfig( - checkRequired("groupingKey", groupingKey), - checkRequired("maximumCharge", maximumCharge), - checkRequired("minimumCharge", minimumCharge), - checkRequired("perUnitRate", perUnitRate), + fun build(): EventOutputConfig = + EventOutputConfig( + checkRequired("unitRatingKey", unitRatingKey), + groupingKey, additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): GroupedWithMinMaxThresholdsConfig = apply { + fun validate(): EventOutputConfig = apply { if (validated) { return@apply } + unitRatingKey() groupingKey() - maximumCharge() - minimumCharge() - perUnitRate() validated = true } @@ -15320,38 +18529,28 @@ private constructor( * Used for best match union deserialization. */ internal fun validity(): Int = - (if (groupingKey.asKnown() == null) 0 else 1) + - (if (maximumCharge.asKnown() == null) 0 else 1) + - (if (minimumCharge.asKnown() == null) 0 else 1) + - (if (perUnitRate.asKnown() == null) 0 else 1) + (if (unitRatingKey.asKnown() == null) 0 else 1) + + (if (groupingKey.asKnown() == null) 0 else 1) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is GroupedWithMinMaxThresholdsConfig && + return other is EventOutputConfig && + unitRatingKey == other.unitRatingKey && groupingKey == other.groupingKey && - maximumCharge == other.maximumCharge && - minimumCharge == other.minimumCharge && - perUnitRate == other.perUnitRate && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash( - groupingKey, - maximumCharge, - minimumCharge, - perUnitRate, - additionalProperties, - ) + Objects.hash(unitRatingKey, groupingKey, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "GroupedWithMinMaxThresholdsConfig{groupingKey=$groupingKey, maximumCharge=$maximumCharge, minimumCharge=$minimumCharge, perUnitRate=$perUnitRate, additionalProperties=$additionalProperties}" + "EventOutputConfig{unitRatingKey=$unitRatingKey, groupingKey=$groupingKey, additionalProperties=$additionalProperties}" } /** @@ -15468,10 +18667,9 @@ private constructor( return true } - return other is GroupedWithMinMaxThresholds && + return other is EventOutput && cadence == other.cadence && - groupedWithMinMaxThresholdsConfig == - other.groupedWithMinMaxThresholdsConfig && + eventOutputConfig == other.eventOutputConfig && itemId == other.itemId && modelType == other.modelType && name == other.name && @@ -15494,7 +18692,7 @@ private constructor( private val hashCode: Int by lazy { Objects.hash( cadence, - groupedWithMinMaxThresholdsConfig, + eventOutputConfig, itemId, modelType, name, @@ -15518,7 +18716,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "GroupedWithMinMaxThresholds{cadence=$cadence, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "EventOutput{cadence=$cadence, eventOutputConfig=$eventOutputConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } } diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/BillableMetricTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/BillableMetricTest.kt index c6327f899..887177dbb 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/BillableMetricTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/BillableMetricTest.kt @@ -35,6 +35,7 @@ internal class BillableMetricTest { .build() ) .name("name") + .archivedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() ) .metadata( @@ -67,6 +68,7 @@ internal class BillableMetricTest { .build() ) .name("name") + .archivedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() ) assertThat(billableMetric.metadata()) @@ -104,6 +106,7 @@ internal class BillableMetricTest { .build() ) .name("name") + .archivedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() ) .metadata( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/ItemListPageResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/ItemListPageResponseTest.kt index 9304e36be..38156b7d5 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/ItemListPageResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/ItemListPageResponseTest.kt @@ -33,6 +33,7 @@ internal class ItemListPageResponseTest { .build() ) .name("name") + .archivedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() ) .paginationMetadata( @@ -59,6 +60,7 @@ internal class ItemListPageResponseTest { .build() ) .name("name") + .archivedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() ) assertThat(itemListPageResponse.paginationMetadata()) @@ -88,6 +90,7 @@ internal class ItemListPageResponseTest { .build() ) .name("name") + .archivedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() ) .paginationMetadata( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/ItemTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/ItemTest.kt index 7d2118f26..fe546ed3e 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/ItemTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/ItemTest.kt @@ -31,6 +31,7 @@ internal class ItemTest { .build() ) .name("name") + .archivedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() assertThat(item.id()).isEqualTo("id") @@ -49,6 +50,7 @@ internal class ItemTest { .build() ) assertThat(item.name()).isEqualTo("name") + assertThat(item.archivedAt()).isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) } @Test @@ -72,6 +74,7 @@ internal class ItemTest { .build() ) .name("name") + .archivedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() val roundtrippedItem = diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/MetricListPageResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/MetricListPageResponseTest.kt index f2eaba159..4f47b1738 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/MetricListPageResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/MetricListPageResponseTest.kt @@ -37,6 +37,7 @@ internal class MetricListPageResponseTest { .build() ) .name("name") + .archivedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() ) .metadata( @@ -76,6 +77,7 @@ internal class MetricListPageResponseTest { .build() ) .name("name") + .archivedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() ) .metadata( @@ -118,6 +120,7 @@ internal class MetricListPageResponseTest { .build() ) .name("name") + .archivedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() ) .metadata( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceTest.kt index 078dec1f3..0f92bec16 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceTest.kt @@ -154,6 +154,7 @@ internal class PriceTest { assertThat(price.scalableMatrixWithTieredPricing()).isNull() assertThat(price.cumulativeGroupedBulk()).isNull() assertThat(price.minimum()).isNull() + assertThat(price.eventOutput()).isNull() } @Test @@ -424,6 +425,7 @@ internal class PriceTest { assertThat(price.scalableMatrixWithTieredPricing()).isNull() assertThat(price.cumulativeGroupedBulk()).isNull() assertThat(price.minimum()).isNull() + assertThat(price.eventOutput()).isNull() } @Test @@ -700,6 +702,7 @@ internal class PriceTest { assertThat(price.scalableMatrixWithTieredPricing()).isNull() assertThat(price.cumulativeGroupedBulk()).isNull() assertThat(price.minimum()).isNull() + assertThat(price.eventOutput()).isNull() } @Test @@ -971,6 +974,7 @@ internal class PriceTest { assertThat(price.scalableMatrixWithTieredPricing()).isNull() assertThat(price.cumulativeGroupedBulk()).isNull() assertThat(price.minimum()).isNull() + assertThat(price.eventOutput()).isNull() } @Test @@ -1247,6 +1251,7 @@ internal class PriceTest { assertThat(price.scalableMatrixWithTieredPricing()).isNull() assertThat(price.cumulativeGroupedBulk()).isNull() assertThat(price.minimum()).isNull() + assertThat(price.eventOutput()).isNull() } @Test @@ -1536,6 +1541,7 @@ internal class PriceTest { assertThat(price.scalableMatrixWithTieredPricing()).isNull() assertThat(price.cumulativeGroupedBulk()).isNull() assertThat(price.minimum()).isNull() + assertThat(price.eventOutput()).isNull() } @Test @@ -1832,6 +1838,7 @@ internal class PriceTest { assertThat(price.scalableMatrixWithTieredPricing()).isNull() assertThat(price.cumulativeGroupedBulk()).isNull() assertThat(price.minimum()).isNull() + assertThat(price.eventOutput()).isNull() } @Test @@ -2127,6 +2134,7 @@ internal class PriceTest { assertThat(price.scalableMatrixWithTieredPricing()).isNull() assertThat(price.cumulativeGroupedBulk()).isNull() assertThat(price.minimum()).isNull() + assertThat(price.eventOutput()).isNull() } @Test @@ -2422,6 +2430,7 @@ internal class PriceTest { assertThat(price.scalableMatrixWithTieredPricing()).isNull() assertThat(price.cumulativeGroupedBulk()).isNull() assertThat(price.minimum()).isNull() + assertThat(price.eventOutput()).isNull() } @Test @@ -2718,6 +2727,7 @@ internal class PriceTest { assertThat(price.scalableMatrixWithTieredPricing()).isNull() assertThat(price.cumulativeGroupedBulk()).isNull() assertThat(price.minimum()).isNull() + assertThat(price.eventOutput()).isNull() } @Test @@ -3004,6 +3014,7 @@ internal class PriceTest { assertThat(price.scalableMatrixWithTieredPricing()).isNull() assertThat(price.cumulativeGroupedBulk()).isNull() assertThat(price.minimum()).isNull() + assertThat(price.eventOutput()).isNull() } @Test @@ -3275,6 +3286,7 @@ internal class PriceTest { assertThat(price.scalableMatrixWithTieredPricing()).isNull() assertThat(price.cumulativeGroupedBulk()).isNull() assertThat(price.minimum()).isNull() + assertThat(price.eventOutput()).isNull() } @Test @@ -3552,6 +3564,7 @@ internal class PriceTest { assertThat(price.scalableMatrixWithTieredPricing()).isNull() assertThat(price.cumulativeGroupedBulk()).isNull() assertThat(price.minimum()).isNull() + assertThat(price.eventOutput()).isNull() } @Test @@ -3833,6 +3846,7 @@ internal class PriceTest { assertThat(price.scalableMatrixWithTieredPricing()).isNull() assertThat(price.cumulativeGroupedBulk()).isNull() assertThat(price.minimum()).isNull() + assertThat(price.eventOutput()).isNull() } @Test @@ -4106,6 +4120,7 @@ internal class PriceTest { assertThat(price.scalableMatrixWithTieredPricing()).isNull() assertThat(price.cumulativeGroupedBulk()).isNull() assertThat(price.minimum()).isNull() + assertThat(price.eventOutput()).isNull() } @Test @@ -4376,6 +4391,7 @@ internal class PriceTest { assertThat(price.scalableMatrixWithTieredPricing()).isNull() assertThat(price.cumulativeGroupedBulk()).isNull() assertThat(price.minimum()).isNull() + assertThat(price.eventOutput()).isNull() } @Test @@ -4657,6 +4673,7 @@ internal class PriceTest { assertThat(price.scalableMatrixWithTieredPricing()).isNull() assertThat(price.cumulativeGroupedBulk()).isNull() assertThat(price.minimum()).isNull() + assertThat(price.eventOutput()).isNull() } @Test @@ -4938,6 +4955,7 @@ internal class PriceTest { assertThat(price.scalableMatrixWithTieredPricing()).isNull() assertThat(price.cumulativeGroupedBulk()).isNull() assertThat(price.minimum()).isNull() + assertThat(price.eventOutput()).isNull() } @Test @@ -5227,6 +5245,7 @@ internal class PriceTest { assertThat(price.scalableMatrixWithTieredPricing()).isNull() assertThat(price.cumulativeGroupedBulk()).isNull() assertThat(price.minimum()).isNull() + assertThat(price.eventOutput()).isNull() } @Test @@ -5517,6 +5536,7 @@ internal class PriceTest { assertThat(price.scalableMatrixWithTieredPricing()).isNull() assertThat(price.cumulativeGroupedBulk()).isNull() assertThat(price.minimum()).isNull() + assertThat(price.eventOutput()).isNull() } @Test @@ -5797,6 +5817,7 @@ internal class PriceTest { assertThat(price.scalableMatrixWithTieredPricing()).isNull() assertThat(price.cumulativeGroupedBulk()).isNull() assertThat(price.minimum()).isNull() + assertThat(price.eventOutput()).isNull() } @Test @@ -6086,6 +6107,7 @@ internal class PriceTest { assertThat(price.scalableMatrixWithTieredPricing()).isNull() assertThat(price.cumulativeGroupedBulk()).isNull() assertThat(price.minimum()).isNull() + assertThat(price.eventOutput()).isNull() } @Test @@ -6380,6 +6402,7 @@ internal class PriceTest { assertThat(price.scalableMatrixWithTieredPricing()).isNull() assertThat(price.cumulativeGroupedBulk()).isNull() assertThat(price.minimum()).isNull() + assertThat(price.eventOutput()).isNull() } @Test @@ -6676,6 +6699,7 @@ internal class PriceTest { assertThat(price.scalableMatrixWithTieredPricing()).isNull() assertThat(price.cumulativeGroupedBulk()).isNull() assertThat(price.minimum()).isNull() + assertThat(price.eventOutput()).isNull() } @Test @@ -6989,6 +7013,7 @@ internal class PriceTest { .isEqualTo(scalableMatrixWithTieredPricing) assertThat(price.cumulativeGroupedBulk()).isNull() assertThat(price.minimum()).isNull() + assertThat(price.eventOutput()).isNull() } @Test @@ -7295,6 +7320,7 @@ internal class PriceTest { assertThat(price.scalableMatrixWithTieredPricing()).isNull() assertThat(price.cumulativeGroupedBulk()).isEqualTo(cumulativeGroupedBulk) assertThat(price.minimum()).isNull() + assertThat(price.eventOutput()).isNull() } @Test @@ -7573,6 +7599,7 @@ internal class PriceTest { assertThat(price.scalableMatrixWithTieredPricing()).isNull() assertThat(price.cumulativeGroupedBulk()).isNull() assertThat(price.minimum()).isEqualTo(minimum) + assertThat(price.eventOutput()).isNull() } @Test @@ -7699,6 +7726,277 @@ internal class PriceTest { assertThat(roundtrippedPrice).isEqualTo(price) } + @Test + fun ofEventOutput() { + val eventOutput = + Price.EventOutput.builder() + .id("id") + .billableMetric(BillableMetricTiny.builder().id("id").build()) + .billingCycleConfiguration( + BillingCycleConfiguration.builder() + .duration(0L) + .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) + .build() + ) + .billingMode(Price.EventOutput.BillingMode.IN_ADVANCE) + .cadence(Price.EventOutput.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) + .conversionRate(0.0) + .unitConversionRateConfig( + ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() + ) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditAllocation( + Allocation.builder() + .allowsRollover(true) + .currency("currency") + .customExpiration( + CustomExpiration.builder() + .duration(0L) + .durationUnit(CustomExpiration.DurationUnit.DAY) + .build() + ) + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .addFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) + .reason("reason") + .build() + ) + .eventOutputConfig( + Price.EventOutput.EventOutputConfig.builder() + .unitRatingKey("x") + .groupingKey("grouping_key") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + BillingCycleConfiguration.builder() + .duration(0L) + .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) + .build() + ) + .item(ItemSlim.builder().id("id").name("name").build()) + .maximum( + Maximum.builder() + .addAppliesToPriceId("string") + .addFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.EventOutput.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Minimum.builder() + .addAppliesToPriceId("string") + .addFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("name") + .planPhaseOrder(0L) + .priceType(Price.EventOutput.PriceType.USAGE_PRICE) + .replacesPriceId("replaces_price_id") + .dimensionalPriceConfiguration( + DimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .build() + ) + .build() + + val price = Price.ofEventOutput(eventOutput) + + assertThat(price.unit()).isNull() + assertThat(price.tiered()).isNull() + assertThat(price.bulk()).isNull() + assertThat(price.package_()).isNull() + assertThat(price.matrix()).isNull() + assertThat(price.thresholdTotalAmount()).isNull() + assertThat(price.tieredPackage()).isNull() + assertThat(price.tieredWithMinimum()).isNull() + assertThat(price.groupedTiered()).isNull() + assertThat(price.tieredPackageWithMinimum()).isNull() + assertThat(price.packageWithAllocation()).isNull() + assertThat(price.unitWithPercent()).isNull() + assertThat(price.matrixWithAllocation()).isNull() + assertThat(price.tieredWithProration()).isNull() + assertThat(price.unitWithProration()).isNull() + assertThat(price.groupedAllocation()).isNull() + assertThat(price.bulkWithProration()).isNull() + assertThat(price.groupedWithProratedMinimum()).isNull() + assertThat(price.groupedWithMeteredMinimum()).isNull() + assertThat(price.groupedWithMinMaxThresholds()).isNull() + assertThat(price.matrixWithDisplayName()).isNull() + assertThat(price.groupedTieredPackage()).isNull() + assertThat(price.maxGroupTieredPackage()).isNull() + assertThat(price.scalableMatrixWithUnitPricing()).isNull() + assertThat(price.scalableMatrixWithTieredPricing()).isNull() + assertThat(price.cumulativeGroupedBulk()).isNull() + assertThat(price.minimum()).isNull() + assertThat(price.eventOutput()).isEqualTo(eventOutput) + } + + @Test + fun ofEventOutputRoundtrip() { + val jsonMapper = jsonMapper() + val price = + Price.ofEventOutput( + Price.EventOutput.builder() + .id("id") + .billableMetric(BillableMetricTiny.builder().id("id").build()) + .billingCycleConfiguration( + BillingCycleConfiguration.builder() + .duration(0L) + .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) + .build() + ) + .billingMode(Price.EventOutput.BillingMode.IN_ADVANCE) + .cadence(Price.EventOutput.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) + .conversionRate(0.0) + .unitConversionRateConfig( + ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() + ) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditAllocation( + Allocation.builder() + .allowsRollover(true) + .currency("currency") + .customExpiration( + CustomExpiration.builder() + .duration(0L) + .durationUnit(CustomExpiration.DurationUnit.DAY) + .build() + ) + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .addFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) + .reason("reason") + .build() + ) + .eventOutputConfig( + Price.EventOutput.EventOutputConfig.builder() + .unitRatingKey("x") + .groupingKey("grouping_key") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + BillingCycleConfiguration.builder() + .duration(0L) + .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) + .build() + ) + .item(ItemSlim.builder().id("id").name("name").build()) + .maximum( + Maximum.builder() + .addAppliesToPriceId("string") + .addFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.EventOutput.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Minimum.builder() + .addAppliesToPriceId("string") + .addFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("name") + .planPhaseOrder(0L) + .priceType(Price.EventOutput.PriceType.USAGE_PRICE) + .replacesPriceId("replaces_price_id") + .dimensionalPriceConfiguration( + DimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .build() + ) + .build() + ) + + val roundtrippedPrice = + jsonMapper.readValue(jsonMapper.writeValueAsString(price), jacksonTypeRef()) + + assertThat(roundtrippedPrice).isEqualTo(price) + } + enum class IncompatibleJsonShapeTestCase(val value: JsonValue) { BOOLEAN(JsonValue.from(false)), STRING(JsonValue.from("invalid")), From 4c2a026cdd5327b5d58a42f2ae81975b5a8b6821 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 7 Oct 2025 01:33:12 +0000 Subject: [PATCH 28/68] feat(api): api update --- .stats.yml | 4 +- .../api/models/BetaCreatePlanVersionParams.kt | 9012 ++++++++++----- ...taExternalPlanIdCreatePlanVersionParams.kt | 9012 ++++++++++----- .../models/ChangedSubscriptionResources.kt | 3 + .../kotlin/com/withorb/api/models/Invoice.kt | 3 + .../models/InvoiceFetchUpcomingResponse.kt | 3 + .../models/InvoiceLineItemCreateResponse.kt | 3 + .../com/withorb/api/models/PerPriceCost.kt | 3 + .../kotlin/com/withorb/api/models/Plan.kt | 3 + .../withorb/api/models/PlanCreateParams.kt | 1545 +++ .../com/withorb/api/models/PlanVersion.kt | 3 + .../kotlin/com/withorb/api/models/Price.kt | 2562 ++++- .../withorb/api/models/PriceCreateParams.kt | 1458 +++ .../api/models/PriceEvaluateMultipleParams.kt | 1495 +++ .../PriceEvaluatePreviewEventsParams.kt | 1495 +++ .../com/withorb/api/models/PriceInterval.kt | 3 + .../api/models/PriceListPageResponse.kt | 3 + .../api/models/SubscriptionCreateParams.kt | 9696 +++++++++++------ .../SubscriptionPriceIntervalsParams.kt | 1495 +++ .../SubscriptionSchedulePlanChangeParams.kt | 9648 ++++++++++------ .../com/withorb/api/models/PriceTest.kt | 290 + 21 files changed, 35058 insertions(+), 12681 deletions(-) diff --git a/.stats.yml b/.stats.yml index 4b69c08ad..3407ffd10 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 118 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-297c7ce95bc0aa1ac6f324a487515f49b8a30b74eb9d39ca9dcd2d9cf065f0ef.yml -openapi_spec_hash: 29e9af981bc78379336079bb4208c54d +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-b070c1d97a6e3b400f43d2bce36c22ed89d432345b26374728c55dd0a20f0afa.yml +openapi_spec_hash: dba4ff52c381cda6159fc56d8b77eb32 config_hash: 1f73a949b649ecfe6ec68ba1bb459dc2 diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BetaCreatePlanVersionParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BetaCreatePlanVersionParams.kt index a39a0e8ea..4937aef2a 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BetaCreatePlanVersionParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BetaCreatePlanVersionParams.kt @@ -1966,6 +1966,9 @@ private constructor( /** Alias for calling [price] with `Price.ofMinimum(minimum)`. */ fun price(minimum: NewPlanMinimumCompositePrice) = price(Price.ofMinimum(minimum)) + /** Alias for calling [price] with `Price.ofPercent(percent)`. */ + fun price(percent: Price.Percent) = price(Price.ofPercent(percent)) + /** Alias for calling [price] with `Price.ofEventOutput(eventOutput)`. */ fun price(eventOutput: Price.EventOutput) = price(Price.ofEventOutput(eventOutput)) @@ -2069,6 +2072,7 @@ private constructor( null, private val cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice? = null, private val minimum: NewPlanMinimumCompositePrice? = null, + private val percent: Percent? = null, private val eventOutput: EventOutput? = null, private val _json: JsonValue? = null, ) { @@ -2133,6 +2137,8 @@ private constructor( fun minimum(): NewPlanMinimumCompositePrice? = minimum + fun percent(): Percent? = percent + fun eventOutput(): EventOutput? = eventOutput fun isUnit(): Boolean = unit != null @@ -2190,6 +2196,8 @@ private constructor( fun isMinimum(): Boolean = minimum != null + fun isPercent(): Boolean = percent != null + fun isEventOutput(): Boolean = eventOutput != null fun asUnit(): NewPlanUnitPrice = unit.getOrThrow("unit") @@ -2267,6 +2275,8 @@ private constructor( fun asMinimum(): NewPlanMinimumCompositePrice = minimum.getOrThrow("minimum") + fun asPercent(): Percent = percent.getOrThrow("percent") + fun asEventOutput(): EventOutput = eventOutput.getOrThrow("eventOutput") fun _json(): JsonValue? = _json @@ -2316,6 +2326,7 @@ private constructor( cumulativeGroupedBulk != null -> visitor.visitCumulativeGroupedBulk(cumulativeGroupedBulk) minimum != null -> visitor.visitMinimum(minimum) + percent != null -> visitor.visitPercent(percent) eventOutput != null -> visitor.visitEventOutput(eventOutput) else -> visitor.unknown(_json) } @@ -2476,6 +2487,10 @@ private constructor( minimum.validate() } + override fun visitPercent(percent: Percent) { + percent.validate() + } + override fun visitEventOutput(eventOutput: EventOutput) { eventOutput.validate() } @@ -2598,6 +2613,8 @@ private constructor( override fun visitMinimum(minimum: NewPlanMinimumCompositePrice) = minimum.validity() + override fun visitPercent(percent: Percent) = percent.validity() + override fun visitEventOutput(eventOutput: EventOutput) = eventOutput.validity() @@ -2638,6 +2655,7 @@ private constructor( scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && cumulativeGroupedBulk == other.cumulativeGroupedBulk && minimum == other.minimum && + percent == other.percent && eventOutput == other.eventOutput } @@ -2670,6 +2688,7 @@ private constructor( scalableMatrixWithTieredPricing, cumulativeGroupedBulk, minimum, + percent, eventOutput, ) @@ -2715,6 +2734,7 @@ private constructor( cumulativeGroupedBulk != null -> "Price{cumulativeGroupedBulk=$cumulativeGroupedBulk}" minimum != null -> "Price{minimum=$minimum}" + percent != null -> "Price{percent=$percent}" eventOutput != null -> "Price{eventOutput=$eventOutput}" _json != null -> "Price{_unknown=$_json}" else -> throw IllegalStateException("Invalid Price") @@ -2807,6 +2827,8 @@ private constructor( fun ofMinimum(minimum: NewPlanMinimumCompositePrice) = Price(minimum = minimum) + fun ofPercent(percent: Percent) = Price(percent = percent) + fun ofEventOutput(eventOutput: EventOutput) = Price(eventOutput = eventOutput) } @@ -2895,6 +2917,8 @@ private constructor( fun visitMinimum(minimum: NewPlanMinimumCompositePrice): T + fun visitPercent(percent: Percent): T + fun visitEventOutput(eventOutput: EventOutput): T /** @@ -3109,6 +3133,11 @@ private constructor( ) ?.let { Price(minimum = it, _json = json) } ?: Price(_json = json) } + "percent" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(percent = it, _json = json) + } ?: Price(_json = json) + } "event_output" -> { return tryDeserialize(node, jacksonTypeRef())?.let { Price(eventOutput = it, _json = json) @@ -3174,6 +3203,7 @@ private constructor( value.cumulativeGroupedBulk != null -> generator.writeObject(value.cumulativeGroupedBulk) value.minimum != null -> generator.writeObject(value.minimum) + value.percent != null -> generator.writeObject(value.percent) value.eventOutput != null -> generator.writeObject(value.eventOutput) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid Price") @@ -6648,14 +6678,14 @@ private constructor( "GroupedWithMinMaxThresholds{cadence=$cadence, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class EventOutput + class Percent @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, - private val eventOutputConfig: JsonField, private val itemId: JsonField, private val modelType: JsonValue, private val name: JsonField, + private val percentConfig: JsonField, private val billableMetricId: JsonField, private val billedInAdvance: JsonField, private val billingCycleConfiguration: JsonField, @@ -6678,9 +6708,6 @@ private constructor( @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), - @JsonProperty("event_output_config") - @ExcludeMissing - eventOutputConfig: JsonField = JsonMissing.of(), @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), @@ -6690,6 +6717,9 @@ private constructor( @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("percent_config") + @ExcludeMissing + percentConfig: JsonField = JsonMissing.of(), @JsonProperty("billable_metric_id") @ExcludeMissing billableMetricId: JsonField = JsonMissing.of(), @@ -6734,10 +6764,10 @@ private constructor( referenceId: JsonField = JsonMissing.of(), ) : this( cadence, - eventOutputConfig, itemId, modelType, name, + percentConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -6763,16 +6793,6 @@ private constructor( */ fun cadence(): Cadence = cadence.getRequired("cadence") - /** - * Configuration for event_output pricing - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun eventOutputConfig(): EventOutputConfig = - eventOutputConfig.getRequired("event_output_config") - /** * The id of the item the price will be associated with. * @@ -6787,7 +6807,7 @@ private constructor( * * Expected to always return the following: * ```kotlin - * JsonValue.from("event_output") + * JsonValue.from("percent") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -6804,6 +6824,15 @@ private constructor( */ fun name(): String = name.getRequired("name") + /** + * Configuration for percent pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun percentConfig(): PercentConfig = percentConfig.getRequired("percent_config") + /** * The id of the billable metric for the price. Only needed if the price is * usage-based. @@ -6933,16 +6962,6 @@ private constructor( @ExcludeMissing fun _cadence(): JsonField = cadence - /** - * Returns the raw JSON value of [eventOutputConfig]. - * - * Unlike [eventOutputConfig], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("event_output_config") - @ExcludeMissing - fun _eventOutputConfig(): JsonField = eventOutputConfig - /** * Returns the raw JSON value of [itemId]. * @@ -6959,6 +6978,16 @@ private constructor( */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + /** + * Returns the raw JSON value of [percentConfig]. + * + * Unlike [percentConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("percent_config") + @ExcludeMissing + fun _percentConfig(): JsonField = percentConfig + /** * Returns the raw JSON value of [billableMetricId]. * @@ -7107,27 +7136,27 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [EventOutput]. + * Returns a mutable builder for constructing an instance of [Percent]. * * The following fields are required: * ```kotlin * .cadence() - * .eventOutputConfig() * .itemId() * .name() + * .percentConfig() * ``` */ fun builder() = Builder() } - /** A builder for [EventOutput]. */ + /** A builder for [Percent]. */ class Builder internal constructor() { private var cadence: JsonField? = null - private var eventOutputConfig: JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonValue = JsonValue.from("event_output") + private var modelType: JsonValue = JsonValue.from("percent") private var name: JsonField? = null + private var percentConfig: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() private var billingCycleConfiguration: JsonField = @@ -7149,26 +7178,26 @@ private constructor( private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(eventOutput: EventOutput) = apply { - cadence = eventOutput.cadence - eventOutputConfig = eventOutput.eventOutputConfig - itemId = eventOutput.itemId - modelType = eventOutput.modelType - name = eventOutput.name - billableMetricId = eventOutput.billableMetricId - billedInAdvance = eventOutput.billedInAdvance - billingCycleConfiguration = eventOutput.billingCycleConfiguration - conversionRate = eventOutput.conversionRate - conversionRateConfig = eventOutput.conversionRateConfig - currency = eventOutput.currency - dimensionalPriceConfiguration = eventOutput.dimensionalPriceConfiguration - externalPriceId = eventOutput.externalPriceId - fixedPriceQuantity = eventOutput.fixedPriceQuantity - invoiceGroupingKey = eventOutput.invoiceGroupingKey - invoicingCycleConfiguration = eventOutput.invoicingCycleConfiguration - metadata = eventOutput.metadata - referenceId = eventOutput.referenceId - additionalProperties = eventOutput.additionalProperties.toMutableMap() + internal fun from(percent: Percent) = apply { + cadence = percent.cadence + itemId = percent.itemId + modelType = percent.modelType + name = percent.name + percentConfig = percent.percentConfig + billableMetricId = percent.billableMetricId + billedInAdvance = percent.billedInAdvance + billingCycleConfiguration = percent.billingCycleConfiguration + conversionRate = percent.conversionRate + conversionRateConfig = percent.conversionRateConfig + currency = percent.currency + dimensionalPriceConfiguration = percent.dimensionalPriceConfiguration + externalPriceId = percent.externalPriceId + fixedPriceQuantity = percent.fixedPriceQuantity + invoiceGroupingKey = percent.invoiceGroupingKey + invoicingCycleConfiguration = percent.invoicingCycleConfiguration + metadata = percent.metadata + referenceId = percent.referenceId + additionalProperties = percent.additionalProperties.toMutableMap() } /** The cadence to bill for this price on. */ @@ -7183,21 +7212,6 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - /** Configuration for event_output pricing */ - fun eventOutputConfig(eventOutputConfig: EventOutputConfig) = - eventOutputConfig(JsonField.of(eventOutputConfig)) - - /** - * Sets [Builder.eventOutputConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.eventOutputConfig] with a well-typed - * [EventOutputConfig] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun eventOutputConfig(eventOutputConfig: JsonField) = apply { - this.eventOutputConfig = eventOutputConfig - } - /** The id of the item the price will be associated with. */ fun itemId(itemId: String) = itemId(JsonField.of(itemId)) @@ -7216,7 +7230,7 @@ private constructor( * It is usually unnecessary to call this method because the field defaults to * the following: * ```kotlin - * JsonValue.from("event_output") + * JsonValue.from("percent") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -7236,6 +7250,21 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } + /** Configuration for percent pricing */ + fun percentConfig(percentConfig: PercentConfig) = + percentConfig(JsonField.of(percentConfig)) + + /** + * Sets [Builder.percentConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.percentConfig] with a well-typed + * [PercentConfig] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun percentConfig(percentConfig: JsonField) = apply { + this.percentConfig = percentConfig + } + /** * The id of the billable metric for the price. Only needed if the price is * usage-based. @@ -7565,27 +7594,27 @@ private constructor( } /** - * Returns an immutable instance of [EventOutput]. + * Returns an immutable instance of [Percent]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```kotlin * .cadence() - * .eventOutputConfig() * .itemId() * .name() + * .percentConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): EventOutput = - EventOutput( + fun build(): Percent = + Percent( checkRequired("cadence", cadence), - checkRequired("eventOutputConfig", eventOutputConfig), checkRequired("itemId", itemId), modelType, checkRequired("name", name), + checkRequired("percentConfig", percentConfig), billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -7605,20 +7634,20 @@ private constructor( private var validated: Boolean = false - fun validate(): EventOutput = apply { + fun validate(): Percent = apply { if (validated) { return@apply } cadence().validate() - eventOutputConfig().validate() itemId() _modelType().let { - if (it != JsonValue.from("event_output")) { + if (it != JsonValue.from("percent")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } name() + percentConfig().validate() billableMetricId() billedInAdvance() billingCycleConfiguration()?.validate() @@ -7651,10 +7680,10 @@ private constructor( */ internal fun validity(): Int = (cadence.asKnown()?.validity() ?: 0) + - (eventOutputConfig.asKnown()?.validity() ?: 0) + (if (itemId.asKnown() == null) 0 else 1) + - modelType.let { if (it == JsonValue.from("event_output")) 1 else 0 } + + modelType.let { if (it == JsonValue.from("percent")) 1 else 0 } + (if (name.asKnown() == null) 0 else 1) + + (percentConfig.asKnown()?.validity() ?: 0) + (if (billableMetricId.asKnown() == null) 0 else 1) + (if (billedInAdvance.asKnown() == null) 0 else 1) + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + @@ -7826,62 +7855,39 @@ private constructor( override fun toString() = value.toString() } - /** Configuration for event_output pricing */ - class EventOutputConfig + /** Configuration for percent pricing */ + class PercentConfig @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val unitRatingKey: JsonField, - private val groupingKey: JsonField, + private val percent: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("unit_rating_key") - @ExcludeMissing - unitRatingKey: JsonField = JsonMissing.of(), - @JsonProperty("grouping_key") + @JsonProperty("percent") @ExcludeMissing - groupingKey: JsonField = JsonMissing.of(), - ) : this(unitRatingKey, groupingKey, mutableMapOf()) + percent: JsonField = JsonMissing.of() + ) : this(percent, mutableMapOf()) /** - * The key in the event data to extract the unit rate from. + * What percent of the component subtotals to charge * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). */ - fun unitRatingKey(): String = unitRatingKey.getRequired("unit_rating_key") - - /** - * An optional key in the event data to group by (e.g., event ID). All events - * will also be grouped by their unit rate. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun groupingKey(): String? = groupingKey.getNullable("grouping_key") - - /** - * Returns the raw JSON value of [unitRatingKey]. - * - * Unlike [unitRatingKey], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("unit_rating_key") - @ExcludeMissing - fun _unitRatingKey(): JsonField = unitRatingKey + fun percent(): Double = percent.getRequired("percent") /** - * Returns the raw JSON value of [groupingKey]. + * Returns the raw JSON value of [percent]. * - * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * Unlike [percent], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("grouping_key") + @JsonProperty("percent") @ExcludeMissing - fun _groupingKey(): JsonField = groupingKey + fun _percent(): JsonField = percent @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -7899,63 +7905,39 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [EventOutputConfig]. + * [PercentConfig]. * * The following fields are required: * ```kotlin - * .unitRatingKey() + * .percent() * ``` */ fun builder() = Builder() } - /** A builder for [EventOutputConfig]. */ + /** A builder for [PercentConfig]. */ class Builder internal constructor() { - private var unitRatingKey: JsonField? = null - private var groupingKey: JsonField = JsonMissing.of() + private var percent: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(eventOutputConfig: EventOutputConfig) = apply { - unitRatingKey = eventOutputConfig.unitRatingKey - groupingKey = eventOutputConfig.groupingKey - additionalProperties = - eventOutputConfig.additionalProperties.toMutableMap() - } - - /** The key in the event data to extract the unit rate from. */ - fun unitRatingKey(unitRatingKey: String) = - unitRatingKey(JsonField.of(unitRatingKey)) - - /** - * Sets [Builder.unitRatingKey] to an arbitrary JSON value. - * - * You should usually call [Builder.unitRatingKey] with a well-typed - * [String] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun unitRatingKey(unitRatingKey: JsonField) = apply { - this.unitRatingKey = unitRatingKey + internal fun from(percentConfig: PercentConfig) = apply { + percent = percentConfig.percent + additionalProperties = percentConfig.additionalProperties.toMutableMap() } - /** - * An optional key in the event data to group by (e.g., event ID). All - * events will also be grouped by their unit rate. - */ - fun groupingKey(groupingKey: String?) = - groupingKey(JsonField.ofNullable(groupingKey)) + /** What percent of the component subtotals to charge */ + fun percent(percent: Double) = percent(JsonField.of(percent)) /** - * Sets [Builder.groupingKey] to an arbitrary JSON value. + * Sets [Builder.percent] to an arbitrary JSON value. * - * You should usually call [Builder.groupingKey] with a well-typed [String] + * You should usually call [Builder.percent] with a well-typed [Double] * value instead. This method is primarily for setting the field to an * undocumented or not yet supported value. */ - fun groupingKey(groupingKey: JsonField) = apply { - this.groupingKey = groupingKey - } + fun percent(percent: JsonField) = apply { this.percent = percent } fun additionalProperties(additionalProperties: Map) = apply { @@ -7980,34 +7962,32 @@ private constructor( } /** - * Returns an immutable instance of [EventOutputConfig]. + * Returns an immutable instance of [PercentConfig]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```kotlin - * .unitRatingKey() + * .percent() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): EventOutputConfig = - EventOutputConfig( - checkRequired("unitRatingKey", unitRatingKey), - groupingKey, + fun build(): PercentConfig = + PercentConfig( + checkRequired("percent", percent), additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): EventOutputConfig = apply { + fun validate(): PercentConfig = apply { if (validated) { return@apply } - unitRatingKey() - groupingKey() + percent() validated = true } @@ -8025,29 +8005,26 @@ private constructor( * * Used for best match union deserialization. */ - internal fun validity(): Int = - (if (unitRatingKey.asKnown() == null) 0 else 1) + - (if (groupingKey.asKnown() == null) 0 else 1) + internal fun validity(): Int = (if (percent.asKnown() == null) 0 else 1) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is EventOutputConfig && - unitRatingKey == other.unitRatingKey && - groupingKey == other.groupingKey && + return other is PercentConfig && + percent == other.percent && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(unitRatingKey, groupingKey, additionalProperties) + Objects.hash(percent, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "EventOutputConfig{unitRatingKey=$unitRatingKey, groupingKey=$groupingKey, additionalProperties=$additionalProperties}" + "PercentConfig{percent=$percent, additionalProperties=$additionalProperties}" } /** @@ -8164,12 +8141,12 @@ private constructor( return true } - return other is EventOutput && + return other is Percent && cadence == other.cadence && - eventOutputConfig == other.eventOutputConfig && itemId == other.itemId && modelType == other.modelType && name == other.name && + percentConfig == other.percentConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && @@ -8189,10 +8166,10 @@ private constructor( private val hashCode: Int by lazy { Objects.hash( cadence, - eventOutputConfig, itemId, modelType, name, + percentConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -8213,1051 +8190,1575 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "EventOutput{cadence=$cadence, eventOutputConfig=$eventOutputConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + "Percent{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, percentConfig=$percentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - return other is AddPrice && - allocationPrice == other.allocationPrice && - planPhaseOrder == other.planPhaseOrder && - price == other.price && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(allocationPrice, planPhaseOrder, price, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "AddPrice{allocationPrice=$allocationPrice, planPhaseOrder=$planPhaseOrder, price=$price, additionalProperties=$additionalProperties}" - } - - class RemoveAdjustment - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val adjustmentId: JsonField, - private val planPhaseOrder: JsonField, - private val additionalProperties: MutableMap, - ) { + class EventOutput + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val eventOutputConfig: JsonField, + private val itemId: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { - @JsonCreator - private constructor( - @JsonProperty("adjustment_id") - @ExcludeMissing - adjustmentId: JsonField = JsonMissing.of(), - @JsonProperty("plan_phase_order") - @ExcludeMissing - planPhaseOrder: JsonField = JsonMissing.of(), - ) : this(adjustmentId, planPhaseOrder, mutableMapOf()) - - /** - * The id of the adjustment to remove from on the plan. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun adjustmentId(): String = adjustmentId.getRequired("adjustment_id") + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("event_output_config") + @ExcludeMissing + eventOutputConfig: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + eventOutputConfig, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + mutableMapOf(), + ) - /** - * The phase to remove this adjustment from. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun planPhaseOrder(): Long? = planPhaseOrder.getNullable("plan_phase_order") + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") - /** - * Returns the raw JSON value of [adjustmentId]. - * - * Unlike [adjustmentId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("adjustment_id") - @ExcludeMissing - fun _adjustmentId(): JsonField = adjustmentId + /** + * Configuration for event_output pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun eventOutputConfig(): EventOutputConfig = + eventOutputConfig.getRequired("event_output_config") - /** - * Returns the raw JSON value of [planPhaseOrder]. - * - * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("plan_phase_order") - @ExcludeMissing - fun _planPhaseOrder(): JsonField = planPhaseOrder + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("event_output") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") - fun toBuilder() = Builder().from(this) + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = billableMetricId.getNullable("billable_metric_id") - companion object { + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") - /** - * Returns a mutable builder for constructing an instance of [RemoveAdjustment]. - * - * The following fields are required: - * ```kotlin - * .adjustmentId() - * ``` - */ - fun builder() = Builder() - } + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") - /** A builder for [RemoveAdjustment]. */ - class Builder internal constructor() { + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") - private var adjustmentId: JsonField? = null - private var planPhaseOrder: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") - internal fun from(removeAdjustment: RemoveAdjustment) = apply { - adjustmentId = removeAdjustment.adjustmentId - planPhaseOrder = removeAdjustment.planPhaseOrder - additionalProperties = removeAdjustment.additionalProperties.toMutableMap() - } + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") - /** The id of the adjustment to remove from on the plan. */ - fun adjustmentId(adjustmentId: String) = adjustmentId(JsonField.of(adjustmentId)) + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") - /** - * Sets [Builder.adjustmentId] to an arbitrary JSON value. - * - * You should usually call [Builder.adjustmentId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun adjustmentId(adjustmentId: JsonField) = apply { - this.adjustmentId = adjustmentId - } - - /** The phase to remove this adjustment from. */ - fun planPhaseOrder(planPhaseOrder: Long?) = - planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") - /** - * Alias for [Builder.planPhaseOrder]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") - /** - * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. - * - * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun planPhaseOrder(planPhaseOrder: JsonField) = apply { - this.planPhaseOrder = planPhaseOrder - } + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + invoiceGroupingKey.getNullable("invoice_grouping_key") - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * Returns the raw JSON value of [eventOutputConfig]. + * + * Unlike [eventOutputConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("event_output_config") + @ExcludeMissing + fun _eventOutputConfig(): JsonField = eventOutputConfig - /** - * Returns an immutable instance of [RemoveAdjustment]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```kotlin - * .adjustmentId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): RemoveAdjustment = - RemoveAdjustment( - checkRequired("adjustmentId", adjustmentId), - planPhaseOrder, - additionalProperties.toMutableMap(), - ) - } + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - private var validated: Boolean = false + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - fun validate(): RemoveAdjustment = apply { - if (validated) { - return@apply - } + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId - adjustmentId() - planPhaseOrder() - validated = true - } + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (if (adjustmentId.asKnown() == null) 0 else 1) + - (if (planPhaseOrder.asKnown() == null) 0 else 1) + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig - return other is RemoveAdjustment && - adjustmentId == other.adjustmentId && - planPhaseOrder == other.planPhaseOrder && - additionalProperties == other.additionalProperties - } + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency - private val hashCode: Int by lazy { - Objects.hash(adjustmentId, planPhaseOrder, additionalProperties) - } + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration - override fun hashCode(): Int = hashCode + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId - override fun toString() = - "RemoveAdjustment{adjustmentId=$adjustmentId, planPhaseOrder=$planPhaseOrder, additionalProperties=$additionalProperties}" - } - - class RemovePrice - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val priceId: JsonField, - private val planPhaseOrder: JsonField, - private val additionalProperties: MutableMap, - ) { + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - @JsonCreator - private constructor( - @JsonProperty("price_id") @ExcludeMissing priceId: JsonField = JsonMissing.of(), - @JsonProperty("plan_phase_order") - @ExcludeMissing - planPhaseOrder: JsonField = JsonMissing.of(), - ) : this(priceId, planPhaseOrder, mutableMapOf()) + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - /** - * The id of the price to remove from the plan. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun priceId(): String = priceId.getRequired("price_id") + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration - /** - * The phase to remove this price from. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun planPhaseOrder(): Long? = planPhaseOrder.getNullable("plan_phase_order") + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata - /** - * Returns the raw JSON value of [priceId]. - * - * Unlike [priceId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId - /** - * Returns the raw JSON value of [planPhaseOrder]. - * - * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("plan_phase_order") - @ExcludeMissing - fun _planPhaseOrder(): JsonField = planPhaseOrder + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + fun toBuilder() = Builder().from(this) - fun toBuilder() = Builder().from(this) + companion object { - companion object { + /** + * Returns a mutable builder for constructing an instance of [EventOutput]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .eventOutputConfig() + * .itemId() + * .name() + * ``` + */ + fun builder() = Builder() + } - /** - * Returns a mutable builder for constructing an instance of [RemovePrice]. - * - * The following fields are required: - * ```kotlin - * .priceId() - * ``` - */ - fun builder() = Builder() - } + /** A builder for [EventOutput]. */ + class Builder internal constructor() { - /** A builder for [RemovePrice]. */ - class Builder internal constructor() { + private var cadence: JsonField? = null + private var eventOutputConfig: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonValue = JsonValue.from("event_output") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - private var priceId: JsonField? = null - private var planPhaseOrder: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + internal fun from(eventOutput: EventOutput) = apply { + cadence = eventOutput.cadence + eventOutputConfig = eventOutput.eventOutputConfig + itemId = eventOutput.itemId + modelType = eventOutput.modelType + name = eventOutput.name + billableMetricId = eventOutput.billableMetricId + billedInAdvance = eventOutput.billedInAdvance + billingCycleConfiguration = eventOutput.billingCycleConfiguration + conversionRate = eventOutput.conversionRate + conversionRateConfig = eventOutput.conversionRateConfig + currency = eventOutput.currency + dimensionalPriceConfiguration = eventOutput.dimensionalPriceConfiguration + externalPriceId = eventOutput.externalPriceId + fixedPriceQuantity = eventOutput.fixedPriceQuantity + invoiceGroupingKey = eventOutput.invoiceGroupingKey + invoicingCycleConfiguration = eventOutput.invoicingCycleConfiguration + metadata = eventOutput.metadata + referenceId = eventOutput.referenceId + additionalProperties = eventOutput.additionalProperties.toMutableMap() + } - internal fun from(removePrice: RemovePrice) = apply { - priceId = removePrice.priceId - planPhaseOrder = removePrice.planPhaseOrder - additionalProperties = removePrice.additionalProperties.toMutableMap() - } + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - /** The id of the price to remove from the plan. */ - fun priceId(priceId: String) = priceId(JsonField.of(priceId)) + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - /** - * Sets [Builder.priceId] to an arbitrary JSON value. - * - * You should usually call [Builder.priceId] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun priceId(priceId: JsonField) = apply { this.priceId = priceId } + /** Configuration for event_output pricing */ + fun eventOutputConfig(eventOutputConfig: EventOutputConfig) = + eventOutputConfig(JsonField.of(eventOutputConfig)) - /** The phase to remove this price from. */ - fun planPhaseOrder(planPhaseOrder: Long?) = - planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + /** + * Sets [Builder.eventOutputConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.eventOutputConfig] with a well-typed + * [EventOutputConfig] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun eventOutputConfig(eventOutputConfig: JsonField) = apply { + this.eventOutputConfig = eventOutputConfig + } - /** - * Alias for [Builder.planPhaseOrder]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - /** - * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. - * - * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun planPhaseOrder(planPhaseOrder: JsonField) = apply { - this.planPhaseOrder = planPhaseOrder - } + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("event_output") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) - /** - * Returns an immutable instance of [RemovePrice]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```kotlin - * .priceId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): RemovePrice = - RemovePrice( - checkRequired("priceId", priceId), - planPhaseOrder, - additionalProperties.toMutableMap(), - ) - } + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } - private var validated: Boolean = false + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) - fun validate(): RemovePrice = apply { - if (validated) { - return@apply - } + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) - priceId() - planPhaseOrder() - validated = true - } + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (if (priceId.asKnown() == null) 0 else 1) + - (if (planPhaseOrder.asKnown() == null) 0 else 1) + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) - return other is RemovePrice && - priceId == other.priceId && - planPhaseOrder == other.planPhaseOrder && - additionalProperties == other.additionalProperties - } + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) - private val hashCode: Int by lazy { - Objects.hash(priceId, planPhaseOrder, additionalProperties) - } + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } - override fun hashCode(): Int = hashCode + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) - override fun toString() = - "RemovePrice{priceId=$priceId, planPhaseOrder=$planPhaseOrder, additionalProperties=$additionalProperties}" - } + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } - class ReplaceAdjustment - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val adjustment: JsonField, - private val replacesAdjustmentId: JsonField, - private val planPhaseOrder: JsonField, - private val additionalProperties: MutableMap, - ) { + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) - @JsonCreator - private constructor( - @JsonProperty("adjustment") - @ExcludeMissing - adjustment: JsonField = JsonMissing.of(), - @JsonProperty("replaces_adjustment_id") - @ExcludeMissing - replacesAdjustmentId: JsonField = JsonMissing.of(), - @JsonProperty("plan_phase_order") - @ExcludeMissing - planPhaseOrder: JsonField = JsonMissing.of(), - ) : this(adjustment, replacesAdjustmentId, planPhaseOrder, mutableMapOf()) + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) - /** - * The definition of a new adjustment to create and add to the plan. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun adjustment(): Adjustment = adjustment.getRequired("adjustment") + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) - /** - * The id of the adjustment on the plan to replace in the plan. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun replacesAdjustmentId(): String = - replacesAdjustmentId.getRequired("replaces_adjustment_id") + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) - /** - * The phase to replace this adjustment from. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun planPhaseOrder(): Long? = planPhaseOrder.getNullable("plan_phase_order") + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) - /** - * Returns the raw JSON value of [adjustment]. - * - * Unlike [adjustment], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("adjustment") - @ExcludeMissing - fun _adjustment(): JsonField = adjustment + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } - /** - * Returns the raw JSON value of [replacesAdjustmentId]. - * - * Unlike [replacesAdjustmentId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("replaces_adjustment_id") - @ExcludeMissing - fun _replacesAdjustmentId(): JsonField = replacesAdjustmentId + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) - /** - * Returns the raw JSON value of [planPhaseOrder]. - * - * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("plan_phase_order") - @ExcludeMissing - fun _planPhaseOrder(): JsonField = planPhaseOrder + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } - fun toBuilder() = Builder().from(this) + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) - companion object { + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) - /** - * Returns a mutable builder for constructing an instance of [ReplaceAdjustment]. - * - * The following fields are required: - * ```kotlin - * .adjustment() - * .replacesAdjustmentId() - * ``` - */ - fun builder() = Builder() - } + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } - /** A builder for [ReplaceAdjustment]. */ - class Builder internal constructor() { + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) - private var adjustment: JsonField? = null - private var replacesAdjustmentId: JsonField? = null - private var planPhaseOrder: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } - internal fun from(replaceAdjustment: ReplaceAdjustment) = apply { - adjustment = replaceAdjustment.adjustment - replacesAdjustmentId = replaceAdjustment.replacesAdjustmentId - planPhaseOrder = replaceAdjustment.planPhaseOrder - additionalProperties = replaceAdjustment.additionalProperties.toMutableMap() - } + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) - /** The definition of a new adjustment to create and add to the plan. */ - fun adjustment(adjustment: Adjustment) = adjustment(JsonField.of(adjustment)) + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - /** - * Sets [Builder.adjustment] to an arbitrary JSON value. - * - * You should usually call [Builder.adjustment] with a well-typed [Adjustment] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun adjustment(adjustment: JsonField) = apply { - this.adjustment = adjustment - } + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - /** - * Alias for calling [adjustment] with - * `Adjustment.ofPercentageDiscount(percentageDiscount)`. - */ - fun adjustment(percentageDiscount: NewPercentageDiscount) = - adjustment(Adjustment.ofPercentageDiscount(percentageDiscount)) + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - /** - * Alias for calling [adjustment] with the following: - * ```kotlin - * NewPercentageDiscount.builder() - * .adjustmentType(NewPercentageDiscount.AdjustmentType.PERCENTAGE_DISCOUNT) - * .percentageDiscount(percentageDiscount) - * .build() - * ``` - */ - fun percentageDiscountAdjustment(percentageDiscount: Double) = - adjustment( - NewPercentageDiscount.builder() - .adjustmentType(NewPercentageDiscount.AdjustmentType.PERCENTAGE_DISCOUNT) - .percentageDiscount(percentageDiscount) - .build() - ) + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) - /** Alias for calling [adjustment] with `Adjustment.ofUsageDiscount(usageDiscount)`. */ - fun adjustment(usageDiscount: NewUsageDiscount) = - adjustment(Adjustment.ofUsageDiscount(usageDiscount)) + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } - /** - * Alias for calling [adjustment] with the following: - * ```kotlin - * NewUsageDiscount.builder() - * .adjustmentType(NewUsageDiscount.AdjustmentType.USAGE_DISCOUNT) - * .usageDiscount(usageDiscount) - * .build() - * ``` - */ - fun usageDiscountAdjustment(usageDiscount: Double) = - adjustment( - NewUsageDiscount.builder() - .adjustmentType(NewUsageDiscount.AdjustmentType.USAGE_DISCOUNT) - .usageDiscount(usageDiscount) - .build() - ) + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** - * Alias for calling [adjustment] with `Adjustment.ofAmountDiscount(amountDiscount)`. - */ - fun adjustment(amountDiscount: NewAmountDiscount) = - adjustment(Adjustment.ofAmountDiscount(amountDiscount)) + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * Alias for calling [adjustment] with the following: - * ```kotlin - * NewAmountDiscount.builder() - * .adjustmentType(NewAmountDiscount.AdjustmentType.AMOUNT_DISCOUNT) - * .amountDiscount(amountDiscount) - * .build() - * ``` - */ - fun amountDiscountAdjustment(amountDiscount: String) = - adjustment( - NewAmountDiscount.builder() - .adjustmentType(NewAmountDiscount.AdjustmentType.AMOUNT_DISCOUNT) - .amountDiscount(amountDiscount) - .build() - ) + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - /** Alias for calling [adjustment] with `Adjustment.ofMinimum(minimum)`. */ - fun adjustment(minimum: NewMinimum) = adjustment(Adjustment.ofMinimum(minimum)) + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - /** Alias for calling [adjustment] with `Adjustment.ofMaximum(maximum)`. */ - fun adjustment(maximum: NewMaximum) = adjustment(Adjustment.ofMaximum(maximum)) + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - /** - * Alias for calling [adjustment] with the following: - * ```kotlin - * NewMaximum.builder() - * .adjustmentType(NewMaximum.AdjustmentType.MAXIMUM) - * .maximumAmount(maximumAmount) - * .build() - * ``` - */ - fun maximumAdjustment(maximumAmount: String) = - adjustment( - NewMaximum.builder() - .adjustmentType(NewMaximum.AdjustmentType.MAXIMUM) - .maximumAmount(maximumAmount) - .build() - ) + /** + * Returns an immutable instance of [EventOutput]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .eventOutputConfig() + * .itemId() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): EventOutput = + EventOutput( + checkRequired("cadence", cadence), + checkRequired("eventOutputConfig", eventOutputConfig), + checkRequired("itemId", itemId), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } - /** The id of the adjustment on the plan to replace in the plan. */ - fun replacesAdjustmentId(replacesAdjustmentId: String) = - replacesAdjustmentId(JsonField.of(replacesAdjustmentId)) + private var validated: Boolean = false - /** - * Sets [Builder.replacesAdjustmentId] to an arbitrary JSON value. - * - * You should usually call [Builder.replacesAdjustmentId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun replacesAdjustmentId(replacesAdjustmentId: JsonField) = apply { - this.replacesAdjustmentId = replacesAdjustmentId - } + fun validate(): EventOutput = apply { + if (validated) { + return@apply + } - /** The phase to replace this adjustment from. */ - fun planPhaseOrder(planPhaseOrder: Long?) = - planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + cadence().validate() + eventOutputConfig().validate() + itemId() + _modelType().let { + if (it != JsonValue.from("event_output")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + metadata()?.validate() + referenceId() + validated = true + } - /** - * Alias for [Builder.planPhaseOrder]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - /** - * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. - * - * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun planPhaseOrder(planPhaseOrder: JsonField) = apply { - this.planPhaseOrder = planPhaseOrder - } + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (eventOutputConfig.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + modelType.let { if (it == JsonValue.from("event_output")) 1 else 0 } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + companion object { - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + val ANNUAL = of("annual") - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + val SEMI_ANNUAL = of("semi_annual") - /** - * Returns an immutable instance of [ReplaceAdjustment]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```kotlin - * .adjustment() - * .replacesAdjustmentId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): ReplaceAdjustment = - ReplaceAdjustment( - checkRequired("adjustment", adjustment), - checkRequired("replacesAdjustmentId", replacesAdjustmentId), - planPhaseOrder, - additionalProperties.toMutableMap(), - ) - } + val MONTHLY = of("monthly") - private var validated: Boolean = false + val QUARTERLY = of("quarterly") - fun validate(): ReplaceAdjustment = apply { - if (validated) { - return@apply - } + val ONE_TIME = of("one_time") - adjustment().validate() - replacesAdjustmentId() - planPhaseOrder() - validated = true - } + val CUSTOM = of("custom") - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + fun of(value: String) = Cadence(JsonField.of(value)) + } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (adjustment.asKnown()?.validity() ?: 0) + - (if (replacesAdjustmentId.asKnown() == null) 0 else 1) + - (if (planPhaseOrder.asKnown() == null) 0 else 1) + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } - /** The definition of a new adjustment to create and add to the plan. */ - @JsonDeserialize(using = Adjustment.Deserializer::class) - @JsonSerialize(using = Adjustment.Serializer::class) - class Adjustment - private constructor( - private val percentageDiscount: NewPercentageDiscount? = null, - private val usageDiscount: NewUsageDiscount? = null, - private val amountDiscount: NewAmountDiscount? = null, - private val minimum: NewMinimum? = null, - private val maximum: NewMaximum? = null, - private val _json: JsonValue? = null, - ) { + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } - fun percentageDiscount(): NewPercentageDiscount? = percentageDiscount + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } - fun usageDiscount(): NewUsageDiscount? = usageDiscount + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } - fun amountDiscount(): NewAmountDiscount? = amountDiscount + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") - fun minimum(): NewMinimum? = minimum + private var validated: Boolean = false - fun maximum(): NewMaximum? = maximum + fun validate(): Cadence = apply { + if (validated) { + return@apply + } - fun isPercentageDiscount(): Boolean = percentageDiscount != null + known() + validated = true + } - fun isUsageDiscount(): Boolean = usageDiscount != null + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - fun isAmountDiscount(): Boolean = amountDiscount != null + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - fun isMinimum(): Boolean = minimum != null + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun isMaximum(): Boolean = maximum != null + return other is Cadence && value == other.value + } - fun asPercentageDiscount(): NewPercentageDiscount = - percentageDiscount.getOrThrow("percentageDiscount") + override fun hashCode() = value.hashCode() - fun asUsageDiscount(): NewUsageDiscount = usageDiscount.getOrThrow("usageDiscount") + override fun toString() = value.toString() + } - fun asAmountDiscount(): NewAmountDiscount = amountDiscount.getOrThrow("amountDiscount") + /** Configuration for event_output pricing */ + class EventOutputConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val unitRatingKey: JsonField, + private val groupingKey: JsonField, + private val additionalProperties: MutableMap, + ) { - fun asMinimum(): NewMinimum = minimum.getOrThrow("minimum") + @JsonCreator + private constructor( + @JsonProperty("unit_rating_key") + @ExcludeMissing + unitRatingKey: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + ) : this(unitRatingKey, groupingKey, mutableMapOf()) - fun asMaximum(): NewMaximum = maximum.getOrThrow("maximum") + /** + * The key in the event data to extract the unit rate from. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun unitRatingKey(): String = unitRatingKey.getRequired("unit_rating_key") - fun _json(): JsonValue? = _json + /** + * An optional key in the event data to group by (e.g., event ID). All events + * will also be grouped by their unit rate. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun groupingKey(): String? = groupingKey.getNullable("grouping_key") - fun accept(visitor: Visitor): T = - when { - percentageDiscount != null -> - visitor.visitPercentageDiscount(percentageDiscount) - usageDiscount != null -> visitor.visitUsageDiscount(usageDiscount) - amountDiscount != null -> visitor.visitAmountDiscount(amountDiscount) - minimum != null -> visitor.visitMinimum(minimum) - maximum != null -> visitor.visitMaximum(maximum) - else -> visitor.unknown(_json) - } + /** + * Returns the raw JSON value of [unitRatingKey]. + * + * Unlike [unitRatingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_rating_key") + @ExcludeMissing + fun _unitRatingKey(): JsonField = unitRatingKey - private var validated: Boolean = false + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey - fun validate(): Adjustment = apply { - if (validated) { - return@apply - } + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - accept( - object : Visitor { - override fun visitPercentageDiscount( - percentageDiscount: NewPercentageDiscount - ) { - percentageDiscount.validate() - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - override fun visitUsageDiscount(usageDiscount: NewUsageDiscount) { - usageDiscount.validate() - } + fun toBuilder() = Builder().from(this) - override fun visitAmountDiscount(amountDiscount: NewAmountDiscount) { - amountDiscount.validate() - } - - override fun visitMinimum(minimum: NewMinimum) { - minimum.validate() - } + companion object { - override fun visitMaximum(maximum: NewMaximum) { - maximum.validate() - } + /** + * Returns a mutable builder for constructing an instance of + * [EventOutputConfig]. + * + * The following fields are required: + * ```kotlin + * .unitRatingKey() + * ``` + */ + fun builder() = Builder() } - ) - validated = true - } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** A builder for [EventOutputConfig]. */ + class Builder internal constructor() { - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitPercentageDiscount( - percentageDiscount: NewPercentageDiscount - ) = percentageDiscount.validity() + private var unitRatingKey: JsonField? = null + private var groupingKey: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() - override fun visitUsageDiscount(usageDiscount: NewUsageDiscount) = - usageDiscount.validity() + internal fun from(eventOutputConfig: EventOutputConfig) = apply { + unitRatingKey = eventOutputConfig.unitRatingKey + groupingKey = eventOutputConfig.groupingKey + additionalProperties = + eventOutputConfig.additionalProperties.toMutableMap() + } - override fun visitAmountDiscount(amountDiscount: NewAmountDiscount) = - amountDiscount.validity() + /** The key in the event data to extract the unit rate from. */ + fun unitRatingKey(unitRatingKey: String) = + unitRatingKey(JsonField.of(unitRatingKey)) - override fun visitMinimum(minimum: NewMinimum) = minimum.validity() + /** + * Sets [Builder.unitRatingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.unitRatingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun unitRatingKey(unitRatingKey: JsonField) = apply { + this.unitRatingKey = unitRatingKey + } - override fun visitMaximum(maximum: NewMaximum) = maximum.validity() + /** + * An optional key in the event data to group by (e.g., event ID). All + * events will also be grouped by their unit rate. + */ + fun groupingKey(groupingKey: String?) = + groupingKey(JsonField.ofNullable(groupingKey)) - override fun unknown(json: JsonValue?) = 0 - } - ) + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - return other is Adjustment && - percentageDiscount == other.percentageDiscount && - usageDiscount == other.usageDiscount && - amountDiscount == other.amountDiscount && - minimum == other.minimum && - maximum == other.maximum - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - override fun hashCode(): Int = - Objects.hash(percentageDiscount, usageDiscount, amountDiscount, minimum, maximum) + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - override fun toString(): String = - when { - percentageDiscount != null -> - "Adjustment{percentageDiscount=$percentageDiscount}" - usageDiscount != null -> "Adjustment{usageDiscount=$usageDiscount}" - amountDiscount != null -> "Adjustment{amountDiscount=$amountDiscount}" - minimum != null -> "Adjustment{minimum=$minimum}" - maximum != null -> "Adjustment{maximum=$maximum}" - _json != null -> "Adjustment{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Adjustment") - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - companion object { + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - fun ofPercentageDiscount(percentageDiscount: NewPercentageDiscount) = - Adjustment(percentageDiscount = percentageDiscount) + /** + * Returns an immutable instance of [EventOutputConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .unitRatingKey() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): EventOutputConfig = + EventOutputConfig( + checkRequired("unitRatingKey", unitRatingKey), + groupingKey, + additionalProperties.toMutableMap(), + ) + } - fun ofUsageDiscount(usageDiscount: NewUsageDiscount) = - Adjustment(usageDiscount = usageDiscount) + private var validated: Boolean = false - fun ofAmountDiscount(amountDiscount: NewAmountDiscount) = - Adjustment(amountDiscount = amountDiscount) + fun validate(): EventOutputConfig = apply { + if (validated) { + return@apply + } - fun ofMinimum(minimum: NewMinimum) = Adjustment(minimum = minimum) + unitRatingKey() + groupingKey() + validated = true + } - fun ofMaximum(maximum: NewMaximum) = Adjustment(maximum = maximum) - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - /** - * An interface that defines how to map each variant of [Adjustment] to a value of type - * [T]. - */ - interface Visitor { + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (unitRatingKey.asKnown() == null) 0 else 1) + + (if (groupingKey.asKnown() == null) 0 else 1) - fun visitPercentageDiscount(percentageDiscount: NewPercentageDiscount): T + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun visitUsageDiscount(usageDiscount: NewUsageDiscount): T + return other is EventOutputConfig && + unitRatingKey == other.unitRatingKey && + groupingKey == other.groupingKey && + additionalProperties == other.additionalProperties + } - fun visitAmountDiscount(amountDiscount: NewAmountDiscount): T + private val hashCode: Int by lazy { + Objects.hash(unitRatingKey, groupingKey, additionalProperties) + } - fun visitMinimum(minimum: NewMinimum): T + override fun hashCode(): Int = hashCode - fun visitMaximum(maximum: NewMaximum): T + override fun toString() = + "EventOutputConfig{unitRatingKey=$unitRatingKey, groupingKey=$groupingKey, additionalProperties=$additionalProperties}" + } /** - * Maps an unknown variant of [Adjustment] to a value of type [T]. - * - * An instance of [Adjustment] can contain an unknown variant if it was deserialized - * from data that doesn't match any known variant. For example, if the SDK is on an - * older version than the API, then the API may respond with new variants that the - * SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown Adjustment: $json") - } - } + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { - internal class Deserializer : BaseDeserializer(Adjustment::class) { + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties - override fun ObjectCodec.deserialize(node: JsonNode): Adjustment { - val json = JsonValue.fromJsonNode(node) - val adjustmentType = json.asObject()?.get("adjustment_type")?.asString() + fun toBuilder() = Builder().from(this) - when (adjustmentType) { - "percentage_discount" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Adjustment(percentageDiscount = it, _json = json) } - ?: Adjustment(_json = json) - } - "usage_discount" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(usageDiscount = it, _json = json) - } ?: Adjustment(_json = json) - } - "amount_discount" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(amountDiscount = it, _json = json) - } ?: Adjustment(_json = json) + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() } - "minimum" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(minimum = it, _json = json) - } ?: Adjustment(_json = json) + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) } - "maximum" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(maximum = it, _json = json) - } ?: Adjustment(_json = json) + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } - return Adjustment(_json = json) - } - } + private var validated: Boolean = false - internal class Serializer : BaseSerializer(Adjustment::class) { + fun validate(): Metadata = apply { + if (validated) { + return@apply + } - override fun serialize( - value: Adjustment, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.percentageDiscount != null -> - generator.writeObject(value.percentageDiscount) - value.usageDiscount != null -> generator.writeObject(value.usageDiscount) - value.amountDiscount != null -> generator.writeObject(value.amountDiscount) - value.minimum != null -> generator.writeObject(value.minimum) - value.maximum != null -> generator.writeObject(value.maximum) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Adjustment") + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } + + return other is EventOutput && + cadence == other.cadence && + eventOutputConfig == other.eventOutputConfig && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + eventOutputConfig, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties, + ) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "EventOutput{cadence=$cadence, eventOutputConfig=$eventOutputConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } } @@ -9266,65 +9767,51 @@ private constructor( return true } - return other is ReplaceAdjustment && - adjustment == other.adjustment && - replacesAdjustmentId == other.replacesAdjustmentId && + return other is AddPrice && + allocationPrice == other.allocationPrice && planPhaseOrder == other.planPhaseOrder && + price == other.price && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(adjustment, replacesAdjustmentId, planPhaseOrder, additionalProperties) + Objects.hash(allocationPrice, planPhaseOrder, price, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "ReplaceAdjustment{adjustment=$adjustment, replacesAdjustmentId=$replacesAdjustmentId, planPhaseOrder=$planPhaseOrder, additionalProperties=$additionalProperties}" + "AddPrice{allocationPrice=$allocationPrice, planPhaseOrder=$planPhaseOrder, price=$price, additionalProperties=$additionalProperties}" } - class ReplacePrice + class RemoveAdjustment @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val replacesPriceId: JsonField, - private val allocationPrice: JsonField, + private val adjustmentId: JsonField, private val planPhaseOrder: JsonField, - private val price: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("replaces_price_id") - @ExcludeMissing - replacesPriceId: JsonField = JsonMissing.of(), - @JsonProperty("allocation_price") + @JsonProperty("adjustment_id") @ExcludeMissing - allocationPrice: JsonField = JsonMissing.of(), + adjustmentId: JsonField = JsonMissing.of(), @JsonProperty("plan_phase_order") @ExcludeMissing planPhaseOrder: JsonField = JsonMissing.of(), - @JsonProperty("price") @ExcludeMissing price: JsonField = JsonMissing.of(), - ) : this(replacesPriceId, allocationPrice, planPhaseOrder, price, mutableMapOf()) + ) : this(adjustmentId, planPhaseOrder, mutableMapOf()) /** - * The id of the price on the plan to replace in the plan. + * The id of the adjustment to remove from on the plan. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ - fun replacesPriceId(): String = replacesPriceId.getRequired("replaces_price_id") - - /** - * The allocation price to add to the plan. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun allocationPrice(): NewAllocationPrice? = allocationPrice.getNullable("allocation_price") + fun adjustmentId(): String = adjustmentId.getRequired("adjustment_id") /** - * The phase to replace this price from. + * The phase to remove this adjustment from. * * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -9332,32 +9819,14 @@ private constructor( fun planPhaseOrder(): Long? = planPhaseOrder.getNullable("plan_phase_order") /** - * New plan price request body params. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun price(): Price? = price.getNullable("price") - - /** - * Returns the raw JSON value of [replacesPriceId]. - * - * Unlike [replacesPriceId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("replaces_price_id") - @ExcludeMissing - fun _replacesPriceId(): JsonField = replacesPriceId - - /** - * Returns the raw JSON value of [allocationPrice]. + * Returns the raw JSON value of [adjustmentId]. * - * Unlike [allocationPrice], this method doesn't throw if the JSON field has an unexpected + * Unlike [adjustmentId], this method doesn't throw if the JSON field has an unexpected * type. */ - @JsonProperty("allocation_price") + @JsonProperty("adjustment_id") @ExcludeMissing - fun _allocationPrice(): JsonField = allocationPrice + fun _adjustmentId(): JsonField = adjustmentId /** * Returns the raw JSON value of [planPhaseOrder]. @@ -9369,13 +9838,6 @@ private constructor( @ExcludeMissing fun _planPhaseOrder(): JsonField = planPhaseOrder - /** - * Returns the raw JSON value of [price]. - * - * Unlike [price], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("price") @ExcludeMissing fun _price(): JsonField = price - @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -9391,64 +9853,44 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [ReplacePrice]. + * Returns a mutable builder for constructing an instance of [RemoveAdjustment]. * * The following fields are required: * ```kotlin - * .replacesPriceId() + * .adjustmentId() * ``` */ fun builder() = Builder() } - /** A builder for [ReplacePrice]. */ + /** A builder for [RemoveAdjustment]. */ class Builder internal constructor() { - private var replacesPriceId: JsonField? = null - private var allocationPrice: JsonField = JsonMissing.of() + private var adjustmentId: JsonField? = null private var planPhaseOrder: JsonField = JsonMissing.of() - private var price: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(replacePrice: ReplacePrice) = apply { - replacesPriceId = replacePrice.replacesPriceId - allocationPrice = replacePrice.allocationPrice - planPhaseOrder = replacePrice.planPhaseOrder - price = replacePrice.price - additionalProperties = replacePrice.additionalProperties.toMutableMap() + internal fun from(removeAdjustment: RemoveAdjustment) = apply { + adjustmentId = removeAdjustment.adjustmentId + planPhaseOrder = removeAdjustment.planPhaseOrder + additionalProperties = removeAdjustment.additionalProperties.toMutableMap() } - /** The id of the price on the plan to replace in the plan. */ - fun replacesPriceId(replacesPriceId: String) = - replacesPriceId(JsonField.of(replacesPriceId)) + /** The id of the adjustment to remove from on the plan. */ + fun adjustmentId(adjustmentId: String) = adjustmentId(JsonField.of(adjustmentId)) /** - * Sets [Builder.replacesPriceId] to an arbitrary JSON value. + * Sets [Builder.adjustmentId] to an arbitrary JSON value. * - * You should usually call [Builder.replacesPriceId] with a well-typed [String] value + * You should usually call [Builder.adjustmentId] with a well-typed [String] value * instead. This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun replacesPriceId(replacesPriceId: JsonField) = apply { - this.replacesPriceId = replacesPriceId - } - - /** The allocation price to add to the plan. */ - fun allocationPrice(allocationPrice: NewAllocationPrice?) = - allocationPrice(JsonField.ofNullable(allocationPrice)) - - /** - * Sets [Builder.allocationPrice] to an arbitrary JSON value. - * - * You should usually call [Builder.allocationPrice] with a well-typed - * [NewAllocationPrice] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun allocationPrice(allocationPrice: JsonField) = apply { - this.allocationPrice = allocationPrice + fun adjustmentId(adjustmentId: JsonField) = apply { + this.adjustmentId = adjustmentId } - /** The phase to replace this price from. */ + /** The phase to remove this adjustment from. */ fun planPhaseOrder(planPhaseOrder: Long?) = planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) @@ -9470,162 +9912,6 @@ private constructor( this.planPhaseOrder = planPhaseOrder } - /** New plan price request body params. */ - fun price(price: Price?) = price(JsonField.ofNullable(price)) - - /** - * Sets [Builder.price] to an arbitrary JSON value. - * - * You should usually call [Builder.price] with a well-typed [Price] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun price(price: JsonField) = apply { this.price = price } - - /** Alias for calling [price] with `Price.ofUnit(unit)`. */ - fun price(unit: NewPlanUnitPrice) = price(Price.ofUnit(unit)) - - /** Alias for calling [price] with `Price.ofTiered(tiered)`. */ - fun price(tiered: NewPlanTieredPrice) = price(Price.ofTiered(tiered)) - - /** Alias for calling [price] with `Price.ofBulk(bulk)`. */ - fun price(bulk: NewPlanBulkPrice) = price(Price.ofBulk(bulk)) - - /** Alias for calling [price] with `Price.ofPackage(package_)`. */ - fun price(package_: NewPlanPackagePrice) = price(Price.ofPackage(package_)) - - /** Alias for calling [price] with `Price.ofMatrix(matrix)`. */ - fun price(matrix: NewPlanMatrixPrice) = price(Price.ofMatrix(matrix)) - - /** - * Alias for calling [price] with `Price.ofThresholdTotalAmount(thresholdTotalAmount)`. - */ - fun price(thresholdTotalAmount: NewPlanThresholdTotalAmountPrice) = - price(Price.ofThresholdTotalAmount(thresholdTotalAmount)) - - /** Alias for calling [price] with `Price.ofTieredPackage(tieredPackage)`. */ - fun price(tieredPackage: NewPlanTieredPackagePrice) = - price(Price.ofTieredPackage(tieredPackage)) - - /** Alias for calling [price] with `Price.ofTieredWithMinimum(tieredWithMinimum)`. */ - fun price(tieredWithMinimum: NewPlanTieredWithMinimumPrice) = - price(Price.ofTieredWithMinimum(tieredWithMinimum)) - - /** Alias for calling [price] with `Price.ofGroupedTiered(groupedTiered)`. */ - fun price(groupedTiered: NewPlanGroupedTieredPrice) = - price(Price.ofGroupedTiered(groupedTiered)) - - /** - * Alias for calling [price] with - * `Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)`. - */ - fun price(tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice) = - price(Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)) - - /** - * Alias for calling [price] with - * `Price.ofPackageWithAllocation(packageWithAllocation)`. - */ - fun price(packageWithAllocation: NewPlanPackageWithAllocationPrice) = - price(Price.ofPackageWithAllocation(packageWithAllocation)) - - /** Alias for calling [price] with `Price.ofUnitWithPercent(unitWithPercent)`. */ - fun price(unitWithPercent: NewPlanUnitWithPercentPrice) = - price(Price.ofUnitWithPercent(unitWithPercent)) - - /** - * Alias for calling [price] with `Price.ofMatrixWithAllocation(matrixWithAllocation)`. - */ - fun price(matrixWithAllocation: NewPlanMatrixWithAllocationPrice) = - price(Price.ofMatrixWithAllocation(matrixWithAllocation)) - - /** - * Alias for calling [price] with `Price.ofTieredWithProration(tieredWithProration)`. - */ - fun price(tieredWithProration: Price.TieredWithProration) = - price(Price.ofTieredWithProration(tieredWithProration)) - - /** Alias for calling [price] with `Price.ofUnitWithProration(unitWithProration)`. */ - fun price(unitWithProration: NewPlanUnitWithProrationPrice) = - price(Price.ofUnitWithProration(unitWithProration)) - - /** Alias for calling [price] with `Price.ofGroupedAllocation(groupedAllocation)`. */ - fun price(groupedAllocation: NewPlanGroupedAllocationPrice) = - price(Price.ofGroupedAllocation(groupedAllocation)) - - /** Alias for calling [price] with `Price.ofBulkWithProration(bulkWithProration)`. */ - fun price(bulkWithProration: NewPlanBulkWithProrationPrice) = - price(Price.ofBulkWithProration(bulkWithProration)) - - /** - * Alias for calling [price] with - * `Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)`. - */ - fun price(groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice) = - price(Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)) - - /** - * Alias for calling [price] with - * `Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)`. - */ - fun price(groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice) = - price(Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)) - - /** - * Alias for calling [price] with - * `Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)`. - */ - fun price(groupedWithMinMaxThresholds: Price.GroupedWithMinMaxThresholds) = - price(Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)) - - /** - * Alias for calling [price] with - * `Price.ofMatrixWithDisplayName(matrixWithDisplayName)`. - */ - fun price(matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice) = - price(Price.ofMatrixWithDisplayName(matrixWithDisplayName)) - - /** - * Alias for calling [price] with `Price.ofGroupedTieredPackage(groupedTieredPackage)`. - */ - fun price(groupedTieredPackage: NewPlanGroupedTieredPackagePrice) = - price(Price.ofGroupedTieredPackage(groupedTieredPackage)) - - /** - * Alias for calling [price] with - * `Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)`. - */ - fun price(maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice) = - price(Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)) - - /** - * Alias for calling [price] with - * `Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)`. - */ - fun price(scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice) = - price(Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)) - - /** - * Alias for calling [price] with - * `Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)`. - */ - fun price( - scalableMatrixWithTieredPricing: NewPlanScalableMatrixWithTieredPricingPrice - ) = price(Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)) - - /** - * Alias for calling [price] with - * `Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)`. - */ - fun price(cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice) = - price(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) - - /** Alias for calling [price] with `Price.ofMinimum(minimum)`. */ - fun price(minimum: NewPlanMinimumCompositePrice) = price(Price.ofMinimum(minimum)) - - /** Alias for calling [price] with `Price.ofEventOutput(eventOutput)`. */ - fun price(eventOutput: Price.EventOutput) = price(Price.ofEventOutput(eventOutput)) - fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -9646,38 +9932,34 @@ private constructor( } /** - * Returns an immutable instance of [ReplacePrice]. + * Returns an immutable instance of [RemoveAdjustment]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```kotlin - * .replacesPriceId() + * .adjustmentId() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): ReplacePrice = - ReplacePrice( - checkRequired("replacesPriceId", replacesPriceId), - allocationPrice, + fun build(): RemoveAdjustment = + RemoveAdjustment( + checkRequired("adjustmentId", adjustmentId), planPhaseOrder, - price, additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): ReplacePrice = apply { + fun validate(): RemoveAdjustment = apply { if (validated) { return@apply } - replacesPriceId() - allocationPrice()?.validate() + adjustmentId() planPhaseOrder() - price()?.validate() validated = true } @@ -9696,1166 +9978,4229 @@ private constructor( * Used for best match union deserialization. */ internal fun validity(): Int = - (if (replacesPriceId.asKnown() == null) 0 else 1) + - (allocationPrice.asKnown()?.validity() ?: 0) + - (if (planPhaseOrder.asKnown() == null) 0 else 1) + - (price.asKnown()?.validity() ?: 0) - - /** New plan price request body params. */ - @JsonDeserialize(using = Price.Deserializer::class) - @JsonSerialize(using = Price.Serializer::class) - class Price - private constructor( - private val unit: NewPlanUnitPrice? = null, - private val tiered: NewPlanTieredPrice? = null, - private val bulk: NewPlanBulkPrice? = null, - private val package_: NewPlanPackagePrice? = null, - private val matrix: NewPlanMatrixPrice? = null, - private val thresholdTotalAmount: NewPlanThresholdTotalAmountPrice? = null, - private val tieredPackage: NewPlanTieredPackagePrice? = null, - private val tieredWithMinimum: NewPlanTieredWithMinimumPrice? = null, - private val groupedTiered: NewPlanGroupedTieredPrice? = null, - private val tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice? = null, - private val packageWithAllocation: NewPlanPackageWithAllocationPrice? = null, - private val unitWithPercent: NewPlanUnitWithPercentPrice? = null, - private val matrixWithAllocation: NewPlanMatrixWithAllocationPrice? = null, - private val tieredWithProration: TieredWithProration? = null, - private val unitWithProration: NewPlanUnitWithProrationPrice? = null, - private val groupedAllocation: NewPlanGroupedAllocationPrice? = null, - private val bulkWithProration: NewPlanBulkWithProrationPrice? = null, - private val groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice? = null, - private val groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice? = null, - private val groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds? = null, - private val matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice? = null, - private val groupedTieredPackage: NewPlanGroupedTieredPackagePrice? = null, - private val maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice? = null, - private val scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice? = - null, - private val scalableMatrixWithTieredPricing: - NewPlanScalableMatrixWithTieredPricingPrice? = - null, - private val cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice? = null, - private val minimum: NewPlanMinimumCompositePrice? = null, - private val eventOutput: EventOutput? = null, - private val _json: JsonValue? = null, - ) { - - fun unit(): NewPlanUnitPrice? = unit + (if (adjustmentId.asKnown() == null) 0 else 1) + + (if (planPhaseOrder.asKnown() == null) 0 else 1) - fun tiered(): NewPlanTieredPrice? = tiered + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun bulk(): NewPlanBulkPrice? = bulk + return other is RemoveAdjustment && + adjustmentId == other.adjustmentId && + planPhaseOrder == other.planPhaseOrder && + additionalProperties == other.additionalProperties + } - fun package_(): NewPlanPackagePrice? = package_ + private val hashCode: Int by lazy { + Objects.hash(adjustmentId, planPhaseOrder, additionalProperties) + } - fun matrix(): NewPlanMatrixPrice? = matrix + override fun hashCode(): Int = hashCode - fun thresholdTotalAmount(): NewPlanThresholdTotalAmountPrice? = thresholdTotalAmount + override fun toString() = + "RemoveAdjustment{adjustmentId=$adjustmentId, planPhaseOrder=$planPhaseOrder, additionalProperties=$additionalProperties}" + } - fun tieredPackage(): NewPlanTieredPackagePrice? = tieredPackage + class RemovePrice + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val priceId: JsonField, + private val planPhaseOrder: JsonField, + private val additionalProperties: MutableMap, + ) { - fun tieredWithMinimum(): NewPlanTieredWithMinimumPrice? = tieredWithMinimum + @JsonCreator + private constructor( + @JsonProperty("price_id") @ExcludeMissing priceId: JsonField = JsonMissing.of(), + @JsonProperty("plan_phase_order") + @ExcludeMissing + planPhaseOrder: JsonField = JsonMissing.of(), + ) : this(priceId, planPhaseOrder, mutableMapOf()) - fun groupedTiered(): NewPlanGroupedTieredPrice? = groupedTiered + /** + * The id of the price to remove from the plan. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun priceId(): String = priceId.getRequired("price_id") - fun tieredPackageWithMinimum(): NewPlanTieredPackageWithMinimumPrice? = - tieredPackageWithMinimum + /** + * The phase to remove this price from. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun planPhaseOrder(): Long? = planPhaseOrder.getNullable("plan_phase_order") - fun packageWithAllocation(): NewPlanPackageWithAllocationPrice? = packageWithAllocation + /** + * Returns the raw JSON value of [priceId]. + * + * Unlike [priceId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId - fun unitWithPercent(): NewPlanUnitWithPercentPrice? = unitWithPercent + /** + * Returns the raw JSON value of [planPhaseOrder]. + * + * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder - fun matrixWithAllocation(): NewPlanMatrixWithAllocationPrice? = matrixWithAllocation + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - fun tieredWithProration(): TieredWithProration? = tieredWithProration + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - fun unitWithProration(): NewPlanUnitWithProrationPrice? = unitWithProration + fun toBuilder() = Builder().from(this) - fun groupedAllocation(): NewPlanGroupedAllocationPrice? = groupedAllocation + companion object { - fun bulkWithProration(): NewPlanBulkWithProrationPrice? = bulkWithProration + /** + * Returns a mutable builder for constructing an instance of [RemovePrice]. + * + * The following fields are required: + * ```kotlin + * .priceId() + * ``` + */ + fun builder() = Builder() + } - fun groupedWithProratedMinimum(): NewPlanGroupedWithProratedMinimumPrice? = - groupedWithProratedMinimum + /** A builder for [RemovePrice]. */ + class Builder internal constructor() { + + private var priceId: JsonField? = null + private var planPhaseOrder: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(removePrice: RemovePrice) = apply { + priceId = removePrice.priceId + planPhaseOrder = removePrice.planPhaseOrder + additionalProperties = removePrice.additionalProperties.toMutableMap() + } + + /** The id of the price to remove from the plan. */ + fun priceId(priceId: String) = priceId(JsonField.of(priceId)) + + /** + * Sets [Builder.priceId] to an arbitrary JSON value. + * + * You should usually call [Builder.priceId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun priceId(priceId: JsonField) = apply { this.priceId = priceId } + + /** The phase to remove this price from. */ + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + + /** + * Alias for [Builder.planPhaseOrder]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + + /** + * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. + * + * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun planPhaseOrder(planPhaseOrder: JsonField) = apply { + this.planPhaseOrder = planPhaseOrder + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [RemovePrice]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .priceId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): RemovePrice = + RemovePrice( + checkRequired("priceId", priceId), + planPhaseOrder, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): RemovePrice = apply { + if (validated) { + return@apply + } + + priceId() + planPhaseOrder() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (priceId.asKnown() == null) 0 else 1) + + (if (planPhaseOrder.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RemovePrice && + priceId == other.priceId && + planPhaseOrder == other.planPhaseOrder && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(priceId, planPhaseOrder, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "RemovePrice{priceId=$priceId, planPhaseOrder=$planPhaseOrder, additionalProperties=$additionalProperties}" + } + + class ReplaceAdjustment + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val adjustment: JsonField, + private val replacesAdjustmentId: JsonField, + private val planPhaseOrder: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("adjustment") + @ExcludeMissing + adjustment: JsonField = JsonMissing.of(), + @JsonProperty("replaces_adjustment_id") + @ExcludeMissing + replacesAdjustmentId: JsonField = JsonMissing.of(), + @JsonProperty("plan_phase_order") + @ExcludeMissing + planPhaseOrder: JsonField = JsonMissing.of(), + ) : this(adjustment, replacesAdjustmentId, planPhaseOrder, mutableMapOf()) + + /** + * The definition of a new adjustment to create and add to the plan. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun adjustment(): Adjustment = adjustment.getRequired("adjustment") + + /** + * The id of the adjustment on the plan to replace in the plan. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun replacesAdjustmentId(): String = + replacesAdjustmentId.getRequired("replaces_adjustment_id") + + /** + * The phase to replace this adjustment from. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun planPhaseOrder(): Long? = planPhaseOrder.getNullable("plan_phase_order") + + /** + * Returns the raw JSON value of [adjustment]. + * + * Unlike [adjustment], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("adjustment") + @ExcludeMissing + fun _adjustment(): JsonField = adjustment + + /** + * Returns the raw JSON value of [replacesAdjustmentId]. + * + * Unlike [replacesAdjustmentId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("replaces_adjustment_id") + @ExcludeMissing + fun _replacesAdjustmentId(): JsonField = replacesAdjustmentId + + /** + * Returns the raw JSON value of [planPhaseOrder]. + * + * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ReplaceAdjustment]. + * + * The following fields are required: + * ```kotlin + * .adjustment() + * .replacesAdjustmentId() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [ReplaceAdjustment]. */ + class Builder internal constructor() { + + private var adjustment: JsonField? = null + private var replacesAdjustmentId: JsonField? = null + private var planPhaseOrder: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(replaceAdjustment: ReplaceAdjustment) = apply { + adjustment = replaceAdjustment.adjustment + replacesAdjustmentId = replaceAdjustment.replacesAdjustmentId + planPhaseOrder = replaceAdjustment.planPhaseOrder + additionalProperties = replaceAdjustment.additionalProperties.toMutableMap() + } + + /** The definition of a new adjustment to create and add to the plan. */ + fun adjustment(adjustment: Adjustment) = adjustment(JsonField.of(adjustment)) + + /** + * Sets [Builder.adjustment] to an arbitrary JSON value. + * + * You should usually call [Builder.adjustment] with a well-typed [Adjustment] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun adjustment(adjustment: JsonField) = apply { + this.adjustment = adjustment + } + + /** + * Alias for calling [adjustment] with + * `Adjustment.ofPercentageDiscount(percentageDiscount)`. + */ + fun adjustment(percentageDiscount: NewPercentageDiscount) = + adjustment(Adjustment.ofPercentageDiscount(percentageDiscount)) + + /** + * Alias for calling [adjustment] with the following: + * ```kotlin + * NewPercentageDiscount.builder() + * .adjustmentType(NewPercentageDiscount.AdjustmentType.PERCENTAGE_DISCOUNT) + * .percentageDiscount(percentageDiscount) + * .build() + * ``` + */ + fun percentageDiscountAdjustment(percentageDiscount: Double) = + adjustment( + NewPercentageDiscount.builder() + .adjustmentType(NewPercentageDiscount.AdjustmentType.PERCENTAGE_DISCOUNT) + .percentageDiscount(percentageDiscount) + .build() + ) + + /** Alias for calling [adjustment] with `Adjustment.ofUsageDiscount(usageDiscount)`. */ + fun adjustment(usageDiscount: NewUsageDiscount) = + adjustment(Adjustment.ofUsageDiscount(usageDiscount)) + + /** + * Alias for calling [adjustment] with the following: + * ```kotlin + * NewUsageDiscount.builder() + * .adjustmentType(NewUsageDiscount.AdjustmentType.USAGE_DISCOUNT) + * .usageDiscount(usageDiscount) + * .build() + * ``` + */ + fun usageDiscountAdjustment(usageDiscount: Double) = + adjustment( + NewUsageDiscount.builder() + .adjustmentType(NewUsageDiscount.AdjustmentType.USAGE_DISCOUNT) + .usageDiscount(usageDiscount) + .build() + ) + + /** + * Alias for calling [adjustment] with `Adjustment.ofAmountDiscount(amountDiscount)`. + */ + fun adjustment(amountDiscount: NewAmountDiscount) = + adjustment(Adjustment.ofAmountDiscount(amountDiscount)) + + /** + * Alias for calling [adjustment] with the following: + * ```kotlin + * NewAmountDiscount.builder() + * .adjustmentType(NewAmountDiscount.AdjustmentType.AMOUNT_DISCOUNT) + * .amountDiscount(amountDiscount) + * .build() + * ``` + */ + fun amountDiscountAdjustment(amountDiscount: String) = + adjustment( + NewAmountDiscount.builder() + .adjustmentType(NewAmountDiscount.AdjustmentType.AMOUNT_DISCOUNT) + .amountDiscount(amountDiscount) + .build() + ) + + /** Alias for calling [adjustment] with `Adjustment.ofMinimum(minimum)`. */ + fun adjustment(minimum: NewMinimum) = adjustment(Adjustment.ofMinimum(minimum)) + + /** Alias for calling [adjustment] with `Adjustment.ofMaximum(maximum)`. */ + fun adjustment(maximum: NewMaximum) = adjustment(Adjustment.ofMaximum(maximum)) + + /** + * Alias for calling [adjustment] with the following: + * ```kotlin + * NewMaximum.builder() + * .adjustmentType(NewMaximum.AdjustmentType.MAXIMUM) + * .maximumAmount(maximumAmount) + * .build() + * ``` + */ + fun maximumAdjustment(maximumAmount: String) = + adjustment( + NewMaximum.builder() + .adjustmentType(NewMaximum.AdjustmentType.MAXIMUM) + .maximumAmount(maximumAmount) + .build() + ) + + /** The id of the adjustment on the plan to replace in the plan. */ + fun replacesAdjustmentId(replacesAdjustmentId: String) = + replacesAdjustmentId(JsonField.of(replacesAdjustmentId)) + + /** + * Sets [Builder.replacesAdjustmentId] to an arbitrary JSON value. + * + * You should usually call [Builder.replacesAdjustmentId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun replacesAdjustmentId(replacesAdjustmentId: JsonField) = apply { + this.replacesAdjustmentId = replacesAdjustmentId + } + + /** The phase to replace this adjustment from. */ + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + + /** + * Alias for [Builder.planPhaseOrder]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + + /** + * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. + * + * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun planPhaseOrder(planPhaseOrder: JsonField) = apply { + this.planPhaseOrder = planPhaseOrder + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ReplaceAdjustment]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .adjustment() + * .replacesAdjustmentId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ReplaceAdjustment = + ReplaceAdjustment( + checkRequired("adjustment", adjustment), + checkRequired("replacesAdjustmentId", replacesAdjustmentId), + planPhaseOrder, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ReplaceAdjustment = apply { + if (validated) { + return@apply + } + + adjustment().validate() + replacesAdjustmentId() + planPhaseOrder() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (adjustment.asKnown()?.validity() ?: 0) + + (if (replacesAdjustmentId.asKnown() == null) 0 else 1) + + (if (planPhaseOrder.asKnown() == null) 0 else 1) + + /** The definition of a new adjustment to create and add to the plan. */ + @JsonDeserialize(using = Adjustment.Deserializer::class) + @JsonSerialize(using = Adjustment.Serializer::class) + class Adjustment + private constructor( + private val percentageDiscount: NewPercentageDiscount? = null, + private val usageDiscount: NewUsageDiscount? = null, + private val amountDiscount: NewAmountDiscount? = null, + private val minimum: NewMinimum? = null, + private val maximum: NewMaximum? = null, + private val _json: JsonValue? = null, + ) { + + fun percentageDiscount(): NewPercentageDiscount? = percentageDiscount + + fun usageDiscount(): NewUsageDiscount? = usageDiscount + + fun amountDiscount(): NewAmountDiscount? = amountDiscount + + fun minimum(): NewMinimum? = minimum + + fun maximum(): NewMaximum? = maximum + + fun isPercentageDiscount(): Boolean = percentageDiscount != null + + fun isUsageDiscount(): Boolean = usageDiscount != null + + fun isAmountDiscount(): Boolean = amountDiscount != null + + fun isMinimum(): Boolean = minimum != null + + fun isMaximum(): Boolean = maximum != null + + fun asPercentageDiscount(): NewPercentageDiscount = + percentageDiscount.getOrThrow("percentageDiscount") + + fun asUsageDiscount(): NewUsageDiscount = usageDiscount.getOrThrow("usageDiscount") + + fun asAmountDiscount(): NewAmountDiscount = amountDiscount.getOrThrow("amountDiscount") + + fun asMinimum(): NewMinimum = minimum.getOrThrow("minimum") + + fun asMaximum(): NewMaximum = maximum.getOrThrow("maximum") + + fun _json(): JsonValue? = _json + + fun accept(visitor: Visitor): T = + when { + percentageDiscount != null -> + visitor.visitPercentageDiscount(percentageDiscount) + usageDiscount != null -> visitor.visitUsageDiscount(usageDiscount) + amountDiscount != null -> visitor.visitAmountDiscount(amountDiscount) + minimum != null -> visitor.visitMinimum(minimum) + maximum != null -> visitor.visitMaximum(maximum) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Adjustment = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitPercentageDiscount( + percentageDiscount: NewPercentageDiscount + ) { + percentageDiscount.validate() + } + + override fun visitUsageDiscount(usageDiscount: NewUsageDiscount) { + usageDiscount.validate() + } + + override fun visitAmountDiscount(amountDiscount: NewAmountDiscount) { + amountDiscount.validate() + } + + override fun visitMinimum(minimum: NewMinimum) { + minimum.validate() + } + + override fun visitMaximum(maximum: NewMaximum) { + maximum.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitPercentageDiscount( + percentageDiscount: NewPercentageDiscount + ) = percentageDiscount.validity() + + override fun visitUsageDiscount(usageDiscount: NewUsageDiscount) = + usageDiscount.validity() + + override fun visitAmountDiscount(amountDiscount: NewAmountDiscount) = + amountDiscount.validity() + + override fun visitMinimum(minimum: NewMinimum) = minimum.validity() + + override fun visitMaximum(maximum: NewMaximum) = maximum.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Adjustment && + percentageDiscount == other.percentageDiscount && + usageDiscount == other.usageDiscount && + amountDiscount == other.amountDiscount && + minimum == other.minimum && + maximum == other.maximum + } + + override fun hashCode(): Int = + Objects.hash(percentageDiscount, usageDiscount, amountDiscount, minimum, maximum) + + override fun toString(): String = + when { + percentageDiscount != null -> + "Adjustment{percentageDiscount=$percentageDiscount}" + usageDiscount != null -> "Adjustment{usageDiscount=$usageDiscount}" + amountDiscount != null -> "Adjustment{amountDiscount=$amountDiscount}" + minimum != null -> "Adjustment{minimum=$minimum}" + maximum != null -> "Adjustment{maximum=$maximum}" + _json != null -> "Adjustment{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Adjustment") + } + + companion object { + + fun ofPercentageDiscount(percentageDiscount: NewPercentageDiscount) = + Adjustment(percentageDiscount = percentageDiscount) + + fun ofUsageDiscount(usageDiscount: NewUsageDiscount) = + Adjustment(usageDiscount = usageDiscount) + + fun ofAmountDiscount(amountDiscount: NewAmountDiscount) = + Adjustment(amountDiscount = amountDiscount) + + fun ofMinimum(minimum: NewMinimum) = Adjustment(minimum = minimum) + + fun ofMaximum(maximum: NewMaximum) = Adjustment(maximum = maximum) + } + + /** + * An interface that defines how to map each variant of [Adjustment] to a value of type + * [T]. + */ + interface Visitor { + + fun visitPercentageDiscount(percentageDiscount: NewPercentageDiscount): T + + fun visitUsageDiscount(usageDiscount: NewUsageDiscount): T + + fun visitAmountDiscount(amountDiscount: NewAmountDiscount): T + + fun visitMinimum(minimum: NewMinimum): T + + fun visitMaximum(maximum: NewMaximum): T + + /** + * Maps an unknown variant of [Adjustment] to a value of type [T]. + * + * An instance of [Adjustment] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the + * SDK is unaware of. + * + * @throws OrbInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw OrbInvalidDataException("Unknown Adjustment: $json") + } + } + + internal class Deserializer : BaseDeserializer(Adjustment::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Adjustment { + val json = JsonValue.fromJsonNode(node) + val adjustmentType = json.asObject()?.get("adjustment_type")?.asString() + + when (adjustmentType) { + "percentage_discount" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Adjustment(percentageDiscount = it, _json = json) } + ?: Adjustment(_json = json) + } + "usage_discount" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(usageDiscount = it, _json = json) + } ?: Adjustment(_json = json) + } + "amount_discount" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(amountDiscount = it, _json = json) + } ?: Adjustment(_json = json) + } + "minimum" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(minimum = it, _json = json) + } ?: Adjustment(_json = json) + } + "maximum" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(maximum = it, _json = json) + } ?: Adjustment(_json = json) + } + } + + return Adjustment(_json = json) + } + } + + internal class Serializer : BaseSerializer(Adjustment::class) { + + override fun serialize( + value: Adjustment, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.percentageDiscount != null -> + generator.writeObject(value.percentageDiscount) + value.usageDiscount != null -> generator.writeObject(value.usageDiscount) + value.amountDiscount != null -> generator.writeObject(value.amountDiscount) + value.minimum != null -> generator.writeObject(value.minimum) + value.maximum != null -> generator.writeObject(value.maximum) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Adjustment") + } + } + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ReplaceAdjustment && + adjustment == other.adjustment && + replacesAdjustmentId == other.replacesAdjustmentId && + planPhaseOrder == other.planPhaseOrder && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(adjustment, replacesAdjustmentId, planPhaseOrder, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ReplaceAdjustment{adjustment=$adjustment, replacesAdjustmentId=$replacesAdjustmentId, planPhaseOrder=$planPhaseOrder, additionalProperties=$additionalProperties}" + } + + class ReplacePrice + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val replacesPriceId: JsonField, + private val allocationPrice: JsonField, + private val planPhaseOrder: JsonField, + private val price: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("replaces_price_id") + @ExcludeMissing + replacesPriceId: JsonField = JsonMissing.of(), + @JsonProperty("allocation_price") + @ExcludeMissing + allocationPrice: JsonField = JsonMissing.of(), + @JsonProperty("plan_phase_order") + @ExcludeMissing + planPhaseOrder: JsonField = JsonMissing.of(), + @JsonProperty("price") @ExcludeMissing price: JsonField = JsonMissing.of(), + ) : this(replacesPriceId, allocationPrice, planPhaseOrder, price, mutableMapOf()) + + /** + * The id of the price on the plan to replace in the plan. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun replacesPriceId(): String = replacesPriceId.getRequired("replaces_price_id") + + /** + * The allocation price to add to the plan. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun allocationPrice(): NewAllocationPrice? = allocationPrice.getNullable("allocation_price") + + /** + * The phase to replace this price from. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun planPhaseOrder(): Long? = planPhaseOrder.getNullable("plan_phase_order") + + /** + * New plan price request body params. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun price(): Price? = price.getNullable("price") + + /** + * Returns the raw JSON value of [replacesPriceId]. + * + * Unlike [replacesPriceId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("replaces_price_id") + @ExcludeMissing + fun _replacesPriceId(): JsonField = replacesPriceId + + /** + * Returns the raw JSON value of [allocationPrice]. + * + * Unlike [allocationPrice], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("allocation_price") + @ExcludeMissing + fun _allocationPrice(): JsonField = allocationPrice + + /** + * Returns the raw JSON value of [planPhaseOrder]. + * + * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder + + /** + * Returns the raw JSON value of [price]. + * + * Unlike [price], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("price") @ExcludeMissing fun _price(): JsonField = price + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ReplacePrice]. + * + * The following fields are required: + * ```kotlin + * .replacesPriceId() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [ReplacePrice]. */ + class Builder internal constructor() { + + private var replacesPriceId: JsonField? = null + private var allocationPrice: JsonField = JsonMissing.of() + private var planPhaseOrder: JsonField = JsonMissing.of() + private var price: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(replacePrice: ReplacePrice) = apply { + replacesPriceId = replacePrice.replacesPriceId + allocationPrice = replacePrice.allocationPrice + planPhaseOrder = replacePrice.planPhaseOrder + price = replacePrice.price + additionalProperties = replacePrice.additionalProperties.toMutableMap() + } + + /** The id of the price on the plan to replace in the plan. */ + fun replacesPriceId(replacesPriceId: String) = + replacesPriceId(JsonField.of(replacesPriceId)) + + /** + * Sets [Builder.replacesPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.replacesPriceId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun replacesPriceId(replacesPriceId: JsonField) = apply { + this.replacesPriceId = replacesPriceId + } + + /** The allocation price to add to the plan. */ + fun allocationPrice(allocationPrice: NewAllocationPrice?) = + allocationPrice(JsonField.ofNullable(allocationPrice)) + + /** + * Sets [Builder.allocationPrice] to an arbitrary JSON value. + * + * You should usually call [Builder.allocationPrice] with a well-typed + * [NewAllocationPrice] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun allocationPrice(allocationPrice: JsonField) = apply { + this.allocationPrice = allocationPrice + } + + /** The phase to replace this price from. */ + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + + /** + * Alias for [Builder.planPhaseOrder]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + + /** + * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. + * + * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun planPhaseOrder(planPhaseOrder: JsonField) = apply { + this.planPhaseOrder = planPhaseOrder + } + + /** New plan price request body params. */ + fun price(price: Price?) = price(JsonField.ofNullable(price)) + + /** + * Sets [Builder.price] to an arbitrary JSON value. + * + * You should usually call [Builder.price] with a well-typed [Price] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun price(price: JsonField) = apply { this.price = price } + + /** Alias for calling [price] with `Price.ofUnit(unit)`. */ + fun price(unit: NewPlanUnitPrice) = price(Price.ofUnit(unit)) + + /** Alias for calling [price] with `Price.ofTiered(tiered)`. */ + fun price(tiered: NewPlanTieredPrice) = price(Price.ofTiered(tiered)) + + /** Alias for calling [price] with `Price.ofBulk(bulk)`. */ + fun price(bulk: NewPlanBulkPrice) = price(Price.ofBulk(bulk)) + + /** Alias for calling [price] with `Price.ofPackage(package_)`. */ + fun price(package_: NewPlanPackagePrice) = price(Price.ofPackage(package_)) + + /** Alias for calling [price] with `Price.ofMatrix(matrix)`. */ + fun price(matrix: NewPlanMatrixPrice) = price(Price.ofMatrix(matrix)) + + /** + * Alias for calling [price] with `Price.ofThresholdTotalAmount(thresholdTotalAmount)`. + */ + fun price(thresholdTotalAmount: NewPlanThresholdTotalAmountPrice) = + price(Price.ofThresholdTotalAmount(thresholdTotalAmount)) + + /** Alias for calling [price] with `Price.ofTieredPackage(tieredPackage)`. */ + fun price(tieredPackage: NewPlanTieredPackagePrice) = + price(Price.ofTieredPackage(tieredPackage)) + + /** Alias for calling [price] with `Price.ofTieredWithMinimum(tieredWithMinimum)`. */ + fun price(tieredWithMinimum: NewPlanTieredWithMinimumPrice) = + price(Price.ofTieredWithMinimum(tieredWithMinimum)) + + /** Alias for calling [price] with `Price.ofGroupedTiered(groupedTiered)`. */ + fun price(groupedTiered: NewPlanGroupedTieredPrice) = + price(Price.ofGroupedTiered(groupedTiered)) + + /** + * Alias for calling [price] with + * `Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)`. + */ + fun price(tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice) = + price(Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)) + + /** + * Alias for calling [price] with + * `Price.ofPackageWithAllocation(packageWithAllocation)`. + */ + fun price(packageWithAllocation: NewPlanPackageWithAllocationPrice) = + price(Price.ofPackageWithAllocation(packageWithAllocation)) + + /** Alias for calling [price] with `Price.ofUnitWithPercent(unitWithPercent)`. */ + fun price(unitWithPercent: NewPlanUnitWithPercentPrice) = + price(Price.ofUnitWithPercent(unitWithPercent)) + + /** + * Alias for calling [price] with `Price.ofMatrixWithAllocation(matrixWithAllocation)`. + */ + fun price(matrixWithAllocation: NewPlanMatrixWithAllocationPrice) = + price(Price.ofMatrixWithAllocation(matrixWithAllocation)) + + /** + * Alias for calling [price] with `Price.ofTieredWithProration(tieredWithProration)`. + */ + fun price(tieredWithProration: Price.TieredWithProration) = + price(Price.ofTieredWithProration(tieredWithProration)) + + /** Alias for calling [price] with `Price.ofUnitWithProration(unitWithProration)`. */ + fun price(unitWithProration: NewPlanUnitWithProrationPrice) = + price(Price.ofUnitWithProration(unitWithProration)) + + /** Alias for calling [price] with `Price.ofGroupedAllocation(groupedAllocation)`. */ + fun price(groupedAllocation: NewPlanGroupedAllocationPrice) = + price(Price.ofGroupedAllocation(groupedAllocation)) + + /** Alias for calling [price] with `Price.ofBulkWithProration(bulkWithProration)`. */ + fun price(bulkWithProration: NewPlanBulkWithProrationPrice) = + price(Price.ofBulkWithProration(bulkWithProration)) + + /** + * Alias for calling [price] with + * `Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)`. + */ + fun price(groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice) = + price(Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)) + + /** + * Alias for calling [price] with + * `Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)`. + */ + fun price(groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice) = + price(Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)) + + /** + * Alias for calling [price] with + * `Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)`. + */ + fun price(groupedWithMinMaxThresholds: Price.GroupedWithMinMaxThresholds) = + price(Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)) + + /** + * Alias for calling [price] with + * `Price.ofMatrixWithDisplayName(matrixWithDisplayName)`. + */ + fun price(matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice) = + price(Price.ofMatrixWithDisplayName(matrixWithDisplayName)) + + /** + * Alias for calling [price] with `Price.ofGroupedTieredPackage(groupedTieredPackage)`. + */ + fun price(groupedTieredPackage: NewPlanGroupedTieredPackagePrice) = + price(Price.ofGroupedTieredPackage(groupedTieredPackage)) + + /** + * Alias for calling [price] with + * `Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)`. + */ + fun price(maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice) = + price(Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)) + + /** + * Alias for calling [price] with + * `Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)`. + */ + fun price(scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice) = + price(Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)) + + /** + * Alias for calling [price] with + * `Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)`. + */ + fun price( + scalableMatrixWithTieredPricing: NewPlanScalableMatrixWithTieredPricingPrice + ) = price(Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)) + + /** + * Alias for calling [price] with + * `Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)`. + */ + fun price(cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice) = + price(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) + + /** Alias for calling [price] with `Price.ofMinimum(minimum)`. */ + fun price(minimum: NewPlanMinimumCompositePrice) = price(Price.ofMinimum(minimum)) + + /** Alias for calling [price] with `Price.ofPercent(percent)`. */ + fun price(percent: Price.Percent) = price(Price.ofPercent(percent)) + + /** Alias for calling [price] with `Price.ofEventOutput(eventOutput)`. */ + fun price(eventOutput: Price.EventOutput) = price(Price.ofEventOutput(eventOutput)) + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ReplacePrice]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .replacesPriceId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ReplacePrice = + ReplacePrice( + checkRequired("replacesPriceId", replacesPriceId), + allocationPrice, + planPhaseOrder, + price, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ReplacePrice = apply { + if (validated) { + return@apply + } + + replacesPriceId() + allocationPrice()?.validate() + planPhaseOrder() + price()?.validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (replacesPriceId.asKnown() == null) 0 else 1) + + (allocationPrice.asKnown()?.validity() ?: 0) + + (if (planPhaseOrder.asKnown() == null) 0 else 1) + + (price.asKnown()?.validity() ?: 0) + + /** New plan price request body params. */ + @JsonDeserialize(using = Price.Deserializer::class) + @JsonSerialize(using = Price.Serializer::class) + class Price + private constructor( + private val unit: NewPlanUnitPrice? = null, + private val tiered: NewPlanTieredPrice? = null, + private val bulk: NewPlanBulkPrice? = null, + private val package_: NewPlanPackagePrice? = null, + private val matrix: NewPlanMatrixPrice? = null, + private val thresholdTotalAmount: NewPlanThresholdTotalAmountPrice? = null, + private val tieredPackage: NewPlanTieredPackagePrice? = null, + private val tieredWithMinimum: NewPlanTieredWithMinimumPrice? = null, + private val groupedTiered: NewPlanGroupedTieredPrice? = null, + private val tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice? = null, + private val packageWithAllocation: NewPlanPackageWithAllocationPrice? = null, + private val unitWithPercent: NewPlanUnitWithPercentPrice? = null, + private val matrixWithAllocation: NewPlanMatrixWithAllocationPrice? = null, + private val tieredWithProration: TieredWithProration? = null, + private val unitWithProration: NewPlanUnitWithProrationPrice? = null, + private val groupedAllocation: NewPlanGroupedAllocationPrice? = null, + private val bulkWithProration: NewPlanBulkWithProrationPrice? = null, + private val groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice? = null, + private val groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice? = null, + private val groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds? = null, + private val matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice? = null, + private val groupedTieredPackage: NewPlanGroupedTieredPackagePrice? = null, + private val maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice? = null, + private val scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice? = + null, + private val scalableMatrixWithTieredPricing: + NewPlanScalableMatrixWithTieredPricingPrice? = + null, + private val cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice? = null, + private val minimum: NewPlanMinimumCompositePrice? = null, + private val percent: Percent? = null, + private val eventOutput: EventOutput? = null, + private val _json: JsonValue? = null, + ) { + + fun unit(): NewPlanUnitPrice? = unit + + fun tiered(): NewPlanTieredPrice? = tiered + + fun bulk(): NewPlanBulkPrice? = bulk + + fun package_(): NewPlanPackagePrice? = package_ + + fun matrix(): NewPlanMatrixPrice? = matrix + + fun thresholdTotalAmount(): NewPlanThresholdTotalAmountPrice? = thresholdTotalAmount + + fun tieredPackage(): NewPlanTieredPackagePrice? = tieredPackage + + fun tieredWithMinimum(): NewPlanTieredWithMinimumPrice? = tieredWithMinimum + + fun groupedTiered(): NewPlanGroupedTieredPrice? = groupedTiered + + fun tieredPackageWithMinimum(): NewPlanTieredPackageWithMinimumPrice? = + tieredPackageWithMinimum + + fun packageWithAllocation(): NewPlanPackageWithAllocationPrice? = packageWithAllocation + + fun unitWithPercent(): NewPlanUnitWithPercentPrice? = unitWithPercent + + fun matrixWithAllocation(): NewPlanMatrixWithAllocationPrice? = matrixWithAllocation + + fun tieredWithProration(): TieredWithProration? = tieredWithProration + + fun unitWithProration(): NewPlanUnitWithProrationPrice? = unitWithProration + + fun groupedAllocation(): NewPlanGroupedAllocationPrice? = groupedAllocation + + fun bulkWithProration(): NewPlanBulkWithProrationPrice? = bulkWithProration + + fun groupedWithProratedMinimum(): NewPlanGroupedWithProratedMinimumPrice? = + groupedWithProratedMinimum + + fun groupedWithMeteredMinimum(): NewPlanGroupedWithMeteredMinimumPrice? = + groupedWithMeteredMinimum + + fun groupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds? = + groupedWithMinMaxThresholds + + fun matrixWithDisplayName(): NewPlanMatrixWithDisplayNamePrice? = matrixWithDisplayName + + fun groupedTieredPackage(): NewPlanGroupedTieredPackagePrice? = groupedTieredPackage + + fun maxGroupTieredPackage(): NewPlanMaxGroupTieredPackagePrice? = maxGroupTieredPackage + + fun scalableMatrixWithUnitPricing(): NewPlanScalableMatrixWithUnitPricingPrice? = + scalableMatrixWithUnitPricing + + fun scalableMatrixWithTieredPricing(): NewPlanScalableMatrixWithTieredPricingPrice? = + scalableMatrixWithTieredPricing + + fun cumulativeGroupedBulk(): NewPlanCumulativeGroupedBulkPrice? = cumulativeGroupedBulk + + fun minimum(): NewPlanMinimumCompositePrice? = minimum + + fun percent(): Percent? = percent + + fun eventOutput(): EventOutput? = eventOutput + + fun isUnit(): Boolean = unit != null + + fun isTiered(): Boolean = tiered != null + + fun isBulk(): Boolean = bulk != null + + fun isPackage(): Boolean = package_ != null + + fun isMatrix(): Boolean = matrix != null + + fun isThresholdTotalAmount(): Boolean = thresholdTotalAmount != null + + fun isTieredPackage(): Boolean = tieredPackage != null + + fun isTieredWithMinimum(): Boolean = tieredWithMinimum != null + + fun isGroupedTiered(): Boolean = groupedTiered != null + + fun isTieredPackageWithMinimum(): Boolean = tieredPackageWithMinimum != null + + fun isPackageWithAllocation(): Boolean = packageWithAllocation != null + + fun isUnitWithPercent(): Boolean = unitWithPercent != null + + fun isMatrixWithAllocation(): Boolean = matrixWithAllocation != null + + fun isTieredWithProration(): Boolean = tieredWithProration != null + + fun isUnitWithProration(): Boolean = unitWithProration != null + + fun isGroupedAllocation(): Boolean = groupedAllocation != null + + fun isBulkWithProration(): Boolean = bulkWithProration != null + + fun isGroupedWithProratedMinimum(): Boolean = groupedWithProratedMinimum != null + + fun isGroupedWithMeteredMinimum(): Boolean = groupedWithMeteredMinimum != null + + fun isGroupedWithMinMaxThresholds(): Boolean = groupedWithMinMaxThresholds != null + + fun isMatrixWithDisplayName(): Boolean = matrixWithDisplayName != null + + fun isGroupedTieredPackage(): Boolean = groupedTieredPackage != null + + fun isMaxGroupTieredPackage(): Boolean = maxGroupTieredPackage != null + + fun isScalableMatrixWithUnitPricing(): Boolean = scalableMatrixWithUnitPricing != null + + fun isScalableMatrixWithTieredPricing(): Boolean = + scalableMatrixWithTieredPricing != null + + fun isCumulativeGroupedBulk(): Boolean = cumulativeGroupedBulk != null + + fun isMinimum(): Boolean = minimum != null + + fun isPercent(): Boolean = percent != null + + fun isEventOutput(): Boolean = eventOutput != null + + fun asUnit(): NewPlanUnitPrice = unit.getOrThrow("unit") + + fun asTiered(): NewPlanTieredPrice = tiered.getOrThrow("tiered") + + fun asBulk(): NewPlanBulkPrice = bulk.getOrThrow("bulk") + + fun asPackage(): NewPlanPackagePrice = package_.getOrThrow("package_") + + fun asMatrix(): NewPlanMatrixPrice = matrix.getOrThrow("matrix") + + fun asThresholdTotalAmount(): NewPlanThresholdTotalAmountPrice = + thresholdTotalAmount.getOrThrow("thresholdTotalAmount") + + fun asTieredPackage(): NewPlanTieredPackagePrice = + tieredPackage.getOrThrow("tieredPackage") + + fun asTieredWithMinimum(): NewPlanTieredWithMinimumPrice = + tieredWithMinimum.getOrThrow("tieredWithMinimum") + + fun asGroupedTiered(): NewPlanGroupedTieredPrice = + groupedTiered.getOrThrow("groupedTiered") + + fun asTieredPackageWithMinimum(): NewPlanTieredPackageWithMinimumPrice = + tieredPackageWithMinimum.getOrThrow("tieredPackageWithMinimum") + + fun asPackageWithAllocation(): NewPlanPackageWithAllocationPrice = + packageWithAllocation.getOrThrow("packageWithAllocation") + + fun asUnitWithPercent(): NewPlanUnitWithPercentPrice = + unitWithPercent.getOrThrow("unitWithPercent") + + fun asMatrixWithAllocation(): NewPlanMatrixWithAllocationPrice = + matrixWithAllocation.getOrThrow("matrixWithAllocation") + + fun asTieredWithProration(): TieredWithProration = + tieredWithProration.getOrThrow("tieredWithProration") + + fun asUnitWithProration(): NewPlanUnitWithProrationPrice = + unitWithProration.getOrThrow("unitWithProration") + + fun asGroupedAllocation(): NewPlanGroupedAllocationPrice = + groupedAllocation.getOrThrow("groupedAllocation") + + fun asBulkWithProration(): NewPlanBulkWithProrationPrice = + bulkWithProration.getOrThrow("bulkWithProration") + + fun asGroupedWithProratedMinimum(): NewPlanGroupedWithProratedMinimumPrice = + groupedWithProratedMinimum.getOrThrow("groupedWithProratedMinimum") + + fun asGroupedWithMeteredMinimum(): NewPlanGroupedWithMeteredMinimumPrice = + groupedWithMeteredMinimum.getOrThrow("groupedWithMeteredMinimum") + + fun asGroupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds = + groupedWithMinMaxThresholds.getOrThrow("groupedWithMinMaxThresholds") + + fun asMatrixWithDisplayName(): NewPlanMatrixWithDisplayNamePrice = + matrixWithDisplayName.getOrThrow("matrixWithDisplayName") + + fun asGroupedTieredPackage(): NewPlanGroupedTieredPackagePrice = + groupedTieredPackage.getOrThrow("groupedTieredPackage") + + fun asMaxGroupTieredPackage(): NewPlanMaxGroupTieredPackagePrice = + maxGroupTieredPackage.getOrThrow("maxGroupTieredPackage") + + fun asScalableMatrixWithUnitPricing(): NewPlanScalableMatrixWithUnitPricingPrice = + scalableMatrixWithUnitPricing.getOrThrow("scalableMatrixWithUnitPricing") + + fun asScalableMatrixWithTieredPricing(): NewPlanScalableMatrixWithTieredPricingPrice = + scalableMatrixWithTieredPricing.getOrThrow("scalableMatrixWithTieredPricing") + + fun asCumulativeGroupedBulk(): NewPlanCumulativeGroupedBulkPrice = + cumulativeGroupedBulk.getOrThrow("cumulativeGroupedBulk") + + fun asMinimum(): NewPlanMinimumCompositePrice = minimum.getOrThrow("minimum") + + fun asPercent(): Percent = percent.getOrThrow("percent") + + fun asEventOutput(): EventOutput = eventOutput.getOrThrow("eventOutput") + + fun _json(): JsonValue? = _json + + fun accept(visitor: Visitor): T = + when { + unit != null -> visitor.visitUnit(unit) + tiered != null -> visitor.visitTiered(tiered) + bulk != null -> visitor.visitBulk(bulk) + package_ != null -> visitor.visitPackage(package_) + matrix != null -> visitor.visitMatrix(matrix) + thresholdTotalAmount != null -> + visitor.visitThresholdTotalAmount(thresholdTotalAmount) + tieredPackage != null -> visitor.visitTieredPackage(tieredPackage) + tieredWithMinimum != null -> visitor.visitTieredWithMinimum(tieredWithMinimum) + groupedTiered != null -> visitor.visitGroupedTiered(groupedTiered) + tieredPackageWithMinimum != null -> + visitor.visitTieredPackageWithMinimum(tieredPackageWithMinimum) + packageWithAllocation != null -> + visitor.visitPackageWithAllocation(packageWithAllocation) + unitWithPercent != null -> visitor.visitUnitWithPercent(unitWithPercent) + matrixWithAllocation != null -> + visitor.visitMatrixWithAllocation(matrixWithAllocation) + tieredWithProration != null -> + visitor.visitTieredWithProration(tieredWithProration) + unitWithProration != null -> visitor.visitUnitWithProration(unitWithProration) + groupedAllocation != null -> visitor.visitGroupedAllocation(groupedAllocation) + bulkWithProration != null -> visitor.visitBulkWithProration(bulkWithProration) + groupedWithProratedMinimum != null -> + visitor.visitGroupedWithProratedMinimum(groupedWithProratedMinimum) + groupedWithMeteredMinimum != null -> + visitor.visitGroupedWithMeteredMinimum(groupedWithMeteredMinimum) + groupedWithMinMaxThresholds != null -> + visitor.visitGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds) + matrixWithDisplayName != null -> + visitor.visitMatrixWithDisplayName(matrixWithDisplayName) + groupedTieredPackage != null -> + visitor.visitGroupedTieredPackage(groupedTieredPackage) + maxGroupTieredPackage != null -> + visitor.visitMaxGroupTieredPackage(maxGroupTieredPackage) + scalableMatrixWithUnitPricing != null -> + visitor.visitScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing) + scalableMatrixWithTieredPricing != null -> + visitor.visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing + ) + cumulativeGroupedBulk != null -> + visitor.visitCumulativeGroupedBulk(cumulativeGroupedBulk) + minimum != null -> visitor.visitMinimum(minimum) + percent != null -> visitor.visitPercent(percent) + eventOutput != null -> visitor.visitEventOutput(eventOutput) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Price = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitUnit(unit: NewPlanUnitPrice) { + unit.validate() + } + + override fun visitTiered(tiered: NewPlanTieredPrice) { + tiered.validate() + } + + override fun visitBulk(bulk: NewPlanBulkPrice) { + bulk.validate() + } + + override fun visitPackage(package_: NewPlanPackagePrice) { + package_.validate() + } + + override fun visitMatrix(matrix: NewPlanMatrixPrice) { + matrix.validate() + } + + override fun visitThresholdTotalAmount( + thresholdTotalAmount: NewPlanThresholdTotalAmountPrice + ) { + thresholdTotalAmount.validate() + } + + override fun visitTieredPackage(tieredPackage: NewPlanTieredPackagePrice) { + tieredPackage.validate() + } + + override fun visitTieredWithMinimum( + tieredWithMinimum: NewPlanTieredWithMinimumPrice + ) { + tieredWithMinimum.validate() + } + + override fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) { + groupedTiered.validate() + } + + override fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice + ) { + tieredPackageWithMinimum.validate() + } + + override fun visitPackageWithAllocation( + packageWithAllocation: NewPlanPackageWithAllocationPrice + ) { + packageWithAllocation.validate() + } + + override fun visitUnitWithPercent( + unitWithPercent: NewPlanUnitWithPercentPrice + ) { + unitWithPercent.validate() + } + + override fun visitMatrixWithAllocation( + matrixWithAllocation: NewPlanMatrixWithAllocationPrice + ) { + matrixWithAllocation.validate() + } + + override fun visitTieredWithProration( + tieredWithProration: TieredWithProration + ) { + tieredWithProration.validate() + } + + override fun visitUnitWithProration( + unitWithProration: NewPlanUnitWithProrationPrice + ) { + unitWithProration.validate() + } + + override fun visitGroupedAllocation( + groupedAllocation: NewPlanGroupedAllocationPrice + ) { + groupedAllocation.validate() + } + + override fun visitBulkWithProration( + bulkWithProration: NewPlanBulkWithProrationPrice + ) { + bulkWithProration.validate() + } + + override fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice + ) { + groupedWithProratedMinimum.validate() + } + + override fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice + ) { + groupedWithMeteredMinimum.validate() + } + + override fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) { + groupedWithMinMaxThresholds.validate() + } + + override fun visitMatrixWithDisplayName( + matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice + ) { + matrixWithDisplayName.validate() + } + + override fun visitGroupedTieredPackage( + groupedTieredPackage: NewPlanGroupedTieredPackagePrice + ) { + groupedTieredPackage.validate() + } + + override fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice + ) { + maxGroupTieredPackage.validate() + } + + override fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice + ) { + scalableMatrixWithUnitPricing.validate() + } + + override fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: + NewPlanScalableMatrixWithTieredPricingPrice + ) { + scalableMatrixWithTieredPricing.validate() + } + + override fun visitCumulativeGroupedBulk( + cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice + ) { + cumulativeGroupedBulk.validate() + } + + override fun visitMinimum(minimum: NewPlanMinimumCompositePrice) { + minimum.validate() + } + + override fun visitPercent(percent: Percent) { + percent.validate() + } + + override fun visitEventOutput(eventOutput: EventOutput) { + eventOutput.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitUnit(unit: NewPlanUnitPrice) = unit.validity() + + override fun visitTiered(tiered: NewPlanTieredPrice) = tiered.validity() + + override fun visitBulk(bulk: NewPlanBulkPrice) = bulk.validity() + + override fun visitPackage(package_: NewPlanPackagePrice) = + package_.validity() + + override fun visitMatrix(matrix: NewPlanMatrixPrice) = matrix.validity() + + override fun visitThresholdTotalAmount( + thresholdTotalAmount: NewPlanThresholdTotalAmountPrice + ) = thresholdTotalAmount.validity() + + override fun visitTieredPackage(tieredPackage: NewPlanTieredPackagePrice) = + tieredPackage.validity() + + override fun visitTieredWithMinimum( + tieredWithMinimum: NewPlanTieredWithMinimumPrice + ) = tieredWithMinimum.validity() + + override fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) = + groupedTiered.validity() + + override fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice + ) = tieredPackageWithMinimum.validity() + + override fun visitPackageWithAllocation( + packageWithAllocation: NewPlanPackageWithAllocationPrice + ) = packageWithAllocation.validity() + + override fun visitUnitWithPercent( + unitWithPercent: NewPlanUnitWithPercentPrice + ) = unitWithPercent.validity() + + override fun visitMatrixWithAllocation( + matrixWithAllocation: NewPlanMatrixWithAllocationPrice + ) = matrixWithAllocation.validity() + + override fun visitTieredWithProration( + tieredWithProration: TieredWithProration + ) = tieredWithProration.validity() + + override fun visitUnitWithProration( + unitWithProration: NewPlanUnitWithProrationPrice + ) = unitWithProration.validity() + + override fun visitGroupedAllocation( + groupedAllocation: NewPlanGroupedAllocationPrice + ) = groupedAllocation.validity() + + override fun visitBulkWithProration( + bulkWithProration: NewPlanBulkWithProrationPrice + ) = bulkWithProration.validity() + + override fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice + ) = groupedWithProratedMinimum.validity() + + override fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice + ) = groupedWithMeteredMinimum.validity() + + override fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) = groupedWithMinMaxThresholds.validity() + + override fun visitMatrixWithDisplayName( + matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice + ) = matrixWithDisplayName.validity() + + override fun visitGroupedTieredPackage( + groupedTieredPackage: NewPlanGroupedTieredPackagePrice + ) = groupedTieredPackage.validity() + + override fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice + ) = maxGroupTieredPackage.validity() + + override fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice + ) = scalableMatrixWithUnitPricing.validity() + + override fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: + NewPlanScalableMatrixWithTieredPricingPrice + ) = scalableMatrixWithTieredPricing.validity() + + override fun visitCumulativeGroupedBulk( + cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice + ) = cumulativeGroupedBulk.validity() + + override fun visitMinimum(minimum: NewPlanMinimumCompositePrice) = + minimum.validity() + + override fun visitPercent(percent: Percent) = percent.validity() + + override fun visitEventOutput(eventOutput: EventOutput) = + eventOutput.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Price && + unit == other.unit && + tiered == other.tiered && + bulk == other.bulk && + package_ == other.package_ && + matrix == other.matrix && + thresholdTotalAmount == other.thresholdTotalAmount && + tieredPackage == other.tieredPackage && + tieredWithMinimum == other.tieredWithMinimum && + groupedTiered == other.groupedTiered && + tieredPackageWithMinimum == other.tieredPackageWithMinimum && + packageWithAllocation == other.packageWithAllocation && + unitWithPercent == other.unitWithPercent && + matrixWithAllocation == other.matrixWithAllocation && + tieredWithProration == other.tieredWithProration && + unitWithProration == other.unitWithProration && + groupedAllocation == other.groupedAllocation && + bulkWithProration == other.bulkWithProration && + groupedWithProratedMinimum == other.groupedWithProratedMinimum && + groupedWithMeteredMinimum == other.groupedWithMeteredMinimum && + groupedWithMinMaxThresholds == other.groupedWithMinMaxThresholds && + matrixWithDisplayName == other.matrixWithDisplayName && + groupedTieredPackage == other.groupedTieredPackage && + maxGroupTieredPackage == other.maxGroupTieredPackage && + scalableMatrixWithUnitPricing == other.scalableMatrixWithUnitPricing && + scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && + cumulativeGroupedBulk == other.cumulativeGroupedBulk && + minimum == other.minimum && + percent == other.percent && + eventOutput == other.eventOutput + } + + override fun hashCode(): Int = + Objects.hash( + unit, + tiered, + bulk, + package_, + matrix, + thresholdTotalAmount, + tieredPackage, + tieredWithMinimum, + groupedTiered, + tieredPackageWithMinimum, + packageWithAllocation, + unitWithPercent, + matrixWithAllocation, + tieredWithProration, + unitWithProration, + groupedAllocation, + bulkWithProration, + groupedWithProratedMinimum, + groupedWithMeteredMinimum, + groupedWithMinMaxThresholds, + matrixWithDisplayName, + groupedTieredPackage, + maxGroupTieredPackage, + scalableMatrixWithUnitPricing, + scalableMatrixWithTieredPricing, + cumulativeGroupedBulk, + minimum, + percent, + eventOutput, + ) + + override fun toString(): String = + when { + unit != null -> "Price{unit=$unit}" + tiered != null -> "Price{tiered=$tiered}" + bulk != null -> "Price{bulk=$bulk}" + package_ != null -> "Price{package_=$package_}" + matrix != null -> "Price{matrix=$matrix}" + thresholdTotalAmount != null -> + "Price{thresholdTotalAmount=$thresholdTotalAmount}" + tieredPackage != null -> "Price{tieredPackage=$tieredPackage}" + tieredWithMinimum != null -> "Price{tieredWithMinimum=$tieredWithMinimum}" + groupedTiered != null -> "Price{groupedTiered=$groupedTiered}" + tieredPackageWithMinimum != null -> + "Price{tieredPackageWithMinimum=$tieredPackageWithMinimum}" + packageWithAllocation != null -> + "Price{packageWithAllocation=$packageWithAllocation}" + unitWithPercent != null -> "Price{unitWithPercent=$unitWithPercent}" + matrixWithAllocation != null -> + "Price{matrixWithAllocation=$matrixWithAllocation}" + tieredWithProration != null -> "Price{tieredWithProration=$tieredWithProration}" + unitWithProration != null -> "Price{unitWithProration=$unitWithProration}" + groupedAllocation != null -> "Price{groupedAllocation=$groupedAllocation}" + bulkWithProration != null -> "Price{bulkWithProration=$bulkWithProration}" + groupedWithProratedMinimum != null -> + "Price{groupedWithProratedMinimum=$groupedWithProratedMinimum}" + groupedWithMeteredMinimum != null -> + "Price{groupedWithMeteredMinimum=$groupedWithMeteredMinimum}" + groupedWithMinMaxThresholds != null -> + "Price{groupedWithMinMaxThresholds=$groupedWithMinMaxThresholds}" + matrixWithDisplayName != null -> + "Price{matrixWithDisplayName=$matrixWithDisplayName}" + groupedTieredPackage != null -> + "Price{groupedTieredPackage=$groupedTieredPackage}" + maxGroupTieredPackage != null -> + "Price{maxGroupTieredPackage=$maxGroupTieredPackage}" + scalableMatrixWithUnitPricing != null -> + "Price{scalableMatrixWithUnitPricing=$scalableMatrixWithUnitPricing}" + scalableMatrixWithTieredPricing != null -> + "Price{scalableMatrixWithTieredPricing=$scalableMatrixWithTieredPricing}" + cumulativeGroupedBulk != null -> + "Price{cumulativeGroupedBulk=$cumulativeGroupedBulk}" + minimum != null -> "Price{minimum=$minimum}" + percent != null -> "Price{percent=$percent}" + eventOutput != null -> "Price{eventOutput=$eventOutput}" + _json != null -> "Price{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Price") + } + + companion object { + + fun ofUnit(unit: NewPlanUnitPrice) = Price(unit = unit) + + fun ofTiered(tiered: NewPlanTieredPrice) = Price(tiered = tiered) + + fun ofBulk(bulk: NewPlanBulkPrice) = Price(bulk = bulk) + + fun ofPackage(package_: NewPlanPackagePrice) = Price(package_ = package_) + + fun ofMatrix(matrix: NewPlanMatrixPrice) = Price(matrix = matrix) + + fun ofThresholdTotalAmount(thresholdTotalAmount: NewPlanThresholdTotalAmountPrice) = + Price(thresholdTotalAmount = thresholdTotalAmount) + + fun ofTieredPackage(tieredPackage: NewPlanTieredPackagePrice) = + Price(tieredPackage = tieredPackage) + + fun ofTieredWithMinimum(tieredWithMinimum: NewPlanTieredWithMinimumPrice) = + Price(tieredWithMinimum = tieredWithMinimum) + + fun ofGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) = + Price(groupedTiered = groupedTiered) + + fun ofTieredPackageWithMinimum( + tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice + ) = Price(tieredPackageWithMinimum = tieredPackageWithMinimum) + + fun ofPackageWithAllocation( + packageWithAllocation: NewPlanPackageWithAllocationPrice + ) = Price(packageWithAllocation = packageWithAllocation) + + fun ofUnitWithPercent(unitWithPercent: NewPlanUnitWithPercentPrice) = + Price(unitWithPercent = unitWithPercent) + + fun ofMatrixWithAllocation(matrixWithAllocation: NewPlanMatrixWithAllocationPrice) = + Price(matrixWithAllocation = matrixWithAllocation) + + fun ofTieredWithProration(tieredWithProration: TieredWithProration) = + Price(tieredWithProration = tieredWithProration) + + fun ofUnitWithProration(unitWithProration: NewPlanUnitWithProrationPrice) = + Price(unitWithProration = unitWithProration) + + fun ofGroupedAllocation(groupedAllocation: NewPlanGroupedAllocationPrice) = + Price(groupedAllocation = groupedAllocation) + + fun ofBulkWithProration(bulkWithProration: NewPlanBulkWithProrationPrice) = + Price(bulkWithProration = bulkWithProration) + + fun ofGroupedWithProratedMinimum( + groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice + ) = Price(groupedWithProratedMinimum = groupedWithProratedMinimum) + + fun ofGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice + ) = Price(groupedWithMeteredMinimum = groupedWithMeteredMinimum) + + fun ofGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) = Price(groupedWithMinMaxThresholds = groupedWithMinMaxThresholds) + + fun ofMatrixWithDisplayName( + matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice + ) = Price(matrixWithDisplayName = matrixWithDisplayName) + + fun ofGroupedTieredPackage(groupedTieredPackage: NewPlanGroupedTieredPackagePrice) = + Price(groupedTieredPackage = groupedTieredPackage) + + fun ofMaxGroupTieredPackage( + maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice + ) = Price(maxGroupTieredPackage = maxGroupTieredPackage) + + fun ofScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice + ) = Price(scalableMatrixWithUnitPricing = scalableMatrixWithUnitPricing) + + fun ofScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: NewPlanScalableMatrixWithTieredPricingPrice + ) = Price(scalableMatrixWithTieredPricing = scalableMatrixWithTieredPricing) + + fun ofCumulativeGroupedBulk( + cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice + ) = Price(cumulativeGroupedBulk = cumulativeGroupedBulk) + + fun ofMinimum(minimum: NewPlanMinimumCompositePrice) = Price(minimum = minimum) + + fun ofPercent(percent: Percent) = Price(percent = percent) + + fun ofEventOutput(eventOutput: EventOutput) = Price(eventOutput = eventOutput) + } + + /** + * An interface that defines how to map each variant of [Price] to a value of type [T]. + */ + interface Visitor { + + fun visitUnit(unit: NewPlanUnitPrice): T + + fun visitTiered(tiered: NewPlanTieredPrice): T + + fun visitBulk(bulk: NewPlanBulkPrice): T + + fun visitPackage(package_: NewPlanPackagePrice): T + + fun visitMatrix(matrix: NewPlanMatrixPrice): T + + fun visitThresholdTotalAmount( + thresholdTotalAmount: NewPlanThresholdTotalAmountPrice + ): T + + fun visitTieredPackage(tieredPackage: NewPlanTieredPackagePrice): T + + fun visitTieredWithMinimum(tieredWithMinimum: NewPlanTieredWithMinimumPrice): T + + fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice): T + + fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice + ): T + + fun visitPackageWithAllocation( + packageWithAllocation: NewPlanPackageWithAllocationPrice + ): T + + fun visitUnitWithPercent(unitWithPercent: NewPlanUnitWithPercentPrice): T + + fun visitMatrixWithAllocation( + matrixWithAllocation: NewPlanMatrixWithAllocationPrice + ): T + + fun visitTieredWithProration(tieredWithProration: TieredWithProration): T + + fun visitUnitWithProration(unitWithProration: NewPlanUnitWithProrationPrice): T + + fun visitGroupedAllocation(groupedAllocation: NewPlanGroupedAllocationPrice): T + + fun visitBulkWithProration(bulkWithProration: NewPlanBulkWithProrationPrice): T + + fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice + ): T + + fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice + ): T + + fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ): T + + fun visitMatrixWithDisplayName( + matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice + ): T + + fun visitGroupedTieredPackage( + groupedTieredPackage: NewPlanGroupedTieredPackagePrice + ): T + + fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice + ): T + + fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice + ): T + + fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: NewPlanScalableMatrixWithTieredPricingPrice + ): T + + fun visitCumulativeGroupedBulk( + cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice + ): T + + fun visitMinimum(minimum: NewPlanMinimumCompositePrice): T + + fun visitPercent(percent: Percent): T + + fun visitEventOutput(eventOutput: EventOutput): T + + /** + * Maps an unknown variant of [Price] to a value of type [T]. + * + * An instance of [Price] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is + * unaware of. + * + * @throws OrbInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw OrbInvalidDataException("Unknown Price: $json") + } + } + + internal class Deserializer : BaseDeserializer(Price::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Price { + val json = JsonValue.fromJsonNode(node) + val modelType = json.asObject()?.get("model_type")?.asString() + + when (modelType) { + "unit" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(unit = it, _json = json) + } ?: Price(_json = json) + } + "tiered" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(tiered = it, _json = json) + } ?: Price(_json = json) + } + "bulk" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(bulk = it, _json = json) + } ?: Price(_json = json) + } + "package" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(package_ = it, _json = json) } ?: Price(_json = json) + } + "matrix" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(matrix = it, _json = json) + } ?: Price(_json = json) + } + "threshold_total_amount" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(thresholdTotalAmount = it, _json = json) } + ?: Price(_json = json) + } + "tiered_package" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(tieredPackage = it, _json = json) } + ?: Price(_json = json) + } + "tiered_with_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(tieredWithMinimum = it, _json = json) } + ?: Price(_json = json) + } + "grouped_tiered" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(groupedTiered = it, _json = json) } + ?: Price(_json = json) + } + "tiered_package_with_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(tieredPackageWithMinimum = it, _json = json) } + ?: Price(_json = json) + } + "package_with_allocation" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(packageWithAllocation = it, _json = json) } + ?: Price(_json = json) + } + "unit_with_percent" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(unitWithPercent = it, _json = json) } + ?: Price(_json = json) + } + "matrix_with_allocation" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(matrixWithAllocation = it, _json = json) } + ?: Price(_json = json) + } + "tiered_with_proration" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(tieredWithProration = it, _json = json) } + ?: Price(_json = json) + } + "unit_with_proration" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(unitWithProration = it, _json = json) } + ?: Price(_json = json) + } + "grouped_allocation" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedAllocation = it, _json = json) } + ?: Price(_json = json) + } + "bulk_with_proration" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(bulkWithProration = it, _json = json) } + ?: Price(_json = json) + } + "grouped_with_prorated_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedWithProratedMinimum = it, _json = json) } + ?: Price(_json = json) + } + "grouped_with_metered_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedWithMeteredMinimum = it, _json = json) } + ?: Price(_json = json) + } + "grouped_with_min_max_thresholds" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedWithMinMaxThresholds = it, _json = json) } + ?: Price(_json = json) + } + "matrix_with_display_name" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(matrixWithDisplayName = it, _json = json) } + ?: Price(_json = json) + } + "grouped_tiered_package" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedTieredPackage = it, _json = json) } + ?: Price(_json = json) + } + "max_group_tiered_package" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(maxGroupTieredPackage = it, _json = json) } + ?: Price(_json = json) + } + "scalable_matrix_with_unit_pricing" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(scalableMatrixWithUnitPricing = it, _json = json) } + ?: Price(_json = json) + } + "scalable_matrix_with_tiered_pricing" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(scalableMatrixWithTieredPricing = it, _json = json) } + ?: Price(_json = json) + } + "cumulative_grouped_bulk" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(cumulativeGroupedBulk = it, _json = json) } + ?: Price(_json = json) + } + "minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(minimum = it, _json = json) } ?: Price(_json = json) + } + "percent" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(percent = it, _json = json) + } ?: Price(_json = json) + } + "event_output" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(eventOutput = it, _json = json) + } ?: Price(_json = json) + } + } + + return Price(_json = json) + } + } + + internal class Serializer : BaseSerializer(Price::class) { + + override fun serialize( + value: Price, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.unit != null -> generator.writeObject(value.unit) + value.tiered != null -> generator.writeObject(value.tiered) + value.bulk != null -> generator.writeObject(value.bulk) + value.package_ != null -> generator.writeObject(value.package_) + value.matrix != null -> generator.writeObject(value.matrix) + value.thresholdTotalAmount != null -> + generator.writeObject(value.thresholdTotalAmount) + value.tieredPackage != null -> generator.writeObject(value.tieredPackage) + value.tieredWithMinimum != null -> + generator.writeObject(value.tieredWithMinimum) + value.groupedTiered != null -> generator.writeObject(value.groupedTiered) + value.tieredPackageWithMinimum != null -> + generator.writeObject(value.tieredPackageWithMinimum) + value.packageWithAllocation != null -> + generator.writeObject(value.packageWithAllocation) + value.unitWithPercent != null -> + generator.writeObject(value.unitWithPercent) + value.matrixWithAllocation != null -> + generator.writeObject(value.matrixWithAllocation) + value.tieredWithProration != null -> + generator.writeObject(value.tieredWithProration) + value.unitWithProration != null -> + generator.writeObject(value.unitWithProration) + value.groupedAllocation != null -> + generator.writeObject(value.groupedAllocation) + value.bulkWithProration != null -> + generator.writeObject(value.bulkWithProration) + value.groupedWithProratedMinimum != null -> + generator.writeObject(value.groupedWithProratedMinimum) + value.groupedWithMeteredMinimum != null -> + generator.writeObject(value.groupedWithMeteredMinimum) + value.groupedWithMinMaxThresholds != null -> + generator.writeObject(value.groupedWithMinMaxThresholds) + value.matrixWithDisplayName != null -> + generator.writeObject(value.matrixWithDisplayName) + value.groupedTieredPackage != null -> + generator.writeObject(value.groupedTieredPackage) + value.maxGroupTieredPackage != null -> + generator.writeObject(value.maxGroupTieredPackage) + value.scalableMatrixWithUnitPricing != null -> + generator.writeObject(value.scalableMatrixWithUnitPricing) + value.scalableMatrixWithTieredPricing != null -> + generator.writeObject(value.scalableMatrixWithTieredPricing) + value.cumulativeGroupedBulk != null -> + generator.writeObject(value.cumulativeGroupedBulk) + value.minimum != null -> generator.writeObject(value.minimum) + value.percent != null -> generator.writeObject(value.percent) + value.eventOutput != null -> generator.writeObject(value.eventOutput) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Price") + } + } + } - fun groupedWithMeteredMinimum(): NewPlanGroupedWithMeteredMinimumPrice? = - groupedWithMeteredMinimum + class TieredWithProration + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val tieredWithProrationConfig: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { - fun groupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds? = - groupedWithMinMaxThresholds + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("tiered_with_proration_config") + @ExcludeMissing + tieredWithProrationConfig: JsonField = + JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + modelType, + name, + tieredWithProrationConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + mutableMapOf(), + ) - fun matrixWithDisplayName(): NewPlanMatrixWithDisplayNamePrice? = matrixWithDisplayName + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") - fun groupedTieredPackage(): NewPlanGroupedTieredPackagePrice? = groupedTieredPackage + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") - fun maxGroupTieredPackage(): NewPlanMaxGroupTieredPackagePrice? = maxGroupTieredPackage + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("tiered_with_proration") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType - fun scalableMatrixWithUnitPricing(): NewPlanScalableMatrixWithUnitPricingPrice? = - scalableMatrixWithUnitPricing + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") - fun scalableMatrixWithTieredPricing(): NewPlanScalableMatrixWithTieredPricingPrice? = - scalableMatrixWithTieredPricing + /** + * Configuration for tiered_with_proration pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun tieredWithProrationConfig(): TieredWithProrationConfig = + tieredWithProrationConfig.getRequired("tiered_with_proration_config") - fun cumulativeGroupedBulk(): NewPlanCumulativeGroupedBulkPrice? = cumulativeGroupedBulk + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = billableMetricId.getNullable("billable_metric_id") - fun minimum(): NewPlanMinimumCompositePrice? = minimum + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") - fun eventOutput(): EventOutput? = eventOutput + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") - fun isUnit(): Boolean = unit != null + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") - fun isTiered(): Boolean = tiered != null + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") - fun isBulk(): Boolean = bulk != null + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") - fun isPackage(): Boolean = package_ != null + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") - fun isMatrix(): Boolean = matrix != null + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") - fun isThresholdTotalAmount(): Boolean = thresholdTotalAmount != null + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") - fun isTieredPackage(): Boolean = tieredPackage != null + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + invoiceGroupingKey.getNullable("invoice_grouping_key") - fun isTieredWithMinimum(): Boolean = tieredWithMinimum != null + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - fun isGroupedTiered(): Boolean = groupedTiered != null + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") - fun isTieredPackageWithMinimum(): Boolean = tieredPackageWithMinimum != null + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") - fun isPackageWithAllocation(): Boolean = packageWithAllocation != null + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence - fun isUnitWithPercent(): Boolean = unitWithPercent != null + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - fun isMatrixWithAllocation(): Boolean = matrixWithAllocation != null + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - fun isTieredWithProration(): Boolean = tieredWithProration != null + /** + * Returns the raw JSON value of [tieredWithProrationConfig]. + * + * Unlike [tieredWithProrationConfig], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("tiered_with_proration_config") + @ExcludeMissing + fun _tieredWithProrationConfig(): JsonField = + tieredWithProrationConfig - fun isUnitWithProration(): Boolean = unitWithProration != null + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId - fun isGroupedAllocation(): Boolean = groupedAllocation != null + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance - fun isBulkWithProration(): Boolean = bulkWithProration != null + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration - fun isGroupedWithProratedMinimum(): Boolean = groupedWithProratedMinimum != null + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate - fun isGroupedWithMeteredMinimum(): Boolean = groupedWithMeteredMinimum != null + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig - fun isGroupedWithMinMaxThresholds(): Boolean = groupedWithMinMaxThresholds != null + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency - fun isMatrixWithDisplayName(): Boolean = matrixWithDisplayName != null + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration - fun isGroupedTieredPackage(): Boolean = groupedTieredPackage != null + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId - fun isMaxGroupTieredPackage(): Boolean = maxGroupTieredPackage != null + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - fun isScalableMatrixWithUnitPricing(): Boolean = scalableMatrixWithUnitPricing != null + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - fun isScalableMatrixWithTieredPricing(): Boolean = - scalableMatrixWithTieredPricing != null + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration - fun isCumulativeGroupedBulk(): Boolean = cumulativeGroupedBulk != null + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata - fun isMinimum(): Boolean = minimum != null + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId - fun isEventOutput(): Boolean = eventOutput != null + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - fun asUnit(): NewPlanUnitPrice = unit.getOrThrow("unit") + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - fun asTiered(): NewPlanTieredPrice = tiered.getOrThrow("tiered") + fun toBuilder() = Builder().from(this) - fun asBulk(): NewPlanBulkPrice = bulk.getOrThrow("bulk") + companion object { - fun asPackage(): NewPlanPackagePrice = package_.getOrThrow("package_") + /** + * Returns a mutable builder for constructing an instance of + * [TieredWithProration]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .name() + * .tieredWithProrationConfig() + * ``` + */ + fun builder() = Builder() + } - fun asMatrix(): NewPlanMatrixPrice = matrix.getOrThrow("matrix") + /** A builder for [TieredWithProration]. */ + class Builder internal constructor() { - fun asThresholdTotalAmount(): NewPlanThresholdTotalAmountPrice = - thresholdTotalAmount.getOrThrow("thresholdTotalAmount") + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonValue = JsonValue.from("tiered_with_proration") + private var name: JsonField? = null + private var tieredWithProrationConfig: JsonField? = + null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - fun asTieredPackage(): NewPlanTieredPackagePrice = - tieredPackage.getOrThrow("tieredPackage") + internal fun from(tieredWithProration: TieredWithProration) = apply { + cadence = tieredWithProration.cadence + itemId = tieredWithProration.itemId + modelType = tieredWithProration.modelType + name = tieredWithProration.name + tieredWithProrationConfig = tieredWithProration.tieredWithProrationConfig + billableMetricId = tieredWithProration.billableMetricId + billedInAdvance = tieredWithProration.billedInAdvance + billingCycleConfiguration = tieredWithProration.billingCycleConfiguration + conversionRate = tieredWithProration.conversionRate + conversionRateConfig = tieredWithProration.conversionRateConfig + currency = tieredWithProration.currency + dimensionalPriceConfiguration = + tieredWithProration.dimensionalPriceConfiguration + externalPriceId = tieredWithProration.externalPriceId + fixedPriceQuantity = tieredWithProration.fixedPriceQuantity + invoiceGroupingKey = tieredWithProration.invoiceGroupingKey + invoicingCycleConfiguration = + tieredWithProration.invoicingCycleConfiguration + metadata = tieredWithProration.metadata + referenceId = tieredWithProration.referenceId + additionalProperties = + tieredWithProration.additionalProperties.toMutableMap() + } - fun asTieredWithMinimum(): NewPlanTieredWithMinimumPrice = - tieredWithMinimum.getOrThrow("tieredWithMinimum") + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - fun asGroupedTiered(): NewPlanGroupedTieredPrice = - groupedTiered.getOrThrow("groupedTiered") + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - fun asTieredPackageWithMinimum(): NewPlanTieredPackageWithMinimumPrice = - tieredPackageWithMinimum.getOrThrow("tieredPackageWithMinimum") + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - fun asPackageWithAllocation(): NewPlanPackageWithAllocationPrice = - packageWithAllocation.getOrThrow("packageWithAllocation") + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun asUnitWithPercent(): NewPlanUnitWithPercentPrice = - unitWithPercent.getOrThrow("unitWithPercent") + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("tiered_with_proration") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } - fun asMatrixWithAllocation(): NewPlanMatrixWithAllocationPrice = - matrixWithAllocation.getOrThrow("matrixWithAllocation") + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) - fun asTieredWithProration(): TieredWithProration = - tieredWithProration.getOrThrow("tieredWithProration") + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } - fun asUnitWithProration(): NewPlanUnitWithProrationPrice = - unitWithProration.getOrThrow("unitWithProration") + /** Configuration for tiered_with_proration pricing */ + fun tieredWithProrationConfig( + tieredWithProrationConfig: TieredWithProrationConfig + ) = tieredWithProrationConfig(JsonField.of(tieredWithProrationConfig)) - fun asGroupedAllocation(): NewPlanGroupedAllocationPrice = - groupedAllocation.getOrThrow("groupedAllocation") + /** + * Sets [Builder.tieredWithProrationConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.tieredWithProrationConfig] with a well-typed + * [TieredWithProrationConfig] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun tieredWithProrationConfig( + tieredWithProrationConfig: JsonField + ) = apply { this.tieredWithProrationConfig = tieredWithProrationConfig } - fun asBulkWithProration(): NewPlanBulkWithProrationPrice = - bulkWithProration.getOrThrow("bulkWithProration") + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) - fun asGroupedWithProratedMinimum(): NewPlanGroupedWithProratedMinimumPrice = - groupedWithProratedMinimum.getOrThrow("groupedWithProratedMinimum") + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } - fun asGroupedWithMeteredMinimum(): NewPlanGroupedWithMeteredMinimumPrice = - groupedWithMeteredMinimum.getOrThrow("groupedWithMeteredMinimum") + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) - fun asGroupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds = - groupedWithMinMaxThresholds.getOrThrow("groupedWithMinMaxThresholds") + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) - fun asMatrixWithDisplayName(): NewPlanMatrixWithDisplayNamePrice = - matrixWithDisplayName.getOrThrow("matrixWithDisplayName") + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } - fun asGroupedTieredPackage(): NewPlanGroupedTieredPackagePrice = - groupedTieredPackage.getOrThrow("groupedTieredPackage") + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - fun asMaxGroupTieredPackage(): NewPlanMaxGroupTieredPackagePrice = - maxGroupTieredPackage.getOrThrow("maxGroupTieredPackage") + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } - fun asScalableMatrixWithUnitPricing(): NewPlanScalableMatrixWithUnitPricingPrice = - scalableMatrixWithUnitPricing.getOrThrow("scalableMatrixWithUnitPricing") + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) - fun asScalableMatrixWithTieredPricing(): NewPlanScalableMatrixWithTieredPricingPrice = - scalableMatrixWithTieredPricing.getOrThrow("scalableMatrixWithTieredPricing") + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) - fun asCumulativeGroupedBulk(): NewPlanCumulativeGroupedBulkPrice = - cumulativeGroupedBulk.getOrThrow("cumulativeGroupedBulk") + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } - fun asMinimum(): NewPlanMinimumCompositePrice = minimum.getOrThrow("minimum") + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) - fun asEventOutput(): EventOutput = eventOutput.getOrThrow("eventOutput") + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } - fun _json(): JsonValue? = _json + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - bulk != null -> visitor.visitBulk(bulk) - package_ != null -> visitor.visitPackage(package_) - matrix != null -> visitor.visitMatrix(matrix) - thresholdTotalAmount != null -> - visitor.visitThresholdTotalAmount(thresholdTotalAmount) - tieredPackage != null -> visitor.visitTieredPackage(tieredPackage) - tieredWithMinimum != null -> visitor.visitTieredWithMinimum(tieredWithMinimum) - groupedTiered != null -> visitor.visitGroupedTiered(groupedTiered) - tieredPackageWithMinimum != null -> - visitor.visitTieredPackageWithMinimum(tieredPackageWithMinimum) - packageWithAllocation != null -> - visitor.visitPackageWithAllocation(packageWithAllocation) - unitWithPercent != null -> visitor.visitUnitWithPercent(unitWithPercent) - matrixWithAllocation != null -> - visitor.visitMatrixWithAllocation(matrixWithAllocation) - tieredWithProration != null -> - visitor.visitTieredWithProration(tieredWithProration) - unitWithProration != null -> visitor.visitUnitWithProration(unitWithProration) - groupedAllocation != null -> visitor.visitGroupedAllocation(groupedAllocation) - bulkWithProration != null -> visitor.visitBulkWithProration(bulkWithProration) - groupedWithProratedMinimum != null -> - visitor.visitGroupedWithProratedMinimum(groupedWithProratedMinimum) - groupedWithMeteredMinimum != null -> - visitor.visitGroupedWithMeteredMinimum(groupedWithMeteredMinimum) - groupedWithMinMaxThresholds != null -> - visitor.visitGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds) - matrixWithDisplayName != null -> - visitor.visitMatrixWithDisplayName(matrixWithDisplayName) - groupedTieredPackage != null -> - visitor.visitGroupedTieredPackage(groupedTieredPackage) - maxGroupTieredPackage != null -> - visitor.visitMaxGroupTieredPackage(maxGroupTieredPackage) - scalableMatrixWithUnitPricing != null -> - visitor.visitScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing) - scalableMatrixWithTieredPricing != null -> - visitor.visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() ) - cumulativeGroupedBulk != null -> - visitor.visitCumulativeGroupedBulk(cumulativeGroupedBulk) - minimum != null -> visitor.visitMinimum(minimum) - eventOutput != null -> visitor.visitEventOutput(eventOutput) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - fun validate(): Price = apply { - if (validated) { - return@apply - } + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) - accept( - object : Visitor { - override fun visitUnit(unit: NewPlanUnitPrice) { - unit.validate() - } + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) - override fun visitTiered(tiered: NewPlanTieredPrice) { - tiered.validate() - } + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) - override fun visitBulk(bulk: NewPlanBulkPrice) { - bulk.validate() - } + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } - override fun visitPackage(package_: NewPlanPackagePrice) { - package_.validate() - } + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) - override fun visitMatrix(matrix: NewPlanMatrixPrice) { - matrix.validate() - } + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } - override fun visitThresholdTotalAmount( - thresholdTotalAmount: NewPlanThresholdTotalAmountPrice - ) { - thresholdTotalAmount.validate() - } + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) - override fun visitTieredPackage(tieredPackage: NewPlanTieredPackagePrice) { - tieredPackage.validate() - } + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } - override fun visitTieredWithMinimum( - tieredWithMinimum: NewPlanTieredWithMinimumPrice - ) { - tieredWithMinimum.validate() - } + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) - override fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) { - groupedTiered.validate() - } + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) - override fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice - ) { - tieredPackageWithMinimum.validate() - } + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } - override fun visitPackageWithAllocation( - packageWithAllocation: NewPlanPackageWithAllocationPrice - ) { - packageWithAllocation.validate() - } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) - override fun visitUnitWithPercent( - unitWithPercent: NewPlanUnitWithPercentPrice - ) { - unitWithPercent.validate() - } + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } - override fun visitMatrixWithAllocation( - matrixWithAllocation: NewPlanMatrixWithAllocationPrice - ) { - matrixWithAllocation.validate() - } + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) - override fun visitTieredWithProration( - tieredWithProration: TieredWithProration - ) { - tieredWithProration.validate() - } + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - override fun visitUnitWithProration( - unitWithProration: NewPlanUnitWithProrationPrice - ) { - unitWithProration.validate() - } + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - override fun visitGroupedAllocation( - groupedAllocation: NewPlanGroupedAllocationPrice - ) { - groupedAllocation.validate() - } + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - override fun visitBulkWithProration( - bulkWithProration: NewPlanBulkWithProrationPrice - ) { - bulkWithProration.validate() - } + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) - override fun visitGroupedWithProratedMinimum( - groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice - ) { - groupedWithProratedMinimum.validate() - } + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } - override fun visitGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice - ) { - groupedWithMeteredMinimum.validate() - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - override fun visitGroupedWithMinMaxThresholds( - groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds - ) { - groupedWithMinMaxThresholds.validate() - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - override fun visitMatrixWithDisplayName( - matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice - ) { - matrixWithDisplayName.validate() + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) } - override fun visitGroupedTieredPackage( - groupedTieredPackage: NewPlanGroupedTieredPackagePrice - ) { - groupedTieredPackage.validate() - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - override fun visitMaxGroupTieredPackage( - maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice - ) { - maxGroupTieredPackage.validate() - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - override fun visitScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice - ) { - scalableMatrixWithUnitPricing.validate() - } + /** + * Returns an immutable instance of [TieredWithProration]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .name() + * .tieredWithProrationConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TieredWithProration = + TieredWithProration( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + modelType, + checkRequired("name", name), + checkRequired("tieredWithProrationConfig", tieredWithProrationConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } - override fun visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: - NewPlanScalableMatrixWithTieredPricingPrice - ) { - scalableMatrixWithTieredPricing.validate() - } + private var validated: Boolean = false - override fun visitCumulativeGroupedBulk( - cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice - ) { - cumulativeGroupedBulk.validate() - } + fun validate(): TieredWithProration = apply { + if (validated) { + return@apply + } - override fun visitMinimum(minimum: NewPlanMinimumCompositePrice) { - minimum.validate() + cadence().validate() + itemId() + _modelType().let { + if (it != JsonValue.from("tiered_with_proration")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") } + } + name() + tieredWithProrationConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + metadata()?.validate() + referenceId() + validated = true + } - override fun visitEventOutput(eventOutput: EventOutput) { - eventOutput.validate() - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false } - ) - validated = true - } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + modelType.let { + if (it == JsonValue.from("tiered_with_proration")) 1 else 0 + } + + (if (name.asKnown() == null) 0 else 1) + + (tieredWithProrationConfig.asKnown()?.validity() ?: 0) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: NewPlanUnitPrice) = unit.validity() + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { - override fun visitTiered(tiered: NewPlanTieredPrice) = tiered.validity() + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value - override fun visitBulk(bulk: NewPlanBulkPrice) = bulk.validity() + companion object { - override fun visitPackage(package_: NewPlanPackagePrice) = - package_.validity() + val ANNUAL = of("annual") - override fun visitMatrix(matrix: NewPlanMatrixPrice) = matrix.validity() + val SEMI_ANNUAL = of("semi_annual") - override fun visitThresholdTotalAmount( - thresholdTotalAmount: NewPlanThresholdTotalAmountPrice - ) = thresholdTotalAmount.validity() + val MONTHLY = of("monthly") - override fun visitTieredPackage(tieredPackage: NewPlanTieredPackagePrice) = - tieredPackage.validity() + val QUARTERLY = of("quarterly") - override fun visitTieredWithMinimum( - tieredWithMinimum: NewPlanTieredWithMinimumPrice - ) = tieredWithMinimum.validity() + val ONE_TIME = of("one_time") - override fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) = - groupedTiered.validity() + val CUSTOM = of("custom") - override fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice - ) = tieredPackageWithMinimum.validity() + fun of(value: String) = Cadence(JsonField.of(value)) + } - override fun visitPackageWithAllocation( - packageWithAllocation: NewPlanPackageWithAllocationPrice - ) = packageWithAllocation.validity() + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } - override fun visitUnitWithPercent( - unitWithPercent: NewPlanUnitWithPercentPrice - ) = unitWithPercent.validity() + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } - override fun visitMatrixWithAllocation( - matrixWithAllocation: NewPlanMatrixWithAllocationPrice - ) = matrixWithAllocation.validity() + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } - override fun visitTieredWithProration( - tieredWithProration: TieredWithProration - ) = tieredWithProration.validity() + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } - override fun visitUnitWithProration( - unitWithProration: NewPlanUnitWithProrationPrice - ) = unitWithProration.validity() + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") - override fun visitGroupedAllocation( - groupedAllocation: NewPlanGroupedAllocationPrice - ) = groupedAllocation.validity() + private var validated: Boolean = false - override fun visitBulkWithProration( - bulkWithProration: NewPlanBulkWithProrationPrice - ) = bulkWithProration.validity() + fun validate(): Cadence = apply { + if (validated) { + return@apply + } - override fun visitGroupedWithProratedMinimum( - groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice - ) = groupedWithProratedMinimum.validity() + known() + validated = true + } - override fun visitGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice - ) = groupedWithMeteredMinimum.validity() + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - override fun visitGroupedWithMinMaxThresholds( - groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds - ) = groupedWithMinMaxThresholds.validity() + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - override fun visitMatrixWithDisplayName( - matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice - ) = matrixWithDisplayName.validity() + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - override fun visitGroupedTieredPackage( - groupedTieredPackage: NewPlanGroupedTieredPackagePrice - ) = groupedTieredPackage.validity() + return other is Cadence && value == other.value + } - override fun visitMaxGroupTieredPackage( - maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice - ) = maxGroupTieredPackage.validity() + override fun hashCode() = value.hashCode() - override fun visitScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice - ) = scalableMatrixWithUnitPricing.validity() + override fun toString() = value.toString() + } - override fun visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: - NewPlanScalableMatrixWithTieredPricingPrice - ) = scalableMatrixWithTieredPricing.validity() + /** Configuration for tiered_with_proration pricing */ + class TieredWithProrationConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val tiers: JsonField>, + private val additionalProperties: MutableMap, + ) { - override fun visitCumulativeGroupedBulk( - cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice - ) = cumulativeGroupedBulk.validity() + @JsonCreator + private constructor( + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of() + ) : this(tiers, mutableMapOf()) - override fun visitMinimum(minimum: NewPlanMinimumCompositePrice) = - minimum.validity() + /** + * Tiers for rating based on total usage quantities into the specified tier with + * proration + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun tiers(): List = tiers.getRequired("tiers") - override fun visitEventOutput(eventOutput: EventOutput) = - eventOutput.validity() + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers - override fun unknown(json: JsonValue?) = 0 + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - return other is Price && - unit == other.unit && - tiered == other.tiered && - bulk == other.bulk && - package_ == other.package_ && - matrix == other.matrix && - thresholdTotalAmount == other.thresholdTotalAmount && - tieredPackage == other.tieredPackage && - tieredWithMinimum == other.tieredWithMinimum && - groupedTiered == other.groupedTiered && - tieredPackageWithMinimum == other.tieredPackageWithMinimum && - packageWithAllocation == other.packageWithAllocation && - unitWithPercent == other.unitWithPercent && - matrixWithAllocation == other.matrixWithAllocation && - tieredWithProration == other.tieredWithProration && - unitWithProration == other.unitWithProration && - groupedAllocation == other.groupedAllocation && - bulkWithProration == other.bulkWithProration && - groupedWithProratedMinimum == other.groupedWithProratedMinimum && - groupedWithMeteredMinimum == other.groupedWithMeteredMinimum && - groupedWithMinMaxThresholds == other.groupedWithMinMaxThresholds && - matrixWithDisplayName == other.matrixWithDisplayName && - groupedTieredPackage == other.groupedTieredPackage && - maxGroupTieredPackage == other.maxGroupTieredPackage && - scalableMatrixWithUnitPricing == other.scalableMatrixWithUnitPricing && - scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && - cumulativeGroupedBulk == other.cumulativeGroupedBulk && - minimum == other.minimum && - eventOutput == other.eventOutput - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - override fun hashCode(): Int = - Objects.hash( - unit, - tiered, - bulk, - package_, - matrix, - thresholdTotalAmount, - tieredPackage, - tieredWithMinimum, - groupedTiered, - tieredPackageWithMinimum, - packageWithAllocation, - unitWithPercent, - matrixWithAllocation, - tieredWithProration, - unitWithProration, - groupedAllocation, - bulkWithProration, - groupedWithProratedMinimum, - groupedWithMeteredMinimum, - groupedWithMinMaxThresholds, - matrixWithDisplayName, - groupedTieredPackage, - maxGroupTieredPackage, - scalableMatrixWithUnitPricing, - scalableMatrixWithTieredPricing, - cumulativeGroupedBulk, - minimum, - eventOutput, - ) + fun toBuilder() = Builder().from(this) - override fun toString(): String = - when { - unit != null -> "Price{unit=$unit}" - tiered != null -> "Price{tiered=$tiered}" - bulk != null -> "Price{bulk=$bulk}" - package_ != null -> "Price{package_=$package_}" - matrix != null -> "Price{matrix=$matrix}" - thresholdTotalAmount != null -> - "Price{thresholdTotalAmount=$thresholdTotalAmount}" - tieredPackage != null -> "Price{tieredPackage=$tieredPackage}" - tieredWithMinimum != null -> "Price{tieredWithMinimum=$tieredWithMinimum}" - groupedTiered != null -> "Price{groupedTiered=$groupedTiered}" - tieredPackageWithMinimum != null -> - "Price{tieredPackageWithMinimum=$tieredPackageWithMinimum}" - packageWithAllocation != null -> - "Price{packageWithAllocation=$packageWithAllocation}" - unitWithPercent != null -> "Price{unitWithPercent=$unitWithPercent}" - matrixWithAllocation != null -> - "Price{matrixWithAllocation=$matrixWithAllocation}" - tieredWithProration != null -> "Price{tieredWithProration=$tieredWithProration}" - unitWithProration != null -> "Price{unitWithProration=$unitWithProration}" - groupedAllocation != null -> "Price{groupedAllocation=$groupedAllocation}" - bulkWithProration != null -> "Price{bulkWithProration=$bulkWithProration}" - groupedWithProratedMinimum != null -> - "Price{groupedWithProratedMinimum=$groupedWithProratedMinimum}" - groupedWithMeteredMinimum != null -> - "Price{groupedWithMeteredMinimum=$groupedWithMeteredMinimum}" - groupedWithMinMaxThresholds != null -> - "Price{groupedWithMinMaxThresholds=$groupedWithMinMaxThresholds}" - matrixWithDisplayName != null -> - "Price{matrixWithDisplayName=$matrixWithDisplayName}" - groupedTieredPackage != null -> - "Price{groupedTieredPackage=$groupedTieredPackage}" - maxGroupTieredPackage != null -> - "Price{maxGroupTieredPackage=$maxGroupTieredPackage}" - scalableMatrixWithUnitPricing != null -> - "Price{scalableMatrixWithUnitPricing=$scalableMatrixWithUnitPricing}" - scalableMatrixWithTieredPricing != null -> - "Price{scalableMatrixWithTieredPricing=$scalableMatrixWithTieredPricing}" - cumulativeGroupedBulk != null -> - "Price{cumulativeGroupedBulk=$cumulativeGroupedBulk}" - minimum != null -> "Price{minimum=$minimum}" - eventOutput != null -> "Price{eventOutput=$eventOutput}" - _json != null -> "Price{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Price") - } + companion object { - companion object { + /** + * Returns a mutable builder for constructing an instance of + * [TieredWithProrationConfig]. + * + * The following fields are required: + * ```kotlin + * .tiers() + * ``` + */ + fun builder() = Builder() + } - fun ofUnit(unit: NewPlanUnitPrice) = Price(unit = unit) + /** A builder for [TieredWithProrationConfig]. */ + class Builder internal constructor() { - fun ofTiered(tiered: NewPlanTieredPrice) = Price(tiered = tiered) + private var tiers: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() - fun ofBulk(bulk: NewPlanBulkPrice) = Price(bulk = bulk) + internal fun from(tieredWithProrationConfig: TieredWithProrationConfig) = + apply { + tiers = tieredWithProrationConfig.tiers.map { it.toMutableList() } + additionalProperties = + tieredWithProrationConfig.additionalProperties.toMutableMap() + } - fun ofPackage(package_: NewPlanPackagePrice) = Price(package_ = package_) + /** + * Tiers for rating based on total usage quantities into the specified tier + * with proration + */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) - fun ofMatrix(matrix: NewPlanMatrixPrice) = Price(matrix = matrix) + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } - fun ofThresholdTotalAmount(thresholdTotalAmount: NewPlanThresholdTotalAmountPrice) = - Price(thresholdTotalAmount = thresholdTotalAmount) + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } - fun ofTieredPackage(tieredPackage: NewPlanTieredPackagePrice) = - Price(tieredPackage = tieredPackage) + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun ofTieredWithMinimum(tieredWithMinimum: NewPlanTieredWithMinimumPrice) = - Price(tieredWithMinimum = tieredWithMinimum) + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun ofGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) = - Price(groupedTiered = groupedTiered) + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun ofTieredPackageWithMinimum( - tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice - ) = Price(tieredPackageWithMinimum = tieredPackageWithMinimum) + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun ofPackageWithAllocation( - packageWithAllocation: NewPlanPackageWithAllocationPrice - ) = Price(packageWithAllocation = packageWithAllocation) + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - fun ofUnitWithPercent(unitWithPercent: NewPlanUnitWithPercentPrice) = - Price(unitWithPercent = unitWithPercent) + /** + * Returns an immutable instance of [TieredWithProrationConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TieredWithProrationConfig = + TieredWithProrationConfig( + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } - fun ofMatrixWithAllocation(matrixWithAllocation: NewPlanMatrixWithAllocationPrice) = - Price(matrixWithAllocation = matrixWithAllocation) + private var validated: Boolean = false - fun ofTieredWithProration(tieredWithProration: TieredWithProration) = - Price(tieredWithProration = tieredWithProration) + fun validate(): TieredWithProrationConfig = apply { + if (validated) { + return@apply + } - fun ofUnitWithProration(unitWithProration: NewPlanUnitWithProrationPrice) = - Price(unitWithProration = unitWithProration) + tiers().forEach { it.validate() } + validated = true + } - fun ofGroupedAllocation(groupedAllocation: NewPlanGroupedAllocationPrice) = - Price(groupedAllocation = groupedAllocation) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (tiers.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single tiered with proration tier */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val tierLowerBound: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(tierLowerBound, unitAmount, mutableMapOf()) + + /** + * Inclusive tier starting value + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun tierLowerBound(): String = + tierLowerBound.getRequired("tier_lower_bound") + + /** + * Amount per unit + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") - fun ofBulkWithProration(bulkWithProration: NewPlanBulkWithProrationPrice) = - Price(bulkWithProration = bulkWithProration) + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound - fun ofGroupedWithProratedMinimum( - groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice - ) = Price(groupedWithProratedMinimum = groupedWithProratedMinimum) + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount - fun ofGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice - ) = Price(groupedWithMeteredMinimum = groupedWithMeteredMinimum) + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - fun ofGroupedWithMinMaxThresholds( - groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds - ) = Price(groupedWithMinMaxThresholds = groupedWithMinMaxThresholds) + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - fun ofMatrixWithDisplayName( - matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice - ) = Price(matrixWithDisplayName = matrixWithDisplayName) + fun toBuilder() = Builder().from(this) - fun ofGroupedTieredPackage(groupedTieredPackage: NewPlanGroupedTieredPackagePrice) = - Price(groupedTieredPackage = groupedTieredPackage) + companion object { - fun ofMaxGroupTieredPackage( - maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice - ) = Price(maxGroupTieredPackage = maxGroupTieredPackage) + /** + * Returns a mutable builder for constructing an instance of [Tier]. + * + * The following fields are required: + * ```kotlin + * .tierLowerBound() + * .unitAmount() + * ``` + */ + fun builder() = Builder() + } - fun ofScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice - ) = Price(scalableMatrixWithUnitPricing = scalableMatrixWithUnitPricing) + /** A builder for [Tier]. */ + class Builder internal constructor() { - fun ofScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: NewPlanScalableMatrixWithTieredPricingPrice - ) = Price(scalableMatrixWithTieredPricing = scalableMatrixWithTieredPricing) + private var tierLowerBound: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() - fun ofCumulativeGroupedBulk( - cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice - ) = Price(cumulativeGroupedBulk = cumulativeGroupedBulk) + internal fun from(tier: Tier) = apply { + tierLowerBound = tier.tierLowerBound + unitAmount = tier.unitAmount + additionalProperties = tier.additionalProperties.toMutableMap() + } - fun ofMinimum(minimum: NewPlanMinimumCompositePrice) = Price(minimum = minimum) + /** Inclusive tier starting value */ + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) - fun ofEventOutput(eventOutput: EventOutput) = Price(eventOutput = eventOutput) - } + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } - /** - * An interface that defines how to map each variant of [Price] to a value of type [T]. - */ - interface Visitor { + /** Amount per unit */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) - fun visitUnit(unit: NewPlanUnitPrice): T + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } - fun visitTiered(tiered: NewPlanTieredPrice): T + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun visitBulk(bulk: NewPlanBulkPrice): T + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun visitPackage(package_: NewPlanPackagePrice): T + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun visitMatrix(matrix: NewPlanMatrixPrice): T + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun visitThresholdTotalAmount( - thresholdTotalAmount: NewPlanThresholdTotalAmountPrice - ): T + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - fun visitTieredPackage(tieredPackage: NewPlanTieredPackagePrice): T + /** + * Returns an immutable instance of [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```kotlin + * .tierLowerBound() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("tierLowerBound", tierLowerBound), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } - fun visitTieredWithMinimum(tieredWithMinimum: NewPlanTieredWithMinimumPrice): T + private var validated: Boolean = false - fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice): T + fun validate(): Tier = apply { + if (validated) { + return@apply + } - fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice - ): T + tierLowerBound() + unitAmount() + validated = true + } - fun visitPackageWithAllocation( - packageWithAllocation: NewPlanPackageWithAllocationPrice - ): T + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - fun visitUnitWithPercent(unitWithPercent: NewPlanUnitWithPercentPrice): T + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (tierLowerBound.asKnown() == null) 0 else 1) + + (if (unitAmount.asKnown() == null) 0 else 1) - fun visitMatrixWithAllocation( - matrixWithAllocation: NewPlanMatrixWithAllocationPrice - ): T + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun visitTieredWithProration(tieredWithProration: TieredWithProration): T + return other is Tier && + tierLowerBound == other.tierLowerBound && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } - fun visitUnitWithProration(unitWithProration: NewPlanUnitWithProrationPrice): T + private val hashCode: Int by lazy { + Objects.hash(tierLowerBound, unitAmount, additionalProperties) + } - fun visitGroupedAllocation(groupedAllocation: NewPlanGroupedAllocationPrice): T + override fun hashCode(): Int = hashCode - fun visitBulkWithProration(bulkWithProration: NewPlanBulkWithProrationPrice): T + override fun toString() = + "Tier{tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } - fun visitGroupedWithProratedMinimum( - groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice - ): T + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun visitGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice - ): T + return other is TieredWithProrationConfig && + tiers == other.tiers && + additionalProperties == other.additionalProperties + } - fun visitGroupedWithMinMaxThresholds( - groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds - ): T + private val hashCode: Int by lazy { Objects.hash(tiers, additionalProperties) } - fun visitMatrixWithDisplayName( - matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice - ): T + override fun hashCode(): Int = hashCode - fun visitGroupedTieredPackage( - groupedTieredPackage: NewPlanGroupedTieredPackagePrice - ): T + override fun toString() = + "TieredWithProrationConfig{tiers=$tiers, additionalProperties=$additionalProperties}" + } - fun visitMaxGroupTieredPackage( - maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice - ): T + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { - fun visitScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice - ): T + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties - fun visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: NewPlanScalableMatrixWithTieredPricingPrice - ): T + fun toBuilder() = Builder().from(this) - fun visitCumulativeGroupedBulk( - cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice - ): T + companion object { - fun visitMinimum(minimum: NewPlanMinimumCompositePrice): T + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } - fun visitEventOutput(eventOutput: EventOutput): T + /** A builder for [Metadata]. */ + class Builder internal constructor() { - /** - * Maps an unknown variant of [Price] to a value of type [T]. - * - * An instance of [Price] can contain an unknown variant if it was deserialized from - * data that doesn't match any known variant. For example, if the SDK is on an older - * version than the API, then the API may respond with new variants that the SDK is - * unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown Price: $json") - } - } + private var additionalProperties: MutableMap = + mutableMapOf() - internal class Deserializer : BaseDeserializer(Price::class) { + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } - override fun ObjectCodec.deserialize(node: JsonNode): Price { - val json = JsonValue.fromJsonNode(node) - val modelType = json.asObject()?.get("model_type")?.asString() + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - when (modelType) { - "unit" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(unit = it, _json = json) - } ?: Price(_json = json) - } - "tiered" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(tiered = it, _json = json) - } ?: Price(_json = json) - } - "bulk" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(bulk = it, _json = json) - } ?: Price(_json = json) - } - "package" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(package_ = it, _json = json) } ?: Price(_json = json) - } - "matrix" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(matrix = it, _json = json) - } ?: Price(_json = json) - } - "threshold_total_amount" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(thresholdTotalAmount = it, _json = json) } - ?: Price(_json = json) - } - "tiered_package" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(tieredPackage = it, _json = json) } - ?: Price(_json = json) - } - "tiered_with_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(tieredWithMinimum = it, _json = json) } - ?: Price(_json = json) - } - "grouped_tiered" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(groupedTiered = it, _json = json) } - ?: Price(_json = json) - } - "tiered_package_with_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(tieredPackageWithMinimum = it, _json = json) } - ?: Price(_json = json) - } - "package_with_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(packageWithAllocation = it, _json = json) } - ?: Price(_json = json) - } - "unit_with_percent" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(unitWithPercent = it, _json = json) } - ?: Price(_json = json) - } - "matrix_with_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(matrixWithAllocation = it, _json = json) } - ?: Price(_json = json) - } - "tiered_with_proration" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(tieredWithProration = it, _json = json) } - ?: Price(_json = json) - } - "unit_with_proration" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(unitWithProration = it, _json = json) } - ?: Price(_json = json) - } - "grouped_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedAllocation = it, _json = json) } - ?: Price(_json = json) - } - "bulk_with_proration" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(bulkWithProration = it, _json = json) } - ?: Price(_json = json) - } - "grouped_with_prorated_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedWithProratedMinimum = it, _json = json) } - ?: Price(_json = json) - } - "grouped_with_metered_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedWithMeteredMinimum = it, _json = json) } - ?: Price(_json = json) - } - "grouped_with_min_max_thresholds" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedWithMinMaxThresholds = it, _json = json) } - ?: Price(_json = json) - } - "matrix_with_display_name" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(matrixWithDisplayName = it, _json = json) } - ?: Price(_json = json) - } - "grouped_tiered_package" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedTieredPackage = it, _json = json) } - ?: Price(_json = json) + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) } - "max_group_tiered_package" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(maxGroupTieredPackage = it, _json = json) } - ?: Price(_json = json) + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) } - "scalable_matrix_with_unit_pricing" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(scalableMatrixWithUnitPricing = it, _json = json) } - ?: Price(_json = json) + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) } - "scalable_matrix_with_tiered_pricing" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(scalableMatrixWithTieredPricing = it, _json = json) } - ?: Price(_json = json) + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply } - "cumulative_grouped_bulk" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(cumulativeGroupedBulk = it, _json = json) } - ?: Price(_json = json) + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false } - "minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(minimum = it, _json = json) } ?: Price(_json = json) + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() } - "event_output" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(eventOutput = it, _json = json) - } ?: Price(_json = json) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } + + return other is Metadata && + additionalProperties == other.additionalProperties } - return Price(_json = json) - } - } + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - internal class Serializer : BaseSerializer(Price::class) { + override fun hashCode(): Int = hashCode - override fun serialize( - value: Price, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unit != null -> generator.writeObject(value.unit) - value.tiered != null -> generator.writeObject(value.tiered) - value.bulk != null -> generator.writeObject(value.bulk) - value.package_ != null -> generator.writeObject(value.package_) - value.matrix != null -> generator.writeObject(value.matrix) - value.thresholdTotalAmount != null -> - generator.writeObject(value.thresholdTotalAmount) - value.tieredPackage != null -> generator.writeObject(value.tieredPackage) - value.tieredWithMinimum != null -> - generator.writeObject(value.tieredWithMinimum) - value.groupedTiered != null -> generator.writeObject(value.groupedTiered) - value.tieredPackageWithMinimum != null -> - generator.writeObject(value.tieredPackageWithMinimum) - value.packageWithAllocation != null -> - generator.writeObject(value.packageWithAllocation) - value.unitWithPercent != null -> - generator.writeObject(value.unitWithPercent) - value.matrixWithAllocation != null -> - generator.writeObject(value.matrixWithAllocation) - value.tieredWithProration != null -> - generator.writeObject(value.tieredWithProration) - value.unitWithProration != null -> - generator.writeObject(value.unitWithProration) - value.groupedAllocation != null -> - generator.writeObject(value.groupedAllocation) - value.bulkWithProration != null -> - generator.writeObject(value.bulkWithProration) - value.groupedWithProratedMinimum != null -> - generator.writeObject(value.groupedWithProratedMinimum) - value.groupedWithMeteredMinimum != null -> - generator.writeObject(value.groupedWithMeteredMinimum) - value.groupedWithMinMaxThresholds != null -> - generator.writeObject(value.groupedWithMinMaxThresholds) - value.matrixWithDisplayName != null -> - generator.writeObject(value.matrixWithDisplayName) - value.groupedTieredPackage != null -> - generator.writeObject(value.groupedTieredPackage) - value.maxGroupTieredPackage != null -> - generator.writeObject(value.maxGroupTieredPackage) - value.scalableMatrixWithUnitPricing != null -> - generator.writeObject(value.scalableMatrixWithUnitPricing) - value.scalableMatrixWithTieredPricing != null -> - generator.writeObject(value.scalableMatrixWithTieredPricing) - value.cumulativeGroupedBulk != null -> - generator.writeObject(value.cumulativeGroupedBulk) - value.minimum != null -> generator.writeObject(value.minimum) - value.eventOutput != null -> generator.writeObject(value.eventOutput) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Price") + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } + + return other is TieredWithProration && + cadence == other.cadence && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + tieredWithProrationConfig == other.tieredWithProrationConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + modelType, + name, + tieredWithProrationConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties, + ) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TieredWithProration{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredWithProrationConfig=$tieredWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class TieredWithProration + class GroupedWithMinMaxThresholds @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, + private val groupedWithMinMaxThresholdsConfig: + JsonField, private val itemId: JsonField, private val modelType: JsonValue, private val name: JsonField, - private val tieredWithProrationConfig: JsonField, private val billableMetricId: JsonField, private val billedInAdvance: JsonField, private val billingCycleConfiguration: JsonField, @@ -10878,6 +14223,11 @@ private constructor( @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), + @JsonProperty("grouped_with_min_max_thresholds_config") + @ExcludeMissing + groupedWithMinMaxThresholdsConfig: + JsonField = + JsonMissing.of(), @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), @@ -10887,10 +14237,6 @@ private constructor( @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("tiered_with_proration_config") - @ExcludeMissing - tieredWithProrationConfig: JsonField = - JsonMissing.of(), @JsonProperty("billable_metric_id") @ExcludeMissing billableMetricId: JsonField = JsonMissing.of(), @@ -10935,10 +14281,10 @@ private constructor( referenceId: JsonField = JsonMissing.of(), ) : this( cadence, + groupedWithMinMaxThresholdsConfig, itemId, modelType, name, - tieredWithProrationConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -10964,6 +14310,18 @@ private constructor( */ fun cadence(): Cadence = cadence.getRequired("cadence") + /** + * Configuration for grouped_with_min_max_thresholds pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupedWithMinMaxThresholdsConfig(): GroupedWithMinMaxThresholdsConfig = + groupedWithMinMaxThresholdsConfig.getRequired( + "grouped_with_min_max_thresholds_config" + ) + /** * The id of the item the price will be associated with. * @@ -10978,7 +14336,7 @@ private constructor( * * Expected to always return the following: * ```kotlin - * JsonValue.from("tiered_with_proration") + * JsonValue.from("grouped_with_min_max_thresholds") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -10995,16 +14353,6 @@ private constructor( */ fun name(): String = name.getRequired("name") - /** - * Configuration for tiered_with_proration pricing - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun tieredWithProrationConfig(): TieredWithProrationConfig = - tieredWithProrationConfig.getRequired("tiered_with_proration_config") - /** * The id of the billable metric for the price. Only needed if the price is * usage-based. @@ -11134,6 +14482,17 @@ private constructor( @ExcludeMissing fun _cadence(): JsonField = cadence + /** + * Returns the raw JSON value of [groupedWithMinMaxThresholdsConfig]. + * + * Unlike [groupedWithMinMaxThresholdsConfig], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("grouped_with_min_max_thresholds_config") + @ExcludeMissing + fun _groupedWithMinMaxThresholdsConfig(): + JsonField = groupedWithMinMaxThresholdsConfig + /** * Returns the raw JSON value of [itemId]. * @@ -11150,17 +14509,6 @@ private constructor( */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - /** - * Returns the raw JSON value of [tieredWithProrationConfig]. - * - * Unlike [tieredWithProrationConfig], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("tiered_with_proration_config") - @ExcludeMissing - fun _tieredWithProrationConfig(): JsonField = - tieredWithProrationConfig - /** * Returns the raw JSON value of [billableMetricId]. * @@ -11310,28 +14658,30 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [TieredWithProration]. + * [GroupedWithMinMaxThresholds]. * * The following fields are required: * ```kotlin * .cadence() + * .groupedWithMinMaxThresholdsConfig() * .itemId() * .name() - * .tieredWithProrationConfig() * ``` */ fun builder() = Builder() } - /** A builder for [TieredWithProration]. */ + /** A builder for [GroupedWithMinMaxThresholds]. */ class Builder internal constructor() { private var cadence: JsonField? = null + private var groupedWithMinMaxThresholdsConfig: + JsonField? = + null private var itemId: JsonField? = null - private var modelType: JsonValue = JsonValue.from("tiered_with_proration") + private var modelType: JsonValue = + JsonValue.from("grouped_with_min_max_thresholds") private var name: JsonField? = null - private var tieredWithProrationConfig: JsonField? = - null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() private var billingCycleConfiguration: JsonField = @@ -11353,30 +14703,33 @@ private constructor( private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(tieredWithProration: TieredWithProration) = apply { - cadence = tieredWithProration.cadence - itemId = tieredWithProration.itemId - modelType = tieredWithProration.modelType - name = tieredWithProration.name - tieredWithProrationConfig = tieredWithProration.tieredWithProrationConfig - billableMetricId = tieredWithProration.billableMetricId - billedInAdvance = tieredWithProration.billedInAdvance - billingCycleConfiguration = tieredWithProration.billingCycleConfiguration - conversionRate = tieredWithProration.conversionRate - conversionRateConfig = tieredWithProration.conversionRateConfig - currency = tieredWithProration.currency - dimensionalPriceConfiguration = - tieredWithProration.dimensionalPriceConfiguration - externalPriceId = tieredWithProration.externalPriceId - fixedPriceQuantity = tieredWithProration.fixedPriceQuantity - invoiceGroupingKey = tieredWithProration.invoiceGroupingKey - invoicingCycleConfiguration = - tieredWithProration.invoicingCycleConfiguration - metadata = tieredWithProration.metadata - referenceId = tieredWithProration.referenceId - additionalProperties = - tieredWithProration.additionalProperties.toMutableMap() - } + internal fun from(groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds) = + apply { + cadence = groupedWithMinMaxThresholds.cadence + groupedWithMinMaxThresholdsConfig = + groupedWithMinMaxThresholds.groupedWithMinMaxThresholdsConfig + itemId = groupedWithMinMaxThresholds.itemId + modelType = groupedWithMinMaxThresholds.modelType + name = groupedWithMinMaxThresholds.name + billableMetricId = groupedWithMinMaxThresholds.billableMetricId + billedInAdvance = groupedWithMinMaxThresholds.billedInAdvance + billingCycleConfiguration = + groupedWithMinMaxThresholds.billingCycleConfiguration + conversionRate = groupedWithMinMaxThresholds.conversionRate + conversionRateConfig = groupedWithMinMaxThresholds.conversionRateConfig + currency = groupedWithMinMaxThresholds.currency + dimensionalPriceConfiguration = + groupedWithMinMaxThresholds.dimensionalPriceConfiguration + externalPriceId = groupedWithMinMaxThresholds.externalPriceId + fixedPriceQuantity = groupedWithMinMaxThresholds.fixedPriceQuantity + invoiceGroupingKey = groupedWithMinMaxThresholds.invoiceGroupingKey + invoicingCycleConfiguration = + groupedWithMinMaxThresholds.invoicingCycleConfiguration + metadata = groupedWithMinMaxThresholds.metadata + referenceId = groupedWithMinMaxThresholds.referenceId + additionalProperties = + groupedWithMinMaxThresholds.additionalProperties.toMutableMap() + } /** The cadence to bill for this price on. */ fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) @@ -11390,6 +14743,29 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + /** Configuration for grouped_with_min_max_thresholds pricing */ + fun groupedWithMinMaxThresholdsConfig( + groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + ) = + groupedWithMinMaxThresholdsConfig( + JsonField.of(groupedWithMinMaxThresholdsConfig) + ) + + /** + * Sets [Builder.groupedWithMinMaxThresholdsConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.groupedWithMinMaxThresholdsConfig] with a + * well-typed [GroupedWithMinMaxThresholdsConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun groupedWithMinMaxThresholdsConfig( + groupedWithMinMaxThresholdsConfig: + JsonField + ) = apply { + this.groupedWithMinMaxThresholdsConfig = groupedWithMinMaxThresholdsConfig + } + /** The id of the item the price will be associated with. */ fun itemId(itemId: String) = itemId(JsonField.of(itemId)) @@ -11408,7 +14784,7 @@ private constructor( * It is usually unnecessary to call this method because the field defaults to * the following: * ```kotlin - * JsonValue.from("tiered_with_proration") + * JsonValue.from("grouped_with_min_max_thresholds") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -11428,22 +14804,6 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } - /** Configuration for tiered_with_proration pricing */ - fun tieredWithProrationConfig( - tieredWithProrationConfig: TieredWithProrationConfig - ) = tieredWithProrationConfig(JsonField.of(tieredWithProrationConfig)) - - /** - * Sets [Builder.tieredWithProrationConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.tieredWithProrationConfig] with a well-typed - * [TieredWithProrationConfig] value instead. This method is primarily for - * setting the field to an undocumented or not yet supported value. - */ - fun tieredWithProrationConfig( - tieredWithProrationConfig: JsonField - ) = apply { this.tieredWithProrationConfig = tieredWithProrationConfig } - /** * The id of the billable metric for the price. Only needed if the price is * usage-based. @@ -11773,27 +15133,30 @@ private constructor( } /** - * Returns an immutable instance of [TieredWithProration]. + * Returns an immutable instance of [GroupedWithMinMaxThresholds]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```kotlin * .cadence() + * .groupedWithMinMaxThresholdsConfig() * .itemId() * .name() - * .tieredWithProrationConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): TieredWithProration = - TieredWithProration( + fun build(): GroupedWithMinMaxThresholds = + GroupedWithMinMaxThresholds( checkRequired("cadence", cadence), + checkRequired( + "groupedWithMinMaxThresholdsConfig", + groupedWithMinMaxThresholdsConfig, + ), checkRequired("itemId", itemId), modelType, checkRequired("name", name), - checkRequired("tieredWithProrationConfig", tieredWithProrationConfig), billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -11813,20 +15176,20 @@ private constructor( private var validated: Boolean = false - fun validate(): TieredWithProration = apply { + fun validate(): GroupedWithMinMaxThresholds = apply { if (validated) { return@apply } cadence().validate() + groupedWithMinMaxThresholdsConfig().validate() itemId() _modelType().let { - if (it != JsonValue.from("tiered_with_proration")) { + if (it != JsonValue.from("grouped_with_min_max_thresholds")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } name() - tieredWithProrationConfig().validate() billableMetricId() billedInAdvance() billingCycleConfiguration()?.validate() @@ -11859,12 +15222,12 @@ private constructor( */ internal fun validity(): Int = (cadence.asKnown()?.validity() ?: 0) + + (groupedWithMinMaxThresholdsConfig.asKnown()?.validity() ?: 0) + (if (itemId.asKnown() == null) 0 else 1) + modelType.let { - if (it == JsonValue.from("tiered_with_proration")) 1 else 0 + if (it == JsonValue.from("grouped_with_min_max_thresholds")) 1 else 0 } + (if (name.asKnown() == null) 0 else 1) + - (tieredWithProrationConfig.asKnown()?.validity() ?: 0) + (if (billableMetricId.asKnown() == null) 0 else 1) + (if (billedInAdvance.asKnown() == null) 0 else 1) + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + @@ -12036,419 +15399,328 @@ private constructor( override fun toString() = value.toString() } - /** Configuration for tiered_with_proration pricing */ - class TieredWithProrationConfig + /** Configuration for grouped_with_min_max_thresholds pricing */ + class GroupedWithMinMaxThresholdsConfig @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val tiers: JsonField>, + private val groupingKey: JsonField, + private val maximumCharge: JsonField, + private val minimumCharge: JsonField, + private val perUnitRate: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("tiers") + @JsonProperty("grouping_key") @ExcludeMissing - tiers: JsonField> = JsonMissing.of() - ) : this(tiers, mutableMapOf()) + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("maximum_charge") + @ExcludeMissing + maximumCharge: JsonField = JsonMissing.of(), + @JsonProperty("minimum_charge") + @ExcludeMissing + minimumCharge: JsonField = JsonMissing.of(), + @JsonProperty("per_unit_rate") + @ExcludeMissing + perUnitRate: JsonField = JsonMissing.of(), + ) : this(groupingKey, maximumCharge, minimumCharge, perUnitRate, mutableMapOf()) /** - * Tiers for rating based on total usage quantities into the specified tier with - * proration + * The event property used to group before applying thresholds * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). */ - fun tiers(): List = tiers.getRequired("tiers") + fun groupingKey(): String = groupingKey.getRequired("grouping_key") /** - * Returns the raw JSON value of [tiers]. + * The maximum amount to charge each group * - * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected - * type. + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). */ - @JsonProperty("tiers") - @ExcludeMissing - fun _tiers(): JsonField> = tiers - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [TieredWithProrationConfig]. - * - * The following fields are required: - * ```kotlin - * .tiers() - * ``` - */ - fun builder() = Builder() - } - - /** A builder for [TieredWithProrationConfig]. */ - class Builder internal constructor() { + fun maximumCharge(): String = maximumCharge.getRequired("maximum_charge") - private var tiers: JsonField>? = null - private var additionalProperties: MutableMap = - mutableMapOf() + /** + * The minimum amount to charge each group, regardless of usage + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun minimumCharge(): String = minimumCharge.getRequired("minimum_charge") - internal fun from(tieredWithProrationConfig: TieredWithProrationConfig) = - apply { - tiers = tieredWithProrationConfig.tiers.map { it.toMutableList() } - additionalProperties = - tieredWithProrationConfig.additionalProperties.toMutableMap() - } + /** + * The base price charged per group + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun perUnitRate(): String = perUnitRate.getRequired("per_unit_rate") - /** - * Tiers for rating based on total usage quantities into the specified tier - * with proration - */ - fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey - /** - * Sets [Builder.tiers] to an arbitrary JSON value. - * - * You should usually call [Builder.tiers] with a well-typed `List` - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun tiers(tiers: JsonField>) = apply { - this.tiers = tiers.map { it.toMutableList() } - } + /** + * Returns the raw JSON value of [maximumCharge]. + * + * Unlike [maximumCharge], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("maximum_charge") + @ExcludeMissing + fun _maximumCharge(): JsonField = maximumCharge - /** - * Adds a single [Tier] to [tiers]. - * - * @throws IllegalStateException if the field was previously set to a - * non-list. - */ - fun addTier(tier: Tier) = apply { - tiers = - (tiers ?: JsonField.of(mutableListOf())).also { - checkKnown("tiers", it).add(tier) - } - } + /** + * Returns the raw JSON value of [minimumCharge]. + * + * Unlike [minimumCharge], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("minimum_charge") + @ExcludeMissing + fun _minimumCharge(): JsonField = minimumCharge - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * Returns the raw JSON value of [perUnitRate]. + * + * Unlike [perUnitRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("per_unit_rate") + @ExcludeMissing + fun _perUnitRate(): JsonField = perUnitRate - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun toBuilder() = Builder().from(this) - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + companion object { /** - * Returns an immutable instance of [TieredWithProrationConfig]. - * - * Further updates to this [Builder] will not mutate the returned instance. + * Returns a mutable builder for constructing an instance of + * [GroupedWithMinMaxThresholdsConfig]. * * The following fields are required: * ```kotlin - * .tiers() + * .groupingKey() + * .maximumCharge() + * .minimumCharge() + * .perUnitRate() * ``` - * - * @throws IllegalStateException if any required field is unset. */ - fun build(): TieredWithProrationConfig = - TieredWithProrationConfig( - checkRequired("tiers", tiers).map { it.toImmutable() }, - additionalProperties.toMutableMap(), - ) + fun builder() = Builder() } - private var validated: Boolean = false - - fun validate(): TieredWithProrationConfig = apply { - if (validated) { - return@apply - } + /** A builder for [GroupedWithMinMaxThresholdsConfig]. */ + class Builder internal constructor() { - tiers().forEach { it.validate() } - validated = true - } + private var groupingKey: JsonField? = null + private var maximumCharge: JsonField? = null + private var minimumCharge: JsonField? = null + private var perUnitRate: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false + internal fun from( + groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + ) = apply { + groupingKey = groupedWithMinMaxThresholdsConfig.groupingKey + maximumCharge = groupedWithMinMaxThresholdsConfig.maximumCharge + minimumCharge = groupedWithMinMaxThresholdsConfig.minimumCharge + perUnitRate = groupedWithMinMaxThresholdsConfig.perUnitRate + additionalProperties = + groupedWithMinMaxThresholdsConfig.additionalProperties + .toMutableMap() } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (tiers.asKnown()?.sumOf { it.validity().toInt() } ?: 0) - - /** Configuration for a single tiered with proration tier */ - class Tier - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val tierLowerBound: JsonField, - private val unitAmount: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("tier_lower_bound") - @ExcludeMissing - tierLowerBound: JsonField = JsonMissing.of(), - @JsonProperty("unit_amount") - @ExcludeMissing - unitAmount: JsonField = JsonMissing.of(), - ) : this(tierLowerBound, unitAmount, mutableMapOf()) - - /** - * Inclusive tier starting value - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type - * or is unexpectedly missing or null (e.g. if the server responded with - * an unexpected value). - */ - fun tierLowerBound(): String = - tierLowerBound.getRequired("tier_lower_bound") + /** The event property used to group before applying thresholds */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) /** - * Amount per unit + * Sets [Builder.groupingKey] to an arbitrary JSON value. * - * @throws OrbInvalidDataException if the JSON field has an unexpected type - * or is unexpectedly missing or null (e.g. if the server responded with - * an unexpected value). + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. */ - fun unitAmount(): String = unitAmount.getRequired("unit_amount") + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } - /** - * Returns the raw JSON value of [tierLowerBound]. - * - * Unlike [tierLowerBound], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("tier_lower_bound") - @ExcludeMissing - fun _tierLowerBound(): JsonField = tierLowerBound + /** The maximum amount to charge each group */ + fun maximumCharge(maximumCharge: String) = + maximumCharge(JsonField.of(maximumCharge)) /** - * Returns the raw JSON value of [unitAmount]. + * Sets [Builder.maximumCharge] to an arbitrary JSON value. * - * Unlike [unitAmount], this method doesn't throw if the JSON field has an - * unexpected type. + * You should usually call [Builder.maximumCharge] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. */ - @JsonProperty("unit_amount") - @ExcludeMissing - fun _unitAmount(): JsonField = unitAmount - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [Tier]. - * - * The following fields are required: - * ```kotlin - * .tierLowerBound() - * .unitAmount() - * ``` - */ - fun builder() = Builder() - } - - /** A builder for [Tier]. */ - class Builder internal constructor() { - - private var tierLowerBound: JsonField? = null - private var unitAmount: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - internal fun from(tier: Tier) = apply { - tierLowerBound = tier.tierLowerBound - unitAmount = tier.unitAmount - additionalProperties = tier.additionalProperties.toMutableMap() - } - - /** Inclusive tier starting value */ - fun tierLowerBound(tierLowerBound: String) = - tierLowerBound(JsonField.of(tierLowerBound)) - - /** - * Sets [Builder.tierLowerBound] to an arbitrary JSON value. - * - * You should usually call [Builder.tierLowerBound] with a well-typed - * [String] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun tierLowerBound(tierLowerBound: JsonField) = apply { - this.tierLowerBound = tierLowerBound - } - - /** Amount per unit */ - fun unitAmount(unitAmount: String) = - unitAmount(JsonField.of(unitAmount)) - - /** - * Sets [Builder.unitAmount] to an arbitrary JSON value. - * - * You should usually call [Builder.unitAmount] with a well-typed - * [String] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun unitAmount(unitAmount: JsonField) = apply { - this.unitAmount = unitAmount - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Tier]. - * - * Further updates to this [Builder] will not mutate the returned - * instance. - * - * The following fields are required: - * ```kotlin - * .tierLowerBound() - * .unitAmount() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Tier = - Tier( - checkRequired("tierLowerBound", tierLowerBound), - checkRequired("unitAmount", unitAmount), - additionalProperties.toMutableMap(), - ) + fun maximumCharge(maximumCharge: JsonField) = apply { + this.maximumCharge = maximumCharge } - private var validated: Boolean = false - - fun validate(): Tier = apply { - if (validated) { - return@apply - } + /** The minimum amount to charge each group, regardless of usage */ + fun minimumCharge(minimumCharge: String) = + minimumCharge(JsonField.of(minimumCharge)) - tierLowerBound() - unitAmount() - validated = true + /** + * Sets [Builder.minimumCharge] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumCharge] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun minimumCharge(minimumCharge: JsonField) = apply { + this.minimumCharge = minimumCharge } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** The base price charged per group */ + fun perUnitRate(perUnitRate: String) = + perUnitRate(JsonField.of(perUnitRate)) /** - * Returns a score indicating how many valid values are contained in this - * object recursively. + * Sets [Builder.perUnitRate] to an arbitrary JSON value. * - * Used for best match union deserialization. + * You should usually call [Builder.perUnitRate] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. */ - internal fun validity(): Int = - (if (tierLowerBound.asKnown() == null) 0 else 1) + - (if (unitAmount.asKnown() == null) 0 else 1) + fun perUnitRate(perUnitRate: JsonField) = apply { + this.perUnitRate = perUnitRate + } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) } - return other is Tier && - tierLowerBound == other.tierLowerBound && - unitAmount == other.unitAmount && - additionalProperties == other.additionalProperties + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) } - private val hashCode: Int by lazy { - Objects.hash(tierLowerBound, unitAmount, additionalProperties) + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) } - override fun hashCode(): Int = hashCode + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - override fun toString() = - "Tier{tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + /** + * Returns an immutable instance of [GroupedWithMinMaxThresholdsConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .maximumCharge() + * .minimumCharge() + * .perUnitRate() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedWithMinMaxThresholdsConfig = + GroupedWithMinMaxThresholdsConfig( + checkRequired("groupingKey", groupingKey), + checkRequired("maximumCharge", maximumCharge), + checkRequired("minimumCharge", minimumCharge), + checkRequired("perUnitRate", perUnitRate), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GroupedWithMinMaxThresholdsConfig = apply { + if (validated) { + return@apply + } + + groupingKey() + maximumCharge() + minimumCharge() + perUnitRate() + validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (groupingKey.asKnown() == null) 0 else 1) + + (if (maximumCharge.asKnown() == null) 0 else 1) + + (if (minimumCharge.asKnown() == null) 0 else 1) + + (if (perUnitRate.asKnown() == null) 0 else 1) + override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is TieredWithProrationConfig && - tiers == other.tiers && + return other is GroupedWithMinMaxThresholdsConfig && + groupingKey == other.groupingKey && + maximumCharge == other.maximumCharge && + minimumCharge == other.minimumCharge && + perUnitRate == other.perUnitRate && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(tiers, additionalProperties) } + private val hashCode: Int by lazy { + Objects.hash( + groupingKey, + maximumCharge, + minimumCharge, + perUnitRate, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode override fun toString() = - "TieredWithProrationConfig{tiers=$tiers, additionalProperties=$additionalProperties}" + "GroupedWithMinMaxThresholdsConfig{groupingKey=$groupingKey, maximumCharge=$maximumCharge, minimumCharge=$minimumCharge, perUnitRate=$perUnitRate, additionalProperties=$additionalProperties}" } /** @@ -12565,12 +15837,13 @@ private constructor( return true } - return other is TieredWithProration && + return other is GroupedWithMinMaxThresholds && cadence == other.cadence && + groupedWithMinMaxThresholdsConfig == + other.groupedWithMinMaxThresholdsConfig && itemId == other.itemId && modelType == other.modelType && name == other.name && - tieredWithProrationConfig == other.tieredWithProrationConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && @@ -12590,10 +15863,10 @@ private constructor( private val hashCode: Int by lazy { Objects.hash( cadence, + groupedWithMinMaxThresholdsConfig, itemId, modelType, name, - tieredWithProrationConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -12614,18 +15887,17 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "TieredWithProration{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredWithProrationConfig=$tieredWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "GroupedWithMinMaxThresholds{cadence=$cadence, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class GroupedWithMinMaxThresholds + class Percent @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, - private val groupedWithMinMaxThresholdsConfig: - JsonField, private val itemId: JsonField, private val modelType: JsonValue, private val name: JsonField, + private val percentConfig: JsonField, private val billableMetricId: JsonField, private val billedInAdvance: JsonField, private val billingCycleConfiguration: JsonField, @@ -12648,11 +15920,6 @@ private constructor( @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), - @JsonProperty("grouped_with_min_max_thresholds_config") - @ExcludeMissing - groupedWithMinMaxThresholdsConfig: - JsonField = - JsonMissing.of(), @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), @@ -12662,6 +15929,9 @@ private constructor( @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("percent_config") + @ExcludeMissing + percentConfig: JsonField = JsonMissing.of(), @JsonProperty("billable_metric_id") @ExcludeMissing billableMetricId: JsonField = JsonMissing.of(), @@ -12706,10 +15976,10 @@ private constructor( referenceId: JsonField = JsonMissing.of(), ) : this( cadence, - groupedWithMinMaxThresholdsConfig, itemId, modelType, name, + percentConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -12735,18 +16005,6 @@ private constructor( */ fun cadence(): Cadence = cadence.getRequired("cadence") - /** - * Configuration for grouped_with_min_max_thresholds pricing - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun groupedWithMinMaxThresholdsConfig(): GroupedWithMinMaxThresholdsConfig = - groupedWithMinMaxThresholdsConfig.getRequired( - "grouped_with_min_max_thresholds_config" - ) - /** * The id of the item the price will be associated with. * @@ -12761,7 +16019,7 @@ private constructor( * * Expected to always return the following: * ```kotlin - * JsonValue.from("grouped_with_min_max_thresholds") + * JsonValue.from("percent") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -12778,6 +16036,15 @@ private constructor( */ fun name(): String = name.getRequired("name") + /** + * Configuration for percent pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun percentConfig(): PercentConfig = percentConfig.getRequired("percent_config") + /** * The id of the billable metric for the price. Only needed if the price is * usage-based. @@ -12907,17 +16174,6 @@ private constructor( @ExcludeMissing fun _cadence(): JsonField = cadence - /** - * Returns the raw JSON value of [groupedWithMinMaxThresholdsConfig]. - * - * Unlike [groupedWithMinMaxThresholdsConfig], this method doesn't throw if the JSON - * field has an unexpected type. - */ - @JsonProperty("grouped_with_min_max_thresholds_config") - @ExcludeMissing - fun _groupedWithMinMaxThresholdsConfig(): - JsonField = groupedWithMinMaxThresholdsConfig - /** * Returns the raw JSON value of [itemId]. * @@ -12934,6 +16190,16 @@ private constructor( */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + /** + * Returns the raw JSON value of [percentConfig]. + * + * Unlike [percentConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("percent_config") + @ExcludeMissing + fun _percentConfig(): JsonField = percentConfig + /** * Returns the raw JSON value of [billableMetricId]. * @@ -13082,79 +16348,69 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [GroupedWithMinMaxThresholds]. + * Returns a mutable builder for constructing an instance of [Percent]. * * The following fields are required: * ```kotlin * .cadence() - * .groupedWithMinMaxThresholdsConfig() * .itemId() * .name() + * .percentConfig() * ``` */ fun builder() = Builder() } - /** A builder for [GroupedWithMinMaxThresholds]. */ + /** A builder for [Percent]. */ class Builder internal constructor() { private var cadence: JsonField? = null - private var groupedWithMinMaxThresholdsConfig: - JsonField? = - null private var itemId: JsonField? = null - private var modelType: JsonValue = - JsonValue.from("grouped_with_min_max_thresholds") + private var modelType: JsonValue = JsonValue.from("percent") private var name: JsonField? = null + private var percentConfig: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() private var billingCycleConfiguration: JsonField = JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var conversionRateConfig: JsonField = - JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var dimensionalPriceConfiguration: - JsonField = - JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: - JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var referenceId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds) = - apply { - cadence = groupedWithMinMaxThresholds.cadence - groupedWithMinMaxThresholdsConfig = - groupedWithMinMaxThresholds.groupedWithMinMaxThresholdsConfig - itemId = groupedWithMinMaxThresholds.itemId - modelType = groupedWithMinMaxThresholds.modelType - name = groupedWithMinMaxThresholds.name - billableMetricId = groupedWithMinMaxThresholds.billableMetricId - billedInAdvance = groupedWithMinMaxThresholds.billedInAdvance - billingCycleConfiguration = - groupedWithMinMaxThresholds.billingCycleConfiguration - conversionRate = groupedWithMinMaxThresholds.conversionRate - conversionRateConfig = groupedWithMinMaxThresholds.conversionRateConfig - currency = groupedWithMinMaxThresholds.currency - dimensionalPriceConfiguration = - groupedWithMinMaxThresholds.dimensionalPriceConfiguration - externalPriceId = groupedWithMinMaxThresholds.externalPriceId - fixedPriceQuantity = groupedWithMinMaxThresholds.fixedPriceQuantity - invoiceGroupingKey = groupedWithMinMaxThresholds.invoiceGroupingKey - invoicingCycleConfiguration = - groupedWithMinMaxThresholds.invoicingCycleConfiguration - metadata = groupedWithMinMaxThresholds.metadata - referenceId = groupedWithMinMaxThresholds.referenceId - additionalProperties = - groupedWithMinMaxThresholds.additionalProperties.toMutableMap() - } + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(percent: Percent) = apply { + cadence = percent.cadence + itemId = percent.itemId + modelType = percent.modelType + name = percent.name + percentConfig = percent.percentConfig + billableMetricId = percent.billableMetricId + billedInAdvance = percent.billedInAdvance + billingCycleConfiguration = percent.billingCycleConfiguration + conversionRate = percent.conversionRate + conversionRateConfig = percent.conversionRateConfig + currency = percent.currency + dimensionalPriceConfiguration = percent.dimensionalPriceConfiguration + externalPriceId = percent.externalPriceId + fixedPriceQuantity = percent.fixedPriceQuantity + invoiceGroupingKey = percent.invoiceGroupingKey + invoicingCycleConfiguration = percent.invoicingCycleConfiguration + metadata = percent.metadata + referenceId = percent.referenceId + additionalProperties = percent.additionalProperties.toMutableMap() + } /** The cadence to bill for this price on. */ fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) @@ -13168,29 +16424,6 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - /** Configuration for grouped_with_min_max_thresholds pricing */ - fun groupedWithMinMaxThresholdsConfig( - groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig - ) = - groupedWithMinMaxThresholdsConfig( - JsonField.of(groupedWithMinMaxThresholdsConfig) - ) - - /** - * Sets [Builder.groupedWithMinMaxThresholdsConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.groupedWithMinMaxThresholdsConfig] with a - * well-typed [GroupedWithMinMaxThresholdsConfig] value instead. This method is - * primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun groupedWithMinMaxThresholdsConfig( - groupedWithMinMaxThresholdsConfig: - JsonField - ) = apply { - this.groupedWithMinMaxThresholdsConfig = groupedWithMinMaxThresholdsConfig - } - /** The id of the item the price will be associated with. */ fun itemId(itemId: String) = itemId(JsonField.of(itemId)) @@ -13209,7 +16442,7 @@ private constructor( * It is usually unnecessary to call this method because the field defaults to * the following: * ```kotlin - * JsonValue.from("grouped_with_min_max_thresholds") + * JsonValue.from("percent") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -13229,6 +16462,21 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } + /** Configuration for percent pricing */ + fun percentConfig(percentConfig: PercentConfig) = + percentConfig(JsonField.of(percentConfig)) + + /** + * Sets [Builder.percentConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.percentConfig] with a well-typed + * [PercentConfig] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun percentConfig(percentConfig: JsonField) = apply { + this.percentConfig = percentConfig + } + /** * The id of the billable metric for the price. Only needed if the price is * usage-based. @@ -13558,30 +16806,27 @@ private constructor( } /** - * Returns an immutable instance of [GroupedWithMinMaxThresholds]. + * Returns an immutable instance of [Percent]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```kotlin * .cadence() - * .groupedWithMinMaxThresholdsConfig() * .itemId() * .name() + * .percentConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): GroupedWithMinMaxThresholds = - GroupedWithMinMaxThresholds( + fun build(): Percent = + Percent( checkRequired("cadence", cadence), - checkRequired( - "groupedWithMinMaxThresholdsConfig", - groupedWithMinMaxThresholdsConfig, - ), checkRequired("itemId", itemId), modelType, checkRequired("name", name), + checkRequired("percentConfig", percentConfig), billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -13601,20 +16846,20 @@ private constructor( private var validated: Boolean = false - fun validate(): GroupedWithMinMaxThresholds = apply { + fun validate(): Percent = apply { if (validated) { return@apply } cadence().validate() - groupedWithMinMaxThresholdsConfig().validate() itemId() _modelType().let { - if (it != JsonValue.from("grouped_with_min_max_thresholds")) { + if (it != JsonValue.from("percent")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } name() + percentConfig().validate() billableMetricId() billedInAdvance() billingCycleConfiguration()?.validate() @@ -13647,12 +16892,10 @@ private constructor( */ internal fun validity(): Int = (cadence.asKnown()?.validity() ?: 0) + - (groupedWithMinMaxThresholdsConfig.asKnown()?.validity() ?: 0) + (if (itemId.asKnown() == null) 0 else 1) + - modelType.let { - if (it == JsonValue.from("grouped_with_min_max_thresholds")) 1 else 0 - } + + modelType.let { if (it == JsonValue.from("percent")) 1 else 0 } + (if (name.asKnown() == null) 0 else 1) + + (percentConfig.asKnown()?.validity() ?: 0) + (if (billableMetricId.asKnown() == null) 0 else 1) + (if (billedInAdvance.asKnown() == null) 0 else 1) + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + @@ -13824,108 +17067,39 @@ private constructor( override fun toString() = value.toString() } - /** Configuration for grouped_with_min_max_thresholds pricing */ - class GroupedWithMinMaxThresholdsConfig + /** Configuration for percent pricing */ + class PercentConfig @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val groupingKey: JsonField, - private val maximumCharge: JsonField, - private val minimumCharge: JsonField, - private val perUnitRate: JsonField, + private val percent: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("grouping_key") - @ExcludeMissing - groupingKey: JsonField = JsonMissing.of(), - @JsonProperty("maximum_charge") - @ExcludeMissing - maximumCharge: JsonField = JsonMissing.of(), - @JsonProperty("minimum_charge") + @JsonProperty("percent") @ExcludeMissing - minimumCharge: JsonField = JsonMissing.of(), - @JsonProperty("per_unit_rate") - @ExcludeMissing - perUnitRate: JsonField = JsonMissing.of(), - ) : this(groupingKey, maximumCharge, minimumCharge, perUnitRate, mutableMapOf()) - - /** - * The event property used to group before applying thresholds - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun groupingKey(): String = groupingKey.getRequired("grouping_key") - - /** - * The maximum amount to charge each group - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun maximumCharge(): String = maximumCharge.getRequired("maximum_charge") - - /** - * The minimum amount to charge each group, regardless of usage - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun minimumCharge(): String = minimumCharge.getRequired("minimum_charge") + percent: JsonField = JsonMissing.of() + ) : this(percent, mutableMapOf()) /** - * The base price charged per group + * What percent of the component subtotals to charge * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). */ - fun perUnitRate(): String = perUnitRate.getRequired("per_unit_rate") - - /** - * Returns the raw JSON value of [groupingKey]. - * - * Unlike [groupingKey], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("grouping_key") - @ExcludeMissing - fun _groupingKey(): JsonField = groupingKey - - /** - * Returns the raw JSON value of [maximumCharge]. - * - * Unlike [maximumCharge], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("maximum_charge") - @ExcludeMissing - fun _maximumCharge(): JsonField = maximumCharge - - /** - * Returns the raw JSON value of [minimumCharge]. - * - * Unlike [minimumCharge], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("minimum_charge") - @ExcludeMissing - fun _minimumCharge(): JsonField = minimumCharge + fun percent(): Double = percent.getRequired("percent") /** - * Returns the raw JSON value of [perUnitRate]. + * Returns the raw JSON value of [percent]. * - * Unlike [perUnitRate], this method doesn't throw if the JSON field has an + * Unlike [percent], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("per_unit_rate") + @JsonProperty("percent") @ExcludeMissing - fun _perUnitRate(): JsonField = perUnitRate + fun _percent(): JsonField = percent @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -13943,100 +17117,39 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [GroupedWithMinMaxThresholdsConfig]. + * [PercentConfig]. * * The following fields are required: * ```kotlin - * .groupingKey() - * .maximumCharge() - * .minimumCharge() - * .perUnitRate() + * .percent() * ``` */ fun builder() = Builder() } - /** A builder for [GroupedWithMinMaxThresholdsConfig]. */ + /** A builder for [PercentConfig]. */ class Builder internal constructor() { - private var groupingKey: JsonField? = null - private var maximumCharge: JsonField? = null - private var minimumCharge: JsonField? = null - private var perUnitRate: JsonField? = null + private var percent: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() - internal fun from( - groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig - ) = apply { - groupingKey = groupedWithMinMaxThresholdsConfig.groupingKey - maximumCharge = groupedWithMinMaxThresholdsConfig.maximumCharge - minimumCharge = groupedWithMinMaxThresholdsConfig.minimumCharge - perUnitRate = groupedWithMinMaxThresholdsConfig.perUnitRate - additionalProperties = - groupedWithMinMaxThresholdsConfig.additionalProperties - .toMutableMap() - } - - /** The event property used to group before applying thresholds */ - fun groupingKey(groupingKey: String) = - groupingKey(JsonField.of(groupingKey)) - - /** - * Sets [Builder.groupingKey] to an arbitrary JSON value. - * - * You should usually call [Builder.groupingKey] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun groupingKey(groupingKey: JsonField) = apply { - this.groupingKey = groupingKey - } - - /** The maximum amount to charge each group */ - fun maximumCharge(maximumCharge: String) = - maximumCharge(JsonField.of(maximumCharge)) - - /** - * Sets [Builder.maximumCharge] to an arbitrary JSON value. - * - * You should usually call [Builder.maximumCharge] with a well-typed - * [String] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun maximumCharge(maximumCharge: JsonField) = apply { - this.maximumCharge = maximumCharge - } - - /** The minimum amount to charge each group, regardless of usage */ - fun minimumCharge(minimumCharge: String) = - minimumCharge(JsonField.of(minimumCharge)) - - /** - * Sets [Builder.minimumCharge] to an arbitrary JSON value. - * - * You should usually call [Builder.minimumCharge] with a well-typed - * [String] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun minimumCharge(minimumCharge: JsonField) = apply { - this.minimumCharge = minimumCharge + internal fun from(percentConfig: PercentConfig) = apply { + percent = percentConfig.percent + additionalProperties = percentConfig.additionalProperties.toMutableMap() } - /** The base price charged per group */ - fun perUnitRate(perUnitRate: String) = - perUnitRate(JsonField.of(perUnitRate)) + /** What percent of the component subtotals to charge */ + fun percent(percent: Double) = percent(JsonField.of(percent)) /** - * Sets [Builder.perUnitRate] to an arbitrary JSON value. + * Sets [Builder.percent] to an arbitrary JSON value. * - * You should usually call [Builder.perUnitRate] with a well-typed [String] + * You should usually call [Builder.percent] with a well-typed [Double] * value instead. This method is primarily for setting the field to an * undocumented or not yet supported value. */ - fun perUnitRate(perUnitRate: JsonField) = apply { - this.perUnitRate = perUnitRate - } + fun percent(percent: JsonField) = apply { this.percent = percent } fun additionalProperties(additionalProperties: Map) = apply { @@ -14061,41 +17174,32 @@ private constructor( } /** - * Returns an immutable instance of [GroupedWithMinMaxThresholdsConfig]. + * Returns an immutable instance of [PercentConfig]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```kotlin - * .groupingKey() - * .maximumCharge() - * .minimumCharge() - * .perUnitRate() + * .percent() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): GroupedWithMinMaxThresholdsConfig = - GroupedWithMinMaxThresholdsConfig( - checkRequired("groupingKey", groupingKey), - checkRequired("maximumCharge", maximumCharge), - checkRequired("minimumCharge", minimumCharge), - checkRequired("perUnitRate", perUnitRate), + fun build(): PercentConfig = + PercentConfig( + checkRequired("percent", percent), additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): GroupedWithMinMaxThresholdsConfig = apply { + fun validate(): PercentConfig = apply { if (validated) { return@apply } - groupingKey() - maximumCharge() - minimumCharge() - perUnitRate() + percent() validated = true } @@ -14113,39 +17217,26 @@ private constructor( * * Used for best match union deserialization. */ - internal fun validity(): Int = - (if (groupingKey.asKnown() == null) 0 else 1) + - (if (maximumCharge.asKnown() == null) 0 else 1) + - (if (minimumCharge.asKnown() == null) 0 else 1) + - (if (perUnitRate.asKnown() == null) 0 else 1) + internal fun validity(): Int = (if (percent.asKnown() == null) 0 else 1) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is GroupedWithMinMaxThresholdsConfig && - groupingKey == other.groupingKey && - maximumCharge == other.maximumCharge && - minimumCharge == other.minimumCharge && - perUnitRate == other.perUnitRate && + return other is PercentConfig && + percent == other.percent && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash( - groupingKey, - maximumCharge, - minimumCharge, - perUnitRate, - additionalProperties, - ) + Objects.hash(percent, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "GroupedWithMinMaxThresholdsConfig{groupingKey=$groupingKey, maximumCharge=$maximumCharge, minimumCharge=$minimumCharge, perUnitRate=$perUnitRate, additionalProperties=$additionalProperties}" + "PercentConfig{percent=$percent, additionalProperties=$additionalProperties}" } /** @@ -14262,13 +17353,12 @@ private constructor( return true } - return other is GroupedWithMinMaxThresholds && + return other is Percent && cadence == other.cadence && - groupedWithMinMaxThresholdsConfig == - other.groupedWithMinMaxThresholdsConfig && itemId == other.itemId && modelType == other.modelType && name == other.name && + percentConfig == other.percentConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && @@ -14288,10 +17378,10 @@ private constructor( private val hashCode: Int by lazy { Objects.hash( cadence, - groupedWithMinMaxThresholdsConfig, itemId, modelType, name, + percentConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -14312,7 +17402,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "GroupedWithMinMaxThresholds{cadence=$cadence, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "Percent{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, percentConfig=$percentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } class EventOutput diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BetaExternalPlanIdCreatePlanVersionParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BetaExternalPlanIdCreatePlanVersionParams.kt index 56a93152b..c4fb755a9 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BetaExternalPlanIdCreatePlanVersionParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BetaExternalPlanIdCreatePlanVersionParams.kt @@ -1971,6 +1971,9 @@ private constructor( /** Alias for calling [price] with `Price.ofMinimum(minimum)`. */ fun price(minimum: NewPlanMinimumCompositePrice) = price(Price.ofMinimum(minimum)) + /** Alias for calling [price] with `Price.ofPercent(percent)`. */ + fun price(percent: Price.Percent) = price(Price.ofPercent(percent)) + /** Alias for calling [price] with `Price.ofEventOutput(eventOutput)`. */ fun price(eventOutput: Price.EventOutput) = price(Price.ofEventOutput(eventOutput)) @@ -2074,6 +2077,7 @@ private constructor( null, private val cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice? = null, private val minimum: NewPlanMinimumCompositePrice? = null, + private val percent: Percent? = null, private val eventOutput: EventOutput? = null, private val _json: JsonValue? = null, ) { @@ -2138,6 +2142,8 @@ private constructor( fun minimum(): NewPlanMinimumCompositePrice? = minimum + fun percent(): Percent? = percent + fun eventOutput(): EventOutput? = eventOutput fun isUnit(): Boolean = unit != null @@ -2195,6 +2201,8 @@ private constructor( fun isMinimum(): Boolean = minimum != null + fun isPercent(): Boolean = percent != null + fun isEventOutput(): Boolean = eventOutput != null fun asUnit(): NewPlanUnitPrice = unit.getOrThrow("unit") @@ -2272,6 +2280,8 @@ private constructor( fun asMinimum(): NewPlanMinimumCompositePrice = minimum.getOrThrow("minimum") + fun asPercent(): Percent = percent.getOrThrow("percent") + fun asEventOutput(): EventOutput = eventOutput.getOrThrow("eventOutput") fun _json(): JsonValue? = _json @@ -2321,6 +2331,7 @@ private constructor( cumulativeGroupedBulk != null -> visitor.visitCumulativeGroupedBulk(cumulativeGroupedBulk) minimum != null -> visitor.visitMinimum(minimum) + percent != null -> visitor.visitPercent(percent) eventOutput != null -> visitor.visitEventOutput(eventOutput) else -> visitor.unknown(_json) } @@ -2481,6 +2492,10 @@ private constructor( minimum.validate() } + override fun visitPercent(percent: Percent) { + percent.validate() + } + override fun visitEventOutput(eventOutput: EventOutput) { eventOutput.validate() } @@ -2603,6 +2618,8 @@ private constructor( override fun visitMinimum(minimum: NewPlanMinimumCompositePrice) = minimum.validity() + override fun visitPercent(percent: Percent) = percent.validity() + override fun visitEventOutput(eventOutput: EventOutput) = eventOutput.validity() @@ -2643,6 +2660,7 @@ private constructor( scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && cumulativeGroupedBulk == other.cumulativeGroupedBulk && minimum == other.minimum && + percent == other.percent && eventOutput == other.eventOutput } @@ -2675,6 +2693,7 @@ private constructor( scalableMatrixWithTieredPricing, cumulativeGroupedBulk, minimum, + percent, eventOutput, ) @@ -2720,6 +2739,7 @@ private constructor( cumulativeGroupedBulk != null -> "Price{cumulativeGroupedBulk=$cumulativeGroupedBulk}" minimum != null -> "Price{minimum=$minimum}" + percent != null -> "Price{percent=$percent}" eventOutput != null -> "Price{eventOutput=$eventOutput}" _json != null -> "Price{_unknown=$_json}" else -> throw IllegalStateException("Invalid Price") @@ -2812,6 +2832,8 @@ private constructor( fun ofMinimum(minimum: NewPlanMinimumCompositePrice) = Price(minimum = minimum) + fun ofPercent(percent: Percent) = Price(percent = percent) + fun ofEventOutput(eventOutput: EventOutput) = Price(eventOutput = eventOutput) } @@ -2900,6 +2922,8 @@ private constructor( fun visitMinimum(minimum: NewPlanMinimumCompositePrice): T + fun visitPercent(percent: Percent): T + fun visitEventOutput(eventOutput: EventOutput): T /** @@ -3114,6 +3138,11 @@ private constructor( ) ?.let { Price(minimum = it, _json = json) } ?: Price(_json = json) } + "percent" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(percent = it, _json = json) + } ?: Price(_json = json) + } "event_output" -> { return tryDeserialize(node, jacksonTypeRef())?.let { Price(eventOutput = it, _json = json) @@ -3179,6 +3208,7 @@ private constructor( value.cumulativeGroupedBulk != null -> generator.writeObject(value.cumulativeGroupedBulk) value.minimum != null -> generator.writeObject(value.minimum) + value.percent != null -> generator.writeObject(value.percent) value.eventOutput != null -> generator.writeObject(value.eventOutput) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid Price") @@ -6653,14 +6683,14 @@ private constructor( "GroupedWithMinMaxThresholds{cadence=$cadence, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class EventOutput + class Percent @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, - private val eventOutputConfig: JsonField, private val itemId: JsonField, private val modelType: JsonValue, private val name: JsonField, + private val percentConfig: JsonField, private val billableMetricId: JsonField, private val billedInAdvance: JsonField, private val billingCycleConfiguration: JsonField, @@ -6683,9 +6713,6 @@ private constructor( @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), - @JsonProperty("event_output_config") - @ExcludeMissing - eventOutputConfig: JsonField = JsonMissing.of(), @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), @@ -6695,6 +6722,9 @@ private constructor( @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("percent_config") + @ExcludeMissing + percentConfig: JsonField = JsonMissing.of(), @JsonProperty("billable_metric_id") @ExcludeMissing billableMetricId: JsonField = JsonMissing.of(), @@ -6739,10 +6769,10 @@ private constructor( referenceId: JsonField = JsonMissing.of(), ) : this( cadence, - eventOutputConfig, itemId, modelType, name, + percentConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -6768,16 +6798,6 @@ private constructor( */ fun cadence(): Cadence = cadence.getRequired("cadence") - /** - * Configuration for event_output pricing - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun eventOutputConfig(): EventOutputConfig = - eventOutputConfig.getRequired("event_output_config") - /** * The id of the item the price will be associated with. * @@ -6792,7 +6812,7 @@ private constructor( * * Expected to always return the following: * ```kotlin - * JsonValue.from("event_output") + * JsonValue.from("percent") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -6809,6 +6829,15 @@ private constructor( */ fun name(): String = name.getRequired("name") + /** + * Configuration for percent pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun percentConfig(): PercentConfig = percentConfig.getRequired("percent_config") + /** * The id of the billable metric for the price. Only needed if the price is * usage-based. @@ -6938,16 +6967,6 @@ private constructor( @ExcludeMissing fun _cadence(): JsonField = cadence - /** - * Returns the raw JSON value of [eventOutputConfig]. - * - * Unlike [eventOutputConfig], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("event_output_config") - @ExcludeMissing - fun _eventOutputConfig(): JsonField = eventOutputConfig - /** * Returns the raw JSON value of [itemId]. * @@ -6964,6 +6983,16 @@ private constructor( */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + /** + * Returns the raw JSON value of [percentConfig]. + * + * Unlike [percentConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("percent_config") + @ExcludeMissing + fun _percentConfig(): JsonField = percentConfig + /** * Returns the raw JSON value of [billableMetricId]. * @@ -7112,27 +7141,27 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [EventOutput]. + * Returns a mutable builder for constructing an instance of [Percent]. * * The following fields are required: * ```kotlin * .cadence() - * .eventOutputConfig() * .itemId() * .name() + * .percentConfig() * ``` */ fun builder() = Builder() } - /** A builder for [EventOutput]. */ + /** A builder for [Percent]. */ class Builder internal constructor() { private var cadence: JsonField? = null - private var eventOutputConfig: JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonValue = JsonValue.from("event_output") + private var modelType: JsonValue = JsonValue.from("percent") private var name: JsonField? = null + private var percentConfig: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() private var billingCycleConfiguration: JsonField = @@ -7154,26 +7183,26 @@ private constructor( private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(eventOutput: EventOutput) = apply { - cadence = eventOutput.cadence - eventOutputConfig = eventOutput.eventOutputConfig - itemId = eventOutput.itemId - modelType = eventOutput.modelType - name = eventOutput.name - billableMetricId = eventOutput.billableMetricId - billedInAdvance = eventOutput.billedInAdvance - billingCycleConfiguration = eventOutput.billingCycleConfiguration - conversionRate = eventOutput.conversionRate - conversionRateConfig = eventOutput.conversionRateConfig - currency = eventOutput.currency - dimensionalPriceConfiguration = eventOutput.dimensionalPriceConfiguration - externalPriceId = eventOutput.externalPriceId - fixedPriceQuantity = eventOutput.fixedPriceQuantity - invoiceGroupingKey = eventOutput.invoiceGroupingKey - invoicingCycleConfiguration = eventOutput.invoicingCycleConfiguration - metadata = eventOutput.metadata - referenceId = eventOutput.referenceId - additionalProperties = eventOutput.additionalProperties.toMutableMap() + internal fun from(percent: Percent) = apply { + cadence = percent.cadence + itemId = percent.itemId + modelType = percent.modelType + name = percent.name + percentConfig = percent.percentConfig + billableMetricId = percent.billableMetricId + billedInAdvance = percent.billedInAdvance + billingCycleConfiguration = percent.billingCycleConfiguration + conversionRate = percent.conversionRate + conversionRateConfig = percent.conversionRateConfig + currency = percent.currency + dimensionalPriceConfiguration = percent.dimensionalPriceConfiguration + externalPriceId = percent.externalPriceId + fixedPriceQuantity = percent.fixedPriceQuantity + invoiceGroupingKey = percent.invoiceGroupingKey + invoicingCycleConfiguration = percent.invoicingCycleConfiguration + metadata = percent.metadata + referenceId = percent.referenceId + additionalProperties = percent.additionalProperties.toMutableMap() } /** The cadence to bill for this price on. */ @@ -7188,21 +7217,6 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - /** Configuration for event_output pricing */ - fun eventOutputConfig(eventOutputConfig: EventOutputConfig) = - eventOutputConfig(JsonField.of(eventOutputConfig)) - - /** - * Sets [Builder.eventOutputConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.eventOutputConfig] with a well-typed - * [EventOutputConfig] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun eventOutputConfig(eventOutputConfig: JsonField) = apply { - this.eventOutputConfig = eventOutputConfig - } - /** The id of the item the price will be associated with. */ fun itemId(itemId: String) = itemId(JsonField.of(itemId)) @@ -7221,7 +7235,7 @@ private constructor( * It is usually unnecessary to call this method because the field defaults to * the following: * ```kotlin - * JsonValue.from("event_output") + * JsonValue.from("percent") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -7241,6 +7255,21 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } + /** Configuration for percent pricing */ + fun percentConfig(percentConfig: PercentConfig) = + percentConfig(JsonField.of(percentConfig)) + + /** + * Sets [Builder.percentConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.percentConfig] with a well-typed + * [PercentConfig] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun percentConfig(percentConfig: JsonField) = apply { + this.percentConfig = percentConfig + } + /** * The id of the billable metric for the price. Only needed if the price is * usage-based. @@ -7570,27 +7599,27 @@ private constructor( } /** - * Returns an immutable instance of [EventOutput]. + * Returns an immutable instance of [Percent]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```kotlin * .cadence() - * .eventOutputConfig() * .itemId() * .name() + * .percentConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): EventOutput = - EventOutput( + fun build(): Percent = + Percent( checkRequired("cadence", cadence), - checkRequired("eventOutputConfig", eventOutputConfig), checkRequired("itemId", itemId), modelType, checkRequired("name", name), + checkRequired("percentConfig", percentConfig), billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -7610,20 +7639,20 @@ private constructor( private var validated: Boolean = false - fun validate(): EventOutput = apply { + fun validate(): Percent = apply { if (validated) { return@apply } cadence().validate() - eventOutputConfig().validate() itemId() _modelType().let { - if (it != JsonValue.from("event_output")) { + if (it != JsonValue.from("percent")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } name() + percentConfig().validate() billableMetricId() billedInAdvance() billingCycleConfiguration()?.validate() @@ -7656,10 +7685,10 @@ private constructor( */ internal fun validity(): Int = (cadence.asKnown()?.validity() ?: 0) + - (eventOutputConfig.asKnown()?.validity() ?: 0) + (if (itemId.asKnown() == null) 0 else 1) + - modelType.let { if (it == JsonValue.from("event_output")) 1 else 0 } + + modelType.let { if (it == JsonValue.from("percent")) 1 else 0 } + (if (name.asKnown() == null) 0 else 1) + + (percentConfig.asKnown()?.validity() ?: 0) + (if (billableMetricId.asKnown() == null) 0 else 1) + (if (billedInAdvance.asKnown() == null) 0 else 1) + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + @@ -7831,62 +7860,39 @@ private constructor( override fun toString() = value.toString() } - /** Configuration for event_output pricing */ - class EventOutputConfig + /** Configuration for percent pricing */ + class PercentConfig @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val unitRatingKey: JsonField, - private val groupingKey: JsonField, + private val percent: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("unit_rating_key") - @ExcludeMissing - unitRatingKey: JsonField = JsonMissing.of(), - @JsonProperty("grouping_key") + @JsonProperty("percent") @ExcludeMissing - groupingKey: JsonField = JsonMissing.of(), - ) : this(unitRatingKey, groupingKey, mutableMapOf()) + percent: JsonField = JsonMissing.of() + ) : this(percent, mutableMapOf()) /** - * The key in the event data to extract the unit rate from. + * What percent of the component subtotals to charge * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). */ - fun unitRatingKey(): String = unitRatingKey.getRequired("unit_rating_key") - - /** - * An optional key in the event data to group by (e.g., event ID). All events - * will also be grouped by their unit rate. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun groupingKey(): String? = groupingKey.getNullable("grouping_key") - - /** - * Returns the raw JSON value of [unitRatingKey]. - * - * Unlike [unitRatingKey], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("unit_rating_key") - @ExcludeMissing - fun _unitRatingKey(): JsonField = unitRatingKey + fun percent(): Double = percent.getRequired("percent") /** - * Returns the raw JSON value of [groupingKey]. + * Returns the raw JSON value of [percent]. * - * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * Unlike [percent], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("grouping_key") + @JsonProperty("percent") @ExcludeMissing - fun _groupingKey(): JsonField = groupingKey + fun _percent(): JsonField = percent @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -7904,63 +7910,39 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [EventOutputConfig]. + * [PercentConfig]. * * The following fields are required: * ```kotlin - * .unitRatingKey() + * .percent() * ``` */ fun builder() = Builder() } - /** A builder for [EventOutputConfig]. */ + /** A builder for [PercentConfig]. */ class Builder internal constructor() { - private var unitRatingKey: JsonField? = null - private var groupingKey: JsonField = JsonMissing.of() + private var percent: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(eventOutputConfig: EventOutputConfig) = apply { - unitRatingKey = eventOutputConfig.unitRatingKey - groupingKey = eventOutputConfig.groupingKey - additionalProperties = - eventOutputConfig.additionalProperties.toMutableMap() - } - - /** The key in the event data to extract the unit rate from. */ - fun unitRatingKey(unitRatingKey: String) = - unitRatingKey(JsonField.of(unitRatingKey)) - - /** - * Sets [Builder.unitRatingKey] to an arbitrary JSON value. - * - * You should usually call [Builder.unitRatingKey] with a well-typed - * [String] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun unitRatingKey(unitRatingKey: JsonField) = apply { - this.unitRatingKey = unitRatingKey + internal fun from(percentConfig: PercentConfig) = apply { + percent = percentConfig.percent + additionalProperties = percentConfig.additionalProperties.toMutableMap() } - /** - * An optional key in the event data to group by (e.g., event ID). All - * events will also be grouped by their unit rate. - */ - fun groupingKey(groupingKey: String?) = - groupingKey(JsonField.ofNullable(groupingKey)) + /** What percent of the component subtotals to charge */ + fun percent(percent: Double) = percent(JsonField.of(percent)) /** - * Sets [Builder.groupingKey] to an arbitrary JSON value. + * Sets [Builder.percent] to an arbitrary JSON value. * - * You should usually call [Builder.groupingKey] with a well-typed [String] + * You should usually call [Builder.percent] with a well-typed [Double] * value instead. This method is primarily for setting the field to an * undocumented or not yet supported value. */ - fun groupingKey(groupingKey: JsonField) = apply { - this.groupingKey = groupingKey - } + fun percent(percent: JsonField) = apply { this.percent = percent } fun additionalProperties(additionalProperties: Map) = apply { @@ -7985,34 +7967,32 @@ private constructor( } /** - * Returns an immutable instance of [EventOutputConfig]. + * Returns an immutable instance of [PercentConfig]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```kotlin - * .unitRatingKey() + * .percent() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): EventOutputConfig = - EventOutputConfig( - checkRequired("unitRatingKey", unitRatingKey), - groupingKey, + fun build(): PercentConfig = + PercentConfig( + checkRequired("percent", percent), additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): EventOutputConfig = apply { + fun validate(): PercentConfig = apply { if (validated) { return@apply } - unitRatingKey() - groupingKey() + percent() validated = true } @@ -8030,29 +8010,26 @@ private constructor( * * Used for best match union deserialization. */ - internal fun validity(): Int = - (if (unitRatingKey.asKnown() == null) 0 else 1) + - (if (groupingKey.asKnown() == null) 0 else 1) + internal fun validity(): Int = (if (percent.asKnown() == null) 0 else 1) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is EventOutputConfig && - unitRatingKey == other.unitRatingKey && - groupingKey == other.groupingKey && + return other is PercentConfig && + percent == other.percent && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(unitRatingKey, groupingKey, additionalProperties) + Objects.hash(percent, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "EventOutputConfig{unitRatingKey=$unitRatingKey, groupingKey=$groupingKey, additionalProperties=$additionalProperties}" + "PercentConfig{percent=$percent, additionalProperties=$additionalProperties}" } /** @@ -8169,12 +8146,12 @@ private constructor( return true } - return other is EventOutput && + return other is Percent && cadence == other.cadence && - eventOutputConfig == other.eventOutputConfig && itemId == other.itemId && modelType == other.modelType && name == other.name && + percentConfig == other.percentConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && @@ -8194,10 +8171,10 @@ private constructor( private val hashCode: Int by lazy { Objects.hash( cadence, - eventOutputConfig, itemId, modelType, name, + percentConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -8218,1051 +8195,1575 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "EventOutput{cadence=$cadence, eventOutputConfig=$eventOutputConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + "Percent{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, percentConfig=$percentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - return other is AddPrice && - allocationPrice == other.allocationPrice && - planPhaseOrder == other.planPhaseOrder && - price == other.price && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(allocationPrice, planPhaseOrder, price, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "AddPrice{allocationPrice=$allocationPrice, planPhaseOrder=$planPhaseOrder, price=$price, additionalProperties=$additionalProperties}" - } - - class RemoveAdjustment - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val adjustmentId: JsonField, - private val planPhaseOrder: JsonField, - private val additionalProperties: MutableMap, - ) { + class EventOutput + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val eventOutputConfig: JsonField, + private val itemId: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { - @JsonCreator - private constructor( - @JsonProperty("adjustment_id") - @ExcludeMissing - adjustmentId: JsonField = JsonMissing.of(), - @JsonProperty("plan_phase_order") - @ExcludeMissing - planPhaseOrder: JsonField = JsonMissing.of(), - ) : this(adjustmentId, planPhaseOrder, mutableMapOf()) - - /** - * The id of the adjustment to remove from on the plan. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun adjustmentId(): String = adjustmentId.getRequired("adjustment_id") + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("event_output_config") + @ExcludeMissing + eventOutputConfig: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + eventOutputConfig, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + mutableMapOf(), + ) - /** - * The phase to remove this adjustment from. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun planPhaseOrder(): Long? = planPhaseOrder.getNullable("plan_phase_order") + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") - /** - * Returns the raw JSON value of [adjustmentId]. - * - * Unlike [adjustmentId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("adjustment_id") - @ExcludeMissing - fun _adjustmentId(): JsonField = adjustmentId + /** + * Configuration for event_output pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun eventOutputConfig(): EventOutputConfig = + eventOutputConfig.getRequired("event_output_config") - /** - * Returns the raw JSON value of [planPhaseOrder]. - * - * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("plan_phase_order") - @ExcludeMissing - fun _planPhaseOrder(): JsonField = planPhaseOrder + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("event_output") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") - fun toBuilder() = Builder().from(this) + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = billableMetricId.getNullable("billable_metric_id") - companion object { + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") - /** - * Returns a mutable builder for constructing an instance of [RemoveAdjustment]. - * - * The following fields are required: - * ```kotlin - * .adjustmentId() - * ``` - */ - fun builder() = Builder() - } + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") - /** A builder for [RemoveAdjustment]. */ - class Builder internal constructor() { + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") - private var adjustmentId: JsonField? = null - private var planPhaseOrder: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") - internal fun from(removeAdjustment: RemoveAdjustment) = apply { - adjustmentId = removeAdjustment.adjustmentId - planPhaseOrder = removeAdjustment.planPhaseOrder - additionalProperties = removeAdjustment.additionalProperties.toMutableMap() - } + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") - /** The id of the adjustment to remove from on the plan. */ - fun adjustmentId(adjustmentId: String) = adjustmentId(JsonField.of(adjustmentId)) + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") - /** - * Sets [Builder.adjustmentId] to an arbitrary JSON value. - * - * You should usually call [Builder.adjustmentId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun adjustmentId(adjustmentId: JsonField) = apply { - this.adjustmentId = adjustmentId - } - - /** The phase to remove this adjustment from. */ - fun planPhaseOrder(planPhaseOrder: Long?) = - planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") - /** - * Alias for [Builder.planPhaseOrder]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") - /** - * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. - * - * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun planPhaseOrder(planPhaseOrder: JsonField) = apply { - this.planPhaseOrder = planPhaseOrder - } + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + invoiceGroupingKey.getNullable("invoice_grouping_key") - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * Returns the raw JSON value of [eventOutputConfig]. + * + * Unlike [eventOutputConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("event_output_config") + @ExcludeMissing + fun _eventOutputConfig(): JsonField = eventOutputConfig - /** - * Returns an immutable instance of [RemoveAdjustment]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```kotlin - * .adjustmentId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): RemoveAdjustment = - RemoveAdjustment( - checkRequired("adjustmentId", adjustmentId), - planPhaseOrder, - additionalProperties.toMutableMap(), - ) - } + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - private var validated: Boolean = false + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - fun validate(): RemoveAdjustment = apply { - if (validated) { - return@apply - } + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId - adjustmentId() - planPhaseOrder() - validated = true - } + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (if (adjustmentId.asKnown() == null) 0 else 1) + - (if (planPhaseOrder.asKnown() == null) 0 else 1) + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig - return other is RemoveAdjustment && - adjustmentId == other.adjustmentId && - planPhaseOrder == other.planPhaseOrder && - additionalProperties == other.additionalProperties - } + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency - private val hashCode: Int by lazy { - Objects.hash(adjustmentId, planPhaseOrder, additionalProperties) - } + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration - override fun hashCode(): Int = hashCode + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId - override fun toString() = - "RemoveAdjustment{adjustmentId=$adjustmentId, planPhaseOrder=$planPhaseOrder, additionalProperties=$additionalProperties}" - } - - class RemovePrice - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val priceId: JsonField, - private val planPhaseOrder: JsonField, - private val additionalProperties: MutableMap, - ) { + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - @JsonCreator - private constructor( - @JsonProperty("price_id") @ExcludeMissing priceId: JsonField = JsonMissing.of(), - @JsonProperty("plan_phase_order") - @ExcludeMissing - planPhaseOrder: JsonField = JsonMissing.of(), - ) : this(priceId, planPhaseOrder, mutableMapOf()) + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - /** - * The id of the price to remove from the plan. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun priceId(): String = priceId.getRequired("price_id") + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration - /** - * The phase to remove this price from. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun planPhaseOrder(): Long? = planPhaseOrder.getNullable("plan_phase_order") + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata - /** - * Returns the raw JSON value of [priceId]. - * - * Unlike [priceId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId - /** - * Returns the raw JSON value of [planPhaseOrder]. - * - * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("plan_phase_order") - @ExcludeMissing - fun _planPhaseOrder(): JsonField = planPhaseOrder + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + fun toBuilder() = Builder().from(this) - fun toBuilder() = Builder().from(this) + companion object { - companion object { + /** + * Returns a mutable builder for constructing an instance of [EventOutput]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .eventOutputConfig() + * .itemId() + * .name() + * ``` + */ + fun builder() = Builder() + } - /** - * Returns a mutable builder for constructing an instance of [RemovePrice]. - * - * The following fields are required: - * ```kotlin - * .priceId() - * ``` - */ - fun builder() = Builder() - } + /** A builder for [EventOutput]. */ + class Builder internal constructor() { - /** A builder for [RemovePrice]. */ - class Builder internal constructor() { + private var cadence: JsonField? = null + private var eventOutputConfig: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonValue = JsonValue.from("event_output") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - private var priceId: JsonField? = null - private var planPhaseOrder: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + internal fun from(eventOutput: EventOutput) = apply { + cadence = eventOutput.cadence + eventOutputConfig = eventOutput.eventOutputConfig + itemId = eventOutput.itemId + modelType = eventOutput.modelType + name = eventOutput.name + billableMetricId = eventOutput.billableMetricId + billedInAdvance = eventOutput.billedInAdvance + billingCycleConfiguration = eventOutput.billingCycleConfiguration + conversionRate = eventOutput.conversionRate + conversionRateConfig = eventOutput.conversionRateConfig + currency = eventOutput.currency + dimensionalPriceConfiguration = eventOutput.dimensionalPriceConfiguration + externalPriceId = eventOutput.externalPriceId + fixedPriceQuantity = eventOutput.fixedPriceQuantity + invoiceGroupingKey = eventOutput.invoiceGroupingKey + invoicingCycleConfiguration = eventOutput.invoicingCycleConfiguration + metadata = eventOutput.metadata + referenceId = eventOutput.referenceId + additionalProperties = eventOutput.additionalProperties.toMutableMap() + } - internal fun from(removePrice: RemovePrice) = apply { - priceId = removePrice.priceId - planPhaseOrder = removePrice.planPhaseOrder - additionalProperties = removePrice.additionalProperties.toMutableMap() - } + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - /** The id of the price to remove from the plan. */ - fun priceId(priceId: String) = priceId(JsonField.of(priceId)) + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - /** - * Sets [Builder.priceId] to an arbitrary JSON value. - * - * You should usually call [Builder.priceId] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun priceId(priceId: JsonField) = apply { this.priceId = priceId } + /** Configuration for event_output pricing */ + fun eventOutputConfig(eventOutputConfig: EventOutputConfig) = + eventOutputConfig(JsonField.of(eventOutputConfig)) - /** The phase to remove this price from. */ - fun planPhaseOrder(planPhaseOrder: Long?) = - planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + /** + * Sets [Builder.eventOutputConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.eventOutputConfig] with a well-typed + * [EventOutputConfig] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun eventOutputConfig(eventOutputConfig: JsonField) = apply { + this.eventOutputConfig = eventOutputConfig + } - /** - * Alias for [Builder.planPhaseOrder]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - /** - * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. - * - * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun planPhaseOrder(planPhaseOrder: JsonField) = apply { - this.planPhaseOrder = planPhaseOrder - } + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("event_output") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) - /** - * Returns an immutable instance of [RemovePrice]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```kotlin - * .priceId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): RemovePrice = - RemovePrice( - checkRequired("priceId", priceId), - planPhaseOrder, - additionalProperties.toMutableMap(), - ) - } + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } - private var validated: Boolean = false + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) - fun validate(): RemovePrice = apply { - if (validated) { - return@apply - } + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) - priceId() - planPhaseOrder() - validated = true - } + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (if (priceId.asKnown() == null) 0 else 1) + - (if (planPhaseOrder.asKnown() == null) 0 else 1) + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) - return other is RemovePrice && - priceId == other.priceId && - planPhaseOrder == other.planPhaseOrder && - additionalProperties == other.additionalProperties - } + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) - private val hashCode: Int by lazy { - Objects.hash(priceId, planPhaseOrder, additionalProperties) - } + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } - override fun hashCode(): Int = hashCode + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) - override fun toString() = - "RemovePrice{priceId=$priceId, planPhaseOrder=$planPhaseOrder, additionalProperties=$additionalProperties}" - } + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } - class ReplaceAdjustment - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val adjustment: JsonField, - private val replacesAdjustmentId: JsonField, - private val planPhaseOrder: JsonField, - private val additionalProperties: MutableMap, - ) { + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) - @JsonCreator - private constructor( - @JsonProperty("adjustment") - @ExcludeMissing - adjustment: JsonField = JsonMissing.of(), - @JsonProperty("replaces_adjustment_id") - @ExcludeMissing - replacesAdjustmentId: JsonField = JsonMissing.of(), - @JsonProperty("plan_phase_order") - @ExcludeMissing - planPhaseOrder: JsonField = JsonMissing.of(), - ) : this(adjustment, replacesAdjustmentId, planPhaseOrder, mutableMapOf()) + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) - /** - * The definition of a new adjustment to create and add to the plan. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun adjustment(): Adjustment = adjustment.getRequired("adjustment") + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) - /** - * The id of the adjustment on the plan to replace in the plan. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun replacesAdjustmentId(): String = - replacesAdjustmentId.getRequired("replaces_adjustment_id") + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) - /** - * The phase to replace this adjustment from. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun planPhaseOrder(): Long? = planPhaseOrder.getNullable("plan_phase_order") + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) - /** - * Returns the raw JSON value of [adjustment]. - * - * Unlike [adjustment], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("adjustment") - @ExcludeMissing - fun _adjustment(): JsonField = adjustment + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } - /** - * Returns the raw JSON value of [replacesAdjustmentId]. - * - * Unlike [replacesAdjustmentId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("replaces_adjustment_id") - @ExcludeMissing - fun _replacesAdjustmentId(): JsonField = replacesAdjustmentId + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) - /** - * Returns the raw JSON value of [planPhaseOrder]. - * - * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("plan_phase_order") - @ExcludeMissing - fun _planPhaseOrder(): JsonField = planPhaseOrder + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } - fun toBuilder() = Builder().from(this) + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) - companion object { + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) - /** - * Returns a mutable builder for constructing an instance of [ReplaceAdjustment]. - * - * The following fields are required: - * ```kotlin - * .adjustment() - * .replacesAdjustmentId() - * ``` - */ - fun builder() = Builder() - } + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } - /** A builder for [ReplaceAdjustment]. */ - class Builder internal constructor() { + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) - private var adjustment: JsonField? = null - private var replacesAdjustmentId: JsonField? = null - private var planPhaseOrder: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } - internal fun from(replaceAdjustment: ReplaceAdjustment) = apply { - adjustment = replaceAdjustment.adjustment - replacesAdjustmentId = replaceAdjustment.replacesAdjustmentId - planPhaseOrder = replaceAdjustment.planPhaseOrder - additionalProperties = replaceAdjustment.additionalProperties.toMutableMap() - } + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) - /** The definition of a new adjustment to create and add to the plan. */ - fun adjustment(adjustment: Adjustment) = adjustment(JsonField.of(adjustment)) + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - /** - * Sets [Builder.adjustment] to an arbitrary JSON value. - * - * You should usually call [Builder.adjustment] with a well-typed [Adjustment] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun adjustment(adjustment: JsonField) = apply { - this.adjustment = adjustment - } + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - /** - * Alias for calling [adjustment] with - * `Adjustment.ofPercentageDiscount(percentageDiscount)`. - */ - fun adjustment(percentageDiscount: NewPercentageDiscount) = - adjustment(Adjustment.ofPercentageDiscount(percentageDiscount)) + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - /** - * Alias for calling [adjustment] with the following: - * ```kotlin - * NewPercentageDiscount.builder() - * .adjustmentType(NewPercentageDiscount.AdjustmentType.PERCENTAGE_DISCOUNT) - * .percentageDiscount(percentageDiscount) - * .build() - * ``` - */ - fun percentageDiscountAdjustment(percentageDiscount: Double) = - adjustment( - NewPercentageDiscount.builder() - .adjustmentType(NewPercentageDiscount.AdjustmentType.PERCENTAGE_DISCOUNT) - .percentageDiscount(percentageDiscount) - .build() - ) + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) - /** Alias for calling [adjustment] with `Adjustment.ofUsageDiscount(usageDiscount)`. */ - fun adjustment(usageDiscount: NewUsageDiscount) = - adjustment(Adjustment.ofUsageDiscount(usageDiscount)) + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } - /** - * Alias for calling [adjustment] with the following: - * ```kotlin - * NewUsageDiscount.builder() - * .adjustmentType(NewUsageDiscount.AdjustmentType.USAGE_DISCOUNT) - * .usageDiscount(usageDiscount) - * .build() - * ``` - */ - fun usageDiscountAdjustment(usageDiscount: Double) = - adjustment( - NewUsageDiscount.builder() - .adjustmentType(NewUsageDiscount.AdjustmentType.USAGE_DISCOUNT) - .usageDiscount(usageDiscount) - .build() - ) + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** - * Alias for calling [adjustment] with `Adjustment.ofAmountDiscount(amountDiscount)`. - */ - fun adjustment(amountDiscount: NewAmountDiscount) = - adjustment(Adjustment.ofAmountDiscount(amountDiscount)) + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * Alias for calling [adjustment] with the following: - * ```kotlin - * NewAmountDiscount.builder() - * .adjustmentType(NewAmountDiscount.AdjustmentType.AMOUNT_DISCOUNT) - * .amountDiscount(amountDiscount) - * .build() - * ``` - */ - fun amountDiscountAdjustment(amountDiscount: String) = - adjustment( - NewAmountDiscount.builder() - .adjustmentType(NewAmountDiscount.AdjustmentType.AMOUNT_DISCOUNT) - .amountDiscount(amountDiscount) - .build() - ) + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - /** Alias for calling [adjustment] with `Adjustment.ofMinimum(minimum)`. */ - fun adjustment(minimum: NewMinimum) = adjustment(Adjustment.ofMinimum(minimum)) + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - /** Alias for calling [adjustment] with `Adjustment.ofMaximum(maximum)`. */ - fun adjustment(maximum: NewMaximum) = adjustment(Adjustment.ofMaximum(maximum)) + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - /** - * Alias for calling [adjustment] with the following: - * ```kotlin - * NewMaximum.builder() - * .adjustmentType(NewMaximum.AdjustmentType.MAXIMUM) - * .maximumAmount(maximumAmount) - * .build() - * ``` - */ - fun maximumAdjustment(maximumAmount: String) = - adjustment( - NewMaximum.builder() - .adjustmentType(NewMaximum.AdjustmentType.MAXIMUM) - .maximumAmount(maximumAmount) - .build() - ) + /** + * Returns an immutable instance of [EventOutput]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .eventOutputConfig() + * .itemId() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): EventOutput = + EventOutput( + checkRequired("cadence", cadence), + checkRequired("eventOutputConfig", eventOutputConfig), + checkRequired("itemId", itemId), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } - /** The id of the adjustment on the plan to replace in the plan. */ - fun replacesAdjustmentId(replacesAdjustmentId: String) = - replacesAdjustmentId(JsonField.of(replacesAdjustmentId)) + private var validated: Boolean = false - /** - * Sets [Builder.replacesAdjustmentId] to an arbitrary JSON value. - * - * You should usually call [Builder.replacesAdjustmentId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun replacesAdjustmentId(replacesAdjustmentId: JsonField) = apply { - this.replacesAdjustmentId = replacesAdjustmentId - } + fun validate(): EventOutput = apply { + if (validated) { + return@apply + } - /** The phase to replace this adjustment from. */ - fun planPhaseOrder(planPhaseOrder: Long?) = - planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + cadence().validate() + eventOutputConfig().validate() + itemId() + _modelType().let { + if (it != JsonValue.from("event_output")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + metadata()?.validate() + referenceId() + validated = true + } - /** - * Alias for [Builder.planPhaseOrder]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - /** - * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. - * - * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun planPhaseOrder(planPhaseOrder: JsonField) = apply { - this.planPhaseOrder = planPhaseOrder - } + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (eventOutputConfig.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + modelType.let { if (it == JsonValue.from("event_output")) 1 else 0 } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + companion object { - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + val ANNUAL = of("annual") - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + val SEMI_ANNUAL = of("semi_annual") - /** - * Returns an immutable instance of [ReplaceAdjustment]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```kotlin - * .adjustment() - * .replacesAdjustmentId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): ReplaceAdjustment = - ReplaceAdjustment( - checkRequired("adjustment", adjustment), - checkRequired("replacesAdjustmentId", replacesAdjustmentId), - planPhaseOrder, - additionalProperties.toMutableMap(), - ) - } + val MONTHLY = of("monthly") - private var validated: Boolean = false + val QUARTERLY = of("quarterly") - fun validate(): ReplaceAdjustment = apply { - if (validated) { - return@apply - } + val ONE_TIME = of("one_time") - adjustment().validate() - replacesAdjustmentId() - planPhaseOrder() - validated = true - } + val CUSTOM = of("custom") - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + fun of(value: String) = Cadence(JsonField.of(value)) + } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (adjustment.asKnown()?.validity() ?: 0) + - (if (replacesAdjustmentId.asKnown() == null) 0 else 1) + - (if (planPhaseOrder.asKnown() == null) 0 else 1) + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } - /** The definition of a new adjustment to create and add to the plan. */ - @JsonDeserialize(using = Adjustment.Deserializer::class) - @JsonSerialize(using = Adjustment.Serializer::class) - class Adjustment - private constructor( - private val percentageDiscount: NewPercentageDiscount? = null, - private val usageDiscount: NewUsageDiscount? = null, - private val amountDiscount: NewAmountDiscount? = null, - private val minimum: NewMinimum? = null, - private val maximum: NewMaximum? = null, - private val _json: JsonValue? = null, - ) { + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } - fun percentageDiscount(): NewPercentageDiscount? = percentageDiscount + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } - fun usageDiscount(): NewUsageDiscount? = usageDiscount + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } - fun amountDiscount(): NewAmountDiscount? = amountDiscount + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") - fun minimum(): NewMinimum? = minimum + private var validated: Boolean = false - fun maximum(): NewMaximum? = maximum + fun validate(): Cadence = apply { + if (validated) { + return@apply + } - fun isPercentageDiscount(): Boolean = percentageDiscount != null + known() + validated = true + } - fun isUsageDiscount(): Boolean = usageDiscount != null + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - fun isAmountDiscount(): Boolean = amountDiscount != null + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - fun isMinimum(): Boolean = minimum != null + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun isMaximum(): Boolean = maximum != null + return other is Cadence && value == other.value + } - fun asPercentageDiscount(): NewPercentageDiscount = - percentageDiscount.getOrThrow("percentageDiscount") + override fun hashCode() = value.hashCode() - fun asUsageDiscount(): NewUsageDiscount = usageDiscount.getOrThrow("usageDiscount") + override fun toString() = value.toString() + } - fun asAmountDiscount(): NewAmountDiscount = amountDiscount.getOrThrow("amountDiscount") + /** Configuration for event_output pricing */ + class EventOutputConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val unitRatingKey: JsonField, + private val groupingKey: JsonField, + private val additionalProperties: MutableMap, + ) { - fun asMinimum(): NewMinimum = minimum.getOrThrow("minimum") + @JsonCreator + private constructor( + @JsonProperty("unit_rating_key") + @ExcludeMissing + unitRatingKey: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + ) : this(unitRatingKey, groupingKey, mutableMapOf()) - fun asMaximum(): NewMaximum = maximum.getOrThrow("maximum") + /** + * The key in the event data to extract the unit rate from. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun unitRatingKey(): String = unitRatingKey.getRequired("unit_rating_key") - fun _json(): JsonValue? = _json + /** + * An optional key in the event data to group by (e.g., event ID). All events + * will also be grouped by their unit rate. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun groupingKey(): String? = groupingKey.getNullable("grouping_key") - fun accept(visitor: Visitor): T = - when { - percentageDiscount != null -> - visitor.visitPercentageDiscount(percentageDiscount) - usageDiscount != null -> visitor.visitUsageDiscount(usageDiscount) - amountDiscount != null -> visitor.visitAmountDiscount(amountDiscount) - minimum != null -> visitor.visitMinimum(minimum) - maximum != null -> visitor.visitMaximum(maximum) - else -> visitor.unknown(_json) - } + /** + * Returns the raw JSON value of [unitRatingKey]. + * + * Unlike [unitRatingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_rating_key") + @ExcludeMissing + fun _unitRatingKey(): JsonField = unitRatingKey - private var validated: Boolean = false + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey - fun validate(): Adjustment = apply { - if (validated) { - return@apply - } + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - accept( - object : Visitor { - override fun visitPercentageDiscount( - percentageDiscount: NewPercentageDiscount - ) { - percentageDiscount.validate() - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - override fun visitUsageDiscount(usageDiscount: NewUsageDiscount) { - usageDiscount.validate() - } + fun toBuilder() = Builder().from(this) - override fun visitAmountDiscount(amountDiscount: NewAmountDiscount) { - amountDiscount.validate() - } - - override fun visitMinimum(minimum: NewMinimum) { - minimum.validate() - } + companion object { - override fun visitMaximum(maximum: NewMaximum) { - maximum.validate() - } + /** + * Returns a mutable builder for constructing an instance of + * [EventOutputConfig]. + * + * The following fields are required: + * ```kotlin + * .unitRatingKey() + * ``` + */ + fun builder() = Builder() } - ) - validated = true - } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** A builder for [EventOutputConfig]. */ + class Builder internal constructor() { - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitPercentageDiscount( - percentageDiscount: NewPercentageDiscount - ) = percentageDiscount.validity() + private var unitRatingKey: JsonField? = null + private var groupingKey: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() - override fun visitUsageDiscount(usageDiscount: NewUsageDiscount) = - usageDiscount.validity() + internal fun from(eventOutputConfig: EventOutputConfig) = apply { + unitRatingKey = eventOutputConfig.unitRatingKey + groupingKey = eventOutputConfig.groupingKey + additionalProperties = + eventOutputConfig.additionalProperties.toMutableMap() + } - override fun visitAmountDiscount(amountDiscount: NewAmountDiscount) = - amountDiscount.validity() + /** The key in the event data to extract the unit rate from. */ + fun unitRatingKey(unitRatingKey: String) = + unitRatingKey(JsonField.of(unitRatingKey)) - override fun visitMinimum(minimum: NewMinimum) = minimum.validity() + /** + * Sets [Builder.unitRatingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.unitRatingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun unitRatingKey(unitRatingKey: JsonField) = apply { + this.unitRatingKey = unitRatingKey + } - override fun visitMaximum(maximum: NewMaximum) = maximum.validity() + /** + * An optional key in the event data to group by (e.g., event ID). All + * events will also be grouped by their unit rate. + */ + fun groupingKey(groupingKey: String?) = + groupingKey(JsonField.ofNullable(groupingKey)) - override fun unknown(json: JsonValue?) = 0 - } - ) + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - return other is Adjustment && - percentageDiscount == other.percentageDiscount && - usageDiscount == other.usageDiscount && - amountDiscount == other.amountDiscount && - minimum == other.minimum && - maximum == other.maximum - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - override fun hashCode(): Int = - Objects.hash(percentageDiscount, usageDiscount, amountDiscount, minimum, maximum) + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - override fun toString(): String = - when { - percentageDiscount != null -> - "Adjustment{percentageDiscount=$percentageDiscount}" - usageDiscount != null -> "Adjustment{usageDiscount=$usageDiscount}" - amountDiscount != null -> "Adjustment{amountDiscount=$amountDiscount}" - minimum != null -> "Adjustment{minimum=$minimum}" - maximum != null -> "Adjustment{maximum=$maximum}" - _json != null -> "Adjustment{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Adjustment") - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - companion object { + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - fun ofPercentageDiscount(percentageDiscount: NewPercentageDiscount) = - Adjustment(percentageDiscount = percentageDiscount) + /** + * Returns an immutable instance of [EventOutputConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .unitRatingKey() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): EventOutputConfig = + EventOutputConfig( + checkRequired("unitRatingKey", unitRatingKey), + groupingKey, + additionalProperties.toMutableMap(), + ) + } - fun ofUsageDiscount(usageDiscount: NewUsageDiscount) = - Adjustment(usageDiscount = usageDiscount) + private var validated: Boolean = false - fun ofAmountDiscount(amountDiscount: NewAmountDiscount) = - Adjustment(amountDiscount = amountDiscount) + fun validate(): EventOutputConfig = apply { + if (validated) { + return@apply + } - fun ofMinimum(minimum: NewMinimum) = Adjustment(minimum = minimum) + unitRatingKey() + groupingKey() + validated = true + } - fun ofMaximum(maximum: NewMaximum) = Adjustment(maximum = maximum) - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - /** - * An interface that defines how to map each variant of [Adjustment] to a value of type - * [T]. - */ - interface Visitor { + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (unitRatingKey.asKnown() == null) 0 else 1) + + (if (groupingKey.asKnown() == null) 0 else 1) - fun visitPercentageDiscount(percentageDiscount: NewPercentageDiscount): T + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun visitUsageDiscount(usageDiscount: NewUsageDiscount): T + return other is EventOutputConfig && + unitRatingKey == other.unitRatingKey && + groupingKey == other.groupingKey && + additionalProperties == other.additionalProperties + } - fun visitAmountDiscount(amountDiscount: NewAmountDiscount): T + private val hashCode: Int by lazy { + Objects.hash(unitRatingKey, groupingKey, additionalProperties) + } - fun visitMinimum(minimum: NewMinimum): T + override fun hashCode(): Int = hashCode - fun visitMaximum(maximum: NewMaximum): T + override fun toString() = + "EventOutputConfig{unitRatingKey=$unitRatingKey, groupingKey=$groupingKey, additionalProperties=$additionalProperties}" + } /** - * Maps an unknown variant of [Adjustment] to a value of type [T]. - * - * An instance of [Adjustment] can contain an unknown variant if it was deserialized - * from data that doesn't match any known variant. For example, if the SDK is on an - * older version than the API, then the API may respond with new variants that the - * SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown Adjustment: $json") - } - } + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { - internal class Deserializer : BaseDeserializer(Adjustment::class) { + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties - override fun ObjectCodec.deserialize(node: JsonNode): Adjustment { - val json = JsonValue.fromJsonNode(node) - val adjustmentType = json.asObject()?.get("adjustment_type")?.asString() + fun toBuilder() = Builder().from(this) - when (adjustmentType) { - "percentage_discount" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Adjustment(percentageDiscount = it, _json = json) } - ?: Adjustment(_json = json) - } - "usage_discount" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(usageDiscount = it, _json = json) - } ?: Adjustment(_json = json) - } - "amount_discount" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(amountDiscount = it, _json = json) - } ?: Adjustment(_json = json) + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() } - "minimum" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(minimum = it, _json = json) - } ?: Adjustment(_json = json) + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) } - "maximum" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(maximum = it, _json = json) - } ?: Adjustment(_json = json) + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } - return Adjustment(_json = json) - } - } + private var validated: Boolean = false - internal class Serializer : BaseSerializer(Adjustment::class) { + fun validate(): Metadata = apply { + if (validated) { + return@apply + } - override fun serialize( - value: Adjustment, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.percentageDiscount != null -> - generator.writeObject(value.percentageDiscount) - value.usageDiscount != null -> generator.writeObject(value.usageDiscount) - value.amountDiscount != null -> generator.writeObject(value.amountDiscount) - value.minimum != null -> generator.writeObject(value.minimum) - value.maximum != null -> generator.writeObject(value.maximum) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Adjustment") + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } + + return other is EventOutput && + cadence == other.cadence && + eventOutputConfig == other.eventOutputConfig && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + eventOutputConfig, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties, + ) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "EventOutput{cadence=$cadence, eventOutputConfig=$eventOutputConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } } @@ -9271,65 +9772,51 @@ private constructor( return true } - return other is ReplaceAdjustment && - adjustment == other.adjustment && - replacesAdjustmentId == other.replacesAdjustmentId && + return other is AddPrice && + allocationPrice == other.allocationPrice && planPhaseOrder == other.planPhaseOrder && + price == other.price && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(adjustment, replacesAdjustmentId, planPhaseOrder, additionalProperties) + Objects.hash(allocationPrice, planPhaseOrder, price, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "ReplaceAdjustment{adjustment=$adjustment, replacesAdjustmentId=$replacesAdjustmentId, planPhaseOrder=$planPhaseOrder, additionalProperties=$additionalProperties}" + "AddPrice{allocationPrice=$allocationPrice, planPhaseOrder=$planPhaseOrder, price=$price, additionalProperties=$additionalProperties}" } - class ReplacePrice + class RemoveAdjustment @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val replacesPriceId: JsonField, - private val allocationPrice: JsonField, + private val adjustmentId: JsonField, private val planPhaseOrder: JsonField, - private val price: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("replaces_price_id") - @ExcludeMissing - replacesPriceId: JsonField = JsonMissing.of(), - @JsonProperty("allocation_price") + @JsonProperty("adjustment_id") @ExcludeMissing - allocationPrice: JsonField = JsonMissing.of(), + adjustmentId: JsonField = JsonMissing.of(), @JsonProperty("plan_phase_order") @ExcludeMissing planPhaseOrder: JsonField = JsonMissing.of(), - @JsonProperty("price") @ExcludeMissing price: JsonField = JsonMissing.of(), - ) : this(replacesPriceId, allocationPrice, planPhaseOrder, price, mutableMapOf()) + ) : this(adjustmentId, planPhaseOrder, mutableMapOf()) /** - * The id of the price on the plan to replace in the plan. + * The id of the adjustment to remove from on the plan. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ - fun replacesPriceId(): String = replacesPriceId.getRequired("replaces_price_id") - - /** - * The allocation price to add to the plan. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun allocationPrice(): NewAllocationPrice? = allocationPrice.getNullable("allocation_price") + fun adjustmentId(): String = adjustmentId.getRequired("adjustment_id") /** - * The phase to replace this price from. + * The phase to remove this adjustment from. * * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -9337,32 +9824,14 @@ private constructor( fun planPhaseOrder(): Long? = planPhaseOrder.getNullable("plan_phase_order") /** - * New plan price request body params. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun price(): Price? = price.getNullable("price") - - /** - * Returns the raw JSON value of [replacesPriceId]. - * - * Unlike [replacesPriceId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("replaces_price_id") - @ExcludeMissing - fun _replacesPriceId(): JsonField = replacesPriceId - - /** - * Returns the raw JSON value of [allocationPrice]. + * Returns the raw JSON value of [adjustmentId]. * - * Unlike [allocationPrice], this method doesn't throw if the JSON field has an unexpected + * Unlike [adjustmentId], this method doesn't throw if the JSON field has an unexpected * type. */ - @JsonProperty("allocation_price") + @JsonProperty("adjustment_id") @ExcludeMissing - fun _allocationPrice(): JsonField = allocationPrice + fun _adjustmentId(): JsonField = adjustmentId /** * Returns the raw JSON value of [planPhaseOrder]. @@ -9374,13 +9843,6 @@ private constructor( @ExcludeMissing fun _planPhaseOrder(): JsonField = planPhaseOrder - /** - * Returns the raw JSON value of [price]. - * - * Unlike [price], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("price") @ExcludeMissing fun _price(): JsonField = price - @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -9396,64 +9858,44 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [ReplacePrice]. + * Returns a mutable builder for constructing an instance of [RemoveAdjustment]. * * The following fields are required: * ```kotlin - * .replacesPriceId() + * .adjustmentId() * ``` */ fun builder() = Builder() } - /** A builder for [ReplacePrice]. */ + /** A builder for [RemoveAdjustment]. */ class Builder internal constructor() { - private var replacesPriceId: JsonField? = null - private var allocationPrice: JsonField = JsonMissing.of() + private var adjustmentId: JsonField? = null private var planPhaseOrder: JsonField = JsonMissing.of() - private var price: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(replacePrice: ReplacePrice) = apply { - replacesPriceId = replacePrice.replacesPriceId - allocationPrice = replacePrice.allocationPrice - planPhaseOrder = replacePrice.planPhaseOrder - price = replacePrice.price - additionalProperties = replacePrice.additionalProperties.toMutableMap() + internal fun from(removeAdjustment: RemoveAdjustment) = apply { + adjustmentId = removeAdjustment.adjustmentId + planPhaseOrder = removeAdjustment.planPhaseOrder + additionalProperties = removeAdjustment.additionalProperties.toMutableMap() } - /** The id of the price on the plan to replace in the plan. */ - fun replacesPriceId(replacesPriceId: String) = - replacesPriceId(JsonField.of(replacesPriceId)) + /** The id of the adjustment to remove from on the plan. */ + fun adjustmentId(adjustmentId: String) = adjustmentId(JsonField.of(adjustmentId)) /** - * Sets [Builder.replacesPriceId] to an arbitrary JSON value. + * Sets [Builder.adjustmentId] to an arbitrary JSON value. * - * You should usually call [Builder.replacesPriceId] with a well-typed [String] value + * You should usually call [Builder.adjustmentId] with a well-typed [String] value * instead. This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun replacesPriceId(replacesPriceId: JsonField) = apply { - this.replacesPriceId = replacesPriceId - } - - /** The allocation price to add to the plan. */ - fun allocationPrice(allocationPrice: NewAllocationPrice?) = - allocationPrice(JsonField.ofNullable(allocationPrice)) - - /** - * Sets [Builder.allocationPrice] to an arbitrary JSON value. - * - * You should usually call [Builder.allocationPrice] with a well-typed - * [NewAllocationPrice] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun allocationPrice(allocationPrice: JsonField) = apply { - this.allocationPrice = allocationPrice + fun adjustmentId(adjustmentId: JsonField) = apply { + this.adjustmentId = adjustmentId } - /** The phase to replace this price from. */ + /** The phase to remove this adjustment from. */ fun planPhaseOrder(planPhaseOrder: Long?) = planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) @@ -9475,162 +9917,6 @@ private constructor( this.planPhaseOrder = planPhaseOrder } - /** New plan price request body params. */ - fun price(price: Price?) = price(JsonField.ofNullable(price)) - - /** - * Sets [Builder.price] to an arbitrary JSON value. - * - * You should usually call [Builder.price] with a well-typed [Price] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun price(price: JsonField) = apply { this.price = price } - - /** Alias for calling [price] with `Price.ofUnit(unit)`. */ - fun price(unit: NewPlanUnitPrice) = price(Price.ofUnit(unit)) - - /** Alias for calling [price] with `Price.ofTiered(tiered)`. */ - fun price(tiered: NewPlanTieredPrice) = price(Price.ofTiered(tiered)) - - /** Alias for calling [price] with `Price.ofBulk(bulk)`. */ - fun price(bulk: NewPlanBulkPrice) = price(Price.ofBulk(bulk)) - - /** Alias for calling [price] with `Price.ofPackage(package_)`. */ - fun price(package_: NewPlanPackagePrice) = price(Price.ofPackage(package_)) - - /** Alias for calling [price] with `Price.ofMatrix(matrix)`. */ - fun price(matrix: NewPlanMatrixPrice) = price(Price.ofMatrix(matrix)) - - /** - * Alias for calling [price] with `Price.ofThresholdTotalAmount(thresholdTotalAmount)`. - */ - fun price(thresholdTotalAmount: NewPlanThresholdTotalAmountPrice) = - price(Price.ofThresholdTotalAmount(thresholdTotalAmount)) - - /** Alias for calling [price] with `Price.ofTieredPackage(tieredPackage)`. */ - fun price(tieredPackage: NewPlanTieredPackagePrice) = - price(Price.ofTieredPackage(tieredPackage)) - - /** Alias for calling [price] with `Price.ofTieredWithMinimum(tieredWithMinimum)`. */ - fun price(tieredWithMinimum: NewPlanTieredWithMinimumPrice) = - price(Price.ofTieredWithMinimum(tieredWithMinimum)) - - /** Alias for calling [price] with `Price.ofGroupedTiered(groupedTiered)`. */ - fun price(groupedTiered: NewPlanGroupedTieredPrice) = - price(Price.ofGroupedTiered(groupedTiered)) - - /** - * Alias for calling [price] with - * `Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)`. - */ - fun price(tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice) = - price(Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)) - - /** - * Alias for calling [price] with - * `Price.ofPackageWithAllocation(packageWithAllocation)`. - */ - fun price(packageWithAllocation: NewPlanPackageWithAllocationPrice) = - price(Price.ofPackageWithAllocation(packageWithAllocation)) - - /** Alias for calling [price] with `Price.ofUnitWithPercent(unitWithPercent)`. */ - fun price(unitWithPercent: NewPlanUnitWithPercentPrice) = - price(Price.ofUnitWithPercent(unitWithPercent)) - - /** - * Alias for calling [price] with `Price.ofMatrixWithAllocation(matrixWithAllocation)`. - */ - fun price(matrixWithAllocation: NewPlanMatrixWithAllocationPrice) = - price(Price.ofMatrixWithAllocation(matrixWithAllocation)) - - /** - * Alias for calling [price] with `Price.ofTieredWithProration(tieredWithProration)`. - */ - fun price(tieredWithProration: Price.TieredWithProration) = - price(Price.ofTieredWithProration(tieredWithProration)) - - /** Alias for calling [price] with `Price.ofUnitWithProration(unitWithProration)`. */ - fun price(unitWithProration: NewPlanUnitWithProrationPrice) = - price(Price.ofUnitWithProration(unitWithProration)) - - /** Alias for calling [price] with `Price.ofGroupedAllocation(groupedAllocation)`. */ - fun price(groupedAllocation: NewPlanGroupedAllocationPrice) = - price(Price.ofGroupedAllocation(groupedAllocation)) - - /** Alias for calling [price] with `Price.ofBulkWithProration(bulkWithProration)`. */ - fun price(bulkWithProration: NewPlanBulkWithProrationPrice) = - price(Price.ofBulkWithProration(bulkWithProration)) - - /** - * Alias for calling [price] with - * `Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)`. - */ - fun price(groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice) = - price(Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)) - - /** - * Alias for calling [price] with - * `Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)`. - */ - fun price(groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice) = - price(Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)) - - /** - * Alias for calling [price] with - * `Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)`. - */ - fun price(groupedWithMinMaxThresholds: Price.GroupedWithMinMaxThresholds) = - price(Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)) - - /** - * Alias for calling [price] with - * `Price.ofMatrixWithDisplayName(matrixWithDisplayName)`. - */ - fun price(matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice) = - price(Price.ofMatrixWithDisplayName(matrixWithDisplayName)) - - /** - * Alias for calling [price] with `Price.ofGroupedTieredPackage(groupedTieredPackage)`. - */ - fun price(groupedTieredPackage: NewPlanGroupedTieredPackagePrice) = - price(Price.ofGroupedTieredPackage(groupedTieredPackage)) - - /** - * Alias for calling [price] with - * `Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)`. - */ - fun price(maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice) = - price(Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)) - - /** - * Alias for calling [price] with - * `Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)`. - */ - fun price(scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice) = - price(Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)) - - /** - * Alias for calling [price] with - * `Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)`. - */ - fun price( - scalableMatrixWithTieredPricing: NewPlanScalableMatrixWithTieredPricingPrice - ) = price(Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)) - - /** - * Alias for calling [price] with - * `Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)`. - */ - fun price(cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice) = - price(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) - - /** Alias for calling [price] with `Price.ofMinimum(minimum)`. */ - fun price(minimum: NewPlanMinimumCompositePrice) = price(Price.ofMinimum(minimum)) - - /** Alias for calling [price] with `Price.ofEventOutput(eventOutput)`. */ - fun price(eventOutput: Price.EventOutput) = price(Price.ofEventOutput(eventOutput)) - fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -9651,38 +9937,34 @@ private constructor( } /** - * Returns an immutable instance of [ReplacePrice]. + * Returns an immutable instance of [RemoveAdjustment]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```kotlin - * .replacesPriceId() + * .adjustmentId() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): ReplacePrice = - ReplacePrice( - checkRequired("replacesPriceId", replacesPriceId), - allocationPrice, + fun build(): RemoveAdjustment = + RemoveAdjustment( + checkRequired("adjustmentId", adjustmentId), planPhaseOrder, - price, additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): ReplacePrice = apply { + fun validate(): RemoveAdjustment = apply { if (validated) { return@apply } - replacesPriceId() - allocationPrice()?.validate() + adjustmentId() planPhaseOrder() - price()?.validate() validated = true } @@ -9701,1166 +9983,4229 @@ private constructor( * Used for best match union deserialization. */ internal fun validity(): Int = - (if (replacesPriceId.asKnown() == null) 0 else 1) + - (allocationPrice.asKnown()?.validity() ?: 0) + - (if (planPhaseOrder.asKnown() == null) 0 else 1) + - (price.asKnown()?.validity() ?: 0) - - /** New plan price request body params. */ - @JsonDeserialize(using = Price.Deserializer::class) - @JsonSerialize(using = Price.Serializer::class) - class Price - private constructor( - private val unit: NewPlanUnitPrice? = null, - private val tiered: NewPlanTieredPrice? = null, - private val bulk: NewPlanBulkPrice? = null, - private val package_: NewPlanPackagePrice? = null, - private val matrix: NewPlanMatrixPrice? = null, - private val thresholdTotalAmount: NewPlanThresholdTotalAmountPrice? = null, - private val tieredPackage: NewPlanTieredPackagePrice? = null, - private val tieredWithMinimum: NewPlanTieredWithMinimumPrice? = null, - private val groupedTiered: NewPlanGroupedTieredPrice? = null, - private val tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice? = null, - private val packageWithAllocation: NewPlanPackageWithAllocationPrice? = null, - private val unitWithPercent: NewPlanUnitWithPercentPrice? = null, - private val matrixWithAllocation: NewPlanMatrixWithAllocationPrice? = null, - private val tieredWithProration: TieredWithProration? = null, - private val unitWithProration: NewPlanUnitWithProrationPrice? = null, - private val groupedAllocation: NewPlanGroupedAllocationPrice? = null, - private val bulkWithProration: NewPlanBulkWithProrationPrice? = null, - private val groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice? = null, - private val groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice? = null, - private val groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds? = null, - private val matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice? = null, - private val groupedTieredPackage: NewPlanGroupedTieredPackagePrice? = null, - private val maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice? = null, - private val scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice? = - null, - private val scalableMatrixWithTieredPricing: - NewPlanScalableMatrixWithTieredPricingPrice? = - null, - private val cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice? = null, - private val minimum: NewPlanMinimumCompositePrice? = null, - private val eventOutput: EventOutput? = null, - private val _json: JsonValue? = null, - ) { - - fun unit(): NewPlanUnitPrice? = unit + (if (adjustmentId.asKnown() == null) 0 else 1) + + (if (planPhaseOrder.asKnown() == null) 0 else 1) - fun tiered(): NewPlanTieredPrice? = tiered + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun bulk(): NewPlanBulkPrice? = bulk + return other is RemoveAdjustment && + adjustmentId == other.adjustmentId && + planPhaseOrder == other.planPhaseOrder && + additionalProperties == other.additionalProperties + } - fun package_(): NewPlanPackagePrice? = package_ + private val hashCode: Int by lazy { + Objects.hash(adjustmentId, planPhaseOrder, additionalProperties) + } - fun matrix(): NewPlanMatrixPrice? = matrix + override fun hashCode(): Int = hashCode - fun thresholdTotalAmount(): NewPlanThresholdTotalAmountPrice? = thresholdTotalAmount + override fun toString() = + "RemoveAdjustment{adjustmentId=$adjustmentId, planPhaseOrder=$planPhaseOrder, additionalProperties=$additionalProperties}" + } - fun tieredPackage(): NewPlanTieredPackagePrice? = tieredPackage + class RemovePrice + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val priceId: JsonField, + private val planPhaseOrder: JsonField, + private val additionalProperties: MutableMap, + ) { - fun tieredWithMinimum(): NewPlanTieredWithMinimumPrice? = tieredWithMinimum + @JsonCreator + private constructor( + @JsonProperty("price_id") @ExcludeMissing priceId: JsonField = JsonMissing.of(), + @JsonProperty("plan_phase_order") + @ExcludeMissing + planPhaseOrder: JsonField = JsonMissing.of(), + ) : this(priceId, planPhaseOrder, mutableMapOf()) - fun groupedTiered(): NewPlanGroupedTieredPrice? = groupedTiered + /** + * The id of the price to remove from the plan. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun priceId(): String = priceId.getRequired("price_id") - fun tieredPackageWithMinimum(): NewPlanTieredPackageWithMinimumPrice? = - tieredPackageWithMinimum + /** + * The phase to remove this price from. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun planPhaseOrder(): Long? = planPhaseOrder.getNullable("plan_phase_order") - fun packageWithAllocation(): NewPlanPackageWithAllocationPrice? = packageWithAllocation + /** + * Returns the raw JSON value of [priceId]. + * + * Unlike [priceId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId - fun unitWithPercent(): NewPlanUnitWithPercentPrice? = unitWithPercent + /** + * Returns the raw JSON value of [planPhaseOrder]. + * + * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder - fun matrixWithAllocation(): NewPlanMatrixWithAllocationPrice? = matrixWithAllocation + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - fun tieredWithProration(): TieredWithProration? = tieredWithProration + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - fun unitWithProration(): NewPlanUnitWithProrationPrice? = unitWithProration + fun toBuilder() = Builder().from(this) - fun groupedAllocation(): NewPlanGroupedAllocationPrice? = groupedAllocation + companion object { - fun bulkWithProration(): NewPlanBulkWithProrationPrice? = bulkWithProration + /** + * Returns a mutable builder for constructing an instance of [RemovePrice]. + * + * The following fields are required: + * ```kotlin + * .priceId() + * ``` + */ + fun builder() = Builder() + } - fun groupedWithProratedMinimum(): NewPlanGroupedWithProratedMinimumPrice? = - groupedWithProratedMinimum + /** A builder for [RemovePrice]. */ + class Builder internal constructor() { + + private var priceId: JsonField? = null + private var planPhaseOrder: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(removePrice: RemovePrice) = apply { + priceId = removePrice.priceId + planPhaseOrder = removePrice.planPhaseOrder + additionalProperties = removePrice.additionalProperties.toMutableMap() + } + + /** The id of the price to remove from the plan. */ + fun priceId(priceId: String) = priceId(JsonField.of(priceId)) + + /** + * Sets [Builder.priceId] to an arbitrary JSON value. + * + * You should usually call [Builder.priceId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun priceId(priceId: JsonField) = apply { this.priceId = priceId } + + /** The phase to remove this price from. */ + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + + /** + * Alias for [Builder.planPhaseOrder]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + + /** + * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. + * + * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun planPhaseOrder(planPhaseOrder: JsonField) = apply { + this.planPhaseOrder = planPhaseOrder + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [RemovePrice]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .priceId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): RemovePrice = + RemovePrice( + checkRequired("priceId", priceId), + planPhaseOrder, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): RemovePrice = apply { + if (validated) { + return@apply + } + + priceId() + planPhaseOrder() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (priceId.asKnown() == null) 0 else 1) + + (if (planPhaseOrder.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RemovePrice && + priceId == other.priceId && + planPhaseOrder == other.planPhaseOrder && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(priceId, planPhaseOrder, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "RemovePrice{priceId=$priceId, planPhaseOrder=$planPhaseOrder, additionalProperties=$additionalProperties}" + } + + class ReplaceAdjustment + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val adjustment: JsonField, + private val replacesAdjustmentId: JsonField, + private val planPhaseOrder: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("adjustment") + @ExcludeMissing + adjustment: JsonField = JsonMissing.of(), + @JsonProperty("replaces_adjustment_id") + @ExcludeMissing + replacesAdjustmentId: JsonField = JsonMissing.of(), + @JsonProperty("plan_phase_order") + @ExcludeMissing + planPhaseOrder: JsonField = JsonMissing.of(), + ) : this(adjustment, replacesAdjustmentId, planPhaseOrder, mutableMapOf()) + + /** + * The definition of a new adjustment to create and add to the plan. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun adjustment(): Adjustment = adjustment.getRequired("adjustment") + + /** + * The id of the adjustment on the plan to replace in the plan. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun replacesAdjustmentId(): String = + replacesAdjustmentId.getRequired("replaces_adjustment_id") + + /** + * The phase to replace this adjustment from. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun planPhaseOrder(): Long? = planPhaseOrder.getNullable("plan_phase_order") + + /** + * Returns the raw JSON value of [adjustment]. + * + * Unlike [adjustment], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("adjustment") + @ExcludeMissing + fun _adjustment(): JsonField = adjustment + + /** + * Returns the raw JSON value of [replacesAdjustmentId]. + * + * Unlike [replacesAdjustmentId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("replaces_adjustment_id") + @ExcludeMissing + fun _replacesAdjustmentId(): JsonField = replacesAdjustmentId + + /** + * Returns the raw JSON value of [planPhaseOrder]. + * + * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ReplaceAdjustment]. + * + * The following fields are required: + * ```kotlin + * .adjustment() + * .replacesAdjustmentId() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [ReplaceAdjustment]. */ + class Builder internal constructor() { + + private var adjustment: JsonField? = null + private var replacesAdjustmentId: JsonField? = null + private var planPhaseOrder: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(replaceAdjustment: ReplaceAdjustment) = apply { + adjustment = replaceAdjustment.adjustment + replacesAdjustmentId = replaceAdjustment.replacesAdjustmentId + planPhaseOrder = replaceAdjustment.planPhaseOrder + additionalProperties = replaceAdjustment.additionalProperties.toMutableMap() + } + + /** The definition of a new adjustment to create and add to the plan. */ + fun adjustment(adjustment: Adjustment) = adjustment(JsonField.of(adjustment)) + + /** + * Sets [Builder.adjustment] to an arbitrary JSON value. + * + * You should usually call [Builder.adjustment] with a well-typed [Adjustment] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun adjustment(adjustment: JsonField) = apply { + this.adjustment = adjustment + } + + /** + * Alias for calling [adjustment] with + * `Adjustment.ofPercentageDiscount(percentageDiscount)`. + */ + fun adjustment(percentageDiscount: NewPercentageDiscount) = + adjustment(Adjustment.ofPercentageDiscount(percentageDiscount)) + + /** + * Alias for calling [adjustment] with the following: + * ```kotlin + * NewPercentageDiscount.builder() + * .adjustmentType(NewPercentageDiscount.AdjustmentType.PERCENTAGE_DISCOUNT) + * .percentageDiscount(percentageDiscount) + * .build() + * ``` + */ + fun percentageDiscountAdjustment(percentageDiscount: Double) = + adjustment( + NewPercentageDiscount.builder() + .adjustmentType(NewPercentageDiscount.AdjustmentType.PERCENTAGE_DISCOUNT) + .percentageDiscount(percentageDiscount) + .build() + ) + + /** Alias for calling [adjustment] with `Adjustment.ofUsageDiscount(usageDiscount)`. */ + fun adjustment(usageDiscount: NewUsageDiscount) = + adjustment(Adjustment.ofUsageDiscount(usageDiscount)) + + /** + * Alias for calling [adjustment] with the following: + * ```kotlin + * NewUsageDiscount.builder() + * .adjustmentType(NewUsageDiscount.AdjustmentType.USAGE_DISCOUNT) + * .usageDiscount(usageDiscount) + * .build() + * ``` + */ + fun usageDiscountAdjustment(usageDiscount: Double) = + adjustment( + NewUsageDiscount.builder() + .adjustmentType(NewUsageDiscount.AdjustmentType.USAGE_DISCOUNT) + .usageDiscount(usageDiscount) + .build() + ) + + /** + * Alias for calling [adjustment] with `Adjustment.ofAmountDiscount(amountDiscount)`. + */ + fun adjustment(amountDiscount: NewAmountDiscount) = + adjustment(Adjustment.ofAmountDiscount(amountDiscount)) + + /** + * Alias for calling [adjustment] with the following: + * ```kotlin + * NewAmountDiscount.builder() + * .adjustmentType(NewAmountDiscount.AdjustmentType.AMOUNT_DISCOUNT) + * .amountDiscount(amountDiscount) + * .build() + * ``` + */ + fun amountDiscountAdjustment(amountDiscount: String) = + adjustment( + NewAmountDiscount.builder() + .adjustmentType(NewAmountDiscount.AdjustmentType.AMOUNT_DISCOUNT) + .amountDiscount(amountDiscount) + .build() + ) + + /** Alias for calling [adjustment] with `Adjustment.ofMinimum(minimum)`. */ + fun adjustment(minimum: NewMinimum) = adjustment(Adjustment.ofMinimum(minimum)) + + /** Alias for calling [adjustment] with `Adjustment.ofMaximum(maximum)`. */ + fun adjustment(maximum: NewMaximum) = adjustment(Adjustment.ofMaximum(maximum)) + + /** + * Alias for calling [adjustment] with the following: + * ```kotlin + * NewMaximum.builder() + * .adjustmentType(NewMaximum.AdjustmentType.MAXIMUM) + * .maximumAmount(maximumAmount) + * .build() + * ``` + */ + fun maximumAdjustment(maximumAmount: String) = + adjustment( + NewMaximum.builder() + .adjustmentType(NewMaximum.AdjustmentType.MAXIMUM) + .maximumAmount(maximumAmount) + .build() + ) + + /** The id of the adjustment on the plan to replace in the plan. */ + fun replacesAdjustmentId(replacesAdjustmentId: String) = + replacesAdjustmentId(JsonField.of(replacesAdjustmentId)) + + /** + * Sets [Builder.replacesAdjustmentId] to an arbitrary JSON value. + * + * You should usually call [Builder.replacesAdjustmentId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun replacesAdjustmentId(replacesAdjustmentId: JsonField) = apply { + this.replacesAdjustmentId = replacesAdjustmentId + } + + /** The phase to replace this adjustment from. */ + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + + /** + * Alias for [Builder.planPhaseOrder]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + + /** + * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. + * + * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun planPhaseOrder(planPhaseOrder: JsonField) = apply { + this.planPhaseOrder = planPhaseOrder + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ReplaceAdjustment]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .adjustment() + * .replacesAdjustmentId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ReplaceAdjustment = + ReplaceAdjustment( + checkRequired("adjustment", adjustment), + checkRequired("replacesAdjustmentId", replacesAdjustmentId), + planPhaseOrder, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ReplaceAdjustment = apply { + if (validated) { + return@apply + } + + adjustment().validate() + replacesAdjustmentId() + planPhaseOrder() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (adjustment.asKnown()?.validity() ?: 0) + + (if (replacesAdjustmentId.asKnown() == null) 0 else 1) + + (if (planPhaseOrder.asKnown() == null) 0 else 1) + + /** The definition of a new adjustment to create and add to the plan. */ + @JsonDeserialize(using = Adjustment.Deserializer::class) + @JsonSerialize(using = Adjustment.Serializer::class) + class Adjustment + private constructor( + private val percentageDiscount: NewPercentageDiscount? = null, + private val usageDiscount: NewUsageDiscount? = null, + private val amountDiscount: NewAmountDiscount? = null, + private val minimum: NewMinimum? = null, + private val maximum: NewMaximum? = null, + private val _json: JsonValue? = null, + ) { + + fun percentageDiscount(): NewPercentageDiscount? = percentageDiscount + + fun usageDiscount(): NewUsageDiscount? = usageDiscount + + fun amountDiscount(): NewAmountDiscount? = amountDiscount + + fun minimum(): NewMinimum? = minimum + + fun maximum(): NewMaximum? = maximum + + fun isPercentageDiscount(): Boolean = percentageDiscount != null + + fun isUsageDiscount(): Boolean = usageDiscount != null + + fun isAmountDiscount(): Boolean = amountDiscount != null + + fun isMinimum(): Boolean = minimum != null + + fun isMaximum(): Boolean = maximum != null + + fun asPercentageDiscount(): NewPercentageDiscount = + percentageDiscount.getOrThrow("percentageDiscount") + + fun asUsageDiscount(): NewUsageDiscount = usageDiscount.getOrThrow("usageDiscount") + + fun asAmountDiscount(): NewAmountDiscount = amountDiscount.getOrThrow("amountDiscount") + + fun asMinimum(): NewMinimum = minimum.getOrThrow("minimum") + + fun asMaximum(): NewMaximum = maximum.getOrThrow("maximum") + + fun _json(): JsonValue? = _json + + fun accept(visitor: Visitor): T = + when { + percentageDiscount != null -> + visitor.visitPercentageDiscount(percentageDiscount) + usageDiscount != null -> visitor.visitUsageDiscount(usageDiscount) + amountDiscount != null -> visitor.visitAmountDiscount(amountDiscount) + minimum != null -> visitor.visitMinimum(minimum) + maximum != null -> visitor.visitMaximum(maximum) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Adjustment = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitPercentageDiscount( + percentageDiscount: NewPercentageDiscount + ) { + percentageDiscount.validate() + } + + override fun visitUsageDiscount(usageDiscount: NewUsageDiscount) { + usageDiscount.validate() + } + + override fun visitAmountDiscount(amountDiscount: NewAmountDiscount) { + amountDiscount.validate() + } + + override fun visitMinimum(minimum: NewMinimum) { + minimum.validate() + } + + override fun visitMaximum(maximum: NewMaximum) { + maximum.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitPercentageDiscount( + percentageDiscount: NewPercentageDiscount + ) = percentageDiscount.validity() + + override fun visitUsageDiscount(usageDiscount: NewUsageDiscount) = + usageDiscount.validity() + + override fun visitAmountDiscount(amountDiscount: NewAmountDiscount) = + amountDiscount.validity() + + override fun visitMinimum(minimum: NewMinimum) = minimum.validity() + + override fun visitMaximum(maximum: NewMaximum) = maximum.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Adjustment && + percentageDiscount == other.percentageDiscount && + usageDiscount == other.usageDiscount && + amountDiscount == other.amountDiscount && + minimum == other.minimum && + maximum == other.maximum + } + + override fun hashCode(): Int = + Objects.hash(percentageDiscount, usageDiscount, amountDiscount, minimum, maximum) + + override fun toString(): String = + when { + percentageDiscount != null -> + "Adjustment{percentageDiscount=$percentageDiscount}" + usageDiscount != null -> "Adjustment{usageDiscount=$usageDiscount}" + amountDiscount != null -> "Adjustment{amountDiscount=$amountDiscount}" + minimum != null -> "Adjustment{minimum=$minimum}" + maximum != null -> "Adjustment{maximum=$maximum}" + _json != null -> "Adjustment{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Adjustment") + } + + companion object { + + fun ofPercentageDiscount(percentageDiscount: NewPercentageDiscount) = + Adjustment(percentageDiscount = percentageDiscount) + + fun ofUsageDiscount(usageDiscount: NewUsageDiscount) = + Adjustment(usageDiscount = usageDiscount) + + fun ofAmountDiscount(amountDiscount: NewAmountDiscount) = + Adjustment(amountDiscount = amountDiscount) + + fun ofMinimum(minimum: NewMinimum) = Adjustment(minimum = minimum) + + fun ofMaximum(maximum: NewMaximum) = Adjustment(maximum = maximum) + } + + /** + * An interface that defines how to map each variant of [Adjustment] to a value of type + * [T]. + */ + interface Visitor { + + fun visitPercentageDiscount(percentageDiscount: NewPercentageDiscount): T + + fun visitUsageDiscount(usageDiscount: NewUsageDiscount): T + + fun visitAmountDiscount(amountDiscount: NewAmountDiscount): T + + fun visitMinimum(minimum: NewMinimum): T + + fun visitMaximum(maximum: NewMaximum): T + + /** + * Maps an unknown variant of [Adjustment] to a value of type [T]. + * + * An instance of [Adjustment] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the + * SDK is unaware of. + * + * @throws OrbInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw OrbInvalidDataException("Unknown Adjustment: $json") + } + } + + internal class Deserializer : BaseDeserializer(Adjustment::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Adjustment { + val json = JsonValue.fromJsonNode(node) + val adjustmentType = json.asObject()?.get("adjustment_type")?.asString() + + when (adjustmentType) { + "percentage_discount" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Adjustment(percentageDiscount = it, _json = json) } + ?: Adjustment(_json = json) + } + "usage_discount" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(usageDiscount = it, _json = json) + } ?: Adjustment(_json = json) + } + "amount_discount" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(amountDiscount = it, _json = json) + } ?: Adjustment(_json = json) + } + "minimum" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(minimum = it, _json = json) + } ?: Adjustment(_json = json) + } + "maximum" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(maximum = it, _json = json) + } ?: Adjustment(_json = json) + } + } + + return Adjustment(_json = json) + } + } + + internal class Serializer : BaseSerializer(Adjustment::class) { + + override fun serialize( + value: Adjustment, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.percentageDiscount != null -> + generator.writeObject(value.percentageDiscount) + value.usageDiscount != null -> generator.writeObject(value.usageDiscount) + value.amountDiscount != null -> generator.writeObject(value.amountDiscount) + value.minimum != null -> generator.writeObject(value.minimum) + value.maximum != null -> generator.writeObject(value.maximum) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Adjustment") + } + } + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ReplaceAdjustment && + adjustment == other.adjustment && + replacesAdjustmentId == other.replacesAdjustmentId && + planPhaseOrder == other.planPhaseOrder && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(adjustment, replacesAdjustmentId, planPhaseOrder, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ReplaceAdjustment{adjustment=$adjustment, replacesAdjustmentId=$replacesAdjustmentId, planPhaseOrder=$planPhaseOrder, additionalProperties=$additionalProperties}" + } + + class ReplacePrice + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val replacesPriceId: JsonField, + private val allocationPrice: JsonField, + private val planPhaseOrder: JsonField, + private val price: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("replaces_price_id") + @ExcludeMissing + replacesPriceId: JsonField = JsonMissing.of(), + @JsonProperty("allocation_price") + @ExcludeMissing + allocationPrice: JsonField = JsonMissing.of(), + @JsonProperty("plan_phase_order") + @ExcludeMissing + planPhaseOrder: JsonField = JsonMissing.of(), + @JsonProperty("price") @ExcludeMissing price: JsonField = JsonMissing.of(), + ) : this(replacesPriceId, allocationPrice, planPhaseOrder, price, mutableMapOf()) + + /** + * The id of the price on the plan to replace in the plan. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun replacesPriceId(): String = replacesPriceId.getRequired("replaces_price_id") + + /** + * The allocation price to add to the plan. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun allocationPrice(): NewAllocationPrice? = allocationPrice.getNullable("allocation_price") + + /** + * The phase to replace this price from. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun planPhaseOrder(): Long? = planPhaseOrder.getNullable("plan_phase_order") + + /** + * New plan price request body params. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun price(): Price? = price.getNullable("price") + + /** + * Returns the raw JSON value of [replacesPriceId]. + * + * Unlike [replacesPriceId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("replaces_price_id") + @ExcludeMissing + fun _replacesPriceId(): JsonField = replacesPriceId + + /** + * Returns the raw JSON value of [allocationPrice]. + * + * Unlike [allocationPrice], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("allocation_price") + @ExcludeMissing + fun _allocationPrice(): JsonField = allocationPrice + + /** + * Returns the raw JSON value of [planPhaseOrder]. + * + * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder + + /** + * Returns the raw JSON value of [price]. + * + * Unlike [price], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("price") @ExcludeMissing fun _price(): JsonField = price + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ReplacePrice]. + * + * The following fields are required: + * ```kotlin + * .replacesPriceId() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [ReplacePrice]. */ + class Builder internal constructor() { + + private var replacesPriceId: JsonField? = null + private var allocationPrice: JsonField = JsonMissing.of() + private var planPhaseOrder: JsonField = JsonMissing.of() + private var price: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(replacePrice: ReplacePrice) = apply { + replacesPriceId = replacePrice.replacesPriceId + allocationPrice = replacePrice.allocationPrice + planPhaseOrder = replacePrice.planPhaseOrder + price = replacePrice.price + additionalProperties = replacePrice.additionalProperties.toMutableMap() + } + + /** The id of the price on the plan to replace in the plan. */ + fun replacesPriceId(replacesPriceId: String) = + replacesPriceId(JsonField.of(replacesPriceId)) + + /** + * Sets [Builder.replacesPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.replacesPriceId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun replacesPriceId(replacesPriceId: JsonField) = apply { + this.replacesPriceId = replacesPriceId + } + + /** The allocation price to add to the plan. */ + fun allocationPrice(allocationPrice: NewAllocationPrice?) = + allocationPrice(JsonField.ofNullable(allocationPrice)) + + /** + * Sets [Builder.allocationPrice] to an arbitrary JSON value. + * + * You should usually call [Builder.allocationPrice] with a well-typed + * [NewAllocationPrice] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun allocationPrice(allocationPrice: JsonField) = apply { + this.allocationPrice = allocationPrice + } + + /** The phase to replace this price from. */ + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + + /** + * Alias for [Builder.planPhaseOrder]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + + /** + * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. + * + * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun planPhaseOrder(planPhaseOrder: JsonField) = apply { + this.planPhaseOrder = planPhaseOrder + } + + /** New plan price request body params. */ + fun price(price: Price?) = price(JsonField.ofNullable(price)) + + /** + * Sets [Builder.price] to an arbitrary JSON value. + * + * You should usually call [Builder.price] with a well-typed [Price] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun price(price: JsonField) = apply { this.price = price } + + /** Alias for calling [price] with `Price.ofUnit(unit)`. */ + fun price(unit: NewPlanUnitPrice) = price(Price.ofUnit(unit)) + + /** Alias for calling [price] with `Price.ofTiered(tiered)`. */ + fun price(tiered: NewPlanTieredPrice) = price(Price.ofTiered(tiered)) + + /** Alias for calling [price] with `Price.ofBulk(bulk)`. */ + fun price(bulk: NewPlanBulkPrice) = price(Price.ofBulk(bulk)) + + /** Alias for calling [price] with `Price.ofPackage(package_)`. */ + fun price(package_: NewPlanPackagePrice) = price(Price.ofPackage(package_)) + + /** Alias for calling [price] with `Price.ofMatrix(matrix)`. */ + fun price(matrix: NewPlanMatrixPrice) = price(Price.ofMatrix(matrix)) + + /** + * Alias for calling [price] with `Price.ofThresholdTotalAmount(thresholdTotalAmount)`. + */ + fun price(thresholdTotalAmount: NewPlanThresholdTotalAmountPrice) = + price(Price.ofThresholdTotalAmount(thresholdTotalAmount)) + + /** Alias for calling [price] with `Price.ofTieredPackage(tieredPackage)`. */ + fun price(tieredPackage: NewPlanTieredPackagePrice) = + price(Price.ofTieredPackage(tieredPackage)) + + /** Alias for calling [price] with `Price.ofTieredWithMinimum(tieredWithMinimum)`. */ + fun price(tieredWithMinimum: NewPlanTieredWithMinimumPrice) = + price(Price.ofTieredWithMinimum(tieredWithMinimum)) + + /** Alias for calling [price] with `Price.ofGroupedTiered(groupedTiered)`. */ + fun price(groupedTiered: NewPlanGroupedTieredPrice) = + price(Price.ofGroupedTiered(groupedTiered)) + + /** + * Alias for calling [price] with + * `Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)`. + */ + fun price(tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice) = + price(Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)) + + /** + * Alias for calling [price] with + * `Price.ofPackageWithAllocation(packageWithAllocation)`. + */ + fun price(packageWithAllocation: NewPlanPackageWithAllocationPrice) = + price(Price.ofPackageWithAllocation(packageWithAllocation)) + + /** Alias for calling [price] with `Price.ofUnitWithPercent(unitWithPercent)`. */ + fun price(unitWithPercent: NewPlanUnitWithPercentPrice) = + price(Price.ofUnitWithPercent(unitWithPercent)) + + /** + * Alias for calling [price] with `Price.ofMatrixWithAllocation(matrixWithAllocation)`. + */ + fun price(matrixWithAllocation: NewPlanMatrixWithAllocationPrice) = + price(Price.ofMatrixWithAllocation(matrixWithAllocation)) + + /** + * Alias for calling [price] with `Price.ofTieredWithProration(tieredWithProration)`. + */ + fun price(tieredWithProration: Price.TieredWithProration) = + price(Price.ofTieredWithProration(tieredWithProration)) + + /** Alias for calling [price] with `Price.ofUnitWithProration(unitWithProration)`. */ + fun price(unitWithProration: NewPlanUnitWithProrationPrice) = + price(Price.ofUnitWithProration(unitWithProration)) + + /** Alias for calling [price] with `Price.ofGroupedAllocation(groupedAllocation)`. */ + fun price(groupedAllocation: NewPlanGroupedAllocationPrice) = + price(Price.ofGroupedAllocation(groupedAllocation)) + + /** Alias for calling [price] with `Price.ofBulkWithProration(bulkWithProration)`. */ + fun price(bulkWithProration: NewPlanBulkWithProrationPrice) = + price(Price.ofBulkWithProration(bulkWithProration)) + + /** + * Alias for calling [price] with + * `Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)`. + */ + fun price(groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice) = + price(Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)) + + /** + * Alias for calling [price] with + * `Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)`. + */ + fun price(groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice) = + price(Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)) + + /** + * Alias for calling [price] with + * `Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)`. + */ + fun price(groupedWithMinMaxThresholds: Price.GroupedWithMinMaxThresholds) = + price(Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)) + + /** + * Alias for calling [price] with + * `Price.ofMatrixWithDisplayName(matrixWithDisplayName)`. + */ + fun price(matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice) = + price(Price.ofMatrixWithDisplayName(matrixWithDisplayName)) + + /** + * Alias for calling [price] with `Price.ofGroupedTieredPackage(groupedTieredPackage)`. + */ + fun price(groupedTieredPackage: NewPlanGroupedTieredPackagePrice) = + price(Price.ofGroupedTieredPackage(groupedTieredPackage)) + + /** + * Alias for calling [price] with + * `Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)`. + */ + fun price(maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice) = + price(Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)) + + /** + * Alias for calling [price] with + * `Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)`. + */ + fun price(scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice) = + price(Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)) + + /** + * Alias for calling [price] with + * `Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)`. + */ + fun price( + scalableMatrixWithTieredPricing: NewPlanScalableMatrixWithTieredPricingPrice + ) = price(Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)) + + /** + * Alias for calling [price] with + * `Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)`. + */ + fun price(cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice) = + price(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) + + /** Alias for calling [price] with `Price.ofMinimum(minimum)`. */ + fun price(minimum: NewPlanMinimumCompositePrice) = price(Price.ofMinimum(minimum)) + + /** Alias for calling [price] with `Price.ofPercent(percent)`. */ + fun price(percent: Price.Percent) = price(Price.ofPercent(percent)) + + /** Alias for calling [price] with `Price.ofEventOutput(eventOutput)`. */ + fun price(eventOutput: Price.EventOutput) = price(Price.ofEventOutput(eventOutput)) + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ReplacePrice]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .replacesPriceId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ReplacePrice = + ReplacePrice( + checkRequired("replacesPriceId", replacesPriceId), + allocationPrice, + planPhaseOrder, + price, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ReplacePrice = apply { + if (validated) { + return@apply + } + + replacesPriceId() + allocationPrice()?.validate() + planPhaseOrder() + price()?.validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (replacesPriceId.asKnown() == null) 0 else 1) + + (allocationPrice.asKnown()?.validity() ?: 0) + + (if (planPhaseOrder.asKnown() == null) 0 else 1) + + (price.asKnown()?.validity() ?: 0) + + /** New plan price request body params. */ + @JsonDeserialize(using = Price.Deserializer::class) + @JsonSerialize(using = Price.Serializer::class) + class Price + private constructor( + private val unit: NewPlanUnitPrice? = null, + private val tiered: NewPlanTieredPrice? = null, + private val bulk: NewPlanBulkPrice? = null, + private val package_: NewPlanPackagePrice? = null, + private val matrix: NewPlanMatrixPrice? = null, + private val thresholdTotalAmount: NewPlanThresholdTotalAmountPrice? = null, + private val tieredPackage: NewPlanTieredPackagePrice? = null, + private val tieredWithMinimum: NewPlanTieredWithMinimumPrice? = null, + private val groupedTiered: NewPlanGroupedTieredPrice? = null, + private val tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice? = null, + private val packageWithAllocation: NewPlanPackageWithAllocationPrice? = null, + private val unitWithPercent: NewPlanUnitWithPercentPrice? = null, + private val matrixWithAllocation: NewPlanMatrixWithAllocationPrice? = null, + private val tieredWithProration: TieredWithProration? = null, + private val unitWithProration: NewPlanUnitWithProrationPrice? = null, + private val groupedAllocation: NewPlanGroupedAllocationPrice? = null, + private val bulkWithProration: NewPlanBulkWithProrationPrice? = null, + private val groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice? = null, + private val groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice? = null, + private val groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds? = null, + private val matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice? = null, + private val groupedTieredPackage: NewPlanGroupedTieredPackagePrice? = null, + private val maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice? = null, + private val scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice? = + null, + private val scalableMatrixWithTieredPricing: + NewPlanScalableMatrixWithTieredPricingPrice? = + null, + private val cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice? = null, + private val minimum: NewPlanMinimumCompositePrice? = null, + private val percent: Percent? = null, + private val eventOutput: EventOutput? = null, + private val _json: JsonValue? = null, + ) { + + fun unit(): NewPlanUnitPrice? = unit + + fun tiered(): NewPlanTieredPrice? = tiered + + fun bulk(): NewPlanBulkPrice? = bulk + + fun package_(): NewPlanPackagePrice? = package_ + + fun matrix(): NewPlanMatrixPrice? = matrix + + fun thresholdTotalAmount(): NewPlanThresholdTotalAmountPrice? = thresholdTotalAmount + + fun tieredPackage(): NewPlanTieredPackagePrice? = tieredPackage + + fun tieredWithMinimum(): NewPlanTieredWithMinimumPrice? = tieredWithMinimum + + fun groupedTiered(): NewPlanGroupedTieredPrice? = groupedTiered + + fun tieredPackageWithMinimum(): NewPlanTieredPackageWithMinimumPrice? = + tieredPackageWithMinimum + + fun packageWithAllocation(): NewPlanPackageWithAllocationPrice? = packageWithAllocation + + fun unitWithPercent(): NewPlanUnitWithPercentPrice? = unitWithPercent + + fun matrixWithAllocation(): NewPlanMatrixWithAllocationPrice? = matrixWithAllocation + + fun tieredWithProration(): TieredWithProration? = tieredWithProration + + fun unitWithProration(): NewPlanUnitWithProrationPrice? = unitWithProration + + fun groupedAllocation(): NewPlanGroupedAllocationPrice? = groupedAllocation + + fun bulkWithProration(): NewPlanBulkWithProrationPrice? = bulkWithProration + + fun groupedWithProratedMinimum(): NewPlanGroupedWithProratedMinimumPrice? = + groupedWithProratedMinimum + + fun groupedWithMeteredMinimum(): NewPlanGroupedWithMeteredMinimumPrice? = + groupedWithMeteredMinimum + + fun groupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds? = + groupedWithMinMaxThresholds + + fun matrixWithDisplayName(): NewPlanMatrixWithDisplayNamePrice? = matrixWithDisplayName + + fun groupedTieredPackage(): NewPlanGroupedTieredPackagePrice? = groupedTieredPackage + + fun maxGroupTieredPackage(): NewPlanMaxGroupTieredPackagePrice? = maxGroupTieredPackage + + fun scalableMatrixWithUnitPricing(): NewPlanScalableMatrixWithUnitPricingPrice? = + scalableMatrixWithUnitPricing + + fun scalableMatrixWithTieredPricing(): NewPlanScalableMatrixWithTieredPricingPrice? = + scalableMatrixWithTieredPricing + + fun cumulativeGroupedBulk(): NewPlanCumulativeGroupedBulkPrice? = cumulativeGroupedBulk + + fun minimum(): NewPlanMinimumCompositePrice? = minimum + + fun percent(): Percent? = percent + + fun eventOutput(): EventOutput? = eventOutput + + fun isUnit(): Boolean = unit != null + + fun isTiered(): Boolean = tiered != null + + fun isBulk(): Boolean = bulk != null + + fun isPackage(): Boolean = package_ != null + + fun isMatrix(): Boolean = matrix != null + + fun isThresholdTotalAmount(): Boolean = thresholdTotalAmount != null + + fun isTieredPackage(): Boolean = tieredPackage != null + + fun isTieredWithMinimum(): Boolean = tieredWithMinimum != null + + fun isGroupedTiered(): Boolean = groupedTiered != null + + fun isTieredPackageWithMinimum(): Boolean = tieredPackageWithMinimum != null + + fun isPackageWithAllocation(): Boolean = packageWithAllocation != null + + fun isUnitWithPercent(): Boolean = unitWithPercent != null + + fun isMatrixWithAllocation(): Boolean = matrixWithAllocation != null + + fun isTieredWithProration(): Boolean = tieredWithProration != null + + fun isUnitWithProration(): Boolean = unitWithProration != null + + fun isGroupedAllocation(): Boolean = groupedAllocation != null + + fun isBulkWithProration(): Boolean = bulkWithProration != null + + fun isGroupedWithProratedMinimum(): Boolean = groupedWithProratedMinimum != null + + fun isGroupedWithMeteredMinimum(): Boolean = groupedWithMeteredMinimum != null + + fun isGroupedWithMinMaxThresholds(): Boolean = groupedWithMinMaxThresholds != null + + fun isMatrixWithDisplayName(): Boolean = matrixWithDisplayName != null + + fun isGroupedTieredPackage(): Boolean = groupedTieredPackage != null + + fun isMaxGroupTieredPackage(): Boolean = maxGroupTieredPackage != null + + fun isScalableMatrixWithUnitPricing(): Boolean = scalableMatrixWithUnitPricing != null + + fun isScalableMatrixWithTieredPricing(): Boolean = + scalableMatrixWithTieredPricing != null + + fun isCumulativeGroupedBulk(): Boolean = cumulativeGroupedBulk != null + + fun isMinimum(): Boolean = minimum != null + + fun isPercent(): Boolean = percent != null + + fun isEventOutput(): Boolean = eventOutput != null + + fun asUnit(): NewPlanUnitPrice = unit.getOrThrow("unit") + + fun asTiered(): NewPlanTieredPrice = tiered.getOrThrow("tiered") + + fun asBulk(): NewPlanBulkPrice = bulk.getOrThrow("bulk") + + fun asPackage(): NewPlanPackagePrice = package_.getOrThrow("package_") + + fun asMatrix(): NewPlanMatrixPrice = matrix.getOrThrow("matrix") + + fun asThresholdTotalAmount(): NewPlanThresholdTotalAmountPrice = + thresholdTotalAmount.getOrThrow("thresholdTotalAmount") + + fun asTieredPackage(): NewPlanTieredPackagePrice = + tieredPackage.getOrThrow("tieredPackage") + + fun asTieredWithMinimum(): NewPlanTieredWithMinimumPrice = + tieredWithMinimum.getOrThrow("tieredWithMinimum") + + fun asGroupedTiered(): NewPlanGroupedTieredPrice = + groupedTiered.getOrThrow("groupedTiered") + + fun asTieredPackageWithMinimum(): NewPlanTieredPackageWithMinimumPrice = + tieredPackageWithMinimum.getOrThrow("tieredPackageWithMinimum") + + fun asPackageWithAllocation(): NewPlanPackageWithAllocationPrice = + packageWithAllocation.getOrThrow("packageWithAllocation") + + fun asUnitWithPercent(): NewPlanUnitWithPercentPrice = + unitWithPercent.getOrThrow("unitWithPercent") + + fun asMatrixWithAllocation(): NewPlanMatrixWithAllocationPrice = + matrixWithAllocation.getOrThrow("matrixWithAllocation") + + fun asTieredWithProration(): TieredWithProration = + tieredWithProration.getOrThrow("tieredWithProration") + + fun asUnitWithProration(): NewPlanUnitWithProrationPrice = + unitWithProration.getOrThrow("unitWithProration") + + fun asGroupedAllocation(): NewPlanGroupedAllocationPrice = + groupedAllocation.getOrThrow("groupedAllocation") + + fun asBulkWithProration(): NewPlanBulkWithProrationPrice = + bulkWithProration.getOrThrow("bulkWithProration") + + fun asGroupedWithProratedMinimum(): NewPlanGroupedWithProratedMinimumPrice = + groupedWithProratedMinimum.getOrThrow("groupedWithProratedMinimum") + + fun asGroupedWithMeteredMinimum(): NewPlanGroupedWithMeteredMinimumPrice = + groupedWithMeteredMinimum.getOrThrow("groupedWithMeteredMinimum") + + fun asGroupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds = + groupedWithMinMaxThresholds.getOrThrow("groupedWithMinMaxThresholds") + + fun asMatrixWithDisplayName(): NewPlanMatrixWithDisplayNamePrice = + matrixWithDisplayName.getOrThrow("matrixWithDisplayName") + + fun asGroupedTieredPackage(): NewPlanGroupedTieredPackagePrice = + groupedTieredPackage.getOrThrow("groupedTieredPackage") + + fun asMaxGroupTieredPackage(): NewPlanMaxGroupTieredPackagePrice = + maxGroupTieredPackage.getOrThrow("maxGroupTieredPackage") + + fun asScalableMatrixWithUnitPricing(): NewPlanScalableMatrixWithUnitPricingPrice = + scalableMatrixWithUnitPricing.getOrThrow("scalableMatrixWithUnitPricing") + + fun asScalableMatrixWithTieredPricing(): NewPlanScalableMatrixWithTieredPricingPrice = + scalableMatrixWithTieredPricing.getOrThrow("scalableMatrixWithTieredPricing") + + fun asCumulativeGroupedBulk(): NewPlanCumulativeGroupedBulkPrice = + cumulativeGroupedBulk.getOrThrow("cumulativeGroupedBulk") + + fun asMinimum(): NewPlanMinimumCompositePrice = minimum.getOrThrow("minimum") + + fun asPercent(): Percent = percent.getOrThrow("percent") + + fun asEventOutput(): EventOutput = eventOutput.getOrThrow("eventOutput") + + fun _json(): JsonValue? = _json + + fun accept(visitor: Visitor): T = + when { + unit != null -> visitor.visitUnit(unit) + tiered != null -> visitor.visitTiered(tiered) + bulk != null -> visitor.visitBulk(bulk) + package_ != null -> visitor.visitPackage(package_) + matrix != null -> visitor.visitMatrix(matrix) + thresholdTotalAmount != null -> + visitor.visitThresholdTotalAmount(thresholdTotalAmount) + tieredPackage != null -> visitor.visitTieredPackage(tieredPackage) + tieredWithMinimum != null -> visitor.visitTieredWithMinimum(tieredWithMinimum) + groupedTiered != null -> visitor.visitGroupedTiered(groupedTiered) + tieredPackageWithMinimum != null -> + visitor.visitTieredPackageWithMinimum(tieredPackageWithMinimum) + packageWithAllocation != null -> + visitor.visitPackageWithAllocation(packageWithAllocation) + unitWithPercent != null -> visitor.visitUnitWithPercent(unitWithPercent) + matrixWithAllocation != null -> + visitor.visitMatrixWithAllocation(matrixWithAllocation) + tieredWithProration != null -> + visitor.visitTieredWithProration(tieredWithProration) + unitWithProration != null -> visitor.visitUnitWithProration(unitWithProration) + groupedAllocation != null -> visitor.visitGroupedAllocation(groupedAllocation) + bulkWithProration != null -> visitor.visitBulkWithProration(bulkWithProration) + groupedWithProratedMinimum != null -> + visitor.visitGroupedWithProratedMinimum(groupedWithProratedMinimum) + groupedWithMeteredMinimum != null -> + visitor.visitGroupedWithMeteredMinimum(groupedWithMeteredMinimum) + groupedWithMinMaxThresholds != null -> + visitor.visitGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds) + matrixWithDisplayName != null -> + visitor.visitMatrixWithDisplayName(matrixWithDisplayName) + groupedTieredPackage != null -> + visitor.visitGroupedTieredPackage(groupedTieredPackage) + maxGroupTieredPackage != null -> + visitor.visitMaxGroupTieredPackage(maxGroupTieredPackage) + scalableMatrixWithUnitPricing != null -> + visitor.visitScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing) + scalableMatrixWithTieredPricing != null -> + visitor.visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing + ) + cumulativeGroupedBulk != null -> + visitor.visitCumulativeGroupedBulk(cumulativeGroupedBulk) + minimum != null -> visitor.visitMinimum(minimum) + percent != null -> visitor.visitPercent(percent) + eventOutput != null -> visitor.visitEventOutput(eventOutput) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Price = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitUnit(unit: NewPlanUnitPrice) { + unit.validate() + } + + override fun visitTiered(tiered: NewPlanTieredPrice) { + tiered.validate() + } + + override fun visitBulk(bulk: NewPlanBulkPrice) { + bulk.validate() + } + + override fun visitPackage(package_: NewPlanPackagePrice) { + package_.validate() + } + + override fun visitMatrix(matrix: NewPlanMatrixPrice) { + matrix.validate() + } + + override fun visitThresholdTotalAmount( + thresholdTotalAmount: NewPlanThresholdTotalAmountPrice + ) { + thresholdTotalAmount.validate() + } + + override fun visitTieredPackage(tieredPackage: NewPlanTieredPackagePrice) { + tieredPackage.validate() + } + + override fun visitTieredWithMinimum( + tieredWithMinimum: NewPlanTieredWithMinimumPrice + ) { + tieredWithMinimum.validate() + } + + override fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) { + groupedTiered.validate() + } + + override fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice + ) { + tieredPackageWithMinimum.validate() + } + + override fun visitPackageWithAllocation( + packageWithAllocation: NewPlanPackageWithAllocationPrice + ) { + packageWithAllocation.validate() + } + + override fun visitUnitWithPercent( + unitWithPercent: NewPlanUnitWithPercentPrice + ) { + unitWithPercent.validate() + } + + override fun visitMatrixWithAllocation( + matrixWithAllocation: NewPlanMatrixWithAllocationPrice + ) { + matrixWithAllocation.validate() + } + + override fun visitTieredWithProration( + tieredWithProration: TieredWithProration + ) { + tieredWithProration.validate() + } + + override fun visitUnitWithProration( + unitWithProration: NewPlanUnitWithProrationPrice + ) { + unitWithProration.validate() + } + + override fun visitGroupedAllocation( + groupedAllocation: NewPlanGroupedAllocationPrice + ) { + groupedAllocation.validate() + } + + override fun visitBulkWithProration( + bulkWithProration: NewPlanBulkWithProrationPrice + ) { + bulkWithProration.validate() + } + + override fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice + ) { + groupedWithProratedMinimum.validate() + } + + override fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice + ) { + groupedWithMeteredMinimum.validate() + } + + override fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) { + groupedWithMinMaxThresholds.validate() + } + + override fun visitMatrixWithDisplayName( + matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice + ) { + matrixWithDisplayName.validate() + } + + override fun visitGroupedTieredPackage( + groupedTieredPackage: NewPlanGroupedTieredPackagePrice + ) { + groupedTieredPackage.validate() + } + + override fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice + ) { + maxGroupTieredPackage.validate() + } + + override fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice + ) { + scalableMatrixWithUnitPricing.validate() + } + + override fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: + NewPlanScalableMatrixWithTieredPricingPrice + ) { + scalableMatrixWithTieredPricing.validate() + } + + override fun visitCumulativeGroupedBulk( + cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice + ) { + cumulativeGroupedBulk.validate() + } + + override fun visitMinimum(minimum: NewPlanMinimumCompositePrice) { + minimum.validate() + } + + override fun visitPercent(percent: Percent) { + percent.validate() + } + + override fun visitEventOutput(eventOutput: EventOutput) { + eventOutput.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitUnit(unit: NewPlanUnitPrice) = unit.validity() + + override fun visitTiered(tiered: NewPlanTieredPrice) = tiered.validity() + + override fun visitBulk(bulk: NewPlanBulkPrice) = bulk.validity() + + override fun visitPackage(package_: NewPlanPackagePrice) = + package_.validity() + + override fun visitMatrix(matrix: NewPlanMatrixPrice) = matrix.validity() + + override fun visitThresholdTotalAmount( + thresholdTotalAmount: NewPlanThresholdTotalAmountPrice + ) = thresholdTotalAmount.validity() + + override fun visitTieredPackage(tieredPackage: NewPlanTieredPackagePrice) = + tieredPackage.validity() + + override fun visitTieredWithMinimum( + tieredWithMinimum: NewPlanTieredWithMinimumPrice + ) = tieredWithMinimum.validity() + + override fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) = + groupedTiered.validity() + + override fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice + ) = tieredPackageWithMinimum.validity() + + override fun visitPackageWithAllocation( + packageWithAllocation: NewPlanPackageWithAllocationPrice + ) = packageWithAllocation.validity() + + override fun visitUnitWithPercent( + unitWithPercent: NewPlanUnitWithPercentPrice + ) = unitWithPercent.validity() + + override fun visitMatrixWithAllocation( + matrixWithAllocation: NewPlanMatrixWithAllocationPrice + ) = matrixWithAllocation.validity() + + override fun visitTieredWithProration( + tieredWithProration: TieredWithProration + ) = tieredWithProration.validity() + + override fun visitUnitWithProration( + unitWithProration: NewPlanUnitWithProrationPrice + ) = unitWithProration.validity() + + override fun visitGroupedAllocation( + groupedAllocation: NewPlanGroupedAllocationPrice + ) = groupedAllocation.validity() + + override fun visitBulkWithProration( + bulkWithProration: NewPlanBulkWithProrationPrice + ) = bulkWithProration.validity() + + override fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice + ) = groupedWithProratedMinimum.validity() + + override fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice + ) = groupedWithMeteredMinimum.validity() + + override fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) = groupedWithMinMaxThresholds.validity() + + override fun visitMatrixWithDisplayName( + matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice + ) = matrixWithDisplayName.validity() + + override fun visitGroupedTieredPackage( + groupedTieredPackage: NewPlanGroupedTieredPackagePrice + ) = groupedTieredPackage.validity() + + override fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice + ) = maxGroupTieredPackage.validity() + + override fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice + ) = scalableMatrixWithUnitPricing.validity() + + override fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: + NewPlanScalableMatrixWithTieredPricingPrice + ) = scalableMatrixWithTieredPricing.validity() + + override fun visitCumulativeGroupedBulk( + cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice + ) = cumulativeGroupedBulk.validity() + + override fun visitMinimum(minimum: NewPlanMinimumCompositePrice) = + minimum.validity() + + override fun visitPercent(percent: Percent) = percent.validity() + + override fun visitEventOutput(eventOutput: EventOutput) = + eventOutput.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Price && + unit == other.unit && + tiered == other.tiered && + bulk == other.bulk && + package_ == other.package_ && + matrix == other.matrix && + thresholdTotalAmount == other.thresholdTotalAmount && + tieredPackage == other.tieredPackage && + tieredWithMinimum == other.tieredWithMinimum && + groupedTiered == other.groupedTiered && + tieredPackageWithMinimum == other.tieredPackageWithMinimum && + packageWithAllocation == other.packageWithAllocation && + unitWithPercent == other.unitWithPercent && + matrixWithAllocation == other.matrixWithAllocation && + tieredWithProration == other.tieredWithProration && + unitWithProration == other.unitWithProration && + groupedAllocation == other.groupedAllocation && + bulkWithProration == other.bulkWithProration && + groupedWithProratedMinimum == other.groupedWithProratedMinimum && + groupedWithMeteredMinimum == other.groupedWithMeteredMinimum && + groupedWithMinMaxThresholds == other.groupedWithMinMaxThresholds && + matrixWithDisplayName == other.matrixWithDisplayName && + groupedTieredPackage == other.groupedTieredPackage && + maxGroupTieredPackage == other.maxGroupTieredPackage && + scalableMatrixWithUnitPricing == other.scalableMatrixWithUnitPricing && + scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && + cumulativeGroupedBulk == other.cumulativeGroupedBulk && + minimum == other.minimum && + percent == other.percent && + eventOutput == other.eventOutput + } + + override fun hashCode(): Int = + Objects.hash( + unit, + tiered, + bulk, + package_, + matrix, + thresholdTotalAmount, + tieredPackage, + tieredWithMinimum, + groupedTiered, + tieredPackageWithMinimum, + packageWithAllocation, + unitWithPercent, + matrixWithAllocation, + tieredWithProration, + unitWithProration, + groupedAllocation, + bulkWithProration, + groupedWithProratedMinimum, + groupedWithMeteredMinimum, + groupedWithMinMaxThresholds, + matrixWithDisplayName, + groupedTieredPackage, + maxGroupTieredPackage, + scalableMatrixWithUnitPricing, + scalableMatrixWithTieredPricing, + cumulativeGroupedBulk, + minimum, + percent, + eventOutput, + ) + + override fun toString(): String = + when { + unit != null -> "Price{unit=$unit}" + tiered != null -> "Price{tiered=$tiered}" + bulk != null -> "Price{bulk=$bulk}" + package_ != null -> "Price{package_=$package_}" + matrix != null -> "Price{matrix=$matrix}" + thresholdTotalAmount != null -> + "Price{thresholdTotalAmount=$thresholdTotalAmount}" + tieredPackage != null -> "Price{tieredPackage=$tieredPackage}" + tieredWithMinimum != null -> "Price{tieredWithMinimum=$tieredWithMinimum}" + groupedTiered != null -> "Price{groupedTiered=$groupedTiered}" + tieredPackageWithMinimum != null -> + "Price{tieredPackageWithMinimum=$tieredPackageWithMinimum}" + packageWithAllocation != null -> + "Price{packageWithAllocation=$packageWithAllocation}" + unitWithPercent != null -> "Price{unitWithPercent=$unitWithPercent}" + matrixWithAllocation != null -> + "Price{matrixWithAllocation=$matrixWithAllocation}" + tieredWithProration != null -> "Price{tieredWithProration=$tieredWithProration}" + unitWithProration != null -> "Price{unitWithProration=$unitWithProration}" + groupedAllocation != null -> "Price{groupedAllocation=$groupedAllocation}" + bulkWithProration != null -> "Price{bulkWithProration=$bulkWithProration}" + groupedWithProratedMinimum != null -> + "Price{groupedWithProratedMinimum=$groupedWithProratedMinimum}" + groupedWithMeteredMinimum != null -> + "Price{groupedWithMeteredMinimum=$groupedWithMeteredMinimum}" + groupedWithMinMaxThresholds != null -> + "Price{groupedWithMinMaxThresholds=$groupedWithMinMaxThresholds}" + matrixWithDisplayName != null -> + "Price{matrixWithDisplayName=$matrixWithDisplayName}" + groupedTieredPackage != null -> + "Price{groupedTieredPackage=$groupedTieredPackage}" + maxGroupTieredPackage != null -> + "Price{maxGroupTieredPackage=$maxGroupTieredPackage}" + scalableMatrixWithUnitPricing != null -> + "Price{scalableMatrixWithUnitPricing=$scalableMatrixWithUnitPricing}" + scalableMatrixWithTieredPricing != null -> + "Price{scalableMatrixWithTieredPricing=$scalableMatrixWithTieredPricing}" + cumulativeGroupedBulk != null -> + "Price{cumulativeGroupedBulk=$cumulativeGroupedBulk}" + minimum != null -> "Price{minimum=$minimum}" + percent != null -> "Price{percent=$percent}" + eventOutput != null -> "Price{eventOutput=$eventOutput}" + _json != null -> "Price{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Price") + } + + companion object { + + fun ofUnit(unit: NewPlanUnitPrice) = Price(unit = unit) + + fun ofTiered(tiered: NewPlanTieredPrice) = Price(tiered = tiered) + + fun ofBulk(bulk: NewPlanBulkPrice) = Price(bulk = bulk) + + fun ofPackage(package_: NewPlanPackagePrice) = Price(package_ = package_) + + fun ofMatrix(matrix: NewPlanMatrixPrice) = Price(matrix = matrix) + + fun ofThresholdTotalAmount(thresholdTotalAmount: NewPlanThresholdTotalAmountPrice) = + Price(thresholdTotalAmount = thresholdTotalAmount) + + fun ofTieredPackage(tieredPackage: NewPlanTieredPackagePrice) = + Price(tieredPackage = tieredPackage) + + fun ofTieredWithMinimum(tieredWithMinimum: NewPlanTieredWithMinimumPrice) = + Price(tieredWithMinimum = tieredWithMinimum) + + fun ofGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) = + Price(groupedTiered = groupedTiered) + + fun ofTieredPackageWithMinimum( + tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice + ) = Price(tieredPackageWithMinimum = tieredPackageWithMinimum) + + fun ofPackageWithAllocation( + packageWithAllocation: NewPlanPackageWithAllocationPrice + ) = Price(packageWithAllocation = packageWithAllocation) + + fun ofUnitWithPercent(unitWithPercent: NewPlanUnitWithPercentPrice) = + Price(unitWithPercent = unitWithPercent) + + fun ofMatrixWithAllocation(matrixWithAllocation: NewPlanMatrixWithAllocationPrice) = + Price(matrixWithAllocation = matrixWithAllocation) + + fun ofTieredWithProration(tieredWithProration: TieredWithProration) = + Price(tieredWithProration = tieredWithProration) + + fun ofUnitWithProration(unitWithProration: NewPlanUnitWithProrationPrice) = + Price(unitWithProration = unitWithProration) + + fun ofGroupedAllocation(groupedAllocation: NewPlanGroupedAllocationPrice) = + Price(groupedAllocation = groupedAllocation) + + fun ofBulkWithProration(bulkWithProration: NewPlanBulkWithProrationPrice) = + Price(bulkWithProration = bulkWithProration) + + fun ofGroupedWithProratedMinimum( + groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice + ) = Price(groupedWithProratedMinimum = groupedWithProratedMinimum) + + fun ofGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice + ) = Price(groupedWithMeteredMinimum = groupedWithMeteredMinimum) + + fun ofGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) = Price(groupedWithMinMaxThresholds = groupedWithMinMaxThresholds) + + fun ofMatrixWithDisplayName( + matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice + ) = Price(matrixWithDisplayName = matrixWithDisplayName) + + fun ofGroupedTieredPackage(groupedTieredPackage: NewPlanGroupedTieredPackagePrice) = + Price(groupedTieredPackage = groupedTieredPackage) + + fun ofMaxGroupTieredPackage( + maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice + ) = Price(maxGroupTieredPackage = maxGroupTieredPackage) + + fun ofScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice + ) = Price(scalableMatrixWithUnitPricing = scalableMatrixWithUnitPricing) + + fun ofScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: NewPlanScalableMatrixWithTieredPricingPrice + ) = Price(scalableMatrixWithTieredPricing = scalableMatrixWithTieredPricing) + + fun ofCumulativeGroupedBulk( + cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice + ) = Price(cumulativeGroupedBulk = cumulativeGroupedBulk) + + fun ofMinimum(minimum: NewPlanMinimumCompositePrice) = Price(minimum = minimum) + + fun ofPercent(percent: Percent) = Price(percent = percent) + + fun ofEventOutput(eventOutput: EventOutput) = Price(eventOutput = eventOutput) + } + + /** + * An interface that defines how to map each variant of [Price] to a value of type [T]. + */ + interface Visitor { + + fun visitUnit(unit: NewPlanUnitPrice): T + + fun visitTiered(tiered: NewPlanTieredPrice): T + + fun visitBulk(bulk: NewPlanBulkPrice): T + + fun visitPackage(package_: NewPlanPackagePrice): T + + fun visitMatrix(matrix: NewPlanMatrixPrice): T + + fun visitThresholdTotalAmount( + thresholdTotalAmount: NewPlanThresholdTotalAmountPrice + ): T + + fun visitTieredPackage(tieredPackage: NewPlanTieredPackagePrice): T + + fun visitTieredWithMinimum(tieredWithMinimum: NewPlanTieredWithMinimumPrice): T + + fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice): T + + fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice + ): T + + fun visitPackageWithAllocation( + packageWithAllocation: NewPlanPackageWithAllocationPrice + ): T + + fun visitUnitWithPercent(unitWithPercent: NewPlanUnitWithPercentPrice): T + + fun visitMatrixWithAllocation( + matrixWithAllocation: NewPlanMatrixWithAllocationPrice + ): T + + fun visitTieredWithProration(tieredWithProration: TieredWithProration): T + + fun visitUnitWithProration(unitWithProration: NewPlanUnitWithProrationPrice): T + + fun visitGroupedAllocation(groupedAllocation: NewPlanGroupedAllocationPrice): T + + fun visitBulkWithProration(bulkWithProration: NewPlanBulkWithProrationPrice): T + + fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice + ): T + + fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice + ): T + + fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ): T + + fun visitMatrixWithDisplayName( + matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice + ): T + + fun visitGroupedTieredPackage( + groupedTieredPackage: NewPlanGroupedTieredPackagePrice + ): T + + fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice + ): T + + fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice + ): T + + fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: NewPlanScalableMatrixWithTieredPricingPrice + ): T + + fun visitCumulativeGroupedBulk( + cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice + ): T + + fun visitMinimum(minimum: NewPlanMinimumCompositePrice): T + + fun visitPercent(percent: Percent): T + + fun visitEventOutput(eventOutput: EventOutput): T + + /** + * Maps an unknown variant of [Price] to a value of type [T]. + * + * An instance of [Price] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is + * unaware of. + * + * @throws OrbInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw OrbInvalidDataException("Unknown Price: $json") + } + } + + internal class Deserializer : BaseDeserializer(Price::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Price { + val json = JsonValue.fromJsonNode(node) + val modelType = json.asObject()?.get("model_type")?.asString() + + when (modelType) { + "unit" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(unit = it, _json = json) + } ?: Price(_json = json) + } + "tiered" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(tiered = it, _json = json) + } ?: Price(_json = json) + } + "bulk" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(bulk = it, _json = json) + } ?: Price(_json = json) + } + "package" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(package_ = it, _json = json) } ?: Price(_json = json) + } + "matrix" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(matrix = it, _json = json) + } ?: Price(_json = json) + } + "threshold_total_amount" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(thresholdTotalAmount = it, _json = json) } + ?: Price(_json = json) + } + "tiered_package" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(tieredPackage = it, _json = json) } + ?: Price(_json = json) + } + "tiered_with_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(tieredWithMinimum = it, _json = json) } + ?: Price(_json = json) + } + "grouped_tiered" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(groupedTiered = it, _json = json) } + ?: Price(_json = json) + } + "tiered_package_with_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(tieredPackageWithMinimum = it, _json = json) } + ?: Price(_json = json) + } + "package_with_allocation" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(packageWithAllocation = it, _json = json) } + ?: Price(_json = json) + } + "unit_with_percent" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(unitWithPercent = it, _json = json) } + ?: Price(_json = json) + } + "matrix_with_allocation" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(matrixWithAllocation = it, _json = json) } + ?: Price(_json = json) + } + "tiered_with_proration" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(tieredWithProration = it, _json = json) } + ?: Price(_json = json) + } + "unit_with_proration" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(unitWithProration = it, _json = json) } + ?: Price(_json = json) + } + "grouped_allocation" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedAllocation = it, _json = json) } + ?: Price(_json = json) + } + "bulk_with_proration" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(bulkWithProration = it, _json = json) } + ?: Price(_json = json) + } + "grouped_with_prorated_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedWithProratedMinimum = it, _json = json) } + ?: Price(_json = json) + } + "grouped_with_metered_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedWithMeteredMinimum = it, _json = json) } + ?: Price(_json = json) + } + "grouped_with_min_max_thresholds" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedWithMinMaxThresholds = it, _json = json) } + ?: Price(_json = json) + } + "matrix_with_display_name" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(matrixWithDisplayName = it, _json = json) } + ?: Price(_json = json) + } + "grouped_tiered_package" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedTieredPackage = it, _json = json) } + ?: Price(_json = json) + } + "max_group_tiered_package" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(maxGroupTieredPackage = it, _json = json) } + ?: Price(_json = json) + } + "scalable_matrix_with_unit_pricing" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(scalableMatrixWithUnitPricing = it, _json = json) } + ?: Price(_json = json) + } + "scalable_matrix_with_tiered_pricing" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(scalableMatrixWithTieredPricing = it, _json = json) } + ?: Price(_json = json) + } + "cumulative_grouped_bulk" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(cumulativeGroupedBulk = it, _json = json) } + ?: Price(_json = json) + } + "minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(minimum = it, _json = json) } ?: Price(_json = json) + } + "percent" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(percent = it, _json = json) + } ?: Price(_json = json) + } + "event_output" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(eventOutput = it, _json = json) + } ?: Price(_json = json) + } + } + + return Price(_json = json) + } + } + + internal class Serializer : BaseSerializer(Price::class) { + + override fun serialize( + value: Price, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.unit != null -> generator.writeObject(value.unit) + value.tiered != null -> generator.writeObject(value.tiered) + value.bulk != null -> generator.writeObject(value.bulk) + value.package_ != null -> generator.writeObject(value.package_) + value.matrix != null -> generator.writeObject(value.matrix) + value.thresholdTotalAmount != null -> + generator.writeObject(value.thresholdTotalAmount) + value.tieredPackage != null -> generator.writeObject(value.tieredPackage) + value.tieredWithMinimum != null -> + generator.writeObject(value.tieredWithMinimum) + value.groupedTiered != null -> generator.writeObject(value.groupedTiered) + value.tieredPackageWithMinimum != null -> + generator.writeObject(value.tieredPackageWithMinimum) + value.packageWithAllocation != null -> + generator.writeObject(value.packageWithAllocation) + value.unitWithPercent != null -> + generator.writeObject(value.unitWithPercent) + value.matrixWithAllocation != null -> + generator.writeObject(value.matrixWithAllocation) + value.tieredWithProration != null -> + generator.writeObject(value.tieredWithProration) + value.unitWithProration != null -> + generator.writeObject(value.unitWithProration) + value.groupedAllocation != null -> + generator.writeObject(value.groupedAllocation) + value.bulkWithProration != null -> + generator.writeObject(value.bulkWithProration) + value.groupedWithProratedMinimum != null -> + generator.writeObject(value.groupedWithProratedMinimum) + value.groupedWithMeteredMinimum != null -> + generator.writeObject(value.groupedWithMeteredMinimum) + value.groupedWithMinMaxThresholds != null -> + generator.writeObject(value.groupedWithMinMaxThresholds) + value.matrixWithDisplayName != null -> + generator.writeObject(value.matrixWithDisplayName) + value.groupedTieredPackage != null -> + generator.writeObject(value.groupedTieredPackage) + value.maxGroupTieredPackage != null -> + generator.writeObject(value.maxGroupTieredPackage) + value.scalableMatrixWithUnitPricing != null -> + generator.writeObject(value.scalableMatrixWithUnitPricing) + value.scalableMatrixWithTieredPricing != null -> + generator.writeObject(value.scalableMatrixWithTieredPricing) + value.cumulativeGroupedBulk != null -> + generator.writeObject(value.cumulativeGroupedBulk) + value.minimum != null -> generator.writeObject(value.minimum) + value.percent != null -> generator.writeObject(value.percent) + value.eventOutput != null -> generator.writeObject(value.eventOutput) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Price") + } + } + } - fun groupedWithMeteredMinimum(): NewPlanGroupedWithMeteredMinimumPrice? = - groupedWithMeteredMinimum + class TieredWithProration + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val tieredWithProrationConfig: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { - fun groupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds? = - groupedWithMinMaxThresholds + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("tiered_with_proration_config") + @ExcludeMissing + tieredWithProrationConfig: JsonField = + JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + modelType, + name, + tieredWithProrationConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + mutableMapOf(), + ) - fun matrixWithDisplayName(): NewPlanMatrixWithDisplayNamePrice? = matrixWithDisplayName + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") - fun groupedTieredPackage(): NewPlanGroupedTieredPackagePrice? = groupedTieredPackage + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") - fun maxGroupTieredPackage(): NewPlanMaxGroupTieredPackagePrice? = maxGroupTieredPackage + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("tiered_with_proration") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType - fun scalableMatrixWithUnitPricing(): NewPlanScalableMatrixWithUnitPricingPrice? = - scalableMatrixWithUnitPricing + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") - fun scalableMatrixWithTieredPricing(): NewPlanScalableMatrixWithTieredPricingPrice? = - scalableMatrixWithTieredPricing + /** + * Configuration for tiered_with_proration pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun tieredWithProrationConfig(): TieredWithProrationConfig = + tieredWithProrationConfig.getRequired("tiered_with_proration_config") - fun cumulativeGroupedBulk(): NewPlanCumulativeGroupedBulkPrice? = cumulativeGroupedBulk + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = billableMetricId.getNullable("billable_metric_id") - fun minimum(): NewPlanMinimumCompositePrice? = minimum + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") - fun eventOutput(): EventOutput? = eventOutput + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") - fun isUnit(): Boolean = unit != null + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") - fun isTiered(): Boolean = tiered != null + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") - fun isBulk(): Boolean = bulk != null + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") - fun isPackage(): Boolean = package_ != null + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") - fun isMatrix(): Boolean = matrix != null + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") - fun isThresholdTotalAmount(): Boolean = thresholdTotalAmount != null + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") - fun isTieredPackage(): Boolean = tieredPackage != null + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + invoiceGroupingKey.getNullable("invoice_grouping_key") - fun isTieredWithMinimum(): Boolean = tieredWithMinimum != null + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - fun isGroupedTiered(): Boolean = groupedTiered != null + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") - fun isTieredPackageWithMinimum(): Boolean = tieredPackageWithMinimum != null + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") - fun isPackageWithAllocation(): Boolean = packageWithAllocation != null + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence - fun isUnitWithPercent(): Boolean = unitWithPercent != null + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - fun isMatrixWithAllocation(): Boolean = matrixWithAllocation != null + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - fun isTieredWithProration(): Boolean = tieredWithProration != null + /** + * Returns the raw JSON value of [tieredWithProrationConfig]. + * + * Unlike [tieredWithProrationConfig], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("tiered_with_proration_config") + @ExcludeMissing + fun _tieredWithProrationConfig(): JsonField = + tieredWithProrationConfig - fun isUnitWithProration(): Boolean = unitWithProration != null + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId - fun isGroupedAllocation(): Boolean = groupedAllocation != null + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance - fun isBulkWithProration(): Boolean = bulkWithProration != null + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration - fun isGroupedWithProratedMinimum(): Boolean = groupedWithProratedMinimum != null + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate - fun isGroupedWithMeteredMinimum(): Boolean = groupedWithMeteredMinimum != null + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig - fun isGroupedWithMinMaxThresholds(): Boolean = groupedWithMinMaxThresholds != null + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency - fun isMatrixWithDisplayName(): Boolean = matrixWithDisplayName != null + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration - fun isGroupedTieredPackage(): Boolean = groupedTieredPackage != null + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId - fun isMaxGroupTieredPackage(): Boolean = maxGroupTieredPackage != null + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - fun isScalableMatrixWithUnitPricing(): Boolean = scalableMatrixWithUnitPricing != null + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - fun isScalableMatrixWithTieredPricing(): Boolean = - scalableMatrixWithTieredPricing != null + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration - fun isCumulativeGroupedBulk(): Boolean = cumulativeGroupedBulk != null + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata - fun isMinimum(): Boolean = minimum != null + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId - fun isEventOutput(): Boolean = eventOutput != null + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - fun asUnit(): NewPlanUnitPrice = unit.getOrThrow("unit") + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - fun asTiered(): NewPlanTieredPrice = tiered.getOrThrow("tiered") + fun toBuilder() = Builder().from(this) - fun asBulk(): NewPlanBulkPrice = bulk.getOrThrow("bulk") + companion object { - fun asPackage(): NewPlanPackagePrice = package_.getOrThrow("package_") + /** + * Returns a mutable builder for constructing an instance of + * [TieredWithProration]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .name() + * .tieredWithProrationConfig() + * ``` + */ + fun builder() = Builder() + } - fun asMatrix(): NewPlanMatrixPrice = matrix.getOrThrow("matrix") + /** A builder for [TieredWithProration]. */ + class Builder internal constructor() { - fun asThresholdTotalAmount(): NewPlanThresholdTotalAmountPrice = - thresholdTotalAmount.getOrThrow("thresholdTotalAmount") + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonValue = JsonValue.from("tiered_with_proration") + private var name: JsonField? = null + private var tieredWithProrationConfig: JsonField? = + null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - fun asTieredPackage(): NewPlanTieredPackagePrice = - tieredPackage.getOrThrow("tieredPackage") + internal fun from(tieredWithProration: TieredWithProration) = apply { + cadence = tieredWithProration.cadence + itemId = tieredWithProration.itemId + modelType = tieredWithProration.modelType + name = tieredWithProration.name + tieredWithProrationConfig = tieredWithProration.tieredWithProrationConfig + billableMetricId = tieredWithProration.billableMetricId + billedInAdvance = tieredWithProration.billedInAdvance + billingCycleConfiguration = tieredWithProration.billingCycleConfiguration + conversionRate = tieredWithProration.conversionRate + conversionRateConfig = tieredWithProration.conversionRateConfig + currency = tieredWithProration.currency + dimensionalPriceConfiguration = + tieredWithProration.dimensionalPriceConfiguration + externalPriceId = tieredWithProration.externalPriceId + fixedPriceQuantity = tieredWithProration.fixedPriceQuantity + invoiceGroupingKey = tieredWithProration.invoiceGroupingKey + invoicingCycleConfiguration = + tieredWithProration.invoicingCycleConfiguration + metadata = tieredWithProration.metadata + referenceId = tieredWithProration.referenceId + additionalProperties = + tieredWithProration.additionalProperties.toMutableMap() + } - fun asTieredWithMinimum(): NewPlanTieredWithMinimumPrice = - tieredWithMinimum.getOrThrow("tieredWithMinimum") + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - fun asGroupedTiered(): NewPlanGroupedTieredPrice = - groupedTiered.getOrThrow("groupedTiered") + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - fun asTieredPackageWithMinimum(): NewPlanTieredPackageWithMinimumPrice = - tieredPackageWithMinimum.getOrThrow("tieredPackageWithMinimum") + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - fun asPackageWithAllocation(): NewPlanPackageWithAllocationPrice = - packageWithAllocation.getOrThrow("packageWithAllocation") + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun asUnitWithPercent(): NewPlanUnitWithPercentPrice = - unitWithPercent.getOrThrow("unitWithPercent") + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("tiered_with_proration") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } - fun asMatrixWithAllocation(): NewPlanMatrixWithAllocationPrice = - matrixWithAllocation.getOrThrow("matrixWithAllocation") + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) - fun asTieredWithProration(): TieredWithProration = - tieredWithProration.getOrThrow("tieredWithProration") + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } - fun asUnitWithProration(): NewPlanUnitWithProrationPrice = - unitWithProration.getOrThrow("unitWithProration") + /** Configuration for tiered_with_proration pricing */ + fun tieredWithProrationConfig( + tieredWithProrationConfig: TieredWithProrationConfig + ) = tieredWithProrationConfig(JsonField.of(tieredWithProrationConfig)) - fun asGroupedAllocation(): NewPlanGroupedAllocationPrice = - groupedAllocation.getOrThrow("groupedAllocation") + /** + * Sets [Builder.tieredWithProrationConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.tieredWithProrationConfig] with a well-typed + * [TieredWithProrationConfig] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun tieredWithProrationConfig( + tieredWithProrationConfig: JsonField + ) = apply { this.tieredWithProrationConfig = tieredWithProrationConfig } - fun asBulkWithProration(): NewPlanBulkWithProrationPrice = - bulkWithProration.getOrThrow("bulkWithProration") + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) - fun asGroupedWithProratedMinimum(): NewPlanGroupedWithProratedMinimumPrice = - groupedWithProratedMinimum.getOrThrow("groupedWithProratedMinimum") + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } - fun asGroupedWithMeteredMinimum(): NewPlanGroupedWithMeteredMinimumPrice = - groupedWithMeteredMinimum.getOrThrow("groupedWithMeteredMinimum") + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) - fun asGroupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds = - groupedWithMinMaxThresholds.getOrThrow("groupedWithMinMaxThresholds") + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) - fun asMatrixWithDisplayName(): NewPlanMatrixWithDisplayNamePrice = - matrixWithDisplayName.getOrThrow("matrixWithDisplayName") + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } - fun asGroupedTieredPackage(): NewPlanGroupedTieredPackagePrice = - groupedTieredPackage.getOrThrow("groupedTieredPackage") + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - fun asMaxGroupTieredPackage(): NewPlanMaxGroupTieredPackagePrice = - maxGroupTieredPackage.getOrThrow("maxGroupTieredPackage") + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } - fun asScalableMatrixWithUnitPricing(): NewPlanScalableMatrixWithUnitPricingPrice = - scalableMatrixWithUnitPricing.getOrThrow("scalableMatrixWithUnitPricing") + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) - fun asScalableMatrixWithTieredPricing(): NewPlanScalableMatrixWithTieredPricingPrice = - scalableMatrixWithTieredPricing.getOrThrow("scalableMatrixWithTieredPricing") + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) - fun asCumulativeGroupedBulk(): NewPlanCumulativeGroupedBulkPrice = - cumulativeGroupedBulk.getOrThrow("cumulativeGroupedBulk") + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } - fun asMinimum(): NewPlanMinimumCompositePrice = minimum.getOrThrow("minimum") + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) - fun asEventOutput(): EventOutput = eventOutput.getOrThrow("eventOutput") + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } - fun _json(): JsonValue? = _json + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - bulk != null -> visitor.visitBulk(bulk) - package_ != null -> visitor.visitPackage(package_) - matrix != null -> visitor.visitMatrix(matrix) - thresholdTotalAmount != null -> - visitor.visitThresholdTotalAmount(thresholdTotalAmount) - tieredPackage != null -> visitor.visitTieredPackage(tieredPackage) - tieredWithMinimum != null -> visitor.visitTieredWithMinimum(tieredWithMinimum) - groupedTiered != null -> visitor.visitGroupedTiered(groupedTiered) - tieredPackageWithMinimum != null -> - visitor.visitTieredPackageWithMinimum(tieredPackageWithMinimum) - packageWithAllocation != null -> - visitor.visitPackageWithAllocation(packageWithAllocation) - unitWithPercent != null -> visitor.visitUnitWithPercent(unitWithPercent) - matrixWithAllocation != null -> - visitor.visitMatrixWithAllocation(matrixWithAllocation) - tieredWithProration != null -> - visitor.visitTieredWithProration(tieredWithProration) - unitWithProration != null -> visitor.visitUnitWithProration(unitWithProration) - groupedAllocation != null -> visitor.visitGroupedAllocation(groupedAllocation) - bulkWithProration != null -> visitor.visitBulkWithProration(bulkWithProration) - groupedWithProratedMinimum != null -> - visitor.visitGroupedWithProratedMinimum(groupedWithProratedMinimum) - groupedWithMeteredMinimum != null -> - visitor.visitGroupedWithMeteredMinimum(groupedWithMeteredMinimum) - groupedWithMinMaxThresholds != null -> - visitor.visitGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds) - matrixWithDisplayName != null -> - visitor.visitMatrixWithDisplayName(matrixWithDisplayName) - groupedTieredPackage != null -> - visitor.visitGroupedTieredPackage(groupedTieredPackage) - maxGroupTieredPackage != null -> - visitor.visitMaxGroupTieredPackage(maxGroupTieredPackage) - scalableMatrixWithUnitPricing != null -> - visitor.visitScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing) - scalableMatrixWithTieredPricing != null -> - visitor.visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() ) - cumulativeGroupedBulk != null -> - visitor.visitCumulativeGroupedBulk(cumulativeGroupedBulk) - minimum != null -> visitor.visitMinimum(minimum) - eventOutput != null -> visitor.visitEventOutput(eventOutput) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - fun validate(): Price = apply { - if (validated) { - return@apply - } + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) - accept( - object : Visitor { - override fun visitUnit(unit: NewPlanUnitPrice) { - unit.validate() - } + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) - override fun visitTiered(tiered: NewPlanTieredPrice) { - tiered.validate() - } + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) - override fun visitBulk(bulk: NewPlanBulkPrice) { - bulk.validate() - } + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } - override fun visitPackage(package_: NewPlanPackagePrice) { - package_.validate() - } + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) - override fun visitMatrix(matrix: NewPlanMatrixPrice) { - matrix.validate() - } + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } - override fun visitThresholdTotalAmount( - thresholdTotalAmount: NewPlanThresholdTotalAmountPrice - ) { - thresholdTotalAmount.validate() - } + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) - override fun visitTieredPackage(tieredPackage: NewPlanTieredPackagePrice) { - tieredPackage.validate() - } + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } - override fun visitTieredWithMinimum( - tieredWithMinimum: NewPlanTieredWithMinimumPrice - ) { - tieredWithMinimum.validate() - } + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) - override fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) { - groupedTiered.validate() - } + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) - override fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice - ) { - tieredPackageWithMinimum.validate() - } + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } - override fun visitPackageWithAllocation( - packageWithAllocation: NewPlanPackageWithAllocationPrice - ) { - packageWithAllocation.validate() - } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) - override fun visitUnitWithPercent( - unitWithPercent: NewPlanUnitWithPercentPrice - ) { - unitWithPercent.validate() - } + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } - override fun visitMatrixWithAllocation( - matrixWithAllocation: NewPlanMatrixWithAllocationPrice - ) { - matrixWithAllocation.validate() - } + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) - override fun visitTieredWithProration( - tieredWithProration: TieredWithProration - ) { - tieredWithProration.validate() - } + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - override fun visitUnitWithProration( - unitWithProration: NewPlanUnitWithProrationPrice - ) { - unitWithProration.validate() - } + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - override fun visitGroupedAllocation( - groupedAllocation: NewPlanGroupedAllocationPrice - ) { - groupedAllocation.validate() - } + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - override fun visitBulkWithProration( - bulkWithProration: NewPlanBulkWithProrationPrice - ) { - bulkWithProration.validate() - } + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) - override fun visitGroupedWithProratedMinimum( - groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice - ) { - groupedWithProratedMinimum.validate() - } + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } - override fun visitGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice - ) { - groupedWithMeteredMinimum.validate() - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - override fun visitGroupedWithMinMaxThresholds( - groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds - ) { - groupedWithMinMaxThresholds.validate() - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - override fun visitMatrixWithDisplayName( - matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice - ) { - matrixWithDisplayName.validate() + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) } - override fun visitGroupedTieredPackage( - groupedTieredPackage: NewPlanGroupedTieredPackagePrice - ) { - groupedTieredPackage.validate() - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - override fun visitMaxGroupTieredPackage( - maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice - ) { - maxGroupTieredPackage.validate() - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - override fun visitScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice - ) { - scalableMatrixWithUnitPricing.validate() - } + /** + * Returns an immutable instance of [TieredWithProration]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .name() + * .tieredWithProrationConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TieredWithProration = + TieredWithProration( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + modelType, + checkRequired("name", name), + checkRequired("tieredWithProrationConfig", tieredWithProrationConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } - override fun visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: - NewPlanScalableMatrixWithTieredPricingPrice - ) { - scalableMatrixWithTieredPricing.validate() - } + private var validated: Boolean = false - override fun visitCumulativeGroupedBulk( - cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice - ) { - cumulativeGroupedBulk.validate() - } + fun validate(): TieredWithProration = apply { + if (validated) { + return@apply + } - override fun visitMinimum(minimum: NewPlanMinimumCompositePrice) { - minimum.validate() + cadence().validate() + itemId() + _modelType().let { + if (it != JsonValue.from("tiered_with_proration")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") } + } + name() + tieredWithProrationConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + metadata()?.validate() + referenceId() + validated = true + } - override fun visitEventOutput(eventOutput: EventOutput) { - eventOutput.validate() - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false } - ) - validated = true - } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + modelType.let { + if (it == JsonValue.from("tiered_with_proration")) 1 else 0 + } + + (if (name.asKnown() == null) 0 else 1) + + (tieredWithProrationConfig.asKnown()?.validity() ?: 0) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: NewPlanUnitPrice) = unit.validity() + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { - override fun visitTiered(tiered: NewPlanTieredPrice) = tiered.validity() + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value - override fun visitBulk(bulk: NewPlanBulkPrice) = bulk.validity() + companion object { - override fun visitPackage(package_: NewPlanPackagePrice) = - package_.validity() + val ANNUAL = of("annual") - override fun visitMatrix(matrix: NewPlanMatrixPrice) = matrix.validity() + val SEMI_ANNUAL = of("semi_annual") - override fun visitThresholdTotalAmount( - thresholdTotalAmount: NewPlanThresholdTotalAmountPrice - ) = thresholdTotalAmount.validity() + val MONTHLY = of("monthly") - override fun visitTieredPackage(tieredPackage: NewPlanTieredPackagePrice) = - tieredPackage.validity() + val QUARTERLY = of("quarterly") - override fun visitTieredWithMinimum( - tieredWithMinimum: NewPlanTieredWithMinimumPrice - ) = tieredWithMinimum.validity() + val ONE_TIME = of("one_time") - override fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) = - groupedTiered.validity() + val CUSTOM = of("custom") - override fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice - ) = tieredPackageWithMinimum.validity() + fun of(value: String) = Cadence(JsonField.of(value)) + } - override fun visitPackageWithAllocation( - packageWithAllocation: NewPlanPackageWithAllocationPrice - ) = packageWithAllocation.validity() + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } - override fun visitUnitWithPercent( - unitWithPercent: NewPlanUnitWithPercentPrice - ) = unitWithPercent.validity() + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } - override fun visitMatrixWithAllocation( - matrixWithAllocation: NewPlanMatrixWithAllocationPrice - ) = matrixWithAllocation.validity() + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } - override fun visitTieredWithProration( - tieredWithProration: TieredWithProration - ) = tieredWithProration.validity() + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } - override fun visitUnitWithProration( - unitWithProration: NewPlanUnitWithProrationPrice - ) = unitWithProration.validity() + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") - override fun visitGroupedAllocation( - groupedAllocation: NewPlanGroupedAllocationPrice - ) = groupedAllocation.validity() + private var validated: Boolean = false - override fun visitBulkWithProration( - bulkWithProration: NewPlanBulkWithProrationPrice - ) = bulkWithProration.validity() + fun validate(): Cadence = apply { + if (validated) { + return@apply + } - override fun visitGroupedWithProratedMinimum( - groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice - ) = groupedWithProratedMinimum.validity() + known() + validated = true + } - override fun visitGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice - ) = groupedWithMeteredMinimum.validity() + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - override fun visitGroupedWithMinMaxThresholds( - groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds - ) = groupedWithMinMaxThresholds.validity() + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - override fun visitMatrixWithDisplayName( - matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice - ) = matrixWithDisplayName.validity() + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - override fun visitGroupedTieredPackage( - groupedTieredPackage: NewPlanGroupedTieredPackagePrice - ) = groupedTieredPackage.validity() + return other is Cadence && value == other.value + } - override fun visitMaxGroupTieredPackage( - maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice - ) = maxGroupTieredPackage.validity() + override fun hashCode() = value.hashCode() - override fun visitScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice - ) = scalableMatrixWithUnitPricing.validity() + override fun toString() = value.toString() + } - override fun visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: - NewPlanScalableMatrixWithTieredPricingPrice - ) = scalableMatrixWithTieredPricing.validity() + /** Configuration for tiered_with_proration pricing */ + class TieredWithProrationConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val tiers: JsonField>, + private val additionalProperties: MutableMap, + ) { - override fun visitCumulativeGroupedBulk( - cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice - ) = cumulativeGroupedBulk.validity() + @JsonCreator + private constructor( + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of() + ) : this(tiers, mutableMapOf()) - override fun visitMinimum(minimum: NewPlanMinimumCompositePrice) = - minimum.validity() + /** + * Tiers for rating based on total usage quantities into the specified tier with + * proration + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun tiers(): List = tiers.getRequired("tiers") - override fun visitEventOutput(eventOutput: EventOutput) = - eventOutput.validity() + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers - override fun unknown(json: JsonValue?) = 0 + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - return other is Price && - unit == other.unit && - tiered == other.tiered && - bulk == other.bulk && - package_ == other.package_ && - matrix == other.matrix && - thresholdTotalAmount == other.thresholdTotalAmount && - tieredPackage == other.tieredPackage && - tieredWithMinimum == other.tieredWithMinimum && - groupedTiered == other.groupedTiered && - tieredPackageWithMinimum == other.tieredPackageWithMinimum && - packageWithAllocation == other.packageWithAllocation && - unitWithPercent == other.unitWithPercent && - matrixWithAllocation == other.matrixWithAllocation && - tieredWithProration == other.tieredWithProration && - unitWithProration == other.unitWithProration && - groupedAllocation == other.groupedAllocation && - bulkWithProration == other.bulkWithProration && - groupedWithProratedMinimum == other.groupedWithProratedMinimum && - groupedWithMeteredMinimum == other.groupedWithMeteredMinimum && - groupedWithMinMaxThresholds == other.groupedWithMinMaxThresholds && - matrixWithDisplayName == other.matrixWithDisplayName && - groupedTieredPackage == other.groupedTieredPackage && - maxGroupTieredPackage == other.maxGroupTieredPackage && - scalableMatrixWithUnitPricing == other.scalableMatrixWithUnitPricing && - scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && - cumulativeGroupedBulk == other.cumulativeGroupedBulk && - minimum == other.minimum && - eventOutput == other.eventOutput - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - override fun hashCode(): Int = - Objects.hash( - unit, - tiered, - bulk, - package_, - matrix, - thresholdTotalAmount, - tieredPackage, - tieredWithMinimum, - groupedTiered, - tieredPackageWithMinimum, - packageWithAllocation, - unitWithPercent, - matrixWithAllocation, - tieredWithProration, - unitWithProration, - groupedAllocation, - bulkWithProration, - groupedWithProratedMinimum, - groupedWithMeteredMinimum, - groupedWithMinMaxThresholds, - matrixWithDisplayName, - groupedTieredPackage, - maxGroupTieredPackage, - scalableMatrixWithUnitPricing, - scalableMatrixWithTieredPricing, - cumulativeGroupedBulk, - minimum, - eventOutput, - ) + fun toBuilder() = Builder().from(this) - override fun toString(): String = - when { - unit != null -> "Price{unit=$unit}" - tiered != null -> "Price{tiered=$tiered}" - bulk != null -> "Price{bulk=$bulk}" - package_ != null -> "Price{package_=$package_}" - matrix != null -> "Price{matrix=$matrix}" - thresholdTotalAmount != null -> - "Price{thresholdTotalAmount=$thresholdTotalAmount}" - tieredPackage != null -> "Price{tieredPackage=$tieredPackage}" - tieredWithMinimum != null -> "Price{tieredWithMinimum=$tieredWithMinimum}" - groupedTiered != null -> "Price{groupedTiered=$groupedTiered}" - tieredPackageWithMinimum != null -> - "Price{tieredPackageWithMinimum=$tieredPackageWithMinimum}" - packageWithAllocation != null -> - "Price{packageWithAllocation=$packageWithAllocation}" - unitWithPercent != null -> "Price{unitWithPercent=$unitWithPercent}" - matrixWithAllocation != null -> - "Price{matrixWithAllocation=$matrixWithAllocation}" - tieredWithProration != null -> "Price{tieredWithProration=$tieredWithProration}" - unitWithProration != null -> "Price{unitWithProration=$unitWithProration}" - groupedAllocation != null -> "Price{groupedAllocation=$groupedAllocation}" - bulkWithProration != null -> "Price{bulkWithProration=$bulkWithProration}" - groupedWithProratedMinimum != null -> - "Price{groupedWithProratedMinimum=$groupedWithProratedMinimum}" - groupedWithMeteredMinimum != null -> - "Price{groupedWithMeteredMinimum=$groupedWithMeteredMinimum}" - groupedWithMinMaxThresholds != null -> - "Price{groupedWithMinMaxThresholds=$groupedWithMinMaxThresholds}" - matrixWithDisplayName != null -> - "Price{matrixWithDisplayName=$matrixWithDisplayName}" - groupedTieredPackage != null -> - "Price{groupedTieredPackage=$groupedTieredPackage}" - maxGroupTieredPackage != null -> - "Price{maxGroupTieredPackage=$maxGroupTieredPackage}" - scalableMatrixWithUnitPricing != null -> - "Price{scalableMatrixWithUnitPricing=$scalableMatrixWithUnitPricing}" - scalableMatrixWithTieredPricing != null -> - "Price{scalableMatrixWithTieredPricing=$scalableMatrixWithTieredPricing}" - cumulativeGroupedBulk != null -> - "Price{cumulativeGroupedBulk=$cumulativeGroupedBulk}" - minimum != null -> "Price{minimum=$minimum}" - eventOutput != null -> "Price{eventOutput=$eventOutput}" - _json != null -> "Price{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Price") - } + companion object { - companion object { + /** + * Returns a mutable builder for constructing an instance of + * [TieredWithProrationConfig]. + * + * The following fields are required: + * ```kotlin + * .tiers() + * ``` + */ + fun builder() = Builder() + } - fun ofUnit(unit: NewPlanUnitPrice) = Price(unit = unit) + /** A builder for [TieredWithProrationConfig]. */ + class Builder internal constructor() { - fun ofTiered(tiered: NewPlanTieredPrice) = Price(tiered = tiered) + private var tiers: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() - fun ofBulk(bulk: NewPlanBulkPrice) = Price(bulk = bulk) + internal fun from(tieredWithProrationConfig: TieredWithProrationConfig) = + apply { + tiers = tieredWithProrationConfig.tiers.map { it.toMutableList() } + additionalProperties = + tieredWithProrationConfig.additionalProperties.toMutableMap() + } - fun ofPackage(package_: NewPlanPackagePrice) = Price(package_ = package_) + /** + * Tiers for rating based on total usage quantities into the specified tier + * with proration + */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) - fun ofMatrix(matrix: NewPlanMatrixPrice) = Price(matrix = matrix) + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } - fun ofThresholdTotalAmount(thresholdTotalAmount: NewPlanThresholdTotalAmountPrice) = - Price(thresholdTotalAmount = thresholdTotalAmount) + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } - fun ofTieredPackage(tieredPackage: NewPlanTieredPackagePrice) = - Price(tieredPackage = tieredPackage) + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun ofTieredWithMinimum(tieredWithMinimum: NewPlanTieredWithMinimumPrice) = - Price(tieredWithMinimum = tieredWithMinimum) + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun ofGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) = - Price(groupedTiered = groupedTiered) + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun ofTieredPackageWithMinimum( - tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice - ) = Price(tieredPackageWithMinimum = tieredPackageWithMinimum) + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun ofPackageWithAllocation( - packageWithAllocation: NewPlanPackageWithAllocationPrice - ) = Price(packageWithAllocation = packageWithAllocation) + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - fun ofUnitWithPercent(unitWithPercent: NewPlanUnitWithPercentPrice) = - Price(unitWithPercent = unitWithPercent) + /** + * Returns an immutable instance of [TieredWithProrationConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TieredWithProrationConfig = + TieredWithProrationConfig( + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } - fun ofMatrixWithAllocation(matrixWithAllocation: NewPlanMatrixWithAllocationPrice) = - Price(matrixWithAllocation = matrixWithAllocation) + private var validated: Boolean = false - fun ofTieredWithProration(tieredWithProration: TieredWithProration) = - Price(tieredWithProration = tieredWithProration) + fun validate(): TieredWithProrationConfig = apply { + if (validated) { + return@apply + } - fun ofUnitWithProration(unitWithProration: NewPlanUnitWithProrationPrice) = - Price(unitWithProration = unitWithProration) + tiers().forEach { it.validate() } + validated = true + } - fun ofGroupedAllocation(groupedAllocation: NewPlanGroupedAllocationPrice) = - Price(groupedAllocation = groupedAllocation) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (tiers.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single tiered with proration tier */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val tierLowerBound: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(tierLowerBound, unitAmount, mutableMapOf()) + + /** + * Inclusive tier starting value + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun tierLowerBound(): String = + tierLowerBound.getRequired("tier_lower_bound") + + /** + * Amount per unit + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") - fun ofBulkWithProration(bulkWithProration: NewPlanBulkWithProrationPrice) = - Price(bulkWithProration = bulkWithProration) + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound - fun ofGroupedWithProratedMinimum( - groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice - ) = Price(groupedWithProratedMinimum = groupedWithProratedMinimum) + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount - fun ofGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice - ) = Price(groupedWithMeteredMinimum = groupedWithMeteredMinimum) + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - fun ofGroupedWithMinMaxThresholds( - groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds - ) = Price(groupedWithMinMaxThresholds = groupedWithMinMaxThresholds) + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - fun ofMatrixWithDisplayName( - matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice - ) = Price(matrixWithDisplayName = matrixWithDisplayName) + fun toBuilder() = Builder().from(this) - fun ofGroupedTieredPackage(groupedTieredPackage: NewPlanGroupedTieredPackagePrice) = - Price(groupedTieredPackage = groupedTieredPackage) + companion object { - fun ofMaxGroupTieredPackage( - maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice - ) = Price(maxGroupTieredPackage = maxGroupTieredPackage) + /** + * Returns a mutable builder for constructing an instance of [Tier]. + * + * The following fields are required: + * ```kotlin + * .tierLowerBound() + * .unitAmount() + * ``` + */ + fun builder() = Builder() + } - fun ofScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice - ) = Price(scalableMatrixWithUnitPricing = scalableMatrixWithUnitPricing) + /** A builder for [Tier]. */ + class Builder internal constructor() { - fun ofScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: NewPlanScalableMatrixWithTieredPricingPrice - ) = Price(scalableMatrixWithTieredPricing = scalableMatrixWithTieredPricing) + private var tierLowerBound: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() - fun ofCumulativeGroupedBulk( - cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice - ) = Price(cumulativeGroupedBulk = cumulativeGroupedBulk) + internal fun from(tier: Tier) = apply { + tierLowerBound = tier.tierLowerBound + unitAmount = tier.unitAmount + additionalProperties = tier.additionalProperties.toMutableMap() + } - fun ofMinimum(minimum: NewPlanMinimumCompositePrice) = Price(minimum = minimum) + /** Inclusive tier starting value */ + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) - fun ofEventOutput(eventOutput: EventOutput) = Price(eventOutput = eventOutput) - } + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } - /** - * An interface that defines how to map each variant of [Price] to a value of type [T]. - */ - interface Visitor { + /** Amount per unit */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) - fun visitUnit(unit: NewPlanUnitPrice): T + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } - fun visitTiered(tiered: NewPlanTieredPrice): T + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun visitBulk(bulk: NewPlanBulkPrice): T + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun visitPackage(package_: NewPlanPackagePrice): T + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun visitMatrix(matrix: NewPlanMatrixPrice): T + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun visitThresholdTotalAmount( - thresholdTotalAmount: NewPlanThresholdTotalAmountPrice - ): T + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - fun visitTieredPackage(tieredPackage: NewPlanTieredPackagePrice): T + /** + * Returns an immutable instance of [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```kotlin + * .tierLowerBound() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("tierLowerBound", tierLowerBound), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } - fun visitTieredWithMinimum(tieredWithMinimum: NewPlanTieredWithMinimumPrice): T + private var validated: Boolean = false - fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice): T + fun validate(): Tier = apply { + if (validated) { + return@apply + } - fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice - ): T + tierLowerBound() + unitAmount() + validated = true + } - fun visitPackageWithAllocation( - packageWithAllocation: NewPlanPackageWithAllocationPrice - ): T + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - fun visitUnitWithPercent(unitWithPercent: NewPlanUnitWithPercentPrice): T + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (tierLowerBound.asKnown() == null) 0 else 1) + + (if (unitAmount.asKnown() == null) 0 else 1) - fun visitMatrixWithAllocation( - matrixWithAllocation: NewPlanMatrixWithAllocationPrice - ): T + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun visitTieredWithProration(tieredWithProration: TieredWithProration): T + return other is Tier && + tierLowerBound == other.tierLowerBound && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } - fun visitUnitWithProration(unitWithProration: NewPlanUnitWithProrationPrice): T + private val hashCode: Int by lazy { + Objects.hash(tierLowerBound, unitAmount, additionalProperties) + } - fun visitGroupedAllocation(groupedAllocation: NewPlanGroupedAllocationPrice): T + override fun hashCode(): Int = hashCode - fun visitBulkWithProration(bulkWithProration: NewPlanBulkWithProrationPrice): T + override fun toString() = + "Tier{tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } - fun visitGroupedWithProratedMinimum( - groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice - ): T + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun visitGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice - ): T + return other is TieredWithProrationConfig && + tiers == other.tiers && + additionalProperties == other.additionalProperties + } - fun visitGroupedWithMinMaxThresholds( - groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds - ): T + private val hashCode: Int by lazy { Objects.hash(tiers, additionalProperties) } - fun visitMatrixWithDisplayName( - matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice - ): T + override fun hashCode(): Int = hashCode - fun visitGroupedTieredPackage( - groupedTieredPackage: NewPlanGroupedTieredPackagePrice - ): T + override fun toString() = + "TieredWithProrationConfig{tiers=$tiers, additionalProperties=$additionalProperties}" + } - fun visitMaxGroupTieredPackage( - maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice - ): T + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { - fun visitScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice - ): T + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties - fun visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: NewPlanScalableMatrixWithTieredPricingPrice - ): T + fun toBuilder() = Builder().from(this) - fun visitCumulativeGroupedBulk( - cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice - ): T + companion object { - fun visitMinimum(minimum: NewPlanMinimumCompositePrice): T + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } - fun visitEventOutput(eventOutput: EventOutput): T + /** A builder for [Metadata]. */ + class Builder internal constructor() { - /** - * Maps an unknown variant of [Price] to a value of type [T]. - * - * An instance of [Price] can contain an unknown variant if it was deserialized from - * data that doesn't match any known variant. For example, if the SDK is on an older - * version than the API, then the API may respond with new variants that the SDK is - * unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown Price: $json") - } - } + private var additionalProperties: MutableMap = + mutableMapOf() - internal class Deserializer : BaseDeserializer(Price::class) { + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } - override fun ObjectCodec.deserialize(node: JsonNode): Price { - val json = JsonValue.fromJsonNode(node) - val modelType = json.asObject()?.get("model_type")?.asString() + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - when (modelType) { - "unit" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(unit = it, _json = json) - } ?: Price(_json = json) - } - "tiered" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(tiered = it, _json = json) - } ?: Price(_json = json) - } - "bulk" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(bulk = it, _json = json) - } ?: Price(_json = json) - } - "package" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(package_ = it, _json = json) } ?: Price(_json = json) - } - "matrix" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(matrix = it, _json = json) - } ?: Price(_json = json) - } - "threshold_total_amount" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(thresholdTotalAmount = it, _json = json) } - ?: Price(_json = json) - } - "tiered_package" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(tieredPackage = it, _json = json) } - ?: Price(_json = json) - } - "tiered_with_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(tieredWithMinimum = it, _json = json) } - ?: Price(_json = json) - } - "grouped_tiered" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(groupedTiered = it, _json = json) } - ?: Price(_json = json) - } - "tiered_package_with_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(tieredPackageWithMinimum = it, _json = json) } - ?: Price(_json = json) - } - "package_with_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(packageWithAllocation = it, _json = json) } - ?: Price(_json = json) - } - "unit_with_percent" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(unitWithPercent = it, _json = json) } - ?: Price(_json = json) - } - "matrix_with_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(matrixWithAllocation = it, _json = json) } - ?: Price(_json = json) - } - "tiered_with_proration" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(tieredWithProration = it, _json = json) } - ?: Price(_json = json) - } - "unit_with_proration" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(unitWithProration = it, _json = json) } - ?: Price(_json = json) - } - "grouped_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedAllocation = it, _json = json) } - ?: Price(_json = json) - } - "bulk_with_proration" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(bulkWithProration = it, _json = json) } - ?: Price(_json = json) - } - "grouped_with_prorated_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedWithProratedMinimum = it, _json = json) } - ?: Price(_json = json) - } - "grouped_with_metered_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedWithMeteredMinimum = it, _json = json) } - ?: Price(_json = json) - } - "grouped_with_min_max_thresholds" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedWithMinMaxThresholds = it, _json = json) } - ?: Price(_json = json) - } - "matrix_with_display_name" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(matrixWithDisplayName = it, _json = json) } - ?: Price(_json = json) - } - "grouped_tiered_package" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedTieredPackage = it, _json = json) } - ?: Price(_json = json) + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) } - "max_group_tiered_package" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(maxGroupTieredPackage = it, _json = json) } - ?: Price(_json = json) + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) } - "scalable_matrix_with_unit_pricing" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(scalableMatrixWithUnitPricing = it, _json = json) } - ?: Price(_json = json) + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) } - "scalable_matrix_with_tiered_pricing" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(scalableMatrixWithTieredPricing = it, _json = json) } - ?: Price(_json = json) + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply } - "cumulative_grouped_bulk" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(cumulativeGroupedBulk = it, _json = json) } - ?: Price(_json = json) + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false } - "minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(minimum = it, _json = json) } ?: Price(_json = json) + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() } - "event_output" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(eventOutput = it, _json = json) - } ?: Price(_json = json) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } + + return other is Metadata && + additionalProperties == other.additionalProperties } - return Price(_json = json) - } - } + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - internal class Serializer : BaseSerializer(Price::class) { + override fun hashCode(): Int = hashCode - override fun serialize( - value: Price, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unit != null -> generator.writeObject(value.unit) - value.tiered != null -> generator.writeObject(value.tiered) - value.bulk != null -> generator.writeObject(value.bulk) - value.package_ != null -> generator.writeObject(value.package_) - value.matrix != null -> generator.writeObject(value.matrix) - value.thresholdTotalAmount != null -> - generator.writeObject(value.thresholdTotalAmount) - value.tieredPackage != null -> generator.writeObject(value.tieredPackage) - value.tieredWithMinimum != null -> - generator.writeObject(value.tieredWithMinimum) - value.groupedTiered != null -> generator.writeObject(value.groupedTiered) - value.tieredPackageWithMinimum != null -> - generator.writeObject(value.tieredPackageWithMinimum) - value.packageWithAllocation != null -> - generator.writeObject(value.packageWithAllocation) - value.unitWithPercent != null -> - generator.writeObject(value.unitWithPercent) - value.matrixWithAllocation != null -> - generator.writeObject(value.matrixWithAllocation) - value.tieredWithProration != null -> - generator.writeObject(value.tieredWithProration) - value.unitWithProration != null -> - generator.writeObject(value.unitWithProration) - value.groupedAllocation != null -> - generator.writeObject(value.groupedAllocation) - value.bulkWithProration != null -> - generator.writeObject(value.bulkWithProration) - value.groupedWithProratedMinimum != null -> - generator.writeObject(value.groupedWithProratedMinimum) - value.groupedWithMeteredMinimum != null -> - generator.writeObject(value.groupedWithMeteredMinimum) - value.groupedWithMinMaxThresholds != null -> - generator.writeObject(value.groupedWithMinMaxThresholds) - value.matrixWithDisplayName != null -> - generator.writeObject(value.matrixWithDisplayName) - value.groupedTieredPackage != null -> - generator.writeObject(value.groupedTieredPackage) - value.maxGroupTieredPackage != null -> - generator.writeObject(value.maxGroupTieredPackage) - value.scalableMatrixWithUnitPricing != null -> - generator.writeObject(value.scalableMatrixWithUnitPricing) - value.scalableMatrixWithTieredPricing != null -> - generator.writeObject(value.scalableMatrixWithTieredPricing) - value.cumulativeGroupedBulk != null -> - generator.writeObject(value.cumulativeGroupedBulk) - value.minimum != null -> generator.writeObject(value.minimum) - value.eventOutput != null -> generator.writeObject(value.eventOutput) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Price") + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } + + return other is TieredWithProration && + cadence == other.cadence && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + tieredWithProrationConfig == other.tieredWithProrationConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + modelType, + name, + tieredWithProrationConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties, + ) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TieredWithProration{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredWithProrationConfig=$tieredWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class TieredWithProration + class GroupedWithMinMaxThresholds @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, + private val groupedWithMinMaxThresholdsConfig: + JsonField, private val itemId: JsonField, private val modelType: JsonValue, private val name: JsonField, - private val tieredWithProrationConfig: JsonField, private val billableMetricId: JsonField, private val billedInAdvance: JsonField, private val billingCycleConfiguration: JsonField, @@ -10883,6 +14228,11 @@ private constructor( @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), + @JsonProperty("grouped_with_min_max_thresholds_config") + @ExcludeMissing + groupedWithMinMaxThresholdsConfig: + JsonField = + JsonMissing.of(), @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), @@ -10892,10 +14242,6 @@ private constructor( @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("tiered_with_proration_config") - @ExcludeMissing - tieredWithProrationConfig: JsonField = - JsonMissing.of(), @JsonProperty("billable_metric_id") @ExcludeMissing billableMetricId: JsonField = JsonMissing.of(), @@ -10940,10 +14286,10 @@ private constructor( referenceId: JsonField = JsonMissing.of(), ) : this( cadence, + groupedWithMinMaxThresholdsConfig, itemId, modelType, name, - tieredWithProrationConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -10969,6 +14315,18 @@ private constructor( */ fun cadence(): Cadence = cadence.getRequired("cadence") + /** + * Configuration for grouped_with_min_max_thresholds pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupedWithMinMaxThresholdsConfig(): GroupedWithMinMaxThresholdsConfig = + groupedWithMinMaxThresholdsConfig.getRequired( + "grouped_with_min_max_thresholds_config" + ) + /** * The id of the item the price will be associated with. * @@ -10983,7 +14341,7 @@ private constructor( * * Expected to always return the following: * ```kotlin - * JsonValue.from("tiered_with_proration") + * JsonValue.from("grouped_with_min_max_thresholds") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -11000,16 +14358,6 @@ private constructor( */ fun name(): String = name.getRequired("name") - /** - * Configuration for tiered_with_proration pricing - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun tieredWithProrationConfig(): TieredWithProrationConfig = - tieredWithProrationConfig.getRequired("tiered_with_proration_config") - /** * The id of the billable metric for the price. Only needed if the price is * usage-based. @@ -11139,6 +14487,17 @@ private constructor( @ExcludeMissing fun _cadence(): JsonField = cadence + /** + * Returns the raw JSON value of [groupedWithMinMaxThresholdsConfig]. + * + * Unlike [groupedWithMinMaxThresholdsConfig], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("grouped_with_min_max_thresholds_config") + @ExcludeMissing + fun _groupedWithMinMaxThresholdsConfig(): + JsonField = groupedWithMinMaxThresholdsConfig + /** * Returns the raw JSON value of [itemId]. * @@ -11155,17 +14514,6 @@ private constructor( */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - /** - * Returns the raw JSON value of [tieredWithProrationConfig]. - * - * Unlike [tieredWithProrationConfig], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("tiered_with_proration_config") - @ExcludeMissing - fun _tieredWithProrationConfig(): JsonField = - tieredWithProrationConfig - /** * Returns the raw JSON value of [billableMetricId]. * @@ -11315,28 +14663,30 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [TieredWithProration]. + * [GroupedWithMinMaxThresholds]. * * The following fields are required: * ```kotlin * .cadence() + * .groupedWithMinMaxThresholdsConfig() * .itemId() * .name() - * .tieredWithProrationConfig() * ``` */ fun builder() = Builder() } - /** A builder for [TieredWithProration]. */ + /** A builder for [GroupedWithMinMaxThresholds]. */ class Builder internal constructor() { private var cadence: JsonField? = null + private var groupedWithMinMaxThresholdsConfig: + JsonField? = + null private var itemId: JsonField? = null - private var modelType: JsonValue = JsonValue.from("tiered_with_proration") + private var modelType: JsonValue = + JsonValue.from("grouped_with_min_max_thresholds") private var name: JsonField? = null - private var tieredWithProrationConfig: JsonField? = - null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() private var billingCycleConfiguration: JsonField = @@ -11358,30 +14708,33 @@ private constructor( private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(tieredWithProration: TieredWithProration) = apply { - cadence = tieredWithProration.cadence - itemId = tieredWithProration.itemId - modelType = tieredWithProration.modelType - name = tieredWithProration.name - tieredWithProrationConfig = tieredWithProration.tieredWithProrationConfig - billableMetricId = tieredWithProration.billableMetricId - billedInAdvance = tieredWithProration.billedInAdvance - billingCycleConfiguration = tieredWithProration.billingCycleConfiguration - conversionRate = tieredWithProration.conversionRate - conversionRateConfig = tieredWithProration.conversionRateConfig - currency = tieredWithProration.currency - dimensionalPriceConfiguration = - tieredWithProration.dimensionalPriceConfiguration - externalPriceId = tieredWithProration.externalPriceId - fixedPriceQuantity = tieredWithProration.fixedPriceQuantity - invoiceGroupingKey = tieredWithProration.invoiceGroupingKey - invoicingCycleConfiguration = - tieredWithProration.invoicingCycleConfiguration - metadata = tieredWithProration.metadata - referenceId = tieredWithProration.referenceId - additionalProperties = - tieredWithProration.additionalProperties.toMutableMap() - } + internal fun from(groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds) = + apply { + cadence = groupedWithMinMaxThresholds.cadence + groupedWithMinMaxThresholdsConfig = + groupedWithMinMaxThresholds.groupedWithMinMaxThresholdsConfig + itemId = groupedWithMinMaxThresholds.itemId + modelType = groupedWithMinMaxThresholds.modelType + name = groupedWithMinMaxThresholds.name + billableMetricId = groupedWithMinMaxThresholds.billableMetricId + billedInAdvance = groupedWithMinMaxThresholds.billedInAdvance + billingCycleConfiguration = + groupedWithMinMaxThresholds.billingCycleConfiguration + conversionRate = groupedWithMinMaxThresholds.conversionRate + conversionRateConfig = groupedWithMinMaxThresholds.conversionRateConfig + currency = groupedWithMinMaxThresholds.currency + dimensionalPriceConfiguration = + groupedWithMinMaxThresholds.dimensionalPriceConfiguration + externalPriceId = groupedWithMinMaxThresholds.externalPriceId + fixedPriceQuantity = groupedWithMinMaxThresholds.fixedPriceQuantity + invoiceGroupingKey = groupedWithMinMaxThresholds.invoiceGroupingKey + invoicingCycleConfiguration = + groupedWithMinMaxThresholds.invoicingCycleConfiguration + metadata = groupedWithMinMaxThresholds.metadata + referenceId = groupedWithMinMaxThresholds.referenceId + additionalProperties = + groupedWithMinMaxThresholds.additionalProperties.toMutableMap() + } /** The cadence to bill for this price on. */ fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) @@ -11395,6 +14748,29 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + /** Configuration for grouped_with_min_max_thresholds pricing */ + fun groupedWithMinMaxThresholdsConfig( + groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + ) = + groupedWithMinMaxThresholdsConfig( + JsonField.of(groupedWithMinMaxThresholdsConfig) + ) + + /** + * Sets [Builder.groupedWithMinMaxThresholdsConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.groupedWithMinMaxThresholdsConfig] with a + * well-typed [GroupedWithMinMaxThresholdsConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun groupedWithMinMaxThresholdsConfig( + groupedWithMinMaxThresholdsConfig: + JsonField + ) = apply { + this.groupedWithMinMaxThresholdsConfig = groupedWithMinMaxThresholdsConfig + } + /** The id of the item the price will be associated with. */ fun itemId(itemId: String) = itemId(JsonField.of(itemId)) @@ -11413,7 +14789,7 @@ private constructor( * It is usually unnecessary to call this method because the field defaults to * the following: * ```kotlin - * JsonValue.from("tiered_with_proration") + * JsonValue.from("grouped_with_min_max_thresholds") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -11433,22 +14809,6 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } - /** Configuration for tiered_with_proration pricing */ - fun tieredWithProrationConfig( - tieredWithProrationConfig: TieredWithProrationConfig - ) = tieredWithProrationConfig(JsonField.of(tieredWithProrationConfig)) - - /** - * Sets [Builder.tieredWithProrationConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.tieredWithProrationConfig] with a well-typed - * [TieredWithProrationConfig] value instead. This method is primarily for - * setting the field to an undocumented or not yet supported value. - */ - fun tieredWithProrationConfig( - tieredWithProrationConfig: JsonField - ) = apply { this.tieredWithProrationConfig = tieredWithProrationConfig } - /** * The id of the billable metric for the price. Only needed if the price is * usage-based. @@ -11778,27 +15138,30 @@ private constructor( } /** - * Returns an immutable instance of [TieredWithProration]. + * Returns an immutable instance of [GroupedWithMinMaxThresholds]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```kotlin * .cadence() + * .groupedWithMinMaxThresholdsConfig() * .itemId() * .name() - * .tieredWithProrationConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): TieredWithProration = - TieredWithProration( + fun build(): GroupedWithMinMaxThresholds = + GroupedWithMinMaxThresholds( checkRequired("cadence", cadence), + checkRequired( + "groupedWithMinMaxThresholdsConfig", + groupedWithMinMaxThresholdsConfig, + ), checkRequired("itemId", itemId), modelType, checkRequired("name", name), - checkRequired("tieredWithProrationConfig", tieredWithProrationConfig), billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -11818,20 +15181,20 @@ private constructor( private var validated: Boolean = false - fun validate(): TieredWithProration = apply { + fun validate(): GroupedWithMinMaxThresholds = apply { if (validated) { return@apply } cadence().validate() + groupedWithMinMaxThresholdsConfig().validate() itemId() _modelType().let { - if (it != JsonValue.from("tiered_with_proration")) { + if (it != JsonValue.from("grouped_with_min_max_thresholds")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } name() - tieredWithProrationConfig().validate() billableMetricId() billedInAdvance() billingCycleConfiguration()?.validate() @@ -11864,12 +15227,12 @@ private constructor( */ internal fun validity(): Int = (cadence.asKnown()?.validity() ?: 0) + + (groupedWithMinMaxThresholdsConfig.asKnown()?.validity() ?: 0) + (if (itemId.asKnown() == null) 0 else 1) + modelType.let { - if (it == JsonValue.from("tiered_with_proration")) 1 else 0 + if (it == JsonValue.from("grouped_with_min_max_thresholds")) 1 else 0 } + (if (name.asKnown() == null) 0 else 1) + - (tieredWithProrationConfig.asKnown()?.validity() ?: 0) + (if (billableMetricId.asKnown() == null) 0 else 1) + (if (billedInAdvance.asKnown() == null) 0 else 1) + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + @@ -12041,419 +15404,328 @@ private constructor( override fun toString() = value.toString() } - /** Configuration for tiered_with_proration pricing */ - class TieredWithProrationConfig + /** Configuration for grouped_with_min_max_thresholds pricing */ + class GroupedWithMinMaxThresholdsConfig @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val tiers: JsonField>, + private val groupingKey: JsonField, + private val maximumCharge: JsonField, + private val minimumCharge: JsonField, + private val perUnitRate: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("tiers") + @JsonProperty("grouping_key") @ExcludeMissing - tiers: JsonField> = JsonMissing.of() - ) : this(tiers, mutableMapOf()) + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("maximum_charge") + @ExcludeMissing + maximumCharge: JsonField = JsonMissing.of(), + @JsonProperty("minimum_charge") + @ExcludeMissing + minimumCharge: JsonField = JsonMissing.of(), + @JsonProperty("per_unit_rate") + @ExcludeMissing + perUnitRate: JsonField = JsonMissing.of(), + ) : this(groupingKey, maximumCharge, minimumCharge, perUnitRate, mutableMapOf()) /** - * Tiers for rating based on total usage quantities into the specified tier with - * proration + * The event property used to group before applying thresholds * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). */ - fun tiers(): List = tiers.getRequired("tiers") + fun groupingKey(): String = groupingKey.getRequired("grouping_key") /** - * Returns the raw JSON value of [tiers]. + * The maximum amount to charge each group * - * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected - * type. + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). */ - @JsonProperty("tiers") - @ExcludeMissing - fun _tiers(): JsonField> = tiers - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [TieredWithProrationConfig]. - * - * The following fields are required: - * ```kotlin - * .tiers() - * ``` - */ - fun builder() = Builder() - } - - /** A builder for [TieredWithProrationConfig]. */ - class Builder internal constructor() { + fun maximumCharge(): String = maximumCharge.getRequired("maximum_charge") - private var tiers: JsonField>? = null - private var additionalProperties: MutableMap = - mutableMapOf() + /** + * The minimum amount to charge each group, regardless of usage + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun minimumCharge(): String = minimumCharge.getRequired("minimum_charge") - internal fun from(tieredWithProrationConfig: TieredWithProrationConfig) = - apply { - tiers = tieredWithProrationConfig.tiers.map { it.toMutableList() } - additionalProperties = - tieredWithProrationConfig.additionalProperties.toMutableMap() - } + /** + * The base price charged per group + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun perUnitRate(): String = perUnitRate.getRequired("per_unit_rate") - /** - * Tiers for rating based on total usage quantities into the specified tier - * with proration - */ - fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey - /** - * Sets [Builder.tiers] to an arbitrary JSON value. - * - * You should usually call [Builder.tiers] with a well-typed `List` - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun tiers(tiers: JsonField>) = apply { - this.tiers = tiers.map { it.toMutableList() } - } + /** + * Returns the raw JSON value of [maximumCharge]. + * + * Unlike [maximumCharge], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("maximum_charge") + @ExcludeMissing + fun _maximumCharge(): JsonField = maximumCharge - /** - * Adds a single [Tier] to [tiers]. - * - * @throws IllegalStateException if the field was previously set to a - * non-list. - */ - fun addTier(tier: Tier) = apply { - tiers = - (tiers ?: JsonField.of(mutableListOf())).also { - checkKnown("tiers", it).add(tier) - } - } + /** + * Returns the raw JSON value of [minimumCharge]. + * + * Unlike [minimumCharge], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("minimum_charge") + @ExcludeMissing + fun _minimumCharge(): JsonField = minimumCharge - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * Returns the raw JSON value of [perUnitRate]. + * + * Unlike [perUnitRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("per_unit_rate") + @ExcludeMissing + fun _perUnitRate(): JsonField = perUnitRate - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun toBuilder() = Builder().from(this) - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + companion object { /** - * Returns an immutable instance of [TieredWithProrationConfig]. - * - * Further updates to this [Builder] will not mutate the returned instance. + * Returns a mutable builder for constructing an instance of + * [GroupedWithMinMaxThresholdsConfig]. * * The following fields are required: * ```kotlin - * .tiers() + * .groupingKey() + * .maximumCharge() + * .minimumCharge() + * .perUnitRate() * ``` - * - * @throws IllegalStateException if any required field is unset. */ - fun build(): TieredWithProrationConfig = - TieredWithProrationConfig( - checkRequired("tiers", tiers).map { it.toImmutable() }, - additionalProperties.toMutableMap(), - ) + fun builder() = Builder() } - private var validated: Boolean = false - - fun validate(): TieredWithProrationConfig = apply { - if (validated) { - return@apply - } + /** A builder for [GroupedWithMinMaxThresholdsConfig]. */ + class Builder internal constructor() { - tiers().forEach { it.validate() } - validated = true - } + private var groupingKey: JsonField? = null + private var maximumCharge: JsonField? = null + private var minimumCharge: JsonField? = null + private var perUnitRate: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false + internal fun from( + groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + ) = apply { + groupingKey = groupedWithMinMaxThresholdsConfig.groupingKey + maximumCharge = groupedWithMinMaxThresholdsConfig.maximumCharge + minimumCharge = groupedWithMinMaxThresholdsConfig.minimumCharge + perUnitRate = groupedWithMinMaxThresholdsConfig.perUnitRate + additionalProperties = + groupedWithMinMaxThresholdsConfig.additionalProperties + .toMutableMap() } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (tiers.asKnown()?.sumOf { it.validity().toInt() } ?: 0) - - /** Configuration for a single tiered with proration tier */ - class Tier - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val tierLowerBound: JsonField, - private val unitAmount: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("tier_lower_bound") - @ExcludeMissing - tierLowerBound: JsonField = JsonMissing.of(), - @JsonProperty("unit_amount") - @ExcludeMissing - unitAmount: JsonField = JsonMissing.of(), - ) : this(tierLowerBound, unitAmount, mutableMapOf()) - - /** - * Inclusive tier starting value - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type - * or is unexpectedly missing or null (e.g. if the server responded with - * an unexpected value). - */ - fun tierLowerBound(): String = - tierLowerBound.getRequired("tier_lower_bound") + /** The event property used to group before applying thresholds */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) /** - * Amount per unit + * Sets [Builder.groupingKey] to an arbitrary JSON value. * - * @throws OrbInvalidDataException if the JSON field has an unexpected type - * or is unexpectedly missing or null (e.g. if the server responded with - * an unexpected value). + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. */ - fun unitAmount(): String = unitAmount.getRequired("unit_amount") + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } - /** - * Returns the raw JSON value of [tierLowerBound]. - * - * Unlike [tierLowerBound], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("tier_lower_bound") - @ExcludeMissing - fun _tierLowerBound(): JsonField = tierLowerBound + /** The maximum amount to charge each group */ + fun maximumCharge(maximumCharge: String) = + maximumCharge(JsonField.of(maximumCharge)) /** - * Returns the raw JSON value of [unitAmount]. + * Sets [Builder.maximumCharge] to an arbitrary JSON value. * - * Unlike [unitAmount], this method doesn't throw if the JSON field has an - * unexpected type. + * You should usually call [Builder.maximumCharge] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. */ - @JsonProperty("unit_amount") - @ExcludeMissing - fun _unitAmount(): JsonField = unitAmount - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [Tier]. - * - * The following fields are required: - * ```kotlin - * .tierLowerBound() - * .unitAmount() - * ``` - */ - fun builder() = Builder() - } - - /** A builder for [Tier]. */ - class Builder internal constructor() { - - private var tierLowerBound: JsonField? = null - private var unitAmount: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - internal fun from(tier: Tier) = apply { - tierLowerBound = tier.tierLowerBound - unitAmount = tier.unitAmount - additionalProperties = tier.additionalProperties.toMutableMap() - } - - /** Inclusive tier starting value */ - fun tierLowerBound(tierLowerBound: String) = - tierLowerBound(JsonField.of(tierLowerBound)) - - /** - * Sets [Builder.tierLowerBound] to an arbitrary JSON value. - * - * You should usually call [Builder.tierLowerBound] with a well-typed - * [String] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun tierLowerBound(tierLowerBound: JsonField) = apply { - this.tierLowerBound = tierLowerBound - } - - /** Amount per unit */ - fun unitAmount(unitAmount: String) = - unitAmount(JsonField.of(unitAmount)) - - /** - * Sets [Builder.unitAmount] to an arbitrary JSON value. - * - * You should usually call [Builder.unitAmount] with a well-typed - * [String] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun unitAmount(unitAmount: JsonField) = apply { - this.unitAmount = unitAmount - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Tier]. - * - * Further updates to this [Builder] will not mutate the returned - * instance. - * - * The following fields are required: - * ```kotlin - * .tierLowerBound() - * .unitAmount() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Tier = - Tier( - checkRequired("tierLowerBound", tierLowerBound), - checkRequired("unitAmount", unitAmount), - additionalProperties.toMutableMap(), - ) + fun maximumCharge(maximumCharge: JsonField) = apply { + this.maximumCharge = maximumCharge } - private var validated: Boolean = false - - fun validate(): Tier = apply { - if (validated) { - return@apply - } + /** The minimum amount to charge each group, regardless of usage */ + fun minimumCharge(minimumCharge: String) = + minimumCharge(JsonField.of(minimumCharge)) - tierLowerBound() - unitAmount() - validated = true + /** + * Sets [Builder.minimumCharge] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumCharge] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun minimumCharge(minimumCharge: JsonField) = apply { + this.minimumCharge = minimumCharge } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** The base price charged per group */ + fun perUnitRate(perUnitRate: String) = + perUnitRate(JsonField.of(perUnitRate)) /** - * Returns a score indicating how many valid values are contained in this - * object recursively. + * Sets [Builder.perUnitRate] to an arbitrary JSON value. * - * Used for best match union deserialization. + * You should usually call [Builder.perUnitRate] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. */ - internal fun validity(): Int = - (if (tierLowerBound.asKnown() == null) 0 else 1) + - (if (unitAmount.asKnown() == null) 0 else 1) + fun perUnitRate(perUnitRate: JsonField) = apply { + this.perUnitRate = perUnitRate + } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) } - return other is Tier && - tierLowerBound == other.tierLowerBound && - unitAmount == other.unitAmount && - additionalProperties == other.additionalProperties + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) } - private val hashCode: Int by lazy { - Objects.hash(tierLowerBound, unitAmount, additionalProperties) + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) } - override fun hashCode(): Int = hashCode + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - override fun toString() = - "Tier{tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + /** + * Returns an immutable instance of [GroupedWithMinMaxThresholdsConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .maximumCharge() + * .minimumCharge() + * .perUnitRate() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedWithMinMaxThresholdsConfig = + GroupedWithMinMaxThresholdsConfig( + checkRequired("groupingKey", groupingKey), + checkRequired("maximumCharge", maximumCharge), + checkRequired("minimumCharge", minimumCharge), + checkRequired("perUnitRate", perUnitRate), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GroupedWithMinMaxThresholdsConfig = apply { + if (validated) { + return@apply + } + + groupingKey() + maximumCharge() + minimumCharge() + perUnitRate() + validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (groupingKey.asKnown() == null) 0 else 1) + + (if (maximumCharge.asKnown() == null) 0 else 1) + + (if (minimumCharge.asKnown() == null) 0 else 1) + + (if (perUnitRate.asKnown() == null) 0 else 1) + override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is TieredWithProrationConfig && - tiers == other.tiers && + return other is GroupedWithMinMaxThresholdsConfig && + groupingKey == other.groupingKey && + maximumCharge == other.maximumCharge && + minimumCharge == other.minimumCharge && + perUnitRate == other.perUnitRate && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(tiers, additionalProperties) } + private val hashCode: Int by lazy { + Objects.hash( + groupingKey, + maximumCharge, + minimumCharge, + perUnitRate, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode override fun toString() = - "TieredWithProrationConfig{tiers=$tiers, additionalProperties=$additionalProperties}" + "GroupedWithMinMaxThresholdsConfig{groupingKey=$groupingKey, maximumCharge=$maximumCharge, minimumCharge=$minimumCharge, perUnitRate=$perUnitRate, additionalProperties=$additionalProperties}" } /** @@ -12570,12 +15842,13 @@ private constructor( return true } - return other is TieredWithProration && + return other is GroupedWithMinMaxThresholds && cadence == other.cadence && + groupedWithMinMaxThresholdsConfig == + other.groupedWithMinMaxThresholdsConfig && itemId == other.itemId && modelType == other.modelType && name == other.name && - tieredWithProrationConfig == other.tieredWithProrationConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && @@ -12595,10 +15868,10 @@ private constructor( private val hashCode: Int by lazy { Objects.hash( cadence, + groupedWithMinMaxThresholdsConfig, itemId, modelType, name, - tieredWithProrationConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -12619,18 +15892,17 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "TieredWithProration{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredWithProrationConfig=$tieredWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "GroupedWithMinMaxThresholds{cadence=$cadence, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class GroupedWithMinMaxThresholds + class Percent @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, - private val groupedWithMinMaxThresholdsConfig: - JsonField, private val itemId: JsonField, private val modelType: JsonValue, private val name: JsonField, + private val percentConfig: JsonField, private val billableMetricId: JsonField, private val billedInAdvance: JsonField, private val billingCycleConfiguration: JsonField, @@ -12653,11 +15925,6 @@ private constructor( @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), - @JsonProperty("grouped_with_min_max_thresholds_config") - @ExcludeMissing - groupedWithMinMaxThresholdsConfig: - JsonField = - JsonMissing.of(), @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), @@ -12667,6 +15934,9 @@ private constructor( @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("percent_config") + @ExcludeMissing + percentConfig: JsonField = JsonMissing.of(), @JsonProperty("billable_metric_id") @ExcludeMissing billableMetricId: JsonField = JsonMissing.of(), @@ -12711,10 +15981,10 @@ private constructor( referenceId: JsonField = JsonMissing.of(), ) : this( cadence, - groupedWithMinMaxThresholdsConfig, itemId, modelType, name, + percentConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -12740,18 +16010,6 @@ private constructor( */ fun cadence(): Cadence = cadence.getRequired("cadence") - /** - * Configuration for grouped_with_min_max_thresholds pricing - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun groupedWithMinMaxThresholdsConfig(): GroupedWithMinMaxThresholdsConfig = - groupedWithMinMaxThresholdsConfig.getRequired( - "grouped_with_min_max_thresholds_config" - ) - /** * The id of the item the price will be associated with. * @@ -12766,7 +16024,7 @@ private constructor( * * Expected to always return the following: * ```kotlin - * JsonValue.from("grouped_with_min_max_thresholds") + * JsonValue.from("percent") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -12783,6 +16041,15 @@ private constructor( */ fun name(): String = name.getRequired("name") + /** + * Configuration for percent pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun percentConfig(): PercentConfig = percentConfig.getRequired("percent_config") + /** * The id of the billable metric for the price. Only needed if the price is * usage-based. @@ -12912,17 +16179,6 @@ private constructor( @ExcludeMissing fun _cadence(): JsonField = cadence - /** - * Returns the raw JSON value of [groupedWithMinMaxThresholdsConfig]. - * - * Unlike [groupedWithMinMaxThresholdsConfig], this method doesn't throw if the JSON - * field has an unexpected type. - */ - @JsonProperty("grouped_with_min_max_thresholds_config") - @ExcludeMissing - fun _groupedWithMinMaxThresholdsConfig(): - JsonField = groupedWithMinMaxThresholdsConfig - /** * Returns the raw JSON value of [itemId]. * @@ -12939,6 +16195,16 @@ private constructor( */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + /** + * Returns the raw JSON value of [percentConfig]. + * + * Unlike [percentConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("percent_config") + @ExcludeMissing + fun _percentConfig(): JsonField = percentConfig + /** * Returns the raw JSON value of [billableMetricId]. * @@ -13087,79 +16353,69 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [GroupedWithMinMaxThresholds]. + * Returns a mutable builder for constructing an instance of [Percent]. * * The following fields are required: * ```kotlin * .cadence() - * .groupedWithMinMaxThresholdsConfig() * .itemId() * .name() + * .percentConfig() * ``` */ fun builder() = Builder() } - /** A builder for [GroupedWithMinMaxThresholds]. */ + /** A builder for [Percent]. */ class Builder internal constructor() { private var cadence: JsonField? = null - private var groupedWithMinMaxThresholdsConfig: - JsonField? = - null private var itemId: JsonField? = null - private var modelType: JsonValue = - JsonValue.from("grouped_with_min_max_thresholds") + private var modelType: JsonValue = JsonValue.from("percent") private var name: JsonField? = null + private var percentConfig: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() private var billingCycleConfiguration: JsonField = JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var conversionRateConfig: JsonField = - JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var dimensionalPriceConfiguration: - JsonField = - JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: - JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var referenceId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds) = - apply { - cadence = groupedWithMinMaxThresholds.cadence - groupedWithMinMaxThresholdsConfig = - groupedWithMinMaxThresholds.groupedWithMinMaxThresholdsConfig - itemId = groupedWithMinMaxThresholds.itemId - modelType = groupedWithMinMaxThresholds.modelType - name = groupedWithMinMaxThresholds.name - billableMetricId = groupedWithMinMaxThresholds.billableMetricId - billedInAdvance = groupedWithMinMaxThresholds.billedInAdvance - billingCycleConfiguration = - groupedWithMinMaxThresholds.billingCycleConfiguration - conversionRate = groupedWithMinMaxThresholds.conversionRate - conversionRateConfig = groupedWithMinMaxThresholds.conversionRateConfig - currency = groupedWithMinMaxThresholds.currency - dimensionalPriceConfiguration = - groupedWithMinMaxThresholds.dimensionalPriceConfiguration - externalPriceId = groupedWithMinMaxThresholds.externalPriceId - fixedPriceQuantity = groupedWithMinMaxThresholds.fixedPriceQuantity - invoiceGroupingKey = groupedWithMinMaxThresholds.invoiceGroupingKey - invoicingCycleConfiguration = - groupedWithMinMaxThresholds.invoicingCycleConfiguration - metadata = groupedWithMinMaxThresholds.metadata - referenceId = groupedWithMinMaxThresholds.referenceId - additionalProperties = - groupedWithMinMaxThresholds.additionalProperties.toMutableMap() - } + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(percent: Percent) = apply { + cadence = percent.cadence + itemId = percent.itemId + modelType = percent.modelType + name = percent.name + percentConfig = percent.percentConfig + billableMetricId = percent.billableMetricId + billedInAdvance = percent.billedInAdvance + billingCycleConfiguration = percent.billingCycleConfiguration + conversionRate = percent.conversionRate + conversionRateConfig = percent.conversionRateConfig + currency = percent.currency + dimensionalPriceConfiguration = percent.dimensionalPriceConfiguration + externalPriceId = percent.externalPriceId + fixedPriceQuantity = percent.fixedPriceQuantity + invoiceGroupingKey = percent.invoiceGroupingKey + invoicingCycleConfiguration = percent.invoicingCycleConfiguration + metadata = percent.metadata + referenceId = percent.referenceId + additionalProperties = percent.additionalProperties.toMutableMap() + } /** The cadence to bill for this price on. */ fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) @@ -13173,29 +16429,6 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - /** Configuration for grouped_with_min_max_thresholds pricing */ - fun groupedWithMinMaxThresholdsConfig( - groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig - ) = - groupedWithMinMaxThresholdsConfig( - JsonField.of(groupedWithMinMaxThresholdsConfig) - ) - - /** - * Sets [Builder.groupedWithMinMaxThresholdsConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.groupedWithMinMaxThresholdsConfig] with a - * well-typed [GroupedWithMinMaxThresholdsConfig] value instead. This method is - * primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun groupedWithMinMaxThresholdsConfig( - groupedWithMinMaxThresholdsConfig: - JsonField - ) = apply { - this.groupedWithMinMaxThresholdsConfig = groupedWithMinMaxThresholdsConfig - } - /** The id of the item the price will be associated with. */ fun itemId(itemId: String) = itemId(JsonField.of(itemId)) @@ -13214,7 +16447,7 @@ private constructor( * It is usually unnecessary to call this method because the field defaults to * the following: * ```kotlin - * JsonValue.from("grouped_with_min_max_thresholds") + * JsonValue.from("percent") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -13234,6 +16467,21 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } + /** Configuration for percent pricing */ + fun percentConfig(percentConfig: PercentConfig) = + percentConfig(JsonField.of(percentConfig)) + + /** + * Sets [Builder.percentConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.percentConfig] with a well-typed + * [PercentConfig] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun percentConfig(percentConfig: JsonField) = apply { + this.percentConfig = percentConfig + } + /** * The id of the billable metric for the price. Only needed if the price is * usage-based. @@ -13563,30 +16811,27 @@ private constructor( } /** - * Returns an immutable instance of [GroupedWithMinMaxThresholds]. + * Returns an immutable instance of [Percent]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```kotlin * .cadence() - * .groupedWithMinMaxThresholdsConfig() * .itemId() * .name() + * .percentConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): GroupedWithMinMaxThresholds = - GroupedWithMinMaxThresholds( + fun build(): Percent = + Percent( checkRequired("cadence", cadence), - checkRequired( - "groupedWithMinMaxThresholdsConfig", - groupedWithMinMaxThresholdsConfig, - ), checkRequired("itemId", itemId), modelType, checkRequired("name", name), + checkRequired("percentConfig", percentConfig), billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -13606,20 +16851,20 @@ private constructor( private var validated: Boolean = false - fun validate(): GroupedWithMinMaxThresholds = apply { + fun validate(): Percent = apply { if (validated) { return@apply } cadence().validate() - groupedWithMinMaxThresholdsConfig().validate() itemId() _modelType().let { - if (it != JsonValue.from("grouped_with_min_max_thresholds")) { + if (it != JsonValue.from("percent")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } name() + percentConfig().validate() billableMetricId() billedInAdvance() billingCycleConfiguration()?.validate() @@ -13652,12 +16897,10 @@ private constructor( */ internal fun validity(): Int = (cadence.asKnown()?.validity() ?: 0) + - (groupedWithMinMaxThresholdsConfig.asKnown()?.validity() ?: 0) + (if (itemId.asKnown() == null) 0 else 1) + - modelType.let { - if (it == JsonValue.from("grouped_with_min_max_thresholds")) 1 else 0 - } + + modelType.let { if (it == JsonValue.from("percent")) 1 else 0 } + (if (name.asKnown() == null) 0 else 1) + + (percentConfig.asKnown()?.validity() ?: 0) + (if (billableMetricId.asKnown() == null) 0 else 1) + (if (billedInAdvance.asKnown() == null) 0 else 1) + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + @@ -13829,108 +17072,39 @@ private constructor( override fun toString() = value.toString() } - /** Configuration for grouped_with_min_max_thresholds pricing */ - class GroupedWithMinMaxThresholdsConfig + /** Configuration for percent pricing */ + class PercentConfig @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val groupingKey: JsonField, - private val maximumCharge: JsonField, - private val minimumCharge: JsonField, - private val perUnitRate: JsonField, + private val percent: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("grouping_key") - @ExcludeMissing - groupingKey: JsonField = JsonMissing.of(), - @JsonProperty("maximum_charge") - @ExcludeMissing - maximumCharge: JsonField = JsonMissing.of(), - @JsonProperty("minimum_charge") + @JsonProperty("percent") @ExcludeMissing - minimumCharge: JsonField = JsonMissing.of(), - @JsonProperty("per_unit_rate") - @ExcludeMissing - perUnitRate: JsonField = JsonMissing.of(), - ) : this(groupingKey, maximumCharge, minimumCharge, perUnitRate, mutableMapOf()) - - /** - * The event property used to group before applying thresholds - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun groupingKey(): String = groupingKey.getRequired("grouping_key") - - /** - * The maximum amount to charge each group - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun maximumCharge(): String = maximumCharge.getRequired("maximum_charge") - - /** - * The minimum amount to charge each group, regardless of usage - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun minimumCharge(): String = minimumCharge.getRequired("minimum_charge") + percent: JsonField = JsonMissing.of() + ) : this(percent, mutableMapOf()) /** - * The base price charged per group + * What percent of the component subtotals to charge * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). */ - fun perUnitRate(): String = perUnitRate.getRequired("per_unit_rate") - - /** - * Returns the raw JSON value of [groupingKey]. - * - * Unlike [groupingKey], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("grouping_key") - @ExcludeMissing - fun _groupingKey(): JsonField = groupingKey - - /** - * Returns the raw JSON value of [maximumCharge]. - * - * Unlike [maximumCharge], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("maximum_charge") - @ExcludeMissing - fun _maximumCharge(): JsonField = maximumCharge - - /** - * Returns the raw JSON value of [minimumCharge]. - * - * Unlike [minimumCharge], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("minimum_charge") - @ExcludeMissing - fun _minimumCharge(): JsonField = minimumCharge + fun percent(): Double = percent.getRequired("percent") /** - * Returns the raw JSON value of [perUnitRate]. + * Returns the raw JSON value of [percent]. * - * Unlike [perUnitRate], this method doesn't throw if the JSON field has an + * Unlike [percent], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("per_unit_rate") + @JsonProperty("percent") @ExcludeMissing - fun _perUnitRate(): JsonField = perUnitRate + fun _percent(): JsonField = percent @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -13948,100 +17122,39 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [GroupedWithMinMaxThresholdsConfig]. + * [PercentConfig]. * * The following fields are required: * ```kotlin - * .groupingKey() - * .maximumCharge() - * .minimumCharge() - * .perUnitRate() + * .percent() * ``` */ fun builder() = Builder() } - /** A builder for [GroupedWithMinMaxThresholdsConfig]. */ + /** A builder for [PercentConfig]. */ class Builder internal constructor() { - private var groupingKey: JsonField? = null - private var maximumCharge: JsonField? = null - private var minimumCharge: JsonField? = null - private var perUnitRate: JsonField? = null + private var percent: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() - internal fun from( - groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig - ) = apply { - groupingKey = groupedWithMinMaxThresholdsConfig.groupingKey - maximumCharge = groupedWithMinMaxThresholdsConfig.maximumCharge - minimumCharge = groupedWithMinMaxThresholdsConfig.minimumCharge - perUnitRate = groupedWithMinMaxThresholdsConfig.perUnitRate - additionalProperties = - groupedWithMinMaxThresholdsConfig.additionalProperties - .toMutableMap() - } - - /** The event property used to group before applying thresholds */ - fun groupingKey(groupingKey: String) = - groupingKey(JsonField.of(groupingKey)) - - /** - * Sets [Builder.groupingKey] to an arbitrary JSON value. - * - * You should usually call [Builder.groupingKey] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun groupingKey(groupingKey: JsonField) = apply { - this.groupingKey = groupingKey - } - - /** The maximum amount to charge each group */ - fun maximumCharge(maximumCharge: String) = - maximumCharge(JsonField.of(maximumCharge)) - - /** - * Sets [Builder.maximumCharge] to an arbitrary JSON value. - * - * You should usually call [Builder.maximumCharge] with a well-typed - * [String] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun maximumCharge(maximumCharge: JsonField) = apply { - this.maximumCharge = maximumCharge - } - - /** The minimum amount to charge each group, regardless of usage */ - fun minimumCharge(minimumCharge: String) = - minimumCharge(JsonField.of(minimumCharge)) - - /** - * Sets [Builder.minimumCharge] to an arbitrary JSON value. - * - * You should usually call [Builder.minimumCharge] with a well-typed - * [String] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun minimumCharge(minimumCharge: JsonField) = apply { - this.minimumCharge = minimumCharge + internal fun from(percentConfig: PercentConfig) = apply { + percent = percentConfig.percent + additionalProperties = percentConfig.additionalProperties.toMutableMap() } - /** The base price charged per group */ - fun perUnitRate(perUnitRate: String) = - perUnitRate(JsonField.of(perUnitRate)) + /** What percent of the component subtotals to charge */ + fun percent(percent: Double) = percent(JsonField.of(percent)) /** - * Sets [Builder.perUnitRate] to an arbitrary JSON value. + * Sets [Builder.percent] to an arbitrary JSON value. * - * You should usually call [Builder.perUnitRate] with a well-typed [String] + * You should usually call [Builder.percent] with a well-typed [Double] * value instead. This method is primarily for setting the field to an * undocumented or not yet supported value. */ - fun perUnitRate(perUnitRate: JsonField) = apply { - this.perUnitRate = perUnitRate - } + fun percent(percent: JsonField) = apply { this.percent = percent } fun additionalProperties(additionalProperties: Map) = apply { @@ -14066,41 +17179,32 @@ private constructor( } /** - * Returns an immutable instance of [GroupedWithMinMaxThresholdsConfig]. + * Returns an immutable instance of [PercentConfig]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```kotlin - * .groupingKey() - * .maximumCharge() - * .minimumCharge() - * .perUnitRate() + * .percent() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): GroupedWithMinMaxThresholdsConfig = - GroupedWithMinMaxThresholdsConfig( - checkRequired("groupingKey", groupingKey), - checkRequired("maximumCharge", maximumCharge), - checkRequired("minimumCharge", minimumCharge), - checkRequired("perUnitRate", perUnitRate), + fun build(): PercentConfig = + PercentConfig( + checkRequired("percent", percent), additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): GroupedWithMinMaxThresholdsConfig = apply { + fun validate(): PercentConfig = apply { if (validated) { return@apply } - groupingKey() - maximumCharge() - minimumCharge() - perUnitRate() + percent() validated = true } @@ -14118,39 +17222,26 @@ private constructor( * * Used for best match union deserialization. */ - internal fun validity(): Int = - (if (groupingKey.asKnown() == null) 0 else 1) + - (if (maximumCharge.asKnown() == null) 0 else 1) + - (if (minimumCharge.asKnown() == null) 0 else 1) + - (if (perUnitRate.asKnown() == null) 0 else 1) + internal fun validity(): Int = (if (percent.asKnown() == null) 0 else 1) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is GroupedWithMinMaxThresholdsConfig && - groupingKey == other.groupingKey && - maximumCharge == other.maximumCharge && - minimumCharge == other.minimumCharge && - perUnitRate == other.perUnitRate && + return other is PercentConfig && + percent == other.percent && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash( - groupingKey, - maximumCharge, - minimumCharge, - perUnitRate, - additionalProperties, - ) + Objects.hash(percent, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "GroupedWithMinMaxThresholdsConfig{groupingKey=$groupingKey, maximumCharge=$maximumCharge, minimumCharge=$minimumCharge, perUnitRate=$perUnitRate, additionalProperties=$additionalProperties}" + "PercentConfig{percent=$percent, additionalProperties=$additionalProperties}" } /** @@ -14267,13 +17358,12 @@ private constructor( return true } - return other is GroupedWithMinMaxThresholds && + return other is Percent && cadence == other.cadence && - groupedWithMinMaxThresholdsConfig == - other.groupedWithMinMaxThresholdsConfig && itemId == other.itemId && modelType == other.modelType && name == other.name && + percentConfig == other.percentConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && @@ -14293,10 +17383,10 @@ private constructor( private val hashCode: Int by lazy { Objects.hash( cadence, - groupedWithMinMaxThresholdsConfig, itemId, modelType, name, + percentConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -14317,7 +17407,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "GroupedWithMinMaxThresholds{cadence=$cadence, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "Percent{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, percentConfig=$percentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } class EventOutput diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/ChangedSubscriptionResources.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/ChangedSubscriptionResources.kt index 8cee6ff23..fe0412662 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/ChangedSubscriptionResources.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/ChangedSubscriptionResources.kt @@ -5557,6 +5557,9 @@ private constructor( /** Alias for calling [price] with `Price.ofMinimum(minimum)`. */ fun price(minimum: Price.Minimum) = price(Price.ofMinimum(minimum)) + /** Alias for calling [price] with `Price.ofPercent(percent)`. */ + fun price(percent: Price.Percent) = price(Price.ofPercent(percent)) + /** Alias for calling [price] with `Price.ofEventOutput(eventOutput)`. */ fun price(eventOutput: Price.EventOutput) = price(Price.ofEventOutput(eventOutput)) diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Invoice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Invoice.kt index 5157d935e..2922ea51f 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Invoice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Invoice.kt @@ -5039,6 +5039,9 @@ private constructor( /** Alias for calling [price] with `Price.ofMinimum(minimum)`. */ fun price(minimum: Price.Minimum) = price(Price.ofMinimum(minimum)) + /** Alias for calling [price] with `Price.ofPercent(percent)`. */ + fun price(percent: Price.Percent) = price(Price.ofPercent(percent)) + /** Alias for calling [price] with `Price.ofEventOutput(eventOutput)`. */ fun price(eventOutput: Price.EventOutput) = price(Price.ofEventOutput(eventOutput)) diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceFetchUpcomingResponse.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceFetchUpcomingResponse.kt index a39f5b710..59784ef98 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceFetchUpcomingResponse.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceFetchUpcomingResponse.kt @@ -5033,6 +5033,9 @@ private constructor( /** Alias for calling [price] with `Price.ofMinimum(minimum)`. */ fun price(minimum: Price.Minimum) = price(Price.ofMinimum(minimum)) + /** Alias for calling [price] with `Price.ofPercent(percent)`. */ + fun price(percent: Price.Percent) = price(Price.ofPercent(percent)) + /** Alias for calling [price] with `Price.ofEventOutput(eventOutput)`. */ fun price(eventOutput: Price.EventOutput) = price(Price.ofEventOutput(eventOutput)) diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceLineItemCreateResponse.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceLineItemCreateResponse.kt index 54affc459..0835f89af 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceLineItemCreateResponse.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceLineItemCreateResponse.kt @@ -1078,6 +1078,9 @@ private constructor( /** Alias for calling [price] with `Price.ofMinimum(minimum)`. */ fun price(minimum: Price.Minimum) = price(Price.ofMinimum(minimum)) + /** Alias for calling [price] with `Price.ofPercent(percent)`. */ + fun price(percent: Price.Percent) = price(Price.ofPercent(percent)) + /** Alias for calling [price] with `Price.ofEventOutput(eventOutput)`. */ fun price(eventOutput: Price.EventOutput) = price(Price.ofEventOutput(eventOutput)) diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PerPriceCost.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PerPriceCost.kt index 3abf8398a..733cf0091 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PerPriceCost.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PerPriceCost.kt @@ -294,6 +294,9 @@ private constructor( /** Alias for calling [price] with `Price.ofMinimum(minimum)`. */ fun price(minimum: Price.Minimum) = price(Price.ofMinimum(minimum)) + /** Alias for calling [price] with `Price.ofPercent(percent)`. */ + fun price(percent: Price.Percent) = price(Price.ofPercent(percent)) + /** Alias for calling [price] with `Price.ofEventOutput(eventOutput)`. */ fun price(eventOutput: Price.EventOutput) = price(Price.ofEventOutput(eventOutput)) diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Plan.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Plan.kt index 05d9421fc..63f0817d3 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Plan.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Plan.kt @@ -1177,6 +1177,9 @@ private constructor( /** Alias for calling [addPrice] with `Price.ofMinimum(minimum)`. */ fun addPrice(minimum: Price.Minimum) = addPrice(Price.ofMinimum(minimum)) + /** Alias for calling [addPrice] with `Price.ofPercent(percent)`. */ + fun addPrice(percent: Price.Percent) = addPrice(Price.ofPercent(percent)) + /** Alias for calling [addPrice] with `Price.ofEventOutput(eventOutput)`. */ fun addPrice(eventOutput: Price.EventOutput) = addPrice(Price.ofEventOutput(eventOutput)) diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanCreateParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanCreateParams.kt index f6dbbec45..7ae6a6ca2 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanCreateParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanCreateParams.kt @@ -1468,6 +1468,9 @@ private constructor( /** Alias for calling [price] with `InnerPrice.ofMinimum(minimum)`. */ fun price(minimum: NewPlanMinimumCompositePrice) = price(InnerPrice.ofMinimum(minimum)) + /** Alias for calling [price] with `InnerPrice.ofPercent(percent)`. */ + fun price(percent: InnerPrice.Percent) = price(InnerPrice.ofPercent(percent)) + /** Alias for calling [price] with `InnerPrice.ofEventOutput(eventOutput)`. */ fun price(eventOutput: InnerPrice.EventOutput) = price(InnerPrice.ofEventOutput(eventOutput)) @@ -1567,6 +1570,7 @@ private constructor( null, private val cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice? = null, private val minimum: NewPlanMinimumCompositePrice? = null, + private val percent: Percent? = null, private val eventOutput: EventOutput? = null, private val _json: JsonValue? = null, ) { @@ -1631,6 +1635,8 @@ private constructor( fun minimum(): NewPlanMinimumCompositePrice? = minimum + fun percent(): Percent? = percent + fun eventOutput(): EventOutput? = eventOutput fun isUnit(): Boolean = unit != null @@ -1688,6 +1694,8 @@ private constructor( fun isMinimum(): Boolean = minimum != null + fun isPercent(): Boolean = percent != null + fun isEventOutput(): Boolean = eventOutput != null fun asUnit(): NewPlanUnitPrice = unit.getOrThrow("unit") @@ -1765,6 +1773,8 @@ private constructor( fun asMinimum(): NewPlanMinimumCompositePrice = minimum.getOrThrow("minimum") + fun asPercent(): Percent = percent.getOrThrow("percent") + fun asEventOutput(): EventOutput = eventOutput.getOrThrow("eventOutput") fun _json(): JsonValue? = _json @@ -1814,6 +1824,7 @@ private constructor( cumulativeGroupedBulk != null -> visitor.visitCumulativeGroupedBulk(cumulativeGroupedBulk) minimum != null -> visitor.visitMinimum(minimum) + percent != null -> visitor.visitPercent(percent) eventOutput != null -> visitor.visitEventOutput(eventOutput) else -> visitor.unknown(_json) } @@ -1974,6 +1985,10 @@ private constructor( minimum.validate() } + override fun visitPercent(percent: Percent) { + percent.validate() + } + override fun visitEventOutput(eventOutput: EventOutput) { eventOutput.validate() } @@ -2096,6 +2111,8 @@ private constructor( override fun visitMinimum(minimum: NewPlanMinimumCompositePrice) = minimum.validity() + override fun visitPercent(percent: Percent) = percent.validity() + override fun visitEventOutput(eventOutput: EventOutput) = eventOutput.validity() @@ -2136,6 +2153,7 @@ private constructor( scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && cumulativeGroupedBulk == other.cumulativeGroupedBulk && minimum == other.minimum && + percent == other.percent && eventOutput == other.eventOutput } @@ -2168,6 +2186,7 @@ private constructor( scalableMatrixWithTieredPricing, cumulativeGroupedBulk, minimum, + percent, eventOutput, ) @@ -2214,6 +2233,7 @@ private constructor( cumulativeGroupedBulk != null -> "InnerPrice{cumulativeGroupedBulk=$cumulativeGroupedBulk}" minimum != null -> "InnerPrice{minimum=$minimum}" + percent != null -> "InnerPrice{percent=$percent}" eventOutput != null -> "InnerPrice{eventOutput=$eventOutput}" _json != null -> "InnerPrice{_unknown=$_json}" else -> throw IllegalStateException("Invalid InnerPrice") @@ -2306,6 +2326,8 @@ private constructor( fun ofMinimum(minimum: NewPlanMinimumCompositePrice) = InnerPrice(minimum = minimum) + fun ofPercent(percent: Percent) = InnerPrice(percent = percent) + fun ofEventOutput(eventOutput: EventOutput) = InnerPrice(eventOutput = eventOutput) } @@ -2395,6 +2417,8 @@ private constructor( fun visitMinimum(minimum: NewPlanMinimumCompositePrice): T + fun visitPercent(percent: Percent): T + fun visitEventOutput(eventOutput: EventOutput): T /** @@ -2613,6 +2637,11 @@ private constructor( ?.let { InnerPrice(minimum = it, _json = json) } ?: InnerPrice(_json = json) } + "percent" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + InnerPrice(percent = it, _json = json) + } ?: InnerPrice(_json = json) + } "event_output" -> { return tryDeserialize(node, jacksonTypeRef())?.let { InnerPrice(eventOutput = it, _json = json) @@ -2678,6 +2707,7 @@ private constructor( value.cumulativeGroupedBulk != null -> generator.writeObject(value.cumulativeGroupedBulk) value.minimum != null -> generator.writeObject(value.minimum) + value.percent != null -> generator.writeObject(value.percent) value.eventOutput != null -> generator.writeObject(value.eventOutput) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid InnerPrice") @@ -6152,6 +6182,1521 @@ private constructor( "GroupedWithMinMaxThresholds{cadence=$cadence, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } + class Percent + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val percentConfig: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("percent_config") + @ExcludeMissing + percentConfig: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + modelType, + name, + percentConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("percent") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * Configuration for percent pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun percentConfig(): PercentConfig = percentConfig.getRequired("percent_config") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = billableMetricId.getNullable("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + invoiceGroupingKey.getNullable("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [percentConfig]. + * + * Unlike [percentConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("percent_config") + @ExcludeMissing + fun _percentConfig(): JsonField = percentConfig + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Percent]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .name() + * .percentConfig() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Percent]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonValue = JsonValue.from("percent") + private var name: JsonField? = null + private var percentConfig: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(percent: Percent) = apply { + cadence = percent.cadence + itemId = percent.itemId + modelType = percent.modelType + name = percent.name + percentConfig = percent.percentConfig + billableMetricId = percent.billableMetricId + billedInAdvance = percent.billedInAdvance + billingCycleConfiguration = percent.billingCycleConfiguration + conversionRate = percent.conversionRate + conversionRateConfig = percent.conversionRateConfig + currency = percent.currency + dimensionalPriceConfiguration = percent.dimensionalPriceConfiguration + externalPriceId = percent.externalPriceId + fixedPriceQuantity = percent.fixedPriceQuantity + invoiceGroupingKey = percent.invoiceGroupingKey + invoicingCycleConfiguration = percent.invoicingCycleConfiguration + metadata = percent.metadata + referenceId = percent.referenceId + additionalProperties = percent.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("percent") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for percent pricing */ + fun percentConfig(percentConfig: PercentConfig) = + percentConfig(JsonField.of(percentConfig)) + + /** + * Sets [Builder.percentConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.percentConfig] with a well-typed + * [PercentConfig] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun percentConfig(percentConfig: JsonField) = apply { + this.percentConfig = percentConfig + } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Percent]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .name() + * .percentConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Percent = + Percent( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + modelType, + checkRequired("name", name), + checkRequired("percentConfig", percentConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Percent = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + _modelType().let { + if (it != JsonValue.from("percent")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + percentConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + modelType.let { if (it == JsonValue.from("percent")) 1 else 0 } + + (if (name.asKnown() == null) 0 else 1) + + (percentConfig.asKnown()?.validity() ?: 0) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Configuration for percent pricing */ + class PercentConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val percent: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("percent") + @ExcludeMissing + percent: JsonField = JsonMissing.of() + ) : this(percent, mutableMapOf()) + + /** + * What percent of the component subtotals to charge + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun percent(): Double = percent.getRequired("percent") + + /** + * Returns the raw JSON value of [percent]. + * + * Unlike [percent], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("percent") + @ExcludeMissing + fun _percent(): JsonField = percent + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [PercentConfig]. + * + * The following fields are required: + * ```kotlin + * .percent() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [PercentConfig]. */ + class Builder internal constructor() { + + private var percent: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(percentConfig: PercentConfig) = apply { + percent = percentConfig.percent + additionalProperties = percentConfig.additionalProperties.toMutableMap() + } + + /** What percent of the component subtotals to charge */ + fun percent(percent: Double) = percent(JsonField.of(percent)) + + /** + * Sets [Builder.percent] to an arbitrary JSON value. + * + * You should usually call [Builder.percent] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun percent(percent: JsonField) = apply { this.percent = percent } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [PercentConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .percent() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): PercentConfig = + PercentConfig( + checkRequired("percent", percent), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): PercentConfig = apply { + if (validated) { + return@apply + } + + percent() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = (if (percent.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PercentConfig && + percent == other.percent && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(percent, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "PercentConfig{percent=$percent, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Percent && + cadence == other.cadence && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + percentConfig == other.percentConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + modelType, + name, + percentConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Percent{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, percentConfig=$percentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + class EventOutput @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanVersion.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanVersion.kt index 015adf4b9..e562e4877 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanVersion.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanVersion.kt @@ -435,6 +435,9 @@ private constructor( /** Alias for calling [addPrice] with `Price.ofMinimum(minimum)`. */ fun addPrice(minimum: Price.Minimum) = addPrice(Price.ofMinimum(minimum)) + /** Alias for calling [addPrice] with `Price.ofPercent(percent)`. */ + fun addPrice(percent: Price.Percent) = addPrice(Price.ofPercent(percent)) + /** Alias for calling [addPrice] with `Price.ofEventOutput(eventOutput)`. */ fun addPrice(eventOutput: Price.EventOutput) = addPrice(Price.ofEventOutput(eventOutput)) diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Price.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Price.kt index e491cbfd8..630d12b60 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Price.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Price.kt @@ -73,6 +73,7 @@ private constructor( private val scalableMatrixWithTieredPricing: ScalableMatrixWithTieredPricing? = null, private val cumulativeGroupedBulk: CumulativeGroupedBulk? = null, private val minimum: Minimum? = null, + private val percent: Percent? = null, private val eventOutput: EventOutput? = null, private val _json: JsonValue? = null, ) { @@ -133,6 +134,8 @@ private constructor( fun minimum(): Minimum? = minimum + fun percent(): Percent? = percent + fun eventOutput(): EventOutput? = eventOutput fun isUnit(): Boolean = unit != null @@ -189,6 +192,8 @@ private constructor( fun isMinimum(): Boolean = minimum != null + fun isPercent(): Boolean = percent != null + fun isEventOutput(): Boolean = eventOutput != null fun asUnit(): Unit = unit.getOrThrow("unit") @@ -259,6 +264,8 @@ private constructor( fun asMinimum(): Minimum = minimum.getOrThrow("minimum") + fun asPercent(): Percent = percent.getOrThrow("percent") + fun asEventOutput(): EventOutput = eventOutput.getOrThrow("eventOutput") fun _json(): JsonValue? = _json @@ -302,6 +309,7 @@ private constructor( cumulativeGroupedBulk != null -> visitor.visitCumulativeGroupedBulk(cumulativeGroupedBulk) minimum != null -> visitor.visitMinimum(minimum) + percent != null -> visitor.visitPercent(percent) eventOutput != null -> visitor.visitEventOutput(eventOutput) else -> visitor.unknown(_json) } @@ -443,6 +451,10 @@ private constructor( minimum.validate() } + override fun visitPercent(percent: Percent) { + percent.validate() + } + override fun visitEventOutput(eventOutput: EventOutput) { eventOutput.validate() } @@ -552,6 +564,8 @@ private constructor( override fun visitMinimum(minimum: Minimum) = minimum.validity() + override fun visitPercent(percent: Percent) = percent.validity() + override fun visitEventOutput(eventOutput: EventOutput) = eventOutput.validity() override fun unknown(json: JsonValue?) = 0 @@ -591,6 +605,7 @@ private constructor( scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && cumulativeGroupedBulk == other.cumulativeGroupedBulk && minimum == other.minimum && + percent == other.percent && eventOutput == other.eventOutput } @@ -623,6 +638,7 @@ private constructor( scalableMatrixWithTieredPricing, cumulativeGroupedBulk, minimum, + percent, eventOutput, ) @@ -661,6 +677,7 @@ private constructor( "Price{scalableMatrixWithTieredPricing=$scalableMatrixWithTieredPricing}" cumulativeGroupedBulk != null -> "Price{cumulativeGroupedBulk=$cumulativeGroupedBulk}" minimum != null -> "Price{minimum=$minimum}" + percent != null -> "Price{percent=$percent}" eventOutput != null -> "Price{eventOutput=$eventOutput}" _json != null -> "Price{_unknown=$_json}" else -> throw IllegalStateException("Invalid Price") @@ -744,6 +761,8 @@ private constructor( fun ofMinimum(minimum: Minimum) = Price(minimum = minimum) + fun ofPercent(percent: Percent) = Price(percent = percent) + fun ofEventOutput(eventOutput: EventOutput) = Price(eventOutput = eventOutput) } @@ -812,6 +831,8 @@ private constructor( fun visitMinimum(minimum: Minimum): T + fun visitPercent(percent: Percent): T + fun visitEventOutput(eventOutput: EventOutput): T /** @@ -970,6 +991,11 @@ private constructor( Price(minimum = it, _json = json) } ?: Price(_json = json) } + "percent" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(percent = it, _json = json) + } ?: Price(_json = json) + } "event_output" -> { return tryDeserialize(node, jacksonTypeRef())?.let { Price(eventOutput = it, _json = json) @@ -1030,6 +1056,7 @@ private constructor( value.cumulativeGroupedBulk != null -> generator.writeObject(value.cumulativeGroupedBulk) value.minimum != null -> generator.writeObject(value.minimum) + value.percent != null -> generator.writeObject(value.percent) value.eventOutput != null -> generator.writeObject(value.eventOutput) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid Price") @@ -62708,7 +62735,2239 @@ private constructor( return true } - return other is CumulativeGroupedBulk && + return other is CumulativeGroupedBulk && + id == other.id && + billableMetric == other.billableMetric && + billingCycleConfiguration == other.billingCycleConfiguration && + billingMode == other.billingMode && + cadence == other.cadence && + compositePriceFilters == other.compositePriceFilters && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + createdAt == other.createdAt && + creditAllocation == other.creditAllocation && + cumulativeGroupedBulkConfig == other.cumulativeGroupedBulkConfig && + currency == other.currency && + discount == other.discount && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + item == other.item && + maximum == other.maximum && + maximumAmount == other.maximumAmount && + metadata == other.metadata && + minimum == other.minimum && + minimumAmount == other.minimumAmount && + modelType == other.modelType && + name == other.name && + planPhaseOrder == other.planPhaseOrder && + priceType == other.priceType && + replacesPriceId == other.replacesPriceId && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + billableMetric, + billingCycleConfiguration, + billingMode, + cadence, + compositePriceFilters, + conversionRate, + conversionRateConfig, + createdAt, + creditAllocation, + cumulativeGroupedBulkConfig, + currency, + discount, + externalPriceId, + fixedPriceQuantity, + invoicingCycleConfiguration, + item, + maximum, + maximumAmount, + metadata, + minimum, + minimumAmount, + modelType, + name, + planPhaseOrder, + priceType, + replacesPriceId, + dimensionalPriceConfiguration, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CumulativeGroupedBulk{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, cumulativeGroupedBulkConfig=$cumulativeGroupedBulkConfig, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + } + + class Minimum + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val billableMetric: JsonField, + private val billingCycleConfiguration: JsonField, + private val billingMode: JsonField, + private val cadence: JsonField, + private val compositePriceFilters: JsonField>, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val createdAt: JsonField, + private val creditAllocation: JsonField, + private val currency: JsonField, + private val discount: JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val item: JsonField, + private val maximum: JsonField, + private val maximumAmount: JsonField, + private val metadata: JsonField, + private val minimum: JsonField, + private val minimumAmount: JsonField, + private val minimumConfig: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val planPhaseOrder: JsonField, + private val priceType: JsonField, + private val replacesPriceId: JsonField, + private val dimensionalPriceConfiguration: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric") + @ExcludeMissing + billableMetric: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("billing_mode") + @ExcludeMissing + billingMode: JsonField = JsonMissing.of(), + @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), + @JsonProperty("composite_price_filters") + @ExcludeMissing + compositePriceFilters: JsonField> = JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + createdAt: JsonField = JsonMissing.of(), + @JsonProperty("credit_allocation") + @ExcludeMissing + creditAllocation: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("discount") + @ExcludeMissing + discount: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("item") @ExcludeMissing item: JsonField = JsonMissing.of(), + @JsonProperty("maximum") @ExcludeMissing maximum: JsonField = JsonMissing.of(), + @JsonProperty("maximum_amount") + @ExcludeMissing + maximumAmount: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("minimum") @ExcludeMissing minimum: JsonField = JsonMissing.of(), + @JsonProperty("minimum_amount") + @ExcludeMissing + minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("minimum_config") + @ExcludeMissing + minimumConfig: JsonField = JsonMissing.of(), + @JsonProperty("model_type") @ExcludeMissing modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("plan_phase_order") + @ExcludeMissing + planPhaseOrder: JsonField = JsonMissing.of(), + @JsonProperty("price_type") + @ExcludeMissing + priceType: JsonField = JsonMissing.of(), + @JsonProperty("replaces_price_id") + @ExcludeMissing + replacesPriceId: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + ) : this( + id, + billableMetric, + billingCycleConfiguration, + billingMode, + cadence, + compositePriceFilters, + conversionRate, + conversionRateConfig, + createdAt, + creditAllocation, + currency, + discount, + externalPriceId, + fixedPriceQuantity, + invoicingCycleConfiguration, + item, + maximum, + maximumAmount, + metadata, + minimum, + minimumAmount, + minimumConfig, + modelType, + name, + planPhaseOrder, + priceType, + replacesPriceId, + dimensionalPriceConfiguration, + mutableMapOf(), + ) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun billableMetric(): BillableMetricTiny? = billableMetric.getNullable("billable_metric") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): BillingCycleConfiguration = + billingCycleConfiguration.getRequired("billing_cycle_configuration") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun billingMode(): BillingMode = billingMode.getRequired("billing_mode") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun compositePriceFilters(): List? = + compositePriceFilters.getNullable("composite_price_filters") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun creditAllocation(): Allocation? = creditAllocation.getNullable("credit_allocation") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + @Deprecated("deprecated") fun discount(): Discount? = discount.getNullable("discount") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): BillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * A minimal representation of an Item containing only the essential identifying + * information. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun item(): ItemSlim = item.getRequired("item") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + @Deprecated("deprecated") fun maximum(): Maximum? = maximum.getNullable("maximum") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + @Deprecated("deprecated") + fun maximumAmount(): String? = maximumAmount.getNullable("maximum_amount") + + /** + * User specified key-value pairs for the resource. If not present, this defaults to an + * empty dictionary. Individual keys can be removed by setting the value to `null`, and the + * entire metadata mapping can be cleared by setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun metadata(): Metadata = metadata.getRequired("metadata") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + @Deprecated("deprecated") fun minimum(): Minimum? = minimum.getNullable("minimum") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + @Deprecated("deprecated") + fun minimumAmount(): String? = minimumAmount.getNullable("minimum_amount") + + /** + * Configuration for minimum pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun minimumConfig(): MinimumConfig = minimumConfig.getRequired("minimum_config") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("minimum") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun name(): String = name.getRequired("name") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun planPhaseOrder(): Long? = planPhaseOrder.getNullable("plan_phase_order") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun priceType(): PriceType = priceType.getRequired("price_type") + + /** + * The price id this price replaces. This price will take the place of the replaced price in + * plan version migrations. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun replacesPriceId(): String? = replacesPriceId.getNullable("replaces_price_id") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): DimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [billableMetric]. + * + * Unlike [billableMetric], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("billable_metric") + @ExcludeMissing + fun _billableMetric(): JsonField = billableMetric + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [billingMode]. + * + * Unlike [billingMode], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("billing_mode") + @ExcludeMissing + fun _billingMode(): JsonField = billingMode + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [compositePriceFilters]. + * + * Unlike [compositePriceFilters], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("composite_price_filters") + @ExcludeMissing + fun _compositePriceFilters(): JsonField> = compositePriceFilters + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [createdAt]. + * + * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt + + /** + * Returns the raw JSON value of [creditAllocation]. + * + * Unlike [creditAllocation], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("credit_allocation") + @ExcludeMissing + fun _creditAllocation(): JsonField = creditAllocation + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [discount]. + * + * Unlike [discount], this method doesn't throw if the JSON field has an unexpected type. + */ + @Deprecated("deprecated") + @JsonProperty("discount") + @ExcludeMissing + fun _discount(): JsonField = discount + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [item]. + * + * Unlike [item], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("item") @ExcludeMissing fun _item(): JsonField = item + + /** + * Returns the raw JSON value of [maximum]. + * + * Unlike [maximum], this method doesn't throw if the JSON field has an unexpected type. + */ + @Deprecated("deprecated") + @JsonProperty("maximum") + @ExcludeMissing + fun _maximum(): JsonField = maximum + + /** + * Returns the raw JSON value of [maximumAmount]. + * + * Unlike [maximumAmount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @Deprecated("deprecated") + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [minimum]. + * + * Unlike [minimum], this method doesn't throw if the JSON field has an unexpected type. + */ + @Deprecated("deprecated") + @JsonProperty("minimum") + @ExcludeMissing + fun _minimum(): JsonField = minimum + + /** + * Returns the raw JSON value of [minimumAmount]. + * + * Unlike [minimumAmount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @Deprecated("deprecated") + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount + + /** + * Returns the raw JSON value of [minimumConfig]. + * + * Unlike [minimumConfig], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("minimum_config") + @ExcludeMissing + fun _minimumConfig(): JsonField = minimumConfig + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [planPhaseOrder]. + * + * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder + + /** + * Returns the raw JSON value of [priceType]. + * + * Unlike [priceType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("price_type") + @ExcludeMissing + fun _priceType(): JsonField = priceType + + /** + * Returns the raw JSON value of [replacesPriceId]. + * + * Unlike [replacesPriceId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("replaces_price_id") + @ExcludeMissing + fun _replacesPriceId(): JsonField = replacesPriceId + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Minimum]. + * + * The following fields are required: + * ```kotlin + * .id() + * .billableMetric() + * .billingCycleConfiguration() + * .billingMode() + * .cadence() + * .compositePriceFilters() + * .conversionRate() + * .conversionRateConfig() + * .createdAt() + * .creditAllocation() + * .currency() + * .discount() + * .externalPriceId() + * .fixedPriceQuantity() + * .invoicingCycleConfiguration() + * .item() + * .maximum() + * .maximumAmount() + * .metadata() + * .minimum() + * .minimumAmount() + * .minimumConfig() + * .name() + * .planPhaseOrder() + * .priceType() + * .replacesPriceId() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Minimum]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var billableMetric: JsonField? = null + private var billingCycleConfiguration: JsonField? = null + private var billingMode: JsonField? = null + private var cadence: JsonField? = null + private var compositePriceFilters: JsonField>? = null + private var conversionRate: JsonField? = null + private var conversionRateConfig: JsonField? = null + private var createdAt: JsonField? = null + private var creditAllocation: JsonField? = null + private var currency: JsonField? = null + private var discount: JsonField? = null + private var externalPriceId: JsonField? = null + private var fixedPriceQuantity: JsonField? = null + private var invoicingCycleConfiguration: JsonField? = null + private var item: JsonField? = null + private var maximum: JsonField? = null + private var maximumAmount: JsonField? = null + private var metadata: JsonField? = null + private var minimum: JsonField? = null + private var minimumAmount: JsonField? = null + private var minimumConfig: JsonField? = null + private var modelType: JsonValue = JsonValue.from("minimum") + private var name: JsonField? = null + private var planPhaseOrder: JsonField? = null + private var priceType: JsonField? = null + private var replacesPriceId: JsonField? = null + private var dimensionalPriceConfiguration: JsonField = + JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(minimum: Minimum) = apply { + id = minimum.id + billableMetric = minimum.billableMetric + billingCycleConfiguration = minimum.billingCycleConfiguration + billingMode = minimum.billingMode + cadence = minimum.cadence + compositePriceFilters = minimum.compositePriceFilters.map { it.toMutableList() } + conversionRate = minimum.conversionRate + conversionRateConfig = minimum.conversionRateConfig + createdAt = minimum.createdAt + creditAllocation = minimum.creditAllocation + currency = minimum.currency + discount = minimum.discount + externalPriceId = minimum.externalPriceId + fixedPriceQuantity = minimum.fixedPriceQuantity + invoicingCycleConfiguration = minimum.invoicingCycleConfiguration + item = minimum.item + maximum = minimum.maximum + maximumAmount = minimum.maximumAmount + metadata = minimum.metadata + this.minimum = minimum.minimum + minimumAmount = minimum.minimumAmount + minimumConfig = minimum.minimumConfig + modelType = minimum.modelType + name = minimum.name + planPhaseOrder = minimum.planPhaseOrder + priceType = minimum.priceType + replacesPriceId = minimum.replacesPriceId + dimensionalPriceConfiguration = minimum.dimensionalPriceConfiguration + additionalProperties = minimum.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun id(id: JsonField) = apply { this.id = id } + + fun billableMetric(billableMetric: BillableMetricTiny?) = + billableMetric(JsonField.ofNullable(billableMetric)) + + /** + * Sets [Builder.billableMetric] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetric] with a well-typed + * [BillableMetricTiny] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun billableMetric(billableMetric: JsonField) = apply { + this.billableMetric = billableMetric + } + + fun billingCycleConfiguration(billingCycleConfiguration: BillingCycleConfiguration) = + billingCycleConfiguration(JsonField.of(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [BillingCycleConfiguration] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + fun billingMode(billingMode: BillingMode) = billingMode(JsonField.of(billingMode)) + + /** + * Sets [Builder.billingMode] to an arbitrary JSON value. + * + * You should usually call [Builder.billingMode] with a well-typed [BillingMode] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun billingMode(billingMode: JsonField) = apply { + this.billingMode = billingMode + } + + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + fun compositePriceFilters(compositePriceFilters: List?) = + compositePriceFilters(JsonField.ofNullable(compositePriceFilters)) + + /** + * Sets [Builder.compositePriceFilters] to an arbitrary JSON value. + * + * You should usually call [Builder.compositePriceFilters] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun compositePriceFilters( + compositePriceFilters: JsonField> + ) = apply { + this.compositePriceFilters = compositePriceFilters.map { it.toMutableList() } + } + + /** + * Adds a single [TransformPriceFilter] to [compositePriceFilters]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addCompositePriceFilter(compositePriceFilter: TransformPriceFilter) = apply { + compositePriceFilters = + (compositePriceFilters ?: JsonField.of(mutableListOf())).also { + checkKnown("compositePriceFilters", it).add(compositePriceFilter) + } + } + + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun conversionRateConfig(conversionRateConfig: JsonField) = + apply { + this.conversionRateConfig = conversionRateConfig + } + + /** + * Alias for calling [conversionRateConfig] with `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + .tieredConfig(tieredConfig) + .build() + ) + + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + + /** + * Sets [Builder.createdAt] to an arbitrary JSON value. + * + * You should usually call [Builder.createdAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun createdAt(createdAt: JsonField) = apply { + this.createdAt = createdAt + } + + fun creditAllocation(creditAllocation: Allocation?) = + creditAllocation(JsonField.ofNullable(creditAllocation)) + + /** + * Sets [Builder.creditAllocation] to an arbitrary JSON value. + * + * You should usually call [Builder.creditAllocation] with a well-typed [Allocation] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun creditAllocation(creditAllocation: JsonField) = apply { + this.creditAllocation = creditAllocation + } + + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + @Deprecated("deprecated") + fun discount(discount: Discount?) = discount(JsonField.ofNullable(discount)) + + /** + * Sets [Builder.discount] to an arbitrary JSON value. + * + * You should usually call [Builder.discount] with a well-typed [Discount] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + @Deprecated("deprecated") + fun discount(discount: JsonField) = apply { this.discount = discount } + + /** Alias for calling [discount] with `Discount.ofPercentage(percentage)`. */ + @Deprecated("deprecated") + fun discount(percentage: PercentageDiscount) = + discount(Discount.ofPercentage(percentage)) + + /** + * Alias for calling [discount] with the following: + * ```kotlin + * PercentageDiscount.builder() + * .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + * .percentageDiscount(percentageDiscount) + * .build() + * ``` + */ + @Deprecated("deprecated") + fun percentageDiscount(percentageDiscount: Double) = + discount( + PercentageDiscount.builder() + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(percentageDiscount) + .build() + ) + + /** Alias for calling [discount] with `Discount.ofTrial(trial)`. */ + @Deprecated("deprecated") + fun discount(trial: TrialDiscount) = discount(Discount.ofTrial(trial)) + + /** Alias for calling [discount] with `Discount.ofUsage(usage)`. */ + @Deprecated("deprecated") + fun discount(usage: UsageDiscount) = discount(Discount.ofUsage(usage)) + + /** + * Alias for calling [discount] with the following: + * ```kotlin + * UsageDiscount.builder() + * .discountType(UsageDiscount.DiscountType.USAGE) + * .usageDiscount(usageDiscount) + * .build() + * ``` + */ + @Deprecated("deprecated") + fun usageDiscount(usageDiscount: Double) = + discount( + UsageDiscount.builder() + .discountType(UsageDiscount.DiscountType.USAGE) + .usageDiscount(usageDiscount) + .build() + ) + + /** Alias for calling [discount] with `Discount.ofAmount(amount)`. */ + @Deprecated("deprecated") + fun discount(amount: AmountDiscount) = discount(Discount.ofAmount(amount)) + + /** + * Alias for calling [discount] with the following: + * ```kotlin + * AmountDiscount.builder() + * .discountType(AmountDiscount.DiscountType.AMOUNT) + * .amountDiscount(amountDiscount) + * .build() + * ``` + */ + @Deprecated("deprecated") + fun amountDiscount(amountDiscount: String) = + discount( + AmountDiscount.builder() + .discountType(AmountDiscount.DiscountType.AMOUNT) + .amountDiscount(amountDiscount) + .build() + ) + + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: BillingCycleConfiguration? + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a well-typed + * [BillingCycleConfiguration] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** + * A minimal representation of an Item containing only the essential identifying + * information. + */ + fun item(item: ItemSlim) = item(JsonField.of(item)) + + /** + * Sets [Builder.item] to an arbitrary JSON value. + * + * You should usually call [Builder.item] with a well-typed [ItemSlim] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun item(item: JsonField) = apply { this.item = item } + + @Deprecated("deprecated") + fun maximum(maximum: Maximum?) = maximum(JsonField.ofNullable(maximum)) + + /** + * Sets [Builder.maximum] to an arbitrary JSON value. + * + * You should usually call [Builder.maximum] with a well-typed [Maximum] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + @Deprecated("deprecated") + fun maximum(maximum: JsonField) = apply { this.maximum = maximum } + + @Deprecated("deprecated") + fun maximumAmount(maximumAmount: String?) = + maximumAmount(JsonField.ofNullable(maximumAmount)) + + /** + * Sets [Builder.maximumAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.maximumAmount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + @Deprecated("deprecated") + fun maximumAmount(maximumAmount: JsonField) = apply { + this.maximumAmount = maximumAmount + } + + /** + * User specified key-value pairs for the resource. If not present, this defaults to an + * empty dictionary. Individual keys can be removed by setting the value to `null`, and + * the entire metadata mapping can be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + @Deprecated("deprecated") + fun minimum(minimum: Minimum?) = minimum(JsonField.ofNullable(minimum)) + + /** + * Sets [Builder.minimum] to an arbitrary JSON value. + * + * You should usually call [Builder.minimum] with a well-typed [Minimum] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + @Deprecated("deprecated") + fun minimum(minimum: JsonField) = apply { this.minimum = minimum } + + @Deprecated("deprecated") + fun minimumAmount(minimumAmount: String?) = + minimumAmount(JsonField.ofNullable(minimumAmount)) + + /** + * Sets [Builder.minimumAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumAmount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + @Deprecated("deprecated") + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount + } + + /** Configuration for minimum pricing */ + fun minimumConfig(minimumConfig: MinimumConfig) = + minimumConfig(JsonField.of(minimumConfig)) + + /** + * Sets [Builder.minimumConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumConfig] with a well-typed [MinimumConfig] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun minimumConfig(minimumConfig: JsonField) = apply { + this.minimumConfig = minimumConfig + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```kotlin + * JsonValue.from("minimum") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + + /** + * Alias for [Builder.planPhaseOrder]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + + /** + * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. + * + * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun planPhaseOrder(planPhaseOrder: JsonField) = apply { + this.planPhaseOrder = planPhaseOrder + } + + fun priceType(priceType: PriceType) = priceType(JsonField.of(priceType)) + + /** + * Sets [Builder.priceType] to an arbitrary JSON value. + * + * You should usually call [Builder.priceType] with a well-typed [PriceType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun priceType(priceType: JsonField) = apply { this.priceType = priceType } + + /** + * The price id this price replaces. This price will take the place of the replaced + * price in plan version migrations. + */ + fun replacesPriceId(replacesPriceId: String?) = + replacesPriceId(JsonField.ofNullable(replacesPriceId)) + + /** + * Sets [Builder.replacesPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.replacesPriceId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun replacesPriceId(replacesPriceId: JsonField) = apply { + this.replacesPriceId = replacesPriceId + } + + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: DimensionalPriceConfiguration? + ) = dimensionalPriceConfiguration(JsonField.ofNullable(dimensionalPriceConfiguration)) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a well-typed + * [DimensionalPriceConfiguration] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Minimum]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .id() + * .billableMetric() + * .billingCycleConfiguration() + * .billingMode() + * .cadence() + * .compositePriceFilters() + * .conversionRate() + * .conversionRateConfig() + * .createdAt() + * .creditAllocation() + * .currency() + * .discount() + * .externalPriceId() + * .fixedPriceQuantity() + * .invoicingCycleConfiguration() + * .item() + * .maximum() + * .maximumAmount() + * .metadata() + * .minimum() + * .minimumAmount() + * .minimumConfig() + * .name() + * .planPhaseOrder() + * .priceType() + * .replacesPriceId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Minimum = + Minimum( + checkRequired("id", id), + checkRequired("billableMetric", billableMetric), + checkRequired("billingCycleConfiguration", billingCycleConfiguration), + checkRequired("billingMode", billingMode), + checkRequired("cadence", cadence), + checkRequired("compositePriceFilters", compositePriceFilters).map { + it.toImmutable() + }, + checkRequired("conversionRate", conversionRate), + checkRequired("conversionRateConfig", conversionRateConfig), + checkRequired("createdAt", createdAt), + checkRequired("creditAllocation", creditAllocation), + checkRequired("currency", currency), + checkRequired("discount", discount), + checkRequired("externalPriceId", externalPriceId), + checkRequired("fixedPriceQuantity", fixedPriceQuantity), + checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), + checkRequired("item", item), + checkRequired("maximum", maximum), + checkRequired("maximumAmount", maximumAmount), + checkRequired("metadata", metadata), + checkRequired("minimum", minimum), + checkRequired("minimumAmount", minimumAmount), + checkRequired("minimumConfig", minimumConfig), + modelType, + checkRequired("name", name), + checkRequired("planPhaseOrder", planPhaseOrder), + checkRequired("priceType", priceType), + checkRequired("replacesPriceId", replacesPriceId), + dimensionalPriceConfiguration, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Minimum = apply { + if (validated) { + return@apply + } + + id() + billableMetric()?.validate() + billingCycleConfiguration().validate() + billingMode().validate() + cadence().validate() + compositePriceFilters()?.forEach { it.validate() } + conversionRate() + conversionRateConfig()?.validate() + createdAt() + creditAllocation()?.validate() + currency() + discount()?.validate() + externalPriceId() + fixedPriceQuantity() + invoicingCycleConfiguration()?.validate() + item().validate() + maximum()?.validate() + maximumAmount() + metadata().validate() + minimum()?.validate() + minimumAmount() + minimumConfig().validate() + _modelType().let { + if (it != JsonValue.from("minimum")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + planPhaseOrder() + priceType().validate() + replacesPriceId() + dimensionalPriceConfiguration()?.validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (id.asKnown() == null) 0 else 1) + + (billableMetric.asKnown()?.validity() ?: 0) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (billingMode.asKnown()?.validity() ?: 0) + + (cadence.asKnown()?.validity() ?: 0) + + (compositePriceFilters.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (createdAt.asKnown() == null) 0 else 1) + + (creditAllocation.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (discount.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (item.asKnown()?.validity() ?: 0) + + (maximum.asKnown()?.validity() ?: 0) + + (if (maximumAmount.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (minimum.asKnown()?.validity() ?: 0) + + (if (minimumAmount.asKnown() == null) 0 else 1) + + (minimumConfig.asKnown()?.validity() ?: 0) + + modelType.let { if (it == JsonValue.from("minimum")) 1 else 0 } + + (if (name.asKnown() == null) 0 else 1) + + (if (planPhaseOrder.asKnown() == null) 0 else 1) + + (priceType.asKnown()?.validity() ?: 0) + + (if (replacesPriceId.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + class BillingMode @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val IN_ADVANCE = of("in_advance") + + val IN_ARREAR = of("in_arrear") + + fun of(value: String) = BillingMode(JsonField.of(value)) + } + + /** An enum containing [BillingMode]'s known values. */ + enum class Known { + IN_ADVANCE, + IN_ARREAR, + } + + /** + * An enum containing [BillingMode]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [BillingMode] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + IN_ADVANCE, + IN_ARREAR, + /** + * An enum member indicating that [BillingMode] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + IN_ADVANCE -> Value.IN_ADVANCE + IN_ARREAR -> Value.IN_ARREAR + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + IN_ADVANCE -> Known.IN_ADVANCE + IN_ARREAR -> Known.IN_ARREAR + else -> throw OrbInvalidDataException("Unknown BillingMode: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): BillingMode = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BillingMode && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class Cadence @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val ONE_TIME = of("one_time") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val SEMI_ANNUAL = of("semi_annual") + + val ANNUAL = of("annual") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ONE_TIME, + MONTHLY, + QUARTERLY, + SEMI_ANNUAL, + ANNUAL, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ONE_TIME, + MONTHLY, + QUARTERLY, + SEMI_ANNUAL, + ANNUAL, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ONE_TIME -> Value.ONE_TIME + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + SEMI_ANNUAL -> Value.SEMI_ANNUAL + ANNUAL -> Value.ANNUAL + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + ONE_TIME -> Known.ONE_TIME + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + SEMI_ANNUAL -> Known.SEMI_ANNUAL + ANNUAL -> Known.ANNUAL + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * User specified key-value pairs for the resource. If not present, this defaults to an + * empty dictionary. Individual keys can be removed by setting the value to `null`, and the + * entire metadata mapping can be cleared by setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + /** Configuration for minimum pricing */ + class MinimumConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val minimumAmount: JsonField, + private val prorated: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("minimum_amount") + @ExcludeMissing + minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("prorated") + @ExcludeMissing + prorated: JsonField = JsonMissing.of(), + ) : this(minimumAmount, prorated, mutableMapOf()) + + /** + * The minimum amount to apply + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") + + /** + * If true, subtotals from this price are prorated based on the service period + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun prorated(): Boolean? = prorated.getNullable("prorated") + + /** + * Returns the raw JSON value of [minimumAmount]. + * + * Unlike [minimumAmount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount + + /** + * Returns the raw JSON value of [prorated]. + * + * Unlike [prorated], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("prorated") @ExcludeMissing fun _prorated(): JsonField = prorated + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [MinimumConfig]. + * + * The following fields are required: + * ```kotlin + * .minimumAmount() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [MinimumConfig]. */ + class Builder internal constructor() { + + private var minimumAmount: JsonField? = null + private var prorated: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(minimumConfig: MinimumConfig) = apply { + minimumAmount = minimumConfig.minimumAmount + prorated = minimumConfig.prorated + additionalProperties = minimumConfig.additionalProperties.toMutableMap() + } + + /** The minimum amount to apply */ + fun minimumAmount(minimumAmount: String) = + minimumAmount(JsonField.of(minimumAmount)) + + /** + * Sets [Builder.minimumAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumAmount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount + } + + /** If true, subtotals from this price are prorated based on the service period */ + fun prorated(prorated: Boolean) = prorated(JsonField.of(prorated)) + + /** + * Sets [Builder.prorated] to an arbitrary JSON value. + * + * You should usually call [Builder.prorated] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun prorated(prorated: JsonField) = apply { this.prorated = prorated } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [MinimumConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .minimumAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MinimumConfig = + MinimumConfig( + checkRequired("minimumAmount", minimumAmount), + prorated, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MinimumConfig = apply { + if (validated) { + return@apply + } + + minimumAmount() + prorated() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (minimumAmount.asKnown() == null) 0 else 1) + + (if (prorated.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MinimumConfig && + minimumAmount == other.minimumAmount && + prorated == other.prorated && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(minimumAmount, prorated, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MinimumConfig{minimumAmount=$minimumAmount, prorated=$prorated, additionalProperties=$additionalProperties}" + } + + class PriceType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val USAGE_PRICE = of("usage_price") + + val FIXED_PRICE = of("fixed_price") + + val COMPOSITE_PRICE = of("composite_price") + + fun of(value: String) = PriceType(JsonField.of(value)) + } + + /** An enum containing [PriceType]'s known values. */ + enum class Known { + USAGE_PRICE, + FIXED_PRICE, + COMPOSITE_PRICE, + } + + /** + * An enum containing [PriceType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [PriceType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + USAGE_PRICE, + FIXED_PRICE, + COMPOSITE_PRICE, + /** + * An enum member indicating that [PriceType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + USAGE_PRICE -> Value.USAGE_PRICE + FIXED_PRICE -> Value.FIXED_PRICE + COMPOSITE_PRICE -> Value.COMPOSITE_PRICE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + USAGE_PRICE -> Known.USAGE_PRICE + FIXED_PRICE -> Known.FIXED_PRICE + COMPOSITE_PRICE -> Known.COMPOSITE_PRICE + else -> throw OrbInvalidDataException("Unknown PriceType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): PriceType = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PriceType && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Minimum && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && @@ -62719,7 +64978,6 @@ private constructor( conversionRateConfig == other.conversionRateConfig && createdAt == other.createdAt && creditAllocation == other.creditAllocation && - cumulativeGroupedBulkConfig == other.cumulativeGroupedBulkConfig && currency == other.currency && discount == other.discount && externalPriceId == other.externalPriceId && @@ -62731,6 +64989,7 @@ private constructor( metadata == other.metadata && minimum == other.minimum && minimumAmount == other.minimumAmount && + minimumConfig == other.minimumConfig && modelType == other.modelType && name == other.name && planPhaseOrder == other.planPhaseOrder && @@ -62752,7 +65011,6 @@ private constructor( conversionRateConfig, createdAt, creditAllocation, - cumulativeGroupedBulkConfig, currency, discount, externalPriceId, @@ -62764,6 +65022,7 @@ private constructor( metadata, minimum, minimumAmount, + minimumConfig, modelType, name, planPhaseOrder, @@ -62777,10 +65036,10 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "CumulativeGroupedBulk{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, cumulativeGroupedBulkConfig=$cumulativeGroupedBulkConfig, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "Minimum{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, minimumConfig=$minimumConfig, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" } - class Minimum + class Percent @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, @@ -62804,9 +65063,9 @@ private constructor( private val metadata: JsonField, private val minimum: JsonField, private val minimumAmount: JsonField, - private val minimumConfig: JsonField, private val modelType: JsonValue, private val name: JsonField, + private val percentConfig: JsonField, private val planPhaseOrder: JsonField, private val priceType: JsonField, private val replacesPriceId: JsonField, @@ -62869,11 +65128,11 @@ private constructor( @JsonProperty("minimum_amount") @ExcludeMissing minimumAmount: JsonField = JsonMissing.of(), - @JsonProperty("minimum_config") - @ExcludeMissing - minimumConfig: JsonField = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("percent_config") + @ExcludeMissing + percentConfig: JsonField = JsonMissing.of(), @JsonProperty("plan_phase_order") @ExcludeMissing planPhaseOrder: JsonField = JsonMissing.of(), @@ -62909,9 +65168,9 @@ private constructor( metadata, minimum, minimumAmount, - minimumConfig, modelType, name, + percentConfig, planPhaseOrder, priceType, replacesPriceId, @@ -63058,20 +65317,12 @@ private constructor( @Deprecated("deprecated") fun minimumAmount(): String? = minimumAmount.getNullable("minimum_amount") - /** - * Configuration for minimum pricing - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun minimumConfig(): MinimumConfig = minimumConfig.getRequired("minimum_config") - /** * The pricing model type * * Expected to always return the following: * ```kotlin - * JsonValue.from("minimum") + * JsonValue.from("percent") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -63085,6 +65336,14 @@ private constructor( */ fun name(): String = name.getRequired("name") + /** + * Configuration for percent pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun percentConfig(): PercentConfig = percentConfig.getRequired("percent_config") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -63311,21 +65570,21 @@ private constructor( fun _minimumAmount(): JsonField = minimumAmount /** - * Returns the raw JSON value of [minimumConfig]. + * Returns the raw JSON value of [name]. * - * Unlike [minimumConfig], this method doesn't throw if the JSON field has an unexpected - * type. + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("minimum_config") - @ExcludeMissing - fun _minimumConfig(): JsonField = minimumConfig + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** - * Returns the raw JSON value of [name]. + * Returns the raw JSON value of [percentConfig]. * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [percentConfig], this method doesn't throw if the JSON field has an unexpected + * type. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("percent_config") + @ExcludeMissing + fun _percentConfig(): JsonField = percentConfig /** * Returns the raw JSON value of [planPhaseOrder]. @@ -63382,7 +65641,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [Minimum]. + * Returns a mutable builder for constructing an instance of [Percent]. * * The following fields are required: * ```kotlin @@ -63407,8 +65666,8 @@ private constructor( * .metadata() * .minimum() * .minimumAmount() - * .minimumConfig() * .name() + * .percentConfig() * .planPhaseOrder() * .priceType() * .replacesPriceId() @@ -63417,7 +65676,7 @@ private constructor( fun builder() = Builder() } - /** A builder for [Minimum]. */ + /** A builder for [Percent]. */ class Builder internal constructor() { private var id: JsonField? = null @@ -63441,9 +65700,9 @@ private constructor( private var metadata: JsonField? = null private var minimum: JsonField? = null private var minimumAmount: JsonField? = null - private var minimumConfig: JsonField? = null - private var modelType: JsonValue = JsonValue.from("minimum") + private var modelType: JsonValue = JsonValue.from("percent") private var name: JsonField? = null + private var percentConfig: JsonField? = null private var planPhaseOrder: JsonField? = null private var priceType: JsonField? = null private var replacesPriceId: JsonField? = null @@ -63451,36 +65710,36 @@ private constructor( JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(minimum: Minimum) = apply { - id = minimum.id - billableMetric = minimum.billableMetric - billingCycleConfiguration = minimum.billingCycleConfiguration - billingMode = minimum.billingMode - cadence = minimum.cadence - compositePriceFilters = minimum.compositePriceFilters.map { it.toMutableList() } - conversionRate = minimum.conversionRate - conversionRateConfig = minimum.conversionRateConfig - createdAt = minimum.createdAt - creditAllocation = minimum.creditAllocation - currency = minimum.currency - discount = minimum.discount - externalPriceId = minimum.externalPriceId - fixedPriceQuantity = minimum.fixedPriceQuantity - invoicingCycleConfiguration = minimum.invoicingCycleConfiguration - item = minimum.item - maximum = minimum.maximum - maximumAmount = minimum.maximumAmount - metadata = minimum.metadata - this.minimum = minimum.minimum - minimumAmount = minimum.minimumAmount - minimumConfig = minimum.minimumConfig - modelType = minimum.modelType - name = minimum.name - planPhaseOrder = minimum.planPhaseOrder - priceType = minimum.priceType - replacesPriceId = minimum.replacesPriceId - dimensionalPriceConfiguration = minimum.dimensionalPriceConfiguration - additionalProperties = minimum.additionalProperties.toMutableMap() + internal fun from(percent: Percent) = apply { + id = percent.id + billableMetric = percent.billableMetric + billingCycleConfiguration = percent.billingCycleConfiguration + billingMode = percent.billingMode + cadence = percent.cadence + compositePriceFilters = percent.compositePriceFilters.map { it.toMutableList() } + conversionRate = percent.conversionRate + conversionRateConfig = percent.conversionRateConfig + createdAt = percent.createdAt + creditAllocation = percent.creditAllocation + currency = percent.currency + discount = percent.discount + externalPriceId = percent.externalPriceId + fixedPriceQuantity = percent.fixedPriceQuantity + invoicingCycleConfiguration = percent.invoicingCycleConfiguration + item = percent.item + maximum = percent.maximum + maximumAmount = percent.maximumAmount + metadata = percent.metadata + minimum = percent.minimum + minimumAmount = percent.minimumAmount + modelType = percent.modelType + name = percent.name + percentConfig = percent.percentConfig + planPhaseOrder = percent.planPhaseOrder + priceType = percent.priceType + replacesPriceId = percent.replacesPriceId + dimensionalPriceConfiguration = percent.dimensionalPriceConfiguration + additionalProperties = percent.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) @@ -63919,28 +66178,13 @@ private constructor( this.minimumAmount = minimumAmount } - /** Configuration for minimum pricing */ - fun minimumConfig(minimumConfig: MinimumConfig) = - minimumConfig(JsonField.of(minimumConfig)) - - /** - * Sets [Builder.minimumConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.minimumConfig] with a well-typed [MinimumConfig] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun minimumConfig(minimumConfig: JsonField) = apply { - this.minimumConfig = minimumConfig - } - /** * Sets the field to an arbitrary JSON value. * * It is usually unnecessary to call this method because the field defaults to the * following: * ```kotlin - * JsonValue.from("minimum") + * JsonValue.from("percent") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -63959,6 +66203,21 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } + /** Configuration for percent pricing */ + fun percentConfig(percentConfig: PercentConfig) = + percentConfig(JsonField.of(percentConfig)) + + /** + * Sets [Builder.percentConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.percentConfig] with a well-typed [PercentConfig] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun percentConfig(percentConfig: JsonField) = apply { + this.percentConfig = percentConfig + } + fun planPhaseOrder(planPhaseOrder: Long?) = planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) @@ -64044,7 +66303,7 @@ private constructor( } /** - * Returns an immutable instance of [Minimum]. + * Returns an immutable instance of [Percent]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -64071,8 +66330,8 @@ private constructor( * .metadata() * .minimum() * .minimumAmount() - * .minimumConfig() * .name() + * .percentConfig() * .planPhaseOrder() * .priceType() * .replacesPriceId() @@ -64080,8 +66339,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): Minimum = - Minimum( + fun build(): Percent = + Percent( checkRequired("id", id), checkRequired("billableMetric", billableMetric), checkRequired("billingCycleConfiguration", billingCycleConfiguration), @@ -64105,9 +66364,9 @@ private constructor( checkRequired("metadata", metadata), checkRequired("minimum", minimum), checkRequired("minimumAmount", minimumAmount), - checkRequired("minimumConfig", minimumConfig), modelType, checkRequired("name", name), + checkRequired("percentConfig", percentConfig), checkRequired("planPhaseOrder", planPhaseOrder), checkRequired("priceType", priceType), checkRequired("replacesPriceId", replacesPriceId), @@ -64118,7 +66377,7 @@ private constructor( private var validated: Boolean = false - fun validate(): Minimum = apply { + fun validate(): Percent = apply { if (validated) { return@apply } @@ -64144,13 +66403,13 @@ private constructor( metadata().validate() minimum()?.validate() minimumAmount() - minimumConfig().validate() _modelType().let { - if (it != JsonValue.from("minimum")) { + if (it != JsonValue.from("percent")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } name() + percentConfig().validate() planPhaseOrder() priceType().validate() replacesPriceId() @@ -64194,9 +66453,9 @@ private constructor( (metadata.asKnown()?.validity() ?: 0) + (minimum.asKnown()?.validity() ?: 0) + (if (minimumAmount.asKnown() == null) 0 else 1) + - (minimumConfig.asKnown()?.validity() ?: 0) + - modelType.let { if (it == JsonValue.from("minimum")) 1 else 0 } + + modelType.let { if (it == JsonValue.from("percent")) 1 else 0 } + (if (name.asKnown() == null) 0 else 1) + + (percentConfig.asKnown()?.validity() ?: 0) + (if (planPhaseOrder.asKnown() == null) 0 else 1) + (priceType.asKnown()?.validity() ?: 0) + (if (replacesPriceId.asKnown() == null) 0 else 1) + @@ -64588,59 +66847,36 @@ private constructor( override fun toString() = "Metadata{additionalProperties=$additionalProperties}" } - /** Configuration for minimum pricing */ - class MinimumConfig + /** Configuration for percent pricing */ + class PercentConfig @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val minimumAmount: JsonField, - private val prorated: JsonField, + private val percent: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("minimum_amount") - @ExcludeMissing - minimumAmount: JsonField = JsonMissing.of(), - @JsonProperty("prorated") + @JsonProperty("percent") @ExcludeMissing - prorated: JsonField = JsonMissing.of(), - ) : this(minimumAmount, prorated, mutableMapOf()) + percent: JsonField = JsonMissing.of() + ) : this(percent, mutableMapOf()) /** - * The minimum amount to apply + * What percent of the component subtotals to charge * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected * value). */ - fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") + fun percent(): Double = percent.getRequired("percent") /** - * If true, subtotals from this price are prorated based on the service period - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun prorated(): Boolean? = prorated.getNullable("prorated") - - /** - * Returns the raw JSON value of [minimumAmount]. - * - * Unlike [minimumAmount], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("minimum_amount") - @ExcludeMissing - fun _minimumAmount(): JsonField = minimumAmount - - /** - * Returns the raw JSON value of [prorated]. + * Returns the raw JSON value of [percent]. * - * Unlike [prorated], this method doesn't throw if the JSON field has an unexpected - * type. + * Unlike [percent], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("prorated") @ExcludeMissing fun _prorated(): JsonField = prorated + @JsonProperty("percent") @ExcludeMissing fun _percent(): JsonField = percent @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -64657,55 +66893,38 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [MinimumConfig]. + * Returns a mutable builder for constructing an instance of [PercentConfig]. * * The following fields are required: * ```kotlin - * .minimumAmount() + * .percent() * ``` */ fun builder() = Builder() } - /** A builder for [MinimumConfig]. */ + /** A builder for [PercentConfig]. */ class Builder internal constructor() { - private var minimumAmount: JsonField? = null - private var prorated: JsonField = JsonMissing.of() + private var percent: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(minimumConfig: MinimumConfig) = apply { - minimumAmount = minimumConfig.minimumAmount - prorated = minimumConfig.prorated - additionalProperties = minimumConfig.additionalProperties.toMutableMap() - } - - /** The minimum amount to apply */ - fun minimumAmount(minimumAmount: String) = - minimumAmount(JsonField.of(minimumAmount)) - - /** - * Sets [Builder.minimumAmount] to an arbitrary JSON value. - * - * You should usually call [Builder.minimumAmount] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun minimumAmount(minimumAmount: JsonField) = apply { - this.minimumAmount = minimumAmount + internal fun from(percentConfig: PercentConfig) = apply { + percent = percentConfig.percent + additionalProperties = percentConfig.additionalProperties.toMutableMap() } - /** If true, subtotals from this price are prorated based on the service period */ - fun prorated(prorated: Boolean) = prorated(JsonField.of(prorated)) + /** What percent of the component subtotals to charge */ + fun percent(percent: Double) = percent(JsonField.of(percent)) /** - * Sets [Builder.prorated] to an arbitrary JSON value. + * Sets [Builder.percent] to an arbitrary JSON value. * - * You should usually call [Builder.prorated] with a well-typed [Boolean] value + * You should usually call [Builder.percent] with a well-typed [Double] value * instead. This method is primarily for setting the field to an undocumented or not * yet supported value. */ - fun prorated(prorated: JsonField) = apply { this.prorated = prorated } + fun percent(percent: JsonField) = apply { this.percent = percent } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -64730,34 +66949,32 @@ private constructor( } /** - * Returns an immutable instance of [MinimumConfig]. + * Returns an immutable instance of [PercentConfig]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```kotlin - * .minimumAmount() + * .percent() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): MinimumConfig = - MinimumConfig( - checkRequired("minimumAmount", minimumAmount), - prorated, + fun build(): PercentConfig = + PercentConfig( + checkRequired("percent", percent), additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): MinimumConfig = apply { + fun validate(): PercentConfig = apply { if (validated) { return@apply } - minimumAmount() - prorated() + percent() validated = true } @@ -64775,29 +66992,24 @@ private constructor( * * Used for best match union deserialization. */ - internal fun validity(): Int = - (if (minimumAmount.asKnown() == null) 0 else 1) + - (if (prorated.asKnown() == null) 0 else 1) + internal fun validity(): Int = (if (percent.asKnown() == null) 0 else 1) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is MinimumConfig && - minimumAmount == other.minimumAmount && - prorated == other.prorated && + return other is PercentConfig && + percent == other.percent && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { - Objects.hash(minimumAmount, prorated, additionalProperties) - } + private val hashCode: Int by lazy { Objects.hash(percent, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "MinimumConfig{minimumAmount=$minimumAmount, prorated=$prorated, additionalProperties=$additionalProperties}" + "PercentConfig{percent=$percent, additionalProperties=$additionalProperties}" } class PriceType @JsonCreator private constructor(private val value: JsonField) : @@ -64940,7 +67152,7 @@ private constructor( return true } - return other is Minimum && + return other is Percent && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && @@ -64962,9 +67174,9 @@ private constructor( metadata == other.metadata && minimum == other.minimum && minimumAmount == other.minimumAmount && - minimumConfig == other.minimumConfig && modelType == other.modelType && name == other.name && + percentConfig == other.percentConfig && planPhaseOrder == other.planPhaseOrder && priceType == other.priceType && replacesPriceId == other.replacesPriceId && @@ -64995,9 +67207,9 @@ private constructor( metadata, minimum, minimumAmount, - minimumConfig, modelType, name, + percentConfig, planPhaseOrder, priceType, replacesPriceId, @@ -65009,7 +67221,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Minimum{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, minimumConfig=$minimumConfig, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "Percent{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, percentConfig=$percentConfig, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" } class EventOutput diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceCreateParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceCreateParams.kt index cb9b7c5a6..42afecefd 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceCreateParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceCreateParams.kt @@ -209,6 +209,9 @@ private constructor( /** Alias for calling [body] with `Body.ofMinimum(minimum)`. */ fun body(minimum: NewFloatingMinimumCompositePrice) = body(Body.ofMinimum(minimum)) + /** Alias for calling [body] with `Body.ofPercent(percent)`. */ + fun body(percent: Body.Percent) = body(Body.ofPercent(percent)) + /** Alias for calling [body] with `Body.ofEventOutput(eventOutput)`. */ fun body(eventOutput: Body.EventOutput) = body(Body.ofEventOutput(eventOutput)) @@ -371,6 +374,7 @@ private constructor( null, private val cumulativeGroupedBulk: NewFloatingCumulativeGroupedBulkPrice? = null, private val minimum: NewFloatingMinimumCompositePrice? = null, + private val percent: Percent? = null, private val eventOutput: EventOutput? = null, private val _json: JsonValue? = null, ) { @@ -435,6 +439,8 @@ private constructor( fun minimum(): NewFloatingMinimumCompositePrice? = minimum + fun percent(): Percent? = percent + fun eventOutput(): EventOutput? = eventOutput fun isUnit(): Boolean = unit != null @@ -491,6 +497,8 @@ private constructor( fun isMinimum(): Boolean = minimum != null + fun isPercent(): Boolean = percent != null + fun isEventOutput(): Boolean = eventOutput != null fun asUnit(): NewFloatingUnitPrice = unit.getOrThrow("unit") @@ -568,6 +576,8 @@ private constructor( fun asMinimum(): NewFloatingMinimumCompositePrice = minimum.getOrThrow("minimum") + fun asPercent(): Percent = percent.getOrThrow("percent") + fun asEventOutput(): EventOutput = eventOutput.getOrThrow("eventOutput") fun _json(): JsonValue? = _json @@ -614,6 +624,7 @@ private constructor( cumulativeGroupedBulk != null -> visitor.visitCumulativeGroupedBulk(cumulativeGroupedBulk) minimum != null -> visitor.visitMinimum(minimum) + percent != null -> visitor.visitPercent(percent) eventOutput != null -> visitor.visitEventOutput(eventOutput) else -> visitor.unknown(_json) } @@ -774,6 +785,10 @@ private constructor( minimum.validate() } + override fun visitPercent(percent: Percent) { + percent.validate() + } + override fun visitEventOutput(eventOutput: EventOutput) { eventOutput.validate() } @@ -896,6 +911,8 @@ private constructor( override fun visitMinimum(minimum: NewFloatingMinimumCompositePrice) = minimum.validity() + override fun visitPercent(percent: Percent) = percent.validity() + override fun visitEventOutput(eventOutput: EventOutput) = eventOutput.validity() override fun unknown(json: JsonValue?) = 0 @@ -935,6 +952,7 @@ private constructor( scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && cumulativeGroupedBulk == other.cumulativeGroupedBulk && minimum == other.minimum && + percent == other.percent && eventOutput == other.eventOutput } @@ -967,6 +985,7 @@ private constructor( scalableMatrixWithTieredPricing, cumulativeGroupedBulk, minimum, + percent, eventOutput, ) @@ -1009,6 +1028,7 @@ private constructor( cumulativeGroupedBulk != null -> "Body{cumulativeGroupedBulk=$cumulativeGroupedBulk}" minimum != null -> "Body{minimum=$minimum}" + percent != null -> "Body{percent=$percent}" eventOutput != null -> "Body{eventOutput=$eventOutput}" _json != null -> "Body{_unknown=$_json}" else -> throw IllegalStateException("Invalid Body") @@ -1101,6 +1121,8 @@ private constructor( fun ofMinimum(minimum: NewFloatingMinimumCompositePrice) = Body(minimum = minimum) + fun ofPercent(percent: Percent) = Body(percent = percent) + fun ofEventOutput(eventOutput: EventOutput) = Body(eventOutput = eventOutput) } @@ -1189,6 +1211,8 @@ private constructor( fun visitMinimum(minimum: NewFloatingMinimumCompositePrice): T + fun visitPercent(percent: Percent): T + fun visitEventOutput(eventOutput: EventOutput): T /** @@ -1399,6 +1423,11 @@ private constructor( ) ?.let { Body(minimum = it, _json = json) } ?: Body(_json = json) } + "percent" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Body(percent = it, _json = json) + } ?: Body(_json = json) + } "event_output" -> { return tryDeserialize(node, jacksonTypeRef())?.let { Body(eventOutput = it, _json = json) @@ -1463,6 +1492,7 @@ private constructor( value.cumulativeGroupedBulk != null -> generator.writeObject(value.cumulativeGroupedBulk) value.minimum != null -> generator.writeObject(value.minimum) + value.percent != null -> generator.writeObject(value.percent) value.eventOutput != null -> generator.writeObject(value.eventOutput) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid Body") @@ -3078,6 +3108,1434 @@ private constructor( "GroupedWithMinMaxThresholds{cadence=$cadence, currency=$currency, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" } + class Percent + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val currency: JsonField, + private val itemId: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val percentConfig: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val dimensionalPriceConfiguration: JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val metadata: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") @ExcludeMissing modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("percent_config") + @ExcludeMissing + percentConfig: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + ) : this( + cadence, + currency, + itemId, + modelType, + name, + percentConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * An ISO 4217 currency string for which this price is billed in. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("percent") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * Configuration for percent pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun percentConfig(): PercentConfig = percentConfig.getRequired("percent_config") + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun billableMetricId(): String? = billableMetricId.getNullable("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + invoiceGroupingKey.getNullable("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [percentConfig]. + * + * Unlike [percentConfig], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("percent_config") + @ExcludeMissing + fun _percentConfig(): JsonField = percentConfig + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Percent]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .currency() + * .itemId() + * .name() + * .percentConfig() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Percent]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var currency: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonValue = JsonValue.from("percent") + private var name: JsonField? = null + private var percentConfig: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(percent: Percent) = apply { + cadence = percent.cadence + currency = percent.currency + itemId = percent.itemId + modelType = percent.modelType + name = percent.name + percentConfig = percent.percentConfig + billableMetricId = percent.billableMetricId + billedInAdvance = percent.billedInAdvance + billingCycleConfiguration = percent.billingCycleConfiguration + conversionRate = percent.conversionRate + conversionRateConfig = percent.conversionRateConfig + dimensionalPriceConfiguration = percent.dimensionalPriceConfiguration + externalPriceId = percent.externalPriceId + fixedPriceQuantity = percent.fixedPriceQuantity + invoiceGroupingKey = percent.invoiceGroupingKey + invoicingCycleConfiguration = percent.invoicingCycleConfiguration + metadata = percent.metadata + additionalProperties = percent.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```kotlin + * JsonValue.from("percent") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for percent pricing */ + fun percentConfig(percentConfig: PercentConfig) = + percentConfig(JsonField.of(percentConfig)) + + /** + * Sets [Builder.percentConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.percentConfig] with a well-typed [PercentConfig] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun percentConfig(percentConfig: JsonField) = apply { + this.percentConfig = percentConfig + } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun conversionRateConfig(conversionRateConfig: JsonField) = + apply { + this.conversionRateConfig = conversionRateConfig + } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a well-typed + * [NewDimensionalPriceConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Percent]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .currency() + * .itemId() + * .name() + * .percentConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Percent = + Percent( + checkRequired("cadence", cadence), + checkRequired("currency", currency), + checkRequired("itemId", itemId), + modelType, + checkRequired("name", name), + checkRequired("percentConfig", percentConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Percent = apply { + if (validated) { + return@apply + } + + cadence().validate() + currency() + itemId() + _modelType().let { + if (it != JsonValue.from("percent")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + percentConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + metadata()?.validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (if (itemId.asKnown() == null) 0 else 1) + + modelType.let { if (it == JsonValue.from("percent")) 1 else 0 } + + (if (name.asKnown() == null) 0 else 1) + + (percentConfig.asKnown()?.validity() ?: 0) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (metadata.asKnown()?.validity() ?: 0) + + /** The cadence to bill for this price on. */ + class Cadence @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Configuration for percent pricing */ + class PercentConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val percent: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("percent") + @ExcludeMissing + percent: JsonField = JsonMissing.of() + ) : this(percent, mutableMapOf()) + + /** + * What percent of the component subtotals to charge + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun percent(): Double = percent.getRequired("percent") + + /** + * Returns the raw JSON value of [percent]. + * + * Unlike [percent], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("percent") @ExcludeMissing fun _percent(): JsonField = percent + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [PercentConfig]. + * + * The following fields are required: + * ```kotlin + * .percent() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [PercentConfig]. */ + class Builder internal constructor() { + + private var percent: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(percentConfig: PercentConfig) = apply { + percent = percentConfig.percent + additionalProperties = percentConfig.additionalProperties.toMutableMap() + } + + /** What percent of the component subtotals to charge */ + fun percent(percent: Double) = percent(JsonField.of(percent)) + + /** + * Sets [Builder.percent] to an arbitrary JSON value. + * + * You should usually call [Builder.percent] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun percent(percent: JsonField) = apply { this.percent = percent } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [PercentConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .percent() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): PercentConfig = + PercentConfig( + checkRequired("percent", percent), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): PercentConfig = apply { + if (validated) { + return@apply + } + + percent() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = (if (percent.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PercentConfig && + percent == other.percent && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(percent, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "PercentConfig{percent=$percent, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Percent && + cadence == other.cadence && + currency == other.currency && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + percentConfig == other.percentConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + currency, + itemId, + modelType, + name, + percentConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Percent{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, percentConfig=$percentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + } + class EventOutput @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceEvaluateMultipleParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceEvaluateMultipleParams.kt index baf734779..4b815aba7 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceEvaluateMultipleParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceEvaluateMultipleParams.kt @@ -1145,6 +1145,9 @@ private constructor( /** Alias for calling [price] with `Price.ofMinimum(minimum)`. */ fun price(minimum: NewFloatingMinimumCompositePrice) = price(Price.ofMinimum(minimum)) + /** Alias for calling [price] with `Price.ofPercent(percent)`. */ + fun price(percent: Price.Percent) = price(Price.ofPercent(percent)) + /** Alias for calling [price] with `Price.ofEventOutput(eventOutput)`. */ fun price(eventOutput: Price.EventOutput) = price(Price.ofEventOutput(eventOutput)) @@ -1269,6 +1272,7 @@ private constructor( null, private val cumulativeGroupedBulk: NewFloatingCumulativeGroupedBulkPrice? = null, private val minimum: NewFloatingMinimumCompositePrice? = null, + private val percent: Percent? = null, private val eventOutput: EventOutput? = null, private val _json: JsonValue? = null, ) { @@ -1337,6 +1341,8 @@ private constructor( fun minimum(): NewFloatingMinimumCompositePrice? = minimum + fun percent(): Percent? = percent + fun eventOutput(): EventOutput? = eventOutput fun isUnit(): Boolean = unit != null @@ -1394,6 +1400,8 @@ private constructor( fun isMinimum(): Boolean = minimum != null + fun isPercent(): Boolean = percent != null + fun isEventOutput(): Boolean = eventOutput != null fun asUnit(): NewFloatingUnitPrice = unit.getOrThrow("unit") @@ -1472,6 +1480,8 @@ private constructor( fun asMinimum(): NewFloatingMinimumCompositePrice = minimum.getOrThrow("minimum") + fun asPercent(): Percent = percent.getOrThrow("percent") + fun asEventOutput(): EventOutput = eventOutput.getOrThrow("eventOutput") fun _json(): JsonValue? = _json @@ -1521,6 +1531,7 @@ private constructor( cumulativeGroupedBulk != null -> visitor.visitCumulativeGroupedBulk(cumulativeGroupedBulk) minimum != null -> visitor.visitMinimum(minimum) + percent != null -> visitor.visitPercent(percent) eventOutput != null -> visitor.visitEventOutput(eventOutput) else -> visitor.unknown(_json) } @@ -1686,6 +1697,10 @@ private constructor( minimum.validate() } + override fun visitPercent(percent: Percent) { + percent.validate() + } + override fun visitEventOutput(eventOutput: EventOutput) { eventOutput.validate() } @@ -1811,6 +1826,8 @@ private constructor( override fun visitMinimum(minimum: NewFloatingMinimumCompositePrice) = minimum.validity() + override fun visitPercent(percent: Percent) = percent.validity() + override fun visitEventOutput(eventOutput: EventOutput) = eventOutput.validity() @@ -1851,6 +1868,7 @@ private constructor( scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && cumulativeGroupedBulk == other.cumulativeGroupedBulk && minimum == other.minimum && + percent == other.percent && eventOutput == other.eventOutput } @@ -1883,6 +1901,7 @@ private constructor( scalableMatrixWithTieredPricing, cumulativeGroupedBulk, minimum, + percent, eventOutput, ) @@ -1928,6 +1947,7 @@ private constructor( cumulativeGroupedBulk != null -> "Price{cumulativeGroupedBulk=$cumulativeGroupedBulk}" minimum != null -> "Price{minimum=$minimum}" + percent != null -> "Price{percent=$percent}" eventOutput != null -> "Price{eventOutput=$eventOutput}" _json != null -> "Price{_unknown=$_json}" else -> throw IllegalStateException("Invalid Price") @@ -2024,6 +2044,8 @@ private constructor( fun ofMinimum(minimum: NewFloatingMinimumCompositePrice) = Price(minimum = minimum) + fun ofPercent(percent: Percent) = Price(percent = percent) + fun ofEventOutput(eventOutput: EventOutput) = Price(eventOutput = eventOutput) } @@ -2114,6 +2136,8 @@ private constructor( fun visitMinimum(minimum: NewFloatingMinimumCompositePrice): T + fun visitPercent(percent: Percent): T + fun visitEventOutput(eventOutput: EventOutput): T /** @@ -2335,6 +2359,11 @@ private constructor( ) ?.let { Price(minimum = it, _json = json) } ?: Price(_json = json) } + "percent" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(percent = it, _json = json) + } ?: Price(_json = json) + } "event_output" -> { return tryDeserialize(node, jacksonTypeRef())?.let { Price(eventOutput = it, _json = json) @@ -2400,6 +2429,7 @@ private constructor( value.cumulativeGroupedBulk != null -> generator.writeObject(value.cumulativeGroupedBulk) value.minimum != null -> generator.writeObject(value.minimum) + value.percent != null -> generator.writeObject(value.percent) value.eventOutput != null -> generator.writeObject(value.eventOutput) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid Price") @@ -4055,6 +4085,1471 @@ private constructor( "GroupedWithMinMaxThresholds{cadence=$cadence, currency=$currency, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" } + class Percent + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val currency: JsonField, + private val itemId: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val percentConfig: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val metadata: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("percent_config") + @ExcludeMissing + percentConfig: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + ) : this( + cadence, + currency, + itemId, + modelType, + name, + percentConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * An ISO 4217 currency string for which this price is billed in. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("percent") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * Configuration for percent pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun percentConfig(): PercentConfig = percentConfig.getRequired("percent_config") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = billableMetricId.getNullable("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + invoiceGroupingKey.getNullable("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [percentConfig]. + * + * Unlike [percentConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("percent_config") + @ExcludeMissing + fun _percentConfig(): JsonField = percentConfig + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Percent]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .currency() + * .itemId() + * .name() + * .percentConfig() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Percent]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var currency: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonValue = JsonValue.from("percent") + private var name: JsonField? = null + private var percentConfig: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(percent: Percent) = apply { + cadence = percent.cadence + currency = percent.currency + itemId = percent.itemId + modelType = percent.modelType + name = percent.name + percentConfig = percent.percentConfig + billableMetricId = percent.billableMetricId + billedInAdvance = percent.billedInAdvance + billingCycleConfiguration = percent.billingCycleConfiguration + conversionRate = percent.conversionRate + conversionRateConfig = percent.conversionRateConfig + dimensionalPriceConfiguration = percent.dimensionalPriceConfiguration + externalPriceId = percent.externalPriceId + fixedPriceQuantity = percent.fixedPriceQuantity + invoiceGroupingKey = percent.invoiceGroupingKey + invoicingCycleConfiguration = percent.invoicingCycleConfiguration + metadata = percent.metadata + additionalProperties = percent.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("percent") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for percent pricing */ + fun percentConfig(percentConfig: PercentConfig) = + percentConfig(JsonField.of(percentConfig)) + + /** + * Sets [Builder.percentConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.percentConfig] with a well-typed + * [PercentConfig] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun percentConfig(percentConfig: JsonField) = apply { + this.percentConfig = percentConfig + } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Percent]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .currency() + * .itemId() + * .name() + * .percentConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Percent = + Percent( + checkRequired("cadence", cadence), + checkRequired("currency", currency), + checkRequired("itemId", itemId), + modelType, + checkRequired("name", name), + checkRequired("percentConfig", percentConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Percent = apply { + if (validated) { + return@apply + } + + cadence().validate() + currency() + itemId() + _modelType().let { + if (it != JsonValue.from("percent")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + percentConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + metadata()?.validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (if (itemId.asKnown() == null) 0 else 1) + + modelType.let { if (it == JsonValue.from("percent")) 1 else 0 } + + (if (name.asKnown() == null) 0 else 1) + + (percentConfig.asKnown()?.validity() ?: 0) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (metadata.asKnown()?.validity() ?: 0) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Configuration for percent pricing */ + class PercentConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val percent: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("percent") + @ExcludeMissing + percent: JsonField = JsonMissing.of() + ) : this(percent, mutableMapOf()) + + /** + * What percent of the component subtotals to charge + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun percent(): Double = percent.getRequired("percent") + + /** + * Returns the raw JSON value of [percent]. + * + * Unlike [percent], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("percent") + @ExcludeMissing + fun _percent(): JsonField = percent + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [PercentConfig]. + * + * The following fields are required: + * ```kotlin + * .percent() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [PercentConfig]. */ + class Builder internal constructor() { + + private var percent: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(percentConfig: PercentConfig) = apply { + percent = percentConfig.percent + additionalProperties = percentConfig.additionalProperties.toMutableMap() + } + + /** What percent of the component subtotals to charge */ + fun percent(percent: Double) = percent(JsonField.of(percent)) + + /** + * Sets [Builder.percent] to an arbitrary JSON value. + * + * You should usually call [Builder.percent] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun percent(percent: JsonField) = apply { this.percent = percent } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [PercentConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .percent() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): PercentConfig = + PercentConfig( + checkRequired("percent", percent), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): PercentConfig = apply { + if (validated) { + return@apply + } + + percent() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = (if (percent.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PercentConfig && + percent == other.percent && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(percent, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "PercentConfig{percent=$percent, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Percent && + cadence == other.cadence && + currency == other.currency && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + percentConfig == other.percentConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + currency, + itemId, + modelType, + name, + percentConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Percent{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, percentConfig=$percentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + } + class EventOutput @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceEvaluatePreviewEventsParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceEvaluatePreviewEventsParams.kt index b7b458d47..d6363350c 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceEvaluatePreviewEventsParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceEvaluatePreviewEventsParams.kt @@ -1680,6 +1680,9 @@ private constructor( /** Alias for calling [price] with `Price.ofMinimum(minimum)`. */ fun price(minimum: NewFloatingMinimumCompositePrice) = price(Price.ofMinimum(minimum)) + /** Alias for calling [price] with `Price.ofPercent(percent)`. */ + fun price(percent: Price.Percent) = price(Price.ofPercent(percent)) + /** Alias for calling [price] with `Price.ofEventOutput(eventOutput)`. */ fun price(eventOutput: Price.EventOutput) = price(Price.ofEventOutput(eventOutput)) @@ -1804,6 +1807,7 @@ private constructor( null, private val cumulativeGroupedBulk: NewFloatingCumulativeGroupedBulkPrice? = null, private val minimum: NewFloatingMinimumCompositePrice? = null, + private val percent: Percent? = null, private val eventOutput: EventOutput? = null, private val _json: JsonValue? = null, ) { @@ -1872,6 +1876,8 @@ private constructor( fun minimum(): NewFloatingMinimumCompositePrice? = minimum + fun percent(): Percent? = percent + fun eventOutput(): EventOutput? = eventOutput fun isUnit(): Boolean = unit != null @@ -1929,6 +1935,8 @@ private constructor( fun isMinimum(): Boolean = minimum != null + fun isPercent(): Boolean = percent != null + fun isEventOutput(): Boolean = eventOutput != null fun asUnit(): NewFloatingUnitPrice = unit.getOrThrow("unit") @@ -2007,6 +2015,8 @@ private constructor( fun asMinimum(): NewFloatingMinimumCompositePrice = minimum.getOrThrow("minimum") + fun asPercent(): Percent = percent.getOrThrow("percent") + fun asEventOutput(): EventOutput = eventOutput.getOrThrow("eventOutput") fun _json(): JsonValue? = _json @@ -2056,6 +2066,7 @@ private constructor( cumulativeGroupedBulk != null -> visitor.visitCumulativeGroupedBulk(cumulativeGroupedBulk) minimum != null -> visitor.visitMinimum(minimum) + percent != null -> visitor.visitPercent(percent) eventOutput != null -> visitor.visitEventOutput(eventOutput) else -> visitor.unknown(_json) } @@ -2221,6 +2232,10 @@ private constructor( minimum.validate() } + override fun visitPercent(percent: Percent) { + percent.validate() + } + override fun visitEventOutput(eventOutput: EventOutput) { eventOutput.validate() } @@ -2346,6 +2361,8 @@ private constructor( override fun visitMinimum(minimum: NewFloatingMinimumCompositePrice) = minimum.validity() + override fun visitPercent(percent: Percent) = percent.validity() + override fun visitEventOutput(eventOutput: EventOutput) = eventOutput.validity() @@ -2386,6 +2403,7 @@ private constructor( scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && cumulativeGroupedBulk == other.cumulativeGroupedBulk && minimum == other.minimum && + percent == other.percent && eventOutput == other.eventOutput } @@ -2418,6 +2436,7 @@ private constructor( scalableMatrixWithTieredPricing, cumulativeGroupedBulk, minimum, + percent, eventOutput, ) @@ -2463,6 +2482,7 @@ private constructor( cumulativeGroupedBulk != null -> "Price{cumulativeGroupedBulk=$cumulativeGroupedBulk}" minimum != null -> "Price{minimum=$minimum}" + percent != null -> "Price{percent=$percent}" eventOutput != null -> "Price{eventOutput=$eventOutput}" _json != null -> "Price{_unknown=$_json}" else -> throw IllegalStateException("Invalid Price") @@ -2559,6 +2579,8 @@ private constructor( fun ofMinimum(minimum: NewFloatingMinimumCompositePrice) = Price(minimum = minimum) + fun ofPercent(percent: Percent) = Price(percent = percent) + fun ofEventOutput(eventOutput: EventOutput) = Price(eventOutput = eventOutput) } @@ -2649,6 +2671,8 @@ private constructor( fun visitMinimum(minimum: NewFloatingMinimumCompositePrice): T + fun visitPercent(percent: Percent): T + fun visitEventOutput(eventOutput: EventOutput): T /** @@ -2870,6 +2894,11 @@ private constructor( ) ?.let { Price(minimum = it, _json = json) } ?: Price(_json = json) } + "percent" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(percent = it, _json = json) + } ?: Price(_json = json) + } "event_output" -> { return tryDeserialize(node, jacksonTypeRef())?.let { Price(eventOutput = it, _json = json) @@ -2935,6 +2964,7 @@ private constructor( value.cumulativeGroupedBulk != null -> generator.writeObject(value.cumulativeGroupedBulk) value.minimum != null -> generator.writeObject(value.minimum) + value.percent != null -> generator.writeObject(value.percent) value.eventOutput != null -> generator.writeObject(value.eventOutput) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid Price") @@ -4590,6 +4620,1471 @@ private constructor( "GroupedWithMinMaxThresholds{cadence=$cadence, currency=$currency, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" } + class Percent + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val currency: JsonField, + private val itemId: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val percentConfig: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val metadata: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("percent_config") + @ExcludeMissing + percentConfig: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + ) : this( + cadence, + currency, + itemId, + modelType, + name, + percentConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * An ISO 4217 currency string for which this price is billed in. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("percent") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * Configuration for percent pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun percentConfig(): PercentConfig = percentConfig.getRequired("percent_config") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = billableMetricId.getNullable("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + invoiceGroupingKey.getNullable("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [percentConfig]. + * + * Unlike [percentConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("percent_config") + @ExcludeMissing + fun _percentConfig(): JsonField = percentConfig + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Percent]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .currency() + * .itemId() + * .name() + * .percentConfig() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Percent]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var currency: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonValue = JsonValue.from("percent") + private var name: JsonField? = null + private var percentConfig: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(percent: Percent) = apply { + cadence = percent.cadence + currency = percent.currency + itemId = percent.itemId + modelType = percent.modelType + name = percent.name + percentConfig = percent.percentConfig + billableMetricId = percent.billableMetricId + billedInAdvance = percent.billedInAdvance + billingCycleConfiguration = percent.billingCycleConfiguration + conversionRate = percent.conversionRate + conversionRateConfig = percent.conversionRateConfig + dimensionalPriceConfiguration = percent.dimensionalPriceConfiguration + externalPriceId = percent.externalPriceId + fixedPriceQuantity = percent.fixedPriceQuantity + invoiceGroupingKey = percent.invoiceGroupingKey + invoicingCycleConfiguration = percent.invoicingCycleConfiguration + metadata = percent.metadata + additionalProperties = percent.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("percent") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for percent pricing */ + fun percentConfig(percentConfig: PercentConfig) = + percentConfig(JsonField.of(percentConfig)) + + /** + * Sets [Builder.percentConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.percentConfig] with a well-typed + * [PercentConfig] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun percentConfig(percentConfig: JsonField) = apply { + this.percentConfig = percentConfig + } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Percent]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .currency() + * .itemId() + * .name() + * .percentConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Percent = + Percent( + checkRequired("cadence", cadence), + checkRequired("currency", currency), + checkRequired("itemId", itemId), + modelType, + checkRequired("name", name), + checkRequired("percentConfig", percentConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Percent = apply { + if (validated) { + return@apply + } + + cadence().validate() + currency() + itemId() + _modelType().let { + if (it != JsonValue.from("percent")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + percentConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + metadata()?.validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (if (itemId.asKnown() == null) 0 else 1) + + modelType.let { if (it == JsonValue.from("percent")) 1 else 0 } + + (if (name.asKnown() == null) 0 else 1) + + (percentConfig.asKnown()?.validity() ?: 0) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (metadata.asKnown()?.validity() ?: 0) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Configuration for percent pricing */ + class PercentConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val percent: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("percent") + @ExcludeMissing + percent: JsonField = JsonMissing.of() + ) : this(percent, mutableMapOf()) + + /** + * What percent of the component subtotals to charge + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun percent(): Double = percent.getRequired("percent") + + /** + * Returns the raw JSON value of [percent]. + * + * Unlike [percent], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("percent") + @ExcludeMissing + fun _percent(): JsonField = percent + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [PercentConfig]. + * + * The following fields are required: + * ```kotlin + * .percent() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [PercentConfig]. */ + class Builder internal constructor() { + + private var percent: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(percentConfig: PercentConfig) = apply { + percent = percentConfig.percent + additionalProperties = percentConfig.additionalProperties.toMutableMap() + } + + /** What percent of the component subtotals to charge */ + fun percent(percent: Double) = percent(JsonField.of(percent)) + + /** + * Sets [Builder.percent] to an arbitrary JSON value. + * + * You should usually call [Builder.percent] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun percent(percent: JsonField) = apply { this.percent = percent } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [PercentConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .percent() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): PercentConfig = + PercentConfig( + checkRequired("percent", percent), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): PercentConfig = apply { + if (validated) { + return@apply + } + + percent() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = (if (percent.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PercentConfig && + percent == other.percent && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(percent, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "PercentConfig{percent=$percent, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Percent && + cadence == other.cadence && + currency == other.currency && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + percentConfig == other.percentConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + currency, + itemId, + modelType, + name, + percentConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Percent{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, percentConfig=$percentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + } + class EventOutput @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceInterval.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceInterval.kt index 7f415be7c..ade43a3ef 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceInterval.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceInterval.kt @@ -601,6 +601,9 @@ private constructor( /** Alias for calling [price] with `Price.ofMinimum(minimum)`. */ fun price(minimum: Price.Minimum) = price(Price.ofMinimum(minimum)) + /** Alias for calling [price] with `Price.ofPercent(percent)`. */ + fun price(percent: Price.Percent) = price(Price.ofPercent(percent)) + /** Alias for calling [price] with `Price.ofEventOutput(eventOutput)`. */ fun price(eventOutput: Price.EventOutput) = price(Price.ofEventOutput(eventOutput)) diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceListPageResponse.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceListPageResponse.kt index 0711bf958..6148f8988 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceListPageResponse.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceListPageResponse.kt @@ -261,6 +261,9 @@ private constructor( /** Alias for calling [addData] with `Price.ofMinimum(minimum)`. */ fun addData(minimum: Price.Minimum) = addData(Price.ofMinimum(minimum)) + /** Alias for calling [addData] with `Price.ofPercent(percent)`. */ + fun addData(percent: Price.Percent) = addData(Price.ofPercent(percent)) + /** Alias for calling [addData] with `Price.ofEventOutput(eventOutput)`. */ fun addData(eventOutput: Price.EventOutput) = addData(Price.ofEventOutput(eventOutput)) diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionCreateParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionCreateParams.kt index 27b2040c9..4f8d53f8a 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionCreateParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionCreateParams.kt @@ -4698,6 +4698,9 @@ private constructor( fun price(minimum: NewSubscriptionMinimumCompositePrice) = price(Price.ofMinimum(minimum)) + /** Alias for calling [price] with `Price.ofPercent(percent)`. */ + fun price(percent: Price.Percent) = price(Price.ofPercent(percent)) + /** Alias for calling [price] with `Price.ofEventOutput(eventOutput)`. */ fun price(eventOutput: Price.EventOutput) = price(Price.ofEventOutput(eventOutput)) @@ -4857,6 +4860,7 @@ private constructor( null, private val cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice? = null, private val minimum: NewSubscriptionMinimumCompositePrice? = null, + private val percent: Percent? = null, private val eventOutput: EventOutput? = null, private val _json: JsonValue? = null, ) { @@ -4929,6 +4933,8 @@ private constructor( fun minimum(): NewSubscriptionMinimumCompositePrice? = minimum + fun percent(): Percent? = percent + fun eventOutput(): EventOutput? = eventOutput fun isUnit(): Boolean = unit != null @@ -4986,6 +4992,8 @@ private constructor( fun isMinimum(): Boolean = minimum != null + fun isPercent(): Boolean = percent != null + fun isEventOutput(): Boolean = eventOutput != null fun asUnit(): NewSubscriptionUnitPrice = unit.getOrThrow("unit") @@ -5065,6 +5073,8 @@ private constructor( fun asMinimum(): NewSubscriptionMinimumCompositePrice = minimum.getOrThrow("minimum") + fun asPercent(): Percent = percent.getOrThrow("percent") + fun asEventOutput(): EventOutput = eventOutput.getOrThrow("eventOutput") fun _json(): JsonValue? = _json @@ -5114,6 +5124,7 @@ private constructor( cumulativeGroupedBulk != null -> visitor.visitCumulativeGroupedBulk(cumulativeGroupedBulk) minimum != null -> visitor.visitMinimum(minimum) + percent != null -> visitor.visitPercent(percent) eventOutput != null -> visitor.visitEventOutput(eventOutput) else -> visitor.unknown(_json) } @@ -5280,6 +5291,10 @@ private constructor( minimum.validate() } + override fun visitPercent(percent: Percent) { + percent.validate() + } + override fun visitEventOutput(eventOutput: EventOutput) { eventOutput.validate() } @@ -5408,6 +5423,8 @@ private constructor( override fun visitMinimum(minimum: NewSubscriptionMinimumCompositePrice) = minimum.validity() + override fun visitPercent(percent: Percent) = percent.validity() + override fun visitEventOutput(eventOutput: EventOutput) = eventOutput.validity() @@ -5448,6 +5465,7 @@ private constructor( scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && cumulativeGroupedBulk == other.cumulativeGroupedBulk && minimum == other.minimum && + percent == other.percent && eventOutput == other.eventOutput } @@ -5480,6 +5498,7 @@ private constructor( scalableMatrixWithTieredPricing, cumulativeGroupedBulk, minimum, + percent, eventOutput, ) @@ -5525,6 +5544,7 @@ private constructor( cumulativeGroupedBulk != null -> "Price{cumulativeGroupedBulk=$cumulativeGroupedBulk}" minimum != null -> "Price{minimum=$minimum}" + percent != null -> "Price{percent=$percent}" eventOutput != null -> "Price{eventOutput=$eventOutput}" _json != null -> "Price{_unknown=$_json}" else -> throw IllegalStateException("Invalid Price") @@ -5622,6 +5642,8 @@ private constructor( fun ofMinimum(minimum: NewSubscriptionMinimumCompositePrice) = Price(minimum = minimum) + fun ofPercent(percent: Percent) = Price(percent = percent) + fun ofEventOutput(eventOutput: EventOutput) = Price(eventOutput = eventOutput) } @@ -5719,6 +5741,8 @@ private constructor( fun visitMinimum(minimum: NewSubscriptionMinimumCompositePrice): T + fun visitPercent(percent: Percent): T + fun visitEventOutput(eventOutput: EventOutput): T /** @@ -5948,6 +5972,11 @@ private constructor( ) ?.let { Price(minimum = it, _json = json) } ?: Price(_json = json) } + "percent" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(percent = it, _json = json) + } ?: Price(_json = json) + } "event_output" -> { return tryDeserialize(node, jacksonTypeRef())?.let { Price(eventOutput = it, _json = json) @@ -6013,6 +6042,7 @@ private constructor( value.cumulativeGroupedBulk != null -> generator.writeObject(value.cumulativeGroupedBulk) value.minimum != null -> generator.writeObject(value.minimum) + value.percent != null -> generator.writeObject(value.percent) value.eventOutput != null -> generator.writeObject(value.eventOutput) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid Price") @@ -9487,14 +9517,14 @@ private constructor( "GroupedWithMinMaxThresholds{cadence=$cadence, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class EventOutput + class Percent @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, - private val eventOutputConfig: JsonField, private val itemId: JsonField, private val modelType: JsonValue, private val name: JsonField, + private val percentConfig: JsonField, private val billableMetricId: JsonField, private val billedInAdvance: JsonField, private val billingCycleConfiguration: JsonField, @@ -9517,9 +9547,6 @@ private constructor( @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), - @JsonProperty("event_output_config") - @ExcludeMissing - eventOutputConfig: JsonField = JsonMissing.of(), @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), @@ -9529,6 +9556,9 @@ private constructor( @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("percent_config") + @ExcludeMissing + percentConfig: JsonField = JsonMissing.of(), @JsonProperty("billable_metric_id") @ExcludeMissing billableMetricId: JsonField = JsonMissing.of(), @@ -9573,10 +9603,10 @@ private constructor( referenceId: JsonField = JsonMissing.of(), ) : this( cadence, - eventOutputConfig, itemId, modelType, name, + percentConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -9602,16 +9632,6 @@ private constructor( */ fun cadence(): Cadence = cadence.getRequired("cadence") - /** - * Configuration for event_output pricing - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun eventOutputConfig(): EventOutputConfig = - eventOutputConfig.getRequired("event_output_config") - /** * The id of the item the price will be associated with. * @@ -9626,7 +9646,7 @@ private constructor( * * Expected to always return the following: * ```kotlin - * JsonValue.from("event_output") + * JsonValue.from("percent") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -9643,6 +9663,15 @@ private constructor( */ fun name(): String = name.getRequired("name") + /** + * Configuration for percent pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun percentConfig(): PercentConfig = percentConfig.getRequired("percent_config") + /** * The id of the billable metric for the price. Only needed if the price is * usage-based. @@ -9772,16 +9801,6 @@ private constructor( @ExcludeMissing fun _cadence(): JsonField = cadence - /** - * Returns the raw JSON value of [eventOutputConfig]. - * - * Unlike [eventOutputConfig], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("event_output_config") - @ExcludeMissing - fun _eventOutputConfig(): JsonField = eventOutputConfig - /** * Returns the raw JSON value of [itemId]. * @@ -9798,6 +9817,16 @@ private constructor( */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + /** + * Returns the raw JSON value of [percentConfig]. + * + * Unlike [percentConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("percent_config") + @ExcludeMissing + fun _percentConfig(): JsonField = percentConfig + /** * Returns the raw JSON value of [billableMetricId]. * @@ -9946,27 +9975,27 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [EventOutput]. + * Returns a mutable builder for constructing an instance of [Percent]. * * The following fields are required: * ```kotlin * .cadence() - * .eventOutputConfig() * .itemId() * .name() + * .percentConfig() * ``` */ fun builder() = Builder() } - /** A builder for [EventOutput]. */ + /** A builder for [Percent]. */ class Builder internal constructor() { private var cadence: JsonField? = null - private var eventOutputConfig: JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonValue = JsonValue.from("event_output") + private var modelType: JsonValue = JsonValue.from("percent") private var name: JsonField? = null + private var percentConfig: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() private var billingCycleConfiguration: JsonField = @@ -9988,26 +10017,26 @@ private constructor( private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(eventOutput: EventOutput) = apply { - cadence = eventOutput.cadence - eventOutputConfig = eventOutput.eventOutputConfig - itemId = eventOutput.itemId - modelType = eventOutput.modelType - name = eventOutput.name - billableMetricId = eventOutput.billableMetricId - billedInAdvance = eventOutput.billedInAdvance - billingCycleConfiguration = eventOutput.billingCycleConfiguration - conversionRate = eventOutput.conversionRate - conversionRateConfig = eventOutput.conversionRateConfig - currency = eventOutput.currency - dimensionalPriceConfiguration = eventOutput.dimensionalPriceConfiguration - externalPriceId = eventOutput.externalPriceId - fixedPriceQuantity = eventOutput.fixedPriceQuantity - invoiceGroupingKey = eventOutput.invoiceGroupingKey - invoicingCycleConfiguration = eventOutput.invoicingCycleConfiguration - metadata = eventOutput.metadata - referenceId = eventOutput.referenceId - additionalProperties = eventOutput.additionalProperties.toMutableMap() + internal fun from(percent: Percent) = apply { + cadence = percent.cadence + itemId = percent.itemId + modelType = percent.modelType + name = percent.name + percentConfig = percent.percentConfig + billableMetricId = percent.billableMetricId + billedInAdvance = percent.billedInAdvance + billingCycleConfiguration = percent.billingCycleConfiguration + conversionRate = percent.conversionRate + conversionRateConfig = percent.conversionRateConfig + currency = percent.currency + dimensionalPriceConfiguration = percent.dimensionalPriceConfiguration + externalPriceId = percent.externalPriceId + fixedPriceQuantity = percent.fixedPriceQuantity + invoiceGroupingKey = percent.invoiceGroupingKey + invoicingCycleConfiguration = percent.invoicingCycleConfiguration + metadata = percent.metadata + referenceId = percent.referenceId + additionalProperties = percent.additionalProperties.toMutableMap() } /** The cadence to bill for this price on. */ @@ -10022,21 +10051,6 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - /** Configuration for event_output pricing */ - fun eventOutputConfig(eventOutputConfig: EventOutputConfig) = - eventOutputConfig(JsonField.of(eventOutputConfig)) - - /** - * Sets [Builder.eventOutputConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.eventOutputConfig] with a well-typed - * [EventOutputConfig] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun eventOutputConfig(eventOutputConfig: JsonField) = apply { - this.eventOutputConfig = eventOutputConfig - } - /** The id of the item the price will be associated with. */ fun itemId(itemId: String) = itemId(JsonField.of(itemId)) @@ -10055,7 +10069,7 @@ private constructor( * It is usually unnecessary to call this method because the field defaults to * the following: * ```kotlin - * JsonValue.from("event_output") + * JsonValue.from("percent") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -10075,6 +10089,21 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } + /** Configuration for percent pricing */ + fun percentConfig(percentConfig: PercentConfig) = + percentConfig(JsonField.of(percentConfig)) + + /** + * Sets [Builder.percentConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.percentConfig] with a well-typed + * [PercentConfig] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun percentConfig(percentConfig: JsonField) = apply { + this.percentConfig = percentConfig + } + /** * The id of the billable metric for the price. Only needed if the price is * usage-based. @@ -10404,27 +10433,27 @@ private constructor( } /** - * Returns an immutable instance of [EventOutput]. + * Returns an immutable instance of [Percent]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```kotlin * .cadence() - * .eventOutputConfig() * .itemId() * .name() + * .percentConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): EventOutput = - EventOutput( + fun build(): Percent = + Percent( checkRequired("cadence", cadence), - checkRequired("eventOutputConfig", eventOutputConfig), checkRequired("itemId", itemId), modelType, checkRequired("name", name), + checkRequired("percentConfig", percentConfig), billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -10444,20 +10473,20 @@ private constructor( private var validated: Boolean = false - fun validate(): EventOutput = apply { + fun validate(): Percent = apply { if (validated) { return@apply } cadence().validate() - eventOutputConfig().validate() itemId() _modelType().let { - if (it != JsonValue.from("event_output")) { + if (it != JsonValue.from("percent")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } name() + percentConfig().validate() billableMetricId() billedInAdvance() billingCycleConfiguration()?.validate() @@ -10490,10 +10519,10 @@ private constructor( */ internal fun validity(): Int = (cadence.asKnown()?.validity() ?: 0) + - (eventOutputConfig.asKnown()?.validity() ?: 0) + (if (itemId.asKnown() == null) 0 else 1) + - modelType.let { if (it == JsonValue.from("event_output")) 1 else 0 } + + modelType.let { if (it == JsonValue.from("percent")) 1 else 0 } + (if (name.asKnown() == null) 0 else 1) + + (percentConfig.asKnown()?.validity() ?: 0) + (if (billableMetricId.asKnown() == null) 0 else 1) + (if (billedInAdvance.asKnown() == null) 0 else 1) + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + @@ -10665,62 +10694,39 @@ private constructor( override fun toString() = value.toString() } - /** Configuration for event_output pricing */ - class EventOutputConfig + /** Configuration for percent pricing */ + class PercentConfig @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val unitRatingKey: JsonField, - private val groupingKey: JsonField, + private val percent: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("unit_rating_key") - @ExcludeMissing - unitRatingKey: JsonField = JsonMissing.of(), - @JsonProperty("grouping_key") + @JsonProperty("percent") @ExcludeMissing - groupingKey: JsonField = JsonMissing.of(), - ) : this(unitRatingKey, groupingKey, mutableMapOf()) + percent: JsonField = JsonMissing.of() + ) : this(percent, mutableMapOf()) /** - * The key in the event data to extract the unit rate from. + * What percent of the component subtotals to charge * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). */ - fun unitRatingKey(): String = unitRatingKey.getRequired("unit_rating_key") - - /** - * An optional key in the event data to group by (e.g., event ID). All events - * will also be grouped by their unit rate. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun groupingKey(): String? = groupingKey.getNullable("grouping_key") - - /** - * Returns the raw JSON value of [unitRatingKey]. - * - * Unlike [unitRatingKey], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("unit_rating_key") - @ExcludeMissing - fun _unitRatingKey(): JsonField = unitRatingKey + fun percent(): Double = percent.getRequired("percent") /** - * Returns the raw JSON value of [groupingKey]. + * Returns the raw JSON value of [percent]. * - * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * Unlike [percent], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("grouping_key") + @JsonProperty("percent") @ExcludeMissing - fun _groupingKey(): JsonField = groupingKey + fun _percent(): JsonField = percent @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -10738,63 +10744,39 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [EventOutputConfig]. + * [PercentConfig]. * * The following fields are required: * ```kotlin - * .unitRatingKey() + * .percent() * ``` */ fun builder() = Builder() } - /** A builder for [EventOutputConfig]. */ + /** A builder for [PercentConfig]. */ class Builder internal constructor() { - private var unitRatingKey: JsonField? = null - private var groupingKey: JsonField = JsonMissing.of() + private var percent: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(eventOutputConfig: EventOutputConfig) = apply { - unitRatingKey = eventOutputConfig.unitRatingKey - groupingKey = eventOutputConfig.groupingKey - additionalProperties = - eventOutputConfig.additionalProperties.toMutableMap() - } - - /** The key in the event data to extract the unit rate from. */ - fun unitRatingKey(unitRatingKey: String) = - unitRatingKey(JsonField.of(unitRatingKey)) - - /** - * Sets [Builder.unitRatingKey] to an arbitrary JSON value. - * - * You should usually call [Builder.unitRatingKey] with a well-typed - * [String] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun unitRatingKey(unitRatingKey: JsonField) = apply { - this.unitRatingKey = unitRatingKey + internal fun from(percentConfig: PercentConfig) = apply { + percent = percentConfig.percent + additionalProperties = percentConfig.additionalProperties.toMutableMap() } - /** - * An optional key in the event data to group by (e.g., event ID). All - * events will also be grouped by their unit rate. - */ - fun groupingKey(groupingKey: String?) = - groupingKey(JsonField.ofNullable(groupingKey)) + /** What percent of the component subtotals to charge */ + fun percent(percent: Double) = percent(JsonField.of(percent)) /** - * Sets [Builder.groupingKey] to an arbitrary JSON value. + * Sets [Builder.percent] to an arbitrary JSON value. * - * You should usually call [Builder.groupingKey] with a well-typed [String] + * You should usually call [Builder.percent] with a well-typed [Double] * value instead. This method is primarily for setting the field to an * undocumented or not yet supported value. */ - fun groupingKey(groupingKey: JsonField) = apply { - this.groupingKey = groupingKey - } + fun percent(percent: JsonField) = apply { this.percent = percent } fun additionalProperties(additionalProperties: Map) = apply { @@ -10819,34 +10801,32 @@ private constructor( } /** - * Returns an immutable instance of [EventOutputConfig]. + * Returns an immutable instance of [PercentConfig]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```kotlin - * .unitRatingKey() + * .percent() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): EventOutputConfig = - EventOutputConfig( - checkRequired("unitRatingKey", unitRatingKey), - groupingKey, + fun build(): PercentConfig = + PercentConfig( + checkRequired("percent", percent), additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): EventOutputConfig = apply { + fun validate(): PercentConfig = apply { if (validated) { return@apply } - unitRatingKey() - groupingKey() + percent() validated = true } @@ -10864,29 +10844,26 @@ private constructor( * * Used for best match union deserialization. */ - internal fun validity(): Int = - (if (unitRatingKey.asKnown() == null) 0 else 1) + - (if (groupingKey.asKnown() == null) 0 else 1) + internal fun validity(): Int = (if (percent.asKnown() == null) 0 else 1) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is EventOutputConfig && - unitRatingKey == other.unitRatingKey && - groupingKey == other.groupingKey && + return other is PercentConfig && + percent == other.percent && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(unitRatingKey, groupingKey, additionalProperties) + Objects.hash(percent, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "EventOutputConfig{unitRatingKey=$unitRatingKey, groupingKey=$groupingKey, additionalProperties=$additionalProperties}" + "PercentConfig{percent=$percent, additionalProperties=$additionalProperties}" } /** @@ -11003,12 +10980,12 @@ private constructor( return true } - return other is EventOutput && + return other is Percent && cadence == other.cadence && - eventOutputConfig == other.eventOutputConfig && itemId == other.itemId && modelType == other.modelType && name == other.name && + percentConfig == other.percentConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && @@ -11028,10 +11005,10 @@ private constructor( private val hashCode: Int by lazy { Objects.hash( cadence, - eventOutputConfig, itemId, modelType, name, + percentConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -11052,1421 +11029,1888 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "EventOutput{cadence=$cadence, eventOutputConfig=$eventOutputConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + "Percent{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, percentConfig=$percentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - return other is AddPrice && - allocationPrice == other.allocationPrice && - discounts == other.discounts && - endDate == other.endDate && - externalPriceId == other.externalPriceId && - maximumAmount == other.maximumAmount && - minimumAmount == other.minimumAmount && - planPhaseOrder == other.planPhaseOrder && - price == other.price && - priceId == other.priceId && - startDate == other.startDate && - additionalProperties == other.additionalProperties - } + class EventOutput + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val eventOutputConfig: JsonField, + private val itemId: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { - private val hashCode: Int by lazy { - Objects.hash( - allocationPrice, - discounts, - endDate, - externalPriceId, - maximumAmount, - minimumAmount, - planPhaseOrder, - price, - priceId, - startDate, - additionalProperties, - ) - } + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("event_output_config") + @ExcludeMissing + eventOutputConfig: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + eventOutputConfig, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + mutableMapOf(), + ) - override fun hashCode(): Int = hashCode + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") - override fun toString() = - "AddPrice{allocationPrice=$allocationPrice, discounts=$discounts, endDate=$endDate, externalPriceId=$externalPriceId, maximumAmount=$maximumAmount, minimumAmount=$minimumAmount, planPhaseOrder=$planPhaseOrder, price=$price, priceId=$priceId, startDate=$startDate, additionalProperties=$additionalProperties}" - } + /** + * Configuration for event_output pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun eventOutputConfig(): EventOutputConfig = + eventOutputConfig.getRequired("event_output_config") - @Deprecated("deprecated") - class ExternalMarketplace - @JsonCreator - private constructor(private val value: JsonField) : Enum { + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API may respond with new members that the SDK is - * unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("event_output") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType - companion object { + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") - val GOOGLE = of("google") + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = billableMetricId.getNullable("billable_metric_id") - val AWS = of("aws") + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") - val AZURE = of("azure") + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") - fun of(value: String) = ExternalMarketplace(JsonField.of(value)) - } + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") - /** An enum containing [ExternalMarketplace]'s known values. */ - enum class Known { - GOOGLE, - AWS, - AZURE, - } + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") - /** - * An enum containing [ExternalMarketplace]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [ExternalMarketplace] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if the - * SDK is on an older version than the API, then the API may respond with new members that - * the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - GOOGLE, - AWS, - AZURE, - /** - * An enum member indicating that [ExternalMarketplace] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") - /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you want - * to throw for the unknown case. - */ - fun value(): Value = - when (this) { - GOOGLE -> Value.GOOGLE - AWS -> Value.AWS - AZURE -> Value.AZURE - else -> Value._UNKNOWN - } + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and don't - * want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known member. - */ - fun known(): Known = - when (this) { - GOOGLE -> Known.GOOGLE - AWS -> Known.AWS - AZURE -> Known.AZURE - else -> throw OrbInvalidDataException("Unknown ExternalMarketplace: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the expected - * primitive type. - */ - fun asString(): String = - _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") - private var validated: Boolean = false + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") - fun validate(): ExternalMarketplace = apply { - if (validated) { - return@apply - } + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + invoiceGroupingKey.getNullable("invoice_grouping_key") - known() - validated = true - } + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence - return other is ExternalMarketplace && value == other.value - } + /** + * Returns the raw JSON value of [eventOutputConfig]. + * + * Unlike [eventOutputConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("event_output_config") + @ExcludeMissing + fun _eventOutputConfig(): JsonField = eventOutputConfig - override fun hashCode() = value.hashCode() + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - override fun toString() = value.toString() - } + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by setting - * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to - * `null`. - */ - class Metadata - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance - fun toBuilder() = Builder().from(this) + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration - companion object { + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate - /** Returns a mutable builder for constructing an instance of [Metadata]. */ - fun builder() = Builder() - } + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig - /** A builder for [Metadata]. */ - class Builder internal constructor() { + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency - private var additionalProperties: MutableMap = mutableMapOf() + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration - internal fun from(metadata: Metadata) = apply { - additionalProperties = metadata.additionalProperties.toMutableMap() - } + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId - /** - * Returns an immutable instance of [Metadata]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - private var validated: Boolean = false + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - fun validate(): Metadata = apply { - if (validated) { - return@apply - } + fun toBuilder() = Builder().from(this) - validated = true - } + companion object { - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** + * Returns a mutable builder for constructing an instance of [EventOutput]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .eventOutputConfig() + * .itemId() + * .name() + * ``` + */ + fun builder() = Builder() + } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + /** A builder for [EventOutput]. */ + class Builder internal constructor() { - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + private var cadence: JsonField? = null + private var eventOutputConfig: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonValue = JsonValue.from("event_output") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - return other is Metadata && additionalProperties == other.additionalProperties - } + internal fun from(eventOutput: EventOutput) = apply { + cadence = eventOutput.cadence + eventOutputConfig = eventOutput.eventOutputConfig + itemId = eventOutput.itemId + modelType = eventOutput.modelType + name = eventOutput.name + billableMetricId = eventOutput.billableMetricId + billedInAdvance = eventOutput.billedInAdvance + billingCycleConfiguration = eventOutput.billingCycleConfiguration + conversionRate = eventOutput.conversionRate + conversionRateConfig = eventOutput.conversionRateConfig + currency = eventOutput.currency + dimensionalPriceConfiguration = eventOutput.dimensionalPriceConfiguration + externalPriceId = eventOutput.externalPriceId + fixedPriceQuantity = eventOutput.fixedPriceQuantity + invoiceGroupingKey = eventOutput.invoiceGroupingKey + invoicingCycleConfiguration = eventOutput.invoicingCycleConfiguration + metadata = eventOutput.metadata + referenceId = eventOutput.referenceId + additionalProperties = eventOutput.additionalProperties.toMutableMap() + } - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - override fun hashCode(): Int = hashCode + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } + /** Configuration for event_output pricing */ + fun eventOutputConfig(eventOutputConfig: EventOutputConfig) = + eventOutputConfig(JsonField.of(eventOutputConfig)) - class RemoveAdjustment - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val adjustmentId: JsonField, - private val additionalProperties: MutableMap, - ) { + /** + * Sets [Builder.eventOutputConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.eventOutputConfig] with a well-typed + * [EventOutputConfig] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun eventOutputConfig(eventOutputConfig: JsonField) = apply { + this.eventOutputConfig = eventOutputConfig + } - @JsonCreator - private constructor( - @JsonProperty("adjustment_id") - @ExcludeMissing - adjustmentId: JsonField = JsonMissing.of() - ) : this(adjustmentId, mutableMapOf()) + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - /** - * The id of the adjustment to remove on the subscription. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun adjustmentId(): String = adjustmentId.getRequired("adjustment_id") + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - /** - * Returns the raw JSON value of [adjustmentId]. - * - * Unlike [adjustmentId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("adjustment_id") - @ExcludeMissing - fun _adjustmentId(): JsonField = adjustmentId + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("event_output") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } - fun toBuilder() = Builder().from(this) + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) - companion object { + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } - /** - * Returns a mutable builder for constructing an instance of [RemoveAdjustment]. - * - * The following fields are required: - * ```kotlin - * .adjustmentId() - * ``` - */ - fun builder() = Builder() - } - - /** A builder for [RemoveAdjustment]. */ - class Builder internal constructor() { - - private var adjustmentId: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) - internal fun from(removeAdjustment: RemoveAdjustment) = apply { - adjustmentId = removeAdjustment.adjustmentId - additionalProperties = removeAdjustment.additionalProperties.toMutableMap() - } + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) - /** The id of the adjustment to remove on the subscription. */ - fun adjustmentId(adjustmentId: String) = adjustmentId(JsonField.of(adjustmentId)) + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } - /** - * Sets [Builder.adjustmentId] to an arbitrary JSON value. - * - * You should usually call [Builder.adjustmentId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun adjustmentId(adjustmentId: JsonField) = apply { - this.adjustmentId = adjustmentId - } + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) - /** - * Returns an immutable instance of [RemoveAdjustment]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```kotlin - * .adjustmentId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): RemoveAdjustment = - RemoveAdjustment( - checkRequired("adjustmentId", adjustmentId), - additionalProperties.toMutableMap(), - ) - } + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } - private var validated: Boolean = false + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) - fun validate(): RemoveAdjustment = apply { - if (validated) { - return@apply - } + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) - adjustmentId() - validated = true - } + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = (if (adjustmentId.asKnown() == null) 0 else 1) + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } - return other is RemoveAdjustment && - adjustmentId == other.adjustmentId && - additionalProperties == other.additionalProperties - } + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) - private val hashCode: Int by lazy { Objects.hash(adjustmentId, additionalProperties) } + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } - override fun hashCode(): Int = hashCode + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) - override fun toString() = - "RemoveAdjustment{adjustmentId=$adjustmentId, additionalProperties=$additionalProperties}" - } - - class RemovePrice - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val externalPriceId: JsonField, - private val priceId: JsonField, - private val additionalProperties: MutableMap, - ) { + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } - @JsonCreator - private constructor( - @JsonProperty("external_price_id") - @ExcludeMissing - externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("price_id") @ExcludeMissing priceId: JsonField = JsonMissing.of(), - ) : this(externalPriceId, priceId, mutableMapOf()) + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) - /** - * The external price id of the price to remove on the subscription. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) - /** - * The id of the price to remove on the subscription. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun priceId(): String? = priceId.getNullable("price_id") + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } - /** - * Returns the raw JSON value of [externalPriceId]. - * - * Unlike [externalPriceId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) - /** - * Returns the raw JSON value of [priceId]. - * - * Unlike [priceId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - fun toBuilder() = Builder().from(this) + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - companion object { + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - /** Returns a mutable builder for constructing an instance of [RemovePrice]. */ - fun builder() = Builder() - } + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) - /** A builder for [RemovePrice]. */ - class Builder internal constructor() { + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } - private var externalPriceId: JsonField = JsonMissing.of() - private var priceId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - internal fun from(removePrice: RemovePrice) = apply { - externalPriceId = removePrice.externalPriceId - priceId = removePrice.priceId - additionalProperties = removePrice.additionalProperties.toMutableMap() - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** The external price id of the price to remove on the subscription. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - /** - * Sets [Builder.externalPriceId] to an arbitrary JSON value. - * - * You should usually call [Builder.externalPriceId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun externalPriceId(externalPriceId: JsonField) = apply { - this.externalPriceId = externalPriceId - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - /** The id of the price to remove on the subscription. */ - fun priceId(priceId: String?) = priceId(JsonField.ofNullable(priceId)) + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - /** - * Sets [Builder.priceId] to an arbitrary JSON value. - * - * You should usually call [Builder.priceId] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun priceId(priceId: JsonField) = apply { this.priceId = priceId } + /** + * Returns an immutable instance of [EventOutput]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .eventOutputConfig() + * .itemId() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): EventOutput = + EventOutput( + checkRequired("cadence", cadence), + checkRequired("eventOutputConfig", eventOutputConfig), + checkRequired("itemId", itemId), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + private var validated: Boolean = false - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun validate(): EventOutput = apply { + if (validated) { + return@apply + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + cadence().validate() + eventOutputConfig().validate() + itemId() + _modelType().let { + if (it != JsonValue.from("event_output")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + metadata()?.validate() + referenceId() + validated = true + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (eventOutputConfig.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + modelType.let { if (it == JsonValue.from("event_output")) 1 else 0 } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) - /** - * Returns an immutable instance of [RemovePrice]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): RemovePrice = - RemovePrice(externalPriceId, priceId, additionalProperties.toMutableMap()) - } + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { - private var validated: Boolean = false + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value - fun validate(): RemovePrice = apply { - if (validated) { - return@apply - } + companion object { - externalPriceId() - priceId() - validated = true - } + val ANNUAL = of("annual") - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + val SEMI_ANNUAL = of("semi_annual") - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (if (externalPriceId.asKnown() == null) 0 else 1) + - (if (priceId.asKnown() == null) 0 else 1) + val MONTHLY = of("monthly") - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + val QUARTERLY = of("quarterly") - return other is RemovePrice && - externalPriceId == other.externalPriceId && - priceId == other.priceId && - additionalProperties == other.additionalProperties - } + val ONE_TIME = of("one_time") - private val hashCode: Int by lazy { - Objects.hash(externalPriceId, priceId, additionalProperties) - } + val CUSTOM = of("custom") - override fun hashCode(): Int = hashCode + fun of(value: String) = Cadence(JsonField.of(value)) + } - override fun toString() = - "RemovePrice{externalPriceId=$externalPriceId, priceId=$priceId, additionalProperties=$additionalProperties}" - } + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } - class ReplaceAdjustment - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val adjustment: JsonField, - private val replacesAdjustmentId: JsonField, - private val additionalProperties: MutableMap, - ) { + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } - @JsonCreator - private constructor( - @JsonProperty("adjustment") - @ExcludeMissing - adjustment: JsonField = JsonMissing.of(), - @JsonProperty("replaces_adjustment_id") - @ExcludeMissing - replacesAdjustmentId: JsonField = JsonMissing.of(), - ) : this(adjustment, replacesAdjustmentId, mutableMapOf()) + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } - /** - * The definition of a new adjustment to create and add to the subscription. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun adjustment(): Adjustment = adjustment.getRequired("adjustment") + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } - /** - * The id of the adjustment on the plan to replace in the subscription. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun replacesAdjustmentId(): String = - replacesAdjustmentId.getRequired("replaces_adjustment_id") + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") - /** - * Returns the raw JSON value of [adjustment]. - * - * Unlike [adjustment], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("adjustment") - @ExcludeMissing - fun _adjustment(): JsonField = adjustment + private var validated: Boolean = false - /** - * Returns the raw JSON value of [replacesAdjustmentId]. - * - * Unlike [replacesAdjustmentId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("replaces_adjustment_id") - @ExcludeMissing - fun _replacesAdjustmentId(): JsonField = replacesAdjustmentId - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + fun validate(): Cadence = apply { + if (validated) { + return@apply + } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + known() + validated = true + } - fun toBuilder() = Builder().from(this) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - companion object { + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - /** - * Returns a mutable builder for constructing an instance of [ReplaceAdjustment]. - * - * The following fields are required: - * ```kotlin - * .adjustment() - * .replacesAdjustmentId() - * ``` - */ - fun builder() = Builder() - } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** A builder for [ReplaceAdjustment]. */ - class Builder internal constructor() { + return other is Cadence && value == other.value + } - private var adjustment: JsonField? = null - private var replacesAdjustmentId: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() + override fun hashCode() = value.hashCode() - internal fun from(replaceAdjustment: ReplaceAdjustment) = apply { - adjustment = replaceAdjustment.adjustment - replacesAdjustmentId = replaceAdjustment.replacesAdjustmentId - additionalProperties = replaceAdjustment.additionalProperties.toMutableMap() - } + override fun toString() = value.toString() + } - /** The definition of a new adjustment to create and add to the subscription. */ - fun adjustment(adjustment: Adjustment) = adjustment(JsonField.of(adjustment)) + /** Configuration for event_output pricing */ + class EventOutputConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val unitRatingKey: JsonField, + private val groupingKey: JsonField, + private val additionalProperties: MutableMap, + ) { - /** - * Sets [Builder.adjustment] to an arbitrary JSON value. - * - * You should usually call [Builder.adjustment] with a well-typed [Adjustment] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun adjustment(adjustment: JsonField) = apply { - this.adjustment = adjustment - } + @JsonCreator + private constructor( + @JsonProperty("unit_rating_key") + @ExcludeMissing + unitRatingKey: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + ) : this(unitRatingKey, groupingKey, mutableMapOf()) - /** - * Alias for calling [adjustment] with - * `Adjustment.ofPercentageDiscount(percentageDiscount)`. - */ - fun adjustment(percentageDiscount: NewPercentageDiscount) = - adjustment(Adjustment.ofPercentageDiscount(percentageDiscount)) + /** + * The key in the event data to extract the unit rate from. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun unitRatingKey(): String = unitRatingKey.getRequired("unit_rating_key") - /** - * Alias for calling [adjustment] with the following: - * ```kotlin - * NewPercentageDiscount.builder() - * .adjustmentType(NewPercentageDiscount.AdjustmentType.PERCENTAGE_DISCOUNT) - * .percentageDiscount(percentageDiscount) - * .build() - * ``` - */ - fun percentageDiscountAdjustment(percentageDiscount: Double) = - adjustment( - NewPercentageDiscount.builder() - .adjustmentType(NewPercentageDiscount.AdjustmentType.PERCENTAGE_DISCOUNT) - .percentageDiscount(percentageDiscount) - .build() - ) + /** + * An optional key in the event data to group by (e.g., event ID). All events + * will also be grouped by their unit rate. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun groupingKey(): String? = groupingKey.getNullable("grouping_key") - /** Alias for calling [adjustment] with `Adjustment.ofUsageDiscount(usageDiscount)`. */ - fun adjustment(usageDiscount: NewUsageDiscount) = - adjustment(Adjustment.ofUsageDiscount(usageDiscount)) + /** + * Returns the raw JSON value of [unitRatingKey]. + * + * Unlike [unitRatingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_rating_key") + @ExcludeMissing + fun _unitRatingKey(): JsonField = unitRatingKey - /** - * Alias for calling [adjustment] with the following: - * ```kotlin - * NewUsageDiscount.builder() - * .adjustmentType(NewUsageDiscount.AdjustmentType.USAGE_DISCOUNT) - * .usageDiscount(usageDiscount) - * .build() - * ``` - */ - fun usageDiscountAdjustment(usageDiscount: Double) = - adjustment( - NewUsageDiscount.builder() - .adjustmentType(NewUsageDiscount.AdjustmentType.USAGE_DISCOUNT) - .usageDiscount(usageDiscount) - .build() - ) + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey - /** - * Alias for calling [adjustment] with `Adjustment.ofAmountDiscount(amountDiscount)`. - */ - fun adjustment(amountDiscount: NewAmountDiscount) = - adjustment(Adjustment.ofAmountDiscount(amountDiscount)) + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - /** - * Alias for calling [adjustment] with the following: - * ```kotlin - * NewAmountDiscount.builder() - * .adjustmentType(NewAmountDiscount.AdjustmentType.AMOUNT_DISCOUNT) - * .amountDiscount(amountDiscount) - * .build() - * ``` - */ - fun amountDiscountAdjustment(amountDiscount: String) = - adjustment( - NewAmountDiscount.builder() - .adjustmentType(NewAmountDiscount.AdjustmentType.AMOUNT_DISCOUNT) - .amountDiscount(amountDiscount) - .build() - ) + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - /** Alias for calling [adjustment] with `Adjustment.ofMinimum(minimum)`. */ - fun adjustment(minimum: NewMinimum) = adjustment(Adjustment.ofMinimum(minimum)) + fun toBuilder() = Builder().from(this) - /** Alias for calling [adjustment] with `Adjustment.ofMaximum(maximum)`. */ - fun adjustment(maximum: NewMaximum) = adjustment(Adjustment.ofMaximum(maximum)) + companion object { - /** - * Alias for calling [adjustment] with the following: - * ```kotlin - * NewMaximum.builder() - * .adjustmentType(NewMaximum.AdjustmentType.MAXIMUM) - * .maximumAmount(maximumAmount) - * .build() - * ``` - */ - fun maximumAdjustment(maximumAmount: String) = - adjustment( - NewMaximum.builder() - .adjustmentType(NewMaximum.AdjustmentType.MAXIMUM) - .maximumAmount(maximumAmount) - .build() - ) + /** + * Returns a mutable builder for constructing an instance of + * [EventOutputConfig]. + * + * The following fields are required: + * ```kotlin + * .unitRatingKey() + * ``` + */ + fun builder() = Builder() + } - /** The id of the adjustment on the plan to replace in the subscription. */ - fun replacesAdjustmentId(replacesAdjustmentId: String) = - replacesAdjustmentId(JsonField.of(replacesAdjustmentId)) + /** A builder for [EventOutputConfig]. */ + class Builder internal constructor() { - /** - * Sets [Builder.replacesAdjustmentId] to an arbitrary JSON value. - * - * You should usually call [Builder.replacesAdjustmentId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun replacesAdjustmentId(replacesAdjustmentId: JsonField) = apply { - this.replacesAdjustmentId = replacesAdjustmentId - } + private var unitRatingKey: JsonField? = null + private var groupingKey: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + internal fun from(eventOutputConfig: EventOutputConfig) = apply { + unitRatingKey = eventOutputConfig.unitRatingKey + groupingKey = eventOutputConfig.groupingKey + additionalProperties = + eventOutputConfig.additionalProperties.toMutableMap() + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** The key in the event data to extract the unit rate from. */ + fun unitRatingKey(unitRatingKey: String) = + unitRatingKey(JsonField.of(unitRatingKey)) - /** - * Returns an immutable instance of [ReplaceAdjustment]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```kotlin - * .adjustment() - * .replacesAdjustmentId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): ReplaceAdjustment = - ReplaceAdjustment( - checkRequired("adjustment", adjustment), - checkRequired("replacesAdjustmentId", replacesAdjustmentId), - additionalProperties.toMutableMap(), - ) - } + /** + * Sets [Builder.unitRatingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.unitRatingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun unitRatingKey(unitRatingKey: JsonField) = apply { + this.unitRatingKey = unitRatingKey + } - private var validated: Boolean = false + /** + * An optional key in the event data to group by (e.g., event ID). All + * events will also be grouped by their unit rate. + */ + fun groupingKey(groupingKey: String?) = + groupingKey(JsonField.ofNullable(groupingKey)) - fun validate(): ReplaceAdjustment = apply { - if (validated) { - return@apply - } + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } - adjustment().validate() - replacesAdjustmentId() - validated = true - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (adjustment.asKnown()?.validity() ?: 0) + - (if (replacesAdjustmentId.asKnown() == null) 0 else 1) + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - /** The definition of a new adjustment to create and add to the subscription. */ - @JsonDeserialize(using = Adjustment.Deserializer::class) - @JsonSerialize(using = Adjustment.Serializer::class) - class Adjustment - private constructor( - private val percentageDiscount: NewPercentageDiscount? = null, - private val usageDiscount: NewUsageDiscount? = null, - private val amountDiscount: NewAmountDiscount? = null, - private val minimum: NewMinimum? = null, - private val maximum: NewMaximum? = null, - private val _json: JsonValue? = null, - ) { + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun percentageDiscount(): NewPercentageDiscount? = percentageDiscount + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - fun usageDiscount(): NewUsageDiscount? = usageDiscount + /** + * Returns an immutable instance of [EventOutputConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .unitRatingKey() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): EventOutputConfig = + EventOutputConfig( + checkRequired("unitRatingKey", unitRatingKey), + groupingKey, + additionalProperties.toMutableMap(), + ) + } - fun amountDiscount(): NewAmountDiscount? = amountDiscount + private var validated: Boolean = false - fun minimum(): NewMinimum? = minimum + fun validate(): EventOutputConfig = apply { + if (validated) { + return@apply + } - fun maximum(): NewMaximum? = maximum + unitRatingKey() + groupingKey() + validated = true + } - fun isPercentageDiscount(): Boolean = percentageDiscount != null + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - fun isUsageDiscount(): Boolean = usageDiscount != null + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (unitRatingKey.asKnown() == null) 0 else 1) + + (if (groupingKey.asKnown() == null) 0 else 1) - fun isAmountDiscount(): Boolean = amountDiscount != null + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun isMinimum(): Boolean = minimum != null + return other is EventOutputConfig && + unitRatingKey == other.unitRatingKey && + groupingKey == other.groupingKey && + additionalProperties == other.additionalProperties + } - fun isMaximum(): Boolean = maximum != null + private val hashCode: Int by lazy { + Objects.hash(unitRatingKey, groupingKey, additionalProperties) + } - fun asPercentageDiscount(): NewPercentageDiscount = - percentageDiscount.getOrThrow("percentageDiscount") + override fun hashCode(): Int = hashCode - fun asUsageDiscount(): NewUsageDiscount = usageDiscount.getOrThrow("usageDiscount") + override fun toString() = + "EventOutputConfig{unitRatingKey=$unitRatingKey, groupingKey=$groupingKey, additionalProperties=$additionalProperties}" + } - fun asAmountDiscount(): NewAmountDiscount = amountDiscount.getOrThrow("amountDiscount") + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { - fun asMinimum(): NewMinimum = minimum.getOrThrow("minimum") + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties - fun asMaximum(): NewMaximum = maximum.getOrThrow("maximum") + fun toBuilder() = Builder().from(this) - fun _json(): JsonValue? = _json + companion object { - fun accept(visitor: Visitor): T = - when { - percentageDiscount != null -> - visitor.visitPercentageDiscount(percentageDiscount) - usageDiscount != null -> visitor.visitUsageDiscount(usageDiscount) - amountDiscount != null -> visitor.visitAmountDiscount(amountDiscount) - minimum != null -> visitor.visitMinimum(minimum) - maximum != null -> visitor.visitMaximum(maximum) - else -> visitor.unknown(_json) - } + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } - private var validated: Boolean = false + /** A builder for [Metadata]. */ + class Builder internal constructor() { - fun validate(): Adjustment = apply { - if (validated) { - return@apply - } + private var additionalProperties: MutableMap = + mutableMapOf() - accept( - object : Visitor { - override fun visitPercentageDiscount( - percentageDiscount: NewPercentageDiscount - ) { - percentageDiscount.validate() + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() } - override fun visitUsageDiscount(usageDiscount: NewUsageDiscount) { - usageDiscount.validate() + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) } - override fun visitAmountDiscount(amountDiscount: NewAmountDiscount) { - amountDiscount.validate() - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - override fun visitMinimum(minimum: NewMinimum) { - minimum.validate() + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) } - override fun visitMaximum(maximum: NewMaximum) { - maximum.validate() + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } - ) - validated = true - } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + private var validated: Boolean = false - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitPercentageDiscount( - percentageDiscount: NewPercentageDiscount - ) = percentageDiscount.validity() + fun validate(): Metadata = apply { + if (validated) { + return@apply + } - override fun visitUsageDiscount(usageDiscount: NewUsageDiscount) = - usageDiscount.validity() + validated = true + } - override fun visitAmountDiscount(amountDiscount: NewAmountDiscount) = - amountDiscount.validity() + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - override fun visitMinimum(minimum: NewMinimum) = minimum.validity() + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } - override fun visitMaximum(maximum: NewMaximum) = maximum.validity() + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - override fun unknown(json: JsonValue?) = 0 + return other is Metadata && + additionalProperties == other.additionalProperties } - ) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Adjustment && - percentageDiscount == other.percentageDiscount && - usageDiscount == other.usageDiscount && - amountDiscount == other.amountDiscount && - minimum == other.minimum && - maximum == other.maximum - } + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - override fun hashCode(): Int = - Objects.hash(percentageDiscount, usageDiscount, amountDiscount, minimum, maximum) + override fun hashCode(): Int = hashCode - override fun toString(): String = - when { - percentageDiscount != null -> - "Adjustment{percentageDiscount=$percentageDiscount}" - usageDiscount != null -> "Adjustment{usageDiscount=$usageDiscount}" - amountDiscount != null -> "Adjustment{amountDiscount=$amountDiscount}" - minimum != null -> "Adjustment{minimum=$minimum}" - maximum != null -> "Adjustment{maximum=$maximum}" - _json != null -> "Adjustment{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Adjustment") + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" } - companion object { + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun ofPercentageDiscount(percentageDiscount: NewPercentageDiscount) = - Adjustment(percentageDiscount = percentageDiscount) + return other is EventOutput && + cadence == other.cadence && + eventOutputConfig == other.eventOutputConfig && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } - fun ofUsageDiscount(usageDiscount: NewUsageDiscount) = - Adjustment(usageDiscount = usageDiscount) + private val hashCode: Int by lazy { + Objects.hash( + cadence, + eventOutputConfig, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties, + ) + } - fun ofAmountDiscount(amountDiscount: NewAmountDiscount) = - Adjustment(amountDiscount = amountDiscount) + override fun hashCode(): Int = hashCode - fun ofMinimum(minimum: NewMinimum) = Adjustment(minimum = minimum) + override fun toString() = + "EventOutput{cadence=$cadence, eventOutputConfig=$eventOutputConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + } - fun ofMaximum(maximum: NewMaximum) = Adjustment(maximum = maximum) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - /** - * An interface that defines how to map each variant of [Adjustment] to a value of type - * [T]. - */ - interface Visitor { + return other is AddPrice && + allocationPrice == other.allocationPrice && + discounts == other.discounts && + endDate == other.endDate && + externalPriceId == other.externalPriceId && + maximumAmount == other.maximumAmount && + minimumAmount == other.minimumAmount && + planPhaseOrder == other.planPhaseOrder && + price == other.price && + priceId == other.priceId && + startDate == other.startDate && + additionalProperties == other.additionalProperties + } - fun visitPercentageDiscount(percentageDiscount: NewPercentageDiscount): T + private val hashCode: Int by lazy { + Objects.hash( + allocationPrice, + discounts, + endDate, + externalPriceId, + maximumAmount, + minimumAmount, + planPhaseOrder, + price, + priceId, + startDate, + additionalProperties, + ) + } - fun visitUsageDiscount(usageDiscount: NewUsageDiscount): T + override fun hashCode(): Int = hashCode - fun visitAmountDiscount(amountDiscount: NewAmountDiscount): T + override fun toString() = + "AddPrice{allocationPrice=$allocationPrice, discounts=$discounts, endDate=$endDate, externalPriceId=$externalPriceId, maximumAmount=$maximumAmount, minimumAmount=$minimumAmount, planPhaseOrder=$planPhaseOrder, price=$price, priceId=$priceId, startDate=$startDate, additionalProperties=$additionalProperties}" + } - fun visitMinimum(minimum: NewMinimum): T + @Deprecated("deprecated") + class ExternalMarketplace + @JsonCreator + private constructor(private val value: JsonField) : Enum { - fun visitMaximum(maximum: NewMaximum): T + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - /** - * Maps an unknown variant of [Adjustment] to a value of type [T]. - * - * An instance of [Adjustment] can contain an unknown variant if it was deserialized - * from data that doesn't match any known variant. For example, if the SDK is on an - * older version than the API, then the API may respond with new variants that the - * SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown Adjustment: $json") - } - } + companion object { - internal class Deserializer : BaseDeserializer(Adjustment::class) { + val GOOGLE = of("google") - override fun ObjectCodec.deserialize(node: JsonNode): Adjustment { - val json = JsonValue.fromJsonNode(node) - val adjustmentType = json.asObject()?.get("adjustment_type")?.asString() + val AWS = of("aws") - when (adjustmentType) { - "percentage_discount" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Adjustment(percentageDiscount = it, _json = json) } - ?: Adjustment(_json = json) - } - "usage_discount" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(usageDiscount = it, _json = json) - } ?: Adjustment(_json = json) - } - "amount_discount" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(amountDiscount = it, _json = json) - } ?: Adjustment(_json = json) - } - "minimum" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(minimum = it, _json = json) - } ?: Adjustment(_json = json) - } - "maximum" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(maximum = it, _json = json) - } ?: Adjustment(_json = json) - } - } - - return Adjustment(_json = json) - } - } - - internal class Serializer : BaseSerializer(Adjustment::class) { - - override fun serialize( - value: Adjustment, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.percentageDiscount != null -> - generator.writeObject(value.percentageDiscount) - value.usageDiscount != null -> generator.writeObject(value.usageDiscount) - value.amountDiscount != null -> generator.writeObject(value.amountDiscount) - value.minimum != null -> generator.writeObject(value.minimum) - value.maximum != null -> generator.writeObject(value.maximum) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Adjustment") - } - } - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + val AZURE = of("azure") - return other is ReplaceAdjustment && - adjustment == other.adjustment && - replacesAdjustmentId == other.replacesAdjustmentId && - additionalProperties == other.additionalProperties + fun of(value: String) = ExternalMarketplace(JsonField.of(value)) } - private val hashCode: Int by lazy { - Objects.hash(adjustment, replacesAdjustmentId, additionalProperties) + /** An enum containing [ExternalMarketplace]'s known values. */ + enum class Known { + GOOGLE, + AWS, + AZURE, } - override fun hashCode(): Int = hashCode - - override fun toString() = - "ReplaceAdjustment{adjustment=$adjustment, replacesAdjustmentId=$replacesAdjustmentId, additionalProperties=$additionalProperties}" - } - - class ReplacePrice - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val replacesPriceId: JsonField, - private val allocationPrice: JsonField, - private val discounts: JsonField>, - private val externalPriceId: JsonField, - private val fixedPriceQuantity: JsonField, - private val maximumAmount: JsonField, - private val minimumAmount: JsonField, - private val price: JsonField, - private val priceId: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("replaces_price_id") - @ExcludeMissing - replacesPriceId: JsonField = JsonMissing.of(), - @JsonProperty("allocation_price") - @ExcludeMissing - allocationPrice: JsonField = JsonMissing.of(), - @JsonProperty("discounts") - @ExcludeMissing - discounts: JsonField> = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("maximum_amount") - @ExcludeMissing - maximumAmount: JsonField = JsonMissing.of(), - @JsonProperty("minimum_amount") - @ExcludeMissing - minimumAmount: JsonField = JsonMissing.of(), - @JsonProperty("price") @ExcludeMissing price: JsonField = JsonMissing.of(), - @JsonProperty("price_id") @ExcludeMissing priceId: JsonField = JsonMissing.of(), - ) : this( - replacesPriceId, - allocationPrice, - discounts, - externalPriceId, - fixedPriceQuantity, - maximumAmount, - minimumAmount, - price, - priceId, - mutableMapOf(), - ) - /** - * The id of the price on the plan to replace in the subscription. + * An enum containing [ExternalMarketplace]'s known values, as well as an [_UNKNOWN] member. * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + * An instance of [ExternalMarketplace] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. */ - fun replacesPriceId(): String = replacesPriceId.getRequired("replaces_price_id") + enum class Value { + GOOGLE, + AWS, + AZURE, + /** + * An enum member indicating that [ExternalMarketplace] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } /** - * The definition of a new allocation price to create and add to the subscription. + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. */ - fun allocationPrice(): NewAllocationPrice? = allocationPrice.getNullable("allocation_price") + fun value(): Value = + when (this) { + GOOGLE -> Value.GOOGLE + AWS -> Value.AWS + AZURE -> Value.AZURE + else -> Value._UNKNOWN + } /** - * [DEPRECATED] Use add_adjustments instead. The subscription's discounts for the - * replacement price. + * Returns an enum member corresponding to this class instance's value. * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - @Deprecated("deprecated") - fun discounts(): List? = discounts.getNullable("discounts") - - /** - * The external price id of the price to add to the subscription. + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). + * @throws OrbInvalidDataException if this class instance's value is a not a known member. */ - fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + fun known(): Known = + when (this) { + GOOGLE -> Known.GOOGLE + AWS -> Known.AWS + AZURE -> Known.AZURE + else -> throw OrbInvalidDataException("Unknown ExternalMarketplace: $value") + } /** - * The new quantity of the price, if the price is a fixed price. + * Returns this class instance's primitive wire representation. * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun fixedPriceQuantity(): Double? = fixedPriceQuantity.getNullable("fixed_price_quantity") - - /** - * [DEPRECATED] Use add_adjustments instead. The subscription's maximum amount for the - * replacement price. + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). + * @throws OrbInvalidDataException if this class instance's value does not have the expected + * primitive type. */ - @Deprecated("deprecated") - fun maximumAmount(): String? = maximumAmount.getNullable("maximum_amount") + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") - /** - * [DEPRECATED] Use add_adjustments instead. The subscription's minimum amount for the - * replacement price. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - @Deprecated("deprecated") - fun minimumAmount(): String? = minimumAmount.getNullable("minimum_amount") + private var validated: Boolean = false - /** - * New subscription price request body params. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun price(): Price? = price.getNullable("price") + fun validate(): ExternalMarketplace = apply { + if (validated) { + return@apply + } - /** - * The id of the price to add to the subscription. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun priceId(): String? = priceId.getNullable("price_id") + known() + validated = true + } - /** - * Returns the raw JSON value of [replacesPriceId]. - * - * Unlike [replacesPriceId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("replaces_price_id") - @ExcludeMissing - fun _replacesPriceId(): JsonField = replacesPriceId + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } /** - * Returns the raw JSON value of [allocationPrice]. + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * Unlike [allocationPrice], this method doesn't throw if the JSON field has an unexpected - * type. + * Used for best match union deserialization. */ - @JsonProperty("allocation_price") - @ExcludeMissing - fun _allocationPrice(): JsonField = allocationPrice + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - /** - * Returns the raw JSON value of [discounts]. - * - * Unlike [discounts], this method doesn't throw if the JSON field has an unexpected type. - */ - @Deprecated("deprecated") - @JsonProperty("discounts") - @ExcludeMissing - fun _discounts(): JsonField> = discounts + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * Returns the raw JSON value of [externalPriceId]. - * - * Unlike [externalPriceId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId + return other is ExternalMarketplace && value == other.value + } - /** - * Returns the raw JSON value of [fixedPriceQuantity]. - * - * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + override fun hashCode() = value.hashCode() - /** - * Returns the raw JSON value of [maximumAmount]. - * - * Unlike [maximumAmount], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @Deprecated("deprecated") - @JsonProperty("maximum_amount") + override fun toString() = value.toString() + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by setting + * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to + * `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter @ExcludeMissing - fun _maximumAmount(): JsonField = maximumAmount + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } /** - * Returns the raw JSON value of [minimumAmount]. + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * Unlike [minimumAmount], this method doesn't throw if the JSON field has an unexpected - * type. + * Used for best match union deserialization. */ - @Deprecated("deprecated") - @JsonProperty("minimum_amount") - @ExcludeMissing - fun _minimumAmount(): JsonField = minimumAmount + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + class RemoveAdjustment + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val adjustmentId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("adjustment_id") + @ExcludeMissing + adjustmentId: JsonField = JsonMissing.of() + ) : this(adjustmentId, mutableMapOf()) /** - * Returns the raw JSON value of [price]. + * The id of the adjustment to remove on the subscription. * - * Unlike [price], this method doesn't throw if the JSON field has an unexpected type. + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ - @JsonProperty("price") @ExcludeMissing fun _price(): JsonField = price + fun adjustmentId(): String = adjustmentId.getRequired("adjustment_id") /** - * Returns the raw JSON value of [priceId]. + * Returns the raw JSON value of [adjustmentId]. * - * Unlike [priceId], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [adjustmentId], this method doesn't throw if the JSON field has an unexpected + * type. */ - @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId + @JsonProperty("adjustment_id") + @ExcludeMissing + fun _adjustmentId(): JsonField = adjustmentId @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -12483,107 +12927,205 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [ReplacePrice]. + * Returns a mutable builder for constructing an instance of [RemoveAdjustment]. * * The following fields are required: * ```kotlin - * .replacesPriceId() + * .adjustmentId() * ``` */ fun builder() = Builder() } - /** A builder for [ReplacePrice]. */ + /** A builder for [RemoveAdjustment]. */ class Builder internal constructor() { - private var replacesPriceId: JsonField? = null - private var allocationPrice: JsonField = JsonMissing.of() - private var discounts: JsonField>? = null - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var maximumAmount: JsonField = JsonMissing.of() - private var minimumAmount: JsonField = JsonMissing.of() - private var price: JsonField = JsonMissing.of() - private var priceId: JsonField = JsonMissing.of() + private var adjustmentId: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(replacePrice: ReplacePrice) = apply { - replacesPriceId = replacePrice.replacesPriceId - allocationPrice = replacePrice.allocationPrice - discounts = replacePrice.discounts.map { it.toMutableList() } - externalPriceId = replacePrice.externalPriceId - fixedPriceQuantity = replacePrice.fixedPriceQuantity - maximumAmount = replacePrice.maximumAmount - minimumAmount = replacePrice.minimumAmount - price = replacePrice.price - priceId = replacePrice.priceId - additionalProperties = replacePrice.additionalProperties.toMutableMap() + internal fun from(removeAdjustment: RemoveAdjustment) = apply { + adjustmentId = removeAdjustment.adjustmentId + additionalProperties = removeAdjustment.additionalProperties.toMutableMap() } - /** The id of the price on the plan to replace in the subscription. */ - fun replacesPriceId(replacesPriceId: String) = - replacesPriceId(JsonField.of(replacesPriceId)) + /** The id of the adjustment to remove on the subscription. */ + fun adjustmentId(adjustmentId: String) = adjustmentId(JsonField.of(adjustmentId)) /** - * Sets [Builder.replacesPriceId] to an arbitrary JSON value. + * Sets [Builder.adjustmentId] to an arbitrary JSON value. * - * You should usually call [Builder.replacesPriceId] with a well-typed [String] value + * You should usually call [Builder.adjustmentId] with a well-typed [String] value * instead. This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun replacesPriceId(replacesPriceId: JsonField) = apply { - this.replacesPriceId = replacesPriceId + fun adjustmentId(adjustmentId: JsonField) = apply { + this.adjustmentId = adjustmentId } - /** The definition of a new allocation price to create and add to the subscription. */ - fun allocationPrice(allocationPrice: NewAllocationPrice?) = - allocationPrice(JsonField.ofNullable(allocationPrice)) + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** - * Sets [Builder.allocationPrice] to an arbitrary JSON value. - * - * You should usually call [Builder.allocationPrice] with a well-typed - * [NewAllocationPrice] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun allocationPrice(allocationPrice: JsonField) = apply { - this.allocationPrice = allocationPrice + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) } - /** - * [DEPRECATED] Use add_adjustments instead. The subscription's discounts for the - * replacement price. - */ - @Deprecated("deprecated") - fun discounts(discounts: List?) = - discounts(JsonField.ofNullable(discounts)) + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - /** - * Sets [Builder.discounts] to an arbitrary JSON value. - * - * You should usually call [Builder.discounts] with a well-typed - * `List` value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - @Deprecated("deprecated") - fun discounts(discounts: JsonField>) = apply { - this.discounts = discounts.map { it.toMutableList() } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) } /** - * Adds a single [DiscountOverride] to [discounts]. + * Returns an immutable instance of [RemoveAdjustment]. * - * @throws IllegalStateException if the field was previously set to a non-list. + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .adjustmentId() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ - @Deprecated("deprecated") - fun addDiscount(discount: DiscountOverride) = apply { - discounts = - (discounts ?: JsonField.of(mutableListOf())).also { - checkKnown("discounts", it).add(discount) - } + fun build(): RemoveAdjustment = + RemoveAdjustment( + checkRequired("adjustmentId", adjustmentId), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): RemoveAdjustment = apply { + if (validated) { + return@apply } - /** The external price id of the price to add to the subscription. */ + adjustmentId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = (if (adjustmentId.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RemoveAdjustment && + adjustmentId == other.adjustmentId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(adjustmentId, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "RemoveAdjustment{adjustmentId=$adjustmentId, additionalProperties=$additionalProperties}" + } + + class RemovePrice + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val externalPriceId: JsonField, + private val priceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("price_id") @ExcludeMissing priceId: JsonField = JsonMissing.of(), + ) : this(externalPriceId, priceId, mutableMapOf()) + + /** + * The external price id of the price to remove on the subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * The id of the price to remove on the subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun priceId(): String? = priceId.getNullable("price_id") + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [priceId]. + * + * Unlike [priceId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [RemovePrice]. */ + fun builder() = Builder() + } + + /** A builder for [RemovePrice]. */ + class Builder internal constructor() { + + private var externalPriceId: JsonField = JsonMissing.of() + private var priceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(removePrice: RemovePrice) = apply { + externalPriceId = removePrice.externalPriceId + priceId = removePrice.priceId + additionalProperties = removePrice.additionalProperties.toMutableMap() + } + + /** The external price id of the price to remove on the subscription. */ fun externalPriceId(externalPriceId: String?) = externalPriceId(JsonField.ofNullable(externalPriceId)) @@ -12598,238 +13140,309 @@ private constructor( this.externalPriceId = externalPriceId } - /** The new quantity of the price, if the price is a fixed price. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = - fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) - - /** - * Alias for [Builder.fixedPriceQuantity]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) + /** The id of the price to remove on the subscription. */ + fun priceId(priceId: String?) = priceId(JsonField.ofNullable(priceId)) /** - * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * Sets [Builder.priceId] to an arbitrary JSON value. * - * You should usually call [Builder.fixedPriceQuantity] with a well-typed [Double] value - * instead. This method is primarily for setting the field to an undocumented or not yet + * You should usually call [Builder.priceId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { - this.fixedPriceQuantity = fixedPriceQuantity + fun priceId(priceId: JsonField) = apply { this.priceId = priceId } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) } - /** - * [DEPRECATED] Use add_adjustments instead. The subscription's maximum amount for the - * replacement price. - */ - @Deprecated("deprecated") - fun maximumAmount(maximumAmount: String?) = - maximumAmount(JsonField.ofNullable(maximumAmount)) + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * Sets [Builder.maximumAmount] to an arbitrary JSON value. - * - * You should usually call [Builder.maximumAmount] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - @Deprecated("deprecated") - fun maximumAmount(maximumAmount: JsonField) = apply { - this.maximumAmount = maximumAmount + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) } - /** - * [DEPRECATED] Use add_adjustments instead. The subscription's minimum amount for the - * replacement price. - */ - @Deprecated("deprecated") - fun minimumAmount(minimumAmount: String?) = - minimumAmount(JsonField.ofNullable(minimumAmount)) + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - /** - * Sets [Builder.minimumAmount] to an arbitrary JSON value. - * - * You should usually call [Builder.minimumAmount] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - @Deprecated("deprecated") - fun minimumAmount(minimumAmount: JsonField) = apply { - this.minimumAmount = minimumAmount + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) } - /** New subscription price request body params. */ - fun price(price: Price?) = price(JsonField.ofNullable(price)) - /** - * Sets [Builder.price] to an arbitrary JSON value. + * Returns an immutable instance of [RemovePrice]. * - * You should usually call [Builder.price] with a well-typed [Price] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. + * Further updates to this [Builder] will not mutate the returned instance. */ - fun price(price: JsonField) = apply { this.price = price } + fun build(): RemovePrice = + RemovePrice(externalPriceId, priceId, additionalProperties.toMutableMap()) + } - /** Alias for calling [price] with `Price.ofUnit(unit)`. */ - fun price(unit: NewSubscriptionUnitPrice) = price(Price.ofUnit(unit)) + private var validated: Boolean = false - /** Alias for calling [price] with `Price.ofTiered(tiered)`. */ - fun price(tiered: NewSubscriptionTieredPrice) = price(Price.ofTiered(tiered)) + fun validate(): RemovePrice = apply { + if (validated) { + return@apply + } - /** Alias for calling [price] with `Price.ofBulk(bulk)`. */ - fun price(bulk: NewSubscriptionBulkPrice) = price(Price.ofBulk(bulk)) + externalPriceId() + priceId() + validated = true + } - /** Alias for calling [price] with `Price.ofPackage(package_)`. */ - fun price(package_: NewSubscriptionPackagePrice) = price(Price.ofPackage(package_)) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - /** Alias for calling [price] with `Price.ofMatrix(matrix)`. */ - fun price(matrix: NewSubscriptionMatrixPrice) = price(Price.ofMatrix(matrix)) + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (priceId.asKnown() == null) 0 else 1) - /** - * Alias for calling [price] with `Price.ofThresholdTotalAmount(thresholdTotalAmount)`. - */ - fun price(thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice) = - price(Price.ofThresholdTotalAmount(thresholdTotalAmount)) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** Alias for calling [price] with `Price.ofTieredPackage(tieredPackage)`. */ - fun price(tieredPackage: NewSubscriptionTieredPackagePrice) = - price(Price.ofTieredPackage(tieredPackage)) + return other is RemovePrice && + externalPriceId == other.externalPriceId && + priceId == other.priceId && + additionalProperties == other.additionalProperties + } - /** Alias for calling [price] with `Price.ofTieredWithMinimum(tieredWithMinimum)`. */ - fun price(tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice) = - price(Price.ofTieredWithMinimum(tieredWithMinimum)) + private val hashCode: Int by lazy { + Objects.hash(externalPriceId, priceId, additionalProperties) + } - /** Alias for calling [price] with `Price.ofGroupedTiered(groupedTiered)`. */ - fun price(groupedTiered: NewSubscriptionGroupedTieredPrice) = - price(Price.ofGroupedTiered(groupedTiered)) + override fun hashCode(): Int = hashCode - /** - * Alias for calling [price] with - * `Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)`. - */ - fun price(tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice) = - price(Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)) + override fun toString() = + "RemovePrice{externalPriceId=$externalPriceId, priceId=$priceId, additionalProperties=$additionalProperties}" + } - /** - * Alias for calling [price] with - * `Price.ofPackageWithAllocation(packageWithAllocation)`. - */ - fun price(packageWithAllocation: NewSubscriptionPackageWithAllocationPrice) = - price(Price.ofPackageWithAllocation(packageWithAllocation)) + class ReplaceAdjustment + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val adjustment: JsonField, + private val replacesAdjustmentId: JsonField, + private val additionalProperties: MutableMap, + ) { - /** Alias for calling [price] with `Price.ofUnitWithPercent(unitWithPercent)`. */ - fun price(unitWithPercent: NewSubscriptionUnitWithPercentPrice) = - price(Price.ofUnitWithPercent(unitWithPercent)) + @JsonCreator + private constructor( + @JsonProperty("adjustment") + @ExcludeMissing + adjustment: JsonField = JsonMissing.of(), + @JsonProperty("replaces_adjustment_id") + @ExcludeMissing + replacesAdjustmentId: JsonField = JsonMissing.of(), + ) : this(adjustment, replacesAdjustmentId, mutableMapOf()) - /** - * Alias for calling [price] with `Price.ofMatrixWithAllocation(matrixWithAllocation)`. - */ - fun price(matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice) = - price(Price.ofMatrixWithAllocation(matrixWithAllocation)) + /** + * The definition of a new adjustment to create and add to the subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun adjustment(): Adjustment = adjustment.getRequired("adjustment") - /** - * Alias for calling [price] with `Price.ofTieredWithProration(tieredWithProration)`. - */ - fun price(tieredWithProration: Price.TieredWithProration) = - price(Price.ofTieredWithProration(tieredWithProration)) + /** + * The id of the adjustment on the plan to replace in the subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun replacesAdjustmentId(): String = + replacesAdjustmentId.getRequired("replaces_adjustment_id") - /** Alias for calling [price] with `Price.ofUnitWithProration(unitWithProration)`. */ - fun price(unitWithProration: NewSubscriptionUnitWithProrationPrice) = - price(Price.ofUnitWithProration(unitWithProration)) + /** + * Returns the raw JSON value of [adjustment]. + * + * Unlike [adjustment], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("adjustment") + @ExcludeMissing + fun _adjustment(): JsonField = adjustment - /** Alias for calling [price] with `Price.ofGroupedAllocation(groupedAllocation)`. */ - fun price(groupedAllocation: NewSubscriptionGroupedAllocationPrice) = - price(Price.ofGroupedAllocation(groupedAllocation)) + /** + * Returns the raw JSON value of [replacesAdjustmentId]. + * + * Unlike [replacesAdjustmentId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("replaces_adjustment_id") + @ExcludeMissing + fun _replacesAdjustmentId(): JsonField = replacesAdjustmentId - /** Alias for calling [price] with `Price.ofBulkWithProration(bulkWithProration)`. */ - fun price(bulkWithProration: NewSubscriptionBulkWithProrationPrice) = - price(Price.ofBulkWithProration(bulkWithProration)) + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - /** - * Alias for calling [price] with - * `Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)`. - */ - fun price(groupedWithProratedMinimum: NewSubscriptionGroupedWithProratedMinimumPrice) = - price(Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)) + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - /** - * Alias for calling [price] with - * `Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)`. - */ - fun price(groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice) = - price(Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)) + fun toBuilder() = Builder().from(this) - /** - * Alias for calling [price] with - * `Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)`. - */ - fun price(groupedWithMinMaxThresholds: Price.GroupedWithMinMaxThresholds) = - price(Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)) + companion object { /** - * Alias for calling [price] with - * `Price.ofMatrixWithDisplayName(matrixWithDisplayName)`. + * Returns a mutable builder for constructing an instance of [ReplaceAdjustment]. + * + * The following fields are required: + * ```kotlin + * .adjustment() + * .replacesAdjustmentId() + * ``` */ - fun price(matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice) = - price(Price.ofMatrixWithDisplayName(matrixWithDisplayName)) + fun builder() = Builder() + } + + /** A builder for [ReplaceAdjustment]. */ + class Builder internal constructor() { + + private var adjustment: JsonField? = null + private var replacesAdjustmentId: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(replaceAdjustment: ReplaceAdjustment) = apply { + adjustment = replaceAdjustment.adjustment + replacesAdjustmentId = replaceAdjustment.replacesAdjustmentId + additionalProperties = replaceAdjustment.additionalProperties.toMutableMap() + } + + /** The definition of a new adjustment to create and add to the subscription. */ + fun adjustment(adjustment: Adjustment) = adjustment(JsonField.of(adjustment)) /** - * Alias for calling [price] with `Price.ofGroupedTieredPackage(groupedTieredPackage)`. + * Sets [Builder.adjustment] to an arbitrary JSON value. + * + * You should usually call [Builder.adjustment] with a well-typed [Adjustment] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun price(groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice) = - price(Price.ofGroupedTieredPackage(groupedTieredPackage)) + fun adjustment(adjustment: JsonField) = apply { + this.adjustment = adjustment + } /** - * Alias for calling [price] with - * `Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)`. + * Alias for calling [adjustment] with + * `Adjustment.ofPercentageDiscount(percentageDiscount)`. */ - fun price(maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice) = - price(Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)) + fun adjustment(percentageDiscount: NewPercentageDiscount) = + adjustment(Adjustment.ofPercentageDiscount(percentageDiscount)) /** - * Alias for calling [price] with - * `Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)`. + * Alias for calling [adjustment] with the following: + * ```kotlin + * NewPercentageDiscount.builder() + * .adjustmentType(NewPercentageDiscount.AdjustmentType.PERCENTAGE_DISCOUNT) + * .percentageDiscount(percentageDiscount) + * .build() + * ``` */ - fun price( - scalableMatrixWithUnitPricing: NewSubscriptionScalableMatrixWithUnitPricingPrice - ) = price(Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)) + fun percentageDiscountAdjustment(percentageDiscount: Double) = + adjustment( + NewPercentageDiscount.builder() + .adjustmentType(NewPercentageDiscount.AdjustmentType.PERCENTAGE_DISCOUNT) + .percentageDiscount(percentageDiscount) + .build() + ) + + /** Alias for calling [adjustment] with `Adjustment.ofUsageDiscount(usageDiscount)`. */ + fun adjustment(usageDiscount: NewUsageDiscount) = + adjustment(Adjustment.ofUsageDiscount(usageDiscount)) /** - * Alias for calling [price] with - * `Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)`. + * Alias for calling [adjustment] with the following: + * ```kotlin + * NewUsageDiscount.builder() + * .adjustmentType(NewUsageDiscount.AdjustmentType.USAGE_DISCOUNT) + * .usageDiscount(usageDiscount) + * .build() + * ``` */ - fun price( - scalableMatrixWithTieredPricing: NewSubscriptionScalableMatrixWithTieredPricingPrice - ) = price(Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)) + fun usageDiscountAdjustment(usageDiscount: Double) = + adjustment( + NewUsageDiscount.builder() + .adjustmentType(NewUsageDiscount.AdjustmentType.USAGE_DISCOUNT) + .usageDiscount(usageDiscount) + .build() + ) /** - * Alias for calling [price] with - * `Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)`. + * Alias for calling [adjustment] with `Adjustment.ofAmountDiscount(amountDiscount)`. */ - fun price(cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice) = - price(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) + fun adjustment(amountDiscount: NewAmountDiscount) = + adjustment(Adjustment.ofAmountDiscount(amountDiscount)) - /** Alias for calling [price] with `Price.ofMinimum(minimum)`. */ - fun price(minimum: NewSubscriptionMinimumCompositePrice) = - price(Price.ofMinimum(minimum)) + /** + * Alias for calling [adjustment] with the following: + * ```kotlin + * NewAmountDiscount.builder() + * .adjustmentType(NewAmountDiscount.AdjustmentType.AMOUNT_DISCOUNT) + * .amountDiscount(amountDiscount) + * .build() + * ``` + */ + fun amountDiscountAdjustment(amountDiscount: String) = + adjustment( + NewAmountDiscount.builder() + .adjustmentType(NewAmountDiscount.AdjustmentType.AMOUNT_DISCOUNT) + .amountDiscount(amountDiscount) + .build() + ) - /** Alias for calling [price] with `Price.ofEventOutput(eventOutput)`. */ - fun price(eventOutput: Price.EventOutput) = price(Price.ofEventOutput(eventOutput)) + /** Alias for calling [adjustment] with `Adjustment.ofMinimum(minimum)`. */ + fun adjustment(minimum: NewMinimum) = adjustment(Adjustment.ofMinimum(minimum)) - /** The id of the price to add to the subscription. */ - fun priceId(priceId: String?) = priceId(JsonField.ofNullable(priceId)) + /** Alias for calling [adjustment] with `Adjustment.ofMaximum(maximum)`. */ + fun adjustment(maximum: NewMaximum) = adjustment(Adjustment.ofMaximum(maximum)) /** - * Sets [Builder.priceId] to an arbitrary JSON value. + * Alias for calling [adjustment] with the following: + * ```kotlin + * NewMaximum.builder() + * .adjustmentType(NewMaximum.AdjustmentType.MAXIMUM) + * .maximumAmount(maximumAmount) + * .build() + * ``` + */ + fun maximumAdjustment(maximumAmount: String) = + adjustment( + NewMaximum.builder() + .adjustmentType(NewMaximum.AdjustmentType.MAXIMUM) + .maximumAmount(maximumAmount) + .build() + ) + + /** The id of the adjustment on the plan to replace in the subscription. */ + fun replacesAdjustmentId(replacesAdjustmentId: String) = + replacesAdjustmentId(JsonField.of(replacesAdjustmentId)) + + /** + * Sets [Builder.replacesAdjustmentId] to an arbitrary JSON value. * - * You should usually call [Builder.priceId] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. + * You should usually call [Builder.replacesAdjustmentId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. */ - fun priceId(priceId: JsonField) = apply { this.priceId = priceId } + fun replacesAdjustmentId(replacesAdjustmentId: JsonField) = apply { + this.replacesAdjustmentId = replacesAdjustmentId + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -12851,48 +13464,35 @@ private constructor( } /** - * Returns an immutable instance of [ReplacePrice]. + * Returns an immutable instance of [ReplaceAdjustment]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```kotlin - * .replacesPriceId() + * .adjustment() + * .replacesAdjustmentId() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): ReplacePrice = - ReplacePrice( - checkRequired("replacesPriceId", replacesPriceId), - allocationPrice, - (discounts ?: JsonMissing.of()).map { it.toImmutable() }, - externalPriceId, - fixedPriceQuantity, - maximumAmount, - minimumAmount, - price, - priceId, + fun build(): ReplaceAdjustment = + ReplaceAdjustment( + checkRequired("adjustment", adjustment), + checkRequired("replacesAdjustmentId", replacesAdjustmentId), additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): ReplacePrice = apply { + fun validate(): ReplaceAdjustment = apply { if (validated) { return@apply } - replacesPriceId() - allocationPrice()?.validate() - discounts()?.forEach { it.validate() } - externalPriceId() - fixedPriceQuantity() - maximumAmount() - minimumAmount() - price()?.validate() - priceId() + adjustment().validate() + replacesAdjustmentId() validated = true } @@ -12911,1227 +13511,3972 @@ private constructor( * Used for best match union deserialization. */ internal fun validity(): Int = - (if (replacesPriceId.asKnown() == null) 0 else 1) + - (allocationPrice.asKnown()?.validity() ?: 0) + - (discounts.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + - (if (externalPriceId.asKnown() == null) 0 else 1) + - (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + - (if (maximumAmount.asKnown() == null) 0 else 1) + - (if (minimumAmount.asKnown() == null) 0 else 1) + - (price.asKnown()?.validity() ?: 0) + - (if (priceId.asKnown() == null) 0 else 1) + (adjustment.asKnown()?.validity() ?: 0) + + (if (replacesAdjustmentId.asKnown() == null) 0 else 1) - /** New subscription price request body params. */ - @JsonDeserialize(using = Price.Deserializer::class) - @JsonSerialize(using = Price.Serializer::class) - class Price + /** The definition of a new adjustment to create and add to the subscription. */ + @JsonDeserialize(using = Adjustment.Deserializer::class) + @JsonSerialize(using = Adjustment.Serializer::class) + class Adjustment private constructor( - private val unit: NewSubscriptionUnitPrice? = null, - private val tiered: NewSubscriptionTieredPrice? = null, - private val bulk: NewSubscriptionBulkPrice? = null, - private val package_: NewSubscriptionPackagePrice? = null, - private val matrix: NewSubscriptionMatrixPrice? = null, - private val thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice? = null, - private val tieredPackage: NewSubscriptionTieredPackagePrice? = null, - private val tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice? = null, - private val groupedTiered: NewSubscriptionGroupedTieredPrice? = null, - private val tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice? = - null, - private val packageWithAllocation: NewSubscriptionPackageWithAllocationPrice? = null, - private val unitWithPercent: NewSubscriptionUnitWithPercentPrice? = null, - private val matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice? = null, - private val tieredWithProration: TieredWithProration? = null, - private val unitWithProration: NewSubscriptionUnitWithProrationPrice? = null, - private val groupedAllocation: NewSubscriptionGroupedAllocationPrice? = null, - private val bulkWithProration: NewSubscriptionBulkWithProrationPrice? = null, - private val groupedWithProratedMinimum: - NewSubscriptionGroupedWithProratedMinimumPrice? = - null, - private val groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice? = - null, - private val groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds? = null, - private val matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice? = null, - private val groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice? = null, - private val maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice? = null, - private val scalableMatrixWithUnitPricing: - NewSubscriptionScalableMatrixWithUnitPricingPrice? = - null, - private val scalableMatrixWithTieredPricing: - NewSubscriptionScalableMatrixWithTieredPricingPrice? = - null, - private val cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice? = null, - private val minimum: NewSubscriptionMinimumCompositePrice? = null, - private val eventOutput: EventOutput? = null, + private val percentageDiscount: NewPercentageDiscount? = null, + private val usageDiscount: NewUsageDiscount? = null, + private val amountDiscount: NewAmountDiscount? = null, + private val minimum: NewMinimum? = null, + private val maximum: NewMaximum? = null, private val _json: JsonValue? = null, ) { - fun unit(): NewSubscriptionUnitPrice? = unit - - fun tiered(): NewSubscriptionTieredPrice? = tiered + fun percentageDiscount(): NewPercentageDiscount? = percentageDiscount - fun bulk(): NewSubscriptionBulkPrice? = bulk + fun usageDiscount(): NewUsageDiscount? = usageDiscount - fun package_(): NewSubscriptionPackagePrice? = package_ + fun amountDiscount(): NewAmountDiscount? = amountDiscount - fun matrix(): NewSubscriptionMatrixPrice? = matrix + fun minimum(): NewMinimum? = minimum - fun thresholdTotalAmount(): NewSubscriptionThresholdTotalAmountPrice? = - thresholdTotalAmount + fun maximum(): NewMaximum? = maximum - fun tieredPackage(): NewSubscriptionTieredPackagePrice? = tieredPackage + fun isPercentageDiscount(): Boolean = percentageDiscount != null - fun tieredWithMinimum(): NewSubscriptionTieredWithMinimumPrice? = tieredWithMinimum + fun isUsageDiscount(): Boolean = usageDiscount != null - fun groupedTiered(): NewSubscriptionGroupedTieredPrice? = groupedTiered + fun isAmountDiscount(): Boolean = amountDiscount != null - fun tieredPackageWithMinimum(): NewSubscriptionTieredPackageWithMinimumPrice? = - tieredPackageWithMinimum + fun isMinimum(): Boolean = minimum != null - fun packageWithAllocation(): NewSubscriptionPackageWithAllocationPrice? = - packageWithAllocation + fun isMaximum(): Boolean = maximum != null - fun unitWithPercent(): NewSubscriptionUnitWithPercentPrice? = unitWithPercent + fun asPercentageDiscount(): NewPercentageDiscount = + percentageDiscount.getOrThrow("percentageDiscount") - fun matrixWithAllocation(): NewSubscriptionMatrixWithAllocationPrice? = - matrixWithAllocation + fun asUsageDiscount(): NewUsageDiscount = usageDiscount.getOrThrow("usageDiscount") - fun tieredWithProration(): TieredWithProration? = tieredWithProration + fun asAmountDiscount(): NewAmountDiscount = amountDiscount.getOrThrow("amountDiscount") - fun unitWithProration(): NewSubscriptionUnitWithProrationPrice? = unitWithProration + fun asMinimum(): NewMinimum = minimum.getOrThrow("minimum") - fun groupedAllocation(): NewSubscriptionGroupedAllocationPrice? = groupedAllocation + fun asMaximum(): NewMaximum = maximum.getOrThrow("maximum") - fun bulkWithProration(): NewSubscriptionBulkWithProrationPrice? = bulkWithProration + fun _json(): JsonValue? = _json - fun groupedWithProratedMinimum(): NewSubscriptionGroupedWithProratedMinimumPrice? = - groupedWithProratedMinimum + fun accept(visitor: Visitor): T = + when { + percentageDiscount != null -> + visitor.visitPercentageDiscount(percentageDiscount) + usageDiscount != null -> visitor.visitUsageDiscount(usageDiscount) + amountDiscount != null -> visitor.visitAmountDiscount(amountDiscount) + minimum != null -> visitor.visitMinimum(minimum) + maximum != null -> visitor.visitMaximum(maximum) + else -> visitor.unknown(_json) + } - fun groupedWithMeteredMinimum(): NewSubscriptionGroupedWithMeteredMinimumPrice? = - groupedWithMeteredMinimum + private var validated: Boolean = false - fun groupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds? = - groupedWithMinMaxThresholds + fun validate(): Adjustment = apply { + if (validated) { + return@apply + } - fun matrixWithDisplayName(): NewSubscriptionMatrixWithDisplayNamePrice? = - matrixWithDisplayName + accept( + object : Visitor { + override fun visitPercentageDiscount( + percentageDiscount: NewPercentageDiscount + ) { + percentageDiscount.validate() + } - fun groupedTieredPackage(): NewSubscriptionGroupedTieredPackagePrice? = - groupedTieredPackage + override fun visitUsageDiscount(usageDiscount: NewUsageDiscount) { + usageDiscount.validate() + } - fun maxGroupTieredPackage(): NewSubscriptionMaxGroupTieredPackagePrice? = - maxGroupTieredPackage + override fun visitAmountDiscount(amountDiscount: NewAmountDiscount) { + amountDiscount.validate() + } - fun scalableMatrixWithUnitPricing(): - NewSubscriptionScalableMatrixWithUnitPricingPrice? = scalableMatrixWithUnitPricing + override fun visitMinimum(minimum: NewMinimum) { + minimum.validate() + } - fun scalableMatrixWithTieredPricing(): - NewSubscriptionScalableMatrixWithTieredPricingPrice? = - scalableMatrixWithTieredPricing + override fun visitMaximum(maximum: NewMaximum) { + maximum.validate() + } + } + ) + validated = true + } - fun cumulativeGroupedBulk(): NewSubscriptionCumulativeGroupedBulkPrice? = - cumulativeGroupedBulk + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - fun minimum(): NewSubscriptionMinimumCompositePrice? = minimum + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitPercentageDiscount( + percentageDiscount: NewPercentageDiscount + ) = percentageDiscount.validity() - fun eventOutput(): EventOutput? = eventOutput + override fun visitUsageDiscount(usageDiscount: NewUsageDiscount) = + usageDiscount.validity() - fun isUnit(): Boolean = unit != null + override fun visitAmountDiscount(amountDiscount: NewAmountDiscount) = + amountDiscount.validity() - fun isTiered(): Boolean = tiered != null + override fun visitMinimum(minimum: NewMinimum) = minimum.validity() - fun isBulk(): Boolean = bulk != null + override fun visitMaximum(maximum: NewMaximum) = maximum.validity() - fun isPackage(): Boolean = package_ != null + override fun unknown(json: JsonValue?) = 0 + } + ) - fun isMatrix(): Boolean = matrix != null + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun isThresholdTotalAmount(): Boolean = thresholdTotalAmount != null + return other is Adjustment && + percentageDiscount == other.percentageDiscount && + usageDiscount == other.usageDiscount && + amountDiscount == other.amountDiscount && + minimum == other.minimum && + maximum == other.maximum + } - fun isTieredPackage(): Boolean = tieredPackage != null + override fun hashCode(): Int = + Objects.hash(percentageDiscount, usageDiscount, amountDiscount, minimum, maximum) - fun isTieredWithMinimum(): Boolean = tieredWithMinimum != null + override fun toString(): String = + when { + percentageDiscount != null -> + "Adjustment{percentageDiscount=$percentageDiscount}" + usageDiscount != null -> "Adjustment{usageDiscount=$usageDiscount}" + amountDiscount != null -> "Adjustment{amountDiscount=$amountDiscount}" + minimum != null -> "Adjustment{minimum=$minimum}" + maximum != null -> "Adjustment{maximum=$maximum}" + _json != null -> "Adjustment{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Adjustment") + } - fun isGroupedTiered(): Boolean = groupedTiered != null + companion object { - fun isTieredPackageWithMinimum(): Boolean = tieredPackageWithMinimum != null + fun ofPercentageDiscount(percentageDiscount: NewPercentageDiscount) = + Adjustment(percentageDiscount = percentageDiscount) - fun isPackageWithAllocation(): Boolean = packageWithAllocation != null + fun ofUsageDiscount(usageDiscount: NewUsageDiscount) = + Adjustment(usageDiscount = usageDiscount) - fun isUnitWithPercent(): Boolean = unitWithPercent != null + fun ofAmountDiscount(amountDiscount: NewAmountDiscount) = + Adjustment(amountDiscount = amountDiscount) - fun isMatrixWithAllocation(): Boolean = matrixWithAllocation != null + fun ofMinimum(minimum: NewMinimum) = Adjustment(minimum = minimum) - fun isTieredWithProration(): Boolean = tieredWithProration != null + fun ofMaximum(maximum: NewMaximum) = Adjustment(maximum = maximum) + } - fun isUnitWithProration(): Boolean = unitWithProration != null + /** + * An interface that defines how to map each variant of [Adjustment] to a value of type + * [T]. + */ + interface Visitor { - fun isGroupedAllocation(): Boolean = groupedAllocation != null + fun visitPercentageDiscount(percentageDiscount: NewPercentageDiscount): T - fun isBulkWithProration(): Boolean = bulkWithProration != null + fun visitUsageDiscount(usageDiscount: NewUsageDiscount): T - fun isGroupedWithProratedMinimum(): Boolean = groupedWithProratedMinimum != null + fun visitAmountDiscount(amountDiscount: NewAmountDiscount): T - fun isGroupedWithMeteredMinimum(): Boolean = groupedWithMeteredMinimum != null + fun visitMinimum(minimum: NewMinimum): T - fun isGroupedWithMinMaxThresholds(): Boolean = groupedWithMinMaxThresholds != null + fun visitMaximum(maximum: NewMaximum): T - fun isMatrixWithDisplayName(): Boolean = matrixWithDisplayName != null + /** + * Maps an unknown variant of [Adjustment] to a value of type [T]. + * + * An instance of [Adjustment] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the + * SDK is unaware of. + * + * @throws OrbInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw OrbInvalidDataException("Unknown Adjustment: $json") + } + } - fun isGroupedTieredPackage(): Boolean = groupedTieredPackage != null + internal class Deserializer : BaseDeserializer(Adjustment::class) { - fun isMaxGroupTieredPackage(): Boolean = maxGroupTieredPackage != null + override fun ObjectCodec.deserialize(node: JsonNode): Adjustment { + val json = JsonValue.fromJsonNode(node) + val adjustmentType = json.asObject()?.get("adjustment_type")?.asString() - fun isScalableMatrixWithUnitPricing(): Boolean = scalableMatrixWithUnitPricing != null + when (adjustmentType) { + "percentage_discount" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Adjustment(percentageDiscount = it, _json = json) } + ?: Adjustment(_json = json) + } + "usage_discount" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(usageDiscount = it, _json = json) + } ?: Adjustment(_json = json) + } + "amount_discount" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(amountDiscount = it, _json = json) + } ?: Adjustment(_json = json) + } + "minimum" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(minimum = it, _json = json) + } ?: Adjustment(_json = json) + } + "maximum" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(maximum = it, _json = json) + } ?: Adjustment(_json = json) + } + } - fun isScalableMatrixWithTieredPricing(): Boolean = - scalableMatrixWithTieredPricing != null + return Adjustment(_json = json) + } + } - fun isCumulativeGroupedBulk(): Boolean = cumulativeGroupedBulk != null + internal class Serializer : BaseSerializer(Adjustment::class) { - fun isMinimum(): Boolean = minimum != null + override fun serialize( + value: Adjustment, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.percentageDiscount != null -> + generator.writeObject(value.percentageDiscount) + value.usageDiscount != null -> generator.writeObject(value.usageDiscount) + value.amountDiscount != null -> generator.writeObject(value.amountDiscount) + value.minimum != null -> generator.writeObject(value.minimum) + value.maximum != null -> generator.writeObject(value.maximum) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Adjustment") + } + } + } + } - fun isEventOutput(): Boolean = eventOutput != null + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun asUnit(): NewSubscriptionUnitPrice = unit.getOrThrow("unit") + return other is ReplaceAdjustment && + adjustment == other.adjustment && + replacesAdjustmentId == other.replacesAdjustmentId && + additionalProperties == other.additionalProperties + } - fun asTiered(): NewSubscriptionTieredPrice = tiered.getOrThrow("tiered") + private val hashCode: Int by lazy { + Objects.hash(adjustment, replacesAdjustmentId, additionalProperties) + } - fun asBulk(): NewSubscriptionBulkPrice = bulk.getOrThrow("bulk") + override fun hashCode(): Int = hashCode - fun asPackage(): NewSubscriptionPackagePrice = package_.getOrThrow("package_") + override fun toString() = + "ReplaceAdjustment{adjustment=$adjustment, replacesAdjustmentId=$replacesAdjustmentId, additionalProperties=$additionalProperties}" + } - fun asMatrix(): NewSubscriptionMatrixPrice = matrix.getOrThrow("matrix") + class ReplacePrice + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val replacesPriceId: JsonField, + private val allocationPrice: JsonField, + private val discounts: JsonField>, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val maximumAmount: JsonField, + private val minimumAmount: JsonField, + private val price: JsonField, + private val priceId: JsonField, + private val additionalProperties: MutableMap, + ) { - fun asThresholdTotalAmount(): NewSubscriptionThresholdTotalAmountPrice = - thresholdTotalAmount.getOrThrow("thresholdTotalAmount") + @JsonCreator + private constructor( + @JsonProperty("replaces_price_id") + @ExcludeMissing + replacesPriceId: JsonField = JsonMissing.of(), + @JsonProperty("allocation_price") + @ExcludeMissing + allocationPrice: JsonField = JsonMissing.of(), + @JsonProperty("discounts") + @ExcludeMissing + discounts: JsonField> = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("maximum_amount") + @ExcludeMissing + maximumAmount: JsonField = JsonMissing.of(), + @JsonProperty("minimum_amount") + @ExcludeMissing + minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("price") @ExcludeMissing price: JsonField = JsonMissing.of(), + @JsonProperty("price_id") @ExcludeMissing priceId: JsonField = JsonMissing.of(), + ) : this( + replacesPriceId, + allocationPrice, + discounts, + externalPriceId, + fixedPriceQuantity, + maximumAmount, + minimumAmount, + price, + priceId, + mutableMapOf(), + ) - fun asTieredPackage(): NewSubscriptionTieredPackagePrice = - tieredPackage.getOrThrow("tieredPackage") + /** + * The id of the price on the plan to replace in the subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun replacesPriceId(): String = replacesPriceId.getRequired("replaces_price_id") - fun asTieredWithMinimum(): NewSubscriptionTieredWithMinimumPrice = - tieredWithMinimum.getOrThrow("tieredWithMinimum") + /** + * The definition of a new allocation price to create and add to the subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun allocationPrice(): NewAllocationPrice? = allocationPrice.getNullable("allocation_price") - fun asGroupedTiered(): NewSubscriptionGroupedTieredPrice = - groupedTiered.getOrThrow("groupedTiered") + /** + * [DEPRECATED] Use add_adjustments instead. The subscription's discounts for the + * replacement price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + @Deprecated("deprecated") + fun discounts(): List? = discounts.getNullable("discounts") - fun asTieredPackageWithMinimum(): NewSubscriptionTieredPackageWithMinimumPrice = - tieredPackageWithMinimum.getOrThrow("tieredPackageWithMinimum") + /** + * The external price id of the price to add to the subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") - fun asPackageWithAllocation(): NewSubscriptionPackageWithAllocationPrice = - packageWithAllocation.getOrThrow("packageWithAllocation") + /** + * The new quantity of the price, if the price is a fixed price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = fixedPriceQuantity.getNullable("fixed_price_quantity") - fun asUnitWithPercent(): NewSubscriptionUnitWithPercentPrice = - unitWithPercent.getOrThrow("unitWithPercent") + /** + * [DEPRECATED] Use add_adjustments instead. The subscription's maximum amount for the + * replacement price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + @Deprecated("deprecated") + fun maximumAmount(): String? = maximumAmount.getNullable("maximum_amount") - fun asMatrixWithAllocation(): NewSubscriptionMatrixWithAllocationPrice = - matrixWithAllocation.getOrThrow("matrixWithAllocation") + /** + * [DEPRECATED] Use add_adjustments instead. The subscription's minimum amount for the + * replacement price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + @Deprecated("deprecated") + fun minimumAmount(): String? = minimumAmount.getNullable("minimum_amount") - fun asTieredWithProration(): TieredWithProration = - tieredWithProration.getOrThrow("tieredWithProration") + /** + * New subscription price request body params. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun price(): Price? = price.getNullable("price") - fun asUnitWithProration(): NewSubscriptionUnitWithProrationPrice = - unitWithProration.getOrThrow("unitWithProration") + /** + * The id of the price to add to the subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun priceId(): String? = priceId.getNullable("price_id") - fun asGroupedAllocation(): NewSubscriptionGroupedAllocationPrice = - groupedAllocation.getOrThrow("groupedAllocation") + /** + * Returns the raw JSON value of [replacesPriceId]. + * + * Unlike [replacesPriceId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("replaces_price_id") + @ExcludeMissing + fun _replacesPriceId(): JsonField = replacesPriceId - fun asBulkWithProration(): NewSubscriptionBulkWithProrationPrice = - bulkWithProration.getOrThrow("bulkWithProration") + /** + * Returns the raw JSON value of [allocationPrice]. + * + * Unlike [allocationPrice], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("allocation_price") + @ExcludeMissing + fun _allocationPrice(): JsonField = allocationPrice - fun asGroupedWithProratedMinimum(): NewSubscriptionGroupedWithProratedMinimumPrice = - groupedWithProratedMinimum.getOrThrow("groupedWithProratedMinimum") + /** + * Returns the raw JSON value of [discounts]. + * + * Unlike [discounts], this method doesn't throw if the JSON field has an unexpected type. + */ + @Deprecated("deprecated") + @JsonProperty("discounts") + @ExcludeMissing + fun _discounts(): JsonField> = discounts - fun asGroupedWithMeteredMinimum(): NewSubscriptionGroupedWithMeteredMinimumPrice = - groupedWithMeteredMinimum.getOrThrow("groupedWithMeteredMinimum") + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId - fun asGroupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds = - groupedWithMinMaxThresholds.getOrThrow("groupedWithMinMaxThresholds") + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - fun asMatrixWithDisplayName(): NewSubscriptionMatrixWithDisplayNamePrice = - matrixWithDisplayName.getOrThrow("matrixWithDisplayName") + /** + * Returns the raw JSON value of [maximumAmount]. + * + * Unlike [maximumAmount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @Deprecated("deprecated") + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount - fun asGroupedTieredPackage(): NewSubscriptionGroupedTieredPackagePrice = - groupedTieredPackage.getOrThrow("groupedTieredPackage") + /** + * Returns the raw JSON value of [minimumAmount]. + * + * Unlike [minimumAmount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @Deprecated("deprecated") + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount - fun asMaxGroupTieredPackage(): NewSubscriptionMaxGroupTieredPackagePrice = - maxGroupTieredPackage.getOrThrow("maxGroupTieredPackage") + /** + * Returns the raw JSON value of [price]. + * + * Unlike [price], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("price") @ExcludeMissing fun _price(): JsonField = price - fun asScalableMatrixWithUnitPricing(): - NewSubscriptionScalableMatrixWithUnitPricingPrice = - scalableMatrixWithUnitPricing.getOrThrow("scalableMatrixWithUnitPricing") + /** + * Returns the raw JSON value of [priceId]. + * + * Unlike [priceId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId - fun asScalableMatrixWithTieredPricing(): - NewSubscriptionScalableMatrixWithTieredPricingPrice = - scalableMatrixWithTieredPricing.getOrThrow("scalableMatrixWithTieredPricing") + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - fun asCumulativeGroupedBulk(): NewSubscriptionCumulativeGroupedBulkPrice = - cumulativeGroupedBulk.getOrThrow("cumulativeGroupedBulk") + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - fun asMinimum(): NewSubscriptionMinimumCompositePrice = minimum.getOrThrow("minimum") + fun toBuilder() = Builder().from(this) - fun asEventOutput(): EventOutput = eventOutput.getOrThrow("eventOutput") + companion object { - fun _json(): JsonValue? = _json + /** + * Returns a mutable builder for constructing an instance of [ReplacePrice]. + * + * The following fields are required: + * ```kotlin + * .replacesPriceId() + * ``` + */ + fun builder() = Builder() + } - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - bulk != null -> visitor.visitBulk(bulk) - package_ != null -> visitor.visitPackage(package_) - matrix != null -> visitor.visitMatrix(matrix) - thresholdTotalAmount != null -> - visitor.visitThresholdTotalAmount(thresholdTotalAmount) - tieredPackage != null -> visitor.visitTieredPackage(tieredPackage) - tieredWithMinimum != null -> visitor.visitTieredWithMinimum(tieredWithMinimum) - groupedTiered != null -> visitor.visitGroupedTiered(groupedTiered) - tieredPackageWithMinimum != null -> - visitor.visitTieredPackageWithMinimum(tieredPackageWithMinimum) - packageWithAllocation != null -> - visitor.visitPackageWithAllocation(packageWithAllocation) - unitWithPercent != null -> visitor.visitUnitWithPercent(unitWithPercent) - matrixWithAllocation != null -> - visitor.visitMatrixWithAllocation(matrixWithAllocation) - tieredWithProration != null -> - visitor.visitTieredWithProration(tieredWithProration) - unitWithProration != null -> visitor.visitUnitWithProration(unitWithProration) - groupedAllocation != null -> visitor.visitGroupedAllocation(groupedAllocation) - bulkWithProration != null -> visitor.visitBulkWithProration(bulkWithProration) - groupedWithProratedMinimum != null -> - visitor.visitGroupedWithProratedMinimum(groupedWithProratedMinimum) - groupedWithMeteredMinimum != null -> - visitor.visitGroupedWithMeteredMinimum(groupedWithMeteredMinimum) - groupedWithMinMaxThresholds != null -> - visitor.visitGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds) - matrixWithDisplayName != null -> - visitor.visitMatrixWithDisplayName(matrixWithDisplayName) - groupedTieredPackage != null -> - visitor.visitGroupedTieredPackage(groupedTieredPackage) - maxGroupTieredPackage != null -> - visitor.visitMaxGroupTieredPackage(maxGroupTieredPackage) - scalableMatrixWithUnitPricing != null -> - visitor.visitScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing) - scalableMatrixWithTieredPricing != null -> - visitor.visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing - ) - cumulativeGroupedBulk != null -> - visitor.visitCumulativeGroupedBulk(cumulativeGroupedBulk) - minimum != null -> visitor.visitMinimum(minimum) - eventOutput != null -> visitor.visitEventOutput(eventOutput) - else -> visitor.unknown(_json) - } + /** A builder for [ReplacePrice]. */ + class Builder internal constructor() { - private var validated: Boolean = false + private var replacesPriceId: JsonField? = null + private var allocationPrice: JsonField = JsonMissing.of() + private var discounts: JsonField>? = null + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var maximumAmount: JsonField = JsonMissing.of() + private var minimumAmount: JsonField = JsonMissing.of() + private var price: JsonField = JsonMissing.of() + private var priceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - fun validate(): Price = apply { - if (validated) { - return@apply - } + internal fun from(replacePrice: ReplacePrice) = apply { + replacesPriceId = replacePrice.replacesPriceId + allocationPrice = replacePrice.allocationPrice + discounts = replacePrice.discounts.map { it.toMutableList() } + externalPriceId = replacePrice.externalPriceId + fixedPriceQuantity = replacePrice.fixedPriceQuantity + maximumAmount = replacePrice.maximumAmount + minimumAmount = replacePrice.minimumAmount + price = replacePrice.price + priceId = replacePrice.priceId + additionalProperties = replacePrice.additionalProperties.toMutableMap() + } - accept( - object : Visitor { - override fun visitUnit(unit: NewSubscriptionUnitPrice) { - unit.validate() - } + /** The id of the price on the plan to replace in the subscription. */ + fun replacesPriceId(replacesPriceId: String) = + replacesPriceId(JsonField.of(replacesPriceId)) - override fun visitTiered(tiered: NewSubscriptionTieredPrice) { - tiered.validate() - } + /** + * Sets [Builder.replacesPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.replacesPriceId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun replacesPriceId(replacesPriceId: JsonField) = apply { + this.replacesPriceId = replacesPriceId + } - override fun visitBulk(bulk: NewSubscriptionBulkPrice) { - bulk.validate() - } + /** The definition of a new allocation price to create and add to the subscription. */ + fun allocationPrice(allocationPrice: NewAllocationPrice?) = + allocationPrice(JsonField.ofNullable(allocationPrice)) - override fun visitPackage(package_: NewSubscriptionPackagePrice) { - package_.validate() - } + /** + * Sets [Builder.allocationPrice] to an arbitrary JSON value. + * + * You should usually call [Builder.allocationPrice] with a well-typed + * [NewAllocationPrice] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun allocationPrice(allocationPrice: JsonField) = apply { + this.allocationPrice = allocationPrice + } - override fun visitMatrix(matrix: NewSubscriptionMatrixPrice) { - matrix.validate() - } + /** + * [DEPRECATED] Use add_adjustments instead. The subscription's discounts for the + * replacement price. + */ + @Deprecated("deprecated") + fun discounts(discounts: List?) = + discounts(JsonField.ofNullable(discounts)) - override fun visitThresholdTotalAmount( - thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice - ) { - thresholdTotalAmount.validate() - } + /** + * Sets [Builder.discounts] to an arbitrary JSON value. + * + * You should usually call [Builder.discounts] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + @Deprecated("deprecated") + fun discounts(discounts: JsonField>) = apply { + this.discounts = discounts.map { it.toMutableList() } + } - override fun visitTieredPackage( - tieredPackage: NewSubscriptionTieredPackagePrice - ) { - tieredPackage.validate() - } + /** + * Adds a single [DiscountOverride] to [discounts]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + @Deprecated("deprecated") + fun addDiscount(discount: DiscountOverride) = apply { + discounts = + (discounts ?: JsonField.of(mutableListOf())).also { + checkKnown("discounts", it).add(discount) + } + } - override fun visitTieredWithMinimum( - tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice - ) { - tieredWithMinimum.validate() - } + /** The external price id of the price to add to the subscription. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) - override fun visitGroupedTiered( - groupedTiered: NewSubscriptionGroupedTieredPrice - ) { - groupedTiered.validate() - } + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } - override fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice - ) { - tieredPackageWithMinimum.validate() - } + /** The new quantity of the price, if the price is a fixed price. */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) - override fun visitPackageWithAllocation( - packageWithAllocation: NewSubscriptionPackageWithAllocationPrice - ) { - packageWithAllocation.validate() - } + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) - override fun visitUnitWithPercent( - unitWithPercent: NewSubscriptionUnitWithPercentPrice - ) { - unitWithPercent.validate() - } + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } - override fun visitMatrixWithAllocation( - matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice - ) { - matrixWithAllocation.validate() - } + /** + * [DEPRECATED] Use add_adjustments instead. The subscription's maximum amount for the + * replacement price. + */ + @Deprecated("deprecated") + fun maximumAmount(maximumAmount: String?) = + maximumAmount(JsonField.ofNullable(maximumAmount)) - override fun visitTieredWithProration( - tieredWithProration: TieredWithProration - ) { - tieredWithProration.validate() - } + /** + * Sets [Builder.maximumAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.maximumAmount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + @Deprecated("deprecated") + fun maximumAmount(maximumAmount: JsonField) = apply { + this.maximumAmount = maximumAmount + } - override fun visitUnitWithProration( - unitWithProration: NewSubscriptionUnitWithProrationPrice - ) { - unitWithProration.validate() - } + /** + * [DEPRECATED] Use add_adjustments instead. The subscription's minimum amount for the + * replacement price. + */ + @Deprecated("deprecated") + fun minimumAmount(minimumAmount: String?) = + minimumAmount(JsonField.ofNullable(minimumAmount)) - override fun visitGroupedAllocation( - groupedAllocation: NewSubscriptionGroupedAllocationPrice - ) { - groupedAllocation.validate() - } + /** + * Sets [Builder.minimumAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumAmount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + @Deprecated("deprecated") + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount + } - override fun visitBulkWithProration( - bulkWithProration: NewSubscriptionBulkWithProrationPrice - ) { - bulkWithProration.validate() - } + /** New subscription price request body params. */ + fun price(price: Price?) = price(JsonField.ofNullable(price)) - override fun visitGroupedWithProratedMinimum( - groupedWithProratedMinimum: - NewSubscriptionGroupedWithProratedMinimumPrice - ) { - groupedWithProratedMinimum.validate() - } + /** + * Sets [Builder.price] to an arbitrary JSON value. + * + * You should usually call [Builder.price] with a well-typed [Price] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun price(price: JsonField) = apply { this.price = price } - override fun visitGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice - ) { - groupedWithMeteredMinimum.validate() - } + /** Alias for calling [price] with `Price.ofUnit(unit)`. */ + fun price(unit: NewSubscriptionUnitPrice) = price(Price.ofUnit(unit)) - override fun visitGroupedWithMinMaxThresholds( - groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds - ) { - groupedWithMinMaxThresholds.validate() - } + /** Alias for calling [price] with `Price.ofTiered(tiered)`. */ + fun price(tiered: NewSubscriptionTieredPrice) = price(Price.ofTiered(tiered)) - override fun visitMatrixWithDisplayName( - matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice - ) { - matrixWithDisplayName.validate() - } + /** Alias for calling [price] with `Price.ofBulk(bulk)`. */ + fun price(bulk: NewSubscriptionBulkPrice) = price(Price.ofBulk(bulk)) - override fun visitGroupedTieredPackage( - groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice - ) { - groupedTieredPackage.validate() - } - - override fun visitMaxGroupTieredPackage( - maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice - ) { - maxGroupTieredPackage.validate() - } + /** Alias for calling [price] with `Price.ofPackage(package_)`. */ + fun price(package_: NewSubscriptionPackagePrice) = price(Price.ofPackage(package_)) - override fun visitScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: - NewSubscriptionScalableMatrixWithUnitPricingPrice - ) { - scalableMatrixWithUnitPricing.validate() - } + /** Alias for calling [price] with `Price.ofMatrix(matrix)`. */ + fun price(matrix: NewSubscriptionMatrixPrice) = price(Price.ofMatrix(matrix)) - override fun visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: - NewSubscriptionScalableMatrixWithTieredPricingPrice - ) { - scalableMatrixWithTieredPricing.validate() - } + /** + * Alias for calling [price] with `Price.ofThresholdTotalAmount(thresholdTotalAmount)`. + */ + fun price(thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice) = + price(Price.ofThresholdTotalAmount(thresholdTotalAmount)) - override fun visitCumulativeGroupedBulk( - cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice - ) { - cumulativeGroupedBulk.validate() - } + /** Alias for calling [price] with `Price.ofTieredPackage(tieredPackage)`. */ + fun price(tieredPackage: NewSubscriptionTieredPackagePrice) = + price(Price.ofTieredPackage(tieredPackage)) - override fun visitMinimum(minimum: NewSubscriptionMinimumCompositePrice) { - minimum.validate() - } + /** Alias for calling [price] with `Price.ofTieredWithMinimum(tieredWithMinimum)`. */ + fun price(tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice) = + price(Price.ofTieredWithMinimum(tieredWithMinimum)) - override fun visitEventOutput(eventOutput: EventOutput) { - eventOutput.validate() - } - } - ) - validated = true - } + /** Alias for calling [price] with `Price.ofGroupedTiered(groupedTiered)`. */ + fun price(groupedTiered: NewSubscriptionGroupedTieredPrice) = + price(Price.ofGroupedTiered(groupedTiered)) - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** + * Alias for calling [price] with + * `Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)`. + */ + fun price(tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice) = + price(Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)) /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. + * Alias for calling [price] with + * `Price.ofPackageWithAllocation(packageWithAllocation)`. */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: NewSubscriptionUnitPrice) = unit.validity() + fun price(packageWithAllocation: NewSubscriptionPackageWithAllocationPrice) = + price(Price.ofPackageWithAllocation(packageWithAllocation)) - override fun visitTiered(tiered: NewSubscriptionTieredPrice) = - tiered.validity() + /** Alias for calling [price] with `Price.ofUnitWithPercent(unitWithPercent)`. */ + fun price(unitWithPercent: NewSubscriptionUnitWithPercentPrice) = + price(Price.ofUnitWithPercent(unitWithPercent)) - override fun visitBulk(bulk: NewSubscriptionBulkPrice) = bulk.validity() + /** + * Alias for calling [price] with `Price.ofMatrixWithAllocation(matrixWithAllocation)`. + */ + fun price(matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice) = + price(Price.ofMatrixWithAllocation(matrixWithAllocation)) - override fun visitPackage(package_: NewSubscriptionPackagePrice) = - package_.validity() + /** + * Alias for calling [price] with `Price.ofTieredWithProration(tieredWithProration)`. + */ + fun price(tieredWithProration: Price.TieredWithProration) = + price(Price.ofTieredWithProration(tieredWithProration)) - override fun visitMatrix(matrix: NewSubscriptionMatrixPrice) = - matrix.validity() + /** Alias for calling [price] with `Price.ofUnitWithProration(unitWithProration)`. */ + fun price(unitWithProration: NewSubscriptionUnitWithProrationPrice) = + price(Price.ofUnitWithProration(unitWithProration)) - override fun visitThresholdTotalAmount( - thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice - ) = thresholdTotalAmount.validity() + /** Alias for calling [price] with `Price.ofGroupedAllocation(groupedAllocation)`. */ + fun price(groupedAllocation: NewSubscriptionGroupedAllocationPrice) = + price(Price.ofGroupedAllocation(groupedAllocation)) - override fun visitTieredPackage( - tieredPackage: NewSubscriptionTieredPackagePrice - ) = tieredPackage.validity() + /** Alias for calling [price] with `Price.ofBulkWithProration(bulkWithProration)`. */ + fun price(bulkWithProration: NewSubscriptionBulkWithProrationPrice) = + price(Price.ofBulkWithProration(bulkWithProration)) - override fun visitTieredWithMinimum( - tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice - ) = tieredWithMinimum.validity() + /** + * Alias for calling [price] with + * `Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)`. + */ + fun price(groupedWithProratedMinimum: NewSubscriptionGroupedWithProratedMinimumPrice) = + price(Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)) - override fun visitGroupedTiered( - groupedTiered: NewSubscriptionGroupedTieredPrice - ) = groupedTiered.validity() + /** + * Alias for calling [price] with + * `Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)`. + */ + fun price(groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice) = + price(Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)) - override fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice - ) = tieredPackageWithMinimum.validity() + /** + * Alias for calling [price] with + * `Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)`. + */ + fun price(groupedWithMinMaxThresholds: Price.GroupedWithMinMaxThresholds) = + price(Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)) - override fun visitPackageWithAllocation( - packageWithAllocation: NewSubscriptionPackageWithAllocationPrice - ) = packageWithAllocation.validity() + /** + * Alias for calling [price] with + * `Price.ofMatrixWithDisplayName(matrixWithDisplayName)`. + */ + fun price(matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice) = + price(Price.ofMatrixWithDisplayName(matrixWithDisplayName)) - override fun visitUnitWithPercent( - unitWithPercent: NewSubscriptionUnitWithPercentPrice - ) = unitWithPercent.validity() + /** + * Alias for calling [price] with `Price.ofGroupedTieredPackage(groupedTieredPackage)`. + */ + fun price(groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice) = + price(Price.ofGroupedTieredPackage(groupedTieredPackage)) - override fun visitMatrixWithAllocation( - matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice - ) = matrixWithAllocation.validity() + /** + * Alias for calling [price] with + * `Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)`. + */ + fun price(maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice) = + price(Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)) - override fun visitTieredWithProration( - tieredWithProration: TieredWithProration - ) = tieredWithProration.validity() + /** + * Alias for calling [price] with + * `Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)`. + */ + fun price( + scalableMatrixWithUnitPricing: NewSubscriptionScalableMatrixWithUnitPricingPrice + ) = price(Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)) - override fun visitUnitWithProration( - unitWithProration: NewSubscriptionUnitWithProrationPrice - ) = unitWithProration.validity() + /** + * Alias for calling [price] with + * `Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)`. + */ + fun price( + scalableMatrixWithTieredPricing: NewSubscriptionScalableMatrixWithTieredPricingPrice + ) = price(Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)) - override fun visitGroupedAllocation( - groupedAllocation: NewSubscriptionGroupedAllocationPrice - ) = groupedAllocation.validity() + /** + * Alias for calling [price] with + * `Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)`. + */ + fun price(cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice) = + price(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) - override fun visitBulkWithProration( - bulkWithProration: NewSubscriptionBulkWithProrationPrice - ) = bulkWithProration.validity() + /** Alias for calling [price] with `Price.ofMinimum(minimum)`. */ + fun price(minimum: NewSubscriptionMinimumCompositePrice) = + price(Price.ofMinimum(minimum)) - override fun visitGroupedWithProratedMinimum( - groupedWithProratedMinimum: - NewSubscriptionGroupedWithProratedMinimumPrice - ) = groupedWithProratedMinimum.validity() + /** Alias for calling [price] with `Price.ofPercent(percent)`. */ + fun price(percent: Price.Percent) = price(Price.ofPercent(percent)) - override fun visitGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice - ) = groupedWithMeteredMinimum.validity() + /** Alias for calling [price] with `Price.ofEventOutput(eventOutput)`. */ + fun price(eventOutput: Price.EventOutput) = price(Price.ofEventOutput(eventOutput)) - override fun visitGroupedWithMinMaxThresholds( - groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds - ) = groupedWithMinMaxThresholds.validity() + /** The id of the price to add to the subscription. */ + fun priceId(priceId: String?) = priceId(JsonField.ofNullable(priceId)) - override fun visitMatrixWithDisplayName( - matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice - ) = matrixWithDisplayName.validity() + /** + * Sets [Builder.priceId] to an arbitrary JSON value. + * + * You should usually call [Builder.priceId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun priceId(priceId: JsonField) = apply { this.priceId = priceId } - override fun visitGroupedTieredPackage( - groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice - ) = groupedTieredPackage.validity() + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - override fun visitMaxGroupTieredPackage( - maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice - ) = maxGroupTieredPackage.validity() + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - override fun visitScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: - NewSubscriptionScalableMatrixWithUnitPricingPrice - ) = scalableMatrixWithUnitPricing.validity() + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - override fun visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: - NewSubscriptionScalableMatrixWithTieredPricingPrice - ) = scalableMatrixWithTieredPricing.validity() + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - override fun visitCumulativeGroupedBulk( - cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice - ) = cumulativeGroupedBulk.validity() + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - override fun visitMinimum(minimum: NewSubscriptionMinimumCompositePrice) = - minimum.validity() - - override fun visitEventOutput(eventOutput: EventOutput) = - eventOutput.validity() - - override fun unknown(json: JsonValue?) = 0 - } + /** + * Returns an immutable instance of [ReplacePrice]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .replacesPriceId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ReplacePrice = + ReplacePrice( + checkRequired("replacesPriceId", replacesPriceId), + allocationPrice, + (discounts ?: JsonMissing.of()).map { it.toImmutable() }, + externalPriceId, + fixedPriceQuantity, + maximumAmount, + minimumAmount, + price, + priceId, + additionalProperties.toMutableMap(), ) + } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + private var validated: Boolean = false - return other is Price && - unit == other.unit && - tiered == other.tiered && - bulk == other.bulk && - package_ == other.package_ && - matrix == other.matrix && - thresholdTotalAmount == other.thresholdTotalAmount && - tieredPackage == other.tieredPackage && - tieredWithMinimum == other.tieredWithMinimum && - groupedTiered == other.groupedTiered && - tieredPackageWithMinimum == other.tieredPackageWithMinimum && - packageWithAllocation == other.packageWithAllocation && - unitWithPercent == other.unitWithPercent && - matrixWithAllocation == other.matrixWithAllocation && - tieredWithProration == other.tieredWithProration && - unitWithProration == other.unitWithProration && - groupedAllocation == other.groupedAllocation && - bulkWithProration == other.bulkWithProration && - groupedWithProratedMinimum == other.groupedWithProratedMinimum && - groupedWithMeteredMinimum == other.groupedWithMeteredMinimum && - groupedWithMinMaxThresholds == other.groupedWithMinMaxThresholds && - matrixWithDisplayName == other.matrixWithDisplayName && - groupedTieredPackage == other.groupedTieredPackage && - maxGroupTieredPackage == other.maxGroupTieredPackage && - scalableMatrixWithUnitPricing == other.scalableMatrixWithUnitPricing && - scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && - cumulativeGroupedBulk == other.cumulativeGroupedBulk && - minimum == other.minimum && - eventOutput == other.eventOutput + fun validate(): ReplacePrice = apply { + if (validated) { + return@apply } - override fun hashCode(): Int = - Objects.hash( - unit, - tiered, - bulk, - package_, - matrix, - thresholdTotalAmount, - tieredPackage, - tieredWithMinimum, - groupedTiered, - tieredPackageWithMinimum, - packageWithAllocation, - unitWithPercent, - matrixWithAllocation, - tieredWithProration, - unitWithProration, - groupedAllocation, - bulkWithProration, - groupedWithProratedMinimum, - groupedWithMeteredMinimum, - groupedWithMinMaxThresholds, - matrixWithDisplayName, - groupedTieredPackage, - maxGroupTieredPackage, - scalableMatrixWithUnitPricing, - scalableMatrixWithTieredPricing, - cumulativeGroupedBulk, - minimum, - eventOutput, - ) + replacesPriceId() + allocationPrice()?.validate() + discounts()?.forEach { it.validate() } + externalPriceId() + fixedPriceQuantity() + maximumAmount() + minimumAmount() + price()?.validate() + priceId() + validated = true + } - override fun toString(): String = - when { - unit != null -> "Price{unit=$unit}" - tiered != null -> "Price{tiered=$tiered}" - bulk != null -> "Price{bulk=$bulk}" - package_ != null -> "Price{package_=$package_}" - matrix != null -> "Price{matrix=$matrix}" - thresholdTotalAmount != null -> - "Price{thresholdTotalAmount=$thresholdTotalAmount}" - tieredPackage != null -> "Price{tieredPackage=$tieredPackage}" - tieredWithMinimum != null -> "Price{tieredWithMinimum=$tieredWithMinimum}" - groupedTiered != null -> "Price{groupedTiered=$groupedTiered}" - tieredPackageWithMinimum != null -> - "Price{tieredPackageWithMinimum=$tieredPackageWithMinimum}" - packageWithAllocation != null -> - "Price{packageWithAllocation=$packageWithAllocation}" - unitWithPercent != null -> "Price{unitWithPercent=$unitWithPercent}" - matrixWithAllocation != null -> - "Price{matrixWithAllocation=$matrixWithAllocation}" - tieredWithProration != null -> "Price{tieredWithProration=$tieredWithProration}" - unitWithProration != null -> "Price{unitWithProration=$unitWithProration}" - groupedAllocation != null -> "Price{groupedAllocation=$groupedAllocation}" - bulkWithProration != null -> "Price{bulkWithProration=$bulkWithProration}" - groupedWithProratedMinimum != null -> - "Price{groupedWithProratedMinimum=$groupedWithProratedMinimum}" - groupedWithMeteredMinimum != null -> - "Price{groupedWithMeteredMinimum=$groupedWithMeteredMinimum}" - groupedWithMinMaxThresholds != null -> - "Price{groupedWithMinMaxThresholds=$groupedWithMinMaxThresholds}" - matrixWithDisplayName != null -> - "Price{matrixWithDisplayName=$matrixWithDisplayName}" - groupedTieredPackage != null -> - "Price{groupedTieredPackage=$groupedTieredPackage}" - maxGroupTieredPackage != null -> - "Price{maxGroupTieredPackage=$maxGroupTieredPackage}" - scalableMatrixWithUnitPricing != null -> - "Price{scalableMatrixWithUnitPricing=$scalableMatrixWithUnitPricing}" - scalableMatrixWithTieredPricing != null -> - "Price{scalableMatrixWithTieredPricing=$scalableMatrixWithTieredPricing}" - cumulativeGroupedBulk != null -> - "Price{cumulativeGroupedBulk=$cumulativeGroupedBulk}" - minimum != null -> "Price{minimum=$minimum}" - eventOutput != null -> "Price{eventOutput=$eventOutput}" - _json != null -> "Price{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Price") - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - companion object { + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (replacesPriceId.asKnown() == null) 0 else 1) + + (allocationPrice.asKnown()?.validity() ?: 0) + + (discounts.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (maximumAmount.asKnown() == null) 0 else 1) + + (if (minimumAmount.asKnown() == null) 0 else 1) + + (price.asKnown()?.validity() ?: 0) + + (if (priceId.asKnown() == null) 0 else 1) - fun ofUnit(unit: NewSubscriptionUnitPrice) = Price(unit = unit) + /** New subscription price request body params. */ + @JsonDeserialize(using = Price.Deserializer::class) + @JsonSerialize(using = Price.Serializer::class) + class Price + private constructor( + private val unit: NewSubscriptionUnitPrice? = null, + private val tiered: NewSubscriptionTieredPrice? = null, + private val bulk: NewSubscriptionBulkPrice? = null, + private val package_: NewSubscriptionPackagePrice? = null, + private val matrix: NewSubscriptionMatrixPrice? = null, + private val thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice? = null, + private val tieredPackage: NewSubscriptionTieredPackagePrice? = null, + private val tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice? = null, + private val groupedTiered: NewSubscriptionGroupedTieredPrice? = null, + private val tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice? = + null, + private val packageWithAllocation: NewSubscriptionPackageWithAllocationPrice? = null, + private val unitWithPercent: NewSubscriptionUnitWithPercentPrice? = null, + private val matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice? = null, + private val tieredWithProration: TieredWithProration? = null, + private val unitWithProration: NewSubscriptionUnitWithProrationPrice? = null, + private val groupedAllocation: NewSubscriptionGroupedAllocationPrice? = null, + private val bulkWithProration: NewSubscriptionBulkWithProrationPrice? = null, + private val groupedWithProratedMinimum: + NewSubscriptionGroupedWithProratedMinimumPrice? = + null, + private val groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice? = + null, + private val groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds? = null, + private val matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice? = null, + private val groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice? = null, + private val maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice? = null, + private val scalableMatrixWithUnitPricing: + NewSubscriptionScalableMatrixWithUnitPricingPrice? = + null, + private val scalableMatrixWithTieredPricing: + NewSubscriptionScalableMatrixWithTieredPricingPrice? = + null, + private val cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice? = null, + private val minimum: NewSubscriptionMinimumCompositePrice? = null, + private val percent: Percent? = null, + private val eventOutput: EventOutput? = null, + private val _json: JsonValue? = null, + ) { - fun ofTiered(tiered: NewSubscriptionTieredPrice) = Price(tiered = tiered) + fun unit(): NewSubscriptionUnitPrice? = unit - fun ofBulk(bulk: NewSubscriptionBulkPrice) = Price(bulk = bulk) + fun tiered(): NewSubscriptionTieredPrice? = tiered - fun ofPackage(package_: NewSubscriptionPackagePrice) = Price(package_ = package_) + fun bulk(): NewSubscriptionBulkPrice? = bulk - fun ofMatrix(matrix: NewSubscriptionMatrixPrice) = Price(matrix = matrix) + fun package_(): NewSubscriptionPackagePrice? = package_ - fun ofThresholdTotalAmount( - thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice - ) = Price(thresholdTotalAmount = thresholdTotalAmount) + fun matrix(): NewSubscriptionMatrixPrice? = matrix - fun ofTieredPackage(tieredPackage: NewSubscriptionTieredPackagePrice) = - Price(tieredPackage = tieredPackage) + fun thresholdTotalAmount(): NewSubscriptionThresholdTotalAmountPrice? = + thresholdTotalAmount - fun ofTieredWithMinimum(tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice) = - Price(tieredWithMinimum = tieredWithMinimum) + fun tieredPackage(): NewSubscriptionTieredPackagePrice? = tieredPackage - fun ofGroupedTiered(groupedTiered: NewSubscriptionGroupedTieredPrice) = - Price(groupedTiered = groupedTiered) + fun tieredWithMinimum(): NewSubscriptionTieredWithMinimumPrice? = tieredWithMinimum - fun ofTieredPackageWithMinimum( - tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice - ) = Price(tieredPackageWithMinimum = tieredPackageWithMinimum) + fun groupedTiered(): NewSubscriptionGroupedTieredPrice? = groupedTiered - fun ofPackageWithAllocation( - packageWithAllocation: NewSubscriptionPackageWithAllocationPrice - ) = Price(packageWithAllocation = packageWithAllocation) + fun tieredPackageWithMinimum(): NewSubscriptionTieredPackageWithMinimumPrice? = + tieredPackageWithMinimum - fun ofUnitWithPercent(unitWithPercent: NewSubscriptionUnitWithPercentPrice) = - Price(unitWithPercent = unitWithPercent) + fun packageWithAllocation(): NewSubscriptionPackageWithAllocationPrice? = + packageWithAllocation - fun ofMatrixWithAllocation( - matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice - ) = Price(matrixWithAllocation = matrixWithAllocation) + fun unitWithPercent(): NewSubscriptionUnitWithPercentPrice? = unitWithPercent - fun ofTieredWithProration(tieredWithProration: TieredWithProration) = - Price(tieredWithProration = tieredWithProration) + fun matrixWithAllocation(): NewSubscriptionMatrixWithAllocationPrice? = + matrixWithAllocation - fun ofUnitWithProration(unitWithProration: NewSubscriptionUnitWithProrationPrice) = - Price(unitWithProration = unitWithProration) + fun tieredWithProration(): TieredWithProration? = tieredWithProration - fun ofGroupedAllocation(groupedAllocation: NewSubscriptionGroupedAllocationPrice) = - Price(groupedAllocation = groupedAllocation) + fun unitWithProration(): NewSubscriptionUnitWithProrationPrice? = unitWithProration - fun ofBulkWithProration(bulkWithProration: NewSubscriptionBulkWithProrationPrice) = - Price(bulkWithProration = bulkWithProration) + fun groupedAllocation(): NewSubscriptionGroupedAllocationPrice? = groupedAllocation - fun ofGroupedWithProratedMinimum( - groupedWithProratedMinimum: NewSubscriptionGroupedWithProratedMinimumPrice - ) = Price(groupedWithProratedMinimum = groupedWithProratedMinimum) + fun bulkWithProration(): NewSubscriptionBulkWithProrationPrice? = bulkWithProration - fun ofGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice - ) = Price(groupedWithMeteredMinimum = groupedWithMeteredMinimum) + fun groupedWithProratedMinimum(): NewSubscriptionGroupedWithProratedMinimumPrice? = + groupedWithProratedMinimum - fun ofGroupedWithMinMaxThresholds( - groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds - ) = Price(groupedWithMinMaxThresholds = groupedWithMinMaxThresholds) + fun groupedWithMeteredMinimum(): NewSubscriptionGroupedWithMeteredMinimumPrice? = + groupedWithMeteredMinimum - fun ofMatrixWithDisplayName( - matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice - ) = Price(matrixWithDisplayName = matrixWithDisplayName) + fun groupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds? = + groupedWithMinMaxThresholds - fun ofGroupedTieredPackage( - groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice - ) = Price(groupedTieredPackage = groupedTieredPackage) + fun matrixWithDisplayName(): NewSubscriptionMatrixWithDisplayNamePrice? = + matrixWithDisplayName - fun ofMaxGroupTieredPackage( - maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice - ) = Price(maxGroupTieredPackage = maxGroupTieredPackage) + fun groupedTieredPackage(): NewSubscriptionGroupedTieredPackagePrice? = + groupedTieredPackage - fun ofScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: NewSubscriptionScalableMatrixWithUnitPricingPrice - ) = Price(scalableMatrixWithUnitPricing = scalableMatrixWithUnitPricing) + fun maxGroupTieredPackage(): NewSubscriptionMaxGroupTieredPackagePrice? = + maxGroupTieredPackage - fun ofScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: - NewSubscriptionScalableMatrixWithTieredPricingPrice - ) = Price(scalableMatrixWithTieredPricing = scalableMatrixWithTieredPricing) + fun scalableMatrixWithUnitPricing(): + NewSubscriptionScalableMatrixWithUnitPricingPrice? = scalableMatrixWithUnitPricing - fun ofCumulativeGroupedBulk( - cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice - ) = Price(cumulativeGroupedBulk = cumulativeGroupedBulk) + fun scalableMatrixWithTieredPricing(): + NewSubscriptionScalableMatrixWithTieredPricingPrice? = + scalableMatrixWithTieredPricing - fun ofMinimum(minimum: NewSubscriptionMinimumCompositePrice) = - Price(minimum = minimum) + fun cumulativeGroupedBulk(): NewSubscriptionCumulativeGroupedBulkPrice? = + cumulativeGroupedBulk - fun ofEventOutput(eventOutput: EventOutput) = Price(eventOutput = eventOutput) - } + fun minimum(): NewSubscriptionMinimumCompositePrice? = minimum - /** - * An interface that defines how to map each variant of [Price] to a value of type [T]. - */ - interface Visitor { + fun percent(): Percent? = percent - fun visitUnit(unit: NewSubscriptionUnitPrice): T + fun eventOutput(): EventOutput? = eventOutput - fun visitTiered(tiered: NewSubscriptionTieredPrice): T + fun isUnit(): Boolean = unit != null - fun visitBulk(bulk: NewSubscriptionBulkPrice): T + fun isTiered(): Boolean = tiered != null - fun visitPackage(package_: NewSubscriptionPackagePrice): T + fun isBulk(): Boolean = bulk != null - fun visitMatrix(matrix: NewSubscriptionMatrixPrice): T + fun isPackage(): Boolean = package_ != null - fun visitThresholdTotalAmount( - thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice - ): T + fun isMatrix(): Boolean = matrix != null - fun visitTieredPackage(tieredPackage: NewSubscriptionTieredPackagePrice): T + fun isThresholdTotalAmount(): Boolean = thresholdTotalAmount != null - fun visitTieredWithMinimum( - tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice - ): T + fun isTieredPackage(): Boolean = tieredPackage != null - fun visitGroupedTiered(groupedTiered: NewSubscriptionGroupedTieredPrice): T + fun isTieredWithMinimum(): Boolean = tieredWithMinimum != null - fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice - ): T + fun isGroupedTiered(): Boolean = groupedTiered != null - fun visitPackageWithAllocation( - packageWithAllocation: NewSubscriptionPackageWithAllocationPrice - ): T + fun isTieredPackageWithMinimum(): Boolean = tieredPackageWithMinimum != null - fun visitUnitWithPercent(unitWithPercent: NewSubscriptionUnitWithPercentPrice): T + fun isPackageWithAllocation(): Boolean = packageWithAllocation != null - fun visitMatrixWithAllocation( - matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice - ): T + fun isUnitWithPercent(): Boolean = unitWithPercent != null - fun visitTieredWithProration(tieredWithProration: TieredWithProration): T + fun isMatrixWithAllocation(): Boolean = matrixWithAllocation != null - fun visitUnitWithProration( - unitWithProration: NewSubscriptionUnitWithProrationPrice - ): T + fun isTieredWithProration(): Boolean = tieredWithProration != null - fun visitGroupedAllocation( - groupedAllocation: NewSubscriptionGroupedAllocationPrice - ): T + fun isUnitWithProration(): Boolean = unitWithProration != null - fun visitBulkWithProration( - bulkWithProration: NewSubscriptionBulkWithProrationPrice - ): T + fun isGroupedAllocation(): Boolean = groupedAllocation != null - fun visitGroupedWithProratedMinimum( - groupedWithProratedMinimum: NewSubscriptionGroupedWithProratedMinimumPrice - ): T + fun isBulkWithProration(): Boolean = bulkWithProration != null - fun visitGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice - ): T + fun isGroupedWithProratedMinimum(): Boolean = groupedWithProratedMinimum != null - fun visitGroupedWithMinMaxThresholds( - groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds - ): T + fun isGroupedWithMeteredMinimum(): Boolean = groupedWithMeteredMinimum != null - fun visitMatrixWithDisplayName( - matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice - ): T + fun isGroupedWithMinMaxThresholds(): Boolean = groupedWithMinMaxThresholds != null - fun visitGroupedTieredPackage( - groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice - ): T + fun isMatrixWithDisplayName(): Boolean = matrixWithDisplayName != null - fun visitMaxGroupTieredPackage( - maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice - ): T + fun isGroupedTieredPackage(): Boolean = groupedTieredPackage != null - fun visitScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: NewSubscriptionScalableMatrixWithUnitPricingPrice - ): T + fun isMaxGroupTieredPackage(): Boolean = maxGroupTieredPackage != null - fun visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: - NewSubscriptionScalableMatrixWithTieredPricingPrice - ): T + fun isScalableMatrixWithUnitPricing(): Boolean = scalableMatrixWithUnitPricing != null - fun visitCumulativeGroupedBulk( - cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice - ): T + fun isScalableMatrixWithTieredPricing(): Boolean = + scalableMatrixWithTieredPricing != null - fun visitMinimum(minimum: NewSubscriptionMinimumCompositePrice): T + fun isCumulativeGroupedBulk(): Boolean = cumulativeGroupedBulk != null - fun visitEventOutput(eventOutput: EventOutput): T + fun isMinimum(): Boolean = minimum != null - /** - * Maps an unknown variant of [Price] to a value of type [T]. - * - * An instance of [Price] can contain an unknown variant if it was deserialized from - * data that doesn't match any known variant. For example, if the SDK is on an older - * version than the API, then the API may respond with new variants that the SDK is - * unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown Price: $json") - } - } + fun isPercent(): Boolean = percent != null - internal class Deserializer : BaseDeserializer(Price::class) { + fun isEventOutput(): Boolean = eventOutput != null - override fun ObjectCodec.deserialize(node: JsonNode): Price { - val json = JsonValue.fromJsonNode(node) - val modelType = json.asObject()?.get("model_type")?.asString() + fun asUnit(): NewSubscriptionUnitPrice = unit.getOrThrow("unit") - when (modelType) { - "unit" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(unit = it, _json = json) } ?: Price(_json = json) - } - "tiered" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(tiered = it, _json = json) } ?: Price(_json = json) - } - "bulk" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(bulk = it, _json = json) } ?: Price(_json = json) - } - "package" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(package_ = it, _json = json) } ?: Price(_json = json) - } - "matrix" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(matrix = it, _json = json) } ?: Price(_json = json) - } - "threshold_total_amount" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(thresholdTotalAmount = it, _json = json) } - ?: Price(_json = json) - } - "tiered_package" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(tieredPackage = it, _json = json) } - ?: Price(_json = json) - } - "tiered_with_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(tieredWithMinimum = it, _json = json) } - ?: Price(_json = json) - } - "grouped_tiered" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedTiered = it, _json = json) } - ?: Price(_json = json) - } - "tiered_package_with_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), + fun asTiered(): NewSubscriptionTieredPrice = tiered.getOrThrow("tiered") + + fun asBulk(): NewSubscriptionBulkPrice = bulk.getOrThrow("bulk") + + fun asPackage(): NewSubscriptionPackagePrice = package_.getOrThrow("package_") + + fun asMatrix(): NewSubscriptionMatrixPrice = matrix.getOrThrow("matrix") + + fun asThresholdTotalAmount(): NewSubscriptionThresholdTotalAmountPrice = + thresholdTotalAmount.getOrThrow("thresholdTotalAmount") + + fun asTieredPackage(): NewSubscriptionTieredPackagePrice = + tieredPackage.getOrThrow("tieredPackage") + + fun asTieredWithMinimum(): NewSubscriptionTieredWithMinimumPrice = + tieredWithMinimum.getOrThrow("tieredWithMinimum") + + fun asGroupedTiered(): NewSubscriptionGroupedTieredPrice = + groupedTiered.getOrThrow("groupedTiered") + + fun asTieredPackageWithMinimum(): NewSubscriptionTieredPackageWithMinimumPrice = + tieredPackageWithMinimum.getOrThrow("tieredPackageWithMinimum") + + fun asPackageWithAllocation(): NewSubscriptionPackageWithAllocationPrice = + packageWithAllocation.getOrThrow("packageWithAllocation") + + fun asUnitWithPercent(): NewSubscriptionUnitWithPercentPrice = + unitWithPercent.getOrThrow("unitWithPercent") + + fun asMatrixWithAllocation(): NewSubscriptionMatrixWithAllocationPrice = + matrixWithAllocation.getOrThrow("matrixWithAllocation") + + fun asTieredWithProration(): TieredWithProration = + tieredWithProration.getOrThrow("tieredWithProration") + + fun asUnitWithProration(): NewSubscriptionUnitWithProrationPrice = + unitWithProration.getOrThrow("unitWithProration") + + fun asGroupedAllocation(): NewSubscriptionGroupedAllocationPrice = + groupedAllocation.getOrThrow("groupedAllocation") + + fun asBulkWithProration(): NewSubscriptionBulkWithProrationPrice = + bulkWithProration.getOrThrow("bulkWithProration") + + fun asGroupedWithProratedMinimum(): NewSubscriptionGroupedWithProratedMinimumPrice = + groupedWithProratedMinimum.getOrThrow("groupedWithProratedMinimum") + + fun asGroupedWithMeteredMinimum(): NewSubscriptionGroupedWithMeteredMinimumPrice = + groupedWithMeteredMinimum.getOrThrow("groupedWithMeteredMinimum") + + fun asGroupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds = + groupedWithMinMaxThresholds.getOrThrow("groupedWithMinMaxThresholds") + + fun asMatrixWithDisplayName(): NewSubscriptionMatrixWithDisplayNamePrice = + matrixWithDisplayName.getOrThrow("matrixWithDisplayName") + + fun asGroupedTieredPackage(): NewSubscriptionGroupedTieredPackagePrice = + groupedTieredPackage.getOrThrow("groupedTieredPackage") + + fun asMaxGroupTieredPackage(): NewSubscriptionMaxGroupTieredPackagePrice = + maxGroupTieredPackage.getOrThrow("maxGroupTieredPackage") + + fun asScalableMatrixWithUnitPricing(): + NewSubscriptionScalableMatrixWithUnitPricingPrice = + scalableMatrixWithUnitPricing.getOrThrow("scalableMatrixWithUnitPricing") + + fun asScalableMatrixWithTieredPricing(): + NewSubscriptionScalableMatrixWithTieredPricingPrice = + scalableMatrixWithTieredPricing.getOrThrow("scalableMatrixWithTieredPricing") + + fun asCumulativeGroupedBulk(): NewSubscriptionCumulativeGroupedBulkPrice = + cumulativeGroupedBulk.getOrThrow("cumulativeGroupedBulk") + + fun asMinimum(): NewSubscriptionMinimumCompositePrice = minimum.getOrThrow("minimum") + + fun asPercent(): Percent = percent.getOrThrow("percent") + + fun asEventOutput(): EventOutput = eventOutput.getOrThrow("eventOutput") + + fun _json(): JsonValue? = _json + + fun accept(visitor: Visitor): T = + when { + unit != null -> visitor.visitUnit(unit) + tiered != null -> visitor.visitTiered(tiered) + bulk != null -> visitor.visitBulk(bulk) + package_ != null -> visitor.visitPackage(package_) + matrix != null -> visitor.visitMatrix(matrix) + thresholdTotalAmount != null -> + visitor.visitThresholdTotalAmount(thresholdTotalAmount) + tieredPackage != null -> visitor.visitTieredPackage(tieredPackage) + tieredWithMinimum != null -> visitor.visitTieredWithMinimum(tieredWithMinimum) + groupedTiered != null -> visitor.visitGroupedTiered(groupedTiered) + tieredPackageWithMinimum != null -> + visitor.visitTieredPackageWithMinimum(tieredPackageWithMinimum) + packageWithAllocation != null -> + visitor.visitPackageWithAllocation(packageWithAllocation) + unitWithPercent != null -> visitor.visitUnitWithPercent(unitWithPercent) + matrixWithAllocation != null -> + visitor.visitMatrixWithAllocation(matrixWithAllocation) + tieredWithProration != null -> + visitor.visitTieredWithProration(tieredWithProration) + unitWithProration != null -> visitor.visitUnitWithProration(unitWithProration) + groupedAllocation != null -> visitor.visitGroupedAllocation(groupedAllocation) + bulkWithProration != null -> visitor.visitBulkWithProration(bulkWithProration) + groupedWithProratedMinimum != null -> + visitor.visitGroupedWithProratedMinimum(groupedWithProratedMinimum) + groupedWithMeteredMinimum != null -> + visitor.visitGroupedWithMeteredMinimum(groupedWithMeteredMinimum) + groupedWithMinMaxThresholds != null -> + visitor.visitGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds) + matrixWithDisplayName != null -> + visitor.visitMatrixWithDisplayName(matrixWithDisplayName) + groupedTieredPackage != null -> + visitor.visitGroupedTieredPackage(groupedTieredPackage) + maxGroupTieredPackage != null -> + visitor.visitMaxGroupTieredPackage(maxGroupTieredPackage) + scalableMatrixWithUnitPricing != null -> + visitor.visitScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing) + scalableMatrixWithTieredPricing != null -> + visitor.visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing + ) + cumulativeGroupedBulk != null -> + visitor.visitCumulativeGroupedBulk(cumulativeGroupedBulk) + minimum != null -> visitor.visitMinimum(minimum) + percent != null -> visitor.visitPercent(percent) + eventOutput != null -> visitor.visitEventOutput(eventOutput) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Price = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitUnit(unit: NewSubscriptionUnitPrice) { + unit.validate() + } + + override fun visitTiered(tiered: NewSubscriptionTieredPrice) { + tiered.validate() + } + + override fun visitBulk(bulk: NewSubscriptionBulkPrice) { + bulk.validate() + } + + override fun visitPackage(package_: NewSubscriptionPackagePrice) { + package_.validate() + } + + override fun visitMatrix(matrix: NewSubscriptionMatrixPrice) { + matrix.validate() + } + + override fun visitThresholdTotalAmount( + thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice + ) { + thresholdTotalAmount.validate() + } + + override fun visitTieredPackage( + tieredPackage: NewSubscriptionTieredPackagePrice + ) { + tieredPackage.validate() + } + + override fun visitTieredWithMinimum( + tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice + ) { + tieredWithMinimum.validate() + } + + override fun visitGroupedTiered( + groupedTiered: NewSubscriptionGroupedTieredPrice + ) { + groupedTiered.validate() + } + + override fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice + ) { + tieredPackageWithMinimum.validate() + } + + override fun visitPackageWithAllocation( + packageWithAllocation: NewSubscriptionPackageWithAllocationPrice + ) { + packageWithAllocation.validate() + } + + override fun visitUnitWithPercent( + unitWithPercent: NewSubscriptionUnitWithPercentPrice + ) { + unitWithPercent.validate() + } + + override fun visitMatrixWithAllocation( + matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice + ) { + matrixWithAllocation.validate() + } + + override fun visitTieredWithProration( + tieredWithProration: TieredWithProration + ) { + tieredWithProration.validate() + } + + override fun visitUnitWithProration( + unitWithProration: NewSubscriptionUnitWithProrationPrice + ) { + unitWithProration.validate() + } + + override fun visitGroupedAllocation( + groupedAllocation: NewSubscriptionGroupedAllocationPrice + ) { + groupedAllocation.validate() + } + + override fun visitBulkWithProration( + bulkWithProration: NewSubscriptionBulkWithProrationPrice + ) { + bulkWithProration.validate() + } + + override fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: + NewSubscriptionGroupedWithProratedMinimumPrice + ) { + groupedWithProratedMinimum.validate() + } + + override fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice + ) { + groupedWithMeteredMinimum.validate() + } + + override fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) { + groupedWithMinMaxThresholds.validate() + } + + override fun visitMatrixWithDisplayName( + matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice + ) { + matrixWithDisplayName.validate() + } + + override fun visitGroupedTieredPackage( + groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice + ) { + groupedTieredPackage.validate() + } + + override fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice + ) { + maxGroupTieredPackage.validate() + } + + override fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: + NewSubscriptionScalableMatrixWithUnitPricingPrice + ) { + scalableMatrixWithUnitPricing.validate() + } + + override fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: + NewSubscriptionScalableMatrixWithTieredPricingPrice + ) { + scalableMatrixWithTieredPricing.validate() + } + + override fun visitCumulativeGroupedBulk( + cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice + ) { + cumulativeGroupedBulk.validate() + } + + override fun visitMinimum(minimum: NewSubscriptionMinimumCompositePrice) { + minimum.validate() + } + + override fun visitPercent(percent: Percent) { + percent.validate() + } + + override fun visitEventOutput(eventOutput: EventOutput) { + eventOutput.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitUnit(unit: NewSubscriptionUnitPrice) = unit.validity() + + override fun visitTiered(tiered: NewSubscriptionTieredPrice) = + tiered.validity() + + override fun visitBulk(bulk: NewSubscriptionBulkPrice) = bulk.validity() + + override fun visitPackage(package_: NewSubscriptionPackagePrice) = + package_.validity() + + override fun visitMatrix(matrix: NewSubscriptionMatrixPrice) = + matrix.validity() + + override fun visitThresholdTotalAmount( + thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice + ) = thresholdTotalAmount.validity() + + override fun visitTieredPackage( + tieredPackage: NewSubscriptionTieredPackagePrice + ) = tieredPackage.validity() + + override fun visitTieredWithMinimum( + tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice + ) = tieredWithMinimum.validity() + + override fun visitGroupedTiered( + groupedTiered: NewSubscriptionGroupedTieredPrice + ) = groupedTiered.validity() + + override fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice + ) = tieredPackageWithMinimum.validity() + + override fun visitPackageWithAllocation( + packageWithAllocation: NewSubscriptionPackageWithAllocationPrice + ) = packageWithAllocation.validity() + + override fun visitUnitWithPercent( + unitWithPercent: NewSubscriptionUnitWithPercentPrice + ) = unitWithPercent.validity() + + override fun visitMatrixWithAllocation( + matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice + ) = matrixWithAllocation.validity() + + override fun visitTieredWithProration( + tieredWithProration: TieredWithProration + ) = tieredWithProration.validity() + + override fun visitUnitWithProration( + unitWithProration: NewSubscriptionUnitWithProrationPrice + ) = unitWithProration.validity() + + override fun visitGroupedAllocation( + groupedAllocation: NewSubscriptionGroupedAllocationPrice + ) = groupedAllocation.validity() + + override fun visitBulkWithProration( + bulkWithProration: NewSubscriptionBulkWithProrationPrice + ) = bulkWithProration.validity() + + override fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: + NewSubscriptionGroupedWithProratedMinimumPrice + ) = groupedWithProratedMinimum.validity() + + override fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice + ) = groupedWithMeteredMinimum.validity() + + override fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) = groupedWithMinMaxThresholds.validity() + + override fun visitMatrixWithDisplayName( + matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice + ) = matrixWithDisplayName.validity() + + override fun visitGroupedTieredPackage( + groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice + ) = groupedTieredPackage.validity() + + override fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice + ) = maxGroupTieredPackage.validity() + + override fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: + NewSubscriptionScalableMatrixWithUnitPricingPrice + ) = scalableMatrixWithUnitPricing.validity() + + override fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: + NewSubscriptionScalableMatrixWithTieredPricingPrice + ) = scalableMatrixWithTieredPricing.validity() + + override fun visitCumulativeGroupedBulk( + cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice + ) = cumulativeGroupedBulk.validity() + + override fun visitMinimum(minimum: NewSubscriptionMinimumCompositePrice) = + minimum.validity() + + override fun visitPercent(percent: Percent) = percent.validity() + + override fun visitEventOutput(eventOutput: EventOutput) = + eventOutput.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Price && + unit == other.unit && + tiered == other.tiered && + bulk == other.bulk && + package_ == other.package_ && + matrix == other.matrix && + thresholdTotalAmount == other.thresholdTotalAmount && + tieredPackage == other.tieredPackage && + tieredWithMinimum == other.tieredWithMinimum && + groupedTiered == other.groupedTiered && + tieredPackageWithMinimum == other.tieredPackageWithMinimum && + packageWithAllocation == other.packageWithAllocation && + unitWithPercent == other.unitWithPercent && + matrixWithAllocation == other.matrixWithAllocation && + tieredWithProration == other.tieredWithProration && + unitWithProration == other.unitWithProration && + groupedAllocation == other.groupedAllocation && + bulkWithProration == other.bulkWithProration && + groupedWithProratedMinimum == other.groupedWithProratedMinimum && + groupedWithMeteredMinimum == other.groupedWithMeteredMinimum && + groupedWithMinMaxThresholds == other.groupedWithMinMaxThresholds && + matrixWithDisplayName == other.matrixWithDisplayName && + groupedTieredPackage == other.groupedTieredPackage && + maxGroupTieredPackage == other.maxGroupTieredPackage && + scalableMatrixWithUnitPricing == other.scalableMatrixWithUnitPricing && + scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && + cumulativeGroupedBulk == other.cumulativeGroupedBulk && + minimum == other.minimum && + percent == other.percent && + eventOutput == other.eventOutput + } + + override fun hashCode(): Int = + Objects.hash( + unit, + tiered, + bulk, + package_, + matrix, + thresholdTotalAmount, + tieredPackage, + tieredWithMinimum, + groupedTiered, + tieredPackageWithMinimum, + packageWithAllocation, + unitWithPercent, + matrixWithAllocation, + tieredWithProration, + unitWithProration, + groupedAllocation, + bulkWithProration, + groupedWithProratedMinimum, + groupedWithMeteredMinimum, + groupedWithMinMaxThresholds, + matrixWithDisplayName, + groupedTieredPackage, + maxGroupTieredPackage, + scalableMatrixWithUnitPricing, + scalableMatrixWithTieredPricing, + cumulativeGroupedBulk, + minimum, + percent, + eventOutput, + ) + + override fun toString(): String = + when { + unit != null -> "Price{unit=$unit}" + tiered != null -> "Price{tiered=$tiered}" + bulk != null -> "Price{bulk=$bulk}" + package_ != null -> "Price{package_=$package_}" + matrix != null -> "Price{matrix=$matrix}" + thresholdTotalAmount != null -> + "Price{thresholdTotalAmount=$thresholdTotalAmount}" + tieredPackage != null -> "Price{tieredPackage=$tieredPackage}" + tieredWithMinimum != null -> "Price{tieredWithMinimum=$tieredWithMinimum}" + groupedTiered != null -> "Price{groupedTiered=$groupedTiered}" + tieredPackageWithMinimum != null -> + "Price{tieredPackageWithMinimum=$tieredPackageWithMinimum}" + packageWithAllocation != null -> + "Price{packageWithAllocation=$packageWithAllocation}" + unitWithPercent != null -> "Price{unitWithPercent=$unitWithPercent}" + matrixWithAllocation != null -> + "Price{matrixWithAllocation=$matrixWithAllocation}" + tieredWithProration != null -> "Price{tieredWithProration=$tieredWithProration}" + unitWithProration != null -> "Price{unitWithProration=$unitWithProration}" + groupedAllocation != null -> "Price{groupedAllocation=$groupedAllocation}" + bulkWithProration != null -> "Price{bulkWithProration=$bulkWithProration}" + groupedWithProratedMinimum != null -> + "Price{groupedWithProratedMinimum=$groupedWithProratedMinimum}" + groupedWithMeteredMinimum != null -> + "Price{groupedWithMeteredMinimum=$groupedWithMeteredMinimum}" + groupedWithMinMaxThresholds != null -> + "Price{groupedWithMinMaxThresholds=$groupedWithMinMaxThresholds}" + matrixWithDisplayName != null -> + "Price{matrixWithDisplayName=$matrixWithDisplayName}" + groupedTieredPackage != null -> + "Price{groupedTieredPackage=$groupedTieredPackage}" + maxGroupTieredPackage != null -> + "Price{maxGroupTieredPackage=$maxGroupTieredPackage}" + scalableMatrixWithUnitPricing != null -> + "Price{scalableMatrixWithUnitPricing=$scalableMatrixWithUnitPricing}" + scalableMatrixWithTieredPricing != null -> + "Price{scalableMatrixWithTieredPricing=$scalableMatrixWithTieredPricing}" + cumulativeGroupedBulk != null -> + "Price{cumulativeGroupedBulk=$cumulativeGroupedBulk}" + minimum != null -> "Price{minimum=$minimum}" + percent != null -> "Price{percent=$percent}" + eventOutput != null -> "Price{eventOutput=$eventOutput}" + _json != null -> "Price{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Price") + } + + companion object { + + fun ofUnit(unit: NewSubscriptionUnitPrice) = Price(unit = unit) + + fun ofTiered(tiered: NewSubscriptionTieredPrice) = Price(tiered = tiered) + + fun ofBulk(bulk: NewSubscriptionBulkPrice) = Price(bulk = bulk) + + fun ofPackage(package_: NewSubscriptionPackagePrice) = Price(package_ = package_) + + fun ofMatrix(matrix: NewSubscriptionMatrixPrice) = Price(matrix = matrix) + + fun ofThresholdTotalAmount( + thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice + ) = Price(thresholdTotalAmount = thresholdTotalAmount) + + fun ofTieredPackage(tieredPackage: NewSubscriptionTieredPackagePrice) = + Price(tieredPackage = tieredPackage) + + fun ofTieredWithMinimum(tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice) = + Price(tieredWithMinimum = tieredWithMinimum) + + fun ofGroupedTiered(groupedTiered: NewSubscriptionGroupedTieredPrice) = + Price(groupedTiered = groupedTiered) + + fun ofTieredPackageWithMinimum( + tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice + ) = Price(tieredPackageWithMinimum = tieredPackageWithMinimum) + + fun ofPackageWithAllocation( + packageWithAllocation: NewSubscriptionPackageWithAllocationPrice + ) = Price(packageWithAllocation = packageWithAllocation) + + fun ofUnitWithPercent(unitWithPercent: NewSubscriptionUnitWithPercentPrice) = + Price(unitWithPercent = unitWithPercent) + + fun ofMatrixWithAllocation( + matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice + ) = Price(matrixWithAllocation = matrixWithAllocation) + + fun ofTieredWithProration(tieredWithProration: TieredWithProration) = + Price(tieredWithProration = tieredWithProration) + + fun ofUnitWithProration(unitWithProration: NewSubscriptionUnitWithProrationPrice) = + Price(unitWithProration = unitWithProration) + + fun ofGroupedAllocation(groupedAllocation: NewSubscriptionGroupedAllocationPrice) = + Price(groupedAllocation = groupedAllocation) + + fun ofBulkWithProration(bulkWithProration: NewSubscriptionBulkWithProrationPrice) = + Price(bulkWithProration = bulkWithProration) + + fun ofGroupedWithProratedMinimum( + groupedWithProratedMinimum: NewSubscriptionGroupedWithProratedMinimumPrice + ) = Price(groupedWithProratedMinimum = groupedWithProratedMinimum) + + fun ofGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice + ) = Price(groupedWithMeteredMinimum = groupedWithMeteredMinimum) + + fun ofGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) = Price(groupedWithMinMaxThresholds = groupedWithMinMaxThresholds) + + fun ofMatrixWithDisplayName( + matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice + ) = Price(matrixWithDisplayName = matrixWithDisplayName) + + fun ofGroupedTieredPackage( + groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice + ) = Price(groupedTieredPackage = groupedTieredPackage) + + fun ofMaxGroupTieredPackage( + maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice + ) = Price(maxGroupTieredPackage = maxGroupTieredPackage) + + fun ofScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: NewSubscriptionScalableMatrixWithUnitPricingPrice + ) = Price(scalableMatrixWithUnitPricing = scalableMatrixWithUnitPricing) + + fun ofScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: + NewSubscriptionScalableMatrixWithTieredPricingPrice + ) = Price(scalableMatrixWithTieredPricing = scalableMatrixWithTieredPricing) + + fun ofCumulativeGroupedBulk( + cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice + ) = Price(cumulativeGroupedBulk = cumulativeGroupedBulk) + + fun ofMinimum(minimum: NewSubscriptionMinimumCompositePrice) = + Price(minimum = minimum) + + fun ofPercent(percent: Percent) = Price(percent = percent) + + fun ofEventOutput(eventOutput: EventOutput) = Price(eventOutput = eventOutput) + } + + /** + * An interface that defines how to map each variant of [Price] to a value of type [T]. + */ + interface Visitor { + + fun visitUnit(unit: NewSubscriptionUnitPrice): T + + fun visitTiered(tiered: NewSubscriptionTieredPrice): T + + fun visitBulk(bulk: NewSubscriptionBulkPrice): T + + fun visitPackage(package_: NewSubscriptionPackagePrice): T + + fun visitMatrix(matrix: NewSubscriptionMatrixPrice): T + + fun visitThresholdTotalAmount( + thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice + ): T + + fun visitTieredPackage(tieredPackage: NewSubscriptionTieredPackagePrice): T + + fun visitTieredWithMinimum( + tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice + ): T + + fun visitGroupedTiered(groupedTiered: NewSubscriptionGroupedTieredPrice): T + + fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice + ): T + + fun visitPackageWithAllocation( + packageWithAllocation: NewSubscriptionPackageWithAllocationPrice + ): T + + fun visitUnitWithPercent(unitWithPercent: NewSubscriptionUnitWithPercentPrice): T + + fun visitMatrixWithAllocation( + matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice + ): T + + fun visitTieredWithProration(tieredWithProration: TieredWithProration): T + + fun visitUnitWithProration( + unitWithProration: NewSubscriptionUnitWithProrationPrice + ): T + + fun visitGroupedAllocation( + groupedAllocation: NewSubscriptionGroupedAllocationPrice + ): T + + fun visitBulkWithProration( + bulkWithProration: NewSubscriptionBulkWithProrationPrice + ): T + + fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: NewSubscriptionGroupedWithProratedMinimumPrice + ): T + + fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice + ): T + + fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ): T + + fun visitMatrixWithDisplayName( + matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice + ): T + + fun visitGroupedTieredPackage( + groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice + ): T + + fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice + ): T + + fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: NewSubscriptionScalableMatrixWithUnitPricingPrice + ): T + + fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: + NewSubscriptionScalableMatrixWithTieredPricingPrice + ): T + + fun visitCumulativeGroupedBulk( + cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice + ): T + + fun visitMinimum(minimum: NewSubscriptionMinimumCompositePrice): T + + fun visitPercent(percent: Percent): T + + fun visitEventOutput(eventOutput: EventOutput): T + + /** + * Maps an unknown variant of [Price] to a value of type [T]. + * + * An instance of [Price] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is + * unaware of. + * + * @throws OrbInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw OrbInvalidDataException("Unknown Price: $json") + } + } + + internal class Deserializer : BaseDeserializer(Price::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Price { + val json = JsonValue.fromJsonNode(node) + val modelType = json.asObject()?.get("model_type")?.asString() + + when (modelType) { + "unit" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(unit = it, _json = json) } ?: Price(_json = json) + } + "tiered" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(tiered = it, _json = json) } ?: Price(_json = json) + } + "bulk" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(bulk = it, _json = json) } ?: Price(_json = json) + } + "package" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(package_ = it, _json = json) } ?: Price(_json = json) + } + "matrix" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(matrix = it, _json = json) } ?: Price(_json = json) + } + "threshold_total_amount" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(thresholdTotalAmount = it, _json = json) } + ?: Price(_json = json) + } + "tiered_package" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(tieredPackage = it, _json = json) } + ?: Price(_json = json) + } + "tiered_with_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(tieredWithMinimum = it, _json = json) } + ?: Price(_json = json) + } + "grouped_tiered" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedTiered = it, _json = json) } + ?: Price(_json = json) + } + "tiered_package_with_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(tieredPackageWithMinimum = it, _json = json) } + ?: Price(_json = json) + } + "package_with_allocation" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(packageWithAllocation = it, _json = json) } + ?: Price(_json = json) + } + "unit_with_percent" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(unitWithPercent = it, _json = json) } + ?: Price(_json = json) + } + "matrix_with_allocation" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(matrixWithAllocation = it, _json = json) } + ?: Price(_json = json) + } + "tiered_with_proration" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(tieredWithProration = it, _json = json) } + ?: Price(_json = json) + } + "unit_with_proration" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(unitWithProration = it, _json = json) } + ?: Price(_json = json) + } + "grouped_allocation" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedAllocation = it, _json = json) } + ?: Price(_json = json) + } + "bulk_with_proration" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(bulkWithProration = it, _json = json) } + ?: Price(_json = json) + } + "grouped_with_prorated_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedWithProratedMinimum = it, _json = json) } + ?: Price(_json = json) + } + "grouped_with_metered_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedWithMeteredMinimum = it, _json = json) } + ?: Price(_json = json) + } + "grouped_with_min_max_thresholds" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedWithMinMaxThresholds = it, _json = json) } + ?: Price(_json = json) + } + "matrix_with_display_name" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(matrixWithDisplayName = it, _json = json) } + ?: Price(_json = json) + } + "grouped_tiered_package" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedTieredPackage = it, _json = json) } + ?: Price(_json = json) + } + "max_group_tiered_package" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(maxGroupTieredPackage = it, _json = json) } + ?: Price(_json = json) + } + "scalable_matrix_with_unit_pricing" -> { + return tryDeserialize( + node, + jacksonTypeRef< + NewSubscriptionScalableMatrixWithUnitPricingPrice + >(), + ) + ?.let { Price(scalableMatrixWithUnitPricing = it, _json = json) } + ?: Price(_json = json) + } + "scalable_matrix_with_tiered_pricing" -> { + return tryDeserialize( + node, + jacksonTypeRef< + NewSubscriptionScalableMatrixWithTieredPricingPrice + >(), + ) + ?.let { Price(scalableMatrixWithTieredPricing = it, _json = json) } + ?: Price(_json = json) + } + "cumulative_grouped_bulk" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(cumulativeGroupedBulk = it, _json = json) } + ?: Price(_json = json) + } + "minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(minimum = it, _json = json) } ?: Price(_json = json) + } + "percent" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(percent = it, _json = json) + } ?: Price(_json = json) + } + "event_output" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(eventOutput = it, _json = json) + } ?: Price(_json = json) + } + } + + return Price(_json = json) + } + } + + internal class Serializer : BaseSerializer(Price::class) { + + override fun serialize( + value: Price, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.unit != null -> generator.writeObject(value.unit) + value.tiered != null -> generator.writeObject(value.tiered) + value.bulk != null -> generator.writeObject(value.bulk) + value.package_ != null -> generator.writeObject(value.package_) + value.matrix != null -> generator.writeObject(value.matrix) + value.thresholdTotalAmount != null -> + generator.writeObject(value.thresholdTotalAmount) + value.tieredPackage != null -> generator.writeObject(value.tieredPackage) + value.tieredWithMinimum != null -> + generator.writeObject(value.tieredWithMinimum) + value.groupedTiered != null -> generator.writeObject(value.groupedTiered) + value.tieredPackageWithMinimum != null -> + generator.writeObject(value.tieredPackageWithMinimum) + value.packageWithAllocation != null -> + generator.writeObject(value.packageWithAllocation) + value.unitWithPercent != null -> + generator.writeObject(value.unitWithPercent) + value.matrixWithAllocation != null -> + generator.writeObject(value.matrixWithAllocation) + value.tieredWithProration != null -> + generator.writeObject(value.tieredWithProration) + value.unitWithProration != null -> + generator.writeObject(value.unitWithProration) + value.groupedAllocation != null -> + generator.writeObject(value.groupedAllocation) + value.bulkWithProration != null -> + generator.writeObject(value.bulkWithProration) + value.groupedWithProratedMinimum != null -> + generator.writeObject(value.groupedWithProratedMinimum) + value.groupedWithMeteredMinimum != null -> + generator.writeObject(value.groupedWithMeteredMinimum) + value.groupedWithMinMaxThresholds != null -> + generator.writeObject(value.groupedWithMinMaxThresholds) + value.matrixWithDisplayName != null -> + generator.writeObject(value.matrixWithDisplayName) + value.groupedTieredPackage != null -> + generator.writeObject(value.groupedTieredPackage) + value.maxGroupTieredPackage != null -> + generator.writeObject(value.maxGroupTieredPackage) + value.scalableMatrixWithUnitPricing != null -> + generator.writeObject(value.scalableMatrixWithUnitPricing) + value.scalableMatrixWithTieredPricing != null -> + generator.writeObject(value.scalableMatrixWithTieredPricing) + value.cumulativeGroupedBulk != null -> + generator.writeObject(value.cumulativeGroupedBulk) + value.minimum != null -> generator.writeObject(value.minimum) + value.percent != null -> generator.writeObject(value.percent) + value.eventOutput != null -> generator.writeObject(value.eventOutput) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Price") + } + } + } + + class TieredWithProration + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val tieredWithProrationConfig: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("tiered_with_proration_config") + @ExcludeMissing + tieredWithProrationConfig: JsonField = + JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + modelType, + name, + tieredWithProrationConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("tiered_with_proration") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * Configuration for tiered_with_proration pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun tieredWithProrationConfig(): TieredWithProrationConfig = + tieredWithProrationConfig.getRequired("tiered_with_proration_config") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = billableMetricId.getNullable("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + invoiceGroupingKey.getNullable("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [tieredWithProrationConfig]. + * + * Unlike [tieredWithProrationConfig], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("tiered_with_proration_config") + @ExcludeMissing + fun _tieredWithProrationConfig(): JsonField = + tieredWithProrationConfig + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [TieredWithProration]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .name() + * .tieredWithProrationConfig() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [TieredWithProration]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonValue = JsonValue.from("tiered_with_proration") + private var name: JsonField? = null + private var tieredWithProrationConfig: JsonField? = + null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(tieredWithProration: TieredWithProration) = apply { + cadence = tieredWithProration.cadence + itemId = tieredWithProration.itemId + modelType = tieredWithProration.modelType + name = tieredWithProration.name + tieredWithProrationConfig = tieredWithProration.tieredWithProrationConfig + billableMetricId = tieredWithProration.billableMetricId + billedInAdvance = tieredWithProration.billedInAdvance + billingCycleConfiguration = tieredWithProration.billingCycleConfiguration + conversionRate = tieredWithProration.conversionRate + conversionRateConfig = tieredWithProration.conversionRateConfig + currency = tieredWithProration.currency + dimensionalPriceConfiguration = + tieredWithProration.dimensionalPriceConfiguration + externalPriceId = tieredWithProration.externalPriceId + fixedPriceQuantity = tieredWithProration.fixedPriceQuantity + invoiceGroupingKey = tieredWithProration.invoiceGroupingKey + invoicingCycleConfiguration = + tieredWithProration.invoicingCycleConfiguration + metadata = tieredWithProration.metadata + referenceId = tieredWithProration.referenceId + additionalProperties = + tieredWithProration.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("tiered_with_proration") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for tiered_with_proration pricing */ + fun tieredWithProrationConfig( + tieredWithProrationConfig: TieredWithProrationConfig + ) = tieredWithProrationConfig(JsonField.of(tieredWithProrationConfig)) + + /** + * Sets [Builder.tieredWithProrationConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.tieredWithProrationConfig] with a well-typed + * [TieredWithProrationConfig] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun tieredWithProrationConfig( + tieredWithProrationConfig: JsonField + ) = apply { this.tieredWithProrationConfig = tieredWithProrationConfig } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED ) - ?.let { Price(tieredPackageWithMinimum = it, _json = json) } - ?: Price(_json = json) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [TieredWithProration]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .name() + * .tieredWithProrationConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TieredWithProration = + TieredWithProration( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + modelType, + checkRequired("name", name), + checkRequired("tieredWithProrationConfig", tieredWithProrationConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TieredWithProration = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + _modelType().let { + if (it != JsonValue.from("tiered_with_proration")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + tieredWithProrationConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + modelType.let { + if (it == JsonValue.from("tiered_with_proration")) 1 else 0 + } + + (if (name.asKnown() == null) 0 else 1) + + (tieredWithProrationConfig.asKnown()?.validity() ?: 0) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Configuration for tiered_with_proration pricing */ + class TieredWithProrationConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val tiers: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of() + ) : this(tiers, mutableMapOf()) + + /** + * Tiers for rating based on total usage quantities into the specified tier with + * proration + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun tiers(): List = tiers.getRequired("tiers") + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [TieredWithProrationConfig]. + * + * The following fields are required: + * ```kotlin + * .tiers() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [TieredWithProrationConfig]. */ + class Builder internal constructor() { + + private var tiers: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(tieredWithProrationConfig: TieredWithProrationConfig) = + apply { + tiers = tieredWithProrationConfig.tiers.map { it.toMutableList() } + additionalProperties = + tieredWithProrationConfig.additionalProperties.toMutableMap() + } + + /** + * Tiers for rating based on total usage quantities into the specified tier + * with proration + */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } } - "package_with_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(packageWithAllocation = it, _json = json) } - ?: Price(_json = json) + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } } - "unit_with_percent" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(unitWithPercent = it, _json = json) } - ?: Price(_json = json) + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) } - "matrix_with_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(matrixWithAllocation = it, _json = json) } - ?: Price(_json = json) + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) } - "tiered_with_proration" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(tieredWithProration = it, _json = json) } - ?: Price(_json = json) + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) } - "unit_with_proration" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(unitWithProration = it, _json = json) } - ?: Price(_json = json) + + /** + * Returns an immutable instance of [TieredWithProrationConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TieredWithProrationConfig = + TieredWithProrationConfig( + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TieredWithProrationConfig = apply { + if (validated) { + return@apply } - "grouped_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), + + tiers().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (tiers.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single tiered with proration tier */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val tierLowerBound: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(tierLowerBound, unitAmount, mutableMapOf()) + + /** + * Inclusive tier starting value + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun tierLowerBound(): String = + tierLowerBound.getRequired("tier_lower_bound") + + /** + * Amount per unit + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Tier]. + * + * The following fields are required: + * ```kotlin + * .tierLowerBound() + * .unitAmount() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var tierLowerBound: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(tier: Tier) = apply { + tierLowerBound = tier.tierLowerBound + unitAmount = tier.unitAmount + additionalProperties = tier.additionalProperties.toMutableMap() + } + + /** Inclusive tier starting value */ + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + /** Amount per unit */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```kotlin + * .tierLowerBound() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("tierLowerBound", tierLowerBound), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), ) - ?.let { Price(groupedAllocation = it, _json = json) } - ?: Price(_json = json) } - "bulk_with_proration" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(bulkWithProration = it, _json = json) } - ?: Price(_json = json) + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + tierLowerBound() + unitAmount() + validated = true } - "grouped_with_prorated_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedWithProratedMinimum = it, _json = json) } - ?: Price(_json = json) + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (tierLowerBound.asKnown() == null) 0 else 1) + + (if (unitAmount.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + tierLowerBound == other.tierLowerBound && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties } - "grouped_with_metered_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedWithMeteredMinimum = it, _json = json) } - ?: Price(_json = json) + + private val hashCode: Int by lazy { + Objects.hash(tierLowerBound, unitAmount, additionalProperties) } - "grouped_with_min_max_thresholds" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedWithMinMaxThresholds = it, _json = json) } - ?: Price(_json = json) + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - "matrix_with_display_name" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(matrixWithDisplayName = it, _json = json) } - ?: Price(_json = json) + + return other is TieredWithProrationConfig && + tiers == other.tiers && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(tiers, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TieredWithProrationConfig{tiers=$tiers, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() } - "grouped_tiered_package" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedTieredPackage = it, _json = json) } - ?: Price(_json = json) + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) } - "max_group_tiered_package" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(maxGroupTieredPackage = it, _json = json) } - ?: Price(_json = json) + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) } - "scalable_matrix_with_unit_pricing" -> { - return tryDeserialize( - node, - jacksonTypeRef< - NewSubscriptionScalableMatrixWithUnitPricingPrice - >(), - ) - ?.let { Price(scalableMatrixWithUnitPricing = it, _json = json) } - ?: Price(_json = json) + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) } - "scalable_matrix_with_tiered_pricing" -> { - return tryDeserialize( - node, - jacksonTypeRef< - NewSubscriptionScalableMatrixWithTieredPricingPrice - >(), - ) - ?.let { Price(scalableMatrixWithTieredPricing = it, _json = json) } - ?: Price(_json = json) + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply } - "cumulative_grouped_bulk" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(cumulativeGroupedBulk = it, _json = json) } - ?: Price(_json = json) + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false } - "minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(minimum = it, _json = json) } ?: Price(_json = json) + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() } - "event_output" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(eventOutput = it, _json = json) - } ?: Price(_json = json) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } + + return other is Metadata && + additionalProperties == other.additionalProperties } - return Price(_json = json) - } - } + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - internal class Serializer : BaseSerializer(Price::class) { + override fun hashCode(): Int = hashCode - override fun serialize( - value: Price, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unit != null -> generator.writeObject(value.unit) - value.tiered != null -> generator.writeObject(value.tiered) - value.bulk != null -> generator.writeObject(value.bulk) - value.package_ != null -> generator.writeObject(value.package_) - value.matrix != null -> generator.writeObject(value.matrix) - value.thresholdTotalAmount != null -> - generator.writeObject(value.thresholdTotalAmount) - value.tieredPackage != null -> generator.writeObject(value.tieredPackage) - value.tieredWithMinimum != null -> - generator.writeObject(value.tieredWithMinimum) - value.groupedTiered != null -> generator.writeObject(value.groupedTiered) - value.tieredPackageWithMinimum != null -> - generator.writeObject(value.tieredPackageWithMinimum) - value.packageWithAllocation != null -> - generator.writeObject(value.packageWithAllocation) - value.unitWithPercent != null -> - generator.writeObject(value.unitWithPercent) - value.matrixWithAllocation != null -> - generator.writeObject(value.matrixWithAllocation) - value.tieredWithProration != null -> - generator.writeObject(value.tieredWithProration) - value.unitWithProration != null -> - generator.writeObject(value.unitWithProration) - value.groupedAllocation != null -> - generator.writeObject(value.groupedAllocation) - value.bulkWithProration != null -> - generator.writeObject(value.bulkWithProration) - value.groupedWithProratedMinimum != null -> - generator.writeObject(value.groupedWithProratedMinimum) - value.groupedWithMeteredMinimum != null -> - generator.writeObject(value.groupedWithMeteredMinimum) - value.groupedWithMinMaxThresholds != null -> - generator.writeObject(value.groupedWithMinMaxThresholds) - value.matrixWithDisplayName != null -> - generator.writeObject(value.matrixWithDisplayName) - value.groupedTieredPackage != null -> - generator.writeObject(value.groupedTieredPackage) - value.maxGroupTieredPackage != null -> - generator.writeObject(value.maxGroupTieredPackage) - value.scalableMatrixWithUnitPricing != null -> - generator.writeObject(value.scalableMatrixWithUnitPricing) - value.scalableMatrixWithTieredPricing != null -> - generator.writeObject(value.scalableMatrixWithTieredPricing) - value.cumulativeGroupedBulk != null -> - generator.writeObject(value.cumulativeGroupedBulk) - value.minimum != null -> generator.writeObject(value.minimum) - value.eventOutput != null -> generator.writeObject(value.eventOutput) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Price") + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } + + return other is TieredWithProration && + cadence == other.cadence && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + tieredWithProrationConfig == other.tieredWithProrationConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + modelType, + name, + tieredWithProrationConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties, + ) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TieredWithProration{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredWithProrationConfig=$tieredWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class TieredWithProration + class GroupedWithMinMaxThresholds @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, + private val groupedWithMinMaxThresholdsConfig: + JsonField, private val itemId: JsonField, private val modelType: JsonValue, private val name: JsonField, - private val tieredWithProrationConfig: JsonField, private val billableMetricId: JsonField, private val billedInAdvance: JsonField, private val billingCycleConfiguration: JsonField, @@ -14154,6 +17499,11 @@ private constructor( @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), + @JsonProperty("grouped_with_min_max_thresholds_config") + @ExcludeMissing + groupedWithMinMaxThresholdsConfig: + JsonField = + JsonMissing.of(), @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), @@ -14163,10 +17513,6 @@ private constructor( @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("tiered_with_proration_config") - @ExcludeMissing - tieredWithProrationConfig: JsonField = - JsonMissing.of(), @JsonProperty("billable_metric_id") @ExcludeMissing billableMetricId: JsonField = JsonMissing.of(), @@ -14211,10 +17557,10 @@ private constructor( referenceId: JsonField = JsonMissing.of(), ) : this( cadence, + groupedWithMinMaxThresholdsConfig, itemId, modelType, name, - tieredWithProrationConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -14240,6 +17586,18 @@ private constructor( */ fun cadence(): Cadence = cadence.getRequired("cadence") + /** + * Configuration for grouped_with_min_max_thresholds pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupedWithMinMaxThresholdsConfig(): GroupedWithMinMaxThresholdsConfig = + groupedWithMinMaxThresholdsConfig.getRequired( + "grouped_with_min_max_thresholds_config" + ) + /** * The id of the item the price will be associated with. * @@ -14254,7 +17612,7 @@ private constructor( * * Expected to always return the following: * ```kotlin - * JsonValue.from("tiered_with_proration") + * JsonValue.from("grouped_with_min_max_thresholds") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -14271,16 +17629,6 @@ private constructor( */ fun name(): String = name.getRequired("name") - /** - * Configuration for tiered_with_proration pricing - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun tieredWithProrationConfig(): TieredWithProrationConfig = - tieredWithProrationConfig.getRequired("tiered_with_proration_config") - /** * The id of the billable metric for the price. Only needed if the price is * usage-based. @@ -14410,6 +17758,17 @@ private constructor( @ExcludeMissing fun _cadence(): JsonField = cadence + /** + * Returns the raw JSON value of [groupedWithMinMaxThresholdsConfig]. + * + * Unlike [groupedWithMinMaxThresholdsConfig], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("grouped_with_min_max_thresholds_config") + @ExcludeMissing + fun _groupedWithMinMaxThresholdsConfig(): + JsonField = groupedWithMinMaxThresholdsConfig + /** * Returns the raw JSON value of [itemId]. * @@ -14426,17 +17785,6 @@ private constructor( */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - /** - * Returns the raw JSON value of [tieredWithProrationConfig]. - * - * Unlike [tieredWithProrationConfig], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("tiered_with_proration_config") - @ExcludeMissing - fun _tieredWithProrationConfig(): JsonField = - tieredWithProrationConfig - /** * Returns the raw JSON value of [billableMetricId]. * @@ -14586,28 +17934,30 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [TieredWithProration]. + * [GroupedWithMinMaxThresholds]. * * The following fields are required: * ```kotlin * .cadence() + * .groupedWithMinMaxThresholdsConfig() * .itemId() * .name() - * .tieredWithProrationConfig() * ``` */ fun builder() = Builder() } - /** A builder for [TieredWithProration]. */ + /** A builder for [GroupedWithMinMaxThresholds]. */ class Builder internal constructor() { private var cadence: JsonField? = null + private var groupedWithMinMaxThresholdsConfig: + JsonField? = + null private var itemId: JsonField? = null - private var modelType: JsonValue = JsonValue.from("tiered_with_proration") + private var modelType: JsonValue = + JsonValue.from("grouped_with_min_max_thresholds") private var name: JsonField? = null - private var tieredWithProrationConfig: JsonField? = - null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() private var billingCycleConfiguration: JsonField = @@ -14629,30 +17979,33 @@ private constructor( private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(tieredWithProration: TieredWithProration) = apply { - cadence = tieredWithProration.cadence - itemId = tieredWithProration.itemId - modelType = tieredWithProration.modelType - name = tieredWithProration.name - tieredWithProrationConfig = tieredWithProration.tieredWithProrationConfig - billableMetricId = tieredWithProration.billableMetricId - billedInAdvance = tieredWithProration.billedInAdvance - billingCycleConfiguration = tieredWithProration.billingCycleConfiguration - conversionRate = tieredWithProration.conversionRate - conversionRateConfig = tieredWithProration.conversionRateConfig - currency = tieredWithProration.currency - dimensionalPriceConfiguration = - tieredWithProration.dimensionalPriceConfiguration - externalPriceId = tieredWithProration.externalPriceId - fixedPriceQuantity = tieredWithProration.fixedPriceQuantity - invoiceGroupingKey = tieredWithProration.invoiceGroupingKey - invoicingCycleConfiguration = - tieredWithProration.invoicingCycleConfiguration - metadata = tieredWithProration.metadata - referenceId = tieredWithProration.referenceId - additionalProperties = - tieredWithProration.additionalProperties.toMutableMap() - } + internal fun from(groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds) = + apply { + cadence = groupedWithMinMaxThresholds.cadence + groupedWithMinMaxThresholdsConfig = + groupedWithMinMaxThresholds.groupedWithMinMaxThresholdsConfig + itemId = groupedWithMinMaxThresholds.itemId + modelType = groupedWithMinMaxThresholds.modelType + name = groupedWithMinMaxThresholds.name + billableMetricId = groupedWithMinMaxThresholds.billableMetricId + billedInAdvance = groupedWithMinMaxThresholds.billedInAdvance + billingCycleConfiguration = + groupedWithMinMaxThresholds.billingCycleConfiguration + conversionRate = groupedWithMinMaxThresholds.conversionRate + conversionRateConfig = groupedWithMinMaxThresholds.conversionRateConfig + currency = groupedWithMinMaxThresholds.currency + dimensionalPriceConfiguration = + groupedWithMinMaxThresholds.dimensionalPriceConfiguration + externalPriceId = groupedWithMinMaxThresholds.externalPriceId + fixedPriceQuantity = groupedWithMinMaxThresholds.fixedPriceQuantity + invoiceGroupingKey = groupedWithMinMaxThresholds.invoiceGroupingKey + invoicingCycleConfiguration = + groupedWithMinMaxThresholds.invoicingCycleConfiguration + metadata = groupedWithMinMaxThresholds.metadata + referenceId = groupedWithMinMaxThresholds.referenceId + additionalProperties = + groupedWithMinMaxThresholds.additionalProperties.toMutableMap() + } /** The cadence to bill for this price on. */ fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) @@ -14666,6 +18019,29 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + /** Configuration for grouped_with_min_max_thresholds pricing */ + fun groupedWithMinMaxThresholdsConfig( + groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + ) = + groupedWithMinMaxThresholdsConfig( + JsonField.of(groupedWithMinMaxThresholdsConfig) + ) + + /** + * Sets [Builder.groupedWithMinMaxThresholdsConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.groupedWithMinMaxThresholdsConfig] with a + * well-typed [GroupedWithMinMaxThresholdsConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun groupedWithMinMaxThresholdsConfig( + groupedWithMinMaxThresholdsConfig: + JsonField + ) = apply { + this.groupedWithMinMaxThresholdsConfig = groupedWithMinMaxThresholdsConfig + } + /** The id of the item the price will be associated with. */ fun itemId(itemId: String) = itemId(JsonField.of(itemId)) @@ -14684,7 +18060,7 @@ private constructor( * It is usually unnecessary to call this method because the field defaults to * the following: * ```kotlin - * JsonValue.from("tiered_with_proration") + * JsonValue.from("grouped_with_min_max_thresholds") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -14704,22 +18080,6 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } - /** Configuration for tiered_with_proration pricing */ - fun tieredWithProrationConfig( - tieredWithProrationConfig: TieredWithProrationConfig - ) = tieredWithProrationConfig(JsonField.of(tieredWithProrationConfig)) - - /** - * Sets [Builder.tieredWithProrationConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.tieredWithProrationConfig] with a well-typed - * [TieredWithProrationConfig] value instead. This method is primarily for - * setting the field to an undocumented or not yet supported value. - */ - fun tieredWithProrationConfig( - tieredWithProrationConfig: JsonField - ) = apply { this.tieredWithProrationConfig = tieredWithProrationConfig } - /** * The id of the billable metric for the price. Only needed if the price is * usage-based. @@ -15049,27 +18409,30 @@ private constructor( } /** - * Returns an immutable instance of [TieredWithProration]. + * Returns an immutable instance of [GroupedWithMinMaxThresholds]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```kotlin * .cadence() + * .groupedWithMinMaxThresholdsConfig() * .itemId() * .name() - * .tieredWithProrationConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): TieredWithProration = - TieredWithProration( + fun build(): GroupedWithMinMaxThresholds = + GroupedWithMinMaxThresholds( checkRequired("cadence", cadence), + checkRequired( + "groupedWithMinMaxThresholdsConfig", + groupedWithMinMaxThresholdsConfig, + ), checkRequired("itemId", itemId), modelType, checkRequired("name", name), - checkRequired("tieredWithProrationConfig", tieredWithProrationConfig), billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -15089,20 +18452,20 @@ private constructor( private var validated: Boolean = false - fun validate(): TieredWithProration = apply { + fun validate(): GroupedWithMinMaxThresholds = apply { if (validated) { return@apply } cadence().validate() + groupedWithMinMaxThresholdsConfig().validate() itemId() _modelType().let { - if (it != JsonValue.from("tiered_with_proration")) { + if (it != JsonValue.from("grouped_with_min_max_thresholds")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } name() - tieredWithProrationConfig().validate() billableMetricId() billedInAdvance() billingCycleConfiguration()?.validate() @@ -15135,12 +18498,12 @@ private constructor( */ internal fun validity(): Int = (cadence.asKnown()?.validity() ?: 0) + + (groupedWithMinMaxThresholdsConfig.asKnown()?.validity() ?: 0) + (if (itemId.asKnown() == null) 0 else 1) + modelType.let { - if (it == JsonValue.from("tiered_with_proration")) 1 else 0 + if (it == JsonValue.from("grouped_with_min_max_thresholds")) 1 else 0 } + (if (name.asKnown() == null) 0 else 1) + - (tieredWithProrationConfig.asKnown()?.validity() ?: 0) + (if (billableMetricId.asKnown() == null) 0 else 1) + (if (billedInAdvance.asKnown() == null) 0 else 1) + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + @@ -15312,419 +18675,328 @@ private constructor( override fun toString() = value.toString() } - /** Configuration for tiered_with_proration pricing */ - class TieredWithProrationConfig + /** Configuration for grouped_with_min_max_thresholds pricing */ + class GroupedWithMinMaxThresholdsConfig @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val tiers: JsonField>, + private val groupingKey: JsonField, + private val maximumCharge: JsonField, + private val minimumCharge: JsonField, + private val perUnitRate: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("tiers") + @JsonProperty("grouping_key") @ExcludeMissing - tiers: JsonField> = JsonMissing.of() - ) : this(tiers, mutableMapOf()) + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("maximum_charge") + @ExcludeMissing + maximumCharge: JsonField = JsonMissing.of(), + @JsonProperty("minimum_charge") + @ExcludeMissing + minimumCharge: JsonField = JsonMissing.of(), + @JsonProperty("per_unit_rate") + @ExcludeMissing + perUnitRate: JsonField = JsonMissing.of(), + ) : this(groupingKey, maximumCharge, minimumCharge, perUnitRate, mutableMapOf()) /** - * Tiers for rating based on total usage quantities into the specified tier with - * proration + * The event property used to group before applying thresholds * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). */ - fun tiers(): List = tiers.getRequired("tiers") + fun groupingKey(): String = groupingKey.getRequired("grouping_key") /** - * Returns the raw JSON value of [tiers]. + * The maximum amount to charge each group * - * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected - * type. + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). */ - @JsonProperty("tiers") - @ExcludeMissing - fun _tiers(): JsonField> = tiers - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [TieredWithProrationConfig]. - * - * The following fields are required: - * ```kotlin - * .tiers() - * ``` - */ - fun builder() = Builder() - } - - /** A builder for [TieredWithProrationConfig]. */ - class Builder internal constructor() { + fun maximumCharge(): String = maximumCharge.getRequired("maximum_charge") - private var tiers: JsonField>? = null - private var additionalProperties: MutableMap = - mutableMapOf() + /** + * The minimum amount to charge each group, regardless of usage + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun minimumCharge(): String = minimumCharge.getRequired("minimum_charge") - internal fun from(tieredWithProrationConfig: TieredWithProrationConfig) = - apply { - tiers = tieredWithProrationConfig.tiers.map { it.toMutableList() } - additionalProperties = - tieredWithProrationConfig.additionalProperties.toMutableMap() - } + /** + * The base price charged per group + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun perUnitRate(): String = perUnitRate.getRequired("per_unit_rate") - /** - * Tiers for rating based on total usage quantities into the specified tier - * with proration - */ - fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey - /** - * Sets [Builder.tiers] to an arbitrary JSON value. - * - * You should usually call [Builder.tiers] with a well-typed `List` - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun tiers(tiers: JsonField>) = apply { - this.tiers = tiers.map { it.toMutableList() } - } + /** + * Returns the raw JSON value of [maximumCharge]. + * + * Unlike [maximumCharge], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("maximum_charge") + @ExcludeMissing + fun _maximumCharge(): JsonField = maximumCharge - /** - * Adds a single [Tier] to [tiers]. - * - * @throws IllegalStateException if the field was previously set to a - * non-list. - */ - fun addTier(tier: Tier) = apply { - tiers = - (tiers ?: JsonField.of(mutableListOf())).also { - checkKnown("tiers", it).add(tier) - } - } + /** + * Returns the raw JSON value of [minimumCharge]. + * + * Unlike [minimumCharge], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("minimum_charge") + @ExcludeMissing + fun _minimumCharge(): JsonField = minimumCharge - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * Returns the raw JSON value of [perUnitRate]. + * + * Unlike [perUnitRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("per_unit_rate") + @ExcludeMissing + fun _perUnitRate(): JsonField = perUnitRate - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun toBuilder() = Builder().from(this) - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + companion object { /** - * Returns an immutable instance of [TieredWithProrationConfig]. - * - * Further updates to this [Builder] will not mutate the returned instance. + * Returns a mutable builder for constructing an instance of + * [GroupedWithMinMaxThresholdsConfig]. * * The following fields are required: * ```kotlin - * .tiers() + * .groupingKey() + * .maximumCharge() + * .minimumCharge() + * .perUnitRate() * ``` - * - * @throws IllegalStateException if any required field is unset. */ - fun build(): TieredWithProrationConfig = - TieredWithProrationConfig( - checkRequired("tiers", tiers).map { it.toImmutable() }, - additionalProperties.toMutableMap(), - ) + fun builder() = Builder() } - private var validated: Boolean = false - - fun validate(): TieredWithProrationConfig = apply { - if (validated) { - return@apply - } + /** A builder for [GroupedWithMinMaxThresholdsConfig]. */ + class Builder internal constructor() { - tiers().forEach { it.validate() } - validated = true - } + private var groupingKey: JsonField? = null + private var maximumCharge: JsonField? = null + private var minimumCharge: JsonField? = null + private var perUnitRate: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false + internal fun from( + groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + ) = apply { + groupingKey = groupedWithMinMaxThresholdsConfig.groupingKey + maximumCharge = groupedWithMinMaxThresholdsConfig.maximumCharge + minimumCharge = groupedWithMinMaxThresholdsConfig.minimumCharge + perUnitRate = groupedWithMinMaxThresholdsConfig.perUnitRate + additionalProperties = + groupedWithMinMaxThresholdsConfig.additionalProperties + .toMutableMap() } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (tiers.asKnown()?.sumOf { it.validity().toInt() } ?: 0) - - /** Configuration for a single tiered with proration tier */ - class Tier - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val tierLowerBound: JsonField, - private val unitAmount: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("tier_lower_bound") - @ExcludeMissing - tierLowerBound: JsonField = JsonMissing.of(), - @JsonProperty("unit_amount") - @ExcludeMissing - unitAmount: JsonField = JsonMissing.of(), - ) : this(tierLowerBound, unitAmount, mutableMapOf()) - - /** - * Inclusive tier starting value - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type - * or is unexpectedly missing or null (e.g. if the server responded with - * an unexpected value). - */ - fun tierLowerBound(): String = - tierLowerBound.getRequired("tier_lower_bound") + /** The event property used to group before applying thresholds */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) /** - * Amount per unit + * Sets [Builder.groupingKey] to an arbitrary JSON value. * - * @throws OrbInvalidDataException if the JSON field has an unexpected type - * or is unexpectedly missing or null (e.g. if the server responded with - * an unexpected value). + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. */ - fun unitAmount(): String = unitAmount.getRequired("unit_amount") + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } - /** - * Returns the raw JSON value of [tierLowerBound]. - * - * Unlike [tierLowerBound], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("tier_lower_bound") - @ExcludeMissing - fun _tierLowerBound(): JsonField = tierLowerBound + /** The maximum amount to charge each group */ + fun maximumCharge(maximumCharge: String) = + maximumCharge(JsonField.of(maximumCharge)) /** - * Returns the raw JSON value of [unitAmount]. + * Sets [Builder.maximumCharge] to an arbitrary JSON value. * - * Unlike [unitAmount], this method doesn't throw if the JSON field has an - * unexpected type. + * You should usually call [Builder.maximumCharge] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. */ - @JsonProperty("unit_amount") - @ExcludeMissing - fun _unitAmount(): JsonField = unitAmount - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [Tier]. - * - * The following fields are required: - * ```kotlin - * .tierLowerBound() - * .unitAmount() - * ``` - */ - fun builder() = Builder() - } - - /** A builder for [Tier]. */ - class Builder internal constructor() { - - private var tierLowerBound: JsonField? = null - private var unitAmount: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - internal fun from(tier: Tier) = apply { - tierLowerBound = tier.tierLowerBound - unitAmount = tier.unitAmount - additionalProperties = tier.additionalProperties.toMutableMap() - } - - /** Inclusive tier starting value */ - fun tierLowerBound(tierLowerBound: String) = - tierLowerBound(JsonField.of(tierLowerBound)) - - /** - * Sets [Builder.tierLowerBound] to an arbitrary JSON value. - * - * You should usually call [Builder.tierLowerBound] with a well-typed - * [String] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun tierLowerBound(tierLowerBound: JsonField) = apply { - this.tierLowerBound = tierLowerBound - } - - /** Amount per unit */ - fun unitAmount(unitAmount: String) = - unitAmount(JsonField.of(unitAmount)) - - /** - * Sets [Builder.unitAmount] to an arbitrary JSON value. - * - * You should usually call [Builder.unitAmount] with a well-typed - * [String] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun unitAmount(unitAmount: JsonField) = apply { - this.unitAmount = unitAmount - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Tier]. - * - * Further updates to this [Builder] will not mutate the returned - * instance. - * - * The following fields are required: - * ```kotlin - * .tierLowerBound() - * .unitAmount() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Tier = - Tier( - checkRequired("tierLowerBound", tierLowerBound), - checkRequired("unitAmount", unitAmount), - additionalProperties.toMutableMap(), - ) + fun maximumCharge(maximumCharge: JsonField) = apply { + this.maximumCharge = maximumCharge } - private var validated: Boolean = false - - fun validate(): Tier = apply { - if (validated) { - return@apply - } + /** The minimum amount to charge each group, regardless of usage */ + fun minimumCharge(minimumCharge: String) = + minimumCharge(JsonField.of(minimumCharge)) - tierLowerBound() - unitAmount() - validated = true + /** + * Sets [Builder.minimumCharge] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumCharge] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun minimumCharge(minimumCharge: JsonField) = apply { + this.minimumCharge = minimumCharge } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** The base price charged per group */ + fun perUnitRate(perUnitRate: String) = + perUnitRate(JsonField.of(perUnitRate)) /** - * Returns a score indicating how many valid values are contained in this - * object recursively. + * Sets [Builder.perUnitRate] to an arbitrary JSON value. * - * Used for best match union deserialization. + * You should usually call [Builder.perUnitRate] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. */ - internal fun validity(): Int = - (if (tierLowerBound.asKnown() == null) 0 else 1) + - (if (unitAmount.asKnown() == null) 0 else 1) + fun perUnitRate(perUnitRate: JsonField) = apply { + this.perUnitRate = perUnitRate + } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) } - return other is Tier && - tierLowerBound == other.tierLowerBound && - unitAmount == other.unitAmount && - additionalProperties == other.additionalProperties + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) } - private val hashCode: Int by lazy { - Objects.hash(tierLowerBound, unitAmount, additionalProperties) + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) } - override fun hashCode(): Int = hashCode + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - override fun toString() = - "Tier{tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + /** + * Returns an immutable instance of [GroupedWithMinMaxThresholdsConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .maximumCharge() + * .minimumCharge() + * .perUnitRate() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedWithMinMaxThresholdsConfig = + GroupedWithMinMaxThresholdsConfig( + checkRequired("groupingKey", groupingKey), + checkRequired("maximumCharge", maximumCharge), + checkRequired("minimumCharge", minimumCharge), + checkRequired("perUnitRate", perUnitRate), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GroupedWithMinMaxThresholdsConfig = apply { + if (validated) { + return@apply + } + + groupingKey() + maximumCharge() + minimumCharge() + perUnitRate() + validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (groupingKey.asKnown() == null) 0 else 1) + + (if (maximumCharge.asKnown() == null) 0 else 1) + + (if (minimumCharge.asKnown() == null) 0 else 1) + + (if (perUnitRate.asKnown() == null) 0 else 1) + override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is TieredWithProrationConfig && - tiers == other.tiers && + return other is GroupedWithMinMaxThresholdsConfig && + groupingKey == other.groupingKey && + maximumCharge == other.maximumCharge && + minimumCharge == other.minimumCharge && + perUnitRate == other.perUnitRate && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(tiers, additionalProperties) } + private val hashCode: Int by lazy { + Objects.hash( + groupingKey, + maximumCharge, + minimumCharge, + perUnitRate, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode override fun toString() = - "TieredWithProrationConfig{tiers=$tiers, additionalProperties=$additionalProperties}" + "GroupedWithMinMaxThresholdsConfig{groupingKey=$groupingKey, maximumCharge=$maximumCharge, minimumCharge=$minimumCharge, perUnitRate=$perUnitRate, additionalProperties=$additionalProperties}" } /** @@ -15841,12 +19113,13 @@ private constructor( return true } - return other is TieredWithProration && + return other is GroupedWithMinMaxThresholds && cadence == other.cadence && + groupedWithMinMaxThresholdsConfig == + other.groupedWithMinMaxThresholdsConfig && itemId == other.itemId && modelType == other.modelType && name == other.name && - tieredWithProrationConfig == other.tieredWithProrationConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && @@ -15866,10 +19139,10 @@ private constructor( private val hashCode: Int by lazy { Objects.hash( cadence, + groupedWithMinMaxThresholdsConfig, itemId, modelType, name, - tieredWithProrationConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -15890,18 +19163,17 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "TieredWithProration{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredWithProrationConfig=$tieredWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "GroupedWithMinMaxThresholds{cadence=$cadence, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class GroupedWithMinMaxThresholds + class Percent @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, - private val groupedWithMinMaxThresholdsConfig: - JsonField, private val itemId: JsonField, private val modelType: JsonValue, private val name: JsonField, + private val percentConfig: JsonField, private val billableMetricId: JsonField, private val billedInAdvance: JsonField, private val billingCycleConfiguration: JsonField, @@ -15924,11 +19196,6 @@ private constructor( @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), - @JsonProperty("grouped_with_min_max_thresholds_config") - @ExcludeMissing - groupedWithMinMaxThresholdsConfig: - JsonField = - JsonMissing.of(), @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), @@ -15938,6 +19205,9 @@ private constructor( @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("percent_config") + @ExcludeMissing + percentConfig: JsonField = JsonMissing.of(), @JsonProperty("billable_metric_id") @ExcludeMissing billableMetricId: JsonField = JsonMissing.of(), @@ -15982,10 +19252,10 @@ private constructor( referenceId: JsonField = JsonMissing.of(), ) : this( cadence, - groupedWithMinMaxThresholdsConfig, itemId, modelType, name, + percentConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -16011,18 +19281,6 @@ private constructor( */ fun cadence(): Cadence = cadence.getRequired("cadence") - /** - * Configuration for grouped_with_min_max_thresholds pricing - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun groupedWithMinMaxThresholdsConfig(): GroupedWithMinMaxThresholdsConfig = - groupedWithMinMaxThresholdsConfig.getRequired( - "grouped_with_min_max_thresholds_config" - ) - /** * The id of the item the price will be associated with. * @@ -16037,7 +19295,7 @@ private constructor( * * Expected to always return the following: * ```kotlin - * JsonValue.from("grouped_with_min_max_thresholds") + * JsonValue.from("percent") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -16054,6 +19312,15 @@ private constructor( */ fun name(): String = name.getRequired("name") + /** + * Configuration for percent pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun percentConfig(): PercentConfig = percentConfig.getRequired("percent_config") + /** * The id of the billable metric for the price. Only needed if the price is * usage-based. @@ -16183,17 +19450,6 @@ private constructor( @ExcludeMissing fun _cadence(): JsonField = cadence - /** - * Returns the raw JSON value of [groupedWithMinMaxThresholdsConfig]. - * - * Unlike [groupedWithMinMaxThresholdsConfig], this method doesn't throw if the JSON - * field has an unexpected type. - */ - @JsonProperty("grouped_with_min_max_thresholds_config") - @ExcludeMissing - fun _groupedWithMinMaxThresholdsConfig(): - JsonField = groupedWithMinMaxThresholdsConfig - /** * Returns the raw JSON value of [itemId]. * @@ -16210,6 +19466,16 @@ private constructor( */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + /** + * Returns the raw JSON value of [percentConfig]. + * + * Unlike [percentConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("percent_config") + @ExcludeMissing + fun _percentConfig(): JsonField = percentConfig + /** * Returns the raw JSON value of [billableMetricId]. * @@ -16358,79 +19624,69 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [GroupedWithMinMaxThresholds]. + * Returns a mutable builder for constructing an instance of [Percent]. * * The following fields are required: * ```kotlin * .cadence() - * .groupedWithMinMaxThresholdsConfig() * .itemId() * .name() + * .percentConfig() * ``` */ fun builder() = Builder() } - /** A builder for [GroupedWithMinMaxThresholds]. */ + /** A builder for [Percent]. */ class Builder internal constructor() { private var cadence: JsonField? = null - private var groupedWithMinMaxThresholdsConfig: - JsonField? = - null private var itemId: JsonField? = null - private var modelType: JsonValue = - JsonValue.from("grouped_with_min_max_thresholds") + private var modelType: JsonValue = JsonValue.from("percent") private var name: JsonField? = null + private var percentConfig: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() private var billingCycleConfiguration: JsonField = JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var conversionRateConfig: JsonField = - JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var dimensionalPriceConfiguration: - JsonField = - JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: - JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var referenceId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds) = - apply { - cadence = groupedWithMinMaxThresholds.cadence - groupedWithMinMaxThresholdsConfig = - groupedWithMinMaxThresholds.groupedWithMinMaxThresholdsConfig - itemId = groupedWithMinMaxThresholds.itemId - modelType = groupedWithMinMaxThresholds.modelType - name = groupedWithMinMaxThresholds.name - billableMetricId = groupedWithMinMaxThresholds.billableMetricId - billedInAdvance = groupedWithMinMaxThresholds.billedInAdvance - billingCycleConfiguration = - groupedWithMinMaxThresholds.billingCycleConfiguration - conversionRate = groupedWithMinMaxThresholds.conversionRate - conversionRateConfig = groupedWithMinMaxThresholds.conversionRateConfig - currency = groupedWithMinMaxThresholds.currency - dimensionalPriceConfiguration = - groupedWithMinMaxThresholds.dimensionalPriceConfiguration - externalPriceId = groupedWithMinMaxThresholds.externalPriceId - fixedPriceQuantity = groupedWithMinMaxThresholds.fixedPriceQuantity - invoiceGroupingKey = groupedWithMinMaxThresholds.invoiceGroupingKey - invoicingCycleConfiguration = - groupedWithMinMaxThresholds.invoicingCycleConfiguration - metadata = groupedWithMinMaxThresholds.metadata - referenceId = groupedWithMinMaxThresholds.referenceId - additionalProperties = - groupedWithMinMaxThresholds.additionalProperties.toMutableMap() - } + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(percent: Percent) = apply { + cadence = percent.cadence + itemId = percent.itemId + modelType = percent.modelType + name = percent.name + percentConfig = percent.percentConfig + billableMetricId = percent.billableMetricId + billedInAdvance = percent.billedInAdvance + billingCycleConfiguration = percent.billingCycleConfiguration + conversionRate = percent.conversionRate + conversionRateConfig = percent.conversionRateConfig + currency = percent.currency + dimensionalPriceConfiguration = percent.dimensionalPriceConfiguration + externalPriceId = percent.externalPriceId + fixedPriceQuantity = percent.fixedPriceQuantity + invoiceGroupingKey = percent.invoiceGroupingKey + invoicingCycleConfiguration = percent.invoicingCycleConfiguration + metadata = percent.metadata + referenceId = percent.referenceId + additionalProperties = percent.additionalProperties.toMutableMap() + } /** The cadence to bill for this price on. */ fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) @@ -16444,29 +19700,6 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - /** Configuration for grouped_with_min_max_thresholds pricing */ - fun groupedWithMinMaxThresholdsConfig( - groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig - ) = - groupedWithMinMaxThresholdsConfig( - JsonField.of(groupedWithMinMaxThresholdsConfig) - ) - - /** - * Sets [Builder.groupedWithMinMaxThresholdsConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.groupedWithMinMaxThresholdsConfig] with a - * well-typed [GroupedWithMinMaxThresholdsConfig] value instead. This method is - * primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun groupedWithMinMaxThresholdsConfig( - groupedWithMinMaxThresholdsConfig: - JsonField - ) = apply { - this.groupedWithMinMaxThresholdsConfig = groupedWithMinMaxThresholdsConfig - } - /** The id of the item the price will be associated with. */ fun itemId(itemId: String) = itemId(JsonField.of(itemId)) @@ -16485,7 +19718,7 @@ private constructor( * It is usually unnecessary to call this method because the field defaults to * the following: * ```kotlin - * JsonValue.from("grouped_with_min_max_thresholds") + * JsonValue.from("percent") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -16505,6 +19738,21 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } + /** Configuration for percent pricing */ + fun percentConfig(percentConfig: PercentConfig) = + percentConfig(JsonField.of(percentConfig)) + + /** + * Sets [Builder.percentConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.percentConfig] with a well-typed + * [PercentConfig] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun percentConfig(percentConfig: JsonField) = apply { + this.percentConfig = percentConfig + } + /** * The id of the billable metric for the price. Only needed if the price is * usage-based. @@ -16834,30 +20082,27 @@ private constructor( } /** - * Returns an immutable instance of [GroupedWithMinMaxThresholds]. + * Returns an immutable instance of [Percent]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```kotlin * .cadence() - * .groupedWithMinMaxThresholdsConfig() * .itemId() * .name() + * .percentConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): GroupedWithMinMaxThresholds = - GroupedWithMinMaxThresholds( + fun build(): Percent = + Percent( checkRequired("cadence", cadence), - checkRequired( - "groupedWithMinMaxThresholdsConfig", - groupedWithMinMaxThresholdsConfig, - ), checkRequired("itemId", itemId), modelType, checkRequired("name", name), + checkRequired("percentConfig", percentConfig), billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -16877,20 +20122,20 @@ private constructor( private var validated: Boolean = false - fun validate(): GroupedWithMinMaxThresholds = apply { + fun validate(): Percent = apply { if (validated) { return@apply } cadence().validate() - groupedWithMinMaxThresholdsConfig().validate() itemId() _modelType().let { - if (it != JsonValue.from("grouped_with_min_max_thresholds")) { + if (it != JsonValue.from("percent")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } name() + percentConfig().validate() billableMetricId() billedInAdvance() billingCycleConfiguration()?.validate() @@ -16923,12 +20168,10 @@ private constructor( */ internal fun validity(): Int = (cadence.asKnown()?.validity() ?: 0) + - (groupedWithMinMaxThresholdsConfig.asKnown()?.validity() ?: 0) + (if (itemId.asKnown() == null) 0 else 1) + - modelType.let { - if (it == JsonValue.from("grouped_with_min_max_thresholds")) 1 else 0 - } + + modelType.let { if (it == JsonValue.from("percent")) 1 else 0 } + (if (name.asKnown() == null) 0 else 1) + + (percentConfig.asKnown()?.validity() ?: 0) + (if (billableMetricId.asKnown() == null) 0 else 1) + (if (billedInAdvance.asKnown() == null) 0 else 1) + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + @@ -17100,108 +20343,39 @@ private constructor( override fun toString() = value.toString() } - /** Configuration for grouped_with_min_max_thresholds pricing */ - class GroupedWithMinMaxThresholdsConfig + /** Configuration for percent pricing */ + class PercentConfig @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val groupingKey: JsonField, - private val maximumCharge: JsonField, - private val minimumCharge: JsonField, - private val perUnitRate: JsonField, + private val percent: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("grouping_key") - @ExcludeMissing - groupingKey: JsonField = JsonMissing.of(), - @JsonProperty("maximum_charge") - @ExcludeMissing - maximumCharge: JsonField = JsonMissing.of(), - @JsonProperty("minimum_charge") + @JsonProperty("percent") @ExcludeMissing - minimumCharge: JsonField = JsonMissing.of(), - @JsonProperty("per_unit_rate") - @ExcludeMissing - perUnitRate: JsonField = JsonMissing.of(), - ) : this(groupingKey, maximumCharge, minimumCharge, perUnitRate, mutableMapOf()) - - /** - * The event property used to group before applying thresholds - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun groupingKey(): String = groupingKey.getRequired("grouping_key") - - /** - * The maximum amount to charge each group - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun maximumCharge(): String = maximumCharge.getRequired("maximum_charge") - - /** - * The minimum amount to charge each group, regardless of usage - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun minimumCharge(): String = minimumCharge.getRequired("minimum_charge") + percent: JsonField = JsonMissing.of() + ) : this(percent, mutableMapOf()) /** - * The base price charged per group + * What percent of the component subtotals to charge * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). */ - fun perUnitRate(): String = perUnitRate.getRequired("per_unit_rate") - - /** - * Returns the raw JSON value of [groupingKey]. - * - * Unlike [groupingKey], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("grouping_key") - @ExcludeMissing - fun _groupingKey(): JsonField = groupingKey - - /** - * Returns the raw JSON value of [maximumCharge]. - * - * Unlike [maximumCharge], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("maximum_charge") - @ExcludeMissing - fun _maximumCharge(): JsonField = maximumCharge - - /** - * Returns the raw JSON value of [minimumCharge]. - * - * Unlike [minimumCharge], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("minimum_charge") - @ExcludeMissing - fun _minimumCharge(): JsonField = minimumCharge + fun percent(): Double = percent.getRequired("percent") /** - * Returns the raw JSON value of [perUnitRate]. + * Returns the raw JSON value of [percent]. * - * Unlike [perUnitRate], this method doesn't throw if the JSON field has an + * Unlike [percent], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("per_unit_rate") + @JsonProperty("percent") @ExcludeMissing - fun _perUnitRate(): JsonField = perUnitRate + fun _percent(): JsonField = percent @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -17219,100 +20393,39 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [GroupedWithMinMaxThresholdsConfig]. + * [PercentConfig]. * * The following fields are required: * ```kotlin - * .groupingKey() - * .maximumCharge() - * .minimumCharge() - * .perUnitRate() + * .percent() * ``` */ fun builder() = Builder() } - /** A builder for [GroupedWithMinMaxThresholdsConfig]. */ + /** A builder for [PercentConfig]. */ class Builder internal constructor() { - private var groupingKey: JsonField? = null - private var maximumCharge: JsonField? = null - private var minimumCharge: JsonField? = null - private var perUnitRate: JsonField? = null + private var percent: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() - internal fun from( - groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig - ) = apply { - groupingKey = groupedWithMinMaxThresholdsConfig.groupingKey - maximumCharge = groupedWithMinMaxThresholdsConfig.maximumCharge - minimumCharge = groupedWithMinMaxThresholdsConfig.minimumCharge - perUnitRate = groupedWithMinMaxThresholdsConfig.perUnitRate - additionalProperties = - groupedWithMinMaxThresholdsConfig.additionalProperties - .toMutableMap() - } - - /** The event property used to group before applying thresholds */ - fun groupingKey(groupingKey: String) = - groupingKey(JsonField.of(groupingKey)) - - /** - * Sets [Builder.groupingKey] to an arbitrary JSON value. - * - * You should usually call [Builder.groupingKey] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun groupingKey(groupingKey: JsonField) = apply { - this.groupingKey = groupingKey - } - - /** The maximum amount to charge each group */ - fun maximumCharge(maximumCharge: String) = - maximumCharge(JsonField.of(maximumCharge)) - - /** - * Sets [Builder.maximumCharge] to an arbitrary JSON value. - * - * You should usually call [Builder.maximumCharge] with a well-typed - * [String] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun maximumCharge(maximumCharge: JsonField) = apply { - this.maximumCharge = maximumCharge - } - - /** The minimum amount to charge each group, regardless of usage */ - fun minimumCharge(minimumCharge: String) = - minimumCharge(JsonField.of(minimumCharge)) - - /** - * Sets [Builder.minimumCharge] to an arbitrary JSON value. - * - * You should usually call [Builder.minimumCharge] with a well-typed - * [String] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun minimumCharge(minimumCharge: JsonField) = apply { - this.minimumCharge = minimumCharge + internal fun from(percentConfig: PercentConfig) = apply { + percent = percentConfig.percent + additionalProperties = percentConfig.additionalProperties.toMutableMap() } - /** The base price charged per group */ - fun perUnitRate(perUnitRate: String) = - perUnitRate(JsonField.of(perUnitRate)) + /** What percent of the component subtotals to charge */ + fun percent(percent: Double) = percent(JsonField.of(percent)) /** - * Sets [Builder.perUnitRate] to an arbitrary JSON value. + * Sets [Builder.percent] to an arbitrary JSON value. * - * You should usually call [Builder.perUnitRate] with a well-typed [String] + * You should usually call [Builder.percent] with a well-typed [Double] * value instead. This method is primarily for setting the field to an * undocumented or not yet supported value. */ - fun perUnitRate(perUnitRate: JsonField) = apply { - this.perUnitRate = perUnitRate - } + fun percent(percent: JsonField) = apply { this.percent = percent } fun additionalProperties(additionalProperties: Map) = apply { @@ -17337,41 +20450,32 @@ private constructor( } /** - * Returns an immutable instance of [GroupedWithMinMaxThresholdsConfig]. + * Returns an immutable instance of [PercentConfig]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```kotlin - * .groupingKey() - * .maximumCharge() - * .minimumCharge() - * .perUnitRate() + * .percent() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): GroupedWithMinMaxThresholdsConfig = - GroupedWithMinMaxThresholdsConfig( - checkRequired("groupingKey", groupingKey), - checkRequired("maximumCharge", maximumCharge), - checkRequired("minimumCharge", minimumCharge), - checkRequired("perUnitRate", perUnitRate), + fun build(): PercentConfig = + PercentConfig( + checkRequired("percent", percent), additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): GroupedWithMinMaxThresholdsConfig = apply { + fun validate(): PercentConfig = apply { if (validated) { return@apply } - groupingKey() - maximumCharge() - minimumCharge() - perUnitRate() + percent() validated = true } @@ -17389,39 +20493,26 @@ private constructor( * * Used for best match union deserialization. */ - internal fun validity(): Int = - (if (groupingKey.asKnown() == null) 0 else 1) + - (if (maximumCharge.asKnown() == null) 0 else 1) + - (if (minimumCharge.asKnown() == null) 0 else 1) + - (if (perUnitRate.asKnown() == null) 0 else 1) + internal fun validity(): Int = (if (percent.asKnown() == null) 0 else 1) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is GroupedWithMinMaxThresholdsConfig && - groupingKey == other.groupingKey && - maximumCharge == other.maximumCharge && - minimumCharge == other.minimumCharge && - perUnitRate == other.perUnitRate && + return other is PercentConfig && + percent == other.percent && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash( - groupingKey, - maximumCharge, - minimumCharge, - perUnitRate, - additionalProperties, - ) + Objects.hash(percent, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "GroupedWithMinMaxThresholdsConfig{groupingKey=$groupingKey, maximumCharge=$maximumCharge, minimumCharge=$minimumCharge, perUnitRate=$perUnitRate, additionalProperties=$additionalProperties}" + "PercentConfig{percent=$percent, additionalProperties=$additionalProperties}" } /** @@ -17538,13 +20629,12 @@ private constructor( return true } - return other is GroupedWithMinMaxThresholds && + return other is Percent && cadence == other.cadence && - groupedWithMinMaxThresholdsConfig == - other.groupedWithMinMaxThresholdsConfig && itemId == other.itemId && modelType == other.modelType && name == other.name && + percentConfig == other.percentConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && @@ -17564,10 +20654,10 @@ private constructor( private val hashCode: Int by lazy { Objects.hash( cadence, - groupedWithMinMaxThresholdsConfig, itemId, modelType, name, + percentConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -17588,7 +20678,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "GroupedWithMinMaxThresholds{cadence=$cadence, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "Percent{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, percentConfig=$percentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } class EventOutput diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsParams.kt index 044c92d74..497f70369 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsParams.kt @@ -1634,6 +1634,9 @@ private constructor( /** Alias for calling [price] with `Price.ofMinimum(minimum)`. */ fun price(minimum: NewFloatingMinimumCompositePrice) = price(Price.ofMinimum(minimum)) + /** Alias for calling [price] with `Price.ofPercent(percent)`. */ + fun price(percent: Price.Percent) = price(Price.ofPercent(percent)) + /** Alias for calling [price] with `Price.ofEventOutput(eventOutput)`. */ fun price(eventOutput: Price.EventOutput) = price(Price.ofEventOutput(eventOutput)) @@ -3257,6 +3260,7 @@ private constructor( null, private val cumulativeGroupedBulk: NewFloatingCumulativeGroupedBulkPrice? = null, private val minimum: NewFloatingMinimumCompositePrice? = null, + private val percent: Percent? = null, private val eventOutput: EventOutput? = null, private val _json: JsonValue? = null, ) { @@ -3325,6 +3329,8 @@ private constructor( fun minimum(): NewFloatingMinimumCompositePrice? = minimum + fun percent(): Percent? = percent + fun eventOutput(): EventOutput? = eventOutput fun isUnit(): Boolean = unit != null @@ -3382,6 +3388,8 @@ private constructor( fun isMinimum(): Boolean = minimum != null + fun isPercent(): Boolean = percent != null + fun isEventOutput(): Boolean = eventOutput != null fun asUnit(): NewFloatingUnitPrice = unit.getOrThrow("unit") @@ -3460,6 +3468,8 @@ private constructor( fun asMinimum(): NewFloatingMinimumCompositePrice = minimum.getOrThrow("minimum") + fun asPercent(): Percent = percent.getOrThrow("percent") + fun asEventOutput(): EventOutput = eventOutput.getOrThrow("eventOutput") fun _json(): JsonValue? = _json @@ -3509,6 +3519,7 @@ private constructor( cumulativeGroupedBulk != null -> visitor.visitCumulativeGroupedBulk(cumulativeGroupedBulk) minimum != null -> visitor.visitMinimum(minimum) + percent != null -> visitor.visitPercent(percent) eventOutput != null -> visitor.visitEventOutput(eventOutput) else -> visitor.unknown(_json) } @@ -3674,6 +3685,10 @@ private constructor( minimum.validate() } + override fun visitPercent(percent: Percent) { + percent.validate() + } + override fun visitEventOutput(eventOutput: EventOutput) { eventOutput.validate() } @@ -3799,6 +3814,8 @@ private constructor( override fun visitMinimum(minimum: NewFloatingMinimumCompositePrice) = minimum.validity() + override fun visitPercent(percent: Percent) = percent.validity() + override fun visitEventOutput(eventOutput: EventOutput) = eventOutput.validity() @@ -3839,6 +3856,7 @@ private constructor( scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && cumulativeGroupedBulk == other.cumulativeGroupedBulk && minimum == other.minimum && + percent == other.percent && eventOutput == other.eventOutput } @@ -3871,6 +3889,7 @@ private constructor( scalableMatrixWithTieredPricing, cumulativeGroupedBulk, minimum, + percent, eventOutput, ) @@ -3916,6 +3935,7 @@ private constructor( cumulativeGroupedBulk != null -> "Price{cumulativeGroupedBulk=$cumulativeGroupedBulk}" minimum != null -> "Price{minimum=$minimum}" + percent != null -> "Price{percent=$percent}" eventOutput != null -> "Price{eventOutput=$eventOutput}" _json != null -> "Price{_unknown=$_json}" else -> throw IllegalStateException("Invalid Price") @@ -4012,6 +4032,8 @@ private constructor( fun ofMinimum(minimum: NewFloatingMinimumCompositePrice) = Price(minimum = minimum) + fun ofPercent(percent: Percent) = Price(percent = percent) + fun ofEventOutput(eventOutput: EventOutput) = Price(eventOutput = eventOutput) } @@ -4102,6 +4124,8 @@ private constructor( fun visitMinimum(minimum: NewFloatingMinimumCompositePrice): T + fun visitPercent(percent: Percent): T + fun visitEventOutput(eventOutput: EventOutput): T /** @@ -4323,6 +4347,11 @@ private constructor( ) ?.let { Price(minimum = it, _json = json) } ?: Price(_json = json) } + "percent" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(percent = it, _json = json) + } ?: Price(_json = json) + } "event_output" -> { return tryDeserialize(node, jacksonTypeRef())?.let { Price(eventOutput = it, _json = json) @@ -4388,6 +4417,7 @@ private constructor( value.cumulativeGroupedBulk != null -> generator.writeObject(value.cumulativeGroupedBulk) value.minimum != null -> generator.writeObject(value.minimum) + value.percent != null -> generator.writeObject(value.percent) value.eventOutput != null -> generator.writeObject(value.eventOutput) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid Price") @@ -6043,6 +6073,1471 @@ private constructor( "GroupedWithMinMaxThresholds{cadence=$cadence, currency=$currency, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" } + class Percent + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val currency: JsonField, + private val itemId: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val percentConfig: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val metadata: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("percent_config") + @ExcludeMissing + percentConfig: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + ) : this( + cadence, + currency, + itemId, + modelType, + name, + percentConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * An ISO 4217 currency string for which this price is billed in. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("percent") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * Configuration for percent pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun percentConfig(): PercentConfig = percentConfig.getRequired("percent_config") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = billableMetricId.getNullable("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + invoiceGroupingKey.getNullable("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [percentConfig]. + * + * Unlike [percentConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("percent_config") + @ExcludeMissing + fun _percentConfig(): JsonField = percentConfig + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Percent]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .currency() + * .itemId() + * .name() + * .percentConfig() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Percent]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var currency: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonValue = JsonValue.from("percent") + private var name: JsonField? = null + private var percentConfig: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(percent: Percent) = apply { + cadence = percent.cadence + currency = percent.currency + itemId = percent.itemId + modelType = percent.modelType + name = percent.name + percentConfig = percent.percentConfig + billableMetricId = percent.billableMetricId + billedInAdvance = percent.billedInAdvance + billingCycleConfiguration = percent.billingCycleConfiguration + conversionRate = percent.conversionRate + conversionRateConfig = percent.conversionRateConfig + dimensionalPriceConfiguration = percent.dimensionalPriceConfiguration + externalPriceId = percent.externalPriceId + fixedPriceQuantity = percent.fixedPriceQuantity + invoiceGroupingKey = percent.invoiceGroupingKey + invoicingCycleConfiguration = percent.invoicingCycleConfiguration + metadata = percent.metadata + additionalProperties = percent.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("percent") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for percent pricing */ + fun percentConfig(percentConfig: PercentConfig) = + percentConfig(JsonField.of(percentConfig)) + + /** + * Sets [Builder.percentConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.percentConfig] with a well-typed + * [PercentConfig] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun percentConfig(percentConfig: JsonField) = apply { + this.percentConfig = percentConfig + } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Percent]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .currency() + * .itemId() + * .name() + * .percentConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Percent = + Percent( + checkRequired("cadence", cadence), + checkRequired("currency", currency), + checkRequired("itemId", itemId), + modelType, + checkRequired("name", name), + checkRequired("percentConfig", percentConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Percent = apply { + if (validated) { + return@apply + } + + cadence().validate() + currency() + itemId() + _modelType().let { + if (it != JsonValue.from("percent")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + percentConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + metadata()?.validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (if (itemId.asKnown() == null) 0 else 1) + + modelType.let { if (it == JsonValue.from("percent")) 1 else 0 } + + (if (name.asKnown() == null) 0 else 1) + + (percentConfig.asKnown()?.validity() ?: 0) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (metadata.asKnown()?.validity() ?: 0) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Configuration for percent pricing */ + class PercentConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val percent: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("percent") + @ExcludeMissing + percent: JsonField = JsonMissing.of() + ) : this(percent, mutableMapOf()) + + /** + * What percent of the component subtotals to charge + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun percent(): Double = percent.getRequired("percent") + + /** + * Returns the raw JSON value of [percent]. + * + * Unlike [percent], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("percent") + @ExcludeMissing + fun _percent(): JsonField = percent + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [PercentConfig]. + * + * The following fields are required: + * ```kotlin + * .percent() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [PercentConfig]. */ + class Builder internal constructor() { + + private var percent: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(percentConfig: PercentConfig) = apply { + percent = percentConfig.percent + additionalProperties = percentConfig.additionalProperties.toMutableMap() + } + + /** What percent of the component subtotals to charge */ + fun percent(percent: Double) = percent(JsonField.of(percent)) + + /** + * Sets [Builder.percent] to an arbitrary JSON value. + * + * You should usually call [Builder.percent] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun percent(percent: JsonField) = apply { this.percent = percent } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [PercentConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .percent() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): PercentConfig = + PercentConfig( + checkRequired("percent", percent), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): PercentConfig = apply { + if (validated) { + return@apply + } + + percent() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = (if (percent.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PercentConfig && + percent == other.percent && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(percent, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "PercentConfig{percent=$percent, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Percent && + cadence == other.cadence && + currency == other.currency && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + percentConfig == other.percentConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + currency, + itemId, + modelType, + name, + percentConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Percent{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, percentConfig=$percentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + } + class EventOutput @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionSchedulePlanChangeParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionSchedulePlanChangeParams.kt index 38e8b5100..c13b19cd6 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionSchedulePlanChangeParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionSchedulePlanChangeParams.kt @@ -4356,6 +4356,9 @@ private constructor( fun price(minimum: NewSubscriptionMinimumCompositePrice) = price(Price.ofMinimum(minimum)) + /** Alias for calling [price] with `Price.ofPercent(percent)`. */ + fun price(percent: Price.Percent) = price(Price.ofPercent(percent)) + /** Alias for calling [price] with `Price.ofEventOutput(eventOutput)`. */ fun price(eventOutput: Price.EventOutput) = price(Price.ofEventOutput(eventOutput)) @@ -4515,6 +4518,7 @@ private constructor( null, private val cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice? = null, private val minimum: NewSubscriptionMinimumCompositePrice? = null, + private val percent: Percent? = null, private val eventOutput: EventOutput? = null, private val _json: JsonValue? = null, ) { @@ -4587,6 +4591,8 @@ private constructor( fun minimum(): NewSubscriptionMinimumCompositePrice? = minimum + fun percent(): Percent? = percent + fun eventOutput(): EventOutput? = eventOutput fun isUnit(): Boolean = unit != null @@ -4644,6 +4650,8 @@ private constructor( fun isMinimum(): Boolean = minimum != null + fun isPercent(): Boolean = percent != null + fun isEventOutput(): Boolean = eventOutput != null fun asUnit(): NewSubscriptionUnitPrice = unit.getOrThrow("unit") @@ -4723,6 +4731,8 @@ private constructor( fun asMinimum(): NewSubscriptionMinimumCompositePrice = minimum.getOrThrow("minimum") + fun asPercent(): Percent = percent.getOrThrow("percent") + fun asEventOutput(): EventOutput = eventOutput.getOrThrow("eventOutput") fun _json(): JsonValue? = _json @@ -4772,6 +4782,7 @@ private constructor( cumulativeGroupedBulk != null -> visitor.visitCumulativeGroupedBulk(cumulativeGroupedBulk) minimum != null -> visitor.visitMinimum(minimum) + percent != null -> visitor.visitPercent(percent) eventOutput != null -> visitor.visitEventOutput(eventOutput) else -> visitor.unknown(_json) } @@ -4938,6 +4949,10 @@ private constructor( minimum.validate() } + override fun visitPercent(percent: Percent) { + percent.validate() + } + override fun visitEventOutput(eventOutput: EventOutput) { eventOutput.validate() } @@ -5066,6 +5081,8 @@ private constructor( override fun visitMinimum(minimum: NewSubscriptionMinimumCompositePrice) = minimum.validity() + override fun visitPercent(percent: Percent) = percent.validity() + override fun visitEventOutput(eventOutput: EventOutput) = eventOutput.validity() @@ -5106,6 +5123,7 @@ private constructor( scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && cumulativeGroupedBulk == other.cumulativeGroupedBulk && minimum == other.minimum && + percent == other.percent && eventOutput == other.eventOutput } @@ -5138,6 +5156,7 @@ private constructor( scalableMatrixWithTieredPricing, cumulativeGroupedBulk, minimum, + percent, eventOutput, ) @@ -5183,6 +5202,7 @@ private constructor( cumulativeGroupedBulk != null -> "Price{cumulativeGroupedBulk=$cumulativeGroupedBulk}" minimum != null -> "Price{minimum=$minimum}" + percent != null -> "Price{percent=$percent}" eventOutput != null -> "Price{eventOutput=$eventOutput}" _json != null -> "Price{_unknown=$_json}" else -> throw IllegalStateException("Invalid Price") @@ -5280,6 +5300,8 @@ private constructor( fun ofMinimum(minimum: NewSubscriptionMinimumCompositePrice) = Price(minimum = minimum) + fun ofPercent(percent: Percent) = Price(percent = percent) + fun ofEventOutput(eventOutput: EventOutput) = Price(eventOutput = eventOutput) } @@ -5377,6 +5399,8 @@ private constructor( fun visitMinimum(minimum: NewSubscriptionMinimumCompositePrice): T + fun visitPercent(percent: Percent): T + fun visitEventOutput(eventOutput: EventOutput): T /** @@ -5606,6 +5630,11 @@ private constructor( ) ?.let { Price(minimum = it, _json = json) } ?: Price(_json = json) } + "percent" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(percent = it, _json = json) + } ?: Price(_json = json) + } "event_output" -> { return tryDeserialize(node, jacksonTypeRef())?.let { Price(eventOutput = it, _json = json) @@ -5671,6 +5700,7 @@ private constructor( value.cumulativeGroupedBulk != null -> generator.writeObject(value.cumulativeGroupedBulk) value.minimum != null -> generator.writeObject(value.minimum) + value.percent != null -> generator.writeObject(value.percent) value.eventOutput != null -> generator.writeObject(value.eventOutput) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid Price") @@ -9145,14 +9175,14 @@ private constructor( "GroupedWithMinMaxThresholds{cadence=$cadence, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class EventOutput + class Percent @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, - private val eventOutputConfig: JsonField, private val itemId: JsonField, private val modelType: JsonValue, private val name: JsonField, + private val percentConfig: JsonField, private val billableMetricId: JsonField, private val billedInAdvance: JsonField, private val billingCycleConfiguration: JsonField, @@ -9175,9 +9205,6 @@ private constructor( @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), - @JsonProperty("event_output_config") - @ExcludeMissing - eventOutputConfig: JsonField = JsonMissing.of(), @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), @@ -9187,6 +9214,9 @@ private constructor( @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("percent_config") + @ExcludeMissing + percentConfig: JsonField = JsonMissing.of(), @JsonProperty("billable_metric_id") @ExcludeMissing billableMetricId: JsonField = JsonMissing.of(), @@ -9231,10 +9261,10 @@ private constructor( referenceId: JsonField = JsonMissing.of(), ) : this( cadence, - eventOutputConfig, itemId, modelType, name, + percentConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -9260,16 +9290,6 @@ private constructor( */ fun cadence(): Cadence = cadence.getRequired("cadence") - /** - * Configuration for event_output pricing - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun eventOutputConfig(): EventOutputConfig = - eventOutputConfig.getRequired("event_output_config") - /** * The id of the item the price will be associated with. * @@ -9284,7 +9304,7 @@ private constructor( * * Expected to always return the following: * ```kotlin - * JsonValue.from("event_output") + * JsonValue.from("percent") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -9301,6 +9321,15 @@ private constructor( */ fun name(): String = name.getRequired("name") + /** + * Configuration for percent pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun percentConfig(): PercentConfig = percentConfig.getRequired("percent_config") + /** * The id of the billable metric for the price. Only needed if the price is * usage-based. @@ -9430,16 +9459,6 @@ private constructor( @ExcludeMissing fun _cadence(): JsonField = cadence - /** - * Returns the raw JSON value of [eventOutputConfig]. - * - * Unlike [eventOutputConfig], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("event_output_config") - @ExcludeMissing - fun _eventOutputConfig(): JsonField = eventOutputConfig - /** * Returns the raw JSON value of [itemId]. * @@ -9456,6 +9475,16 @@ private constructor( */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + /** + * Returns the raw JSON value of [percentConfig]. + * + * Unlike [percentConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("percent_config") + @ExcludeMissing + fun _percentConfig(): JsonField = percentConfig + /** * Returns the raw JSON value of [billableMetricId]. * @@ -9604,27 +9633,27 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [EventOutput]. + * Returns a mutable builder for constructing an instance of [Percent]. * * The following fields are required: * ```kotlin * .cadence() - * .eventOutputConfig() * .itemId() * .name() + * .percentConfig() * ``` */ fun builder() = Builder() } - /** A builder for [EventOutput]. */ + /** A builder for [Percent]. */ class Builder internal constructor() { private var cadence: JsonField? = null - private var eventOutputConfig: JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonValue = JsonValue.from("event_output") + private var modelType: JsonValue = JsonValue.from("percent") private var name: JsonField? = null + private var percentConfig: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() private var billingCycleConfiguration: JsonField = @@ -9646,26 +9675,26 @@ private constructor( private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(eventOutput: EventOutput) = apply { - cadence = eventOutput.cadence - eventOutputConfig = eventOutput.eventOutputConfig - itemId = eventOutput.itemId - modelType = eventOutput.modelType - name = eventOutput.name - billableMetricId = eventOutput.billableMetricId - billedInAdvance = eventOutput.billedInAdvance - billingCycleConfiguration = eventOutput.billingCycleConfiguration - conversionRate = eventOutput.conversionRate - conversionRateConfig = eventOutput.conversionRateConfig - currency = eventOutput.currency - dimensionalPriceConfiguration = eventOutput.dimensionalPriceConfiguration - externalPriceId = eventOutput.externalPriceId - fixedPriceQuantity = eventOutput.fixedPriceQuantity - invoiceGroupingKey = eventOutput.invoiceGroupingKey - invoicingCycleConfiguration = eventOutput.invoicingCycleConfiguration - metadata = eventOutput.metadata - referenceId = eventOutput.referenceId - additionalProperties = eventOutput.additionalProperties.toMutableMap() + internal fun from(percent: Percent) = apply { + cadence = percent.cadence + itemId = percent.itemId + modelType = percent.modelType + name = percent.name + percentConfig = percent.percentConfig + billableMetricId = percent.billableMetricId + billedInAdvance = percent.billedInAdvance + billingCycleConfiguration = percent.billingCycleConfiguration + conversionRate = percent.conversionRate + conversionRateConfig = percent.conversionRateConfig + currency = percent.currency + dimensionalPriceConfiguration = percent.dimensionalPriceConfiguration + externalPriceId = percent.externalPriceId + fixedPriceQuantity = percent.fixedPriceQuantity + invoiceGroupingKey = percent.invoiceGroupingKey + invoicingCycleConfiguration = percent.invoicingCycleConfiguration + metadata = percent.metadata + referenceId = percent.referenceId + additionalProperties = percent.additionalProperties.toMutableMap() } /** The cadence to bill for this price on. */ @@ -9680,21 +9709,6 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - /** Configuration for event_output pricing */ - fun eventOutputConfig(eventOutputConfig: EventOutputConfig) = - eventOutputConfig(JsonField.of(eventOutputConfig)) - - /** - * Sets [Builder.eventOutputConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.eventOutputConfig] with a well-typed - * [EventOutputConfig] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun eventOutputConfig(eventOutputConfig: JsonField) = apply { - this.eventOutputConfig = eventOutputConfig - } - /** The id of the item the price will be associated with. */ fun itemId(itemId: String) = itemId(JsonField.of(itemId)) @@ -9713,7 +9727,7 @@ private constructor( * It is usually unnecessary to call this method because the field defaults to * the following: * ```kotlin - * JsonValue.from("event_output") + * JsonValue.from("percent") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -9733,6 +9747,21 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } + /** Configuration for percent pricing */ + fun percentConfig(percentConfig: PercentConfig) = + percentConfig(JsonField.of(percentConfig)) + + /** + * Sets [Builder.percentConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.percentConfig] with a well-typed + * [PercentConfig] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun percentConfig(percentConfig: JsonField) = apply { + this.percentConfig = percentConfig + } + /** * The id of the billable metric for the price. Only needed if the price is * usage-based. @@ -10062,27 +10091,27 @@ private constructor( } /** - * Returns an immutable instance of [EventOutput]. + * Returns an immutable instance of [Percent]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```kotlin * .cadence() - * .eventOutputConfig() * .itemId() * .name() + * .percentConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): EventOutput = - EventOutput( + fun build(): Percent = + Percent( checkRequired("cadence", cadence), - checkRequired("eventOutputConfig", eventOutputConfig), checkRequired("itemId", itemId), modelType, checkRequired("name", name), + checkRequired("percentConfig", percentConfig), billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -10102,20 +10131,20 @@ private constructor( private var validated: Boolean = false - fun validate(): EventOutput = apply { + fun validate(): Percent = apply { if (validated) { return@apply } cadence().validate() - eventOutputConfig().validate() itemId() _modelType().let { - if (it != JsonValue.from("event_output")) { + if (it != JsonValue.from("percent")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } name() + percentConfig().validate() billableMetricId() billedInAdvance() billingCycleConfiguration()?.validate() @@ -10148,10 +10177,10 @@ private constructor( */ internal fun validity(): Int = (cadence.asKnown()?.validity() ?: 0) + - (eventOutputConfig.asKnown()?.validity() ?: 0) + (if (itemId.asKnown() == null) 0 else 1) + - modelType.let { if (it == JsonValue.from("event_output")) 1 else 0 } + + modelType.let { if (it == JsonValue.from("percent")) 1 else 0 } + (if (name.asKnown() == null) 0 else 1) + + (percentConfig.asKnown()?.validity() ?: 0) + (if (billableMetricId.asKnown() == null) 0 else 1) + (if (billedInAdvance.asKnown() == null) 0 else 1) + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + @@ -10323,62 +10352,39 @@ private constructor( override fun toString() = value.toString() } - /** Configuration for event_output pricing */ - class EventOutputConfig + /** Configuration for percent pricing */ + class PercentConfig @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val unitRatingKey: JsonField, - private val groupingKey: JsonField, + private val percent: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("unit_rating_key") - @ExcludeMissing - unitRatingKey: JsonField = JsonMissing.of(), - @JsonProperty("grouping_key") + @JsonProperty("percent") @ExcludeMissing - groupingKey: JsonField = JsonMissing.of(), - ) : this(unitRatingKey, groupingKey, mutableMapOf()) + percent: JsonField = JsonMissing.of() + ) : this(percent, mutableMapOf()) /** - * The key in the event data to extract the unit rate from. + * What percent of the component subtotals to charge * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). */ - fun unitRatingKey(): String = unitRatingKey.getRequired("unit_rating_key") - - /** - * An optional key in the event data to group by (e.g., event ID). All events - * will also be grouped by their unit rate. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun groupingKey(): String? = groupingKey.getNullable("grouping_key") - - /** - * Returns the raw JSON value of [unitRatingKey]. - * - * Unlike [unitRatingKey], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("unit_rating_key") - @ExcludeMissing - fun _unitRatingKey(): JsonField = unitRatingKey + fun percent(): Double = percent.getRequired("percent") /** - * Returns the raw JSON value of [groupingKey]. + * Returns the raw JSON value of [percent]. * - * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * Unlike [percent], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("grouping_key") + @JsonProperty("percent") @ExcludeMissing - fun _groupingKey(): JsonField = groupingKey + fun _percent(): JsonField = percent @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -10396,63 +10402,39 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [EventOutputConfig]. + * [PercentConfig]. * * The following fields are required: * ```kotlin - * .unitRatingKey() + * .percent() * ``` */ fun builder() = Builder() } - /** A builder for [EventOutputConfig]. */ + /** A builder for [PercentConfig]. */ class Builder internal constructor() { - private var unitRatingKey: JsonField? = null - private var groupingKey: JsonField = JsonMissing.of() + private var percent: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(eventOutputConfig: EventOutputConfig) = apply { - unitRatingKey = eventOutputConfig.unitRatingKey - groupingKey = eventOutputConfig.groupingKey - additionalProperties = - eventOutputConfig.additionalProperties.toMutableMap() - } - - /** The key in the event data to extract the unit rate from. */ - fun unitRatingKey(unitRatingKey: String) = - unitRatingKey(JsonField.of(unitRatingKey)) - - /** - * Sets [Builder.unitRatingKey] to an arbitrary JSON value. - * - * You should usually call [Builder.unitRatingKey] with a well-typed - * [String] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun unitRatingKey(unitRatingKey: JsonField) = apply { - this.unitRatingKey = unitRatingKey + internal fun from(percentConfig: PercentConfig) = apply { + percent = percentConfig.percent + additionalProperties = percentConfig.additionalProperties.toMutableMap() } - /** - * An optional key in the event data to group by (e.g., event ID). All - * events will also be grouped by their unit rate. - */ - fun groupingKey(groupingKey: String?) = - groupingKey(JsonField.ofNullable(groupingKey)) + /** What percent of the component subtotals to charge */ + fun percent(percent: Double) = percent(JsonField.of(percent)) /** - * Sets [Builder.groupingKey] to an arbitrary JSON value. + * Sets [Builder.percent] to an arbitrary JSON value. * - * You should usually call [Builder.groupingKey] with a well-typed [String] + * You should usually call [Builder.percent] with a well-typed [Double] * value instead. This method is primarily for setting the field to an * undocumented or not yet supported value. */ - fun groupingKey(groupingKey: JsonField) = apply { - this.groupingKey = groupingKey - } + fun percent(percent: JsonField) = apply { this.percent = percent } fun additionalProperties(additionalProperties: Map) = apply { @@ -10477,34 +10459,32 @@ private constructor( } /** - * Returns an immutable instance of [EventOutputConfig]. + * Returns an immutable instance of [PercentConfig]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```kotlin - * .unitRatingKey() + * .percent() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): EventOutputConfig = - EventOutputConfig( - checkRequired("unitRatingKey", unitRatingKey), - groupingKey, + fun build(): PercentConfig = + PercentConfig( + checkRequired("percent", percent), additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): EventOutputConfig = apply { + fun validate(): PercentConfig = apply { if (validated) { return@apply } - unitRatingKey() - groupingKey() + percent() validated = true } @@ -10522,29 +10502,26 @@ private constructor( * * Used for best match union deserialization. */ - internal fun validity(): Int = - (if (unitRatingKey.asKnown() == null) 0 else 1) + - (if (groupingKey.asKnown() == null) 0 else 1) + internal fun validity(): Int = (if (percent.asKnown() == null) 0 else 1) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is EventOutputConfig && - unitRatingKey == other.unitRatingKey && - groupingKey == other.groupingKey && + return other is PercentConfig && + percent == other.percent && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(unitRatingKey, groupingKey, additionalProperties) + Objects.hash(percent, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "EventOutputConfig{unitRatingKey=$unitRatingKey, groupingKey=$groupingKey, additionalProperties=$additionalProperties}" + "PercentConfig{percent=$percent, additionalProperties=$additionalProperties}" } /** @@ -10661,12 +10638,12 @@ private constructor( return true } - return other is EventOutput && + return other is Percent && cadence == other.cadence && - eventOutputConfig == other.eventOutputConfig && itemId == other.itemId && modelType == other.modelType && name == other.name && + percentConfig == other.percentConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && @@ -10686,10 +10663,10 @@ private constructor( private val hashCode: Int by lazy { Objects.hash( cadence, - eventOutputConfig, itemId, modelType, name, + percentConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -10710,1083 +10687,1575 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "EventOutput{cadence=$cadence, eventOutputConfig=$eventOutputConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + "Percent{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, percentConfig=$percentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - return other is AddPrice && - allocationPrice == other.allocationPrice && - discounts == other.discounts && - endDate == other.endDate && - externalPriceId == other.externalPriceId && - maximumAmount == other.maximumAmount && - minimumAmount == other.minimumAmount && - planPhaseOrder == other.planPhaseOrder && - price == other.price && - priceId == other.priceId && - startDate == other.startDate && - additionalProperties == other.additionalProperties - } + class EventOutput + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val eventOutputConfig: JsonField, + private val itemId: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { - private val hashCode: Int by lazy { - Objects.hash( - allocationPrice, - discounts, - endDate, - externalPriceId, - maximumAmount, - minimumAmount, - planPhaseOrder, - price, - priceId, - startDate, - additionalProperties, - ) - } + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("event_output_config") + @ExcludeMissing + eventOutputConfig: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + eventOutputConfig, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + mutableMapOf(), + ) - override fun hashCode(): Int = hashCode + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") - override fun toString() = - "AddPrice{allocationPrice=$allocationPrice, discounts=$discounts, endDate=$endDate, externalPriceId=$externalPriceId, maximumAmount=$maximumAmount, minimumAmount=$minimumAmount, planPhaseOrder=$planPhaseOrder, price=$price, priceId=$priceId, startDate=$startDate, additionalProperties=$additionalProperties}" - } + /** + * Configuration for event_output pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun eventOutputConfig(): EventOutputConfig = + eventOutputConfig.getRequired("event_output_config") - /** - * Reset billing periods to be aligned with the plan change's effective date or start of the - * month. Defaults to `unchanged` which keeps subscription's existing billing cycle alignment. - */ - class BillingCycleAlignment - @JsonCreator - private constructor(private val value: JsonField) : Enum { + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API may respond with new members that the SDK is - * unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("event_output") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType - companion object { + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") - val UNCHANGED = of("unchanged") + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = billableMetricId.getNullable("billable_metric_id") - val PLAN_CHANGE_DATE = of("plan_change_date") + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") - val START_OF_MONTH = of("start_of_month") + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") - fun of(value: String) = BillingCycleAlignment(JsonField.of(value)) - } + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") - /** An enum containing [BillingCycleAlignment]'s known values. */ - enum class Known { - UNCHANGED, - PLAN_CHANGE_DATE, - START_OF_MONTH, - } + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") - /** - * An enum containing [BillingCycleAlignment]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [BillingCycleAlignment] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if the - * SDK is on an older version than the API, then the API may respond with new members that - * the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - UNCHANGED, - PLAN_CHANGE_DATE, - START_OF_MONTH, - /** - * An enum member indicating that [BillingCycleAlignment] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") - /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you want - * to throw for the unknown case. - */ - fun value(): Value = - when (this) { - UNCHANGED -> Value.UNCHANGED - PLAN_CHANGE_DATE -> Value.PLAN_CHANGE_DATE - START_OF_MONTH -> Value.START_OF_MONTH - else -> Value._UNKNOWN - } + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and don't - * want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known member. - */ - fun known(): Known = - when (this) { - UNCHANGED -> Known.UNCHANGED - PLAN_CHANGE_DATE -> Known.PLAN_CHANGE_DATE - START_OF_MONTH -> Known.START_OF_MONTH - else -> throw OrbInvalidDataException("Unknown BillingCycleAlignment: $value") - } + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the expected - * primitive type. - */ - fun asString(): String = - _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") - private var validated: Boolean = false + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + invoiceGroupingKey.getNullable("invoice_grouping_key") - fun validate(): BillingCycleAlignment = apply { - if (validated) { - return@apply - } + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - known() - validated = true - } + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * Returns the raw JSON value of [eventOutputConfig]. + * + * Unlike [eventOutputConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("event_output_config") + @ExcludeMissing + fun _eventOutputConfig(): JsonField = eventOutputConfig - return other is BillingCycleAlignment && value == other.value - } + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - override fun hashCode() = value.hashCode() + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - override fun toString() = value.toString() - } + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId - class RemoveAdjustment - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val adjustmentId: JsonField, - private val additionalProperties: MutableMap, - ) { + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance - @JsonCreator - private constructor( - @JsonProperty("adjustment_id") - @ExcludeMissing - adjustmentId: JsonField = JsonMissing.of() - ) : this(adjustmentId, mutableMapOf()) + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration - /** - * The id of the adjustment to remove on the subscription. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun adjustmentId(): String = adjustmentId.getRequired("adjustment_id") + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate - /** - * Returns the raw JSON value of [adjustmentId]. - * - * Unlike [adjustmentId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("adjustment_id") - @ExcludeMissing - fun _adjustmentId(): JsonField = adjustmentId + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration - fun toBuilder() = Builder().from(this) + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId - companion object { + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - /** - * Returns a mutable builder for constructing an instance of [RemoveAdjustment]. - * - * The following fields are required: - * ```kotlin - * .adjustmentId() - * ``` - */ - fun builder() = Builder() - } + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - /** A builder for [RemoveAdjustment]. */ - class Builder internal constructor() { + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration - private var adjustmentId: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata - internal fun from(removeAdjustment: RemoveAdjustment) = apply { - adjustmentId = removeAdjustment.adjustmentId - additionalProperties = removeAdjustment.additionalProperties.toMutableMap() - } + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId - /** The id of the adjustment to remove on the subscription. */ - fun adjustmentId(adjustmentId: String) = adjustmentId(JsonField.of(adjustmentId)) + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - /** - * Sets [Builder.adjustmentId] to an arbitrary JSON value. - * - * You should usually call [Builder.adjustmentId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun adjustmentId(adjustmentId: JsonField) = apply { - this.adjustmentId = adjustmentId - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun toBuilder() = Builder().from(this) - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + companion object { - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + /** + * Returns a mutable builder for constructing an instance of [EventOutput]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .eventOutputConfig() + * .itemId() + * .name() + * ``` + */ + fun builder() = Builder() + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + /** A builder for [EventOutput]. */ + class Builder internal constructor() { - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + private var cadence: JsonField? = null + private var eventOutputConfig: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonValue = JsonValue.from("event_output") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - /** - * Returns an immutable instance of [RemoveAdjustment]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```kotlin - * .adjustmentId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): RemoveAdjustment = - RemoveAdjustment( - checkRequired("adjustmentId", adjustmentId), - additionalProperties.toMutableMap(), - ) - } + internal fun from(eventOutput: EventOutput) = apply { + cadence = eventOutput.cadence + eventOutputConfig = eventOutput.eventOutputConfig + itemId = eventOutput.itemId + modelType = eventOutput.modelType + name = eventOutput.name + billableMetricId = eventOutput.billableMetricId + billedInAdvance = eventOutput.billedInAdvance + billingCycleConfiguration = eventOutput.billingCycleConfiguration + conversionRate = eventOutput.conversionRate + conversionRateConfig = eventOutput.conversionRateConfig + currency = eventOutput.currency + dimensionalPriceConfiguration = eventOutput.dimensionalPriceConfiguration + externalPriceId = eventOutput.externalPriceId + fixedPriceQuantity = eventOutput.fixedPriceQuantity + invoiceGroupingKey = eventOutput.invoiceGroupingKey + invoicingCycleConfiguration = eventOutput.invoicingCycleConfiguration + metadata = eventOutput.metadata + referenceId = eventOutput.referenceId + additionalProperties = eventOutput.additionalProperties.toMutableMap() + } - private var validated: Boolean = false + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - fun validate(): RemoveAdjustment = apply { - if (validated) { - return@apply - } + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - adjustmentId() - validated = true - } + /** Configuration for event_output pricing */ + fun eventOutputConfig(eventOutputConfig: EventOutputConfig) = + eventOutputConfig(JsonField.of(eventOutputConfig)) - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** + * Sets [Builder.eventOutputConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.eventOutputConfig] with a well-typed + * [EventOutputConfig] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun eventOutputConfig(eventOutputConfig: JsonField) = apply { + this.eventOutputConfig = eventOutputConfig + } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = (if (adjustmentId.asKnown() == null) 0 else 1) + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - return other is RemoveAdjustment && - adjustmentId == other.adjustmentId && - additionalProperties == other.additionalProperties - } + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("event_output") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } - private val hashCode: Int by lazy { Objects.hash(adjustmentId, additionalProperties) } + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) - override fun hashCode(): Int = hashCode + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } - override fun toString() = - "RemoveAdjustment{adjustmentId=$adjustmentId, additionalProperties=$additionalProperties}" - } + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) - class RemovePrice - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val externalPriceId: JsonField, - private val priceId: JsonField, - private val additionalProperties: MutableMap, - ) { + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } - @JsonCreator - private constructor( - @JsonProperty("external_price_id") - @ExcludeMissing - externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("price_id") @ExcludeMissing priceId: JsonField = JsonMissing.of(), - ) : this(externalPriceId, priceId, mutableMapOf()) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) - /** - * The external price id of the price to remove on the subscription. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) - /** - * The id of the price to remove on the subscription. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun priceId(): String? = priceId.getNullable("price_id") + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } - /** - * Returns the raw JSON value of [externalPriceId]. - * - * Unlike [externalPriceId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - /** - * Returns the raw JSON value of [priceId]. - * - * Unlike [priceId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) - fun toBuilder() = Builder().from(this) + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } - companion object { + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) - /** Returns a mutable builder for constructing an instance of [RemovePrice]. */ - fun builder() = Builder() - } + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } - /** A builder for [RemovePrice]. */ - class Builder internal constructor() { + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) - private var externalPriceId: JsonField = JsonMissing.of() - private var priceId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) - internal fun from(removePrice: RemovePrice) = apply { - externalPriceId = removePrice.externalPriceId - priceId = removePrice.priceId - additionalProperties = removePrice.additionalProperties.toMutableMap() - } + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) - /** The external price id of the price to remove on the subscription. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) - /** - * Sets [Builder.externalPriceId] to an arbitrary JSON value. - * - * You should usually call [Builder.externalPriceId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun externalPriceId(externalPriceId: JsonField) = apply { - this.externalPriceId = externalPriceId - } + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) - /** The id of the price to remove on the subscription. */ - fun priceId(priceId: String?) = priceId(JsonField.ofNullable(priceId)) + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } - /** - * Sets [Builder.priceId] to an arbitrary JSON value. - * - * You should usually call [Builder.priceId] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun priceId(priceId: JsonField) = apply { this.priceId = priceId } + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [RemovePrice]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): RemovePrice = - RemovePrice(externalPriceId, priceId, additionalProperties.toMutableMap()) - } - - private var validated: Boolean = false - - fun validate(): RemovePrice = apply { - if (validated) { - return@apply - } + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } - externalPriceId() - priceId() - validated = true - } + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (if (externalPriceId.asKnown() == null) 0 else 1) + - (if (priceId.asKnown() == null) 0 else 1) + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) - return other is RemovePrice && - externalPriceId == other.externalPriceId && - priceId == other.priceId && - additionalProperties == other.additionalProperties - } + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } - private val hashCode: Int by lazy { - Objects.hash(externalPriceId, priceId, additionalProperties) - } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) - override fun hashCode(): Int = hashCode + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } - override fun toString() = - "RemovePrice{externalPriceId=$externalPriceId, priceId=$priceId, additionalProperties=$additionalProperties}" - } + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) - class ReplaceAdjustment - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val adjustment: JsonField, - private val replacesAdjustmentId: JsonField, - private val additionalProperties: MutableMap, - ) { + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - @JsonCreator - private constructor( - @JsonProperty("adjustment") - @ExcludeMissing - adjustment: JsonField = JsonMissing.of(), - @JsonProperty("replaces_adjustment_id") - @ExcludeMissing - replacesAdjustmentId: JsonField = JsonMissing.of(), - ) : this(adjustment, replacesAdjustmentId, mutableMapOf()) + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - /** - * The definition of a new adjustment to create and add to the subscription. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun adjustment(): Adjustment = adjustment.getRequired("adjustment") + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - /** - * The id of the adjustment on the plan to replace in the subscription. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun replacesAdjustmentId(): String = - replacesAdjustmentId.getRequired("replaces_adjustment_id") + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) - /** - * Returns the raw JSON value of [adjustment]. - * - * Unlike [adjustment], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("adjustment") - @ExcludeMissing - fun _adjustment(): JsonField = adjustment + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } - /** - * Returns the raw JSON value of [replacesAdjustmentId]. - * - * Unlike [replacesAdjustmentId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("replaces_adjustment_id") - @ExcludeMissing - fun _replacesAdjustmentId(): JsonField = replacesAdjustmentId + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun toBuilder() = Builder().from(this) + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - companion object { + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - /** - * Returns a mutable builder for constructing an instance of [ReplaceAdjustment]. - * - * The following fields are required: - * ```kotlin - * .adjustment() - * .replacesAdjustmentId() - * ``` - */ - fun builder() = Builder() - } - - /** A builder for [ReplaceAdjustment]. */ - class Builder internal constructor() { - - private var adjustment: JsonField? = null - private var replacesAdjustmentId: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() + /** + * Returns an immutable instance of [EventOutput]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .eventOutputConfig() + * .itemId() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): EventOutput = + EventOutput( + checkRequired("cadence", cadence), + checkRequired("eventOutputConfig", eventOutputConfig), + checkRequired("itemId", itemId), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } - internal fun from(replaceAdjustment: ReplaceAdjustment) = apply { - adjustment = replaceAdjustment.adjustment - replacesAdjustmentId = replaceAdjustment.replacesAdjustmentId - additionalProperties = replaceAdjustment.additionalProperties.toMutableMap() - } + private var validated: Boolean = false - /** The definition of a new adjustment to create and add to the subscription. */ - fun adjustment(adjustment: Adjustment) = adjustment(JsonField.of(adjustment)) + fun validate(): EventOutput = apply { + if (validated) { + return@apply + } - /** - * Sets [Builder.adjustment] to an arbitrary JSON value. - * - * You should usually call [Builder.adjustment] with a well-typed [Adjustment] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun adjustment(adjustment: JsonField) = apply { - this.adjustment = adjustment - } + cadence().validate() + eventOutputConfig().validate() + itemId() + _modelType().let { + if (it != JsonValue.from("event_output")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + metadata()?.validate() + referenceId() + validated = true + } - /** - * Alias for calling [adjustment] with - * `Adjustment.ofPercentageDiscount(percentageDiscount)`. - */ - fun adjustment(percentageDiscount: NewPercentageDiscount) = - adjustment(Adjustment.ofPercentageDiscount(percentageDiscount)) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - /** - * Alias for calling [adjustment] with the following: - * ```kotlin - * NewPercentageDiscount.builder() - * .adjustmentType(NewPercentageDiscount.AdjustmentType.PERCENTAGE_DISCOUNT) - * .percentageDiscount(percentageDiscount) - * .build() - * ``` - */ - fun percentageDiscountAdjustment(percentageDiscount: Double) = - adjustment( - NewPercentageDiscount.builder() - .adjustmentType(NewPercentageDiscount.AdjustmentType.PERCENTAGE_DISCOUNT) - .percentageDiscount(percentageDiscount) - .build() - ) + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (eventOutputConfig.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + modelType.let { if (it == JsonValue.from("event_output")) 1 else 0 } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) - /** Alias for calling [adjustment] with `Adjustment.ofUsageDiscount(usageDiscount)`. */ - fun adjustment(usageDiscount: NewUsageDiscount) = - adjustment(Adjustment.ofUsageDiscount(usageDiscount)) + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { - /** - * Alias for calling [adjustment] with the following: - * ```kotlin - * NewUsageDiscount.builder() - * .adjustmentType(NewUsageDiscount.AdjustmentType.USAGE_DISCOUNT) - * .usageDiscount(usageDiscount) - * .build() - * ``` - */ - fun usageDiscountAdjustment(usageDiscount: Double) = - adjustment( - NewUsageDiscount.builder() - .adjustmentType(NewUsageDiscount.AdjustmentType.USAGE_DISCOUNT) - .usageDiscount(usageDiscount) - .build() - ) + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value - /** - * Alias for calling [adjustment] with `Adjustment.ofAmountDiscount(amountDiscount)`. - */ - fun adjustment(amountDiscount: NewAmountDiscount) = - adjustment(Adjustment.ofAmountDiscount(amountDiscount)) + companion object { - /** - * Alias for calling [adjustment] with the following: - * ```kotlin - * NewAmountDiscount.builder() - * .adjustmentType(NewAmountDiscount.AdjustmentType.AMOUNT_DISCOUNT) - * .amountDiscount(amountDiscount) - * .build() - * ``` - */ - fun amountDiscountAdjustment(amountDiscount: String) = - adjustment( - NewAmountDiscount.builder() - .adjustmentType(NewAmountDiscount.AdjustmentType.AMOUNT_DISCOUNT) - .amountDiscount(amountDiscount) - .build() - ) + val ANNUAL = of("annual") - /** Alias for calling [adjustment] with `Adjustment.ofMinimum(minimum)`. */ - fun adjustment(minimum: NewMinimum) = adjustment(Adjustment.ofMinimum(minimum)) + val SEMI_ANNUAL = of("semi_annual") - /** Alias for calling [adjustment] with `Adjustment.ofMaximum(maximum)`. */ - fun adjustment(maximum: NewMaximum) = adjustment(Adjustment.ofMaximum(maximum)) + val MONTHLY = of("monthly") - /** - * Alias for calling [adjustment] with the following: - * ```kotlin - * NewMaximum.builder() - * .adjustmentType(NewMaximum.AdjustmentType.MAXIMUM) - * .maximumAmount(maximumAmount) - * .build() - * ``` - */ - fun maximumAdjustment(maximumAmount: String) = - adjustment( - NewMaximum.builder() - .adjustmentType(NewMaximum.AdjustmentType.MAXIMUM) - .maximumAmount(maximumAmount) - .build() - ) + val QUARTERLY = of("quarterly") - /** The id of the adjustment on the plan to replace in the subscription. */ - fun replacesAdjustmentId(replacesAdjustmentId: String) = - replacesAdjustmentId(JsonField.of(replacesAdjustmentId)) + val ONE_TIME = of("one_time") - /** - * Sets [Builder.replacesAdjustmentId] to an arbitrary JSON value. - * - * You should usually call [Builder.replacesAdjustmentId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun replacesAdjustmentId(replacesAdjustmentId: JsonField) = apply { - this.replacesAdjustmentId = replacesAdjustmentId - } + val CUSTOM = of("custom") - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun of(value: String) = Cadence(JsonField.of(value)) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } - /** - * Returns an immutable instance of [ReplaceAdjustment]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```kotlin - * .adjustment() - * .replacesAdjustmentId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): ReplaceAdjustment = - ReplaceAdjustment( - checkRequired("adjustment", adjustment), - checkRequired("replacesAdjustmentId", replacesAdjustmentId), - additionalProperties.toMutableMap(), - ) - } + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } - private var validated: Boolean = false + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } - fun validate(): ReplaceAdjustment = apply { - if (validated) { - return@apply - } + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } - adjustment().validate() - replacesAdjustmentId() - validated = true - } + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + private var validated: Boolean = false - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (adjustment.asKnown()?.validity() ?: 0) + - (if (replacesAdjustmentId.asKnown() == null) 0 else 1) + fun validate(): Cadence = apply { + if (validated) { + return@apply + } - /** The definition of a new adjustment to create and add to the subscription. */ - @JsonDeserialize(using = Adjustment.Deserializer::class) - @JsonSerialize(using = Adjustment.Serializer::class) - class Adjustment - private constructor( - private val percentageDiscount: NewPercentageDiscount? = null, - private val usageDiscount: NewUsageDiscount? = null, - private val amountDiscount: NewAmountDiscount? = null, - private val minimum: NewMinimum? = null, - private val maximum: NewMaximum? = null, - private val _json: JsonValue? = null, - ) { + known() + validated = true + } - fun percentageDiscount(): NewPercentageDiscount? = percentageDiscount + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - fun usageDiscount(): NewUsageDiscount? = usageDiscount + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - fun amountDiscount(): NewAmountDiscount? = amountDiscount + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun minimum(): NewMinimum? = minimum + return other is Cadence && value == other.value + } - fun maximum(): NewMaximum? = maximum + override fun hashCode() = value.hashCode() - fun isPercentageDiscount(): Boolean = percentageDiscount != null + override fun toString() = value.toString() + } - fun isUsageDiscount(): Boolean = usageDiscount != null + /** Configuration for event_output pricing */ + class EventOutputConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val unitRatingKey: JsonField, + private val groupingKey: JsonField, + private val additionalProperties: MutableMap, + ) { - fun isAmountDiscount(): Boolean = amountDiscount != null + @JsonCreator + private constructor( + @JsonProperty("unit_rating_key") + @ExcludeMissing + unitRatingKey: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + ) : this(unitRatingKey, groupingKey, mutableMapOf()) - fun isMinimum(): Boolean = minimum != null + /** + * The key in the event data to extract the unit rate from. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun unitRatingKey(): String = unitRatingKey.getRequired("unit_rating_key") - fun isMaximum(): Boolean = maximum != null + /** + * An optional key in the event data to group by (e.g., event ID). All events + * will also be grouped by their unit rate. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun groupingKey(): String? = groupingKey.getNullable("grouping_key") - fun asPercentageDiscount(): NewPercentageDiscount = - percentageDiscount.getOrThrow("percentageDiscount") + /** + * Returns the raw JSON value of [unitRatingKey]. + * + * Unlike [unitRatingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_rating_key") + @ExcludeMissing + fun _unitRatingKey(): JsonField = unitRatingKey - fun asUsageDiscount(): NewUsageDiscount = usageDiscount.getOrThrow("usageDiscount") + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey - fun asAmountDiscount(): NewAmountDiscount = amountDiscount.getOrThrow("amountDiscount") + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - fun asMinimum(): NewMinimum = minimum.getOrThrow("minimum") + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - fun asMaximum(): NewMaximum = maximum.getOrThrow("maximum") + fun toBuilder() = Builder().from(this) - fun _json(): JsonValue? = _json + companion object { - fun accept(visitor: Visitor): T = - when { - percentageDiscount != null -> - visitor.visitPercentageDiscount(percentageDiscount) - usageDiscount != null -> visitor.visitUsageDiscount(usageDiscount) - amountDiscount != null -> visitor.visitAmountDiscount(amountDiscount) - minimum != null -> visitor.visitMinimum(minimum) - maximum != null -> visitor.visitMaximum(maximum) - else -> visitor.unknown(_json) - } + /** + * Returns a mutable builder for constructing an instance of + * [EventOutputConfig]. + * + * The following fields are required: + * ```kotlin + * .unitRatingKey() + * ``` + */ + fun builder() = Builder() + } - private var validated: Boolean = false + /** A builder for [EventOutputConfig]. */ + class Builder internal constructor() { - fun validate(): Adjustment = apply { - if (validated) { - return@apply - } + private var unitRatingKey: JsonField? = null + private var groupingKey: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() - accept( - object : Visitor { - override fun visitPercentageDiscount( - percentageDiscount: NewPercentageDiscount - ) { - percentageDiscount.validate() + internal fun from(eventOutputConfig: EventOutputConfig) = apply { + unitRatingKey = eventOutputConfig.unitRatingKey + groupingKey = eventOutputConfig.groupingKey + additionalProperties = + eventOutputConfig.additionalProperties.toMutableMap() } - override fun visitUsageDiscount(usageDiscount: NewUsageDiscount) { - usageDiscount.validate() - } + /** The key in the event data to extract the unit rate from. */ + fun unitRatingKey(unitRatingKey: String) = + unitRatingKey(JsonField.of(unitRatingKey)) - override fun visitAmountDiscount(amountDiscount: NewAmountDiscount) { - amountDiscount.validate() + /** + * Sets [Builder.unitRatingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.unitRatingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun unitRatingKey(unitRatingKey: JsonField) = apply { + this.unitRatingKey = unitRatingKey } - override fun visitMinimum(minimum: NewMinimum) { - minimum.validate() + /** + * An optional key in the event data to group by (e.g., event ID). All + * events will also be grouped by their unit rate. + */ + fun groupingKey(groupingKey: String?) = + groupingKey(JsonField.ofNullable(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey } - override fun visitMaximum(maximum: NewMaximum) { - maximum.validate() + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) } - } - ) - validated = true - } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitPercentageDiscount( - percentageDiscount: NewPercentageDiscount - ) = percentageDiscount.validity() + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - override fun visitUsageDiscount(usageDiscount: NewUsageDiscount) = - usageDiscount.validity() + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - override fun visitAmountDiscount(amountDiscount: NewAmountDiscount) = - amountDiscount.validity() + /** + * Returns an immutable instance of [EventOutputConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .unitRatingKey() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): EventOutputConfig = + EventOutputConfig( + checkRequired("unitRatingKey", unitRatingKey), + groupingKey, + additionalProperties.toMutableMap(), + ) + } - override fun visitMinimum(minimum: NewMinimum) = minimum.validity() + private var validated: Boolean = false - override fun visitMaximum(maximum: NewMaximum) = maximum.validity() + fun validate(): EventOutputConfig = apply { + if (validated) { + return@apply + } - override fun unknown(json: JsonValue?) = 0 + unitRatingKey() + groupingKey() + validated = true } - ) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - return other is Adjustment && - percentageDiscount == other.percentageDiscount && - usageDiscount == other.usageDiscount && - amountDiscount == other.amountDiscount && - minimum == other.minimum && - maximum == other.maximum - } + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (unitRatingKey.asKnown() == null) 0 else 1) + + (if (groupingKey.asKnown() == null) 0 else 1) - override fun hashCode(): Int = - Objects.hash(percentageDiscount, usageDiscount, amountDiscount, minimum, maximum) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - override fun toString(): String = - when { - percentageDiscount != null -> - "Adjustment{percentageDiscount=$percentageDiscount}" - usageDiscount != null -> "Adjustment{usageDiscount=$usageDiscount}" - amountDiscount != null -> "Adjustment{amountDiscount=$amountDiscount}" - minimum != null -> "Adjustment{minimum=$minimum}" - maximum != null -> "Adjustment{maximum=$maximum}" - _json != null -> "Adjustment{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Adjustment") - } + return other is EventOutputConfig && + unitRatingKey == other.unitRatingKey && + groupingKey == other.groupingKey && + additionalProperties == other.additionalProperties + } - companion object { + private val hashCode: Int by lazy { + Objects.hash(unitRatingKey, groupingKey, additionalProperties) + } - fun ofPercentageDiscount(percentageDiscount: NewPercentageDiscount) = - Adjustment(percentageDiscount = percentageDiscount) + override fun hashCode(): Int = hashCode - fun ofUsageDiscount(usageDiscount: NewUsageDiscount) = - Adjustment(usageDiscount = usageDiscount) + override fun toString() = + "EventOutputConfig{unitRatingKey=$unitRatingKey, groupingKey=$groupingKey, additionalProperties=$additionalProperties}" + } - fun ofAmountDiscount(amountDiscount: NewAmountDiscount) = - Adjustment(amountDiscount = amountDiscount) + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { - fun ofMinimum(minimum: NewMinimum) = Adjustment(minimum = minimum) + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties - fun ofMaximum(maximum: NewMaximum) = Adjustment(maximum = maximum) - } + fun toBuilder() = Builder().from(this) - /** - * An interface that defines how to map each variant of [Adjustment] to a value of type - * [T]. - */ - interface Visitor { + companion object { - fun visitPercentageDiscount(percentageDiscount: NewPercentageDiscount): T + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } - fun visitUsageDiscount(usageDiscount: NewUsageDiscount): T + /** A builder for [Metadata]. */ + class Builder internal constructor() { - fun visitAmountDiscount(amountDiscount: NewAmountDiscount): T + private var additionalProperties: MutableMap = + mutableMapOf() - fun visitMinimum(minimum: NewMinimum): T + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } - fun visitMaximum(maximum: NewMaximum): T + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** - * Maps an unknown variant of [Adjustment] to a value of type [T]. - * - * An instance of [Adjustment] can contain an unknown variant if it was deserialized - * from data that doesn't match any known variant. For example, if the SDK is on an - * older version than the API, then the API may respond with new variants that the - * SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown Adjustment: $json") - } - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - internal class Deserializer : BaseDeserializer(Adjustment::class) { + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - override fun ObjectCodec.deserialize(node: JsonNode): Adjustment { - val json = JsonValue.fromJsonNode(node) - val adjustmentType = json.asObject()?.get("adjustment_type")?.asString() + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - when (adjustmentType) { - "percentage_discount" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Adjustment(percentageDiscount = it, _json = json) } - ?: Adjustment(_json = json) + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) } - "usage_discount" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(usageDiscount = it, _json = json) - } ?: Adjustment(_json = json) + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply } - "amount_discount" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(amountDiscount = it, _json = json) - } ?: Adjustment(_json = json) + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false } - "minimum" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(minimum = it, _json = json) - } ?: Adjustment(_json = json) + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() } - "maximum" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(maximum = it, _json = json) - } ?: Adjustment(_json = json) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } + + return other is Metadata && + additionalProperties == other.additionalProperties } - return Adjustment(_json = json) - } - } + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - internal class Serializer : BaseSerializer(Adjustment::class) { + override fun hashCode(): Int = hashCode - override fun serialize( - value: Adjustment, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.percentageDiscount != null -> - generator.writeObject(value.percentageDiscount) - value.usageDiscount != null -> generator.writeObject(value.usageDiscount) - value.amountDiscount != null -> generator.writeObject(value.amountDiscount) - value.minimum != null -> generator.writeObject(value.minimum) - value.maximum != null -> generator.writeObject(value.maximum) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Adjustment") + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } + + return other is EventOutput && + cadence == other.cadence && + eventOutputConfig == other.eventOutputConfig && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + eventOutputConfig, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties, + ) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "EventOutput{cadence=$cadence, eventOutputConfig=$eventOutputConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } } @@ -11795,238 +12264,213 @@ private constructor( return true } - return other is ReplaceAdjustment && - adjustment == other.adjustment && - replacesAdjustmentId == other.replacesAdjustmentId && + return other is AddPrice && + allocationPrice == other.allocationPrice && + discounts == other.discounts && + endDate == other.endDate && + externalPriceId == other.externalPriceId && + maximumAmount == other.maximumAmount && + minimumAmount == other.minimumAmount && + planPhaseOrder == other.planPhaseOrder && + price == other.price && + priceId == other.priceId && + startDate == other.startDate && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(adjustment, replacesAdjustmentId, additionalProperties) + Objects.hash( + allocationPrice, + discounts, + endDate, + externalPriceId, + maximumAmount, + minimumAmount, + planPhaseOrder, + price, + priceId, + startDate, + additionalProperties, + ) } override fun hashCode(): Int = hashCode override fun toString() = - "ReplaceAdjustment{adjustment=$adjustment, replacesAdjustmentId=$replacesAdjustmentId, additionalProperties=$additionalProperties}" + "AddPrice{allocationPrice=$allocationPrice, discounts=$discounts, endDate=$endDate, externalPriceId=$externalPriceId, maximumAmount=$maximumAmount, minimumAmount=$minimumAmount, planPhaseOrder=$planPhaseOrder, price=$price, priceId=$priceId, startDate=$startDate, additionalProperties=$additionalProperties}" } - class ReplacePrice - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val replacesPriceId: JsonField, - private val allocationPrice: JsonField, - private val discounts: JsonField>, - private val externalPriceId: JsonField, - private val fixedPriceQuantity: JsonField, - private val maximumAmount: JsonField, - private val minimumAmount: JsonField, - private val price: JsonField, - private val priceId: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("replaces_price_id") - @ExcludeMissing - replacesPriceId: JsonField = JsonMissing.of(), - @JsonProperty("allocation_price") - @ExcludeMissing - allocationPrice: JsonField = JsonMissing.of(), - @JsonProperty("discounts") - @ExcludeMissing - discounts: JsonField> = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("maximum_amount") - @ExcludeMissing - maximumAmount: JsonField = JsonMissing.of(), - @JsonProperty("minimum_amount") - @ExcludeMissing - minimumAmount: JsonField = JsonMissing.of(), - @JsonProperty("price") @ExcludeMissing price: JsonField = JsonMissing.of(), - @JsonProperty("price_id") @ExcludeMissing priceId: JsonField = JsonMissing.of(), - ) : this( - replacesPriceId, - allocationPrice, - discounts, - externalPriceId, - fixedPriceQuantity, - maximumAmount, - minimumAmount, - price, - priceId, - mutableMapOf(), - ) + /** + * Reset billing periods to be aligned with the plan change's effective date or start of the + * month. Defaults to `unchanged` which keeps subscription's existing billing cycle alignment. + */ + class BillingCycleAlignment + @JsonCreator + private constructor(private val value: JsonField) : Enum { /** - * The id of the price on the plan to replace in the subscription. + * Returns this class instance's raw value. * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. */ - fun replacesPriceId(): String = replacesPriceId.getRequired("replaces_price_id") + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - /** - * The definition of a new allocation price to create and add to the subscription. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun allocationPrice(): NewAllocationPrice? = allocationPrice.getNullable("allocation_price") + companion object { - /** - * [DEPRECATED] Use add_adjustments instead. The subscription's discounts for the - * replacement price. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - @Deprecated("deprecated") - fun discounts(): List? = discounts.getNullable("discounts") + val UNCHANGED = of("unchanged") - /** - * The external price id of the price to add to the subscription. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + val PLAN_CHANGE_DATE = of("plan_change_date") - /** - * The new quantity of the price, if the price is a fixed price. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun fixedPriceQuantity(): Double? = fixedPriceQuantity.getNullable("fixed_price_quantity") + val START_OF_MONTH = of("start_of_month") - /** - * [DEPRECATED] Use add_adjustments instead. The subscription's maximum amount for the - * replacement price. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - @Deprecated("deprecated") - fun maximumAmount(): String? = maximumAmount.getNullable("maximum_amount") + fun of(value: String) = BillingCycleAlignment(JsonField.of(value)) + } - /** - * [DEPRECATED] Use add_adjustments instead. The subscription's minimum amount for the - * replacement price. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - @Deprecated("deprecated") - fun minimumAmount(): String? = minimumAmount.getNullable("minimum_amount") + /** An enum containing [BillingCycleAlignment]'s known values. */ + enum class Known { + UNCHANGED, + PLAN_CHANGE_DATE, + START_OF_MONTH, + } /** - * New subscription price request body params. + * An enum containing [BillingCycleAlignment]'s known values, as well as an [_UNKNOWN] + * member. * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). + * An instance of [BillingCycleAlignment] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. */ - fun price(): Price? = price.getNullable("price") + enum class Value { + UNCHANGED, + PLAN_CHANGE_DATE, + START_OF_MONTH, + /** + * An enum member indicating that [BillingCycleAlignment] was instantiated with an + * unknown value. + */ + _UNKNOWN, + } /** - * The id of the price to add to the subscription. + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. */ - fun priceId(): String? = priceId.getNullable("price_id") + fun value(): Value = + when (this) { + UNCHANGED -> Value.UNCHANGED + PLAN_CHANGE_DATE -> Value.PLAN_CHANGE_DATE + START_OF_MONTH -> Value.START_OF_MONTH + else -> Value._UNKNOWN + } /** - * Returns the raw JSON value of [replacesPriceId]. + * Returns an enum member corresponding to this class instance's value. * - * Unlike [replacesPriceId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("replaces_price_id") - @ExcludeMissing - fun _replacesPriceId(): JsonField = replacesPriceId - - /** - * Returns the raw JSON value of [allocationPrice]. + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. * - * Unlike [allocationPrice], this method doesn't throw if the JSON field has an unexpected - * type. + * @throws OrbInvalidDataException if this class instance's value is a not a known member. */ - @JsonProperty("allocation_price") - @ExcludeMissing - fun _allocationPrice(): JsonField = allocationPrice + fun known(): Known = + when (this) { + UNCHANGED -> Known.UNCHANGED + PLAN_CHANGE_DATE -> Known.PLAN_CHANGE_DATE + START_OF_MONTH -> Known.START_OF_MONTH + else -> throw OrbInvalidDataException("Unknown BillingCycleAlignment: $value") + } /** - * Returns the raw JSON value of [discounts]. + * Returns this class instance's primitive wire representation. * - * Unlike [discounts], this method doesn't throw if the JSON field has an unexpected type. - */ - @Deprecated("deprecated") - @JsonProperty("discounts") - @ExcludeMissing - fun _discounts(): JsonField> = discounts - - /** - * Returns the raw JSON value of [externalPriceId]. + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. * - * Unlike [externalPriceId], this method doesn't throw if the JSON field has an unexpected - * type. + * @throws OrbInvalidDataException if this class instance's value does not have the expected + * primitive type. */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") - /** - * Returns the raw JSON value of [fixedPriceQuantity]. - * - * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + private var validated: Boolean = false - /** - * Returns the raw JSON value of [maximumAmount]. - * - * Unlike [maximumAmount], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @Deprecated("deprecated") - @JsonProperty("maximum_amount") - @ExcludeMissing - fun _maximumAmount(): JsonField = maximumAmount + fun validate(): BillingCycleAlignment = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } /** - * Returns the raw JSON value of [minimumAmount]. + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * Unlike [minimumAmount], this method doesn't throw if the JSON field has an unexpected - * type. + * Used for best match union deserialization. */ - @Deprecated("deprecated") - @JsonProperty("minimum_amount") - @ExcludeMissing - fun _minimumAmount(): JsonField = minimumAmount + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BillingCycleAlignment && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class RemoveAdjustment + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val adjustmentId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("adjustment_id") + @ExcludeMissing + adjustmentId: JsonField = JsonMissing.of() + ) : this(adjustmentId, mutableMapOf()) /** - * Returns the raw JSON value of [price]. + * The id of the adjustment to remove on the subscription. * - * Unlike [price], this method doesn't throw if the JSON field has an unexpected type. + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ - @JsonProperty("price") @ExcludeMissing fun _price(): JsonField = price + fun adjustmentId(): String = adjustmentId.getRequired("adjustment_id") /** - * Returns the raw JSON value of [priceId]. + * Returns the raw JSON value of [adjustmentId]. * - * Unlike [priceId], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [adjustmentId], this method doesn't throw if the JSON field has an unexpected + * type. */ - @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId + @JsonProperty("adjustment_id") + @ExcludeMissing + fun _adjustmentId(): JsonField = adjustmentId @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -12043,107 +12487,205 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [ReplacePrice]. + * Returns a mutable builder for constructing an instance of [RemoveAdjustment]. * * The following fields are required: * ```kotlin - * .replacesPriceId() + * .adjustmentId() * ``` */ fun builder() = Builder() } - /** A builder for [ReplacePrice]. */ + /** A builder for [RemoveAdjustment]. */ class Builder internal constructor() { - private var replacesPriceId: JsonField? = null - private var allocationPrice: JsonField = JsonMissing.of() - private var discounts: JsonField>? = null - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var maximumAmount: JsonField = JsonMissing.of() - private var minimumAmount: JsonField = JsonMissing.of() - private var price: JsonField = JsonMissing.of() - private var priceId: JsonField = JsonMissing.of() + private var adjustmentId: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(replacePrice: ReplacePrice) = apply { - replacesPriceId = replacePrice.replacesPriceId - allocationPrice = replacePrice.allocationPrice - discounts = replacePrice.discounts.map { it.toMutableList() } - externalPriceId = replacePrice.externalPriceId - fixedPriceQuantity = replacePrice.fixedPriceQuantity - maximumAmount = replacePrice.maximumAmount - minimumAmount = replacePrice.minimumAmount - price = replacePrice.price - priceId = replacePrice.priceId - additionalProperties = replacePrice.additionalProperties.toMutableMap() + internal fun from(removeAdjustment: RemoveAdjustment) = apply { + adjustmentId = removeAdjustment.adjustmentId + additionalProperties = removeAdjustment.additionalProperties.toMutableMap() } - /** The id of the price on the plan to replace in the subscription. */ - fun replacesPriceId(replacesPriceId: String) = - replacesPriceId(JsonField.of(replacesPriceId)) + /** The id of the adjustment to remove on the subscription. */ + fun adjustmentId(adjustmentId: String) = adjustmentId(JsonField.of(adjustmentId)) /** - * Sets [Builder.replacesPriceId] to an arbitrary JSON value. + * Sets [Builder.adjustmentId] to an arbitrary JSON value. * - * You should usually call [Builder.replacesPriceId] with a well-typed [String] value + * You should usually call [Builder.adjustmentId] with a well-typed [String] value * instead. This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun replacesPriceId(replacesPriceId: JsonField) = apply { - this.replacesPriceId = replacesPriceId + fun adjustmentId(adjustmentId: JsonField) = apply { + this.adjustmentId = adjustmentId } - /** The definition of a new allocation price to create and add to the subscription. */ - fun allocationPrice(allocationPrice: NewAllocationPrice?) = - allocationPrice(JsonField.ofNullable(allocationPrice)) + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** - * Sets [Builder.allocationPrice] to an arbitrary JSON value. - * - * You should usually call [Builder.allocationPrice] with a well-typed - * [NewAllocationPrice] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun allocationPrice(allocationPrice: JsonField) = apply { - this.allocationPrice = allocationPrice + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) } - /** - * [DEPRECATED] Use add_adjustments instead. The subscription's discounts for the - * replacement price. - */ - @Deprecated("deprecated") - fun discounts(discounts: List?) = - discounts(JsonField.ofNullable(discounts)) + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - /** - * Sets [Builder.discounts] to an arbitrary JSON value. - * - * You should usually call [Builder.discounts] with a well-typed - * `List` value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - @Deprecated("deprecated") - fun discounts(discounts: JsonField>) = apply { - this.discounts = discounts.map { it.toMutableList() } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) } /** - * Adds a single [DiscountOverride] to [discounts]. + * Returns an immutable instance of [RemoveAdjustment]. * - * @throws IllegalStateException if the field was previously set to a non-list. + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .adjustmentId() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ - @Deprecated("deprecated") - fun addDiscount(discount: DiscountOverride) = apply { - discounts = - (discounts ?: JsonField.of(mutableListOf())).also { - checkKnown("discounts", it).add(discount) - } + fun build(): RemoveAdjustment = + RemoveAdjustment( + checkRequired("adjustmentId", adjustmentId), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): RemoveAdjustment = apply { + if (validated) { + return@apply } - /** The external price id of the price to add to the subscription. */ + adjustmentId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = (if (adjustmentId.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RemoveAdjustment && + adjustmentId == other.adjustmentId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(adjustmentId, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "RemoveAdjustment{adjustmentId=$adjustmentId, additionalProperties=$additionalProperties}" + } + + class RemovePrice + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val externalPriceId: JsonField, + private val priceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("price_id") @ExcludeMissing priceId: JsonField = JsonMissing.of(), + ) : this(externalPriceId, priceId, mutableMapOf()) + + /** + * The external price id of the price to remove on the subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * The id of the price to remove on the subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun priceId(): String? = priceId.getNullable("price_id") + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [priceId]. + * + * Unlike [priceId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [RemovePrice]. */ + fun builder() = Builder() + } + + /** A builder for [RemovePrice]. */ + class Builder internal constructor() { + + private var externalPriceId: JsonField = JsonMissing.of() + private var priceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(removePrice: RemovePrice) = apply { + externalPriceId = removePrice.externalPriceId + priceId = removePrice.priceId + additionalProperties = removePrice.additionalProperties.toMutableMap() + } + + /** The external price id of the price to remove on the subscription. */ fun externalPriceId(externalPriceId: String?) = externalPriceId(JsonField.ofNullable(externalPriceId)) @@ -12158,242 +12700,21 @@ private constructor( this.externalPriceId = externalPriceId } - /** The new quantity of the price, if the price is a fixed price. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = - fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) - - /** - * Alias for [Builder.fixedPriceQuantity]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) + /** The id of the price to remove on the subscription. */ + fun priceId(priceId: String?) = priceId(JsonField.ofNullable(priceId)) /** - * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * Sets [Builder.priceId] to an arbitrary JSON value. * - * You should usually call [Builder.fixedPriceQuantity] with a well-typed [Double] value - * instead. This method is primarily for setting the field to an undocumented or not yet + * You should usually call [Builder.priceId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } - - /** - * [DEPRECATED] Use add_adjustments instead. The subscription's maximum amount for the - * replacement price. - */ - @Deprecated("deprecated") - fun maximumAmount(maximumAmount: String?) = - maximumAmount(JsonField.ofNullable(maximumAmount)) - - /** - * Sets [Builder.maximumAmount] to an arbitrary JSON value. - * - * You should usually call [Builder.maximumAmount] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - @Deprecated("deprecated") - fun maximumAmount(maximumAmount: JsonField) = apply { - this.maximumAmount = maximumAmount - } - - /** - * [DEPRECATED] Use add_adjustments instead. The subscription's minimum amount for the - * replacement price. - */ - @Deprecated("deprecated") - fun minimumAmount(minimumAmount: String?) = - minimumAmount(JsonField.ofNullable(minimumAmount)) - - /** - * Sets [Builder.minimumAmount] to an arbitrary JSON value. - * - * You should usually call [Builder.minimumAmount] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - @Deprecated("deprecated") - fun minimumAmount(minimumAmount: JsonField) = apply { - this.minimumAmount = minimumAmount - } - - /** New subscription price request body params. */ - fun price(price: Price?) = price(JsonField.ofNullable(price)) - - /** - * Sets [Builder.price] to an arbitrary JSON value. - * - * You should usually call [Builder.price] with a well-typed [Price] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun price(price: JsonField) = apply { this.price = price } - - /** Alias for calling [price] with `Price.ofUnit(unit)`. */ - fun price(unit: NewSubscriptionUnitPrice) = price(Price.ofUnit(unit)) - - /** Alias for calling [price] with `Price.ofTiered(tiered)`. */ - fun price(tiered: NewSubscriptionTieredPrice) = price(Price.ofTiered(tiered)) - - /** Alias for calling [price] with `Price.ofBulk(bulk)`. */ - fun price(bulk: NewSubscriptionBulkPrice) = price(Price.ofBulk(bulk)) - - /** Alias for calling [price] with `Price.ofPackage(package_)`. */ - fun price(package_: NewSubscriptionPackagePrice) = price(Price.ofPackage(package_)) - - /** Alias for calling [price] with `Price.ofMatrix(matrix)`. */ - fun price(matrix: NewSubscriptionMatrixPrice) = price(Price.ofMatrix(matrix)) - - /** - * Alias for calling [price] with `Price.ofThresholdTotalAmount(thresholdTotalAmount)`. - */ - fun price(thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice) = - price(Price.ofThresholdTotalAmount(thresholdTotalAmount)) - - /** Alias for calling [price] with `Price.ofTieredPackage(tieredPackage)`. */ - fun price(tieredPackage: NewSubscriptionTieredPackagePrice) = - price(Price.ofTieredPackage(tieredPackage)) - - /** Alias for calling [price] with `Price.ofTieredWithMinimum(tieredWithMinimum)`. */ - fun price(tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice) = - price(Price.ofTieredWithMinimum(tieredWithMinimum)) - - /** Alias for calling [price] with `Price.ofGroupedTiered(groupedTiered)`. */ - fun price(groupedTiered: NewSubscriptionGroupedTieredPrice) = - price(Price.ofGroupedTiered(groupedTiered)) - - /** - * Alias for calling [price] with - * `Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)`. - */ - fun price(tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice) = - price(Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)) - - /** - * Alias for calling [price] with - * `Price.ofPackageWithAllocation(packageWithAllocation)`. - */ - fun price(packageWithAllocation: NewSubscriptionPackageWithAllocationPrice) = - price(Price.ofPackageWithAllocation(packageWithAllocation)) - - /** Alias for calling [price] with `Price.ofUnitWithPercent(unitWithPercent)`. */ - fun price(unitWithPercent: NewSubscriptionUnitWithPercentPrice) = - price(Price.ofUnitWithPercent(unitWithPercent)) - - /** - * Alias for calling [price] with `Price.ofMatrixWithAllocation(matrixWithAllocation)`. - */ - fun price(matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice) = - price(Price.ofMatrixWithAllocation(matrixWithAllocation)) - - /** - * Alias for calling [price] with `Price.ofTieredWithProration(tieredWithProration)`. - */ - fun price(tieredWithProration: Price.TieredWithProration) = - price(Price.ofTieredWithProration(tieredWithProration)) - - /** Alias for calling [price] with `Price.ofUnitWithProration(unitWithProration)`. */ - fun price(unitWithProration: NewSubscriptionUnitWithProrationPrice) = - price(Price.ofUnitWithProration(unitWithProration)) - - /** Alias for calling [price] with `Price.ofGroupedAllocation(groupedAllocation)`. */ - fun price(groupedAllocation: NewSubscriptionGroupedAllocationPrice) = - price(Price.ofGroupedAllocation(groupedAllocation)) - - /** Alias for calling [price] with `Price.ofBulkWithProration(bulkWithProration)`. */ - fun price(bulkWithProration: NewSubscriptionBulkWithProrationPrice) = - price(Price.ofBulkWithProration(bulkWithProration)) - - /** - * Alias for calling [price] with - * `Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)`. - */ - fun price(groupedWithProratedMinimum: NewSubscriptionGroupedWithProratedMinimumPrice) = - price(Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)) - - /** - * Alias for calling [price] with - * `Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)`. - */ - fun price(groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice) = - price(Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)) - - /** - * Alias for calling [price] with - * `Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)`. - */ - fun price(groupedWithMinMaxThresholds: Price.GroupedWithMinMaxThresholds) = - price(Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)) - - /** - * Alias for calling [price] with - * `Price.ofMatrixWithDisplayName(matrixWithDisplayName)`. - */ - fun price(matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice) = - price(Price.ofMatrixWithDisplayName(matrixWithDisplayName)) - - /** - * Alias for calling [price] with `Price.ofGroupedTieredPackage(groupedTieredPackage)`. - */ - fun price(groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice) = - price(Price.ofGroupedTieredPackage(groupedTieredPackage)) - - /** - * Alias for calling [price] with - * `Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)`. - */ - fun price(maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice) = - price(Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)) - - /** - * Alias for calling [price] with - * `Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)`. - */ - fun price( - scalableMatrixWithUnitPricing: NewSubscriptionScalableMatrixWithUnitPricingPrice - ) = price(Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)) - - /** - * Alias for calling [price] with - * `Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)`. - */ - fun price( - scalableMatrixWithTieredPricing: NewSubscriptionScalableMatrixWithTieredPricingPrice - ) = price(Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)) - - /** - * Alias for calling [price] with - * `Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)`. - */ - fun price(cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice) = - price(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) - - /** Alias for calling [price] with `Price.ofMinimum(minimum)`. */ - fun price(minimum: NewSubscriptionMinimumCompositePrice) = - price(Price.ofMinimum(minimum)) - - /** Alias for calling [price] with `Price.ofEventOutput(eventOutput)`. */ - fun price(eventOutput: Price.EventOutput) = price(Price.ofEventOutput(eventOutput)) - - /** The id of the price to add to the subscription. */ - fun priceId(priceId: String?) = priceId(JsonField.ofNullable(priceId)) - - /** - * Sets [Builder.priceId] to an arbitrary JSON value. - * - * You should usually call [Builder.priceId] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun priceId(priceId: JsonField) = apply { this.priceId = priceId } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) + fun priceId(priceId: JsonField) = apply { this.priceId = priceId } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) } fun putAdditionalProperty(key: String, value: JsonValue) = apply { @@ -12411,47 +12732,22 @@ private constructor( } /** - * Returns an immutable instance of [ReplacePrice]. + * Returns an immutable instance of [RemovePrice]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```kotlin - * .replacesPriceId() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ - fun build(): ReplacePrice = - ReplacePrice( - checkRequired("replacesPriceId", replacesPriceId), - allocationPrice, - (discounts ?: JsonMissing.of()).map { it.toImmutable() }, - externalPriceId, - fixedPriceQuantity, - maximumAmount, - minimumAmount, - price, - priceId, - additionalProperties.toMutableMap(), - ) + fun build(): RemovePrice = + RemovePrice(externalPriceId, priceId, additionalProperties.toMutableMap()) } private var validated: Boolean = false - fun validate(): ReplacePrice = apply { + fun validate(): RemovePrice = apply { if (validated) { return@apply } - replacesPriceId() - allocationPrice()?.validate() - discounts()?.forEach { it.validate() } externalPriceId() - fixedPriceQuantity() - maximumAmount() - minimumAmount() - price()?.validate() priceId() validated = true } @@ -12471,1227 +12767,4276 @@ private constructor( * Used for best match union deserialization. */ internal fun validity(): Int = - (if (replacesPriceId.asKnown() == null) 0 else 1) + - (allocationPrice.asKnown()?.validity() ?: 0) + - (discounts.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + - (if (externalPriceId.asKnown() == null) 0 else 1) + - (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + - (if (maximumAmount.asKnown() == null) 0 else 1) + - (if (minimumAmount.asKnown() == null) 0 else 1) + - (price.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + (if (priceId.asKnown() == null) 0 else 1) - /** New subscription price request body params. */ - @JsonDeserialize(using = Price.Deserializer::class) - @JsonSerialize(using = Price.Serializer::class) - class Price - private constructor( - private val unit: NewSubscriptionUnitPrice? = null, - private val tiered: NewSubscriptionTieredPrice? = null, - private val bulk: NewSubscriptionBulkPrice? = null, - private val package_: NewSubscriptionPackagePrice? = null, - private val matrix: NewSubscriptionMatrixPrice? = null, - private val thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice? = null, - private val tieredPackage: NewSubscriptionTieredPackagePrice? = null, - private val tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice? = null, - private val groupedTiered: NewSubscriptionGroupedTieredPrice? = null, - private val tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice? = - null, - private val packageWithAllocation: NewSubscriptionPackageWithAllocationPrice? = null, - private val unitWithPercent: NewSubscriptionUnitWithPercentPrice? = null, - private val matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice? = null, - private val tieredWithProration: TieredWithProration? = null, - private val unitWithProration: NewSubscriptionUnitWithProrationPrice? = null, - private val groupedAllocation: NewSubscriptionGroupedAllocationPrice? = null, - private val bulkWithProration: NewSubscriptionBulkWithProrationPrice? = null, - private val groupedWithProratedMinimum: - NewSubscriptionGroupedWithProratedMinimumPrice? = - null, - private val groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice? = - null, - private val groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds? = null, - private val matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice? = null, - private val groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice? = null, - private val maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice? = null, - private val scalableMatrixWithUnitPricing: - NewSubscriptionScalableMatrixWithUnitPricingPrice? = - null, - private val scalableMatrixWithTieredPricing: - NewSubscriptionScalableMatrixWithTieredPricingPrice? = - null, - private val cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice? = null, - private val minimum: NewSubscriptionMinimumCompositePrice? = null, - private val eventOutput: EventOutput? = null, - private val _json: JsonValue? = null, - ) { - - fun unit(): NewSubscriptionUnitPrice? = unit + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun tiered(): NewSubscriptionTieredPrice? = tiered + return other is RemovePrice && + externalPriceId == other.externalPriceId && + priceId == other.priceId && + additionalProperties == other.additionalProperties + } - fun bulk(): NewSubscriptionBulkPrice? = bulk + private val hashCode: Int by lazy { + Objects.hash(externalPriceId, priceId, additionalProperties) + } - fun package_(): NewSubscriptionPackagePrice? = package_ + override fun hashCode(): Int = hashCode - fun matrix(): NewSubscriptionMatrixPrice? = matrix + override fun toString() = + "RemovePrice{externalPriceId=$externalPriceId, priceId=$priceId, additionalProperties=$additionalProperties}" + } - fun thresholdTotalAmount(): NewSubscriptionThresholdTotalAmountPrice? = - thresholdTotalAmount + class ReplaceAdjustment + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val adjustment: JsonField, + private val replacesAdjustmentId: JsonField, + private val additionalProperties: MutableMap, + ) { - fun tieredPackage(): NewSubscriptionTieredPackagePrice? = tieredPackage + @JsonCreator + private constructor( + @JsonProperty("adjustment") + @ExcludeMissing + adjustment: JsonField = JsonMissing.of(), + @JsonProperty("replaces_adjustment_id") + @ExcludeMissing + replacesAdjustmentId: JsonField = JsonMissing.of(), + ) : this(adjustment, replacesAdjustmentId, mutableMapOf()) - fun tieredWithMinimum(): NewSubscriptionTieredWithMinimumPrice? = tieredWithMinimum + /** + * The definition of a new adjustment to create and add to the subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun adjustment(): Adjustment = adjustment.getRequired("adjustment") - fun groupedTiered(): NewSubscriptionGroupedTieredPrice? = groupedTiered + /** + * The id of the adjustment on the plan to replace in the subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun replacesAdjustmentId(): String = + replacesAdjustmentId.getRequired("replaces_adjustment_id") - fun tieredPackageWithMinimum(): NewSubscriptionTieredPackageWithMinimumPrice? = - tieredPackageWithMinimum + /** + * Returns the raw JSON value of [adjustment]. + * + * Unlike [adjustment], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("adjustment") + @ExcludeMissing + fun _adjustment(): JsonField = adjustment - fun packageWithAllocation(): NewSubscriptionPackageWithAllocationPrice? = - packageWithAllocation + /** + * Returns the raw JSON value of [replacesAdjustmentId]. + * + * Unlike [replacesAdjustmentId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("replaces_adjustment_id") + @ExcludeMissing + fun _replacesAdjustmentId(): JsonField = replacesAdjustmentId - fun unitWithPercent(): NewSubscriptionUnitWithPercentPrice? = unitWithPercent + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - fun matrixWithAllocation(): NewSubscriptionMatrixWithAllocationPrice? = - matrixWithAllocation + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - fun tieredWithProration(): TieredWithProration? = tieredWithProration + fun toBuilder() = Builder().from(this) - fun unitWithProration(): NewSubscriptionUnitWithProrationPrice? = unitWithProration + companion object { - fun groupedAllocation(): NewSubscriptionGroupedAllocationPrice? = groupedAllocation + /** + * Returns a mutable builder for constructing an instance of [ReplaceAdjustment]. + * + * The following fields are required: + * ```kotlin + * .adjustment() + * .replacesAdjustmentId() + * ``` + */ + fun builder() = Builder() + } - fun bulkWithProration(): NewSubscriptionBulkWithProrationPrice? = bulkWithProration + /** A builder for [ReplaceAdjustment]. */ + class Builder internal constructor() { - fun groupedWithProratedMinimum(): NewSubscriptionGroupedWithProratedMinimumPrice? = - groupedWithProratedMinimum + private var adjustment: JsonField? = null + private var replacesAdjustmentId: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() - fun groupedWithMeteredMinimum(): NewSubscriptionGroupedWithMeteredMinimumPrice? = - groupedWithMeteredMinimum + internal fun from(replaceAdjustment: ReplaceAdjustment) = apply { + adjustment = replaceAdjustment.adjustment + replacesAdjustmentId = replaceAdjustment.replacesAdjustmentId + additionalProperties = replaceAdjustment.additionalProperties.toMutableMap() + } - fun groupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds? = - groupedWithMinMaxThresholds + /** The definition of a new adjustment to create and add to the subscription. */ + fun adjustment(adjustment: Adjustment) = adjustment(JsonField.of(adjustment)) - fun matrixWithDisplayName(): NewSubscriptionMatrixWithDisplayNamePrice? = - matrixWithDisplayName + /** + * Sets [Builder.adjustment] to an arbitrary JSON value. + * + * You should usually call [Builder.adjustment] with a well-typed [Adjustment] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun adjustment(adjustment: JsonField) = apply { + this.adjustment = adjustment + } - fun groupedTieredPackage(): NewSubscriptionGroupedTieredPackagePrice? = - groupedTieredPackage + /** + * Alias for calling [adjustment] with + * `Adjustment.ofPercentageDiscount(percentageDiscount)`. + */ + fun adjustment(percentageDiscount: NewPercentageDiscount) = + adjustment(Adjustment.ofPercentageDiscount(percentageDiscount)) - fun maxGroupTieredPackage(): NewSubscriptionMaxGroupTieredPackagePrice? = - maxGroupTieredPackage + /** + * Alias for calling [adjustment] with the following: + * ```kotlin + * NewPercentageDiscount.builder() + * .adjustmentType(NewPercentageDiscount.AdjustmentType.PERCENTAGE_DISCOUNT) + * .percentageDiscount(percentageDiscount) + * .build() + * ``` + */ + fun percentageDiscountAdjustment(percentageDiscount: Double) = + adjustment( + NewPercentageDiscount.builder() + .adjustmentType(NewPercentageDiscount.AdjustmentType.PERCENTAGE_DISCOUNT) + .percentageDiscount(percentageDiscount) + .build() + ) - fun scalableMatrixWithUnitPricing(): - NewSubscriptionScalableMatrixWithUnitPricingPrice? = scalableMatrixWithUnitPricing + /** Alias for calling [adjustment] with `Adjustment.ofUsageDiscount(usageDiscount)`. */ + fun adjustment(usageDiscount: NewUsageDiscount) = + adjustment(Adjustment.ofUsageDiscount(usageDiscount)) - fun scalableMatrixWithTieredPricing(): - NewSubscriptionScalableMatrixWithTieredPricingPrice? = - scalableMatrixWithTieredPricing + /** + * Alias for calling [adjustment] with the following: + * ```kotlin + * NewUsageDiscount.builder() + * .adjustmentType(NewUsageDiscount.AdjustmentType.USAGE_DISCOUNT) + * .usageDiscount(usageDiscount) + * .build() + * ``` + */ + fun usageDiscountAdjustment(usageDiscount: Double) = + adjustment( + NewUsageDiscount.builder() + .adjustmentType(NewUsageDiscount.AdjustmentType.USAGE_DISCOUNT) + .usageDiscount(usageDiscount) + .build() + ) - fun cumulativeGroupedBulk(): NewSubscriptionCumulativeGroupedBulkPrice? = - cumulativeGroupedBulk + /** + * Alias for calling [adjustment] with `Adjustment.ofAmountDiscount(amountDiscount)`. + */ + fun adjustment(amountDiscount: NewAmountDiscount) = + adjustment(Adjustment.ofAmountDiscount(amountDiscount)) - fun minimum(): NewSubscriptionMinimumCompositePrice? = minimum + /** + * Alias for calling [adjustment] with the following: + * ```kotlin + * NewAmountDiscount.builder() + * .adjustmentType(NewAmountDiscount.AdjustmentType.AMOUNT_DISCOUNT) + * .amountDiscount(amountDiscount) + * .build() + * ``` + */ + fun amountDiscountAdjustment(amountDiscount: String) = + adjustment( + NewAmountDiscount.builder() + .adjustmentType(NewAmountDiscount.AdjustmentType.AMOUNT_DISCOUNT) + .amountDiscount(amountDiscount) + .build() + ) - fun eventOutput(): EventOutput? = eventOutput + /** Alias for calling [adjustment] with `Adjustment.ofMinimum(minimum)`. */ + fun adjustment(minimum: NewMinimum) = adjustment(Adjustment.ofMinimum(minimum)) - fun isUnit(): Boolean = unit != null - - fun isTiered(): Boolean = tiered != null - - fun isBulk(): Boolean = bulk != null + /** Alias for calling [adjustment] with `Adjustment.ofMaximum(maximum)`. */ + fun adjustment(maximum: NewMaximum) = adjustment(Adjustment.ofMaximum(maximum)) - fun isPackage(): Boolean = package_ != null + /** + * Alias for calling [adjustment] with the following: + * ```kotlin + * NewMaximum.builder() + * .adjustmentType(NewMaximum.AdjustmentType.MAXIMUM) + * .maximumAmount(maximumAmount) + * .build() + * ``` + */ + fun maximumAdjustment(maximumAmount: String) = + adjustment( + NewMaximum.builder() + .adjustmentType(NewMaximum.AdjustmentType.MAXIMUM) + .maximumAmount(maximumAmount) + .build() + ) - fun isMatrix(): Boolean = matrix != null + /** The id of the adjustment on the plan to replace in the subscription. */ + fun replacesAdjustmentId(replacesAdjustmentId: String) = + replacesAdjustmentId(JsonField.of(replacesAdjustmentId)) - fun isThresholdTotalAmount(): Boolean = thresholdTotalAmount != null + /** + * Sets [Builder.replacesAdjustmentId] to an arbitrary JSON value. + * + * You should usually call [Builder.replacesAdjustmentId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun replacesAdjustmentId(replacesAdjustmentId: JsonField) = apply { + this.replacesAdjustmentId = replacesAdjustmentId + } - fun isTieredPackage(): Boolean = tieredPackage != null + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun isTieredWithMinimum(): Boolean = tieredWithMinimum != null + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun isGroupedTiered(): Boolean = groupedTiered != null + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun isTieredPackageWithMinimum(): Boolean = tieredPackageWithMinimum != null + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - fun isPackageWithAllocation(): Boolean = packageWithAllocation != null + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - fun isUnitWithPercent(): Boolean = unitWithPercent != null + /** + * Returns an immutable instance of [ReplaceAdjustment]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .adjustment() + * .replacesAdjustmentId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ReplaceAdjustment = + ReplaceAdjustment( + checkRequired("adjustment", adjustment), + checkRequired("replacesAdjustmentId", replacesAdjustmentId), + additionalProperties.toMutableMap(), + ) + } - fun isMatrixWithAllocation(): Boolean = matrixWithAllocation != null + private var validated: Boolean = false - fun isTieredWithProration(): Boolean = tieredWithProration != null + fun validate(): ReplaceAdjustment = apply { + if (validated) { + return@apply + } - fun isUnitWithProration(): Boolean = unitWithProration != null + adjustment().validate() + replacesAdjustmentId() + validated = true + } - fun isGroupedAllocation(): Boolean = groupedAllocation != null + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - fun isBulkWithProration(): Boolean = bulkWithProration != null + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (adjustment.asKnown()?.validity() ?: 0) + + (if (replacesAdjustmentId.asKnown() == null) 0 else 1) - fun isGroupedWithProratedMinimum(): Boolean = groupedWithProratedMinimum != null + /** The definition of a new adjustment to create and add to the subscription. */ + @JsonDeserialize(using = Adjustment.Deserializer::class) + @JsonSerialize(using = Adjustment.Serializer::class) + class Adjustment + private constructor( + private val percentageDiscount: NewPercentageDiscount? = null, + private val usageDiscount: NewUsageDiscount? = null, + private val amountDiscount: NewAmountDiscount? = null, + private val minimum: NewMinimum? = null, + private val maximum: NewMaximum? = null, + private val _json: JsonValue? = null, + ) { - fun isGroupedWithMeteredMinimum(): Boolean = groupedWithMeteredMinimum != null + fun percentageDiscount(): NewPercentageDiscount? = percentageDiscount - fun isGroupedWithMinMaxThresholds(): Boolean = groupedWithMinMaxThresholds != null + fun usageDiscount(): NewUsageDiscount? = usageDiscount - fun isMatrixWithDisplayName(): Boolean = matrixWithDisplayName != null + fun amountDiscount(): NewAmountDiscount? = amountDiscount - fun isGroupedTieredPackage(): Boolean = groupedTieredPackage != null + fun minimum(): NewMinimum? = minimum - fun isMaxGroupTieredPackage(): Boolean = maxGroupTieredPackage != null + fun maximum(): NewMaximum? = maximum - fun isScalableMatrixWithUnitPricing(): Boolean = scalableMatrixWithUnitPricing != null + fun isPercentageDiscount(): Boolean = percentageDiscount != null - fun isScalableMatrixWithTieredPricing(): Boolean = - scalableMatrixWithTieredPricing != null + fun isUsageDiscount(): Boolean = usageDiscount != null - fun isCumulativeGroupedBulk(): Boolean = cumulativeGroupedBulk != null + fun isAmountDiscount(): Boolean = amountDiscount != null fun isMinimum(): Boolean = minimum != null - fun isEventOutput(): Boolean = eventOutput != null - - fun asUnit(): NewSubscriptionUnitPrice = unit.getOrThrow("unit") + fun isMaximum(): Boolean = maximum != null - fun asTiered(): NewSubscriptionTieredPrice = tiered.getOrThrow("tiered") + fun asPercentageDiscount(): NewPercentageDiscount = + percentageDiscount.getOrThrow("percentageDiscount") - fun asBulk(): NewSubscriptionBulkPrice = bulk.getOrThrow("bulk") + fun asUsageDiscount(): NewUsageDiscount = usageDiscount.getOrThrow("usageDiscount") - fun asPackage(): NewSubscriptionPackagePrice = package_.getOrThrow("package_") + fun asAmountDiscount(): NewAmountDiscount = amountDiscount.getOrThrow("amountDiscount") - fun asMatrix(): NewSubscriptionMatrixPrice = matrix.getOrThrow("matrix") + fun asMinimum(): NewMinimum = minimum.getOrThrow("minimum") - fun asThresholdTotalAmount(): NewSubscriptionThresholdTotalAmountPrice = - thresholdTotalAmount.getOrThrow("thresholdTotalAmount") + fun asMaximum(): NewMaximum = maximum.getOrThrow("maximum") - fun asTieredPackage(): NewSubscriptionTieredPackagePrice = - tieredPackage.getOrThrow("tieredPackage") + fun _json(): JsonValue? = _json - fun asTieredWithMinimum(): NewSubscriptionTieredWithMinimumPrice = - tieredWithMinimum.getOrThrow("tieredWithMinimum") + fun accept(visitor: Visitor): T = + when { + percentageDiscount != null -> + visitor.visitPercentageDiscount(percentageDiscount) + usageDiscount != null -> visitor.visitUsageDiscount(usageDiscount) + amountDiscount != null -> visitor.visitAmountDiscount(amountDiscount) + minimum != null -> visitor.visitMinimum(minimum) + maximum != null -> visitor.visitMaximum(maximum) + else -> visitor.unknown(_json) + } - fun asGroupedTiered(): NewSubscriptionGroupedTieredPrice = - groupedTiered.getOrThrow("groupedTiered") + private var validated: Boolean = false - fun asTieredPackageWithMinimum(): NewSubscriptionTieredPackageWithMinimumPrice = - tieredPackageWithMinimum.getOrThrow("tieredPackageWithMinimum") + fun validate(): Adjustment = apply { + if (validated) { + return@apply + } - fun asPackageWithAllocation(): NewSubscriptionPackageWithAllocationPrice = - packageWithAllocation.getOrThrow("packageWithAllocation") + accept( + object : Visitor { + override fun visitPercentageDiscount( + percentageDiscount: NewPercentageDiscount + ) { + percentageDiscount.validate() + } - fun asUnitWithPercent(): NewSubscriptionUnitWithPercentPrice = - unitWithPercent.getOrThrow("unitWithPercent") + override fun visitUsageDiscount(usageDiscount: NewUsageDiscount) { + usageDiscount.validate() + } - fun asMatrixWithAllocation(): NewSubscriptionMatrixWithAllocationPrice = - matrixWithAllocation.getOrThrow("matrixWithAllocation") + override fun visitAmountDiscount(amountDiscount: NewAmountDiscount) { + amountDiscount.validate() + } - fun asTieredWithProration(): TieredWithProration = - tieredWithProration.getOrThrow("tieredWithProration") + override fun visitMinimum(minimum: NewMinimum) { + minimum.validate() + } - fun asUnitWithProration(): NewSubscriptionUnitWithProrationPrice = - unitWithProration.getOrThrow("unitWithProration") + override fun visitMaximum(maximum: NewMaximum) { + maximum.validate() + } + } + ) + validated = true + } - fun asGroupedAllocation(): NewSubscriptionGroupedAllocationPrice = - groupedAllocation.getOrThrow("groupedAllocation") + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - fun asBulkWithProration(): NewSubscriptionBulkWithProrationPrice = - bulkWithProration.getOrThrow("bulkWithProration") + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitPercentageDiscount( + percentageDiscount: NewPercentageDiscount + ) = percentageDiscount.validity() - fun asGroupedWithProratedMinimum(): NewSubscriptionGroupedWithProratedMinimumPrice = - groupedWithProratedMinimum.getOrThrow("groupedWithProratedMinimum") + override fun visitUsageDiscount(usageDiscount: NewUsageDiscount) = + usageDiscount.validity() - fun asGroupedWithMeteredMinimum(): NewSubscriptionGroupedWithMeteredMinimumPrice = - groupedWithMeteredMinimum.getOrThrow("groupedWithMeteredMinimum") + override fun visitAmountDiscount(amountDiscount: NewAmountDiscount) = + amountDiscount.validity() - fun asGroupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds = - groupedWithMinMaxThresholds.getOrThrow("groupedWithMinMaxThresholds") + override fun visitMinimum(minimum: NewMinimum) = minimum.validity() - fun asMatrixWithDisplayName(): NewSubscriptionMatrixWithDisplayNamePrice = - matrixWithDisplayName.getOrThrow("matrixWithDisplayName") + override fun visitMaximum(maximum: NewMaximum) = maximum.validity() - fun asGroupedTieredPackage(): NewSubscriptionGroupedTieredPackagePrice = - groupedTieredPackage.getOrThrow("groupedTieredPackage") + override fun unknown(json: JsonValue?) = 0 + } + ) - fun asMaxGroupTieredPackage(): NewSubscriptionMaxGroupTieredPackagePrice = - maxGroupTieredPackage.getOrThrow("maxGroupTieredPackage") - - fun asScalableMatrixWithUnitPricing(): - NewSubscriptionScalableMatrixWithUnitPricingPrice = - scalableMatrixWithUnitPricing.getOrThrow("scalableMatrixWithUnitPricing") - - fun asScalableMatrixWithTieredPricing(): - NewSubscriptionScalableMatrixWithTieredPricingPrice = - scalableMatrixWithTieredPricing.getOrThrow("scalableMatrixWithTieredPricing") - - fun asCumulativeGroupedBulk(): NewSubscriptionCumulativeGroupedBulkPrice = - cumulativeGroupedBulk.getOrThrow("cumulativeGroupedBulk") - - fun asMinimum(): NewSubscriptionMinimumCompositePrice = minimum.getOrThrow("minimum") + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun asEventOutput(): EventOutput = eventOutput.getOrThrow("eventOutput") + return other is Adjustment && + percentageDiscount == other.percentageDiscount && + usageDiscount == other.usageDiscount && + amountDiscount == other.amountDiscount && + minimum == other.minimum && + maximum == other.maximum + } - fun _json(): JsonValue? = _json + override fun hashCode(): Int = + Objects.hash(percentageDiscount, usageDiscount, amountDiscount, minimum, maximum) - fun accept(visitor: Visitor): T = + override fun toString(): String = when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - bulk != null -> visitor.visitBulk(bulk) - package_ != null -> visitor.visitPackage(package_) - matrix != null -> visitor.visitMatrix(matrix) - thresholdTotalAmount != null -> - visitor.visitThresholdTotalAmount(thresholdTotalAmount) - tieredPackage != null -> visitor.visitTieredPackage(tieredPackage) - tieredWithMinimum != null -> visitor.visitTieredWithMinimum(tieredWithMinimum) - groupedTiered != null -> visitor.visitGroupedTiered(groupedTiered) - tieredPackageWithMinimum != null -> - visitor.visitTieredPackageWithMinimum(tieredPackageWithMinimum) - packageWithAllocation != null -> - visitor.visitPackageWithAllocation(packageWithAllocation) - unitWithPercent != null -> visitor.visitUnitWithPercent(unitWithPercent) - matrixWithAllocation != null -> - visitor.visitMatrixWithAllocation(matrixWithAllocation) - tieredWithProration != null -> - visitor.visitTieredWithProration(tieredWithProration) - unitWithProration != null -> visitor.visitUnitWithProration(unitWithProration) - groupedAllocation != null -> visitor.visitGroupedAllocation(groupedAllocation) - bulkWithProration != null -> visitor.visitBulkWithProration(bulkWithProration) - groupedWithProratedMinimum != null -> - visitor.visitGroupedWithProratedMinimum(groupedWithProratedMinimum) - groupedWithMeteredMinimum != null -> - visitor.visitGroupedWithMeteredMinimum(groupedWithMeteredMinimum) - groupedWithMinMaxThresholds != null -> - visitor.visitGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds) - matrixWithDisplayName != null -> - visitor.visitMatrixWithDisplayName(matrixWithDisplayName) - groupedTieredPackage != null -> - visitor.visitGroupedTieredPackage(groupedTieredPackage) - maxGroupTieredPackage != null -> - visitor.visitMaxGroupTieredPackage(maxGroupTieredPackage) - scalableMatrixWithUnitPricing != null -> - visitor.visitScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing) - scalableMatrixWithTieredPricing != null -> - visitor.visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing - ) - cumulativeGroupedBulk != null -> - visitor.visitCumulativeGroupedBulk(cumulativeGroupedBulk) - minimum != null -> visitor.visitMinimum(minimum) - eventOutput != null -> visitor.visitEventOutput(eventOutput) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): Price = apply { - if (validated) { - return@apply + percentageDiscount != null -> + "Adjustment{percentageDiscount=$percentageDiscount}" + usageDiscount != null -> "Adjustment{usageDiscount=$usageDiscount}" + amountDiscount != null -> "Adjustment{amountDiscount=$amountDiscount}" + minimum != null -> "Adjustment{minimum=$minimum}" + maximum != null -> "Adjustment{maximum=$maximum}" + _json != null -> "Adjustment{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Adjustment") } - accept( - object : Visitor { - override fun visitUnit(unit: NewSubscriptionUnitPrice) { - unit.validate() - } + companion object { - override fun visitTiered(tiered: NewSubscriptionTieredPrice) { - tiered.validate() - } + fun ofPercentageDiscount(percentageDiscount: NewPercentageDiscount) = + Adjustment(percentageDiscount = percentageDiscount) - override fun visitBulk(bulk: NewSubscriptionBulkPrice) { - bulk.validate() - } + fun ofUsageDiscount(usageDiscount: NewUsageDiscount) = + Adjustment(usageDiscount = usageDiscount) - override fun visitPackage(package_: NewSubscriptionPackagePrice) { - package_.validate() - } + fun ofAmountDiscount(amountDiscount: NewAmountDiscount) = + Adjustment(amountDiscount = amountDiscount) - override fun visitMatrix(matrix: NewSubscriptionMatrixPrice) { - matrix.validate() - } + fun ofMinimum(minimum: NewMinimum) = Adjustment(minimum = minimum) - override fun visitThresholdTotalAmount( - thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice - ) { - thresholdTotalAmount.validate() - } + fun ofMaximum(maximum: NewMaximum) = Adjustment(maximum = maximum) + } - override fun visitTieredPackage( - tieredPackage: NewSubscriptionTieredPackagePrice - ) { - tieredPackage.validate() - } + /** + * An interface that defines how to map each variant of [Adjustment] to a value of type + * [T]. + */ + interface Visitor { - override fun visitTieredWithMinimum( - tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice - ) { - tieredWithMinimum.validate() - } + fun visitPercentageDiscount(percentageDiscount: NewPercentageDiscount): T - override fun visitGroupedTiered( - groupedTiered: NewSubscriptionGroupedTieredPrice - ) { - groupedTiered.validate() - } + fun visitUsageDiscount(usageDiscount: NewUsageDiscount): T - override fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice - ) { - tieredPackageWithMinimum.validate() - } + fun visitAmountDiscount(amountDiscount: NewAmountDiscount): T - override fun visitPackageWithAllocation( - packageWithAllocation: NewSubscriptionPackageWithAllocationPrice - ) { - packageWithAllocation.validate() - } + fun visitMinimum(minimum: NewMinimum): T - override fun visitUnitWithPercent( - unitWithPercent: NewSubscriptionUnitWithPercentPrice - ) { - unitWithPercent.validate() - } + fun visitMaximum(maximum: NewMaximum): T - override fun visitMatrixWithAllocation( - matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice - ) { - matrixWithAllocation.validate() - } + /** + * Maps an unknown variant of [Adjustment] to a value of type [T]. + * + * An instance of [Adjustment] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the + * SDK is unaware of. + * + * @throws OrbInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw OrbInvalidDataException("Unknown Adjustment: $json") + } + } - override fun visitTieredWithProration( - tieredWithProration: TieredWithProration - ) { - tieredWithProration.validate() - } + internal class Deserializer : BaseDeserializer(Adjustment::class) { - override fun visitUnitWithProration( - unitWithProration: NewSubscriptionUnitWithProrationPrice - ) { - unitWithProration.validate() - } + override fun ObjectCodec.deserialize(node: JsonNode): Adjustment { + val json = JsonValue.fromJsonNode(node) + val adjustmentType = json.asObject()?.get("adjustment_type")?.asString() - override fun visitGroupedAllocation( - groupedAllocation: NewSubscriptionGroupedAllocationPrice - ) { - groupedAllocation.validate() + when (adjustmentType) { + "percentage_discount" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Adjustment(percentageDiscount = it, _json = json) } + ?: Adjustment(_json = json) } - - override fun visitBulkWithProration( - bulkWithProration: NewSubscriptionBulkWithProrationPrice - ) { - bulkWithProration.validate() + "usage_discount" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(usageDiscount = it, _json = json) + } ?: Adjustment(_json = json) } - - override fun visitGroupedWithProratedMinimum( - groupedWithProratedMinimum: - NewSubscriptionGroupedWithProratedMinimumPrice - ) { - groupedWithProratedMinimum.validate() + "amount_discount" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(amountDiscount = it, _json = json) + } ?: Adjustment(_json = json) } - - override fun visitGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice - ) { - groupedWithMeteredMinimum.validate() + "minimum" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(minimum = it, _json = json) + } ?: Adjustment(_json = json) } - - override fun visitGroupedWithMinMaxThresholds( - groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds - ) { - groupedWithMinMaxThresholds.validate() + "maximum" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(maximum = it, _json = json) + } ?: Adjustment(_json = json) } + } - override fun visitMatrixWithDisplayName( - matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice - ) { - matrixWithDisplayName.validate() - } + return Adjustment(_json = json) + } + } - override fun visitGroupedTieredPackage( - groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice - ) { - groupedTieredPackage.validate() - } + internal class Serializer : BaseSerializer(Adjustment::class) { - override fun visitMaxGroupTieredPackage( - maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice - ) { - maxGroupTieredPackage.validate() - } - - override fun visitScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: - NewSubscriptionScalableMatrixWithUnitPricingPrice - ) { - scalableMatrixWithUnitPricing.validate() - } - - override fun visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: - NewSubscriptionScalableMatrixWithTieredPricingPrice - ) { - scalableMatrixWithTieredPricing.validate() - } - - override fun visitCumulativeGroupedBulk( - cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice - ) { - cumulativeGroupedBulk.validate() - } - - override fun visitMinimum(minimum: NewSubscriptionMinimumCompositePrice) { - minimum.validate() - } - - override fun visitEventOutput(eventOutput: EventOutput) { - eventOutput.validate() - } + override fun serialize( + value: Adjustment, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.percentageDiscount != null -> + generator.writeObject(value.percentageDiscount) + value.usageDiscount != null -> generator.writeObject(value.usageDiscount) + value.amountDiscount != null -> generator.writeObject(value.amountDiscount) + value.minimum != null -> generator.writeObject(value.minimum) + value.maximum != null -> generator.writeObject(value.maximum) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Adjustment") } - ) - validated = true + } } + } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: NewSubscriptionUnitPrice) = unit.validity() + return other is ReplaceAdjustment && + adjustment == other.adjustment && + replacesAdjustmentId == other.replacesAdjustmentId && + additionalProperties == other.additionalProperties + } - override fun visitTiered(tiered: NewSubscriptionTieredPrice) = - tiered.validity() + private val hashCode: Int by lazy { + Objects.hash(adjustment, replacesAdjustmentId, additionalProperties) + } - override fun visitBulk(bulk: NewSubscriptionBulkPrice) = bulk.validity() + override fun hashCode(): Int = hashCode - override fun visitPackage(package_: NewSubscriptionPackagePrice) = - package_.validity() + override fun toString() = + "ReplaceAdjustment{adjustment=$adjustment, replacesAdjustmentId=$replacesAdjustmentId, additionalProperties=$additionalProperties}" + } - override fun visitMatrix(matrix: NewSubscriptionMatrixPrice) = - matrix.validity() + class ReplacePrice + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val replacesPriceId: JsonField, + private val allocationPrice: JsonField, + private val discounts: JsonField>, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val maximumAmount: JsonField, + private val minimumAmount: JsonField, + private val price: JsonField, + private val priceId: JsonField, + private val additionalProperties: MutableMap, + ) { - override fun visitThresholdTotalAmount( - thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice - ) = thresholdTotalAmount.validity() + @JsonCreator + private constructor( + @JsonProperty("replaces_price_id") + @ExcludeMissing + replacesPriceId: JsonField = JsonMissing.of(), + @JsonProperty("allocation_price") + @ExcludeMissing + allocationPrice: JsonField = JsonMissing.of(), + @JsonProperty("discounts") + @ExcludeMissing + discounts: JsonField> = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("maximum_amount") + @ExcludeMissing + maximumAmount: JsonField = JsonMissing.of(), + @JsonProperty("minimum_amount") + @ExcludeMissing + minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("price") @ExcludeMissing price: JsonField = JsonMissing.of(), + @JsonProperty("price_id") @ExcludeMissing priceId: JsonField = JsonMissing.of(), + ) : this( + replacesPriceId, + allocationPrice, + discounts, + externalPriceId, + fixedPriceQuantity, + maximumAmount, + minimumAmount, + price, + priceId, + mutableMapOf(), + ) - override fun visitTieredPackage( - tieredPackage: NewSubscriptionTieredPackagePrice - ) = tieredPackage.validity() + /** + * The id of the price on the plan to replace in the subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun replacesPriceId(): String = replacesPriceId.getRequired("replaces_price_id") - override fun visitTieredWithMinimum( - tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice - ) = tieredWithMinimum.validity() + /** + * The definition of a new allocation price to create and add to the subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun allocationPrice(): NewAllocationPrice? = allocationPrice.getNullable("allocation_price") - override fun visitGroupedTiered( - groupedTiered: NewSubscriptionGroupedTieredPrice - ) = groupedTiered.validity() + /** + * [DEPRECATED] Use add_adjustments instead. The subscription's discounts for the + * replacement price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + @Deprecated("deprecated") + fun discounts(): List? = discounts.getNullable("discounts") - override fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice - ) = tieredPackageWithMinimum.validity() + /** + * The external price id of the price to add to the subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") - override fun visitPackageWithAllocation( - packageWithAllocation: NewSubscriptionPackageWithAllocationPrice - ) = packageWithAllocation.validity() + /** + * The new quantity of the price, if the price is a fixed price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = fixedPriceQuantity.getNullable("fixed_price_quantity") - override fun visitUnitWithPercent( - unitWithPercent: NewSubscriptionUnitWithPercentPrice - ) = unitWithPercent.validity() + /** + * [DEPRECATED] Use add_adjustments instead. The subscription's maximum amount for the + * replacement price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + @Deprecated("deprecated") + fun maximumAmount(): String? = maximumAmount.getNullable("maximum_amount") - override fun visitMatrixWithAllocation( - matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice - ) = matrixWithAllocation.validity() + /** + * [DEPRECATED] Use add_adjustments instead. The subscription's minimum amount for the + * replacement price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + @Deprecated("deprecated") + fun minimumAmount(): String? = minimumAmount.getNullable("minimum_amount") - override fun visitTieredWithProration( - tieredWithProration: TieredWithProration - ) = tieredWithProration.validity() + /** + * New subscription price request body params. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun price(): Price? = price.getNullable("price") - override fun visitUnitWithProration( - unitWithProration: NewSubscriptionUnitWithProrationPrice - ) = unitWithProration.validity() + /** + * The id of the price to add to the subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun priceId(): String? = priceId.getNullable("price_id") - override fun visitGroupedAllocation( - groupedAllocation: NewSubscriptionGroupedAllocationPrice - ) = groupedAllocation.validity() + /** + * Returns the raw JSON value of [replacesPriceId]. + * + * Unlike [replacesPriceId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("replaces_price_id") + @ExcludeMissing + fun _replacesPriceId(): JsonField = replacesPriceId - override fun visitBulkWithProration( - bulkWithProration: NewSubscriptionBulkWithProrationPrice - ) = bulkWithProration.validity() + /** + * Returns the raw JSON value of [allocationPrice]. + * + * Unlike [allocationPrice], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("allocation_price") + @ExcludeMissing + fun _allocationPrice(): JsonField = allocationPrice - override fun visitGroupedWithProratedMinimum( - groupedWithProratedMinimum: - NewSubscriptionGroupedWithProratedMinimumPrice - ) = groupedWithProratedMinimum.validity() + /** + * Returns the raw JSON value of [discounts]. + * + * Unlike [discounts], this method doesn't throw if the JSON field has an unexpected type. + */ + @Deprecated("deprecated") + @JsonProperty("discounts") + @ExcludeMissing + fun _discounts(): JsonField> = discounts - override fun visitGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice - ) = groupedWithMeteredMinimum.validity() + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId - override fun visitGroupedWithMinMaxThresholds( - groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds - ) = groupedWithMinMaxThresholds.validity() + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - override fun visitMatrixWithDisplayName( - matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice - ) = matrixWithDisplayName.validity() + /** + * Returns the raw JSON value of [maximumAmount]. + * + * Unlike [maximumAmount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @Deprecated("deprecated") + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount - override fun visitGroupedTieredPackage( - groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice - ) = groupedTieredPackage.validity() + /** + * Returns the raw JSON value of [minimumAmount]. + * + * Unlike [minimumAmount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @Deprecated("deprecated") + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount - override fun visitMaxGroupTieredPackage( - maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice - ) = maxGroupTieredPackage.validity() + /** + * Returns the raw JSON value of [price]. + * + * Unlike [price], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("price") @ExcludeMissing fun _price(): JsonField = price - override fun visitScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: - NewSubscriptionScalableMatrixWithUnitPricingPrice - ) = scalableMatrixWithUnitPricing.validity() + /** + * Returns the raw JSON value of [priceId]. + * + * Unlike [priceId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId - override fun visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: - NewSubscriptionScalableMatrixWithTieredPricingPrice - ) = scalableMatrixWithTieredPricing.validity() + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - override fun visitCumulativeGroupedBulk( - cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice - ) = cumulativeGroupedBulk.validity() + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - override fun visitMinimum(minimum: NewSubscriptionMinimumCompositePrice) = - minimum.validity() + fun toBuilder() = Builder().from(this) - override fun visitEventOutput(eventOutput: EventOutput) = - eventOutput.validity() + companion object { - override fun unknown(json: JsonValue?) = 0 - } - ) + /** + * Returns a mutable builder for constructing an instance of [ReplacePrice]. + * + * The following fields are required: + * ```kotlin + * .replacesPriceId() + * ``` + */ + fun builder() = Builder() + } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** A builder for [ReplacePrice]. */ + class Builder internal constructor() { - return other is Price && - unit == other.unit && - tiered == other.tiered && - bulk == other.bulk && - package_ == other.package_ && - matrix == other.matrix && - thresholdTotalAmount == other.thresholdTotalAmount && - tieredPackage == other.tieredPackage && - tieredWithMinimum == other.tieredWithMinimum && - groupedTiered == other.groupedTiered && - tieredPackageWithMinimum == other.tieredPackageWithMinimum && - packageWithAllocation == other.packageWithAllocation && - unitWithPercent == other.unitWithPercent && - matrixWithAllocation == other.matrixWithAllocation && - tieredWithProration == other.tieredWithProration && - unitWithProration == other.unitWithProration && - groupedAllocation == other.groupedAllocation && - bulkWithProration == other.bulkWithProration && - groupedWithProratedMinimum == other.groupedWithProratedMinimum && - groupedWithMeteredMinimum == other.groupedWithMeteredMinimum && - groupedWithMinMaxThresholds == other.groupedWithMinMaxThresholds && - matrixWithDisplayName == other.matrixWithDisplayName && - groupedTieredPackage == other.groupedTieredPackage && - maxGroupTieredPackage == other.maxGroupTieredPackage && - scalableMatrixWithUnitPricing == other.scalableMatrixWithUnitPricing && - scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && - cumulativeGroupedBulk == other.cumulativeGroupedBulk && - minimum == other.minimum && - eventOutput == other.eventOutput + private var replacesPriceId: JsonField? = null + private var allocationPrice: JsonField = JsonMissing.of() + private var discounts: JsonField>? = null + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var maximumAmount: JsonField = JsonMissing.of() + private var minimumAmount: JsonField = JsonMissing.of() + private var price: JsonField = JsonMissing.of() + private var priceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(replacePrice: ReplacePrice) = apply { + replacesPriceId = replacePrice.replacesPriceId + allocationPrice = replacePrice.allocationPrice + discounts = replacePrice.discounts.map { it.toMutableList() } + externalPriceId = replacePrice.externalPriceId + fixedPriceQuantity = replacePrice.fixedPriceQuantity + maximumAmount = replacePrice.maximumAmount + minimumAmount = replacePrice.minimumAmount + price = replacePrice.price + priceId = replacePrice.priceId + additionalProperties = replacePrice.additionalProperties.toMutableMap() } - override fun hashCode(): Int = - Objects.hash( - unit, - tiered, - bulk, - package_, - matrix, - thresholdTotalAmount, - tieredPackage, - tieredWithMinimum, - groupedTiered, - tieredPackageWithMinimum, - packageWithAllocation, - unitWithPercent, - matrixWithAllocation, - tieredWithProration, - unitWithProration, - groupedAllocation, - bulkWithProration, - groupedWithProratedMinimum, - groupedWithMeteredMinimum, - groupedWithMinMaxThresholds, - matrixWithDisplayName, - groupedTieredPackage, - maxGroupTieredPackage, - scalableMatrixWithUnitPricing, - scalableMatrixWithTieredPricing, - cumulativeGroupedBulk, - minimum, - eventOutput, - ) + /** The id of the price on the plan to replace in the subscription. */ + fun replacesPriceId(replacesPriceId: String) = + replacesPriceId(JsonField.of(replacesPriceId)) - override fun toString(): String = - when { - unit != null -> "Price{unit=$unit}" - tiered != null -> "Price{tiered=$tiered}" - bulk != null -> "Price{bulk=$bulk}" - package_ != null -> "Price{package_=$package_}" - matrix != null -> "Price{matrix=$matrix}" - thresholdTotalAmount != null -> - "Price{thresholdTotalAmount=$thresholdTotalAmount}" - tieredPackage != null -> "Price{tieredPackage=$tieredPackage}" - tieredWithMinimum != null -> "Price{tieredWithMinimum=$tieredWithMinimum}" - groupedTiered != null -> "Price{groupedTiered=$groupedTiered}" - tieredPackageWithMinimum != null -> - "Price{tieredPackageWithMinimum=$tieredPackageWithMinimum}" - packageWithAllocation != null -> - "Price{packageWithAllocation=$packageWithAllocation}" - unitWithPercent != null -> "Price{unitWithPercent=$unitWithPercent}" - matrixWithAllocation != null -> - "Price{matrixWithAllocation=$matrixWithAllocation}" - tieredWithProration != null -> "Price{tieredWithProration=$tieredWithProration}" - unitWithProration != null -> "Price{unitWithProration=$unitWithProration}" - groupedAllocation != null -> "Price{groupedAllocation=$groupedAllocation}" - bulkWithProration != null -> "Price{bulkWithProration=$bulkWithProration}" - groupedWithProratedMinimum != null -> - "Price{groupedWithProratedMinimum=$groupedWithProratedMinimum}" - groupedWithMeteredMinimum != null -> - "Price{groupedWithMeteredMinimum=$groupedWithMeteredMinimum}" - groupedWithMinMaxThresholds != null -> - "Price{groupedWithMinMaxThresholds=$groupedWithMinMaxThresholds}" - matrixWithDisplayName != null -> - "Price{matrixWithDisplayName=$matrixWithDisplayName}" - groupedTieredPackage != null -> - "Price{groupedTieredPackage=$groupedTieredPackage}" - maxGroupTieredPackage != null -> - "Price{maxGroupTieredPackage=$maxGroupTieredPackage}" - scalableMatrixWithUnitPricing != null -> - "Price{scalableMatrixWithUnitPricing=$scalableMatrixWithUnitPricing}" - scalableMatrixWithTieredPricing != null -> - "Price{scalableMatrixWithTieredPricing=$scalableMatrixWithTieredPricing}" - cumulativeGroupedBulk != null -> - "Price{cumulativeGroupedBulk=$cumulativeGroupedBulk}" - minimum != null -> "Price{minimum=$minimum}" - eventOutput != null -> "Price{eventOutput=$eventOutput}" - _json != null -> "Price{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Price") - } - - companion object { + /** + * Sets [Builder.replacesPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.replacesPriceId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun replacesPriceId(replacesPriceId: JsonField) = apply { + this.replacesPriceId = replacesPriceId + } - fun ofUnit(unit: NewSubscriptionUnitPrice) = Price(unit = unit) + /** The definition of a new allocation price to create and add to the subscription. */ + fun allocationPrice(allocationPrice: NewAllocationPrice?) = + allocationPrice(JsonField.ofNullable(allocationPrice)) - fun ofTiered(tiered: NewSubscriptionTieredPrice) = Price(tiered = tiered) + /** + * Sets [Builder.allocationPrice] to an arbitrary JSON value. + * + * You should usually call [Builder.allocationPrice] with a well-typed + * [NewAllocationPrice] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun allocationPrice(allocationPrice: JsonField) = apply { + this.allocationPrice = allocationPrice + } - fun ofBulk(bulk: NewSubscriptionBulkPrice) = Price(bulk = bulk) + /** + * [DEPRECATED] Use add_adjustments instead. The subscription's discounts for the + * replacement price. + */ + @Deprecated("deprecated") + fun discounts(discounts: List?) = + discounts(JsonField.ofNullable(discounts)) - fun ofPackage(package_: NewSubscriptionPackagePrice) = Price(package_ = package_) + /** + * Sets [Builder.discounts] to an arbitrary JSON value. + * + * You should usually call [Builder.discounts] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + @Deprecated("deprecated") + fun discounts(discounts: JsonField>) = apply { + this.discounts = discounts.map { it.toMutableList() } + } - fun ofMatrix(matrix: NewSubscriptionMatrixPrice) = Price(matrix = matrix) + /** + * Adds a single [DiscountOverride] to [discounts]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + @Deprecated("deprecated") + fun addDiscount(discount: DiscountOverride) = apply { + discounts = + (discounts ?: JsonField.of(mutableListOf())).also { + checkKnown("discounts", it).add(discount) + } + } - fun ofThresholdTotalAmount( - thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice - ) = Price(thresholdTotalAmount = thresholdTotalAmount) + /** The external price id of the price to add to the subscription. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) - fun ofTieredPackage(tieredPackage: NewSubscriptionTieredPackagePrice) = - Price(tieredPackage = tieredPackage) + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } - fun ofTieredWithMinimum(tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice) = - Price(tieredWithMinimum = tieredWithMinimum) + /** The new quantity of the price, if the price is a fixed price. */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) - fun ofGroupedTiered(groupedTiered: NewSubscriptionGroupedTieredPrice) = - Price(groupedTiered = groupedTiered) + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) - fun ofTieredPackageWithMinimum( - tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice - ) = Price(tieredPackageWithMinimum = tieredPackageWithMinimum) + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } - fun ofPackageWithAllocation( - packageWithAllocation: NewSubscriptionPackageWithAllocationPrice - ) = Price(packageWithAllocation = packageWithAllocation) + /** + * [DEPRECATED] Use add_adjustments instead. The subscription's maximum amount for the + * replacement price. + */ + @Deprecated("deprecated") + fun maximumAmount(maximumAmount: String?) = + maximumAmount(JsonField.ofNullable(maximumAmount)) - fun ofUnitWithPercent(unitWithPercent: NewSubscriptionUnitWithPercentPrice) = - Price(unitWithPercent = unitWithPercent) + /** + * Sets [Builder.maximumAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.maximumAmount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + @Deprecated("deprecated") + fun maximumAmount(maximumAmount: JsonField) = apply { + this.maximumAmount = maximumAmount + } - fun ofMatrixWithAllocation( - matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice - ) = Price(matrixWithAllocation = matrixWithAllocation) + /** + * [DEPRECATED] Use add_adjustments instead. The subscription's minimum amount for the + * replacement price. + */ + @Deprecated("deprecated") + fun minimumAmount(minimumAmount: String?) = + minimumAmount(JsonField.ofNullable(minimumAmount)) - fun ofTieredWithProration(tieredWithProration: TieredWithProration) = - Price(tieredWithProration = tieredWithProration) + /** + * Sets [Builder.minimumAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumAmount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + @Deprecated("deprecated") + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount + } - fun ofUnitWithProration(unitWithProration: NewSubscriptionUnitWithProrationPrice) = - Price(unitWithProration = unitWithProration) + /** New subscription price request body params. */ + fun price(price: Price?) = price(JsonField.ofNullable(price)) - fun ofGroupedAllocation(groupedAllocation: NewSubscriptionGroupedAllocationPrice) = - Price(groupedAllocation = groupedAllocation) + /** + * Sets [Builder.price] to an arbitrary JSON value. + * + * You should usually call [Builder.price] with a well-typed [Price] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun price(price: JsonField) = apply { this.price = price } - fun ofBulkWithProration(bulkWithProration: NewSubscriptionBulkWithProrationPrice) = - Price(bulkWithProration = bulkWithProration) + /** Alias for calling [price] with `Price.ofUnit(unit)`. */ + fun price(unit: NewSubscriptionUnitPrice) = price(Price.ofUnit(unit)) - fun ofGroupedWithProratedMinimum( - groupedWithProratedMinimum: NewSubscriptionGroupedWithProratedMinimumPrice - ) = Price(groupedWithProratedMinimum = groupedWithProratedMinimum) + /** Alias for calling [price] with `Price.ofTiered(tiered)`. */ + fun price(tiered: NewSubscriptionTieredPrice) = price(Price.ofTiered(tiered)) - fun ofGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice - ) = Price(groupedWithMeteredMinimum = groupedWithMeteredMinimum) + /** Alias for calling [price] with `Price.ofBulk(bulk)`. */ + fun price(bulk: NewSubscriptionBulkPrice) = price(Price.ofBulk(bulk)) - fun ofGroupedWithMinMaxThresholds( - groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds - ) = Price(groupedWithMinMaxThresholds = groupedWithMinMaxThresholds) + /** Alias for calling [price] with `Price.ofPackage(package_)`. */ + fun price(package_: NewSubscriptionPackagePrice) = price(Price.ofPackage(package_)) - fun ofMatrixWithDisplayName( - matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice - ) = Price(matrixWithDisplayName = matrixWithDisplayName) + /** Alias for calling [price] with `Price.ofMatrix(matrix)`. */ + fun price(matrix: NewSubscriptionMatrixPrice) = price(Price.ofMatrix(matrix)) - fun ofGroupedTieredPackage( - groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice - ) = Price(groupedTieredPackage = groupedTieredPackage) + /** + * Alias for calling [price] with `Price.ofThresholdTotalAmount(thresholdTotalAmount)`. + */ + fun price(thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice) = + price(Price.ofThresholdTotalAmount(thresholdTotalAmount)) - fun ofMaxGroupTieredPackage( - maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice - ) = Price(maxGroupTieredPackage = maxGroupTieredPackage) + /** Alias for calling [price] with `Price.ofTieredPackage(tieredPackage)`. */ + fun price(tieredPackage: NewSubscriptionTieredPackagePrice) = + price(Price.ofTieredPackage(tieredPackage)) - fun ofScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: NewSubscriptionScalableMatrixWithUnitPricingPrice - ) = Price(scalableMatrixWithUnitPricing = scalableMatrixWithUnitPricing) + /** Alias for calling [price] with `Price.ofTieredWithMinimum(tieredWithMinimum)`. */ + fun price(tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice) = + price(Price.ofTieredWithMinimum(tieredWithMinimum)) - fun ofScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: - NewSubscriptionScalableMatrixWithTieredPricingPrice - ) = Price(scalableMatrixWithTieredPricing = scalableMatrixWithTieredPricing) + /** Alias for calling [price] with `Price.ofGroupedTiered(groupedTiered)`. */ + fun price(groupedTiered: NewSubscriptionGroupedTieredPrice) = + price(Price.ofGroupedTiered(groupedTiered)) - fun ofCumulativeGroupedBulk( - cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice - ) = Price(cumulativeGroupedBulk = cumulativeGroupedBulk) + /** + * Alias for calling [price] with + * `Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)`. + */ + fun price(tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice) = + price(Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)) - fun ofMinimum(minimum: NewSubscriptionMinimumCompositePrice) = - Price(minimum = minimum) + /** + * Alias for calling [price] with + * `Price.ofPackageWithAllocation(packageWithAllocation)`. + */ + fun price(packageWithAllocation: NewSubscriptionPackageWithAllocationPrice) = + price(Price.ofPackageWithAllocation(packageWithAllocation)) - fun ofEventOutput(eventOutput: EventOutput) = Price(eventOutput = eventOutput) - } + /** Alias for calling [price] with `Price.ofUnitWithPercent(unitWithPercent)`. */ + fun price(unitWithPercent: NewSubscriptionUnitWithPercentPrice) = + price(Price.ofUnitWithPercent(unitWithPercent)) /** - * An interface that defines how to map each variant of [Price] to a value of type [T]. + * Alias for calling [price] with `Price.ofMatrixWithAllocation(matrixWithAllocation)`. */ - interface Visitor { + fun price(matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice) = + price(Price.ofMatrixWithAllocation(matrixWithAllocation)) - fun visitUnit(unit: NewSubscriptionUnitPrice): T + /** + * Alias for calling [price] with `Price.ofTieredWithProration(tieredWithProration)`. + */ + fun price(tieredWithProration: Price.TieredWithProration) = + price(Price.ofTieredWithProration(tieredWithProration)) - fun visitTiered(tiered: NewSubscriptionTieredPrice): T - - fun visitBulk(bulk: NewSubscriptionBulkPrice): T + /** Alias for calling [price] with `Price.ofUnitWithProration(unitWithProration)`. */ + fun price(unitWithProration: NewSubscriptionUnitWithProrationPrice) = + price(Price.ofUnitWithProration(unitWithProration)) - fun visitPackage(package_: NewSubscriptionPackagePrice): T + /** Alias for calling [price] with `Price.ofGroupedAllocation(groupedAllocation)`. */ + fun price(groupedAllocation: NewSubscriptionGroupedAllocationPrice) = + price(Price.ofGroupedAllocation(groupedAllocation)) - fun visitMatrix(matrix: NewSubscriptionMatrixPrice): T + /** Alias for calling [price] with `Price.ofBulkWithProration(bulkWithProration)`. */ + fun price(bulkWithProration: NewSubscriptionBulkWithProrationPrice) = + price(Price.ofBulkWithProration(bulkWithProration)) - fun visitThresholdTotalAmount( - thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice - ): T + /** + * Alias for calling [price] with + * `Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)`. + */ + fun price(groupedWithProratedMinimum: NewSubscriptionGroupedWithProratedMinimumPrice) = + price(Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)) - fun visitTieredPackage(tieredPackage: NewSubscriptionTieredPackagePrice): T + /** + * Alias for calling [price] with + * `Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)`. + */ + fun price(groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice) = + price(Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)) - fun visitTieredWithMinimum( - tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice - ): T + /** + * Alias for calling [price] with + * `Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)`. + */ + fun price(groupedWithMinMaxThresholds: Price.GroupedWithMinMaxThresholds) = + price(Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)) - fun visitGroupedTiered(groupedTiered: NewSubscriptionGroupedTieredPrice): T + /** + * Alias for calling [price] with + * `Price.ofMatrixWithDisplayName(matrixWithDisplayName)`. + */ + fun price(matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice) = + price(Price.ofMatrixWithDisplayName(matrixWithDisplayName)) - fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice - ): T + /** + * Alias for calling [price] with `Price.ofGroupedTieredPackage(groupedTieredPackage)`. + */ + fun price(groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice) = + price(Price.ofGroupedTieredPackage(groupedTieredPackage)) - fun visitPackageWithAllocation( - packageWithAllocation: NewSubscriptionPackageWithAllocationPrice - ): T + /** + * Alias for calling [price] with + * `Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)`. + */ + fun price(maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice) = + price(Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)) - fun visitUnitWithPercent(unitWithPercent: NewSubscriptionUnitWithPercentPrice): T + /** + * Alias for calling [price] with + * `Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)`. + */ + fun price( + scalableMatrixWithUnitPricing: NewSubscriptionScalableMatrixWithUnitPricingPrice + ) = price(Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)) - fun visitMatrixWithAllocation( - matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice - ): T + /** + * Alias for calling [price] with + * `Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)`. + */ + fun price( + scalableMatrixWithTieredPricing: NewSubscriptionScalableMatrixWithTieredPricingPrice + ) = price(Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)) - fun visitTieredWithProration(tieredWithProration: TieredWithProration): T + /** + * Alias for calling [price] with + * `Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)`. + */ + fun price(cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice) = + price(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) - fun visitUnitWithProration( - unitWithProration: NewSubscriptionUnitWithProrationPrice - ): T + /** Alias for calling [price] with `Price.ofMinimum(minimum)`. */ + fun price(minimum: NewSubscriptionMinimumCompositePrice) = + price(Price.ofMinimum(minimum)) - fun visitGroupedAllocation( - groupedAllocation: NewSubscriptionGroupedAllocationPrice - ): T + /** Alias for calling [price] with `Price.ofPercent(percent)`. */ + fun price(percent: Price.Percent) = price(Price.ofPercent(percent)) - fun visitBulkWithProration( - bulkWithProration: NewSubscriptionBulkWithProrationPrice - ): T + /** Alias for calling [price] with `Price.ofEventOutput(eventOutput)`. */ + fun price(eventOutput: Price.EventOutput) = price(Price.ofEventOutput(eventOutput)) - fun visitGroupedWithProratedMinimum( - groupedWithProratedMinimum: NewSubscriptionGroupedWithProratedMinimumPrice - ): T + /** The id of the price to add to the subscription. */ + fun priceId(priceId: String?) = priceId(JsonField.ofNullable(priceId)) - fun visitGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice - ): T + /** + * Sets [Builder.priceId] to an arbitrary JSON value. + * + * You should usually call [Builder.priceId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun priceId(priceId: JsonField) = apply { this.priceId = priceId } - fun visitGroupedWithMinMaxThresholds( - groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds - ): T + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun visitMatrixWithDisplayName( - matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice - ): T + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun visitGroupedTieredPackage( - groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice - ): T + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun visitMaxGroupTieredPackage( - maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice - ): T + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - fun visitScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: NewSubscriptionScalableMatrixWithUnitPricingPrice - ): T + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - fun visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: - NewSubscriptionScalableMatrixWithTieredPricingPrice - ): T + /** + * Returns an immutable instance of [ReplacePrice]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .replacesPriceId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ReplacePrice = + ReplacePrice( + checkRequired("replacesPriceId", replacesPriceId), + allocationPrice, + (discounts ?: JsonMissing.of()).map { it.toImmutable() }, + externalPriceId, + fixedPriceQuantity, + maximumAmount, + minimumAmount, + price, + priceId, + additionalProperties.toMutableMap(), + ) + } - fun visitCumulativeGroupedBulk( - cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice - ): T + private var validated: Boolean = false - fun visitMinimum(minimum: NewSubscriptionMinimumCompositePrice): T + fun validate(): ReplacePrice = apply { + if (validated) { + return@apply + } - fun visitEventOutput(eventOutput: EventOutput): T + replacesPriceId() + allocationPrice()?.validate() + discounts()?.forEach { it.validate() } + externalPriceId() + fixedPriceQuantity() + maximumAmount() + minimumAmount() + price()?.validate() + priceId() + validated = true + } - /** - * Maps an unknown variant of [Price] to a value of type [T]. - * - * An instance of [Price] can contain an unknown variant if it was deserialized from - * data that doesn't match any known variant. For example, if the SDK is on an older - * version than the API, then the API may respond with new variants that the SDK is - * unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown Price: $json") - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false } - internal class Deserializer : BaseDeserializer(Price::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): Price { - val json = JsonValue.fromJsonNode(node) - val modelType = json.asObject()?.get("model_type")?.asString() + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (replacesPriceId.asKnown() == null) 0 else 1) + + (allocationPrice.asKnown()?.validity() ?: 0) + + (discounts.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (maximumAmount.asKnown() == null) 0 else 1) + + (if (minimumAmount.asKnown() == null) 0 else 1) + + (price.asKnown()?.validity() ?: 0) + + (if (priceId.asKnown() == null) 0 else 1) - when (modelType) { - "unit" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(unit = it, _json = json) } ?: Price(_json = json) - } - "tiered" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(tiered = it, _json = json) } ?: Price(_json = json) - } - "bulk" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(bulk = it, _json = json) } ?: Price(_json = json) - } - "package" -> { - return tryDeserialize( - node, + /** New subscription price request body params. */ + @JsonDeserialize(using = Price.Deserializer::class) + @JsonSerialize(using = Price.Serializer::class) + class Price + private constructor( + private val unit: NewSubscriptionUnitPrice? = null, + private val tiered: NewSubscriptionTieredPrice? = null, + private val bulk: NewSubscriptionBulkPrice? = null, + private val package_: NewSubscriptionPackagePrice? = null, + private val matrix: NewSubscriptionMatrixPrice? = null, + private val thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice? = null, + private val tieredPackage: NewSubscriptionTieredPackagePrice? = null, + private val tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice? = null, + private val groupedTiered: NewSubscriptionGroupedTieredPrice? = null, + private val tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice? = + null, + private val packageWithAllocation: NewSubscriptionPackageWithAllocationPrice? = null, + private val unitWithPercent: NewSubscriptionUnitWithPercentPrice? = null, + private val matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice? = null, + private val tieredWithProration: TieredWithProration? = null, + private val unitWithProration: NewSubscriptionUnitWithProrationPrice? = null, + private val groupedAllocation: NewSubscriptionGroupedAllocationPrice? = null, + private val bulkWithProration: NewSubscriptionBulkWithProrationPrice? = null, + private val groupedWithProratedMinimum: + NewSubscriptionGroupedWithProratedMinimumPrice? = + null, + private val groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice? = + null, + private val groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds? = null, + private val matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice? = null, + private val groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice? = null, + private val maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice? = null, + private val scalableMatrixWithUnitPricing: + NewSubscriptionScalableMatrixWithUnitPricingPrice? = + null, + private val scalableMatrixWithTieredPricing: + NewSubscriptionScalableMatrixWithTieredPricingPrice? = + null, + private val cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice? = null, + private val minimum: NewSubscriptionMinimumCompositePrice? = null, + private val percent: Percent? = null, + private val eventOutput: EventOutput? = null, + private val _json: JsonValue? = null, + ) { + + fun unit(): NewSubscriptionUnitPrice? = unit + + fun tiered(): NewSubscriptionTieredPrice? = tiered + + fun bulk(): NewSubscriptionBulkPrice? = bulk + + fun package_(): NewSubscriptionPackagePrice? = package_ + + fun matrix(): NewSubscriptionMatrixPrice? = matrix + + fun thresholdTotalAmount(): NewSubscriptionThresholdTotalAmountPrice? = + thresholdTotalAmount + + fun tieredPackage(): NewSubscriptionTieredPackagePrice? = tieredPackage + + fun tieredWithMinimum(): NewSubscriptionTieredWithMinimumPrice? = tieredWithMinimum + + fun groupedTiered(): NewSubscriptionGroupedTieredPrice? = groupedTiered + + fun tieredPackageWithMinimum(): NewSubscriptionTieredPackageWithMinimumPrice? = + tieredPackageWithMinimum + + fun packageWithAllocation(): NewSubscriptionPackageWithAllocationPrice? = + packageWithAllocation + + fun unitWithPercent(): NewSubscriptionUnitWithPercentPrice? = unitWithPercent + + fun matrixWithAllocation(): NewSubscriptionMatrixWithAllocationPrice? = + matrixWithAllocation + + fun tieredWithProration(): TieredWithProration? = tieredWithProration + + fun unitWithProration(): NewSubscriptionUnitWithProrationPrice? = unitWithProration + + fun groupedAllocation(): NewSubscriptionGroupedAllocationPrice? = groupedAllocation + + fun bulkWithProration(): NewSubscriptionBulkWithProrationPrice? = bulkWithProration + + fun groupedWithProratedMinimum(): NewSubscriptionGroupedWithProratedMinimumPrice? = + groupedWithProratedMinimum + + fun groupedWithMeteredMinimum(): NewSubscriptionGroupedWithMeteredMinimumPrice? = + groupedWithMeteredMinimum + + fun groupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds? = + groupedWithMinMaxThresholds + + fun matrixWithDisplayName(): NewSubscriptionMatrixWithDisplayNamePrice? = + matrixWithDisplayName + + fun groupedTieredPackage(): NewSubscriptionGroupedTieredPackagePrice? = + groupedTieredPackage + + fun maxGroupTieredPackage(): NewSubscriptionMaxGroupTieredPackagePrice? = + maxGroupTieredPackage + + fun scalableMatrixWithUnitPricing(): + NewSubscriptionScalableMatrixWithUnitPricingPrice? = scalableMatrixWithUnitPricing + + fun scalableMatrixWithTieredPricing(): + NewSubscriptionScalableMatrixWithTieredPricingPrice? = + scalableMatrixWithTieredPricing + + fun cumulativeGroupedBulk(): NewSubscriptionCumulativeGroupedBulkPrice? = + cumulativeGroupedBulk + + fun minimum(): NewSubscriptionMinimumCompositePrice? = minimum + + fun percent(): Percent? = percent + + fun eventOutput(): EventOutput? = eventOutput + + fun isUnit(): Boolean = unit != null + + fun isTiered(): Boolean = tiered != null + + fun isBulk(): Boolean = bulk != null + + fun isPackage(): Boolean = package_ != null + + fun isMatrix(): Boolean = matrix != null + + fun isThresholdTotalAmount(): Boolean = thresholdTotalAmount != null + + fun isTieredPackage(): Boolean = tieredPackage != null + + fun isTieredWithMinimum(): Boolean = tieredWithMinimum != null + + fun isGroupedTiered(): Boolean = groupedTiered != null + + fun isTieredPackageWithMinimum(): Boolean = tieredPackageWithMinimum != null + + fun isPackageWithAllocation(): Boolean = packageWithAllocation != null + + fun isUnitWithPercent(): Boolean = unitWithPercent != null + + fun isMatrixWithAllocation(): Boolean = matrixWithAllocation != null + + fun isTieredWithProration(): Boolean = tieredWithProration != null + + fun isUnitWithProration(): Boolean = unitWithProration != null + + fun isGroupedAllocation(): Boolean = groupedAllocation != null + + fun isBulkWithProration(): Boolean = bulkWithProration != null + + fun isGroupedWithProratedMinimum(): Boolean = groupedWithProratedMinimum != null + + fun isGroupedWithMeteredMinimum(): Boolean = groupedWithMeteredMinimum != null + + fun isGroupedWithMinMaxThresholds(): Boolean = groupedWithMinMaxThresholds != null + + fun isMatrixWithDisplayName(): Boolean = matrixWithDisplayName != null + + fun isGroupedTieredPackage(): Boolean = groupedTieredPackage != null + + fun isMaxGroupTieredPackage(): Boolean = maxGroupTieredPackage != null + + fun isScalableMatrixWithUnitPricing(): Boolean = scalableMatrixWithUnitPricing != null + + fun isScalableMatrixWithTieredPricing(): Boolean = + scalableMatrixWithTieredPricing != null + + fun isCumulativeGroupedBulk(): Boolean = cumulativeGroupedBulk != null + + fun isMinimum(): Boolean = minimum != null + + fun isPercent(): Boolean = percent != null + + fun isEventOutput(): Boolean = eventOutput != null + + fun asUnit(): NewSubscriptionUnitPrice = unit.getOrThrow("unit") + + fun asTiered(): NewSubscriptionTieredPrice = tiered.getOrThrow("tiered") + + fun asBulk(): NewSubscriptionBulkPrice = bulk.getOrThrow("bulk") + + fun asPackage(): NewSubscriptionPackagePrice = package_.getOrThrow("package_") + + fun asMatrix(): NewSubscriptionMatrixPrice = matrix.getOrThrow("matrix") + + fun asThresholdTotalAmount(): NewSubscriptionThresholdTotalAmountPrice = + thresholdTotalAmount.getOrThrow("thresholdTotalAmount") + + fun asTieredPackage(): NewSubscriptionTieredPackagePrice = + tieredPackage.getOrThrow("tieredPackage") + + fun asTieredWithMinimum(): NewSubscriptionTieredWithMinimumPrice = + tieredWithMinimum.getOrThrow("tieredWithMinimum") + + fun asGroupedTiered(): NewSubscriptionGroupedTieredPrice = + groupedTiered.getOrThrow("groupedTiered") + + fun asTieredPackageWithMinimum(): NewSubscriptionTieredPackageWithMinimumPrice = + tieredPackageWithMinimum.getOrThrow("tieredPackageWithMinimum") + + fun asPackageWithAllocation(): NewSubscriptionPackageWithAllocationPrice = + packageWithAllocation.getOrThrow("packageWithAllocation") + + fun asUnitWithPercent(): NewSubscriptionUnitWithPercentPrice = + unitWithPercent.getOrThrow("unitWithPercent") + + fun asMatrixWithAllocation(): NewSubscriptionMatrixWithAllocationPrice = + matrixWithAllocation.getOrThrow("matrixWithAllocation") + + fun asTieredWithProration(): TieredWithProration = + tieredWithProration.getOrThrow("tieredWithProration") + + fun asUnitWithProration(): NewSubscriptionUnitWithProrationPrice = + unitWithProration.getOrThrow("unitWithProration") + + fun asGroupedAllocation(): NewSubscriptionGroupedAllocationPrice = + groupedAllocation.getOrThrow("groupedAllocation") + + fun asBulkWithProration(): NewSubscriptionBulkWithProrationPrice = + bulkWithProration.getOrThrow("bulkWithProration") + + fun asGroupedWithProratedMinimum(): NewSubscriptionGroupedWithProratedMinimumPrice = + groupedWithProratedMinimum.getOrThrow("groupedWithProratedMinimum") + + fun asGroupedWithMeteredMinimum(): NewSubscriptionGroupedWithMeteredMinimumPrice = + groupedWithMeteredMinimum.getOrThrow("groupedWithMeteredMinimum") + + fun asGroupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds = + groupedWithMinMaxThresholds.getOrThrow("groupedWithMinMaxThresholds") + + fun asMatrixWithDisplayName(): NewSubscriptionMatrixWithDisplayNamePrice = + matrixWithDisplayName.getOrThrow("matrixWithDisplayName") + + fun asGroupedTieredPackage(): NewSubscriptionGroupedTieredPackagePrice = + groupedTieredPackage.getOrThrow("groupedTieredPackage") + + fun asMaxGroupTieredPackage(): NewSubscriptionMaxGroupTieredPackagePrice = + maxGroupTieredPackage.getOrThrow("maxGroupTieredPackage") + + fun asScalableMatrixWithUnitPricing(): + NewSubscriptionScalableMatrixWithUnitPricingPrice = + scalableMatrixWithUnitPricing.getOrThrow("scalableMatrixWithUnitPricing") + + fun asScalableMatrixWithTieredPricing(): + NewSubscriptionScalableMatrixWithTieredPricingPrice = + scalableMatrixWithTieredPricing.getOrThrow("scalableMatrixWithTieredPricing") + + fun asCumulativeGroupedBulk(): NewSubscriptionCumulativeGroupedBulkPrice = + cumulativeGroupedBulk.getOrThrow("cumulativeGroupedBulk") + + fun asMinimum(): NewSubscriptionMinimumCompositePrice = minimum.getOrThrow("minimum") + + fun asPercent(): Percent = percent.getOrThrow("percent") + + fun asEventOutput(): EventOutput = eventOutput.getOrThrow("eventOutput") + + fun _json(): JsonValue? = _json + + fun accept(visitor: Visitor): T = + when { + unit != null -> visitor.visitUnit(unit) + tiered != null -> visitor.visitTiered(tiered) + bulk != null -> visitor.visitBulk(bulk) + package_ != null -> visitor.visitPackage(package_) + matrix != null -> visitor.visitMatrix(matrix) + thresholdTotalAmount != null -> + visitor.visitThresholdTotalAmount(thresholdTotalAmount) + tieredPackage != null -> visitor.visitTieredPackage(tieredPackage) + tieredWithMinimum != null -> visitor.visitTieredWithMinimum(tieredWithMinimum) + groupedTiered != null -> visitor.visitGroupedTiered(groupedTiered) + tieredPackageWithMinimum != null -> + visitor.visitTieredPackageWithMinimum(tieredPackageWithMinimum) + packageWithAllocation != null -> + visitor.visitPackageWithAllocation(packageWithAllocation) + unitWithPercent != null -> visitor.visitUnitWithPercent(unitWithPercent) + matrixWithAllocation != null -> + visitor.visitMatrixWithAllocation(matrixWithAllocation) + tieredWithProration != null -> + visitor.visitTieredWithProration(tieredWithProration) + unitWithProration != null -> visitor.visitUnitWithProration(unitWithProration) + groupedAllocation != null -> visitor.visitGroupedAllocation(groupedAllocation) + bulkWithProration != null -> visitor.visitBulkWithProration(bulkWithProration) + groupedWithProratedMinimum != null -> + visitor.visitGroupedWithProratedMinimum(groupedWithProratedMinimum) + groupedWithMeteredMinimum != null -> + visitor.visitGroupedWithMeteredMinimum(groupedWithMeteredMinimum) + groupedWithMinMaxThresholds != null -> + visitor.visitGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds) + matrixWithDisplayName != null -> + visitor.visitMatrixWithDisplayName(matrixWithDisplayName) + groupedTieredPackage != null -> + visitor.visitGroupedTieredPackage(groupedTieredPackage) + maxGroupTieredPackage != null -> + visitor.visitMaxGroupTieredPackage(maxGroupTieredPackage) + scalableMatrixWithUnitPricing != null -> + visitor.visitScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing) + scalableMatrixWithTieredPricing != null -> + visitor.visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing + ) + cumulativeGroupedBulk != null -> + visitor.visitCumulativeGroupedBulk(cumulativeGroupedBulk) + minimum != null -> visitor.visitMinimum(minimum) + percent != null -> visitor.visitPercent(percent) + eventOutput != null -> visitor.visitEventOutput(eventOutput) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Price = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitUnit(unit: NewSubscriptionUnitPrice) { + unit.validate() + } + + override fun visitTiered(tiered: NewSubscriptionTieredPrice) { + tiered.validate() + } + + override fun visitBulk(bulk: NewSubscriptionBulkPrice) { + bulk.validate() + } + + override fun visitPackage(package_: NewSubscriptionPackagePrice) { + package_.validate() + } + + override fun visitMatrix(matrix: NewSubscriptionMatrixPrice) { + matrix.validate() + } + + override fun visitThresholdTotalAmount( + thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice + ) { + thresholdTotalAmount.validate() + } + + override fun visitTieredPackage( + tieredPackage: NewSubscriptionTieredPackagePrice + ) { + tieredPackage.validate() + } + + override fun visitTieredWithMinimum( + tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice + ) { + tieredWithMinimum.validate() + } + + override fun visitGroupedTiered( + groupedTiered: NewSubscriptionGroupedTieredPrice + ) { + groupedTiered.validate() + } + + override fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice + ) { + tieredPackageWithMinimum.validate() + } + + override fun visitPackageWithAllocation( + packageWithAllocation: NewSubscriptionPackageWithAllocationPrice + ) { + packageWithAllocation.validate() + } + + override fun visitUnitWithPercent( + unitWithPercent: NewSubscriptionUnitWithPercentPrice + ) { + unitWithPercent.validate() + } + + override fun visitMatrixWithAllocation( + matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice + ) { + matrixWithAllocation.validate() + } + + override fun visitTieredWithProration( + tieredWithProration: TieredWithProration + ) { + tieredWithProration.validate() + } + + override fun visitUnitWithProration( + unitWithProration: NewSubscriptionUnitWithProrationPrice + ) { + unitWithProration.validate() + } + + override fun visitGroupedAllocation( + groupedAllocation: NewSubscriptionGroupedAllocationPrice + ) { + groupedAllocation.validate() + } + + override fun visitBulkWithProration( + bulkWithProration: NewSubscriptionBulkWithProrationPrice + ) { + bulkWithProration.validate() + } + + override fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: + NewSubscriptionGroupedWithProratedMinimumPrice + ) { + groupedWithProratedMinimum.validate() + } + + override fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice + ) { + groupedWithMeteredMinimum.validate() + } + + override fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) { + groupedWithMinMaxThresholds.validate() + } + + override fun visitMatrixWithDisplayName( + matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice + ) { + matrixWithDisplayName.validate() + } + + override fun visitGroupedTieredPackage( + groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice + ) { + groupedTieredPackage.validate() + } + + override fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice + ) { + maxGroupTieredPackage.validate() + } + + override fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: + NewSubscriptionScalableMatrixWithUnitPricingPrice + ) { + scalableMatrixWithUnitPricing.validate() + } + + override fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: + NewSubscriptionScalableMatrixWithTieredPricingPrice + ) { + scalableMatrixWithTieredPricing.validate() + } + + override fun visitCumulativeGroupedBulk( + cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice + ) { + cumulativeGroupedBulk.validate() + } + + override fun visitMinimum(minimum: NewSubscriptionMinimumCompositePrice) { + minimum.validate() + } + + override fun visitPercent(percent: Percent) { + percent.validate() + } + + override fun visitEventOutput(eventOutput: EventOutput) { + eventOutput.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitUnit(unit: NewSubscriptionUnitPrice) = unit.validity() + + override fun visitTiered(tiered: NewSubscriptionTieredPrice) = + tiered.validity() + + override fun visitBulk(bulk: NewSubscriptionBulkPrice) = bulk.validity() + + override fun visitPackage(package_: NewSubscriptionPackagePrice) = + package_.validity() + + override fun visitMatrix(matrix: NewSubscriptionMatrixPrice) = + matrix.validity() + + override fun visitThresholdTotalAmount( + thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice + ) = thresholdTotalAmount.validity() + + override fun visitTieredPackage( + tieredPackage: NewSubscriptionTieredPackagePrice + ) = tieredPackage.validity() + + override fun visitTieredWithMinimum( + tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice + ) = tieredWithMinimum.validity() + + override fun visitGroupedTiered( + groupedTiered: NewSubscriptionGroupedTieredPrice + ) = groupedTiered.validity() + + override fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice + ) = tieredPackageWithMinimum.validity() + + override fun visitPackageWithAllocation( + packageWithAllocation: NewSubscriptionPackageWithAllocationPrice + ) = packageWithAllocation.validity() + + override fun visitUnitWithPercent( + unitWithPercent: NewSubscriptionUnitWithPercentPrice + ) = unitWithPercent.validity() + + override fun visitMatrixWithAllocation( + matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice + ) = matrixWithAllocation.validity() + + override fun visitTieredWithProration( + tieredWithProration: TieredWithProration + ) = tieredWithProration.validity() + + override fun visitUnitWithProration( + unitWithProration: NewSubscriptionUnitWithProrationPrice + ) = unitWithProration.validity() + + override fun visitGroupedAllocation( + groupedAllocation: NewSubscriptionGroupedAllocationPrice + ) = groupedAllocation.validity() + + override fun visitBulkWithProration( + bulkWithProration: NewSubscriptionBulkWithProrationPrice + ) = bulkWithProration.validity() + + override fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: + NewSubscriptionGroupedWithProratedMinimumPrice + ) = groupedWithProratedMinimum.validity() + + override fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice + ) = groupedWithMeteredMinimum.validity() + + override fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) = groupedWithMinMaxThresholds.validity() + + override fun visitMatrixWithDisplayName( + matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice + ) = matrixWithDisplayName.validity() + + override fun visitGroupedTieredPackage( + groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice + ) = groupedTieredPackage.validity() + + override fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice + ) = maxGroupTieredPackage.validity() + + override fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: + NewSubscriptionScalableMatrixWithUnitPricingPrice + ) = scalableMatrixWithUnitPricing.validity() + + override fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: + NewSubscriptionScalableMatrixWithTieredPricingPrice + ) = scalableMatrixWithTieredPricing.validity() + + override fun visitCumulativeGroupedBulk( + cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice + ) = cumulativeGroupedBulk.validity() + + override fun visitMinimum(minimum: NewSubscriptionMinimumCompositePrice) = + minimum.validity() + + override fun visitPercent(percent: Percent) = percent.validity() + + override fun visitEventOutput(eventOutput: EventOutput) = + eventOutput.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Price && + unit == other.unit && + tiered == other.tiered && + bulk == other.bulk && + package_ == other.package_ && + matrix == other.matrix && + thresholdTotalAmount == other.thresholdTotalAmount && + tieredPackage == other.tieredPackage && + tieredWithMinimum == other.tieredWithMinimum && + groupedTiered == other.groupedTiered && + tieredPackageWithMinimum == other.tieredPackageWithMinimum && + packageWithAllocation == other.packageWithAllocation && + unitWithPercent == other.unitWithPercent && + matrixWithAllocation == other.matrixWithAllocation && + tieredWithProration == other.tieredWithProration && + unitWithProration == other.unitWithProration && + groupedAllocation == other.groupedAllocation && + bulkWithProration == other.bulkWithProration && + groupedWithProratedMinimum == other.groupedWithProratedMinimum && + groupedWithMeteredMinimum == other.groupedWithMeteredMinimum && + groupedWithMinMaxThresholds == other.groupedWithMinMaxThresholds && + matrixWithDisplayName == other.matrixWithDisplayName && + groupedTieredPackage == other.groupedTieredPackage && + maxGroupTieredPackage == other.maxGroupTieredPackage && + scalableMatrixWithUnitPricing == other.scalableMatrixWithUnitPricing && + scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && + cumulativeGroupedBulk == other.cumulativeGroupedBulk && + minimum == other.minimum && + percent == other.percent && + eventOutput == other.eventOutput + } + + override fun hashCode(): Int = + Objects.hash( + unit, + tiered, + bulk, + package_, + matrix, + thresholdTotalAmount, + tieredPackage, + tieredWithMinimum, + groupedTiered, + tieredPackageWithMinimum, + packageWithAllocation, + unitWithPercent, + matrixWithAllocation, + tieredWithProration, + unitWithProration, + groupedAllocation, + bulkWithProration, + groupedWithProratedMinimum, + groupedWithMeteredMinimum, + groupedWithMinMaxThresholds, + matrixWithDisplayName, + groupedTieredPackage, + maxGroupTieredPackage, + scalableMatrixWithUnitPricing, + scalableMatrixWithTieredPricing, + cumulativeGroupedBulk, + minimum, + percent, + eventOutput, + ) + + override fun toString(): String = + when { + unit != null -> "Price{unit=$unit}" + tiered != null -> "Price{tiered=$tiered}" + bulk != null -> "Price{bulk=$bulk}" + package_ != null -> "Price{package_=$package_}" + matrix != null -> "Price{matrix=$matrix}" + thresholdTotalAmount != null -> + "Price{thresholdTotalAmount=$thresholdTotalAmount}" + tieredPackage != null -> "Price{tieredPackage=$tieredPackage}" + tieredWithMinimum != null -> "Price{tieredWithMinimum=$tieredWithMinimum}" + groupedTiered != null -> "Price{groupedTiered=$groupedTiered}" + tieredPackageWithMinimum != null -> + "Price{tieredPackageWithMinimum=$tieredPackageWithMinimum}" + packageWithAllocation != null -> + "Price{packageWithAllocation=$packageWithAllocation}" + unitWithPercent != null -> "Price{unitWithPercent=$unitWithPercent}" + matrixWithAllocation != null -> + "Price{matrixWithAllocation=$matrixWithAllocation}" + tieredWithProration != null -> "Price{tieredWithProration=$tieredWithProration}" + unitWithProration != null -> "Price{unitWithProration=$unitWithProration}" + groupedAllocation != null -> "Price{groupedAllocation=$groupedAllocation}" + bulkWithProration != null -> "Price{bulkWithProration=$bulkWithProration}" + groupedWithProratedMinimum != null -> + "Price{groupedWithProratedMinimum=$groupedWithProratedMinimum}" + groupedWithMeteredMinimum != null -> + "Price{groupedWithMeteredMinimum=$groupedWithMeteredMinimum}" + groupedWithMinMaxThresholds != null -> + "Price{groupedWithMinMaxThresholds=$groupedWithMinMaxThresholds}" + matrixWithDisplayName != null -> + "Price{matrixWithDisplayName=$matrixWithDisplayName}" + groupedTieredPackage != null -> + "Price{groupedTieredPackage=$groupedTieredPackage}" + maxGroupTieredPackage != null -> + "Price{maxGroupTieredPackage=$maxGroupTieredPackage}" + scalableMatrixWithUnitPricing != null -> + "Price{scalableMatrixWithUnitPricing=$scalableMatrixWithUnitPricing}" + scalableMatrixWithTieredPricing != null -> + "Price{scalableMatrixWithTieredPricing=$scalableMatrixWithTieredPricing}" + cumulativeGroupedBulk != null -> + "Price{cumulativeGroupedBulk=$cumulativeGroupedBulk}" + minimum != null -> "Price{minimum=$minimum}" + percent != null -> "Price{percent=$percent}" + eventOutput != null -> "Price{eventOutput=$eventOutput}" + _json != null -> "Price{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Price") + } + + companion object { + + fun ofUnit(unit: NewSubscriptionUnitPrice) = Price(unit = unit) + + fun ofTiered(tiered: NewSubscriptionTieredPrice) = Price(tiered = tiered) + + fun ofBulk(bulk: NewSubscriptionBulkPrice) = Price(bulk = bulk) + + fun ofPackage(package_: NewSubscriptionPackagePrice) = Price(package_ = package_) + + fun ofMatrix(matrix: NewSubscriptionMatrixPrice) = Price(matrix = matrix) + + fun ofThresholdTotalAmount( + thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice + ) = Price(thresholdTotalAmount = thresholdTotalAmount) + + fun ofTieredPackage(tieredPackage: NewSubscriptionTieredPackagePrice) = + Price(tieredPackage = tieredPackage) + + fun ofTieredWithMinimum(tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice) = + Price(tieredWithMinimum = tieredWithMinimum) + + fun ofGroupedTiered(groupedTiered: NewSubscriptionGroupedTieredPrice) = + Price(groupedTiered = groupedTiered) + + fun ofTieredPackageWithMinimum( + tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice + ) = Price(tieredPackageWithMinimum = tieredPackageWithMinimum) + + fun ofPackageWithAllocation( + packageWithAllocation: NewSubscriptionPackageWithAllocationPrice + ) = Price(packageWithAllocation = packageWithAllocation) + + fun ofUnitWithPercent(unitWithPercent: NewSubscriptionUnitWithPercentPrice) = + Price(unitWithPercent = unitWithPercent) + + fun ofMatrixWithAllocation( + matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice + ) = Price(matrixWithAllocation = matrixWithAllocation) + + fun ofTieredWithProration(tieredWithProration: TieredWithProration) = + Price(tieredWithProration = tieredWithProration) + + fun ofUnitWithProration(unitWithProration: NewSubscriptionUnitWithProrationPrice) = + Price(unitWithProration = unitWithProration) + + fun ofGroupedAllocation(groupedAllocation: NewSubscriptionGroupedAllocationPrice) = + Price(groupedAllocation = groupedAllocation) + + fun ofBulkWithProration(bulkWithProration: NewSubscriptionBulkWithProrationPrice) = + Price(bulkWithProration = bulkWithProration) + + fun ofGroupedWithProratedMinimum( + groupedWithProratedMinimum: NewSubscriptionGroupedWithProratedMinimumPrice + ) = Price(groupedWithProratedMinimum = groupedWithProratedMinimum) + + fun ofGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice + ) = Price(groupedWithMeteredMinimum = groupedWithMeteredMinimum) + + fun ofGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) = Price(groupedWithMinMaxThresholds = groupedWithMinMaxThresholds) + + fun ofMatrixWithDisplayName( + matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice + ) = Price(matrixWithDisplayName = matrixWithDisplayName) + + fun ofGroupedTieredPackage( + groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice + ) = Price(groupedTieredPackage = groupedTieredPackage) + + fun ofMaxGroupTieredPackage( + maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice + ) = Price(maxGroupTieredPackage = maxGroupTieredPackage) + + fun ofScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: NewSubscriptionScalableMatrixWithUnitPricingPrice + ) = Price(scalableMatrixWithUnitPricing = scalableMatrixWithUnitPricing) + + fun ofScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: + NewSubscriptionScalableMatrixWithTieredPricingPrice + ) = Price(scalableMatrixWithTieredPricing = scalableMatrixWithTieredPricing) + + fun ofCumulativeGroupedBulk( + cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice + ) = Price(cumulativeGroupedBulk = cumulativeGroupedBulk) + + fun ofMinimum(minimum: NewSubscriptionMinimumCompositePrice) = + Price(minimum = minimum) + + fun ofPercent(percent: Percent) = Price(percent = percent) + + fun ofEventOutput(eventOutput: EventOutput) = Price(eventOutput = eventOutput) + } + + /** + * An interface that defines how to map each variant of [Price] to a value of type [T]. + */ + interface Visitor { + + fun visitUnit(unit: NewSubscriptionUnitPrice): T + + fun visitTiered(tiered: NewSubscriptionTieredPrice): T + + fun visitBulk(bulk: NewSubscriptionBulkPrice): T + + fun visitPackage(package_: NewSubscriptionPackagePrice): T + + fun visitMatrix(matrix: NewSubscriptionMatrixPrice): T + + fun visitThresholdTotalAmount( + thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice + ): T + + fun visitTieredPackage(tieredPackage: NewSubscriptionTieredPackagePrice): T + + fun visitTieredWithMinimum( + tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice + ): T + + fun visitGroupedTiered(groupedTiered: NewSubscriptionGroupedTieredPrice): T + + fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice + ): T + + fun visitPackageWithAllocation( + packageWithAllocation: NewSubscriptionPackageWithAllocationPrice + ): T + + fun visitUnitWithPercent(unitWithPercent: NewSubscriptionUnitWithPercentPrice): T + + fun visitMatrixWithAllocation( + matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice + ): T + + fun visitTieredWithProration(tieredWithProration: TieredWithProration): T + + fun visitUnitWithProration( + unitWithProration: NewSubscriptionUnitWithProrationPrice + ): T + + fun visitGroupedAllocation( + groupedAllocation: NewSubscriptionGroupedAllocationPrice + ): T + + fun visitBulkWithProration( + bulkWithProration: NewSubscriptionBulkWithProrationPrice + ): T + + fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: NewSubscriptionGroupedWithProratedMinimumPrice + ): T + + fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice + ): T + + fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ): T + + fun visitMatrixWithDisplayName( + matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice + ): T + + fun visitGroupedTieredPackage( + groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice + ): T + + fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice + ): T + + fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: NewSubscriptionScalableMatrixWithUnitPricingPrice + ): T + + fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: + NewSubscriptionScalableMatrixWithTieredPricingPrice + ): T + + fun visitCumulativeGroupedBulk( + cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice + ): T + + fun visitMinimum(minimum: NewSubscriptionMinimumCompositePrice): T + + fun visitPercent(percent: Percent): T + + fun visitEventOutput(eventOutput: EventOutput): T + + /** + * Maps an unknown variant of [Price] to a value of type [T]. + * + * An instance of [Price] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is + * unaware of. + * + * @throws OrbInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw OrbInvalidDataException("Unknown Price: $json") + } + } + + internal class Deserializer : BaseDeserializer(Price::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Price { + val json = JsonValue.fromJsonNode(node) + val modelType = json.asObject()?.get("model_type")?.asString() + + when (modelType) { + "unit" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(unit = it, _json = json) } ?: Price(_json = json) + } + "tiered" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(tiered = it, _json = json) } ?: Price(_json = json) + } + "bulk" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(bulk = it, _json = json) } ?: Price(_json = json) + } + "package" -> { + return tryDeserialize( + node, jacksonTypeRef(), ) - ?.let { Price(package_ = it, _json = json) } ?: Price(_json = json) + ?.let { Price(package_ = it, _json = json) } ?: Price(_json = json) + } + "matrix" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(matrix = it, _json = json) } ?: Price(_json = json) + } + "threshold_total_amount" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(thresholdTotalAmount = it, _json = json) } + ?: Price(_json = json) + } + "tiered_package" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(tieredPackage = it, _json = json) } + ?: Price(_json = json) + } + "tiered_with_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(tieredWithMinimum = it, _json = json) } + ?: Price(_json = json) + } + "grouped_tiered" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedTiered = it, _json = json) } + ?: Price(_json = json) + } + "tiered_package_with_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(tieredPackageWithMinimum = it, _json = json) } + ?: Price(_json = json) + } + "package_with_allocation" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(packageWithAllocation = it, _json = json) } + ?: Price(_json = json) + } + "unit_with_percent" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(unitWithPercent = it, _json = json) } + ?: Price(_json = json) + } + "matrix_with_allocation" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(matrixWithAllocation = it, _json = json) } + ?: Price(_json = json) + } + "tiered_with_proration" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(tieredWithProration = it, _json = json) } + ?: Price(_json = json) + } + "unit_with_proration" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(unitWithProration = it, _json = json) } + ?: Price(_json = json) + } + "grouped_allocation" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedAllocation = it, _json = json) } + ?: Price(_json = json) + } + "bulk_with_proration" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(bulkWithProration = it, _json = json) } + ?: Price(_json = json) + } + "grouped_with_prorated_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedWithProratedMinimum = it, _json = json) } + ?: Price(_json = json) + } + "grouped_with_metered_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedWithMeteredMinimum = it, _json = json) } + ?: Price(_json = json) + } + "grouped_with_min_max_thresholds" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedWithMinMaxThresholds = it, _json = json) } + ?: Price(_json = json) + } + "matrix_with_display_name" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(matrixWithDisplayName = it, _json = json) } + ?: Price(_json = json) + } + "grouped_tiered_package" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedTieredPackage = it, _json = json) } + ?: Price(_json = json) + } + "max_group_tiered_package" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(maxGroupTieredPackage = it, _json = json) } + ?: Price(_json = json) + } + "scalable_matrix_with_unit_pricing" -> { + return tryDeserialize( + node, + jacksonTypeRef< + NewSubscriptionScalableMatrixWithUnitPricingPrice + >(), + ) + ?.let { Price(scalableMatrixWithUnitPricing = it, _json = json) } + ?: Price(_json = json) + } + "scalable_matrix_with_tiered_pricing" -> { + return tryDeserialize( + node, + jacksonTypeRef< + NewSubscriptionScalableMatrixWithTieredPricingPrice + >(), + ) + ?.let { Price(scalableMatrixWithTieredPricing = it, _json = json) } + ?: Price(_json = json) + } + "cumulative_grouped_bulk" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(cumulativeGroupedBulk = it, _json = json) } + ?: Price(_json = json) + } + "minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(minimum = it, _json = json) } ?: Price(_json = json) + } + "percent" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(percent = it, _json = json) + } ?: Price(_json = json) + } + "event_output" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(eventOutput = it, _json = json) + } ?: Price(_json = json) + } + } + + return Price(_json = json) + } + } + + internal class Serializer : BaseSerializer(Price::class) { + + override fun serialize( + value: Price, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.unit != null -> generator.writeObject(value.unit) + value.tiered != null -> generator.writeObject(value.tiered) + value.bulk != null -> generator.writeObject(value.bulk) + value.package_ != null -> generator.writeObject(value.package_) + value.matrix != null -> generator.writeObject(value.matrix) + value.thresholdTotalAmount != null -> + generator.writeObject(value.thresholdTotalAmount) + value.tieredPackage != null -> generator.writeObject(value.tieredPackage) + value.tieredWithMinimum != null -> + generator.writeObject(value.tieredWithMinimum) + value.groupedTiered != null -> generator.writeObject(value.groupedTiered) + value.tieredPackageWithMinimum != null -> + generator.writeObject(value.tieredPackageWithMinimum) + value.packageWithAllocation != null -> + generator.writeObject(value.packageWithAllocation) + value.unitWithPercent != null -> + generator.writeObject(value.unitWithPercent) + value.matrixWithAllocation != null -> + generator.writeObject(value.matrixWithAllocation) + value.tieredWithProration != null -> + generator.writeObject(value.tieredWithProration) + value.unitWithProration != null -> + generator.writeObject(value.unitWithProration) + value.groupedAllocation != null -> + generator.writeObject(value.groupedAllocation) + value.bulkWithProration != null -> + generator.writeObject(value.bulkWithProration) + value.groupedWithProratedMinimum != null -> + generator.writeObject(value.groupedWithProratedMinimum) + value.groupedWithMeteredMinimum != null -> + generator.writeObject(value.groupedWithMeteredMinimum) + value.groupedWithMinMaxThresholds != null -> + generator.writeObject(value.groupedWithMinMaxThresholds) + value.matrixWithDisplayName != null -> + generator.writeObject(value.matrixWithDisplayName) + value.groupedTieredPackage != null -> + generator.writeObject(value.groupedTieredPackage) + value.maxGroupTieredPackage != null -> + generator.writeObject(value.maxGroupTieredPackage) + value.scalableMatrixWithUnitPricing != null -> + generator.writeObject(value.scalableMatrixWithUnitPricing) + value.scalableMatrixWithTieredPricing != null -> + generator.writeObject(value.scalableMatrixWithTieredPricing) + value.cumulativeGroupedBulk != null -> + generator.writeObject(value.cumulativeGroupedBulk) + value.minimum != null -> generator.writeObject(value.minimum) + value.percent != null -> generator.writeObject(value.percent) + value.eventOutput != null -> generator.writeObject(value.eventOutput) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Price") + } + } + } + + class TieredWithProration + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val tieredWithProrationConfig: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("tiered_with_proration_config") + @ExcludeMissing + tieredWithProrationConfig: JsonField = + JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + modelType, + name, + tieredWithProrationConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("tiered_with_proration") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * Configuration for tiered_with_proration pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun tieredWithProrationConfig(): TieredWithProrationConfig = + tieredWithProrationConfig.getRequired("tiered_with_proration_config") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = billableMetricId.getNullable("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + invoiceGroupingKey.getNullable("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [tieredWithProrationConfig]. + * + * Unlike [tieredWithProrationConfig], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("tiered_with_proration_config") + @ExcludeMissing + fun _tieredWithProrationConfig(): JsonField = + tieredWithProrationConfig + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [TieredWithProration]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .name() + * .tieredWithProrationConfig() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [TieredWithProration]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonValue = JsonValue.from("tiered_with_proration") + private var name: JsonField? = null + private var tieredWithProrationConfig: JsonField? = + null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(tieredWithProration: TieredWithProration) = apply { + cadence = tieredWithProration.cadence + itemId = tieredWithProration.itemId + modelType = tieredWithProration.modelType + name = tieredWithProration.name + tieredWithProrationConfig = tieredWithProration.tieredWithProrationConfig + billableMetricId = tieredWithProration.billableMetricId + billedInAdvance = tieredWithProration.billedInAdvance + billingCycleConfiguration = tieredWithProration.billingCycleConfiguration + conversionRate = tieredWithProration.conversionRate + conversionRateConfig = tieredWithProration.conversionRateConfig + currency = tieredWithProration.currency + dimensionalPriceConfiguration = + tieredWithProration.dimensionalPriceConfiguration + externalPriceId = tieredWithProration.externalPriceId + fixedPriceQuantity = tieredWithProration.fixedPriceQuantity + invoiceGroupingKey = tieredWithProration.invoiceGroupingKey + invoicingCycleConfiguration = + tieredWithProration.invoicingCycleConfiguration + metadata = tieredWithProration.metadata + referenceId = tieredWithProration.referenceId + additionalProperties = + tieredWithProration.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("tiered_with_proration") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for tiered_with_proration pricing */ + fun tieredWithProrationConfig( + tieredWithProrationConfig: TieredWithProrationConfig + ) = tieredWithProrationConfig(JsonField.of(tieredWithProrationConfig)) + + /** + * Sets [Builder.tieredWithProrationConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.tieredWithProrationConfig] with a well-typed + * [TieredWithProrationConfig] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun tieredWithProrationConfig( + tieredWithProrationConfig: JsonField + ) = apply { this.tieredWithProrationConfig = tieredWithProrationConfig } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [TieredWithProration]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .name() + * .tieredWithProrationConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TieredWithProration = + TieredWithProration( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + modelType, + checkRequired("name", name), + checkRequired("tieredWithProrationConfig", tieredWithProrationConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TieredWithProration = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + _modelType().let { + if (it != JsonValue.from("tiered_with_proration")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + tieredWithProrationConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + modelType.let { + if (it == JsonValue.from("tiered_with_proration")) 1 else 0 + } + + (if (name.asKnown() == null) 0 else 1) + + (tieredWithProrationConfig.asKnown()?.validity() ?: 0) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN } - "matrix" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(matrix = it, _json = json) } ?: Price(_json = json) + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") } - "threshold_total_amount" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(thresholdTotalAmount = it, _json = json) } - ?: Price(_json = json) + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply } - "tiered_package" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(tieredPackage = it, _json = json) } - ?: Price(_json = json) + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Configuration for tiered_with_proration pricing */ + class TieredWithProrationConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val tiers: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of() + ) : this(tiers, mutableMapOf()) + + /** + * Tiers for rating based on total usage quantities into the specified tier with + * proration + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun tiers(): List = tiers.getRequired("tiers") + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [TieredWithProrationConfig]. + * + * The following fields are required: + * ```kotlin + * .tiers() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [TieredWithProrationConfig]. */ + class Builder internal constructor() { + + private var tiers: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(tieredWithProrationConfig: TieredWithProrationConfig) = + apply { + tiers = tieredWithProrationConfig.tiers.map { it.toMutableList() } + additionalProperties = + tieredWithProrationConfig.additionalProperties.toMutableMap() + } + + /** + * Tiers for rating based on total usage quantities into the specified tier + * with proration + */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } } - "tiered_with_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(tieredWithMinimum = it, _json = json) } - ?: Price(_json = json) + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } } - "grouped_tiered" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedTiered = it, _json = json) } - ?: Price(_json = json) + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) } - "tiered_package_with_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(tieredPackageWithMinimum = it, _json = json) } - ?: Price(_json = json) + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) } - "package_with_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(packageWithAllocation = it, _json = json) } - ?: Price(_json = json) + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) } - "unit_with_percent" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(unitWithPercent = it, _json = json) } - ?: Price(_json = json) + + /** + * Returns an immutable instance of [TieredWithProrationConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TieredWithProrationConfig = + TieredWithProrationConfig( + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TieredWithProrationConfig = apply { + if (validated) { + return@apply } - "matrix_with_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(matrixWithAllocation = it, _json = json) } - ?: Price(_json = json) + + tiers().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false } - "tiered_with_proration" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(tieredWithProration = it, _json = json) } - ?: Price(_json = json) + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (tiers.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single tiered with proration tier */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val tierLowerBound: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(tierLowerBound, unitAmount, mutableMapOf()) + + /** + * Inclusive tier starting value + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun tierLowerBound(): String = + tierLowerBound.getRequired("tier_lower_bound") + + /** + * Amount per unit + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) } - "unit_with_proration" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(unitWithProration = it, _json = json) } - ?: Price(_json = json) + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Tier]. + * + * The following fields are required: + * ```kotlin + * .tierLowerBound() + * .unitAmount() + * ``` + */ + fun builder() = Builder() } - "grouped_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var tierLowerBound: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(tier: Tier) = apply { + tierLowerBound = tier.tierLowerBound + unitAmount = tier.unitAmount + additionalProperties = tier.additionalProperties.toMutableMap() + } + + /** Inclusive tier starting value */ + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + /** Amount per unit */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```kotlin + * .tierLowerBound() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("tierLowerBound", tierLowerBound), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), ) - ?.let { Price(groupedAllocation = it, _json = json) } - ?: Price(_json = json) } - "bulk_with_proration" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(bulkWithProration = it, _json = json) } - ?: Price(_json = json) + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + tierLowerBound() + unitAmount() + validated = true } - "grouped_with_prorated_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedWithProratedMinimum = it, _json = json) } - ?: Price(_json = json) + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (tierLowerBound.asKnown() == null) 0 else 1) + + (if (unitAmount.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + tierLowerBound == other.tierLowerBound && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties } - "grouped_with_metered_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedWithMeteredMinimum = it, _json = json) } - ?: Price(_json = json) + + private val hashCode: Int by lazy { + Objects.hash(tierLowerBound, unitAmount, additionalProperties) } - "grouped_with_min_max_thresholds" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedWithMinMaxThresholds = it, _json = json) } - ?: Price(_json = json) + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - "matrix_with_display_name" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(matrixWithDisplayName = it, _json = json) } - ?: Price(_json = json) + + return other is TieredWithProrationConfig && + tiers == other.tiers && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(tiers, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TieredWithProrationConfig{tiers=$tiers, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() } - "grouped_tiered_package" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedTieredPackage = it, _json = json) } - ?: Price(_json = json) + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) } - "max_group_tiered_package" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(maxGroupTieredPackage = it, _json = json) } - ?: Price(_json = json) + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) } - "scalable_matrix_with_unit_pricing" -> { - return tryDeserialize( - node, - jacksonTypeRef< - NewSubscriptionScalableMatrixWithUnitPricingPrice - >(), - ) - ?.let { Price(scalableMatrixWithUnitPricing = it, _json = json) } - ?: Price(_json = json) + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) } - "scalable_matrix_with_tiered_pricing" -> { - return tryDeserialize( - node, - jacksonTypeRef< - NewSubscriptionScalableMatrixWithTieredPricingPrice - >(), - ) - ?.let { Price(scalableMatrixWithTieredPricing = it, _json = json) } - ?: Price(_json = json) + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply } - "cumulative_grouped_bulk" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(cumulativeGroupedBulk = it, _json = json) } - ?: Price(_json = json) + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false } - "minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(minimum = it, _json = json) } ?: Price(_json = json) + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() } - "event_output" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(eventOutput = it, _json = json) - } ?: Price(_json = json) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } + + return other is Metadata && + additionalProperties == other.additionalProperties } - return Price(_json = json) - } - } + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - internal class Serializer : BaseSerializer(Price::class) { + override fun hashCode(): Int = hashCode - override fun serialize( - value: Price, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unit != null -> generator.writeObject(value.unit) - value.tiered != null -> generator.writeObject(value.tiered) - value.bulk != null -> generator.writeObject(value.bulk) - value.package_ != null -> generator.writeObject(value.package_) - value.matrix != null -> generator.writeObject(value.matrix) - value.thresholdTotalAmount != null -> - generator.writeObject(value.thresholdTotalAmount) - value.tieredPackage != null -> generator.writeObject(value.tieredPackage) - value.tieredWithMinimum != null -> - generator.writeObject(value.tieredWithMinimum) - value.groupedTiered != null -> generator.writeObject(value.groupedTiered) - value.tieredPackageWithMinimum != null -> - generator.writeObject(value.tieredPackageWithMinimum) - value.packageWithAllocation != null -> - generator.writeObject(value.packageWithAllocation) - value.unitWithPercent != null -> - generator.writeObject(value.unitWithPercent) - value.matrixWithAllocation != null -> - generator.writeObject(value.matrixWithAllocation) - value.tieredWithProration != null -> - generator.writeObject(value.tieredWithProration) - value.unitWithProration != null -> - generator.writeObject(value.unitWithProration) - value.groupedAllocation != null -> - generator.writeObject(value.groupedAllocation) - value.bulkWithProration != null -> - generator.writeObject(value.bulkWithProration) - value.groupedWithProratedMinimum != null -> - generator.writeObject(value.groupedWithProratedMinimum) - value.groupedWithMeteredMinimum != null -> - generator.writeObject(value.groupedWithMeteredMinimum) - value.groupedWithMinMaxThresholds != null -> - generator.writeObject(value.groupedWithMinMaxThresholds) - value.matrixWithDisplayName != null -> - generator.writeObject(value.matrixWithDisplayName) - value.groupedTieredPackage != null -> - generator.writeObject(value.groupedTieredPackage) - value.maxGroupTieredPackage != null -> - generator.writeObject(value.maxGroupTieredPackage) - value.scalableMatrixWithUnitPricing != null -> - generator.writeObject(value.scalableMatrixWithUnitPricing) - value.scalableMatrixWithTieredPricing != null -> - generator.writeObject(value.scalableMatrixWithTieredPricing) - value.cumulativeGroupedBulk != null -> - generator.writeObject(value.cumulativeGroupedBulk) - value.minimum != null -> generator.writeObject(value.minimum) - value.eventOutput != null -> generator.writeObject(value.eventOutput) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Price") + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } + + return other is TieredWithProration && + cadence == other.cadence && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + tieredWithProrationConfig == other.tieredWithProrationConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + modelType, + name, + tieredWithProrationConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties, + ) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TieredWithProration{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredWithProrationConfig=$tieredWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class TieredWithProration + class GroupedWithMinMaxThresholds @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, + private val groupedWithMinMaxThresholdsConfig: + JsonField, private val itemId: JsonField, private val modelType: JsonValue, private val name: JsonField, - private val tieredWithProrationConfig: JsonField, private val billableMetricId: JsonField, private val billedInAdvance: JsonField, private val billingCycleConfiguration: JsonField, @@ -13714,6 +17059,11 @@ private constructor( @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), + @JsonProperty("grouped_with_min_max_thresholds_config") + @ExcludeMissing + groupedWithMinMaxThresholdsConfig: + JsonField = + JsonMissing.of(), @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), @@ -13723,10 +17073,6 @@ private constructor( @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("tiered_with_proration_config") - @ExcludeMissing - tieredWithProrationConfig: JsonField = - JsonMissing.of(), @JsonProperty("billable_metric_id") @ExcludeMissing billableMetricId: JsonField = JsonMissing.of(), @@ -13771,10 +17117,10 @@ private constructor( referenceId: JsonField = JsonMissing.of(), ) : this( cadence, + groupedWithMinMaxThresholdsConfig, itemId, modelType, name, - tieredWithProrationConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -13800,6 +17146,18 @@ private constructor( */ fun cadence(): Cadence = cadence.getRequired("cadence") + /** + * Configuration for grouped_with_min_max_thresholds pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupedWithMinMaxThresholdsConfig(): GroupedWithMinMaxThresholdsConfig = + groupedWithMinMaxThresholdsConfig.getRequired( + "grouped_with_min_max_thresholds_config" + ) + /** * The id of the item the price will be associated with. * @@ -13814,7 +17172,7 @@ private constructor( * * Expected to always return the following: * ```kotlin - * JsonValue.from("tiered_with_proration") + * JsonValue.from("grouped_with_min_max_thresholds") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -13831,16 +17189,6 @@ private constructor( */ fun name(): String = name.getRequired("name") - /** - * Configuration for tiered_with_proration pricing - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun tieredWithProrationConfig(): TieredWithProrationConfig = - tieredWithProrationConfig.getRequired("tiered_with_proration_config") - /** * The id of the billable metric for the price. Only needed if the price is * usage-based. @@ -13970,6 +17318,17 @@ private constructor( @ExcludeMissing fun _cadence(): JsonField = cadence + /** + * Returns the raw JSON value of [groupedWithMinMaxThresholdsConfig]. + * + * Unlike [groupedWithMinMaxThresholdsConfig], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("grouped_with_min_max_thresholds_config") + @ExcludeMissing + fun _groupedWithMinMaxThresholdsConfig(): + JsonField = groupedWithMinMaxThresholdsConfig + /** * Returns the raw JSON value of [itemId]. * @@ -13986,17 +17345,6 @@ private constructor( */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - /** - * Returns the raw JSON value of [tieredWithProrationConfig]. - * - * Unlike [tieredWithProrationConfig], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("tiered_with_proration_config") - @ExcludeMissing - fun _tieredWithProrationConfig(): JsonField = - tieredWithProrationConfig - /** * Returns the raw JSON value of [billableMetricId]. * @@ -14146,28 +17494,30 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [TieredWithProration]. + * [GroupedWithMinMaxThresholds]. * * The following fields are required: * ```kotlin * .cadence() + * .groupedWithMinMaxThresholdsConfig() * .itemId() * .name() - * .tieredWithProrationConfig() * ``` */ fun builder() = Builder() } - /** A builder for [TieredWithProration]. */ + /** A builder for [GroupedWithMinMaxThresholds]. */ class Builder internal constructor() { private var cadence: JsonField? = null + private var groupedWithMinMaxThresholdsConfig: + JsonField? = + null private var itemId: JsonField? = null - private var modelType: JsonValue = JsonValue.from("tiered_with_proration") + private var modelType: JsonValue = + JsonValue.from("grouped_with_min_max_thresholds") private var name: JsonField? = null - private var tieredWithProrationConfig: JsonField? = - null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() private var billingCycleConfiguration: JsonField = @@ -14189,30 +17539,33 @@ private constructor( private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(tieredWithProration: TieredWithProration) = apply { - cadence = tieredWithProration.cadence - itemId = tieredWithProration.itemId - modelType = tieredWithProration.modelType - name = tieredWithProration.name - tieredWithProrationConfig = tieredWithProration.tieredWithProrationConfig - billableMetricId = tieredWithProration.billableMetricId - billedInAdvance = tieredWithProration.billedInAdvance - billingCycleConfiguration = tieredWithProration.billingCycleConfiguration - conversionRate = tieredWithProration.conversionRate - conversionRateConfig = tieredWithProration.conversionRateConfig - currency = tieredWithProration.currency - dimensionalPriceConfiguration = - tieredWithProration.dimensionalPriceConfiguration - externalPriceId = tieredWithProration.externalPriceId - fixedPriceQuantity = tieredWithProration.fixedPriceQuantity - invoiceGroupingKey = tieredWithProration.invoiceGroupingKey - invoicingCycleConfiguration = - tieredWithProration.invoicingCycleConfiguration - metadata = tieredWithProration.metadata - referenceId = tieredWithProration.referenceId - additionalProperties = - tieredWithProration.additionalProperties.toMutableMap() - } + internal fun from(groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds) = + apply { + cadence = groupedWithMinMaxThresholds.cadence + groupedWithMinMaxThresholdsConfig = + groupedWithMinMaxThresholds.groupedWithMinMaxThresholdsConfig + itemId = groupedWithMinMaxThresholds.itemId + modelType = groupedWithMinMaxThresholds.modelType + name = groupedWithMinMaxThresholds.name + billableMetricId = groupedWithMinMaxThresholds.billableMetricId + billedInAdvance = groupedWithMinMaxThresholds.billedInAdvance + billingCycleConfiguration = + groupedWithMinMaxThresholds.billingCycleConfiguration + conversionRate = groupedWithMinMaxThresholds.conversionRate + conversionRateConfig = groupedWithMinMaxThresholds.conversionRateConfig + currency = groupedWithMinMaxThresholds.currency + dimensionalPriceConfiguration = + groupedWithMinMaxThresholds.dimensionalPriceConfiguration + externalPriceId = groupedWithMinMaxThresholds.externalPriceId + fixedPriceQuantity = groupedWithMinMaxThresholds.fixedPriceQuantity + invoiceGroupingKey = groupedWithMinMaxThresholds.invoiceGroupingKey + invoicingCycleConfiguration = + groupedWithMinMaxThresholds.invoicingCycleConfiguration + metadata = groupedWithMinMaxThresholds.metadata + referenceId = groupedWithMinMaxThresholds.referenceId + additionalProperties = + groupedWithMinMaxThresholds.additionalProperties.toMutableMap() + } /** The cadence to bill for this price on. */ fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) @@ -14226,6 +17579,29 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + /** Configuration for grouped_with_min_max_thresholds pricing */ + fun groupedWithMinMaxThresholdsConfig( + groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + ) = + groupedWithMinMaxThresholdsConfig( + JsonField.of(groupedWithMinMaxThresholdsConfig) + ) + + /** + * Sets [Builder.groupedWithMinMaxThresholdsConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.groupedWithMinMaxThresholdsConfig] with a + * well-typed [GroupedWithMinMaxThresholdsConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun groupedWithMinMaxThresholdsConfig( + groupedWithMinMaxThresholdsConfig: + JsonField + ) = apply { + this.groupedWithMinMaxThresholdsConfig = groupedWithMinMaxThresholdsConfig + } + /** The id of the item the price will be associated with. */ fun itemId(itemId: String) = itemId(JsonField.of(itemId)) @@ -14244,7 +17620,7 @@ private constructor( * It is usually unnecessary to call this method because the field defaults to * the following: * ```kotlin - * JsonValue.from("tiered_with_proration") + * JsonValue.from("grouped_with_min_max_thresholds") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -14264,22 +17640,6 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } - /** Configuration for tiered_with_proration pricing */ - fun tieredWithProrationConfig( - tieredWithProrationConfig: TieredWithProrationConfig - ) = tieredWithProrationConfig(JsonField.of(tieredWithProrationConfig)) - - /** - * Sets [Builder.tieredWithProrationConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.tieredWithProrationConfig] with a well-typed - * [TieredWithProrationConfig] value instead. This method is primarily for - * setting the field to an undocumented or not yet supported value. - */ - fun tieredWithProrationConfig( - tieredWithProrationConfig: JsonField - ) = apply { this.tieredWithProrationConfig = tieredWithProrationConfig } - /** * The id of the billable metric for the price. Only needed if the price is * usage-based. @@ -14609,27 +17969,30 @@ private constructor( } /** - * Returns an immutable instance of [TieredWithProration]. + * Returns an immutable instance of [GroupedWithMinMaxThresholds]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```kotlin * .cadence() + * .groupedWithMinMaxThresholdsConfig() * .itemId() * .name() - * .tieredWithProrationConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): TieredWithProration = - TieredWithProration( + fun build(): GroupedWithMinMaxThresholds = + GroupedWithMinMaxThresholds( checkRequired("cadence", cadence), + checkRequired( + "groupedWithMinMaxThresholdsConfig", + groupedWithMinMaxThresholdsConfig, + ), checkRequired("itemId", itemId), modelType, checkRequired("name", name), - checkRequired("tieredWithProrationConfig", tieredWithProrationConfig), billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -14649,20 +18012,20 @@ private constructor( private var validated: Boolean = false - fun validate(): TieredWithProration = apply { + fun validate(): GroupedWithMinMaxThresholds = apply { if (validated) { return@apply } cadence().validate() + groupedWithMinMaxThresholdsConfig().validate() itemId() _modelType().let { - if (it != JsonValue.from("tiered_with_proration")) { + if (it != JsonValue.from("grouped_with_min_max_thresholds")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } name() - tieredWithProrationConfig().validate() billableMetricId() billedInAdvance() billingCycleConfiguration()?.validate() @@ -14695,12 +18058,12 @@ private constructor( */ internal fun validity(): Int = (cadence.asKnown()?.validity() ?: 0) + + (groupedWithMinMaxThresholdsConfig.asKnown()?.validity() ?: 0) + (if (itemId.asKnown() == null) 0 else 1) + modelType.let { - if (it == JsonValue.from("tiered_with_proration")) 1 else 0 + if (it == JsonValue.from("grouped_with_min_max_thresholds")) 1 else 0 } + (if (name.asKnown() == null) 0 else 1) + - (tieredWithProrationConfig.asKnown()?.validity() ?: 0) + (if (billableMetricId.asKnown() == null) 0 else 1) + (if (billedInAdvance.asKnown() == null) 0 else 1) + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + @@ -14872,419 +18235,328 @@ private constructor( override fun toString() = value.toString() } - /** Configuration for tiered_with_proration pricing */ - class TieredWithProrationConfig + /** Configuration for grouped_with_min_max_thresholds pricing */ + class GroupedWithMinMaxThresholdsConfig @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val tiers: JsonField>, + private val groupingKey: JsonField, + private val maximumCharge: JsonField, + private val minimumCharge: JsonField, + private val perUnitRate: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("tiers") + @JsonProperty("grouping_key") @ExcludeMissing - tiers: JsonField> = JsonMissing.of() - ) : this(tiers, mutableMapOf()) + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("maximum_charge") + @ExcludeMissing + maximumCharge: JsonField = JsonMissing.of(), + @JsonProperty("minimum_charge") + @ExcludeMissing + minimumCharge: JsonField = JsonMissing.of(), + @JsonProperty("per_unit_rate") + @ExcludeMissing + perUnitRate: JsonField = JsonMissing.of(), + ) : this(groupingKey, maximumCharge, minimumCharge, perUnitRate, mutableMapOf()) /** - * Tiers for rating based on total usage quantities into the specified tier with - * proration + * The event property used to group before applying thresholds * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). */ - fun tiers(): List = tiers.getRequired("tiers") + fun groupingKey(): String = groupingKey.getRequired("grouping_key") /** - * Returns the raw JSON value of [tiers]. + * The maximum amount to charge each group * - * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected - * type. + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). */ - @JsonProperty("tiers") - @ExcludeMissing - fun _tiers(): JsonField> = tiers - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [TieredWithProrationConfig]. - * - * The following fields are required: - * ```kotlin - * .tiers() - * ``` - */ - fun builder() = Builder() - } - - /** A builder for [TieredWithProrationConfig]. */ - class Builder internal constructor() { + fun maximumCharge(): String = maximumCharge.getRequired("maximum_charge") - private var tiers: JsonField>? = null - private var additionalProperties: MutableMap = - mutableMapOf() + /** + * The minimum amount to charge each group, regardless of usage + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun minimumCharge(): String = minimumCharge.getRequired("minimum_charge") - internal fun from(tieredWithProrationConfig: TieredWithProrationConfig) = - apply { - tiers = tieredWithProrationConfig.tiers.map { it.toMutableList() } - additionalProperties = - tieredWithProrationConfig.additionalProperties.toMutableMap() - } + /** + * The base price charged per group + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun perUnitRate(): String = perUnitRate.getRequired("per_unit_rate") - /** - * Tiers for rating based on total usage quantities into the specified tier - * with proration - */ - fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey - /** - * Sets [Builder.tiers] to an arbitrary JSON value. - * - * You should usually call [Builder.tiers] with a well-typed `List` - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun tiers(tiers: JsonField>) = apply { - this.tiers = tiers.map { it.toMutableList() } - } + /** + * Returns the raw JSON value of [maximumCharge]. + * + * Unlike [maximumCharge], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("maximum_charge") + @ExcludeMissing + fun _maximumCharge(): JsonField = maximumCharge - /** - * Adds a single [Tier] to [tiers]. - * - * @throws IllegalStateException if the field was previously set to a - * non-list. - */ - fun addTier(tier: Tier) = apply { - tiers = - (tiers ?: JsonField.of(mutableListOf())).also { - checkKnown("tiers", it).add(tier) - } - } + /** + * Returns the raw JSON value of [minimumCharge]. + * + * Unlike [minimumCharge], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("minimum_charge") + @ExcludeMissing + fun _minimumCharge(): JsonField = minimumCharge - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * Returns the raw JSON value of [perUnitRate]. + * + * Unlike [perUnitRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("per_unit_rate") + @ExcludeMissing + fun _perUnitRate(): JsonField = perUnitRate - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun toBuilder() = Builder().from(this) - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + companion object { /** - * Returns an immutable instance of [TieredWithProrationConfig]. - * - * Further updates to this [Builder] will not mutate the returned instance. + * Returns a mutable builder for constructing an instance of + * [GroupedWithMinMaxThresholdsConfig]. * * The following fields are required: * ```kotlin - * .tiers() + * .groupingKey() + * .maximumCharge() + * .minimumCharge() + * .perUnitRate() * ``` - * - * @throws IllegalStateException if any required field is unset. */ - fun build(): TieredWithProrationConfig = - TieredWithProrationConfig( - checkRequired("tiers", tiers).map { it.toImmutable() }, - additionalProperties.toMutableMap(), - ) + fun builder() = Builder() } - private var validated: Boolean = false - - fun validate(): TieredWithProrationConfig = apply { - if (validated) { - return@apply - } + /** A builder for [GroupedWithMinMaxThresholdsConfig]. */ + class Builder internal constructor() { - tiers().forEach { it.validate() } - validated = true - } + private var groupingKey: JsonField? = null + private var maximumCharge: JsonField? = null + private var minimumCharge: JsonField? = null + private var perUnitRate: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false + internal fun from( + groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + ) = apply { + groupingKey = groupedWithMinMaxThresholdsConfig.groupingKey + maximumCharge = groupedWithMinMaxThresholdsConfig.maximumCharge + minimumCharge = groupedWithMinMaxThresholdsConfig.minimumCharge + perUnitRate = groupedWithMinMaxThresholdsConfig.perUnitRate + additionalProperties = + groupedWithMinMaxThresholdsConfig.additionalProperties + .toMutableMap() } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (tiers.asKnown()?.sumOf { it.validity().toInt() } ?: 0) - - /** Configuration for a single tiered with proration tier */ - class Tier - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val tierLowerBound: JsonField, - private val unitAmount: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("tier_lower_bound") - @ExcludeMissing - tierLowerBound: JsonField = JsonMissing.of(), - @JsonProperty("unit_amount") - @ExcludeMissing - unitAmount: JsonField = JsonMissing.of(), - ) : this(tierLowerBound, unitAmount, mutableMapOf()) - - /** - * Inclusive tier starting value - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type - * or is unexpectedly missing or null (e.g. if the server responded with - * an unexpected value). - */ - fun tierLowerBound(): String = - tierLowerBound.getRequired("tier_lower_bound") + /** The event property used to group before applying thresholds */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) /** - * Amount per unit + * Sets [Builder.groupingKey] to an arbitrary JSON value. * - * @throws OrbInvalidDataException if the JSON field has an unexpected type - * or is unexpectedly missing or null (e.g. if the server responded with - * an unexpected value). + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. */ - fun unitAmount(): String = unitAmount.getRequired("unit_amount") + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } - /** - * Returns the raw JSON value of [tierLowerBound]. - * - * Unlike [tierLowerBound], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("tier_lower_bound") - @ExcludeMissing - fun _tierLowerBound(): JsonField = tierLowerBound + /** The maximum amount to charge each group */ + fun maximumCharge(maximumCharge: String) = + maximumCharge(JsonField.of(maximumCharge)) /** - * Returns the raw JSON value of [unitAmount]. + * Sets [Builder.maximumCharge] to an arbitrary JSON value. * - * Unlike [unitAmount], this method doesn't throw if the JSON field has an - * unexpected type. + * You should usually call [Builder.maximumCharge] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. */ - @JsonProperty("unit_amount") - @ExcludeMissing - fun _unitAmount(): JsonField = unitAmount - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [Tier]. - * - * The following fields are required: - * ```kotlin - * .tierLowerBound() - * .unitAmount() - * ``` - */ - fun builder() = Builder() - } - - /** A builder for [Tier]. */ - class Builder internal constructor() { - - private var tierLowerBound: JsonField? = null - private var unitAmount: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - internal fun from(tier: Tier) = apply { - tierLowerBound = tier.tierLowerBound - unitAmount = tier.unitAmount - additionalProperties = tier.additionalProperties.toMutableMap() - } - - /** Inclusive tier starting value */ - fun tierLowerBound(tierLowerBound: String) = - tierLowerBound(JsonField.of(tierLowerBound)) - - /** - * Sets [Builder.tierLowerBound] to an arbitrary JSON value. - * - * You should usually call [Builder.tierLowerBound] with a well-typed - * [String] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun tierLowerBound(tierLowerBound: JsonField) = apply { - this.tierLowerBound = tierLowerBound - } - - /** Amount per unit */ - fun unitAmount(unitAmount: String) = - unitAmount(JsonField.of(unitAmount)) - - /** - * Sets [Builder.unitAmount] to an arbitrary JSON value. - * - * You should usually call [Builder.unitAmount] with a well-typed - * [String] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun unitAmount(unitAmount: JsonField) = apply { - this.unitAmount = unitAmount - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Tier]. - * - * Further updates to this [Builder] will not mutate the returned - * instance. - * - * The following fields are required: - * ```kotlin - * .tierLowerBound() - * .unitAmount() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Tier = - Tier( - checkRequired("tierLowerBound", tierLowerBound), - checkRequired("unitAmount", unitAmount), - additionalProperties.toMutableMap(), - ) + fun maximumCharge(maximumCharge: JsonField) = apply { + this.maximumCharge = maximumCharge } - private var validated: Boolean = false - - fun validate(): Tier = apply { - if (validated) { - return@apply - } + /** The minimum amount to charge each group, regardless of usage */ + fun minimumCharge(minimumCharge: String) = + minimumCharge(JsonField.of(minimumCharge)) - tierLowerBound() - unitAmount() - validated = true + /** + * Sets [Builder.minimumCharge] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumCharge] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun minimumCharge(minimumCharge: JsonField) = apply { + this.minimumCharge = minimumCharge } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** The base price charged per group */ + fun perUnitRate(perUnitRate: String) = + perUnitRate(JsonField.of(perUnitRate)) /** - * Returns a score indicating how many valid values are contained in this - * object recursively. + * Sets [Builder.perUnitRate] to an arbitrary JSON value. * - * Used for best match union deserialization. + * You should usually call [Builder.perUnitRate] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. */ - internal fun validity(): Int = - (if (tierLowerBound.asKnown() == null) 0 else 1) + - (if (unitAmount.asKnown() == null) 0 else 1) + fun perUnitRate(perUnitRate: JsonField) = apply { + this.perUnitRate = perUnitRate + } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) } - return other is Tier && - tierLowerBound == other.tierLowerBound && - unitAmount == other.unitAmount && - additionalProperties == other.additionalProperties + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) } - private val hashCode: Int by lazy { - Objects.hash(tierLowerBound, unitAmount, additionalProperties) + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) } - override fun hashCode(): Int = hashCode + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - override fun toString() = - "Tier{tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + /** + * Returns an immutable instance of [GroupedWithMinMaxThresholdsConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .maximumCharge() + * .minimumCharge() + * .perUnitRate() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedWithMinMaxThresholdsConfig = + GroupedWithMinMaxThresholdsConfig( + checkRequired("groupingKey", groupingKey), + checkRequired("maximumCharge", maximumCharge), + checkRequired("minimumCharge", minimumCharge), + checkRequired("perUnitRate", perUnitRate), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GroupedWithMinMaxThresholdsConfig = apply { + if (validated) { + return@apply + } + + groupingKey() + maximumCharge() + minimumCharge() + perUnitRate() + validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (groupingKey.asKnown() == null) 0 else 1) + + (if (maximumCharge.asKnown() == null) 0 else 1) + + (if (minimumCharge.asKnown() == null) 0 else 1) + + (if (perUnitRate.asKnown() == null) 0 else 1) + override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is TieredWithProrationConfig && - tiers == other.tiers && + return other is GroupedWithMinMaxThresholdsConfig && + groupingKey == other.groupingKey && + maximumCharge == other.maximumCharge && + minimumCharge == other.minimumCharge && + perUnitRate == other.perUnitRate && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(tiers, additionalProperties) } + private val hashCode: Int by lazy { + Objects.hash( + groupingKey, + maximumCharge, + minimumCharge, + perUnitRate, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode override fun toString() = - "TieredWithProrationConfig{tiers=$tiers, additionalProperties=$additionalProperties}" + "GroupedWithMinMaxThresholdsConfig{groupingKey=$groupingKey, maximumCharge=$maximumCharge, minimumCharge=$minimumCharge, perUnitRate=$perUnitRate, additionalProperties=$additionalProperties}" } /** @@ -15401,12 +18673,13 @@ private constructor( return true } - return other is TieredWithProration && + return other is GroupedWithMinMaxThresholds && cadence == other.cadence && + groupedWithMinMaxThresholdsConfig == + other.groupedWithMinMaxThresholdsConfig && itemId == other.itemId && modelType == other.modelType && name == other.name && - tieredWithProrationConfig == other.tieredWithProrationConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && @@ -15426,10 +18699,10 @@ private constructor( private val hashCode: Int by lazy { Objects.hash( cadence, + groupedWithMinMaxThresholdsConfig, itemId, modelType, name, - tieredWithProrationConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -15450,18 +18723,17 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "TieredWithProration{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredWithProrationConfig=$tieredWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "GroupedWithMinMaxThresholds{cadence=$cadence, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class GroupedWithMinMaxThresholds + class Percent @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, - private val groupedWithMinMaxThresholdsConfig: - JsonField, private val itemId: JsonField, private val modelType: JsonValue, private val name: JsonField, + private val percentConfig: JsonField, private val billableMetricId: JsonField, private val billedInAdvance: JsonField, private val billingCycleConfiguration: JsonField, @@ -15484,11 +18756,6 @@ private constructor( @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), - @JsonProperty("grouped_with_min_max_thresholds_config") - @ExcludeMissing - groupedWithMinMaxThresholdsConfig: - JsonField = - JsonMissing.of(), @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), @@ -15498,6 +18765,9 @@ private constructor( @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("percent_config") + @ExcludeMissing + percentConfig: JsonField = JsonMissing.of(), @JsonProperty("billable_metric_id") @ExcludeMissing billableMetricId: JsonField = JsonMissing.of(), @@ -15542,10 +18812,10 @@ private constructor( referenceId: JsonField = JsonMissing.of(), ) : this( cadence, - groupedWithMinMaxThresholdsConfig, itemId, modelType, name, + percentConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -15571,18 +18841,6 @@ private constructor( */ fun cadence(): Cadence = cadence.getRequired("cadence") - /** - * Configuration for grouped_with_min_max_thresholds pricing - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun groupedWithMinMaxThresholdsConfig(): GroupedWithMinMaxThresholdsConfig = - groupedWithMinMaxThresholdsConfig.getRequired( - "grouped_with_min_max_thresholds_config" - ) - /** * The id of the item the price will be associated with. * @@ -15597,7 +18855,7 @@ private constructor( * * Expected to always return the following: * ```kotlin - * JsonValue.from("grouped_with_min_max_thresholds") + * JsonValue.from("percent") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -15614,6 +18872,15 @@ private constructor( */ fun name(): String = name.getRequired("name") + /** + * Configuration for percent pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun percentConfig(): PercentConfig = percentConfig.getRequired("percent_config") + /** * The id of the billable metric for the price. Only needed if the price is * usage-based. @@ -15743,17 +19010,6 @@ private constructor( @ExcludeMissing fun _cadence(): JsonField = cadence - /** - * Returns the raw JSON value of [groupedWithMinMaxThresholdsConfig]. - * - * Unlike [groupedWithMinMaxThresholdsConfig], this method doesn't throw if the JSON - * field has an unexpected type. - */ - @JsonProperty("grouped_with_min_max_thresholds_config") - @ExcludeMissing - fun _groupedWithMinMaxThresholdsConfig(): - JsonField = groupedWithMinMaxThresholdsConfig - /** * Returns the raw JSON value of [itemId]. * @@ -15770,6 +19026,16 @@ private constructor( */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + /** + * Returns the raw JSON value of [percentConfig]. + * + * Unlike [percentConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("percent_config") + @ExcludeMissing + fun _percentConfig(): JsonField = percentConfig + /** * Returns the raw JSON value of [billableMetricId]. * @@ -15918,79 +19184,69 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [GroupedWithMinMaxThresholds]. + * Returns a mutable builder for constructing an instance of [Percent]. * * The following fields are required: * ```kotlin * .cadence() - * .groupedWithMinMaxThresholdsConfig() * .itemId() * .name() + * .percentConfig() * ``` */ fun builder() = Builder() } - /** A builder for [GroupedWithMinMaxThresholds]. */ + /** A builder for [Percent]. */ class Builder internal constructor() { private var cadence: JsonField? = null - private var groupedWithMinMaxThresholdsConfig: - JsonField? = - null private var itemId: JsonField? = null - private var modelType: JsonValue = - JsonValue.from("grouped_with_min_max_thresholds") + private var modelType: JsonValue = JsonValue.from("percent") private var name: JsonField? = null + private var percentConfig: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() private var billingCycleConfiguration: JsonField = JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var conversionRateConfig: JsonField = - JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var dimensionalPriceConfiguration: - JsonField = - JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: - JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var referenceId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds) = - apply { - cadence = groupedWithMinMaxThresholds.cadence - groupedWithMinMaxThresholdsConfig = - groupedWithMinMaxThresholds.groupedWithMinMaxThresholdsConfig - itemId = groupedWithMinMaxThresholds.itemId - modelType = groupedWithMinMaxThresholds.modelType - name = groupedWithMinMaxThresholds.name - billableMetricId = groupedWithMinMaxThresholds.billableMetricId - billedInAdvance = groupedWithMinMaxThresholds.billedInAdvance - billingCycleConfiguration = - groupedWithMinMaxThresholds.billingCycleConfiguration - conversionRate = groupedWithMinMaxThresholds.conversionRate - conversionRateConfig = groupedWithMinMaxThresholds.conversionRateConfig - currency = groupedWithMinMaxThresholds.currency - dimensionalPriceConfiguration = - groupedWithMinMaxThresholds.dimensionalPriceConfiguration - externalPriceId = groupedWithMinMaxThresholds.externalPriceId - fixedPriceQuantity = groupedWithMinMaxThresholds.fixedPriceQuantity - invoiceGroupingKey = groupedWithMinMaxThresholds.invoiceGroupingKey - invoicingCycleConfiguration = - groupedWithMinMaxThresholds.invoicingCycleConfiguration - metadata = groupedWithMinMaxThresholds.metadata - referenceId = groupedWithMinMaxThresholds.referenceId - additionalProperties = - groupedWithMinMaxThresholds.additionalProperties.toMutableMap() - } + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(percent: Percent) = apply { + cadence = percent.cadence + itemId = percent.itemId + modelType = percent.modelType + name = percent.name + percentConfig = percent.percentConfig + billableMetricId = percent.billableMetricId + billedInAdvance = percent.billedInAdvance + billingCycleConfiguration = percent.billingCycleConfiguration + conversionRate = percent.conversionRate + conversionRateConfig = percent.conversionRateConfig + currency = percent.currency + dimensionalPriceConfiguration = percent.dimensionalPriceConfiguration + externalPriceId = percent.externalPriceId + fixedPriceQuantity = percent.fixedPriceQuantity + invoiceGroupingKey = percent.invoiceGroupingKey + invoicingCycleConfiguration = percent.invoicingCycleConfiguration + metadata = percent.metadata + referenceId = percent.referenceId + additionalProperties = percent.additionalProperties.toMutableMap() + } /** The cadence to bill for this price on. */ fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) @@ -16004,29 +19260,6 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - /** Configuration for grouped_with_min_max_thresholds pricing */ - fun groupedWithMinMaxThresholdsConfig( - groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig - ) = - groupedWithMinMaxThresholdsConfig( - JsonField.of(groupedWithMinMaxThresholdsConfig) - ) - - /** - * Sets [Builder.groupedWithMinMaxThresholdsConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.groupedWithMinMaxThresholdsConfig] with a - * well-typed [GroupedWithMinMaxThresholdsConfig] value instead. This method is - * primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun groupedWithMinMaxThresholdsConfig( - groupedWithMinMaxThresholdsConfig: - JsonField - ) = apply { - this.groupedWithMinMaxThresholdsConfig = groupedWithMinMaxThresholdsConfig - } - /** The id of the item the price will be associated with. */ fun itemId(itemId: String) = itemId(JsonField.of(itemId)) @@ -16045,7 +19278,7 @@ private constructor( * It is usually unnecessary to call this method because the field defaults to * the following: * ```kotlin - * JsonValue.from("grouped_with_min_max_thresholds") + * JsonValue.from("percent") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -16065,6 +19298,21 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } + /** Configuration for percent pricing */ + fun percentConfig(percentConfig: PercentConfig) = + percentConfig(JsonField.of(percentConfig)) + + /** + * Sets [Builder.percentConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.percentConfig] with a well-typed + * [PercentConfig] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun percentConfig(percentConfig: JsonField) = apply { + this.percentConfig = percentConfig + } + /** * The id of the billable metric for the price. Only needed if the price is * usage-based. @@ -16394,30 +19642,27 @@ private constructor( } /** - * Returns an immutable instance of [GroupedWithMinMaxThresholds]. + * Returns an immutable instance of [Percent]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```kotlin * .cadence() - * .groupedWithMinMaxThresholdsConfig() * .itemId() * .name() + * .percentConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): GroupedWithMinMaxThresholds = - GroupedWithMinMaxThresholds( + fun build(): Percent = + Percent( checkRequired("cadence", cadence), - checkRequired( - "groupedWithMinMaxThresholdsConfig", - groupedWithMinMaxThresholdsConfig, - ), checkRequired("itemId", itemId), modelType, checkRequired("name", name), + checkRequired("percentConfig", percentConfig), billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -16437,20 +19682,20 @@ private constructor( private var validated: Boolean = false - fun validate(): GroupedWithMinMaxThresholds = apply { + fun validate(): Percent = apply { if (validated) { return@apply } cadence().validate() - groupedWithMinMaxThresholdsConfig().validate() itemId() _modelType().let { - if (it != JsonValue.from("grouped_with_min_max_thresholds")) { + if (it != JsonValue.from("percent")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } name() + percentConfig().validate() billableMetricId() billedInAdvance() billingCycleConfiguration()?.validate() @@ -16483,12 +19728,10 @@ private constructor( */ internal fun validity(): Int = (cadence.asKnown()?.validity() ?: 0) + - (groupedWithMinMaxThresholdsConfig.asKnown()?.validity() ?: 0) + (if (itemId.asKnown() == null) 0 else 1) + - modelType.let { - if (it == JsonValue.from("grouped_with_min_max_thresholds")) 1 else 0 - } + + modelType.let { if (it == JsonValue.from("percent")) 1 else 0 } + (if (name.asKnown() == null) 0 else 1) + + (percentConfig.asKnown()?.validity() ?: 0) + (if (billableMetricId.asKnown() == null) 0 else 1) + (if (billedInAdvance.asKnown() == null) 0 else 1) + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + @@ -16660,108 +19903,39 @@ private constructor( override fun toString() = value.toString() } - /** Configuration for grouped_with_min_max_thresholds pricing */ - class GroupedWithMinMaxThresholdsConfig + /** Configuration for percent pricing */ + class PercentConfig @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val groupingKey: JsonField, - private val maximumCharge: JsonField, - private val minimumCharge: JsonField, - private val perUnitRate: JsonField, + private val percent: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("grouping_key") - @ExcludeMissing - groupingKey: JsonField = JsonMissing.of(), - @JsonProperty("maximum_charge") - @ExcludeMissing - maximumCharge: JsonField = JsonMissing.of(), - @JsonProperty("minimum_charge") + @JsonProperty("percent") @ExcludeMissing - minimumCharge: JsonField = JsonMissing.of(), - @JsonProperty("per_unit_rate") - @ExcludeMissing - perUnitRate: JsonField = JsonMissing.of(), - ) : this(groupingKey, maximumCharge, minimumCharge, perUnitRate, mutableMapOf()) - - /** - * The event property used to group before applying thresholds - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun groupingKey(): String = groupingKey.getRequired("grouping_key") - - /** - * The maximum amount to charge each group - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun maximumCharge(): String = maximumCharge.getRequired("maximum_charge") - - /** - * The minimum amount to charge each group, regardless of usage - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun minimumCharge(): String = minimumCharge.getRequired("minimum_charge") + percent: JsonField = JsonMissing.of() + ) : this(percent, mutableMapOf()) /** - * The base price charged per group + * What percent of the component subtotals to charge * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). */ - fun perUnitRate(): String = perUnitRate.getRequired("per_unit_rate") - - /** - * Returns the raw JSON value of [groupingKey]. - * - * Unlike [groupingKey], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("grouping_key") - @ExcludeMissing - fun _groupingKey(): JsonField = groupingKey - - /** - * Returns the raw JSON value of [maximumCharge]. - * - * Unlike [maximumCharge], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("maximum_charge") - @ExcludeMissing - fun _maximumCharge(): JsonField = maximumCharge - - /** - * Returns the raw JSON value of [minimumCharge]. - * - * Unlike [minimumCharge], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("minimum_charge") - @ExcludeMissing - fun _minimumCharge(): JsonField = minimumCharge + fun percent(): Double = percent.getRequired("percent") /** - * Returns the raw JSON value of [perUnitRate]. + * Returns the raw JSON value of [percent]. * - * Unlike [perUnitRate], this method doesn't throw if the JSON field has an + * Unlike [percent], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("per_unit_rate") + @JsonProperty("percent") @ExcludeMissing - fun _perUnitRate(): JsonField = perUnitRate + fun _percent(): JsonField = percent @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -16779,100 +19953,39 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [GroupedWithMinMaxThresholdsConfig]. + * [PercentConfig]. * * The following fields are required: * ```kotlin - * .groupingKey() - * .maximumCharge() - * .minimumCharge() - * .perUnitRate() + * .percent() * ``` */ fun builder() = Builder() } - /** A builder for [GroupedWithMinMaxThresholdsConfig]. */ + /** A builder for [PercentConfig]. */ class Builder internal constructor() { - private var groupingKey: JsonField? = null - private var maximumCharge: JsonField? = null - private var minimumCharge: JsonField? = null - private var perUnitRate: JsonField? = null + private var percent: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() - internal fun from( - groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig - ) = apply { - groupingKey = groupedWithMinMaxThresholdsConfig.groupingKey - maximumCharge = groupedWithMinMaxThresholdsConfig.maximumCharge - minimumCharge = groupedWithMinMaxThresholdsConfig.minimumCharge - perUnitRate = groupedWithMinMaxThresholdsConfig.perUnitRate - additionalProperties = - groupedWithMinMaxThresholdsConfig.additionalProperties - .toMutableMap() - } - - /** The event property used to group before applying thresholds */ - fun groupingKey(groupingKey: String) = - groupingKey(JsonField.of(groupingKey)) - - /** - * Sets [Builder.groupingKey] to an arbitrary JSON value. - * - * You should usually call [Builder.groupingKey] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun groupingKey(groupingKey: JsonField) = apply { - this.groupingKey = groupingKey - } - - /** The maximum amount to charge each group */ - fun maximumCharge(maximumCharge: String) = - maximumCharge(JsonField.of(maximumCharge)) - - /** - * Sets [Builder.maximumCharge] to an arbitrary JSON value. - * - * You should usually call [Builder.maximumCharge] with a well-typed - * [String] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun maximumCharge(maximumCharge: JsonField) = apply { - this.maximumCharge = maximumCharge - } - - /** The minimum amount to charge each group, regardless of usage */ - fun minimumCharge(minimumCharge: String) = - minimumCharge(JsonField.of(minimumCharge)) - - /** - * Sets [Builder.minimumCharge] to an arbitrary JSON value. - * - * You should usually call [Builder.minimumCharge] with a well-typed - * [String] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun minimumCharge(minimumCharge: JsonField) = apply { - this.minimumCharge = minimumCharge + internal fun from(percentConfig: PercentConfig) = apply { + percent = percentConfig.percent + additionalProperties = percentConfig.additionalProperties.toMutableMap() } - /** The base price charged per group */ - fun perUnitRate(perUnitRate: String) = - perUnitRate(JsonField.of(perUnitRate)) + /** What percent of the component subtotals to charge */ + fun percent(percent: Double) = percent(JsonField.of(percent)) /** - * Sets [Builder.perUnitRate] to an arbitrary JSON value. + * Sets [Builder.percent] to an arbitrary JSON value. * - * You should usually call [Builder.perUnitRate] with a well-typed [String] + * You should usually call [Builder.percent] with a well-typed [Double] * value instead. This method is primarily for setting the field to an * undocumented or not yet supported value. */ - fun perUnitRate(perUnitRate: JsonField) = apply { - this.perUnitRate = perUnitRate - } + fun percent(percent: JsonField) = apply { this.percent = percent } fun additionalProperties(additionalProperties: Map) = apply { @@ -16897,41 +20010,32 @@ private constructor( } /** - * Returns an immutable instance of [GroupedWithMinMaxThresholdsConfig]. + * Returns an immutable instance of [PercentConfig]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```kotlin - * .groupingKey() - * .maximumCharge() - * .minimumCharge() - * .perUnitRate() + * .percent() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): GroupedWithMinMaxThresholdsConfig = - GroupedWithMinMaxThresholdsConfig( - checkRequired("groupingKey", groupingKey), - checkRequired("maximumCharge", maximumCharge), - checkRequired("minimumCharge", minimumCharge), - checkRequired("perUnitRate", perUnitRate), + fun build(): PercentConfig = + PercentConfig( + checkRequired("percent", percent), additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): GroupedWithMinMaxThresholdsConfig = apply { + fun validate(): PercentConfig = apply { if (validated) { return@apply } - groupingKey() - maximumCharge() - minimumCharge() - perUnitRate() + percent() validated = true } @@ -16949,39 +20053,26 @@ private constructor( * * Used for best match union deserialization. */ - internal fun validity(): Int = - (if (groupingKey.asKnown() == null) 0 else 1) + - (if (maximumCharge.asKnown() == null) 0 else 1) + - (if (minimumCharge.asKnown() == null) 0 else 1) + - (if (perUnitRate.asKnown() == null) 0 else 1) + internal fun validity(): Int = (if (percent.asKnown() == null) 0 else 1) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is GroupedWithMinMaxThresholdsConfig && - groupingKey == other.groupingKey && - maximumCharge == other.maximumCharge && - minimumCharge == other.minimumCharge && - perUnitRate == other.perUnitRate && + return other is PercentConfig && + percent == other.percent && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash( - groupingKey, - maximumCharge, - minimumCharge, - perUnitRate, - additionalProperties, - ) + Objects.hash(percent, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "GroupedWithMinMaxThresholdsConfig{groupingKey=$groupingKey, maximumCharge=$maximumCharge, minimumCharge=$minimumCharge, perUnitRate=$perUnitRate, additionalProperties=$additionalProperties}" + "PercentConfig{percent=$percent, additionalProperties=$additionalProperties}" } /** @@ -17098,13 +20189,12 @@ private constructor( return true } - return other is GroupedWithMinMaxThresholds && + return other is Percent && cadence == other.cadence && - groupedWithMinMaxThresholdsConfig == - other.groupedWithMinMaxThresholdsConfig && itemId == other.itemId && modelType == other.modelType && name == other.name && + percentConfig == other.percentConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && @@ -17124,10 +20214,10 @@ private constructor( private val hashCode: Int by lazy { Objects.hash( cadence, - groupedWithMinMaxThresholdsConfig, itemId, modelType, name, + percentConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -17148,7 +20238,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "GroupedWithMinMaxThresholds{cadence=$cadence, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "Percent{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, percentConfig=$percentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } class EventOutput diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceTest.kt index 0f92bec16..1fce5bea1 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceTest.kt @@ -154,6 +154,7 @@ internal class PriceTest { assertThat(price.scalableMatrixWithTieredPricing()).isNull() assertThat(price.cumulativeGroupedBulk()).isNull() assertThat(price.minimum()).isNull() + assertThat(price.percent()).isNull() assertThat(price.eventOutput()).isNull() } @@ -425,6 +426,7 @@ internal class PriceTest { assertThat(price.scalableMatrixWithTieredPricing()).isNull() assertThat(price.cumulativeGroupedBulk()).isNull() assertThat(price.minimum()).isNull() + assertThat(price.percent()).isNull() assertThat(price.eventOutput()).isNull() } @@ -702,6 +704,7 @@ internal class PriceTest { assertThat(price.scalableMatrixWithTieredPricing()).isNull() assertThat(price.cumulativeGroupedBulk()).isNull() assertThat(price.minimum()).isNull() + assertThat(price.percent()).isNull() assertThat(price.eventOutput()).isNull() } @@ -974,6 +977,7 @@ internal class PriceTest { assertThat(price.scalableMatrixWithTieredPricing()).isNull() assertThat(price.cumulativeGroupedBulk()).isNull() assertThat(price.minimum()).isNull() + assertThat(price.percent()).isNull() assertThat(price.eventOutput()).isNull() } @@ -1251,6 +1255,7 @@ internal class PriceTest { assertThat(price.scalableMatrixWithTieredPricing()).isNull() assertThat(price.cumulativeGroupedBulk()).isNull() assertThat(price.minimum()).isNull() + assertThat(price.percent()).isNull() assertThat(price.eventOutput()).isNull() } @@ -1541,6 +1546,7 @@ internal class PriceTest { assertThat(price.scalableMatrixWithTieredPricing()).isNull() assertThat(price.cumulativeGroupedBulk()).isNull() assertThat(price.minimum()).isNull() + assertThat(price.percent()).isNull() assertThat(price.eventOutput()).isNull() } @@ -1838,6 +1844,7 @@ internal class PriceTest { assertThat(price.scalableMatrixWithTieredPricing()).isNull() assertThat(price.cumulativeGroupedBulk()).isNull() assertThat(price.minimum()).isNull() + assertThat(price.percent()).isNull() assertThat(price.eventOutput()).isNull() } @@ -2134,6 +2141,7 @@ internal class PriceTest { assertThat(price.scalableMatrixWithTieredPricing()).isNull() assertThat(price.cumulativeGroupedBulk()).isNull() assertThat(price.minimum()).isNull() + assertThat(price.percent()).isNull() assertThat(price.eventOutput()).isNull() } @@ -2430,6 +2438,7 @@ internal class PriceTest { assertThat(price.scalableMatrixWithTieredPricing()).isNull() assertThat(price.cumulativeGroupedBulk()).isNull() assertThat(price.minimum()).isNull() + assertThat(price.percent()).isNull() assertThat(price.eventOutput()).isNull() } @@ -2727,6 +2736,7 @@ internal class PriceTest { assertThat(price.scalableMatrixWithTieredPricing()).isNull() assertThat(price.cumulativeGroupedBulk()).isNull() assertThat(price.minimum()).isNull() + assertThat(price.percent()).isNull() assertThat(price.eventOutput()).isNull() } @@ -3014,6 +3024,7 @@ internal class PriceTest { assertThat(price.scalableMatrixWithTieredPricing()).isNull() assertThat(price.cumulativeGroupedBulk()).isNull() assertThat(price.minimum()).isNull() + assertThat(price.percent()).isNull() assertThat(price.eventOutput()).isNull() } @@ -3286,6 +3297,7 @@ internal class PriceTest { assertThat(price.scalableMatrixWithTieredPricing()).isNull() assertThat(price.cumulativeGroupedBulk()).isNull() assertThat(price.minimum()).isNull() + assertThat(price.percent()).isNull() assertThat(price.eventOutput()).isNull() } @@ -3564,6 +3576,7 @@ internal class PriceTest { assertThat(price.scalableMatrixWithTieredPricing()).isNull() assertThat(price.cumulativeGroupedBulk()).isNull() assertThat(price.minimum()).isNull() + assertThat(price.percent()).isNull() assertThat(price.eventOutput()).isNull() } @@ -3846,6 +3859,7 @@ internal class PriceTest { assertThat(price.scalableMatrixWithTieredPricing()).isNull() assertThat(price.cumulativeGroupedBulk()).isNull() assertThat(price.minimum()).isNull() + assertThat(price.percent()).isNull() assertThat(price.eventOutput()).isNull() } @@ -4120,6 +4134,7 @@ internal class PriceTest { assertThat(price.scalableMatrixWithTieredPricing()).isNull() assertThat(price.cumulativeGroupedBulk()).isNull() assertThat(price.minimum()).isNull() + assertThat(price.percent()).isNull() assertThat(price.eventOutput()).isNull() } @@ -4391,6 +4406,7 @@ internal class PriceTest { assertThat(price.scalableMatrixWithTieredPricing()).isNull() assertThat(price.cumulativeGroupedBulk()).isNull() assertThat(price.minimum()).isNull() + assertThat(price.percent()).isNull() assertThat(price.eventOutput()).isNull() } @@ -4673,6 +4689,7 @@ internal class PriceTest { assertThat(price.scalableMatrixWithTieredPricing()).isNull() assertThat(price.cumulativeGroupedBulk()).isNull() assertThat(price.minimum()).isNull() + assertThat(price.percent()).isNull() assertThat(price.eventOutput()).isNull() } @@ -4955,6 +4972,7 @@ internal class PriceTest { assertThat(price.scalableMatrixWithTieredPricing()).isNull() assertThat(price.cumulativeGroupedBulk()).isNull() assertThat(price.minimum()).isNull() + assertThat(price.percent()).isNull() assertThat(price.eventOutput()).isNull() } @@ -5245,6 +5263,7 @@ internal class PriceTest { assertThat(price.scalableMatrixWithTieredPricing()).isNull() assertThat(price.cumulativeGroupedBulk()).isNull() assertThat(price.minimum()).isNull() + assertThat(price.percent()).isNull() assertThat(price.eventOutput()).isNull() } @@ -5536,6 +5555,7 @@ internal class PriceTest { assertThat(price.scalableMatrixWithTieredPricing()).isNull() assertThat(price.cumulativeGroupedBulk()).isNull() assertThat(price.minimum()).isNull() + assertThat(price.percent()).isNull() assertThat(price.eventOutput()).isNull() } @@ -5817,6 +5837,7 @@ internal class PriceTest { assertThat(price.scalableMatrixWithTieredPricing()).isNull() assertThat(price.cumulativeGroupedBulk()).isNull() assertThat(price.minimum()).isNull() + assertThat(price.percent()).isNull() assertThat(price.eventOutput()).isNull() } @@ -6107,6 +6128,7 @@ internal class PriceTest { assertThat(price.scalableMatrixWithTieredPricing()).isNull() assertThat(price.cumulativeGroupedBulk()).isNull() assertThat(price.minimum()).isNull() + assertThat(price.percent()).isNull() assertThat(price.eventOutput()).isNull() } @@ -6402,6 +6424,7 @@ internal class PriceTest { assertThat(price.scalableMatrixWithTieredPricing()).isNull() assertThat(price.cumulativeGroupedBulk()).isNull() assertThat(price.minimum()).isNull() + assertThat(price.percent()).isNull() assertThat(price.eventOutput()).isNull() } @@ -6699,6 +6722,7 @@ internal class PriceTest { assertThat(price.scalableMatrixWithTieredPricing()).isNull() assertThat(price.cumulativeGroupedBulk()).isNull() assertThat(price.minimum()).isNull() + assertThat(price.percent()).isNull() assertThat(price.eventOutput()).isNull() } @@ -7013,6 +7037,7 @@ internal class PriceTest { .isEqualTo(scalableMatrixWithTieredPricing) assertThat(price.cumulativeGroupedBulk()).isNull() assertThat(price.minimum()).isNull() + assertThat(price.percent()).isNull() assertThat(price.eventOutput()).isNull() } @@ -7320,6 +7345,7 @@ internal class PriceTest { assertThat(price.scalableMatrixWithTieredPricing()).isNull() assertThat(price.cumulativeGroupedBulk()).isEqualTo(cumulativeGroupedBulk) assertThat(price.minimum()).isNull() + assertThat(price.percent()).isNull() assertThat(price.eventOutput()).isNull() } @@ -7599,6 +7625,7 @@ internal class PriceTest { assertThat(price.scalableMatrixWithTieredPricing()).isNull() assertThat(price.cumulativeGroupedBulk()).isNull() assertThat(price.minimum()).isEqualTo(minimum) + assertThat(price.percent()).isNull() assertThat(price.eventOutput()).isNull() } @@ -7726,6 +7753,268 @@ internal class PriceTest { assertThat(roundtrippedPrice).isEqualTo(price) } + @Test + fun ofPercent() { + val percent = + Price.Percent.builder() + .id("id") + .billableMetric(BillableMetricTiny.builder().id("id").build()) + .billingCycleConfiguration( + BillingCycleConfiguration.builder() + .duration(0L) + .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) + .build() + ) + .billingMode(Price.Percent.BillingMode.IN_ADVANCE) + .cadence(Price.Percent.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) + .conversionRate(0.0) + .unitConversionRateConfig( + ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() + ) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditAllocation( + Allocation.builder() + .allowsRollover(true) + .currency("currency") + .customExpiration( + CustomExpiration.builder() + .duration(0L) + .durationUnit(CustomExpiration.DurationUnit.DAY) + .build() + ) + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .addFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + BillingCycleConfiguration.builder() + .duration(0L) + .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) + .build() + ) + .item(ItemSlim.builder().id("id").name("name").build()) + .maximum( + Maximum.builder() + .addAppliesToPriceId("string") + .addFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.Percent.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Minimum.builder() + .addAppliesToPriceId("string") + .addFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("name") + .percentConfig(Price.Percent.PercentConfig.builder().percent(0.0).build()) + .planPhaseOrder(0L) + .priceType(Price.Percent.PriceType.USAGE_PRICE) + .replacesPriceId("replaces_price_id") + .dimensionalPriceConfiguration( + DimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .build() + ) + .build() + + val price = Price.ofPercent(percent) + + assertThat(price.unit()).isNull() + assertThat(price.tiered()).isNull() + assertThat(price.bulk()).isNull() + assertThat(price.package_()).isNull() + assertThat(price.matrix()).isNull() + assertThat(price.thresholdTotalAmount()).isNull() + assertThat(price.tieredPackage()).isNull() + assertThat(price.tieredWithMinimum()).isNull() + assertThat(price.groupedTiered()).isNull() + assertThat(price.tieredPackageWithMinimum()).isNull() + assertThat(price.packageWithAllocation()).isNull() + assertThat(price.unitWithPercent()).isNull() + assertThat(price.matrixWithAllocation()).isNull() + assertThat(price.tieredWithProration()).isNull() + assertThat(price.unitWithProration()).isNull() + assertThat(price.groupedAllocation()).isNull() + assertThat(price.bulkWithProration()).isNull() + assertThat(price.groupedWithProratedMinimum()).isNull() + assertThat(price.groupedWithMeteredMinimum()).isNull() + assertThat(price.groupedWithMinMaxThresholds()).isNull() + assertThat(price.matrixWithDisplayName()).isNull() + assertThat(price.groupedTieredPackage()).isNull() + assertThat(price.maxGroupTieredPackage()).isNull() + assertThat(price.scalableMatrixWithUnitPricing()).isNull() + assertThat(price.scalableMatrixWithTieredPricing()).isNull() + assertThat(price.cumulativeGroupedBulk()).isNull() + assertThat(price.minimum()).isNull() + assertThat(price.percent()).isEqualTo(percent) + assertThat(price.eventOutput()).isNull() + } + + @Test + fun ofPercentRoundtrip() { + val jsonMapper = jsonMapper() + val price = + Price.ofPercent( + Price.Percent.builder() + .id("id") + .billableMetric(BillableMetricTiny.builder().id("id").build()) + .billingCycleConfiguration( + BillingCycleConfiguration.builder() + .duration(0L) + .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) + .build() + ) + .billingMode(Price.Percent.BillingMode.IN_ADVANCE) + .cadence(Price.Percent.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) + .conversionRate(0.0) + .unitConversionRateConfig( + ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() + ) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditAllocation( + Allocation.builder() + .allowsRollover(true) + .currency("currency") + .customExpiration( + CustomExpiration.builder() + .duration(0L) + .durationUnit(CustomExpiration.DurationUnit.DAY) + .build() + ) + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .addFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + BillingCycleConfiguration.builder() + .duration(0L) + .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) + .build() + ) + .item(ItemSlim.builder().id("id").name("name").build()) + .maximum( + Maximum.builder() + .addAppliesToPriceId("string") + .addFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.Percent.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Minimum.builder() + .addAppliesToPriceId("string") + .addFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("name") + .percentConfig(Price.Percent.PercentConfig.builder().percent(0.0).build()) + .planPhaseOrder(0L) + .priceType(Price.Percent.PriceType.USAGE_PRICE) + .replacesPriceId("replaces_price_id") + .dimensionalPriceConfiguration( + DimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .build() + ) + .build() + ) + + val roundtrippedPrice = + jsonMapper.readValue(jsonMapper.writeValueAsString(price), jacksonTypeRef()) + + assertThat(roundtrippedPrice).isEqualTo(price) + } + @Test fun ofEventOutput() { val eventOutput = @@ -7870,6 +8159,7 @@ internal class PriceTest { assertThat(price.scalableMatrixWithTieredPricing()).isNull() assertThat(price.cumulativeGroupedBulk()).isNull() assertThat(price.minimum()).isNull() + assertThat(price.percent()).isNull() assertThat(price.eventOutput()).isEqualTo(eventOutput) } From 93761f0a10e3a553c7ca56701f746de784ee2516 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 10 Oct 2025 00:33:11 +0000 Subject: [PATCH 29/68] feat(api): api update --- .stats.yml | 4 +- .../api/models/InvoiceLineItemCreateParams.kt | 251 ++++++++++++------ .../async/InvoiceLineItemServiceAsync.kt | 9 + .../blocking/InvoiceLineItemService.kt | 9 + .../models/InvoiceLineItemCreateParamsTest.kt | 27 +- .../async/InvoiceLineItemServiceAsyncTest.kt | 3 +- .../blocking/InvoiceLineItemServiceTest.kt | 3 +- 7 files changed, 222 insertions(+), 84 deletions(-) diff --git a/.stats.yml b/.stats.yml index 3407ffd10..32f63a300 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 118 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-b070c1d97a6e3b400f43d2bce36c22ed89d432345b26374728c55dd0a20f0afa.yml -openapi_spec_hash: dba4ff52c381cda6159fc56d8b77eb32 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-15e42bc01739abea4a925894a1a7de447de40b003a3433461952e8e06919588b.yml +openapi_spec_hash: 8a0bc5b6ab417f7256cbf83d70c459a3 config_hash: 1f73a949b649ecfe6ec68ba1bb459dc2 diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceLineItemCreateParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceLineItemCreateParams.kt index dc7334883..4005dc59e 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceLineItemCreateParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceLineItemCreateParams.kt @@ -22,6 +22,15 @@ import java.util.Objects /** * This creates a one-off fixed fee invoice line item on an Invoice. This can only be done for * invoices that are in a `draft` status. + * + * The behavior depends on which parameters are provided: + * - If `item_id` is provided without `name`: The item is looked up by ID, and the item's name is + * used for the line item. + * - If `name` is provided without `item_id`: An item with the given name is searched for in the + * account. If found, that item is used. If not found, a new item is created with that name. The + * new item's name is used for the line item. + * - If both `item_id` and `name` are provided: The item is looked up by ID for association, but the + * provided `name` is used for the line item (not the item's name). */ class InvoiceLineItemCreateParams private constructor( @@ -54,15 +63,6 @@ private constructor( */ fun invoiceId(): String = body.invoiceId() - /** - * The item name associated with this line item. If an item with the same name exists in Orb, - * that item will be associated with the line item. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly - * missing or null (e.g. if the server responded with an unexpected value). - */ - fun name(): String = body.name() - /** * The number of units on the line item * @@ -79,6 +79,29 @@ private constructor( */ fun startDate(): LocalDate = body.startDate() + /** + * The id of the item to associate with this line item. If provided without `name`, the item's + * name will be used for the price/line item. If provided with `name`, the item will be + * associated but `name` will be used for the line item. At least one of `name` or `item_id` + * must be provided. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun itemId(): String? = body.itemId() + + /** + * The name to use for the line item. If `item_id` is not provided, Orb will search for an item + * with this name. If found, that item will be associated with the line item. If not found, a + * new item will be created with this name. If `item_id` is provided, this name will be used for + * the line item, but the item association will be based on `item_id`. At least one of `name` or + * `item_id` must be provided. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun name(): String? = body.name() + /** * Returns the raw JSON value of [amount]. * @@ -100,13 +123,6 @@ private constructor( */ fun _invoiceId(): JsonField = body._invoiceId() - /** - * Returns the raw JSON value of [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. - */ - fun _name(): JsonField = body._name() - /** * Returns the raw JSON value of [quantity]. * @@ -121,6 +137,20 @@ private constructor( */ fun _startDate(): JsonField = body._startDate() + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _itemId(): JsonField = body._itemId() + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _name(): JsonField = body._name() + fun _additionalBodyProperties(): Map = body._additionalProperties() /** Additional headers to send with the request. */ @@ -141,7 +171,6 @@ private constructor( * .amount() * .endDate() * .invoiceId() - * .name() * .quantity() * .startDate() * ``` @@ -170,8 +199,8 @@ private constructor( * - [amount] * - [endDate] * - [invoiceId] - * - [name] * - [quantity] + * - [startDate] * - etc. */ fun body(body: Body) = apply { this.body = body.toBuilder() } @@ -211,20 +240,6 @@ private constructor( */ fun invoiceId(invoiceId: JsonField) = apply { body.invoiceId(invoiceId) } - /** - * The item name associated with this line item. If an item with the same name exists in - * Orb, that item will be associated with the line item. - */ - fun name(name: String) = apply { body.name(name) } - - /** - * Sets [Builder.name] to an arbitrary JSON value. - * - * You should usually call [Builder.name] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun name(name: JsonField) = apply { body.name(name) } - /** The number of units on the line item */ fun quantity(quantity: Double) = apply { body.quantity(quantity) } @@ -248,6 +263,39 @@ private constructor( */ fun startDate(startDate: JsonField) = apply { body.startDate(startDate) } + /** + * The id of the item to associate with this line item. If provided without `name`, the + * item's name will be used for the price/line item. If provided with `name`, the item will + * be associated but `name` will be used for the line item. At least one of `name` or + * `item_id` must be provided. + */ + fun itemId(itemId: String?) = apply { body.itemId(itemId) } + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { body.itemId(itemId) } + + /** + * The name to use for the line item. If `item_id` is not provided, Orb will search for an + * item with this name. If found, that item will be associated with the line item. If not + * found, a new item will be created with this name. If `item_id` is provided, this name + * will be used for the line item, but the item association will be based on `item_id`. At + * least one of `name` or `item_id` must be provided. + */ + fun name(name: String?) = apply { body.name(name) } + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun name(name: JsonField) = apply { body.name(name) } + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { body.additionalProperties(additionalBodyProperties) } @@ -375,7 +423,6 @@ private constructor( * .amount() * .endDate() * .invoiceId() - * .name() * .quantity() * .startDate() * ``` @@ -402,9 +449,10 @@ private constructor( private val amount: JsonField, private val endDate: JsonField, private val invoiceId: JsonField, - private val name: JsonField, private val quantity: JsonField, private val startDate: JsonField, + private val itemId: JsonField, + private val name: JsonField, private val additionalProperties: MutableMap, ) { @@ -417,14 +465,15 @@ private constructor( @JsonProperty("invoice_id") @ExcludeMissing invoiceId: JsonField = JsonMissing.of(), - @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @JsonProperty("quantity") @ExcludeMissing quantity: JsonField = JsonMissing.of(), @JsonProperty("start_date") @ExcludeMissing startDate: JsonField = JsonMissing.of(), - ) : this(amount, endDate, invoiceId, name, quantity, startDate, mutableMapOf()) + @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(amount, endDate, invoiceId, quantity, startDate, itemId, name, mutableMapOf()) /** * The total amount in the invoice's currency to add to the line item. @@ -450,15 +499,6 @@ private constructor( */ fun invoiceId(): String = invoiceId.getRequired("invoice_id") - /** - * The item name associated with this line item. If an item with the same name exists in - * Orb, that item will be associated with the line item. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun name(): String = name.getRequired("name") - /** * The number of units on the line item * @@ -475,6 +515,29 @@ private constructor( */ fun startDate(): LocalDate = startDate.getRequired("start_date") + /** + * The id of the item to associate with this line item. If provided without `name`, the + * item's name will be used for the price/line item. If provided with `name`, the item will + * be associated but `name` will be used for the line item. At least one of `name` or + * `item_id` must be provided. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun itemId(): String? = itemId.getNullable("item_id") + + /** + * The name to use for the line item. If `item_id` is not provided, Orb will search for an + * item with this name. If found, that item will be associated with the line item. If not + * found, a new item will be created with this name. If `item_id` is provided, this name + * will be used for the line item, but the item association will be based on `item_id`. At + * least one of `name` or `item_id` must be provided. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun name(): String? = name.getNullable("name") + /** * Returns the raw JSON value of [amount]. * @@ -496,13 +559,6 @@ private constructor( */ @JsonProperty("invoice_id") @ExcludeMissing fun _invoiceId(): JsonField = invoiceId - /** - * Returns the raw JSON value of [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - /** * Returns the raw JSON value of [quantity]. * @@ -519,6 +575,20 @@ private constructor( @ExcludeMissing fun _startDate(): JsonField = startDate + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -541,7 +611,6 @@ private constructor( * .amount() * .endDate() * .invoiceId() - * .name() * .quantity() * .startDate() * ``` @@ -555,18 +624,20 @@ private constructor( private var amount: JsonField? = null private var endDate: JsonField? = null private var invoiceId: JsonField? = null - private var name: JsonField? = null private var quantity: JsonField? = null private var startDate: JsonField? = null + private var itemId: JsonField = JsonMissing.of() + private var name: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() internal fun from(body: Body) = apply { amount = body.amount endDate = body.endDate invoiceId = body.invoiceId - name = body.name quantity = body.quantity startDate = body.startDate + itemId = body.itemId + name = body.name additionalProperties = body.additionalProperties.toMutableMap() } @@ -606,21 +677,6 @@ private constructor( */ fun invoiceId(invoiceId: JsonField) = apply { this.invoiceId = invoiceId } - /** - * The item name associated with this line item. If an item with the same name exists in - * Orb, that item will be associated with the line item. - */ - fun name(name: String) = name(JsonField.of(name)) - - /** - * Sets [Builder.name] to an arbitrary JSON value. - * - * You should usually call [Builder.name] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun name(name: JsonField) = apply { this.name = name } - /** The number of units on the line item */ fun quantity(quantity: Double) = quantity(JsonField.of(quantity)) @@ -645,6 +701,41 @@ private constructor( */ fun startDate(startDate: JsonField) = apply { this.startDate = startDate } + /** + * The id of the item to associate with this line item. If provided without `name`, the + * item's name will be used for the price/line item. If provided with `name`, the item + * will be associated but `name` will be used for the line item. At least one of `name` + * or `item_id` must be provided. + */ + fun itemId(itemId: String?) = itemId(JsonField.ofNullable(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * The name to use for the line item. If `item_id` is not provided, Orb will search for + * an item with this name. If found, that item will be associated with the line item. If + * not found, a new item will be created with this name. If `item_id` is provided, this + * name will be used for the line item, but the item association will be based on + * `item_id`. At least one of `name` or `item_id` must be provided. + */ + fun name(name: String?) = name(JsonField.ofNullable(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonField) = apply { this.name = name } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -674,7 +765,6 @@ private constructor( * .amount() * .endDate() * .invoiceId() - * .name() * .quantity() * .startDate() * ``` @@ -686,9 +776,10 @@ private constructor( checkRequired("amount", amount), checkRequired("endDate", endDate), checkRequired("invoiceId", invoiceId), - checkRequired("name", name), checkRequired("quantity", quantity), checkRequired("startDate", startDate), + itemId, + name, additionalProperties.toMutableMap(), ) } @@ -703,9 +794,10 @@ private constructor( amount() endDate() invoiceId() - name() quantity() startDate() + itemId() + name() validated = true } @@ -727,9 +819,10 @@ private constructor( (if (amount.asKnown() == null) 0 else 1) + (if (endDate.asKnown() == null) 0 else 1) + (if (invoiceId.asKnown() == null) 0 else 1) + - (if (name.asKnown() == null) 0 else 1) + (if (quantity.asKnown() == null) 0 else 1) + - (if (startDate.asKnown() == null) 0 else 1) + (if (startDate.asKnown() == null) 0 else 1) + + (if (itemId.asKnown() == null) 0 else 1) + + (if (name.asKnown() == null) 0 else 1) override fun equals(other: Any?): Boolean { if (this === other) { @@ -740,9 +833,10 @@ private constructor( amount == other.amount && endDate == other.endDate && invoiceId == other.invoiceId && - name == other.name && quantity == other.quantity && startDate == other.startDate && + itemId == other.itemId && + name == other.name && additionalProperties == other.additionalProperties } @@ -751,9 +845,10 @@ private constructor( amount, endDate, invoiceId, - name, quantity, startDate, + itemId, + name, additionalProperties, ) } @@ -761,7 +856,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Body{amount=$amount, endDate=$endDate, invoiceId=$invoiceId, name=$name, quantity=$quantity, startDate=$startDate, additionalProperties=$additionalProperties}" + "Body{amount=$amount, endDate=$endDate, invoiceId=$invoiceId, quantity=$quantity, startDate=$startDate, itemId=$itemId, name=$name, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/InvoiceLineItemServiceAsync.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/InvoiceLineItemServiceAsync.kt index 0dcf26f95..eb20e781c 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/InvoiceLineItemServiceAsync.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/InvoiceLineItemServiceAsync.kt @@ -26,6 +26,15 @@ interface InvoiceLineItemServiceAsync { /** * This creates a one-off fixed fee invoice line item on an Invoice. This can only be done for * invoices that are in a `draft` status. + * + * The behavior depends on which parameters are provided: + * - If `item_id` is provided without `name`: The item is looked up by ID, and the item's name + * is used for the line item. + * - If `name` is provided without `item_id`: An item with the given name is searched for in the + * account. If found, that item is used. If not found, a new item is created with that name. + * The new item's name is used for the line item. + * - If both `item_id` and `name` are provided: The item is looked up by ID for association, but + * the provided `name` is used for the line item (not the item's name). */ suspend fun create( params: InvoiceLineItemCreateParams, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/InvoiceLineItemService.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/InvoiceLineItemService.kt index 30c0ea492..2080f3901 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/InvoiceLineItemService.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/InvoiceLineItemService.kt @@ -26,6 +26,15 @@ interface InvoiceLineItemService { /** * This creates a one-off fixed fee invoice line item on an Invoice. This can only be done for * invoices that are in a `draft` status. + * + * The behavior depends on which parameters are provided: + * - If `item_id` is provided without `name`: The item is looked up by ID, and the item's name + * is used for the line item. + * - If `name` is provided without `item_id`: An item with the given name is searched for in the + * account. If found, that item is used. If not found, a new item is created with that name. + * The new item's name is used for the line item. + * - If both `item_id` and `name` are provided: The item is looked up by ID for association, but + * the provided `name` is used for the line item (not the item's name). */ fun create( params: InvoiceLineItemCreateParams, diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceLineItemCreateParamsTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceLineItemCreateParamsTest.kt index 4854317ef..71753142f 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceLineItemCreateParamsTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceLineItemCreateParamsTest.kt @@ -14,9 +14,10 @@ internal class InvoiceLineItemCreateParamsTest { .amount("12.00") .endDate(LocalDate.parse("2023-09-22")) .invoiceId("4khy3nwzktxv7") - .name("Item Name") .quantity(1.0) .startDate(LocalDate.parse("2023-09-22")) + .itemId("4khy3nwzktxv7") + .name("Item Name") .build() } @@ -27,9 +28,10 @@ internal class InvoiceLineItemCreateParamsTest { .amount("12.00") .endDate(LocalDate.parse("2023-09-22")) .invoiceId("4khy3nwzktxv7") - .name("Item Name") .quantity(1.0) .startDate(LocalDate.parse("2023-09-22")) + .itemId("4khy3nwzktxv7") + .name("Item Name") .build() val body = params._body() @@ -37,7 +39,28 @@ internal class InvoiceLineItemCreateParamsTest { assertThat(body.amount()).isEqualTo("12.00") assertThat(body.endDate()).isEqualTo(LocalDate.parse("2023-09-22")) assertThat(body.invoiceId()).isEqualTo("4khy3nwzktxv7") + assertThat(body.quantity()).isEqualTo(1.0) + assertThat(body.startDate()).isEqualTo(LocalDate.parse("2023-09-22")) + assertThat(body.itemId()).isEqualTo("4khy3nwzktxv7") assertThat(body.name()).isEqualTo("Item Name") + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + InvoiceLineItemCreateParams.builder() + .amount("12.00") + .endDate(LocalDate.parse("2023-09-22")) + .invoiceId("4khy3nwzktxv7") + .quantity(1.0) + .startDate(LocalDate.parse("2023-09-22")) + .build() + + val body = params._body() + + assertThat(body.amount()).isEqualTo("12.00") + assertThat(body.endDate()).isEqualTo(LocalDate.parse("2023-09-22")) + assertThat(body.invoiceId()).isEqualTo("4khy3nwzktxv7") assertThat(body.quantity()).isEqualTo(1.0) assertThat(body.startDate()).isEqualTo(LocalDate.parse("2023-09-22")) } diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/InvoiceLineItemServiceAsyncTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/InvoiceLineItemServiceAsyncTest.kt index 49d963e14..da5ad4379 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/InvoiceLineItemServiceAsyncTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/InvoiceLineItemServiceAsyncTest.kt @@ -27,9 +27,10 @@ internal class InvoiceLineItemServiceAsyncTest { .amount("12.00") .endDate(LocalDate.parse("2023-09-22")) .invoiceId("4khy3nwzktxv7") - .name("Item Name") .quantity(1.0) .startDate(LocalDate.parse("2023-09-22")) + .itemId("4khy3nwzktxv7") + .name("Item Name") .build() ) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/InvoiceLineItemServiceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/InvoiceLineItemServiceTest.kt index 2f8dc2ce6..237b42ccc 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/InvoiceLineItemServiceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/InvoiceLineItemServiceTest.kt @@ -27,9 +27,10 @@ internal class InvoiceLineItemServiceTest { .amount("12.00") .endDate(LocalDate.parse("2023-09-22")) .invoiceId("4khy3nwzktxv7") - .name("Item Name") .quantity(1.0) .startDate(LocalDate.parse("2023-09-22")) + .itemId("4khy3nwzktxv7") + .name("Item Name") .build() ) From 55ad4a4320cada62ca679193af9d5c927f6e6f21 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 10 Oct 2025 16:33:29 +0000 Subject: [PATCH 30/68] codegen metadata --- .stats.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.stats.yml b/.stats.yml index 32f63a300..1d5af75a0 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 118 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-15e42bc01739abea4a925894a1a7de447de40b003a3433461952e8e06919588b.yml -openapi_spec_hash: 8a0bc5b6ab417f7256cbf83d70c459a3 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-ee9adb19e1aafbee7edb5b95348a1629c1de6ca9625f3b49f6064ae10d863bfc.yml +openapi_spec_hash: 42006f5fb95364855be09dc4432073c0 config_hash: 1f73a949b649ecfe6ec68ba1bb459dc2 From 6d42811246f63cd57f9c2b9917a291ba9ef5b6ae Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 13 Oct 2025 21:33:22 +0000 Subject: [PATCH 31/68] feat(api): api update --- .stats.yml | 4 +- .../api/models/BetaCreatePlanVersionParams.kt | 17672 +++++++++------ ...taExternalPlanIdCreatePlanVersionParams.kt | 17672 +++++++++------ .../models/ChangedSubscriptionResources.kt | 4 + .../kotlin/com/withorb/api/models/Invoice.kt | 4 + .../models/InvoiceFetchUpcomingResponse.kt | 4 + .../models/InvoiceLineItemCreateResponse.kt | 4 + .../com/withorb/api/models/PerPriceCost.kt | 4 + .../kotlin/com/withorb/api/models/Plan.kt | 4 + .../withorb/api/models/PlanCreateParams.kt | 2069 ++ .../com/withorb/api/models/PlanVersion.kt | 4 + .../kotlin/com/withorb/api/models/Price.kt | 2724 +++ .../withorb/api/models/PriceCreateParams.kt | 1978 ++ .../api/models/PriceEvaluateMultipleParams.kt | 2019 ++ .../PriceEvaluatePreviewEventsParams.kt | 2019 ++ .../com/withorb/api/models/PriceInterval.kt | 4 + .../api/models/PriceListPageResponse.kt | 4 + .../api/models/SubscriptionCreateParams.kt | 18444 ++++++++++------ .../SubscriptionPriceIntervalsParams.kt | 2019 ++ .../SubscriptionSchedulePlanChangeParams.kt | 18366 +++++++++------ .../com/withorb/api/models/PriceTest.kt | 334 + 21 files changed, 57553 insertions(+), 27803 deletions(-) diff --git a/.stats.yml b/.stats.yml index 1d5af75a0..0fdea26bb 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 118 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-ee9adb19e1aafbee7edb5b95348a1629c1de6ca9625f3b49f6064ae10d863bfc.yml -openapi_spec_hash: 42006f5fb95364855be09dc4432073c0 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-d0eaf664d43e26c42ebf8740ff1b6ee34c4d424c7048a7f04df994cb65627f89.yml +openapi_spec_hash: 4d7622040380d5c7bd2e5a5ec9b86783 config_hash: 1f73a949b649ecfe6ec68ba1bb459dc2 diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BetaCreatePlanVersionParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BetaCreatePlanVersionParams.kt index 4937aef2a..38cc195ca 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BetaCreatePlanVersionParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BetaCreatePlanVersionParams.kt @@ -1834,6 +1834,10 @@ private constructor( /** Alias for calling [price] with `Price.ofBulk(bulk)`. */ fun price(bulk: NewPlanBulkPrice) = price(Price.ofBulk(bulk)) + /** Alias for calling [price] with `Price.ofBulkWithFilters(bulkWithFilters)`. */ + fun price(bulkWithFilters: Price.BulkWithFilters) = + price(Price.ofBulkWithFilters(bulkWithFilters)) + /** Alias for calling [price] with `Price.ofPackage(package_)`. */ fun price(package_: NewPlanPackagePrice) = price(Price.ofPackage(package_)) @@ -2045,6 +2049,7 @@ private constructor( private val unit: NewPlanUnitPrice? = null, private val tiered: NewPlanTieredPrice? = null, private val bulk: NewPlanBulkPrice? = null, + private val bulkWithFilters: BulkWithFilters? = null, private val package_: NewPlanPackagePrice? = null, private val matrix: NewPlanMatrixPrice? = null, private val thresholdTotalAmount: NewPlanThresholdTotalAmountPrice? = null, @@ -2083,6 +2088,8 @@ private constructor( fun bulk(): NewPlanBulkPrice? = bulk + fun bulkWithFilters(): BulkWithFilters? = bulkWithFilters + fun package_(): NewPlanPackagePrice? = package_ fun matrix(): NewPlanMatrixPrice? = matrix @@ -2147,6 +2154,8 @@ private constructor( fun isBulk(): Boolean = bulk != null + fun isBulkWithFilters(): Boolean = bulkWithFilters != null + fun isPackage(): Boolean = package_ != null fun isMatrix(): Boolean = matrix != null @@ -2206,6 +2215,8 @@ private constructor( fun asBulk(): NewPlanBulkPrice = bulk.getOrThrow("bulk") + fun asBulkWithFilters(): BulkWithFilters = bulkWithFilters.getOrThrow("bulkWithFilters") + fun asPackage(): NewPlanPackagePrice = package_.getOrThrow("package_") fun asMatrix(): NewPlanMatrixPrice = matrix.getOrThrow("matrix") @@ -2286,6 +2297,7 @@ private constructor( unit != null -> visitor.visitUnit(unit) tiered != null -> visitor.visitTiered(tiered) bulk != null -> visitor.visitBulk(bulk) + bulkWithFilters != null -> visitor.visitBulkWithFilters(bulkWithFilters) package_ != null -> visitor.visitPackage(package_) matrix != null -> visitor.visitMatrix(matrix) thresholdTotalAmount != null -> @@ -2352,6 +2364,10 @@ private constructor( bulk.validate() } + override fun visitBulkWithFilters(bulkWithFilters: BulkWithFilters) { + bulkWithFilters.validate() + } + override fun visitPackage(package_: NewPlanPackagePrice) { package_.validate() } @@ -2522,6 +2538,9 @@ private constructor( override fun visitBulk(bulk: NewPlanBulkPrice) = bulk.validity() + override fun visitBulkWithFilters(bulkWithFilters: BulkWithFilters) = + bulkWithFilters.validity() + override fun visitPackage(package_: NewPlanPackagePrice) = package_.validity() @@ -2631,6 +2650,7 @@ private constructor( unit == other.unit && tiered == other.tiered && bulk == other.bulk && + bulkWithFilters == other.bulkWithFilters && package_ == other.package_ && matrix == other.matrix && thresholdTotalAmount == other.thresholdTotalAmount && @@ -2664,6 +2684,7 @@ private constructor( unit, tiered, bulk, + bulkWithFilters, package_, matrix, thresholdTotalAmount, @@ -2697,6 +2718,7 @@ private constructor( unit != null -> "Price{unit=$unit}" tiered != null -> "Price{tiered=$tiered}" bulk != null -> "Price{bulk=$bulk}" + bulkWithFilters != null -> "Price{bulkWithFilters=$bulkWithFilters}" package_ != null -> "Price{package_=$package_}" matrix != null -> "Price{matrix=$matrix}" thresholdTotalAmount != null -> @@ -2748,6 +2770,9 @@ private constructor( fun ofBulk(bulk: NewPlanBulkPrice) = Price(bulk = bulk) + fun ofBulkWithFilters(bulkWithFilters: BulkWithFilters) = + Price(bulkWithFilters = bulkWithFilters) + fun ofPackage(package_: NewPlanPackagePrice) = Price(package_ = package_) fun ofMatrix(matrix: NewPlanMatrixPrice) = Price(matrix = matrix) @@ -2843,6 +2868,8 @@ private constructor( fun visitBulk(bulk: NewPlanBulkPrice): T + fun visitBulkWithFilters(bulkWithFilters: BulkWithFilters): T + fun visitPackage(package_: NewPlanPackagePrice): T fun visitMatrix(matrix: NewPlanMatrixPrice): T @@ -2958,6 +2985,11 @@ private constructor( Price(bulk = it, _json = json) } ?: Price(_json = json) } + "bulk_with_filters" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(bulkWithFilters = it, _json = json) + } ?: Price(_json = json) + } "package" -> { return tryDeserialize(node, jacksonTypeRef()) ?.let { Price(package_ = it, _json = json) } ?: Price(_json = json) @@ -3160,6 +3192,8 @@ private constructor( value.unit != null -> generator.writeObject(value.unit) value.tiered != null -> generator.writeObject(value.tiered) value.bulk != null -> generator.writeObject(value.bulk) + value.bulkWithFilters != null -> + generator.writeObject(value.bulkWithFilters) value.package_ != null -> generator.writeObject(value.package_) value.matrix != null -> generator.writeObject(value.matrix) value.thresholdTotalAmount != null -> @@ -3211,14 +3245,14 @@ private constructor( } } - class TieredWithProration + class BulkWithFilters @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( + private val bulkWithFiltersConfig: JsonField, private val cadence: JsonField, private val itemId: JsonField, private val modelType: JsonValue, private val name: JsonField, - private val tieredWithProrationConfig: JsonField, private val billableMetricId: JsonField, private val billedInAdvance: JsonField, private val billingCycleConfiguration: JsonField, @@ -3238,6 +3272,9 @@ private constructor( @JsonCreator private constructor( + @JsonProperty("bulk_with_filters_config") + @ExcludeMissing + bulkWithFiltersConfig: JsonField = JsonMissing.of(), @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), @@ -3250,10 +3287,6 @@ private constructor( @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("tiered_with_proration_config") - @ExcludeMissing - tieredWithProrationConfig: JsonField = - JsonMissing.of(), @JsonProperty("billable_metric_id") @ExcludeMissing billableMetricId: JsonField = JsonMissing.of(), @@ -3297,11 +3330,11 @@ private constructor( @ExcludeMissing referenceId: JsonField = JsonMissing.of(), ) : this( + bulkWithFiltersConfig, cadence, itemId, modelType, name, - tieredWithProrationConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -3318,6 +3351,16 @@ private constructor( mutableMapOf(), ) + /** + * Configuration for bulk_with_filters pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun bulkWithFiltersConfig(): BulkWithFiltersConfig = + bulkWithFiltersConfig.getRequired("bulk_with_filters_config") + /** * The cadence to bill for this price on. * @@ -3341,7 +3384,7 @@ private constructor( * * Expected to always return the following: * ```kotlin - * JsonValue.from("tiered_with_proration") + * JsonValue.from("bulk_with_filters") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -3358,16 +3401,6 @@ private constructor( */ fun name(): String = name.getRequired("name") - /** - * Configuration for tiered_with_proration pricing - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun tieredWithProrationConfig(): TieredWithProrationConfig = - tieredWithProrationConfig.getRequired("tiered_with_proration_config") - /** * The id of the billable metric for the price. Only needed if the price is * usage-based. @@ -3487,6 +3520,17 @@ private constructor( */ fun referenceId(): String? = referenceId.getNullable("reference_id") + /** + * Returns the raw JSON value of [bulkWithFiltersConfig]. + * + * Unlike [bulkWithFiltersConfig], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("bulk_with_filters_config") + @ExcludeMissing + fun _bulkWithFiltersConfig(): JsonField = + bulkWithFiltersConfig + /** * Returns the raw JSON value of [cadence]. * @@ -3513,17 +3557,6 @@ private constructor( */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - /** - * Returns the raw JSON value of [tieredWithProrationConfig]. - * - * Unlike [tieredWithProrationConfig], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("tiered_with_proration_config") - @ExcludeMissing - fun _tieredWithProrationConfig(): JsonField = - tieredWithProrationConfig - /** * Returns the raw JSON value of [billableMetricId]. * @@ -3672,29 +3705,27 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [TieredWithProration]. + * Returns a mutable builder for constructing an instance of [BulkWithFilters]. * * The following fields are required: * ```kotlin + * .bulkWithFiltersConfig() * .cadence() * .itemId() * .name() - * .tieredWithProrationConfig() * ``` */ fun builder() = Builder() } - /** A builder for [TieredWithProration]. */ + /** A builder for [BulkWithFilters]. */ class Builder internal constructor() { + private var bulkWithFiltersConfig: JsonField? = null private var cadence: JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonValue = JsonValue.from("tiered_with_proration") + private var modelType: JsonValue = JsonValue.from("bulk_with_filters") private var name: JsonField? = null - private var tieredWithProrationConfig: JsonField? = - null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() private var billingCycleConfiguration: JsonField = @@ -3716,31 +3747,44 @@ private constructor( private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(tieredWithProration: TieredWithProration) = apply { - cadence = tieredWithProration.cadence - itemId = tieredWithProration.itemId - modelType = tieredWithProration.modelType - name = tieredWithProration.name - tieredWithProrationConfig = tieredWithProration.tieredWithProrationConfig - billableMetricId = tieredWithProration.billableMetricId - billedInAdvance = tieredWithProration.billedInAdvance - billingCycleConfiguration = tieredWithProration.billingCycleConfiguration - conversionRate = tieredWithProration.conversionRate - conversionRateConfig = tieredWithProration.conversionRateConfig - currency = tieredWithProration.currency + internal fun from(bulkWithFilters: BulkWithFilters) = apply { + bulkWithFiltersConfig = bulkWithFilters.bulkWithFiltersConfig + cadence = bulkWithFilters.cadence + itemId = bulkWithFilters.itemId + modelType = bulkWithFilters.modelType + name = bulkWithFilters.name + billableMetricId = bulkWithFilters.billableMetricId + billedInAdvance = bulkWithFilters.billedInAdvance + billingCycleConfiguration = bulkWithFilters.billingCycleConfiguration + conversionRate = bulkWithFilters.conversionRate + conversionRateConfig = bulkWithFilters.conversionRateConfig + currency = bulkWithFilters.currency dimensionalPriceConfiguration = - tieredWithProration.dimensionalPriceConfiguration - externalPriceId = tieredWithProration.externalPriceId - fixedPriceQuantity = tieredWithProration.fixedPriceQuantity - invoiceGroupingKey = tieredWithProration.invoiceGroupingKey - invoicingCycleConfiguration = - tieredWithProration.invoicingCycleConfiguration - metadata = tieredWithProration.metadata - referenceId = tieredWithProration.referenceId - additionalProperties = - tieredWithProration.additionalProperties.toMutableMap() + bulkWithFilters.dimensionalPriceConfiguration + externalPriceId = bulkWithFilters.externalPriceId + fixedPriceQuantity = bulkWithFilters.fixedPriceQuantity + invoiceGroupingKey = bulkWithFilters.invoiceGroupingKey + invoicingCycleConfiguration = bulkWithFilters.invoicingCycleConfiguration + metadata = bulkWithFilters.metadata + referenceId = bulkWithFilters.referenceId + additionalProperties = bulkWithFilters.additionalProperties.toMutableMap() } + /** Configuration for bulk_with_filters pricing */ + fun bulkWithFiltersConfig(bulkWithFiltersConfig: BulkWithFiltersConfig) = + bulkWithFiltersConfig(JsonField.of(bulkWithFiltersConfig)) + + /** + * Sets [Builder.bulkWithFiltersConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.bulkWithFiltersConfig] with a well-typed + * [BulkWithFiltersConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun bulkWithFiltersConfig( + bulkWithFiltersConfig: JsonField + ) = apply { this.bulkWithFiltersConfig = bulkWithFiltersConfig } + /** The cadence to bill for this price on. */ fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) @@ -3771,7 +3815,7 @@ private constructor( * It is usually unnecessary to call this method because the field defaults to * the following: * ```kotlin - * JsonValue.from("tiered_with_proration") + * JsonValue.from("bulk_with_filters") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -3791,22 +3835,6 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } - /** Configuration for tiered_with_proration pricing */ - fun tieredWithProrationConfig( - tieredWithProrationConfig: TieredWithProrationConfig - ) = tieredWithProrationConfig(JsonField.of(tieredWithProrationConfig)) - - /** - * Sets [Builder.tieredWithProrationConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.tieredWithProrationConfig] with a well-typed - * [TieredWithProrationConfig] value instead. This method is primarily for - * setting the field to an undocumented or not yet supported value. - */ - fun tieredWithProrationConfig( - tieredWithProrationConfig: JsonField - ) = apply { this.tieredWithProrationConfig = tieredWithProrationConfig } - /** * The id of the billable metric for the price. Only needed if the price is * usage-based. @@ -4136,27 +4164,27 @@ private constructor( } /** - * Returns an immutable instance of [TieredWithProration]. + * Returns an immutable instance of [BulkWithFilters]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```kotlin + * .bulkWithFiltersConfig() * .cadence() * .itemId() * .name() - * .tieredWithProrationConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): TieredWithProration = - TieredWithProration( + fun build(): BulkWithFilters = + BulkWithFilters( + checkRequired("bulkWithFiltersConfig", bulkWithFiltersConfig), checkRequired("cadence", cadence), checkRequired("itemId", itemId), modelType, checkRequired("name", name), - checkRequired("tieredWithProrationConfig", tieredWithProrationConfig), billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -4176,20 +4204,20 @@ private constructor( private var validated: Boolean = false - fun validate(): TieredWithProration = apply { + fun validate(): BulkWithFilters = apply { if (validated) { return@apply } + bulkWithFiltersConfig().validate() cadence().validate() itemId() _modelType().let { - if (it != JsonValue.from("tiered_with_proration")) { + if (it != JsonValue.from("bulk_with_filters")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } name() - tieredWithProrationConfig().validate() billableMetricId() billedInAdvance() billingCycleConfiguration()?.validate() @@ -4221,13 +4249,11 @@ private constructor( * Used for best match union deserialization. */ internal fun validity(): Int = - (cadence.asKnown()?.validity() ?: 0) + + (bulkWithFiltersConfig.asKnown()?.validity() ?: 0) + + (cadence.asKnown()?.validity() ?: 0) + (if (itemId.asKnown() == null) 0 else 1) + - modelType.let { - if (it == JsonValue.from("tiered_with_proration")) 1 else 0 - } + + modelType.let { if (it == JsonValue.from("bulk_with_filters")) 1 else 0 } + (if (name.asKnown() == null) 0 else 1) + - (tieredWithProrationConfig.asKnown()?.validity() ?: 0) + (if (billableMetricId.asKnown() == null) 0 else 1) + (if (billedInAdvance.asKnown() == null) 0 else 1) + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + @@ -4242,201 +4268,66 @@ private constructor( (metadata.asKnown()?.validity() ?: 0) + (if (referenceId.asKnown() == null) 0 else 1) - /** The cadence to bill for this price on. */ - class Cadence - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - val ANNUAL = of("annual") - - val SEMI_ANNUAL = of("semi_annual") - - val MONTHLY = of("monthly") - - val QUARTERLY = of("quarterly") - - val ONE_TIME = of("one_time") - - val CUSTOM = of("custom") - - fun of(value: String) = Cadence(JsonField.of(value)) - } + /** Configuration for bulk_with_filters pricing */ + class BulkWithFiltersConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val filters: JsonField>, + private val tiers: JsonField>, + private val additionalProperties: MutableMap, + ) { - /** An enum containing [Cadence]'s known values. */ - enum class Known { - ANNUAL, - SEMI_ANNUAL, - MONTHLY, - QUARTERLY, - ONE_TIME, - CUSTOM, - } + @JsonCreator + private constructor( + @JsonProperty("filters") + @ExcludeMissing + filters: JsonField> = JsonMissing.of(), + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of(), + ) : this(filters, tiers, mutableMapOf()) /** - * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * Property filters to apply (all must match) * - * An instance of [Cadence] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). */ - enum class Value { - ANNUAL, - SEMI_ANNUAL, - MONTHLY, - QUARTERLY, - ONE_TIME, - CUSTOM, - /** - * An enum member indicating that [Cadence] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } + fun filters(): List = filters.getRequired("filters") /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * Bulk tiers for rating based on total usage volume * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). */ - fun value(): Value = - when (this) { - ANNUAL -> Value.ANNUAL - SEMI_ANNUAL -> Value.SEMI_ANNUAL - MONTHLY -> Value.MONTHLY - QUARTERLY -> Value.QUARTERLY - ONE_TIME -> Value.ONE_TIME - CUSTOM -> Value.CUSTOM - else -> Value._UNKNOWN - } + fun tiers(): List = tiers.getRequired("tiers") /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. + * Returns the raw JSON value of [filters]. * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. + * Unlike [filters], this method doesn't throw if the JSON field has an + * unexpected type. */ - fun known(): Known = - when (this) { - ANNUAL -> Known.ANNUAL - SEMI_ANNUAL -> Known.SEMI_ANNUAL - MONTHLY -> Known.MONTHLY - QUARTERLY -> Known.QUARTERLY - ONE_TIME -> Known.ONE_TIME - CUSTOM -> Known.CUSTOM - else -> throw OrbInvalidDataException("Unknown Cadence: $value") - } + @JsonProperty("filters") + @ExcludeMissing + fun _filters(): JsonField> = filters /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. + * Returns the raw JSON value of [tiers]. * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. */ - fun asString(): String = - _value().asString() - ?: throw OrbInvalidDataException("Value is not a String") - - private var validated: Boolean = false - - fun validate(): Cadence = apply { - if (validated) { - return@apply - } + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Cadence && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** Configuration for tiered_with_proration pricing */ - class TieredWithProrationConfig - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val tiers: JsonField>, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("tiers") - @ExcludeMissing - tiers: JsonField> = JsonMissing.of() - ) : this(tiers, mutableMapOf()) - - /** - * Tiers for rating based on total usage quantities into the specified tier with - * proration - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun tiers(): List = tiers.getRequired("tiers") - - /** - * Returns the raw JSON value of [tiers]. - * - * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("tiers") - @ExcludeMissing - fun _tiers(): JsonField> = tiers - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) } @JsonAnyGetter @@ -4450,34 +4341,60 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [TieredWithProrationConfig]. + * [BulkWithFiltersConfig]. * * The following fields are required: * ```kotlin + * .filters() * .tiers() * ``` */ fun builder() = Builder() } - /** A builder for [TieredWithProrationConfig]. */ + /** A builder for [BulkWithFiltersConfig]. */ class Builder internal constructor() { + private var filters: JsonField>? = null private var tiers: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(tieredWithProrationConfig: TieredWithProrationConfig) = - apply { - tiers = tieredWithProrationConfig.tiers.map { it.toMutableList() } - additionalProperties = - tieredWithProrationConfig.additionalProperties.toMutableMap() - } + internal fun from(bulkWithFiltersConfig: BulkWithFiltersConfig) = apply { + filters = bulkWithFiltersConfig.filters.map { it.toMutableList() } + tiers = bulkWithFiltersConfig.tiers.map { it.toMutableList() } + additionalProperties = + bulkWithFiltersConfig.additionalProperties.toMutableMap() + } + + /** Property filters to apply (all must match) */ + fun filters(filters: List) = filters(JsonField.of(filters)) /** - * Tiers for rating based on total usage quantities into the specified tier - * with proration + * Sets [Builder.filters] to an arbitrary JSON value. + * + * You should usually call [Builder.filters] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun filters(filters: JsonField>) = apply { + this.filters = filters.map { it.toMutableList() } + } + + /** + * Adds a single [Filter] to [filters]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. */ + fun addFilter(filter: Filter) = apply { + filters = + (filters ?: JsonField.of(mutableListOf())).also { + checkKnown("filters", it).add(filter) + } + } + + /** Bulk tiers for rating based on total usage volume */ fun tiers(tiers: List) = tiers(JsonField.of(tiers)) /** @@ -4527,19 +4444,21 @@ private constructor( } /** - * Returns an immutable instance of [TieredWithProrationConfig]. + * Returns an immutable instance of [BulkWithFiltersConfig]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```kotlin + * .filters() * .tiers() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): TieredWithProrationConfig = - TieredWithProrationConfig( + fun build(): BulkWithFiltersConfig = + BulkWithFiltersConfig( + checkRequired("filters", filters).map { it.toImmutable() }, checkRequired("tiers", tiers).map { it.toImmutable() }, additionalProperties.toMutableMap(), ) @@ -4547,11 +4466,12 @@ private constructor( private var validated: Boolean = false - fun validate(): TieredWithProrationConfig = apply { + fun validate(): BulkWithFiltersConfig = apply { if (validated) { return@apply } + filters().forEach { it.validate() } tiers().forEach { it.validate() } validated = true } @@ -4571,65 +4491,65 @@ private constructor( * Used for best match union deserialization. */ internal fun validity(): Int = - (tiers.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + (filters.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + (tiers.asKnown()?.sumOf { it.validity().toInt() } ?: 0) - /** Configuration for a single tiered with proration tier */ - class Tier + /** Configuration for a single property filter */ + class Filter @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val tierLowerBound: JsonField, - private val unitAmount: JsonField, + private val propertyKey: JsonField, + private val propertyValue: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("tier_lower_bound") + @JsonProperty("property_key") @ExcludeMissing - tierLowerBound: JsonField = JsonMissing.of(), - @JsonProperty("unit_amount") + propertyKey: JsonField = JsonMissing.of(), + @JsonProperty("property_value") @ExcludeMissing - unitAmount: JsonField = JsonMissing.of(), - ) : this(tierLowerBound, unitAmount, mutableMapOf()) + propertyValue: JsonField = JsonMissing.of(), + ) : this(propertyKey, propertyValue, mutableMapOf()) /** - * Inclusive tier starting value + * Event property key to filter on * * @throws OrbInvalidDataException if the JSON field has an unexpected type * or is unexpectedly missing or null (e.g. if the server responded with * an unexpected value). */ - fun tierLowerBound(): String = - tierLowerBound.getRequired("tier_lower_bound") + fun propertyKey(): String = propertyKey.getRequired("property_key") /** - * Amount per unit + * Event property value to match * * @throws OrbInvalidDataException if the JSON field has an unexpected type * or is unexpectedly missing or null (e.g. if the server responded with * an unexpected value). */ - fun unitAmount(): String = unitAmount.getRequired("unit_amount") + fun propertyValue(): String = propertyValue.getRequired("property_value") /** - * Returns the raw JSON value of [tierLowerBound]. + * Returns the raw JSON value of [propertyKey]. * - * Unlike [tierLowerBound], this method doesn't throw if the JSON field has - * an unexpected type. + * Unlike [propertyKey], this method doesn't throw if the JSON field has an + * unexpected type. */ - @JsonProperty("tier_lower_bound") + @JsonProperty("property_key") @ExcludeMissing - fun _tierLowerBound(): JsonField = tierLowerBound + fun _propertyKey(): JsonField = propertyKey /** - * Returns the raw JSON value of [unitAmount]. + * Returns the raw JSON value of [propertyValue]. * - * Unlike [unitAmount], this method doesn't throw if the JSON field has an - * unexpected type. + * Unlike [propertyValue], this method doesn't throw if the JSON field has + * an unexpected type. */ - @JsonProperty("unit_amount") + @JsonProperty("property_value") @ExcludeMissing - fun _unitAmount(): JsonField = unitAmount + fun _propertyValue(): JsonField = propertyValue @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -4646,59 +4566,59 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [Tier]. + * Returns a mutable builder for constructing an instance of [Filter]. * * The following fields are required: * ```kotlin - * .tierLowerBound() - * .unitAmount() + * .propertyKey() + * .propertyValue() * ``` */ fun builder() = Builder() } - /** A builder for [Tier]. */ + /** A builder for [Filter]. */ class Builder internal constructor() { - private var tierLowerBound: JsonField? = null - private var unitAmount: JsonField? = null + private var propertyKey: JsonField? = null + private var propertyValue: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(tier: Tier) = apply { - tierLowerBound = tier.tierLowerBound - unitAmount = tier.unitAmount - additionalProperties = tier.additionalProperties.toMutableMap() + internal fun from(filter: Filter) = apply { + propertyKey = filter.propertyKey + propertyValue = filter.propertyValue + additionalProperties = filter.additionalProperties.toMutableMap() } - /** Inclusive tier starting value */ - fun tierLowerBound(tierLowerBound: String) = - tierLowerBound(JsonField.of(tierLowerBound)) + /** Event property key to filter on */ + fun propertyKey(propertyKey: String) = + propertyKey(JsonField.of(propertyKey)) /** - * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * Sets [Builder.propertyKey] to an arbitrary JSON value. * - * You should usually call [Builder.tierLowerBound] with a well-typed + * You should usually call [Builder.propertyKey] with a well-typed * [String] value instead. This method is primarily for setting the * field to an undocumented or not yet supported value. */ - fun tierLowerBound(tierLowerBound: JsonField) = apply { - this.tierLowerBound = tierLowerBound + fun propertyKey(propertyKey: JsonField) = apply { + this.propertyKey = propertyKey } - /** Amount per unit */ - fun unitAmount(unitAmount: String) = - unitAmount(JsonField.of(unitAmount)) + /** Event property value to match */ + fun propertyValue(propertyValue: String) = + propertyValue(JsonField.of(propertyValue)) /** - * Sets [Builder.unitAmount] to an arbitrary JSON value. + * Sets [Builder.propertyValue] to an arbitrary JSON value. * - * You should usually call [Builder.unitAmount] with a well-typed + * You should usually call [Builder.propertyValue] with a well-typed * [String] value instead. This method is primarily for setting the * field to an undocumented or not yet supported value. */ - fun unitAmount(unitAmount: JsonField) = apply { - this.unitAmount = unitAmount + fun propertyValue(propertyValue: JsonField) = apply { + this.propertyValue = propertyValue } fun additionalProperties(additionalProperties: Map) = @@ -4724,36 +4644,36 @@ private constructor( } /** - * Returns an immutable instance of [Tier]. + * Returns an immutable instance of [Filter]. * * Further updates to this [Builder] will not mutate the returned * instance. * * The following fields are required: * ```kotlin - * .tierLowerBound() - * .unitAmount() + * .propertyKey() + * .propertyValue() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): Tier = - Tier( - checkRequired("tierLowerBound", tierLowerBound), - checkRequired("unitAmount", unitAmount), + fun build(): Filter = + Filter( + checkRequired("propertyKey", propertyKey), + checkRequired("propertyValue", propertyValue), additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): Tier = apply { + fun validate(): Filter = apply { if (validated) { return@apply } - tierLowerBound() - unitAmount() + propertyKey() + propertyValue() validated = true } @@ -4772,4573 +4692,3965 @@ private constructor( * Used for best match union deserialization. */ internal fun validity(): Int = - (if (tierLowerBound.asKnown() == null) 0 else 1) + - (if (unitAmount.asKnown() == null) 0 else 1) + (if (propertyKey.asKnown() == null) 0 else 1) + + (if (propertyValue.asKnown() == null) 0 else 1) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is Tier && - tierLowerBound == other.tierLowerBound && - unitAmount == other.unitAmount && + return other is Filter && + propertyKey == other.propertyKey && + propertyValue == other.propertyValue && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(tierLowerBound, unitAmount, additionalProperties) + Objects.hash(propertyKey, propertyValue, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "Tier{tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is TieredWithProrationConfig && - tiers == other.tiers && - additionalProperties == other.additionalProperties + "Filter{propertyKey=$propertyKey, propertyValue=$propertyValue, additionalProperties=$additionalProperties}" } - private val hashCode: Int by lazy { Objects.hash(tiers, additionalProperties) } + /** Configuration for a single bulk pricing tier */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val unitAmount: JsonField, + private val tierLowerBound: JsonField, + private val additionalProperties: MutableMap, + ) { - override fun hashCode(): Int = hashCode + @JsonCreator + private constructor( + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + ) : this(unitAmount, tierLowerBound, mutableMapOf()) - override fun toString() = - "TieredWithProrationConfig{tiers=$tiers, additionalProperties=$additionalProperties}" - } + /** + * Amount per unit + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - class Metadata - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { + /** + * The lower bound for this tier + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun tierLowerBound(): String? = + tierLowerBound.getNullable("tier_lower_bound") - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount - fun toBuilder() = Builder().from(this) + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound - companion object { + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - /** Returns a mutable builder for constructing an instance of [Metadata]. */ - fun builder() = Builder() - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - /** A builder for [Metadata]. */ - class Builder internal constructor() { + fun toBuilder() = Builder().from(this) - private var additionalProperties: MutableMap = - mutableMapOf() + companion object { - internal fun from(metadata: Metadata) = apply { - additionalProperties = metadata.additionalProperties.toMutableMap() + /** + * Returns a mutable builder for constructing an instance of [Tier]. + * + * The following fields are required: + * ```kotlin + * .unitAmount() + * ``` + */ + fun builder() = Builder() } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var unitAmount: JsonField? = null + private var tierLowerBound: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(tier: Tier) = apply { + unitAmount = tier.unitAmount + tierLowerBound = tier.tierLowerBound + additionalProperties = tier.additionalProperties.toMutableMap() } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** Amount per unit */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) + /** The lower bound for this tier */ + fun tierLowerBound(tierLowerBound: String?) = + tierLowerBound(JsonField.ofNullable(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```kotlin + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("unitAmount", unitAmount), + tierLowerBound, + additionalProperties.toMutableMap(), + ) } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + unitAmount() + tierLowerBound() + validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + /** - * Returns an immutable instance of [Metadata]. + * Returns a score indicating how many valid values are contained in this + * object recursively. * - * Further updates to this [Builder] will not mutate the returned instance. + * Used for best match union deserialization. */ - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } + internal fun validity(): Int = + (if (unitAmount.asKnown() == null) 0 else 1) + + (if (tierLowerBound.asKnown() == null) 0 else 1) - private var validated: Boolean = false + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun validate(): Metadata = apply { - if (validated) { - return@apply + return other is Tier && + unitAmount == other.unitAmount && + tierLowerBound == other.tierLowerBound && + additionalProperties == other.additionalProperties } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false + private val hashCode: Int by lazy { + Objects.hash(unitAmount, tierLowerBound, additionalProperties) } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - additionalProperties.count { (_, value) -> - !value.isNull() && !value.isMissing() - } + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{unitAmount=$unitAmount, tierLowerBound=$tierLowerBound, additionalProperties=$additionalProperties}" + } override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is Metadata && + return other is BulkWithFiltersConfig && + filters == other.filters && + tiers == other.tiers && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + private val hashCode: Int by lazy { + Objects.hash(filters, tiers, additionalProperties) + } override fun hashCode(): Int = hashCode - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + override fun toString() = + "BulkWithFiltersConfig{filters=$filters, tiers=$tiers, additionalProperties=$additionalProperties}" } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { - return other is TieredWithProration && - cadence == other.cadence && - itemId == other.itemId && - modelType == other.modelType && - name == other.name && - tieredWithProrationConfig == other.tieredWithProrationConfig && - billableMetricId == other.billableMetricId && - billedInAdvance == other.billedInAdvance && - billingCycleConfiguration == other.billingCycleConfiguration && - conversionRate == other.conversionRate && - conversionRateConfig == other.conversionRateConfig && - currency == other.currency && - dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && - externalPriceId == other.externalPriceId && - fixedPriceQuantity == other.fixedPriceQuantity && - invoiceGroupingKey == other.invoiceGroupingKey && - invoicingCycleConfiguration == other.invoicingCycleConfiguration && - metadata == other.metadata && - referenceId == other.referenceId && - additionalProperties == other.additionalProperties - } + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value - private val hashCode: Int by lazy { - Objects.hash( - cadence, - itemId, - modelType, - name, - tieredWithProrationConfig, - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - conversionRateConfig, - currency, - dimensionalPriceConfiguration, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - additionalProperties, - ) - } + companion object { - override fun hashCode(): Int = hashCode + val ANNUAL = of("annual") - override fun toString() = - "TieredWithProration{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredWithProrationConfig=$tieredWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" - } + val SEMI_ANNUAL = of("semi_annual") - class GroupedWithMinMaxThresholds - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val cadence: JsonField, - private val groupedWithMinMaxThresholdsConfig: - JsonField, - private val itemId: JsonField, - private val modelType: JsonValue, - private val name: JsonField, - private val billableMetricId: JsonField, - private val billedInAdvance: JsonField, - private val billingCycleConfiguration: JsonField, - private val conversionRate: JsonField, - private val conversionRateConfig: JsonField, - private val currency: JsonField, - private val dimensionalPriceConfiguration: - JsonField, - private val externalPriceId: JsonField, - private val fixedPriceQuantity: JsonField, - private val invoiceGroupingKey: JsonField, - private val invoicingCycleConfiguration: JsonField, - private val metadata: JsonField, - private val referenceId: JsonField, - private val additionalProperties: MutableMap, - ) { + val MONTHLY = of("monthly") - @JsonCreator - private constructor( - @JsonProperty("cadence") - @ExcludeMissing - cadence: JsonField = JsonMissing.of(), - @JsonProperty("grouped_with_min_max_thresholds_config") - @ExcludeMissing - groupedWithMinMaxThresholdsConfig: - JsonField = - JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - modelType: JsonValue = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - name: JsonField = JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("conversion_rate_config") - @ExcludeMissing - conversionRateConfig: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - currency: JsonField = JsonMissing.of(), - @JsonProperty("dimensional_price_configuration") - @ExcludeMissing - dimensionalPriceConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - metadata: JsonField = JsonMissing.of(), - @JsonProperty("reference_id") - @ExcludeMissing - referenceId: JsonField = JsonMissing.of(), - ) : this( - cadence, - groupedWithMinMaxThresholdsConfig, - itemId, - modelType, - name, - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - conversionRateConfig, - currency, - dimensionalPriceConfiguration, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - mutableMapOf(), - ) + val QUARTERLY = of("quarterly") - /** - * The cadence to bill for this price on. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun cadence(): Cadence = cadence.getRequired("cadence") + val ONE_TIME = of("one_time") - /** - * Configuration for grouped_with_min_max_thresholds pricing - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun groupedWithMinMaxThresholdsConfig(): GroupedWithMinMaxThresholdsConfig = - groupedWithMinMaxThresholdsConfig.getRequired( - "grouped_with_min_max_thresholds_config" - ) + val CUSTOM = of("custom") - /** - * The id of the item the price will be associated with. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun itemId(): String = itemId.getRequired("item_id") + fun of(value: String) = Cadence(JsonField.of(value)) + } - /** - * The pricing model type - * - * Expected to always return the following: - * ```kotlin - * JsonValue.from("grouped_with_min_max_thresholds") - * ``` - * - * However, this method can be useful for debugging and logging (e.g. if the server - * responded with an unexpected value). - */ - @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } - /** - * The name of the price. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun name(): String = name.getRequired("name") + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun billableMetricId(): String? = billableMetricId.getNullable("billable_metric_id") + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun billingCycleConfiguration(): NewBillingCycleConfiguration? = - billingCycleConfiguration.getNullable("billing_cycle_configuration") + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") - /** - * The per unit conversion rate of the price currency to the invoicing currency. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + private var validated: Boolean = false - /** - * The configuration for the rate of the price currency to the invoicing currency. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun conversionRateConfig(): ConversionRateConfig? = - conversionRateConfig.getNullable("conversion_rate_config") + fun validate(): Cadence = apply { + if (validated) { + return@apply + } - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun currency(): String? = currency.getNullable("currency") + known() + validated = true + } - /** - * For dimensional price: specifies a price group and dimension values - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = - dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - /** - * An alias for the price. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun fixedPriceQuantity(): Double? = - fixedPriceQuantity.getNullable("fixed_price_quantity") + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * The property used to group this price on an invoice - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun invoiceGroupingKey(): String? = - invoiceGroupingKey.getNullable("invoice_grouping_key") + return other is Cadence && value == other.value + } - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by * setting `metadata` to `null`. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). */ - fun metadata(): Metadata? = metadata.getNullable("metadata") + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun referenceId(): String? = referenceId.getNullable("reference_id") + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties - /** - * Returns the raw JSON value of [cadence]. - * - * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("cadence") - @ExcludeMissing - fun _cadence(): JsonField = cadence + fun toBuilder() = Builder().from(this) - /** - * Returns the raw JSON value of [groupedWithMinMaxThresholdsConfig]. - * - * Unlike [groupedWithMinMaxThresholdsConfig], this method doesn't throw if the JSON - * field has an unexpected type. - */ - @JsonProperty("grouped_with_min_max_thresholds_config") - @ExcludeMissing - fun _groupedWithMinMaxThresholdsConfig(): - JsonField = groupedWithMinMaxThresholdsConfig + companion object { - /** - * Returns the raw JSON value of [itemId]. - * - * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } - /** - * Returns the raw JSON value of [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + /** A builder for [Metadata]. */ + class Builder internal constructor() { - /** - * Returns the raw JSON value of [billableMetricId]. - * - * Unlike [billableMetricId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = billableMetricId + private var additionalProperties: MutableMap = + mutableMapOf() - /** - * Returns the raw JSON value of [billedInAdvance]. - * - * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } - /** - * Returns the raw JSON value of [billingCycleConfiguration]. - * - * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** - * Returns the raw JSON value of [conversionRate]. - * - * Unlike [conversionRate], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * Returns the raw JSON value of [conversionRateConfig]. - * - * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("conversion_rate_config") - @ExcludeMissing - fun _conversionRateConfig(): JsonField = conversionRateConfig + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - /** - * Returns the raw JSON value of [currency]. - * - * Unlike [currency], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("currency") - @ExcludeMissing - fun _currency(): JsonField = currency + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - /** - * Returns the raw JSON value of [dimensionalPriceConfiguration]. - * - * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON - * field has an unexpected type. - */ - @JsonProperty("dimensional_price_configuration") - @ExcludeMissing - fun _dimensionalPriceConfiguration(): JsonField = - dimensionalPriceConfiguration + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - /** - * Returns the raw JSON value of [externalPriceId]. - * - * Unlike [externalPriceId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } - /** - * Returns the raw JSON value of [fixedPriceQuantity]. - * - * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** - * Returns the raw JSON value of [invoiceGroupingKey]. - * - * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Returns the raw JSON value of [invoicingCycleConfiguration]. - * - * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * Returns the raw JSON value of [metadata]. - * - * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - /** - * Returns the raw JSON value of [referenceId]. - * - * Unlike [referenceId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("reference_id") - @ExcludeMissing - fun _referenceId(): JsonField = referenceId - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + private var validated: Boolean = false - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + fun validate(): Metadata = apply { + if (validated) { + return@apply + } - fun toBuilder() = Builder().from(this) + validated = true + } - companion object { + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } /** - * Returns a mutable builder for constructing an instance of - * [GroupedWithMinMaxThresholds]. + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * The following fields are required: - * ```kotlin - * .cadence() - * .groupedWithMinMaxThresholdsConfig() - * .itemId() - * .name() - * ``` + * Used for best match union deserialization. */ - fun builder() = Builder() - } - - /** A builder for [GroupedWithMinMaxThresholds]. */ - class Builder internal constructor() { - - private var cadence: JsonField? = null - private var groupedWithMinMaxThresholdsConfig: - JsonField? = - null - private var itemId: JsonField? = null - private var modelType: JsonValue = - JsonValue.from("grouped_with_min_max_thresholds") - private var name: JsonField? = null - private var billableMetricId: JsonField = JsonMissing.of() - private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var conversionRateConfig: JsonField = - JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var dimensionalPriceConfiguration: - JsonField = - JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: - JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var referenceId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } - internal fun from(groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds) = - apply { - cadence = groupedWithMinMaxThresholds.cadence - groupedWithMinMaxThresholdsConfig = - groupedWithMinMaxThresholds.groupedWithMinMaxThresholdsConfig - itemId = groupedWithMinMaxThresholds.itemId - modelType = groupedWithMinMaxThresholds.modelType - name = groupedWithMinMaxThresholds.name - billableMetricId = groupedWithMinMaxThresholds.billableMetricId - billedInAdvance = groupedWithMinMaxThresholds.billedInAdvance - billingCycleConfiguration = - groupedWithMinMaxThresholds.billingCycleConfiguration - conversionRate = groupedWithMinMaxThresholds.conversionRate - conversionRateConfig = groupedWithMinMaxThresholds.conversionRateConfig - currency = groupedWithMinMaxThresholds.currency - dimensionalPriceConfiguration = - groupedWithMinMaxThresholds.dimensionalPriceConfiguration - externalPriceId = groupedWithMinMaxThresholds.externalPriceId - fixedPriceQuantity = groupedWithMinMaxThresholds.fixedPriceQuantity - invoiceGroupingKey = groupedWithMinMaxThresholds.invoiceGroupingKey - invoicingCycleConfiguration = - groupedWithMinMaxThresholds.invoicingCycleConfiguration - metadata = groupedWithMinMaxThresholds.metadata - referenceId = groupedWithMinMaxThresholds.referenceId - additionalProperties = - groupedWithMinMaxThresholds.additionalProperties.toMutableMap() + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + return other is Metadata && + additionalProperties == other.additionalProperties + } - /** - * Sets [Builder.cadence] to an arbitrary JSON value. - * - * You should usually call [Builder.cadence] with a well-typed [Cadence] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /** Configuration for grouped_with_min_max_thresholds pricing */ - fun groupedWithMinMaxThresholdsConfig( - groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig - ) = - groupedWithMinMaxThresholdsConfig( - JsonField.of(groupedWithMinMaxThresholdsConfig) - ) + override fun hashCode(): Int = hashCode - /** - * Sets [Builder.groupedWithMinMaxThresholdsConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.groupedWithMinMaxThresholdsConfig] with a - * well-typed [GroupedWithMinMaxThresholdsConfig] value instead. This method is - * primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun groupedWithMinMaxThresholdsConfig( - groupedWithMinMaxThresholdsConfig: - JsonField - ) = apply { - this.groupedWithMinMaxThresholdsConfig = groupedWithMinMaxThresholdsConfig + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - /** The id of the item the price will be associated with. */ - fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + return other is BulkWithFilters && + bulkWithFiltersConfig == other.bulkWithFiltersConfig && + cadence == other.cadence && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } - /** - * Sets [Builder.itemId] to an arbitrary JSON value. - * - * You should usually call [Builder.itemId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + private val hashCode: Int by lazy { + Objects.hash( + bulkWithFiltersConfig, + cadence, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties, + ) + } - /** - * Sets the field to an arbitrary JSON value. - * - * It is usually unnecessary to call this method because the field defaults to - * the following: - * ```kotlin - * JsonValue.from("grouped_with_min_max_thresholds") - * ``` - * - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + override fun hashCode(): Int = hashCode - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) + override fun toString() = + "BulkWithFilters{bulkWithFiltersConfig=$bulkWithFiltersConfig, cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } - /** - * Sets [Builder.name] to an arbitrary JSON value. - * - * You should usually call [Builder.name] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun name(name: JsonField) = apply { this.name = name } + class TieredWithProration + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val tieredWithProrationConfig: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: String?) = - billableMetricId(JsonField.ofNullable(billableMetricId)) + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("tiered_with_proration_config") + @ExcludeMissing + tieredWithProrationConfig: JsonField = + JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + modelType, + name, + tieredWithProrationConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + mutableMapOf(), + ) - /** - * Sets [Builder.billableMetricId] to an arbitrary JSON value. - * - * You should usually call [Builder.billableMetricId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun billableMetricId(billableMetricId: JsonField) = apply { - this.billableMetricId = billableMetricId - } + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") - /** - * If the Price represents a fixed cost, the price will be billed in-advance if - * this is true, and in-arrears if this is false. - */ - fun billedInAdvance(billedInAdvance: Boolean?) = - billedInAdvance(JsonField.ofNullable(billedInAdvance)) + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") - /** - * Alias for [Builder.billedInAdvance]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun billedInAdvance(billedInAdvance: Boolean) = - billedInAdvance(billedInAdvance as Boolean?) + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("tiered_with_proration") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType - /** - * Sets [Builder.billedInAdvance] to an arbitrary JSON value. - * - * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun billedInAdvance(billedInAdvance: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: NewBillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + /** + * Configuration for tiered_with_proration pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun tieredWithProrationConfig(): TieredWithProrationConfig = + tieredWithProrationConfig.getRequired("tiered_with_proration_config") - /** - * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.billingCycleConfiguration] with a well-typed - * [NewBillingCycleConfiguration] value instead. This method is primarily for - * setting the field to an undocumented or not yet supported value. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: JsonField - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = billableMetricId.getNullable("billable_metric_id") - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: Double?) = - conversionRate(JsonField.ofNullable(conversionRate)) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") - /** - * Alias for [Builder.conversionRate]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") - /** - * Sets [Builder.conversionRate] to an arbitrary JSON value. - * - * You should usually call [Builder.conversionRate] with a well-typed [Double] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") - /** - * The configuration for the rate of the price currency to the invoicing - * currency. - */ - fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = - conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") - /** - * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.conversionRateConfig] with a well-typed - * [ConversionRateConfig] value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun conversionRateConfig( - conversionRateConfig: JsonField - ) = apply { this.conversionRateConfig = conversionRateConfig } + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") - /** - * Alias for calling [conversionRateConfig] with - * `ConversionRateConfig.ofUnit(unit)`. - */ - fun conversionRateConfig(unit: UnitConversionRateConfig) = - conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") - /** - * Alias for calling [conversionRateConfig] with the following: - * ```kotlin - * UnitConversionRateConfig.builder() - * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) - * .unitConfig(unitConfig) - * .build() - * ``` - */ - fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = - conversionRateConfig( - UnitConversionRateConfig.builder() - .conversionRateType( - UnitConversionRateConfig.ConversionRateType.UNIT - ) - .unitConfig(unitConfig) - .build() - ) + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") - /** - * Alias for calling [conversionRateConfig] with - * `ConversionRateConfig.ofTiered(tiered)`. - */ - fun conversionRateConfig(tiered: TieredConversionRateConfig) = - conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") - /** - * Alias for calling [conversionRateConfig] with the following: - * ```kotlin - * TieredConversionRateConfig.builder() - * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) - * .tieredConfig(tieredConfig) - * .build() - * ``` - */ - fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = - conversionRateConfig( - TieredConversionRateConfig.builder() - .conversionRateType( - TieredConversionRateConfig.ConversionRateType.TIERED - ) - .tieredConfig(tieredConfig) - .build() - ) + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + invoiceGroupingKey.getNullable("invoice_grouping_key") - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - /** - * Sets [Builder.currency] to an arbitrary JSON value. - * - * You should usually call [Builder.currency] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") - /** For dimensional price: specifies a price group and dimension values */ - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? - ) = - dimensionalPriceConfiguration( - JsonField.ofNullable(dimensionalPriceConfiguration) - ) + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") - /** - * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.dimensionalPriceConfiguration] with a - * well-typed [NewDimensionalPriceConfiguration] value instead. This method is - * primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: JsonField - ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - /** - * Sets [Builder.externalPriceId] to an arbitrary JSON value. - * - * You should usually call [Builder.externalPriceId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun externalPriceId(externalPriceId: JsonField) = apply { - this.externalPriceId = externalPriceId - } + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = - fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + /** + * Returns the raw JSON value of [tieredWithProrationConfig]. + * + * Unlike [tieredWithProrationConfig], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("tiered_with_proration_config") + @ExcludeMissing + fun _tieredWithProrationConfig(): JsonField = + tieredWithProrationConfig - /** - * Alias for [Builder.fixedPriceQuantity]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId - /** - * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. - * - * You should usually call [Builder.fixedPriceQuantity] with a well-typed - * [Double] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = - invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration - /** - * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. - * - * You should usually call [Builder.invoiceGroupingKey] with a well-typed - * [String] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { - this.invoiceGroupingKey = invoiceGroupingKey - } + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate - /** - * Within each billing cycle, specifies the cadence at which invoices are - * produced. If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: NewBillingCycleConfiguration? - ) = - invoicingCycleConfiguration( - JsonField.ofNullable(invoicingCycleConfiguration) - ) + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig - /** - * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.invoicingCycleConfiguration] with a - * well-typed [NewBillingCycleConfiguration] value instead. This method is - * primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration - /** - * Sets [Builder.metadata] to an arbitrary JSON value. - * - * You should usually call [Builder.metadata] with a well-typed [Metadata] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - fun referenceId(referenceId: String?) = - referenceId(JsonField.ofNullable(referenceId)) + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - /** - * Sets [Builder.referenceId] to an arbitrary JSON value. - * - * You should usually call [Builder.referenceId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun referenceId(referenceId: JsonField) = apply { - this.referenceId = referenceId - } + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { /** - * Returns an immutable instance of [GroupedWithMinMaxThresholds]. - * - * Further updates to this [Builder] will not mutate the returned instance. + * Returns a mutable builder for constructing an instance of + * [TieredWithProration]. * * The following fields are required: * ```kotlin * .cadence() - * .groupedWithMinMaxThresholdsConfig() * .itemId() * .name() + * .tieredWithProrationConfig() * ``` - * - * @throws IllegalStateException if any required field is unset. */ - fun build(): GroupedWithMinMaxThresholds = - GroupedWithMinMaxThresholds( - checkRequired("cadence", cadence), - checkRequired( - "groupedWithMinMaxThresholdsConfig", - groupedWithMinMaxThresholdsConfig, - ), - checkRequired("itemId", itemId), - modelType, - checkRequired("name", name), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - conversionRateConfig, - currency, - dimensionalPriceConfiguration, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - additionalProperties.toMutableMap(), - ) + fun builder() = Builder() } - private var validated: Boolean = false - - fun validate(): GroupedWithMinMaxThresholds = apply { - if (validated) { - return@apply - } + /** A builder for [TieredWithProration]. */ + class Builder internal constructor() { - cadence().validate() - groupedWithMinMaxThresholdsConfig().validate() - itemId() - _modelType().let { - if (it != JsonValue.from("grouped_with_min_max_thresholds")) { - throw OrbInvalidDataException("'modelType' is invalid, received $it") - } - } - name() - billableMetricId() - billedInAdvance() - billingCycleConfiguration()?.validate() - conversionRate() - conversionRateConfig()?.validate() - currency() - dimensionalPriceConfiguration()?.validate() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration()?.validate() - metadata()?.validate() - referenceId() - validated = true - } + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonValue = JsonValue.from("tiered_with_proration") + private var name: JsonField? = null + private var tieredWithProrationConfig: JsonField? = + null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false + internal fun from(tieredWithProration: TieredWithProration) = apply { + cadence = tieredWithProration.cadence + itemId = tieredWithProration.itemId + modelType = tieredWithProration.modelType + name = tieredWithProration.name + tieredWithProrationConfig = tieredWithProration.tieredWithProrationConfig + billableMetricId = tieredWithProration.billableMetricId + billedInAdvance = tieredWithProration.billedInAdvance + billingCycleConfiguration = tieredWithProration.billingCycleConfiguration + conversionRate = tieredWithProration.conversionRate + conversionRateConfig = tieredWithProration.conversionRateConfig + currency = tieredWithProration.currency + dimensionalPriceConfiguration = + tieredWithProration.dimensionalPriceConfiguration + externalPriceId = tieredWithProration.externalPriceId + fixedPriceQuantity = tieredWithProration.fixedPriceQuantity + invoiceGroupingKey = tieredWithProration.invoiceGroupingKey + invoicingCycleConfiguration = + tieredWithProration.invoicingCycleConfiguration + metadata = tieredWithProration.metadata + referenceId = tieredWithProration.referenceId + additionalProperties = + tieredWithProration.additionalProperties.toMutableMap() } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (cadence.asKnown()?.validity() ?: 0) + - (groupedWithMinMaxThresholdsConfig.asKnown()?.validity() ?: 0) + - (if (itemId.asKnown() == null) 0 else 1) + - modelType.let { - if (it == JsonValue.from("grouped_with_min_max_thresholds")) 1 else 0 - } + - (if (name.asKnown() == null) 0 else 1) + - (if (billableMetricId.asKnown() == null) 0 else 1) + - (if (billedInAdvance.asKnown() == null) 0 else 1) + - (billingCycleConfiguration.asKnown()?.validity() ?: 0) + - (if (conversionRate.asKnown() == null) 0 else 1) + - (conversionRateConfig.asKnown()?.validity() ?: 0) + - (if (currency.asKnown() == null) 0 else 1) + - (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + - (if (externalPriceId.asKnown() == null) 0 else 1) + - (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + - (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + - (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + - (metadata.asKnown()?.validity() ?: 0) + - (if (referenceId.asKnown() == null) 0 else 1) - - /** The cadence to bill for this price on. */ - class Cadence - @JsonCreator - private constructor(private val value: JsonField) : Enum { + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) /** - * Returns this class instance's raw value. + * Sets [Builder.cadence] to an arbitrary JSON value. * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - val ANNUAL = of("annual") + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - val SEMI_ANNUAL = of("semi_annual") + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - val MONTHLY = of("monthly") + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("tiered_with_proration") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } - val QUARTERLY = of("quarterly") + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) - val ONE_TIME = of("one_time") + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } - val CUSTOM = of("custom") + /** Configuration for tiered_with_proration pricing */ + fun tieredWithProrationConfig( + tieredWithProrationConfig: TieredWithProrationConfig + ) = tieredWithProrationConfig(JsonField.of(tieredWithProrationConfig)) - fun of(value: String) = Cadence(JsonField.of(value)) - } + /** + * Sets [Builder.tieredWithProrationConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.tieredWithProrationConfig] with a well-typed + * [TieredWithProrationConfig] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun tieredWithProrationConfig( + tieredWithProrationConfig: JsonField + ) = apply { this.tieredWithProrationConfig = tieredWithProrationConfig } - /** An enum containing [Cadence]'s known values. */ - enum class Known { - ANNUAL, - SEMI_ANNUAL, - MONTHLY, - QUARTERLY, - ONE_TIME, - CUSTOM, - } + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) /** - * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * Sets [Builder.billableMetricId] to an arbitrary JSON value. * - * An instance of [Cadence] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. */ - enum class Value { - ANNUAL, - SEMI_ANNUAL, - MONTHLY, - QUARTERLY, - ONE_TIME, - CUSTOM, - /** - * An enum member indicating that [Cadence] was instantiated with an unknown - * value. - */ - _UNKNOWN, + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId } /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. */ - fun value(): Value = - when (this) { - ANNUAL -> Value.ANNUAL - SEMI_ANNUAL -> Value.SEMI_ANNUAL - MONTHLY -> Value.MONTHLY - QUARTERLY -> Value.QUARTERLY - ONE_TIME -> Value.ONE_TIME - CUSTOM -> Value.CUSTOM - else -> Value._UNKNOWN - } + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) /** - * Returns an enum member corresponding to this class instance's value. + * Alias for [Builder.billedInAdvance]. * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. */ - fun known(): Known = - when (this) { - ANNUAL -> Known.ANNUAL - SEMI_ANNUAL -> Known.SEMI_ANNUAL - MONTHLY -> Known.MONTHLY - QUARTERLY -> Known.QUARTERLY - ONE_TIME -> Known.ONE_TIME - CUSTOM -> Known.CUSTOM - else -> throw OrbInvalidDataException("Unknown Cadence: $value") - } + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. */ - fun asString(): String = - _value().asString() - ?: throw OrbInvalidDataException("Value is not a String") + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } - private var validated: Boolean = false + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) - fun validate(): Cadence = apply { - if (validated) { - return@apply - } + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) - known() - validated = true + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) /** - * Returns a score indicating how many valid values are contained in this object - * recursively. + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. * - * Used for best match union deserialization. + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. */ - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Cadence && value == other.value - } - - override fun hashCode() = value.hashCode() + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } - override fun toString() = value.toString() - } + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) - /** Configuration for grouped_with_min_max_thresholds pricing */ - class GroupedWithMinMaxThresholdsConfig - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val groupingKey: JsonField, - private val maximumCharge: JsonField, - private val minimumCharge: JsonField, - private val perUnitRate: JsonField, - private val additionalProperties: MutableMap, - ) { + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) - @JsonCreator - private constructor( - @JsonProperty("grouping_key") - @ExcludeMissing - groupingKey: JsonField = JsonMissing.of(), - @JsonProperty("maximum_charge") - @ExcludeMissing - maximumCharge: JsonField = JsonMissing.of(), - @JsonProperty("minimum_charge") - @ExcludeMissing - minimumCharge: JsonField = JsonMissing.of(), - @JsonProperty("per_unit_rate") - @ExcludeMissing - perUnitRate: JsonField = JsonMissing.of(), - ) : this(groupingKey, maximumCharge, minimumCharge, perUnitRate, mutableMapOf()) + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) /** - * The event property used to group before applying thresholds - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` */ - fun groupingKey(): String = groupingKey.getRequired("grouping_key") + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) /** - * The maximum amount to charge each group - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. */ - fun maximumCharge(): String = maximumCharge.getRequired("maximum_charge") + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) /** - * The minimum amount to charge each group, regardless of usage + * Sets [Builder.currency] to an arbitrary JSON value. * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. */ - fun minimumCharge(): String = minimumCharge.getRequired("minimum_charge") + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) /** - * The base price charged per group + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. */ - fun perUnitRate(): String = perUnitRate.getRequired("per_unit_rate") + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) /** - * Returns the raw JSON value of [groupingKey]. + * Sets [Builder.externalPriceId] to an arbitrary JSON value. * - * Unlike [groupingKey], this method doesn't throw if the JSON field has an - * unexpected type. + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. */ - @JsonProperty("grouping_key") - @ExcludeMissing - fun _groupingKey(): JsonField = groupingKey + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } /** - * Returns the raw JSON value of [maximumCharge]. - * - * Unlike [maximumCharge], this method doesn't throw if the JSON field has an - * unexpected type. + * If the Price represents a fixed cost, this represents the quantity of units + * applied. */ - @JsonProperty("maximum_charge") - @ExcludeMissing - fun _maximumCharge(): JsonField = maximumCharge + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) /** - * Returns the raw JSON value of [minimumCharge]. + * Alias for [Builder.fixedPriceQuantity]. * - * Unlike [minimumCharge], this method doesn't throw if the JSON field has an - * unexpected type. + * This unboxed primitive overload exists for backwards compatibility. */ - @JsonProperty("minimum_charge") - @ExcludeMissing - fun _minimumCharge(): JsonField = minimumCharge + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) /** - * Returns the raw JSON value of [perUnitRate]. + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. * - * Unlike [perUnitRate], this method doesn't throw if the JSON field has an - * unexpected type. + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. */ - @JsonProperty("per_unit_rate") - @ExcludeMissing - fun _perUnitRate(): JsonField = perUnitRate - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) - /** - * Returns a mutable builder for constructing an instance of - * [GroupedWithMinMaxThresholdsConfig]. - * - * The following fields are required: - * ```kotlin - * .groupingKey() - * .maximumCharge() - * .minimumCharge() - * .perUnitRate() - * ``` - */ - fun builder() = Builder() + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey } - /** A builder for [GroupedWithMinMaxThresholdsConfig]. */ - class Builder internal constructor() { - - private var groupingKey: JsonField? = null - private var maximumCharge: JsonField? = null - private var minimumCharge: JsonField? = null - private var perUnitRate: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - internal fun from( - groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig - ) = apply { - groupingKey = groupedWithMinMaxThresholdsConfig.groupingKey - maximumCharge = groupedWithMinMaxThresholdsConfig.maximumCharge - minimumCharge = groupedWithMinMaxThresholdsConfig.minimumCharge - perUnitRate = groupedWithMinMaxThresholdsConfig.perUnitRate - additionalProperties = - groupedWithMinMaxThresholdsConfig.additionalProperties - .toMutableMap() - } - - /** The event property used to group before applying thresholds */ - fun groupingKey(groupingKey: String) = - groupingKey(JsonField.of(groupingKey)) - - /** - * Sets [Builder.groupingKey] to an arbitrary JSON value. - * - * You should usually call [Builder.groupingKey] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun groupingKey(groupingKey: JsonField) = apply { - this.groupingKey = groupingKey - } - - /** The maximum amount to charge each group */ - fun maximumCharge(maximumCharge: String) = - maximumCharge(JsonField.of(maximumCharge)) - - /** - * Sets [Builder.maximumCharge] to an arbitrary JSON value. - * - * You should usually call [Builder.maximumCharge] with a well-typed - * [String] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun maximumCharge(maximumCharge: JsonField) = apply { - this.maximumCharge = maximumCharge - } - - /** The minimum amount to charge each group, regardless of usage */ - fun minimumCharge(minimumCharge: String) = - minimumCharge(JsonField.of(minimumCharge)) - - /** - * Sets [Builder.minimumCharge] to an arbitrary JSON value. - * - * You should usually call [Builder.minimumCharge] with a well-typed - * [String] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun minimumCharge(minimumCharge: JsonField) = apply { - this.minimumCharge = minimumCharge - } - - /** The base price charged per group */ - fun perUnitRate(perUnitRate: String) = - perUnitRate(JsonField.of(perUnitRate)) - - /** - * Sets [Builder.perUnitRate] to an arbitrary JSON value. - * - * You should usually call [Builder.perUnitRate] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun perUnitRate(perUnitRate: JsonField) = apply { - this.perUnitRate = perUnitRate - } + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } - /** - * Returns an immutable instance of [GroupedWithMinMaxThresholdsConfig]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```kotlin - * .groupingKey() - * .maximumCharge() - * .minimumCharge() - * .perUnitRate() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): GroupedWithMinMaxThresholdsConfig = - GroupedWithMinMaxThresholdsConfig( - checkRequired("groupingKey", groupingKey), - checkRequired("maximumCharge", maximumCharge), - checkRequired("minimumCharge", minimumCharge), - checkRequired("perUnitRate", perUnitRate), - additionalProperties.toMutableMap(), - ) + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) } - private var validated: Boolean = false + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun validate(): GroupedWithMinMaxThresholdsConfig = apply { - if (validated) { - return@apply + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) } - groupingKey() - maximumCharge() - minimumCharge() - perUnitRate() - validated = true + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } /** - * Returns a score indicating how many valid values are contained in this object - * recursively. + * Returns an immutable instance of [TieredWithProration]. * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (if (groupingKey.asKnown() == null) 0 else 1) + - (if (maximumCharge.asKnown() == null) 0 else 1) + - (if (minimumCharge.asKnown() == null) 0 else 1) + - (if (perUnitRate.asKnown() == null) 0 else 1) + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .name() + * .tieredWithProrationConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TieredWithProration = + TieredWithProration( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + modelType, + checkRequired("name", name), + checkRequired("tieredWithProrationConfig", tieredWithProrationConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + private var validated: Boolean = false - return other is GroupedWithMinMaxThresholdsConfig && - groupingKey == other.groupingKey && - maximumCharge == other.maximumCharge && - minimumCharge == other.minimumCharge && - perUnitRate == other.perUnitRate && - additionalProperties == other.additionalProperties + fun validate(): TieredWithProration = apply { + if (validated) { + return@apply } - private val hashCode: Int by lazy { - Objects.hash( - groupingKey, - maximumCharge, - minimumCharge, - perUnitRate, - additionalProperties, - ) + cadence().validate() + itemId() + _modelType().let { + if (it != JsonValue.from("tiered_with_proration")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "GroupedWithMinMaxThresholdsConfig{groupingKey=$groupingKey, maximumCharge=$maximumCharge, minimumCharge=$minimumCharge, perUnitRate=$perUnitRate, additionalProperties=$additionalProperties}" + name() + tieredWithProrationConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + metadata()?.validate() + referenceId() + validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. */ - class Metadata - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + modelType.let { + if (it == JsonValue.from("tiered_with_proration")) 1 else 0 + } + + (if (name.asKnown() == null) 0 else 1) + + (tieredWithProrationConfig.asKnown()?.validity() ?: 0) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { - fun toBuilder() = Builder().from(this) + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { - /** Returns a mutable builder for constructing an instance of [Metadata]. */ - fun builder() = Builder() - } - - /** A builder for [Metadata]. */ - class Builder internal constructor() { + val ANNUAL = of("annual") - private var additionalProperties: MutableMap = - mutableMapOf() + val SEMI_ANNUAL = of("semi_annual") - internal fun from(metadata: Metadata) = apply { - additionalProperties = metadata.additionalProperties.toMutableMap() - } + val MONTHLY = of("monthly") - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + val QUARTERLY = of("quarterly") - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + val ONE_TIME = of("one_time") - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + val CUSTOM = of("custom") - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun of(value: String) = Cadence(JsonField.of(value)) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, /** - * Returns an immutable instance of [Metadata]. - * - * Further updates to this [Builder] will not mutate the returned instance. + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. */ - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true + _UNKNOWN, } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. * - * Used for best match union deserialization. + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. */ - internal fun validity(): Int = - additionalProperties.count { (_, value) -> - !value.isNull() && !value.isMissing() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN } - return other is Metadata && - additionalProperties == other.additionalProperties + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true } - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - override fun hashCode(): Int = hashCode + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + return other is Cadence && value == other.value } - return other is GroupedWithMinMaxThresholds && - cadence == other.cadence && - groupedWithMinMaxThresholdsConfig == - other.groupedWithMinMaxThresholdsConfig && - itemId == other.itemId && - modelType == other.modelType && - name == other.name && - billableMetricId == other.billableMetricId && - billedInAdvance == other.billedInAdvance && - billingCycleConfiguration == other.billingCycleConfiguration && - conversionRate == other.conversionRate && - conversionRateConfig == other.conversionRateConfig && - currency == other.currency && - dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && - externalPriceId == other.externalPriceId && - fixedPriceQuantity == other.fixedPriceQuantity && - invoiceGroupingKey == other.invoiceGroupingKey && - invoicingCycleConfiguration == other.invoicingCycleConfiguration && - metadata == other.metadata && - referenceId == other.referenceId && - additionalProperties == other.additionalProperties - } + override fun hashCode() = value.hashCode() - private val hashCode: Int by lazy { - Objects.hash( - cadence, - groupedWithMinMaxThresholdsConfig, - itemId, - modelType, - name, - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - conversionRateConfig, - currency, - dimensionalPriceConfiguration, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - additionalProperties, - ) + override fun toString() = value.toString() } - override fun hashCode(): Int = hashCode + /** Configuration for tiered_with_proration pricing */ + class TieredWithProrationConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val tiers: JsonField>, + private val additionalProperties: MutableMap, + ) { - override fun toString() = - "GroupedWithMinMaxThresholds{cadence=$cadence, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" - } + @JsonCreator + private constructor( + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of() + ) : this(tiers, mutableMapOf()) - class Percent - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val cadence: JsonField, - private val itemId: JsonField, - private val modelType: JsonValue, - private val name: JsonField, - private val percentConfig: JsonField, - private val billableMetricId: JsonField, - private val billedInAdvance: JsonField, - private val billingCycleConfiguration: JsonField, - private val conversionRate: JsonField, - private val conversionRateConfig: JsonField, - private val currency: JsonField, - private val dimensionalPriceConfiguration: - JsonField, - private val externalPriceId: JsonField, - private val fixedPriceQuantity: JsonField, - private val invoiceGroupingKey: JsonField, - private val invoicingCycleConfiguration: JsonField, - private val metadata: JsonField, - private val referenceId: JsonField, - private val additionalProperties: MutableMap, - ) { + /** + * Tiers for rating based on total usage quantities into the specified tier with + * proration + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun tiers(): List = tiers.getRequired("tiers") - @JsonCreator - private constructor( - @JsonProperty("cadence") - @ExcludeMissing - cadence: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - modelType: JsonValue = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - name: JsonField = JsonMissing.of(), - @JsonProperty("percent_config") - @ExcludeMissing - percentConfig: JsonField = JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("conversion_rate_config") - @ExcludeMissing - conversionRateConfig: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - currency: JsonField = JsonMissing.of(), - @JsonProperty("dimensional_price_configuration") - @ExcludeMissing - dimensionalPriceConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - metadata: JsonField = JsonMissing.of(), - @JsonProperty("reference_id") + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tiers") @ExcludeMissing - referenceId: JsonField = JsonMissing.of(), - ) : this( - cadence, - itemId, - modelType, - name, - percentConfig, - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - conversionRateConfig, - currency, - dimensionalPriceConfiguration, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - mutableMapOf(), - ) + fun _tiers(): JsonField> = tiers - /** - * The cadence to bill for this price on. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun cadence(): Cadence = cadence.getRequired("cadence") + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - /** - * The id of the item the price will be associated with. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun itemId(): String = itemId.getRequired("item_id") + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - /** - * The pricing model type - * - * Expected to always return the following: - * ```kotlin - * JsonValue.from("percent") - * ``` - * - * However, this method can be useful for debugging and logging (e.g. if the server - * responded with an unexpected value). - */ - @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + fun toBuilder() = Builder().from(this) - /** - * The name of the price. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun name(): String = name.getRequired("name") + companion object { - /** - * Configuration for percent pricing - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun percentConfig(): PercentConfig = percentConfig.getRequired("percent_config") + /** + * Returns a mutable builder for constructing an instance of + * [TieredWithProrationConfig]. + * + * The following fields are required: + * ```kotlin + * .tiers() + * ``` + */ + fun builder() = Builder() + } - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun billableMetricId(): String? = billableMetricId.getNullable("billable_metric_id") + /** A builder for [TieredWithProrationConfig]. */ + class Builder internal constructor() { - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + private var tiers: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun billingCycleConfiguration(): NewBillingCycleConfiguration? = - billingCycleConfiguration.getNullable("billing_cycle_configuration") + internal fun from(tieredWithProrationConfig: TieredWithProrationConfig) = + apply { + tiers = tieredWithProrationConfig.tiers.map { it.toMutableList() } + additionalProperties = + tieredWithProrationConfig.additionalProperties.toMutableMap() + } - /** - * The per unit conversion rate of the price currency to the invoicing currency. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + /** + * Tiers for rating based on total usage quantities into the specified tier + * with proration + */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) - /** - * The configuration for the rate of the price currency to the invoicing currency. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun conversionRateConfig(): ConversionRateConfig? = - conversionRateConfig.getNullable("conversion_rate_config") + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun currency(): String? = currency.getNullable("currency") + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } - /** - * For dimensional price: specifies a price group and dimension values - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = - dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** - * An alias for the price. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun fixedPriceQuantity(): Double? = - fixedPriceQuantity.getNullable("fixed_price_quantity") + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - /** - * The property used to group this price on an invoice - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun invoiceGroupingKey(): String? = - invoiceGroupingKey.getNullable("invoice_grouping_key") + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun metadata(): Metadata? = metadata.getNullable("metadata") + /** + * Returns an immutable instance of [TieredWithProrationConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TieredWithProrationConfig = + TieredWithProrationConfig( + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun referenceId(): String? = referenceId.getNullable("reference_id") + private var validated: Boolean = false - /** - * Returns the raw JSON value of [cadence]. - * - * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("cadence") - @ExcludeMissing - fun _cadence(): JsonField = cadence + fun validate(): TieredWithProrationConfig = apply { + if (validated) { + return@apply + } - /** - * Returns the raw JSON value of [itemId]. - * - * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + tiers().forEach { it.validate() } + validated = true + } - /** - * Returns the raw JSON value of [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - /** - * Returns the raw JSON value of [percentConfig]. - * - * Unlike [percentConfig], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("percent_config") - @ExcludeMissing - fun _percentConfig(): JsonField = percentConfig + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (tiers.asKnown()?.sumOf { it.validity().toInt() } ?: 0) - /** - * Returns the raw JSON value of [billableMetricId]. - * - * Unlike [billableMetricId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = billableMetricId + /** Configuration for a single tiered with proration tier */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val tierLowerBound: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { - /** - * Returns the raw JSON value of [billedInAdvance]. - * - * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance + @JsonCreator + private constructor( + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(tierLowerBound, unitAmount, mutableMapOf()) - /** - * Returns the raw JSON value of [billingCycleConfiguration]. - * - * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration + /** + * Inclusive tier starting value + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun tierLowerBound(): String = + tierLowerBound.getRequired("tier_lower_bound") - /** - * Returns the raw JSON value of [conversionRate]. - * - * Unlike [conversionRate], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate + /** + * Amount per unit + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") - /** - * Returns the raw JSON value of [conversionRateConfig]. - * - * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("conversion_rate_config") - @ExcludeMissing - fun _conversionRateConfig(): JsonField = conversionRateConfig + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound - /** - * Returns the raw JSON value of [currency]. - * - * Unlike [currency], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("currency") - @ExcludeMissing - fun _currency(): JsonField = currency + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount - /** - * Returns the raw JSON value of [dimensionalPriceConfiguration]. - * - * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON - * field has an unexpected type. - */ - @JsonProperty("dimensional_price_configuration") - @ExcludeMissing - fun _dimensionalPriceConfiguration(): JsonField = - dimensionalPriceConfiguration + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - /** - * Returns the raw JSON value of [externalPriceId]. - * - * Unlike [externalPriceId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - /** - * Returns the raw JSON value of [fixedPriceQuantity]. - * - * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + fun toBuilder() = Builder().from(this) - /** - * Returns the raw JSON value of [invoiceGroupingKey]. - * - * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + companion object { - /** - * Returns the raw JSON value of [invoicingCycleConfiguration]. - * - * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration + /** + * Returns a mutable builder for constructing an instance of [Tier]. + * + * The following fields are required: + * ```kotlin + * .tierLowerBound() + * .unitAmount() + * ``` + */ + fun builder() = Builder() + } - /** - * Returns the raw JSON value of [metadata]. - * - * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata + /** A builder for [Tier]. */ + class Builder internal constructor() { - /** - * Returns the raw JSON value of [referenceId]. - * - * Unlike [referenceId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("reference_id") - @ExcludeMissing - fun _referenceId(): JsonField = referenceId + private var tierLowerBound: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + internal fun from(tier: Tier) = apply { + tierLowerBound = tier.tierLowerBound + unitAmount = tier.unitAmount + additionalProperties = tier.additionalProperties.toMutableMap() + } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** Inclusive tier starting value */ + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) - fun toBuilder() = Builder().from(this) + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } - companion object { + /** Amount per unit */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) - /** - * Returns a mutable builder for constructing an instance of [Percent]. - * - * The following fields are required: - * ```kotlin - * .cadence() - * .itemId() - * .name() - * .percentConfig() - * ``` - */ - fun builder() = Builder() - } + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } - /** A builder for [Percent]. */ - class Builder internal constructor() { + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - private var cadence: JsonField? = null - private var itemId: JsonField? = null - private var modelType: JsonValue = JsonValue.from("percent") - private var name: JsonField? = null - private var percentConfig: JsonField? = null - private var billableMetricId: JsonField = JsonMissing.of() - private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var conversionRateConfig: JsonField = - JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var dimensionalPriceConfiguration: - JsonField = - JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: - JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var referenceId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - internal fun from(percent: Percent) = apply { - cadence = percent.cadence - itemId = percent.itemId - modelType = percent.modelType - name = percent.name - percentConfig = percent.percentConfig - billableMetricId = percent.billableMetricId - billedInAdvance = percent.billedInAdvance - billingCycleConfiguration = percent.billingCycleConfiguration - conversionRate = percent.conversionRate - conversionRateConfig = percent.conversionRateConfig - currency = percent.currency - dimensionalPriceConfiguration = percent.dimensionalPriceConfiguration - externalPriceId = percent.externalPriceId - fixedPriceQuantity = percent.fixedPriceQuantity - invoiceGroupingKey = percent.invoiceGroupingKey - invoicingCycleConfiguration = percent.invoicingCycleConfiguration - metadata = percent.metadata - referenceId = percent.referenceId - additionalProperties = percent.additionalProperties.toMutableMap() - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - /** - * Sets [Builder.cadence] to an arbitrary JSON value. - * - * You should usually call [Builder.cadence] with a well-typed [Cadence] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - /** The id of the item the price will be associated with. */ - fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + /** + * Returns an immutable instance of [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```kotlin + * .tierLowerBound() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("tierLowerBound", tierLowerBound), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } - /** - * Sets [Builder.itemId] to an arbitrary JSON value. - * - * You should usually call [Builder.itemId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + private var validated: Boolean = false - /** - * Sets the field to an arbitrary JSON value. - * - * It is usually unnecessary to call this method because the field defaults to - * the following: - * ```kotlin - * JsonValue.from("percent") - * ``` - * - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + fun validate(): Tier = apply { + if (validated) { + return@apply + } - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) + tierLowerBound() + unitAmount() + validated = true + } - /** - * Sets [Builder.name] to an arbitrary JSON value. - * - * You should usually call [Builder.name] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun name(name: JsonField) = apply { this.name = name } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - /** Configuration for percent pricing */ - fun percentConfig(percentConfig: PercentConfig) = - percentConfig(JsonField.of(percentConfig)) + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (tierLowerBound.asKnown() == null) 0 else 1) + + (if (unitAmount.asKnown() == null) 0 else 1) - /** - * Sets [Builder.percentConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.percentConfig] with a well-typed - * [PercentConfig] value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. - */ - fun percentConfig(percentConfig: JsonField) = apply { - this.percentConfig = percentConfig + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + tierLowerBound == other.tierLowerBound && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(tierLowerBound, unitAmount, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" } - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: String?) = - billableMetricId(JsonField.ofNullable(billableMetricId)) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * Sets [Builder.billableMetricId] to an arbitrary JSON value. - * - * You should usually call [Builder.billableMetricId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun billableMetricId(billableMetricId: JsonField) = apply { - this.billableMetricId = billableMetricId + return other is TieredWithProrationConfig && + tiers == other.tiers && + additionalProperties == other.additionalProperties } - /** - * If the Price represents a fixed cost, the price will be billed in-advance if - * this is true, and in-arrears if this is false. - */ - fun billedInAdvance(billedInAdvance: Boolean?) = - billedInAdvance(JsonField.ofNullable(billedInAdvance)) + private val hashCode: Int by lazy { Objects.hash(tiers, additionalProperties) } - /** - * Alias for [Builder.billedInAdvance]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun billedInAdvance(billedInAdvance: Boolean) = - billedInAdvance(billedInAdvance as Boolean?) + override fun hashCode(): Int = hashCode - /** - * Sets [Builder.billedInAdvance] to an arbitrary JSON value. - * - * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun billedInAdvance(billedInAdvance: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } + override fun toString() = + "TieredWithProrationConfig{tiers=$tiers, additionalProperties=$additionalProperties}" + } - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: NewBillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { - /** - * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.billingCycleConfiguration] with a well-typed - * [NewBillingCycleConfiguration] value instead. This method is primarily for - * setting the field to an undocumented or not yet supported value. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: JsonField - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: Double?) = - conversionRate(JsonField.ofNullable(conversionRate)) + fun toBuilder() = Builder().from(this) - /** - * Alias for [Builder.conversionRate]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) + companion object { - /** - * Sets [Builder.conversionRate] to an arbitrary JSON value. - * - * You should usually call [Builder.conversionRate] with a well-typed [Double] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() } - /** - * The configuration for the rate of the price currency to the invoicing - * currency. - */ - fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = - conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + /** A builder for [Metadata]. */ + class Builder internal constructor() { - /** - * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.conversionRateConfig] with a well-typed - * [ConversionRateConfig] value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun conversionRateConfig( - conversionRateConfig: JsonField - ) = apply { this.conversionRateConfig = conversionRateConfig } + private var additionalProperties: MutableMap = + mutableMapOf() - /** - * Alias for calling [conversionRateConfig] with - * `ConversionRateConfig.ofUnit(unit)`. - */ - fun conversionRateConfig(unit: UnitConversionRateConfig) = - conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } - /** - * Alias for calling [conversionRateConfig] with the following: - * ```kotlin - * UnitConversionRateConfig.builder() - * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) - * .unitConfig(unitConfig) - * .build() - * ``` - */ - fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = - conversionRateConfig( - UnitConversionRateConfig.builder() - .conversionRateType( - UnitConversionRateConfig.ConversionRateType.UNIT - ) - .unitConfig(unitConfig) - .build() - ) + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** - * Alias for calling [conversionRateConfig] with - * `ConversionRateConfig.ofTiered(tiered)`. - */ - fun conversionRateConfig(tiered: TieredConversionRateConfig) = - conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * Alias for calling [conversionRateConfig] with the following: - * ```kotlin - * TieredConversionRateConfig.builder() - * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) - * .tieredConfig(tieredConfig) - * .build() - * ``` - */ - fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = - conversionRateConfig( - TieredConversionRateConfig.builder() - .conversionRateType( - TieredConversionRateConfig.ConversionRateType.TIERED - ) - .tieredConfig(tieredConfig) - .build() - ) + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - /** - * Sets [Builder.currency] to an arbitrary JSON value. - * - * You should usually call [Builder.currency] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - /** For dimensional price: specifies a price group and dimension values */ - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? - ) = - dimensionalPriceConfiguration( - JsonField.ofNullable(dimensionalPriceConfiguration) - ) + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } - /** - * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.dimensionalPriceConfiguration] with a - * well-typed [NewDimensionalPriceConfiguration] value instead. This method is - * primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: JsonField - ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + private var validated: Boolean = false - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) + fun validate(): Metadata = apply { + if (validated) { + return@apply + } - /** - * Sets [Builder.externalPriceId] to an arbitrary JSON value. - * - * You should usually call [Builder.externalPriceId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun externalPriceId(externalPriceId: JsonField) = apply { - this.externalPriceId = externalPriceId + validated = true } - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = - fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } /** - * Alias for [Builder.fixedPriceQuantity]. + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * This unboxed primitive overload exists for backwards compatibility. + * Used for best match union deserialization. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } - /** - * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. - * - * You should usually call [Builder.fixedPriceQuantity] with a well-typed - * [Double] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { - this.fixedPriceQuantity = fixedPriceQuantity + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties } - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = - invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) - - /** - * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. - * - * You should usually call [Builder.invoiceGroupingKey] with a well-typed - * [String] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { - this.invoiceGroupingKey = invoiceGroupingKey - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are - * produced. If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: NewBillingCycleConfiguration? - ) = - invoicingCycleConfiguration( - JsonField.ofNullable(invoicingCycleConfiguration) - ) - - /** - * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.invoicingCycleConfiguration] with a - * well-typed [NewBillingCycleConfiguration] value instead. This method is - * primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * Sets [Builder.metadata] to an arbitrary JSON value. - * - * You should usually call [Builder.metadata] with a well-typed [Metadata] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - fun referenceId(referenceId: String?) = - referenceId(JsonField.ofNullable(referenceId)) - - /** - * Sets [Builder.referenceId] to an arbitrary JSON value. - * - * You should usually call [Builder.referenceId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun referenceId(referenceId: JsonField) = apply { - this.referenceId = referenceId - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + override fun hashCode(): Int = hashCode - /** - * Returns an immutable instance of [Percent]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```kotlin - * .cadence() - * .itemId() - * .name() - * .percentConfig() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Percent = - Percent( - checkRequired("cadence", cadence), - checkRequired("itemId", itemId), - modelType, - checkRequired("name", name), - checkRequired("percentConfig", percentConfig), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - conversionRateConfig, - currency, - dimensionalPriceConfiguration, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - additionalProperties.toMutableMap(), - ) + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" } - private var validated: Boolean = false - - fun validate(): Percent = apply { - if (validated) { - return@apply + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - cadence().validate() - itemId() - _modelType().let { - if (it != JsonValue.from("percent")) { - throw OrbInvalidDataException("'modelType' is invalid, received $it") - } - } - name() - percentConfig().validate() - billableMetricId() - billedInAdvance() - billingCycleConfiguration()?.validate() - conversionRate() - conversionRateConfig()?.validate() - currency() - dimensionalPriceConfiguration()?.validate() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration()?.validate() - metadata()?.validate() - referenceId() - validated = true + return other is TieredWithProration && + cadence == other.cadence && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + tieredWithProrationConfig == other.tieredWithProrationConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + modelType, + name, + tieredWithProrationConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties, + ) + } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (cadence.asKnown()?.validity() ?: 0) + - (if (itemId.asKnown() == null) 0 else 1) + - modelType.let { if (it == JsonValue.from("percent")) 1 else 0 } + - (if (name.asKnown() == null) 0 else 1) + - (percentConfig.asKnown()?.validity() ?: 0) + - (if (billableMetricId.asKnown() == null) 0 else 1) + - (if (billedInAdvance.asKnown() == null) 0 else 1) + - (billingCycleConfiguration.asKnown()?.validity() ?: 0) + - (if (conversionRate.asKnown() == null) 0 else 1) + - (conversionRateConfig.asKnown()?.validity() ?: 0) + - (if (currency.asKnown() == null) 0 else 1) + - (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + - (if (externalPriceId.asKnown() == null) 0 else 1) + - (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + - (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + - (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + - (metadata.asKnown()?.validity() ?: 0) + - (if (referenceId.asKnown() == null) 0 else 1) + override fun hashCode(): Int = hashCode - /** The cadence to bill for this price on. */ - class Cadence - @JsonCreator - private constructor(private val value: JsonField) : Enum { + override fun toString() = + "TieredWithProration{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredWithProrationConfig=$tieredWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value + class GroupedWithMinMaxThresholds + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val groupedWithMinMaxThresholdsConfig: + JsonField, + private val itemId: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { - companion object { + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("grouped_with_min_max_thresholds_config") + @ExcludeMissing + groupedWithMinMaxThresholdsConfig: + JsonField = + JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + groupedWithMinMaxThresholdsConfig, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + mutableMapOf(), + ) - val ANNUAL = of("annual") + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") - val SEMI_ANNUAL = of("semi_annual") + /** + * Configuration for grouped_with_min_max_thresholds pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupedWithMinMaxThresholdsConfig(): GroupedWithMinMaxThresholdsConfig = + groupedWithMinMaxThresholdsConfig.getRequired( + "grouped_with_min_max_thresholds_config" + ) - val MONTHLY = of("monthly") + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") - val QUARTERLY = of("quarterly") + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("grouped_with_min_max_thresholds") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType - val ONE_TIME = of("one_time") + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") - val CUSTOM = of("custom") + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = billableMetricId.getNullable("billable_metric_id") - fun of(value: String) = Cadence(JsonField.of(value)) - } + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") - /** An enum containing [Cadence]'s known values. */ - enum class Known { - ANNUAL, - SEMI_ANNUAL, - MONTHLY, - QUARTERLY, - ONE_TIME, - CUSTOM, - } + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") - /** - * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Cadence] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - ANNUAL, - SEMI_ANNUAL, - MONTHLY, - QUARTERLY, - ONE_TIME, - CUSTOM, - /** - * An enum member indicating that [Cadence] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - ANNUAL -> Value.ANNUAL - SEMI_ANNUAL -> Value.SEMI_ANNUAL - MONTHLY -> Value.MONTHLY - QUARTERLY -> Value.QUARTERLY - ONE_TIME -> Value.ONE_TIME - CUSTOM -> Value.CUSTOM - else -> Value._UNKNOWN - } + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - ANNUAL -> Known.ANNUAL - SEMI_ANNUAL -> Known.SEMI_ANNUAL - MONTHLY -> Known.MONTHLY - QUARTERLY -> Known.QUARTERLY - ONE_TIME -> Known.ONE_TIME - CUSTOM -> Known.CUSTOM - else -> throw OrbInvalidDataException("Unknown Cadence: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString() - ?: throw OrbInvalidDataException("Value is not a String") + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") - private var validated: Boolean = false + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") - fun validate(): Cadence = apply { - if (validated) { - return@apply - } + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") - known() - validated = true - } + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + invoiceGroupingKey.getNullable("invoice_grouping_key") - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") - return other is Cadence && value == other.value - } + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") - override fun hashCode() = value.hashCode() + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence - override fun toString() = value.toString() - } + /** + * Returns the raw JSON value of [groupedWithMinMaxThresholdsConfig]. + * + * Unlike [groupedWithMinMaxThresholdsConfig], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("grouped_with_min_max_thresholds_config") + @ExcludeMissing + fun _groupedWithMinMaxThresholdsConfig(): + JsonField = groupedWithMinMaxThresholdsConfig - /** Configuration for percent pricing */ - class PercentConfig - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val percent: JsonField, - private val additionalProperties: MutableMap, - ) { + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - @JsonCreator - private constructor( - @JsonProperty("percent") - @ExcludeMissing - percent: JsonField = JsonMissing.of() - ) : this(percent, mutableMapOf()) + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - /** - * What percent of the component subtotals to charge - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun percent(): Double = percent.getRequired("percent") + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId - /** - * Returns the raw JSON value of [percent]. - * - * Unlike [percent], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("percent") - @ExcludeMissing - fun _percent(): JsonField = percent + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate - fun toBuilder() = Builder().from(this) + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig - companion object { + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency - /** - * Returns a mutable builder for constructing an instance of - * [PercentConfig]. - * - * The following fields are required: - * ```kotlin - * .percent() - * ``` - */ - fun builder() = Builder() - } - - /** A builder for [PercentConfig]. */ - class Builder internal constructor() { + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration - private var percent: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId - internal fun from(percentConfig: PercentConfig) = apply { - percent = percentConfig.percent - additionalProperties = percentConfig.additionalProperties.toMutableMap() - } + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - /** What percent of the component subtotals to charge */ - fun percent(percent: Double) = percent(JsonField.of(percent)) + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - /** - * Sets [Builder.percent] to an arbitrary JSON value. - * - * You should usually call [Builder.percent] with a well-typed [Double] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun percent(percent: JsonField) = apply { this.percent = percent } + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun toBuilder() = Builder().from(this) - /** - * Returns an immutable instance of [PercentConfig]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```kotlin - * .percent() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): PercentConfig = - PercentConfig( - checkRequired("percent", percent), - additionalProperties.toMutableMap(), - ) - } + companion object { - private var validated: Boolean = false + /** + * Returns a mutable builder for constructing an instance of + * [GroupedWithMinMaxThresholds]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .groupedWithMinMaxThresholdsConfig() + * .itemId() + * .name() + * ``` + */ + fun builder() = Builder() + } - fun validate(): PercentConfig = apply { - if (validated) { - return@apply - } + /** A builder for [GroupedWithMinMaxThresholds]. */ + class Builder internal constructor() { - percent() - validated = true - } + private var cadence: JsonField? = null + private var groupedWithMinMaxThresholdsConfig: + JsonField? = + null + private var itemId: JsonField? = null + private var modelType: JsonValue = + JsonValue.from("grouped_with_min_max_thresholds") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false + internal fun from(groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds) = + apply { + cadence = groupedWithMinMaxThresholds.cadence + groupedWithMinMaxThresholdsConfig = + groupedWithMinMaxThresholds.groupedWithMinMaxThresholdsConfig + itemId = groupedWithMinMaxThresholds.itemId + modelType = groupedWithMinMaxThresholds.modelType + name = groupedWithMinMaxThresholds.name + billableMetricId = groupedWithMinMaxThresholds.billableMetricId + billedInAdvance = groupedWithMinMaxThresholds.billedInAdvance + billingCycleConfiguration = + groupedWithMinMaxThresholds.billingCycleConfiguration + conversionRate = groupedWithMinMaxThresholds.conversionRate + conversionRateConfig = groupedWithMinMaxThresholds.conversionRateConfig + currency = groupedWithMinMaxThresholds.currency + dimensionalPriceConfiguration = + groupedWithMinMaxThresholds.dimensionalPriceConfiguration + externalPriceId = groupedWithMinMaxThresholds.externalPriceId + fixedPriceQuantity = groupedWithMinMaxThresholds.fixedPriceQuantity + invoiceGroupingKey = groupedWithMinMaxThresholds.invoiceGroupingKey + invoicingCycleConfiguration = + groupedWithMinMaxThresholds.invoicingCycleConfiguration + metadata = groupedWithMinMaxThresholds.metadata + referenceId = groupedWithMinMaxThresholds.referenceId + additionalProperties = + groupedWithMinMaxThresholds.additionalProperties.toMutableMap() } + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + /** - * Returns a score indicating how many valid values are contained in this object - * recursively. + * Sets [Builder.cadence] to an arbitrary JSON value. * - * Used for best match union deserialization. + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. */ - internal fun validity(): Int = (if (percent.asKnown() == null) 0 else 1) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is PercentConfig && - percent == other.percent && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(percent, additionalProperties) - } + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - override fun hashCode(): Int = hashCode + /** Configuration for grouped_with_min_max_thresholds pricing */ + fun groupedWithMinMaxThresholdsConfig( + groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + ) = + groupedWithMinMaxThresholdsConfig( + JsonField.of(groupedWithMinMaxThresholdsConfig) + ) - override fun toString() = - "PercentConfig{percent=$percent, additionalProperties=$additionalProperties}" - } - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - class Metadata - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Metadata]. */ - fun builder() = Builder() + /** + * Sets [Builder.groupedWithMinMaxThresholdsConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.groupedWithMinMaxThresholdsConfig] with a + * well-typed [GroupedWithMinMaxThresholdsConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun groupedWithMinMaxThresholdsConfig( + groupedWithMinMaxThresholdsConfig: + JsonField + ) = apply { + this.groupedWithMinMaxThresholdsConfig = groupedWithMinMaxThresholdsConfig } - /** A builder for [Metadata]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = - mutableMapOf() - - internal fun from(metadata: Metadata) = apply { - additionalProperties = metadata.additionalProperties.toMutableMap() - } + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("grouped_with_min_max_thresholds") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) - /** - * Returns an immutable instance of [Metadata]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId } - private var validated: Boolean = false + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) - fun validate(): Metadata = apply { - if (validated) { - return@apply - } + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) - validated = true + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) /** - * Returns a score indicating how many valid values are contained in this object - * recursively. + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. * - * Used for best match union deserialization. + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. */ - internal fun validity(): Int = - additionalProperties.count { (_, value) -> - !value.isNull() && !value.isMissing() - } + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) - return other is Metadata && - additionalProperties == other.additionalProperties + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate } - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) - override fun hashCode(): Int = hashCode + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) - return other is Percent && - cadence == other.cadence && - itemId == other.itemId && - modelType == other.modelType && - name == other.name && - percentConfig == other.percentConfig && - billableMetricId == other.billableMetricId && - billedInAdvance == other.billedInAdvance && - billingCycleConfiguration == other.billingCycleConfiguration && - conversionRate == other.conversionRate && - conversionRateConfig == other.conversionRateConfig && - currency == other.currency && - dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && - externalPriceId == other.externalPriceId && - fixedPriceQuantity == other.fixedPriceQuantity && - invoiceGroupingKey == other.invoiceGroupingKey && - invoicingCycleConfiguration == other.invoicingCycleConfiguration && - metadata == other.metadata && - referenceId == other.referenceId && - additionalProperties == other.additionalProperties - } + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) - private val hashCode: Int by lazy { - Objects.hash( - cadence, - itemId, - modelType, - name, - percentConfig, - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - conversionRateConfig, - currency, - dimensionalPriceConfiguration, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - additionalProperties, - ) - } + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) - override fun hashCode(): Int = hashCode + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) - override fun toString() = - "Percent{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, percentConfig=$percentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" - } + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } - class EventOutput - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val cadence: JsonField, - private val eventOutputConfig: JsonField, - private val itemId: JsonField, - private val modelType: JsonValue, - private val name: JsonField, - private val billableMetricId: JsonField, - private val billedInAdvance: JsonField, - private val billingCycleConfiguration: JsonField, - private val conversionRate: JsonField, - private val conversionRateConfig: JsonField, - private val currency: JsonField, - private val dimensionalPriceConfiguration: - JsonField, - private val externalPriceId: JsonField, - private val fixedPriceQuantity: JsonField, - private val invoiceGroupingKey: JsonField, - private val invoicingCycleConfiguration: JsonField, - private val metadata: JsonField, - private val referenceId: JsonField, - private val additionalProperties: MutableMap, - ) { + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) - @JsonCreator - private constructor( - @JsonProperty("cadence") - @ExcludeMissing - cadence: JsonField = JsonMissing.of(), - @JsonProperty("event_output_config") - @ExcludeMissing - eventOutputConfig: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - modelType: JsonValue = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - name: JsonField = JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("conversion_rate_config") - @ExcludeMissing - conversionRateConfig: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - currency: JsonField = JsonMissing.of(), - @JsonProperty("dimensional_price_configuration") - @ExcludeMissing - dimensionalPriceConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - metadata: JsonField = JsonMissing.of(), - @JsonProperty("reference_id") - @ExcludeMissing - referenceId: JsonField = JsonMissing.of(), - ) : this( - cadence, - eventOutputConfig, - itemId, - modelType, - name, - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - conversionRateConfig, - currency, - dimensionalPriceConfiguration, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - mutableMapOf(), - ) + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } - /** - * The cadence to bill for this price on. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun cadence(): Cadence = cadence.getRequired("cadence") + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) - /** - * Configuration for event_output pricing - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun eventOutputConfig(): EventOutputConfig = - eventOutputConfig.getRequired("event_output_config") + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } - /** - * The id of the item the price will be associated with. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun itemId(): String = itemId.getRequired("item_id") + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) - /** - * The pricing model type - * - * Expected to always return the following: - * ```kotlin - * JsonValue.from("event_output") - * ``` - * - * However, this method can be useful for debugging and logging (e.g. if the server - * responded with an unexpected value). - */ - @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType - - /** - * The name of the price. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun name(): String = name.getRequired("name") - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun billableMetricId(): String? = billableMetricId.getNullable("billable_metric_id") - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun billingCycleConfiguration(): NewBillingCycleConfiguration? = - billingCycleConfiguration.getNullable("billing_cycle_configuration") + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) - /** - * The per unit conversion rate of the price currency to the invoicing currency. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } - /** - * The configuration for the rate of the price currency to the invoicing currency. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun conversionRateConfig(): ConversionRateConfig? = - conversionRateConfig.getNullable("conversion_rate_config") + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun currency(): String? = currency.getNullable("currency") + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } - /** - * For dimensional price: specifies a price group and dimension values - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = - dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) - /** - * An alias for the price. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun fixedPriceQuantity(): Double? = - fixedPriceQuantity.getNullable("fixed_price_quantity") + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - /** - * The property used to group this price on an invoice - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun invoiceGroupingKey(): String? = - invoiceGroupingKey.getNullable("invoice_grouping_key") + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun metadata(): Metadata? = metadata.getNullable("metadata") + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun referenceId(): String? = referenceId.getNullable("reference_id") + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** - * Returns the raw JSON value of [cadence]. - * - * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("cadence") - @ExcludeMissing - fun _cadence(): JsonField = cadence + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * Returns the raw JSON value of [eventOutputConfig]. - * - * Unlike [eventOutputConfig], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("event_output_config") - @ExcludeMissing - fun _eventOutputConfig(): JsonField = eventOutputConfig + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - /** - * Returns the raw JSON value of [itemId]. - * - * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - /** - * Returns the raw JSON value of [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - /** - * Returns the raw JSON value of [billableMetricId]. - * - * Unlike [billableMetricId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = billableMetricId + /** + * Returns an immutable instance of [GroupedWithMinMaxThresholds]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .groupedWithMinMaxThresholdsConfig() + * .itemId() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedWithMinMaxThresholds = + GroupedWithMinMaxThresholds( + checkRequired("cadence", cadence), + checkRequired( + "groupedWithMinMaxThresholdsConfig", + groupedWithMinMaxThresholdsConfig, + ), + checkRequired("itemId", itemId), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } - /** - * Returns the raw JSON value of [billedInAdvance]. - * - * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance + private var validated: Boolean = false - /** - * Returns the raw JSON value of [billingCycleConfiguration]. - * - * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration + fun validate(): GroupedWithMinMaxThresholds = apply { + if (validated) { + return@apply + } - /** - * Returns the raw JSON value of [conversionRate]. - * - * Unlike [conversionRate], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate + cadence().validate() + groupedWithMinMaxThresholdsConfig().validate() + itemId() + _modelType().let { + if (it != JsonValue.from("grouped_with_min_max_thresholds")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + metadata()?.validate() + referenceId() + validated = true + } - /** - * Returns the raw JSON value of [conversionRateConfig]. - * - * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("conversion_rate_config") - @ExcludeMissing - fun _conversionRateConfig(): JsonField = conversionRateConfig + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } /** - * Returns the raw JSON value of [currency]. + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * Unlike [currency], this method doesn't throw if the JSON field has an unexpected - * type. + * Used for best match union deserialization. */ - @JsonProperty("currency") - @ExcludeMissing - fun _currency(): JsonField = currency + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (groupedWithMinMaxThresholdsConfig.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + modelType.let { + if (it == JsonValue.from("grouped_with_min_max_thresholds")) 1 else 0 + } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) - /** - * Returns the raw JSON value of [dimensionalPriceConfiguration]. - * - * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON - * field has an unexpected type. - */ - @JsonProperty("dimensional_price_configuration") - @ExcludeMissing - fun _dimensionalPriceConfiguration(): JsonField = - dimensionalPriceConfiguration + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { - /** - * Returns the raw JSON value of [externalPriceId]. - * - * Unlike [externalPriceId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value - /** - * Returns the raw JSON value of [fixedPriceQuantity]. - * - * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + companion object { - /** - * Returns the raw JSON value of [invoiceGroupingKey]. - * - * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + val ANNUAL = of("annual") - /** - * Returns the raw JSON value of [invoicingCycleConfiguration]. - * - * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration + val SEMI_ANNUAL = of("semi_annual") - /** - * Returns the raw JSON value of [metadata]. - * - * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata + val MONTHLY = of("monthly") - /** - * Returns the raw JSON value of [referenceId]. - * - * Unlike [referenceId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("reference_id") - @ExcludeMissing - fun _referenceId(): JsonField = referenceId + val QUARTERLY = of("quarterly") - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + val ONE_TIME = of("one_time") - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + val CUSTOM = of("custom") - fun toBuilder() = Builder().from(this) + fun of(value: String) = Cadence(JsonField.of(value)) + } - companion object { + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } /** - * Returns a mutable builder for constructing an instance of [EventOutput]. + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. * - * The following fields are required: - * ```kotlin - * .cadence() - * .eventOutputConfig() - * .itemId() - * .name() - * ``` + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. */ - fun builder() = Builder() - } - - /** A builder for [EventOutput]. */ - class Builder internal constructor() { - - private var cadence: JsonField? = null - private var eventOutputConfig: JsonField? = null - private var itemId: JsonField? = null - private var modelType: JsonValue = JsonValue.from("event_output") - private var name: JsonField? = null - private var billableMetricId: JsonField = JsonMissing.of() - private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var conversionRateConfig: JsonField = - JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var dimensionalPriceConfiguration: - JsonField = - JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: - JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var referenceId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(eventOutput: EventOutput) = apply { - cadence = eventOutput.cadence - eventOutputConfig = eventOutput.eventOutputConfig - itemId = eventOutput.itemId - modelType = eventOutput.modelType - name = eventOutput.name - billableMetricId = eventOutput.billableMetricId - billedInAdvance = eventOutput.billedInAdvance - billingCycleConfiguration = eventOutput.billingCycleConfiguration - conversionRate = eventOutput.conversionRate - conversionRateConfig = eventOutput.conversionRateConfig - currency = eventOutput.currency - dimensionalPriceConfiguration = eventOutput.dimensionalPriceConfiguration - externalPriceId = eventOutput.externalPriceId - fixedPriceQuantity = eventOutput.fixedPriceQuantity - invoiceGroupingKey = eventOutput.invoiceGroupingKey - invoicingCycleConfiguration = eventOutput.invoicingCycleConfiguration - metadata = eventOutput.metadata - referenceId = eventOutput.referenceId - additionalProperties = eventOutput.additionalProperties.toMutableMap() + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, } - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - /** - * Sets [Builder.cadence] to an arbitrary JSON value. + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. * - * You should usually call [Builder.cadence] with a well-typed [Cadence] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. */ - fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - - /** Configuration for event_output pricing */ - fun eventOutputConfig(eventOutputConfig: EventOutputConfig) = - eventOutputConfig(JsonField.of(eventOutputConfig)) + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } /** - * Sets [Builder.eventOutputConfig] to an arbitrary JSON value. + * Returns an enum member corresponding to this class instance's value. * - * You should usually call [Builder.eventOutputConfig] with a well-typed - * [EventOutputConfig] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun eventOutputConfig(eventOutputConfig: JsonField) = apply { - this.eventOutputConfig = eventOutputConfig - } - - /** The id of the item the price will be associated with. */ - fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - - /** - * Sets [Builder.itemId] to an arbitrary JSON value. + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. * - * You should usually call [Builder.itemId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } /** - * Sets the field to an arbitrary JSON value. + * Returns this class instance's primitive wire representation. * - * It is usually unnecessary to call this method because the field defaults to - * the following: - * ```kotlin - * JsonValue.from("event_output") - * ``` + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. * - * This method is primarily for setting the field to an undocumented or not yet - * supported value. + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. */ - fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } /** - * Sets [Builder.name] to an arbitrary JSON value. + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * You should usually call [Builder.name] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. + * Used for best match union deserialization. */ - fun name(name: JsonField) = apply { this.name = name } + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: String?) = - billableMetricId(JsonField.ofNullable(billableMetricId)) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Configuration for grouped_with_min_max_thresholds pricing */ + class GroupedWithMinMaxThresholdsConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val groupingKey: JsonField, + private val maximumCharge: JsonField, + private val minimumCharge: JsonField, + private val perUnitRate: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("maximum_charge") + @ExcludeMissing + maximumCharge: JsonField = JsonMissing.of(), + @JsonProperty("minimum_charge") + @ExcludeMissing + minimumCharge: JsonField = JsonMissing.of(), + @JsonProperty("per_unit_rate") + @ExcludeMissing + perUnitRate: JsonField = JsonMissing.of(), + ) : this(groupingKey, maximumCharge, minimumCharge, perUnitRate, mutableMapOf()) /** - * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * The event property used to group before applying thresholds * - * You should usually call [Builder.billableMetricId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). */ - fun billableMetricId(billableMetricId: JsonField) = apply { - this.billableMetricId = billableMetricId - } + fun groupingKey(): String = groupingKey.getRequired("grouping_key") /** - * If the Price represents a fixed cost, the price will be billed in-advance if - * this is true, and in-arrears if this is false. + * The maximum amount to charge each group + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). */ - fun billedInAdvance(billedInAdvance: Boolean?) = - billedInAdvance(JsonField.ofNullable(billedInAdvance)) + fun maximumCharge(): String = maximumCharge.getRequired("maximum_charge") /** - * Alias for [Builder.billedInAdvance]. + * The minimum amount to charge each group, regardless of usage * - * This unboxed primitive overload exists for backwards compatibility. + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). */ - fun billedInAdvance(billedInAdvance: Boolean) = - billedInAdvance(billedInAdvance as Boolean?) + fun minimumCharge(): String = minimumCharge.getRequired("minimum_charge") /** - * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * The base price charged per group * - * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun billedInAdvance(billedInAdvance: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). */ - fun billingCycleConfiguration( - billingCycleConfiguration: NewBillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + fun perUnitRate(): String = perUnitRate.getRequired("per_unit_rate") /** - * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * Returns the raw JSON value of [groupingKey]. * - * You should usually call [Builder.billingCycleConfiguration] with a well-typed - * [NewBillingCycleConfiguration] value instead. This method is primarily for - * setting the field to an undocumented or not yet supported value. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: JsonField - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } - - /** - * The per unit conversion rate of the price currency to the invoicing currency. + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. */ - fun conversionRate(conversionRate: Double?) = - conversionRate(JsonField.ofNullable(conversionRate)) + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey /** - * Alias for [Builder.conversionRate]. + * Returns the raw JSON value of [maximumCharge]. * - * This unboxed primitive overload exists for backwards compatibility. + * Unlike [maximumCharge], this method doesn't throw if the JSON field has an + * unexpected type. */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) + @JsonProperty("maximum_charge") + @ExcludeMissing + fun _maximumCharge(): JsonField = maximumCharge /** - * Sets [Builder.conversionRate] to an arbitrary JSON value. + * Returns the raw JSON value of [minimumCharge]. * - * You should usually call [Builder.conversionRate] with a well-typed [Double] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** - * The configuration for the rate of the price currency to the invoicing - * currency. + * Unlike [minimumCharge], this method doesn't throw if the JSON field has an + * unexpected type. */ - fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = - conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + @JsonProperty("minimum_charge") + @ExcludeMissing + fun _minimumCharge(): JsonField = minimumCharge /** - * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * Returns the raw JSON value of [perUnitRate]. * - * You should usually call [Builder.conversionRateConfig] with a well-typed - * [ConversionRateConfig] value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. + * Unlike [perUnitRate], this method doesn't throw if the JSON field has an + * unexpected type. */ - fun conversionRateConfig( - conversionRateConfig: JsonField - ) = apply { this.conversionRateConfig = conversionRateConfig } + @JsonProperty("per_unit_rate") + @ExcludeMissing + fun _perUnitRate(): JsonField = perUnitRate - /** - * Alias for calling [conversionRateConfig] with - * `ConversionRateConfig.ofUnit(unit)`. - */ - fun conversionRateConfig(unit: UnitConversionRateConfig) = - conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - /** - * Alias for calling [conversionRateConfig] with the following: - * ```kotlin - * UnitConversionRateConfig.builder() - * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) - * .unitConfig(unitConfig) - * .build() - * ``` - */ - fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = - conversionRateConfig( - UnitConversionRateConfig.builder() - .conversionRateType( - UnitConversionRateConfig.ConversionRateType.UNIT - ) - .unitConfig(unitConfig) - .build() - ) + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - /** - * Alias for calling [conversionRateConfig] with - * `ConversionRateConfig.ofTiered(tiered)`. - */ - fun conversionRateConfig(tiered: TieredConversionRateConfig) = - conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + fun toBuilder() = Builder().from(this) - /** - * Alias for calling [conversionRateConfig] with the following: - * ```kotlin - * TieredConversionRateConfig.builder() - * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) - * .tieredConfig(tieredConfig) - * .build() - * ``` - */ - fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = - conversionRateConfig( - TieredConversionRateConfig.builder() - .conversionRateType( - TieredConversionRateConfig.ConversionRateType.TIERED - ) - .tieredConfig(tieredConfig) - .build() - ) + companion object { - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + /** + * Returns a mutable builder for constructing an instance of + * [GroupedWithMinMaxThresholdsConfig]. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .maximumCharge() + * .minimumCharge() + * .perUnitRate() + * ``` + */ + fun builder() = Builder() + } - /** - * Sets [Builder.currency] to an arbitrary JSON value. - * - * You should usually call [Builder.currency] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } + /** A builder for [GroupedWithMinMaxThresholdsConfig]. */ + class Builder internal constructor() { - /** For dimensional price: specifies a price group and dimension values */ - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? - ) = - dimensionalPriceConfiguration( - JsonField.ofNullable(dimensionalPriceConfiguration) - ) + private var groupingKey: JsonField? = null + private var maximumCharge: JsonField? = null + private var minimumCharge: JsonField? = null + private var perUnitRate: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() - /** - * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.dimensionalPriceConfiguration] with a - * well-typed [NewDimensionalPriceConfiguration] value instead. This method is - * primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: JsonField - ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + internal fun from( + groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + ) = apply { + groupingKey = groupedWithMinMaxThresholdsConfig.groupingKey + maximumCharge = groupedWithMinMaxThresholdsConfig.maximumCharge + minimumCharge = groupedWithMinMaxThresholdsConfig.minimumCharge + perUnitRate = groupedWithMinMaxThresholdsConfig.perUnitRate + additionalProperties = + groupedWithMinMaxThresholdsConfig.additionalProperties + .toMutableMap() + } - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) + /** The event property used to group before applying thresholds */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) - /** - * Sets [Builder.externalPriceId] to an arbitrary JSON value. - * - * You should usually call [Builder.externalPriceId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun externalPriceId(externalPriceId: JsonField) = apply { - this.externalPriceId = externalPriceId - } + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = - fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + /** The maximum amount to charge each group */ + fun maximumCharge(maximumCharge: String) = + maximumCharge(JsonField.of(maximumCharge)) - /** - * Alias for [Builder.fixedPriceQuantity]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) + /** + * Sets [Builder.maximumCharge] to an arbitrary JSON value. + * + * You should usually call [Builder.maximumCharge] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun maximumCharge(maximumCharge: JsonField) = apply { + this.maximumCharge = maximumCharge + } - /** - * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. - * - * You should usually call [Builder.fixedPriceQuantity] with a well-typed - * [Double] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + /** The minimum amount to charge each group, regardless of usage */ + fun minimumCharge(minimumCharge: String) = + minimumCharge(JsonField.of(minimumCharge)) - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = - invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + /** + * Sets [Builder.minimumCharge] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumCharge] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun minimumCharge(minimumCharge: JsonField) = apply { + this.minimumCharge = minimumCharge + } - /** - * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. - * - * You should usually call [Builder.invoiceGroupingKey] with a well-typed - * [String] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { - this.invoiceGroupingKey = invoiceGroupingKey - } + /** The base price charged per group */ + fun perUnitRate(perUnitRate: String) = + perUnitRate(JsonField.of(perUnitRate)) - /** - * Within each billing cycle, specifies the cadence at which invoices are - * produced. If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: NewBillingCycleConfiguration? - ) = - invoicingCycleConfiguration( - JsonField.ofNullable(invoicingCycleConfiguration) - ) + /** + * Sets [Builder.perUnitRate] to an arbitrary JSON value. + * + * You should usually call [Builder.perUnitRate] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun perUnitRate(perUnitRate: JsonField) = apply { + this.perUnitRate = perUnitRate + } - /** - * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.invoicingCycleConfiguration] with a - * well-typed [NewBillingCycleConfiguration] value instead. This method is - * primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * Sets [Builder.metadata] to an arbitrary JSON value. - * - * You should usually call [Builder.metadata] with a well-typed [Metadata] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - fun referenceId(referenceId: String?) = - referenceId(JsonField.ofNullable(referenceId)) + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - /** - * Sets [Builder.referenceId] to an arbitrary JSON value. - * - * You should usually call [Builder.referenceId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun referenceId(referenceId: JsonField) = apply { - this.referenceId = referenceId - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) + /** + * Returns an immutable instance of [GroupedWithMinMaxThresholdsConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .maximumCharge() + * .minimumCharge() + * .perUnitRate() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedWithMinMaxThresholdsConfig = + GroupedWithMinMaxThresholdsConfig( + checkRequired("groupingKey", groupingKey), + checkRequired("maximumCharge", maximumCharge), + checkRequired("minimumCharge", minimumCharge), + checkRequired("perUnitRate", perUnitRate), + additionalProperties.toMutableMap(), + ) } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + private var validated: Boolean = false - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) + fun validate(): GroupedWithMinMaxThresholdsConfig = apply { + if (validated) { + return@apply } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) + groupingKey() + maximumCharge() + minimumCharge() + perUnitRate() + validated = true } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } /** - * Returns an immutable instance of [EventOutput]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```kotlin - * .cadence() - * .eventOutputConfig() - * .itemId() - * .name() - * ``` + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * @throws IllegalStateException if any required field is unset. + * Used for best match union deserialization. */ - fun build(): EventOutput = - EventOutput( - checkRequired("cadence", cadence), - checkRequired("eventOutputConfig", eventOutputConfig), - checkRequired("itemId", itemId), - modelType, - checkRequired("name", name), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - conversionRateConfig, - currency, - dimensionalPriceConfiguration, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - additionalProperties.toMutableMap(), - ) - } + internal fun validity(): Int = + (if (groupingKey.asKnown() == null) 0 else 1) + + (if (maximumCharge.asKnown() == null) 0 else 1) + + (if (minimumCharge.asKnown() == null) 0 else 1) + + (if (perUnitRate.asKnown() == null) 0 else 1) - private var validated: Boolean = false + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun validate(): EventOutput = apply { - if (validated) { - return@apply + return other is GroupedWithMinMaxThresholdsConfig && + groupingKey == other.groupingKey && + maximumCharge == other.maximumCharge && + minimumCharge == other.minimumCharge && + perUnitRate == other.perUnitRate && + additionalProperties == other.additionalProperties } - cadence().validate() - eventOutputConfig().validate() - itemId() - _modelType().let { - if (it != JsonValue.from("event_output")) { - throw OrbInvalidDataException("'modelType' is invalid, received $it") - } + private val hashCode: Int by lazy { + Objects.hash( + groupingKey, + maximumCharge, + minimumCharge, + perUnitRate, + additionalProperties, + ) } - name() - billableMetricId() - billedInAdvance() - billingCycleConfiguration()?.validate() - conversionRate() - conversionRateConfig()?.validate() - currency() - dimensionalPriceConfiguration()?.validate() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration()?.validate() - metadata()?.validate() - referenceId() - validated = true - } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedWithMinMaxThresholdsConfig{groupingKey=$groupingKey, maximumCharge=$maximumCharge, minimumCharge=$minimumCharge, perUnitRate=$perUnitRate, additionalProperties=$additionalProperties}" + } /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. */ - internal fun validity(): Int = - (cadence.asKnown()?.validity() ?: 0) + - (eventOutputConfig.asKnown()?.validity() ?: 0) + - (if (itemId.asKnown() == null) 0 else 1) + - modelType.let { if (it == JsonValue.from("event_output")) 1 else 0 } + - (if (name.asKnown() == null) 0 else 1) + - (if (billableMetricId.asKnown() == null) 0 else 1) + - (if (billedInAdvance.asKnown() == null) 0 else 1) + - (billingCycleConfiguration.asKnown()?.validity() ?: 0) + - (if (conversionRate.asKnown() == null) 0 else 1) + - (conversionRateConfig.asKnown()?.validity() ?: 0) + - (if (currency.asKnown() == null) 0 else 1) + - (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + - (if (externalPriceId.asKnown() == null) 0 else 1) + - (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + - (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + - (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + - (metadata.asKnown()?.validity() ?: 0) + - (if (referenceId.asKnown() == null) 0 else 1) - - /** The cadence to bill for this price on. */ - class Cadence + class Metadata @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ + private constructor( @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value + private val additionalProperties: Map + ) { - companion object { + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties - val ANNUAL = of("annual") + fun toBuilder() = Builder().from(this) - val SEMI_ANNUAL = of("semi_annual") + companion object { - val MONTHLY = of("monthly") + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } - val QUARTERLY = of("quarterly") + /** A builder for [Metadata]. */ + class Builder internal constructor() { - val ONE_TIME = of("one_time") + private var additionalProperties: MutableMap = + mutableMapOf() - val CUSTOM = of("custom") + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } - fun of(value: String) = Cadence(JsonField.of(value)) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** An enum containing [Cadence]'s known values. */ - enum class Known { - ANNUAL, - SEMI_ANNUAL, - MONTHLY, - QUARTERLY, - ONE_TIME, - CUSTOM, - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Cadence] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - ANNUAL, - SEMI_ANNUAL, - MONTHLY, - QUARTERLY, - ONE_TIME, - CUSTOM, - /** - * An enum member indicating that [Cadence] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - ANNUAL -> Value.ANNUAL - SEMI_ANNUAL -> Value.SEMI_ANNUAL - MONTHLY -> Value.MONTHLY - QUARTERLY -> Value.QUARTERLY - ONE_TIME -> Value.ONE_TIME - CUSTOM -> Value.CUSTOM - else -> Value._UNKNOWN + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) } - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - ANNUAL -> Known.ANNUAL - SEMI_ANNUAL -> Known.SEMI_ANNUAL - MONTHLY -> Known.MONTHLY - QUARTERLY -> Known.QUARTERLY - ONE_TIME -> Known.ONE_TIME - CUSTOM -> Known.CUSTOM - else -> throw OrbInvalidDataException("Unknown Cadence: $value") + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) } - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString() - ?: throw OrbInvalidDataException("Value is not a String") + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } private var validated: Boolean = false - fun validate(): Cadence = apply { + fun validate(): Metadata = apply { if (validated) { return@apply } - known() validated = true } @@ -9356,3071 +8668,7897 @@ private constructor( * * Used for best match union deserialization. */ - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is Cadence && value == other.value + return other is Metadata && + additionalProperties == other.additionalProperties } - override fun hashCode() = value.hashCode() + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - override fun toString() = value.toString() - } + override fun hashCode(): Int = hashCode - /** Configuration for event_output pricing */ - class EventOutputConfig - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val unitRatingKey: JsonField, - private val groupingKey: JsonField, - private val additionalProperties: MutableMap, - ) { + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } - @JsonCreator - private constructor( - @JsonProperty("unit_rating_key") - @ExcludeMissing - unitRatingKey: JsonField = JsonMissing.of(), - @JsonProperty("grouping_key") - @ExcludeMissing - groupingKey: JsonField = JsonMissing.of(), - ) : this(unitRatingKey, groupingKey, mutableMapOf()) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * The key in the event data to extract the unit rate from. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun unitRatingKey(): String = unitRatingKey.getRequired("unit_rating_key") + return other is GroupedWithMinMaxThresholds && + cadence == other.cadence && + groupedWithMinMaxThresholdsConfig == + other.groupedWithMinMaxThresholdsConfig && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } - /** - * An optional key in the event data to group by (e.g., event ID). All events - * will also be grouped by their unit rate. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun groupingKey(): String? = groupingKey.getNullable("grouping_key") + private val hashCode: Int by lazy { + Objects.hash( + cadence, + groupedWithMinMaxThresholdsConfig, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties, + ) + } - /** - * Returns the raw JSON value of [unitRatingKey]. - * - * Unlike [unitRatingKey], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("unit_rating_key") - @ExcludeMissing - fun _unitRatingKey(): JsonField = unitRatingKey + override fun hashCode(): Int = hashCode - /** - * Returns the raw JSON value of [groupingKey]. - * - * Unlike [groupingKey], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("grouping_key") - @ExcludeMissing - fun _groupingKey(): JsonField = groupingKey + override fun toString() = + "GroupedWithMinMaxThresholds{cadence=$cadence, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + class Percent + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val percentConfig: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { - @JsonAnyGetter + @JsonCreator + private constructor( + @JsonProperty("cadence") @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("percent_config") + @ExcludeMissing + percentConfig: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + modelType, + name, + percentConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + mutableMapOf(), + ) - companion object { + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") - /** - * Returns a mutable builder for constructing an instance of - * [EventOutputConfig]. - * - * The following fields are required: - * ```kotlin - * .unitRatingKey() - * ``` - */ - fun builder() = Builder() - } + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") - /** A builder for [EventOutputConfig]. */ - class Builder internal constructor() { + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("percent") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType - private var unitRatingKey: JsonField? = null - private var groupingKey: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") - internal fun from(eventOutputConfig: EventOutputConfig) = apply { - unitRatingKey = eventOutputConfig.unitRatingKey - groupingKey = eventOutputConfig.groupingKey - additionalProperties = - eventOutputConfig.additionalProperties.toMutableMap() - } + /** + * Configuration for percent pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun percentConfig(): PercentConfig = percentConfig.getRequired("percent_config") - /** The key in the event data to extract the unit rate from. */ - fun unitRatingKey(unitRatingKey: String) = - unitRatingKey(JsonField.of(unitRatingKey)) + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = billableMetricId.getNullable("billable_metric_id") - /** - * Sets [Builder.unitRatingKey] to an arbitrary JSON value. - * - * You should usually call [Builder.unitRatingKey] with a well-typed - * [String] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun unitRatingKey(unitRatingKey: JsonField) = apply { - this.unitRatingKey = unitRatingKey - } + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") - /** - * An optional key in the event data to group by (e.g., event ID). All - * events will also be grouped by their unit rate. - */ - fun groupingKey(groupingKey: String?) = - groupingKey(JsonField.ofNullable(groupingKey)) - - /** - * Sets [Builder.groupingKey] to an arbitrary JSON value. - * - * You should usually call [Builder.groupingKey] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun groupingKey(groupingKey: JsonField) = apply { - this.groupingKey = groupingKey - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [EventOutputConfig]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```kotlin - * .unitRatingKey() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): EventOutputConfig = - EventOutputConfig( - checkRequired("unitRatingKey", unitRatingKey), - groupingKey, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): EventOutputConfig = apply { - if (validated) { - return@apply - } + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") - unitRatingKey() - groupingKey() - validated = true - } + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (if (unitRatingKey.asKnown() == null) 0 else 1) + - (if (groupingKey.asKnown() == null) 0 else 1) + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") - return other is EventOutputConfig && - unitRatingKey == other.unitRatingKey && - groupingKey == other.groupingKey && - additionalProperties == other.additionalProperties - } + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") - private val hashCode: Int by lazy { - Objects.hash(unitRatingKey, groupingKey, additionalProperties) - } + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") - override fun hashCode(): Int = hashCode + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + invoiceGroupingKey.getNullable("invoice_grouping_key") - override fun toString() = - "EventOutputConfig{unitRatingKey=$unitRatingKey, groupingKey=$groupingKey, additionalProperties=$additionalProperties}" - } + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). */ - class Metadata - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) + fun metadata(): Metadata? = metadata.getNullable("metadata") - companion object { + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") - /** Returns a mutable builder for constructing an instance of [Metadata]. */ - fun builder() = Builder() - } + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence - /** A builder for [Metadata]. */ - class Builder internal constructor() { + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - private var additionalProperties: MutableMap = - mutableMapOf() + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - internal fun from(metadata: Metadata) = apply { - additionalProperties = metadata.additionalProperties.toMutableMap() - } + /** + * Returns the raw JSON value of [percentConfig]. + * + * Unlike [percentConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("percent_config") + @ExcludeMissing + fun _percentConfig(): JsonField = percentConfig - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Metadata]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance - private var validated: Boolean = false + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration - fun validate(): Metadata = apply { - if (validated) { - return@apply - } + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate - validated = true - } + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - additionalProperties.count { (_, value) -> - !value.isNull() && !value.isMissing() - } + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId - return other is Metadata && - additionalProperties == other.additionalProperties - } + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - override fun hashCode(): Int = hashCode + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId - return other is EventOutput && - cadence == other.cadence && - eventOutputConfig == other.eventOutputConfig && - itemId == other.itemId && - modelType == other.modelType && - name == other.name && - billableMetricId == other.billableMetricId && - billedInAdvance == other.billedInAdvance && - billingCycleConfiguration == other.billingCycleConfiguration && - conversionRate == other.conversionRate && - conversionRateConfig == other.conversionRateConfig && - currency == other.currency && - dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && - externalPriceId == other.externalPriceId && - fixedPriceQuantity == other.fixedPriceQuantity && - invoiceGroupingKey == other.invoiceGroupingKey && - invoicingCycleConfiguration == other.invoicingCycleConfiguration && - metadata == other.metadata && - referenceId == other.referenceId && - additionalProperties == other.additionalProperties + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) } - private val hashCode: Int by lazy { - Objects.hash( - cadence, - eventOutputConfig, - itemId, - modelType, - name, - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - conversionRateConfig, - currency, - dimensionalPriceConfiguration, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - additionalProperties, - ) - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - override fun hashCode(): Int = hashCode + fun toBuilder() = Builder().from(this) - override fun toString() = - "EventOutput{cadence=$cadence, eventOutputConfig=$eventOutputConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" - } - } + companion object { - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * Returns a mutable builder for constructing an instance of [Percent]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .name() + * .percentConfig() + * ``` + */ + fun builder() = Builder() + } - return other is AddPrice && - allocationPrice == other.allocationPrice && - planPhaseOrder == other.planPhaseOrder && - price == other.price && - additionalProperties == other.additionalProperties - } + /** A builder for [Percent]. */ + class Builder internal constructor() { - private val hashCode: Int by lazy { - Objects.hash(allocationPrice, planPhaseOrder, price, additionalProperties) - } - - override fun hashCode(): Int = hashCode + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonValue = JsonValue.from("percent") + private var name: JsonField? = null + private var percentConfig: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - override fun toString() = - "AddPrice{allocationPrice=$allocationPrice, planPhaseOrder=$planPhaseOrder, price=$price, additionalProperties=$additionalProperties}" - } + internal fun from(percent: Percent) = apply { + cadence = percent.cadence + itemId = percent.itemId + modelType = percent.modelType + name = percent.name + percentConfig = percent.percentConfig + billableMetricId = percent.billableMetricId + billedInAdvance = percent.billedInAdvance + billingCycleConfiguration = percent.billingCycleConfiguration + conversionRate = percent.conversionRate + conversionRateConfig = percent.conversionRateConfig + currency = percent.currency + dimensionalPriceConfiguration = percent.dimensionalPriceConfiguration + externalPriceId = percent.externalPriceId + fixedPriceQuantity = percent.fixedPriceQuantity + invoiceGroupingKey = percent.invoiceGroupingKey + invoicingCycleConfiguration = percent.invoicingCycleConfiguration + metadata = percent.metadata + referenceId = percent.referenceId + additionalProperties = percent.additionalProperties.toMutableMap() + } - class RemoveAdjustment - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val adjustmentId: JsonField, - private val planPhaseOrder: JsonField, - private val additionalProperties: MutableMap, - ) { + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - @JsonCreator - private constructor( - @JsonProperty("adjustment_id") - @ExcludeMissing - adjustmentId: JsonField = JsonMissing.of(), - @JsonProperty("plan_phase_order") - @ExcludeMissing - planPhaseOrder: JsonField = JsonMissing.of(), - ) : this(adjustmentId, planPhaseOrder, mutableMapOf()) + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - /** - * The id of the adjustment to remove from on the plan. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun adjustmentId(): String = adjustmentId.getRequired("adjustment_id") + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - /** - * The phase to remove this adjustment from. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun planPhaseOrder(): Long? = planPhaseOrder.getNullable("plan_phase_order") + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - /** - * Returns the raw JSON value of [adjustmentId]. - * - * Unlike [adjustmentId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("adjustment_id") - @ExcludeMissing - fun _adjustmentId(): JsonField = adjustmentId + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("percent") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } - /** - * Returns the raw JSON value of [planPhaseOrder]. - * - * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("plan_phase_order") - @ExcludeMissing - fun _planPhaseOrder(): JsonField = planPhaseOrder + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** Configuration for percent pricing */ + fun percentConfig(percentConfig: PercentConfig) = + percentConfig(JsonField.of(percentConfig)) - fun toBuilder() = Builder().from(this) + /** + * Sets [Builder.percentConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.percentConfig] with a well-typed + * [PercentConfig] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun percentConfig(percentConfig: JsonField) = apply { + this.percentConfig = percentConfig + } - companion object { + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) - /** - * Returns a mutable builder for constructing an instance of [RemoveAdjustment]. - * - * The following fields are required: - * ```kotlin - * .adjustmentId() - * ``` - */ - fun builder() = Builder() - } + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } - /** A builder for [RemoveAdjustment]. */ - class Builder internal constructor() { + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) - private var adjustmentId: JsonField? = null - private var planPhaseOrder: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) - internal fun from(removeAdjustment: RemoveAdjustment) = apply { - adjustmentId = removeAdjustment.adjustmentId - planPhaseOrder = removeAdjustment.planPhaseOrder - additionalProperties = removeAdjustment.additionalProperties.toMutableMap() - } + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } - /** The id of the adjustment to remove from on the plan. */ - fun adjustmentId(adjustmentId: String) = adjustmentId(JsonField.of(adjustmentId)) + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - /** - * Sets [Builder.adjustmentId] to an arbitrary JSON value. - * - * You should usually call [Builder.adjustmentId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun adjustmentId(adjustmentId: JsonField) = apply { - this.adjustmentId = adjustmentId - } + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } - /** The phase to remove this adjustment from. */ - fun planPhaseOrder(planPhaseOrder: Long?) = - planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) - - /** - * Alias for [Builder.planPhaseOrder]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) - /** - * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. - * - * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun planPhaseOrder(planPhaseOrder: JsonField) = apply { - this.planPhaseOrder = planPhaseOrder - } + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) - /** - * Returns an immutable instance of [RemoveAdjustment]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```kotlin - * .adjustmentId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): RemoveAdjustment = - RemoveAdjustment( - checkRequired("adjustmentId", adjustmentId), - planPhaseOrder, - additionalProperties.toMutableMap(), - ) - } + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) - private var validated: Boolean = false + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) - fun validate(): RemoveAdjustment = apply { - if (validated) { - return@apply - } + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) - adjustmentId() - planPhaseOrder() - validated = true - } + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (if (adjustmentId.asKnown() == null) 0 else 1) + - (if (planPhaseOrder.asKnown() == null) 0 else 1) + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) - return other is RemoveAdjustment && - adjustmentId == other.adjustmentId && - planPhaseOrder == other.planPhaseOrder && - additionalProperties == other.additionalProperties - } + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } - private val hashCode: Int by lazy { - Objects.hash(adjustmentId, planPhaseOrder, additionalProperties) - } + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) - override fun hashCode(): Int = hashCode + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) - override fun toString() = - "RemoveAdjustment{adjustmentId=$adjustmentId, planPhaseOrder=$planPhaseOrder, additionalProperties=$additionalProperties}" - } + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } - class RemovePrice - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val priceId: JsonField, - private val planPhaseOrder: JsonField, - private val additionalProperties: MutableMap, - ) { + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) - @JsonCreator - private constructor( - @JsonProperty("price_id") @ExcludeMissing priceId: JsonField = JsonMissing.of(), - @JsonProperty("plan_phase_order") - @ExcludeMissing - planPhaseOrder: JsonField = JsonMissing.of(), - ) : this(priceId, planPhaseOrder, mutableMapOf()) - - /** - * The id of the price to remove from the plan. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun priceId(): String = priceId.getRequired("price_id") - - /** - * The phase to remove this price from. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun planPhaseOrder(): Long? = planPhaseOrder.getNullable("plan_phase_order") + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } - /** - * Returns the raw JSON value of [priceId]. - * - * Unlike [priceId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) - /** - * Returns the raw JSON value of [planPhaseOrder]. - * - * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("plan_phase_order") - @ExcludeMissing - fun _planPhaseOrder(): JsonField = planPhaseOrder + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - fun toBuilder() = Builder().from(this) + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) - companion object { + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } - /** - * Returns a mutable builder for constructing an instance of [RemovePrice]. - * - * The following fields are required: - * ```kotlin - * .priceId() - * ``` - */ - fun builder() = Builder() - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** A builder for [RemovePrice]. */ - class Builder internal constructor() { + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - private var priceId: JsonField? = null - private var planPhaseOrder: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - internal fun from(removePrice: RemovePrice) = apply { - priceId = removePrice.priceId - planPhaseOrder = removePrice.planPhaseOrder - additionalProperties = removePrice.additionalProperties.toMutableMap() - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - /** The id of the price to remove from the plan. */ - fun priceId(priceId: String) = priceId(JsonField.of(priceId)) + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - /** - * Sets [Builder.priceId] to an arbitrary JSON value. - * - * You should usually call [Builder.priceId] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun priceId(priceId: JsonField) = apply { this.priceId = priceId } + /** + * Returns an immutable instance of [Percent]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .name() + * .percentConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Percent = + Percent( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + modelType, + checkRequired("name", name), + checkRequired("percentConfig", percentConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } - /** The phase to remove this price from. */ - fun planPhaseOrder(planPhaseOrder: Long?) = - planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + private var validated: Boolean = false - /** - * Alias for [Builder.planPhaseOrder]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + fun validate(): Percent = apply { + if (validated) { + return@apply + } - /** - * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. - * - * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun planPhaseOrder(planPhaseOrder: JsonField) = apply { - this.planPhaseOrder = planPhaseOrder - } + cadence().validate() + itemId() + _modelType().let { + if (it != JsonValue.from("percent")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + percentConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + metadata()?.validate() + referenceId() + validated = true + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + modelType.let { if (it == JsonValue.from("percent")) 1 else 0 } + + (if (name.asKnown() == null) 0 else 1) + + (percentConfig.asKnown()?.validity() ?: 0) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + companion object { - /** - * Returns an immutable instance of [RemovePrice]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```kotlin - * .priceId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): RemovePrice = - RemovePrice( - checkRequired("priceId", priceId), - planPhaseOrder, - additionalProperties.toMutableMap(), - ) - } + val ANNUAL = of("annual") - private var validated: Boolean = false + val SEMI_ANNUAL = of("semi_annual") - fun validate(): RemovePrice = apply { - if (validated) { - return@apply - } + val MONTHLY = of("monthly") - priceId() - planPhaseOrder() - validated = true - } + val QUARTERLY = of("quarterly") - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + val ONE_TIME = of("one_time") - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (if (priceId.asKnown() == null) 0 else 1) + - (if (planPhaseOrder.asKnown() == null) 0 else 1) + val CUSTOM = of("custom") - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + fun of(value: String) = Cadence(JsonField.of(value)) + } - return other is RemovePrice && - priceId == other.priceId && - planPhaseOrder == other.planPhaseOrder && - additionalProperties == other.additionalProperties - } + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } - private val hashCode: Int by lazy { - Objects.hash(priceId, planPhaseOrder, additionalProperties) - } + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } - override fun hashCode(): Int = hashCode + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } - override fun toString() = - "RemovePrice{priceId=$priceId, planPhaseOrder=$planPhaseOrder, additionalProperties=$additionalProperties}" - } + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } - class ReplaceAdjustment - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val adjustment: JsonField, - private val replacesAdjustmentId: JsonField, - private val planPhaseOrder: JsonField, - private val additionalProperties: MutableMap, - ) { + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") - @JsonCreator - private constructor( - @JsonProperty("adjustment") - @ExcludeMissing - adjustment: JsonField = JsonMissing.of(), - @JsonProperty("replaces_adjustment_id") - @ExcludeMissing - replacesAdjustmentId: JsonField = JsonMissing.of(), - @JsonProperty("plan_phase_order") - @ExcludeMissing - planPhaseOrder: JsonField = JsonMissing.of(), - ) : this(adjustment, replacesAdjustmentId, planPhaseOrder, mutableMapOf()) + private var validated: Boolean = false - /** - * The definition of a new adjustment to create and add to the plan. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun adjustment(): Adjustment = adjustment.getRequired("adjustment") + fun validate(): Cadence = apply { + if (validated) { + return@apply + } - /** - * The id of the adjustment on the plan to replace in the plan. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun replacesAdjustmentId(): String = - replacesAdjustmentId.getRequired("replaces_adjustment_id") + known() + validated = true + } - /** - * The phase to replace this adjustment from. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun planPhaseOrder(): Long? = planPhaseOrder.getNullable("plan_phase_order") + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - /** - * Returns the raw JSON value of [adjustment]. - * - * Unlike [adjustment], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("adjustment") - @ExcludeMissing - fun _adjustment(): JsonField = adjustment + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - /** - * Returns the raw JSON value of [replacesAdjustmentId]. - * - * Unlike [replacesAdjustmentId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("replaces_adjustment_id") - @ExcludeMissing - fun _replacesAdjustmentId(): JsonField = replacesAdjustmentId + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * Returns the raw JSON value of [planPhaseOrder]. - * - * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("plan_phase_order") - @ExcludeMissing - fun _planPhaseOrder(): JsonField = planPhaseOrder + return other is Cadence && value == other.value + } - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + override fun hashCode() = value.hashCode() - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + override fun toString() = value.toString() + } - fun toBuilder() = Builder().from(this) + /** Configuration for percent pricing */ + class PercentConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val percent: JsonField, + private val additionalProperties: MutableMap, + ) { - companion object { + @JsonCreator + private constructor( + @JsonProperty("percent") + @ExcludeMissing + percent: JsonField = JsonMissing.of() + ) : this(percent, mutableMapOf()) - /** - * Returns a mutable builder for constructing an instance of [ReplaceAdjustment]. - * - * The following fields are required: - * ```kotlin - * .adjustment() - * .replacesAdjustmentId() - * ``` - */ - fun builder() = Builder() - } + /** + * What percent of the component subtotals to charge + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun percent(): Double = percent.getRequired("percent") - /** A builder for [ReplaceAdjustment]. */ - class Builder internal constructor() { + /** + * Returns the raw JSON value of [percent]. + * + * Unlike [percent], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("percent") + @ExcludeMissing + fun _percent(): JsonField = percent - private var adjustment: JsonField? = null - private var replacesAdjustmentId: JsonField? = null - private var planPhaseOrder: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - internal fun from(replaceAdjustment: ReplaceAdjustment) = apply { - adjustment = replaceAdjustment.adjustment - replacesAdjustmentId = replaceAdjustment.replacesAdjustmentId - planPhaseOrder = replaceAdjustment.planPhaseOrder - additionalProperties = replaceAdjustment.additionalProperties.toMutableMap() - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - /** The definition of a new adjustment to create and add to the plan. */ - fun adjustment(adjustment: Adjustment) = adjustment(JsonField.of(adjustment)) + fun toBuilder() = Builder().from(this) - /** - * Sets [Builder.adjustment] to an arbitrary JSON value. - * - * You should usually call [Builder.adjustment] with a well-typed [Adjustment] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun adjustment(adjustment: JsonField) = apply { - this.adjustment = adjustment - } + companion object { - /** - * Alias for calling [adjustment] with - * `Adjustment.ofPercentageDiscount(percentageDiscount)`. - */ - fun adjustment(percentageDiscount: NewPercentageDiscount) = - adjustment(Adjustment.ofPercentageDiscount(percentageDiscount)) + /** + * Returns a mutable builder for constructing an instance of + * [PercentConfig]. + * + * The following fields are required: + * ```kotlin + * .percent() + * ``` + */ + fun builder() = Builder() + } - /** - * Alias for calling [adjustment] with the following: - * ```kotlin - * NewPercentageDiscount.builder() - * .adjustmentType(NewPercentageDiscount.AdjustmentType.PERCENTAGE_DISCOUNT) - * .percentageDiscount(percentageDiscount) - * .build() - * ``` - */ - fun percentageDiscountAdjustment(percentageDiscount: Double) = - adjustment( - NewPercentageDiscount.builder() - .adjustmentType(NewPercentageDiscount.AdjustmentType.PERCENTAGE_DISCOUNT) - .percentageDiscount(percentageDiscount) - .build() - ) + /** A builder for [PercentConfig]. */ + class Builder internal constructor() { - /** Alias for calling [adjustment] with `Adjustment.ofUsageDiscount(usageDiscount)`. */ - fun adjustment(usageDiscount: NewUsageDiscount) = - adjustment(Adjustment.ofUsageDiscount(usageDiscount)) + private var percent: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() - /** - * Alias for calling [adjustment] with the following: - * ```kotlin - * NewUsageDiscount.builder() - * .adjustmentType(NewUsageDiscount.AdjustmentType.USAGE_DISCOUNT) - * .usageDiscount(usageDiscount) - * .build() - * ``` - */ - fun usageDiscountAdjustment(usageDiscount: Double) = - adjustment( - NewUsageDiscount.builder() - .adjustmentType(NewUsageDiscount.AdjustmentType.USAGE_DISCOUNT) - .usageDiscount(usageDiscount) - .build() - ) + internal fun from(percentConfig: PercentConfig) = apply { + percent = percentConfig.percent + additionalProperties = percentConfig.additionalProperties.toMutableMap() + } - /** - * Alias for calling [adjustment] with `Adjustment.ofAmountDiscount(amountDiscount)`. - */ - fun adjustment(amountDiscount: NewAmountDiscount) = - adjustment(Adjustment.ofAmountDiscount(amountDiscount)) + /** What percent of the component subtotals to charge */ + fun percent(percent: Double) = percent(JsonField.of(percent)) - /** - * Alias for calling [adjustment] with the following: - * ```kotlin - * NewAmountDiscount.builder() - * .adjustmentType(NewAmountDiscount.AdjustmentType.AMOUNT_DISCOUNT) - * .amountDiscount(amountDiscount) - * .build() - * ``` - */ - fun amountDiscountAdjustment(amountDiscount: String) = - adjustment( - NewAmountDiscount.builder() - .adjustmentType(NewAmountDiscount.AdjustmentType.AMOUNT_DISCOUNT) - .amountDiscount(amountDiscount) - .build() - ) + /** + * Sets [Builder.percent] to an arbitrary JSON value. + * + * You should usually call [Builder.percent] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun percent(percent: JsonField) = apply { this.percent = percent } - /** Alias for calling [adjustment] with `Adjustment.ofMinimum(minimum)`. */ - fun adjustment(minimum: NewMinimum) = adjustment(Adjustment.ofMinimum(minimum)) + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** Alias for calling [adjustment] with `Adjustment.ofMaximum(maximum)`. */ - fun adjustment(maximum: NewMaximum) = adjustment(Adjustment.ofMaximum(maximum)) + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * Alias for calling [adjustment] with the following: - * ```kotlin - * NewMaximum.builder() - * .adjustmentType(NewMaximum.AdjustmentType.MAXIMUM) - * .maximumAmount(maximumAmount) - * .build() - * ``` - */ - fun maximumAdjustment(maximumAmount: String) = - adjustment( - NewMaximum.builder() - .adjustmentType(NewMaximum.AdjustmentType.MAXIMUM) - .maximumAmount(maximumAmount) - .build() - ) + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - /** The id of the adjustment on the plan to replace in the plan. */ - fun replacesAdjustmentId(replacesAdjustmentId: String) = - replacesAdjustmentId(JsonField.of(replacesAdjustmentId)) + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - /** - * Sets [Builder.replacesAdjustmentId] to an arbitrary JSON value. - * - * You should usually call [Builder.replacesAdjustmentId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun replacesAdjustmentId(replacesAdjustmentId: JsonField) = apply { - this.replacesAdjustmentId = replacesAdjustmentId - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - /** The phase to replace this adjustment from. */ - fun planPhaseOrder(planPhaseOrder: Long?) = - planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + /** + * Returns an immutable instance of [PercentConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .percent() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): PercentConfig = + PercentConfig( + checkRequired("percent", percent), + additionalProperties.toMutableMap(), + ) + } - /** - * Alias for [Builder.planPhaseOrder]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + private var validated: Boolean = false - /** - * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. - * - * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun planPhaseOrder(planPhaseOrder: JsonField) = apply { - this.planPhaseOrder = planPhaseOrder - } + fun validate(): PercentConfig = apply { + if (validated) { + return@apply + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + percent() + validated = true + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = (if (percent.asKnown() == null) 0 else 1) - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + return other is PercentConfig && + percent == other.percent && + additionalProperties == other.additionalProperties + } - /** - * Returns an immutable instance of [ReplaceAdjustment]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```kotlin - * .adjustment() - * .replacesAdjustmentId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): ReplaceAdjustment = - ReplaceAdjustment( - checkRequired("adjustment", adjustment), - checkRequired("replacesAdjustmentId", replacesAdjustmentId), - planPhaseOrder, - additionalProperties.toMutableMap(), - ) - } + private val hashCode: Int by lazy { + Objects.hash(percent, additionalProperties) + } - private var validated: Boolean = false + override fun hashCode(): Int = hashCode - fun validate(): ReplaceAdjustment = apply { - if (validated) { - return@apply - } + override fun toString() = + "PercentConfig{percent=$percent, additionalProperties=$additionalProperties}" + } - adjustment().validate() - replacesAdjustmentId() - planPhaseOrder() - validated = true - } + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (adjustment.asKnown()?.validity() ?: 0) + - (if (replacesAdjustmentId.asKnown() == null) 0 else 1) + - (if (planPhaseOrder.asKnown() == null) 0 else 1) + fun toBuilder() = Builder().from(this) - /** The definition of a new adjustment to create and add to the plan. */ - @JsonDeserialize(using = Adjustment.Deserializer::class) - @JsonSerialize(using = Adjustment.Serializer::class) - class Adjustment - private constructor( - private val percentageDiscount: NewPercentageDiscount? = null, - private val usageDiscount: NewUsageDiscount? = null, - private val amountDiscount: NewAmountDiscount? = null, - private val minimum: NewMinimum? = null, - private val maximum: NewMaximum? = null, - private val _json: JsonValue? = null, - ) { + companion object { - fun percentageDiscount(): NewPercentageDiscount? = percentageDiscount + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } - fun usageDiscount(): NewUsageDiscount? = usageDiscount + /** A builder for [Metadata]. */ + class Builder internal constructor() { - fun amountDiscount(): NewAmountDiscount? = amountDiscount + private var additionalProperties: MutableMap = + mutableMapOf() - fun minimum(): NewMinimum? = minimum + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } - fun maximum(): NewMaximum? = maximum + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun isPercentageDiscount(): Boolean = percentageDiscount != null + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun isUsageDiscount(): Boolean = usageDiscount != null + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun isAmountDiscount(): Boolean = amountDiscount != null + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun isMinimum(): Boolean = minimum != null + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - fun isMaximum(): Boolean = maximum != null + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } - fun asPercentageDiscount(): NewPercentageDiscount = - percentageDiscount.getOrThrow("percentageDiscount") + private var validated: Boolean = false - fun asUsageDiscount(): NewUsageDiscount = usageDiscount.getOrThrow("usageDiscount") + fun validate(): Metadata = apply { + if (validated) { + return@apply + } - fun asAmountDiscount(): NewAmountDiscount = amountDiscount.getOrThrow("amountDiscount") + validated = true + } - fun asMinimum(): NewMinimum = minimum.getOrThrow("minimum") + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - fun asMaximum(): NewMaximum = maximum.getOrThrow("maximum") + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } - fun _json(): JsonValue? = _json + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun accept(visitor: Visitor): T = - when { - percentageDiscount != null -> - visitor.visitPercentageDiscount(percentageDiscount) - usageDiscount != null -> visitor.visitUsageDiscount(usageDiscount) - amountDiscount != null -> visitor.visitAmountDiscount(amountDiscount) - minimum != null -> visitor.visitMinimum(minimum) - maximum != null -> visitor.visitMaximum(maximum) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): Adjustment = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitPercentageDiscount( - percentageDiscount: NewPercentageDiscount - ) { - percentageDiscount.validate() - } + return other is Metadata && + additionalProperties == other.additionalProperties + } - override fun visitUsageDiscount(usageDiscount: NewUsageDiscount) { - usageDiscount.validate() - } + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - override fun visitAmountDiscount(amountDiscount: NewAmountDiscount) { - amountDiscount.validate() - } + override fun hashCode(): Int = hashCode - override fun visitMinimum(minimum: NewMinimum) { - minimum.validate() - } + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } - override fun visitMaximum(maximum: NewMaximum) { - maximum.validate() - } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - ) - validated = true - } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false + return other is Percent && + cadence == other.cadence && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + percentConfig == other.percentConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitPercentageDiscount( - percentageDiscount: NewPercentageDiscount - ) = percentageDiscount.validity() - - override fun visitUsageDiscount(usageDiscount: NewUsageDiscount) = - usageDiscount.validity() + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + modelType, + name, + percentConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties, + ) + } - override fun visitAmountDiscount(amountDiscount: NewAmountDiscount) = - amountDiscount.validity() + override fun hashCode(): Int = hashCode - override fun visitMinimum(minimum: NewMinimum) = minimum.validity() + override fun toString() = + "Percent{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, percentConfig=$percentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } - override fun visitMaximum(maximum: NewMaximum) = maximum.validity() + class EventOutput + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val eventOutputConfig: JsonField, + private val itemId: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { - override fun unknown(json: JsonValue?) = 0 - } + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("event_output_config") + @ExcludeMissing + eventOutputConfig: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + eventOutputConfig, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + mutableMapOf(), ) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Adjustment && - percentageDiscount == other.percentageDiscount && - usageDiscount == other.usageDiscount && - amountDiscount == other.amountDiscount && - minimum == other.minimum && - maximum == other.maximum - } + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") - override fun hashCode(): Int = - Objects.hash(percentageDiscount, usageDiscount, amountDiscount, minimum, maximum) + /** + * Configuration for event_output pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun eventOutputConfig(): EventOutputConfig = + eventOutputConfig.getRequired("event_output_config") - override fun toString(): String = - when { - percentageDiscount != null -> - "Adjustment{percentageDiscount=$percentageDiscount}" - usageDiscount != null -> "Adjustment{usageDiscount=$usageDiscount}" - amountDiscount != null -> "Adjustment{amountDiscount=$amountDiscount}" - minimum != null -> "Adjustment{minimum=$minimum}" - maximum != null -> "Adjustment{maximum=$maximum}" - _json != null -> "Adjustment{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Adjustment") - } - - companion object { + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") - fun ofPercentageDiscount(percentageDiscount: NewPercentageDiscount) = - Adjustment(percentageDiscount = percentageDiscount) + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("event_output") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType - fun ofUsageDiscount(usageDiscount: NewUsageDiscount) = - Adjustment(usageDiscount = usageDiscount) + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") - fun ofAmountDiscount(amountDiscount: NewAmountDiscount) = - Adjustment(amountDiscount = amountDiscount) + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = billableMetricId.getNullable("billable_metric_id") - fun ofMinimum(minimum: NewMinimum) = Adjustment(minimum = minimum) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") - fun ofMaximum(maximum: NewMaximum) = Adjustment(maximum = maximum) - } + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") - /** - * An interface that defines how to map each variant of [Adjustment] to a value of type - * [T]. - */ - interface Visitor { + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") - fun visitPercentageDiscount(percentageDiscount: NewPercentageDiscount): T + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") - fun visitUsageDiscount(usageDiscount: NewUsageDiscount): T + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") - fun visitAmountDiscount(amountDiscount: NewAmountDiscount): T + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") - fun visitMinimum(minimum: NewMinimum): T + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") - fun visitMaximum(maximum: NewMaximum): T + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") /** - * Maps an unknown variant of [Adjustment] to a value of type [T]. + * The property used to group this price on an invoice * - * An instance of [Adjustment] can contain an unknown variant if it was deserialized - * from data that doesn't match any known variant. For example, if the SDK is on an - * older version than the API, then the API may respond with new variants that the - * SDK is unaware of. + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + invoiceGroupingKey.getNullable("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. * - * @throws OrbInvalidDataException in the default implementation. + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown Adjustment: $json") - } - } + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - internal class Deserializer : BaseDeserializer(Adjustment::class) { + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") - override fun ObjectCodec.deserialize(node: JsonNode): Adjustment { - val json = JsonValue.fromJsonNode(node) - val adjustmentType = json.asObject()?.get("adjustment_type")?.asString() + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") - when (adjustmentType) { - "percentage_discount" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Adjustment(percentageDiscount = it, _json = json) } - ?: Adjustment(_json = json) - } - "usage_discount" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(usageDiscount = it, _json = json) - } ?: Adjustment(_json = json) - } - "amount_discount" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(amountDiscount = it, _json = json) - } ?: Adjustment(_json = json) - } - "minimum" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(minimum = it, _json = json) - } ?: Adjustment(_json = json) - } - "maximum" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(maximum = it, _json = json) - } ?: Adjustment(_json = json) - } - } + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence - return Adjustment(_json = json) - } - } + /** + * Returns the raw JSON value of [eventOutputConfig]. + * + * Unlike [eventOutputConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("event_output_config") + @ExcludeMissing + fun _eventOutputConfig(): JsonField = eventOutputConfig - internal class Serializer : BaseSerializer(Adjustment::class) { + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - override fun serialize( - value: Adjustment, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.percentageDiscount != null -> - generator.writeObject(value.percentageDiscount) - value.usageDiscount != null -> generator.writeObject(value.usageDiscount) - value.amountDiscount != null -> generator.writeObject(value.amountDiscount) - value.minimum != null -> generator.writeObject(value.minimum) - value.maximum != null -> generator.writeObject(value.maximum) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Adjustment") - } - } - } - } + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId - return other is ReplaceAdjustment && - adjustment == other.adjustment && - replacesAdjustmentId == other.replacesAdjustmentId && - planPhaseOrder == other.planPhaseOrder && - additionalProperties == other.additionalProperties - } + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance - private val hashCode: Int by lazy { - Objects.hash(adjustment, replacesAdjustmentId, planPhaseOrder, additionalProperties) - } + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration - override fun hashCode(): Int = hashCode + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate - override fun toString() = - "ReplaceAdjustment{adjustment=$adjustment, replacesAdjustmentId=$replacesAdjustmentId, planPhaseOrder=$planPhaseOrder, additionalProperties=$additionalProperties}" - } + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig - class ReplacePrice - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val replacesPriceId: JsonField, - private val allocationPrice: JsonField, - private val planPhaseOrder: JsonField, - private val price: JsonField, - private val additionalProperties: MutableMap, - ) { + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency - @JsonCreator - private constructor( - @JsonProperty("replaces_price_id") - @ExcludeMissing - replacesPriceId: JsonField = JsonMissing.of(), - @JsonProperty("allocation_price") - @ExcludeMissing - allocationPrice: JsonField = JsonMissing.of(), - @JsonProperty("plan_phase_order") - @ExcludeMissing - planPhaseOrder: JsonField = JsonMissing.of(), - @JsonProperty("price") @ExcludeMissing price: JsonField = JsonMissing.of(), - ) : this(replacesPriceId, allocationPrice, planPhaseOrder, price, mutableMapOf()) + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration - /** - * The id of the price on the plan to replace in the plan. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun replacesPriceId(): String = replacesPriceId.getRequired("replaces_price_id") + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId - /** - * The allocation price to add to the plan. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun allocationPrice(): NewAllocationPrice? = allocationPrice.getNullable("allocation_price") + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - /** - * The phase to replace this price from. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun planPhaseOrder(): Long? = planPhaseOrder.getNullable("plan_phase_order") + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - /** - * New plan price request body params. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun price(): Price? = price.getNullable("price") + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration - /** - * Returns the raw JSON value of [replacesPriceId]. - * - * Unlike [replacesPriceId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("replaces_price_id") - @ExcludeMissing - fun _replacesPriceId(): JsonField = replacesPriceId + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata - /** - * Returns the raw JSON value of [allocationPrice]. - * - * Unlike [allocationPrice], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("allocation_price") - @ExcludeMissing - fun _allocationPrice(): JsonField = allocationPrice + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId - /** - * Returns the raw JSON value of [planPhaseOrder]. - * - * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("plan_phase_order") - @ExcludeMissing - fun _planPhaseOrder(): JsonField = planPhaseOrder + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - /** - * Returns the raw JSON value of [price]. - * - * Unlike [price], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("price") @ExcludeMissing fun _price(): JsonField = price + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + fun toBuilder() = Builder().from(this) - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + companion object { - fun toBuilder() = Builder().from(this) + /** + * Returns a mutable builder for constructing an instance of [EventOutput]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .eventOutputConfig() + * .itemId() + * .name() + * ``` + */ + fun builder() = Builder() + } - companion object { + /** A builder for [EventOutput]. */ + class Builder internal constructor() { - /** - * Returns a mutable builder for constructing an instance of [ReplacePrice]. - * - * The following fields are required: - * ```kotlin - * .replacesPriceId() - * ``` - */ - fun builder() = Builder() - } + private var cadence: JsonField? = null + private var eventOutputConfig: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonValue = JsonValue.from("event_output") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - /** A builder for [ReplacePrice]. */ - class Builder internal constructor() { + internal fun from(eventOutput: EventOutput) = apply { + cadence = eventOutput.cadence + eventOutputConfig = eventOutput.eventOutputConfig + itemId = eventOutput.itemId + modelType = eventOutput.modelType + name = eventOutput.name + billableMetricId = eventOutput.billableMetricId + billedInAdvance = eventOutput.billedInAdvance + billingCycleConfiguration = eventOutput.billingCycleConfiguration + conversionRate = eventOutput.conversionRate + conversionRateConfig = eventOutput.conversionRateConfig + currency = eventOutput.currency + dimensionalPriceConfiguration = eventOutput.dimensionalPriceConfiguration + externalPriceId = eventOutput.externalPriceId + fixedPriceQuantity = eventOutput.fixedPriceQuantity + invoiceGroupingKey = eventOutput.invoiceGroupingKey + invoicingCycleConfiguration = eventOutput.invoicingCycleConfiguration + metadata = eventOutput.metadata + referenceId = eventOutput.referenceId + additionalProperties = eventOutput.additionalProperties.toMutableMap() + } - private var replacesPriceId: JsonField? = null - private var allocationPrice: JsonField = JsonMissing.of() - private var planPhaseOrder: JsonField = JsonMissing.of() - private var price: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - internal fun from(replacePrice: ReplacePrice) = apply { - replacesPriceId = replacePrice.replacesPriceId - allocationPrice = replacePrice.allocationPrice - planPhaseOrder = replacePrice.planPhaseOrder - price = replacePrice.price - additionalProperties = replacePrice.additionalProperties.toMutableMap() - } + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - /** The id of the price on the plan to replace in the plan. */ - fun replacesPriceId(replacesPriceId: String) = - replacesPriceId(JsonField.of(replacesPriceId)) + /** Configuration for event_output pricing */ + fun eventOutputConfig(eventOutputConfig: EventOutputConfig) = + eventOutputConfig(JsonField.of(eventOutputConfig)) - /** - * Sets [Builder.replacesPriceId] to an arbitrary JSON value. - * - * You should usually call [Builder.replacesPriceId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun replacesPriceId(replacesPriceId: JsonField) = apply { - this.replacesPriceId = replacesPriceId - } + /** + * Sets [Builder.eventOutputConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.eventOutputConfig] with a well-typed + * [EventOutputConfig] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun eventOutputConfig(eventOutputConfig: JsonField) = apply { + this.eventOutputConfig = eventOutputConfig + } - /** The allocation price to add to the plan. */ - fun allocationPrice(allocationPrice: NewAllocationPrice?) = - allocationPrice(JsonField.ofNullable(allocationPrice)) + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - /** - * Sets [Builder.allocationPrice] to an arbitrary JSON value. - * - * You should usually call [Builder.allocationPrice] with a well-typed - * [NewAllocationPrice] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun allocationPrice(allocationPrice: JsonField) = apply { - this.allocationPrice = allocationPrice - } + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - /** The phase to replace this price from. */ - fun planPhaseOrder(planPhaseOrder: Long?) = - planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("event_output") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } - /** - * Alias for [Builder.planPhaseOrder]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) - /** - * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. - * - * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun planPhaseOrder(planPhaseOrder: JsonField) = apply { - this.planPhaseOrder = planPhaseOrder - } + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } - /** New plan price request body params. */ - fun price(price: Price?) = price(JsonField.ofNullable(price)) + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) - /** - * Sets [Builder.price] to an arbitrary JSON value. - * - * You should usually call [Builder.price] with a well-typed [Price] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun price(price: JsonField) = apply { this.price = price } + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } - /** Alias for calling [price] with `Price.ofUnit(unit)`. */ - fun price(unit: NewPlanUnitPrice) = price(Price.ofUnit(unit)) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) - /** Alias for calling [price] with `Price.ofTiered(tiered)`. */ - fun price(tiered: NewPlanTieredPrice) = price(Price.ofTiered(tiered)) + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) - /** Alias for calling [price] with `Price.ofBulk(bulk)`. */ - fun price(bulk: NewPlanBulkPrice) = price(Price.ofBulk(bulk)) + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } - /** Alias for calling [price] with `Price.ofPackage(package_)`. */ - fun price(package_: NewPlanPackagePrice) = price(Price.ofPackage(package_)) + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - /** Alias for calling [price] with `Price.ofMatrix(matrix)`. */ - fun price(matrix: NewPlanMatrixPrice) = price(Price.ofMatrix(matrix)) + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } - /** - * Alias for calling [price] with `Price.ofThresholdTotalAmount(thresholdTotalAmount)`. - */ - fun price(thresholdTotalAmount: NewPlanThresholdTotalAmountPrice) = - price(Price.ofThresholdTotalAmount(thresholdTotalAmount)) + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) - /** Alias for calling [price] with `Price.ofTieredPackage(tieredPackage)`. */ - fun price(tieredPackage: NewPlanTieredPackagePrice) = - price(Price.ofTieredPackage(tieredPackage)) + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) - /** Alias for calling [price] with `Price.ofTieredWithMinimum(tieredWithMinimum)`. */ - fun price(tieredWithMinimum: NewPlanTieredWithMinimumPrice) = - price(Price.ofTieredWithMinimum(tieredWithMinimum)) + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } - /** Alias for calling [price] with `Price.ofGroupedTiered(groupedTiered)`. */ - fun price(groupedTiered: NewPlanGroupedTieredPrice) = - price(Price.ofGroupedTiered(groupedTiered)) + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) - /** - * Alias for calling [price] with - * `Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)`. - */ - fun price(tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice) = - price(Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)) + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } - /** - * Alias for calling [price] with - * `Price.ofPackageWithAllocation(packageWithAllocation)`. - */ - fun price(packageWithAllocation: NewPlanPackageWithAllocationPrice) = - price(Price.ofPackageWithAllocation(packageWithAllocation)) + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) - /** Alias for calling [price] with `Price.ofUnitWithPercent(unitWithPercent)`. */ - fun price(unitWithPercent: NewPlanUnitWithPercentPrice) = - price(Price.ofUnitWithPercent(unitWithPercent)) + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) - /** - * Alias for calling [price] with `Price.ofMatrixWithAllocation(matrixWithAllocation)`. - */ - fun price(matrixWithAllocation: NewPlanMatrixWithAllocationPrice) = - price(Price.ofMatrixWithAllocation(matrixWithAllocation)) + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) - /** - * Alias for calling [price] with `Price.ofTieredWithProration(tieredWithProration)`. - */ - fun price(tieredWithProration: Price.TieredWithProration) = - price(Price.ofTieredWithProration(tieredWithProration)) + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) - /** Alias for calling [price] with `Price.ofUnitWithProration(unitWithProration)`. */ - fun price(unitWithProration: NewPlanUnitWithProrationPrice) = - price(Price.ofUnitWithProration(unitWithProration)) + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) - /** Alias for calling [price] with `Price.ofGroupedAllocation(groupedAllocation)`. */ - fun price(groupedAllocation: NewPlanGroupedAllocationPrice) = - price(Price.ofGroupedAllocation(groupedAllocation)) + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } - /** Alias for calling [price] with `Price.ofBulkWithProration(bulkWithProration)`. */ - fun price(bulkWithProration: NewPlanBulkWithProrationPrice) = - price(Price.ofBulkWithProration(bulkWithProration)) + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) - /** - * Alias for calling [price] with - * `Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)`. - */ - fun price(groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice) = - price(Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)) + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } - /** - * Alias for calling [price] with - * `Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)`. - */ - fun price(groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice) = - price(Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)) + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) - /** - * Alias for calling [price] with - * `Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)`. - */ - fun price(groupedWithMinMaxThresholds: Price.GroupedWithMinMaxThresholds) = - price(Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)) + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } - /** - * Alias for calling [price] with - * `Price.ofMatrixWithDisplayName(matrixWithDisplayName)`. - */ - fun price(matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice) = - price(Price.ofMatrixWithDisplayName(matrixWithDisplayName)) + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) - /** - * Alias for calling [price] with `Price.ofGroupedTieredPackage(groupedTieredPackage)`. - */ - fun price(groupedTieredPackage: NewPlanGroupedTieredPackagePrice) = - price(Price.ofGroupedTieredPackage(groupedTieredPackage)) + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) - /** - * Alias for calling [price] with - * `Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)`. - */ - fun price(maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice) = - price(Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)) + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } - /** - * Alias for calling [price] with - * `Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)`. - */ - fun price(scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice) = - price(Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)) + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) - /** - * Alias for calling [price] with - * `Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)`. - */ - fun price( - scalableMatrixWithTieredPricing: NewPlanScalableMatrixWithTieredPricingPrice - ) = price(Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)) + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } - /** - * Alias for calling [price] with - * `Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)`. - */ - fun price(cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice) = - price(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) - /** Alias for calling [price] with `Price.ofMinimum(minimum)`. */ - fun price(minimum: NewPlanMinimumCompositePrice) = price(Price.ofMinimum(minimum)) + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - /** Alias for calling [price] with `Price.ofPercent(percent)`. */ - fun price(percent: Price.Percent) = price(Price.ofPercent(percent)) + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - /** Alias for calling [price] with `Price.ofEventOutput(eventOutput)`. */ - fun price(eventOutput: Price.EventOutput) = price(Price.ofEventOutput(eventOutput)) + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - /** - * Returns an immutable instance of [ReplacePrice]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```kotlin - * .replacesPriceId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): ReplacePrice = - ReplacePrice( - checkRequired("replacesPriceId", replacesPriceId), - allocationPrice, - planPhaseOrder, - price, - additionalProperties.toMutableMap(), - ) - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - private var validated: Boolean = false + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - fun validate(): ReplacePrice = apply { - if (validated) { - return@apply + /** + * Returns an immutable instance of [EventOutput]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .eventOutputConfig() + * .itemId() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): EventOutput = + EventOutput( + checkRequired("cadence", cadence), + checkRequired("eventOutputConfig", eventOutputConfig), + checkRequired("itemId", itemId), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): EventOutput = apply { + if (validated) { + return@apply + } + + cadence().validate() + eventOutputConfig().validate() + itemId() + _modelType().let { + if (it != JsonValue.from("event_output")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (eventOutputConfig.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + modelType.let { if (it == JsonValue.from("event_output")) 1 else 0 } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Configuration for event_output pricing */ + class EventOutputConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val unitRatingKey: JsonField, + private val groupingKey: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("unit_rating_key") + @ExcludeMissing + unitRatingKey: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + ) : this(unitRatingKey, groupingKey, mutableMapOf()) + + /** + * The key in the event data to extract the unit rate from. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun unitRatingKey(): String = unitRatingKey.getRequired("unit_rating_key") + + /** + * An optional key in the event data to group by (e.g., event ID). All events + * will also be grouped by their unit rate. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun groupingKey(): String? = groupingKey.getNullable("grouping_key") + + /** + * Returns the raw JSON value of [unitRatingKey]. + * + * Unlike [unitRatingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_rating_key") + @ExcludeMissing + fun _unitRatingKey(): JsonField = unitRatingKey + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [EventOutputConfig]. + * + * The following fields are required: + * ```kotlin + * .unitRatingKey() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [EventOutputConfig]. */ + class Builder internal constructor() { + + private var unitRatingKey: JsonField? = null + private var groupingKey: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(eventOutputConfig: EventOutputConfig) = apply { + unitRatingKey = eventOutputConfig.unitRatingKey + groupingKey = eventOutputConfig.groupingKey + additionalProperties = + eventOutputConfig.additionalProperties.toMutableMap() + } + + /** The key in the event data to extract the unit rate from. */ + fun unitRatingKey(unitRatingKey: String) = + unitRatingKey(JsonField.of(unitRatingKey)) + + /** + * Sets [Builder.unitRatingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.unitRatingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun unitRatingKey(unitRatingKey: JsonField) = apply { + this.unitRatingKey = unitRatingKey + } + + /** + * An optional key in the event data to group by (e.g., event ID). All + * events will also be grouped by their unit rate. + */ + fun groupingKey(groupingKey: String?) = + groupingKey(JsonField.ofNullable(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [EventOutputConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .unitRatingKey() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): EventOutputConfig = + EventOutputConfig( + checkRequired("unitRatingKey", unitRatingKey), + groupingKey, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): EventOutputConfig = apply { + if (validated) { + return@apply + } + + unitRatingKey() + groupingKey() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (unitRatingKey.asKnown() == null) 0 else 1) + + (if (groupingKey.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is EventOutputConfig && + unitRatingKey == other.unitRatingKey && + groupingKey == other.groupingKey && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(unitRatingKey, groupingKey, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "EventOutputConfig{unitRatingKey=$unitRatingKey, groupingKey=$groupingKey, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is EventOutput && + cadence == other.cadence && + eventOutputConfig == other.eventOutputConfig && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + eventOutputConfig, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "EventOutput{cadence=$cadence, eventOutputConfig=$eventOutputConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AddPrice && + allocationPrice == other.allocationPrice && + planPhaseOrder == other.planPhaseOrder && + price == other.price && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(allocationPrice, planPhaseOrder, price, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AddPrice{allocationPrice=$allocationPrice, planPhaseOrder=$planPhaseOrder, price=$price, additionalProperties=$additionalProperties}" + } + + class RemoveAdjustment + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val adjustmentId: JsonField, + private val planPhaseOrder: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("adjustment_id") + @ExcludeMissing + adjustmentId: JsonField = JsonMissing.of(), + @JsonProperty("plan_phase_order") + @ExcludeMissing + planPhaseOrder: JsonField = JsonMissing.of(), + ) : this(adjustmentId, planPhaseOrder, mutableMapOf()) + + /** + * The id of the adjustment to remove from on the plan. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun adjustmentId(): String = adjustmentId.getRequired("adjustment_id") + + /** + * The phase to remove this adjustment from. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun planPhaseOrder(): Long? = planPhaseOrder.getNullable("plan_phase_order") + + /** + * Returns the raw JSON value of [adjustmentId]. + * + * Unlike [adjustmentId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("adjustment_id") + @ExcludeMissing + fun _adjustmentId(): JsonField = adjustmentId + + /** + * Returns the raw JSON value of [planPhaseOrder]. + * + * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [RemoveAdjustment]. + * + * The following fields are required: + * ```kotlin + * .adjustmentId() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [RemoveAdjustment]. */ + class Builder internal constructor() { + + private var adjustmentId: JsonField? = null + private var planPhaseOrder: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(removeAdjustment: RemoveAdjustment) = apply { + adjustmentId = removeAdjustment.adjustmentId + planPhaseOrder = removeAdjustment.planPhaseOrder + additionalProperties = removeAdjustment.additionalProperties.toMutableMap() + } + + /** The id of the adjustment to remove from on the plan. */ + fun adjustmentId(adjustmentId: String) = adjustmentId(JsonField.of(adjustmentId)) + + /** + * Sets [Builder.adjustmentId] to an arbitrary JSON value. + * + * You should usually call [Builder.adjustmentId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun adjustmentId(adjustmentId: JsonField) = apply { + this.adjustmentId = adjustmentId + } + + /** The phase to remove this adjustment from. */ + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + + /** + * Alias for [Builder.planPhaseOrder]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + + /** + * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. + * + * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun planPhaseOrder(planPhaseOrder: JsonField) = apply { + this.planPhaseOrder = planPhaseOrder + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [RemoveAdjustment]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .adjustmentId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): RemoveAdjustment = + RemoveAdjustment( + checkRequired("adjustmentId", adjustmentId), + planPhaseOrder, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): RemoveAdjustment = apply { + if (validated) { + return@apply + } + + adjustmentId() + planPhaseOrder() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (adjustmentId.asKnown() == null) 0 else 1) + + (if (planPhaseOrder.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RemoveAdjustment && + adjustmentId == other.adjustmentId && + planPhaseOrder == other.planPhaseOrder && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(adjustmentId, planPhaseOrder, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "RemoveAdjustment{adjustmentId=$adjustmentId, planPhaseOrder=$planPhaseOrder, additionalProperties=$additionalProperties}" + } + + class RemovePrice + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val priceId: JsonField, + private val planPhaseOrder: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("price_id") @ExcludeMissing priceId: JsonField = JsonMissing.of(), + @JsonProperty("plan_phase_order") + @ExcludeMissing + planPhaseOrder: JsonField = JsonMissing.of(), + ) : this(priceId, planPhaseOrder, mutableMapOf()) + + /** + * The id of the price to remove from the plan. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun priceId(): String = priceId.getRequired("price_id") + + /** + * The phase to remove this price from. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun planPhaseOrder(): Long? = planPhaseOrder.getNullable("plan_phase_order") + + /** + * Returns the raw JSON value of [priceId]. + * + * Unlike [priceId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId + + /** + * Returns the raw JSON value of [planPhaseOrder]. + * + * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [RemovePrice]. + * + * The following fields are required: + * ```kotlin + * .priceId() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [RemovePrice]. */ + class Builder internal constructor() { + + private var priceId: JsonField? = null + private var planPhaseOrder: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(removePrice: RemovePrice) = apply { + priceId = removePrice.priceId + planPhaseOrder = removePrice.planPhaseOrder + additionalProperties = removePrice.additionalProperties.toMutableMap() + } + + /** The id of the price to remove from the plan. */ + fun priceId(priceId: String) = priceId(JsonField.of(priceId)) + + /** + * Sets [Builder.priceId] to an arbitrary JSON value. + * + * You should usually call [Builder.priceId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun priceId(priceId: JsonField) = apply { this.priceId = priceId } + + /** The phase to remove this price from. */ + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + + /** + * Alias for [Builder.planPhaseOrder]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + + /** + * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. + * + * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun planPhaseOrder(planPhaseOrder: JsonField) = apply { + this.planPhaseOrder = planPhaseOrder + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [RemovePrice]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .priceId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): RemovePrice = + RemovePrice( + checkRequired("priceId", priceId), + planPhaseOrder, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): RemovePrice = apply { + if (validated) { + return@apply + } + + priceId() + planPhaseOrder() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (priceId.asKnown() == null) 0 else 1) + + (if (planPhaseOrder.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RemovePrice && + priceId == other.priceId && + planPhaseOrder == other.planPhaseOrder && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(priceId, planPhaseOrder, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "RemovePrice{priceId=$priceId, planPhaseOrder=$planPhaseOrder, additionalProperties=$additionalProperties}" + } + + class ReplaceAdjustment + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val adjustment: JsonField, + private val replacesAdjustmentId: JsonField, + private val planPhaseOrder: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("adjustment") + @ExcludeMissing + adjustment: JsonField = JsonMissing.of(), + @JsonProperty("replaces_adjustment_id") + @ExcludeMissing + replacesAdjustmentId: JsonField = JsonMissing.of(), + @JsonProperty("plan_phase_order") + @ExcludeMissing + planPhaseOrder: JsonField = JsonMissing.of(), + ) : this(adjustment, replacesAdjustmentId, planPhaseOrder, mutableMapOf()) + + /** + * The definition of a new adjustment to create and add to the plan. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun adjustment(): Adjustment = adjustment.getRequired("adjustment") + + /** + * The id of the adjustment on the plan to replace in the plan. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun replacesAdjustmentId(): String = + replacesAdjustmentId.getRequired("replaces_adjustment_id") + + /** + * The phase to replace this adjustment from. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun planPhaseOrder(): Long? = planPhaseOrder.getNullable("plan_phase_order") + + /** + * Returns the raw JSON value of [adjustment]. + * + * Unlike [adjustment], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("adjustment") + @ExcludeMissing + fun _adjustment(): JsonField = adjustment + + /** + * Returns the raw JSON value of [replacesAdjustmentId]. + * + * Unlike [replacesAdjustmentId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("replaces_adjustment_id") + @ExcludeMissing + fun _replacesAdjustmentId(): JsonField = replacesAdjustmentId + + /** + * Returns the raw JSON value of [planPhaseOrder]. + * + * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ReplaceAdjustment]. + * + * The following fields are required: + * ```kotlin + * .adjustment() + * .replacesAdjustmentId() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [ReplaceAdjustment]. */ + class Builder internal constructor() { + + private var adjustment: JsonField? = null + private var replacesAdjustmentId: JsonField? = null + private var planPhaseOrder: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(replaceAdjustment: ReplaceAdjustment) = apply { + adjustment = replaceAdjustment.adjustment + replacesAdjustmentId = replaceAdjustment.replacesAdjustmentId + planPhaseOrder = replaceAdjustment.planPhaseOrder + additionalProperties = replaceAdjustment.additionalProperties.toMutableMap() + } + + /** The definition of a new adjustment to create and add to the plan. */ + fun adjustment(adjustment: Adjustment) = adjustment(JsonField.of(adjustment)) + + /** + * Sets [Builder.adjustment] to an arbitrary JSON value. + * + * You should usually call [Builder.adjustment] with a well-typed [Adjustment] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun adjustment(adjustment: JsonField) = apply { + this.adjustment = adjustment + } + + /** + * Alias for calling [adjustment] with + * `Adjustment.ofPercentageDiscount(percentageDiscount)`. + */ + fun adjustment(percentageDiscount: NewPercentageDiscount) = + adjustment(Adjustment.ofPercentageDiscount(percentageDiscount)) + + /** + * Alias for calling [adjustment] with the following: + * ```kotlin + * NewPercentageDiscount.builder() + * .adjustmentType(NewPercentageDiscount.AdjustmentType.PERCENTAGE_DISCOUNT) + * .percentageDiscount(percentageDiscount) + * .build() + * ``` + */ + fun percentageDiscountAdjustment(percentageDiscount: Double) = + adjustment( + NewPercentageDiscount.builder() + .adjustmentType(NewPercentageDiscount.AdjustmentType.PERCENTAGE_DISCOUNT) + .percentageDiscount(percentageDiscount) + .build() + ) + + /** Alias for calling [adjustment] with `Adjustment.ofUsageDiscount(usageDiscount)`. */ + fun adjustment(usageDiscount: NewUsageDiscount) = + adjustment(Adjustment.ofUsageDiscount(usageDiscount)) + + /** + * Alias for calling [adjustment] with the following: + * ```kotlin + * NewUsageDiscount.builder() + * .adjustmentType(NewUsageDiscount.AdjustmentType.USAGE_DISCOUNT) + * .usageDiscount(usageDiscount) + * .build() + * ``` + */ + fun usageDiscountAdjustment(usageDiscount: Double) = + adjustment( + NewUsageDiscount.builder() + .adjustmentType(NewUsageDiscount.AdjustmentType.USAGE_DISCOUNT) + .usageDiscount(usageDiscount) + .build() + ) + + /** + * Alias for calling [adjustment] with `Adjustment.ofAmountDiscount(amountDiscount)`. + */ + fun adjustment(amountDiscount: NewAmountDiscount) = + adjustment(Adjustment.ofAmountDiscount(amountDiscount)) + + /** + * Alias for calling [adjustment] with the following: + * ```kotlin + * NewAmountDiscount.builder() + * .adjustmentType(NewAmountDiscount.AdjustmentType.AMOUNT_DISCOUNT) + * .amountDiscount(amountDiscount) + * .build() + * ``` + */ + fun amountDiscountAdjustment(amountDiscount: String) = + adjustment( + NewAmountDiscount.builder() + .adjustmentType(NewAmountDiscount.AdjustmentType.AMOUNT_DISCOUNT) + .amountDiscount(amountDiscount) + .build() + ) + + /** Alias for calling [adjustment] with `Adjustment.ofMinimum(minimum)`. */ + fun adjustment(minimum: NewMinimum) = adjustment(Adjustment.ofMinimum(minimum)) + + /** Alias for calling [adjustment] with `Adjustment.ofMaximum(maximum)`. */ + fun adjustment(maximum: NewMaximum) = adjustment(Adjustment.ofMaximum(maximum)) + + /** + * Alias for calling [adjustment] with the following: + * ```kotlin + * NewMaximum.builder() + * .adjustmentType(NewMaximum.AdjustmentType.MAXIMUM) + * .maximumAmount(maximumAmount) + * .build() + * ``` + */ + fun maximumAdjustment(maximumAmount: String) = + adjustment( + NewMaximum.builder() + .adjustmentType(NewMaximum.AdjustmentType.MAXIMUM) + .maximumAmount(maximumAmount) + .build() + ) + + /** The id of the adjustment on the plan to replace in the plan. */ + fun replacesAdjustmentId(replacesAdjustmentId: String) = + replacesAdjustmentId(JsonField.of(replacesAdjustmentId)) + + /** + * Sets [Builder.replacesAdjustmentId] to an arbitrary JSON value. + * + * You should usually call [Builder.replacesAdjustmentId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun replacesAdjustmentId(replacesAdjustmentId: JsonField) = apply { + this.replacesAdjustmentId = replacesAdjustmentId + } + + /** The phase to replace this adjustment from. */ + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + + /** + * Alias for [Builder.planPhaseOrder]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + + /** + * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. + * + * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun planPhaseOrder(planPhaseOrder: JsonField) = apply { + this.planPhaseOrder = planPhaseOrder + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ReplaceAdjustment]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .adjustment() + * .replacesAdjustmentId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ReplaceAdjustment = + ReplaceAdjustment( + checkRequired("adjustment", adjustment), + checkRequired("replacesAdjustmentId", replacesAdjustmentId), + planPhaseOrder, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ReplaceAdjustment = apply { + if (validated) { + return@apply + } + + adjustment().validate() + replacesAdjustmentId() + planPhaseOrder() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (adjustment.asKnown()?.validity() ?: 0) + + (if (replacesAdjustmentId.asKnown() == null) 0 else 1) + + (if (planPhaseOrder.asKnown() == null) 0 else 1) + + /** The definition of a new adjustment to create and add to the plan. */ + @JsonDeserialize(using = Adjustment.Deserializer::class) + @JsonSerialize(using = Adjustment.Serializer::class) + class Adjustment + private constructor( + private val percentageDiscount: NewPercentageDiscount? = null, + private val usageDiscount: NewUsageDiscount? = null, + private val amountDiscount: NewAmountDiscount? = null, + private val minimum: NewMinimum? = null, + private val maximum: NewMaximum? = null, + private val _json: JsonValue? = null, + ) { + + fun percentageDiscount(): NewPercentageDiscount? = percentageDiscount + + fun usageDiscount(): NewUsageDiscount? = usageDiscount + + fun amountDiscount(): NewAmountDiscount? = amountDiscount + + fun minimum(): NewMinimum? = minimum + + fun maximum(): NewMaximum? = maximum + + fun isPercentageDiscount(): Boolean = percentageDiscount != null + + fun isUsageDiscount(): Boolean = usageDiscount != null + + fun isAmountDiscount(): Boolean = amountDiscount != null + + fun isMinimum(): Boolean = minimum != null + + fun isMaximum(): Boolean = maximum != null + + fun asPercentageDiscount(): NewPercentageDiscount = + percentageDiscount.getOrThrow("percentageDiscount") + + fun asUsageDiscount(): NewUsageDiscount = usageDiscount.getOrThrow("usageDiscount") + + fun asAmountDiscount(): NewAmountDiscount = amountDiscount.getOrThrow("amountDiscount") + + fun asMinimum(): NewMinimum = minimum.getOrThrow("minimum") + + fun asMaximum(): NewMaximum = maximum.getOrThrow("maximum") + + fun _json(): JsonValue? = _json + + fun accept(visitor: Visitor): T = + when { + percentageDiscount != null -> + visitor.visitPercentageDiscount(percentageDiscount) + usageDiscount != null -> visitor.visitUsageDiscount(usageDiscount) + amountDiscount != null -> visitor.visitAmountDiscount(amountDiscount) + minimum != null -> visitor.visitMinimum(minimum) + maximum != null -> visitor.visitMaximum(maximum) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Adjustment = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitPercentageDiscount( + percentageDiscount: NewPercentageDiscount + ) { + percentageDiscount.validate() + } + + override fun visitUsageDiscount(usageDiscount: NewUsageDiscount) { + usageDiscount.validate() + } + + override fun visitAmountDiscount(amountDiscount: NewAmountDiscount) { + amountDiscount.validate() + } + + override fun visitMinimum(minimum: NewMinimum) { + minimum.validate() + } + + override fun visitMaximum(maximum: NewMaximum) { + maximum.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitPercentageDiscount( + percentageDiscount: NewPercentageDiscount + ) = percentageDiscount.validity() + + override fun visitUsageDiscount(usageDiscount: NewUsageDiscount) = + usageDiscount.validity() + + override fun visitAmountDiscount(amountDiscount: NewAmountDiscount) = + amountDiscount.validity() + + override fun visitMinimum(minimum: NewMinimum) = minimum.validity() + + override fun visitMaximum(maximum: NewMaximum) = maximum.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Adjustment && + percentageDiscount == other.percentageDiscount && + usageDiscount == other.usageDiscount && + amountDiscount == other.amountDiscount && + minimum == other.minimum && + maximum == other.maximum + } + + override fun hashCode(): Int = + Objects.hash(percentageDiscount, usageDiscount, amountDiscount, minimum, maximum) + + override fun toString(): String = + when { + percentageDiscount != null -> + "Adjustment{percentageDiscount=$percentageDiscount}" + usageDiscount != null -> "Adjustment{usageDiscount=$usageDiscount}" + amountDiscount != null -> "Adjustment{amountDiscount=$amountDiscount}" + minimum != null -> "Adjustment{minimum=$minimum}" + maximum != null -> "Adjustment{maximum=$maximum}" + _json != null -> "Adjustment{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Adjustment") + } + + companion object { + + fun ofPercentageDiscount(percentageDiscount: NewPercentageDiscount) = + Adjustment(percentageDiscount = percentageDiscount) + + fun ofUsageDiscount(usageDiscount: NewUsageDiscount) = + Adjustment(usageDiscount = usageDiscount) + + fun ofAmountDiscount(amountDiscount: NewAmountDiscount) = + Adjustment(amountDiscount = amountDiscount) + + fun ofMinimum(minimum: NewMinimum) = Adjustment(minimum = minimum) + + fun ofMaximum(maximum: NewMaximum) = Adjustment(maximum = maximum) + } + + /** + * An interface that defines how to map each variant of [Adjustment] to a value of type + * [T]. + */ + interface Visitor { + + fun visitPercentageDiscount(percentageDiscount: NewPercentageDiscount): T + + fun visitUsageDiscount(usageDiscount: NewUsageDiscount): T + + fun visitAmountDiscount(amountDiscount: NewAmountDiscount): T + + fun visitMinimum(minimum: NewMinimum): T + + fun visitMaximum(maximum: NewMaximum): T + + /** + * Maps an unknown variant of [Adjustment] to a value of type [T]. + * + * An instance of [Adjustment] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the + * SDK is unaware of. + * + * @throws OrbInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw OrbInvalidDataException("Unknown Adjustment: $json") + } + } + + internal class Deserializer : BaseDeserializer(Adjustment::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Adjustment { + val json = JsonValue.fromJsonNode(node) + val adjustmentType = json.asObject()?.get("adjustment_type")?.asString() + + when (adjustmentType) { + "percentage_discount" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Adjustment(percentageDiscount = it, _json = json) } + ?: Adjustment(_json = json) + } + "usage_discount" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(usageDiscount = it, _json = json) + } ?: Adjustment(_json = json) + } + "amount_discount" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(amountDiscount = it, _json = json) + } ?: Adjustment(_json = json) + } + "minimum" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(minimum = it, _json = json) + } ?: Adjustment(_json = json) + } + "maximum" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(maximum = it, _json = json) + } ?: Adjustment(_json = json) + } + } + + return Adjustment(_json = json) + } + } + + internal class Serializer : BaseSerializer(Adjustment::class) { + + override fun serialize( + value: Adjustment, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.percentageDiscount != null -> + generator.writeObject(value.percentageDiscount) + value.usageDiscount != null -> generator.writeObject(value.usageDiscount) + value.amountDiscount != null -> generator.writeObject(value.amountDiscount) + value.minimum != null -> generator.writeObject(value.minimum) + value.maximum != null -> generator.writeObject(value.maximum) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Adjustment") + } + } + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ReplaceAdjustment && + adjustment == other.adjustment && + replacesAdjustmentId == other.replacesAdjustmentId && + planPhaseOrder == other.planPhaseOrder && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(adjustment, replacesAdjustmentId, planPhaseOrder, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ReplaceAdjustment{adjustment=$adjustment, replacesAdjustmentId=$replacesAdjustmentId, planPhaseOrder=$planPhaseOrder, additionalProperties=$additionalProperties}" + } + + class ReplacePrice + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val replacesPriceId: JsonField, + private val allocationPrice: JsonField, + private val planPhaseOrder: JsonField, + private val price: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("replaces_price_id") + @ExcludeMissing + replacesPriceId: JsonField = JsonMissing.of(), + @JsonProperty("allocation_price") + @ExcludeMissing + allocationPrice: JsonField = JsonMissing.of(), + @JsonProperty("plan_phase_order") + @ExcludeMissing + planPhaseOrder: JsonField = JsonMissing.of(), + @JsonProperty("price") @ExcludeMissing price: JsonField = JsonMissing.of(), + ) : this(replacesPriceId, allocationPrice, planPhaseOrder, price, mutableMapOf()) + + /** + * The id of the price on the plan to replace in the plan. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun replacesPriceId(): String = replacesPriceId.getRequired("replaces_price_id") + + /** + * The allocation price to add to the plan. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun allocationPrice(): NewAllocationPrice? = allocationPrice.getNullable("allocation_price") + + /** + * The phase to replace this price from. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun planPhaseOrder(): Long? = planPhaseOrder.getNullable("plan_phase_order") + + /** + * New plan price request body params. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun price(): Price? = price.getNullable("price") + + /** + * Returns the raw JSON value of [replacesPriceId]. + * + * Unlike [replacesPriceId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("replaces_price_id") + @ExcludeMissing + fun _replacesPriceId(): JsonField = replacesPriceId + + /** + * Returns the raw JSON value of [allocationPrice]. + * + * Unlike [allocationPrice], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("allocation_price") + @ExcludeMissing + fun _allocationPrice(): JsonField = allocationPrice + + /** + * Returns the raw JSON value of [planPhaseOrder]. + * + * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder + + /** + * Returns the raw JSON value of [price]. + * + * Unlike [price], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("price") @ExcludeMissing fun _price(): JsonField = price + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ReplacePrice]. + * + * The following fields are required: + * ```kotlin + * .replacesPriceId() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [ReplacePrice]. */ + class Builder internal constructor() { + + private var replacesPriceId: JsonField? = null + private var allocationPrice: JsonField = JsonMissing.of() + private var planPhaseOrder: JsonField = JsonMissing.of() + private var price: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(replacePrice: ReplacePrice) = apply { + replacesPriceId = replacePrice.replacesPriceId + allocationPrice = replacePrice.allocationPrice + planPhaseOrder = replacePrice.planPhaseOrder + price = replacePrice.price + additionalProperties = replacePrice.additionalProperties.toMutableMap() + } + + /** The id of the price on the plan to replace in the plan. */ + fun replacesPriceId(replacesPriceId: String) = + replacesPriceId(JsonField.of(replacesPriceId)) + + /** + * Sets [Builder.replacesPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.replacesPriceId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun replacesPriceId(replacesPriceId: JsonField) = apply { + this.replacesPriceId = replacesPriceId + } + + /** The allocation price to add to the plan. */ + fun allocationPrice(allocationPrice: NewAllocationPrice?) = + allocationPrice(JsonField.ofNullable(allocationPrice)) + + /** + * Sets [Builder.allocationPrice] to an arbitrary JSON value. + * + * You should usually call [Builder.allocationPrice] with a well-typed + * [NewAllocationPrice] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun allocationPrice(allocationPrice: JsonField) = apply { + this.allocationPrice = allocationPrice + } + + /** The phase to replace this price from. */ + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + + /** + * Alias for [Builder.planPhaseOrder]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + + /** + * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. + * + * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun planPhaseOrder(planPhaseOrder: JsonField) = apply { + this.planPhaseOrder = planPhaseOrder + } + + /** New plan price request body params. */ + fun price(price: Price?) = price(JsonField.ofNullable(price)) + + /** + * Sets [Builder.price] to an arbitrary JSON value. + * + * You should usually call [Builder.price] with a well-typed [Price] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun price(price: JsonField) = apply { this.price = price } + + /** Alias for calling [price] with `Price.ofUnit(unit)`. */ + fun price(unit: NewPlanUnitPrice) = price(Price.ofUnit(unit)) + + /** Alias for calling [price] with `Price.ofTiered(tiered)`. */ + fun price(tiered: NewPlanTieredPrice) = price(Price.ofTiered(tiered)) + + /** Alias for calling [price] with `Price.ofBulk(bulk)`. */ + fun price(bulk: NewPlanBulkPrice) = price(Price.ofBulk(bulk)) + + /** Alias for calling [price] with `Price.ofBulkWithFilters(bulkWithFilters)`. */ + fun price(bulkWithFilters: Price.BulkWithFilters) = + price(Price.ofBulkWithFilters(bulkWithFilters)) + + /** Alias for calling [price] with `Price.ofPackage(package_)`. */ + fun price(package_: NewPlanPackagePrice) = price(Price.ofPackage(package_)) + + /** Alias for calling [price] with `Price.ofMatrix(matrix)`. */ + fun price(matrix: NewPlanMatrixPrice) = price(Price.ofMatrix(matrix)) + + /** + * Alias for calling [price] with `Price.ofThresholdTotalAmount(thresholdTotalAmount)`. + */ + fun price(thresholdTotalAmount: NewPlanThresholdTotalAmountPrice) = + price(Price.ofThresholdTotalAmount(thresholdTotalAmount)) + + /** Alias for calling [price] with `Price.ofTieredPackage(tieredPackage)`. */ + fun price(tieredPackage: NewPlanTieredPackagePrice) = + price(Price.ofTieredPackage(tieredPackage)) + + /** Alias for calling [price] with `Price.ofTieredWithMinimum(tieredWithMinimum)`. */ + fun price(tieredWithMinimum: NewPlanTieredWithMinimumPrice) = + price(Price.ofTieredWithMinimum(tieredWithMinimum)) + + /** Alias for calling [price] with `Price.ofGroupedTiered(groupedTiered)`. */ + fun price(groupedTiered: NewPlanGroupedTieredPrice) = + price(Price.ofGroupedTiered(groupedTiered)) + + /** + * Alias for calling [price] with + * `Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)`. + */ + fun price(tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice) = + price(Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)) + + /** + * Alias for calling [price] with + * `Price.ofPackageWithAllocation(packageWithAllocation)`. + */ + fun price(packageWithAllocation: NewPlanPackageWithAllocationPrice) = + price(Price.ofPackageWithAllocation(packageWithAllocation)) + + /** Alias for calling [price] with `Price.ofUnitWithPercent(unitWithPercent)`. */ + fun price(unitWithPercent: NewPlanUnitWithPercentPrice) = + price(Price.ofUnitWithPercent(unitWithPercent)) + + /** + * Alias for calling [price] with `Price.ofMatrixWithAllocation(matrixWithAllocation)`. + */ + fun price(matrixWithAllocation: NewPlanMatrixWithAllocationPrice) = + price(Price.ofMatrixWithAllocation(matrixWithAllocation)) + + /** + * Alias for calling [price] with `Price.ofTieredWithProration(tieredWithProration)`. + */ + fun price(tieredWithProration: Price.TieredWithProration) = + price(Price.ofTieredWithProration(tieredWithProration)) + + /** Alias for calling [price] with `Price.ofUnitWithProration(unitWithProration)`. */ + fun price(unitWithProration: NewPlanUnitWithProrationPrice) = + price(Price.ofUnitWithProration(unitWithProration)) + + /** Alias for calling [price] with `Price.ofGroupedAllocation(groupedAllocation)`. */ + fun price(groupedAllocation: NewPlanGroupedAllocationPrice) = + price(Price.ofGroupedAllocation(groupedAllocation)) + + /** Alias for calling [price] with `Price.ofBulkWithProration(bulkWithProration)`. */ + fun price(bulkWithProration: NewPlanBulkWithProrationPrice) = + price(Price.ofBulkWithProration(bulkWithProration)) + + /** + * Alias for calling [price] with + * `Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)`. + */ + fun price(groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice) = + price(Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)) + + /** + * Alias for calling [price] with + * `Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)`. + */ + fun price(groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice) = + price(Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)) + + /** + * Alias for calling [price] with + * `Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)`. + */ + fun price(groupedWithMinMaxThresholds: Price.GroupedWithMinMaxThresholds) = + price(Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)) + + /** + * Alias for calling [price] with + * `Price.ofMatrixWithDisplayName(matrixWithDisplayName)`. + */ + fun price(matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice) = + price(Price.ofMatrixWithDisplayName(matrixWithDisplayName)) + + /** + * Alias for calling [price] with `Price.ofGroupedTieredPackage(groupedTieredPackage)`. + */ + fun price(groupedTieredPackage: NewPlanGroupedTieredPackagePrice) = + price(Price.ofGroupedTieredPackage(groupedTieredPackage)) + + /** + * Alias for calling [price] with + * `Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)`. + */ + fun price(maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice) = + price(Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)) + + /** + * Alias for calling [price] with + * `Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)`. + */ + fun price(scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice) = + price(Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)) + + /** + * Alias for calling [price] with + * `Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)`. + */ + fun price( + scalableMatrixWithTieredPricing: NewPlanScalableMatrixWithTieredPricingPrice + ) = price(Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)) + + /** + * Alias for calling [price] with + * `Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)`. + */ + fun price(cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice) = + price(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) + + /** Alias for calling [price] with `Price.ofMinimum(minimum)`. */ + fun price(minimum: NewPlanMinimumCompositePrice) = price(Price.ofMinimum(minimum)) + + /** Alias for calling [price] with `Price.ofPercent(percent)`. */ + fun price(percent: Price.Percent) = price(Price.ofPercent(percent)) + + /** Alias for calling [price] with `Price.ofEventOutput(eventOutput)`. */ + fun price(eventOutput: Price.EventOutput) = price(Price.ofEventOutput(eventOutput)) + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ReplacePrice]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .replacesPriceId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ReplacePrice = + ReplacePrice( + checkRequired("replacesPriceId", replacesPriceId), + allocationPrice, + planPhaseOrder, + price, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ReplacePrice = apply { + if (validated) { + return@apply + } + + replacesPriceId() + allocationPrice()?.validate() + planPhaseOrder() + price()?.validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (replacesPriceId.asKnown() == null) 0 else 1) + + (allocationPrice.asKnown()?.validity() ?: 0) + + (if (planPhaseOrder.asKnown() == null) 0 else 1) + + (price.asKnown()?.validity() ?: 0) + + /** New plan price request body params. */ + @JsonDeserialize(using = Price.Deserializer::class) + @JsonSerialize(using = Price.Serializer::class) + class Price + private constructor( + private val unit: NewPlanUnitPrice? = null, + private val tiered: NewPlanTieredPrice? = null, + private val bulk: NewPlanBulkPrice? = null, + private val bulkWithFilters: BulkWithFilters? = null, + private val package_: NewPlanPackagePrice? = null, + private val matrix: NewPlanMatrixPrice? = null, + private val thresholdTotalAmount: NewPlanThresholdTotalAmountPrice? = null, + private val tieredPackage: NewPlanTieredPackagePrice? = null, + private val tieredWithMinimum: NewPlanTieredWithMinimumPrice? = null, + private val groupedTiered: NewPlanGroupedTieredPrice? = null, + private val tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice? = null, + private val packageWithAllocation: NewPlanPackageWithAllocationPrice? = null, + private val unitWithPercent: NewPlanUnitWithPercentPrice? = null, + private val matrixWithAllocation: NewPlanMatrixWithAllocationPrice? = null, + private val tieredWithProration: TieredWithProration? = null, + private val unitWithProration: NewPlanUnitWithProrationPrice? = null, + private val groupedAllocation: NewPlanGroupedAllocationPrice? = null, + private val bulkWithProration: NewPlanBulkWithProrationPrice? = null, + private val groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice? = null, + private val groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice? = null, + private val groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds? = null, + private val matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice? = null, + private val groupedTieredPackage: NewPlanGroupedTieredPackagePrice? = null, + private val maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice? = null, + private val scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice? = + null, + private val scalableMatrixWithTieredPricing: + NewPlanScalableMatrixWithTieredPricingPrice? = + null, + private val cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice? = null, + private val minimum: NewPlanMinimumCompositePrice? = null, + private val percent: Percent? = null, + private val eventOutput: EventOutput? = null, + private val _json: JsonValue? = null, + ) { + + fun unit(): NewPlanUnitPrice? = unit + + fun tiered(): NewPlanTieredPrice? = tiered + + fun bulk(): NewPlanBulkPrice? = bulk + + fun bulkWithFilters(): BulkWithFilters? = bulkWithFilters + + fun package_(): NewPlanPackagePrice? = package_ + + fun matrix(): NewPlanMatrixPrice? = matrix + + fun thresholdTotalAmount(): NewPlanThresholdTotalAmountPrice? = thresholdTotalAmount + + fun tieredPackage(): NewPlanTieredPackagePrice? = tieredPackage + + fun tieredWithMinimum(): NewPlanTieredWithMinimumPrice? = tieredWithMinimum + + fun groupedTiered(): NewPlanGroupedTieredPrice? = groupedTiered + + fun tieredPackageWithMinimum(): NewPlanTieredPackageWithMinimumPrice? = + tieredPackageWithMinimum + + fun packageWithAllocation(): NewPlanPackageWithAllocationPrice? = packageWithAllocation + + fun unitWithPercent(): NewPlanUnitWithPercentPrice? = unitWithPercent + + fun matrixWithAllocation(): NewPlanMatrixWithAllocationPrice? = matrixWithAllocation + + fun tieredWithProration(): TieredWithProration? = tieredWithProration + + fun unitWithProration(): NewPlanUnitWithProrationPrice? = unitWithProration + + fun groupedAllocation(): NewPlanGroupedAllocationPrice? = groupedAllocation + + fun bulkWithProration(): NewPlanBulkWithProrationPrice? = bulkWithProration + + fun groupedWithProratedMinimum(): NewPlanGroupedWithProratedMinimumPrice? = + groupedWithProratedMinimum + + fun groupedWithMeteredMinimum(): NewPlanGroupedWithMeteredMinimumPrice? = + groupedWithMeteredMinimum + + fun groupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds? = + groupedWithMinMaxThresholds + + fun matrixWithDisplayName(): NewPlanMatrixWithDisplayNamePrice? = matrixWithDisplayName + + fun groupedTieredPackage(): NewPlanGroupedTieredPackagePrice? = groupedTieredPackage + + fun maxGroupTieredPackage(): NewPlanMaxGroupTieredPackagePrice? = maxGroupTieredPackage + + fun scalableMatrixWithUnitPricing(): NewPlanScalableMatrixWithUnitPricingPrice? = + scalableMatrixWithUnitPricing + + fun scalableMatrixWithTieredPricing(): NewPlanScalableMatrixWithTieredPricingPrice? = + scalableMatrixWithTieredPricing + + fun cumulativeGroupedBulk(): NewPlanCumulativeGroupedBulkPrice? = cumulativeGroupedBulk + + fun minimum(): NewPlanMinimumCompositePrice? = minimum + + fun percent(): Percent? = percent + + fun eventOutput(): EventOutput? = eventOutput + + fun isUnit(): Boolean = unit != null + + fun isTiered(): Boolean = tiered != null + + fun isBulk(): Boolean = bulk != null + + fun isBulkWithFilters(): Boolean = bulkWithFilters != null + + fun isPackage(): Boolean = package_ != null + + fun isMatrix(): Boolean = matrix != null + + fun isThresholdTotalAmount(): Boolean = thresholdTotalAmount != null + + fun isTieredPackage(): Boolean = tieredPackage != null + + fun isTieredWithMinimum(): Boolean = tieredWithMinimum != null + + fun isGroupedTiered(): Boolean = groupedTiered != null + + fun isTieredPackageWithMinimum(): Boolean = tieredPackageWithMinimum != null + + fun isPackageWithAllocation(): Boolean = packageWithAllocation != null + + fun isUnitWithPercent(): Boolean = unitWithPercent != null + + fun isMatrixWithAllocation(): Boolean = matrixWithAllocation != null + + fun isTieredWithProration(): Boolean = tieredWithProration != null + + fun isUnitWithProration(): Boolean = unitWithProration != null + + fun isGroupedAllocation(): Boolean = groupedAllocation != null + + fun isBulkWithProration(): Boolean = bulkWithProration != null + + fun isGroupedWithProratedMinimum(): Boolean = groupedWithProratedMinimum != null + + fun isGroupedWithMeteredMinimum(): Boolean = groupedWithMeteredMinimum != null + + fun isGroupedWithMinMaxThresholds(): Boolean = groupedWithMinMaxThresholds != null + + fun isMatrixWithDisplayName(): Boolean = matrixWithDisplayName != null + + fun isGroupedTieredPackage(): Boolean = groupedTieredPackage != null + + fun isMaxGroupTieredPackage(): Boolean = maxGroupTieredPackage != null + + fun isScalableMatrixWithUnitPricing(): Boolean = scalableMatrixWithUnitPricing != null + + fun isScalableMatrixWithTieredPricing(): Boolean = + scalableMatrixWithTieredPricing != null + + fun isCumulativeGroupedBulk(): Boolean = cumulativeGroupedBulk != null + + fun isMinimum(): Boolean = minimum != null + + fun isPercent(): Boolean = percent != null + + fun isEventOutput(): Boolean = eventOutput != null + + fun asUnit(): NewPlanUnitPrice = unit.getOrThrow("unit") + + fun asTiered(): NewPlanTieredPrice = tiered.getOrThrow("tiered") + + fun asBulk(): NewPlanBulkPrice = bulk.getOrThrow("bulk") + + fun asBulkWithFilters(): BulkWithFilters = bulkWithFilters.getOrThrow("bulkWithFilters") + + fun asPackage(): NewPlanPackagePrice = package_.getOrThrow("package_") + + fun asMatrix(): NewPlanMatrixPrice = matrix.getOrThrow("matrix") + + fun asThresholdTotalAmount(): NewPlanThresholdTotalAmountPrice = + thresholdTotalAmount.getOrThrow("thresholdTotalAmount") + + fun asTieredPackage(): NewPlanTieredPackagePrice = + tieredPackage.getOrThrow("tieredPackage") + + fun asTieredWithMinimum(): NewPlanTieredWithMinimumPrice = + tieredWithMinimum.getOrThrow("tieredWithMinimum") + + fun asGroupedTiered(): NewPlanGroupedTieredPrice = + groupedTiered.getOrThrow("groupedTiered") + + fun asTieredPackageWithMinimum(): NewPlanTieredPackageWithMinimumPrice = + tieredPackageWithMinimum.getOrThrow("tieredPackageWithMinimum") + + fun asPackageWithAllocation(): NewPlanPackageWithAllocationPrice = + packageWithAllocation.getOrThrow("packageWithAllocation") + + fun asUnitWithPercent(): NewPlanUnitWithPercentPrice = + unitWithPercent.getOrThrow("unitWithPercent") + + fun asMatrixWithAllocation(): NewPlanMatrixWithAllocationPrice = + matrixWithAllocation.getOrThrow("matrixWithAllocation") + + fun asTieredWithProration(): TieredWithProration = + tieredWithProration.getOrThrow("tieredWithProration") + + fun asUnitWithProration(): NewPlanUnitWithProrationPrice = + unitWithProration.getOrThrow("unitWithProration") + + fun asGroupedAllocation(): NewPlanGroupedAllocationPrice = + groupedAllocation.getOrThrow("groupedAllocation") + + fun asBulkWithProration(): NewPlanBulkWithProrationPrice = + bulkWithProration.getOrThrow("bulkWithProration") + + fun asGroupedWithProratedMinimum(): NewPlanGroupedWithProratedMinimumPrice = + groupedWithProratedMinimum.getOrThrow("groupedWithProratedMinimum") + + fun asGroupedWithMeteredMinimum(): NewPlanGroupedWithMeteredMinimumPrice = + groupedWithMeteredMinimum.getOrThrow("groupedWithMeteredMinimum") + + fun asGroupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds = + groupedWithMinMaxThresholds.getOrThrow("groupedWithMinMaxThresholds") + + fun asMatrixWithDisplayName(): NewPlanMatrixWithDisplayNamePrice = + matrixWithDisplayName.getOrThrow("matrixWithDisplayName") + + fun asGroupedTieredPackage(): NewPlanGroupedTieredPackagePrice = + groupedTieredPackage.getOrThrow("groupedTieredPackage") + + fun asMaxGroupTieredPackage(): NewPlanMaxGroupTieredPackagePrice = + maxGroupTieredPackage.getOrThrow("maxGroupTieredPackage") + + fun asScalableMatrixWithUnitPricing(): NewPlanScalableMatrixWithUnitPricingPrice = + scalableMatrixWithUnitPricing.getOrThrow("scalableMatrixWithUnitPricing") + + fun asScalableMatrixWithTieredPricing(): NewPlanScalableMatrixWithTieredPricingPrice = + scalableMatrixWithTieredPricing.getOrThrow("scalableMatrixWithTieredPricing") + + fun asCumulativeGroupedBulk(): NewPlanCumulativeGroupedBulkPrice = + cumulativeGroupedBulk.getOrThrow("cumulativeGroupedBulk") + + fun asMinimum(): NewPlanMinimumCompositePrice = minimum.getOrThrow("minimum") + + fun asPercent(): Percent = percent.getOrThrow("percent") + + fun asEventOutput(): EventOutput = eventOutput.getOrThrow("eventOutput") + + fun _json(): JsonValue? = _json + + fun accept(visitor: Visitor): T = + when { + unit != null -> visitor.visitUnit(unit) + tiered != null -> visitor.visitTiered(tiered) + bulk != null -> visitor.visitBulk(bulk) + bulkWithFilters != null -> visitor.visitBulkWithFilters(bulkWithFilters) + package_ != null -> visitor.visitPackage(package_) + matrix != null -> visitor.visitMatrix(matrix) + thresholdTotalAmount != null -> + visitor.visitThresholdTotalAmount(thresholdTotalAmount) + tieredPackage != null -> visitor.visitTieredPackage(tieredPackage) + tieredWithMinimum != null -> visitor.visitTieredWithMinimum(tieredWithMinimum) + groupedTiered != null -> visitor.visitGroupedTiered(groupedTiered) + tieredPackageWithMinimum != null -> + visitor.visitTieredPackageWithMinimum(tieredPackageWithMinimum) + packageWithAllocation != null -> + visitor.visitPackageWithAllocation(packageWithAllocation) + unitWithPercent != null -> visitor.visitUnitWithPercent(unitWithPercent) + matrixWithAllocation != null -> + visitor.visitMatrixWithAllocation(matrixWithAllocation) + tieredWithProration != null -> + visitor.visitTieredWithProration(tieredWithProration) + unitWithProration != null -> visitor.visitUnitWithProration(unitWithProration) + groupedAllocation != null -> visitor.visitGroupedAllocation(groupedAllocation) + bulkWithProration != null -> visitor.visitBulkWithProration(bulkWithProration) + groupedWithProratedMinimum != null -> + visitor.visitGroupedWithProratedMinimum(groupedWithProratedMinimum) + groupedWithMeteredMinimum != null -> + visitor.visitGroupedWithMeteredMinimum(groupedWithMeteredMinimum) + groupedWithMinMaxThresholds != null -> + visitor.visitGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds) + matrixWithDisplayName != null -> + visitor.visitMatrixWithDisplayName(matrixWithDisplayName) + groupedTieredPackage != null -> + visitor.visitGroupedTieredPackage(groupedTieredPackage) + maxGroupTieredPackage != null -> + visitor.visitMaxGroupTieredPackage(maxGroupTieredPackage) + scalableMatrixWithUnitPricing != null -> + visitor.visitScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing) + scalableMatrixWithTieredPricing != null -> + visitor.visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing + ) + cumulativeGroupedBulk != null -> + visitor.visitCumulativeGroupedBulk(cumulativeGroupedBulk) + minimum != null -> visitor.visitMinimum(minimum) + percent != null -> visitor.visitPercent(percent) + eventOutput != null -> visitor.visitEventOutput(eventOutput) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Price = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitUnit(unit: NewPlanUnitPrice) { + unit.validate() + } + + override fun visitTiered(tiered: NewPlanTieredPrice) { + tiered.validate() + } + + override fun visitBulk(bulk: NewPlanBulkPrice) { + bulk.validate() + } + + override fun visitBulkWithFilters(bulkWithFilters: BulkWithFilters) { + bulkWithFilters.validate() + } + + override fun visitPackage(package_: NewPlanPackagePrice) { + package_.validate() + } + + override fun visitMatrix(matrix: NewPlanMatrixPrice) { + matrix.validate() + } + + override fun visitThresholdTotalAmount( + thresholdTotalAmount: NewPlanThresholdTotalAmountPrice + ) { + thresholdTotalAmount.validate() + } + + override fun visitTieredPackage(tieredPackage: NewPlanTieredPackagePrice) { + tieredPackage.validate() + } + + override fun visitTieredWithMinimum( + tieredWithMinimum: NewPlanTieredWithMinimumPrice + ) { + tieredWithMinimum.validate() + } + + override fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) { + groupedTiered.validate() + } + + override fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice + ) { + tieredPackageWithMinimum.validate() + } + + override fun visitPackageWithAllocation( + packageWithAllocation: NewPlanPackageWithAllocationPrice + ) { + packageWithAllocation.validate() + } + + override fun visitUnitWithPercent( + unitWithPercent: NewPlanUnitWithPercentPrice + ) { + unitWithPercent.validate() + } + + override fun visitMatrixWithAllocation( + matrixWithAllocation: NewPlanMatrixWithAllocationPrice + ) { + matrixWithAllocation.validate() + } + + override fun visitTieredWithProration( + tieredWithProration: TieredWithProration + ) { + tieredWithProration.validate() + } + + override fun visitUnitWithProration( + unitWithProration: NewPlanUnitWithProrationPrice + ) { + unitWithProration.validate() + } + + override fun visitGroupedAllocation( + groupedAllocation: NewPlanGroupedAllocationPrice + ) { + groupedAllocation.validate() + } + + override fun visitBulkWithProration( + bulkWithProration: NewPlanBulkWithProrationPrice + ) { + bulkWithProration.validate() + } + + override fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice + ) { + groupedWithProratedMinimum.validate() + } + + override fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice + ) { + groupedWithMeteredMinimum.validate() + } + + override fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) { + groupedWithMinMaxThresholds.validate() + } + + override fun visitMatrixWithDisplayName( + matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice + ) { + matrixWithDisplayName.validate() + } + + override fun visitGroupedTieredPackage( + groupedTieredPackage: NewPlanGroupedTieredPackagePrice + ) { + groupedTieredPackage.validate() + } + + override fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice + ) { + maxGroupTieredPackage.validate() + } + + override fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice + ) { + scalableMatrixWithUnitPricing.validate() + } + + override fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: + NewPlanScalableMatrixWithTieredPricingPrice + ) { + scalableMatrixWithTieredPricing.validate() + } + + override fun visitCumulativeGroupedBulk( + cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice + ) { + cumulativeGroupedBulk.validate() + } + + override fun visitMinimum(minimum: NewPlanMinimumCompositePrice) { + minimum.validate() + } + + override fun visitPercent(percent: Percent) { + percent.validate() + } + + override fun visitEventOutput(eventOutput: EventOutput) { + eventOutput.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitUnit(unit: NewPlanUnitPrice) = unit.validity() + + override fun visitTiered(tiered: NewPlanTieredPrice) = tiered.validity() + + override fun visitBulk(bulk: NewPlanBulkPrice) = bulk.validity() + + override fun visitBulkWithFilters(bulkWithFilters: BulkWithFilters) = + bulkWithFilters.validity() + + override fun visitPackage(package_: NewPlanPackagePrice) = + package_.validity() + + override fun visitMatrix(matrix: NewPlanMatrixPrice) = matrix.validity() + + override fun visitThresholdTotalAmount( + thresholdTotalAmount: NewPlanThresholdTotalAmountPrice + ) = thresholdTotalAmount.validity() + + override fun visitTieredPackage(tieredPackage: NewPlanTieredPackagePrice) = + tieredPackage.validity() + + override fun visitTieredWithMinimum( + tieredWithMinimum: NewPlanTieredWithMinimumPrice + ) = tieredWithMinimum.validity() + + override fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) = + groupedTiered.validity() + + override fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice + ) = tieredPackageWithMinimum.validity() + + override fun visitPackageWithAllocation( + packageWithAllocation: NewPlanPackageWithAllocationPrice + ) = packageWithAllocation.validity() + + override fun visitUnitWithPercent( + unitWithPercent: NewPlanUnitWithPercentPrice + ) = unitWithPercent.validity() + + override fun visitMatrixWithAllocation( + matrixWithAllocation: NewPlanMatrixWithAllocationPrice + ) = matrixWithAllocation.validity() + + override fun visitTieredWithProration( + tieredWithProration: TieredWithProration + ) = tieredWithProration.validity() + + override fun visitUnitWithProration( + unitWithProration: NewPlanUnitWithProrationPrice + ) = unitWithProration.validity() + + override fun visitGroupedAllocation( + groupedAllocation: NewPlanGroupedAllocationPrice + ) = groupedAllocation.validity() + + override fun visitBulkWithProration( + bulkWithProration: NewPlanBulkWithProrationPrice + ) = bulkWithProration.validity() + + override fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice + ) = groupedWithProratedMinimum.validity() + + override fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice + ) = groupedWithMeteredMinimum.validity() + + override fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) = groupedWithMinMaxThresholds.validity() + + override fun visitMatrixWithDisplayName( + matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice + ) = matrixWithDisplayName.validity() + + override fun visitGroupedTieredPackage( + groupedTieredPackage: NewPlanGroupedTieredPackagePrice + ) = groupedTieredPackage.validity() + + override fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice + ) = maxGroupTieredPackage.validity() + + override fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice + ) = scalableMatrixWithUnitPricing.validity() + + override fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: + NewPlanScalableMatrixWithTieredPricingPrice + ) = scalableMatrixWithTieredPricing.validity() + + override fun visitCumulativeGroupedBulk( + cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice + ) = cumulativeGroupedBulk.validity() + + override fun visitMinimum(minimum: NewPlanMinimumCompositePrice) = + minimum.validity() + + override fun visitPercent(percent: Percent) = percent.validity() + + override fun visitEventOutput(eventOutput: EventOutput) = + eventOutput.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Price && + unit == other.unit && + tiered == other.tiered && + bulk == other.bulk && + bulkWithFilters == other.bulkWithFilters && + package_ == other.package_ && + matrix == other.matrix && + thresholdTotalAmount == other.thresholdTotalAmount && + tieredPackage == other.tieredPackage && + tieredWithMinimum == other.tieredWithMinimum && + groupedTiered == other.groupedTiered && + tieredPackageWithMinimum == other.tieredPackageWithMinimum && + packageWithAllocation == other.packageWithAllocation && + unitWithPercent == other.unitWithPercent && + matrixWithAllocation == other.matrixWithAllocation && + tieredWithProration == other.tieredWithProration && + unitWithProration == other.unitWithProration && + groupedAllocation == other.groupedAllocation && + bulkWithProration == other.bulkWithProration && + groupedWithProratedMinimum == other.groupedWithProratedMinimum && + groupedWithMeteredMinimum == other.groupedWithMeteredMinimum && + groupedWithMinMaxThresholds == other.groupedWithMinMaxThresholds && + matrixWithDisplayName == other.matrixWithDisplayName && + groupedTieredPackage == other.groupedTieredPackage && + maxGroupTieredPackage == other.maxGroupTieredPackage && + scalableMatrixWithUnitPricing == other.scalableMatrixWithUnitPricing && + scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && + cumulativeGroupedBulk == other.cumulativeGroupedBulk && + minimum == other.minimum && + percent == other.percent && + eventOutput == other.eventOutput + } + + override fun hashCode(): Int = + Objects.hash( + unit, + tiered, + bulk, + bulkWithFilters, + package_, + matrix, + thresholdTotalAmount, + tieredPackage, + tieredWithMinimum, + groupedTiered, + tieredPackageWithMinimum, + packageWithAllocation, + unitWithPercent, + matrixWithAllocation, + tieredWithProration, + unitWithProration, + groupedAllocation, + bulkWithProration, + groupedWithProratedMinimum, + groupedWithMeteredMinimum, + groupedWithMinMaxThresholds, + matrixWithDisplayName, + groupedTieredPackage, + maxGroupTieredPackage, + scalableMatrixWithUnitPricing, + scalableMatrixWithTieredPricing, + cumulativeGroupedBulk, + minimum, + percent, + eventOutput, + ) + + override fun toString(): String = + when { + unit != null -> "Price{unit=$unit}" + tiered != null -> "Price{tiered=$tiered}" + bulk != null -> "Price{bulk=$bulk}" + bulkWithFilters != null -> "Price{bulkWithFilters=$bulkWithFilters}" + package_ != null -> "Price{package_=$package_}" + matrix != null -> "Price{matrix=$matrix}" + thresholdTotalAmount != null -> + "Price{thresholdTotalAmount=$thresholdTotalAmount}" + tieredPackage != null -> "Price{tieredPackage=$tieredPackage}" + tieredWithMinimum != null -> "Price{tieredWithMinimum=$tieredWithMinimum}" + groupedTiered != null -> "Price{groupedTiered=$groupedTiered}" + tieredPackageWithMinimum != null -> + "Price{tieredPackageWithMinimum=$tieredPackageWithMinimum}" + packageWithAllocation != null -> + "Price{packageWithAllocation=$packageWithAllocation}" + unitWithPercent != null -> "Price{unitWithPercent=$unitWithPercent}" + matrixWithAllocation != null -> + "Price{matrixWithAllocation=$matrixWithAllocation}" + tieredWithProration != null -> "Price{tieredWithProration=$tieredWithProration}" + unitWithProration != null -> "Price{unitWithProration=$unitWithProration}" + groupedAllocation != null -> "Price{groupedAllocation=$groupedAllocation}" + bulkWithProration != null -> "Price{bulkWithProration=$bulkWithProration}" + groupedWithProratedMinimum != null -> + "Price{groupedWithProratedMinimum=$groupedWithProratedMinimum}" + groupedWithMeteredMinimum != null -> + "Price{groupedWithMeteredMinimum=$groupedWithMeteredMinimum}" + groupedWithMinMaxThresholds != null -> + "Price{groupedWithMinMaxThresholds=$groupedWithMinMaxThresholds}" + matrixWithDisplayName != null -> + "Price{matrixWithDisplayName=$matrixWithDisplayName}" + groupedTieredPackage != null -> + "Price{groupedTieredPackage=$groupedTieredPackage}" + maxGroupTieredPackage != null -> + "Price{maxGroupTieredPackage=$maxGroupTieredPackage}" + scalableMatrixWithUnitPricing != null -> + "Price{scalableMatrixWithUnitPricing=$scalableMatrixWithUnitPricing}" + scalableMatrixWithTieredPricing != null -> + "Price{scalableMatrixWithTieredPricing=$scalableMatrixWithTieredPricing}" + cumulativeGroupedBulk != null -> + "Price{cumulativeGroupedBulk=$cumulativeGroupedBulk}" + minimum != null -> "Price{minimum=$minimum}" + percent != null -> "Price{percent=$percent}" + eventOutput != null -> "Price{eventOutput=$eventOutput}" + _json != null -> "Price{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Price") + } + + companion object { + + fun ofUnit(unit: NewPlanUnitPrice) = Price(unit = unit) + + fun ofTiered(tiered: NewPlanTieredPrice) = Price(tiered = tiered) + + fun ofBulk(bulk: NewPlanBulkPrice) = Price(bulk = bulk) + + fun ofBulkWithFilters(bulkWithFilters: BulkWithFilters) = + Price(bulkWithFilters = bulkWithFilters) + + fun ofPackage(package_: NewPlanPackagePrice) = Price(package_ = package_) + + fun ofMatrix(matrix: NewPlanMatrixPrice) = Price(matrix = matrix) + + fun ofThresholdTotalAmount(thresholdTotalAmount: NewPlanThresholdTotalAmountPrice) = + Price(thresholdTotalAmount = thresholdTotalAmount) + + fun ofTieredPackage(tieredPackage: NewPlanTieredPackagePrice) = + Price(tieredPackage = tieredPackage) + + fun ofTieredWithMinimum(tieredWithMinimum: NewPlanTieredWithMinimumPrice) = + Price(tieredWithMinimum = tieredWithMinimum) + + fun ofGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) = + Price(groupedTiered = groupedTiered) + + fun ofTieredPackageWithMinimum( + tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice + ) = Price(tieredPackageWithMinimum = tieredPackageWithMinimum) + + fun ofPackageWithAllocation( + packageWithAllocation: NewPlanPackageWithAllocationPrice + ) = Price(packageWithAllocation = packageWithAllocation) + + fun ofUnitWithPercent(unitWithPercent: NewPlanUnitWithPercentPrice) = + Price(unitWithPercent = unitWithPercent) + + fun ofMatrixWithAllocation(matrixWithAllocation: NewPlanMatrixWithAllocationPrice) = + Price(matrixWithAllocation = matrixWithAllocation) + + fun ofTieredWithProration(tieredWithProration: TieredWithProration) = + Price(tieredWithProration = tieredWithProration) + + fun ofUnitWithProration(unitWithProration: NewPlanUnitWithProrationPrice) = + Price(unitWithProration = unitWithProration) + + fun ofGroupedAllocation(groupedAllocation: NewPlanGroupedAllocationPrice) = + Price(groupedAllocation = groupedAllocation) + + fun ofBulkWithProration(bulkWithProration: NewPlanBulkWithProrationPrice) = + Price(bulkWithProration = bulkWithProration) + + fun ofGroupedWithProratedMinimum( + groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice + ) = Price(groupedWithProratedMinimum = groupedWithProratedMinimum) + + fun ofGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice + ) = Price(groupedWithMeteredMinimum = groupedWithMeteredMinimum) + + fun ofGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) = Price(groupedWithMinMaxThresholds = groupedWithMinMaxThresholds) + + fun ofMatrixWithDisplayName( + matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice + ) = Price(matrixWithDisplayName = matrixWithDisplayName) + + fun ofGroupedTieredPackage(groupedTieredPackage: NewPlanGroupedTieredPackagePrice) = + Price(groupedTieredPackage = groupedTieredPackage) + + fun ofMaxGroupTieredPackage( + maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice + ) = Price(maxGroupTieredPackage = maxGroupTieredPackage) + + fun ofScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice + ) = Price(scalableMatrixWithUnitPricing = scalableMatrixWithUnitPricing) + + fun ofScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: NewPlanScalableMatrixWithTieredPricingPrice + ) = Price(scalableMatrixWithTieredPricing = scalableMatrixWithTieredPricing) + + fun ofCumulativeGroupedBulk( + cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice + ) = Price(cumulativeGroupedBulk = cumulativeGroupedBulk) + + fun ofMinimum(minimum: NewPlanMinimumCompositePrice) = Price(minimum = minimum) + + fun ofPercent(percent: Percent) = Price(percent = percent) + + fun ofEventOutput(eventOutput: EventOutput) = Price(eventOutput = eventOutput) + } + + /** + * An interface that defines how to map each variant of [Price] to a value of type [T]. + */ + interface Visitor { + + fun visitUnit(unit: NewPlanUnitPrice): T + + fun visitTiered(tiered: NewPlanTieredPrice): T + + fun visitBulk(bulk: NewPlanBulkPrice): T + + fun visitBulkWithFilters(bulkWithFilters: BulkWithFilters): T + + fun visitPackage(package_: NewPlanPackagePrice): T + + fun visitMatrix(matrix: NewPlanMatrixPrice): T + + fun visitThresholdTotalAmount( + thresholdTotalAmount: NewPlanThresholdTotalAmountPrice + ): T + + fun visitTieredPackage(tieredPackage: NewPlanTieredPackagePrice): T + + fun visitTieredWithMinimum(tieredWithMinimum: NewPlanTieredWithMinimumPrice): T + + fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice): T + + fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice + ): T + + fun visitPackageWithAllocation( + packageWithAllocation: NewPlanPackageWithAllocationPrice + ): T + + fun visitUnitWithPercent(unitWithPercent: NewPlanUnitWithPercentPrice): T + + fun visitMatrixWithAllocation( + matrixWithAllocation: NewPlanMatrixWithAllocationPrice + ): T + + fun visitTieredWithProration(tieredWithProration: TieredWithProration): T + + fun visitUnitWithProration(unitWithProration: NewPlanUnitWithProrationPrice): T + + fun visitGroupedAllocation(groupedAllocation: NewPlanGroupedAllocationPrice): T + + fun visitBulkWithProration(bulkWithProration: NewPlanBulkWithProrationPrice): T + + fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice + ): T + + fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice + ): T + + fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ): T + + fun visitMatrixWithDisplayName( + matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice + ): T + + fun visitGroupedTieredPackage( + groupedTieredPackage: NewPlanGroupedTieredPackagePrice + ): T + + fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice + ): T + + fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice + ): T + + fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: NewPlanScalableMatrixWithTieredPricingPrice + ): T + + fun visitCumulativeGroupedBulk( + cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice + ): T + + fun visitMinimum(minimum: NewPlanMinimumCompositePrice): T + + fun visitPercent(percent: Percent): T + + fun visitEventOutput(eventOutput: EventOutput): T + + /** + * Maps an unknown variant of [Price] to a value of type [T]. + * + * An instance of [Price] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is + * unaware of. + * + * @throws OrbInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw OrbInvalidDataException("Unknown Price: $json") + } + } + + internal class Deserializer : BaseDeserializer(Price::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Price { + val json = JsonValue.fromJsonNode(node) + val modelType = json.asObject()?.get("model_type")?.asString() + + when (modelType) { + "unit" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(unit = it, _json = json) + } ?: Price(_json = json) + } + "tiered" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(tiered = it, _json = json) + } ?: Price(_json = json) + } + "bulk" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(bulk = it, _json = json) + } ?: Price(_json = json) + } + "bulk_with_filters" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(bulkWithFilters = it, _json = json) + } ?: Price(_json = json) + } + "package" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(package_ = it, _json = json) } ?: Price(_json = json) + } + "matrix" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(matrix = it, _json = json) + } ?: Price(_json = json) + } + "threshold_total_amount" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(thresholdTotalAmount = it, _json = json) } + ?: Price(_json = json) + } + "tiered_package" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(tieredPackage = it, _json = json) } + ?: Price(_json = json) + } + "tiered_with_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(tieredWithMinimum = it, _json = json) } + ?: Price(_json = json) + } + "grouped_tiered" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(groupedTiered = it, _json = json) } + ?: Price(_json = json) + } + "tiered_package_with_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(tieredPackageWithMinimum = it, _json = json) } + ?: Price(_json = json) + } + "package_with_allocation" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(packageWithAllocation = it, _json = json) } + ?: Price(_json = json) + } + "unit_with_percent" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(unitWithPercent = it, _json = json) } + ?: Price(_json = json) + } + "matrix_with_allocation" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(matrixWithAllocation = it, _json = json) } + ?: Price(_json = json) + } + "tiered_with_proration" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(tieredWithProration = it, _json = json) } + ?: Price(_json = json) + } + "unit_with_proration" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(unitWithProration = it, _json = json) } + ?: Price(_json = json) + } + "grouped_allocation" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedAllocation = it, _json = json) } + ?: Price(_json = json) + } + "bulk_with_proration" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(bulkWithProration = it, _json = json) } + ?: Price(_json = json) + } + "grouped_with_prorated_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedWithProratedMinimum = it, _json = json) } + ?: Price(_json = json) + } + "grouped_with_metered_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedWithMeteredMinimum = it, _json = json) } + ?: Price(_json = json) + } + "grouped_with_min_max_thresholds" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedWithMinMaxThresholds = it, _json = json) } + ?: Price(_json = json) + } + "matrix_with_display_name" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(matrixWithDisplayName = it, _json = json) } + ?: Price(_json = json) + } + "grouped_tiered_package" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedTieredPackage = it, _json = json) } + ?: Price(_json = json) + } + "max_group_tiered_package" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(maxGroupTieredPackage = it, _json = json) } + ?: Price(_json = json) + } + "scalable_matrix_with_unit_pricing" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(scalableMatrixWithUnitPricing = it, _json = json) } + ?: Price(_json = json) + } + "scalable_matrix_with_tiered_pricing" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(scalableMatrixWithTieredPricing = it, _json = json) } + ?: Price(_json = json) + } + "cumulative_grouped_bulk" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(cumulativeGroupedBulk = it, _json = json) } + ?: Price(_json = json) + } + "minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(minimum = it, _json = json) } ?: Price(_json = json) + } + "percent" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(percent = it, _json = json) + } ?: Price(_json = json) + } + "event_output" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(eventOutput = it, _json = json) + } ?: Price(_json = json) + } + } + + return Price(_json = json) + } + } + + internal class Serializer : BaseSerializer(Price::class) { + + override fun serialize( + value: Price, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.unit != null -> generator.writeObject(value.unit) + value.tiered != null -> generator.writeObject(value.tiered) + value.bulk != null -> generator.writeObject(value.bulk) + value.bulkWithFilters != null -> + generator.writeObject(value.bulkWithFilters) + value.package_ != null -> generator.writeObject(value.package_) + value.matrix != null -> generator.writeObject(value.matrix) + value.thresholdTotalAmount != null -> + generator.writeObject(value.thresholdTotalAmount) + value.tieredPackage != null -> generator.writeObject(value.tieredPackage) + value.tieredWithMinimum != null -> + generator.writeObject(value.tieredWithMinimum) + value.groupedTiered != null -> generator.writeObject(value.groupedTiered) + value.tieredPackageWithMinimum != null -> + generator.writeObject(value.tieredPackageWithMinimum) + value.packageWithAllocation != null -> + generator.writeObject(value.packageWithAllocation) + value.unitWithPercent != null -> + generator.writeObject(value.unitWithPercent) + value.matrixWithAllocation != null -> + generator.writeObject(value.matrixWithAllocation) + value.tieredWithProration != null -> + generator.writeObject(value.tieredWithProration) + value.unitWithProration != null -> + generator.writeObject(value.unitWithProration) + value.groupedAllocation != null -> + generator.writeObject(value.groupedAllocation) + value.bulkWithProration != null -> + generator.writeObject(value.bulkWithProration) + value.groupedWithProratedMinimum != null -> + generator.writeObject(value.groupedWithProratedMinimum) + value.groupedWithMeteredMinimum != null -> + generator.writeObject(value.groupedWithMeteredMinimum) + value.groupedWithMinMaxThresholds != null -> + generator.writeObject(value.groupedWithMinMaxThresholds) + value.matrixWithDisplayName != null -> + generator.writeObject(value.matrixWithDisplayName) + value.groupedTieredPackage != null -> + generator.writeObject(value.groupedTieredPackage) + value.maxGroupTieredPackage != null -> + generator.writeObject(value.maxGroupTieredPackage) + value.scalableMatrixWithUnitPricing != null -> + generator.writeObject(value.scalableMatrixWithUnitPricing) + value.scalableMatrixWithTieredPricing != null -> + generator.writeObject(value.scalableMatrixWithTieredPricing) + value.cumulativeGroupedBulk != null -> + generator.writeObject(value.cumulativeGroupedBulk) + value.minimum != null -> generator.writeObject(value.minimum) + value.percent != null -> generator.writeObject(value.percent) + value.eventOutput != null -> generator.writeObject(value.eventOutput) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Price") + } + } } - replacesPriceId() - allocationPrice()?.validate() - planPhaseOrder() - price()?.validate() - validated = true - } + class BulkWithFilters + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val bulkWithFiltersConfig: JsonField, + private val cadence: JsonField, + private val itemId: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + @JsonCreator + private constructor( + @JsonProperty("bulk_with_filters_config") + @ExcludeMissing + bulkWithFiltersConfig: JsonField = JsonMissing.of(), + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + bulkWithFiltersConfig, + cadence, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + mutableMapOf(), + ) - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (if (replacesPriceId.asKnown() == null) 0 else 1) + - (allocationPrice.asKnown()?.validity() ?: 0) + - (if (planPhaseOrder.asKnown() == null) 0 else 1) + - (price.asKnown()?.validity() ?: 0) + /** + * Configuration for bulk_with_filters pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun bulkWithFiltersConfig(): BulkWithFiltersConfig = + bulkWithFiltersConfig.getRequired("bulk_with_filters_config") - /** New plan price request body params. */ - @JsonDeserialize(using = Price.Deserializer::class) - @JsonSerialize(using = Price.Serializer::class) - class Price - private constructor( - private val unit: NewPlanUnitPrice? = null, - private val tiered: NewPlanTieredPrice? = null, - private val bulk: NewPlanBulkPrice? = null, - private val package_: NewPlanPackagePrice? = null, - private val matrix: NewPlanMatrixPrice? = null, - private val thresholdTotalAmount: NewPlanThresholdTotalAmountPrice? = null, - private val tieredPackage: NewPlanTieredPackagePrice? = null, - private val tieredWithMinimum: NewPlanTieredWithMinimumPrice? = null, - private val groupedTiered: NewPlanGroupedTieredPrice? = null, - private val tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice? = null, - private val packageWithAllocation: NewPlanPackageWithAllocationPrice? = null, - private val unitWithPercent: NewPlanUnitWithPercentPrice? = null, - private val matrixWithAllocation: NewPlanMatrixWithAllocationPrice? = null, - private val tieredWithProration: TieredWithProration? = null, - private val unitWithProration: NewPlanUnitWithProrationPrice? = null, - private val groupedAllocation: NewPlanGroupedAllocationPrice? = null, - private val bulkWithProration: NewPlanBulkWithProrationPrice? = null, - private val groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice? = null, - private val groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice? = null, - private val groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds? = null, - private val matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice? = null, - private val groupedTieredPackage: NewPlanGroupedTieredPackagePrice? = null, - private val maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice? = null, - private val scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice? = - null, - private val scalableMatrixWithTieredPricing: - NewPlanScalableMatrixWithTieredPricingPrice? = - null, - private val cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice? = null, - private val minimum: NewPlanMinimumCompositePrice? = null, - private val percent: Percent? = null, - private val eventOutput: EventOutput? = null, - private val _json: JsonValue? = null, - ) { + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") - fun unit(): NewPlanUnitPrice? = unit + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") - fun tiered(): NewPlanTieredPrice? = tiered + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("bulk_with_filters") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType - fun bulk(): NewPlanBulkPrice? = bulk + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") - fun package_(): NewPlanPackagePrice? = package_ + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = billableMetricId.getNullable("billable_metric_id") - fun matrix(): NewPlanMatrixPrice? = matrix + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") - fun thresholdTotalAmount(): NewPlanThresholdTotalAmountPrice? = thresholdTotalAmount + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") - fun tieredPackage(): NewPlanTieredPackagePrice? = tieredPackage + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") - fun tieredWithMinimum(): NewPlanTieredWithMinimumPrice? = tieredWithMinimum + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") - fun groupedTiered(): NewPlanGroupedTieredPrice? = groupedTiered + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") - fun tieredPackageWithMinimum(): NewPlanTieredPackageWithMinimumPrice? = - tieredPackageWithMinimum + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") - fun packageWithAllocation(): NewPlanPackageWithAllocationPrice? = packageWithAllocation + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") - fun unitWithPercent(): NewPlanUnitWithPercentPrice? = unitWithPercent + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") - fun matrixWithAllocation(): NewPlanMatrixWithAllocationPrice? = matrixWithAllocation + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + invoiceGroupingKey.getNullable("invoice_grouping_key") - fun tieredWithProration(): TieredWithProration? = tieredWithProration + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - fun unitWithProration(): NewPlanUnitWithProrationPrice? = unitWithProration + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") - fun groupedAllocation(): NewPlanGroupedAllocationPrice? = groupedAllocation + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") - fun bulkWithProration(): NewPlanBulkWithProrationPrice? = bulkWithProration + /** + * Returns the raw JSON value of [bulkWithFiltersConfig]. + * + * Unlike [bulkWithFiltersConfig], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("bulk_with_filters_config") + @ExcludeMissing + fun _bulkWithFiltersConfig(): JsonField = + bulkWithFiltersConfig - fun groupedWithProratedMinimum(): NewPlanGroupedWithProratedMinimumPrice? = - groupedWithProratedMinimum + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence - fun groupedWithMeteredMinimum(): NewPlanGroupedWithMeteredMinimumPrice? = - groupedWithMeteredMinimum + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - fun groupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds? = - groupedWithMinMaxThresholds + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - fun matrixWithDisplayName(): NewPlanMatrixWithDisplayNamePrice? = matrixWithDisplayName + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId - fun groupedTieredPackage(): NewPlanGroupedTieredPackagePrice? = groupedTieredPackage + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance - fun maxGroupTieredPackage(): NewPlanMaxGroupTieredPackagePrice? = maxGroupTieredPackage + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration - fun scalableMatrixWithUnitPricing(): NewPlanScalableMatrixWithUnitPricingPrice? = - scalableMatrixWithUnitPricing + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate - fun scalableMatrixWithTieredPricing(): NewPlanScalableMatrixWithTieredPricingPrice? = - scalableMatrixWithTieredPricing + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig - fun cumulativeGroupedBulk(): NewPlanCumulativeGroupedBulkPrice? = cumulativeGroupedBulk + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency - fun minimum(): NewPlanMinimumCompositePrice? = minimum + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration - fun percent(): Percent? = percent + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId - fun eventOutput(): EventOutput? = eventOutput + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - fun isUnit(): Boolean = unit != null + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - fun isTiered(): Boolean = tiered != null + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration - fun isBulk(): Boolean = bulk != null + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata - fun isPackage(): Boolean = package_ != null + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId - fun isMatrix(): Boolean = matrix != null + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - fun isThresholdTotalAmount(): Boolean = thresholdTotalAmount != null + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - fun isTieredPackage(): Boolean = tieredPackage != null + fun toBuilder() = Builder().from(this) - fun isTieredWithMinimum(): Boolean = tieredWithMinimum != null + companion object { - fun isGroupedTiered(): Boolean = groupedTiered != null + /** + * Returns a mutable builder for constructing an instance of [BulkWithFilters]. + * + * The following fields are required: + * ```kotlin + * .bulkWithFiltersConfig() + * .cadence() + * .itemId() + * .name() + * ``` + */ + fun builder() = Builder() + } - fun isTieredPackageWithMinimum(): Boolean = tieredPackageWithMinimum != null + /** A builder for [BulkWithFilters]. */ + class Builder internal constructor() { - fun isPackageWithAllocation(): Boolean = packageWithAllocation != null + private var bulkWithFiltersConfig: JsonField? = null + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonValue = JsonValue.from("bulk_with_filters") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - fun isUnitWithPercent(): Boolean = unitWithPercent != null + internal fun from(bulkWithFilters: BulkWithFilters) = apply { + bulkWithFiltersConfig = bulkWithFilters.bulkWithFiltersConfig + cadence = bulkWithFilters.cadence + itemId = bulkWithFilters.itemId + modelType = bulkWithFilters.modelType + name = bulkWithFilters.name + billableMetricId = bulkWithFilters.billableMetricId + billedInAdvance = bulkWithFilters.billedInAdvance + billingCycleConfiguration = bulkWithFilters.billingCycleConfiguration + conversionRate = bulkWithFilters.conversionRate + conversionRateConfig = bulkWithFilters.conversionRateConfig + currency = bulkWithFilters.currency + dimensionalPriceConfiguration = + bulkWithFilters.dimensionalPriceConfiguration + externalPriceId = bulkWithFilters.externalPriceId + fixedPriceQuantity = bulkWithFilters.fixedPriceQuantity + invoiceGroupingKey = bulkWithFilters.invoiceGroupingKey + invoicingCycleConfiguration = bulkWithFilters.invoicingCycleConfiguration + metadata = bulkWithFilters.metadata + referenceId = bulkWithFilters.referenceId + additionalProperties = bulkWithFilters.additionalProperties.toMutableMap() + } - fun isMatrixWithAllocation(): Boolean = matrixWithAllocation != null + /** Configuration for bulk_with_filters pricing */ + fun bulkWithFiltersConfig(bulkWithFiltersConfig: BulkWithFiltersConfig) = + bulkWithFiltersConfig(JsonField.of(bulkWithFiltersConfig)) - fun isTieredWithProration(): Boolean = tieredWithProration != null + /** + * Sets [Builder.bulkWithFiltersConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.bulkWithFiltersConfig] with a well-typed + * [BulkWithFiltersConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun bulkWithFiltersConfig( + bulkWithFiltersConfig: JsonField + ) = apply { this.bulkWithFiltersConfig = bulkWithFiltersConfig } - fun isUnitWithProration(): Boolean = unitWithProration != null + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - fun isGroupedAllocation(): Boolean = groupedAllocation != null + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - fun isBulkWithProration(): Boolean = bulkWithProration != null + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - fun isGroupedWithProratedMinimum(): Boolean = groupedWithProratedMinimum != null + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun isGroupedWithMeteredMinimum(): Boolean = groupedWithMeteredMinimum != null + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("bulk_with_filters") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } - fun isGroupedWithMinMaxThresholds(): Boolean = groupedWithMinMaxThresholds != null + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) - fun isMatrixWithDisplayName(): Boolean = matrixWithDisplayName != null + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } - fun isGroupedTieredPackage(): Boolean = groupedTieredPackage != null + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) - fun isMaxGroupTieredPackage(): Boolean = maxGroupTieredPackage != null + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } - fun isScalableMatrixWithUnitPricing(): Boolean = scalableMatrixWithUnitPricing != null + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) - fun isScalableMatrixWithTieredPricing(): Boolean = - scalableMatrixWithTieredPricing != null + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) - fun isCumulativeGroupedBulk(): Boolean = cumulativeGroupedBulk != null + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } - fun isMinimum(): Boolean = minimum != null + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - fun isPercent(): Boolean = percent != null + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } - fun isEventOutput(): Boolean = eventOutput != null + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) - fun asUnit(): NewPlanUnitPrice = unit.getOrThrow("unit") + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) - fun asTiered(): NewPlanTieredPrice = tiered.getOrThrow("tiered") + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } - fun asBulk(): NewPlanBulkPrice = bulk.getOrThrow("bulk") + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) - fun asPackage(): NewPlanPackagePrice = package_.getOrThrow("package_") + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } - fun asMatrix(): NewPlanMatrixPrice = matrix.getOrThrow("matrix") + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) - fun asThresholdTotalAmount(): NewPlanThresholdTotalAmountPrice = - thresholdTotalAmount.getOrThrow("thresholdTotalAmount") + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) - fun asTieredPackage(): NewPlanTieredPackagePrice = - tieredPackage.getOrThrow("tieredPackage") + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) - fun asTieredWithMinimum(): NewPlanTieredWithMinimumPrice = - tieredWithMinimum.getOrThrow("tieredWithMinimum") + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) - fun asGroupedTiered(): NewPlanGroupedTieredPrice = - groupedTiered.getOrThrow("groupedTiered") + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) - fun asTieredPackageWithMinimum(): NewPlanTieredPackageWithMinimumPrice = - tieredPackageWithMinimum.getOrThrow("tieredPackageWithMinimum") + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } - fun asPackageWithAllocation(): NewPlanPackageWithAllocationPrice = - packageWithAllocation.getOrThrow("packageWithAllocation") + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) - fun asUnitWithPercent(): NewPlanUnitWithPercentPrice = - unitWithPercent.getOrThrow("unitWithPercent") + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } - fun asMatrixWithAllocation(): NewPlanMatrixWithAllocationPrice = - matrixWithAllocation.getOrThrow("matrixWithAllocation") + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) - fun asTieredWithProration(): TieredWithProration = - tieredWithProration.getOrThrow("tieredWithProration") + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } - fun asUnitWithProration(): NewPlanUnitWithProrationPrice = - unitWithProration.getOrThrow("unitWithProration") + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) - fun asGroupedAllocation(): NewPlanGroupedAllocationPrice = - groupedAllocation.getOrThrow("groupedAllocation") + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) - fun asBulkWithProration(): NewPlanBulkWithProrationPrice = - bulkWithProration.getOrThrow("bulkWithProration") + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } - fun asGroupedWithProratedMinimum(): NewPlanGroupedWithProratedMinimumPrice = - groupedWithProratedMinimum.getOrThrow("groupedWithProratedMinimum") + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) - fun asGroupedWithMeteredMinimum(): NewPlanGroupedWithMeteredMinimumPrice = - groupedWithMeteredMinimum.getOrThrow("groupedWithMeteredMinimum") + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } - fun asGroupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds = - groupedWithMinMaxThresholds.getOrThrow("groupedWithMinMaxThresholds") + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) - fun asMatrixWithDisplayName(): NewPlanMatrixWithDisplayNamePrice = - matrixWithDisplayName.getOrThrow("matrixWithDisplayName") + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - fun asGroupedTieredPackage(): NewPlanGroupedTieredPackagePrice = - groupedTieredPackage.getOrThrow("groupedTieredPackage") + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - fun asMaxGroupTieredPackage(): NewPlanMaxGroupTieredPackagePrice = - maxGroupTieredPackage.getOrThrow("maxGroupTieredPackage") + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - fun asScalableMatrixWithUnitPricing(): NewPlanScalableMatrixWithUnitPricingPrice = - scalableMatrixWithUnitPricing.getOrThrow("scalableMatrixWithUnitPricing") + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) - fun asScalableMatrixWithTieredPricing(): NewPlanScalableMatrixWithTieredPricingPrice = - scalableMatrixWithTieredPricing.getOrThrow("scalableMatrixWithTieredPricing") + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } - fun asCumulativeGroupedBulk(): NewPlanCumulativeGroupedBulkPrice = - cumulativeGroupedBulk.getOrThrow("cumulativeGroupedBulk") + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun asMinimum(): NewPlanMinimumCompositePrice = minimum.getOrThrow("minimum") + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun asPercent(): Percent = percent.getOrThrow("percent") + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun asEventOutput(): EventOutput = eventOutput.getOrThrow("eventOutput") + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun _json(): JsonValue? = _json + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - bulk != null -> visitor.visitBulk(bulk) - package_ != null -> visitor.visitPackage(package_) - matrix != null -> visitor.visitMatrix(matrix) - thresholdTotalAmount != null -> - visitor.visitThresholdTotalAmount(thresholdTotalAmount) - tieredPackage != null -> visitor.visitTieredPackage(tieredPackage) - tieredWithMinimum != null -> visitor.visitTieredWithMinimum(tieredWithMinimum) - groupedTiered != null -> visitor.visitGroupedTiered(groupedTiered) - tieredPackageWithMinimum != null -> - visitor.visitTieredPackageWithMinimum(tieredPackageWithMinimum) - packageWithAllocation != null -> - visitor.visitPackageWithAllocation(packageWithAllocation) - unitWithPercent != null -> visitor.visitUnitWithPercent(unitWithPercent) - matrixWithAllocation != null -> - visitor.visitMatrixWithAllocation(matrixWithAllocation) - tieredWithProration != null -> - visitor.visitTieredWithProration(tieredWithProration) - unitWithProration != null -> visitor.visitUnitWithProration(unitWithProration) - groupedAllocation != null -> visitor.visitGroupedAllocation(groupedAllocation) - bulkWithProration != null -> visitor.visitBulkWithProration(bulkWithProration) - groupedWithProratedMinimum != null -> - visitor.visitGroupedWithProratedMinimum(groupedWithProratedMinimum) - groupedWithMeteredMinimum != null -> - visitor.visitGroupedWithMeteredMinimum(groupedWithMeteredMinimum) - groupedWithMinMaxThresholds != null -> - visitor.visitGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds) - matrixWithDisplayName != null -> - visitor.visitMatrixWithDisplayName(matrixWithDisplayName) - groupedTieredPackage != null -> - visitor.visitGroupedTieredPackage(groupedTieredPackage) - maxGroupTieredPackage != null -> - visitor.visitMaxGroupTieredPackage(maxGroupTieredPackage) - scalableMatrixWithUnitPricing != null -> - visitor.visitScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing) - scalableMatrixWithTieredPricing != null -> - visitor.visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing + /** + * Returns an immutable instance of [BulkWithFilters]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .bulkWithFiltersConfig() + * .cadence() + * .itemId() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BulkWithFilters = + BulkWithFilters( + checkRequired("bulkWithFiltersConfig", bulkWithFiltersConfig), + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties.toMutableMap(), ) - cumulativeGroupedBulk != null -> - visitor.visitCumulativeGroupedBulk(cumulativeGroupedBulk) - minimum != null -> visitor.visitMinimum(minimum) - percent != null -> visitor.visitPercent(percent) - eventOutput != null -> visitor.visitEventOutput(eventOutput) - else -> visitor.unknown(_json) } - private var validated: Boolean = false + private var validated: Boolean = false - fun validate(): Price = apply { - if (validated) { - return@apply - } + fun validate(): BulkWithFilters = apply { + if (validated) { + return@apply + } - accept( - object : Visitor { - override fun visitUnit(unit: NewPlanUnitPrice) { - unit.validate() + bulkWithFiltersConfig().validate() + cadence().validate() + itemId() + _modelType().let { + if (it != JsonValue.from("bulk_with_filters")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + metadata()?.validate() + referenceId() + validated = true + } - override fun visitTiered(tiered: NewPlanTieredPrice) { - tiered.validate() - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - override fun visitBulk(bulk: NewPlanBulkPrice) { - bulk.validate() - } + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (bulkWithFiltersConfig.asKnown()?.validity() ?: 0) + + (cadence.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + modelType.let { if (it == JsonValue.from("bulk_with_filters")) 1 else 0 } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) - override fun visitPackage(package_: NewPlanPackagePrice) { - package_.validate() - } + /** Configuration for bulk_with_filters pricing */ + class BulkWithFiltersConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val filters: JsonField>, + private val tiers: JsonField>, + private val additionalProperties: MutableMap, + ) { - override fun visitMatrix(matrix: NewPlanMatrixPrice) { - matrix.validate() - } + @JsonCreator + private constructor( + @JsonProperty("filters") + @ExcludeMissing + filters: JsonField> = JsonMissing.of(), + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of(), + ) : this(filters, tiers, mutableMapOf()) - override fun visitThresholdTotalAmount( - thresholdTotalAmount: NewPlanThresholdTotalAmountPrice - ) { - thresholdTotalAmount.validate() - } + /** + * Property filters to apply (all must match) + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun filters(): List = filters.getRequired("filters") - override fun visitTieredPackage(tieredPackage: NewPlanTieredPackagePrice) { - tieredPackage.validate() - } + /** + * Bulk tiers for rating based on total usage volume + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun tiers(): List = tiers.getRequired("tiers") - override fun visitTieredWithMinimum( - tieredWithMinimum: NewPlanTieredWithMinimumPrice - ) { - tieredWithMinimum.validate() - } + /** + * Returns the raw JSON value of [filters]. + * + * Unlike [filters], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("filters") + @ExcludeMissing + fun _filters(): JsonField> = filters - override fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) { - groupedTiered.validate() - } + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers - override fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice - ) { - tieredPackageWithMinimum.validate() - } + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - override fun visitPackageWithAllocation( - packageWithAllocation: NewPlanPackageWithAllocationPrice - ) { - packageWithAllocation.validate() - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - override fun visitUnitWithPercent( - unitWithPercent: NewPlanUnitWithPercentPrice - ) { - unitWithPercent.validate() - } + fun toBuilder() = Builder().from(this) - override fun visitMatrixWithAllocation( - matrixWithAllocation: NewPlanMatrixWithAllocationPrice - ) { - matrixWithAllocation.validate() - } + companion object { - override fun visitTieredWithProration( - tieredWithProration: TieredWithProration - ) { - tieredWithProration.validate() - } + /** + * Returns a mutable builder for constructing an instance of + * [BulkWithFiltersConfig]. + * + * The following fields are required: + * ```kotlin + * .filters() + * .tiers() + * ``` + */ + fun builder() = Builder() + } - override fun visitUnitWithProration( - unitWithProration: NewPlanUnitWithProrationPrice - ) { - unitWithProration.validate() - } + /** A builder for [BulkWithFiltersConfig]. */ + class Builder internal constructor() { - override fun visitGroupedAllocation( - groupedAllocation: NewPlanGroupedAllocationPrice - ) { - groupedAllocation.validate() - } + private var filters: JsonField>? = null + private var tiers: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() - override fun visitBulkWithProration( - bulkWithProration: NewPlanBulkWithProrationPrice - ) { - bulkWithProration.validate() + internal fun from(bulkWithFiltersConfig: BulkWithFiltersConfig) = apply { + filters = bulkWithFiltersConfig.filters.map { it.toMutableList() } + tiers = bulkWithFiltersConfig.tiers.map { it.toMutableList() } + additionalProperties = + bulkWithFiltersConfig.additionalProperties.toMutableMap() } - override fun visitGroupedWithProratedMinimum( - groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice - ) { - groupedWithProratedMinimum.validate() - } + /** Property filters to apply (all must match) */ + fun filters(filters: List) = filters(JsonField.of(filters)) - override fun visitGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice - ) { - groupedWithMeteredMinimum.validate() + /** + * Sets [Builder.filters] to an arbitrary JSON value. + * + * You should usually call [Builder.filters] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun filters(filters: JsonField>) = apply { + this.filters = filters.map { it.toMutableList() } } - override fun visitGroupedWithMinMaxThresholds( - groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds - ) { - groupedWithMinMaxThresholds.validate() + /** + * Adds a single [Filter] to [filters]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addFilter(filter: Filter) = apply { + filters = + (filters ?: JsonField.of(mutableListOf())).also { + checkKnown("filters", it).add(filter) + } } - override fun visitMatrixWithDisplayName( - matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice - ) { - matrixWithDisplayName.validate() - } + /** Bulk tiers for rating based on total usage volume */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) - override fun visitGroupedTieredPackage( - groupedTieredPackage: NewPlanGroupedTieredPackagePrice - ) { - groupedTieredPackage.validate() + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } } - override fun visitMaxGroupTieredPackage( - maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice - ) { - maxGroupTieredPackage.validate() + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } } - override fun visitScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice - ) { - scalableMatrixWithUnitPricing.validate() - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - override fun visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: - NewPlanScalableMatrixWithTieredPricingPrice - ) { - scalableMatrixWithTieredPricing.validate() + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) } - override fun visitCumulativeGroupedBulk( - cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice - ) { - cumulativeGroupedBulk.validate() - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - override fun visitMinimum(minimum: NewPlanMinimumCompositePrice) { - minimum.validate() + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) } - override fun visitPercent(percent: Percent) { - percent.validate() + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) } - override fun visitEventOutput(eventOutput: EventOutput) { - eventOutput.validate() - } + /** + * Returns an immutable instance of [BulkWithFiltersConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .filters() + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BulkWithFiltersConfig = + BulkWithFiltersConfig( + checkRequired("filters", filters).map { it.toImmutable() }, + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) } - ) - validated = true - } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + private var validated: Boolean = false - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: NewPlanUnitPrice) = unit.validity() + fun validate(): BulkWithFiltersConfig = apply { + if (validated) { + return@apply + } - override fun visitTiered(tiered: NewPlanTieredPrice) = tiered.validity() + filters().forEach { it.validate() } + tiers().forEach { it.validate() } + validated = true + } - override fun visitBulk(bulk: NewPlanBulkPrice) = bulk.validity() + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - override fun visitPackage(package_: NewPlanPackagePrice) = - package_.validity() + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (filters.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + (tiers.asKnown()?.sumOf { it.validity().toInt() } ?: 0) - override fun visitMatrix(matrix: NewPlanMatrixPrice) = matrix.validity() + /** Configuration for a single property filter */ + class Filter + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val propertyKey: JsonField, + private val propertyValue: JsonField, + private val additionalProperties: MutableMap, + ) { - override fun visitThresholdTotalAmount( - thresholdTotalAmount: NewPlanThresholdTotalAmountPrice - ) = thresholdTotalAmount.validity() + @JsonCreator + private constructor( + @JsonProperty("property_key") + @ExcludeMissing + propertyKey: JsonField = JsonMissing.of(), + @JsonProperty("property_value") + @ExcludeMissing + propertyValue: JsonField = JsonMissing.of(), + ) : this(propertyKey, propertyValue, mutableMapOf()) - override fun visitTieredPackage(tieredPackage: NewPlanTieredPackagePrice) = - tieredPackage.validity() + /** + * Event property key to filter on + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun propertyKey(): String = propertyKey.getRequired("property_key") - override fun visitTieredWithMinimum( - tieredWithMinimum: NewPlanTieredWithMinimumPrice - ) = tieredWithMinimum.validity() + /** + * Event property value to match + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun propertyValue(): String = propertyValue.getRequired("property_value") - override fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) = - groupedTiered.validity() + /** + * Returns the raw JSON value of [propertyKey]. + * + * Unlike [propertyKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("property_key") + @ExcludeMissing + fun _propertyKey(): JsonField = propertyKey - override fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice - ) = tieredPackageWithMinimum.validity() + /** + * Returns the raw JSON value of [propertyValue]. + * + * Unlike [propertyValue], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("property_value") + @ExcludeMissing + fun _propertyValue(): JsonField = propertyValue - override fun visitPackageWithAllocation( - packageWithAllocation: NewPlanPackageWithAllocationPrice - ) = packageWithAllocation.validity() + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - override fun visitUnitWithPercent( - unitWithPercent: NewPlanUnitWithPercentPrice - ) = unitWithPercent.validity() + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - override fun visitMatrixWithAllocation( - matrixWithAllocation: NewPlanMatrixWithAllocationPrice - ) = matrixWithAllocation.validity() + fun toBuilder() = Builder().from(this) - override fun visitTieredWithProration( - tieredWithProration: TieredWithProration - ) = tieredWithProration.validity() + companion object { - override fun visitUnitWithProration( - unitWithProration: NewPlanUnitWithProrationPrice - ) = unitWithProration.validity() + /** + * Returns a mutable builder for constructing an instance of [Filter]. + * + * The following fields are required: + * ```kotlin + * .propertyKey() + * .propertyValue() + * ``` + */ + fun builder() = Builder() + } - override fun visitGroupedAllocation( - groupedAllocation: NewPlanGroupedAllocationPrice - ) = groupedAllocation.validity() + /** A builder for [Filter]. */ + class Builder internal constructor() { - override fun visitBulkWithProration( - bulkWithProration: NewPlanBulkWithProrationPrice - ) = bulkWithProration.validity() + private var propertyKey: JsonField? = null + private var propertyValue: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() - override fun visitGroupedWithProratedMinimum( - groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice - ) = groupedWithProratedMinimum.validity() + internal fun from(filter: Filter) = apply { + propertyKey = filter.propertyKey + propertyValue = filter.propertyValue + additionalProperties = filter.additionalProperties.toMutableMap() + } - override fun visitGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice - ) = groupedWithMeteredMinimum.validity() + /** Event property key to filter on */ + fun propertyKey(propertyKey: String) = + propertyKey(JsonField.of(propertyKey)) - override fun visitGroupedWithMinMaxThresholds( - groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds - ) = groupedWithMinMaxThresholds.validity() + /** + * Sets [Builder.propertyKey] to an arbitrary JSON value. + * + * You should usually call [Builder.propertyKey] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun propertyKey(propertyKey: JsonField) = apply { + this.propertyKey = propertyKey + } - override fun visitMatrixWithDisplayName( - matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice - ) = matrixWithDisplayName.validity() + /** Event property value to match */ + fun propertyValue(propertyValue: String) = + propertyValue(JsonField.of(propertyValue)) - override fun visitGroupedTieredPackage( - groupedTieredPackage: NewPlanGroupedTieredPackagePrice - ) = groupedTieredPackage.validity() + /** + * Sets [Builder.propertyValue] to an arbitrary JSON value. + * + * You should usually call [Builder.propertyValue] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun propertyValue(propertyValue: JsonField) = apply { + this.propertyValue = propertyValue + } - override fun visitMaxGroupTieredPackage( - maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice - ) = maxGroupTieredPackage.validity() + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - override fun visitScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice - ) = scalableMatrixWithUnitPricing.validity() + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - override fun visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: - NewPlanScalableMatrixWithTieredPricingPrice - ) = scalableMatrixWithTieredPricing.validity() + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - override fun visitCumulativeGroupedBulk( - cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice - ) = cumulativeGroupedBulk.validity() + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - override fun visitMinimum(minimum: NewPlanMinimumCompositePrice) = - minimum.validity() + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - override fun visitPercent(percent: Percent) = percent.validity() + /** + * Returns an immutable instance of [Filter]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```kotlin + * .propertyKey() + * .propertyValue() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Filter = + Filter( + checkRequired("propertyKey", propertyKey), + checkRequired("propertyValue", propertyValue), + additionalProperties.toMutableMap(), + ) + } - override fun visitEventOutput(eventOutput: EventOutput) = - eventOutput.validity() + private var validated: Boolean = false - override fun unknown(json: JsonValue?) = 0 - } - ) + fun validate(): Filter = apply { + if (validated) { + return@apply + } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + propertyKey() + propertyValue() + validated = true + } - return other is Price && - unit == other.unit && - tiered == other.tiered && - bulk == other.bulk && - package_ == other.package_ && - matrix == other.matrix && - thresholdTotalAmount == other.thresholdTotalAmount && - tieredPackage == other.tieredPackage && - tieredWithMinimum == other.tieredWithMinimum && - groupedTiered == other.groupedTiered && - tieredPackageWithMinimum == other.tieredPackageWithMinimum && - packageWithAllocation == other.packageWithAllocation && - unitWithPercent == other.unitWithPercent && - matrixWithAllocation == other.matrixWithAllocation && - tieredWithProration == other.tieredWithProration && - unitWithProration == other.unitWithProration && - groupedAllocation == other.groupedAllocation && - bulkWithProration == other.bulkWithProration && - groupedWithProratedMinimum == other.groupedWithProratedMinimum && - groupedWithMeteredMinimum == other.groupedWithMeteredMinimum && - groupedWithMinMaxThresholds == other.groupedWithMinMaxThresholds && - matrixWithDisplayName == other.matrixWithDisplayName && - groupedTieredPackage == other.groupedTieredPackage && - maxGroupTieredPackage == other.maxGroupTieredPackage && - scalableMatrixWithUnitPricing == other.scalableMatrixWithUnitPricing && - scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && - cumulativeGroupedBulk == other.cumulativeGroupedBulk && - minimum == other.minimum && - percent == other.percent && - eventOutput == other.eventOutput - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - override fun hashCode(): Int = - Objects.hash( - unit, - tiered, - bulk, - package_, - matrix, - thresholdTotalAmount, - tieredPackage, - tieredWithMinimum, - groupedTiered, - tieredPackageWithMinimum, - packageWithAllocation, - unitWithPercent, - matrixWithAllocation, - tieredWithProration, - unitWithProration, - groupedAllocation, - bulkWithProration, - groupedWithProratedMinimum, - groupedWithMeteredMinimum, - groupedWithMinMaxThresholds, - matrixWithDisplayName, - groupedTieredPackage, - maxGroupTieredPackage, - scalableMatrixWithUnitPricing, - scalableMatrixWithTieredPricing, - cumulativeGroupedBulk, - minimum, - percent, - eventOutput, - ) + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (propertyKey.asKnown() == null) 0 else 1) + + (if (propertyValue.asKnown() == null) 0 else 1) - override fun toString(): String = - when { - unit != null -> "Price{unit=$unit}" - tiered != null -> "Price{tiered=$tiered}" - bulk != null -> "Price{bulk=$bulk}" - package_ != null -> "Price{package_=$package_}" - matrix != null -> "Price{matrix=$matrix}" - thresholdTotalAmount != null -> - "Price{thresholdTotalAmount=$thresholdTotalAmount}" - tieredPackage != null -> "Price{tieredPackage=$tieredPackage}" - tieredWithMinimum != null -> "Price{tieredWithMinimum=$tieredWithMinimum}" - groupedTiered != null -> "Price{groupedTiered=$groupedTiered}" - tieredPackageWithMinimum != null -> - "Price{tieredPackageWithMinimum=$tieredPackageWithMinimum}" - packageWithAllocation != null -> - "Price{packageWithAllocation=$packageWithAllocation}" - unitWithPercent != null -> "Price{unitWithPercent=$unitWithPercent}" - matrixWithAllocation != null -> - "Price{matrixWithAllocation=$matrixWithAllocation}" - tieredWithProration != null -> "Price{tieredWithProration=$tieredWithProration}" - unitWithProration != null -> "Price{unitWithProration=$unitWithProration}" - groupedAllocation != null -> "Price{groupedAllocation=$groupedAllocation}" - bulkWithProration != null -> "Price{bulkWithProration=$bulkWithProration}" - groupedWithProratedMinimum != null -> - "Price{groupedWithProratedMinimum=$groupedWithProratedMinimum}" - groupedWithMeteredMinimum != null -> - "Price{groupedWithMeteredMinimum=$groupedWithMeteredMinimum}" - groupedWithMinMaxThresholds != null -> - "Price{groupedWithMinMaxThresholds=$groupedWithMinMaxThresholds}" - matrixWithDisplayName != null -> - "Price{matrixWithDisplayName=$matrixWithDisplayName}" - groupedTieredPackage != null -> - "Price{groupedTieredPackage=$groupedTieredPackage}" - maxGroupTieredPackage != null -> - "Price{maxGroupTieredPackage=$maxGroupTieredPackage}" - scalableMatrixWithUnitPricing != null -> - "Price{scalableMatrixWithUnitPricing=$scalableMatrixWithUnitPricing}" - scalableMatrixWithTieredPricing != null -> - "Price{scalableMatrixWithTieredPricing=$scalableMatrixWithTieredPricing}" - cumulativeGroupedBulk != null -> - "Price{cumulativeGroupedBulk=$cumulativeGroupedBulk}" - minimum != null -> "Price{minimum=$minimum}" - percent != null -> "Price{percent=$percent}" - eventOutput != null -> "Price{eventOutput=$eventOutput}" - _json != null -> "Price{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Price") - } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - companion object { + return other is Filter && + propertyKey == other.propertyKey && + propertyValue == other.propertyValue && + additionalProperties == other.additionalProperties + } - fun ofUnit(unit: NewPlanUnitPrice) = Price(unit = unit) + private val hashCode: Int by lazy { + Objects.hash(propertyKey, propertyValue, additionalProperties) + } - fun ofTiered(tiered: NewPlanTieredPrice) = Price(tiered = tiered) + override fun hashCode(): Int = hashCode - fun ofBulk(bulk: NewPlanBulkPrice) = Price(bulk = bulk) + override fun toString() = + "Filter{propertyKey=$propertyKey, propertyValue=$propertyValue, additionalProperties=$additionalProperties}" + } - fun ofPackage(package_: NewPlanPackagePrice) = Price(package_ = package_) + /** Configuration for a single bulk pricing tier */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val unitAmount: JsonField, + private val tierLowerBound: JsonField, + private val additionalProperties: MutableMap, + ) { - fun ofMatrix(matrix: NewPlanMatrixPrice) = Price(matrix = matrix) + @JsonCreator + private constructor( + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + ) : this(unitAmount, tierLowerBound, mutableMapOf()) - fun ofThresholdTotalAmount(thresholdTotalAmount: NewPlanThresholdTotalAmountPrice) = - Price(thresholdTotalAmount = thresholdTotalAmount) + /** + * Amount per unit + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") - fun ofTieredPackage(tieredPackage: NewPlanTieredPackagePrice) = - Price(tieredPackage = tieredPackage) + /** + * The lower bound for this tier + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun tierLowerBound(): String? = + tierLowerBound.getNullable("tier_lower_bound") - fun ofTieredWithMinimum(tieredWithMinimum: NewPlanTieredWithMinimumPrice) = - Price(tieredWithMinimum = tieredWithMinimum) + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount - fun ofGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) = - Price(groupedTiered = groupedTiered) + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound - fun ofTieredPackageWithMinimum( - tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice - ) = Price(tieredPackageWithMinimum = tieredPackageWithMinimum) + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - fun ofPackageWithAllocation( - packageWithAllocation: NewPlanPackageWithAllocationPrice - ) = Price(packageWithAllocation = packageWithAllocation) + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - fun ofUnitWithPercent(unitWithPercent: NewPlanUnitWithPercentPrice) = - Price(unitWithPercent = unitWithPercent) + fun toBuilder() = Builder().from(this) - fun ofMatrixWithAllocation(matrixWithAllocation: NewPlanMatrixWithAllocationPrice) = - Price(matrixWithAllocation = matrixWithAllocation) + companion object { - fun ofTieredWithProration(tieredWithProration: TieredWithProration) = - Price(tieredWithProration = tieredWithProration) + /** + * Returns a mutable builder for constructing an instance of [Tier]. + * + * The following fields are required: + * ```kotlin + * .unitAmount() + * ``` + */ + fun builder() = Builder() + } - fun ofUnitWithProration(unitWithProration: NewPlanUnitWithProrationPrice) = - Price(unitWithProration = unitWithProration) + /** A builder for [Tier]. */ + class Builder internal constructor() { - fun ofGroupedAllocation(groupedAllocation: NewPlanGroupedAllocationPrice) = - Price(groupedAllocation = groupedAllocation) + private var unitAmount: JsonField? = null + private var tierLowerBound: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() - fun ofBulkWithProration(bulkWithProration: NewPlanBulkWithProrationPrice) = - Price(bulkWithProration = bulkWithProration) + internal fun from(tier: Tier) = apply { + unitAmount = tier.unitAmount + tierLowerBound = tier.tierLowerBound + additionalProperties = tier.additionalProperties.toMutableMap() + } - fun ofGroupedWithProratedMinimum( - groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice - ) = Price(groupedWithProratedMinimum = groupedWithProratedMinimum) + /** Amount per unit */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) - fun ofGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice - ) = Price(groupedWithMeteredMinimum = groupedWithMeteredMinimum) + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } - fun ofGroupedWithMinMaxThresholds( - groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds - ) = Price(groupedWithMinMaxThresholds = groupedWithMinMaxThresholds) + /** The lower bound for this tier */ + fun tierLowerBound(tierLowerBound: String?) = + tierLowerBound(JsonField.ofNullable(tierLowerBound)) - fun ofMatrixWithDisplayName( - matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice - ) = Price(matrixWithDisplayName = matrixWithDisplayName) + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } - fun ofGroupedTieredPackage(groupedTieredPackage: NewPlanGroupedTieredPackagePrice) = - Price(groupedTieredPackage = groupedTieredPackage) + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun ofMaxGroupTieredPackage( - maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice - ) = Price(maxGroupTieredPackage = maxGroupTieredPackage) + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun ofScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice - ) = Price(scalableMatrixWithUnitPricing = scalableMatrixWithUnitPricing) + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun ofScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: NewPlanScalableMatrixWithTieredPricingPrice - ) = Price(scalableMatrixWithTieredPricing = scalableMatrixWithTieredPricing) + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun ofCumulativeGroupedBulk( - cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice - ) = Price(cumulativeGroupedBulk = cumulativeGroupedBulk) + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - fun ofMinimum(minimum: NewPlanMinimumCompositePrice) = Price(minimum = minimum) + /** + * Returns an immutable instance of [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```kotlin + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("unitAmount", unitAmount), + tierLowerBound, + additionalProperties.toMutableMap(), + ) + } - fun ofPercent(percent: Percent) = Price(percent = percent) + private var validated: Boolean = false - fun ofEventOutput(eventOutput: EventOutput) = Price(eventOutput = eventOutput) - } + fun validate(): Tier = apply { + if (validated) { + return@apply + } - /** - * An interface that defines how to map each variant of [Price] to a value of type [T]. - */ - interface Visitor { + unitAmount() + tierLowerBound() + validated = true + } - fun visitUnit(unit: NewPlanUnitPrice): T + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - fun visitTiered(tiered: NewPlanTieredPrice): T + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (unitAmount.asKnown() == null) 0 else 1) + + (if (tierLowerBound.asKnown() == null) 0 else 1) - fun visitBulk(bulk: NewPlanBulkPrice): T + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun visitPackage(package_: NewPlanPackagePrice): T + return other is Tier && + unitAmount == other.unitAmount && + tierLowerBound == other.tierLowerBound && + additionalProperties == other.additionalProperties + } - fun visitMatrix(matrix: NewPlanMatrixPrice): T + private val hashCode: Int by lazy { + Objects.hash(unitAmount, tierLowerBound, additionalProperties) + } - fun visitThresholdTotalAmount( - thresholdTotalAmount: NewPlanThresholdTotalAmountPrice - ): T + override fun hashCode(): Int = hashCode - fun visitTieredPackage(tieredPackage: NewPlanTieredPackagePrice): T + override fun toString() = + "Tier{unitAmount=$unitAmount, tierLowerBound=$tierLowerBound, additionalProperties=$additionalProperties}" + } - fun visitTieredWithMinimum(tieredWithMinimum: NewPlanTieredWithMinimumPrice): T + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice): T + return other is BulkWithFiltersConfig && + filters == other.filters && + tiers == other.tiers && + additionalProperties == other.additionalProperties + } - fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice - ): T + private val hashCode: Int by lazy { + Objects.hash(filters, tiers, additionalProperties) + } - fun visitPackageWithAllocation( - packageWithAllocation: NewPlanPackageWithAllocationPrice - ): T + override fun hashCode(): Int = hashCode - fun visitUnitWithPercent(unitWithPercent: NewPlanUnitWithPercentPrice): T + override fun toString() = + "BulkWithFiltersConfig{filters=$filters, tiers=$tiers, additionalProperties=$additionalProperties}" + } - fun visitMatrixWithAllocation( - matrixWithAllocation: NewPlanMatrixWithAllocationPrice - ): T + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { - fun visitTieredWithProration(tieredWithProration: TieredWithProration): T + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value - fun visitUnitWithProration(unitWithProration: NewPlanUnitWithProrationPrice): T + companion object { - fun visitGroupedAllocation(groupedAllocation: NewPlanGroupedAllocationPrice): T + val ANNUAL = of("annual") - fun visitBulkWithProration(bulkWithProration: NewPlanBulkWithProrationPrice): T + val SEMI_ANNUAL = of("semi_annual") - fun visitGroupedWithProratedMinimum( - groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice - ): T + val MONTHLY = of("monthly") - fun visitGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice - ): T + val QUARTERLY = of("quarterly") - fun visitGroupedWithMinMaxThresholds( - groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds - ): T + val ONE_TIME = of("one_time") - fun visitMatrixWithDisplayName( - matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice - ): T + val CUSTOM = of("custom") - fun visitGroupedTieredPackage( - groupedTieredPackage: NewPlanGroupedTieredPackagePrice - ): T + fun of(value: String) = Cadence(JsonField.of(value)) + } - fun visitMaxGroupTieredPackage( - maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice - ): T + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } - fun visitScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice - ): T + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } - fun visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: NewPlanScalableMatrixWithTieredPricingPrice - ): T + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } - fun visitCumulativeGroupedBulk( - cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice - ): T + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } - fun visitMinimum(minimum: NewPlanMinimumCompositePrice): T + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") - fun visitPercent(percent: Percent): T + private var validated: Boolean = false - fun visitEventOutput(eventOutput: EventOutput): T + fun validate(): Cadence = apply { + if (validated) { + return@apply + } - /** - * Maps an unknown variant of [Price] to a value of type [T]. - * - * An instance of [Price] can contain an unknown variant if it was deserialized from - * data that doesn't match any known variant. For example, if the SDK is on an older - * version than the API, then the API may respond with new variants that the SDK is - * unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown Price: $json") - } - } + known() + validated = true + } - internal class Deserializer : BaseDeserializer(Price::class) { + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - override fun ObjectCodec.deserialize(node: JsonNode): Price { - val json = JsonValue.fromJsonNode(node) - val modelType = json.asObject()?.get("model_type")?.asString() + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - when (modelType) { - "unit" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(unit = it, _json = json) - } ?: Price(_json = json) - } - "tiered" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(tiered = it, _json = json) - } ?: Price(_json = json) - } - "bulk" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(bulk = it, _json = json) - } ?: Price(_json = json) - } - "package" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(package_ = it, _json = json) } ?: Price(_json = json) - } - "matrix" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(matrix = it, _json = json) - } ?: Price(_json = json) - } - "threshold_total_amount" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(thresholdTotalAmount = it, _json = json) } - ?: Price(_json = json) - } - "tiered_package" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(tieredPackage = it, _json = json) } - ?: Price(_json = json) - } - "tiered_with_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(tieredWithMinimum = it, _json = json) } - ?: Price(_json = json) - } - "grouped_tiered" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(groupedTiered = it, _json = json) } - ?: Price(_json = json) - } - "tiered_package_with_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(tieredPackageWithMinimum = it, _json = json) } - ?: Price(_json = json) - } - "package_with_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(packageWithAllocation = it, _json = json) } - ?: Price(_json = json) - } - "unit_with_percent" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(unitWithPercent = it, _json = json) } - ?: Price(_json = json) - } - "matrix_with_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(matrixWithAllocation = it, _json = json) } - ?: Price(_json = json) - } - "tiered_with_proration" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(tieredWithProration = it, _json = json) } - ?: Price(_json = json) - } - "unit_with_proration" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(unitWithProration = it, _json = json) } - ?: Price(_json = json) - } - "grouped_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedAllocation = it, _json = json) } - ?: Price(_json = json) - } - "bulk_with_proration" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(bulkWithProration = it, _json = json) } - ?: Price(_json = json) - } - "grouped_with_prorated_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedWithProratedMinimum = it, _json = json) } - ?: Price(_json = json) - } - "grouped_with_metered_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedWithMeteredMinimum = it, _json = json) } - ?: Price(_json = json) - } - "grouped_with_min_max_thresholds" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedWithMinMaxThresholds = it, _json = json) } - ?: Price(_json = json) - } - "matrix_with_display_name" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(matrixWithDisplayName = it, _json = json) } - ?: Price(_json = json) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - "grouped_tiered_package" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedTieredPackage = it, _json = json) } - ?: Price(_json = json) + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() } - "max_group_tiered_package" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(maxGroupTieredPackage = it, _json = json) } - ?: Price(_json = json) + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) } - "scalable_matrix_with_unit_pricing" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(scalableMatrixWithUnitPricing = it, _json = json) } - ?: Price(_json = json) + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) } - "scalable_matrix_with_tiered_pricing" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(scalableMatrixWithTieredPricing = it, _json = json) } - ?: Price(_json = json) + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) } - "cumulative_grouped_bulk" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(cumulativeGroupedBulk = it, _json = json) } - ?: Price(_json = json) + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply } - "minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(minimum = it, _json = json) } ?: Price(_json = json) + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false } - "percent" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(percent = it, _json = json) - } ?: Price(_json = json) + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() } - "event_output" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(eventOutput = it, _json = json) - } ?: Price(_json = json) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } + + return other is Metadata && + additionalProperties == other.additionalProperties } - return Price(_json = json) - } - } + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - internal class Serializer : BaseSerializer(Price::class) { + override fun hashCode(): Int = hashCode - override fun serialize( - value: Price, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unit != null -> generator.writeObject(value.unit) - value.tiered != null -> generator.writeObject(value.tiered) - value.bulk != null -> generator.writeObject(value.bulk) - value.package_ != null -> generator.writeObject(value.package_) - value.matrix != null -> generator.writeObject(value.matrix) - value.thresholdTotalAmount != null -> - generator.writeObject(value.thresholdTotalAmount) - value.tieredPackage != null -> generator.writeObject(value.tieredPackage) - value.tieredWithMinimum != null -> - generator.writeObject(value.tieredWithMinimum) - value.groupedTiered != null -> generator.writeObject(value.groupedTiered) - value.tieredPackageWithMinimum != null -> - generator.writeObject(value.tieredPackageWithMinimum) - value.packageWithAllocation != null -> - generator.writeObject(value.packageWithAllocation) - value.unitWithPercent != null -> - generator.writeObject(value.unitWithPercent) - value.matrixWithAllocation != null -> - generator.writeObject(value.matrixWithAllocation) - value.tieredWithProration != null -> - generator.writeObject(value.tieredWithProration) - value.unitWithProration != null -> - generator.writeObject(value.unitWithProration) - value.groupedAllocation != null -> - generator.writeObject(value.groupedAllocation) - value.bulkWithProration != null -> - generator.writeObject(value.bulkWithProration) - value.groupedWithProratedMinimum != null -> - generator.writeObject(value.groupedWithProratedMinimum) - value.groupedWithMeteredMinimum != null -> - generator.writeObject(value.groupedWithMeteredMinimum) - value.groupedWithMinMaxThresholds != null -> - generator.writeObject(value.groupedWithMinMaxThresholds) - value.matrixWithDisplayName != null -> - generator.writeObject(value.matrixWithDisplayName) - value.groupedTieredPackage != null -> - generator.writeObject(value.groupedTieredPackage) - value.maxGroupTieredPackage != null -> - generator.writeObject(value.maxGroupTieredPackage) - value.scalableMatrixWithUnitPricing != null -> - generator.writeObject(value.scalableMatrixWithUnitPricing) - value.scalableMatrixWithTieredPricing != null -> - generator.writeObject(value.scalableMatrixWithTieredPricing) - value.cumulativeGroupedBulk != null -> - generator.writeObject(value.cumulativeGroupedBulk) - value.minimum != null -> generator.writeObject(value.minimum) - value.percent != null -> generator.writeObject(value.percent) - value.eventOutput != null -> generator.writeObject(value.eventOutput) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Price") + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } + + return other is BulkWithFilters && + bulkWithFiltersConfig == other.bulkWithFiltersConfig && + cadence == other.cadence && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + bulkWithFiltersConfig, + cadence, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties, + ) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BulkWithFilters{bulkWithFiltersConfig=$bulkWithFiltersConfig, cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } class TieredWithProration diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BetaExternalPlanIdCreatePlanVersionParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BetaExternalPlanIdCreatePlanVersionParams.kt index c4fb755a9..e953d1a3e 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BetaExternalPlanIdCreatePlanVersionParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BetaExternalPlanIdCreatePlanVersionParams.kt @@ -1839,6 +1839,10 @@ private constructor( /** Alias for calling [price] with `Price.ofBulk(bulk)`. */ fun price(bulk: NewPlanBulkPrice) = price(Price.ofBulk(bulk)) + /** Alias for calling [price] with `Price.ofBulkWithFilters(bulkWithFilters)`. */ + fun price(bulkWithFilters: Price.BulkWithFilters) = + price(Price.ofBulkWithFilters(bulkWithFilters)) + /** Alias for calling [price] with `Price.ofPackage(package_)`. */ fun price(package_: NewPlanPackagePrice) = price(Price.ofPackage(package_)) @@ -2050,6 +2054,7 @@ private constructor( private val unit: NewPlanUnitPrice? = null, private val tiered: NewPlanTieredPrice? = null, private val bulk: NewPlanBulkPrice? = null, + private val bulkWithFilters: BulkWithFilters? = null, private val package_: NewPlanPackagePrice? = null, private val matrix: NewPlanMatrixPrice? = null, private val thresholdTotalAmount: NewPlanThresholdTotalAmountPrice? = null, @@ -2088,6 +2093,8 @@ private constructor( fun bulk(): NewPlanBulkPrice? = bulk + fun bulkWithFilters(): BulkWithFilters? = bulkWithFilters + fun package_(): NewPlanPackagePrice? = package_ fun matrix(): NewPlanMatrixPrice? = matrix @@ -2152,6 +2159,8 @@ private constructor( fun isBulk(): Boolean = bulk != null + fun isBulkWithFilters(): Boolean = bulkWithFilters != null + fun isPackage(): Boolean = package_ != null fun isMatrix(): Boolean = matrix != null @@ -2211,6 +2220,8 @@ private constructor( fun asBulk(): NewPlanBulkPrice = bulk.getOrThrow("bulk") + fun asBulkWithFilters(): BulkWithFilters = bulkWithFilters.getOrThrow("bulkWithFilters") + fun asPackage(): NewPlanPackagePrice = package_.getOrThrow("package_") fun asMatrix(): NewPlanMatrixPrice = matrix.getOrThrow("matrix") @@ -2291,6 +2302,7 @@ private constructor( unit != null -> visitor.visitUnit(unit) tiered != null -> visitor.visitTiered(tiered) bulk != null -> visitor.visitBulk(bulk) + bulkWithFilters != null -> visitor.visitBulkWithFilters(bulkWithFilters) package_ != null -> visitor.visitPackage(package_) matrix != null -> visitor.visitMatrix(matrix) thresholdTotalAmount != null -> @@ -2357,6 +2369,10 @@ private constructor( bulk.validate() } + override fun visitBulkWithFilters(bulkWithFilters: BulkWithFilters) { + bulkWithFilters.validate() + } + override fun visitPackage(package_: NewPlanPackagePrice) { package_.validate() } @@ -2527,6 +2543,9 @@ private constructor( override fun visitBulk(bulk: NewPlanBulkPrice) = bulk.validity() + override fun visitBulkWithFilters(bulkWithFilters: BulkWithFilters) = + bulkWithFilters.validity() + override fun visitPackage(package_: NewPlanPackagePrice) = package_.validity() @@ -2636,6 +2655,7 @@ private constructor( unit == other.unit && tiered == other.tiered && bulk == other.bulk && + bulkWithFilters == other.bulkWithFilters && package_ == other.package_ && matrix == other.matrix && thresholdTotalAmount == other.thresholdTotalAmount && @@ -2669,6 +2689,7 @@ private constructor( unit, tiered, bulk, + bulkWithFilters, package_, matrix, thresholdTotalAmount, @@ -2702,6 +2723,7 @@ private constructor( unit != null -> "Price{unit=$unit}" tiered != null -> "Price{tiered=$tiered}" bulk != null -> "Price{bulk=$bulk}" + bulkWithFilters != null -> "Price{bulkWithFilters=$bulkWithFilters}" package_ != null -> "Price{package_=$package_}" matrix != null -> "Price{matrix=$matrix}" thresholdTotalAmount != null -> @@ -2753,6 +2775,9 @@ private constructor( fun ofBulk(bulk: NewPlanBulkPrice) = Price(bulk = bulk) + fun ofBulkWithFilters(bulkWithFilters: BulkWithFilters) = + Price(bulkWithFilters = bulkWithFilters) + fun ofPackage(package_: NewPlanPackagePrice) = Price(package_ = package_) fun ofMatrix(matrix: NewPlanMatrixPrice) = Price(matrix = matrix) @@ -2848,6 +2873,8 @@ private constructor( fun visitBulk(bulk: NewPlanBulkPrice): T + fun visitBulkWithFilters(bulkWithFilters: BulkWithFilters): T + fun visitPackage(package_: NewPlanPackagePrice): T fun visitMatrix(matrix: NewPlanMatrixPrice): T @@ -2963,6 +2990,11 @@ private constructor( Price(bulk = it, _json = json) } ?: Price(_json = json) } + "bulk_with_filters" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(bulkWithFilters = it, _json = json) + } ?: Price(_json = json) + } "package" -> { return tryDeserialize(node, jacksonTypeRef()) ?.let { Price(package_ = it, _json = json) } ?: Price(_json = json) @@ -3165,6 +3197,8 @@ private constructor( value.unit != null -> generator.writeObject(value.unit) value.tiered != null -> generator.writeObject(value.tiered) value.bulk != null -> generator.writeObject(value.bulk) + value.bulkWithFilters != null -> + generator.writeObject(value.bulkWithFilters) value.package_ != null -> generator.writeObject(value.package_) value.matrix != null -> generator.writeObject(value.matrix) value.thresholdTotalAmount != null -> @@ -3216,14 +3250,14 @@ private constructor( } } - class TieredWithProration + class BulkWithFilters @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( + private val bulkWithFiltersConfig: JsonField, private val cadence: JsonField, private val itemId: JsonField, private val modelType: JsonValue, private val name: JsonField, - private val tieredWithProrationConfig: JsonField, private val billableMetricId: JsonField, private val billedInAdvance: JsonField, private val billingCycleConfiguration: JsonField, @@ -3243,6 +3277,9 @@ private constructor( @JsonCreator private constructor( + @JsonProperty("bulk_with_filters_config") + @ExcludeMissing + bulkWithFiltersConfig: JsonField = JsonMissing.of(), @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), @@ -3255,10 +3292,6 @@ private constructor( @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("tiered_with_proration_config") - @ExcludeMissing - tieredWithProrationConfig: JsonField = - JsonMissing.of(), @JsonProperty("billable_metric_id") @ExcludeMissing billableMetricId: JsonField = JsonMissing.of(), @@ -3302,11 +3335,11 @@ private constructor( @ExcludeMissing referenceId: JsonField = JsonMissing.of(), ) : this( + bulkWithFiltersConfig, cadence, itemId, modelType, name, - tieredWithProrationConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -3323,6 +3356,16 @@ private constructor( mutableMapOf(), ) + /** + * Configuration for bulk_with_filters pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun bulkWithFiltersConfig(): BulkWithFiltersConfig = + bulkWithFiltersConfig.getRequired("bulk_with_filters_config") + /** * The cadence to bill for this price on. * @@ -3346,7 +3389,7 @@ private constructor( * * Expected to always return the following: * ```kotlin - * JsonValue.from("tiered_with_proration") + * JsonValue.from("bulk_with_filters") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -3363,16 +3406,6 @@ private constructor( */ fun name(): String = name.getRequired("name") - /** - * Configuration for tiered_with_proration pricing - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun tieredWithProrationConfig(): TieredWithProrationConfig = - tieredWithProrationConfig.getRequired("tiered_with_proration_config") - /** * The id of the billable metric for the price. Only needed if the price is * usage-based. @@ -3492,6 +3525,17 @@ private constructor( */ fun referenceId(): String? = referenceId.getNullable("reference_id") + /** + * Returns the raw JSON value of [bulkWithFiltersConfig]. + * + * Unlike [bulkWithFiltersConfig], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("bulk_with_filters_config") + @ExcludeMissing + fun _bulkWithFiltersConfig(): JsonField = + bulkWithFiltersConfig + /** * Returns the raw JSON value of [cadence]. * @@ -3518,17 +3562,6 @@ private constructor( */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - /** - * Returns the raw JSON value of [tieredWithProrationConfig]. - * - * Unlike [tieredWithProrationConfig], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("tiered_with_proration_config") - @ExcludeMissing - fun _tieredWithProrationConfig(): JsonField = - tieredWithProrationConfig - /** * Returns the raw JSON value of [billableMetricId]. * @@ -3677,29 +3710,27 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [TieredWithProration]. + * Returns a mutable builder for constructing an instance of [BulkWithFilters]. * * The following fields are required: * ```kotlin + * .bulkWithFiltersConfig() * .cadence() * .itemId() * .name() - * .tieredWithProrationConfig() * ``` */ fun builder() = Builder() } - /** A builder for [TieredWithProration]. */ + /** A builder for [BulkWithFilters]. */ class Builder internal constructor() { + private var bulkWithFiltersConfig: JsonField? = null private var cadence: JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonValue = JsonValue.from("tiered_with_proration") + private var modelType: JsonValue = JsonValue.from("bulk_with_filters") private var name: JsonField? = null - private var tieredWithProrationConfig: JsonField? = - null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() private var billingCycleConfiguration: JsonField = @@ -3721,31 +3752,44 @@ private constructor( private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(tieredWithProration: TieredWithProration) = apply { - cadence = tieredWithProration.cadence - itemId = tieredWithProration.itemId - modelType = tieredWithProration.modelType - name = tieredWithProration.name - tieredWithProrationConfig = tieredWithProration.tieredWithProrationConfig - billableMetricId = tieredWithProration.billableMetricId - billedInAdvance = tieredWithProration.billedInAdvance - billingCycleConfiguration = tieredWithProration.billingCycleConfiguration - conversionRate = tieredWithProration.conversionRate - conversionRateConfig = tieredWithProration.conversionRateConfig - currency = tieredWithProration.currency + internal fun from(bulkWithFilters: BulkWithFilters) = apply { + bulkWithFiltersConfig = bulkWithFilters.bulkWithFiltersConfig + cadence = bulkWithFilters.cadence + itemId = bulkWithFilters.itemId + modelType = bulkWithFilters.modelType + name = bulkWithFilters.name + billableMetricId = bulkWithFilters.billableMetricId + billedInAdvance = bulkWithFilters.billedInAdvance + billingCycleConfiguration = bulkWithFilters.billingCycleConfiguration + conversionRate = bulkWithFilters.conversionRate + conversionRateConfig = bulkWithFilters.conversionRateConfig + currency = bulkWithFilters.currency dimensionalPriceConfiguration = - tieredWithProration.dimensionalPriceConfiguration - externalPriceId = tieredWithProration.externalPriceId - fixedPriceQuantity = tieredWithProration.fixedPriceQuantity - invoiceGroupingKey = tieredWithProration.invoiceGroupingKey - invoicingCycleConfiguration = - tieredWithProration.invoicingCycleConfiguration - metadata = tieredWithProration.metadata - referenceId = tieredWithProration.referenceId - additionalProperties = - tieredWithProration.additionalProperties.toMutableMap() + bulkWithFilters.dimensionalPriceConfiguration + externalPriceId = bulkWithFilters.externalPriceId + fixedPriceQuantity = bulkWithFilters.fixedPriceQuantity + invoiceGroupingKey = bulkWithFilters.invoiceGroupingKey + invoicingCycleConfiguration = bulkWithFilters.invoicingCycleConfiguration + metadata = bulkWithFilters.metadata + referenceId = bulkWithFilters.referenceId + additionalProperties = bulkWithFilters.additionalProperties.toMutableMap() } + /** Configuration for bulk_with_filters pricing */ + fun bulkWithFiltersConfig(bulkWithFiltersConfig: BulkWithFiltersConfig) = + bulkWithFiltersConfig(JsonField.of(bulkWithFiltersConfig)) + + /** + * Sets [Builder.bulkWithFiltersConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.bulkWithFiltersConfig] with a well-typed + * [BulkWithFiltersConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun bulkWithFiltersConfig( + bulkWithFiltersConfig: JsonField + ) = apply { this.bulkWithFiltersConfig = bulkWithFiltersConfig } + /** The cadence to bill for this price on. */ fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) @@ -3776,7 +3820,7 @@ private constructor( * It is usually unnecessary to call this method because the field defaults to * the following: * ```kotlin - * JsonValue.from("tiered_with_proration") + * JsonValue.from("bulk_with_filters") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -3796,22 +3840,6 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } - /** Configuration for tiered_with_proration pricing */ - fun tieredWithProrationConfig( - tieredWithProrationConfig: TieredWithProrationConfig - ) = tieredWithProrationConfig(JsonField.of(tieredWithProrationConfig)) - - /** - * Sets [Builder.tieredWithProrationConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.tieredWithProrationConfig] with a well-typed - * [TieredWithProrationConfig] value instead. This method is primarily for - * setting the field to an undocumented or not yet supported value. - */ - fun tieredWithProrationConfig( - tieredWithProrationConfig: JsonField - ) = apply { this.tieredWithProrationConfig = tieredWithProrationConfig } - /** * The id of the billable metric for the price. Only needed if the price is * usage-based. @@ -4141,27 +4169,27 @@ private constructor( } /** - * Returns an immutable instance of [TieredWithProration]. + * Returns an immutable instance of [BulkWithFilters]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```kotlin + * .bulkWithFiltersConfig() * .cadence() * .itemId() * .name() - * .tieredWithProrationConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): TieredWithProration = - TieredWithProration( + fun build(): BulkWithFilters = + BulkWithFilters( + checkRequired("bulkWithFiltersConfig", bulkWithFiltersConfig), checkRequired("cadence", cadence), checkRequired("itemId", itemId), modelType, checkRequired("name", name), - checkRequired("tieredWithProrationConfig", tieredWithProrationConfig), billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -4181,20 +4209,20 @@ private constructor( private var validated: Boolean = false - fun validate(): TieredWithProration = apply { + fun validate(): BulkWithFilters = apply { if (validated) { return@apply } + bulkWithFiltersConfig().validate() cadence().validate() itemId() _modelType().let { - if (it != JsonValue.from("tiered_with_proration")) { + if (it != JsonValue.from("bulk_with_filters")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } name() - tieredWithProrationConfig().validate() billableMetricId() billedInAdvance() billingCycleConfiguration()?.validate() @@ -4226,13 +4254,11 @@ private constructor( * Used for best match union deserialization. */ internal fun validity(): Int = - (cadence.asKnown()?.validity() ?: 0) + + (bulkWithFiltersConfig.asKnown()?.validity() ?: 0) + + (cadence.asKnown()?.validity() ?: 0) + (if (itemId.asKnown() == null) 0 else 1) + - modelType.let { - if (it == JsonValue.from("tiered_with_proration")) 1 else 0 - } + + modelType.let { if (it == JsonValue.from("bulk_with_filters")) 1 else 0 } + (if (name.asKnown() == null) 0 else 1) + - (tieredWithProrationConfig.asKnown()?.validity() ?: 0) + (if (billableMetricId.asKnown() == null) 0 else 1) + (if (billedInAdvance.asKnown() == null) 0 else 1) + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + @@ -4247,201 +4273,66 @@ private constructor( (metadata.asKnown()?.validity() ?: 0) + (if (referenceId.asKnown() == null) 0 else 1) - /** The cadence to bill for this price on. */ - class Cadence - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - val ANNUAL = of("annual") - - val SEMI_ANNUAL = of("semi_annual") - - val MONTHLY = of("monthly") - - val QUARTERLY = of("quarterly") - - val ONE_TIME = of("one_time") - - val CUSTOM = of("custom") - - fun of(value: String) = Cadence(JsonField.of(value)) - } + /** Configuration for bulk_with_filters pricing */ + class BulkWithFiltersConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val filters: JsonField>, + private val tiers: JsonField>, + private val additionalProperties: MutableMap, + ) { - /** An enum containing [Cadence]'s known values. */ - enum class Known { - ANNUAL, - SEMI_ANNUAL, - MONTHLY, - QUARTERLY, - ONE_TIME, - CUSTOM, - } + @JsonCreator + private constructor( + @JsonProperty("filters") + @ExcludeMissing + filters: JsonField> = JsonMissing.of(), + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of(), + ) : this(filters, tiers, mutableMapOf()) /** - * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * Property filters to apply (all must match) * - * An instance of [Cadence] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). */ - enum class Value { - ANNUAL, - SEMI_ANNUAL, - MONTHLY, - QUARTERLY, - ONE_TIME, - CUSTOM, - /** - * An enum member indicating that [Cadence] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } + fun filters(): List = filters.getRequired("filters") /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * Bulk tiers for rating based on total usage volume * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). */ - fun value(): Value = - when (this) { - ANNUAL -> Value.ANNUAL - SEMI_ANNUAL -> Value.SEMI_ANNUAL - MONTHLY -> Value.MONTHLY - QUARTERLY -> Value.QUARTERLY - ONE_TIME -> Value.ONE_TIME - CUSTOM -> Value.CUSTOM - else -> Value._UNKNOWN - } + fun tiers(): List = tiers.getRequired("tiers") /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. + * Returns the raw JSON value of [filters]. * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. + * Unlike [filters], this method doesn't throw if the JSON field has an + * unexpected type. */ - fun known(): Known = - when (this) { - ANNUAL -> Known.ANNUAL - SEMI_ANNUAL -> Known.SEMI_ANNUAL - MONTHLY -> Known.MONTHLY - QUARTERLY -> Known.QUARTERLY - ONE_TIME -> Known.ONE_TIME - CUSTOM -> Known.CUSTOM - else -> throw OrbInvalidDataException("Unknown Cadence: $value") - } + @JsonProperty("filters") + @ExcludeMissing + fun _filters(): JsonField> = filters /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. + * Returns the raw JSON value of [tiers]. * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. */ - fun asString(): String = - _value().asString() - ?: throw OrbInvalidDataException("Value is not a String") - - private var validated: Boolean = false - - fun validate(): Cadence = apply { - if (validated) { - return@apply - } + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Cadence && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** Configuration for tiered_with_proration pricing */ - class TieredWithProrationConfig - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val tiers: JsonField>, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("tiers") - @ExcludeMissing - tiers: JsonField> = JsonMissing.of() - ) : this(tiers, mutableMapOf()) - - /** - * Tiers for rating based on total usage quantities into the specified tier with - * proration - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun tiers(): List = tiers.getRequired("tiers") - - /** - * Returns the raw JSON value of [tiers]. - * - * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("tiers") - @ExcludeMissing - fun _tiers(): JsonField> = tiers - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) } @JsonAnyGetter @@ -4455,34 +4346,60 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [TieredWithProrationConfig]. + * [BulkWithFiltersConfig]. * * The following fields are required: * ```kotlin + * .filters() * .tiers() * ``` */ fun builder() = Builder() } - /** A builder for [TieredWithProrationConfig]. */ + /** A builder for [BulkWithFiltersConfig]. */ class Builder internal constructor() { + private var filters: JsonField>? = null private var tiers: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(tieredWithProrationConfig: TieredWithProrationConfig) = - apply { - tiers = tieredWithProrationConfig.tiers.map { it.toMutableList() } - additionalProperties = - tieredWithProrationConfig.additionalProperties.toMutableMap() - } + internal fun from(bulkWithFiltersConfig: BulkWithFiltersConfig) = apply { + filters = bulkWithFiltersConfig.filters.map { it.toMutableList() } + tiers = bulkWithFiltersConfig.tiers.map { it.toMutableList() } + additionalProperties = + bulkWithFiltersConfig.additionalProperties.toMutableMap() + } + + /** Property filters to apply (all must match) */ + fun filters(filters: List) = filters(JsonField.of(filters)) /** - * Tiers for rating based on total usage quantities into the specified tier - * with proration + * Sets [Builder.filters] to an arbitrary JSON value. + * + * You should usually call [Builder.filters] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun filters(filters: JsonField>) = apply { + this.filters = filters.map { it.toMutableList() } + } + + /** + * Adds a single [Filter] to [filters]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. */ + fun addFilter(filter: Filter) = apply { + filters = + (filters ?: JsonField.of(mutableListOf())).also { + checkKnown("filters", it).add(filter) + } + } + + /** Bulk tiers for rating based on total usage volume */ fun tiers(tiers: List) = tiers(JsonField.of(tiers)) /** @@ -4532,19 +4449,21 @@ private constructor( } /** - * Returns an immutable instance of [TieredWithProrationConfig]. + * Returns an immutable instance of [BulkWithFiltersConfig]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```kotlin + * .filters() * .tiers() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): TieredWithProrationConfig = - TieredWithProrationConfig( + fun build(): BulkWithFiltersConfig = + BulkWithFiltersConfig( + checkRequired("filters", filters).map { it.toImmutable() }, checkRequired("tiers", tiers).map { it.toImmutable() }, additionalProperties.toMutableMap(), ) @@ -4552,11 +4471,12 @@ private constructor( private var validated: Boolean = false - fun validate(): TieredWithProrationConfig = apply { + fun validate(): BulkWithFiltersConfig = apply { if (validated) { return@apply } + filters().forEach { it.validate() } tiers().forEach { it.validate() } validated = true } @@ -4576,65 +4496,65 @@ private constructor( * Used for best match union deserialization. */ internal fun validity(): Int = - (tiers.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + (filters.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + (tiers.asKnown()?.sumOf { it.validity().toInt() } ?: 0) - /** Configuration for a single tiered with proration tier */ - class Tier + /** Configuration for a single property filter */ + class Filter @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val tierLowerBound: JsonField, - private val unitAmount: JsonField, + private val propertyKey: JsonField, + private val propertyValue: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("tier_lower_bound") + @JsonProperty("property_key") @ExcludeMissing - tierLowerBound: JsonField = JsonMissing.of(), - @JsonProperty("unit_amount") + propertyKey: JsonField = JsonMissing.of(), + @JsonProperty("property_value") @ExcludeMissing - unitAmount: JsonField = JsonMissing.of(), - ) : this(tierLowerBound, unitAmount, mutableMapOf()) + propertyValue: JsonField = JsonMissing.of(), + ) : this(propertyKey, propertyValue, mutableMapOf()) /** - * Inclusive tier starting value + * Event property key to filter on * * @throws OrbInvalidDataException if the JSON field has an unexpected type * or is unexpectedly missing or null (e.g. if the server responded with * an unexpected value). */ - fun tierLowerBound(): String = - tierLowerBound.getRequired("tier_lower_bound") + fun propertyKey(): String = propertyKey.getRequired("property_key") /** - * Amount per unit + * Event property value to match * * @throws OrbInvalidDataException if the JSON field has an unexpected type * or is unexpectedly missing or null (e.g. if the server responded with * an unexpected value). */ - fun unitAmount(): String = unitAmount.getRequired("unit_amount") + fun propertyValue(): String = propertyValue.getRequired("property_value") /** - * Returns the raw JSON value of [tierLowerBound]. + * Returns the raw JSON value of [propertyKey]. * - * Unlike [tierLowerBound], this method doesn't throw if the JSON field has - * an unexpected type. + * Unlike [propertyKey], this method doesn't throw if the JSON field has an + * unexpected type. */ - @JsonProperty("tier_lower_bound") + @JsonProperty("property_key") @ExcludeMissing - fun _tierLowerBound(): JsonField = tierLowerBound + fun _propertyKey(): JsonField = propertyKey /** - * Returns the raw JSON value of [unitAmount]. + * Returns the raw JSON value of [propertyValue]. * - * Unlike [unitAmount], this method doesn't throw if the JSON field has an - * unexpected type. + * Unlike [propertyValue], this method doesn't throw if the JSON field has + * an unexpected type. */ - @JsonProperty("unit_amount") + @JsonProperty("property_value") @ExcludeMissing - fun _unitAmount(): JsonField = unitAmount + fun _propertyValue(): JsonField = propertyValue @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -4651,59 +4571,59 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [Tier]. + * Returns a mutable builder for constructing an instance of [Filter]. * * The following fields are required: * ```kotlin - * .tierLowerBound() - * .unitAmount() + * .propertyKey() + * .propertyValue() * ``` */ fun builder() = Builder() } - /** A builder for [Tier]. */ + /** A builder for [Filter]. */ class Builder internal constructor() { - private var tierLowerBound: JsonField? = null - private var unitAmount: JsonField? = null + private var propertyKey: JsonField? = null + private var propertyValue: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(tier: Tier) = apply { - tierLowerBound = tier.tierLowerBound - unitAmount = tier.unitAmount - additionalProperties = tier.additionalProperties.toMutableMap() + internal fun from(filter: Filter) = apply { + propertyKey = filter.propertyKey + propertyValue = filter.propertyValue + additionalProperties = filter.additionalProperties.toMutableMap() } - /** Inclusive tier starting value */ - fun tierLowerBound(tierLowerBound: String) = - tierLowerBound(JsonField.of(tierLowerBound)) + /** Event property key to filter on */ + fun propertyKey(propertyKey: String) = + propertyKey(JsonField.of(propertyKey)) /** - * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * Sets [Builder.propertyKey] to an arbitrary JSON value. * - * You should usually call [Builder.tierLowerBound] with a well-typed + * You should usually call [Builder.propertyKey] with a well-typed * [String] value instead. This method is primarily for setting the * field to an undocumented or not yet supported value. */ - fun tierLowerBound(tierLowerBound: JsonField) = apply { - this.tierLowerBound = tierLowerBound + fun propertyKey(propertyKey: JsonField) = apply { + this.propertyKey = propertyKey } - /** Amount per unit */ - fun unitAmount(unitAmount: String) = - unitAmount(JsonField.of(unitAmount)) + /** Event property value to match */ + fun propertyValue(propertyValue: String) = + propertyValue(JsonField.of(propertyValue)) /** - * Sets [Builder.unitAmount] to an arbitrary JSON value. + * Sets [Builder.propertyValue] to an arbitrary JSON value. * - * You should usually call [Builder.unitAmount] with a well-typed + * You should usually call [Builder.propertyValue] with a well-typed * [String] value instead. This method is primarily for setting the * field to an undocumented or not yet supported value. */ - fun unitAmount(unitAmount: JsonField) = apply { - this.unitAmount = unitAmount + fun propertyValue(propertyValue: JsonField) = apply { + this.propertyValue = propertyValue } fun additionalProperties(additionalProperties: Map) = @@ -4729,36 +4649,36 @@ private constructor( } /** - * Returns an immutable instance of [Tier]. + * Returns an immutable instance of [Filter]. * * Further updates to this [Builder] will not mutate the returned * instance. * * The following fields are required: * ```kotlin - * .tierLowerBound() - * .unitAmount() + * .propertyKey() + * .propertyValue() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): Tier = - Tier( - checkRequired("tierLowerBound", tierLowerBound), - checkRequired("unitAmount", unitAmount), + fun build(): Filter = + Filter( + checkRequired("propertyKey", propertyKey), + checkRequired("propertyValue", propertyValue), additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): Tier = apply { + fun validate(): Filter = apply { if (validated) { return@apply } - tierLowerBound() - unitAmount() + propertyKey() + propertyValue() validated = true } @@ -4777,4573 +4697,3965 @@ private constructor( * Used for best match union deserialization. */ internal fun validity(): Int = - (if (tierLowerBound.asKnown() == null) 0 else 1) + - (if (unitAmount.asKnown() == null) 0 else 1) + (if (propertyKey.asKnown() == null) 0 else 1) + + (if (propertyValue.asKnown() == null) 0 else 1) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is Tier && - tierLowerBound == other.tierLowerBound && - unitAmount == other.unitAmount && + return other is Filter && + propertyKey == other.propertyKey && + propertyValue == other.propertyValue && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(tierLowerBound, unitAmount, additionalProperties) + Objects.hash(propertyKey, propertyValue, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "Tier{tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is TieredWithProrationConfig && - tiers == other.tiers && - additionalProperties == other.additionalProperties + "Filter{propertyKey=$propertyKey, propertyValue=$propertyValue, additionalProperties=$additionalProperties}" } - private val hashCode: Int by lazy { Objects.hash(tiers, additionalProperties) } + /** Configuration for a single bulk pricing tier */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val unitAmount: JsonField, + private val tierLowerBound: JsonField, + private val additionalProperties: MutableMap, + ) { - override fun hashCode(): Int = hashCode + @JsonCreator + private constructor( + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + ) : this(unitAmount, tierLowerBound, mutableMapOf()) - override fun toString() = - "TieredWithProrationConfig{tiers=$tiers, additionalProperties=$additionalProperties}" - } + /** + * Amount per unit + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - class Metadata - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { + /** + * The lower bound for this tier + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun tierLowerBound(): String? = + tierLowerBound.getNullable("tier_lower_bound") - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount - fun toBuilder() = Builder().from(this) + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound - companion object { + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - /** Returns a mutable builder for constructing an instance of [Metadata]. */ - fun builder() = Builder() - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - /** A builder for [Metadata]. */ - class Builder internal constructor() { + fun toBuilder() = Builder().from(this) - private var additionalProperties: MutableMap = - mutableMapOf() + companion object { - internal fun from(metadata: Metadata) = apply { - additionalProperties = metadata.additionalProperties.toMutableMap() + /** + * Returns a mutable builder for constructing an instance of [Tier]. + * + * The following fields are required: + * ```kotlin + * .unitAmount() + * ``` + */ + fun builder() = Builder() } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var unitAmount: JsonField? = null + private var tierLowerBound: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(tier: Tier) = apply { + unitAmount = tier.unitAmount + tierLowerBound = tier.tierLowerBound + additionalProperties = tier.additionalProperties.toMutableMap() } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** Amount per unit */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) + /** The lower bound for this tier */ + fun tierLowerBound(tierLowerBound: String?) = + tierLowerBound(JsonField.ofNullable(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```kotlin + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("unitAmount", unitAmount), + tierLowerBound, + additionalProperties.toMutableMap(), + ) } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + unitAmount() + tierLowerBound() + validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + /** - * Returns an immutable instance of [Metadata]. + * Returns a score indicating how many valid values are contained in this + * object recursively. * - * Further updates to this [Builder] will not mutate the returned instance. + * Used for best match union deserialization. */ - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } + internal fun validity(): Int = + (if (unitAmount.asKnown() == null) 0 else 1) + + (if (tierLowerBound.asKnown() == null) 0 else 1) - private var validated: Boolean = false + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun validate(): Metadata = apply { - if (validated) { - return@apply + return other is Tier && + unitAmount == other.unitAmount && + tierLowerBound == other.tierLowerBound && + additionalProperties == other.additionalProperties } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false + private val hashCode: Int by lazy { + Objects.hash(unitAmount, tierLowerBound, additionalProperties) } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - additionalProperties.count { (_, value) -> - !value.isNull() && !value.isMissing() - } + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{unitAmount=$unitAmount, tierLowerBound=$tierLowerBound, additionalProperties=$additionalProperties}" + } override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is Metadata && + return other is BulkWithFiltersConfig && + filters == other.filters && + tiers == other.tiers && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + private val hashCode: Int by lazy { + Objects.hash(filters, tiers, additionalProperties) + } override fun hashCode(): Int = hashCode - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + override fun toString() = + "BulkWithFiltersConfig{filters=$filters, tiers=$tiers, additionalProperties=$additionalProperties}" } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { - return other is TieredWithProration && - cadence == other.cadence && - itemId == other.itemId && - modelType == other.modelType && - name == other.name && - tieredWithProrationConfig == other.tieredWithProrationConfig && - billableMetricId == other.billableMetricId && - billedInAdvance == other.billedInAdvance && - billingCycleConfiguration == other.billingCycleConfiguration && - conversionRate == other.conversionRate && - conversionRateConfig == other.conversionRateConfig && - currency == other.currency && - dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && - externalPriceId == other.externalPriceId && - fixedPriceQuantity == other.fixedPriceQuantity && - invoiceGroupingKey == other.invoiceGroupingKey && - invoicingCycleConfiguration == other.invoicingCycleConfiguration && - metadata == other.metadata && - referenceId == other.referenceId && - additionalProperties == other.additionalProperties - } + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value - private val hashCode: Int by lazy { - Objects.hash( - cadence, - itemId, - modelType, - name, - tieredWithProrationConfig, - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - conversionRateConfig, - currency, - dimensionalPriceConfiguration, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - additionalProperties, - ) - } + companion object { - override fun hashCode(): Int = hashCode + val ANNUAL = of("annual") - override fun toString() = - "TieredWithProration{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredWithProrationConfig=$tieredWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" - } + val SEMI_ANNUAL = of("semi_annual") - class GroupedWithMinMaxThresholds - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val cadence: JsonField, - private val groupedWithMinMaxThresholdsConfig: - JsonField, - private val itemId: JsonField, - private val modelType: JsonValue, - private val name: JsonField, - private val billableMetricId: JsonField, - private val billedInAdvance: JsonField, - private val billingCycleConfiguration: JsonField, - private val conversionRate: JsonField, - private val conversionRateConfig: JsonField, - private val currency: JsonField, - private val dimensionalPriceConfiguration: - JsonField, - private val externalPriceId: JsonField, - private val fixedPriceQuantity: JsonField, - private val invoiceGroupingKey: JsonField, - private val invoicingCycleConfiguration: JsonField, - private val metadata: JsonField, - private val referenceId: JsonField, - private val additionalProperties: MutableMap, - ) { + val MONTHLY = of("monthly") - @JsonCreator - private constructor( - @JsonProperty("cadence") - @ExcludeMissing - cadence: JsonField = JsonMissing.of(), - @JsonProperty("grouped_with_min_max_thresholds_config") - @ExcludeMissing - groupedWithMinMaxThresholdsConfig: - JsonField = - JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - modelType: JsonValue = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - name: JsonField = JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("conversion_rate_config") - @ExcludeMissing - conversionRateConfig: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - currency: JsonField = JsonMissing.of(), - @JsonProperty("dimensional_price_configuration") - @ExcludeMissing - dimensionalPriceConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - metadata: JsonField = JsonMissing.of(), - @JsonProperty("reference_id") - @ExcludeMissing - referenceId: JsonField = JsonMissing.of(), - ) : this( - cadence, - groupedWithMinMaxThresholdsConfig, - itemId, - modelType, - name, - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - conversionRateConfig, - currency, - dimensionalPriceConfiguration, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - mutableMapOf(), - ) + val QUARTERLY = of("quarterly") - /** - * The cadence to bill for this price on. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun cadence(): Cadence = cadence.getRequired("cadence") + val ONE_TIME = of("one_time") - /** - * Configuration for grouped_with_min_max_thresholds pricing - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun groupedWithMinMaxThresholdsConfig(): GroupedWithMinMaxThresholdsConfig = - groupedWithMinMaxThresholdsConfig.getRequired( - "grouped_with_min_max_thresholds_config" - ) + val CUSTOM = of("custom") - /** - * The id of the item the price will be associated with. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun itemId(): String = itemId.getRequired("item_id") + fun of(value: String) = Cadence(JsonField.of(value)) + } - /** - * The pricing model type - * - * Expected to always return the following: - * ```kotlin - * JsonValue.from("grouped_with_min_max_thresholds") - * ``` - * - * However, this method can be useful for debugging and logging (e.g. if the server - * responded with an unexpected value). - */ - @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } - /** - * The name of the price. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun name(): String = name.getRequired("name") + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun billableMetricId(): String? = billableMetricId.getNullable("billable_metric_id") + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun billingCycleConfiguration(): NewBillingCycleConfiguration? = - billingCycleConfiguration.getNullable("billing_cycle_configuration") + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") - /** - * The per unit conversion rate of the price currency to the invoicing currency. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + private var validated: Boolean = false - /** - * The configuration for the rate of the price currency to the invoicing currency. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun conversionRateConfig(): ConversionRateConfig? = - conversionRateConfig.getNullable("conversion_rate_config") + fun validate(): Cadence = apply { + if (validated) { + return@apply + } - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun currency(): String? = currency.getNullable("currency") + known() + validated = true + } - /** - * For dimensional price: specifies a price group and dimension values - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = - dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - /** - * An alias for the price. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun fixedPriceQuantity(): Double? = - fixedPriceQuantity.getNullable("fixed_price_quantity") + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * The property used to group this price on an invoice - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun invoiceGroupingKey(): String? = - invoiceGroupingKey.getNullable("invoice_grouping_key") + return other is Cadence && value == other.value + } - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by * setting `metadata` to `null`. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). */ - fun metadata(): Metadata? = metadata.getNullable("metadata") + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun referenceId(): String? = referenceId.getNullable("reference_id") + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties - /** - * Returns the raw JSON value of [cadence]. - * - * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("cadence") - @ExcludeMissing - fun _cadence(): JsonField = cadence + fun toBuilder() = Builder().from(this) - /** - * Returns the raw JSON value of [groupedWithMinMaxThresholdsConfig]. - * - * Unlike [groupedWithMinMaxThresholdsConfig], this method doesn't throw if the JSON - * field has an unexpected type. - */ - @JsonProperty("grouped_with_min_max_thresholds_config") - @ExcludeMissing - fun _groupedWithMinMaxThresholdsConfig(): - JsonField = groupedWithMinMaxThresholdsConfig + companion object { - /** - * Returns the raw JSON value of [itemId]. - * - * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } - /** - * Returns the raw JSON value of [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + /** A builder for [Metadata]. */ + class Builder internal constructor() { - /** - * Returns the raw JSON value of [billableMetricId]. - * - * Unlike [billableMetricId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = billableMetricId + private var additionalProperties: MutableMap = + mutableMapOf() - /** - * Returns the raw JSON value of [billedInAdvance]. - * - * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } - /** - * Returns the raw JSON value of [billingCycleConfiguration]. - * - * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** - * Returns the raw JSON value of [conversionRate]. - * - * Unlike [conversionRate], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * Returns the raw JSON value of [conversionRateConfig]. - * - * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("conversion_rate_config") - @ExcludeMissing - fun _conversionRateConfig(): JsonField = conversionRateConfig + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - /** - * Returns the raw JSON value of [currency]. - * - * Unlike [currency], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("currency") - @ExcludeMissing - fun _currency(): JsonField = currency + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - /** - * Returns the raw JSON value of [dimensionalPriceConfiguration]. - * - * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON - * field has an unexpected type. - */ - @JsonProperty("dimensional_price_configuration") - @ExcludeMissing - fun _dimensionalPriceConfiguration(): JsonField = - dimensionalPriceConfiguration + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - /** - * Returns the raw JSON value of [externalPriceId]. - * - * Unlike [externalPriceId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } - /** - * Returns the raw JSON value of [fixedPriceQuantity]. - * - * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** - * Returns the raw JSON value of [invoiceGroupingKey]. - * - * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Returns the raw JSON value of [invoicingCycleConfiguration]. - * - * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * Returns the raw JSON value of [metadata]. - * - * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - /** - * Returns the raw JSON value of [referenceId]. - * - * Unlike [referenceId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("reference_id") - @ExcludeMissing - fun _referenceId(): JsonField = referenceId - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + private var validated: Boolean = false - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + fun validate(): Metadata = apply { + if (validated) { + return@apply + } - fun toBuilder() = Builder().from(this) + validated = true + } - companion object { + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } /** - * Returns a mutable builder for constructing an instance of - * [GroupedWithMinMaxThresholds]. + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * The following fields are required: - * ```kotlin - * .cadence() - * .groupedWithMinMaxThresholdsConfig() - * .itemId() - * .name() - * ``` + * Used for best match union deserialization. */ - fun builder() = Builder() - } - - /** A builder for [GroupedWithMinMaxThresholds]. */ - class Builder internal constructor() { - - private var cadence: JsonField? = null - private var groupedWithMinMaxThresholdsConfig: - JsonField? = - null - private var itemId: JsonField? = null - private var modelType: JsonValue = - JsonValue.from("grouped_with_min_max_thresholds") - private var name: JsonField? = null - private var billableMetricId: JsonField = JsonMissing.of() - private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var conversionRateConfig: JsonField = - JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var dimensionalPriceConfiguration: - JsonField = - JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: - JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var referenceId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } - internal fun from(groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds) = - apply { - cadence = groupedWithMinMaxThresholds.cadence - groupedWithMinMaxThresholdsConfig = - groupedWithMinMaxThresholds.groupedWithMinMaxThresholdsConfig - itemId = groupedWithMinMaxThresholds.itemId - modelType = groupedWithMinMaxThresholds.modelType - name = groupedWithMinMaxThresholds.name - billableMetricId = groupedWithMinMaxThresholds.billableMetricId - billedInAdvance = groupedWithMinMaxThresholds.billedInAdvance - billingCycleConfiguration = - groupedWithMinMaxThresholds.billingCycleConfiguration - conversionRate = groupedWithMinMaxThresholds.conversionRate - conversionRateConfig = groupedWithMinMaxThresholds.conversionRateConfig - currency = groupedWithMinMaxThresholds.currency - dimensionalPriceConfiguration = - groupedWithMinMaxThresholds.dimensionalPriceConfiguration - externalPriceId = groupedWithMinMaxThresholds.externalPriceId - fixedPriceQuantity = groupedWithMinMaxThresholds.fixedPriceQuantity - invoiceGroupingKey = groupedWithMinMaxThresholds.invoiceGroupingKey - invoicingCycleConfiguration = - groupedWithMinMaxThresholds.invoicingCycleConfiguration - metadata = groupedWithMinMaxThresholds.metadata - referenceId = groupedWithMinMaxThresholds.referenceId - additionalProperties = - groupedWithMinMaxThresholds.additionalProperties.toMutableMap() + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + return other is Metadata && + additionalProperties == other.additionalProperties + } - /** - * Sets [Builder.cadence] to an arbitrary JSON value. - * - * You should usually call [Builder.cadence] with a well-typed [Cadence] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /** Configuration for grouped_with_min_max_thresholds pricing */ - fun groupedWithMinMaxThresholdsConfig( - groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig - ) = - groupedWithMinMaxThresholdsConfig( - JsonField.of(groupedWithMinMaxThresholdsConfig) - ) + override fun hashCode(): Int = hashCode - /** - * Sets [Builder.groupedWithMinMaxThresholdsConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.groupedWithMinMaxThresholdsConfig] with a - * well-typed [GroupedWithMinMaxThresholdsConfig] value instead. This method is - * primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun groupedWithMinMaxThresholdsConfig( - groupedWithMinMaxThresholdsConfig: - JsonField - ) = apply { - this.groupedWithMinMaxThresholdsConfig = groupedWithMinMaxThresholdsConfig + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - /** The id of the item the price will be associated with. */ - fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + return other is BulkWithFilters && + bulkWithFiltersConfig == other.bulkWithFiltersConfig && + cadence == other.cadence && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } - /** - * Sets [Builder.itemId] to an arbitrary JSON value. - * - * You should usually call [Builder.itemId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + private val hashCode: Int by lazy { + Objects.hash( + bulkWithFiltersConfig, + cadence, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties, + ) + } - /** - * Sets the field to an arbitrary JSON value. - * - * It is usually unnecessary to call this method because the field defaults to - * the following: - * ```kotlin - * JsonValue.from("grouped_with_min_max_thresholds") - * ``` - * - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + override fun hashCode(): Int = hashCode - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) + override fun toString() = + "BulkWithFilters{bulkWithFiltersConfig=$bulkWithFiltersConfig, cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } - /** - * Sets [Builder.name] to an arbitrary JSON value. - * - * You should usually call [Builder.name] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun name(name: JsonField) = apply { this.name = name } + class TieredWithProration + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val tieredWithProrationConfig: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: String?) = - billableMetricId(JsonField.ofNullable(billableMetricId)) + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("tiered_with_proration_config") + @ExcludeMissing + tieredWithProrationConfig: JsonField = + JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + modelType, + name, + tieredWithProrationConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + mutableMapOf(), + ) - /** - * Sets [Builder.billableMetricId] to an arbitrary JSON value. - * - * You should usually call [Builder.billableMetricId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun billableMetricId(billableMetricId: JsonField) = apply { - this.billableMetricId = billableMetricId - } + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") - /** - * If the Price represents a fixed cost, the price will be billed in-advance if - * this is true, and in-arrears if this is false. - */ - fun billedInAdvance(billedInAdvance: Boolean?) = - billedInAdvance(JsonField.ofNullable(billedInAdvance)) + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") - /** - * Alias for [Builder.billedInAdvance]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun billedInAdvance(billedInAdvance: Boolean) = - billedInAdvance(billedInAdvance as Boolean?) + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("tiered_with_proration") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType - /** - * Sets [Builder.billedInAdvance] to an arbitrary JSON value. - * - * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun billedInAdvance(billedInAdvance: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: NewBillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + /** + * Configuration for tiered_with_proration pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun tieredWithProrationConfig(): TieredWithProrationConfig = + tieredWithProrationConfig.getRequired("tiered_with_proration_config") - /** - * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.billingCycleConfiguration] with a well-typed - * [NewBillingCycleConfiguration] value instead. This method is primarily for - * setting the field to an undocumented or not yet supported value. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: JsonField - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = billableMetricId.getNullable("billable_metric_id") - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: Double?) = - conversionRate(JsonField.ofNullable(conversionRate)) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") - /** - * Alias for [Builder.conversionRate]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") - /** - * Sets [Builder.conversionRate] to an arbitrary JSON value. - * - * You should usually call [Builder.conversionRate] with a well-typed [Double] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") - /** - * The configuration for the rate of the price currency to the invoicing - * currency. - */ - fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = - conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") - /** - * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.conversionRateConfig] with a well-typed - * [ConversionRateConfig] value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun conversionRateConfig( - conversionRateConfig: JsonField - ) = apply { this.conversionRateConfig = conversionRateConfig } + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") - /** - * Alias for calling [conversionRateConfig] with - * `ConversionRateConfig.ofUnit(unit)`. - */ - fun conversionRateConfig(unit: UnitConversionRateConfig) = - conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") - /** - * Alias for calling [conversionRateConfig] with the following: - * ```kotlin - * UnitConversionRateConfig.builder() - * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) - * .unitConfig(unitConfig) - * .build() - * ``` - */ - fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = - conversionRateConfig( - UnitConversionRateConfig.builder() - .conversionRateType( - UnitConversionRateConfig.ConversionRateType.UNIT - ) - .unitConfig(unitConfig) - .build() - ) + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") - /** - * Alias for calling [conversionRateConfig] with - * `ConversionRateConfig.ofTiered(tiered)`. - */ - fun conversionRateConfig(tiered: TieredConversionRateConfig) = - conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") - /** - * Alias for calling [conversionRateConfig] with the following: - * ```kotlin - * TieredConversionRateConfig.builder() - * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) - * .tieredConfig(tieredConfig) - * .build() - * ``` - */ - fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = - conversionRateConfig( - TieredConversionRateConfig.builder() - .conversionRateType( - TieredConversionRateConfig.ConversionRateType.TIERED - ) - .tieredConfig(tieredConfig) - .build() - ) + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + invoiceGroupingKey.getNullable("invoice_grouping_key") - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - /** - * Sets [Builder.currency] to an arbitrary JSON value. - * - * You should usually call [Builder.currency] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") - /** For dimensional price: specifies a price group and dimension values */ - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? - ) = - dimensionalPriceConfiguration( - JsonField.ofNullable(dimensionalPriceConfiguration) - ) + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") - /** - * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.dimensionalPriceConfiguration] with a - * well-typed [NewDimensionalPriceConfiguration] value instead. This method is - * primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: JsonField - ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - /** - * Sets [Builder.externalPriceId] to an arbitrary JSON value. - * - * You should usually call [Builder.externalPriceId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun externalPriceId(externalPriceId: JsonField) = apply { - this.externalPriceId = externalPriceId - } + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = - fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + /** + * Returns the raw JSON value of [tieredWithProrationConfig]. + * + * Unlike [tieredWithProrationConfig], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("tiered_with_proration_config") + @ExcludeMissing + fun _tieredWithProrationConfig(): JsonField = + tieredWithProrationConfig - /** - * Alias for [Builder.fixedPriceQuantity]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId - /** - * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. - * - * You should usually call [Builder.fixedPriceQuantity] with a well-typed - * [Double] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = - invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration - /** - * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. - * - * You should usually call [Builder.invoiceGroupingKey] with a well-typed - * [String] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { - this.invoiceGroupingKey = invoiceGroupingKey - } + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate - /** - * Within each billing cycle, specifies the cadence at which invoices are - * produced. If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: NewBillingCycleConfiguration? - ) = - invoicingCycleConfiguration( - JsonField.ofNullable(invoicingCycleConfiguration) - ) + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig - /** - * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.invoicingCycleConfiguration] with a - * well-typed [NewBillingCycleConfiguration] value instead. This method is - * primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration - /** - * Sets [Builder.metadata] to an arbitrary JSON value. - * - * You should usually call [Builder.metadata] with a well-typed [Metadata] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - fun referenceId(referenceId: String?) = - referenceId(JsonField.ofNullable(referenceId)) + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - /** - * Sets [Builder.referenceId] to an arbitrary JSON value. - * - * You should usually call [Builder.referenceId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun referenceId(referenceId: JsonField) = apply { - this.referenceId = referenceId - } + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { /** - * Returns an immutable instance of [GroupedWithMinMaxThresholds]. - * - * Further updates to this [Builder] will not mutate the returned instance. + * Returns a mutable builder for constructing an instance of + * [TieredWithProration]. * * The following fields are required: * ```kotlin * .cadence() - * .groupedWithMinMaxThresholdsConfig() * .itemId() * .name() + * .tieredWithProrationConfig() * ``` - * - * @throws IllegalStateException if any required field is unset. */ - fun build(): GroupedWithMinMaxThresholds = - GroupedWithMinMaxThresholds( - checkRequired("cadence", cadence), - checkRequired( - "groupedWithMinMaxThresholdsConfig", - groupedWithMinMaxThresholdsConfig, - ), - checkRequired("itemId", itemId), - modelType, - checkRequired("name", name), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - conversionRateConfig, - currency, - dimensionalPriceConfiguration, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - additionalProperties.toMutableMap(), - ) + fun builder() = Builder() } - private var validated: Boolean = false - - fun validate(): GroupedWithMinMaxThresholds = apply { - if (validated) { - return@apply - } + /** A builder for [TieredWithProration]. */ + class Builder internal constructor() { - cadence().validate() - groupedWithMinMaxThresholdsConfig().validate() - itemId() - _modelType().let { - if (it != JsonValue.from("grouped_with_min_max_thresholds")) { - throw OrbInvalidDataException("'modelType' is invalid, received $it") - } - } - name() - billableMetricId() - billedInAdvance() - billingCycleConfiguration()?.validate() - conversionRate() - conversionRateConfig()?.validate() - currency() - dimensionalPriceConfiguration()?.validate() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration()?.validate() - metadata()?.validate() - referenceId() - validated = true - } + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonValue = JsonValue.from("tiered_with_proration") + private var name: JsonField? = null + private var tieredWithProrationConfig: JsonField? = + null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false + internal fun from(tieredWithProration: TieredWithProration) = apply { + cadence = tieredWithProration.cadence + itemId = tieredWithProration.itemId + modelType = tieredWithProration.modelType + name = tieredWithProration.name + tieredWithProrationConfig = tieredWithProration.tieredWithProrationConfig + billableMetricId = tieredWithProration.billableMetricId + billedInAdvance = tieredWithProration.billedInAdvance + billingCycleConfiguration = tieredWithProration.billingCycleConfiguration + conversionRate = tieredWithProration.conversionRate + conversionRateConfig = tieredWithProration.conversionRateConfig + currency = tieredWithProration.currency + dimensionalPriceConfiguration = + tieredWithProration.dimensionalPriceConfiguration + externalPriceId = tieredWithProration.externalPriceId + fixedPriceQuantity = tieredWithProration.fixedPriceQuantity + invoiceGroupingKey = tieredWithProration.invoiceGroupingKey + invoicingCycleConfiguration = + tieredWithProration.invoicingCycleConfiguration + metadata = tieredWithProration.metadata + referenceId = tieredWithProration.referenceId + additionalProperties = + tieredWithProration.additionalProperties.toMutableMap() } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (cadence.asKnown()?.validity() ?: 0) + - (groupedWithMinMaxThresholdsConfig.asKnown()?.validity() ?: 0) + - (if (itemId.asKnown() == null) 0 else 1) + - modelType.let { - if (it == JsonValue.from("grouped_with_min_max_thresholds")) 1 else 0 - } + - (if (name.asKnown() == null) 0 else 1) + - (if (billableMetricId.asKnown() == null) 0 else 1) + - (if (billedInAdvance.asKnown() == null) 0 else 1) + - (billingCycleConfiguration.asKnown()?.validity() ?: 0) + - (if (conversionRate.asKnown() == null) 0 else 1) + - (conversionRateConfig.asKnown()?.validity() ?: 0) + - (if (currency.asKnown() == null) 0 else 1) + - (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + - (if (externalPriceId.asKnown() == null) 0 else 1) + - (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + - (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + - (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + - (metadata.asKnown()?.validity() ?: 0) + - (if (referenceId.asKnown() == null) 0 else 1) - - /** The cadence to bill for this price on. */ - class Cadence - @JsonCreator - private constructor(private val value: JsonField) : Enum { + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) /** - * Returns this class instance's raw value. + * Sets [Builder.cadence] to an arbitrary JSON value. * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - val ANNUAL = of("annual") + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - val SEMI_ANNUAL = of("semi_annual") + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - val MONTHLY = of("monthly") + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("tiered_with_proration") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } - val QUARTERLY = of("quarterly") + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) - val ONE_TIME = of("one_time") + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } - val CUSTOM = of("custom") + /** Configuration for tiered_with_proration pricing */ + fun tieredWithProrationConfig( + tieredWithProrationConfig: TieredWithProrationConfig + ) = tieredWithProrationConfig(JsonField.of(tieredWithProrationConfig)) - fun of(value: String) = Cadence(JsonField.of(value)) - } + /** + * Sets [Builder.tieredWithProrationConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.tieredWithProrationConfig] with a well-typed + * [TieredWithProrationConfig] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun tieredWithProrationConfig( + tieredWithProrationConfig: JsonField + ) = apply { this.tieredWithProrationConfig = tieredWithProrationConfig } - /** An enum containing [Cadence]'s known values. */ - enum class Known { - ANNUAL, - SEMI_ANNUAL, - MONTHLY, - QUARTERLY, - ONE_TIME, - CUSTOM, - } + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) /** - * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * Sets [Builder.billableMetricId] to an arbitrary JSON value. * - * An instance of [Cadence] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. */ - enum class Value { - ANNUAL, - SEMI_ANNUAL, - MONTHLY, - QUARTERLY, - ONE_TIME, - CUSTOM, - /** - * An enum member indicating that [Cadence] was instantiated with an unknown - * value. - */ - _UNKNOWN, + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId } /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. */ - fun value(): Value = - when (this) { - ANNUAL -> Value.ANNUAL - SEMI_ANNUAL -> Value.SEMI_ANNUAL - MONTHLY -> Value.MONTHLY - QUARTERLY -> Value.QUARTERLY - ONE_TIME -> Value.ONE_TIME - CUSTOM -> Value.CUSTOM - else -> Value._UNKNOWN - } + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) /** - * Returns an enum member corresponding to this class instance's value. + * Alias for [Builder.billedInAdvance]. * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. */ - fun known(): Known = - when (this) { - ANNUAL -> Known.ANNUAL - SEMI_ANNUAL -> Known.SEMI_ANNUAL - MONTHLY -> Known.MONTHLY - QUARTERLY -> Known.QUARTERLY - ONE_TIME -> Known.ONE_TIME - CUSTOM -> Known.CUSTOM - else -> throw OrbInvalidDataException("Unknown Cadence: $value") - } + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. */ - fun asString(): String = - _value().asString() - ?: throw OrbInvalidDataException("Value is not a String") + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } - private var validated: Boolean = false + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) - fun validate(): Cadence = apply { - if (validated) { - return@apply - } + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) - known() - validated = true + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) /** - * Returns a score indicating how many valid values are contained in this object - * recursively. + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. * - * Used for best match union deserialization. + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. */ - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Cadence && value == other.value - } - - override fun hashCode() = value.hashCode() + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } - override fun toString() = value.toString() - } + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) - /** Configuration for grouped_with_min_max_thresholds pricing */ - class GroupedWithMinMaxThresholdsConfig - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val groupingKey: JsonField, - private val maximumCharge: JsonField, - private val minimumCharge: JsonField, - private val perUnitRate: JsonField, - private val additionalProperties: MutableMap, - ) { + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) - @JsonCreator - private constructor( - @JsonProperty("grouping_key") - @ExcludeMissing - groupingKey: JsonField = JsonMissing.of(), - @JsonProperty("maximum_charge") - @ExcludeMissing - maximumCharge: JsonField = JsonMissing.of(), - @JsonProperty("minimum_charge") - @ExcludeMissing - minimumCharge: JsonField = JsonMissing.of(), - @JsonProperty("per_unit_rate") - @ExcludeMissing - perUnitRate: JsonField = JsonMissing.of(), - ) : this(groupingKey, maximumCharge, minimumCharge, perUnitRate, mutableMapOf()) + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) /** - * The event property used to group before applying thresholds - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` */ - fun groupingKey(): String = groupingKey.getRequired("grouping_key") + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) /** - * The maximum amount to charge each group - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. */ - fun maximumCharge(): String = maximumCharge.getRequired("maximum_charge") + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) /** - * The minimum amount to charge each group, regardless of usage + * Sets [Builder.currency] to an arbitrary JSON value. * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. */ - fun minimumCharge(): String = minimumCharge.getRequired("minimum_charge") + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) /** - * The base price charged per group + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. */ - fun perUnitRate(): String = perUnitRate.getRequired("per_unit_rate") + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) /** - * Returns the raw JSON value of [groupingKey]. + * Sets [Builder.externalPriceId] to an arbitrary JSON value. * - * Unlike [groupingKey], this method doesn't throw if the JSON field has an - * unexpected type. + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. */ - @JsonProperty("grouping_key") - @ExcludeMissing - fun _groupingKey(): JsonField = groupingKey + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } /** - * Returns the raw JSON value of [maximumCharge]. - * - * Unlike [maximumCharge], this method doesn't throw if the JSON field has an - * unexpected type. + * If the Price represents a fixed cost, this represents the quantity of units + * applied. */ - @JsonProperty("maximum_charge") - @ExcludeMissing - fun _maximumCharge(): JsonField = maximumCharge + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) /** - * Returns the raw JSON value of [minimumCharge]. + * Alias for [Builder.fixedPriceQuantity]. * - * Unlike [minimumCharge], this method doesn't throw if the JSON field has an - * unexpected type. + * This unboxed primitive overload exists for backwards compatibility. */ - @JsonProperty("minimum_charge") - @ExcludeMissing - fun _minimumCharge(): JsonField = minimumCharge + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) /** - * Returns the raw JSON value of [perUnitRate]. + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. * - * Unlike [perUnitRate], this method doesn't throw if the JSON field has an - * unexpected type. + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. */ - @JsonProperty("per_unit_rate") - @ExcludeMissing - fun _perUnitRate(): JsonField = perUnitRate - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) - /** - * Returns a mutable builder for constructing an instance of - * [GroupedWithMinMaxThresholdsConfig]. - * - * The following fields are required: - * ```kotlin - * .groupingKey() - * .maximumCharge() - * .minimumCharge() - * .perUnitRate() - * ``` - */ - fun builder() = Builder() + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey } - /** A builder for [GroupedWithMinMaxThresholdsConfig]. */ - class Builder internal constructor() { - - private var groupingKey: JsonField? = null - private var maximumCharge: JsonField? = null - private var minimumCharge: JsonField? = null - private var perUnitRate: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - internal fun from( - groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig - ) = apply { - groupingKey = groupedWithMinMaxThresholdsConfig.groupingKey - maximumCharge = groupedWithMinMaxThresholdsConfig.maximumCharge - minimumCharge = groupedWithMinMaxThresholdsConfig.minimumCharge - perUnitRate = groupedWithMinMaxThresholdsConfig.perUnitRate - additionalProperties = - groupedWithMinMaxThresholdsConfig.additionalProperties - .toMutableMap() - } - - /** The event property used to group before applying thresholds */ - fun groupingKey(groupingKey: String) = - groupingKey(JsonField.of(groupingKey)) - - /** - * Sets [Builder.groupingKey] to an arbitrary JSON value. - * - * You should usually call [Builder.groupingKey] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun groupingKey(groupingKey: JsonField) = apply { - this.groupingKey = groupingKey - } - - /** The maximum amount to charge each group */ - fun maximumCharge(maximumCharge: String) = - maximumCharge(JsonField.of(maximumCharge)) - - /** - * Sets [Builder.maximumCharge] to an arbitrary JSON value. - * - * You should usually call [Builder.maximumCharge] with a well-typed - * [String] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun maximumCharge(maximumCharge: JsonField) = apply { - this.maximumCharge = maximumCharge - } - - /** The minimum amount to charge each group, regardless of usage */ - fun minimumCharge(minimumCharge: String) = - minimumCharge(JsonField.of(minimumCharge)) - - /** - * Sets [Builder.minimumCharge] to an arbitrary JSON value. - * - * You should usually call [Builder.minimumCharge] with a well-typed - * [String] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun minimumCharge(minimumCharge: JsonField) = apply { - this.minimumCharge = minimumCharge - } - - /** The base price charged per group */ - fun perUnitRate(perUnitRate: String) = - perUnitRate(JsonField.of(perUnitRate)) - - /** - * Sets [Builder.perUnitRate] to an arbitrary JSON value. - * - * You should usually call [Builder.perUnitRate] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun perUnitRate(perUnitRate: JsonField) = apply { - this.perUnitRate = perUnitRate - } + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } - /** - * Returns an immutable instance of [GroupedWithMinMaxThresholdsConfig]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```kotlin - * .groupingKey() - * .maximumCharge() - * .minimumCharge() - * .perUnitRate() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): GroupedWithMinMaxThresholdsConfig = - GroupedWithMinMaxThresholdsConfig( - checkRequired("groupingKey", groupingKey), - checkRequired("maximumCharge", maximumCharge), - checkRequired("minimumCharge", minimumCharge), - checkRequired("perUnitRate", perUnitRate), - additionalProperties.toMutableMap(), - ) + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) } - private var validated: Boolean = false + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun validate(): GroupedWithMinMaxThresholdsConfig = apply { - if (validated) { - return@apply + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) } - groupingKey() - maximumCharge() - minimumCharge() - perUnitRate() - validated = true + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } /** - * Returns a score indicating how many valid values are contained in this object - * recursively. + * Returns an immutable instance of [TieredWithProration]. * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (if (groupingKey.asKnown() == null) 0 else 1) + - (if (maximumCharge.asKnown() == null) 0 else 1) + - (if (minimumCharge.asKnown() == null) 0 else 1) + - (if (perUnitRate.asKnown() == null) 0 else 1) + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .name() + * .tieredWithProrationConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TieredWithProration = + TieredWithProration( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + modelType, + checkRequired("name", name), + checkRequired("tieredWithProrationConfig", tieredWithProrationConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + private var validated: Boolean = false - return other is GroupedWithMinMaxThresholdsConfig && - groupingKey == other.groupingKey && - maximumCharge == other.maximumCharge && - minimumCharge == other.minimumCharge && - perUnitRate == other.perUnitRate && - additionalProperties == other.additionalProperties + fun validate(): TieredWithProration = apply { + if (validated) { + return@apply } - private val hashCode: Int by lazy { - Objects.hash( - groupingKey, - maximumCharge, - minimumCharge, - perUnitRate, - additionalProperties, - ) + cadence().validate() + itemId() + _modelType().let { + if (it != JsonValue.from("tiered_with_proration")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "GroupedWithMinMaxThresholdsConfig{groupingKey=$groupingKey, maximumCharge=$maximumCharge, minimumCharge=$minimumCharge, perUnitRate=$perUnitRate, additionalProperties=$additionalProperties}" + name() + tieredWithProrationConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + metadata()?.validate() + referenceId() + validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. */ - class Metadata - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + modelType.let { + if (it == JsonValue.from("tiered_with_proration")) 1 else 0 + } + + (if (name.asKnown() == null) 0 else 1) + + (tieredWithProrationConfig.asKnown()?.validity() ?: 0) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { - fun toBuilder() = Builder().from(this) + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { - /** Returns a mutable builder for constructing an instance of [Metadata]. */ - fun builder() = Builder() - } - - /** A builder for [Metadata]. */ - class Builder internal constructor() { + val ANNUAL = of("annual") - private var additionalProperties: MutableMap = - mutableMapOf() + val SEMI_ANNUAL = of("semi_annual") - internal fun from(metadata: Metadata) = apply { - additionalProperties = metadata.additionalProperties.toMutableMap() - } + val MONTHLY = of("monthly") - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + val QUARTERLY = of("quarterly") - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + val ONE_TIME = of("one_time") - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + val CUSTOM = of("custom") - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun of(value: String) = Cadence(JsonField.of(value)) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, /** - * Returns an immutable instance of [Metadata]. - * - * Further updates to this [Builder] will not mutate the returned instance. + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. */ - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true + _UNKNOWN, } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. * - * Used for best match union deserialization. + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. */ - internal fun validity(): Int = - additionalProperties.count { (_, value) -> - !value.isNull() && !value.isMissing() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN } - return other is Metadata && - additionalProperties == other.additionalProperties + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true } - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - override fun hashCode(): Int = hashCode + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + return other is Cadence && value == other.value } - return other is GroupedWithMinMaxThresholds && - cadence == other.cadence && - groupedWithMinMaxThresholdsConfig == - other.groupedWithMinMaxThresholdsConfig && - itemId == other.itemId && - modelType == other.modelType && - name == other.name && - billableMetricId == other.billableMetricId && - billedInAdvance == other.billedInAdvance && - billingCycleConfiguration == other.billingCycleConfiguration && - conversionRate == other.conversionRate && - conversionRateConfig == other.conversionRateConfig && - currency == other.currency && - dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && - externalPriceId == other.externalPriceId && - fixedPriceQuantity == other.fixedPriceQuantity && - invoiceGroupingKey == other.invoiceGroupingKey && - invoicingCycleConfiguration == other.invoicingCycleConfiguration && - metadata == other.metadata && - referenceId == other.referenceId && - additionalProperties == other.additionalProperties - } + override fun hashCode() = value.hashCode() - private val hashCode: Int by lazy { - Objects.hash( - cadence, - groupedWithMinMaxThresholdsConfig, - itemId, - modelType, - name, - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - conversionRateConfig, - currency, - dimensionalPriceConfiguration, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - additionalProperties, - ) + override fun toString() = value.toString() } - override fun hashCode(): Int = hashCode + /** Configuration for tiered_with_proration pricing */ + class TieredWithProrationConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val tiers: JsonField>, + private val additionalProperties: MutableMap, + ) { - override fun toString() = - "GroupedWithMinMaxThresholds{cadence=$cadence, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" - } + @JsonCreator + private constructor( + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of() + ) : this(tiers, mutableMapOf()) - class Percent - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val cadence: JsonField, - private val itemId: JsonField, - private val modelType: JsonValue, - private val name: JsonField, - private val percentConfig: JsonField, - private val billableMetricId: JsonField, - private val billedInAdvance: JsonField, - private val billingCycleConfiguration: JsonField, - private val conversionRate: JsonField, - private val conversionRateConfig: JsonField, - private val currency: JsonField, - private val dimensionalPriceConfiguration: - JsonField, - private val externalPriceId: JsonField, - private val fixedPriceQuantity: JsonField, - private val invoiceGroupingKey: JsonField, - private val invoicingCycleConfiguration: JsonField, - private val metadata: JsonField, - private val referenceId: JsonField, - private val additionalProperties: MutableMap, - ) { + /** + * Tiers for rating based on total usage quantities into the specified tier with + * proration + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun tiers(): List = tiers.getRequired("tiers") - @JsonCreator - private constructor( - @JsonProperty("cadence") - @ExcludeMissing - cadence: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - modelType: JsonValue = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - name: JsonField = JsonMissing.of(), - @JsonProperty("percent_config") - @ExcludeMissing - percentConfig: JsonField = JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("conversion_rate_config") - @ExcludeMissing - conversionRateConfig: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - currency: JsonField = JsonMissing.of(), - @JsonProperty("dimensional_price_configuration") - @ExcludeMissing - dimensionalPriceConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - metadata: JsonField = JsonMissing.of(), - @JsonProperty("reference_id") + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tiers") @ExcludeMissing - referenceId: JsonField = JsonMissing.of(), - ) : this( - cadence, - itemId, - modelType, - name, - percentConfig, - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - conversionRateConfig, - currency, - dimensionalPriceConfiguration, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - mutableMapOf(), - ) + fun _tiers(): JsonField> = tiers - /** - * The cadence to bill for this price on. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun cadence(): Cadence = cadence.getRequired("cadence") + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - /** - * The id of the item the price will be associated with. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun itemId(): String = itemId.getRequired("item_id") + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - /** - * The pricing model type - * - * Expected to always return the following: - * ```kotlin - * JsonValue.from("percent") - * ``` - * - * However, this method can be useful for debugging and logging (e.g. if the server - * responded with an unexpected value). - */ - @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + fun toBuilder() = Builder().from(this) - /** - * The name of the price. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun name(): String = name.getRequired("name") + companion object { - /** - * Configuration for percent pricing - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun percentConfig(): PercentConfig = percentConfig.getRequired("percent_config") + /** + * Returns a mutable builder for constructing an instance of + * [TieredWithProrationConfig]. + * + * The following fields are required: + * ```kotlin + * .tiers() + * ``` + */ + fun builder() = Builder() + } - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun billableMetricId(): String? = billableMetricId.getNullable("billable_metric_id") + /** A builder for [TieredWithProrationConfig]. */ + class Builder internal constructor() { - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + private var tiers: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun billingCycleConfiguration(): NewBillingCycleConfiguration? = - billingCycleConfiguration.getNullable("billing_cycle_configuration") + internal fun from(tieredWithProrationConfig: TieredWithProrationConfig) = + apply { + tiers = tieredWithProrationConfig.tiers.map { it.toMutableList() } + additionalProperties = + tieredWithProrationConfig.additionalProperties.toMutableMap() + } - /** - * The per unit conversion rate of the price currency to the invoicing currency. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + /** + * Tiers for rating based on total usage quantities into the specified tier + * with proration + */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) - /** - * The configuration for the rate of the price currency to the invoicing currency. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun conversionRateConfig(): ConversionRateConfig? = - conversionRateConfig.getNullable("conversion_rate_config") + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun currency(): String? = currency.getNullable("currency") + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } - /** - * For dimensional price: specifies a price group and dimension values - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = - dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** - * An alias for the price. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun fixedPriceQuantity(): Double? = - fixedPriceQuantity.getNullable("fixed_price_quantity") + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - /** - * The property used to group this price on an invoice - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun invoiceGroupingKey(): String? = - invoiceGroupingKey.getNullable("invoice_grouping_key") + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun metadata(): Metadata? = metadata.getNullable("metadata") + /** + * Returns an immutable instance of [TieredWithProrationConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TieredWithProrationConfig = + TieredWithProrationConfig( + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun referenceId(): String? = referenceId.getNullable("reference_id") + private var validated: Boolean = false - /** - * Returns the raw JSON value of [cadence]. - * - * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("cadence") - @ExcludeMissing - fun _cadence(): JsonField = cadence + fun validate(): TieredWithProrationConfig = apply { + if (validated) { + return@apply + } - /** - * Returns the raw JSON value of [itemId]. - * - * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + tiers().forEach { it.validate() } + validated = true + } - /** - * Returns the raw JSON value of [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - /** - * Returns the raw JSON value of [percentConfig]. - * - * Unlike [percentConfig], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("percent_config") - @ExcludeMissing - fun _percentConfig(): JsonField = percentConfig + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (tiers.asKnown()?.sumOf { it.validity().toInt() } ?: 0) - /** - * Returns the raw JSON value of [billableMetricId]. - * - * Unlike [billableMetricId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = billableMetricId + /** Configuration for a single tiered with proration tier */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val tierLowerBound: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { - /** - * Returns the raw JSON value of [billedInAdvance]. - * - * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance + @JsonCreator + private constructor( + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(tierLowerBound, unitAmount, mutableMapOf()) - /** - * Returns the raw JSON value of [billingCycleConfiguration]. - * - * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration + /** + * Inclusive tier starting value + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun tierLowerBound(): String = + tierLowerBound.getRequired("tier_lower_bound") - /** - * Returns the raw JSON value of [conversionRate]. - * - * Unlike [conversionRate], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate + /** + * Amount per unit + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") - /** - * Returns the raw JSON value of [conversionRateConfig]. - * - * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("conversion_rate_config") - @ExcludeMissing - fun _conversionRateConfig(): JsonField = conversionRateConfig + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound - /** - * Returns the raw JSON value of [currency]. - * - * Unlike [currency], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("currency") - @ExcludeMissing - fun _currency(): JsonField = currency + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount - /** - * Returns the raw JSON value of [dimensionalPriceConfiguration]. - * - * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON - * field has an unexpected type. - */ - @JsonProperty("dimensional_price_configuration") - @ExcludeMissing - fun _dimensionalPriceConfiguration(): JsonField = - dimensionalPriceConfiguration + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - /** - * Returns the raw JSON value of [externalPriceId]. - * - * Unlike [externalPriceId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - /** - * Returns the raw JSON value of [fixedPriceQuantity]. - * - * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + fun toBuilder() = Builder().from(this) - /** - * Returns the raw JSON value of [invoiceGroupingKey]. - * - * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + companion object { - /** - * Returns the raw JSON value of [invoicingCycleConfiguration]. - * - * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration + /** + * Returns a mutable builder for constructing an instance of [Tier]. + * + * The following fields are required: + * ```kotlin + * .tierLowerBound() + * .unitAmount() + * ``` + */ + fun builder() = Builder() + } - /** - * Returns the raw JSON value of [metadata]. - * - * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata + /** A builder for [Tier]. */ + class Builder internal constructor() { - /** - * Returns the raw JSON value of [referenceId]. - * - * Unlike [referenceId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("reference_id") - @ExcludeMissing - fun _referenceId(): JsonField = referenceId + private var tierLowerBound: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + internal fun from(tier: Tier) = apply { + tierLowerBound = tier.tierLowerBound + unitAmount = tier.unitAmount + additionalProperties = tier.additionalProperties.toMutableMap() + } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** Inclusive tier starting value */ + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) - fun toBuilder() = Builder().from(this) + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } - companion object { + /** Amount per unit */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) - /** - * Returns a mutable builder for constructing an instance of [Percent]. - * - * The following fields are required: - * ```kotlin - * .cadence() - * .itemId() - * .name() - * .percentConfig() - * ``` - */ - fun builder() = Builder() - } + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } - /** A builder for [Percent]. */ - class Builder internal constructor() { + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - private var cadence: JsonField? = null - private var itemId: JsonField? = null - private var modelType: JsonValue = JsonValue.from("percent") - private var name: JsonField? = null - private var percentConfig: JsonField? = null - private var billableMetricId: JsonField = JsonMissing.of() - private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var conversionRateConfig: JsonField = - JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var dimensionalPriceConfiguration: - JsonField = - JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: - JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var referenceId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - internal fun from(percent: Percent) = apply { - cadence = percent.cadence - itemId = percent.itemId - modelType = percent.modelType - name = percent.name - percentConfig = percent.percentConfig - billableMetricId = percent.billableMetricId - billedInAdvance = percent.billedInAdvance - billingCycleConfiguration = percent.billingCycleConfiguration - conversionRate = percent.conversionRate - conversionRateConfig = percent.conversionRateConfig - currency = percent.currency - dimensionalPriceConfiguration = percent.dimensionalPriceConfiguration - externalPriceId = percent.externalPriceId - fixedPriceQuantity = percent.fixedPriceQuantity - invoiceGroupingKey = percent.invoiceGroupingKey - invoicingCycleConfiguration = percent.invoicingCycleConfiguration - metadata = percent.metadata - referenceId = percent.referenceId - additionalProperties = percent.additionalProperties.toMutableMap() - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - /** - * Sets [Builder.cadence] to an arbitrary JSON value. - * - * You should usually call [Builder.cadence] with a well-typed [Cadence] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - /** The id of the item the price will be associated with. */ - fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + /** + * Returns an immutable instance of [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```kotlin + * .tierLowerBound() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("tierLowerBound", tierLowerBound), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } - /** - * Sets [Builder.itemId] to an arbitrary JSON value. - * - * You should usually call [Builder.itemId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + private var validated: Boolean = false - /** - * Sets the field to an arbitrary JSON value. - * - * It is usually unnecessary to call this method because the field defaults to - * the following: - * ```kotlin - * JsonValue.from("percent") - * ``` - * - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + fun validate(): Tier = apply { + if (validated) { + return@apply + } - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) + tierLowerBound() + unitAmount() + validated = true + } - /** - * Sets [Builder.name] to an arbitrary JSON value. - * - * You should usually call [Builder.name] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun name(name: JsonField) = apply { this.name = name } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - /** Configuration for percent pricing */ - fun percentConfig(percentConfig: PercentConfig) = - percentConfig(JsonField.of(percentConfig)) + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (tierLowerBound.asKnown() == null) 0 else 1) + + (if (unitAmount.asKnown() == null) 0 else 1) - /** - * Sets [Builder.percentConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.percentConfig] with a well-typed - * [PercentConfig] value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. - */ - fun percentConfig(percentConfig: JsonField) = apply { - this.percentConfig = percentConfig + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + tierLowerBound == other.tierLowerBound && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(tierLowerBound, unitAmount, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" } - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: String?) = - billableMetricId(JsonField.ofNullable(billableMetricId)) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * Sets [Builder.billableMetricId] to an arbitrary JSON value. - * - * You should usually call [Builder.billableMetricId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun billableMetricId(billableMetricId: JsonField) = apply { - this.billableMetricId = billableMetricId + return other is TieredWithProrationConfig && + tiers == other.tiers && + additionalProperties == other.additionalProperties } - /** - * If the Price represents a fixed cost, the price will be billed in-advance if - * this is true, and in-arrears if this is false. - */ - fun billedInAdvance(billedInAdvance: Boolean?) = - billedInAdvance(JsonField.ofNullable(billedInAdvance)) + private val hashCode: Int by lazy { Objects.hash(tiers, additionalProperties) } - /** - * Alias for [Builder.billedInAdvance]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun billedInAdvance(billedInAdvance: Boolean) = - billedInAdvance(billedInAdvance as Boolean?) + override fun hashCode(): Int = hashCode - /** - * Sets [Builder.billedInAdvance] to an arbitrary JSON value. - * - * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun billedInAdvance(billedInAdvance: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } + override fun toString() = + "TieredWithProrationConfig{tiers=$tiers, additionalProperties=$additionalProperties}" + } - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: NewBillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { - /** - * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.billingCycleConfiguration] with a well-typed - * [NewBillingCycleConfiguration] value instead. This method is primarily for - * setting the field to an undocumented or not yet supported value. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: JsonField - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: Double?) = - conversionRate(JsonField.ofNullable(conversionRate)) + fun toBuilder() = Builder().from(this) - /** - * Alias for [Builder.conversionRate]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) + companion object { - /** - * Sets [Builder.conversionRate] to an arbitrary JSON value. - * - * You should usually call [Builder.conversionRate] with a well-typed [Double] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() } - /** - * The configuration for the rate of the price currency to the invoicing - * currency. - */ - fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = - conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + /** A builder for [Metadata]. */ + class Builder internal constructor() { - /** - * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.conversionRateConfig] with a well-typed - * [ConversionRateConfig] value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun conversionRateConfig( - conversionRateConfig: JsonField - ) = apply { this.conversionRateConfig = conversionRateConfig } + private var additionalProperties: MutableMap = + mutableMapOf() - /** - * Alias for calling [conversionRateConfig] with - * `ConversionRateConfig.ofUnit(unit)`. - */ - fun conversionRateConfig(unit: UnitConversionRateConfig) = - conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } - /** - * Alias for calling [conversionRateConfig] with the following: - * ```kotlin - * UnitConversionRateConfig.builder() - * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) - * .unitConfig(unitConfig) - * .build() - * ``` - */ - fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = - conversionRateConfig( - UnitConversionRateConfig.builder() - .conversionRateType( - UnitConversionRateConfig.ConversionRateType.UNIT - ) - .unitConfig(unitConfig) - .build() - ) + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** - * Alias for calling [conversionRateConfig] with - * `ConversionRateConfig.ofTiered(tiered)`. - */ - fun conversionRateConfig(tiered: TieredConversionRateConfig) = - conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * Alias for calling [conversionRateConfig] with the following: - * ```kotlin - * TieredConversionRateConfig.builder() - * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) - * .tieredConfig(tieredConfig) - * .build() - * ``` - */ - fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = - conversionRateConfig( - TieredConversionRateConfig.builder() - .conversionRateType( - TieredConversionRateConfig.ConversionRateType.TIERED - ) - .tieredConfig(tieredConfig) - .build() - ) + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - /** - * Sets [Builder.currency] to an arbitrary JSON value. - * - * You should usually call [Builder.currency] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - /** For dimensional price: specifies a price group and dimension values */ - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? - ) = - dimensionalPriceConfiguration( - JsonField.ofNullable(dimensionalPriceConfiguration) - ) + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } - /** - * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.dimensionalPriceConfiguration] with a - * well-typed [NewDimensionalPriceConfiguration] value instead. This method is - * primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: JsonField - ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + private var validated: Boolean = false - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) + fun validate(): Metadata = apply { + if (validated) { + return@apply + } - /** - * Sets [Builder.externalPriceId] to an arbitrary JSON value. - * - * You should usually call [Builder.externalPriceId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun externalPriceId(externalPriceId: JsonField) = apply { - this.externalPriceId = externalPriceId + validated = true } - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = - fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } /** - * Alias for [Builder.fixedPriceQuantity]. + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * This unboxed primitive overload exists for backwards compatibility. + * Used for best match union deserialization. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } - /** - * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. - * - * You should usually call [Builder.fixedPriceQuantity] with a well-typed - * [Double] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { - this.fixedPriceQuantity = fixedPriceQuantity + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties } - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = - invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) - - /** - * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. - * - * You should usually call [Builder.invoiceGroupingKey] with a well-typed - * [String] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { - this.invoiceGroupingKey = invoiceGroupingKey - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are - * produced. If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: NewBillingCycleConfiguration? - ) = - invoicingCycleConfiguration( - JsonField.ofNullable(invoicingCycleConfiguration) - ) - - /** - * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.invoicingCycleConfiguration] with a - * well-typed [NewBillingCycleConfiguration] value instead. This method is - * primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * Sets [Builder.metadata] to an arbitrary JSON value. - * - * You should usually call [Builder.metadata] with a well-typed [Metadata] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - fun referenceId(referenceId: String?) = - referenceId(JsonField.ofNullable(referenceId)) - - /** - * Sets [Builder.referenceId] to an arbitrary JSON value. - * - * You should usually call [Builder.referenceId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun referenceId(referenceId: JsonField) = apply { - this.referenceId = referenceId - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + override fun hashCode(): Int = hashCode - /** - * Returns an immutable instance of [Percent]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```kotlin - * .cadence() - * .itemId() - * .name() - * .percentConfig() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Percent = - Percent( - checkRequired("cadence", cadence), - checkRequired("itemId", itemId), - modelType, - checkRequired("name", name), - checkRequired("percentConfig", percentConfig), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - conversionRateConfig, - currency, - dimensionalPriceConfiguration, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - additionalProperties.toMutableMap(), - ) + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" } - private var validated: Boolean = false - - fun validate(): Percent = apply { - if (validated) { - return@apply + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - cadence().validate() - itemId() - _modelType().let { - if (it != JsonValue.from("percent")) { - throw OrbInvalidDataException("'modelType' is invalid, received $it") - } - } - name() - percentConfig().validate() - billableMetricId() - billedInAdvance() - billingCycleConfiguration()?.validate() - conversionRate() - conversionRateConfig()?.validate() - currency() - dimensionalPriceConfiguration()?.validate() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration()?.validate() - metadata()?.validate() - referenceId() - validated = true + return other is TieredWithProration && + cadence == other.cadence && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + tieredWithProrationConfig == other.tieredWithProrationConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + modelType, + name, + tieredWithProrationConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties, + ) + } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (cadence.asKnown()?.validity() ?: 0) + - (if (itemId.asKnown() == null) 0 else 1) + - modelType.let { if (it == JsonValue.from("percent")) 1 else 0 } + - (if (name.asKnown() == null) 0 else 1) + - (percentConfig.asKnown()?.validity() ?: 0) + - (if (billableMetricId.asKnown() == null) 0 else 1) + - (if (billedInAdvance.asKnown() == null) 0 else 1) + - (billingCycleConfiguration.asKnown()?.validity() ?: 0) + - (if (conversionRate.asKnown() == null) 0 else 1) + - (conversionRateConfig.asKnown()?.validity() ?: 0) + - (if (currency.asKnown() == null) 0 else 1) + - (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + - (if (externalPriceId.asKnown() == null) 0 else 1) + - (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + - (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + - (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + - (metadata.asKnown()?.validity() ?: 0) + - (if (referenceId.asKnown() == null) 0 else 1) + override fun hashCode(): Int = hashCode - /** The cadence to bill for this price on. */ - class Cadence - @JsonCreator - private constructor(private val value: JsonField) : Enum { + override fun toString() = + "TieredWithProration{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredWithProrationConfig=$tieredWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value + class GroupedWithMinMaxThresholds + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val groupedWithMinMaxThresholdsConfig: + JsonField, + private val itemId: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { - companion object { + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("grouped_with_min_max_thresholds_config") + @ExcludeMissing + groupedWithMinMaxThresholdsConfig: + JsonField = + JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + groupedWithMinMaxThresholdsConfig, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + mutableMapOf(), + ) - val ANNUAL = of("annual") + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") - val SEMI_ANNUAL = of("semi_annual") + /** + * Configuration for grouped_with_min_max_thresholds pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupedWithMinMaxThresholdsConfig(): GroupedWithMinMaxThresholdsConfig = + groupedWithMinMaxThresholdsConfig.getRequired( + "grouped_with_min_max_thresholds_config" + ) - val MONTHLY = of("monthly") + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") - val QUARTERLY = of("quarterly") + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("grouped_with_min_max_thresholds") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType - val ONE_TIME = of("one_time") + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") - val CUSTOM = of("custom") + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = billableMetricId.getNullable("billable_metric_id") - fun of(value: String) = Cadence(JsonField.of(value)) - } + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") - /** An enum containing [Cadence]'s known values. */ - enum class Known { - ANNUAL, - SEMI_ANNUAL, - MONTHLY, - QUARTERLY, - ONE_TIME, - CUSTOM, - } + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") - /** - * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Cadence] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - ANNUAL, - SEMI_ANNUAL, - MONTHLY, - QUARTERLY, - ONE_TIME, - CUSTOM, - /** - * An enum member indicating that [Cadence] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - ANNUAL -> Value.ANNUAL - SEMI_ANNUAL -> Value.SEMI_ANNUAL - MONTHLY -> Value.MONTHLY - QUARTERLY -> Value.QUARTERLY - ONE_TIME -> Value.ONE_TIME - CUSTOM -> Value.CUSTOM - else -> Value._UNKNOWN - } + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - ANNUAL -> Known.ANNUAL - SEMI_ANNUAL -> Known.SEMI_ANNUAL - MONTHLY -> Known.MONTHLY - QUARTERLY -> Known.QUARTERLY - ONE_TIME -> Known.ONE_TIME - CUSTOM -> Known.CUSTOM - else -> throw OrbInvalidDataException("Unknown Cadence: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString() - ?: throw OrbInvalidDataException("Value is not a String") + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") - private var validated: Boolean = false + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") - fun validate(): Cadence = apply { - if (validated) { - return@apply - } + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") - known() - validated = true - } + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + invoiceGroupingKey.getNullable("invoice_grouping_key") - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") - return other is Cadence && value == other.value - } + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") - override fun hashCode() = value.hashCode() + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence - override fun toString() = value.toString() - } + /** + * Returns the raw JSON value of [groupedWithMinMaxThresholdsConfig]. + * + * Unlike [groupedWithMinMaxThresholdsConfig], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("grouped_with_min_max_thresholds_config") + @ExcludeMissing + fun _groupedWithMinMaxThresholdsConfig(): + JsonField = groupedWithMinMaxThresholdsConfig - /** Configuration for percent pricing */ - class PercentConfig - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val percent: JsonField, - private val additionalProperties: MutableMap, - ) { + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - @JsonCreator - private constructor( - @JsonProperty("percent") - @ExcludeMissing - percent: JsonField = JsonMissing.of() - ) : this(percent, mutableMapOf()) + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - /** - * What percent of the component subtotals to charge - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun percent(): Double = percent.getRequired("percent") + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId - /** - * Returns the raw JSON value of [percent]. - * - * Unlike [percent], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("percent") - @ExcludeMissing - fun _percent(): JsonField = percent + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate - fun toBuilder() = Builder().from(this) + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig - companion object { + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency - /** - * Returns a mutable builder for constructing an instance of - * [PercentConfig]. - * - * The following fields are required: - * ```kotlin - * .percent() - * ``` - */ - fun builder() = Builder() - } - - /** A builder for [PercentConfig]. */ - class Builder internal constructor() { + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration - private var percent: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId - internal fun from(percentConfig: PercentConfig) = apply { - percent = percentConfig.percent - additionalProperties = percentConfig.additionalProperties.toMutableMap() - } + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - /** What percent of the component subtotals to charge */ - fun percent(percent: Double) = percent(JsonField.of(percent)) + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - /** - * Sets [Builder.percent] to an arbitrary JSON value. - * - * You should usually call [Builder.percent] with a well-typed [Double] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun percent(percent: JsonField) = apply { this.percent = percent } + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun toBuilder() = Builder().from(this) - /** - * Returns an immutable instance of [PercentConfig]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```kotlin - * .percent() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): PercentConfig = - PercentConfig( - checkRequired("percent", percent), - additionalProperties.toMutableMap(), - ) - } + companion object { - private var validated: Boolean = false + /** + * Returns a mutable builder for constructing an instance of + * [GroupedWithMinMaxThresholds]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .groupedWithMinMaxThresholdsConfig() + * .itemId() + * .name() + * ``` + */ + fun builder() = Builder() + } - fun validate(): PercentConfig = apply { - if (validated) { - return@apply - } + /** A builder for [GroupedWithMinMaxThresholds]. */ + class Builder internal constructor() { - percent() - validated = true - } + private var cadence: JsonField? = null + private var groupedWithMinMaxThresholdsConfig: + JsonField? = + null + private var itemId: JsonField? = null + private var modelType: JsonValue = + JsonValue.from("grouped_with_min_max_thresholds") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false + internal fun from(groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds) = + apply { + cadence = groupedWithMinMaxThresholds.cadence + groupedWithMinMaxThresholdsConfig = + groupedWithMinMaxThresholds.groupedWithMinMaxThresholdsConfig + itemId = groupedWithMinMaxThresholds.itemId + modelType = groupedWithMinMaxThresholds.modelType + name = groupedWithMinMaxThresholds.name + billableMetricId = groupedWithMinMaxThresholds.billableMetricId + billedInAdvance = groupedWithMinMaxThresholds.billedInAdvance + billingCycleConfiguration = + groupedWithMinMaxThresholds.billingCycleConfiguration + conversionRate = groupedWithMinMaxThresholds.conversionRate + conversionRateConfig = groupedWithMinMaxThresholds.conversionRateConfig + currency = groupedWithMinMaxThresholds.currency + dimensionalPriceConfiguration = + groupedWithMinMaxThresholds.dimensionalPriceConfiguration + externalPriceId = groupedWithMinMaxThresholds.externalPriceId + fixedPriceQuantity = groupedWithMinMaxThresholds.fixedPriceQuantity + invoiceGroupingKey = groupedWithMinMaxThresholds.invoiceGroupingKey + invoicingCycleConfiguration = + groupedWithMinMaxThresholds.invoicingCycleConfiguration + metadata = groupedWithMinMaxThresholds.metadata + referenceId = groupedWithMinMaxThresholds.referenceId + additionalProperties = + groupedWithMinMaxThresholds.additionalProperties.toMutableMap() } + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + /** - * Returns a score indicating how many valid values are contained in this object - * recursively. + * Sets [Builder.cadence] to an arbitrary JSON value. * - * Used for best match union deserialization. + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. */ - internal fun validity(): Int = (if (percent.asKnown() == null) 0 else 1) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is PercentConfig && - percent == other.percent && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(percent, additionalProperties) - } + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - override fun hashCode(): Int = hashCode + /** Configuration for grouped_with_min_max_thresholds pricing */ + fun groupedWithMinMaxThresholdsConfig( + groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + ) = + groupedWithMinMaxThresholdsConfig( + JsonField.of(groupedWithMinMaxThresholdsConfig) + ) - override fun toString() = - "PercentConfig{percent=$percent, additionalProperties=$additionalProperties}" - } - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - class Metadata - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Metadata]. */ - fun builder() = Builder() + /** + * Sets [Builder.groupedWithMinMaxThresholdsConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.groupedWithMinMaxThresholdsConfig] with a + * well-typed [GroupedWithMinMaxThresholdsConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun groupedWithMinMaxThresholdsConfig( + groupedWithMinMaxThresholdsConfig: + JsonField + ) = apply { + this.groupedWithMinMaxThresholdsConfig = groupedWithMinMaxThresholdsConfig } - /** A builder for [Metadata]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = - mutableMapOf() - - internal fun from(metadata: Metadata) = apply { - additionalProperties = metadata.additionalProperties.toMutableMap() - } + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("grouped_with_min_max_thresholds") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) - /** - * Returns an immutable instance of [Metadata]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId } - private var validated: Boolean = false + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) - fun validate(): Metadata = apply { - if (validated) { - return@apply - } + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) - validated = true + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) /** - * Returns a score indicating how many valid values are contained in this object - * recursively. + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. * - * Used for best match union deserialization. + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. */ - internal fun validity(): Int = - additionalProperties.count { (_, value) -> - !value.isNull() && !value.isMissing() - } + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) - return other is Metadata && - additionalProperties == other.additionalProperties + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate } - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) - override fun hashCode(): Int = hashCode + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) - return other is Percent && - cadence == other.cadence && - itemId == other.itemId && - modelType == other.modelType && - name == other.name && - percentConfig == other.percentConfig && - billableMetricId == other.billableMetricId && - billedInAdvance == other.billedInAdvance && - billingCycleConfiguration == other.billingCycleConfiguration && - conversionRate == other.conversionRate && - conversionRateConfig == other.conversionRateConfig && - currency == other.currency && - dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && - externalPriceId == other.externalPriceId && - fixedPriceQuantity == other.fixedPriceQuantity && - invoiceGroupingKey == other.invoiceGroupingKey && - invoicingCycleConfiguration == other.invoicingCycleConfiguration && - metadata == other.metadata && - referenceId == other.referenceId && - additionalProperties == other.additionalProperties - } + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) - private val hashCode: Int by lazy { - Objects.hash( - cadence, - itemId, - modelType, - name, - percentConfig, - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - conversionRateConfig, - currency, - dimensionalPriceConfiguration, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - additionalProperties, - ) - } + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) - override fun hashCode(): Int = hashCode + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) - override fun toString() = - "Percent{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, percentConfig=$percentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" - } + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } - class EventOutput - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val cadence: JsonField, - private val eventOutputConfig: JsonField, - private val itemId: JsonField, - private val modelType: JsonValue, - private val name: JsonField, - private val billableMetricId: JsonField, - private val billedInAdvance: JsonField, - private val billingCycleConfiguration: JsonField, - private val conversionRate: JsonField, - private val conversionRateConfig: JsonField, - private val currency: JsonField, - private val dimensionalPriceConfiguration: - JsonField, - private val externalPriceId: JsonField, - private val fixedPriceQuantity: JsonField, - private val invoiceGroupingKey: JsonField, - private val invoicingCycleConfiguration: JsonField, - private val metadata: JsonField, - private val referenceId: JsonField, - private val additionalProperties: MutableMap, - ) { + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) - @JsonCreator - private constructor( - @JsonProperty("cadence") - @ExcludeMissing - cadence: JsonField = JsonMissing.of(), - @JsonProperty("event_output_config") - @ExcludeMissing - eventOutputConfig: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - modelType: JsonValue = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - name: JsonField = JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("conversion_rate_config") - @ExcludeMissing - conversionRateConfig: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - currency: JsonField = JsonMissing.of(), - @JsonProperty("dimensional_price_configuration") - @ExcludeMissing - dimensionalPriceConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - metadata: JsonField = JsonMissing.of(), - @JsonProperty("reference_id") - @ExcludeMissing - referenceId: JsonField = JsonMissing.of(), - ) : this( - cadence, - eventOutputConfig, - itemId, - modelType, - name, - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - conversionRateConfig, - currency, - dimensionalPriceConfiguration, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - mutableMapOf(), - ) + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } - /** - * The cadence to bill for this price on. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun cadence(): Cadence = cadence.getRequired("cadence") + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) - /** - * Configuration for event_output pricing - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun eventOutputConfig(): EventOutputConfig = - eventOutputConfig.getRequired("event_output_config") + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } - /** - * The id of the item the price will be associated with. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun itemId(): String = itemId.getRequired("item_id") + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) - /** - * The pricing model type - * - * Expected to always return the following: - * ```kotlin - * JsonValue.from("event_output") - * ``` - * - * However, this method can be useful for debugging and logging (e.g. if the server - * responded with an unexpected value). - */ - @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType - - /** - * The name of the price. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun name(): String = name.getRequired("name") - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun billableMetricId(): String? = billableMetricId.getNullable("billable_metric_id") - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun billingCycleConfiguration(): NewBillingCycleConfiguration? = - billingCycleConfiguration.getNullable("billing_cycle_configuration") + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) - /** - * The per unit conversion rate of the price currency to the invoicing currency. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } - /** - * The configuration for the rate of the price currency to the invoicing currency. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun conversionRateConfig(): ConversionRateConfig? = - conversionRateConfig.getNullable("conversion_rate_config") + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun currency(): String? = currency.getNullable("currency") + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } - /** - * For dimensional price: specifies a price group and dimension values - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = - dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) - /** - * An alias for the price. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun fixedPriceQuantity(): Double? = - fixedPriceQuantity.getNullable("fixed_price_quantity") + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - /** - * The property used to group this price on an invoice - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun invoiceGroupingKey(): String? = - invoiceGroupingKey.getNullable("invoice_grouping_key") + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun metadata(): Metadata? = metadata.getNullable("metadata") + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun referenceId(): String? = referenceId.getNullable("reference_id") + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** - * Returns the raw JSON value of [cadence]. - * - * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("cadence") - @ExcludeMissing - fun _cadence(): JsonField = cadence + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * Returns the raw JSON value of [eventOutputConfig]. - * - * Unlike [eventOutputConfig], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("event_output_config") - @ExcludeMissing - fun _eventOutputConfig(): JsonField = eventOutputConfig + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - /** - * Returns the raw JSON value of [itemId]. - * - * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - /** - * Returns the raw JSON value of [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - /** - * Returns the raw JSON value of [billableMetricId]. - * - * Unlike [billableMetricId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = billableMetricId + /** + * Returns an immutable instance of [GroupedWithMinMaxThresholds]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .groupedWithMinMaxThresholdsConfig() + * .itemId() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedWithMinMaxThresholds = + GroupedWithMinMaxThresholds( + checkRequired("cadence", cadence), + checkRequired( + "groupedWithMinMaxThresholdsConfig", + groupedWithMinMaxThresholdsConfig, + ), + checkRequired("itemId", itemId), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } - /** - * Returns the raw JSON value of [billedInAdvance]. - * - * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance + private var validated: Boolean = false - /** - * Returns the raw JSON value of [billingCycleConfiguration]. - * - * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration + fun validate(): GroupedWithMinMaxThresholds = apply { + if (validated) { + return@apply + } - /** - * Returns the raw JSON value of [conversionRate]. - * - * Unlike [conversionRate], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate + cadence().validate() + groupedWithMinMaxThresholdsConfig().validate() + itemId() + _modelType().let { + if (it != JsonValue.from("grouped_with_min_max_thresholds")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + metadata()?.validate() + referenceId() + validated = true + } - /** - * Returns the raw JSON value of [conversionRateConfig]. - * - * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("conversion_rate_config") - @ExcludeMissing - fun _conversionRateConfig(): JsonField = conversionRateConfig + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } /** - * Returns the raw JSON value of [currency]. + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * Unlike [currency], this method doesn't throw if the JSON field has an unexpected - * type. + * Used for best match union deserialization. */ - @JsonProperty("currency") - @ExcludeMissing - fun _currency(): JsonField = currency + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (groupedWithMinMaxThresholdsConfig.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + modelType.let { + if (it == JsonValue.from("grouped_with_min_max_thresholds")) 1 else 0 + } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) - /** - * Returns the raw JSON value of [dimensionalPriceConfiguration]. - * - * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON - * field has an unexpected type. - */ - @JsonProperty("dimensional_price_configuration") - @ExcludeMissing - fun _dimensionalPriceConfiguration(): JsonField = - dimensionalPriceConfiguration + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { - /** - * Returns the raw JSON value of [externalPriceId]. - * - * Unlike [externalPriceId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value - /** - * Returns the raw JSON value of [fixedPriceQuantity]. - * - * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + companion object { - /** - * Returns the raw JSON value of [invoiceGroupingKey]. - * - * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + val ANNUAL = of("annual") - /** - * Returns the raw JSON value of [invoicingCycleConfiguration]. - * - * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration + val SEMI_ANNUAL = of("semi_annual") - /** - * Returns the raw JSON value of [metadata]. - * - * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata + val MONTHLY = of("monthly") - /** - * Returns the raw JSON value of [referenceId]. - * - * Unlike [referenceId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("reference_id") - @ExcludeMissing - fun _referenceId(): JsonField = referenceId + val QUARTERLY = of("quarterly") - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + val ONE_TIME = of("one_time") - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + val CUSTOM = of("custom") - fun toBuilder() = Builder().from(this) + fun of(value: String) = Cadence(JsonField.of(value)) + } - companion object { + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } /** - * Returns a mutable builder for constructing an instance of [EventOutput]. + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. * - * The following fields are required: - * ```kotlin - * .cadence() - * .eventOutputConfig() - * .itemId() - * .name() - * ``` + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. */ - fun builder() = Builder() - } - - /** A builder for [EventOutput]. */ - class Builder internal constructor() { - - private var cadence: JsonField? = null - private var eventOutputConfig: JsonField? = null - private var itemId: JsonField? = null - private var modelType: JsonValue = JsonValue.from("event_output") - private var name: JsonField? = null - private var billableMetricId: JsonField = JsonMissing.of() - private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var conversionRateConfig: JsonField = - JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var dimensionalPriceConfiguration: - JsonField = - JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: - JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var referenceId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(eventOutput: EventOutput) = apply { - cadence = eventOutput.cadence - eventOutputConfig = eventOutput.eventOutputConfig - itemId = eventOutput.itemId - modelType = eventOutput.modelType - name = eventOutput.name - billableMetricId = eventOutput.billableMetricId - billedInAdvance = eventOutput.billedInAdvance - billingCycleConfiguration = eventOutput.billingCycleConfiguration - conversionRate = eventOutput.conversionRate - conversionRateConfig = eventOutput.conversionRateConfig - currency = eventOutput.currency - dimensionalPriceConfiguration = eventOutput.dimensionalPriceConfiguration - externalPriceId = eventOutput.externalPriceId - fixedPriceQuantity = eventOutput.fixedPriceQuantity - invoiceGroupingKey = eventOutput.invoiceGroupingKey - invoicingCycleConfiguration = eventOutput.invoicingCycleConfiguration - metadata = eventOutput.metadata - referenceId = eventOutput.referenceId - additionalProperties = eventOutput.additionalProperties.toMutableMap() + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, } - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - /** - * Sets [Builder.cadence] to an arbitrary JSON value. + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. * - * You should usually call [Builder.cadence] with a well-typed [Cadence] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. */ - fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - - /** Configuration for event_output pricing */ - fun eventOutputConfig(eventOutputConfig: EventOutputConfig) = - eventOutputConfig(JsonField.of(eventOutputConfig)) + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } /** - * Sets [Builder.eventOutputConfig] to an arbitrary JSON value. + * Returns an enum member corresponding to this class instance's value. * - * You should usually call [Builder.eventOutputConfig] with a well-typed - * [EventOutputConfig] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun eventOutputConfig(eventOutputConfig: JsonField) = apply { - this.eventOutputConfig = eventOutputConfig - } - - /** The id of the item the price will be associated with. */ - fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - - /** - * Sets [Builder.itemId] to an arbitrary JSON value. + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. * - * You should usually call [Builder.itemId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } /** - * Sets the field to an arbitrary JSON value. + * Returns this class instance's primitive wire representation. * - * It is usually unnecessary to call this method because the field defaults to - * the following: - * ```kotlin - * JsonValue.from("event_output") - * ``` + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. * - * This method is primarily for setting the field to an undocumented or not yet - * supported value. + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. */ - fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } /** - * Sets [Builder.name] to an arbitrary JSON value. + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * You should usually call [Builder.name] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. + * Used for best match union deserialization. */ - fun name(name: JsonField) = apply { this.name = name } + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: String?) = - billableMetricId(JsonField.ofNullable(billableMetricId)) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Configuration for grouped_with_min_max_thresholds pricing */ + class GroupedWithMinMaxThresholdsConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val groupingKey: JsonField, + private val maximumCharge: JsonField, + private val minimumCharge: JsonField, + private val perUnitRate: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("maximum_charge") + @ExcludeMissing + maximumCharge: JsonField = JsonMissing.of(), + @JsonProperty("minimum_charge") + @ExcludeMissing + minimumCharge: JsonField = JsonMissing.of(), + @JsonProperty("per_unit_rate") + @ExcludeMissing + perUnitRate: JsonField = JsonMissing.of(), + ) : this(groupingKey, maximumCharge, minimumCharge, perUnitRate, mutableMapOf()) /** - * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * The event property used to group before applying thresholds * - * You should usually call [Builder.billableMetricId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). */ - fun billableMetricId(billableMetricId: JsonField) = apply { - this.billableMetricId = billableMetricId - } + fun groupingKey(): String = groupingKey.getRequired("grouping_key") /** - * If the Price represents a fixed cost, the price will be billed in-advance if - * this is true, and in-arrears if this is false. + * The maximum amount to charge each group + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). */ - fun billedInAdvance(billedInAdvance: Boolean?) = - billedInAdvance(JsonField.ofNullable(billedInAdvance)) + fun maximumCharge(): String = maximumCharge.getRequired("maximum_charge") /** - * Alias for [Builder.billedInAdvance]. + * The minimum amount to charge each group, regardless of usage * - * This unboxed primitive overload exists for backwards compatibility. + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). */ - fun billedInAdvance(billedInAdvance: Boolean) = - billedInAdvance(billedInAdvance as Boolean?) + fun minimumCharge(): String = minimumCharge.getRequired("minimum_charge") /** - * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * The base price charged per group * - * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun billedInAdvance(billedInAdvance: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). */ - fun billingCycleConfiguration( - billingCycleConfiguration: NewBillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + fun perUnitRate(): String = perUnitRate.getRequired("per_unit_rate") /** - * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * Returns the raw JSON value of [groupingKey]. * - * You should usually call [Builder.billingCycleConfiguration] with a well-typed - * [NewBillingCycleConfiguration] value instead. This method is primarily for - * setting the field to an undocumented or not yet supported value. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: JsonField - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } - - /** - * The per unit conversion rate of the price currency to the invoicing currency. + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. */ - fun conversionRate(conversionRate: Double?) = - conversionRate(JsonField.ofNullable(conversionRate)) + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey /** - * Alias for [Builder.conversionRate]. + * Returns the raw JSON value of [maximumCharge]. * - * This unboxed primitive overload exists for backwards compatibility. + * Unlike [maximumCharge], this method doesn't throw if the JSON field has an + * unexpected type. */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) + @JsonProperty("maximum_charge") + @ExcludeMissing + fun _maximumCharge(): JsonField = maximumCharge /** - * Sets [Builder.conversionRate] to an arbitrary JSON value. + * Returns the raw JSON value of [minimumCharge]. * - * You should usually call [Builder.conversionRate] with a well-typed [Double] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** - * The configuration for the rate of the price currency to the invoicing - * currency. + * Unlike [minimumCharge], this method doesn't throw if the JSON field has an + * unexpected type. */ - fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = - conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + @JsonProperty("minimum_charge") + @ExcludeMissing + fun _minimumCharge(): JsonField = minimumCharge /** - * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * Returns the raw JSON value of [perUnitRate]. * - * You should usually call [Builder.conversionRateConfig] with a well-typed - * [ConversionRateConfig] value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. + * Unlike [perUnitRate], this method doesn't throw if the JSON field has an + * unexpected type. */ - fun conversionRateConfig( - conversionRateConfig: JsonField - ) = apply { this.conversionRateConfig = conversionRateConfig } + @JsonProperty("per_unit_rate") + @ExcludeMissing + fun _perUnitRate(): JsonField = perUnitRate - /** - * Alias for calling [conversionRateConfig] with - * `ConversionRateConfig.ofUnit(unit)`. - */ - fun conversionRateConfig(unit: UnitConversionRateConfig) = - conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - /** - * Alias for calling [conversionRateConfig] with the following: - * ```kotlin - * UnitConversionRateConfig.builder() - * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) - * .unitConfig(unitConfig) - * .build() - * ``` - */ - fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = - conversionRateConfig( - UnitConversionRateConfig.builder() - .conversionRateType( - UnitConversionRateConfig.ConversionRateType.UNIT - ) - .unitConfig(unitConfig) - .build() - ) + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - /** - * Alias for calling [conversionRateConfig] with - * `ConversionRateConfig.ofTiered(tiered)`. - */ - fun conversionRateConfig(tiered: TieredConversionRateConfig) = - conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + fun toBuilder() = Builder().from(this) - /** - * Alias for calling [conversionRateConfig] with the following: - * ```kotlin - * TieredConversionRateConfig.builder() - * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) - * .tieredConfig(tieredConfig) - * .build() - * ``` - */ - fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = - conversionRateConfig( - TieredConversionRateConfig.builder() - .conversionRateType( - TieredConversionRateConfig.ConversionRateType.TIERED - ) - .tieredConfig(tieredConfig) - .build() - ) + companion object { - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + /** + * Returns a mutable builder for constructing an instance of + * [GroupedWithMinMaxThresholdsConfig]. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .maximumCharge() + * .minimumCharge() + * .perUnitRate() + * ``` + */ + fun builder() = Builder() + } - /** - * Sets [Builder.currency] to an arbitrary JSON value. - * - * You should usually call [Builder.currency] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } + /** A builder for [GroupedWithMinMaxThresholdsConfig]. */ + class Builder internal constructor() { - /** For dimensional price: specifies a price group and dimension values */ - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? - ) = - dimensionalPriceConfiguration( - JsonField.ofNullable(dimensionalPriceConfiguration) - ) + private var groupingKey: JsonField? = null + private var maximumCharge: JsonField? = null + private var minimumCharge: JsonField? = null + private var perUnitRate: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() - /** - * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.dimensionalPriceConfiguration] with a - * well-typed [NewDimensionalPriceConfiguration] value instead. This method is - * primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: JsonField - ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + internal fun from( + groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + ) = apply { + groupingKey = groupedWithMinMaxThresholdsConfig.groupingKey + maximumCharge = groupedWithMinMaxThresholdsConfig.maximumCharge + minimumCharge = groupedWithMinMaxThresholdsConfig.minimumCharge + perUnitRate = groupedWithMinMaxThresholdsConfig.perUnitRate + additionalProperties = + groupedWithMinMaxThresholdsConfig.additionalProperties + .toMutableMap() + } - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) + /** The event property used to group before applying thresholds */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) - /** - * Sets [Builder.externalPriceId] to an arbitrary JSON value. - * - * You should usually call [Builder.externalPriceId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun externalPriceId(externalPriceId: JsonField) = apply { - this.externalPriceId = externalPriceId - } + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = - fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + /** The maximum amount to charge each group */ + fun maximumCharge(maximumCharge: String) = + maximumCharge(JsonField.of(maximumCharge)) - /** - * Alias for [Builder.fixedPriceQuantity]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) + /** + * Sets [Builder.maximumCharge] to an arbitrary JSON value. + * + * You should usually call [Builder.maximumCharge] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun maximumCharge(maximumCharge: JsonField) = apply { + this.maximumCharge = maximumCharge + } - /** - * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. - * - * You should usually call [Builder.fixedPriceQuantity] with a well-typed - * [Double] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + /** The minimum amount to charge each group, regardless of usage */ + fun minimumCharge(minimumCharge: String) = + minimumCharge(JsonField.of(minimumCharge)) - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = - invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + /** + * Sets [Builder.minimumCharge] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumCharge] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun minimumCharge(minimumCharge: JsonField) = apply { + this.minimumCharge = minimumCharge + } - /** - * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. - * - * You should usually call [Builder.invoiceGroupingKey] with a well-typed - * [String] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { - this.invoiceGroupingKey = invoiceGroupingKey - } + /** The base price charged per group */ + fun perUnitRate(perUnitRate: String) = + perUnitRate(JsonField.of(perUnitRate)) - /** - * Within each billing cycle, specifies the cadence at which invoices are - * produced. If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: NewBillingCycleConfiguration? - ) = - invoicingCycleConfiguration( - JsonField.ofNullable(invoicingCycleConfiguration) - ) + /** + * Sets [Builder.perUnitRate] to an arbitrary JSON value. + * + * You should usually call [Builder.perUnitRate] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun perUnitRate(perUnitRate: JsonField) = apply { + this.perUnitRate = perUnitRate + } - /** - * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.invoicingCycleConfiguration] with a - * well-typed [NewBillingCycleConfiguration] value instead. This method is - * primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * Sets [Builder.metadata] to an arbitrary JSON value. - * - * You should usually call [Builder.metadata] with a well-typed [Metadata] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - fun referenceId(referenceId: String?) = - referenceId(JsonField.ofNullable(referenceId)) + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - /** - * Sets [Builder.referenceId] to an arbitrary JSON value. - * - * You should usually call [Builder.referenceId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun referenceId(referenceId: JsonField) = apply { - this.referenceId = referenceId - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) + /** + * Returns an immutable instance of [GroupedWithMinMaxThresholdsConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .maximumCharge() + * .minimumCharge() + * .perUnitRate() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedWithMinMaxThresholdsConfig = + GroupedWithMinMaxThresholdsConfig( + checkRequired("groupingKey", groupingKey), + checkRequired("maximumCharge", maximumCharge), + checkRequired("minimumCharge", minimumCharge), + checkRequired("perUnitRate", perUnitRate), + additionalProperties.toMutableMap(), + ) } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + private var validated: Boolean = false - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) + fun validate(): GroupedWithMinMaxThresholdsConfig = apply { + if (validated) { + return@apply } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) + groupingKey() + maximumCharge() + minimumCharge() + perUnitRate() + validated = true } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } /** - * Returns an immutable instance of [EventOutput]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```kotlin - * .cadence() - * .eventOutputConfig() - * .itemId() - * .name() - * ``` + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * @throws IllegalStateException if any required field is unset. + * Used for best match union deserialization. */ - fun build(): EventOutput = - EventOutput( - checkRequired("cadence", cadence), - checkRequired("eventOutputConfig", eventOutputConfig), - checkRequired("itemId", itemId), - modelType, - checkRequired("name", name), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - conversionRateConfig, - currency, - dimensionalPriceConfiguration, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - additionalProperties.toMutableMap(), - ) - } + internal fun validity(): Int = + (if (groupingKey.asKnown() == null) 0 else 1) + + (if (maximumCharge.asKnown() == null) 0 else 1) + + (if (minimumCharge.asKnown() == null) 0 else 1) + + (if (perUnitRate.asKnown() == null) 0 else 1) - private var validated: Boolean = false + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun validate(): EventOutput = apply { - if (validated) { - return@apply + return other is GroupedWithMinMaxThresholdsConfig && + groupingKey == other.groupingKey && + maximumCharge == other.maximumCharge && + minimumCharge == other.minimumCharge && + perUnitRate == other.perUnitRate && + additionalProperties == other.additionalProperties } - cadence().validate() - eventOutputConfig().validate() - itemId() - _modelType().let { - if (it != JsonValue.from("event_output")) { - throw OrbInvalidDataException("'modelType' is invalid, received $it") - } + private val hashCode: Int by lazy { + Objects.hash( + groupingKey, + maximumCharge, + minimumCharge, + perUnitRate, + additionalProperties, + ) } - name() - billableMetricId() - billedInAdvance() - billingCycleConfiguration()?.validate() - conversionRate() - conversionRateConfig()?.validate() - currency() - dimensionalPriceConfiguration()?.validate() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration()?.validate() - metadata()?.validate() - referenceId() - validated = true - } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedWithMinMaxThresholdsConfig{groupingKey=$groupingKey, maximumCharge=$maximumCharge, minimumCharge=$minimumCharge, perUnitRate=$perUnitRate, additionalProperties=$additionalProperties}" + } /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. */ - internal fun validity(): Int = - (cadence.asKnown()?.validity() ?: 0) + - (eventOutputConfig.asKnown()?.validity() ?: 0) + - (if (itemId.asKnown() == null) 0 else 1) + - modelType.let { if (it == JsonValue.from("event_output")) 1 else 0 } + - (if (name.asKnown() == null) 0 else 1) + - (if (billableMetricId.asKnown() == null) 0 else 1) + - (if (billedInAdvance.asKnown() == null) 0 else 1) + - (billingCycleConfiguration.asKnown()?.validity() ?: 0) + - (if (conversionRate.asKnown() == null) 0 else 1) + - (conversionRateConfig.asKnown()?.validity() ?: 0) + - (if (currency.asKnown() == null) 0 else 1) + - (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + - (if (externalPriceId.asKnown() == null) 0 else 1) + - (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + - (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + - (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + - (metadata.asKnown()?.validity() ?: 0) + - (if (referenceId.asKnown() == null) 0 else 1) - - /** The cadence to bill for this price on. */ - class Cadence + class Metadata @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ + private constructor( @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value + private val additionalProperties: Map + ) { - companion object { + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties - val ANNUAL = of("annual") + fun toBuilder() = Builder().from(this) - val SEMI_ANNUAL = of("semi_annual") + companion object { - val MONTHLY = of("monthly") + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } - val QUARTERLY = of("quarterly") + /** A builder for [Metadata]. */ + class Builder internal constructor() { - val ONE_TIME = of("one_time") + private var additionalProperties: MutableMap = + mutableMapOf() - val CUSTOM = of("custom") + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } - fun of(value: String) = Cadence(JsonField.of(value)) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** An enum containing [Cadence]'s known values. */ - enum class Known { - ANNUAL, - SEMI_ANNUAL, - MONTHLY, - QUARTERLY, - ONE_TIME, - CUSTOM, - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Cadence] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - ANNUAL, - SEMI_ANNUAL, - MONTHLY, - QUARTERLY, - ONE_TIME, - CUSTOM, - /** - * An enum member indicating that [Cadence] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - ANNUAL -> Value.ANNUAL - SEMI_ANNUAL -> Value.SEMI_ANNUAL - MONTHLY -> Value.MONTHLY - QUARTERLY -> Value.QUARTERLY - ONE_TIME -> Value.ONE_TIME - CUSTOM -> Value.CUSTOM - else -> Value._UNKNOWN + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) } - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - ANNUAL -> Known.ANNUAL - SEMI_ANNUAL -> Known.SEMI_ANNUAL - MONTHLY -> Known.MONTHLY - QUARTERLY -> Known.QUARTERLY - ONE_TIME -> Known.ONE_TIME - CUSTOM -> Known.CUSTOM - else -> throw OrbInvalidDataException("Unknown Cadence: $value") + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) } - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString() - ?: throw OrbInvalidDataException("Value is not a String") + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } private var validated: Boolean = false - fun validate(): Cadence = apply { + fun validate(): Metadata = apply { if (validated) { return@apply } - known() validated = true } @@ -9361,3071 +8673,7897 @@ private constructor( * * Used for best match union deserialization. */ - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is Cadence && value == other.value + return other is Metadata && + additionalProperties == other.additionalProperties } - override fun hashCode() = value.hashCode() + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - override fun toString() = value.toString() - } + override fun hashCode(): Int = hashCode - /** Configuration for event_output pricing */ - class EventOutputConfig - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val unitRatingKey: JsonField, - private val groupingKey: JsonField, - private val additionalProperties: MutableMap, - ) { + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } - @JsonCreator - private constructor( - @JsonProperty("unit_rating_key") - @ExcludeMissing - unitRatingKey: JsonField = JsonMissing.of(), - @JsonProperty("grouping_key") - @ExcludeMissing - groupingKey: JsonField = JsonMissing.of(), - ) : this(unitRatingKey, groupingKey, mutableMapOf()) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * The key in the event data to extract the unit rate from. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun unitRatingKey(): String = unitRatingKey.getRequired("unit_rating_key") + return other is GroupedWithMinMaxThresholds && + cadence == other.cadence && + groupedWithMinMaxThresholdsConfig == + other.groupedWithMinMaxThresholdsConfig && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } - /** - * An optional key in the event data to group by (e.g., event ID). All events - * will also be grouped by their unit rate. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun groupingKey(): String? = groupingKey.getNullable("grouping_key") + private val hashCode: Int by lazy { + Objects.hash( + cadence, + groupedWithMinMaxThresholdsConfig, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties, + ) + } - /** - * Returns the raw JSON value of [unitRatingKey]. - * - * Unlike [unitRatingKey], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("unit_rating_key") - @ExcludeMissing - fun _unitRatingKey(): JsonField = unitRatingKey + override fun hashCode(): Int = hashCode - /** - * Returns the raw JSON value of [groupingKey]. - * - * Unlike [groupingKey], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("grouping_key") - @ExcludeMissing - fun _groupingKey(): JsonField = groupingKey + override fun toString() = + "GroupedWithMinMaxThresholds{cadence=$cadence, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + class Percent + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val percentConfig: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { - @JsonAnyGetter + @JsonCreator + private constructor( + @JsonProperty("cadence") @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("percent_config") + @ExcludeMissing + percentConfig: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + modelType, + name, + percentConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + mutableMapOf(), + ) - companion object { + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") - /** - * Returns a mutable builder for constructing an instance of - * [EventOutputConfig]. - * - * The following fields are required: - * ```kotlin - * .unitRatingKey() - * ``` - */ - fun builder() = Builder() - } + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") - /** A builder for [EventOutputConfig]. */ - class Builder internal constructor() { + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("percent") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType - private var unitRatingKey: JsonField? = null - private var groupingKey: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") - internal fun from(eventOutputConfig: EventOutputConfig) = apply { - unitRatingKey = eventOutputConfig.unitRatingKey - groupingKey = eventOutputConfig.groupingKey - additionalProperties = - eventOutputConfig.additionalProperties.toMutableMap() - } + /** + * Configuration for percent pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun percentConfig(): PercentConfig = percentConfig.getRequired("percent_config") - /** The key in the event data to extract the unit rate from. */ - fun unitRatingKey(unitRatingKey: String) = - unitRatingKey(JsonField.of(unitRatingKey)) + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = billableMetricId.getNullable("billable_metric_id") - /** - * Sets [Builder.unitRatingKey] to an arbitrary JSON value. - * - * You should usually call [Builder.unitRatingKey] with a well-typed - * [String] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun unitRatingKey(unitRatingKey: JsonField) = apply { - this.unitRatingKey = unitRatingKey - } + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") - /** - * An optional key in the event data to group by (e.g., event ID). All - * events will also be grouped by their unit rate. - */ - fun groupingKey(groupingKey: String?) = - groupingKey(JsonField.ofNullable(groupingKey)) - - /** - * Sets [Builder.groupingKey] to an arbitrary JSON value. - * - * You should usually call [Builder.groupingKey] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun groupingKey(groupingKey: JsonField) = apply { - this.groupingKey = groupingKey - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [EventOutputConfig]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```kotlin - * .unitRatingKey() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): EventOutputConfig = - EventOutputConfig( - checkRequired("unitRatingKey", unitRatingKey), - groupingKey, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): EventOutputConfig = apply { - if (validated) { - return@apply - } + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") - unitRatingKey() - groupingKey() - validated = true - } + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (if (unitRatingKey.asKnown() == null) 0 else 1) + - (if (groupingKey.asKnown() == null) 0 else 1) + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") - return other is EventOutputConfig && - unitRatingKey == other.unitRatingKey && - groupingKey == other.groupingKey && - additionalProperties == other.additionalProperties - } + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") - private val hashCode: Int by lazy { - Objects.hash(unitRatingKey, groupingKey, additionalProperties) - } + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") - override fun hashCode(): Int = hashCode + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + invoiceGroupingKey.getNullable("invoice_grouping_key") - override fun toString() = - "EventOutputConfig{unitRatingKey=$unitRatingKey, groupingKey=$groupingKey, additionalProperties=$additionalProperties}" - } + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). */ - class Metadata - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) + fun metadata(): Metadata? = metadata.getNullable("metadata") - companion object { + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") - /** Returns a mutable builder for constructing an instance of [Metadata]. */ - fun builder() = Builder() - } + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence - /** A builder for [Metadata]. */ - class Builder internal constructor() { + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - private var additionalProperties: MutableMap = - mutableMapOf() + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - internal fun from(metadata: Metadata) = apply { - additionalProperties = metadata.additionalProperties.toMutableMap() - } + /** + * Returns the raw JSON value of [percentConfig]. + * + * Unlike [percentConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("percent_config") + @ExcludeMissing + fun _percentConfig(): JsonField = percentConfig - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Metadata]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance - private var validated: Boolean = false + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration - fun validate(): Metadata = apply { - if (validated) { - return@apply - } + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate - validated = true - } + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - additionalProperties.count { (_, value) -> - !value.isNull() && !value.isMissing() - } + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId - return other is Metadata && - additionalProperties == other.additionalProperties - } + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - override fun hashCode(): Int = hashCode + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId - return other is EventOutput && - cadence == other.cadence && - eventOutputConfig == other.eventOutputConfig && - itemId == other.itemId && - modelType == other.modelType && - name == other.name && - billableMetricId == other.billableMetricId && - billedInAdvance == other.billedInAdvance && - billingCycleConfiguration == other.billingCycleConfiguration && - conversionRate == other.conversionRate && - conversionRateConfig == other.conversionRateConfig && - currency == other.currency && - dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && - externalPriceId == other.externalPriceId && - fixedPriceQuantity == other.fixedPriceQuantity && - invoiceGroupingKey == other.invoiceGroupingKey && - invoicingCycleConfiguration == other.invoicingCycleConfiguration && - metadata == other.metadata && - referenceId == other.referenceId && - additionalProperties == other.additionalProperties + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) } - private val hashCode: Int by lazy { - Objects.hash( - cadence, - eventOutputConfig, - itemId, - modelType, - name, - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - conversionRateConfig, - currency, - dimensionalPriceConfiguration, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - additionalProperties, - ) - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - override fun hashCode(): Int = hashCode + fun toBuilder() = Builder().from(this) - override fun toString() = - "EventOutput{cadence=$cadence, eventOutputConfig=$eventOutputConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" - } - } + companion object { - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * Returns a mutable builder for constructing an instance of [Percent]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .name() + * .percentConfig() + * ``` + */ + fun builder() = Builder() + } - return other is AddPrice && - allocationPrice == other.allocationPrice && - planPhaseOrder == other.planPhaseOrder && - price == other.price && - additionalProperties == other.additionalProperties - } + /** A builder for [Percent]. */ + class Builder internal constructor() { - private val hashCode: Int by lazy { - Objects.hash(allocationPrice, planPhaseOrder, price, additionalProperties) - } - - override fun hashCode(): Int = hashCode + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonValue = JsonValue.from("percent") + private var name: JsonField? = null + private var percentConfig: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - override fun toString() = - "AddPrice{allocationPrice=$allocationPrice, planPhaseOrder=$planPhaseOrder, price=$price, additionalProperties=$additionalProperties}" - } + internal fun from(percent: Percent) = apply { + cadence = percent.cadence + itemId = percent.itemId + modelType = percent.modelType + name = percent.name + percentConfig = percent.percentConfig + billableMetricId = percent.billableMetricId + billedInAdvance = percent.billedInAdvance + billingCycleConfiguration = percent.billingCycleConfiguration + conversionRate = percent.conversionRate + conversionRateConfig = percent.conversionRateConfig + currency = percent.currency + dimensionalPriceConfiguration = percent.dimensionalPriceConfiguration + externalPriceId = percent.externalPriceId + fixedPriceQuantity = percent.fixedPriceQuantity + invoiceGroupingKey = percent.invoiceGroupingKey + invoicingCycleConfiguration = percent.invoicingCycleConfiguration + metadata = percent.metadata + referenceId = percent.referenceId + additionalProperties = percent.additionalProperties.toMutableMap() + } - class RemoveAdjustment - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val adjustmentId: JsonField, - private val planPhaseOrder: JsonField, - private val additionalProperties: MutableMap, - ) { + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - @JsonCreator - private constructor( - @JsonProperty("adjustment_id") - @ExcludeMissing - adjustmentId: JsonField = JsonMissing.of(), - @JsonProperty("plan_phase_order") - @ExcludeMissing - planPhaseOrder: JsonField = JsonMissing.of(), - ) : this(adjustmentId, planPhaseOrder, mutableMapOf()) + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - /** - * The id of the adjustment to remove from on the plan. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun adjustmentId(): String = adjustmentId.getRequired("adjustment_id") + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - /** - * The phase to remove this adjustment from. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun planPhaseOrder(): Long? = planPhaseOrder.getNullable("plan_phase_order") + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - /** - * Returns the raw JSON value of [adjustmentId]. - * - * Unlike [adjustmentId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("adjustment_id") - @ExcludeMissing - fun _adjustmentId(): JsonField = adjustmentId + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("percent") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } - /** - * Returns the raw JSON value of [planPhaseOrder]. - * - * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("plan_phase_order") - @ExcludeMissing - fun _planPhaseOrder(): JsonField = planPhaseOrder + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** Configuration for percent pricing */ + fun percentConfig(percentConfig: PercentConfig) = + percentConfig(JsonField.of(percentConfig)) - fun toBuilder() = Builder().from(this) + /** + * Sets [Builder.percentConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.percentConfig] with a well-typed + * [PercentConfig] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun percentConfig(percentConfig: JsonField) = apply { + this.percentConfig = percentConfig + } - companion object { + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) - /** - * Returns a mutable builder for constructing an instance of [RemoveAdjustment]. - * - * The following fields are required: - * ```kotlin - * .adjustmentId() - * ``` - */ - fun builder() = Builder() - } + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } - /** A builder for [RemoveAdjustment]. */ - class Builder internal constructor() { + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) - private var adjustmentId: JsonField? = null - private var planPhaseOrder: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) - internal fun from(removeAdjustment: RemoveAdjustment) = apply { - adjustmentId = removeAdjustment.adjustmentId - planPhaseOrder = removeAdjustment.planPhaseOrder - additionalProperties = removeAdjustment.additionalProperties.toMutableMap() - } + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } - /** The id of the adjustment to remove from on the plan. */ - fun adjustmentId(adjustmentId: String) = adjustmentId(JsonField.of(adjustmentId)) + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - /** - * Sets [Builder.adjustmentId] to an arbitrary JSON value. - * - * You should usually call [Builder.adjustmentId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun adjustmentId(adjustmentId: JsonField) = apply { - this.adjustmentId = adjustmentId - } + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } - /** The phase to remove this adjustment from. */ - fun planPhaseOrder(planPhaseOrder: Long?) = - planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) - - /** - * Alias for [Builder.planPhaseOrder]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) - /** - * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. - * - * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun planPhaseOrder(planPhaseOrder: JsonField) = apply { - this.planPhaseOrder = planPhaseOrder - } + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) - /** - * Returns an immutable instance of [RemoveAdjustment]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```kotlin - * .adjustmentId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): RemoveAdjustment = - RemoveAdjustment( - checkRequired("adjustmentId", adjustmentId), - planPhaseOrder, - additionalProperties.toMutableMap(), - ) - } + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) - private var validated: Boolean = false + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) - fun validate(): RemoveAdjustment = apply { - if (validated) { - return@apply - } + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) - adjustmentId() - planPhaseOrder() - validated = true - } + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (if (adjustmentId.asKnown() == null) 0 else 1) + - (if (planPhaseOrder.asKnown() == null) 0 else 1) + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) - return other is RemoveAdjustment && - adjustmentId == other.adjustmentId && - planPhaseOrder == other.planPhaseOrder && - additionalProperties == other.additionalProperties - } + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } - private val hashCode: Int by lazy { - Objects.hash(adjustmentId, planPhaseOrder, additionalProperties) - } + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) - override fun hashCode(): Int = hashCode + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) - override fun toString() = - "RemoveAdjustment{adjustmentId=$adjustmentId, planPhaseOrder=$planPhaseOrder, additionalProperties=$additionalProperties}" - } + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } - class RemovePrice - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val priceId: JsonField, - private val planPhaseOrder: JsonField, - private val additionalProperties: MutableMap, - ) { + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) - @JsonCreator - private constructor( - @JsonProperty("price_id") @ExcludeMissing priceId: JsonField = JsonMissing.of(), - @JsonProperty("plan_phase_order") - @ExcludeMissing - planPhaseOrder: JsonField = JsonMissing.of(), - ) : this(priceId, planPhaseOrder, mutableMapOf()) - - /** - * The id of the price to remove from the plan. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun priceId(): String = priceId.getRequired("price_id") - - /** - * The phase to remove this price from. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun planPhaseOrder(): Long? = planPhaseOrder.getNullable("plan_phase_order") + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } - /** - * Returns the raw JSON value of [priceId]. - * - * Unlike [priceId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) - /** - * Returns the raw JSON value of [planPhaseOrder]. - * - * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("plan_phase_order") - @ExcludeMissing - fun _planPhaseOrder(): JsonField = planPhaseOrder + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - fun toBuilder() = Builder().from(this) + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) - companion object { + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } - /** - * Returns a mutable builder for constructing an instance of [RemovePrice]. - * - * The following fields are required: - * ```kotlin - * .priceId() - * ``` - */ - fun builder() = Builder() - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** A builder for [RemovePrice]. */ - class Builder internal constructor() { + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - private var priceId: JsonField? = null - private var planPhaseOrder: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - internal fun from(removePrice: RemovePrice) = apply { - priceId = removePrice.priceId - planPhaseOrder = removePrice.planPhaseOrder - additionalProperties = removePrice.additionalProperties.toMutableMap() - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - /** The id of the price to remove from the plan. */ - fun priceId(priceId: String) = priceId(JsonField.of(priceId)) + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - /** - * Sets [Builder.priceId] to an arbitrary JSON value. - * - * You should usually call [Builder.priceId] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun priceId(priceId: JsonField) = apply { this.priceId = priceId } + /** + * Returns an immutable instance of [Percent]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .name() + * .percentConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Percent = + Percent( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + modelType, + checkRequired("name", name), + checkRequired("percentConfig", percentConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } - /** The phase to remove this price from. */ - fun planPhaseOrder(planPhaseOrder: Long?) = - planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + private var validated: Boolean = false - /** - * Alias for [Builder.planPhaseOrder]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + fun validate(): Percent = apply { + if (validated) { + return@apply + } - /** - * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. - * - * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun planPhaseOrder(planPhaseOrder: JsonField) = apply { - this.planPhaseOrder = planPhaseOrder - } + cadence().validate() + itemId() + _modelType().let { + if (it != JsonValue.from("percent")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + percentConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + metadata()?.validate() + referenceId() + validated = true + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + modelType.let { if (it == JsonValue.from("percent")) 1 else 0 } + + (if (name.asKnown() == null) 0 else 1) + + (percentConfig.asKnown()?.validity() ?: 0) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + companion object { - /** - * Returns an immutable instance of [RemovePrice]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```kotlin - * .priceId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): RemovePrice = - RemovePrice( - checkRequired("priceId", priceId), - planPhaseOrder, - additionalProperties.toMutableMap(), - ) - } + val ANNUAL = of("annual") - private var validated: Boolean = false + val SEMI_ANNUAL = of("semi_annual") - fun validate(): RemovePrice = apply { - if (validated) { - return@apply - } + val MONTHLY = of("monthly") - priceId() - planPhaseOrder() - validated = true - } + val QUARTERLY = of("quarterly") - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + val ONE_TIME = of("one_time") - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (if (priceId.asKnown() == null) 0 else 1) + - (if (planPhaseOrder.asKnown() == null) 0 else 1) + val CUSTOM = of("custom") - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + fun of(value: String) = Cadence(JsonField.of(value)) + } - return other is RemovePrice && - priceId == other.priceId && - planPhaseOrder == other.planPhaseOrder && - additionalProperties == other.additionalProperties - } + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } - private val hashCode: Int by lazy { - Objects.hash(priceId, planPhaseOrder, additionalProperties) - } + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } - override fun hashCode(): Int = hashCode + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } - override fun toString() = - "RemovePrice{priceId=$priceId, planPhaseOrder=$planPhaseOrder, additionalProperties=$additionalProperties}" - } + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } - class ReplaceAdjustment - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val adjustment: JsonField, - private val replacesAdjustmentId: JsonField, - private val planPhaseOrder: JsonField, - private val additionalProperties: MutableMap, - ) { + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") - @JsonCreator - private constructor( - @JsonProperty("adjustment") - @ExcludeMissing - adjustment: JsonField = JsonMissing.of(), - @JsonProperty("replaces_adjustment_id") - @ExcludeMissing - replacesAdjustmentId: JsonField = JsonMissing.of(), - @JsonProperty("plan_phase_order") - @ExcludeMissing - planPhaseOrder: JsonField = JsonMissing.of(), - ) : this(adjustment, replacesAdjustmentId, planPhaseOrder, mutableMapOf()) + private var validated: Boolean = false - /** - * The definition of a new adjustment to create and add to the plan. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun adjustment(): Adjustment = adjustment.getRequired("adjustment") + fun validate(): Cadence = apply { + if (validated) { + return@apply + } - /** - * The id of the adjustment on the plan to replace in the plan. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun replacesAdjustmentId(): String = - replacesAdjustmentId.getRequired("replaces_adjustment_id") + known() + validated = true + } - /** - * The phase to replace this adjustment from. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun planPhaseOrder(): Long? = planPhaseOrder.getNullable("plan_phase_order") + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - /** - * Returns the raw JSON value of [adjustment]. - * - * Unlike [adjustment], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("adjustment") - @ExcludeMissing - fun _adjustment(): JsonField = adjustment + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - /** - * Returns the raw JSON value of [replacesAdjustmentId]. - * - * Unlike [replacesAdjustmentId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("replaces_adjustment_id") - @ExcludeMissing - fun _replacesAdjustmentId(): JsonField = replacesAdjustmentId + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * Returns the raw JSON value of [planPhaseOrder]. - * - * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("plan_phase_order") - @ExcludeMissing - fun _planPhaseOrder(): JsonField = planPhaseOrder + return other is Cadence && value == other.value + } - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + override fun hashCode() = value.hashCode() - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + override fun toString() = value.toString() + } - fun toBuilder() = Builder().from(this) + /** Configuration for percent pricing */ + class PercentConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val percent: JsonField, + private val additionalProperties: MutableMap, + ) { - companion object { + @JsonCreator + private constructor( + @JsonProperty("percent") + @ExcludeMissing + percent: JsonField = JsonMissing.of() + ) : this(percent, mutableMapOf()) - /** - * Returns a mutable builder for constructing an instance of [ReplaceAdjustment]. - * - * The following fields are required: - * ```kotlin - * .adjustment() - * .replacesAdjustmentId() - * ``` - */ - fun builder() = Builder() - } + /** + * What percent of the component subtotals to charge + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun percent(): Double = percent.getRequired("percent") - /** A builder for [ReplaceAdjustment]. */ - class Builder internal constructor() { + /** + * Returns the raw JSON value of [percent]. + * + * Unlike [percent], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("percent") + @ExcludeMissing + fun _percent(): JsonField = percent - private var adjustment: JsonField? = null - private var replacesAdjustmentId: JsonField? = null - private var planPhaseOrder: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - internal fun from(replaceAdjustment: ReplaceAdjustment) = apply { - adjustment = replaceAdjustment.adjustment - replacesAdjustmentId = replaceAdjustment.replacesAdjustmentId - planPhaseOrder = replaceAdjustment.planPhaseOrder - additionalProperties = replaceAdjustment.additionalProperties.toMutableMap() - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - /** The definition of a new adjustment to create and add to the plan. */ - fun adjustment(adjustment: Adjustment) = adjustment(JsonField.of(adjustment)) + fun toBuilder() = Builder().from(this) - /** - * Sets [Builder.adjustment] to an arbitrary JSON value. - * - * You should usually call [Builder.adjustment] with a well-typed [Adjustment] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun adjustment(adjustment: JsonField) = apply { - this.adjustment = adjustment - } + companion object { - /** - * Alias for calling [adjustment] with - * `Adjustment.ofPercentageDiscount(percentageDiscount)`. - */ - fun adjustment(percentageDiscount: NewPercentageDiscount) = - adjustment(Adjustment.ofPercentageDiscount(percentageDiscount)) + /** + * Returns a mutable builder for constructing an instance of + * [PercentConfig]. + * + * The following fields are required: + * ```kotlin + * .percent() + * ``` + */ + fun builder() = Builder() + } - /** - * Alias for calling [adjustment] with the following: - * ```kotlin - * NewPercentageDiscount.builder() - * .adjustmentType(NewPercentageDiscount.AdjustmentType.PERCENTAGE_DISCOUNT) - * .percentageDiscount(percentageDiscount) - * .build() - * ``` - */ - fun percentageDiscountAdjustment(percentageDiscount: Double) = - adjustment( - NewPercentageDiscount.builder() - .adjustmentType(NewPercentageDiscount.AdjustmentType.PERCENTAGE_DISCOUNT) - .percentageDiscount(percentageDiscount) - .build() - ) + /** A builder for [PercentConfig]. */ + class Builder internal constructor() { - /** Alias for calling [adjustment] with `Adjustment.ofUsageDiscount(usageDiscount)`. */ - fun adjustment(usageDiscount: NewUsageDiscount) = - adjustment(Adjustment.ofUsageDiscount(usageDiscount)) + private var percent: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() - /** - * Alias for calling [adjustment] with the following: - * ```kotlin - * NewUsageDiscount.builder() - * .adjustmentType(NewUsageDiscount.AdjustmentType.USAGE_DISCOUNT) - * .usageDiscount(usageDiscount) - * .build() - * ``` - */ - fun usageDiscountAdjustment(usageDiscount: Double) = - adjustment( - NewUsageDiscount.builder() - .adjustmentType(NewUsageDiscount.AdjustmentType.USAGE_DISCOUNT) - .usageDiscount(usageDiscount) - .build() - ) + internal fun from(percentConfig: PercentConfig) = apply { + percent = percentConfig.percent + additionalProperties = percentConfig.additionalProperties.toMutableMap() + } - /** - * Alias for calling [adjustment] with `Adjustment.ofAmountDiscount(amountDiscount)`. - */ - fun adjustment(amountDiscount: NewAmountDiscount) = - adjustment(Adjustment.ofAmountDiscount(amountDiscount)) + /** What percent of the component subtotals to charge */ + fun percent(percent: Double) = percent(JsonField.of(percent)) - /** - * Alias for calling [adjustment] with the following: - * ```kotlin - * NewAmountDiscount.builder() - * .adjustmentType(NewAmountDiscount.AdjustmentType.AMOUNT_DISCOUNT) - * .amountDiscount(amountDiscount) - * .build() - * ``` - */ - fun amountDiscountAdjustment(amountDiscount: String) = - adjustment( - NewAmountDiscount.builder() - .adjustmentType(NewAmountDiscount.AdjustmentType.AMOUNT_DISCOUNT) - .amountDiscount(amountDiscount) - .build() - ) + /** + * Sets [Builder.percent] to an arbitrary JSON value. + * + * You should usually call [Builder.percent] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun percent(percent: JsonField) = apply { this.percent = percent } - /** Alias for calling [adjustment] with `Adjustment.ofMinimum(minimum)`. */ - fun adjustment(minimum: NewMinimum) = adjustment(Adjustment.ofMinimum(minimum)) + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** Alias for calling [adjustment] with `Adjustment.ofMaximum(maximum)`. */ - fun adjustment(maximum: NewMaximum) = adjustment(Adjustment.ofMaximum(maximum)) + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * Alias for calling [adjustment] with the following: - * ```kotlin - * NewMaximum.builder() - * .adjustmentType(NewMaximum.AdjustmentType.MAXIMUM) - * .maximumAmount(maximumAmount) - * .build() - * ``` - */ - fun maximumAdjustment(maximumAmount: String) = - adjustment( - NewMaximum.builder() - .adjustmentType(NewMaximum.AdjustmentType.MAXIMUM) - .maximumAmount(maximumAmount) - .build() - ) + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - /** The id of the adjustment on the plan to replace in the plan. */ - fun replacesAdjustmentId(replacesAdjustmentId: String) = - replacesAdjustmentId(JsonField.of(replacesAdjustmentId)) + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - /** - * Sets [Builder.replacesAdjustmentId] to an arbitrary JSON value. - * - * You should usually call [Builder.replacesAdjustmentId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun replacesAdjustmentId(replacesAdjustmentId: JsonField) = apply { - this.replacesAdjustmentId = replacesAdjustmentId - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - /** The phase to replace this adjustment from. */ - fun planPhaseOrder(planPhaseOrder: Long?) = - planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + /** + * Returns an immutable instance of [PercentConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .percent() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): PercentConfig = + PercentConfig( + checkRequired("percent", percent), + additionalProperties.toMutableMap(), + ) + } - /** - * Alias for [Builder.planPhaseOrder]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + private var validated: Boolean = false - /** - * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. - * - * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun planPhaseOrder(planPhaseOrder: JsonField) = apply { - this.planPhaseOrder = planPhaseOrder - } + fun validate(): PercentConfig = apply { + if (validated) { + return@apply + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + percent() + validated = true + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = (if (percent.asKnown() == null) 0 else 1) - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + return other is PercentConfig && + percent == other.percent && + additionalProperties == other.additionalProperties + } - /** - * Returns an immutable instance of [ReplaceAdjustment]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```kotlin - * .adjustment() - * .replacesAdjustmentId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): ReplaceAdjustment = - ReplaceAdjustment( - checkRequired("adjustment", adjustment), - checkRequired("replacesAdjustmentId", replacesAdjustmentId), - planPhaseOrder, - additionalProperties.toMutableMap(), - ) - } + private val hashCode: Int by lazy { + Objects.hash(percent, additionalProperties) + } - private var validated: Boolean = false + override fun hashCode(): Int = hashCode - fun validate(): ReplaceAdjustment = apply { - if (validated) { - return@apply - } + override fun toString() = + "PercentConfig{percent=$percent, additionalProperties=$additionalProperties}" + } - adjustment().validate() - replacesAdjustmentId() - planPhaseOrder() - validated = true - } + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (adjustment.asKnown()?.validity() ?: 0) + - (if (replacesAdjustmentId.asKnown() == null) 0 else 1) + - (if (planPhaseOrder.asKnown() == null) 0 else 1) + fun toBuilder() = Builder().from(this) - /** The definition of a new adjustment to create and add to the plan. */ - @JsonDeserialize(using = Adjustment.Deserializer::class) - @JsonSerialize(using = Adjustment.Serializer::class) - class Adjustment - private constructor( - private val percentageDiscount: NewPercentageDiscount? = null, - private val usageDiscount: NewUsageDiscount? = null, - private val amountDiscount: NewAmountDiscount? = null, - private val minimum: NewMinimum? = null, - private val maximum: NewMaximum? = null, - private val _json: JsonValue? = null, - ) { + companion object { - fun percentageDiscount(): NewPercentageDiscount? = percentageDiscount + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } - fun usageDiscount(): NewUsageDiscount? = usageDiscount + /** A builder for [Metadata]. */ + class Builder internal constructor() { - fun amountDiscount(): NewAmountDiscount? = amountDiscount + private var additionalProperties: MutableMap = + mutableMapOf() - fun minimum(): NewMinimum? = minimum + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } - fun maximum(): NewMaximum? = maximum + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun isPercentageDiscount(): Boolean = percentageDiscount != null + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun isUsageDiscount(): Boolean = usageDiscount != null + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun isAmountDiscount(): Boolean = amountDiscount != null + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun isMinimum(): Boolean = minimum != null + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - fun isMaximum(): Boolean = maximum != null + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } - fun asPercentageDiscount(): NewPercentageDiscount = - percentageDiscount.getOrThrow("percentageDiscount") + private var validated: Boolean = false - fun asUsageDiscount(): NewUsageDiscount = usageDiscount.getOrThrow("usageDiscount") + fun validate(): Metadata = apply { + if (validated) { + return@apply + } - fun asAmountDiscount(): NewAmountDiscount = amountDiscount.getOrThrow("amountDiscount") + validated = true + } - fun asMinimum(): NewMinimum = minimum.getOrThrow("minimum") + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - fun asMaximum(): NewMaximum = maximum.getOrThrow("maximum") + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } - fun _json(): JsonValue? = _json + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun accept(visitor: Visitor): T = - when { - percentageDiscount != null -> - visitor.visitPercentageDiscount(percentageDiscount) - usageDiscount != null -> visitor.visitUsageDiscount(usageDiscount) - amountDiscount != null -> visitor.visitAmountDiscount(amountDiscount) - minimum != null -> visitor.visitMinimum(minimum) - maximum != null -> visitor.visitMaximum(maximum) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): Adjustment = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitPercentageDiscount( - percentageDiscount: NewPercentageDiscount - ) { - percentageDiscount.validate() - } + return other is Metadata && + additionalProperties == other.additionalProperties + } - override fun visitUsageDiscount(usageDiscount: NewUsageDiscount) { - usageDiscount.validate() - } + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - override fun visitAmountDiscount(amountDiscount: NewAmountDiscount) { - amountDiscount.validate() - } + override fun hashCode(): Int = hashCode - override fun visitMinimum(minimum: NewMinimum) { - minimum.validate() - } + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } - override fun visitMaximum(maximum: NewMaximum) { - maximum.validate() - } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - ) - validated = true - } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false + return other is Percent && + cadence == other.cadence && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + percentConfig == other.percentConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitPercentageDiscount( - percentageDiscount: NewPercentageDiscount - ) = percentageDiscount.validity() - - override fun visitUsageDiscount(usageDiscount: NewUsageDiscount) = - usageDiscount.validity() + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + modelType, + name, + percentConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties, + ) + } - override fun visitAmountDiscount(amountDiscount: NewAmountDiscount) = - amountDiscount.validity() + override fun hashCode(): Int = hashCode - override fun visitMinimum(minimum: NewMinimum) = minimum.validity() + override fun toString() = + "Percent{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, percentConfig=$percentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } - override fun visitMaximum(maximum: NewMaximum) = maximum.validity() + class EventOutput + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val eventOutputConfig: JsonField, + private val itemId: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { - override fun unknown(json: JsonValue?) = 0 - } + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("event_output_config") + @ExcludeMissing + eventOutputConfig: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + eventOutputConfig, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + mutableMapOf(), ) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Adjustment && - percentageDiscount == other.percentageDiscount && - usageDiscount == other.usageDiscount && - amountDiscount == other.amountDiscount && - minimum == other.minimum && - maximum == other.maximum - } + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") - override fun hashCode(): Int = - Objects.hash(percentageDiscount, usageDiscount, amountDiscount, minimum, maximum) + /** + * Configuration for event_output pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun eventOutputConfig(): EventOutputConfig = + eventOutputConfig.getRequired("event_output_config") - override fun toString(): String = - when { - percentageDiscount != null -> - "Adjustment{percentageDiscount=$percentageDiscount}" - usageDiscount != null -> "Adjustment{usageDiscount=$usageDiscount}" - amountDiscount != null -> "Adjustment{amountDiscount=$amountDiscount}" - minimum != null -> "Adjustment{minimum=$minimum}" - maximum != null -> "Adjustment{maximum=$maximum}" - _json != null -> "Adjustment{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Adjustment") - } - - companion object { + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") - fun ofPercentageDiscount(percentageDiscount: NewPercentageDiscount) = - Adjustment(percentageDiscount = percentageDiscount) + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("event_output") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType - fun ofUsageDiscount(usageDiscount: NewUsageDiscount) = - Adjustment(usageDiscount = usageDiscount) + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") - fun ofAmountDiscount(amountDiscount: NewAmountDiscount) = - Adjustment(amountDiscount = amountDiscount) + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = billableMetricId.getNullable("billable_metric_id") - fun ofMinimum(minimum: NewMinimum) = Adjustment(minimum = minimum) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") - fun ofMaximum(maximum: NewMaximum) = Adjustment(maximum = maximum) - } + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") - /** - * An interface that defines how to map each variant of [Adjustment] to a value of type - * [T]. - */ - interface Visitor { + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") - fun visitPercentageDiscount(percentageDiscount: NewPercentageDiscount): T + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") - fun visitUsageDiscount(usageDiscount: NewUsageDiscount): T + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") - fun visitAmountDiscount(amountDiscount: NewAmountDiscount): T + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") - fun visitMinimum(minimum: NewMinimum): T + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") - fun visitMaximum(maximum: NewMaximum): T + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") /** - * Maps an unknown variant of [Adjustment] to a value of type [T]. + * The property used to group this price on an invoice * - * An instance of [Adjustment] can contain an unknown variant if it was deserialized - * from data that doesn't match any known variant. For example, if the SDK is on an - * older version than the API, then the API may respond with new variants that the - * SDK is unaware of. + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + invoiceGroupingKey.getNullable("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. * - * @throws OrbInvalidDataException in the default implementation. + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown Adjustment: $json") - } - } + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - internal class Deserializer : BaseDeserializer(Adjustment::class) { + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") - override fun ObjectCodec.deserialize(node: JsonNode): Adjustment { - val json = JsonValue.fromJsonNode(node) - val adjustmentType = json.asObject()?.get("adjustment_type")?.asString() + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") - when (adjustmentType) { - "percentage_discount" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Adjustment(percentageDiscount = it, _json = json) } - ?: Adjustment(_json = json) - } - "usage_discount" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(usageDiscount = it, _json = json) - } ?: Adjustment(_json = json) - } - "amount_discount" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(amountDiscount = it, _json = json) - } ?: Adjustment(_json = json) - } - "minimum" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(minimum = it, _json = json) - } ?: Adjustment(_json = json) - } - "maximum" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(maximum = it, _json = json) - } ?: Adjustment(_json = json) - } - } + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence - return Adjustment(_json = json) - } - } + /** + * Returns the raw JSON value of [eventOutputConfig]. + * + * Unlike [eventOutputConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("event_output_config") + @ExcludeMissing + fun _eventOutputConfig(): JsonField = eventOutputConfig - internal class Serializer : BaseSerializer(Adjustment::class) { + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - override fun serialize( - value: Adjustment, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.percentageDiscount != null -> - generator.writeObject(value.percentageDiscount) - value.usageDiscount != null -> generator.writeObject(value.usageDiscount) - value.amountDiscount != null -> generator.writeObject(value.amountDiscount) - value.minimum != null -> generator.writeObject(value.minimum) - value.maximum != null -> generator.writeObject(value.maximum) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Adjustment") - } - } - } - } + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId - return other is ReplaceAdjustment && - adjustment == other.adjustment && - replacesAdjustmentId == other.replacesAdjustmentId && - planPhaseOrder == other.planPhaseOrder && - additionalProperties == other.additionalProperties - } + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance - private val hashCode: Int by lazy { - Objects.hash(adjustment, replacesAdjustmentId, planPhaseOrder, additionalProperties) - } + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration - override fun hashCode(): Int = hashCode + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate - override fun toString() = - "ReplaceAdjustment{adjustment=$adjustment, replacesAdjustmentId=$replacesAdjustmentId, planPhaseOrder=$planPhaseOrder, additionalProperties=$additionalProperties}" - } + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig - class ReplacePrice - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val replacesPriceId: JsonField, - private val allocationPrice: JsonField, - private val planPhaseOrder: JsonField, - private val price: JsonField, - private val additionalProperties: MutableMap, - ) { + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency - @JsonCreator - private constructor( - @JsonProperty("replaces_price_id") - @ExcludeMissing - replacesPriceId: JsonField = JsonMissing.of(), - @JsonProperty("allocation_price") - @ExcludeMissing - allocationPrice: JsonField = JsonMissing.of(), - @JsonProperty("plan_phase_order") - @ExcludeMissing - planPhaseOrder: JsonField = JsonMissing.of(), - @JsonProperty("price") @ExcludeMissing price: JsonField = JsonMissing.of(), - ) : this(replacesPriceId, allocationPrice, planPhaseOrder, price, mutableMapOf()) + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration - /** - * The id of the price on the plan to replace in the plan. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun replacesPriceId(): String = replacesPriceId.getRequired("replaces_price_id") + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId - /** - * The allocation price to add to the plan. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun allocationPrice(): NewAllocationPrice? = allocationPrice.getNullable("allocation_price") + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - /** - * The phase to replace this price from. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun planPhaseOrder(): Long? = planPhaseOrder.getNullable("plan_phase_order") + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - /** - * New plan price request body params. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun price(): Price? = price.getNullable("price") + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration - /** - * Returns the raw JSON value of [replacesPriceId]. - * - * Unlike [replacesPriceId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("replaces_price_id") - @ExcludeMissing - fun _replacesPriceId(): JsonField = replacesPriceId + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata - /** - * Returns the raw JSON value of [allocationPrice]. - * - * Unlike [allocationPrice], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("allocation_price") - @ExcludeMissing - fun _allocationPrice(): JsonField = allocationPrice + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId - /** - * Returns the raw JSON value of [planPhaseOrder]. - * - * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("plan_phase_order") - @ExcludeMissing - fun _planPhaseOrder(): JsonField = planPhaseOrder + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - /** - * Returns the raw JSON value of [price]. - * - * Unlike [price], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("price") @ExcludeMissing fun _price(): JsonField = price + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + fun toBuilder() = Builder().from(this) - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + companion object { - fun toBuilder() = Builder().from(this) + /** + * Returns a mutable builder for constructing an instance of [EventOutput]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .eventOutputConfig() + * .itemId() + * .name() + * ``` + */ + fun builder() = Builder() + } - companion object { + /** A builder for [EventOutput]. */ + class Builder internal constructor() { - /** - * Returns a mutable builder for constructing an instance of [ReplacePrice]. - * - * The following fields are required: - * ```kotlin - * .replacesPriceId() - * ``` - */ - fun builder() = Builder() - } + private var cadence: JsonField? = null + private var eventOutputConfig: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonValue = JsonValue.from("event_output") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - /** A builder for [ReplacePrice]. */ - class Builder internal constructor() { + internal fun from(eventOutput: EventOutput) = apply { + cadence = eventOutput.cadence + eventOutputConfig = eventOutput.eventOutputConfig + itemId = eventOutput.itemId + modelType = eventOutput.modelType + name = eventOutput.name + billableMetricId = eventOutput.billableMetricId + billedInAdvance = eventOutput.billedInAdvance + billingCycleConfiguration = eventOutput.billingCycleConfiguration + conversionRate = eventOutput.conversionRate + conversionRateConfig = eventOutput.conversionRateConfig + currency = eventOutput.currency + dimensionalPriceConfiguration = eventOutput.dimensionalPriceConfiguration + externalPriceId = eventOutput.externalPriceId + fixedPriceQuantity = eventOutput.fixedPriceQuantity + invoiceGroupingKey = eventOutput.invoiceGroupingKey + invoicingCycleConfiguration = eventOutput.invoicingCycleConfiguration + metadata = eventOutput.metadata + referenceId = eventOutput.referenceId + additionalProperties = eventOutput.additionalProperties.toMutableMap() + } - private var replacesPriceId: JsonField? = null - private var allocationPrice: JsonField = JsonMissing.of() - private var planPhaseOrder: JsonField = JsonMissing.of() - private var price: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - internal fun from(replacePrice: ReplacePrice) = apply { - replacesPriceId = replacePrice.replacesPriceId - allocationPrice = replacePrice.allocationPrice - planPhaseOrder = replacePrice.planPhaseOrder - price = replacePrice.price - additionalProperties = replacePrice.additionalProperties.toMutableMap() - } + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - /** The id of the price on the plan to replace in the plan. */ - fun replacesPriceId(replacesPriceId: String) = - replacesPriceId(JsonField.of(replacesPriceId)) + /** Configuration for event_output pricing */ + fun eventOutputConfig(eventOutputConfig: EventOutputConfig) = + eventOutputConfig(JsonField.of(eventOutputConfig)) - /** - * Sets [Builder.replacesPriceId] to an arbitrary JSON value. - * - * You should usually call [Builder.replacesPriceId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun replacesPriceId(replacesPriceId: JsonField) = apply { - this.replacesPriceId = replacesPriceId - } + /** + * Sets [Builder.eventOutputConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.eventOutputConfig] with a well-typed + * [EventOutputConfig] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun eventOutputConfig(eventOutputConfig: JsonField) = apply { + this.eventOutputConfig = eventOutputConfig + } - /** The allocation price to add to the plan. */ - fun allocationPrice(allocationPrice: NewAllocationPrice?) = - allocationPrice(JsonField.ofNullable(allocationPrice)) + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - /** - * Sets [Builder.allocationPrice] to an arbitrary JSON value. - * - * You should usually call [Builder.allocationPrice] with a well-typed - * [NewAllocationPrice] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun allocationPrice(allocationPrice: JsonField) = apply { - this.allocationPrice = allocationPrice - } + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - /** The phase to replace this price from. */ - fun planPhaseOrder(planPhaseOrder: Long?) = - planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("event_output") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } - /** - * Alias for [Builder.planPhaseOrder]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) - /** - * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. - * - * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun planPhaseOrder(planPhaseOrder: JsonField) = apply { - this.planPhaseOrder = planPhaseOrder - } + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } - /** New plan price request body params. */ - fun price(price: Price?) = price(JsonField.ofNullable(price)) + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) - /** - * Sets [Builder.price] to an arbitrary JSON value. - * - * You should usually call [Builder.price] with a well-typed [Price] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun price(price: JsonField) = apply { this.price = price } + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } - /** Alias for calling [price] with `Price.ofUnit(unit)`. */ - fun price(unit: NewPlanUnitPrice) = price(Price.ofUnit(unit)) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) - /** Alias for calling [price] with `Price.ofTiered(tiered)`. */ - fun price(tiered: NewPlanTieredPrice) = price(Price.ofTiered(tiered)) + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) - /** Alias for calling [price] with `Price.ofBulk(bulk)`. */ - fun price(bulk: NewPlanBulkPrice) = price(Price.ofBulk(bulk)) + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } - /** Alias for calling [price] with `Price.ofPackage(package_)`. */ - fun price(package_: NewPlanPackagePrice) = price(Price.ofPackage(package_)) + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - /** Alias for calling [price] with `Price.ofMatrix(matrix)`. */ - fun price(matrix: NewPlanMatrixPrice) = price(Price.ofMatrix(matrix)) + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } - /** - * Alias for calling [price] with `Price.ofThresholdTotalAmount(thresholdTotalAmount)`. - */ - fun price(thresholdTotalAmount: NewPlanThresholdTotalAmountPrice) = - price(Price.ofThresholdTotalAmount(thresholdTotalAmount)) + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) - /** Alias for calling [price] with `Price.ofTieredPackage(tieredPackage)`. */ - fun price(tieredPackage: NewPlanTieredPackagePrice) = - price(Price.ofTieredPackage(tieredPackage)) + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) - /** Alias for calling [price] with `Price.ofTieredWithMinimum(tieredWithMinimum)`. */ - fun price(tieredWithMinimum: NewPlanTieredWithMinimumPrice) = - price(Price.ofTieredWithMinimum(tieredWithMinimum)) + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } - /** Alias for calling [price] with `Price.ofGroupedTiered(groupedTiered)`. */ - fun price(groupedTiered: NewPlanGroupedTieredPrice) = - price(Price.ofGroupedTiered(groupedTiered)) + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) - /** - * Alias for calling [price] with - * `Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)`. - */ - fun price(tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice) = - price(Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)) + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } - /** - * Alias for calling [price] with - * `Price.ofPackageWithAllocation(packageWithAllocation)`. - */ - fun price(packageWithAllocation: NewPlanPackageWithAllocationPrice) = - price(Price.ofPackageWithAllocation(packageWithAllocation)) + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) - /** Alias for calling [price] with `Price.ofUnitWithPercent(unitWithPercent)`. */ - fun price(unitWithPercent: NewPlanUnitWithPercentPrice) = - price(Price.ofUnitWithPercent(unitWithPercent)) + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) - /** - * Alias for calling [price] with `Price.ofMatrixWithAllocation(matrixWithAllocation)`. - */ - fun price(matrixWithAllocation: NewPlanMatrixWithAllocationPrice) = - price(Price.ofMatrixWithAllocation(matrixWithAllocation)) + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) - /** - * Alias for calling [price] with `Price.ofTieredWithProration(tieredWithProration)`. - */ - fun price(tieredWithProration: Price.TieredWithProration) = - price(Price.ofTieredWithProration(tieredWithProration)) + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) - /** Alias for calling [price] with `Price.ofUnitWithProration(unitWithProration)`. */ - fun price(unitWithProration: NewPlanUnitWithProrationPrice) = - price(Price.ofUnitWithProration(unitWithProration)) + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) - /** Alias for calling [price] with `Price.ofGroupedAllocation(groupedAllocation)`. */ - fun price(groupedAllocation: NewPlanGroupedAllocationPrice) = - price(Price.ofGroupedAllocation(groupedAllocation)) + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } - /** Alias for calling [price] with `Price.ofBulkWithProration(bulkWithProration)`. */ - fun price(bulkWithProration: NewPlanBulkWithProrationPrice) = - price(Price.ofBulkWithProration(bulkWithProration)) + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) - /** - * Alias for calling [price] with - * `Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)`. - */ - fun price(groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice) = - price(Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)) + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } - /** - * Alias for calling [price] with - * `Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)`. - */ - fun price(groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice) = - price(Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)) + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) - /** - * Alias for calling [price] with - * `Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)`. - */ - fun price(groupedWithMinMaxThresholds: Price.GroupedWithMinMaxThresholds) = - price(Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)) + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } - /** - * Alias for calling [price] with - * `Price.ofMatrixWithDisplayName(matrixWithDisplayName)`. - */ - fun price(matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice) = - price(Price.ofMatrixWithDisplayName(matrixWithDisplayName)) + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) - /** - * Alias for calling [price] with `Price.ofGroupedTieredPackage(groupedTieredPackage)`. - */ - fun price(groupedTieredPackage: NewPlanGroupedTieredPackagePrice) = - price(Price.ofGroupedTieredPackage(groupedTieredPackage)) + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) - /** - * Alias for calling [price] with - * `Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)`. - */ - fun price(maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice) = - price(Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)) + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } - /** - * Alias for calling [price] with - * `Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)`. - */ - fun price(scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice) = - price(Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)) + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) - /** - * Alias for calling [price] with - * `Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)`. - */ - fun price( - scalableMatrixWithTieredPricing: NewPlanScalableMatrixWithTieredPricingPrice - ) = price(Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)) + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } - /** - * Alias for calling [price] with - * `Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)`. - */ - fun price(cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice) = - price(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) - /** Alias for calling [price] with `Price.ofMinimum(minimum)`. */ - fun price(minimum: NewPlanMinimumCompositePrice) = price(Price.ofMinimum(minimum)) + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - /** Alias for calling [price] with `Price.ofPercent(percent)`. */ - fun price(percent: Price.Percent) = price(Price.ofPercent(percent)) + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - /** Alias for calling [price] with `Price.ofEventOutput(eventOutput)`. */ - fun price(eventOutput: Price.EventOutput) = price(Price.ofEventOutput(eventOutput)) + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - /** - * Returns an immutable instance of [ReplacePrice]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```kotlin - * .replacesPriceId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): ReplacePrice = - ReplacePrice( - checkRequired("replacesPriceId", replacesPriceId), - allocationPrice, - planPhaseOrder, - price, - additionalProperties.toMutableMap(), - ) - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - private var validated: Boolean = false + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - fun validate(): ReplacePrice = apply { - if (validated) { - return@apply + /** + * Returns an immutable instance of [EventOutput]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .eventOutputConfig() + * .itemId() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): EventOutput = + EventOutput( + checkRequired("cadence", cadence), + checkRequired("eventOutputConfig", eventOutputConfig), + checkRequired("itemId", itemId), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): EventOutput = apply { + if (validated) { + return@apply + } + + cadence().validate() + eventOutputConfig().validate() + itemId() + _modelType().let { + if (it != JsonValue.from("event_output")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (eventOutputConfig.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + modelType.let { if (it == JsonValue.from("event_output")) 1 else 0 } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Configuration for event_output pricing */ + class EventOutputConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val unitRatingKey: JsonField, + private val groupingKey: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("unit_rating_key") + @ExcludeMissing + unitRatingKey: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + ) : this(unitRatingKey, groupingKey, mutableMapOf()) + + /** + * The key in the event data to extract the unit rate from. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun unitRatingKey(): String = unitRatingKey.getRequired("unit_rating_key") + + /** + * An optional key in the event data to group by (e.g., event ID). All events + * will also be grouped by their unit rate. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun groupingKey(): String? = groupingKey.getNullable("grouping_key") + + /** + * Returns the raw JSON value of [unitRatingKey]. + * + * Unlike [unitRatingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_rating_key") + @ExcludeMissing + fun _unitRatingKey(): JsonField = unitRatingKey + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [EventOutputConfig]. + * + * The following fields are required: + * ```kotlin + * .unitRatingKey() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [EventOutputConfig]. */ + class Builder internal constructor() { + + private var unitRatingKey: JsonField? = null + private var groupingKey: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(eventOutputConfig: EventOutputConfig) = apply { + unitRatingKey = eventOutputConfig.unitRatingKey + groupingKey = eventOutputConfig.groupingKey + additionalProperties = + eventOutputConfig.additionalProperties.toMutableMap() + } + + /** The key in the event data to extract the unit rate from. */ + fun unitRatingKey(unitRatingKey: String) = + unitRatingKey(JsonField.of(unitRatingKey)) + + /** + * Sets [Builder.unitRatingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.unitRatingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun unitRatingKey(unitRatingKey: JsonField) = apply { + this.unitRatingKey = unitRatingKey + } + + /** + * An optional key in the event data to group by (e.g., event ID). All + * events will also be grouped by their unit rate. + */ + fun groupingKey(groupingKey: String?) = + groupingKey(JsonField.ofNullable(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [EventOutputConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .unitRatingKey() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): EventOutputConfig = + EventOutputConfig( + checkRequired("unitRatingKey", unitRatingKey), + groupingKey, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): EventOutputConfig = apply { + if (validated) { + return@apply + } + + unitRatingKey() + groupingKey() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (unitRatingKey.asKnown() == null) 0 else 1) + + (if (groupingKey.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is EventOutputConfig && + unitRatingKey == other.unitRatingKey && + groupingKey == other.groupingKey && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(unitRatingKey, groupingKey, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "EventOutputConfig{unitRatingKey=$unitRatingKey, groupingKey=$groupingKey, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is EventOutput && + cadence == other.cadence && + eventOutputConfig == other.eventOutputConfig && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + eventOutputConfig, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "EventOutput{cadence=$cadence, eventOutputConfig=$eventOutputConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AddPrice && + allocationPrice == other.allocationPrice && + planPhaseOrder == other.planPhaseOrder && + price == other.price && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(allocationPrice, planPhaseOrder, price, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AddPrice{allocationPrice=$allocationPrice, planPhaseOrder=$planPhaseOrder, price=$price, additionalProperties=$additionalProperties}" + } + + class RemoveAdjustment + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val adjustmentId: JsonField, + private val planPhaseOrder: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("adjustment_id") + @ExcludeMissing + adjustmentId: JsonField = JsonMissing.of(), + @JsonProperty("plan_phase_order") + @ExcludeMissing + planPhaseOrder: JsonField = JsonMissing.of(), + ) : this(adjustmentId, planPhaseOrder, mutableMapOf()) + + /** + * The id of the adjustment to remove from on the plan. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun adjustmentId(): String = adjustmentId.getRequired("adjustment_id") + + /** + * The phase to remove this adjustment from. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun planPhaseOrder(): Long? = planPhaseOrder.getNullable("plan_phase_order") + + /** + * Returns the raw JSON value of [adjustmentId]. + * + * Unlike [adjustmentId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("adjustment_id") + @ExcludeMissing + fun _adjustmentId(): JsonField = adjustmentId + + /** + * Returns the raw JSON value of [planPhaseOrder]. + * + * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [RemoveAdjustment]. + * + * The following fields are required: + * ```kotlin + * .adjustmentId() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [RemoveAdjustment]. */ + class Builder internal constructor() { + + private var adjustmentId: JsonField? = null + private var planPhaseOrder: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(removeAdjustment: RemoveAdjustment) = apply { + adjustmentId = removeAdjustment.adjustmentId + planPhaseOrder = removeAdjustment.planPhaseOrder + additionalProperties = removeAdjustment.additionalProperties.toMutableMap() + } + + /** The id of the adjustment to remove from on the plan. */ + fun adjustmentId(adjustmentId: String) = adjustmentId(JsonField.of(adjustmentId)) + + /** + * Sets [Builder.adjustmentId] to an arbitrary JSON value. + * + * You should usually call [Builder.adjustmentId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun adjustmentId(adjustmentId: JsonField) = apply { + this.adjustmentId = adjustmentId + } + + /** The phase to remove this adjustment from. */ + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + + /** + * Alias for [Builder.planPhaseOrder]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + + /** + * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. + * + * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun planPhaseOrder(planPhaseOrder: JsonField) = apply { + this.planPhaseOrder = planPhaseOrder + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [RemoveAdjustment]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .adjustmentId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): RemoveAdjustment = + RemoveAdjustment( + checkRequired("adjustmentId", adjustmentId), + planPhaseOrder, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): RemoveAdjustment = apply { + if (validated) { + return@apply + } + + adjustmentId() + planPhaseOrder() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (adjustmentId.asKnown() == null) 0 else 1) + + (if (planPhaseOrder.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RemoveAdjustment && + adjustmentId == other.adjustmentId && + planPhaseOrder == other.planPhaseOrder && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(adjustmentId, planPhaseOrder, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "RemoveAdjustment{adjustmentId=$adjustmentId, planPhaseOrder=$planPhaseOrder, additionalProperties=$additionalProperties}" + } + + class RemovePrice + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val priceId: JsonField, + private val planPhaseOrder: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("price_id") @ExcludeMissing priceId: JsonField = JsonMissing.of(), + @JsonProperty("plan_phase_order") + @ExcludeMissing + planPhaseOrder: JsonField = JsonMissing.of(), + ) : this(priceId, planPhaseOrder, mutableMapOf()) + + /** + * The id of the price to remove from the plan. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun priceId(): String = priceId.getRequired("price_id") + + /** + * The phase to remove this price from. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun planPhaseOrder(): Long? = planPhaseOrder.getNullable("plan_phase_order") + + /** + * Returns the raw JSON value of [priceId]. + * + * Unlike [priceId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId + + /** + * Returns the raw JSON value of [planPhaseOrder]. + * + * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [RemovePrice]. + * + * The following fields are required: + * ```kotlin + * .priceId() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [RemovePrice]. */ + class Builder internal constructor() { + + private var priceId: JsonField? = null + private var planPhaseOrder: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(removePrice: RemovePrice) = apply { + priceId = removePrice.priceId + planPhaseOrder = removePrice.planPhaseOrder + additionalProperties = removePrice.additionalProperties.toMutableMap() + } + + /** The id of the price to remove from the plan. */ + fun priceId(priceId: String) = priceId(JsonField.of(priceId)) + + /** + * Sets [Builder.priceId] to an arbitrary JSON value. + * + * You should usually call [Builder.priceId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun priceId(priceId: JsonField) = apply { this.priceId = priceId } + + /** The phase to remove this price from. */ + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + + /** + * Alias for [Builder.planPhaseOrder]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + + /** + * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. + * + * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun planPhaseOrder(planPhaseOrder: JsonField) = apply { + this.planPhaseOrder = planPhaseOrder + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [RemovePrice]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .priceId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): RemovePrice = + RemovePrice( + checkRequired("priceId", priceId), + planPhaseOrder, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): RemovePrice = apply { + if (validated) { + return@apply + } + + priceId() + planPhaseOrder() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (priceId.asKnown() == null) 0 else 1) + + (if (planPhaseOrder.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RemovePrice && + priceId == other.priceId && + planPhaseOrder == other.planPhaseOrder && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(priceId, planPhaseOrder, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "RemovePrice{priceId=$priceId, planPhaseOrder=$planPhaseOrder, additionalProperties=$additionalProperties}" + } + + class ReplaceAdjustment + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val adjustment: JsonField, + private val replacesAdjustmentId: JsonField, + private val planPhaseOrder: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("adjustment") + @ExcludeMissing + adjustment: JsonField = JsonMissing.of(), + @JsonProperty("replaces_adjustment_id") + @ExcludeMissing + replacesAdjustmentId: JsonField = JsonMissing.of(), + @JsonProperty("plan_phase_order") + @ExcludeMissing + planPhaseOrder: JsonField = JsonMissing.of(), + ) : this(adjustment, replacesAdjustmentId, planPhaseOrder, mutableMapOf()) + + /** + * The definition of a new adjustment to create and add to the plan. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun adjustment(): Adjustment = adjustment.getRequired("adjustment") + + /** + * The id of the adjustment on the plan to replace in the plan. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun replacesAdjustmentId(): String = + replacesAdjustmentId.getRequired("replaces_adjustment_id") + + /** + * The phase to replace this adjustment from. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun planPhaseOrder(): Long? = planPhaseOrder.getNullable("plan_phase_order") + + /** + * Returns the raw JSON value of [adjustment]. + * + * Unlike [adjustment], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("adjustment") + @ExcludeMissing + fun _adjustment(): JsonField = adjustment + + /** + * Returns the raw JSON value of [replacesAdjustmentId]. + * + * Unlike [replacesAdjustmentId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("replaces_adjustment_id") + @ExcludeMissing + fun _replacesAdjustmentId(): JsonField = replacesAdjustmentId + + /** + * Returns the raw JSON value of [planPhaseOrder]. + * + * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ReplaceAdjustment]. + * + * The following fields are required: + * ```kotlin + * .adjustment() + * .replacesAdjustmentId() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [ReplaceAdjustment]. */ + class Builder internal constructor() { + + private var adjustment: JsonField? = null + private var replacesAdjustmentId: JsonField? = null + private var planPhaseOrder: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(replaceAdjustment: ReplaceAdjustment) = apply { + adjustment = replaceAdjustment.adjustment + replacesAdjustmentId = replaceAdjustment.replacesAdjustmentId + planPhaseOrder = replaceAdjustment.planPhaseOrder + additionalProperties = replaceAdjustment.additionalProperties.toMutableMap() + } + + /** The definition of a new adjustment to create and add to the plan. */ + fun adjustment(adjustment: Adjustment) = adjustment(JsonField.of(adjustment)) + + /** + * Sets [Builder.adjustment] to an arbitrary JSON value. + * + * You should usually call [Builder.adjustment] with a well-typed [Adjustment] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun adjustment(adjustment: JsonField) = apply { + this.adjustment = adjustment + } + + /** + * Alias for calling [adjustment] with + * `Adjustment.ofPercentageDiscount(percentageDiscount)`. + */ + fun adjustment(percentageDiscount: NewPercentageDiscount) = + adjustment(Adjustment.ofPercentageDiscount(percentageDiscount)) + + /** + * Alias for calling [adjustment] with the following: + * ```kotlin + * NewPercentageDiscount.builder() + * .adjustmentType(NewPercentageDiscount.AdjustmentType.PERCENTAGE_DISCOUNT) + * .percentageDiscount(percentageDiscount) + * .build() + * ``` + */ + fun percentageDiscountAdjustment(percentageDiscount: Double) = + adjustment( + NewPercentageDiscount.builder() + .adjustmentType(NewPercentageDiscount.AdjustmentType.PERCENTAGE_DISCOUNT) + .percentageDiscount(percentageDiscount) + .build() + ) + + /** Alias for calling [adjustment] with `Adjustment.ofUsageDiscount(usageDiscount)`. */ + fun adjustment(usageDiscount: NewUsageDiscount) = + adjustment(Adjustment.ofUsageDiscount(usageDiscount)) + + /** + * Alias for calling [adjustment] with the following: + * ```kotlin + * NewUsageDiscount.builder() + * .adjustmentType(NewUsageDiscount.AdjustmentType.USAGE_DISCOUNT) + * .usageDiscount(usageDiscount) + * .build() + * ``` + */ + fun usageDiscountAdjustment(usageDiscount: Double) = + adjustment( + NewUsageDiscount.builder() + .adjustmentType(NewUsageDiscount.AdjustmentType.USAGE_DISCOUNT) + .usageDiscount(usageDiscount) + .build() + ) + + /** + * Alias for calling [adjustment] with `Adjustment.ofAmountDiscount(amountDiscount)`. + */ + fun adjustment(amountDiscount: NewAmountDiscount) = + adjustment(Adjustment.ofAmountDiscount(amountDiscount)) + + /** + * Alias for calling [adjustment] with the following: + * ```kotlin + * NewAmountDiscount.builder() + * .adjustmentType(NewAmountDiscount.AdjustmentType.AMOUNT_DISCOUNT) + * .amountDiscount(amountDiscount) + * .build() + * ``` + */ + fun amountDiscountAdjustment(amountDiscount: String) = + adjustment( + NewAmountDiscount.builder() + .adjustmentType(NewAmountDiscount.AdjustmentType.AMOUNT_DISCOUNT) + .amountDiscount(amountDiscount) + .build() + ) + + /** Alias for calling [adjustment] with `Adjustment.ofMinimum(minimum)`. */ + fun adjustment(minimum: NewMinimum) = adjustment(Adjustment.ofMinimum(minimum)) + + /** Alias for calling [adjustment] with `Adjustment.ofMaximum(maximum)`. */ + fun adjustment(maximum: NewMaximum) = adjustment(Adjustment.ofMaximum(maximum)) + + /** + * Alias for calling [adjustment] with the following: + * ```kotlin + * NewMaximum.builder() + * .adjustmentType(NewMaximum.AdjustmentType.MAXIMUM) + * .maximumAmount(maximumAmount) + * .build() + * ``` + */ + fun maximumAdjustment(maximumAmount: String) = + adjustment( + NewMaximum.builder() + .adjustmentType(NewMaximum.AdjustmentType.MAXIMUM) + .maximumAmount(maximumAmount) + .build() + ) + + /** The id of the adjustment on the plan to replace in the plan. */ + fun replacesAdjustmentId(replacesAdjustmentId: String) = + replacesAdjustmentId(JsonField.of(replacesAdjustmentId)) + + /** + * Sets [Builder.replacesAdjustmentId] to an arbitrary JSON value. + * + * You should usually call [Builder.replacesAdjustmentId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun replacesAdjustmentId(replacesAdjustmentId: JsonField) = apply { + this.replacesAdjustmentId = replacesAdjustmentId + } + + /** The phase to replace this adjustment from. */ + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + + /** + * Alias for [Builder.planPhaseOrder]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + + /** + * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. + * + * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun planPhaseOrder(planPhaseOrder: JsonField) = apply { + this.planPhaseOrder = planPhaseOrder + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ReplaceAdjustment]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .adjustment() + * .replacesAdjustmentId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ReplaceAdjustment = + ReplaceAdjustment( + checkRequired("adjustment", adjustment), + checkRequired("replacesAdjustmentId", replacesAdjustmentId), + planPhaseOrder, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ReplaceAdjustment = apply { + if (validated) { + return@apply + } + + adjustment().validate() + replacesAdjustmentId() + planPhaseOrder() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (adjustment.asKnown()?.validity() ?: 0) + + (if (replacesAdjustmentId.asKnown() == null) 0 else 1) + + (if (planPhaseOrder.asKnown() == null) 0 else 1) + + /** The definition of a new adjustment to create and add to the plan. */ + @JsonDeserialize(using = Adjustment.Deserializer::class) + @JsonSerialize(using = Adjustment.Serializer::class) + class Adjustment + private constructor( + private val percentageDiscount: NewPercentageDiscount? = null, + private val usageDiscount: NewUsageDiscount? = null, + private val amountDiscount: NewAmountDiscount? = null, + private val minimum: NewMinimum? = null, + private val maximum: NewMaximum? = null, + private val _json: JsonValue? = null, + ) { + + fun percentageDiscount(): NewPercentageDiscount? = percentageDiscount + + fun usageDiscount(): NewUsageDiscount? = usageDiscount + + fun amountDiscount(): NewAmountDiscount? = amountDiscount + + fun minimum(): NewMinimum? = minimum + + fun maximum(): NewMaximum? = maximum + + fun isPercentageDiscount(): Boolean = percentageDiscount != null + + fun isUsageDiscount(): Boolean = usageDiscount != null + + fun isAmountDiscount(): Boolean = amountDiscount != null + + fun isMinimum(): Boolean = minimum != null + + fun isMaximum(): Boolean = maximum != null + + fun asPercentageDiscount(): NewPercentageDiscount = + percentageDiscount.getOrThrow("percentageDiscount") + + fun asUsageDiscount(): NewUsageDiscount = usageDiscount.getOrThrow("usageDiscount") + + fun asAmountDiscount(): NewAmountDiscount = amountDiscount.getOrThrow("amountDiscount") + + fun asMinimum(): NewMinimum = minimum.getOrThrow("minimum") + + fun asMaximum(): NewMaximum = maximum.getOrThrow("maximum") + + fun _json(): JsonValue? = _json + + fun accept(visitor: Visitor): T = + when { + percentageDiscount != null -> + visitor.visitPercentageDiscount(percentageDiscount) + usageDiscount != null -> visitor.visitUsageDiscount(usageDiscount) + amountDiscount != null -> visitor.visitAmountDiscount(amountDiscount) + minimum != null -> visitor.visitMinimum(minimum) + maximum != null -> visitor.visitMaximum(maximum) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Adjustment = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitPercentageDiscount( + percentageDiscount: NewPercentageDiscount + ) { + percentageDiscount.validate() + } + + override fun visitUsageDiscount(usageDiscount: NewUsageDiscount) { + usageDiscount.validate() + } + + override fun visitAmountDiscount(amountDiscount: NewAmountDiscount) { + amountDiscount.validate() + } + + override fun visitMinimum(minimum: NewMinimum) { + minimum.validate() + } + + override fun visitMaximum(maximum: NewMaximum) { + maximum.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitPercentageDiscount( + percentageDiscount: NewPercentageDiscount + ) = percentageDiscount.validity() + + override fun visitUsageDiscount(usageDiscount: NewUsageDiscount) = + usageDiscount.validity() + + override fun visitAmountDiscount(amountDiscount: NewAmountDiscount) = + amountDiscount.validity() + + override fun visitMinimum(minimum: NewMinimum) = minimum.validity() + + override fun visitMaximum(maximum: NewMaximum) = maximum.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Adjustment && + percentageDiscount == other.percentageDiscount && + usageDiscount == other.usageDiscount && + amountDiscount == other.amountDiscount && + minimum == other.minimum && + maximum == other.maximum + } + + override fun hashCode(): Int = + Objects.hash(percentageDiscount, usageDiscount, amountDiscount, minimum, maximum) + + override fun toString(): String = + when { + percentageDiscount != null -> + "Adjustment{percentageDiscount=$percentageDiscount}" + usageDiscount != null -> "Adjustment{usageDiscount=$usageDiscount}" + amountDiscount != null -> "Adjustment{amountDiscount=$amountDiscount}" + minimum != null -> "Adjustment{minimum=$minimum}" + maximum != null -> "Adjustment{maximum=$maximum}" + _json != null -> "Adjustment{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Adjustment") + } + + companion object { + + fun ofPercentageDiscount(percentageDiscount: NewPercentageDiscount) = + Adjustment(percentageDiscount = percentageDiscount) + + fun ofUsageDiscount(usageDiscount: NewUsageDiscount) = + Adjustment(usageDiscount = usageDiscount) + + fun ofAmountDiscount(amountDiscount: NewAmountDiscount) = + Adjustment(amountDiscount = amountDiscount) + + fun ofMinimum(minimum: NewMinimum) = Adjustment(minimum = minimum) + + fun ofMaximum(maximum: NewMaximum) = Adjustment(maximum = maximum) + } + + /** + * An interface that defines how to map each variant of [Adjustment] to a value of type + * [T]. + */ + interface Visitor { + + fun visitPercentageDiscount(percentageDiscount: NewPercentageDiscount): T + + fun visitUsageDiscount(usageDiscount: NewUsageDiscount): T + + fun visitAmountDiscount(amountDiscount: NewAmountDiscount): T + + fun visitMinimum(minimum: NewMinimum): T + + fun visitMaximum(maximum: NewMaximum): T + + /** + * Maps an unknown variant of [Adjustment] to a value of type [T]. + * + * An instance of [Adjustment] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the + * SDK is unaware of. + * + * @throws OrbInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw OrbInvalidDataException("Unknown Adjustment: $json") + } + } + + internal class Deserializer : BaseDeserializer(Adjustment::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Adjustment { + val json = JsonValue.fromJsonNode(node) + val adjustmentType = json.asObject()?.get("adjustment_type")?.asString() + + when (adjustmentType) { + "percentage_discount" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Adjustment(percentageDiscount = it, _json = json) } + ?: Adjustment(_json = json) + } + "usage_discount" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(usageDiscount = it, _json = json) + } ?: Adjustment(_json = json) + } + "amount_discount" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(amountDiscount = it, _json = json) + } ?: Adjustment(_json = json) + } + "minimum" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(minimum = it, _json = json) + } ?: Adjustment(_json = json) + } + "maximum" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(maximum = it, _json = json) + } ?: Adjustment(_json = json) + } + } + + return Adjustment(_json = json) + } + } + + internal class Serializer : BaseSerializer(Adjustment::class) { + + override fun serialize( + value: Adjustment, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.percentageDiscount != null -> + generator.writeObject(value.percentageDiscount) + value.usageDiscount != null -> generator.writeObject(value.usageDiscount) + value.amountDiscount != null -> generator.writeObject(value.amountDiscount) + value.minimum != null -> generator.writeObject(value.minimum) + value.maximum != null -> generator.writeObject(value.maximum) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Adjustment") + } + } + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ReplaceAdjustment && + adjustment == other.adjustment && + replacesAdjustmentId == other.replacesAdjustmentId && + planPhaseOrder == other.planPhaseOrder && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(adjustment, replacesAdjustmentId, planPhaseOrder, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ReplaceAdjustment{adjustment=$adjustment, replacesAdjustmentId=$replacesAdjustmentId, planPhaseOrder=$planPhaseOrder, additionalProperties=$additionalProperties}" + } + + class ReplacePrice + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val replacesPriceId: JsonField, + private val allocationPrice: JsonField, + private val planPhaseOrder: JsonField, + private val price: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("replaces_price_id") + @ExcludeMissing + replacesPriceId: JsonField = JsonMissing.of(), + @JsonProperty("allocation_price") + @ExcludeMissing + allocationPrice: JsonField = JsonMissing.of(), + @JsonProperty("plan_phase_order") + @ExcludeMissing + planPhaseOrder: JsonField = JsonMissing.of(), + @JsonProperty("price") @ExcludeMissing price: JsonField = JsonMissing.of(), + ) : this(replacesPriceId, allocationPrice, planPhaseOrder, price, mutableMapOf()) + + /** + * The id of the price on the plan to replace in the plan. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun replacesPriceId(): String = replacesPriceId.getRequired("replaces_price_id") + + /** + * The allocation price to add to the plan. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun allocationPrice(): NewAllocationPrice? = allocationPrice.getNullable("allocation_price") + + /** + * The phase to replace this price from. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun planPhaseOrder(): Long? = planPhaseOrder.getNullable("plan_phase_order") + + /** + * New plan price request body params. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun price(): Price? = price.getNullable("price") + + /** + * Returns the raw JSON value of [replacesPriceId]. + * + * Unlike [replacesPriceId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("replaces_price_id") + @ExcludeMissing + fun _replacesPriceId(): JsonField = replacesPriceId + + /** + * Returns the raw JSON value of [allocationPrice]. + * + * Unlike [allocationPrice], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("allocation_price") + @ExcludeMissing + fun _allocationPrice(): JsonField = allocationPrice + + /** + * Returns the raw JSON value of [planPhaseOrder]. + * + * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder + + /** + * Returns the raw JSON value of [price]. + * + * Unlike [price], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("price") @ExcludeMissing fun _price(): JsonField = price + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ReplacePrice]. + * + * The following fields are required: + * ```kotlin + * .replacesPriceId() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [ReplacePrice]. */ + class Builder internal constructor() { + + private var replacesPriceId: JsonField? = null + private var allocationPrice: JsonField = JsonMissing.of() + private var planPhaseOrder: JsonField = JsonMissing.of() + private var price: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(replacePrice: ReplacePrice) = apply { + replacesPriceId = replacePrice.replacesPriceId + allocationPrice = replacePrice.allocationPrice + planPhaseOrder = replacePrice.planPhaseOrder + price = replacePrice.price + additionalProperties = replacePrice.additionalProperties.toMutableMap() + } + + /** The id of the price on the plan to replace in the plan. */ + fun replacesPriceId(replacesPriceId: String) = + replacesPriceId(JsonField.of(replacesPriceId)) + + /** + * Sets [Builder.replacesPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.replacesPriceId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun replacesPriceId(replacesPriceId: JsonField) = apply { + this.replacesPriceId = replacesPriceId + } + + /** The allocation price to add to the plan. */ + fun allocationPrice(allocationPrice: NewAllocationPrice?) = + allocationPrice(JsonField.ofNullable(allocationPrice)) + + /** + * Sets [Builder.allocationPrice] to an arbitrary JSON value. + * + * You should usually call [Builder.allocationPrice] with a well-typed + * [NewAllocationPrice] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun allocationPrice(allocationPrice: JsonField) = apply { + this.allocationPrice = allocationPrice + } + + /** The phase to replace this price from. */ + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + + /** + * Alias for [Builder.planPhaseOrder]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + + /** + * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. + * + * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun planPhaseOrder(planPhaseOrder: JsonField) = apply { + this.planPhaseOrder = planPhaseOrder + } + + /** New plan price request body params. */ + fun price(price: Price?) = price(JsonField.ofNullable(price)) + + /** + * Sets [Builder.price] to an arbitrary JSON value. + * + * You should usually call [Builder.price] with a well-typed [Price] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun price(price: JsonField) = apply { this.price = price } + + /** Alias for calling [price] with `Price.ofUnit(unit)`. */ + fun price(unit: NewPlanUnitPrice) = price(Price.ofUnit(unit)) + + /** Alias for calling [price] with `Price.ofTiered(tiered)`. */ + fun price(tiered: NewPlanTieredPrice) = price(Price.ofTiered(tiered)) + + /** Alias for calling [price] with `Price.ofBulk(bulk)`. */ + fun price(bulk: NewPlanBulkPrice) = price(Price.ofBulk(bulk)) + + /** Alias for calling [price] with `Price.ofBulkWithFilters(bulkWithFilters)`. */ + fun price(bulkWithFilters: Price.BulkWithFilters) = + price(Price.ofBulkWithFilters(bulkWithFilters)) + + /** Alias for calling [price] with `Price.ofPackage(package_)`. */ + fun price(package_: NewPlanPackagePrice) = price(Price.ofPackage(package_)) + + /** Alias for calling [price] with `Price.ofMatrix(matrix)`. */ + fun price(matrix: NewPlanMatrixPrice) = price(Price.ofMatrix(matrix)) + + /** + * Alias for calling [price] with `Price.ofThresholdTotalAmount(thresholdTotalAmount)`. + */ + fun price(thresholdTotalAmount: NewPlanThresholdTotalAmountPrice) = + price(Price.ofThresholdTotalAmount(thresholdTotalAmount)) + + /** Alias for calling [price] with `Price.ofTieredPackage(tieredPackage)`. */ + fun price(tieredPackage: NewPlanTieredPackagePrice) = + price(Price.ofTieredPackage(tieredPackage)) + + /** Alias for calling [price] with `Price.ofTieredWithMinimum(tieredWithMinimum)`. */ + fun price(tieredWithMinimum: NewPlanTieredWithMinimumPrice) = + price(Price.ofTieredWithMinimum(tieredWithMinimum)) + + /** Alias for calling [price] with `Price.ofGroupedTiered(groupedTiered)`. */ + fun price(groupedTiered: NewPlanGroupedTieredPrice) = + price(Price.ofGroupedTiered(groupedTiered)) + + /** + * Alias for calling [price] with + * `Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)`. + */ + fun price(tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice) = + price(Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)) + + /** + * Alias for calling [price] with + * `Price.ofPackageWithAllocation(packageWithAllocation)`. + */ + fun price(packageWithAllocation: NewPlanPackageWithAllocationPrice) = + price(Price.ofPackageWithAllocation(packageWithAllocation)) + + /** Alias for calling [price] with `Price.ofUnitWithPercent(unitWithPercent)`. */ + fun price(unitWithPercent: NewPlanUnitWithPercentPrice) = + price(Price.ofUnitWithPercent(unitWithPercent)) + + /** + * Alias for calling [price] with `Price.ofMatrixWithAllocation(matrixWithAllocation)`. + */ + fun price(matrixWithAllocation: NewPlanMatrixWithAllocationPrice) = + price(Price.ofMatrixWithAllocation(matrixWithAllocation)) + + /** + * Alias for calling [price] with `Price.ofTieredWithProration(tieredWithProration)`. + */ + fun price(tieredWithProration: Price.TieredWithProration) = + price(Price.ofTieredWithProration(tieredWithProration)) + + /** Alias for calling [price] with `Price.ofUnitWithProration(unitWithProration)`. */ + fun price(unitWithProration: NewPlanUnitWithProrationPrice) = + price(Price.ofUnitWithProration(unitWithProration)) + + /** Alias for calling [price] with `Price.ofGroupedAllocation(groupedAllocation)`. */ + fun price(groupedAllocation: NewPlanGroupedAllocationPrice) = + price(Price.ofGroupedAllocation(groupedAllocation)) + + /** Alias for calling [price] with `Price.ofBulkWithProration(bulkWithProration)`. */ + fun price(bulkWithProration: NewPlanBulkWithProrationPrice) = + price(Price.ofBulkWithProration(bulkWithProration)) + + /** + * Alias for calling [price] with + * `Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)`. + */ + fun price(groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice) = + price(Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)) + + /** + * Alias for calling [price] with + * `Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)`. + */ + fun price(groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice) = + price(Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)) + + /** + * Alias for calling [price] with + * `Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)`. + */ + fun price(groupedWithMinMaxThresholds: Price.GroupedWithMinMaxThresholds) = + price(Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)) + + /** + * Alias for calling [price] with + * `Price.ofMatrixWithDisplayName(matrixWithDisplayName)`. + */ + fun price(matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice) = + price(Price.ofMatrixWithDisplayName(matrixWithDisplayName)) + + /** + * Alias for calling [price] with `Price.ofGroupedTieredPackage(groupedTieredPackage)`. + */ + fun price(groupedTieredPackage: NewPlanGroupedTieredPackagePrice) = + price(Price.ofGroupedTieredPackage(groupedTieredPackage)) + + /** + * Alias for calling [price] with + * `Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)`. + */ + fun price(maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice) = + price(Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)) + + /** + * Alias for calling [price] with + * `Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)`. + */ + fun price(scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice) = + price(Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)) + + /** + * Alias for calling [price] with + * `Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)`. + */ + fun price( + scalableMatrixWithTieredPricing: NewPlanScalableMatrixWithTieredPricingPrice + ) = price(Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)) + + /** + * Alias for calling [price] with + * `Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)`. + */ + fun price(cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice) = + price(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) + + /** Alias for calling [price] with `Price.ofMinimum(minimum)`. */ + fun price(minimum: NewPlanMinimumCompositePrice) = price(Price.ofMinimum(minimum)) + + /** Alias for calling [price] with `Price.ofPercent(percent)`. */ + fun price(percent: Price.Percent) = price(Price.ofPercent(percent)) + + /** Alias for calling [price] with `Price.ofEventOutput(eventOutput)`. */ + fun price(eventOutput: Price.EventOutput) = price(Price.ofEventOutput(eventOutput)) + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ReplacePrice]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .replacesPriceId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ReplacePrice = + ReplacePrice( + checkRequired("replacesPriceId", replacesPriceId), + allocationPrice, + planPhaseOrder, + price, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ReplacePrice = apply { + if (validated) { + return@apply + } + + replacesPriceId() + allocationPrice()?.validate() + planPhaseOrder() + price()?.validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (replacesPriceId.asKnown() == null) 0 else 1) + + (allocationPrice.asKnown()?.validity() ?: 0) + + (if (planPhaseOrder.asKnown() == null) 0 else 1) + + (price.asKnown()?.validity() ?: 0) + + /** New plan price request body params. */ + @JsonDeserialize(using = Price.Deserializer::class) + @JsonSerialize(using = Price.Serializer::class) + class Price + private constructor( + private val unit: NewPlanUnitPrice? = null, + private val tiered: NewPlanTieredPrice? = null, + private val bulk: NewPlanBulkPrice? = null, + private val bulkWithFilters: BulkWithFilters? = null, + private val package_: NewPlanPackagePrice? = null, + private val matrix: NewPlanMatrixPrice? = null, + private val thresholdTotalAmount: NewPlanThresholdTotalAmountPrice? = null, + private val tieredPackage: NewPlanTieredPackagePrice? = null, + private val tieredWithMinimum: NewPlanTieredWithMinimumPrice? = null, + private val groupedTiered: NewPlanGroupedTieredPrice? = null, + private val tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice? = null, + private val packageWithAllocation: NewPlanPackageWithAllocationPrice? = null, + private val unitWithPercent: NewPlanUnitWithPercentPrice? = null, + private val matrixWithAllocation: NewPlanMatrixWithAllocationPrice? = null, + private val tieredWithProration: TieredWithProration? = null, + private val unitWithProration: NewPlanUnitWithProrationPrice? = null, + private val groupedAllocation: NewPlanGroupedAllocationPrice? = null, + private val bulkWithProration: NewPlanBulkWithProrationPrice? = null, + private val groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice? = null, + private val groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice? = null, + private val groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds? = null, + private val matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice? = null, + private val groupedTieredPackage: NewPlanGroupedTieredPackagePrice? = null, + private val maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice? = null, + private val scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice? = + null, + private val scalableMatrixWithTieredPricing: + NewPlanScalableMatrixWithTieredPricingPrice? = + null, + private val cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice? = null, + private val minimum: NewPlanMinimumCompositePrice? = null, + private val percent: Percent? = null, + private val eventOutput: EventOutput? = null, + private val _json: JsonValue? = null, + ) { + + fun unit(): NewPlanUnitPrice? = unit + + fun tiered(): NewPlanTieredPrice? = tiered + + fun bulk(): NewPlanBulkPrice? = bulk + + fun bulkWithFilters(): BulkWithFilters? = bulkWithFilters + + fun package_(): NewPlanPackagePrice? = package_ + + fun matrix(): NewPlanMatrixPrice? = matrix + + fun thresholdTotalAmount(): NewPlanThresholdTotalAmountPrice? = thresholdTotalAmount + + fun tieredPackage(): NewPlanTieredPackagePrice? = tieredPackage + + fun tieredWithMinimum(): NewPlanTieredWithMinimumPrice? = tieredWithMinimum + + fun groupedTiered(): NewPlanGroupedTieredPrice? = groupedTiered + + fun tieredPackageWithMinimum(): NewPlanTieredPackageWithMinimumPrice? = + tieredPackageWithMinimum + + fun packageWithAllocation(): NewPlanPackageWithAllocationPrice? = packageWithAllocation + + fun unitWithPercent(): NewPlanUnitWithPercentPrice? = unitWithPercent + + fun matrixWithAllocation(): NewPlanMatrixWithAllocationPrice? = matrixWithAllocation + + fun tieredWithProration(): TieredWithProration? = tieredWithProration + + fun unitWithProration(): NewPlanUnitWithProrationPrice? = unitWithProration + + fun groupedAllocation(): NewPlanGroupedAllocationPrice? = groupedAllocation + + fun bulkWithProration(): NewPlanBulkWithProrationPrice? = bulkWithProration + + fun groupedWithProratedMinimum(): NewPlanGroupedWithProratedMinimumPrice? = + groupedWithProratedMinimum + + fun groupedWithMeteredMinimum(): NewPlanGroupedWithMeteredMinimumPrice? = + groupedWithMeteredMinimum + + fun groupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds? = + groupedWithMinMaxThresholds + + fun matrixWithDisplayName(): NewPlanMatrixWithDisplayNamePrice? = matrixWithDisplayName + + fun groupedTieredPackage(): NewPlanGroupedTieredPackagePrice? = groupedTieredPackage + + fun maxGroupTieredPackage(): NewPlanMaxGroupTieredPackagePrice? = maxGroupTieredPackage + + fun scalableMatrixWithUnitPricing(): NewPlanScalableMatrixWithUnitPricingPrice? = + scalableMatrixWithUnitPricing + + fun scalableMatrixWithTieredPricing(): NewPlanScalableMatrixWithTieredPricingPrice? = + scalableMatrixWithTieredPricing + + fun cumulativeGroupedBulk(): NewPlanCumulativeGroupedBulkPrice? = cumulativeGroupedBulk + + fun minimum(): NewPlanMinimumCompositePrice? = minimum + + fun percent(): Percent? = percent + + fun eventOutput(): EventOutput? = eventOutput + + fun isUnit(): Boolean = unit != null + + fun isTiered(): Boolean = tiered != null + + fun isBulk(): Boolean = bulk != null + + fun isBulkWithFilters(): Boolean = bulkWithFilters != null + + fun isPackage(): Boolean = package_ != null + + fun isMatrix(): Boolean = matrix != null + + fun isThresholdTotalAmount(): Boolean = thresholdTotalAmount != null + + fun isTieredPackage(): Boolean = tieredPackage != null + + fun isTieredWithMinimum(): Boolean = tieredWithMinimum != null + + fun isGroupedTiered(): Boolean = groupedTiered != null + + fun isTieredPackageWithMinimum(): Boolean = tieredPackageWithMinimum != null + + fun isPackageWithAllocation(): Boolean = packageWithAllocation != null + + fun isUnitWithPercent(): Boolean = unitWithPercent != null + + fun isMatrixWithAllocation(): Boolean = matrixWithAllocation != null + + fun isTieredWithProration(): Boolean = tieredWithProration != null + + fun isUnitWithProration(): Boolean = unitWithProration != null + + fun isGroupedAllocation(): Boolean = groupedAllocation != null + + fun isBulkWithProration(): Boolean = bulkWithProration != null + + fun isGroupedWithProratedMinimum(): Boolean = groupedWithProratedMinimum != null + + fun isGroupedWithMeteredMinimum(): Boolean = groupedWithMeteredMinimum != null + + fun isGroupedWithMinMaxThresholds(): Boolean = groupedWithMinMaxThresholds != null + + fun isMatrixWithDisplayName(): Boolean = matrixWithDisplayName != null + + fun isGroupedTieredPackage(): Boolean = groupedTieredPackage != null + + fun isMaxGroupTieredPackage(): Boolean = maxGroupTieredPackage != null + + fun isScalableMatrixWithUnitPricing(): Boolean = scalableMatrixWithUnitPricing != null + + fun isScalableMatrixWithTieredPricing(): Boolean = + scalableMatrixWithTieredPricing != null + + fun isCumulativeGroupedBulk(): Boolean = cumulativeGroupedBulk != null + + fun isMinimum(): Boolean = minimum != null + + fun isPercent(): Boolean = percent != null + + fun isEventOutput(): Boolean = eventOutput != null + + fun asUnit(): NewPlanUnitPrice = unit.getOrThrow("unit") + + fun asTiered(): NewPlanTieredPrice = tiered.getOrThrow("tiered") + + fun asBulk(): NewPlanBulkPrice = bulk.getOrThrow("bulk") + + fun asBulkWithFilters(): BulkWithFilters = bulkWithFilters.getOrThrow("bulkWithFilters") + + fun asPackage(): NewPlanPackagePrice = package_.getOrThrow("package_") + + fun asMatrix(): NewPlanMatrixPrice = matrix.getOrThrow("matrix") + + fun asThresholdTotalAmount(): NewPlanThresholdTotalAmountPrice = + thresholdTotalAmount.getOrThrow("thresholdTotalAmount") + + fun asTieredPackage(): NewPlanTieredPackagePrice = + tieredPackage.getOrThrow("tieredPackage") + + fun asTieredWithMinimum(): NewPlanTieredWithMinimumPrice = + tieredWithMinimum.getOrThrow("tieredWithMinimum") + + fun asGroupedTiered(): NewPlanGroupedTieredPrice = + groupedTiered.getOrThrow("groupedTiered") + + fun asTieredPackageWithMinimum(): NewPlanTieredPackageWithMinimumPrice = + tieredPackageWithMinimum.getOrThrow("tieredPackageWithMinimum") + + fun asPackageWithAllocation(): NewPlanPackageWithAllocationPrice = + packageWithAllocation.getOrThrow("packageWithAllocation") + + fun asUnitWithPercent(): NewPlanUnitWithPercentPrice = + unitWithPercent.getOrThrow("unitWithPercent") + + fun asMatrixWithAllocation(): NewPlanMatrixWithAllocationPrice = + matrixWithAllocation.getOrThrow("matrixWithAllocation") + + fun asTieredWithProration(): TieredWithProration = + tieredWithProration.getOrThrow("tieredWithProration") + + fun asUnitWithProration(): NewPlanUnitWithProrationPrice = + unitWithProration.getOrThrow("unitWithProration") + + fun asGroupedAllocation(): NewPlanGroupedAllocationPrice = + groupedAllocation.getOrThrow("groupedAllocation") + + fun asBulkWithProration(): NewPlanBulkWithProrationPrice = + bulkWithProration.getOrThrow("bulkWithProration") + + fun asGroupedWithProratedMinimum(): NewPlanGroupedWithProratedMinimumPrice = + groupedWithProratedMinimum.getOrThrow("groupedWithProratedMinimum") + + fun asGroupedWithMeteredMinimum(): NewPlanGroupedWithMeteredMinimumPrice = + groupedWithMeteredMinimum.getOrThrow("groupedWithMeteredMinimum") + + fun asGroupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds = + groupedWithMinMaxThresholds.getOrThrow("groupedWithMinMaxThresholds") + + fun asMatrixWithDisplayName(): NewPlanMatrixWithDisplayNamePrice = + matrixWithDisplayName.getOrThrow("matrixWithDisplayName") + + fun asGroupedTieredPackage(): NewPlanGroupedTieredPackagePrice = + groupedTieredPackage.getOrThrow("groupedTieredPackage") + + fun asMaxGroupTieredPackage(): NewPlanMaxGroupTieredPackagePrice = + maxGroupTieredPackage.getOrThrow("maxGroupTieredPackage") + + fun asScalableMatrixWithUnitPricing(): NewPlanScalableMatrixWithUnitPricingPrice = + scalableMatrixWithUnitPricing.getOrThrow("scalableMatrixWithUnitPricing") + + fun asScalableMatrixWithTieredPricing(): NewPlanScalableMatrixWithTieredPricingPrice = + scalableMatrixWithTieredPricing.getOrThrow("scalableMatrixWithTieredPricing") + + fun asCumulativeGroupedBulk(): NewPlanCumulativeGroupedBulkPrice = + cumulativeGroupedBulk.getOrThrow("cumulativeGroupedBulk") + + fun asMinimum(): NewPlanMinimumCompositePrice = minimum.getOrThrow("minimum") + + fun asPercent(): Percent = percent.getOrThrow("percent") + + fun asEventOutput(): EventOutput = eventOutput.getOrThrow("eventOutput") + + fun _json(): JsonValue? = _json + + fun accept(visitor: Visitor): T = + when { + unit != null -> visitor.visitUnit(unit) + tiered != null -> visitor.visitTiered(tiered) + bulk != null -> visitor.visitBulk(bulk) + bulkWithFilters != null -> visitor.visitBulkWithFilters(bulkWithFilters) + package_ != null -> visitor.visitPackage(package_) + matrix != null -> visitor.visitMatrix(matrix) + thresholdTotalAmount != null -> + visitor.visitThresholdTotalAmount(thresholdTotalAmount) + tieredPackage != null -> visitor.visitTieredPackage(tieredPackage) + tieredWithMinimum != null -> visitor.visitTieredWithMinimum(tieredWithMinimum) + groupedTiered != null -> visitor.visitGroupedTiered(groupedTiered) + tieredPackageWithMinimum != null -> + visitor.visitTieredPackageWithMinimum(tieredPackageWithMinimum) + packageWithAllocation != null -> + visitor.visitPackageWithAllocation(packageWithAllocation) + unitWithPercent != null -> visitor.visitUnitWithPercent(unitWithPercent) + matrixWithAllocation != null -> + visitor.visitMatrixWithAllocation(matrixWithAllocation) + tieredWithProration != null -> + visitor.visitTieredWithProration(tieredWithProration) + unitWithProration != null -> visitor.visitUnitWithProration(unitWithProration) + groupedAllocation != null -> visitor.visitGroupedAllocation(groupedAllocation) + bulkWithProration != null -> visitor.visitBulkWithProration(bulkWithProration) + groupedWithProratedMinimum != null -> + visitor.visitGroupedWithProratedMinimum(groupedWithProratedMinimum) + groupedWithMeteredMinimum != null -> + visitor.visitGroupedWithMeteredMinimum(groupedWithMeteredMinimum) + groupedWithMinMaxThresholds != null -> + visitor.visitGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds) + matrixWithDisplayName != null -> + visitor.visitMatrixWithDisplayName(matrixWithDisplayName) + groupedTieredPackage != null -> + visitor.visitGroupedTieredPackage(groupedTieredPackage) + maxGroupTieredPackage != null -> + visitor.visitMaxGroupTieredPackage(maxGroupTieredPackage) + scalableMatrixWithUnitPricing != null -> + visitor.visitScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing) + scalableMatrixWithTieredPricing != null -> + visitor.visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing + ) + cumulativeGroupedBulk != null -> + visitor.visitCumulativeGroupedBulk(cumulativeGroupedBulk) + minimum != null -> visitor.visitMinimum(minimum) + percent != null -> visitor.visitPercent(percent) + eventOutput != null -> visitor.visitEventOutput(eventOutput) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Price = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitUnit(unit: NewPlanUnitPrice) { + unit.validate() + } + + override fun visitTiered(tiered: NewPlanTieredPrice) { + tiered.validate() + } + + override fun visitBulk(bulk: NewPlanBulkPrice) { + bulk.validate() + } + + override fun visitBulkWithFilters(bulkWithFilters: BulkWithFilters) { + bulkWithFilters.validate() + } + + override fun visitPackage(package_: NewPlanPackagePrice) { + package_.validate() + } + + override fun visitMatrix(matrix: NewPlanMatrixPrice) { + matrix.validate() + } + + override fun visitThresholdTotalAmount( + thresholdTotalAmount: NewPlanThresholdTotalAmountPrice + ) { + thresholdTotalAmount.validate() + } + + override fun visitTieredPackage(tieredPackage: NewPlanTieredPackagePrice) { + tieredPackage.validate() + } + + override fun visitTieredWithMinimum( + tieredWithMinimum: NewPlanTieredWithMinimumPrice + ) { + tieredWithMinimum.validate() + } + + override fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) { + groupedTiered.validate() + } + + override fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice + ) { + tieredPackageWithMinimum.validate() + } + + override fun visitPackageWithAllocation( + packageWithAllocation: NewPlanPackageWithAllocationPrice + ) { + packageWithAllocation.validate() + } + + override fun visitUnitWithPercent( + unitWithPercent: NewPlanUnitWithPercentPrice + ) { + unitWithPercent.validate() + } + + override fun visitMatrixWithAllocation( + matrixWithAllocation: NewPlanMatrixWithAllocationPrice + ) { + matrixWithAllocation.validate() + } + + override fun visitTieredWithProration( + tieredWithProration: TieredWithProration + ) { + tieredWithProration.validate() + } + + override fun visitUnitWithProration( + unitWithProration: NewPlanUnitWithProrationPrice + ) { + unitWithProration.validate() + } + + override fun visitGroupedAllocation( + groupedAllocation: NewPlanGroupedAllocationPrice + ) { + groupedAllocation.validate() + } + + override fun visitBulkWithProration( + bulkWithProration: NewPlanBulkWithProrationPrice + ) { + bulkWithProration.validate() + } + + override fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice + ) { + groupedWithProratedMinimum.validate() + } + + override fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice + ) { + groupedWithMeteredMinimum.validate() + } + + override fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) { + groupedWithMinMaxThresholds.validate() + } + + override fun visitMatrixWithDisplayName( + matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice + ) { + matrixWithDisplayName.validate() + } + + override fun visitGroupedTieredPackage( + groupedTieredPackage: NewPlanGroupedTieredPackagePrice + ) { + groupedTieredPackage.validate() + } + + override fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice + ) { + maxGroupTieredPackage.validate() + } + + override fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice + ) { + scalableMatrixWithUnitPricing.validate() + } + + override fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: + NewPlanScalableMatrixWithTieredPricingPrice + ) { + scalableMatrixWithTieredPricing.validate() + } + + override fun visitCumulativeGroupedBulk( + cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice + ) { + cumulativeGroupedBulk.validate() + } + + override fun visitMinimum(minimum: NewPlanMinimumCompositePrice) { + minimum.validate() + } + + override fun visitPercent(percent: Percent) { + percent.validate() + } + + override fun visitEventOutput(eventOutput: EventOutput) { + eventOutput.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitUnit(unit: NewPlanUnitPrice) = unit.validity() + + override fun visitTiered(tiered: NewPlanTieredPrice) = tiered.validity() + + override fun visitBulk(bulk: NewPlanBulkPrice) = bulk.validity() + + override fun visitBulkWithFilters(bulkWithFilters: BulkWithFilters) = + bulkWithFilters.validity() + + override fun visitPackage(package_: NewPlanPackagePrice) = + package_.validity() + + override fun visitMatrix(matrix: NewPlanMatrixPrice) = matrix.validity() + + override fun visitThresholdTotalAmount( + thresholdTotalAmount: NewPlanThresholdTotalAmountPrice + ) = thresholdTotalAmount.validity() + + override fun visitTieredPackage(tieredPackage: NewPlanTieredPackagePrice) = + tieredPackage.validity() + + override fun visitTieredWithMinimum( + tieredWithMinimum: NewPlanTieredWithMinimumPrice + ) = tieredWithMinimum.validity() + + override fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) = + groupedTiered.validity() + + override fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice + ) = tieredPackageWithMinimum.validity() + + override fun visitPackageWithAllocation( + packageWithAllocation: NewPlanPackageWithAllocationPrice + ) = packageWithAllocation.validity() + + override fun visitUnitWithPercent( + unitWithPercent: NewPlanUnitWithPercentPrice + ) = unitWithPercent.validity() + + override fun visitMatrixWithAllocation( + matrixWithAllocation: NewPlanMatrixWithAllocationPrice + ) = matrixWithAllocation.validity() + + override fun visitTieredWithProration( + tieredWithProration: TieredWithProration + ) = tieredWithProration.validity() + + override fun visitUnitWithProration( + unitWithProration: NewPlanUnitWithProrationPrice + ) = unitWithProration.validity() + + override fun visitGroupedAllocation( + groupedAllocation: NewPlanGroupedAllocationPrice + ) = groupedAllocation.validity() + + override fun visitBulkWithProration( + bulkWithProration: NewPlanBulkWithProrationPrice + ) = bulkWithProration.validity() + + override fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice + ) = groupedWithProratedMinimum.validity() + + override fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice + ) = groupedWithMeteredMinimum.validity() + + override fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) = groupedWithMinMaxThresholds.validity() + + override fun visitMatrixWithDisplayName( + matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice + ) = matrixWithDisplayName.validity() + + override fun visitGroupedTieredPackage( + groupedTieredPackage: NewPlanGroupedTieredPackagePrice + ) = groupedTieredPackage.validity() + + override fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice + ) = maxGroupTieredPackage.validity() + + override fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice + ) = scalableMatrixWithUnitPricing.validity() + + override fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: + NewPlanScalableMatrixWithTieredPricingPrice + ) = scalableMatrixWithTieredPricing.validity() + + override fun visitCumulativeGroupedBulk( + cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice + ) = cumulativeGroupedBulk.validity() + + override fun visitMinimum(minimum: NewPlanMinimumCompositePrice) = + minimum.validity() + + override fun visitPercent(percent: Percent) = percent.validity() + + override fun visitEventOutput(eventOutput: EventOutput) = + eventOutput.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Price && + unit == other.unit && + tiered == other.tiered && + bulk == other.bulk && + bulkWithFilters == other.bulkWithFilters && + package_ == other.package_ && + matrix == other.matrix && + thresholdTotalAmount == other.thresholdTotalAmount && + tieredPackage == other.tieredPackage && + tieredWithMinimum == other.tieredWithMinimum && + groupedTiered == other.groupedTiered && + tieredPackageWithMinimum == other.tieredPackageWithMinimum && + packageWithAllocation == other.packageWithAllocation && + unitWithPercent == other.unitWithPercent && + matrixWithAllocation == other.matrixWithAllocation && + tieredWithProration == other.tieredWithProration && + unitWithProration == other.unitWithProration && + groupedAllocation == other.groupedAllocation && + bulkWithProration == other.bulkWithProration && + groupedWithProratedMinimum == other.groupedWithProratedMinimum && + groupedWithMeteredMinimum == other.groupedWithMeteredMinimum && + groupedWithMinMaxThresholds == other.groupedWithMinMaxThresholds && + matrixWithDisplayName == other.matrixWithDisplayName && + groupedTieredPackage == other.groupedTieredPackage && + maxGroupTieredPackage == other.maxGroupTieredPackage && + scalableMatrixWithUnitPricing == other.scalableMatrixWithUnitPricing && + scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && + cumulativeGroupedBulk == other.cumulativeGroupedBulk && + minimum == other.minimum && + percent == other.percent && + eventOutput == other.eventOutput + } + + override fun hashCode(): Int = + Objects.hash( + unit, + tiered, + bulk, + bulkWithFilters, + package_, + matrix, + thresholdTotalAmount, + tieredPackage, + tieredWithMinimum, + groupedTiered, + tieredPackageWithMinimum, + packageWithAllocation, + unitWithPercent, + matrixWithAllocation, + tieredWithProration, + unitWithProration, + groupedAllocation, + bulkWithProration, + groupedWithProratedMinimum, + groupedWithMeteredMinimum, + groupedWithMinMaxThresholds, + matrixWithDisplayName, + groupedTieredPackage, + maxGroupTieredPackage, + scalableMatrixWithUnitPricing, + scalableMatrixWithTieredPricing, + cumulativeGroupedBulk, + minimum, + percent, + eventOutput, + ) + + override fun toString(): String = + when { + unit != null -> "Price{unit=$unit}" + tiered != null -> "Price{tiered=$tiered}" + bulk != null -> "Price{bulk=$bulk}" + bulkWithFilters != null -> "Price{bulkWithFilters=$bulkWithFilters}" + package_ != null -> "Price{package_=$package_}" + matrix != null -> "Price{matrix=$matrix}" + thresholdTotalAmount != null -> + "Price{thresholdTotalAmount=$thresholdTotalAmount}" + tieredPackage != null -> "Price{tieredPackage=$tieredPackage}" + tieredWithMinimum != null -> "Price{tieredWithMinimum=$tieredWithMinimum}" + groupedTiered != null -> "Price{groupedTiered=$groupedTiered}" + tieredPackageWithMinimum != null -> + "Price{tieredPackageWithMinimum=$tieredPackageWithMinimum}" + packageWithAllocation != null -> + "Price{packageWithAllocation=$packageWithAllocation}" + unitWithPercent != null -> "Price{unitWithPercent=$unitWithPercent}" + matrixWithAllocation != null -> + "Price{matrixWithAllocation=$matrixWithAllocation}" + tieredWithProration != null -> "Price{tieredWithProration=$tieredWithProration}" + unitWithProration != null -> "Price{unitWithProration=$unitWithProration}" + groupedAllocation != null -> "Price{groupedAllocation=$groupedAllocation}" + bulkWithProration != null -> "Price{bulkWithProration=$bulkWithProration}" + groupedWithProratedMinimum != null -> + "Price{groupedWithProratedMinimum=$groupedWithProratedMinimum}" + groupedWithMeteredMinimum != null -> + "Price{groupedWithMeteredMinimum=$groupedWithMeteredMinimum}" + groupedWithMinMaxThresholds != null -> + "Price{groupedWithMinMaxThresholds=$groupedWithMinMaxThresholds}" + matrixWithDisplayName != null -> + "Price{matrixWithDisplayName=$matrixWithDisplayName}" + groupedTieredPackage != null -> + "Price{groupedTieredPackage=$groupedTieredPackage}" + maxGroupTieredPackage != null -> + "Price{maxGroupTieredPackage=$maxGroupTieredPackage}" + scalableMatrixWithUnitPricing != null -> + "Price{scalableMatrixWithUnitPricing=$scalableMatrixWithUnitPricing}" + scalableMatrixWithTieredPricing != null -> + "Price{scalableMatrixWithTieredPricing=$scalableMatrixWithTieredPricing}" + cumulativeGroupedBulk != null -> + "Price{cumulativeGroupedBulk=$cumulativeGroupedBulk}" + minimum != null -> "Price{minimum=$minimum}" + percent != null -> "Price{percent=$percent}" + eventOutput != null -> "Price{eventOutput=$eventOutput}" + _json != null -> "Price{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Price") + } + + companion object { + + fun ofUnit(unit: NewPlanUnitPrice) = Price(unit = unit) + + fun ofTiered(tiered: NewPlanTieredPrice) = Price(tiered = tiered) + + fun ofBulk(bulk: NewPlanBulkPrice) = Price(bulk = bulk) + + fun ofBulkWithFilters(bulkWithFilters: BulkWithFilters) = + Price(bulkWithFilters = bulkWithFilters) + + fun ofPackage(package_: NewPlanPackagePrice) = Price(package_ = package_) + + fun ofMatrix(matrix: NewPlanMatrixPrice) = Price(matrix = matrix) + + fun ofThresholdTotalAmount(thresholdTotalAmount: NewPlanThresholdTotalAmountPrice) = + Price(thresholdTotalAmount = thresholdTotalAmount) + + fun ofTieredPackage(tieredPackage: NewPlanTieredPackagePrice) = + Price(tieredPackage = tieredPackage) + + fun ofTieredWithMinimum(tieredWithMinimum: NewPlanTieredWithMinimumPrice) = + Price(tieredWithMinimum = tieredWithMinimum) + + fun ofGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) = + Price(groupedTiered = groupedTiered) + + fun ofTieredPackageWithMinimum( + tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice + ) = Price(tieredPackageWithMinimum = tieredPackageWithMinimum) + + fun ofPackageWithAllocation( + packageWithAllocation: NewPlanPackageWithAllocationPrice + ) = Price(packageWithAllocation = packageWithAllocation) + + fun ofUnitWithPercent(unitWithPercent: NewPlanUnitWithPercentPrice) = + Price(unitWithPercent = unitWithPercent) + + fun ofMatrixWithAllocation(matrixWithAllocation: NewPlanMatrixWithAllocationPrice) = + Price(matrixWithAllocation = matrixWithAllocation) + + fun ofTieredWithProration(tieredWithProration: TieredWithProration) = + Price(tieredWithProration = tieredWithProration) + + fun ofUnitWithProration(unitWithProration: NewPlanUnitWithProrationPrice) = + Price(unitWithProration = unitWithProration) + + fun ofGroupedAllocation(groupedAllocation: NewPlanGroupedAllocationPrice) = + Price(groupedAllocation = groupedAllocation) + + fun ofBulkWithProration(bulkWithProration: NewPlanBulkWithProrationPrice) = + Price(bulkWithProration = bulkWithProration) + + fun ofGroupedWithProratedMinimum( + groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice + ) = Price(groupedWithProratedMinimum = groupedWithProratedMinimum) + + fun ofGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice + ) = Price(groupedWithMeteredMinimum = groupedWithMeteredMinimum) + + fun ofGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) = Price(groupedWithMinMaxThresholds = groupedWithMinMaxThresholds) + + fun ofMatrixWithDisplayName( + matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice + ) = Price(matrixWithDisplayName = matrixWithDisplayName) + + fun ofGroupedTieredPackage(groupedTieredPackage: NewPlanGroupedTieredPackagePrice) = + Price(groupedTieredPackage = groupedTieredPackage) + + fun ofMaxGroupTieredPackage( + maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice + ) = Price(maxGroupTieredPackage = maxGroupTieredPackage) + + fun ofScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice + ) = Price(scalableMatrixWithUnitPricing = scalableMatrixWithUnitPricing) + + fun ofScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: NewPlanScalableMatrixWithTieredPricingPrice + ) = Price(scalableMatrixWithTieredPricing = scalableMatrixWithTieredPricing) + + fun ofCumulativeGroupedBulk( + cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice + ) = Price(cumulativeGroupedBulk = cumulativeGroupedBulk) + + fun ofMinimum(minimum: NewPlanMinimumCompositePrice) = Price(minimum = minimum) + + fun ofPercent(percent: Percent) = Price(percent = percent) + + fun ofEventOutput(eventOutput: EventOutput) = Price(eventOutput = eventOutput) + } + + /** + * An interface that defines how to map each variant of [Price] to a value of type [T]. + */ + interface Visitor { + + fun visitUnit(unit: NewPlanUnitPrice): T + + fun visitTiered(tiered: NewPlanTieredPrice): T + + fun visitBulk(bulk: NewPlanBulkPrice): T + + fun visitBulkWithFilters(bulkWithFilters: BulkWithFilters): T + + fun visitPackage(package_: NewPlanPackagePrice): T + + fun visitMatrix(matrix: NewPlanMatrixPrice): T + + fun visitThresholdTotalAmount( + thresholdTotalAmount: NewPlanThresholdTotalAmountPrice + ): T + + fun visitTieredPackage(tieredPackage: NewPlanTieredPackagePrice): T + + fun visitTieredWithMinimum(tieredWithMinimum: NewPlanTieredWithMinimumPrice): T + + fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice): T + + fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice + ): T + + fun visitPackageWithAllocation( + packageWithAllocation: NewPlanPackageWithAllocationPrice + ): T + + fun visitUnitWithPercent(unitWithPercent: NewPlanUnitWithPercentPrice): T + + fun visitMatrixWithAllocation( + matrixWithAllocation: NewPlanMatrixWithAllocationPrice + ): T + + fun visitTieredWithProration(tieredWithProration: TieredWithProration): T + + fun visitUnitWithProration(unitWithProration: NewPlanUnitWithProrationPrice): T + + fun visitGroupedAllocation(groupedAllocation: NewPlanGroupedAllocationPrice): T + + fun visitBulkWithProration(bulkWithProration: NewPlanBulkWithProrationPrice): T + + fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice + ): T + + fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice + ): T + + fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ): T + + fun visitMatrixWithDisplayName( + matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice + ): T + + fun visitGroupedTieredPackage( + groupedTieredPackage: NewPlanGroupedTieredPackagePrice + ): T + + fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice + ): T + + fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice + ): T + + fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: NewPlanScalableMatrixWithTieredPricingPrice + ): T + + fun visitCumulativeGroupedBulk( + cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice + ): T + + fun visitMinimum(minimum: NewPlanMinimumCompositePrice): T + + fun visitPercent(percent: Percent): T + + fun visitEventOutput(eventOutput: EventOutput): T + + /** + * Maps an unknown variant of [Price] to a value of type [T]. + * + * An instance of [Price] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is + * unaware of. + * + * @throws OrbInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw OrbInvalidDataException("Unknown Price: $json") + } + } + + internal class Deserializer : BaseDeserializer(Price::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Price { + val json = JsonValue.fromJsonNode(node) + val modelType = json.asObject()?.get("model_type")?.asString() + + when (modelType) { + "unit" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(unit = it, _json = json) + } ?: Price(_json = json) + } + "tiered" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(tiered = it, _json = json) + } ?: Price(_json = json) + } + "bulk" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(bulk = it, _json = json) + } ?: Price(_json = json) + } + "bulk_with_filters" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(bulkWithFilters = it, _json = json) + } ?: Price(_json = json) + } + "package" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(package_ = it, _json = json) } ?: Price(_json = json) + } + "matrix" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(matrix = it, _json = json) + } ?: Price(_json = json) + } + "threshold_total_amount" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(thresholdTotalAmount = it, _json = json) } + ?: Price(_json = json) + } + "tiered_package" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(tieredPackage = it, _json = json) } + ?: Price(_json = json) + } + "tiered_with_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(tieredWithMinimum = it, _json = json) } + ?: Price(_json = json) + } + "grouped_tiered" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(groupedTiered = it, _json = json) } + ?: Price(_json = json) + } + "tiered_package_with_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(tieredPackageWithMinimum = it, _json = json) } + ?: Price(_json = json) + } + "package_with_allocation" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(packageWithAllocation = it, _json = json) } + ?: Price(_json = json) + } + "unit_with_percent" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(unitWithPercent = it, _json = json) } + ?: Price(_json = json) + } + "matrix_with_allocation" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(matrixWithAllocation = it, _json = json) } + ?: Price(_json = json) + } + "tiered_with_proration" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(tieredWithProration = it, _json = json) } + ?: Price(_json = json) + } + "unit_with_proration" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(unitWithProration = it, _json = json) } + ?: Price(_json = json) + } + "grouped_allocation" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedAllocation = it, _json = json) } + ?: Price(_json = json) + } + "bulk_with_proration" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(bulkWithProration = it, _json = json) } + ?: Price(_json = json) + } + "grouped_with_prorated_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedWithProratedMinimum = it, _json = json) } + ?: Price(_json = json) + } + "grouped_with_metered_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedWithMeteredMinimum = it, _json = json) } + ?: Price(_json = json) + } + "grouped_with_min_max_thresholds" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedWithMinMaxThresholds = it, _json = json) } + ?: Price(_json = json) + } + "matrix_with_display_name" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(matrixWithDisplayName = it, _json = json) } + ?: Price(_json = json) + } + "grouped_tiered_package" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedTieredPackage = it, _json = json) } + ?: Price(_json = json) + } + "max_group_tiered_package" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(maxGroupTieredPackage = it, _json = json) } + ?: Price(_json = json) + } + "scalable_matrix_with_unit_pricing" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(scalableMatrixWithUnitPricing = it, _json = json) } + ?: Price(_json = json) + } + "scalable_matrix_with_tiered_pricing" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(scalableMatrixWithTieredPricing = it, _json = json) } + ?: Price(_json = json) + } + "cumulative_grouped_bulk" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(cumulativeGroupedBulk = it, _json = json) } + ?: Price(_json = json) + } + "minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(minimum = it, _json = json) } ?: Price(_json = json) + } + "percent" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(percent = it, _json = json) + } ?: Price(_json = json) + } + "event_output" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(eventOutput = it, _json = json) + } ?: Price(_json = json) + } + } + + return Price(_json = json) + } + } + + internal class Serializer : BaseSerializer(Price::class) { + + override fun serialize( + value: Price, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.unit != null -> generator.writeObject(value.unit) + value.tiered != null -> generator.writeObject(value.tiered) + value.bulk != null -> generator.writeObject(value.bulk) + value.bulkWithFilters != null -> + generator.writeObject(value.bulkWithFilters) + value.package_ != null -> generator.writeObject(value.package_) + value.matrix != null -> generator.writeObject(value.matrix) + value.thresholdTotalAmount != null -> + generator.writeObject(value.thresholdTotalAmount) + value.tieredPackage != null -> generator.writeObject(value.tieredPackage) + value.tieredWithMinimum != null -> + generator.writeObject(value.tieredWithMinimum) + value.groupedTiered != null -> generator.writeObject(value.groupedTiered) + value.tieredPackageWithMinimum != null -> + generator.writeObject(value.tieredPackageWithMinimum) + value.packageWithAllocation != null -> + generator.writeObject(value.packageWithAllocation) + value.unitWithPercent != null -> + generator.writeObject(value.unitWithPercent) + value.matrixWithAllocation != null -> + generator.writeObject(value.matrixWithAllocation) + value.tieredWithProration != null -> + generator.writeObject(value.tieredWithProration) + value.unitWithProration != null -> + generator.writeObject(value.unitWithProration) + value.groupedAllocation != null -> + generator.writeObject(value.groupedAllocation) + value.bulkWithProration != null -> + generator.writeObject(value.bulkWithProration) + value.groupedWithProratedMinimum != null -> + generator.writeObject(value.groupedWithProratedMinimum) + value.groupedWithMeteredMinimum != null -> + generator.writeObject(value.groupedWithMeteredMinimum) + value.groupedWithMinMaxThresholds != null -> + generator.writeObject(value.groupedWithMinMaxThresholds) + value.matrixWithDisplayName != null -> + generator.writeObject(value.matrixWithDisplayName) + value.groupedTieredPackage != null -> + generator.writeObject(value.groupedTieredPackage) + value.maxGroupTieredPackage != null -> + generator.writeObject(value.maxGroupTieredPackage) + value.scalableMatrixWithUnitPricing != null -> + generator.writeObject(value.scalableMatrixWithUnitPricing) + value.scalableMatrixWithTieredPricing != null -> + generator.writeObject(value.scalableMatrixWithTieredPricing) + value.cumulativeGroupedBulk != null -> + generator.writeObject(value.cumulativeGroupedBulk) + value.minimum != null -> generator.writeObject(value.minimum) + value.percent != null -> generator.writeObject(value.percent) + value.eventOutput != null -> generator.writeObject(value.eventOutput) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Price") + } + } } - replacesPriceId() - allocationPrice()?.validate() - planPhaseOrder() - price()?.validate() - validated = true - } + class BulkWithFilters + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val bulkWithFiltersConfig: JsonField, + private val cadence: JsonField, + private val itemId: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + @JsonCreator + private constructor( + @JsonProperty("bulk_with_filters_config") + @ExcludeMissing + bulkWithFiltersConfig: JsonField = JsonMissing.of(), + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + bulkWithFiltersConfig, + cadence, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + mutableMapOf(), + ) - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (if (replacesPriceId.asKnown() == null) 0 else 1) + - (allocationPrice.asKnown()?.validity() ?: 0) + - (if (planPhaseOrder.asKnown() == null) 0 else 1) + - (price.asKnown()?.validity() ?: 0) + /** + * Configuration for bulk_with_filters pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun bulkWithFiltersConfig(): BulkWithFiltersConfig = + bulkWithFiltersConfig.getRequired("bulk_with_filters_config") - /** New plan price request body params. */ - @JsonDeserialize(using = Price.Deserializer::class) - @JsonSerialize(using = Price.Serializer::class) - class Price - private constructor( - private val unit: NewPlanUnitPrice? = null, - private val tiered: NewPlanTieredPrice? = null, - private val bulk: NewPlanBulkPrice? = null, - private val package_: NewPlanPackagePrice? = null, - private val matrix: NewPlanMatrixPrice? = null, - private val thresholdTotalAmount: NewPlanThresholdTotalAmountPrice? = null, - private val tieredPackage: NewPlanTieredPackagePrice? = null, - private val tieredWithMinimum: NewPlanTieredWithMinimumPrice? = null, - private val groupedTiered: NewPlanGroupedTieredPrice? = null, - private val tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice? = null, - private val packageWithAllocation: NewPlanPackageWithAllocationPrice? = null, - private val unitWithPercent: NewPlanUnitWithPercentPrice? = null, - private val matrixWithAllocation: NewPlanMatrixWithAllocationPrice? = null, - private val tieredWithProration: TieredWithProration? = null, - private val unitWithProration: NewPlanUnitWithProrationPrice? = null, - private val groupedAllocation: NewPlanGroupedAllocationPrice? = null, - private val bulkWithProration: NewPlanBulkWithProrationPrice? = null, - private val groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice? = null, - private val groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice? = null, - private val groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds? = null, - private val matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice? = null, - private val groupedTieredPackage: NewPlanGroupedTieredPackagePrice? = null, - private val maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice? = null, - private val scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice? = - null, - private val scalableMatrixWithTieredPricing: - NewPlanScalableMatrixWithTieredPricingPrice? = - null, - private val cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice? = null, - private val minimum: NewPlanMinimumCompositePrice? = null, - private val percent: Percent? = null, - private val eventOutput: EventOutput? = null, - private val _json: JsonValue? = null, - ) { + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") - fun unit(): NewPlanUnitPrice? = unit + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") - fun tiered(): NewPlanTieredPrice? = tiered + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("bulk_with_filters") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType - fun bulk(): NewPlanBulkPrice? = bulk + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") - fun package_(): NewPlanPackagePrice? = package_ + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = billableMetricId.getNullable("billable_metric_id") - fun matrix(): NewPlanMatrixPrice? = matrix + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") - fun thresholdTotalAmount(): NewPlanThresholdTotalAmountPrice? = thresholdTotalAmount + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") - fun tieredPackage(): NewPlanTieredPackagePrice? = tieredPackage + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") - fun tieredWithMinimum(): NewPlanTieredWithMinimumPrice? = tieredWithMinimum + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") - fun groupedTiered(): NewPlanGroupedTieredPrice? = groupedTiered + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") - fun tieredPackageWithMinimum(): NewPlanTieredPackageWithMinimumPrice? = - tieredPackageWithMinimum + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") - fun packageWithAllocation(): NewPlanPackageWithAllocationPrice? = packageWithAllocation + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") - fun unitWithPercent(): NewPlanUnitWithPercentPrice? = unitWithPercent + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") - fun matrixWithAllocation(): NewPlanMatrixWithAllocationPrice? = matrixWithAllocation + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + invoiceGroupingKey.getNullable("invoice_grouping_key") - fun tieredWithProration(): TieredWithProration? = tieredWithProration + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - fun unitWithProration(): NewPlanUnitWithProrationPrice? = unitWithProration + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") - fun groupedAllocation(): NewPlanGroupedAllocationPrice? = groupedAllocation + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") - fun bulkWithProration(): NewPlanBulkWithProrationPrice? = bulkWithProration + /** + * Returns the raw JSON value of [bulkWithFiltersConfig]. + * + * Unlike [bulkWithFiltersConfig], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("bulk_with_filters_config") + @ExcludeMissing + fun _bulkWithFiltersConfig(): JsonField = + bulkWithFiltersConfig - fun groupedWithProratedMinimum(): NewPlanGroupedWithProratedMinimumPrice? = - groupedWithProratedMinimum + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence - fun groupedWithMeteredMinimum(): NewPlanGroupedWithMeteredMinimumPrice? = - groupedWithMeteredMinimum + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - fun groupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds? = - groupedWithMinMaxThresholds + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - fun matrixWithDisplayName(): NewPlanMatrixWithDisplayNamePrice? = matrixWithDisplayName + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId - fun groupedTieredPackage(): NewPlanGroupedTieredPackagePrice? = groupedTieredPackage + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance - fun maxGroupTieredPackage(): NewPlanMaxGroupTieredPackagePrice? = maxGroupTieredPackage + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration - fun scalableMatrixWithUnitPricing(): NewPlanScalableMatrixWithUnitPricingPrice? = - scalableMatrixWithUnitPricing + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate - fun scalableMatrixWithTieredPricing(): NewPlanScalableMatrixWithTieredPricingPrice? = - scalableMatrixWithTieredPricing + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig - fun cumulativeGroupedBulk(): NewPlanCumulativeGroupedBulkPrice? = cumulativeGroupedBulk + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency - fun minimum(): NewPlanMinimumCompositePrice? = minimum + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration - fun percent(): Percent? = percent + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId - fun eventOutput(): EventOutput? = eventOutput + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - fun isUnit(): Boolean = unit != null + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - fun isTiered(): Boolean = tiered != null + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration - fun isBulk(): Boolean = bulk != null + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata - fun isPackage(): Boolean = package_ != null + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId - fun isMatrix(): Boolean = matrix != null + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - fun isThresholdTotalAmount(): Boolean = thresholdTotalAmount != null + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - fun isTieredPackage(): Boolean = tieredPackage != null + fun toBuilder() = Builder().from(this) - fun isTieredWithMinimum(): Boolean = tieredWithMinimum != null + companion object { - fun isGroupedTiered(): Boolean = groupedTiered != null + /** + * Returns a mutable builder for constructing an instance of [BulkWithFilters]. + * + * The following fields are required: + * ```kotlin + * .bulkWithFiltersConfig() + * .cadence() + * .itemId() + * .name() + * ``` + */ + fun builder() = Builder() + } - fun isTieredPackageWithMinimum(): Boolean = tieredPackageWithMinimum != null + /** A builder for [BulkWithFilters]. */ + class Builder internal constructor() { - fun isPackageWithAllocation(): Boolean = packageWithAllocation != null + private var bulkWithFiltersConfig: JsonField? = null + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonValue = JsonValue.from("bulk_with_filters") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - fun isUnitWithPercent(): Boolean = unitWithPercent != null + internal fun from(bulkWithFilters: BulkWithFilters) = apply { + bulkWithFiltersConfig = bulkWithFilters.bulkWithFiltersConfig + cadence = bulkWithFilters.cadence + itemId = bulkWithFilters.itemId + modelType = bulkWithFilters.modelType + name = bulkWithFilters.name + billableMetricId = bulkWithFilters.billableMetricId + billedInAdvance = bulkWithFilters.billedInAdvance + billingCycleConfiguration = bulkWithFilters.billingCycleConfiguration + conversionRate = bulkWithFilters.conversionRate + conversionRateConfig = bulkWithFilters.conversionRateConfig + currency = bulkWithFilters.currency + dimensionalPriceConfiguration = + bulkWithFilters.dimensionalPriceConfiguration + externalPriceId = bulkWithFilters.externalPriceId + fixedPriceQuantity = bulkWithFilters.fixedPriceQuantity + invoiceGroupingKey = bulkWithFilters.invoiceGroupingKey + invoicingCycleConfiguration = bulkWithFilters.invoicingCycleConfiguration + metadata = bulkWithFilters.metadata + referenceId = bulkWithFilters.referenceId + additionalProperties = bulkWithFilters.additionalProperties.toMutableMap() + } - fun isMatrixWithAllocation(): Boolean = matrixWithAllocation != null + /** Configuration for bulk_with_filters pricing */ + fun bulkWithFiltersConfig(bulkWithFiltersConfig: BulkWithFiltersConfig) = + bulkWithFiltersConfig(JsonField.of(bulkWithFiltersConfig)) - fun isTieredWithProration(): Boolean = tieredWithProration != null + /** + * Sets [Builder.bulkWithFiltersConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.bulkWithFiltersConfig] with a well-typed + * [BulkWithFiltersConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun bulkWithFiltersConfig( + bulkWithFiltersConfig: JsonField + ) = apply { this.bulkWithFiltersConfig = bulkWithFiltersConfig } - fun isUnitWithProration(): Boolean = unitWithProration != null + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - fun isGroupedAllocation(): Boolean = groupedAllocation != null + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - fun isBulkWithProration(): Boolean = bulkWithProration != null + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - fun isGroupedWithProratedMinimum(): Boolean = groupedWithProratedMinimum != null + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun isGroupedWithMeteredMinimum(): Boolean = groupedWithMeteredMinimum != null + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("bulk_with_filters") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } - fun isGroupedWithMinMaxThresholds(): Boolean = groupedWithMinMaxThresholds != null + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) - fun isMatrixWithDisplayName(): Boolean = matrixWithDisplayName != null + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } - fun isGroupedTieredPackage(): Boolean = groupedTieredPackage != null + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) - fun isMaxGroupTieredPackage(): Boolean = maxGroupTieredPackage != null + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } - fun isScalableMatrixWithUnitPricing(): Boolean = scalableMatrixWithUnitPricing != null + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) - fun isScalableMatrixWithTieredPricing(): Boolean = - scalableMatrixWithTieredPricing != null + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) - fun isCumulativeGroupedBulk(): Boolean = cumulativeGroupedBulk != null + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } - fun isMinimum(): Boolean = minimum != null + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - fun isPercent(): Boolean = percent != null + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } - fun isEventOutput(): Boolean = eventOutput != null + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) - fun asUnit(): NewPlanUnitPrice = unit.getOrThrow("unit") + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) - fun asTiered(): NewPlanTieredPrice = tiered.getOrThrow("tiered") + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } - fun asBulk(): NewPlanBulkPrice = bulk.getOrThrow("bulk") + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) - fun asPackage(): NewPlanPackagePrice = package_.getOrThrow("package_") + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } - fun asMatrix(): NewPlanMatrixPrice = matrix.getOrThrow("matrix") + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) - fun asThresholdTotalAmount(): NewPlanThresholdTotalAmountPrice = - thresholdTotalAmount.getOrThrow("thresholdTotalAmount") + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) - fun asTieredPackage(): NewPlanTieredPackagePrice = - tieredPackage.getOrThrow("tieredPackage") + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) - fun asTieredWithMinimum(): NewPlanTieredWithMinimumPrice = - tieredWithMinimum.getOrThrow("tieredWithMinimum") + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) - fun asGroupedTiered(): NewPlanGroupedTieredPrice = - groupedTiered.getOrThrow("groupedTiered") + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) - fun asTieredPackageWithMinimum(): NewPlanTieredPackageWithMinimumPrice = - tieredPackageWithMinimum.getOrThrow("tieredPackageWithMinimum") + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } - fun asPackageWithAllocation(): NewPlanPackageWithAllocationPrice = - packageWithAllocation.getOrThrow("packageWithAllocation") + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) - fun asUnitWithPercent(): NewPlanUnitWithPercentPrice = - unitWithPercent.getOrThrow("unitWithPercent") + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } - fun asMatrixWithAllocation(): NewPlanMatrixWithAllocationPrice = - matrixWithAllocation.getOrThrow("matrixWithAllocation") + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) - fun asTieredWithProration(): TieredWithProration = - tieredWithProration.getOrThrow("tieredWithProration") + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } - fun asUnitWithProration(): NewPlanUnitWithProrationPrice = - unitWithProration.getOrThrow("unitWithProration") + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) - fun asGroupedAllocation(): NewPlanGroupedAllocationPrice = - groupedAllocation.getOrThrow("groupedAllocation") + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) - fun asBulkWithProration(): NewPlanBulkWithProrationPrice = - bulkWithProration.getOrThrow("bulkWithProration") + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } - fun asGroupedWithProratedMinimum(): NewPlanGroupedWithProratedMinimumPrice = - groupedWithProratedMinimum.getOrThrow("groupedWithProratedMinimum") + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) - fun asGroupedWithMeteredMinimum(): NewPlanGroupedWithMeteredMinimumPrice = - groupedWithMeteredMinimum.getOrThrow("groupedWithMeteredMinimum") + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } - fun asGroupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds = - groupedWithMinMaxThresholds.getOrThrow("groupedWithMinMaxThresholds") + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) - fun asMatrixWithDisplayName(): NewPlanMatrixWithDisplayNamePrice = - matrixWithDisplayName.getOrThrow("matrixWithDisplayName") + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - fun asGroupedTieredPackage(): NewPlanGroupedTieredPackagePrice = - groupedTieredPackage.getOrThrow("groupedTieredPackage") + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - fun asMaxGroupTieredPackage(): NewPlanMaxGroupTieredPackagePrice = - maxGroupTieredPackage.getOrThrow("maxGroupTieredPackage") + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - fun asScalableMatrixWithUnitPricing(): NewPlanScalableMatrixWithUnitPricingPrice = - scalableMatrixWithUnitPricing.getOrThrow("scalableMatrixWithUnitPricing") + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) - fun asScalableMatrixWithTieredPricing(): NewPlanScalableMatrixWithTieredPricingPrice = - scalableMatrixWithTieredPricing.getOrThrow("scalableMatrixWithTieredPricing") + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } - fun asCumulativeGroupedBulk(): NewPlanCumulativeGroupedBulkPrice = - cumulativeGroupedBulk.getOrThrow("cumulativeGroupedBulk") + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun asMinimum(): NewPlanMinimumCompositePrice = minimum.getOrThrow("minimum") + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun asPercent(): Percent = percent.getOrThrow("percent") + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun asEventOutput(): EventOutput = eventOutput.getOrThrow("eventOutput") + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun _json(): JsonValue? = _json + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - bulk != null -> visitor.visitBulk(bulk) - package_ != null -> visitor.visitPackage(package_) - matrix != null -> visitor.visitMatrix(matrix) - thresholdTotalAmount != null -> - visitor.visitThresholdTotalAmount(thresholdTotalAmount) - tieredPackage != null -> visitor.visitTieredPackage(tieredPackage) - tieredWithMinimum != null -> visitor.visitTieredWithMinimum(tieredWithMinimum) - groupedTiered != null -> visitor.visitGroupedTiered(groupedTiered) - tieredPackageWithMinimum != null -> - visitor.visitTieredPackageWithMinimum(tieredPackageWithMinimum) - packageWithAllocation != null -> - visitor.visitPackageWithAllocation(packageWithAllocation) - unitWithPercent != null -> visitor.visitUnitWithPercent(unitWithPercent) - matrixWithAllocation != null -> - visitor.visitMatrixWithAllocation(matrixWithAllocation) - tieredWithProration != null -> - visitor.visitTieredWithProration(tieredWithProration) - unitWithProration != null -> visitor.visitUnitWithProration(unitWithProration) - groupedAllocation != null -> visitor.visitGroupedAllocation(groupedAllocation) - bulkWithProration != null -> visitor.visitBulkWithProration(bulkWithProration) - groupedWithProratedMinimum != null -> - visitor.visitGroupedWithProratedMinimum(groupedWithProratedMinimum) - groupedWithMeteredMinimum != null -> - visitor.visitGroupedWithMeteredMinimum(groupedWithMeteredMinimum) - groupedWithMinMaxThresholds != null -> - visitor.visitGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds) - matrixWithDisplayName != null -> - visitor.visitMatrixWithDisplayName(matrixWithDisplayName) - groupedTieredPackage != null -> - visitor.visitGroupedTieredPackage(groupedTieredPackage) - maxGroupTieredPackage != null -> - visitor.visitMaxGroupTieredPackage(maxGroupTieredPackage) - scalableMatrixWithUnitPricing != null -> - visitor.visitScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing) - scalableMatrixWithTieredPricing != null -> - visitor.visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing + /** + * Returns an immutable instance of [BulkWithFilters]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .bulkWithFiltersConfig() + * .cadence() + * .itemId() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BulkWithFilters = + BulkWithFilters( + checkRequired("bulkWithFiltersConfig", bulkWithFiltersConfig), + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties.toMutableMap(), ) - cumulativeGroupedBulk != null -> - visitor.visitCumulativeGroupedBulk(cumulativeGroupedBulk) - minimum != null -> visitor.visitMinimum(minimum) - percent != null -> visitor.visitPercent(percent) - eventOutput != null -> visitor.visitEventOutput(eventOutput) - else -> visitor.unknown(_json) } - private var validated: Boolean = false + private var validated: Boolean = false - fun validate(): Price = apply { - if (validated) { - return@apply - } + fun validate(): BulkWithFilters = apply { + if (validated) { + return@apply + } - accept( - object : Visitor { - override fun visitUnit(unit: NewPlanUnitPrice) { - unit.validate() + bulkWithFiltersConfig().validate() + cadence().validate() + itemId() + _modelType().let { + if (it != JsonValue.from("bulk_with_filters")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + metadata()?.validate() + referenceId() + validated = true + } - override fun visitTiered(tiered: NewPlanTieredPrice) { - tiered.validate() - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - override fun visitBulk(bulk: NewPlanBulkPrice) { - bulk.validate() - } + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (bulkWithFiltersConfig.asKnown()?.validity() ?: 0) + + (cadence.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + modelType.let { if (it == JsonValue.from("bulk_with_filters")) 1 else 0 } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) - override fun visitPackage(package_: NewPlanPackagePrice) { - package_.validate() - } + /** Configuration for bulk_with_filters pricing */ + class BulkWithFiltersConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val filters: JsonField>, + private val tiers: JsonField>, + private val additionalProperties: MutableMap, + ) { - override fun visitMatrix(matrix: NewPlanMatrixPrice) { - matrix.validate() - } + @JsonCreator + private constructor( + @JsonProperty("filters") + @ExcludeMissing + filters: JsonField> = JsonMissing.of(), + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of(), + ) : this(filters, tiers, mutableMapOf()) - override fun visitThresholdTotalAmount( - thresholdTotalAmount: NewPlanThresholdTotalAmountPrice - ) { - thresholdTotalAmount.validate() - } + /** + * Property filters to apply (all must match) + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun filters(): List = filters.getRequired("filters") - override fun visitTieredPackage(tieredPackage: NewPlanTieredPackagePrice) { - tieredPackage.validate() - } + /** + * Bulk tiers for rating based on total usage volume + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun tiers(): List = tiers.getRequired("tiers") - override fun visitTieredWithMinimum( - tieredWithMinimum: NewPlanTieredWithMinimumPrice - ) { - tieredWithMinimum.validate() - } + /** + * Returns the raw JSON value of [filters]. + * + * Unlike [filters], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("filters") + @ExcludeMissing + fun _filters(): JsonField> = filters - override fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) { - groupedTiered.validate() - } + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers - override fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice - ) { - tieredPackageWithMinimum.validate() - } + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - override fun visitPackageWithAllocation( - packageWithAllocation: NewPlanPackageWithAllocationPrice - ) { - packageWithAllocation.validate() - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - override fun visitUnitWithPercent( - unitWithPercent: NewPlanUnitWithPercentPrice - ) { - unitWithPercent.validate() - } + fun toBuilder() = Builder().from(this) - override fun visitMatrixWithAllocation( - matrixWithAllocation: NewPlanMatrixWithAllocationPrice - ) { - matrixWithAllocation.validate() - } + companion object { - override fun visitTieredWithProration( - tieredWithProration: TieredWithProration - ) { - tieredWithProration.validate() - } + /** + * Returns a mutable builder for constructing an instance of + * [BulkWithFiltersConfig]. + * + * The following fields are required: + * ```kotlin + * .filters() + * .tiers() + * ``` + */ + fun builder() = Builder() + } - override fun visitUnitWithProration( - unitWithProration: NewPlanUnitWithProrationPrice - ) { - unitWithProration.validate() - } + /** A builder for [BulkWithFiltersConfig]. */ + class Builder internal constructor() { - override fun visitGroupedAllocation( - groupedAllocation: NewPlanGroupedAllocationPrice - ) { - groupedAllocation.validate() - } + private var filters: JsonField>? = null + private var tiers: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() - override fun visitBulkWithProration( - bulkWithProration: NewPlanBulkWithProrationPrice - ) { - bulkWithProration.validate() + internal fun from(bulkWithFiltersConfig: BulkWithFiltersConfig) = apply { + filters = bulkWithFiltersConfig.filters.map { it.toMutableList() } + tiers = bulkWithFiltersConfig.tiers.map { it.toMutableList() } + additionalProperties = + bulkWithFiltersConfig.additionalProperties.toMutableMap() } - override fun visitGroupedWithProratedMinimum( - groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice - ) { - groupedWithProratedMinimum.validate() - } + /** Property filters to apply (all must match) */ + fun filters(filters: List) = filters(JsonField.of(filters)) - override fun visitGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice - ) { - groupedWithMeteredMinimum.validate() + /** + * Sets [Builder.filters] to an arbitrary JSON value. + * + * You should usually call [Builder.filters] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun filters(filters: JsonField>) = apply { + this.filters = filters.map { it.toMutableList() } } - override fun visitGroupedWithMinMaxThresholds( - groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds - ) { - groupedWithMinMaxThresholds.validate() + /** + * Adds a single [Filter] to [filters]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addFilter(filter: Filter) = apply { + filters = + (filters ?: JsonField.of(mutableListOf())).also { + checkKnown("filters", it).add(filter) + } } - override fun visitMatrixWithDisplayName( - matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice - ) { - matrixWithDisplayName.validate() - } + /** Bulk tiers for rating based on total usage volume */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) - override fun visitGroupedTieredPackage( - groupedTieredPackage: NewPlanGroupedTieredPackagePrice - ) { - groupedTieredPackage.validate() + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } } - override fun visitMaxGroupTieredPackage( - maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice - ) { - maxGroupTieredPackage.validate() + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } } - override fun visitScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice - ) { - scalableMatrixWithUnitPricing.validate() - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - override fun visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: - NewPlanScalableMatrixWithTieredPricingPrice - ) { - scalableMatrixWithTieredPricing.validate() + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) } - override fun visitCumulativeGroupedBulk( - cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice - ) { - cumulativeGroupedBulk.validate() - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - override fun visitMinimum(minimum: NewPlanMinimumCompositePrice) { - minimum.validate() + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) } - override fun visitPercent(percent: Percent) { - percent.validate() + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) } - override fun visitEventOutput(eventOutput: EventOutput) { - eventOutput.validate() - } + /** + * Returns an immutable instance of [BulkWithFiltersConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .filters() + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BulkWithFiltersConfig = + BulkWithFiltersConfig( + checkRequired("filters", filters).map { it.toImmutable() }, + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) } - ) - validated = true - } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + private var validated: Boolean = false - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: NewPlanUnitPrice) = unit.validity() + fun validate(): BulkWithFiltersConfig = apply { + if (validated) { + return@apply + } - override fun visitTiered(tiered: NewPlanTieredPrice) = tiered.validity() + filters().forEach { it.validate() } + tiers().forEach { it.validate() } + validated = true + } - override fun visitBulk(bulk: NewPlanBulkPrice) = bulk.validity() + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - override fun visitPackage(package_: NewPlanPackagePrice) = - package_.validity() + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (filters.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + (tiers.asKnown()?.sumOf { it.validity().toInt() } ?: 0) - override fun visitMatrix(matrix: NewPlanMatrixPrice) = matrix.validity() + /** Configuration for a single property filter */ + class Filter + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val propertyKey: JsonField, + private val propertyValue: JsonField, + private val additionalProperties: MutableMap, + ) { - override fun visitThresholdTotalAmount( - thresholdTotalAmount: NewPlanThresholdTotalAmountPrice - ) = thresholdTotalAmount.validity() + @JsonCreator + private constructor( + @JsonProperty("property_key") + @ExcludeMissing + propertyKey: JsonField = JsonMissing.of(), + @JsonProperty("property_value") + @ExcludeMissing + propertyValue: JsonField = JsonMissing.of(), + ) : this(propertyKey, propertyValue, mutableMapOf()) - override fun visitTieredPackage(tieredPackage: NewPlanTieredPackagePrice) = - tieredPackage.validity() + /** + * Event property key to filter on + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun propertyKey(): String = propertyKey.getRequired("property_key") - override fun visitTieredWithMinimum( - tieredWithMinimum: NewPlanTieredWithMinimumPrice - ) = tieredWithMinimum.validity() + /** + * Event property value to match + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun propertyValue(): String = propertyValue.getRequired("property_value") - override fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) = - groupedTiered.validity() + /** + * Returns the raw JSON value of [propertyKey]. + * + * Unlike [propertyKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("property_key") + @ExcludeMissing + fun _propertyKey(): JsonField = propertyKey - override fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice - ) = tieredPackageWithMinimum.validity() + /** + * Returns the raw JSON value of [propertyValue]. + * + * Unlike [propertyValue], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("property_value") + @ExcludeMissing + fun _propertyValue(): JsonField = propertyValue - override fun visitPackageWithAllocation( - packageWithAllocation: NewPlanPackageWithAllocationPrice - ) = packageWithAllocation.validity() + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - override fun visitUnitWithPercent( - unitWithPercent: NewPlanUnitWithPercentPrice - ) = unitWithPercent.validity() + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - override fun visitMatrixWithAllocation( - matrixWithAllocation: NewPlanMatrixWithAllocationPrice - ) = matrixWithAllocation.validity() + fun toBuilder() = Builder().from(this) - override fun visitTieredWithProration( - tieredWithProration: TieredWithProration - ) = tieredWithProration.validity() + companion object { - override fun visitUnitWithProration( - unitWithProration: NewPlanUnitWithProrationPrice - ) = unitWithProration.validity() + /** + * Returns a mutable builder for constructing an instance of [Filter]. + * + * The following fields are required: + * ```kotlin + * .propertyKey() + * .propertyValue() + * ``` + */ + fun builder() = Builder() + } - override fun visitGroupedAllocation( - groupedAllocation: NewPlanGroupedAllocationPrice - ) = groupedAllocation.validity() + /** A builder for [Filter]. */ + class Builder internal constructor() { - override fun visitBulkWithProration( - bulkWithProration: NewPlanBulkWithProrationPrice - ) = bulkWithProration.validity() + private var propertyKey: JsonField? = null + private var propertyValue: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() - override fun visitGroupedWithProratedMinimum( - groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice - ) = groupedWithProratedMinimum.validity() + internal fun from(filter: Filter) = apply { + propertyKey = filter.propertyKey + propertyValue = filter.propertyValue + additionalProperties = filter.additionalProperties.toMutableMap() + } - override fun visitGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice - ) = groupedWithMeteredMinimum.validity() + /** Event property key to filter on */ + fun propertyKey(propertyKey: String) = + propertyKey(JsonField.of(propertyKey)) - override fun visitGroupedWithMinMaxThresholds( - groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds - ) = groupedWithMinMaxThresholds.validity() + /** + * Sets [Builder.propertyKey] to an arbitrary JSON value. + * + * You should usually call [Builder.propertyKey] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun propertyKey(propertyKey: JsonField) = apply { + this.propertyKey = propertyKey + } - override fun visitMatrixWithDisplayName( - matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice - ) = matrixWithDisplayName.validity() + /** Event property value to match */ + fun propertyValue(propertyValue: String) = + propertyValue(JsonField.of(propertyValue)) - override fun visitGroupedTieredPackage( - groupedTieredPackage: NewPlanGroupedTieredPackagePrice - ) = groupedTieredPackage.validity() + /** + * Sets [Builder.propertyValue] to an arbitrary JSON value. + * + * You should usually call [Builder.propertyValue] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun propertyValue(propertyValue: JsonField) = apply { + this.propertyValue = propertyValue + } - override fun visitMaxGroupTieredPackage( - maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice - ) = maxGroupTieredPackage.validity() + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - override fun visitScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice - ) = scalableMatrixWithUnitPricing.validity() + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - override fun visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: - NewPlanScalableMatrixWithTieredPricingPrice - ) = scalableMatrixWithTieredPricing.validity() + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - override fun visitCumulativeGroupedBulk( - cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice - ) = cumulativeGroupedBulk.validity() + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - override fun visitMinimum(minimum: NewPlanMinimumCompositePrice) = - minimum.validity() + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - override fun visitPercent(percent: Percent) = percent.validity() + /** + * Returns an immutable instance of [Filter]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```kotlin + * .propertyKey() + * .propertyValue() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Filter = + Filter( + checkRequired("propertyKey", propertyKey), + checkRequired("propertyValue", propertyValue), + additionalProperties.toMutableMap(), + ) + } - override fun visitEventOutput(eventOutput: EventOutput) = - eventOutput.validity() + private var validated: Boolean = false - override fun unknown(json: JsonValue?) = 0 - } - ) + fun validate(): Filter = apply { + if (validated) { + return@apply + } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + propertyKey() + propertyValue() + validated = true + } - return other is Price && - unit == other.unit && - tiered == other.tiered && - bulk == other.bulk && - package_ == other.package_ && - matrix == other.matrix && - thresholdTotalAmount == other.thresholdTotalAmount && - tieredPackage == other.tieredPackage && - tieredWithMinimum == other.tieredWithMinimum && - groupedTiered == other.groupedTiered && - tieredPackageWithMinimum == other.tieredPackageWithMinimum && - packageWithAllocation == other.packageWithAllocation && - unitWithPercent == other.unitWithPercent && - matrixWithAllocation == other.matrixWithAllocation && - tieredWithProration == other.tieredWithProration && - unitWithProration == other.unitWithProration && - groupedAllocation == other.groupedAllocation && - bulkWithProration == other.bulkWithProration && - groupedWithProratedMinimum == other.groupedWithProratedMinimum && - groupedWithMeteredMinimum == other.groupedWithMeteredMinimum && - groupedWithMinMaxThresholds == other.groupedWithMinMaxThresholds && - matrixWithDisplayName == other.matrixWithDisplayName && - groupedTieredPackage == other.groupedTieredPackage && - maxGroupTieredPackage == other.maxGroupTieredPackage && - scalableMatrixWithUnitPricing == other.scalableMatrixWithUnitPricing && - scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && - cumulativeGroupedBulk == other.cumulativeGroupedBulk && - minimum == other.minimum && - percent == other.percent && - eventOutput == other.eventOutput - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - override fun hashCode(): Int = - Objects.hash( - unit, - tiered, - bulk, - package_, - matrix, - thresholdTotalAmount, - tieredPackage, - tieredWithMinimum, - groupedTiered, - tieredPackageWithMinimum, - packageWithAllocation, - unitWithPercent, - matrixWithAllocation, - tieredWithProration, - unitWithProration, - groupedAllocation, - bulkWithProration, - groupedWithProratedMinimum, - groupedWithMeteredMinimum, - groupedWithMinMaxThresholds, - matrixWithDisplayName, - groupedTieredPackage, - maxGroupTieredPackage, - scalableMatrixWithUnitPricing, - scalableMatrixWithTieredPricing, - cumulativeGroupedBulk, - minimum, - percent, - eventOutput, - ) + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (propertyKey.asKnown() == null) 0 else 1) + + (if (propertyValue.asKnown() == null) 0 else 1) - override fun toString(): String = - when { - unit != null -> "Price{unit=$unit}" - tiered != null -> "Price{tiered=$tiered}" - bulk != null -> "Price{bulk=$bulk}" - package_ != null -> "Price{package_=$package_}" - matrix != null -> "Price{matrix=$matrix}" - thresholdTotalAmount != null -> - "Price{thresholdTotalAmount=$thresholdTotalAmount}" - tieredPackage != null -> "Price{tieredPackage=$tieredPackage}" - tieredWithMinimum != null -> "Price{tieredWithMinimum=$tieredWithMinimum}" - groupedTiered != null -> "Price{groupedTiered=$groupedTiered}" - tieredPackageWithMinimum != null -> - "Price{tieredPackageWithMinimum=$tieredPackageWithMinimum}" - packageWithAllocation != null -> - "Price{packageWithAllocation=$packageWithAllocation}" - unitWithPercent != null -> "Price{unitWithPercent=$unitWithPercent}" - matrixWithAllocation != null -> - "Price{matrixWithAllocation=$matrixWithAllocation}" - tieredWithProration != null -> "Price{tieredWithProration=$tieredWithProration}" - unitWithProration != null -> "Price{unitWithProration=$unitWithProration}" - groupedAllocation != null -> "Price{groupedAllocation=$groupedAllocation}" - bulkWithProration != null -> "Price{bulkWithProration=$bulkWithProration}" - groupedWithProratedMinimum != null -> - "Price{groupedWithProratedMinimum=$groupedWithProratedMinimum}" - groupedWithMeteredMinimum != null -> - "Price{groupedWithMeteredMinimum=$groupedWithMeteredMinimum}" - groupedWithMinMaxThresholds != null -> - "Price{groupedWithMinMaxThresholds=$groupedWithMinMaxThresholds}" - matrixWithDisplayName != null -> - "Price{matrixWithDisplayName=$matrixWithDisplayName}" - groupedTieredPackage != null -> - "Price{groupedTieredPackage=$groupedTieredPackage}" - maxGroupTieredPackage != null -> - "Price{maxGroupTieredPackage=$maxGroupTieredPackage}" - scalableMatrixWithUnitPricing != null -> - "Price{scalableMatrixWithUnitPricing=$scalableMatrixWithUnitPricing}" - scalableMatrixWithTieredPricing != null -> - "Price{scalableMatrixWithTieredPricing=$scalableMatrixWithTieredPricing}" - cumulativeGroupedBulk != null -> - "Price{cumulativeGroupedBulk=$cumulativeGroupedBulk}" - minimum != null -> "Price{minimum=$minimum}" - percent != null -> "Price{percent=$percent}" - eventOutput != null -> "Price{eventOutput=$eventOutput}" - _json != null -> "Price{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Price") - } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - companion object { + return other is Filter && + propertyKey == other.propertyKey && + propertyValue == other.propertyValue && + additionalProperties == other.additionalProperties + } - fun ofUnit(unit: NewPlanUnitPrice) = Price(unit = unit) + private val hashCode: Int by lazy { + Objects.hash(propertyKey, propertyValue, additionalProperties) + } - fun ofTiered(tiered: NewPlanTieredPrice) = Price(tiered = tiered) + override fun hashCode(): Int = hashCode - fun ofBulk(bulk: NewPlanBulkPrice) = Price(bulk = bulk) + override fun toString() = + "Filter{propertyKey=$propertyKey, propertyValue=$propertyValue, additionalProperties=$additionalProperties}" + } - fun ofPackage(package_: NewPlanPackagePrice) = Price(package_ = package_) + /** Configuration for a single bulk pricing tier */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val unitAmount: JsonField, + private val tierLowerBound: JsonField, + private val additionalProperties: MutableMap, + ) { - fun ofMatrix(matrix: NewPlanMatrixPrice) = Price(matrix = matrix) + @JsonCreator + private constructor( + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + ) : this(unitAmount, tierLowerBound, mutableMapOf()) - fun ofThresholdTotalAmount(thresholdTotalAmount: NewPlanThresholdTotalAmountPrice) = - Price(thresholdTotalAmount = thresholdTotalAmount) + /** + * Amount per unit + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") - fun ofTieredPackage(tieredPackage: NewPlanTieredPackagePrice) = - Price(tieredPackage = tieredPackage) + /** + * The lower bound for this tier + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun tierLowerBound(): String? = + tierLowerBound.getNullable("tier_lower_bound") - fun ofTieredWithMinimum(tieredWithMinimum: NewPlanTieredWithMinimumPrice) = - Price(tieredWithMinimum = tieredWithMinimum) + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount - fun ofGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) = - Price(groupedTiered = groupedTiered) + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound - fun ofTieredPackageWithMinimum( - tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice - ) = Price(tieredPackageWithMinimum = tieredPackageWithMinimum) + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - fun ofPackageWithAllocation( - packageWithAllocation: NewPlanPackageWithAllocationPrice - ) = Price(packageWithAllocation = packageWithAllocation) + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - fun ofUnitWithPercent(unitWithPercent: NewPlanUnitWithPercentPrice) = - Price(unitWithPercent = unitWithPercent) + fun toBuilder() = Builder().from(this) - fun ofMatrixWithAllocation(matrixWithAllocation: NewPlanMatrixWithAllocationPrice) = - Price(matrixWithAllocation = matrixWithAllocation) + companion object { - fun ofTieredWithProration(tieredWithProration: TieredWithProration) = - Price(tieredWithProration = tieredWithProration) + /** + * Returns a mutable builder for constructing an instance of [Tier]. + * + * The following fields are required: + * ```kotlin + * .unitAmount() + * ``` + */ + fun builder() = Builder() + } - fun ofUnitWithProration(unitWithProration: NewPlanUnitWithProrationPrice) = - Price(unitWithProration = unitWithProration) + /** A builder for [Tier]. */ + class Builder internal constructor() { - fun ofGroupedAllocation(groupedAllocation: NewPlanGroupedAllocationPrice) = - Price(groupedAllocation = groupedAllocation) + private var unitAmount: JsonField? = null + private var tierLowerBound: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() - fun ofBulkWithProration(bulkWithProration: NewPlanBulkWithProrationPrice) = - Price(bulkWithProration = bulkWithProration) + internal fun from(tier: Tier) = apply { + unitAmount = tier.unitAmount + tierLowerBound = tier.tierLowerBound + additionalProperties = tier.additionalProperties.toMutableMap() + } - fun ofGroupedWithProratedMinimum( - groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice - ) = Price(groupedWithProratedMinimum = groupedWithProratedMinimum) + /** Amount per unit */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) - fun ofGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice - ) = Price(groupedWithMeteredMinimum = groupedWithMeteredMinimum) + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } - fun ofGroupedWithMinMaxThresholds( - groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds - ) = Price(groupedWithMinMaxThresholds = groupedWithMinMaxThresholds) + /** The lower bound for this tier */ + fun tierLowerBound(tierLowerBound: String?) = + tierLowerBound(JsonField.ofNullable(tierLowerBound)) - fun ofMatrixWithDisplayName( - matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice - ) = Price(matrixWithDisplayName = matrixWithDisplayName) + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } - fun ofGroupedTieredPackage(groupedTieredPackage: NewPlanGroupedTieredPackagePrice) = - Price(groupedTieredPackage = groupedTieredPackage) + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun ofMaxGroupTieredPackage( - maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice - ) = Price(maxGroupTieredPackage = maxGroupTieredPackage) + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun ofScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice - ) = Price(scalableMatrixWithUnitPricing = scalableMatrixWithUnitPricing) + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun ofScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: NewPlanScalableMatrixWithTieredPricingPrice - ) = Price(scalableMatrixWithTieredPricing = scalableMatrixWithTieredPricing) + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun ofCumulativeGroupedBulk( - cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice - ) = Price(cumulativeGroupedBulk = cumulativeGroupedBulk) + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - fun ofMinimum(minimum: NewPlanMinimumCompositePrice) = Price(minimum = minimum) + /** + * Returns an immutable instance of [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```kotlin + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("unitAmount", unitAmount), + tierLowerBound, + additionalProperties.toMutableMap(), + ) + } - fun ofPercent(percent: Percent) = Price(percent = percent) + private var validated: Boolean = false - fun ofEventOutput(eventOutput: EventOutput) = Price(eventOutput = eventOutput) - } + fun validate(): Tier = apply { + if (validated) { + return@apply + } - /** - * An interface that defines how to map each variant of [Price] to a value of type [T]. - */ - interface Visitor { + unitAmount() + tierLowerBound() + validated = true + } - fun visitUnit(unit: NewPlanUnitPrice): T + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - fun visitTiered(tiered: NewPlanTieredPrice): T + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (unitAmount.asKnown() == null) 0 else 1) + + (if (tierLowerBound.asKnown() == null) 0 else 1) - fun visitBulk(bulk: NewPlanBulkPrice): T + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun visitPackage(package_: NewPlanPackagePrice): T + return other is Tier && + unitAmount == other.unitAmount && + tierLowerBound == other.tierLowerBound && + additionalProperties == other.additionalProperties + } - fun visitMatrix(matrix: NewPlanMatrixPrice): T + private val hashCode: Int by lazy { + Objects.hash(unitAmount, tierLowerBound, additionalProperties) + } - fun visitThresholdTotalAmount( - thresholdTotalAmount: NewPlanThresholdTotalAmountPrice - ): T + override fun hashCode(): Int = hashCode - fun visitTieredPackage(tieredPackage: NewPlanTieredPackagePrice): T + override fun toString() = + "Tier{unitAmount=$unitAmount, tierLowerBound=$tierLowerBound, additionalProperties=$additionalProperties}" + } - fun visitTieredWithMinimum(tieredWithMinimum: NewPlanTieredWithMinimumPrice): T + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice): T + return other is BulkWithFiltersConfig && + filters == other.filters && + tiers == other.tiers && + additionalProperties == other.additionalProperties + } - fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice - ): T + private val hashCode: Int by lazy { + Objects.hash(filters, tiers, additionalProperties) + } - fun visitPackageWithAllocation( - packageWithAllocation: NewPlanPackageWithAllocationPrice - ): T + override fun hashCode(): Int = hashCode - fun visitUnitWithPercent(unitWithPercent: NewPlanUnitWithPercentPrice): T + override fun toString() = + "BulkWithFiltersConfig{filters=$filters, tiers=$tiers, additionalProperties=$additionalProperties}" + } - fun visitMatrixWithAllocation( - matrixWithAllocation: NewPlanMatrixWithAllocationPrice - ): T + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { - fun visitTieredWithProration(tieredWithProration: TieredWithProration): T + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value - fun visitUnitWithProration(unitWithProration: NewPlanUnitWithProrationPrice): T + companion object { - fun visitGroupedAllocation(groupedAllocation: NewPlanGroupedAllocationPrice): T + val ANNUAL = of("annual") - fun visitBulkWithProration(bulkWithProration: NewPlanBulkWithProrationPrice): T + val SEMI_ANNUAL = of("semi_annual") - fun visitGroupedWithProratedMinimum( - groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice - ): T + val MONTHLY = of("monthly") - fun visitGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice - ): T + val QUARTERLY = of("quarterly") - fun visitGroupedWithMinMaxThresholds( - groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds - ): T + val ONE_TIME = of("one_time") - fun visitMatrixWithDisplayName( - matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice - ): T + val CUSTOM = of("custom") - fun visitGroupedTieredPackage( - groupedTieredPackage: NewPlanGroupedTieredPackagePrice - ): T + fun of(value: String) = Cadence(JsonField.of(value)) + } - fun visitMaxGroupTieredPackage( - maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice - ): T + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } - fun visitScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice - ): T + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } - fun visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: NewPlanScalableMatrixWithTieredPricingPrice - ): T + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } - fun visitCumulativeGroupedBulk( - cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice - ): T + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } - fun visitMinimum(minimum: NewPlanMinimumCompositePrice): T + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") - fun visitPercent(percent: Percent): T + private var validated: Boolean = false - fun visitEventOutput(eventOutput: EventOutput): T + fun validate(): Cadence = apply { + if (validated) { + return@apply + } - /** - * Maps an unknown variant of [Price] to a value of type [T]. - * - * An instance of [Price] can contain an unknown variant if it was deserialized from - * data that doesn't match any known variant. For example, if the SDK is on an older - * version than the API, then the API may respond with new variants that the SDK is - * unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown Price: $json") - } - } + known() + validated = true + } - internal class Deserializer : BaseDeserializer(Price::class) { + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - override fun ObjectCodec.deserialize(node: JsonNode): Price { - val json = JsonValue.fromJsonNode(node) - val modelType = json.asObject()?.get("model_type")?.asString() + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - when (modelType) { - "unit" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(unit = it, _json = json) - } ?: Price(_json = json) - } - "tiered" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(tiered = it, _json = json) - } ?: Price(_json = json) - } - "bulk" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(bulk = it, _json = json) - } ?: Price(_json = json) - } - "package" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(package_ = it, _json = json) } ?: Price(_json = json) - } - "matrix" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(matrix = it, _json = json) - } ?: Price(_json = json) - } - "threshold_total_amount" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(thresholdTotalAmount = it, _json = json) } - ?: Price(_json = json) - } - "tiered_package" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(tieredPackage = it, _json = json) } - ?: Price(_json = json) - } - "tiered_with_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(tieredWithMinimum = it, _json = json) } - ?: Price(_json = json) - } - "grouped_tiered" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(groupedTiered = it, _json = json) } - ?: Price(_json = json) - } - "tiered_package_with_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(tieredPackageWithMinimum = it, _json = json) } - ?: Price(_json = json) - } - "package_with_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(packageWithAllocation = it, _json = json) } - ?: Price(_json = json) - } - "unit_with_percent" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(unitWithPercent = it, _json = json) } - ?: Price(_json = json) - } - "matrix_with_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(matrixWithAllocation = it, _json = json) } - ?: Price(_json = json) - } - "tiered_with_proration" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(tieredWithProration = it, _json = json) } - ?: Price(_json = json) - } - "unit_with_proration" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(unitWithProration = it, _json = json) } - ?: Price(_json = json) - } - "grouped_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedAllocation = it, _json = json) } - ?: Price(_json = json) - } - "bulk_with_proration" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(bulkWithProration = it, _json = json) } - ?: Price(_json = json) - } - "grouped_with_prorated_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedWithProratedMinimum = it, _json = json) } - ?: Price(_json = json) - } - "grouped_with_metered_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedWithMeteredMinimum = it, _json = json) } - ?: Price(_json = json) - } - "grouped_with_min_max_thresholds" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedWithMinMaxThresholds = it, _json = json) } - ?: Price(_json = json) - } - "matrix_with_display_name" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(matrixWithDisplayName = it, _json = json) } - ?: Price(_json = json) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - "grouped_tiered_package" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedTieredPackage = it, _json = json) } - ?: Price(_json = json) + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() } - "max_group_tiered_package" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(maxGroupTieredPackage = it, _json = json) } - ?: Price(_json = json) + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) } - "scalable_matrix_with_unit_pricing" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(scalableMatrixWithUnitPricing = it, _json = json) } - ?: Price(_json = json) + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) } - "scalable_matrix_with_tiered_pricing" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(scalableMatrixWithTieredPricing = it, _json = json) } - ?: Price(_json = json) + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) } - "cumulative_grouped_bulk" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(cumulativeGroupedBulk = it, _json = json) } - ?: Price(_json = json) + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply } - "minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(minimum = it, _json = json) } ?: Price(_json = json) + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false } - "percent" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(percent = it, _json = json) - } ?: Price(_json = json) + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() } - "event_output" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(eventOutput = it, _json = json) - } ?: Price(_json = json) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } + + return other is Metadata && + additionalProperties == other.additionalProperties } - return Price(_json = json) - } - } + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - internal class Serializer : BaseSerializer(Price::class) { + override fun hashCode(): Int = hashCode - override fun serialize( - value: Price, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unit != null -> generator.writeObject(value.unit) - value.tiered != null -> generator.writeObject(value.tiered) - value.bulk != null -> generator.writeObject(value.bulk) - value.package_ != null -> generator.writeObject(value.package_) - value.matrix != null -> generator.writeObject(value.matrix) - value.thresholdTotalAmount != null -> - generator.writeObject(value.thresholdTotalAmount) - value.tieredPackage != null -> generator.writeObject(value.tieredPackage) - value.tieredWithMinimum != null -> - generator.writeObject(value.tieredWithMinimum) - value.groupedTiered != null -> generator.writeObject(value.groupedTiered) - value.tieredPackageWithMinimum != null -> - generator.writeObject(value.tieredPackageWithMinimum) - value.packageWithAllocation != null -> - generator.writeObject(value.packageWithAllocation) - value.unitWithPercent != null -> - generator.writeObject(value.unitWithPercent) - value.matrixWithAllocation != null -> - generator.writeObject(value.matrixWithAllocation) - value.tieredWithProration != null -> - generator.writeObject(value.tieredWithProration) - value.unitWithProration != null -> - generator.writeObject(value.unitWithProration) - value.groupedAllocation != null -> - generator.writeObject(value.groupedAllocation) - value.bulkWithProration != null -> - generator.writeObject(value.bulkWithProration) - value.groupedWithProratedMinimum != null -> - generator.writeObject(value.groupedWithProratedMinimum) - value.groupedWithMeteredMinimum != null -> - generator.writeObject(value.groupedWithMeteredMinimum) - value.groupedWithMinMaxThresholds != null -> - generator.writeObject(value.groupedWithMinMaxThresholds) - value.matrixWithDisplayName != null -> - generator.writeObject(value.matrixWithDisplayName) - value.groupedTieredPackage != null -> - generator.writeObject(value.groupedTieredPackage) - value.maxGroupTieredPackage != null -> - generator.writeObject(value.maxGroupTieredPackage) - value.scalableMatrixWithUnitPricing != null -> - generator.writeObject(value.scalableMatrixWithUnitPricing) - value.scalableMatrixWithTieredPricing != null -> - generator.writeObject(value.scalableMatrixWithTieredPricing) - value.cumulativeGroupedBulk != null -> - generator.writeObject(value.cumulativeGroupedBulk) - value.minimum != null -> generator.writeObject(value.minimum) - value.percent != null -> generator.writeObject(value.percent) - value.eventOutput != null -> generator.writeObject(value.eventOutput) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Price") + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } + + return other is BulkWithFilters && + bulkWithFiltersConfig == other.bulkWithFiltersConfig && + cadence == other.cadence && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + bulkWithFiltersConfig, + cadence, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties, + ) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BulkWithFilters{bulkWithFiltersConfig=$bulkWithFiltersConfig, cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } class TieredWithProration diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/ChangedSubscriptionResources.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/ChangedSubscriptionResources.kt index fe0412662..d985b2be3 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/ChangedSubscriptionResources.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/ChangedSubscriptionResources.kt @@ -5414,6 +5414,10 @@ private constructor( /** Alias for calling [price] with `Price.ofBulk(bulk)`. */ fun price(bulk: Price.Bulk) = price(Price.ofBulk(bulk)) + /** Alias for calling [price] with `Price.ofBulkWithFilters(bulkWithFilters)`. */ + fun price(bulkWithFilters: Price.BulkWithFilters) = + price(Price.ofBulkWithFilters(bulkWithFilters)) + /** Alias for calling [price] with `Price.ofPackage(package_)`. */ fun price(package_: Price.Package) = price(Price.ofPackage(package_)) diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Invoice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Invoice.kt index 2922ea51f..03c0901e9 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Invoice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Invoice.kt @@ -4908,6 +4908,10 @@ private constructor( /** Alias for calling [price] with `Price.ofBulk(bulk)`. */ fun price(bulk: Price.Bulk) = price(Price.ofBulk(bulk)) + /** Alias for calling [price] with `Price.ofBulkWithFilters(bulkWithFilters)`. */ + fun price(bulkWithFilters: Price.BulkWithFilters) = + price(Price.ofBulkWithFilters(bulkWithFilters)) + /** Alias for calling [price] with `Price.ofPackage(package_)`. */ fun price(package_: Price.Package) = price(Price.ofPackage(package_)) diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceFetchUpcomingResponse.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceFetchUpcomingResponse.kt index 59784ef98..13b8f1aac 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceFetchUpcomingResponse.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceFetchUpcomingResponse.kt @@ -4902,6 +4902,10 @@ private constructor( /** Alias for calling [price] with `Price.ofBulk(bulk)`. */ fun price(bulk: Price.Bulk) = price(Price.ofBulk(bulk)) + /** Alias for calling [price] with `Price.ofBulkWithFilters(bulkWithFilters)`. */ + fun price(bulkWithFilters: Price.BulkWithFilters) = + price(Price.ofBulkWithFilters(bulkWithFilters)) + /** Alias for calling [price] with `Price.ofPackage(package_)`. */ fun price(package_: Price.Package) = price(Price.ofPackage(package_)) diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceLineItemCreateResponse.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceLineItemCreateResponse.kt index 0835f89af..a6e49d057 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceLineItemCreateResponse.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceLineItemCreateResponse.kt @@ -961,6 +961,10 @@ private constructor( /** Alias for calling [price] with `Price.ofBulk(bulk)`. */ fun price(bulk: Price.Bulk) = price(Price.ofBulk(bulk)) + /** Alias for calling [price] with `Price.ofBulkWithFilters(bulkWithFilters)`. */ + fun price(bulkWithFilters: Price.BulkWithFilters) = + price(Price.ofBulkWithFilters(bulkWithFilters)) + /** Alias for calling [price] with `Price.ofPackage(package_)`. */ fun price(package_: Price.Package) = price(Price.ofPackage(package_)) diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PerPriceCost.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PerPriceCost.kt index 733cf0091..4cf1c59af 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PerPriceCost.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PerPriceCost.kt @@ -177,6 +177,10 @@ private constructor( /** Alias for calling [price] with `Price.ofBulk(bulk)`. */ fun price(bulk: Price.Bulk) = price(Price.ofBulk(bulk)) + /** Alias for calling [price] with `Price.ofBulkWithFilters(bulkWithFilters)`. */ + fun price(bulkWithFilters: Price.BulkWithFilters) = + price(Price.ofBulkWithFilters(bulkWithFilters)) + /** Alias for calling [price] with `Price.ofPackage(package_)`. */ fun price(package_: Price.Package) = price(Price.ofPackage(package_)) diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Plan.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Plan.kt index 63f0817d3..4017d393f 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Plan.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Plan.kt @@ -1052,6 +1052,10 @@ private constructor( /** Alias for calling [addPrice] with `Price.ofBulk(bulk)`. */ fun addPrice(bulk: Price.Bulk) = addPrice(Price.ofBulk(bulk)) + /** Alias for calling [addPrice] with `Price.ofBulkWithFilters(bulkWithFilters)`. */ + fun addPrice(bulkWithFilters: Price.BulkWithFilters) = + addPrice(Price.ofBulkWithFilters(bulkWithFilters)) + /** Alias for calling [addPrice] with `Price.ofPackage(package_)`. */ fun addPrice(package_: Price.Package) = addPrice(Price.ofPackage(package_)) diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanCreateParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanCreateParams.kt index 7ae6a6ca2..569b4f7f2 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanCreateParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanCreateParams.kt @@ -1324,6 +1324,10 @@ private constructor( /** Alias for calling [price] with `InnerPrice.ofBulk(bulk)`. */ fun price(bulk: NewPlanBulkPrice) = price(InnerPrice.ofBulk(bulk)) + /** Alias for calling [price] with `InnerPrice.ofBulkWithFilters(bulkWithFilters)`. */ + fun price(bulkWithFilters: InnerPrice.BulkWithFilters) = + price(InnerPrice.ofBulkWithFilters(bulkWithFilters)) + /** Alias for calling [price] with `InnerPrice.ofPackage(package_)`. */ fun price(package_: NewPlanPackagePrice) = price(InnerPrice.ofPackage(package_)) @@ -1543,6 +1547,7 @@ private constructor( private val unit: NewPlanUnitPrice? = null, private val tiered: NewPlanTieredPrice? = null, private val bulk: NewPlanBulkPrice? = null, + private val bulkWithFilters: BulkWithFilters? = null, private val package_: NewPlanPackagePrice? = null, private val matrix: NewPlanMatrixPrice? = null, private val thresholdTotalAmount: NewPlanThresholdTotalAmountPrice? = null, @@ -1581,6 +1586,8 @@ private constructor( fun bulk(): NewPlanBulkPrice? = bulk + fun bulkWithFilters(): BulkWithFilters? = bulkWithFilters + fun package_(): NewPlanPackagePrice? = package_ fun matrix(): NewPlanMatrixPrice? = matrix @@ -1645,6 +1652,8 @@ private constructor( fun isBulk(): Boolean = bulk != null + fun isBulkWithFilters(): Boolean = bulkWithFilters != null + fun isPackage(): Boolean = package_ != null fun isMatrix(): Boolean = matrix != null @@ -1704,6 +1713,8 @@ private constructor( fun asBulk(): NewPlanBulkPrice = bulk.getOrThrow("bulk") + fun asBulkWithFilters(): BulkWithFilters = bulkWithFilters.getOrThrow("bulkWithFilters") + fun asPackage(): NewPlanPackagePrice = package_.getOrThrow("package_") fun asMatrix(): NewPlanMatrixPrice = matrix.getOrThrow("matrix") @@ -1784,6 +1795,7 @@ private constructor( unit != null -> visitor.visitUnit(unit) tiered != null -> visitor.visitTiered(tiered) bulk != null -> visitor.visitBulk(bulk) + bulkWithFilters != null -> visitor.visitBulkWithFilters(bulkWithFilters) package_ != null -> visitor.visitPackage(package_) matrix != null -> visitor.visitMatrix(matrix) thresholdTotalAmount != null -> @@ -1850,6 +1862,10 @@ private constructor( bulk.validate() } + override fun visitBulkWithFilters(bulkWithFilters: BulkWithFilters) { + bulkWithFilters.validate() + } + override fun visitPackage(package_: NewPlanPackagePrice) { package_.validate() } @@ -2020,6 +2036,9 @@ private constructor( override fun visitBulk(bulk: NewPlanBulkPrice) = bulk.validity() + override fun visitBulkWithFilters(bulkWithFilters: BulkWithFilters) = + bulkWithFilters.validity() + override fun visitPackage(package_: NewPlanPackagePrice) = package_.validity() @@ -2129,6 +2148,7 @@ private constructor( unit == other.unit && tiered == other.tiered && bulk == other.bulk && + bulkWithFilters == other.bulkWithFilters && package_ == other.package_ && matrix == other.matrix && thresholdTotalAmount == other.thresholdTotalAmount && @@ -2162,6 +2182,7 @@ private constructor( unit, tiered, bulk, + bulkWithFilters, package_, matrix, thresholdTotalAmount, @@ -2195,6 +2216,7 @@ private constructor( unit != null -> "InnerPrice{unit=$unit}" tiered != null -> "InnerPrice{tiered=$tiered}" bulk != null -> "InnerPrice{bulk=$bulk}" + bulkWithFilters != null -> "InnerPrice{bulkWithFilters=$bulkWithFilters}" package_ != null -> "InnerPrice{package_=$package_}" matrix != null -> "InnerPrice{matrix=$matrix}" thresholdTotalAmount != null -> @@ -2247,6 +2269,9 @@ private constructor( fun ofBulk(bulk: NewPlanBulkPrice) = InnerPrice(bulk = bulk) + fun ofBulkWithFilters(bulkWithFilters: BulkWithFilters) = + InnerPrice(bulkWithFilters = bulkWithFilters) + fun ofPackage(package_: NewPlanPackagePrice) = InnerPrice(package_ = package_) fun ofMatrix(matrix: NewPlanMatrixPrice) = InnerPrice(matrix = matrix) @@ -2343,6 +2368,8 @@ private constructor( fun visitBulk(bulk: NewPlanBulkPrice): T + fun visitBulkWithFilters(bulkWithFilters: BulkWithFilters): T + fun visitPackage(package_: NewPlanPackagePrice): T fun visitMatrix(matrix: NewPlanMatrixPrice): T @@ -2458,6 +2485,11 @@ private constructor( InnerPrice(bulk = it, _json = json) } ?: InnerPrice(_json = json) } + "bulk_with_filters" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + InnerPrice(bulkWithFilters = it, _json = json) + } ?: InnerPrice(_json = json) + } "package" -> { return tryDeserialize(node, jacksonTypeRef()) ?.let { InnerPrice(package_ = it, _json = json) } @@ -2664,6 +2696,8 @@ private constructor( value.unit != null -> generator.writeObject(value.unit) value.tiered != null -> generator.writeObject(value.tiered) value.bulk != null -> generator.writeObject(value.bulk) + value.bulkWithFilters != null -> + generator.writeObject(value.bulkWithFilters) value.package_ != null -> generator.writeObject(value.package_) value.matrix != null -> generator.writeObject(value.matrix) value.thresholdTotalAmount != null -> @@ -2715,6 +2749,2041 @@ private constructor( } } + class BulkWithFilters + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val bulkWithFiltersConfig: JsonField, + private val cadence: JsonField, + private val itemId: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("bulk_with_filters_config") + @ExcludeMissing + bulkWithFiltersConfig: JsonField = JsonMissing.of(), + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + bulkWithFiltersConfig, + cadence, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * Configuration for bulk_with_filters pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun bulkWithFiltersConfig(): BulkWithFiltersConfig = + bulkWithFiltersConfig.getRequired("bulk_with_filters_config") + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("bulk_with_filters") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = billableMetricId.getNullable("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + invoiceGroupingKey.getNullable("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [bulkWithFiltersConfig]. + * + * Unlike [bulkWithFiltersConfig], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("bulk_with_filters_config") + @ExcludeMissing + fun _bulkWithFiltersConfig(): JsonField = + bulkWithFiltersConfig + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [BulkWithFilters]. + * + * The following fields are required: + * ```kotlin + * .bulkWithFiltersConfig() + * .cadence() + * .itemId() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [BulkWithFilters]. */ + class Builder internal constructor() { + + private var bulkWithFiltersConfig: JsonField? = null + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonValue = JsonValue.from("bulk_with_filters") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(bulkWithFilters: BulkWithFilters) = apply { + bulkWithFiltersConfig = bulkWithFilters.bulkWithFiltersConfig + cadence = bulkWithFilters.cadence + itemId = bulkWithFilters.itemId + modelType = bulkWithFilters.modelType + name = bulkWithFilters.name + billableMetricId = bulkWithFilters.billableMetricId + billedInAdvance = bulkWithFilters.billedInAdvance + billingCycleConfiguration = bulkWithFilters.billingCycleConfiguration + conversionRate = bulkWithFilters.conversionRate + conversionRateConfig = bulkWithFilters.conversionRateConfig + currency = bulkWithFilters.currency + dimensionalPriceConfiguration = + bulkWithFilters.dimensionalPriceConfiguration + externalPriceId = bulkWithFilters.externalPriceId + fixedPriceQuantity = bulkWithFilters.fixedPriceQuantity + invoiceGroupingKey = bulkWithFilters.invoiceGroupingKey + invoicingCycleConfiguration = bulkWithFilters.invoicingCycleConfiguration + metadata = bulkWithFilters.metadata + referenceId = bulkWithFilters.referenceId + additionalProperties = bulkWithFilters.additionalProperties.toMutableMap() + } + + /** Configuration for bulk_with_filters pricing */ + fun bulkWithFiltersConfig(bulkWithFiltersConfig: BulkWithFiltersConfig) = + bulkWithFiltersConfig(JsonField.of(bulkWithFiltersConfig)) + + /** + * Sets [Builder.bulkWithFiltersConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.bulkWithFiltersConfig] with a well-typed + * [BulkWithFiltersConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun bulkWithFiltersConfig( + bulkWithFiltersConfig: JsonField + ) = apply { this.bulkWithFiltersConfig = bulkWithFiltersConfig } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("bulk_with_filters") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BulkWithFilters]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .bulkWithFiltersConfig() + * .cadence() + * .itemId() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BulkWithFilters = + BulkWithFilters( + checkRequired("bulkWithFiltersConfig", bulkWithFiltersConfig), + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): BulkWithFilters = apply { + if (validated) { + return@apply + } + + bulkWithFiltersConfig().validate() + cadence().validate() + itemId() + _modelType().let { + if (it != JsonValue.from("bulk_with_filters")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (bulkWithFiltersConfig.asKnown()?.validity() ?: 0) + + (cadence.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + modelType.let { if (it == JsonValue.from("bulk_with_filters")) 1 else 0 } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** Configuration for bulk_with_filters pricing */ + class BulkWithFiltersConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val filters: JsonField>, + private val tiers: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("filters") + @ExcludeMissing + filters: JsonField> = JsonMissing.of(), + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of(), + ) : this(filters, tiers, mutableMapOf()) + + /** + * Property filters to apply (all must match) + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun filters(): List = filters.getRequired("filters") + + /** + * Bulk tiers for rating based on total usage volume + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun tiers(): List = tiers.getRequired("tiers") + + /** + * Returns the raw JSON value of [filters]. + * + * Unlike [filters], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("filters") + @ExcludeMissing + fun _filters(): JsonField> = filters + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [BulkWithFiltersConfig]. + * + * The following fields are required: + * ```kotlin + * .filters() + * .tiers() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [BulkWithFiltersConfig]. */ + class Builder internal constructor() { + + private var filters: JsonField>? = null + private var tiers: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(bulkWithFiltersConfig: BulkWithFiltersConfig) = apply { + filters = bulkWithFiltersConfig.filters.map { it.toMutableList() } + tiers = bulkWithFiltersConfig.tiers.map { it.toMutableList() } + additionalProperties = + bulkWithFiltersConfig.additionalProperties.toMutableMap() + } + + /** Property filters to apply (all must match) */ + fun filters(filters: List) = filters(JsonField.of(filters)) + + /** + * Sets [Builder.filters] to an arbitrary JSON value. + * + * You should usually call [Builder.filters] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun filters(filters: JsonField>) = apply { + this.filters = filters.map { it.toMutableList() } + } + + /** + * Adds a single [Filter] to [filters]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addFilter(filter: Filter) = apply { + filters = + (filters ?: JsonField.of(mutableListOf())).also { + checkKnown("filters", it).add(filter) + } + } + + /** Bulk tiers for rating based on total usage volume */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BulkWithFiltersConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .filters() + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BulkWithFiltersConfig = + BulkWithFiltersConfig( + checkRequired("filters", filters).map { it.toImmutable() }, + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): BulkWithFiltersConfig = apply { + if (validated) { + return@apply + } + + filters().forEach { it.validate() } + tiers().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (filters.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + (tiers.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single property filter */ + class Filter + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val propertyKey: JsonField, + private val propertyValue: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("property_key") + @ExcludeMissing + propertyKey: JsonField = JsonMissing.of(), + @JsonProperty("property_value") + @ExcludeMissing + propertyValue: JsonField = JsonMissing.of(), + ) : this(propertyKey, propertyValue, mutableMapOf()) + + /** + * Event property key to filter on + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun propertyKey(): String = propertyKey.getRequired("property_key") + + /** + * Event property value to match + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun propertyValue(): String = propertyValue.getRequired("property_value") + + /** + * Returns the raw JSON value of [propertyKey]. + * + * Unlike [propertyKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("property_key") + @ExcludeMissing + fun _propertyKey(): JsonField = propertyKey + + /** + * Returns the raw JSON value of [propertyValue]. + * + * Unlike [propertyValue], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("property_value") + @ExcludeMissing + fun _propertyValue(): JsonField = propertyValue + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Filter]. + * + * The following fields are required: + * ```kotlin + * .propertyKey() + * .propertyValue() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Filter]. */ + class Builder internal constructor() { + + private var propertyKey: JsonField? = null + private var propertyValue: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(filter: Filter) = apply { + propertyKey = filter.propertyKey + propertyValue = filter.propertyValue + additionalProperties = filter.additionalProperties.toMutableMap() + } + + /** Event property key to filter on */ + fun propertyKey(propertyKey: String) = + propertyKey(JsonField.of(propertyKey)) + + /** + * Sets [Builder.propertyKey] to an arbitrary JSON value. + * + * You should usually call [Builder.propertyKey] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun propertyKey(propertyKey: JsonField) = apply { + this.propertyKey = propertyKey + } + + /** Event property value to match */ + fun propertyValue(propertyValue: String) = + propertyValue(JsonField.of(propertyValue)) + + /** + * Sets [Builder.propertyValue] to an arbitrary JSON value. + * + * You should usually call [Builder.propertyValue] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun propertyValue(propertyValue: JsonField) = apply { + this.propertyValue = propertyValue + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Filter]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```kotlin + * .propertyKey() + * .propertyValue() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Filter = + Filter( + checkRequired("propertyKey", propertyKey), + checkRequired("propertyValue", propertyValue), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Filter = apply { + if (validated) { + return@apply + } + + propertyKey() + propertyValue() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (propertyKey.asKnown() == null) 0 else 1) + + (if (propertyValue.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Filter && + propertyKey == other.propertyKey && + propertyValue == other.propertyValue && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(propertyKey, propertyValue, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Filter{propertyKey=$propertyKey, propertyValue=$propertyValue, additionalProperties=$additionalProperties}" + } + + /** Configuration for a single bulk pricing tier */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val unitAmount: JsonField, + private val tierLowerBound: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + ) : this(unitAmount, tierLowerBound, mutableMapOf()) + + /** + * Amount per unit + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * The lower bound for this tier + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun tierLowerBound(): String? = + tierLowerBound.getNullable("tier_lower_bound") + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Tier]. + * + * The following fields are required: + * ```kotlin + * .unitAmount() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var unitAmount: JsonField? = null + private var tierLowerBound: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(tier: Tier) = apply { + unitAmount = tier.unitAmount + tierLowerBound = tier.tierLowerBound + additionalProperties = tier.additionalProperties.toMutableMap() + } + + /** Amount per unit */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + /** The lower bound for this tier */ + fun tierLowerBound(tierLowerBound: String?) = + tierLowerBound(JsonField.ofNullable(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```kotlin + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("unitAmount", unitAmount), + tierLowerBound, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + unitAmount() + tierLowerBound() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (unitAmount.asKnown() == null) 0 else 1) + + (if (tierLowerBound.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + unitAmount == other.unitAmount && + tierLowerBound == other.tierLowerBound && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(unitAmount, tierLowerBound, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{unitAmount=$unitAmount, tierLowerBound=$tierLowerBound, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BulkWithFiltersConfig && + filters == other.filters && + tiers == other.tiers && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(filters, tiers, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BulkWithFiltersConfig{filters=$filters, tiers=$tiers, additionalProperties=$additionalProperties}" + } + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BulkWithFilters && + bulkWithFiltersConfig == other.bulkWithFiltersConfig && + cadence == other.cadence && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + bulkWithFiltersConfig, + cadence, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BulkWithFilters{bulkWithFiltersConfig=$bulkWithFiltersConfig, cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + class TieredWithProration @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanVersion.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanVersion.kt index e562e4877..6a441361c 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanVersion.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanVersion.kt @@ -310,6 +310,10 @@ private constructor( /** Alias for calling [addPrice] with `Price.ofBulk(bulk)`. */ fun addPrice(bulk: Price.Bulk) = addPrice(Price.ofBulk(bulk)) + /** Alias for calling [addPrice] with `Price.ofBulkWithFilters(bulkWithFilters)`. */ + fun addPrice(bulkWithFilters: Price.BulkWithFilters) = + addPrice(Price.ofBulkWithFilters(bulkWithFilters)) + /** Alias for calling [addPrice] with `Price.ofPackage(package_)`. */ fun addPrice(package_: Price.Package) = addPrice(Price.ofPackage(package_)) diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Price.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Price.kt index 630d12b60..c879b870c 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Price.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Price.kt @@ -49,6 +49,7 @@ private constructor( private val unit: Unit? = null, private val tiered: Tiered? = null, private val bulk: Bulk? = null, + private val bulkWithFilters: BulkWithFilters? = null, private val package_: Package? = null, private val matrix: Matrix? = null, private val thresholdTotalAmount: ThresholdTotalAmount? = null, @@ -84,6 +85,8 @@ private constructor( fun bulk(): Bulk? = bulk + fun bulkWithFilters(): BulkWithFilters? = bulkWithFilters + fun package_(): Package? = package_ fun matrix(): Matrix? = matrix @@ -144,6 +147,8 @@ private constructor( fun isBulk(): Boolean = bulk != null + fun isBulkWithFilters(): Boolean = bulkWithFilters != null + fun isPackage(): Boolean = package_ != null fun isMatrix(): Boolean = matrix != null @@ -202,6 +207,8 @@ private constructor( fun asBulk(): Bulk = bulk.getOrThrow("bulk") + fun asBulkWithFilters(): BulkWithFilters = bulkWithFilters.getOrThrow("bulkWithFilters") + fun asPackage(): Package = package_.getOrThrow("package_") fun asMatrix(): Matrix = matrix.getOrThrow("matrix") @@ -275,6 +282,7 @@ private constructor( unit != null -> visitor.visitUnit(unit) tiered != null -> visitor.visitTiered(tiered) bulk != null -> visitor.visitBulk(bulk) + bulkWithFilters != null -> visitor.visitBulkWithFilters(bulkWithFilters) package_ != null -> visitor.visitPackage(package_) matrix != null -> visitor.visitMatrix(matrix) thresholdTotalAmount != null -> visitor.visitThresholdTotalAmount(thresholdTotalAmount) @@ -335,6 +343,10 @@ private constructor( bulk.validate() } + override fun visitBulkWithFilters(bulkWithFilters: BulkWithFilters) { + bulkWithFilters.validate() + } + override fun visitPackage(package_: Package) { package_.validate() } @@ -485,6 +497,9 @@ private constructor( override fun visitBulk(bulk: Bulk) = bulk.validity() + override fun visitBulkWithFilters(bulkWithFilters: BulkWithFilters) = + bulkWithFilters.validity() + override fun visitPackage(package_: Package) = package_.validity() override fun visitMatrix(matrix: Matrix) = matrix.validity() @@ -581,6 +596,7 @@ private constructor( unit == other.unit && tiered == other.tiered && bulk == other.bulk && + bulkWithFilters == other.bulkWithFilters && package_ == other.package_ && matrix == other.matrix && thresholdTotalAmount == other.thresholdTotalAmount && @@ -614,6 +630,7 @@ private constructor( unit, tiered, bulk, + bulkWithFilters, package_, matrix, thresholdTotalAmount, @@ -647,6 +664,7 @@ private constructor( unit != null -> "Price{unit=$unit}" tiered != null -> "Price{tiered=$tiered}" bulk != null -> "Price{bulk=$bulk}" + bulkWithFilters != null -> "Price{bulkWithFilters=$bulkWithFilters}" package_ != null -> "Price{package_=$package_}" matrix != null -> "Price{matrix=$matrix}" thresholdTotalAmount != null -> "Price{thresholdTotalAmount=$thresholdTotalAmount}" @@ -691,6 +709,9 @@ private constructor( fun ofBulk(bulk: Bulk) = Price(bulk = bulk) + fun ofBulkWithFilters(bulkWithFilters: BulkWithFilters) = + Price(bulkWithFilters = bulkWithFilters) + fun ofPackage(package_: Package) = Price(package_ = package_) fun ofMatrix(matrix: Matrix) = Price(matrix = matrix) @@ -775,6 +796,8 @@ private constructor( fun visitBulk(bulk: Bulk): T + fun visitBulkWithFilters(bulkWithFilters: BulkWithFilters): T + fun visitPackage(package_: Package): T fun visitMatrix(matrix: Matrix): T @@ -871,6 +894,11 @@ private constructor( Price(bulk = it, _json = json) } ?: Price(_json = json) } + "bulk_with_filters" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(bulkWithFilters = it, _json = json) + } ?: Price(_json = json) + } "package" -> { return tryDeserialize(node, jacksonTypeRef())?.let { Price(package_ = it, _json = json) @@ -1018,6 +1046,7 @@ private constructor( value.unit != null -> generator.writeObject(value.unit) value.tiered != null -> generator.writeObject(value.tiered) value.bulk != null -> generator.writeObject(value.bulk) + value.bulkWithFilters != null -> generator.writeObject(value.bulkWithFilters) value.package_ != null -> generator.writeObject(value.package_) value.matrix != null -> generator.writeObject(value.matrix) value.thresholdTotalAmount != null -> @@ -7119,6 +7148,2701 @@ private constructor( "Bulk{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, bulkConfig=$bulkConfig, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" } + class BulkWithFilters + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val billableMetric: JsonField, + private val billingCycleConfiguration: JsonField, + private val billingMode: JsonField, + private val bulkWithFiltersConfig: JsonField, + private val cadence: JsonField, + private val compositePriceFilters: JsonField>, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val createdAt: JsonField, + private val creditAllocation: JsonField, + private val currency: JsonField, + private val discount: JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val item: JsonField, + private val maximum: JsonField, + private val maximumAmount: JsonField, + private val metadata: JsonField, + private val minimum: JsonField, + private val minimumAmount: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val planPhaseOrder: JsonField, + private val priceType: JsonField, + private val replacesPriceId: JsonField, + private val dimensionalPriceConfiguration: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric") + @ExcludeMissing + billableMetric: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("billing_mode") + @ExcludeMissing + billingMode: JsonField = JsonMissing.of(), + @JsonProperty("bulk_with_filters_config") + @ExcludeMissing + bulkWithFiltersConfig: JsonField = JsonMissing.of(), + @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), + @JsonProperty("composite_price_filters") + @ExcludeMissing + compositePriceFilters: JsonField> = JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + createdAt: JsonField = JsonMissing.of(), + @JsonProperty("credit_allocation") + @ExcludeMissing + creditAllocation: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("discount") + @ExcludeMissing + discount: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("item") @ExcludeMissing item: JsonField = JsonMissing.of(), + @JsonProperty("maximum") @ExcludeMissing maximum: JsonField = JsonMissing.of(), + @JsonProperty("maximum_amount") + @ExcludeMissing + maximumAmount: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("minimum") @ExcludeMissing minimum: JsonField = JsonMissing.of(), + @JsonProperty("minimum_amount") + @ExcludeMissing + minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("model_type") @ExcludeMissing modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("plan_phase_order") + @ExcludeMissing + planPhaseOrder: JsonField = JsonMissing.of(), + @JsonProperty("price_type") + @ExcludeMissing + priceType: JsonField = JsonMissing.of(), + @JsonProperty("replaces_price_id") + @ExcludeMissing + replacesPriceId: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + ) : this( + id, + billableMetric, + billingCycleConfiguration, + billingMode, + bulkWithFiltersConfig, + cadence, + compositePriceFilters, + conversionRate, + conversionRateConfig, + createdAt, + creditAllocation, + currency, + discount, + externalPriceId, + fixedPriceQuantity, + invoicingCycleConfiguration, + item, + maximum, + maximumAmount, + metadata, + minimum, + minimumAmount, + modelType, + name, + planPhaseOrder, + priceType, + replacesPriceId, + dimensionalPriceConfiguration, + mutableMapOf(), + ) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun billableMetric(): BillableMetricTiny? = billableMetric.getNullable("billable_metric") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): BillingCycleConfiguration = + billingCycleConfiguration.getRequired("billing_cycle_configuration") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun billingMode(): BillingMode = billingMode.getRequired("billing_mode") + + /** + * Configuration for bulk_with_filters pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun bulkWithFiltersConfig(): BulkWithFiltersConfig = + bulkWithFiltersConfig.getRequired("bulk_with_filters_config") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun compositePriceFilters(): List? = + compositePriceFilters.getNullable("composite_price_filters") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun creditAllocation(): Allocation? = creditAllocation.getNullable("credit_allocation") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + @Deprecated("deprecated") fun discount(): Discount? = discount.getNullable("discount") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): BillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * A minimal representation of an Item containing only the essential identifying + * information. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun item(): ItemSlim = item.getRequired("item") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + @Deprecated("deprecated") fun maximum(): Maximum? = maximum.getNullable("maximum") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + @Deprecated("deprecated") + fun maximumAmount(): String? = maximumAmount.getNullable("maximum_amount") + + /** + * User specified key-value pairs for the resource. If not present, this defaults to an + * empty dictionary. Individual keys can be removed by setting the value to `null`, and the + * entire metadata mapping can be cleared by setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun metadata(): Metadata = metadata.getRequired("metadata") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + @Deprecated("deprecated") fun minimum(): Minimum? = minimum.getNullable("minimum") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + @Deprecated("deprecated") + fun minimumAmount(): String? = minimumAmount.getNullable("minimum_amount") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("bulk_with_filters") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun name(): String = name.getRequired("name") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun planPhaseOrder(): Long? = planPhaseOrder.getNullable("plan_phase_order") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun priceType(): PriceType = priceType.getRequired("price_type") + + /** + * The price id this price replaces. This price will take the place of the replaced price in + * plan version migrations. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun replacesPriceId(): String? = replacesPriceId.getNullable("replaces_price_id") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): DimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [billableMetric]. + * + * Unlike [billableMetric], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("billable_metric") + @ExcludeMissing + fun _billableMetric(): JsonField = billableMetric + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [billingMode]. + * + * Unlike [billingMode], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("billing_mode") + @ExcludeMissing + fun _billingMode(): JsonField = billingMode + + /** + * Returns the raw JSON value of [bulkWithFiltersConfig]. + * + * Unlike [bulkWithFiltersConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("bulk_with_filters_config") + @ExcludeMissing + fun _bulkWithFiltersConfig(): JsonField = bulkWithFiltersConfig + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [compositePriceFilters]. + * + * Unlike [compositePriceFilters], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("composite_price_filters") + @ExcludeMissing + fun _compositePriceFilters(): JsonField> = compositePriceFilters + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [createdAt]. + * + * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt + + /** + * Returns the raw JSON value of [creditAllocation]. + * + * Unlike [creditAllocation], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("credit_allocation") + @ExcludeMissing + fun _creditAllocation(): JsonField = creditAllocation + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [discount]. + * + * Unlike [discount], this method doesn't throw if the JSON field has an unexpected type. + */ + @Deprecated("deprecated") + @JsonProperty("discount") + @ExcludeMissing + fun _discount(): JsonField = discount + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [item]. + * + * Unlike [item], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("item") @ExcludeMissing fun _item(): JsonField = item + + /** + * Returns the raw JSON value of [maximum]. + * + * Unlike [maximum], this method doesn't throw if the JSON field has an unexpected type. + */ + @Deprecated("deprecated") + @JsonProperty("maximum") + @ExcludeMissing + fun _maximum(): JsonField = maximum + + /** + * Returns the raw JSON value of [maximumAmount]. + * + * Unlike [maximumAmount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @Deprecated("deprecated") + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [minimum]. + * + * Unlike [minimum], this method doesn't throw if the JSON field has an unexpected type. + */ + @Deprecated("deprecated") + @JsonProperty("minimum") + @ExcludeMissing + fun _minimum(): JsonField = minimum + + /** + * Returns the raw JSON value of [minimumAmount]. + * + * Unlike [minimumAmount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @Deprecated("deprecated") + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [planPhaseOrder]. + * + * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder + + /** + * Returns the raw JSON value of [priceType]. + * + * Unlike [priceType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("price_type") + @ExcludeMissing + fun _priceType(): JsonField = priceType + + /** + * Returns the raw JSON value of [replacesPriceId]. + * + * Unlike [replacesPriceId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("replaces_price_id") + @ExcludeMissing + fun _replacesPriceId(): JsonField = replacesPriceId + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [BulkWithFilters]. + * + * The following fields are required: + * ```kotlin + * .id() + * .billableMetric() + * .billingCycleConfiguration() + * .billingMode() + * .bulkWithFiltersConfig() + * .cadence() + * .compositePriceFilters() + * .conversionRate() + * .conversionRateConfig() + * .createdAt() + * .creditAllocation() + * .currency() + * .discount() + * .externalPriceId() + * .fixedPriceQuantity() + * .invoicingCycleConfiguration() + * .item() + * .maximum() + * .maximumAmount() + * .metadata() + * .minimum() + * .minimumAmount() + * .name() + * .planPhaseOrder() + * .priceType() + * .replacesPriceId() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [BulkWithFilters]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var billableMetric: JsonField? = null + private var billingCycleConfiguration: JsonField? = null + private var billingMode: JsonField? = null + private var bulkWithFiltersConfig: JsonField? = null + private var cadence: JsonField? = null + private var compositePriceFilters: JsonField>? = null + private var conversionRate: JsonField? = null + private var conversionRateConfig: JsonField? = null + private var createdAt: JsonField? = null + private var creditAllocation: JsonField? = null + private var currency: JsonField? = null + private var discount: JsonField? = null + private var externalPriceId: JsonField? = null + private var fixedPriceQuantity: JsonField? = null + private var invoicingCycleConfiguration: JsonField? = null + private var item: JsonField? = null + private var maximum: JsonField? = null + private var maximumAmount: JsonField? = null + private var metadata: JsonField? = null + private var minimum: JsonField? = null + private var minimumAmount: JsonField? = null + private var modelType: JsonValue = JsonValue.from("bulk_with_filters") + private var name: JsonField? = null + private var planPhaseOrder: JsonField? = null + private var priceType: JsonField? = null + private var replacesPriceId: JsonField? = null + private var dimensionalPriceConfiguration: JsonField = + JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(bulkWithFilters: BulkWithFilters) = apply { + id = bulkWithFilters.id + billableMetric = bulkWithFilters.billableMetric + billingCycleConfiguration = bulkWithFilters.billingCycleConfiguration + billingMode = bulkWithFilters.billingMode + bulkWithFiltersConfig = bulkWithFilters.bulkWithFiltersConfig + cadence = bulkWithFilters.cadence + compositePriceFilters = + bulkWithFilters.compositePriceFilters.map { it.toMutableList() } + conversionRate = bulkWithFilters.conversionRate + conversionRateConfig = bulkWithFilters.conversionRateConfig + createdAt = bulkWithFilters.createdAt + creditAllocation = bulkWithFilters.creditAllocation + currency = bulkWithFilters.currency + discount = bulkWithFilters.discount + externalPriceId = bulkWithFilters.externalPriceId + fixedPriceQuantity = bulkWithFilters.fixedPriceQuantity + invoicingCycleConfiguration = bulkWithFilters.invoicingCycleConfiguration + item = bulkWithFilters.item + maximum = bulkWithFilters.maximum + maximumAmount = bulkWithFilters.maximumAmount + metadata = bulkWithFilters.metadata + minimum = bulkWithFilters.minimum + minimumAmount = bulkWithFilters.minimumAmount + modelType = bulkWithFilters.modelType + name = bulkWithFilters.name + planPhaseOrder = bulkWithFilters.planPhaseOrder + priceType = bulkWithFilters.priceType + replacesPriceId = bulkWithFilters.replacesPriceId + dimensionalPriceConfiguration = bulkWithFilters.dimensionalPriceConfiguration + additionalProperties = bulkWithFilters.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun id(id: JsonField) = apply { this.id = id } + + fun billableMetric(billableMetric: BillableMetricTiny?) = + billableMetric(JsonField.ofNullable(billableMetric)) + + /** + * Sets [Builder.billableMetric] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetric] with a well-typed + * [BillableMetricTiny] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun billableMetric(billableMetric: JsonField) = apply { + this.billableMetric = billableMetric + } + + fun billingCycleConfiguration(billingCycleConfiguration: BillingCycleConfiguration) = + billingCycleConfiguration(JsonField.of(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [BillingCycleConfiguration] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + fun billingMode(billingMode: BillingMode) = billingMode(JsonField.of(billingMode)) + + /** + * Sets [Builder.billingMode] to an arbitrary JSON value. + * + * You should usually call [Builder.billingMode] with a well-typed [BillingMode] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun billingMode(billingMode: JsonField) = apply { + this.billingMode = billingMode + } + + /** Configuration for bulk_with_filters pricing */ + fun bulkWithFiltersConfig(bulkWithFiltersConfig: BulkWithFiltersConfig) = + bulkWithFiltersConfig(JsonField.of(bulkWithFiltersConfig)) + + /** + * Sets [Builder.bulkWithFiltersConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.bulkWithFiltersConfig] with a well-typed + * [BulkWithFiltersConfig] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun bulkWithFiltersConfig(bulkWithFiltersConfig: JsonField) = + apply { + this.bulkWithFiltersConfig = bulkWithFiltersConfig + } + + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + fun compositePriceFilters(compositePriceFilters: List?) = + compositePriceFilters(JsonField.ofNullable(compositePriceFilters)) + + /** + * Sets [Builder.compositePriceFilters] to an arbitrary JSON value. + * + * You should usually call [Builder.compositePriceFilters] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun compositePriceFilters( + compositePriceFilters: JsonField> + ) = apply { + this.compositePriceFilters = compositePriceFilters.map { it.toMutableList() } + } + + /** + * Adds a single [TransformPriceFilter] to [compositePriceFilters]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addCompositePriceFilter(compositePriceFilter: TransformPriceFilter) = apply { + compositePriceFilters = + (compositePriceFilters ?: JsonField.of(mutableListOf())).also { + checkKnown("compositePriceFilters", it).add(compositePriceFilter) + } + } + + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun conversionRateConfig(conversionRateConfig: JsonField) = + apply { + this.conversionRateConfig = conversionRateConfig + } + + /** + * Alias for calling [conversionRateConfig] with `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + .tieredConfig(tieredConfig) + .build() + ) + + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + + /** + * Sets [Builder.createdAt] to an arbitrary JSON value. + * + * You should usually call [Builder.createdAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun createdAt(createdAt: JsonField) = apply { + this.createdAt = createdAt + } + + fun creditAllocation(creditAllocation: Allocation?) = + creditAllocation(JsonField.ofNullable(creditAllocation)) + + /** + * Sets [Builder.creditAllocation] to an arbitrary JSON value. + * + * You should usually call [Builder.creditAllocation] with a well-typed [Allocation] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun creditAllocation(creditAllocation: JsonField) = apply { + this.creditAllocation = creditAllocation + } + + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + @Deprecated("deprecated") + fun discount(discount: Discount?) = discount(JsonField.ofNullable(discount)) + + /** + * Sets [Builder.discount] to an arbitrary JSON value. + * + * You should usually call [Builder.discount] with a well-typed [Discount] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + @Deprecated("deprecated") + fun discount(discount: JsonField) = apply { this.discount = discount } + + /** Alias for calling [discount] with `Discount.ofPercentage(percentage)`. */ + @Deprecated("deprecated") + fun discount(percentage: PercentageDiscount) = + discount(Discount.ofPercentage(percentage)) + + /** + * Alias for calling [discount] with the following: + * ```kotlin + * PercentageDiscount.builder() + * .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + * .percentageDiscount(percentageDiscount) + * .build() + * ``` + */ + @Deprecated("deprecated") + fun percentageDiscount(percentageDiscount: Double) = + discount( + PercentageDiscount.builder() + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(percentageDiscount) + .build() + ) + + /** Alias for calling [discount] with `Discount.ofTrial(trial)`. */ + @Deprecated("deprecated") + fun discount(trial: TrialDiscount) = discount(Discount.ofTrial(trial)) + + /** Alias for calling [discount] with `Discount.ofUsage(usage)`. */ + @Deprecated("deprecated") + fun discount(usage: UsageDiscount) = discount(Discount.ofUsage(usage)) + + /** + * Alias for calling [discount] with the following: + * ```kotlin + * UsageDiscount.builder() + * .discountType(UsageDiscount.DiscountType.USAGE) + * .usageDiscount(usageDiscount) + * .build() + * ``` + */ + @Deprecated("deprecated") + fun usageDiscount(usageDiscount: Double) = + discount( + UsageDiscount.builder() + .discountType(UsageDiscount.DiscountType.USAGE) + .usageDiscount(usageDiscount) + .build() + ) + + /** Alias for calling [discount] with `Discount.ofAmount(amount)`. */ + @Deprecated("deprecated") + fun discount(amount: AmountDiscount) = discount(Discount.ofAmount(amount)) + + /** + * Alias for calling [discount] with the following: + * ```kotlin + * AmountDiscount.builder() + * .discountType(AmountDiscount.DiscountType.AMOUNT) + * .amountDiscount(amountDiscount) + * .build() + * ``` + */ + @Deprecated("deprecated") + fun amountDiscount(amountDiscount: String) = + discount( + AmountDiscount.builder() + .discountType(AmountDiscount.DiscountType.AMOUNT) + .amountDiscount(amountDiscount) + .build() + ) + + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: BillingCycleConfiguration? + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a well-typed + * [BillingCycleConfiguration] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** + * A minimal representation of an Item containing only the essential identifying + * information. + */ + fun item(item: ItemSlim) = item(JsonField.of(item)) + + /** + * Sets [Builder.item] to an arbitrary JSON value. + * + * You should usually call [Builder.item] with a well-typed [ItemSlim] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun item(item: JsonField) = apply { this.item = item } + + @Deprecated("deprecated") + fun maximum(maximum: Maximum?) = maximum(JsonField.ofNullable(maximum)) + + /** + * Sets [Builder.maximum] to an arbitrary JSON value. + * + * You should usually call [Builder.maximum] with a well-typed [Maximum] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + @Deprecated("deprecated") + fun maximum(maximum: JsonField) = apply { this.maximum = maximum } + + @Deprecated("deprecated") + fun maximumAmount(maximumAmount: String?) = + maximumAmount(JsonField.ofNullable(maximumAmount)) + + /** + * Sets [Builder.maximumAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.maximumAmount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + @Deprecated("deprecated") + fun maximumAmount(maximumAmount: JsonField) = apply { + this.maximumAmount = maximumAmount + } + + /** + * User specified key-value pairs for the resource. If not present, this defaults to an + * empty dictionary. Individual keys can be removed by setting the value to `null`, and + * the entire metadata mapping can be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + @Deprecated("deprecated") + fun minimum(minimum: Minimum?) = minimum(JsonField.ofNullable(minimum)) + + /** + * Sets [Builder.minimum] to an arbitrary JSON value. + * + * You should usually call [Builder.minimum] with a well-typed [Minimum] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + @Deprecated("deprecated") + fun minimum(minimum: JsonField) = apply { this.minimum = minimum } + + @Deprecated("deprecated") + fun minimumAmount(minimumAmount: String?) = + minimumAmount(JsonField.ofNullable(minimumAmount)) + + /** + * Sets [Builder.minimumAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumAmount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + @Deprecated("deprecated") + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```kotlin + * JsonValue.from("bulk_with_filters") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + + /** + * Alias for [Builder.planPhaseOrder]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + + /** + * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. + * + * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun planPhaseOrder(planPhaseOrder: JsonField) = apply { + this.planPhaseOrder = planPhaseOrder + } + + fun priceType(priceType: PriceType) = priceType(JsonField.of(priceType)) + + /** + * Sets [Builder.priceType] to an arbitrary JSON value. + * + * You should usually call [Builder.priceType] with a well-typed [PriceType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun priceType(priceType: JsonField) = apply { this.priceType = priceType } + + /** + * The price id this price replaces. This price will take the place of the replaced + * price in plan version migrations. + */ + fun replacesPriceId(replacesPriceId: String?) = + replacesPriceId(JsonField.ofNullable(replacesPriceId)) + + /** + * Sets [Builder.replacesPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.replacesPriceId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun replacesPriceId(replacesPriceId: JsonField) = apply { + this.replacesPriceId = replacesPriceId + } + + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: DimensionalPriceConfiguration? + ) = dimensionalPriceConfiguration(JsonField.ofNullable(dimensionalPriceConfiguration)) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a well-typed + * [DimensionalPriceConfiguration] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BulkWithFilters]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .id() + * .billableMetric() + * .billingCycleConfiguration() + * .billingMode() + * .bulkWithFiltersConfig() + * .cadence() + * .compositePriceFilters() + * .conversionRate() + * .conversionRateConfig() + * .createdAt() + * .creditAllocation() + * .currency() + * .discount() + * .externalPriceId() + * .fixedPriceQuantity() + * .invoicingCycleConfiguration() + * .item() + * .maximum() + * .maximumAmount() + * .metadata() + * .minimum() + * .minimumAmount() + * .name() + * .planPhaseOrder() + * .priceType() + * .replacesPriceId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BulkWithFilters = + BulkWithFilters( + checkRequired("id", id), + checkRequired("billableMetric", billableMetric), + checkRequired("billingCycleConfiguration", billingCycleConfiguration), + checkRequired("billingMode", billingMode), + checkRequired("bulkWithFiltersConfig", bulkWithFiltersConfig), + checkRequired("cadence", cadence), + checkRequired("compositePriceFilters", compositePriceFilters).map { + it.toImmutable() + }, + checkRequired("conversionRate", conversionRate), + checkRequired("conversionRateConfig", conversionRateConfig), + checkRequired("createdAt", createdAt), + checkRequired("creditAllocation", creditAllocation), + checkRequired("currency", currency), + checkRequired("discount", discount), + checkRequired("externalPriceId", externalPriceId), + checkRequired("fixedPriceQuantity", fixedPriceQuantity), + checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), + checkRequired("item", item), + checkRequired("maximum", maximum), + checkRequired("maximumAmount", maximumAmount), + checkRequired("metadata", metadata), + checkRequired("minimum", minimum), + checkRequired("minimumAmount", minimumAmount), + modelType, + checkRequired("name", name), + checkRequired("planPhaseOrder", planPhaseOrder), + checkRequired("priceType", priceType), + checkRequired("replacesPriceId", replacesPriceId), + dimensionalPriceConfiguration, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): BulkWithFilters = apply { + if (validated) { + return@apply + } + + id() + billableMetric()?.validate() + billingCycleConfiguration().validate() + billingMode().validate() + bulkWithFiltersConfig().validate() + cadence().validate() + compositePriceFilters()?.forEach { it.validate() } + conversionRate() + conversionRateConfig()?.validate() + createdAt() + creditAllocation()?.validate() + currency() + discount()?.validate() + externalPriceId() + fixedPriceQuantity() + invoicingCycleConfiguration()?.validate() + item().validate() + maximum()?.validate() + maximumAmount() + metadata().validate() + minimum()?.validate() + minimumAmount() + _modelType().let { + if (it != JsonValue.from("bulk_with_filters")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + planPhaseOrder() + priceType().validate() + replacesPriceId() + dimensionalPriceConfiguration()?.validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (id.asKnown() == null) 0 else 1) + + (billableMetric.asKnown()?.validity() ?: 0) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (billingMode.asKnown()?.validity() ?: 0) + + (bulkWithFiltersConfig.asKnown()?.validity() ?: 0) + + (cadence.asKnown()?.validity() ?: 0) + + (compositePriceFilters.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (createdAt.asKnown() == null) 0 else 1) + + (creditAllocation.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (discount.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (item.asKnown()?.validity() ?: 0) + + (maximum.asKnown()?.validity() ?: 0) + + (if (maximumAmount.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (minimum.asKnown()?.validity() ?: 0) + + (if (minimumAmount.asKnown() == null) 0 else 1) + + modelType.let { if (it == JsonValue.from("bulk_with_filters")) 1 else 0 } + + (if (name.asKnown() == null) 0 else 1) + + (if (planPhaseOrder.asKnown() == null) 0 else 1) + + (priceType.asKnown()?.validity() ?: 0) + + (if (replacesPriceId.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + class BillingMode @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val IN_ADVANCE = of("in_advance") + + val IN_ARREAR = of("in_arrear") + + fun of(value: String) = BillingMode(JsonField.of(value)) + } + + /** An enum containing [BillingMode]'s known values. */ + enum class Known { + IN_ADVANCE, + IN_ARREAR, + } + + /** + * An enum containing [BillingMode]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [BillingMode] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + IN_ADVANCE, + IN_ARREAR, + /** + * An enum member indicating that [BillingMode] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + IN_ADVANCE -> Value.IN_ADVANCE + IN_ARREAR -> Value.IN_ARREAR + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + IN_ADVANCE -> Known.IN_ADVANCE + IN_ARREAR -> Known.IN_ARREAR + else -> throw OrbInvalidDataException("Unknown BillingMode: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): BillingMode = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BillingMode && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Configuration for bulk_with_filters pricing */ + class BulkWithFiltersConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val filters: JsonField>, + private val tiers: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("filters") + @ExcludeMissing + filters: JsonField> = JsonMissing.of(), + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of(), + ) : this(filters, tiers, mutableMapOf()) + + /** + * Property filters to apply (all must match) + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun filters(): List = filters.getRequired("filters") + + /** + * Bulk tiers for rating based on total usage volume + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun tiers(): List = tiers.getRequired("tiers") + + /** + * Returns the raw JSON value of [filters]. + * + * Unlike [filters], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("filters") + @ExcludeMissing + fun _filters(): JsonField> = filters + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tiers") @ExcludeMissing fun _tiers(): JsonField> = tiers + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [BulkWithFiltersConfig]. + * + * The following fields are required: + * ```kotlin + * .filters() + * .tiers() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [BulkWithFiltersConfig]. */ + class Builder internal constructor() { + + private var filters: JsonField>? = null + private var tiers: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(bulkWithFiltersConfig: BulkWithFiltersConfig) = apply { + filters = bulkWithFiltersConfig.filters.map { it.toMutableList() } + tiers = bulkWithFiltersConfig.tiers.map { it.toMutableList() } + additionalProperties = bulkWithFiltersConfig.additionalProperties.toMutableMap() + } + + /** Property filters to apply (all must match) */ + fun filters(filters: List) = filters(JsonField.of(filters)) + + /** + * Sets [Builder.filters] to an arbitrary JSON value. + * + * You should usually call [Builder.filters] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun filters(filters: JsonField>) = apply { + this.filters = filters.map { it.toMutableList() } + } + + /** + * Adds a single [Filter] to [filters]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addFilter(filter: Filter) = apply { + filters = + (filters ?: JsonField.of(mutableListOf())).also { + checkKnown("filters", it).add(filter) + } + } + + /** Bulk tiers for rating based on total usage volume */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BulkWithFiltersConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .filters() + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BulkWithFiltersConfig = + BulkWithFiltersConfig( + checkRequired("filters", filters).map { it.toImmutable() }, + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): BulkWithFiltersConfig = apply { + if (validated) { + return@apply + } + + filters().forEach { it.validate() } + tiers().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (filters.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + (tiers.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single property filter */ + class Filter + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val propertyKey: JsonField, + private val propertyValue: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("property_key") + @ExcludeMissing + propertyKey: JsonField = JsonMissing.of(), + @JsonProperty("property_value") + @ExcludeMissing + propertyValue: JsonField = JsonMissing.of(), + ) : this(propertyKey, propertyValue, mutableMapOf()) + + /** + * Event property key to filter on + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun propertyKey(): String = propertyKey.getRequired("property_key") + + /** + * Event property value to match + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun propertyValue(): String = propertyValue.getRequired("property_value") + + /** + * Returns the raw JSON value of [propertyKey]. + * + * Unlike [propertyKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("property_key") + @ExcludeMissing + fun _propertyKey(): JsonField = propertyKey + + /** + * Returns the raw JSON value of [propertyValue]. + * + * Unlike [propertyValue], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("property_value") + @ExcludeMissing + fun _propertyValue(): JsonField = propertyValue + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Filter]. + * + * The following fields are required: + * ```kotlin + * .propertyKey() + * .propertyValue() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Filter]. */ + class Builder internal constructor() { + + private var propertyKey: JsonField? = null + private var propertyValue: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(filter: Filter) = apply { + propertyKey = filter.propertyKey + propertyValue = filter.propertyValue + additionalProperties = filter.additionalProperties.toMutableMap() + } + + /** Event property key to filter on */ + fun propertyKey(propertyKey: String) = propertyKey(JsonField.of(propertyKey)) + + /** + * Sets [Builder.propertyKey] to an arbitrary JSON value. + * + * You should usually call [Builder.propertyKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun propertyKey(propertyKey: JsonField) = apply { + this.propertyKey = propertyKey + } + + /** Event property value to match */ + fun propertyValue(propertyValue: String) = + propertyValue(JsonField.of(propertyValue)) + + /** + * Sets [Builder.propertyValue] to an arbitrary JSON value. + * + * You should usually call [Builder.propertyValue] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun propertyValue(propertyValue: JsonField) = apply { + this.propertyValue = propertyValue + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Filter]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .propertyKey() + * .propertyValue() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Filter = + Filter( + checkRequired("propertyKey", propertyKey), + checkRequired("propertyValue", propertyValue), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Filter = apply { + if (validated) { + return@apply + } + + propertyKey() + propertyValue() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (propertyKey.asKnown() == null) 0 else 1) + + (if (propertyValue.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Filter && + propertyKey == other.propertyKey && + propertyValue == other.propertyValue && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(propertyKey, propertyValue, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Filter{propertyKey=$propertyKey, propertyValue=$propertyValue, additionalProperties=$additionalProperties}" + } + + /** Configuration for a single bulk pricing tier */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val unitAmount: JsonField, + private val tierLowerBound: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + ) : this(unitAmount, tierLowerBound, mutableMapOf()) + + /** + * Amount per unit + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * The lower bound for this tier + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun tierLowerBound(): String? = tierLowerBound.getNullable("tier_lower_bound") + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Tier]. + * + * The following fields are required: + * ```kotlin + * .unitAmount() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var unitAmount: JsonField? = null + private var tierLowerBound: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(tier: Tier) = apply { + unitAmount = tier.unitAmount + tierLowerBound = tier.tierLowerBound + additionalProperties = tier.additionalProperties.toMutableMap() + } + + /** Amount per unit */ + fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + /** The lower bound for this tier */ + fun tierLowerBound(tierLowerBound: String?) = + tierLowerBound(JsonField.ofNullable(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Tier]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("unitAmount", unitAmount), + tierLowerBound, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + unitAmount() + tierLowerBound() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (unitAmount.asKnown() == null) 0 else 1) + + (if (tierLowerBound.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + unitAmount == other.unitAmount && + tierLowerBound == other.tierLowerBound && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(unitAmount, tierLowerBound, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{unitAmount=$unitAmount, tierLowerBound=$tierLowerBound, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BulkWithFiltersConfig && + filters == other.filters && + tiers == other.tiers && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(filters, tiers, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BulkWithFiltersConfig{filters=$filters, tiers=$tiers, additionalProperties=$additionalProperties}" + } + + class Cadence @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val ONE_TIME = of("one_time") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val SEMI_ANNUAL = of("semi_annual") + + val ANNUAL = of("annual") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ONE_TIME, + MONTHLY, + QUARTERLY, + SEMI_ANNUAL, + ANNUAL, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ONE_TIME, + MONTHLY, + QUARTERLY, + SEMI_ANNUAL, + ANNUAL, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ONE_TIME -> Value.ONE_TIME + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + SEMI_ANNUAL -> Value.SEMI_ANNUAL + ANNUAL -> Value.ANNUAL + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + ONE_TIME -> Known.ONE_TIME + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + SEMI_ANNUAL -> Known.SEMI_ANNUAL + ANNUAL -> Known.ANNUAL + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * User specified key-value pairs for the resource. If not present, this defaults to an + * empty dictionary. Individual keys can be removed by setting the value to `null`, and the + * entire metadata mapping can be cleared by setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + class PriceType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val USAGE_PRICE = of("usage_price") + + val FIXED_PRICE = of("fixed_price") + + val COMPOSITE_PRICE = of("composite_price") + + fun of(value: String) = PriceType(JsonField.of(value)) + } + + /** An enum containing [PriceType]'s known values. */ + enum class Known { + USAGE_PRICE, + FIXED_PRICE, + COMPOSITE_PRICE, + } + + /** + * An enum containing [PriceType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [PriceType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + USAGE_PRICE, + FIXED_PRICE, + COMPOSITE_PRICE, + /** + * An enum member indicating that [PriceType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + USAGE_PRICE -> Value.USAGE_PRICE + FIXED_PRICE -> Value.FIXED_PRICE + COMPOSITE_PRICE -> Value.COMPOSITE_PRICE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + USAGE_PRICE -> Known.USAGE_PRICE + FIXED_PRICE -> Known.FIXED_PRICE + COMPOSITE_PRICE -> Known.COMPOSITE_PRICE + else -> throw OrbInvalidDataException("Unknown PriceType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): PriceType = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PriceType && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BulkWithFilters && + id == other.id && + billableMetric == other.billableMetric && + billingCycleConfiguration == other.billingCycleConfiguration && + billingMode == other.billingMode && + bulkWithFiltersConfig == other.bulkWithFiltersConfig && + cadence == other.cadence && + compositePriceFilters == other.compositePriceFilters && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + createdAt == other.createdAt && + creditAllocation == other.creditAllocation && + currency == other.currency && + discount == other.discount && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + item == other.item && + maximum == other.maximum && + maximumAmount == other.maximumAmount && + metadata == other.metadata && + minimum == other.minimum && + minimumAmount == other.minimumAmount && + modelType == other.modelType && + name == other.name && + planPhaseOrder == other.planPhaseOrder && + priceType == other.priceType && + replacesPriceId == other.replacesPriceId && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + billableMetric, + billingCycleConfiguration, + billingMode, + bulkWithFiltersConfig, + cadence, + compositePriceFilters, + conversionRate, + conversionRateConfig, + createdAt, + creditAllocation, + currency, + discount, + externalPriceId, + fixedPriceQuantity, + invoicingCycleConfiguration, + item, + maximum, + maximumAmount, + metadata, + minimum, + minimumAmount, + modelType, + name, + planPhaseOrder, + priceType, + replacesPriceId, + dimensionalPriceConfiguration, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BulkWithFilters{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, bulkWithFiltersConfig=$bulkWithFiltersConfig, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + } + class Package @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceCreateParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceCreateParams.kt index 42afecefd..1cf6b93ed 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceCreateParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceCreateParams.kt @@ -21,6 +21,7 @@ import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.Params +import com.withorb.api.core.checkKnown import com.withorb.api.core.checkRequired import com.withorb.api.core.getOrThrow import com.withorb.api.core.http.Headers @@ -98,6 +99,10 @@ private constructor( /** Alias for calling [body] with `Body.ofBulk(bulk)`. */ fun body(bulk: NewFloatingBulkPrice) = body(Body.ofBulk(bulk)) + /** Alias for calling [body] with `Body.ofBulkWithFilters(bulkWithFilters)`. */ + fun body(bulkWithFilters: Body.BulkWithFilters) = + body(Body.ofBulkWithFilters(bulkWithFilters)) + /** Alias for calling [body] with `Body.ofPackage(package_)`. */ fun body(package_: NewFloatingPackagePrice) = body(Body.ofPackage(package_)) @@ -347,6 +352,7 @@ private constructor( private val unit: NewFloatingUnitPrice? = null, private val tiered: NewFloatingTieredPrice? = null, private val bulk: NewFloatingBulkPrice? = null, + private val bulkWithFilters: BulkWithFilters? = null, private val package_: NewFloatingPackagePrice? = null, private val matrix: NewFloatingMatrixPrice? = null, private val thresholdTotalAmount: NewFloatingThresholdTotalAmountPrice? = null, @@ -385,6 +391,8 @@ private constructor( fun bulk(): NewFloatingBulkPrice? = bulk + fun bulkWithFilters(): BulkWithFilters? = bulkWithFilters + fun package_(): NewFloatingPackagePrice? = package_ fun matrix(): NewFloatingMatrixPrice? = matrix @@ -449,6 +457,8 @@ private constructor( fun isBulk(): Boolean = bulk != null + fun isBulkWithFilters(): Boolean = bulkWithFilters != null + fun isPackage(): Boolean = package_ != null fun isMatrix(): Boolean = matrix != null @@ -507,6 +517,8 @@ private constructor( fun asBulk(): NewFloatingBulkPrice = bulk.getOrThrow("bulk") + fun asBulkWithFilters(): BulkWithFilters = bulkWithFilters.getOrThrow("bulkWithFilters") + fun asPackage(): NewFloatingPackagePrice = package_.getOrThrow("package_") fun asMatrix(): NewFloatingMatrixPrice = matrix.getOrThrow("matrix") @@ -587,6 +599,7 @@ private constructor( unit != null -> visitor.visitUnit(unit) tiered != null -> visitor.visitTiered(tiered) bulk != null -> visitor.visitBulk(bulk) + bulkWithFilters != null -> visitor.visitBulkWithFilters(bulkWithFilters) package_ != null -> visitor.visitPackage(package_) matrix != null -> visitor.visitMatrix(matrix) thresholdTotalAmount != null -> @@ -650,6 +663,10 @@ private constructor( bulk.validate() } + override fun visitBulkWithFilters(bulkWithFilters: BulkWithFilters) { + bulkWithFilters.validate() + } + override fun visitPackage(package_: NewFloatingPackagePrice) { package_.validate() } @@ -820,6 +837,9 @@ private constructor( override fun visitBulk(bulk: NewFloatingBulkPrice) = bulk.validity() + override fun visitBulkWithFilters(bulkWithFilters: BulkWithFilters) = + bulkWithFilters.validity() + override fun visitPackage(package_: NewFloatingPackagePrice) = package_.validity() @@ -928,6 +948,7 @@ private constructor( unit == other.unit && tiered == other.tiered && bulk == other.bulk && + bulkWithFilters == other.bulkWithFilters && package_ == other.package_ && matrix == other.matrix && thresholdTotalAmount == other.thresholdTotalAmount && @@ -961,6 +982,7 @@ private constructor( unit, tiered, bulk, + bulkWithFilters, package_, matrix, thresholdTotalAmount, @@ -994,6 +1016,7 @@ private constructor( unit != null -> "Body{unit=$unit}" tiered != null -> "Body{tiered=$tiered}" bulk != null -> "Body{bulk=$bulk}" + bulkWithFilters != null -> "Body{bulkWithFilters=$bulkWithFilters}" package_ != null -> "Body{package_=$package_}" matrix != null -> "Body{matrix=$matrix}" thresholdTotalAmount != null -> "Body{thresholdTotalAmount=$thresholdTotalAmount}" @@ -1042,6 +1065,9 @@ private constructor( fun ofBulk(bulk: NewFloatingBulkPrice) = Body(bulk = bulk) + fun ofBulkWithFilters(bulkWithFilters: BulkWithFilters) = + Body(bulkWithFilters = bulkWithFilters) + fun ofPackage(package_: NewFloatingPackagePrice) = Body(package_ = package_) fun ofMatrix(matrix: NewFloatingMatrixPrice) = Body(matrix = matrix) @@ -1135,6 +1161,8 @@ private constructor( fun visitBulk(bulk: NewFloatingBulkPrice): T + fun visitBulkWithFilters(bulkWithFilters: BulkWithFilters): T + fun visitPackage(package_: NewFloatingPackagePrice): T fun visitMatrix(matrix: NewFloatingMatrixPrice): T @@ -1251,6 +1279,11 @@ private constructor( Body(bulk = it, _json = json) } ?: Body(_json = json) } + "bulk_with_filters" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Body(bulkWithFilters = it, _json = json) + } ?: Body(_json = json) + } "package" -> { return tryDeserialize(node, jacksonTypeRef()) ?.let { Body(package_ = it, _json = json) } ?: Body(_json = json) @@ -1450,6 +1483,7 @@ private constructor( value.unit != null -> generator.writeObject(value.unit) value.tiered != null -> generator.writeObject(value.tiered) value.bulk != null -> generator.writeObject(value.bulk) + value.bulkWithFilters != null -> generator.writeObject(value.bulkWithFilters) value.package_ != null -> generator.writeObject(value.package_) value.matrix != null -> generator.writeObject(value.matrix) value.thresholdTotalAmount != null -> @@ -1500,6 +1534,1950 @@ private constructor( } } + class BulkWithFilters + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val bulkWithFiltersConfig: JsonField, + private val cadence: JsonField, + private val currency: JsonField, + private val itemId: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val dimensionalPriceConfiguration: JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val metadata: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("bulk_with_filters_config") + @ExcludeMissing + bulkWithFiltersConfig: JsonField = JsonMissing.of(), + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") @ExcludeMissing modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + ) : this( + bulkWithFiltersConfig, + cadence, + currency, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + mutableMapOf(), + ) + + /** + * Configuration for bulk_with_filters pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun bulkWithFiltersConfig(): BulkWithFiltersConfig = + bulkWithFiltersConfig.getRequired("bulk_with_filters_config") + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * An ISO 4217 currency string for which this price is billed in. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("bulk_with_filters") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun billableMetricId(): String? = billableMetricId.getNullable("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + invoiceGroupingKey.getNullable("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * Returns the raw JSON value of [bulkWithFiltersConfig]. + * + * Unlike [bulkWithFiltersConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("bulk_with_filters_config") + @ExcludeMissing + fun _bulkWithFiltersConfig(): JsonField = bulkWithFiltersConfig + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [BulkWithFilters]. + * + * The following fields are required: + * ```kotlin + * .bulkWithFiltersConfig() + * .cadence() + * .currency() + * .itemId() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [BulkWithFilters]. */ + class Builder internal constructor() { + + private var bulkWithFiltersConfig: JsonField? = null + private var cadence: JsonField? = null + private var currency: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonValue = JsonValue.from("bulk_with_filters") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(bulkWithFilters: BulkWithFilters) = apply { + bulkWithFiltersConfig = bulkWithFilters.bulkWithFiltersConfig + cadence = bulkWithFilters.cadence + currency = bulkWithFilters.currency + itemId = bulkWithFilters.itemId + modelType = bulkWithFilters.modelType + name = bulkWithFilters.name + billableMetricId = bulkWithFilters.billableMetricId + billedInAdvance = bulkWithFilters.billedInAdvance + billingCycleConfiguration = bulkWithFilters.billingCycleConfiguration + conversionRate = bulkWithFilters.conversionRate + conversionRateConfig = bulkWithFilters.conversionRateConfig + dimensionalPriceConfiguration = bulkWithFilters.dimensionalPriceConfiguration + externalPriceId = bulkWithFilters.externalPriceId + fixedPriceQuantity = bulkWithFilters.fixedPriceQuantity + invoiceGroupingKey = bulkWithFilters.invoiceGroupingKey + invoicingCycleConfiguration = bulkWithFilters.invoicingCycleConfiguration + metadata = bulkWithFilters.metadata + additionalProperties = bulkWithFilters.additionalProperties.toMutableMap() + } + + /** Configuration for bulk_with_filters pricing */ + fun bulkWithFiltersConfig(bulkWithFiltersConfig: BulkWithFiltersConfig) = + bulkWithFiltersConfig(JsonField.of(bulkWithFiltersConfig)) + + /** + * Sets [Builder.bulkWithFiltersConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.bulkWithFiltersConfig] with a well-typed + * [BulkWithFiltersConfig] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun bulkWithFiltersConfig(bulkWithFiltersConfig: JsonField) = + apply { + this.bulkWithFiltersConfig = bulkWithFiltersConfig + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```kotlin + * JsonValue.from("bulk_with_filters") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun conversionRateConfig(conversionRateConfig: JsonField) = + apply { + this.conversionRateConfig = conversionRateConfig + } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a well-typed + * [NewDimensionalPriceConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BulkWithFilters]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .bulkWithFiltersConfig() + * .cadence() + * .currency() + * .itemId() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BulkWithFilters = + BulkWithFilters( + checkRequired("bulkWithFiltersConfig", bulkWithFiltersConfig), + checkRequired("cadence", cadence), + checkRequired("currency", currency), + checkRequired("itemId", itemId), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): BulkWithFilters = apply { + if (validated) { + return@apply + } + + bulkWithFiltersConfig().validate() + cadence().validate() + currency() + itemId() + _modelType().let { + if (it != JsonValue.from("bulk_with_filters")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + metadata()?.validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (bulkWithFiltersConfig.asKnown()?.validity() ?: 0) + + (cadence.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (if (itemId.asKnown() == null) 0 else 1) + + modelType.let { if (it == JsonValue.from("bulk_with_filters")) 1 else 0 } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (metadata.asKnown()?.validity() ?: 0) + + /** Configuration for bulk_with_filters pricing */ + class BulkWithFiltersConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val filters: JsonField>, + private val tiers: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("filters") + @ExcludeMissing + filters: JsonField> = JsonMissing.of(), + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of(), + ) : this(filters, tiers, mutableMapOf()) + + /** + * Property filters to apply (all must match) + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun filters(): List = filters.getRequired("filters") + + /** + * Bulk tiers for rating based on total usage volume + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun tiers(): List = tiers.getRequired("tiers") + + /** + * Returns the raw JSON value of [filters]. + * + * Unlike [filters], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("filters") + @ExcludeMissing + fun _filters(): JsonField> = filters + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tiers") @ExcludeMissing fun _tiers(): JsonField> = tiers + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [BulkWithFiltersConfig]. + * + * The following fields are required: + * ```kotlin + * .filters() + * .tiers() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [BulkWithFiltersConfig]. */ + class Builder internal constructor() { + + private var filters: JsonField>? = null + private var tiers: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(bulkWithFiltersConfig: BulkWithFiltersConfig) = apply { + filters = bulkWithFiltersConfig.filters.map { it.toMutableList() } + tiers = bulkWithFiltersConfig.tiers.map { it.toMutableList() } + additionalProperties = + bulkWithFiltersConfig.additionalProperties.toMutableMap() + } + + /** Property filters to apply (all must match) */ + fun filters(filters: List) = filters(JsonField.of(filters)) + + /** + * Sets [Builder.filters] to an arbitrary JSON value. + * + * You should usually call [Builder.filters] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun filters(filters: JsonField>) = apply { + this.filters = filters.map { it.toMutableList() } + } + + /** + * Adds a single [Filter] to [filters]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addFilter(filter: Filter) = apply { + filters = + (filters ?: JsonField.of(mutableListOf())).also { + checkKnown("filters", it).add(filter) + } + } + + /** Bulk tiers for rating based on total usage volume */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BulkWithFiltersConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .filters() + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BulkWithFiltersConfig = + BulkWithFiltersConfig( + checkRequired("filters", filters).map { it.toImmutable() }, + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): BulkWithFiltersConfig = apply { + if (validated) { + return@apply + } + + filters().forEach { it.validate() } + tiers().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (filters.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + (tiers.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single property filter */ + class Filter + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val propertyKey: JsonField, + private val propertyValue: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("property_key") + @ExcludeMissing + propertyKey: JsonField = JsonMissing.of(), + @JsonProperty("property_value") + @ExcludeMissing + propertyValue: JsonField = JsonMissing.of(), + ) : this(propertyKey, propertyValue, mutableMapOf()) + + /** + * Event property key to filter on + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun propertyKey(): String = propertyKey.getRequired("property_key") + + /** + * Event property value to match + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun propertyValue(): String = propertyValue.getRequired("property_value") + + /** + * Returns the raw JSON value of [propertyKey]. + * + * Unlike [propertyKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("property_key") + @ExcludeMissing + fun _propertyKey(): JsonField = propertyKey + + /** + * Returns the raw JSON value of [propertyValue]. + * + * Unlike [propertyValue], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("property_value") + @ExcludeMissing + fun _propertyValue(): JsonField = propertyValue + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Filter]. + * + * The following fields are required: + * ```kotlin + * .propertyKey() + * .propertyValue() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Filter]. */ + class Builder internal constructor() { + + private var propertyKey: JsonField? = null + private var propertyValue: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(filter: Filter) = apply { + propertyKey = filter.propertyKey + propertyValue = filter.propertyValue + additionalProperties = filter.additionalProperties.toMutableMap() + } + + /** Event property key to filter on */ + fun propertyKey(propertyKey: String) = + propertyKey(JsonField.of(propertyKey)) + + /** + * Sets [Builder.propertyKey] to an arbitrary JSON value. + * + * You should usually call [Builder.propertyKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun propertyKey(propertyKey: JsonField) = apply { + this.propertyKey = propertyKey + } + + /** Event property value to match */ + fun propertyValue(propertyValue: String) = + propertyValue(JsonField.of(propertyValue)) + + /** + * Sets [Builder.propertyValue] to an arbitrary JSON value. + * + * You should usually call [Builder.propertyValue] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun propertyValue(propertyValue: JsonField) = apply { + this.propertyValue = propertyValue + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Filter]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .propertyKey() + * .propertyValue() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Filter = + Filter( + checkRequired("propertyKey", propertyKey), + checkRequired("propertyValue", propertyValue), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Filter = apply { + if (validated) { + return@apply + } + + propertyKey() + propertyValue() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (propertyKey.asKnown() == null) 0 else 1) + + (if (propertyValue.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Filter && + propertyKey == other.propertyKey && + propertyValue == other.propertyValue && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(propertyKey, propertyValue, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Filter{propertyKey=$propertyKey, propertyValue=$propertyValue, additionalProperties=$additionalProperties}" + } + + /** Configuration for a single bulk pricing tier */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val unitAmount: JsonField, + private val tierLowerBound: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + ) : this(unitAmount, tierLowerBound, mutableMapOf()) + + /** + * Amount per unit + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * The lower bound for this tier + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun tierLowerBound(): String? = tierLowerBound.getNullable("tier_lower_bound") + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Tier]. + * + * The following fields are required: + * ```kotlin + * .unitAmount() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var unitAmount: JsonField? = null + private var tierLowerBound: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(tier: Tier) = apply { + unitAmount = tier.unitAmount + tierLowerBound = tier.tierLowerBound + additionalProperties = tier.additionalProperties.toMutableMap() + } + + /** Amount per unit */ + fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + /** The lower bound for this tier */ + fun tierLowerBound(tierLowerBound: String?) = + tierLowerBound(JsonField.ofNullable(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Tier]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("unitAmount", unitAmount), + tierLowerBound, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + unitAmount() + tierLowerBound() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (unitAmount.asKnown() == null) 0 else 1) + + (if (tierLowerBound.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + unitAmount == other.unitAmount && + tierLowerBound == other.tierLowerBound && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(unitAmount, tierLowerBound, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{unitAmount=$unitAmount, tierLowerBound=$tierLowerBound, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BulkWithFiltersConfig && + filters == other.filters && + tiers == other.tiers && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(filters, tiers, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BulkWithFiltersConfig{filters=$filters, tiers=$tiers, additionalProperties=$additionalProperties}" + } + + /** The cadence to bill for this price on. */ + class Cadence @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BulkWithFilters && + bulkWithFiltersConfig == other.bulkWithFiltersConfig && + cadence == other.cadence && + currency == other.currency && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + bulkWithFiltersConfig, + cadence, + currency, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BulkWithFilters{bulkWithFiltersConfig=$bulkWithFiltersConfig, cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + } + class GroupedWithMinMaxThresholds @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceEvaluateMultipleParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceEvaluateMultipleParams.kt index 4b815aba7..28a851d22 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceEvaluateMultipleParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceEvaluateMultipleParams.kt @@ -1012,6 +1012,10 @@ private constructor( /** Alias for calling [price] with `Price.ofBulk(bulk)`. */ fun price(bulk: NewFloatingBulkPrice) = price(Price.ofBulk(bulk)) + /** Alias for calling [price] with `Price.ofBulkWithFilters(bulkWithFilters)`. */ + fun price(bulkWithFilters: Price.BulkWithFilters) = + price(Price.ofBulkWithFilters(bulkWithFilters)) + /** Alias for calling [price] with `Price.ofPackage(package_)`. */ fun price(package_: NewFloatingPackagePrice) = price(Price.ofPackage(package_)) @@ -1242,6 +1246,7 @@ private constructor( private val unit: NewFloatingUnitPrice? = null, private val tiered: NewFloatingTieredPrice? = null, private val bulk: NewFloatingBulkPrice? = null, + private val bulkWithFilters: BulkWithFilters? = null, private val package_: NewFloatingPackagePrice? = null, private val matrix: NewFloatingMatrixPrice? = null, private val thresholdTotalAmount: NewFloatingThresholdTotalAmountPrice? = null, @@ -1283,6 +1288,8 @@ private constructor( fun bulk(): NewFloatingBulkPrice? = bulk + fun bulkWithFilters(): BulkWithFilters? = bulkWithFilters + fun package_(): NewFloatingPackagePrice? = package_ fun matrix(): NewFloatingMatrixPrice? = matrix @@ -1351,6 +1358,8 @@ private constructor( fun isBulk(): Boolean = bulk != null + fun isBulkWithFilters(): Boolean = bulkWithFilters != null + fun isPackage(): Boolean = package_ != null fun isMatrix(): Boolean = matrix != null @@ -1410,6 +1419,8 @@ private constructor( fun asBulk(): NewFloatingBulkPrice = bulk.getOrThrow("bulk") + fun asBulkWithFilters(): BulkWithFilters = bulkWithFilters.getOrThrow("bulkWithFilters") + fun asPackage(): NewFloatingPackagePrice = package_.getOrThrow("package_") fun asMatrix(): NewFloatingMatrixPrice = matrix.getOrThrow("matrix") @@ -1491,6 +1502,7 @@ private constructor( unit != null -> visitor.visitUnit(unit) tiered != null -> visitor.visitTiered(tiered) bulk != null -> visitor.visitBulk(bulk) + bulkWithFilters != null -> visitor.visitBulkWithFilters(bulkWithFilters) package_ != null -> visitor.visitPackage(package_) matrix != null -> visitor.visitMatrix(matrix) thresholdTotalAmount != null -> @@ -1557,6 +1569,10 @@ private constructor( bulk.validate() } + override fun visitBulkWithFilters(bulkWithFilters: BulkWithFilters) { + bulkWithFilters.validate() + } + override fun visitPackage(package_: NewFloatingPackagePrice) { package_.validate() } @@ -1732,6 +1748,9 @@ private constructor( override fun visitBulk(bulk: NewFloatingBulkPrice) = bulk.validity() + override fun visitBulkWithFilters(bulkWithFilters: BulkWithFilters) = + bulkWithFilters.validity() + override fun visitPackage(package_: NewFloatingPackagePrice) = package_.validity() @@ -1844,6 +1863,7 @@ private constructor( unit == other.unit && tiered == other.tiered && bulk == other.bulk && + bulkWithFilters == other.bulkWithFilters && package_ == other.package_ && matrix == other.matrix && thresholdTotalAmount == other.thresholdTotalAmount && @@ -1877,6 +1897,7 @@ private constructor( unit, tiered, bulk, + bulkWithFilters, package_, matrix, thresholdTotalAmount, @@ -1910,6 +1931,7 @@ private constructor( unit != null -> "Price{unit=$unit}" tiered != null -> "Price{tiered=$tiered}" bulk != null -> "Price{bulk=$bulk}" + bulkWithFilters != null -> "Price{bulkWithFilters=$bulkWithFilters}" package_ != null -> "Price{package_=$package_}" matrix != null -> "Price{matrix=$matrix}" thresholdTotalAmount != null -> @@ -1961,6 +1983,9 @@ private constructor( fun ofBulk(bulk: NewFloatingBulkPrice) = Price(bulk = bulk) + fun ofBulkWithFilters(bulkWithFilters: BulkWithFilters) = + Price(bulkWithFilters = bulkWithFilters) + fun ofPackage(package_: NewFloatingPackagePrice) = Price(package_ = package_) fun ofMatrix(matrix: NewFloatingMatrixPrice) = Price(matrix = matrix) @@ -2060,6 +2085,8 @@ private constructor( fun visitBulk(bulk: NewFloatingBulkPrice): T + fun visitBulkWithFilters(bulkWithFilters: BulkWithFilters): T + fun visitPackage(package_: NewFloatingPackagePrice): T fun visitMatrix(matrix: NewFloatingMatrixPrice): T @@ -2174,6 +2201,11 @@ private constructor( return tryDeserialize(node, jacksonTypeRef()) ?.let { Price(bulk = it, _json = json) } ?: Price(_json = json) } + "bulk_with_filters" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(bulkWithFilters = it, _json = json) + } ?: Price(_json = json) + } "package" -> { return tryDeserialize(node, jacksonTypeRef()) ?.let { Price(package_ = it, _json = json) } ?: Price(_json = json) @@ -2386,6 +2418,8 @@ private constructor( value.unit != null -> generator.writeObject(value.unit) value.tiered != null -> generator.writeObject(value.tiered) value.bulk != null -> generator.writeObject(value.bulk) + value.bulkWithFilters != null -> + generator.writeObject(value.bulkWithFilters) value.package_ != null -> generator.writeObject(value.package_) value.matrix != null -> generator.writeObject(value.matrix) value.thresholdTotalAmount != null -> @@ -2437,6 +2471,1991 @@ private constructor( } } + class BulkWithFilters + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val bulkWithFiltersConfig: JsonField, + private val cadence: JsonField, + private val currency: JsonField, + private val itemId: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val metadata: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("bulk_with_filters_config") + @ExcludeMissing + bulkWithFiltersConfig: JsonField = JsonMissing.of(), + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + ) : this( + bulkWithFiltersConfig, + cadence, + currency, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + mutableMapOf(), + ) + + /** + * Configuration for bulk_with_filters pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun bulkWithFiltersConfig(): BulkWithFiltersConfig = + bulkWithFiltersConfig.getRequired("bulk_with_filters_config") + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * An ISO 4217 currency string for which this price is billed in. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("bulk_with_filters") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = billableMetricId.getNullable("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + invoiceGroupingKey.getNullable("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * Returns the raw JSON value of [bulkWithFiltersConfig]. + * + * Unlike [bulkWithFiltersConfig], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("bulk_with_filters_config") + @ExcludeMissing + fun _bulkWithFiltersConfig(): JsonField = + bulkWithFiltersConfig + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [BulkWithFilters]. + * + * The following fields are required: + * ```kotlin + * .bulkWithFiltersConfig() + * .cadence() + * .currency() + * .itemId() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [BulkWithFilters]. */ + class Builder internal constructor() { + + private var bulkWithFiltersConfig: JsonField? = null + private var cadence: JsonField? = null + private var currency: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonValue = JsonValue.from("bulk_with_filters") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(bulkWithFilters: BulkWithFilters) = apply { + bulkWithFiltersConfig = bulkWithFilters.bulkWithFiltersConfig + cadence = bulkWithFilters.cadence + currency = bulkWithFilters.currency + itemId = bulkWithFilters.itemId + modelType = bulkWithFilters.modelType + name = bulkWithFilters.name + billableMetricId = bulkWithFilters.billableMetricId + billedInAdvance = bulkWithFilters.billedInAdvance + billingCycleConfiguration = bulkWithFilters.billingCycleConfiguration + conversionRate = bulkWithFilters.conversionRate + conversionRateConfig = bulkWithFilters.conversionRateConfig + dimensionalPriceConfiguration = + bulkWithFilters.dimensionalPriceConfiguration + externalPriceId = bulkWithFilters.externalPriceId + fixedPriceQuantity = bulkWithFilters.fixedPriceQuantity + invoiceGroupingKey = bulkWithFilters.invoiceGroupingKey + invoicingCycleConfiguration = bulkWithFilters.invoicingCycleConfiguration + metadata = bulkWithFilters.metadata + additionalProperties = bulkWithFilters.additionalProperties.toMutableMap() + } + + /** Configuration for bulk_with_filters pricing */ + fun bulkWithFiltersConfig(bulkWithFiltersConfig: BulkWithFiltersConfig) = + bulkWithFiltersConfig(JsonField.of(bulkWithFiltersConfig)) + + /** + * Sets [Builder.bulkWithFiltersConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.bulkWithFiltersConfig] with a well-typed + * [BulkWithFiltersConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun bulkWithFiltersConfig( + bulkWithFiltersConfig: JsonField + ) = apply { this.bulkWithFiltersConfig = bulkWithFiltersConfig } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("bulk_with_filters") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BulkWithFilters]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .bulkWithFiltersConfig() + * .cadence() + * .currency() + * .itemId() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BulkWithFilters = + BulkWithFilters( + checkRequired("bulkWithFiltersConfig", bulkWithFiltersConfig), + checkRequired("cadence", cadence), + checkRequired("currency", currency), + checkRequired("itemId", itemId), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): BulkWithFilters = apply { + if (validated) { + return@apply + } + + bulkWithFiltersConfig().validate() + cadence().validate() + currency() + itemId() + _modelType().let { + if (it != JsonValue.from("bulk_with_filters")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + metadata()?.validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (bulkWithFiltersConfig.asKnown()?.validity() ?: 0) + + (cadence.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (if (itemId.asKnown() == null) 0 else 1) + + modelType.let { if (it == JsonValue.from("bulk_with_filters")) 1 else 0 } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (metadata.asKnown()?.validity() ?: 0) + + /** Configuration for bulk_with_filters pricing */ + class BulkWithFiltersConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val filters: JsonField>, + private val tiers: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("filters") + @ExcludeMissing + filters: JsonField> = JsonMissing.of(), + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of(), + ) : this(filters, tiers, mutableMapOf()) + + /** + * Property filters to apply (all must match) + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun filters(): List = filters.getRequired("filters") + + /** + * Bulk tiers for rating based on total usage volume + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun tiers(): List = tiers.getRequired("tiers") + + /** + * Returns the raw JSON value of [filters]. + * + * Unlike [filters], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("filters") + @ExcludeMissing + fun _filters(): JsonField> = filters + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [BulkWithFiltersConfig]. + * + * The following fields are required: + * ```kotlin + * .filters() + * .tiers() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [BulkWithFiltersConfig]. */ + class Builder internal constructor() { + + private var filters: JsonField>? = null + private var tiers: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(bulkWithFiltersConfig: BulkWithFiltersConfig) = apply { + filters = bulkWithFiltersConfig.filters.map { it.toMutableList() } + tiers = bulkWithFiltersConfig.tiers.map { it.toMutableList() } + additionalProperties = + bulkWithFiltersConfig.additionalProperties.toMutableMap() + } + + /** Property filters to apply (all must match) */ + fun filters(filters: List) = filters(JsonField.of(filters)) + + /** + * Sets [Builder.filters] to an arbitrary JSON value. + * + * You should usually call [Builder.filters] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun filters(filters: JsonField>) = apply { + this.filters = filters.map { it.toMutableList() } + } + + /** + * Adds a single [Filter] to [filters]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addFilter(filter: Filter) = apply { + filters = + (filters ?: JsonField.of(mutableListOf())).also { + checkKnown("filters", it).add(filter) + } + } + + /** Bulk tiers for rating based on total usage volume */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BulkWithFiltersConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .filters() + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BulkWithFiltersConfig = + BulkWithFiltersConfig( + checkRequired("filters", filters).map { it.toImmutable() }, + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): BulkWithFiltersConfig = apply { + if (validated) { + return@apply + } + + filters().forEach { it.validate() } + tiers().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (filters.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + (tiers.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single property filter */ + class Filter + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val propertyKey: JsonField, + private val propertyValue: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("property_key") + @ExcludeMissing + propertyKey: JsonField = JsonMissing.of(), + @JsonProperty("property_value") + @ExcludeMissing + propertyValue: JsonField = JsonMissing.of(), + ) : this(propertyKey, propertyValue, mutableMapOf()) + + /** + * Event property key to filter on + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun propertyKey(): String = propertyKey.getRequired("property_key") + + /** + * Event property value to match + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun propertyValue(): String = propertyValue.getRequired("property_value") + + /** + * Returns the raw JSON value of [propertyKey]. + * + * Unlike [propertyKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("property_key") + @ExcludeMissing + fun _propertyKey(): JsonField = propertyKey + + /** + * Returns the raw JSON value of [propertyValue]. + * + * Unlike [propertyValue], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("property_value") + @ExcludeMissing + fun _propertyValue(): JsonField = propertyValue + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Filter]. + * + * The following fields are required: + * ```kotlin + * .propertyKey() + * .propertyValue() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Filter]. */ + class Builder internal constructor() { + + private var propertyKey: JsonField? = null + private var propertyValue: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(filter: Filter) = apply { + propertyKey = filter.propertyKey + propertyValue = filter.propertyValue + additionalProperties = filter.additionalProperties.toMutableMap() + } + + /** Event property key to filter on */ + fun propertyKey(propertyKey: String) = + propertyKey(JsonField.of(propertyKey)) + + /** + * Sets [Builder.propertyKey] to an arbitrary JSON value. + * + * You should usually call [Builder.propertyKey] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun propertyKey(propertyKey: JsonField) = apply { + this.propertyKey = propertyKey + } + + /** Event property value to match */ + fun propertyValue(propertyValue: String) = + propertyValue(JsonField.of(propertyValue)) + + /** + * Sets [Builder.propertyValue] to an arbitrary JSON value. + * + * You should usually call [Builder.propertyValue] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun propertyValue(propertyValue: JsonField) = apply { + this.propertyValue = propertyValue + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Filter]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```kotlin + * .propertyKey() + * .propertyValue() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Filter = + Filter( + checkRequired("propertyKey", propertyKey), + checkRequired("propertyValue", propertyValue), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Filter = apply { + if (validated) { + return@apply + } + + propertyKey() + propertyValue() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (propertyKey.asKnown() == null) 0 else 1) + + (if (propertyValue.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Filter && + propertyKey == other.propertyKey && + propertyValue == other.propertyValue && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(propertyKey, propertyValue, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Filter{propertyKey=$propertyKey, propertyValue=$propertyValue, additionalProperties=$additionalProperties}" + } + + /** Configuration for a single bulk pricing tier */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val unitAmount: JsonField, + private val tierLowerBound: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + ) : this(unitAmount, tierLowerBound, mutableMapOf()) + + /** + * Amount per unit + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * The lower bound for this tier + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun tierLowerBound(): String? = + tierLowerBound.getNullable("tier_lower_bound") + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Tier]. + * + * The following fields are required: + * ```kotlin + * .unitAmount() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var unitAmount: JsonField? = null + private var tierLowerBound: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(tier: Tier) = apply { + unitAmount = tier.unitAmount + tierLowerBound = tier.tierLowerBound + additionalProperties = tier.additionalProperties.toMutableMap() + } + + /** Amount per unit */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + /** The lower bound for this tier */ + fun tierLowerBound(tierLowerBound: String?) = + tierLowerBound(JsonField.ofNullable(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```kotlin + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("unitAmount", unitAmount), + tierLowerBound, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + unitAmount() + tierLowerBound() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (unitAmount.asKnown() == null) 0 else 1) + + (if (tierLowerBound.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + unitAmount == other.unitAmount && + tierLowerBound == other.tierLowerBound && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(unitAmount, tierLowerBound, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{unitAmount=$unitAmount, tierLowerBound=$tierLowerBound, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BulkWithFiltersConfig && + filters == other.filters && + tiers == other.tiers && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(filters, tiers, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BulkWithFiltersConfig{filters=$filters, tiers=$tiers, additionalProperties=$additionalProperties}" + } + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BulkWithFilters && + bulkWithFiltersConfig == other.bulkWithFiltersConfig && + cadence == other.cadence && + currency == other.currency && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + bulkWithFiltersConfig, + cadence, + currency, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BulkWithFilters{bulkWithFiltersConfig=$bulkWithFiltersConfig, cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + } + class GroupedWithMinMaxThresholds @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceEvaluatePreviewEventsParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceEvaluatePreviewEventsParams.kt index d6363350c..7f1c3a92d 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceEvaluatePreviewEventsParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceEvaluatePreviewEventsParams.kt @@ -1547,6 +1547,10 @@ private constructor( /** Alias for calling [price] with `Price.ofBulk(bulk)`. */ fun price(bulk: NewFloatingBulkPrice) = price(Price.ofBulk(bulk)) + /** Alias for calling [price] with `Price.ofBulkWithFilters(bulkWithFilters)`. */ + fun price(bulkWithFilters: Price.BulkWithFilters) = + price(Price.ofBulkWithFilters(bulkWithFilters)) + /** Alias for calling [price] with `Price.ofPackage(package_)`. */ fun price(package_: NewFloatingPackagePrice) = price(Price.ofPackage(package_)) @@ -1777,6 +1781,7 @@ private constructor( private val unit: NewFloatingUnitPrice? = null, private val tiered: NewFloatingTieredPrice? = null, private val bulk: NewFloatingBulkPrice? = null, + private val bulkWithFilters: BulkWithFilters? = null, private val package_: NewFloatingPackagePrice? = null, private val matrix: NewFloatingMatrixPrice? = null, private val thresholdTotalAmount: NewFloatingThresholdTotalAmountPrice? = null, @@ -1818,6 +1823,8 @@ private constructor( fun bulk(): NewFloatingBulkPrice? = bulk + fun bulkWithFilters(): BulkWithFilters? = bulkWithFilters + fun package_(): NewFloatingPackagePrice? = package_ fun matrix(): NewFloatingMatrixPrice? = matrix @@ -1886,6 +1893,8 @@ private constructor( fun isBulk(): Boolean = bulk != null + fun isBulkWithFilters(): Boolean = bulkWithFilters != null + fun isPackage(): Boolean = package_ != null fun isMatrix(): Boolean = matrix != null @@ -1945,6 +1954,8 @@ private constructor( fun asBulk(): NewFloatingBulkPrice = bulk.getOrThrow("bulk") + fun asBulkWithFilters(): BulkWithFilters = bulkWithFilters.getOrThrow("bulkWithFilters") + fun asPackage(): NewFloatingPackagePrice = package_.getOrThrow("package_") fun asMatrix(): NewFloatingMatrixPrice = matrix.getOrThrow("matrix") @@ -2026,6 +2037,7 @@ private constructor( unit != null -> visitor.visitUnit(unit) tiered != null -> visitor.visitTiered(tiered) bulk != null -> visitor.visitBulk(bulk) + bulkWithFilters != null -> visitor.visitBulkWithFilters(bulkWithFilters) package_ != null -> visitor.visitPackage(package_) matrix != null -> visitor.visitMatrix(matrix) thresholdTotalAmount != null -> @@ -2092,6 +2104,10 @@ private constructor( bulk.validate() } + override fun visitBulkWithFilters(bulkWithFilters: BulkWithFilters) { + bulkWithFilters.validate() + } + override fun visitPackage(package_: NewFloatingPackagePrice) { package_.validate() } @@ -2267,6 +2283,9 @@ private constructor( override fun visitBulk(bulk: NewFloatingBulkPrice) = bulk.validity() + override fun visitBulkWithFilters(bulkWithFilters: BulkWithFilters) = + bulkWithFilters.validity() + override fun visitPackage(package_: NewFloatingPackagePrice) = package_.validity() @@ -2379,6 +2398,7 @@ private constructor( unit == other.unit && tiered == other.tiered && bulk == other.bulk && + bulkWithFilters == other.bulkWithFilters && package_ == other.package_ && matrix == other.matrix && thresholdTotalAmount == other.thresholdTotalAmount && @@ -2412,6 +2432,7 @@ private constructor( unit, tiered, bulk, + bulkWithFilters, package_, matrix, thresholdTotalAmount, @@ -2445,6 +2466,7 @@ private constructor( unit != null -> "Price{unit=$unit}" tiered != null -> "Price{tiered=$tiered}" bulk != null -> "Price{bulk=$bulk}" + bulkWithFilters != null -> "Price{bulkWithFilters=$bulkWithFilters}" package_ != null -> "Price{package_=$package_}" matrix != null -> "Price{matrix=$matrix}" thresholdTotalAmount != null -> @@ -2496,6 +2518,9 @@ private constructor( fun ofBulk(bulk: NewFloatingBulkPrice) = Price(bulk = bulk) + fun ofBulkWithFilters(bulkWithFilters: BulkWithFilters) = + Price(bulkWithFilters = bulkWithFilters) + fun ofPackage(package_: NewFloatingPackagePrice) = Price(package_ = package_) fun ofMatrix(matrix: NewFloatingMatrixPrice) = Price(matrix = matrix) @@ -2595,6 +2620,8 @@ private constructor( fun visitBulk(bulk: NewFloatingBulkPrice): T + fun visitBulkWithFilters(bulkWithFilters: BulkWithFilters): T + fun visitPackage(package_: NewFloatingPackagePrice): T fun visitMatrix(matrix: NewFloatingMatrixPrice): T @@ -2709,6 +2736,11 @@ private constructor( return tryDeserialize(node, jacksonTypeRef()) ?.let { Price(bulk = it, _json = json) } ?: Price(_json = json) } + "bulk_with_filters" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(bulkWithFilters = it, _json = json) + } ?: Price(_json = json) + } "package" -> { return tryDeserialize(node, jacksonTypeRef()) ?.let { Price(package_ = it, _json = json) } ?: Price(_json = json) @@ -2921,6 +2953,8 @@ private constructor( value.unit != null -> generator.writeObject(value.unit) value.tiered != null -> generator.writeObject(value.tiered) value.bulk != null -> generator.writeObject(value.bulk) + value.bulkWithFilters != null -> + generator.writeObject(value.bulkWithFilters) value.package_ != null -> generator.writeObject(value.package_) value.matrix != null -> generator.writeObject(value.matrix) value.thresholdTotalAmount != null -> @@ -2972,6 +3006,1991 @@ private constructor( } } + class BulkWithFilters + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val bulkWithFiltersConfig: JsonField, + private val cadence: JsonField, + private val currency: JsonField, + private val itemId: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val metadata: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("bulk_with_filters_config") + @ExcludeMissing + bulkWithFiltersConfig: JsonField = JsonMissing.of(), + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + ) : this( + bulkWithFiltersConfig, + cadence, + currency, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + mutableMapOf(), + ) + + /** + * Configuration for bulk_with_filters pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun bulkWithFiltersConfig(): BulkWithFiltersConfig = + bulkWithFiltersConfig.getRequired("bulk_with_filters_config") + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * An ISO 4217 currency string for which this price is billed in. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("bulk_with_filters") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = billableMetricId.getNullable("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + invoiceGroupingKey.getNullable("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * Returns the raw JSON value of [bulkWithFiltersConfig]. + * + * Unlike [bulkWithFiltersConfig], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("bulk_with_filters_config") + @ExcludeMissing + fun _bulkWithFiltersConfig(): JsonField = + bulkWithFiltersConfig + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [BulkWithFilters]. + * + * The following fields are required: + * ```kotlin + * .bulkWithFiltersConfig() + * .cadence() + * .currency() + * .itemId() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [BulkWithFilters]. */ + class Builder internal constructor() { + + private var bulkWithFiltersConfig: JsonField? = null + private var cadence: JsonField? = null + private var currency: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonValue = JsonValue.from("bulk_with_filters") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(bulkWithFilters: BulkWithFilters) = apply { + bulkWithFiltersConfig = bulkWithFilters.bulkWithFiltersConfig + cadence = bulkWithFilters.cadence + currency = bulkWithFilters.currency + itemId = bulkWithFilters.itemId + modelType = bulkWithFilters.modelType + name = bulkWithFilters.name + billableMetricId = bulkWithFilters.billableMetricId + billedInAdvance = bulkWithFilters.billedInAdvance + billingCycleConfiguration = bulkWithFilters.billingCycleConfiguration + conversionRate = bulkWithFilters.conversionRate + conversionRateConfig = bulkWithFilters.conversionRateConfig + dimensionalPriceConfiguration = + bulkWithFilters.dimensionalPriceConfiguration + externalPriceId = bulkWithFilters.externalPriceId + fixedPriceQuantity = bulkWithFilters.fixedPriceQuantity + invoiceGroupingKey = bulkWithFilters.invoiceGroupingKey + invoicingCycleConfiguration = bulkWithFilters.invoicingCycleConfiguration + metadata = bulkWithFilters.metadata + additionalProperties = bulkWithFilters.additionalProperties.toMutableMap() + } + + /** Configuration for bulk_with_filters pricing */ + fun bulkWithFiltersConfig(bulkWithFiltersConfig: BulkWithFiltersConfig) = + bulkWithFiltersConfig(JsonField.of(bulkWithFiltersConfig)) + + /** + * Sets [Builder.bulkWithFiltersConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.bulkWithFiltersConfig] with a well-typed + * [BulkWithFiltersConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun bulkWithFiltersConfig( + bulkWithFiltersConfig: JsonField + ) = apply { this.bulkWithFiltersConfig = bulkWithFiltersConfig } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("bulk_with_filters") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BulkWithFilters]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .bulkWithFiltersConfig() + * .cadence() + * .currency() + * .itemId() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BulkWithFilters = + BulkWithFilters( + checkRequired("bulkWithFiltersConfig", bulkWithFiltersConfig), + checkRequired("cadence", cadence), + checkRequired("currency", currency), + checkRequired("itemId", itemId), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): BulkWithFilters = apply { + if (validated) { + return@apply + } + + bulkWithFiltersConfig().validate() + cadence().validate() + currency() + itemId() + _modelType().let { + if (it != JsonValue.from("bulk_with_filters")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + metadata()?.validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (bulkWithFiltersConfig.asKnown()?.validity() ?: 0) + + (cadence.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (if (itemId.asKnown() == null) 0 else 1) + + modelType.let { if (it == JsonValue.from("bulk_with_filters")) 1 else 0 } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (metadata.asKnown()?.validity() ?: 0) + + /** Configuration for bulk_with_filters pricing */ + class BulkWithFiltersConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val filters: JsonField>, + private val tiers: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("filters") + @ExcludeMissing + filters: JsonField> = JsonMissing.of(), + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of(), + ) : this(filters, tiers, mutableMapOf()) + + /** + * Property filters to apply (all must match) + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun filters(): List = filters.getRequired("filters") + + /** + * Bulk tiers for rating based on total usage volume + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun tiers(): List = tiers.getRequired("tiers") + + /** + * Returns the raw JSON value of [filters]. + * + * Unlike [filters], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("filters") + @ExcludeMissing + fun _filters(): JsonField> = filters + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [BulkWithFiltersConfig]. + * + * The following fields are required: + * ```kotlin + * .filters() + * .tiers() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [BulkWithFiltersConfig]. */ + class Builder internal constructor() { + + private var filters: JsonField>? = null + private var tiers: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(bulkWithFiltersConfig: BulkWithFiltersConfig) = apply { + filters = bulkWithFiltersConfig.filters.map { it.toMutableList() } + tiers = bulkWithFiltersConfig.tiers.map { it.toMutableList() } + additionalProperties = + bulkWithFiltersConfig.additionalProperties.toMutableMap() + } + + /** Property filters to apply (all must match) */ + fun filters(filters: List) = filters(JsonField.of(filters)) + + /** + * Sets [Builder.filters] to an arbitrary JSON value. + * + * You should usually call [Builder.filters] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun filters(filters: JsonField>) = apply { + this.filters = filters.map { it.toMutableList() } + } + + /** + * Adds a single [Filter] to [filters]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addFilter(filter: Filter) = apply { + filters = + (filters ?: JsonField.of(mutableListOf())).also { + checkKnown("filters", it).add(filter) + } + } + + /** Bulk tiers for rating based on total usage volume */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BulkWithFiltersConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .filters() + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BulkWithFiltersConfig = + BulkWithFiltersConfig( + checkRequired("filters", filters).map { it.toImmutable() }, + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): BulkWithFiltersConfig = apply { + if (validated) { + return@apply + } + + filters().forEach { it.validate() } + tiers().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (filters.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + (tiers.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single property filter */ + class Filter + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val propertyKey: JsonField, + private val propertyValue: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("property_key") + @ExcludeMissing + propertyKey: JsonField = JsonMissing.of(), + @JsonProperty("property_value") + @ExcludeMissing + propertyValue: JsonField = JsonMissing.of(), + ) : this(propertyKey, propertyValue, mutableMapOf()) + + /** + * Event property key to filter on + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun propertyKey(): String = propertyKey.getRequired("property_key") + + /** + * Event property value to match + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun propertyValue(): String = propertyValue.getRequired("property_value") + + /** + * Returns the raw JSON value of [propertyKey]. + * + * Unlike [propertyKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("property_key") + @ExcludeMissing + fun _propertyKey(): JsonField = propertyKey + + /** + * Returns the raw JSON value of [propertyValue]. + * + * Unlike [propertyValue], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("property_value") + @ExcludeMissing + fun _propertyValue(): JsonField = propertyValue + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Filter]. + * + * The following fields are required: + * ```kotlin + * .propertyKey() + * .propertyValue() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Filter]. */ + class Builder internal constructor() { + + private var propertyKey: JsonField? = null + private var propertyValue: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(filter: Filter) = apply { + propertyKey = filter.propertyKey + propertyValue = filter.propertyValue + additionalProperties = filter.additionalProperties.toMutableMap() + } + + /** Event property key to filter on */ + fun propertyKey(propertyKey: String) = + propertyKey(JsonField.of(propertyKey)) + + /** + * Sets [Builder.propertyKey] to an arbitrary JSON value. + * + * You should usually call [Builder.propertyKey] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun propertyKey(propertyKey: JsonField) = apply { + this.propertyKey = propertyKey + } + + /** Event property value to match */ + fun propertyValue(propertyValue: String) = + propertyValue(JsonField.of(propertyValue)) + + /** + * Sets [Builder.propertyValue] to an arbitrary JSON value. + * + * You should usually call [Builder.propertyValue] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun propertyValue(propertyValue: JsonField) = apply { + this.propertyValue = propertyValue + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Filter]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```kotlin + * .propertyKey() + * .propertyValue() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Filter = + Filter( + checkRequired("propertyKey", propertyKey), + checkRequired("propertyValue", propertyValue), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Filter = apply { + if (validated) { + return@apply + } + + propertyKey() + propertyValue() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (propertyKey.asKnown() == null) 0 else 1) + + (if (propertyValue.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Filter && + propertyKey == other.propertyKey && + propertyValue == other.propertyValue && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(propertyKey, propertyValue, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Filter{propertyKey=$propertyKey, propertyValue=$propertyValue, additionalProperties=$additionalProperties}" + } + + /** Configuration for a single bulk pricing tier */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val unitAmount: JsonField, + private val tierLowerBound: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + ) : this(unitAmount, tierLowerBound, mutableMapOf()) + + /** + * Amount per unit + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * The lower bound for this tier + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun tierLowerBound(): String? = + tierLowerBound.getNullable("tier_lower_bound") + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Tier]. + * + * The following fields are required: + * ```kotlin + * .unitAmount() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var unitAmount: JsonField? = null + private var tierLowerBound: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(tier: Tier) = apply { + unitAmount = tier.unitAmount + tierLowerBound = tier.tierLowerBound + additionalProperties = tier.additionalProperties.toMutableMap() + } + + /** Amount per unit */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + /** The lower bound for this tier */ + fun tierLowerBound(tierLowerBound: String?) = + tierLowerBound(JsonField.ofNullable(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```kotlin + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("unitAmount", unitAmount), + tierLowerBound, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + unitAmount() + tierLowerBound() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (unitAmount.asKnown() == null) 0 else 1) + + (if (tierLowerBound.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + unitAmount == other.unitAmount && + tierLowerBound == other.tierLowerBound && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(unitAmount, tierLowerBound, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{unitAmount=$unitAmount, tierLowerBound=$tierLowerBound, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BulkWithFiltersConfig && + filters == other.filters && + tiers == other.tiers && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(filters, tiers, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BulkWithFiltersConfig{filters=$filters, tiers=$tiers, additionalProperties=$additionalProperties}" + } + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BulkWithFilters && + bulkWithFiltersConfig == other.bulkWithFiltersConfig && + cadence == other.cadence && + currency == other.currency && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + bulkWithFiltersConfig, + cadence, + currency, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BulkWithFilters{bulkWithFiltersConfig=$bulkWithFiltersConfig, cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + } + class GroupedWithMinMaxThresholds @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceInterval.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceInterval.kt index ade43a3ef..8a59b1aaa 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceInterval.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceInterval.kt @@ -484,6 +484,10 @@ private constructor( /** Alias for calling [price] with `Price.ofBulk(bulk)`. */ fun price(bulk: Price.Bulk) = price(Price.ofBulk(bulk)) + /** Alias for calling [price] with `Price.ofBulkWithFilters(bulkWithFilters)`. */ + fun price(bulkWithFilters: Price.BulkWithFilters) = + price(Price.ofBulkWithFilters(bulkWithFilters)) + /** Alias for calling [price] with `Price.ofPackage(package_)`. */ fun price(package_: Price.Package) = price(Price.ofPackage(package_)) diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceListPageResponse.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceListPageResponse.kt index 6148f8988..fb46b3a20 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceListPageResponse.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceListPageResponse.kt @@ -136,6 +136,10 @@ private constructor( /** Alias for calling [addData] with `Price.ofBulk(bulk)`. */ fun addData(bulk: Price.Bulk) = addData(Price.ofBulk(bulk)) + /** Alias for calling [addData] with `Price.ofBulkWithFilters(bulkWithFilters)`. */ + fun addData(bulkWithFilters: Price.BulkWithFilters) = + addData(Price.ofBulkWithFilters(bulkWithFilters)) + /** Alias for calling [addData] with `Price.ofPackage(package_)`. */ fun addData(package_: Price.Package) = addData(Price.ofPackage(package_)) diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionCreateParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionCreateParams.kt index 4f8d53f8a..0fa37067a 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionCreateParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionCreateParams.kt @@ -4564,6 +4564,10 @@ private constructor( /** Alias for calling [price] with `Price.ofBulk(bulk)`. */ fun price(bulk: NewSubscriptionBulkPrice) = price(Price.ofBulk(bulk)) + /** Alias for calling [price] with `Price.ofBulkWithFilters(bulkWithFilters)`. */ + fun price(bulkWithFilters: Price.BulkWithFilters) = + price(Price.ofBulkWithFilters(bulkWithFilters)) + /** Alias for calling [price] with `Price.ofPackage(package_)`. */ fun price(package_: NewSubscriptionPackagePrice) = price(Price.ofPackage(package_)) @@ -4828,6 +4832,7 @@ private constructor( private val unit: NewSubscriptionUnitPrice? = null, private val tiered: NewSubscriptionTieredPrice? = null, private val bulk: NewSubscriptionBulkPrice? = null, + private val bulkWithFilters: BulkWithFilters? = null, private val package_: NewSubscriptionPackagePrice? = null, private val matrix: NewSubscriptionMatrixPrice? = null, private val thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice? = null, @@ -4871,6 +4876,8 @@ private constructor( fun bulk(): NewSubscriptionBulkPrice? = bulk + fun bulkWithFilters(): BulkWithFilters? = bulkWithFilters + fun package_(): NewSubscriptionPackagePrice? = package_ fun matrix(): NewSubscriptionMatrixPrice? = matrix @@ -4943,6 +4950,8 @@ private constructor( fun isBulk(): Boolean = bulk != null + fun isBulkWithFilters(): Boolean = bulkWithFilters != null + fun isPackage(): Boolean = package_ != null fun isMatrix(): Boolean = matrix != null @@ -5002,6 +5011,8 @@ private constructor( fun asBulk(): NewSubscriptionBulkPrice = bulk.getOrThrow("bulk") + fun asBulkWithFilters(): BulkWithFilters = bulkWithFilters.getOrThrow("bulkWithFilters") + fun asPackage(): NewSubscriptionPackagePrice = package_.getOrThrow("package_") fun asMatrix(): NewSubscriptionMatrixPrice = matrix.getOrThrow("matrix") @@ -5084,6 +5095,7 @@ private constructor( unit != null -> visitor.visitUnit(unit) tiered != null -> visitor.visitTiered(tiered) bulk != null -> visitor.visitBulk(bulk) + bulkWithFilters != null -> visitor.visitBulkWithFilters(bulkWithFilters) package_ != null -> visitor.visitPackage(package_) matrix != null -> visitor.visitMatrix(matrix) thresholdTotalAmount != null -> @@ -5150,6 +5162,10 @@ private constructor( bulk.validate() } + override fun visitBulkWithFilters(bulkWithFilters: BulkWithFilters) { + bulkWithFilters.validate() + } + override fun visitPackage(package_: NewSubscriptionPackagePrice) { package_.validate() } @@ -5327,6 +5343,9 @@ private constructor( override fun visitBulk(bulk: NewSubscriptionBulkPrice) = bulk.validity() + override fun visitBulkWithFilters(bulkWithFilters: BulkWithFilters) = + bulkWithFilters.validity() + override fun visitPackage(package_: NewSubscriptionPackagePrice) = package_.validity() @@ -5441,6 +5460,7 @@ private constructor( unit == other.unit && tiered == other.tiered && bulk == other.bulk && + bulkWithFilters == other.bulkWithFilters && package_ == other.package_ && matrix == other.matrix && thresholdTotalAmount == other.thresholdTotalAmount && @@ -5474,6 +5494,7 @@ private constructor( unit, tiered, bulk, + bulkWithFilters, package_, matrix, thresholdTotalAmount, @@ -5507,6 +5528,7 @@ private constructor( unit != null -> "Price{unit=$unit}" tiered != null -> "Price{tiered=$tiered}" bulk != null -> "Price{bulk=$bulk}" + bulkWithFilters != null -> "Price{bulkWithFilters=$bulkWithFilters}" package_ != null -> "Price{package_=$package_}" matrix != null -> "Price{matrix=$matrix}" thresholdTotalAmount != null -> @@ -5558,6 +5580,9 @@ private constructor( fun ofBulk(bulk: NewSubscriptionBulkPrice) = Price(bulk = bulk) + fun ofBulkWithFilters(bulkWithFilters: BulkWithFilters) = + Price(bulkWithFilters = bulkWithFilters) + fun ofPackage(package_: NewSubscriptionPackagePrice) = Price(package_ = package_) fun ofMatrix(matrix: NewSubscriptionMatrixPrice) = Price(matrix = matrix) @@ -5658,6 +5683,8 @@ private constructor( fun visitBulk(bulk: NewSubscriptionBulkPrice): T + fun visitBulkWithFilters(bulkWithFilters: BulkWithFilters): T + fun visitPackage(package_: NewSubscriptionPackagePrice): T fun visitMatrix(matrix: NewSubscriptionMatrixPrice): T @@ -5782,6 +5809,11 @@ private constructor( return tryDeserialize(node, jacksonTypeRef()) ?.let { Price(bulk = it, _json = json) } ?: Price(_json = json) } + "bulk_with_filters" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(bulkWithFilters = it, _json = json) + } ?: Price(_json = json) + } "package" -> { return tryDeserialize( node, @@ -5999,6 +6031,8 @@ private constructor( value.unit != null -> generator.writeObject(value.unit) value.tiered != null -> generator.writeObject(value.tiered) value.bulk != null -> generator.writeObject(value.bulk) + value.bulkWithFilters != null -> + generator.writeObject(value.bulkWithFilters) value.package_ != null -> generator.writeObject(value.package_) value.matrix != null -> generator.writeObject(value.matrix) value.thresholdTotalAmount != null -> @@ -6050,14 +6084,14 @@ private constructor( } } - class TieredWithProration + class BulkWithFilters @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( + private val bulkWithFiltersConfig: JsonField, private val cadence: JsonField, private val itemId: JsonField, private val modelType: JsonValue, private val name: JsonField, - private val tieredWithProrationConfig: JsonField, private val billableMetricId: JsonField, private val billedInAdvance: JsonField, private val billingCycleConfiguration: JsonField, @@ -6077,6 +6111,9 @@ private constructor( @JsonCreator private constructor( + @JsonProperty("bulk_with_filters_config") + @ExcludeMissing + bulkWithFiltersConfig: JsonField = JsonMissing.of(), @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), @@ -6089,10 +6126,6 @@ private constructor( @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("tiered_with_proration_config") - @ExcludeMissing - tieredWithProrationConfig: JsonField = - JsonMissing.of(), @JsonProperty("billable_metric_id") @ExcludeMissing billableMetricId: JsonField = JsonMissing.of(), @@ -6136,11 +6169,11 @@ private constructor( @ExcludeMissing referenceId: JsonField = JsonMissing.of(), ) : this( + bulkWithFiltersConfig, cadence, itemId, modelType, name, - tieredWithProrationConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -6157,6 +6190,16 @@ private constructor( mutableMapOf(), ) + /** + * Configuration for bulk_with_filters pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun bulkWithFiltersConfig(): BulkWithFiltersConfig = + bulkWithFiltersConfig.getRequired("bulk_with_filters_config") + /** * The cadence to bill for this price on. * @@ -6180,7 +6223,7 @@ private constructor( * * Expected to always return the following: * ```kotlin - * JsonValue.from("tiered_with_proration") + * JsonValue.from("bulk_with_filters") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -6197,16 +6240,6 @@ private constructor( */ fun name(): String = name.getRequired("name") - /** - * Configuration for tiered_with_proration pricing - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun tieredWithProrationConfig(): TieredWithProrationConfig = - tieredWithProrationConfig.getRequired("tiered_with_proration_config") - /** * The id of the billable metric for the price. Only needed if the price is * usage-based. @@ -6326,6 +6359,17 @@ private constructor( */ fun referenceId(): String? = referenceId.getNullable("reference_id") + /** + * Returns the raw JSON value of [bulkWithFiltersConfig]. + * + * Unlike [bulkWithFiltersConfig], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("bulk_with_filters_config") + @ExcludeMissing + fun _bulkWithFiltersConfig(): JsonField = + bulkWithFiltersConfig + /** * Returns the raw JSON value of [cadence]. * @@ -6352,17 +6396,6 @@ private constructor( */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - /** - * Returns the raw JSON value of [tieredWithProrationConfig]. - * - * Unlike [tieredWithProrationConfig], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("tiered_with_proration_config") - @ExcludeMissing - fun _tieredWithProrationConfig(): JsonField = - tieredWithProrationConfig - /** * Returns the raw JSON value of [billableMetricId]. * @@ -6511,29 +6544,27 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [TieredWithProration]. + * Returns a mutable builder for constructing an instance of [BulkWithFilters]. * * The following fields are required: * ```kotlin + * .bulkWithFiltersConfig() * .cadence() * .itemId() * .name() - * .tieredWithProrationConfig() * ``` */ fun builder() = Builder() } - /** A builder for [TieredWithProration]. */ + /** A builder for [BulkWithFilters]. */ class Builder internal constructor() { + private var bulkWithFiltersConfig: JsonField? = null private var cadence: JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonValue = JsonValue.from("tiered_with_proration") + private var modelType: JsonValue = JsonValue.from("bulk_with_filters") private var name: JsonField? = null - private var tieredWithProrationConfig: JsonField? = - null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() private var billingCycleConfiguration: JsonField = @@ -6555,31 +6586,44 @@ private constructor( private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(tieredWithProration: TieredWithProration) = apply { - cadence = tieredWithProration.cadence - itemId = tieredWithProration.itemId - modelType = tieredWithProration.modelType - name = tieredWithProration.name - tieredWithProrationConfig = tieredWithProration.tieredWithProrationConfig - billableMetricId = tieredWithProration.billableMetricId - billedInAdvance = tieredWithProration.billedInAdvance - billingCycleConfiguration = tieredWithProration.billingCycleConfiguration - conversionRate = tieredWithProration.conversionRate - conversionRateConfig = tieredWithProration.conversionRateConfig - currency = tieredWithProration.currency + internal fun from(bulkWithFilters: BulkWithFilters) = apply { + bulkWithFiltersConfig = bulkWithFilters.bulkWithFiltersConfig + cadence = bulkWithFilters.cadence + itemId = bulkWithFilters.itemId + modelType = bulkWithFilters.modelType + name = bulkWithFilters.name + billableMetricId = bulkWithFilters.billableMetricId + billedInAdvance = bulkWithFilters.billedInAdvance + billingCycleConfiguration = bulkWithFilters.billingCycleConfiguration + conversionRate = bulkWithFilters.conversionRate + conversionRateConfig = bulkWithFilters.conversionRateConfig + currency = bulkWithFilters.currency dimensionalPriceConfiguration = - tieredWithProration.dimensionalPriceConfiguration - externalPriceId = tieredWithProration.externalPriceId - fixedPriceQuantity = tieredWithProration.fixedPriceQuantity - invoiceGroupingKey = tieredWithProration.invoiceGroupingKey - invoicingCycleConfiguration = - tieredWithProration.invoicingCycleConfiguration - metadata = tieredWithProration.metadata - referenceId = tieredWithProration.referenceId - additionalProperties = - tieredWithProration.additionalProperties.toMutableMap() + bulkWithFilters.dimensionalPriceConfiguration + externalPriceId = bulkWithFilters.externalPriceId + fixedPriceQuantity = bulkWithFilters.fixedPriceQuantity + invoiceGroupingKey = bulkWithFilters.invoiceGroupingKey + invoicingCycleConfiguration = bulkWithFilters.invoicingCycleConfiguration + metadata = bulkWithFilters.metadata + referenceId = bulkWithFilters.referenceId + additionalProperties = bulkWithFilters.additionalProperties.toMutableMap() } + /** Configuration for bulk_with_filters pricing */ + fun bulkWithFiltersConfig(bulkWithFiltersConfig: BulkWithFiltersConfig) = + bulkWithFiltersConfig(JsonField.of(bulkWithFiltersConfig)) + + /** + * Sets [Builder.bulkWithFiltersConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.bulkWithFiltersConfig] with a well-typed + * [BulkWithFiltersConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun bulkWithFiltersConfig( + bulkWithFiltersConfig: JsonField + ) = apply { this.bulkWithFiltersConfig = bulkWithFiltersConfig } + /** The cadence to bill for this price on. */ fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) @@ -6610,7 +6654,7 @@ private constructor( * It is usually unnecessary to call this method because the field defaults to * the following: * ```kotlin - * JsonValue.from("tiered_with_proration") + * JsonValue.from("bulk_with_filters") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -6630,22 +6674,6 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } - /** Configuration for tiered_with_proration pricing */ - fun tieredWithProrationConfig( - tieredWithProrationConfig: TieredWithProrationConfig - ) = tieredWithProrationConfig(JsonField.of(tieredWithProrationConfig)) - - /** - * Sets [Builder.tieredWithProrationConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.tieredWithProrationConfig] with a well-typed - * [TieredWithProrationConfig] value instead. This method is primarily for - * setting the field to an undocumented or not yet supported value. - */ - fun tieredWithProrationConfig( - tieredWithProrationConfig: JsonField - ) = apply { this.tieredWithProrationConfig = tieredWithProrationConfig } - /** * The id of the billable metric for the price. Only needed if the price is * usage-based. @@ -6975,27 +7003,27 @@ private constructor( } /** - * Returns an immutable instance of [TieredWithProration]. + * Returns an immutable instance of [BulkWithFilters]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```kotlin + * .bulkWithFiltersConfig() * .cadence() * .itemId() * .name() - * .tieredWithProrationConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): TieredWithProration = - TieredWithProration( + fun build(): BulkWithFilters = + BulkWithFilters( + checkRequired("bulkWithFiltersConfig", bulkWithFiltersConfig), checkRequired("cadence", cadence), checkRequired("itemId", itemId), modelType, checkRequired("name", name), - checkRequired("tieredWithProrationConfig", tieredWithProrationConfig), billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -7015,20 +7043,20 @@ private constructor( private var validated: Boolean = false - fun validate(): TieredWithProration = apply { + fun validate(): BulkWithFilters = apply { if (validated) { return@apply } + bulkWithFiltersConfig().validate() cadence().validate() itemId() _modelType().let { - if (it != JsonValue.from("tiered_with_proration")) { + if (it != JsonValue.from("bulk_with_filters")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } name() - tieredWithProrationConfig().validate() billableMetricId() billedInAdvance() billingCycleConfiguration()?.validate() @@ -7060,13 +7088,11 @@ private constructor( * Used for best match union deserialization. */ internal fun validity(): Int = - (cadence.asKnown()?.validity() ?: 0) + + (bulkWithFiltersConfig.asKnown()?.validity() ?: 0) + + (cadence.asKnown()?.validity() ?: 0) + (if (itemId.asKnown() == null) 0 else 1) + - modelType.let { - if (it == JsonValue.from("tiered_with_proration")) 1 else 0 - } + + modelType.let { if (it == JsonValue.from("bulk_with_filters")) 1 else 0 } + (if (name.asKnown() == null) 0 else 1) + - (tieredWithProrationConfig.asKnown()?.validity() ?: 0) + (if (billableMetricId.asKnown() == null) 0 else 1) + (if (billedInAdvance.asKnown() == null) 0 else 1) + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + @@ -7081,201 +7107,66 @@ private constructor( (metadata.asKnown()?.validity() ?: 0) + (if (referenceId.asKnown() == null) 0 else 1) - /** The cadence to bill for this price on. */ - class Cadence - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - val ANNUAL = of("annual") - - val SEMI_ANNUAL = of("semi_annual") - - val MONTHLY = of("monthly") - - val QUARTERLY = of("quarterly") - - val ONE_TIME = of("one_time") - - val CUSTOM = of("custom") - - fun of(value: String) = Cadence(JsonField.of(value)) - } + /** Configuration for bulk_with_filters pricing */ + class BulkWithFiltersConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val filters: JsonField>, + private val tiers: JsonField>, + private val additionalProperties: MutableMap, + ) { - /** An enum containing [Cadence]'s known values. */ - enum class Known { - ANNUAL, - SEMI_ANNUAL, - MONTHLY, - QUARTERLY, - ONE_TIME, - CUSTOM, - } + @JsonCreator + private constructor( + @JsonProperty("filters") + @ExcludeMissing + filters: JsonField> = JsonMissing.of(), + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of(), + ) : this(filters, tiers, mutableMapOf()) /** - * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * Property filters to apply (all must match) * - * An instance of [Cadence] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). */ - enum class Value { - ANNUAL, - SEMI_ANNUAL, - MONTHLY, - QUARTERLY, - ONE_TIME, - CUSTOM, - /** - * An enum member indicating that [Cadence] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } + fun filters(): List = filters.getRequired("filters") /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * Bulk tiers for rating based on total usage volume * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). */ - fun value(): Value = - when (this) { - ANNUAL -> Value.ANNUAL - SEMI_ANNUAL -> Value.SEMI_ANNUAL - MONTHLY -> Value.MONTHLY - QUARTERLY -> Value.QUARTERLY - ONE_TIME -> Value.ONE_TIME - CUSTOM -> Value.CUSTOM - else -> Value._UNKNOWN - } + fun tiers(): List = tiers.getRequired("tiers") /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. + * Returns the raw JSON value of [filters]. * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. + * Unlike [filters], this method doesn't throw if the JSON field has an + * unexpected type. */ - fun known(): Known = - when (this) { - ANNUAL -> Known.ANNUAL - SEMI_ANNUAL -> Known.SEMI_ANNUAL - MONTHLY -> Known.MONTHLY - QUARTERLY -> Known.QUARTERLY - ONE_TIME -> Known.ONE_TIME - CUSTOM -> Known.CUSTOM - else -> throw OrbInvalidDataException("Unknown Cadence: $value") - } + @JsonProperty("filters") + @ExcludeMissing + fun _filters(): JsonField> = filters /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. + * Returns the raw JSON value of [tiers]. * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. */ - fun asString(): String = - _value().asString() - ?: throw OrbInvalidDataException("Value is not a String") - - private var validated: Boolean = false - - fun validate(): Cadence = apply { - if (validated) { - return@apply - } + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Cadence && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** Configuration for tiered_with_proration pricing */ - class TieredWithProrationConfig - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val tiers: JsonField>, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("tiers") - @ExcludeMissing - tiers: JsonField> = JsonMissing.of() - ) : this(tiers, mutableMapOf()) - - /** - * Tiers for rating based on total usage quantities into the specified tier with - * proration - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun tiers(): List = tiers.getRequired("tiers") - - /** - * Returns the raw JSON value of [tiers]. - * - * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("tiers") - @ExcludeMissing - fun _tiers(): JsonField> = tiers - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) } @JsonAnyGetter @@ -7289,34 +7180,60 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [TieredWithProrationConfig]. + * [BulkWithFiltersConfig]. * * The following fields are required: * ```kotlin + * .filters() * .tiers() * ``` */ fun builder() = Builder() } - /** A builder for [TieredWithProrationConfig]. */ + /** A builder for [BulkWithFiltersConfig]. */ class Builder internal constructor() { + private var filters: JsonField>? = null private var tiers: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(tieredWithProrationConfig: TieredWithProrationConfig) = - apply { - tiers = tieredWithProrationConfig.tiers.map { it.toMutableList() } - additionalProperties = - tieredWithProrationConfig.additionalProperties.toMutableMap() - } + internal fun from(bulkWithFiltersConfig: BulkWithFiltersConfig) = apply { + filters = bulkWithFiltersConfig.filters.map { it.toMutableList() } + tiers = bulkWithFiltersConfig.tiers.map { it.toMutableList() } + additionalProperties = + bulkWithFiltersConfig.additionalProperties.toMutableMap() + } + + /** Property filters to apply (all must match) */ + fun filters(filters: List) = filters(JsonField.of(filters)) /** - * Tiers for rating based on total usage quantities into the specified tier - * with proration + * Sets [Builder.filters] to an arbitrary JSON value. + * + * You should usually call [Builder.filters] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun filters(filters: JsonField>) = apply { + this.filters = filters.map { it.toMutableList() } + } + + /** + * Adds a single [Filter] to [filters]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. */ + fun addFilter(filter: Filter) = apply { + filters = + (filters ?: JsonField.of(mutableListOf())).also { + checkKnown("filters", it).add(filter) + } + } + + /** Bulk tiers for rating based on total usage volume */ fun tiers(tiers: List) = tiers(JsonField.of(tiers)) /** @@ -7366,19 +7283,21 @@ private constructor( } /** - * Returns an immutable instance of [TieredWithProrationConfig]. + * Returns an immutable instance of [BulkWithFiltersConfig]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```kotlin + * .filters() * .tiers() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): TieredWithProrationConfig = - TieredWithProrationConfig( + fun build(): BulkWithFiltersConfig = + BulkWithFiltersConfig( + checkRequired("filters", filters).map { it.toImmutable() }, checkRequired("tiers", tiers).map { it.toImmutable() }, additionalProperties.toMutableMap(), ) @@ -7386,11 +7305,12 @@ private constructor( private var validated: Boolean = false - fun validate(): TieredWithProrationConfig = apply { + fun validate(): BulkWithFiltersConfig = apply { if (validated) { return@apply } + filters().forEach { it.validate() } tiers().forEach { it.validate() } validated = true } @@ -7410,65 +7330,65 @@ private constructor( * Used for best match union deserialization. */ internal fun validity(): Int = - (tiers.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + (filters.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + (tiers.asKnown()?.sumOf { it.validity().toInt() } ?: 0) - /** Configuration for a single tiered with proration tier */ - class Tier + /** Configuration for a single property filter */ + class Filter @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val tierLowerBound: JsonField, - private val unitAmount: JsonField, + private val propertyKey: JsonField, + private val propertyValue: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("tier_lower_bound") + @JsonProperty("property_key") @ExcludeMissing - tierLowerBound: JsonField = JsonMissing.of(), - @JsonProperty("unit_amount") + propertyKey: JsonField = JsonMissing.of(), + @JsonProperty("property_value") @ExcludeMissing - unitAmount: JsonField = JsonMissing.of(), - ) : this(tierLowerBound, unitAmount, mutableMapOf()) + propertyValue: JsonField = JsonMissing.of(), + ) : this(propertyKey, propertyValue, mutableMapOf()) /** - * Inclusive tier starting value + * Event property key to filter on * * @throws OrbInvalidDataException if the JSON field has an unexpected type * or is unexpectedly missing or null (e.g. if the server responded with * an unexpected value). */ - fun tierLowerBound(): String = - tierLowerBound.getRequired("tier_lower_bound") + fun propertyKey(): String = propertyKey.getRequired("property_key") /** - * Amount per unit + * Event property value to match * * @throws OrbInvalidDataException if the JSON field has an unexpected type * or is unexpectedly missing or null (e.g. if the server responded with * an unexpected value). */ - fun unitAmount(): String = unitAmount.getRequired("unit_amount") + fun propertyValue(): String = propertyValue.getRequired("property_value") /** - * Returns the raw JSON value of [tierLowerBound]. + * Returns the raw JSON value of [propertyKey]. * - * Unlike [tierLowerBound], this method doesn't throw if the JSON field has - * an unexpected type. + * Unlike [propertyKey], this method doesn't throw if the JSON field has an + * unexpected type. */ - @JsonProperty("tier_lower_bound") + @JsonProperty("property_key") @ExcludeMissing - fun _tierLowerBound(): JsonField = tierLowerBound + fun _propertyKey(): JsonField = propertyKey /** - * Returns the raw JSON value of [unitAmount]. + * Returns the raw JSON value of [propertyValue]. * - * Unlike [unitAmount], this method doesn't throw if the JSON field has an - * unexpected type. + * Unlike [propertyValue], this method doesn't throw if the JSON field has + * an unexpected type. */ - @JsonProperty("unit_amount") + @JsonProperty("property_value") @ExcludeMissing - fun _unitAmount(): JsonField = unitAmount + fun _propertyValue(): JsonField = propertyValue @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -7485,59 +7405,59 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [Tier]. + * Returns a mutable builder for constructing an instance of [Filter]. * * The following fields are required: * ```kotlin - * .tierLowerBound() - * .unitAmount() + * .propertyKey() + * .propertyValue() * ``` */ fun builder() = Builder() } - /** A builder for [Tier]. */ + /** A builder for [Filter]. */ class Builder internal constructor() { - private var tierLowerBound: JsonField? = null - private var unitAmount: JsonField? = null + private var propertyKey: JsonField? = null + private var propertyValue: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(tier: Tier) = apply { - tierLowerBound = tier.tierLowerBound - unitAmount = tier.unitAmount - additionalProperties = tier.additionalProperties.toMutableMap() + internal fun from(filter: Filter) = apply { + propertyKey = filter.propertyKey + propertyValue = filter.propertyValue + additionalProperties = filter.additionalProperties.toMutableMap() } - /** Inclusive tier starting value */ - fun tierLowerBound(tierLowerBound: String) = - tierLowerBound(JsonField.of(tierLowerBound)) + /** Event property key to filter on */ + fun propertyKey(propertyKey: String) = + propertyKey(JsonField.of(propertyKey)) /** - * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * Sets [Builder.propertyKey] to an arbitrary JSON value. * - * You should usually call [Builder.tierLowerBound] with a well-typed + * You should usually call [Builder.propertyKey] with a well-typed * [String] value instead. This method is primarily for setting the * field to an undocumented or not yet supported value. */ - fun tierLowerBound(tierLowerBound: JsonField) = apply { - this.tierLowerBound = tierLowerBound + fun propertyKey(propertyKey: JsonField) = apply { + this.propertyKey = propertyKey } - /** Amount per unit */ - fun unitAmount(unitAmount: String) = - unitAmount(JsonField.of(unitAmount)) + /** Event property value to match */ + fun propertyValue(propertyValue: String) = + propertyValue(JsonField.of(propertyValue)) /** - * Sets [Builder.unitAmount] to an arbitrary JSON value. + * Sets [Builder.propertyValue] to an arbitrary JSON value. * - * You should usually call [Builder.unitAmount] with a well-typed + * You should usually call [Builder.propertyValue] with a well-typed * [String] value instead. This method is primarily for setting the * field to an undocumented or not yet supported value. */ - fun unitAmount(unitAmount: JsonField) = apply { - this.unitAmount = unitAmount + fun propertyValue(propertyValue: JsonField) = apply { + this.propertyValue = propertyValue } fun additionalProperties(additionalProperties: Map) = @@ -7563,36 +7483,36 @@ private constructor( } /** - * Returns an immutable instance of [Tier]. + * Returns an immutable instance of [Filter]. * * Further updates to this [Builder] will not mutate the returned * instance. * * The following fields are required: * ```kotlin - * .tierLowerBound() - * .unitAmount() + * .propertyKey() + * .propertyValue() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): Tier = - Tier( - checkRequired("tierLowerBound", tierLowerBound), - checkRequired("unitAmount", unitAmount), + fun build(): Filter = + Filter( + checkRequired("propertyKey", propertyKey), + checkRequired("propertyValue", propertyValue), additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): Tier = apply { + fun validate(): Filter = apply { if (validated) { return@apply } - tierLowerBound() - unitAmount() + propertyKey() + propertyValue() validated = true } @@ -7611,4573 +7531,3965 @@ private constructor( * Used for best match union deserialization. */ internal fun validity(): Int = - (if (tierLowerBound.asKnown() == null) 0 else 1) + - (if (unitAmount.asKnown() == null) 0 else 1) + (if (propertyKey.asKnown() == null) 0 else 1) + + (if (propertyValue.asKnown() == null) 0 else 1) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is Tier && - tierLowerBound == other.tierLowerBound && - unitAmount == other.unitAmount && + return other is Filter && + propertyKey == other.propertyKey && + propertyValue == other.propertyValue && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(tierLowerBound, unitAmount, additionalProperties) + Objects.hash(propertyKey, propertyValue, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "Tier{tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is TieredWithProrationConfig && - tiers == other.tiers && - additionalProperties == other.additionalProperties + "Filter{propertyKey=$propertyKey, propertyValue=$propertyValue, additionalProperties=$additionalProperties}" } - private val hashCode: Int by lazy { Objects.hash(tiers, additionalProperties) } + /** Configuration for a single bulk pricing tier */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val unitAmount: JsonField, + private val tierLowerBound: JsonField, + private val additionalProperties: MutableMap, + ) { - override fun hashCode(): Int = hashCode + @JsonCreator + private constructor( + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + ) : this(unitAmount, tierLowerBound, mutableMapOf()) - override fun toString() = - "TieredWithProrationConfig{tiers=$tiers, additionalProperties=$additionalProperties}" - } + /** + * Amount per unit + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - class Metadata - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { + /** + * The lower bound for this tier + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun tierLowerBound(): String? = + tierLowerBound.getNullable("tier_lower_bound") - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount - fun toBuilder() = Builder().from(this) + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound - companion object { + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - /** Returns a mutable builder for constructing an instance of [Metadata]. */ - fun builder() = Builder() - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - /** A builder for [Metadata]. */ - class Builder internal constructor() { + fun toBuilder() = Builder().from(this) - private var additionalProperties: MutableMap = - mutableMapOf() + companion object { - internal fun from(metadata: Metadata) = apply { - additionalProperties = metadata.additionalProperties.toMutableMap() + /** + * Returns a mutable builder for constructing an instance of [Tier]. + * + * The following fields are required: + * ```kotlin + * .unitAmount() + * ``` + */ + fun builder() = Builder() } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var unitAmount: JsonField? = null + private var tierLowerBound: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(tier: Tier) = apply { + unitAmount = tier.unitAmount + tierLowerBound = tier.tierLowerBound + additionalProperties = tier.additionalProperties.toMutableMap() } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** Amount per unit */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) + /** The lower bound for this tier */ + fun tierLowerBound(tierLowerBound: String?) = + tierLowerBound(JsonField.ofNullable(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```kotlin + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("unitAmount", unitAmount), + tierLowerBound, + additionalProperties.toMutableMap(), + ) } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + unitAmount() + tierLowerBound() + validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + /** - * Returns an immutable instance of [Metadata]. + * Returns a score indicating how many valid values are contained in this + * object recursively. * - * Further updates to this [Builder] will not mutate the returned instance. + * Used for best match union deserialization. */ - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } + internal fun validity(): Int = + (if (unitAmount.asKnown() == null) 0 else 1) + + (if (tierLowerBound.asKnown() == null) 0 else 1) - private var validated: Boolean = false + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun validate(): Metadata = apply { - if (validated) { - return@apply + return other is Tier && + unitAmount == other.unitAmount && + tierLowerBound == other.tierLowerBound && + additionalProperties == other.additionalProperties } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false + private val hashCode: Int by lazy { + Objects.hash(unitAmount, tierLowerBound, additionalProperties) } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - additionalProperties.count { (_, value) -> - !value.isNull() && !value.isMissing() - } + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{unitAmount=$unitAmount, tierLowerBound=$tierLowerBound, additionalProperties=$additionalProperties}" + } override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is Metadata && + return other is BulkWithFiltersConfig && + filters == other.filters && + tiers == other.tiers && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + private val hashCode: Int by lazy { + Objects.hash(filters, tiers, additionalProperties) + } override fun hashCode(): Int = hashCode - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + override fun toString() = + "BulkWithFiltersConfig{filters=$filters, tiers=$tiers, additionalProperties=$additionalProperties}" } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { - return other is TieredWithProration && - cadence == other.cadence && - itemId == other.itemId && - modelType == other.modelType && - name == other.name && - tieredWithProrationConfig == other.tieredWithProrationConfig && - billableMetricId == other.billableMetricId && - billedInAdvance == other.billedInAdvance && - billingCycleConfiguration == other.billingCycleConfiguration && - conversionRate == other.conversionRate && - conversionRateConfig == other.conversionRateConfig && - currency == other.currency && - dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && - externalPriceId == other.externalPriceId && - fixedPriceQuantity == other.fixedPriceQuantity && - invoiceGroupingKey == other.invoiceGroupingKey && - invoicingCycleConfiguration == other.invoicingCycleConfiguration && - metadata == other.metadata && - referenceId == other.referenceId && - additionalProperties == other.additionalProperties - } + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value - private val hashCode: Int by lazy { - Objects.hash( - cadence, - itemId, - modelType, - name, - tieredWithProrationConfig, - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - conversionRateConfig, - currency, - dimensionalPriceConfiguration, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - additionalProperties, - ) - } + companion object { - override fun hashCode(): Int = hashCode + val ANNUAL = of("annual") - override fun toString() = - "TieredWithProration{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredWithProrationConfig=$tieredWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" - } + val SEMI_ANNUAL = of("semi_annual") - class GroupedWithMinMaxThresholds - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val cadence: JsonField, - private val groupedWithMinMaxThresholdsConfig: - JsonField, - private val itemId: JsonField, - private val modelType: JsonValue, - private val name: JsonField, - private val billableMetricId: JsonField, - private val billedInAdvance: JsonField, - private val billingCycleConfiguration: JsonField, - private val conversionRate: JsonField, - private val conversionRateConfig: JsonField, - private val currency: JsonField, - private val dimensionalPriceConfiguration: - JsonField, - private val externalPriceId: JsonField, - private val fixedPriceQuantity: JsonField, - private val invoiceGroupingKey: JsonField, - private val invoicingCycleConfiguration: JsonField, - private val metadata: JsonField, - private val referenceId: JsonField, - private val additionalProperties: MutableMap, - ) { + val MONTHLY = of("monthly") - @JsonCreator - private constructor( - @JsonProperty("cadence") - @ExcludeMissing - cadence: JsonField = JsonMissing.of(), - @JsonProperty("grouped_with_min_max_thresholds_config") - @ExcludeMissing - groupedWithMinMaxThresholdsConfig: - JsonField = - JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - modelType: JsonValue = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - name: JsonField = JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("conversion_rate_config") - @ExcludeMissing - conversionRateConfig: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - currency: JsonField = JsonMissing.of(), - @JsonProperty("dimensional_price_configuration") - @ExcludeMissing - dimensionalPriceConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - metadata: JsonField = JsonMissing.of(), - @JsonProperty("reference_id") - @ExcludeMissing - referenceId: JsonField = JsonMissing.of(), - ) : this( - cadence, - groupedWithMinMaxThresholdsConfig, - itemId, - modelType, - name, - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - conversionRateConfig, - currency, - dimensionalPriceConfiguration, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - mutableMapOf(), - ) + val QUARTERLY = of("quarterly") - /** - * The cadence to bill for this price on. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun cadence(): Cadence = cadence.getRequired("cadence") + val ONE_TIME = of("one_time") - /** - * Configuration for grouped_with_min_max_thresholds pricing - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun groupedWithMinMaxThresholdsConfig(): GroupedWithMinMaxThresholdsConfig = - groupedWithMinMaxThresholdsConfig.getRequired( - "grouped_with_min_max_thresholds_config" - ) + val CUSTOM = of("custom") - /** - * The id of the item the price will be associated with. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun itemId(): String = itemId.getRequired("item_id") + fun of(value: String) = Cadence(JsonField.of(value)) + } - /** - * The pricing model type - * - * Expected to always return the following: - * ```kotlin - * JsonValue.from("grouped_with_min_max_thresholds") - * ``` - * - * However, this method can be useful for debugging and logging (e.g. if the server - * responded with an unexpected value). - */ - @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } - /** - * The name of the price. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun name(): String = name.getRequired("name") + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun billableMetricId(): String? = billableMetricId.getNullable("billable_metric_id") + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun billingCycleConfiguration(): NewBillingCycleConfiguration? = - billingCycleConfiguration.getNullable("billing_cycle_configuration") + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") - /** - * The per unit conversion rate of the price currency to the invoicing currency. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + private var validated: Boolean = false - /** - * The configuration for the rate of the price currency to the invoicing currency. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun conversionRateConfig(): ConversionRateConfig? = - conversionRateConfig.getNullable("conversion_rate_config") + fun validate(): Cadence = apply { + if (validated) { + return@apply + } - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun currency(): String? = currency.getNullable("currency") + known() + validated = true + } - /** - * For dimensional price: specifies a price group and dimension values - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = - dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - /** - * An alias for the price. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun fixedPriceQuantity(): Double? = - fixedPriceQuantity.getNullable("fixed_price_quantity") + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * The property used to group this price on an invoice - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun invoiceGroupingKey(): String? = - invoiceGroupingKey.getNullable("invoice_grouping_key") + return other is Cadence && value == other.value + } - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by * setting `metadata` to `null`. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). */ - fun metadata(): Metadata? = metadata.getNullable("metadata") + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun referenceId(): String? = referenceId.getNullable("reference_id") + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties - /** - * Returns the raw JSON value of [cadence]. - * - * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("cadence") - @ExcludeMissing - fun _cadence(): JsonField = cadence + fun toBuilder() = Builder().from(this) - /** - * Returns the raw JSON value of [groupedWithMinMaxThresholdsConfig]. - * - * Unlike [groupedWithMinMaxThresholdsConfig], this method doesn't throw if the JSON - * field has an unexpected type. - */ - @JsonProperty("grouped_with_min_max_thresholds_config") - @ExcludeMissing - fun _groupedWithMinMaxThresholdsConfig(): - JsonField = groupedWithMinMaxThresholdsConfig + companion object { - /** - * Returns the raw JSON value of [itemId]. - * - * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } - /** - * Returns the raw JSON value of [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + /** A builder for [Metadata]. */ + class Builder internal constructor() { - /** - * Returns the raw JSON value of [billableMetricId]. - * - * Unlike [billableMetricId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = billableMetricId + private var additionalProperties: MutableMap = + mutableMapOf() - /** - * Returns the raw JSON value of [billedInAdvance]. - * - * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } - /** - * Returns the raw JSON value of [billingCycleConfiguration]. - * - * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** - * Returns the raw JSON value of [conversionRate]. - * - * Unlike [conversionRate], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * Returns the raw JSON value of [conversionRateConfig]. - * - * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("conversion_rate_config") - @ExcludeMissing - fun _conversionRateConfig(): JsonField = conversionRateConfig + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - /** - * Returns the raw JSON value of [currency]. - * - * Unlike [currency], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("currency") - @ExcludeMissing - fun _currency(): JsonField = currency + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - /** - * Returns the raw JSON value of [dimensionalPriceConfiguration]. - * - * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON - * field has an unexpected type. - */ - @JsonProperty("dimensional_price_configuration") - @ExcludeMissing - fun _dimensionalPriceConfiguration(): JsonField = - dimensionalPriceConfiguration + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - /** - * Returns the raw JSON value of [externalPriceId]. - * - * Unlike [externalPriceId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } - /** - * Returns the raw JSON value of [fixedPriceQuantity]. - * - * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** - * Returns the raw JSON value of [invoiceGroupingKey]. - * - * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Returns the raw JSON value of [invoicingCycleConfiguration]. - * - * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * Returns the raw JSON value of [metadata]. - * - * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - /** - * Returns the raw JSON value of [referenceId]. - * - * Unlike [referenceId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("reference_id") - @ExcludeMissing - fun _referenceId(): JsonField = referenceId - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + private var validated: Boolean = false - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + fun validate(): Metadata = apply { + if (validated) { + return@apply + } - fun toBuilder() = Builder().from(this) + validated = true + } - companion object { + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } /** - * Returns a mutable builder for constructing an instance of - * [GroupedWithMinMaxThresholds]. + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * The following fields are required: - * ```kotlin - * .cadence() - * .groupedWithMinMaxThresholdsConfig() - * .itemId() - * .name() - * ``` + * Used for best match union deserialization. */ - fun builder() = Builder() - } - - /** A builder for [GroupedWithMinMaxThresholds]. */ - class Builder internal constructor() { - - private var cadence: JsonField? = null - private var groupedWithMinMaxThresholdsConfig: - JsonField? = - null - private var itemId: JsonField? = null - private var modelType: JsonValue = - JsonValue.from("grouped_with_min_max_thresholds") - private var name: JsonField? = null - private var billableMetricId: JsonField = JsonMissing.of() - private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var conversionRateConfig: JsonField = - JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var dimensionalPriceConfiguration: - JsonField = - JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: - JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var referenceId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } - internal fun from(groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds) = - apply { - cadence = groupedWithMinMaxThresholds.cadence - groupedWithMinMaxThresholdsConfig = - groupedWithMinMaxThresholds.groupedWithMinMaxThresholdsConfig - itemId = groupedWithMinMaxThresholds.itemId - modelType = groupedWithMinMaxThresholds.modelType - name = groupedWithMinMaxThresholds.name - billableMetricId = groupedWithMinMaxThresholds.billableMetricId - billedInAdvance = groupedWithMinMaxThresholds.billedInAdvance - billingCycleConfiguration = - groupedWithMinMaxThresholds.billingCycleConfiguration - conversionRate = groupedWithMinMaxThresholds.conversionRate - conversionRateConfig = groupedWithMinMaxThresholds.conversionRateConfig - currency = groupedWithMinMaxThresholds.currency - dimensionalPriceConfiguration = - groupedWithMinMaxThresholds.dimensionalPriceConfiguration - externalPriceId = groupedWithMinMaxThresholds.externalPriceId - fixedPriceQuantity = groupedWithMinMaxThresholds.fixedPriceQuantity - invoiceGroupingKey = groupedWithMinMaxThresholds.invoiceGroupingKey - invoicingCycleConfiguration = - groupedWithMinMaxThresholds.invoicingCycleConfiguration - metadata = groupedWithMinMaxThresholds.metadata - referenceId = groupedWithMinMaxThresholds.referenceId - additionalProperties = - groupedWithMinMaxThresholds.additionalProperties.toMutableMap() + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + return other is Metadata && + additionalProperties == other.additionalProperties + } - /** - * Sets [Builder.cadence] to an arbitrary JSON value. - * - * You should usually call [Builder.cadence] with a well-typed [Cadence] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /** Configuration for grouped_with_min_max_thresholds pricing */ - fun groupedWithMinMaxThresholdsConfig( - groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig - ) = - groupedWithMinMaxThresholdsConfig( - JsonField.of(groupedWithMinMaxThresholdsConfig) - ) + override fun hashCode(): Int = hashCode - /** - * Sets [Builder.groupedWithMinMaxThresholdsConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.groupedWithMinMaxThresholdsConfig] with a - * well-typed [GroupedWithMinMaxThresholdsConfig] value instead. This method is - * primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun groupedWithMinMaxThresholdsConfig( - groupedWithMinMaxThresholdsConfig: - JsonField - ) = apply { - this.groupedWithMinMaxThresholdsConfig = groupedWithMinMaxThresholdsConfig + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - /** The id of the item the price will be associated with. */ - fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + return other is BulkWithFilters && + bulkWithFiltersConfig == other.bulkWithFiltersConfig && + cadence == other.cadence && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } - /** - * Sets [Builder.itemId] to an arbitrary JSON value. - * - * You should usually call [Builder.itemId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + private val hashCode: Int by lazy { + Objects.hash( + bulkWithFiltersConfig, + cadence, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties, + ) + } - /** - * Sets the field to an arbitrary JSON value. - * - * It is usually unnecessary to call this method because the field defaults to - * the following: - * ```kotlin - * JsonValue.from("grouped_with_min_max_thresholds") - * ``` - * - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + override fun hashCode(): Int = hashCode - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) + override fun toString() = + "BulkWithFilters{bulkWithFiltersConfig=$bulkWithFiltersConfig, cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } - /** - * Sets [Builder.name] to an arbitrary JSON value. - * - * You should usually call [Builder.name] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun name(name: JsonField) = apply { this.name = name } + class TieredWithProration + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val tieredWithProrationConfig: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: String?) = - billableMetricId(JsonField.ofNullable(billableMetricId)) + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("tiered_with_proration_config") + @ExcludeMissing + tieredWithProrationConfig: JsonField = + JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + modelType, + name, + tieredWithProrationConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + mutableMapOf(), + ) - /** - * Sets [Builder.billableMetricId] to an arbitrary JSON value. - * - * You should usually call [Builder.billableMetricId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun billableMetricId(billableMetricId: JsonField) = apply { - this.billableMetricId = billableMetricId - } + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") - /** - * If the Price represents a fixed cost, the price will be billed in-advance if - * this is true, and in-arrears if this is false. - */ - fun billedInAdvance(billedInAdvance: Boolean?) = - billedInAdvance(JsonField.ofNullable(billedInAdvance)) + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") - /** - * Alias for [Builder.billedInAdvance]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun billedInAdvance(billedInAdvance: Boolean) = - billedInAdvance(billedInAdvance as Boolean?) + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("tiered_with_proration") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType - /** - * Sets [Builder.billedInAdvance] to an arbitrary JSON value. - * - * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun billedInAdvance(billedInAdvance: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: NewBillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + /** + * Configuration for tiered_with_proration pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun tieredWithProrationConfig(): TieredWithProrationConfig = + tieredWithProrationConfig.getRequired("tiered_with_proration_config") - /** - * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.billingCycleConfiguration] with a well-typed - * [NewBillingCycleConfiguration] value instead. This method is primarily for - * setting the field to an undocumented or not yet supported value. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: JsonField - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = billableMetricId.getNullable("billable_metric_id") - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: Double?) = - conversionRate(JsonField.ofNullable(conversionRate)) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") - /** - * Alias for [Builder.conversionRate]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") - /** - * Sets [Builder.conversionRate] to an arbitrary JSON value. - * - * You should usually call [Builder.conversionRate] with a well-typed [Double] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") - /** - * The configuration for the rate of the price currency to the invoicing - * currency. - */ - fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = - conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") - /** - * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.conversionRateConfig] with a well-typed - * [ConversionRateConfig] value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun conversionRateConfig( - conversionRateConfig: JsonField - ) = apply { this.conversionRateConfig = conversionRateConfig } + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") - /** - * Alias for calling [conversionRateConfig] with - * `ConversionRateConfig.ofUnit(unit)`. - */ - fun conversionRateConfig(unit: UnitConversionRateConfig) = - conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") - /** - * Alias for calling [conversionRateConfig] with the following: - * ```kotlin - * UnitConversionRateConfig.builder() - * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) - * .unitConfig(unitConfig) - * .build() - * ``` - */ - fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = - conversionRateConfig( - UnitConversionRateConfig.builder() - .conversionRateType( - UnitConversionRateConfig.ConversionRateType.UNIT - ) - .unitConfig(unitConfig) - .build() - ) + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") - /** - * Alias for calling [conversionRateConfig] with - * `ConversionRateConfig.ofTiered(tiered)`. - */ - fun conversionRateConfig(tiered: TieredConversionRateConfig) = - conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") - /** - * Alias for calling [conversionRateConfig] with the following: - * ```kotlin - * TieredConversionRateConfig.builder() - * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) - * .tieredConfig(tieredConfig) - * .build() - * ``` - */ - fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = - conversionRateConfig( - TieredConversionRateConfig.builder() - .conversionRateType( - TieredConversionRateConfig.ConversionRateType.TIERED - ) - .tieredConfig(tieredConfig) - .build() - ) + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + invoiceGroupingKey.getNullable("invoice_grouping_key") - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - /** - * Sets [Builder.currency] to an arbitrary JSON value. - * - * You should usually call [Builder.currency] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") - /** For dimensional price: specifies a price group and dimension values */ - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? - ) = - dimensionalPriceConfiguration( - JsonField.ofNullable(dimensionalPriceConfiguration) - ) + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") - /** - * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.dimensionalPriceConfiguration] with a - * well-typed [NewDimensionalPriceConfiguration] value instead. This method is - * primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: JsonField - ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - /** - * Sets [Builder.externalPriceId] to an arbitrary JSON value. - * - * You should usually call [Builder.externalPriceId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun externalPriceId(externalPriceId: JsonField) = apply { - this.externalPriceId = externalPriceId - } + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = - fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + /** + * Returns the raw JSON value of [tieredWithProrationConfig]. + * + * Unlike [tieredWithProrationConfig], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("tiered_with_proration_config") + @ExcludeMissing + fun _tieredWithProrationConfig(): JsonField = + tieredWithProrationConfig - /** - * Alias for [Builder.fixedPriceQuantity]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId - /** - * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. - * - * You should usually call [Builder.fixedPriceQuantity] with a well-typed - * [Double] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = - invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration - /** - * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. - * - * You should usually call [Builder.invoiceGroupingKey] with a well-typed - * [String] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { - this.invoiceGroupingKey = invoiceGroupingKey - } + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate - /** - * Within each billing cycle, specifies the cadence at which invoices are - * produced. If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: NewBillingCycleConfiguration? - ) = - invoicingCycleConfiguration( - JsonField.ofNullable(invoicingCycleConfiguration) - ) + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig - /** - * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.invoicingCycleConfiguration] with a - * well-typed [NewBillingCycleConfiguration] value instead. This method is - * primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration - /** - * Sets [Builder.metadata] to an arbitrary JSON value. - * - * You should usually call [Builder.metadata] with a well-typed [Metadata] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - fun referenceId(referenceId: String?) = - referenceId(JsonField.ofNullable(referenceId)) + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - /** - * Sets [Builder.referenceId] to an arbitrary JSON value. - * - * You should usually call [Builder.referenceId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun referenceId(referenceId: JsonField) = apply { - this.referenceId = referenceId - } + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { /** - * Returns an immutable instance of [GroupedWithMinMaxThresholds]. - * - * Further updates to this [Builder] will not mutate the returned instance. + * Returns a mutable builder for constructing an instance of + * [TieredWithProration]. * * The following fields are required: * ```kotlin * .cadence() - * .groupedWithMinMaxThresholdsConfig() * .itemId() * .name() + * .tieredWithProrationConfig() * ``` - * - * @throws IllegalStateException if any required field is unset. */ - fun build(): GroupedWithMinMaxThresholds = - GroupedWithMinMaxThresholds( - checkRequired("cadence", cadence), - checkRequired( - "groupedWithMinMaxThresholdsConfig", - groupedWithMinMaxThresholdsConfig, - ), - checkRequired("itemId", itemId), - modelType, - checkRequired("name", name), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - conversionRateConfig, - currency, - dimensionalPriceConfiguration, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - additionalProperties.toMutableMap(), - ) + fun builder() = Builder() } - private var validated: Boolean = false - - fun validate(): GroupedWithMinMaxThresholds = apply { - if (validated) { - return@apply - } + /** A builder for [TieredWithProration]. */ + class Builder internal constructor() { - cadence().validate() - groupedWithMinMaxThresholdsConfig().validate() - itemId() - _modelType().let { - if (it != JsonValue.from("grouped_with_min_max_thresholds")) { - throw OrbInvalidDataException("'modelType' is invalid, received $it") - } - } - name() - billableMetricId() - billedInAdvance() - billingCycleConfiguration()?.validate() - conversionRate() - conversionRateConfig()?.validate() - currency() - dimensionalPriceConfiguration()?.validate() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration()?.validate() - metadata()?.validate() - referenceId() - validated = true - } + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonValue = JsonValue.from("tiered_with_proration") + private var name: JsonField? = null + private var tieredWithProrationConfig: JsonField? = + null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false + internal fun from(tieredWithProration: TieredWithProration) = apply { + cadence = tieredWithProration.cadence + itemId = tieredWithProration.itemId + modelType = tieredWithProration.modelType + name = tieredWithProration.name + tieredWithProrationConfig = tieredWithProration.tieredWithProrationConfig + billableMetricId = tieredWithProration.billableMetricId + billedInAdvance = tieredWithProration.billedInAdvance + billingCycleConfiguration = tieredWithProration.billingCycleConfiguration + conversionRate = tieredWithProration.conversionRate + conversionRateConfig = tieredWithProration.conversionRateConfig + currency = tieredWithProration.currency + dimensionalPriceConfiguration = + tieredWithProration.dimensionalPriceConfiguration + externalPriceId = tieredWithProration.externalPriceId + fixedPriceQuantity = tieredWithProration.fixedPriceQuantity + invoiceGroupingKey = tieredWithProration.invoiceGroupingKey + invoicingCycleConfiguration = + tieredWithProration.invoicingCycleConfiguration + metadata = tieredWithProration.metadata + referenceId = tieredWithProration.referenceId + additionalProperties = + tieredWithProration.additionalProperties.toMutableMap() } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (cadence.asKnown()?.validity() ?: 0) + - (groupedWithMinMaxThresholdsConfig.asKnown()?.validity() ?: 0) + - (if (itemId.asKnown() == null) 0 else 1) + - modelType.let { - if (it == JsonValue.from("grouped_with_min_max_thresholds")) 1 else 0 - } + - (if (name.asKnown() == null) 0 else 1) + - (if (billableMetricId.asKnown() == null) 0 else 1) + - (if (billedInAdvance.asKnown() == null) 0 else 1) + - (billingCycleConfiguration.asKnown()?.validity() ?: 0) + - (if (conversionRate.asKnown() == null) 0 else 1) + - (conversionRateConfig.asKnown()?.validity() ?: 0) + - (if (currency.asKnown() == null) 0 else 1) + - (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + - (if (externalPriceId.asKnown() == null) 0 else 1) + - (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + - (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + - (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + - (metadata.asKnown()?.validity() ?: 0) + - (if (referenceId.asKnown() == null) 0 else 1) - - /** The cadence to bill for this price on. */ - class Cadence - @JsonCreator - private constructor(private val value: JsonField) : Enum { + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) /** - * Returns this class instance's raw value. + * Sets [Builder.cadence] to an arbitrary JSON value. * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - val ANNUAL = of("annual") + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - val SEMI_ANNUAL = of("semi_annual") + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - val MONTHLY = of("monthly") + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("tiered_with_proration") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } - val QUARTERLY = of("quarterly") + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) - val ONE_TIME = of("one_time") + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } - val CUSTOM = of("custom") + /** Configuration for tiered_with_proration pricing */ + fun tieredWithProrationConfig( + tieredWithProrationConfig: TieredWithProrationConfig + ) = tieredWithProrationConfig(JsonField.of(tieredWithProrationConfig)) - fun of(value: String) = Cadence(JsonField.of(value)) - } + /** + * Sets [Builder.tieredWithProrationConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.tieredWithProrationConfig] with a well-typed + * [TieredWithProrationConfig] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun tieredWithProrationConfig( + tieredWithProrationConfig: JsonField + ) = apply { this.tieredWithProrationConfig = tieredWithProrationConfig } - /** An enum containing [Cadence]'s known values. */ - enum class Known { - ANNUAL, - SEMI_ANNUAL, - MONTHLY, - QUARTERLY, - ONE_TIME, - CUSTOM, - } + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) /** - * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * Sets [Builder.billableMetricId] to an arbitrary JSON value. * - * An instance of [Cadence] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. */ - enum class Value { - ANNUAL, - SEMI_ANNUAL, - MONTHLY, - QUARTERLY, - ONE_TIME, - CUSTOM, - /** - * An enum member indicating that [Cadence] was instantiated with an unknown - * value. - */ - _UNKNOWN, + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId } /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. */ - fun value(): Value = - when (this) { - ANNUAL -> Value.ANNUAL - SEMI_ANNUAL -> Value.SEMI_ANNUAL - MONTHLY -> Value.MONTHLY - QUARTERLY -> Value.QUARTERLY - ONE_TIME -> Value.ONE_TIME - CUSTOM -> Value.CUSTOM - else -> Value._UNKNOWN - } + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) /** - * Returns an enum member corresponding to this class instance's value. + * Alias for [Builder.billedInAdvance]. * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. */ - fun known(): Known = - when (this) { - ANNUAL -> Known.ANNUAL - SEMI_ANNUAL -> Known.SEMI_ANNUAL - MONTHLY -> Known.MONTHLY - QUARTERLY -> Known.QUARTERLY - ONE_TIME -> Known.ONE_TIME - CUSTOM -> Known.CUSTOM - else -> throw OrbInvalidDataException("Unknown Cadence: $value") - } + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. */ - fun asString(): String = - _value().asString() - ?: throw OrbInvalidDataException("Value is not a String") + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } - private var validated: Boolean = false + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) - fun validate(): Cadence = apply { - if (validated) { - return@apply - } + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) - known() - validated = true + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) /** - * Returns a score indicating how many valid values are contained in this object - * recursively. + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. * - * Used for best match union deserialization. + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. */ - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Cadence && value == other.value - } - - override fun hashCode() = value.hashCode() + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } - override fun toString() = value.toString() - } + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) - /** Configuration for grouped_with_min_max_thresholds pricing */ - class GroupedWithMinMaxThresholdsConfig - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val groupingKey: JsonField, - private val maximumCharge: JsonField, - private val minimumCharge: JsonField, - private val perUnitRate: JsonField, - private val additionalProperties: MutableMap, - ) { + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) - @JsonCreator - private constructor( - @JsonProperty("grouping_key") - @ExcludeMissing - groupingKey: JsonField = JsonMissing.of(), - @JsonProperty("maximum_charge") - @ExcludeMissing - maximumCharge: JsonField = JsonMissing.of(), - @JsonProperty("minimum_charge") - @ExcludeMissing - minimumCharge: JsonField = JsonMissing.of(), - @JsonProperty("per_unit_rate") - @ExcludeMissing - perUnitRate: JsonField = JsonMissing.of(), - ) : this(groupingKey, maximumCharge, minimumCharge, perUnitRate, mutableMapOf()) + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) /** - * The event property used to group before applying thresholds - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` */ - fun groupingKey(): String = groupingKey.getRequired("grouping_key") + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) /** - * The maximum amount to charge each group - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. */ - fun maximumCharge(): String = maximumCharge.getRequired("maximum_charge") + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) /** - * The minimum amount to charge each group, regardless of usage + * Sets [Builder.currency] to an arbitrary JSON value. * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. */ - fun minimumCharge(): String = minimumCharge.getRequired("minimum_charge") + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) /** - * The base price charged per group + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. */ - fun perUnitRate(): String = perUnitRate.getRequired("per_unit_rate") + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) /** - * Returns the raw JSON value of [groupingKey]. + * Sets [Builder.externalPriceId] to an arbitrary JSON value. * - * Unlike [groupingKey], this method doesn't throw if the JSON field has an - * unexpected type. + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. */ - @JsonProperty("grouping_key") - @ExcludeMissing - fun _groupingKey(): JsonField = groupingKey + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } /** - * Returns the raw JSON value of [maximumCharge]. - * - * Unlike [maximumCharge], this method doesn't throw if the JSON field has an - * unexpected type. + * If the Price represents a fixed cost, this represents the quantity of units + * applied. */ - @JsonProperty("maximum_charge") - @ExcludeMissing - fun _maximumCharge(): JsonField = maximumCharge + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) /** - * Returns the raw JSON value of [minimumCharge]. + * Alias for [Builder.fixedPriceQuantity]. * - * Unlike [minimumCharge], this method doesn't throw if the JSON field has an - * unexpected type. + * This unboxed primitive overload exists for backwards compatibility. */ - @JsonProperty("minimum_charge") - @ExcludeMissing - fun _minimumCharge(): JsonField = minimumCharge + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) /** - * Returns the raw JSON value of [perUnitRate]. + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. * - * Unlike [perUnitRate], this method doesn't throw if the JSON field has an - * unexpected type. + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. */ - @JsonProperty("per_unit_rate") - @ExcludeMissing - fun _perUnitRate(): JsonField = perUnitRate - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) - /** - * Returns a mutable builder for constructing an instance of - * [GroupedWithMinMaxThresholdsConfig]. - * - * The following fields are required: - * ```kotlin - * .groupingKey() - * .maximumCharge() - * .minimumCharge() - * .perUnitRate() - * ``` - */ - fun builder() = Builder() + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey } - /** A builder for [GroupedWithMinMaxThresholdsConfig]. */ - class Builder internal constructor() { - - private var groupingKey: JsonField? = null - private var maximumCharge: JsonField? = null - private var minimumCharge: JsonField? = null - private var perUnitRate: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - internal fun from( - groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig - ) = apply { - groupingKey = groupedWithMinMaxThresholdsConfig.groupingKey - maximumCharge = groupedWithMinMaxThresholdsConfig.maximumCharge - minimumCharge = groupedWithMinMaxThresholdsConfig.minimumCharge - perUnitRate = groupedWithMinMaxThresholdsConfig.perUnitRate - additionalProperties = - groupedWithMinMaxThresholdsConfig.additionalProperties - .toMutableMap() - } - - /** The event property used to group before applying thresholds */ - fun groupingKey(groupingKey: String) = - groupingKey(JsonField.of(groupingKey)) - - /** - * Sets [Builder.groupingKey] to an arbitrary JSON value. - * - * You should usually call [Builder.groupingKey] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun groupingKey(groupingKey: JsonField) = apply { - this.groupingKey = groupingKey - } - - /** The maximum amount to charge each group */ - fun maximumCharge(maximumCharge: String) = - maximumCharge(JsonField.of(maximumCharge)) - - /** - * Sets [Builder.maximumCharge] to an arbitrary JSON value. - * - * You should usually call [Builder.maximumCharge] with a well-typed - * [String] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun maximumCharge(maximumCharge: JsonField) = apply { - this.maximumCharge = maximumCharge - } - - /** The minimum amount to charge each group, regardless of usage */ - fun minimumCharge(minimumCharge: String) = - minimumCharge(JsonField.of(minimumCharge)) - - /** - * Sets [Builder.minimumCharge] to an arbitrary JSON value. - * - * You should usually call [Builder.minimumCharge] with a well-typed - * [String] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun minimumCharge(minimumCharge: JsonField) = apply { - this.minimumCharge = minimumCharge - } - - /** The base price charged per group */ - fun perUnitRate(perUnitRate: String) = - perUnitRate(JsonField.of(perUnitRate)) - - /** - * Sets [Builder.perUnitRate] to an arbitrary JSON value. - * - * You should usually call [Builder.perUnitRate] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun perUnitRate(perUnitRate: JsonField) = apply { - this.perUnitRate = perUnitRate - } + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } - /** - * Returns an immutable instance of [GroupedWithMinMaxThresholdsConfig]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```kotlin - * .groupingKey() - * .maximumCharge() - * .minimumCharge() - * .perUnitRate() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): GroupedWithMinMaxThresholdsConfig = - GroupedWithMinMaxThresholdsConfig( - checkRequired("groupingKey", groupingKey), - checkRequired("maximumCharge", maximumCharge), - checkRequired("minimumCharge", minimumCharge), - checkRequired("perUnitRate", perUnitRate), - additionalProperties.toMutableMap(), - ) + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) } - private var validated: Boolean = false + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun validate(): GroupedWithMinMaxThresholdsConfig = apply { - if (validated) { - return@apply + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) } - groupingKey() - maximumCharge() - minimumCharge() - perUnitRate() - validated = true + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } /** - * Returns a score indicating how many valid values are contained in this object - * recursively. + * Returns an immutable instance of [TieredWithProration]. * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (if (groupingKey.asKnown() == null) 0 else 1) + - (if (maximumCharge.asKnown() == null) 0 else 1) + - (if (minimumCharge.asKnown() == null) 0 else 1) + - (if (perUnitRate.asKnown() == null) 0 else 1) + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .name() + * .tieredWithProrationConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TieredWithProration = + TieredWithProration( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + modelType, + checkRequired("name", name), + checkRequired("tieredWithProrationConfig", tieredWithProrationConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + private var validated: Boolean = false - return other is GroupedWithMinMaxThresholdsConfig && - groupingKey == other.groupingKey && - maximumCharge == other.maximumCharge && - minimumCharge == other.minimumCharge && - perUnitRate == other.perUnitRate && - additionalProperties == other.additionalProperties + fun validate(): TieredWithProration = apply { + if (validated) { + return@apply } - private val hashCode: Int by lazy { - Objects.hash( - groupingKey, - maximumCharge, - minimumCharge, - perUnitRate, - additionalProperties, - ) + cadence().validate() + itemId() + _modelType().let { + if (it != JsonValue.from("tiered_with_proration")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "GroupedWithMinMaxThresholdsConfig{groupingKey=$groupingKey, maximumCharge=$maximumCharge, minimumCharge=$minimumCharge, perUnitRate=$perUnitRate, additionalProperties=$additionalProperties}" + name() + tieredWithProrationConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + metadata()?.validate() + referenceId() + validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. */ - class Metadata - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + modelType.let { + if (it == JsonValue.from("tiered_with_proration")) 1 else 0 + } + + (if (name.asKnown() == null) 0 else 1) + + (tieredWithProrationConfig.asKnown()?.validity() ?: 0) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { - fun toBuilder() = Builder().from(this) + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { - /** Returns a mutable builder for constructing an instance of [Metadata]. */ - fun builder() = Builder() - } - - /** A builder for [Metadata]. */ - class Builder internal constructor() { + val ANNUAL = of("annual") - private var additionalProperties: MutableMap = - mutableMapOf() + val SEMI_ANNUAL = of("semi_annual") - internal fun from(metadata: Metadata) = apply { - additionalProperties = metadata.additionalProperties.toMutableMap() - } + val MONTHLY = of("monthly") - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + val QUARTERLY = of("quarterly") - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + val ONE_TIME = of("one_time") - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + val CUSTOM = of("custom") - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun of(value: String) = Cadence(JsonField.of(value)) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, /** - * Returns an immutable instance of [Metadata]. - * - * Further updates to this [Builder] will not mutate the returned instance. + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. */ - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true + _UNKNOWN, } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. * - * Used for best match union deserialization. + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. */ - internal fun validity(): Int = - additionalProperties.count { (_, value) -> - !value.isNull() && !value.isMissing() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN } - return other is Metadata && - additionalProperties == other.additionalProperties + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true } - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - override fun hashCode(): Int = hashCode + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + return other is Cadence && value == other.value } - return other is GroupedWithMinMaxThresholds && - cadence == other.cadence && - groupedWithMinMaxThresholdsConfig == - other.groupedWithMinMaxThresholdsConfig && - itemId == other.itemId && - modelType == other.modelType && - name == other.name && - billableMetricId == other.billableMetricId && - billedInAdvance == other.billedInAdvance && - billingCycleConfiguration == other.billingCycleConfiguration && - conversionRate == other.conversionRate && - conversionRateConfig == other.conversionRateConfig && - currency == other.currency && - dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && - externalPriceId == other.externalPriceId && - fixedPriceQuantity == other.fixedPriceQuantity && - invoiceGroupingKey == other.invoiceGroupingKey && - invoicingCycleConfiguration == other.invoicingCycleConfiguration && - metadata == other.metadata && - referenceId == other.referenceId && - additionalProperties == other.additionalProperties - } + override fun hashCode() = value.hashCode() - private val hashCode: Int by lazy { - Objects.hash( - cadence, - groupedWithMinMaxThresholdsConfig, - itemId, - modelType, - name, - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - conversionRateConfig, - currency, - dimensionalPriceConfiguration, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - additionalProperties, - ) + override fun toString() = value.toString() } - override fun hashCode(): Int = hashCode + /** Configuration for tiered_with_proration pricing */ + class TieredWithProrationConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val tiers: JsonField>, + private val additionalProperties: MutableMap, + ) { - override fun toString() = - "GroupedWithMinMaxThresholds{cadence=$cadence, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" - } + @JsonCreator + private constructor( + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of() + ) : this(tiers, mutableMapOf()) - class Percent - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val cadence: JsonField, - private val itemId: JsonField, - private val modelType: JsonValue, - private val name: JsonField, - private val percentConfig: JsonField, - private val billableMetricId: JsonField, - private val billedInAdvance: JsonField, - private val billingCycleConfiguration: JsonField, - private val conversionRate: JsonField, - private val conversionRateConfig: JsonField, - private val currency: JsonField, - private val dimensionalPriceConfiguration: - JsonField, - private val externalPriceId: JsonField, - private val fixedPriceQuantity: JsonField, - private val invoiceGroupingKey: JsonField, - private val invoicingCycleConfiguration: JsonField, - private val metadata: JsonField, - private val referenceId: JsonField, - private val additionalProperties: MutableMap, - ) { + /** + * Tiers for rating based on total usage quantities into the specified tier with + * proration + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun tiers(): List = tiers.getRequired("tiers") - @JsonCreator - private constructor( - @JsonProperty("cadence") - @ExcludeMissing - cadence: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - modelType: JsonValue = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - name: JsonField = JsonMissing.of(), - @JsonProperty("percent_config") - @ExcludeMissing - percentConfig: JsonField = JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("conversion_rate_config") - @ExcludeMissing - conversionRateConfig: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - currency: JsonField = JsonMissing.of(), - @JsonProperty("dimensional_price_configuration") - @ExcludeMissing - dimensionalPriceConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - metadata: JsonField = JsonMissing.of(), - @JsonProperty("reference_id") + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tiers") @ExcludeMissing - referenceId: JsonField = JsonMissing.of(), - ) : this( - cadence, - itemId, - modelType, - name, - percentConfig, - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - conversionRateConfig, - currency, - dimensionalPriceConfiguration, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - mutableMapOf(), - ) + fun _tiers(): JsonField> = tiers - /** - * The cadence to bill for this price on. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun cadence(): Cadence = cadence.getRequired("cadence") + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - /** - * The id of the item the price will be associated with. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun itemId(): String = itemId.getRequired("item_id") + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - /** - * The pricing model type - * - * Expected to always return the following: - * ```kotlin - * JsonValue.from("percent") - * ``` - * - * However, this method can be useful for debugging and logging (e.g. if the server - * responded with an unexpected value). - */ - @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + fun toBuilder() = Builder().from(this) - /** - * The name of the price. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun name(): String = name.getRequired("name") + companion object { - /** - * Configuration for percent pricing - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun percentConfig(): PercentConfig = percentConfig.getRequired("percent_config") + /** + * Returns a mutable builder for constructing an instance of + * [TieredWithProrationConfig]. + * + * The following fields are required: + * ```kotlin + * .tiers() + * ``` + */ + fun builder() = Builder() + } - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun billableMetricId(): String? = billableMetricId.getNullable("billable_metric_id") + /** A builder for [TieredWithProrationConfig]. */ + class Builder internal constructor() { - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + private var tiers: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun billingCycleConfiguration(): NewBillingCycleConfiguration? = - billingCycleConfiguration.getNullable("billing_cycle_configuration") + internal fun from(tieredWithProrationConfig: TieredWithProrationConfig) = + apply { + tiers = tieredWithProrationConfig.tiers.map { it.toMutableList() } + additionalProperties = + tieredWithProrationConfig.additionalProperties.toMutableMap() + } - /** - * The per unit conversion rate of the price currency to the invoicing currency. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + /** + * Tiers for rating based on total usage quantities into the specified tier + * with proration + */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) - /** - * The configuration for the rate of the price currency to the invoicing currency. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun conversionRateConfig(): ConversionRateConfig? = - conversionRateConfig.getNullable("conversion_rate_config") + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun currency(): String? = currency.getNullable("currency") + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } - /** - * For dimensional price: specifies a price group and dimension values - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = - dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** - * An alias for the price. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun fixedPriceQuantity(): Double? = - fixedPriceQuantity.getNullable("fixed_price_quantity") + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - /** - * The property used to group this price on an invoice - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun invoiceGroupingKey(): String? = - invoiceGroupingKey.getNullable("invoice_grouping_key") + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun metadata(): Metadata? = metadata.getNullable("metadata") + /** + * Returns an immutable instance of [TieredWithProrationConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TieredWithProrationConfig = + TieredWithProrationConfig( + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun referenceId(): String? = referenceId.getNullable("reference_id") + private var validated: Boolean = false - /** - * Returns the raw JSON value of [cadence]. - * - * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("cadence") - @ExcludeMissing - fun _cadence(): JsonField = cadence + fun validate(): TieredWithProrationConfig = apply { + if (validated) { + return@apply + } - /** - * Returns the raw JSON value of [itemId]. - * - * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + tiers().forEach { it.validate() } + validated = true + } - /** - * Returns the raw JSON value of [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - /** - * Returns the raw JSON value of [percentConfig]. - * - * Unlike [percentConfig], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("percent_config") - @ExcludeMissing - fun _percentConfig(): JsonField = percentConfig + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (tiers.asKnown()?.sumOf { it.validity().toInt() } ?: 0) - /** - * Returns the raw JSON value of [billableMetricId]. - * - * Unlike [billableMetricId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = billableMetricId + /** Configuration for a single tiered with proration tier */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val tierLowerBound: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { - /** - * Returns the raw JSON value of [billedInAdvance]. - * - * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance + @JsonCreator + private constructor( + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(tierLowerBound, unitAmount, mutableMapOf()) - /** - * Returns the raw JSON value of [billingCycleConfiguration]. - * - * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration + /** + * Inclusive tier starting value + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun tierLowerBound(): String = + tierLowerBound.getRequired("tier_lower_bound") - /** - * Returns the raw JSON value of [conversionRate]. - * - * Unlike [conversionRate], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate + /** + * Amount per unit + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") - /** - * Returns the raw JSON value of [conversionRateConfig]. - * - * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("conversion_rate_config") - @ExcludeMissing - fun _conversionRateConfig(): JsonField = conversionRateConfig + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound - /** - * Returns the raw JSON value of [currency]. - * - * Unlike [currency], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("currency") - @ExcludeMissing - fun _currency(): JsonField = currency + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount - /** - * Returns the raw JSON value of [dimensionalPriceConfiguration]. - * - * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON - * field has an unexpected type. - */ - @JsonProperty("dimensional_price_configuration") - @ExcludeMissing - fun _dimensionalPriceConfiguration(): JsonField = - dimensionalPriceConfiguration + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - /** - * Returns the raw JSON value of [externalPriceId]. - * - * Unlike [externalPriceId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - /** - * Returns the raw JSON value of [fixedPriceQuantity]. - * - * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + fun toBuilder() = Builder().from(this) - /** - * Returns the raw JSON value of [invoiceGroupingKey]. - * - * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + companion object { - /** - * Returns the raw JSON value of [invoicingCycleConfiguration]. - * - * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration + /** + * Returns a mutable builder for constructing an instance of [Tier]. + * + * The following fields are required: + * ```kotlin + * .tierLowerBound() + * .unitAmount() + * ``` + */ + fun builder() = Builder() + } - /** - * Returns the raw JSON value of [metadata]. - * - * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata + /** A builder for [Tier]. */ + class Builder internal constructor() { - /** - * Returns the raw JSON value of [referenceId]. - * - * Unlike [referenceId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("reference_id") - @ExcludeMissing - fun _referenceId(): JsonField = referenceId + private var tierLowerBound: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + internal fun from(tier: Tier) = apply { + tierLowerBound = tier.tierLowerBound + unitAmount = tier.unitAmount + additionalProperties = tier.additionalProperties.toMutableMap() + } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** Inclusive tier starting value */ + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) - fun toBuilder() = Builder().from(this) + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } - companion object { + /** Amount per unit */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) - /** - * Returns a mutable builder for constructing an instance of [Percent]. - * - * The following fields are required: - * ```kotlin - * .cadence() - * .itemId() - * .name() - * .percentConfig() - * ``` - */ - fun builder() = Builder() - } + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } - /** A builder for [Percent]. */ - class Builder internal constructor() { + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - private var cadence: JsonField? = null - private var itemId: JsonField? = null - private var modelType: JsonValue = JsonValue.from("percent") - private var name: JsonField? = null - private var percentConfig: JsonField? = null - private var billableMetricId: JsonField = JsonMissing.of() - private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var conversionRateConfig: JsonField = - JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var dimensionalPriceConfiguration: - JsonField = - JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: - JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var referenceId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - internal fun from(percent: Percent) = apply { - cadence = percent.cadence - itemId = percent.itemId - modelType = percent.modelType - name = percent.name - percentConfig = percent.percentConfig - billableMetricId = percent.billableMetricId - billedInAdvance = percent.billedInAdvance - billingCycleConfiguration = percent.billingCycleConfiguration - conversionRate = percent.conversionRate - conversionRateConfig = percent.conversionRateConfig - currency = percent.currency - dimensionalPriceConfiguration = percent.dimensionalPriceConfiguration - externalPriceId = percent.externalPriceId - fixedPriceQuantity = percent.fixedPriceQuantity - invoiceGroupingKey = percent.invoiceGroupingKey - invoicingCycleConfiguration = percent.invoicingCycleConfiguration - metadata = percent.metadata - referenceId = percent.referenceId - additionalProperties = percent.additionalProperties.toMutableMap() - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - /** - * Sets [Builder.cadence] to an arbitrary JSON value. - * - * You should usually call [Builder.cadence] with a well-typed [Cadence] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - /** The id of the item the price will be associated with. */ - fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + /** + * Returns an immutable instance of [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```kotlin + * .tierLowerBound() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("tierLowerBound", tierLowerBound), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } - /** - * Sets [Builder.itemId] to an arbitrary JSON value. - * - * You should usually call [Builder.itemId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + private var validated: Boolean = false - /** - * Sets the field to an arbitrary JSON value. - * - * It is usually unnecessary to call this method because the field defaults to - * the following: - * ```kotlin - * JsonValue.from("percent") - * ``` - * - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + fun validate(): Tier = apply { + if (validated) { + return@apply + } - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) + tierLowerBound() + unitAmount() + validated = true + } - /** - * Sets [Builder.name] to an arbitrary JSON value. - * - * You should usually call [Builder.name] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun name(name: JsonField) = apply { this.name = name } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - /** Configuration for percent pricing */ - fun percentConfig(percentConfig: PercentConfig) = - percentConfig(JsonField.of(percentConfig)) + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (tierLowerBound.asKnown() == null) 0 else 1) + + (if (unitAmount.asKnown() == null) 0 else 1) - /** - * Sets [Builder.percentConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.percentConfig] with a well-typed - * [PercentConfig] value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. - */ - fun percentConfig(percentConfig: JsonField) = apply { - this.percentConfig = percentConfig + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + tierLowerBound == other.tierLowerBound && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(tierLowerBound, unitAmount, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" } - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: String?) = - billableMetricId(JsonField.ofNullable(billableMetricId)) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * Sets [Builder.billableMetricId] to an arbitrary JSON value. - * - * You should usually call [Builder.billableMetricId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun billableMetricId(billableMetricId: JsonField) = apply { - this.billableMetricId = billableMetricId + return other is TieredWithProrationConfig && + tiers == other.tiers && + additionalProperties == other.additionalProperties } - /** - * If the Price represents a fixed cost, the price will be billed in-advance if - * this is true, and in-arrears if this is false. - */ - fun billedInAdvance(billedInAdvance: Boolean?) = - billedInAdvance(JsonField.ofNullable(billedInAdvance)) + private val hashCode: Int by lazy { Objects.hash(tiers, additionalProperties) } - /** - * Alias for [Builder.billedInAdvance]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun billedInAdvance(billedInAdvance: Boolean) = - billedInAdvance(billedInAdvance as Boolean?) + override fun hashCode(): Int = hashCode - /** - * Sets [Builder.billedInAdvance] to an arbitrary JSON value. - * - * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun billedInAdvance(billedInAdvance: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } + override fun toString() = + "TieredWithProrationConfig{tiers=$tiers, additionalProperties=$additionalProperties}" + } - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: NewBillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { - /** - * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.billingCycleConfiguration] with a well-typed - * [NewBillingCycleConfiguration] value instead. This method is primarily for - * setting the field to an undocumented or not yet supported value. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: JsonField - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: Double?) = - conversionRate(JsonField.ofNullable(conversionRate)) + fun toBuilder() = Builder().from(this) - /** - * Alias for [Builder.conversionRate]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) + companion object { - /** - * Sets [Builder.conversionRate] to an arbitrary JSON value. - * - * You should usually call [Builder.conversionRate] with a well-typed [Double] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() } - /** - * The configuration for the rate of the price currency to the invoicing - * currency. - */ - fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = - conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + /** A builder for [Metadata]. */ + class Builder internal constructor() { - /** - * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.conversionRateConfig] with a well-typed - * [ConversionRateConfig] value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun conversionRateConfig( - conversionRateConfig: JsonField - ) = apply { this.conversionRateConfig = conversionRateConfig } + private var additionalProperties: MutableMap = + mutableMapOf() - /** - * Alias for calling [conversionRateConfig] with - * `ConversionRateConfig.ofUnit(unit)`. - */ - fun conversionRateConfig(unit: UnitConversionRateConfig) = - conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } - /** - * Alias for calling [conversionRateConfig] with the following: - * ```kotlin - * UnitConversionRateConfig.builder() - * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) - * .unitConfig(unitConfig) - * .build() - * ``` - */ - fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = - conversionRateConfig( - UnitConversionRateConfig.builder() - .conversionRateType( - UnitConversionRateConfig.ConversionRateType.UNIT - ) - .unitConfig(unitConfig) - .build() - ) + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** - * Alias for calling [conversionRateConfig] with - * `ConversionRateConfig.ofTiered(tiered)`. - */ - fun conversionRateConfig(tiered: TieredConversionRateConfig) = - conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * Alias for calling [conversionRateConfig] with the following: - * ```kotlin - * TieredConversionRateConfig.builder() - * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) - * .tieredConfig(tieredConfig) - * .build() - * ``` - */ - fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = - conversionRateConfig( - TieredConversionRateConfig.builder() - .conversionRateType( - TieredConversionRateConfig.ConversionRateType.TIERED - ) - .tieredConfig(tieredConfig) - .build() - ) + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - /** - * Sets [Builder.currency] to an arbitrary JSON value. - * - * You should usually call [Builder.currency] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - /** For dimensional price: specifies a price group and dimension values */ - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? - ) = - dimensionalPriceConfiguration( - JsonField.ofNullable(dimensionalPriceConfiguration) - ) + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } - /** - * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.dimensionalPriceConfiguration] with a - * well-typed [NewDimensionalPriceConfiguration] value instead. This method is - * primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: JsonField - ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + private var validated: Boolean = false - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) + fun validate(): Metadata = apply { + if (validated) { + return@apply + } - /** - * Sets [Builder.externalPriceId] to an arbitrary JSON value. - * - * You should usually call [Builder.externalPriceId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun externalPriceId(externalPriceId: JsonField) = apply { - this.externalPriceId = externalPriceId + validated = true } - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = - fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } /** - * Alias for [Builder.fixedPriceQuantity]. + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * This unboxed primitive overload exists for backwards compatibility. + * Used for best match union deserialization. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } - /** - * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. - * - * You should usually call [Builder.fixedPriceQuantity] with a well-typed - * [Double] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { - this.fixedPriceQuantity = fixedPriceQuantity + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties } - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = - invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) - - /** - * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. - * - * You should usually call [Builder.invoiceGroupingKey] with a well-typed - * [String] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { - this.invoiceGroupingKey = invoiceGroupingKey - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are - * produced. If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: NewBillingCycleConfiguration? - ) = - invoicingCycleConfiguration( - JsonField.ofNullable(invoicingCycleConfiguration) - ) - - /** - * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.invoicingCycleConfiguration] with a - * well-typed [NewBillingCycleConfiguration] value instead. This method is - * primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * Sets [Builder.metadata] to an arbitrary JSON value. - * - * You should usually call [Builder.metadata] with a well-typed [Metadata] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - fun referenceId(referenceId: String?) = - referenceId(JsonField.ofNullable(referenceId)) - - /** - * Sets [Builder.referenceId] to an arbitrary JSON value. - * - * You should usually call [Builder.referenceId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun referenceId(referenceId: JsonField) = apply { - this.referenceId = referenceId - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + override fun hashCode(): Int = hashCode - /** - * Returns an immutable instance of [Percent]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```kotlin - * .cadence() - * .itemId() - * .name() - * .percentConfig() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Percent = - Percent( - checkRequired("cadence", cadence), - checkRequired("itemId", itemId), - modelType, - checkRequired("name", name), - checkRequired("percentConfig", percentConfig), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - conversionRateConfig, - currency, - dimensionalPriceConfiguration, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - additionalProperties.toMutableMap(), - ) + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" } - private var validated: Boolean = false - - fun validate(): Percent = apply { - if (validated) { - return@apply + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - cadence().validate() - itemId() - _modelType().let { - if (it != JsonValue.from("percent")) { - throw OrbInvalidDataException("'modelType' is invalid, received $it") - } - } - name() - percentConfig().validate() - billableMetricId() - billedInAdvance() - billingCycleConfiguration()?.validate() - conversionRate() - conversionRateConfig()?.validate() - currency() - dimensionalPriceConfiguration()?.validate() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration()?.validate() - metadata()?.validate() - referenceId() - validated = true + return other is TieredWithProration && + cadence == other.cadence && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + tieredWithProrationConfig == other.tieredWithProrationConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + modelType, + name, + tieredWithProrationConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties, + ) + } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (cadence.asKnown()?.validity() ?: 0) + - (if (itemId.asKnown() == null) 0 else 1) + - modelType.let { if (it == JsonValue.from("percent")) 1 else 0 } + - (if (name.asKnown() == null) 0 else 1) + - (percentConfig.asKnown()?.validity() ?: 0) + - (if (billableMetricId.asKnown() == null) 0 else 1) + - (if (billedInAdvance.asKnown() == null) 0 else 1) + - (billingCycleConfiguration.asKnown()?.validity() ?: 0) + - (if (conversionRate.asKnown() == null) 0 else 1) + - (conversionRateConfig.asKnown()?.validity() ?: 0) + - (if (currency.asKnown() == null) 0 else 1) + - (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + - (if (externalPriceId.asKnown() == null) 0 else 1) + - (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + - (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + - (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + - (metadata.asKnown()?.validity() ?: 0) + - (if (referenceId.asKnown() == null) 0 else 1) + override fun hashCode(): Int = hashCode - /** The cadence to bill for this price on. */ - class Cadence - @JsonCreator - private constructor(private val value: JsonField) : Enum { + override fun toString() = + "TieredWithProration{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredWithProrationConfig=$tieredWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value + class GroupedWithMinMaxThresholds + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val groupedWithMinMaxThresholdsConfig: + JsonField, + private val itemId: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { - companion object { + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("grouped_with_min_max_thresholds_config") + @ExcludeMissing + groupedWithMinMaxThresholdsConfig: + JsonField = + JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + groupedWithMinMaxThresholdsConfig, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + mutableMapOf(), + ) - val ANNUAL = of("annual") + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") - val SEMI_ANNUAL = of("semi_annual") + /** + * Configuration for grouped_with_min_max_thresholds pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupedWithMinMaxThresholdsConfig(): GroupedWithMinMaxThresholdsConfig = + groupedWithMinMaxThresholdsConfig.getRequired( + "grouped_with_min_max_thresholds_config" + ) - val MONTHLY = of("monthly") + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") - val QUARTERLY = of("quarterly") + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("grouped_with_min_max_thresholds") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType - val ONE_TIME = of("one_time") + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") - val CUSTOM = of("custom") + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = billableMetricId.getNullable("billable_metric_id") - fun of(value: String) = Cadence(JsonField.of(value)) - } + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") - /** An enum containing [Cadence]'s known values. */ - enum class Known { - ANNUAL, - SEMI_ANNUAL, - MONTHLY, - QUARTERLY, - ONE_TIME, - CUSTOM, - } + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") - /** - * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Cadence] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - ANNUAL, - SEMI_ANNUAL, - MONTHLY, - QUARTERLY, - ONE_TIME, - CUSTOM, - /** - * An enum member indicating that [Cadence] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - ANNUAL -> Value.ANNUAL - SEMI_ANNUAL -> Value.SEMI_ANNUAL - MONTHLY -> Value.MONTHLY - QUARTERLY -> Value.QUARTERLY - ONE_TIME -> Value.ONE_TIME - CUSTOM -> Value.CUSTOM - else -> Value._UNKNOWN - } + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - ANNUAL -> Known.ANNUAL - SEMI_ANNUAL -> Known.SEMI_ANNUAL - MONTHLY -> Known.MONTHLY - QUARTERLY -> Known.QUARTERLY - ONE_TIME -> Known.ONE_TIME - CUSTOM -> Known.CUSTOM - else -> throw OrbInvalidDataException("Unknown Cadence: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString() - ?: throw OrbInvalidDataException("Value is not a String") + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") - private var validated: Boolean = false + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") - fun validate(): Cadence = apply { - if (validated) { - return@apply - } + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") - known() - validated = true - } + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + invoiceGroupingKey.getNullable("invoice_grouping_key") - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") - return other is Cadence && value == other.value - } + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") - override fun hashCode() = value.hashCode() + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence - override fun toString() = value.toString() - } + /** + * Returns the raw JSON value of [groupedWithMinMaxThresholdsConfig]. + * + * Unlike [groupedWithMinMaxThresholdsConfig], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("grouped_with_min_max_thresholds_config") + @ExcludeMissing + fun _groupedWithMinMaxThresholdsConfig(): + JsonField = groupedWithMinMaxThresholdsConfig - /** Configuration for percent pricing */ - class PercentConfig - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val percent: JsonField, - private val additionalProperties: MutableMap, - ) { + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - @JsonCreator - private constructor( - @JsonProperty("percent") - @ExcludeMissing - percent: JsonField = JsonMissing.of() - ) : this(percent, mutableMapOf()) + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - /** - * What percent of the component subtotals to charge - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun percent(): Double = percent.getRequired("percent") + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId - /** - * Returns the raw JSON value of [percent]. - * - * Unlike [percent], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("percent") - @ExcludeMissing - fun _percent(): JsonField = percent + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate - fun toBuilder() = Builder().from(this) + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig - companion object { + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency - /** - * Returns a mutable builder for constructing an instance of - * [PercentConfig]. - * - * The following fields are required: - * ```kotlin - * .percent() - * ``` - */ - fun builder() = Builder() - } - - /** A builder for [PercentConfig]. */ - class Builder internal constructor() { + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration - private var percent: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId - internal fun from(percentConfig: PercentConfig) = apply { - percent = percentConfig.percent - additionalProperties = percentConfig.additionalProperties.toMutableMap() - } + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - /** What percent of the component subtotals to charge */ - fun percent(percent: Double) = percent(JsonField.of(percent)) + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - /** - * Sets [Builder.percent] to an arbitrary JSON value. - * - * You should usually call [Builder.percent] with a well-typed [Double] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun percent(percent: JsonField) = apply { this.percent = percent } + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun toBuilder() = Builder().from(this) - /** - * Returns an immutable instance of [PercentConfig]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```kotlin - * .percent() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): PercentConfig = - PercentConfig( - checkRequired("percent", percent), - additionalProperties.toMutableMap(), - ) - } + companion object { - private var validated: Boolean = false + /** + * Returns a mutable builder for constructing an instance of + * [GroupedWithMinMaxThresholds]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .groupedWithMinMaxThresholdsConfig() + * .itemId() + * .name() + * ``` + */ + fun builder() = Builder() + } - fun validate(): PercentConfig = apply { - if (validated) { - return@apply - } + /** A builder for [GroupedWithMinMaxThresholds]. */ + class Builder internal constructor() { - percent() - validated = true - } + private var cadence: JsonField? = null + private var groupedWithMinMaxThresholdsConfig: + JsonField? = + null + private var itemId: JsonField? = null + private var modelType: JsonValue = + JsonValue.from("grouped_with_min_max_thresholds") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false + internal fun from(groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds) = + apply { + cadence = groupedWithMinMaxThresholds.cadence + groupedWithMinMaxThresholdsConfig = + groupedWithMinMaxThresholds.groupedWithMinMaxThresholdsConfig + itemId = groupedWithMinMaxThresholds.itemId + modelType = groupedWithMinMaxThresholds.modelType + name = groupedWithMinMaxThresholds.name + billableMetricId = groupedWithMinMaxThresholds.billableMetricId + billedInAdvance = groupedWithMinMaxThresholds.billedInAdvance + billingCycleConfiguration = + groupedWithMinMaxThresholds.billingCycleConfiguration + conversionRate = groupedWithMinMaxThresholds.conversionRate + conversionRateConfig = groupedWithMinMaxThresholds.conversionRateConfig + currency = groupedWithMinMaxThresholds.currency + dimensionalPriceConfiguration = + groupedWithMinMaxThresholds.dimensionalPriceConfiguration + externalPriceId = groupedWithMinMaxThresholds.externalPriceId + fixedPriceQuantity = groupedWithMinMaxThresholds.fixedPriceQuantity + invoiceGroupingKey = groupedWithMinMaxThresholds.invoiceGroupingKey + invoicingCycleConfiguration = + groupedWithMinMaxThresholds.invoicingCycleConfiguration + metadata = groupedWithMinMaxThresholds.metadata + referenceId = groupedWithMinMaxThresholds.referenceId + additionalProperties = + groupedWithMinMaxThresholds.additionalProperties.toMutableMap() } + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + /** - * Returns a score indicating how many valid values are contained in this object - * recursively. + * Sets [Builder.cadence] to an arbitrary JSON value. * - * Used for best match union deserialization. + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. */ - internal fun validity(): Int = (if (percent.asKnown() == null) 0 else 1) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is PercentConfig && - percent == other.percent && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(percent, additionalProperties) - } + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - override fun hashCode(): Int = hashCode + /** Configuration for grouped_with_min_max_thresholds pricing */ + fun groupedWithMinMaxThresholdsConfig( + groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + ) = + groupedWithMinMaxThresholdsConfig( + JsonField.of(groupedWithMinMaxThresholdsConfig) + ) - override fun toString() = - "PercentConfig{percent=$percent, additionalProperties=$additionalProperties}" - } - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - class Metadata - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Metadata]. */ - fun builder() = Builder() + /** + * Sets [Builder.groupedWithMinMaxThresholdsConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.groupedWithMinMaxThresholdsConfig] with a + * well-typed [GroupedWithMinMaxThresholdsConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun groupedWithMinMaxThresholdsConfig( + groupedWithMinMaxThresholdsConfig: + JsonField + ) = apply { + this.groupedWithMinMaxThresholdsConfig = groupedWithMinMaxThresholdsConfig } - /** A builder for [Metadata]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = - mutableMapOf() - - internal fun from(metadata: Metadata) = apply { - additionalProperties = metadata.additionalProperties.toMutableMap() - } + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("grouped_with_min_max_thresholds") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) - /** - * Returns an immutable instance of [Metadata]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId } - private var validated: Boolean = false + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) - fun validate(): Metadata = apply { - if (validated) { - return@apply - } + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) - validated = true + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) /** - * Returns a score indicating how many valid values are contained in this object - * recursively. + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. * - * Used for best match union deserialization. + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. */ - internal fun validity(): Int = - additionalProperties.count { (_, value) -> - !value.isNull() && !value.isMissing() - } + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) - return other is Metadata && - additionalProperties == other.additionalProperties + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate } - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) - override fun hashCode(): Int = hashCode + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) - return other is Percent && - cadence == other.cadence && - itemId == other.itemId && - modelType == other.modelType && - name == other.name && - percentConfig == other.percentConfig && - billableMetricId == other.billableMetricId && - billedInAdvance == other.billedInAdvance && - billingCycleConfiguration == other.billingCycleConfiguration && - conversionRate == other.conversionRate && - conversionRateConfig == other.conversionRateConfig && - currency == other.currency && - dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && - externalPriceId == other.externalPriceId && - fixedPriceQuantity == other.fixedPriceQuantity && - invoiceGroupingKey == other.invoiceGroupingKey && - invoicingCycleConfiguration == other.invoicingCycleConfiguration && - metadata == other.metadata && - referenceId == other.referenceId && - additionalProperties == other.additionalProperties - } + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) - private val hashCode: Int by lazy { - Objects.hash( - cadence, - itemId, - modelType, - name, - percentConfig, - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - conversionRateConfig, - currency, - dimensionalPriceConfiguration, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - additionalProperties, - ) - } + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) - override fun hashCode(): Int = hashCode + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) - override fun toString() = - "Percent{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, percentConfig=$percentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" - } + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } - class EventOutput - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val cadence: JsonField, - private val eventOutputConfig: JsonField, - private val itemId: JsonField, - private val modelType: JsonValue, - private val name: JsonField, - private val billableMetricId: JsonField, - private val billedInAdvance: JsonField, - private val billingCycleConfiguration: JsonField, - private val conversionRate: JsonField, - private val conversionRateConfig: JsonField, - private val currency: JsonField, - private val dimensionalPriceConfiguration: - JsonField, - private val externalPriceId: JsonField, - private val fixedPriceQuantity: JsonField, - private val invoiceGroupingKey: JsonField, - private val invoicingCycleConfiguration: JsonField, - private val metadata: JsonField, - private val referenceId: JsonField, - private val additionalProperties: MutableMap, - ) { + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) - @JsonCreator - private constructor( - @JsonProperty("cadence") - @ExcludeMissing - cadence: JsonField = JsonMissing.of(), - @JsonProperty("event_output_config") - @ExcludeMissing - eventOutputConfig: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - modelType: JsonValue = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - name: JsonField = JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("conversion_rate_config") - @ExcludeMissing - conversionRateConfig: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - currency: JsonField = JsonMissing.of(), - @JsonProperty("dimensional_price_configuration") - @ExcludeMissing - dimensionalPriceConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - metadata: JsonField = JsonMissing.of(), - @JsonProperty("reference_id") - @ExcludeMissing - referenceId: JsonField = JsonMissing.of(), - ) : this( - cadence, - eventOutputConfig, - itemId, - modelType, - name, - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - conversionRateConfig, - currency, - dimensionalPriceConfiguration, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - mutableMapOf(), - ) + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } - /** - * The cadence to bill for this price on. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun cadence(): Cadence = cadence.getRequired("cadence") + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) - /** - * Configuration for event_output pricing - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun eventOutputConfig(): EventOutputConfig = - eventOutputConfig.getRequired("event_output_config") + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } - /** - * The id of the item the price will be associated with. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun itemId(): String = itemId.getRequired("item_id") + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) - /** - * The pricing model type - * - * Expected to always return the following: - * ```kotlin - * JsonValue.from("event_output") - * ``` - * - * However, this method can be useful for debugging and logging (e.g. if the server - * responded with an unexpected value). - */ - @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType - - /** - * The name of the price. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun name(): String = name.getRequired("name") - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun billableMetricId(): String? = billableMetricId.getNullable("billable_metric_id") - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun billingCycleConfiguration(): NewBillingCycleConfiguration? = - billingCycleConfiguration.getNullable("billing_cycle_configuration") + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) - /** - * The per unit conversion rate of the price currency to the invoicing currency. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } - /** - * The configuration for the rate of the price currency to the invoicing currency. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun conversionRateConfig(): ConversionRateConfig? = - conversionRateConfig.getNullable("conversion_rate_config") + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun currency(): String? = currency.getNullable("currency") + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } - /** - * For dimensional price: specifies a price group and dimension values - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = - dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) - /** - * An alias for the price. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun fixedPriceQuantity(): Double? = - fixedPriceQuantity.getNullable("fixed_price_quantity") + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - /** - * The property used to group this price on an invoice - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun invoiceGroupingKey(): String? = - invoiceGroupingKey.getNullable("invoice_grouping_key") + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun metadata(): Metadata? = metadata.getNullable("metadata") + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun referenceId(): String? = referenceId.getNullable("reference_id") + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** - * Returns the raw JSON value of [cadence]. - * - * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("cadence") - @ExcludeMissing - fun _cadence(): JsonField = cadence + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * Returns the raw JSON value of [eventOutputConfig]. - * - * Unlike [eventOutputConfig], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("event_output_config") - @ExcludeMissing - fun _eventOutputConfig(): JsonField = eventOutputConfig + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - /** - * Returns the raw JSON value of [itemId]. - * - * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - /** - * Returns the raw JSON value of [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - /** - * Returns the raw JSON value of [billableMetricId]. - * - * Unlike [billableMetricId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = billableMetricId + /** + * Returns an immutable instance of [GroupedWithMinMaxThresholds]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .groupedWithMinMaxThresholdsConfig() + * .itemId() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedWithMinMaxThresholds = + GroupedWithMinMaxThresholds( + checkRequired("cadence", cadence), + checkRequired( + "groupedWithMinMaxThresholdsConfig", + groupedWithMinMaxThresholdsConfig, + ), + checkRequired("itemId", itemId), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } - /** - * Returns the raw JSON value of [billedInAdvance]. - * - * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance + private var validated: Boolean = false - /** - * Returns the raw JSON value of [billingCycleConfiguration]. - * - * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration + fun validate(): GroupedWithMinMaxThresholds = apply { + if (validated) { + return@apply + } - /** - * Returns the raw JSON value of [conversionRate]. - * - * Unlike [conversionRate], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate + cadence().validate() + groupedWithMinMaxThresholdsConfig().validate() + itemId() + _modelType().let { + if (it != JsonValue.from("grouped_with_min_max_thresholds")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + metadata()?.validate() + referenceId() + validated = true + } - /** - * Returns the raw JSON value of [conversionRateConfig]. - * - * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("conversion_rate_config") - @ExcludeMissing - fun _conversionRateConfig(): JsonField = conversionRateConfig + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } /** - * Returns the raw JSON value of [currency]. + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * Unlike [currency], this method doesn't throw if the JSON field has an unexpected - * type. + * Used for best match union deserialization. */ - @JsonProperty("currency") - @ExcludeMissing - fun _currency(): JsonField = currency + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (groupedWithMinMaxThresholdsConfig.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + modelType.let { + if (it == JsonValue.from("grouped_with_min_max_thresholds")) 1 else 0 + } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) - /** - * Returns the raw JSON value of [dimensionalPriceConfiguration]. - * - * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON - * field has an unexpected type. - */ - @JsonProperty("dimensional_price_configuration") - @ExcludeMissing - fun _dimensionalPriceConfiguration(): JsonField = - dimensionalPriceConfiguration + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { - /** - * Returns the raw JSON value of [externalPriceId]. - * - * Unlike [externalPriceId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value - /** - * Returns the raw JSON value of [fixedPriceQuantity]. - * - * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + companion object { - /** - * Returns the raw JSON value of [invoiceGroupingKey]. - * - * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + val ANNUAL = of("annual") - /** - * Returns the raw JSON value of [invoicingCycleConfiguration]. - * - * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration + val SEMI_ANNUAL = of("semi_annual") - /** - * Returns the raw JSON value of [metadata]. - * - * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata + val MONTHLY = of("monthly") - /** - * Returns the raw JSON value of [referenceId]. - * - * Unlike [referenceId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("reference_id") - @ExcludeMissing - fun _referenceId(): JsonField = referenceId + val QUARTERLY = of("quarterly") - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + val ONE_TIME = of("one_time") - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + val CUSTOM = of("custom") - fun toBuilder() = Builder().from(this) + fun of(value: String) = Cadence(JsonField.of(value)) + } - companion object { + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } /** - * Returns a mutable builder for constructing an instance of [EventOutput]. + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. * - * The following fields are required: - * ```kotlin - * .cadence() - * .eventOutputConfig() - * .itemId() - * .name() - * ``` + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. */ - fun builder() = Builder() - } - - /** A builder for [EventOutput]. */ - class Builder internal constructor() { - - private var cadence: JsonField? = null - private var eventOutputConfig: JsonField? = null - private var itemId: JsonField? = null - private var modelType: JsonValue = JsonValue.from("event_output") - private var name: JsonField? = null - private var billableMetricId: JsonField = JsonMissing.of() - private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var conversionRateConfig: JsonField = - JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var dimensionalPriceConfiguration: - JsonField = - JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: - JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var referenceId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(eventOutput: EventOutput) = apply { - cadence = eventOutput.cadence - eventOutputConfig = eventOutput.eventOutputConfig - itemId = eventOutput.itemId - modelType = eventOutput.modelType - name = eventOutput.name - billableMetricId = eventOutput.billableMetricId - billedInAdvance = eventOutput.billedInAdvance - billingCycleConfiguration = eventOutput.billingCycleConfiguration - conversionRate = eventOutput.conversionRate - conversionRateConfig = eventOutput.conversionRateConfig - currency = eventOutput.currency - dimensionalPriceConfiguration = eventOutput.dimensionalPriceConfiguration - externalPriceId = eventOutput.externalPriceId - fixedPriceQuantity = eventOutput.fixedPriceQuantity - invoiceGroupingKey = eventOutput.invoiceGroupingKey - invoicingCycleConfiguration = eventOutput.invoicingCycleConfiguration - metadata = eventOutput.metadata - referenceId = eventOutput.referenceId - additionalProperties = eventOutput.additionalProperties.toMutableMap() + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, } - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - /** - * Sets [Builder.cadence] to an arbitrary JSON value. + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. * - * You should usually call [Builder.cadence] with a well-typed [Cadence] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. */ - fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - - /** Configuration for event_output pricing */ - fun eventOutputConfig(eventOutputConfig: EventOutputConfig) = - eventOutputConfig(JsonField.of(eventOutputConfig)) + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } /** - * Sets [Builder.eventOutputConfig] to an arbitrary JSON value. + * Returns an enum member corresponding to this class instance's value. * - * You should usually call [Builder.eventOutputConfig] with a well-typed - * [EventOutputConfig] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun eventOutputConfig(eventOutputConfig: JsonField) = apply { - this.eventOutputConfig = eventOutputConfig - } - - /** The id of the item the price will be associated with. */ - fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - - /** - * Sets [Builder.itemId] to an arbitrary JSON value. + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. * - * You should usually call [Builder.itemId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } /** - * Sets the field to an arbitrary JSON value. + * Returns this class instance's primitive wire representation. * - * It is usually unnecessary to call this method because the field defaults to - * the following: - * ```kotlin - * JsonValue.from("event_output") - * ``` + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. * - * This method is primarily for setting the field to an undocumented or not yet - * supported value. + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. */ - fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } /** - * Sets [Builder.name] to an arbitrary JSON value. + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * You should usually call [Builder.name] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. + * Used for best match union deserialization. */ - fun name(name: JsonField) = apply { this.name = name } + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: String?) = - billableMetricId(JsonField.ofNullable(billableMetricId)) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Configuration for grouped_with_min_max_thresholds pricing */ + class GroupedWithMinMaxThresholdsConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val groupingKey: JsonField, + private val maximumCharge: JsonField, + private val minimumCharge: JsonField, + private val perUnitRate: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("maximum_charge") + @ExcludeMissing + maximumCharge: JsonField = JsonMissing.of(), + @JsonProperty("minimum_charge") + @ExcludeMissing + minimumCharge: JsonField = JsonMissing.of(), + @JsonProperty("per_unit_rate") + @ExcludeMissing + perUnitRate: JsonField = JsonMissing.of(), + ) : this(groupingKey, maximumCharge, minimumCharge, perUnitRate, mutableMapOf()) /** - * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * The event property used to group before applying thresholds * - * You should usually call [Builder.billableMetricId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). */ - fun billableMetricId(billableMetricId: JsonField) = apply { - this.billableMetricId = billableMetricId - } + fun groupingKey(): String = groupingKey.getRequired("grouping_key") /** - * If the Price represents a fixed cost, the price will be billed in-advance if - * this is true, and in-arrears if this is false. + * The maximum amount to charge each group + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). */ - fun billedInAdvance(billedInAdvance: Boolean?) = - billedInAdvance(JsonField.ofNullable(billedInAdvance)) + fun maximumCharge(): String = maximumCharge.getRequired("maximum_charge") /** - * Alias for [Builder.billedInAdvance]. + * The minimum amount to charge each group, regardless of usage * - * This unboxed primitive overload exists for backwards compatibility. + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). */ - fun billedInAdvance(billedInAdvance: Boolean) = - billedInAdvance(billedInAdvance as Boolean?) + fun minimumCharge(): String = minimumCharge.getRequired("minimum_charge") /** - * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * The base price charged per group * - * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun billedInAdvance(billedInAdvance: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). */ - fun billingCycleConfiguration( - billingCycleConfiguration: NewBillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + fun perUnitRate(): String = perUnitRate.getRequired("per_unit_rate") /** - * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * Returns the raw JSON value of [groupingKey]. * - * You should usually call [Builder.billingCycleConfiguration] with a well-typed - * [NewBillingCycleConfiguration] value instead. This method is primarily for - * setting the field to an undocumented or not yet supported value. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: JsonField - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } - - /** - * The per unit conversion rate of the price currency to the invoicing currency. + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. */ - fun conversionRate(conversionRate: Double?) = - conversionRate(JsonField.ofNullable(conversionRate)) + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey /** - * Alias for [Builder.conversionRate]. + * Returns the raw JSON value of [maximumCharge]. * - * This unboxed primitive overload exists for backwards compatibility. + * Unlike [maximumCharge], this method doesn't throw if the JSON field has an + * unexpected type. */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) + @JsonProperty("maximum_charge") + @ExcludeMissing + fun _maximumCharge(): JsonField = maximumCharge /** - * Sets [Builder.conversionRate] to an arbitrary JSON value. + * Returns the raw JSON value of [minimumCharge]. * - * You should usually call [Builder.conversionRate] with a well-typed [Double] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** - * The configuration for the rate of the price currency to the invoicing - * currency. + * Unlike [minimumCharge], this method doesn't throw if the JSON field has an + * unexpected type. */ - fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = - conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + @JsonProperty("minimum_charge") + @ExcludeMissing + fun _minimumCharge(): JsonField = minimumCharge /** - * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * Returns the raw JSON value of [perUnitRate]. * - * You should usually call [Builder.conversionRateConfig] with a well-typed - * [ConversionRateConfig] value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. + * Unlike [perUnitRate], this method doesn't throw if the JSON field has an + * unexpected type. */ - fun conversionRateConfig( - conversionRateConfig: JsonField - ) = apply { this.conversionRateConfig = conversionRateConfig } + @JsonProperty("per_unit_rate") + @ExcludeMissing + fun _perUnitRate(): JsonField = perUnitRate - /** - * Alias for calling [conversionRateConfig] with - * `ConversionRateConfig.ofUnit(unit)`. - */ - fun conversionRateConfig(unit: UnitConversionRateConfig) = - conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - /** - * Alias for calling [conversionRateConfig] with the following: - * ```kotlin - * UnitConversionRateConfig.builder() - * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) - * .unitConfig(unitConfig) - * .build() - * ``` - */ - fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = - conversionRateConfig( - UnitConversionRateConfig.builder() - .conversionRateType( - UnitConversionRateConfig.ConversionRateType.UNIT - ) - .unitConfig(unitConfig) - .build() - ) + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - /** - * Alias for calling [conversionRateConfig] with - * `ConversionRateConfig.ofTiered(tiered)`. - */ - fun conversionRateConfig(tiered: TieredConversionRateConfig) = - conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + fun toBuilder() = Builder().from(this) - /** - * Alias for calling [conversionRateConfig] with the following: - * ```kotlin - * TieredConversionRateConfig.builder() - * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) - * .tieredConfig(tieredConfig) - * .build() - * ``` - */ - fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = - conversionRateConfig( - TieredConversionRateConfig.builder() - .conversionRateType( - TieredConversionRateConfig.ConversionRateType.TIERED - ) - .tieredConfig(tieredConfig) - .build() - ) + companion object { - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + /** + * Returns a mutable builder for constructing an instance of + * [GroupedWithMinMaxThresholdsConfig]. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .maximumCharge() + * .minimumCharge() + * .perUnitRate() + * ``` + */ + fun builder() = Builder() + } - /** - * Sets [Builder.currency] to an arbitrary JSON value. - * - * You should usually call [Builder.currency] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } + /** A builder for [GroupedWithMinMaxThresholdsConfig]. */ + class Builder internal constructor() { - /** For dimensional price: specifies a price group and dimension values */ - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? - ) = - dimensionalPriceConfiguration( - JsonField.ofNullable(dimensionalPriceConfiguration) - ) + private var groupingKey: JsonField? = null + private var maximumCharge: JsonField? = null + private var minimumCharge: JsonField? = null + private var perUnitRate: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() - /** - * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.dimensionalPriceConfiguration] with a - * well-typed [NewDimensionalPriceConfiguration] value instead. This method is - * primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: JsonField - ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + internal fun from( + groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + ) = apply { + groupingKey = groupedWithMinMaxThresholdsConfig.groupingKey + maximumCharge = groupedWithMinMaxThresholdsConfig.maximumCharge + minimumCharge = groupedWithMinMaxThresholdsConfig.minimumCharge + perUnitRate = groupedWithMinMaxThresholdsConfig.perUnitRate + additionalProperties = + groupedWithMinMaxThresholdsConfig.additionalProperties + .toMutableMap() + } - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) + /** The event property used to group before applying thresholds */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) - /** - * Sets [Builder.externalPriceId] to an arbitrary JSON value. - * - * You should usually call [Builder.externalPriceId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun externalPriceId(externalPriceId: JsonField) = apply { - this.externalPriceId = externalPriceId - } + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = - fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + /** The maximum amount to charge each group */ + fun maximumCharge(maximumCharge: String) = + maximumCharge(JsonField.of(maximumCharge)) - /** - * Alias for [Builder.fixedPriceQuantity]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) + /** + * Sets [Builder.maximumCharge] to an arbitrary JSON value. + * + * You should usually call [Builder.maximumCharge] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun maximumCharge(maximumCharge: JsonField) = apply { + this.maximumCharge = maximumCharge + } - /** - * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. - * - * You should usually call [Builder.fixedPriceQuantity] with a well-typed - * [Double] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + /** The minimum amount to charge each group, regardless of usage */ + fun minimumCharge(minimumCharge: String) = + minimumCharge(JsonField.of(minimumCharge)) - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = - invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + /** + * Sets [Builder.minimumCharge] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumCharge] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun minimumCharge(minimumCharge: JsonField) = apply { + this.minimumCharge = minimumCharge + } - /** - * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. - * - * You should usually call [Builder.invoiceGroupingKey] with a well-typed - * [String] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { - this.invoiceGroupingKey = invoiceGroupingKey - } + /** The base price charged per group */ + fun perUnitRate(perUnitRate: String) = + perUnitRate(JsonField.of(perUnitRate)) - /** - * Within each billing cycle, specifies the cadence at which invoices are - * produced. If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: NewBillingCycleConfiguration? - ) = - invoicingCycleConfiguration( - JsonField.ofNullable(invoicingCycleConfiguration) - ) + /** + * Sets [Builder.perUnitRate] to an arbitrary JSON value. + * + * You should usually call [Builder.perUnitRate] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun perUnitRate(perUnitRate: JsonField) = apply { + this.perUnitRate = perUnitRate + } - /** - * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.invoicingCycleConfiguration] with a - * well-typed [NewBillingCycleConfiguration] value instead. This method is - * primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * Sets [Builder.metadata] to an arbitrary JSON value. - * - * You should usually call [Builder.metadata] with a well-typed [Metadata] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - fun referenceId(referenceId: String?) = - referenceId(JsonField.ofNullable(referenceId)) + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - /** - * Sets [Builder.referenceId] to an arbitrary JSON value. - * - * You should usually call [Builder.referenceId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun referenceId(referenceId: JsonField) = apply { - this.referenceId = referenceId - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) + /** + * Returns an immutable instance of [GroupedWithMinMaxThresholdsConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .maximumCharge() + * .minimumCharge() + * .perUnitRate() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedWithMinMaxThresholdsConfig = + GroupedWithMinMaxThresholdsConfig( + checkRequired("groupingKey", groupingKey), + checkRequired("maximumCharge", maximumCharge), + checkRequired("minimumCharge", minimumCharge), + checkRequired("perUnitRate", perUnitRate), + additionalProperties.toMutableMap(), + ) } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + private var validated: Boolean = false - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) + fun validate(): GroupedWithMinMaxThresholdsConfig = apply { + if (validated) { + return@apply } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) + groupingKey() + maximumCharge() + minimumCharge() + perUnitRate() + validated = true } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } /** - * Returns an immutable instance of [EventOutput]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```kotlin - * .cadence() - * .eventOutputConfig() - * .itemId() - * .name() - * ``` + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * @throws IllegalStateException if any required field is unset. + * Used for best match union deserialization. */ - fun build(): EventOutput = - EventOutput( - checkRequired("cadence", cadence), - checkRequired("eventOutputConfig", eventOutputConfig), - checkRequired("itemId", itemId), - modelType, - checkRequired("name", name), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - conversionRateConfig, - currency, - dimensionalPriceConfiguration, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - additionalProperties.toMutableMap(), - ) - } + internal fun validity(): Int = + (if (groupingKey.asKnown() == null) 0 else 1) + + (if (maximumCharge.asKnown() == null) 0 else 1) + + (if (minimumCharge.asKnown() == null) 0 else 1) + + (if (perUnitRate.asKnown() == null) 0 else 1) - private var validated: Boolean = false + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun validate(): EventOutput = apply { - if (validated) { - return@apply + return other is GroupedWithMinMaxThresholdsConfig && + groupingKey == other.groupingKey && + maximumCharge == other.maximumCharge && + minimumCharge == other.minimumCharge && + perUnitRate == other.perUnitRate && + additionalProperties == other.additionalProperties } - cadence().validate() - eventOutputConfig().validate() - itemId() - _modelType().let { - if (it != JsonValue.from("event_output")) { - throw OrbInvalidDataException("'modelType' is invalid, received $it") - } + private val hashCode: Int by lazy { + Objects.hash( + groupingKey, + maximumCharge, + minimumCharge, + perUnitRate, + additionalProperties, + ) } - name() - billableMetricId() - billedInAdvance() - billingCycleConfiguration()?.validate() - conversionRate() - conversionRateConfig()?.validate() - currency() - dimensionalPriceConfiguration()?.validate() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration()?.validate() - metadata()?.validate() - referenceId() - validated = true - } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedWithMinMaxThresholdsConfig{groupingKey=$groupingKey, maximumCharge=$maximumCharge, minimumCharge=$minimumCharge, perUnitRate=$perUnitRate, additionalProperties=$additionalProperties}" + } /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. */ - internal fun validity(): Int = - (cadence.asKnown()?.validity() ?: 0) + - (eventOutputConfig.asKnown()?.validity() ?: 0) + - (if (itemId.asKnown() == null) 0 else 1) + - modelType.let { if (it == JsonValue.from("event_output")) 1 else 0 } + - (if (name.asKnown() == null) 0 else 1) + - (if (billableMetricId.asKnown() == null) 0 else 1) + - (if (billedInAdvance.asKnown() == null) 0 else 1) + - (billingCycleConfiguration.asKnown()?.validity() ?: 0) + - (if (conversionRate.asKnown() == null) 0 else 1) + - (conversionRateConfig.asKnown()?.validity() ?: 0) + - (if (currency.asKnown() == null) 0 else 1) + - (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + - (if (externalPriceId.asKnown() == null) 0 else 1) + - (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + - (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + - (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + - (metadata.asKnown()?.validity() ?: 0) + - (if (referenceId.asKnown() == null) 0 else 1) - - /** The cadence to bill for this price on. */ - class Cadence + class Metadata @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ + private constructor( @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value + private val additionalProperties: Map + ) { - companion object { + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties - val ANNUAL = of("annual") + fun toBuilder() = Builder().from(this) - val SEMI_ANNUAL = of("semi_annual") + companion object { - val MONTHLY = of("monthly") + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } - val QUARTERLY = of("quarterly") + /** A builder for [Metadata]. */ + class Builder internal constructor() { - val ONE_TIME = of("one_time") + private var additionalProperties: MutableMap = + mutableMapOf() - val CUSTOM = of("custom") + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } - fun of(value: String) = Cadence(JsonField.of(value)) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** An enum containing [Cadence]'s known values. */ - enum class Known { - ANNUAL, - SEMI_ANNUAL, - MONTHLY, - QUARTERLY, - ONE_TIME, - CUSTOM, - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Cadence] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - ANNUAL, - SEMI_ANNUAL, - MONTHLY, - QUARTERLY, - ONE_TIME, - CUSTOM, - /** - * An enum member indicating that [Cadence] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - ANNUAL -> Value.ANNUAL - SEMI_ANNUAL -> Value.SEMI_ANNUAL - MONTHLY -> Value.MONTHLY - QUARTERLY -> Value.QUARTERLY - ONE_TIME -> Value.ONE_TIME - CUSTOM -> Value.CUSTOM - else -> Value._UNKNOWN + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) } - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - ANNUAL -> Known.ANNUAL - SEMI_ANNUAL -> Known.SEMI_ANNUAL - MONTHLY -> Known.MONTHLY - QUARTERLY -> Known.QUARTERLY - ONE_TIME -> Known.ONE_TIME - CUSTOM -> Known.CUSTOM - else -> throw OrbInvalidDataException("Unknown Cadence: $value") + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) } - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString() - ?: throw OrbInvalidDataException("Value is not a String") + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } private var validated: Boolean = false - fun validate(): Cadence = apply { + fun validate(): Metadata = apply { if (validated) { return@apply } - known() validated = true } @@ -12195,2221 +11507,4982 @@ private constructor( * * Used for best match union deserialization. */ - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is Cadence && value == other.value + return other is Metadata && + additionalProperties == other.additionalProperties } - override fun hashCode() = value.hashCode() + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - override fun toString() = value.toString() - } + override fun hashCode(): Int = hashCode - /** Configuration for event_output pricing */ - class EventOutputConfig - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val unitRatingKey: JsonField, - private val groupingKey: JsonField, - private val additionalProperties: MutableMap, - ) { + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } - @JsonCreator - private constructor( - @JsonProperty("unit_rating_key") - @ExcludeMissing - unitRatingKey: JsonField = JsonMissing.of(), - @JsonProperty("grouping_key") - @ExcludeMissing - groupingKey: JsonField = JsonMissing.of(), - ) : this(unitRatingKey, groupingKey, mutableMapOf()) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * The key in the event data to extract the unit rate from. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun unitRatingKey(): String = unitRatingKey.getRequired("unit_rating_key") + return other is GroupedWithMinMaxThresholds && + cadence == other.cadence && + groupedWithMinMaxThresholdsConfig == + other.groupedWithMinMaxThresholdsConfig && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } - /** - * An optional key in the event data to group by (e.g., event ID). All events - * will also be grouped by their unit rate. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun groupingKey(): String? = groupingKey.getNullable("grouping_key") + private val hashCode: Int by lazy { + Objects.hash( + cadence, + groupedWithMinMaxThresholdsConfig, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties, + ) + } - /** - * Returns the raw JSON value of [unitRatingKey]. - * - * Unlike [unitRatingKey], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("unit_rating_key") - @ExcludeMissing - fun _unitRatingKey(): JsonField = unitRatingKey + override fun hashCode(): Int = hashCode - /** - * Returns the raw JSON value of [groupingKey]. - * - * Unlike [groupingKey], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("grouping_key") - @ExcludeMissing - fun _groupingKey(): JsonField = groupingKey + override fun toString() = + "GroupedWithMinMaxThresholds{cadence=$cadence, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + class Percent + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val percentConfig: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { - @JsonAnyGetter + @JsonCreator + private constructor( + @JsonProperty("cadence") @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("percent_config") + @ExcludeMissing + percentConfig: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + modelType, + name, + percentConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + mutableMapOf(), + ) - companion object { + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") - /** - * Returns a mutable builder for constructing an instance of - * [EventOutputConfig]. - * - * The following fields are required: - * ```kotlin - * .unitRatingKey() - * ``` - */ - fun builder() = Builder() - } + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") - /** A builder for [EventOutputConfig]. */ - class Builder internal constructor() { + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("percent") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType - private var unitRatingKey: JsonField? = null - private var groupingKey: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") - internal fun from(eventOutputConfig: EventOutputConfig) = apply { - unitRatingKey = eventOutputConfig.unitRatingKey - groupingKey = eventOutputConfig.groupingKey - additionalProperties = - eventOutputConfig.additionalProperties.toMutableMap() - } + /** + * Configuration for percent pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun percentConfig(): PercentConfig = percentConfig.getRequired("percent_config") - /** The key in the event data to extract the unit rate from. */ - fun unitRatingKey(unitRatingKey: String) = - unitRatingKey(JsonField.of(unitRatingKey)) + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = billableMetricId.getNullable("billable_metric_id") - /** - * Sets [Builder.unitRatingKey] to an arbitrary JSON value. - * - * You should usually call [Builder.unitRatingKey] with a well-typed - * [String] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun unitRatingKey(unitRatingKey: JsonField) = apply { - this.unitRatingKey = unitRatingKey - } + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") - /** - * An optional key in the event data to group by (e.g., event ID). All - * events will also be grouped by their unit rate. - */ - fun groupingKey(groupingKey: String?) = - groupingKey(JsonField.ofNullable(groupingKey)) - - /** - * Sets [Builder.groupingKey] to an arbitrary JSON value. - * - * You should usually call [Builder.groupingKey] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun groupingKey(groupingKey: JsonField) = apply { - this.groupingKey = groupingKey - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [EventOutputConfig]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```kotlin - * .unitRatingKey() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): EventOutputConfig = - EventOutputConfig( - checkRequired("unitRatingKey", unitRatingKey), - groupingKey, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): EventOutputConfig = apply { - if (validated) { - return@apply - } + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") - unitRatingKey() - groupingKey() - validated = true - } + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (if (unitRatingKey.asKnown() == null) 0 else 1) + - (if (groupingKey.asKnown() == null) 0 else 1) + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") - return other is EventOutputConfig && - unitRatingKey == other.unitRatingKey && - groupingKey == other.groupingKey && - additionalProperties == other.additionalProperties - } + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") - private val hashCode: Int by lazy { - Objects.hash(unitRatingKey, groupingKey, additionalProperties) - } + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") - override fun hashCode(): Int = hashCode + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + invoiceGroupingKey.getNullable("invoice_grouping_key") - override fun toString() = - "EventOutputConfig{unitRatingKey=$unitRatingKey, groupingKey=$groupingKey, additionalProperties=$additionalProperties}" - } + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). */ - class Metadata - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) + fun metadata(): Metadata? = metadata.getNullable("metadata") - companion object { + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") - /** Returns a mutable builder for constructing an instance of [Metadata]. */ - fun builder() = Builder() - } + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence - /** A builder for [Metadata]. */ - class Builder internal constructor() { + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - private var additionalProperties: MutableMap = - mutableMapOf() + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - internal fun from(metadata: Metadata) = apply { - additionalProperties = metadata.additionalProperties.toMutableMap() - } + /** + * Returns the raw JSON value of [percentConfig]. + * + * Unlike [percentConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("percent_config") + @ExcludeMissing + fun _percentConfig(): JsonField = percentConfig - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration - /** - * Returns an immutable instance of [Metadata]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate - private var validated: Boolean = false + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig - fun validate(): Metadata = apply { - if (validated) { - return@apply - } + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency - validated = true - } + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - additionalProperties.count { (_, value) -> - !value.isNull() && !value.isMissing() - } + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - return other is Metadata && - additionalProperties == other.additionalProperties - } + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata - override fun hashCode(): Int = hashCode + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is EventOutput && - cadence == other.cadence && - eventOutputConfig == other.eventOutputConfig && - itemId == other.itemId && - modelType == other.modelType && - name == other.name && - billableMetricId == other.billableMetricId && - billedInAdvance == other.billedInAdvance && - billingCycleConfiguration == other.billingCycleConfiguration && - conversionRate == other.conversionRate && - conversionRateConfig == other.conversionRateConfig && - currency == other.currency && - dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && - externalPriceId == other.externalPriceId && - fixedPriceQuantity == other.fixedPriceQuantity && - invoiceGroupingKey == other.invoiceGroupingKey && - invoicingCycleConfiguration == other.invoicingCycleConfiguration && - metadata == other.metadata && - referenceId == other.referenceId && - additionalProperties == other.additionalProperties - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - private val hashCode: Int by lazy { - Objects.hash( - cadence, - eventOutputConfig, - itemId, - modelType, - name, - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - conversionRateConfig, - currency, - dimensionalPriceConfiguration, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - additionalProperties, - ) - } + fun toBuilder() = Builder().from(this) - override fun hashCode(): Int = hashCode + companion object { - override fun toString() = - "EventOutput{cadence=$cadence, eventOutputConfig=$eventOutputConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" - } - } + /** + * Returns a mutable builder for constructing an instance of [Percent]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .name() + * .percentConfig() + * ``` + */ + fun builder() = Builder() + } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** A builder for [Percent]. */ + class Builder internal constructor() { - return other is AddPrice && - allocationPrice == other.allocationPrice && - discounts == other.discounts && - endDate == other.endDate && - externalPriceId == other.externalPriceId && - maximumAmount == other.maximumAmount && - minimumAmount == other.minimumAmount && - planPhaseOrder == other.planPhaseOrder && - price == other.price && - priceId == other.priceId && - startDate == other.startDate && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - allocationPrice, - discounts, - endDate, - externalPriceId, - maximumAmount, - minimumAmount, - planPhaseOrder, - price, - priceId, - startDate, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonValue = JsonValue.from("percent") + private var name: JsonField? = null + private var percentConfig: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - override fun toString() = - "AddPrice{allocationPrice=$allocationPrice, discounts=$discounts, endDate=$endDate, externalPriceId=$externalPriceId, maximumAmount=$maximumAmount, minimumAmount=$minimumAmount, planPhaseOrder=$planPhaseOrder, price=$price, priceId=$priceId, startDate=$startDate, additionalProperties=$additionalProperties}" - } + internal fun from(percent: Percent) = apply { + cadence = percent.cadence + itemId = percent.itemId + modelType = percent.modelType + name = percent.name + percentConfig = percent.percentConfig + billableMetricId = percent.billableMetricId + billedInAdvance = percent.billedInAdvance + billingCycleConfiguration = percent.billingCycleConfiguration + conversionRate = percent.conversionRate + conversionRateConfig = percent.conversionRateConfig + currency = percent.currency + dimensionalPriceConfiguration = percent.dimensionalPriceConfiguration + externalPriceId = percent.externalPriceId + fixedPriceQuantity = percent.fixedPriceQuantity + invoiceGroupingKey = percent.invoiceGroupingKey + invoicingCycleConfiguration = percent.invoicingCycleConfiguration + metadata = percent.metadata + referenceId = percent.referenceId + additionalProperties = percent.additionalProperties.toMutableMap() + } - @Deprecated("deprecated") - class ExternalMarketplace - @JsonCreator - private constructor(private val value: JsonField) : Enum { + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API may respond with new members that the SDK is - * unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - companion object { + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - val GOOGLE = of("google") + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - val AWS = of("aws") + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("percent") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } - val AZURE = of("azure") + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) - fun of(value: String) = ExternalMarketplace(JsonField.of(value)) - } + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } - /** An enum containing [ExternalMarketplace]'s known values. */ - enum class Known { - GOOGLE, - AWS, - AZURE, - } + /** Configuration for percent pricing */ + fun percentConfig(percentConfig: PercentConfig) = + percentConfig(JsonField.of(percentConfig)) - /** - * An enum containing [ExternalMarketplace]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [ExternalMarketplace] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if the - * SDK is on an older version than the API, then the API may respond with new members that - * the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - GOOGLE, - AWS, - AZURE, - /** - * An enum member indicating that [ExternalMarketplace] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } + /** + * Sets [Builder.percentConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.percentConfig] with a well-typed + * [PercentConfig] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun percentConfig(percentConfig: JsonField) = apply { + this.percentConfig = percentConfig + } - /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you want - * to throw for the unknown case. - */ - fun value(): Value = - when (this) { - GOOGLE -> Value.GOOGLE - AWS -> Value.AWS - AZURE -> Value.AZURE - else -> Value._UNKNOWN - } + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and don't - * want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known member. - */ - fun known(): Known = - when (this) { - GOOGLE -> Known.GOOGLE - AWS -> Known.AWS - AZURE -> Known.AZURE - else -> throw OrbInvalidDataException("Unknown ExternalMarketplace: $value") - } + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the expected - * primitive type. - */ - fun asString(): String = - _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) - private var validated: Boolean = false + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) - fun validate(): ExternalMarketplace = apply { - if (validated) { - return@apply - } + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } - known() - validated = true - } + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) - return other is ExternalMarketplace && value == other.value - } + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } - override fun hashCode() = value.hashCode() + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) - override fun toString() = value.toString() - } + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by setting - * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to - * `null`. - */ - class Metadata - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) - fun toBuilder() = Builder().from(this) + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) - companion object { + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) - /** Returns a mutable builder for constructing an instance of [Metadata]. */ - fun builder() = Builder() - } + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) - /** A builder for [Metadata]. */ - class Builder internal constructor() { + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } - private var additionalProperties: MutableMap = mutableMapOf() + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) - internal fun from(metadata: Metadata) = apply { - additionalProperties = metadata.additionalProperties.toMutableMap() - } + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } - /** - * Returns an immutable instance of [Metadata]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) - private var validated: Boolean = false + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - return other is Metadata && additionalProperties == other.additionalProperties - } + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) - override fun hashCode(): Int = hashCode + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - class RemoveAdjustment - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val adjustmentId: JsonField, - private val additionalProperties: MutableMap, - ) { + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - @JsonCreator - private constructor( - @JsonProperty("adjustment_id") - @ExcludeMissing - adjustmentId: JsonField = JsonMissing.of() - ) : this(adjustmentId, mutableMapOf()) + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - /** - * The id of the adjustment to remove on the subscription. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun adjustmentId(): String = adjustmentId.getRequired("adjustment_id") + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - /** - * Returns the raw JSON value of [adjustmentId]. - * - * Unlike [adjustmentId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("adjustment_id") - @ExcludeMissing - fun _adjustmentId(): JsonField = adjustmentId + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** + * Returns an immutable instance of [Percent]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .name() + * .percentConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Percent = + Percent( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + modelType, + checkRequired("name", name), + checkRequired("percentConfig", percentConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + private var validated: Boolean = false - fun toBuilder() = Builder().from(this) + fun validate(): Percent = apply { + if (validated) { + return@apply + } - companion object { + cadence().validate() + itemId() + _modelType().let { + if (it != JsonValue.from("percent")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + percentConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + metadata()?.validate() + referenceId() + validated = true + } - /** - * Returns a mutable builder for constructing an instance of [RemoveAdjustment]. - * - * The following fields are required: - * ```kotlin - * .adjustmentId() - * ``` - */ - fun builder() = Builder() - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - /** A builder for [RemoveAdjustment]. */ - class Builder internal constructor() { + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + modelType.let { if (it == JsonValue.from("percent")) 1 else 0 } + + (if (name.asKnown() == null) 0 else 1) + + (percentConfig.asKnown()?.validity() ?: 0) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) - private var adjustmentId: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { - internal fun from(removeAdjustment: RemoveAdjustment) = apply { - adjustmentId = removeAdjustment.adjustmentId - additionalProperties = removeAdjustment.additionalProperties.toMutableMap() - } + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value - /** The id of the adjustment to remove on the subscription. */ - fun adjustmentId(adjustmentId: String) = adjustmentId(JsonField.of(adjustmentId)) + companion object { - /** - * Sets [Builder.adjustmentId] to an arbitrary JSON value. - * - * You should usually call [Builder.adjustmentId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun adjustmentId(adjustmentId: JsonField) = apply { - this.adjustmentId = adjustmentId - } + val ANNUAL = of("annual") - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + val SEMI_ANNUAL = of("semi_annual") - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + val MONTHLY = of("monthly") - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + val QUARTERLY = of("quarterly") - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + val ONE_TIME = of("one_time") - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + val CUSTOM = of("custom") - /** - * Returns an immutable instance of [RemoveAdjustment]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```kotlin - * .adjustmentId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): RemoveAdjustment = - RemoveAdjustment( - checkRequired("adjustmentId", adjustmentId), - additionalProperties.toMutableMap(), - ) - } + fun of(value: String) = Cadence(JsonField.of(value)) + } - private var validated: Boolean = false + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } - fun validate(): RemoveAdjustment = apply { - if (validated) { - return@apply - } + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } - adjustmentId() - validated = true - } + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = (if (adjustmentId.asKnown() == null) 0 else 1) + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + private var validated: Boolean = false - return other is RemoveAdjustment && - adjustmentId == other.adjustmentId && - additionalProperties == other.additionalProperties - } + fun validate(): Cadence = apply { + if (validated) { + return@apply + } - private val hashCode: Int by lazy { Objects.hash(adjustmentId, additionalProperties) } + known() + validated = true + } - override fun hashCode(): Int = hashCode + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - override fun toString() = - "RemoveAdjustment{adjustmentId=$adjustmentId, additionalProperties=$additionalProperties}" - } + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - class RemovePrice - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val externalPriceId: JsonField, - private val priceId: JsonField, - private val additionalProperties: MutableMap, - ) { + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - @JsonCreator - private constructor( - @JsonProperty("external_price_id") - @ExcludeMissing - externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("price_id") @ExcludeMissing priceId: JsonField = JsonMissing.of(), - ) : this(externalPriceId, priceId, mutableMapOf()) + return other is Cadence && value == other.value + } - /** - * The external price id of the price to remove on the subscription. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + override fun hashCode() = value.hashCode() - /** - * The id of the price to remove on the subscription. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun priceId(): String? = priceId.getNullable("price_id") + override fun toString() = value.toString() + } - /** - * Returns the raw JSON value of [externalPriceId]. - * - * Unlike [externalPriceId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId + /** Configuration for percent pricing */ + class PercentConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val percent: JsonField, + private val additionalProperties: MutableMap, + ) { - /** - * Returns the raw JSON value of [priceId]. - * - * Unlike [priceId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId + @JsonCreator + private constructor( + @JsonProperty("percent") + @ExcludeMissing + percent: JsonField = JsonMissing.of() + ) : this(percent, mutableMapOf()) - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** + * What percent of the component subtotals to charge + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun percent(): Double = percent.getRequired("percent") - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** + * Returns the raw JSON value of [percent]. + * + * Unlike [percent], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("percent") + @ExcludeMissing + fun _percent(): JsonField = percent - fun toBuilder() = Builder().from(this) + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - companion object { + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - /** Returns a mutable builder for constructing an instance of [RemovePrice]. */ - fun builder() = Builder() - } + fun toBuilder() = Builder().from(this) - /** A builder for [RemovePrice]. */ - class Builder internal constructor() { + companion object { - private var externalPriceId: JsonField = JsonMissing.of() - private var priceId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + /** + * Returns a mutable builder for constructing an instance of + * [PercentConfig]. + * + * The following fields are required: + * ```kotlin + * .percent() + * ``` + */ + fun builder() = Builder() + } - internal fun from(removePrice: RemovePrice) = apply { - externalPriceId = removePrice.externalPriceId - priceId = removePrice.priceId - additionalProperties = removePrice.additionalProperties.toMutableMap() - } + /** A builder for [PercentConfig]. */ + class Builder internal constructor() { - /** The external price id of the price to remove on the subscription. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) + private var percent: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() - /** - * Sets [Builder.externalPriceId] to an arbitrary JSON value. - * - * You should usually call [Builder.externalPriceId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun externalPriceId(externalPriceId: JsonField) = apply { - this.externalPriceId = externalPriceId - } + internal fun from(percentConfig: PercentConfig) = apply { + percent = percentConfig.percent + additionalProperties = percentConfig.additionalProperties.toMutableMap() + } - /** The id of the price to remove on the subscription. */ - fun priceId(priceId: String?) = priceId(JsonField.ofNullable(priceId)) + /** What percent of the component subtotals to charge */ + fun percent(percent: Double) = percent(JsonField.of(percent)) - /** - * Sets [Builder.priceId] to an arbitrary JSON value. - * - * You should usually call [Builder.priceId] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun priceId(priceId: JsonField) = apply { this.priceId = priceId } + /** + * Sets [Builder.percent] to an arbitrary JSON value. + * + * You should usually call [Builder.percent] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun percent(percent: JsonField) = apply { this.percent = percent } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - /** - * Returns an immutable instance of [RemovePrice]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): RemovePrice = - RemovePrice(externalPriceId, priceId, additionalProperties.toMutableMap()) - } + /** + * Returns an immutable instance of [PercentConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .percent() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): PercentConfig = + PercentConfig( + checkRequired("percent", percent), + additionalProperties.toMutableMap(), + ) + } - private var validated: Boolean = false + private var validated: Boolean = false - fun validate(): RemovePrice = apply { - if (validated) { - return@apply - } + fun validate(): PercentConfig = apply { + if (validated) { + return@apply + } - externalPriceId() - priceId() - validated = true - } + percent() + validated = true + } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (if (externalPriceId.asKnown() == null) 0 else 1) + - (if (priceId.asKnown() == null) 0 else 1) + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = (if (percent.asKnown() == null) 0 else 1) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - return other is RemovePrice && - externalPriceId == other.externalPriceId && - priceId == other.priceId && - additionalProperties == other.additionalProperties - } + return other is PercentConfig && + percent == other.percent && + additionalProperties == other.additionalProperties + } - private val hashCode: Int by lazy { - Objects.hash(externalPriceId, priceId, additionalProperties) - } + private val hashCode: Int by lazy { + Objects.hash(percent, additionalProperties) + } - override fun hashCode(): Int = hashCode + override fun hashCode(): Int = hashCode - override fun toString() = - "RemovePrice{externalPriceId=$externalPriceId, priceId=$priceId, additionalProperties=$additionalProperties}" - } + override fun toString() = + "PercentConfig{percent=$percent, additionalProperties=$additionalProperties}" + } - class ReplaceAdjustment - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val adjustment: JsonField, - private val replacesAdjustmentId: JsonField, - private val additionalProperties: MutableMap, - ) { + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { - @JsonCreator - private constructor( - @JsonProperty("adjustment") - @ExcludeMissing - adjustment: JsonField = JsonMissing.of(), - @JsonProperty("replaces_adjustment_id") - @ExcludeMissing - replacesAdjustmentId: JsonField = JsonMissing.of(), - ) : this(adjustment, replacesAdjustmentId, mutableMapOf()) + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties - /** - * The definition of a new adjustment to create and add to the subscription. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun adjustment(): Adjustment = adjustment.getRequired("adjustment") + fun toBuilder() = Builder().from(this) - /** - * The id of the adjustment on the plan to replace in the subscription. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun replacesAdjustmentId(): String = - replacesAdjustmentId.getRequired("replaces_adjustment_id") + companion object { - /** - * Returns the raw JSON value of [adjustment]. - * - * Unlike [adjustment], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("adjustment") - @ExcludeMissing - fun _adjustment(): JsonField = adjustment + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } - /** - * Returns the raw JSON value of [replacesAdjustmentId]. - * - * Unlike [replacesAdjustmentId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("replaces_adjustment_id") - @ExcludeMissing - fun _replacesAdjustmentId(): JsonField = replacesAdjustmentId + /** A builder for [Metadata]. */ + class Builder internal constructor() { - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + private var additionalProperties: MutableMap = + mutableMapOf() - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } - fun toBuilder() = Builder().from(this) + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - companion object { + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * Returns a mutable builder for constructing an instance of [ReplaceAdjustment]. - * - * The following fields are required: - * ```kotlin - * .adjustment() - * .replacesAdjustmentId() - * ``` - */ - fun builder() = Builder() - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - /** A builder for [ReplaceAdjustment]. */ - class Builder internal constructor() { + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - private var adjustment: JsonField? = null - private var replacesAdjustmentId: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - internal fun from(replaceAdjustment: ReplaceAdjustment) = apply { - adjustment = replaceAdjustment.adjustment - replacesAdjustmentId = replaceAdjustment.replacesAdjustmentId - additionalProperties = replaceAdjustment.additionalProperties.toMutableMap() - } + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } - /** The definition of a new adjustment to create and add to the subscription. */ - fun adjustment(adjustment: Adjustment) = adjustment(JsonField.of(adjustment)) + private var validated: Boolean = false - /** - * Sets [Builder.adjustment] to an arbitrary JSON value. - * - * You should usually call [Builder.adjustment] with a well-typed [Adjustment] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun adjustment(adjustment: JsonField) = apply { - this.adjustment = adjustment - } + fun validate(): Metadata = apply { + if (validated) { + return@apply + } - /** - * Alias for calling [adjustment] with - * `Adjustment.ofPercentageDiscount(percentageDiscount)`. - */ - fun adjustment(percentageDiscount: NewPercentageDiscount) = - adjustment(Adjustment.ofPercentageDiscount(percentageDiscount)) + validated = true + } - /** - * Alias for calling [adjustment] with the following: - * ```kotlin - * NewPercentageDiscount.builder() - * .adjustmentType(NewPercentageDiscount.AdjustmentType.PERCENTAGE_DISCOUNT) - * .percentageDiscount(percentageDiscount) - * .build() - * ``` - */ - fun percentageDiscountAdjustment(percentageDiscount: Double) = - adjustment( - NewPercentageDiscount.builder() - .adjustmentType(NewPercentageDiscount.AdjustmentType.PERCENTAGE_DISCOUNT) - .percentageDiscount(percentageDiscount) - .build() - ) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - /** Alias for calling [adjustment] with `Adjustment.ofUsageDiscount(usageDiscount)`. */ - fun adjustment(usageDiscount: NewUsageDiscount) = - adjustment(Adjustment.ofUsageDiscount(usageDiscount)) + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } - /** - * Alias for calling [adjustment] with the following: - * ```kotlin - * NewUsageDiscount.builder() - * .adjustmentType(NewUsageDiscount.AdjustmentType.USAGE_DISCOUNT) - * .usageDiscount(usageDiscount) - * .build() - * ``` - */ - fun usageDiscountAdjustment(usageDiscount: Double) = - adjustment( - NewUsageDiscount.builder() - .adjustmentType(NewUsageDiscount.AdjustmentType.USAGE_DISCOUNT) - .usageDiscount(usageDiscount) - .build() - ) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * Alias for calling [adjustment] with `Adjustment.ofAmountDiscount(amountDiscount)`. - */ - fun adjustment(amountDiscount: NewAmountDiscount) = - adjustment(Adjustment.ofAmountDiscount(amountDiscount)) + return other is Metadata && + additionalProperties == other.additionalProperties + } - /** - * Alias for calling [adjustment] with the following: - * ```kotlin - * NewAmountDiscount.builder() - * .adjustmentType(NewAmountDiscount.AdjustmentType.AMOUNT_DISCOUNT) - * .amountDiscount(amountDiscount) - * .build() - * ``` - */ - fun amountDiscountAdjustment(amountDiscount: String) = - adjustment( - NewAmountDiscount.builder() - .adjustmentType(NewAmountDiscount.AdjustmentType.AMOUNT_DISCOUNT) - .amountDiscount(amountDiscount) - .build() - ) + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /** Alias for calling [adjustment] with `Adjustment.ofMinimum(minimum)`. */ - fun adjustment(minimum: NewMinimum) = adjustment(Adjustment.ofMinimum(minimum)) + override fun hashCode(): Int = hashCode - /** Alias for calling [adjustment] with `Adjustment.ofMaximum(maximum)`. */ - fun adjustment(maximum: NewMaximum) = adjustment(Adjustment.ofMaximum(maximum)) + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } - /** - * Alias for calling [adjustment] with the following: - * ```kotlin - * NewMaximum.builder() - * .adjustmentType(NewMaximum.AdjustmentType.MAXIMUM) - * .maximumAmount(maximumAmount) - * .build() - * ``` - */ - fun maximumAdjustment(maximumAmount: String) = - adjustment( - NewMaximum.builder() - .adjustmentType(NewMaximum.AdjustmentType.MAXIMUM) - .maximumAmount(maximumAmount) - .build() - ) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** The id of the adjustment on the plan to replace in the subscription. */ - fun replacesAdjustmentId(replacesAdjustmentId: String) = - replacesAdjustmentId(JsonField.of(replacesAdjustmentId)) - - /** - * Sets [Builder.replacesAdjustmentId] to an arbitrary JSON value. - * - * You should usually call [Builder.replacesAdjustmentId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun replacesAdjustmentId(replacesAdjustmentId: JsonField) = apply { - this.replacesAdjustmentId = replacesAdjustmentId - } + return other is Percent && + cadence == other.cadence && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + percentConfig == other.percentConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + modelType, + name, + percentConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties, + ) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + override fun hashCode(): Int = hashCode - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) + override fun toString() = + "Percent{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, percentConfig=$percentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + class EventOutput + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val eventOutputConfig: JsonField, + private val itemId: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { - /** - * Returns an immutable instance of [ReplaceAdjustment]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```kotlin - * .adjustment() - * .replacesAdjustmentId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): ReplaceAdjustment = - ReplaceAdjustment( - checkRequired("adjustment", adjustment), - checkRequired("replacesAdjustmentId", replacesAdjustmentId), - additionalProperties.toMutableMap(), + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("event_output_config") + @ExcludeMissing + eventOutputConfig: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + eventOutputConfig, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + mutableMapOf(), ) - } - private var validated: Boolean = false + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") - fun validate(): ReplaceAdjustment = apply { - if (validated) { - return@apply - } + /** + * Configuration for event_output pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun eventOutputConfig(): EventOutputConfig = + eventOutputConfig.getRequired("event_output_config") - adjustment().validate() - replacesAdjustmentId() - validated = true - } + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("event_output") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (adjustment.asKnown()?.validity() ?: 0) + - (if (replacesAdjustmentId.asKnown() == null) 0 else 1) - - /** The definition of a new adjustment to create and add to the subscription. */ - @JsonDeserialize(using = Adjustment.Deserializer::class) - @JsonSerialize(using = Adjustment.Serializer::class) - class Adjustment - private constructor( - private val percentageDiscount: NewPercentageDiscount? = null, - private val usageDiscount: NewUsageDiscount? = null, - private val amountDiscount: NewAmountDiscount? = null, - private val minimum: NewMinimum? = null, - private val maximum: NewMaximum? = null, - private val _json: JsonValue? = null, - ) { + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") - fun percentageDiscount(): NewPercentageDiscount? = percentageDiscount + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = billableMetricId.getNullable("billable_metric_id") - fun usageDiscount(): NewUsageDiscount? = usageDiscount + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") - fun amountDiscount(): NewAmountDiscount? = amountDiscount + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") - fun minimum(): NewMinimum? = minimum + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") - fun maximum(): NewMaximum? = maximum + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") - fun isPercentageDiscount(): Boolean = percentageDiscount != null + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") - fun isUsageDiscount(): Boolean = usageDiscount != null + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") - fun isAmountDiscount(): Boolean = amountDiscount != null + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") - fun isMinimum(): Boolean = minimum != null + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") - fun isMaximum(): Boolean = maximum != null + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + invoiceGroupingKey.getNullable("invoice_grouping_key") - fun asPercentageDiscount(): NewPercentageDiscount = - percentageDiscount.getOrThrow("percentageDiscount") + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - fun asUsageDiscount(): NewUsageDiscount = usageDiscount.getOrThrow("usageDiscount") + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") - fun asAmountDiscount(): NewAmountDiscount = amountDiscount.getOrThrow("amountDiscount") + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") - fun asMinimum(): NewMinimum = minimum.getOrThrow("minimum") + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence - fun asMaximum(): NewMaximum = maximum.getOrThrow("maximum") + /** + * Returns the raw JSON value of [eventOutputConfig]. + * + * Unlike [eventOutputConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("event_output_config") + @ExcludeMissing + fun _eventOutputConfig(): JsonField = eventOutputConfig - fun _json(): JsonValue? = _json + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - fun accept(visitor: Visitor): T = - when { - percentageDiscount != null -> - visitor.visitPercentageDiscount(percentageDiscount) - usageDiscount != null -> visitor.visitUsageDiscount(usageDiscount) - amountDiscount != null -> visitor.visitAmountDiscount(amountDiscount) - minimum != null -> visitor.visitMinimum(minimum) - maximum != null -> visitor.visitMaximum(maximum) - else -> visitor.unknown(_json) - } + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - private var validated: Boolean = false + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId - fun validate(): Adjustment = apply { - if (validated) { - return@apply - } + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance - accept( - object : Visitor { - override fun visitPercentageDiscount( - percentageDiscount: NewPercentageDiscount - ) { - percentageDiscount.validate() - } + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration - override fun visitUsageDiscount(usageDiscount: NewUsageDiscount) { - usageDiscount.validate() - } + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate - override fun visitAmountDiscount(amountDiscount: NewAmountDiscount) { - amountDiscount.validate() - } + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig - override fun visitMinimum(minimum: NewMinimum) { - minimum.validate() - } - - override fun visitMaximum(maximum: NewMaximum) { - maximum.validate() - } - } - ) - validated = true - } + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitPercentageDiscount( - percentageDiscount: NewPercentageDiscount - ) = percentageDiscount.validity() + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId - override fun visitUsageDiscount(usageDiscount: NewUsageDiscount) = - usageDiscount.validity() + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - override fun visitAmountDiscount(amountDiscount: NewAmountDiscount) = - amountDiscount.validity() + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - override fun visitMinimum(minimum: NewMinimum) = minimum.validity() + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration - override fun visitMaximum(maximum: NewMaximum) = maximum.validity() + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata - override fun unknown(json: JsonValue?) = 0 - } - ) + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) } - return other is Adjustment && - percentageDiscount == other.percentageDiscount && - usageDiscount == other.usageDiscount && - amountDiscount == other.amountDiscount && - minimum == other.minimum && - maximum == other.maximum - } - - override fun hashCode(): Int = - Objects.hash(percentageDiscount, usageDiscount, amountDiscount, minimum, maximum) + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - override fun toString(): String = - when { - percentageDiscount != null -> - "Adjustment{percentageDiscount=$percentageDiscount}" - usageDiscount != null -> "Adjustment{usageDiscount=$usageDiscount}" - amountDiscount != null -> "Adjustment{amountDiscount=$amountDiscount}" - minimum != null -> "Adjustment{minimum=$minimum}" - maximum != null -> "Adjustment{maximum=$maximum}" - _json != null -> "Adjustment{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Adjustment") - } + fun toBuilder() = Builder().from(this) - companion object { + companion object { - fun ofPercentageDiscount(percentageDiscount: NewPercentageDiscount) = - Adjustment(percentageDiscount = percentageDiscount) + /** + * Returns a mutable builder for constructing an instance of [EventOutput]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .eventOutputConfig() + * .itemId() + * .name() + * ``` + */ + fun builder() = Builder() + } - fun ofUsageDiscount(usageDiscount: NewUsageDiscount) = - Adjustment(usageDiscount = usageDiscount) + /** A builder for [EventOutput]. */ + class Builder internal constructor() { - fun ofAmountDiscount(amountDiscount: NewAmountDiscount) = - Adjustment(amountDiscount = amountDiscount) + private var cadence: JsonField? = null + private var eventOutputConfig: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonValue = JsonValue.from("event_output") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - fun ofMinimum(minimum: NewMinimum) = Adjustment(minimum = minimum) + internal fun from(eventOutput: EventOutput) = apply { + cadence = eventOutput.cadence + eventOutputConfig = eventOutput.eventOutputConfig + itemId = eventOutput.itemId + modelType = eventOutput.modelType + name = eventOutput.name + billableMetricId = eventOutput.billableMetricId + billedInAdvance = eventOutput.billedInAdvance + billingCycleConfiguration = eventOutput.billingCycleConfiguration + conversionRate = eventOutput.conversionRate + conversionRateConfig = eventOutput.conversionRateConfig + currency = eventOutput.currency + dimensionalPriceConfiguration = eventOutput.dimensionalPriceConfiguration + externalPriceId = eventOutput.externalPriceId + fixedPriceQuantity = eventOutput.fixedPriceQuantity + invoiceGroupingKey = eventOutput.invoiceGroupingKey + invoicingCycleConfiguration = eventOutput.invoicingCycleConfiguration + metadata = eventOutput.metadata + referenceId = eventOutput.referenceId + additionalProperties = eventOutput.additionalProperties.toMutableMap() + } - fun ofMaximum(maximum: NewMaximum) = Adjustment(maximum = maximum) - } + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - /** - * An interface that defines how to map each variant of [Adjustment] to a value of type - * [T]. - */ - interface Visitor { + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - fun visitPercentageDiscount(percentageDiscount: NewPercentageDiscount): T + /** Configuration for event_output pricing */ + fun eventOutputConfig(eventOutputConfig: EventOutputConfig) = + eventOutputConfig(JsonField.of(eventOutputConfig)) - fun visitUsageDiscount(usageDiscount: NewUsageDiscount): T + /** + * Sets [Builder.eventOutputConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.eventOutputConfig] with a well-typed + * [EventOutputConfig] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun eventOutputConfig(eventOutputConfig: JsonField) = apply { + this.eventOutputConfig = eventOutputConfig + } - fun visitAmountDiscount(amountDiscount: NewAmountDiscount): T + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - fun visitMinimum(minimum: NewMinimum): T + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun visitMaximum(maximum: NewMaximum): T + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("event_output") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } - /** - * Maps an unknown variant of [Adjustment] to a value of type [T]. - * - * An instance of [Adjustment] can contain an unknown variant if it was deserialized - * from data that doesn't match any known variant. For example, if the SDK is on an - * older version than the API, then the API may respond with new variants that the - * SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown Adjustment: $json") - } - } + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) - internal class Deserializer : BaseDeserializer(Adjustment::class) { + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } - override fun ObjectCodec.deserialize(node: JsonNode): Adjustment { - val json = JsonValue.fromJsonNode(node) - val adjustmentType = json.asObject()?.get("adjustment_type")?.asString() + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) - when (adjustmentType) { - "percentage_discount" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Adjustment(percentageDiscount = it, _json = json) } - ?: Adjustment(_json = json) - } - "usage_discount" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(usageDiscount = it, _json = json) - } ?: Adjustment(_json = json) - } - "amount_discount" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(amountDiscount = it, _json = json) - } ?: Adjustment(_json = json) - } - "minimum" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(minimum = it, _json = json) - } ?: Adjustment(_json = json) - } - "maximum" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(maximum = it, _json = json) - } ?: Adjustment(_json = json) - } + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId } - return Adjustment(_json = json) - } - } + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) - internal class Serializer : BaseSerializer(Adjustment::class) { + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) - override fun serialize( - value: Adjustment, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.percentageDiscount != null -> - generator.writeObject(value.percentageDiscount) - value.usageDiscount != null -> generator.writeObject(value.usageDiscount) - value.amountDiscount != null -> generator.writeObject(value.amountDiscount) - value.minimum != null -> generator.writeObject(value.minimum) - value.maximum != null -> generator.writeObject(value.maximum) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Adjustment") + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance } - } - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - return other is ReplaceAdjustment && - adjustment == other.adjustment && - replacesAdjustmentId == other.replacesAdjustmentId && - additionalProperties == other.additionalProperties - } + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - private val hashCode: Int by lazy { - Objects.hash(adjustment, replacesAdjustmentId, additionalProperties) - } + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } - override fun hashCode(): Int = hashCode + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) - override fun toString() = - "ReplaceAdjustment{adjustment=$adjustment, replacesAdjustmentId=$replacesAdjustmentId, additionalProperties=$additionalProperties}" - } + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) - class ReplacePrice - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val replacesPriceId: JsonField, - private val allocationPrice: JsonField, - private val discounts: JsonField>, - private val externalPriceId: JsonField, - private val fixedPriceQuantity: JsonField, - private val maximumAmount: JsonField, - private val minimumAmount: JsonField, - private val price: JsonField, - private val priceId: JsonField, - private val additionalProperties: MutableMap, - ) { + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } - @JsonCreator - private constructor( - @JsonProperty("replaces_price_id") - @ExcludeMissing - replacesPriceId: JsonField = JsonMissing.of(), - @JsonProperty("allocation_price") - @ExcludeMissing - allocationPrice: JsonField = JsonMissing.of(), - @JsonProperty("discounts") - @ExcludeMissing - discounts: JsonField> = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("maximum_amount") - @ExcludeMissing - maximumAmount: JsonField = JsonMissing.of(), - @JsonProperty("minimum_amount") - @ExcludeMissing - minimumAmount: JsonField = JsonMissing.of(), - @JsonProperty("price") @ExcludeMissing price: JsonField = JsonMissing.of(), - @JsonProperty("price_id") @ExcludeMissing priceId: JsonField = JsonMissing.of(), - ) : this( - replacesPriceId, - allocationPrice, - discounts, - externalPriceId, - fixedPriceQuantity, - maximumAmount, - minimumAmount, - price, - priceId, - mutableMapOf(), - ) + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) - /** - * The id of the price on the plan to replace in the subscription. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun replacesPriceId(): String = replacesPriceId.getRequired("replaces_price_id") + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } - /** - * The definition of a new allocation price to create and add to the subscription. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun allocationPrice(): NewAllocationPrice? = allocationPrice.getNullable("allocation_price") + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) - /** - * [DEPRECATED] Use add_adjustments instead. The subscription's discounts for the - * replacement price. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - @Deprecated("deprecated") - fun discounts(): List? = discounts.getNullable("discounts") + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) - /** - * The external price id of the price to add to the subscription. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) - /** - * The new quantity of the price, if the price is a fixed price. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun fixedPriceQuantity(): Double? = fixedPriceQuantity.getNullable("fixed_price_quantity") + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) - /** - * [DEPRECATED] Use add_adjustments instead. The subscription's maximum amount for the - * replacement price. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - @Deprecated("deprecated") - fun maximumAmount(): String? = maximumAmount.getNullable("maximum_amount") + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) - /** - * [DEPRECATED] Use add_adjustments instead. The subscription's minimum amount for the - * replacement price. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - @Deprecated("deprecated") - fun minimumAmount(): String? = minimumAmount.getNullable("minimum_amount") + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } - /** - * New subscription price request body params. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun price(): Price? = price.getNullable("price") + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) - /** - * The id of the price to add to the subscription. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun priceId(): String? = priceId.getNullable("price_id") + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } - /** - * Returns the raw JSON value of [replacesPriceId]. - * - * Unlike [replacesPriceId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("replaces_price_id") - @ExcludeMissing - fun _replacesPriceId(): JsonField = replacesPriceId + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) - /** - * Returns the raw JSON value of [allocationPrice]. - * - * Unlike [allocationPrice], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("allocation_price") - @ExcludeMissing - fun _allocationPrice(): JsonField = allocationPrice + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } - /** - * Returns the raw JSON value of [discounts]. - * - * Unlike [discounts], this method doesn't throw if the JSON field has an unexpected type. - */ - @Deprecated("deprecated") - @JsonProperty("discounts") - @ExcludeMissing - fun _discounts(): JsonField> = discounts + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) - /** - * Returns the raw JSON value of [externalPriceId]. - * - * Unlike [externalPriceId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) - /** - * Returns the raw JSON value of [fixedPriceQuantity]. - * - * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } - /** - * Returns the raw JSON value of [maximumAmount]. - * - * Unlike [maximumAmount], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @Deprecated("deprecated") - @JsonProperty("maximum_amount") - @ExcludeMissing - fun _maximumAmount(): JsonField = maximumAmount + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) - /** - * Returns the raw JSON value of [minimumAmount]. - * - * Unlike [minimumAmount], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @Deprecated("deprecated") - @JsonProperty("minimum_amount") - @ExcludeMissing - fun _minimumAmount(): JsonField = minimumAmount + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } - /** - * Returns the raw JSON value of [price]. - * - * Unlike [price], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("price") @ExcludeMissing fun _price(): JsonField = price - - /** - * Returns the raw JSON value of [priceId]. - * - * Unlike [priceId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - fun toBuilder() = Builder().from(this) + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - companion object { + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - /** - * Returns a mutable builder for constructing an instance of [ReplacePrice]. - * - * The following fields are required: - * ```kotlin - * .replacesPriceId() - * ``` - */ - fun builder() = Builder() - } + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) - /** A builder for [ReplacePrice]. */ - class Builder internal constructor() { + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } - private var replacesPriceId: JsonField? = null - private var allocationPrice: JsonField = JsonMissing.of() - private var discounts: JsonField>? = null - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var maximumAmount: JsonField = JsonMissing.of() - private var minimumAmount: JsonField = JsonMissing.of() - private var price: JsonField = JsonMissing.of() - private var priceId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - internal fun from(replacePrice: ReplacePrice) = apply { - replacesPriceId = replacePrice.replacesPriceId - allocationPrice = replacePrice.allocationPrice - discounts = replacePrice.discounts.map { it.toMutableList() } - externalPriceId = replacePrice.externalPriceId - fixedPriceQuantity = replacePrice.fixedPriceQuantity - maximumAmount = replacePrice.maximumAmount - minimumAmount = replacePrice.minimumAmount - price = replacePrice.price - priceId = replacePrice.priceId - additionalProperties = replacePrice.additionalProperties.toMutableMap() - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** The id of the price on the plan to replace in the subscription. */ - fun replacesPriceId(replacesPriceId: String) = - replacesPriceId(JsonField.of(replacesPriceId)) + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - /** - * Sets [Builder.replacesPriceId] to an arbitrary JSON value. - * - * You should usually call [Builder.replacesPriceId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun replacesPriceId(replacesPriceId: JsonField) = apply { - this.replacesPriceId = replacesPriceId - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - /** The definition of a new allocation price to create and add to the subscription. */ - fun allocationPrice(allocationPrice: NewAllocationPrice?) = - allocationPrice(JsonField.ofNullable(allocationPrice)) + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - /** - * Sets [Builder.allocationPrice] to an arbitrary JSON value. - * - * You should usually call [Builder.allocationPrice] with a well-typed - * [NewAllocationPrice] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun allocationPrice(allocationPrice: JsonField) = apply { - this.allocationPrice = allocationPrice - } + /** + * Returns an immutable instance of [EventOutput]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .eventOutputConfig() + * .itemId() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): EventOutput = + EventOutput( + checkRequired("cadence", cadence), + checkRequired("eventOutputConfig", eventOutputConfig), + checkRequired("itemId", itemId), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } - /** - * [DEPRECATED] Use add_adjustments instead. The subscription's discounts for the - * replacement price. - */ - @Deprecated("deprecated") - fun discounts(discounts: List?) = - discounts(JsonField.ofNullable(discounts)) + private var validated: Boolean = false - /** - * Sets [Builder.discounts] to an arbitrary JSON value. - * - * You should usually call [Builder.discounts] with a well-typed - * `List` value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - @Deprecated("deprecated") - fun discounts(discounts: JsonField>) = apply { - this.discounts = discounts.map { it.toMutableList() } - } + fun validate(): EventOutput = apply { + if (validated) { + return@apply + } - /** - * Adds a single [DiscountOverride] to [discounts]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - @Deprecated("deprecated") - fun addDiscount(discount: DiscountOverride) = apply { - discounts = - (discounts ?: JsonField.of(mutableListOf())).also { - checkKnown("discounts", it).add(discount) + cadence().validate() + eventOutputConfig().validate() + itemId() + _modelType().let { + if (it != JsonValue.from("event_output")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } } - } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + metadata()?.validate() + referenceId() + validated = true + } - /** The external price id of the price to add to the subscription. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - /** - * Sets [Builder.externalPriceId] to an arbitrary JSON value. - * - * You should usually call [Builder.externalPriceId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun externalPriceId(externalPriceId: JsonField) = apply { - this.externalPriceId = externalPriceId - } - - /** The new quantity of the price, if the price is a fixed price. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = - fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (eventOutputConfig.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + modelType.let { if (it == JsonValue.from("event_output")) 1 else 0 } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) - /** - * Alias for [Builder.fixedPriceQuantity]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { - /** - * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. - * - * You should usually call [Builder.fixedPriceQuantity] with a well-typed [Double] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value - /** - * [DEPRECATED] Use add_adjustments instead. The subscription's maximum amount for the - * replacement price. - */ - @Deprecated("deprecated") - fun maximumAmount(maximumAmount: String?) = - maximumAmount(JsonField.ofNullable(maximumAmount)) + companion object { - /** - * Sets [Builder.maximumAmount] to an arbitrary JSON value. - * - * You should usually call [Builder.maximumAmount] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - @Deprecated("deprecated") - fun maximumAmount(maximumAmount: JsonField) = apply { - this.maximumAmount = maximumAmount - } + val ANNUAL = of("annual") - /** - * [DEPRECATED] Use add_adjustments instead. The subscription's minimum amount for the - * replacement price. - */ - @Deprecated("deprecated") - fun minimumAmount(minimumAmount: String?) = - minimumAmount(JsonField.ofNullable(minimumAmount)) + val SEMI_ANNUAL = of("semi_annual") - /** - * Sets [Builder.minimumAmount] to an arbitrary JSON value. - * - * You should usually call [Builder.minimumAmount] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - @Deprecated("deprecated") - fun minimumAmount(minimumAmount: JsonField) = apply { - this.minimumAmount = minimumAmount - } + val MONTHLY = of("monthly") - /** New subscription price request body params. */ - fun price(price: Price?) = price(JsonField.ofNullable(price)) + val QUARTERLY = of("quarterly") - /** - * Sets [Builder.price] to an arbitrary JSON value. - * - * You should usually call [Builder.price] with a well-typed [Price] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun price(price: JsonField) = apply { this.price = price } + val ONE_TIME = of("one_time") - /** Alias for calling [price] with `Price.ofUnit(unit)`. */ - fun price(unit: NewSubscriptionUnitPrice) = price(Price.ofUnit(unit)) + val CUSTOM = of("custom") - /** Alias for calling [price] with `Price.ofTiered(tiered)`. */ - fun price(tiered: NewSubscriptionTieredPrice) = price(Price.ofTiered(tiered)) + fun of(value: String) = Cadence(JsonField.of(value)) + } - /** Alias for calling [price] with `Price.ofBulk(bulk)`. */ - fun price(bulk: NewSubscriptionBulkPrice) = price(Price.ofBulk(bulk)) + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } - /** Alias for calling [price] with `Price.ofPackage(package_)`. */ - fun price(package_: NewSubscriptionPackagePrice) = price(Price.ofPackage(package_)) + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } - /** Alias for calling [price] with `Price.ofMatrix(matrix)`. */ - fun price(matrix: NewSubscriptionMatrixPrice) = price(Price.ofMatrix(matrix)) + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } - /** - * Alias for calling [price] with `Price.ofThresholdTotalAmount(thresholdTotalAmount)`. - */ - fun price(thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice) = - price(Price.ofThresholdTotalAmount(thresholdTotalAmount)) + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } - /** Alias for calling [price] with `Price.ofTieredPackage(tieredPackage)`. */ - fun price(tieredPackage: NewSubscriptionTieredPackagePrice) = - price(Price.ofTieredPackage(tieredPackage)) + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") - /** Alias for calling [price] with `Price.ofTieredWithMinimum(tieredWithMinimum)`. */ - fun price(tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice) = - price(Price.ofTieredWithMinimum(tieredWithMinimum)) + private var validated: Boolean = false - /** Alias for calling [price] with `Price.ofGroupedTiered(groupedTiered)`. */ - fun price(groupedTiered: NewSubscriptionGroupedTieredPrice) = - price(Price.ofGroupedTiered(groupedTiered)) + fun validate(): Cadence = apply { + if (validated) { + return@apply + } - /** - * Alias for calling [price] with - * `Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)`. - */ - fun price(tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice) = - price(Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)) + known() + validated = true + } - /** - * Alias for calling [price] with - * `Price.ofPackageWithAllocation(packageWithAllocation)`. - */ - fun price(packageWithAllocation: NewSubscriptionPackageWithAllocationPrice) = - price(Price.ofPackageWithAllocation(packageWithAllocation)) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - /** Alias for calling [price] with `Price.ofUnitWithPercent(unitWithPercent)`. */ - fun price(unitWithPercent: NewSubscriptionUnitWithPercentPrice) = - price(Price.ofUnitWithPercent(unitWithPercent)) + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - /** - * Alias for calling [price] with `Price.ofMatrixWithAllocation(matrixWithAllocation)`. - */ - fun price(matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice) = - price(Price.ofMatrixWithAllocation(matrixWithAllocation)) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * Alias for calling [price] with `Price.ofTieredWithProration(tieredWithProration)`. - */ - fun price(tieredWithProration: Price.TieredWithProration) = - price(Price.ofTieredWithProration(tieredWithProration)) + return other is Cadence && value == other.value + } - /** Alias for calling [price] with `Price.ofUnitWithProration(unitWithProration)`. */ - fun price(unitWithProration: NewSubscriptionUnitWithProrationPrice) = - price(Price.ofUnitWithProration(unitWithProration)) + override fun hashCode() = value.hashCode() - /** Alias for calling [price] with `Price.ofGroupedAllocation(groupedAllocation)`. */ - fun price(groupedAllocation: NewSubscriptionGroupedAllocationPrice) = - price(Price.ofGroupedAllocation(groupedAllocation)) + override fun toString() = value.toString() + } - /** Alias for calling [price] with `Price.ofBulkWithProration(bulkWithProration)`. */ - fun price(bulkWithProration: NewSubscriptionBulkWithProrationPrice) = - price(Price.ofBulkWithProration(bulkWithProration)) + /** Configuration for event_output pricing */ + class EventOutputConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val unitRatingKey: JsonField, + private val groupingKey: JsonField, + private val additionalProperties: MutableMap, + ) { - /** - * Alias for calling [price] with - * `Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)`. - */ - fun price(groupedWithProratedMinimum: NewSubscriptionGroupedWithProratedMinimumPrice) = - price(Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)) + @JsonCreator + private constructor( + @JsonProperty("unit_rating_key") + @ExcludeMissing + unitRatingKey: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + ) : this(unitRatingKey, groupingKey, mutableMapOf()) - /** - * Alias for calling [price] with - * `Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)`. - */ - fun price(groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice) = - price(Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)) + /** + * The key in the event data to extract the unit rate from. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun unitRatingKey(): String = unitRatingKey.getRequired("unit_rating_key") - /** - * Alias for calling [price] with - * `Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)`. - */ - fun price(groupedWithMinMaxThresholds: Price.GroupedWithMinMaxThresholds) = - price(Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)) + /** + * An optional key in the event data to group by (e.g., event ID). All events + * will also be grouped by their unit rate. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun groupingKey(): String? = groupingKey.getNullable("grouping_key") - /** - * Alias for calling [price] with - * `Price.ofMatrixWithDisplayName(matrixWithDisplayName)`. - */ - fun price(matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice) = - price(Price.ofMatrixWithDisplayName(matrixWithDisplayName)) + /** + * Returns the raw JSON value of [unitRatingKey]. + * + * Unlike [unitRatingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_rating_key") + @ExcludeMissing + fun _unitRatingKey(): JsonField = unitRatingKey - /** - * Alias for calling [price] with `Price.ofGroupedTieredPackage(groupedTieredPackage)`. - */ - fun price(groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice) = - price(Price.ofGroupedTieredPackage(groupedTieredPackage)) + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey - /** - * Alias for calling [price] with - * `Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)`. - */ - fun price(maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice) = - price(Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)) + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - /** - * Alias for calling [price] with - * `Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)`. - */ - fun price( - scalableMatrixWithUnitPricing: NewSubscriptionScalableMatrixWithUnitPricingPrice - ) = price(Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)) + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - /** - * Alias for calling [price] with - * `Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)`. - */ - fun price( - scalableMatrixWithTieredPricing: NewSubscriptionScalableMatrixWithTieredPricingPrice - ) = price(Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)) + fun toBuilder() = Builder().from(this) - /** - * Alias for calling [price] with - * `Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)`. - */ - fun price(cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice) = - price(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) + companion object { - /** Alias for calling [price] with `Price.ofMinimum(minimum)`. */ - fun price(minimum: NewSubscriptionMinimumCompositePrice) = - price(Price.ofMinimum(minimum)) + /** + * Returns a mutable builder for constructing an instance of + * [EventOutputConfig]. + * + * The following fields are required: + * ```kotlin + * .unitRatingKey() + * ``` + */ + fun builder() = Builder() + } - /** Alias for calling [price] with `Price.ofPercent(percent)`. */ - fun price(percent: Price.Percent) = price(Price.ofPercent(percent)) + /** A builder for [EventOutputConfig]. */ + class Builder internal constructor() { - /** Alias for calling [price] with `Price.ofEventOutput(eventOutput)`. */ - fun price(eventOutput: Price.EventOutput) = price(Price.ofEventOutput(eventOutput)) + private var unitRatingKey: JsonField? = null + private var groupingKey: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() - /** The id of the price to add to the subscription. */ - fun priceId(priceId: String?) = priceId(JsonField.ofNullable(priceId)) + internal fun from(eventOutputConfig: EventOutputConfig) = apply { + unitRatingKey = eventOutputConfig.unitRatingKey + groupingKey = eventOutputConfig.groupingKey + additionalProperties = + eventOutputConfig.additionalProperties.toMutableMap() + } - /** - * Sets [Builder.priceId] to an arbitrary JSON value. - * - * You should usually call [Builder.priceId] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun priceId(priceId: JsonField) = apply { this.priceId = priceId } + /** The key in the event data to extract the unit rate from. */ + fun unitRatingKey(unitRatingKey: String) = + unitRatingKey(JsonField.of(unitRatingKey)) - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * Sets [Builder.unitRatingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.unitRatingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun unitRatingKey(unitRatingKey: JsonField) = apply { + this.unitRatingKey = unitRatingKey + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * An optional key in the event data to group by (e.g., event ID). All + * events will also be grouped by their unit rate. + */ + fun groupingKey(groupingKey: String?) = + groupingKey(JsonField.ofNullable(groupingKey)) - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * Returns an immutable instance of [ReplacePrice]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```kotlin - * .replacesPriceId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [EventOutputConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .unitRatingKey() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): EventOutputConfig = + EventOutputConfig( + checkRequired("unitRatingKey", unitRatingKey), + groupingKey, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): EventOutputConfig = apply { + if (validated) { + return@apply + } + + unitRatingKey() + groupingKey() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (unitRatingKey.asKnown() == null) 0 else 1) + + (if (groupingKey.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is EventOutputConfig && + unitRatingKey == other.unitRatingKey && + groupingKey == other.groupingKey && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(unitRatingKey, groupingKey, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "EventOutputConfig{unitRatingKey=$unitRatingKey, groupingKey=$groupingKey, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is EventOutput && + cadence == other.cadence && + eventOutputConfig == other.eventOutputConfig && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + eventOutputConfig, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "EventOutput{cadence=$cadence, eventOutputConfig=$eventOutputConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AddPrice && + allocationPrice == other.allocationPrice && + discounts == other.discounts && + endDate == other.endDate && + externalPriceId == other.externalPriceId && + maximumAmount == other.maximumAmount && + minimumAmount == other.minimumAmount && + planPhaseOrder == other.planPhaseOrder && + price == other.price && + priceId == other.priceId && + startDate == other.startDate && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + allocationPrice, + discounts, + endDate, + externalPriceId, + maximumAmount, + minimumAmount, + planPhaseOrder, + price, + priceId, + startDate, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AddPrice{allocationPrice=$allocationPrice, discounts=$discounts, endDate=$endDate, externalPriceId=$externalPriceId, maximumAmount=$maximumAmount, minimumAmount=$minimumAmount, planPhaseOrder=$planPhaseOrder, price=$price, priceId=$priceId, startDate=$startDate, additionalProperties=$additionalProperties}" + } + + @Deprecated("deprecated") + class ExternalMarketplace + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val GOOGLE = of("google") + + val AWS = of("aws") + + val AZURE = of("azure") + + fun of(value: String) = ExternalMarketplace(JsonField.of(value)) + } + + /** An enum containing [ExternalMarketplace]'s known values. */ + enum class Known { + GOOGLE, + AWS, + AZURE, + } + + /** + * An enum containing [ExternalMarketplace]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ExternalMarketplace] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + GOOGLE, + AWS, + AZURE, + /** + * An enum member indicating that [ExternalMarketplace] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + GOOGLE -> Value.GOOGLE + AWS -> Value.AWS + AZURE -> Value.AZURE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known member. + */ + fun known(): Known = + when (this) { + GOOGLE -> Known.GOOGLE + AWS -> Known.AWS + AZURE -> Known.AZURE + else -> throw OrbInvalidDataException("Unknown ExternalMarketplace: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the expected + * primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): ExternalMarketplace = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ExternalMarketplace && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by setting + * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to + * `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + class RemoveAdjustment + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val adjustmentId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("adjustment_id") + @ExcludeMissing + adjustmentId: JsonField = JsonMissing.of() + ) : this(adjustmentId, mutableMapOf()) + + /** + * The id of the adjustment to remove on the subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun adjustmentId(): String = adjustmentId.getRequired("adjustment_id") + + /** + * Returns the raw JSON value of [adjustmentId]. + * + * Unlike [adjustmentId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("adjustment_id") + @ExcludeMissing + fun _adjustmentId(): JsonField = adjustmentId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [RemoveAdjustment]. + * + * The following fields are required: + * ```kotlin + * .adjustmentId() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [RemoveAdjustment]. */ + class Builder internal constructor() { + + private var adjustmentId: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(removeAdjustment: RemoveAdjustment) = apply { + adjustmentId = removeAdjustment.adjustmentId + additionalProperties = removeAdjustment.additionalProperties.toMutableMap() + } + + /** The id of the adjustment to remove on the subscription. */ + fun adjustmentId(adjustmentId: String) = adjustmentId(JsonField.of(adjustmentId)) + + /** + * Sets [Builder.adjustmentId] to an arbitrary JSON value. + * + * You should usually call [Builder.adjustmentId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun adjustmentId(adjustmentId: JsonField) = apply { + this.adjustmentId = adjustmentId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [RemoveAdjustment]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .adjustmentId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): RemoveAdjustment = + RemoveAdjustment( + checkRequired("adjustmentId", adjustmentId), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): RemoveAdjustment = apply { + if (validated) { + return@apply + } + + adjustmentId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = (if (adjustmentId.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RemoveAdjustment && + adjustmentId == other.adjustmentId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(adjustmentId, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "RemoveAdjustment{adjustmentId=$adjustmentId, additionalProperties=$additionalProperties}" + } + + class RemovePrice + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val externalPriceId: JsonField, + private val priceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("price_id") @ExcludeMissing priceId: JsonField = JsonMissing.of(), + ) : this(externalPriceId, priceId, mutableMapOf()) + + /** + * The external price id of the price to remove on the subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * The id of the price to remove on the subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun priceId(): String? = priceId.getNullable("price_id") + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [priceId]. + * + * Unlike [priceId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [RemovePrice]. */ + fun builder() = Builder() + } + + /** A builder for [RemovePrice]. */ + class Builder internal constructor() { + + private var externalPriceId: JsonField = JsonMissing.of() + private var priceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(removePrice: RemovePrice) = apply { + externalPriceId = removePrice.externalPriceId + priceId = removePrice.priceId + additionalProperties = removePrice.additionalProperties.toMutableMap() + } + + /** The external price id of the price to remove on the subscription. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** The id of the price to remove on the subscription. */ + fun priceId(priceId: String?) = priceId(JsonField.ofNullable(priceId)) + + /** + * Sets [Builder.priceId] to an arbitrary JSON value. + * + * You should usually call [Builder.priceId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun priceId(priceId: JsonField) = apply { this.priceId = priceId } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [RemovePrice]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): RemovePrice = + RemovePrice(externalPriceId, priceId, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): RemovePrice = apply { + if (validated) { + return@apply + } + + externalPriceId() + priceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (priceId.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RemovePrice && + externalPriceId == other.externalPriceId && + priceId == other.priceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(externalPriceId, priceId, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "RemovePrice{externalPriceId=$externalPriceId, priceId=$priceId, additionalProperties=$additionalProperties}" + } + + class ReplaceAdjustment + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val adjustment: JsonField, + private val replacesAdjustmentId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("adjustment") + @ExcludeMissing + adjustment: JsonField = JsonMissing.of(), + @JsonProperty("replaces_adjustment_id") + @ExcludeMissing + replacesAdjustmentId: JsonField = JsonMissing.of(), + ) : this(adjustment, replacesAdjustmentId, mutableMapOf()) + + /** + * The definition of a new adjustment to create and add to the subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun adjustment(): Adjustment = adjustment.getRequired("adjustment") + + /** + * The id of the adjustment on the plan to replace in the subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun replacesAdjustmentId(): String = + replacesAdjustmentId.getRequired("replaces_adjustment_id") + + /** + * Returns the raw JSON value of [adjustment]. + * + * Unlike [adjustment], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("adjustment") + @ExcludeMissing + fun _adjustment(): JsonField = adjustment + + /** + * Returns the raw JSON value of [replacesAdjustmentId]. + * + * Unlike [replacesAdjustmentId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("replaces_adjustment_id") + @ExcludeMissing + fun _replacesAdjustmentId(): JsonField = replacesAdjustmentId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ReplaceAdjustment]. + * + * The following fields are required: + * ```kotlin + * .adjustment() + * .replacesAdjustmentId() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [ReplaceAdjustment]. */ + class Builder internal constructor() { + + private var adjustment: JsonField? = null + private var replacesAdjustmentId: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(replaceAdjustment: ReplaceAdjustment) = apply { + adjustment = replaceAdjustment.adjustment + replacesAdjustmentId = replaceAdjustment.replacesAdjustmentId + additionalProperties = replaceAdjustment.additionalProperties.toMutableMap() + } + + /** The definition of a new adjustment to create and add to the subscription. */ + fun adjustment(adjustment: Adjustment) = adjustment(JsonField.of(adjustment)) + + /** + * Sets [Builder.adjustment] to an arbitrary JSON value. + * + * You should usually call [Builder.adjustment] with a well-typed [Adjustment] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun adjustment(adjustment: JsonField) = apply { + this.adjustment = adjustment + } + + /** + * Alias for calling [adjustment] with + * `Adjustment.ofPercentageDiscount(percentageDiscount)`. + */ + fun adjustment(percentageDiscount: NewPercentageDiscount) = + adjustment(Adjustment.ofPercentageDiscount(percentageDiscount)) + + /** + * Alias for calling [adjustment] with the following: + * ```kotlin + * NewPercentageDiscount.builder() + * .adjustmentType(NewPercentageDiscount.AdjustmentType.PERCENTAGE_DISCOUNT) + * .percentageDiscount(percentageDiscount) + * .build() + * ``` + */ + fun percentageDiscountAdjustment(percentageDiscount: Double) = + adjustment( + NewPercentageDiscount.builder() + .adjustmentType(NewPercentageDiscount.AdjustmentType.PERCENTAGE_DISCOUNT) + .percentageDiscount(percentageDiscount) + .build() + ) + + /** Alias for calling [adjustment] with `Adjustment.ofUsageDiscount(usageDiscount)`. */ + fun adjustment(usageDiscount: NewUsageDiscount) = + adjustment(Adjustment.ofUsageDiscount(usageDiscount)) + + /** + * Alias for calling [adjustment] with the following: + * ```kotlin + * NewUsageDiscount.builder() + * .adjustmentType(NewUsageDiscount.AdjustmentType.USAGE_DISCOUNT) + * .usageDiscount(usageDiscount) + * .build() + * ``` + */ + fun usageDiscountAdjustment(usageDiscount: Double) = + adjustment( + NewUsageDiscount.builder() + .adjustmentType(NewUsageDiscount.AdjustmentType.USAGE_DISCOUNT) + .usageDiscount(usageDiscount) + .build() + ) + + /** + * Alias for calling [adjustment] with `Adjustment.ofAmountDiscount(amountDiscount)`. + */ + fun adjustment(amountDiscount: NewAmountDiscount) = + adjustment(Adjustment.ofAmountDiscount(amountDiscount)) + + /** + * Alias for calling [adjustment] with the following: + * ```kotlin + * NewAmountDiscount.builder() + * .adjustmentType(NewAmountDiscount.AdjustmentType.AMOUNT_DISCOUNT) + * .amountDiscount(amountDiscount) + * .build() + * ``` + */ + fun amountDiscountAdjustment(amountDiscount: String) = + adjustment( + NewAmountDiscount.builder() + .adjustmentType(NewAmountDiscount.AdjustmentType.AMOUNT_DISCOUNT) + .amountDiscount(amountDiscount) + .build() + ) + + /** Alias for calling [adjustment] with `Adjustment.ofMinimum(minimum)`. */ + fun adjustment(minimum: NewMinimum) = adjustment(Adjustment.ofMinimum(minimum)) + + /** Alias for calling [adjustment] with `Adjustment.ofMaximum(maximum)`. */ + fun adjustment(maximum: NewMaximum) = adjustment(Adjustment.ofMaximum(maximum)) + + /** + * Alias for calling [adjustment] with the following: + * ```kotlin + * NewMaximum.builder() + * .adjustmentType(NewMaximum.AdjustmentType.MAXIMUM) + * .maximumAmount(maximumAmount) + * .build() + * ``` + */ + fun maximumAdjustment(maximumAmount: String) = + adjustment( + NewMaximum.builder() + .adjustmentType(NewMaximum.AdjustmentType.MAXIMUM) + .maximumAmount(maximumAmount) + .build() + ) + + /** The id of the adjustment on the plan to replace in the subscription. */ + fun replacesAdjustmentId(replacesAdjustmentId: String) = + replacesAdjustmentId(JsonField.of(replacesAdjustmentId)) + + /** + * Sets [Builder.replacesAdjustmentId] to an arbitrary JSON value. + * + * You should usually call [Builder.replacesAdjustmentId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun replacesAdjustmentId(replacesAdjustmentId: JsonField) = apply { + this.replacesAdjustmentId = replacesAdjustmentId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ReplaceAdjustment]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .adjustment() + * .replacesAdjustmentId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ReplaceAdjustment = + ReplaceAdjustment( + checkRequired("adjustment", adjustment), + checkRequired("replacesAdjustmentId", replacesAdjustmentId), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ReplaceAdjustment = apply { + if (validated) { + return@apply + } + + adjustment().validate() + replacesAdjustmentId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (adjustment.asKnown()?.validity() ?: 0) + + (if (replacesAdjustmentId.asKnown() == null) 0 else 1) + + /** The definition of a new adjustment to create and add to the subscription. */ + @JsonDeserialize(using = Adjustment.Deserializer::class) + @JsonSerialize(using = Adjustment.Serializer::class) + class Adjustment + private constructor( + private val percentageDiscount: NewPercentageDiscount? = null, + private val usageDiscount: NewUsageDiscount? = null, + private val amountDiscount: NewAmountDiscount? = null, + private val minimum: NewMinimum? = null, + private val maximum: NewMaximum? = null, + private val _json: JsonValue? = null, + ) { + + fun percentageDiscount(): NewPercentageDiscount? = percentageDiscount + + fun usageDiscount(): NewUsageDiscount? = usageDiscount + + fun amountDiscount(): NewAmountDiscount? = amountDiscount + + fun minimum(): NewMinimum? = minimum + + fun maximum(): NewMaximum? = maximum + + fun isPercentageDiscount(): Boolean = percentageDiscount != null + + fun isUsageDiscount(): Boolean = usageDiscount != null + + fun isAmountDiscount(): Boolean = amountDiscount != null + + fun isMinimum(): Boolean = minimum != null + + fun isMaximum(): Boolean = maximum != null + + fun asPercentageDiscount(): NewPercentageDiscount = + percentageDiscount.getOrThrow("percentageDiscount") + + fun asUsageDiscount(): NewUsageDiscount = usageDiscount.getOrThrow("usageDiscount") + + fun asAmountDiscount(): NewAmountDiscount = amountDiscount.getOrThrow("amountDiscount") + + fun asMinimum(): NewMinimum = minimum.getOrThrow("minimum") + + fun asMaximum(): NewMaximum = maximum.getOrThrow("maximum") + + fun _json(): JsonValue? = _json + + fun accept(visitor: Visitor): T = + when { + percentageDiscount != null -> + visitor.visitPercentageDiscount(percentageDiscount) + usageDiscount != null -> visitor.visitUsageDiscount(usageDiscount) + amountDiscount != null -> visitor.visitAmountDiscount(amountDiscount) + minimum != null -> visitor.visitMinimum(minimum) + maximum != null -> visitor.visitMaximum(maximum) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Adjustment = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitPercentageDiscount( + percentageDiscount: NewPercentageDiscount + ) { + percentageDiscount.validate() + } + + override fun visitUsageDiscount(usageDiscount: NewUsageDiscount) { + usageDiscount.validate() + } + + override fun visitAmountDiscount(amountDiscount: NewAmountDiscount) { + amountDiscount.validate() + } + + override fun visitMinimum(minimum: NewMinimum) { + minimum.validate() + } + + override fun visitMaximum(maximum: NewMaximum) { + maximum.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitPercentageDiscount( + percentageDiscount: NewPercentageDiscount + ) = percentageDiscount.validity() + + override fun visitUsageDiscount(usageDiscount: NewUsageDiscount) = + usageDiscount.validity() + + override fun visitAmountDiscount(amountDiscount: NewAmountDiscount) = + amountDiscount.validity() + + override fun visitMinimum(minimum: NewMinimum) = minimum.validity() + + override fun visitMaximum(maximum: NewMaximum) = maximum.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Adjustment && + percentageDiscount == other.percentageDiscount && + usageDiscount == other.usageDiscount && + amountDiscount == other.amountDiscount && + minimum == other.minimum && + maximum == other.maximum + } + + override fun hashCode(): Int = + Objects.hash(percentageDiscount, usageDiscount, amountDiscount, minimum, maximum) + + override fun toString(): String = + when { + percentageDiscount != null -> + "Adjustment{percentageDiscount=$percentageDiscount}" + usageDiscount != null -> "Adjustment{usageDiscount=$usageDiscount}" + amountDiscount != null -> "Adjustment{amountDiscount=$amountDiscount}" + minimum != null -> "Adjustment{minimum=$minimum}" + maximum != null -> "Adjustment{maximum=$maximum}" + _json != null -> "Adjustment{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Adjustment") + } + + companion object { + + fun ofPercentageDiscount(percentageDiscount: NewPercentageDiscount) = + Adjustment(percentageDiscount = percentageDiscount) + + fun ofUsageDiscount(usageDiscount: NewUsageDiscount) = + Adjustment(usageDiscount = usageDiscount) + + fun ofAmountDiscount(amountDiscount: NewAmountDiscount) = + Adjustment(amountDiscount = amountDiscount) + + fun ofMinimum(minimum: NewMinimum) = Adjustment(minimum = minimum) + + fun ofMaximum(maximum: NewMaximum) = Adjustment(maximum = maximum) + } + + /** + * An interface that defines how to map each variant of [Adjustment] to a value of type + * [T]. + */ + interface Visitor { + + fun visitPercentageDiscount(percentageDiscount: NewPercentageDiscount): T + + fun visitUsageDiscount(usageDiscount: NewUsageDiscount): T + + fun visitAmountDiscount(amountDiscount: NewAmountDiscount): T + + fun visitMinimum(minimum: NewMinimum): T + + fun visitMaximum(maximum: NewMaximum): T + + /** + * Maps an unknown variant of [Adjustment] to a value of type [T]. + * + * An instance of [Adjustment] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the + * SDK is unaware of. + * + * @throws OrbInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw OrbInvalidDataException("Unknown Adjustment: $json") + } + } + + internal class Deserializer : BaseDeserializer(Adjustment::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Adjustment { + val json = JsonValue.fromJsonNode(node) + val adjustmentType = json.asObject()?.get("adjustment_type")?.asString() + + when (adjustmentType) { + "percentage_discount" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Adjustment(percentageDiscount = it, _json = json) } + ?: Adjustment(_json = json) + } + "usage_discount" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(usageDiscount = it, _json = json) + } ?: Adjustment(_json = json) + } + "amount_discount" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(amountDiscount = it, _json = json) + } ?: Adjustment(_json = json) + } + "minimum" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(minimum = it, _json = json) + } ?: Adjustment(_json = json) + } + "maximum" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(maximum = it, _json = json) + } ?: Adjustment(_json = json) + } + } + + return Adjustment(_json = json) + } + } + + internal class Serializer : BaseSerializer(Adjustment::class) { + + override fun serialize( + value: Adjustment, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.percentageDiscount != null -> + generator.writeObject(value.percentageDiscount) + value.usageDiscount != null -> generator.writeObject(value.usageDiscount) + value.amountDiscount != null -> generator.writeObject(value.amountDiscount) + value.minimum != null -> generator.writeObject(value.minimum) + value.maximum != null -> generator.writeObject(value.maximum) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Adjustment") + } + } + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ReplaceAdjustment && + adjustment == other.adjustment && + replacesAdjustmentId == other.replacesAdjustmentId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(adjustment, replacesAdjustmentId, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ReplaceAdjustment{adjustment=$adjustment, replacesAdjustmentId=$replacesAdjustmentId, additionalProperties=$additionalProperties}" + } + + class ReplacePrice + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val replacesPriceId: JsonField, + private val allocationPrice: JsonField, + private val discounts: JsonField>, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val maximumAmount: JsonField, + private val minimumAmount: JsonField, + private val price: JsonField, + private val priceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("replaces_price_id") + @ExcludeMissing + replacesPriceId: JsonField = JsonMissing.of(), + @JsonProperty("allocation_price") + @ExcludeMissing + allocationPrice: JsonField = JsonMissing.of(), + @JsonProperty("discounts") + @ExcludeMissing + discounts: JsonField> = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("maximum_amount") + @ExcludeMissing + maximumAmount: JsonField = JsonMissing.of(), + @JsonProperty("minimum_amount") + @ExcludeMissing + minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("price") @ExcludeMissing price: JsonField = JsonMissing.of(), + @JsonProperty("price_id") @ExcludeMissing priceId: JsonField = JsonMissing.of(), + ) : this( + replacesPriceId, + allocationPrice, + discounts, + externalPriceId, + fixedPriceQuantity, + maximumAmount, + minimumAmount, + price, + priceId, + mutableMapOf(), + ) + + /** + * The id of the price on the plan to replace in the subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun replacesPriceId(): String = replacesPriceId.getRequired("replaces_price_id") + + /** + * The definition of a new allocation price to create and add to the subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun allocationPrice(): NewAllocationPrice? = allocationPrice.getNullable("allocation_price") + + /** + * [DEPRECATED] Use add_adjustments instead. The subscription's discounts for the + * replacement price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + @Deprecated("deprecated") + fun discounts(): List? = discounts.getNullable("discounts") + + /** + * The external price id of the price to add to the subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * The new quantity of the price, if the price is a fixed price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * [DEPRECATED] Use add_adjustments instead. The subscription's maximum amount for the + * replacement price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + @Deprecated("deprecated") + fun maximumAmount(): String? = maximumAmount.getNullable("maximum_amount") + + /** + * [DEPRECATED] Use add_adjustments instead. The subscription's minimum amount for the + * replacement price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + @Deprecated("deprecated") + fun minimumAmount(): String? = minimumAmount.getNullable("minimum_amount") + + /** + * New subscription price request body params. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun price(): Price? = price.getNullable("price") + + /** + * The id of the price to add to the subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun priceId(): String? = priceId.getNullable("price_id") + + /** + * Returns the raw JSON value of [replacesPriceId]. + * + * Unlike [replacesPriceId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("replaces_price_id") + @ExcludeMissing + fun _replacesPriceId(): JsonField = replacesPriceId + + /** + * Returns the raw JSON value of [allocationPrice]. + * + * Unlike [allocationPrice], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("allocation_price") + @ExcludeMissing + fun _allocationPrice(): JsonField = allocationPrice + + /** + * Returns the raw JSON value of [discounts]. + * + * Unlike [discounts], this method doesn't throw if the JSON field has an unexpected type. + */ + @Deprecated("deprecated") + @JsonProperty("discounts") + @ExcludeMissing + fun _discounts(): JsonField> = discounts + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [maximumAmount]. + * + * Unlike [maximumAmount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @Deprecated("deprecated") + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount + + /** + * Returns the raw JSON value of [minimumAmount]. + * + * Unlike [minimumAmount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @Deprecated("deprecated") + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount + + /** + * Returns the raw JSON value of [price]. + * + * Unlike [price], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("price") @ExcludeMissing fun _price(): JsonField = price + + /** + * Returns the raw JSON value of [priceId]. + * + * Unlike [priceId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ReplacePrice]. + * + * The following fields are required: + * ```kotlin + * .replacesPriceId() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [ReplacePrice]. */ + class Builder internal constructor() { + + private var replacesPriceId: JsonField? = null + private var allocationPrice: JsonField = JsonMissing.of() + private var discounts: JsonField>? = null + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var maximumAmount: JsonField = JsonMissing.of() + private var minimumAmount: JsonField = JsonMissing.of() + private var price: JsonField = JsonMissing.of() + private var priceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(replacePrice: ReplacePrice) = apply { + replacesPriceId = replacePrice.replacesPriceId + allocationPrice = replacePrice.allocationPrice + discounts = replacePrice.discounts.map { it.toMutableList() } + externalPriceId = replacePrice.externalPriceId + fixedPriceQuantity = replacePrice.fixedPriceQuantity + maximumAmount = replacePrice.maximumAmount + minimumAmount = replacePrice.minimumAmount + price = replacePrice.price + priceId = replacePrice.priceId + additionalProperties = replacePrice.additionalProperties.toMutableMap() + } + + /** The id of the price on the plan to replace in the subscription. */ + fun replacesPriceId(replacesPriceId: String) = + replacesPriceId(JsonField.of(replacesPriceId)) + + /** + * Sets [Builder.replacesPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.replacesPriceId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun replacesPriceId(replacesPriceId: JsonField) = apply { + this.replacesPriceId = replacesPriceId + } + + /** The definition of a new allocation price to create and add to the subscription. */ + fun allocationPrice(allocationPrice: NewAllocationPrice?) = + allocationPrice(JsonField.ofNullable(allocationPrice)) + + /** + * Sets [Builder.allocationPrice] to an arbitrary JSON value. + * + * You should usually call [Builder.allocationPrice] with a well-typed + * [NewAllocationPrice] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun allocationPrice(allocationPrice: JsonField) = apply { + this.allocationPrice = allocationPrice + } + + /** + * [DEPRECATED] Use add_adjustments instead. The subscription's discounts for the + * replacement price. + */ + @Deprecated("deprecated") + fun discounts(discounts: List?) = + discounts(JsonField.ofNullable(discounts)) + + /** + * Sets [Builder.discounts] to an arbitrary JSON value. + * + * You should usually call [Builder.discounts] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + @Deprecated("deprecated") + fun discounts(discounts: JsonField>) = apply { + this.discounts = discounts.map { it.toMutableList() } + } + + /** + * Adds a single [DiscountOverride] to [discounts]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + @Deprecated("deprecated") + fun addDiscount(discount: DiscountOverride) = apply { + discounts = + (discounts ?: JsonField.of(mutableListOf())).also { + checkKnown("discounts", it).add(discount) + } + } + + /** The external price id of the price to add to the subscription. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** The new quantity of the price, if the price is a fixed price. */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** + * [DEPRECATED] Use add_adjustments instead. The subscription's maximum amount for the + * replacement price. + */ + @Deprecated("deprecated") + fun maximumAmount(maximumAmount: String?) = + maximumAmount(JsonField.ofNullable(maximumAmount)) + + /** + * Sets [Builder.maximumAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.maximumAmount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + @Deprecated("deprecated") + fun maximumAmount(maximumAmount: JsonField) = apply { + this.maximumAmount = maximumAmount + } + + /** + * [DEPRECATED] Use add_adjustments instead. The subscription's minimum amount for the + * replacement price. + */ + @Deprecated("deprecated") + fun minimumAmount(minimumAmount: String?) = + minimumAmount(JsonField.ofNullable(minimumAmount)) + + /** + * Sets [Builder.minimumAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumAmount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + @Deprecated("deprecated") + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount + } + + /** New subscription price request body params. */ + fun price(price: Price?) = price(JsonField.ofNullable(price)) + + /** + * Sets [Builder.price] to an arbitrary JSON value. + * + * You should usually call [Builder.price] with a well-typed [Price] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun price(price: JsonField) = apply { this.price = price } + + /** Alias for calling [price] with `Price.ofUnit(unit)`. */ + fun price(unit: NewSubscriptionUnitPrice) = price(Price.ofUnit(unit)) + + /** Alias for calling [price] with `Price.ofTiered(tiered)`. */ + fun price(tiered: NewSubscriptionTieredPrice) = price(Price.ofTiered(tiered)) + + /** Alias for calling [price] with `Price.ofBulk(bulk)`. */ + fun price(bulk: NewSubscriptionBulkPrice) = price(Price.ofBulk(bulk)) + + /** Alias for calling [price] with `Price.ofBulkWithFilters(bulkWithFilters)`. */ + fun price(bulkWithFilters: Price.BulkWithFilters) = + price(Price.ofBulkWithFilters(bulkWithFilters)) + + /** Alias for calling [price] with `Price.ofPackage(package_)`. */ + fun price(package_: NewSubscriptionPackagePrice) = price(Price.ofPackage(package_)) + + /** Alias for calling [price] with `Price.ofMatrix(matrix)`. */ + fun price(matrix: NewSubscriptionMatrixPrice) = price(Price.ofMatrix(matrix)) + + /** + * Alias for calling [price] with `Price.ofThresholdTotalAmount(thresholdTotalAmount)`. + */ + fun price(thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice) = + price(Price.ofThresholdTotalAmount(thresholdTotalAmount)) + + /** Alias for calling [price] with `Price.ofTieredPackage(tieredPackage)`. */ + fun price(tieredPackage: NewSubscriptionTieredPackagePrice) = + price(Price.ofTieredPackage(tieredPackage)) + + /** Alias for calling [price] with `Price.ofTieredWithMinimum(tieredWithMinimum)`. */ + fun price(tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice) = + price(Price.ofTieredWithMinimum(tieredWithMinimum)) + + /** Alias for calling [price] with `Price.ofGroupedTiered(groupedTiered)`. */ + fun price(groupedTiered: NewSubscriptionGroupedTieredPrice) = + price(Price.ofGroupedTiered(groupedTiered)) + + /** + * Alias for calling [price] with + * `Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)`. + */ + fun price(tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice) = + price(Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)) + + /** + * Alias for calling [price] with + * `Price.ofPackageWithAllocation(packageWithAllocation)`. + */ + fun price(packageWithAllocation: NewSubscriptionPackageWithAllocationPrice) = + price(Price.ofPackageWithAllocation(packageWithAllocation)) + + /** Alias for calling [price] with `Price.ofUnitWithPercent(unitWithPercent)`. */ + fun price(unitWithPercent: NewSubscriptionUnitWithPercentPrice) = + price(Price.ofUnitWithPercent(unitWithPercent)) + + /** + * Alias for calling [price] with `Price.ofMatrixWithAllocation(matrixWithAllocation)`. + */ + fun price(matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice) = + price(Price.ofMatrixWithAllocation(matrixWithAllocation)) + + /** + * Alias for calling [price] with `Price.ofTieredWithProration(tieredWithProration)`. + */ + fun price(tieredWithProration: Price.TieredWithProration) = + price(Price.ofTieredWithProration(tieredWithProration)) + + /** Alias for calling [price] with `Price.ofUnitWithProration(unitWithProration)`. */ + fun price(unitWithProration: NewSubscriptionUnitWithProrationPrice) = + price(Price.ofUnitWithProration(unitWithProration)) + + /** Alias for calling [price] with `Price.ofGroupedAllocation(groupedAllocation)`. */ + fun price(groupedAllocation: NewSubscriptionGroupedAllocationPrice) = + price(Price.ofGroupedAllocation(groupedAllocation)) + + /** Alias for calling [price] with `Price.ofBulkWithProration(bulkWithProration)`. */ + fun price(bulkWithProration: NewSubscriptionBulkWithProrationPrice) = + price(Price.ofBulkWithProration(bulkWithProration)) + + /** + * Alias for calling [price] with + * `Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)`. + */ + fun price(groupedWithProratedMinimum: NewSubscriptionGroupedWithProratedMinimumPrice) = + price(Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)) + + /** + * Alias for calling [price] with + * `Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)`. + */ + fun price(groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice) = + price(Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)) + + /** + * Alias for calling [price] with + * `Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)`. + */ + fun price(groupedWithMinMaxThresholds: Price.GroupedWithMinMaxThresholds) = + price(Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)) + + /** + * Alias for calling [price] with + * `Price.ofMatrixWithDisplayName(matrixWithDisplayName)`. + */ + fun price(matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice) = + price(Price.ofMatrixWithDisplayName(matrixWithDisplayName)) + + /** + * Alias for calling [price] with `Price.ofGroupedTieredPackage(groupedTieredPackage)`. + */ + fun price(groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice) = + price(Price.ofGroupedTieredPackage(groupedTieredPackage)) + + /** + * Alias for calling [price] with + * `Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)`. + */ + fun price(maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice) = + price(Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)) + + /** + * Alias for calling [price] with + * `Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)`. + */ + fun price( + scalableMatrixWithUnitPricing: NewSubscriptionScalableMatrixWithUnitPricingPrice + ) = price(Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)) + + /** + * Alias for calling [price] with + * `Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)`. + */ + fun price( + scalableMatrixWithTieredPricing: NewSubscriptionScalableMatrixWithTieredPricingPrice + ) = price(Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)) + + /** + * Alias for calling [price] with + * `Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)`. + */ + fun price(cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice) = + price(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) + + /** Alias for calling [price] with `Price.ofMinimum(minimum)`. */ + fun price(minimum: NewSubscriptionMinimumCompositePrice) = + price(Price.ofMinimum(minimum)) + + /** Alias for calling [price] with `Price.ofPercent(percent)`. */ + fun price(percent: Price.Percent) = price(Price.ofPercent(percent)) + + /** Alias for calling [price] with `Price.ofEventOutput(eventOutput)`. */ + fun price(eventOutput: Price.EventOutput) = price(Price.ofEventOutput(eventOutput)) + + /** The id of the price to add to the subscription. */ + fun priceId(priceId: String?) = priceId(JsonField.ofNullable(priceId)) + + /** + * Sets [Builder.priceId] to an arbitrary JSON value. + * + * You should usually call [Builder.priceId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun priceId(priceId: JsonField) = apply { this.priceId = priceId } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ReplacePrice]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .replacesPriceId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): ReplacePrice = ReplacePrice( checkRequired("replacesPriceId", replacesPriceId), @@ -14417,1286 +16490,3351 @@ private constructor( (discounts ?: JsonMissing.of()).map { it.toImmutable() }, externalPriceId, fixedPriceQuantity, - maximumAmount, - minimumAmount, - price, - priceId, - additionalProperties.toMutableMap(), + maximumAmount, + minimumAmount, + price, + priceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ReplacePrice = apply { + if (validated) { + return@apply + } + + replacesPriceId() + allocationPrice()?.validate() + discounts()?.forEach { it.validate() } + externalPriceId() + fixedPriceQuantity() + maximumAmount() + minimumAmount() + price()?.validate() + priceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (replacesPriceId.asKnown() == null) 0 else 1) + + (allocationPrice.asKnown()?.validity() ?: 0) + + (discounts.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (maximumAmount.asKnown() == null) 0 else 1) + + (if (minimumAmount.asKnown() == null) 0 else 1) + + (price.asKnown()?.validity() ?: 0) + + (if (priceId.asKnown() == null) 0 else 1) + + /** New subscription price request body params. */ + @JsonDeserialize(using = Price.Deserializer::class) + @JsonSerialize(using = Price.Serializer::class) + class Price + private constructor( + private val unit: NewSubscriptionUnitPrice? = null, + private val tiered: NewSubscriptionTieredPrice? = null, + private val bulk: NewSubscriptionBulkPrice? = null, + private val bulkWithFilters: BulkWithFilters? = null, + private val package_: NewSubscriptionPackagePrice? = null, + private val matrix: NewSubscriptionMatrixPrice? = null, + private val thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice? = null, + private val tieredPackage: NewSubscriptionTieredPackagePrice? = null, + private val tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice? = null, + private val groupedTiered: NewSubscriptionGroupedTieredPrice? = null, + private val tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice? = + null, + private val packageWithAllocation: NewSubscriptionPackageWithAllocationPrice? = null, + private val unitWithPercent: NewSubscriptionUnitWithPercentPrice? = null, + private val matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice? = null, + private val tieredWithProration: TieredWithProration? = null, + private val unitWithProration: NewSubscriptionUnitWithProrationPrice? = null, + private val groupedAllocation: NewSubscriptionGroupedAllocationPrice? = null, + private val bulkWithProration: NewSubscriptionBulkWithProrationPrice? = null, + private val groupedWithProratedMinimum: + NewSubscriptionGroupedWithProratedMinimumPrice? = + null, + private val groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice? = + null, + private val groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds? = null, + private val matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice? = null, + private val groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice? = null, + private val maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice? = null, + private val scalableMatrixWithUnitPricing: + NewSubscriptionScalableMatrixWithUnitPricingPrice? = + null, + private val scalableMatrixWithTieredPricing: + NewSubscriptionScalableMatrixWithTieredPricingPrice? = + null, + private val cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice? = null, + private val minimum: NewSubscriptionMinimumCompositePrice? = null, + private val percent: Percent? = null, + private val eventOutput: EventOutput? = null, + private val _json: JsonValue? = null, + ) { + + fun unit(): NewSubscriptionUnitPrice? = unit + + fun tiered(): NewSubscriptionTieredPrice? = tiered + + fun bulk(): NewSubscriptionBulkPrice? = bulk + + fun bulkWithFilters(): BulkWithFilters? = bulkWithFilters + + fun package_(): NewSubscriptionPackagePrice? = package_ + + fun matrix(): NewSubscriptionMatrixPrice? = matrix + + fun thresholdTotalAmount(): NewSubscriptionThresholdTotalAmountPrice? = + thresholdTotalAmount + + fun tieredPackage(): NewSubscriptionTieredPackagePrice? = tieredPackage + + fun tieredWithMinimum(): NewSubscriptionTieredWithMinimumPrice? = tieredWithMinimum + + fun groupedTiered(): NewSubscriptionGroupedTieredPrice? = groupedTiered + + fun tieredPackageWithMinimum(): NewSubscriptionTieredPackageWithMinimumPrice? = + tieredPackageWithMinimum + + fun packageWithAllocation(): NewSubscriptionPackageWithAllocationPrice? = + packageWithAllocation + + fun unitWithPercent(): NewSubscriptionUnitWithPercentPrice? = unitWithPercent + + fun matrixWithAllocation(): NewSubscriptionMatrixWithAllocationPrice? = + matrixWithAllocation + + fun tieredWithProration(): TieredWithProration? = tieredWithProration + + fun unitWithProration(): NewSubscriptionUnitWithProrationPrice? = unitWithProration + + fun groupedAllocation(): NewSubscriptionGroupedAllocationPrice? = groupedAllocation + + fun bulkWithProration(): NewSubscriptionBulkWithProrationPrice? = bulkWithProration + + fun groupedWithProratedMinimum(): NewSubscriptionGroupedWithProratedMinimumPrice? = + groupedWithProratedMinimum + + fun groupedWithMeteredMinimum(): NewSubscriptionGroupedWithMeteredMinimumPrice? = + groupedWithMeteredMinimum + + fun groupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds? = + groupedWithMinMaxThresholds + + fun matrixWithDisplayName(): NewSubscriptionMatrixWithDisplayNamePrice? = + matrixWithDisplayName + + fun groupedTieredPackage(): NewSubscriptionGroupedTieredPackagePrice? = + groupedTieredPackage + + fun maxGroupTieredPackage(): NewSubscriptionMaxGroupTieredPackagePrice? = + maxGroupTieredPackage + + fun scalableMatrixWithUnitPricing(): + NewSubscriptionScalableMatrixWithUnitPricingPrice? = scalableMatrixWithUnitPricing + + fun scalableMatrixWithTieredPricing(): + NewSubscriptionScalableMatrixWithTieredPricingPrice? = + scalableMatrixWithTieredPricing + + fun cumulativeGroupedBulk(): NewSubscriptionCumulativeGroupedBulkPrice? = + cumulativeGroupedBulk + + fun minimum(): NewSubscriptionMinimumCompositePrice? = minimum + + fun percent(): Percent? = percent + + fun eventOutput(): EventOutput? = eventOutput + + fun isUnit(): Boolean = unit != null + + fun isTiered(): Boolean = tiered != null + + fun isBulk(): Boolean = bulk != null + + fun isBulkWithFilters(): Boolean = bulkWithFilters != null + + fun isPackage(): Boolean = package_ != null + + fun isMatrix(): Boolean = matrix != null + + fun isThresholdTotalAmount(): Boolean = thresholdTotalAmount != null + + fun isTieredPackage(): Boolean = tieredPackage != null + + fun isTieredWithMinimum(): Boolean = tieredWithMinimum != null + + fun isGroupedTiered(): Boolean = groupedTiered != null + + fun isTieredPackageWithMinimum(): Boolean = tieredPackageWithMinimum != null + + fun isPackageWithAllocation(): Boolean = packageWithAllocation != null + + fun isUnitWithPercent(): Boolean = unitWithPercent != null + + fun isMatrixWithAllocation(): Boolean = matrixWithAllocation != null + + fun isTieredWithProration(): Boolean = tieredWithProration != null + + fun isUnitWithProration(): Boolean = unitWithProration != null + + fun isGroupedAllocation(): Boolean = groupedAllocation != null + + fun isBulkWithProration(): Boolean = bulkWithProration != null + + fun isGroupedWithProratedMinimum(): Boolean = groupedWithProratedMinimum != null + + fun isGroupedWithMeteredMinimum(): Boolean = groupedWithMeteredMinimum != null + + fun isGroupedWithMinMaxThresholds(): Boolean = groupedWithMinMaxThresholds != null + + fun isMatrixWithDisplayName(): Boolean = matrixWithDisplayName != null + + fun isGroupedTieredPackage(): Boolean = groupedTieredPackage != null + + fun isMaxGroupTieredPackage(): Boolean = maxGroupTieredPackage != null + + fun isScalableMatrixWithUnitPricing(): Boolean = scalableMatrixWithUnitPricing != null + + fun isScalableMatrixWithTieredPricing(): Boolean = + scalableMatrixWithTieredPricing != null + + fun isCumulativeGroupedBulk(): Boolean = cumulativeGroupedBulk != null + + fun isMinimum(): Boolean = minimum != null + + fun isPercent(): Boolean = percent != null + + fun isEventOutput(): Boolean = eventOutput != null + + fun asUnit(): NewSubscriptionUnitPrice = unit.getOrThrow("unit") + + fun asTiered(): NewSubscriptionTieredPrice = tiered.getOrThrow("tiered") + + fun asBulk(): NewSubscriptionBulkPrice = bulk.getOrThrow("bulk") + + fun asBulkWithFilters(): BulkWithFilters = bulkWithFilters.getOrThrow("bulkWithFilters") + + fun asPackage(): NewSubscriptionPackagePrice = package_.getOrThrow("package_") + + fun asMatrix(): NewSubscriptionMatrixPrice = matrix.getOrThrow("matrix") + + fun asThresholdTotalAmount(): NewSubscriptionThresholdTotalAmountPrice = + thresholdTotalAmount.getOrThrow("thresholdTotalAmount") + + fun asTieredPackage(): NewSubscriptionTieredPackagePrice = + tieredPackage.getOrThrow("tieredPackage") + + fun asTieredWithMinimum(): NewSubscriptionTieredWithMinimumPrice = + tieredWithMinimum.getOrThrow("tieredWithMinimum") + + fun asGroupedTiered(): NewSubscriptionGroupedTieredPrice = + groupedTiered.getOrThrow("groupedTiered") + + fun asTieredPackageWithMinimum(): NewSubscriptionTieredPackageWithMinimumPrice = + tieredPackageWithMinimum.getOrThrow("tieredPackageWithMinimum") + + fun asPackageWithAllocation(): NewSubscriptionPackageWithAllocationPrice = + packageWithAllocation.getOrThrow("packageWithAllocation") + + fun asUnitWithPercent(): NewSubscriptionUnitWithPercentPrice = + unitWithPercent.getOrThrow("unitWithPercent") + + fun asMatrixWithAllocation(): NewSubscriptionMatrixWithAllocationPrice = + matrixWithAllocation.getOrThrow("matrixWithAllocation") + + fun asTieredWithProration(): TieredWithProration = + tieredWithProration.getOrThrow("tieredWithProration") + + fun asUnitWithProration(): NewSubscriptionUnitWithProrationPrice = + unitWithProration.getOrThrow("unitWithProration") + + fun asGroupedAllocation(): NewSubscriptionGroupedAllocationPrice = + groupedAllocation.getOrThrow("groupedAllocation") + + fun asBulkWithProration(): NewSubscriptionBulkWithProrationPrice = + bulkWithProration.getOrThrow("bulkWithProration") + + fun asGroupedWithProratedMinimum(): NewSubscriptionGroupedWithProratedMinimumPrice = + groupedWithProratedMinimum.getOrThrow("groupedWithProratedMinimum") + + fun asGroupedWithMeteredMinimum(): NewSubscriptionGroupedWithMeteredMinimumPrice = + groupedWithMeteredMinimum.getOrThrow("groupedWithMeteredMinimum") + + fun asGroupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds = + groupedWithMinMaxThresholds.getOrThrow("groupedWithMinMaxThresholds") + + fun asMatrixWithDisplayName(): NewSubscriptionMatrixWithDisplayNamePrice = + matrixWithDisplayName.getOrThrow("matrixWithDisplayName") + + fun asGroupedTieredPackage(): NewSubscriptionGroupedTieredPackagePrice = + groupedTieredPackage.getOrThrow("groupedTieredPackage") + + fun asMaxGroupTieredPackage(): NewSubscriptionMaxGroupTieredPackagePrice = + maxGroupTieredPackage.getOrThrow("maxGroupTieredPackage") + + fun asScalableMatrixWithUnitPricing(): + NewSubscriptionScalableMatrixWithUnitPricingPrice = + scalableMatrixWithUnitPricing.getOrThrow("scalableMatrixWithUnitPricing") + + fun asScalableMatrixWithTieredPricing(): + NewSubscriptionScalableMatrixWithTieredPricingPrice = + scalableMatrixWithTieredPricing.getOrThrow("scalableMatrixWithTieredPricing") + + fun asCumulativeGroupedBulk(): NewSubscriptionCumulativeGroupedBulkPrice = + cumulativeGroupedBulk.getOrThrow("cumulativeGroupedBulk") + + fun asMinimum(): NewSubscriptionMinimumCompositePrice = minimum.getOrThrow("minimum") + + fun asPercent(): Percent = percent.getOrThrow("percent") + + fun asEventOutput(): EventOutput = eventOutput.getOrThrow("eventOutput") + + fun _json(): JsonValue? = _json + + fun accept(visitor: Visitor): T = + when { + unit != null -> visitor.visitUnit(unit) + tiered != null -> visitor.visitTiered(tiered) + bulk != null -> visitor.visitBulk(bulk) + bulkWithFilters != null -> visitor.visitBulkWithFilters(bulkWithFilters) + package_ != null -> visitor.visitPackage(package_) + matrix != null -> visitor.visitMatrix(matrix) + thresholdTotalAmount != null -> + visitor.visitThresholdTotalAmount(thresholdTotalAmount) + tieredPackage != null -> visitor.visitTieredPackage(tieredPackage) + tieredWithMinimum != null -> visitor.visitTieredWithMinimum(tieredWithMinimum) + groupedTiered != null -> visitor.visitGroupedTiered(groupedTiered) + tieredPackageWithMinimum != null -> + visitor.visitTieredPackageWithMinimum(tieredPackageWithMinimum) + packageWithAllocation != null -> + visitor.visitPackageWithAllocation(packageWithAllocation) + unitWithPercent != null -> visitor.visitUnitWithPercent(unitWithPercent) + matrixWithAllocation != null -> + visitor.visitMatrixWithAllocation(matrixWithAllocation) + tieredWithProration != null -> + visitor.visitTieredWithProration(tieredWithProration) + unitWithProration != null -> visitor.visitUnitWithProration(unitWithProration) + groupedAllocation != null -> visitor.visitGroupedAllocation(groupedAllocation) + bulkWithProration != null -> visitor.visitBulkWithProration(bulkWithProration) + groupedWithProratedMinimum != null -> + visitor.visitGroupedWithProratedMinimum(groupedWithProratedMinimum) + groupedWithMeteredMinimum != null -> + visitor.visitGroupedWithMeteredMinimum(groupedWithMeteredMinimum) + groupedWithMinMaxThresholds != null -> + visitor.visitGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds) + matrixWithDisplayName != null -> + visitor.visitMatrixWithDisplayName(matrixWithDisplayName) + groupedTieredPackage != null -> + visitor.visitGroupedTieredPackage(groupedTieredPackage) + maxGroupTieredPackage != null -> + visitor.visitMaxGroupTieredPackage(maxGroupTieredPackage) + scalableMatrixWithUnitPricing != null -> + visitor.visitScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing) + scalableMatrixWithTieredPricing != null -> + visitor.visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing + ) + cumulativeGroupedBulk != null -> + visitor.visitCumulativeGroupedBulk(cumulativeGroupedBulk) + minimum != null -> visitor.visitMinimum(minimum) + percent != null -> visitor.visitPercent(percent) + eventOutput != null -> visitor.visitEventOutput(eventOutput) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Price = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitUnit(unit: NewSubscriptionUnitPrice) { + unit.validate() + } + + override fun visitTiered(tiered: NewSubscriptionTieredPrice) { + tiered.validate() + } + + override fun visitBulk(bulk: NewSubscriptionBulkPrice) { + bulk.validate() + } + + override fun visitBulkWithFilters(bulkWithFilters: BulkWithFilters) { + bulkWithFilters.validate() + } + + override fun visitPackage(package_: NewSubscriptionPackagePrice) { + package_.validate() + } + + override fun visitMatrix(matrix: NewSubscriptionMatrixPrice) { + matrix.validate() + } + + override fun visitThresholdTotalAmount( + thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice + ) { + thresholdTotalAmount.validate() + } + + override fun visitTieredPackage( + tieredPackage: NewSubscriptionTieredPackagePrice + ) { + tieredPackage.validate() + } + + override fun visitTieredWithMinimum( + tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice + ) { + tieredWithMinimum.validate() + } + + override fun visitGroupedTiered( + groupedTiered: NewSubscriptionGroupedTieredPrice + ) { + groupedTiered.validate() + } + + override fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice + ) { + tieredPackageWithMinimum.validate() + } + + override fun visitPackageWithAllocation( + packageWithAllocation: NewSubscriptionPackageWithAllocationPrice + ) { + packageWithAllocation.validate() + } + + override fun visitUnitWithPercent( + unitWithPercent: NewSubscriptionUnitWithPercentPrice + ) { + unitWithPercent.validate() + } + + override fun visitMatrixWithAllocation( + matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice + ) { + matrixWithAllocation.validate() + } + + override fun visitTieredWithProration( + tieredWithProration: TieredWithProration + ) { + tieredWithProration.validate() + } + + override fun visitUnitWithProration( + unitWithProration: NewSubscriptionUnitWithProrationPrice + ) { + unitWithProration.validate() + } + + override fun visitGroupedAllocation( + groupedAllocation: NewSubscriptionGroupedAllocationPrice + ) { + groupedAllocation.validate() + } + + override fun visitBulkWithProration( + bulkWithProration: NewSubscriptionBulkWithProrationPrice + ) { + bulkWithProration.validate() + } + + override fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: + NewSubscriptionGroupedWithProratedMinimumPrice + ) { + groupedWithProratedMinimum.validate() + } + + override fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice + ) { + groupedWithMeteredMinimum.validate() + } + + override fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) { + groupedWithMinMaxThresholds.validate() + } + + override fun visitMatrixWithDisplayName( + matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice + ) { + matrixWithDisplayName.validate() + } + + override fun visitGroupedTieredPackage( + groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice + ) { + groupedTieredPackage.validate() + } + + override fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice + ) { + maxGroupTieredPackage.validate() + } + + override fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: + NewSubscriptionScalableMatrixWithUnitPricingPrice + ) { + scalableMatrixWithUnitPricing.validate() + } + + override fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: + NewSubscriptionScalableMatrixWithTieredPricingPrice + ) { + scalableMatrixWithTieredPricing.validate() + } + + override fun visitCumulativeGroupedBulk( + cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice + ) { + cumulativeGroupedBulk.validate() + } + + override fun visitMinimum(minimum: NewSubscriptionMinimumCompositePrice) { + minimum.validate() + } + + override fun visitPercent(percent: Percent) { + percent.validate() + } + + override fun visitEventOutput(eventOutput: EventOutput) { + eventOutput.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitUnit(unit: NewSubscriptionUnitPrice) = unit.validity() + + override fun visitTiered(tiered: NewSubscriptionTieredPrice) = + tiered.validity() + + override fun visitBulk(bulk: NewSubscriptionBulkPrice) = bulk.validity() + + override fun visitBulkWithFilters(bulkWithFilters: BulkWithFilters) = + bulkWithFilters.validity() + + override fun visitPackage(package_: NewSubscriptionPackagePrice) = + package_.validity() + + override fun visitMatrix(matrix: NewSubscriptionMatrixPrice) = + matrix.validity() + + override fun visitThresholdTotalAmount( + thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice + ) = thresholdTotalAmount.validity() + + override fun visitTieredPackage( + tieredPackage: NewSubscriptionTieredPackagePrice + ) = tieredPackage.validity() + + override fun visitTieredWithMinimum( + tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice + ) = tieredWithMinimum.validity() + + override fun visitGroupedTiered( + groupedTiered: NewSubscriptionGroupedTieredPrice + ) = groupedTiered.validity() + + override fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice + ) = tieredPackageWithMinimum.validity() + + override fun visitPackageWithAllocation( + packageWithAllocation: NewSubscriptionPackageWithAllocationPrice + ) = packageWithAllocation.validity() + + override fun visitUnitWithPercent( + unitWithPercent: NewSubscriptionUnitWithPercentPrice + ) = unitWithPercent.validity() + + override fun visitMatrixWithAllocation( + matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice + ) = matrixWithAllocation.validity() + + override fun visitTieredWithProration( + tieredWithProration: TieredWithProration + ) = tieredWithProration.validity() + + override fun visitUnitWithProration( + unitWithProration: NewSubscriptionUnitWithProrationPrice + ) = unitWithProration.validity() + + override fun visitGroupedAllocation( + groupedAllocation: NewSubscriptionGroupedAllocationPrice + ) = groupedAllocation.validity() + + override fun visitBulkWithProration( + bulkWithProration: NewSubscriptionBulkWithProrationPrice + ) = bulkWithProration.validity() + + override fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: + NewSubscriptionGroupedWithProratedMinimumPrice + ) = groupedWithProratedMinimum.validity() + + override fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice + ) = groupedWithMeteredMinimum.validity() + + override fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) = groupedWithMinMaxThresholds.validity() + + override fun visitMatrixWithDisplayName( + matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice + ) = matrixWithDisplayName.validity() + + override fun visitGroupedTieredPackage( + groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice + ) = groupedTieredPackage.validity() + + override fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice + ) = maxGroupTieredPackage.validity() + + override fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: + NewSubscriptionScalableMatrixWithUnitPricingPrice + ) = scalableMatrixWithUnitPricing.validity() + + override fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: + NewSubscriptionScalableMatrixWithTieredPricingPrice + ) = scalableMatrixWithTieredPricing.validity() + + override fun visitCumulativeGroupedBulk( + cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice + ) = cumulativeGroupedBulk.validity() + + override fun visitMinimum(minimum: NewSubscriptionMinimumCompositePrice) = + minimum.validity() + + override fun visitPercent(percent: Percent) = percent.validity() + + override fun visitEventOutput(eventOutput: EventOutput) = + eventOutput.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Price && + unit == other.unit && + tiered == other.tiered && + bulk == other.bulk && + bulkWithFilters == other.bulkWithFilters && + package_ == other.package_ && + matrix == other.matrix && + thresholdTotalAmount == other.thresholdTotalAmount && + tieredPackage == other.tieredPackage && + tieredWithMinimum == other.tieredWithMinimum && + groupedTiered == other.groupedTiered && + tieredPackageWithMinimum == other.tieredPackageWithMinimum && + packageWithAllocation == other.packageWithAllocation && + unitWithPercent == other.unitWithPercent && + matrixWithAllocation == other.matrixWithAllocation && + tieredWithProration == other.tieredWithProration && + unitWithProration == other.unitWithProration && + groupedAllocation == other.groupedAllocation && + bulkWithProration == other.bulkWithProration && + groupedWithProratedMinimum == other.groupedWithProratedMinimum && + groupedWithMeteredMinimum == other.groupedWithMeteredMinimum && + groupedWithMinMaxThresholds == other.groupedWithMinMaxThresholds && + matrixWithDisplayName == other.matrixWithDisplayName && + groupedTieredPackage == other.groupedTieredPackage && + maxGroupTieredPackage == other.maxGroupTieredPackage && + scalableMatrixWithUnitPricing == other.scalableMatrixWithUnitPricing && + scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && + cumulativeGroupedBulk == other.cumulativeGroupedBulk && + minimum == other.minimum && + percent == other.percent && + eventOutput == other.eventOutput + } + + override fun hashCode(): Int = + Objects.hash( + unit, + tiered, + bulk, + bulkWithFilters, + package_, + matrix, + thresholdTotalAmount, + tieredPackage, + tieredWithMinimum, + groupedTiered, + tieredPackageWithMinimum, + packageWithAllocation, + unitWithPercent, + matrixWithAllocation, + tieredWithProration, + unitWithProration, + groupedAllocation, + bulkWithProration, + groupedWithProratedMinimum, + groupedWithMeteredMinimum, + groupedWithMinMaxThresholds, + matrixWithDisplayName, + groupedTieredPackage, + maxGroupTieredPackage, + scalableMatrixWithUnitPricing, + scalableMatrixWithTieredPricing, + cumulativeGroupedBulk, + minimum, + percent, + eventOutput, + ) + + override fun toString(): String = + when { + unit != null -> "Price{unit=$unit}" + tiered != null -> "Price{tiered=$tiered}" + bulk != null -> "Price{bulk=$bulk}" + bulkWithFilters != null -> "Price{bulkWithFilters=$bulkWithFilters}" + package_ != null -> "Price{package_=$package_}" + matrix != null -> "Price{matrix=$matrix}" + thresholdTotalAmount != null -> + "Price{thresholdTotalAmount=$thresholdTotalAmount}" + tieredPackage != null -> "Price{tieredPackage=$tieredPackage}" + tieredWithMinimum != null -> "Price{tieredWithMinimum=$tieredWithMinimum}" + groupedTiered != null -> "Price{groupedTiered=$groupedTiered}" + tieredPackageWithMinimum != null -> + "Price{tieredPackageWithMinimum=$tieredPackageWithMinimum}" + packageWithAllocation != null -> + "Price{packageWithAllocation=$packageWithAllocation}" + unitWithPercent != null -> "Price{unitWithPercent=$unitWithPercent}" + matrixWithAllocation != null -> + "Price{matrixWithAllocation=$matrixWithAllocation}" + tieredWithProration != null -> "Price{tieredWithProration=$tieredWithProration}" + unitWithProration != null -> "Price{unitWithProration=$unitWithProration}" + groupedAllocation != null -> "Price{groupedAllocation=$groupedAllocation}" + bulkWithProration != null -> "Price{bulkWithProration=$bulkWithProration}" + groupedWithProratedMinimum != null -> + "Price{groupedWithProratedMinimum=$groupedWithProratedMinimum}" + groupedWithMeteredMinimum != null -> + "Price{groupedWithMeteredMinimum=$groupedWithMeteredMinimum}" + groupedWithMinMaxThresholds != null -> + "Price{groupedWithMinMaxThresholds=$groupedWithMinMaxThresholds}" + matrixWithDisplayName != null -> + "Price{matrixWithDisplayName=$matrixWithDisplayName}" + groupedTieredPackage != null -> + "Price{groupedTieredPackage=$groupedTieredPackage}" + maxGroupTieredPackage != null -> + "Price{maxGroupTieredPackage=$maxGroupTieredPackage}" + scalableMatrixWithUnitPricing != null -> + "Price{scalableMatrixWithUnitPricing=$scalableMatrixWithUnitPricing}" + scalableMatrixWithTieredPricing != null -> + "Price{scalableMatrixWithTieredPricing=$scalableMatrixWithTieredPricing}" + cumulativeGroupedBulk != null -> + "Price{cumulativeGroupedBulk=$cumulativeGroupedBulk}" + minimum != null -> "Price{minimum=$minimum}" + percent != null -> "Price{percent=$percent}" + eventOutput != null -> "Price{eventOutput=$eventOutput}" + _json != null -> "Price{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Price") + } + + companion object { + + fun ofUnit(unit: NewSubscriptionUnitPrice) = Price(unit = unit) + + fun ofTiered(tiered: NewSubscriptionTieredPrice) = Price(tiered = tiered) + + fun ofBulk(bulk: NewSubscriptionBulkPrice) = Price(bulk = bulk) + + fun ofBulkWithFilters(bulkWithFilters: BulkWithFilters) = + Price(bulkWithFilters = bulkWithFilters) + + fun ofPackage(package_: NewSubscriptionPackagePrice) = Price(package_ = package_) + + fun ofMatrix(matrix: NewSubscriptionMatrixPrice) = Price(matrix = matrix) + + fun ofThresholdTotalAmount( + thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice + ) = Price(thresholdTotalAmount = thresholdTotalAmount) + + fun ofTieredPackage(tieredPackage: NewSubscriptionTieredPackagePrice) = + Price(tieredPackage = tieredPackage) + + fun ofTieredWithMinimum(tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice) = + Price(tieredWithMinimum = tieredWithMinimum) + + fun ofGroupedTiered(groupedTiered: NewSubscriptionGroupedTieredPrice) = + Price(groupedTiered = groupedTiered) + + fun ofTieredPackageWithMinimum( + tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice + ) = Price(tieredPackageWithMinimum = tieredPackageWithMinimum) + + fun ofPackageWithAllocation( + packageWithAllocation: NewSubscriptionPackageWithAllocationPrice + ) = Price(packageWithAllocation = packageWithAllocation) + + fun ofUnitWithPercent(unitWithPercent: NewSubscriptionUnitWithPercentPrice) = + Price(unitWithPercent = unitWithPercent) + + fun ofMatrixWithAllocation( + matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice + ) = Price(matrixWithAllocation = matrixWithAllocation) + + fun ofTieredWithProration(tieredWithProration: TieredWithProration) = + Price(tieredWithProration = tieredWithProration) + + fun ofUnitWithProration(unitWithProration: NewSubscriptionUnitWithProrationPrice) = + Price(unitWithProration = unitWithProration) + + fun ofGroupedAllocation(groupedAllocation: NewSubscriptionGroupedAllocationPrice) = + Price(groupedAllocation = groupedAllocation) + + fun ofBulkWithProration(bulkWithProration: NewSubscriptionBulkWithProrationPrice) = + Price(bulkWithProration = bulkWithProration) + + fun ofGroupedWithProratedMinimum( + groupedWithProratedMinimum: NewSubscriptionGroupedWithProratedMinimumPrice + ) = Price(groupedWithProratedMinimum = groupedWithProratedMinimum) + + fun ofGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice + ) = Price(groupedWithMeteredMinimum = groupedWithMeteredMinimum) + + fun ofGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) = Price(groupedWithMinMaxThresholds = groupedWithMinMaxThresholds) + + fun ofMatrixWithDisplayName( + matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice + ) = Price(matrixWithDisplayName = matrixWithDisplayName) + + fun ofGroupedTieredPackage( + groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice + ) = Price(groupedTieredPackage = groupedTieredPackage) + + fun ofMaxGroupTieredPackage( + maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice + ) = Price(maxGroupTieredPackage = maxGroupTieredPackage) + + fun ofScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: NewSubscriptionScalableMatrixWithUnitPricingPrice + ) = Price(scalableMatrixWithUnitPricing = scalableMatrixWithUnitPricing) + + fun ofScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: + NewSubscriptionScalableMatrixWithTieredPricingPrice + ) = Price(scalableMatrixWithTieredPricing = scalableMatrixWithTieredPricing) + + fun ofCumulativeGroupedBulk( + cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice + ) = Price(cumulativeGroupedBulk = cumulativeGroupedBulk) + + fun ofMinimum(minimum: NewSubscriptionMinimumCompositePrice) = + Price(minimum = minimum) + + fun ofPercent(percent: Percent) = Price(percent = percent) + + fun ofEventOutput(eventOutput: EventOutput) = Price(eventOutput = eventOutput) + } + + /** + * An interface that defines how to map each variant of [Price] to a value of type [T]. + */ + interface Visitor { + + fun visitUnit(unit: NewSubscriptionUnitPrice): T + + fun visitTiered(tiered: NewSubscriptionTieredPrice): T + + fun visitBulk(bulk: NewSubscriptionBulkPrice): T + + fun visitBulkWithFilters(bulkWithFilters: BulkWithFilters): T + + fun visitPackage(package_: NewSubscriptionPackagePrice): T + + fun visitMatrix(matrix: NewSubscriptionMatrixPrice): T + + fun visitThresholdTotalAmount( + thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice + ): T + + fun visitTieredPackage(tieredPackage: NewSubscriptionTieredPackagePrice): T + + fun visitTieredWithMinimum( + tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice + ): T + + fun visitGroupedTiered(groupedTiered: NewSubscriptionGroupedTieredPrice): T + + fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice + ): T + + fun visitPackageWithAllocation( + packageWithAllocation: NewSubscriptionPackageWithAllocationPrice + ): T + + fun visitUnitWithPercent(unitWithPercent: NewSubscriptionUnitWithPercentPrice): T + + fun visitMatrixWithAllocation( + matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice + ): T + + fun visitTieredWithProration(tieredWithProration: TieredWithProration): T + + fun visitUnitWithProration( + unitWithProration: NewSubscriptionUnitWithProrationPrice + ): T + + fun visitGroupedAllocation( + groupedAllocation: NewSubscriptionGroupedAllocationPrice + ): T + + fun visitBulkWithProration( + bulkWithProration: NewSubscriptionBulkWithProrationPrice + ): T + + fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: NewSubscriptionGroupedWithProratedMinimumPrice + ): T + + fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice + ): T + + fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ): T + + fun visitMatrixWithDisplayName( + matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice + ): T + + fun visitGroupedTieredPackage( + groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice + ): T + + fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice + ): T + + fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: NewSubscriptionScalableMatrixWithUnitPricingPrice + ): T + + fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: + NewSubscriptionScalableMatrixWithTieredPricingPrice + ): T + + fun visitCumulativeGroupedBulk( + cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice + ): T + + fun visitMinimum(minimum: NewSubscriptionMinimumCompositePrice): T + + fun visitPercent(percent: Percent): T + + fun visitEventOutput(eventOutput: EventOutput): T + + /** + * Maps an unknown variant of [Price] to a value of type [T]. + * + * An instance of [Price] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is + * unaware of. + * + * @throws OrbInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw OrbInvalidDataException("Unknown Price: $json") + } + } + + internal class Deserializer : BaseDeserializer(Price::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Price { + val json = JsonValue.fromJsonNode(node) + val modelType = json.asObject()?.get("model_type")?.asString() + + when (modelType) { + "unit" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(unit = it, _json = json) } ?: Price(_json = json) + } + "tiered" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(tiered = it, _json = json) } ?: Price(_json = json) + } + "bulk" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(bulk = it, _json = json) } ?: Price(_json = json) + } + "bulk_with_filters" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(bulkWithFilters = it, _json = json) + } ?: Price(_json = json) + } + "package" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(package_ = it, _json = json) } ?: Price(_json = json) + } + "matrix" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(matrix = it, _json = json) } ?: Price(_json = json) + } + "threshold_total_amount" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(thresholdTotalAmount = it, _json = json) } + ?: Price(_json = json) + } + "tiered_package" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(tieredPackage = it, _json = json) } + ?: Price(_json = json) + } + "tiered_with_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(tieredWithMinimum = it, _json = json) } + ?: Price(_json = json) + } + "grouped_tiered" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedTiered = it, _json = json) } + ?: Price(_json = json) + } + "tiered_package_with_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(tieredPackageWithMinimum = it, _json = json) } + ?: Price(_json = json) + } + "package_with_allocation" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(packageWithAllocation = it, _json = json) } + ?: Price(_json = json) + } + "unit_with_percent" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(unitWithPercent = it, _json = json) } + ?: Price(_json = json) + } + "matrix_with_allocation" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(matrixWithAllocation = it, _json = json) } + ?: Price(_json = json) + } + "tiered_with_proration" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(tieredWithProration = it, _json = json) } + ?: Price(_json = json) + } + "unit_with_proration" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(unitWithProration = it, _json = json) } + ?: Price(_json = json) + } + "grouped_allocation" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedAllocation = it, _json = json) } + ?: Price(_json = json) + } + "bulk_with_proration" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(bulkWithProration = it, _json = json) } + ?: Price(_json = json) + } + "grouped_with_prorated_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedWithProratedMinimum = it, _json = json) } + ?: Price(_json = json) + } + "grouped_with_metered_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedWithMeteredMinimum = it, _json = json) } + ?: Price(_json = json) + } + "grouped_with_min_max_thresholds" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedWithMinMaxThresholds = it, _json = json) } + ?: Price(_json = json) + } + "matrix_with_display_name" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(matrixWithDisplayName = it, _json = json) } + ?: Price(_json = json) + } + "grouped_tiered_package" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedTieredPackage = it, _json = json) } + ?: Price(_json = json) + } + "max_group_tiered_package" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(maxGroupTieredPackage = it, _json = json) } + ?: Price(_json = json) + } + "scalable_matrix_with_unit_pricing" -> { + return tryDeserialize( + node, + jacksonTypeRef< + NewSubscriptionScalableMatrixWithUnitPricingPrice + >(), + ) + ?.let { Price(scalableMatrixWithUnitPricing = it, _json = json) } + ?: Price(_json = json) + } + "scalable_matrix_with_tiered_pricing" -> { + return tryDeserialize( + node, + jacksonTypeRef< + NewSubscriptionScalableMatrixWithTieredPricingPrice + >(), + ) + ?.let { Price(scalableMatrixWithTieredPricing = it, _json = json) } + ?: Price(_json = json) + } + "cumulative_grouped_bulk" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(cumulativeGroupedBulk = it, _json = json) } + ?: Price(_json = json) + } + "minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(minimum = it, _json = json) } ?: Price(_json = json) + } + "percent" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(percent = it, _json = json) + } ?: Price(_json = json) + } + "event_output" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(eventOutput = it, _json = json) + } ?: Price(_json = json) + } + } + + return Price(_json = json) + } + } + + internal class Serializer : BaseSerializer(Price::class) { + + override fun serialize( + value: Price, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.unit != null -> generator.writeObject(value.unit) + value.tiered != null -> generator.writeObject(value.tiered) + value.bulk != null -> generator.writeObject(value.bulk) + value.bulkWithFilters != null -> + generator.writeObject(value.bulkWithFilters) + value.package_ != null -> generator.writeObject(value.package_) + value.matrix != null -> generator.writeObject(value.matrix) + value.thresholdTotalAmount != null -> + generator.writeObject(value.thresholdTotalAmount) + value.tieredPackage != null -> generator.writeObject(value.tieredPackage) + value.tieredWithMinimum != null -> + generator.writeObject(value.tieredWithMinimum) + value.groupedTiered != null -> generator.writeObject(value.groupedTiered) + value.tieredPackageWithMinimum != null -> + generator.writeObject(value.tieredPackageWithMinimum) + value.packageWithAllocation != null -> + generator.writeObject(value.packageWithAllocation) + value.unitWithPercent != null -> + generator.writeObject(value.unitWithPercent) + value.matrixWithAllocation != null -> + generator.writeObject(value.matrixWithAllocation) + value.tieredWithProration != null -> + generator.writeObject(value.tieredWithProration) + value.unitWithProration != null -> + generator.writeObject(value.unitWithProration) + value.groupedAllocation != null -> + generator.writeObject(value.groupedAllocation) + value.bulkWithProration != null -> + generator.writeObject(value.bulkWithProration) + value.groupedWithProratedMinimum != null -> + generator.writeObject(value.groupedWithProratedMinimum) + value.groupedWithMeteredMinimum != null -> + generator.writeObject(value.groupedWithMeteredMinimum) + value.groupedWithMinMaxThresholds != null -> + generator.writeObject(value.groupedWithMinMaxThresholds) + value.matrixWithDisplayName != null -> + generator.writeObject(value.matrixWithDisplayName) + value.groupedTieredPackage != null -> + generator.writeObject(value.groupedTieredPackage) + value.maxGroupTieredPackage != null -> + generator.writeObject(value.maxGroupTieredPackage) + value.scalableMatrixWithUnitPricing != null -> + generator.writeObject(value.scalableMatrixWithUnitPricing) + value.scalableMatrixWithTieredPricing != null -> + generator.writeObject(value.scalableMatrixWithTieredPricing) + value.cumulativeGroupedBulk != null -> + generator.writeObject(value.cumulativeGroupedBulk) + value.minimum != null -> generator.writeObject(value.minimum) + value.percent != null -> generator.writeObject(value.percent) + value.eventOutput != null -> generator.writeObject(value.eventOutput) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Price") + } + } + } + + class BulkWithFilters + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val bulkWithFiltersConfig: JsonField, + private val cadence: JsonField, + private val itemId: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("bulk_with_filters_config") + @ExcludeMissing + bulkWithFiltersConfig: JsonField = JsonMissing.of(), + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + bulkWithFiltersConfig, + cadence, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + mutableMapOf(), ) - } - - private var validated: Boolean = false - - fun validate(): ReplacePrice = apply { - if (validated) { - return@apply - } - - replacesPriceId() - allocationPrice()?.validate() - discounts()?.forEach { it.validate() } - externalPriceId() - fixedPriceQuantity() - maximumAmount() - minimumAmount() - price()?.validate() - priceId() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (if (replacesPriceId.asKnown() == null) 0 else 1) + - (allocationPrice.asKnown()?.validity() ?: 0) + - (discounts.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + - (if (externalPriceId.asKnown() == null) 0 else 1) + - (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + - (if (maximumAmount.asKnown() == null) 0 else 1) + - (if (minimumAmount.asKnown() == null) 0 else 1) + - (price.asKnown()?.validity() ?: 0) + - (if (priceId.asKnown() == null) 0 else 1) + /** + * Configuration for bulk_with_filters pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun bulkWithFiltersConfig(): BulkWithFiltersConfig = + bulkWithFiltersConfig.getRequired("bulk_with_filters_config") - /** New subscription price request body params. */ - @JsonDeserialize(using = Price.Deserializer::class) - @JsonSerialize(using = Price.Serializer::class) - class Price - private constructor( - private val unit: NewSubscriptionUnitPrice? = null, - private val tiered: NewSubscriptionTieredPrice? = null, - private val bulk: NewSubscriptionBulkPrice? = null, - private val package_: NewSubscriptionPackagePrice? = null, - private val matrix: NewSubscriptionMatrixPrice? = null, - private val thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice? = null, - private val tieredPackage: NewSubscriptionTieredPackagePrice? = null, - private val tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice? = null, - private val groupedTiered: NewSubscriptionGroupedTieredPrice? = null, - private val tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice? = - null, - private val packageWithAllocation: NewSubscriptionPackageWithAllocationPrice? = null, - private val unitWithPercent: NewSubscriptionUnitWithPercentPrice? = null, - private val matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice? = null, - private val tieredWithProration: TieredWithProration? = null, - private val unitWithProration: NewSubscriptionUnitWithProrationPrice? = null, - private val groupedAllocation: NewSubscriptionGroupedAllocationPrice? = null, - private val bulkWithProration: NewSubscriptionBulkWithProrationPrice? = null, - private val groupedWithProratedMinimum: - NewSubscriptionGroupedWithProratedMinimumPrice? = - null, - private val groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice? = - null, - private val groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds? = null, - private val matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice? = null, - private val groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice? = null, - private val maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice? = null, - private val scalableMatrixWithUnitPricing: - NewSubscriptionScalableMatrixWithUnitPricingPrice? = - null, - private val scalableMatrixWithTieredPricing: - NewSubscriptionScalableMatrixWithTieredPricingPrice? = - null, - private val cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice? = null, - private val minimum: NewSubscriptionMinimumCompositePrice? = null, - private val percent: Percent? = null, - private val eventOutput: EventOutput? = null, - private val _json: JsonValue? = null, - ) { + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") - fun unit(): NewSubscriptionUnitPrice? = unit + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") - fun tiered(): NewSubscriptionTieredPrice? = tiered + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("bulk_with_filters") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType - fun bulk(): NewSubscriptionBulkPrice? = bulk + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") - fun package_(): NewSubscriptionPackagePrice? = package_ + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = billableMetricId.getNullable("billable_metric_id") - fun matrix(): NewSubscriptionMatrixPrice? = matrix + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") - fun thresholdTotalAmount(): NewSubscriptionThresholdTotalAmountPrice? = - thresholdTotalAmount + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") - fun tieredPackage(): NewSubscriptionTieredPackagePrice? = tieredPackage + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") - fun tieredWithMinimum(): NewSubscriptionTieredWithMinimumPrice? = tieredWithMinimum + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") - fun groupedTiered(): NewSubscriptionGroupedTieredPrice? = groupedTiered + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") - fun tieredPackageWithMinimum(): NewSubscriptionTieredPackageWithMinimumPrice? = - tieredPackageWithMinimum + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") - fun packageWithAllocation(): NewSubscriptionPackageWithAllocationPrice? = - packageWithAllocation + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") - fun unitWithPercent(): NewSubscriptionUnitWithPercentPrice? = unitWithPercent + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") - fun matrixWithAllocation(): NewSubscriptionMatrixWithAllocationPrice? = - matrixWithAllocation + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + invoiceGroupingKey.getNullable("invoice_grouping_key") - fun tieredWithProration(): TieredWithProration? = tieredWithProration + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - fun unitWithProration(): NewSubscriptionUnitWithProrationPrice? = unitWithProration + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") - fun groupedAllocation(): NewSubscriptionGroupedAllocationPrice? = groupedAllocation + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") - fun bulkWithProration(): NewSubscriptionBulkWithProrationPrice? = bulkWithProration + /** + * Returns the raw JSON value of [bulkWithFiltersConfig]. + * + * Unlike [bulkWithFiltersConfig], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("bulk_with_filters_config") + @ExcludeMissing + fun _bulkWithFiltersConfig(): JsonField = + bulkWithFiltersConfig - fun groupedWithProratedMinimum(): NewSubscriptionGroupedWithProratedMinimumPrice? = - groupedWithProratedMinimum + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence - fun groupedWithMeteredMinimum(): NewSubscriptionGroupedWithMeteredMinimumPrice? = - groupedWithMeteredMinimum + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - fun groupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds? = - groupedWithMinMaxThresholds + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - fun matrixWithDisplayName(): NewSubscriptionMatrixWithDisplayNamePrice? = - matrixWithDisplayName + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId - fun groupedTieredPackage(): NewSubscriptionGroupedTieredPackagePrice? = - groupedTieredPackage + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance - fun maxGroupTieredPackage(): NewSubscriptionMaxGroupTieredPackagePrice? = - maxGroupTieredPackage + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration - fun scalableMatrixWithUnitPricing(): - NewSubscriptionScalableMatrixWithUnitPricingPrice? = scalableMatrixWithUnitPricing + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate - fun scalableMatrixWithTieredPricing(): - NewSubscriptionScalableMatrixWithTieredPricingPrice? = - scalableMatrixWithTieredPricing + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig - fun cumulativeGroupedBulk(): NewSubscriptionCumulativeGroupedBulkPrice? = - cumulativeGroupedBulk + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency - fun minimum(): NewSubscriptionMinimumCompositePrice? = minimum + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration - fun percent(): Percent? = percent + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId - fun eventOutput(): EventOutput? = eventOutput + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - fun isUnit(): Boolean = unit != null + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - fun isTiered(): Boolean = tiered != null + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration - fun isBulk(): Boolean = bulk != null + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata - fun isPackage(): Boolean = package_ != null + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId - fun isMatrix(): Boolean = matrix != null + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - fun isThresholdTotalAmount(): Boolean = thresholdTotalAmount != null + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - fun isTieredPackage(): Boolean = tieredPackage != null + fun toBuilder() = Builder().from(this) - fun isTieredWithMinimum(): Boolean = tieredWithMinimum != null + companion object { - fun isGroupedTiered(): Boolean = groupedTiered != null + /** + * Returns a mutable builder for constructing an instance of [BulkWithFilters]. + * + * The following fields are required: + * ```kotlin + * .bulkWithFiltersConfig() + * .cadence() + * .itemId() + * .name() + * ``` + */ + fun builder() = Builder() + } - fun isTieredPackageWithMinimum(): Boolean = tieredPackageWithMinimum != null + /** A builder for [BulkWithFilters]. */ + class Builder internal constructor() { - fun isPackageWithAllocation(): Boolean = packageWithAllocation != null + private var bulkWithFiltersConfig: JsonField? = null + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonValue = JsonValue.from("bulk_with_filters") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - fun isUnitWithPercent(): Boolean = unitWithPercent != null + internal fun from(bulkWithFilters: BulkWithFilters) = apply { + bulkWithFiltersConfig = bulkWithFilters.bulkWithFiltersConfig + cadence = bulkWithFilters.cadence + itemId = bulkWithFilters.itemId + modelType = bulkWithFilters.modelType + name = bulkWithFilters.name + billableMetricId = bulkWithFilters.billableMetricId + billedInAdvance = bulkWithFilters.billedInAdvance + billingCycleConfiguration = bulkWithFilters.billingCycleConfiguration + conversionRate = bulkWithFilters.conversionRate + conversionRateConfig = bulkWithFilters.conversionRateConfig + currency = bulkWithFilters.currency + dimensionalPriceConfiguration = + bulkWithFilters.dimensionalPriceConfiguration + externalPriceId = bulkWithFilters.externalPriceId + fixedPriceQuantity = bulkWithFilters.fixedPriceQuantity + invoiceGroupingKey = bulkWithFilters.invoiceGroupingKey + invoicingCycleConfiguration = bulkWithFilters.invoicingCycleConfiguration + metadata = bulkWithFilters.metadata + referenceId = bulkWithFilters.referenceId + additionalProperties = bulkWithFilters.additionalProperties.toMutableMap() + } - fun isMatrixWithAllocation(): Boolean = matrixWithAllocation != null + /** Configuration for bulk_with_filters pricing */ + fun bulkWithFiltersConfig(bulkWithFiltersConfig: BulkWithFiltersConfig) = + bulkWithFiltersConfig(JsonField.of(bulkWithFiltersConfig)) - fun isTieredWithProration(): Boolean = tieredWithProration != null + /** + * Sets [Builder.bulkWithFiltersConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.bulkWithFiltersConfig] with a well-typed + * [BulkWithFiltersConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun bulkWithFiltersConfig( + bulkWithFiltersConfig: JsonField + ) = apply { this.bulkWithFiltersConfig = bulkWithFiltersConfig } - fun isUnitWithProration(): Boolean = unitWithProration != null + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - fun isGroupedAllocation(): Boolean = groupedAllocation != null + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - fun isBulkWithProration(): Boolean = bulkWithProration != null + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - fun isGroupedWithProratedMinimum(): Boolean = groupedWithProratedMinimum != null + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun isGroupedWithMeteredMinimum(): Boolean = groupedWithMeteredMinimum != null + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("bulk_with_filters") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } - fun isGroupedWithMinMaxThresholds(): Boolean = groupedWithMinMaxThresholds != null + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) - fun isMatrixWithDisplayName(): Boolean = matrixWithDisplayName != null + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } - fun isGroupedTieredPackage(): Boolean = groupedTieredPackage != null + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) - fun isMaxGroupTieredPackage(): Boolean = maxGroupTieredPackage != null + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } - fun isScalableMatrixWithUnitPricing(): Boolean = scalableMatrixWithUnitPricing != null + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) - fun isScalableMatrixWithTieredPricing(): Boolean = - scalableMatrixWithTieredPricing != null + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) - fun isCumulativeGroupedBulk(): Boolean = cumulativeGroupedBulk != null + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } - fun isMinimum(): Boolean = minimum != null + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - fun isPercent(): Boolean = percent != null + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } - fun isEventOutput(): Boolean = eventOutput != null + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) - fun asUnit(): NewSubscriptionUnitPrice = unit.getOrThrow("unit") + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) - fun asTiered(): NewSubscriptionTieredPrice = tiered.getOrThrow("tiered") + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } - fun asBulk(): NewSubscriptionBulkPrice = bulk.getOrThrow("bulk") + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) - fun asPackage(): NewSubscriptionPackagePrice = package_.getOrThrow("package_") + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } - fun asMatrix(): NewSubscriptionMatrixPrice = matrix.getOrThrow("matrix") + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) - fun asThresholdTotalAmount(): NewSubscriptionThresholdTotalAmountPrice = - thresholdTotalAmount.getOrThrow("thresholdTotalAmount") + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) - fun asTieredPackage(): NewSubscriptionTieredPackagePrice = - tieredPackage.getOrThrow("tieredPackage") + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) - fun asTieredWithMinimum(): NewSubscriptionTieredWithMinimumPrice = - tieredWithMinimum.getOrThrow("tieredWithMinimum") + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) - fun asGroupedTiered(): NewSubscriptionGroupedTieredPrice = - groupedTiered.getOrThrow("groupedTiered") + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) - fun asTieredPackageWithMinimum(): NewSubscriptionTieredPackageWithMinimumPrice = - tieredPackageWithMinimum.getOrThrow("tieredPackageWithMinimum") + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } - fun asPackageWithAllocation(): NewSubscriptionPackageWithAllocationPrice = - packageWithAllocation.getOrThrow("packageWithAllocation") + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) - fun asUnitWithPercent(): NewSubscriptionUnitWithPercentPrice = - unitWithPercent.getOrThrow("unitWithPercent") + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } - fun asMatrixWithAllocation(): NewSubscriptionMatrixWithAllocationPrice = - matrixWithAllocation.getOrThrow("matrixWithAllocation") + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) - fun asTieredWithProration(): TieredWithProration = - tieredWithProration.getOrThrow("tieredWithProration") + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } - fun asUnitWithProration(): NewSubscriptionUnitWithProrationPrice = - unitWithProration.getOrThrow("unitWithProration") + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) - fun asGroupedAllocation(): NewSubscriptionGroupedAllocationPrice = - groupedAllocation.getOrThrow("groupedAllocation") + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) - fun asBulkWithProration(): NewSubscriptionBulkWithProrationPrice = - bulkWithProration.getOrThrow("bulkWithProration") + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } - fun asGroupedWithProratedMinimum(): NewSubscriptionGroupedWithProratedMinimumPrice = - groupedWithProratedMinimum.getOrThrow("groupedWithProratedMinimum") + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) - fun asGroupedWithMeteredMinimum(): NewSubscriptionGroupedWithMeteredMinimumPrice = - groupedWithMeteredMinimum.getOrThrow("groupedWithMeteredMinimum") + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } - fun asGroupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds = - groupedWithMinMaxThresholds.getOrThrow("groupedWithMinMaxThresholds") + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) - fun asMatrixWithDisplayName(): NewSubscriptionMatrixWithDisplayNamePrice = - matrixWithDisplayName.getOrThrow("matrixWithDisplayName") + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - fun asGroupedTieredPackage(): NewSubscriptionGroupedTieredPackagePrice = - groupedTieredPackage.getOrThrow("groupedTieredPackage") + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - fun asMaxGroupTieredPackage(): NewSubscriptionMaxGroupTieredPackagePrice = - maxGroupTieredPackage.getOrThrow("maxGroupTieredPackage") + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - fun asScalableMatrixWithUnitPricing(): - NewSubscriptionScalableMatrixWithUnitPricingPrice = - scalableMatrixWithUnitPricing.getOrThrow("scalableMatrixWithUnitPricing") + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) - fun asScalableMatrixWithTieredPricing(): - NewSubscriptionScalableMatrixWithTieredPricingPrice = - scalableMatrixWithTieredPricing.getOrThrow("scalableMatrixWithTieredPricing") + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } - fun asCumulativeGroupedBulk(): NewSubscriptionCumulativeGroupedBulkPrice = - cumulativeGroupedBulk.getOrThrow("cumulativeGroupedBulk") + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun asMinimum(): NewSubscriptionMinimumCompositePrice = minimum.getOrThrow("minimum") + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun asPercent(): Percent = percent.getOrThrow("percent") + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun asEventOutput(): EventOutput = eventOutput.getOrThrow("eventOutput") + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun _json(): JsonValue? = _json + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - bulk != null -> visitor.visitBulk(bulk) - package_ != null -> visitor.visitPackage(package_) - matrix != null -> visitor.visitMatrix(matrix) - thresholdTotalAmount != null -> - visitor.visitThresholdTotalAmount(thresholdTotalAmount) - tieredPackage != null -> visitor.visitTieredPackage(tieredPackage) - tieredWithMinimum != null -> visitor.visitTieredWithMinimum(tieredWithMinimum) - groupedTiered != null -> visitor.visitGroupedTiered(groupedTiered) - tieredPackageWithMinimum != null -> - visitor.visitTieredPackageWithMinimum(tieredPackageWithMinimum) - packageWithAllocation != null -> - visitor.visitPackageWithAllocation(packageWithAllocation) - unitWithPercent != null -> visitor.visitUnitWithPercent(unitWithPercent) - matrixWithAllocation != null -> - visitor.visitMatrixWithAllocation(matrixWithAllocation) - tieredWithProration != null -> - visitor.visitTieredWithProration(tieredWithProration) - unitWithProration != null -> visitor.visitUnitWithProration(unitWithProration) - groupedAllocation != null -> visitor.visitGroupedAllocation(groupedAllocation) - bulkWithProration != null -> visitor.visitBulkWithProration(bulkWithProration) - groupedWithProratedMinimum != null -> - visitor.visitGroupedWithProratedMinimum(groupedWithProratedMinimum) - groupedWithMeteredMinimum != null -> - visitor.visitGroupedWithMeteredMinimum(groupedWithMeteredMinimum) - groupedWithMinMaxThresholds != null -> - visitor.visitGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds) - matrixWithDisplayName != null -> - visitor.visitMatrixWithDisplayName(matrixWithDisplayName) - groupedTieredPackage != null -> - visitor.visitGroupedTieredPackage(groupedTieredPackage) - maxGroupTieredPackage != null -> - visitor.visitMaxGroupTieredPackage(maxGroupTieredPackage) - scalableMatrixWithUnitPricing != null -> - visitor.visitScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing) - scalableMatrixWithTieredPricing != null -> - visitor.visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing + /** + * Returns an immutable instance of [BulkWithFilters]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .bulkWithFiltersConfig() + * .cadence() + * .itemId() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BulkWithFilters = + BulkWithFilters( + checkRequired("bulkWithFiltersConfig", bulkWithFiltersConfig), + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties.toMutableMap(), ) - cumulativeGroupedBulk != null -> - visitor.visitCumulativeGroupedBulk(cumulativeGroupedBulk) - minimum != null -> visitor.visitMinimum(minimum) - percent != null -> visitor.visitPercent(percent) - eventOutput != null -> visitor.visitEventOutput(eventOutput) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): Price = apply { - if (validated) { - return@apply } - accept( - object : Visitor { - override fun visitUnit(unit: NewSubscriptionUnitPrice) { - unit.validate() - } - - override fun visitTiered(tiered: NewSubscriptionTieredPrice) { - tiered.validate() - } + private var validated: Boolean = false - override fun visitBulk(bulk: NewSubscriptionBulkPrice) { - bulk.validate() - } + fun validate(): BulkWithFilters = apply { + if (validated) { + return@apply + } - override fun visitPackage(package_: NewSubscriptionPackagePrice) { - package_.validate() + bulkWithFiltersConfig().validate() + cadence().validate() + itemId() + _modelType().let { + if (it != JsonValue.from("bulk_with_filters")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + metadata()?.validate() + referenceId() + validated = true + } - override fun visitMatrix(matrix: NewSubscriptionMatrixPrice) { - matrix.validate() - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - override fun visitThresholdTotalAmount( - thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice - ) { - thresholdTotalAmount.validate() - } + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (bulkWithFiltersConfig.asKnown()?.validity() ?: 0) + + (cadence.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + modelType.let { if (it == JsonValue.from("bulk_with_filters")) 1 else 0 } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) - override fun visitTieredPackage( - tieredPackage: NewSubscriptionTieredPackagePrice - ) { - tieredPackage.validate() - } + /** Configuration for bulk_with_filters pricing */ + class BulkWithFiltersConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val filters: JsonField>, + private val tiers: JsonField>, + private val additionalProperties: MutableMap, + ) { - override fun visitTieredWithMinimum( - tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice - ) { - tieredWithMinimum.validate() - } + @JsonCreator + private constructor( + @JsonProperty("filters") + @ExcludeMissing + filters: JsonField> = JsonMissing.of(), + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of(), + ) : this(filters, tiers, mutableMapOf()) - override fun visitGroupedTiered( - groupedTiered: NewSubscriptionGroupedTieredPrice - ) { - groupedTiered.validate() - } + /** + * Property filters to apply (all must match) + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun filters(): List = filters.getRequired("filters") - override fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice - ) { - tieredPackageWithMinimum.validate() - } + /** + * Bulk tiers for rating based on total usage volume + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun tiers(): List = tiers.getRequired("tiers") - override fun visitPackageWithAllocation( - packageWithAllocation: NewSubscriptionPackageWithAllocationPrice - ) { - packageWithAllocation.validate() - } + /** + * Returns the raw JSON value of [filters]. + * + * Unlike [filters], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("filters") + @ExcludeMissing + fun _filters(): JsonField> = filters - override fun visitUnitWithPercent( - unitWithPercent: NewSubscriptionUnitWithPercentPrice - ) { - unitWithPercent.validate() - } + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers - override fun visitMatrixWithAllocation( - matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice - ) { - matrixWithAllocation.validate() - } + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - override fun visitTieredWithProration( - tieredWithProration: TieredWithProration - ) { - tieredWithProration.validate() - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - override fun visitUnitWithProration( - unitWithProration: NewSubscriptionUnitWithProrationPrice - ) { - unitWithProration.validate() - } + fun toBuilder() = Builder().from(this) - override fun visitGroupedAllocation( - groupedAllocation: NewSubscriptionGroupedAllocationPrice - ) { - groupedAllocation.validate() - } + companion object { - override fun visitBulkWithProration( - bulkWithProration: NewSubscriptionBulkWithProrationPrice - ) { - bulkWithProration.validate() - } + /** + * Returns a mutable builder for constructing an instance of + * [BulkWithFiltersConfig]. + * + * The following fields are required: + * ```kotlin + * .filters() + * .tiers() + * ``` + */ + fun builder() = Builder() + } - override fun visitGroupedWithProratedMinimum( - groupedWithProratedMinimum: - NewSubscriptionGroupedWithProratedMinimumPrice - ) { - groupedWithProratedMinimum.validate() - } + /** A builder for [BulkWithFiltersConfig]. */ + class Builder internal constructor() { - override fun visitGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice - ) { - groupedWithMeteredMinimum.validate() - } + private var filters: JsonField>? = null + private var tiers: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() - override fun visitGroupedWithMinMaxThresholds( - groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds - ) { - groupedWithMinMaxThresholds.validate() + internal fun from(bulkWithFiltersConfig: BulkWithFiltersConfig) = apply { + filters = bulkWithFiltersConfig.filters.map { it.toMutableList() } + tiers = bulkWithFiltersConfig.tiers.map { it.toMutableList() } + additionalProperties = + bulkWithFiltersConfig.additionalProperties.toMutableMap() } - override fun visitMatrixWithDisplayName( - matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice - ) { - matrixWithDisplayName.validate() - } + /** Property filters to apply (all must match) */ + fun filters(filters: List) = filters(JsonField.of(filters)) - override fun visitGroupedTieredPackage( - groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice - ) { - groupedTieredPackage.validate() + /** + * Sets [Builder.filters] to an arbitrary JSON value. + * + * You should usually call [Builder.filters] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun filters(filters: JsonField>) = apply { + this.filters = filters.map { it.toMutableList() } } - override fun visitMaxGroupTieredPackage( - maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice - ) { - maxGroupTieredPackage.validate() + /** + * Adds a single [Filter] to [filters]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addFilter(filter: Filter) = apply { + filters = + (filters ?: JsonField.of(mutableListOf())).also { + checkKnown("filters", it).add(filter) + } } - override fun visitScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: - NewSubscriptionScalableMatrixWithUnitPricingPrice - ) { - scalableMatrixWithUnitPricing.validate() - } + /** Bulk tiers for rating based on total usage volume */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) - override fun visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: - NewSubscriptionScalableMatrixWithTieredPricingPrice - ) { - scalableMatrixWithTieredPricing.validate() + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } } - override fun visitCumulativeGroupedBulk( - cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice - ) { - cumulativeGroupedBulk.validate() + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } } - override fun visitMinimum(minimum: NewSubscriptionMinimumCompositePrice) { - minimum.validate() + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) } - override fun visitPercent(percent: Percent) { - percent.validate() + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) } - override fun visitEventOutput(eventOutput: EventOutput) { - eventOutput.validate() + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) } + + /** + * Returns an immutable instance of [BulkWithFiltersConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .filters() + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BulkWithFiltersConfig = + BulkWithFiltersConfig( + checkRequired("filters", filters).map { it.toImmutable() }, + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) } - ) - validated = true - } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + private var validated: Boolean = false - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: NewSubscriptionUnitPrice) = unit.validity() + fun validate(): BulkWithFiltersConfig = apply { + if (validated) { + return@apply + } - override fun visitTiered(tiered: NewSubscriptionTieredPrice) = - tiered.validity() + filters().forEach { it.validate() } + tiers().forEach { it.validate() } + validated = true + } - override fun visitBulk(bulk: NewSubscriptionBulkPrice) = bulk.validity() + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - override fun visitPackage(package_: NewSubscriptionPackagePrice) = - package_.validity() + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (filters.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + (tiers.asKnown()?.sumOf { it.validity().toInt() } ?: 0) - override fun visitMatrix(matrix: NewSubscriptionMatrixPrice) = - matrix.validity() + /** Configuration for a single property filter */ + class Filter + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val propertyKey: JsonField, + private val propertyValue: JsonField, + private val additionalProperties: MutableMap, + ) { - override fun visitThresholdTotalAmount( - thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice - ) = thresholdTotalAmount.validity() + @JsonCreator + private constructor( + @JsonProperty("property_key") + @ExcludeMissing + propertyKey: JsonField = JsonMissing.of(), + @JsonProperty("property_value") + @ExcludeMissing + propertyValue: JsonField = JsonMissing.of(), + ) : this(propertyKey, propertyValue, mutableMapOf()) - override fun visitTieredPackage( - tieredPackage: NewSubscriptionTieredPackagePrice - ) = tieredPackage.validity() + /** + * Event property key to filter on + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun propertyKey(): String = propertyKey.getRequired("property_key") - override fun visitTieredWithMinimum( - tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice - ) = tieredWithMinimum.validity() + /** + * Event property value to match + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun propertyValue(): String = propertyValue.getRequired("property_value") - override fun visitGroupedTiered( - groupedTiered: NewSubscriptionGroupedTieredPrice - ) = groupedTiered.validity() + /** + * Returns the raw JSON value of [propertyKey]. + * + * Unlike [propertyKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("property_key") + @ExcludeMissing + fun _propertyKey(): JsonField = propertyKey - override fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice - ) = tieredPackageWithMinimum.validity() + /** + * Returns the raw JSON value of [propertyValue]. + * + * Unlike [propertyValue], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("property_value") + @ExcludeMissing + fun _propertyValue(): JsonField = propertyValue - override fun visitPackageWithAllocation( - packageWithAllocation: NewSubscriptionPackageWithAllocationPrice - ) = packageWithAllocation.validity() + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - override fun visitUnitWithPercent( - unitWithPercent: NewSubscriptionUnitWithPercentPrice - ) = unitWithPercent.validity() + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - override fun visitMatrixWithAllocation( - matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice - ) = matrixWithAllocation.validity() + fun toBuilder() = Builder().from(this) - override fun visitTieredWithProration( - tieredWithProration: TieredWithProration - ) = tieredWithProration.validity() + companion object { - override fun visitUnitWithProration( - unitWithProration: NewSubscriptionUnitWithProrationPrice - ) = unitWithProration.validity() + /** + * Returns a mutable builder for constructing an instance of [Filter]. + * + * The following fields are required: + * ```kotlin + * .propertyKey() + * .propertyValue() + * ``` + */ + fun builder() = Builder() + } - override fun visitGroupedAllocation( - groupedAllocation: NewSubscriptionGroupedAllocationPrice - ) = groupedAllocation.validity() + /** A builder for [Filter]. */ + class Builder internal constructor() { - override fun visitBulkWithProration( - bulkWithProration: NewSubscriptionBulkWithProrationPrice - ) = bulkWithProration.validity() + private var propertyKey: JsonField? = null + private var propertyValue: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() - override fun visitGroupedWithProratedMinimum( - groupedWithProratedMinimum: - NewSubscriptionGroupedWithProratedMinimumPrice - ) = groupedWithProratedMinimum.validity() + internal fun from(filter: Filter) = apply { + propertyKey = filter.propertyKey + propertyValue = filter.propertyValue + additionalProperties = filter.additionalProperties.toMutableMap() + } - override fun visitGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice - ) = groupedWithMeteredMinimum.validity() + /** Event property key to filter on */ + fun propertyKey(propertyKey: String) = + propertyKey(JsonField.of(propertyKey)) - override fun visitGroupedWithMinMaxThresholds( - groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds - ) = groupedWithMinMaxThresholds.validity() + /** + * Sets [Builder.propertyKey] to an arbitrary JSON value. + * + * You should usually call [Builder.propertyKey] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun propertyKey(propertyKey: JsonField) = apply { + this.propertyKey = propertyKey + } - override fun visitMatrixWithDisplayName( - matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice - ) = matrixWithDisplayName.validity() + /** Event property value to match */ + fun propertyValue(propertyValue: String) = + propertyValue(JsonField.of(propertyValue)) - override fun visitGroupedTieredPackage( - groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice - ) = groupedTieredPackage.validity() + /** + * Sets [Builder.propertyValue] to an arbitrary JSON value. + * + * You should usually call [Builder.propertyValue] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun propertyValue(propertyValue: JsonField) = apply { + this.propertyValue = propertyValue + } - override fun visitMaxGroupTieredPackage( - maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice - ) = maxGroupTieredPackage.validity() + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - override fun visitScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: - NewSubscriptionScalableMatrixWithUnitPricingPrice - ) = scalableMatrixWithUnitPricing.validity() + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - override fun visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: - NewSubscriptionScalableMatrixWithTieredPricingPrice - ) = scalableMatrixWithTieredPricing.validity() + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - override fun visitCumulativeGroupedBulk( - cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice - ) = cumulativeGroupedBulk.validity() + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - override fun visitMinimum(minimum: NewSubscriptionMinimumCompositePrice) = - minimum.validity() + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - override fun visitPercent(percent: Percent) = percent.validity() + /** + * Returns an immutable instance of [Filter]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```kotlin + * .propertyKey() + * .propertyValue() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Filter = + Filter( + checkRequired("propertyKey", propertyKey), + checkRequired("propertyValue", propertyValue), + additionalProperties.toMutableMap(), + ) + } - override fun visitEventOutput(eventOutput: EventOutput) = - eventOutput.validity() + private var validated: Boolean = false - override fun unknown(json: JsonValue?) = 0 - } - ) + fun validate(): Filter = apply { + if (validated) { + return@apply + } + + propertyKey() + propertyValue() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (propertyKey.asKnown() == null) 0 else 1) + + (if (propertyValue.asKnown() == null) 0 else 1) - return other is Price && - unit == other.unit && - tiered == other.tiered && - bulk == other.bulk && - package_ == other.package_ && - matrix == other.matrix && - thresholdTotalAmount == other.thresholdTotalAmount && - tieredPackage == other.tieredPackage && - tieredWithMinimum == other.tieredWithMinimum && - groupedTiered == other.groupedTiered && - tieredPackageWithMinimum == other.tieredPackageWithMinimum && - packageWithAllocation == other.packageWithAllocation && - unitWithPercent == other.unitWithPercent && - matrixWithAllocation == other.matrixWithAllocation && - tieredWithProration == other.tieredWithProration && - unitWithProration == other.unitWithProration && - groupedAllocation == other.groupedAllocation && - bulkWithProration == other.bulkWithProration && - groupedWithProratedMinimum == other.groupedWithProratedMinimum && - groupedWithMeteredMinimum == other.groupedWithMeteredMinimum && - groupedWithMinMaxThresholds == other.groupedWithMinMaxThresholds && - matrixWithDisplayName == other.matrixWithDisplayName && - groupedTieredPackage == other.groupedTieredPackage && - maxGroupTieredPackage == other.maxGroupTieredPackage && - scalableMatrixWithUnitPricing == other.scalableMatrixWithUnitPricing && - scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && - cumulativeGroupedBulk == other.cumulativeGroupedBulk && - minimum == other.minimum && - percent == other.percent && - eventOutput == other.eventOutput - } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - override fun hashCode(): Int = - Objects.hash( - unit, - tiered, - bulk, - package_, - matrix, - thresholdTotalAmount, - tieredPackage, - tieredWithMinimum, - groupedTiered, - tieredPackageWithMinimum, - packageWithAllocation, - unitWithPercent, - matrixWithAllocation, - tieredWithProration, - unitWithProration, - groupedAllocation, - bulkWithProration, - groupedWithProratedMinimum, - groupedWithMeteredMinimum, - groupedWithMinMaxThresholds, - matrixWithDisplayName, - groupedTieredPackage, - maxGroupTieredPackage, - scalableMatrixWithUnitPricing, - scalableMatrixWithTieredPricing, - cumulativeGroupedBulk, - minimum, - percent, - eventOutput, - ) + return other is Filter && + propertyKey == other.propertyKey && + propertyValue == other.propertyValue && + additionalProperties == other.additionalProperties + } - override fun toString(): String = - when { - unit != null -> "Price{unit=$unit}" - tiered != null -> "Price{tiered=$tiered}" - bulk != null -> "Price{bulk=$bulk}" - package_ != null -> "Price{package_=$package_}" - matrix != null -> "Price{matrix=$matrix}" - thresholdTotalAmount != null -> - "Price{thresholdTotalAmount=$thresholdTotalAmount}" - tieredPackage != null -> "Price{tieredPackage=$tieredPackage}" - tieredWithMinimum != null -> "Price{tieredWithMinimum=$tieredWithMinimum}" - groupedTiered != null -> "Price{groupedTiered=$groupedTiered}" - tieredPackageWithMinimum != null -> - "Price{tieredPackageWithMinimum=$tieredPackageWithMinimum}" - packageWithAllocation != null -> - "Price{packageWithAllocation=$packageWithAllocation}" - unitWithPercent != null -> "Price{unitWithPercent=$unitWithPercent}" - matrixWithAllocation != null -> - "Price{matrixWithAllocation=$matrixWithAllocation}" - tieredWithProration != null -> "Price{tieredWithProration=$tieredWithProration}" - unitWithProration != null -> "Price{unitWithProration=$unitWithProration}" - groupedAllocation != null -> "Price{groupedAllocation=$groupedAllocation}" - bulkWithProration != null -> "Price{bulkWithProration=$bulkWithProration}" - groupedWithProratedMinimum != null -> - "Price{groupedWithProratedMinimum=$groupedWithProratedMinimum}" - groupedWithMeteredMinimum != null -> - "Price{groupedWithMeteredMinimum=$groupedWithMeteredMinimum}" - groupedWithMinMaxThresholds != null -> - "Price{groupedWithMinMaxThresholds=$groupedWithMinMaxThresholds}" - matrixWithDisplayName != null -> - "Price{matrixWithDisplayName=$matrixWithDisplayName}" - groupedTieredPackage != null -> - "Price{groupedTieredPackage=$groupedTieredPackage}" - maxGroupTieredPackage != null -> - "Price{maxGroupTieredPackage=$maxGroupTieredPackage}" - scalableMatrixWithUnitPricing != null -> - "Price{scalableMatrixWithUnitPricing=$scalableMatrixWithUnitPricing}" - scalableMatrixWithTieredPricing != null -> - "Price{scalableMatrixWithTieredPricing=$scalableMatrixWithTieredPricing}" - cumulativeGroupedBulk != null -> - "Price{cumulativeGroupedBulk=$cumulativeGroupedBulk}" - minimum != null -> "Price{minimum=$minimum}" - percent != null -> "Price{percent=$percent}" - eventOutput != null -> "Price{eventOutput=$eventOutput}" - _json != null -> "Price{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Price") - } + private val hashCode: Int by lazy { + Objects.hash(propertyKey, propertyValue, additionalProperties) + } - companion object { + override fun hashCode(): Int = hashCode - fun ofUnit(unit: NewSubscriptionUnitPrice) = Price(unit = unit) + override fun toString() = + "Filter{propertyKey=$propertyKey, propertyValue=$propertyValue, additionalProperties=$additionalProperties}" + } - fun ofTiered(tiered: NewSubscriptionTieredPrice) = Price(tiered = tiered) + /** Configuration for a single bulk pricing tier */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val unitAmount: JsonField, + private val tierLowerBound: JsonField, + private val additionalProperties: MutableMap, + ) { - fun ofBulk(bulk: NewSubscriptionBulkPrice) = Price(bulk = bulk) + @JsonCreator + private constructor( + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + ) : this(unitAmount, tierLowerBound, mutableMapOf()) - fun ofPackage(package_: NewSubscriptionPackagePrice) = Price(package_ = package_) + /** + * Amount per unit + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") - fun ofMatrix(matrix: NewSubscriptionMatrixPrice) = Price(matrix = matrix) + /** + * The lower bound for this tier + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun tierLowerBound(): String? = + tierLowerBound.getNullable("tier_lower_bound") - fun ofThresholdTotalAmount( - thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice - ) = Price(thresholdTotalAmount = thresholdTotalAmount) + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount - fun ofTieredPackage(tieredPackage: NewSubscriptionTieredPackagePrice) = - Price(tieredPackage = tieredPackage) + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound - fun ofTieredWithMinimum(tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice) = - Price(tieredWithMinimum = tieredWithMinimum) + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - fun ofGroupedTiered(groupedTiered: NewSubscriptionGroupedTieredPrice) = - Price(groupedTiered = groupedTiered) + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - fun ofTieredPackageWithMinimum( - tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice - ) = Price(tieredPackageWithMinimum = tieredPackageWithMinimum) + fun toBuilder() = Builder().from(this) - fun ofPackageWithAllocation( - packageWithAllocation: NewSubscriptionPackageWithAllocationPrice - ) = Price(packageWithAllocation = packageWithAllocation) + companion object { - fun ofUnitWithPercent(unitWithPercent: NewSubscriptionUnitWithPercentPrice) = - Price(unitWithPercent = unitWithPercent) + /** + * Returns a mutable builder for constructing an instance of [Tier]. + * + * The following fields are required: + * ```kotlin + * .unitAmount() + * ``` + */ + fun builder() = Builder() + } - fun ofMatrixWithAllocation( - matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice - ) = Price(matrixWithAllocation = matrixWithAllocation) + /** A builder for [Tier]. */ + class Builder internal constructor() { - fun ofTieredWithProration(tieredWithProration: TieredWithProration) = - Price(tieredWithProration = tieredWithProration) + private var unitAmount: JsonField? = null + private var tierLowerBound: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() - fun ofUnitWithProration(unitWithProration: NewSubscriptionUnitWithProrationPrice) = - Price(unitWithProration = unitWithProration) + internal fun from(tier: Tier) = apply { + unitAmount = tier.unitAmount + tierLowerBound = tier.tierLowerBound + additionalProperties = tier.additionalProperties.toMutableMap() + } - fun ofGroupedAllocation(groupedAllocation: NewSubscriptionGroupedAllocationPrice) = - Price(groupedAllocation = groupedAllocation) + /** Amount per unit */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) - fun ofBulkWithProration(bulkWithProration: NewSubscriptionBulkWithProrationPrice) = - Price(bulkWithProration = bulkWithProration) + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } - fun ofGroupedWithProratedMinimum( - groupedWithProratedMinimum: NewSubscriptionGroupedWithProratedMinimumPrice - ) = Price(groupedWithProratedMinimum = groupedWithProratedMinimum) + /** The lower bound for this tier */ + fun tierLowerBound(tierLowerBound: String?) = + tierLowerBound(JsonField.ofNullable(tierLowerBound)) - fun ofGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice - ) = Price(groupedWithMeteredMinimum = groupedWithMeteredMinimum) + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } - fun ofGroupedWithMinMaxThresholds( - groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds - ) = Price(groupedWithMinMaxThresholds = groupedWithMinMaxThresholds) + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun ofMatrixWithDisplayName( - matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice - ) = Price(matrixWithDisplayName = matrixWithDisplayName) + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun ofGroupedTieredPackage( - groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice - ) = Price(groupedTieredPackage = groupedTieredPackage) + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun ofMaxGroupTieredPackage( - maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice - ) = Price(maxGroupTieredPackage = maxGroupTieredPackage) + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun ofScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: NewSubscriptionScalableMatrixWithUnitPricingPrice - ) = Price(scalableMatrixWithUnitPricing = scalableMatrixWithUnitPricing) + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - fun ofScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: - NewSubscriptionScalableMatrixWithTieredPricingPrice - ) = Price(scalableMatrixWithTieredPricing = scalableMatrixWithTieredPricing) + /** + * Returns an immutable instance of [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```kotlin + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("unitAmount", unitAmount), + tierLowerBound, + additionalProperties.toMutableMap(), + ) + } - fun ofCumulativeGroupedBulk( - cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice - ) = Price(cumulativeGroupedBulk = cumulativeGroupedBulk) + private var validated: Boolean = false - fun ofMinimum(minimum: NewSubscriptionMinimumCompositePrice) = - Price(minimum = minimum) + fun validate(): Tier = apply { + if (validated) { + return@apply + } - fun ofPercent(percent: Percent) = Price(percent = percent) + unitAmount() + tierLowerBound() + validated = true + } - fun ofEventOutput(eventOutput: EventOutput) = Price(eventOutput = eventOutput) - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - /** - * An interface that defines how to map each variant of [Price] to a value of type [T]. - */ - interface Visitor { + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (unitAmount.asKnown() == null) 0 else 1) + + (if (tierLowerBound.asKnown() == null) 0 else 1) - fun visitUnit(unit: NewSubscriptionUnitPrice): T + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun visitTiered(tiered: NewSubscriptionTieredPrice): T + return other is Tier && + unitAmount == other.unitAmount && + tierLowerBound == other.tierLowerBound && + additionalProperties == other.additionalProperties + } - fun visitBulk(bulk: NewSubscriptionBulkPrice): T + private val hashCode: Int by lazy { + Objects.hash(unitAmount, tierLowerBound, additionalProperties) + } - fun visitPackage(package_: NewSubscriptionPackagePrice): T + override fun hashCode(): Int = hashCode - fun visitMatrix(matrix: NewSubscriptionMatrixPrice): T + override fun toString() = + "Tier{unitAmount=$unitAmount, tierLowerBound=$tierLowerBound, additionalProperties=$additionalProperties}" + } - fun visitThresholdTotalAmount( - thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice - ): T + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun visitTieredPackage(tieredPackage: NewSubscriptionTieredPackagePrice): T + return other is BulkWithFiltersConfig && + filters == other.filters && + tiers == other.tiers && + additionalProperties == other.additionalProperties + } - fun visitTieredWithMinimum( - tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice - ): T + private val hashCode: Int by lazy { + Objects.hash(filters, tiers, additionalProperties) + } - fun visitGroupedTiered(groupedTiered: NewSubscriptionGroupedTieredPrice): T + override fun hashCode(): Int = hashCode - fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice - ): T + override fun toString() = + "BulkWithFiltersConfig{filters=$filters, tiers=$tiers, additionalProperties=$additionalProperties}" + } - fun visitPackageWithAllocation( - packageWithAllocation: NewSubscriptionPackageWithAllocationPrice - ): T + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { - fun visitUnitWithPercent(unitWithPercent: NewSubscriptionUnitWithPercentPrice): T + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value - fun visitMatrixWithAllocation( - matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice - ): T + companion object { - fun visitTieredWithProration(tieredWithProration: TieredWithProration): T + val ANNUAL = of("annual") - fun visitUnitWithProration( - unitWithProration: NewSubscriptionUnitWithProrationPrice - ): T + val SEMI_ANNUAL = of("semi_annual") - fun visitGroupedAllocation( - groupedAllocation: NewSubscriptionGroupedAllocationPrice - ): T + val MONTHLY = of("monthly") - fun visitBulkWithProration( - bulkWithProration: NewSubscriptionBulkWithProrationPrice - ): T + val QUARTERLY = of("quarterly") - fun visitGroupedWithProratedMinimum( - groupedWithProratedMinimum: NewSubscriptionGroupedWithProratedMinimumPrice - ): T + val ONE_TIME = of("one_time") - fun visitGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice - ): T + val CUSTOM = of("custom") - fun visitGroupedWithMinMaxThresholds( - groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds - ): T + fun of(value: String) = Cadence(JsonField.of(value)) + } - fun visitMatrixWithDisplayName( - matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice - ): T + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } - fun visitGroupedTieredPackage( - groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice - ): T + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } - fun visitMaxGroupTieredPackage( - maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice - ): T + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } - fun visitScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: NewSubscriptionScalableMatrixWithUnitPricingPrice - ): T + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } - fun visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: - NewSubscriptionScalableMatrixWithTieredPricingPrice - ): T + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") - fun visitCumulativeGroupedBulk( - cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice - ): T + private var validated: Boolean = false - fun visitMinimum(minimum: NewSubscriptionMinimumCompositePrice): T + fun validate(): Cadence = apply { + if (validated) { + return@apply + } - fun visitPercent(percent: Percent): T + known() + validated = true + } - fun visitEventOutput(eventOutput: EventOutput): T + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - /** - * Maps an unknown variant of [Price] to a value of type [T]. - * - * An instance of [Price] can contain an unknown variant if it was deserialized from - * data that doesn't match any known variant. For example, if the SDK is on an older - * version than the API, then the API may respond with new variants that the SDK is - * unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown Price: $json") - } - } + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - internal class Deserializer : BaseDeserializer(Price::class) { + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - override fun ObjectCodec.deserialize(node: JsonNode): Price { - val json = JsonValue.fromJsonNode(node) - val modelType = json.asObject()?.get("model_type")?.asString() + return other is Cadence && value == other.value + } - when (modelType) { - "unit" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(unit = it, _json = json) } ?: Price(_json = json) - } - "tiered" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(tiered = it, _json = json) } ?: Price(_json = json) - } - "bulk" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(bulk = it, _json = json) } ?: Price(_json = json) - } - "package" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(package_ = it, _json = json) } ?: Price(_json = json) - } - "matrix" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(matrix = it, _json = json) } ?: Price(_json = json) - } - "threshold_total_amount" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(thresholdTotalAmount = it, _json = json) } - ?: Price(_json = json) - } - "tiered_package" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(tieredPackage = it, _json = json) } - ?: Price(_json = json) - } - "tiered_with_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(tieredWithMinimum = it, _json = json) } - ?: Price(_json = json) - } - "grouped_tiered" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedTiered = it, _json = json) } - ?: Price(_json = json) - } - "tiered_package_with_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(tieredPackageWithMinimum = it, _json = json) } - ?: Price(_json = json) - } - "package_with_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(packageWithAllocation = it, _json = json) } - ?: Price(_json = json) - } - "unit_with_percent" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(unitWithPercent = it, _json = json) } - ?: Price(_json = json) - } - "matrix_with_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(matrixWithAllocation = it, _json = json) } - ?: Price(_json = json) - } - "tiered_with_proration" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(tieredWithProration = it, _json = json) } - ?: Price(_json = json) - } - "unit_with_proration" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(unitWithProration = it, _json = json) } - ?: Price(_json = json) - } - "grouped_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedAllocation = it, _json = json) } - ?: Price(_json = json) - } - "bulk_with_proration" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(bulkWithProration = it, _json = json) } - ?: Price(_json = json) - } - "grouped_with_prorated_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedWithProratedMinimum = it, _json = json) } - ?: Price(_json = json) - } - "grouped_with_metered_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedWithMeteredMinimum = it, _json = json) } - ?: Price(_json = json) - } - "grouped_with_min_max_thresholds" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedWithMinMaxThresholds = it, _json = json) } - ?: Price(_json = json) - } - "matrix_with_display_name" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(matrixWithDisplayName = it, _json = json) } - ?: Price(_json = json) - } - "grouped_tiered_package" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedTieredPackage = it, _json = json) } - ?: Price(_json = json) + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() } - "max_group_tiered_package" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(maxGroupTieredPackage = it, _json = json) } - ?: Price(_json = json) + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) } - "scalable_matrix_with_unit_pricing" -> { - return tryDeserialize( - node, - jacksonTypeRef< - NewSubscriptionScalableMatrixWithUnitPricingPrice - >(), - ) - ?.let { Price(scalableMatrixWithUnitPricing = it, _json = json) } - ?: Price(_json = json) + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) } - "scalable_matrix_with_tiered_pricing" -> { - return tryDeserialize( - node, - jacksonTypeRef< - NewSubscriptionScalableMatrixWithTieredPricingPrice - >(), - ) - ?.let { Price(scalableMatrixWithTieredPricing = it, _json = json) } - ?: Price(_json = json) + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) } - "cumulative_grouped_bulk" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(cumulativeGroupedBulk = it, _json = json) } - ?: Price(_json = json) + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply } - "minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(minimum = it, _json = json) } ?: Price(_json = json) + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false } - "percent" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(percent = it, _json = json) - } ?: Price(_json = json) + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() } - "event_output" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(eventOutput = it, _json = json) - } ?: Price(_json = json) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } + + return other is Metadata && + additionalProperties == other.additionalProperties } - return Price(_json = json) - } - } + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - internal class Serializer : BaseSerializer(Price::class) { + override fun hashCode(): Int = hashCode - override fun serialize( - value: Price, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unit != null -> generator.writeObject(value.unit) - value.tiered != null -> generator.writeObject(value.tiered) - value.bulk != null -> generator.writeObject(value.bulk) - value.package_ != null -> generator.writeObject(value.package_) - value.matrix != null -> generator.writeObject(value.matrix) - value.thresholdTotalAmount != null -> - generator.writeObject(value.thresholdTotalAmount) - value.tieredPackage != null -> generator.writeObject(value.tieredPackage) - value.tieredWithMinimum != null -> - generator.writeObject(value.tieredWithMinimum) - value.groupedTiered != null -> generator.writeObject(value.groupedTiered) - value.tieredPackageWithMinimum != null -> - generator.writeObject(value.tieredPackageWithMinimum) - value.packageWithAllocation != null -> - generator.writeObject(value.packageWithAllocation) - value.unitWithPercent != null -> - generator.writeObject(value.unitWithPercent) - value.matrixWithAllocation != null -> - generator.writeObject(value.matrixWithAllocation) - value.tieredWithProration != null -> - generator.writeObject(value.tieredWithProration) - value.unitWithProration != null -> - generator.writeObject(value.unitWithProration) - value.groupedAllocation != null -> - generator.writeObject(value.groupedAllocation) - value.bulkWithProration != null -> - generator.writeObject(value.bulkWithProration) - value.groupedWithProratedMinimum != null -> - generator.writeObject(value.groupedWithProratedMinimum) - value.groupedWithMeteredMinimum != null -> - generator.writeObject(value.groupedWithMeteredMinimum) - value.groupedWithMinMaxThresholds != null -> - generator.writeObject(value.groupedWithMinMaxThresholds) - value.matrixWithDisplayName != null -> - generator.writeObject(value.matrixWithDisplayName) - value.groupedTieredPackage != null -> - generator.writeObject(value.groupedTieredPackage) - value.maxGroupTieredPackage != null -> - generator.writeObject(value.maxGroupTieredPackage) - value.scalableMatrixWithUnitPricing != null -> - generator.writeObject(value.scalableMatrixWithUnitPricing) - value.scalableMatrixWithTieredPricing != null -> - generator.writeObject(value.scalableMatrixWithTieredPricing) - value.cumulativeGroupedBulk != null -> - generator.writeObject(value.cumulativeGroupedBulk) - value.minimum != null -> generator.writeObject(value.minimum) - value.percent != null -> generator.writeObject(value.percent) - value.eventOutput != null -> generator.writeObject(value.eventOutput) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Price") + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } + + return other is BulkWithFilters && + bulkWithFiltersConfig == other.bulkWithFiltersConfig && + cadence == other.cadence && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + bulkWithFiltersConfig, + cadence, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties, + ) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BulkWithFilters{bulkWithFiltersConfig=$bulkWithFiltersConfig, cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } class TieredWithProration diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsParams.kt index 497f70369..c96e11edd 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsParams.kt @@ -1501,6 +1501,10 @@ private constructor( /** Alias for calling [price] with `Price.ofBulk(bulk)`. */ fun price(bulk: NewFloatingBulkPrice) = price(Price.ofBulk(bulk)) + /** Alias for calling [price] with `Price.ofBulkWithFilters(bulkWithFilters)`. */ + fun price(bulkWithFilters: Price.BulkWithFilters) = + price(Price.ofBulkWithFilters(bulkWithFilters)) + /** Alias for calling [price] with `Price.ofPackage(package_)`. */ fun price(package_: NewFloatingPackagePrice) = price(Price.ofPackage(package_)) @@ -3230,6 +3234,7 @@ private constructor( private val unit: NewFloatingUnitPrice? = null, private val tiered: NewFloatingTieredPrice? = null, private val bulk: NewFloatingBulkPrice? = null, + private val bulkWithFilters: BulkWithFilters? = null, private val package_: NewFloatingPackagePrice? = null, private val matrix: NewFloatingMatrixPrice? = null, private val thresholdTotalAmount: NewFloatingThresholdTotalAmountPrice? = null, @@ -3271,6 +3276,8 @@ private constructor( fun bulk(): NewFloatingBulkPrice? = bulk + fun bulkWithFilters(): BulkWithFilters? = bulkWithFilters + fun package_(): NewFloatingPackagePrice? = package_ fun matrix(): NewFloatingMatrixPrice? = matrix @@ -3339,6 +3346,8 @@ private constructor( fun isBulk(): Boolean = bulk != null + fun isBulkWithFilters(): Boolean = bulkWithFilters != null + fun isPackage(): Boolean = package_ != null fun isMatrix(): Boolean = matrix != null @@ -3398,6 +3407,8 @@ private constructor( fun asBulk(): NewFloatingBulkPrice = bulk.getOrThrow("bulk") + fun asBulkWithFilters(): BulkWithFilters = bulkWithFilters.getOrThrow("bulkWithFilters") + fun asPackage(): NewFloatingPackagePrice = package_.getOrThrow("package_") fun asMatrix(): NewFloatingMatrixPrice = matrix.getOrThrow("matrix") @@ -3479,6 +3490,7 @@ private constructor( unit != null -> visitor.visitUnit(unit) tiered != null -> visitor.visitTiered(tiered) bulk != null -> visitor.visitBulk(bulk) + bulkWithFilters != null -> visitor.visitBulkWithFilters(bulkWithFilters) package_ != null -> visitor.visitPackage(package_) matrix != null -> visitor.visitMatrix(matrix) thresholdTotalAmount != null -> @@ -3545,6 +3557,10 @@ private constructor( bulk.validate() } + override fun visitBulkWithFilters(bulkWithFilters: BulkWithFilters) { + bulkWithFilters.validate() + } + override fun visitPackage(package_: NewFloatingPackagePrice) { package_.validate() } @@ -3720,6 +3736,9 @@ private constructor( override fun visitBulk(bulk: NewFloatingBulkPrice) = bulk.validity() + override fun visitBulkWithFilters(bulkWithFilters: BulkWithFilters) = + bulkWithFilters.validity() + override fun visitPackage(package_: NewFloatingPackagePrice) = package_.validity() @@ -3832,6 +3851,7 @@ private constructor( unit == other.unit && tiered == other.tiered && bulk == other.bulk && + bulkWithFilters == other.bulkWithFilters && package_ == other.package_ && matrix == other.matrix && thresholdTotalAmount == other.thresholdTotalAmount && @@ -3865,6 +3885,7 @@ private constructor( unit, tiered, bulk, + bulkWithFilters, package_, matrix, thresholdTotalAmount, @@ -3898,6 +3919,7 @@ private constructor( unit != null -> "Price{unit=$unit}" tiered != null -> "Price{tiered=$tiered}" bulk != null -> "Price{bulk=$bulk}" + bulkWithFilters != null -> "Price{bulkWithFilters=$bulkWithFilters}" package_ != null -> "Price{package_=$package_}" matrix != null -> "Price{matrix=$matrix}" thresholdTotalAmount != null -> @@ -3949,6 +3971,9 @@ private constructor( fun ofBulk(bulk: NewFloatingBulkPrice) = Price(bulk = bulk) + fun ofBulkWithFilters(bulkWithFilters: BulkWithFilters) = + Price(bulkWithFilters = bulkWithFilters) + fun ofPackage(package_: NewFloatingPackagePrice) = Price(package_ = package_) fun ofMatrix(matrix: NewFloatingMatrixPrice) = Price(matrix = matrix) @@ -4048,6 +4073,8 @@ private constructor( fun visitBulk(bulk: NewFloatingBulkPrice): T + fun visitBulkWithFilters(bulkWithFilters: BulkWithFilters): T + fun visitPackage(package_: NewFloatingPackagePrice): T fun visitMatrix(matrix: NewFloatingMatrixPrice): T @@ -4162,6 +4189,11 @@ private constructor( return tryDeserialize(node, jacksonTypeRef()) ?.let { Price(bulk = it, _json = json) } ?: Price(_json = json) } + "bulk_with_filters" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(bulkWithFilters = it, _json = json) + } ?: Price(_json = json) + } "package" -> { return tryDeserialize(node, jacksonTypeRef()) ?.let { Price(package_ = it, _json = json) } ?: Price(_json = json) @@ -4374,6 +4406,8 @@ private constructor( value.unit != null -> generator.writeObject(value.unit) value.tiered != null -> generator.writeObject(value.tiered) value.bulk != null -> generator.writeObject(value.bulk) + value.bulkWithFilters != null -> + generator.writeObject(value.bulkWithFilters) value.package_ != null -> generator.writeObject(value.package_) value.matrix != null -> generator.writeObject(value.matrix) value.thresholdTotalAmount != null -> @@ -4425,6 +4459,1991 @@ private constructor( } } + class BulkWithFilters + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val bulkWithFiltersConfig: JsonField, + private val cadence: JsonField, + private val currency: JsonField, + private val itemId: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val metadata: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("bulk_with_filters_config") + @ExcludeMissing + bulkWithFiltersConfig: JsonField = JsonMissing.of(), + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + ) : this( + bulkWithFiltersConfig, + cadence, + currency, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + mutableMapOf(), + ) + + /** + * Configuration for bulk_with_filters pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun bulkWithFiltersConfig(): BulkWithFiltersConfig = + bulkWithFiltersConfig.getRequired("bulk_with_filters_config") + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * An ISO 4217 currency string for which this price is billed in. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("bulk_with_filters") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = billableMetricId.getNullable("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + invoiceGroupingKey.getNullable("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * Returns the raw JSON value of [bulkWithFiltersConfig]. + * + * Unlike [bulkWithFiltersConfig], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("bulk_with_filters_config") + @ExcludeMissing + fun _bulkWithFiltersConfig(): JsonField = + bulkWithFiltersConfig + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [BulkWithFilters]. + * + * The following fields are required: + * ```kotlin + * .bulkWithFiltersConfig() + * .cadence() + * .currency() + * .itemId() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [BulkWithFilters]. */ + class Builder internal constructor() { + + private var bulkWithFiltersConfig: JsonField? = null + private var cadence: JsonField? = null + private var currency: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonValue = JsonValue.from("bulk_with_filters") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(bulkWithFilters: BulkWithFilters) = apply { + bulkWithFiltersConfig = bulkWithFilters.bulkWithFiltersConfig + cadence = bulkWithFilters.cadence + currency = bulkWithFilters.currency + itemId = bulkWithFilters.itemId + modelType = bulkWithFilters.modelType + name = bulkWithFilters.name + billableMetricId = bulkWithFilters.billableMetricId + billedInAdvance = bulkWithFilters.billedInAdvance + billingCycleConfiguration = bulkWithFilters.billingCycleConfiguration + conversionRate = bulkWithFilters.conversionRate + conversionRateConfig = bulkWithFilters.conversionRateConfig + dimensionalPriceConfiguration = + bulkWithFilters.dimensionalPriceConfiguration + externalPriceId = bulkWithFilters.externalPriceId + fixedPriceQuantity = bulkWithFilters.fixedPriceQuantity + invoiceGroupingKey = bulkWithFilters.invoiceGroupingKey + invoicingCycleConfiguration = bulkWithFilters.invoicingCycleConfiguration + metadata = bulkWithFilters.metadata + additionalProperties = bulkWithFilters.additionalProperties.toMutableMap() + } + + /** Configuration for bulk_with_filters pricing */ + fun bulkWithFiltersConfig(bulkWithFiltersConfig: BulkWithFiltersConfig) = + bulkWithFiltersConfig(JsonField.of(bulkWithFiltersConfig)) + + /** + * Sets [Builder.bulkWithFiltersConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.bulkWithFiltersConfig] with a well-typed + * [BulkWithFiltersConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun bulkWithFiltersConfig( + bulkWithFiltersConfig: JsonField + ) = apply { this.bulkWithFiltersConfig = bulkWithFiltersConfig } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("bulk_with_filters") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BulkWithFilters]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .bulkWithFiltersConfig() + * .cadence() + * .currency() + * .itemId() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BulkWithFilters = + BulkWithFilters( + checkRequired("bulkWithFiltersConfig", bulkWithFiltersConfig), + checkRequired("cadence", cadence), + checkRequired("currency", currency), + checkRequired("itemId", itemId), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): BulkWithFilters = apply { + if (validated) { + return@apply + } + + bulkWithFiltersConfig().validate() + cadence().validate() + currency() + itemId() + _modelType().let { + if (it != JsonValue.from("bulk_with_filters")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + metadata()?.validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (bulkWithFiltersConfig.asKnown()?.validity() ?: 0) + + (cadence.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (if (itemId.asKnown() == null) 0 else 1) + + modelType.let { if (it == JsonValue.from("bulk_with_filters")) 1 else 0 } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (metadata.asKnown()?.validity() ?: 0) + + /** Configuration for bulk_with_filters pricing */ + class BulkWithFiltersConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val filters: JsonField>, + private val tiers: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("filters") + @ExcludeMissing + filters: JsonField> = JsonMissing.of(), + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of(), + ) : this(filters, tiers, mutableMapOf()) + + /** + * Property filters to apply (all must match) + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun filters(): List = filters.getRequired("filters") + + /** + * Bulk tiers for rating based on total usage volume + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun tiers(): List = tiers.getRequired("tiers") + + /** + * Returns the raw JSON value of [filters]. + * + * Unlike [filters], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("filters") + @ExcludeMissing + fun _filters(): JsonField> = filters + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [BulkWithFiltersConfig]. + * + * The following fields are required: + * ```kotlin + * .filters() + * .tiers() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [BulkWithFiltersConfig]. */ + class Builder internal constructor() { + + private var filters: JsonField>? = null + private var tiers: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(bulkWithFiltersConfig: BulkWithFiltersConfig) = apply { + filters = bulkWithFiltersConfig.filters.map { it.toMutableList() } + tiers = bulkWithFiltersConfig.tiers.map { it.toMutableList() } + additionalProperties = + bulkWithFiltersConfig.additionalProperties.toMutableMap() + } + + /** Property filters to apply (all must match) */ + fun filters(filters: List) = filters(JsonField.of(filters)) + + /** + * Sets [Builder.filters] to an arbitrary JSON value. + * + * You should usually call [Builder.filters] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun filters(filters: JsonField>) = apply { + this.filters = filters.map { it.toMutableList() } + } + + /** + * Adds a single [Filter] to [filters]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addFilter(filter: Filter) = apply { + filters = + (filters ?: JsonField.of(mutableListOf())).also { + checkKnown("filters", it).add(filter) + } + } + + /** Bulk tiers for rating based on total usage volume */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BulkWithFiltersConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .filters() + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BulkWithFiltersConfig = + BulkWithFiltersConfig( + checkRequired("filters", filters).map { it.toImmutable() }, + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): BulkWithFiltersConfig = apply { + if (validated) { + return@apply + } + + filters().forEach { it.validate() } + tiers().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (filters.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + (tiers.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single property filter */ + class Filter + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val propertyKey: JsonField, + private val propertyValue: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("property_key") + @ExcludeMissing + propertyKey: JsonField = JsonMissing.of(), + @JsonProperty("property_value") + @ExcludeMissing + propertyValue: JsonField = JsonMissing.of(), + ) : this(propertyKey, propertyValue, mutableMapOf()) + + /** + * Event property key to filter on + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun propertyKey(): String = propertyKey.getRequired("property_key") + + /** + * Event property value to match + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun propertyValue(): String = propertyValue.getRequired("property_value") + + /** + * Returns the raw JSON value of [propertyKey]. + * + * Unlike [propertyKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("property_key") + @ExcludeMissing + fun _propertyKey(): JsonField = propertyKey + + /** + * Returns the raw JSON value of [propertyValue]. + * + * Unlike [propertyValue], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("property_value") + @ExcludeMissing + fun _propertyValue(): JsonField = propertyValue + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Filter]. + * + * The following fields are required: + * ```kotlin + * .propertyKey() + * .propertyValue() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Filter]. */ + class Builder internal constructor() { + + private var propertyKey: JsonField? = null + private var propertyValue: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(filter: Filter) = apply { + propertyKey = filter.propertyKey + propertyValue = filter.propertyValue + additionalProperties = filter.additionalProperties.toMutableMap() + } + + /** Event property key to filter on */ + fun propertyKey(propertyKey: String) = + propertyKey(JsonField.of(propertyKey)) + + /** + * Sets [Builder.propertyKey] to an arbitrary JSON value. + * + * You should usually call [Builder.propertyKey] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun propertyKey(propertyKey: JsonField) = apply { + this.propertyKey = propertyKey + } + + /** Event property value to match */ + fun propertyValue(propertyValue: String) = + propertyValue(JsonField.of(propertyValue)) + + /** + * Sets [Builder.propertyValue] to an arbitrary JSON value. + * + * You should usually call [Builder.propertyValue] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun propertyValue(propertyValue: JsonField) = apply { + this.propertyValue = propertyValue + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Filter]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```kotlin + * .propertyKey() + * .propertyValue() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Filter = + Filter( + checkRequired("propertyKey", propertyKey), + checkRequired("propertyValue", propertyValue), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Filter = apply { + if (validated) { + return@apply + } + + propertyKey() + propertyValue() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (propertyKey.asKnown() == null) 0 else 1) + + (if (propertyValue.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Filter && + propertyKey == other.propertyKey && + propertyValue == other.propertyValue && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(propertyKey, propertyValue, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Filter{propertyKey=$propertyKey, propertyValue=$propertyValue, additionalProperties=$additionalProperties}" + } + + /** Configuration for a single bulk pricing tier */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val unitAmount: JsonField, + private val tierLowerBound: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + ) : this(unitAmount, tierLowerBound, mutableMapOf()) + + /** + * Amount per unit + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * The lower bound for this tier + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun tierLowerBound(): String? = + tierLowerBound.getNullable("tier_lower_bound") + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Tier]. + * + * The following fields are required: + * ```kotlin + * .unitAmount() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var unitAmount: JsonField? = null + private var tierLowerBound: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(tier: Tier) = apply { + unitAmount = tier.unitAmount + tierLowerBound = tier.tierLowerBound + additionalProperties = tier.additionalProperties.toMutableMap() + } + + /** Amount per unit */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + /** The lower bound for this tier */ + fun tierLowerBound(tierLowerBound: String?) = + tierLowerBound(JsonField.ofNullable(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```kotlin + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("unitAmount", unitAmount), + tierLowerBound, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + unitAmount() + tierLowerBound() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (unitAmount.asKnown() == null) 0 else 1) + + (if (tierLowerBound.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + unitAmount == other.unitAmount && + tierLowerBound == other.tierLowerBound && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(unitAmount, tierLowerBound, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{unitAmount=$unitAmount, tierLowerBound=$tierLowerBound, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BulkWithFiltersConfig && + filters == other.filters && + tiers == other.tiers && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(filters, tiers, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BulkWithFiltersConfig{filters=$filters, tiers=$tiers, additionalProperties=$additionalProperties}" + } + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BulkWithFilters && + bulkWithFiltersConfig == other.bulkWithFiltersConfig && + cadence == other.cadence && + currency == other.currency && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + bulkWithFiltersConfig, + cadence, + currency, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BulkWithFilters{bulkWithFiltersConfig=$bulkWithFiltersConfig, cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + } + class GroupedWithMinMaxThresholds @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionSchedulePlanChangeParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionSchedulePlanChangeParams.kt index c13b19cd6..9c876d7a1 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionSchedulePlanChangeParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionSchedulePlanChangeParams.kt @@ -4222,6 +4222,10 @@ private constructor( /** Alias for calling [price] with `Price.ofBulk(bulk)`. */ fun price(bulk: NewSubscriptionBulkPrice) = price(Price.ofBulk(bulk)) + /** Alias for calling [price] with `Price.ofBulkWithFilters(bulkWithFilters)`. */ + fun price(bulkWithFilters: Price.BulkWithFilters) = + price(Price.ofBulkWithFilters(bulkWithFilters)) + /** Alias for calling [price] with `Price.ofPackage(package_)`. */ fun price(package_: NewSubscriptionPackagePrice) = price(Price.ofPackage(package_)) @@ -4486,6 +4490,7 @@ private constructor( private val unit: NewSubscriptionUnitPrice? = null, private val tiered: NewSubscriptionTieredPrice? = null, private val bulk: NewSubscriptionBulkPrice? = null, + private val bulkWithFilters: BulkWithFilters? = null, private val package_: NewSubscriptionPackagePrice? = null, private val matrix: NewSubscriptionMatrixPrice? = null, private val thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice? = null, @@ -4529,6 +4534,8 @@ private constructor( fun bulk(): NewSubscriptionBulkPrice? = bulk + fun bulkWithFilters(): BulkWithFilters? = bulkWithFilters + fun package_(): NewSubscriptionPackagePrice? = package_ fun matrix(): NewSubscriptionMatrixPrice? = matrix @@ -4601,6 +4608,8 @@ private constructor( fun isBulk(): Boolean = bulk != null + fun isBulkWithFilters(): Boolean = bulkWithFilters != null + fun isPackage(): Boolean = package_ != null fun isMatrix(): Boolean = matrix != null @@ -4660,6 +4669,8 @@ private constructor( fun asBulk(): NewSubscriptionBulkPrice = bulk.getOrThrow("bulk") + fun asBulkWithFilters(): BulkWithFilters = bulkWithFilters.getOrThrow("bulkWithFilters") + fun asPackage(): NewSubscriptionPackagePrice = package_.getOrThrow("package_") fun asMatrix(): NewSubscriptionMatrixPrice = matrix.getOrThrow("matrix") @@ -4742,6 +4753,7 @@ private constructor( unit != null -> visitor.visitUnit(unit) tiered != null -> visitor.visitTiered(tiered) bulk != null -> visitor.visitBulk(bulk) + bulkWithFilters != null -> visitor.visitBulkWithFilters(bulkWithFilters) package_ != null -> visitor.visitPackage(package_) matrix != null -> visitor.visitMatrix(matrix) thresholdTotalAmount != null -> @@ -4808,6 +4820,10 @@ private constructor( bulk.validate() } + override fun visitBulkWithFilters(bulkWithFilters: BulkWithFilters) { + bulkWithFilters.validate() + } + override fun visitPackage(package_: NewSubscriptionPackagePrice) { package_.validate() } @@ -4985,6 +5001,9 @@ private constructor( override fun visitBulk(bulk: NewSubscriptionBulkPrice) = bulk.validity() + override fun visitBulkWithFilters(bulkWithFilters: BulkWithFilters) = + bulkWithFilters.validity() + override fun visitPackage(package_: NewSubscriptionPackagePrice) = package_.validity() @@ -5099,6 +5118,7 @@ private constructor( unit == other.unit && tiered == other.tiered && bulk == other.bulk && + bulkWithFilters == other.bulkWithFilters && package_ == other.package_ && matrix == other.matrix && thresholdTotalAmount == other.thresholdTotalAmount && @@ -5132,6 +5152,7 @@ private constructor( unit, tiered, bulk, + bulkWithFilters, package_, matrix, thresholdTotalAmount, @@ -5165,6 +5186,7 @@ private constructor( unit != null -> "Price{unit=$unit}" tiered != null -> "Price{tiered=$tiered}" bulk != null -> "Price{bulk=$bulk}" + bulkWithFilters != null -> "Price{bulkWithFilters=$bulkWithFilters}" package_ != null -> "Price{package_=$package_}" matrix != null -> "Price{matrix=$matrix}" thresholdTotalAmount != null -> @@ -5216,6 +5238,9 @@ private constructor( fun ofBulk(bulk: NewSubscriptionBulkPrice) = Price(bulk = bulk) + fun ofBulkWithFilters(bulkWithFilters: BulkWithFilters) = + Price(bulkWithFilters = bulkWithFilters) + fun ofPackage(package_: NewSubscriptionPackagePrice) = Price(package_ = package_) fun ofMatrix(matrix: NewSubscriptionMatrixPrice) = Price(matrix = matrix) @@ -5316,6 +5341,8 @@ private constructor( fun visitBulk(bulk: NewSubscriptionBulkPrice): T + fun visitBulkWithFilters(bulkWithFilters: BulkWithFilters): T + fun visitPackage(package_: NewSubscriptionPackagePrice): T fun visitMatrix(matrix: NewSubscriptionMatrixPrice): T @@ -5440,6 +5467,11 @@ private constructor( return tryDeserialize(node, jacksonTypeRef()) ?.let { Price(bulk = it, _json = json) } ?: Price(_json = json) } + "bulk_with_filters" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(bulkWithFilters = it, _json = json) + } ?: Price(_json = json) + } "package" -> { return tryDeserialize( node, @@ -5657,6 +5689,8 @@ private constructor( value.unit != null -> generator.writeObject(value.unit) value.tiered != null -> generator.writeObject(value.tiered) value.bulk != null -> generator.writeObject(value.bulk) + value.bulkWithFilters != null -> + generator.writeObject(value.bulkWithFilters) value.package_ != null -> generator.writeObject(value.package_) value.matrix != null -> generator.writeObject(value.matrix) value.thresholdTotalAmount != null -> @@ -5708,14 +5742,14 @@ private constructor( } } - class TieredWithProration + class BulkWithFilters @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( + private val bulkWithFiltersConfig: JsonField, private val cadence: JsonField, private val itemId: JsonField, private val modelType: JsonValue, private val name: JsonField, - private val tieredWithProrationConfig: JsonField, private val billableMetricId: JsonField, private val billedInAdvance: JsonField, private val billingCycleConfiguration: JsonField, @@ -5735,6 +5769,9 @@ private constructor( @JsonCreator private constructor( + @JsonProperty("bulk_with_filters_config") + @ExcludeMissing + bulkWithFiltersConfig: JsonField = JsonMissing.of(), @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), @@ -5747,10 +5784,6 @@ private constructor( @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("tiered_with_proration_config") - @ExcludeMissing - tieredWithProrationConfig: JsonField = - JsonMissing.of(), @JsonProperty("billable_metric_id") @ExcludeMissing billableMetricId: JsonField = JsonMissing.of(), @@ -5794,11 +5827,11 @@ private constructor( @ExcludeMissing referenceId: JsonField = JsonMissing.of(), ) : this( + bulkWithFiltersConfig, cadence, itemId, modelType, name, - tieredWithProrationConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -5815,6 +5848,16 @@ private constructor( mutableMapOf(), ) + /** + * Configuration for bulk_with_filters pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun bulkWithFiltersConfig(): BulkWithFiltersConfig = + bulkWithFiltersConfig.getRequired("bulk_with_filters_config") + /** * The cadence to bill for this price on. * @@ -5838,7 +5881,7 @@ private constructor( * * Expected to always return the following: * ```kotlin - * JsonValue.from("tiered_with_proration") + * JsonValue.from("bulk_with_filters") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -5855,16 +5898,6 @@ private constructor( */ fun name(): String = name.getRequired("name") - /** - * Configuration for tiered_with_proration pricing - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun tieredWithProrationConfig(): TieredWithProrationConfig = - tieredWithProrationConfig.getRequired("tiered_with_proration_config") - /** * The id of the billable metric for the price. Only needed if the price is * usage-based. @@ -5984,6 +6017,17 @@ private constructor( */ fun referenceId(): String? = referenceId.getNullable("reference_id") + /** + * Returns the raw JSON value of [bulkWithFiltersConfig]. + * + * Unlike [bulkWithFiltersConfig], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("bulk_with_filters_config") + @ExcludeMissing + fun _bulkWithFiltersConfig(): JsonField = + bulkWithFiltersConfig + /** * Returns the raw JSON value of [cadence]. * @@ -6010,17 +6054,6 @@ private constructor( */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - /** - * Returns the raw JSON value of [tieredWithProrationConfig]. - * - * Unlike [tieredWithProrationConfig], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("tiered_with_proration_config") - @ExcludeMissing - fun _tieredWithProrationConfig(): JsonField = - tieredWithProrationConfig - /** * Returns the raw JSON value of [billableMetricId]. * @@ -6169,29 +6202,27 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [TieredWithProration]. + * Returns a mutable builder for constructing an instance of [BulkWithFilters]. * * The following fields are required: * ```kotlin + * .bulkWithFiltersConfig() * .cadence() * .itemId() * .name() - * .tieredWithProrationConfig() * ``` */ fun builder() = Builder() } - /** A builder for [TieredWithProration]. */ + /** A builder for [BulkWithFilters]. */ class Builder internal constructor() { + private var bulkWithFiltersConfig: JsonField? = null private var cadence: JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonValue = JsonValue.from("tiered_with_proration") + private var modelType: JsonValue = JsonValue.from("bulk_with_filters") private var name: JsonField? = null - private var tieredWithProrationConfig: JsonField? = - null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() private var billingCycleConfiguration: JsonField = @@ -6213,31 +6244,44 @@ private constructor( private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(tieredWithProration: TieredWithProration) = apply { - cadence = tieredWithProration.cadence - itemId = tieredWithProration.itemId - modelType = tieredWithProration.modelType - name = tieredWithProration.name - tieredWithProrationConfig = tieredWithProration.tieredWithProrationConfig - billableMetricId = tieredWithProration.billableMetricId - billedInAdvance = tieredWithProration.billedInAdvance - billingCycleConfiguration = tieredWithProration.billingCycleConfiguration - conversionRate = tieredWithProration.conversionRate - conversionRateConfig = tieredWithProration.conversionRateConfig - currency = tieredWithProration.currency + internal fun from(bulkWithFilters: BulkWithFilters) = apply { + bulkWithFiltersConfig = bulkWithFilters.bulkWithFiltersConfig + cadence = bulkWithFilters.cadence + itemId = bulkWithFilters.itemId + modelType = bulkWithFilters.modelType + name = bulkWithFilters.name + billableMetricId = bulkWithFilters.billableMetricId + billedInAdvance = bulkWithFilters.billedInAdvance + billingCycleConfiguration = bulkWithFilters.billingCycleConfiguration + conversionRate = bulkWithFilters.conversionRate + conversionRateConfig = bulkWithFilters.conversionRateConfig + currency = bulkWithFilters.currency dimensionalPriceConfiguration = - tieredWithProration.dimensionalPriceConfiguration - externalPriceId = tieredWithProration.externalPriceId - fixedPriceQuantity = tieredWithProration.fixedPriceQuantity - invoiceGroupingKey = tieredWithProration.invoiceGroupingKey - invoicingCycleConfiguration = - tieredWithProration.invoicingCycleConfiguration - metadata = tieredWithProration.metadata - referenceId = tieredWithProration.referenceId - additionalProperties = - tieredWithProration.additionalProperties.toMutableMap() + bulkWithFilters.dimensionalPriceConfiguration + externalPriceId = bulkWithFilters.externalPriceId + fixedPriceQuantity = bulkWithFilters.fixedPriceQuantity + invoiceGroupingKey = bulkWithFilters.invoiceGroupingKey + invoicingCycleConfiguration = bulkWithFilters.invoicingCycleConfiguration + metadata = bulkWithFilters.metadata + referenceId = bulkWithFilters.referenceId + additionalProperties = bulkWithFilters.additionalProperties.toMutableMap() } + /** Configuration for bulk_with_filters pricing */ + fun bulkWithFiltersConfig(bulkWithFiltersConfig: BulkWithFiltersConfig) = + bulkWithFiltersConfig(JsonField.of(bulkWithFiltersConfig)) + + /** + * Sets [Builder.bulkWithFiltersConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.bulkWithFiltersConfig] with a well-typed + * [BulkWithFiltersConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun bulkWithFiltersConfig( + bulkWithFiltersConfig: JsonField + ) = apply { this.bulkWithFiltersConfig = bulkWithFiltersConfig } + /** The cadence to bill for this price on. */ fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) @@ -6268,7 +6312,7 @@ private constructor( * It is usually unnecessary to call this method because the field defaults to * the following: * ```kotlin - * JsonValue.from("tiered_with_proration") + * JsonValue.from("bulk_with_filters") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -6288,22 +6332,6 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } - /** Configuration for tiered_with_proration pricing */ - fun tieredWithProrationConfig( - tieredWithProrationConfig: TieredWithProrationConfig - ) = tieredWithProrationConfig(JsonField.of(tieredWithProrationConfig)) - - /** - * Sets [Builder.tieredWithProrationConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.tieredWithProrationConfig] with a well-typed - * [TieredWithProrationConfig] value instead. This method is primarily for - * setting the field to an undocumented or not yet supported value. - */ - fun tieredWithProrationConfig( - tieredWithProrationConfig: JsonField - ) = apply { this.tieredWithProrationConfig = tieredWithProrationConfig } - /** * The id of the billable metric for the price. Only needed if the price is * usage-based. @@ -6633,27 +6661,27 @@ private constructor( } /** - * Returns an immutable instance of [TieredWithProration]. + * Returns an immutable instance of [BulkWithFilters]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```kotlin + * .bulkWithFiltersConfig() * .cadence() * .itemId() * .name() - * .tieredWithProrationConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): TieredWithProration = - TieredWithProration( + fun build(): BulkWithFilters = + BulkWithFilters( + checkRequired("bulkWithFiltersConfig", bulkWithFiltersConfig), checkRequired("cadence", cadence), checkRequired("itemId", itemId), modelType, checkRequired("name", name), - checkRequired("tieredWithProrationConfig", tieredWithProrationConfig), billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -6673,20 +6701,20 @@ private constructor( private var validated: Boolean = false - fun validate(): TieredWithProration = apply { + fun validate(): BulkWithFilters = apply { if (validated) { return@apply } + bulkWithFiltersConfig().validate() cadence().validate() itemId() _modelType().let { - if (it != JsonValue.from("tiered_with_proration")) { + if (it != JsonValue.from("bulk_with_filters")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } name() - tieredWithProrationConfig().validate() billableMetricId() billedInAdvance() billingCycleConfiguration()?.validate() @@ -6718,13 +6746,11 @@ private constructor( * Used for best match union deserialization. */ internal fun validity(): Int = - (cadence.asKnown()?.validity() ?: 0) + + (bulkWithFiltersConfig.asKnown()?.validity() ?: 0) + + (cadence.asKnown()?.validity() ?: 0) + (if (itemId.asKnown() == null) 0 else 1) + - modelType.let { - if (it == JsonValue.from("tiered_with_proration")) 1 else 0 - } + + modelType.let { if (it == JsonValue.from("bulk_with_filters")) 1 else 0 } + (if (name.asKnown() == null) 0 else 1) + - (tieredWithProrationConfig.asKnown()?.validity() ?: 0) + (if (billableMetricId.asKnown() == null) 0 else 1) + (if (billedInAdvance.asKnown() == null) 0 else 1) + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + @@ -6739,201 +6765,66 @@ private constructor( (metadata.asKnown()?.validity() ?: 0) + (if (referenceId.asKnown() == null) 0 else 1) - /** The cadence to bill for this price on. */ - class Cadence - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - val ANNUAL = of("annual") - - val SEMI_ANNUAL = of("semi_annual") - - val MONTHLY = of("monthly") - - val QUARTERLY = of("quarterly") - - val ONE_TIME = of("one_time") - - val CUSTOM = of("custom") - - fun of(value: String) = Cadence(JsonField.of(value)) - } + /** Configuration for bulk_with_filters pricing */ + class BulkWithFiltersConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val filters: JsonField>, + private val tiers: JsonField>, + private val additionalProperties: MutableMap, + ) { - /** An enum containing [Cadence]'s known values. */ - enum class Known { - ANNUAL, - SEMI_ANNUAL, - MONTHLY, - QUARTERLY, - ONE_TIME, - CUSTOM, - } + @JsonCreator + private constructor( + @JsonProperty("filters") + @ExcludeMissing + filters: JsonField> = JsonMissing.of(), + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of(), + ) : this(filters, tiers, mutableMapOf()) /** - * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * Property filters to apply (all must match) * - * An instance of [Cadence] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). */ - enum class Value { - ANNUAL, - SEMI_ANNUAL, - MONTHLY, - QUARTERLY, - ONE_TIME, - CUSTOM, - /** - * An enum member indicating that [Cadence] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } + fun filters(): List = filters.getRequired("filters") /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * Bulk tiers for rating based on total usage volume * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). */ - fun value(): Value = - when (this) { - ANNUAL -> Value.ANNUAL - SEMI_ANNUAL -> Value.SEMI_ANNUAL - MONTHLY -> Value.MONTHLY - QUARTERLY -> Value.QUARTERLY - ONE_TIME -> Value.ONE_TIME - CUSTOM -> Value.CUSTOM - else -> Value._UNKNOWN - } + fun tiers(): List = tiers.getRequired("tiers") /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. + * Returns the raw JSON value of [filters]. * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. + * Unlike [filters], this method doesn't throw if the JSON field has an + * unexpected type. */ - fun known(): Known = - when (this) { - ANNUAL -> Known.ANNUAL - SEMI_ANNUAL -> Known.SEMI_ANNUAL - MONTHLY -> Known.MONTHLY - QUARTERLY -> Known.QUARTERLY - ONE_TIME -> Known.ONE_TIME - CUSTOM -> Known.CUSTOM - else -> throw OrbInvalidDataException("Unknown Cadence: $value") - } + @JsonProperty("filters") + @ExcludeMissing + fun _filters(): JsonField> = filters /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. + * Returns the raw JSON value of [tiers]. * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. */ - fun asString(): String = - _value().asString() - ?: throw OrbInvalidDataException("Value is not a String") - - private var validated: Boolean = false - - fun validate(): Cadence = apply { - if (validated) { - return@apply - } + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Cadence && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** Configuration for tiered_with_proration pricing */ - class TieredWithProrationConfig - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val tiers: JsonField>, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("tiers") - @ExcludeMissing - tiers: JsonField> = JsonMissing.of() - ) : this(tiers, mutableMapOf()) - - /** - * Tiers for rating based on total usage quantities into the specified tier with - * proration - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun tiers(): List = tiers.getRequired("tiers") - - /** - * Returns the raw JSON value of [tiers]. - * - * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("tiers") - @ExcludeMissing - fun _tiers(): JsonField> = tiers - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) } @JsonAnyGetter @@ -6947,34 +6838,60 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [TieredWithProrationConfig]. + * [BulkWithFiltersConfig]. * * The following fields are required: * ```kotlin + * .filters() * .tiers() * ``` */ fun builder() = Builder() } - /** A builder for [TieredWithProrationConfig]. */ + /** A builder for [BulkWithFiltersConfig]. */ class Builder internal constructor() { + private var filters: JsonField>? = null private var tiers: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(tieredWithProrationConfig: TieredWithProrationConfig) = - apply { - tiers = tieredWithProrationConfig.tiers.map { it.toMutableList() } - additionalProperties = - tieredWithProrationConfig.additionalProperties.toMutableMap() - } + internal fun from(bulkWithFiltersConfig: BulkWithFiltersConfig) = apply { + filters = bulkWithFiltersConfig.filters.map { it.toMutableList() } + tiers = bulkWithFiltersConfig.tiers.map { it.toMutableList() } + additionalProperties = + bulkWithFiltersConfig.additionalProperties.toMutableMap() + } + + /** Property filters to apply (all must match) */ + fun filters(filters: List) = filters(JsonField.of(filters)) /** - * Tiers for rating based on total usage quantities into the specified tier - * with proration + * Sets [Builder.filters] to an arbitrary JSON value. + * + * You should usually call [Builder.filters] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun filters(filters: JsonField>) = apply { + this.filters = filters.map { it.toMutableList() } + } + + /** + * Adds a single [Filter] to [filters]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. */ + fun addFilter(filter: Filter) = apply { + filters = + (filters ?: JsonField.of(mutableListOf())).also { + checkKnown("filters", it).add(filter) + } + } + + /** Bulk tiers for rating based on total usage volume */ fun tiers(tiers: List) = tiers(JsonField.of(tiers)) /** @@ -7024,19 +6941,21 @@ private constructor( } /** - * Returns an immutable instance of [TieredWithProrationConfig]. + * Returns an immutable instance of [BulkWithFiltersConfig]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```kotlin + * .filters() * .tiers() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): TieredWithProrationConfig = - TieredWithProrationConfig( + fun build(): BulkWithFiltersConfig = + BulkWithFiltersConfig( + checkRequired("filters", filters).map { it.toImmutable() }, checkRequired("tiers", tiers).map { it.toImmutable() }, additionalProperties.toMutableMap(), ) @@ -7044,11 +6963,12 @@ private constructor( private var validated: Boolean = false - fun validate(): TieredWithProrationConfig = apply { + fun validate(): BulkWithFiltersConfig = apply { if (validated) { return@apply } + filters().forEach { it.validate() } tiers().forEach { it.validate() } validated = true } @@ -7068,65 +6988,65 @@ private constructor( * Used for best match union deserialization. */ internal fun validity(): Int = - (tiers.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + (filters.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + (tiers.asKnown()?.sumOf { it.validity().toInt() } ?: 0) - /** Configuration for a single tiered with proration tier */ - class Tier + /** Configuration for a single property filter */ + class Filter @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val tierLowerBound: JsonField, - private val unitAmount: JsonField, + private val propertyKey: JsonField, + private val propertyValue: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("tier_lower_bound") + @JsonProperty("property_key") @ExcludeMissing - tierLowerBound: JsonField = JsonMissing.of(), - @JsonProperty("unit_amount") + propertyKey: JsonField = JsonMissing.of(), + @JsonProperty("property_value") @ExcludeMissing - unitAmount: JsonField = JsonMissing.of(), - ) : this(tierLowerBound, unitAmount, mutableMapOf()) + propertyValue: JsonField = JsonMissing.of(), + ) : this(propertyKey, propertyValue, mutableMapOf()) /** - * Inclusive tier starting value + * Event property key to filter on * * @throws OrbInvalidDataException if the JSON field has an unexpected type * or is unexpectedly missing or null (e.g. if the server responded with * an unexpected value). */ - fun tierLowerBound(): String = - tierLowerBound.getRequired("tier_lower_bound") + fun propertyKey(): String = propertyKey.getRequired("property_key") /** - * Amount per unit + * Event property value to match * * @throws OrbInvalidDataException if the JSON field has an unexpected type * or is unexpectedly missing or null (e.g. if the server responded with * an unexpected value). */ - fun unitAmount(): String = unitAmount.getRequired("unit_amount") + fun propertyValue(): String = propertyValue.getRequired("property_value") /** - * Returns the raw JSON value of [tierLowerBound]. + * Returns the raw JSON value of [propertyKey]. * - * Unlike [tierLowerBound], this method doesn't throw if the JSON field has - * an unexpected type. + * Unlike [propertyKey], this method doesn't throw if the JSON field has an + * unexpected type. */ - @JsonProperty("tier_lower_bound") + @JsonProperty("property_key") @ExcludeMissing - fun _tierLowerBound(): JsonField = tierLowerBound + fun _propertyKey(): JsonField = propertyKey /** - * Returns the raw JSON value of [unitAmount]. + * Returns the raw JSON value of [propertyValue]. * - * Unlike [unitAmount], this method doesn't throw if the JSON field has an - * unexpected type. + * Unlike [propertyValue], this method doesn't throw if the JSON field has + * an unexpected type. */ - @JsonProperty("unit_amount") + @JsonProperty("property_value") @ExcludeMissing - fun _unitAmount(): JsonField = unitAmount + fun _propertyValue(): JsonField = propertyValue @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -7143,59 +7063,59 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [Tier]. + * Returns a mutable builder for constructing an instance of [Filter]. * * The following fields are required: * ```kotlin - * .tierLowerBound() - * .unitAmount() + * .propertyKey() + * .propertyValue() * ``` */ fun builder() = Builder() } - /** A builder for [Tier]. */ + /** A builder for [Filter]. */ class Builder internal constructor() { - private var tierLowerBound: JsonField? = null - private var unitAmount: JsonField? = null + private var propertyKey: JsonField? = null + private var propertyValue: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(tier: Tier) = apply { - tierLowerBound = tier.tierLowerBound - unitAmount = tier.unitAmount - additionalProperties = tier.additionalProperties.toMutableMap() + internal fun from(filter: Filter) = apply { + propertyKey = filter.propertyKey + propertyValue = filter.propertyValue + additionalProperties = filter.additionalProperties.toMutableMap() } - /** Inclusive tier starting value */ - fun tierLowerBound(tierLowerBound: String) = - tierLowerBound(JsonField.of(tierLowerBound)) + /** Event property key to filter on */ + fun propertyKey(propertyKey: String) = + propertyKey(JsonField.of(propertyKey)) /** - * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * Sets [Builder.propertyKey] to an arbitrary JSON value. * - * You should usually call [Builder.tierLowerBound] with a well-typed + * You should usually call [Builder.propertyKey] with a well-typed * [String] value instead. This method is primarily for setting the * field to an undocumented or not yet supported value. */ - fun tierLowerBound(tierLowerBound: JsonField) = apply { - this.tierLowerBound = tierLowerBound + fun propertyKey(propertyKey: JsonField) = apply { + this.propertyKey = propertyKey } - /** Amount per unit */ - fun unitAmount(unitAmount: String) = - unitAmount(JsonField.of(unitAmount)) + /** Event property value to match */ + fun propertyValue(propertyValue: String) = + propertyValue(JsonField.of(propertyValue)) /** - * Sets [Builder.unitAmount] to an arbitrary JSON value. + * Sets [Builder.propertyValue] to an arbitrary JSON value. * - * You should usually call [Builder.unitAmount] with a well-typed + * You should usually call [Builder.propertyValue] with a well-typed * [String] value instead. This method is primarily for setting the * field to an undocumented or not yet supported value. */ - fun unitAmount(unitAmount: JsonField) = apply { - this.unitAmount = unitAmount + fun propertyValue(propertyValue: JsonField) = apply { + this.propertyValue = propertyValue } fun additionalProperties(additionalProperties: Map) = @@ -7221,36 +7141,36 @@ private constructor( } /** - * Returns an immutable instance of [Tier]. + * Returns an immutable instance of [Filter]. * * Further updates to this [Builder] will not mutate the returned * instance. * * The following fields are required: * ```kotlin - * .tierLowerBound() - * .unitAmount() + * .propertyKey() + * .propertyValue() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): Tier = - Tier( - checkRequired("tierLowerBound", tierLowerBound), - checkRequired("unitAmount", unitAmount), + fun build(): Filter = + Filter( + checkRequired("propertyKey", propertyKey), + checkRequired("propertyValue", propertyValue), additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): Tier = apply { + fun validate(): Filter = apply { if (validated) { return@apply } - tierLowerBound() - unitAmount() + propertyKey() + propertyValue() validated = true } @@ -7269,4573 +7189,3965 @@ private constructor( * Used for best match union deserialization. */ internal fun validity(): Int = - (if (tierLowerBound.asKnown() == null) 0 else 1) + - (if (unitAmount.asKnown() == null) 0 else 1) + (if (propertyKey.asKnown() == null) 0 else 1) + + (if (propertyValue.asKnown() == null) 0 else 1) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is Tier && - tierLowerBound == other.tierLowerBound && - unitAmount == other.unitAmount && + return other is Filter && + propertyKey == other.propertyKey && + propertyValue == other.propertyValue && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(tierLowerBound, unitAmount, additionalProperties) + Objects.hash(propertyKey, propertyValue, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "Tier{tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is TieredWithProrationConfig && - tiers == other.tiers && - additionalProperties == other.additionalProperties + "Filter{propertyKey=$propertyKey, propertyValue=$propertyValue, additionalProperties=$additionalProperties}" } - private val hashCode: Int by lazy { Objects.hash(tiers, additionalProperties) } + /** Configuration for a single bulk pricing tier */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val unitAmount: JsonField, + private val tierLowerBound: JsonField, + private val additionalProperties: MutableMap, + ) { - override fun hashCode(): Int = hashCode + @JsonCreator + private constructor( + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + ) : this(unitAmount, tierLowerBound, mutableMapOf()) - override fun toString() = - "TieredWithProrationConfig{tiers=$tiers, additionalProperties=$additionalProperties}" - } + /** + * Amount per unit + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - class Metadata - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { + /** + * The lower bound for this tier + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun tierLowerBound(): String? = + tierLowerBound.getNullable("tier_lower_bound") - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount - fun toBuilder() = Builder().from(this) + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound - companion object { + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - /** Returns a mutable builder for constructing an instance of [Metadata]. */ - fun builder() = Builder() - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - /** A builder for [Metadata]. */ - class Builder internal constructor() { + fun toBuilder() = Builder().from(this) - private var additionalProperties: MutableMap = - mutableMapOf() + companion object { - internal fun from(metadata: Metadata) = apply { - additionalProperties = metadata.additionalProperties.toMutableMap() + /** + * Returns a mutable builder for constructing an instance of [Tier]. + * + * The following fields are required: + * ```kotlin + * .unitAmount() + * ``` + */ + fun builder() = Builder() } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var unitAmount: JsonField? = null + private var tierLowerBound: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(tier: Tier) = apply { + unitAmount = tier.unitAmount + tierLowerBound = tier.tierLowerBound + additionalProperties = tier.additionalProperties.toMutableMap() } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** Amount per unit */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) + /** The lower bound for this tier */ + fun tierLowerBound(tierLowerBound: String?) = + tierLowerBound(JsonField.ofNullable(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```kotlin + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("unitAmount", unitAmount), + tierLowerBound, + additionalProperties.toMutableMap(), + ) } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + unitAmount() + tierLowerBound() + validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + /** - * Returns an immutable instance of [Metadata]. + * Returns a score indicating how many valid values are contained in this + * object recursively. * - * Further updates to this [Builder] will not mutate the returned instance. + * Used for best match union deserialization. */ - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } + internal fun validity(): Int = + (if (unitAmount.asKnown() == null) 0 else 1) + + (if (tierLowerBound.asKnown() == null) 0 else 1) - private var validated: Boolean = false + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun validate(): Metadata = apply { - if (validated) { - return@apply + return other is Tier && + unitAmount == other.unitAmount && + tierLowerBound == other.tierLowerBound && + additionalProperties == other.additionalProperties } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false + private val hashCode: Int by lazy { + Objects.hash(unitAmount, tierLowerBound, additionalProperties) } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - additionalProperties.count { (_, value) -> - !value.isNull() && !value.isMissing() - } + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{unitAmount=$unitAmount, tierLowerBound=$tierLowerBound, additionalProperties=$additionalProperties}" + } override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is Metadata && + return other is BulkWithFiltersConfig && + filters == other.filters && + tiers == other.tiers && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + private val hashCode: Int by lazy { + Objects.hash(filters, tiers, additionalProperties) + } override fun hashCode(): Int = hashCode - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + override fun toString() = + "BulkWithFiltersConfig{filters=$filters, tiers=$tiers, additionalProperties=$additionalProperties}" } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { - return other is TieredWithProration && - cadence == other.cadence && - itemId == other.itemId && - modelType == other.modelType && - name == other.name && - tieredWithProrationConfig == other.tieredWithProrationConfig && - billableMetricId == other.billableMetricId && - billedInAdvance == other.billedInAdvance && - billingCycleConfiguration == other.billingCycleConfiguration && - conversionRate == other.conversionRate && - conversionRateConfig == other.conversionRateConfig && - currency == other.currency && - dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && - externalPriceId == other.externalPriceId && - fixedPriceQuantity == other.fixedPriceQuantity && - invoiceGroupingKey == other.invoiceGroupingKey && - invoicingCycleConfiguration == other.invoicingCycleConfiguration && - metadata == other.metadata && - referenceId == other.referenceId && - additionalProperties == other.additionalProperties - } + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value - private val hashCode: Int by lazy { - Objects.hash( - cadence, - itemId, - modelType, - name, - tieredWithProrationConfig, - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - conversionRateConfig, - currency, - dimensionalPriceConfiguration, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - additionalProperties, - ) - } + companion object { - override fun hashCode(): Int = hashCode + val ANNUAL = of("annual") - override fun toString() = - "TieredWithProration{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredWithProrationConfig=$tieredWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" - } + val SEMI_ANNUAL = of("semi_annual") - class GroupedWithMinMaxThresholds - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val cadence: JsonField, - private val groupedWithMinMaxThresholdsConfig: - JsonField, - private val itemId: JsonField, - private val modelType: JsonValue, - private val name: JsonField, - private val billableMetricId: JsonField, - private val billedInAdvance: JsonField, - private val billingCycleConfiguration: JsonField, - private val conversionRate: JsonField, - private val conversionRateConfig: JsonField, - private val currency: JsonField, - private val dimensionalPriceConfiguration: - JsonField, - private val externalPriceId: JsonField, - private val fixedPriceQuantity: JsonField, - private val invoiceGroupingKey: JsonField, - private val invoicingCycleConfiguration: JsonField, - private val metadata: JsonField, - private val referenceId: JsonField, - private val additionalProperties: MutableMap, - ) { + val MONTHLY = of("monthly") - @JsonCreator - private constructor( - @JsonProperty("cadence") - @ExcludeMissing - cadence: JsonField = JsonMissing.of(), - @JsonProperty("grouped_with_min_max_thresholds_config") - @ExcludeMissing - groupedWithMinMaxThresholdsConfig: - JsonField = - JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - modelType: JsonValue = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - name: JsonField = JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("conversion_rate_config") - @ExcludeMissing - conversionRateConfig: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - currency: JsonField = JsonMissing.of(), - @JsonProperty("dimensional_price_configuration") - @ExcludeMissing - dimensionalPriceConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - metadata: JsonField = JsonMissing.of(), - @JsonProperty("reference_id") - @ExcludeMissing - referenceId: JsonField = JsonMissing.of(), - ) : this( - cadence, - groupedWithMinMaxThresholdsConfig, - itemId, - modelType, - name, - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - conversionRateConfig, - currency, - dimensionalPriceConfiguration, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - mutableMapOf(), - ) + val QUARTERLY = of("quarterly") - /** - * The cadence to bill for this price on. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun cadence(): Cadence = cadence.getRequired("cadence") + val ONE_TIME = of("one_time") - /** - * Configuration for grouped_with_min_max_thresholds pricing - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun groupedWithMinMaxThresholdsConfig(): GroupedWithMinMaxThresholdsConfig = - groupedWithMinMaxThresholdsConfig.getRequired( - "grouped_with_min_max_thresholds_config" - ) + val CUSTOM = of("custom") - /** - * The id of the item the price will be associated with. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun itemId(): String = itemId.getRequired("item_id") + fun of(value: String) = Cadence(JsonField.of(value)) + } - /** - * The pricing model type - * - * Expected to always return the following: - * ```kotlin - * JsonValue.from("grouped_with_min_max_thresholds") - * ``` - * - * However, this method can be useful for debugging and logging (e.g. if the server - * responded with an unexpected value). - */ - @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } - /** - * The name of the price. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun name(): String = name.getRequired("name") + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun billableMetricId(): String? = billableMetricId.getNullable("billable_metric_id") + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun billingCycleConfiguration(): NewBillingCycleConfiguration? = - billingCycleConfiguration.getNullable("billing_cycle_configuration") + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") - /** - * The per unit conversion rate of the price currency to the invoicing currency. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + private var validated: Boolean = false - /** - * The configuration for the rate of the price currency to the invoicing currency. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun conversionRateConfig(): ConversionRateConfig? = - conversionRateConfig.getNullable("conversion_rate_config") + fun validate(): Cadence = apply { + if (validated) { + return@apply + } - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun currency(): String? = currency.getNullable("currency") + known() + validated = true + } - /** - * For dimensional price: specifies a price group and dimension values - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = - dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - /** - * An alias for the price. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun fixedPriceQuantity(): Double? = - fixedPriceQuantity.getNullable("fixed_price_quantity") + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * The property used to group this price on an invoice - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun invoiceGroupingKey(): String? = - invoiceGroupingKey.getNullable("invoice_grouping_key") + return other is Cadence && value == other.value + } - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by * setting `metadata` to `null`. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). */ - fun metadata(): Metadata? = metadata.getNullable("metadata") + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun referenceId(): String? = referenceId.getNullable("reference_id") + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties - /** - * Returns the raw JSON value of [cadence]. - * - * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("cadence") - @ExcludeMissing - fun _cadence(): JsonField = cadence + fun toBuilder() = Builder().from(this) - /** - * Returns the raw JSON value of [groupedWithMinMaxThresholdsConfig]. - * - * Unlike [groupedWithMinMaxThresholdsConfig], this method doesn't throw if the JSON - * field has an unexpected type. - */ - @JsonProperty("grouped_with_min_max_thresholds_config") - @ExcludeMissing - fun _groupedWithMinMaxThresholdsConfig(): - JsonField = groupedWithMinMaxThresholdsConfig + companion object { - /** - * Returns the raw JSON value of [itemId]. - * - * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } - /** - * Returns the raw JSON value of [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + /** A builder for [Metadata]. */ + class Builder internal constructor() { - /** - * Returns the raw JSON value of [billableMetricId]. - * - * Unlike [billableMetricId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = billableMetricId + private var additionalProperties: MutableMap = + mutableMapOf() - /** - * Returns the raw JSON value of [billedInAdvance]. - * - * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } - /** - * Returns the raw JSON value of [billingCycleConfiguration]. - * - * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** - * Returns the raw JSON value of [conversionRate]. - * - * Unlike [conversionRate], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * Returns the raw JSON value of [conversionRateConfig]. - * - * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("conversion_rate_config") - @ExcludeMissing - fun _conversionRateConfig(): JsonField = conversionRateConfig + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - /** - * Returns the raw JSON value of [currency]. - * - * Unlike [currency], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("currency") - @ExcludeMissing - fun _currency(): JsonField = currency + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - /** - * Returns the raw JSON value of [dimensionalPriceConfiguration]. - * - * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON - * field has an unexpected type. - */ - @JsonProperty("dimensional_price_configuration") - @ExcludeMissing - fun _dimensionalPriceConfiguration(): JsonField = - dimensionalPriceConfiguration + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - /** - * Returns the raw JSON value of [externalPriceId]. - * - * Unlike [externalPriceId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } - /** - * Returns the raw JSON value of [fixedPriceQuantity]. - * - * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** - * Returns the raw JSON value of [invoiceGroupingKey]. - * - * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Returns the raw JSON value of [invoicingCycleConfiguration]. - * - * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * Returns the raw JSON value of [metadata]. - * - * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - /** - * Returns the raw JSON value of [referenceId]. - * - * Unlike [referenceId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("reference_id") - @ExcludeMissing - fun _referenceId(): JsonField = referenceId - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + private var validated: Boolean = false - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + fun validate(): Metadata = apply { + if (validated) { + return@apply + } - fun toBuilder() = Builder().from(this) + validated = true + } - companion object { + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } /** - * Returns a mutable builder for constructing an instance of - * [GroupedWithMinMaxThresholds]. + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * The following fields are required: - * ```kotlin - * .cadence() - * .groupedWithMinMaxThresholdsConfig() - * .itemId() - * .name() - * ``` + * Used for best match union deserialization. */ - fun builder() = Builder() - } - - /** A builder for [GroupedWithMinMaxThresholds]. */ - class Builder internal constructor() { - - private var cadence: JsonField? = null - private var groupedWithMinMaxThresholdsConfig: - JsonField? = - null - private var itemId: JsonField? = null - private var modelType: JsonValue = - JsonValue.from("grouped_with_min_max_thresholds") - private var name: JsonField? = null - private var billableMetricId: JsonField = JsonMissing.of() - private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var conversionRateConfig: JsonField = - JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var dimensionalPriceConfiguration: - JsonField = - JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: - JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var referenceId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } - internal fun from(groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds) = - apply { - cadence = groupedWithMinMaxThresholds.cadence - groupedWithMinMaxThresholdsConfig = - groupedWithMinMaxThresholds.groupedWithMinMaxThresholdsConfig - itemId = groupedWithMinMaxThresholds.itemId - modelType = groupedWithMinMaxThresholds.modelType - name = groupedWithMinMaxThresholds.name - billableMetricId = groupedWithMinMaxThresholds.billableMetricId - billedInAdvance = groupedWithMinMaxThresholds.billedInAdvance - billingCycleConfiguration = - groupedWithMinMaxThresholds.billingCycleConfiguration - conversionRate = groupedWithMinMaxThresholds.conversionRate - conversionRateConfig = groupedWithMinMaxThresholds.conversionRateConfig - currency = groupedWithMinMaxThresholds.currency - dimensionalPriceConfiguration = - groupedWithMinMaxThresholds.dimensionalPriceConfiguration - externalPriceId = groupedWithMinMaxThresholds.externalPriceId - fixedPriceQuantity = groupedWithMinMaxThresholds.fixedPriceQuantity - invoiceGroupingKey = groupedWithMinMaxThresholds.invoiceGroupingKey - invoicingCycleConfiguration = - groupedWithMinMaxThresholds.invoicingCycleConfiguration - metadata = groupedWithMinMaxThresholds.metadata - referenceId = groupedWithMinMaxThresholds.referenceId - additionalProperties = - groupedWithMinMaxThresholds.additionalProperties.toMutableMap() + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + return other is Metadata && + additionalProperties == other.additionalProperties + } - /** - * Sets [Builder.cadence] to an arbitrary JSON value. - * - * You should usually call [Builder.cadence] with a well-typed [Cadence] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /** Configuration for grouped_with_min_max_thresholds pricing */ - fun groupedWithMinMaxThresholdsConfig( - groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig - ) = - groupedWithMinMaxThresholdsConfig( - JsonField.of(groupedWithMinMaxThresholdsConfig) - ) + override fun hashCode(): Int = hashCode - /** - * Sets [Builder.groupedWithMinMaxThresholdsConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.groupedWithMinMaxThresholdsConfig] with a - * well-typed [GroupedWithMinMaxThresholdsConfig] value instead. This method is - * primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun groupedWithMinMaxThresholdsConfig( - groupedWithMinMaxThresholdsConfig: - JsonField - ) = apply { - this.groupedWithMinMaxThresholdsConfig = groupedWithMinMaxThresholdsConfig + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - /** The id of the item the price will be associated with. */ - fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + return other is BulkWithFilters && + bulkWithFiltersConfig == other.bulkWithFiltersConfig && + cadence == other.cadence && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } - /** - * Sets [Builder.itemId] to an arbitrary JSON value. - * - * You should usually call [Builder.itemId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + private val hashCode: Int by lazy { + Objects.hash( + bulkWithFiltersConfig, + cadence, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties, + ) + } - /** - * Sets the field to an arbitrary JSON value. - * - * It is usually unnecessary to call this method because the field defaults to - * the following: - * ```kotlin - * JsonValue.from("grouped_with_min_max_thresholds") - * ``` - * - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + override fun hashCode(): Int = hashCode - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) + override fun toString() = + "BulkWithFilters{bulkWithFiltersConfig=$bulkWithFiltersConfig, cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } - /** - * Sets [Builder.name] to an arbitrary JSON value. - * - * You should usually call [Builder.name] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun name(name: JsonField) = apply { this.name = name } + class TieredWithProration + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val tieredWithProrationConfig: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: String?) = - billableMetricId(JsonField.ofNullable(billableMetricId)) + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("tiered_with_proration_config") + @ExcludeMissing + tieredWithProrationConfig: JsonField = + JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + modelType, + name, + tieredWithProrationConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + mutableMapOf(), + ) - /** - * Sets [Builder.billableMetricId] to an arbitrary JSON value. - * - * You should usually call [Builder.billableMetricId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun billableMetricId(billableMetricId: JsonField) = apply { - this.billableMetricId = billableMetricId - } + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") - /** - * If the Price represents a fixed cost, the price will be billed in-advance if - * this is true, and in-arrears if this is false. - */ - fun billedInAdvance(billedInAdvance: Boolean?) = - billedInAdvance(JsonField.ofNullable(billedInAdvance)) + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") - /** - * Alias for [Builder.billedInAdvance]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun billedInAdvance(billedInAdvance: Boolean) = - billedInAdvance(billedInAdvance as Boolean?) + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("tiered_with_proration") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType - /** - * Sets [Builder.billedInAdvance] to an arbitrary JSON value. - * - * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun billedInAdvance(billedInAdvance: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: NewBillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + /** + * Configuration for tiered_with_proration pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun tieredWithProrationConfig(): TieredWithProrationConfig = + tieredWithProrationConfig.getRequired("tiered_with_proration_config") - /** - * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.billingCycleConfiguration] with a well-typed - * [NewBillingCycleConfiguration] value instead. This method is primarily for - * setting the field to an undocumented or not yet supported value. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: JsonField - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = billableMetricId.getNullable("billable_metric_id") - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: Double?) = - conversionRate(JsonField.ofNullable(conversionRate)) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") - /** - * Alias for [Builder.conversionRate]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") - /** - * Sets [Builder.conversionRate] to an arbitrary JSON value. - * - * You should usually call [Builder.conversionRate] with a well-typed [Double] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") - /** - * The configuration for the rate of the price currency to the invoicing - * currency. - */ - fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = - conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") - /** - * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.conversionRateConfig] with a well-typed - * [ConversionRateConfig] value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun conversionRateConfig( - conversionRateConfig: JsonField - ) = apply { this.conversionRateConfig = conversionRateConfig } + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") - /** - * Alias for calling [conversionRateConfig] with - * `ConversionRateConfig.ofUnit(unit)`. - */ - fun conversionRateConfig(unit: UnitConversionRateConfig) = - conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") - /** - * Alias for calling [conversionRateConfig] with the following: - * ```kotlin - * UnitConversionRateConfig.builder() - * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) - * .unitConfig(unitConfig) - * .build() - * ``` - */ - fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = - conversionRateConfig( - UnitConversionRateConfig.builder() - .conversionRateType( - UnitConversionRateConfig.ConversionRateType.UNIT - ) - .unitConfig(unitConfig) - .build() - ) + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") - /** - * Alias for calling [conversionRateConfig] with - * `ConversionRateConfig.ofTiered(tiered)`. - */ - fun conversionRateConfig(tiered: TieredConversionRateConfig) = - conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") - /** - * Alias for calling [conversionRateConfig] with the following: - * ```kotlin - * TieredConversionRateConfig.builder() - * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) - * .tieredConfig(tieredConfig) - * .build() - * ``` - */ - fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = - conversionRateConfig( - TieredConversionRateConfig.builder() - .conversionRateType( - TieredConversionRateConfig.ConversionRateType.TIERED - ) - .tieredConfig(tieredConfig) - .build() - ) + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + invoiceGroupingKey.getNullable("invoice_grouping_key") - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - /** - * Sets [Builder.currency] to an arbitrary JSON value. - * - * You should usually call [Builder.currency] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") - /** For dimensional price: specifies a price group and dimension values */ - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? - ) = - dimensionalPriceConfiguration( - JsonField.ofNullable(dimensionalPriceConfiguration) - ) + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") - /** - * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.dimensionalPriceConfiguration] with a - * well-typed [NewDimensionalPriceConfiguration] value instead. This method is - * primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: JsonField - ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - /** - * Sets [Builder.externalPriceId] to an arbitrary JSON value. - * - * You should usually call [Builder.externalPriceId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun externalPriceId(externalPriceId: JsonField) = apply { - this.externalPriceId = externalPriceId - } + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = - fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + /** + * Returns the raw JSON value of [tieredWithProrationConfig]. + * + * Unlike [tieredWithProrationConfig], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("tiered_with_proration_config") + @ExcludeMissing + fun _tieredWithProrationConfig(): JsonField = + tieredWithProrationConfig - /** - * Alias for [Builder.fixedPriceQuantity]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId - /** - * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. - * - * You should usually call [Builder.fixedPriceQuantity] with a well-typed - * [Double] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = - invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration - /** - * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. - * - * You should usually call [Builder.invoiceGroupingKey] with a well-typed - * [String] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { - this.invoiceGroupingKey = invoiceGroupingKey - } + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate - /** - * Within each billing cycle, specifies the cadence at which invoices are - * produced. If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: NewBillingCycleConfiguration? - ) = - invoicingCycleConfiguration( - JsonField.ofNullable(invoicingCycleConfiguration) - ) + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig - /** - * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.invoicingCycleConfiguration] with a - * well-typed [NewBillingCycleConfiguration] value instead. This method is - * primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration - /** - * Sets [Builder.metadata] to an arbitrary JSON value. - * - * You should usually call [Builder.metadata] with a well-typed [Metadata] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - fun referenceId(referenceId: String?) = - referenceId(JsonField.ofNullable(referenceId)) + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - /** - * Sets [Builder.referenceId] to an arbitrary JSON value. - * - * You should usually call [Builder.referenceId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun referenceId(referenceId: JsonField) = apply { - this.referenceId = referenceId - } + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { /** - * Returns an immutable instance of [GroupedWithMinMaxThresholds]. - * - * Further updates to this [Builder] will not mutate the returned instance. + * Returns a mutable builder for constructing an instance of + * [TieredWithProration]. * * The following fields are required: * ```kotlin * .cadence() - * .groupedWithMinMaxThresholdsConfig() * .itemId() * .name() + * .tieredWithProrationConfig() * ``` - * - * @throws IllegalStateException if any required field is unset. */ - fun build(): GroupedWithMinMaxThresholds = - GroupedWithMinMaxThresholds( - checkRequired("cadence", cadence), - checkRequired( - "groupedWithMinMaxThresholdsConfig", - groupedWithMinMaxThresholdsConfig, - ), - checkRequired("itemId", itemId), - modelType, - checkRequired("name", name), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - conversionRateConfig, - currency, - dimensionalPriceConfiguration, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - additionalProperties.toMutableMap(), - ) + fun builder() = Builder() } - private var validated: Boolean = false - - fun validate(): GroupedWithMinMaxThresholds = apply { - if (validated) { - return@apply - } + /** A builder for [TieredWithProration]. */ + class Builder internal constructor() { - cadence().validate() - groupedWithMinMaxThresholdsConfig().validate() - itemId() - _modelType().let { - if (it != JsonValue.from("grouped_with_min_max_thresholds")) { - throw OrbInvalidDataException("'modelType' is invalid, received $it") - } - } - name() - billableMetricId() - billedInAdvance() - billingCycleConfiguration()?.validate() - conversionRate() - conversionRateConfig()?.validate() - currency() - dimensionalPriceConfiguration()?.validate() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration()?.validate() - metadata()?.validate() - referenceId() - validated = true - } + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonValue = JsonValue.from("tiered_with_proration") + private var name: JsonField? = null + private var tieredWithProrationConfig: JsonField? = + null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false + internal fun from(tieredWithProration: TieredWithProration) = apply { + cadence = tieredWithProration.cadence + itemId = tieredWithProration.itemId + modelType = tieredWithProration.modelType + name = tieredWithProration.name + tieredWithProrationConfig = tieredWithProration.tieredWithProrationConfig + billableMetricId = tieredWithProration.billableMetricId + billedInAdvance = tieredWithProration.billedInAdvance + billingCycleConfiguration = tieredWithProration.billingCycleConfiguration + conversionRate = tieredWithProration.conversionRate + conversionRateConfig = tieredWithProration.conversionRateConfig + currency = tieredWithProration.currency + dimensionalPriceConfiguration = + tieredWithProration.dimensionalPriceConfiguration + externalPriceId = tieredWithProration.externalPriceId + fixedPriceQuantity = tieredWithProration.fixedPriceQuantity + invoiceGroupingKey = tieredWithProration.invoiceGroupingKey + invoicingCycleConfiguration = + tieredWithProration.invoicingCycleConfiguration + metadata = tieredWithProration.metadata + referenceId = tieredWithProration.referenceId + additionalProperties = + tieredWithProration.additionalProperties.toMutableMap() } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (cadence.asKnown()?.validity() ?: 0) + - (groupedWithMinMaxThresholdsConfig.asKnown()?.validity() ?: 0) + - (if (itemId.asKnown() == null) 0 else 1) + - modelType.let { - if (it == JsonValue.from("grouped_with_min_max_thresholds")) 1 else 0 - } + - (if (name.asKnown() == null) 0 else 1) + - (if (billableMetricId.asKnown() == null) 0 else 1) + - (if (billedInAdvance.asKnown() == null) 0 else 1) + - (billingCycleConfiguration.asKnown()?.validity() ?: 0) + - (if (conversionRate.asKnown() == null) 0 else 1) + - (conversionRateConfig.asKnown()?.validity() ?: 0) + - (if (currency.asKnown() == null) 0 else 1) + - (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + - (if (externalPriceId.asKnown() == null) 0 else 1) + - (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + - (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + - (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + - (metadata.asKnown()?.validity() ?: 0) + - (if (referenceId.asKnown() == null) 0 else 1) - - /** The cadence to bill for this price on. */ - class Cadence - @JsonCreator - private constructor(private val value: JsonField) : Enum { + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) /** - * Returns this class instance's raw value. + * Sets [Builder.cadence] to an arbitrary JSON value. * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - val ANNUAL = of("annual") + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - val SEMI_ANNUAL = of("semi_annual") + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - val MONTHLY = of("monthly") + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("tiered_with_proration") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } - val QUARTERLY = of("quarterly") + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) - val ONE_TIME = of("one_time") + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } - val CUSTOM = of("custom") + /** Configuration for tiered_with_proration pricing */ + fun tieredWithProrationConfig( + tieredWithProrationConfig: TieredWithProrationConfig + ) = tieredWithProrationConfig(JsonField.of(tieredWithProrationConfig)) - fun of(value: String) = Cadence(JsonField.of(value)) - } + /** + * Sets [Builder.tieredWithProrationConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.tieredWithProrationConfig] with a well-typed + * [TieredWithProrationConfig] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun tieredWithProrationConfig( + tieredWithProrationConfig: JsonField + ) = apply { this.tieredWithProrationConfig = tieredWithProrationConfig } - /** An enum containing [Cadence]'s known values. */ - enum class Known { - ANNUAL, - SEMI_ANNUAL, - MONTHLY, - QUARTERLY, - ONE_TIME, - CUSTOM, - } + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) /** - * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * Sets [Builder.billableMetricId] to an arbitrary JSON value. * - * An instance of [Cadence] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. */ - enum class Value { - ANNUAL, - SEMI_ANNUAL, - MONTHLY, - QUARTERLY, - ONE_TIME, - CUSTOM, - /** - * An enum member indicating that [Cadence] was instantiated with an unknown - * value. - */ - _UNKNOWN, + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId } /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. */ - fun value(): Value = - when (this) { - ANNUAL -> Value.ANNUAL - SEMI_ANNUAL -> Value.SEMI_ANNUAL - MONTHLY -> Value.MONTHLY - QUARTERLY -> Value.QUARTERLY - ONE_TIME -> Value.ONE_TIME - CUSTOM -> Value.CUSTOM - else -> Value._UNKNOWN - } + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) /** - * Returns an enum member corresponding to this class instance's value. + * Alias for [Builder.billedInAdvance]. * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. */ - fun known(): Known = - when (this) { - ANNUAL -> Known.ANNUAL - SEMI_ANNUAL -> Known.SEMI_ANNUAL - MONTHLY -> Known.MONTHLY - QUARTERLY -> Known.QUARTERLY - ONE_TIME -> Known.ONE_TIME - CUSTOM -> Known.CUSTOM - else -> throw OrbInvalidDataException("Unknown Cadence: $value") - } + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. */ - fun asString(): String = - _value().asString() - ?: throw OrbInvalidDataException("Value is not a String") + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } - private var validated: Boolean = false + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) - fun validate(): Cadence = apply { - if (validated) { - return@apply - } + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) - known() - validated = true + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) /** - * Returns a score indicating how many valid values are contained in this object - * recursively. + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. * - * Used for best match union deserialization. + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. */ - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Cadence && value == other.value - } - - override fun hashCode() = value.hashCode() + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } - override fun toString() = value.toString() - } + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) - /** Configuration for grouped_with_min_max_thresholds pricing */ - class GroupedWithMinMaxThresholdsConfig - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val groupingKey: JsonField, - private val maximumCharge: JsonField, - private val minimumCharge: JsonField, - private val perUnitRate: JsonField, - private val additionalProperties: MutableMap, - ) { + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) - @JsonCreator - private constructor( - @JsonProperty("grouping_key") - @ExcludeMissing - groupingKey: JsonField = JsonMissing.of(), - @JsonProperty("maximum_charge") - @ExcludeMissing - maximumCharge: JsonField = JsonMissing.of(), - @JsonProperty("minimum_charge") - @ExcludeMissing - minimumCharge: JsonField = JsonMissing.of(), - @JsonProperty("per_unit_rate") - @ExcludeMissing - perUnitRate: JsonField = JsonMissing.of(), - ) : this(groupingKey, maximumCharge, minimumCharge, perUnitRate, mutableMapOf()) + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) /** - * The event property used to group before applying thresholds - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` */ - fun groupingKey(): String = groupingKey.getRequired("grouping_key") + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) /** - * The maximum amount to charge each group - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. */ - fun maximumCharge(): String = maximumCharge.getRequired("maximum_charge") + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) /** - * The minimum amount to charge each group, regardless of usage + * Sets [Builder.currency] to an arbitrary JSON value. * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. */ - fun minimumCharge(): String = minimumCharge.getRequired("minimum_charge") + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) /** - * The base price charged per group + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. */ - fun perUnitRate(): String = perUnitRate.getRequired("per_unit_rate") + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) /** - * Returns the raw JSON value of [groupingKey]. + * Sets [Builder.externalPriceId] to an arbitrary JSON value. * - * Unlike [groupingKey], this method doesn't throw if the JSON field has an - * unexpected type. + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. */ - @JsonProperty("grouping_key") - @ExcludeMissing - fun _groupingKey(): JsonField = groupingKey + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } /** - * Returns the raw JSON value of [maximumCharge]. - * - * Unlike [maximumCharge], this method doesn't throw if the JSON field has an - * unexpected type. + * If the Price represents a fixed cost, this represents the quantity of units + * applied. */ - @JsonProperty("maximum_charge") - @ExcludeMissing - fun _maximumCharge(): JsonField = maximumCharge + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) /** - * Returns the raw JSON value of [minimumCharge]. + * Alias for [Builder.fixedPriceQuantity]. * - * Unlike [minimumCharge], this method doesn't throw if the JSON field has an - * unexpected type. + * This unboxed primitive overload exists for backwards compatibility. */ - @JsonProperty("minimum_charge") - @ExcludeMissing - fun _minimumCharge(): JsonField = minimumCharge + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) /** - * Returns the raw JSON value of [perUnitRate]. + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. * - * Unlike [perUnitRate], this method doesn't throw if the JSON field has an - * unexpected type. + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. */ - @JsonProperty("per_unit_rate") - @ExcludeMissing - fun _perUnitRate(): JsonField = perUnitRate - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) - /** - * Returns a mutable builder for constructing an instance of - * [GroupedWithMinMaxThresholdsConfig]. - * - * The following fields are required: - * ```kotlin - * .groupingKey() - * .maximumCharge() - * .minimumCharge() - * .perUnitRate() - * ``` - */ - fun builder() = Builder() + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey } - /** A builder for [GroupedWithMinMaxThresholdsConfig]. */ - class Builder internal constructor() { - - private var groupingKey: JsonField? = null - private var maximumCharge: JsonField? = null - private var minimumCharge: JsonField? = null - private var perUnitRate: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - internal fun from( - groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig - ) = apply { - groupingKey = groupedWithMinMaxThresholdsConfig.groupingKey - maximumCharge = groupedWithMinMaxThresholdsConfig.maximumCharge - minimumCharge = groupedWithMinMaxThresholdsConfig.minimumCharge - perUnitRate = groupedWithMinMaxThresholdsConfig.perUnitRate - additionalProperties = - groupedWithMinMaxThresholdsConfig.additionalProperties - .toMutableMap() - } - - /** The event property used to group before applying thresholds */ - fun groupingKey(groupingKey: String) = - groupingKey(JsonField.of(groupingKey)) - - /** - * Sets [Builder.groupingKey] to an arbitrary JSON value. - * - * You should usually call [Builder.groupingKey] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun groupingKey(groupingKey: JsonField) = apply { - this.groupingKey = groupingKey - } - - /** The maximum amount to charge each group */ - fun maximumCharge(maximumCharge: String) = - maximumCharge(JsonField.of(maximumCharge)) - - /** - * Sets [Builder.maximumCharge] to an arbitrary JSON value. - * - * You should usually call [Builder.maximumCharge] with a well-typed - * [String] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun maximumCharge(maximumCharge: JsonField) = apply { - this.maximumCharge = maximumCharge - } - - /** The minimum amount to charge each group, regardless of usage */ - fun minimumCharge(minimumCharge: String) = - minimumCharge(JsonField.of(minimumCharge)) - - /** - * Sets [Builder.minimumCharge] to an arbitrary JSON value. - * - * You should usually call [Builder.minimumCharge] with a well-typed - * [String] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun minimumCharge(minimumCharge: JsonField) = apply { - this.minimumCharge = minimumCharge - } - - /** The base price charged per group */ - fun perUnitRate(perUnitRate: String) = - perUnitRate(JsonField.of(perUnitRate)) - - /** - * Sets [Builder.perUnitRate] to an arbitrary JSON value. - * - * You should usually call [Builder.perUnitRate] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun perUnitRate(perUnitRate: JsonField) = apply { - this.perUnitRate = perUnitRate - } + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } - /** - * Returns an immutable instance of [GroupedWithMinMaxThresholdsConfig]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```kotlin - * .groupingKey() - * .maximumCharge() - * .minimumCharge() - * .perUnitRate() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): GroupedWithMinMaxThresholdsConfig = - GroupedWithMinMaxThresholdsConfig( - checkRequired("groupingKey", groupingKey), - checkRequired("maximumCharge", maximumCharge), - checkRequired("minimumCharge", minimumCharge), - checkRequired("perUnitRate", perUnitRate), - additionalProperties.toMutableMap(), - ) + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) } - private var validated: Boolean = false + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun validate(): GroupedWithMinMaxThresholdsConfig = apply { - if (validated) { - return@apply + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) } - groupingKey() - maximumCharge() - minimumCharge() - perUnitRate() - validated = true + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } /** - * Returns a score indicating how many valid values are contained in this object - * recursively. + * Returns an immutable instance of [TieredWithProration]. * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (if (groupingKey.asKnown() == null) 0 else 1) + - (if (maximumCharge.asKnown() == null) 0 else 1) + - (if (minimumCharge.asKnown() == null) 0 else 1) + - (if (perUnitRate.asKnown() == null) 0 else 1) + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .name() + * .tieredWithProrationConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TieredWithProration = + TieredWithProration( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + modelType, + checkRequired("name", name), + checkRequired("tieredWithProrationConfig", tieredWithProrationConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + private var validated: Boolean = false - return other is GroupedWithMinMaxThresholdsConfig && - groupingKey == other.groupingKey && - maximumCharge == other.maximumCharge && - minimumCharge == other.minimumCharge && - perUnitRate == other.perUnitRate && - additionalProperties == other.additionalProperties + fun validate(): TieredWithProration = apply { + if (validated) { + return@apply } - private val hashCode: Int by lazy { - Objects.hash( - groupingKey, - maximumCharge, - minimumCharge, - perUnitRate, - additionalProperties, - ) + cadence().validate() + itemId() + _modelType().let { + if (it != JsonValue.from("tiered_with_proration")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "GroupedWithMinMaxThresholdsConfig{groupingKey=$groupingKey, maximumCharge=$maximumCharge, minimumCharge=$minimumCharge, perUnitRate=$perUnitRate, additionalProperties=$additionalProperties}" + name() + tieredWithProrationConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + metadata()?.validate() + referenceId() + validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. */ - class Metadata - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + modelType.let { + if (it == JsonValue.from("tiered_with_proration")) 1 else 0 + } + + (if (name.asKnown() == null) 0 else 1) + + (tieredWithProrationConfig.asKnown()?.validity() ?: 0) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { - fun toBuilder() = Builder().from(this) + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { - /** Returns a mutable builder for constructing an instance of [Metadata]. */ - fun builder() = Builder() - } - - /** A builder for [Metadata]. */ - class Builder internal constructor() { + val ANNUAL = of("annual") - private var additionalProperties: MutableMap = - mutableMapOf() + val SEMI_ANNUAL = of("semi_annual") - internal fun from(metadata: Metadata) = apply { - additionalProperties = metadata.additionalProperties.toMutableMap() - } + val MONTHLY = of("monthly") - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + val QUARTERLY = of("quarterly") - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + val ONE_TIME = of("one_time") - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + val CUSTOM = of("custom") - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun of(value: String) = Cadence(JsonField.of(value)) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, /** - * Returns an immutable instance of [Metadata]. - * - * Further updates to this [Builder] will not mutate the returned instance. + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. */ - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true + _UNKNOWN, } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. * - * Used for best match union deserialization. + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. */ - internal fun validity(): Int = - additionalProperties.count { (_, value) -> - !value.isNull() && !value.isMissing() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN } - return other is Metadata && - additionalProperties == other.additionalProperties + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true } - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - override fun hashCode(): Int = hashCode + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + return other is Cadence && value == other.value } - return other is GroupedWithMinMaxThresholds && - cadence == other.cadence && - groupedWithMinMaxThresholdsConfig == - other.groupedWithMinMaxThresholdsConfig && - itemId == other.itemId && - modelType == other.modelType && - name == other.name && - billableMetricId == other.billableMetricId && - billedInAdvance == other.billedInAdvance && - billingCycleConfiguration == other.billingCycleConfiguration && - conversionRate == other.conversionRate && - conversionRateConfig == other.conversionRateConfig && - currency == other.currency && - dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && - externalPriceId == other.externalPriceId && - fixedPriceQuantity == other.fixedPriceQuantity && - invoiceGroupingKey == other.invoiceGroupingKey && - invoicingCycleConfiguration == other.invoicingCycleConfiguration && - metadata == other.metadata && - referenceId == other.referenceId && - additionalProperties == other.additionalProperties - } + override fun hashCode() = value.hashCode() - private val hashCode: Int by lazy { - Objects.hash( - cadence, - groupedWithMinMaxThresholdsConfig, - itemId, - modelType, - name, - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - conversionRateConfig, - currency, - dimensionalPriceConfiguration, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - additionalProperties, - ) + override fun toString() = value.toString() } - override fun hashCode(): Int = hashCode + /** Configuration for tiered_with_proration pricing */ + class TieredWithProrationConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val tiers: JsonField>, + private val additionalProperties: MutableMap, + ) { - override fun toString() = - "GroupedWithMinMaxThresholds{cadence=$cadence, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" - } + @JsonCreator + private constructor( + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of() + ) : this(tiers, mutableMapOf()) - class Percent - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val cadence: JsonField, - private val itemId: JsonField, - private val modelType: JsonValue, - private val name: JsonField, - private val percentConfig: JsonField, - private val billableMetricId: JsonField, - private val billedInAdvance: JsonField, - private val billingCycleConfiguration: JsonField, - private val conversionRate: JsonField, - private val conversionRateConfig: JsonField, - private val currency: JsonField, - private val dimensionalPriceConfiguration: - JsonField, - private val externalPriceId: JsonField, - private val fixedPriceQuantity: JsonField, - private val invoiceGroupingKey: JsonField, - private val invoicingCycleConfiguration: JsonField, - private val metadata: JsonField, - private val referenceId: JsonField, - private val additionalProperties: MutableMap, - ) { + /** + * Tiers for rating based on total usage quantities into the specified tier with + * proration + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun tiers(): List = tiers.getRequired("tiers") - @JsonCreator - private constructor( - @JsonProperty("cadence") - @ExcludeMissing - cadence: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - modelType: JsonValue = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - name: JsonField = JsonMissing.of(), - @JsonProperty("percent_config") - @ExcludeMissing - percentConfig: JsonField = JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("conversion_rate_config") - @ExcludeMissing - conversionRateConfig: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - currency: JsonField = JsonMissing.of(), - @JsonProperty("dimensional_price_configuration") - @ExcludeMissing - dimensionalPriceConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - metadata: JsonField = JsonMissing.of(), - @JsonProperty("reference_id") + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tiers") @ExcludeMissing - referenceId: JsonField = JsonMissing.of(), - ) : this( - cadence, - itemId, - modelType, - name, - percentConfig, - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - conversionRateConfig, - currency, - dimensionalPriceConfiguration, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - mutableMapOf(), - ) + fun _tiers(): JsonField> = tiers - /** - * The cadence to bill for this price on. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun cadence(): Cadence = cadence.getRequired("cadence") + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - /** - * The id of the item the price will be associated with. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun itemId(): String = itemId.getRequired("item_id") + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - /** - * The pricing model type - * - * Expected to always return the following: - * ```kotlin - * JsonValue.from("percent") - * ``` - * - * However, this method can be useful for debugging and logging (e.g. if the server - * responded with an unexpected value). - */ - @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + fun toBuilder() = Builder().from(this) - /** - * The name of the price. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun name(): String = name.getRequired("name") + companion object { - /** - * Configuration for percent pricing - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun percentConfig(): PercentConfig = percentConfig.getRequired("percent_config") + /** + * Returns a mutable builder for constructing an instance of + * [TieredWithProrationConfig]. + * + * The following fields are required: + * ```kotlin + * .tiers() + * ``` + */ + fun builder() = Builder() + } - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun billableMetricId(): String? = billableMetricId.getNullable("billable_metric_id") + /** A builder for [TieredWithProrationConfig]. */ + class Builder internal constructor() { - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + private var tiers: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun billingCycleConfiguration(): NewBillingCycleConfiguration? = - billingCycleConfiguration.getNullable("billing_cycle_configuration") + internal fun from(tieredWithProrationConfig: TieredWithProrationConfig) = + apply { + tiers = tieredWithProrationConfig.tiers.map { it.toMutableList() } + additionalProperties = + tieredWithProrationConfig.additionalProperties.toMutableMap() + } - /** - * The per unit conversion rate of the price currency to the invoicing currency. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + /** + * Tiers for rating based on total usage quantities into the specified tier + * with proration + */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) - /** - * The configuration for the rate of the price currency to the invoicing currency. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun conversionRateConfig(): ConversionRateConfig? = - conversionRateConfig.getNullable("conversion_rate_config") + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun currency(): String? = currency.getNullable("currency") + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } - /** - * For dimensional price: specifies a price group and dimension values - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = - dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** - * An alias for the price. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun fixedPriceQuantity(): Double? = - fixedPriceQuantity.getNullable("fixed_price_quantity") + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - /** - * The property used to group this price on an invoice - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun invoiceGroupingKey(): String? = - invoiceGroupingKey.getNullable("invoice_grouping_key") + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun metadata(): Metadata? = metadata.getNullable("metadata") + /** + * Returns an immutable instance of [TieredWithProrationConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TieredWithProrationConfig = + TieredWithProrationConfig( + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun referenceId(): String? = referenceId.getNullable("reference_id") + private var validated: Boolean = false - /** - * Returns the raw JSON value of [cadence]. - * - * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("cadence") - @ExcludeMissing - fun _cadence(): JsonField = cadence + fun validate(): TieredWithProrationConfig = apply { + if (validated) { + return@apply + } - /** - * Returns the raw JSON value of [itemId]. - * - * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + tiers().forEach { it.validate() } + validated = true + } - /** - * Returns the raw JSON value of [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - /** - * Returns the raw JSON value of [percentConfig]. - * - * Unlike [percentConfig], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("percent_config") - @ExcludeMissing - fun _percentConfig(): JsonField = percentConfig + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (tiers.asKnown()?.sumOf { it.validity().toInt() } ?: 0) - /** - * Returns the raw JSON value of [billableMetricId]. - * - * Unlike [billableMetricId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = billableMetricId + /** Configuration for a single tiered with proration tier */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val tierLowerBound: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { - /** - * Returns the raw JSON value of [billedInAdvance]. - * - * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance + @JsonCreator + private constructor( + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(tierLowerBound, unitAmount, mutableMapOf()) - /** - * Returns the raw JSON value of [billingCycleConfiguration]. - * - * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration + /** + * Inclusive tier starting value + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun tierLowerBound(): String = + tierLowerBound.getRequired("tier_lower_bound") - /** - * Returns the raw JSON value of [conversionRate]. - * - * Unlike [conversionRate], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate + /** + * Amount per unit + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") - /** - * Returns the raw JSON value of [conversionRateConfig]. - * - * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("conversion_rate_config") - @ExcludeMissing - fun _conversionRateConfig(): JsonField = conversionRateConfig + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound - /** - * Returns the raw JSON value of [currency]. - * - * Unlike [currency], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("currency") - @ExcludeMissing - fun _currency(): JsonField = currency + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount - /** - * Returns the raw JSON value of [dimensionalPriceConfiguration]. - * - * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON - * field has an unexpected type. - */ - @JsonProperty("dimensional_price_configuration") - @ExcludeMissing - fun _dimensionalPriceConfiguration(): JsonField = - dimensionalPriceConfiguration + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - /** - * Returns the raw JSON value of [externalPriceId]. - * - * Unlike [externalPriceId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - /** - * Returns the raw JSON value of [fixedPriceQuantity]. - * - * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + fun toBuilder() = Builder().from(this) - /** - * Returns the raw JSON value of [invoiceGroupingKey]. - * - * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + companion object { - /** - * Returns the raw JSON value of [invoicingCycleConfiguration]. - * - * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration + /** + * Returns a mutable builder for constructing an instance of [Tier]. + * + * The following fields are required: + * ```kotlin + * .tierLowerBound() + * .unitAmount() + * ``` + */ + fun builder() = Builder() + } - /** - * Returns the raw JSON value of [metadata]. - * - * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata + /** A builder for [Tier]. */ + class Builder internal constructor() { - /** - * Returns the raw JSON value of [referenceId]. - * - * Unlike [referenceId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("reference_id") - @ExcludeMissing - fun _referenceId(): JsonField = referenceId + private var tierLowerBound: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + internal fun from(tier: Tier) = apply { + tierLowerBound = tier.tierLowerBound + unitAmount = tier.unitAmount + additionalProperties = tier.additionalProperties.toMutableMap() + } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** Inclusive tier starting value */ + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) - fun toBuilder() = Builder().from(this) + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } - companion object { + /** Amount per unit */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) - /** - * Returns a mutable builder for constructing an instance of [Percent]. - * - * The following fields are required: - * ```kotlin - * .cadence() - * .itemId() - * .name() - * .percentConfig() - * ``` - */ - fun builder() = Builder() - } + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } - /** A builder for [Percent]. */ - class Builder internal constructor() { + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - private var cadence: JsonField? = null - private var itemId: JsonField? = null - private var modelType: JsonValue = JsonValue.from("percent") - private var name: JsonField? = null - private var percentConfig: JsonField? = null - private var billableMetricId: JsonField = JsonMissing.of() - private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var conversionRateConfig: JsonField = - JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var dimensionalPriceConfiguration: - JsonField = - JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: - JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var referenceId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - internal fun from(percent: Percent) = apply { - cadence = percent.cadence - itemId = percent.itemId - modelType = percent.modelType - name = percent.name - percentConfig = percent.percentConfig - billableMetricId = percent.billableMetricId - billedInAdvance = percent.billedInAdvance - billingCycleConfiguration = percent.billingCycleConfiguration - conversionRate = percent.conversionRate - conversionRateConfig = percent.conversionRateConfig - currency = percent.currency - dimensionalPriceConfiguration = percent.dimensionalPriceConfiguration - externalPriceId = percent.externalPriceId - fixedPriceQuantity = percent.fixedPriceQuantity - invoiceGroupingKey = percent.invoiceGroupingKey - invoicingCycleConfiguration = percent.invoicingCycleConfiguration - metadata = percent.metadata - referenceId = percent.referenceId - additionalProperties = percent.additionalProperties.toMutableMap() - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - /** - * Sets [Builder.cadence] to an arbitrary JSON value. - * - * You should usually call [Builder.cadence] with a well-typed [Cadence] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - /** The id of the item the price will be associated with. */ - fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + /** + * Returns an immutable instance of [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```kotlin + * .tierLowerBound() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("tierLowerBound", tierLowerBound), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } - /** - * Sets [Builder.itemId] to an arbitrary JSON value. - * - * You should usually call [Builder.itemId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + private var validated: Boolean = false - /** - * Sets the field to an arbitrary JSON value. - * - * It is usually unnecessary to call this method because the field defaults to - * the following: - * ```kotlin - * JsonValue.from("percent") - * ``` - * - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + fun validate(): Tier = apply { + if (validated) { + return@apply + } - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) + tierLowerBound() + unitAmount() + validated = true + } - /** - * Sets [Builder.name] to an arbitrary JSON value. - * - * You should usually call [Builder.name] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun name(name: JsonField) = apply { this.name = name } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - /** Configuration for percent pricing */ - fun percentConfig(percentConfig: PercentConfig) = - percentConfig(JsonField.of(percentConfig)) + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (tierLowerBound.asKnown() == null) 0 else 1) + + (if (unitAmount.asKnown() == null) 0 else 1) - /** - * Sets [Builder.percentConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.percentConfig] with a well-typed - * [PercentConfig] value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. - */ - fun percentConfig(percentConfig: JsonField) = apply { - this.percentConfig = percentConfig + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + tierLowerBound == other.tierLowerBound && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(tierLowerBound, unitAmount, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" } - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: String?) = - billableMetricId(JsonField.ofNullable(billableMetricId)) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * Sets [Builder.billableMetricId] to an arbitrary JSON value. - * - * You should usually call [Builder.billableMetricId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun billableMetricId(billableMetricId: JsonField) = apply { - this.billableMetricId = billableMetricId + return other is TieredWithProrationConfig && + tiers == other.tiers && + additionalProperties == other.additionalProperties } - /** - * If the Price represents a fixed cost, the price will be billed in-advance if - * this is true, and in-arrears if this is false. - */ - fun billedInAdvance(billedInAdvance: Boolean?) = - billedInAdvance(JsonField.ofNullable(billedInAdvance)) + private val hashCode: Int by lazy { Objects.hash(tiers, additionalProperties) } - /** - * Alias for [Builder.billedInAdvance]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun billedInAdvance(billedInAdvance: Boolean) = - billedInAdvance(billedInAdvance as Boolean?) + override fun hashCode(): Int = hashCode - /** - * Sets [Builder.billedInAdvance] to an arbitrary JSON value. - * - * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun billedInAdvance(billedInAdvance: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } + override fun toString() = + "TieredWithProrationConfig{tiers=$tiers, additionalProperties=$additionalProperties}" + } - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: NewBillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { - /** - * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.billingCycleConfiguration] with a well-typed - * [NewBillingCycleConfiguration] value instead. This method is primarily for - * setting the field to an undocumented or not yet supported value. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: JsonField - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: Double?) = - conversionRate(JsonField.ofNullable(conversionRate)) + fun toBuilder() = Builder().from(this) - /** - * Alias for [Builder.conversionRate]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) + companion object { - /** - * Sets [Builder.conversionRate] to an arbitrary JSON value. - * - * You should usually call [Builder.conversionRate] with a well-typed [Double] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() } - /** - * The configuration for the rate of the price currency to the invoicing - * currency. - */ - fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = - conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + /** A builder for [Metadata]. */ + class Builder internal constructor() { - /** - * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.conversionRateConfig] with a well-typed - * [ConversionRateConfig] value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun conversionRateConfig( - conversionRateConfig: JsonField - ) = apply { this.conversionRateConfig = conversionRateConfig } + private var additionalProperties: MutableMap = + mutableMapOf() - /** - * Alias for calling [conversionRateConfig] with - * `ConversionRateConfig.ofUnit(unit)`. - */ - fun conversionRateConfig(unit: UnitConversionRateConfig) = - conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } - /** - * Alias for calling [conversionRateConfig] with the following: - * ```kotlin - * UnitConversionRateConfig.builder() - * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) - * .unitConfig(unitConfig) - * .build() - * ``` - */ - fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = - conversionRateConfig( - UnitConversionRateConfig.builder() - .conversionRateType( - UnitConversionRateConfig.ConversionRateType.UNIT - ) - .unitConfig(unitConfig) - .build() - ) + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** - * Alias for calling [conversionRateConfig] with - * `ConversionRateConfig.ofTiered(tiered)`. - */ - fun conversionRateConfig(tiered: TieredConversionRateConfig) = - conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * Alias for calling [conversionRateConfig] with the following: - * ```kotlin - * TieredConversionRateConfig.builder() - * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) - * .tieredConfig(tieredConfig) - * .build() - * ``` - */ - fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = - conversionRateConfig( - TieredConversionRateConfig.builder() - .conversionRateType( - TieredConversionRateConfig.ConversionRateType.TIERED - ) - .tieredConfig(tieredConfig) - .build() - ) + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - /** - * Sets [Builder.currency] to an arbitrary JSON value. - * - * You should usually call [Builder.currency] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - /** For dimensional price: specifies a price group and dimension values */ - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? - ) = - dimensionalPriceConfiguration( - JsonField.ofNullable(dimensionalPriceConfiguration) - ) + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } - /** - * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.dimensionalPriceConfiguration] with a - * well-typed [NewDimensionalPriceConfiguration] value instead. This method is - * primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: JsonField - ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + private var validated: Boolean = false - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) + fun validate(): Metadata = apply { + if (validated) { + return@apply + } - /** - * Sets [Builder.externalPriceId] to an arbitrary JSON value. - * - * You should usually call [Builder.externalPriceId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun externalPriceId(externalPriceId: JsonField) = apply { - this.externalPriceId = externalPriceId + validated = true } - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = - fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } /** - * Alias for [Builder.fixedPriceQuantity]. + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * This unboxed primitive overload exists for backwards compatibility. + * Used for best match union deserialization. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } - /** - * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. - * - * You should usually call [Builder.fixedPriceQuantity] with a well-typed - * [Double] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { - this.fixedPriceQuantity = fixedPriceQuantity + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties } - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = - invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) - - /** - * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. - * - * You should usually call [Builder.invoiceGroupingKey] with a well-typed - * [String] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { - this.invoiceGroupingKey = invoiceGroupingKey - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are - * produced. If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: NewBillingCycleConfiguration? - ) = - invoicingCycleConfiguration( - JsonField.ofNullable(invoicingCycleConfiguration) - ) - - /** - * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.invoicingCycleConfiguration] with a - * well-typed [NewBillingCycleConfiguration] value instead. This method is - * primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * Sets [Builder.metadata] to an arbitrary JSON value. - * - * You should usually call [Builder.metadata] with a well-typed [Metadata] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - fun referenceId(referenceId: String?) = - referenceId(JsonField.ofNullable(referenceId)) - - /** - * Sets [Builder.referenceId] to an arbitrary JSON value. - * - * You should usually call [Builder.referenceId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun referenceId(referenceId: JsonField) = apply { - this.referenceId = referenceId - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + override fun hashCode(): Int = hashCode - /** - * Returns an immutable instance of [Percent]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```kotlin - * .cadence() - * .itemId() - * .name() - * .percentConfig() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Percent = - Percent( - checkRequired("cadence", cadence), - checkRequired("itemId", itemId), - modelType, - checkRequired("name", name), - checkRequired("percentConfig", percentConfig), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - conversionRateConfig, - currency, - dimensionalPriceConfiguration, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - additionalProperties.toMutableMap(), - ) + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" } - private var validated: Boolean = false - - fun validate(): Percent = apply { - if (validated) { - return@apply + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - cadence().validate() - itemId() - _modelType().let { - if (it != JsonValue.from("percent")) { - throw OrbInvalidDataException("'modelType' is invalid, received $it") - } - } - name() - percentConfig().validate() - billableMetricId() - billedInAdvance() - billingCycleConfiguration()?.validate() - conversionRate() - conversionRateConfig()?.validate() - currency() - dimensionalPriceConfiguration()?.validate() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration()?.validate() - metadata()?.validate() - referenceId() - validated = true + return other is TieredWithProration && + cadence == other.cadence && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + tieredWithProrationConfig == other.tieredWithProrationConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + modelType, + name, + tieredWithProrationConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties, + ) + } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (cadence.asKnown()?.validity() ?: 0) + - (if (itemId.asKnown() == null) 0 else 1) + - modelType.let { if (it == JsonValue.from("percent")) 1 else 0 } + - (if (name.asKnown() == null) 0 else 1) + - (percentConfig.asKnown()?.validity() ?: 0) + - (if (billableMetricId.asKnown() == null) 0 else 1) + - (if (billedInAdvance.asKnown() == null) 0 else 1) + - (billingCycleConfiguration.asKnown()?.validity() ?: 0) + - (if (conversionRate.asKnown() == null) 0 else 1) + - (conversionRateConfig.asKnown()?.validity() ?: 0) + - (if (currency.asKnown() == null) 0 else 1) + - (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + - (if (externalPriceId.asKnown() == null) 0 else 1) + - (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + - (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + - (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + - (metadata.asKnown()?.validity() ?: 0) + - (if (referenceId.asKnown() == null) 0 else 1) + override fun hashCode(): Int = hashCode - /** The cadence to bill for this price on. */ - class Cadence - @JsonCreator - private constructor(private val value: JsonField) : Enum { + override fun toString() = + "TieredWithProration{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredWithProrationConfig=$tieredWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value + class GroupedWithMinMaxThresholds + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val groupedWithMinMaxThresholdsConfig: + JsonField, + private val itemId: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { - companion object { + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("grouped_with_min_max_thresholds_config") + @ExcludeMissing + groupedWithMinMaxThresholdsConfig: + JsonField = + JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + groupedWithMinMaxThresholdsConfig, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + mutableMapOf(), + ) - val ANNUAL = of("annual") + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") - val SEMI_ANNUAL = of("semi_annual") + /** + * Configuration for grouped_with_min_max_thresholds pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupedWithMinMaxThresholdsConfig(): GroupedWithMinMaxThresholdsConfig = + groupedWithMinMaxThresholdsConfig.getRequired( + "grouped_with_min_max_thresholds_config" + ) - val MONTHLY = of("monthly") + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") - val QUARTERLY = of("quarterly") + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("grouped_with_min_max_thresholds") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType - val ONE_TIME = of("one_time") + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") - val CUSTOM = of("custom") + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = billableMetricId.getNullable("billable_metric_id") - fun of(value: String) = Cadence(JsonField.of(value)) - } + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") - /** An enum containing [Cadence]'s known values. */ - enum class Known { - ANNUAL, - SEMI_ANNUAL, - MONTHLY, - QUARTERLY, - ONE_TIME, - CUSTOM, - } + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") - /** - * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Cadence] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - ANNUAL, - SEMI_ANNUAL, - MONTHLY, - QUARTERLY, - ONE_TIME, - CUSTOM, - /** - * An enum member indicating that [Cadence] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - ANNUAL -> Value.ANNUAL - SEMI_ANNUAL -> Value.SEMI_ANNUAL - MONTHLY -> Value.MONTHLY - QUARTERLY -> Value.QUARTERLY - ONE_TIME -> Value.ONE_TIME - CUSTOM -> Value.CUSTOM - else -> Value._UNKNOWN - } + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - ANNUAL -> Known.ANNUAL - SEMI_ANNUAL -> Known.SEMI_ANNUAL - MONTHLY -> Known.MONTHLY - QUARTERLY -> Known.QUARTERLY - ONE_TIME -> Known.ONE_TIME - CUSTOM -> Known.CUSTOM - else -> throw OrbInvalidDataException("Unknown Cadence: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString() - ?: throw OrbInvalidDataException("Value is not a String") + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") - private var validated: Boolean = false + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") - fun validate(): Cadence = apply { - if (validated) { - return@apply - } + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") - known() - validated = true - } + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + invoiceGroupingKey.getNullable("invoice_grouping_key") - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") - return other is Cadence && value == other.value - } + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") - override fun hashCode() = value.hashCode() + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence - override fun toString() = value.toString() - } + /** + * Returns the raw JSON value of [groupedWithMinMaxThresholdsConfig]. + * + * Unlike [groupedWithMinMaxThresholdsConfig], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("grouped_with_min_max_thresholds_config") + @ExcludeMissing + fun _groupedWithMinMaxThresholdsConfig(): + JsonField = groupedWithMinMaxThresholdsConfig - /** Configuration for percent pricing */ - class PercentConfig - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val percent: JsonField, - private val additionalProperties: MutableMap, - ) { + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - @JsonCreator - private constructor( - @JsonProperty("percent") - @ExcludeMissing - percent: JsonField = JsonMissing.of() - ) : this(percent, mutableMapOf()) + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - /** - * What percent of the component subtotals to charge - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun percent(): Double = percent.getRequired("percent") + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId - /** - * Returns the raw JSON value of [percent]. - * - * Unlike [percent], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("percent") - @ExcludeMissing - fun _percent(): JsonField = percent + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate - fun toBuilder() = Builder().from(this) + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig - companion object { + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency - /** - * Returns a mutable builder for constructing an instance of - * [PercentConfig]. - * - * The following fields are required: - * ```kotlin - * .percent() - * ``` - */ - fun builder() = Builder() - } - - /** A builder for [PercentConfig]. */ - class Builder internal constructor() { + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration - private var percent: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId - internal fun from(percentConfig: PercentConfig) = apply { - percent = percentConfig.percent - additionalProperties = percentConfig.additionalProperties.toMutableMap() - } + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - /** What percent of the component subtotals to charge */ - fun percent(percent: Double) = percent(JsonField.of(percent)) + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - /** - * Sets [Builder.percent] to an arbitrary JSON value. - * - * You should usually call [Builder.percent] with a well-typed [Double] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun percent(percent: JsonField) = apply { this.percent = percent } + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun toBuilder() = Builder().from(this) - /** - * Returns an immutable instance of [PercentConfig]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```kotlin - * .percent() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): PercentConfig = - PercentConfig( - checkRequired("percent", percent), - additionalProperties.toMutableMap(), - ) - } + companion object { - private var validated: Boolean = false + /** + * Returns a mutable builder for constructing an instance of + * [GroupedWithMinMaxThresholds]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .groupedWithMinMaxThresholdsConfig() + * .itemId() + * .name() + * ``` + */ + fun builder() = Builder() + } - fun validate(): PercentConfig = apply { - if (validated) { - return@apply - } + /** A builder for [GroupedWithMinMaxThresholds]. */ + class Builder internal constructor() { - percent() - validated = true - } + private var cadence: JsonField? = null + private var groupedWithMinMaxThresholdsConfig: + JsonField? = + null + private var itemId: JsonField? = null + private var modelType: JsonValue = + JsonValue.from("grouped_with_min_max_thresholds") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false + internal fun from(groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds) = + apply { + cadence = groupedWithMinMaxThresholds.cadence + groupedWithMinMaxThresholdsConfig = + groupedWithMinMaxThresholds.groupedWithMinMaxThresholdsConfig + itemId = groupedWithMinMaxThresholds.itemId + modelType = groupedWithMinMaxThresholds.modelType + name = groupedWithMinMaxThresholds.name + billableMetricId = groupedWithMinMaxThresholds.billableMetricId + billedInAdvance = groupedWithMinMaxThresholds.billedInAdvance + billingCycleConfiguration = + groupedWithMinMaxThresholds.billingCycleConfiguration + conversionRate = groupedWithMinMaxThresholds.conversionRate + conversionRateConfig = groupedWithMinMaxThresholds.conversionRateConfig + currency = groupedWithMinMaxThresholds.currency + dimensionalPriceConfiguration = + groupedWithMinMaxThresholds.dimensionalPriceConfiguration + externalPriceId = groupedWithMinMaxThresholds.externalPriceId + fixedPriceQuantity = groupedWithMinMaxThresholds.fixedPriceQuantity + invoiceGroupingKey = groupedWithMinMaxThresholds.invoiceGroupingKey + invoicingCycleConfiguration = + groupedWithMinMaxThresholds.invoicingCycleConfiguration + metadata = groupedWithMinMaxThresholds.metadata + referenceId = groupedWithMinMaxThresholds.referenceId + additionalProperties = + groupedWithMinMaxThresholds.additionalProperties.toMutableMap() } + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + /** - * Returns a score indicating how many valid values are contained in this object - * recursively. + * Sets [Builder.cadence] to an arbitrary JSON value. * - * Used for best match union deserialization. + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. */ - internal fun validity(): Int = (if (percent.asKnown() == null) 0 else 1) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is PercentConfig && - percent == other.percent && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(percent, additionalProperties) - } + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - override fun hashCode(): Int = hashCode + /** Configuration for grouped_with_min_max_thresholds pricing */ + fun groupedWithMinMaxThresholdsConfig( + groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + ) = + groupedWithMinMaxThresholdsConfig( + JsonField.of(groupedWithMinMaxThresholdsConfig) + ) - override fun toString() = - "PercentConfig{percent=$percent, additionalProperties=$additionalProperties}" - } - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - class Metadata - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Metadata]. */ - fun builder() = Builder() + /** + * Sets [Builder.groupedWithMinMaxThresholdsConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.groupedWithMinMaxThresholdsConfig] with a + * well-typed [GroupedWithMinMaxThresholdsConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun groupedWithMinMaxThresholdsConfig( + groupedWithMinMaxThresholdsConfig: + JsonField + ) = apply { + this.groupedWithMinMaxThresholdsConfig = groupedWithMinMaxThresholdsConfig } - /** A builder for [Metadata]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = - mutableMapOf() - - internal fun from(metadata: Metadata) = apply { - additionalProperties = metadata.additionalProperties.toMutableMap() - } + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("grouped_with_min_max_thresholds") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) - /** - * Returns an immutable instance of [Metadata]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId } - private var validated: Boolean = false + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) - fun validate(): Metadata = apply { - if (validated) { - return@apply - } + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) - validated = true + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) /** - * Returns a score indicating how many valid values are contained in this object - * recursively. + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. * - * Used for best match union deserialization. + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. */ - internal fun validity(): Int = - additionalProperties.count { (_, value) -> - !value.isNull() && !value.isMissing() - } + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) - return other is Metadata && - additionalProperties == other.additionalProperties + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate } - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) - override fun hashCode(): Int = hashCode + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) - return other is Percent && - cadence == other.cadence && - itemId == other.itemId && - modelType == other.modelType && - name == other.name && - percentConfig == other.percentConfig && - billableMetricId == other.billableMetricId && - billedInAdvance == other.billedInAdvance && - billingCycleConfiguration == other.billingCycleConfiguration && - conversionRate == other.conversionRate && - conversionRateConfig == other.conversionRateConfig && - currency == other.currency && - dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && - externalPriceId == other.externalPriceId && - fixedPriceQuantity == other.fixedPriceQuantity && - invoiceGroupingKey == other.invoiceGroupingKey && - invoicingCycleConfiguration == other.invoicingCycleConfiguration && - metadata == other.metadata && - referenceId == other.referenceId && - additionalProperties == other.additionalProperties - } + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) - private val hashCode: Int by lazy { - Objects.hash( - cadence, - itemId, - modelType, - name, - percentConfig, - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - conversionRateConfig, - currency, - dimensionalPriceConfiguration, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - additionalProperties, - ) - } + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) - override fun hashCode(): Int = hashCode + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) - override fun toString() = - "Percent{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, percentConfig=$percentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" - } + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } - class EventOutput - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val cadence: JsonField, - private val eventOutputConfig: JsonField, - private val itemId: JsonField, - private val modelType: JsonValue, - private val name: JsonField, - private val billableMetricId: JsonField, - private val billedInAdvance: JsonField, - private val billingCycleConfiguration: JsonField, - private val conversionRate: JsonField, - private val conversionRateConfig: JsonField, - private val currency: JsonField, - private val dimensionalPriceConfiguration: - JsonField, - private val externalPriceId: JsonField, - private val fixedPriceQuantity: JsonField, - private val invoiceGroupingKey: JsonField, - private val invoicingCycleConfiguration: JsonField, - private val metadata: JsonField, - private val referenceId: JsonField, - private val additionalProperties: MutableMap, - ) { + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) - @JsonCreator - private constructor( - @JsonProperty("cadence") - @ExcludeMissing - cadence: JsonField = JsonMissing.of(), - @JsonProperty("event_output_config") - @ExcludeMissing - eventOutputConfig: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - modelType: JsonValue = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - name: JsonField = JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("conversion_rate_config") - @ExcludeMissing - conversionRateConfig: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - currency: JsonField = JsonMissing.of(), - @JsonProperty("dimensional_price_configuration") - @ExcludeMissing - dimensionalPriceConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - metadata: JsonField = JsonMissing.of(), - @JsonProperty("reference_id") - @ExcludeMissing - referenceId: JsonField = JsonMissing.of(), - ) : this( - cadence, - eventOutputConfig, - itemId, - modelType, - name, - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - conversionRateConfig, - currency, - dimensionalPriceConfiguration, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - mutableMapOf(), - ) + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } - /** - * The cadence to bill for this price on. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun cadence(): Cadence = cadence.getRequired("cadence") + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) - /** - * Configuration for event_output pricing - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun eventOutputConfig(): EventOutputConfig = - eventOutputConfig.getRequired("event_output_config") + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } - /** - * The id of the item the price will be associated with. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun itemId(): String = itemId.getRequired("item_id") + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) - /** - * The pricing model type - * - * Expected to always return the following: - * ```kotlin - * JsonValue.from("event_output") - * ``` - * - * However, this method can be useful for debugging and logging (e.g. if the server - * responded with an unexpected value). - */ - @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType - - /** - * The name of the price. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun name(): String = name.getRequired("name") - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun billableMetricId(): String? = billableMetricId.getNullable("billable_metric_id") - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun billingCycleConfiguration(): NewBillingCycleConfiguration? = - billingCycleConfiguration.getNullable("billing_cycle_configuration") + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) - /** - * The per unit conversion rate of the price currency to the invoicing currency. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } - /** - * The configuration for the rate of the price currency to the invoicing currency. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun conversionRateConfig(): ConversionRateConfig? = - conversionRateConfig.getNullable("conversion_rate_config") + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun currency(): String? = currency.getNullable("currency") + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } - /** - * For dimensional price: specifies a price group and dimension values - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = - dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) - /** - * An alias for the price. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun fixedPriceQuantity(): Double? = - fixedPriceQuantity.getNullable("fixed_price_quantity") + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - /** - * The property used to group this price on an invoice - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun invoiceGroupingKey(): String? = - invoiceGroupingKey.getNullable("invoice_grouping_key") + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun metadata(): Metadata? = metadata.getNullable("metadata") + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun referenceId(): String? = referenceId.getNullable("reference_id") + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** - * Returns the raw JSON value of [cadence]. - * - * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("cadence") - @ExcludeMissing - fun _cadence(): JsonField = cadence + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * Returns the raw JSON value of [eventOutputConfig]. - * - * Unlike [eventOutputConfig], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("event_output_config") - @ExcludeMissing - fun _eventOutputConfig(): JsonField = eventOutputConfig + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - /** - * Returns the raw JSON value of [itemId]. - * - * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - /** - * Returns the raw JSON value of [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - /** - * Returns the raw JSON value of [billableMetricId]. - * - * Unlike [billableMetricId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = billableMetricId + /** + * Returns an immutable instance of [GroupedWithMinMaxThresholds]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .groupedWithMinMaxThresholdsConfig() + * .itemId() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedWithMinMaxThresholds = + GroupedWithMinMaxThresholds( + checkRequired("cadence", cadence), + checkRequired( + "groupedWithMinMaxThresholdsConfig", + groupedWithMinMaxThresholdsConfig, + ), + checkRequired("itemId", itemId), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } - /** - * Returns the raw JSON value of [billedInAdvance]. - * - * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance + private var validated: Boolean = false - /** - * Returns the raw JSON value of [billingCycleConfiguration]. - * - * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration + fun validate(): GroupedWithMinMaxThresholds = apply { + if (validated) { + return@apply + } - /** - * Returns the raw JSON value of [conversionRate]. - * - * Unlike [conversionRate], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate + cadence().validate() + groupedWithMinMaxThresholdsConfig().validate() + itemId() + _modelType().let { + if (it != JsonValue.from("grouped_with_min_max_thresholds")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + metadata()?.validate() + referenceId() + validated = true + } - /** - * Returns the raw JSON value of [conversionRateConfig]. - * - * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("conversion_rate_config") - @ExcludeMissing - fun _conversionRateConfig(): JsonField = conversionRateConfig + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } /** - * Returns the raw JSON value of [currency]. + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * Unlike [currency], this method doesn't throw if the JSON field has an unexpected - * type. + * Used for best match union deserialization. */ - @JsonProperty("currency") - @ExcludeMissing - fun _currency(): JsonField = currency + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (groupedWithMinMaxThresholdsConfig.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + modelType.let { + if (it == JsonValue.from("grouped_with_min_max_thresholds")) 1 else 0 + } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) - /** - * Returns the raw JSON value of [dimensionalPriceConfiguration]. - * - * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON - * field has an unexpected type. - */ - @JsonProperty("dimensional_price_configuration") - @ExcludeMissing - fun _dimensionalPriceConfiguration(): JsonField = - dimensionalPriceConfiguration + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { - /** - * Returns the raw JSON value of [externalPriceId]. - * - * Unlike [externalPriceId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value - /** - * Returns the raw JSON value of [fixedPriceQuantity]. - * - * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + companion object { - /** - * Returns the raw JSON value of [invoiceGroupingKey]. - * - * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + val ANNUAL = of("annual") - /** - * Returns the raw JSON value of [invoicingCycleConfiguration]. - * - * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration + val SEMI_ANNUAL = of("semi_annual") - /** - * Returns the raw JSON value of [metadata]. - * - * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata + val MONTHLY = of("monthly") - /** - * Returns the raw JSON value of [referenceId]. - * - * Unlike [referenceId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("reference_id") - @ExcludeMissing - fun _referenceId(): JsonField = referenceId + val QUARTERLY = of("quarterly") - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + val ONE_TIME = of("one_time") - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + val CUSTOM = of("custom") - fun toBuilder() = Builder().from(this) + fun of(value: String) = Cadence(JsonField.of(value)) + } - companion object { + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } /** - * Returns a mutable builder for constructing an instance of [EventOutput]. + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. * - * The following fields are required: - * ```kotlin - * .cadence() - * .eventOutputConfig() - * .itemId() - * .name() - * ``` + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. */ - fun builder() = Builder() - } - - /** A builder for [EventOutput]. */ - class Builder internal constructor() { - - private var cadence: JsonField? = null - private var eventOutputConfig: JsonField? = null - private var itemId: JsonField? = null - private var modelType: JsonValue = JsonValue.from("event_output") - private var name: JsonField? = null - private var billableMetricId: JsonField = JsonMissing.of() - private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var conversionRateConfig: JsonField = - JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var dimensionalPriceConfiguration: - JsonField = - JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: - JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var referenceId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(eventOutput: EventOutput) = apply { - cadence = eventOutput.cadence - eventOutputConfig = eventOutput.eventOutputConfig - itemId = eventOutput.itemId - modelType = eventOutput.modelType - name = eventOutput.name - billableMetricId = eventOutput.billableMetricId - billedInAdvance = eventOutput.billedInAdvance - billingCycleConfiguration = eventOutput.billingCycleConfiguration - conversionRate = eventOutput.conversionRate - conversionRateConfig = eventOutput.conversionRateConfig - currency = eventOutput.currency - dimensionalPriceConfiguration = eventOutput.dimensionalPriceConfiguration - externalPriceId = eventOutput.externalPriceId - fixedPriceQuantity = eventOutput.fixedPriceQuantity - invoiceGroupingKey = eventOutput.invoiceGroupingKey - invoicingCycleConfiguration = eventOutput.invoicingCycleConfiguration - metadata = eventOutput.metadata - referenceId = eventOutput.referenceId - additionalProperties = eventOutput.additionalProperties.toMutableMap() + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, } - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - /** - * Sets [Builder.cadence] to an arbitrary JSON value. + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. * - * You should usually call [Builder.cadence] with a well-typed [Cadence] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. */ - fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - - /** Configuration for event_output pricing */ - fun eventOutputConfig(eventOutputConfig: EventOutputConfig) = - eventOutputConfig(JsonField.of(eventOutputConfig)) + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } /** - * Sets [Builder.eventOutputConfig] to an arbitrary JSON value. + * Returns an enum member corresponding to this class instance's value. * - * You should usually call [Builder.eventOutputConfig] with a well-typed - * [EventOutputConfig] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun eventOutputConfig(eventOutputConfig: JsonField) = apply { - this.eventOutputConfig = eventOutputConfig - } - - /** The id of the item the price will be associated with. */ - fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - - /** - * Sets [Builder.itemId] to an arbitrary JSON value. + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. * - * You should usually call [Builder.itemId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } /** - * Sets the field to an arbitrary JSON value. + * Returns this class instance's primitive wire representation. * - * It is usually unnecessary to call this method because the field defaults to - * the following: - * ```kotlin - * JsonValue.from("event_output") - * ``` + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. * - * This method is primarily for setting the field to an undocumented or not yet - * supported value. + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. */ - fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } /** - * Sets [Builder.name] to an arbitrary JSON value. + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * You should usually call [Builder.name] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. + * Used for best match union deserialization. */ - fun name(name: JsonField) = apply { this.name = name } + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: String?) = - billableMetricId(JsonField.ofNullable(billableMetricId)) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Configuration for grouped_with_min_max_thresholds pricing */ + class GroupedWithMinMaxThresholdsConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val groupingKey: JsonField, + private val maximumCharge: JsonField, + private val minimumCharge: JsonField, + private val perUnitRate: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("maximum_charge") + @ExcludeMissing + maximumCharge: JsonField = JsonMissing.of(), + @JsonProperty("minimum_charge") + @ExcludeMissing + minimumCharge: JsonField = JsonMissing.of(), + @JsonProperty("per_unit_rate") + @ExcludeMissing + perUnitRate: JsonField = JsonMissing.of(), + ) : this(groupingKey, maximumCharge, minimumCharge, perUnitRate, mutableMapOf()) /** - * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * The event property used to group before applying thresholds * - * You should usually call [Builder.billableMetricId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). */ - fun billableMetricId(billableMetricId: JsonField) = apply { - this.billableMetricId = billableMetricId - } + fun groupingKey(): String = groupingKey.getRequired("grouping_key") /** - * If the Price represents a fixed cost, the price will be billed in-advance if - * this is true, and in-arrears if this is false. + * The maximum amount to charge each group + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). */ - fun billedInAdvance(billedInAdvance: Boolean?) = - billedInAdvance(JsonField.ofNullable(billedInAdvance)) + fun maximumCharge(): String = maximumCharge.getRequired("maximum_charge") /** - * Alias for [Builder.billedInAdvance]. + * The minimum amount to charge each group, regardless of usage * - * This unboxed primitive overload exists for backwards compatibility. + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). */ - fun billedInAdvance(billedInAdvance: Boolean) = - billedInAdvance(billedInAdvance as Boolean?) + fun minimumCharge(): String = minimumCharge.getRequired("minimum_charge") /** - * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * The base price charged per group * - * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun billedInAdvance(billedInAdvance: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). */ - fun billingCycleConfiguration( - billingCycleConfiguration: NewBillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + fun perUnitRate(): String = perUnitRate.getRequired("per_unit_rate") /** - * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * Returns the raw JSON value of [groupingKey]. * - * You should usually call [Builder.billingCycleConfiguration] with a well-typed - * [NewBillingCycleConfiguration] value instead. This method is primarily for - * setting the field to an undocumented or not yet supported value. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: JsonField - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } - - /** - * The per unit conversion rate of the price currency to the invoicing currency. + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. */ - fun conversionRate(conversionRate: Double?) = - conversionRate(JsonField.ofNullable(conversionRate)) + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey /** - * Alias for [Builder.conversionRate]. + * Returns the raw JSON value of [maximumCharge]. * - * This unboxed primitive overload exists for backwards compatibility. + * Unlike [maximumCharge], this method doesn't throw if the JSON field has an + * unexpected type. */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) + @JsonProperty("maximum_charge") + @ExcludeMissing + fun _maximumCharge(): JsonField = maximumCharge /** - * Sets [Builder.conversionRate] to an arbitrary JSON value. + * Returns the raw JSON value of [minimumCharge]. * - * You should usually call [Builder.conversionRate] with a well-typed [Double] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** - * The configuration for the rate of the price currency to the invoicing - * currency. + * Unlike [minimumCharge], this method doesn't throw if the JSON field has an + * unexpected type. */ - fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = - conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + @JsonProperty("minimum_charge") + @ExcludeMissing + fun _minimumCharge(): JsonField = minimumCharge /** - * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * Returns the raw JSON value of [perUnitRate]. * - * You should usually call [Builder.conversionRateConfig] with a well-typed - * [ConversionRateConfig] value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. + * Unlike [perUnitRate], this method doesn't throw if the JSON field has an + * unexpected type. */ - fun conversionRateConfig( - conversionRateConfig: JsonField - ) = apply { this.conversionRateConfig = conversionRateConfig } + @JsonProperty("per_unit_rate") + @ExcludeMissing + fun _perUnitRate(): JsonField = perUnitRate - /** - * Alias for calling [conversionRateConfig] with - * `ConversionRateConfig.ofUnit(unit)`. - */ - fun conversionRateConfig(unit: UnitConversionRateConfig) = - conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - /** - * Alias for calling [conversionRateConfig] with the following: - * ```kotlin - * UnitConversionRateConfig.builder() - * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) - * .unitConfig(unitConfig) - * .build() - * ``` - */ - fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = - conversionRateConfig( - UnitConversionRateConfig.builder() - .conversionRateType( - UnitConversionRateConfig.ConversionRateType.UNIT - ) - .unitConfig(unitConfig) - .build() - ) + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - /** - * Alias for calling [conversionRateConfig] with - * `ConversionRateConfig.ofTiered(tiered)`. - */ - fun conversionRateConfig(tiered: TieredConversionRateConfig) = - conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + fun toBuilder() = Builder().from(this) - /** - * Alias for calling [conversionRateConfig] with the following: - * ```kotlin - * TieredConversionRateConfig.builder() - * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) - * .tieredConfig(tieredConfig) - * .build() - * ``` - */ - fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = - conversionRateConfig( - TieredConversionRateConfig.builder() - .conversionRateType( - TieredConversionRateConfig.ConversionRateType.TIERED - ) - .tieredConfig(tieredConfig) - .build() - ) + companion object { - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + /** + * Returns a mutable builder for constructing an instance of + * [GroupedWithMinMaxThresholdsConfig]. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .maximumCharge() + * .minimumCharge() + * .perUnitRate() + * ``` + */ + fun builder() = Builder() + } - /** - * Sets [Builder.currency] to an arbitrary JSON value. - * - * You should usually call [Builder.currency] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } + /** A builder for [GroupedWithMinMaxThresholdsConfig]. */ + class Builder internal constructor() { - /** For dimensional price: specifies a price group and dimension values */ - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? - ) = - dimensionalPriceConfiguration( - JsonField.ofNullable(dimensionalPriceConfiguration) - ) + private var groupingKey: JsonField? = null + private var maximumCharge: JsonField? = null + private var minimumCharge: JsonField? = null + private var perUnitRate: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() - /** - * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.dimensionalPriceConfiguration] with a - * well-typed [NewDimensionalPriceConfiguration] value instead. This method is - * primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: JsonField - ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + internal fun from( + groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + ) = apply { + groupingKey = groupedWithMinMaxThresholdsConfig.groupingKey + maximumCharge = groupedWithMinMaxThresholdsConfig.maximumCharge + minimumCharge = groupedWithMinMaxThresholdsConfig.minimumCharge + perUnitRate = groupedWithMinMaxThresholdsConfig.perUnitRate + additionalProperties = + groupedWithMinMaxThresholdsConfig.additionalProperties + .toMutableMap() + } - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) + /** The event property used to group before applying thresholds */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) - /** - * Sets [Builder.externalPriceId] to an arbitrary JSON value. - * - * You should usually call [Builder.externalPriceId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun externalPriceId(externalPriceId: JsonField) = apply { - this.externalPriceId = externalPriceId - } + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = - fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + /** The maximum amount to charge each group */ + fun maximumCharge(maximumCharge: String) = + maximumCharge(JsonField.of(maximumCharge)) - /** - * Alias for [Builder.fixedPriceQuantity]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) + /** + * Sets [Builder.maximumCharge] to an arbitrary JSON value. + * + * You should usually call [Builder.maximumCharge] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun maximumCharge(maximumCharge: JsonField) = apply { + this.maximumCharge = maximumCharge + } - /** - * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. - * - * You should usually call [Builder.fixedPriceQuantity] with a well-typed - * [Double] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + /** The minimum amount to charge each group, regardless of usage */ + fun minimumCharge(minimumCharge: String) = + minimumCharge(JsonField.of(minimumCharge)) - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = - invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + /** + * Sets [Builder.minimumCharge] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumCharge] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun minimumCharge(minimumCharge: JsonField) = apply { + this.minimumCharge = minimumCharge + } - /** - * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. - * - * You should usually call [Builder.invoiceGroupingKey] with a well-typed - * [String] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { - this.invoiceGroupingKey = invoiceGroupingKey - } + /** The base price charged per group */ + fun perUnitRate(perUnitRate: String) = + perUnitRate(JsonField.of(perUnitRate)) - /** - * Within each billing cycle, specifies the cadence at which invoices are - * produced. If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: NewBillingCycleConfiguration? - ) = - invoicingCycleConfiguration( - JsonField.ofNullable(invoicingCycleConfiguration) - ) + /** + * Sets [Builder.perUnitRate] to an arbitrary JSON value. + * + * You should usually call [Builder.perUnitRate] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun perUnitRate(perUnitRate: JsonField) = apply { + this.perUnitRate = perUnitRate + } - /** - * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.invoicingCycleConfiguration] with a - * well-typed [NewBillingCycleConfiguration] value instead. This method is - * primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * Sets [Builder.metadata] to an arbitrary JSON value. - * - * You should usually call [Builder.metadata] with a well-typed [Metadata] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - fun referenceId(referenceId: String?) = - referenceId(JsonField.ofNullable(referenceId)) + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - /** - * Sets [Builder.referenceId] to an arbitrary JSON value. - * - * You should usually call [Builder.referenceId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun referenceId(referenceId: JsonField) = apply { - this.referenceId = referenceId - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) + /** + * Returns an immutable instance of [GroupedWithMinMaxThresholdsConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .maximumCharge() + * .minimumCharge() + * .perUnitRate() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedWithMinMaxThresholdsConfig = + GroupedWithMinMaxThresholdsConfig( + checkRequired("groupingKey", groupingKey), + checkRequired("maximumCharge", maximumCharge), + checkRequired("minimumCharge", minimumCharge), + checkRequired("perUnitRate", perUnitRate), + additionalProperties.toMutableMap(), + ) } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + private var validated: Boolean = false - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) + fun validate(): GroupedWithMinMaxThresholdsConfig = apply { + if (validated) { + return@apply } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) + groupingKey() + maximumCharge() + minimumCharge() + perUnitRate() + validated = true } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } /** - * Returns an immutable instance of [EventOutput]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```kotlin - * .cadence() - * .eventOutputConfig() - * .itemId() - * .name() - * ``` + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * @throws IllegalStateException if any required field is unset. + * Used for best match union deserialization. */ - fun build(): EventOutput = - EventOutput( - checkRequired("cadence", cadence), - checkRequired("eventOutputConfig", eventOutputConfig), - checkRequired("itemId", itemId), - modelType, - checkRequired("name", name), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - conversionRateConfig, - currency, - dimensionalPriceConfiguration, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - additionalProperties.toMutableMap(), - ) - } + internal fun validity(): Int = + (if (groupingKey.asKnown() == null) 0 else 1) + + (if (maximumCharge.asKnown() == null) 0 else 1) + + (if (minimumCharge.asKnown() == null) 0 else 1) + + (if (perUnitRate.asKnown() == null) 0 else 1) - private var validated: Boolean = false + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun validate(): EventOutput = apply { - if (validated) { - return@apply + return other is GroupedWithMinMaxThresholdsConfig && + groupingKey == other.groupingKey && + maximumCharge == other.maximumCharge && + minimumCharge == other.minimumCharge && + perUnitRate == other.perUnitRate && + additionalProperties == other.additionalProperties } - cadence().validate() - eventOutputConfig().validate() - itemId() - _modelType().let { - if (it != JsonValue.from("event_output")) { - throw OrbInvalidDataException("'modelType' is invalid, received $it") - } + private val hashCode: Int by lazy { + Objects.hash( + groupingKey, + maximumCharge, + minimumCharge, + perUnitRate, + additionalProperties, + ) } - name() - billableMetricId() - billedInAdvance() - billingCycleConfiguration()?.validate() - conversionRate() - conversionRateConfig()?.validate() - currency() - dimensionalPriceConfiguration()?.validate() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration()?.validate() - metadata()?.validate() - referenceId() - validated = true - } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedWithMinMaxThresholdsConfig{groupingKey=$groupingKey, maximumCharge=$maximumCharge, minimumCharge=$minimumCharge, perUnitRate=$perUnitRate, additionalProperties=$additionalProperties}" + } /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. */ - internal fun validity(): Int = - (cadence.asKnown()?.validity() ?: 0) + - (eventOutputConfig.asKnown()?.validity() ?: 0) + - (if (itemId.asKnown() == null) 0 else 1) + - modelType.let { if (it == JsonValue.from("event_output")) 1 else 0 } + - (if (name.asKnown() == null) 0 else 1) + - (if (billableMetricId.asKnown() == null) 0 else 1) + - (if (billedInAdvance.asKnown() == null) 0 else 1) + - (billingCycleConfiguration.asKnown()?.validity() ?: 0) + - (if (conversionRate.asKnown() == null) 0 else 1) + - (conversionRateConfig.asKnown()?.validity() ?: 0) + - (if (currency.asKnown() == null) 0 else 1) + - (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + - (if (externalPriceId.asKnown() == null) 0 else 1) + - (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + - (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + - (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + - (metadata.asKnown()?.validity() ?: 0) + - (if (referenceId.asKnown() == null) 0 else 1) - - /** The cadence to bill for this price on. */ - class Cadence + class Metadata @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ + private constructor( @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value + private val additionalProperties: Map + ) { - companion object { + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties - val ANNUAL = of("annual") + fun toBuilder() = Builder().from(this) - val SEMI_ANNUAL = of("semi_annual") + companion object { - val MONTHLY = of("monthly") + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } - val QUARTERLY = of("quarterly") + /** A builder for [Metadata]. */ + class Builder internal constructor() { - val ONE_TIME = of("one_time") + private var additionalProperties: MutableMap = + mutableMapOf() - val CUSTOM = of("custom") + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } - fun of(value: String) = Cadence(JsonField.of(value)) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** An enum containing [Cadence]'s known values. */ - enum class Known { - ANNUAL, - SEMI_ANNUAL, - MONTHLY, - QUARTERLY, - ONE_TIME, - CUSTOM, - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Cadence] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - ANNUAL, - SEMI_ANNUAL, - MONTHLY, - QUARTERLY, - ONE_TIME, - CUSTOM, - /** - * An enum member indicating that [Cadence] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - ANNUAL -> Value.ANNUAL - SEMI_ANNUAL -> Value.SEMI_ANNUAL - MONTHLY -> Value.MONTHLY - QUARTERLY -> Value.QUARTERLY - ONE_TIME -> Value.ONE_TIME - CUSTOM -> Value.CUSTOM - else -> Value._UNKNOWN + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) } - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - ANNUAL -> Known.ANNUAL - SEMI_ANNUAL -> Known.SEMI_ANNUAL - MONTHLY -> Known.MONTHLY - QUARTERLY -> Known.QUARTERLY - ONE_TIME -> Known.ONE_TIME - CUSTOM -> Known.CUSTOM - else -> throw OrbInvalidDataException("Unknown Cadence: $value") + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) } - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString() - ?: throw OrbInvalidDataException("Value is not a String") + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } private var validated: Boolean = false - fun validate(): Cadence = apply { + fun validate(): Metadata = apply { if (validated) { return@apply } - known() validated = true } @@ -11853,3410 +11165,8236 @@ private constructor( * * Used for best match union deserialization. */ - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is Cadence && value == other.value + return other is Metadata && + additionalProperties == other.additionalProperties } - override fun hashCode() = value.hashCode() + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - override fun toString() = value.toString() - } + override fun hashCode(): Int = hashCode - /** Configuration for event_output pricing */ - class EventOutputConfig - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val unitRatingKey: JsonField, - private val groupingKey: JsonField, - private val additionalProperties: MutableMap, - ) { + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } - @JsonCreator - private constructor( - @JsonProperty("unit_rating_key") - @ExcludeMissing - unitRatingKey: JsonField = JsonMissing.of(), - @JsonProperty("grouping_key") - @ExcludeMissing - groupingKey: JsonField = JsonMissing.of(), - ) : this(unitRatingKey, groupingKey, mutableMapOf()) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * The key in the event data to extract the unit rate from. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun unitRatingKey(): String = unitRatingKey.getRequired("unit_rating_key") + return other is GroupedWithMinMaxThresholds && + cadence == other.cadence && + groupedWithMinMaxThresholdsConfig == + other.groupedWithMinMaxThresholdsConfig && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } - /** - * An optional key in the event data to group by (e.g., event ID). All events - * will also be grouped by their unit rate. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun groupingKey(): String? = groupingKey.getNullable("grouping_key") + private val hashCode: Int by lazy { + Objects.hash( + cadence, + groupedWithMinMaxThresholdsConfig, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties, + ) + } - /** - * Returns the raw JSON value of [unitRatingKey]. - * - * Unlike [unitRatingKey], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("unit_rating_key") - @ExcludeMissing - fun _unitRatingKey(): JsonField = unitRatingKey + override fun hashCode(): Int = hashCode - /** - * Returns the raw JSON value of [groupingKey]. - * - * Unlike [groupingKey], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("grouping_key") - @ExcludeMissing - fun _groupingKey(): JsonField = groupingKey + override fun toString() = + "GroupedWithMinMaxThresholds{cadence=$cadence, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + class Percent + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val percentConfig: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { - @JsonAnyGetter + @JsonCreator + private constructor( + @JsonProperty("cadence") @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("percent_config") + @ExcludeMissing + percentConfig: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + modelType, + name, + percentConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + mutableMapOf(), + ) - companion object { + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") - /** - * Returns a mutable builder for constructing an instance of - * [EventOutputConfig]. - * - * The following fields are required: - * ```kotlin - * .unitRatingKey() - * ``` - */ - fun builder() = Builder() - } + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") - /** A builder for [EventOutputConfig]. */ - class Builder internal constructor() { + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("percent") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType - private var unitRatingKey: JsonField? = null - private var groupingKey: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") - internal fun from(eventOutputConfig: EventOutputConfig) = apply { - unitRatingKey = eventOutputConfig.unitRatingKey - groupingKey = eventOutputConfig.groupingKey - additionalProperties = - eventOutputConfig.additionalProperties.toMutableMap() - } + /** + * Configuration for percent pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun percentConfig(): PercentConfig = percentConfig.getRequired("percent_config") - /** The key in the event data to extract the unit rate from. */ - fun unitRatingKey(unitRatingKey: String) = - unitRatingKey(JsonField.of(unitRatingKey)) + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = billableMetricId.getNullable("billable_metric_id") - /** - * Sets [Builder.unitRatingKey] to an arbitrary JSON value. - * - * You should usually call [Builder.unitRatingKey] with a well-typed - * [String] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun unitRatingKey(unitRatingKey: JsonField) = apply { - this.unitRatingKey = unitRatingKey - } + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") - /** - * An optional key in the event data to group by (e.g., event ID). All - * events will also be grouped by their unit rate. - */ - fun groupingKey(groupingKey: String?) = - groupingKey(JsonField.ofNullable(groupingKey)) - - /** - * Sets [Builder.groupingKey] to an arbitrary JSON value. - * - * You should usually call [Builder.groupingKey] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun groupingKey(groupingKey: JsonField) = apply { - this.groupingKey = groupingKey - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [EventOutputConfig]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```kotlin - * .unitRatingKey() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): EventOutputConfig = - EventOutputConfig( - checkRequired("unitRatingKey", unitRatingKey), - groupingKey, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): EventOutputConfig = apply { - if (validated) { - return@apply - } + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") - unitRatingKey() - groupingKey() - validated = true - } + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (if (unitRatingKey.asKnown() == null) 0 else 1) + - (if (groupingKey.asKnown() == null) 0 else 1) + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") - return other is EventOutputConfig && - unitRatingKey == other.unitRatingKey && - groupingKey == other.groupingKey && - additionalProperties == other.additionalProperties - } + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") - private val hashCode: Int by lazy { - Objects.hash(unitRatingKey, groupingKey, additionalProperties) - } + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") - override fun hashCode(): Int = hashCode + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + invoiceGroupingKey.getNullable("invoice_grouping_key") - override fun toString() = - "EventOutputConfig{unitRatingKey=$unitRatingKey, groupingKey=$groupingKey, additionalProperties=$additionalProperties}" - } + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). */ - class Metadata - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) + fun metadata(): Metadata? = metadata.getNullable("metadata") - companion object { + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") - /** Returns a mutable builder for constructing an instance of [Metadata]. */ - fun builder() = Builder() - } + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence - /** A builder for [Metadata]. */ - class Builder internal constructor() { + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - private var additionalProperties: MutableMap = - mutableMapOf() + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - internal fun from(metadata: Metadata) = apply { - additionalProperties = metadata.additionalProperties.toMutableMap() - } + /** + * Returns the raw JSON value of [percentConfig]. + * + * Unlike [percentConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("percent_config") + @ExcludeMissing + fun _percentConfig(): JsonField = percentConfig - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration - /** - * Returns an immutable instance of [Metadata]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate - private var validated: Boolean = false + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig - fun validate(): Metadata = apply { - if (validated) { - return@apply - } + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency - validated = true - } + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - additionalProperties.count { (_, value) -> - !value.isNull() && !value.isMissing() - } + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - return other is Metadata && - additionalProperties == other.additionalProperties - } + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata - override fun hashCode(): Int = hashCode + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is EventOutput && - cadence == other.cadence && - eventOutputConfig == other.eventOutputConfig && - itemId == other.itemId && - modelType == other.modelType && - name == other.name && - billableMetricId == other.billableMetricId && - billedInAdvance == other.billedInAdvance && - billingCycleConfiguration == other.billingCycleConfiguration && - conversionRate == other.conversionRate && - conversionRateConfig == other.conversionRateConfig && - currency == other.currency && - dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && - externalPriceId == other.externalPriceId && - fixedPriceQuantity == other.fixedPriceQuantity && - invoiceGroupingKey == other.invoiceGroupingKey && - invoicingCycleConfiguration == other.invoicingCycleConfiguration && - metadata == other.metadata && - referenceId == other.referenceId && - additionalProperties == other.additionalProperties - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - private val hashCode: Int by lazy { - Objects.hash( - cadence, - eventOutputConfig, - itemId, - modelType, - name, - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - conversionRateConfig, - currency, - dimensionalPriceConfiguration, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - additionalProperties, - ) - } + fun toBuilder() = Builder().from(this) - override fun hashCode(): Int = hashCode + companion object { - override fun toString() = - "EventOutput{cadence=$cadence, eventOutputConfig=$eventOutputConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" - } - } + /** + * Returns a mutable builder for constructing an instance of [Percent]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .name() + * .percentConfig() + * ``` + */ + fun builder() = Builder() + } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** A builder for [Percent]. */ + class Builder internal constructor() { - return other is AddPrice && - allocationPrice == other.allocationPrice && - discounts == other.discounts && - endDate == other.endDate && - externalPriceId == other.externalPriceId && - maximumAmount == other.maximumAmount && - minimumAmount == other.minimumAmount && - planPhaseOrder == other.planPhaseOrder && - price == other.price && - priceId == other.priceId && - startDate == other.startDate && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - allocationPrice, - discounts, - endDate, - externalPriceId, - maximumAmount, - minimumAmount, - planPhaseOrder, - price, - priceId, - startDate, - additionalProperties, - ) - } + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonValue = JsonValue.from("percent") + private var name: JsonField? = null + private var percentConfig: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - override fun hashCode(): Int = hashCode + internal fun from(percent: Percent) = apply { + cadence = percent.cadence + itemId = percent.itemId + modelType = percent.modelType + name = percent.name + percentConfig = percent.percentConfig + billableMetricId = percent.billableMetricId + billedInAdvance = percent.billedInAdvance + billingCycleConfiguration = percent.billingCycleConfiguration + conversionRate = percent.conversionRate + conversionRateConfig = percent.conversionRateConfig + currency = percent.currency + dimensionalPriceConfiguration = percent.dimensionalPriceConfiguration + externalPriceId = percent.externalPriceId + fixedPriceQuantity = percent.fixedPriceQuantity + invoiceGroupingKey = percent.invoiceGroupingKey + invoicingCycleConfiguration = percent.invoicingCycleConfiguration + metadata = percent.metadata + referenceId = percent.referenceId + additionalProperties = percent.additionalProperties.toMutableMap() + } - override fun toString() = - "AddPrice{allocationPrice=$allocationPrice, discounts=$discounts, endDate=$endDate, externalPriceId=$externalPriceId, maximumAmount=$maximumAmount, minimumAmount=$minimumAmount, planPhaseOrder=$planPhaseOrder, price=$price, priceId=$priceId, startDate=$startDate, additionalProperties=$additionalProperties}" - } + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - /** - * Reset billing periods to be aligned with the plan change's effective date or start of the - * month. Defaults to `unchanged` which keeps subscription's existing billing cycle alignment. - */ - class BillingCycleAlignment - @JsonCreator - private constructor(private val value: JsonField) : Enum { + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API may respond with new members that the SDK is - * unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - companion object { + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - val UNCHANGED = of("unchanged") + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("percent") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } - val PLAN_CHANGE_DATE = of("plan_change_date") + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) - val START_OF_MONTH = of("start_of_month") + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } - fun of(value: String) = BillingCycleAlignment(JsonField.of(value)) - } + /** Configuration for percent pricing */ + fun percentConfig(percentConfig: PercentConfig) = + percentConfig(JsonField.of(percentConfig)) - /** An enum containing [BillingCycleAlignment]'s known values. */ - enum class Known { - UNCHANGED, - PLAN_CHANGE_DATE, - START_OF_MONTH, - } + /** + * Sets [Builder.percentConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.percentConfig] with a well-typed + * [PercentConfig] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun percentConfig(percentConfig: JsonField) = apply { + this.percentConfig = percentConfig + } - /** - * An enum containing [BillingCycleAlignment]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [BillingCycleAlignment] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if the - * SDK is on an older version than the API, then the API may respond with new members that - * the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - UNCHANGED, - PLAN_CHANGE_DATE, - START_OF_MONTH, - /** - * An enum member indicating that [BillingCycleAlignment] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) - /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you want - * to throw for the unknown case. - */ - fun value(): Value = - when (this) { - UNCHANGED -> Value.UNCHANGED - PLAN_CHANGE_DATE -> Value.PLAN_CHANGE_DATE - START_OF_MONTH -> Value.START_OF_MONTH - else -> Value._UNKNOWN - } + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and don't - * want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known member. - */ - fun known(): Known = - when (this) { - UNCHANGED -> Known.UNCHANGED - PLAN_CHANGE_DATE -> Known.PLAN_CHANGE_DATE - START_OF_MONTH -> Known.START_OF_MONTH - else -> throw OrbInvalidDataException("Unknown BillingCycleAlignment: $value") - } + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the expected - * primitive type. - */ - fun asString(): String = - _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) - private var validated: Boolean = false + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } - fun validate(): BillingCycleAlignment = apply { - if (validated) { - return@apply - } + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - known() - validated = true - } + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } - return other is BillingCycleAlignment && value == other.value - } + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) - override fun hashCode() = value.hashCode() + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } - override fun toString() = value.toString() - } + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) - class RemoveAdjustment - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val adjustmentId: JsonField, - private val additionalProperties: MutableMap, - ) { + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) - @JsonCreator - private constructor( - @JsonProperty("adjustment_id") - @ExcludeMissing - adjustmentId: JsonField = JsonMissing.of() - ) : this(adjustmentId, mutableMapOf()) + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) - /** - * The id of the adjustment to remove on the subscription. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun adjustmentId(): String = adjustmentId.getRequired("adjustment_id") + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) - /** - * Returns the raw JSON value of [adjustmentId]. - * - * Unlike [adjustmentId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("adjustment_id") - @ExcludeMissing - fun _adjustmentId(): JsonField = adjustmentId + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) - fun toBuilder() = Builder().from(this) + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } - companion object { + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) - /** - * Returns a mutable builder for constructing an instance of [RemoveAdjustment]. - * - * The following fields are required: - * ```kotlin - * .adjustmentId() - * ``` - */ - fun builder() = Builder() - } + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } - /** A builder for [RemoveAdjustment]. */ - class Builder internal constructor() { + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) - private var adjustmentId: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) - internal fun from(removeAdjustment: RemoveAdjustment) = apply { - adjustmentId = removeAdjustment.adjustmentId - additionalProperties = removeAdjustment.additionalProperties.toMutableMap() - } + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } - /** The id of the adjustment to remove on the subscription. */ - fun adjustmentId(adjustmentId: String) = adjustmentId(JsonField.of(adjustmentId)) - - /** - * Sets [Builder.adjustmentId] to an arbitrary JSON value. - * - * You should usually call [Builder.adjustmentId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun adjustmentId(adjustmentId: JsonField) = apply { - this.adjustmentId = adjustmentId - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - /** - * Returns an immutable instance of [RemoveAdjustment]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```kotlin - * .adjustmentId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): RemoveAdjustment = - RemoveAdjustment( - checkRequired("adjustmentId", adjustmentId), - additionalProperties.toMutableMap(), - ) - } + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - private var validated: Boolean = false + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) - fun validate(): RemoveAdjustment = apply { - if (validated) { - return@apply - } + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } - adjustmentId() - validated = true - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = (if (adjustmentId.asKnown() == null) 0 else 1) + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - return other is RemoveAdjustment && - adjustmentId == other.adjustmentId && - additionalProperties == other.additionalProperties - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - private val hashCode: Int by lazy { Objects.hash(adjustmentId, additionalProperties) } + /** + * Returns an immutable instance of [Percent]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .name() + * .percentConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Percent = + Percent( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + modelType, + checkRequired("name", name), + checkRequired("percentConfig", percentConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } - override fun hashCode(): Int = hashCode + private var validated: Boolean = false - override fun toString() = - "RemoveAdjustment{adjustmentId=$adjustmentId, additionalProperties=$additionalProperties}" - } + fun validate(): Percent = apply { + if (validated) { + return@apply + } - class RemovePrice - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val externalPriceId: JsonField, - private val priceId: JsonField, - private val additionalProperties: MutableMap, - ) { + cadence().validate() + itemId() + _modelType().let { + if (it != JsonValue.from("percent")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + percentConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + metadata()?.validate() + referenceId() + validated = true + } - @JsonCreator - private constructor( - @JsonProperty("external_price_id") - @ExcludeMissing - externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("price_id") @ExcludeMissing priceId: JsonField = JsonMissing.of(), - ) : this(externalPriceId, priceId, mutableMapOf()) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - /** - * The external price id of the price to remove on the subscription. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") - - /** - * The id of the price to remove on the subscription. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun priceId(): String? = priceId.getNullable("price_id") + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + modelType.let { if (it == JsonValue.from("percent")) 1 else 0 } + + (if (name.asKnown() == null) 0 else 1) + + (percentConfig.asKnown()?.validity() ?: 0) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) - /** - * Returns the raw JSON value of [externalPriceId]. - * - * Unlike [externalPriceId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { - /** - * Returns the raw JSON value of [priceId]. - * - * Unlike [priceId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + companion object { - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + val ANNUAL = of("annual") - fun toBuilder() = Builder().from(this) + val SEMI_ANNUAL = of("semi_annual") - companion object { + val MONTHLY = of("monthly") - /** Returns a mutable builder for constructing an instance of [RemovePrice]. */ - fun builder() = Builder() - } + val QUARTERLY = of("quarterly") - /** A builder for [RemovePrice]. */ - class Builder internal constructor() { + val ONE_TIME = of("one_time") - private var externalPriceId: JsonField = JsonMissing.of() - private var priceId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + val CUSTOM = of("custom") - internal fun from(removePrice: RemovePrice) = apply { - externalPriceId = removePrice.externalPriceId - priceId = removePrice.priceId - additionalProperties = removePrice.additionalProperties.toMutableMap() - } + fun of(value: String) = Cadence(JsonField.of(value)) + } - /** The external price id of the price to remove on the subscription. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } - /** - * Sets [Builder.externalPriceId] to an arbitrary JSON value. - * - * You should usually call [Builder.externalPriceId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun externalPriceId(externalPriceId: JsonField) = apply { - this.externalPriceId = externalPriceId - } + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } - /** The id of the price to remove on the subscription. */ - fun priceId(priceId: String?) = priceId(JsonField.ofNullable(priceId)) + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } - /** - * Sets [Builder.priceId] to an arbitrary JSON value. - * - * You should usually call [Builder.priceId] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun priceId(priceId: JsonField) = apply { this.priceId = priceId } + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + private var validated: Boolean = false - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun validate(): Cadence = apply { + if (validated) { + return@apply + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + known() + validated = true + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - /** - * Returns an immutable instance of [RemovePrice]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): RemovePrice = - RemovePrice(externalPriceId, priceId, additionalProperties.toMutableMap()) - } + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - private var validated: Boolean = false + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun validate(): RemovePrice = apply { - if (validated) { - return@apply - } + return other is Cadence && value == other.value + } - externalPriceId() - priceId() - validated = true - } + override fun hashCode() = value.hashCode() - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + override fun toString() = value.toString() + } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (if (externalPriceId.asKnown() == null) 0 else 1) + - (if (priceId.asKnown() == null) 0 else 1) + /** Configuration for percent pricing */ + class PercentConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val percent: JsonField, + private val additionalProperties: MutableMap, + ) { - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + @JsonCreator + private constructor( + @JsonProperty("percent") + @ExcludeMissing + percent: JsonField = JsonMissing.of() + ) : this(percent, mutableMapOf()) - return other is RemovePrice && - externalPriceId == other.externalPriceId && - priceId == other.priceId && - additionalProperties == other.additionalProperties - } + /** + * What percent of the component subtotals to charge + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun percent(): Double = percent.getRequired("percent") - private val hashCode: Int by lazy { - Objects.hash(externalPriceId, priceId, additionalProperties) - } + /** + * Returns the raw JSON value of [percent]. + * + * Unlike [percent], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("percent") + @ExcludeMissing + fun _percent(): JsonField = percent - override fun hashCode(): Int = hashCode + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - override fun toString() = - "RemovePrice{externalPriceId=$externalPriceId, priceId=$priceId, additionalProperties=$additionalProperties}" - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - class ReplaceAdjustment - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val adjustment: JsonField, - private val replacesAdjustmentId: JsonField, - private val additionalProperties: MutableMap, - ) { + fun toBuilder() = Builder().from(this) - @JsonCreator - private constructor( - @JsonProperty("adjustment") - @ExcludeMissing - adjustment: JsonField = JsonMissing.of(), - @JsonProperty("replaces_adjustment_id") - @ExcludeMissing - replacesAdjustmentId: JsonField = JsonMissing.of(), - ) : this(adjustment, replacesAdjustmentId, mutableMapOf()) + companion object { - /** - * The definition of a new adjustment to create and add to the subscription. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun adjustment(): Adjustment = adjustment.getRequired("adjustment") + /** + * Returns a mutable builder for constructing an instance of + * [PercentConfig]. + * + * The following fields are required: + * ```kotlin + * .percent() + * ``` + */ + fun builder() = Builder() + } - /** - * The id of the adjustment on the plan to replace in the subscription. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun replacesAdjustmentId(): String = - replacesAdjustmentId.getRequired("replaces_adjustment_id") + /** A builder for [PercentConfig]. */ + class Builder internal constructor() { - /** - * Returns the raw JSON value of [adjustment]. - * - * Unlike [adjustment], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("adjustment") - @ExcludeMissing - fun _adjustment(): JsonField = adjustment + private var percent: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() - /** - * Returns the raw JSON value of [replacesAdjustmentId]. - * - * Unlike [replacesAdjustmentId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("replaces_adjustment_id") - @ExcludeMissing - fun _replacesAdjustmentId(): JsonField = replacesAdjustmentId + internal fun from(percentConfig: PercentConfig) = apply { + percent = percentConfig.percent + additionalProperties = percentConfig.additionalProperties.toMutableMap() + } - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** What percent of the component subtotals to charge */ + fun percent(percent: Double) = percent(JsonField.of(percent)) - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** + * Sets [Builder.percent] to an arbitrary JSON value. + * + * You should usually call [Builder.percent] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun percent(percent: JsonField) = apply { this.percent = percent } - fun toBuilder() = Builder().from(this) + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - companion object { + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * Returns a mutable builder for constructing an instance of [ReplaceAdjustment]. - * - * The following fields are required: - * ```kotlin - * .adjustment() - * .replacesAdjustmentId() - * ``` - */ - fun builder() = Builder() - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - /** A builder for [ReplaceAdjustment]. */ - class Builder internal constructor() { + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - private var adjustment: JsonField? = null - private var replacesAdjustmentId: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - internal fun from(replaceAdjustment: ReplaceAdjustment) = apply { - adjustment = replaceAdjustment.adjustment - replacesAdjustmentId = replaceAdjustment.replacesAdjustmentId - additionalProperties = replaceAdjustment.additionalProperties.toMutableMap() - } + /** + * Returns an immutable instance of [PercentConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .percent() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): PercentConfig = + PercentConfig( + checkRequired("percent", percent), + additionalProperties.toMutableMap(), + ) + } - /** The definition of a new adjustment to create and add to the subscription. */ - fun adjustment(adjustment: Adjustment) = adjustment(JsonField.of(adjustment)) + private var validated: Boolean = false - /** - * Sets [Builder.adjustment] to an arbitrary JSON value. - * - * You should usually call [Builder.adjustment] with a well-typed [Adjustment] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun adjustment(adjustment: JsonField) = apply { - this.adjustment = adjustment - } + fun validate(): PercentConfig = apply { + if (validated) { + return@apply + } - /** - * Alias for calling [adjustment] with - * `Adjustment.ofPercentageDiscount(percentageDiscount)`. - */ - fun adjustment(percentageDiscount: NewPercentageDiscount) = - adjustment(Adjustment.ofPercentageDiscount(percentageDiscount)) + percent() + validated = true + } - /** - * Alias for calling [adjustment] with the following: - * ```kotlin - * NewPercentageDiscount.builder() - * .adjustmentType(NewPercentageDiscount.AdjustmentType.PERCENTAGE_DISCOUNT) - * .percentageDiscount(percentageDiscount) - * .build() - * ``` - */ - fun percentageDiscountAdjustment(percentageDiscount: Double) = - adjustment( - NewPercentageDiscount.builder() - .adjustmentType(NewPercentageDiscount.AdjustmentType.PERCENTAGE_DISCOUNT) - .percentageDiscount(percentageDiscount) - .build() - ) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - /** Alias for calling [adjustment] with `Adjustment.ofUsageDiscount(usageDiscount)`. */ - fun adjustment(usageDiscount: NewUsageDiscount) = - adjustment(Adjustment.ofUsageDiscount(usageDiscount)) + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = (if (percent.asKnown() == null) 0 else 1) - /** - * Alias for calling [adjustment] with the following: - * ```kotlin - * NewUsageDiscount.builder() - * .adjustmentType(NewUsageDiscount.AdjustmentType.USAGE_DISCOUNT) - * .usageDiscount(usageDiscount) - * .build() - * ``` - */ - fun usageDiscountAdjustment(usageDiscount: Double) = - adjustment( - NewUsageDiscount.builder() - .adjustmentType(NewUsageDiscount.AdjustmentType.USAGE_DISCOUNT) - .usageDiscount(usageDiscount) - .build() - ) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * Alias for calling [adjustment] with `Adjustment.ofAmountDiscount(amountDiscount)`. - */ - fun adjustment(amountDiscount: NewAmountDiscount) = - adjustment(Adjustment.ofAmountDiscount(amountDiscount)) + return other is PercentConfig && + percent == other.percent && + additionalProperties == other.additionalProperties + } - /** - * Alias for calling [adjustment] with the following: - * ```kotlin - * NewAmountDiscount.builder() - * .adjustmentType(NewAmountDiscount.AdjustmentType.AMOUNT_DISCOUNT) - * .amountDiscount(amountDiscount) - * .build() - * ``` - */ - fun amountDiscountAdjustment(amountDiscount: String) = - adjustment( - NewAmountDiscount.builder() - .adjustmentType(NewAmountDiscount.AdjustmentType.AMOUNT_DISCOUNT) - .amountDiscount(amountDiscount) - .build() - ) + private val hashCode: Int by lazy { + Objects.hash(percent, additionalProperties) + } - /** Alias for calling [adjustment] with `Adjustment.ofMinimum(minimum)`. */ - fun adjustment(minimum: NewMinimum) = adjustment(Adjustment.ofMinimum(minimum)) + override fun hashCode(): Int = hashCode - /** Alias for calling [adjustment] with `Adjustment.ofMaximum(maximum)`. */ - fun adjustment(maximum: NewMaximum) = adjustment(Adjustment.ofMaximum(maximum)) + override fun toString() = + "PercentConfig{percent=$percent, additionalProperties=$additionalProperties}" + } - /** - * Alias for calling [adjustment] with the following: - * ```kotlin - * NewMaximum.builder() - * .adjustmentType(NewMaximum.AdjustmentType.MAXIMUM) - * .maximumAmount(maximumAmount) - * .build() - * ``` - */ - fun maximumAdjustment(maximumAmount: String) = - adjustment( - NewMaximum.builder() - .adjustmentType(NewMaximum.AdjustmentType.MAXIMUM) - .maximumAmount(maximumAmount) - .build() - ) + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { - /** The id of the adjustment on the plan to replace in the subscription. */ - fun replacesAdjustmentId(replacesAdjustmentId: String) = - replacesAdjustmentId(JsonField.of(replacesAdjustmentId)) + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties - /** - * Sets [Builder.replacesAdjustmentId] to an arbitrary JSON value. - * - * You should usually call [Builder.replacesAdjustmentId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun replacesAdjustmentId(replacesAdjustmentId: JsonField) = apply { - this.replacesAdjustmentId = replacesAdjustmentId - } + fun toBuilder() = Builder().from(this) - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + companion object { - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + /** A builder for [Metadata]. */ + class Builder internal constructor() { - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + private var additionalProperties: MutableMap = + mutableMapOf() - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } - /** - * Returns an immutable instance of [ReplaceAdjustment]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```kotlin - * .adjustment() - * .replacesAdjustmentId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): ReplaceAdjustment = - ReplaceAdjustment( - checkRequired("adjustment", adjustment), - checkRequired("replacesAdjustmentId", replacesAdjustmentId), - additionalProperties.toMutableMap(), - ) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - private var validated: Boolean = false + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun validate(): ReplaceAdjustment = apply { - if (validated) { - return@apply - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - adjustment().validate() - replacesAdjustmentId() - validated = true - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (adjustment.asKnown()?.validity() ?: 0) + - (if (replacesAdjustmentId.asKnown() == null) 0 else 1) + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } - /** The definition of a new adjustment to create and add to the subscription. */ - @JsonDeserialize(using = Adjustment.Deserializer::class) - @JsonSerialize(using = Adjustment.Serializer::class) - class Adjustment - private constructor( - private val percentageDiscount: NewPercentageDiscount? = null, - private val usageDiscount: NewUsageDiscount? = null, - private val amountDiscount: NewAmountDiscount? = null, - private val minimum: NewMinimum? = null, - private val maximum: NewMaximum? = null, - private val _json: JsonValue? = null, - ) { + private var validated: Boolean = false - fun percentageDiscount(): NewPercentageDiscount? = percentageDiscount + fun validate(): Metadata = apply { + if (validated) { + return@apply + } - fun usageDiscount(): NewUsageDiscount? = usageDiscount + validated = true + } - fun amountDiscount(): NewAmountDiscount? = amountDiscount + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - fun minimum(): NewMinimum? = minimum + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } - fun maximum(): NewMaximum? = maximum - - fun isPercentageDiscount(): Boolean = percentageDiscount != null - - fun isUsageDiscount(): Boolean = usageDiscount != null - - fun isAmountDiscount(): Boolean = amountDiscount != null - - fun isMinimum(): Boolean = minimum != null - - fun isMaximum(): Boolean = maximum != null - - fun asPercentageDiscount(): NewPercentageDiscount = - percentageDiscount.getOrThrow("percentageDiscount") - - fun asUsageDiscount(): NewUsageDiscount = usageDiscount.getOrThrow("usageDiscount") - - fun asAmountDiscount(): NewAmountDiscount = amountDiscount.getOrThrow("amountDiscount") - - fun asMinimum(): NewMinimum = minimum.getOrThrow("minimum") - - fun asMaximum(): NewMaximum = maximum.getOrThrow("maximum") - - fun _json(): JsonValue? = _json - - fun accept(visitor: Visitor): T = - when { - percentageDiscount != null -> - visitor.visitPercentageDiscount(percentageDiscount) - usageDiscount != null -> visitor.visitUsageDiscount(usageDiscount) - amountDiscount != null -> visitor.visitAmountDiscount(amountDiscount) - minimum != null -> visitor.visitMinimum(minimum) - maximum != null -> visitor.visitMaximum(maximum) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): Adjustment = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitPercentageDiscount( - percentageDiscount: NewPercentageDiscount - ) { - percentageDiscount.validate() - } - - override fun visitUsageDiscount(usageDiscount: NewUsageDiscount) { - usageDiscount.validate() - } - - override fun visitAmountDiscount(amountDiscount: NewAmountDiscount) { - amountDiscount.validate() - } - - override fun visitMinimum(minimum: NewMinimum) { - minimum.validate() + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - override fun visitMaximum(maximum: NewMaximum) { - maximum.validate() - } + return other is Metadata && + additionalProperties == other.additionalProperties } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitPercentageDiscount( - percentageDiscount: NewPercentageDiscount - ) = percentageDiscount.validity() - override fun visitUsageDiscount(usageDiscount: NewUsageDiscount) = - usageDiscount.validity() - - override fun visitAmountDiscount(amountDiscount: NewAmountDiscount) = - amountDiscount.validity() + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - override fun visitMinimum(minimum: NewMinimum) = minimum.validity() + override fun hashCode(): Int = hashCode - override fun visitMaximum(maximum: NewMaximum) = maximum.validity() + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } - override fun unknown(json: JsonValue?) = 0 + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - ) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + return other is Percent && + cadence == other.cadence && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + percentConfig == other.percentConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties } - return other is Adjustment && - percentageDiscount == other.percentageDiscount && - usageDiscount == other.usageDiscount && - amountDiscount == other.amountDiscount && - minimum == other.minimum && - maximum == other.maximum - } - - override fun hashCode(): Int = - Objects.hash(percentageDiscount, usageDiscount, amountDiscount, minimum, maximum) - - override fun toString(): String = - when { - percentageDiscount != null -> - "Adjustment{percentageDiscount=$percentageDiscount}" - usageDiscount != null -> "Adjustment{usageDiscount=$usageDiscount}" - amountDiscount != null -> "Adjustment{amountDiscount=$amountDiscount}" - minimum != null -> "Adjustment{minimum=$minimum}" - maximum != null -> "Adjustment{maximum=$maximum}" - _json != null -> "Adjustment{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Adjustment") + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + modelType, + name, + percentConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties, + ) } - companion object { - - fun ofPercentageDiscount(percentageDiscount: NewPercentageDiscount) = - Adjustment(percentageDiscount = percentageDiscount) - - fun ofUsageDiscount(usageDiscount: NewUsageDiscount) = - Adjustment(usageDiscount = usageDiscount) - - fun ofAmountDiscount(amountDiscount: NewAmountDiscount) = - Adjustment(amountDiscount = amountDiscount) - - fun ofMinimum(minimum: NewMinimum) = Adjustment(minimum = minimum) - - fun ofMaximum(maximum: NewMaximum) = Adjustment(maximum = maximum) - } - - /** - * An interface that defines how to map each variant of [Adjustment] to a value of type - * [T]. - */ - interface Visitor { - - fun visitPercentageDiscount(percentageDiscount: NewPercentageDiscount): T - - fun visitUsageDiscount(usageDiscount: NewUsageDiscount): T - - fun visitAmountDiscount(amountDiscount: NewAmountDiscount): T - - fun visitMinimum(minimum: NewMinimum): T - - fun visitMaximum(maximum: NewMaximum): T + override fun hashCode(): Int = hashCode - /** - * Maps an unknown variant of [Adjustment] to a value of type [T]. - * - * An instance of [Adjustment] can contain an unknown variant if it was deserialized - * from data that doesn't match any known variant. For example, if the SDK is on an - * older version than the API, then the API may respond with new variants that the - * SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown Adjustment: $json") - } + override fun toString() = + "Percent{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, percentConfig=$percentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - internal class Deserializer : BaseDeserializer(Adjustment::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): Adjustment { - val json = JsonValue.fromJsonNode(node) - val adjustmentType = json.asObject()?.get("adjustment_type")?.asString() + class EventOutput + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val eventOutputConfig: JsonField, + private val itemId: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { - when (adjustmentType) { - "percentage_discount" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Adjustment(percentageDiscount = it, _json = json) } - ?: Adjustment(_json = json) - } - "usage_discount" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(usageDiscount = it, _json = json) - } ?: Adjustment(_json = json) - } - "amount_discount" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(amountDiscount = it, _json = json) - } ?: Adjustment(_json = json) - } - "minimum" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(minimum = it, _json = json) - } ?: Adjustment(_json = json) - } - "maximum" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(maximum = it, _json = json) - } ?: Adjustment(_json = json) - } - } + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("event_output_config") + @ExcludeMissing + eventOutputConfig: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + eventOutputConfig, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + mutableMapOf(), + ) - return Adjustment(_json = json) - } - } + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") - internal class Serializer : BaseSerializer(Adjustment::class) { + /** + * Configuration for event_output pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun eventOutputConfig(): EventOutputConfig = + eventOutputConfig.getRequired("event_output_config") - override fun serialize( - value: Adjustment, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.percentageDiscount != null -> - generator.writeObject(value.percentageDiscount) - value.usageDiscount != null -> generator.writeObject(value.usageDiscount) - value.amountDiscount != null -> generator.writeObject(value.amountDiscount) - value.minimum != null -> generator.writeObject(value.minimum) - value.maximum != null -> generator.writeObject(value.maximum) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Adjustment") - } - } - } - } + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("event_output") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType - return other is ReplaceAdjustment && - adjustment == other.adjustment && - replacesAdjustmentId == other.replacesAdjustmentId && - additionalProperties == other.additionalProperties - } + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") - private val hashCode: Int by lazy { - Objects.hash(adjustment, replacesAdjustmentId, additionalProperties) - } + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = billableMetricId.getNullable("billable_metric_id") - override fun hashCode(): Int = hashCode + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") - override fun toString() = - "ReplaceAdjustment{adjustment=$adjustment, replacesAdjustmentId=$replacesAdjustmentId, additionalProperties=$additionalProperties}" - } + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") - class ReplacePrice - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val replacesPriceId: JsonField, - private val allocationPrice: JsonField, - private val discounts: JsonField>, - private val externalPriceId: JsonField, - private val fixedPriceQuantity: JsonField, - private val maximumAmount: JsonField, - private val minimumAmount: JsonField, - private val price: JsonField, - private val priceId: JsonField, - private val additionalProperties: MutableMap, - ) { + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") - @JsonCreator - private constructor( - @JsonProperty("replaces_price_id") - @ExcludeMissing - replacesPriceId: JsonField = JsonMissing.of(), - @JsonProperty("allocation_price") - @ExcludeMissing - allocationPrice: JsonField = JsonMissing.of(), - @JsonProperty("discounts") - @ExcludeMissing - discounts: JsonField> = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("maximum_amount") - @ExcludeMissing - maximumAmount: JsonField = JsonMissing.of(), - @JsonProperty("minimum_amount") - @ExcludeMissing - minimumAmount: JsonField = JsonMissing.of(), - @JsonProperty("price") @ExcludeMissing price: JsonField = JsonMissing.of(), - @JsonProperty("price_id") @ExcludeMissing priceId: JsonField = JsonMissing.of(), - ) : this( - replacesPriceId, - allocationPrice, - discounts, - externalPriceId, - fixedPriceQuantity, - maximumAmount, - minimumAmount, - price, - priceId, - mutableMapOf(), - ) + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") - /** - * The id of the price on the plan to replace in the subscription. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun replacesPriceId(): String = replacesPriceId.getRequired("replaces_price_id") + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") - /** - * The definition of a new allocation price to create and add to the subscription. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun allocationPrice(): NewAllocationPrice? = allocationPrice.getNullable("allocation_price") + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") - /** - * [DEPRECATED] Use add_adjustments instead. The subscription's discounts for the - * replacement price. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - @Deprecated("deprecated") - fun discounts(): List? = discounts.getNullable("discounts") + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") - /** - * The external price id of the price to add to the subscription. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") - /** - * The new quantity of the price, if the price is a fixed price. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun fixedPriceQuantity(): Double? = fixedPriceQuantity.getNullable("fixed_price_quantity") + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + invoiceGroupingKey.getNullable("invoice_grouping_key") - /** - * [DEPRECATED] Use add_adjustments instead. The subscription's maximum amount for the - * replacement price. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - @Deprecated("deprecated") - fun maximumAmount(): String? = maximumAmount.getNullable("maximum_amount") + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - /** - * [DEPRECATED] Use add_adjustments instead. The subscription's minimum amount for the - * replacement price. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - @Deprecated("deprecated") - fun minimumAmount(): String? = minimumAmount.getNullable("minimum_amount") + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") - /** - * New subscription price request body params. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun price(): Price? = price.getNullable("price") + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") - /** - * The id of the price to add to the subscription. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun priceId(): String? = priceId.getNullable("price_id") + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence - /** - * Returns the raw JSON value of [replacesPriceId]. - * - * Unlike [replacesPriceId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("replaces_price_id") - @ExcludeMissing - fun _replacesPriceId(): JsonField = replacesPriceId + /** + * Returns the raw JSON value of [eventOutputConfig]. + * + * Unlike [eventOutputConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("event_output_config") + @ExcludeMissing + fun _eventOutputConfig(): JsonField = eventOutputConfig - /** - * Returns the raw JSON value of [allocationPrice]. - * - * Unlike [allocationPrice], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("allocation_price") - @ExcludeMissing - fun _allocationPrice(): JsonField = allocationPrice + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - /** - * Returns the raw JSON value of [discounts]. - * - * Unlike [discounts], this method doesn't throw if the JSON field has an unexpected type. - */ - @Deprecated("deprecated") - @JsonProperty("discounts") - @ExcludeMissing - fun _discounts(): JsonField> = discounts + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - /** - * Returns the raw JSON value of [externalPriceId]. - * - * Unlike [externalPriceId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId - /** - * Returns the raw JSON value of [fixedPriceQuantity]. - * - * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance - /** - * Returns the raw JSON value of [maximumAmount]. - * - * Unlike [maximumAmount], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @Deprecated("deprecated") - @JsonProperty("maximum_amount") - @ExcludeMissing - fun _maximumAmount(): JsonField = maximumAmount - - /** - * Returns the raw JSON value of [minimumAmount]. - * - * Unlike [minimumAmount], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @Deprecated("deprecated") - @JsonProperty("minimum_amount") - @ExcludeMissing - fun _minimumAmount(): JsonField = minimumAmount - - /** - * Returns the raw JSON value of [price]. - * - * Unlike [price], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("price") @ExcludeMissing fun _price(): JsonField = price + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration - /** - * Returns the raw JSON value of [priceId]. - * - * Unlike [priceId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency - fun toBuilder() = Builder().from(this) + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration - companion object { + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId - /** - * Returns a mutable builder for constructing an instance of [ReplacePrice]. - * - * The following fields are required: - * ```kotlin - * .replacesPriceId() - * ``` - */ - fun builder() = Builder() - } + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - /** A builder for [ReplacePrice]. */ - class Builder internal constructor() { + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - private var replacesPriceId: JsonField? = null - private var allocationPrice: JsonField = JsonMissing.of() - private var discounts: JsonField>? = null - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var maximumAmount: JsonField = JsonMissing.of() - private var minimumAmount: JsonField = JsonMissing.of() - private var price: JsonField = JsonMissing.of() - private var priceId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration - internal fun from(replacePrice: ReplacePrice) = apply { - replacesPriceId = replacePrice.replacesPriceId - allocationPrice = replacePrice.allocationPrice - discounts = replacePrice.discounts.map { it.toMutableList() } - externalPriceId = replacePrice.externalPriceId - fixedPriceQuantity = replacePrice.fixedPriceQuantity - maximumAmount = replacePrice.maximumAmount - minimumAmount = replacePrice.minimumAmount - price = replacePrice.price - priceId = replacePrice.priceId - additionalProperties = replacePrice.additionalProperties.toMutableMap() - } + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata - /** The id of the price on the plan to replace in the subscription. */ - fun replacesPriceId(replacesPriceId: String) = - replacesPriceId(JsonField.of(replacesPriceId)) + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId - /** - * Sets [Builder.replacesPriceId] to an arbitrary JSON value. - * - * You should usually call [Builder.replacesPriceId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun replacesPriceId(replacesPriceId: JsonField) = apply { - this.replacesPriceId = replacesPriceId - } + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - /** The definition of a new allocation price to create and add to the subscription. */ - fun allocationPrice(allocationPrice: NewAllocationPrice?) = - allocationPrice(JsonField.ofNullable(allocationPrice)) + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - /** - * Sets [Builder.allocationPrice] to an arbitrary JSON value. - * - * You should usually call [Builder.allocationPrice] with a well-typed - * [NewAllocationPrice] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun allocationPrice(allocationPrice: JsonField) = apply { - this.allocationPrice = allocationPrice - } + fun toBuilder() = Builder().from(this) - /** - * [DEPRECATED] Use add_adjustments instead. The subscription's discounts for the - * replacement price. - */ - @Deprecated("deprecated") - fun discounts(discounts: List?) = - discounts(JsonField.ofNullable(discounts)) + companion object { - /** - * Sets [Builder.discounts] to an arbitrary JSON value. - * - * You should usually call [Builder.discounts] with a well-typed - * `List` value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - @Deprecated("deprecated") - fun discounts(discounts: JsonField>) = apply { - this.discounts = discounts.map { it.toMutableList() } - } + /** + * Returns a mutable builder for constructing an instance of [EventOutput]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .eventOutputConfig() + * .itemId() + * .name() + * ``` + */ + fun builder() = Builder() + } - /** - * Adds a single [DiscountOverride] to [discounts]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - @Deprecated("deprecated") - fun addDiscount(discount: DiscountOverride) = apply { - discounts = - (discounts ?: JsonField.of(mutableListOf())).also { - checkKnown("discounts", it).add(discount) - } - } + /** A builder for [EventOutput]. */ + class Builder internal constructor() { - /** The external price id of the price to add to the subscription. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) + private var cadence: JsonField? = null + private var eventOutputConfig: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonValue = JsonValue.from("event_output") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - /** - * Sets [Builder.externalPriceId] to an arbitrary JSON value. - * - * You should usually call [Builder.externalPriceId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun externalPriceId(externalPriceId: JsonField) = apply { - this.externalPriceId = externalPriceId - } + internal fun from(eventOutput: EventOutput) = apply { + cadence = eventOutput.cadence + eventOutputConfig = eventOutput.eventOutputConfig + itemId = eventOutput.itemId + modelType = eventOutput.modelType + name = eventOutput.name + billableMetricId = eventOutput.billableMetricId + billedInAdvance = eventOutput.billedInAdvance + billingCycleConfiguration = eventOutput.billingCycleConfiguration + conversionRate = eventOutput.conversionRate + conversionRateConfig = eventOutput.conversionRateConfig + currency = eventOutput.currency + dimensionalPriceConfiguration = eventOutput.dimensionalPriceConfiguration + externalPriceId = eventOutput.externalPriceId + fixedPriceQuantity = eventOutput.fixedPriceQuantity + invoiceGroupingKey = eventOutput.invoiceGroupingKey + invoicingCycleConfiguration = eventOutput.invoicingCycleConfiguration + metadata = eventOutput.metadata + referenceId = eventOutput.referenceId + additionalProperties = eventOutput.additionalProperties.toMutableMap() + } - /** The new quantity of the price, if the price is a fixed price. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = - fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - /** - * Alias for [Builder.fixedPriceQuantity]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - /** - * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. - * - * You should usually call [Builder.fixedPriceQuantity] with a well-typed [Double] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + /** Configuration for event_output pricing */ + fun eventOutputConfig(eventOutputConfig: EventOutputConfig) = + eventOutputConfig(JsonField.of(eventOutputConfig)) - /** - * [DEPRECATED] Use add_adjustments instead. The subscription's maximum amount for the - * replacement price. - */ - @Deprecated("deprecated") - fun maximumAmount(maximumAmount: String?) = - maximumAmount(JsonField.ofNullable(maximumAmount)) + /** + * Sets [Builder.eventOutputConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.eventOutputConfig] with a well-typed + * [EventOutputConfig] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun eventOutputConfig(eventOutputConfig: JsonField) = apply { + this.eventOutputConfig = eventOutputConfig + } - /** - * Sets [Builder.maximumAmount] to an arbitrary JSON value. - * - * You should usually call [Builder.maximumAmount] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - @Deprecated("deprecated") - fun maximumAmount(maximumAmount: JsonField) = apply { - this.maximumAmount = maximumAmount - } + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - /** - * [DEPRECATED] Use add_adjustments instead. The subscription's minimum amount for the - * replacement price. - */ - @Deprecated("deprecated") - fun minimumAmount(minimumAmount: String?) = - minimumAmount(JsonField.ofNullable(minimumAmount)) + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - /** - * Sets [Builder.minimumAmount] to an arbitrary JSON value. - * - * You should usually call [Builder.minimumAmount] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - @Deprecated("deprecated") - fun minimumAmount(minimumAmount: JsonField) = apply { - this.minimumAmount = minimumAmount - } + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("event_output") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } - /** New subscription price request body params. */ - fun price(price: Price?) = price(JsonField.ofNullable(price)) + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) - /** - * Sets [Builder.price] to an arbitrary JSON value. - * - * You should usually call [Builder.price] with a well-typed [Price] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun price(price: JsonField) = apply { this.price = price } + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } - /** Alias for calling [price] with `Price.ofUnit(unit)`. */ - fun price(unit: NewSubscriptionUnitPrice) = price(Price.ofUnit(unit)) + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) - /** Alias for calling [price] with `Price.ofTiered(tiered)`. */ - fun price(tiered: NewSubscriptionTieredPrice) = price(Price.ofTiered(tiered)) + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } - /** Alias for calling [price] with `Price.ofBulk(bulk)`. */ - fun price(bulk: NewSubscriptionBulkPrice) = price(Price.ofBulk(bulk)) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) - /** Alias for calling [price] with `Price.ofPackage(package_)`. */ - fun price(package_: NewSubscriptionPackagePrice) = price(Price.ofPackage(package_)) + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) - /** Alias for calling [price] with `Price.ofMatrix(matrix)`. */ - fun price(matrix: NewSubscriptionMatrixPrice) = price(Price.ofMatrix(matrix)) + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } - /** - * Alias for calling [price] with `Price.ofThresholdTotalAmount(thresholdTotalAmount)`. - */ - fun price(thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice) = - price(Price.ofThresholdTotalAmount(thresholdTotalAmount)) + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - /** Alias for calling [price] with `Price.ofTieredPackage(tieredPackage)`. */ - fun price(tieredPackage: NewSubscriptionTieredPackagePrice) = - price(Price.ofTieredPackage(tieredPackage)) + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } - /** Alias for calling [price] with `Price.ofTieredWithMinimum(tieredWithMinimum)`. */ - fun price(tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice) = - price(Price.ofTieredWithMinimum(tieredWithMinimum)) - - /** Alias for calling [price] with `Price.ofGroupedTiered(groupedTiered)`. */ - fun price(groupedTiered: NewSubscriptionGroupedTieredPrice) = - price(Price.ofGroupedTiered(groupedTiered)) - - /** - * Alias for calling [price] with - * `Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)`. - */ - fun price(tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice) = - price(Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)) + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) - /** - * Alias for calling [price] with - * `Price.ofPackageWithAllocation(packageWithAllocation)`. - */ - fun price(packageWithAllocation: NewSubscriptionPackageWithAllocationPrice) = - price(Price.ofPackageWithAllocation(packageWithAllocation)) + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) - /** Alias for calling [price] with `Price.ofUnitWithPercent(unitWithPercent)`. */ - fun price(unitWithPercent: NewSubscriptionUnitWithPercentPrice) = - price(Price.ofUnitWithPercent(unitWithPercent)) + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } - /** - * Alias for calling [price] with `Price.ofMatrixWithAllocation(matrixWithAllocation)`. - */ - fun price(matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice) = - price(Price.ofMatrixWithAllocation(matrixWithAllocation)) + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) - /** - * Alias for calling [price] with `Price.ofTieredWithProration(tieredWithProration)`. - */ - fun price(tieredWithProration: Price.TieredWithProration) = - price(Price.ofTieredWithProration(tieredWithProration)) + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } - /** Alias for calling [price] with `Price.ofUnitWithProration(unitWithProration)`. */ - fun price(unitWithProration: NewSubscriptionUnitWithProrationPrice) = - price(Price.ofUnitWithProration(unitWithProration)) + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) - /** Alias for calling [price] with `Price.ofGroupedAllocation(groupedAllocation)`. */ - fun price(groupedAllocation: NewSubscriptionGroupedAllocationPrice) = - price(Price.ofGroupedAllocation(groupedAllocation)) + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) - /** Alias for calling [price] with `Price.ofBulkWithProration(bulkWithProration)`. */ - fun price(bulkWithProration: NewSubscriptionBulkWithProrationPrice) = - price(Price.ofBulkWithProration(bulkWithProration)) + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) - /** - * Alias for calling [price] with - * `Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)`. - */ - fun price(groupedWithProratedMinimum: NewSubscriptionGroupedWithProratedMinimumPrice) = - price(Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)) + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) - /** - * Alias for calling [price] with - * `Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)`. - */ - fun price(groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice) = - price(Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)) + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) - /** - * Alias for calling [price] with - * `Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)`. - */ - fun price(groupedWithMinMaxThresholds: Price.GroupedWithMinMaxThresholds) = - price(Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)) + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } - /** - * Alias for calling [price] with - * `Price.ofMatrixWithDisplayName(matrixWithDisplayName)`. - */ - fun price(matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice) = - price(Price.ofMatrixWithDisplayName(matrixWithDisplayName)) + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) - /** - * Alias for calling [price] with `Price.ofGroupedTieredPackage(groupedTieredPackage)`. - */ - fun price(groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice) = - price(Price.ofGroupedTieredPackage(groupedTieredPackage)) + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } - /** - * Alias for calling [price] with - * `Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)`. - */ - fun price(maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice) = - price(Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)) + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) - /** - * Alias for calling [price] with - * `Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)`. - */ - fun price( - scalableMatrixWithUnitPricing: NewSubscriptionScalableMatrixWithUnitPricingPrice - ) = price(Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)) + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } - /** - * Alias for calling [price] with - * `Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)`. - */ - fun price( - scalableMatrixWithTieredPricing: NewSubscriptionScalableMatrixWithTieredPricingPrice - ) = price(Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)) + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) - /** - * Alias for calling [price] with - * `Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)`. - */ - fun price(cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice) = - price(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) - /** Alias for calling [price] with `Price.ofMinimum(minimum)`. */ - fun price(minimum: NewSubscriptionMinimumCompositePrice) = - price(Price.ofMinimum(minimum)) + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } - /** Alias for calling [price] with `Price.ofPercent(percent)`. */ - fun price(percent: Price.Percent) = price(Price.ofPercent(percent)) + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) - /** Alias for calling [price] with `Price.ofEventOutput(eventOutput)`. */ - fun price(eventOutput: Price.EventOutput) = price(Price.ofEventOutput(eventOutput)) + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } - /** The id of the price to add to the subscription. */ - fun priceId(priceId: String?) = priceId(JsonField.ofNullable(priceId)) + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) - /** - * Sets [Builder.priceId] to an arbitrary JSON value. - * - * You should usually call [Builder.priceId] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun priceId(priceId: JsonField) = apply { this.priceId = priceId } + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** - * Returns an immutable instance of [ReplacePrice]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```kotlin - * .replacesPriceId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): ReplacePrice = - ReplacePrice( - checkRequired("replacesPriceId", replacesPriceId), - allocationPrice, - (discounts ?: JsonMissing.of()).map { it.toImmutable() }, + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [EventOutput]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .eventOutputConfig() + * .itemId() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): EventOutput = + EventOutput( + checkRequired("cadence", cadence), + checkRequired("eventOutputConfig", eventOutputConfig), + checkRequired("itemId", itemId), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): EventOutput = apply { + if (validated) { + return@apply + } + + cadence().validate() + eventOutputConfig().validate() + itemId() + _modelType().let { + if (it != JsonValue.from("event_output")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (eventOutputConfig.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + modelType.let { if (it == JsonValue.from("event_output")) 1 else 0 } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Configuration for event_output pricing */ + class EventOutputConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val unitRatingKey: JsonField, + private val groupingKey: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("unit_rating_key") + @ExcludeMissing + unitRatingKey: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + ) : this(unitRatingKey, groupingKey, mutableMapOf()) + + /** + * The key in the event data to extract the unit rate from. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun unitRatingKey(): String = unitRatingKey.getRequired("unit_rating_key") + + /** + * An optional key in the event data to group by (e.g., event ID). All events + * will also be grouped by their unit rate. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun groupingKey(): String? = groupingKey.getNullable("grouping_key") + + /** + * Returns the raw JSON value of [unitRatingKey]. + * + * Unlike [unitRatingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_rating_key") + @ExcludeMissing + fun _unitRatingKey(): JsonField = unitRatingKey + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [EventOutputConfig]. + * + * The following fields are required: + * ```kotlin + * .unitRatingKey() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [EventOutputConfig]. */ + class Builder internal constructor() { + + private var unitRatingKey: JsonField? = null + private var groupingKey: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(eventOutputConfig: EventOutputConfig) = apply { + unitRatingKey = eventOutputConfig.unitRatingKey + groupingKey = eventOutputConfig.groupingKey + additionalProperties = + eventOutputConfig.additionalProperties.toMutableMap() + } + + /** The key in the event data to extract the unit rate from. */ + fun unitRatingKey(unitRatingKey: String) = + unitRatingKey(JsonField.of(unitRatingKey)) + + /** + * Sets [Builder.unitRatingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.unitRatingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun unitRatingKey(unitRatingKey: JsonField) = apply { + this.unitRatingKey = unitRatingKey + } + + /** + * An optional key in the event data to group by (e.g., event ID). All + * events will also be grouped by their unit rate. + */ + fun groupingKey(groupingKey: String?) = + groupingKey(JsonField.ofNullable(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [EventOutputConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .unitRatingKey() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): EventOutputConfig = + EventOutputConfig( + checkRequired("unitRatingKey", unitRatingKey), + groupingKey, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): EventOutputConfig = apply { + if (validated) { + return@apply + } + + unitRatingKey() + groupingKey() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (unitRatingKey.asKnown() == null) 0 else 1) + + (if (groupingKey.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is EventOutputConfig && + unitRatingKey == other.unitRatingKey && + groupingKey == other.groupingKey && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(unitRatingKey, groupingKey, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "EventOutputConfig{unitRatingKey=$unitRatingKey, groupingKey=$groupingKey, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is EventOutput && + cadence == other.cadence && + eventOutputConfig == other.eventOutputConfig && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + eventOutputConfig, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "EventOutput{cadence=$cadence, eventOutputConfig=$eventOutputConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AddPrice && + allocationPrice == other.allocationPrice && + discounts == other.discounts && + endDate == other.endDate && + externalPriceId == other.externalPriceId && + maximumAmount == other.maximumAmount && + minimumAmount == other.minimumAmount && + planPhaseOrder == other.planPhaseOrder && + price == other.price && + priceId == other.priceId && + startDate == other.startDate && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + allocationPrice, + discounts, + endDate, + externalPriceId, + maximumAmount, + minimumAmount, + planPhaseOrder, + price, + priceId, + startDate, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AddPrice{allocationPrice=$allocationPrice, discounts=$discounts, endDate=$endDate, externalPriceId=$externalPriceId, maximumAmount=$maximumAmount, minimumAmount=$minimumAmount, planPhaseOrder=$planPhaseOrder, price=$price, priceId=$priceId, startDate=$startDate, additionalProperties=$additionalProperties}" + } + + /** + * Reset billing periods to be aligned with the plan change's effective date or start of the + * month. Defaults to `unchanged` which keeps subscription's existing billing cycle alignment. + */ + class BillingCycleAlignment + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val UNCHANGED = of("unchanged") + + val PLAN_CHANGE_DATE = of("plan_change_date") + + val START_OF_MONTH = of("start_of_month") + + fun of(value: String) = BillingCycleAlignment(JsonField.of(value)) + } + + /** An enum containing [BillingCycleAlignment]'s known values. */ + enum class Known { + UNCHANGED, + PLAN_CHANGE_DATE, + START_OF_MONTH, + } + + /** + * An enum containing [BillingCycleAlignment]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [BillingCycleAlignment] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + UNCHANGED, + PLAN_CHANGE_DATE, + START_OF_MONTH, + /** + * An enum member indicating that [BillingCycleAlignment] was instantiated with an + * unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + UNCHANGED -> Value.UNCHANGED + PLAN_CHANGE_DATE -> Value.PLAN_CHANGE_DATE + START_OF_MONTH -> Value.START_OF_MONTH + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known member. + */ + fun known(): Known = + when (this) { + UNCHANGED -> Known.UNCHANGED + PLAN_CHANGE_DATE -> Known.PLAN_CHANGE_DATE + START_OF_MONTH -> Known.START_OF_MONTH + else -> throw OrbInvalidDataException("Unknown BillingCycleAlignment: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the expected + * primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): BillingCycleAlignment = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BillingCycleAlignment && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class RemoveAdjustment + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val adjustmentId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("adjustment_id") + @ExcludeMissing + adjustmentId: JsonField = JsonMissing.of() + ) : this(adjustmentId, mutableMapOf()) + + /** + * The id of the adjustment to remove on the subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun adjustmentId(): String = adjustmentId.getRequired("adjustment_id") + + /** + * Returns the raw JSON value of [adjustmentId]. + * + * Unlike [adjustmentId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("adjustment_id") + @ExcludeMissing + fun _adjustmentId(): JsonField = adjustmentId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [RemoveAdjustment]. + * + * The following fields are required: + * ```kotlin + * .adjustmentId() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [RemoveAdjustment]. */ + class Builder internal constructor() { + + private var adjustmentId: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(removeAdjustment: RemoveAdjustment) = apply { + adjustmentId = removeAdjustment.adjustmentId + additionalProperties = removeAdjustment.additionalProperties.toMutableMap() + } + + /** The id of the adjustment to remove on the subscription. */ + fun adjustmentId(adjustmentId: String) = adjustmentId(JsonField.of(adjustmentId)) + + /** + * Sets [Builder.adjustmentId] to an arbitrary JSON value. + * + * You should usually call [Builder.adjustmentId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun adjustmentId(adjustmentId: JsonField) = apply { + this.adjustmentId = adjustmentId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [RemoveAdjustment]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .adjustmentId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): RemoveAdjustment = + RemoveAdjustment( + checkRequired("adjustmentId", adjustmentId), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): RemoveAdjustment = apply { + if (validated) { + return@apply + } + + adjustmentId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = (if (adjustmentId.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RemoveAdjustment && + adjustmentId == other.adjustmentId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(adjustmentId, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "RemoveAdjustment{adjustmentId=$adjustmentId, additionalProperties=$additionalProperties}" + } + + class RemovePrice + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val externalPriceId: JsonField, + private val priceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("price_id") @ExcludeMissing priceId: JsonField = JsonMissing.of(), + ) : this(externalPriceId, priceId, mutableMapOf()) + + /** + * The external price id of the price to remove on the subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * The id of the price to remove on the subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun priceId(): String? = priceId.getNullable("price_id") + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [priceId]. + * + * Unlike [priceId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [RemovePrice]. */ + fun builder() = Builder() + } + + /** A builder for [RemovePrice]. */ + class Builder internal constructor() { + + private var externalPriceId: JsonField = JsonMissing.of() + private var priceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(removePrice: RemovePrice) = apply { + externalPriceId = removePrice.externalPriceId + priceId = removePrice.priceId + additionalProperties = removePrice.additionalProperties.toMutableMap() + } + + /** The external price id of the price to remove on the subscription. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** The id of the price to remove on the subscription. */ + fun priceId(priceId: String?) = priceId(JsonField.ofNullable(priceId)) + + /** + * Sets [Builder.priceId] to an arbitrary JSON value. + * + * You should usually call [Builder.priceId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun priceId(priceId: JsonField) = apply { this.priceId = priceId } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [RemovePrice]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): RemovePrice = + RemovePrice(externalPriceId, priceId, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): RemovePrice = apply { + if (validated) { + return@apply + } + + externalPriceId() + priceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (priceId.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RemovePrice && + externalPriceId == other.externalPriceId && + priceId == other.priceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(externalPriceId, priceId, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "RemovePrice{externalPriceId=$externalPriceId, priceId=$priceId, additionalProperties=$additionalProperties}" + } + + class ReplaceAdjustment + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val adjustment: JsonField, + private val replacesAdjustmentId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("adjustment") + @ExcludeMissing + adjustment: JsonField = JsonMissing.of(), + @JsonProperty("replaces_adjustment_id") + @ExcludeMissing + replacesAdjustmentId: JsonField = JsonMissing.of(), + ) : this(adjustment, replacesAdjustmentId, mutableMapOf()) + + /** + * The definition of a new adjustment to create and add to the subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun adjustment(): Adjustment = adjustment.getRequired("adjustment") + + /** + * The id of the adjustment on the plan to replace in the subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun replacesAdjustmentId(): String = + replacesAdjustmentId.getRequired("replaces_adjustment_id") + + /** + * Returns the raw JSON value of [adjustment]. + * + * Unlike [adjustment], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("adjustment") + @ExcludeMissing + fun _adjustment(): JsonField = adjustment + + /** + * Returns the raw JSON value of [replacesAdjustmentId]. + * + * Unlike [replacesAdjustmentId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("replaces_adjustment_id") + @ExcludeMissing + fun _replacesAdjustmentId(): JsonField = replacesAdjustmentId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ReplaceAdjustment]. + * + * The following fields are required: + * ```kotlin + * .adjustment() + * .replacesAdjustmentId() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [ReplaceAdjustment]. */ + class Builder internal constructor() { + + private var adjustment: JsonField? = null + private var replacesAdjustmentId: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(replaceAdjustment: ReplaceAdjustment) = apply { + adjustment = replaceAdjustment.adjustment + replacesAdjustmentId = replaceAdjustment.replacesAdjustmentId + additionalProperties = replaceAdjustment.additionalProperties.toMutableMap() + } + + /** The definition of a new adjustment to create and add to the subscription. */ + fun adjustment(adjustment: Adjustment) = adjustment(JsonField.of(adjustment)) + + /** + * Sets [Builder.adjustment] to an arbitrary JSON value. + * + * You should usually call [Builder.adjustment] with a well-typed [Adjustment] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun adjustment(adjustment: JsonField) = apply { + this.adjustment = adjustment + } + + /** + * Alias for calling [adjustment] with + * `Adjustment.ofPercentageDiscount(percentageDiscount)`. + */ + fun adjustment(percentageDiscount: NewPercentageDiscount) = + adjustment(Adjustment.ofPercentageDiscount(percentageDiscount)) + + /** + * Alias for calling [adjustment] with the following: + * ```kotlin + * NewPercentageDiscount.builder() + * .adjustmentType(NewPercentageDiscount.AdjustmentType.PERCENTAGE_DISCOUNT) + * .percentageDiscount(percentageDiscount) + * .build() + * ``` + */ + fun percentageDiscountAdjustment(percentageDiscount: Double) = + adjustment( + NewPercentageDiscount.builder() + .adjustmentType(NewPercentageDiscount.AdjustmentType.PERCENTAGE_DISCOUNT) + .percentageDiscount(percentageDiscount) + .build() + ) + + /** Alias for calling [adjustment] with `Adjustment.ofUsageDiscount(usageDiscount)`. */ + fun adjustment(usageDiscount: NewUsageDiscount) = + adjustment(Adjustment.ofUsageDiscount(usageDiscount)) + + /** + * Alias for calling [adjustment] with the following: + * ```kotlin + * NewUsageDiscount.builder() + * .adjustmentType(NewUsageDiscount.AdjustmentType.USAGE_DISCOUNT) + * .usageDiscount(usageDiscount) + * .build() + * ``` + */ + fun usageDiscountAdjustment(usageDiscount: Double) = + adjustment( + NewUsageDiscount.builder() + .adjustmentType(NewUsageDiscount.AdjustmentType.USAGE_DISCOUNT) + .usageDiscount(usageDiscount) + .build() + ) + + /** + * Alias for calling [adjustment] with `Adjustment.ofAmountDiscount(amountDiscount)`. + */ + fun adjustment(amountDiscount: NewAmountDiscount) = + adjustment(Adjustment.ofAmountDiscount(amountDiscount)) + + /** + * Alias for calling [adjustment] with the following: + * ```kotlin + * NewAmountDiscount.builder() + * .adjustmentType(NewAmountDiscount.AdjustmentType.AMOUNT_DISCOUNT) + * .amountDiscount(amountDiscount) + * .build() + * ``` + */ + fun amountDiscountAdjustment(amountDiscount: String) = + adjustment( + NewAmountDiscount.builder() + .adjustmentType(NewAmountDiscount.AdjustmentType.AMOUNT_DISCOUNT) + .amountDiscount(amountDiscount) + .build() + ) + + /** Alias for calling [adjustment] with `Adjustment.ofMinimum(minimum)`. */ + fun adjustment(minimum: NewMinimum) = adjustment(Adjustment.ofMinimum(minimum)) + + /** Alias for calling [adjustment] with `Adjustment.ofMaximum(maximum)`. */ + fun adjustment(maximum: NewMaximum) = adjustment(Adjustment.ofMaximum(maximum)) + + /** + * Alias for calling [adjustment] with the following: + * ```kotlin + * NewMaximum.builder() + * .adjustmentType(NewMaximum.AdjustmentType.MAXIMUM) + * .maximumAmount(maximumAmount) + * .build() + * ``` + */ + fun maximumAdjustment(maximumAmount: String) = + adjustment( + NewMaximum.builder() + .adjustmentType(NewMaximum.AdjustmentType.MAXIMUM) + .maximumAmount(maximumAmount) + .build() + ) + + /** The id of the adjustment on the plan to replace in the subscription. */ + fun replacesAdjustmentId(replacesAdjustmentId: String) = + replacesAdjustmentId(JsonField.of(replacesAdjustmentId)) + + /** + * Sets [Builder.replacesAdjustmentId] to an arbitrary JSON value. + * + * You should usually call [Builder.replacesAdjustmentId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun replacesAdjustmentId(replacesAdjustmentId: JsonField) = apply { + this.replacesAdjustmentId = replacesAdjustmentId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ReplaceAdjustment]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .adjustment() + * .replacesAdjustmentId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ReplaceAdjustment = + ReplaceAdjustment( + checkRequired("adjustment", adjustment), + checkRequired("replacesAdjustmentId", replacesAdjustmentId), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ReplaceAdjustment = apply { + if (validated) { + return@apply + } + + adjustment().validate() + replacesAdjustmentId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (adjustment.asKnown()?.validity() ?: 0) + + (if (replacesAdjustmentId.asKnown() == null) 0 else 1) + + /** The definition of a new adjustment to create and add to the subscription. */ + @JsonDeserialize(using = Adjustment.Deserializer::class) + @JsonSerialize(using = Adjustment.Serializer::class) + class Adjustment + private constructor( + private val percentageDiscount: NewPercentageDiscount? = null, + private val usageDiscount: NewUsageDiscount? = null, + private val amountDiscount: NewAmountDiscount? = null, + private val minimum: NewMinimum? = null, + private val maximum: NewMaximum? = null, + private val _json: JsonValue? = null, + ) { + + fun percentageDiscount(): NewPercentageDiscount? = percentageDiscount + + fun usageDiscount(): NewUsageDiscount? = usageDiscount + + fun amountDiscount(): NewAmountDiscount? = amountDiscount + + fun minimum(): NewMinimum? = minimum + + fun maximum(): NewMaximum? = maximum + + fun isPercentageDiscount(): Boolean = percentageDiscount != null + + fun isUsageDiscount(): Boolean = usageDiscount != null + + fun isAmountDiscount(): Boolean = amountDiscount != null + + fun isMinimum(): Boolean = minimum != null + + fun isMaximum(): Boolean = maximum != null + + fun asPercentageDiscount(): NewPercentageDiscount = + percentageDiscount.getOrThrow("percentageDiscount") + + fun asUsageDiscount(): NewUsageDiscount = usageDiscount.getOrThrow("usageDiscount") + + fun asAmountDiscount(): NewAmountDiscount = amountDiscount.getOrThrow("amountDiscount") + + fun asMinimum(): NewMinimum = minimum.getOrThrow("minimum") + + fun asMaximum(): NewMaximum = maximum.getOrThrow("maximum") + + fun _json(): JsonValue? = _json + + fun accept(visitor: Visitor): T = + when { + percentageDiscount != null -> + visitor.visitPercentageDiscount(percentageDiscount) + usageDiscount != null -> visitor.visitUsageDiscount(usageDiscount) + amountDiscount != null -> visitor.visitAmountDiscount(amountDiscount) + minimum != null -> visitor.visitMinimum(minimum) + maximum != null -> visitor.visitMaximum(maximum) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Adjustment = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitPercentageDiscount( + percentageDiscount: NewPercentageDiscount + ) { + percentageDiscount.validate() + } + + override fun visitUsageDiscount(usageDiscount: NewUsageDiscount) { + usageDiscount.validate() + } + + override fun visitAmountDiscount(amountDiscount: NewAmountDiscount) { + amountDiscount.validate() + } + + override fun visitMinimum(minimum: NewMinimum) { + minimum.validate() + } + + override fun visitMaximum(maximum: NewMaximum) { + maximum.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitPercentageDiscount( + percentageDiscount: NewPercentageDiscount + ) = percentageDiscount.validity() + + override fun visitUsageDiscount(usageDiscount: NewUsageDiscount) = + usageDiscount.validity() + + override fun visitAmountDiscount(amountDiscount: NewAmountDiscount) = + amountDiscount.validity() + + override fun visitMinimum(minimum: NewMinimum) = minimum.validity() + + override fun visitMaximum(maximum: NewMaximum) = maximum.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Adjustment && + percentageDiscount == other.percentageDiscount && + usageDiscount == other.usageDiscount && + amountDiscount == other.amountDiscount && + minimum == other.minimum && + maximum == other.maximum + } + + override fun hashCode(): Int = + Objects.hash(percentageDiscount, usageDiscount, amountDiscount, minimum, maximum) + + override fun toString(): String = + when { + percentageDiscount != null -> + "Adjustment{percentageDiscount=$percentageDiscount}" + usageDiscount != null -> "Adjustment{usageDiscount=$usageDiscount}" + amountDiscount != null -> "Adjustment{amountDiscount=$amountDiscount}" + minimum != null -> "Adjustment{minimum=$minimum}" + maximum != null -> "Adjustment{maximum=$maximum}" + _json != null -> "Adjustment{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Adjustment") + } + + companion object { + + fun ofPercentageDiscount(percentageDiscount: NewPercentageDiscount) = + Adjustment(percentageDiscount = percentageDiscount) + + fun ofUsageDiscount(usageDiscount: NewUsageDiscount) = + Adjustment(usageDiscount = usageDiscount) + + fun ofAmountDiscount(amountDiscount: NewAmountDiscount) = + Adjustment(amountDiscount = amountDiscount) + + fun ofMinimum(minimum: NewMinimum) = Adjustment(minimum = minimum) + + fun ofMaximum(maximum: NewMaximum) = Adjustment(maximum = maximum) + } + + /** + * An interface that defines how to map each variant of [Adjustment] to a value of type + * [T]. + */ + interface Visitor { + + fun visitPercentageDiscount(percentageDiscount: NewPercentageDiscount): T + + fun visitUsageDiscount(usageDiscount: NewUsageDiscount): T + + fun visitAmountDiscount(amountDiscount: NewAmountDiscount): T + + fun visitMinimum(minimum: NewMinimum): T + + fun visitMaximum(maximum: NewMaximum): T + + /** + * Maps an unknown variant of [Adjustment] to a value of type [T]. + * + * An instance of [Adjustment] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the + * SDK is unaware of. + * + * @throws OrbInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw OrbInvalidDataException("Unknown Adjustment: $json") + } + } + + internal class Deserializer : BaseDeserializer(Adjustment::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Adjustment { + val json = JsonValue.fromJsonNode(node) + val adjustmentType = json.asObject()?.get("adjustment_type")?.asString() + + when (adjustmentType) { + "percentage_discount" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Adjustment(percentageDiscount = it, _json = json) } + ?: Adjustment(_json = json) + } + "usage_discount" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(usageDiscount = it, _json = json) + } ?: Adjustment(_json = json) + } + "amount_discount" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(amountDiscount = it, _json = json) + } ?: Adjustment(_json = json) + } + "minimum" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(minimum = it, _json = json) + } ?: Adjustment(_json = json) + } + "maximum" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(maximum = it, _json = json) + } ?: Adjustment(_json = json) + } + } + + return Adjustment(_json = json) + } + } + + internal class Serializer : BaseSerializer(Adjustment::class) { + + override fun serialize( + value: Adjustment, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.percentageDiscount != null -> + generator.writeObject(value.percentageDiscount) + value.usageDiscount != null -> generator.writeObject(value.usageDiscount) + value.amountDiscount != null -> generator.writeObject(value.amountDiscount) + value.minimum != null -> generator.writeObject(value.minimum) + value.maximum != null -> generator.writeObject(value.maximum) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Adjustment") + } + } + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ReplaceAdjustment && + adjustment == other.adjustment && + replacesAdjustmentId == other.replacesAdjustmentId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(adjustment, replacesAdjustmentId, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ReplaceAdjustment{adjustment=$adjustment, replacesAdjustmentId=$replacesAdjustmentId, additionalProperties=$additionalProperties}" + } + + class ReplacePrice + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val replacesPriceId: JsonField, + private val allocationPrice: JsonField, + private val discounts: JsonField>, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val maximumAmount: JsonField, + private val minimumAmount: JsonField, + private val price: JsonField, + private val priceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("replaces_price_id") + @ExcludeMissing + replacesPriceId: JsonField = JsonMissing.of(), + @JsonProperty("allocation_price") + @ExcludeMissing + allocationPrice: JsonField = JsonMissing.of(), + @JsonProperty("discounts") + @ExcludeMissing + discounts: JsonField> = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("maximum_amount") + @ExcludeMissing + maximumAmount: JsonField = JsonMissing.of(), + @JsonProperty("minimum_amount") + @ExcludeMissing + minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("price") @ExcludeMissing price: JsonField = JsonMissing.of(), + @JsonProperty("price_id") @ExcludeMissing priceId: JsonField = JsonMissing.of(), + ) : this( + replacesPriceId, + allocationPrice, + discounts, + externalPriceId, + fixedPriceQuantity, + maximumAmount, + minimumAmount, + price, + priceId, + mutableMapOf(), + ) + + /** + * The id of the price on the plan to replace in the subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun replacesPriceId(): String = replacesPriceId.getRequired("replaces_price_id") + + /** + * The definition of a new allocation price to create and add to the subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun allocationPrice(): NewAllocationPrice? = allocationPrice.getNullable("allocation_price") + + /** + * [DEPRECATED] Use add_adjustments instead. The subscription's discounts for the + * replacement price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + @Deprecated("deprecated") + fun discounts(): List? = discounts.getNullable("discounts") + + /** + * The external price id of the price to add to the subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * The new quantity of the price, if the price is a fixed price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * [DEPRECATED] Use add_adjustments instead. The subscription's maximum amount for the + * replacement price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + @Deprecated("deprecated") + fun maximumAmount(): String? = maximumAmount.getNullable("maximum_amount") + + /** + * [DEPRECATED] Use add_adjustments instead. The subscription's minimum amount for the + * replacement price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + @Deprecated("deprecated") + fun minimumAmount(): String? = minimumAmount.getNullable("minimum_amount") + + /** + * New subscription price request body params. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun price(): Price? = price.getNullable("price") + + /** + * The id of the price to add to the subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun priceId(): String? = priceId.getNullable("price_id") + + /** + * Returns the raw JSON value of [replacesPriceId]. + * + * Unlike [replacesPriceId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("replaces_price_id") + @ExcludeMissing + fun _replacesPriceId(): JsonField = replacesPriceId + + /** + * Returns the raw JSON value of [allocationPrice]. + * + * Unlike [allocationPrice], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("allocation_price") + @ExcludeMissing + fun _allocationPrice(): JsonField = allocationPrice + + /** + * Returns the raw JSON value of [discounts]. + * + * Unlike [discounts], this method doesn't throw if the JSON field has an unexpected type. + */ + @Deprecated("deprecated") + @JsonProperty("discounts") + @ExcludeMissing + fun _discounts(): JsonField> = discounts + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [maximumAmount]. + * + * Unlike [maximumAmount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @Deprecated("deprecated") + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount + + /** + * Returns the raw JSON value of [minimumAmount]. + * + * Unlike [minimumAmount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @Deprecated("deprecated") + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount + + /** + * Returns the raw JSON value of [price]. + * + * Unlike [price], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("price") @ExcludeMissing fun _price(): JsonField = price + + /** + * Returns the raw JSON value of [priceId]. + * + * Unlike [priceId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ReplacePrice]. + * + * The following fields are required: + * ```kotlin + * .replacesPriceId() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [ReplacePrice]. */ + class Builder internal constructor() { + + private var replacesPriceId: JsonField? = null + private var allocationPrice: JsonField = JsonMissing.of() + private var discounts: JsonField>? = null + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var maximumAmount: JsonField = JsonMissing.of() + private var minimumAmount: JsonField = JsonMissing.of() + private var price: JsonField = JsonMissing.of() + private var priceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(replacePrice: ReplacePrice) = apply { + replacesPriceId = replacePrice.replacesPriceId + allocationPrice = replacePrice.allocationPrice + discounts = replacePrice.discounts.map { it.toMutableList() } + externalPriceId = replacePrice.externalPriceId + fixedPriceQuantity = replacePrice.fixedPriceQuantity + maximumAmount = replacePrice.maximumAmount + minimumAmount = replacePrice.minimumAmount + price = replacePrice.price + priceId = replacePrice.priceId + additionalProperties = replacePrice.additionalProperties.toMutableMap() + } + + /** The id of the price on the plan to replace in the subscription. */ + fun replacesPriceId(replacesPriceId: String) = + replacesPriceId(JsonField.of(replacesPriceId)) + + /** + * Sets [Builder.replacesPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.replacesPriceId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun replacesPriceId(replacesPriceId: JsonField) = apply { + this.replacesPriceId = replacesPriceId + } + + /** The definition of a new allocation price to create and add to the subscription. */ + fun allocationPrice(allocationPrice: NewAllocationPrice?) = + allocationPrice(JsonField.ofNullable(allocationPrice)) + + /** + * Sets [Builder.allocationPrice] to an arbitrary JSON value. + * + * You should usually call [Builder.allocationPrice] with a well-typed + * [NewAllocationPrice] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun allocationPrice(allocationPrice: JsonField) = apply { + this.allocationPrice = allocationPrice + } + + /** + * [DEPRECATED] Use add_adjustments instead. The subscription's discounts for the + * replacement price. + */ + @Deprecated("deprecated") + fun discounts(discounts: List?) = + discounts(JsonField.ofNullable(discounts)) + + /** + * Sets [Builder.discounts] to an arbitrary JSON value. + * + * You should usually call [Builder.discounts] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + @Deprecated("deprecated") + fun discounts(discounts: JsonField>) = apply { + this.discounts = discounts.map { it.toMutableList() } + } + + /** + * Adds a single [DiscountOverride] to [discounts]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + @Deprecated("deprecated") + fun addDiscount(discount: DiscountOverride) = apply { + discounts = + (discounts ?: JsonField.of(mutableListOf())).also { + checkKnown("discounts", it).add(discount) + } + } + + /** The external price id of the price to add to the subscription. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** The new quantity of the price, if the price is a fixed price. */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** + * [DEPRECATED] Use add_adjustments instead. The subscription's maximum amount for the + * replacement price. + */ + @Deprecated("deprecated") + fun maximumAmount(maximumAmount: String?) = + maximumAmount(JsonField.ofNullable(maximumAmount)) + + /** + * Sets [Builder.maximumAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.maximumAmount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + @Deprecated("deprecated") + fun maximumAmount(maximumAmount: JsonField) = apply { + this.maximumAmount = maximumAmount + } + + /** + * [DEPRECATED] Use add_adjustments instead. The subscription's minimum amount for the + * replacement price. + */ + @Deprecated("deprecated") + fun minimumAmount(minimumAmount: String?) = + minimumAmount(JsonField.ofNullable(minimumAmount)) + + /** + * Sets [Builder.minimumAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumAmount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + @Deprecated("deprecated") + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount + } + + /** New subscription price request body params. */ + fun price(price: Price?) = price(JsonField.ofNullable(price)) + + /** + * Sets [Builder.price] to an arbitrary JSON value. + * + * You should usually call [Builder.price] with a well-typed [Price] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun price(price: JsonField) = apply { this.price = price } + + /** Alias for calling [price] with `Price.ofUnit(unit)`. */ + fun price(unit: NewSubscriptionUnitPrice) = price(Price.ofUnit(unit)) + + /** Alias for calling [price] with `Price.ofTiered(tiered)`. */ + fun price(tiered: NewSubscriptionTieredPrice) = price(Price.ofTiered(tiered)) + + /** Alias for calling [price] with `Price.ofBulk(bulk)`. */ + fun price(bulk: NewSubscriptionBulkPrice) = price(Price.ofBulk(bulk)) + + /** Alias for calling [price] with `Price.ofBulkWithFilters(bulkWithFilters)`. */ + fun price(bulkWithFilters: Price.BulkWithFilters) = + price(Price.ofBulkWithFilters(bulkWithFilters)) + + /** Alias for calling [price] with `Price.ofPackage(package_)`. */ + fun price(package_: NewSubscriptionPackagePrice) = price(Price.ofPackage(package_)) + + /** Alias for calling [price] with `Price.ofMatrix(matrix)`. */ + fun price(matrix: NewSubscriptionMatrixPrice) = price(Price.ofMatrix(matrix)) + + /** + * Alias for calling [price] with `Price.ofThresholdTotalAmount(thresholdTotalAmount)`. + */ + fun price(thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice) = + price(Price.ofThresholdTotalAmount(thresholdTotalAmount)) + + /** Alias for calling [price] with `Price.ofTieredPackage(tieredPackage)`. */ + fun price(tieredPackage: NewSubscriptionTieredPackagePrice) = + price(Price.ofTieredPackage(tieredPackage)) + + /** Alias for calling [price] with `Price.ofTieredWithMinimum(tieredWithMinimum)`. */ + fun price(tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice) = + price(Price.ofTieredWithMinimum(tieredWithMinimum)) + + /** Alias for calling [price] with `Price.ofGroupedTiered(groupedTiered)`. */ + fun price(groupedTiered: NewSubscriptionGroupedTieredPrice) = + price(Price.ofGroupedTiered(groupedTiered)) + + /** + * Alias for calling [price] with + * `Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)`. + */ + fun price(tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice) = + price(Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)) + + /** + * Alias for calling [price] with + * `Price.ofPackageWithAllocation(packageWithAllocation)`. + */ + fun price(packageWithAllocation: NewSubscriptionPackageWithAllocationPrice) = + price(Price.ofPackageWithAllocation(packageWithAllocation)) + + /** Alias for calling [price] with `Price.ofUnitWithPercent(unitWithPercent)`. */ + fun price(unitWithPercent: NewSubscriptionUnitWithPercentPrice) = + price(Price.ofUnitWithPercent(unitWithPercent)) + + /** + * Alias for calling [price] with `Price.ofMatrixWithAllocation(matrixWithAllocation)`. + */ + fun price(matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice) = + price(Price.ofMatrixWithAllocation(matrixWithAllocation)) + + /** + * Alias for calling [price] with `Price.ofTieredWithProration(tieredWithProration)`. + */ + fun price(tieredWithProration: Price.TieredWithProration) = + price(Price.ofTieredWithProration(tieredWithProration)) + + /** Alias for calling [price] with `Price.ofUnitWithProration(unitWithProration)`. */ + fun price(unitWithProration: NewSubscriptionUnitWithProrationPrice) = + price(Price.ofUnitWithProration(unitWithProration)) + + /** Alias for calling [price] with `Price.ofGroupedAllocation(groupedAllocation)`. */ + fun price(groupedAllocation: NewSubscriptionGroupedAllocationPrice) = + price(Price.ofGroupedAllocation(groupedAllocation)) + + /** Alias for calling [price] with `Price.ofBulkWithProration(bulkWithProration)`. */ + fun price(bulkWithProration: NewSubscriptionBulkWithProrationPrice) = + price(Price.ofBulkWithProration(bulkWithProration)) + + /** + * Alias for calling [price] with + * `Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)`. + */ + fun price(groupedWithProratedMinimum: NewSubscriptionGroupedWithProratedMinimumPrice) = + price(Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)) + + /** + * Alias for calling [price] with + * `Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)`. + */ + fun price(groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice) = + price(Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)) + + /** + * Alias for calling [price] with + * `Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)`. + */ + fun price(groupedWithMinMaxThresholds: Price.GroupedWithMinMaxThresholds) = + price(Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)) + + /** + * Alias for calling [price] with + * `Price.ofMatrixWithDisplayName(matrixWithDisplayName)`. + */ + fun price(matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice) = + price(Price.ofMatrixWithDisplayName(matrixWithDisplayName)) + + /** + * Alias for calling [price] with `Price.ofGroupedTieredPackage(groupedTieredPackage)`. + */ + fun price(groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice) = + price(Price.ofGroupedTieredPackage(groupedTieredPackage)) + + /** + * Alias for calling [price] with + * `Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)`. + */ + fun price(maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice) = + price(Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)) + + /** + * Alias for calling [price] with + * `Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)`. + */ + fun price( + scalableMatrixWithUnitPricing: NewSubscriptionScalableMatrixWithUnitPricingPrice + ) = price(Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)) + + /** + * Alias for calling [price] with + * `Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)`. + */ + fun price( + scalableMatrixWithTieredPricing: NewSubscriptionScalableMatrixWithTieredPricingPrice + ) = price(Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)) + + /** + * Alias for calling [price] with + * `Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)`. + */ + fun price(cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice) = + price(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) + + /** Alias for calling [price] with `Price.ofMinimum(minimum)`. */ + fun price(minimum: NewSubscriptionMinimumCompositePrice) = + price(Price.ofMinimum(minimum)) + + /** Alias for calling [price] with `Price.ofPercent(percent)`. */ + fun price(percent: Price.Percent) = price(Price.ofPercent(percent)) + + /** Alias for calling [price] with `Price.ofEventOutput(eventOutput)`. */ + fun price(eventOutput: Price.EventOutput) = price(Price.ofEventOutput(eventOutput)) + + /** The id of the price to add to the subscription. */ + fun priceId(priceId: String?) = priceId(JsonField.ofNullable(priceId)) + + /** + * Sets [Builder.priceId] to an arbitrary JSON value. + * + * You should usually call [Builder.priceId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun priceId(priceId: JsonField) = apply { this.priceId = priceId } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ReplacePrice]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .replacesPriceId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ReplacePrice = + ReplacePrice( + checkRequired("replacesPriceId", replacesPriceId), + allocationPrice, + (discounts ?: JsonMissing.of()).map { it.toImmutable() }, + externalPriceId, + fixedPriceQuantity, + maximumAmount, + minimumAmount, + price, + priceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ReplacePrice = apply { + if (validated) { + return@apply + } + + replacesPriceId() + allocationPrice()?.validate() + discounts()?.forEach { it.validate() } + externalPriceId() + fixedPriceQuantity() + maximumAmount() + minimumAmount() + price()?.validate() + priceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (replacesPriceId.asKnown() == null) 0 else 1) + + (allocationPrice.asKnown()?.validity() ?: 0) + + (discounts.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (maximumAmount.asKnown() == null) 0 else 1) + + (if (minimumAmount.asKnown() == null) 0 else 1) + + (price.asKnown()?.validity() ?: 0) + + (if (priceId.asKnown() == null) 0 else 1) + + /** New subscription price request body params. */ + @JsonDeserialize(using = Price.Deserializer::class) + @JsonSerialize(using = Price.Serializer::class) + class Price + private constructor( + private val unit: NewSubscriptionUnitPrice? = null, + private val tiered: NewSubscriptionTieredPrice? = null, + private val bulk: NewSubscriptionBulkPrice? = null, + private val bulkWithFilters: BulkWithFilters? = null, + private val package_: NewSubscriptionPackagePrice? = null, + private val matrix: NewSubscriptionMatrixPrice? = null, + private val thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice? = null, + private val tieredPackage: NewSubscriptionTieredPackagePrice? = null, + private val tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice? = null, + private val groupedTiered: NewSubscriptionGroupedTieredPrice? = null, + private val tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice? = + null, + private val packageWithAllocation: NewSubscriptionPackageWithAllocationPrice? = null, + private val unitWithPercent: NewSubscriptionUnitWithPercentPrice? = null, + private val matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice? = null, + private val tieredWithProration: TieredWithProration? = null, + private val unitWithProration: NewSubscriptionUnitWithProrationPrice? = null, + private val groupedAllocation: NewSubscriptionGroupedAllocationPrice? = null, + private val bulkWithProration: NewSubscriptionBulkWithProrationPrice? = null, + private val groupedWithProratedMinimum: + NewSubscriptionGroupedWithProratedMinimumPrice? = + null, + private val groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice? = + null, + private val groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds? = null, + private val matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice? = null, + private val groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice? = null, + private val maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice? = null, + private val scalableMatrixWithUnitPricing: + NewSubscriptionScalableMatrixWithUnitPricingPrice? = + null, + private val scalableMatrixWithTieredPricing: + NewSubscriptionScalableMatrixWithTieredPricingPrice? = + null, + private val cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice? = null, + private val minimum: NewSubscriptionMinimumCompositePrice? = null, + private val percent: Percent? = null, + private val eventOutput: EventOutput? = null, + private val _json: JsonValue? = null, + ) { + + fun unit(): NewSubscriptionUnitPrice? = unit + + fun tiered(): NewSubscriptionTieredPrice? = tiered + + fun bulk(): NewSubscriptionBulkPrice? = bulk + + fun bulkWithFilters(): BulkWithFilters? = bulkWithFilters + + fun package_(): NewSubscriptionPackagePrice? = package_ + + fun matrix(): NewSubscriptionMatrixPrice? = matrix + + fun thresholdTotalAmount(): NewSubscriptionThresholdTotalAmountPrice? = + thresholdTotalAmount + + fun tieredPackage(): NewSubscriptionTieredPackagePrice? = tieredPackage + + fun tieredWithMinimum(): NewSubscriptionTieredWithMinimumPrice? = tieredWithMinimum + + fun groupedTiered(): NewSubscriptionGroupedTieredPrice? = groupedTiered + + fun tieredPackageWithMinimum(): NewSubscriptionTieredPackageWithMinimumPrice? = + tieredPackageWithMinimum + + fun packageWithAllocation(): NewSubscriptionPackageWithAllocationPrice? = + packageWithAllocation + + fun unitWithPercent(): NewSubscriptionUnitWithPercentPrice? = unitWithPercent + + fun matrixWithAllocation(): NewSubscriptionMatrixWithAllocationPrice? = + matrixWithAllocation + + fun tieredWithProration(): TieredWithProration? = tieredWithProration + + fun unitWithProration(): NewSubscriptionUnitWithProrationPrice? = unitWithProration + + fun groupedAllocation(): NewSubscriptionGroupedAllocationPrice? = groupedAllocation + + fun bulkWithProration(): NewSubscriptionBulkWithProrationPrice? = bulkWithProration + + fun groupedWithProratedMinimum(): NewSubscriptionGroupedWithProratedMinimumPrice? = + groupedWithProratedMinimum + + fun groupedWithMeteredMinimum(): NewSubscriptionGroupedWithMeteredMinimumPrice? = + groupedWithMeteredMinimum + + fun groupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds? = + groupedWithMinMaxThresholds + + fun matrixWithDisplayName(): NewSubscriptionMatrixWithDisplayNamePrice? = + matrixWithDisplayName + + fun groupedTieredPackage(): NewSubscriptionGroupedTieredPackagePrice? = + groupedTieredPackage + + fun maxGroupTieredPackage(): NewSubscriptionMaxGroupTieredPackagePrice? = + maxGroupTieredPackage + + fun scalableMatrixWithUnitPricing(): + NewSubscriptionScalableMatrixWithUnitPricingPrice? = scalableMatrixWithUnitPricing + + fun scalableMatrixWithTieredPricing(): + NewSubscriptionScalableMatrixWithTieredPricingPrice? = + scalableMatrixWithTieredPricing + + fun cumulativeGroupedBulk(): NewSubscriptionCumulativeGroupedBulkPrice? = + cumulativeGroupedBulk + + fun minimum(): NewSubscriptionMinimumCompositePrice? = minimum + + fun percent(): Percent? = percent + + fun eventOutput(): EventOutput? = eventOutput + + fun isUnit(): Boolean = unit != null + + fun isTiered(): Boolean = tiered != null + + fun isBulk(): Boolean = bulk != null + + fun isBulkWithFilters(): Boolean = bulkWithFilters != null + + fun isPackage(): Boolean = package_ != null + + fun isMatrix(): Boolean = matrix != null + + fun isThresholdTotalAmount(): Boolean = thresholdTotalAmount != null + + fun isTieredPackage(): Boolean = tieredPackage != null + + fun isTieredWithMinimum(): Boolean = tieredWithMinimum != null + + fun isGroupedTiered(): Boolean = groupedTiered != null + + fun isTieredPackageWithMinimum(): Boolean = tieredPackageWithMinimum != null + + fun isPackageWithAllocation(): Boolean = packageWithAllocation != null + + fun isUnitWithPercent(): Boolean = unitWithPercent != null + + fun isMatrixWithAllocation(): Boolean = matrixWithAllocation != null + + fun isTieredWithProration(): Boolean = tieredWithProration != null + + fun isUnitWithProration(): Boolean = unitWithProration != null + + fun isGroupedAllocation(): Boolean = groupedAllocation != null + + fun isBulkWithProration(): Boolean = bulkWithProration != null + + fun isGroupedWithProratedMinimum(): Boolean = groupedWithProratedMinimum != null + + fun isGroupedWithMeteredMinimum(): Boolean = groupedWithMeteredMinimum != null + + fun isGroupedWithMinMaxThresholds(): Boolean = groupedWithMinMaxThresholds != null + + fun isMatrixWithDisplayName(): Boolean = matrixWithDisplayName != null + + fun isGroupedTieredPackage(): Boolean = groupedTieredPackage != null + + fun isMaxGroupTieredPackage(): Boolean = maxGroupTieredPackage != null + + fun isScalableMatrixWithUnitPricing(): Boolean = scalableMatrixWithUnitPricing != null + + fun isScalableMatrixWithTieredPricing(): Boolean = + scalableMatrixWithTieredPricing != null + + fun isCumulativeGroupedBulk(): Boolean = cumulativeGroupedBulk != null + + fun isMinimum(): Boolean = minimum != null + + fun isPercent(): Boolean = percent != null + + fun isEventOutput(): Boolean = eventOutput != null + + fun asUnit(): NewSubscriptionUnitPrice = unit.getOrThrow("unit") + + fun asTiered(): NewSubscriptionTieredPrice = tiered.getOrThrow("tiered") + + fun asBulk(): NewSubscriptionBulkPrice = bulk.getOrThrow("bulk") + + fun asBulkWithFilters(): BulkWithFilters = bulkWithFilters.getOrThrow("bulkWithFilters") + + fun asPackage(): NewSubscriptionPackagePrice = package_.getOrThrow("package_") + + fun asMatrix(): NewSubscriptionMatrixPrice = matrix.getOrThrow("matrix") + + fun asThresholdTotalAmount(): NewSubscriptionThresholdTotalAmountPrice = + thresholdTotalAmount.getOrThrow("thresholdTotalAmount") + + fun asTieredPackage(): NewSubscriptionTieredPackagePrice = + tieredPackage.getOrThrow("tieredPackage") + + fun asTieredWithMinimum(): NewSubscriptionTieredWithMinimumPrice = + tieredWithMinimum.getOrThrow("tieredWithMinimum") + + fun asGroupedTiered(): NewSubscriptionGroupedTieredPrice = + groupedTiered.getOrThrow("groupedTiered") + + fun asTieredPackageWithMinimum(): NewSubscriptionTieredPackageWithMinimumPrice = + tieredPackageWithMinimum.getOrThrow("tieredPackageWithMinimum") + + fun asPackageWithAllocation(): NewSubscriptionPackageWithAllocationPrice = + packageWithAllocation.getOrThrow("packageWithAllocation") + + fun asUnitWithPercent(): NewSubscriptionUnitWithPercentPrice = + unitWithPercent.getOrThrow("unitWithPercent") + + fun asMatrixWithAllocation(): NewSubscriptionMatrixWithAllocationPrice = + matrixWithAllocation.getOrThrow("matrixWithAllocation") + + fun asTieredWithProration(): TieredWithProration = + tieredWithProration.getOrThrow("tieredWithProration") + + fun asUnitWithProration(): NewSubscriptionUnitWithProrationPrice = + unitWithProration.getOrThrow("unitWithProration") + + fun asGroupedAllocation(): NewSubscriptionGroupedAllocationPrice = + groupedAllocation.getOrThrow("groupedAllocation") + + fun asBulkWithProration(): NewSubscriptionBulkWithProrationPrice = + bulkWithProration.getOrThrow("bulkWithProration") + + fun asGroupedWithProratedMinimum(): NewSubscriptionGroupedWithProratedMinimumPrice = + groupedWithProratedMinimum.getOrThrow("groupedWithProratedMinimum") + + fun asGroupedWithMeteredMinimum(): NewSubscriptionGroupedWithMeteredMinimumPrice = + groupedWithMeteredMinimum.getOrThrow("groupedWithMeteredMinimum") + + fun asGroupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds = + groupedWithMinMaxThresholds.getOrThrow("groupedWithMinMaxThresholds") + + fun asMatrixWithDisplayName(): NewSubscriptionMatrixWithDisplayNamePrice = + matrixWithDisplayName.getOrThrow("matrixWithDisplayName") + + fun asGroupedTieredPackage(): NewSubscriptionGroupedTieredPackagePrice = + groupedTieredPackage.getOrThrow("groupedTieredPackage") + + fun asMaxGroupTieredPackage(): NewSubscriptionMaxGroupTieredPackagePrice = + maxGroupTieredPackage.getOrThrow("maxGroupTieredPackage") + + fun asScalableMatrixWithUnitPricing(): + NewSubscriptionScalableMatrixWithUnitPricingPrice = + scalableMatrixWithUnitPricing.getOrThrow("scalableMatrixWithUnitPricing") + + fun asScalableMatrixWithTieredPricing(): + NewSubscriptionScalableMatrixWithTieredPricingPrice = + scalableMatrixWithTieredPricing.getOrThrow("scalableMatrixWithTieredPricing") + + fun asCumulativeGroupedBulk(): NewSubscriptionCumulativeGroupedBulkPrice = + cumulativeGroupedBulk.getOrThrow("cumulativeGroupedBulk") + + fun asMinimum(): NewSubscriptionMinimumCompositePrice = minimum.getOrThrow("minimum") + + fun asPercent(): Percent = percent.getOrThrow("percent") + + fun asEventOutput(): EventOutput = eventOutput.getOrThrow("eventOutput") + + fun _json(): JsonValue? = _json + + fun accept(visitor: Visitor): T = + when { + unit != null -> visitor.visitUnit(unit) + tiered != null -> visitor.visitTiered(tiered) + bulk != null -> visitor.visitBulk(bulk) + bulkWithFilters != null -> visitor.visitBulkWithFilters(bulkWithFilters) + package_ != null -> visitor.visitPackage(package_) + matrix != null -> visitor.visitMatrix(matrix) + thresholdTotalAmount != null -> + visitor.visitThresholdTotalAmount(thresholdTotalAmount) + tieredPackage != null -> visitor.visitTieredPackage(tieredPackage) + tieredWithMinimum != null -> visitor.visitTieredWithMinimum(tieredWithMinimum) + groupedTiered != null -> visitor.visitGroupedTiered(groupedTiered) + tieredPackageWithMinimum != null -> + visitor.visitTieredPackageWithMinimum(tieredPackageWithMinimum) + packageWithAllocation != null -> + visitor.visitPackageWithAllocation(packageWithAllocation) + unitWithPercent != null -> visitor.visitUnitWithPercent(unitWithPercent) + matrixWithAllocation != null -> + visitor.visitMatrixWithAllocation(matrixWithAllocation) + tieredWithProration != null -> + visitor.visitTieredWithProration(tieredWithProration) + unitWithProration != null -> visitor.visitUnitWithProration(unitWithProration) + groupedAllocation != null -> visitor.visitGroupedAllocation(groupedAllocation) + bulkWithProration != null -> visitor.visitBulkWithProration(bulkWithProration) + groupedWithProratedMinimum != null -> + visitor.visitGroupedWithProratedMinimum(groupedWithProratedMinimum) + groupedWithMeteredMinimum != null -> + visitor.visitGroupedWithMeteredMinimum(groupedWithMeteredMinimum) + groupedWithMinMaxThresholds != null -> + visitor.visitGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds) + matrixWithDisplayName != null -> + visitor.visitMatrixWithDisplayName(matrixWithDisplayName) + groupedTieredPackage != null -> + visitor.visitGroupedTieredPackage(groupedTieredPackage) + maxGroupTieredPackage != null -> + visitor.visitMaxGroupTieredPackage(maxGroupTieredPackage) + scalableMatrixWithUnitPricing != null -> + visitor.visitScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing) + scalableMatrixWithTieredPricing != null -> + visitor.visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing + ) + cumulativeGroupedBulk != null -> + visitor.visitCumulativeGroupedBulk(cumulativeGroupedBulk) + minimum != null -> visitor.visitMinimum(minimum) + percent != null -> visitor.visitPercent(percent) + eventOutput != null -> visitor.visitEventOutput(eventOutput) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Price = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitUnit(unit: NewSubscriptionUnitPrice) { + unit.validate() + } + + override fun visitTiered(tiered: NewSubscriptionTieredPrice) { + tiered.validate() + } + + override fun visitBulk(bulk: NewSubscriptionBulkPrice) { + bulk.validate() + } + + override fun visitBulkWithFilters(bulkWithFilters: BulkWithFilters) { + bulkWithFilters.validate() + } + + override fun visitPackage(package_: NewSubscriptionPackagePrice) { + package_.validate() + } + + override fun visitMatrix(matrix: NewSubscriptionMatrixPrice) { + matrix.validate() + } + + override fun visitThresholdTotalAmount( + thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice + ) { + thresholdTotalAmount.validate() + } + + override fun visitTieredPackage( + tieredPackage: NewSubscriptionTieredPackagePrice + ) { + tieredPackage.validate() + } + + override fun visitTieredWithMinimum( + tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice + ) { + tieredWithMinimum.validate() + } + + override fun visitGroupedTiered( + groupedTiered: NewSubscriptionGroupedTieredPrice + ) { + groupedTiered.validate() + } + + override fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice + ) { + tieredPackageWithMinimum.validate() + } + + override fun visitPackageWithAllocation( + packageWithAllocation: NewSubscriptionPackageWithAllocationPrice + ) { + packageWithAllocation.validate() + } + + override fun visitUnitWithPercent( + unitWithPercent: NewSubscriptionUnitWithPercentPrice + ) { + unitWithPercent.validate() + } + + override fun visitMatrixWithAllocation( + matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice + ) { + matrixWithAllocation.validate() + } + + override fun visitTieredWithProration( + tieredWithProration: TieredWithProration + ) { + tieredWithProration.validate() + } + + override fun visitUnitWithProration( + unitWithProration: NewSubscriptionUnitWithProrationPrice + ) { + unitWithProration.validate() + } + + override fun visitGroupedAllocation( + groupedAllocation: NewSubscriptionGroupedAllocationPrice + ) { + groupedAllocation.validate() + } + + override fun visitBulkWithProration( + bulkWithProration: NewSubscriptionBulkWithProrationPrice + ) { + bulkWithProration.validate() + } + + override fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: + NewSubscriptionGroupedWithProratedMinimumPrice + ) { + groupedWithProratedMinimum.validate() + } + + override fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice + ) { + groupedWithMeteredMinimum.validate() + } + + override fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) { + groupedWithMinMaxThresholds.validate() + } + + override fun visitMatrixWithDisplayName( + matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice + ) { + matrixWithDisplayName.validate() + } + + override fun visitGroupedTieredPackage( + groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice + ) { + groupedTieredPackage.validate() + } + + override fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice + ) { + maxGroupTieredPackage.validate() + } + + override fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: + NewSubscriptionScalableMatrixWithUnitPricingPrice + ) { + scalableMatrixWithUnitPricing.validate() + } + + override fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: + NewSubscriptionScalableMatrixWithTieredPricingPrice + ) { + scalableMatrixWithTieredPricing.validate() + } + + override fun visitCumulativeGroupedBulk( + cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice + ) { + cumulativeGroupedBulk.validate() + } + + override fun visitMinimum(minimum: NewSubscriptionMinimumCompositePrice) { + minimum.validate() + } + + override fun visitPercent(percent: Percent) { + percent.validate() + } + + override fun visitEventOutput(eventOutput: EventOutput) { + eventOutput.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitUnit(unit: NewSubscriptionUnitPrice) = unit.validity() + + override fun visitTiered(tiered: NewSubscriptionTieredPrice) = + tiered.validity() + + override fun visitBulk(bulk: NewSubscriptionBulkPrice) = bulk.validity() + + override fun visitBulkWithFilters(bulkWithFilters: BulkWithFilters) = + bulkWithFilters.validity() + + override fun visitPackage(package_: NewSubscriptionPackagePrice) = + package_.validity() + + override fun visitMatrix(matrix: NewSubscriptionMatrixPrice) = + matrix.validity() + + override fun visitThresholdTotalAmount( + thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice + ) = thresholdTotalAmount.validity() + + override fun visitTieredPackage( + tieredPackage: NewSubscriptionTieredPackagePrice + ) = tieredPackage.validity() + + override fun visitTieredWithMinimum( + tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice + ) = tieredWithMinimum.validity() + + override fun visitGroupedTiered( + groupedTiered: NewSubscriptionGroupedTieredPrice + ) = groupedTiered.validity() + + override fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice + ) = tieredPackageWithMinimum.validity() + + override fun visitPackageWithAllocation( + packageWithAllocation: NewSubscriptionPackageWithAllocationPrice + ) = packageWithAllocation.validity() + + override fun visitUnitWithPercent( + unitWithPercent: NewSubscriptionUnitWithPercentPrice + ) = unitWithPercent.validity() + + override fun visitMatrixWithAllocation( + matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice + ) = matrixWithAllocation.validity() + + override fun visitTieredWithProration( + tieredWithProration: TieredWithProration + ) = tieredWithProration.validity() + + override fun visitUnitWithProration( + unitWithProration: NewSubscriptionUnitWithProrationPrice + ) = unitWithProration.validity() + + override fun visitGroupedAllocation( + groupedAllocation: NewSubscriptionGroupedAllocationPrice + ) = groupedAllocation.validity() + + override fun visitBulkWithProration( + bulkWithProration: NewSubscriptionBulkWithProrationPrice + ) = bulkWithProration.validity() + + override fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: + NewSubscriptionGroupedWithProratedMinimumPrice + ) = groupedWithProratedMinimum.validity() + + override fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice + ) = groupedWithMeteredMinimum.validity() + + override fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) = groupedWithMinMaxThresholds.validity() + + override fun visitMatrixWithDisplayName( + matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice + ) = matrixWithDisplayName.validity() + + override fun visitGroupedTieredPackage( + groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice + ) = groupedTieredPackage.validity() + + override fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice + ) = maxGroupTieredPackage.validity() + + override fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: + NewSubscriptionScalableMatrixWithUnitPricingPrice + ) = scalableMatrixWithUnitPricing.validity() + + override fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: + NewSubscriptionScalableMatrixWithTieredPricingPrice + ) = scalableMatrixWithTieredPricing.validity() + + override fun visitCumulativeGroupedBulk( + cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice + ) = cumulativeGroupedBulk.validity() + + override fun visitMinimum(minimum: NewSubscriptionMinimumCompositePrice) = + minimum.validity() + + override fun visitPercent(percent: Percent) = percent.validity() + + override fun visitEventOutput(eventOutput: EventOutput) = + eventOutput.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Price && + unit == other.unit && + tiered == other.tiered && + bulk == other.bulk && + bulkWithFilters == other.bulkWithFilters && + package_ == other.package_ && + matrix == other.matrix && + thresholdTotalAmount == other.thresholdTotalAmount && + tieredPackage == other.tieredPackage && + tieredWithMinimum == other.tieredWithMinimum && + groupedTiered == other.groupedTiered && + tieredPackageWithMinimum == other.tieredPackageWithMinimum && + packageWithAllocation == other.packageWithAllocation && + unitWithPercent == other.unitWithPercent && + matrixWithAllocation == other.matrixWithAllocation && + tieredWithProration == other.tieredWithProration && + unitWithProration == other.unitWithProration && + groupedAllocation == other.groupedAllocation && + bulkWithProration == other.bulkWithProration && + groupedWithProratedMinimum == other.groupedWithProratedMinimum && + groupedWithMeteredMinimum == other.groupedWithMeteredMinimum && + groupedWithMinMaxThresholds == other.groupedWithMinMaxThresholds && + matrixWithDisplayName == other.matrixWithDisplayName && + groupedTieredPackage == other.groupedTieredPackage && + maxGroupTieredPackage == other.maxGroupTieredPackage && + scalableMatrixWithUnitPricing == other.scalableMatrixWithUnitPricing && + scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && + cumulativeGroupedBulk == other.cumulativeGroupedBulk && + minimum == other.minimum && + percent == other.percent && + eventOutput == other.eventOutput + } + + override fun hashCode(): Int = + Objects.hash( + unit, + tiered, + bulk, + bulkWithFilters, + package_, + matrix, + thresholdTotalAmount, + tieredPackage, + tieredWithMinimum, + groupedTiered, + tieredPackageWithMinimum, + packageWithAllocation, + unitWithPercent, + matrixWithAllocation, + tieredWithProration, + unitWithProration, + groupedAllocation, + bulkWithProration, + groupedWithProratedMinimum, + groupedWithMeteredMinimum, + groupedWithMinMaxThresholds, + matrixWithDisplayName, + groupedTieredPackage, + maxGroupTieredPackage, + scalableMatrixWithUnitPricing, + scalableMatrixWithTieredPricing, + cumulativeGroupedBulk, + minimum, + percent, + eventOutput, + ) + + override fun toString(): String = + when { + unit != null -> "Price{unit=$unit}" + tiered != null -> "Price{tiered=$tiered}" + bulk != null -> "Price{bulk=$bulk}" + bulkWithFilters != null -> "Price{bulkWithFilters=$bulkWithFilters}" + package_ != null -> "Price{package_=$package_}" + matrix != null -> "Price{matrix=$matrix}" + thresholdTotalAmount != null -> + "Price{thresholdTotalAmount=$thresholdTotalAmount}" + tieredPackage != null -> "Price{tieredPackage=$tieredPackage}" + tieredWithMinimum != null -> "Price{tieredWithMinimum=$tieredWithMinimum}" + groupedTiered != null -> "Price{groupedTiered=$groupedTiered}" + tieredPackageWithMinimum != null -> + "Price{tieredPackageWithMinimum=$tieredPackageWithMinimum}" + packageWithAllocation != null -> + "Price{packageWithAllocation=$packageWithAllocation}" + unitWithPercent != null -> "Price{unitWithPercent=$unitWithPercent}" + matrixWithAllocation != null -> + "Price{matrixWithAllocation=$matrixWithAllocation}" + tieredWithProration != null -> "Price{tieredWithProration=$tieredWithProration}" + unitWithProration != null -> "Price{unitWithProration=$unitWithProration}" + groupedAllocation != null -> "Price{groupedAllocation=$groupedAllocation}" + bulkWithProration != null -> "Price{bulkWithProration=$bulkWithProration}" + groupedWithProratedMinimum != null -> + "Price{groupedWithProratedMinimum=$groupedWithProratedMinimum}" + groupedWithMeteredMinimum != null -> + "Price{groupedWithMeteredMinimum=$groupedWithMeteredMinimum}" + groupedWithMinMaxThresholds != null -> + "Price{groupedWithMinMaxThresholds=$groupedWithMinMaxThresholds}" + matrixWithDisplayName != null -> + "Price{matrixWithDisplayName=$matrixWithDisplayName}" + groupedTieredPackage != null -> + "Price{groupedTieredPackage=$groupedTieredPackage}" + maxGroupTieredPackage != null -> + "Price{maxGroupTieredPackage=$maxGroupTieredPackage}" + scalableMatrixWithUnitPricing != null -> + "Price{scalableMatrixWithUnitPricing=$scalableMatrixWithUnitPricing}" + scalableMatrixWithTieredPricing != null -> + "Price{scalableMatrixWithTieredPricing=$scalableMatrixWithTieredPricing}" + cumulativeGroupedBulk != null -> + "Price{cumulativeGroupedBulk=$cumulativeGroupedBulk}" + minimum != null -> "Price{minimum=$minimum}" + percent != null -> "Price{percent=$percent}" + eventOutput != null -> "Price{eventOutput=$eventOutput}" + _json != null -> "Price{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Price") + } + + companion object { + + fun ofUnit(unit: NewSubscriptionUnitPrice) = Price(unit = unit) + + fun ofTiered(tiered: NewSubscriptionTieredPrice) = Price(tiered = tiered) + + fun ofBulk(bulk: NewSubscriptionBulkPrice) = Price(bulk = bulk) + + fun ofBulkWithFilters(bulkWithFilters: BulkWithFilters) = + Price(bulkWithFilters = bulkWithFilters) + + fun ofPackage(package_: NewSubscriptionPackagePrice) = Price(package_ = package_) + + fun ofMatrix(matrix: NewSubscriptionMatrixPrice) = Price(matrix = matrix) + + fun ofThresholdTotalAmount( + thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice + ) = Price(thresholdTotalAmount = thresholdTotalAmount) + + fun ofTieredPackage(tieredPackage: NewSubscriptionTieredPackagePrice) = + Price(tieredPackage = tieredPackage) + + fun ofTieredWithMinimum(tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice) = + Price(tieredWithMinimum = tieredWithMinimum) + + fun ofGroupedTiered(groupedTiered: NewSubscriptionGroupedTieredPrice) = + Price(groupedTiered = groupedTiered) + + fun ofTieredPackageWithMinimum( + tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice + ) = Price(tieredPackageWithMinimum = tieredPackageWithMinimum) + + fun ofPackageWithAllocation( + packageWithAllocation: NewSubscriptionPackageWithAllocationPrice + ) = Price(packageWithAllocation = packageWithAllocation) + + fun ofUnitWithPercent(unitWithPercent: NewSubscriptionUnitWithPercentPrice) = + Price(unitWithPercent = unitWithPercent) + + fun ofMatrixWithAllocation( + matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice + ) = Price(matrixWithAllocation = matrixWithAllocation) + + fun ofTieredWithProration(tieredWithProration: TieredWithProration) = + Price(tieredWithProration = tieredWithProration) + + fun ofUnitWithProration(unitWithProration: NewSubscriptionUnitWithProrationPrice) = + Price(unitWithProration = unitWithProration) + + fun ofGroupedAllocation(groupedAllocation: NewSubscriptionGroupedAllocationPrice) = + Price(groupedAllocation = groupedAllocation) + + fun ofBulkWithProration(bulkWithProration: NewSubscriptionBulkWithProrationPrice) = + Price(bulkWithProration = bulkWithProration) + + fun ofGroupedWithProratedMinimum( + groupedWithProratedMinimum: NewSubscriptionGroupedWithProratedMinimumPrice + ) = Price(groupedWithProratedMinimum = groupedWithProratedMinimum) + + fun ofGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice + ) = Price(groupedWithMeteredMinimum = groupedWithMeteredMinimum) + + fun ofGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) = Price(groupedWithMinMaxThresholds = groupedWithMinMaxThresholds) + + fun ofMatrixWithDisplayName( + matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice + ) = Price(matrixWithDisplayName = matrixWithDisplayName) + + fun ofGroupedTieredPackage( + groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice + ) = Price(groupedTieredPackage = groupedTieredPackage) + + fun ofMaxGroupTieredPackage( + maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice + ) = Price(maxGroupTieredPackage = maxGroupTieredPackage) + + fun ofScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: NewSubscriptionScalableMatrixWithUnitPricingPrice + ) = Price(scalableMatrixWithUnitPricing = scalableMatrixWithUnitPricing) + + fun ofScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: + NewSubscriptionScalableMatrixWithTieredPricingPrice + ) = Price(scalableMatrixWithTieredPricing = scalableMatrixWithTieredPricing) + + fun ofCumulativeGroupedBulk( + cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice + ) = Price(cumulativeGroupedBulk = cumulativeGroupedBulk) + + fun ofMinimum(minimum: NewSubscriptionMinimumCompositePrice) = + Price(minimum = minimum) + + fun ofPercent(percent: Percent) = Price(percent = percent) + + fun ofEventOutput(eventOutput: EventOutput) = Price(eventOutput = eventOutput) + } + + /** + * An interface that defines how to map each variant of [Price] to a value of type [T]. + */ + interface Visitor { + + fun visitUnit(unit: NewSubscriptionUnitPrice): T + + fun visitTiered(tiered: NewSubscriptionTieredPrice): T + + fun visitBulk(bulk: NewSubscriptionBulkPrice): T + + fun visitBulkWithFilters(bulkWithFilters: BulkWithFilters): T + + fun visitPackage(package_: NewSubscriptionPackagePrice): T + + fun visitMatrix(matrix: NewSubscriptionMatrixPrice): T + + fun visitThresholdTotalAmount( + thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice + ): T + + fun visitTieredPackage(tieredPackage: NewSubscriptionTieredPackagePrice): T + + fun visitTieredWithMinimum( + tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice + ): T + + fun visitGroupedTiered(groupedTiered: NewSubscriptionGroupedTieredPrice): T + + fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice + ): T + + fun visitPackageWithAllocation( + packageWithAllocation: NewSubscriptionPackageWithAllocationPrice + ): T + + fun visitUnitWithPercent(unitWithPercent: NewSubscriptionUnitWithPercentPrice): T + + fun visitMatrixWithAllocation( + matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice + ): T + + fun visitTieredWithProration(tieredWithProration: TieredWithProration): T + + fun visitUnitWithProration( + unitWithProration: NewSubscriptionUnitWithProrationPrice + ): T + + fun visitGroupedAllocation( + groupedAllocation: NewSubscriptionGroupedAllocationPrice + ): T + + fun visitBulkWithProration( + bulkWithProration: NewSubscriptionBulkWithProrationPrice + ): T + + fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: NewSubscriptionGroupedWithProratedMinimumPrice + ): T + + fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice + ): T + + fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ): T + + fun visitMatrixWithDisplayName( + matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice + ): T + + fun visitGroupedTieredPackage( + groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice + ): T + + fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice + ): T + + fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: NewSubscriptionScalableMatrixWithUnitPricingPrice + ): T + + fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: + NewSubscriptionScalableMatrixWithTieredPricingPrice + ): T + + fun visitCumulativeGroupedBulk( + cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice + ): T + + fun visitMinimum(minimum: NewSubscriptionMinimumCompositePrice): T + + fun visitPercent(percent: Percent): T + + fun visitEventOutput(eventOutput: EventOutput): T + + /** + * Maps an unknown variant of [Price] to a value of type [T]. + * + * An instance of [Price] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is + * unaware of. + * + * @throws OrbInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw OrbInvalidDataException("Unknown Price: $json") + } + } + + internal class Deserializer : BaseDeserializer(Price::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Price { + val json = JsonValue.fromJsonNode(node) + val modelType = json.asObject()?.get("model_type")?.asString() + + when (modelType) { + "unit" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(unit = it, _json = json) } ?: Price(_json = json) + } + "tiered" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(tiered = it, _json = json) } ?: Price(_json = json) + } + "bulk" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(bulk = it, _json = json) } ?: Price(_json = json) + } + "bulk_with_filters" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(bulkWithFilters = it, _json = json) + } ?: Price(_json = json) + } + "package" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(package_ = it, _json = json) } ?: Price(_json = json) + } + "matrix" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(matrix = it, _json = json) } ?: Price(_json = json) + } + "threshold_total_amount" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(thresholdTotalAmount = it, _json = json) } + ?: Price(_json = json) + } + "tiered_package" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(tieredPackage = it, _json = json) } + ?: Price(_json = json) + } + "tiered_with_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(tieredWithMinimum = it, _json = json) } + ?: Price(_json = json) + } + "grouped_tiered" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedTiered = it, _json = json) } + ?: Price(_json = json) + } + "tiered_package_with_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(tieredPackageWithMinimum = it, _json = json) } + ?: Price(_json = json) + } + "package_with_allocation" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(packageWithAllocation = it, _json = json) } + ?: Price(_json = json) + } + "unit_with_percent" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(unitWithPercent = it, _json = json) } + ?: Price(_json = json) + } + "matrix_with_allocation" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(matrixWithAllocation = it, _json = json) } + ?: Price(_json = json) + } + "tiered_with_proration" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(tieredWithProration = it, _json = json) } + ?: Price(_json = json) + } + "unit_with_proration" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(unitWithProration = it, _json = json) } + ?: Price(_json = json) + } + "grouped_allocation" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedAllocation = it, _json = json) } + ?: Price(_json = json) + } + "bulk_with_proration" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(bulkWithProration = it, _json = json) } + ?: Price(_json = json) + } + "grouped_with_prorated_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedWithProratedMinimum = it, _json = json) } + ?: Price(_json = json) + } + "grouped_with_metered_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedWithMeteredMinimum = it, _json = json) } + ?: Price(_json = json) + } + "grouped_with_min_max_thresholds" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedWithMinMaxThresholds = it, _json = json) } + ?: Price(_json = json) + } + "matrix_with_display_name" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(matrixWithDisplayName = it, _json = json) } + ?: Price(_json = json) + } + "grouped_tiered_package" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedTieredPackage = it, _json = json) } + ?: Price(_json = json) + } + "max_group_tiered_package" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(maxGroupTieredPackage = it, _json = json) } + ?: Price(_json = json) + } + "scalable_matrix_with_unit_pricing" -> { + return tryDeserialize( + node, + jacksonTypeRef< + NewSubscriptionScalableMatrixWithUnitPricingPrice + >(), + ) + ?.let { Price(scalableMatrixWithUnitPricing = it, _json = json) } + ?: Price(_json = json) + } + "scalable_matrix_with_tiered_pricing" -> { + return tryDeserialize( + node, + jacksonTypeRef< + NewSubscriptionScalableMatrixWithTieredPricingPrice + >(), + ) + ?.let { Price(scalableMatrixWithTieredPricing = it, _json = json) } + ?: Price(_json = json) + } + "cumulative_grouped_bulk" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(cumulativeGroupedBulk = it, _json = json) } + ?: Price(_json = json) + } + "minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(minimum = it, _json = json) } ?: Price(_json = json) + } + "percent" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(percent = it, _json = json) + } ?: Price(_json = json) + } + "event_output" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(eventOutput = it, _json = json) + } ?: Price(_json = json) + } + } + + return Price(_json = json) + } + } + + internal class Serializer : BaseSerializer(Price::class) { + + override fun serialize( + value: Price, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.unit != null -> generator.writeObject(value.unit) + value.tiered != null -> generator.writeObject(value.tiered) + value.bulk != null -> generator.writeObject(value.bulk) + value.bulkWithFilters != null -> + generator.writeObject(value.bulkWithFilters) + value.package_ != null -> generator.writeObject(value.package_) + value.matrix != null -> generator.writeObject(value.matrix) + value.thresholdTotalAmount != null -> + generator.writeObject(value.thresholdTotalAmount) + value.tieredPackage != null -> generator.writeObject(value.tieredPackage) + value.tieredWithMinimum != null -> + generator.writeObject(value.tieredWithMinimum) + value.groupedTiered != null -> generator.writeObject(value.groupedTiered) + value.tieredPackageWithMinimum != null -> + generator.writeObject(value.tieredPackageWithMinimum) + value.packageWithAllocation != null -> + generator.writeObject(value.packageWithAllocation) + value.unitWithPercent != null -> + generator.writeObject(value.unitWithPercent) + value.matrixWithAllocation != null -> + generator.writeObject(value.matrixWithAllocation) + value.tieredWithProration != null -> + generator.writeObject(value.tieredWithProration) + value.unitWithProration != null -> + generator.writeObject(value.unitWithProration) + value.groupedAllocation != null -> + generator.writeObject(value.groupedAllocation) + value.bulkWithProration != null -> + generator.writeObject(value.bulkWithProration) + value.groupedWithProratedMinimum != null -> + generator.writeObject(value.groupedWithProratedMinimum) + value.groupedWithMeteredMinimum != null -> + generator.writeObject(value.groupedWithMeteredMinimum) + value.groupedWithMinMaxThresholds != null -> + generator.writeObject(value.groupedWithMinMaxThresholds) + value.matrixWithDisplayName != null -> + generator.writeObject(value.matrixWithDisplayName) + value.groupedTieredPackage != null -> + generator.writeObject(value.groupedTieredPackage) + value.maxGroupTieredPackage != null -> + generator.writeObject(value.maxGroupTieredPackage) + value.scalableMatrixWithUnitPricing != null -> + generator.writeObject(value.scalableMatrixWithUnitPricing) + value.scalableMatrixWithTieredPricing != null -> + generator.writeObject(value.scalableMatrixWithTieredPricing) + value.cumulativeGroupedBulk != null -> + generator.writeObject(value.cumulativeGroupedBulk) + value.minimum != null -> generator.writeObject(value.minimum) + value.percent != null -> generator.writeObject(value.percent) + value.eventOutput != null -> generator.writeObject(value.eventOutput) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Price") + } + } + } + + class BulkWithFilters + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val bulkWithFiltersConfig: JsonField, + private val cadence: JsonField, + private val itemId: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("bulk_with_filters_config") + @ExcludeMissing + bulkWithFiltersConfig: JsonField = JsonMissing.of(), + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + bulkWithFiltersConfig, + cadence, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, externalPriceId, fixedPriceQuantity, - maximumAmount, - minimumAmount, - price, - priceId, - additionalProperties.toMutableMap(), + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + mutableMapOf(), ) - } - - private var validated: Boolean = false - - fun validate(): ReplacePrice = apply { - if (validated) { - return@apply - } - - replacesPriceId() - allocationPrice()?.validate() - discounts()?.forEach { it.validate() } - externalPriceId() - fixedPriceQuantity() - maximumAmount() - minimumAmount() - price()?.validate() - priceId() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (if (replacesPriceId.asKnown() == null) 0 else 1) + - (allocationPrice.asKnown()?.validity() ?: 0) + - (discounts.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + - (if (externalPriceId.asKnown() == null) 0 else 1) + - (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + - (if (maximumAmount.asKnown() == null) 0 else 1) + - (if (minimumAmount.asKnown() == null) 0 else 1) + - (price.asKnown()?.validity() ?: 0) + - (if (priceId.asKnown() == null) 0 else 1) + /** + * Configuration for bulk_with_filters pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun bulkWithFiltersConfig(): BulkWithFiltersConfig = + bulkWithFiltersConfig.getRequired("bulk_with_filters_config") - /** New subscription price request body params. */ - @JsonDeserialize(using = Price.Deserializer::class) - @JsonSerialize(using = Price.Serializer::class) - class Price - private constructor( - private val unit: NewSubscriptionUnitPrice? = null, - private val tiered: NewSubscriptionTieredPrice? = null, - private val bulk: NewSubscriptionBulkPrice? = null, - private val package_: NewSubscriptionPackagePrice? = null, - private val matrix: NewSubscriptionMatrixPrice? = null, - private val thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice? = null, - private val tieredPackage: NewSubscriptionTieredPackagePrice? = null, - private val tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice? = null, - private val groupedTiered: NewSubscriptionGroupedTieredPrice? = null, - private val tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice? = - null, - private val packageWithAllocation: NewSubscriptionPackageWithAllocationPrice? = null, - private val unitWithPercent: NewSubscriptionUnitWithPercentPrice? = null, - private val matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice? = null, - private val tieredWithProration: TieredWithProration? = null, - private val unitWithProration: NewSubscriptionUnitWithProrationPrice? = null, - private val groupedAllocation: NewSubscriptionGroupedAllocationPrice? = null, - private val bulkWithProration: NewSubscriptionBulkWithProrationPrice? = null, - private val groupedWithProratedMinimum: - NewSubscriptionGroupedWithProratedMinimumPrice? = - null, - private val groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice? = - null, - private val groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds? = null, - private val matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice? = null, - private val groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice? = null, - private val maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice? = null, - private val scalableMatrixWithUnitPricing: - NewSubscriptionScalableMatrixWithUnitPricingPrice? = - null, - private val scalableMatrixWithTieredPricing: - NewSubscriptionScalableMatrixWithTieredPricingPrice? = - null, - private val cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice? = null, - private val minimum: NewSubscriptionMinimumCompositePrice? = null, - private val percent: Percent? = null, - private val eventOutput: EventOutput? = null, - private val _json: JsonValue? = null, - ) { + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") - fun unit(): NewSubscriptionUnitPrice? = unit + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") - fun tiered(): NewSubscriptionTieredPrice? = tiered + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("bulk_with_filters") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType - fun bulk(): NewSubscriptionBulkPrice? = bulk + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") - fun package_(): NewSubscriptionPackagePrice? = package_ + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = billableMetricId.getNullable("billable_metric_id") - fun matrix(): NewSubscriptionMatrixPrice? = matrix + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") - fun thresholdTotalAmount(): NewSubscriptionThresholdTotalAmountPrice? = - thresholdTotalAmount + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") - fun tieredPackage(): NewSubscriptionTieredPackagePrice? = tieredPackage + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") - fun tieredWithMinimum(): NewSubscriptionTieredWithMinimumPrice? = tieredWithMinimum + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") - fun groupedTiered(): NewSubscriptionGroupedTieredPrice? = groupedTiered + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") - fun tieredPackageWithMinimum(): NewSubscriptionTieredPackageWithMinimumPrice? = - tieredPackageWithMinimum + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") - fun packageWithAllocation(): NewSubscriptionPackageWithAllocationPrice? = - packageWithAllocation + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") - fun unitWithPercent(): NewSubscriptionUnitWithPercentPrice? = unitWithPercent + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") - fun matrixWithAllocation(): NewSubscriptionMatrixWithAllocationPrice? = - matrixWithAllocation + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + invoiceGroupingKey.getNullable("invoice_grouping_key") - fun tieredWithProration(): TieredWithProration? = tieredWithProration + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - fun unitWithProration(): NewSubscriptionUnitWithProrationPrice? = unitWithProration + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") - fun groupedAllocation(): NewSubscriptionGroupedAllocationPrice? = groupedAllocation + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") - fun bulkWithProration(): NewSubscriptionBulkWithProrationPrice? = bulkWithProration + /** + * Returns the raw JSON value of [bulkWithFiltersConfig]. + * + * Unlike [bulkWithFiltersConfig], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("bulk_with_filters_config") + @ExcludeMissing + fun _bulkWithFiltersConfig(): JsonField = + bulkWithFiltersConfig - fun groupedWithProratedMinimum(): NewSubscriptionGroupedWithProratedMinimumPrice? = - groupedWithProratedMinimum + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence - fun groupedWithMeteredMinimum(): NewSubscriptionGroupedWithMeteredMinimumPrice? = - groupedWithMeteredMinimum + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - fun groupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds? = - groupedWithMinMaxThresholds + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - fun matrixWithDisplayName(): NewSubscriptionMatrixWithDisplayNamePrice? = - matrixWithDisplayName + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId - fun groupedTieredPackage(): NewSubscriptionGroupedTieredPackagePrice? = - groupedTieredPackage + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance - fun maxGroupTieredPackage(): NewSubscriptionMaxGroupTieredPackagePrice? = - maxGroupTieredPackage + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration - fun scalableMatrixWithUnitPricing(): - NewSubscriptionScalableMatrixWithUnitPricingPrice? = scalableMatrixWithUnitPricing + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate - fun scalableMatrixWithTieredPricing(): - NewSubscriptionScalableMatrixWithTieredPricingPrice? = - scalableMatrixWithTieredPricing + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig - fun cumulativeGroupedBulk(): NewSubscriptionCumulativeGroupedBulkPrice? = - cumulativeGroupedBulk + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency - fun minimum(): NewSubscriptionMinimumCompositePrice? = minimum + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration - fun percent(): Percent? = percent + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId - fun eventOutput(): EventOutput? = eventOutput + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - fun isUnit(): Boolean = unit != null + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - fun isTiered(): Boolean = tiered != null + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration - fun isBulk(): Boolean = bulk != null + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata - fun isPackage(): Boolean = package_ != null + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId - fun isMatrix(): Boolean = matrix != null + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - fun isThresholdTotalAmount(): Boolean = thresholdTotalAmount != null + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - fun isTieredPackage(): Boolean = tieredPackage != null + fun toBuilder() = Builder().from(this) - fun isTieredWithMinimum(): Boolean = tieredWithMinimum != null + companion object { - fun isGroupedTiered(): Boolean = groupedTiered != null + /** + * Returns a mutable builder for constructing an instance of [BulkWithFilters]. + * + * The following fields are required: + * ```kotlin + * .bulkWithFiltersConfig() + * .cadence() + * .itemId() + * .name() + * ``` + */ + fun builder() = Builder() + } - fun isTieredPackageWithMinimum(): Boolean = tieredPackageWithMinimum != null + /** A builder for [BulkWithFilters]. */ + class Builder internal constructor() { - fun isPackageWithAllocation(): Boolean = packageWithAllocation != null + private var bulkWithFiltersConfig: JsonField? = null + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonValue = JsonValue.from("bulk_with_filters") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - fun isUnitWithPercent(): Boolean = unitWithPercent != null + internal fun from(bulkWithFilters: BulkWithFilters) = apply { + bulkWithFiltersConfig = bulkWithFilters.bulkWithFiltersConfig + cadence = bulkWithFilters.cadence + itemId = bulkWithFilters.itemId + modelType = bulkWithFilters.modelType + name = bulkWithFilters.name + billableMetricId = bulkWithFilters.billableMetricId + billedInAdvance = bulkWithFilters.billedInAdvance + billingCycleConfiguration = bulkWithFilters.billingCycleConfiguration + conversionRate = bulkWithFilters.conversionRate + conversionRateConfig = bulkWithFilters.conversionRateConfig + currency = bulkWithFilters.currency + dimensionalPriceConfiguration = + bulkWithFilters.dimensionalPriceConfiguration + externalPriceId = bulkWithFilters.externalPriceId + fixedPriceQuantity = bulkWithFilters.fixedPriceQuantity + invoiceGroupingKey = bulkWithFilters.invoiceGroupingKey + invoicingCycleConfiguration = bulkWithFilters.invoicingCycleConfiguration + metadata = bulkWithFilters.metadata + referenceId = bulkWithFilters.referenceId + additionalProperties = bulkWithFilters.additionalProperties.toMutableMap() + } - fun isMatrixWithAllocation(): Boolean = matrixWithAllocation != null + /** Configuration for bulk_with_filters pricing */ + fun bulkWithFiltersConfig(bulkWithFiltersConfig: BulkWithFiltersConfig) = + bulkWithFiltersConfig(JsonField.of(bulkWithFiltersConfig)) - fun isTieredWithProration(): Boolean = tieredWithProration != null + /** + * Sets [Builder.bulkWithFiltersConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.bulkWithFiltersConfig] with a well-typed + * [BulkWithFiltersConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun bulkWithFiltersConfig( + bulkWithFiltersConfig: JsonField + ) = apply { this.bulkWithFiltersConfig = bulkWithFiltersConfig } - fun isUnitWithProration(): Boolean = unitWithProration != null + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - fun isGroupedAllocation(): Boolean = groupedAllocation != null + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - fun isBulkWithProration(): Boolean = bulkWithProration != null + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - fun isGroupedWithProratedMinimum(): Boolean = groupedWithProratedMinimum != null + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun isGroupedWithMeteredMinimum(): Boolean = groupedWithMeteredMinimum != null + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("bulk_with_filters") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } - fun isGroupedWithMinMaxThresholds(): Boolean = groupedWithMinMaxThresholds != null + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) - fun isMatrixWithDisplayName(): Boolean = matrixWithDisplayName != null + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } - fun isGroupedTieredPackage(): Boolean = groupedTieredPackage != null + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) - fun isMaxGroupTieredPackage(): Boolean = maxGroupTieredPackage != null + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } - fun isScalableMatrixWithUnitPricing(): Boolean = scalableMatrixWithUnitPricing != null + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) - fun isScalableMatrixWithTieredPricing(): Boolean = - scalableMatrixWithTieredPricing != null + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) - fun isCumulativeGroupedBulk(): Boolean = cumulativeGroupedBulk != null + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } - fun isMinimum(): Boolean = minimum != null + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - fun isPercent(): Boolean = percent != null + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } - fun isEventOutput(): Boolean = eventOutput != null + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) - fun asUnit(): NewSubscriptionUnitPrice = unit.getOrThrow("unit") + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) - fun asTiered(): NewSubscriptionTieredPrice = tiered.getOrThrow("tiered") + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } - fun asBulk(): NewSubscriptionBulkPrice = bulk.getOrThrow("bulk") + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) - fun asPackage(): NewSubscriptionPackagePrice = package_.getOrThrow("package_") + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } - fun asMatrix(): NewSubscriptionMatrixPrice = matrix.getOrThrow("matrix") + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) - fun asThresholdTotalAmount(): NewSubscriptionThresholdTotalAmountPrice = - thresholdTotalAmount.getOrThrow("thresholdTotalAmount") + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) - fun asTieredPackage(): NewSubscriptionTieredPackagePrice = - tieredPackage.getOrThrow("tieredPackage") + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) - fun asTieredWithMinimum(): NewSubscriptionTieredWithMinimumPrice = - tieredWithMinimum.getOrThrow("tieredWithMinimum") + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) - fun asGroupedTiered(): NewSubscriptionGroupedTieredPrice = - groupedTiered.getOrThrow("groupedTiered") + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) - fun asTieredPackageWithMinimum(): NewSubscriptionTieredPackageWithMinimumPrice = - tieredPackageWithMinimum.getOrThrow("tieredPackageWithMinimum") + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } - fun asPackageWithAllocation(): NewSubscriptionPackageWithAllocationPrice = - packageWithAllocation.getOrThrow("packageWithAllocation") + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) - fun asUnitWithPercent(): NewSubscriptionUnitWithPercentPrice = - unitWithPercent.getOrThrow("unitWithPercent") + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } - fun asMatrixWithAllocation(): NewSubscriptionMatrixWithAllocationPrice = - matrixWithAllocation.getOrThrow("matrixWithAllocation") + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) - fun asTieredWithProration(): TieredWithProration = - tieredWithProration.getOrThrow("tieredWithProration") + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } - fun asUnitWithProration(): NewSubscriptionUnitWithProrationPrice = - unitWithProration.getOrThrow("unitWithProration") + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) - fun asGroupedAllocation(): NewSubscriptionGroupedAllocationPrice = - groupedAllocation.getOrThrow("groupedAllocation") + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) - fun asBulkWithProration(): NewSubscriptionBulkWithProrationPrice = - bulkWithProration.getOrThrow("bulkWithProration") + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } - fun asGroupedWithProratedMinimum(): NewSubscriptionGroupedWithProratedMinimumPrice = - groupedWithProratedMinimum.getOrThrow("groupedWithProratedMinimum") + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) - fun asGroupedWithMeteredMinimum(): NewSubscriptionGroupedWithMeteredMinimumPrice = - groupedWithMeteredMinimum.getOrThrow("groupedWithMeteredMinimum") + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } - fun asGroupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds = - groupedWithMinMaxThresholds.getOrThrow("groupedWithMinMaxThresholds") + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) - fun asMatrixWithDisplayName(): NewSubscriptionMatrixWithDisplayNamePrice = - matrixWithDisplayName.getOrThrow("matrixWithDisplayName") + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - fun asGroupedTieredPackage(): NewSubscriptionGroupedTieredPackagePrice = - groupedTieredPackage.getOrThrow("groupedTieredPackage") + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - fun asMaxGroupTieredPackage(): NewSubscriptionMaxGroupTieredPackagePrice = - maxGroupTieredPackage.getOrThrow("maxGroupTieredPackage") + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - fun asScalableMatrixWithUnitPricing(): - NewSubscriptionScalableMatrixWithUnitPricingPrice = - scalableMatrixWithUnitPricing.getOrThrow("scalableMatrixWithUnitPricing") + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) - fun asScalableMatrixWithTieredPricing(): - NewSubscriptionScalableMatrixWithTieredPricingPrice = - scalableMatrixWithTieredPricing.getOrThrow("scalableMatrixWithTieredPricing") + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } - fun asCumulativeGroupedBulk(): NewSubscriptionCumulativeGroupedBulkPrice = - cumulativeGroupedBulk.getOrThrow("cumulativeGroupedBulk") + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun asMinimum(): NewSubscriptionMinimumCompositePrice = minimum.getOrThrow("minimum") + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun asPercent(): Percent = percent.getOrThrow("percent") + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun asEventOutput(): EventOutput = eventOutput.getOrThrow("eventOutput") + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun _json(): JsonValue? = _json + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - bulk != null -> visitor.visitBulk(bulk) - package_ != null -> visitor.visitPackage(package_) - matrix != null -> visitor.visitMatrix(matrix) - thresholdTotalAmount != null -> - visitor.visitThresholdTotalAmount(thresholdTotalAmount) - tieredPackage != null -> visitor.visitTieredPackage(tieredPackage) - tieredWithMinimum != null -> visitor.visitTieredWithMinimum(tieredWithMinimum) - groupedTiered != null -> visitor.visitGroupedTiered(groupedTiered) - tieredPackageWithMinimum != null -> - visitor.visitTieredPackageWithMinimum(tieredPackageWithMinimum) - packageWithAllocation != null -> - visitor.visitPackageWithAllocation(packageWithAllocation) - unitWithPercent != null -> visitor.visitUnitWithPercent(unitWithPercent) - matrixWithAllocation != null -> - visitor.visitMatrixWithAllocation(matrixWithAllocation) - tieredWithProration != null -> - visitor.visitTieredWithProration(tieredWithProration) - unitWithProration != null -> visitor.visitUnitWithProration(unitWithProration) - groupedAllocation != null -> visitor.visitGroupedAllocation(groupedAllocation) - bulkWithProration != null -> visitor.visitBulkWithProration(bulkWithProration) - groupedWithProratedMinimum != null -> - visitor.visitGroupedWithProratedMinimum(groupedWithProratedMinimum) - groupedWithMeteredMinimum != null -> - visitor.visitGroupedWithMeteredMinimum(groupedWithMeteredMinimum) - groupedWithMinMaxThresholds != null -> - visitor.visitGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds) - matrixWithDisplayName != null -> - visitor.visitMatrixWithDisplayName(matrixWithDisplayName) - groupedTieredPackage != null -> - visitor.visitGroupedTieredPackage(groupedTieredPackage) - maxGroupTieredPackage != null -> - visitor.visitMaxGroupTieredPackage(maxGroupTieredPackage) - scalableMatrixWithUnitPricing != null -> - visitor.visitScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing) - scalableMatrixWithTieredPricing != null -> - visitor.visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing + /** + * Returns an immutable instance of [BulkWithFilters]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .bulkWithFiltersConfig() + * .cadence() + * .itemId() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BulkWithFilters = + BulkWithFilters( + checkRequired("bulkWithFiltersConfig", bulkWithFiltersConfig), + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties.toMutableMap(), ) - cumulativeGroupedBulk != null -> - visitor.visitCumulativeGroupedBulk(cumulativeGroupedBulk) - minimum != null -> visitor.visitMinimum(minimum) - percent != null -> visitor.visitPercent(percent) - eventOutput != null -> visitor.visitEventOutput(eventOutput) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): Price = apply { - if (validated) { - return@apply } - accept( - object : Visitor { - override fun visitUnit(unit: NewSubscriptionUnitPrice) { - unit.validate() - } - - override fun visitTiered(tiered: NewSubscriptionTieredPrice) { - tiered.validate() - } + private var validated: Boolean = false - override fun visitBulk(bulk: NewSubscriptionBulkPrice) { - bulk.validate() - } + fun validate(): BulkWithFilters = apply { + if (validated) { + return@apply + } - override fun visitPackage(package_: NewSubscriptionPackagePrice) { - package_.validate() + bulkWithFiltersConfig().validate() + cadence().validate() + itemId() + _modelType().let { + if (it != JsonValue.from("bulk_with_filters")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + metadata()?.validate() + referenceId() + validated = true + } - override fun visitMatrix(matrix: NewSubscriptionMatrixPrice) { - matrix.validate() - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - override fun visitThresholdTotalAmount( - thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice - ) { - thresholdTotalAmount.validate() - } + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (bulkWithFiltersConfig.asKnown()?.validity() ?: 0) + + (cadence.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + modelType.let { if (it == JsonValue.from("bulk_with_filters")) 1 else 0 } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) - override fun visitTieredPackage( - tieredPackage: NewSubscriptionTieredPackagePrice - ) { - tieredPackage.validate() - } + /** Configuration for bulk_with_filters pricing */ + class BulkWithFiltersConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val filters: JsonField>, + private val tiers: JsonField>, + private val additionalProperties: MutableMap, + ) { - override fun visitTieredWithMinimum( - tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice - ) { - tieredWithMinimum.validate() - } + @JsonCreator + private constructor( + @JsonProperty("filters") + @ExcludeMissing + filters: JsonField> = JsonMissing.of(), + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of(), + ) : this(filters, tiers, mutableMapOf()) - override fun visitGroupedTiered( - groupedTiered: NewSubscriptionGroupedTieredPrice - ) { - groupedTiered.validate() - } + /** + * Property filters to apply (all must match) + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun filters(): List = filters.getRequired("filters") - override fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice - ) { - tieredPackageWithMinimum.validate() - } + /** + * Bulk tiers for rating based on total usage volume + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun tiers(): List = tiers.getRequired("tiers") - override fun visitPackageWithAllocation( - packageWithAllocation: NewSubscriptionPackageWithAllocationPrice - ) { - packageWithAllocation.validate() - } + /** + * Returns the raw JSON value of [filters]. + * + * Unlike [filters], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("filters") + @ExcludeMissing + fun _filters(): JsonField> = filters - override fun visitUnitWithPercent( - unitWithPercent: NewSubscriptionUnitWithPercentPrice - ) { - unitWithPercent.validate() - } + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers - override fun visitMatrixWithAllocation( - matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice - ) { - matrixWithAllocation.validate() - } + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - override fun visitTieredWithProration( - tieredWithProration: TieredWithProration - ) { - tieredWithProration.validate() - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - override fun visitUnitWithProration( - unitWithProration: NewSubscriptionUnitWithProrationPrice - ) { - unitWithProration.validate() - } + fun toBuilder() = Builder().from(this) - override fun visitGroupedAllocation( - groupedAllocation: NewSubscriptionGroupedAllocationPrice - ) { - groupedAllocation.validate() - } + companion object { - override fun visitBulkWithProration( - bulkWithProration: NewSubscriptionBulkWithProrationPrice - ) { - bulkWithProration.validate() - } + /** + * Returns a mutable builder for constructing an instance of + * [BulkWithFiltersConfig]. + * + * The following fields are required: + * ```kotlin + * .filters() + * .tiers() + * ``` + */ + fun builder() = Builder() + } - override fun visitGroupedWithProratedMinimum( - groupedWithProratedMinimum: - NewSubscriptionGroupedWithProratedMinimumPrice - ) { - groupedWithProratedMinimum.validate() - } + /** A builder for [BulkWithFiltersConfig]. */ + class Builder internal constructor() { - override fun visitGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice - ) { - groupedWithMeteredMinimum.validate() - } + private var filters: JsonField>? = null + private var tiers: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() - override fun visitGroupedWithMinMaxThresholds( - groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds - ) { - groupedWithMinMaxThresholds.validate() + internal fun from(bulkWithFiltersConfig: BulkWithFiltersConfig) = apply { + filters = bulkWithFiltersConfig.filters.map { it.toMutableList() } + tiers = bulkWithFiltersConfig.tiers.map { it.toMutableList() } + additionalProperties = + bulkWithFiltersConfig.additionalProperties.toMutableMap() } - override fun visitMatrixWithDisplayName( - matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice - ) { - matrixWithDisplayName.validate() - } + /** Property filters to apply (all must match) */ + fun filters(filters: List) = filters(JsonField.of(filters)) - override fun visitGroupedTieredPackage( - groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice - ) { - groupedTieredPackage.validate() + /** + * Sets [Builder.filters] to an arbitrary JSON value. + * + * You should usually call [Builder.filters] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun filters(filters: JsonField>) = apply { + this.filters = filters.map { it.toMutableList() } } - override fun visitMaxGroupTieredPackage( - maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice - ) { - maxGroupTieredPackage.validate() + /** + * Adds a single [Filter] to [filters]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addFilter(filter: Filter) = apply { + filters = + (filters ?: JsonField.of(mutableListOf())).also { + checkKnown("filters", it).add(filter) + } } - override fun visitScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: - NewSubscriptionScalableMatrixWithUnitPricingPrice - ) { - scalableMatrixWithUnitPricing.validate() - } + /** Bulk tiers for rating based on total usage volume */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) - override fun visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: - NewSubscriptionScalableMatrixWithTieredPricingPrice - ) { - scalableMatrixWithTieredPricing.validate() + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } } - override fun visitCumulativeGroupedBulk( - cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice - ) { - cumulativeGroupedBulk.validate() + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } } - override fun visitMinimum(minimum: NewSubscriptionMinimumCompositePrice) { - minimum.validate() + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) } - override fun visitPercent(percent: Percent) { - percent.validate() + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) } - override fun visitEventOutput(eventOutput: EventOutput) { - eventOutput.validate() + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) } + + /** + * Returns an immutable instance of [BulkWithFiltersConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .filters() + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BulkWithFiltersConfig = + BulkWithFiltersConfig( + checkRequired("filters", filters).map { it.toImmutable() }, + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) } - ) - validated = true - } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + private var validated: Boolean = false - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: NewSubscriptionUnitPrice) = unit.validity() + fun validate(): BulkWithFiltersConfig = apply { + if (validated) { + return@apply + } - override fun visitTiered(tiered: NewSubscriptionTieredPrice) = - tiered.validity() + filters().forEach { it.validate() } + tiers().forEach { it.validate() } + validated = true + } - override fun visitBulk(bulk: NewSubscriptionBulkPrice) = bulk.validity() + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - override fun visitPackage(package_: NewSubscriptionPackagePrice) = - package_.validity() + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (filters.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + (tiers.asKnown()?.sumOf { it.validity().toInt() } ?: 0) - override fun visitMatrix(matrix: NewSubscriptionMatrixPrice) = - matrix.validity() + /** Configuration for a single property filter */ + class Filter + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val propertyKey: JsonField, + private val propertyValue: JsonField, + private val additionalProperties: MutableMap, + ) { - override fun visitThresholdTotalAmount( - thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice - ) = thresholdTotalAmount.validity() + @JsonCreator + private constructor( + @JsonProperty("property_key") + @ExcludeMissing + propertyKey: JsonField = JsonMissing.of(), + @JsonProperty("property_value") + @ExcludeMissing + propertyValue: JsonField = JsonMissing.of(), + ) : this(propertyKey, propertyValue, mutableMapOf()) - override fun visitTieredPackage( - tieredPackage: NewSubscriptionTieredPackagePrice - ) = tieredPackage.validity() + /** + * Event property key to filter on + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun propertyKey(): String = propertyKey.getRequired("property_key") - override fun visitTieredWithMinimum( - tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice - ) = tieredWithMinimum.validity() + /** + * Event property value to match + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun propertyValue(): String = propertyValue.getRequired("property_value") - override fun visitGroupedTiered( - groupedTiered: NewSubscriptionGroupedTieredPrice - ) = groupedTiered.validity() + /** + * Returns the raw JSON value of [propertyKey]. + * + * Unlike [propertyKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("property_key") + @ExcludeMissing + fun _propertyKey(): JsonField = propertyKey - override fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice - ) = tieredPackageWithMinimum.validity() + /** + * Returns the raw JSON value of [propertyValue]. + * + * Unlike [propertyValue], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("property_value") + @ExcludeMissing + fun _propertyValue(): JsonField = propertyValue - override fun visitPackageWithAllocation( - packageWithAllocation: NewSubscriptionPackageWithAllocationPrice - ) = packageWithAllocation.validity() + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - override fun visitUnitWithPercent( - unitWithPercent: NewSubscriptionUnitWithPercentPrice - ) = unitWithPercent.validity() + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - override fun visitMatrixWithAllocation( - matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice - ) = matrixWithAllocation.validity() + fun toBuilder() = Builder().from(this) - override fun visitTieredWithProration( - tieredWithProration: TieredWithProration - ) = tieredWithProration.validity() + companion object { - override fun visitUnitWithProration( - unitWithProration: NewSubscriptionUnitWithProrationPrice - ) = unitWithProration.validity() + /** + * Returns a mutable builder for constructing an instance of [Filter]. + * + * The following fields are required: + * ```kotlin + * .propertyKey() + * .propertyValue() + * ``` + */ + fun builder() = Builder() + } - override fun visitGroupedAllocation( - groupedAllocation: NewSubscriptionGroupedAllocationPrice - ) = groupedAllocation.validity() + /** A builder for [Filter]. */ + class Builder internal constructor() { - override fun visitBulkWithProration( - bulkWithProration: NewSubscriptionBulkWithProrationPrice - ) = bulkWithProration.validity() + private var propertyKey: JsonField? = null + private var propertyValue: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() - override fun visitGroupedWithProratedMinimum( - groupedWithProratedMinimum: - NewSubscriptionGroupedWithProratedMinimumPrice - ) = groupedWithProratedMinimum.validity() + internal fun from(filter: Filter) = apply { + propertyKey = filter.propertyKey + propertyValue = filter.propertyValue + additionalProperties = filter.additionalProperties.toMutableMap() + } - override fun visitGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice - ) = groupedWithMeteredMinimum.validity() + /** Event property key to filter on */ + fun propertyKey(propertyKey: String) = + propertyKey(JsonField.of(propertyKey)) - override fun visitGroupedWithMinMaxThresholds( - groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds - ) = groupedWithMinMaxThresholds.validity() + /** + * Sets [Builder.propertyKey] to an arbitrary JSON value. + * + * You should usually call [Builder.propertyKey] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun propertyKey(propertyKey: JsonField) = apply { + this.propertyKey = propertyKey + } - override fun visitMatrixWithDisplayName( - matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice - ) = matrixWithDisplayName.validity() + /** Event property value to match */ + fun propertyValue(propertyValue: String) = + propertyValue(JsonField.of(propertyValue)) - override fun visitGroupedTieredPackage( - groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice - ) = groupedTieredPackage.validity() + /** + * Sets [Builder.propertyValue] to an arbitrary JSON value. + * + * You should usually call [Builder.propertyValue] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun propertyValue(propertyValue: JsonField) = apply { + this.propertyValue = propertyValue + } - override fun visitMaxGroupTieredPackage( - maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice - ) = maxGroupTieredPackage.validity() + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - override fun visitScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: - NewSubscriptionScalableMatrixWithUnitPricingPrice - ) = scalableMatrixWithUnitPricing.validity() + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - override fun visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: - NewSubscriptionScalableMatrixWithTieredPricingPrice - ) = scalableMatrixWithTieredPricing.validity() + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - override fun visitCumulativeGroupedBulk( - cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice - ) = cumulativeGroupedBulk.validity() + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - override fun visitMinimum(minimum: NewSubscriptionMinimumCompositePrice) = - minimum.validity() + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - override fun visitPercent(percent: Percent) = percent.validity() + /** + * Returns an immutable instance of [Filter]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```kotlin + * .propertyKey() + * .propertyValue() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Filter = + Filter( + checkRequired("propertyKey", propertyKey), + checkRequired("propertyValue", propertyValue), + additionalProperties.toMutableMap(), + ) + } - override fun visitEventOutput(eventOutput: EventOutput) = - eventOutput.validity() + private var validated: Boolean = false - override fun unknown(json: JsonValue?) = 0 - } - ) + fun validate(): Filter = apply { + if (validated) { + return@apply + } + + propertyKey() + propertyValue() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (propertyKey.asKnown() == null) 0 else 1) + + (if (propertyValue.asKnown() == null) 0 else 1) - return other is Price && - unit == other.unit && - tiered == other.tiered && - bulk == other.bulk && - package_ == other.package_ && - matrix == other.matrix && - thresholdTotalAmount == other.thresholdTotalAmount && - tieredPackage == other.tieredPackage && - tieredWithMinimum == other.tieredWithMinimum && - groupedTiered == other.groupedTiered && - tieredPackageWithMinimum == other.tieredPackageWithMinimum && - packageWithAllocation == other.packageWithAllocation && - unitWithPercent == other.unitWithPercent && - matrixWithAllocation == other.matrixWithAllocation && - tieredWithProration == other.tieredWithProration && - unitWithProration == other.unitWithProration && - groupedAllocation == other.groupedAllocation && - bulkWithProration == other.bulkWithProration && - groupedWithProratedMinimum == other.groupedWithProratedMinimum && - groupedWithMeteredMinimum == other.groupedWithMeteredMinimum && - groupedWithMinMaxThresholds == other.groupedWithMinMaxThresholds && - matrixWithDisplayName == other.matrixWithDisplayName && - groupedTieredPackage == other.groupedTieredPackage && - maxGroupTieredPackage == other.maxGroupTieredPackage && - scalableMatrixWithUnitPricing == other.scalableMatrixWithUnitPricing && - scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && - cumulativeGroupedBulk == other.cumulativeGroupedBulk && - minimum == other.minimum && - percent == other.percent && - eventOutput == other.eventOutput - } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - override fun hashCode(): Int = - Objects.hash( - unit, - tiered, - bulk, - package_, - matrix, - thresholdTotalAmount, - tieredPackage, - tieredWithMinimum, - groupedTiered, - tieredPackageWithMinimum, - packageWithAllocation, - unitWithPercent, - matrixWithAllocation, - tieredWithProration, - unitWithProration, - groupedAllocation, - bulkWithProration, - groupedWithProratedMinimum, - groupedWithMeteredMinimum, - groupedWithMinMaxThresholds, - matrixWithDisplayName, - groupedTieredPackage, - maxGroupTieredPackage, - scalableMatrixWithUnitPricing, - scalableMatrixWithTieredPricing, - cumulativeGroupedBulk, - minimum, - percent, - eventOutput, - ) + return other is Filter && + propertyKey == other.propertyKey && + propertyValue == other.propertyValue && + additionalProperties == other.additionalProperties + } - override fun toString(): String = - when { - unit != null -> "Price{unit=$unit}" - tiered != null -> "Price{tiered=$tiered}" - bulk != null -> "Price{bulk=$bulk}" - package_ != null -> "Price{package_=$package_}" - matrix != null -> "Price{matrix=$matrix}" - thresholdTotalAmount != null -> - "Price{thresholdTotalAmount=$thresholdTotalAmount}" - tieredPackage != null -> "Price{tieredPackage=$tieredPackage}" - tieredWithMinimum != null -> "Price{tieredWithMinimum=$tieredWithMinimum}" - groupedTiered != null -> "Price{groupedTiered=$groupedTiered}" - tieredPackageWithMinimum != null -> - "Price{tieredPackageWithMinimum=$tieredPackageWithMinimum}" - packageWithAllocation != null -> - "Price{packageWithAllocation=$packageWithAllocation}" - unitWithPercent != null -> "Price{unitWithPercent=$unitWithPercent}" - matrixWithAllocation != null -> - "Price{matrixWithAllocation=$matrixWithAllocation}" - tieredWithProration != null -> "Price{tieredWithProration=$tieredWithProration}" - unitWithProration != null -> "Price{unitWithProration=$unitWithProration}" - groupedAllocation != null -> "Price{groupedAllocation=$groupedAllocation}" - bulkWithProration != null -> "Price{bulkWithProration=$bulkWithProration}" - groupedWithProratedMinimum != null -> - "Price{groupedWithProratedMinimum=$groupedWithProratedMinimum}" - groupedWithMeteredMinimum != null -> - "Price{groupedWithMeteredMinimum=$groupedWithMeteredMinimum}" - groupedWithMinMaxThresholds != null -> - "Price{groupedWithMinMaxThresholds=$groupedWithMinMaxThresholds}" - matrixWithDisplayName != null -> - "Price{matrixWithDisplayName=$matrixWithDisplayName}" - groupedTieredPackage != null -> - "Price{groupedTieredPackage=$groupedTieredPackage}" - maxGroupTieredPackage != null -> - "Price{maxGroupTieredPackage=$maxGroupTieredPackage}" - scalableMatrixWithUnitPricing != null -> - "Price{scalableMatrixWithUnitPricing=$scalableMatrixWithUnitPricing}" - scalableMatrixWithTieredPricing != null -> - "Price{scalableMatrixWithTieredPricing=$scalableMatrixWithTieredPricing}" - cumulativeGroupedBulk != null -> - "Price{cumulativeGroupedBulk=$cumulativeGroupedBulk}" - minimum != null -> "Price{minimum=$minimum}" - percent != null -> "Price{percent=$percent}" - eventOutput != null -> "Price{eventOutput=$eventOutput}" - _json != null -> "Price{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Price") - } + private val hashCode: Int by lazy { + Objects.hash(propertyKey, propertyValue, additionalProperties) + } - companion object { + override fun hashCode(): Int = hashCode - fun ofUnit(unit: NewSubscriptionUnitPrice) = Price(unit = unit) + override fun toString() = + "Filter{propertyKey=$propertyKey, propertyValue=$propertyValue, additionalProperties=$additionalProperties}" + } - fun ofTiered(tiered: NewSubscriptionTieredPrice) = Price(tiered = tiered) + /** Configuration for a single bulk pricing tier */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val unitAmount: JsonField, + private val tierLowerBound: JsonField, + private val additionalProperties: MutableMap, + ) { - fun ofBulk(bulk: NewSubscriptionBulkPrice) = Price(bulk = bulk) + @JsonCreator + private constructor( + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + ) : this(unitAmount, tierLowerBound, mutableMapOf()) - fun ofPackage(package_: NewSubscriptionPackagePrice) = Price(package_ = package_) + /** + * Amount per unit + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") - fun ofMatrix(matrix: NewSubscriptionMatrixPrice) = Price(matrix = matrix) + /** + * The lower bound for this tier + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun tierLowerBound(): String? = + tierLowerBound.getNullable("tier_lower_bound") - fun ofThresholdTotalAmount( - thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice - ) = Price(thresholdTotalAmount = thresholdTotalAmount) + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount - fun ofTieredPackage(tieredPackage: NewSubscriptionTieredPackagePrice) = - Price(tieredPackage = tieredPackage) + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound - fun ofTieredWithMinimum(tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice) = - Price(tieredWithMinimum = tieredWithMinimum) + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - fun ofGroupedTiered(groupedTiered: NewSubscriptionGroupedTieredPrice) = - Price(groupedTiered = groupedTiered) + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - fun ofTieredPackageWithMinimum( - tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice - ) = Price(tieredPackageWithMinimum = tieredPackageWithMinimum) + fun toBuilder() = Builder().from(this) - fun ofPackageWithAllocation( - packageWithAllocation: NewSubscriptionPackageWithAllocationPrice - ) = Price(packageWithAllocation = packageWithAllocation) + companion object { - fun ofUnitWithPercent(unitWithPercent: NewSubscriptionUnitWithPercentPrice) = - Price(unitWithPercent = unitWithPercent) + /** + * Returns a mutable builder for constructing an instance of [Tier]. + * + * The following fields are required: + * ```kotlin + * .unitAmount() + * ``` + */ + fun builder() = Builder() + } - fun ofMatrixWithAllocation( - matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice - ) = Price(matrixWithAllocation = matrixWithAllocation) + /** A builder for [Tier]. */ + class Builder internal constructor() { - fun ofTieredWithProration(tieredWithProration: TieredWithProration) = - Price(tieredWithProration = tieredWithProration) + private var unitAmount: JsonField? = null + private var tierLowerBound: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() - fun ofUnitWithProration(unitWithProration: NewSubscriptionUnitWithProrationPrice) = - Price(unitWithProration = unitWithProration) + internal fun from(tier: Tier) = apply { + unitAmount = tier.unitAmount + tierLowerBound = tier.tierLowerBound + additionalProperties = tier.additionalProperties.toMutableMap() + } - fun ofGroupedAllocation(groupedAllocation: NewSubscriptionGroupedAllocationPrice) = - Price(groupedAllocation = groupedAllocation) + /** Amount per unit */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) - fun ofBulkWithProration(bulkWithProration: NewSubscriptionBulkWithProrationPrice) = - Price(bulkWithProration = bulkWithProration) + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } - fun ofGroupedWithProratedMinimum( - groupedWithProratedMinimum: NewSubscriptionGroupedWithProratedMinimumPrice - ) = Price(groupedWithProratedMinimum = groupedWithProratedMinimum) + /** The lower bound for this tier */ + fun tierLowerBound(tierLowerBound: String?) = + tierLowerBound(JsonField.ofNullable(tierLowerBound)) - fun ofGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice - ) = Price(groupedWithMeteredMinimum = groupedWithMeteredMinimum) + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } - fun ofGroupedWithMinMaxThresholds( - groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds - ) = Price(groupedWithMinMaxThresholds = groupedWithMinMaxThresholds) + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun ofMatrixWithDisplayName( - matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice - ) = Price(matrixWithDisplayName = matrixWithDisplayName) + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun ofGroupedTieredPackage( - groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice - ) = Price(groupedTieredPackage = groupedTieredPackage) + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun ofMaxGroupTieredPackage( - maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice - ) = Price(maxGroupTieredPackage = maxGroupTieredPackage) + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun ofScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: NewSubscriptionScalableMatrixWithUnitPricingPrice - ) = Price(scalableMatrixWithUnitPricing = scalableMatrixWithUnitPricing) + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - fun ofScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: - NewSubscriptionScalableMatrixWithTieredPricingPrice - ) = Price(scalableMatrixWithTieredPricing = scalableMatrixWithTieredPricing) + /** + * Returns an immutable instance of [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```kotlin + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("unitAmount", unitAmount), + tierLowerBound, + additionalProperties.toMutableMap(), + ) + } - fun ofCumulativeGroupedBulk( - cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice - ) = Price(cumulativeGroupedBulk = cumulativeGroupedBulk) + private var validated: Boolean = false - fun ofMinimum(minimum: NewSubscriptionMinimumCompositePrice) = - Price(minimum = minimum) + fun validate(): Tier = apply { + if (validated) { + return@apply + } - fun ofPercent(percent: Percent) = Price(percent = percent) + unitAmount() + tierLowerBound() + validated = true + } - fun ofEventOutput(eventOutput: EventOutput) = Price(eventOutput = eventOutput) - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - /** - * An interface that defines how to map each variant of [Price] to a value of type [T]. - */ - interface Visitor { + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (unitAmount.asKnown() == null) 0 else 1) + + (if (tierLowerBound.asKnown() == null) 0 else 1) - fun visitUnit(unit: NewSubscriptionUnitPrice): T + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun visitTiered(tiered: NewSubscriptionTieredPrice): T + return other is Tier && + unitAmount == other.unitAmount && + tierLowerBound == other.tierLowerBound && + additionalProperties == other.additionalProperties + } - fun visitBulk(bulk: NewSubscriptionBulkPrice): T + private val hashCode: Int by lazy { + Objects.hash(unitAmount, tierLowerBound, additionalProperties) + } - fun visitPackage(package_: NewSubscriptionPackagePrice): T + override fun hashCode(): Int = hashCode - fun visitMatrix(matrix: NewSubscriptionMatrixPrice): T + override fun toString() = + "Tier{unitAmount=$unitAmount, tierLowerBound=$tierLowerBound, additionalProperties=$additionalProperties}" + } - fun visitThresholdTotalAmount( - thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice - ): T + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun visitTieredPackage(tieredPackage: NewSubscriptionTieredPackagePrice): T + return other is BulkWithFiltersConfig && + filters == other.filters && + tiers == other.tiers && + additionalProperties == other.additionalProperties + } - fun visitTieredWithMinimum( - tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice - ): T + private val hashCode: Int by lazy { + Objects.hash(filters, tiers, additionalProperties) + } - fun visitGroupedTiered(groupedTiered: NewSubscriptionGroupedTieredPrice): T + override fun hashCode(): Int = hashCode - fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice - ): T + override fun toString() = + "BulkWithFiltersConfig{filters=$filters, tiers=$tiers, additionalProperties=$additionalProperties}" + } - fun visitPackageWithAllocation( - packageWithAllocation: NewSubscriptionPackageWithAllocationPrice - ): T + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { - fun visitUnitWithPercent(unitWithPercent: NewSubscriptionUnitWithPercentPrice): T + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value - fun visitMatrixWithAllocation( - matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice - ): T + companion object { - fun visitTieredWithProration(tieredWithProration: TieredWithProration): T + val ANNUAL = of("annual") - fun visitUnitWithProration( - unitWithProration: NewSubscriptionUnitWithProrationPrice - ): T + val SEMI_ANNUAL = of("semi_annual") - fun visitGroupedAllocation( - groupedAllocation: NewSubscriptionGroupedAllocationPrice - ): T + val MONTHLY = of("monthly") - fun visitBulkWithProration( - bulkWithProration: NewSubscriptionBulkWithProrationPrice - ): T + val QUARTERLY = of("quarterly") - fun visitGroupedWithProratedMinimum( - groupedWithProratedMinimum: NewSubscriptionGroupedWithProratedMinimumPrice - ): T + val ONE_TIME = of("one_time") - fun visitGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice - ): T + val CUSTOM = of("custom") - fun visitGroupedWithMinMaxThresholds( - groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds - ): T + fun of(value: String) = Cadence(JsonField.of(value)) + } - fun visitMatrixWithDisplayName( - matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice - ): T + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } - fun visitGroupedTieredPackage( - groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice - ): T + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } - fun visitMaxGroupTieredPackage( - maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice - ): T + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } - fun visitScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: NewSubscriptionScalableMatrixWithUnitPricingPrice - ): T + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } - fun visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: - NewSubscriptionScalableMatrixWithTieredPricingPrice - ): T + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") - fun visitCumulativeGroupedBulk( - cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice - ): T + private var validated: Boolean = false - fun visitMinimum(minimum: NewSubscriptionMinimumCompositePrice): T + fun validate(): Cadence = apply { + if (validated) { + return@apply + } - fun visitPercent(percent: Percent): T + known() + validated = true + } - fun visitEventOutput(eventOutput: EventOutput): T + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - /** - * Maps an unknown variant of [Price] to a value of type [T]. - * - * An instance of [Price] can contain an unknown variant if it was deserialized from - * data that doesn't match any known variant. For example, if the SDK is on an older - * version than the API, then the API may respond with new variants that the SDK is - * unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown Price: $json") - } - } + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - internal class Deserializer : BaseDeserializer(Price::class) { + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - override fun ObjectCodec.deserialize(node: JsonNode): Price { - val json = JsonValue.fromJsonNode(node) - val modelType = json.asObject()?.get("model_type")?.asString() + return other is Cadence && value == other.value + } - when (modelType) { - "unit" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(unit = it, _json = json) } ?: Price(_json = json) - } - "tiered" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(tiered = it, _json = json) } ?: Price(_json = json) - } - "bulk" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(bulk = it, _json = json) } ?: Price(_json = json) - } - "package" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(package_ = it, _json = json) } ?: Price(_json = json) - } - "matrix" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(matrix = it, _json = json) } ?: Price(_json = json) - } - "threshold_total_amount" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(thresholdTotalAmount = it, _json = json) } - ?: Price(_json = json) - } - "tiered_package" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(tieredPackage = it, _json = json) } - ?: Price(_json = json) - } - "tiered_with_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(tieredWithMinimum = it, _json = json) } - ?: Price(_json = json) - } - "grouped_tiered" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedTiered = it, _json = json) } - ?: Price(_json = json) - } - "tiered_package_with_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(tieredPackageWithMinimum = it, _json = json) } - ?: Price(_json = json) - } - "package_with_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(packageWithAllocation = it, _json = json) } - ?: Price(_json = json) - } - "unit_with_percent" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(unitWithPercent = it, _json = json) } - ?: Price(_json = json) - } - "matrix_with_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(matrixWithAllocation = it, _json = json) } - ?: Price(_json = json) - } - "tiered_with_proration" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(tieredWithProration = it, _json = json) } - ?: Price(_json = json) - } - "unit_with_proration" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(unitWithProration = it, _json = json) } - ?: Price(_json = json) - } - "grouped_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedAllocation = it, _json = json) } - ?: Price(_json = json) - } - "bulk_with_proration" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(bulkWithProration = it, _json = json) } - ?: Price(_json = json) - } - "grouped_with_prorated_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedWithProratedMinimum = it, _json = json) } - ?: Price(_json = json) - } - "grouped_with_metered_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedWithMeteredMinimum = it, _json = json) } - ?: Price(_json = json) - } - "grouped_with_min_max_thresholds" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedWithMinMaxThresholds = it, _json = json) } - ?: Price(_json = json) - } - "matrix_with_display_name" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(matrixWithDisplayName = it, _json = json) } - ?: Price(_json = json) - } - "grouped_tiered_package" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedTieredPackage = it, _json = json) } - ?: Price(_json = json) + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() } - "max_group_tiered_package" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(maxGroupTieredPackage = it, _json = json) } - ?: Price(_json = json) + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) } - "scalable_matrix_with_unit_pricing" -> { - return tryDeserialize( - node, - jacksonTypeRef< - NewSubscriptionScalableMatrixWithUnitPricingPrice - >(), - ) - ?.let { Price(scalableMatrixWithUnitPricing = it, _json = json) } - ?: Price(_json = json) + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) } - "scalable_matrix_with_tiered_pricing" -> { - return tryDeserialize( - node, - jacksonTypeRef< - NewSubscriptionScalableMatrixWithTieredPricingPrice - >(), - ) - ?.let { Price(scalableMatrixWithTieredPricing = it, _json = json) } - ?: Price(_json = json) + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) } - "cumulative_grouped_bulk" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(cumulativeGroupedBulk = it, _json = json) } - ?: Price(_json = json) + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply } - "minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(minimum = it, _json = json) } ?: Price(_json = json) + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false } - "percent" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(percent = it, _json = json) - } ?: Price(_json = json) + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() } - "event_output" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(eventOutput = it, _json = json) - } ?: Price(_json = json) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } + + return other is Metadata && + additionalProperties == other.additionalProperties } - return Price(_json = json) - } - } + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - internal class Serializer : BaseSerializer(Price::class) { + override fun hashCode(): Int = hashCode - override fun serialize( - value: Price, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unit != null -> generator.writeObject(value.unit) - value.tiered != null -> generator.writeObject(value.tiered) - value.bulk != null -> generator.writeObject(value.bulk) - value.package_ != null -> generator.writeObject(value.package_) - value.matrix != null -> generator.writeObject(value.matrix) - value.thresholdTotalAmount != null -> - generator.writeObject(value.thresholdTotalAmount) - value.tieredPackage != null -> generator.writeObject(value.tieredPackage) - value.tieredWithMinimum != null -> - generator.writeObject(value.tieredWithMinimum) - value.groupedTiered != null -> generator.writeObject(value.groupedTiered) - value.tieredPackageWithMinimum != null -> - generator.writeObject(value.tieredPackageWithMinimum) - value.packageWithAllocation != null -> - generator.writeObject(value.packageWithAllocation) - value.unitWithPercent != null -> - generator.writeObject(value.unitWithPercent) - value.matrixWithAllocation != null -> - generator.writeObject(value.matrixWithAllocation) - value.tieredWithProration != null -> - generator.writeObject(value.tieredWithProration) - value.unitWithProration != null -> - generator.writeObject(value.unitWithProration) - value.groupedAllocation != null -> - generator.writeObject(value.groupedAllocation) - value.bulkWithProration != null -> - generator.writeObject(value.bulkWithProration) - value.groupedWithProratedMinimum != null -> - generator.writeObject(value.groupedWithProratedMinimum) - value.groupedWithMeteredMinimum != null -> - generator.writeObject(value.groupedWithMeteredMinimum) - value.groupedWithMinMaxThresholds != null -> - generator.writeObject(value.groupedWithMinMaxThresholds) - value.matrixWithDisplayName != null -> - generator.writeObject(value.matrixWithDisplayName) - value.groupedTieredPackage != null -> - generator.writeObject(value.groupedTieredPackage) - value.maxGroupTieredPackage != null -> - generator.writeObject(value.maxGroupTieredPackage) - value.scalableMatrixWithUnitPricing != null -> - generator.writeObject(value.scalableMatrixWithUnitPricing) - value.scalableMatrixWithTieredPricing != null -> - generator.writeObject(value.scalableMatrixWithTieredPricing) - value.cumulativeGroupedBulk != null -> - generator.writeObject(value.cumulativeGroupedBulk) - value.minimum != null -> generator.writeObject(value.minimum) - value.percent != null -> generator.writeObject(value.percent) - value.eventOutput != null -> generator.writeObject(value.eventOutput) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Price") + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } + + return other is BulkWithFilters && + bulkWithFiltersConfig == other.bulkWithFiltersConfig && + cadence == other.cadence && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + bulkWithFiltersConfig, + cadence, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties, + ) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BulkWithFilters{bulkWithFiltersConfig=$bulkWithFiltersConfig, cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } class TieredWithProration diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceTest.kt index 1fce5bea1..42a8033cb 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceTest.kt @@ -130,6 +130,7 @@ internal class PriceTest { assertThat(price.unit()).isEqualTo(unit) assertThat(price.tiered()).isNull() assertThat(price.bulk()).isNull() + assertThat(price.bulkWithFilters()).isNull() assertThat(price.package_()).isNull() assertThat(price.matrix()).isNull() assertThat(price.thresholdTotalAmount()).isNull() @@ -402,6 +403,7 @@ internal class PriceTest { assertThat(price.unit()).isNull() assertThat(price.tiered()).isEqualTo(tiered) assertThat(price.bulk()).isNull() + assertThat(price.bulkWithFilters()).isNull() assertThat(price.package_()).isNull() assertThat(price.matrix()).isNull() assertThat(price.thresholdTotalAmount()).isNull() @@ -680,6 +682,7 @@ internal class PriceTest { assertThat(price.unit()).isNull() assertThat(price.tiered()).isNull() assertThat(price.bulk()).isEqualTo(bulk) + assertThat(price.bulkWithFilters()).isNull() assertThat(price.package_()).isNull() assertThat(price.matrix()).isNull() assertThat(price.thresholdTotalAmount()).isNull() @@ -836,6 +839,311 @@ internal class PriceTest { assertThat(roundtrippedPrice).isEqualTo(price) } + @Test + fun ofBulkWithFilters() { + val bulkWithFilters = + Price.BulkWithFilters.builder() + .id("id") + .billableMetric(BillableMetricTiny.builder().id("id").build()) + .billingCycleConfiguration( + BillingCycleConfiguration.builder() + .duration(0L) + .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) + .build() + ) + .billingMode(Price.BulkWithFilters.BillingMode.IN_ADVANCE) + .bulkWithFiltersConfig( + Price.BulkWithFilters.BulkWithFiltersConfig.builder() + .addFilter( + Price.BulkWithFilters.BulkWithFiltersConfig.Filter.builder() + .propertyKey("x") + .propertyValue("x") + .build() + ) + .addTier( + Price.BulkWithFilters.BulkWithFiltersConfig.Tier.builder() + .unitAmount("unit_amount") + .tierLowerBound("tier_lower_bound") + .build() + ) + .addTier( + Price.BulkWithFilters.BulkWithFiltersConfig.Tier.builder() + .unitAmount("unit_amount") + .tierLowerBound("tier_lower_bound") + .build() + ) + .build() + ) + .cadence(Price.BulkWithFilters.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) + .conversionRate(0.0) + .unitConversionRateConfig( + ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() + ) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditAllocation( + Allocation.builder() + .allowsRollover(true) + .currency("currency") + .customExpiration( + CustomExpiration.builder() + .duration(0L) + .durationUnit(CustomExpiration.DurationUnit.DAY) + .build() + ) + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .addFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + BillingCycleConfiguration.builder() + .duration(0L) + .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) + .build() + ) + .item(ItemSlim.builder().id("id").name("name").build()) + .maximum( + Maximum.builder() + .addAppliesToPriceId("string") + .addFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.BulkWithFilters.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Minimum.builder() + .addAppliesToPriceId("string") + .addFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("name") + .planPhaseOrder(0L) + .priceType(Price.BulkWithFilters.PriceType.USAGE_PRICE) + .replacesPriceId("replaces_price_id") + .dimensionalPriceConfiguration( + DimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .build() + ) + .build() + + val price = Price.ofBulkWithFilters(bulkWithFilters) + + assertThat(price.unit()).isNull() + assertThat(price.tiered()).isNull() + assertThat(price.bulk()).isNull() + assertThat(price.bulkWithFilters()).isEqualTo(bulkWithFilters) + assertThat(price.package_()).isNull() + assertThat(price.matrix()).isNull() + assertThat(price.thresholdTotalAmount()).isNull() + assertThat(price.tieredPackage()).isNull() + assertThat(price.tieredWithMinimum()).isNull() + assertThat(price.groupedTiered()).isNull() + assertThat(price.tieredPackageWithMinimum()).isNull() + assertThat(price.packageWithAllocation()).isNull() + assertThat(price.unitWithPercent()).isNull() + assertThat(price.matrixWithAllocation()).isNull() + assertThat(price.tieredWithProration()).isNull() + assertThat(price.unitWithProration()).isNull() + assertThat(price.groupedAllocation()).isNull() + assertThat(price.bulkWithProration()).isNull() + assertThat(price.groupedWithProratedMinimum()).isNull() + assertThat(price.groupedWithMeteredMinimum()).isNull() + assertThat(price.groupedWithMinMaxThresholds()).isNull() + assertThat(price.matrixWithDisplayName()).isNull() + assertThat(price.groupedTieredPackage()).isNull() + assertThat(price.maxGroupTieredPackage()).isNull() + assertThat(price.scalableMatrixWithUnitPricing()).isNull() + assertThat(price.scalableMatrixWithTieredPricing()).isNull() + assertThat(price.cumulativeGroupedBulk()).isNull() + assertThat(price.minimum()).isNull() + assertThat(price.percent()).isNull() + assertThat(price.eventOutput()).isNull() + } + + @Test + fun ofBulkWithFiltersRoundtrip() { + val jsonMapper = jsonMapper() + val price = + Price.ofBulkWithFilters( + Price.BulkWithFilters.builder() + .id("id") + .billableMetric(BillableMetricTiny.builder().id("id").build()) + .billingCycleConfiguration( + BillingCycleConfiguration.builder() + .duration(0L) + .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) + .build() + ) + .billingMode(Price.BulkWithFilters.BillingMode.IN_ADVANCE) + .bulkWithFiltersConfig( + Price.BulkWithFilters.BulkWithFiltersConfig.builder() + .addFilter( + Price.BulkWithFilters.BulkWithFiltersConfig.Filter.builder() + .propertyKey("x") + .propertyValue("x") + .build() + ) + .addTier( + Price.BulkWithFilters.BulkWithFiltersConfig.Tier.builder() + .unitAmount("unit_amount") + .tierLowerBound("tier_lower_bound") + .build() + ) + .addTier( + Price.BulkWithFilters.BulkWithFiltersConfig.Tier.builder() + .unitAmount("unit_amount") + .tierLowerBound("tier_lower_bound") + .build() + ) + .build() + ) + .cadence(Price.BulkWithFilters.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) + .conversionRate(0.0) + .unitConversionRateConfig( + ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() + ) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditAllocation( + Allocation.builder() + .allowsRollover(true) + .currency("currency") + .customExpiration( + CustomExpiration.builder() + .duration(0L) + .durationUnit(CustomExpiration.DurationUnit.DAY) + .build() + ) + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .addFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + BillingCycleConfiguration.builder() + .duration(0L) + .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) + .build() + ) + .item(ItemSlim.builder().id("id").name("name").build()) + .maximum( + Maximum.builder() + .addAppliesToPriceId("string") + .addFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.BulkWithFilters.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Minimum.builder() + .addAppliesToPriceId("string") + .addFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("name") + .planPhaseOrder(0L) + .priceType(Price.BulkWithFilters.PriceType.USAGE_PRICE) + .replacesPriceId("replaces_price_id") + .dimensionalPriceConfiguration( + DimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .build() + ) + .build() + ) + + val roundtrippedPrice = + jsonMapper.readValue(jsonMapper.writeValueAsString(price), jacksonTypeRef()) + + assertThat(roundtrippedPrice).isEqualTo(price) + } + @Test fun ofPackage() { val package_ = @@ -953,6 +1261,7 @@ internal class PriceTest { assertThat(price.unit()).isNull() assertThat(price.tiered()).isNull() assertThat(price.bulk()).isNull() + assertThat(price.bulkWithFilters()).isNull() assertThat(price.package_()).isEqualTo(package_) assertThat(price.matrix()).isNull() assertThat(price.thresholdTotalAmount()).isNull() @@ -1231,6 +1540,7 @@ internal class PriceTest { assertThat(price.unit()).isNull() assertThat(price.tiered()).isNull() assertThat(price.bulk()).isNull() + assertThat(price.bulkWithFilters()).isNull() assertThat(price.package_()).isNull() assertThat(price.matrix()).isEqualTo(matrix) assertThat(price.thresholdTotalAmount()).isNull() @@ -1522,6 +1832,7 @@ internal class PriceTest { assertThat(price.unit()).isNull() assertThat(price.tiered()).isNull() assertThat(price.bulk()).isNull() + assertThat(price.bulkWithFilters()).isNull() assertThat(price.package_()).isNull() assertThat(price.matrix()).isNull() assertThat(price.thresholdTotalAmount()).isEqualTo(thresholdTotalAmount) @@ -1820,6 +2131,7 @@ internal class PriceTest { assertThat(price.unit()).isNull() assertThat(price.tiered()).isNull() assertThat(price.bulk()).isNull() + assertThat(price.bulkWithFilters()).isNull() assertThat(price.package_()).isNull() assertThat(price.matrix()).isNull() assertThat(price.thresholdTotalAmount()).isNull() @@ -2117,6 +2429,7 @@ internal class PriceTest { assertThat(price.unit()).isNull() assertThat(price.tiered()).isNull() assertThat(price.bulk()).isNull() + assertThat(price.bulkWithFilters()).isNull() assertThat(price.package_()).isNull() assertThat(price.matrix()).isNull() assertThat(price.thresholdTotalAmount()).isNull() @@ -2414,6 +2727,7 @@ internal class PriceTest { assertThat(price.unit()).isNull() assertThat(price.tiered()).isNull() assertThat(price.bulk()).isNull() + assertThat(price.bulkWithFilters()).isNull() assertThat(price.package_()).isNull() assertThat(price.matrix()).isNull() assertThat(price.thresholdTotalAmount()).isNull() @@ -2712,6 +3026,7 @@ internal class PriceTest { assertThat(price.unit()).isNull() assertThat(price.tiered()).isNull() assertThat(price.bulk()).isNull() + assertThat(price.bulkWithFilters()).isNull() assertThat(price.package_()).isNull() assertThat(price.matrix()).isNull() assertThat(price.thresholdTotalAmount()).isNull() @@ -3000,6 +3315,7 @@ internal class PriceTest { assertThat(price.unit()).isNull() assertThat(price.tiered()).isNull() assertThat(price.bulk()).isNull() + assertThat(price.bulkWithFilters()).isNull() assertThat(price.package_()).isNull() assertThat(price.matrix()).isNull() assertThat(price.thresholdTotalAmount()).isNull() @@ -3273,6 +3589,7 @@ internal class PriceTest { assertThat(price.unit()).isNull() assertThat(price.tiered()).isNull() assertThat(price.bulk()).isNull() + assertThat(price.bulkWithFilters()).isNull() assertThat(price.package_()).isNull() assertThat(price.matrix()).isNull() assertThat(price.thresholdTotalAmount()).isNull() @@ -3552,6 +3869,7 @@ internal class PriceTest { assertThat(price.unit()).isNull() assertThat(price.tiered()).isNull() assertThat(price.bulk()).isNull() + assertThat(price.bulkWithFilters()).isNull() assertThat(price.package_()).isNull() assertThat(price.matrix()).isNull() assertThat(price.thresholdTotalAmount()).isNull() @@ -3835,6 +4153,7 @@ internal class PriceTest { assertThat(price.unit()).isNull() assertThat(price.tiered()).isNull() assertThat(price.bulk()).isNull() + assertThat(price.bulkWithFilters()).isNull() assertThat(price.package_()).isNull() assertThat(price.matrix()).isNull() assertThat(price.thresholdTotalAmount()).isNull() @@ -4110,6 +4429,7 @@ internal class PriceTest { assertThat(price.unit()).isNull() assertThat(price.tiered()).isNull() assertThat(price.bulk()).isNull() + assertThat(price.bulkWithFilters()).isNull() assertThat(price.package_()).isNull() assertThat(price.matrix()).isNull() assertThat(price.thresholdTotalAmount()).isNull() @@ -4382,6 +4702,7 @@ internal class PriceTest { assertThat(price.unit()).isNull() assertThat(price.tiered()).isNull() assertThat(price.bulk()).isNull() + assertThat(price.bulkWithFilters()).isNull() assertThat(price.package_()).isNull() assertThat(price.matrix()).isNull() assertThat(price.thresholdTotalAmount()).isNull() @@ -4665,6 +4986,7 @@ internal class PriceTest { assertThat(price.unit()).isNull() assertThat(price.tiered()).isNull() assertThat(price.bulk()).isNull() + assertThat(price.bulkWithFilters()).isNull() assertThat(price.package_()).isNull() assertThat(price.matrix()).isNull() assertThat(price.thresholdTotalAmount()).isNull() @@ -4948,6 +5270,7 @@ internal class PriceTest { assertThat(price.unit()).isNull() assertThat(price.tiered()).isNull() assertThat(price.bulk()).isNull() + assertThat(price.bulkWithFilters()).isNull() assertThat(price.package_()).isNull() assertThat(price.matrix()).isNull() assertThat(price.thresholdTotalAmount()).isNull() @@ -5239,6 +5562,7 @@ internal class PriceTest { assertThat(price.unit()).isNull() assertThat(price.tiered()).isNull() assertThat(price.bulk()).isNull() + assertThat(price.bulkWithFilters()).isNull() assertThat(price.package_()).isNull() assertThat(price.matrix()).isNull() assertThat(price.thresholdTotalAmount()).isNull() @@ -5531,6 +5855,7 @@ internal class PriceTest { assertThat(price.unit()).isNull() assertThat(price.tiered()).isNull() assertThat(price.bulk()).isNull() + assertThat(price.bulkWithFilters()).isNull() assertThat(price.package_()).isNull() assertThat(price.matrix()).isNull() assertThat(price.thresholdTotalAmount()).isNull() @@ -5813,6 +6138,7 @@ internal class PriceTest { assertThat(price.unit()).isNull() assertThat(price.tiered()).isNull() assertThat(price.bulk()).isNull() + assertThat(price.bulkWithFilters()).isNull() assertThat(price.package_()).isNull() assertThat(price.matrix()).isNull() assertThat(price.thresholdTotalAmount()).isNull() @@ -6104,6 +6430,7 @@ internal class PriceTest { assertThat(price.unit()).isNull() assertThat(price.tiered()).isNull() assertThat(price.bulk()).isNull() + assertThat(price.bulkWithFilters()).isNull() assertThat(price.package_()).isNull() assertThat(price.matrix()).isNull() assertThat(price.thresholdTotalAmount()).isNull() @@ -6400,6 +6727,7 @@ internal class PriceTest { assertThat(price.unit()).isNull() assertThat(price.tiered()).isNull() assertThat(price.bulk()).isNull() + assertThat(price.bulkWithFilters()).isNull() assertThat(price.package_()).isNull() assertThat(price.matrix()).isNull() assertThat(price.thresholdTotalAmount()).isNull() @@ -6698,6 +7026,7 @@ internal class PriceTest { assertThat(price.unit()).isNull() assertThat(price.tiered()).isNull() assertThat(price.bulk()).isNull() + assertThat(price.bulkWithFilters()).isNull() assertThat(price.package_()).isNull() assertThat(price.matrix()).isNull() assertThat(price.thresholdTotalAmount()).isNull() @@ -7012,6 +7341,7 @@ internal class PriceTest { assertThat(price.unit()).isNull() assertThat(price.tiered()).isNull() assertThat(price.bulk()).isNull() + assertThat(price.bulkWithFilters()).isNull() assertThat(price.package_()).isNull() assertThat(price.matrix()).isNull() assertThat(price.thresholdTotalAmount()).isNull() @@ -7321,6 +7651,7 @@ internal class PriceTest { assertThat(price.unit()).isNull() assertThat(price.tiered()).isNull() assertThat(price.bulk()).isNull() + assertThat(price.bulkWithFilters()).isNull() assertThat(price.package_()).isNull() assertThat(price.matrix()).isNull() assertThat(price.thresholdTotalAmount()).isNull() @@ -7601,6 +7932,7 @@ internal class PriceTest { assertThat(price.unit()).isNull() assertThat(price.tiered()).isNull() assertThat(price.bulk()).isNull() + assertThat(price.bulkWithFilters()).isNull() assertThat(price.package_()).isNull() assertThat(price.matrix()).isNull() assertThat(price.thresholdTotalAmount()).isNull() @@ -7868,6 +8200,7 @@ internal class PriceTest { assertThat(price.unit()).isNull() assertThat(price.tiered()).isNull() assertThat(price.bulk()).isNull() + assertThat(price.bulkWithFilters()).isNull() assertThat(price.package_()).isNull() assertThat(price.matrix()).isNull() assertThat(price.thresholdTotalAmount()).isNull() @@ -8135,6 +8468,7 @@ internal class PriceTest { assertThat(price.unit()).isNull() assertThat(price.tiered()).isNull() assertThat(price.bulk()).isNull() + assertThat(price.bulkWithFilters()).isNull() assertThat(price.package_()).isNull() assertThat(price.matrix()).isNull() assertThat(price.thresholdTotalAmount()).isNull() From 0285f3a1dd36ff49e345c862ac5dd8e714019df1 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 15 Oct 2025 20:33:17 +0000 Subject: [PATCH 32/68] feat(api): api update --- .stats.yml | 4 +- ...editLedgerCreateEntryByExternalIdParams.kt | 46 ++++++++++++++++++- .../CustomerCreditLedgerCreateEntryParams.kt | 46 ++++++++++++++++++- ...LedgerCreateEntryByExternalIdParamsTest.kt | 3 ++ ...stomerCreditLedgerCreateEntryParamsTest.kt | 3 ++ .../credits/LedgerServiceAsyncTest.kt | 2 + .../customers/credits/LedgerServiceTest.kt | 2 + 7 files changed, 102 insertions(+), 4 deletions(-) diff --git a/.stats.yml b/.stats.yml index 0fdea26bb..d2bd16b22 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 118 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-d0eaf664d43e26c42ebf8740ff1b6ee34c4d424c7048a7f04df994cb65627f89.yml -openapi_spec_hash: 4d7622040380d5c7bd2e5a5ec9b86783 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-2b5eeb4a60cbec92f80b4a54f33c2d17b36cbac4739886f737108f2ad74ff12d.yml +openapi_spec_hash: ebbe8419f5831506de5b4c0b4eb56acf config_hash: 1f73a949b649ecfe6ec68ba1bb459dc2 diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdParams.kt index 6437950b4..29dbfdcf7 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdParams.kt @@ -1141,6 +1141,7 @@ private constructor( private val netTerms: JsonField, private val customDueDate: JsonField, private val invoiceDate: JsonField, + private val itemId: JsonField, private val memo: JsonField, private val requireSuccessfulPayment: JsonField, private val additionalProperties: MutableMap, @@ -1160,6 +1161,9 @@ private constructor( @JsonProperty("invoice_date") @ExcludeMissing invoiceDate: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), @JsonProperty("memo") @ExcludeMissing memo: JsonField = JsonMissing.of(), @@ -1171,6 +1175,7 @@ private constructor( netTerms, customDueDate, invoiceDate, + itemId, memo, requireSuccessfulPayment, mutableMapOf(), @@ -1217,6 +1222,15 @@ private constructor( */ fun invoiceDate(): InvoiceDate? = invoiceDate.getNullable("invoice_date") + /** + * The ID of the Item to be used for the invoice line item. If not provided, a + * default 'Credits' item will be used. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun itemId(): String? = itemId.getNullable("item_id") + /** * An optional memo to display on the invoice. * @@ -1275,6 +1289,14 @@ private constructor( @ExcludeMissing fun _invoiceDate(): JsonField = invoiceDate + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + /** * Returns the raw JSON value of [memo]. * @@ -1326,6 +1348,7 @@ private constructor( private var netTerms: JsonField? = null private var customDueDate: JsonField = JsonMissing.of() private var invoiceDate: JsonField = JsonMissing.of() + private var itemId: JsonField = JsonMissing.of() private var memo: JsonField = JsonMissing.of() private var requireSuccessfulPayment: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -1335,6 +1358,7 @@ private constructor( netTerms = invoiceSettings.netTerms customDueDate = invoiceSettings.customDueDate invoiceDate = invoiceSettings.invoiceDate + itemId = invoiceSettings.itemId memo = invoiceSettings.memo requireSuccessfulPayment = invoiceSettings.requireSuccessfulPayment additionalProperties = invoiceSettings.additionalProperties.toMutableMap() @@ -1437,6 +1461,21 @@ private constructor( fun invoiceDate(dateTime: OffsetDateTime) = invoiceDate(InvoiceDate.ofDateTime(dateTime)) + /** + * The ID of the Item to be used for the invoice line item. If not provided, a + * default 'Credits' item will be used. + */ + fun itemId(itemId: String?) = itemId(JsonField.ofNullable(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + /** An optional memo to display on the invoice. */ fun memo(memo: String?) = memo(JsonField.ofNullable(memo)) @@ -1509,6 +1548,7 @@ private constructor( checkRequired("netTerms", netTerms), customDueDate, invoiceDate, + itemId, memo, requireSuccessfulPayment, additionalProperties.toMutableMap(), @@ -1526,6 +1566,7 @@ private constructor( netTerms() customDueDate()?.validate() invoiceDate()?.validate() + itemId() memo() requireSuccessfulPayment() validated = true @@ -1550,6 +1591,7 @@ private constructor( (if (netTerms.asKnown() == null) 0 else 1) + (customDueDate.asKnown()?.validity() ?: 0) + (invoiceDate.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + (if (memo.asKnown() == null) 0 else 1) + (if (requireSuccessfulPayment.asKnown() == null) 0 else 1) @@ -1920,6 +1962,7 @@ private constructor( netTerms == other.netTerms && customDueDate == other.customDueDate && invoiceDate == other.invoiceDate && + itemId == other.itemId && memo == other.memo && requireSuccessfulPayment == other.requireSuccessfulPayment && additionalProperties == other.additionalProperties @@ -1931,6 +1974,7 @@ private constructor( netTerms, customDueDate, invoiceDate, + itemId, memo, requireSuccessfulPayment, additionalProperties, @@ -1940,7 +1984,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "InvoiceSettings{autoCollection=$autoCollection, netTerms=$netTerms, customDueDate=$customDueDate, invoiceDate=$invoiceDate, memo=$memo, requireSuccessfulPayment=$requireSuccessfulPayment, additionalProperties=$additionalProperties}" + "InvoiceSettings{autoCollection=$autoCollection, netTerms=$netTerms, customDueDate=$customDueDate, invoiceDate=$invoiceDate, itemId=$itemId, memo=$memo, requireSuccessfulPayment=$requireSuccessfulPayment, additionalProperties=$additionalProperties}" } /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryParams.kt index 53d7256e3..09d015c07 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryParams.kt @@ -1136,6 +1136,7 @@ private constructor( private val netTerms: JsonField, private val customDueDate: JsonField, private val invoiceDate: JsonField, + private val itemId: JsonField, private val memo: JsonField, private val requireSuccessfulPayment: JsonField, private val additionalProperties: MutableMap, @@ -1155,6 +1156,9 @@ private constructor( @JsonProperty("invoice_date") @ExcludeMissing invoiceDate: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), @JsonProperty("memo") @ExcludeMissing memo: JsonField = JsonMissing.of(), @@ -1166,6 +1170,7 @@ private constructor( netTerms, customDueDate, invoiceDate, + itemId, memo, requireSuccessfulPayment, mutableMapOf(), @@ -1212,6 +1217,15 @@ private constructor( */ fun invoiceDate(): InvoiceDate? = invoiceDate.getNullable("invoice_date") + /** + * The ID of the Item to be used for the invoice line item. If not provided, a + * default 'Credits' item will be used. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun itemId(): String? = itemId.getNullable("item_id") + /** * An optional memo to display on the invoice. * @@ -1270,6 +1284,14 @@ private constructor( @ExcludeMissing fun _invoiceDate(): JsonField = invoiceDate + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + /** * Returns the raw JSON value of [memo]. * @@ -1321,6 +1343,7 @@ private constructor( private var netTerms: JsonField? = null private var customDueDate: JsonField = JsonMissing.of() private var invoiceDate: JsonField = JsonMissing.of() + private var itemId: JsonField = JsonMissing.of() private var memo: JsonField = JsonMissing.of() private var requireSuccessfulPayment: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -1330,6 +1353,7 @@ private constructor( netTerms = invoiceSettings.netTerms customDueDate = invoiceSettings.customDueDate invoiceDate = invoiceSettings.invoiceDate + itemId = invoiceSettings.itemId memo = invoiceSettings.memo requireSuccessfulPayment = invoiceSettings.requireSuccessfulPayment additionalProperties = invoiceSettings.additionalProperties.toMutableMap() @@ -1432,6 +1456,21 @@ private constructor( fun invoiceDate(dateTime: OffsetDateTime) = invoiceDate(InvoiceDate.ofDateTime(dateTime)) + /** + * The ID of the Item to be used for the invoice line item. If not provided, a + * default 'Credits' item will be used. + */ + fun itemId(itemId: String?) = itemId(JsonField.ofNullable(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + /** An optional memo to display on the invoice. */ fun memo(memo: String?) = memo(JsonField.ofNullable(memo)) @@ -1504,6 +1543,7 @@ private constructor( checkRequired("netTerms", netTerms), customDueDate, invoiceDate, + itemId, memo, requireSuccessfulPayment, additionalProperties.toMutableMap(), @@ -1521,6 +1561,7 @@ private constructor( netTerms() customDueDate()?.validate() invoiceDate()?.validate() + itemId() memo() requireSuccessfulPayment() validated = true @@ -1545,6 +1586,7 @@ private constructor( (if (netTerms.asKnown() == null) 0 else 1) + (customDueDate.asKnown()?.validity() ?: 0) + (invoiceDate.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + (if (memo.asKnown() == null) 0 else 1) + (if (requireSuccessfulPayment.asKnown() == null) 0 else 1) @@ -1915,6 +1957,7 @@ private constructor( netTerms == other.netTerms && customDueDate == other.customDueDate && invoiceDate == other.invoiceDate && + itemId == other.itemId && memo == other.memo && requireSuccessfulPayment == other.requireSuccessfulPayment && additionalProperties == other.additionalProperties @@ -1926,6 +1969,7 @@ private constructor( netTerms, customDueDate, invoiceDate, + itemId, memo, requireSuccessfulPayment, additionalProperties, @@ -1935,7 +1979,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "InvoiceSettings{autoCollection=$autoCollection, netTerms=$netTerms, customDueDate=$customDueDate, invoiceDate=$invoiceDate, memo=$memo, requireSuccessfulPayment=$requireSuccessfulPayment, additionalProperties=$additionalProperties}" + "InvoiceSettings{autoCollection=$autoCollection, netTerms=$netTerms, customDueDate=$customDueDate, invoiceDate=$invoiceDate, itemId=$itemId, memo=$memo, requireSuccessfulPayment=$requireSuccessfulPayment, additionalProperties=$additionalProperties}" } /** diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdParamsTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdParamsTest.kt index 8fb52e174..7bbe52742 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdParamsTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdParamsTest.kt @@ -29,6 +29,7 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdParamsTest { .netTerms(0L) .customDueDate(LocalDate.parse("2019-12-27")) .invoiceDate(LocalDate.parse("2019-12-27")) + .itemId("item_id") .memo("memo") .requireSuccessfulPayment(true) .build() @@ -78,6 +79,7 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdParamsTest { .netTerms(0L) .customDueDate(LocalDate.parse("2019-12-27")) .invoiceDate(LocalDate.parse("2019-12-27")) + .itemId("item_id") .memo("memo") .requireSuccessfulPayment(true) .build() @@ -113,6 +115,7 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdParamsTest { .netTerms(0L) .customDueDate(LocalDate.parse("2019-12-27")) .invoiceDate(LocalDate.parse("2019-12-27")) + .itemId("item_id") .memo("memo") .requireSuccessfulPayment(true) .build() diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryParamsTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryParamsTest.kt index 746f8a2e5..f9478f7e6 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryParamsTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryParamsTest.kt @@ -28,6 +28,7 @@ internal class CustomerCreditLedgerCreateEntryParamsTest { .netTerms(0L) .customDueDate(LocalDate.parse("2019-12-27")) .invoiceDate(LocalDate.parse("2019-12-27")) + .itemId("item_id") .memo("memo") .requireSuccessfulPayment(true) .build() @@ -75,6 +76,7 @@ internal class CustomerCreditLedgerCreateEntryParamsTest { .netTerms(0L) .customDueDate(LocalDate.parse("2019-12-27")) .invoiceDate(LocalDate.parse("2019-12-27")) + .itemId("item_id") .memo("memo") .requireSuccessfulPayment(true) .build() @@ -107,6 +109,7 @@ internal class CustomerCreditLedgerCreateEntryParamsTest { .netTerms(0L) .customDueDate(LocalDate.parse("2019-12-27")) .invoiceDate(LocalDate.parse("2019-12-27")) + .itemId("item_id") .memo("memo") .requireSuccessfulPayment(true) .build() diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/customers/credits/LedgerServiceAsyncTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/customers/credits/LedgerServiceAsyncTest.kt index cd65ac395..cccdbbab9 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/customers/credits/LedgerServiceAsyncTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/customers/credits/LedgerServiceAsyncTest.kt @@ -56,6 +56,7 @@ internal class LedgerServiceAsyncTest { .netTerms(0L) .customDueDate(LocalDate.parse("2019-12-27")) .invoiceDate(LocalDate.parse("2019-12-27")) + .itemId("item_id") .memo("memo") .requireSuccessfulPayment(true) .build() @@ -103,6 +104,7 @@ internal class LedgerServiceAsyncTest { .netTerms(0L) .customDueDate(LocalDate.parse("2019-12-27")) .invoiceDate(LocalDate.parse("2019-12-27")) + .itemId("item_id") .memo("memo") .requireSuccessfulPayment(true) .build() diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/customers/credits/LedgerServiceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/customers/credits/LedgerServiceTest.kt index f57c343cc..a72a537a1 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/customers/credits/LedgerServiceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/customers/credits/LedgerServiceTest.kt @@ -56,6 +56,7 @@ internal class LedgerServiceTest { .netTerms(0L) .customDueDate(LocalDate.parse("2019-12-27")) .invoiceDate(LocalDate.parse("2019-12-27")) + .itemId("item_id") .memo("memo") .requireSuccessfulPayment(true) .build() @@ -103,6 +104,7 @@ internal class LedgerServiceTest { .netTerms(0L) .customDueDate(LocalDate.parse("2019-12-27")) .invoiceDate(LocalDate.parse("2019-12-27")) + .itemId("item_id") .memo("memo") .requireSuccessfulPayment(true) .build() From f47c49b90ec5c7262d09b0e24ef1815270644117 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 16 Oct 2025 18:33:09 +0000 Subject: [PATCH 33/68] codegen metadata --- .stats.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.stats.yml b/.stats.yml index d2bd16b22..c97965bce 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 118 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-2b5eeb4a60cbec92f80b4a54f33c2d17b36cbac4739886f737108f2ad74ff12d.yml -openapi_spec_hash: ebbe8419f5831506de5b4c0b4eb56acf +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-cc3ad3383dd73a4bf35b91b19baf855439ec29635ee500163e0bd972faef7bea.yml +openapi_spec_hash: 671698714962b7a17f2f1fc308ad9434 config_hash: 1f73a949b649ecfe6ec68ba1bb459dc2 From a58f47b9e018a45680b2819cbc6ff9945779573d Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 17 Oct 2025 20:33:09 +0000 Subject: [PATCH 34/68] feat(api): api update --- .stats.yml | 4 +- .../com/withorb/api/models/AffectedBlock.kt | 590 +- .../com/withorb/api/models/AmountDiscount.kt | 554 +- .../api/models/AmountDiscountInterval.kt | 554 +- .../api/models/BetaCreatePlanVersionParams.kt | 122 +- ...taExternalPlanIdCreatePlanVersionParams.kt | 122 +- .../kotlin/com/withorb/api/models/Maximum.kt | 555 +- .../com/withorb/api/models/MaximumInterval.kt | 555 +- .../kotlin/com/withorb/api/models/Minimum.kt | 555 +- .../com/withorb/api/models/MinimumInterval.kt | 555 +- .../MonetaryAmountDiscountAdjustment.kt | 554 +- .../api/models/MonetaryMaximumAdjustment.kt | 554 +- .../api/models/MonetaryMinimumAdjustment.kt | 554 +- .../MonetaryPercentageDiscountAdjustment.kt | 554 +- .../models/MonetaryUsageDiscountAdjustment.kt | 554 +- .../withorb/api/models/NewAmountDiscount.kt | 554 +- .../com/withorb/api/models/NewMaximum.kt | 554 +- .../com/withorb/api/models/NewMinimum.kt | 554 +- .../api/models/NewPercentageDiscount.kt | 554 +- .../withorb/api/models/NewUsageDiscount.kt | 554 +- .../withorb/api/models/PercentageDiscount.kt | 554 +- .../api/models/PercentageDiscountInterval.kt | 554 +- .../withorb/api/models/PlanCreateParams.kt | 61 +- .../PlanPhaseAmountDiscountAdjustment.kt | 554 +- .../api/models/PlanPhaseMaximumAdjustment.kt | 554 +- .../api/models/PlanPhaseMinimumAdjustment.kt | 554 +- .../PlanPhasePercentageDiscountAdjustment.kt | 554 +- .../PlanPhaseUsageDiscountAdjustment.kt | 554 +- .../kotlin/com/withorb/api/models/Price.kt | 16855 +++++++++++++++- .../withorb/api/models/PriceCreateParams.kt | 55 +- .../api/models/PriceEvaluateMultipleParams.kt | 61 +- .../PriceEvaluatePreviewEventsParams.kt | 61 +- .../api/models/SubscriptionCreateParams.kt | 122 +- .../SubscriptionPriceIntervalsParams.kt | 61 +- .../SubscriptionSchedulePlanChangeParams.kt | 122 +- .../api/models/TransformPriceFilter.kt | 534 - .../com/withorb/api/models/TrialDiscount.kt | 554 +- .../com/withorb/api/models/UsageDiscount.kt | 554 +- .../api/models/UsageDiscountInterval.kt | 554 +- .../api/models/AdjustmentIntervalTest.kt | 18 +- .../withorb/api/models/AffectedBlockTest.kt | 22 + .../withorb/api/models/AggregatedCostTest.kt | 76 +- .../api/models/AmendmentLedgerEntryTest.kt | 21 + .../api/models/AmountDiscountIntervalTest.kt | 18 +- .../withorb/api/models/AmountDiscountTest.kt | 18 +- .../models/BetaCreatePlanVersionParamsTest.kt | 36 +- ...ternalPlanIdCreatePlanVersionParamsTest.kt | 36 +- .../ChangedSubscriptionResourcesTest.kt | 500 +- .../api/models/CouponListPageResponseTest.kt | 18 +- .../com/withorb/api/models/CouponTest.kt | 18 +- .../CreditBlockExpiryLedgerEntryTest.kt | 21 + ...ustomerCostListByExternalIdResponseTest.kt | 102 +- .../models/CustomerCostListResponseTest.kt | 102 +- ...dgerCreateEntryByExternalIdResponseTest.kt | 270 +- ...omerCreditLedgerCreateEntryResponseTest.kt | 270 +- ...tLedgerListByExternalIdPageResponseTest.kt | 291 +- ...reditLedgerListByExternalIdResponseTest.kt | 270 +- ...ustomerCreditLedgerListPageResponseTest.kt | 291 +- .../CustomerCreditLedgerListResponseTest.kt | 270 +- .../api/models/DecrementLedgerEntryTest.kt | 21 + .../com/withorb/api/models/DiscountTest.kt | 48 +- .../models/ExpirationChangeLedgerEntryTest.kt | 21 + .../api/models/IncrementLedgerEntryTest.kt | 271 +- .../api/models/InvoiceCreateParamsTest.kt | 18 +- .../InvoiceFetchUpcomingResponseTest.kt | 212 +- .../api/models/InvoiceLevelDiscountTest.kt | 36 +- .../InvoiceLineItemCreateResponseTest.kt | 144 +- .../api/models/InvoiceListPageResponseTest.kt | 250 +- .../com/withorb/api/models/InvoiceTest.kt | 212 +- .../withorb/api/models/MaximumIntervalTest.kt | 18 +- .../com/withorb/api/models/MaximumTest.kt | 18 +- .../withorb/api/models/MinimumIntervalTest.kt | 18 +- .../com/withorb/api/models/MinimumTest.kt | 18 +- .../MonetaryAmountDiscountAdjustmentTest.kt | 18 +- .../models/MonetaryMaximumAdjustmentTest.kt | 18 +- .../models/MonetaryMinimumAdjustmentTest.kt | 18 +- ...onetaryPercentageDiscountAdjustmentTest.kt | 18 +- .../MonetaryUsageDiscountAdjustmentTest.kt | 18 +- .../api/models/MutatedSubscriptionTest.kt | 910 +- .../api/models/NewAmountDiscountTest.kt | 18 +- .../com/withorb/api/models/NewMaximumTest.kt | 18 +- .../com/withorb/api/models/NewMinimumTest.kt | 18 +- .../api/models/NewPercentageDiscountTest.kt | 18 +- .../api/models/NewUsageDiscountTest.kt | 18 +- .../withorb/api/models/PerPriceCostTest.kt | 72 +- .../models/PercentageDiscountIntervalTest.kt | 18 +- .../api/models/PercentageDiscountTest.kt | 18 +- .../api/models/PlanCreateParamsTest.kt | 18 +- .../api/models/PlanListPageResponseTest.kt | 218 +- .../PlanPhaseAmountDiscountAdjustmentTest.kt | 18 +- .../models/PlanPhaseMaximumAdjustmentTest.kt | 18 +- .../models/PlanPhaseMinimumAdjustmentTest.kt | 18 +- ...anPhasePercentageDiscountAdjustmentTest.kt | 18 +- .../PlanPhaseUsageDiscountAdjustmentTest.kt | 18 +- .../kotlin/com/withorb/api/models/PlanTest.kt | 198 +- .../com/withorb/api/models/PlanVersionTest.kt | 90 +- .../withorb/api/models/PriceIntervalTest.kt | 72 +- .../api/models/PriceListPageResponseTest.kt | 72 +- .../com/withorb/api/models/PriceTest.kt | 1528 +- .../SubscriptionChangeApplyResponseTest.kt | 1010 +- .../SubscriptionChangeCancelResponseTest.kt | 1010 +- .../SubscriptionChangeRetrieveResponseTest.kt | 1010 +- .../models/SubscriptionCreateParamsTest.kt | 36 +- .../SubscriptionFetchCostsResponseTest.kt | 102 +- .../SubscriptionPriceIntervalsParamsTest.kt | 18 +- ...ubscriptionSchedulePlanChangeParamsTest.kt | 36 +- .../withorb/api/models/SubscriptionTest.kt | 378 +- .../withorb/api/models/SubscriptionsTest.kt | 460 +- .../api/models/TransformPriceFilterTest.kt | 45 - .../withorb/api/models/TrialDiscountTest.kt | 18 +- .../api/models/UsageDiscountIntervalTest.kt | 18 +- .../withorb/api/models/UsageDiscountTest.kt | 18 +- .../models/VoidInitiatedLedgerEntryTest.kt | 21 + .../withorb/api/models/VoidLedgerEntryTest.kt | 21 + .../services/async/BetaServiceAsyncTest.kt | 17 +- .../services/async/InvoiceServiceAsyncTest.kt | 7 +- .../services/async/PlanServiceAsyncTest.kt | 9 +- .../async/SubscriptionServiceAsyncTest.kt | 41 +- .../beta/ExternalPlanIdServiceAsyncTest.kt | 17 +- .../api/services/blocking/BetaServiceTest.kt | 17 +- .../services/blocking/InvoiceServiceTest.kt | 7 +- .../api/services/blocking/PlanServiceTest.kt | 9 +- .../blocking/SubscriptionServiceTest.kt | 41 +- .../beta/ExternalPlanIdServiceTest.kt | 17 +- 124 files changed, 38489 insertions(+), 6529 deletions(-) delete mode 100644 orb-kotlin-core/src/main/kotlin/com/withorb/api/models/TransformPriceFilter.kt delete mode 100644 orb-kotlin-core/src/test/kotlin/com/withorb/api/models/TransformPriceFilterTest.kt diff --git a/.stats.yml b/.stats.yml index c97965bce..320998e13 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 118 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-cc3ad3383dd73a4bf35b91b19baf855439ec29635ee500163e0bd972faef7bea.yml -openapi_spec_hash: 671698714962b7a17f2f1fc308ad9434 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-828c91953d2351040fdd4d90a3d9eafd09f9d240c4f6ce0441b7a10c06c1c722.yml +openapi_spec_hash: c82bc88563f80f600e59e22014d4cec4 config_hash: 1f73a949b649ecfe6ec68ba1bb459dc2 diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/AffectedBlock.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/AffectedBlock.kt index 9e634a515..f07da4471 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/AffectedBlock.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/AffectedBlock.kt @@ -6,11 +6,14 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty +import com.withorb.api.core.Enum import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue +import com.withorb.api.core.checkKnown import com.withorb.api.core.checkRequired +import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import java.time.OffsetDateTime import java.util.Collections @@ -20,6 +23,7 @@ class AffectedBlock @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, + private val blockFilters: JsonField>, private val expiryDate: JsonField, private val perUnitCostBasis: JsonField, private val additionalProperties: MutableMap, @@ -28,13 +32,16 @@ private constructor( @JsonCreator private constructor( @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("block_filters") + @ExcludeMissing + blockFilters: JsonField> = JsonMissing.of(), @JsonProperty("expiry_date") @ExcludeMissing expiryDate: JsonField = JsonMissing.of(), @JsonProperty("per_unit_cost_basis") @ExcludeMissing perUnitCostBasis: JsonField = JsonMissing.of(), - ) : this(id, expiryDate, perUnitCostBasis, mutableMapOf()) + ) : this(id, blockFilters, expiryDate, perUnitCostBasis, mutableMapOf()) /** * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly @@ -42,6 +49,12 @@ private constructor( */ fun id(): String = id.getRequired("id") + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun blockFilters(): List? = blockFilters.getNullable("block_filters") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server * responded with an unexpected value). @@ -61,6 +74,15 @@ private constructor( */ @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + /** + * Returns the raw JSON value of [blockFilters]. + * + * Unlike [blockFilters], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("block_filters") + @ExcludeMissing + fun _blockFilters(): JsonField> = blockFilters + /** * Returns the raw JSON value of [expiryDate]. * @@ -100,6 +122,7 @@ private constructor( * The following fields are required: * ```kotlin * .id() + * .blockFilters() * .expiryDate() * .perUnitCostBasis() * ``` @@ -111,12 +134,14 @@ private constructor( class Builder internal constructor() { private var id: JsonField? = null + private var blockFilters: JsonField>? = null private var expiryDate: JsonField? = null private var perUnitCostBasis: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(affectedBlock: AffectedBlock) = apply { id = affectedBlock.id + blockFilters = affectedBlock.blockFilters.map { it.toMutableList() } expiryDate = affectedBlock.expiryDate perUnitCostBasis = affectedBlock.perUnitCostBasis additionalProperties = affectedBlock.additionalProperties.toMutableMap() @@ -132,6 +157,32 @@ private constructor( */ fun id(id: JsonField) = apply { this.id = id } + fun blockFilters(blockFilters: List?) = + blockFilters(JsonField.ofNullable(blockFilters)) + + /** + * Sets [Builder.blockFilters] to an arbitrary JSON value. + * + * You should usually call [Builder.blockFilters] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun blockFilters(blockFilters: JsonField>) = apply { + this.blockFilters = blockFilters.map { it.toMutableList() } + } + + /** + * Adds a single [BlockFilter] to [blockFilters]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addBlockFilter(blockFilter: BlockFilter) = apply { + blockFilters = + (blockFilters ?: JsonField.of(mutableListOf())).also { + checkKnown("blockFilters", it).add(blockFilter) + } + } + fun expiryDate(expiryDate: OffsetDateTime?) = expiryDate(JsonField.ofNullable(expiryDate)) /** @@ -186,6 +237,7 @@ private constructor( * The following fields are required: * ```kotlin * .id() + * .blockFilters() * .expiryDate() * .perUnitCostBasis() * ``` @@ -195,6 +247,7 @@ private constructor( fun build(): AffectedBlock = AffectedBlock( checkRequired("id", id), + checkRequired("blockFilters", blockFilters).map { it.toImmutable() }, checkRequired("expiryDate", expiryDate), checkRequired("perUnitCostBasis", perUnitCostBasis), additionalProperties.toMutableMap(), @@ -209,6 +262,7 @@ private constructor( } id() + blockFilters()?.forEach { it.validate() } expiryDate() perUnitCostBasis() validated = true @@ -229,9 +283,538 @@ private constructor( */ internal fun validity(): Int = (if (id.asKnown() == null) 0 else 1) + + (blockFilters.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + (if (expiryDate.asKnown() == null) 0 else 1) + (if (perUnitCostBasis.asKnown() == null) 0 else 1) + class BlockFilter + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val field: JsonField, + private val operator: JsonField, + private val values: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("field") @ExcludeMissing field: JsonField = JsonMissing.of(), + @JsonProperty("operator") + @ExcludeMissing + operator: JsonField = JsonMissing.of(), + @JsonProperty("values") + @ExcludeMissing + values: JsonField> = JsonMissing.of(), + ) : this(field, operator, values, mutableMapOf()) + + /** + * The property of the price to filter on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun field(): Field = field.getRequired("field") + + /** + * Should prices that match the filter be included or excluded. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun operator(): Operator = operator.getRequired("operator") + + /** + * The IDs or values that match this filter. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun values(): List = values.getRequired("values") + + /** + * Returns the raw JSON value of [field]. + * + * Unlike [field], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("field") @ExcludeMissing fun _field(): JsonField = field + + /** + * Returns the raw JSON value of [operator]. + * + * Unlike [operator], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("operator") @ExcludeMissing fun _operator(): JsonField = operator + + /** + * Returns the raw JSON value of [values]. + * + * Unlike [values], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("values") @ExcludeMissing fun _values(): JsonField> = values + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [BlockFilter]. + * + * The following fields are required: + * ```kotlin + * .field() + * .operator() + * .values() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [BlockFilter]. */ + class Builder internal constructor() { + + private var field: JsonField? = null + private var operator: JsonField? = null + private var values: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(blockFilter: BlockFilter) = apply { + field = blockFilter.field + operator = blockFilter.operator + values = blockFilter.values.map { it.toMutableList() } + additionalProperties = blockFilter.additionalProperties.toMutableMap() + } + + /** The property of the price to filter on. */ + fun field(field: Field) = field(JsonField.of(field)) + + /** + * Sets [Builder.field] to an arbitrary JSON value. + * + * You should usually call [Builder.field] with a well-typed [Field] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun field(field: JsonField) = apply { this.field = field } + + /** Should prices that match the filter be included or excluded. */ + fun operator(operator: Operator) = operator(JsonField.of(operator)) + + /** + * Sets [Builder.operator] to an arbitrary JSON value. + * + * You should usually call [Builder.operator] with a well-typed [Operator] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun operator(operator: JsonField) = apply { this.operator = operator } + + /** The IDs or values that match this filter. */ + fun values(values: List) = values(JsonField.of(values)) + + /** + * Sets [Builder.values] to an arbitrary JSON value. + * + * You should usually call [Builder.values] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun values(values: JsonField>) = apply { + this.values = values.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [values]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addValue(value: String) = apply { + values = + (values ?: JsonField.of(mutableListOf())).also { + checkKnown("values", it).add(value) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BlockFilter]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .field() + * .operator() + * .values() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BlockFilter = + BlockFilter( + checkRequired("field", field), + checkRequired("operator", operator), + checkRequired("values", values).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): BlockFilter = apply { + if (validated) { + return@apply + } + + field().validate() + operator().validate() + values() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (field.asKnown()?.validity() ?: 0) + + (operator.asKnown()?.validity() ?: 0) + + (values.asKnown()?.size ?: 0) + + /** The property of the price to filter on. */ + class Field @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val PRICE_ID = of("price_id") + + val ITEM_ID = of("item_id") + + val PRICE_TYPE = of("price_type") + + val CURRENCY = of("currency") + + val PRICING_UNIT_ID = of("pricing_unit_id") + + fun of(value: String) = Field(JsonField.of(value)) + } + + /** An enum containing [Field]'s known values. */ + enum class Known { + PRICE_ID, + ITEM_ID, + PRICE_TYPE, + CURRENCY, + PRICING_UNIT_ID, + } + + /** + * An enum containing [Field]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Field] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + PRICE_ID, + ITEM_ID, + PRICE_TYPE, + CURRENCY, + PRICING_UNIT_ID, + /** + * An enum member indicating that [Field] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + PRICE_ID -> Value.PRICE_ID + ITEM_ID -> Value.ITEM_ID + PRICE_TYPE -> Value.PRICE_TYPE + CURRENCY -> Value.CURRENCY + PRICING_UNIT_ID -> Value.PRICING_UNIT_ID + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + PRICE_ID -> Known.PRICE_ID + ITEM_ID -> Known.ITEM_ID + PRICE_TYPE -> Known.PRICE_TYPE + CURRENCY -> Known.CURRENCY + PRICING_UNIT_ID -> Known.PRICING_UNIT_ID + else -> throw OrbInvalidDataException("Unknown Field: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Field = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Field && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Should prices that match the filter be included or excluded. */ + class Operator @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val INCLUDES = of("includes") + + val EXCLUDES = of("excludes") + + fun of(value: String) = Operator(JsonField.of(value)) + } + + /** An enum containing [Operator]'s known values. */ + enum class Known { + INCLUDES, + EXCLUDES, + } + + /** + * An enum containing [Operator]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Operator] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + INCLUDES, + EXCLUDES, + /** + * An enum member indicating that [Operator] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + INCLUDES -> Value.INCLUDES + EXCLUDES -> Value.EXCLUDES + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + INCLUDES -> Known.INCLUDES + EXCLUDES -> Known.EXCLUDES + else -> throw OrbInvalidDataException("Unknown Operator: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Operator = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Operator && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BlockFilter && + field == other.field && + operator == other.operator && + values == other.values && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(field, operator, values, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BlockFilter{field=$field, operator=$operator, values=$values, additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -239,17 +822,18 @@ private constructor( return other is AffectedBlock && id == other.id && + blockFilters == other.blockFilters && expiryDate == other.expiryDate && perUnitCostBasis == other.perUnitCostBasis && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(id, expiryDate, perUnitCostBasis, additionalProperties) + Objects.hash(id, blockFilters, expiryDate, perUnitCostBasis, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "AffectedBlock{id=$id, expiryDate=$expiryDate, perUnitCostBasis=$perUnitCostBasis, additionalProperties=$additionalProperties}" + "AffectedBlock{id=$id, blockFilters=$blockFilters, expiryDate=$expiryDate, perUnitCostBasis=$perUnitCostBasis, additionalProperties=$additionalProperties}" } diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/AmountDiscount.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/AmountDiscount.kt index a921b4f73..5bec912af 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/AmountDiscount.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/AmountDiscount.kt @@ -24,7 +24,7 @@ private constructor( private val amountDiscount: JsonField, private val discountType: JsonField, private val appliesToPriceIds: JsonField>, - private val filters: JsonField>, + private val filters: JsonField>, private val reason: JsonField, private val additionalProperties: MutableMap, ) { @@ -42,7 +42,7 @@ private constructor( appliesToPriceIds: JsonField> = JsonMissing.of(), @JsonProperty("filters") @ExcludeMissing - filters: JsonField> = JsonMissing.of(), + filters: JsonField> = JsonMissing.of(), @JsonProperty("reason") @ExcludeMissing reason: JsonField = JsonMissing.of(), ) : this(amountDiscount, discountType, appliesToPriceIds, filters, reason, mutableMapOf()) @@ -75,7 +75,7 @@ private constructor( * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server * responded with an unexpected value). */ - fun filters(): List? = filters.getNullable("filters") + fun filters(): List? = filters.getNullable("filters") /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server @@ -116,9 +116,7 @@ private constructor( * * Unlike [filters], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("filters") - @ExcludeMissing - fun _filters(): JsonField> = filters + @JsonProperty("filters") @ExcludeMissing fun _filters(): JsonField> = filters /** * Returns the raw JSON value of [reason]. @@ -159,7 +157,7 @@ private constructor( private var amountDiscount: JsonField? = null private var discountType: JsonField? = null private var appliesToPriceIds: JsonField>? = null - private var filters: JsonField>? = null + private var filters: JsonField>? = null private var reason: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -230,25 +228,25 @@ private constructor( } /** The filters that determine which prices to apply this discount to. */ - fun filters(filters: List?) = filters(JsonField.ofNullable(filters)) + fun filters(filters: List?) = filters(JsonField.ofNullable(filters)) /** * Sets [Builder.filters] to an arbitrary JSON value. * - * You should usually call [Builder.filters] with a well-typed `List` - * value instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. + * You should usually call [Builder.filters] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. */ - fun filters(filters: JsonField>) = apply { + fun filters(filters: JsonField>) = apply { this.filters = filters.map { it.toMutableList() } } /** - * Adds a single [TransformPriceFilter] to [filters]. + * Adds a single [Filter] to [filters]. * * @throws IllegalStateException if the field was previously set to a non-list. */ - fun addFilter(filter: TransformPriceFilter) = apply { + fun addFilter(filter: Filter) = apply { filters = (filters ?: JsonField.of(mutableListOf())).also { checkKnown("filters", it).add(filter) @@ -464,6 +462,534 @@ private constructor( override fun toString() = value.toString() } + class Filter + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val field: JsonField, + private val operator: JsonField, + private val values: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("field") @ExcludeMissing field: JsonField = JsonMissing.of(), + @JsonProperty("operator") + @ExcludeMissing + operator: JsonField = JsonMissing.of(), + @JsonProperty("values") + @ExcludeMissing + values: JsonField> = JsonMissing.of(), + ) : this(field, operator, values, mutableMapOf()) + + /** + * The property of the price to filter on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun field(): Field = field.getRequired("field") + + /** + * Should prices that match the filter be included or excluded. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun operator(): Operator = operator.getRequired("operator") + + /** + * The IDs or values that match this filter. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun values(): List = values.getRequired("values") + + /** + * Returns the raw JSON value of [field]. + * + * Unlike [field], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("field") @ExcludeMissing fun _field(): JsonField = field + + /** + * Returns the raw JSON value of [operator]. + * + * Unlike [operator], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("operator") @ExcludeMissing fun _operator(): JsonField = operator + + /** + * Returns the raw JSON value of [values]. + * + * Unlike [values], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("values") @ExcludeMissing fun _values(): JsonField> = values + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Filter]. + * + * The following fields are required: + * ```kotlin + * .field() + * .operator() + * .values() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Filter]. */ + class Builder internal constructor() { + + private var field: JsonField? = null + private var operator: JsonField? = null + private var values: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(filter: Filter) = apply { + field = filter.field + operator = filter.operator + values = filter.values.map { it.toMutableList() } + additionalProperties = filter.additionalProperties.toMutableMap() + } + + /** The property of the price to filter on. */ + fun field(field: Field) = field(JsonField.of(field)) + + /** + * Sets [Builder.field] to an arbitrary JSON value. + * + * You should usually call [Builder.field] with a well-typed [Field] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun field(field: JsonField) = apply { this.field = field } + + /** Should prices that match the filter be included or excluded. */ + fun operator(operator: Operator) = operator(JsonField.of(operator)) + + /** + * Sets [Builder.operator] to an arbitrary JSON value. + * + * You should usually call [Builder.operator] with a well-typed [Operator] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun operator(operator: JsonField) = apply { this.operator = operator } + + /** The IDs or values that match this filter. */ + fun values(values: List) = values(JsonField.of(values)) + + /** + * Sets [Builder.values] to an arbitrary JSON value. + * + * You should usually call [Builder.values] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun values(values: JsonField>) = apply { + this.values = values.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [values]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addValue(value: String) = apply { + values = + (values ?: JsonField.of(mutableListOf())).also { + checkKnown("values", it).add(value) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Filter]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .field() + * .operator() + * .values() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Filter = + Filter( + checkRequired("field", field), + checkRequired("operator", operator), + checkRequired("values", values).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Filter = apply { + if (validated) { + return@apply + } + + field().validate() + operator().validate() + values() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (field.asKnown()?.validity() ?: 0) + + (operator.asKnown()?.validity() ?: 0) + + (values.asKnown()?.size ?: 0) + + /** The property of the price to filter on. */ + class Field @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val PRICE_ID = of("price_id") + + val ITEM_ID = of("item_id") + + val PRICE_TYPE = of("price_type") + + val CURRENCY = of("currency") + + val PRICING_UNIT_ID = of("pricing_unit_id") + + fun of(value: String) = Field(JsonField.of(value)) + } + + /** An enum containing [Field]'s known values. */ + enum class Known { + PRICE_ID, + ITEM_ID, + PRICE_TYPE, + CURRENCY, + PRICING_UNIT_ID, + } + + /** + * An enum containing [Field]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Field] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + PRICE_ID, + ITEM_ID, + PRICE_TYPE, + CURRENCY, + PRICING_UNIT_ID, + /** + * An enum member indicating that [Field] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + PRICE_ID -> Value.PRICE_ID + ITEM_ID -> Value.ITEM_ID + PRICE_TYPE -> Value.PRICE_TYPE + CURRENCY -> Value.CURRENCY + PRICING_UNIT_ID -> Value.PRICING_UNIT_ID + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + PRICE_ID -> Known.PRICE_ID + ITEM_ID -> Known.ITEM_ID + PRICE_TYPE -> Known.PRICE_TYPE + CURRENCY -> Known.CURRENCY + PRICING_UNIT_ID -> Known.PRICING_UNIT_ID + else -> throw OrbInvalidDataException("Unknown Field: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Field = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Field && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Should prices that match the filter be included or excluded. */ + class Operator @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val INCLUDES = of("includes") + + val EXCLUDES = of("excludes") + + fun of(value: String) = Operator(JsonField.of(value)) + } + + /** An enum containing [Operator]'s known values. */ + enum class Known { + INCLUDES, + EXCLUDES, + } + + /** + * An enum containing [Operator]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Operator] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + INCLUDES, + EXCLUDES, + /** + * An enum member indicating that [Operator] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + INCLUDES -> Value.INCLUDES + EXCLUDES -> Value.EXCLUDES + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + INCLUDES -> Known.INCLUDES + EXCLUDES -> Known.EXCLUDES + else -> throw OrbInvalidDataException("Unknown Operator: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Operator = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Operator && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Filter && + field == other.field && + operator == other.operator && + values == other.values && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(field, operator, values, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Filter{field=$field, operator=$operator, values=$values, additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/AmountDiscountInterval.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/AmountDiscountInterval.kt index a1fff5676..40d6c920e 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/AmountDiscountInterval.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/AmountDiscountInterval.kt @@ -26,7 +26,7 @@ private constructor( private val appliesToPriceIntervalIds: JsonField>, private val discountType: JsonField, private val endDate: JsonField, - private val filters: JsonField>, + private val filters: JsonField>, private val startDate: JsonField, private val additionalProperties: MutableMap, ) { @@ -47,7 +47,7 @@ private constructor( endDate: JsonField = JsonMissing.of(), @JsonProperty("filters") @ExcludeMissing - filters: JsonField> = JsonMissing.of(), + filters: JsonField> = JsonMissing.of(), @JsonProperty("start_date") @ExcludeMissing startDate: JsonField = JsonMissing.of(), @@ -98,7 +98,7 @@ private constructor( * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ - fun filters(): List = filters.getRequired("filters") + fun filters(): List = filters.getRequired("filters") /** * The start date of the discount interval. @@ -148,9 +148,7 @@ private constructor( * * Unlike [filters], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("filters") - @ExcludeMissing - fun _filters(): JsonField> = filters + @JsonProperty("filters") @ExcludeMissing fun _filters(): JsonField> = filters /** * Returns the raw JSON value of [startDate]. @@ -198,7 +196,7 @@ private constructor( private var appliesToPriceIntervalIds: JsonField>? = null private var discountType: JsonField? = null private var endDate: JsonField? = null - private var filters: JsonField>? = null + private var filters: JsonField>? = null private var startDate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -280,25 +278,25 @@ private constructor( fun endDate(endDate: JsonField) = apply { this.endDate = endDate } /** The filters that determine which prices this discount interval applies to. */ - fun filters(filters: List) = filters(JsonField.of(filters)) + fun filters(filters: List) = filters(JsonField.of(filters)) /** * Sets [Builder.filters] to an arbitrary JSON value. * - * You should usually call [Builder.filters] with a well-typed `List` - * value instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. + * You should usually call [Builder.filters] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. */ - fun filters(filters: JsonField>) = apply { + fun filters(filters: JsonField>) = apply { this.filters = filters.map { it.toMutableList() } } /** - * Adds a single [TransformPriceFilter] to [filters]. + * Adds a single [Filter] to [filters]. * * @throws IllegalStateException if the field was previously set to a non-list. */ - fun addFilter(filter: TransformPriceFilter) = apply { + fun addFilter(filter: Filter) = apply { filters = (filters ?: JsonField.of(mutableListOf())).also { checkKnown("filters", it).add(filter) @@ -525,6 +523,534 @@ private constructor( override fun toString() = value.toString() } + class Filter + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val field: JsonField, + private val operator: JsonField, + private val values: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("field") @ExcludeMissing field: JsonField = JsonMissing.of(), + @JsonProperty("operator") + @ExcludeMissing + operator: JsonField = JsonMissing.of(), + @JsonProperty("values") + @ExcludeMissing + values: JsonField> = JsonMissing.of(), + ) : this(field, operator, values, mutableMapOf()) + + /** + * The property of the price to filter on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun field(): Field = field.getRequired("field") + + /** + * Should prices that match the filter be included or excluded. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun operator(): Operator = operator.getRequired("operator") + + /** + * The IDs or values that match this filter. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun values(): List = values.getRequired("values") + + /** + * Returns the raw JSON value of [field]. + * + * Unlike [field], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("field") @ExcludeMissing fun _field(): JsonField = field + + /** + * Returns the raw JSON value of [operator]. + * + * Unlike [operator], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("operator") @ExcludeMissing fun _operator(): JsonField = operator + + /** + * Returns the raw JSON value of [values]. + * + * Unlike [values], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("values") @ExcludeMissing fun _values(): JsonField> = values + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Filter]. + * + * The following fields are required: + * ```kotlin + * .field() + * .operator() + * .values() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Filter]. */ + class Builder internal constructor() { + + private var field: JsonField? = null + private var operator: JsonField? = null + private var values: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(filter: Filter) = apply { + field = filter.field + operator = filter.operator + values = filter.values.map { it.toMutableList() } + additionalProperties = filter.additionalProperties.toMutableMap() + } + + /** The property of the price to filter on. */ + fun field(field: Field) = field(JsonField.of(field)) + + /** + * Sets [Builder.field] to an arbitrary JSON value. + * + * You should usually call [Builder.field] with a well-typed [Field] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun field(field: JsonField) = apply { this.field = field } + + /** Should prices that match the filter be included or excluded. */ + fun operator(operator: Operator) = operator(JsonField.of(operator)) + + /** + * Sets [Builder.operator] to an arbitrary JSON value. + * + * You should usually call [Builder.operator] with a well-typed [Operator] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun operator(operator: JsonField) = apply { this.operator = operator } + + /** The IDs or values that match this filter. */ + fun values(values: List) = values(JsonField.of(values)) + + /** + * Sets [Builder.values] to an arbitrary JSON value. + * + * You should usually call [Builder.values] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun values(values: JsonField>) = apply { + this.values = values.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [values]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addValue(value: String) = apply { + values = + (values ?: JsonField.of(mutableListOf())).also { + checkKnown("values", it).add(value) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Filter]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .field() + * .operator() + * .values() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Filter = + Filter( + checkRequired("field", field), + checkRequired("operator", operator), + checkRequired("values", values).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Filter = apply { + if (validated) { + return@apply + } + + field().validate() + operator().validate() + values() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (field.asKnown()?.validity() ?: 0) + + (operator.asKnown()?.validity() ?: 0) + + (values.asKnown()?.size ?: 0) + + /** The property of the price to filter on. */ + class Field @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val PRICE_ID = of("price_id") + + val ITEM_ID = of("item_id") + + val PRICE_TYPE = of("price_type") + + val CURRENCY = of("currency") + + val PRICING_UNIT_ID = of("pricing_unit_id") + + fun of(value: String) = Field(JsonField.of(value)) + } + + /** An enum containing [Field]'s known values. */ + enum class Known { + PRICE_ID, + ITEM_ID, + PRICE_TYPE, + CURRENCY, + PRICING_UNIT_ID, + } + + /** + * An enum containing [Field]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Field] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + PRICE_ID, + ITEM_ID, + PRICE_TYPE, + CURRENCY, + PRICING_UNIT_ID, + /** + * An enum member indicating that [Field] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + PRICE_ID -> Value.PRICE_ID + ITEM_ID -> Value.ITEM_ID + PRICE_TYPE -> Value.PRICE_TYPE + CURRENCY -> Value.CURRENCY + PRICING_UNIT_ID -> Value.PRICING_UNIT_ID + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + PRICE_ID -> Known.PRICE_ID + ITEM_ID -> Known.ITEM_ID + PRICE_TYPE -> Known.PRICE_TYPE + CURRENCY -> Known.CURRENCY + PRICING_UNIT_ID -> Known.PRICING_UNIT_ID + else -> throw OrbInvalidDataException("Unknown Field: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Field = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Field && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Should prices that match the filter be included or excluded. */ + class Operator @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val INCLUDES = of("includes") + + val EXCLUDES = of("excludes") + + fun of(value: String) = Operator(JsonField.of(value)) + } + + /** An enum containing [Operator]'s known values. */ + enum class Known { + INCLUDES, + EXCLUDES, + } + + /** + * An enum containing [Operator]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Operator] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + INCLUDES, + EXCLUDES, + /** + * An enum member indicating that [Operator] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + INCLUDES -> Value.INCLUDES + EXCLUDES -> Value.EXCLUDES + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + INCLUDES -> Known.INCLUDES + EXCLUDES -> Known.EXCLUDES + else -> throw OrbInvalidDataException("Unknown Operator: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Operator = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Operator && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Filter && + field == other.field && + operator == other.operator && + values == other.values && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(field, operator, values, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Filter{field=$field, operator=$operator, values=$values, additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BetaCreatePlanVersionParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BetaCreatePlanVersionParams.kt index 38cc195ca..8d7025189 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BetaCreatePlanVersionParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BetaCreatePlanVersionParams.kt @@ -11445,6 +11445,7 @@ private constructor( @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val unitRatingKey: JsonField, + private val defaultUnitRate: JsonField, private val groupingKey: JsonField, private val additionalProperties: MutableMap, ) { @@ -11454,10 +11455,13 @@ private constructor( @JsonProperty("unit_rating_key") @ExcludeMissing unitRatingKey: JsonField = JsonMissing.of(), + @JsonProperty("default_unit_rate") + @ExcludeMissing + defaultUnitRate: JsonField = JsonMissing.of(), @JsonProperty("grouping_key") @ExcludeMissing groupingKey: JsonField = JsonMissing.of(), - ) : this(unitRatingKey, groupingKey, mutableMapOf()) + ) : this(unitRatingKey, defaultUnitRate, groupingKey, mutableMapOf()) /** * The key in the event data to extract the unit rate from. @@ -11468,6 +11472,17 @@ private constructor( */ fun unitRatingKey(): String = unitRatingKey.getRequired("unit_rating_key") + /** + * If provided, this amount will be used as the unit rate when an event does not + * have a value for the `unit_rating_key`. If not provided, events missing a + * unit rate will be ignored. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun defaultUnitRate(): String? = + defaultUnitRate.getNullable("default_unit_rate") + /** * An optional key in the event data to group by (e.g., event ID). All events * will also be grouped by their unit rate. @@ -11487,6 +11502,16 @@ private constructor( @ExcludeMissing fun _unitRatingKey(): JsonField = unitRatingKey + /** + * Returns the raw JSON value of [defaultUnitRate]. + * + * Unlike [defaultUnitRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("default_unit_rate") + @ExcludeMissing + fun _defaultUnitRate(): JsonField = defaultUnitRate + /** * Returns the raw JSON value of [groupingKey]. * @@ -11527,12 +11552,14 @@ private constructor( class Builder internal constructor() { private var unitRatingKey: JsonField? = null + private var defaultUnitRate: JsonField = JsonMissing.of() private var groupingKey: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() internal fun from(eventOutputConfig: EventOutputConfig) = apply { unitRatingKey = eventOutputConfig.unitRatingKey + defaultUnitRate = eventOutputConfig.defaultUnitRate groupingKey = eventOutputConfig.groupingKey additionalProperties = eventOutputConfig.additionalProperties.toMutableMap() @@ -11553,6 +11580,25 @@ private constructor( this.unitRatingKey = unitRatingKey } + /** + * If provided, this amount will be used as the unit rate when an event does + * not have a value for the `unit_rating_key`. If not provided, events + * missing a unit rate will be ignored. + */ + fun defaultUnitRate(defaultUnitRate: String?) = + defaultUnitRate(JsonField.ofNullable(defaultUnitRate)) + + /** + * Sets [Builder.defaultUnitRate] to an arbitrary JSON value. + * + * You should usually call [Builder.defaultUnitRate] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun defaultUnitRate(defaultUnitRate: JsonField) = apply { + this.defaultUnitRate = defaultUnitRate + } + /** * An optional key in the event data to group by (e.g., event ID). All * events will also be grouped by their unit rate. @@ -11608,6 +11654,7 @@ private constructor( fun build(): EventOutputConfig = EventOutputConfig( checkRequired("unitRatingKey", unitRatingKey), + defaultUnitRate, groupingKey, additionalProperties.toMutableMap(), ) @@ -11621,6 +11668,7 @@ private constructor( } unitRatingKey() + defaultUnitRate() groupingKey() validated = true } @@ -11641,6 +11689,7 @@ private constructor( */ internal fun validity(): Int = (if (unitRatingKey.asKnown() == null) 0 else 1) + + (if (defaultUnitRate.asKnown() == null) 0 else 1) + (if (groupingKey.asKnown() == null) 0 else 1) override fun equals(other: Any?): Boolean { @@ -11650,18 +11699,24 @@ private constructor( return other is EventOutputConfig && unitRatingKey == other.unitRatingKey && + defaultUnitRate == other.defaultUnitRate && groupingKey == other.groupingKey && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(unitRatingKey, groupingKey, additionalProperties) + Objects.hash( + unitRatingKey, + defaultUnitRate, + groupingKey, + additionalProperties, + ) } override fun hashCode(): Int = hashCode override fun toString() = - "EventOutputConfig{unitRatingKey=$unitRatingKey, groupingKey=$groupingKey, additionalProperties=$additionalProperties}" + "EventOutputConfig{unitRatingKey=$unitRatingKey, defaultUnitRate=$defaultUnitRate, groupingKey=$groupingKey, additionalProperties=$additionalProperties}" } /** @@ -22726,6 +22781,7 @@ private constructor( @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val unitRatingKey: JsonField, + private val defaultUnitRate: JsonField, private val groupingKey: JsonField, private val additionalProperties: MutableMap, ) { @@ -22735,10 +22791,13 @@ private constructor( @JsonProperty("unit_rating_key") @ExcludeMissing unitRatingKey: JsonField = JsonMissing.of(), + @JsonProperty("default_unit_rate") + @ExcludeMissing + defaultUnitRate: JsonField = JsonMissing.of(), @JsonProperty("grouping_key") @ExcludeMissing groupingKey: JsonField = JsonMissing.of(), - ) : this(unitRatingKey, groupingKey, mutableMapOf()) + ) : this(unitRatingKey, defaultUnitRate, groupingKey, mutableMapOf()) /** * The key in the event data to extract the unit rate from. @@ -22749,6 +22808,17 @@ private constructor( */ fun unitRatingKey(): String = unitRatingKey.getRequired("unit_rating_key") + /** + * If provided, this amount will be used as the unit rate when an event does not + * have a value for the `unit_rating_key`. If not provided, events missing a + * unit rate will be ignored. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun defaultUnitRate(): String? = + defaultUnitRate.getNullable("default_unit_rate") + /** * An optional key in the event data to group by (e.g., event ID). All events * will also be grouped by their unit rate. @@ -22768,6 +22838,16 @@ private constructor( @ExcludeMissing fun _unitRatingKey(): JsonField = unitRatingKey + /** + * Returns the raw JSON value of [defaultUnitRate]. + * + * Unlike [defaultUnitRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("default_unit_rate") + @ExcludeMissing + fun _defaultUnitRate(): JsonField = defaultUnitRate + /** * Returns the raw JSON value of [groupingKey]. * @@ -22808,12 +22888,14 @@ private constructor( class Builder internal constructor() { private var unitRatingKey: JsonField? = null + private var defaultUnitRate: JsonField = JsonMissing.of() private var groupingKey: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() internal fun from(eventOutputConfig: EventOutputConfig) = apply { unitRatingKey = eventOutputConfig.unitRatingKey + defaultUnitRate = eventOutputConfig.defaultUnitRate groupingKey = eventOutputConfig.groupingKey additionalProperties = eventOutputConfig.additionalProperties.toMutableMap() @@ -22834,6 +22916,25 @@ private constructor( this.unitRatingKey = unitRatingKey } + /** + * If provided, this amount will be used as the unit rate when an event does + * not have a value for the `unit_rating_key`. If not provided, events + * missing a unit rate will be ignored. + */ + fun defaultUnitRate(defaultUnitRate: String?) = + defaultUnitRate(JsonField.ofNullable(defaultUnitRate)) + + /** + * Sets [Builder.defaultUnitRate] to an arbitrary JSON value. + * + * You should usually call [Builder.defaultUnitRate] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun defaultUnitRate(defaultUnitRate: JsonField) = apply { + this.defaultUnitRate = defaultUnitRate + } + /** * An optional key in the event data to group by (e.g., event ID). All * events will also be grouped by their unit rate. @@ -22889,6 +22990,7 @@ private constructor( fun build(): EventOutputConfig = EventOutputConfig( checkRequired("unitRatingKey", unitRatingKey), + defaultUnitRate, groupingKey, additionalProperties.toMutableMap(), ) @@ -22902,6 +23004,7 @@ private constructor( } unitRatingKey() + defaultUnitRate() groupingKey() validated = true } @@ -22922,6 +23025,7 @@ private constructor( */ internal fun validity(): Int = (if (unitRatingKey.asKnown() == null) 0 else 1) + + (if (defaultUnitRate.asKnown() == null) 0 else 1) + (if (groupingKey.asKnown() == null) 0 else 1) override fun equals(other: Any?): Boolean { @@ -22931,18 +23035,24 @@ private constructor( return other is EventOutputConfig && unitRatingKey == other.unitRatingKey && + defaultUnitRate == other.defaultUnitRate && groupingKey == other.groupingKey && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(unitRatingKey, groupingKey, additionalProperties) + Objects.hash( + unitRatingKey, + defaultUnitRate, + groupingKey, + additionalProperties, + ) } override fun hashCode(): Int = hashCode override fun toString() = - "EventOutputConfig{unitRatingKey=$unitRatingKey, groupingKey=$groupingKey, additionalProperties=$additionalProperties}" + "EventOutputConfig{unitRatingKey=$unitRatingKey, defaultUnitRate=$defaultUnitRate, groupingKey=$groupingKey, additionalProperties=$additionalProperties}" } /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BetaExternalPlanIdCreatePlanVersionParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BetaExternalPlanIdCreatePlanVersionParams.kt index e953d1a3e..ad81ac0aa 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BetaExternalPlanIdCreatePlanVersionParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BetaExternalPlanIdCreatePlanVersionParams.kt @@ -11450,6 +11450,7 @@ private constructor( @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val unitRatingKey: JsonField, + private val defaultUnitRate: JsonField, private val groupingKey: JsonField, private val additionalProperties: MutableMap, ) { @@ -11459,10 +11460,13 @@ private constructor( @JsonProperty("unit_rating_key") @ExcludeMissing unitRatingKey: JsonField = JsonMissing.of(), + @JsonProperty("default_unit_rate") + @ExcludeMissing + defaultUnitRate: JsonField = JsonMissing.of(), @JsonProperty("grouping_key") @ExcludeMissing groupingKey: JsonField = JsonMissing.of(), - ) : this(unitRatingKey, groupingKey, mutableMapOf()) + ) : this(unitRatingKey, defaultUnitRate, groupingKey, mutableMapOf()) /** * The key in the event data to extract the unit rate from. @@ -11473,6 +11477,17 @@ private constructor( */ fun unitRatingKey(): String = unitRatingKey.getRequired("unit_rating_key") + /** + * If provided, this amount will be used as the unit rate when an event does not + * have a value for the `unit_rating_key`. If not provided, events missing a + * unit rate will be ignored. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun defaultUnitRate(): String? = + defaultUnitRate.getNullable("default_unit_rate") + /** * An optional key in the event data to group by (e.g., event ID). All events * will also be grouped by their unit rate. @@ -11492,6 +11507,16 @@ private constructor( @ExcludeMissing fun _unitRatingKey(): JsonField = unitRatingKey + /** + * Returns the raw JSON value of [defaultUnitRate]. + * + * Unlike [defaultUnitRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("default_unit_rate") + @ExcludeMissing + fun _defaultUnitRate(): JsonField = defaultUnitRate + /** * Returns the raw JSON value of [groupingKey]. * @@ -11532,12 +11557,14 @@ private constructor( class Builder internal constructor() { private var unitRatingKey: JsonField? = null + private var defaultUnitRate: JsonField = JsonMissing.of() private var groupingKey: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() internal fun from(eventOutputConfig: EventOutputConfig) = apply { unitRatingKey = eventOutputConfig.unitRatingKey + defaultUnitRate = eventOutputConfig.defaultUnitRate groupingKey = eventOutputConfig.groupingKey additionalProperties = eventOutputConfig.additionalProperties.toMutableMap() @@ -11558,6 +11585,25 @@ private constructor( this.unitRatingKey = unitRatingKey } + /** + * If provided, this amount will be used as the unit rate when an event does + * not have a value for the `unit_rating_key`. If not provided, events + * missing a unit rate will be ignored. + */ + fun defaultUnitRate(defaultUnitRate: String?) = + defaultUnitRate(JsonField.ofNullable(defaultUnitRate)) + + /** + * Sets [Builder.defaultUnitRate] to an arbitrary JSON value. + * + * You should usually call [Builder.defaultUnitRate] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun defaultUnitRate(defaultUnitRate: JsonField) = apply { + this.defaultUnitRate = defaultUnitRate + } + /** * An optional key in the event data to group by (e.g., event ID). All * events will also be grouped by their unit rate. @@ -11613,6 +11659,7 @@ private constructor( fun build(): EventOutputConfig = EventOutputConfig( checkRequired("unitRatingKey", unitRatingKey), + defaultUnitRate, groupingKey, additionalProperties.toMutableMap(), ) @@ -11626,6 +11673,7 @@ private constructor( } unitRatingKey() + defaultUnitRate() groupingKey() validated = true } @@ -11646,6 +11694,7 @@ private constructor( */ internal fun validity(): Int = (if (unitRatingKey.asKnown() == null) 0 else 1) + + (if (defaultUnitRate.asKnown() == null) 0 else 1) + (if (groupingKey.asKnown() == null) 0 else 1) override fun equals(other: Any?): Boolean { @@ -11655,18 +11704,24 @@ private constructor( return other is EventOutputConfig && unitRatingKey == other.unitRatingKey && + defaultUnitRate == other.defaultUnitRate && groupingKey == other.groupingKey && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(unitRatingKey, groupingKey, additionalProperties) + Objects.hash( + unitRatingKey, + defaultUnitRate, + groupingKey, + additionalProperties, + ) } override fun hashCode(): Int = hashCode override fun toString() = - "EventOutputConfig{unitRatingKey=$unitRatingKey, groupingKey=$groupingKey, additionalProperties=$additionalProperties}" + "EventOutputConfig{unitRatingKey=$unitRatingKey, defaultUnitRate=$defaultUnitRate, groupingKey=$groupingKey, additionalProperties=$additionalProperties}" } /** @@ -22731,6 +22786,7 @@ private constructor( @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val unitRatingKey: JsonField, + private val defaultUnitRate: JsonField, private val groupingKey: JsonField, private val additionalProperties: MutableMap, ) { @@ -22740,10 +22796,13 @@ private constructor( @JsonProperty("unit_rating_key") @ExcludeMissing unitRatingKey: JsonField = JsonMissing.of(), + @JsonProperty("default_unit_rate") + @ExcludeMissing + defaultUnitRate: JsonField = JsonMissing.of(), @JsonProperty("grouping_key") @ExcludeMissing groupingKey: JsonField = JsonMissing.of(), - ) : this(unitRatingKey, groupingKey, mutableMapOf()) + ) : this(unitRatingKey, defaultUnitRate, groupingKey, mutableMapOf()) /** * The key in the event data to extract the unit rate from. @@ -22754,6 +22813,17 @@ private constructor( */ fun unitRatingKey(): String = unitRatingKey.getRequired("unit_rating_key") + /** + * If provided, this amount will be used as the unit rate when an event does not + * have a value for the `unit_rating_key`. If not provided, events missing a + * unit rate will be ignored. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun defaultUnitRate(): String? = + defaultUnitRate.getNullable("default_unit_rate") + /** * An optional key in the event data to group by (e.g., event ID). All events * will also be grouped by their unit rate. @@ -22773,6 +22843,16 @@ private constructor( @ExcludeMissing fun _unitRatingKey(): JsonField = unitRatingKey + /** + * Returns the raw JSON value of [defaultUnitRate]. + * + * Unlike [defaultUnitRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("default_unit_rate") + @ExcludeMissing + fun _defaultUnitRate(): JsonField = defaultUnitRate + /** * Returns the raw JSON value of [groupingKey]. * @@ -22813,12 +22893,14 @@ private constructor( class Builder internal constructor() { private var unitRatingKey: JsonField? = null + private var defaultUnitRate: JsonField = JsonMissing.of() private var groupingKey: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() internal fun from(eventOutputConfig: EventOutputConfig) = apply { unitRatingKey = eventOutputConfig.unitRatingKey + defaultUnitRate = eventOutputConfig.defaultUnitRate groupingKey = eventOutputConfig.groupingKey additionalProperties = eventOutputConfig.additionalProperties.toMutableMap() @@ -22839,6 +22921,25 @@ private constructor( this.unitRatingKey = unitRatingKey } + /** + * If provided, this amount will be used as the unit rate when an event does + * not have a value for the `unit_rating_key`. If not provided, events + * missing a unit rate will be ignored. + */ + fun defaultUnitRate(defaultUnitRate: String?) = + defaultUnitRate(JsonField.ofNullable(defaultUnitRate)) + + /** + * Sets [Builder.defaultUnitRate] to an arbitrary JSON value. + * + * You should usually call [Builder.defaultUnitRate] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun defaultUnitRate(defaultUnitRate: JsonField) = apply { + this.defaultUnitRate = defaultUnitRate + } + /** * An optional key in the event data to group by (e.g., event ID). All * events will also be grouped by their unit rate. @@ -22894,6 +22995,7 @@ private constructor( fun build(): EventOutputConfig = EventOutputConfig( checkRequired("unitRatingKey", unitRatingKey), + defaultUnitRate, groupingKey, additionalProperties.toMutableMap(), ) @@ -22907,6 +23009,7 @@ private constructor( } unitRatingKey() + defaultUnitRate() groupingKey() validated = true } @@ -22927,6 +23030,7 @@ private constructor( */ internal fun validity(): Int = (if (unitRatingKey.asKnown() == null) 0 else 1) + + (if (defaultUnitRate.asKnown() == null) 0 else 1) + (if (groupingKey.asKnown() == null) 0 else 1) override fun equals(other: Any?): Boolean { @@ -22936,18 +23040,24 @@ private constructor( return other is EventOutputConfig && unitRatingKey == other.unitRatingKey && + defaultUnitRate == other.defaultUnitRate && groupingKey == other.groupingKey && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(unitRatingKey, groupingKey, additionalProperties) + Objects.hash( + unitRatingKey, + defaultUnitRate, + groupingKey, + additionalProperties, + ) } override fun hashCode(): Int = hashCode override fun toString() = - "EventOutputConfig{unitRatingKey=$unitRatingKey, groupingKey=$groupingKey, additionalProperties=$additionalProperties}" + "EventOutputConfig{unitRatingKey=$unitRatingKey, defaultUnitRate=$defaultUnitRate, groupingKey=$groupingKey, additionalProperties=$additionalProperties}" } /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Maximum.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Maximum.kt index 88df14fb7..8ba756ccc 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Maximum.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Maximum.kt @@ -6,6 +6,7 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty +import com.withorb.api.core.Enum import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing @@ -21,7 +22,7 @@ class Maximum @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val appliesToPriceIds: JsonField>, - private val filters: JsonField>, + private val filters: JsonField>, private val maximumAmount: JsonField, private val additionalProperties: MutableMap, ) { @@ -33,7 +34,7 @@ private constructor( appliesToPriceIds: JsonField> = JsonMissing.of(), @JsonProperty("filters") @ExcludeMissing - filters: JsonField> = JsonMissing.of(), + filters: JsonField> = JsonMissing.of(), @JsonProperty("maximum_amount") @ExcludeMissing maximumAmount: JsonField = JsonMissing.of(), @@ -55,7 +56,7 @@ private constructor( * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ - fun filters(): List = filters.getRequired("filters") + fun filters(): List = filters.getRequired("filters") /** * Maximum amount applied @@ -81,9 +82,7 @@ private constructor( * * Unlike [filters], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("filters") - @ExcludeMissing - fun _filters(): JsonField> = filters + @JsonProperty("filters") @ExcludeMissing fun _filters(): JsonField> = filters /** * Returns the raw JSON value of [maximumAmount]. @@ -125,7 +124,7 @@ private constructor( class Builder internal constructor() { private var appliesToPriceIds: JsonField>? = null - private var filters: JsonField>? = null + private var filters: JsonField>? = null private var maximumAmount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -170,25 +169,25 @@ private constructor( } /** The filters that determine which prices to apply this maximum to. */ - fun filters(filters: List) = filters(JsonField.of(filters)) + fun filters(filters: List) = filters(JsonField.of(filters)) /** * Sets [Builder.filters] to an arbitrary JSON value. * - * You should usually call [Builder.filters] with a well-typed `List` - * value instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. + * You should usually call [Builder.filters] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. */ - fun filters(filters: JsonField>) = apply { + fun filters(filters: JsonField>) = apply { this.filters = filters.map { it.toMutableList() } } /** - * Adds a single [TransformPriceFilter] to [filters]. + * Adds a single [Filter] to [filters]. * * @throws IllegalStateException if the field was previously set to a non-list. */ - fun addFilter(filter: TransformPriceFilter) = apply { + fun addFilter(filter: Filter) = apply { filters = (filters ?: JsonField.of(mutableListOf())).also { checkKnown("filters", it).add(filter) @@ -282,6 +281,534 @@ private constructor( (filters.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + (if (maximumAmount.asKnown() == null) 0 else 1) + class Filter + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val field: JsonField, + private val operator: JsonField, + private val values: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("field") @ExcludeMissing field: JsonField = JsonMissing.of(), + @JsonProperty("operator") + @ExcludeMissing + operator: JsonField = JsonMissing.of(), + @JsonProperty("values") + @ExcludeMissing + values: JsonField> = JsonMissing.of(), + ) : this(field, operator, values, mutableMapOf()) + + /** + * The property of the price to filter on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun field(): Field = field.getRequired("field") + + /** + * Should prices that match the filter be included or excluded. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun operator(): Operator = operator.getRequired("operator") + + /** + * The IDs or values that match this filter. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun values(): List = values.getRequired("values") + + /** + * Returns the raw JSON value of [field]. + * + * Unlike [field], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("field") @ExcludeMissing fun _field(): JsonField = field + + /** + * Returns the raw JSON value of [operator]. + * + * Unlike [operator], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("operator") @ExcludeMissing fun _operator(): JsonField = operator + + /** + * Returns the raw JSON value of [values]. + * + * Unlike [values], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("values") @ExcludeMissing fun _values(): JsonField> = values + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Filter]. + * + * The following fields are required: + * ```kotlin + * .field() + * .operator() + * .values() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Filter]. */ + class Builder internal constructor() { + + private var field: JsonField? = null + private var operator: JsonField? = null + private var values: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(filter: Filter) = apply { + field = filter.field + operator = filter.operator + values = filter.values.map { it.toMutableList() } + additionalProperties = filter.additionalProperties.toMutableMap() + } + + /** The property of the price to filter on. */ + fun field(field: Field) = field(JsonField.of(field)) + + /** + * Sets [Builder.field] to an arbitrary JSON value. + * + * You should usually call [Builder.field] with a well-typed [Field] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun field(field: JsonField) = apply { this.field = field } + + /** Should prices that match the filter be included or excluded. */ + fun operator(operator: Operator) = operator(JsonField.of(operator)) + + /** + * Sets [Builder.operator] to an arbitrary JSON value. + * + * You should usually call [Builder.operator] with a well-typed [Operator] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun operator(operator: JsonField) = apply { this.operator = operator } + + /** The IDs or values that match this filter. */ + fun values(values: List) = values(JsonField.of(values)) + + /** + * Sets [Builder.values] to an arbitrary JSON value. + * + * You should usually call [Builder.values] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun values(values: JsonField>) = apply { + this.values = values.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [values]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addValue(value: String) = apply { + values = + (values ?: JsonField.of(mutableListOf())).also { + checkKnown("values", it).add(value) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Filter]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .field() + * .operator() + * .values() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Filter = + Filter( + checkRequired("field", field), + checkRequired("operator", operator), + checkRequired("values", values).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Filter = apply { + if (validated) { + return@apply + } + + field().validate() + operator().validate() + values() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (field.asKnown()?.validity() ?: 0) + + (operator.asKnown()?.validity() ?: 0) + + (values.asKnown()?.size ?: 0) + + /** The property of the price to filter on. */ + class Field @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val PRICE_ID = of("price_id") + + val ITEM_ID = of("item_id") + + val PRICE_TYPE = of("price_type") + + val CURRENCY = of("currency") + + val PRICING_UNIT_ID = of("pricing_unit_id") + + fun of(value: String) = Field(JsonField.of(value)) + } + + /** An enum containing [Field]'s known values. */ + enum class Known { + PRICE_ID, + ITEM_ID, + PRICE_TYPE, + CURRENCY, + PRICING_UNIT_ID, + } + + /** + * An enum containing [Field]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Field] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + PRICE_ID, + ITEM_ID, + PRICE_TYPE, + CURRENCY, + PRICING_UNIT_ID, + /** + * An enum member indicating that [Field] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + PRICE_ID -> Value.PRICE_ID + ITEM_ID -> Value.ITEM_ID + PRICE_TYPE -> Value.PRICE_TYPE + CURRENCY -> Value.CURRENCY + PRICING_UNIT_ID -> Value.PRICING_UNIT_ID + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + PRICE_ID -> Known.PRICE_ID + ITEM_ID -> Known.ITEM_ID + PRICE_TYPE -> Known.PRICE_TYPE + CURRENCY -> Known.CURRENCY + PRICING_UNIT_ID -> Known.PRICING_UNIT_ID + else -> throw OrbInvalidDataException("Unknown Field: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Field = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Field && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Should prices that match the filter be included or excluded. */ + class Operator @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val INCLUDES = of("includes") + + val EXCLUDES = of("excludes") + + fun of(value: String) = Operator(JsonField.of(value)) + } + + /** An enum containing [Operator]'s known values. */ + enum class Known { + INCLUDES, + EXCLUDES, + } + + /** + * An enum containing [Operator]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Operator] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + INCLUDES, + EXCLUDES, + /** + * An enum member indicating that [Operator] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + INCLUDES -> Value.INCLUDES + EXCLUDES -> Value.EXCLUDES + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + INCLUDES -> Known.INCLUDES + EXCLUDES -> Known.EXCLUDES + else -> throw OrbInvalidDataException("Unknown Operator: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Operator = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Operator && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Filter && + field == other.field && + operator == other.operator && + values == other.values && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(field, operator, values, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Filter{field=$field, operator=$operator, values=$values, additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MaximumInterval.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MaximumInterval.kt index 31790bbc1..89f26b163 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MaximumInterval.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MaximumInterval.kt @@ -6,6 +6,7 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty +import com.withorb.api.core.Enum import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing @@ -23,7 +24,7 @@ class MaximumInterval private constructor( private val appliesToPriceIntervalIds: JsonField>, private val endDate: JsonField, - private val filters: JsonField>, + private val filters: JsonField>, private val maximumAmount: JsonField, private val startDate: JsonField, private val additionalProperties: MutableMap, @@ -39,7 +40,7 @@ private constructor( endDate: JsonField = JsonMissing.of(), @JsonProperty("filters") @ExcludeMissing - filters: JsonField> = JsonMissing.of(), + filters: JsonField> = JsonMissing.of(), @JsonProperty("maximum_amount") @ExcludeMissing maximumAmount: JsonField = JsonMissing.of(), @@ -71,7 +72,7 @@ private constructor( * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ - fun filters(): List = filters.getRequired("filters") + fun filters(): List = filters.getRequired("filters") /** * The maximum amount to charge in a given billing period for the price intervals this transform @@ -112,9 +113,7 @@ private constructor( * * Unlike [filters], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("filters") - @ExcludeMissing - fun _filters(): JsonField> = filters + @JsonProperty("filters") @ExcludeMissing fun _filters(): JsonField> = filters /** * Returns the raw JSON value of [maximumAmount]. @@ -168,7 +167,7 @@ private constructor( private var appliesToPriceIntervalIds: JsonField>? = null private var endDate: JsonField? = null - private var filters: JsonField>? = null + private var filters: JsonField>? = null private var maximumAmount: JsonField? = null private var startDate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -223,25 +222,25 @@ private constructor( fun endDate(endDate: JsonField) = apply { this.endDate = endDate } /** The filters that determine which prices this maximum interval applies to. */ - fun filters(filters: List) = filters(JsonField.of(filters)) + fun filters(filters: List) = filters(JsonField.of(filters)) /** * Sets [Builder.filters] to an arbitrary JSON value. * - * You should usually call [Builder.filters] with a well-typed `List` - * value instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. + * You should usually call [Builder.filters] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. */ - fun filters(filters: JsonField>) = apply { + fun filters(filters: JsonField>) = apply { this.filters = filters.map { it.toMutableList() } } /** - * Adds a single [TransformPriceFilter] to [filters]. + * Adds a single [Filter] to [filters]. * * @throws IllegalStateException if the field was previously set to a non-list. */ - fun addFilter(filter: TransformPriceFilter) = apply { + fun addFilter(filter: Filter) = apply { filters = (filters ?: JsonField.of(mutableListOf())).also { checkKnown("filters", it).add(filter) @@ -360,6 +359,534 @@ private constructor( (if (maximumAmount.asKnown() == null) 0 else 1) + (if (startDate.asKnown() == null) 0 else 1) + class Filter + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val field: JsonField, + private val operator: JsonField, + private val values: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("field") @ExcludeMissing field: JsonField = JsonMissing.of(), + @JsonProperty("operator") + @ExcludeMissing + operator: JsonField = JsonMissing.of(), + @JsonProperty("values") + @ExcludeMissing + values: JsonField> = JsonMissing.of(), + ) : this(field, operator, values, mutableMapOf()) + + /** + * The property of the price to filter on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun field(): Field = field.getRequired("field") + + /** + * Should prices that match the filter be included or excluded. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun operator(): Operator = operator.getRequired("operator") + + /** + * The IDs or values that match this filter. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun values(): List = values.getRequired("values") + + /** + * Returns the raw JSON value of [field]. + * + * Unlike [field], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("field") @ExcludeMissing fun _field(): JsonField = field + + /** + * Returns the raw JSON value of [operator]. + * + * Unlike [operator], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("operator") @ExcludeMissing fun _operator(): JsonField = operator + + /** + * Returns the raw JSON value of [values]. + * + * Unlike [values], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("values") @ExcludeMissing fun _values(): JsonField> = values + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Filter]. + * + * The following fields are required: + * ```kotlin + * .field() + * .operator() + * .values() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Filter]. */ + class Builder internal constructor() { + + private var field: JsonField? = null + private var operator: JsonField? = null + private var values: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(filter: Filter) = apply { + field = filter.field + operator = filter.operator + values = filter.values.map { it.toMutableList() } + additionalProperties = filter.additionalProperties.toMutableMap() + } + + /** The property of the price to filter on. */ + fun field(field: Field) = field(JsonField.of(field)) + + /** + * Sets [Builder.field] to an arbitrary JSON value. + * + * You should usually call [Builder.field] with a well-typed [Field] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun field(field: JsonField) = apply { this.field = field } + + /** Should prices that match the filter be included or excluded. */ + fun operator(operator: Operator) = operator(JsonField.of(operator)) + + /** + * Sets [Builder.operator] to an arbitrary JSON value. + * + * You should usually call [Builder.operator] with a well-typed [Operator] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun operator(operator: JsonField) = apply { this.operator = operator } + + /** The IDs or values that match this filter. */ + fun values(values: List) = values(JsonField.of(values)) + + /** + * Sets [Builder.values] to an arbitrary JSON value. + * + * You should usually call [Builder.values] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun values(values: JsonField>) = apply { + this.values = values.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [values]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addValue(value: String) = apply { + values = + (values ?: JsonField.of(mutableListOf())).also { + checkKnown("values", it).add(value) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Filter]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .field() + * .operator() + * .values() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Filter = + Filter( + checkRequired("field", field), + checkRequired("operator", operator), + checkRequired("values", values).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Filter = apply { + if (validated) { + return@apply + } + + field().validate() + operator().validate() + values() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (field.asKnown()?.validity() ?: 0) + + (operator.asKnown()?.validity() ?: 0) + + (values.asKnown()?.size ?: 0) + + /** The property of the price to filter on. */ + class Field @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val PRICE_ID = of("price_id") + + val ITEM_ID = of("item_id") + + val PRICE_TYPE = of("price_type") + + val CURRENCY = of("currency") + + val PRICING_UNIT_ID = of("pricing_unit_id") + + fun of(value: String) = Field(JsonField.of(value)) + } + + /** An enum containing [Field]'s known values. */ + enum class Known { + PRICE_ID, + ITEM_ID, + PRICE_TYPE, + CURRENCY, + PRICING_UNIT_ID, + } + + /** + * An enum containing [Field]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Field] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + PRICE_ID, + ITEM_ID, + PRICE_TYPE, + CURRENCY, + PRICING_UNIT_ID, + /** + * An enum member indicating that [Field] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + PRICE_ID -> Value.PRICE_ID + ITEM_ID -> Value.ITEM_ID + PRICE_TYPE -> Value.PRICE_TYPE + CURRENCY -> Value.CURRENCY + PRICING_UNIT_ID -> Value.PRICING_UNIT_ID + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + PRICE_ID -> Known.PRICE_ID + ITEM_ID -> Known.ITEM_ID + PRICE_TYPE -> Known.PRICE_TYPE + CURRENCY -> Known.CURRENCY + PRICING_UNIT_ID -> Known.PRICING_UNIT_ID + else -> throw OrbInvalidDataException("Unknown Field: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Field = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Field && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Should prices that match the filter be included or excluded. */ + class Operator @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val INCLUDES = of("includes") + + val EXCLUDES = of("excludes") + + fun of(value: String) = Operator(JsonField.of(value)) + } + + /** An enum containing [Operator]'s known values. */ + enum class Known { + INCLUDES, + EXCLUDES, + } + + /** + * An enum containing [Operator]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Operator] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + INCLUDES, + EXCLUDES, + /** + * An enum member indicating that [Operator] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + INCLUDES -> Value.INCLUDES + EXCLUDES -> Value.EXCLUDES + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + INCLUDES -> Known.INCLUDES + EXCLUDES -> Known.EXCLUDES + else -> throw OrbInvalidDataException("Unknown Operator: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Operator = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Operator && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Filter && + field == other.field && + operator == other.operator && + values == other.values && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(field, operator, values, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Filter{field=$field, operator=$operator, values=$values, additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Minimum.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Minimum.kt index 81dc73944..7c2da8175 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Minimum.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Minimum.kt @@ -6,6 +6,7 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty +import com.withorb.api.core.Enum import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing @@ -21,7 +22,7 @@ class Minimum @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val appliesToPriceIds: JsonField>, - private val filters: JsonField>, + private val filters: JsonField>, private val minimumAmount: JsonField, private val additionalProperties: MutableMap, ) { @@ -33,7 +34,7 @@ private constructor( appliesToPriceIds: JsonField> = JsonMissing.of(), @JsonProperty("filters") @ExcludeMissing - filters: JsonField> = JsonMissing.of(), + filters: JsonField> = JsonMissing.of(), @JsonProperty("minimum_amount") @ExcludeMissing minimumAmount: JsonField = JsonMissing.of(), @@ -55,7 +56,7 @@ private constructor( * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ - fun filters(): List = filters.getRequired("filters") + fun filters(): List = filters.getRequired("filters") /** * Minimum amount applied @@ -81,9 +82,7 @@ private constructor( * * Unlike [filters], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("filters") - @ExcludeMissing - fun _filters(): JsonField> = filters + @JsonProperty("filters") @ExcludeMissing fun _filters(): JsonField> = filters /** * Returns the raw JSON value of [minimumAmount]. @@ -125,7 +124,7 @@ private constructor( class Builder internal constructor() { private var appliesToPriceIds: JsonField>? = null - private var filters: JsonField>? = null + private var filters: JsonField>? = null private var minimumAmount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -170,25 +169,25 @@ private constructor( } /** The filters that determine which prices to apply this minimum to. */ - fun filters(filters: List) = filters(JsonField.of(filters)) + fun filters(filters: List) = filters(JsonField.of(filters)) /** * Sets [Builder.filters] to an arbitrary JSON value. * - * You should usually call [Builder.filters] with a well-typed `List` - * value instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. + * You should usually call [Builder.filters] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. */ - fun filters(filters: JsonField>) = apply { + fun filters(filters: JsonField>) = apply { this.filters = filters.map { it.toMutableList() } } /** - * Adds a single [TransformPriceFilter] to [filters]. + * Adds a single [Filter] to [filters]. * * @throws IllegalStateException if the field was previously set to a non-list. */ - fun addFilter(filter: TransformPriceFilter) = apply { + fun addFilter(filter: Filter) = apply { filters = (filters ?: JsonField.of(mutableListOf())).also { checkKnown("filters", it).add(filter) @@ -282,6 +281,534 @@ private constructor( (filters.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + (if (minimumAmount.asKnown() == null) 0 else 1) + class Filter + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val field: JsonField, + private val operator: JsonField, + private val values: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("field") @ExcludeMissing field: JsonField = JsonMissing.of(), + @JsonProperty("operator") + @ExcludeMissing + operator: JsonField = JsonMissing.of(), + @JsonProperty("values") + @ExcludeMissing + values: JsonField> = JsonMissing.of(), + ) : this(field, operator, values, mutableMapOf()) + + /** + * The property of the price to filter on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun field(): Field = field.getRequired("field") + + /** + * Should prices that match the filter be included or excluded. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun operator(): Operator = operator.getRequired("operator") + + /** + * The IDs or values that match this filter. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun values(): List = values.getRequired("values") + + /** + * Returns the raw JSON value of [field]. + * + * Unlike [field], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("field") @ExcludeMissing fun _field(): JsonField = field + + /** + * Returns the raw JSON value of [operator]. + * + * Unlike [operator], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("operator") @ExcludeMissing fun _operator(): JsonField = operator + + /** + * Returns the raw JSON value of [values]. + * + * Unlike [values], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("values") @ExcludeMissing fun _values(): JsonField> = values + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Filter]. + * + * The following fields are required: + * ```kotlin + * .field() + * .operator() + * .values() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Filter]. */ + class Builder internal constructor() { + + private var field: JsonField? = null + private var operator: JsonField? = null + private var values: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(filter: Filter) = apply { + field = filter.field + operator = filter.operator + values = filter.values.map { it.toMutableList() } + additionalProperties = filter.additionalProperties.toMutableMap() + } + + /** The property of the price to filter on. */ + fun field(field: Field) = field(JsonField.of(field)) + + /** + * Sets [Builder.field] to an arbitrary JSON value. + * + * You should usually call [Builder.field] with a well-typed [Field] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun field(field: JsonField) = apply { this.field = field } + + /** Should prices that match the filter be included or excluded. */ + fun operator(operator: Operator) = operator(JsonField.of(operator)) + + /** + * Sets [Builder.operator] to an arbitrary JSON value. + * + * You should usually call [Builder.operator] with a well-typed [Operator] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun operator(operator: JsonField) = apply { this.operator = operator } + + /** The IDs or values that match this filter. */ + fun values(values: List) = values(JsonField.of(values)) + + /** + * Sets [Builder.values] to an arbitrary JSON value. + * + * You should usually call [Builder.values] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun values(values: JsonField>) = apply { + this.values = values.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [values]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addValue(value: String) = apply { + values = + (values ?: JsonField.of(mutableListOf())).also { + checkKnown("values", it).add(value) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Filter]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .field() + * .operator() + * .values() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Filter = + Filter( + checkRequired("field", field), + checkRequired("operator", operator), + checkRequired("values", values).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Filter = apply { + if (validated) { + return@apply + } + + field().validate() + operator().validate() + values() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (field.asKnown()?.validity() ?: 0) + + (operator.asKnown()?.validity() ?: 0) + + (values.asKnown()?.size ?: 0) + + /** The property of the price to filter on. */ + class Field @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val PRICE_ID = of("price_id") + + val ITEM_ID = of("item_id") + + val PRICE_TYPE = of("price_type") + + val CURRENCY = of("currency") + + val PRICING_UNIT_ID = of("pricing_unit_id") + + fun of(value: String) = Field(JsonField.of(value)) + } + + /** An enum containing [Field]'s known values. */ + enum class Known { + PRICE_ID, + ITEM_ID, + PRICE_TYPE, + CURRENCY, + PRICING_UNIT_ID, + } + + /** + * An enum containing [Field]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Field] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + PRICE_ID, + ITEM_ID, + PRICE_TYPE, + CURRENCY, + PRICING_UNIT_ID, + /** + * An enum member indicating that [Field] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + PRICE_ID -> Value.PRICE_ID + ITEM_ID -> Value.ITEM_ID + PRICE_TYPE -> Value.PRICE_TYPE + CURRENCY -> Value.CURRENCY + PRICING_UNIT_ID -> Value.PRICING_UNIT_ID + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + PRICE_ID -> Known.PRICE_ID + ITEM_ID -> Known.ITEM_ID + PRICE_TYPE -> Known.PRICE_TYPE + CURRENCY -> Known.CURRENCY + PRICING_UNIT_ID -> Known.PRICING_UNIT_ID + else -> throw OrbInvalidDataException("Unknown Field: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Field = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Field && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Should prices that match the filter be included or excluded. */ + class Operator @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val INCLUDES = of("includes") + + val EXCLUDES = of("excludes") + + fun of(value: String) = Operator(JsonField.of(value)) + } + + /** An enum containing [Operator]'s known values. */ + enum class Known { + INCLUDES, + EXCLUDES, + } + + /** + * An enum containing [Operator]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Operator] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + INCLUDES, + EXCLUDES, + /** + * An enum member indicating that [Operator] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + INCLUDES -> Value.INCLUDES + EXCLUDES -> Value.EXCLUDES + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + INCLUDES -> Known.INCLUDES + EXCLUDES -> Known.EXCLUDES + else -> throw OrbInvalidDataException("Unknown Operator: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Operator = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Operator && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Filter && + field == other.field && + operator == other.operator && + values == other.values && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(field, operator, values, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Filter{field=$field, operator=$operator, values=$values, additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MinimumInterval.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MinimumInterval.kt index 89d0f106f..6a4ea08b5 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MinimumInterval.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MinimumInterval.kt @@ -6,6 +6,7 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty +import com.withorb.api.core.Enum import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing @@ -23,7 +24,7 @@ class MinimumInterval private constructor( private val appliesToPriceIntervalIds: JsonField>, private val endDate: JsonField, - private val filters: JsonField>, + private val filters: JsonField>, private val minimumAmount: JsonField, private val startDate: JsonField, private val additionalProperties: MutableMap, @@ -39,7 +40,7 @@ private constructor( endDate: JsonField = JsonMissing.of(), @JsonProperty("filters") @ExcludeMissing - filters: JsonField> = JsonMissing.of(), + filters: JsonField> = JsonMissing.of(), @JsonProperty("minimum_amount") @ExcludeMissing minimumAmount: JsonField = JsonMissing.of(), @@ -71,7 +72,7 @@ private constructor( * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ - fun filters(): List = filters.getRequired("filters") + fun filters(): List = filters.getRequired("filters") /** * The minimum amount to charge in a given billing period for the price intervals this minimum @@ -112,9 +113,7 @@ private constructor( * * Unlike [filters], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("filters") - @ExcludeMissing - fun _filters(): JsonField> = filters + @JsonProperty("filters") @ExcludeMissing fun _filters(): JsonField> = filters /** * Returns the raw JSON value of [minimumAmount]. @@ -168,7 +167,7 @@ private constructor( private var appliesToPriceIntervalIds: JsonField>? = null private var endDate: JsonField? = null - private var filters: JsonField>? = null + private var filters: JsonField>? = null private var minimumAmount: JsonField? = null private var startDate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -223,25 +222,25 @@ private constructor( fun endDate(endDate: JsonField) = apply { this.endDate = endDate } /** The filters that determine which prices this minimum interval applies to. */ - fun filters(filters: List) = filters(JsonField.of(filters)) + fun filters(filters: List) = filters(JsonField.of(filters)) /** * Sets [Builder.filters] to an arbitrary JSON value. * - * You should usually call [Builder.filters] with a well-typed `List` - * value instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. + * You should usually call [Builder.filters] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. */ - fun filters(filters: JsonField>) = apply { + fun filters(filters: JsonField>) = apply { this.filters = filters.map { it.toMutableList() } } /** - * Adds a single [TransformPriceFilter] to [filters]. + * Adds a single [Filter] to [filters]. * * @throws IllegalStateException if the field was previously set to a non-list. */ - fun addFilter(filter: TransformPriceFilter) = apply { + fun addFilter(filter: Filter) = apply { filters = (filters ?: JsonField.of(mutableListOf())).also { checkKnown("filters", it).add(filter) @@ -360,6 +359,534 @@ private constructor( (if (minimumAmount.asKnown() == null) 0 else 1) + (if (startDate.asKnown() == null) 0 else 1) + class Filter + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val field: JsonField, + private val operator: JsonField, + private val values: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("field") @ExcludeMissing field: JsonField = JsonMissing.of(), + @JsonProperty("operator") + @ExcludeMissing + operator: JsonField = JsonMissing.of(), + @JsonProperty("values") + @ExcludeMissing + values: JsonField> = JsonMissing.of(), + ) : this(field, operator, values, mutableMapOf()) + + /** + * The property of the price to filter on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun field(): Field = field.getRequired("field") + + /** + * Should prices that match the filter be included or excluded. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun operator(): Operator = operator.getRequired("operator") + + /** + * The IDs or values that match this filter. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun values(): List = values.getRequired("values") + + /** + * Returns the raw JSON value of [field]. + * + * Unlike [field], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("field") @ExcludeMissing fun _field(): JsonField = field + + /** + * Returns the raw JSON value of [operator]. + * + * Unlike [operator], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("operator") @ExcludeMissing fun _operator(): JsonField = operator + + /** + * Returns the raw JSON value of [values]. + * + * Unlike [values], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("values") @ExcludeMissing fun _values(): JsonField> = values + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Filter]. + * + * The following fields are required: + * ```kotlin + * .field() + * .operator() + * .values() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Filter]. */ + class Builder internal constructor() { + + private var field: JsonField? = null + private var operator: JsonField? = null + private var values: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(filter: Filter) = apply { + field = filter.field + operator = filter.operator + values = filter.values.map { it.toMutableList() } + additionalProperties = filter.additionalProperties.toMutableMap() + } + + /** The property of the price to filter on. */ + fun field(field: Field) = field(JsonField.of(field)) + + /** + * Sets [Builder.field] to an arbitrary JSON value. + * + * You should usually call [Builder.field] with a well-typed [Field] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun field(field: JsonField) = apply { this.field = field } + + /** Should prices that match the filter be included or excluded. */ + fun operator(operator: Operator) = operator(JsonField.of(operator)) + + /** + * Sets [Builder.operator] to an arbitrary JSON value. + * + * You should usually call [Builder.operator] with a well-typed [Operator] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun operator(operator: JsonField) = apply { this.operator = operator } + + /** The IDs or values that match this filter. */ + fun values(values: List) = values(JsonField.of(values)) + + /** + * Sets [Builder.values] to an arbitrary JSON value. + * + * You should usually call [Builder.values] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun values(values: JsonField>) = apply { + this.values = values.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [values]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addValue(value: String) = apply { + values = + (values ?: JsonField.of(mutableListOf())).also { + checkKnown("values", it).add(value) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Filter]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .field() + * .operator() + * .values() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Filter = + Filter( + checkRequired("field", field), + checkRequired("operator", operator), + checkRequired("values", values).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Filter = apply { + if (validated) { + return@apply + } + + field().validate() + operator().validate() + values() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (field.asKnown()?.validity() ?: 0) + + (operator.asKnown()?.validity() ?: 0) + + (values.asKnown()?.size ?: 0) + + /** The property of the price to filter on. */ + class Field @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val PRICE_ID = of("price_id") + + val ITEM_ID = of("item_id") + + val PRICE_TYPE = of("price_type") + + val CURRENCY = of("currency") + + val PRICING_UNIT_ID = of("pricing_unit_id") + + fun of(value: String) = Field(JsonField.of(value)) + } + + /** An enum containing [Field]'s known values. */ + enum class Known { + PRICE_ID, + ITEM_ID, + PRICE_TYPE, + CURRENCY, + PRICING_UNIT_ID, + } + + /** + * An enum containing [Field]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Field] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + PRICE_ID, + ITEM_ID, + PRICE_TYPE, + CURRENCY, + PRICING_UNIT_ID, + /** + * An enum member indicating that [Field] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + PRICE_ID -> Value.PRICE_ID + ITEM_ID -> Value.ITEM_ID + PRICE_TYPE -> Value.PRICE_TYPE + CURRENCY -> Value.CURRENCY + PRICING_UNIT_ID -> Value.PRICING_UNIT_ID + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + PRICE_ID -> Known.PRICE_ID + ITEM_ID -> Known.ITEM_ID + PRICE_TYPE -> Known.PRICE_TYPE + CURRENCY -> Known.CURRENCY + PRICING_UNIT_ID -> Known.PRICING_UNIT_ID + else -> throw OrbInvalidDataException("Unknown Field: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Field = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Field && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Should prices that match the filter be included or excluded. */ + class Operator @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val INCLUDES = of("includes") + + val EXCLUDES = of("excludes") + + fun of(value: String) = Operator(JsonField.of(value)) + } + + /** An enum containing [Operator]'s known values. */ + enum class Known { + INCLUDES, + EXCLUDES, + } + + /** + * An enum containing [Operator]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Operator] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + INCLUDES, + EXCLUDES, + /** + * An enum member indicating that [Operator] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + INCLUDES -> Value.INCLUDES + EXCLUDES -> Value.EXCLUDES + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + INCLUDES -> Known.INCLUDES + EXCLUDES -> Known.EXCLUDES + else -> throw OrbInvalidDataException("Unknown Operator: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Operator = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Operator && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Filter && + field == other.field && + operator == other.operator && + values == other.values && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(field, operator, values, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Filter{field=$field, operator=$operator, values=$values, additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MonetaryAmountDiscountAdjustment.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MonetaryAmountDiscountAdjustment.kt index 9eb874d20..b0f7331f8 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MonetaryAmountDiscountAdjustment.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MonetaryAmountDiscountAdjustment.kt @@ -26,7 +26,7 @@ private constructor( private val amount: JsonField, private val amountDiscount: JsonField, private val appliesToPriceIds: JsonField>, - private val filters: JsonField>, + private val filters: JsonField>, private val isInvoiceLevel: JsonField, private val reason: JsonField, private val replacesAdjustmentId: JsonField, @@ -48,7 +48,7 @@ private constructor( appliesToPriceIds: JsonField> = JsonMissing.of(), @JsonProperty("filters") @ExcludeMissing - filters: JsonField> = JsonMissing.of(), + filters: JsonField> = JsonMissing.of(), @JsonProperty("is_invoice_level") @ExcludeMissing isInvoiceLevel: JsonField = JsonMissing.of(), @@ -113,7 +113,7 @@ private constructor( * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ - fun filters(): List = filters.getRequired("filters") + fun filters(): List = filters.getRequired("filters") /** * True for adjustments that apply to an entire invoice, false for adjustments that apply to @@ -189,9 +189,7 @@ private constructor( * * Unlike [filters], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("filters") - @ExcludeMissing - fun _filters(): JsonField> = filters + @JsonProperty("filters") @ExcludeMissing fun _filters(): JsonField> = filters /** * Returns the raw JSON value of [isInvoiceLevel]. @@ -261,7 +259,7 @@ private constructor( private var amount: JsonField? = null private var amountDiscount: JsonField? = null private var appliesToPriceIds: JsonField>? = null - private var filters: JsonField>? = null + private var filters: JsonField>? = null private var isInvoiceLevel: JsonField? = null private var reason: JsonField? = null private var replacesAdjustmentId: JsonField? = null @@ -366,25 +364,25 @@ private constructor( } /** The filters that determine which prices to apply this adjustment to. */ - fun filters(filters: List) = filters(JsonField.of(filters)) + fun filters(filters: List) = filters(JsonField.of(filters)) /** * Sets [Builder.filters] to an arbitrary JSON value. * - * You should usually call [Builder.filters] with a well-typed `List` - * value instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. + * You should usually call [Builder.filters] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. */ - fun filters(filters: JsonField>) = apply { + fun filters(filters: JsonField>) = apply { this.filters = filters.map { it.toMutableList() } } /** - * Adds a single [TransformPriceFilter] to [filters]. + * Adds a single [Filter] to [filters]. * * @throws IllegalStateException if the field was previously set to a non-list. */ - fun addFilter(filter: TransformPriceFilter) = apply { + fun addFilter(filter: Filter) = apply { filters = (filters ?: JsonField.of(mutableListOf())).also { checkKnown("filters", it).add(filter) @@ -656,6 +654,534 @@ private constructor( override fun toString() = value.toString() } + class Filter + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val field: JsonField, + private val operator: JsonField, + private val values: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("field") @ExcludeMissing field: JsonField = JsonMissing.of(), + @JsonProperty("operator") + @ExcludeMissing + operator: JsonField = JsonMissing.of(), + @JsonProperty("values") + @ExcludeMissing + values: JsonField> = JsonMissing.of(), + ) : this(field, operator, values, mutableMapOf()) + + /** + * The property of the price to filter on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun field(): Field = field.getRequired("field") + + /** + * Should prices that match the filter be included or excluded. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun operator(): Operator = operator.getRequired("operator") + + /** + * The IDs or values that match this filter. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun values(): List = values.getRequired("values") + + /** + * Returns the raw JSON value of [field]. + * + * Unlike [field], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("field") @ExcludeMissing fun _field(): JsonField = field + + /** + * Returns the raw JSON value of [operator]. + * + * Unlike [operator], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("operator") @ExcludeMissing fun _operator(): JsonField = operator + + /** + * Returns the raw JSON value of [values]. + * + * Unlike [values], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("values") @ExcludeMissing fun _values(): JsonField> = values + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Filter]. + * + * The following fields are required: + * ```kotlin + * .field() + * .operator() + * .values() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Filter]. */ + class Builder internal constructor() { + + private var field: JsonField? = null + private var operator: JsonField? = null + private var values: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(filter: Filter) = apply { + field = filter.field + operator = filter.operator + values = filter.values.map { it.toMutableList() } + additionalProperties = filter.additionalProperties.toMutableMap() + } + + /** The property of the price to filter on. */ + fun field(field: Field) = field(JsonField.of(field)) + + /** + * Sets [Builder.field] to an arbitrary JSON value. + * + * You should usually call [Builder.field] with a well-typed [Field] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun field(field: JsonField) = apply { this.field = field } + + /** Should prices that match the filter be included or excluded. */ + fun operator(operator: Operator) = operator(JsonField.of(operator)) + + /** + * Sets [Builder.operator] to an arbitrary JSON value. + * + * You should usually call [Builder.operator] with a well-typed [Operator] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun operator(operator: JsonField) = apply { this.operator = operator } + + /** The IDs or values that match this filter. */ + fun values(values: List) = values(JsonField.of(values)) + + /** + * Sets [Builder.values] to an arbitrary JSON value. + * + * You should usually call [Builder.values] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun values(values: JsonField>) = apply { + this.values = values.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [values]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addValue(value: String) = apply { + values = + (values ?: JsonField.of(mutableListOf())).also { + checkKnown("values", it).add(value) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Filter]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .field() + * .operator() + * .values() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Filter = + Filter( + checkRequired("field", field), + checkRequired("operator", operator), + checkRequired("values", values).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Filter = apply { + if (validated) { + return@apply + } + + field().validate() + operator().validate() + values() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (field.asKnown()?.validity() ?: 0) + + (operator.asKnown()?.validity() ?: 0) + + (values.asKnown()?.size ?: 0) + + /** The property of the price to filter on. */ + class Field @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val PRICE_ID = of("price_id") + + val ITEM_ID = of("item_id") + + val PRICE_TYPE = of("price_type") + + val CURRENCY = of("currency") + + val PRICING_UNIT_ID = of("pricing_unit_id") + + fun of(value: String) = Field(JsonField.of(value)) + } + + /** An enum containing [Field]'s known values. */ + enum class Known { + PRICE_ID, + ITEM_ID, + PRICE_TYPE, + CURRENCY, + PRICING_UNIT_ID, + } + + /** + * An enum containing [Field]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Field] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + PRICE_ID, + ITEM_ID, + PRICE_TYPE, + CURRENCY, + PRICING_UNIT_ID, + /** + * An enum member indicating that [Field] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + PRICE_ID -> Value.PRICE_ID + ITEM_ID -> Value.ITEM_ID + PRICE_TYPE -> Value.PRICE_TYPE + CURRENCY -> Value.CURRENCY + PRICING_UNIT_ID -> Value.PRICING_UNIT_ID + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + PRICE_ID -> Known.PRICE_ID + ITEM_ID -> Known.ITEM_ID + PRICE_TYPE -> Known.PRICE_TYPE + CURRENCY -> Known.CURRENCY + PRICING_UNIT_ID -> Known.PRICING_UNIT_ID + else -> throw OrbInvalidDataException("Unknown Field: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Field = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Field && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Should prices that match the filter be included or excluded. */ + class Operator @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val INCLUDES = of("includes") + + val EXCLUDES = of("excludes") + + fun of(value: String) = Operator(JsonField.of(value)) + } + + /** An enum containing [Operator]'s known values. */ + enum class Known { + INCLUDES, + EXCLUDES, + } + + /** + * An enum containing [Operator]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Operator] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + INCLUDES, + EXCLUDES, + /** + * An enum member indicating that [Operator] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + INCLUDES -> Value.INCLUDES + EXCLUDES -> Value.EXCLUDES + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + INCLUDES -> Known.INCLUDES + EXCLUDES -> Known.EXCLUDES + else -> throw OrbInvalidDataException("Unknown Operator: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Operator = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Operator && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Filter && + field == other.field && + operator == other.operator && + values == other.values && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(field, operator, values, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Filter{field=$field, operator=$operator, values=$values, additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MonetaryMaximumAdjustment.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MonetaryMaximumAdjustment.kt index de8229531..438dacaad 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MonetaryMaximumAdjustment.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MonetaryMaximumAdjustment.kt @@ -25,7 +25,7 @@ private constructor( private val adjustmentType: JsonField, private val amount: JsonField, private val appliesToPriceIds: JsonField>, - private val filters: JsonField>, + private val filters: JsonField>, private val isInvoiceLevel: JsonField, private val maximumAmount: JsonField, private val reason: JsonField, @@ -45,7 +45,7 @@ private constructor( appliesToPriceIds: JsonField> = JsonMissing.of(), @JsonProperty("filters") @ExcludeMissing - filters: JsonField> = JsonMissing.of(), + filters: JsonField> = JsonMissing.of(), @JsonProperty("is_invoice_level") @ExcludeMissing isInvoiceLevel: JsonField = JsonMissing.of(), @@ -104,7 +104,7 @@ private constructor( * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ - fun filters(): List = filters.getRequired("filters") + fun filters(): List = filters.getRequired("filters") /** * True for adjustments that apply to an entire invoice, false for adjustments that apply to @@ -180,9 +180,7 @@ private constructor( * * Unlike [filters], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("filters") - @ExcludeMissing - fun _filters(): JsonField> = filters + @JsonProperty("filters") @ExcludeMissing fun _filters(): JsonField> = filters /** * Returns the raw JSON value of [isInvoiceLevel]. @@ -259,7 +257,7 @@ private constructor( private var adjustmentType: JsonField? = null private var amount: JsonField? = null private var appliesToPriceIds: JsonField>? = null - private var filters: JsonField>? = null + private var filters: JsonField>? = null private var isInvoiceLevel: JsonField? = null private var maximumAmount: JsonField? = null private var reason: JsonField? = null @@ -346,25 +344,25 @@ private constructor( } /** The filters that determine which prices to apply this adjustment to. */ - fun filters(filters: List) = filters(JsonField.of(filters)) + fun filters(filters: List) = filters(JsonField.of(filters)) /** * Sets [Builder.filters] to an arbitrary JSON value. * - * You should usually call [Builder.filters] with a well-typed `List` - * value instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. + * You should usually call [Builder.filters] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. */ - fun filters(filters: JsonField>) = apply { + fun filters(filters: JsonField>) = apply { this.filters = filters.map { it.toMutableList() } } /** - * Adds a single [TransformPriceFilter] to [filters]. + * Adds a single [Filter] to [filters]. * * @throws IllegalStateException if the field was previously set to a non-list. */ - fun addFilter(filter: TransformPriceFilter) = apply { + fun addFilter(filter: Filter) = apply { filters = (filters ?: JsonField.of(mutableListOf())).also { checkKnown("filters", it).add(filter) @@ -653,6 +651,534 @@ private constructor( override fun toString() = value.toString() } + class Filter + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val field: JsonField, + private val operator: JsonField, + private val values: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("field") @ExcludeMissing field: JsonField = JsonMissing.of(), + @JsonProperty("operator") + @ExcludeMissing + operator: JsonField = JsonMissing.of(), + @JsonProperty("values") + @ExcludeMissing + values: JsonField> = JsonMissing.of(), + ) : this(field, operator, values, mutableMapOf()) + + /** + * The property of the price to filter on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun field(): Field = field.getRequired("field") + + /** + * Should prices that match the filter be included or excluded. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun operator(): Operator = operator.getRequired("operator") + + /** + * The IDs or values that match this filter. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun values(): List = values.getRequired("values") + + /** + * Returns the raw JSON value of [field]. + * + * Unlike [field], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("field") @ExcludeMissing fun _field(): JsonField = field + + /** + * Returns the raw JSON value of [operator]. + * + * Unlike [operator], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("operator") @ExcludeMissing fun _operator(): JsonField = operator + + /** + * Returns the raw JSON value of [values]. + * + * Unlike [values], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("values") @ExcludeMissing fun _values(): JsonField> = values + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Filter]. + * + * The following fields are required: + * ```kotlin + * .field() + * .operator() + * .values() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Filter]. */ + class Builder internal constructor() { + + private var field: JsonField? = null + private var operator: JsonField? = null + private var values: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(filter: Filter) = apply { + field = filter.field + operator = filter.operator + values = filter.values.map { it.toMutableList() } + additionalProperties = filter.additionalProperties.toMutableMap() + } + + /** The property of the price to filter on. */ + fun field(field: Field) = field(JsonField.of(field)) + + /** + * Sets [Builder.field] to an arbitrary JSON value. + * + * You should usually call [Builder.field] with a well-typed [Field] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun field(field: JsonField) = apply { this.field = field } + + /** Should prices that match the filter be included or excluded. */ + fun operator(operator: Operator) = operator(JsonField.of(operator)) + + /** + * Sets [Builder.operator] to an arbitrary JSON value. + * + * You should usually call [Builder.operator] with a well-typed [Operator] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun operator(operator: JsonField) = apply { this.operator = operator } + + /** The IDs or values that match this filter. */ + fun values(values: List) = values(JsonField.of(values)) + + /** + * Sets [Builder.values] to an arbitrary JSON value. + * + * You should usually call [Builder.values] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun values(values: JsonField>) = apply { + this.values = values.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [values]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addValue(value: String) = apply { + values = + (values ?: JsonField.of(mutableListOf())).also { + checkKnown("values", it).add(value) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Filter]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .field() + * .operator() + * .values() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Filter = + Filter( + checkRequired("field", field), + checkRequired("operator", operator), + checkRequired("values", values).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Filter = apply { + if (validated) { + return@apply + } + + field().validate() + operator().validate() + values() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (field.asKnown()?.validity() ?: 0) + + (operator.asKnown()?.validity() ?: 0) + + (values.asKnown()?.size ?: 0) + + /** The property of the price to filter on. */ + class Field @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val PRICE_ID = of("price_id") + + val ITEM_ID = of("item_id") + + val PRICE_TYPE = of("price_type") + + val CURRENCY = of("currency") + + val PRICING_UNIT_ID = of("pricing_unit_id") + + fun of(value: String) = Field(JsonField.of(value)) + } + + /** An enum containing [Field]'s known values. */ + enum class Known { + PRICE_ID, + ITEM_ID, + PRICE_TYPE, + CURRENCY, + PRICING_UNIT_ID, + } + + /** + * An enum containing [Field]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Field] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + PRICE_ID, + ITEM_ID, + PRICE_TYPE, + CURRENCY, + PRICING_UNIT_ID, + /** + * An enum member indicating that [Field] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + PRICE_ID -> Value.PRICE_ID + ITEM_ID -> Value.ITEM_ID + PRICE_TYPE -> Value.PRICE_TYPE + CURRENCY -> Value.CURRENCY + PRICING_UNIT_ID -> Value.PRICING_UNIT_ID + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + PRICE_ID -> Known.PRICE_ID + ITEM_ID -> Known.ITEM_ID + PRICE_TYPE -> Known.PRICE_TYPE + CURRENCY -> Known.CURRENCY + PRICING_UNIT_ID -> Known.PRICING_UNIT_ID + else -> throw OrbInvalidDataException("Unknown Field: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Field = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Field && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Should prices that match the filter be included or excluded. */ + class Operator @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val INCLUDES = of("includes") + + val EXCLUDES = of("excludes") + + fun of(value: String) = Operator(JsonField.of(value)) + } + + /** An enum containing [Operator]'s known values. */ + enum class Known { + INCLUDES, + EXCLUDES, + } + + /** + * An enum containing [Operator]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Operator] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + INCLUDES, + EXCLUDES, + /** + * An enum member indicating that [Operator] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + INCLUDES -> Value.INCLUDES + EXCLUDES -> Value.EXCLUDES + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + INCLUDES -> Known.INCLUDES + EXCLUDES -> Known.EXCLUDES + else -> throw OrbInvalidDataException("Unknown Operator: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Operator = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Operator && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Filter && + field == other.field && + operator == other.operator && + values == other.values && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(field, operator, values, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Filter{field=$field, operator=$operator, values=$values, additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MonetaryMinimumAdjustment.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MonetaryMinimumAdjustment.kt index 630a06ca6..2e87bd2e7 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MonetaryMinimumAdjustment.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MonetaryMinimumAdjustment.kt @@ -25,7 +25,7 @@ private constructor( private val adjustmentType: JsonField, private val amount: JsonField, private val appliesToPriceIds: JsonField>, - private val filters: JsonField>, + private val filters: JsonField>, private val isInvoiceLevel: JsonField, private val itemId: JsonField, private val minimumAmount: JsonField, @@ -46,7 +46,7 @@ private constructor( appliesToPriceIds: JsonField> = JsonMissing.of(), @JsonProperty("filters") @ExcludeMissing - filters: JsonField> = JsonMissing.of(), + filters: JsonField> = JsonMissing.of(), @JsonProperty("is_invoice_level") @ExcludeMissing isInvoiceLevel: JsonField = JsonMissing.of(), @@ -107,7 +107,7 @@ private constructor( * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ - fun filters(): List = filters.getRequired("filters") + fun filters(): List = filters.getRequired("filters") /** * True for adjustments that apply to an entire invoice, false for adjustments that apply to @@ -191,9 +191,7 @@ private constructor( * * Unlike [filters], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("filters") - @ExcludeMissing - fun _filters(): JsonField> = filters + @JsonProperty("filters") @ExcludeMissing fun _filters(): JsonField> = filters /** * Returns the raw JSON value of [isInvoiceLevel]. @@ -278,7 +276,7 @@ private constructor( private var adjustmentType: JsonField? = null private var amount: JsonField? = null private var appliesToPriceIds: JsonField>? = null - private var filters: JsonField>? = null + private var filters: JsonField>? = null private var isInvoiceLevel: JsonField? = null private var itemId: JsonField? = null private var minimumAmount: JsonField? = null @@ -367,25 +365,25 @@ private constructor( } /** The filters that determine which prices to apply this adjustment to. */ - fun filters(filters: List) = filters(JsonField.of(filters)) + fun filters(filters: List) = filters(JsonField.of(filters)) /** * Sets [Builder.filters] to an arbitrary JSON value. * - * You should usually call [Builder.filters] with a well-typed `List` - * value instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. + * You should usually call [Builder.filters] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. */ - fun filters(filters: JsonField>) = apply { + fun filters(filters: JsonField>) = apply { this.filters = filters.map { it.toMutableList() } } /** - * Adds a single [TransformPriceFilter] to [filters]. + * Adds a single [Filter] to [filters]. * * @throws IllegalStateException if the field was previously set to a non-list. */ - fun addFilter(filter: TransformPriceFilter) = apply { + fun addFilter(filter: Filter) = apply { filters = (filters ?: JsonField.of(mutableListOf())).also { checkKnown("filters", it).add(filter) @@ -689,6 +687,534 @@ private constructor( override fun toString() = value.toString() } + class Filter + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val field: JsonField, + private val operator: JsonField, + private val values: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("field") @ExcludeMissing field: JsonField = JsonMissing.of(), + @JsonProperty("operator") + @ExcludeMissing + operator: JsonField = JsonMissing.of(), + @JsonProperty("values") + @ExcludeMissing + values: JsonField> = JsonMissing.of(), + ) : this(field, operator, values, mutableMapOf()) + + /** + * The property of the price to filter on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun field(): Field = field.getRequired("field") + + /** + * Should prices that match the filter be included or excluded. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun operator(): Operator = operator.getRequired("operator") + + /** + * The IDs or values that match this filter. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun values(): List = values.getRequired("values") + + /** + * Returns the raw JSON value of [field]. + * + * Unlike [field], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("field") @ExcludeMissing fun _field(): JsonField = field + + /** + * Returns the raw JSON value of [operator]. + * + * Unlike [operator], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("operator") @ExcludeMissing fun _operator(): JsonField = operator + + /** + * Returns the raw JSON value of [values]. + * + * Unlike [values], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("values") @ExcludeMissing fun _values(): JsonField> = values + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Filter]. + * + * The following fields are required: + * ```kotlin + * .field() + * .operator() + * .values() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Filter]. */ + class Builder internal constructor() { + + private var field: JsonField? = null + private var operator: JsonField? = null + private var values: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(filter: Filter) = apply { + field = filter.field + operator = filter.operator + values = filter.values.map { it.toMutableList() } + additionalProperties = filter.additionalProperties.toMutableMap() + } + + /** The property of the price to filter on. */ + fun field(field: Field) = field(JsonField.of(field)) + + /** + * Sets [Builder.field] to an arbitrary JSON value. + * + * You should usually call [Builder.field] with a well-typed [Field] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun field(field: JsonField) = apply { this.field = field } + + /** Should prices that match the filter be included or excluded. */ + fun operator(operator: Operator) = operator(JsonField.of(operator)) + + /** + * Sets [Builder.operator] to an arbitrary JSON value. + * + * You should usually call [Builder.operator] with a well-typed [Operator] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun operator(operator: JsonField) = apply { this.operator = operator } + + /** The IDs or values that match this filter. */ + fun values(values: List) = values(JsonField.of(values)) + + /** + * Sets [Builder.values] to an arbitrary JSON value. + * + * You should usually call [Builder.values] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun values(values: JsonField>) = apply { + this.values = values.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [values]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addValue(value: String) = apply { + values = + (values ?: JsonField.of(mutableListOf())).also { + checkKnown("values", it).add(value) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Filter]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .field() + * .operator() + * .values() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Filter = + Filter( + checkRequired("field", field), + checkRequired("operator", operator), + checkRequired("values", values).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Filter = apply { + if (validated) { + return@apply + } + + field().validate() + operator().validate() + values() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (field.asKnown()?.validity() ?: 0) + + (operator.asKnown()?.validity() ?: 0) + + (values.asKnown()?.size ?: 0) + + /** The property of the price to filter on. */ + class Field @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val PRICE_ID = of("price_id") + + val ITEM_ID = of("item_id") + + val PRICE_TYPE = of("price_type") + + val CURRENCY = of("currency") + + val PRICING_UNIT_ID = of("pricing_unit_id") + + fun of(value: String) = Field(JsonField.of(value)) + } + + /** An enum containing [Field]'s known values. */ + enum class Known { + PRICE_ID, + ITEM_ID, + PRICE_TYPE, + CURRENCY, + PRICING_UNIT_ID, + } + + /** + * An enum containing [Field]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Field] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + PRICE_ID, + ITEM_ID, + PRICE_TYPE, + CURRENCY, + PRICING_UNIT_ID, + /** + * An enum member indicating that [Field] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + PRICE_ID -> Value.PRICE_ID + ITEM_ID -> Value.ITEM_ID + PRICE_TYPE -> Value.PRICE_TYPE + CURRENCY -> Value.CURRENCY + PRICING_UNIT_ID -> Value.PRICING_UNIT_ID + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + PRICE_ID -> Known.PRICE_ID + ITEM_ID -> Known.ITEM_ID + PRICE_TYPE -> Known.PRICE_TYPE + CURRENCY -> Known.CURRENCY + PRICING_UNIT_ID -> Known.PRICING_UNIT_ID + else -> throw OrbInvalidDataException("Unknown Field: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Field = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Field && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Should prices that match the filter be included or excluded. */ + class Operator @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val INCLUDES = of("includes") + + val EXCLUDES = of("excludes") + + fun of(value: String) = Operator(JsonField.of(value)) + } + + /** An enum containing [Operator]'s known values. */ + enum class Known { + INCLUDES, + EXCLUDES, + } + + /** + * An enum containing [Operator]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Operator] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + INCLUDES, + EXCLUDES, + /** + * An enum member indicating that [Operator] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + INCLUDES -> Value.INCLUDES + EXCLUDES -> Value.EXCLUDES + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + INCLUDES -> Known.INCLUDES + EXCLUDES -> Known.EXCLUDES + else -> throw OrbInvalidDataException("Unknown Operator: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Operator = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Operator && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Filter && + field == other.field && + operator == other.operator && + values == other.values && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(field, operator, values, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Filter{field=$field, operator=$operator, values=$values, additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MonetaryPercentageDiscountAdjustment.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MonetaryPercentageDiscountAdjustment.kt index 334086584..65eb75503 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MonetaryPercentageDiscountAdjustment.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MonetaryPercentageDiscountAdjustment.kt @@ -25,7 +25,7 @@ private constructor( private val adjustmentType: JsonField, private val amount: JsonField, private val appliesToPriceIds: JsonField>, - private val filters: JsonField>, + private val filters: JsonField>, private val isInvoiceLevel: JsonField, private val percentageDiscount: JsonField, private val reason: JsonField, @@ -45,7 +45,7 @@ private constructor( appliesToPriceIds: JsonField> = JsonMissing.of(), @JsonProperty("filters") @ExcludeMissing - filters: JsonField> = JsonMissing.of(), + filters: JsonField> = JsonMissing.of(), @JsonProperty("is_invoice_level") @ExcludeMissing isInvoiceLevel: JsonField = JsonMissing.of(), @@ -104,7 +104,7 @@ private constructor( * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ - fun filters(): List = filters.getRequired("filters") + fun filters(): List = filters.getRequired("filters") /** * True for adjustments that apply to an entire invoice, false for adjustments that apply to @@ -180,9 +180,7 @@ private constructor( * * Unlike [filters], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("filters") - @ExcludeMissing - fun _filters(): JsonField> = filters + @JsonProperty("filters") @ExcludeMissing fun _filters(): JsonField> = filters /** * Returns the raw JSON value of [isInvoiceLevel]. @@ -261,7 +259,7 @@ private constructor( private var adjustmentType: JsonField? = null private var amount: JsonField? = null private var appliesToPriceIds: JsonField>? = null - private var filters: JsonField>? = null + private var filters: JsonField>? = null private var isInvoiceLevel: JsonField? = null private var percentageDiscount: JsonField? = null private var reason: JsonField? = null @@ -351,25 +349,25 @@ private constructor( } /** The filters that determine which prices to apply this adjustment to. */ - fun filters(filters: List) = filters(JsonField.of(filters)) + fun filters(filters: List) = filters(JsonField.of(filters)) /** * Sets [Builder.filters] to an arbitrary JSON value. * - * You should usually call [Builder.filters] with a well-typed `List` - * value instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. + * You should usually call [Builder.filters] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. */ - fun filters(filters: JsonField>) = apply { + fun filters(filters: JsonField>) = apply { this.filters = filters.map { it.toMutableList() } } /** - * Adds a single [TransformPriceFilter] to [filters]. + * Adds a single [Filter] to [filters]. * * @throws IllegalStateException if the field was previously set to a non-list. */ - fun addFilter(filter: TransformPriceFilter) = apply { + fun addFilter(filter: Filter) = apply { filters = (filters ?: JsonField.of(mutableListOf())).also { checkKnown("filters", it).add(filter) @@ -659,6 +657,534 @@ private constructor( override fun toString() = value.toString() } + class Filter + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val field: JsonField, + private val operator: JsonField, + private val values: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("field") @ExcludeMissing field: JsonField = JsonMissing.of(), + @JsonProperty("operator") + @ExcludeMissing + operator: JsonField = JsonMissing.of(), + @JsonProperty("values") + @ExcludeMissing + values: JsonField> = JsonMissing.of(), + ) : this(field, operator, values, mutableMapOf()) + + /** + * The property of the price to filter on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun field(): Field = field.getRequired("field") + + /** + * Should prices that match the filter be included or excluded. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun operator(): Operator = operator.getRequired("operator") + + /** + * The IDs or values that match this filter. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun values(): List = values.getRequired("values") + + /** + * Returns the raw JSON value of [field]. + * + * Unlike [field], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("field") @ExcludeMissing fun _field(): JsonField = field + + /** + * Returns the raw JSON value of [operator]. + * + * Unlike [operator], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("operator") @ExcludeMissing fun _operator(): JsonField = operator + + /** + * Returns the raw JSON value of [values]. + * + * Unlike [values], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("values") @ExcludeMissing fun _values(): JsonField> = values + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Filter]. + * + * The following fields are required: + * ```kotlin + * .field() + * .operator() + * .values() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Filter]. */ + class Builder internal constructor() { + + private var field: JsonField? = null + private var operator: JsonField? = null + private var values: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(filter: Filter) = apply { + field = filter.field + operator = filter.operator + values = filter.values.map { it.toMutableList() } + additionalProperties = filter.additionalProperties.toMutableMap() + } + + /** The property of the price to filter on. */ + fun field(field: Field) = field(JsonField.of(field)) + + /** + * Sets [Builder.field] to an arbitrary JSON value. + * + * You should usually call [Builder.field] with a well-typed [Field] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun field(field: JsonField) = apply { this.field = field } + + /** Should prices that match the filter be included or excluded. */ + fun operator(operator: Operator) = operator(JsonField.of(operator)) + + /** + * Sets [Builder.operator] to an arbitrary JSON value. + * + * You should usually call [Builder.operator] with a well-typed [Operator] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun operator(operator: JsonField) = apply { this.operator = operator } + + /** The IDs or values that match this filter. */ + fun values(values: List) = values(JsonField.of(values)) + + /** + * Sets [Builder.values] to an arbitrary JSON value. + * + * You should usually call [Builder.values] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun values(values: JsonField>) = apply { + this.values = values.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [values]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addValue(value: String) = apply { + values = + (values ?: JsonField.of(mutableListOf())).also { + checkKnown("values", it).add(value) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Filter]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .field() + * .operator() + * .values() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Filter = + Filter( + checkRequired("field", field), + checkRequired("operator", operator), + checkRequired("values", values).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Filter = apply { + if (validated) { + return@apply + } + + field().validate() + operator().validate() + values() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (field.asKnown()?.validity() ?: 0) + + (operator.asKnown()?.validity() ?: 0) + + (values.asKnown()?.size ?: 0) + + /** The property of the price to filter on. */ + class Field @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val PRICE_ID = of("price_id") + + val ITEM_ID = of("item_id") + + val PRICE_TYPE = of("price_type") + + val CURRENCY = of("currency") + + val PRICING_UNIT_ID = of("pricing_unit_id") + + fun of(value: String) = Field(JsonField.of(value)) + } + + /** An enum containing [Field]'s known values. */ + enum class Known { + PRICE_ID, + ITEM_ID, + PRICE_TYPE, + CURRENCY, + PRICING_UNIT_ID, + } + + /** + * An enum containing [Field]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Field] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + PRICE_ID, + ITEM_ID, + PRICE_TYPE, + CURRENCY, + PRICING_UNIT_ID, + /** + * An enum member indicating that [Field] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + PRICE_ID -> Value.PRICE_ID + ITEM_ID -> Value.ITEM_ID + PRICE_TYPE -> Value.PRICE_TYPE + CURRENCY -> Value.CURRENCY + PRICING_UNIT_ID -> Value.PRICING_UNIT_ID + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + PRICE_ID -> Known.PRICE_ID + ITEM_ID -> Known.ITEM_ID + PRICE_TYPE -> Known.PRICE_TYPE + CURRENCY -> Known.CURRENCY + PRICING_UNIT_ID -> Known.PRICING_UNIT_ID + else -> throw OrbInvalidDataException("Unknown Field: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Field = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Field && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Should prices that match the filter be included or excluded. */ + class Operator @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val INCLUDES = of("includes") + + val EXCLUDES = of("excludes") + + fun of(value: String) = Operator(JsonField.of(value)) + } + + /** An enum containing [Operator]'s known values. */ + enum class Known { + INCLUDES, + EXCLUDES, + } + + /** + * An enum containing [Operator]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Operator] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + INCLUDES, + EXCLUDES, + /** + * An enum member indicating that [Operator] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + INCLUDES -> Value.INCLUDES + EXCLUDES -> Value.EXCLUDES + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + INCLUDES -> Known.INCLUDES + EXCLUDES -> Known.EXCLUDES + else -> throw OrbInvalidDataException("Unknown Operator: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Operator = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Operator && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Filter && + field == other.field && + operator == other.operator && + values == other.values && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(field, operator, values, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Filter{field=$field, operator=$operator, values=$values, additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MonetaryUsageDiscountAdjustment.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MonetaryUsageDiscountAdjustment.kt index 667eec5ed..e36a6926e 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MonetaryUsageDiscountAdjustment.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/MonetaryUsageDiscountAdjustment.kt @@ -25,7 +25,7 @@ private constructor( private val adjustmentType: JsonField, private val amount: JsonField, private val appliesToPriceIds: JsonField>, - private val filters: JsonField>, + private val filters: JsonField>, private val isInvoiceLevel: JsonField, private val reason: JsonField, private val replacesAdjustmentId: JsonField, @@ -45,7 +45,7 @@ private constructor( appliesToPriceIds: JsonField> = JsonMissing.of(), @JsonProperty("filters") @ExcludeMissing - filters: JsonField> = JsonMissing.of(), + filters: JsonField> = JsonMissing.of(), @JsonProperty("is_invoice_level") @ExcludeMissing isInvoiceLevel: JsonField = JsonMissing.of(), @@ -104,7 +104,7 @@ private constructor( * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ - fun filters(): List = filters.getRequired("filters") + fun filters(): List = filters.getRequired("filters") /** * True for adjustments that apply to an entire invoice, false for adjustments that apply to @@ -180,9 +180,7 @@ private constructor( * * Unlike [filters], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("filters") - @ExcludeMissing - fun _filters(): JsonField> = filters + @JsonProperty("filters") @ExcludeMissing fun _filters(): JsonField> = filters /** * Returns the raw JSON value of [isInvoiceLevel]. @@ -260,7 +258,7 @@ private constructor( private var adjustmentType: JsonField? = null private var amount: JsonField? = null private var appliesToPriceIds: JsonField>? = null - private var filters: JsonField>? = null + private var filters: JsonField>? = null private var isInvoiceLevel: JsonField? = null private var reason: JsonField? = null private var replacesAdjustmentId: JsonField? = null @@ -349,25 +347,25 @@ private constructor( } /** The filters that determine which prices to apply this adjustment to. */ - fun filters(filters: List) = filters(JsonField.of(filters)) + fun filters(filters: List) = filters(JsonField.of(filters)) /** * Sets [Builder.filters] to an arbitrary JSON value. * - * You should usually call [Builder.filters] with a well-typed `List` - * value instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. + * You should usually call [Builder.filters] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. */ - fun filters(filters: JsonField>) = apply { + fun filters(filters: JsonField>) = apply { this.filters = filters.map { it.toMutableList() } } /** - * Adds a single [TransformPriceFilter] to [filters]. + * Adds a single [Filter] to [filters]. * * @throws IllegalStateException if the field was previously set to a non-list. */ - fun addFilter(filter: TransformPriceFilter) = apply { + fun addFilter(filter: Filter) = apply { filters = (filters ?: JsonField.of(mutableListOf())).also { checkKnown("filters", it).add(filter) @@ -656,6 +654,534 @@ private constructor( override fun toString() = value.toString() } + class Filter + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val field: JsonField, + private val operator: JsonField, + private val values: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("field") @ExcludeMissing field: JsonField = JsonMissing.of(), + @JsonProperty("operator") + @ExcludeMissing + operator: JsonField = JsonMissing.of(), + @JsonProperty("values") + @ExcludeMissing + values: JsonField> = JsonMissing.of(), + ) : this(field, operator, values, mutableMapOf()) + + /** + * The property of the price to filter on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun field(): Field = field.getRequired("field") + + /** + * Should prices that match the filter be included or excluded. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun operator(): Operator = operator.getRequired("operator") + + /** + * The IDs or values that match this filter. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun values(): List = values.getRequired("values") + + /** + * Returns the raw JSON value of [field]. + * + * Unlike [field], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("field") @ExcludeMissing fun _field(): JsonField = field + + /** + * Returns the raw JSON value of [operator]. + * + * Unlike [operator], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("operator") @ExcludeMissing fun _operator(): JsonField = operator + + /** + * Returns the raw JSON value of [values]. + * + * Unlike [values], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("values") @ExcludeMissing fun _values(): JsonField> = values + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Filter]. + * + * The following fields are required: + * ```kotlin + * .field() + * .operator() + * .values() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Filter]. */ + class Builder internal constructor() { + + private var field: JsonField? = null + private var operator: JsonField? = null + private var values: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(filter: Filter) = apply { + field = filter.field + operator = filter.operator + values = filter.values.map { it.toMutableList() } + additionalProperties = filter.additionalProperties.toMutableMap() + } + + /** The property of the price to filter on. */ + fun field(field: Field) = field(JsonField.of(field)) + + /** + * Sets [Builder.field] to an arbitrary JSON value. + * + * You should usually call [Builder.field] with a well-typed [Field] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun field(field: JsonField) = apply { this.field = field } + + /** Should prices that match the filter be included or excluded. */ + fun operator(operator: Operator) = operator(JsonField.of(operator)) + + /** + * Sets [Builder.operator] to an arbitrary JSON value. + * + * You should usually call [Builder.operator] with a well-typed [Operator] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun operator(operator: JsonField) = apply { this.operator = operator } + + /** The IDs or values that match this filter. */ + fun values(values: List) = values(JsonField.of(values)) + + /** + * Sets [Builder.values] to an arbitrary JSON value. + * + * You should usually call [Builder.values] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun values(values: JsonField>) = apply { + this.values = values.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [values]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addValue(value: String) = apply { + values = + (values ?: JsonField.of(mutableListOf())).also { + checkKnown("values", it).add(value) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Filter]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .field() + * .operator() + * .values() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Filter = + Filter( + checkRequired("field", field), + checkRequired("operator", operator), + checkRequired("values", values).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Filter = apply { + if (validated) { + return@apply + } + + field().validate() + operator().validate() + values() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (field.asKnown()?.validity() ?: 0) + + (operator.asKnown()?.validity() ?: 0) + + (values.asKnown()?.size ?: 0) + + /** The property of the price to filter on. */ + class Field @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val PRICE_ID = of("price_id") + + val ITEM_ID = of("item_id") + + val PRICE_TYPE = of("price_type") + + val CURRENCY = of("currency") + + val PRICING_UNIT_ID = of("pricing_unit_id") + + fun of(value: String) = Field(JsonField.of(value)) + } + + /** An enum containing [Field]'s known values. */ + enum class Known { + PRICE_ID, + ITEM_ID, + PRICE_TYPE, + CURRENCY, + PRICING_UNIT_ID, + } + + /** + * An enum containing [Field]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Field] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + PRICE_ID, + ITEM_ID, + PRICE_TYPE, + CURRENCY, + PRICING_UNIT_ID, + /** + * An enum member indicating that [Field] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + PRICE_ID -> Value.PRICE_ID + ITEM_ID -> Value.ITEM_ID + PRICE_TYPE -> Value.PRICE_TYPE + CURRENCY -> Value.CURRENCY + PRICING_UNIT_ID -> Value.PRICING_UNIT_ID + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + PRICE_ID -> Known.PRICE_ID + ITEM_ID -> Known.ITEM_ID + PRICE_TYPE -> Known.PRICE_TYPE + CURRENCY -> Known.CURRENCY + PRICING_UNIT_ID -> Known.PRICING_UNIT_ID + else -> throw OrbInvalidDataException("Unknown Field: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Field = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Field && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Should prices that match the filter be included or excluded. */ + class Operator @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val INCLUDES = of("includes") + + val EXCLUDES = of("excludes") + + fun of(value: String) = Operator(JsonField.of(value)) + } + + /** An enum containing [Operator]'s known values. */ + enum class Known { + INCLUDES, + EXCLUDES, + } + + /** + * An enum containing [Operator]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Operator] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + INCLUDES, + EXCLUDES, + /** + * An enum member indicating that [Operator] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + INCLUDES -> Value.INCLUDES + EXCLUDES -> Value.EXCLUDES + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + INCLUDES -> Known.INCLUDES + EXCLUDES -> Known.EXCLUDES + else -> throw OrbInvalidDataException("Unknown Operator: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Operator = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Operator && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Filter && + field == other.field && + operator == other.operator && + values == other.values && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(field, operator, values, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Filter{field=$field, operator=$operator, values=$values, additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewAmountDiscount.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewAmountDiscount.kt index 2c741bf25..6b2295485 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewAmountDiscount.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewAmountDiscount.kt @@ -27,7 +27,7 @@ private constructor( private val appliesToItemIds: JsonField>, private val appliesToPriceIds: JsonField>, private val currency: JsonField, - private val filters: JsonField>, + private val filters: JsonField>, private val isInvoiceLevel: JsonField, private val priceType: JsonField, private val additionalProperties: MutableMap, @@ -53,7 +53,7 @@ private constructor( @JsonProperty("currency") @ExcludeMissing currency: JsonField = JsonMissing.of(), @JsonProperty("filters") @ExcludeMissing - filters: JsonField> = JsonMissing.of(), + filters: JsonField> = JsonMissing.of(), @JsonProperty("is_invoice_level") @ExcludeMissing isInvoiceLevel: JsonField = JsonMissing.of(), @@ -123,7 +123,7 @@ private constructor( * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server * responded with an unexpected value). */ - fun filters(): List? = filters.getNullable("filters") + fun filters(): List? = filters.getNullable("filters") /** * When false, this adjustment will be applied to a single price. Otherwise, it will be applied @@ -201,9 +201,7 @@ private constructor( * * Unlike [filters], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("filters") - @ExcludeMissing - fun _filters(): JsonField> = filters + @JsonProperty("filters") @ExcludeMissing fun _filters(): JsonField> = filters /** * Returns the raw JSON value of [isInvoiceLevel]. @@ -256,7 +254,7 @@ private constructor( private var appliesToItemIds: JsonField>? = null private var appliesToPriceIds: JsonField>? = null private var currency: JsonField = JsonMissing.of() - private var filters: JsonField>? = null + private var filters: JsonField>? = null private var isInvoiceLevel: JsonField = JsonMissing.of() private var priceType: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -382,25 +380,25 @@ private constructor( fun currency(currency: JsonField) = apply { this.currency = currency } /** A list of filters that determine which prices this adjustment will apply to. */ - fun filters(filters: List?) = filters(JsonField.ofNullable(filters)) + fun filters(filters: List?) = filters(JsonField.ofNullable(filters)) /** * Sets [Builder.filters] to an arbitrary JSON value. * - * You should usually call [Builder.filters] with a well-typed `List` - * value instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. + * You should usually call [Builder.filters] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. */ - fun filters(filters: JsonField>) = apply { + fun filters(filters: JsonField>) = apply { this.filters = filters.map { it.toMutableList() } } /** - * Adds a single [TransformPriceFilter] to [filters]. + * Adds a single [Filter] to [filters]. * * @throws IllegalStateException if the field was previously set to a non-list. */ - fun addFilter(filter: TransformPriceFilter) = apply { + fun addFilter(filter: Filter) = apply { filters = (filters ?: JsonField.of(mutableListOf())).also { checkKnown("filters", it).add(filter) @@ -767,6 +765,534 @@ private constructor( override fun toString() = value.toString() } + class Filter + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val field: JsonField, + private val operator: JsonField, + private val values: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("field") @ExcludeMissing field: JsonField = JsonMissing.of(), + @JsonProperty("operator") + @ExcludeMissing + operator: JsonField = JsonMissing.of(), + @JsonProperty("values") + @ExcludeMissing + values: JsonField> = JsonMissing.of(), + ) : this(field, operator, values, mutableMapOf()) + + /** + * The property of the price to filter on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun field(): Field = field.getRequired("field") + + /** + * Should prices that match the filter be included or excluded. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun operator(): Operator = operator.getRequired("operator") + + /** + * The IDs or values that match this filter. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun values(): List = values.getRequired("values") + + /** + * Returns the raw JSON value of [field]. + * + * Unlike [field], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("field") @ExcludeMissing fun _field(): JsonField = field + + /** + * Returns the raw JSON value of [operator]. + * + * Unlike [operator], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("operator") @ExcludeMissing fun _operator(): JsonField = operator + + /** + * Returns the raw JSON value of [values]. + * + * Unlike [values], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("values") @ExcludeMissing fun _values(): JsonField> = values + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Filter]. + * + * The following fields are required: + * ```kotlin + * .field() + * .operator() + * .values() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Filter]. */ + class Builder internal constructor() { + + private var field: JsonField? = null + private var operator: JsonField? = null + private var values: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(filter: Filter) = apply { + field = filter.field + operator = filter.operator + values = filter.values.map { it.toMutableList() } + additionalProperties = filter.additionalProperties.toMutableMap() + } + + /** The property of the price to filter on. */ + fun field(field: Field) = field(JsonField.of(field)) + + /** + * Sets [Builder.field] to an arbitrary JSON value. + * + * You should usually call [Builder.field] with a well-typed [Field] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun field(field: JsonField) = apply { this.field = field } + + /** Should prices that match the filter be included or excluded. */ + fun operator(operator: Operator) = operator(JsonField.of(operator)) + + /** + * Sets [Builder.operator] to an arbitrary JSON value. + * + * You should usually call [Builder.operator] with a well-typed [Operator] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun operator(operator: JsonField) = apply { this.operator = operator } + + /** The IDs or values that match this filter. */ + fun values(values: List) = values(JsonField.of(values)) + + /** + * Sets [Builder.values] to an arbitrary JSON value. + * + * You should usually call [Builder.values] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun values(values: JsonField>) = apply { + this.values = values.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [values]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addValue(value: String) = apply { + values = + (values ?: JsonField.of(mutableListOf())).also { + checkKnown("values", it).add(value) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Filter]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .field() + * .operator() + * .values() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Filter = + Filter( + checkRequired("field", field), + checkRequired("operator", operator), + checkRequired("values", values).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Filter = apply { + if (validated) { + return@apply + } + + field().validate() + operator().validate() + values() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (field.asKnown()?.validity() ?: 0) + + (operator.asKnown()?.validity() ?: 0) + + (values.asKnown()?.size ?: 0) + + /** The property of the price to filter on. */ + class Field @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val PRICE_ID = of("price_id") + + val ITEM_ID = of("item_id") + + val PRICE_TYPE = of("price_type") + + val CURRENCY = of("currency") + + val PRICING_UNIT_ID = of("pricing_unit_id") + + fun of(value: String) = Field(JsonField.of(value)) + } + + /** An enum containing [Field]'s known values. */ + enum class Known { + PRICE_ID, + ITEM_ID, + PRICE_TYPE, + CURRENCY, + PRICING_UNIT_ID, + } + + /** + * An enum containing [Field]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Field] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + PRICE_ID, + ITEM_ID, + PRICE_TYPE, + CURRENCY, + PRICING_UNIT_ID, + /** + * An enum member indicating that [Field] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + PRICE_ID -> Value.PRICE_ID + ITEM_ID -> Value.ITEM_ID + PRICE_TYPE -> Value.PRICE_TYPE + CURRENCY -> Value.CURRENCY + PRICING_UNIT_ID -> Value.PRICING_UNIT_ID + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + PRICE_ID -> Known.PRICE_ID + ITEM_ID -> Known.ITEM_ID + PRICE_TYPE -> Known.PRICE_TYPE + CURRENCY -> Known.CURRENCY + PRICING_UNIT_ID -> Known.PRICING_UNIT_ID + else -> throw OrbInvalidDataException("Unknown Field: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Field = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Field && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Should prices that match the filter be included or excluded. */ + class Operator @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val INCLUDES = of("includes") + + val EXCLUDES = of("excludes") + + fun of(value: String) = Operator(JsonField.of(value)) + } + + /** An enum containing [Operator]'s known values. */ + enum class Known { + INCLUDES, + EXCLUDES, + } + + /** + * An enum containing [Operator]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Operator] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + INCLUDES, + EXCLUDES, + /** + * An enum member indicating that [Operator] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + INCLUDES -> Value.INCLUDES + EXCLUDES -> Value.EXCLUDES + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + INCLUDES -> Known.INCLUDES + EXCLUDES -> Known.EXCLUDES + else -> throw OrbInvalidDataException("Unknown Operator: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Operator = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Operator && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Filter && + field == other.field && + operator == other.operator && + values == other.values && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(field, operator, values, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Filter{field=$field, operator=$operator, values=$values, additionalProperties=$additionalProperties}" + } + /** If set, only prices of the specified type will have the adjustment applied. */ class PriceType @JsonCreator private constructor(private val value: JsonField) : Enum { diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewMaximum.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewMaximum.kt index 0293f4b14..eec7389a5 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewMaximum.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewMaximum.kt @@ -27,7 +27,7 @@ private constructor( private val appliesToItemIds: JsonField>, private val appliesToPriceIds: JsonField>, private val currency: JsonField, - private val filters: JsonField>, + private val filters: JsonField>, private val isInvoiceLevel: JsonField, private val priceType: JsonField, private val additionalProperties: MutableMap, @@ -53,7 +53,7 @@ private constructor( @JsonProperty("currency") @ExcludeMissing currency: JsonField = JsonMissing.of(), @JsonProperty("filters") @ExcludeMissing - filters: JsonField> = JsonMissing.of(), + filters: JsonField> = JsonMissing.of(), @JsonProperty("is_invoice_level") @ExcludeMissing isInvoiceLevel: JsonField = JsonMissing.of(), @@ -123,7 +123,7 @@ private constructor( * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server * responded with an unexpected value). */ - fun filters(): List? = filters.getNullable("filters") + fun filters(): List? = filters.getNullable("filters") /** * When false, this adjustment will be applied to a single price. Otherwise, it will be applied @@ -201,9 +201,7 @@ private constructor( * * Unlike [filters], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("filters") - @ExcludeMissing - fun _filters(): JsonField> = filters + @JsonProperty("filters") @ExcludeMissing fun _filters(): JsonField> = filters /** * Returns the raw JSON value of [isInvoiceLevel]. @@ -256,7 +254,7 @@ private constructor( private var appliesToItemIds: JsonField>? = null private var appliesToPriceIds: JsonField>? = null private var currency: JsonField = JsonMissing.of() - private var filters: JsonField>? = null + private var filters: JsonField>? = null private var isInvoiceLevel: JsonField = JsonMissing.of() private var priceType: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -382,25 +380,25 @@ private constructor( fun currency(currency: JsonField) = apply { this.currency = currency } /** A list of filters that determine which prices this adjustment will apply to. */ - fun filters(filters: List?) = filters(JsonField.ofNullable(filters)) + fun filters(filters: List?) = filters(JsonField.ofNullable(filters)) /** * Sets [Builder.filters] to an arbitrary JSON value. * - * You should usually call [Builder.filters] with a well-typed `List` - * value instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. + * You should usually call [Builder.filters] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. */ - fun filters(filters: JsonField>) = apply { + fun filters(filters: JsonField>) = apply { this.filters = filters.map { it.toMutableList() } } /** - * Adds a single [TransformPriceFilter] to [filters]. + * Adds a single [Filter] to [filters]. * * @throws IllegalStateException if the field was previously set to a non-list. */ - fun addFilter(filter: TransformPriceFilter) = apply { + fun addFilter(filter: Filter) = apply { filters = (filters ?: JsonField.of(mutableListOf())).also { checkKnown("filters", it).add(filter) @@ -767,6 +765,534 @@ private constructor( override fun toString() = value.toString() } + class Filter + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val field: JsonField, + private val operator: JsonField, + private val values: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("field") @ExcludeMissing field: JsonField = JsonMissing.of(), + @JsonProperty("operator") + @ExcludeMissing + operator: JsonField = JsonMissing.of(), + @JsonProperty("values") + @ExcludeMissing + values: JsonField> = JsonMissing.of(), + ) : this(field, operator, values, mutableMapOf()) + + /** + * The property of the price to filter on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun field(): Field = field.getRequired("field") + + /** + * Should prices that match the filter be included or excluded. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun operator(): Operator = operator.getRequired("operator") + + /** + * The IDs or values that match this filter. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun values(): List = values.getRequired("values") + + /** + * Returns the raw JSON value of [field]. + * + * Unlike [field], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("field") @ExcludeMissing fun _field(): JsonField = field + + /** + * Returns the raw JSON value of [operator]. + * + * Unlike [operator], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("operator") @ExcludeMissing fun _operator(): JsonField = operator + + /** + * Returns the raw JSON value of [values]. + * + * Unlike [values], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("values") @ExcludeMissing fun _values(): JsonField> = values + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Filter]. + * + * The following fields are required: + * ```kotlin + * .field() + * .operator() + * .values() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Filter]. */ + class Builder internal constructor() { + + private var field: JsonField? = null + private var operator: JsonField? = null + private var values: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(filter: Filter) = apply { + field = filter.field + operator = filter.operator + values = filter.values.map { it.toMutableList() } + additionalProperties = filter.additionalProperties.toMutableMap() + } + + /** The property of the price to filter on. */ + fun field(field: Field) = field(JsonField.of(field)) + + /** + * Sets [Builder.field] to an arbitrary JSON value. + * + * You should usually call [Builder.field] with a well-typed [Field] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun field(field: JsonField) = apply { this.field = field } + + /** Should prices that match the filter be included or excluded. */ + fun operator(operator: Operator) = operator(JsonField.of(operator)) + + /** + * Sets [Builder.operator] to an arbitrary JSON value. + * + * You should usually call [Builder.operator] with a well-typed [Operator] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun operator(operator: JsonField) = apply { this.operator = operator } + + /** The IDs or values that match this filter. */ + fun values(values: List) = values(JsonField.of(values)) + + /** + * Sets [Builder.values] to an arbitrary JSON value. + * + * You should usually call [Builder.values] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun values(values: JsonField>) = apply { + this.values = values.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [values]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addValue(value: String) = apply { + values = + (values ?: JsonField.of(mutableListOf())).also { + checkKnown("values", it).add(value) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Filter]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .field() + * .operator() + * .values() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Filter = + Filter( + checkRequired("field", field), + checkRequired("operator", operator), + checkRequired("values", values).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Filter = apply { + if (validated) { + return@apply + } + + field().validate() + operator().validate() + values() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (field.asKnown()?.validity() ?: 0) + + (operator.asKnown()?.validity() ?: 0) + + (values.asKnown()?.size ?: 0) + + /** The property of the price to filter on. */ + class Field @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val PRICE_ID = of("price_id") + + val ITEM_ID = of("item_id") + + val PRICE_TYPE = of("price_type") + + val CURRENCY = of("currency") + + val PRICING_UNIT_ID = of("pricing_unit_id") + + fun of(value: String) = Field(JsonField.of(value)) + } + + /** An enum containing [Field]'s known values. */ + enum class Known { + PRICE_ID, + ITEM_ID, + PRICE_TYPE, + CURRENCY, + PRICING_UNIT_ID, + } + + /** + * An enum containing [Field]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Field] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + PRICE_ID, + ITEM_ID, + PRICE_TYPE, + CURRENCY, + PRICING_UNIT_ID, + /** + * An enum member indicating that [Field] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + PRICE_ID -> Value.PRICE_ID + ITEM_ID -> Value.ITEM_ID + PRICE_TYPE -> Value.PRICE_TYPE + CURRENCY -> Value.CURRENCY + PRICING_UNIT_ID -> Value.PRICING_UNIT_ID + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + PRICE_ID -> Known.PRICE_ID + ITEM_ID -> Known.ITEM_ID + PRICE_TYPE -> Known.PRICE_TYPE + CURRENCY -> Known.CURRENCY + PRICING_UNIT_ID -> Known.PRICING_UNIT_ID + else -> throw OrbInvalidDataException("Unknown Field: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Field = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Field && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Should prices that match the filter be included or excluded. */ + class Operator @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val INCLUDES = of("includes") + + val EXCLUDES = of("excludes") + + fun of(value: String) = Operator(JsonField.of(value)) + } + + /** An enum containing [Operator]'s known values. */ + enum class Known { + INCLUDES, + EXCLUDES, + } + + /** + * An enum containing [Operator]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Operator] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + INCLUDES, + EXCLUDES, + /** + * An enum member indicating that [Operator] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + INCLUDES -> Value.INCLUDES + EXCLUDES -> Value.EXCLUDES + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + INCLUDES -> Known.INCLUDES + EXCLUDES -> Known.EXCLUDES + else -> throw OrbInvalidDataException("Unknown Operator: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Operator = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Operator && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Filter && + field == other.field && + operator == other.operator && + values == other.values && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(field, operator, values, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Filter{field=$field, operator=$operator, values=$values, additionalProperties=$additionalProperties}" + } + /** If set, only prices of the specified type will have the adjustment applied. */ class PriceType @JsonCreator private constructor(private val value: JsonField) : Enum { diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewMinimum.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewMinimum.kt index b5350f944..5950f203c 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewMinimum.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewMinimum.kt @@ -28,7 +28,7 @@ private constructor( private val appliesToItemIds: JsonField>, private val appliesToPriceIds: JsonField>, private val currency: JsonField, - private val filters: JsonField>, + private val filters: JsonField>, private val isInvoiceLevel: JsonField, private val priceType: JsonField, private val additionalProperties: MutableMap, @@ -55,7 +55,7 @@ private constructor( @JsonProperty("currency") @ExcludeMissing currency: JsonField = JsonMissing.of(), @JsonProperty("filters") @ExcludeMissing - filters: JsonField> = JsonMissing.of(), + filters: JsonField> = JsonMissing.of(), @JsonProperty("is_invoice_level") @ExcludeMissing isInvoiceLevel: JsonField = JsonMissing.of(), @@ -134,7 +134,7 @@ private constructor( * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server * responded with an unexpected value). */ - fun filters(): List? = filters.getNullable("filters") + fun filters(): List? = filters.getNullable("filters") /** * When false, this adjustment will be applied to a single price. Otherwise, it will be applied @@ -219,9 +219,7 @@ private constructor( * * Unlike [filters], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("filters") - @ExcludeMissing - fun _filters(): JsonField> = filters + @JsonProperty("filters") @ExcludeMissing fun _filters(): JsonField> = filters /** * Returns the raw JSON value of [isInvoiceLevel]. @@ -276,7 +274,7 @@ private constructor( private var appliesToItemIds: JsonField>? = null private var appliesToPriceIds: JsonField>? = null private var currency: JsonField = JsonMissing.of() - private var filters: JsonField>? = null + private var filters: JsonField>? = null private var isInvoiceLevel: JsonField = JsonMissing.of() private var priceType: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -414,25 +412,25 @@ private constructor( fun currency(currency: JsonField) = apply { this.currency = currency } /** A list of filters that determine which prices this adjustment will apply to. */ - fun filters(filters: List?) = filters(JsonField.ofNullable(filters)) + fun filters(filters: List?) = filters(JsonField.ofNullable(filters)) /** * Sets [Builder.filters] to an arbitrary JSON value. * - * You should usually call [Builder.filters] with a well-typed `List` - * value instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. + * You should usually call [Builder.filters] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. */ - fun filters(filters: JsonField>) = apply { + fun filters(filters: JsonField>) = apply { this.filters = filters.map { it.toMutableList() } } /** - * Adds a single [TransformPriceFilter] to [filters]. + * Adds a single [Filter] to [filters]. * * @throws IllegalStateException if the field was previously set to a non-list. */ - fun addFilter(filter: TransformPriceFilter) = apply { + fun addFilter(filter: Filter) = apply { filters = (filters ?: JsonField.of(mutableListOf())).also { checkKnown("filters", it).add(filter) @@ -803,6 +801,534 @@ private constructor( override fun toString() = value.toString() } + class Filter + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val field: JsonField, + private val operator: JsonField, + private val values: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("field") @ExcludeMissing field: JsonField = JsonMissing.of(), + @JsonProperty("operator") + @ExcludeMissing + operator: JsonField = JsonMissing.of(), + @JsonProperty("values") + @ExcludeMissing + values: JsonField> = JsonMissing.of(), + ) : this(field, operator, values, mutableMapOf()) + + /** + * The property of the price to filter on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun field(): Field = field.getRequired("field") + + /** + * Should prices that match the filter be included or excluded. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun operator(): Operator = operator.getRequired("operator") + + /** + * The IDs or values that match this filter. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun values(): List = values.getRequired("values") + + /** + * Returns the raw JSON value of [field]. + * + * Unlike [field], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("field") @ExcludeMissing fun _field(): JsonField = field + + /** + * Returns the raw JSON value of [operator]. + * + * Unlike [operator], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("operator") @ExcludeMissing fun _operator(): JsonField = operator + + /** + * Returns the raw JSON value of [values]. + * + * Unlike [values], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("values") @ExcludeMissing fun _values(): JsonField> = values + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Filter]. + * + * The following fields are required: + * ```kotlin + * .field() + * .operator() + * .values() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Filter]. */ + class Builder internal constructor() { + + private var field: JsonField? = null + private var operator: JsonField? = null + private var values: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(filter: Filter) = apply { + field = filter.field + operator = filter.operator + values = filter.values.map { it.toMutableList() } + additionalProperties = filter.additionalProperties.toMutableMap() + } + + /** The property of the price to filter on. */ + fun field(field: Field) = field(JsonField.of(field)) + + /** + * Sets [Builder.field] to an arbitrary JSON value. + * + * You should usually call [Builder.field] with a well-typed [Field] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun field(field: JsonField) = apply { this.field = field } + + /** Should prices that match the filter be included or excluded. */ + fun operator(operator: Operator) = operator(JsonField.of(operator)) + + /** + * Sets [Builder.operator] to an arbitrary JSON value. + * + * You should usually call [Builder.operator] with a well-typed [Operator] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun operator(operator: JsonField) = apply { this.operator = operator } + + /** The IDs or values that match this filter. */ + fun values(values: List) = values(JsonField.of(values)) + + /** + * Sets [Builder.values] to an arbitrary JSON value. + * + * You should usually call [Builder.values] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun values(values: JsonField>) = apply { + this.values = values.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [values]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addValue(value: String) = apply { + values = + (values ?: JsonField.of(mutableListOf())).also { + checkKnown("values", it).add(value) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Filter]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .field() + * .operator() + * .values() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Filter = + Filter( + checkRequired("field", field), + checkRequired("operator", operator), + checkRequired("values", values).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Filter = apply { + if (validated) { + return@apply + } + + field().validate() + operator().validate() + values() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (field.asKnown()?.validity() ?: 0) + + (operator.asKnown()?.validity() ?: 0) + + (values.asKnown()?.size ?: 0) + + /** The property of the price to filter on. */ + class Field @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val PRICE_ID = of("price_id") + + val ITEM_ID = of("item_id") + + val PRICE_TYPE = of("price_type") + + val CURRENCY = of("currency") + + val PRICING_UNIT_ID = of("pricing_unit_id") + + fun of(value: String) = Field(JsonField.of(value)) + } + + /** An enum containing [Field]'s known values. */ + enum class Known { + PRICE_ID, + ITEM_ID, + PRICE_TYPE, + CURRENCY, + PRICING_UNIT_ID, + } + + /** + * An enum containing [Field]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Field] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + PRICE_ID, + ITEM_ID, + PRICE_TYPE, + CURRENCY, + PRICING_UNIT_ID, + /** + * An enum member indicating that [Field] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + PRICE_ID -> Value.PRICE_ID + ITEM_ID -> Value.ITEM_ID + PRICE_TYPE -> Value.PRICE_TYPE + CURRENCY -> Value.CURRENCY + PRICING_UNIT_ID -> Value.PRICING_UNIT_ID + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + PRICE_ID -> Known.PRICE_ID + ITEM_ID -> Known.ITEM_ID + PRICE_TYPE -> Known.PRICE_TYPE + CURRENCY -> Known.CURRENCY + PRICING_UNIT_ID -> Known.PRICING_UNIT_ID + else -> throw OrbInvalidDataException("Unknown Field: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Field = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Field && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Should prices that match the filter be included or excluded. */ + class Operator @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val INCLUDES = of("includes") + + val EXCLUDES = of("excludes") + + fun of(value: String) = Operator(JsonField.of(value)) + } + + /** An enum containing [Operator]'s known values. */ + enum class Known { + INCLUDES, + EXCLUDES, + } + + /** + * An enum containing [Operator]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Operator] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + INCLUDES, + EXCLUDES, + /** + * An enum member indicating that [Operator] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + INCLUDES -> Value.INCLUDES + EXCLUDES -> Value.EXCLUDES + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + INCLUDES -> Known.INCLUDES + EXCLUDES -> Known.EXCLUDES + else -> throw OrbInvalidDataException("Unknown Operator: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Operator = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Operator && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Filter && + field == other.field && + operator == other.operator && + values == other.values && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(field, operator, values, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Filter{field=$field, operator=$operator, values=$values, additionalProperties=$additionalProperties}" + } + /** If set, only prices of the specified type will have the adjustment applied. */ class PriceType @JsonCreator private constructor(private val value: JsonField) : Enum { diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPercentageDiscount.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPercentageDiscount.kt index f73f61633..a122b84f6 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPercentageDiscount.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPercentageDiscount.kt @@ -27,7 +27,7 @@ private constructor( private val appliesToItemIds: JsonField>, private val appliesToPriceIds: JsonField>, private val currency: JsonField, - private val filters: JsonField>, + private val filters: JsonField>, private val isInvoiceLevel: JsonField, private val priceType: JsonField, private val additionalProperties: MutableMap, @@ -53,7 +53,7 @@ private constructor( @JsonProperty("currency") @ExcludeMissing currency: JsonField = JsonMissing.of(), @JsonProperty("filters") @ExcludeMissing - filters: JsonField> = JsonMissing.of(), + filters: JsonField> = JsonMissing.of(), @JsonProperty("is_invoice_level") @ExcludeMissing isInvoiceLevel: JsonField = JsonMissing.of(), @@ -123,7 +123,7 @@ private constructor( * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server * responded with an unexpected value). */ - fun filters(): List? = filters.getNullable("filters") + fun filters(): List? = filters.getNullable("filters") /** * When false, this adjustment will be applied to a single price. Otherwise, it will be applied @@ -202,9 +202,7 @@ private constructor( * * Unlike [filters], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("filters") - @ExcludeMissing - fun _filters(): JsonField> = filters + @JsonProperty("filters") @ExcludeMissing fun _filters(): JsonField> = filters /** * Returns the raw JSON value of [isInvoiceLevel]. @@ -257,7 +255,7 @@ private constructor( private var appliesToItemIds: JsonField>? = null private var appliesToPriceIds: JsonField>? = null private var currency: JsonField = JsonMissing.of() - private var filters: JsonField>? = null + private var filters: JsonField>? = null private var isInvoiceLevel: JsonField = JsonMissing.of() private var priceType: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -384,25 +382,25 @@ private constructor( fun currency(currency: JsonField) = apply { this.currency = currency } /** A list of filters that determine which prices this adjustment will apply to. */ - fun filters(filters: List?) = filters(JsonField.ofNullable(filters)) + fun filters(filters: List?) = filters(JsonField.ofNullable(filters)) /** * Sets [Builder.filters] to an arbitrary JSON value. * - * You should usually call [Builder.filters] with a well-typed `List` - * value instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. + * You should usually call [Builder.filters] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. */ - fun filters(filters: JsonField>) = apply { + fun filters(filters: JsonField>) = apply { this.filters = filters.map { it.toMutableList() } } /** - * Adds a single [TransformPriceFilter] to [filters]. + * Adds a single [Filter] to [filters]. * * @throws IllegalStateException if the field was previously set to a non-list. */ - fun addFilter(filter: TransformPriceFilter) = apply { + fun addFilter(filter: Filter) = apply { filters = (filters ?: JsonField.of(mutableListOf())).also { checkKnown("filters", it).add(filter) @@ -769,6 +767,534 @@ private constructor( override fun toString() = value.toString() } + class Filter + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val field: JsonField, + private val operator: JsonField, + private val values: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("field") @ExcludeMissing field: JsonField = JsonMissing.of(), + @JsonProperty("operator") + @ExcludeMissing + operator: JsonField = JsonMissing.of(), + @JsonProperty("values") + @ExcludeMissing + values: JsonField> = JsonMissing.of(), + ) : this(field, operator, values, mutableMapOf()) + + /** + * The property of the price to filter on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun field(): Field = field.getRequired("field") + + /** + * Should prices that match the filter be included or excluded. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun operator(): Operator = operator.getRequired("operator") + + /** + * The IDs or values that match this filter. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun values(): List = values.getRequired("values") + + /** + * Returns the raw JSON value of [field]. + * + * Unlike [field], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("field") @ExcludeMissing fun _field(): JsonField = field + + /** + * Returns the raw JSON value of [operator]. + * + * Unlike [operator], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("operator") @ExcludeMissing fun _operator(): JsonField = operator + + /** + * Returns the raw JSON value of [values]. + * + * Unlike [values], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("values") @ExcludeMissing fun _values(): JsonField> = values + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Filter]. + * + * The following fields are required: + * ```kotlin + * .field() + * .operator() + * .values() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Filter]. */ + class Builder internal constructor() { + + private var field: JsonField? = null + private var operator: JsonField? = null + private var values: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(filter: Filter) = apply { + field = filter.field + operator = filter.operator + values = filter.values.map { it.toMutableList() } + additionalProperties = filter.additionalProperties.toMutableMap() + } + + /** The property of the price to filter on. */ + fun field(field: Field) = field(JsonField.of(field)) + + /** + * Sets [Builder.field] to an arbitrary JSON value. + * + * You should usually call [Builder.field] with a well-typed [Field] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun field(field: JsonField) = apply { this.field = field } + + /** Should prices that match the filter be included or excluded. */ + fun operator(operator: Operator) = operator(JsonField.of(operator)) + + /** + * Sets [Builder.operator] to an arbitrary JSON value. + * + * You should usually call [Builder.operator] with a well-typed [Operator] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun operator(operator: JsonField) = apply { this.operator = operator } + + /** The IDs or values that match this filter. */ + fun values(values: List) = values(JsonField.of(values)) + + /** + * Sets [Builder.values] to an arbitrary JSON value. + * + * You should usually call [Builder.values] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun values(values: JsonField>) = apply { + this.values = values.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [values]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addValue(value: String) = apply { + values = + (values ?: JsonField.of(mutableListOf())).also { + checkKnown("values", it).add(value) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Filter]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .field() + * .operator() + * .values() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Filter = + Filter( + checkRequired("field", field), + checkRequired("operator", operator), + checkRequired("values", values).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Filter = apply { + if (validated) { + return@apply + } + + field().validate() + operator().validate() + values() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (field.asKnown()?.validity() ?: 0) + + (operator.asKnown()?.validity() ?: 0) + + (values.asKnown()?.size ?: 0) + + /** The property of the price to filter on. */ + class Field @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val PRICE_ID = of("price_id") + + val ITEM_ID = of("item_id") + + val PRICE_TYPE = of("price_type") + + val CURRENCY = of("currency") + + val PRICING_UNIT_ID = of("pricing_unit_id") + + fun of(value: String) = Field(JsonField.of(value)) + } + + /** An enum containing [Field]'s known values. */ + enum class Known { + PRICE_ID, + ITEM_ID, + PRICE_TYPE, + CURRENCY, + PRICING_UNIT_ID, + } + + /** + * An enum containing [Field]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Field] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + PRICE_ID, + ITEM_ID, + PRICE_TYPE, + CURRENCY, + PRICING_UNIT_ID, + /** + * An enum member indicating that [Field] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + PRICE_ID -> Value.PRICE_ID + ITEM_ID -> Value.ITEM_ID + PRICE_TYPE -> Value.PRICE_TYPE + CURRENCY -> Value.CURRENCY + PRICING_UNIT_ID -> Value.PRICING_UNIT_ID + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + PRICE_ID -> Known.PRICE_ID + ITEM_ID -> Known.ITEM_ID + PRICE_TYPE -> Known.PRICE_TYPE + CURRENCY -> Known.CURRENCY + PRICING_UNIT_ID -> Known.PRICING_UNIT_ID + else -> throw OrbInvalidDataException("Unknown Field: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Field = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Field && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Should prices that match the filter be included or excluded. */ + class Operator @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val INCLUDES = of("includes") + + val EXCLUDES = of("excludes") + + fun of(value: String) = Operator(JsonField.of(value)) + } + + /** An enum containing [Operator]'s known values. */ + enum class Known { + INCLUDES, + EXCLUDES, + } + + /** + * An enum containing [Operator]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Operator] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + INCLUDES, + EXCLUDES, + /** + * An enum member indicating that [Operator] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + INCLUDES -> Value.INCLUDES + EXCLUDES -> Value.EXCLUDES + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + INCLUDES -> Known.INCLUDES + EXCLUDES -> Known.EXCLUDES + else -> throw OrbInvalidDataException("Unknown Operator: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Operator = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Operator && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Filter && + field == other.field && + operator == other.operator && + values == other.values && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(field, operator, values, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Filter{field=$field, operator=$operator, values=$values, additionalProperties=$additionalProperties}" + } + /** If set, only prices of the specified type will have the adjustment applied. */ class PriceType @JsonCreator private constructor(private val value: JsonField) : Enum { diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewUsageDiscount.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewUsageDiscount.kt index 09d595afa..0d01c188f 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewUsageDiscount.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewUsageDiscount.kt @@ -27,7 +27,7 @@ private constructor( private val appliesToItemIds: JsonField>, private val appliesToPriceIds: JsonField>, private val currency: JsonField, - private val filters: JsonField>, + private val filters: JsonField>, private val isInvoiceLevel: JsonField, private val priceType: JsonField, private val additionalProperties: MutableMap, @@ -53,7 +53,7 @@ private constructor( @JsonProperty("currency") @ExcludeMissing currency: JsonField = JsonMissing.of(), @JsonProperty("filters") @ExcludeMissing - filters: JsonField> = JsonMissing.of(), + filters: JsonField> = JsonMissing.of(), @JsonProperty("is_invoice_level") @ExcludeMissing isInvoiceLevel: JsonField = JsonMissing.of(), @@ -123,7 +123,7 @@ private constructor( * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server * responded with an unexpected value). */ - fun filters(): List? = filters.getNullable("filters") + fun filters(): List? = filters.getNullable("filters") /** * When false, this adjustment will be applied to a single price. Otherwise, it will be applied @@ -201,9 +201,7 @@ private constructor( * * Unlike [filters], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("filters") - @ExcludeMissing - fun _filters(): JsonField> = filters + @JsonProperty("filters") @ExcludeMissing fun _filters(): JsonField> = filters /** * Returns the raw JSON value of [isInvoiceLevel]. @@ -256,7 +254,7 @@ private constructor( private var appliesToItemIds: JsonField>? = null private var appliesToPriceIds: JsonField>? = null private var currency: JsonField = JsonMissing.of() - private var filters: JsonField>? = null + private var filters: JsonField>? = null private var isInvoiceLevel: JsonField = JsonMissing.of() private var priceType: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -382,25 +380,25 @@ private constructor( fun currency(currency: JsonField) = apply { this.currency = currency } /** A list of filters that determine which prices this adjustment will apply to. */ - fun filters(filters: List?) = filters(JsonField.ofNullable(filters)) + fun filters(filters: List?) = filters(JsonField.ofNullable(filters)) /** * Sets [Builder.filters] to an arbitrary JSON value. * - * You should usually call [Builder.filters] with a well-typed `List` - * value instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. + * You should usually call [Builder.filters] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. */ - fun filters(filters: JsonField>) = apply { + fun filters(filters: JsonField>) = apply { this.filters = filters.map { it.toMutableList() } } /** - * Adds a single [TransformPriceFilter] to [filters]. + * Adds a single [Filter] to [filters]. * * @throws IllegalStateException if the field was previously set to a non-list. */ - fun addFilter(filter: TransformPriceFilter) = apply { + fun addFilter(filter: Filter) = apply { filters = (filters ?: JsonField.of(mutableListOf())).also { checkKnown("filters", it).add(filter) @@ -767,6 +765,534 @@ private constructor( override fun toString() = value.toString() } + class Filter + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val field: JsonField, + private val operator: JsonField, + private val values: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("field") @ExcludeMissing field: JsonField = JsonMissing.of(), + @JsonProperty("operator") + @ExcludeMissing + operator: JsonField = JsonMissing.of(), + @JsonProperty("values") + @ExcludeMissing + values: JsonField> = JsonMissing.of(), + ) : this(field, operator, values, mutableMapOf()) + + /** + * The property of the price to filter on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun field(): Field = field.getRequired("field") + + /** + * Should prices that match the filter be included or excluded. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun operator(): Operator = operator.getRequired("operator") + + /** + * The IDs or values that match this filter. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun values(): List = values.getRequired("values") + + /** + * Returns the raw JSON value of [field]. + * + * Unlike [field], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("field") @ExcludeMissing fun _field(): JsonField = field + + /** + * Returns the raw JSON value of [operator]. + * + * Unlike [operator], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("operator") @ExcludeMissing fun _operator(): JsonField = operator + + /** + * Returns the raw JSON value of [values]. + * + * Unlike [values], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("values") @ExcludeMissing fun _values(): JsonField> = values + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Filter]. + * + * The following fields are required: + * ```kotlin + * .field() + * .operator() + * .values() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Filter]. */ + class Builder internal constructor() { + + private var field: JsonField? = null + private var operator: JsonField? = null + private var values: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(filter: Filter) = apply { + field = filter.field + operator = filter.operator + values = filter.values.map { it.toMutableList() } + additionalProperties = filter.additionalProperties.toMutableMap() + } + + /** The property of the price to filter on. */ + fun field(field: Field) = field(JsonField.of(field)) + + /** + * Sets [Builder.field] to an arbitrary JSON value. + * + * You should usually call [Builder.field] with a well-typed [Field] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun field(field: JsonField) = apply { this.field = field } + + /** Should prices that match the filter be included or excluded. */ + fun operator(operator: Operator) = operator(JsonField.of(operator)) + + /** + * Sets [Builder.operator] to an arbitrary JSON value. + * + * You should usually call [Builder.operator] with a well-typed [Operator] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun operator(operator: JsonField) = apply { this.operator = operator } + + /** The IDs or values that match this filter. */ + fun values(values: List) = values(JsonField.of(values)) + + /** + * Sets [Builder.values] to an arbitrary JSON value. + * + * You should usually call [Builder.values] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun values(values: JsonField>) = apply { + this.values = values.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [values]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addValue(value: String) = apply { + values = + (values ?: JsonField.of(mutableListOf())).also { + checkKnown("values", it).add(value) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Filter]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .field() + * .operator() + * .values() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Filter = + Filter( + checkRequired("field", field), + checkRequired("operator", operator), + checkRequired("values", values).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Filter = apply { + if (validated) { + return@apply + } + + field().validate() + operator().validate() + values() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (field.asKnown()?.validity() ?: 0) + + (operator.asKnown()?.validity() ?: 0) + + (values.asKnown()?.size ?: 0) + + /** The property of the price to filter on. */ + class Field @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val PRICE_ID = of("price_id") + + val ITEM_ID = of("item_id") + + val PRICE_TYPE = of("price_type") + + val CURRENCY = of("currency") + + val PRICING_UNIT_ID = of("pricing_unit_id") + + fun of(value: String) = Field(JsonField.of(value)) + } + + /** An enum containing [Field]'s known values. */ + enum class Known { + PRICE_ID, + ITEM_ID, + PRICE_TYPE, + CURRENCY, + PRICING_UNIT_ID, + } + + /** + * An enum containing [Field]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Field] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + PRICE_ID, + ITEM_ID, + PRICE_TYPE, + CURRENCY, + PRICING_UNIT_ID, + /** + * An enum member indicating that [Field] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + PRICE_ID -> Value.PRICE_ID + ITEM_ID -> Value.ITEM_ID + PRICE_TYPE -> Value.PRICE_TYPE + CURRENCY -> Value.CURRENCY + PRICING_UNIT_ID -> Value.PRICING_UNIT_ID + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + PRICE_ID -> Known.PRICE_ID + ITEM_ID -> Known.ITEM_ID + PRICE_TYPE -> Known.PRICE_TYPE + CURRENCY -> Known.CURRENCY + PRICING_UNIT_ID -> Known.PRICING_UNIT_ID + else -> throw OrbInvalidDataException("Unknown Field: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Field = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Field && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Should prices that match the filter be included or excluded. */ + class Operator @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val INCLUDES = of("includes") + + val EXCLUDES = of("excludes") + + fun of(value: String) = Operator(JsonField.of(value)) + } + + /** An enum containing [Operator]'s known values. */ + enum class Known { + INCLUDES, + EXCLUDES, + } + + /** + * An enum containing [Operator]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Operator] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + INCLUDES, + EXCLUDES, + /** + * An enum member indicating that [Operator] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + INCLUDES -> Value.INCLUDES + EXCLUDES -> Value.EXCLUDES + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + INCLUDES -> Known.INCLUDES + EXCLUDES -> Known.EXCLUDES + else -> throw OrbInvalidDataException("Unknown Operator: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Operator = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Operator && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Filter && + field == other.field && + operator == other.operator && + values == other.values && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(field, operator, values, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Filter{field=$field, operator=$operator, values=$values, additionalProperties=$additionalProperties}" + } + /** If set, only prices of the specified type will have the adjustment applied. */ class PriceType @JsonCreator private constructor(private val value: JsonField) : Enum { diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PercentageDiscount.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PercentageDiscount.kt index b423b3db6..89aab9b6c 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PercentageDiscount.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PercentageDiscount.kt @@ -24,7 +24,7 @@ private constructor( private val discountType: JsonField, private val percentageDiscount: JsonField, private val appliesToPriceIds: JsonField>, - private val filters: JsonField>, + private val filters: JsonField>, private val reason: JsonField, private val additionalProperties: MutableMap, ) { @@ -42,7 +42,7 @@ private constructor( appliesToPriceIds: JsonField> = JsonMissing.of(), @JsonProperty("filters") @ExcludeMissing - filters: JsonField> = JsonMissing.of(), + filters: JsonField> = JsonMissing.of(), @JsonProperty("reason") @ExcludeMissing reason: JsonField = JsonMissing.of(), ) : this(discountType, percentageDiscount, appliesToPriceIds, filters, reason, mutableMapOf()) @@ -75,7 +75,7 @@ private constructor( * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server * responded with an unexpected value). */ - fun filters(): List? = filters.getNullable("filters") + fun filters(): List? = filters.getNullable("filters") /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server @@ -117,9 +117,7 @@ private constructor( * * Unlike [filters], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("filters") - @ExcludeMissing - fun _filters(): JsonField> = filters + @JsonProperty("filters") @ExcludeMissing fun _filters(): JsonField> = filters /** * Returns the raw JSON value of [reason]. @@ -160,7 +158,7 @@ private constructor( private var discountType: JsonField? = null private var percentageDiscount: JsonField? = null private var appliesToPriceIds: JsonField>? = null - private var filters: JsonField>? = null + private var filters: JsonField>? = null private var reason: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -232,25 +230,25 @@ private constructor( } /** The filters that determine which prices to apply this discount to. */ - fun filters(filters: List?) = filters(JsonField.ofNullable(filters)) + fun filters(filters: List?) = filters(JsonField.ofNullable(filters)) /** * Sets [Builder.filters] to an arbitrary JSON value. * - * You should usually call [Builder.filters] with a well-typed `List` - * value instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. + * You should usually call [Builder.filters] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. */ - fun filters(filters: JsonField>) = apply { + fun filters(filters: JsonField>) = apply { this.filters = filters.map { it.toMutableList() } } /** - * Adds a single [TransformPriceFilter] to [filters]. + * Adds a single [Filter] to [filters]. * * @throws IllegalStateException if the field was previously set to a non-list. */ - fun addFilter(filter: TransformPriceFilter) = apply { + fun addFilter(filter: Filter) = apply { filters = (filters ?: JsonField.of(mutableListOf())).also { checkKnown("filters", it).add(filter) @@ -466,6 +464,534 @@ private constructor( override fun toString() = value.toString() } + class Filter + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val field: JsonField, + private val operator: JsonField, + private val values: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("field") @ExcludeMissing field: JsonField = JsonMissing.of(), + @JsonProperty("operator") + @ExcludeMissing + operator: JsonField = JsonMissing.of(), + @JsonProperty("values") + @ExcludeMissing + values: JsonField> = JsonMissing.of(), + ) : this(field, operator, values, mutableMapOf()) + + /** + * The property of the price to filter on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun field(): Field = field.getRequired("field") + + /** + * Should prices that match the filter be included or excluded. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun operator(): Operator = operator.getRequired("operator") + + /** + * The IDs or values that match this filter. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun values(): List = values.getRequired("values") + + /** + * Returns the raw JSON value of [field]. + * + * Unlike [field], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("field") @ExcludeMissing fun _field(): JsonField = field + + /** + * Returns the raw JSON value of [operator]. + * + * Unlike [operator], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("operator") @ExcludeMissing fun _operator(): JsonField = operator + + /** + * Returns the raw JSON value of [values]. + * + * Unlike [values], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("values") @ExcludeMissing fun _values(): JsonField> = values + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Filter]. + * + * The following fields are required: + * ```kotlin + * .field() + * .operator() + * .values() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Filter]. */ + class Builder internal constructor() { + + private var field: JsonField? = null + private var operator: JsonField? = null + private var values: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(filter: Filter) = apply { + field = filter.field + operator = filter.operator + values = filter.values.map { it.toMutableList() } + additionalProperties = filter.additionalProperties.toMutableMap() + } + + /** The property of the price to filter on. */ + fun field(field: Field) = field(JsonField.of(field)) + + /** + * Sets [Builder.field] to an arbitrary JSON value. + * + * You should usually call [Builder.field] with a well-typed [Field] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun field(field: JsonField) = apply { this.field = field } + + /** Should prices that match the filter be included or excluded. */ + fun operator(operator: Operator) = operator(JsonField.of(operator)) + + /** + * Sets [Builder.operator] to an arbitrary JSON value. + * + * You should usually call [Builder.operator] with a well-typed [Operator] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun operator(operator: JsonField) = apply { this.operator = operator } + + /** The IDs or values that match this filter. */ + fun values(values: List) = values(JsonField.of(values)) + + /** + * Sets [Builder.values] to an arbitrary JSON value. + * + * You should usually call [Builder.values] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun values(values: JsonField>) = apply { + this.values = values.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [values]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addValue(value: String) = apply { + values = + (values ?: JsonField.of(mutableListOf())).also { + checkKnown("values", it).add(value) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Filter]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .field() + * .operator() + * .values() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Filter = + Filter( + checkRequired("field", field), + checkRequired("operator", operator), + checkRequired("values", values).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Filter = apply { + if (validated) { + return@apply + } + + field().validate() + operator().validate() + values() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (field.asKnown()?.validity() ?: 0) + + (operator.asKnown()?.validity() ?: 0) + + (values.asKnown()?.size ?: 0) + + /** The property of the price to filter on. */ + class Field @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val PRICE_ID = of("price_id") + + val ITEM_ID = of("item_id") + + val PRICE_TYPE = of("price_type") + + val CURRENCY = of("currency") + + val PRICING_UNIT_ID = of("pricing_unit_id") + + fun of(value: String) = Field(JsonField.of(value)) + } + + /** An enum containing [Field]'s known values. */ + enum class Known { + PRICE_ID, + ITEM_ID, + PRICE_TYPE, + CURRENCY, + PRICING_UNIT_ID, + } + + /** + * An enum containing [Field]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Field] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + PRICE_ID, + ITEM_ID, + PRICE_TYPE, + CURRENCY, + PRICING_UNIT_ID, + /** + * An enum member indicating that [Field] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + PRICE_ID -> Value.PRICE_ID + ITEM_ID -> Value.ITEM_ID + PRICE_TYPE -> Value.PRICE_TYPE + CURRENCY -> Value.CURRENCY + PRICING_UNIT_ID -> Value.PRICING_UNIT_ID + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + PRICE_ID -> Known.PRICE_ID + ITEM_ID -> Known.ITEM_ID + PRICE_TYPE -> Known.PRICE_TYPE + CURRENCY -> Known.CURRENCY + PRICING_UNIT_ID -> Known.PRICING_UNIT_ID + else -> throw OrbInvalidDataException("Unknown Field: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Field = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Field && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Should prices that match the filter be included or excluded. */ + class Operator @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val INCLUDES = of("includes") + + val EXCLUDES = of("excludes") + + fun of(value: String) = Operator(JsonField.of(value)) + } + + /** An enum containing [Operator]'s known values. */ + enum class Known { + INCLUDES, + EXCLUDES, + } + + /** + * An enum containing [Operator]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Operator] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + INCLUDES, + EXCLUDES, + /** + * An enum member indicating that [Operator] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + INCLUDES -> Value.INCLUDES + EXCLUDES -> Value.EXCLUDES + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + INCLUDES -> Known.INCLUDES + EXCLUDES -> Known.EXCLUDES + else -> throw OrbInvalidDataException("Unknown Operator: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Operator = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Operator && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Filter && + field == other.field && + operator == other.operator && + values == other.values && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(field, operator, values, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Filter{field=$field, operator=$operator, values=$values, additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PercentageDiscountInterval.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PercentageDiscountInterval.kt index c56edae4e..4a488d7a0 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PercentageDiscountInterval.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PercentageDiscountInterval.kt @@ -25,7 +25,7 @@ private constructor( private val appliesToPriceIntervalIds: JsonField>, private val discountType: JsonField, private val endDate: JsonField, - private val filters: JsonField>, + private val filters: JsonField>, private val percentageDiscount: JsonField, private val startDate: JsonField, private val additionalProperties: MutableMap, @@ -44,7 +44,7 @@ private constructor( endDate: JsonField = JsonMissing.of(), @JsonProperty("filters") @ExcludeMissing - filters: JsonField> = JsonMissing.of(), + filters: JsonField> = JsonMissing.of(), @JsonProperty("percentage_discount") @ExcludeMissing percentageDiscount: JsonField = JsonMissing.of(), @@ -90,7 +90,7 @@ private constructor( * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ - fun filters(): List = filters.getRequired("filters") + fun filters(): List = filters.getRequired("filters") /** * Only available if discount_type is `percentage`.This is a number between 0 and 1. @@ -139,9 +139,7 @@ private constructor( * * Unlike [filters], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("filters") - @ExcludeMissing - fun _filters(): JsonField> = filters + @JsonProperty("filters") @ExcludeMissing fun _filters(): JsonField> = filters /** * Returns the raw JSON value of [percentageDiscount]. @@ -198,7 +196,7 @@ private constructor( private var appliesToPriceIntervalIds: JsonField>? = null private var discountType: JsonField? = null private var endDate: JsonField? = null - private var filters: JsonField>? = null + private var filters: JsonField>? = null private var percentageDiscount: JsonField? = null private var startDate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -267,25 +265,25 @@ private constructor( fun endDate(endDate: JsonField) = apply { this.endDate = endDate } /** The filters that determine which prices this discount interval applies to. */ - fun filters(filters: List) = filters(JsonField.of(filters)) + fun filters(filters: List) = filters(JsonField.of(filters)) /** * Sets [Builder.filters] to an arbitrary JSON value. * - * You should usually call [Builder.filters] with a well-typed `List` - * value instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. + * You should usually call [Builder.filters] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. */ - fun filters(filters: JsonField>) = apply { + fun filters(filters: JsonField>) = apply { this.filters = filters.map { it.toMutableList() } } /** - * Adds a single [TransformPriceFilter] to [filters]. + * Adds a single [Filter] to [filters]. * * @throws IllegalStateException if the field was previously set to a non-list. */ - fun addFilter(filter: TransformPriceFilter) = apply { + fun addFilter(filter: Filter) = apply { filters = (filters ?: JsonField.of(mutableListOf())).also { checkKnown("filters", it).add(filter) @@ -527,6 +525,534 @@ private constructor( override fun toString() = value.toString() } + class Filter + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val field: JsonField, + private val operator: JsonField, + private val values: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("field") @ExcludeMissing field: JsonField = JsonMissing.of(), + @JsonProperty("operator") + @ExcludeMissing + operator: JsonField = JsonMissing.of(), + @JsonProperty("values") + @ExcludeMissing + values: JsonField> = JsonMissing.of(), + ) : this(field, operator, values, mutableMapOf()) + + /** + * The property of the price to filter on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun field(): Field = field.getRequired("field") + + /** + * Should prices that match the filter be included or excluded. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun operator(): Operator = operator.getRequired("operator") + + /** + * The IDs or values that match this filter. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun values(): List = values.getRequired("values") + + /** + * Returns the raw JSON value of [field]. + * + * Unlike [field], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("field") @ExcludeMissing fun _field(): JsonField = field + + /** + * Returns the raw JSON value of [operator]. + * + * Unlike [operator], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("operator") @ExcludeMissing fun _operator(): JsonField = operator + + /** + * Returns the raw JSON value of [values]. + * + * Unlike [values], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("values") @ExcludeMissing fun _values(): JsonField> = values + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Filter]. + * + * The following fields are required: + * ```kotlin + * .field() + * .operator() + * .values() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Filter]. */ + class Builder internal constructor() { + + private var field: JsonField? = null + private var operator: JsonField? = null + private var values: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(filter: Filter) = apply { + field = filter.field + operator = filter.operator + values = filter.values.map { it.toMutableList() } + additionalProperties = filter.additionalProperties.toMutableMap() + } + + /** The property of the price to filter on. */ + fun field(field: Field) = field(JsonField.of(field)) + + /** + * Sets [Builder.field] to an arbitrary JSON value. + * + * You should usually call [Builder.field] with a well-typed [Field] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun field(field: JsonField) = apply { this.field = field } + + /** Should prices that match the filter be included or excluded. */ + fun operator(operator: Operator) = operator(JsonField.of(operator)) + + /** + * Sets [Builder.operator] to an arbitrary JSON value. + * + * You should usually call [Builder.operator] with a well-typed [Operator] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun operator(operator: JsonField) = apply { this.operator = operator } + + /** The IDs or values that match this filter. */ + fun values(values: List) = values(JsonField.of(values)) + + /** + * Sets [Builder.values] to an arbitrary JSON value. + * + * You should usually call [Builder.values] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun values(values: JsonField>) = apply { + this.values = values.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [values]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addValue(value: String) = apply { + values = + (values ?: JsonField.of(mutableListOf())).also { + checkKnown("values", it).add(value) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Filter]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .field() + * .operator() + * .values() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Filter = + Filter( + checkRequired("field", field), + checkRequired("operator", operator), + checkRequired("values", values).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Filter = apply { + if (validated) { + return@apply + } + + field().validate() + operator().validate() + values() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (field.asKnown()?.validity() ?: 0) + + (operator.asKnown()?.validity() ?: 0) + + (values.asKnown()?.size ?: 0) + + /** The property of the price to filter on. */ + class Field @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val PRICE_ID = of("price_id") + + val ITEM_ID = of("item_id") + + val PRICE_TYPE = of("price_type") + + val CURRENCY = of("currency") + + val PRICING_UNIT_ID = of("pricing_unit_id") + + fun of(value: String) = Field(JsonField.of(value)) + } + + /** An enum containing [Field]'s known values. */ + enum class Known { + PRICE_ID, + ITEM_ID, + PRICE_TYPE, + CURRENCY, + PRICING_UNIT_ID, + } + + /** + * An enum containing [Field]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Field] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + PRICE_ID, + ITEM_ID, + PRICE_TYPE, + CURRENCY, + PRICING_UNIT_ID, + /** + * An enum member indicating that [Field] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + PRICE_ID -> Value.PRICE_ID + ITEM_ID -> Value.ITEM_ID + PRICE_TYPE -> Value.PRICE_TYPE + CURRENCY -> Value.CURRENCY + PRICING_UNIT_ID -> Value.PRICING_UNIT_ID + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + PRICE_ID -> Known.PRICE_ID + ITEM_ID -> Known.ITEM_ID + PRICE_TYPE -> Known.PRICE_TYPE + CURRENCY -> Known.CURRENCY + PRICING_UNIT_ID -> Known.PRICING_UNIT_ID + else -> throw OrbInvalidDataException("Unknown Field: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Field = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Field && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Should prices that match the filter be included or excluded. */ + class Operator @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val INCLUDES = of("includes") + + val EXCLUDES = of("excludes") + + fun of(value: String) = Operator(JsonField.of(value)) + } + + /** An enum containing [Operator]'s known values. */ + enum class Known { + INCLUDES, + EXCLUDES, + } + + /** + * An enum containing [Operator]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Operator] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + INCLUDES, + EXCLUDES, + /** + * An enum member indicating that [Operator] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + INCLUDES -> Value.INCLUDES + EXCLUDES -> Value.EXCLUDES + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + INCLUDES -> Known.INCLUDES + EXCLUDES -> Known.EXCLUDES + else -> throw OrbInvalidDataException("Unknown Operator: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Operator = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Operator && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Filter && + field == other.field && + operator == other.operator && + values == other.values && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(field, operator, values, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Filter{field=$field, operator=$operator, values=$values, additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanCreateParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanCreateParams.kt index 569b4f7f2..1cea98d1f 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanCreateParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanCreateParams.kt @@ -10949,6 +10949,7 @@ private constructor( @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val unitRatingKey: JsonField, + private val defaultUnitRate: JsonField, private val groupingKey: JsonField, private val additionalProperties: MutableMap, ) { @@ -10958,10 +10959,13 @@ private constructor( @JsonProperty("unit_rating_key") @ExcludeMissing unitRatingKey: JsonField = JsonMissing.of(), + @JsonProperty("default_unit_rate") + @ExcludeMissing + defaultUnitRate: JsonField = JsonMissing.of(), @JsonProperty("grouping_key") @ExcludeMissing groupingKey: JsonField = JsonMissing.of(), - ) : this(unitRatingKey, groupingKey, mutableMapOf()) + ) : this(unitRatingKey, defaultUnitRate, groupingKey, mutableMapOf()) /** * The key in the event data to extract the unit rate from. @@ -10972,6 +10976,17 @@ private constructor( */ fun unitRatingKey(): String = unitRatingKey.getRequired("unit_rating_key") + /** + * If provided, this amount will be used as the unit rate when an event does not + * have a value for the `unit_rating_key`. If not provided, events missing a + * unit rate will be ignored. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun defaultUnitRate(): String? = + defaultUnitRate.getNullable("default_unit_rate") + /** * An optional key in the event data to group by (e.g., event ID). All events * will also be grouped by their unit rate. @@ -10991,6 +11006,16 @@ private constructor( @ExcludeMissing fun _unitRatingKey(): JsonField = unitRatingKey + /** + * Returns the raw JSON value of [defaultUnitRate]. + * + * Unlike [defaultUnitRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("default_unit_rate") + @ExcludeMissing + fun _defaultUnitRate(): JsonField = defaultUnitRate + /** * Returns the raw JSON value of [groupingKey]. * @@ -11031,12 +11056,14 @@ private constructor( class Builder internal constructor() { private var unitRatingKey: JsonField? = null + private var defaultUnitRate: JsonField = JsonMissing.of() private var groupingKey: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() internal fun from(eventOutputConfig: EventOutputConfig) = apply { unitRatingKey = eventOutputConfig.unitRatingKey + defaultUnitRate = eventOutputConfig.defaultUnitRate groupingKey = eventOutputConfig.groupingKey additionalProperties = eventOutputConfig.additionalProperties.toMutableMap() @@ -11057,6 +11084,25 @@ private constructor( this.unitRatingKey = unitRatingKey } + /** + * If provided, this amount will be used as the unit rate when an event does + * not have a value for the `unit_rating_key`. If not provided, events + * missing a unit rate will be ignored. + */ + fun defaultUnitRate(defaultUnitRate: String?) = + defaultUnitRate(JsonField.ofNullable(defaultUnitRate)) + + /** + * Sets [Builder.defaultUnitRate] to an arbitrary JSON value. + * + * You should usually call [Builder.defaultUnitRate] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun defaultUnitRate(defaultUnitRate: JsonField) = apply { + this.defaultUnitRate = defaultUnitRate + } + /** * An optional key in the event data to group by (e.g., event ID). All * events will also be grouped by their unit rate. @@ -11112,6 +11158,7 @@ private constructor( fun build(): EventOutputConfig = EventOutputConfig( checkRequired("unitRatingKey", unitRatingKey), + defaultUnitRate, groupingKey, additionalProperties.toMutableMap(), ) @@ -11125,6 +11172,7 @@ private constructor( } unitRatingKey() + defaultUnitRate() groupingKey() validated = true } @@ -11145,6 +11193,7 @@ private constructor( */ internal fun validity(): Int = (if (unitRatingKey.asKnown() == null) 0 else 1) + + (if (defaultUnitRate.asKnown() == null) 0 else 1) + (if (groupingKey.asKnown() == null) 0 else 1) override fun equals(other: Any?): Boolean { @@ -11154,18 +11203,24 @@ private constructor( return other is EventOutputConfig && unitRatingKey == other.unitRatingKey && + defaultUnitRate == other.defaultUnitRate && groupingKey == other.groupingKey && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(unitRatingKey, groupingKey, additionalProperties) + Objects.hash( + unitRatingKey, + defaultUnitRate, + groupingKey, + additionalProperties, + ) } override fun hashCode(): Int = hashCode override fun toString() = - "EventOutputConfig{unitRatingKey=$unitRatingKey, groupingKey=$groupingKey, additionalProperties=$additionalProperties}" + "EventOutputConfig{unitRatingKey=$unitRatingKey, defaultUnitRate=$defaultUnitRate, groupingKey=$groupingKey, additionalProperties=$additionalProperties}" } /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanPhaseAmountDiscountAdjustment.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanPhaseAmountDiscountAdjustment.kt index 511242156..7b168d056 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanPhaseAmountDiscountAdjustment.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanPhaseAmountDiscountAdjustment.kt @@ -25,7 +25,7 @@ private constructor( private val adjustmentType: JsonField, private val amountDiscount: JsonField, private val appliesToPriceIds: JsonField>, - private val filters: JsonField>, + private val filters: JsonField>, private val isInvoiceLevel: JsonField, private val planPhaseOrder: JsonField, private val reason: JsonField, @@ -47,7 +47,7 @@ private constructor( appliesToPriceIds: JsonField> = JsonMissing.of(), @JsonProperty("filters") @ExcludeMissing - filters: JsonField> = JsonMissing.of(), + filters: JsonField> = JsonMissing.of(), @JsonProperty("is_invoice_level") @ExcludeMissing isInvoiceLevel: JsonField = JsonMissing.of(), @@ -107,7 +107,7 @@ private constructor( * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ - fun filters(): List = filters.getRequired("filters") + fun filters(): List = filters.getRequired("filters") /** * True for adjustments that apply to an entire invoice, false for adjustments that apply to @@ -184,9 +184,7 @@ private constructor( * * Unlike [filters], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("filters") - @ExcludeMissing - fun _filters(): JsonField> = filters + @JsonProperty("filters") @ExcludeMissing fun _filters(): JsonField> = filters /** * Returns the raw JSON value of [isInvoiceLevel]. @@ -264,7 +262,7 @@ private constructor( private var adjustmentType: JsonField? = null private var amountDiscount: JsonField? = null private var appliesToPriceIds: JsonField>? = null - private var filters: JsonField>? = null + private var filters: JsonField>? = null private var isInvoiceLevel: JsonField? = null private var planPhaseOrder: JsonField? = null private var reason: JsonField? = null @@ -359,25 +357,25 @@ private constructor( } /** The filters that determine which prices to apply this adjustment to. */ - fun filters(filters: List) = filters(JsonField.of(filters)) + fun filters(filters: List) = filters(JsonField.of(filters)) /** * Sets [Builder.filters] to an arbitrary JSON value. * - * You should usually call [Builder.filters] with a well-typed `List` - * value instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. + * You should usually call [Builder.filters] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. */ - fun filters(filters: JsonField>) = apply { + fun filters(filters: JsonField>) = apply { this.filters = filters.map { it.toMutableList() } } /** - * Adds a single [TransformPriceFilter] to [filters]. + * Adds a single [Filter] to [filters]. * * @throws IllegalStateException if the field was previously set to a non-list. */ - fun addFilter(filter: TransformPriceFilter) = apply { + fun addFilter(filter: Filter) = apply { filters = (filters ?: JsonField.of(mutableListOf())).also { checkKnown("filters", it).add(filter) @@ -671,6 +669,534 @@ private constructor( override fun toString() = value.toString() } + class Filter + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val field: JsonField, + private val operator: JsonField, + private val values: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("field") @ExcludeMissing field: JsonField = JsonMissing.of(), + @JsonProperty("operator") + @ExcludeMissing + operator: JsonField = JsonMissing.of(), + @JsonProperty("values") + @ExcludeMissing + values: JsonField> = JsonMissing.of(), + ) : this(field, operator, values, mutableMapOf()) + + /** + * The property of the price to filter on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun field(): Field = field.getRequired("field") + + /** + * Should prices that match the filter be included or excluded. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun operator(): Operator = operator.getRequired("operator") + + /** + * The IDs or values that match this filter. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun values(): List = values.getRequired("values") + + /** + * Returns the raw JSON value of [field]. + * + * Unlike [field], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("field") @ExcludeMissing fun _field(): JsonField = field + + /** + * Returns the raw JSON value of [operator]. + * + * Unlike [operator], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("operator") @ExcludeMissing fun _operator(): JsonField = operator + + /** + * Returns the raw JSON value of [values]. + * + * Unlike [values], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("values") @ExcludeMissing fun _values(): JsonField> = values + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Filter]. + * + * The following fields are required: + * ```kotlin + * .field() + * .operator() + * .values() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Filter]. */ + class Builder internal constructor() { + + private var field: JsonField? = null + private var operator: JsonField? = null + private var values: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(filter: Filter) = apply { + field = filter.field + operator = filter.operator + values = filter.values.map { it.toMutableList() } + additionalProperties = filter.additionalProperties.toMutableMap() + } + + /** The property of the price to filter on. */ + fun field(field: Field) = field(JsonField.of(field)) + + /** + * Sets [Builder.field] to an arbitrary JSON value. + * + * You should usually call [Builder.field] with a well-typed [Field] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun field(field: JsonField) = apply { this.field = field } + + /** Should prices that match the filter be included or excluded. */ + fun operator(operator: Operator) = operator(JsonField.of(operator)) + + /** + * Sets [Builder.operator] to an arbitrary JSON value. + * + * You should usually call [Builder.operator] with a well-typed [Operator] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun operator(operator: JsonField) = apply { this.operator = operator } + + /** The IDs or values that match this filter. */ + fun values(values: List) = values(JsonField.of(values)) + + /** + * Sets [Builder.values] to an arbitrary JSON value. + * + * You should usually call [Builder.values] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun values(values: JsonField>) = apply { + this.values = values.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [values]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addValue(value: String) = apply { + values = + (values ?: JsonField.of(mutableListOf())).also { + checkKnown("values", it).add(value) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Filter]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .field() + * .operator() + * .values() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Filter = + Filter( + checkRequired("field", field), + checkRequired("operator", operator), + checkRequired("values", values).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Filter = apply { + if (validated) { + return@apply + } + + field().validate() + operator().validate() + values() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (field.asKnown()?.validity() ?: 0) + + (operator.asKnown()?.validity() ?: 0) + + (values.asKnown()?.size ?: 0) + + /** The property of the price to filter on. */ + class Field @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val PRICE_ID = of("price_id") + + val ITEM_ID = of("item_id") + + val PRICE_TYPE = of("price_type") + + val CURRENCY = of("currency") + + val PRICING_UNIT_ID = of("pricing_unit_id") + + fun of(value: String) = Field(JsonField.of(value)) + } + + /** An enum containing [Field]'s known values. */ + enum class Known { + PRICE_ID, + ITEM_ID, + PRICE_TYPE, + CURRENCY, + PRICING_UNIT_ID, + } + + /** + * An enum containing [Field]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Field] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + PRICE_ID, + ITEM_ID, + PRICE_TYPE, + CURRENCY, + PRICING_UNIT_ID, + /** + * An enum member indicating that [Field] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + PRICE_ID -> Value.PRICE_ID + ITEM_ID -> Value.ITEM_ID + PRICE_TYPE -> Value.PRICE_TYPE + CURRENCY -> Value.CURRENCY + PRICING_UNIT_ID -> Value.PRICING_UNIT_ID + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + PRICE_ID -> Known.PRICE_ID + ITEM_ID -> Known.ITEM_ID + PRICE_TYPE -> Known.PRICE_TYPE + CURRENCY -> Known.CURRENCY + PRICING_UNIT_ID -> Known.PRICING_UNIT_ID + else -> throw OrbInvalidDataException("Unknown Field: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Field = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Field && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Should prices that match the filter be included or excluded. */ + class Operator @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val INCLUDES = of("includes") + + val EXCLUDES = of("excludes") + + fun of(value: String) = Operator(JsonField.of(value)) + } + + /** An enum containing [Operator]'s known values. */ + enum class Known { + INCLUDES, + EXCLUDES, + } + + /** + * An enum containing [Operator]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Operator] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + INCLUDES, + EXCLUDES, + /** + * An enum member indicating that [Operator] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + INCLUDES -> Value.INCLUDES + EXCLUDES -> Value.EXCLUDES + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + INCLUDES -> Known.INCLUDES + EXCLUDES -> Known.EXCLUDES + else -> throw OrbInvalidDataException("Unknown Operator: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Operator = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Operator && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Filter && + field == other.field && + operator == other.operator && + values == other.values && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(field, operator, values, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Filter{field=$field, operator=$operator, values=$values, additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanPhaseMaximumAdjustment.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanPhaseMaximumAdjustment.kt index 984d006cb..634c00386 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanPhaseMaximumAdjustment.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanPhaseMaximumAdjustment.kt @@ -24,7 +24,7 @@ private constructor( private val id: JsonField, private val adjustmentType: JsonField, private val appliesToPriceIds: JsonField>, - private val filters: JsonField>, + private val filters: JsonField>, private val isInvoiceLevel: JsonField, private val maximumAmount: JsonField, private val planPhaseOrder: JsonField, @@ -44,7 +44,7 @@ private constructor( appliesToPriceIds: JsonField> = JsonMissing.of(), @JsonProperty("filters") @ExcludeMissing - filters: JsonField> = JsonMissing.of(), + filters: JsonField> = JsonMissing.of(), @JsonProperty("is_invoice_level") @ExcludeMissing isInvoiceLevel: JsonField = JsonMissing.of(), @@ -98,7 +98,7 @@ private constructor( * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ - fun filters(): List = filters.getRequired("filters") + fun filters(): List = filters.getRequired("filters") /** * True for adjustments that apply to an entire invoice, false for adjustments that apply to @@ -175,9 +175,7 @@ private constructor( * * Unlike [filters], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("filters") - @ExcludeMissing - fun _filters(): JsonField> = filters + @JsonProperty("filters") @ExcludeMissing fun _filters(): JsonField> = filters /** * Returns the raw JSON value of [isInvoiceLevel]. @@ -262,7 +260,7 @@ private constructor( private var id: JsonField? = null private var adjustmentType: JsonField? = null private var appliesToPriceIds: JsonField>? = null - private var filters: JsonField>? = null + private var filters: JsonField>? = null private var isInvoiceLevel: JsonField? = null private var maximumAmount: JsonField? = null private var planPhaseOrder: JsonField? = null @@ -339,25 +337,25 @@ private constructor( } /** The filters that determine which prices to apply this adjustment to. */ - fun filters(filters: List) = filters(JsonField.of(filters)) + fun filters(filters: List) = filters(JsonField.of(filters)) /** * Sets [Builder.filters] to an arbitrary JSON value. * - * You should usually call [Builder.filters] with a well-typed `List` - * value instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. + * You should usually call [Builder.filters] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. */ - fun filters(filters: JsonField>) = apply { + fun filters(filters: JsonField>) = apply { this.filters = filters.map { it.toMutableList() } } /** - * Adds a single [TransformPriceFilter] to [filters]. + * Adds a single [Filter] to [filters]. * * @throws IllegalStateException if the field was previously set to a non-list. */ - fun addFilter(filter: TransformPriceFilter) = apply { + fun addFilter(filter: Filter) = apply { filters = (filters ?: JsonField.of(mutableListOf())).also { checkKnown("filters", it).add(filter) @@ -668,6 +666,534 @@ private constructor( override fun toString() = value.toString() } + class Filter + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val field: JsonField, + private val operator: JsonField, + private val values: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("field") @ExcludeMissing field: JsonField = JsonMissing.of(), + @JsonProperty("operator") + @ExcludeMissing + operator: JsonField = JsonMissing.of(), + @JsonProperty("values") + @ExcludeMissing + values: JsonField> = JsonMissing.of(), + ) : this(field, operator, values, mutableMapOf()) + + /** + * The property of the price to filter on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun field(): Field = field.getRequired("field") + + /** + * Should prices that match the filter be included or excluded. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun operator(): Operator = operator.getRequired("operator") + + /** + * The IDs or values that match this filter. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun values(): List = values.getRequired("values") + + /** + * Returns the raw JSON value of [field]. + * + * Unlike [field], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("field") @ExcludeMissing fun _field(): JsonField = field + + /** + * Returns the raw JSON value of [operator]. + * + * Unlike [operator], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("operator") @ExcludeMissing fun _operator(): JsonField = operator + + /** + * Returns the raw JSON value of [values]. + * + * Unlike [values], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("values") @ExcludeMissing fun _values(): JsonField> = values + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Filter]. + * + * The following fields are required: + * ```kotlin + * .field() + * .operator() + * .values() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Filter]. */ + class Builder internal constructor() { + + private var field: JsonField? = null + private var operator: JsonField? = null + private var values: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(filter: Filter) = apply { + field = filter.field + operator = filter.operator + values = filter.values.map { it.toMutableList() } + additionalProperties = filter.additionalProperties.toMutableMap() + } + + /** The property of the price to filter on. */ + fun field(field: Field) = field(JsonField.of(field)) + + /** + * Sets [Builder.field] to an arbitrary JSON value. + * + * You should usually call [Builder.field] with a well-typed [Field] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun field(field: JsonField) = apply { this.field = field } + + /** Should prices that match the filter be included or excluded. */ + fun operator(operator: Operator) = operator(JsonField.of(operator)) + + /** + * Sets [Builder.operator] to an arbitrary JSON value. + * + * You should usually call [Builder.operator] with a well-typed [Operator] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun operator(operator: JsonField) = apply { this.operator = operator } + + /** The IDs or values that match this filter. */ + fun values(values: List) = values(JsonField.of(values)) + + /** + * Sets [Builder.values] to an arbitrary JSON value. + * + * You should usually call [Builder.values] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun values(values: JsonField>) = apply { + this.values = values.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [values]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addValue(value: String) = apply { + values = + (values ?: JsonField.of(mutableListOf())).also { + checkKnown("values", it).add(value) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Filter]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .field() + * .operator() + * .values() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Filter = + Filter( + checkRequired("field", field), + checkRequired("operator", operator), + checkRequired("values", values).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Filter = apply { + if (validated) { + return@apply + } + + field().validate() + operator().validate() + values() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (field.asKnown()?.validity() ?: 0) + + (operator.asKnown()?.validity() ?: 0) + + (values.asKnown()?.size ?: 0) + + /** The property of the price to filter on. */ + class Field @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val PRICE_ID = of("price_id") + + val ITEM_ID = of("item_id") + + val PRICE_TYPE = of("price_type") + + val CURRENCY = of("currency") + + val PRICING_UNIT_ID = of("pricing_unit_id") + + fun of(value: String) = Field(JsonField.of(value)) + } + + /** An enum containing [Field]'s known values. */ + enum class Known { + PRICE_ID, + ITEM_ID, + PRICE_TYPE, + CURRENCY, + PRICING_UNIT_ID, + } + + /** + * An enum containing [Field]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Field] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + PRICE_ID, + ITEM_ID, + PRICE_TYPE, + CURRENCY, + PRICING_UNIT_ID, + /** + * An enum member indicating that [Field] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + PRICE_ID -> Value.PRICE_ID + ITEM_ID -> Value.ITEM_ID + PRICE_TYPE -> Value.PRICE_TYPE + CURRENCY -> Value.CURRENCY + PRICING_UNIT_ID -> Value.PRICING_UNIT_ID + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + PRICE_ID -> Known.PRICE_ID + ITEM_ID -> Known.ITEM_ID + PRICE_TYPE -> Known.PRICE_TYPE + CURRENCY -> Known.CURRENCY + PRICING_UNIT_ID -> Known.PRICING_UNIT_ID + else -> throw OrbInvalidDataException("Unknown Field: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Field = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Field && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Should prices that match the filter be included or excluded. */ + class Operator @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val INCLUDES = of("includes") + + val EXCLUDES = of("excludes") + + fun of(value: String) = Operator(JsonField.of(value)) + } + + /** An enum containing [Operator]'s known values. */ + enum class Known { + INCLUDES, + EXCLUDES, + } + + /** + * An enum containing [Operator]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Operator] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + INCLUDES, + EXCLUDES, + /** + * An enum member indicating that [Operator] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + INCLUDES -> Value.INCLUDES + EXCLUDES -> Value.EXCLUDES + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + INCLUDES -> Known.INCLUDES + EXCLUDES -> Known.EXCLUDES + else -> throw OrbInvalidDataException("Unknown Operator: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Operator = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Operator && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Filter && + field == other.field && + operator == other.operator && + values == other.values && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(field, operator, values, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Filter{field=$field, operator=$operator, values=$values, additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanPhaseMinimumAdjustment.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanPhaseMinimumAdjustment.kt index a2c11586d..b8a20bbe7 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanPhaseMinimumAdjustment.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanPhaseMinimumAdjustment.kt @@ -24,7 +24,7 @@ private constructor( private val id: JsonField, private val adjustmentType: JsonField, private val appliesToPriceIds: JsonField>, - private val filters: JsonField>, + private val filters: JsonField>, private val isInvoiceLevel: JsonField, private val itemId: JsonField, private val minimumAmount: JsonField, @@ -45,7 +45,7 @@ private constructor( appliesToPriceIds: JsonField> = JsonMissing.of(), @JsonProperty("filters") @ExcludeMissing - filters: JsonField> = JsonMissing.of(), + filters: JsonField> = JsonMissing.of(), @JsonProperty("is_invoice_level") @ExcludeMissing isInvoiceLevel: JsonField = JsonMissing.of(), @@ -101,7 +101,7 @@ private constructor( * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ - fun filters(): List = filters.getRequired("filters") + fun filters(): List = filters.getRequired("filters") /** * True for adjustments that apply to an entire invoice, false for adjustments that apply to @@ -186,9 +186,7 @@ private constructor( * * Unlike [filters], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("filters") - @ExcludeMissing - fun _filters(): JsonField> = filters + @JsonProperty("filters") @ExcludeMissing fun _filters(): JsonField> = filters /** * Returns the raw JSON value of [isInvoiceLevel]. @@ -281,7 +279,7 @@ private constructor( private var id: JsonField? = null private var adjustmentType: JsonField? = null private var appliesToPriceIds: JsonField>? = null - private var filters: JsonField>? = null + private var filters: JsonField>? = null private var isInvoiceLevel: JsonField? = null private var itemId: JsonField? = null private var minimumAmount: JsonField? = null @@ -360,25 +358,25 @@ private constructor( } /** The filters that determine which prices to apply this adjustment to. */ - fun filters(filters: List) = filters(JsonField.of(filters)) + fun filters(filters: List) = filters(JsonField.of(filters)) /** * Sets [Builder.filters] to an arbitrary JSON value. * - * You should usually call [Builder.filters] with a well-typed `List` - * value instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. + * You should usually call [Builder.filters] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. */ - fun filters(filters: JsonField>) = apply { + fun filters(filters: JsonField>) = apply { this.filters = filters.map { it.toMutableList() } } /** - * Adds a single [TransformPriceFilter] to [filters]. + * Adds a single [Filter] to [filters]. * * @throws IllegalStateException if the field was previously set to a non-list. */ - fun addFilter(filter: TransformPriceFilter) = apply { + fun addFilter(filter: Filter) = apply { filters = (filters ?: JsonField.of(mutableListOf())).also { checkKnown("filters", it).add(filter) @@ -704,6 +702,534 @@ private constructor( override fun toString() = value.toString() } + class Filter + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val field: JsonField, + private val operator: JsonField, + private val values: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("field") @ExcludeMissing field: JsonField = JsonMissing.of(), + @JsonProperty("operator") + @ExcludeMissing + operator: JsonField = JsonMissing.of(), + @JsonProperty("values") + @ExcludeMissing + values: JsonField> = JsonMissing.of(), + ) : this(field, operator, values, mutableMapOf()) + + /** + * The property of the price to filter on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun field(): Field = field.getRequired("field") + + /** + * Should prices that match the filter be included or excluded. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun operator(): Operator = operator.getRequired("operator") + + /** + * The IDs or values that match this filter. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun values(): List = values.getRequired("values") + + /** + * Returns the raw JSON value of [field]. + * + * Unlike [field], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("field") @ExcludeMissing fun _field(): JsonField = field + + /** + * Returns the raw JSON value of [operator]. + * + * Unlike [operator], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("operator") @ExcludeMissing fun _operator(): JsonField = operator + + /** + * Returns the raw JSON value of [values]. + * + * Unlike [values], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("values") @ExcludeMissing fun _values(): JsonField> = values + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Filter]. + * + * The following fields are required: + * ```kotlin + * .field() + * .operator() + * .values() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Filter]. */ + class Builder internal constructor() { + + private var field: JsonField? = null + private var operator: JsonField? = null + private var values: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(filter: Filter) = apply { + field = filter.field + operator = filter.operator + values = filter.values.map { it.toMutableList() } + additionalProperties = filter.additionalProperties.toMutableMap() + } + + /** The property of the price to filter on. */ + fun field(field: Field) = field(JsonField.of(field)) + + /** + * Sets [Builder.field] to an arbitrary JSON value. + * + * You should usually call [Builder.field] with a well-typed [Field] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun field(field: JsonField) = apply { this.field = field } + + /** Should prices that match the filter be included or excluded. */ + fun operator(operator: Operator) = operator(JsonField.of(operator)) + + /** + * Sets [Builder.operator] to an arbitrary JSON value. + * + * You should usually call [Builder.operator] with a well-typed [Operator] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun operator(operator: JsonField) = apply { this.operator = operator } + + /** The IDs or values that match this filter. */ + fun values(values: List) = values(JsonField.of(values)) + + /** + * Sets [Builder.values] to an arbitrary JSON value. + * + * You should usually call [Builder.values] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun values(values: JsonField>) = apply { + this.values = values.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [values]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addValue(value: String) = apply { + values = + (values ?: JsonField.of(mutableListOf())).also { + checkKnown("values", it).add(value) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Filter]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .field() + * .operator() + * .values() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Filter = + Filter( + checkRequired("field", field), + checkRequired("operator", operator), + checkRequired("values", values).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Filter = apply { + if (validated) { + return@apply + } + + field().validate() + operator().validate() + values() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (field.asKnown()?.validity() ?: 0) + + (operator.asKnown()?.validity() ?: 0) + + (values.asKnown()?.size ?: 0) + + /** The property of the price to filter on. */ + class Field @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val PRICE_ID = of("price_id") + + val ITEM_ID = of("item_id") + + val PRICE_TYPE = of("price_type") + + val CURRENCY = of("currency") + + val PRICING_UNIT_ID = of("pricing_unit_id") + + fun of(value: String) = Field(JsonField.of(value)) + } + + /** An enum containing [Field]'s known values. */ + enum class Known { + PRICE_ID, + ITEM_ID, + PRICE_TYPE, + CURRENCY, + PRICING_UNIT_ID, + } + + /** + * An enum containing [Field]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Field] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + PRICE_ID, + ITEM_ID, + PRICE_TYPE, + CURRENCY, + PRICING_UNIT_ID, + /** + * An enum member indicating that [Field] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + PRICE_ID -> Value.PRICE_ID + ITEM_ID -> Value.ITEM_ID + PRICE_TYPE -> Value.PRICE_TYPE + CURRENCY -> Value.CURRENCY + PRICING_UNIT_ID -> Value.PRICING_UNIT_ID + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + PRICE_ID -> Known.PRICE_ID + ITEM_ID -> Known.ITEM_ID + PRICE_TYPE -> Known.PRICE_TYPE + CURRENCY -> Known.CURRENCY + PRICING_UNIT_ID -> Known.PRICING_UNIT_ID + else -> throw OrbInvalidDataException("Unknown Field: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Field = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Field && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Should prices that match the filter be included or excluded. */ + class Operator @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val INCLUDES = of("includes") + + val EXCLUDES = of("excludes") + + fun of(value: String) = Operator(JsonField.of(value)) + } + + /** An enum containing [Operator]'s known values. */ + enum class Known { + INCLUDES, + EXCLUDES, + } + + /** + * An enum containing [Operator]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Operator] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + INCLUDES, + EXCLUDES, + /** + * An enum member indicating that [Operator] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + INCLUDES -> Value.INCLUDES + EXCLUDES -> Value.EXCLUDES + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + INCLUDES -> Known.INCLUDES + EXCLUDES -> Known.EXCLUDES + else -> throw OrbInvalidDataException("Unknown Operator: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Operator = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Operator && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Filter && + field == other.field && + operator == other.operator && + values == other.values && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(field, operator, values, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Filter{field=$field, operator=$operator, values=$values, additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanPhasePercentageDiscountAdjustment.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanPhasePercentageDiscountAdjustment.kt index 39acfaa4f..2f36384aa 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanPhasePercentageDiscountAdjustment.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanPhasePercentageDiscountAdjustment.kt @@ -24,7 +24,7 @@ private constructor( private val id: JsonField, private val adjustmentType: JsonField, private val appliesToPriceIds: JsonField>, - private val filters: JsonField>, + private val filters: JsonField>, private val isInvoiceLevel: JsonField, private val percentageDiscount: JsonField, private val planPhaseOrder: JsonField, @@ -44,7 +44,7 @@ private constructor( appliesToPriceIds: JsonField> = JsonMissing.of(), @JsonProperty("filters") @ExcludeMissing - filters: JsonField> = JsonMissing.of(), + filters: JsonField> = JsonMissing.of(), @JsonProperty("is_invoice_level") @ExcludeMissing isInvoiceLevel: JsonField = JsonMissing.of(), @@ -98,7 +98,7 @@ private constructor( * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ - fun filters(): List = filters.getRequired("filters") + fun filters(): List = filters.getRequired("filters") /** * True for adjustments that apply to an entire invoice, false for adjustments that apply to @@ -175,9 +175,7 @@ private constructor( * * Unlike [filters], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("filters") - @ExcludeMissing - fun _filters(): JsonField> = filters + @JsonProperty("filters") @ExcludeMissing fun _filters(): JsonField> = filters /** * Returns the raw JSON value of [isInvoiceLevel]. @@ -264,7 +262,7 @@ private constructor( private var id: JsonField? = null private var adjustmentType: JsonField? = null private var appliesToPriceIds: JsonField>? = null - private var filters: JsonField>? = null + private var filters: JsonField>? = null private var isInvoiceLevel: JsonField? = null private var percentageDiscount: JsonField? = null private var planPhaseOrder: JsonField? = null @@ -344,25 +342,25 @@ private constructor( } /** The filters that determine which prices to apply this adjustment to. */ - fun filters(filters: List) = filters(JsonField.of(filters)) + fun filters(filters: List) = filters(JsonField.of(filters)) /** * Sets [Builder.filters] to an arbitrary JSON value. * - * You should usually call [Builder.filters] with a well-typed `List` - * value instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. + * You should usually call [Builder.filters] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. */ - fun filters(filters: JsonField>) = apply { + fun filters(filters: JsonField>) = apply { this.filters = filters.map { it.toMutableList() } } /** - * Adds a single [TransformPriceFilter] to [filters]. + * Adds a single [Filter] to [filters]. * * @throws IllegalStateException if the field was previously set to a non-list. */ - fun addFilter(filter: TransformPriceFilter) = apply { + fun addFilter(filter: Filter) = apply { filters = (filters ?: JsonField.of(mutableListOf())).also { checkKnown("filters", it).add(filter) @@ -674,6 +672,534 @@ private constructor( override fun toString() = value.toString() } + class Filter + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val field: JsonField, + private val operator: JsonField, + private val values: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("field") @ExcludeMissing field: JsonField = JsonMissing.of(), + @JsonProperty("operator") + @ExcludeMissing + operator: JsonField = JsonMissing.of(), + @JsonProperty("values") + @ExcludeMissing + values: JsonField> = JsonMissing.of(), + ) : this(field, operator, values, mutableMapOf()) + + /** + * The property of the price to filter on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun field(): Field = field.getRequired("field") + + /** + * Should prices that match the filter be included or excluded. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun operator(): Operator = operator.getRequired("operator") + + /** + * The IDs or values that match this filter. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun values(): List = values.getRequired("values") + + /** + * Returns the raw JSON value of [field]. + * + * Unlike [field], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("field") @ExcludeMissing fun _field(): JsonField = field + + /** + * Returns the raw JSON value of [operator]. + * + * Unlike [operator], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("operator") @ExcludeMissing fun _operator(): JsonField = operator + + /** + * Returns the raw JSON value of [values]. + * + * Unlike [values], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("values") @ExcludeMissing fun _values(): JsonField> = values + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Filter]. + * + * The following fields are required: + * ```kotlin + * .field() + * .operator() + * .values() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Filter]. */ + class Builder internal constructor() { + + private var field: JsonField? = null + private var operator: JsonField? = null + private var values: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(filter: Filter) = apply { + field = filter.field + operator = filter.operator + values = filter.values.map { it.toMutableList() } + additionalProperties = filter.additionalProperties.toMutableMap() + } + + /** The property of the price to filter on. */ + fun field(field: Field) = field(JsonField.of(field)) + + /** + * Sets [Builder.field] to an arbitrary JSON value. + * + * You should usually call [Builder.field] with a well-typed [Field] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun field(field: JsonField) = apply { this.field = field } + + /** Should prices that match the filter be included or excluded. */ + fun operator(operator: Operator) = operator(JsonField.of(operator)) + + /** + * Sets [Builder.operator] to an arbitrary JSON value. + * + * You should usually call [Builder.operator] with a well-typed [Operator] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun operator(operator: JsonField) = apply { this.operator = operator } + + /** The IDs or values that match this filter. */ + fun values(values: List) = values(JsonField.of(values)) + + /** + * Sets [Builder.values] to an arbitrary JSON value. + * + * You should usually call [Builder.values] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun values(values: JsonField>) = apply { + this.values = values.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [values]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addValue(value: String) = apply { + values = + (values ?: JsonField.of(mutableListOf())).also { + checkKnown("values", it).add(value) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Filter]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .field() + * .operator() + * .values() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Filter = + Filter( + checkRequired("field", field), + checkRequired("operator", operator), + checkRequired("values", values).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Filter = apply { + if (validated) { + return@apply + } + + field().validate() + operator().validate() + values() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (field.asKnown()?.validity() ?: 0) + + (operator.asKnown()?.validity() ?: 0) + + (values.asKnown()?.size ?: 0) + + /** The property of the price to filter on. */ + class Field @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val PRICE_ID = of("price_id") + + val ITEM_ID = of("item_id") + + val PRICE_TYPE = of("price_type") + + val CURRENCY = of("currency") + + val PRICING_UNIT_ID = of("pricing_unit_id") + + fun of(value: String) = Field(JsonField.of(value)) + } + + /** An enum containing [Field]'s known values. */ + enum class Known { + PRICE_ID, + ITEM_ID, + PRICE_TYPE, + CURRENCY, + PRICING_UNIT_ID, + } + + /** + * An enum containing [Field]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Field] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + PRICE_ID, + ITEM_ID, + PRICE_TYPE, + CURRENCY, + PRICING_UNIT_ID, + /** + * An enum member indicating that [Field] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + PRICE_ID -> Value.PRICE_ID + ITEM_ID -> Value.ITEM_ID + PRICE_TYPE -> Value.PRICE_TYPE + CURRENCY -> Value.CURRENCY + PRICING_UNIT_ID -> Value.PRICING_UNIT_ID + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + PRICE_ID -> Known.PRICE_ID + ITEM_ID -> Known.ITEM_ID + PRICE_TYPE -> Known.PRICE_TYPE + CURRENCY -> Known.CURRENCY + PRICING_UNIT_ID -> Known.PRICING_UNIT_ID + else -> throw OrbInvalidDataException("Unknown Field: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Field = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Field && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Should prices that match the filter be included or excluded. */ + class Operator @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val INCLUDES = of("includes") + + val EXCLUDES = of("excludes") + + fun of(value: String) = Operator(JsonField.of(value)) + } + + /** An enum containing [Operator]'s known values. */ + enum class Known { + INCLUDES, + EXCLUDES, + } + + /** + * An enum containing [Operator]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Operator] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + INCLUDES, + EXCLUDES, + /** + * An enum member indicating that [Operator] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + INCLUDES -> Value.INCLUDES + EXCLUDES -> Value.EXCLUDES + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + INCLUDES -> Known.INCLUDES + EXCLUDES -> Known.EXCLUDES + else -> throw OrbInvalidDataException("Unknown Operator: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Operator = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Operator && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Filter && + field == other.field && + operator == other.operator && + values == other.values && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(field, operator, values, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Filter{field=$field, operator=$operator, values=$values, additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanPhaseUsageDiscountAdjustment.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanPhaseUsageDiscountAdjustment.kt index aa1e6e912..7c945b7af 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanPhaseUsageDiscountAdjustment.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanPhaseUsageDiscountAdjustment.kt @@ -24,7 +24,7 @@ private constructor( private val id: JsonField, private val adjustmentType: JsonField, private val appliesToPriceIds: JsonField>, - private val filters: JsonField>, + private val filters: JsonField>, private val isInvoiceLevel: JsonField, private val planPhaseOrder: JsonField, private val reason: JsonField, @@ -44,7 +44,7 @@ private constructor( appliesToPriceIds: JsonField> = JsonMissing.of(), @JsonProperty("filters") @ExcludeMissing - filters: JsonField> = JsonMissing.of(), + filters: JsonField> = JsonMissing.of(), @JsonProperty("is_invoice_level") @ExcludeMissing isInvoiceLevel: JsonField = JsonMissing.of(), @@ -98,7 +98,7 @@ private constructor( * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ - fun filters(): List = filters.getRequired("filters") + fun filters(): List = filters.getRequired("filters") /** * True for adjustments that apply to an entire invoice, false for adjustments that apply to @@ -175,9 +175,7 @@ private constructor( * * Unlike [filters], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("filters") - @ExcludeMissing - fun _filters(): JsonField> = filters + @JsonProperty("filters") @ExcludeMissing fun _filters(): JsonField> = filters /** * Returns the raw JSON value of [isInvoiceLevel]. @@ -263,7 +261,7 @@ private constructor( private var id: JsonField? = null private var adjustmentType: JsonField? = null private var appliesToPriceIds: JsonField>? = null - private var filters: JsonField>? = null + private var filters: JsonField>? = null private var isInvoiceLevel: JsonField? = null private var planPhaseOrder: JsonField? = null private var reason: JsonField? = null @@ -342,25 +340,25 @@ private constructor( } /** The filters that determine which prices to apply this adjustment to. */ - fun filters(filters: List) = filters(JsonField.of(filters)) + fun filters(filters: List) = filters(JsonField.of(filters)) /** * Sets [Builder.filters] to an arbitrary JSON value. * - * You should usually call [Builder.filters] with a well-typed `List` - * value instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. + * You should usually call [Builder.filters] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. */ - fun filters(filters: JsonField>) = apply { + fun filters(filters: JsonField>) = apply { this.filters = filters.map { it.toMutableList() } } /** - * Adds a single [TransformPriceFilter] to [filters]. + * Adds a single [Filter] to [filters]. * * @throws IllegalStateException if the field was previously set to a non-list. */ - fun addFilter(filter: TransformPriceFilter) = apply { + fun addFilter(filter: Filter) = apply { filters = (filters ?: JsonField.of(mutableListOf())).also { checkKnown("filters", it).add(filter) @@ -671,6 +669,534 @@ private constructor( override fun toString() = value.toString() } + class Filter + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val field: JsonField, + private val operator: JsonField, + private val values: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("field") @ExcludeMissing field: JsonField = JsonMissing.of(), + @JsonProperty("operator") + @ExcludeMissing + operator: JsonField = JsonMissing.of(), + @JsonProperty("values") + @ExcludeMissing + values: JsonField> = JsonMissing.of(), + ) : this(field, operator, values, mutableMapOf()) + + /** + * The property of the price to filter on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun field(): Field = field.getRequired("field") + + /** + * Should prices that match the filter be included or excluded. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun operator(): Operator = operator.getRequired("operator") + + /** + * The IDs or values that match this filter. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun values(): List = values.getRequired("values") + + /** + * Returns the raw JSON value of [field]. + * + * Unlike [field], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("field") @ExcludeMissing fun _field(): JsonField = field + + /** + * Returns the raw JSON value of [operator]. + * + * Unlike [operator], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("operator") @ExcludeMissing fun _operator(): JsonField = operator + + /** + * Returns the raw JSON value of [values]. + * + * Unlike [values], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("values") @ExcludeMissing fun _values(): JsonField> = values + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Filter]. + * + * The following fields are required: + * ```kotlin + * .field() + * .operator() + * .values() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Filter]. */ + class Builder internal constructor() { + + private var field: JsonField? = null + private var operator: JsonField? = null + private var values: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(filter: Filter) = apply { + field = filter.field + operator = filter.operator + values = filter.values.map { it.toMutableList() } + additionalProperties = filter.additionalProperties.toMutableMap() + } + + /** The property of the price to filter on. */ + fun field(field: Field) = field(JsonField.of(field)) + + /** + * Sets [Builder.field] to an arbitrary JSON value. + * + * You should usually call [Builder.field] with a well-typed [Field] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun field(field: JsonField) = apply { this.field = field } + + /** Should prices that match the filter be included or excluded. */ + fun operator(operator: Operator) = operator(JsonField.of(operator)) + + /** + * Sets [Builder.operator] to an arbitrary JSON value. + * + * You should usually call [Builder.operator] with a well-typed [Operator] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun operator(operator: JsonField) = apply { this.operator = operator } + + /** The IDs or values that match this filter. */ + fun values(values: List) = values(JsonField.of(values)) + + /** + * Sets [Builder.values] to an arbitrary JSON value. + * + * You should usually call [Builder.values] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun values(values: JsonField>) = apply { + this.values = values.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [values]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addValue(value: String) = apply { + values = + (values ?: JsonField.of(mutableListOf())).also { + checkKnown("values", it).add(value) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Filter]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .field() + * .operator() + * .values() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Filter = + Filter( + checkRequired("field", field), + checkRequired("operator", operator), + checkRequired("values", values).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Filter = apply { + if (validated) { + return@apply + } + + field().validate() + operator().validate() + values() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (field.asKnown()?.validity() ?: 0) + + (operator.asKnown()?.validity() ?: 0) + + (values.asKnown()?.size ?: 0) + + /** The property of the price to filter on. */ + class Field @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val PRICE_ID = of("price_id") + + val ITEM_ID = of("item_id") + + val PRICE_TYPE = of("price_type") + + val CURRENCY = of("currency") + + val PRICING_UNIT_ID = of("pricing_unit_id") + + fun of(value: String) = Field(JsonField.of(value)) + } + + /** An enum containing [Field]'s known values. */ + enum class Known { + PRICE_ID, + ITEM_ID, + PRICE_TYPE, + CURRENCY, + PRICING_UNIT_ID, + } + + /** + * An enum containing [Field]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Field] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + PRICE_ID, + ITEM_ID, + PRICE_TYPE, + CURRENCY, + PRICING_UNIT_ID, + /** + * An enum member indicating that [Field] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + PRICE_ID -> Value.PRICE_ID + ITEM_ID -> Value.ITEM_ID + PRICE_TYPE -> Value.PRICE_TYPE + CURRENCY -> Value.CURRENCY + PRICING_UNIT_ID -> Value.PRICING_UNIT_ID + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + PRICE_ID -> Known.PRICE_ID + ITEM_ID -> Known.ITEM_ID + PRICE_TYPE -> Known.PRICE_TYPE + CURRENCY -> Known.CURRENCY + PRICING_UNIT_ID -> Known.PRICING_UNIT_ID + else -> throw OrbInvalidDataException("Unknown Field: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Field = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Field && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Should prices that match the filter be included or excluded. */ + class Operator @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val INCLUDES = of("includes") + + val EXCLUDES = of("excludes") + + fun of(value: String) = Operator(JsonField.of(value)) + } + + /** An enum containing [Operator]'s known values. */ + enum class Known { + INCLUDES, + EXCLUDES, + } + + /** + * An enum containing [Operator]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Operator] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + INCLUDES, + EXCLUDES, + /** + * An enum member indicating that [Operator] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + INCLUDES -> Value.INCLUDES + EXCLUDES -> Value.EXCLUDES + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + INCLUDES -> Known.INCLUDES + EXCLUDES -> Known.EXCLUDES + else -> throw OrbInvalidDataException("Unknown Operator: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Operator = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Operator && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Filter && + field == other.field && + operator == other.operator && + values == other.values && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(field, operator, values, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Filter{field=$field, operator=$operator, values=$values, additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Price.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Price.kt index c879b870c..5c87d0849 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Price.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Price.kt @@ -1101,7 +1101,7 @@ private constructor( private val billingCycleConfiguration: JsonField, private val billingMode: JsonField, private val cadence: JsonField, - private val compositePriceFilters: JsonField>, + private val compositePriceFilters: JsonField>, private val conversionRate: JsonField, private val conversionRateConfig: JsonField, private val createdAt: JsonField, @@ -1142,7 +1142,7 @@ private constructor( @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), @JsonProperty("composite_price_filters") @ExcludeMissing - compositePriceFilters: JsonField> = JsonMissing.of(), + compositePriceFilters: JsonField> = JsonMissing.of(), @JsonProperty("conversion_rate") @ExcludeMissing conversionRate: JsonField = JsonMissing.of(), @@ -1267,7 +1267,7 @@ private constructor( * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun compositePriceFilters(): List? = + fun compositePriceFilters(): List? = compositePriceFilters.getNullable("composite_price_filters") /** @@ -1478,7 +1478,7 @@ private constructor( */ @JsonProperty("composite_price_filters") @ExcludeMissing - fun _compositePriceFilters(): JsonField> = compositePriceFilters + fun _compositePriceFilters(): JsonField> = compositePriceFilters /** * Returns the raw JSON value of [conversionRate]. @@ -1737,7 +1737,7 @@ private constructor( private var billingCycleConfiguration: JsonField? = null private var billingMode: JsonField? = null private var cadence: JsonField? = null - private var compositePriceFilters: JsonField>? = null + private var compositePriceFilters: JsonField>? = null private var conversionRate: JsonField? = null private var conversionRateConfig: JsonField? = null private var createdAt: JsonField? = null @@ -1858,28 +1858,28 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - fun compositePriceFilters(compositePriceFilters: List?) = + fun compositePriceFilters(compositePriceFilters: List?) = compositePriceFilters(JsonField.ofNullable(compositePriceFilters)) /** * Sets [Builder.compositePriceFilters] to an arbitrary JSON value. * * You should usually call [Builder.compositePriceFilters] with a well-typed - * `List` value instead. This method is primarily for setting the + * `List` value instead. This method is primarily for setting the * field to an undocumented or not yet supported value. */ fun compositePriceFilters( - compositePriceFilters: JsonField> + compositePriceFilters: JsonField> ) = apply { this.compositePriceFilters = compositePriceFilters.map { it.toMutableList() } } /** - * Adds a single [TransformPriceFilter] to [compositePriceFilters]. + * Adds a single [CompositePriceFilter] to [compositePriceFilters]. * * @throws IllegalStateException if the field was previously set to a non-list. */ - fun addCompositePriceFilter(compositePriceFilter: TransformPriceFilter) = apply { + fun addCompositePriceFilter(compositePriceFilter: CompositePriceFilter) = apply { compositePriceFilters = (compositePriceFilters ?: JsonField.of(mutableListOf())).also { checkKnown("compositePriceFilters", it).add(compositePriceFilter) @@ -2794,6 +2794,546 @@ private constructor( override fun toString() = value.toString() } + class CompositePriceFilter + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val field: JsonField, + private val operator: JsonField, + private val values: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("field") @ExcludeMissing field: JsonField = JsonMissing.of(), + @JsonProperty("operator") + @ExcludeMissing + operator: JsonField = JsonMissing.of(), + @JsonProperty("values") + @ExcludeMissing + values: JsonField> = JsonMissing.of(), + ) : this(field, operator, values, mutableMapOf()) + + /** + * The property of the price to filter on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun field(): Field = field.getRequired("field") + + /** + * Should prices that match the filter be included or excluded. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun operator(): Operator = operator.getRequired("operator") + + /** + * The IDs or values that match this filter. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun values(): List = values.getRequired("values") + + /** + * Returns the raw JSON value of [field]. + * + * Unlike [field], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("field") @ExcludeMissing fun _field(): JsonField = field + + /** + * Returns the raw JSON value of [operator]. + * + * Unlike [operator], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("operator") + @ExcludeMissing + fun _operator(): JsonField = operator + + /** + * Returns the raw JSON value of [values]. + * + * Unlike [values], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("values") @ExcludeMissing fun _values(): JsonField> = values + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [CompositePriceFilter]. + * + * The following fields are required: + * ```kotlin + * .field() + * .operator() + * .values() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [CompositePriceFilter]. */ + class Builder internal constructor() { + + private var field: JsonField? = null + private var operator: JsonField? = null + private var values: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(compositePriceFilter: CompositePriceFilter) = apply { + field = compositePriceFilter.field + operator = compositePriceFilter.operator + values = compositePriceFilter.values.map { it.toMutableList() } + additionalProperties = compositePriceFilter.additionalProperties.toMutableMap() + } + + /** The property of the price to filter on. */ + fun field(field: Field) = field(JsonField.of(field)) + + /** + * Sets [Builder.field] to an arbitrary JSON value. + * + * You should usually call [Builder.field] with a well-typed [Field] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun field(field: JsonField) = apply { this.field = field } + + /** Should prices that match the filter be included or excluded. */ + fun operator(operator: Operator) = operator(JsonField.of(operator)) + + /** + * Sets [Builder.operator] to an arbitrary JSON value. + * + * You should usually call [Builder.operator] with a well-typed [Operator] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun operator(operator: JsonField) = apply { this.operator = operator } + + /** The IDs or values that match this filter. */ + fun values(values: List) = values(JsonField.of(values)) + + /** + * Sets [Builder.values] to an arbitrary JSON value. + * + * You should usually call [Builder.values] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun values(values: JsonField>) = apply { + this.values = values.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [values]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addValue(value: String) = apply { + values = + (values ?: JsonField.of(mutableListOf())).also { + checkKnown("values", it).add(value) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CompositePriceFilter]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .field() + * .operator() + * .values() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CompositePriceFilter = + CompositePriceFilter( + checkRequired("field", field), + checkRequired("operator", operator), + checkRequired("values", values).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CompositePriceFilter = apply { + if (validated) { + return@apply + } + + field().validate() + operator().validate() + values() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (field.asKnown()?.validity() ?: 0) + + (operator.asKnown()?.validity() ?: 0) + + (values.asKnown()?.size ?: 0) + + /** The property of the price to filter on. */ + class Field @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val PRICE_ID = of("price_id") + + val ITEM_ID = of("item_id") + + val PRICE_TYPE = of("price_type") + + val CURRENCY = of("currency") + + val PRICING_UNIT_ID = of("pricing_unit_id") + + fun of(value: String) = Field(JsonField.of(value)) + } + + /** An enum containing [Field]'s known values. */ + enum class Known { + PRICE_ID, + ITEM_ID, + PRICE_TYPE, + CURRENCY, + PRICING_UNIT_ID, + } + + /** + * An enum containing [Field]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Field] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + PRICE_ID, + ITEM_ID, + PRICE_TYPE, + CURRENCY, + PRICING_UNIT_ID, + /** + * An enum member indicating that [Field] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + PRICE_ID -> Value.PRICE_ID + ITEM_ID -> Value.ITEM_ID + PRICE_TYPE -> Value.PRICE_TYPE + CURRENCY -> Value.CURRENCY + PRICING_UNIT_ID -> Value.PRICING_UNIT_ID + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + PRICE_ID -> Known.PRICE_ID + ITEM_ID -> Known.ITEM_ID + PRICE_TYPE -> Known.PRICE_TYPE + CURRENCY -> Known.CURRENCY + PRICING_UNIT_ID -> Known.PRICING_UNIT_ID + else -> throw OrbInvalidDataException("Unknown Field: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Field = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Field && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Should prices that match the filter be included or excluded. */ + class Operator @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val INCLUDES = of("includes") + + val EXCLUDES = of("excludes") + + fun of(value: String) = Operator(JsonField.of(value)) + } + + /** An enum containing [Operator]'s known values. */ + enum class Known { + INCLUDES, + EXCLUDES, + } + + /** + * An enum containing [Operator]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Operator] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + INCLUDES, + EXCLUDES, + /** + * An enum member indicating that [Operator] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + INCLUDES -> Value.INCLUDES + EXCLUDES -> Value.EXCLUDES + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + INCLUDES -> Known.INCLUDES + EXCLUDES -> Known.EXCLUDES + else -> throw OrbInvalidDataException("Unknown Operator: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Operator = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Operator && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CompositePriceFilter && + field == other.field && + operator == other.operator && + values == other.values && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(field, operator, values, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CompositePriceFilter{field=$field, operator=$operator, values=$values, additionalProperties=$additionalProperties}" + } + /** * User specified key-value pairs for the resource. If not present, this defaults to an * empty dictionary. Individual keys can be removed by setting the value to `null`, and the @@ -3119,7 +3659,7 @@ private constructor( private val billingCycleConfiguration: JsonField, private val billingMode: JsonField, private val cadence: JsonField, - private val compositePriceFilters: JsonField>, + private val compositePriceFilters: JsonField>, private val conversionRate: JsonField, private val conversionRateConfig: JsonField, private val createdAt: JsonField, @@ -3160,7 +3700,7 @@ private constructor( @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), @JsonProperty("composite_price_filters") @ExcludeMissing - compositePriceFilters: JsonField> = JsonMissing.of(), + compositePriceFilters: JsonField> = JsonMissing.of(), @JsonProperty("conversion_rate") @ExcludeMissing conversionRate: JsonField = JsonMissing.of(), @@ -3285,7 +3825,7 @@ private constructor( * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun compositePriceFilters(): List? = + fun compositePriceFilters(): List? = compositePriceFilters.getNullable("composite_price_filters") /** @@ -3496,7 +4036,7 @@ private constructor( */ @JsonProperty("composite_price_filters") @ExcludeMissing - fun _compositePriceFilters(): JsonField> = compositePriceFilters + fun _compositePriceFilters(): JsonField> = compositePriceFilters /** * Returns the raw JSON value of [conversionRate]. @@ -3756,7 +4296,7 @@ private constructor( private var billingCycleConfiguration: JsonField? = null private var billingMode: JsonField? = null private var cadence: JsonField? = null - private var compositePriceFilters: JsonField>? = null + private var compositePriceFilters: JsonField>? = null private var conversionRate: JsonField? = null private var conversionRateConfig: JsonField? = null private var createdAt: JsonField? = null @@ -3877,28 +4417,28 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - fun compositePriceFilters(compositePriceFilters: List?) = + fun compositePriceFilters(compositePriceFilters: List?) = compositePriceFilters(JsonField.ofNullable(compositePriceFilters)) /** * Sets [Builder.compositePriceFilters] to an arbitrary JSON value. * * You should usually call [Builder.compositePriceFilters] with a well-typed - * `List` value instead. This method is primarily for setting the + * `List` value instead. This method is primarily for setting the * field to an undocumented or not yet supported value. */ fun compositePriceFilters( - compositePriceFilters: JsonField> + compositePriceFilters: JsonField> ) = apply { this.compositePriceFilters = compositePriceFilters.map { it.toMutableList() } } /** - * Adds a single [TransformPriceFilter] to [compositePriceFilters]. + * Adds a single [CompositePriceFilter] to [compositePriceFilters]. * * @throws IllegalStateException if the field was previously set to a non-list. */ - fun addCompositePriceFilter(compositePriceFilter: TransformPriceFilter) = apply { + fun addCompositePriceFilter(compositePriceFilter: CompositePriceFilter) = apply { compositePriceFilters = (compositePriceFilters ?: JsonField.of(mutableListOf())).also { checkKnown("compositePriceFilters", it).add(compositePriceFilter) @@ -4813,6 +5353,546 @@ private constructor( override fun toString() = value.toString() } + class CompositePriceFilter + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val field: JsonField, + private val operator: JsonField, + private val values: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("field") @ExcludeMissing field: JsonField = JsonMissing.of(), + @JsonProperty("operator") + @ExcludeMissing + operator: JsonField = JsonMissing.of(), + @JsonProperty("values") + @ExcludeMissing + values: JsonField> = JsonMissing.of(), + ) : this(field, operator, values, mutableMapOf()) + + /** + * The property of the price to filter on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun field(): Field = field.getRequired("field") + + /** + * Should prices that match the filter be included or excluded. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun operator(): Operator = operator.getRequired("operator") + + /** + * The IDs or values that match this filter. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun values(): List = values.getRequired("values") + + /** + * Returns the raw JSON value of [field]. + * + * Unlike [field], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("field") @ExcludeMissing fun _field(): JsonField = field + + /** + * Returns the raw JSON value of [operator]. + * + * Unlike [operator], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("operator") + @ExcludeMissing + fun _operator(): JsonField = operator + + /** + * Returns the raw JSON value of [values]. + * + * Unlike [values], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("values") @ExcludeMissing fun _values(): JsonField> = values + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [CompositePriceFilter]. + * + * The following fields are required: + * ```kotlin + * .field() + * .operator() + * .values() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [CompositePriceFilter]. */ + class Builder internal constructor() { + + private var field: JsonField? = null + private var operator: JsonField? = null + private var values: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(compositePriceFilter: CompositePriceFilter) = apply { + field = compositePriceFilter.field + operator = compositePriceFilter.operator + values = compositePriceFilter.values.map { it.toMutableList() } + additionalProperties = compositePriceFilter.additionalProperties.toMutableMap() + } + + /** The property of the price to filter on. */ + fun field(field: Field) = field(JsonField.of(field)) + + /** + * Sets [Builder.field] to an arbitrary JSON value. + * + * You should usually call [Builder.field] with a well-typed [Field] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun field(field: JsonField) = apply { this.field = field } + + /** Should prices that match the filter be included or excluded. */ + fun operator(operator: Operator) = operator(JsonField.of(operator)) + + /** + * Sets [Builder.operator] to an arbitrary JSON value. + * + * You should usually call [Builder.operator] with a well-typed [Operator] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun operator(operator: JsonField) = apply { this.operator = operator } + + /** The IDs or values that match this filter. */ + fun values(values: List) = values(JsonField.of(values)) + + /** + * Sets [Builder.values] to an arbitrary JSON value. + * + * You should usually call [Builder.values] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun values(values: JsonField>) = apply { + this.values = values.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [values]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addValue(value: String) = apply { + values = + (values ?: JsonField.of(mutableListOf())).also { + checkKnown("values", it).add(value) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CompositePriceFilter]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .field() + * .operator() + * .values() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CompositePriceFilter = + CompositePriceFilter( + checkRequired("field", field), + checkRequired("operator", operator), + checkRequired("values", values).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CompositePriceFilter = apply { + if (validated) { + return@apply + } + + field().validate() + operator().validate() + values() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (field.asKnown()?.validity() ?: 0) + + (operator.asKnown()?.validity() ?: 0) + + (values.asKnown()?.size ?: 0) + + /** The property of the price to filter on. */ + class Field @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val PRICE_ID = of("price_id") + + val ITEM_ID = of("item_id") + + val PRICE_TYPE = of("price_type") + + val CURRENCY = of("currency") + + val PRICING_UNIT_ID = of("pricing_unit_id") + + fun of(value: String) = Field(JsonField.of(value)) + } + + /** An enum containing [Field]'s known values. */ + enum class Known { + PRICE_ID, + ITEM_ID, + PRICE_TYPE, + CURRENCY, + PRICING_UNIT_ID, + } + + /** + * An enum containing [Field]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Field] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + PRICE_ID, + ITEM_ID, + PRICE_TYPE, + CURRENCY, + PRICING_UNIT_ID, + /** + * An enum member indicating that [Field] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + PRICE_ID -> Value.PRICE_ID + ITEM_ID -> Value.ITEM_ID + PRICE_TYPE -> Value.PRICE_TYPE + CURRENCY -> Value.CURRENCY + PRICING_UNIT_ID -> Value.PRICING_UNIT_ID + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + PRICE_ID -> Known.PRICE_ID + ITEM_ID -> Known.ITEM_ID + PRICE_TYPE -> Known.PRICE_TYPE + CURRENCY -> Known.CURRENCY + PRICING_UNIT_ID -> Known.PRICING_UNIT_ID + else -> throw OrbInvalidDataException("Unknown Field: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Field = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Field && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Should prices that match the filter be included or excluded. */ + class Operator @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val INCLUDES = of("includes") + + val EXCLUDES = of("excludes") + + fun of(value: String) = Operator(JsonField.of(value)) + } + + /** An enum containing [Operator]'s known values. */ + enum class Known { + INCLUDES, + EXCLUDES, + } + + /** + * An enum containing [Operator]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Operator] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + INCLUDES, + EXCLUDES, + /** + * An enum member indicating that [Operator] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + INCLUDES -> Value.INCLUDES + EXCLUDES -> Value.EXCLUDES + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + INCLUDES -> Known.INCLUDES + EXCLUDES -> Known.EXCLUDES + else -> throw OrbInvalidDataException("Unknown Operator: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Operator = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Operator && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CompositePriceFilter && + field == other.field && + operator == other.operator && + values == other.values && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(field, operator, values, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CompositePriceFilter{field=$field, operator=$operator, values=$values, additionalProperties=$additionalProperties}" + } + /** * User specified key-value pairs for the resource. If not present, this defaults to an * empty dictionary. Individual keys can be removed by setting the value to `null`, and the @@ -5139,7 +6219,7 @@ private constructor( private val billingMode: JsonField, private val bulkConfig: JsonField, private val cadence: JsonField, - private val compositePriceFilters: JsonField>, + private val compositePriceFilters: JsonField>, private val conversionRate: JsonField, private val conversionRateConfig: JsonField, private val createdAt: JsonField, @@ -5182,7 +6262,7 @@ private constructor( @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), @JsonProperty("composite_price_filters") @ExcludeMissing - compositePriceFilters: JsonField> = JsonMissing.of(), + compositePriceFilters: JsonField> = JsonMissing.of(), @JsonProperty("conversion_rate") @ExcludeMissing conversionRate: JsonField = JsonMissing.of(), @@ -5312,7 +6392,7 @@ private constructor( * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun compositePriceFilters(): List? = + fun compositePriceFilters(): List? = compositePriceFilters.getNullable("composite_price_filters") /** @@ -5524,7 +6604,7 @@ private constructor( */ @JsonProperty("composite_price_filters") @ExcludeMissing - fun _compositePriceFilters(): JsonField> = compositePriceFilters + fun _compositePriceFilters(): JsonField> = compositePriceFilters /** * Returns the raw JSON value of [conversionRate]. @@ -5775,7 +6855,7 @@ private constructor( private var billingMode: JsonField? = null private var bulkConfig: JsonField? = null private var cadence: JsonField? = null - private var compositePriceFilters: JsonField>? = null + private var compositePriceFilters: JsonField>? = null private var conversionRate: JsonField? = null private var conversionRateConfig: JsonField? = null private var createdAt: JsonField? = null @@ -5909,28 +6989,28 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - fun compositePriceFilters(compositePriceFilters: List?) = + fun compositePriceFilters(compositePriceFilters: List?) = compositePriceFilters(JsonField.ofNullable(compositePriceFilters)) /** * Sets [Builder.compositePriceFilters] to an arbitrary JSON value. * * You should usually call [Builder.compositePriceFilters] with a well-typed - * `List` value instead. This method is primarily for setting the + * `List` value instead. This method is primarily for setting the * field to an undocumented or not yet supported value. */ fun compositePriceFilters( - compositePriceFilters: JsonField> + compositePriceFilters: JsonField> ) = apply { this.compositePriceFilters = compositePriceFilters.map { it.toMutableList() } } /** - * Adds a single [TransformPriceFilter] to [compositePriceFilters]. + * Adds a single [CompositePriceFilter] to [compositePriceFilters]. * * @throws IllegalStateException if the field was previously set to a non-list. */ - fun addCompositePriceFilter(compositePriceFilter: TransformPriceFilter) = apply { + fun addCompositePriceFilter(compositePriceFilter: CompositePriceFilter) = apply { compositePriceFilters = (compositePriceFilters ?: JsonField.of(mutableListOf())).also { checkKnown("compositePriceFilters", it).add(compositePriceFilter) @@ -6831,6 +7911,546 @@ private constructor( override fun toString() = value.toString() } + class CompositePriceFilter + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val field: JsonField, + private val operator: JsonField, + private val values: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("field") @ExcludeMissing field: JsonField = JsonMissing.of(), + @JsonProperty("operator") + @ExcludeMissing + operator: JsonField = JsonMissing.of(), + @JsonProperty("values") + @ExcludeMissing + values: JsonField> = JsonMissing.of(), + ) : this(field, operator, values, mutableMapOf()) + + /** + * The property of the price to filter on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun field(): Field = field.getRequired("field") + + /** + * Should prices that match the filter be included or excluded. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun operator(): Operator = operator.getRequired("operator") + + /** + * The IDs or values that match this filter. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun values(): List = values.getRequired("values") + + /** + * Returns the raw JSON value of [field]. + * + * Unlike [field], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("field") @ExcludeMissing fun _field(): JsonField = field + + /** + * Returns the raw JSON value of [operator]. + * + * Unlike [operator], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("operator") + @ExcludeMissing + fun _operator(): JsonField = operator + + /** + * Returns the raw JSON value of [values]. + * + * Unlike [values], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("values") @ExcludeMissing fun _values(): JsonField> = values + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [CompositePriceFilter]. + * + * The following fields are required: + * ```kotlin + * .field() + * .operator() + * .values() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [CompositePriceFilter]. */ + class Builder internal constructor() { + + private var field: JsonField? = null + private var operator: JsonField? = null + private var values: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(compositePriceFilter: CompositePriceFilter) = apply { + field = compositePriceFilter.field + operator = compositePriceFilter.operator + values = compositePriceFilter.values.map { it.toMutableList() } + additionalProperties = compositePriceFilter.additionalProperties.toMutableMap() + } + + /** The property of the price to filter on. */ + fun field(field: Field) = field(JsonField.of(field)) + + /** + * Sets [Builder.field] to an arbitrary JSON value. + * + * You should usually call [Builder.field] with a well-typed [Field] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun field(field: JsonField) = apply { this.field = field } + + /** Should prices that match the filter be included or excluded. */ + fun operator(operator: Operator) = operator(JsonField.of(operator)) + + /** + * Sets [Builder.operator] to an arbitrary JSON value. + * + * You should usually call [Builder.operator] with a well-typed [Operator] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun operator(operator: JsonField) = apply { this.operator = operator } + + /** The IDs or values that match this filter. */ + fun values(values: List) = values(JsonField.of(values)) + + /** + * Sets [Builder.values] to an arbitrary JSON value. + * + * You should usually call [Builder.values] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun values(values: JsonField>) = apply { + this.values = values.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [values]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addValue(value: String) = apply { + values = + (values ?: JsonField.of(mutableListOf())).also { + checkKnown("values", it).add(value) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CompositePriceFilter]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .field() + * .operator() + * .values() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CompositePriceFilter = + CompositePriceFilter( + checkRequired("field", field), + checkRequired("operator", operator), + checkRequired("values", values).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CompositePriceFilter = apply { + if (validated) { + return@apply + } + + field().validate() + operator().validate() + values() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (field.asKnown()?.validity() ?: 0) + + (operator.asKnown()?.validity() ?: 0) + + (values.asKnown()?.size ?: 0) + + /** The property of the price to filter on. */ + class Field @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val PRICE_ID = of("price_id") + + val ITEM_ID = of("item_id") + + val PRICE_TYPE = of("price_type") + + val CURRENCY = of("currency") + + val PRICING_UNIT_ID = of("pricing_unit_id") + + fun of(value: String) = Field(JsonField.of(value)) + } + + /** An enum containing [Field]'s known values. */ + enum class Known { + PRICE_ID, + ITEM_ID, + PRICE_TYPE, + CURRENCY, + PRICING_UNIT_ID, + } + + /** + * An enum containing [Field]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Field] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + PRICE_ID, + ITEM_ID, + PRICE_TYPE, + CURRENCY, + PRICING_UNIT_ID, + /** + * An enum member indicating that [Field] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + PRICE_ID -> Value.PRICE_ID + ITEM_ID -> Value.ITEM_ID + PRICE_TYPE -> Value.PRICE_TYPE + CURRENCY -> Value.CURRENCY + PRICING_UNIT_ID -> Value.PRICING_UNIT_ID + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + PRICE_ID -> Known.PRICE_ID + ITEM_ID -> Known.ITEM_ID + PRICE_TYPE -> Known.PRICE_TYPE + CURRENCY -> Known.CURRENCY + PRICING_UNIT_ID -> Known.PRICING_UNIT_ID + else -> throw OrbInvalidDataException("Unknown Field: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Field = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Field && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Should prices that match the filter be included or excluded. */ + class Operator @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val INCLUDES = of("includes") + + val EXCLUDES = of("excludes") + + fun of(value: String) = Operator(JsonField.of(value)) + } + + /** An enum containing [Operator]'s known values. */ + enum class Known { + INCLUDES, + EXCLUDES, + } + + /** + * An enum containing [Operator]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Operator] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + INCLUDES, + EXCLUDES, + /** + * An enum member indicating that [Operator] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + INCLUDES -> Value.INCLUDES + EXCLUDES -> Value.EXCLUDES + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + INCLUDES -> Known.INCLUDES + EXCLUDES -> Known.EXCLUDES + else -> throw OrbInvalidDataException("Unknown Operator: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Operator = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Operator && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CompositePriceFilter && + field == other.field && + operator == other.operator && + values == other.values && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(field, operator, values, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CompositePriceFilter{field=$field, operator=$operator, values=$values, additionalProperties=$additionalProperties}" + } + /** * User specified key-value pairs for the resource. If not present, this defaults to an * empty dictionary. Individual keys can be removed by setting the value to `null`, and the @@ -7157,7 +8777,7 @@ private constructor( private val billingMode: JsonField, private val bulkWithFiltersConfig: JsonField, private val cadence: JsonField, - private val compositePriceFilters: JsonField>, + private val compositePriceFilters: JsonField>, private val conversionRate: JsonField, private val conversionRateConfig: JsonField, private val createdAt: JsonField, @@ -7200,7 +8820,7 @@ private constructor( @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), @JsonProperty("composite_price_filters") @ExcludeMissing - compositePriceFilters: JsonField> = JsonMissing.of(), + compositePriceFilters: JsonField> = JsonMissing.of(), @JsonProperty("conversion_rate") @ExcludeMissing conversionRate: JsonField = JsonMissing.of(), @@ -7331,7 +8951,7 @@ private constructor( * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun compositePriceFilters(): List? = + fun compositePriceFilters(): List? = compositePriceFilters.getNullable("composite_price_filters") /** @@ -7544,7 +9164,7 @@ private constructor( */ @JsonProperty("composite_price_filters") @ExcludeMissing - fun _compositePriceFilters(): JsonField> = compositePriceFilters + fun _compositePriceFilters(): JsonField> = compositePriceFilters /** * Returns the raw JSON value of [conversionRate]. @@ -7795,7 +9415,7 @@ private constructor( private var billingMode: JsonField? = null private var bulkWithFiltersConfig: JsonField? = null private var cadence: JsonField? = null - private var compositePriceFilters: JsonField>? = null + private var compositePriceFilters: JsonField>? = null private var conversionRate: JsonField? = null private var conversionRateConfig: JsonField? = null private var createdAt: JsonField? = null @@ -7932,28 +9552,28 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - fun compositePriceFilters(compositePriceFilters: List?) = + fun compositePriceFilters(compositePriceFilters: List?) = compositePriceFilters(JsonField.ofNullable(compositePriceFilters)) /** * Sets [Builder.compositePriceFilters] to an arbitrary JSON value. * * You should usually call [Builder.compositePriceFilters] with a well-typed - * `List` value instead. This method is primarily for setting the + * `List` value instead. This method is primarily for setting the * field to an undocumented or not yet supported value. */ fun compositePriceFilters( - compositePriceFilters: JsonField> + compositePriceFilters: JsonField> ) = apply { this.compositePriceFilters = compositePriceFilters.map { it.toMutableList() } } /** - * Adds a single [TransformPriceFilter] to [compositePriceFilters]. + * Adds a single [CompositePriceFilter] to [compositePriceFilters]. * * @throws IllegalStateException if the field was previously set to a non-list. */ - fun addCompositePriceFilter(compositePriceFilter: TransformPriceFilter) = apply { + fun addCompositePriceFilter(compositePriceFilter: CompositePriceFilter) = apply { compositePriceFilters = (compositePriceFilters ?: JsonField.of(mutableListOf())).also { checkKnown("compositePriceFilters", it).add(compositePriceFilter) @@ -9526,6 +11146,546 @@ private constructor( override fun toString() = value.toString() } + class CompositePriceFilter + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val field: JsonField, + private val operator: JsonField, + private val values: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("field") @ExcludeMissing field: JsonField = JsonMissing.of(), + @JsonProperty("operator") + @ExcludeMissing + operator: JsonField = JsonMissing.of(), + @JsonProperty("values") + @ExcludeMissing + values: JsonField> = JsonMissing.of(), + ) : this(field, operator, values, mutableMapOf()) + + /** + * The property of the price to filter on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun field(): Field = field.getRequired("field") + + /** + * Should prices that match the filter be included or excluded. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun operator(): Operator = operator.getRequired("operator") + + /** + * The IDs or values that match this filter. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun values(): List = values.getRequired("values") + + /** + * Returns the raw JSON value of [field]. + * + * Unlike [field], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("field") @ExcludeMissing fun _field(): JsonField = field + + /** + * Returns the raw JSON value of [operator]. + * + * Unlike [operator], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("operator") + @ExcludeMissing + fun _operator(): JsonField = operator + + /** + * Returns the raw JSON value of [values]. + * + * Unlike [values], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("values") @ExcludeMissing fun _values(): JsonField> = values + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [CompositePriceFilter]. + * + * The following fields are required: + * ```kotlin + * .field() + * .operator() + * .values() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [CompositePriceFilter]. */ + class Builder internal constructor() { + + private var field: JsonField? = null + private var operator: JsonField? = null + private var values: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(compositePriceFilter: CompositePriceFilter) = apply { + field = compositePriceFilter.field + operator = compositePriceFilter.operator + values = compositePriceFilter.values.map { it.toMutableList() } + additionalProperties = compositePriceFilter.additionalProperties.toMutableMap() + } + + /** The property of the price to filter on. */ + fun field(field: Field) = field(JsonField.of(field)) + + /** + * Sets [Builder.field] to an arbitrary JSON value. + * + * You should usually call [Builder.field] with a well-typed [Field] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun field(field: JsonField) = apply { this.field = field } + + /** Should prices that match the filter be included or excluded. */ + fun operator(operator: Operator) = operator(JsonField.of(operator)) + + /** + * Sets [Builder.operator] to an arbitrary JSON value. + * + * You should usually call [Builder.operator] with a well-typed [Operator] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun operator(operator: JsonField) = apply { this.operator = operator } + + /** The IDs or values that match this filter. */ + fun values(values: List) = values(JsonField.of(values)) + + /** + * Sets [Builder.values] to an arbitrary JSON value. + * + * You should usually call [Builder.values] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun values(values: JsonField>) = apply { + this.values = values.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [values]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addValue(value: String) = apply { + values = + (values ?: JsonField.of(mutableListOf())).also { + checkKnown("values", it).add(value) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CompositePriceFilter]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .field() + * .operator() + * .values() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CompositePriceFilter = + CompositePriceFilter( + checkRequired("field", field), + checkRequired("operator", operator), + checkRequired("values", values).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CompositePriceFilter = apply { + if (validated) { + return@apply + } + + field().validate() + operator().validate() + values() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (field.asKnown()?.validity() ?: 0) + + (operator.asKnown()?.validity() ?: 0) + + (values.asKnown()?.size ?: 0) + + /** The property of the price to filter on. */ + class Field @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val PRICE_ID = of("price_id") + + val ITEM_ID = of("item_id") + + val PRICE_TYPE = of("price_type") + + val CURRENCY = of("currency") + + val PRICING_UNIT_ID = of("pricing_unit_id") + + fun of(value: String) = Field(JsonField.of(value)) + } + + /** An enum containing [Field]'s known values. */ + enum class Known { + PRICE_ID, + ITEM_ID, + PRICE_TYPE, + CURRENCY, + PRICING_UNIT_ID, + } + + /** + * An enum containing [Field]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Field] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + PRICE_ID, + ITEM_ID, + PRICE_TYPE, + CURRENCY, + PRICING_UNIT_ID, + /** + * An enum member indicating that [Field] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + PRICE_ID -> Value.PRICE_ID + ITEM_ID -> Value.ITEM_ID + PRICE_TYPE -> Value.PRICE_TYPE + CURRENCY -> Value.CURRENCY + PRICING_UNIT_ID -> Value.PRICING_UNIT_ID + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + PRICE_ID -> Known.PRICE_ID + ITEM_ID -> Known.ITEM_ID + PRICE_TYPE -> Known.PRICE_TYPE + CURRENCY -> Known.CURRENCY + PRICING_UNIT_ID -> Known.PRICING_UNIT_ID + else -> throw OrbInvalidDataException("Unknown Field: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Field = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Field && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Should prices that match the filter be included or excluded. */ + class Operator @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val INCLUDES = of("includes") + + val EXCLUDES = of("excludes") + + fun of(value: String) = Operator(JsonField.of(value)) + } + + /** An enum containing [Operator]'s known values. */ + enum class Known { + INCLUDES, + EXCLUDES, + } + + /** + * An enum containing [Operator]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Operator] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + INCLUDES, + EXCLUDES, + /** + * An enum member indicating that [Operator] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + INCLUDES -> Value.INCLUDES + EXCLUDES -> Value.EXCLUDES + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + INCLUDES -> Known.INCLUDES + EXCLUDES -> Known.EXCLUDES + else -> throw OrbInvalidDataException("Unknown Operator: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Operator = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Operator && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CompositePriceFilter && + field == other.field && + operator == other.operator && + values == other.values && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(field, operator, values, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CompositePriceFilter{field=$field, operator=$operator, values=$values, additionalProperties=$additionalProperties}" + } + /** * User specified key-value pairs for the resource. If not present, this defaults to an * empty dictionary. Individual keys can be removed by setting the value to `null`, and the @@ -9851,7 +12011,7 @@ private constructor( private val billingCycleConfiguration: JsonField, private val billingMode: JsonField, private val cadence: JsonField, - private val compositePriceFilters: JsonField>, + private val compositePriceFilters: JsonField>, private val conversionRate: JsonField, private val conversionRateConfig: JsonField, private val createdAt: JsonField, @@ -9892,7 +12052,7 @@ private constructor( @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), @JsonProperty("composite_price_filters") @ExcludeMissing - compositePriceFilters: JsonField> = JsonMissing.of(), + compositePriceFilters: JsonField> = JsonMissing.of(), @JsonProperty("conversion_rate") @ExcludeMissing conversionRate: JsonField = JsonMissing.of(), @@ -10017,7 +12177,7 @@ private constructor( * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun compositePriceFilters(): List? = + fun compositePriceFilters(): List? = compositePriceFilters.getNullable("composite_price_filters") /** @@ -10228,7 +12388,7 @@ private constructor( */ @JsonProperty("composite_price_filters") @ExcludeMissing - fun _compositePriceFilters(): JsonField> = compositePriceFilters + fun _compositePriceFilters(): JsonField> = compositePriceFilters /** * Returns the raw JSON value of [conversionRate]. @@ -10488,7 +12648,7 @@ private constructor( private var billingCycleConfiguration: JsonField? = null private var billingMode: JsonField? = null private var cadence: JsonField? = null - private var compositePriceFilters: JsonField>? = null + private var compositePriceFilters: JsonField>? = null private var conversionRate: JsonField? = null private var conversionRateConfig: JsonField? = null private var createdAt: JsonField? = null @@ -10609,28 +12769,28 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - fun compositePriceFilters(compositePriceFilters: List?) = + fun compositePriceFilters(compositePriceFilters: List?) = compositePriceFilters(JsonField.ofNullable(compositePriceFilters)) /** * Sets [Builder.compositePriceFilters] to an arbitrary JSON value. * * You should usually call [Builder.compositePriceFilters] with a well-typed - * `List` value instead. This method is primarily for setting the + * `List` value instead. This method is primarily for setting the * field to an undocumented or not yet supported value. */ fun compositePriceFilters( - compositePriceFilters: JsonField> + compositePriceFilters: JsonField> ) = apply { this.compositePriceFilters = compositePriceFilters.map { it.toMutableList() } } /** - * Adds a single [TransformPriceFilter] to [compositePriceFilters]. + * Adds a single [CompositePriceFilter] to [compositePriceFilters]. * * @throws IllegalStateException if the field was previously set to a non-list. */ - fun addCompositePriceFilter(compositePriceFilter: TransformPriceFilter) = apply { + fun addCompositePriceFilter(compositePriceFilter: CompositePriceFilter) = apply { compositePriceFilters = (compositePriceFilters ?: JsonField.of(mutableListOf())).also { checkKnown("compositePriceFilters", it).add(compositePriceFilter) @@ -11546,6 +13706,546 @@ private constructor( override fun toString() = value.toString() } + class CompositePriceFilter + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val field: JsonField, + private val operator: JsonField, + private val values: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("field") @ExcludeMissing field: JsonField = JsonMissing.of(), + @JsonProperty("operator") + @ExcludeMissing + operator: JsonField = JsonMissing.of(), + @JsonProperty("values") + @ExcludeMissing + values: JsonField> = JsonMissing.of(), + ) : this(field, operator, values, mutableMapOf()) + + /** + * The property of the price to filter on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun field(): Field = field.getRequired("field") + + /** + * Should prices that match the filter be included or excluded. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun operator(): Operator = operator.getRequired("operator") + + /** + * The IDs or values that match this filter. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun values(): List = values.getRequired("values") + + /** + * Returns the raw JSON value of [field]. + * + * Unlike [field], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("field") @ExcludeMissing fun _field(): JsonField = field + + /** + * Returns the raw JSON value of [operator]. + * + * Unlike [operator], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("operator") + @ExcludeMissing + fun _operator(): JsonField = operator + + /** + * Returns the raw JSON value of [values]. + * + * Unlike [values], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("values") @ExcludeMissing fun _values(): JsonField> = values + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [CompositePriceFilter]. + * + * The following fields are required: + * ```kotlin + * .field() + * .operator() + * .values() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [CompositePriceFilter]. */ + class Builder internal constructor() { + + private var field: JsonField? = null + private var operator: JsonField? = null + private var values: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(compositePriceFilter: CompositePriceFilter) = apply { + field = compositePriceFilter.field + operator = compositePriceFilter.operator + values = compositePriceFilter.values.map { it.toMutableList() } + additionalProperties = compositePriceFilter.additionalProperties.toMutableMap() + } + + /** The property of the price to filter on. */ + fun field(field: Field) = field(JsonField.of(field)) + + /** + * Sets [Builder.field] to an arbitrary JSON value. + * + * You should usually call [Builder.field] with a well-typed [Field] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun field(field: JsonField) = apply { this.field = field } + + /** Should prices that match the filter be included or excluded. */ + fun operator(operator: Operator) = operator(JsonField.of(operator)) + + /** + * Sets [Builder.operator] to an arbitrary JSON value. + * + * You should usually call [Builder.operator] with a well-typed [Operator] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun operator(operator: JsonField) = apply { this.operator = operator } + + /** The IDs or values that match this filter. */ + fun values(values: List) = values(JsonField.of(values)) + + /** + * Sets [Builder.values] to an arbitrary JSON value. + * + * You should usually call [Builder.values] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun values(values: JsonField>) = apply { + this.values = values.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [values]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addValue(value: String) = apply { + values = + (values ?: JsonField.of(mutableListOf())).also { + checkKnown("values", it).add(value) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CompositePriceFilter]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .field() + * .operator() + * .values() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CompositePriceFilter = + CompositePriceFilter( + checkRequired("field", field), + checkRequired("operator", operator), + checkRequired("values", values).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CompositePriceFilter = apply { + if (validated) { + return@apply + } + + field().validate() + operator().validate() + values() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (field.asKnown()?.validity() ?: 0) + + (operator.asKnown()?.validity() ?: 0) + + (values.asKnown()?.size ?: 0) + + /** The property of the price to filter on. */ + class Field @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val PRICE_ID = of("price_id") + + val ITEM_ID = of("item_id") + + val PRICE_TYPE = of("price_type") + + val CURRENCY = of("currency") + + val PRICING_UNIT_ID = of("pricing_unit_id") + + fun of(value: String) = Field(JsonField.of(value)) + } + + /** An enum containing [Field]'s known values. */ + enum class Known { + PRICE_ID, + ITEM_ID, + PRICE_TYPE, + CURRENCY, + PRICING_UNIT_ID, + } + + /** + * An enum containing [Field]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Field] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + PRICE_ID, + ITEM_ID, + PRICE_TYPE, + CURRENCY, + PRICING_UNIT_ID, + /** + * An enum member indicating that [Field] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + PRICE_ID -> Value.PRICE_ID + ITEM_ID -> Value.ITEM_ID + PRICE_TYPE -> Value.PRICE_TYPE + CURRENCY -> Value.CURRENCY + PRICING_UNIT_ID -> Value.PRICING_UNIT_ID + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + PRICE_ID -> Known.PRICE_ID + ITEM_ID -> Known.ITEM_ID + PRICE_TYPE -> Known.PRICE_TYPE + CURRENCY -> Known.CURRENCY + PRICING_UNIT_ID -> Known.PRICING_UNIT_ID + else -> throw OrbInvalidDataException("Unknown Field: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Field = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Field && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Should prices that match the filter be included or excluded. */ + class Operator @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val INCLUDES = of("includes") + + val EXCLUDES = of("excludes") + + fun of(value: String) = Operator(JsonField.of(value)) + } + + /** An enum containing [Operator]'s known values. */ + enum class Known { + INCLUDES, + EXCLUDES, + } + + /** + * An enum containing [Operator]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Operator] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + INCLUDES, + EXCLUDES, + /** + * An enum member indicating that [Operator] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + INCLUDES -> Value.INCLUDES + EXCLUDES -> Value.EXCLUDES + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + INCLUDES -> Known.INCLUDES + EXCLUDES -> Known.EXCLUDES + else -> throw OrbInvalidDataException("Unknown Operator: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Operator = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Operator && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CompositePriceFilter && + field == other.field && + operator == other.operator && + values == other.values && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(field, operator, values, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CompositePriceFilter{field=$field, operator=$operator, values=$values, additionalProperties=$additionalProperties}" + } + /** * User specified key-value pairs for the resource. If not present, this defaults to an * empty dictionary. Individual keys can be removed by setting the value to `null`, and the @@ -11871,7 +14571,7 @@ private constructor( private val billingCycleConfiguration: JsonField, private val billingMode: JsonField, private val cadence: JsonField, - private val compositePriceFilters: JsonField>, + private val compositePriceFilters: JsonField>, private val conversionRate: JsonField, private val conversionRateConfig: JsonField, private val createdAt: JsonField, @@ -11912,7 +14612,7 @@ private constructor( @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), @JsonProperty("composite_price_filters") @ExcludeMissing - compositePriceFilters: JsonField> = JsonMissing.of(), + compositePriceFilters: JsonField> = JsonMissing.of(), @JsonProperty("conversion_rate") @ExcludeMissing conversionRate: JsonField = JsonMissing.of(), @@ -12037,7 +14737,7 @@ private constructor( * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun compositePriceFilters(): List? = + fun compositePriceFilters(): List? = compositePriceFilters.getNullable("composite_price_filters") /** @@ -12248,7 +14948,7 @@ private constructor( */ @JsonProperty("composite_price_filters") @ExcludeMissing - fun _compositePriceFilters(): JsonField> = compositePriceFilters + fun _compositePriceFilters(): JsonField> = compositePriceFilters /** * Returns the raw JSON value of [conversionRate]. @@ -12508,7 +15208,7 @@ private constructor( private var billingCycleConfiguration: JsonField? = null private var billingMode: JsonField? = null private var cadence: JsonField? = null - private var compositePriceFilters: JsonField>? = null + private var compositePriceFilters: JsonField>? = null private var conversionRate: JsonField? = null private var conversionRateConfig: JsonField? = null private var createdAt: JsonField? = null @@ -12629,28 +15329,28 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - fun compositePriceFilters(compositePriceFilters: List?) = + fun compositePriceFilters(compositePriceFilters: List?) = compositePriceFilters(JsonField.ofNullable(compositePriceFilters)) /** * Sets [Builder.compositePriceFilters] to an arbitrary JSON value. * * You should usually call [Builder.compositePriceFilters] with a well-typed - * `List` value instead. This method is primarily for setting the + * `List` value instead. This method is primarily for setting the * field to an undocumented or not yet supported value. */ fun compositePriceFilters( - compositePriceFilters: JsonField> + compositePriceFilters: JsonField> ) = apply { this.compositePriceFilters = compositePriceFilters.map { it.toMutableList() } } /** - * Adds a single [TransformPriceFilter] to [compositePriceFilters]. + * Adds a single [CompositePriceFilter] to [compositePriceFilters]. * * @throws IllegalStateException if the field was previously set to a non-list. */ - fun addCompositePriceFilter(compositePriceFilter: TransformPriceFilter) = apply { + fun addCompositePriceFilter(compositePriceFilter: CompositePriceFilter) = apply { compositePriceFilters = (compositePriceFilters ?: JsonField.of(mutableListOf())).also { checkKnown("compositePriceFilters", it).add(compositePriceFilter) @@ -13565,6 +16265,546 @@ private constructor( override fun toString() = value.toString() } + class CompositePriceFilter + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val field: JsonField, + private val operator: JsonField, + private val values: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("field") @ExcludeMissing field: JsonField = JsonMissing.of(), + @JsonProperty("operator") + @ExcludeMissing + operator: JsonField = JsonMissing.of(), + @JsonProperty("values") + @ExcludeMissing + values: JsonField> = JsonMissing.of(), + ) : this(field, operator, values, mutableMapOf()) + + /** + * The property of the price to filter on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun field(): Field = field.getRequired("field") + + /** + * Should prices that match the filter be included or excluded. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun operator(): Operator = operator.getRequired("operator") + + /** + * The IDs or values that match this filter. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun values(): List = values.getRequired("values") + + /** + * Returns the raw JSON value of [field]. + * + * Unlike [field], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("field") @ExcludeMissing fun _field(): JsonField = field + + /** + * Returns the raw JSON value of [operator]. + * + * Unlike [operator], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("operator") + @ExcludeMissing + fun _operator(): JsonField = operator + + /** + * Returns the raw JSON value of [values]. + * + * Unlike [values], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("values") @ExcludeMissing fun _values(): JsonField> = values + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [CompositePriceFilter]. + * + * The following fields are required: + * ```kotlin + * .field() + * .operator() + * .values() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [CompositePriceFilter]. */ + class Builder internal constructor() { + + private var field: JsonField? = null + private var operator: JsonField? = null + private var values: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(compositePriceFilter: CompositePriceFilter) = apply { + field = compositePriceFilter.field + operator = compositePriceFilter.operator + values = compositePriceFilter.values.map { it.toMutableList() } + additionalProperties = compositePriceFilter.additionalProperties.toMutableMap() + } + + /** The property of the price to filter on. */ + fun field(field: Field) = field(JsonField.of(field)) + + /** + * Sets [Builder.field] to an arbitrary JSON value. + * + * You should usually call [Builder.field] with a well-typed [Field] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun field(field: JsonField) = apply { this.field = field } + + /** Should prices that match the filter be included or excluded. */ + fun operator(operator: Operator) = operator(JsonField.of(operator)) + + /** + * Sets [Builder.operator] to an arbitrary JSON value. + * + * You should usually call [Builder.operator] with a well-typed [Operator] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun operator(operator: JsonField) = apply { this.operator = operator } + + /** The IDs or values that match this filter. */ + fun values(values: List) = values(JsonField.of(values)) + + /** + * Sets [Builder.values] to an arbitrary JSON value. + * + * You should usually call [Builder.values] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun values(values: JsonField>) = apply { + this.values = values.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [values]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addValue(value: String) = apply { + values = + (values ?: JsonField.of(mutableListOf())).also { + checkKnown("values", it).add(value) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CompositePriceFilter]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .field() + * .operator() + * .values() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CompositePriceFilter = + CompositePriceFilter( + checkRequired("field", field), + checkRequired("operator", operator), + checkRequired("values", values).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CompositePriceFilter = apply { + if (validated) { + return@apply + } + + field().validate() + operator().validate() + values() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (field.asKnown()?.validity() ?: 0) + + (operator.asKnown()?.validity() ?: 0) + + (values.asKnown()?.size ?: 0) + + /** The property of the price to filter on. */ + class Field @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val PRICE_ID = of("price_id") + + val ITEM_ID = of("item_id") + + val PRICE_TYPE = of("price_type") + + val CURRENCY = of("currency") + + val PRICING_UNIT_ID = of("pricing_unit_id") + + fun of(value: String) = Field(JsonField.of(value)) + } + + /** An enum containing [Field]'s known values. */ + enum class Known { + PRICE_ID, + ITEM_ID, + PRICE_TYPE, + CURRENCY, + PRICING_UNIT_ID, + } + + /** + * An enum containing [Field]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Field] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + PRICE_ID, + ITEM_ID, + PRICE_TYPE, + CURRENCY, + PRICING_UNIT_ID, + /** + * An enum member indicating that [Field] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + PRICE_ID -> Value.PRICE_ID + ITEM_ID -> Value.ITEM_ID + PRICE_TYPE -> Value.PRICE_TYPE + CURRENCY -> Value.CURRENCY + PRICING_UNIT_ID -> Value.PRICING_UNIT_ID + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + PRICE_ID -> Known.PRICE_ID + ITEM_ID -> Known.ITEM_ID + PRICE_TYPE -> Known.PRICE_TYPE + CURRENCY -> Known.CURRENCY + PRICING_UNIT_ID -> Known.PRICING_UNIT_ID + else -> throw OrbInvalidDataException("Unknown Field: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Field = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Field && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Should prices that match the filter be included or excluded. */ + class Operator @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val INCLUDES = of("includes") + + val EXCLUDES = of("excludes") + + fun of(value: String) = Operator(JsonField.of(value)) + } + + /** An enum containing [Operator]'s known values. */ + enum class Known { + INCLUDES, + EXCLUDES, + } + + /** + * An enum containing [Operator]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Operator] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + INCLUDES, + EXCLUDES, + /** + * An enum member indicating that [Operator] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + INCLUDES -> Value.INCLUDES + EXCLUDES -> Value.EXCLUDES + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + INCLUDES -> Known.INCLUDES + EXCLUDES -> Known.EXCLUDES + else -> throw OrbInvalidDataException("Unknown Operator: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Operator = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Operator && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CompositePriceFilter && + field == other.field && + operator == other.operator && + values == other.values && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(field, operator, values, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CompositePriceFilter{field=$field, operator=$operator, values=$values, additionalProperties=$additionalProperties}" + } + /** * User specified key-value pairs for the resource. If not present, this defaults to an * empty dictionary. Individual keys can be removed by setting the value to `null`, and the @@ -13890,7 +17130,7 @@ private constructor( private val billingCycleConfiguration: JsonField, private val billingMode: JsonField, private val cadence: JsonField, - private val compositePriceFilters: JsonField>, + private val compositePriceFilters: JsonField>, private val conversionRate: JsonField, private val conversionRateConfig: JsonField, private val createdAt: JsonField, @@ -13931,7 +17171,7 @@ private constructor( @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), @JsonProperty("composite_price_filters") @ExcludeMissing - compositePriceFilters: JsonField> = JsonMissing.of(), + compositePriceFilters: JsonField> = JsonMissing.of(), @JsonProperty("conversion_rate") @ExcludeMissing conversionRate: JsonField = JsonMissing.of(), @@ -14056,7 +17296,7 @@ private constructor( * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun compositePriceFilters(): List? = + fun compositePriceFilters(): List? = compositePriceFilters.getNullable("composite_price_filters") /** @@ -14268,7 +17508,7 @@ private constructor( */ @JsonProperty("composite_price_filters") @ExcludeMissing - fun _compositePriceFilters(): JsonField> = compositePriceFilters + fun _compositePriceFilters(): JsonField> = compositePriceFilters /** * Returns the raw JSON value of [conversionRate]. @@ -14529,7 +17769,7 @@ private constructor( private var billingCycleConfiguration: JsonField? = null private var billingMode: JsonField? = null private var cadence: JsonField? = null - private var compositePriceFilters: JsonField>? = null + private var compositePriceFilters: JsonField>? = null private var conversionRate: JsonField? = null private var conversionRateConfig: JsonField? = null private var createdAt: JsonField? = null @@ -14651,28 +17891,28 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - fun compositePriceFilters(compositePriceFilters: List?) = + fun compositePriceFilters(compositePriceFilters: List?) = compositePriceFilters(JsonField.ofNullable(compositePriceFilters)) /** * Sets [Builder.compositePriceFilters] to an arbitrary JSON value. * * You should usually call [Builder.compositePriceFilters] with a well-typed - * `List` value instead. This method is primarily for setting the + * `List` value instead. This method is primarily for setting the * field to an undocumented or not yet supported value. */ fun compositePriceFilters( - compositePriceFilters: JsonField> + compositePriceFilters: JsonField> ) = apply { this.compositePriceFilters = compositePriceFilters.map { it.toMutableList() } } /** - * Adds a single [TransformPriceFilter] to [compositePriceFilters]. + * Adds a single [CompositePriceFilter] to [compositePriceFilters]. * * @throws IllegalStateException if the field was previously set to a non-list. */ - fun addCompositePriceFilter(compositePriceFilter: TransformPriceFilter) = apply { + fun addCompositePriceFilter(compositePriceFilter: CompositePriceFilter) = apply { compositePriceFilters = (compositePriceFilters ?: JsonField.of(mutableListOf())).also { checkKnown("compositePriceFilters", it).add(compositePriceFilter) @@ -15588,6 +18828,546 @@ private constructor( override fun toString() = value.toString() } + class CompositePriceFilter + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val field: JsonField, + private val operator: JsonField, + private val values: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("field") @ExcludeMissing field: JsonField = JsonMissing.of(), + @JsonProperty("operator") + @ExcludeMissing + operator: JsonField = JsonMissing.of(), + @JsonProperty("values") + @ExcludeMissing + values: JsonField> = JsonMissing.of(), + ) : this(field, operator, values, mutableMapOf()) + + /** + * The property of the price to filter on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun field(): Field = field.getRequired("field") + + /** + * Should prices that match the filter be included or excluded. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun operator(): Operator = operator.getRequired("operator") + + /** + * The IDs or values that match this filter. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun values(): List = values.getRequired("values") + + /** + * Returns the raw JSON value of [field]. + * + * Unlike [field], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("field") @ExcludeMissing fun _field(): JsonField = field + + /** + * Returns the raw JSON value of [operator]. + * + * Unlike [operator], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("operator") + @ExcludeMissing + fun _operator(): JsonField = operator + + /** + * Returns the raw JSON value of [values]. + * + * Unlike [values], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("values") @ExcludeMissing fun _values(): JsonField> = values + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [CompositePriceFilter]. + * + * The following fields are required: + * ```kotlin + * .field() + * .operator() + * .values() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [CompositePriceFilter]. */ + class Builder internal constructor() { + + private var field: JsonField? = null + private var operator: JsonField? = null + private var values: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(compositePriceFilter: CompositePriceFilter) = apply { + field = compositePriceFilter.field + operator = compositePriceFilter.operator + values = compositePriceFilter.values.map { it.toMutableList() } + additionalProperties = compositePriceFilter.additionalProperties.toMutableMap() + } + + /** The property of the price to filter on. */ + fun field(field: Field) = field(JsonField.of(field)) + + /** + * Sets [Builder.field] to an arbitrary JSON value. + * + * You should usually call [Builder.field] with a well-typed [Field] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun field(field: JsonField) = apply { this.field = field } + + /** Should prices that match the filter be included or excluded. */ + fun operator(operator: Operator) = operator(JsonField.of(operator)) + + /** + * Sets [Builder.operator] to an arbitrary JSON value. + * + * You should usually call [Builder.operator] with a well-typed [Operator] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun operator(operator: JsonField) = apply { this.operator = operator } + + /** The IDs or values that match this filter. */ + fun values(values: List) = values(JsonField.of(values)) + + /** + * Sets [Builder.values] to an arbitrary JSON value. + * + * You should usually call [Builder.values] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun values(values: JsonField>) = apply { + this.values = values.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [values]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addValue(value: String) = apply { + values = + (values ?: JsonField.of(mutableListOf())).also { + checkKnown("values", it).add(value) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CompositePriceFilter]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .field() + * .operator() + * .values() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CompositePriceFilter = + CompositePriceFilter( + checkRequired("field", field), + checkRequired("operator", operator), + checkRequired("values", values).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CompositePriceFilter = apply { + if (validated) { + return@apply + } + + field().validate() + operator().validate() + values() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (field.asKnown()?.validity() ?: 0) + + (operator.asKnown()?.validity() ?: 0) + + (values.asKnown()?.size ?: 0) + + /** The property of the price to filter on. */ + class Field @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val PRICE_ID = of("price_id") + + val ITEM_ID = of("item_id") + + val PRICE_TYPE = of("price_type") + + val CURRENCY = of("currency") + + val PRICING_UNIT_ID = of("pricing_unit_id") + + fun of(value: String) = Field(JsonField.of(value)) + } + + /** An enum containing [Field]'s known values. */ + enum class Known { + PRICE_ID, + ITEM_ID, + PRICE_TYPE, + CURRENCY, + PRICING_UNIT_ID, + } + + /** + * An enum containing [Field]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Field] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + PRICE_ID, + ITEM_ID, + PRICE_TYPE, + CURRENCY, + PRICING_UNIT_ID, + /** + * An enum member indicating that [Field] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + PRICE_ID -> Value.PRICE_ID + ITEM_ID -> Value.ITEM_ID + PRICE_TYPE -> Value.PRICE_TYPE + CURRENCY -> Value.CURRENCY + PRICING_UNIT_ID -> Value.PRICING_UNIT_ID + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + PRICE_ID -> Known.PRICE_ID + ITEM_ID -> Known.ITEM_ID + PRICE_TYPE -> Known.PRICE_TYPE + CURRENCY -> Known.CURRENCY + PRICING_UNIT_ID -> Known.PRICING_UNIT_ID + else -> throw OrbInvalidDataException("Unknown Field: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Field = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Field && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Should prices that match the filter be included or excluded. */ + class Operator @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val INCLUDES = of("includes") + + val EXCLUDES = of("excludes") + + fun of(value: String) = Operator(JsonField.of(value)) + } + + /** An enum containing [Operator]'s known values. */ + enum class Known { + INCLUDES, + EXCLUDES, + } + + /** + * An enum containing [Operator]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Operator] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + INCLUDES, + EXCLUDES, + /** + * An enum member indicating that [Operator] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + INCLUDES -> Value.INCLUDES + EXCLUDES -> Value.EXCLUDES + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + INCLUDES -> Known.INCLUDES + EXCLUDES -> Known.EXCLUDES + else -> throw OrbInvalidDataException("Unknown Operator: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Operator = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Operator && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CompositePriceFilter && + field == other.field && + operator == other.operator && + values == other.values && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(field, operator, values, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CompositePriceFilter{field=$field, operator=$operator, values=$values, additionalProperties=$additionalProperties}" + } + /** * User specified key-value pairs for the resource. If not present, this defaults to an * empty dictionary. Individual keys can be removed by setting the value to `null`, and the @@ -16371,7 +20151,7 @@ private constructor( private val billingCycleConfiguration: JsonField, private val billingMode: JsonField, private val cadence: JsonField, - private val compositePriceFilters: JsonField>, + private val compositePriceFilters: JsonField>, private val conversionRate: JsonField, private val conversionRateConfig: JsonField, private val createdAt: JsonField, @@ -16412,7 +20192,7 @@ private constructor( @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), @JsonProperty("composite_price_filters") @ExcludeMissing - compositePriceFilters: JsonField> = JsonMissing.of(), + compositePriceFilters: JsonField> = JsonMissing.of(), @JsonProperty("conversion_rate") @ExcludeMissing conversionRate: JsonField = JsonMissing.of(), @@ -16537,7 +20317,7 @@ private constructor( * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun compositePriceFilters(): List? = + fun compositePriceFilters(): List? = compositePriceFilters.getNullable("composite_price_filters") /** @@ -16749,7 +20529,7 @@ private constructor( */ @JsonProperty("composite_price_filters") @ExcludeMissing - fun _compositePriceFilters(): JsonField> = compositePriceFilters + fun _compositePriceFilters(): JsonField> = compositePriceFilters /** * Returns the raw JSON value of [conversionRate]. @@ -17009,7 +20789,7 @@ private constructor( private var billingCycleConfiguration: JsonField? = null private var billingMode: JsonField? = null private var cadence: JsonField? = null - private var compositePriceFilters: JsonField>? = null + private var compositePriceFilters: JsonField>? = null private var conversionRate: JsonField? = null private var conversionRateConfig: JsonField? = null private var createdAt: JsonField? = null @@ -17131,28 +20911,28 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - fun compositePriceFilters(compositePriceFilters: List?) = + fun compositePriceFilters(compositePriceFilters: List?) = compositePriceFilters(JsonField.ofNullable(compositePriceFilters)) /** * Sets [Builder.compositePriceFilters] to an arbitrary JSON value. * * You should usually call [Builder.compositePriceFilters] with a well-typed - * `List` value instead. This method is primarily for setting the + * `List` value instead. This method is primarily for setting the * field to an undocumented or not yet supported value. */ fun compositePriceFilters( - compositePriceFilters: JsonField> + compositePriceFilters: JsonField> ) = apply { this.compositePriceFilters = compositePriceFilters.map { it.toMutableList() } } /** - * Adds a single [TransformPriceFilter] to [compositePriceFilters]. + * Adds a single [CompositePriceFilter] to [compositePriceFilters]. * * @throws IllegalStateException if the field was previously set to a non-list. */ - fun addCompositePriceFilter(compositePriceFilter: TransformPriceFilter) = apply { + fun addCompositePriceFilter(compositePriceFilter: CompositePriceFilter) = apply { compositePriceFilters = (compositePriceFilters ?: JsonField.of(mutableListOf())).also { checkKnown("compositePriceFilters", it).add(compositePriceFilter) @@ -18068,6 +21848,546 @@ private constructor( override fun toString() = value.toString() } + class CompositePriceFilter + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val field: JsonField, + private val operator: JsonField, + private val values: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("field") @ExcludeMissing field: JsonField = JsonMissing.of(), + @JsonProperty("operator") + @ExcludeMissing + operator: JsonField = JsonMissing.of(), + @JsonProperty("values") + @ExcludeMissing + values: JsonField> = JsonMissing.of(), + ) : this(field, operator, values, mutableMapOf()) + + /** + * The property of the price to filter on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun field(): Field = field.getRequired("field") + + /** + * Should prices that match the filter be included or excluded. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun operator(): Operator = operator.getRequired("operator") + + /** + * The IDs or values that match this filter. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun values(): List = values.getRequired("values") + + /** + * Returns the raw JSON value of [field]. + * + * Unlike [field], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("field") @ExcludeMissing fun _field(): JsonField = field + + /** + * Returns the raw JSON value of [operator]. + * + * Unlike [operator], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("operator") + @ExcludeMissing + fun _operator(): JsonField = operator + + /** + * Returns the raw JSON value of [values]. + * + * Unlike [values], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("values") @ExcludeMissing fun _values(): JsonField> = values + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [CompositePriceFilter]. + * + * The following fields are required: + * ```kotlin + * .field() + * .operator() + * .values() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [CompositePriceFilter]. */ + class Builder internal constructor() { + + private var field: JsonField? = null + private var operator: JsonField? = null + private var values: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(compositePriceFilter: CompositePriceFilter) = apply { + field = compositePriceFilter.field + operator = compositePriceFilter.operator + values = compositePriceFilter.values.map { it.toMutableList() } + additionalProperties = compositePriceFilter.additionalProperties.toMutableMap() + } + + /** The property of the price to filter on. */ + fun field(field: Field) = field(JsonField.of(field)) + + /** + * Sets [Builder.field] to an arbitrary JSON value. + * + * You should usually call [Builder.field] with a well-typed [Field] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun field(field: JsonField) = apply { this.field = field } + + /** Should prices that match the filter be included or excluded. */ + fun operator(operator: Operator) = operator(JsonField.of(operator)) + + /** + * Sets [Builder.operator] to an arbitrary JSON value. + * + * You should usually call [Builder.operator] with a well-typed [Operator] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun operator(operator: JsonField) = apply { this.operator = operator } + + /** The IDs or values that match this filter. */ + fun values(values: List) = values(JsonField.of(values)) + + /** + * Sets [Builder.values] to an arbitrary JSON value. + * + * You should usually call [Builder.values] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun values(values: JsonField>) = apply { + this.values = values.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [values]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addValue(value: String) = apply { + values = + (values ?: JsonField.of(mutableListOf())).also { + checkKnown("values", it).add(value) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CompositePriceFilter]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .field() + * .operator() + * .values() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CompositePriceFilter = + CompositePriceFilter( + checkRequired("field", field), + checkRequired("operator", operator), + checkRequired("values", values).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CompositePriceFilter = apply { + if (validated) { + return@apply + } + + field().validate() + operator().validate() + values() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (field.asKnown()?.validity() ?: 0) + + (operator.asKnown()?.validity() ?: 0) + + (values.asKnown()?.size ?: 0) + + /** The property of the price to filter on. */ + class Field @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val PRICE_ID = of("price_id") + + val ITEM_ID = of("item_id") + + val PRICE_TYPE = of("price_type") + + val CURRENCY = of("currency") + + val PRICING_UNIT_ID = of("pricing_unit_id") + + fun of(value: String) = Field(JsonField.of(value)) + } + + /** An enum containing [Field]'s known values. */ + enum class Known { + PRICE_ID, + ITEM_ID, + PRICE_TYPE, + CURRENCY, + PRICING_UNIT_ID, + } + + /** + * An enum containing [Field]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Field] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + PRICE_ID, + ITEM_ID, + PRICE_TYPE, + CURRENCY, + PRICING_UNIT_ID, + /** + * An enum member indicating that [Field] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + PRICE_ID -> Value.PRICE_ID + ITEM_ID -> Value.ITEM_ID + PRICE_TYPE -> Value.PRICE_TYPE + CURRENCY -> Value.CURRENCY + PRICING_UNIT_ID -> Value.PRICING_UNIT_ID + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + PRICE_ID -> Known.PRICE_ID + ITEM_ID -> Known.ITEM_ID + PRICE_TYPE -> Known.PRICE_TYPE + CURRENCY -> Known.CURRENCY + PRICING_UNIT_ID -> Known.PRICING_UNIT_ID + else -> throw OrbInvalidDataException("Unknown Field: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Field = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Field && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Should prices that match the filter be included or excluded. */ + class Operator @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val INCLUDES = of("includes") + + val EXCLUDES = of("excludes") + + fun of(value: String) = Operator(JsonField.of(value)) + } + + /** An enum containing [Operator]'s known values. */ + enum class Known { + INCLUDES, + EXCLUDES, + } + + /** + * An enum containing [Operator]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Operator] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + INCLUDES, + EXCLUDES, + /** + * An enum member indicating that [Operator] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + INCLUDES -> Value.INCLUDES + EXCLUDES -> Value.EXCLUDES + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + INCLUDES -> Known.INCLUDES + EXCLUDES -> Known.EXCLUDES + else -> throw OrbInvalidDataException("Unknown Operator: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Operator = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Operator && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CompositePriceFilter && + field == other.field && + operator == other.operator && + values == other.values && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(field, operator, values, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CompositePriceFilter{field=$field, operator=$operator, values=$values, additionalProperties=$additionalProperties}" + } + /** * User specified key-value pairs for the resource. If not present, this defaults to an * empty dictionary. Individual keys can be removed by setting the value to `null`, and the @@ -18845,7 +23165,7 @@ private constructor( private val billingCycleConfiguration: JsonField, private val billingMode: JsonField, private val cadence: JsonField, - private val compositePriceFilters: JsonField>, + private val compositePriceFilters: JsonField>, private val conversionRate: JsonField, private val conversionRateConfig: JsonField, private val createdAt: JsonField, @@ -18886,7 +23206,7 @@ private constructor( @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), @JsonProperty("composite_price_filters") @ExcludeMissing - compositePriceFilters: JsonField> = JsonMissing.of(), + compositePriceFilters: JsonField> = JsonMissing.of(), @JsonProperty("conversion_rate") @ExcludeMissing conversionRate: JsonField = JsonMissing.of(), @@ -19011,7 +23331,7 @@ private constructor( * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun compositePriceFilters(): List? = + fun compositePriceFilters(): List? = compositePriceFilters.getNullable("composite_price_filters") /** @@ -19223,7 +23543,7 @@ private constructor( */ @JsonProperty("composite_price_filters") @ExcludeMissing - fun _compositePriceFilters(): JsonField> = compositePriceFilters + fun _compositePriceFilters(): JsonField> = compositePriceFilters /** * Returns the raw JSON value of [conversionRate]. @@ -19483,7 +23803,7 @@ private constructor( private var billingCycleConfiguration: JsonField? = null private var billingMode: JsonField? = null private var cadence: JsonField? = null - private var compositePriceFilters: JsonField>? = null + private var compositePriceFilters: JsonField>? = null private var conversionRate: JsonField? = null private var conversionRateConfig: JsonField? = null private var createdAt: JsonField? = null @@ -19605,28 +23925,28 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - fun compositePriceFilters(compositePriceFilters: List?) = + fun compositePriceFilters(compositePriceFilters: List?) = compositePriceFilters(JsonField.ofNullable(compositePriceFilters)) /** * Sets [Builder.compositePriceFilters] to an arbitrary JSON value. * * You should usually call [Builder.compositePriceFilters] with a well-typed - * `List` value instead. This method is primarily for setting the + * `List` value instead. This method is primarily for setting the * field to an undocumented or not yet supported value. */ fun compositePriceFilters( - compositePriceFilters: JsonField> + compositePriceFilters: JsonField> ) = apply { this.compositePriceFilters = compositePriceFilters.map { it.toMutableList() } } /** - * Adds a single [TransformPriceFilter] to [compositePriceFilters]. + * Adds a single [CompositePriceFilter] to [compositePriceFilters]. * * @throws IllegalStateException if the field was previously set to a non-list. */ - fun addCompositePriceFilter(compositePriceFilter: TransformPriceFilter) = apply { + fun addCompositePriceFilter(compositePriceFilter: CompositePriceFilter) = apply { compositePriceFilters = (compositePriceFilters ?: JsonField.of(mutableListOf())).also { checkKnown("compositePriceFilters", it).add(compositePriceFilter) @@ -20542,6 +24862,546 @@ private constructor( override fun toString() = value.toString() } + class CompositePriceFilter + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val field: JsonField, + private val operator: JsonField, + private val values: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("field") @ExcludeMissing field: JsonField = JsonMissing.of(), + @JsonProperty("operator") + @ExcludeMissing + operator: JsonField = JsonMissing.of(), + @JsonProperty("values") + @ExcludeMissing + values: JsonField> = JsonMissing.of(), + ) : this(field, operator, values, mutableMapOf()) + + /** + * The property of the price to filter on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun field(): Field = field.getRequired("field") + + /** + * Should prices that match the filter be included or excluded. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun operator(): Operator = operator.getRequired("operator") + + /** + * The IDs or values that match this filter. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun values(): List = values.getRequired("values") + + /** + * Returns the raw JSON value of [field]. + * + * Unlike [field], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("field") @ExcludeMissing fun _field(): JsonField = field + + /** + * Returns the raw JSON value of [operator]. + * + * Unlike [operator], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("operator") + @ExcludeMissing + fun _operator(): JsonField = operator + + /** + * Returns the raw JSON value of [values]. + * + * Unlike [values], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("values") @ExcludeMissing fun _values(): JsonField> = values + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [CompositePriceFilter]. + * + * The following fields are required: + * ```kotlin + * .field() + * .operator() + * .values() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [CompositePriceFilter]. */ + class Builder internal constructor() { + + private var field: JsonField? = null + private var operator: JsonField? = null + private var values: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(compositePriceFilter: CompositePriceFilter) = apply { + field = compositePriceFilter.field + operator = compositePriceFilter.operator + values = compositePriceFilter.values.map { it.toMutableList() } + additionalProperties = compositePriceFilter.additionalProperties.toMutableMap() + } + + /** The property of the price to filter on. */ + fun field(field: Field) = field(JsonField.of(field)) + + /** + * Sets [Builder.field] to an arbitrary JSON value. + * + * You should usually call [Builder.field] with a well-typed [Field] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun field(field: JsonField) = apply { this.field = field } + + /** Should prices that match the filter be included or excluded. */ + fun operator(operator: Operator) = operator(JsonField.of(operator)) + + /** + * Sets [Builder.operator] to an arbitrary JSON value. + * + * You should usually call [Builder.operator] with a well-typed [Operator] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun operator(operator: JsonField) = apply { this.operator = operator } + + /** The IDs or values that match this filter. */ + fun values(values: List) = values(JsonField.of(values)) + + /** + * Sets [Builder.values] to an arbitrary JSON value. + * + * You should usually call [Builder.values] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun values(values: JsonField>) = apply { + this.values = values.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [values]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addValue(value: String) = apply { + values = + (values ?: JsonField.of(mutableListOf())).also { + checkKnown("values", it).add(value) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CompositePriceFilter]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .field() + * .operator() + * .values() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CompositePriceFilter = + CompositePriceFilter( + checkRequired("field", field), + checkRequired("operator", operator), + checkRequired("values", values).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CompositePriceFilter = apply { + if (validated) { + return@apply + } + + field().validate() + operator().validate() + values() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (field.asKnown()?.validity() ?: 0) + + (operator.asKnown()?.validity() ?: 0) + + (values.asKnown()?.size ?: 0) + + /** The property of the price to filter on. */ + class Field @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val PRICE_ID = of("price_id") + + val ITEM_ID = of("item_id") + + val PRICE_TYPE = of("price_type") + + val CURRENCY = of("currency") + + val PRICING_UNIT_ID = of("pricing_unit_id") + + fun of(value: String) = Field(JsonField.of(value)) + } + + /** An enum containing [Field]'s known values. */ + enum class Known { + PRICE_ID, + ITEM_ID, + PRICE_TYPE, + CURRENCY, + PRICING_UNIT_ID, + } + + /** + * An enum containing [Field]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Field] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + PRICE_ID, + ITEM_ID, + PRICE_TYPE, + CURRENCY, + PRICING_UNIT_ID, + /** + * An enum member indicating that [Field] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + PRICE_ID -> Value.PRICE_ID + ITEM_ID -> Value.ITEM_ID + PRICE_TYPE -> Value.PRICE_TYPE + CURRENCY -> Value.CURRENCY + PRICING_UNIT_ID -> Value.PRICING_UNIT_ID + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + PRICE_ID -> Known.PRICE_ID + ITEM_ID -> Known.ITEM_ID + PRICE_TYPE -> Known.PRICE_TYPE + CURRENCY -> Known.CURRENCY + PRICING_UNIT_ID -> Known.PRICING_UNIT_ID + else -> throw OrbInvalidDataException("Unknown Field: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Field = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Field && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Should prices that match the filter be included or excluded. */ + class Operator @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val INCLUDES = of("includes") + + val EXCLUDES = of("excludes") + + fun of(value: String) = Operator(JsonField.of(value)) + } + + /** An enum containing [Operator]'s known values. */ + enum class Known { + INCLUDES, + EXCLUDES, + } + + /** + * An enum containing [Operator]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Operator] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + INCLUDES, + EXCLUDES, + /** + * An enum member indicating that [Operator] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + INCLUDES -> Value.INCLUDES + EXCLUDES -> Value.EXCLUDES + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + INCLUDES -> Known.INCLUDES + EXCLUDES -> Known.EXCLUDES + else -> throw OrbInvalidDataException("Unknown Operator: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Operator = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Operator && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CompositePriceFilter && + field == other.field && + operator == other.operator && + values == other.values && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(field, operator, values, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CompositePriceFilter{field=$field, operator=$operator, values=$values, additionalProperties=$additionalProperties}" + } + /** * User specified key-value pairs for the resource. If not present, this defaults to an * empty dictionary. Individual keys can be removed by setting the value to `null`, and the @@ -21403,7 +26263,7 @@ private constructor( private val billingCycleConfiguration: JsonField, private val billingMode: JsonField, private val cadence: JsonField, - private val compositePriceFilters: JsonField>, + private val compositePriceFilters: JsonField>, private val conversionRate: JsonField, private val conversionRateConfig: JsonField, private val createdAt: JsonField, @@ -21444,7 +26304,7 @@ private constructor( @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), @JsonProperty("composite_price_filters") @ExcludeMissing - compositePriceFilters: JsonField> = JsonMissing.of(), + compositePriceFilters: JsonField> = JsonMissing.of(), @JsonProperty("conversion_rate") @ExcludeMissing conversionRate: JsonField = JsonMissing.of(), @@ -21569,7 +26429,7 @@ private constructor( * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun compositePriceFilters(): List? = + fun compositePriceFilters(): List? = compositePriceFilters.getNullable("composite_price_filters") /** @@ -21781,7 +26641,7 @@ private constructor( */ @JsonProperty("composite_price_filters") @ExcludeMissing - fun _compositePriceFilters(): JsonField> = compositePriceFilters + fun _compositePriceFilters(): JsonField> = compositePriceFilters /** * Returns the raw JSON value of [conversionRate]. @@ -22041,7 +26901,7 @@ private constructor( private var billingCycleConfiguration: JsonField? = null private var billingMode: JsonField? = null private var cadence: JsonField? = null - private var compositePriceFilters: JsonField>? = null + private var compositePriceFilters: JsonField>? = null private var conversionRate: JsonField? = null private var conversionRateConfig: JsonField? = null private var createdAt: JsonField? = null @@ -22163,28 +27023,28 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - fun compositePriceFilters(compositePriceFilters: List?) = + fun compositePriceFilters(compositePriceFilters: List?) = compositePriceFilters(JsonField.ofNullable(compositePriceFilters)) /** * Sets [Builder.compositePriceFilters] to an arbitrary JSON value. * * You should usually call [Builder.compositePriceFilters] with a well-typed - * `List` value instead. This method is primarily for setting the + * `List` value instead. This method is primarily for setting the * field to an undocumented or not yet supported value. */ fun compositePriceFilters( - compositePriceFilters: JsonField> + compositePriceFilters: JsonField> ) = apply { this.compositePriceFilters = compositePriceFilters.map { it.toMutableList() } } /** - * Adds a single [TransformPriceFilter] to [compositePriceFilters]. + * Adds a single [CompositePriceFilter] to [compositePriceFilters]. * * @throws IllegalStateException if the field was previously set to a non-list. */ - fun addCompositePriceFilter(compositePriceFilter: TransformPriceFilter) = apply { + fun addCompositePriceFilter(compositePriceFilter: CompositePriceFilter) = apply { compositePriceFilters = (compositePriceFilters ?: JsonField.of(mutableListOf())).also { checkKnown("compositePriceFilters", it).add(compositePriceFilter) @@ -23100,6 +27960,546 @@ private constructor( override fun toString() = value.toString() } + class CompositePriceFilter + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val field: JsonField, + private val operator: JsonField, + private val values: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("field") @ExcludeMissing field: JsonField = JsonMissing.of(), + @JsonProperty("operator") + @ExcludeMissing + operator: JsonField = JsonMissing.of(), + @JsonProperty("values") + @ExcludeMissing + values: JsonField> = JsonMissing.of(), + ) : this(field, operator, values, mutableMapOf()) + + /** + * The property of the price to filter on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun field(): Field = field.getRequired("field") + + /** + * Should prices that match the filter be included or excluded. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun operator(): Operator = operator.getRequired("operator") + + /** + * The IDs or values that match this filter. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun values(): List = values.getRequired("values") + + /** + * Returns the raw JSON value of [field]. + * + * Unlike [field], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("field") @ExcludeMissing fun _field(): JsonField = field + + /** + * Returns the raw JSON value of [operator]. + * + * Unlike [operator], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("operator") + @ExcludeMissing + fun _operator(): JsonField = operator + + /** + * Returns the raw JSON value of [values]. + * + * Unlike [values], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("values") @ExcludeMissing fun _values(): JsonField> = values + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [CompositePriceFilter]. + * + * The following fields are required: + * ```kotlin + * .field() + * .operator() + * .values() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [CompositePriceFilter]. */ + class Builder internal constructor() { + + private var field: JsonField? = null + private var operator: JsonField? = null + private var values: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(compositePriceFilter: CompositePriceFilter) = apply { + field = compositePriceFilter.field + operator = compositePriceFilter.operator + values = compositePriceFilter.values.map { it.toMutableList() } + additionalProperties = compositePriceFilter.additionalProperties.toMutableMap() + } + + /** The property of the price to filter on. */ + fun field(field: Field) = field(JsonField.of(field)) + + /** + * Sets [Builder.field] to an arbitrary JSON value. + * + * You should usually call [Builder.field] with a well-typed [Field] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun field(field: JsonField) = apply { this.field = field } + + /** Should prices that match the filter be included or excluded. */ + fun operator(operator: Operator) = operator(JsonField.of(operator)) + + /** + * Sets [Builder.operator] to an arbitrary JSON value. + * + * You should usually call [Builder.operator] with a well-typed [Operator] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun operator(operator: JsonField) = apply { this.operator = operator } + + /** The IDs or values that match this filter. */ + fun values(values: List) = values(JsonField.of(values)) + + /** + * Sets [Builder.values] to an arbitrary JSON value. + * + * You should usually call [Builder.values] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun values(values: JsonField>) = apply { + this.values = values.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [values]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addValue(value: String) = apply { + values = + (values ?: JsonField.of(mutableListOf())).also { + checkKnown("values", it).add(value) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CompositePriceFilter]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .field() + * .operator() + * .values() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CompositePriceFilter = + CompositePriceFilter( + checkRequired("field", field), + checkRequired("operator", operator), + checkRequired("values", values).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CompositePriceFilter = apply { + if (validated) { + return@apply + } + + field().validate() + operator().validate() + values() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (field.asKnown()?.validity() ?: 0) + + (operator.asKnown()?.validity() ?: 0) + + (values.asKnown()?.size ?: 0) + + /** The property of the price to filter on. */ + class Field @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val PRICE_ID = of("price_id") + + val ITEM_ID = of("item_id") + + val PRICE_TYPE = of("price_type") + + val CURRENCY = of("currency") + + val PRICING_UNIT_ID = of("pricing_unit_id") + + fun of(value: String) = Field(JsonField.of(value)) + } + + /** An enum containing [Field]'s known values. */ + enum class Known { + PRICE_ID, + ITEM_ID, + PRICE_TYPE, + CURRENCY, + PRICING_UNIT_ID, + } + + /** + * An enum containing [Field]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Field] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + PRICE_ID, + ITEM_ID, + PRICE_TYPE, + CURRENCY, + PRICING_UNIT_ID, + /** + * An enum member indicating that [Field] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + PRICE_ID -> Value.PRICE_ID + ITEM_ID -> Value.ITEM_ID + PRICE_TYPE -> Value.PRICE_TYPE + CURRENCY -> Value.CURRENCY + PRICING_UNIT_ID -> Value.PRICING_UNIT_ID + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + PRICE_ID -> Known.PRICE_ID + ITEM_ID -> Known.ITEM_ID + PRICE_TYPE -> Known.PRICE_TYPE + CURRENCY -> Known.CURRENCY + PRICING_UNIT_ID -> Known.PRICING_UNIT_ID + else -> throw OrbInvalidDataException("Unknown Field: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Field = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Field && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Should prices that match the filter be included or excluded. */ + class Operator @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val INCLUDES = of("includes") + + val EXCLUDES = of("excludes") + + fun of(value: String) = Operator(JsonField.of(value)) + } + + /** An enum containing [Operator]'s known values. */ + enum class Known { + INCLUDES, + EXCLUDES, + } + + /** + * An enum containing [Operator]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Operator] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + INCLUDES, + EXCLUDES, + /** + * An enum member indicating that [Operator] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + INCLUDES -> Value.INCLUDES + EXCLUDES -> Value.EXCLUDES + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + INCLUDES -> Known.INCLUDES + EXCLUDES -> Known.EXCLUDES + else -> throw OrbInvalidDataException("Unknown Operator: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Operator = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Operator && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CompositePriceFilter && + field == other.field && + operator == other.operator && + values == other.values && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(field, operator, values, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CompositePriceFilter{field=$field, operator=$operator, values=$values, additionalProperties=$additionalProperties}" + } + /** Configuration for grouped_tiered pricing */ class GroupedTieredConfig @JsonCreator(mode = JsonCreator.Mode.DISABLED) @@ -23874,7 +29274,7 @@ private constructor( private val billingCycleConfiguration: JsonField, private val billingMode: JsonField, private val cadence: JsonField, - private val compositePriceFilters: JsonField>, + private val compositePriceFilters: JsonField>, private val conversionRate: JsonField, private val conversionRateConfig: JsonField, private val createdAt: JsonField, @@ -23915,7 +29315,7 @@ private constructor( @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), @JsonProperty("composite_price_filters") @ExcludeMissing - compositePriceFilters: JsonField> = JsonMissing.of(), + compositePriceFilters: JsonField> = JsonMissing.of(), @JsonProperty("conversion_rate") @ExcludeMissing conversionRate: JsonField = JsonMissing.of(), @@ -24041,7 +29441,7 @@ private constructor( * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun compositePriceFilters(): List? = + fun compositePriceFilters(): List? = compositePriceFilters.getNullable("composite_price_filters") /** @@ -24253,7 +29653,7 @@ private constructor( */ @JsonProperty("composite_price_filters") @ExcludeMissing - fun _compositePriceFilters(): JsonField> = compositePriceFilters + fun _compositePriceFilters(): JsonField> = compositePriceFilters /** * Returns the raw JSON value of [conversionRate]. @@ -24514,7 +29914,7 @@ private constructor( private var billingCycleConfiguration: JsonField? = null private var billingMode: JsonField? = null private var cadence: JsonField? = null - private var compositePriceFilters: JsonField>? = null + private var compositePriceFilters: JsonField>? = null private var conversionRate: JsonField? = null private var conversionRateConfig: JsonField? = null private var createdAt: JsonField? = null @@ -24639,28 +30039,28 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - fun compositePriceFilters(compositePriceFilters: List?) = + fun compositePriceFilters(compositePriceFilters: List?) = compositePriceFilters(JsonField.ofNullable(compositePriceFilters)) /** * Sets [Builder.compositePriceFilters] to an arbitrary JSON value. * * You should usually call [Builder.compositePriceFilters] with a well-typed - * `List` value instead. This method is primarily for setting the + * `List` value instead. This method is primarily for setting the * field to an undocumented or not yet supported value. */ fun compositePriceFilters( - compositePriceFilters: JsonField> + compositePriceFilters: JsonField> ) = apply { this.compositePriceFilters = compositePriceFilters.map { it.toMutableList() } } /** - * Adds a single [TransformPriceFilter] to [compositePriceFilters]. + * Adds a single [CompositePriceFilter] to [compositePriceFilters]. * * @throws IllegalStateException if the field was previously set to a non-list. */ - fun addCompositePriceFilter(compositePriceFilter: TransformPriceFilter) = apply { + fun addCompositePriceFilter(compositePriceFilter: CompositePriceFilter) = apply { compositePriceFilters = (compositePriceFilters ?: JsonField.of(mutableListOf())).also { checkKnown("compositePriceFilters", it).add(compositePriceFilter) @@ -25579,6 +30979,546 @@ private constructor( override fun toString() = value.toString() } + class CompositePriceFilter + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val field: JsonField, + private val operator: JsonField, + private val values: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("field") @ExcludeMissing field: JsonField = JsonMissing.of(), + @JsonProperty("operator") + @ExcludeMissing + operator: JsonField = JsonMissing.of(), + @JsonProperty("values") + @ExcludeMissing + values: JsonField> = JsonMissing.of(), + ) : this(field, operator, values, mutableMapOf()) + + /** + * The property of the price to filter on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun field(): Field = field.getRequired("field") + + /** + * Should prices that match the filter be included or excluded. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun operator(): Operator = operator.getRequired("operator") + + /** + * The IDs or values that match this filter. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun values(): List = values.getRequired("values") + + /** + * Returns the raw JSON value of [field]. + * + * Unlike [field], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("field") @ExcludeMissing fun _field(): JsonField = field + + /** + * Returns the raw JSON value of [operator]. + * + * Unlike [operator], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("operator") + @ExcludeMissing + fun _operator(): JsonField = operator + + /** + * Returns the raw JSON value of [values]. + * + * Unlike [values], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("values") @ExcludeMissing fun _values(): JsonField> = values + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [CompositePriceFilter]. + * + * The following fields are required: + * ```kotlin + * .field() + * .operator() + * .values() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [CompositePriceFilter]. */ + class Builder internal constructor() { + + private var field: JsonField? = null + private var operator: JsonField? = null + private var values: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(compositePriceFilter: CompositePriceFilter) = apply { + field = compositePriceFilter.field + operator = compositePriceFilter.operator + values = compositePriceFilter.values.map { it.toMutableList() } + additionalProperties = compositePriceFilter.additionalProperties.toMutableMap() + } + + /** The property of the price to filter on. */ + fun field(field: Field) = field(JsonField.of(field)) + + /** + * Sets [Builder.field] to an arbitrary JSON value. + * + * You should usually call [Builder.field] with a well-typed [Field] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun field(field: JsonField) = apply { this.field = field } + + /** Should prices that match the filter be included or excluded. */ + fun operator(operator: Operator) = operator(JsonField.of(operator)) + + /** + * Sets [Builder.operator] to an arbitrary JSON value. + * + * You should usually call [Builder.operator] with a well-typed [Operator] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun operator(operator: JsonField) = apply { this.operator = operator } + + /** The IDs or values that match this filter. */ + fun values(values: List) = values(JsonField.of(values)) + + /** + * Sets [Builder.values] to an arbitrary JSON value. + * + * You should usually call [Builder.values] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun values(values: JsonField>) = apply { + this.values = values.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [values]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addValue(value: String) = apply { + values = + (values ?: JsonField.of(mutableListOf())).also { + checkKnown("values", it).add(value) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CompositePriceFilter]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .field() + * .operator() + * .values() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CompositePriceFilter = + CompositePriceFilter( + checkRequired("field", field), + checkRequired("operator", operator), + checkRequired("values", values).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CompositePriceFilter = apply { + if (validated) { + return@apply + } + + field().validate() + operator().validate() + values() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (field.asKnown()?.validity() ?: 0) + + (operator.asKnown()?.validity() ?: 0) + + (values.asKnown()?.size ?: 0) + + /** The property of the price to filter on. */ + class Field @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val PRICE_ID = of("price_id") + + val ITEM_ID = of("item_id") + + val PRICE_TYPE = of("price_type") + + val CURRENCY = of("currency") + + val PRICING_UNIT_ID = of("pricing_unit_id") + + fun of(value: String) = Field(JsonField.of(value)) + } + + /** An enum containing [Field]'s known values. */ + enum class Known { + PRICE_ID, + ITEM_ID, + PRICE_TYPE, + CURRENCY, + PRICING_UNIT_ID, + } + + /** + * An enum containing [Field]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Field] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + PRICE_ID, + ITEM_ID, + PRICE_TYPE, + CURRENCY, + PRICING_UNIT_ID, + /** + * An enum member indicating that [Field] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + PRICE_ID -> Value.PRICE_ID + ITEM_ID -> Value.ITEM_ID + PRICE_TYPE -> Value.PRICE_TYPE + CURRENCY -> Value.CURRENCY + PRICING_UNIT_ID -> Value.PRICING_UNIT_ID + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + PRICE_ID -> Known.PRICE_ID + ITEM_ID -> Known.ITEM_ID + PRICE_TYPE -> Known.PRICE_TYPE + CURRENCY -> Known.CURRENCY + PRICING_UNIT_ID -> Known.PRICING_UNIT_ID + else -> throw OrbInvalidDataException("Unknown Field: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Field = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Field && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Should prices that match the filter be included or excluded. */ + class Operator @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val INCLUDES = of("includes") + + val EXCLUDES = of("excludes") + + fun of(value: String) = Operator(JsonField.of(value)) + } + + /** An enum containing [Operator]'s known values. */ + enum class Known { + INCLUDES, + EXCLUDES, + } + + /** + * An enum containing [Operator]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Operator] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + INCLUDES, + EXCLUDES, + /** + * An enum member indicating that [Operator] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + INCLUDES -> Value.INCLUDES + EXCLUDES -> Value.EXCLUDES + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + INCLUDES -> Known.INCLUDES + EXCLUDES -> Known.EXCLUDES + else -> throw OrbInvalidDataException("Unknown Operator: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Operator = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Operator && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CompositePriceFilter && + field == other.field && + operator == other.operator && + values == other.values && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(field, operator, values, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CompositePriceFilter{field=$field, operator=$operator, values=$values, additionalProperties=$additionalProperties}" + } + /** * User specified key-value pairs for the resource. If not present, this defaults to an * empty dictionary. Individual keys can be removed by setting the value to `null`, and the @@ -26401,7 +32341,7 @@ private constructor( private val billingCycleConfiguration: JsonField, private val billingMode: JsonField, private val cadence: JsonField, - private val compositePriceFilters: JsonField>, + private val compositePriceFilters: JsonField>, private val conversionRate: JsonField, private val conversionRateConfig: JsonField, private val createdAt: JsonField, @@ -26442,7 +32382,7 @@ private constructor( @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), @JsonProperty("composite_price_filters") @ExcludeMissing - compositePriceFilters: JsonField> = JsonMissing.of(), + compositePriceFilters: JsonField> = JsonMissing.of(), @JsonProperty("conversion_rate") @ExcludeMissing conversionRate: JsonField = JsonMissing.of(), @@ -26567,7 +32507,7 @@ private constructor( * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun compositePriceFilters(): List? = + fun compositePriceFilters(): List? = compositePriceFilters.getNullable("composite_price_filters") /** @@ -26779,7 +32719,7 @@ private constructor( */ @JsonProperty("composite_price_filters") @ExcludeMissing - fun _compositePriceFilters(): JsonField> = compositePriceFilters + fun _compositePriceFilters(): JsonField> = compositePriceFilters /** * Returns the raw JSON value of [conversionRate]. @@ -27040,7 +32980,7 @@ private constructor( private var billingCycleConfiguration: JsonField? = null private var billingMode: JsonField? = null private var cadence: JsonField? = null - private var compositePriceFilters: JsonField>? = null + private var compositePriceFilters: JsonField>? = null private var conversionRate: JsonField? = null private var conversionRateConfig: JsonField? = null private var createdAt: JsonField? = null @@ -27162,28 +33102,28 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - fun compositePriceFilters(compositePriceFilters: List?) = + fun compositePriceFilters(compositePriceFilters: List?) = compositePriceFilters(JsonField.ofNullable(compositePriceFilters)) /** * Sets [Builder.compositePriceFilters] to an arbitrary JSON value. * * You should usually call [Builder.compositePriceFilters] with a well-typed - * `List` value instead. This method is primarily for setting the + * `List` value instead. This method is primarily for setting the * field to an undocumented or not yet supported value. */ fun compositePriceFilters( - compositePriceFilters: JsonField> + compositePriceFilters: JsonField> ) = apply { this.compositePriceFilters = compositePriceFilters.map { it.toMutableList() } } /** - * Adds a single [TransformPriceFilter] to [compositePriceFilters]. + * Adds a single [CompositePriceFilter] to [compositePriceFilters]. * * @throws IllegalStateException if the field was previously set to a non-list. */ - fun addCompositePriceFilter(compositePriceFilter: TransformPriceFilter) = apply { + fun addCompositePriceFilter(compositePriceFilter: CompositePriceFilter) = apply { compositePriceFilters = (compositePriceFilters ?: JsonField.of(mutableListOf())).also { checkKnown("compositePriceFilters", it).add(compositePriceFilter) @@ -28100,6 +34040,546 @@ private constructor( override fun toString() = value.toString() } + class CompositePriceFilter + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val field: JsonField, + private val operator: JsonField, + private val values: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("field") @ExcludeMissing field: JsonField = JsonMissing.of(), + @JsonProperty("operator") + @ExcludeMissing + operator: JsonField = JsonMissing.of(), + @JsonProperty("values") + @ExcludeMissing + values: JsonField> = JsonMissing.of(), + ) : this(field, operator, values, mutableMapOf()) + + /** + * The property of the price to filter on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun field(): Field = field.getRequired("field") + + /** + * Should prices that match the filter be included or excluded. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun operator(): Operator = operator.getRequired("operator") + + /** + * The IDs or values that match this filter. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun values(): List = values.getRequired("values") + + /** + * Returns the raw JSON value of [field]. + * + * Unlike [field], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("field") @ExcludeMissing fun _field(): JsonField = field + + /** + * Returns the raw JSON value of [operator]. + * + * Unlike [operator], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("operator") + @ExcludeMissing + fun _operator(): JsonField = operator + + /** + * Returns the raw JSON value of [values]. + * + * Unlike [values], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("values") @ExcludeMissing fun _values(): JsonField> = values + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [CompositePriceFilter]. + * + * The following fields are required: + * ```kotlin + * .field() + * .operator() + * .values() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [CompositePriceFilter]. */ + class Builder internal constructor() { + + private var field: JsonField? = null + private var operator: JsonField? = null + private var values: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(compositePriceFilter: CompositePriceFilter) = apply { + field = compositePriceFilter.field + operator = compositePriceFilter.operator + values = compositePriceFilter.values.map { it.toMutableList() } + additionalProperties = compositePriceFilter.additionalProperties.toMutableMap() + } + + /** The property of the price to filter on. */ + fun field(field: Field) = field(JsonField.of(field)) + + /** + * Sets [Builder.field] to an arbitrary JSON value. + * + * You should usually call [Builder.field] with a well-typed [Field] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun field(field: JsonField) = apply { this.field = field } + + /** Should prices that match the filter be included or excluded. */ + fun operator(operator: Operator) = operator(JsonField.of(operator)) + + /** + * Sets [Builder.operator] to an arbitrary JSON value. + * + * You should usually call [Builder.operator] with a well-typed [Operator] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun operator(operator: JsonField) = apply { this.operator = operator } + + /** The IDs or values that match this filter. */ + fun values(values: List) = values(JsonField.of(values)) + + /** + * Sets [Builder.values] to an arbitrary JSON value. + * + * You should usually call [Builder.values] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun values(values: JsonField>) = apply { + this.values = values.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [values]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addValue(value: String) = apply { + values = + (values ?: JsonField.of(mutableListOf())).also { + checkKnown("values", it).add(value) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CompositePriceFilter]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .field() + * .operator() + * .values() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CompositePriceFilter = + CompositePriceFilter( + checkRequired("field", field), + checkRequired("operator", operator), + checkRequired("values", values).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CompositePriceFilter = apply { + if (validated) { + return@apply + } + + field().validate() + operator().validate() + values() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (field.asKnown()?.validity() ?: 0) + + (operator.asKnown()?.validity() ?: 0) + + (values.asKnown()?.size ?: 0) + + /** The property of the price to filter on. */ + class Field @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val PRICE_ID = of("price_id") + + val ITEM_ID = of("item_id") + + val PRICE_TYPE = of("price_type") + + val CURRENCY = of("currency") + + val PRICING_UNIT_ID = of("pricing_unit_id") + + fun of(value: String) = Field(JsonField.of(value)) + } + + /** An enum containing [Field]'s known values. */ + enum class Known { + PRICE_ID, + ITEM_ID, + PRICE_TYPE, + CURRENCY, + PRICING_UNIT_ID, + } + + /** + * An enum containing [Field]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Field] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + PRICE_ID, + ITEM_ID, + PRICE_TYPE, + CURRENCY, + PRICING_UNIT_ID, + /** + * An enum member indicating that [Field] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + PRICE_ID -> Value.PRICE_ID + ITEM_ID -> Value.ITEM_ID + PRICE_TYPE -> Value.PRICE_TYPE + CURRENCY -> Value.CURRENCY + PRICING_UNIT_ID -> Value.PRICING_UNIT_ID + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + PRICE_ID -> Known.PRICE_ID + ITEM_ID -> Known.ITEM_ID + PRICE_TYPE -> Known.PRICE_TYPE + CURRENCY -> Known.CURRENCY + PRICING_UNIT_ID -> Known.PRICING_UNIT_ID + else -> throw OrbInvalidDataException("Unknown Field: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Field = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Field && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Should prices that match the filter be included or excluded. */ + class Operator @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val INCLUDES = of("includes") + + val EXCLUDES = of("excludes") + + fun of(value: String) = Operator(JsonField.of(value)) + } + + /** An enum containing [Operator]'s known values. */ + enum class Known { + INCLUDES, + EXCLUDES, + } + + /** + * An enum containing [Operator]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Operator] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + INCLUDES, + EXCLUDES, + /** + * An enum member indicating that [Operator] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + INCLUDES -> Value.INCLUDES + EXCLUDES -> Value.EXCLUDES + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + INCLUDES -> Known.INCLUDES + EXCLUDES -> Known.EXCLUDES + else -> throw OrbInvalidDataException("Unknown Operator: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Operator = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Operator && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CompositePriceFilter && + field == other.field && + operator == other.operator && + values == other.values && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(field, operator, values, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CompositePriceFilter{field=$field, operator=$operator, values=$values, additionalProperties=$additionalProperties}" + } + /** * User specified key-value pairs for the resource. If not present, this defaults to an * empty dictionary. Individual keys can be removed by setting the value to `null`, and the @@ -28692,7 +35172,7 @@ private constructor( private val billingCycleConfiguration: JsonField, private val billingMode: JsonField, private val cadence: JsonField, - private val compositePriceFilters: JsonField>, + private val compositePriceFilters: JsonField>, private val conversionRate: JsonField, private val conversionRateConfig: JsonField, private val createdAt: JsonField, @@ -28733,7 +35213,7 @@ private constructor( @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), @JsonProperty("composite_price_filters") @ExcludeMissing - compositePriceFilters: JsonField> = JsonMissing.of(), + compositePriceFilters: JsonField> = JsonMissing.of(), @JsonProperty("conversion_rate") @ExcludeMissing conversionRate: JsonField = JsonMissing.of(), @@ -28858,7 +35338,7 @@ private constructor( * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun compositePriceFilters(): List? = + fun compositePriceFilters(): List? = compositePriceFilters.getNullable("composite_price_filters") /** @@ -29070,7 +35550,7 @@ private constructor( */ @JsonProperty("composite_price_filters") @ExcludeMissing - fun _compositePriceFilters(): JsonField> = compositePriceFilters + fun _compositePriceFilters(): JsonField> = compositePriceFilters /** * Returns the raw JSON value of [conversionRate]. @@ -29330,7 +35810,7 @@ private constructor( private var billingCycleConfiguration: JsonField? = null private var billingMode: JsonField? = null private var cadence: JsonField? = null - private var compositePriceFilters: JsonField>? = null + private var compositePriceFilters: JsonField>? = null private var conversionRate: JsonField? = null private var conversionRateConfig: JsonField? = null private var createdAt: JsonField? = null @@ -29452,28 +35932,28 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - fun compositePriceFilters(compositePriceFilters: List?) = + fun compositePriceFilters(compositePriceFilters: List?) = compositePriceFilters(JsonField.ofNullable(compositePriceFilters)) /** * Sets [Builder.compositePriceFilters] to an arbitrary JSON value. * * You should usually call [Builder.compositePriceFilters] with a well-typed - * `List` value instead. This method is primarily for setting the + * `List` value instead. This method is primarily for setting the * field to an undocumented or not yet supported value. */ fun compositePriceFilters( - compositePriceFilters: JsonField> + compositePriceFilters: JsonField> ) = apply { this.compositePriceFilters = compositePriceFilters.map { it.toMutableList() } } /** - * Adds a single [TransformPriceFilter] to [compositePriceFilters]. + * Adds a single [CompositePriceFilter] to [compositePriceFilters]. * * @throws IllegalStateException if the field was previously set to a non-list. */ - fun addCompositePriceFilter(compositePriceFilter: TransformPriceFilter) = apply { + fun addCompositePriceFilter(compositePriceFilter: CompositePriceFilter) = apply { compositePriceFilters = (compositePriceFilters ?: JsonField.of(mutableListOf())).also { checkKnown("compositePriceFilters", it).add(compositePriceFilter) @@ -30390,6 +36870,546 @@ private constructor( override fun toString() = value.toString() } + class CompositePriceFilter + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val field: JsonField, + private val operator: JsonField, + private val values: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("field") @ExcludeMissing field: JsonField = JsonMissing.of(), + @JsonProperty("operator") + @ExcludeMissing + operator: JsonField = JsonMissing.of(), + @JsonProperty("values") + @ExcludeMissing + values: JsonField> = JsonMissing.of(), + ) : this(field, operator, values, mutableMapOf()) + + /** + * The property of the price to filter on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun field(): Field = field.getRequired("field") + + /** + * Should prices that match the filter be included or excluded. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun operator(): Operator = operator.getRequired("operator") + + /** + * The IDs or values that match this filter. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun values(): List = values.getRequired("values") + + /** + * Returns the raw JSON value of [field]. + * + * Unlike [field], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("field") @ExcludeMissing fun _field(): JsonField = field + + /** + * Returns the raw JSON value of [operator]. + * + * Unlike [operator], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("operator") + @ExcludeMissing + fun _operator(): JsonField = operator + + /** + * Returns the raw JSON value of [values]. + * + * Unlike [values], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("values") @ExcludeMissing fun _values(): JsonField> = values + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [CompositePriceFilter]. + * + * The following fields are required: + * ```kotlin + * .field() + * .operator() + * .values() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [CompositePriceFilter]. */ + class Builder internal constructor() { + + private var field: JsonField? = null + private var operator: JsonField? = null + private var values: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(compositePriceFilter: CompositePriceFilter) = apply { + field = compositePriceFilter.field + operator = compositePriceFilter.operator + values = compositePriceFilter.values.map { it.toMutableList() } + additionalProperties = compositePriceFilter.additionalProperties.toMutableMap() + } + + /** The property of the price to filter on. */ + fun field(field: Field) = field(JsonField.of(field)) + + /** + * Sets [Builder.field] to an arbitrary JSON value. + * + * You should usually call [Builder.field] with a well-typed [Field] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun field(field: JsonField) = apply { this.field = field } + + /** Should prices that match the filter be included or excluded. */ + fun operator(operator: Operator) = operator(JsonField.of(operator)) + + /** + * Sets [Builder.operator] to an arbitrary JSON value. + * + * You should usually call [Builder.operator] with a well-typed [Operator] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun operator(operator: JsonField) = apply { this.operator = operator } + + /** The IDs or values that match this filter. */ + fun values(values: List) = values(JsonField.of(values)) + + /** + * Sets [Builder.values] to an arbitrary JSON value. + * + * You should usually call [Builder.values] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun values(values: JsonField>) = apply { + this.values = values.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [values]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addValue(value: String) = apply { + values = + (values ?: JsonField.of(mutableListOf())).also { + checkKnown("values", it).add(value) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CompositePriceFilter]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .field() + * .operator() + * .values() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CompositePriceFilter = + CompositePriceFilter( + checkRequired("field", field), + checkRequired("operator", operator), + checkRequired("values", values).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CompositePriceFilter = apply { + if (validated) { + return@apply + } + + field().validate() + operator().validate() + values() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (field.asKnown()?.validity() ?: 0) + + (operator.asKnown()?.validity() ?: 0) + + (values.asKnown()?.size ?: 0) + + /** The property of the price to filter on. */ + class Field @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val PRICE_ID = of("price_id") + + val ITEM_ID = of("item_id") + + val PRICE_TYPE = of("price_type") + + val CURRENCY = of("currency") + + val PRICING_UNIT_ID = of("pricing_unit_id") + + fun of(value: String) = Field(JsonField.of(value)) + } + + /** An enum containing [Field]'s known values. */ + enum class Known { + PRICE_ID, + ITEM_ID, + PRICE_TYPE, + CURRENCY, + PRICING_UNIT_ID, + } + + /** + * An enum containing [Field]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Field] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + PRICE_ID, + ITEM_ID, + PRICE_TYPE, + CURRENCY, + PRICING_UNIT_ID, + /** + * An enum member indicating that [Field] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + PRICE_ID -> Value.PRICE_ID + ITEM_ID -> Value.ITEM_ID + PRICE_TYPE -> Value.PRICE_TYPE + CURRENCY -> Value.CURRENCY + PRICING_UNIT_ID -> Value.PRICING_UNIT_ID + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + PRICE_ID -> Known.PRICE_ID + ITEM_ID -> Known.ITEM_ID + PRICE_TYPE -> Known.PRICE_TYPE + CURRENCY -> Known.CURRENCY + PRICING_UNIT_ID -> Known.PRICING_UNIT_ID + else -> throw OrbInvalidDataException("Unknown Field: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Field = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Field && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Should prices that match the filter be included or excluded. */ + class Operator @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val INCLUDES = of("includes") + + val EXCLUDES = of("excludes") + + fun of(value: String) = Operator(JsonField.of(value)) + } + + /** An enum containing [Operator]'s known values. */ + enum class Known { + INCLUDES, + EXCLUDES, + } + + /** + * An enum containing [Operator]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Operator] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + INCLUDES, + EXCLUDES, + /** + * An enum member indicating that [Operator] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + INCLUDES -> Value.INCLUDES + EXCLUDES -> Value.EXCLUDES + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + INCLUDES -> Known.INCLUDES + EXCLUDES -> Known.EXCLUDES + else -> throw OrbInvalidDataException("Unknown Operator: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Operator = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Operator && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CompositePriceFilter && + field == other.field && + operator == other.operator && + values == other.values && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(field, operator, values, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CompositePriceFilter{field=$field, operator=$operator, values=$values, additionalProperties=$additionalProperties}" + } + /** * User specified key-value pairs for the resource. If not present, this defaults to an * empty dictionary. Individual keys can be removed by setting the value to `null`, and the @@ -30929,7 +37949,7 @@ private constructor( private val billingCycleConfiguration: JsonField, private val billingMode: JsonField, private val cadence: JsonField, - private val compositePriceFilters: JsonField>, + private val compositePriceFilters: JsonField>, private val conversionRate: JsonField, private val conversionRateConfig: JsonField, private val createdAt: JsonField, @@ -30970,7 +37990,7 @@ private constructor( @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), @JsonProperty("composite_price_filters") @ExcludeMissing - compositePriceFilters: JsonField> = JsonMissing.of(), + compositePriceFilters: JsonField> = JsonMissing.of(), @JsonProperty("conversion_rate") @ExcludeMissing conversionRate: JsonField = JsonMissing.of(), @@ -31095,7 +38115,7 @@ private constructor( * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun compositePriceFilters(): List? = + fun compositePriceFilters(): List? = compositePriceFilters.getNullable("composite_price_filters") /** @@ -31307,7 +38327,7 @@ private constructor( */ @JsonProperty("composite_price_filters") @ExcludeMissing - fun _compositePriceFilters(): JsonField> = compositePriceFilters + fun _compositePriceFilters(): JsonField> = compositePriceFilters /** * Returns the raw JSON value of [conversionRate]. @@ -31568,7 +38588,7 @@ private constructor( private var billingCycleConfiguration: JsonField? = null private var billingMode: JsonField? = null private var cadence: JsonField? = null - private var compositePriceFilters: JsonField>? = null + private var compositePriceFilters: JsonField>? = null private var conversionRate: JsonField? = null private var conversionRateConfig: JsonField? = null private var createdAt: JsonField? = null @@ -31690,28 +38710,28 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - fun compositePriceFilters(compositePriceFilters: List?) = + fun compositePriceFilters(compositePriceFilters: List?) = compositePriceFilters(JsonField.ofNullable(compositePriceFilters)) /** * Sets [Builder.compositePriceFilters] to an arbitrary JSON value. * * You should usually call [Builder.compositePriceFilters] with a well-typed - * `List` value instead. This method is primarily for setting the + * `List` value instead. This method is primarily for setting the * field to an undocumented or not yet supported value. */ fun compositePriceFilters( - compositePriceFilters: JsonField> + compositePriceFilters: JsonField> ) = apply { this.compositePriceFilters = compositePriceFilters.map { it.toMutableList() } } /** - * Adds a single [TransformPriceFilter] to [compositePriceFilters]. + * Adds a single [CompositePriceFilter] to [compositePriceFilters]. * * @throws IllegalStateException if the field was previously set to a non-list. */ - fun addCompositePriceFilter(compositePriceFilter: TransformPriceFilter) = apply { + fun addCompositePriceFilter(compositePriceFilter: CompositePriceFilter) = apply { compositePriceFilters = (compositePriceFilters ?: JsonField.of(mutableListOf())).also { checkKnown("compositePriceFilters", it).add(compositePriceFilter) @@ -32627,6 +39647,546 @@ private constructor( override fun toString() = value.toString() } + class CompositePriceFilter + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val field: JsonField, + private val operator: JsonField, + private val values: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("field") @ExcludeMissing field: JsonField = JsonMissing.of(), + @JsonProperty("operator") + @ExcludeMissing + operator: JsonField = JsonMissing.of(), + @JsonProperty("values") + @ExcludeMissing + values: JsonField> = JsonMissing.of(), + ) : this(field, operator, values, mutableMapOf()) + + /** + * The property of the price to filter on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun field(): Field = field.getRequired("field") + + /** + * Should prices that match the filter be included or excluded. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun operator(): Operator = operator.getRequired("operator") + + /** + * The IDs or values that match this filter. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun values(): List = values.getRequired("values") + + /** + * Returns the raw JSON value of [field]. + * + * Unlike [field], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("field") @ExcludeMissing fun _field(): JsonField = field + + /** + * Returns the raw JSON value of [operator]. + * + * Unlike [operator], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("operator") + @ExcludeMissing + fun _operator(): JsonField = operator + + /** + * Returns the raw JSON value of [values]. + * + * Unlike [values], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("values") @ExcludeMissing fun _values(): JsonField> = values + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [CompositePriceFilter]. + * + * The following fields are required: + * ```kotlin + * .field() + * .operator() + * .values() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [CompositePriceFilter]. */ + class Builder internal constructor() { + + private var field: JsonField? = null + private var operator: JsonField? = null + private var values: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(compositePriceFilter: CompositePriceFilter) = apply { + field = compositePriceFilter.field + operator = compositePriceFilter.operator + values = compositePriceFilter.values.map { it.toMutableList() } + additionalProperties = compositePriceFilter.additionalProperties.toMutableMap() + } + + /** The property of the price to filter on. */ + fun field(field: Field) = field(JsonField.of(field)) + + /** + * Sets [Builder.field] to an arbitrary JSON value. + * + * You should usually call [Builder.field] with a well-typed [Field] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun field(field: JsonField) = apply { this.field = field } + + /** Should prices that match the filter be included or excluded. */ + fun operator(operator: Operator) = operator(JsonField.of(operator)) + + /** + * Sets [Builder.operator] to an arbitrary JSON value. + * + * You should usually call [Builder.operator] with a well-typed [Operator] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun operator(operator: JsonField) = apply { this.operator = operator } + + /** The IDs or values that match this filter. */ + fun values(values: List) = values(JsonField.of(values)) + + /** + * Sets [Builder.values] to an arbitrary JSON value. + * + * You should usually call [Builder.values] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun values(values: JsonField>) = apply { + this.values = values.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [values]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addValue(value: String) = apply { + values = + (values ?: JsonField.of(mutableListOf())).also { + checkKnown("values", it).add(value) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CompositePriceFilter]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .field() + * .operator() + * .values() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CompositePriceFilter = + CompositePriceFilter( + checkRequired("field", field), + checkRequired("operator", operator), + checkRequired("values", values).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CompositePriceFilter = apply { + if (validated) { + return@apply + } + + field().validate() + operator().validate() + values() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (field.asKnown()?.validity() ?: 0) + + (operator.asKnown()?.validity() ?: 0) + + (values.asKnown()?.size ?: 0) + + /** The property of the price to filter on. */ + class Field @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val PRICE_ID = of("price_id") + + val ITEM_ID = of("item_id") + + val PRICE_TYPE = of("price_type") + + val CURRENCY = of("currency") + + val PRICING_UNIT_ID = of("pricing_unit_id") + + fun of(value: String) = Field(JsonField.of(value)) + } + + /** An enum containing [Field]'s known values. */ + enum class Known { + PRICE_ID, + ITEM_ID, + PRICE_TYPE, + CURRENCY, + PRICING_UNIT_ID, + } + + /** + * An enum containing [Field]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Field] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + PRICE_ID, + ITEM_ID, + PRICE_TYPE, + CURRENCY, + PRICING_UNIT_ID, + /** + * An enum member indicating that [Field] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + PRICE_ID -> Value.PRICE_ID + ITEM_ID -> Value.ITEM_ID + PRICE_TYPE -> Value.PRICE_TYPE + CURRENCY -> Value.CURRENCY + PRICING_UNIT_ID -> Value.PRICING_UNIT_ID + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + PRICE_ID -> Known.PRICE_ID + ITEM_ID -> Known.ITEM_ID + PRICE_TYPE -> Known.PRICE_TYPE + CURRENCY -> Known.CURRENCY + PRICING_UNIT_ID -> Known.PRICING_UNIT_ID + else -> throw OrbInvalidDataException("Unknown Field: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Field = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Field && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Should prices that match the filter be included or excluded. */ + class Operator @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val INCLUDES = of("includes") + + val EXCLUDES = of("excludes") + + fun of(value: String) = Operator(JsonField.of(value)) + } + + /** An enum containing [Operator]'s known values. */ + enum class Known { + INCLUDES, + EXCLUDES, + } + + /** + * An enum containing [Operator]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Operator] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + INCLUDES, + EXCLUDES, + /** + * An enum member indicating that [Operator] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + INCLUDES -> Value.INCLUDES + EXCLUDES -> Value.EXCLUDES + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + INCLUDES -> Known.INCLUDES + EXCLUDES -> Known.EXCLUDES + else -> throw OrbInvalidDataException("Unknown Operator: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Operator = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Operator && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CompositePriceFilter && + field == other.field && + operator == other.operator && + values == other.values && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(field, operator, values, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CompositePriceFilter{field=$field, operator=$operator, values=$values, additionalProperties=$additionalProperties}" + } + /** * User specified key-value pairs for the resource. If not present, this defaults to an * empty dictionary. Individual keys can be removed by setting the value to `null`, and the @@ -32952,7 +40512,7 @@ private constructor( private val billingCycleConfiguration: JsonField, private val billingMode: JsonField, private val cadence: JsonField, - private val compositePriceFilters: JsonField>, + private val compositePriceFilters: JsonField>, private val conversionRate: JsonField, private val conversionRateConfig: JsonField, private val createdAt: JsonField, @@ -32993,7 +40553,7 @@ private constructor( @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), @JsonProperty("composite_price_filters") @ExcludeMissing - compositePriceFilters: JsonField> = JsonMissing.of(), + compositePriceFilters: JsonField> = JsonMissing.of(), @JsonProperty("conversion_rate") @ExcludeMissing conversionRate: JsonField = JsonMissing.of(), @@ -33118,7 +40678,7 @@ private constructor( * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun compositePriceFilters(): List? = + fun compositePriceFilters(): List? = compositePriceFilters.getNullable("composite_price_filters") /** @@ -33330,7 +40890,7 @@ private constructor( */ @JsonProperty("composite_price_filters") @ExcludeMissing - fun _compositePriceFilters(): JsonField> = compositePriceFilters + fun _compositePriceFilters(): JsonField> = compositePriceFilters /** * Returns the raw JSON value of [conversionRate]. @@ -33591,7 +41151,7 @@ private constructor( private var billingCycleConfiguration: JsonField? = null private var billingMode: JsonField? = null private var cadence: JsonField? = null - private var compositePriceFilters: JsonField>? = null + private var compositePriceFilters: JsonField>? = null private var conversionRate: JsonField? = null private var conversionRateConfig: JsonField? = null private var createdAt: JsonField? = null @@ -33713,28 +41273,28 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - fun compositePriceFilters(compositePriceFilters: List?) = + fun compositePriceFilters(compositePriceFilters: List?) = compositePriceFilters(JsonField.ofNullable(compositePriceFilters)) /** * Sets [Builder.compositePriceFilters] to an arbitrary JSON value. * * You should usually call [Builder.compositePriceFilters] with a well-typed - * `List` value instead. This method is primarily for setting the + * `List` value instead. This method is primarily for setting the * field to an undocumented or not yet supported value. */ fun compositePriceFilters( - compositePriceFilters: JsonField> + compositePriceFilters: JsonField> ) = apply { this.compositePriceFilters = compositePriceFilters.map { it.toMutableList() } } /** - * Adds a single [TransformPriceFilter] to [compositePriceFilters]. + * Adds a single [CompositePriceFilter] to [compositePriceFilters]. * * @throws IllegalStateException if the field was previously set to a non-list. */ - fun addCompositePriceFilter(compositePriceFilter: TransformPriceFilter) = apply { + fun addCompositePriceFilter(compositePriceFilter: CompositePriceFilter) = apply { compositePriceFilters = (compositePriceFilters ?: JsonField.of(mutableListOf())).also { checkKnown("compositePriceFilters", it).add(compositePriceFilter) @@ -34650,6 +42210,546 @@ private constructor( override fun toString() = value.toString() } + class CompositePriceFilter + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val field: JsonField, + private val operator: JsonField, + private val values: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("field") @ExcludeMissing field: JsonField = JsonMissing.of(), + @JsonProperty("operator") + @ExcludeMissing + operator: JsonField = JsonMissing.of(), + @JsonProperty("values") + @ExcludeMissing + values: JsonField> = JsonMissing.of(), + ) : this(field, operator, values, mutableMapOf()) + + /** + * The property of the price to filter on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun field(): Field = field.getRequired("field") + + /** + * Should prices that match the filter be included or excluded. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun operator(): Operator = operator.getRequired("operator") + + /** + * The IDs or values that match this filter. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun values(): List = values.getRequired("values") + + /** + * Returns the raw JSON value of [field]. + * + * Unlike [field], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("field") @ExcludeMissing fun _field(): JsonField = field + + /** + * Returns the raw JSON value of [operator]. + * + * Unlike [operator], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("operator") + @ExcludeMissing + fun _operator(): JsonField = operator + + /** + * Returns the raw JSON value of [values]. + * + * Unlike [values], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("values") @ExcludeMissing fun _values(): JsonField> = values + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [CompositePriceFilter]. + * + * The following fields are required: + * ```kotlin + * .field() + * .operator() + * .values() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [CompositePriceFilter]. */ + class Builder internal constructor() { + + private var field: JsonField? = null + private var operator: JsonField? = null + private var values: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(compositePriceFilter: CompositePriceFilter) = apply { + field = compositePriceFilter.field + operator = compositePriceFilter.operator + values = compositePriceFilter.values.map { it.toMutableList() } + additionalProperties = compositePriceFilter.additionalProperties.toMutableMap() + } + + /** The property of the price to filter on. */ + fun field(field: Field) = field(JsonField.of(field)) + + /** + * Sets [Builder.field] to an arbitrary JSON value. + * + * You should usually call [Builder.field] with a well-typed [Field] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun field(field: JsonField) = apply { this.field = field } + + /** Should prices that match the filter be included or excluded. */ + fun operator(operator: Operator) = operator(JsonField.of(operator)) + + /** + * Sets [Builder.operator] to an arbitrary JSON value. + * + * You should usually call [Builder.operator] with a well-typed [Operator] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun operator(operator: JsonField) = apply { this.operator = operator } + + /** The IDs or values that match this filter. */ + fun values(values: List) = values(JsonField.of(values)) + + /** + * Sets [Builder.values] to an arbitrary JSON value. + * + * You should usually call [Builder.values] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun values(values: JsonField>) = apply { + this.values = values.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [values]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addValue(value: String) = apply { + values = + (values ?: JsonField.of(mutableListOf())).also { + checkKnown("values", it).add(value) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CompositePriceFilter]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .field() + * .operator() + * .values() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CompositePriceFilter = + CompositePriceFilter( + checkRequired("field", field), + checkRequired("operator", operator), + checkRequired("values", values).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CompositePriceFilter = apply { + if (validated) { + return@apply + } + + field().validate() + operator().validate() + values() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (field.asKnown()?.validity() ?: 0) + + (operator.asKnown()?.validity() ?: 0) + + (values.asKnown()?.size ?: 0) + + /** The property of the price to filter on. */ + class Field @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val PRICE_ID = of("price_id") + + val ITEM_ID = of("item_id") + + val PRICE_TYPE = of("price_type") + + val CURRENCY = of("currency") + + val PRICING_UNIT_ID = of("pricing_unit_id") + + fun of(value: String) = Field(JsonField.of(value)) + } + + /** An enum containing [Field]'s known values. */ + enum class Known { + PRICE_ID, + ITEM_ID, + PRICE_TYPE, + CURRENCY, + PRICING_UNIT_ID, + } + + /** + * An enum containing [Field]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Field] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + PRICE_ID, + ITEM_ID, + PRICE_TYPE, + CURRENCY, + PRICING_UNIT_ID, + /** + * An enum member indicating that [Field] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + PRICE_ID -> Value.PRICE_ID + ITEM_ID -> Value.ITEM_ID + PRICE_TYPE -> Value.PRICE_TYPE + CURRENCY -> Value.CURRENCY + PRICING_UNIT_ID -> Value.PRICING_UNIT_ID + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + PRICE_ID -> Known.PRICE_ID + ITEM_ID -> Known.ITEM_ID + PRICE_TYPE -> Known.PRICE_TYPE + CURRENCY -> Known.CURRENCY + PRICING_UNIT_ID -> Known.PRICING_UNIT_ID + else -> throw OrbInvalidDataException("Unknown Field: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Field = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Field && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Should prices that match the filter be included or excluded. */ + class Operator @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val INCLUDES = of("includes") + + val EXCLUDES = of("excludes") + + fun of(value: String) = Operator(JsonField.of(value)) + } + + /** An enum containing [Operator]'s known values. */ + enum class Known { + INCLUDES, + EXCLUDES, + } + + /** + * An enum containing [Operator]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Operator] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + INCLUDES, + EXCLUDES, + /** + * An enum member indicating that [Operator] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + INCLUDES -> Value.INCLUDES + EXCLUDES -> Value.EXCLUDES + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + INCLUDES -> Known.INCLUDES + EXCLUDES -> Known.EXCLUDES + else -> throw OrbInvalidDataException("Unknown Operator: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Operator = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Operator && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CompositePriceFilter && + field == other.field && + operator == other.operator && + values == other.values && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(field, operator, values, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CompositePriceFilter{field=$field, operator=$operator, values=$values, additionalProperties=$additionalProperties}" + } + /** * User specified key-value pairs for the resource. If not present, this defaults to an * empty dictionary. Individual keys can be removed by setting the value to `null`, and the @@ -35379,7 +43479,7 @@ private constructor( private val billingCycleConfiguration: JsonField, private val billingMode: JsonField, private val cadence: JsonField, - private val compositePriceFilters: JsonField>, + private val compositePriceFilters: JsonField>, private val conversionRate: JsonField, private val conversionRateConfig: JsonField, private val createdAt: JsonField, @@ -35420,7 +43520,7 @@ private constructor( @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), @JsonProperty("composite_price_filters") @ExcludeMissing - compositePriceFilters: JsonField> = JsonMissing.of(), + compositePriceFilters: JsonField> = JsonMissing.of(), @JsonProperty("conversion_rate") @ExcludeMissing conversionRate: JsonField = JsonMissing.of(), @@ -35545,7 +43645,7 @@ private constructor( * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun compositePriceFilters(): List? = + fun compositePriceFilters(): List? = compositePriceFilters.getNullable("composite_price_filters") /** @@ -35757,7 +43857,7 @@ private constructor( */ @JsonProperty("composite_price_filters") @ExcludeMissing - fun _compositePriceFilters(): JsonField> = compositePriceFilters + fun _compositePriceFilters(): JsonField> = compositePriceFilters /** * Returns the raw JSON value of [conversionRate]. @@ -36017,7 +44117,7 @@ private constructor( private var billingCycleConfiguration: JsonField? = null private var billingMode: JsonField? = null private var cadence: JsonField? = null - private var compositePriceFilters: JsonField>? = null + private var compositePriceFilters: JsonField>? = null private var conversionRate: JsonField? = null private var conversionRateConfig: JsonField? = null private var createdAt: JsonField? = null @@ -36139,28 +44239,28 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - fun compositePriceFilters(compositePriceFilters: List?) = + fun compositePriceFilters(compositePriceFilters: List?) = compositePriceFilters(JsonField.ofNullable(compositePriceFilters)) /** * Sets [Builder.compositePriceFilters] to an arbitrary JSON value. * * You should usually call [Builder.compositePriceFilters] with a well-typed - * `List` value instead. This method is primarily for setting the + * `List` value instead. This method is primarily for setting the * field to an undocumented or not yet supported value. */ fun compositePriceFilters( - compositePriceFilters: JsonField> + compositePriceFilters: JsonField> ) = apply { this.compositePriceFilters = compositePriceFilters.map { it.toMutableList() } } /** - * Adds a single [TransformPriceFilter] to [compositePriceFilters]. + * Adds a single [CompositePriceFilter] to [compositePriceFilters]. * * @throws IllegalStateException if the field was previously set to a non-list. */ - fun addCompositePriceFilter(compositePriceFilter: TransformPriceFilter) = apply { + fun addCompositePriceFilter(compositePriceFilter: CompositePriceFilter) = apply { compositePriceFilters = (compositePriceFilters ?: JsonField.of(mutableListOf())).also { checkKnown("compositePriceFilters", it).add(compositePriceFilter) @@ -37076,6 +45176,546 @@ private constructor( override fun toString() = value.toString() } + class CompositePriceFilter + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val field: JsonField, + private val operator: JsonField, + private val values: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("field") @ExcludeMissing field: JsonField = JsonMissing.of(), + @JsonProperty("operator") + @ExcludeMissing + operator: JsonField = JsonMissing.of(), + @JsonProperty("values") + @ExcludeMissing + values: JsonField> = JsonMissing.of(), + ) : this(field, operator, values, mutableMapOf()) + + /** + * The property of the price to filter on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun field(): Field = field.getRequired("field") + + /** + * Should prices that match the filter be included or excluded. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun operator(): Operator = operator.getRequired("operator") + + /** + * The IDs or values that match this filter. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun values(): List = values.getRequired("values") + + /** + * Returns the raw JSON value of [field]. + * + * Unlike [field], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("field") @ExcludeMissing fun _field(): JsonField = field + + /** + * Returns the raw JSON value of [operator]. + * + * Unlike [operator], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("operator") + @ExcludeMissing + fun _operator(): JsonField = operator + + /** + * Returns the raw JSON value of [values]. + * + * Unlike [values], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("values") @ExcludeMissing fun _values(): JsonField> = values + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [CompositePriceFilter]. + * + * The following fields are required: + * ```kotlin + * .field() + * .operator() + * .values() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [CompositePriceFilter]. */ + class Builder internal constructor() { + + private var field: JsonField? = null + private var operator: JsonField? = null + private var values: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(compositePriceFilter: CompositePriceFilter) = apply { + field = compositePriceFilter.field + operator = compositePriceFilter.operator + values = compositePriceFilter.values.map { it.toMutableList() } + additionalProperties = compositePriceFilter.additionalProperties.toMutableMap() + } + + /** The property of the price to filter on. */ + fun field(field: Field) = field(JsonField.of(field)) + + /** + * Sets [Builder.field] to an arbitrary JSON value. + * + * You should usually call [Builder.field] with a well-typed [Field] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun field(field: JsonField) = apply { this.field = field } + + /** Should prices that match the filter be included or excluded. */ + fun operator(operator: Operator) = operator(JsonField.of(operator)) + + /** + * Sets [Builder.operator] to an arbitrary JSON value. + * + * You should usually call [Builder.operator] with a well-typed [Operator] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun operator(operator: JsonField) = apply { this.operator = operator } + + /** The IDs or values that match this filter. */ + fun values(values: List) = values(JsonField.of(values)) + + /** + * Sets [Builder.values] to an arbitrary JSON value. + * + * You should usually call [Builder.values] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun values(values: JsonField>) = apply { + this.values = values.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [values]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addValue(value: String) = apply { + values = + (values ?: JsonField.of(mutableListOf())).also { + checkKnown("values", it).add(value) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CompositePriceFilter]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .field() + * .operator() + * .values() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CompositePriceFilter = + CompositePriceFilter( + checkRequired("field", field), + checkRequired("operator", operator), + checkRequired("values", values).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CompositePriceFilter = apply { + if (validated) { + return@apply + } + + field().validate() + operator().validate() + values() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (field.asKnown()?.validity() ?: 0) + + (operator.asKnown()?.validity() ?: 0) + + (values.asKnown()?.size ?: 0) + + /** The property of the price to filter on. */ + class Field @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val PRICE_ID = of("price_id") + + val ITEM_ID = of("item_id") + + val PRICE_TYPE = of("price_type") + + val CURRENCY = of("currency") + + val PRICING_UNIT_ID = of("pricing_unit_id") + + fun of(value: String) = Field(JsonField.of(value)) + } + + /** An enum containing [Field]'s known values. */ + enum class Known { + PRICE_ID, + ITEM_ID, + PRICE_TYPE, + CURRENCY, + PRICING_UNIT_ID, + } + + /** + * An enum containing [Field]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Field] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + PRICE_ID, + ITEM_ID, + PRICE_TYPE, + CURRENCY, + PRICING_UNIT_ID, + /** + * An enum member indicating that [Field] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + PRICE_ID -> Value.PRICE_ID + ITEM_ID -> Value.ITEM_ID + PRICE_TYPE -> Value.PRICE_TYPE + CURRENCY -> Value.CURRENCY + PRICING_UNIT_ID -> Value.PRICING_UNIT_ID + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + PRICE_ID -> Known.PRICE_ID + ITEM_ID -> Known.ITEM_ID + PRICE_TYPE -> Known.PRICE_TYPE + CURRENCY -> Known.CURRENCY + PRICING_UNIT_ID -> Known.PRICING_UNIT_ID + else -> throw OrbInvalidDataException("Unknown Field: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Field = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Field && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Should prices that match the filter be included or excluded. */ + class Operator @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val INCLUDES = of("includes") + + val EXCLUDES = of("excludes") + + fun of(value: String) = Operator(JsonField.of(value)) + } + + /** An enum containing [Operator]'s known values. */ + enum class Known { + INCLUDES, + EXCLUDES, + } + + /** + * An enum containing [Operator]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Operator] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + INCLUDES, + EXCLUDES, + /** + * An enum member indicating that [Operator] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + INCLUDES -> Value.INCLUDES + EXCLUDES -> Value.EXCLUDES + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + INCLUDES -> Known.INCLUDES + EXCLUDES -> Known.EXCLUDES + else -> throw OrbInvalidDataException("Unknown Operator: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Operator = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Operator && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CompositePriceFilter && + field == other.field && + operator == other.operator && + values == other.values && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(field, operator, values, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CompositePriceFilter{field=$field, operator=$operator, values=$values, additionalProperties=$additionalProperties}" + } + /** * User specified key-value pairs for the resource. If not present, this defaults to an * empty dictionary. Individual keys can be removed by setting the value to `null`, and the @@ -37573,7 +46213,7 @@ private constructor( private val billingCycleConfiguration: JsonField, private val billingMode: JsonField, private val cadence: JsonField, - private val compositePriceFilters: JsonField>, + private val compositePriceFilters: JsonField>, private val conversionRate: JsonField, private val conversionRateConfig: JsonField, private val createdAt: JsonField, @@ -37614,7 +46254,7 @@ private constructor( @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), @JsonProperty("composite_price_filters") @ExcludeMissing - compositePriceFilters: JsonField> = JsonMissing.of(), + compositePriceFilters: JsonField> = JsonMissing.of(), @JsonProperty("conversion_rate") @ExcludeMissing conversionRate: JsonField = JsonMissing.of(), @@ -37739,7 +46379,7 @@ private constructor( * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun compositePriceFilters(): List? = + fun compositePriceFilters(): List? = compositePriceFilters.getNullable("composite_price_filters") /** @@ -37951,7 +46591,7 @@ private constructor( */ @JsonProperty("composite_price_filters") @ExcludeMissing - fun _compositePriceFilters(): JsonField> = compositePriceFilters + fun _compositePriceFilters(): JsonField> = compositePriceFilters /** * Returns the raw JSON value of [conversionRate]. @@ -38211,7 +46851,7 @@ private constructor( private var billingCycleConfiguration: JsonField? = null private var billingMode: JsonField? = null private var cadence: JsonField? = null - private var compositePriceFilters: JsonField>? = null + private var compositePriceFilters: JsonField>? = null private var conversionRate: JsonField? = null private var conversionRateConfig: JsonField? = null private var createdAt: JsonField? = null @@ -38333,28 +46973,28 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - fun compositePriceFilters(compositePriceFilters: List?) = + fun compositePriceFilters(compositePriceFilters: List?) = compositePriceFilters(JsonField.ofNullable(compositePriceFilters)) /** * Sets [Builder.compositePriceFilters] to an arbitrary JSON value. * * You should usually call [Builder.compositePriceFilters] with a well-typed - * `List` value instead. This method is primarily for setting the + * `List` value instead. This method is primarily for setting the * field to an undocumented or not yet supported value. */ fun compositePriceFilters( - compositePriceFilters: JsonField> + compositePriceFilters: JsonField> ) = apply { this.compositePriceFilters = compositePriceFilters.map { it.toMutableList() } } /** - * Adds a single [TransformPriceFilter] to [compositePriceFilters]. + * Adds a single [CompositePriceFilter] to [compositePriceFilters]. * * @throws IllegalStateException if the field was previously set to a non-list. */ - fun addCompositePriceFilter(compositePriceFilter: TransformPriceFilter) = apply { + fun addCompositePriceFilter(compositePriceFilter: CompositePriceFilter) = apply { compositePriceFilters = (compositePriceFilters ?: JsonField.of(mutableListOf())).also { checkKnown("compositePriceFilters", it).add(compositePriceFilter) @@ -39270,6 +47910,546 @@ private constructor( override fun toString() = value.toString() } + class CompositePriceFilter + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val field: JsonField, + private val operator: JsonField, + private val values: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("field") @ExcludeMissing field: JsonField = JsonMissing.of(), + @JsonProperty("operator") + @ExcludeMissing + operator: JsonField = JsonMissing.of(), + @JsonProperty("values") + @ExcludeMissing + values: JsonField> = JsonMissing.of(), + ) : this(field, operator, values, mutableMapOf()) + + /** + * The property of the price to filter on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun field(): Field = field.getRequired("field") + + /** + * Should prices that match the filter be included or excluded. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun operator(): Operator = operator.getRequired("operator") + + /** + * The IDs or values that match this filter. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun values(): List = values.getRequired("values") + + /** + * Returns the raw JSON value of [field]. + * + * Unlike [field], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("field") @ExcludeMissing fun _field(): JsonField = field + + /** + * Returns the raw JSON value of [operator]. + * + * Unlike [operator], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("operator") + @ExcludeMissing + fun _operator(): JsonField = operator + + /** + * Returns the raw JSON value of [values]. + * + * Unlike [values], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("values") @ExcludeMissing fun _values(): JsonField> = values + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [CompositePriceFilter]. + * + * The following fields are required: + * ```kotlin + * .field() + * .operator() + * .values() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [CompositePriceFilter]. */ + class Builder internal constructor() { + + private var field: JsonField? = null + private var operator: JsonField? = null + private var values: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(compositePriceFilter: CompositePriceFilter) = apply { + field = compositePriceFilter.field + operator = compositePriceFilter.operator + values = compositePriceFilter.values.map { it.toMutableList() } + additionalProperties = compositePriceFilter.additionalProperties.toMutableMap() + } + + /** The property of the price to filter on. */ + fun field(field: Field) = field(JsonField.of(field)) + + /** + * Sets [Builder.field] to an arbitrary JSON value. + * + * You should usually call [Builder.field] with a well-typed [Field] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun field(field: JsonField) = apply { this.field = field } + + /** Should prices that match the filter be included or excluded. */ + fun operator(operator: Operator) = operator(JsonField.of(operator)) + + /** + * Sets [Builder.operator] to an arbitrary JSON value. + * + * You should usually call [Builder.operator] with a well-typed [Operator] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun operator(operator: JsonField) = apply { this.operator = operator } + + /** The IDs or values that match this filter. */ + fun values(values: List) = values(JsonField.of(values)) + + /** + * Sets [Builder.values] to an arbitrary JSON value. + * + * You should usually call [Builder.values] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun values(values: JsonField>) = apply { + this.values = values.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [values]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addValue(value: String) = apply { + values = + (values ?: JsonField.of(mutableListOf())).also { + checkKnown("values", it).add(value) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CompositePriceFilter]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .field() + * .operator() + * .values() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CompositePriceFilter = + CompositePriceFilter( + checkRequired("field", field), + checkRequired("operator", operator), + checkRequired("values", values).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CompositePriceFilter = apply { + if (validated) { + return@apply + } + + field().validate() + operator().validate() + values() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (field.asKnown()?.validity() ?: 0) + + (operator.asKnown()?.validity() ?: 0) + + (values.asKnown()?.size ?: 0) + + /** The property of the price to filter on. */ + class Field @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val PRICE_ID = of("price_id") + + val ITEM_ID = of("item_id") + + val PRICE_TYPE = of("price_type") + + val CURRENCY = of("currency") + + val PRICING_UNIT_ID = of("pricing_unit_id") + + fun of(value: String) = Field(JsonField.of(value)) + } + + /** An enum containing [Field]'s known values. */ + enum class Known { + PRICE_ID, + ITEM_ID, + PRICE_TYPE, + CURRENCY, + PRICING_UNIT_ID, + } + + /** + * An enum containing [Field]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Field] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + PRICE_ID, + ITEM_ID, + PRICE_TYPE, + CURRENCY, + PRICING_UNIT_ID, + /** + * An enum member indicating that [Field] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + PRICE_ID -> Value.PRICE_ID + ITEM_ID -> Value.ITEM_ID + PRICE_TYPE -> Value.PRICE_TYPE + CURRENCY -> Value.CURRENCY + PRICING_UNIT_ID -> Value.PRICING_UNIT_ID + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + PRICE_ID -> Known.PRICE_ID + ITEM_ID -> Known.ITEM_ID + PRICE_TYPE -> Known.PRICE_TYPE + CURRENCY -> Known.CURRENCY + PRICING_UNIT_ID -> Known.PRICING_UNIT_ID + else -> throw OrbInvalidDataException("Unknown Field: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Field = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Field && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Should prices that match the filter be included or excluded. */ + class Operator @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val INCLUDES = of("includes") + + val EXCLUDES = of("excludes") + + fun of(value: String) = Operator(JsonField.of(value)) + } + + /** An enum containing [Operator]'s known values. */ + enum class Known { + INCLUDES, + EXCLUDES, + } + + /** + * An enum containing [Operator]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Operator] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + INCLUDES, + EXCLUDES, + /** + * An enum member indicating that [Operator] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + INCLUDES -> Value.INCLUDES + EXCLUDES -> Value.EXCLUDES + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + INCLUDES -> Known.INCLUDES + EXCLUDES -> Known.EXCLUDES + else -> throw OrbInvalidDataException("Unknown Operator: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Operator = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Operator && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CompositePriceFilter && + field == other.field && + operator == other.operator && + values == other.values && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(field, operator, values, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CompositePriceFilter{field=$field, operator=$operator, values=$values, additionalProperties=$additionalProperties}" + } + /** Configuration for grouped_allocation pricing */ class GroupedAllocationConfig @JsonCreator(mode = JsonCreator.Mode.DISABLED) @@ -39862,7 +49042,7 @@ private constructor( private val billingMode: JsonField, private val bulkWithProrationConfig: JsonField, private val cadence: JsonField, - private val compositePriceFilters: JsonField>, + private val compositePriceFilters: JsonField>, private val conversionRate: JsonField, private val conversionRateConfig: JsonField, private val createdAt: JsonField, @@ -39905,7 +49085,7 @@ private constructor( @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), @JsonProperty("composite_price_filters") @ExcludeMissing - compositePriceFilters: JsonField> = JsonMissing.of(), + compositePriceFilters: JsonField> = JsonMissing.of(), @JsonProperty("conversion_rate") @ExcludeMissing conversionRate: JsonField = JsonMissing.of(), @@ -40036,7 +49216,7 @@ private constructor( * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun compositePriceFilters(): List? = + fun compositePriceFilters(): List? = compositePriceFilters.getNullable("composite_price_filters") /** @@ -40249,7 +49429,7 @@ private constructor( */ @JsonProperty("composite_price_filters") @ExcludeMissing - fun _compositePriceFilters(): JsonField> = compositePriceFilters + fun _compositePriceFilters(): JsonField> = compositePriceFilters /** * Returns the raw JSON value of [conversionRate]. @@ -40500,7 +49680,7 @@ private constructor( private var billingMode: JsonField? = null private var bulkWithProrationConfig: JsonField? = null private var cadence: JsonField? = null - private var compositePriceFilters: JsonField>? = null + private var compositePriceFilters: JsonField>? = null private var conversionRate: JsonField? = null private var conversionRateConfig: JsonField? = null private var createdAt: JsonField? = null @@ -40636,28 +49816,28 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - fun compositePriceFilters(compositePriceFilters: List?) = + fun compositePriceFilters(compositePriceFilters: List?) = compositePriceFilters(JsonField.ofNullable(compositePriceFilters)) /** * Sets [Builder.compositePriceFilters] to an arbitrary JSON value. * * You should usually call [Builder.compositePriceFilters] with a well-typed - * `List` value instead. This method is primarily for setting the + * `List` value instead. This method is primarily for setting the * field to an undocumented or not yet supported value. */ fun compositePriceFilters( - compositePriceFilters: JsonField> + compositePriceFilters: JsonField> ) = apply { this.compositePriceFilters = compositePriceFilters.map { it.toMutableList() } } /** - * Adds a single [TransformPriceFilter] to [compositePriceFilters]. + * Adds a single [CompositePriceFilter] to [compositePriceFilters]. * * @throws IllegalStateException if the field was previously set to a non-list. */ - fun addCompositePriceFilter(compositePriceFilter: TransformPriceFilter) = apply { + fun addCompositePriceFilter(compositePriceFilter: CompositePriceFilter) = apply { compositePriceFilters = (compositePriceFilters ?: JsonField.of(mutableListOf())).also { checkKnown("compositePriceFilters", it).add(compositePriceFilter) @@ -41955,6 +51135,546 @@ private constructor( override fun toString() = value.toString() } + class CompositePriceFilter + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val field: JsonField, + private val operator: JsonField, + private val values: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("field") @ExcludeMissing field: JsonField = JsonMissing.of(), + @JsonProperty("operator") + @ExcludeMissing + operator: JsonField = JsonMissing.of(), + @JsonProperty("values") + @ExcludeMissing + values: JsonField> = JsonMissing.of(), + ) : this(field, operator, values, mutableMapOf()) + + /** + * The property of the price to filter on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun field(): Field = field.getRequired("field") + + /** + * Should prices that match the filter be included or excluded. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun operator(): Operator = operator.getRequired("operator") + + /** + * The IDs or values that match this filter. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun values(): List = values.getRequired("values") + + /** + * Returns the raw JSON value of [field]. + * + * Unlike [field], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("field") @ExcludeMissing fun _field(): JsonField = field + + /** + * Returns the raw JSON value of [operator]. + * + * Unlike [operator], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("operator") + @ExcludeMissing + fun _operator(): JsonField = operator + + /** + * Returns the raw JSON value of [values]. + * + * Unlike [values], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("values") @ExcludeMissing fun _values(): JsonField> = values + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [CompositePriceFilter]. + * + * The following fields are required: + * ```kotlin + * .field() + * .operator() + * .values() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [CompositePriceFilter]. */ + class Builder internal constructor() { + + private var field: JsonField? = null + private var operator: JsonField? = null + private var values: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(compositePriceFilter: CompositePriceFilter) = apply { + field = compositePriceFilter.field + operator = compositePriceFilter.operator + values = compositePriceFilter.values.map { it.toMutableList() } + additionalProperties = compositePriceFilter.additionalProperties.toMutableMap() + } + + /** The property of the price to filter on. */ + fun field(field: Field) = field(JsonField.of(field)) + + /** + * Sets [Builder.field] to an arbitrary JSON value. + * + * You should usually call [Builder.field] with a well-typed [Field] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun field(field: JsonField) = apply { this.field = field } + + /** Should prices that match the filter be included or excluded. */ + fun operator(operator: Operator) = operator(JsonField.of(operator)) + + /** + * Sets [Builder.operator] to an arbitrary JSON value. + * + * You should usually call [Builder.operator] with a well-typed [Operator] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun operator(operator: JsonField) = apply { this.operator = operator } + + /** The IDs or values that match this filter. */ + fun values(values: List) = values(JsonField.of(values)) + + /** + * Sets [Builder.values] to an arbitrary JSON value. + * + * You should usually call [Builder.values] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun values(values: JsonField>) = apply { + this.values = values.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [values]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addValue(value: String) = apply { + values = + (values ?: JsonField.of(mutableListOf())).also { + checkKnown("values", it).add(value) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CompositePriceFilter]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .field() + * .operator() + * .values() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CompositePriceFilter = + CompositePriceFilter( + checkRequired("field", field), + checkRequired("operator", operator), + checkRequired("values", values).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CompositePriceFilter = apply { + if (validated) { + return@apply + } + + field().validate() + operator().validate() + values() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (field.asKnown()?.validity() ?: 0) + + (operator.asKnown()?.validity() ?: 0) + + (values.asKnown()?.size ?: 0) + + /** The property of the price to filter on. */ + class Field @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val PRICE_ID = of("price_id") + + val ITEM_ID = of("item_id") + + val PRICE_TYPE = of("price_type") + + val CURRENCY = of("currency") + + val PRICING_UNIT_ID = of("pricing_unit_id") + + fun of(value: String) = Field(JsonField.of(value)) + } + + /** An enum containing [Field]'s known values. */ + enum class Known { + PRICE_ID, + ITEM_ID, + PRICE_TYPE, + CURRENCY, + PRICING_UNIT_ID, + } + + /** + * An enum containing [Field]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Field] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + PRICE_ID, + ITEM_ID, + PRICE_TYPE, + CURRENCY, + PRICING_UNIT_ID, + /** + * An enum member indicating that [Field] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + PRICE_ID -> Value.PRICE_ID + ITEM_ID -> Value.ITEM_ID + PRICE_TYPE -> Value.PRICE_TYPE + CURRENCY -> Value.CURRENCY + PRICING_UNIT_ID -> Value.PRICING_UNIT_ID + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + PRICE_ID -> Known.PRICE_ID + ITEM_ID -> Known.ITEM_ID + PRICE_TYPE -> Known.PRICE_TYPE + CURRENCY -> Known.CURRENCY + PRICING_UNIT_ID -> Known.PRICING_UNIT_ID + else -> throw OrbInvalidDataException("Unknown Field: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Field = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Field && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Should prices that match the filter be included or excluded. */ + class Operator @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val INCLUDES = of("includes") + + val EXCLUDES = of("excludes") + + fun of(value: String) = Operator(JsonField.of(value)) + } + + /** An enum containing [Operator]'s known values. */ + enum class Known { + INCLUDES, + EXCLUDES, + } + + /** + * An enum containing [Operator]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Operator] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + INCLUDES, + EXCLUDES, + /** + * An enum member indicating that [Operator] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + INCLUDES -> Value.INCLUDES + EXCLUDES -> Value.EXCLUDES + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + INCLUDES -> Known.INCLUDES + EXCLUDES -> Known.EXCLUDES + else -> throw OrbInvalidDataException("Unknown Operator: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Operator = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Operator && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CompositePriceFilter && + field == other.field && + operator == other.operator && + values == other.values && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(field, operator, values, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CompositePriceFilter{field=$field, operator=$operator, values=$values, additionalProperties=$additionalProperties}" + } + /** * User specified key-value pairs for the resource. If not present, this defaults to an * empty dictionary. Individual keys can be removed by setting the value to `null`, and the @@ -42280,7 +52000,7 @@ private constructor( private val billingCycleConfiguration: JsonField, private val billingMode: JsonField, private val cadence: JsonField, - private val compositePriceFilters: JsonField>, + private val compositePriceFilters: JsonField>, private val conversionRate: JsonField, private val conversionRateConfig: JsonField, private val createdAt: JsonField, @@ -42321,7 +52041,7 @@ private constructor( @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), @JsonProperty("composite_price_filters") @ExcludeMissing - compositePriceFilters: JsonField> = JsonMissing.of(), + compositePriceFilters: JsonField> = JsonMissing.of(), @JsonProperty("conversion_rate") @ExcludeMissing conversionRate: JsonField = JsonMissing.of(), @@ -42447,7 +52167,7 @@ private constructor( * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun compositePriceFilters(): List? = + fun compositePriceFilters(): List? = compositePriceFilters.getNullable("composite_price_filters") /** @@ -42659,7 +52379,7 @@ private constructor( */ @JsonProperty("composite_price_filters") @ExcludeMissing - fun _compositePriceFilters(): JsonField> = compositePriceFilters + fun _compositePriceFilters(): JsonField> = compositePriceFilters /** * Returns the raw JSON value of [conversionRate]. @@ -42921,7 +52641,7 @@ private constructor( private var billingCycleConfiguration: JsonField? = null private var billingMode: JsonField? = null private var cadence: JsonField? = null - private var compositePriceFilters: JsonField>? = null + private var compositePriceFilters: JsonField>? = null private var conversionRate: JsonField? = null private var conversionRateConfig: JsonField? = null private var createdAt: JsonField? = null @@ -43048,28 +52768,28 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - fun compositePriceFilters(compositePriceFilters: List?) = + fun compositePriceFilters(compositePriceFilters: List?) = compositePriceFilters(JsonField.ofNullable(compositePriceFilters)) /** * Sets [Builder.compositePriceFilters] to an arbitrary JSON value. * * You should usually call [Builder.compositePriceFilters] with a well-typed - * `List` value instead. This method is primarily for setting the + * `List` value instead. This method is primarily for setting the * field to an undocumented or not yet supported value. */ fun compositePriceFilters( - compositePriceFilters: JsonField> + compositePriceFilters: JsonField> ) = apply { this.compositePriceFilters = compositePriceFilters.map { it.toMutableList() } } /** - * Adds a single [TransformPriceFilter] to [compositePriceFilters]. + * Adds a single [CompositePriceFilter] to [compositePriceFilters]. * * @throws IllegalStateException if the field was previously set to a non-list. */ - fun addCompositePriceFilter(compositePriceFilter: TransformPriceFilter) = apply { + fun addCompositePriceFilter(compositePriceFilter: CompositePriceFilter) = apply { compositePriceFilters = (compositePriceFilters ?: JsonField.of(mutableListOf())).also { checkKnown("compositePriceFilters", it).add(compositePriceFilter) @@ -43991,6 +53711,546 @@ private constructor( override fun toString() = value.toString() } + class CompositePriceFilter + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val field: JsonField, + private val operator: JsonField, + private val values: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("field") @ExcludeMissing field: JsonField = JsonMissing.of(), + @JsonProperty("operator") + @ExcludeMissing + operator: JsonField = JsonMissing.of(), + @JsonProperty("values") + @ExcludeMissing + values: JsonField> = JsonMissing.of(), + ) : this(field, operator, values, mutableMapOf()) + + /** + * The property of the price to filter on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun field(): Field = field.getRequired("field") + + /** + * Should prices that match the filter be included or excluded. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun operator(): Operator = operator.getRequired("operator") + + /** + * The IDs or values that match this filter. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun values(): List = values.getRequired("values") + + /** + * Returns the raw JSON value of [field]. + * + * Unlike [field], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("field") @ExcludeMissing fun _field(): JsonField = field + + /** + * Returns the raw JSON value of [operator]. + * + * Unlike [operator], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("operator") + @ExcludeMissing + fun _operator(): JsonField = operator + + /** + * Returns the raw JSON value of [values]. + * + * Unlike [values], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("values") @ExcludeMissing fun _values(): JsonField> = values + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [CompositePriceFilter]. + * + * The following fields are required: + * ```kotlin + * .field() + * .operator() + * .values() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [CompositePriceFilter]. */ + class Builder internal constructor() { + + private var field: JsonField? = null + private var operator: JsonField? = null + private var values: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(compositePriceFilter: CompositePriceFilter) = apply { + field = compositePriceFilter.field + operator = compositePriceFilter.operator + values = compositePriceFilter.values.map { it.toMutableList() } + additionalProperties = compositePriceFilter.additionalProperties.toMutableMap() + } + + /** The property of the price to filter on. */ + fun field(field: Field) = field(JsonField.of(field)) + + /** + * Sets [Builder.field] to an arbitrary JSON value. + * + * You should usually call [Builder.field] with a well-typed [Field] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun field(field: JsonField) = apply { this.field = field } + + /** Should prices that match the filter be included or excluded. */ + fun operator(operator: Operator) = operator(JsonField.of(operator)) + + /** + * Sets [Builder.operator] to an arbitrary JSON value. + * + * You should usually call [Builder.operator] with a well-typed [Operator] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun operator(operator: JsonField) = apply { this.operator = operator } + + /** The IDs or values that match this filter. */ + fun values(values: List) = values(JsonField.of(values)) + + /** + * Sets [Builder.values] to an arbitrary JSON value. + * + * You should usually call [Builder.values] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun values(values: JsonField>) = apply { + this.values = values.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [values]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addValue(value: String) = apply { + values = + (values ?: JsonField.of(mutableListOf())).also { + checkKnown("values", it).add(value) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CompositePriceFilter]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .field() + * .operator() + * .values() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CompositePriceFilter = + CompositePriceFilter( + checkRequired("field", field), + checkRequired("operator", operator), + checkRequired("values", values).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CompositePriceFilter = apply { + if (validated) { + return@apply + } + + field().validate() + operator().validate() + values() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (field.asKnown()?.validity() ?: 0) + + (operator.asKnown()?.validity() ?: 0) + + (values.asKnown()?.size ?: 0) + + /** The property of the price to filter on. */ + class Field @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val PRICE_ID = of("price_id") + + val ITEM_ID = of("item_id") + + val PRICE_TYPE = of("price_type") + + val CURRENCY = of("currency") + + val PRICING_UNIT_ID = of("pricing_unit_id") + + fun of(value: String) = Field(JsonField.of(value)) + } + + /** An enum containing [Field]'s known values. */ + enum class Known { + PRICE_ID, + ITEM_ID, + PRICE_TYPE, + CURRENCY, + PRICING_UNIT_ID, + } + + /** + * An enum containing [Field]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Field] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + PRICE_ID, + ITEM_ID, + PRICE_TYPE, + CURRENCY, + PRICING_UNIT_ID, + /** + * An enum member indicating that [Field] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + PRICE_ID -> Value.PRICE_ID + ITEM_ID -> Value.ITEM_ID + PRICE_TYPE -> Value.PRICE_TYPE + CURRENCY -> Value.CURRENCY + PRICING_UNIT_ID -> Value.PRICING_UNIT_ID + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + PRICE_ID -> Known.PRICE_ID + ITEM_ID -> Known.ITEM_ID + PRICE_TYPE -> Known.PRICE_TYPE + CURRENCY -> Known.CURRENCY + PRICING_UNIT_ID -> Known.PRICING_UNIT_ID + else -> throw OrbInvalidDataException("Unknown Field: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Field = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Field && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Should prices that match the filter be included or excluded. */ + class Operator @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val INCLUDES = of("includes") + + val EXCLUDES = of("excludes") + + fun of(value: String) = Operator(JsonField.of(value)) + } + + /** An enum containing [Operator]'s known values. */ + enum class Known { + INCLUDES, + EXCLUDES, + } + + /** + * An enum containing [Operator]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Operator] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + INCLUDES, + EXCLUDES, + /** + * An enum member indicating that [Operator] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + INCLUDES -> Value.INCLUDES + EXCLUDES -> Value.EXCLUDES + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + INCLUDES -> Known.INCLUDES + EXCLUDES -> Known.EXCLUDES + else -> throw OrbInvalidDataException("Unknown Operator: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Operator = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Operator && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CompositePriceFilter && + field == other.field && + operator == other.operator && + values == other.values && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(field, operator, values, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CompositePriceFilter{field=$field, operator=$operator, values=$values, additionalProperties=$additionalProperties}" + } + /** Configuration for grouped_with_prorated_minimum pricing */ class GroupedWithProratedMinimumConfig @JsonCreator(mode = JsonCreator.Mode.DISABLED) @@ -44574,7 +54834,7 @@ private constructor( private val billingCycleConfiguration: JsonField, private val billingMode: JsonField, private val cadence: JsonField, - private val compositePriceFilters: JsonField>, + private val compositePriceFilters: JsonField>, private val conversionRate: JsonField, private val conversionRateConfig: JsonField, private val createdAt: JsonField, @@ -44615,7 +54875,7 @@ private constructor( @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), @JsonProperty("composite_price_filters") @ExcludeMissing - compositePriceFilters: JsonField> = JsonMissing.of(), + compositePriceFilters: JsonField> = JsonMissing.of(), @JsonProperty("conversion_rate") @ExcludeMissing conversionRate: JsonField = JsonMissing.of(), @@ -44741,7 +55001,7 @@ private constructor( * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun compositePriceFilters(): List? = + fun compositePriceFilters(): List? = compositePriceFilters.getNullable("composite_price_filters") /** @@ -44953,7 +55213,7 @@ private constructor( */ @JsonProperty("composite_price_filters") @ExcludeMissing - fun _compositePriceFilters(): JsonField> = compositePriceFilters + fun _compositePriceFilters(): JsonField> = compositePriceFilters /** * Returns the raw JSON value of [conversionRate]. @@ -45215,7 +55475,7 @@ private constructor( private var billingCycleConfiguration: JsonField? = null private var billingMode: JsonField? = null private var cadence: JsonField? = null - private var compositePriceFilters: JsonField>? = null + private var compositePriceFilters: JsonField>? = null private var conversionRate: JsonField? = null private var conversionRateConfig: JsonField? = null private var createdAt: JsonField? = null @@ -45341,28 +55601,28 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - fun compositePriceFilters(compositePriceFilters: List?) = + fun compositePriceFilters(compositePriceFilters: List?) = compositePriceFilters(JsonField.ofNullable(compositePriceFilters)) /** * Sets [Builder.compositePriceFilters] to an arbitrary JSON value. * * You should usually call [Builder.compositePriceFilters] with a well-typed - * `List` value instead. This method is primarily for setting the + * `List` value instead. This method is primarily for setting the * field to an undocumented or not yet supported value. */ fun compositePriceFilters( - compositePriceFilters: JsonField> + compositePriceFilters: JsonField> ) = apply { this.compositePriceFilters = compositePriceFilters.map { it.toMutableList() } } /** - * Adds a single [TransformPriceFilter] to [compositePriceFilters]. + * Adds a single [CompositePriceFilter] to [compositePriceFilters]. * * @throws IllegalStateException if the field was previously set to a non-list. */ - fun addCompositePriceFilter(compositePriceFilter: TransformPriceFilter) = apply { + fun addCompositePriceFilter(compositePriceFilter: CompositePriceFilter) = apply { compositePriceFilters = (compositePriceFilters ?: JsonField.of(mutableListOf())).also { checkKnown("compositePriceFilters", it).add(compositePriceFilter) @@ -46284,6 +56544,546 @@ private constructor( override fun toString() = value.toString() } + class CompositePriceFilter + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val field: JsonField, + private val operator: JsonField, + private val values: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("field") @ExcludeMissing field: JsonField = JsonMissing.of(), + @JsonProperty("operator") + @ExcludeMissing + operator: JsonField = JsonMissing.of(), + @JsonProperty("values") + @ExcludeMissing + values: JsonField> = JsonMissing.of(), + ) : this(field, operator, values, mutableMapOf()) + + /** + * The property of the price to filter on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun field(): Field = field.getRequired("field") + + /** + * Should prices that match the filter be included or excluded. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun operator(): Operator = operator.getRequired("operator") + + /** + * The IDs or values that match this filter. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun values(): List = values.getRequired("values") + + /** + * Returns the raw JSON value of [field]. + * + * Unlike [field], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("field") @ExcludeMissing fun _field(): JsonField = field + + /** + * Returns the raw JSON value of [operator]. + * + * Unlike [operator], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("operator") + @ExcludeMissing + fun _operator(): JsonField = operator + + /** + * Returns the raw JSON value of [values]. + * + * Unlike [values], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("values") @ExcludeMissing fun _values(): JsonField> = values + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [CompositePriceFilter]. + * + * The following fields are required: + * ```kotlin + * .field() + * .operator() + * .values() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [CompositePriceFilter]. */ + class Builder internal constructor() { + + private var field: JsonField? = null + private var operator: JsonField? = null + private var values: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(compositePriceFilter: CompositePriceFilter) = apply { + field = compositePriceFilter.field + operator = compositePriceFilter.operator + values = compositePriceFilter.values.map { it.toMutableList() } + additionalProperties = compositePriceFilter.additionalProperties.toMutableMap() + } + + /** The property of the price to filter on. */ + fun field(field: Field) = field(JsonField.of(field)) + + /** + * Sets [Builder.field] to an arbitrary JSON value. + * + * You should usually call [Builder.field] with a well-typed [Field] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun field(field: JsonField) = apply { this.field = field } + + /** Should prices that match the filter be included or excluded. */ + fun operator(operator: Operator) = operator(JsonField.of(operator)) + + /** + * Sets [Builder.operator] to an arbitrary JSON value. + * + * You should usually call [Builder.operator] with a well-typed [Operator] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun operator(operator: JsonField) = apply { this.operator = operator } + + /** The IDs or values that match this filter. */ + fun values(values: List) = values(JsonField.of(values)) + + /** + * Sets [Builder.values] to an arbitrary JSON value. + * + * You should usually call [Builder.values] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun values(values: JsonField>) = apply { + this.values = values.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [values]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addValue(value: String) = apply { + values = + (values ?: JsonField.of(mutableListOf())).also { + checkKnown("values", it).add(value) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CompositePriceFilter]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .field() + * .operator() + * .values() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CompositePriceFilter = + CompositePriceFilter( + checkRequired("field", field), + checkRequired("operator", operator), + checkRequired("values", values).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CompositePriceFilter = apply { + if (validated) { + return@apply + } + + field().validate() + operator().validate() + values() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (field.asKnown()?.validity() ?: 0) + + (operator.asKnown()?.validity() ?: 0) + + (values.asKnown()?.size ?: 0) + + /** The property of the price to filter on. */ + class Field @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val PRICE_ID = of("price_id") + + val ITEM_ID = of("item_id") + + val PRICE_TYPE = of("price_type") + + val CURRENCY = of("currency") + + val PRICING_UNIT_ID = of("pricing_unit_id") + + fun of(value: String) = Field(JsonField.of(value)) + } + + /** An enum containing [Field]'s known values. */ + enum class Known { + PRICE_ID, + ITEM_ID, + PRICE_TYPE, + CURRENCY, + PRICING_UNIT_ID, + } + + /** + * An enum containing [Field]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Field] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + PRICE_ID, + ITEM_ID, + PRICE_TYPE, + CURRENCY, + PRICING_UNIT_ID, + /** + * An enum member indicating that [Field] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + PRICE_ID -> Value.PRICE_ID + ITEM_ID -> Value.ITEM_ID + PRICE_TYPE -> Value.PRICE_TYPE + CURRENCY -> Value.CURRENCY + PRICING_UNIT_ID -> Value.PRICING_UNIT_ID + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + PRICE_ID -> Known.PRICE_ID + ITEM_ID -> Known.ITEM_ID + PRICE_TYPE -> Known.PRICE_TYPE + CURRENCY -> Known.CURRENCY + PRICING_UNIT_ID -> Known.PRICING_UNIT_ID + else -> throw OrbInvalidDataException("Unknown Field: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Field = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Field && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Should prices that match the filter be included or excluded. */ + class Operator @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val INCLUDES = of("includes") + + val EXCLUDES = of("excludes") + + fun of(value: String) = Operator(JsonField.of(value)) + } + + /** An enum containing [Operator]'s known values. */ + enum class Known { + INCLUDES, + EXCLUDES, + } + + /** + * An enum containing [Operator]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Operator] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + INCLUDES, + EXCLUDES, + /** + * An enum member indicating that [Operator] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + INCLUDES -> Value.INCLUDES + EXCLUDES -> Value.EXCLUDES + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + INCLUDES -> Known.INCLUDES + EXCLUDES -> Known.EXCLUDES + else -> throw OrbInvalidDataException("Unknown Operator: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Operator = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Operator && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CompositePriceFilter && + field == other.field && + operator == other.operator && + values == other.values && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(field, operator, values, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CompositePriceFilter{field=$field, operator=$operator, values=$values, additionalProperties=$additionalProperties}" + } + /** Configuration for grouped_with_metered_minimum pricing */ class GroupedWithMeteredMinimumConfig @JsonCreator(mode = JsonCreator.Mode.DISABLED) @@ -47503,7 +58303,7 @@ private constructor( private val billingCycleConfiguration: JsonField, private val billingMode: JsonField, private val cadence: JsonField, - private val compositePriceFilters: JsonField>, + private val compositePriceFilters: JsonField>, private val conversionRate: JsonField, private val conversionRateConfig: JsonField, private val createdAt: JsonField, @@ -47544,7 +58344,7 @@ private constructor( @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), @JsonProperty("composite_price_filters") @ExcludeMissing - compositePriceFilters: JsonField> = JsonMissing.of(), + compositePriceFilters: JsonField> = JsonMissing.of(), @JsonProperty("conversion_rate") @ExcludeMissing conversionRate: JsonField = JsonMissing.of(), @@ -47670,7 +58470,7 @@ private constructor( * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun compositePriceFilters(): List? = + fun compositePriceFilters(): List? = compositePriceFilters.getNullable("composite_price_filters") /** @@ -47882,7 +58682,7 @@ private constructor( */ @JsonProperty("composite_price_filters") @ExcludeMissing - fun _compositePriceFilters(): JsonField> = compositePriceFilters + fun _compositePriceFilters(): JsonField> = compositePriceFilters /** * Returns the raw JSON value of [conversionRate]. @@ -48144,7 +58944,7 @@ private constructor( private var billingCycleConfiguration: JsonField? = null private var billingMode: JsonField? = null private var cadence: JsonField? = null - private var compositePriceFilters: JsonField>? = null + private var compositePriceFilters: JsonField>? = null private var conversionRate: JsonField? = null private var conversionRateConfig: JsonField? = null private var createdAt: JsonField? = null @@ -48272,28 +59072,28 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - fun compositePriceFilters(compositePriceFilters: List?) = + fun compositePriceFilters(compositePriceFilters: List?) = compositePriceFilters(JsonField.ofNullable(compositePriceFilters)) /** * Sets [Builder.compositePriceFilters] to an arbitrary JSON value. * * You should usually call [Builder.compositePriceFilters] with a well-typed - * `List` value instead. This method is primarily for setting the + * `List` value instead. This method is primarily for setting the * field to an undocumented or not yet supported value. */ fun compositePriceFilters( - compositePriceFilters: JsonField> + compositePriceFilters: JsonField> ) = apply { this.compositePriceFilters = compositePriceFilters.map { it.toMutableList() } } /** - * Adds a single [TransformPriceFilter] to [compositePriceFilters]. + * Adds a single [CompositePriceFilter] to [compositePriceFilters]. * * @throws IllegalStateException if the field was previously set to a non-list. */ - fun addCompositePriceFilter(compositePriceFilter: TransformPriceFilter) = apply { + fun addCompositePriceFilter(compositePriceFilter: CompositePriceFilter) = apply { compositePriceFilters = (compositePriceFilters ?: JsonField.of(mutableListOf())).also { checkKnown("compositePriceFilters", it).add(compositePriceFilter) @@ -49215,6 +60015,546 @@ private constructor( override fun toString() = value.toString() } + class CompositePriceFilter + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val field: JsonField, + private val operator: JsonField, + private val values: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("field") @ExcludeMissing field: JsonField = JsonMissing.of(), + @JsonProperty("operator") + @ExcludeMissing + operator: JsonField = JsonMissing.of(), + @JsonProperty("values") + @ExcludeMissing + values: JsonField> = JsonMissing.of(), + ) : this(field, operator, values, mutableMapOf()) + + /** + * The property of the price to filter on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun field(): Field = field.getRequired("field") + + /** + * Should prices that match the filter be included or excluded. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun operator(): Operator = operator.getRequired("operator") + + /** + * The IDs or values that match this filter. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun values(): List = values.getRequired("values") + + /** + * Returns the raw JSON value of [field]. + * + * Unlike [field], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("field") @ExcludeMissing fun _field(): JsonField = field + + /** + * Returns the raw JSON value of [operator]. + * + * Unlike [operator], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("operator") + @ExcludeMissing + fun _operator(): JsonField = operator + + /** + * Returns the raw JSON value of [values]. + * + * Unlike [values], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("values") @ExcludeMissing fun _values(): JsonField> = values + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [CompositePriceFilter]. + * + * The following fields are required: + * ```kotlin + * .field() + * .operator() + * .values() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [CompositePriceFilter]. */ + class Builder internal constructor() { + + private var field: JsonField? = null + private var operator: JsonField? = null + private var values: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(compositePriceFilter: CompositePriceFilter) = apply { + field = compositePriceFilter.field + operator = compositePriceFilter.operator + values = compositePriceFilter.values.map { it.toMutableList() } + additionalProperties = compositePriceFilter.additionalProperties.toMutableMap() + } + + /** The property of the price to filter on. */ + fun field(field: Field) = field(JsonField.of(field)) + + /** + * Sets [Builder.field] to an arbitrary JSON value. + * + * You should usually call [Builder.field] with a well-typed [Field] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun field(field: JsonField) = apply { this.field = field } + + /** Should prices that match the filter be included or excluded. */ + fun operator(operator: Operator) = operator(JsonField.of(operator)) + + /** + * Sets [Builder.operator] to an arbitrary JSON value. + * + * You should usually call [Builder.operator] with a well-typed [Operator] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun operator(operator: JsonField) = apply { this.operator = operator } + + /** The IDs or values that match this filter. */ + fun values(values: List) = values(JsonField.of(values)) + + /** + * Sets [Builder.values] to an arbitrary JSON value. + * + * You should usually call [Builder.values] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun values(values: JsonField>) = apply { + this.values = values.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [values]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addValue(value: String) = apply { + values = + (values ?: JsonField.of(mutableListOf())).also { + checkKnown("values", it).add(value) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CompositePriceFilter]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .field() + * .operator() + * .values() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CompositePriceFilter = + CompositePriceFilter( + checkRequired("field", field), + checkRequired("operator", operator), + checkRequired("values", values).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CompositePriceFilter = apply { + if (validated) { + return@apply + } + + field().validate() + operator().validate() + values() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (field.asKnown()?.validity() ?: 0) + + (operator.asKnown()?.validity() ?: 0) + + (values.asKnown()?.size ?: 0) + + /** The property of the price to filter on. */ + class Field @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val PRICE_ID = of("price_id") + + val ITEM_ID = of("item_id") + + val PRICE_TYPE = of("price_type") + + val CURRENCY = of("currency") + + val PRICING_UNIT_ID = of("pricing_unit_id") + + fun of(value: String) = Field(JsonField.of(value)) + } + + /** An enum containing [Field]'s known values. */ + enum class Known { + PRICE_ID, + ITEM_ID, + PRICE_TYPE, + CURRENCY, + PRICING_UNIT_ID, + } + + /** + * An enum containing [Field]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Field] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + PRICE_ID, + ITEM_ID, + PRICE_TYPE, + CURRENCY, + PRICING_UNIT_ID, + /** + * An enum member indicating that [Field] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + PRICE_ID -> Value.PRICE_ID + ITEM_ID -> Value.ITEM_ID + PRICE_TYPE -> Value.PRICE_TYPE + CURRENCY -> Value.CURRENCY + PRICING_UNIT_ID -> Value.PRICING_UNIT_ID + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + PRICE_ID -> Known.PRICE_ID + ITEM_ID -> Known.ITEM_ID + PRICE_TYPE -> Known.PRICE_TYPE + CURRENCY -> Known.CURRENCY + PRICING_UNIT_ID -> Known.PRICING_UNIT_ID + else -> throw OrbInvalidDataException("Unknown Field: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Field = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Field && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Should prices that match the filter be included or excluded. */ + class Operator @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val INCLUDES = of("includes") + + val EXCLUDES = of("excludes") + + fun of(value: String) = Operator(JsonField.of(value)) + } + + /** An enum containing [Operator]'s known values. */ + enum class Known { + INCLUDES, + EXCLUDES, + } + + /** + * An enum containing [Operator]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Operator] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + INCLUDES, + EXCLUDES, + /** + * An enum member indicating that [Operator] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + INCLUDES -> Value.INCLUDES + EXCLUDES -> Value.EXCLUDES + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + INCLUDES -> Known.INCLUDES + EXCLUDES -> Known.EXCLUDES + else -> throw OrbInvalidDataException("Unknown Operator: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Operator = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Operator && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CompositePriceFilter && + field == other.field && + operator == other.operator && + values == other.values && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(field, operator, values, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CompositePriceFilter{field=$field, operator=$operator, values=$values, additionalProperties=$additionalProperties}" + } + /** Configuration for grouped_with_min_max_thresholds pricing */ class GroupedWithMinMaxThresholdsConfig @JsonCreator(mode = JsonCreator.Mode.DISABLED) @@ -49860,7 +61200,7 @@ private constructor( private val billingCycleConfiguration: JsonField, private val billingMode: JsonField, private val cadence: JsonField, - private val compositePriceFilters: JsonField>, + private val compositePriceFilters: JsonField>, private val conversionRate: JsonField, private val conversionRateConfig: JsonField, private val createdAt: JsonField, @@ -49901,7 +61241,7 @@ private constructor( @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), @JsonProperty("composite_price_filters") @ExcludeMissing - compositePriceFilters: JsonField> = JsonMissing.of(), + compositePriceFilters: JsonField> = JsonMissing.of(), @JsonProperty("conversion_rate") @ExcludeMissing conversionRate: JsonField = JsonMissing.of(), @@ -50026,7 +61366,7 @@ private constructor( * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun compositePriceFilters(): List? = + fun compositePriceFilters(): List? = compositePriceFilters.getNullable("composite_price_filters") /** @@ -50238,7 +61578,7 @@ private constructor( */ @JsonProperty("composite_price_filters") @ExcludeMissing - fun _compositePriceFilters(): JsonField> = compositePriceFilters + fun _compositePriceFilters(): JsonField> = compositePriceFilters /** * Returns the raw JSON value of [conversionRate]. @@ -50499,7 +61839,7 @@ private constructor( private var billingCycleConfiguration: JsonField? = null private var billingMode: JsonField? = null private var cadence: JsonField? = null - private var compositePriceFilters: JsonField>? = null + private var compositePriceFilters: JsonField>? = null private var conversionRate: JsonField? = null private var conversionRateConfig: JsonField? = null private var createdAt: JsonField? = null @@ -50621,28 +61961,28 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - fun compositePriceFilters(compositePriceFilters: List?) = + fun compositePriceFilters(compositePriceFilters: List?) = compositePriceFilters(JsonField.ofNullable(compositePriceFilters)) /** * Sets [Builder.compositePriceFilters] to an arbitrary JSON value. * * You should usually call [Builder.compositePriceFilters] with a well-typed - * `List` value instead. This method is primarily for setting the + * `List` value instead. This method is primarily for setting the * field to an undocumented or not yet supported value. */ fun compositePriceFilters( - compositePriceFilters: JsonField> + compositePriceFilters: JsonField> ) = apply { this.compositePriceFilters = compositePriceFilters.map { it.toMutableList() } } /** - * Adds a single [TransformPriceFilter] to [compositePriceFilters]. + * Adds a single [CompositePriceFilter] to [compositePriceFilters]. * * @throws IllegalStateException if the field was previously set to a non-list. */ - fun addCompositePriceFilter(compositePriceFilter: TransformPriceFilter) = apply { + fun addCompositePriceFilter(compositePriceFilter: CompositePriceFilter) = apply { compositePriceFilters = (compositePriceFilters ?: JsonField.of(mutableListOf())).also { checkKnown("compositePriceFilters", it).add(compositePriceFilter) @@ -51559,6 +62899,546 @@ private constructor( override fun toString() = value.toString() } + class CompositePriceFilter + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val field: JsonField, + private val operator: JsonField, + private val values: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("field") @ExcludeMissing field: JsonField = JsonMissing.of(), + @JsonProperty("operator") + @ExcludeMissing + operator: JsonField = JsonMissing.of(), + @JsonProperty("values") + @ExcludeMissing + values: JsonField> = JsonMissing.of(), + ) : this(field, operator, values, mutableMapOf()) + + /** + * The property of the price to filter on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun field(): Field = field.getRequired("field") + + /** + * Should prices that match the filter be included or excluded. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun operator(): Operator = operator.getRequired("operator") + + /** + * The IDs or values that match this filter. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun values(): List = values.getRequired("values") + + /** + * Returns the raw JSON value of [field]. + * + * Unlike [field], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("field") @ExcludeMissing fun _field(): JsonField = field + + /** + * Returns the raw JSON value of [operator]. + * + * Unlike [operator], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("operator") + @ExcludeMissing + fun _operator(): JsonField = operator + + /** + * Returns the raw JSON value of [values]. + * + * Unlike [values], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("values") @ExcludeMissing fun _values(): JsonField> = values + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [CompositePriceFilter]. + * + * The following fields are required: + * ```kotlin + * .field() + * .operator() + * .values() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [CompositePriceFilter]. */ + class Builder internal constructor() { + + private var field: JsonField? = null + private var operator: JsonField? = null + private var values: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(compositePriceFilter: CompositePriceFilter) = apply { + field = compositePriceFilter.field + operator = compositePriceFilter.operator + values = compositePriceFilter.values.map { it.toMutableList() } + additionalProperties = compositePriceFilter.additionalProperties.toMutableMap() + } + + /** The property of the price to filter on. */ + fun field(field: Field) = field(JsonField.of(field)) + + /** + * Sets [Builder.field] to an arbitrary JSON value. + * + * You should usually call [Builder.field] with a well-typed [Field] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun field(field: JsonField) = apply { this.field = field } + + /** Should prices that match the filter be included or excluded. */ + fun operator(operator: Operator) = operator(JsonField.of(operator)) + + /** + * Sets [Builder.operator] to an arbitrary JSON value. + * + * You should usually call [Builder.operator] with a well-typed [Operator] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun operator(operator: JsonField) = apply { this.operator = operator } + + /** The IDs or values that match this filter. */ + fun values(values: List) = values(JsonField.of(values)) + + /** + * Sets [Builder.values] to an arbitrary JSON value. + * + * You should usually call [Builder.values] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun values(values: JsonField>) = apply { + this.values = values.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [values]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addValue(value: String) = apply { + values = + (values ?: JsonField.of(mutableListOf())).also { + checkKnown("values", it).add(value) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CompositePriceFilter]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .field() + * .operator() + * .values() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CompositePriceFilter = + CompositePriceFilter( + checkRequired("field", field), + checkRequired("operator", operator), + checkRequired("values", values).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CompositePriceFilter = apply { + if (validated) { + return@apply + } + + field().validate() + operator().validate() + values() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (field.asKnown()?.validity() ?: 0) + + (operator.asKnown()?.validity() ?: 0) + + (values.asKnown()?.size ?: 0) + + /** The property of the price to filter on. */ + class Field @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val PRICE_ID = of("price_id") + + val ITEM_ID = of("item_id") + + val PRICE_TYPE = of("price_type") + + val CURRENCY = of("currency") + + val PRICING_UNIT_ID = of("pricing_unit_id") + + fun of(value: String) = Field(JsonField.of(value)) + } + + /** An enum containing [Field]'s known values. */ + enum class Known { + PRICE_ID, + ITEM_ID, + PRICE_TYPE, + CURRENCY, + PRICING_UNIT_ID, + } + + /** + * An enum containing [Field]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Field] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + PRICE_ID, + ITEM_ID, + PRICE_TYPE, + CURRENCY, + PRICING_UNIT_ID, + /** + * An enum member indicating that [Field] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + PRICE_ID -> Value.PRICE_ID + ITEM_ID -> Value.ITEM_ID + PRICE_TYPE -> Value.PRICE_TYPE + CURRENCY -> Value.CURRENCY + PRICING_UNIT_ID -> Value.PRICING_UNIT_ID + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + PRICE_ID -> Known.PRICE_ID + ITEM_ID -> Known.ITEM_ID + PRICE_TYPE -> Known.PRICE_TYPE + CURRENCY -> Known.CURRENCY + PRICING_UNIT_ID -> Known.PRICING_UNIT_ID + else -> throw OrbInvalidDataException("Unknown Field: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Field = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Field && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Should prices that match the filter be included or excluded. */ + class Operator @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val INCLUDES = of("includes") + + val EXCLUDES = of("excludes") + + fun of(value: String) = Operator(JsonField.of(value)) + } + + /** An enum containing [Operator]'s known values. */ + enum class Known { + INCLUDES, + EXCLUDES, + } + + /** + * An enum containing [Operator]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Operator] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + INCLUDES, + EXCLUDES, + /** + * An enum member indicating that [Operator] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + INCLUDES -> Value.INCLUDES + EXCLUDES -> Value.EXCLUDES + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + INCLUDES -> Known.INCLUDES + EXCLUDES -> Known.EXCLUDES + else -> throw OrbInvalidDataException("Unknown Operator: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Operator = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Operator && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CompositePriceFilter && + field == other.field && + operator == other.operator && + values == other.values && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(field, operator, values, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CompositePriceFilter{field=$field, operator=$operator, values=$values, additionalProperties=$additionalProperties}" + } + /** Configuration for matrix_with_display_name pricing */ class MatrixWithDisplayNameConfig @JsonCreator(mode = JsonCreator.Mode.DISABLED) @@ -52381,7 +64261,7 @@ private constructor( private val billingCycleConfiguration: JsonField, private val billingMode: JsonField, private val cadence: JsonField, - private val compositePriceFilters: JsonField>, + private val compositePriceFilters: JsonField>, private val conversionRate: JsonField, private val conversionRateConfig: JsonField, private val createdAt: JsonField, @@ -52422,7 +64302,7 @@ private constructor( @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), @JsonProperty("composite_price_filters") @ExcludeMissing - compositePriceFilters: JsonField> = JsonMissing.of(), + compositePriceFilters: JsonField> = JsonMissing.of(), @JsonProperty("conversion_rate") @ExcludeMissing conversionRate: JsonField = JsonMissing.of(), @@ -52547,7 +64427,7 @@ private constructor( * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun compositePriceFilters(): List? = + fun compositePriceFilters(): List? = compositePriceFilters.getNullable("composite_price_filters") /** @@ -52759,7 +64639,7 @@ private constructor( */ @JsonProperty("composite_price_filters") @ExcludeMissing - fun _compositePriceFilters(): JsonField> = compositePriceFilters + fun _compositePriceFilters(): JsonField> = compositePriceFilters /** * Returns the raw JSON value of [conversionRate]. @@ -53020,7 +64900,7 @@ private constructor( private var billingCycleConfiguration: JsonField? = null private var billingMode: JsonField? = null private var cadence: JsonField? = null - private var compositePriceFilters: JsonField>? = null + private var compositePriceFilters: JsonField>? = null private var conversionRate: JsonField? = null private var conversionRateConfig: JsonField? = null private var createdAt: JsonField? = null @@ -53142,28 +65022,28 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - fun compositePriceFilters(compositePriceFilters: List?) = + fun compositePriceFilters(compositePriceFilters: List?) = compositePriceFilters(JsonField.ofNullable(compositePriceFilters)) /** * Sets [Builder.compositePriceFilters] to an arbitrary JSON value. * * You should usually call [Builder.compositePriceFilters] with a well-typed - * `List` value instead. This method is primarily for setting the + * `List` value instead. This method is primarily for setting the * field to an undocumented or not yet supported value. */ fun compositePriceFilters( - compositePriceFilters: JsonField> + compositePriceFilters: JsonField> ) = apply { this.compositePriceFilters = compositePriceFilters.map { it.toMutableList() } } /** - * Adds a single [TransformPriceFilter] to [compositePriceFilters]. + * Adds a single [CompositePriceFilter] to [compositePriceFilters]. * * @throws IllegalStateException if the field was previously set to a non-list. */ - fun addCompositePriceFilter(compositePriceFilter: TransformPriceFilter) = apply { + fun addCompositePriceFilter(compositePriceFilter: CompositePriceFilter) = apply { compositePriceFilters = (compositePriceFilters ?: JsonField.of(mutableListOf())).also { checkKnown("compositePriceFilters", it).add(compositePriceFilter) @@ -54079,6 +65959,546 @@ private constructor( override fun toString() = value.toString() } + class CompositePriceFilter + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val field: JsonField, + private val operator: JsonField, + private val values: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("field") @ExcludeMissing field: JsonField = JsonMissing.of(), + @JsonProperty("operator") + @ExcludeMissing + operator: JsonField = JsonMissing.of(), + @JsonProperty("values") + @ExcludeMissing + values: JsonField> = JsonMissing.of(), + ) : this(field, operator, values, mutableMapOf()) + + /** + * The property of the price to filter on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun field(): Field = field.getRequired("field") + + /** + * Should prices that match the filter be included or excluded. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun operator(): Operator = operator.getRequired("operator") + + /** + * The IDs or values that match this filter. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun values(): List = values.getRequired("values") + + /** + * Returns the raw JSON value of [field]. + * + * Unlike [field], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("field") @ExcludeMissing fun _field(): JsonField = field + + /** + * Returns the raw JSON value of [operator]. + * + * Unlike [operator], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("operator") + @ExcludeMissing + fun _operator(): JsonField = operator + + /** + * Returns the raw JSON value of [values]. + * + * Unlike [values], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("values") @ExcludeMissing fun _values(): JsonField> = values + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [CompositePriceFilter]. + * + * The following fields are required: + * ```kotlin + * .field() + * .operator() + * .values() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [CompositePriceFilter]. */ + class Builder internal constructor() { + + private var field: JsonField? = null + private var operator: JsonField? = null + private var values: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(compositePriceFilter: CompositePriceFilter) = apply { + field = compositePriceFilter.field + operator = compositePriceFilter.operator + values = compositePriceFilter.values.map { it.toMutableList() } + additionalProperties = compositePriceFilter.additionalProperties.toMutableMap() + } + + /** The property of the price to filter on. */ + fun field(field: Field) = field(JsonField.of(field)) + + /** + * Sets [Builder.field] to an arbitrary JSON value. + * + * You should usually call [Builder.field] with a well-typed [Field] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun field(field: JsonField) = apply { this.field = field } + + /** Should prices that match the filter be included or excluded. */ + fun operator(operator: Operator) = operator(JsonField.of(operator)) + + /** + * Sets [Builder.operator] to an arbitrary JSON value. + * + * You should usually call [Builder.operator] with a well-typed [Operator] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun operator(operator: JsonField) = apply { this.operator = operator } + + /** The IDs or values that match this filter. */ + fun values(values: List) = values(JsonField.of(values)) + + /** + * Sets [Builder.values] to an arbitrary JSON value. + * + * You should usually call [Builder.values] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun values(values: JsonField>) = apply { + this.values = values.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [values]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addValue(value: String) = apply { + values = + (values ?: JsonField.of(mutableListOf())).also { + checkKnown("values", it).add(value) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CompositePriceFilter]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .field() + * .operator() + * .values() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CompositePriceFilter = + CompositePriceFilter( + checkRequired("field", field), + checkRequired("operator", operator), + checkRequired("values", values).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CompositePriceFilter = apply { + if (validated) { + return@apply + } + + field().validate() + operator().validate() + values() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (field.asKnown()?.validity() ?: 0) + + (operator.asKnown()?.validity() ?: 0) + + (values.asKnown()?.size ?: 0) + + /** The property of the price to filter on. */ + class Field @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val PRICE_ID = of("price_id") + + val ITEM_ID = of("item_id") + + val PRICE_TYPE = of("price_type") + + val CURRENCY = of("currency") + + val PRICING_UNIT_ID = of("pricing_unit_id") + + fun of(value: String) = Field(JsonField.of(value)) + } + + /** An enum containing [Field]'s known values. */ + enum class Known { + PRICE_ID, + ITEM_ID, + PRICE_TYPE, + CURRENCY, + PRICING_UNIT_ID, + } + + /** + * An enum containing [Field]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Field] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + PRICE_ID, + ITEM_ID, + PRICE_TYPE, + CURRENCY, + PRICING_UNIT_ID, + /** + * An enum member indicating that [Field] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + PRICE_ID -> Value.PRICE_ID + ITEM_ID -> Value.ITEM_ID + PRICE_TYPE -> Value.PRICE_TYPE + CURRENCY -> Value.CURRENCY + PRICING_UNIT_ID -> Value.PRICING_UNIT_ID + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + PRICE_ID -> Known.PRICE_ID + ITEM_ID -> Known.ITEM_ID + PRICE_TYPE -> Known.PRICE_TYPE + CURRENCY -> Known.CURRENCY + PRICING_UNIT_ID -> Known.PRICING_UNIT_ID + else -> throw OrbInvalidDataException("Unknown Field: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Field = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Field && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Should prices that match the filter be included or excluded. */ + class Operator @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val INCLUDES = of("includes") + + val EXCLUDES = of("excludes") + + fun of(value: String) = Operator(JsonField.of(value)) + } + + /** An enum containing [Operator]'s known values. */ + enum class Known { + INCLUDES, + EXCLUDES, + } + + /** + * An enum containing [Operator]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Operator] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + INCLUDES, + EXCLUDES, + /** + * An enum member indicating that [Operator] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + INCLUDES -> Value.INCLUDES + EXCLUDES -> Value.EXCLUDES + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + INCLUDES -> Known.INCLUDES + EXCLUDES -> Known.EXCLUDES + else -> throw OrbInvalidDataException("Unknown Operator: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Operator = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Operator && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CompositePriceFilter && + field == other.field && + operator == other.operator && + values == other.values && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(field, operator, values, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CompositePriceFilter{field=$field, operator=$operator, values=$values, additionalProperties=$additionalProperties}" + } + /** Configuration for grouped_tiered_package pricing */ class GroupedTieredPackageConfig @JsonCreator(mode = JsonCreator.Mode.DISABLED) @@ -54899,7 +67319,7 @@ private constructor( private val billingCycleConfiguration: JsonField, private val billingMode: JsonField, private val cadence: JsonField, - private val compositePriceFilters: JsonField>, + private val compositePriceFilters: JsonField>, private val conversionRate: JsonField, private val conversionRateConfig: JsonField, private val createdAt: JsonField, @@ -54940,7 +67360,7 @@ private constructor( @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), @JsonProperty("composite_price_filters") @ExcludeMissing - compositePriceFilters: JsonField> = JsonMissing.of(), + compositePriceFilters: JsonField> = JsonMissing.of(), @JsonProperty("conversion_rate") @ExcludeMissing conversionRate: JsonField = JsonMissing.of(), @@ -55065,7 +67485,7 @@ private constructor( * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun compositePriceFilters(): List? = + fun compositePriceFilters(): List? = compositePriceFilters.getNullable("composite_price_filters") /** @@ -55277,7 +67697,7 @@ private constructor( */ @JsonProperty("composite_price_filters") @ExcludeMissing - fun _compositePriceFilters(): JsonField> = compositePriceFilters + fun _compositePriceFilters(): JsonField> = compositePriceFilters /** * Returns the raw JSON value of [conversionRate]. @@ -55538,7 +67958,7 @@ private constructor( private var billingCycleConfiguration: JsonField? = null private var billingMode: JsonField? = null private var cadence: JsonField? = null - private var compositePriceFilters: JsonField>? = null + private var compositePriceFilters: JsonField>? = null private var conversionRate: JsonField? = null private var conversionRateConfig: JsonField? = null private var createdAt: JsonField? = null @@ -55660,28 +68080,28 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - fun compositePriceFilters(compositePriceFilters: List?) = + fun compositePriceFilters(compositePriceFilters: List?) = compositePriceFilters(JsonField.ofNullable(compositePriceFilters)) /** * Sets [Builder.compositePriceFilters] to an arbitrary JSON value. * * You should usually call [Builder.compositePriceFilters] with a well-typed - * `List` value instead. This method is primarily for setting the + * `List` value instead. This method is primarily for setting the * field to an undocumented or not yet supported value. */ fun compositePriceFilters( - compositePriceFilters: JsonField> + compositePriceFilters: JsonField> ) = apply { this.compositePriceFilters = compositePriceFilters.map { it.toMutableList() } } /** - * Adds a single [TransformPriceFilter] to [compositePriceFilters]. + * Adds a single [CompositePriceFilter] to [compositePriceFilters]. * * @throws IllegalStateException if the field was previously set to a non-list. */ - fun addCompositePriceFilter(compositePriceFilter: TransformPriceFilter) = apply { + fun addCompositePriceFilter(compositePriceFilter: CompositePriceFilter) = apply { compositePriceFilters = (compositePriceFilters ?: JsonField.of(mutableListOf())).also { checkKnown("compositePriceFilters", it).add(compositePriceFilter) @@ -56598,6 +69018,546 @@ private constructor( override fun toString() = value.toString() } + class CompositePriceFilter + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val field: JsonField, + private val operator: JsonField, + private val values: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("field") @ExcludeMissing field: JsonField = JsonMissing.of(), + @JsonProperty("operator") + @ExcludeMissing + operator: JsonField = JsonMissing.of(), + @JsonProperty("values") + @ExcludeMissing + values: JsonField> = JsonMissing.of(), + ) : this(field, operator, values, mutableMapOf()) + + /** + * The property of the price to filter on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun field(): Field = field.getRequired("field") + + /** + * Should prices that match the filter be included or excluded. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun operator(): Operator = operator.getRequired("operator") + + /** + * The IDs or values that match this filter. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun values(): List = values.getRequired("values") + + /** + * Returns the raw JSON value of [field]. + * + * Unlike [field], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("field") @ExcludeMissing fun _field(): JsonField = field + + /** + * Returns the raw JSON value of [operator]. + * + * Unlike [operator], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("operator") + @ExcludeMissing + fun _operator(): JsonField = operator + + /** + * Returns the raw JSON value of [values]. + * + * Unlike [values], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("values") @ExcludeMissing fun _values(): JsonField> = values + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [CompositePriceFilter]. + * + * The following fields are required: + * ```kotlin + * .field() + * .operator() + * .values() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [CompositePriceFilter]. */ + class Builder internal constructor() { + + private var field: JsonField? = null + private var operator: JsonField? = null + private var values: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(compositePriceFilter: CompositePriceFilter) = apply { + field = compositePriceFilter.field + operator = compositePriceFilter.operator + values = compositePriceFilter.values.map { it.toMutableList() } + additionalProperties = compositePriceFilter.additionalProperties.toMutableMap() + } + + /** The property of the price to filter on. */ + fun field(field: Field) = field(JsonField.of(field)) + + /** + * Sets [Builder.field] to an arbitrary JSON value. + * + * You should usually call [Builder.field] with a well-typed [Field] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun field(field: JsonField) = apply { this.field = field } + + /** Should prices that match the filter be included or excluded. */ + fun operator(operator: Operator) = operator(JsonField.of(operator)) + + /** + * Sets [Builder.operator] to an arbitrary JSON value. + * + * You should usually call [Builder.operator] with a well-typed [Operator] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun operator(operator: JsonField) = apply { this.operator = operator } + + /** The IDs or values that match this filter. */ + fun values(values: List) = values(JsonField.of(values)) + + /** + * Sets [Builder.values] to an arbitrary JSON value. + * + * You should usually call [Builder.values] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun values(values: JsonField>) = apply { + this.values = values.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [values]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addValue(value: String) = apply { + values = + (values ?: JsonField.of(mutableListOf())).also { + checkKnown("values", it).add(value) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CompositePriceFilter]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .field() + * .operator() + * .values() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CompositePriceFilter = + CompositePriceFilter( + checkRequired("field", field), + checkRequired("operator", operator), + checkRequired("values", values).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CompositePriceFilter = apply { + if (validated) { + return@apply + } + + field().validate() + operator().validate() + values() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (field.asKnown()?.validity() ?: 0) + + (operator.asKnown()?.validity() ?: 0) + + (values.asKnown()?.size ?: 0) + + /** The property of the price to filter on. */ + class Field @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val PRICE_ID = of("price_id") + + val ITEM_ID = of("item_id") + + val PRICE_TYPE = of("price_type") + + val CURRENCY = of("currency") + + val PRICING_UNIT_ID = of("pricing_unit_id") + + fun of(value: String) = Field(JsonField.of(value)) + } + + /** An enum containing [Field]'s known values. */ + enum class Known { + PRICE_ID, + ITEM_ID, + PRICE_TYPE, + CURRENCY, + PRICING_UNIT_ID, + } + + /** + * An enum containing [Field]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Field] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + PRICE_ID, + ITEM_ID, + PRICE_TYPE, + CURRENCY, + PRICING_UNIT_ID, + /** + * An enum member indicating that [Field] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + PRICE_ID -> Value.PRICE_ID + ITEM_ID -> Value.ITEM_ID + PRICE_TYPE -> Value.PRICE_TYPE + CURRENCY -> Value.CURRENCY + PRICING_UNIT_ID -> Value.PRICING_UNIT_ID + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + PRICE_ID -> Known.PRICE_ID + ITEM_ID -> Known.ITEM_ID + PRICE_TYPE -> Known.PRICE_TYPE + CURRENCY -> Known.CURRENCY + PRICING_UNIT_ID -> Known.PRICING_UNIT_ID + else -> throw OrbInvalidDataException("Unknown Field: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Field = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Field && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Should prices that match the filter be included or excluded. */ + class Operator @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val INCLUDES = of("includes") + + val EXCLUDES = of("excludes") + + fun of(value: String) = Operator(JsonField.of(value)) + } + + /** An enum containing [Operator]'s known values. */ + enum class Known { + INCLUDES, + EXCLUDES, + } + + /** + * An enum containing [Operator]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Operator] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + INCLUDES, + EXCLUDES, + /** + * An enum member indicating that [Operator] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + INCLUDES -> Value.INCLUDES + EXCLUDES -> Value.EXCLUDES + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + INCLUDES -> Known.INCLUDES + EXCLUDES -> Known.EXCLUDES + else -> throw OrbInvalidDataException("Unknown Operator: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Operator = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Operator && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CompositePriceFilter && + field == other.field && + operator == other.operator && + values == other.values && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(field, operator, values, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CompositePriceFilter{field=$field, operator=$operator, values=$values, additionalProperties=$additionalProperties}" + } + /** Configuration for max_group_tiered_package pricing */ class MaxGroupTieredPackageConfig @JsonCreator(mode = JsonCreator.Mode.DISABLED) @@ -57421,7 +70381,7 @@ private constructor( private val billingCycleConfiguration: JsonField, private val billingMode: JsonField, private val cadence: JsonField, - private val compositePriceFilters: JsonField>, + private val compositePriceFilters: JsonField>, private val conversionRate: JsonField, private val conversionRateConfig: JsonField, private val createdAt: JsonField, @@ -57463,7 +70423,7 @@ private constructor( @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), @JsonProperty("composite_price_filters") @ExcludeMissing - compositePriceFilters: JsonField> = JsonMissing.of(), + compositePriceFilters: JsonField> = JsonMissing.of(), @JsonProperty("conversion_rate") @ExcludeMissing conversionRate: JsonField = JsonMissing.of(), @@ -57589,7 +70549,7 @@ private constructor( * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun compositePriceFilters(): List? = + fun compositePriceFilters(): List? = compositePriceFilters.getNullable("composite_price_filters") /** @@ -57803,7 +70763,7 @@ private constructor( */ @JsonProperty("composite_price_filters") @ExcludeMissing - fun _compositePriceFilters(): JsonField> = compositePriceFilters + fun _compositePriceFilters(): JsonField> = compositePriceFilters /** * Returns the raw JSON value of [conversionRate]. @@ -58065,7 +71025,7 @@ private constructor( private var billingCycleConfiguration: JsonField? = null private var billingMode: JsonField? = null private var cadence: JsonField? = null - private var compositePriceFilters: JsonField>? = null + private var compositePriceFilters: JsonField>? = null private var conversionRate: JsonField? = null private var conversionRateConfig: JsonField? = null private var createdAt: JsonField? = null @@ -58197,28 +71157,28 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - fun compositePriceFilters(compositePriceFilters: List?) = + fun compositePriceFilters(compositePriceFilters: List?) = compositePriceFilters(JsonField.ofNullable(compositePriceFilters)) /** * Sets [Builder.compositePriceFilters] to an arbitrary JSON value. * * You should usually call [Builder.compositePriceFilters] with a well-typed - * `List` value instead. This method is primarily for setting the + * `List` value instead. This method is primarily for setting the * field to an undocumented or not yet supported value. */ fun compositePriceFilters( - compositePriceFilters: JsonField> + compositePriceFilters: JsonField> ) = apply { this.compositePriceFilters = compositePriceFilters.map { it.toMutableList() } } /** - * Adds a single [TransformPriceFilter] to [compositePriceFilters]. + * Adds a single [CompositePriceFilter] to [compositePriceFilters]. * * @throws IllegalStateException if the field was previously set to a non-list. */ - fun addCompositePriceFilter(compositePriceFilter: TransformPriceFilter) = apply { + fun addCompositePriceFilter(compositePriceFilter: CompositePriceFilter) = apply { compositePriceFilters = (compositePriceFilters ?: JsonField.of(mutableListOf())).also { checkKnown("compositePriceFilters", it).add(compositePriceFilter) @@ -59145,6 +72105,546 @@ private constructor( override fun toString() = value.toString() } + class CompositePriceFilter + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val field: JsonField, + private val operator: JsonField, + private val values: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("field") @ExcludeMissing field: JsonField = JsonMissing.of(), + @JsonProperty("operator") + @ExcludeMissing + operator: JsonField = JsonMissing.of(), + @JsonProperty("values") + @ExcludeMissing + values: JsonField> = JsonMissing.of(), + ) : this(field, operator, values, mutableMapOf()) + + /** + * The property of the price to filter on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun field(): Field = field.getRequired("field") + + /** + * Should prices that match the filter be included or excluded. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun operator(): Operator = operator.getRequired("operator") + + /** + * The IDs or values that match this filter. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun values(): List = values.getRequired("values") + + /** + * Returns the raw JSON value of [field]. + * + * Unlike [field], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("field") @ExcludeMissing fun _field(): JsonField = field + + /** + * Returns the raw JSON value of [operator]. + * + * Unlike [operator], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("operator") + @ExcludeMissing + fun _operator(): JsonField = operator + + /** + * Returns the raw JSON value of [values]. + * + * Unlike [values], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("values") @ExcludeMissing fun _values(): JsonField> = values + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [CompositePriceFilter]. + * + * The following fields are required: + * ```kotlin + * .field() + * .operator() + * .values() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [CompositePriceFilter]. */ + class Builder internal constructor() { + + private var field: JsonField? = null + private var operator: JsonField? = null + private var values: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(compositePriceFilter: CompositePriceFilter) = apply { + field = compositePriceFilter.field + operator = compositePriceFilter.operator + values = compositePriceFilter.values.map { it.toMutableList() } + additionalProperties = compositePriceFilter.additionalProperties.toMutableMap() + } + + /** The property of the price to filter on. */ + fun field(field: Field) = field(JsonField.of(field)) + + /** + * Sets [Builder.field] to an arbitrary JSON value. + * + * You should usually call [Builder.field] with a well-typed [Field] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun field(field: JsonField) = apply { this.field = field } + + /** Should prices that match the filter be included or excluded. */ + fun operator(operator: Operator) = operator(JsonField.of(operator)) + + /** + * Sets [Builder.operator] to an arbitrary JSON value. + * + * You should usually call [Builder.operator] with a well-typed [Operator] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun operator(operator: JsonField) = apply { this.operator = operator } + + /** The IDs or values that match this filter. */ + fun values(values: List) = values(JsonField.of(values)) + + /** + * Sets [Builder.values] to an arbitrary JSON value. + * + * You should usually call [Builder.values] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun values(values: JsonField>) = apply { + this.values = values.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [values]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addValue(value: String) = apply { + values = + (values ?: JsonField.of(mutableListOf())).also { + checkKnown("values", it).add(value) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CompositePriceFilter]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .field() + * .operator() + * .values() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CompositePriceFilter = + CompositePriceFilter( + checkRequired("field", field), + checkRequired("operator", operator), + checkRequired("values", values).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CompositePriceFilter = apply { + if (validated) { + return@apply + } + + field().validate() + operator().validate() + values() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (field.asKnown()?.validity() ?: 0) + + (operator.asKnown()?.validity() ?: 0) + + (values.asKnown()?.size ?: 0) + + /** The property of the price to filter on. */ + class Field @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val PRICE_ID = of("price_id") + + val ITEM_ID = of("item_id") + + val PRICE_TYPE = of("price_type") + + val CURRENCY = of("currency") + + val PRICING_UNIT_ID = of("pricing_unit_id") + + fun of(value: String) = Field(JsonField.of(value)) + } + + /** An enum containing [Field]'s known values. */ + enum class Known { + PRICE_ID, + ITEM_ID, + PRICE_TYPE, + CURRENCY, + PRICING_UNIT_ID, + } + + /** + * An enum containing [Field]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Field] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + PRICE_ID, + ITEM_ID, + PRICE_TYPE, + CURRENCY, + PRICING_UNIT_ID, + /** + * An enum member indicating that [Field] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + PRICE_ID -> Value.PRICE_ID + ITEM_ID -> Value.ITEM_ID + PRICE_TYPE -> Value.PRICE_TYPE + CURRENCY -> Value.CURRENCY + PRICING_UNIT_ID -> Value.PRICING_UNIT_ID + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + PRICE_ID -> Known.PRICE_ID + ITEM_ID -> Known.ITEM_ID + PRICE_TYPE -> Known.PRICE_TYPE + CURRENCY -> Known.CURRENCY + PRICING_UNIT_ID -> Known.PRICING_UNIT_ID + else -> throw OrbInvalidDataException("Unknown Field: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Field = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Field && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Should prices that match the filter be included or excluded. */ + class Operator @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val INCLUDES = of("includes") + + val EXCLUDES = of("excludes") + + fun of(value: String) = Operator(JsonField.of(value)) + } + + /** An enum containing [Operator]'s known values. */ + enum class Known { + INCLUDES, + EXCLUDES, + } + + /** + * An enum containing [Operator]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Operator] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + INCLUDES, + EXCLUDES, + /** + * An enum member indicating that [Operator] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + INCLUDES -> Value.INCLUDES + EXCLUDES -> Value.EXCLUDES + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + INCLUDES -> Known.INCLUDES + EXCLUDES -> Known.EXCLUDES + else -> throw OrbInvalidDataException("Unknown Operator: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Operator = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Operator && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CompositePriceFilter && + field == other.field && + operator == other.operator && + values == other.values && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(field, operator, values, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CompositePriceFilter{field=$field, operator=$operator, values=$values, additionalProperties=$additionalProperties}" + } + /** * User specified key-value pairs for the resource. If not present, this defaults to an * empty dictionary. Individual keys can be removed by setting the value to `null`, and the @@ -60131,7 +73631,7 @@ private constructor( private val billingCycleConfiguration: JsonField, private val billingMode: JsonField, private val cadence: JsonField, - private val compositePriceFilters: JsonField>, + private val compositePriceFilters: JsonField>, private val conversionRate: JsonField, private val conversionRateConfig: JsonField, private val createdAt: JsonField, @@ -60173,7 +73673,7 @@ private constructor( @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), @JsonProperty("composite_price_filters") @ExcludeMissing - compositePriceFilters: JsonField> = JsonMissing.of(), + compositePriceFilters: JsonField> = JsonMissing.of(), @JsonProperty("conversion_rate") @ExcludeMissing conversionRate: JsonField = JsonMissing.of(), @@ -60300,7 +73800,7 @@ private constructor( * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun compositePriceFilters(): List? = + fun compositePriceFilters(): List? = compositePriceFilters.getNullable("composite_price_filters") /** @@ -60514,7 +74014,7 @@ private constructor( */ @JsonProperty("composite_price_filters") @ExcludeMissing - fun _compositePriceFilters(): JsonField> = compositePriceFilters + fun _compositePriceFilters(): JsonField> = compositePriceFilters /** * Returns the raw JSON value of [conversionRate]. @@ -60776,7 +74276,7 @@ private constructor( private var billingCycleConfiguration: JsonField? = null private var billingMode: JsonField? = null private var cadence: JsonField? = null - private var compositePriceFilters: JsonField>? = null + private var compositePriceFilters: JsonField>? = null private var conversionRate: JsonField? = null private var conversionRateConfig: JsonField? = null private var createdAt: JsonField? = null @@ -60908,28 +74408,28 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - fun compositePriceFilters(compositePriceFilters: List?) = + fun compositePriceFilters(compositePriceFilters: List?) = compositePriceFilters(JsonField.ofNullable(compositePriceFilters)) /** * Sets [Builder.compositePriceFilters] to an arbitrary JSON value. * * You should usually call [Builder.compositePriceFilters] with a well-typed - * `List` value instead. This method is primarily for setting the + * `List` value instead. This method is primarily for setting the * field to an undocumented or not yet supported value. */ fun compositePriceFilters( - compositePriceFilters: JsonField> + compositePriceFilters: JsonField> ) = apply { this.compositePriceFilters = compositePriceFilters.map { it.toMutableList() } } /** - * Adds a single [TransformPriceFilter] to [compositePriceFilters]. + * Adds a single [CompositePriceFilter] to [compositePriceFilters]. * * @throws IllegalStateException if the field was previously set to a non-list. */ - fun addCompositePriceFilter(compositePriceFilter: TransformPriceFilter) = apply { + fun addCompositePriceFilter(compositePriceFilter: CompositePriceFilter) = apply { compositePriceFilters = (compositePriceFilters ?: JsonField.of(mutableListOf())).also { checkKnown("compositePriceFilters", it).add(compositePriceFilter) @@ -61857,6 +75357,546 @@ private constructor( override fun toString() = value.toString() } + class CompositePriceFilter + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val field: JsonField, + private val operator: JsonField, + private val values: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("field") @ExcludeMissing field: JsonField = JsonMissing.of(), + @JsonProperty("operator") + @ExcludeMissing + operator: JsonField = JsonMissing.of(), + @JsonProperty("values") + @ExcludeMissing + values: JsonField> = JsonMissing.of(), + ) : this(field, operator, values, mutableMapOf()) + + /** + * The property of the price to filter on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun field(): Field = field.getRequired("field") + + /** + * Should prices that match the filter be included or excluded. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun operator(): Operator = operator.getRequired("operator") + + /** + * The IDs or values that match this filter. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun values(): List = values.getRequired("values") + + /** + * Returns the raw JSON value of [field]. + * + * Unlike [field], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("field") @ExcludeMissing fun _field(): JsonField = field + + /** + * Returns the raw JSON value of [operator]. + * + * Unlike [operator], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("operator") + @ExcludeMissing + fun _operator(): JsonField = operator + + /** + * Returns the raw JSON value of [values]. + * + * Unlike [values], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("values") @ExcludeMissing fun _values(): JsonField> = values + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [CompositePriceFilter]. + * + * The following fields are required: + * ```kotlin + * .field() + * .operator() + * .values() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [CompositePriceFilter]. */ + class Builder internal constructor() { + + private var field: JsonField? = null + private var operator: JsonField? = null + private var values: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(compositePriceFilter: CompositePriceFilter) = apply { + field = compositePriceFilter.field + operator = compositePriceFilter.operator + values = compositePriceFilter.values.map { it.toMutableList() } + additionalProperties = compositePriceFilter.additionalProperties.toMutableMap() + } + + /** The property of the price to filter on. */ + fun field(field: Field) = field(JsonField.of(field)) + + /** + * Sets [Builder.field] to an arbitrary JSON value. + * + * You should usually call [Builder.field] with a well-typed [Field] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun field(field: JsonField) = apply { this.field = field } + + /** Should prices that match the filter be included or excluded. */ + fun operator(operator: Operator) = operator(JsonField.of(operator)) + + /** + * Sets [Builder.operator] to an arbitrary JSON value. + * + * You should usually call [Builder.operator] with a well-typed [Operator] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun operator(operator: JsonField) = apply { this.operator = operator } + + /** The IDs or values that match this filter. */ + fun values(values: List) = values(JsonField.of(values)) + + /** + * Sets [Builder.values] to an arbitrary JSON value. + * + * You should usually call [Builder.values] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun values(values: JsonField>) = apply { + this.values = values.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [values]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addValue(value: String) = apply { + values = + (values ?: JsonField.of(mutableListOf())).also { + checkKnown("values", it).add(value) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CompositePriceFilter]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .field() + * .operator() + * .values() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CompositePriceFilter = + CompositePriceFilter( + checkRequired("field", field), + checkRequired("operator", operator), + checkRequired("values", values).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CompositePriceFilter = apply { + if (validated) { + return@apply + } + + field().validate() + operator().validate() + values() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (field.asKnown()?.validity() ?: 0) + + (operator.asKnown()?.validity() ?: 0) + + (values.asKnown()?.size ?: 0) + + /** The property of the price to filter on. */ + class Field @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val PRICE_ID = of("price_id") + + val ITEM_ID = of("item_id") + + val PRICE_TYPE = of("price_type") + + val CURRENCY = of("currency") + + val PRICING_UNIT_ID = of("pricing_unit_id") + + fun of(value: String) = Field(JsonField.of(value)) + } + + /** An enum containing [Field]'s known values. */ + enum class Known { + PRICE_ID, + ITEM_ID, + PRICE_TYPE, + CURRENCY, + PRICING_UNIT_ID, + } + + /** + * An enum containing [Field]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Field] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + PRICE_ID, + ITEM_ID, + PRICE_TYPE, + CURRENCY, + PRICING_UNIT_ID, + /** + * An enum member indicating that [Field] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + PRICE_ID -> Value.PRICE_ID + ITEM_ID -> Value.ITEM_ID + PRICE_TYPE -> Value.PRICE_TYPE + CURRENCY -> Value.CURRENCY + PRICING_UNIT_ID -> Value.PRICING_UNIT_ID + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + PRICE_ID -> Known.PRICE_ID + ITEM_ID -> Known.ITEM_ID + PRICE_TYPE -> Known.PRICE_TYPE + CURRENCY -> Known.CURRENCY + PRICING_UNIT_ID -> Known.PRICING_UNIT_ID + else -> throw OrbInvalidDataException("Unknown Field: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Field = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Field && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Should prices that match the filter be included or excluded. */ + class Operator @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val INCLUDES = of("includes") + + val EXCLUDES = of("excludes") + + fun of(value: String) = Operator(JsonField.of(value)) + } + + /** An enum containing [Operator]'s known values. */ + enum class Known { + INCLUDES, + EXCLUDES, + } + + /** + * An enum containing [Operator]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Operator] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + INCLUDES, + EXCLUDES, + /** + * An enum member indicating that [Operator] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + INCLUDES -> Value.INCLUDES + EXCLUDES -> Value.EXCLUDES + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + INCLUDES -> Known.INCLUDES + EXCLUDES -> Known.EXCLUDES + else -> throw OrbInvalidDataException("Unknown Operator: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Operator = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Operator && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CompositePriceFilter && + field == other.field && + operator == other.operator && + values == other.values && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(field, operator, values, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CompositePriceFilter{field=$field, operator=$operator, values=$values, additionalProperties=$additionalProperties}" + } + /** * User specified key-value pairs for the resource. If not present, this defaults to an * empty dictionary. Individual keys can be removed by setting the value to `null`, and the @@ -63022,7 +77062,7 @@ private constructor( private val billingCycleConfiguration: JsonField, private val billingMode: JsonField, private val cadence: JsonField, - private val compositePriceFilters: JsonField>, + private val compositePriceFilters: JsonField>, private val conversionRate: JsonField, private val conversionRateConfig: JsonField, private val createdAt: JsonField, @@ -63063,7 +77103,7 @@ private constructor( @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), @JsonProperty("composite_price_filters") @ExcludeMissing - compositePriceFilters: JsonField> = JsonMissing.of(), + compositePriceFilters: JsonField> = JsonMissing.of(), @JsonProperty("conversion_rate") @ExcludeMissing conversionRate: JsonField = JsonMissing.of(), @@ -63188,7 +77228,7 @@ private constructor( * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun compositePriceFilters(): List? = + fun compositePriceFilters(): List? = compositePriceFilters.getNullable("composite_price_filters") /** @@ -63400,7 +77440,7 @@ private constructor( */ @JsonProperty("composite_price_filters") @ExcludeMissing - fun _compositePriceFilters(): JsonField> = compositePriceFilters + fun _compositePriceFilters(): JsonField> = compositePriceFilters /** * Returns the raw JSON value of [conversionRate]. @@ -63661,7 +77701,7 @@ private constructor( private var billingCycleConfiguration: JsonField? = null private var billingMode: JsonField? = null private var cadence: JsonField? = null - private var compositePriceFilters: JsonField>? = null + private var compositePriceFilters: JsonField>? = null private var conversionRate: JsonField? = null private var conversionRateConfig: JsonField? = null private var createdAt: JsonField? = null @@ -63783,28 +77823,28 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - fun compositePriceFilters(compositePriceFilters: List?) = + fun compositePriceFilters(compositePriceFilters: List?) = compositePriceFilters(JsonField.ofNullable(compositePriceFilters)) /** * Sets [Builder.compositePriceFilters] to an arbitrary JSON value. * * You should usually call [Builder.compositePriceFilters] with a well-typed - * `List` value instead. This method is primarily for setting the + * `List` value instead. This method is primarily for setting the * field to an undocumented or not yet supported value. */ fun compositePriceFilters( - compositePriceFilters: JsonField> + compositePriceFilters: JsonField> ) = apply { this.compositePriceFilters = compositePriceFilters.map { it.toMutableList() } } /** - * Adds a single [TransformPriceFilter] to [compositePriceFilters]. + * Adds a single [CompositePriceFilter] to [compositePriceFilters]. * * @throws IllegalStateException if the field was previously set to a non-list. */ - fun addCompositePriceFilter(compositePriceFilter: TransformPriceFilter) = apply { + fun addCompositePriceFilter(compositePriceFilter: CompositePriceFilter) = apply { compositePriceFilters = (compositePriceFilters ?: JsonField.of(mutableListOf())).also { checkKnown("compositePriceFilters", it).add(compositePriceFilter) @@ -64721,6 +78761,546 @@ private constructor( override fun toString() = value.toString() } + class CompositePriceFilter + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val field: JsonField, + private val operator: JsonField, + private val values: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("field") @ExcludeMissing field: JsonField = JsonMissing.of(), + @JsonProperty("operator") + @ExcludeMissing + operator: JsonField = JsonMissing.of(), + @JsonProperty("values") + @ExcludeMissing + values: JsonField> = JsonMissing.of(), + ) : this(field, operator, values, mutableMapOf()) + + /** + * The property of the price to filter on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun field(): Field = field.getRequired("field") + + /** + * Should prices that match the filter be included or excluded. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun operator(): Operator = operator.getRequired("operator") + + /** + * The IDs or values that match this filter. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun values(): List = values.getRequired("values") + + /** + * Returns the raw JSON value of [field]. + * + * Unlike [field], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("field") @ExcludeMissing fun _field(): JsonField = field + + /** + * Returns the raw JSON value of [operator]. + * + * Unlike [operator], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("operator") + @ExcludeMissing + fun _operator(): JsonField = operator + + /** + * Returns the raw JSON value of [values]. + * + * Unlike [values], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("values") @ExcludeMissing fun _values(): JsonField> = values + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [CompositePriceFilter]. + * + * The following fields are required: + * ```kotlin + * .field() + * .operator() + * .values() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [CompositePriceFilter]. */ + class Builder internal constructor() { + + private var field: JsonField? = null + private var operator: JsonField? = null + private var values: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(compositePriceFilter: CompositePriceFilter) = apply { + field = compositePriceFilter.field + operator = compositePriceFilter.operator + values = compositePriceFilter.values.map { it.toMutableList() } + additionalProperties = compositePriceFilter.additionalProperties.toMutableMap() + } + + /** The property of the price to filter on. */ + fun field(field: Field) = field(JsonField.of(field)) + + /** + * Sets [Builder.field] to an arbitrary JSON value. + * + * You should usually call [Builder.field] with a well-typed [Field] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun field(field: JsonField) = apply { this.field = field } + + /** Should prices that match the filter be included or excluded. */ + fun operator(operator: Operator) = operator(JsonField.of(operator)) + + /** + * Sets [Builder.operator] to an arbitrary JSON value. + * + * You should usually call [Builder.operator] with a well-typed [Operator] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun operator(operator: JsonField) = apply { this.operator = operator } + + /** The IDs or values that match this filter. */ + fun values(values: List) = values(JsonField.of(values)) + + /** + * Sets [Builder.values] to an arbitrary JSON value. + * + * You should usually call [Builder.values] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun values(values: JsonField>) = apply { + this.values = values.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [values]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addValue(value: String) = apply { + values = + (values ?: JsonField.of(mutableListOf())).also { + checkKnown("values", it).add(value) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CompositePriceFilter]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .field() + * .operator() + * .values() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CompositePriceFilter = + CompositePriceFilter( + checkRequired("field", field), + checkRequired("operator", operator), + checkRequired("values", values).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CompositePriceFilter = apply { + if (validated) { + return@apply + } + + field().validate() + operator().validate() + values() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (field.asKnown()?.validity() ?: 0) + + (operator.asKnown()?.validity() ?: 0) + + (values.asKnown()?.size ?: 0) + + /** The property of the price to filter on. */ + class Field @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val PRICE_ID = of("price_id") + + val ITEM_ID = of("item_id") + + val PRICE_TYPE = of("price_type") + + val CURRENCY = of("currency") + + val PRICING_UNIT_ID = of("pricing_unit_id") + + fun of(value: String) = Field(JsonField.of(value)) + } + + /** An enum containing [Field]'s known values. */ + enum class Known { + PRICE_ID, + ITEM_ID, + PRICE_TYPE, + CURRENCY, + PRICING_UNIT_ID, + } + + /** + * An enum containing [Field]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Field] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + PRICE_ID, + ITEM_ID, + PRICE_TYPE, + CURRENCY, + PRICING_UNIT_ID, + /** + * An enum member indicating that [Field] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + PRICE_ID -> Value.PRICE_ID + ITEM_ID -> Value.ITEM_ID + PRICE_TYPE -> Value.PRICE_TYPE + CURRENCY -> Value.CURRENCY + PRICING_UNIT_ID -> Value.PRICING_UNIT_ID + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + PRICE_ID -> Known.PRICE_ID + ITEM_ID -> Known.ITEM_ID + PRICE_TYPE -> Known.PRICE_TYPE + CURRENCY -> Known.CURRENCY + PRICING_UNIT_ID -> Known.PRICING_UNIT_ID + else -> throw OrbInvalidDataException("Unknown Field: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Field = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Field && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Should prices that match the filter be included or excluded. */ + class Operator @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val INCLUDES = of("includes") + + val EXCLUDES = of("excludes") + + fun of(value: String) = Operator(JsonField.of(value)) + } + + /** An enum containing [Operator]'s known values. */ + enum class Known { + INCLUDES, + EXCLUDES, + } + + /** + * An enum containing [Operator]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Operator] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + INCLUDES, + EXCLUDES, + /** + * An enum member indicating that [Operator] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + INCLUDES -> Value.INCLUDES + EXCLUDES -> Value.EXCLUDES + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + INCLUDES -> Known.INCLUDES + EXCLUDES -> Known.EXCLUDES + else -> throw OrbInvalidDataException("Unknown Operator: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Operator = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Operator && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CompositePriceFilter && + field == other.field && + operator == other.operator && + values == other.values && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(field, operator, values, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CompositePriceFilter{field=$field, operator=$operator, values=$values, additionalProperties=$additionalProperties}" + } + /** Configuration for cumulative_grouped_bulk pricing */ class CumulativeGroupedBulkConfig @JsonCreator(mode = JsonCreator.Mode.DISABLED) @@ -65539,7 +80119,7 @@ private constructor( private val billingCycleConfiguration: JsonField, private val billingMode: JsonField, private val cadence: JsonField, - private val compositePriceFilters: JsonField>, + private val compositePriceFilters: JsonField>, private val conversionRate: JsonField, private val conversionRateConfig: JsonField, private val createdAt: JsonField, @@ -65580,7 +80160,7 @@ private constructor( @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), @JsonProperty("composite_price_filters") @ExcludeMissing - compositePriceFilters: JsonField> = JsonMissing.of(), + compositePriceFilters: JsonField> = JsonMissing.of(), @JsonProperty("conversion_rate") @ExcludeMissing conversionRate: JsonField = JsonMissing.of(), @@ -65705,7 +80285,7 @@ private constructor( * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun compositePriceFilters(): List? = + fun compositePriceFilters(): List? = compositePriceFilters.getNullable("composite_price_filters") /** @@ -65916,7 +80496,7 @@ private constructor( */ @JsonProperty("composite_price_filters") @ExcludeMissing - fun _compositePriceFilters(): JsonField> = compositePriceFilters + fun _compositePriceFilters(): JsonField> = compositePriceFilters /** * Returns the raw JSON value of [conversionRate]. @@ -66176,7 +80756,7 @@ private constructor( private var billingCycleConfiguration: JsonField? = null private var billingMode: JsonField? = null private var cadence: JsonField? = null - private var compositePriceFilters: JsonField>? = null + private var compositePriceFilters: JsonField>? = null private var conversionRate: JsonField? = null private var conversionRateConfig: JsonField? = null private var createdAt: JsonField? = null @@ -66297,28 +80877,28 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - fun compositePriceFilters(compositePriceFilters: List?) = + fun compositePriceFilters(compositePriceFilters: List?) = compositePriceFilters(JsonField.ofNullable(compositePriceFilters)) /** * Sets [Builder.compositePriceFilters] to an arbitrary JSON value. * * You should usually call [Builder.compositePriceFilters] with a well-typed - * `List` value instead. This method is primarily for setting the + * `List` value instead. This method is primarily for setting the * field to an undocumented or not yet supported value. */ fun compositePriceFilters( - compositePriceFilters: JsonField> + compositePriceFilters: JsonField> ) = apply { this.compositePriceFilters = compositePriceFilters.map { it.toMutableList() } } /** - * Adds a single [TransformPriceFilter] to [compositePriceFilters]. + * Adds a single [CompositePriceFilter] to [compositePriceFilters]. * * @throws IllegalStateException if the field was previously set to a non-list. */ - fun addCompositePriceFilter(compositePriceFilter: TransformPriceFilter) = apply { + fun addCompositePriceFilter(compositePriceFilter: CompositePriceFilter) = apply { compositePriceFilters = (compositePriceFilters ?: JsonField.of(mutableListOf())).also { checkKnown("compositePriceFilters", it).add(compositePriceFilter) @@ -67234,6 +81814,546 @@ private constructor( override fun toString() = value.toString() } + class CompositePriceFilter + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val field: JsonField, + private val operator: JsonField, + private val values: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("field") @ExcludeMissing field: JsonField = JsonMissing.of(), + @JsonProperty("operator") + @ExcludeMissing + operator: JsonField = JsonMissing.of(), + @JsonProperty("values") + @ExcludeMissing + values: JsonField> = JsonMissing.of(), + ) : this(field, operator, values, mutableMapOf()) + + /** + * The property of the price to filter on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun field(): Field = field.getRequired("field") + + /** + * Should prices that match the filter be included or excluded. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun operator(): Operator = operator.getRequired("operator") + + /** + * The IDs or values that match this filter. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun values(): List = values.getRequired("values") + + /** + * Returns the raw JSON value of [field]. + * + * Unlike [field], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("field") @ExcludeMissing fun _field(): JsonField = field + + /** + * Returns the raw JSON value of [operator]. + * + * Unlike [operator], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("operator") + @ExcludeMissing + fun _operator(): JsonField = operator + + /** + * Returns the raw JSON value of [values]. + * + * Unlike [values], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("values") @ExcludeMissing fun _values(): JsonField> = values + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [CompositePriceFilter]. + * + * The following fields are required: + * ```kotlin + * .field() + * .operator() + * .values() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [CompositePriceFilter]. */ + class Builder internal constructor() { + + private var field: JsonField? = null + private var operator: JsonField? = null + private var values: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(compositePriceFilter: CompositePriceFilter) = apply { + field = compositePriceFilter.field + operator = compositePriceFilter.operator + values = compositePriceFilter.values.map { it.toMutableList() } + additionalProperties = compositePriceFilter.additionalProperties.toMutableMap() + } + + /** The property of the price to filter on. */ + fun field(field: Field) = field(JsonField.of(field)) + + /** + * Sets [Builder.field] to an arbitrary JSON value. + * + * You should usually call [Builder.field] with a well-typed [Field] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun field(field: JsonField) = apply { this.field = field } + + /** Should prices that match the filter be included or excluded. */ + fun operator(operator: Operator) = operator(JsonField.of(operator)) + + /** + * Sets [Builder.operator] to an arbitrary JSON value. + * + * You should usually call [Builder.operator] with a well-typed [Operator] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun operator(operator: JsonField) = apply { this.operator = operator } + + /** The IDs or values that match this filter. */ + fun values(values: List) = values(JsonField.of(values)) + + /** + * Sets [Builder.values] to an arbitrary JSON value. + * + * You should usually call [Builder.values] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun values(values: JsonField>) = apply { + this.values = values.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [values]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addValue(value: String) = apply { + values = + (values ?: JsonField.of(mutableListOf())).also { + checkKnown("values", it).add(value) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CompositePriceFilter]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .field() + * .operator() + * .values() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CompositePriceFilter = + CompositePriceFilter( + checkRequired("field", field), + checkRequired("operator", operator), + checkRequired("values", values).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CompositePriceFilter = apply { + if (validated) { + return@apply + } + + field().validate() + operator().validate() + values() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (field.asKnown()?.validity() ?: 0) + + (operator.asKnown()?.validity() ?: 0) + + (values.asKnown()?.size ?: 0) + + /** The property of the price to filter on. */ + class Field @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val PRICE_ID = of("price_id") + + val ITEM_ID = of("item_id") + + val PRICE_TYPE = of("price_type") + + val CURRENCY = of("currency") + + val PRICING_UNIT_ID = of("pricing_unit_id") + + fun of(value: String) = Field(JsonField.of(value)) + } + + /** An enum containing [Field]'s known values. */ + enum class Known { + PRICE_ID, + ITEM_ID, + PRICE_TYPE, + CURRENCY, + PRICING_UNIT_ID, + } + + /** + * An enum containing [Field]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Field] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + PRICE_ID, + ITEM_ID, + PRICE_TYPE, + CURRENCY, + PRICING_UNIT_ID, + /** + * An enum member indicating that [Field] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + PRICE_ID -> Value.PRICE_ID + ITEM_ID -> Value.ITEM_ID + PRICE_TYPE -> Value.PRICE_TYPE + CURRENCY -> Value.CURRENCY + PRICING_UNIT_ID -> Value.PRICING_UNIT_ID + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + PRICE_ID -> Known.PRICE_ID + ITEM_ID -> Known.ITEM_ID + PRICE_TYPE -> Known.PRICE_TYPE + CURRENCY -> Known.CURRENCY + PRICING_UNIT_ID -> Known.PRICING_UNIT_ID + else -> throw OrbInvalidDataException("Unknown Field: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Field = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Field && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Should prices that match the filter be included or excluded. */ + class Operator @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val INCLUDES = of("includes") + + val EXCLUDES = of("excludes") + + fun of(value: String) = Operator(JsonField.of(value)) + } + + /** An enum containing [Operator]'s known values. */ + enum class Known { + INCLUDES, + EXCLUDES, + } + + /** + * An enum containing [Operator]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Operator] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + INCLUDES, + EXCLUDES, + /** + * An enum member indicating that [Operator] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + INCLUDES -> Value.INCLUDES + EXCLUDES -> Value.EXCLUDES + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + INCLUDES -> Known.INCLUDES + EXCLUDES -> Known.EXCLUDES + else -> throw OrbInvalidDataException("Unknown Operator: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Operator = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Operator && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CompositePriceFilter && + field == other.field && + operator == other.operator && + values == other.values && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(field, operator, values, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CompositePriceFilter{field=$field, operator=$operator, values=$values, additionalProperties=$additionalProperties}" + } + /** * User specified key-value pairs for the resource. If not present, this defaults to an * empty dictionary. Individual keys can be removed by setting the value to `null`, and the @@ -67771,7 +82891,7 @@ private constructor( private val billingCycleConfiguration: JsonField, private val billingMode: JsonField, private val cadence: JsonField, - private val compositePriceFilters: JsonField>, + private val compositePriceFilters: JsonField>, private val conversionRate: JsonField, private val conversionRateConfig: JsonField, private val createdAt: JsonField, @@ -67812,7 +82932,7 @@ private constructor( @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), @JsonProperty("composite_price_filters") @ExcludeMissing - compositePriceFilters: JsonField> = JsonMissing.of(), + compositePriceFilters: JsonField> = JsonMissing.of(), @JsonProperty("conversion_rate") @ExcludeMissing conversionRate: JsonField = JsonMissing.of(), @@ -67937,7 +83057,7 @@ private constructor( * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun compositePriceFilters(): List? = + fun compositePriceFilters(): List? = compositePriceFilters.getNullable("composite_price_filters") /** @@ -68148,7 +83268,7 @@ private constructor( */ @JsonProperty("composite_price_filters") @ExcludeMissing - fun _compositePriceFilters(): JsonField> = compositePriceFilters + fun _compositePriceFilters(): JsonField> = compositePriceFilters /** * Returns the raw JSON value of [conversionRate]. @@ -68408,7 +83528,7 @@ private constructor( private var billingCycleConfiguration: JsonField? = null private var billingMode: JsonField? = null private var cadence: JsonField? = null - private var compositePriceFilters: JsonField>? = null + private var compositePriceFilters: JsonField>? = null private var conversionRate: JsonField? = null private var conversionRateConfig: JsonField? = null private var createdAt: JsonField? = null @@ -68529,28 +83649,28 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - fun compositePriceFilters(compositePriceFilters: List?) = + fun compositePriceFilters(compositePriceFilters: List?) = compositePriceFilters(JsonField.ofNullable(compositePriceFilters)) /** * Sets [Builder.compositePriceFilters] to an arbitrary JSON value. * * You should usually call [Builder.compositePriceFilters] with a well-typed - * `List` value instead. This method is primarily for setting the + * `List` value instead. This method is primarily for setting the * field to an undocumented or not yet supported value. */ fun compositePriceFilters( - compositePriceFilters: JsonField> + compositePriceFilters: JsonField> ) = apply { this.compositePriceFilters = compositePriceFilters.map { it.toMutableList() } } /** - * Adds a single [TransformPriceFilter] to [compositePriceFilters]. + * Adds a single [CompositePriceFilter] to [compositePriceFilters]. * * @throws IllegalStateException if the field was previously set to a non-list. */ - fun addCompositePriceFilter(compositePriceFilter: TransformPriceFilter) = apply { + fun addCompositePriceFilter(compositePriceFilter: CompositePriceFilter) = apply { compositePriceFilters = (compositePriceFilters ?: JsonField.of(mutableListOf())).also { checkKnown("compositePriceFilters", it).add(compositePriceFilter) @@ -69466,6 +84586,546 @@ private constructor( override fun toString() = value.toString() } + class CompositePriceFilter + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val field: JsonField, + private val operator: JsonField, + private val values: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("field") @ExcludeMissing field: JsonField = JsonMissing.of(), + @JsonProperty("operator") + @ExcludeMissing + operator: JsonField = JsonMissing.of(), + @JsonProperty("values") + @ExcludeMissing + values: JsonField> = JsonMissing.of(), + ) : this(field, operator, values, mutableMapOf()) + + /** + * The property of the price to filter on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun field(): Field = field.getRequired("field") + + /** + * Should prices that match the filter be included or excluded. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun operator(): Operator = operator.getRequired("operator") + + /** + * The IDs or values that match this filter. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun values(): List = values.getRequired("values") + + /** + * Returns the raw JSON value of [field]. + * + * Unlike [field], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("field") @ExcludeMissing fun _field(): JsonField = field + + /** + * Returns the raw JSON value of [operator]. + * + * Unlike [operator], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("operator") + @ExcludeMissing + fun _operator(): JsonField = operator + + /** + * Returns the raw JSON value of [values]. + * + * Unlike [values], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("values") @ExcludeMissing fun _values(): JsonField> = values + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [CompositePriceFilter]. + * + * The following fields are required: + * ```kotlin + * .field() + * .operator() + * .values() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [CompositePriceFilter]. */ + class Builder internal constructor() { + + private var field: JsonField? = null + private var operator: JsonField? = null + private var values: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(compositePriceFilter: CompositePriceFilter) = apply { + field = compositePriceFilter.field + operator = compositePriceFilter.operator + values = compositePriceFilter.values.map { it.toMutableList() } + additionalProperties = compositePriceFilter.additionalProperties.toMutableMap() + } + + /** The property of the price to filter on. */ + fun field(field: Field) = field(JsonField.of(field)) + + /** + * Sets [Builder.field] to an arbitrary JSON value. + * + * You should usually call [Builder.field] with a well-typed [Field] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun field(field: JsonField) = apply { this.field = field } + + /** Should prices that match the filter be included or excluded. */ + fun operator(operator: Operator) = operator(JsonField.of(operator)) + + /** + * Sets [Builder.operator] to an arbitrary JSON value. + * + * You should usually call [Builder.operator] with a well-typed [Operator] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun operator(operator: JsonField) = apply { this.operator = operator } + + /** The IDs or values that match this filter. */ + fun values(values: List) = values(JsonField.of(values)) + + /** + * Sets [Builder.values] to an arbitrary JSON value. + * + * You should usually call [Builder.values] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun values(values: JsonField>) = apply { + this.values = values.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [values]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addValue(value: String) = apply { + values = + (values ?: JsonField.of(mutableListOf())).also { + checkKnown("values", it).add(value) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CompositePriceFilter]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .field() + * .operator() + * .values() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CompositePriceFilter = + CompositePriceFilter( + checkRequired("field", field), + checkRequired("operator", operator), + checkRequired("values", values).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CompositePriceFilter = apply { + if (validated) { + return@apply + } + + field().validate() + operator().validate() + values() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (field.asKnown()?.validity() ?: 0) + + (operator.asKnown()?.validity() ?: 0) + + (values.asKnown()?.size ?: 0) + + /** The property of the price to filter on. */ + class Field @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val PRICE_ID = of("price_id") + + val ITEM_ID = of("item_id") + + val PRICE_TYPE = of("price_type") + + val CURRENCY = of("currency") + + val PRICING_UNIT_ID = of("pricing_unit_id") + + fun of(value: String) = Field(JsonField.of(value)) + } + + /** An enum containing [Field]'s known values. */ + enum class Known { + PRICE_ID, + ITEM_ID, + PRICE_TYPE, + CURRENCY, + PRICING_UNIT_ID, + } + + /** + * An enum containing [Field]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Field] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + PRICE_ID, + ITEM_ID, + PRICE_TYPE, + CURRENCY, + PRICING_UNIT_ID, + /** + * An enum member indicating that [Field] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + PRICE_ID -> Value.PRICE_ID + ITEM_ID -> Value.ITEM_ID + PRICE_TYPE -> Value.PRICE_TYPE + CURRENCY -> Value.CURRENCY + PRICING_UNIT_ID -> Value.PRICING_UNIT_ID + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + PRICE_ID -> Known.PRICE_ID + ITEM_ID -> Known.ITEM_ID + PRICE_TYPE -> Known.PRICE_TYPE + CURRENCY -> Known.CURRENCY + PRICING_UNIT_ID -> Known.PRICING_UNIT_ID + else -> throw OrbInvalidDataException("Unknown Field: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Field = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Field && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Should prices that match the filter be included or excluded. */ + class Operator @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val INCLUDES = of("includes") + + val EXCLUDES = of("excludes") + + fun of(value: String) = Operator(JsonField.of(value)) + } + + /** An enum containing [Operator]'s known values. */ + enum class Known { + INCLUDES, + EXCLUDES, + } + + /** + * An enum containing [Operator]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Operator] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + INCLUDES, + EXCLUDES, + /** + * An enum member indicating that [Operator] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + INCLUDES -> Value.INCLUDES + EXCLUDES -> Value.EXCLUDES + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + INCLUDES -> Known.INCLUDES + EXCLUDES -> Known.EXCLUDES + else -> throw OrbInvalidDataException("Unknown Operator: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Operator = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Operator && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CompositePriceFilter && + field == other.field && + operator == other.operator && + values == other.values && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(field, operator, values, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CompositePriceFilter{field=$field, operator=$operator, values=$values, additionalProperties=$additionalProperties}" + } + /** * User specified key-value pairs for the resource. If not present, this defaults to an * empty dictionary. Individual keys can be removed by setting the value to `null`, and the @@ -69956,7 +85616,7 @@ private constructor( private val billingCycleConfiguration: JsonField, private val billingMode: JsonField, private val cadence: JsonField, - private val compositePriceFilters: JsonField>, + private val compositePriceFilters: JsonField>, private val conversionRate: JsonField, private val conversionRateConfig: JsonField, private val createdAt: JsonField, @@ -69997,7 +85657,7 @@ private constructor( @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), @JsonProperty("composite_price_filters") @ExcludeMissing - compositePriceFilters: JsonField> = JsonMissing.of(), + compositePriceFilters: JsonField> = JsonMissing.of(), @JsonProperty("conversion_rate") @ExcludeMissing conversionRate: JsonField = JsonMissing.of(), @@ -70122,7 +85782,7 @@ private constructor( * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun compositePriceFilters(): List? = + fun compositePriceFilters(): List? = compositePriceFilters.getNullable("composite_price_filters") /** @@ -70334,7 +85994,7 @@ private constructor( */ @JsonProperty("composite_price_filters") @ExcludeMissing - fun _compositePriceFilters(): JsonField> = compositePriceFilters + fun _compositePriceFilters(): JsonField> = compositePriceFilters /** * Returns the raw JSON value of [conversionRate]. @@ -70594,7 +86254,7 @@ private constructor( private var billingCycleConfiguration: JsonField? = null private var billingMode: JsonField? = null private var cadence: JsonField? = null - private var compositePriceFilters: JsonField>? = null + private var compositePriceFilters: JsonField>? = null private var conversionRate: JsonField? = null private var conversionRateConfig: JsonField? = null private var createdAt: JsonField? = null @@ -70715,28 +86375,28 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - fun compositePriceFilters(compositePriceFilters: List?) = + fun compositePriceFilters(compositePriceFilters: List?) = compositePriceFilters(JsonField.ofNullable(compositePriceFilters)) /** * Sets [Builder.compositePriceFilters] to an arbitrary JSON value. * * You should usually call [Builder.compositePriceFilters] with a well-typed - * `List` value instead. This method is primarily for setting the + * `List` value instead. This method is primarily for setting the * field to an undocumented or not yet supported value. */ fun compositePriceFilters( - compositePriceFilters: JsonField> + compositePriceFilters: JsonField> ) = apply { this.compositePriceFilters = compositePriceFilters.map { it.toMutableList() } } /** - * Adds a single [TransformPriceFilter] to [compositePriceFilters]. + * Adds a single [CompositePriceFilter] to [compositePriceFilters]. * * @throws IllegalStateException if the field was previously set to a non-list. */ - fun addCompositePriceFilter(compositePriceFilter: TransformPriceFilter) = apply { + fun addCompositePriceFilter(compositePriceFilter: CompositePriceFilter) = apply { compositePriceFilters = (compositePriceFilters ?: JsonField.of(mutableListOf())).also { checkKnown("compositePriceFilters", it).add(compositePriceFilter) @@ -71652,11 +87312,552 @@ private constructor( override fun toString() = value.toString() } + class CompositePriceFilter + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val field: JsonField, + private val operator: JsonField, + private val values: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("field") @ExcludeMissing field: JsonField = JsonMissing.of(), + @JsonProperty("operator") + @ExcludeMissing + operator: JsonField = JsonMissing.of(), + @JsonProperty("values") + @ExcludeMissing + values: JsonField> = JsonMissing.of(), + ) : this(field, operator, values, mutableMapOf()) + + /** + * The property of the price to filter on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun field(): Field = field.getRequired("field") + + /** + * Should prices that match the filter be included or excluded. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun operator(): Operator = operator.getRequired("operator") + + /** + * The IDs or values that match this filter. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun values(): List = values.getRequired("values") + + /** + * Returns the raw JSON value of [field]. + * + * Unlike [field], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("field") @ExcludeMissing fun _field(): JsonField = field + + /** + * Returns the raw JSON value of [operator]. + * + * Unlike [operator], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("operator") + @ExcludeMissing + fun _operator(): JsonField = operator + + /** + * Returns the raw JSON value of [values]. + * + * Unlike [values], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("values") @ExcludeMissing fun _values(): JsonField> = values + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [CompositePriceFilter]. + * + * The following fields are required: + * ```kotlin + * .field() + * .operator() + * .values() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [CompositePriceFilter]. */ + class Builder internal constructor() { + + private var field: JsonField? = null + private var operator: JsonField? = null + private var values: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(compositePriceFilter: CompositePriceFilter) = apply { + field = compositePriceFilter.field + operator = compositePriceFilter.operator + values = compositePriceFilter.values.map { it.toMutableList() } + additionalProperties = compositePriceFilter.additionalProperties.toMutableMap() + } + + /** The property of the price to filter on. */ + fun field(field: Field) = field(JsonField.of(field)) + + /** + * Sets [Builder.field] to an arbitrary JSON value. + * + * You should usually call [Builder.field] with a well-typed [Field] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun field(field: JsonField) = apply { this.field = field } + + /** Should prices that match the filter be included or excluded. */ + fun operator(operator: Operator) = operator(JsonField.of(operator)) + + /** + * Sets [Builder.operator] to an arbitrary JSON value. + * + * You should usually call [Builder.operator] with a well-typed [Operator] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun operator(operator: JsonField) = apply { this.operator = operator } + + /** The IDs or values that match this filter. */ + fun values(values: List) = values(JsonField.of(values)) + + /** + * Sets [Builder.values] to an arbitrary JSON value. + * + * You should usually call [Builder.values] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun values(values: JsonField>) = apply { + this.values = values.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [values]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addValue(value: String) = apply { + values = + (values ?: JsonField.of(mutableListOf())).also { + checkKnown("values", it).add(value) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CompositePriceFilter]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .field() + * .operator() + * .values() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CompositePriceFilter = + CompositePriceFilter( + checkRequired("field", field), + checkRequired("operator", operator), + checkRequired("values", values).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CompositePriceFilter = apply { + if (validated) { + return@apply + } + + field().validate() + operator().validate() + values() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (field.asKnown()?.validity() ?: 0) + + (operator.asKnown()?.validity() ?: 0) + + (values.asKnown()?.size ?: 0) + + /** The property of the price to filter on. */ + class Field @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val PRICE_ID = of("price_id") + + val ITEM_ID = of("item_id") + + val PRICE_TYPE = of("price_type") + + val CURRENCY = of("currency") + + val PRICING_UNIT_ID = of("pricing_unit_id") + + fun of(value: String) = Field(JsonField.of(value)) + } + + /** An enum containing [Field]'s known values. */ + enum class Known { + PRICE_ID, + ITEM_ID, + PRICE_TYPE, + CURRENCY, + PRICING_UNIT_ID, + } + + /** + * An enum containing [Field]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Field] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + PRICE_ID, + ITEM_ID, + PRICE_TYPE, + CURRENCY, + PRICING_UNIT_ID, + /** + * An enum member indicating that [Field] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + PRICE_ID -> Value.PRICE_ID + ITEM_ID -> Value.ITEM_ID + PRICE_TYPE -> Value.PRICE_TYPE + CURRENCY -> Value.CURRENCY + PRICING_UNIT_ID -> Value.PRICING_UNIT_ID + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + PRICE_ID -> Known.PRICE_ID + ITEM_ID -> Known.ITEM_ID + PRICE_TYPE -> Known.PRICE_TYPE + CURRENCY -> Known.CURRENCY + PRICING_UNIT_ID -> Known.PRICING_UNIT_ID + else -> throw OrbInvalidDataException("Unknown Field: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Field = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Field && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Should prices that match the filter be included or excluded. */ + class Operator @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val INCLUDES = of("includes") + + val EXCLUDES = of("excludes") + + fun of(value: String) = Operator(JsonField.of(value)) + } + + /** An enum containing [Operator]'s known values. */ + enum class Known { + INCLUDES, + EXCLUDES, + } + + /** + * An enum containing [Operator]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Operator] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + INCLUDES, + EXCLUDES, + /** + * An enum member indicating that [Operator] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + INCLUDES -> Value.INCLUDES + EXCLUDES -> Value.EXCLUDES + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + INCLUDES -> Known.INCLUDES + EXCLUDES -> Known.EXCLUDES + else -> throw OrbInvalidDataException("Unknown Operator: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Operator = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Operator && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CompositePriceFilter && + field == other.field && + operator == other.operator && + values == other.values && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(field, operator, values, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CompositePriceFilter{field=$field, operator=$operator, values=$values, additionalProperties=$additionalProperties}" + } + /** Configuration for event_output pricing */ class EventOutputConfig @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val unitRatingKey: JsonField, + private val defaultUnitRate: JsonField, private val groupingKey: JsonField, private val additionalProperties: MutableMap, ) { @@ -71666,10 +87867,13 @@ private constructor( @JsonProperty("unit_rating_key") @ExcludeMissing unitRatingKey: JsonField = JsonMissing.of(), + @JsonProperty("default_unit_rate") + @ExcludeMissing + defaultUnitRate: JsonField = JsonMissing.of(), @JsonProperty("grouping_key") @ExcludeMissing groupingKey: JsonField = JsonMissing.of(), - ) : this(unitRatingKey, groupingKey, mutableMapOf()) + ) : this(unitRatingKey, defaultUnitRate, groupingKey, mutableMapOf()) /** * The key in the event data to extract the unit rate from. @@ -71680,6 +87884,16 @@ private constructor( */ fun unitRatingKey(): String = unitRatingKey.getRequired("unit_rating_key") + /** + * If provided, this amount will be used as the unit rate when an event does not have a + * value for the `unit_rating_key`. If not provided, events missing a unit rate will be + * ignored. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun defaultUnitRate(): String? = defaultUnitRate.getNullable("default_unit_rate") + /** * An optional key in the event data to group by (e.g., event ID). All events will also * be grouped by their unit rate. @@ -71699,6 +87913,16 @@ private constructor( @ExcludeMissing fun _unitRatingKey(): JsonField = unitRatingKey + /** + * Returns the raw JSON value of [defaultUnitRate]. + * + * Unlike [defaultUnitRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("default_unit_rate") + @ExcludeMissing + fun _defaultUnitRate(): JsonField = defaultUnitRate + /** * Returns the raw JSON value of [groupingKey]. * @@ -71738,11 +87962,13 @@ private constructor( class Builder internal constructor() { private var unitRatingKey: JsonField? = null + private var defaultUnitRate: JsonField = JsonMissing.of() private var groupingKey: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() internal fun from(eventOutputConfig: EventOutputConfig) = apply { unitRatingKey = eventOutputConfig.unitRatingKey + defaultUnitRate = eventOutputConfig.defaultUnitRate groupingKey = eventOutputConfig.groupingKey additionalProperties = eventOutputConfig.additionalProperties.toMutableMap() } @@ -71762,6 +87988,25 @@ private constructor( this.unitRatingKey = unitRatingKey } + /** + * If provided, this amount will be used as the unit rate when an event does not + * have a value for the `unit_rating_key`. If not provided, events missing a unit + * rate will be ignored. + */ + fun defaultUnitRate(defaultUnitRate: String?) = + defaultUnitRate(JsonField.ofNullable(defaultUnitRate)) + + /** + * Sets [Builder.defaultUnitRate] to an arbitrary JSON value. + * + * You should usually call [Builder.defaultUnitRate] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun defaultUnitRate(defaultUnitRate: JsonField) = apply { + this.defaultUnitRate = defaultUnitRate + } + /** * An optional key in the event data to group by (e.g., event ID). All events will * also be grouped by their unit rate. @@ -71817,6 +88062,7 @@ private constructor( fun build(): EventOutputConfig = EventOutputConfig( checkRequired("unitRatingKey", unitRatingKey), + defaultUnitRate, groupingKey, additionalProperties.toMutableMap(), ) @@ -71830,6 +88076,7 @@ private constructor( } unitRatingKey() + defaultUnitRate() groupingKey() validated = true } @@ -71850,6 +88097,7 @@ private constructor( */ internal fun validity(): Int = (if (unitRatingKey.asKnown() == null) 0 else 1) + + (if (defaultUnitRate.asKnown() == null) 0 else 1) + (if (groupingKey.asKnown() == null) 0 else 1) override fun equals(other: Any?): Boolean { @@ -71859,18 +88107,19 @@ private constructor( return other is EventOutputConfig && unitRatingKey == other.unitRatingKey && + defaultUnitRate == other.defaultUnitRate && groupingKey == other.groupingKey && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(unitRatingKey, groupingKey, additionalProperties) + Objects.hash(unitRatingKey, defaultUnitRate, groupingKey, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "EventOutputConfig{unitRatingKey=$unitRatingKey, groupingKey=$groupingKey, additionalProperties=$additionalProperties}" + "EventOutputConfig{unitRatingKey=$unitRatingKey, defaultUnitRate=$defaultUnitRate, groupingKey=$groupingKey, additionalProperties=$additionalProperties}" } /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceCreateParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceCreateParams.kt index 1cf6b93ed..5262e7247 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceCreateParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceCreateParams.kt @@ -7620,6 +7620,7 @@ private constructor( @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val unitRatingKey: JsonField, + private val defaultUnitRate: JsonField, private val groupingKey: JsonField, private val additionalProperties: MutableMap, ) { @@ -7629,10 +7630,13 @@ private constructor( @JsonProperty("unit_rating_key") @ExcludeMissing unitRatingKey: JsonField = JsonMissing.of(), + @JsonProperty("default_unit_rate") + @ExcludeMissing + defaultUnitRate: JsonField = JsonMissing.of(), @JsonProperty("grouping_key") @ExcludeMissing groupingKey: JsonField = JsonMissing.of(), - ) : this(unitRatingKey, groupingKey, mutableMapOf()) + ) : this(unitRatingKey, defaultUnitRate, groupingKey, mutableMapOf()) /** * The key in the event data to extract the unit rate from. @@ -7643,6 +7647,16 @@ private constructor( */ fun unitRatingKey(): String = unitRatingKey.getRequired("unit_rating_key") + /** + * If provided, this amount will be used as the unit rate when an event does not + * have a value for the `unit_rating_key`. If not provided, events missing a unit + * rate will be ignored. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun defaultUnitRate(): String? = defaultUnitRate.getNullable("default_unit_rate") + /** * An optional key in the event data to group by (e.g., event ID). All events will * also be grouped by their unit rate. @@ -7662,6 +7676,16 @@ private constructor( @ExcludeMissing fun _unitRatingKey(): JsonField = unitRatingKey + /** + * Returns the raw JSON value of [defaultUnitRate]. + * + * Unlike [defaultUnitRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("default_unit_rate") + @ExcludeMissing + fun _defaultUnitRate(): JsonField = defaultUnitRate + /** * Returns the raw JSON value of [groupingKey]. * @@ -7702,11 +7726,13 @@ private constructor( class Builder internal constructor() { private var unitRatingKey: JsonField? = null + private var defaultUnitRate: JsonField = JsonMissing.of() private var groupingKey: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() internal fun from(eventOutputConfig: EventOutputConfig) = apply { unitRatingKey = eventOutputConfig.unitRatingKey + defaultUnitRate = eventOutputConfig.defaultUnitRate groupingKey = eventOutputConfig.groupingKey additionalProperties = eventOutputConfig.additionalProperties.toMutableMap() } @@ -7726,6 +7752,25 @@ private constructor( this.unitRatingKey = unitRatingKey } + /** + * If provided, this amount will be used as the unit rate when an event does not + * have a value for the `unit_rating_key`. If not provided, events missing a + * unit rate will be ignored. + */ + fun defaultUnitRate(defaultUnitRate: String?) = + defaultUnitRate(JsonField.ofNullable(defaultUnitRate)) + + /** + * Sets [Builder.defaultUnitRate] to an arbitrary JSON value. + * + * You should usually call [Builder.defaultUnitRate] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun defaultUnitRate(defaultUnitRate: JsonField) = apply { + this.defaultUnitRate = defaultUnitRate + } + /** * An optional key in the event data to group by (e.g., event ID). All events * will also be grouped by their unit rate. @@ -7781,6 +7826,7 @@ private constructor( fun build(): EventOutputConfig = EventOutputConfig( checkRequired("unitRatingKey", unitRatingKey), + defaultUnitRate, groupingKey, additionalProperties.toMutableMap(), ) @@ -7794,6 +7840,7 @@ private constructor( } unitRatingKey() + defaultUnitRate() groupingKey() validated = true } @@ -7814,6 +7861,7 @@ private constructor( */ internal fun validity(): Int = (if (unitRatingKey.asKnown() == null) 0 else 1) + + (if (defaultUnitRate.asKnown() == null) 0 else 1) + (if (groupingKey.asKnown() == null) 0 else 1) override fun equals(other: Any?): Boolean { @@ -7823,18 +7871,19 @@ private constructor( return other is EventOutputConfig && unitRatingKey == other.unitRatingKey && + defaultUnitRate == other.defaultUnitRate && groupingKey == other.groupingKey && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(unitRatingKey, groupingKey, additionalProperties) + Objects.hash(unitRatingKey, defaultUnitRate, groupingKey, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "EventOutputConfig{unitRatingKey=$unitRatingKey, groupingKey=$groupingKey, additionalProperties=$additionalProperties}" + "EventOutputConfig{unitRatingKey=$unitRatingKey, defaultUnitRate=$defaultUnitRate, groupingKey=$groupingKey, additionalProperties=$additionalProperties}" } /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceEvaluateMultipleParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceEvaluateMultipleParams.kt index 28a851d22..e4c93aeb4 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceEvaluateMultipleParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceEvaluateMultipleParams.kt @@ -8704,6 +8704,7 @@ private constructor( @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val unitRatingKey: JsonField, + private val defaultUnitRate: JsonField, private val groupingKey: JsonField, private val additionalProperties: MutableMap, ) { @@ -8713,10 +8714,13 @@ private constructor( @JsonProperty("unit_rating_key") @ExcludeMissing unitRatingKey: JsonField = JsonMissing.of(), + @JsonProperty("default_unit_rate") + @ExcludeMissing + defaultUnitRate: JsonField = JsonMissing.of(), @JsonProperty("grouping_key") @ExcludeMissing groupingKey: JsonField = JsonMissing.of(), - ) : this(unitRatingKey, groupingKey, mutableMapOf()) + ) : this(unitRatingKey, defaultUnitRate, groupingKey, mutableMapOf()) /** * The key in the event data to extract the unit rate from. @@ -8727,6 +8731,17 @@ private constructor( */ fun unitRatingKey(): String = unitRatingKey.getRequired("unit_rating_key") + /** + * If provided, this amount will be used as the unit rate when an event does not + * have a value for the `unit_rating_key`. If not provided, events missing a + * unit rate will be ignored. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun defaultUnitRate(): String? = + defaultUnitRate.getNullable("default_unit_rate") + /** * An optional key in the event data to group by (e.g., event ID). All events * will also be grouped by their unit rate. @@ -8746,6 +8761,16 @@ private constructor( @ExcludeMissing fun _unitRatingKey(): JsonField = unitRatingKey + /** + * Returns the raw JSON value of [defaultUnitRate]. + * + * Unlike [defaultUnitRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("default_unit_rate") + @ExcludeMissing + fun _defaultUnitRate(): JsonField = defaultUnitRate + /** * Returns the raw JSON value of [groupingKey]. * @@ -8786,12 +8811,14 @@ private constructor( class Builder internal constructor() { private var unitRatingKey: JsonField? = null + private var defaultUnitRate: JsonField = JsonMissing.of() private var groupingKey: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() internal fun from(eventOutputConfig: EventOutputConfig) = apply { unitRatingKey = eventOutputConfig.unitRatingKey + defaultUnitRate = eventOutputConfig.defaultUnitRate groupingKey = eventOutputConfig.groupingKey additionalProperties = eventOutputConfig.additionalProperties.toMutableMap() @@ -8812,6 +8839,25 @@ private constructor( this.unitRatingKey = unitRatingKey } + /** + * If provided, this amount will be used as the unit rate when an event does + * not have a value for the `unit_rating_key`. If not provided, events + * missing a unit rate will be ignored. + */ + fun defaultUnitRate(defaultUnitRate: String?) = + defaultUnitRate(JsonField.ofNullable(defaultUnitRate)) + + /** + * Sets [Builder.defaultUnitRate] to an arbitrary JSON value. + * + * You should usually call [Builder.defaultUnitRate] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun defaultUnitRate(defaultUnitRate: JsonField) = apply { + this.defaultUnitRate = defaultUnitRate + } + /** * An optional key in the event data to group by (e.g., event ID). All * events will also be grouped by their unit rate. @@ -8867,6 +8913,7 @@ private constructor( fun build(): EventOutputConfig = EventOutputConfig( checkRequired("unitRatingKey", unitRatingKey), + defaultUnitRate, groupingKey, additionalProperties.toMutableMap(), ) @@ -8880,6 +8927,7 @@ private constructor( } unitRatingKey() + defaultUnitRate() groupingKey() validated = true } @@ -8900,6 +8948,7 @@ private constructor( */ internal fun validity(): Int = (if (unitRatingKey.asKnown() == null) 0 else 1) + + (if (defaultUnitRate.asKnown() == null) 0 else 1) + (if (groupingKey.asKnown() == null) 0 else 1) override fun equals(other: Any?): Boolean { @@ -8909,18 +8958,24 @@ private constructor( return other is EventOutputConfig && unitRatingKey == other.unitRatingKey && + defaultUnitRate == other.defaultUnitRate && groupingKey == other.groupingKey && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(unitRatingKey, groupingKey, additionalProperties) + Objects.hash( + unitRatingKey, + defaultUnitRate, + groupingKey, + additionalProperties, + ) } override fun hashCode(): Int = hashCode override fun toString() = - "EventOutputConfig{unitRatingKey=$unitRatingKey, groupingKey=$groupingKey, additionalProperties=$additionalProperties}" + "EventOutputConfig{unitRatingKey=$unitRatingKey, defaultUnitRate=$defaultUnitRate, groupingKey=$groupingKey, additionalProperties=$additionalProperties}" } /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceEvaluatePreviewEventsParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceEvaluatePreviewEventsParams.kt index 7f1c3a92d..d4b0b5a00 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceEvaluatePreviewEventsParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceEvaluatePreviewEventsParams.kt @@ -9239,6 +9239,7 @@ private constructor( @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val unitRatingKey: JsonField, + private val defaultUnitRate: JsonField, private val groupingKey: JsonField, private val additionalProperties: MutableMap, ) { @@ -9248,10 +9249,13 @@ private constructor( @JsonProperty("unit_rating_key") @ExcludeMissing unitRatingKey: JsonField = JsonMissing.of(), + @JsonProperty("default_unit_rate") + @ExcludeMissing + defaultUnitRate: JsonField = JsonMissing.of(), @JsonProperty("grouping_key") @ExcludeMissing groupingKey: JsonField = JsonMissing.of(), - ) : this(unitRatingKey, groupingKey, mutableMapOf()) + ) : this(unitRatingKey, defaultUnitRate, groupingKey, mutableMapOf()) /** * The key in the event data to extract the unit rate from. @@ -9262,6 +9266,17 @@ private constructor( */ fun unitRatingKey(): String = unitRatingKey.getRequired("unit_rating_key") + /** + * If provided, this amount will be used as the unit rate when an event does not + * have a value for the `unit_rating_key`. If not provided, events missing a + * unit rate will be ignored. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun defaultUnitRate(): String? = + defaultUnitRate.getNullable("default_unit_rate") + /** * An optional key in the event data to group by (e.g., event ID). All events * will also be grouped by their unit rate. @@ -9281,6 +9296,16 @@ private constructor( @ExcludeMissing fun _unitRatingKey(): JsonField = unitRatingKey + /** + * Returns the raw JSON value of [defaultUnitRate]. + * + * Unlike [defaultUnitRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("default_unit_rate") + @ExcludeMissing + fun _defaultUnitRate(): JsonField = defaultUnitRate + /** * Returns the raw JSON value of [groupingKey]. * @@ -9321,12 +9346,14 @@ private constructor( class Builder internal constructor() { private var unitRatingKey: JsonField? = null + private var defaultUnitRate: JsonField = JsonMissing.of() private var groupingKey: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() internal fun from(eventOutputConfig: EventOutputConfig) = apply { unitRatingKey = eventOutputConfig.unitRatingKey + defaultUnitRate = eventOutputConfig.defaultUnitRate groupingKey = eventOutputConfig.groupingKey additionalProperties = eventOutputConfig.additionalProperties.toMutableMap() @@ -9347,6 +9374,25 @@ private constructor( this.unitRatingKey = unitRatingKey } + /** + * If provided, this amount will be used as the unit rate when an event does + * not have a value for the `unit_rating_key`. If not provided, events + * missing a unit rate will be ignored. + */ + fun defaultUnitRate(defaultUnitRate: String?) = + defaultUnitRate(JsonField.ofNullable(defaultUnitRate)) + + /** + * Sets [Builder.defaultUnitRate] to an arbitrary JSON value. + * + * You should usually call [Builder.defaultUnitRate] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun defaultUnitRate(defaultUnitRate: JsonField) = apply { + this.defaultUnitRate = defaultUnitRate + } + /** * An optional key in the event data to group by (e.g., event ID). All * events will also be grouped by their unit rate. @@ -9402,6 +9448,7 @@ private constructor( fun build(): EventOutputConfig = EventOutputConfig( checkRequired("unitRatingKey", unitRatingKey), + defaultUnitRate, groupingKey, additionalProperties.toMutableMap(), ) @@ -9415,6 +9462,7 @@ private constructor( } unitRatingKey() + defaultUnitRate() groupingKey() validated = true } @@ -9435,6 +9483,7 @@ private constructor( */ internal fun validity(): Int = (if (unitRatingKey.asKnown() == null) 0 else 1) + + (if (defaultUnitRate.asKnown() == null) 0 else 1) + (if (groupingKey.asKnown() == null) 0 else 1) override fun equals(other: Any?): Boolean { @@ -9444,18 +9493,24 @@ private constructor( return other is EventOutputConfig && unitRatingKey == other.unitRatingKey && + defaultUnitRate == other.defaultUnitRate && groupingKey == other.groupingKey && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(unitRatingKey, groupingKey, additionalProperties) + Objects.hash( + unitRatingKey, + defaultUnitRate, + groupingKey, + additionalProperties, + ) } override fun hashCode(): Int = hashCode override fun toString() = - "EventOutputConfig{unitRatingKey=$unitRatingKey, groupingKey=$groupingKey, additionalProperties=$additionalProperties}" + "EventOutputConfig{unitRatingKey=$unitRatingKey, defaultUnitRate=$defaultUnitRate, groupingKey=$groupingKey, additionalProperties=$additionalProperties}" } /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionCreateParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionCreateParams.kt index 0fa37067a..064558142 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionCreateParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionCreateParams.kt @@ -14284,6 +14284,7 @@ private constructor( @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val unitRatingKey: JsonField, + private val defaultUnitRate: JsonField, private val groupingKey: JsonField, private val additionalProperties: MutableMap, ) { @@ -14293,10 +14294,13 @@ private constructor( @JsonProperty("unit_rating_key") @ExcludeMissing unitRatingKey: JsonField = JsonMissing.of(), + @JsonProperty("default_unit_rate") + @ExcludeMissing + defaultUnitRate: JsonField = JsonMissing.of(), @JsonProperty("grouping_key") @ExcludeMissing groupingKey: JsonField = JsonMissing.of(), - ) : this(unitRatingKey, groupingKey, mutableMapOf()) + ) : this(unitRatingKey, defaultUnitRate, groupingKey, mutableMapOf()) /** * The key in the event data to extract the unit rate from. @@ -14307,6 +14311,17 @@ private constructor( */ fun unitRatingKey(): String = unitRatingKey.getRequired("unit_rating_key") + /** + * If provided, this amount will be used as the unit rate when an event does not + * have a value for the `unit_rating_key`. If not provided, events missing a + * unit rate will be ignored. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun defaultUnitRate(): String? = + defaultUnitRate.getNullable("default_unit_rate") + /** * An optional key in the event data to group by (e.g., event ID). All events * will also be grouped by their unit rate. @@ -14326,6 +14341,16 @@ private constructor( @ExcludeMissing fun _unitRatingKey(): JsonField = unitRatingKey + /** + * Returns the raw JSON value of [defaultUnitRate]. + * + * Unlike [defaultUnitRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("default_unit_rate") + @ExcludeMissing + fun _defaultUnitRate(): JsonField = defaultUnitRate + /** * Returns the raw JSON value of [groupingKey]. * @@ -14366,12 +14391,14 @@ private constructor( class Builder internal constructor() { private var unitRatingKey: JsonField? = null + private var defaultUnitRate: JsonField = JsonMissing.of() private var groupingKey: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() internal fun from(eventOutputConfig: EventOutputConfig) = apply { unitRatingKey = eventOutputConfig.unitRatingKey + defaultUnitRate = eventOutputConfig.defaultUnitRate groupingKey = eventOutputConfig.groupingKey additionalProperties = eventOutputConfig.additionalProperties.toMutableMap() @@ -14392,6 +14419,25 @@ private constructor( this.unitRatingKey = unitRatingKey } + /** + * If provided, this amount will be used as the unit rate when an event does + * not have a value for the `unit_rating_key`. If not provided, events + * missing a unit rate will be ignored. + */ + fun defaultUnitRate(defaultUnitRate: String?) = + defaultUnitRate(JsonField.ofNullable(defaultUnitRate)) + + /** + * Sets [Builder.defaultUnitRate] to an arbitrary JSON value. + * + * You should usually call [Builder.defaultUnitRate] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun defaultUnitRate(defaultUnitRate: JsonField) = apply { + this.defaultUnitRate = defaultUnitRate + } + /** * An optional key in the event data to group by (e.g., event ID). All * events will also be grouped by their unit rate. @@ -14447,6 +14493,7 @@ private constructor( fun build(): EventOutputConfig = EventOutputConfig( checkRequired("unitRatingKey", unitRatingKey), + defaultUnitRate, groupingKey, additionalProperties.toMutableMap(), ) @@ -14460,6 +14507,7 @@ private constructor( } unitRatingKey() + defaultUnitRate() groupingKey() validated = true } @@ -14480,6 +14528,7 @@ private constructor( */ internal fun validity(): Int = (if (unitRatingKey.asKnown() == null) 0 else 1) + + (if (defaultUnitRate.asKnown() == null) 0 else 1) + (if (groupingKey.asKnown() == null) 0 else 1) override fun equals(other: Any?): Boolean { @@ -14489,18 +14538,24 @@ private constructor( return other is EventOutputConfig && unitRatingKey == other.unitRatingKey && + defaultUnitRate == other.defaultUnitRate && groupingKey == other.groupingKey && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(unitRatingKey, groupingKey, additionalProperties) + Objects.hash( + unitRatingKey, + defaultUnitRate, + groupingKey, + additionalProperties, + ) } override fun hashCode(): Int = hashCode override fun toString() = - "EventOutputConfig{unitRatingKey=$unitRatingKey, groupingKey=$groupingKey, additionalProperties=$additionalProperties}" + "EventOutputConfig{unitRatingKey=$unitRatingKey, defaultUnitRate=$defaultUnitRate, groupingKey=$groupingKey, additionalProperties=$additionalProperties}" } /** @@ -26002,6 +26057,7 @@ private constructor( @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val unitRatingKey: JsonField, + private val defaultUnitRate: JsonField, private val groupingKey: JsonField, private val additionalProperties: MutableMap, ) { @@ -26011,10 +26067,13 @@ private constructor( @JsonProperty("unit_rating_key") @ExcludeMissing unitRatingKey: JsonField = JsonMissing.of(), + @JsonProperty("default_unit_rate") + @ExcludeMissing + defaultUnitRate: JsonField = JsonMissing.of(), @JsonProperty("grouping_key") @ExcludeMissing groupingKey: JsonField = JsonMissing.of(), - ) : this(unitRatingKey, groupingKey, mutableMapOf()) + ) : this(unitRatingKey, defaultUnitRate, groupingKey, mutableMapOf()) /** * The key in the event data to extract the unit rate from. @@ -26025,6 +26084,17 @@ private constructor( */ fun unitRatingKey(): String = unitRatingKey.getRequired("unit_rating_key") + /** + * If provided, this amount will be used as the unit rate when an event does not + * have a value for the `unit_rating_key`. If not provided, events missing a + * unit rate will be ignored. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun defaultUnitRate(): String? = + defaultUnitRate.getNullable("default_unit_rate") + /** * An optional key in the event data to group by (e.g., event ID). All events * will also be grouped by their unit rate. @@ -26044,6 +26114,16 @@ private constructor( @ExcludeMissing fun _unitRatingKey(): JsonField = unitRatingKey + /** + * Returns the raw JSON value of [defaultUnitRate]. + * + * Unlike [defaultUnitRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("default_unit_rate") + @ExcludeMissing + fun _defaultUnitRate(): JsonField = defaultUnitRate + /** * Returns the raw JSON value of [groupingKey]. * @@ -26084,12 +26164,14 @@ private constructor( class Builder internal constructor() { private var unitRatingKey: JsonField? = null + private var defaultUnitRate: JsonField = JsonMissing.of() private var groupingKey: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() internal fun from(eventOutputConfig: EventOutputConfig) = apply { unitRatingKey = eventOutputConfig.unitRatingKey + defaultUnitRate = eventOutputConfig.defaultUnitRate groupingKey = eventOutputConfig.groupingKey additionalProperties = eventOutputConfig.additionalProperties.toMutableMap() @@ -26110,6 +26192,25 @@ private constructor( this.unitRatingKey = unitRatingKey } + /** + * If provided, this amount will be used as the unit rate when an event does + * not have a value for the `unit_rating_key`. If not provided, events + * missing a unit rate will be ignored. + */ + fun defaultUnitRate(defaultUnitRate: String?) = + defaultUnitRate(JsonField.ofNullable(defaultUnitRate)) + + /** + * Sets [Builder.defaultUnitRate] to an arbitrary JSON value. + * + * You should usually call [Builder.defaultUnitRate] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun defaultUnitRate(defaultUnitRate: JsonField) = apply { + this.defaultUnitRate = defaultUnitRate + } + /** * An optional key in the event data to group by (e.g., event ID). All * events will also be grouped by their unit rate. @@ -26165,6 +26266,7 @@ private constructor( fun build(): EventOutputConfig = EventOutputConfig( checkRequired("unitRatingKey", unitRatingKey), + defaultUnitRate, groupingKey, additionalProperties.toMutableMap(), ) @@ -26178,6 +26280,7 @@ private constructor( } unitRatingKey() + defaultUnitRate() groupingKey() validated = true } @@ -26198,6 +26301,7 @@ private constructor( */ internal fun validity(): Int = (if (unitRatingKey.asKnown() == null) 0 else 1) + + (if (defaultUnitRate.asKnown() == null) 0 else 1) + (if (groupingKey.asKnown() == null) 0 else 1) override fun equals(other: Any?): Boolean { @@ -26207,18 +26311,24 @@ private constructor( return other is EventOutputConfig && unitRatingKey == other.unitRatingKey && + defaultUnitRate == other.defaultUnitRate && groupingKey == other.groupingKey && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(unitRatingKey, groupingKey, additionalProperties) + Objects.hash( + unitRatingKey, + defaultUnitRate, + groupingKey, + additionalProperties, + ) } override fun hashCode(): Int = hashCode override fun toString() = - "EventOutputConfig{unitRatingKey=$unitRatingKey, groupingKey=$groupingKey, additionalProperties=$additionalProperties}" + "EventOutputConfig{unitRatingKey=$unitRatingKey, defaultUnitRate=$defaultUnitRate, groupingKey=$groupingKey, additionalProperties=$additionalProperties}" } /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsParams.kt index c96e11edd..7dd24c6e7 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsParams.kt @@ -10692,6 +10692,7 @@ private constructor( @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val unitRatingKey: JsonField, + private val defaultUnitRate: JsonField, private val groupingKey: JsonField, private val additionalProperties: MutableMap, ) { @@ -10701,10 +10702,13 @@ private constructor( @JsonProperty("unit_rating_key") @ExcludeMissing unitRatingKey: JsonField = JsonMissing.of(), + @JsonProperty("default_unit_rate") + @ExcludeMissing + defaultUnitRate: JsonField = JsonMissing.of(), @JsonProperty("grouping_key") @ExcludeMissing groupingKey: JsonField = JsonMissing.of(), - ) : this(unitRatingKey, groupingKey, mutableMapOf()) + ) : this(unitRatingKey, defaultUnitRate, groupingKey, mutableMapOf()) /** * The key in the event data to extract the unit rate from. @@ -10715,6 +10719,17 @@ private constructor( */ fun unitRatingKey(): String = unitRatingKey.getRequired("unit_rating_key") + /** + * If provided, this amount will be used as the unit rate when an event does not + * have a value for the `unit_rating_key`. If not provided, events missing a + * unit rate will be ignored. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun defaultUnitRate(): String? = + defaultUnitRate.getNullable("default_unit_rate") + /** * An optional key in the event data to group by (e.g., event ID). All events * will also be grouped by their unit rate. @@ -10734,6 +10749,16 @@ private constructor( @ExcludeMissing fun _unitRatingKey(): JsonField = unitRatingKey + /** + * Returns the raw JSON value of [defaultUnitRate]. + * + * Unlike [defaultUnitRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("default_unit_rate") + @ExcludeMissing + fun _defaultUnitRate(): JsonField = defaultUnitRate + /** * Returns the raw JSON value of [groupingKey]. * @@ -10774,12 +10799,14 @@ private constructor( class Builder internal constructor() { private var unitRatingKey: JsonField? = null + private var defaultUnitRate: JsonField = JsonMissing.of() private var groupingKey: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() internal fun from(eventOutputConfig: EventOutputConfig) = apply { unitRatingKey = eventOutputConfig.unitRatingKey + defaultUnitRate = eventOutputConfig.defaultUnitRate groupingKey = eventOutputConfig.groupingKey additionalProperties = eventOutputConfig.additionalProperties.toMutableMap() @@ -10800,6 +10827,25 @@ private constructor( this.unitRatingKey = unitRatingKey } + /** + * If provided, this amount will be used as the unit rate when an event does + * not have a value for the `unit_rating_key`. If not provided, events + * missing a unit rate will be ignored. + */ + fun defaultUnitRate(defaultUnitRate: String?) = + defaultUnitRate(JsonField.ofNullable(defaultUnitRate)) + + /** + * Sets [Builder.defaultUnitRate] to an arbitrary JSON value. + * + * You should usually call [Builder.defaultUnitRate] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun defaultUnitRate(defaultUnitRate: JsonField) = apply { + this.defaultUnitRate = defaultUnitRate + } + /** * An optional key in the event data to group by (e.g., event ID). All * events will also be grouped by their unit rate. @@ -10855,6 +10901,7 @@ private constructor( fun build(): EventOutputConfig = EventOutputConfig( checkRequired("unitRatingKey", unitRatingKey), + defaultUnitRate, groupingKey, additionalProperties.toMutableMap(), ) @@ -10868,6 +10915,7 @@ private constructor( } unitRatingKey() + defaultUnitRate() groupingKey() validated = true } @@ -10888,6 +10936,7 @@ private constructor( */ internal fun validity(): Int = (if (unitRatingKey.asKnown() == null) 0 else 1) + + (if (defaultUnitRate.asKnown() == null) 0 else 1) + (if (groupingKey.asKnown() == null) 0 else 1) override fun equals(other: Any?): Boolean { @@ -10897,18 +10946,24 @@ private constructor( return other is EventOutputConfig && unitRatingKey == other.unitRatingKey && + defaultUnitRate == other.defaultUnitRate && groupingKey == other.groupingKey && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(unitRatingKey, groupingKey, additionalProperties) + Objects.hash( + unitRatingKey, + defaultUnitRate, + groupingKey, + additionalProperties, + ) } override fun hashCode(): Int = hashCode override fun toString() = - "EventOutputConfig{unitRatingKey=$unitRatingKey, groupingKey=$groupingKey, additionalProperties=$additionalProperties}" + "EventOutputConfig{unitRatingKey=$unitRatingKey, defaultUnitRate=$defaultUnitRate, groupingKey=$groupingKey, additionalProperties=$additionalProperties}" } /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionSchedulePlanChangeParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionSchedulePlanChangeParams.kt index 9c876d7a1..650591840 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionSchedulePlanChangeParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionSchedulePlanChangeParams.kt @@ -13942,6 +13942,7 @@ private constructor( @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val unitRatingKey: JsonField, + private val defaultUnitRate: JsonField, private val groupingKey: JsonField, private val additionalProperties: MutableMap, ) { @@ -13951,10 +13952,13 @@ private constructor( @JsonProperty("unit_rating_key") @ExcludeMissing unitRatingKey: JsonField = JsonMissing.of(), + @JsonProperty("default_unit_rate") + @ExcludeMissing + defaultUnitRate: JsonField = JsonMissing.of(), @JsonProperty("grouping_key") @ExcludeMissing groupingKey: JsonField = JsonMissing.of(), - ) : this(unitRatingKey, groupingKey, mutableMapOf()) + ) : this(unitRatingKey, defaultUnitRate, groupingKey, mutableMapOf()) /** * The key in the event data to extract the unit rate from. @@ -13965,6 +13969,17 @@ private constructor( */ fun unitRatingKey(): String = unitRatingKey.getRequired("unit_rating_key") + /** + * If provided, this amount will be used as the unit rate when an event does not + * have a value for the `unit_rating_key`. If not provided, events missing a + * unit rate will be ignored. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun defaultUnitRate(): String? = + defaultUnitRate.getNullable("default_unit_rate") + /** * An optional key in the event data to group by (e.g., event ID). All events * will also be grouped by their unit rate. @@ -13984,6 +13999,16 @@ private constructor( @ExcludeMissing fun _unitRatingKey(): JsonField = unitRatingKey + /** + * Returns the raw JSON value of [defaultUnitRate]. + * + * Unlike [defaultUnitRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("default_unit_rate") + @ExcludeMissing + fun _defaultUnitRate(): JsonField = defaultUnitRate + /** * Returns the raw JSON value of [groupingKey]. * @@ -14024,12 +14049,14 @@ private constructor( class Builder internal constructor() { private var unitRatingKey: JsonField? = null + private var defaultUnitRate: JsonField = JsonMissing.of() private var groupingKey: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() internal fun from(eventOutputConfig: EventOutputConfig) = apply { unitRatingKey = eventOutputConfig.unitRatingKey + defaultUnitRate = eventOutputConfig.defaultUnitRate groupingKey = eventOutputConfig.groupingKey additionalProperties = eventOutputConfig.additionalProperties.toMutableMap() @@ -14050,6 +14077,25 @@ private constructor( this.unitRatingKey = unitRatingKey } + /** + * If provided, this amount will be used as the unit rate when an event does + * not have a value for the `unit_rating_key`. If not provided, events + * missing a unit rate will be ignored. + */ + fun defaultUnitRate(defaultUnitRate: String?) = + defaultUnitRate(JsonField.ofNullable(defaultUnitRate)) + + /** + * Sets [Builder.defaultUnitRate] to an arbitrary JSON value. + * + * You should usually call [Builder.defaultUnitRate] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun defaultUnitRate(defaultUnitRate: JsonField) = apply { + this.defaultUnitRate = defaultUnitRate + } + /** * An optional key in the event data to group by (e.g., event ID). All * events will also be grouped by their unit rate. @@ -14105,6 +14151,7 @@ private constructor( fun build(): EventOutputConfig = EventOutputConfig( checkRequired("unitRatingKey", unitRatingKey), + defaultUnitRate, groupingKey, additionalProperties.toMutableMap(), ) @@ -14118,6 +14165,7 @@ private constructor( } unitRatingKey() + defaultUnitRate() groupingKey() validated = true } @@ -14138,6 +14186,7 @@ private constructor( */ internal fun validity(): Int = (if (unitRatingKey.asKnown() == null) 0 else 1) + + (if (defaultUnitRate.asKnown() == null) 0 else 1) + (if (groupingKey.asKnown() == null) 0 else 1) override fun equals(other: Any?): Boolean { @@ -14147,18 +14196,24 @@ private constructor( return other is EventOutputConfig && unitRatingKey == other.unitRatingKey && + defaultUnitRate == other.defaultUnitRate && groupingKey == other.groupingKey && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(unitRatingKey, groupingKey, additionalProperties) + Objects.hash( + unitRatingKey, + defaultUnitRate, + groupingKey, + additionalProperties, + ) } override fun hashCode(): Int = hashCode override fun toString() = - "EventOutputConfig{unitRatingKey=$unitRatingKey, groupingKey=$groupingKey, additionalProperties=$additionalProperties}" + "EventOutputConfig{unitRatingKey=$unitRatingKey, defaultUnitRate=$defaultUnitRate, groupingKey=$groupingKey, additionalProperties=$additionalProperties}" } /** @@ -25562,6 +25617,7 @@ private constructor( @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val unitRatingKey: JsonField, + private val defaultUnitRate: JsonField, private val groupingKey: JsonField, private val additionalProperties: MutableMap, ) { @@ -25571,10 +25627,13 @@ private constructor( @JsonProperty("unit_rating_key") @ExcludeMissing unitRatingKey: JsonField = JsonMissing.of(), + @JsonProperty("default_unit_rate") + @ExcludeMissing + defaultUnitRate: JsonField = JsonMissing.of(), @JsonProperty("grouping_key") @ExcludeMissing groupingKey: JsonField = JsonMissing.of(), - ) : this(unitRatingKey, groupingKey, mutableMapOf()) + ) : this(unitRatingKey, defaultUnitRate, groupingKey, mutableMapOf()) /** * The key in the event data to extract the unit rate from. @@ -25585,6 +25644,17 @@ private constructor( */ fun unitRatingKey(): String = unitRatingKey.getRequired("unit_rating_key") + /** + * If provided, this amount will be used as the unit rate when an event does not + * have a value for the `unit_rating_key`. If not provided, events missing a + * unit rate will be ignored. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun defaultUnitRate(): String? = + defaultUnitRate.getNullable("default_unit_rate") + /** * An optional key in the event data to group by (e.g., event ID). All events * will also be grouped by their unit rate. @@ -25604,6 +25674,16 @@ private constructor( @ExcludeMissing fun _unitRatingKey(): JsonField = unitRatingKey + /** + * Returns the raw JSON value of [defaultUnitRate]. + * + * Unlike [defaultUnitRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("default_unit_rate") + @ExcludeMissing + fun _defaultUnitRate(): JsonField = defaultUnitRate + /** * Returns the raw JSON value of [groupingKey]. * @@ -25644,12 +25724,14 @@ private constructor( class Builder internal constructor() { private var unitRatingKey: JsonField? = null + private var defaultUnitRate: JsonField = JsonMissing.of() private var groupingKey: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() internal fun from(eventOutputConfig: EventOutputConfig) = apply { unitRatingKey = eventOutputConfig.unitRatingKey + defaultUnitRate = eventOutputConfig.defaultUnitRate groupingKey = eventOutputConfig.groupingKey additionalProperties = eventOutputConfig.additionalProperties.toMutableMap() @@ -25670,6 +25752,25 @@ private constructor( this.unitRatingKey = unitRatingKey } + /** + * If provided, this amount will be used as the unit rate when an event does + * not have a value for the `unit_rating_key`. If not provided, events + * missing a unit rate will be ignored. + */ + fun defaultUnitRate(defaultUnitRate: String?) = + defaultUnitRate(JsonField.ofNullable(defaultUnitRate)) + + /** + * Sets [Builder.defaultUnitRate] to an arbitrary JSON value. + * + * You should usually call [Builder.defaultUnitRate] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun defaultUnitRate(defaultUnitRate: JsonField) = apply { + this.defaultUnitRate = defaultUnitRate + } + /** * An optional key in the event data to group by (e.g., event ID). All * events will also be grouped by their unit rate. @@ -25725,6 +25826,7 @@ private constructor( fun build(): EventOutputConfig = EventOutputConfig( checkRequired("unitRatingKey", unitRatingKey), + defaultUnitRate, groupingKey, additionalProperties.toMutableMap(), ) @@ -25738,6 +25840,7 @@ private constructor( } unitRatingKey() + defaultUnitRate() groupingKey() validated = true } @@ -25758,6 +25861,7 @@ private constructor( */ internal fun validity(): Int = (if (unitRatingKey.asKnown() == null) 0 else 1) + + (if (defaultUnitRate.asKnown() == null) 0 else 1) + (if (groupingKey.asKnown() == null) 0 else 1) override fun equals(other: Any?): Boolean { @@ -25767,18 +25871,24 @@ private constructor( return other is EventOutputConfig && unitRatingKey == other.unitRatingKey && + defaultUnitRate == other.defaultUnitRate && groupingKey == other.groupingKey && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(unitRatingKey, groupingKey, additionalProperties) + Objects.hash( + unitRatingKey, + defaultUnitRate, + groupingKey, + additionalProperties, + ) } override fun hashCode(): Int = hashCode override fun toString() = - "EventOutputConfig{unitRatingKey=$unitRatingKey, groupingKey=$groupingKey, additionalProperties=$additionalProperties}" + "EventOutputConfig{unitRatingKey=$unitRatingKey, defaultUnitRate=$defaultUnitRate, groupingKey=$groupingKey, additionalProperties=$additionalProperties}" } /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/TransformPriceFilter.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/TransformPriceFilter.kt deleted file mode 100644 index 12c402f4c..000000000 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/TransformPriceFilter.kt +++ /dev/null @@ -1,534 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.withorb.api.models - -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import com.withorb.api.core.Enum -import com.withorb.api.core.ExcludeMissing -import com.withorb.api.core.JsonField -import com.withorb.api.core.JsonMissing -import com.withorb.api.core.JsonValue -import com.withorb.api.core.checkKnown -import com.withorb.api.core.checkRequired -import com.withorb.api.core.toImmutable -import com.withorb.api.errors.OrbInvalidDataException -import java.util.Collections -import java.util.Objects - -class TransformPriceFilter -@JsonCreator(mode = JsonCreator.Mode.DISABLED) -private constructor( - private val field: JsonField, - private val operator: JsonField, - private val values: JsonField>, - private val additionalProperties: MutableMap, -) { - - @JsonCreator - private constructor( - @JsonProperty("field") @ExcludeMissing field: JsonField = JsonMissing.of(), - @JsonProperty("operator") @ExcludeMissing operator: JsonField = JsonMissing.of(), - @JsonProperty("values") @ExcludeMissing values: JsonField> = JsonMissing.of(), - ) : this(field, operator, values, mutableMapOf()) - - /** - * The property of the price to filter on. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly - * missing or null (e.g. if the server responded with an unexpected value). - */ - fun field(): Field = field.getRequired("field") - - /** - * Should prices that match the filter be included or excluded. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly - * missing or null (e.g. if the server responded with an unexpected value). - */ - fun operator(): Operator = operator.getRequired("operator") - - /** - * The IDs or values that match this filter. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly - * missing or null (e.g. if the server responded with an unexpected value). - */ - fun values(): List = values.getRequired("values") - - /** - * Returns the raw JSON value of [field]. - * - * Unlike [field], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("field") @ExcludeMissing fun _field(): JsonField = field - - /** - * Returns the raw JSON value of [operator]. - * - * Unlike [operator], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("operator") @ExcludeMissing fun _operator(): JsonField = operator - - /** - * Returns the raw JSON value of [values]. - * - * Unlike [values], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("values") @ExcludeMissing fun _values(): JsonField> = values - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [TransformPriceFilter]. - * - * The following fields are required: - * ```kotlin - * .field() - * .operator() - * .values() - * ``` - */ - fun builder() = Builder() - } - - /** A builder for [TransformPriceFilter]. */ - class Builder internal constructor() { - - private var field: JsonField? = null - private var operator: JsonField? = null - private var values: JsonField>? = null - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(transformPriceFilter: TransformPriceFilter) = apply { - field = transformPriceFilter.field - operator = transformPriceFilter.operator - values = transformPriceFilter.values.map { it.toMutableList() } - additionalProperties = transformPriceFilter.additionalProperties.toMutableMap() - } - - /** The property of the price to filter on. */ - fun field(field: Field) = field(JsonField.of(field)) - - /** - * Sets [Builder.field] to an arbitrary JSON value. - * - * You should usually call [Builder.field] with a well-typed [Field] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun field(field: JsonField) = apply { this.field = field } - - /** Should prices that match the filter be included or excluded. */ - fun operator(operator: Operator) = operator(JsonField.of(operator)) - - /** - * Sets [Builder.operator] to an arbitrary JSON value. - * - * You should usually call [Builder.operator] with a well-typed [Operator] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun operator(operator: JsonField) = apply { this.operator = operator } - - /** The IDs or values that match this filter. */ - fun values(values: List) = values(JsonField.of(values)) - - /** - * Sets [Builder.values] to an arbitrary JSON value. - * - * You should usually call [Builder.values] with a well-typed `List` value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun values(values: JsonField>) = apply { - this.values = values.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [values]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addValue(value: String) = apply { - values = - (values ?: JsonField.of(mutableListOf())).also { - checkKnown("values", it).add(value) - } - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [TransformPriceFilter]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```kotlin - * .field() - * .operator() - * .values() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): TransformPriceFilter = - TransformPriceFilter( - checkRequired("field", field), - checkRequired("operator", operator), - checkRequired("values", values).map { it.toImmutable() }, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): TransformPriceFilter = apply { - if (validated) { - return@apply - } - - field().validate() - operator().validate() - values() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (field.asKnown()?.validity() ?: 0) + - (operator.asKnown()?.validity() ?: 0) + - (values.asKnown()?.size ?: 0) - - /** The property of the price to filter on. */ - class Field @JsonCreator private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API may respond with new members that the SDK is - * unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - val PRICE_ID = of("price_id") - - val ITEM_ID = of("item_id") - - val PRICE_TYPE = of("price_type") - - val CURRENCY = of("currency") - - val PRICING_UNIT_ID = of("pricing_unit_id") - - fun of(value: String) = Field(JsonField.of(value)) - } - - /** An enum containing [Field]'s known values. */ - enum class Known { - PRICE_ID, - ITEM_ID, - PRICE_TYPE, - CURRENCY, - PRICING_UNIT_ID, - } - - /** - * An enum containing [Field]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Field] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if the - * SDK is on an older version than the API, then the API may respond with new members that - * the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - PRICE_ID, - ITEM_ID, - PRICE_TYPE, - CURRENCY, - PRICING_UNIT_ID, - /** An enum member indicating that [Field] was instantiated with an unknown value. */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you want - * to throw for the unknown case. - */ - fun value(): Value = - when (this) { - PRICE_ID -> Value.PRICE_ID - ITEM_ID -> Value.ITEM_ID - PRICE_TYPE -> Value.PRICE_TYPE - CURRENCY -> Value.CURRENCY - PRICING_UNIT_ID -> Value.PRICING_UNIT_ID - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and don't - * want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known member. - */ - fun known(): Known = - when (this) { - PRICE_ID -> Known.PRICE_ID - ITEM_ID -> Known.ITEM_ID - PRICE_TYPE -> Known.PRICE_TYPE - CURRENCY -> Known.CURRENCY - PRICING_UNIT_ID -> Known.PRICING_UNIT_ID - else -> throw OrbInvalidDataException("Unknown Field: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the expected - * primitive type. - */ - fun asString(): String = - _value().asString() ?: throw OrbInvalidDataException("Value is not a String") - - private var validated: Boolean = false - - fun validate(): Field = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Field && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** Should prices that match the filter be included or excluded. */ - class Operator @JsonCreator private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API may respond with new members that the SDK is - * unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - val INCLUDES = of("includes") - - val EXCLUDES = of("excludes") - - fun of(value: String) = Operator(JsonField.of(value)) - } - - /** An enum containing [Operator]'s known values. */ - enum class Known { - INCLUDES, - EXCLUDES, - } - - /** - * An enum containing [Operator]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Operator] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if the - * SDK is on an older version than the API, then the API may respond with new members that - * the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - INCLUDES, - EXCLUDES, - /** An enum member indicating that [Operator] was instantiated with an unknown value. */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you want - * to throw for the unknown case. - */ - fun value(): Value = - when (this) { - INCLUDES -> Value.INCLUDES - EXCLUDES -> Value.EXCLUDES - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and don't - * want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known member. - */ - fun known(): Known = - when (this) { - INCLUDES -> Known.INCLUDES - EXCLUDES -> Known.EXCLUDES - else -> throw OrbInvalidDataException("Unknown Operator: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the expected - * primitive type. - */ - fun asString(): String = - _value().asString() ?: throw OrbInvalidDataException("Value is not a String") - - private var validated: Boolean = false - - fun validate(): Operator = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Operator && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is TransformPriceFilter && - field == other.field && - operator == other.operator && - values == other.values && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(field, operator, values, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "TransformPriceFilter{field=$field, operator=$operator, values=$values, additionalProperties=$additionalProperties}" -} diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/TrialDiscount.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/TrialDiscount.kt index 69d9031fe..03c20d6e0 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/TrialDiscount.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/TrialDiscount.kt @@ -23,7 +23,7 @@ class TrialDiscount private constructor( private val discountType: JsonField, private val appliesToPriceIds: JsonField>, - private val filters: JsonField>, + private val filters: JsonField>, private val reason: JsonField, private val trialAmountDiscount: JsonField, private val trialPercentageDiscount: JsonField, @@ -40,7 +40,7 @@ private constructor( appliesToPriceIds: JsonField> = JsonMissing.of(), @JsonProperty("filters") @ExcludeMissing - filters: JsonField> = JsonMissing.of(), + filters: JsonField> = JsonMissing.of(), @JsonProperty("reason") @ExcludeMissing reason: JsonField = JsonMissing.of(), @JsonProperty("trial_amount_discount") @ExcludeMissing @@ -79,7 +79,7 @@ private constructor( * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server * responded with an unexpected value). */ - fun filters(): List? = filters.getNullable("filters") + fun filters(): List? = filters.getNullable("filters") /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server @@ -128,9 +128,7 @@ private constructor( * * Unlike [filters], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("filters") - @ExcludeMissing - fun _filters(): JsonField> = filters + @JsonProperty("filters") @ExcludeMissing fun _filters(): JsonField> = filters /** * Returns the raw JSON value of [reason]. @@ -189,7 +187,7 @@ private constructor( private var discountType: JsonField? = null private var appliesToPriceIds: JsonField>? = null - private var filters: JsonField>? = null + private var filters: JsonField>? = null private var reason: JsonField = JsonMissing.of() private var trialAmountDiscount: JsonField = JsonMissing.of() private var trialPercentageDiscount: JsonField = JsonMissing.of() @@ -249,25 +247,25 @@ private constructor( } /** The filters that determine which prices to apply this discount to. */ - fun filters(filters: List?) = filters(JsonField.ofNullable(filters)) + fun filters(filters: List?) = filters(JsonField.ofNullable(filters)) /** * Sets [Builder.filters] to an arbitrary JSON value. * - * You should usually call [Builder.filters] with a well-typed `List` - * value instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. + * You should usually call [Builder.filters] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. */ - fun filters(filters: JsonField>) = apply { + fun filters(filters: JsonField>) = apply { this.filters = filters.map { it.toMutableList() } } /** - * Adds a single [TransformPriceFilter] to [filters]. + * Adds a single [Filter] to [filters]. * * @throws IllegalStateException if the field was previously set to a non-list. */ - fun addFilter(filter: TransformPriceFilter) = apply { + fun addFilter(filter: Filter) = apply { filters = (filters ?: JsonField.of(mutableListOf())).also { checkKnown("filters", it).add(filter) @@ -523,6 +521,534 @@ private constructor( override fun toString() = value.toString() } + class Filter + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val field: JsonField, + private val operator: JsonField, + private val values: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("field") @ExcludeMissing field: JsonField = JsonMissing.of(), + @JsonProperty("operator") + @ExcludeMissing + operator: JsonField = JsonMissing.of(), + @JsonProperty("values") + @ExcludeMissing + values: JsonField> = JsonMissing.of(), + ) : this(field, operator, values, mutableMapOf()) + + /** + * The property of the price to filter on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun field(): Field = field.getRequired("field") + + /** + * Should prices that match the filter be included or excluded. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun operator(): Operator = operator.getRequired("operator") + + /** + * The IDs or values that match this filter. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun values(): List = values.getRequired("values") + + /** + * Returns the raw JSON value of [field]. + * + * Unlike [field], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("field") @ExcludeMissing fun _field(): JsonField = field + + /** + * Returns the raw JSON value of [operator]. + * + * Unlike [operator], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("operator") @ExcludeMissing fun _operator(): JsonField = operator + + /** + * Returns the raw JSON value of [values]. + * + * Unlike [values], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("values") @ExcludeMissing fun _values(): JsonField> = values + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Filter]. + * + * The following fields are required: + * ```kotlin + * .field() + * .operator() + * .values() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Filter]. */ + class Builder internal constructor() { + + private var field: JsonField? = null + private var operator: JsonField? = null + private var values: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(filter: Filter) = apply { + field = filter.field + operator = filter.operator + values = filter.values.map { it.toMutableList() } + additionalProperties = filter.additionalProperties.toMutableMap() + } + + /** The property of the price to filter on. */ + fun field(field: Field) = field(JsonField.of(field)) + + /** + * Sets [Builder.field] to an arbitrary JSON value. + * + * You should usually call [Builder.field] with a well-typed [Field] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun field(field: JsonField) = apply { this.field = field } + + /** Should prices that match the filter be included or excluded. */ + fun operator(operator: Operator) = operator(JsonField.of(operator)) + + /** + * Sets [Builder.operator] to an arbitrary JSON value. + * + * You should usually call [Builder.operator] with a well-typed [Operator] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun operator(operator: JsonField) = apply { this.operator = operator } + + /** The IDs or values that match this filter. */ + fun values(values: List) = values(JsonField.of(values)) + + /** + * Sets [Builder.values] to an arbitrary JSON value. + * + * You should usually call [Builder.values] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun values(values: JsonField>) = apply { + this.values = values.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [values]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addValue(value: String) = apply { + values = + (values ?: JsonField.of(mutableListOf())).also { + checkKnown("values", it).add(value) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Filter]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .field() + * .operator() + * .values() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Filter = + Filter( + checkRequired("field", field), + checkRequired("operator", operator), + checkRequired("values", values).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Filter = apply { + if (validated) { + return@apply + } + + field().validate() + operator().validate() + values() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (field.asKnown()?.validity() ?: 0) + + (operator.asKnown()?.validity() ?: 0) + + (values.asKnown()?.size ?: 0) + + /** The property of the price to filter on. */ + class Field @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val PRICE_ID = of("price_id") + + val ITEM_ID = of("item_id") + + val PRICE_TYPE = of("price_type") + + val CURRENCY = of("currency") + + val PRICING_UNIT_ID = of("pricing_unit_id") + + fun of(value: String) = Field(JsonField.of(value)) + } + + /** An enum containing [Field]'s known values. */ + enum class Known { + PRICE_ID, + ITEM_ID, + PRICE_TYPE, + CURRENCY, + PRICING_UNIT_ID, + } + + /** + * An enum containing [Field]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Field] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + PRICE_ID, + ITEM_ID, + PRICE_TYPE, + CURRENCY, + PRICING_UNIT_ID, + /** + * An enum member indicating that [Field] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + PRICE_ID -> Value.PRICE_ID + ITEM_ID -> Value.ITEM_ID + PRICE_TYPE -> Value.PRICE_TYPE + CURRENCY -> Value.CURRENCY + PRICING_UNIT_ID -> Value.PRICING_UNIT_ID + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + PRICE_ID -> Known.PRICE_ID + ITEM_ID -> Known.ITEM_ID + PRICE_TYPE -> Known.PRICE_TYPE + CURRENCY -> Known.CURRENCY + PRICING_UNIT_ID -> Known.PRICING_UNIT_ID + else -> throw OrbInvalidDataException("Unknown Field: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Field = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Field && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Should prices that match the filter be included or excluded. */ + class Operator @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val INCLUDES = of("includes") + + val EXCLUDES = of("excludes") + + fun of(value: String) = Operator(JsonField.of(value)) + } + + /** An enum containing [Operator]'s known values. */ + enum class Known { + INCLUDES, + EXCLUDES, + } + + /** + * An enum containing [Operator]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Operator] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + INCLUDES, + EXCLUDES, + /** + * An enum member indicating that [Operator] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + INCLUDES -> Value.INCLUDES + EXCLUDES -> Value.EXCLUDES + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + INCLUDES -> Known.INCLUDES + EXCLUDES -> Known.EXCLUDES + else -> throw OrbInvalidDataException("Unknown Operator: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Operator = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Operator && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Filter && + field == other.field && + operator == other.operator && + values == other.values && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(field, operator, values, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Filter{field=$field, operator=$operator, values=$values, additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/UsageDiscount.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/UsageDiscount.kt index c4c91b584..96af476b1 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/UsageDiscount.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/UsageDiscount.kt @@ -24,7 +24,7 @@ private constructor( private val discountType: JsonField, private val usageDiscount: JsonField, private val appliesToPriceIds: JsonField>, - private val filters: JsonField>, + private val filters: JsonField>, private val reason: JsonField, private val additionalProperties: MutableMap, ) { @@ -42,7 +42,7 @@ private constructor( appliesToPriceIds: JsonField> = JsonMissing.of(), @JsonProperty("filters") @ExcludeMissing - filters: JsonField> = JsonMissing.of(), + filters: JsonField> = JsonMissing.of(), @JsonProperty("reason") @ExcludeMissing reason: JsonField = JsonMissing.of(), ) : this(discountType, usageDiscount, appliesToPriceIds, filters, reason, mutableMapOf()) @@ -75,7 +75,7 @@ private constructor( * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server * responded with an unexpected value). */ - fun filters(): List? = filters.getNullable("filters") + fun filters(): List? = filters.getNullable("filters") /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server @@ -116,9 +116,7 @@ private constructor( * * Unlike [filters], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("filters") - @ExcludeMissing - fun _filters(): JsonField> = filters + @JsonProperty("filters") @ExcludeMissing fun _filters(): JsonField> = filters /** * Returns the raw JSON value of [reason]. @@ -159,7 +157,7 @@ private constructor( private var discountType: JsonField? = null private var usageDiscount: JsonField? = null private var appliesToPriceIds: JsonField>? = null - private var filters: JsonField>? = null + private var filters: JsonField>? = null private var reason: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -233,25 +231,25 @@ private constructor( } /** The filters that determine which prices to apply this discount to. */ - fun filters(filters: List?) = filters(JsonField.ofNullable(filters)) + fun filters(filters: List?) = filters(JsonField.ofNullable(filters)) /** * Sets [Builder.filters] to an arbitrary JSON value. * - * You should usually call [Builder.filters] with a well-typed `List` - * value instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. + * You should usually call [Builder.filters] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. */ - fun filters(filters: JsonField>) = apply { + fun filters(filters: JsonField>) = apply { this.filters = filters.map { it.toMutableList() } } /** - * Adds a single [TransformPriceFilter] to [filters]. + * Adds a single [Filter] to [filters]. * * @throws IllegalStateException if the field was previously set to a non-list. */ - fun addFilter(filter: TransformPriceFilter) = apply { + fun addFilter(filter: Filter) = apply { filters = (filters ?: JsonField.of(mutableListOf())).also { checkKnown("filters", it).add(filter) @@ -467,6 +465,534 @@ private constructor( override fun toString() = value.toString() } + class Filter + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val field: JsonField, + private val operator: JsonField, + private val values: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("field") @ExcludeMissing field: JsonField = JsonMissing.of(), + @JsonProperty("operator") + @ExcludeMissing + operator: JsonField = JsonMissing.of(), + @JsonProperty("values") + @ExcludeMissing + values: JsonField> = JsonMissing.of(), + ) : this(field, operator, values, mutableMapOf()) + + /** + * The property of the price to filter on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun field(): Field = field.getRequired("field") + + /** + * Should prices that match the filter be included or excluded. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun operator(): Operator = operator.getRequired("operator") + + /** + * The IDs or values that match this filter. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun values(): List = values.getRequired("values") + + /** + * Returns the raw JSON value of [field]. + * + * Unlike [field], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("field") @ExcludeMissing fun _field(): JsonField = field + + /** + * Returns the raw JSON value of [operator]. + * + * Unlike [operator], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("operator") @ExcludeMissing fun _operator(): JsonField = operator + + /** + * Returns the raw JSON value of [values]. + * + * Unlike [values], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("values") @ExcludeMissing fun _values(): JsonField> = values + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Filter]. + * + * The following fields are required: + * ```kotlin + * .field() + * .operator() + * .values() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Filter]. */ + class Builder internal constructor() { + + private var field: JsonField? = null + private var operator: JsonField? = null + private var values: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(filter: Filter) = apply { + field = filter.field + operator = filter.operator + values = filter.values.map { it.toMutableList() } + additionalProperties = filter.additionalProperties.toMutableMap() + } + + /** The property of the price to filter on. */ + fun field(field: Field) = field(JsonField.of(field)) + + /** + * Sets [Builder.field] to an arbitrary JSON value. + * + * You should usually call [Builder.field] with a well-typed [Field] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun field(field: JsonField) = apply { this.field = field } + + /** Should prices that match the filter be included or excluded. */ + fun operator(operator: Operator) = operator(JsonField.of(operator)) + + /** + * Sets [Builder.operator] to an arbitrary JSON value. + * + * You should usually call [Builder.operator] with a well-typed [Operator] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun operator(operator: JsonField) = apply { this.operator = operator } + + /** The IDs or values that match this filter. */ + fun values(values: List) = values(JsonField.of(values)) + + /** + * Sets [Builder.values] to an arbitrary JSON value. + * + * You should usually call [Builder.values] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun values(values: JsonField>) = apply { + this.values = values.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [values]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addValue(value: String) = apply { + values = + (values ?: JsonField.of(mutableListOf())).also { + checkKnown("values", it).add(value) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Filter]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .field() + * .operator() + * .values() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Filter = + Filter( + checkRequired("field", field), + checkRequired("operator", operator), + checkRequired("values", values).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Filter = apply { + if (validated) { + return@apply + } + + field().validate() + operator().validate() + values() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (field.asKnown()?.validity() ?: 0) + + (operator.asKnown()?.validity() ?: 0) + + (values.asKnown()?.size ?: 0) + + /** The property of the price to filter on. */ + class Field @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val PRICE_ID = of("price_id") + + val ITEM_ID = of("item_id") + + val PRICE_TYPE = of("price_type") + + val CURRENCY = of("currency") + + val PRICING_UNIT_ID = of("pricing_unit_id") + + fun of(value: String) = Field(JsonField.of(value)) + } + + /** An enum containing [Field]'s known values. */ + enum class Known { + PRICE_ID, + ITEM_ID, + PRICE_TYPE, + CURRENCY, + PRICING_UNIT_ID, + } + + /** + * An enum containing [Field]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Field] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + PRICE_ID, + ITEM_ID, + PRICE_TYPE, + CURRENCY, + PRICING_UNIT_ID, + /** + * An enum member indicating that [Field] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + PRICE_ID -> Value.PRICE_ID + ITEM_ID -> Value.ITEM_ID + PRICE_TYPE -> Value.PRICE_TYPE + CURRENCY -> Value.CURRENCY + PRICING_UNIT_ID -> Value.PRICING_UNIT_ID + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + PRICE_ID -> Known.PRICE_ID + ITEM_ID -> Known.ITEM_ID + PRICE_TYPE -> Known.PRICE_TYPE + CURRENCY -> Known.CURRENCY + PRICING_UNIT_ID -> Known.PRICING_UNIT_ID + else -> throw OrbInvalidDataException("Unknown Field: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Field = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Field && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Should prices that match the filter be included or excluded. */ + class Operator @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val INCLUDES = of("includes") + + val EXCLUDES = of("excludes") + + fun of(value: String) = Operator(JsonField.of(value)) + } + + /** An enum containing [Operator]'s known values. */ + enum class Known { + INCLUDES, + EXCLUDES, + } + + /** + * An enum containing [Operator]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Operator] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + INCLUDES, + EXCLUDES, + /** + * An enum member indicating that [Operator] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + INCLUDES -> Value.INCLUDES + EXCLUDES -> Value.EXCLUDES + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + INCLUDES -> Known.INCLUDES + EXCLUDES -> Known.EXCLUDES + else -> throw OrbInvalidDataException("Unknown Operator: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Operator = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Operator && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Filter && + field == other.field && + operator == other.operator && + values == other.values && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(field, operator, values, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Filter{field=$field, operator=$operator, values=$values, additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/UsageDiscountInterval.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/UsageDiscountInterval.kt index e2cf8b9c9..b5b874985 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/UsageDiscountInterval.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/UsageDiscountInterval.kt @@ -25,7 +25,7 @@ private constructor( private val appliesToPriceIntervalIds: JsonField>, private val discountType: JsonField, private val endDate: JsonField, - private val filters: JsonField>, + private val filters: JsonField>, private val startDate: JsonField, private val usageDiscount: JsonField, private val additionalProperties: MutableMap, @@ -44,7 +44,7 @@ private constructor( endDate: JsonField = JsonMissing.of(), @JsonProperty("filters") @ExcludeMissing - filters: JsonField> = JsonMissing.of(), + filters: JsonField> = JsonMissing.of(), @JsonProperty("start_date") @ExcludeMissing startDate: JsonField = JsonMissing.of(), @@ -90,7 +90,7 @@ private constructor( * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ - fun filters(): List = filters.getRequired("filters") + fun filters(): List = filters.getRequired("filters") /** * The start date of the discount interval. @@ -139,9 +139,7 @@ private constructor( * * Unlike [filters], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("filters") - @ExcludeMissing - fun _filters(): JsonField> = filters + @JsonProperty("filters") @ExcludeMissing fun _filters(): JsonField> = filters /** * Returns the raw JSON value of [startDate]. @@ -197,7 +195,7 @@ private constructor( private var appliesToPriceIntervalIds: JsonField>? = null private var discountType: JsonField? = null private var endDate: JsonField? = null - private var filters: JsonField>? = null + private var filters: JsonField>? = null private var startDate: JsonField? = null private var usageDiscount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -266,25 +264,25 @@ private constructor( fun endDate(endDate: JsonField) = apply { this.endDate = endDate } /** The filters that determine which prices this discount interval applies to. */ - fun filters(filters: List) = filters(JsonField.of(filters)) + fun filters(filters: List) = filters(JsonField.of(filters)) /** * Sets [Builder.filters] to an arbitrary JSON value. * - * You should usually call [Builder.filters] with a well-typed `List` - * value instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. + * You should usually call [Builder.filters] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. */ - fun filters(filters: JsonField>) = apply { + fun filters(filters: JsonField>) = apply { this.filters = filters.map { it.toMutableList() } } /** - * Adds a single [TransformPriceFilter] to [filters]. + * Adds a single [Filter] to [filters]. * * @throws IllegalStateException if the field was previously set to a non-list. */ - fun addFilter(filter: TransformPriceFilter) = apply { + fun addFilter(filter: Filter) = apply { filters = (filters ?: JsonField.of(mutableListOf())).also { checkKnown("filters", it).add(filter) @@ -528,6 +526,534 @@ private constructor( override fun toString() = value.toString() } + class Filter + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val field: JsonField, + private val operator: JsonField, + private val values: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("field") @ExcludeMissing field: JsonField = JsonMissing.of(), + @JsonProperty("operator") + @ExcludeMissing + operator: JsonField = JsonMissing.of(), + @JsonProperty("values") + @ExcludeMissing + values: JsonField> = JsonMissing.of(), + ) : this(field, operator, values, mutableMapOf()) + + /** + * The property of the price to filter on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun field(): Field = field.getRequired("field") + + /** + * Should prices that match the filter be included or excluded. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun operator(): Operator = operator.getRequired("operator") + + /** + * The IDs or values that match this filter. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun values(): List = values.getRequired("values") + + /** + * Returns the raw JSON value of [field]. + * + * Unlike [field], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("field") @ExcludeMissing fun _field(): JsonField = field + + /** + * Returns the raw JSON value of [operator]. + * + * Unlike [operator], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("operator") @ExcludeMissing fun _operator(): JsonField = operator + + /** + * Returns the raw JSON value of [values]. + * + * Unlike [values], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("values") @ExcludeMissing fun _values(): JsonField> = values + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Filter]. + * + * The following fields are required: + * ```kotlin + * .field() + * .operator() + * .values() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Filter]. */ + class Builder internal constructor() { + + private var field: JsonField? = null + private var operator: JsonField? = null + private var values: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(filter: Filter) = apply { + field = filter.field + operator = filter.operator + values = filter.values.map { it.toMutableList() } + additionalProperties = filter.additionalProperties.toMutableMap() + } + + /** The property of the price to filter on. */ + fun field(field: Field) = field(JsonField.of(field)) + + /** + * Sets [Builder.field] to an arbitrary JSON value. + * + * You should usually call [Builder.field] with a well-typed [Field] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun field(field: JsonField) = apply { this.field = field } + + /** Should prices that match the filter be included or excluded. */ + fun operator(operator: Operator) = operator(JsonField.of(operator)) + + /** + * Sets [Builder.operator] to an arbitrary JSON value. + * + * You should usually call [Builder.operator] with a well-typed [Operator] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun operator(operator: JsonField) = apply { this.operator = operator } + + /** The IDs or values that match this filter. */ + fun values(values: List) = values(JsonField.of(values)) + + /** + * Sets [Builder.values] to an arbitrary JSON value. + * + * You should usually call [Builder.values] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun values(values: JsonField>) = apply { + this.values = values.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [values]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addValue(value: String) = apply { + values = + (values ?: JsonField.of(mutableListOf())).also { + checkKnown("values", it).add(value) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Filter]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .field() + * .operator() + * .values() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Filter = + Filter( + checkRequired("field", field), + checkRequired("operator", operator), + checkRequired("values", values).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Filter = apply { + if (validated) { + return@apply + } + + field().validate() + operator().validate() + values() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (field.asKnown()?.validity() ?: 0) + + (operator.asKnown()?.validity() ?: 0) + + (values.asKnown()?.size ?: 0) + + /** The property of the price to filter on. */ + class Field @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val PRICE_ID = of("price_id") + + val ITEM_ID = of("item_id") + + val PRICE_TYPE = of("price_type") + + val CURRENCY = of("currency") + + val PRICING_UNIT_ID = of("pricing_unit_id") + + fun of(value: String) = Field(JsonField.of(value)) + } + + /** An enum containing [Field]'s known values. */ + enum class Known { + PRICE_ID, + ITEM_ID, + PRICE_TYPE, + CURRENCY, + PRICING_UNIT_ID, + } + + /** + * An enum containing [Field]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Field] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + PRICE_ID, + ITEM_ID, + PRICE_TYPE, + CURRENCY, + PRICING_UNIT_ID, + /** + * An enum member indicating that [Field] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + PRICE_ID -> Value.PRICE_ID + ITEM_ID -> Value.ITEM_ID + PRICE_TYPE -> Value.PRICE_TYPE + CURRENCY -> Value.CURRENCY + PRICING_UNIT_ID -> Value.PRICING_UNIT_ID + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + PRICE_ID -> Known.PRICE_ID + ITEM_ID -> Known.ITEM_ID + PRICE_TYPE -> Known.PRICE_TYPE + CURRENCY -> Known.CURRENCY + PRICING_UNIT_ID -> Known.PRICING_UNIT_ID + else -> throw OrbInvalidDataException("Unknown Field: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Field = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Field && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Should prices that match the filter be included or excluded. */ + class Operator @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val INCLUDES = of("includes") + + val EXCLUDES = of("excludes") + + fun of(value: String) = Operator(JsonField.of(value)) + } + + /** An enum containing [Operator]'s known values. */ + enum class Known { + INCLUDES, + EXCLUDES, + } + + /** + * An enum containing [Operator]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Operator] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + INCLUDES, + EXCLUDES, + /** + * An enum member indicating that [Operator] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + INCLUDES -> Value.INCLUDES + EXCLUDES -> Value.EXCLUDES + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + INCLUDES -> Known.INCLUDES + EXCLUDES -> Known.EXCLUDES + else -> throw OrbInvalidDataException("Unknown Operator: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Operator = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Operator && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Filter && + field == other.field && + operator == other.operator && + values == other.values && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(field, operator, values, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Filter{field=$field, operator=$operator, values=$values, additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/AdjustmentIntervalTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/AdjustmentIntervalTest.kt index d65ea1e19..113614f26 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/AdjustmentIntervalTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/AdjustmentIntervalTest.kt @@ -23,9 +23,9 @@ internal class AdjustmentIntervalTest { ) .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PlanPhaseUsageDiscountAdjustment.Filter.builder() + .field(PlanPhaseUsageDiscountAdjustment.Filter.Field.PRICE_ID) + .operator(PlanPhaseUsageDiscountAdjustment.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -52,9 +52,9 @@ internal class AdjustmentIntervalTest { ) .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PlanPhaseUsageDiscountAdjustment.Filter.builder() + .field(PlanPhaseUsageDiscountAdjustment.Filter.Field.PRICE_ID) + .operator(PlanPhaseUsageDiscountAdjustment.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -87,9 +87,9 @@ internal class AdjustmentIntervalTest { ) .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PlanPhaseUsageDiscountAdjustment.Filter.builder() + .field(PlanPhaseUsageDiscountAdjustment.Filter.Field.PRICE_ID) + .operator(PlanPhaseUsageDiscountAdjustment.Filter.Operator.INCLUDES) .addValue("string") .build() ) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/AffectedBlockTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/AffectedBlockTest.kt index 06d3e4c3f..3299fbed0 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/AffectedBlockTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/AffectedBlockTest.kt @@ -15,11 +15,26 @@ internal class AffectedBlockTest { val affectedBlock = AffectedBlock.builder() .id("id") + .addBlockFilter( + AffectedBlock.BlockFilter.builder() + .field(AffectedBlock.BlockFilter.Field.PRICE_ID) + .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() assertThat(affectedBlock.id()).isEqualTo("id") + assertThat(affectedBlock.blockFilters()) + .containsExactly( + AffectedBlock.BlockFilter.builder() + .field(AffectedBlock.BlockFilter.Field.PRICE_ID) + .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) assertThat(affectedBlock.expiryDate()) .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) assertThat(affectedBlock.perUnitCostBasis()).isEqualTo("per_unit_cost_basis") @@ -31,6 +46,13 @@ internal class AffectedBlockTest { val affectedBlock = AffectedBlock.builder() .id("id") + .addBlockFilter( + AffectedBlock.BlockFilter.builder() + .field(AffectedBlock.BlockFilter.Field.PRICE_ID) + .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/AggregatedCostTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/AggregatedCostTest.kt index d6819e955..6d18a70c1 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/AggregatedCostTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/AggregatedCostTest.kt @@ -30,9 +30,9 @@ internal class AggregatedCostTest { .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Price.Unit.CompositePriceFilter.builder() + .field(Price.Unit.CompositePriceFilter.Field.PRICE_ID) + .operator(Price.Unit.CompositePriceFilter.Operator.INCLUDES) .addValue("string") .build() ) @@ -63,9 +63,11 @@ internal class AggregatedCostTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator( + PercentageDiscount.Filter.Operator.INCLUDES + ) .addValue("string") .build() ) @@ -85,9 +87,9 @@ internal class AggregatedCostTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -104,9 +106,9 @@ internal class AggregatedCostTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -155,9 +157,9 @@ internal class AggregatedCostTest { .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Price.Unit.CompositePriceFilter.builder() + .field(Price.Unit.CompositePriceFilter.Field.PRICE_ID) + .operator(Price.Unit.CompositePriceFilter.Operator.INCLUDES) .addValue("string") .build() ) @@ -186,9 +188,9 @@ internal class AggregatedCostTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -208,9 +210,9 @@ internal class AggregatedCostTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -227,9 +229,9 @@ internal class AggregatedCostTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -284,9 +286,9 @@ internal class AggregatedCostTest { .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Price.Unit.CompositePriceFilter.builder() + .field(Price.Unit.CompositePriceFilter.Field.PRICE_ID) + .operator(Price.Unit.CompositePriceFilter.Operator.INCLUDES) .addValue("string") .build() ) @@ -317,9 +319,11 @@ internal class AggregatedCostTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator( + PercentageDiscount.Filter.Operator.INCLUDES + ) .addValue("string") .build() ) @@ -339,9 +343,9 @@ internal class AggregatedCostTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -358,9 +362,9 @@ internal class AggregatedCostTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/AmendmentLedgerEntryTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/AmendmentLedgerEntryTest.kt index cc4b7e787..021be10d6 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/AmendmentLedgerEntryTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/AmendmentLedgerEntryTest.kt @@ -21,6 +21,13 @@ internal class AmendmentLedgerEntryTest { .creditBlock( AffectedBlock.builder() .id("id") + .addBlockFilter( + AffectedBlock.BlockFilter.builder() + .field(AffectedBlock.BlockFilter.Field.PRICE_ID) + .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() @@ -53,6 +60,13 @@ internal class AmendmentLedgerEntryTest { .isEqualTo( AffectedBlock.builder() .id("id") + .addBlockFilter( + AffectedBlock.BlockFilter.builder() + .field(AffectedBlock.BlockFilter.Field.PRICE_ID) + .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() @@ -92,6 +106,13 @@ internal class AmendmentLedgerEntryTest { .creditBlock( AffectedBlock.builder() .id("id") + .addBlockFilter( + AffectedBlock.BlockFilter.builder() + .field(AffectedBlock.BlockFilter.Field.PRICE_ID) + .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/AmountDiscountIntervalTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/AmountDiscountIntervalTest.kt index 035130c18..7e1631690 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/AmountDiscountIntervalTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/AmountDiscountIntervalTest.kt @@ -19,9 +19,9 @@ internal class AmountDiscountIntervalTest { .discountType(AmountDiscountInterval.DiscountType.AMOUNT) .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + AmountDiscountInterval.Filter.builder() + .field(AmountDiscountInterval.Filter.Field.PRICE_ID) + .operator(AmountDiscountInterval.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -36,9 +36,9 @@ internal class AmountDiscountIntervalTest { .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) assertThat(amountDiscountInterval.filters()) .containsExactly( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + AmountDiscountInterval.Filter.builder() + .field(AmountDiscountInterval.Filter.Field.PRICE_ID) + .operator(AmountDiscountInterval.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -56,9 +56,9 @@ internal class AmountDiscountIntervalTest { .discountType(AmountDiscountInterval.DiscountType.AMOUNT) .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + AmountDiscountInterval.Filter.builder() + .field(AmountDiscountInterval.Filter.Field.PRICE_ID) + .operator(AmountDiscountInterval.Filter.Operator.INCLUDES) .addValue("string") .build() ) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/AmountDiscountTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/AmountDiscountTest.kt index 43b88c98f..cb748300d 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/AmountDiscountTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/AmountDiscountTest.kt @@ -18,9 +18,9 @@ internal class AmountDiscountTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + AmountDiscount.Filter.builder() + .field(AmountDiscount.Filter.Field.PRICE_ID) + .operator(AmountDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -33,9 +33,9 @@ internal class AmountDiscountTest { .containsExactly("h74gfhdjvn7ujokd", "7hfgtgjnbvc3ujkl") assertThat(amountDiscount.filters()) .containsExactly( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + AmountDiscount.Filter.builder() + .field(AmountDiscount.Filter.Field.PRICE_ID) + .operator(AmountDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -52,9 +52,9 @@ internal class AmountDiscountTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + AmountDiscount.Filter.builder() + .field(AmountDiscount.Filter.Field.PRICE_ID) + .operator(AmountDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/BetaCreatePlanVersionParamsTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/BetaCreatePlanVersionParamsTest.kt index 641af6239..e6acde520 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/BetaCreatePlanVersionParamsTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/BetaCreatePlanVersionParamsTest.kt @@ -28,9 +28,9 @@ internal class BetaCreatePlanVersionParamsTest { .addAppliesToPriceId("price_2") .currency("currency") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + NewPercentageDiscount.Filter.builder() + .field(NewPercentageDiscount.Filter.Field.PRICE_ID) + .operator(NewPercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -133,9 +133,9 @@ internal class BetaCreatePlanVersionParamsTest { .addAppliesToPriceId("price_2") .currency("currency") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + NewPercentageDiscount.Filter.builder() + .field(NewPercentageDiscount.Filter.Field.PRICE_ID) + .operator(NewPercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -247,9 +247,9 @@ internal class BetaCreatePlanVersionParamsTest { .addAppliesToPriceId("price_2") .currency("currency") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + NewPercentageDiscount.Filter.builder() + .field(NewPercentageDiscount.Filter.Field.PRICE_ID) + .operator(NewPercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -354,9 +354,9 @@ internal class BetaCreatePlanVersionParamsTest { .addAppliesToPriceId("price_2") .currency("currency") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + NewPercentageDiscount.Filter.builder() + .field(NewPercentageDiscount.Filter.Field.PRICE_ID) + .operator(NewPercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -458,9 +458,9 @@ internal class BetaCreatePlanVersionParamsTest { .addAppliesToPriceId("price_2") .currency("currency") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + NewPercentageDiscount.Filter.builder() + .field(NewPercentageDiscount.Filter.Field.PRICE_ID) + .operator(NewPercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -567,9 +567,9 @@ internal class BetaCreatePlanVersionParamsTest { .addAppliesToPriceId("price_2") .currency("currency") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + NewPercentageDiscount.Filter.builder() + .field(NewPercentageDiscount.Filter.Field.PRICE_ID) + .operator(NewPercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/BetaExternalPlanIdCreatePlanVersionParamsTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/BetaExternalPlanIdCreatePlanVersionParamsTest.kt index c05f7acc8..6f438cc15 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/BetaExternalPlanIdCreatePlanVersionParamsTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/BetaExternalPlanIdCreatePlanVersionParamsTest.kt @@ -28,9 +28,9 @@ internal class BetaExternalPlanIdCreatePlanVersionParamsTest { .addAppliesToPriceId("price_2") .currency("currency") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + NewPercentageDiscount.Filter.builder() + .field(NewPercentageDiscount.Filter.Field.PRICE_ID) + .operator(NewPercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -133,9 +133,9 @@ internal class BetaExternalPlanIdCreatePlanVersionParamsTest { .addAppliesToPriceId("price_2") .currency("currency") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + NewPercentageDiscount.Filter.builder() + .field(NewPercentageDiscount.Filter.Field.PRICE_ID) + .operator(NewPercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -251,9 +251,9 @@ internal class BetaExternalPlanIdCreatePlanVersionParamsTest { .addAppliesToPriceId("price_2") .currency("currency") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + NewPercentageDiscount.Filter.builder() + .field(NewPercentageDiscount.Filter.Field.PRICE_ID) + .operator(NewPercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -358,9 +358,9 @@ internal class BetaExternalPlanIdCreatePlanVersionParamsTest { .addAppliesToPriceId("price_2") .currency("currency") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + NewPercentageDiscount.Filter.builder() + .field(NewPercentageDiscount.Filter.Field.PRICE_ID) + .operator(NewPercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -462,9 +462,9 @@ internal class BetaExternalPlanIdCreatePlanVersionParamsTest { .addAppliesToPriceId("price_2") .currency("currency") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + NewPercentageDiscount.Filter.builder() + .field(NewPercentageDiscount.Filter.Field.PRICE_ID) + .operator(NewPercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -571,9 +571,9 @@ internal class BetaExternalPlanIdCreatePlanVersionParamsTest { .addAppliesToPriceId("price_2") .currency("currency") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + NewPercentageDiscount.Filter.builder() + .field(NewPercentageDiscount.Filter.Field.PRICE_ID) + .operator(NewPercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/ChangedSubscriptionResourcesTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/ChangedSubscriptionResourcesTest.kt index a1ac50821..4e461862c 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/ChangedSubscriptionResourcesTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/ChangedSubscriptionResourcesTest.kt @@ -184,9 +184,9 @@ internal class ChangedSubscriptionResourcesTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -221,9 +221,15 @@ internal class ChangedSubscriptionResourcesTest { .amount("amount") .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + MonetaryUsageDiscountAdjustment.Filter.builder() + .field( + MonetaryUsageDiscountAdjustment.Filter.Field + .PRICE_ID + ) + .operator( + MonetaryUsageDiscountAdjustment.Filter.Operator + .INCLUDES + ) .addValue("string") .build() ) @@ -242,9 +248,11 @@ internal class ChangedSubscriptionResourcesTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator( + PercentageDiscount.Filter.Operator.INCLUDES + ) .addValue("string") .build() ) @@ -258,9 +266,9 @@ internal class ChangedSubscriptionResourcesTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -272,9 +280,9 @@ internal class ChangedSubscriptionResourcesTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -301,9 +309,14 @@ internal class ChangedSubscriptionResourcesTest { .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Price.Unit.CompositePriceFilter.builder() + .field( + Price.Unit.CompositePriceFilter.Field.PRICE_ID + ) + .operator( + Price.Unit.CompositePriceFilter.Operator + .INCLUDES + ) .addValue("string") .build() ) @@ -338,10 +351,13 @@ internal class ChangedSubscriptionResourcesTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) + PercentageDiscount.Filter.builder() + .field( + PercentageDiscount.Filter.Field.PRICE_ID + ) .operator( - TransformPriceFilter.Operator.INCLUDES + PercentageDiscount.Filter.Operator + .INCLUDES ) .addValue("string") .build() @@ -364,11 +380,9 @@ internal class ChangedSubscriptionResourcesTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -388,11 +402,9 @@ internal class ChangedSubscriptionResourcesTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -454,9 +466,9 @@ internal class ChangedSubscriptionResourcesTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -474,9 +486,9 @@ internal class ChangedSubscriptionResourcesTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -684,9 +696,9 @@ internal class ChangedSubscriptionResourcesTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -718,9 +730,15 @@ internal class ChangedSubscriptionResourcesTest { .amount("amount") .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + MonetaryUsageDiscountAdjustment.Filter.builder() + .field( + MonetaryUsageDiscountAdjustment.Filter.Field + .PRICE_ID + ) + .operator( + MonetaryUsageDiscountAdjustment.Filter.Operator + .INCLUDES + ) .addValue("string") .build() ) @@ -739,9 +757,11 @@ internal class ChangedSubscriptionResourcesTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator( + PercentageDiscount.Filter.Operator.INCLUDES + ) .addValue("string") .build() ) @@ -755,9 +775,9 @@ internal class ChangedSubscriptionResourcesTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -769,9 +789,9 @@ internal class ChangedSubscriptionResourcesTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -798,9 +818,14 @@ internal class ChangedSubscriptionResourcesTest { .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Price.Unit.CompositePriceFilter.builder() + .field( + Price.Unit.CompositePriceFilter.Field.PRICE_ID + ) + .operator( + Price.Unit.CompositePriceFilter.Operator + .INCLUDES + ) .addValue("string") .build() ) @@ -835,10 +860,13 @@ internal class ChangedSubscriptionResourcesTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) + PercentageDiscount.Filter.builder() + .field( + PercentageDiscount.Filter.Field.PRICE_ID + ) .operator( - TransformPriceFilter.Operator.INCLUDES + PercentageDiscount.Filter.Operator + .INCLUDES ) .addValue("string") .build() @@ -861,11 +889,9 @@ internal class ChangedSubscriptionResourcesTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -885,11 +911,9 @@ internal class ChangedSubscriptionResourcesTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -951,9 +975,9 @@ internal class ChangedSubscriptionResourcesTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -971,9 +995,9 @@ internal class ChangedSubscriptionResourcesTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -1186,9 +1210,9 @@ internal class ChangedSubscriptionResourcesTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -1223,9 +1247,15 @@ internal class ChangedSubscriptionResourcesTest { .amount("amount") .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + MonetaryUsageDiscountAdjustment.Filter.builder() + .field( + MonetaryUsageDiscountAdjustment.Filter.Field + .PRICE_ID + ) + .operator( + MonetaryUsageDiscountAdjustment.Filter.Operator + .INCLUDES + ) .addValue("string") .build() ) @@ -1244,9 +1274,9 @@ internal class ChangedSubscriptionResourcesTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -1260,9 +1290,9 @@ internal class ChangedSubscriptionResourcesTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -1274,9 +1304,9 @@ internal class ChangedSubscriptionResourcesTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -1301,9 +1331,11 @@ internal class ChangedSubscriptionResourcesTest { .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Price.Unit.CompositePriceFilter.builder() + .field(Price.Unit.CompositePriceFilter.Field.PRICE_ID) + .operator( + Price.Unit.CompositePriceFilter.Operator.INCLUDES + ) .addValue("string") .build() ) @@ -1336,10 +1368,10 @@ internal class ChangedSubscriptionResourcesTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) .operator( - TransformPriceFilter.Operator.INCLUDES + PercentageDiscount.Filter.Operator.INCLUDES ) .addValue("string") .build() @@ -1362,11 +1394,9 @@ internal class ChangedSubscriptionResourcesTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -1383,11 +1413,9 @@ internal class ChangedSubscriptionResourcesTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -1447,9 +1475,9 @@ internal class ChangedSubscriptionResourcesTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -1467,9 +1495,9 @@ internal class ChangedSubscriptionResourcesTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -1673,9 +1701,9 @@ internal class ChangedSubscriptionResourcesTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -1707,9 +1735,15 @@ internal class ChangedSubscriptionResourcesTest { .amount("amount") .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + MonetaryUsageDiscountAdjustment.Filter.builder() + .field( + MonetaryUsageDiscountAdjustment.Filter.Field + .PRICE_ID + ) + .operator( + MonetaryUsageDiscountAdjustment.Filter.Operator + .INCLUDES + ) .addValue("string") .build() ) @@ -1728,9 +1762,9 @@ internal class ChangedSubscriptionResourcesTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -1744,9 +1778,9 @@ internal class ChangedSubscriptionResourcesTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -1758,9 +1792,9 @@ internal class ChangedSubscriptionResourcesTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -1785,9 +1819,11 @@ internal class ChangedSubscriptionResourcesTest { .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Price.Unit.CompositePriceFilter.builder() + .field(Price.Unit.CompositePriceFilter.Field.PRICE_ID) + .operator( + Price.Unit.CompositePriceFilter.Operator.INCLUDES + ) .addValue("string") .build() ) @@ -1820,10 +1856,10 @@ internal class ChangedSubscriptionResourcesTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) .operator( - TransformPriceFilter.Operator.INCLUDES + PercentageDiscount.Filter.Operator.INCLUDES ) .addValue("string") .build() @@ -1846,11 +1882,9 @@ internal class ChangedSubscriptionResourcesTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -1867,11 +1901,9 @@ internal class ChangedSubscriptionResourcesTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -1931,9 +1963,9 @@ internal class ChangedSubscriptionResourcesTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -1951,9 +1983,9 @@ internal class ChangedSubscriptionResourcesTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -2173,9 +2205,9 @@ internal class ChangedSubscriptionResourcesTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -2210,9 +2242,15 @@ internal class ChangedSubscriptionResourcesTest { .amount("amount") .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + MonetaryUsageDiscountAdjustment.Filter.builder() + .field( + MonetaryUsageDiscountAdjustment.Filter.Field + .PRICE_ID + ) + .operator( + MonetaryUsageDiscountAdjustment.Filter.Operator + .INCLUDES + ) .addValue("string") .build() ) @@ -2231,9 +2269,11 @@ internal class ChangedSubscriptionResourcesTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator( + PercentageDiscount.Filter.Operator.INCLUDES + ) .addValue("string") .build() ) @@ -2247,9 +2287,9 @@ internal class ChangedSubscriptionResourcesTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -2261,9 +2301,9 @@ internal class ChangedSubscriptionResourcesTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -2290,9 +2330,14 @@ internal class ChangedSubscriptionResourcesTest { .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Price.Unit.CompositePriceFilter.builder() + .field( + Price.Unit.CompositePriceFilter.Field.PRICE_ID + ) + .operator( + Price.Unit.CompositePriceFilter.Operator + .INCLUDES + ) .addValue("string") .build() ) @@ -2327,10 +2372,13 @@ internal class ChangedSubscriptionResourcesTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) + PercentageDiscount.Filter.builder() + .field( + PercentageDiscount.Filter.Field.PRICE_ID + ) .operator( - TransformPriceFilter.Operator.INCLUDES + PercentageDiscount.Filter.Operator + .INCLUDES ) .addValue("string") .build() @@ -2353,11 +2401,9 @@ internal class ChangedSubscriptionResourcesTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -2377,11 +2423,9 @@ internal class ChangedSubscriptionResourcesTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -2443,9 +2487,9 @@ internal class ChangedSubscriptionResourcesTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -2463,9 +2507,9 @@ internal class ChangedSubscriptionResourcesTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -2673,9 +2717,9 @@ internal class ChangedSubscriptionResourcesTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -2707,9 +2751,15 @@ internal class ChangedSubscriptionResourcesTest { .amount("amount") .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + MonetaryUsageDiscountAdjustment.Filter.builder() + .field( + MonetaryUsageDiscountAdjustment.Filter.Field + .PRICE_ID + ) + .operator( + MonetaryUsageDiscountAdjustment.Filter.Operator + .INCLUDES + ) .addValue("string") .build() ) @@ -2728,9 +2778,11 @@ internal class ChangedSubscriptionResourcesTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator( + PercentageDiscount.Filter.Operator.INCLUDES + ) .addValue("string") .build() ) @@ -2744,9 +2796,9 @@ internal class ChangedSubscriptionResourcesTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -2758,9 +2810,9 @@ internal class ChangedSubscriptionResourcesTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -2787,9 +2839,14 @@ internal class ChangedSubscriptionResourcesTest { .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Price.Unit.CompositePriceFilter.builder() + .field( + Price.Unit.CompositePriceFilter.Field.PRICE_ID + ) + .operator( + Price.Unit.CompositePriceFilter.Operator + .INCLUDES + ) .addValue("string") .build() ) @@ -2824,10 +2881,13 @@ internal class ChangedSubscriptionResourcesTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) + PercentageDiscount.Filter.builder() + .field( + PercentageDiscount.Filter.Field.PRICE_ID + ) .operator( - TransformPriceFilter.Operator.INCLUDES + PercentageDiscount.Filter.Operator + .INCLUDES ) .addValue("string") .build() @@ -2850,11 +2910,9 @@ internal class ChangedSubscriptionResourcesTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -2874,11 +2932,9 @@ internal class ChangedSubscriptionResourcesTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -2940,9 +2996,9 @@ internal class ChangedSubscriptionResourcesTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -2960,9 +3016,9 @@ internal class ChangedSubscriptionResourcesTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CouponListPageResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CouponListPageResponseTest.kt index f452c3109..d89b824cf 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CouponListPageResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CouponListPageResponseTest.kt @@ -25,9 +25,9 @@ internal class CouponListPageResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -57,9 +57,9 @@ internal class CouponListPageResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -92,9 +92,9 @@ internal class CouponListPageResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CouponTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CouponTest.kt index 73a5ec822..f354410bd 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CouponTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CouponTest.kt @@ -23,9 +23,9 @@ internal class CouponTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -49,9 +49,9 @@ internal class CouponTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -79,9 +79,9 @@ internal class CouponTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CreditBlockExpiryLedgerEntryTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CreditBlockExpiryLedgerEntryTest.kt index 2e59cc5b4..6518d1403 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CreditBlockExpiryLedgerEntryTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CreditBlockExpiryLedgerEntryTest.kt @@ -21,6 +21,13 @@ internal class CreditBlockExpiryLedgerEntryTest { .creditBlock( AffectedBlock.builder() .id("id") + .addBlockFilter( + AffectedBlock.BlockFilter.builder() + .field(AffectedBlock.BlockFilter.Field.PRICE_ID) + .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() @@ -53,6 +60,13 @@ internal class CreditBlockExpiryLedgerEntryTest { .isEqualTo( AffectedBlock.builder() .id("id") + .addBlockFilter( + AffectedBlock.BlockFilter.builder() + .field(AffectedBlock.BlockFilter.Field.PRICE_ID) + .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() @@ -92,6 +106,13 @@ internal class CreditBlockExpiryLedgerEntryTest { .creditBlock( AffectedBlock.builder() .id("id") + .addBlockFilter( + AffectedBlock.BlockFilter.builder() + .field(AffectedBlock.BlockFilter.Field.PRICE_ID) + .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCostListByExternalIdResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCostListByExternalIdResponseTest.kt index fcf910455..cfc4a85c5 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCostListByExternalIdResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCostListByExternalIdResponseTest.kt @@ -36,9 +36,14 @@ internal class CustomerCostListByExternalIdResponseTest { .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Price.Unit.CompositePriceFilter.builder() + .field( + Price.Unit.CompositePriceFilter.Field.PRICE_ID + ) + .operator( + Price.Unit.CompositePriceFilter.Operator + .INCLUDES + ) .addValue("string") .build() ) @@ -73,10 +78,13 @@ internal class CustomerCostListByExternalIdResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) + PercentageDiscount.Filter.builder() + .field( + PercentageDiscount.Filter.Field.PRICE_ID + ) .operator( - TransformPriceFilter.Operator.INCLUDES + PercentageDiscount.Filter.Operator + .INCLUDES ) .addValue("string") .build() @@ -99,11 +107,9 @@ internal class CustomerCostListByExternalIdResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -123,11 +129,9 @@ internal class CustomerCostListByExternalIdResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -186,9 +190,11 @@ internal class CustomerCostListByExternalIdResponseTest { .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Price.Unit.CompositePriceFilter.builder() + .field(Price.Unit.CompositePriceFilter.Field.PRICE_ID) + .operator( + Price.Unit.CompositePriceFilter.Operator.INCLUDES + ) .addValue("string") .build() ) @@ -221,10 +227,10 @@ internal class CustomerCostListByExternalIdResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) .operator( - TransformPriceFilter.Operator.INCLUDES + PercentageDiscount.Filter.Operator.INCLUDES ) .addValue("string") .build() @@ -247,11 +253,9 @@ internal class CustomerCostListByExternalIdResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -268,11 +272,9 @@ internal class CustomerCostListByExternalIdResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -335,9 +337,14 @@ internal class CustomerCostListByExternalIdResponseTest { .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Price.Unit.CompositePriceFilter.builder() + .field( + Price.Unit.CompositePriceFilter.Field.PRICE_ID + ) + .operator( + Price.Unit.CompositePriceFilter.Operator + .INCLUDES + ) .addValue("string") .build() ) @@ -372,10 +379,13 @@ internal class CustomerCostListByExternalIdResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) + PercentageDiscount.Filter.builder() + .field( + PercentageDiscount.Filter.Field.PRICE_ID + ) .operator( - TransformPriceFilter.Operator.INCLUDES + PercentageDiscount.Filter.Operator + .INCLUDES ) .addValue("string") .build() @@ -398,11 +408,9 @@ internal class CustomerCostListByExternalIdResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -422,11 +430,9 @@ internal class CustomerCostListByExternalIdResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCostListResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCostListResponseTest.kt index 8dd14fcdc..515ae5de8 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCostListResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCostListResponseTest.kt @@ -36,9 +36,14 @@ internal class CustomerCostListResponseTest { .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Price.Unit.CompositePriceFilter.builder() + .field( + Price.Unit.CompositePriceFilter.Field.PRICE_ID + ) + .operator( + Price.Unit.CompositePriceFilter.Operator + .INCLUDES + ) .addValue("string") .build() ) @@ -73,10 +78,13 @@ internal class CustomerCostListResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) + PercentageDiscount.Filter.builder() + .field( + PercentageDiscount.Filter.Field.PRICE_ID + ) .operator( - TransformPriceFilter.Operator.INCLUDES + PercentageDiscount.Filter.Operator + .INCLUDES ) .addValue("string") .build() @@ -99,11 +107,9 @@ internal class CustomerCostListResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -123,11 +129,9 @@ internal class CustomerCostListResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -186,9 +190,11 @@ internal class CustomerCostListResponseTest { .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Price.Unit.CompositePriceFilter.builder() + .field(Price.Unit.CompositePriceFilter.Field.PRICE_ID) + .operator( + Price.Unit.CompositePriceFilter.Operator.INCLUDES + ) .addValue("string") .build() ) @@ -221,10 +227,10 @@ internal class CustomerCostListResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) .operator( - TransformPriceFilter.Operator.INCLUDES + PercentageDiscount.Filter.Operator.INCLUDES ) .addValue("string") .build() @@ -247,11 +253,9 @@ internal class CustomerCostListResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -268,11 +272,9 @@ internal class CustomerCostListResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -335,9 +337,14 @@ internal class CustomerCostListResponseTest { .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Price.Unit.CompositePriceFilter.builder() + .field( + Price.Unit.CompositePriceFilter.Field.PRICE_ID + ) + .operator( + Price.Unit.CompositePriceFilter.Operator + .INCLUDES + ) .addValue("string") .build() ) @@ -372,10 +379,13 @@ internal class CustomerCostListResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) + PercentageDiscount.Filter.builder() + .field( + PercentageDiscount.Filter.Field.PRICE_ID + ) .operator( - TransformPriceFilter.Operator.INCLUDES + PercentageDiscount.Filter.Operator + .INCLUDES ) .addValue("string") .build() @@ -398,11 +408,9 @@ internal class CustomerCostListResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -422,11 +430,9 @@ internal class CustomerCostListResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdResponseTest.kt index ab76f0a34..2aa483067 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdResponseTest.kt @@ -25,6 +25,13 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdResponseTest { .creditBlock( AffectedBlock.builder() .id("id") + .addBlockFilter( + AffectedBlock.BlockFilter.builder() + .field(AffectedBlock.BlockFilter.Field.PRICE_ID) + .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() @@ -121,9 +128,9 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -155,9 +162,15 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdResponseTest { .amount("amount") .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + MonetaryUsageDiscountAdjustment.Filter.builder() + .field( + MonetaryUsageDiscountAdjustment.Filter.Field + .PRICE_ID + ) + .operator( + MonetaryUsageDiscountAdjustment.Filter.Operator + .INCLUDES + ) .addValue("string") .build() ) @@ -176,9 +189,11 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator( + PercentageDiscount.Filter.Operator.INCLUDES + ) .addValue("string") .build() ) @@ -192,9 +207,9 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -206,9 +221,9 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -235,9 +250,14 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdResponseTest { .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Price.Unit.CompositePriceFilter.builder() + .field( + Price.Unit.CompositePriceFilter.Field.PRICE_ID + ) + .operator( + Price.Unit.CompositePriceFilter.Operator + .INCLUDES + ) .addValue("string") .build() ) @@ -272,10 +292,13 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) + PercentageDiscount.Filter.builder() + .field( + PercentageDiscount.Filter.Field.PRICE_ID + ) .operator( - TransformPriceFilter.Operator.INCLUDES + PercentageDiscount.Filter.Operator + .INCLUDES ) .addValue("string") .build() @@ -298,11 +321,9 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -322,11 +343,9 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -388,9 +407,9 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -408,9 +427,9 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -481,6 +500,13 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdResponseTest { .creditBlock( AffectedBlock.builder() .id("id") + .addBlockFilter( + AffectedBlock.BlockFilter.builder() + .field(AffectedBlock.BlockFilter.Field.PRICE_ID) + .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() @@ -577,9 +603,9 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -611,10 +637,15 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdResponseTest { .amount("amount") .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) + MonetaryUsageDiscountAdjustment.Filter.builder() + .field( + MonetaryUsageDiscountAdjustment.Filter.Field + .PRICE_ID + ) .operator( - TransformPriceFilter.Operator.INCLUDES + MonetaryUsageDiscountAdjustment.Filter + .Operator + .INCLUDES ) .addValue("string") .build() @@ -636,10 +667,10 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) .operator( - TransformPriceFilter.Operator.INCLUDES + PercentageDiscount.Filter.Operator.INCLUDES ) .addValue("string") .build() @@ -654,11 +685,9 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -670,11 +699,9 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -701,10 +728,14 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdResponseTest { .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) + Price.Unit.CompositePriceFilter.builder() + .field( + Price.Unit.CompositePriceFilter.Field + .PRICE_ID + ) .operator( - TransformPriceFilter.Operator.INCLUDES + Price.Unit.CompositePriceFilter.Operator + .INCLUDES ) .addValue("string") .build() @@ -742,12 +773,13 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() + PercentageDiscount.Filter.builder() .field( - TransformPriceFilter.Field.PRICE_ID + PercentageDiscount.Filter.Field + .PRICE_ID ) .operator( - TransformPriceFilter.Operator + PercentageDiscount.Filter.Operator .INCLUDES ) .addValue("string") @@ -771,13 +803,10 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field( - TransformPriceFilter.Field.PRICE_ID - ) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) .operator( - TransformPriceFilter.Operator - .INCLUDES + Maximum.Filter.Operator.INCLUDES ) .addValue("string") .build() @@ -798,13 +827,10 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field( - TransformPriceFilter.Field.PRICE_ID - ) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) .operator( - TransformPriceFilter.Operator - .INCLUDES + Minimum.Filter.Operator.INCLUDES ) .addValue("string") .build() @@ -869,9 +895,9 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -889,9 +915,9 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -960,6 +986,13 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdResponseTest { .creditBlock( AffectedBlock.builder() .id("id") + .addBlockFilter( + AffectedBlock.BlockFilter.builder() + .field(AffectedBlock.BlockFilter.Field.PRICE_ID) + .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() @@ -1012,6 +1045,13 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdResponseTest { .creditBlock( AffectedBlock.builder() .id("id") + .addBlockFilter( + AffectedBlock.BlockFilter.builder() + .field(AffectedBlock.BlockFilter.Field.PRICE_ID) + .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() @@ -1060,6 +1100,13 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdResponseTest { .creditBlock( AffectedBlock.builder() .id("id") + .addBlockFilter( + AffectedBlock.BlockFilter.builder() + .field(AffectedBlock.BlockFilter.Field.PRICE_ID) + .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() @@ -1110,6 +1157,13 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdResponseTest { .creditBlock( AffectedBlock.builder() .id("id") + .addBlockFilter( + AffectedBlock.BlockFilter.builder() + .field(AffectedBlock.BlockFilter.Field.PRICE_ID) + .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() @@ -1156,6 +1210,13 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdResponseTest { .creditBlock( AffectedBlock.builder() .id("id") + .addBlockFilter( + AffectedBlock.BlockFilter.builder() + .field(AffectedBlock.BlockFilter.Field.PRICE_ID) + .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() @@ -1207,6 +1268,13 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdResponseTest { .creditBlock( AffectedBlock.builder() .id("id") + .addBlockFilter( + AffectedBlock.BlockFilter.builder() + .field(AffectedBlock.BlockFilter.Field.PRICE_ID) + .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() @@ -1252,6 +1320,13 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdResponseTest { .creditBlock( AffectedBlock.builder() .id("id") + .addBlockFilter( + AffectedBlock.BlockFilter.builder() + .field(AffectedBlock.BlockFilter.Field.PRICE_ID) + .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() @@ -1302,6 +1377,13 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdResponseTest { .creditBlock( AffectedBlock.builder() .id("id") + .addBlockFilter( + AffectedBlock.BlockFilter.builder() + .field(AffectedBlock.BlockFilter.Field.PRICE_ID) + .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() @@ -1349,6 +1431,13 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdResponseTest { .creditBlock( AffectedBlock.builder() .id("id") + .addBlockFilter( + AffectedBlock.BlockFilter.builder() + .field(AffectedBlock.BlockFilter.Field.PRICE_ID) + .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() @@ -1401,6 +1490,13 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdResponseTest { .creditBlock( AffectedBlock.builder() .id("id") + .addBlockFilter( + AffectedBlock.BlockFilter.builder() + .field(AffectedBlock.BlockFilter.Field.PRICE_ID) + .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() @@ -1449,6 +1545,13 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdResponseTest { .creditBlock( AffectedBlock.builder() .id("id") + .addBlockFilter( + AffectedBlock.BlockFilter.builder() + .field(AffectedBlock.BlockFilter.Field.PRICE_ID) + .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() @@ -1498,6 +1601,13 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdResponseTest { .creditBlock( AffectedBlock.builder() .id("id") + .addBlockFilter( + AffectedBlock.BlockFilter.builder() + .field(AffectedBlock.BlockFilter.Field.PRICE_ID) + .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryResponseTest.kt index 5099bf445..41bb72d62 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryResponseTest.kt @@ -25,6 +25,13 @@ internal class CustomerCreditLedgerCreateEntryResponseTest { .creditBlock( AffectedBlock.builder() .id("id") + .addBlockFilter( + AffectedBlock.BlockFilter.builder() + .field(AffectedBlock.BlockFilter.Field.PRICE_ID) + .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() @@ -121,9 +128,9 @@ internal class CustomerCreditLedgerCreateEntryResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -155,9 +162,15 @@ internal class CustomerCreditLedgerCreateEntryResponseTest { .amount("amount") .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + MonetaryUsageDiscountAdjustment.Filter.builder() + .field( + MonetaryUsageDiscountAdjustment.Filter.Field + .PRICE_ID + ) + .operator( + MonetaryUsageDiscountAdjustment.Filter.Operator + .INCLUDES + ) .addValue("string") .build() ) @@ -176,9 +189,11 @@ internal class CustomerCreditLedgerCreateEntryResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator( + PercentageDiscount.Filter.Operator.INCLUDES + ) .addValue("string") .build() ) @@ -192,9 +207,9 @@ internal class CustomerCreditLedgerCreateEntryResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -206,9 +221,9 @@ internal class CustomerCreditLedgerCreateEntryResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -235,9 +250,14 @@ internal class CustomerCreditLedgerCreateEntryResponseTest { .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Price.Unit.CompositePriceFilter.builder() + .field( + Price.Unit.CompositePriceFilter.Field.PRICE_ID + ) + .operator( + Price.Unit.CompositePriceFilter.Operator + .INCLUDES + ) .addValue("string") .build() ) @@ -272,10 +292,13 @@ internal class CustomerCreditLedgerCreateEntryResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) + PercentageDiscount.Filter.builder() + .field( + PercentageDiscount.Filter.Field.PRICE_ID + ) .operator( - TransformPriceFilter.Operator.INCLUDES + PercentageDiscount.Filter.Operator + .INCLUDES ) .addValue("string") .build() @@ -298,11 +321,9 @@ internal class CustomerCreditLedgerCreateEntryResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -322,11 +343,9 @@ internal class CustomerCreditLedgerCreateEntryResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -388,9 +407,9 @@ internal class CustomerCreditLedgerCreateEntryResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -408,9 +427,9 @@ internal class CustomerCreditLedgerCreateEntryResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -480,6 +499,13 @@ internal class CustomerCreditLedgerCreateEntryResponseTest { .creditBlock( AffectedBlock.builder() .id("id") + .addBlockFilter( + AffectedBlock.BlockFilter.builder() + .field(AffectedBlock.BlockFilter.Field.PRICE_ID) + .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() @@ -576,9 +602,9 @@ internal class CustomerCreditLedgerCreateEntryResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -610,10 +636,15 @@ internal class CustomerCreditLedgerCreateEntryResponseTest { .amount("amount") .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) + MonetaryUsageDiscountAdjustment.Filter.builder() + .field( + MonetaryUsageDiscountAdjustment.Filter.Field + .PRICE_ID + ) .operator( - TransformPriceFilter.Operator.INCLUDES + MonetaryUsageDiscountAdjustment.Filter + .Operator + .INCLUDES ) .addValue("string") .build() @@ -635,10 +666,10 @@ internal class CustomerCreditLedgerCreateEntryResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) .operator( - TransformPriceFilter.Operator.INCLUDES + PercentageDiscount.Filter.Operator.INCLUDES ) .addValue("string") .build() @@ -653,11 +684,9 @@ internal class CustomerCreditLedgerCreateEntryResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -669,11 +698,9 @@ internal class CustomerCreditLedgerCreateEntryResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -700,10 +727,14 @@ internal class CustomerCreditLedgerCreateEntryResponseTest { .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) + Price.Unit.CompositePriceFilter.builder() + .field( + Price.Unit.CompositePriceFilter.Field + .PRICE_ID + ) .operator( - TransformPriceFilter.Operator.INCLUDES + Price.Unit.CompositePriceFilter.Operator + .INCLUDES ) .addValue("string") .build() @@ -741,12 +772,13 @@ internal class CustomerCreditLedgerCreateEntryResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() + PercentageDiscount.Filter.builder() .field( - TransformPriceFilter.Field.PRICE_ID + PercentageDiscount.Filter.Field + .PRICE_ID ) .operator( - TransformPriceFilter.Operator + PercentageDiscount.Filter.Operator .INCLUDES ) .addValue("string") @@ -770,13 +802,10 @@ internal class CustomerCreditLedgerCreateEntryResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field( - TransformPriceFilter.Field.PRICE_ID - ) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) .operator( - TransformPriceFilter.Operator - .INCLUDES + Maximum.Filter.Operator.INCLUDES ) .addValue("string") .build() @@ -797,13 +826,10 @@ internal class CustomerCreditLedgerCreateEntryResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field( - TransformPriceFilter.Field.PRICE_ID - ) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) .operator( - TransformPriceFilter.Operator - .INCLUDES + Minimum.Filter.Operator.INCLUDES ) .addValue("string") .build() @@ -868,9 +894,9 @@ internal class CustomerCreditLedgerCreateEntryResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -888,9 +914,9 @@ internal class CustomerCreditLedgerCreateEntryResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -959,6 +985,13 @@ internal class CustomerCreditLedgerCreateEntryResponseTest { .creditBlock( AffectedBlock.builder() .id("id") + .addBlockFilter( + AffectedBlock.BlockFilter.builder() + .field(AffectedBlock.BlockFilter.Field.PRICE_ID) + .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() @@ -1010,6 +1043,13 @@ internal class CustomerCreditLedgerCreateEntryResponseTest { .creditBlock( AffectedBlock.builder() .id("id") + .addBlockFilter( + AffectedBlock.BlockFilter.builder() + .field(AffectedBlock.BlockFilter.Field.PRICE_ID) + .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() @@ -1058,6 +1098,13 @@ internal class CustomerCreditLedgerCreateEntryResponseTest { .creditBlock( AffectedBlock.builder() .id("id") + .addBlockFilter( + AffectedBlock.BlockFilter.builder() + .field(AffectedBlock.BlockFilter.Field.PRICE_ID) + .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() @@ -1108,6 +1155,13 @@ internal class CustomerCreditLedgerCreateEntryResponseTest { .creditBlock( AffectedBlock.builder() .id("id") + .addBlockFilter( + AffectedBlock.BlockFilter.builder() + .field(AffectedBlock.BlockFilter.Field.PRICE_ID) + .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() @@ -1154,6 +1208,13 @@ internal class CustomerCreditLedgerCreateEntryResponseTest { .creditBlock( AffectedBlock.builder() .id("id") + .addBlockFilter( + AffectedBlock.BlockFilter.builder() + .field(AffectedBlock.BlockFilter.Field.PRICE_ID) + .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() @@ -1203,6 +1264,13 @@ internal class CustomerCreditLedgerCreateEntryResponseTest { .creditBlock( AffectedBlock.builder() .id("id") + .addBlockFilter( + AffectedBlock.BlockFilter.builder() + .field(AffectedBlock.BlockFilter.Field.PRICE_ID) + .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() @@ -1248,6 +1316,13 @@ internal class CustomerCreditLedgerCreateEntryResponseTest { .creditBlock( AffectedBlock.builder() .id("id") + .addBlockFilter( + AffectedBlock.BlockFilter.builder() + .field(AffectedBlock.BlockFilter.Field.PRICE_ID) + .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() @@ -1298,6 +1373,13 @@ internal class CustomerCreditLedgerCreateEntryResponseTest { .creditBlock( AffectedBlock.builder() .id("id") + .addBlockFilter( + AffectedBlock.BlockFilter.builder() + .field(AffectedBlock.BlockFilter.Field.PRICE_ID) + .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() @@ -1345,6 +1427,13 @@ internal class CustomerCreditLedgerCreateEntryResponseTest { .creditBlock( AffectedBlock.builder() .id("id") + .addBlockFilter( + AffectedBlock.BlockFilter.builder() + .field(AffectedBlock.BlockFilter.Field.PRICE_ID) + .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() @@ -1396,6 +1485,13 @@ internal class CustomerCreditLedgerCreateEntryResponseTest { .creditBlock( AffectedBlock.builder() .id("id") + .addBlockFilter( + AffectedBlock.BlockFilter.builder() + .field(AffectedBlock.BlockFilter.Field.PRICE_ID) + .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() @@ -1444,6 +1540,13 @@ internal class CustomerCreditLedgerCreateEntryResponseTest { .creditBlock( AffectedBlock.builder() .id("id") + .addBlockFilter( + AffectedBlock.BlockFilter.builder() + .field(AffectedBlock.BlockFilter.Field.PRICE_ID) + .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() @@ -1492,6 +1595,13 @@ internal class CustomerCreditLedgerCreateEntryResponseTest { .creditBlock( AffectedBlock.builder() .id("id") + .addBlockFilter( + AffectedBlock.BlockFilter.builder() + .field(AffectedBlock.BlockFilter.Field.PRICE_ID) + .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdPageResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdPageResponseTest.kt index 98d0f59b4..3f6ff44c1 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdPageResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdPageResponseTest.kt @@ -23,6 +23,13 @@ internal class CustomerCreditLedgerListByExternalIdPageResponseTest { .creditBlock( AffectedBlock.builder() .id("id") + .addBlockFilter( + AffectedBlock.BlockFilter.builder() + .field(AffectedBlock.BlockFilter.Field.PRICE_ID) + .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() @@ -126,9 +133,11 @@ internal class CustomerCreditLedgerListByExternalIdPageResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator( + PercentageDiscount.Filter.Operator.INCLUDES + ) .addValue("string") .build() ) @@ -160,10 +169,16 @@ internal class CustomerCreditLedgerListByExternalIdPageResponseTest { .amount("amount") .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) + MonetaryUsageDiscountAdjustment.Filter.builder() + .field( + MonetaryUsageDiscountAdjustment.Filter + .Field + .PRICE_ID + ) .operator( - TransformPriceFilter.Operator.INCLUDES + MonetaryUsageDiscountAdjustment.Filter + .Operator + .INCLUDES ) .addValue("string") .build() @@ -185,10 +200,13 @@ internal class CustomerCreditLedgerListByExternalIdPageResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) + PercentageDiscount.Filter.builder() + .field( + PercentageDiscount.Filter.Field.PRICE_ID + ) .operator( - TransformPriceFilter.Operator.INCLUDES + PercentageDiscount.Filter.Operator + .INCLUDES ) .addValue("string") .build() @@ -203,11 +221,9 @@ internal class CustomerCreditLedgerListByExternalIdPageResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -219,11 +235,9 @@ internal class CustomerCreditLedgerListByExternalIdPageResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -251,10 +265,14 @@ internal class CustomerCreditLedgerListByExternalIdPageResponseTest { .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) + Price.Unit.CompositePriceFilter.builder() + .field( + Price.Unit.CompositePriceFilter.Field + .PRICE_ID + ) .operator( - TransformPriceFilter.Operator.INCLUDES + Price.Unit.CompositePriceFilter.Operator + .INCLUDES ) .addValue("string") .build() @@ -294,13 +312,14 @@ internal class CustomerCreditLedgerListByExternalIdPageResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() + PercentageDiscount.Filter.builder() .field( - TransformPriceFilter.Field + PercentageDiscount.Filter.Field .PRICE_ID ) .operator( - TransformPriceFilter.Operator + PercentageDiscount.Filter + .Operator .INCLUDES ) .addValue("string") @@ -327,14 +346,12 @@ internal class CustomerCreditLedgerListByExternalIdPageResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() + Maximum.Filter.builder() .field( - TransformPriceFilter.Field - .PRICE_ID + Maximum.Filter.Field.PRICE_ID ) .operator( - TransformPriceFilter.Operator - .INCLUDES + Maximum.Filter.Operator.INCLUDES ) .addValue("string") .build() @@ -355,14 +372,12 @@ internal class CustomerCreditLedgerListByExternalIdPageResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() + Minimum.Filter.builder() .field( - TransformPriceFilter.Field - .PRICE_ID + Minimum.Filter.Field.PRICE_ID ) .operator( - TransformPriceFilter.Operator - .INCLUDES + Minimum.Filter.Operator.INCLUDES ) .addValue("string") .build() @@ -429,9 +444,9 @@ internal class CustomerCreditLedgerListByExternalIdPageResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -449,9 +464,9 @@ internal class CustomerCreditLedgerListByExternalIdPageResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -516,6 +531,13 @@ internal class CustomerCreditLedgerListByExternalIdPageResponseTest { .creditBlock( AffectedBlock.builder() .id("id") + .addBlockFilter( + AffectedBlock.BlockFilter.builder() + .field(AffectedBlock.BlockFilter.Field.PRICE_ID) + .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() @@ -619,9 +641,11 @@ internal class CustomerCreditLedgerListByExternalIdPageResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator( + PercentageDiscount.Filter.Operator.INCLUDES + ) .addValue("string") .build() ) @@ -653,10 +677,16 @@ internal class CustomerCreditLedgerListByExternalIdPageResponseTest { .amount("amount") .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) + MonetaryUsageDiscountAdjustment.Filter.builder() + .field( + MonetaryUsageDiscountAdjustment.Filter + .Field + .PRICE_ID + ) .operator( - TransformPriceFilter.Operator.INCLUDES + MonetaryUsageDiscountAdjustment.Filter + .Operator + .INCLUDES ) .addValue("string") .build() @@ -678,10 +708,13 @@ internal class CustomerCreditLedgerListByExternalIdPageResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) + PercentageDiscount.Filter.builder() + .field( + PercentageDiscount.Filter.Field.PRICE_ID + ) .operator( - TransformPriceFilter.Operator.INCLUDES + PercentageDiscount.Filter.Operator + .INCLUDES ) .addValue("string") .build() @@ -696,11 +729,9 @@ internal class CustomerCreditLedgerListByExternalIdPageResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -712,11 +743,9 @@ internal class CustomerCreditLedgerListByExternalIdPageResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -744,10 +773,14 @@ internal class CustomerCreditLedgerListByExternalIdPageResponseTest { .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) + Price.Unit.CompositePriceFilter.builder() + .field( + Price.Unit.CompositePriceFilter.Field + .PRICE_ID + ) .operator( - TransformPriceFilter.Operator.INCLUDES + Price.Unit.CompositePriceFilter.Operator + .INCLUDES ) .addValue("string") .build() @@ -787,13 +820,14 @@ internal class CustomerCreditLedgerListByExternalIdPageResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() + PercentageDiscount.Filter.builder() .field( - TransformPriceFilter.Field + PercentageDiscount.Filter.Field .PRICE_ID ) .operator( - TransformPriceFilter.Operator + PercentageDiscount.Filter + .Operator .INCLUDES ) .addValue("string") @@ -820,14 +854,12 @@ internal class CustomerCreditLedgerListByExternalIdPageResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() + Maximum.Filter.builder() .field( - TransformPriceFilter.Field - .PRICE_ID + Maximum.Filter.Field.PRICE_ID ) .operator( - TransformPriceFilter.Operator - .INCLUDES + Maximum.Filter.Operator.INCLUDES ) .addValue("string") .build() @@ -848,14 +880,12 @@ internal class CustomerCreditLedgerListByExternalIdPageResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() + Minimum.Filter.builder() .field( - TransformPriceFilter.Field - .PRICE_ID + Minimum.Filter.Field.PRICE_ID ) .operator( - TransformPriceFilter.Operator - .INCLUDES + Minimum.Filter.Operator.INCLUDES ) .addValue("string") .build() @@ -922,9 +952,9 @@ internal class CustomerCreditLedgerListByExternalIdPageResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -942,9 +972,9 @@ internal class CustomerCreditLedgerListByExternalIdPageResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -1012,6 +1042,13 @@ internal class CustomerCreditLedgerListByExternalIdPageResponseTest { .creditBlock( AffectedBlock.builder() .id("id") + .addBlockFilter( + AffectedBlock.BlockFilter.builder() + .field(AffectedBlock.BlockFilter.Field.PRICE_ID) + .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() @@ -1115,9 +1152,11 @@ internal class CustomerCreditLedgerListByExternalIdPageResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator( + PercentageDiscount.Filter.Operator.INCLUDES + ) .addValue("string") .build() ) @@ -1149,10 +1188,16 @@ internal class CustomerCreditLedgerListByExternalIdPageResponseTest { .amount("amount") .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) + MonetaryUsageDiscountAdjustment.Filter.builder() + .field( + MonetaryUsageDiscountAdjustment.Filter + .Field + .PRICE_ID + ) .operator( - TransformPriceFilter.Operator.INCLUDES + MonetaryUsageDiscountAdjustment.Filter + .Operator + .INCLUDES ) .addValue("string") .build() @@ -1174,10 +1219,13 @@ internal class CustomerCreditLedgerListByExternalIdPageResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) + PercentageDiscount.Filter.builder() + .field( + PercentageDiscount.Filter.Field.PRICE_ID + ) .operator( - TransformPriceFilter.Operator.INCLUDES + PercentageDiscount.Filter.Operator + .INCLUDES ) .addValue("string") .build() @@ -1192,11 +1240,9 @@ internal class CustomerCreditLedgerListByExternalIdPageResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -1208,11 +1254,9 @@ internal class CustomerCreditLedgerListByExternalIdPageResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -1240,10 +1284,14 @@ internal class CustomerCreditLedgerListByExternalIdPageResponseTest { .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) + Price.Unit.CompositePriceFilter.builder() + .field( + Price.Unit.CompositePriceFilter.Field + .PRICE_ID + ) .operator( - TransformPriceFilter.Operator.INCLUDES + Price.Unit.CompositePriceFilter.Operator + .INCLUDES ) .addValue("string") .build() @@ -1283,13 +1331,14 @@ internal class CustomerCreditLedgerListByExternalIdPageResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() + PercentageDiscount.Filter.builder() .field( - TransformPriceFilter.Field + PercentageDiscount.Filter.Field .PRICE_ID ) .operator( - TransformPriceFilter.Operator + PercentageDiscount.Filter + .Operator .INCLUDES ) .addValue("string") @@ -1316,14 +1365,12 @@ internal class CustomerCreditLedgerListByExternalIdPageResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() + Maximum.Filter.builder() .field( - TransformPriceFilter.Field - .PRICE_ID + Maximum.Filter.Field.PRICE_ID ) .operator( - TransformPriceFilter.Operator - .INCLUDES + Maximum.Filter.Operator.INCLUDES ) .addValue("string") .build() @@ -1344,14 +1391,12 @@ internal class CustomerCreditLedgerListByExternalIdPageResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() + Minimum.Filter.builder() .field( - TransformPriceFilter.Field - .PRICE_ID + Minimum.Filter.Field.PRICE_ID ) .operator( - TransformPriceFilter.Operator - .INCLUDES + Minimum.Filter.Operator.INCLUDES ) .addValue("string") .build() @@ -1418,9 +1463,9 @@ internal class CustomerCreditLedgerListByExternalIdPageResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -1438,9 +1483,9 @@ internal class CustomerCreditLedgerListByExternalIdPageResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdResponseTest.kt index 6c3341fdc..3e4db0590 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdResponseTest.kt @@ -25,6 +25,13 @@ internal class CustomerCreditLedgerListByExternalIdResponseTest { .creditBlock( AffectedBlock.builder() .id("id") + .addBlockFilter( + AffectedBlock.BlockFilter.builder() + .field(AffectedBlock.BlockFilter.Field.PRICE_ID) + .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() @@ -121,9 +128,9 @@ internal class CustomerCreditLedgerListByExternalIdResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -155,9 +162,15 @@ internal class CustomerCreditLedgerListByExternalIdResponseTest { .amount("amount") .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + MonetaryUsageDiscountAdjustment.Filter.builder() + .field( + MonetaryUsageDiscountAdjustment.Filter.Field + .PRICE_ID + ) + .operator( + MonetaryUsageDiscountAdjustment.Filter.Operator + .INCLUDES + ) .addValue("string") .build() ) @@ -176,9 +189,11 @@ internal class CustomerCreditLedgerListByExternalIdResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator( + PercentageDiscount.Filter.Operator.INCLUDES + ) .addValue("string") .build() ) @@ -192,9 +207,9 @@ internal class CustomerCreditLedgerListByExternalIdResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -206,9 +221,9 @@ internal class CustomerCreditLedgerListByExternalIdResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -235,9 +250,14 @@ internal class CustomerCreditLedgerListByExternalIdResponseTest { .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Price.Unit.CompositePriceFilter.builder() + .field( + Price.Unit.CompositePriceFilter.Field.PRICE_ID + ) + .operator( + Price.Unit.CompositePriceFilter.Operator + .INCLUDES + ) .addValue("string") .build() ) @@ -272,10 +292,13 @@ internal class CustomerCreditLedgerListByExternalIdResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) + PercentageDiscount.Filter.builder() + .field( + PercentageDiscount.Filter.Field.PRICE_ID + ) .operator( - TransformPriceFilter.Operator.INCLUDES + PercentageDiscount.Filter.Operator + .INCLUDES ) .addValue("string") .build() @@ -298,11 +321,9 @@ internal class CustomerCreditLedgerListByExternalIdResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -322,11 +343,9 @@ internal class CustomerCreditLedgerListByExternalIdResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -388,9 +407,9 @@ internal class CustomerCreditLedgerListByExternalIdResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -408,9 +427,9 @@ internal class CustomerCreditLedgerListByExternalIdResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -480,6 +499,13 @@ internal class CustomerCreditLedgerListByExternalIdResponseTest { .creditBlock( AffectedBlock.builder() .id("id") + .addBlockFilter( + AffectedBlock.BlockFilter.builder() + .field(AffectedBlock.BlockFilter.Field.PRICE_ID) + .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() @@ -576,9 +602,9 @@ internal class CustomerCreditLedgerListByExternalIdResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -610,10 +636,15 @@ internal class CustomerCreditLedgerListByExternalIdResponseTest { .amount("amount") .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) + MonetaryUsageDiscountAdjustment.Filter.builder() + .field( + MonetaryUsageDiscountAdjustment.Filter.Field + .PRICE_ID + ) .operator( - TransformPriceFilter.Operator.INCLUDES + MonetaryUsageDiscountAdjustment.Filter + .Operator + .INCLUDES ) .addValue("string") .build() @@ -635,10 +666,10 @@ internal class CustomerCreditLedgerListByExternalIdResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) .operator( - TransformPriceFilter.Operator.INCLUDES + PercentageDiscount.Filter.Operator.INCLUDES ) .addValue("string") .build() @@ -653,11 +684,9 @@ internal class CustomerCreditLedgerListByExternalIdResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -669,11 +698,9 @@ internal class CustomerCreditLedgerListByExternalIdResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -700,10 +727,14 @@ internal class CustomerCreditLedgerListByExternalIdResponseTest { .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) + Price.Unit.CompositePriceFilter.builder() + .field( + Price.Unit.CompositePriceFilter.Field + .PRICE_ID + ) .operator( - TransformPriceFilter.Operator.INCLUDES + Price.Unit.CompositePriceFilter.Operator + .INCLUDES ) .addValue("string") .build() @@ -741,12 +772,13 @@ internal class CustomerCreditLedgerListByExternalIdResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() + PercentageDiscount.Filter.builder() .field( - TransformPriceFilter.Field.PRICE_ID + PercentageDiscount.Filter.Field + .PRICE_ID ) .operator( - TransformPriceFilter.Operator + PercentageDiscount.Filter.Operator .INCLUDES ) .addValue("string") @@ -770,13 +802,10 @@ internal class CustomerCreditLedgerListByExternalIdResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field( - TransformPriceFilter.Field.PRICE_ID - ) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) .operator( - TransformPriceFilter.Operator - .INCLUDES + Maximum.Filter.Operator.INCLUDES ) .addValue("string") .build() @@ -797,13 +826,10 @@ internal class CustomerCreditLedgerListByExternalIdResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field( - TransformPriceFilter.Field.PRICE_ID - ) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) .operator( - TransformPriceFilter.Operator - .INCLUDES + Minimum.Filter.Operator.INCLUDES ) .addValue("string") .build() @@ -868,9 +894,9 @@ internal class CustomerCreditLedgerListByExternalIdResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -888,9 +914,9 @@ internal class CustomerCreditLedgerListByExternalIdResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -959,6 +985,13 @@ internal class CustomerCreditLedgerListByExternalIdResponseTest { .creditBlock( AffectedBlock.builder() .id("id") + .addBlockFilter( + AffectedBlock.BlockFilter.builder() + .field(AffectedBlock.BlockFilter.Field.PRICE_ID) + .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() @@ -1010,6 +1043,13 @@ internal class CustomerCreditLedgerListByExternalIdResponseTest { .creditBlock( AffectedBlock.builder() .id("id") + .addBlockFilter( + AffectedBlock.BlockFilter.builder() + .field(AffectedBlock.BlockFilter.Field.PRICE_ID) + .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() @@ -1058,6 +1098,13 @@ internal class CustomerCreditLedgerListByExternalIdResponseTest { .creditBlock( AffectedBlock.builder() .id("id") + .addBlockFilter( + AffectedBlock.BlockFilter.builder() + .field(AffectedBlock.BlockFilter.Field.PRICE_ID) + .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() @@ -1108,6 +1155,13 @@ internal class CustomerCreditLedgerListByExternalIdResponseTest { .creditBlock( AffectedBlock.builder() .id("id") + .addBlockFilter( + AffectedBlock.BlockFilter.builder() + .field(AffectedBlock.BlockFilter.Field.PRICE_ID) + .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() @@ -1154,6 +1208,13 @@ internal class CustomerCreditLedgerListByExternalIdResponseTest { .creditBlock( AffectedBlock.builder() .id("id") + .addBlockFilter( + AffectedBlock.BlockFilter.builder() + .field(AffectedBlock.BlockFilter.Field.PRICE_ID) + .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() @@ -1203,6 +1264,13 @@ internal class CustomerCreditLedgerListByExternalIdResponseTest { .creditBlock( AffectedBlock.builder() .id("id") + .addBlockFilter( + AffectedBlock.BlockFilter.builder() + .field(AffectedBlock.BlockFilter.Field.PRICE_ID) + .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() @@ -1248,6 +1316,13 @@ internal class CustomerCreditLedgerListByExternalIdResponseTest { .creditBlock( AffectedBlock.builder() .id("id") + .addBlockFilter( + AffectedBlock.BlockFilter.builder() + .field(AffectedBlock.BlockFilter.Field.PRICE_ID) + .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() @@ -1298,6 +1373,13 @@ internal class CustomerCreditLedgerListByExternalIdResponseTest { .creditBlock( AffectedBlock.builder() .id("id") + .addBlockFilter( + AffectedBlock.BlockFilter.builder() + .field(AffectedBlock.BlockFilter.Field.PRICE_ID) + .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() @@ -1345,6 +1427,13 @@ internal class CustomerCreditLedgerListByExternalIdResponseTest { .creditBlock( AffectedBlock.builder() .id("id") + .addBlockFilter( + AffectedBlock.BlockFilter.builder() + .field(AffectedBlock.BlockFilter.Field.PRICE_ID) + .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() @@ -1397,6 +1486,13 @@ internal class CustomerCreditLedgerListByExternalIdResponseTest { .creditBlock( AffectedBlock.builder() .id("id") + .addBlockFilter( + AffectedBlock.BlockFilter.builder() + .field(AffectedBlock.BlockFilter.Field.PRICE_ID) + .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() @@ -1445,6 +1541,13 @@ internal class CustomerCreditLedgerListByExternalIdResponseTest { .creditBlock( AffectedBlock.builder() .id("id") + .addBlockFilter( + AffectedBlock.BlockFilter.builder() + .field(AffectedBlock.BlockFilter.Field.PRICE_ID) + .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() @@ -1493,6 +1596,13 @@ internal class CustomerCreditLedgerListByExternalIdResponseTest { .creditBlock( AffectedBlock.builder() .id("id") + .addBlockFilter( + AffectedBlock.BlockFilter.builder() + .field(AffectedBlock.BlockFilter.Field.PRICE_ID) + .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListPageResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListPageResponseTest.kt index ed59e99ea..bc73ba6d9 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListPageResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListPageResponseTest.kt @@ -23,6 +23,13 @@ internal class CustomerCreditLedgerListPageResponseTest { .creditBlock( AffectedBlock.builder() .id("id") + .addBlockFilter( + AffectedBlock.BlockFilter.builder() + .field(AffectedBlock.BlockFilter.Field.PRICE_ID) + .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() @@ -126,9 +133,11 @@ internal class CustomerCreditLedgerListPageResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator( + PercentageDiscount.Filter.Operator.INCLUDES + ) .addValue("string") .build() ) @@ -160,10 +169,16 @@ internal class CustomerCreditLedgerListPageResponseTest { .amount("amount") .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) + MonetaryUsageDiscountAdjustment.Filter.builder() + .field( + MonetaryUsageDiscountAdjustment.Filter + .Field + .PRICE_ID + ) .operator( - TransformPriceFilter.Operator.INCLUDES + MonetaryUsageDiscountAdjustment.Filter + .Operator + .INCLUDES ) .addValue("string") .build() @@ -185,10 +200,13 @@ internal class CustomerCreditLedgerListPageResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) + PercentageDiscount.Filter.builder() + .field( + PercentageDiscount.Filter.Field.PRICE_ID + ) .operator( - TransformPriceFilter.Operator.INCLUDES + PercentageDiscount.Filter.Operator + .INCLUDES ) .addValue("string") .build() @@ -203,11 +221,9 @@ internal class CustomerCreditLedgerListPageResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -219,11 +235,9 @@ internal class CustomerCreditLedgerListPageResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -251,10 +265,14 @@ internal class CustomerCreditLedgerListPageResponseTest { .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) + Price.Unit.CompositePriceFilter.builder() + .field( + Price.Unit.CompositePriceFilter.Field + .PRICE_ID + ) .operator( - TransformPriceFilter.Operator.INCLUDES + Price.Unit.CompositePriceFilter.Operator + .INCLUDES ) .addValue("string") .build() @@ -294,13 +312,14 @@ internal class CustomerCreditLedgerListPageResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() + PercentageDiscount.Filter.builder() .field( - TransformPriceFilter.Field + PercentageDiscount.Filter.Field .PRICE_ID ) .operator( - TransformPriceFilter.Operator + PercentageDiscount.Filter + .Operator .INCLUDES ) .addValue("string") @@ -327,14 +346,12 @@ internal class CustomerCreditLedgerListPageResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() + Maximum.Filter.builder() .field( - TransformPriceFilter.Field - .PRICE_ID + Maximum.Filter.Field.PRICE_ID ) .operator( - TransformPriceFilter.Operator - .INCLUDES + Maximum.Filter.Operator.INCLUDES ) .addValue("string") .build() @@ -355,14 +372,12 @@ internal class CustomerCreditLedgerListPageResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() + Minimum.Filter.builder() .field( - TransformPriceFilter.Field - .PRICE_ID + Minimum.Filter.Field.PRICE_ID ) .operator( - TransformPriceFilter.Operator - .INCLUDES + Minimum.Filter.Operator.INCLUDES ) .addValue("string") .build() @@ -429,9 +444,9 @@ internal class CustomerCreditLedgerListPageResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -449,9 +464,9 @@ internal class CustomerCreditLedgerListPageResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -516,6 +531,13 @@ internal class CustomerCreditLedgerListPageResponseTest { .creditBlock( AffectedBlock.builder() .id("id") + .addBlockFilter( + AffectedBlock.BlockFilter.builder() + .field(AffectedBlock.BlockFilter.Field.PRICE_ID) + .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() @@ -619,9 +641,11 @@ internal class CustomerCreditLedgerListPageResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator( + PercentageDiscount.Filter.Operator.INCLUDES + ) .addValue("string") .build() ) @@ -653,10 +677,16 @@ internal class CustomerCreditLedgerListPageResponseTest { .amount("amount") .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) + MonetaryUsageDiscountAdjustment.Filter.builder() + .field( + MonetaryUsageDiscountAdjustment.Filter + .Field + .PRICE_ID + ) .operator( - TransformPriceFilter.Operator.INCLUDES + MonetaryUsageDiscountAdjustment.Filter + .Operator + .INCLUDES ) .addValue("string") .build() @@ -678,10 +708,13 @@ internal class CustomerCreditLedgerListPageResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) + PercentageDiscount.Filter.builder() + .field( + PercentageDiscount.Filter.Field.PRICE_ID + ) .operator( - TransformPriceFilter.Operator.INCLUDES + PercentageDiscount.Filter.Operator + .INCLUDES ) .addValue("string") .build() @@ -696,11 +729,9 @@ internal class CustomerCreditLedgerListPageResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -712,11 +743,9 @@ internal class CustomerCreditLedgerListPageResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -744,10 +773,14 @@ internal class CustomerCreditLedgerListPageResponseTest { .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) + Price.Unit.CompositePriceFilter.builder() + .field( + Price.Unit.CompositePriceFilter.Field + .PRICE_ID + ) .operator( - TransformPriceFilter.Operator.INCLUDES + Price.Unit.CompositePriceFilter.Operator + .INCLUDES ) .addValue("string") .build() @@ -787,13 +820,14 @@ internal class CustomerCreditLedgerListPageResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() + PercentageDiscount.Filter.builder() .field( - TransformPriceFilter.Field + PercentageDiscount.Filter.Field .PRICE_ID ) .operator( - TransformPriceFilter.Operator + PercentageDiscount.Filter + .Operator .INCLUDES ) .addValue("string") @@ -820,14 +854,12 @@ internal class CustomerCreditLedgerListPageResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() + Maximum.Filter.builder() .field( - TransformPriceFilter.Field - .PRICE_ID + Maximum.Filter.Field.PRICE_ID ) .operator( - TransformPriceFilter.Operator - .INCLUDES + Maximum.Filter.Operator.INCLUDES ) .addValue("string") .build() @@ -848,14 +880,12 @@ internal class CustomerCreditLedgerListPageResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() + Minimum.Filter.builder() .field( - TransformPriceFilter.Field - .PRICE_ID + Minimum.Filter.Field.PRICE_ID ) .operator( - TransformPriceFilter.Operator - .INCLUDES + Minimum.Filter.Operator.INCLUDES ) .addValue("string") .build() @@ -922,9 +952,9 @@ internal class CustomerCreditLedgerListPageResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -942,9 +972,9 @@ internal class CustomerCreditLedgerListPageResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -1012,6 +1042,13 @@ internal class CustomerCreditLedgerListPageResponseTest { .creditBlock( AffectedBlock.builder() .id("id") + .addBlockFilter( + AffectedBlock.BlockFilter.builder() + .field(AffectedBlock.BlockFilter.Field.PRICE_ID) + .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() @@ -1115,9 +1152,11 @@ internal class CustomerCreditLedgerListPageResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator( + PercentageDiscount.Filter.Operator.INCLUDES + ) .addValue("string") .build() ) @@ -1149,10 +1188,16 @@ internal class CustomerCreditLedgerListPageResponseTest { .amount("amount") .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) + MonetaryUsageDiscountAdjustment.Filter.builder() + .field( + MonetaryUsageDiscountAdjustment.Filter + .Field + .PRICE_ID + ) .operator( - TransformPriceFilter.Operator.INCLUDES + MonetaryUsageDiscountAdjustment.Filter + .Operator + .INCLUDES ) .addValue("string") .build() @@ -1174,10 +1219,13 @@ internal class CustomerCreditLedgerListPageResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) + PercentageDiscount.Filter.builder() + .field( + PercentageDiscount.Filter.Field.PRICE_ID + ) .operator( - TransformPriceFilter.Operator.INCLUDES + PercentageDiscount.Filter.Operator + .INCLUDES ) .addValue("string") .build() @@ -1192,11 +1240,9 @@ internal class CustomerCreditLedgerListPageResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -1208,11 +1254,9 @@ internal class CustomerCreditLedgerListPageResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -1240,10 +1284,14 @@ internal class CustomerCreditLedgerListPageResponseTest { .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) + Price.Unit.CompositePriceFilter.builder() + .field( + Price.Unit.CompositePriceFilter.Field + .PRICE_ID + ) .operator( - TransformPriceFilter.Operator.INCLUDES + Price.Unit.CompositePriceFilter.Operator + .INCLUDES ) .addValue("string") .build() @@ -1283,13 +1331,14 @@ internal class CustomerCreditLedgerListPageResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() + PercentageDiscount.Filter.builder() .field( - TransformPriceFilter.Field + PercentageDiscount.Filter.Field .PRICE_ID ) .operator( - TransformPriceFilter.Operator + PercentageDiscount.Filter + .Operator .INCLUDES ) .addValue("string") @@ -1316,14 +1365,12 @@ internal class CustomerCreditLedgerListPageResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() + Maximum.Filter.builder() .field( - TransformPriceFilter.Field - .PRICE_ID + Maximum.Filter.Field.PRICE_ID ) .operator( - TransformPriceFilter.Operator - .INCLUDES + Maximum.Filter.Operator.INCLUDES ) .addValue("string") .build() @@ -1344,14 +1391,12 @@ internal class CustomerCreditLedgerListPageResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() + Minimum.Filter.builder() .field( - TransformPriceFilter.Field - .PRICE_ID + Minimum.Filter.Field.PRICE_ID ) .operator( - TransformPriceFilter.Operator - .INCLUDES + Minimum.Filter.Operator.INCLUDES ) .addValue("string") .build() @@ -1418,9 +1463,9 @@ internal class CustomerCreditLedgerListPageResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -1438,9 +1483,9 @@ internal class CustomerCreditLedgerListPageResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListResponseTest.kt index 650235b26..b9accfb05 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListResponseTest.kt @@ -25,6 +25,13 @@ internal class CustomerCreditLedgerListResponseTest { .creditBlock( AffectedBlock.builder() .id("id") + .addBlockFilter( + AffectedBlock.BlockFilter.builder() + .field(AffectedBlock.BlockFilter.Field.PRICE_ID) + .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() @@ -121,9 +128,9 @@ internal class CustomerCreditLedgerListResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -155,9 +162,15 @@ internal class CustomerCreditLedgerListResponseTest { .amount("amount") .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + MonetaryUsageDiscountAdjustment.Filter.builder() + .field( + MonetaryUsageDiscountAdjustment.Filter.Field + .PRICE_ID + ) + .operator( + MonetaryUsageDiscountAdjustment.Filter.Operator + .INCLUDES + ) .addValue("string") .build() ) @@ -176,9 +189,11 @@ internal class CustomerCreditLedgerListResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator( + PercentageDiscount.Filter.Operator.INCLUDES + ) .addValue("string") .build() ) @@ -192,9 +207,9 @@ internal class CustomerCreditLedgerListResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -206,9 +221,9 @@ internal class CustomerCreditLedgerListResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -235,9 +250,14 @@ internal class CustomerCreditLedgerListResponseTest { .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Price.Unit.CompositePriceFilter.builder() + .field( + Price.Unit.CompositePriceFilter.Field.PRICE_ID + ) + .operator( + Price.Unit.CompositePriceFilter.Operator + .INCLUDES + ) .addValue("string") .build() ) @@ -272,10 +292,13 @@ internal class CustomerCreditLedgerListResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) + PercentageDiscount.Filter.builder() + .field( + PercentageDiscount.Filter.Field.PRICE_ID + ) .operator( - TransformPriceFilter.Operator.INCLUDES + PercentageDiscount.Filter.Operator + .INCLUDES ) .addValue("string") .build() @@ -298,11 +321,9 @@ internal class CustomerCreditLedgerListResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -322,11 +343,9 @@ internal class CustomerCreditLedgerListResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -388,9 +407,9 @@ internal class CustomerCreditLedgerListResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -408,9 +427,9 @@ internal class CustomerCreditLedgerListResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -480,6 +499,13 @@ internal class CustomerCreditLedgerListResponseTest { .creditBlock( AffectedBlock.builder() .id("id") + .addBlockFilter( + AffectedBlock.BlockFilter.builder() + .field(AffectedBlock.BlockFilter.Field.PRICE_ID) + .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() @@ -576,9 +602,9 @@ internal class CustomerCreditLedgerListResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -610,10 +636,15 @@ internal class CustomerCreditLedgerListResponseTest { .amount("amount") .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) + MonetaryUsageDiscountAdjustment.Filter.builder() + .field( + MonetaryUsageDiscountAdjustment.Filter.Field + .PRICE_ID + ) .operator( - TransformPriceFilter.Operator.INCLUDES + MonetaryUsageDiscountAdjustment.Filter + .Operator + .INCLUDES ) .addValue("string") .build() @@ -635,10 +666,10 @@ internal class CustomerCreditLedgerListResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) .operator( - TransformPriceFilter.Operator.INCLUDES + PercentageDiscount.Filter.Operator.INCLUDES ) .addValue("string") .build() @@ -653,11 +684,9 @@ internal class CustomerCreditLedgerListResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -669,11 +698,9 @@ internal class CustomerCreditLedgerListResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -700,10 +727,14 @@ internal class CustomerCreditLedgerListResponseTest { .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) + Price.Unit.CompositePriceFilter.builder() + .field( + Price.Unit.CompositePriceFilter.Field + .PRICE_ID + ) .operator( - TransformPriceFilter.Operator.INCLUDES + Price.Unit.CompositePriceFilter.Operator + .INCLUDES ) .addValue("string") .build() @@ -741,12 +772,13 @@ internal class CustomerCreditLedgerListResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() + PercentageDiscount.Filter.builder() .field( - TransformPriceFilter.Field.PRICE_ID + PercentageDiscount.Filter.Field + .PRICE_ID ) .operator( - TransformPriceFilter.Operator + PercentageDiscount.Filter.Operator .INCLUDES ) .addValue("string") @@ -770,13 +802,10 @@ internal class CustomerCreditLedgerListResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field( - TransformPriceFilter.Field.PRICE_ID - ) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) .operator( - TransformPriceFilter.Operator - .INCLUDES + Maximum.Filter.Operator.INCLUDES ) .addValue("string") .build() @@ -797,13 +826,10 @@ internal class CustomerCreditLedgerListResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field( - TransformPriceFilter.Field.PRICE_ID - ) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) .operator( - TransformPriceFilter.Operator - .INCLUDES + Minimum.Filter.Operator.INCLUDES ) .addValue("string") .build() @@ -868,9 +894,9 @@ internal class CustomerCreditLedgerListResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -888,9 +914,9 @@ internal class CustomerCreditLedgerListResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -959,6 +985,13 @@ internal class CustomerCreditLedgerListResponseTest { .creditBlock( AffectedBlock.builder() .id("id") + .addBlockFilter( + AffectedBlock.BlockFilter.builder() + .field(AffectedBlock.BlockFilter.Field.PRICE_ID) + .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() @@ -1010,6 +1043,13 @@ internal class CustomerCreditLedgerListResponseTest { .creditBlock( AffectedBlock.builder() .id("id") + .addBlockFilter( + AffectedBlock.BlockFilter.builder() + .field(AffectedBlock.BlockFilter.Field.PRICE_ID) + .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() @@ -1058,6 +1098,13 @@ internal class CustomerCreditLedgerListResponseTest { .creditBlock( AffectedBlock.builder() .id("id") + .addBlockFilter( + AffectedBlock.BlockFilter.builder() + .field(AffectedBlock.BlockFilter.Field.PRICE_ID) + .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() @@ -1107,6 +1154,13 @@ internal class CustomerCreditLedgerListResponseTest { .creditBlock( AffectedBlock.builder() .id("id") + .addBlockFilter( + AffectedBlock.BlockFilter.builder() + .field(AffectedBlock.BlockFilter.Field.PRICE_ID) + .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() @@ -1153,6 +1207,13 @@ internal class CustomerCreditLedgerListResponseTest { .creditBlock( AffectedBlock.builder() .id("id") + .addBlockFilter( + AffectedBlock.BlockFilter.builder() + .field(AffectedBlock.BlockFilter.Field.PRICE_ID) + .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() @@ -1202,6 +1263,13 @@ internal class CustomerCreditLedgerListResponseTest { .creditBlock( AffectedBlock.builder() .id("id") + .addBlockFilter( + AffectedBlock.BlockFilter.builder() + .field(AffectedBlock.BlockFilter.Field.PRICE_ID) + .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() @@ -1247,6 +1315,13 @@ internal class CustomerCreditLedgerListResponseTest { .creditBlock( AffectedBlock.builder() .id("id") + .addBlockFilter( + AffectedBlock.BlockFilter.builder() + .field(AffectedBlock.BlockFilter.Field.PRICE_ID) + .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() @@ -1296,6 +1371,13 @@ internal class CustomerCreditLedgerListResponseTest { .creditBlock( AffectedBlock.builder() .id("id") + .addBlockFilter( + AffectedBlock.BlockFilter.builder() + .field(AffectedBlock.BlockFilter.Field.PRICE_ID) + .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() @@ -1343,6 +1425,13 @@ internal class CustomerCreditLedgerListResponseTest { .creditBlock( AffectedBlock.builder() .id("id") + .addBlockFilter( + AffectedBlock.BlockFilter.builder() + .field(AffectedBlock.BlockFilter.Field.PRICE_ID) + .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() @@ -1394,6 +1483,13 @@ internal class CustomerCreditLedgerListResponseTest { .creditBlock( AffectedBlock.builder() .id("id") + .addBlockFilter( + AffectedBlock.BlockFilter.builder() + .field(AffectedBlock.BlockFilter.Field.PRICE_ID) + .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() @@ -1442,6 +1538,13 @@ internal class CustomerCreditLedgerListResponseTest { .creditBlock( AffectedBlock.builder() .id("id") + .addBlockFilter( + AffectedBlock.BlockFilter.builder() + .field(AffectedBlock.BlockFilter.Field.PRICE_ID) + .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() @@ -1490,6 +1593,13 @@ internal class CustomerCreditLedgerListResponseTest { .creditBlock( AffectedBlock.builder() .id("id") + .addBlockFilter( + AffectedBlock.BlockFilter.builder() + .field(AffectedBlock.BlockFilter.Field.PRICE_ID) + .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/DecrementLedgerEntryTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/DecrementLedgerEntryTest.kt index 43b2841eb..10e23562f 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/DecrementLedgerEntryTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/DecrementLedgerEntryTest.kt @@ -21,6 +21,13 @@ internal class DecrementLedgerEntryTest { .creditBlock( AffectedBlock.builder() .id("id") + .addBlockFilter( + AffectedBlock.BlockFilter.builder() + .field(AffectedBlock.BlockFilter.Field.PRICE_ID) + .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() @@ -56,6 +63,13 @@ internal class DecrementLedgerEntryTest { .isEqualTo( AffectedBlock.builder() .id("id") + .addBlockFilter( + AffectedBlock.BlockFilter.builder() + .field(AffectedBlock.BlockFilter.Field.PRICE_ID) + .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() @@ -98,6 +112,13 @@ internal class DecrementLedgerEntryTest { .creditBlock( AffectedBlock.builder() .id("id") + .addBlockFilter( + AffectedBlock.BlockFilter.builder() + .field(AffectedBlock.BlockFilter.Field.PRICE_ID) + .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/DiscountTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/DiscountTest.kt index ddb6c9284..cd9b79dff 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/DiscountTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/DiscountTest.kt @@ -23,9 +23,9 @@ internal class DiscountTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -51,9 +51,9 @@ internal class DiscountTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -78,9 +78,9 @@ internal class DiscountTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + TrialDiscount.Filter.builder() + .field(TrialDiscount.Filter.Field.PRICE_ID) + .operator(TrialDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -107,9 +107,9 @@ internal class DiscountTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + TrialDiscount.Filter.builder() + .field(TrialDiscount.Filter.Field.PRICE_ID) + .operator(TrialDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -137,9 +137,9 @@ internal class DiscountTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + UsageDiscount.Filter.builder() + .field(UsageDiscount.Filter.Field.PRICE_ID) + .operator(UsageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -165,9 +165,9 @@ internal class DiscountTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + UsageDiscount.Filter.builder() + .field(UsageDiscount.Filter.Field.PRICE_ID) + .operator(UsageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -193,9 +193,9 @@ internal class DiscountTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + AmountDiscount.Filter.builder() + .field(AmountDiscount.Filter.Field.PRICE_ID) + .operator(AmountDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -221,9 +221,9 @@ internal class DiscountTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + AmountDiscount.Filter.builder() + .field(AmountDiscount.Filter.Field.PRICE_ID) + .operator(AmountDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/ExpirationChangeLedgerEntryTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/ExpirationChangeLedgerEntryTest.kt index 04ea2eccb..2aacd3628 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/ExpirationChangeLedgerEntryTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/ExpirationChangeLedgerEntryTest.kt @@ -21,6 +21,13 @@ internal class ExpirationChangeLedgerEntryTest { .creditBlock( AffectedBlock.builder() .id("id") + .addBlockFilter( + AffectedBlock.BlockFilter.builder() + .field(AffectedBlock.BlockFilter.Field.PRICE_ID) + .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() @@ -54,6 +61,13 @@ internal class ExpirationChangeLedgerEntryTest { .isEqualTo( AffectedBlock.builder() .id("id") + .addBlockFilter( + AffectedBlock.BlockFilter.builder() + .field(AffectedBlock.BlockFilter.Field.PRICE_ID) + .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() @@ -95,6 +109,13 @@ internal class ExpirationChangeLedgerEntryTest { .creditBlock( AffectedBlock.builder() .id("id") + .addBlockFilter( + AffectedBlock.BlockFilter.builder() + .field(AffectedBlock.BlockFilter.Field.PRICE_ID) + .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/IncrementLedgerEntryTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/IncrementLedgerEntryTest.kt index a11f01251..163cdfa7f 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/IncrementLedgerEntryTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/IncrementLedgerEntryTest.kt @@ -21,6 +21,13 @@ internal class IncrementLedgerEntryTest { .creditBlock( AffectedBlock.builder() .id("id") + .addBlockFilter( + AffectedBlock.BlockFilter.builder() + .field(AffectedBlock.BlockFilter.Field.PRICE_ID) + .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() @@ -117,9 +124,9 @@ internal class IncrementLedgerEntryTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -151,9 +158,15 @@ internal class IncrementLedgerEntryTest { .amount("amount") .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + MonetaryUsageDiscountAdjustment.Filter.builder() + .field( + MonetaryUsageDiscountAdjustment.Filter.Field + .PRICE_ID + ) + .operator( + MonetaryUsageDiscountAdjustment.Filter.Operator + .INCLUDES + ) .addValue("string") .build() ) @@ -172,9 +185,11 @@ internal class IncrementLedgerEntryTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator( + PercentageDiscount.Filter.Operator.INCLUDES + ) .addValue("string") .build() ) @@ -188,9 +203,9 @@ internal class IncrementLedgerEntryTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -202,9 +217,9 @@ internal class IncrementLedgerEntryTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -231,9 +246,14 @@ internal class IncrementLedgerEntryTest { .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Price.Unit.CompositePriceFilter.builder() + .field( + Price.Unit.CompositePriceFilter.Field.PRICE_ID + ) + .operator( + Price.Unit.CompositePriceFilter.Operator + .INCLUDES + ) .addValue("string") .build() ) @@ -268,10 +288,13 @@ internal class IncrementLedgerEntryTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) + PercentageDiscount.Filter.builder() + .field( + PercentageDiscount.Filter.Field.PRICE_ID + ) .operator( - TransformPriceFilter.Operator.INCLUDES + PercentageDiscount.Filter.Operator + .INCLUDES ) .addValue("string") .build() @@ -294,11 +317,9 @@ internal class IncrementLedgerEntryTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -318,11 +339,9 @@ internal class IncrementLedgerEntryTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -384,9 +403,9 @@ internal class IncrementLedgerEntryTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -404,9 +423,9 @@ internal class IncrementLedgerEntryTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -460,6 +479,13 @@ internal class IncrementLedgerEntryTest { .isEqualTo( AffectedBlock.builder() .id("id") + .addBlockFilter( + AffectedBlock.BlockFilter.builder() + .field(AffectedBlock.BlockFilter.Field.PRICE_ID) + .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() @@ -557,9 +583,9 @@ internal class IncrementLedgerEntryTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -591,9 +617,15 @@ internal class IncrementLedgerEntryTest { .amount("amount") .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + MonetaryUsageDiscountAdjustment.Filter.builder() + .field( + MonetaryUsageDiscountAdjustment.Filter.Field + .PRICE_ID + ) + .operator( + MonetaryUsageDiscountAdjustment.Filter.Operator + .INCLUDES + ) .addValue("string") .build() ) @@ -612,9 +644,9 @@ internal class IncrementLedgerEntryTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -628,9 +660,9 @@ internal class IncrementLedgerEntryTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -642,9 +674,9 @@ internal class IncrementLedgerEntryTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -669,9 +701,11 @@ internal class IncrementLedgerEntryTest { .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Price.Unit.CompositePriceFilter.builder() + .field(Price.Unit.CompositePriceFilter.Field.PRICE_ID) + .operator( + Price.Unit.CompositePriceFilter.Operator.INCLUDES + ) .addValue("string") .build() ) @@ -704,10 +738,10 @@ internal class IncrementLedgerEntryTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) .operator( - TransformPriceFilter.Operator.INCLUDES + PercentageDiscount.Filter.Operator.INCLUDES ) .addValue("string") .build() @@ -730,11 +764,9 @@ internal class IncrementLedgerEntryTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -751,11 +783,9 @@ internal class IncrementLedgerEntryTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -815,9 +845,9 @@ internal class IncrementLedgerEntryTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -835,9 +865,9 @@ internal class IncrementLedgerEntryTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -894,6 +924,13 @@ internal class IncrementLedgerEntryTest { .creditBlock( AffectedBlock.builder() .id("id") + .addBlockFilter( + AffectedBlock.BlockFilter.builder() + .field(AffectedBlock.BlockFilter.Field.PRICE_ID) + .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() @@ -990,9 +1027,9 @@ internal class IncrementLedgerEntryTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -1024,9 +1061,15 @@ internal class IncrementLedgerEntryTest { .amount("amount") .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + MonetaryUsageDiscountAdjustment.Filter.builder() + .field( + MonetaryUsageDiscountAdjustment.Filter.Field + .PRICE_ID + ) + .operator( + MonetaryUsageDiscountAdjustment.Filter.Operator + .INCLUDES + ) .addValue("string") .build() ) @@ -1045,9 +1088,11 @@ internal class IncrementLedgerEntryTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator( + PercentageDiscount.Filter.Operator.INCLUDES + ) .addValue("string") .build() ) @@ -1061,9 +1106,9 @@ internal class IncrementLedgerEntryTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -1075,9 +1120,9 @@ internal class IncrementLedgerEntryTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -1104,9 +1149,14 @@ internal class IncrementLedgerEntryTest { .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Price.Unit.CompositePriceFilter.builder() + .field( + Price.Unit.CompositePriceFilter.Field.PRICE_ID + ) + .operator( + Price.Unit.CompositePriceFilter.Operator + .INCLUDES + ) .addValue("string") .build() ) @@ -1141,10 +1191,13 @@ internal class IncrementLedgerEntryTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) + PercentageDiscount.Filter.builder() + .field( + PercentageDiscount.Filter.Field.PRICE_ID + ) .operator( - TransformPriceFilter.Operator.INCLUDES + PercentageDiscount.Filter.Operator + .INCLUDES ) .addValue("string") .build() @@ -1167,11 +1220,9 @@ internal class IncrementLedgerEntryTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -1191,11 +1242,9 @@ internal class IncrementLedgerEntryTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -1257,9 +1306,9 @@ internal class IncrementLedgerEntryTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -1277,9 +1326,9 @@ internal class IncrementLedgerEntryTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceCreateParamsTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceCreateParamsTest.kt index 62bd0eca3..b00c638da 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceCreateParamsTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceCreateParamsTest.kt @@ -34,9 +34,9 @@ internal class InvoiceCreateParamsTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -81,9 +81,9 @@ internal class InvoiceCreateParamsTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -128,9 +128,9 @@ internal class InvoiceCreateParamsTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceFetchUpcomingResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceFetchUpcomingResponseTest.kt index 600ba9d0e..69e84e4d4 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceFetchUpcomingResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceFetchUpcomingResponseTest.kt @@ -88,9 +88,9 @@ internal class InvoiceFetchUpcomingResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -118,9 +118,13 @@ internal class InvoiceFetchUpcomingResponseTest { .amount("amount") .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + MonetaryUsageDiscountAdjustment.Filter.builder() + .field( + MonetaryUsageDiscountAdjustment.Filter.Field.PRICE_ID + ) + .operator( + MonetaryUsageDiscountAdjustment.Filter.Operator.INCLUDES + ) .addValue("string") .build() ) @@ -139,9 +143,9 @@ internal class InvoiceFetchUpcomingResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -155,9 +159,9 @@ internal class InvoiceFetchUpcomingResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -169,9 +173,9 @@ internal class InvoiceFetchUpcomingResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -194,9 +198,9 @@ internal class InvoiceFetchUpcomingResponseTest { .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Price.Unit.CompositePriceFilter.builder() + .field(Price.Unit.CompositePriceFilter.Field.PRICE_ID) + .operator(Price.Unit.CompositePriceFilter.Operator.INCLUDES) .addValue("string") .build() ) @@ -227,9 +231,11 @@ internal class InvoiceFetchUpcomingResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator( + PercentageDiscount.Filter.Operator.INCLUDES + ) .addValue("string") .build() ) @@ -249,9 +255,9 @@ internal class InvoiceFetchUpcomingResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -268,9 +274,9 @@ internal class InvoiceFetchUpcomingResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -328,9 +334,9 @@ internal class InvoiceFetchUpcomingResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -348,9 +354,9 @@ internal class InvoiceFetchUpcomingResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -478,9 +484,9 @@ internal class InvoiceFetchUpcomingResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -516,9 +522,11 @@ internal class InvoiceFetchUpcomingResponseTest { .amount("amount") .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + MonetaryUsageDiscountAdjustment.Filter.builder() + .field(MonetaryUsageDiscountAdjustment.Filter.Field.PRICE_ID) + .operator( + MonetaryUsageDiscountAdjustment.Filter.Operator.INCLUDES + ) .addValue("string") .build() ) @@ -537,9 +545,9 @@ internal class InvoiceFetchUpcomingResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -553,9 +561,9 @@ internal class InvoiceFetchUpcomingResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -567,9 +575,9 @@ internal class InvoiceFetchUpcomingResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -592,9 +600,9 @@ internal class InvoiceFetchUpcomingResponseTest { .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Price.Unit.CompositePriceFilter.builder() + .field(Price.Unit.CompositePriceFilter.Field.PRICE_ID) + .operator(Price.Unit.CompositePriceFilter.Operator.INCLUDES) .addValue("string") .build() ) @@ -623,9 +631,9 @@ internal class InvoiceFetchUpcomingResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -645,9 +653,9 @@ internal class InvoiceFetchUpcomingResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -664,9 +672,9 @@ internal class InvoiceFetchUpcomingResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -722,9 +730,9 @@ internal class InvoiceFetchUpcomingResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -744,9 +752,9 @@ internal class InvoiceFetchUpcomingResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -882,9 +890,9 @@ internal class InvoiceFetchUpcomingResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -912,9 +920,13 @@ internal class InvoiceFetchUpcomingResponseTest { .amount("amount") .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + MonetaryUsageDiscountAdjustment.Filter.builder() + .field( + MonetaryUsageDiscountAdjustment.Filter.Field.PRICE_ID + ) + .operator( + MonetaryUsageDiscountAdjustment.Filter.Operator.INCLUDES + ) .addValue("string") .build() ) @@ -933,9 +945,9 @@ internal class InvoiceFetchUpcomingResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -949,9 +961,9 @@ internal class InvoiceFetchUpcomingResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -963,9 +975,9 @@ internal class InvoiceFetchUpcomingResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -988,9 +1000,9 @@ internal class InvoiceFetchUpcomingResponseTest { .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Price.Unit.CompositePriceFilter.builder() + .field(Price.Unit.CompositePriceFilter.Field.PRICE_ID) + .operator(Price.Unit.CompositePriceFilter.Operator.INCLUDES) .addValue("string") .build() ) @@ -1021,9 +1033,11 @@ internal class InvoiceFetchUpcomingResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator( + PercentageDiscount.Filter.Operator.INCLUDES + ) .addValue("string") .build() ) @@ -1043,9 +1057,9 @@ internal class InvoiceFetchUpcomingResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -1062,9 +1076,9 @@ internal class InvoiceFetchUpcomingResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -1122,9 +1136,9 @@ internal class InvoiceFetchUpcomingResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -1142,9 +1156,9 @@ internal class InvoiceFetchUpcomingResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceLevelDiscountTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceLevelDiscountTest.kt index da7c3d505..f768a98e1 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceLevelDiscountTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceLevelDiscountTest.kt @@ -23,9 +23,9 @@ internal class InvoiceLevelDiscountTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -50,9 +50,9 @@ internal class InvoiceLevelDiscountTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -78,9 +78,9 @@ internal class InvoiceLevelDiscountTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + AmountDiscount.Filter.builder() + .field(AmountDiscount.Filter.Field.PRICE_ID) + .operator(AmountDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -105,9 +105,9 @@ internal class InvoiceLevelDiscountTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + AmountDiscount.Filter.builder() + .field(AmountDiscount.Filter.Field.PRICE_ID) + .operator(AmountDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -132,9 +132,9 @@ internal class InvoiceLevelDiscountTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + TrialDiscount.Filter.builder() + .field(TrialDiscount.Filter.Field.PRICE_ID) + .operator(TrialDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -160,9 +160,9 @@ internal class InvoiceLevelDiscountTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + TrialDiscount.Filter.builder() + .field(TrialDiscount.Filter.Field.PRICE_ID) + .operator(TrialDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceLineItemCreateResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceLineItemCreateResponseTest.kt index ad1f6a593..befb00bb3 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceLineItemCreateResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceLineItemCreateResponseTest.kt @@ -26,9 +26,9 @@ internal class InvoiceLineItemCreateResponseTest { .amount("amount") .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + MonetaryUsageDiscountAdjustment.Filter.builder() + .field(MonetaryUsageDiscountAdjustment.Filter.Field.PRICE_ID) + .operator(MonetaryUsageDiscountAdjustment.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -47,9 +47,9 @@ internal class InvoiceLineItemCreateResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -63,9 +63,9 @@ internal class InvoiceLineItemCreateResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -77,9 +77,9 @@ internal class InvoiceLineItemCreateResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -102,9 +102,9 @@ internal class InvoiceLineItemCreateResponseTest { .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Price.Unit.CompositePriceFilter.builder() + .field(Price.Unit.CompositePriceFilter.Field.PRICE_ID) + .operator(Price.Unit.CompositePriceFilter.Operator.INCLUDES) .addValue("string") .build() ) @@ -133,9 +133,9 @@ internal class InvoiceLineItemCreateResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -155,9 +155,9 @@ internal class InvoiceLineItemCreateResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -174,9 +174,9 @@ internal class InvoiceLineItemCreateResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -236,9 +236,9 @@ internal class InvoiceLineItemCreateResponseTest { .amount("amount") .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + MonetaryUsageDiscountAdjustment.Filter.builder() + .field(MonetaryUsageDiscountAdjustment.Filter.Field.PRICE_ID) + .operator(MonetaryUsageDiscountAdjustment.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -260,9 +260,9 @@ internal class InvoiceLineItemCreateResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -279,9 +279,9 @@ internal class InvoiceLineItemCreateResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -294,9 +294,9 @@ internal class InvoiceLineItemCreateResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -321,9 +321,9 @@ internal class InvoiceLineItemCreateResponseTest { .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Price.Unit.CompositePriceFilter.builder() + .field(Price.Unit.CompositePriceFilter.Field.PRICE_ID) + .operator(Price.Unit.CompositePriceFilter.Operator.INCLUDES) .addValue("string") .build() ) @@ -352,9 +352,9 @@ internal class InvoiceLineItemCreateResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -374,9 +374,9 @@ internal class InvoiceLineItemCreateResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -393,9 +393,9 @@ internal class InvoiceLineItemCreateResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -464,9 +464,9 @@ internal class InvoiceLineItemCreateResponseTest { .amount("amount") .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + MonetaryUsageDiscountAdjustment.Filter.builder() + .field(MonetaryUsageDiscountAdjustment.Filter.Field.PRICE_ID) + .operator(MonetaryUsageDiscountAdjustment.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -485,9 +485,9 @@ internal class InvoiceLineItemCreateResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -501,9 +501,9 @@ internal class InvoiceLineItemCreateResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -515,9 +515,9 @@ internal class InvoiceLineItemCreateResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -540,9 +540,9 @@ internal class InvoiceLineItemCreateResponseTest { .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Price.Unit.CompositePriceFilter.builder() + .field(Price.Unit.CompositePriceFilter.Field.PRICE_ID) + .operator(Price.Unit.CompositePriceFilter.Operator.INCLUDES) .addValue("string") .build() ) @@ -571,9 +571,9 @@ internal class InvoiceLineItemCreateResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -593,9 +593,9 @@ internal class InvoiceLineItemCreateResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -612,9 +612,9 @@ internal class InvoiceLineItemCreateResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceListPageResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceListPageResponseTest.kt index e4d0df0a4..6c2cc0be2 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceListPageResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceListPageResponseTest.kt @@ -89,9 +89,9 @@ internal class InvoiceListPageResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -123,9 +123,15 @@ internal class InvoiceListPageResponseTest { .amount("amount") .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + MonetaryUsageDiscountAdjustment.Filter.builder() + .field( + MonetaryUsageDiscountAdjustment.Filter.Field + .PRICE_ID + ) + .operator( + MonetaryUsageDiscountAdjustment.Filter.Operator + .INCLUDES + ) .addValue("string") .build() ) @@ -144,9 +150,11 @@ internal class InvoiceListPageResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator( + PercentageDiscount.Filter.Operator.INCLUDES + ) .addValue("string") .build() ) @@ -160,9 +168,9 @@ internal class InvoiceListPageResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -174,9 +182,9 @@ internal class InvoiceListPageResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -203,9 +211,14 @@ internal class InvoiceListPageResponseTest { .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Price.Unit.CompositePriceFilter.builder() + .field( + Price.Unit.CompositePriceFilter.Field.PRICE_ID + ) + .operator( + Price.Unit.CompositePriceFilter.Operator + .INCLUDES + ) .addValue("string") .build() ) @@ -240,10 +253,13 @@ internal class InvoiceListPageResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) + PercentageDiscount.Filter.builder() + .field( + PercentageDiscount.Filter.Field.PRICE_ID + ) .operator( - TransformPriceFilter.Operator.INCLUDES + PercentageDiscount.Filter.Operator + .INCLUDES ) .addValue("string") .build() @@ -266,11 +282,9 @@ internal class InvoiceListPageResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -290,11 +304,9 @@ internal class InvoiceListPageResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -356,9 +368,9 @@ internal class InvoiceListPageResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -376,9 +388,9 @@ internal class InvoiceListPageResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -498,9 +510,9 @@ internal class InvoiceListPageResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -532,9 +544,15 @@ internal class InvoiceListPageResponseTest { .amount("amount") .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + MonetaryUsageDiscountAdjustment.Filter.builder() + .field( + MonetaryUsageDiscountAdjustment.Filter.Field + .PRICE_ID + ) + .operator( + MonetaryUsageDiscountAdjustment.Filter.Operator + .INCLUDES + ) .addValue("string") .build() ) @@ -553,9 +571,9 @@ internal class InvoiceListPageResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -569,9 +587,9 @@ internal class InvoiceListPageResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -583,9 +601,9 @@ internal class InvoiceListPageResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -610,9 +628,11 @@ internal class InvoiceListPageResponseTest { .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Price.Unit.CompositePriceFilter.builder() + .field(Price.Unit.CompositePriceFilter.Field.PRICE_ID) + .operator( + Price.Unit.CompositePriceFilter.Operator.INCLUDES + ) .addValue("string") .build() ) @@ -645,10 +665,10 @@ internal class InvoiceListPageResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) .operator( - TransformPriceFilter.Operator.INCLUDES + PercentageDiscount.Filter.Operator.INCLUDES ) .addValue("string") .build() @@ -671,11 +691,9 @@ internal class InvoiceListPageResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -692,11 +710,9 @@ internal class InvoiceListPageResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -756,9 +772,9 @@ internal class InvoiceListPageResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -776,9 +792,9 @@ internal class InvoiceListPageResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -905,9 +921,9 @@ internal class InvoiceListPageResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -939,9 +955,15 @@ internal class InvoiceListPageResponseTest { .amount("amount") .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + MonetaryUsageDiscountAdjustment.Filter.builder() + .field( + MonetaryUsageDiscountAdjustment.Filter.Field + .PRICE_ID + ) + .operator( + MonetaryUsageDiscountAdjustment.Filter.Operator + .INCLUDES + ) .addValue("string") .build() ) @@ -960,9 +982,11 @@ internal class InvoiceListPageResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator( + PercentageDiscount.Filter.Operator.INCLUDES + ) .addValue("string") .build() ) @@ -976,9 +1000,9 @@ internal class InvoiceListPageResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -990,9 +1014,9 @@ internal class InvoiceListPageResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -1019,9 +1043,14 @@ internal class InvoiceListPageResponseTest { .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Price.Unit.CompositePriceFilter.builder() + .field( + Price.Unit.CompositePriceFilter.Field.PRICE_ID + ) + .operator( + Price.Unit.CompositePriceFilter.Operator + .INCLUDES + ) .addValue("string") .build() ) @@ -1056,10 +1085,13 @@ internal class InvoiceListPageResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) + PercentageDiscount.Filter.builder() + .field( + PercentageDiscount.Filter.Field.PRICE_ID + ) .operator( - TransformPriceFilter.Operator.INCLUDES + PercentageDiscount.Filter.Operator + .INCLUDES ) .addValue("string") .build() @@ -1082,11 +1114,9 @@ internal class InvoiceListPageResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -1106,11 +1136,9 @@ internal class InvoiceListPageResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -1172,9 +1200,9 @@ internal class InvoiceListPageResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -1192,9 +1220,9 @@ internal class InvoiceListPageResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceTest.kt index 5c7177b38..093722ab5 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceTest.kt @@ -83,9 +83,9 @@ internal class InvoiceTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -114,9 +114,13 @@ internal class InvoiceTest { .amount("amount") .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + MonetaryUsageDiscountAdjustment.Filter.builder() + .field( + MonetaryUsageDiscountAdjustment.Filter.Field.PRICE_ID + ) + .operator( + MonetaryUsageDiscountAdjustment.Filter.Operator.INCLUDES + ) .addValue("string") .build() ) @@ -135,9 +139,9 @@ internal class InvoiceTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -151,9 +155,9 @@ internal class InvoiceTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -165,9 +169,9 @@ internal class InvoiceTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -190,9 +194,9 @@ internal class InvoiceTest { .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Price.Unit.CompositePriceFilter.builder() + .field(Price.Unit.CompositePriceFilter.Field.PRICE_ID) + .operator(Price.Unit.CompositePriceFilter.Operator.INCLUDES) .addValue("string") .build() ) @@ -223,9 +227,11 @@ internal class InvoiceTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator( + PercentageDiscount.Filter.Operator.INCLUDES + ) .addValue("string") .build() ) @@ -245,9 +251,9 @@ internal class InvoiceTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -264,9 +270,9 @@ internal class InvoiceTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -324,9 +330,9 @@ internal class InvoiceTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -344,9 +350,9 @@ internal class InvoiceTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -466,9 +472,9 @@ internal class InvoiceTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -503,9 +509,11 @@ internal class InvoiceTest { .amount("amount") .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + MonetaryUsageDiscountAdjustment.Filter.builder() + .field(MonetaryUsageDiscountAdjustment.Filter.Field.PRICE_ID) + .operator( + MonetaryUsageDiscountAdjustment.Filter.Operator.INCLUDES + ) .addValue("string") .build() ) @@ -524,9 +532,9 @@ internal class InvoiceTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -540,9 +548,9 @@ internal class InvoiceTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -554,9 +562,9 @@ internal class InvoiceTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -579,9 +587,9 @@ internal class InvoiceTest { .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Price.Unit.CompositePriceFilter.builder() + .field(Price.Unit.CompositePriceFilter.Field.PRICE_ID) + .operator(Price.Unit.CompositePriceFilter.Operator.INCLUDES) .addValue("string") .build() ) @@ -610,9 +618,9 @@ internal class InvoiceTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -632,9 +640,9 @@ internal class InvoiceTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -651,9 +659,9 @@ internal class InvoiceTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -709,9 +717,9 @@ internal class InvoiceTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -731,9 +739,9 @@ internal class InvoiceTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -857,9 +865,9 @@ internal class InvoiceTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -888,9 +896,13 @@ internal class InvoiceTest { .amount("amount") .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + MonetaryUsageDiscountAdjustment.Filter.builder() + .field( + MonetaryUsageDiscountAdjustment.Filter.Field.PRICE_ID + ) + .operator( + MonetaryUsageDiscountAdjustment.Filter.Operator.INCLUDES + ) .addValue("string") .build() ) @@ -909,9 +921,9 @@ internal class InvoiceTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -925,9 +937,9 @@ internal class InvoiceTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -939,9 +951,9 @@ internal class InvoiceTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -964,9 +976,9 @@ internal class InvoiceTest { .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Price.Unit.CompositePriceFilter.builder() + .field(Price.Unit.CompositePriceFilter.Field.PRICE_ID) + .operator(Price.Unit.CompositePriceFilter.Operator.INCLUDES) .addValue("string") .build() ) @@ -997,9 +1009,11 @@ internal class InvoiceTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator( + PercentageDiscount.Filter.Operator.INCLUDES + ) .addValue("string") .build() ) @@ -1019,9 +1033,9 @@ internal class InvoiceTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -1038,9 +1052,9 @@ internal class InvoiceTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -1098,9 +1112,9 @@ internal class InvoiceTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -1118,9 +1132,9 @@ internal class InvoiceTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/MaximumIntervalTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/MaximumIntervalTest.kt index 435bde6cc..50c44837d 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/MaximumIntervalTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/MaximumIntervalTest.kt @@ -17,9 +17,9 @@ internal class MaximumIntervalTest { .addAppliesToPriceIntervalId("string") .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + MaximumInterval.Filter.builder() + .field(MaximumInterval.Filter.Field.PRICE_ID) + .operator(MaximumInterval.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -32,9 +32,9 @@ internal class MaximumIntervalTest { .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) assertThat(maximumInterval.filters()) .containsExactly( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + MaximumInterval.Filter.builder() + .field(MaximumInterval.Filter.Field.PRICE_ID) + .operator(MaximumInterval.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -51,9 +51,9 @@ internal class MaximumIntervalTest { .addAppliesToPriceIntervalId("string") .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + MaximumInterval.Filter.builder() + .field(MaximumInterval.Filter.Field.PRICE_ID) + .operator(MaximumInterval.Filter.Operator.INCLUDES) .addValue("string") .build() ) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/MaximumTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/MaximumTest.kt index 1eb179e04..876cb92b7 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/MaximumTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/MaximumTest.kt @@ -15,9 +15,9 @@ internal class MaximumTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -27,9 +27,9 @@ internal class MaximumTest { assertThat(maximum.appliesToPriceIds()).containsExactly("string") assertThat(maximum.filters()) .containsExactly( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -43,9 +43,9 @@ internal class MaximumTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/MinimumIntervalTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/MinimumIntervalTest.kt index 989cd05ed..71c4ced4b 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/MinimumIntervalTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/MinimumIntervalTest.kt @@ -17,9 +17,9 @@ internal class MinimumIntervalTest { .addAppliesToPriceIntervalId("string") .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + MinimumInterval.Filter.builder() + .field(MinimumInterval.Filter.Field.PRICE_ID) + .operator(MinimumInterval.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -32,9 +32,9 @@ internal class MinimumIntervalTest { .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) assertThat(minimumInterval.filters()) .containsExactly( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + MinimumInterval.Filter.builder() + .field(MinimumInterval.Filter.Field.PRICE_ID) + .operator(MinimumInterval.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -51,9 +51,9 @@ internal class MinimumIntervalTest { .addAppliesToPriceIntervalId("string") .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + MinimumInterval.Filter.builder() + .field(MinimumInterval.Filter.Field.PRICE_ID) + .operator(MinimumInterval.Filter.Operator.INCLUDES) .addValue("string") .build() ) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/MinimumTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/MinimumTest.kt index c39afb724..f8aef3afa 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/MinimumTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/MinimumTest.kt @@ -15,9 +15,9 @@ internal class MinimumTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -27,9 +27,9 @@ internal class MinimumTest { assertThat(minimum.appliesToPriceIds()).containsExactly("string") assertThat(minimum.filters()) .containsExactly( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -43,9 +43,9 @@ internal class MinimumTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/MonetaryAmountDiscountAdjustmentTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/MonetaryAmountDiscountAdjustmentTest.kt index 3c4211a1e..cf05942cb 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/MonetaryAmountDiscountAdjustmentTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/MonetaryAmountDiscountAdjustmentTest.kt @@ -19,9 +19,9 @@ internal class MonetaryAmountDiscountAdjustmentTest { .amountDiscount("amount_discount") .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + MonetaryAmountDiscountAdjustment.Filter.builder() + .field(MonetaryAmountDiscountAdjustment.Filter.Field.PRICE_ID) + .operator(MonetaryAmountDiscountAdjustment.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -38,9 +38,9 @@ internal class MonetaryAmountDiscountAdjustmentTest { assertThat(monetaryAmountDiscountAdjustment.appliesToPriceIds()).containsExactly("string") assertThat(monetaryAmountDiscountAdjustment.filters()) .containsExactly( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + MonetaryAmountDiscountAdjustment.Filter.builder() + .field(MonetaryAmountDiscountAdjustment.Filter.Field.PRICE_ID) + .operator(MonetaryAmountDiscountAdjustment.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -61,9 +61,9 @@ internal class MonetaryAmountDiscountAdjustmentTest { .amountDiscount("amount_discount") .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + MonetaryAmountDiscountAdjustment.Filter.builder() + .field(MonetaryAmountDiscountAdjustment.Filter.Field.PRICE_ID) + .operator(MonetaryAmountDiscountAdjustment.Filter.Operator.INCLUDES) .addValue("string") .build() ) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/MonetaryMaximumAdjustmentTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/MonetaryMaximumAdjustmentTest.kt index 9727617a6..eff274b1b 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/MonetaryMaximumAdjustmentTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/MonetaryMaximumAdjustmentTest.kt @@ -18,9 +18,9 @@ internal class MonetaryMaximumAdjustmentTest { .amount("amount") .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + MonetaryMaximumAdjustment.Filter.builder() + .field(MonetaryMaximumAdjustment.Filter.Field.PRICE_ID) + .operator(MonetaryMaximumAdjustment.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -37,9 +37,9 @@ internal class MonetaryMaximumAdjustmentTest { assertThat(monetaryMaximumAdjustment.appliesToPriceIds()).containsExactly("string") assertThat(monetaryMaximumAdjustment.filters()) .containsExactly( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + MonetaryMaximumAdjustment.Filter.builder() + .field(MonetaryMaximumAdjustment.Filter.Field.PRICE_ID) + .operator(MonetaryMaximumAdjustment.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -60,9 +60,9 @@ internal class MonetaryMaximumAdjustmentTest { .amount("amount") .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + MonetaryMaximumAdjustment.Filter.builder() + .field(MonetaryMaximumAdjustment.Filter.Field.PRICE_ID) + .operator(MonetaryMaximumAdjustment.Filter.Operator.INCLUDES) .addValue("string") .build() ) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/MonetaryMinimumAdjustmentTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/MonetaryMinimumAdjustmentTest.kt index 5cfc9fd9a..e5f79084f 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/MonetaryMinimumAdjustmentTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/MonetaryMinimumAdjustmentTest.kt @@ -18,9 +18,9 @@ internal class MonetaryMinimumAdjustmentTest { .amount("amount") .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + MonetaryMinimumAdjustment.Filter.builder() + .field(MonetaryMinimumAdjustment.Filter.Field.PRICE_ID) + .operator(MonetaryMinimumAdjustment.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -38,9 +38,9 @@ internal class MonetaryMinimumAdjustmentTest { assertThat(monetaryMinimumAdjustment.appliesToPriceIds()).containsExactly("string") assertThat(monetaryMinimumAdjustment.filters()) .containsExactly( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + MonetaryMinimumAdjustment.Filter.builder() + .field(MonetaryMinimumAdjustment.Filter.Field.PRICE_ID) + .operator(MonetaryMinimumAdjustment.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -62,9 +62,9 @@ internal class MonetaryMinimumAdjustmentTest { .amount("amount") .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + MonetaryMinimumAdjustment.Filter.builder() + .field(MonetaryMinimumAdjustment.Filter.Field.PRICE_ID) + .operator(MonetaryMinimumAdjustment.Filter.Operator.INCLUDES) .addValue("string") .build() ) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/MonetaryPercentageDiscountAdjustmentTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/MonetaryPercentageDiscountAdjustmentTest.kt index 532a8f1a0..349207152 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/MonetaryPercentageDiscountAdjustmentTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/MonetaryPercentageDiscountAdjustmentTest.kt @@ -20,9 +20,9 @@ internal class MonetaryPercentageDiscountAdjustmentTest { .amount("amount") .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + MonetaryPercentageDiscountAdjustment.Filter.builder() + .field(MonetaryPercentageDiscountAdjustment.Filter.Field.PRICE_ID) + .operator(MonetaryPercentageDiscountAdjustment.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -40,9 +40,9 @@ internal class MonetaryPercentageDiscountAdjustmentTest { .containsExactly("string") assertThat(monetaryPercentageDiscountAdjustment.filters()) .containsExactly( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + MonetaryPercentageDiscountAdjustment.Filter.builder() + .field(MonetaryPercentageDiscountAdjustment.Filter.Field.PRICE_ID) + .operator(MonetaryPercentageDiscountAdjustment.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -65,9 +65,9 @@ internal class MonetaryPercentageDiscountAdjustmentTest { .amount("amount") .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + MonetaryPercentageDiscountAdjustment.Filter.builder() + .field(MonetaryPercentageDiscountAdjustment.Filter.Field.PRICE_ID) + .operator(MonetaryPercentageDiscountAdjustment.Filter.Operator.INCLUDES) .addValue("string") .build() ) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/MonetaryUsageDiscountAdjustmentTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/MonetaryUsageDiscountAdjustmentTest.kt index 5b797a57e..c9b564e07 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/MonetaryUsageDiscountAdjustmentTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/MonetaryUsageDiscountAdjustmentTest.kt @@ -18,9 +18,9 @@ internal class MonetaryUsageDiscountAdjustmentTest { .amount("amount") .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + MonetaryUsageDiscountAdjustment.Filter.builder() + .field(MonetaryUsageDiscountAdjustment.Filter.Field.PRICE_ID) + .operator(MonetaryUsageDiscountAdjustment.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -37,9 +37,9 @@ internal class MonetaryUsageDiscountAdjustmentTest { assertThat(monetaryUsageDiscountAdjustment.appliesToPriceIds()).containsExactly("string") assertThat(monetaryUsageDiscountAdjustment.filters()) .containsExactly( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + MonetaryUsageDiscountAdjustment.Filter.builder() + .field(MonetaryUsageDiscountAdjustment.Filter.Field.PRICE_ID) + .operator(MonetaryUsageDiscountAdjustment.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -60,9 +60,9 @@ internal class MonetaryUsageDiscountAdjustmentTest { .amount("amount") .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + MonetaryUsageDiscountAdjustment.Filter.builder() + .field(MonetaryUsageDiscountAdjustment.Filter.Field.PRICE_ID) + .operator(MonetaryUsageDiscountAdjustment.Filter.Operator.INCLUDES) .addValue("string") .build() ) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/MutatedSubscriptionTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/MutatedSubscriptionTest.kt index f95b60461..203cef795 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/MutatedSubscriptionTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/MutatedSubscriptionTest.kt @@ -28,9 +28,14 @@ internal class MutatedSubscriptionTest { ) .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PlanPhaseUsageDiscountAdjustment.Filter.builder() + .field( + PlanPhaseUsageDiscountAdjustment.Filter.Field.PRICE_ID + ) + .operator( + PlanPhaseUsageDiscountAdjustment.Filter.Operator + .INCLUDES + ) .addValue("string") .build() ) @@ -149,9 +154,9 @@ internal class MutatedSubscriptionTest { .discountType(AmountDiscountInterval.DiscountType.AMOUNT) .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + AmountDiscountInterval.Filter.builder() + .field(AmountDiscountInterval.Filter.Field.PRICE_ID) + .operator(AmountDiscountInterval.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -173,9 +178,9 @@ internal class MutatedSubscriptionTest { .addAppliesToPriceIntervalId("string") .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + MaximumInterval.Filter.builder() + .field(MaximumInterval.Filter.Field.PRICE_ID) + .operator(MaximumInterval.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -193,9 +198,9 @@ internal class MutatedSubscriptionTest { .addAppliesToPriceIntervalId("string") .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + MinimumInterval.Filter.builder() + .field(MinimumInterval.Filter.Field.PRICE_ID) + .operator(MinimumInterval.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -217,9 +222,14 @@ internal class MutatedSubscriptionTest { ) .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PlanPhaseUsageDiscountAdjustment.Filter.builder() + .field( + PlanPhaseUsageDiscountAdjustment.Filter.Field.PRICE_ID + ) + .operator( + PlanPhaseUsageDiscountAdjustment.Filter.Operator + .INCLUDES + ) .addValue("string") .build() ) @@ -249,9 +259,9 @@ internal class MutatedSubscriptionTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -264,9 +274,9 @@ internal class MutatedSubscriptionTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -283,9 +293,9 @@ internal class MutatedSubscriptionTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -306,9 +316,11 @@ internal class MutatedSubscriptionTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator( + PercentageDiscount.Filter.Operator.INCLUDES + ) .addValue("string") .build() ) @@ -321,9 +333,9 @@ internal class MutatedSubscriptionTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -335,9 +347,9 @@ internal class MutatedSubscriptionTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -362,9 +374,9 @@ internal class MutatedSubscriptionTest { .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Price.Unit.CompositePriceFilter.builder() + .field(Price.Unit.CompositePriceFilter.Field.PRICE_ID) + .operator(Price.Unit.CompositePriceFilter.Operator.INCLUDES) .addValue("string") .build() ) @@ -395,9 +407,11 @@ internal class MutatedSubscriptionTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator( + PercentageDiscount.Filter.Operator.INCLUDES + ) .addValue("string") .build() ) @@ -417,9 +431,9 @@ internal class MutatedSubscriptionTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -436,9 +450,9 @@ internal class MutatedSubscriptionTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -508,9 +522,9 @@ internal class MutatedSubscriptionTest { .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Price.Unit.CompositePriceFilter.builder() + .field(Price.Unit.CompositePriceFilter.Field.PRICE_ID) + .operator(Price.Unit.CompositePriceFilter.Operator.INCLUDES) .addValue("string") .build() ) @@ -541,9 +555,11 @@ internal class MutatedSubscriptionTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator( + PercentageDiscount.Filter.Operator.INCLUDES + ) .addValue("string") .build() ) @@ -563,9 +579,9 @@ internal class MutatedSubscriptionTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -582,9 +598,9 @@ internal class MutatedSubscriptionTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -807,9 +823,11 @@ internal class MutatedSubscriptionTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator( + PercentageDiscount.Filter.Operator.INCLUDES + ) .addValue("string") .build() ) @@ -845,10 +863,16 @@ internal class MutatedSubscriptionTest { .amount("amount") .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) + MonetaryUsageDiscountAdjustment.Filter.builder() + .field( + MonetaryUsageDiscountAdjustment.Filter + .Field + .PRICE_ID + ) .operator( - TransformPriceFilter.Operator.INCLUDES + MonetaryUsageDiscountAdjustment.Filter + .Operator + .INCLUDES ) .addValue("string") .build() @@ -870,10 +894,13 @@ internal class MutatedSubscriptionTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) + PercentageDiscount.Filter.builder() + .field( + PercentageDiscount.Filter.Field.PRICE_ID + ) .operator( - TransformPriceFilter.Operator.INCLUDES + PercentageDiscount.Filter.Operator + .INCLUDES ) .addValue("string") .build() @@ -888,11 +915,9 @@ internal class MutatedSubscriptionTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -904,11 +929,9 @@ internal class MutatedSubscriptionTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -936,10 +959,14 @@ internal class MutatedSubscriptionTest { .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) + Price.Unit.CompositePriceFilter.builder() + .field( + Price.Unit.CompositePriceFilter.Field + .PRICE_ID + ) .operator( - TransformPriceFilter.Operator.INCLUDES + Price.Unit.CompositePriceFilter.Operator + .INCLUDES ) .addValue("string") .build() @@ -979,13 +1006,14 @@ internal class MutatedSubscriptionTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() + PercentageDiscount.Filter.builder() .field( - TransformPriceFilter.Field + PercentageDiscount.Filter.Field .PRICE_ID ) .operator( - TransformPriceFilter.Operator + PercentageDiscount.Filter + .Operator .INCLUDES ) .addValue("string") @@ -1012,14 +1040,12 @@ internal class MutatedSubscriptionTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() + Maximum.Filter.builder() .field( - TransformPriceFilter.Field - .PRICE_ID + Maximum.Filter.Field.PRICE_ID ) .operator( - TransformPriceFilter.Operator - .INCLUDES + Maximum.Filter.Operator.INCLUDES ) .addValue("string") .build() @@ -1040,14 +1066,12 @@ internal class MutatedSubscriptionTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() + Minimum.Filter.builder() .field( - TransformPriceFilter.Field - .PRICE_ID + Minimum.Filter.Field.PRICE_ID ) .operator( - TransformPriceFilter.Operator - .INCLUDES + Minimum.Filter.Operator.INCLUDES ) .addValue("string") .build() @@ -1114,9 +1138,9 @@ internal class MutatedSubscriptionTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -1134,9 +1158,9 @@ internal class MutatedSubscriptionTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -1360,9 +1384,11 @@ internal class MutatedSubscriptionTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator( + PercentageDiscount.Filter.Operator.INCLUDES + ) .addValue("string") .build() ) @@ -1394,10 +1420,16 @@ internal class MutatedSubscriptionTest { .amount("amount") .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) + MonetaryUsageDiscountAdjustment.Filter.builder() + .field( + MonetaryUsageDiscountAdjustment.Filter + .Field + .PRICE_ID + ) .operator( - TransformPriceFilter.Operator.INCLUDES + MonetaryUsageDiscountAdjustment.Filter + .Operator + .INCLUDES ) .addValue("string") .build() @@ -1419,10 +1451,13 @@ internal class MutatedSubscriptionTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) + PercentageDiscount.Filter.builder() + .field( + PercentageDiscount.Filter.Field.PRICE_ID + ) .operator( - TransformPriceFilter.Operator.INCLUDES + PercentageDiscount.Filter.Operator + .INCLUDES ) .addValue("string") .build() @@ -1437,11 +1472,9 @@ internal class MutatedSubscriptionTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -1453,11 +1486,9 @@ internal class MutatedSubscriptionTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -1485,10 +1516,14 @@ internal class MutatedSubscriptionTest { .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) + Price.Unit.CompositePriceFilter.builder() + .field( + Price.Unit.CompositePriceFilter.Field + .PRICE_ID + ) .operator( - TransformPriceFilter.Operator.INCLUDES + Price.Unit.CompositePriceFilter.Operator + .INCLUDES ) .addValue("string") .build() @@ -1528,13 +1563,14 @@ internal class MutatedSubscriptionTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() + PercentageDiscount.Filter.builder() .field( - TransformPriceFilter.Field + PercentageDiscount.Filter.Field .PRICE_ID ) .operator( - TransformPriceFilter.Operator + PercentageDiscount.Filter + .Operator .INCLUDES ) .addValue("string") @@ -1561,14 +1597,12 @@ internal class MutatedSubscriptionTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() + Maximum.Filter.builder() .field( - TransformPriceFilter.Field - .PRICE_ID + Maximum.Filter.Field.PRICE_ID ) .operator( - TransformPriceFilter.Operator - .INCLUDES + Maximum.Filter.Operator.INCLUDES ) .addValue("string") .build() @@ -1589,14 +1623,12 @@ internal class MutatedSubscriptionTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() + Minimum.Filter.builder() .field( - TransformPriceFilter.Field - .PRICE_ID + Minimum.Filter.Field.PRICE_ID ) .operator( - TransformPriceFilter.Operator - .INCLUDES + Minimum.Filter.Operator.INCLUDES ) .addValue("string") .build() @@ -1663,9 +1695,9 @@ internal class MutatedSubscriptionTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -1683,9 +1715,9 @@ internal class MutatedSubscriptionTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -1751,9 +1783,11 @@ internal class MutatedSubscriptionTest { ) .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PlanPhaseUsageDiscountAdjustment.Filter.builder() + .field(PlanPhaseUsageDiscountAdjustment.Filter.Field.PRICE_ID) + .operator( + PlanPhaseUsageDiscountAdjustment.Filter.Operator.INCLUDES + ) .addValue("string") .build() ) @@ -1876,9 +1910,9 @@ internal class MutatedSubscriptionTest { .discountType(AmountDiscountInterval.DiscountType.AMOUNT) .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + AmountDiscountInterval.Filter.builder() + .field(AmountDiscountInterval.Filter.Field.PRICE_ID) + .operator(AmountDiscountInterval.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -1904,9 +1938,9 @@ internal class MutatedSubscriptionTest { .addAppliesToPriceIntervalId("string") .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + MaximumInterval.Filter.builder() + .field(MaximumInterval.Filter.Field.PRICE_ID) + .operator(MaximumInterval.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -1926,9 +1960,9 @@ internal class MutatedSubscriptionTest { .addAppliesToPriceIntervalId("string") .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + MinimumInterval.Filter.builder() + .field(MinimumInterval.Filter.Field.PRICE_ID) + .operator(MinimumInterval.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -1952,9 +1986,11 @@ internal class MutatedSubscriptionTest { ) .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PlanPhaseUsageDiscountAdjustment.Filter.builder() + .field(PlanPhaseUsageDiscountAdjustment.Filter.Field.PRICE_ID) + .operator( + PlanPhaseUsageDiscountAdjustment.Filter.Operator.INCLUDES + ) .addValue("string") .build() ) @@ -1984,9 +2020,9 @@ internal class MutatedSubscriptionTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -1999,9 +2035,9 @@ internal class MutatedSubscriptionTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -2018,9 +2054,9 @@ internal class MutatedSubscriptionTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -2041,9 +2077,9 @@ internal class MutatedSubscriptionTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -2056,9 +2092,9 @@ internal class MutatedSubscriptionTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -2070,9 +2106,9 @@ internal class MutatedSubscriptionTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -2097,9 +2133,9 @@ internal class MutatedSubscriptionTest { .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Price.Unit.CompositePriceFilter.builder() + .field(Price.Unit.CompositePriceFilter.Field.PRICE_ID) + .operator(Price.Unit.CompositePriceFilter.Operator.INCLUDES) .addValue("string") .build() ) @@ -2128,9 +2164,9 @@ internal class MutatedSubscriptionTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -2150,9 +2186,9 @@ internal class MutatedSubscriptionTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -2169,9 +2205,9 @@ internal class MutatedSubscriptionTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -2238,9 +2274,9 @@ internal class MutatedSubscriptionTest { .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Price.Unit.CompositePriceFilter.builder() + .field(Price.Unit.CompositePriceFilter.Field.PRICE_ID) + .operator(Price.Unit.CompositePriceFilter.Operator.INCLUDES) .addValue("string") .build() ) @@ -2269,9 +2305,9 @@ internal class MutatedSubscriptionTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -2291,9 +2327,9 @@ internal class MutatedSubscriptionTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -2310,9 +2346,9 @@ internal class MutatedSubscriptionTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -2529,9 +2565,9 @@ internal class MutatedSubscriptionTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -2567,10 +2603,15 @@ internal class MutatedSubscriptionTest { .amount("amount") .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) + MonetaryUsageDiscountAdjustment.Filter.builder() + .field( + MonetaryUsageDiscountAdjustment.Filter.Field + .PRICE_ID + ) .operator( - TransformPriceFilter.Operator.INCLUDES + MonetaryUsageDiscountAdjustment.Filter + .Operator + .INCLUDES ) .addValue("string") .build() @@ -2592,10 +2633,10 @@ internal class MutatedSubscriptionTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) .operator( - TransformPriceFilter.Operator.INCLUDES + PercentageDiscount.Filter.Operator.INCLUDES ) .addValue("string") .build() @@ -2610,11 +2651,9 @@ internal class MutatedSubscriptionTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -2626,11 +2665,9 @@ internal class MutatedSubscriptionTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -2657,10 +2694,14 @@ internal class MutatedSubscriptionTest { .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) + Price.Unit.CompositePriceFilter.builder() + .field( + Price.Unit.CompositePriceFilter.Field + .PRICE_ID + ) .operator( - TransformPriceFilter.Operator.INCLUDES + Price.Unit.CompositePriceFilter.Operator + .INCLUDES ) .addValue("string") .build() @@ -2698,12 +2739,13 @@ internal class MutatedSubscriptionTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() + PercentageDiscount.Filter.builder() .field( - TransformPriceFilter.Field.PRICE_ID + PercentageDiscount.Filter.Field + .PRICE_ID ) .operator( - TransformPriceFilter.Operator + PercentageDiscount.Filter.Operator .INCLUDES ) .addValue("string") @@ -2727,13 +2769,10 @@ internal class MutatedSubscriptionTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field( - TransformPriceFilter.Field.PRICE_ID - ) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) .operator( - TransformPriceFilter.Operator - .INCLUDES + Maximum.Filter.Operator.INCLUDES ) .addValue("string") .build() @@ -2754,13 +2793,10 @@ internal class MutatedSubscriptionTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field( - TransformPriceFilter.Field.PRICE_ID - ) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) .operator( - TransformPriceFilter.Operator - .INCLUDES + Minimum.Filter.Operator.INCLUDES ) .addValue("string") .build() @@ -2825,9 +2861,9 @@ internal class MutatedSubscriptionTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -2845,9 +2881,9 @@ internal class MutatedSubscriptionTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -3059,9 +3095,9 @@ internal class MutatedSubscriptionTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -3093,10 +3129,15 @@ internal class MutatedSubscriptionTest { .amount("amount") .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) + MonetaryUsageDiscountAdjustment.Filter.builder() + .field( + MonetaryUsageDiscountAdjustment.Filter.Field + .PRICE_ID + ) .operator( - TransformPriceFilter.Operator.INCLUDES + MonetaryUsageDiscountAdjustment.Filter + .Operator + .INCLUDES ) .addValue("string") .build() @@ -3118,10 +3159,10 @@ internal class MutatedSubscriptionTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) .operator( - TransformPriceFilter.Operator.INCLUDES + PercentageDiscount.Filter.Operator.INCLUDES ) .addValue("string") .build() @@ -3136,11 +3177,9 @@ internal class MutatedSubscriptionTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -3152,11 +3191,9 @@ internal class MutatedSubscriptionTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -3183,10 +3220,14 @@ internal class MutatedSubscriptionTest { .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) + Price.Unit.CompositePriceFilter.builder() + .field( + Price.Unit.CompositePriceFilter.Field + .PRICE_ID + ) .operator( - TransformPriceFilter.Operator.INCLUDES + Price.Unit.CompositePriceFilter.Operator + .INCLUDES ) .addValue("string") .build() @@ -3224,12 +3265,13 @@ internal class MutatedSubscriptionTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() + PercentageDiscount.Filter.builder() .field( - TransformPriceFilter.Field.PRICE_ID + PercentageDiscount.Filter.Field + .PRICE_ID ) .operator( - TransformPriceFilter.Operator + PercentageDiscount.Filter.Operator .INCLUDES ) .addValue("string") @@ -3253,13 +3295,10 @@ internal class MutatedSubscriptionTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field( - TransformPriceFilter.Field.PRICE_ID - ) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) .operator( - TransformPriceFilter.Operator - .INCLUDES + Maximum.Filter.Operator.INCLUDES ) .addValue("string") .build() @@ -3280,13 +3319,10 @@ internal class MutatedSubscriptionTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field( - TransformPriceFilter.Field.PRICE_ID - ) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) .operator( - TransformPriceFilter.Operator - .INCLUDES + Minimum.Filter.Operator.INCLUDES ) .addValue("string") .build() @@ -3351,9 +3387,9 @@ internal class MutatedSubscriptionTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -3371,9 +3407,9 @@ internal class MutatedSubscriptionTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -3441,9 +3477,14 @@ internal class MutatedSubscriptionTest { ) .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PlanPhaseUsageDiscountAdjustment.Filter.builder() + .field( + PlanPhaseUsageDiscountAdjustment.Filter.Field.PRICE_ID + ) + .operator( + PlanPhaseUsageDiscountAdjustment.Filter.Operator + .INCLUDES + ) .addValue("string") .build() ) @@ -3562,9 +3603,9 @@ internal class MutatedSubscriptionTest { .discountType(AmountDiscountInterval.DiscountType.AMOUNT) .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + AmountDiscountInterval.Filter.builder() + .field(AmountDiscountInterval.Filter.Field.PRICE_ID) + .operator(AmountDiscountInterval.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -3586,9 +3627,9 @@ internal class MutatedSubscriptionTest { .addAppliesToPriceIntervalId("string") .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + MaximumInterval.Filter.builder() + .field(MaximumInterval.Filter.Field.PRICE_ID) + .operator(MaximumInterval.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -3606,9 +3647,9 @@ internal class MutatedSubscriptionTest { .addAppliesToPriceIntervalId("string") .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + MinimumInterval.Filter.builder() + .field(MinimumInterval.Filter.Field.PRICE_ID) + .operator(MinimumInterval.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -3630,9 +3671,14 @@ internal class MutatedSubscriptionTest { ) .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PlanPhaseUsageDiscountAdjustment.Filter.builder() + .field( + PlanPhaseUsageDiscountAdjustment.Filter.Field.PRICE_ID + ) + .operator( + PlanPhaseUsageDiscountAdjustment.Filter.Operator + .INCLUDES + ) .addValue("string") .build() ) @@ -3662,9 +3708,9 @@ internal class MutatedSubscriptionTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -3677,9 +3723,9 @@ internal class MutatedSubscriptionTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -3696,9 +3742,9 @@ internal class MutatedSubscriptionTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -3719,9 +3765,11 @@ internal class MutatedSubscriptionTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator( + PercentageDiscount.Filter.Operator.INCLUDES + ) .addValue("string") .build() ) @@ -3734,9 +3782,9 @@ internal class MutatedSubscriptionTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -3748,9 +3796,9 @@ internal class MutatedSubscriptionTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -3775,9 +3823,9 @@ internal class MutatedSubscriptionTest { .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Price.Unit.CompositePriceFilter.builder() + .field(Price.Unit.CompositePriceFilter.Field.PRICE_ID) + .operator(Price.Unit.CompositePriceFilter.Operator.INCLUDES) .addValue("string") .build() ) @@ -3808,9 +3856,11 @@ internal class MutatedSubscriptionTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator( + PercentageDiscount.Filter.Operator.INCLUDES + ) .addValue("string") .build() ) @@ -3830,9 +3880,9 @@ internal class MutatedSubscriptionTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -3849,9 +3899,9 @@ internal class MutatedSubscriptionTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -3921,9 +3971,9 @@ internal class MutatedSubscriptionTest { .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Price.Unit.CompositePriceFilter.builder() + .field(Price.Unit.CompositePriceFilter.Field.PRICE_ID) + .operator(Price.Unit.CompositePriceFilter.Operator.INCLUDES) .addValue("string") .build() ) @@ -3954,9 +4004,11 @@ internal class MutatedSubscriptionTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator( + PercentageDiscount.Filter.Operator.INCLUDES + ) .addValue("string") .build() ) @@ -3976,9 +4028,9 @@ internal class MutatedSubscriptionTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -3995,9 +4047,9 @@ internal class MutatedSubscriptionTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -4220,9 +4272,11 @@ internal class MutatedSubscriptionTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator( + PercentageDiscount.Filter.Operator.INCLUDES + ) .addValue("string") .build() ) @@ -4258,10 +4312,16 @@ internal class MutatedSubscriptionTest { .amount("amount") .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) + MonetaryUsageDiscountAdjustment.Filter.builder() + .field( + MonetaryUsageDiscountAdjustment.Filter + .Field + .PRICE_ID + ) .operator( - TransformPriceFilter.Operator.INCLUDES + MonetaryUsageDiscountAdjustment.Filter + .Operator + .INCLUDES ) .addValue("string") .build() @@ -4283,10 +4343,13 @@ internal class MutatedSubscriptionTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) + PercentageDiscount.Filter.builder() + .field( + PercentageDiscount.Filter.Field.PRICE_ID + ) .operator( - TransformPriceFilter.Operator.INCLUDES + PercentageDiscount.Filter.Operator + .INCLUDES ) .addValue("string") .build() @@ -4301,11 +4364,9 @@ internal class MutatedSubscriptionTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -4317,11 +4378,9 @@ internal class MutatedSubscriptionTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -4349,10 +4408,14 @@ internal class MutatedSubscriptionTest { .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) + Price.Unit.CompositePriceFilter.builder() + .field( + Price.Unit.CompositePriceFilter.Field + .PRICE_ID + ) .operator( - TransformPriceFilter.Operator.INCLUDES + Price.Unit.CompositePriceFilter.Operator + .INCLUDES ) .addValue("string") .build() @@ -4392,13 +4455,14 @@ internal class MutatedSubscriptionTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() + PercentageDiscount.Filter.builder() .field( - TransformPriceFilter.Field + PercentageDiscount.Filter.Field .PRICE_ID ) .operator( - TransformPriceFilter.Operator + PercentageDiscount.Filter + .Operator .INCLUDES ) .addValue("string") @@ -4425,14 +4489,12 @@ internal class MutatedSubscriptionTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() + Maximum.Filter.builder() .field( - TransformPriceFilter.Field - .PRICE_ID + Maximum.Filter.Field.PRICE_ID ) .operator( - TransformPriceFilter.Operator - .INCLUDES + Maximum.Filter.Operator.INCLUDES ) .addValue("string") .build() @@ -4453,14 +4515,12 @@ internal class MutatedSubscriptionTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() + Minimum.Filter.builder() .field( - TransformPriceFilter.Field - .PRICE_ID + Minimum.Filter.Field.PRICE_ID ) .operator( - TransformPriceFilter.Operator - .INCLUDES + Minimum.Filter.Operator.INCLUDES ) .addValue("string") .build() @@ -4527,9 +4587,9 @@ internal class MutatedSubscriptionTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -4547,9 +4607,9 @@ internal class MutatedSubscriptionTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -4773,9 +4833,11 @@ internal class MutatedSubscriptionTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator( + PercentageDiscount.Filter.Operator.INCLUDES + ) .addValue("string") .build() ) @@ -4807,10 +4869,16 @@ internal class MutatedSubscriptionTest { .amount("amount") .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) + MonetaryUsageDiscountAdjustment.Filter.builder() + .field( + MonetaryUsageDiscountAdjustment.Filter + .Field + .PRICE_ID + ) .operator( - TransformPriceFilter.Operator.INCLUDES + MonetaryUsageDiscountAdjustment.Filter + .Operator + .INCLUDES ) .addValue("string") .build() @@ -4832,10 +4900,13 @@ internal class MutatedSubscriptionTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) + PercentageDiscount.Filter.builder() + .field( + PercentageDiscount.Filter.Field.PRICE_ID + ) .operator( - TransformPriceFilter.Operator.INCLUDES + PercentageDiscount.Filter.Operator + .INCLUDES ) .addValue("string") .build() @@ -4850,11 +4921,9 @@ internal class MutatedSubscriptionTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -4866,11 +4935,9 @@ internal class MutatedSubscriptionTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -4898,10 +4965,14 @@ internal class MutatedSubscriptionTest { .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) + Price.Unit.CompositePriceFilter.builder() + .field( + Price.Unit.CompositePriceFilter.Field + .PRICE_ID + ) .operator( - TransformPriceFilter.Operator.INCLUDES + Price.Unit.CompositePriceFilter.Operator + .INCLUDES ) .addValue("string") .build() @@ -4941,13 +5012,14 @@ internal class MutatedSubscriptionTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() + PercentageDiscount.Filter.builder() .field( - TransformPriceFilter.Field + PercentageDiscount.Filter.Field .PRICE_ID ) .operator( - TransformPriceFilter.Operator + PercentageDiscount.Filter + .Operator .INCLUDES ) .addValue("string") @@ -4974,14 +5046,12 @@ internal class MutatedSubscriptionTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() + Maximum.Filter.builder() .field( - TransformPriceFilter.Field - .PRICE_ID + Maximum.Filter.Field.PRICE_ID ) .operator( - TransformPriceFilter.Operator - .INCLUDES + Maximum.Filter.Operator.INCLUDES ) .addValue("string") .build() @@ -5002,14 +5072,12 @@ internal class MutatedSubscriptionTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() + Minimum.Filter.builder() .field( - TransformPriceFilter.Field - .PRICE_ID + Minimum.Filter.Field.PRICE_ID ) .operator( - TransformPriceFilter.Operator - .INCLUDES + Minimum.Filter.Operator.INCLUDES ) .addValue("string") .build() @@ -5076,9 +5144,9 @@ internal class MutatedSubscriptionTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -5096,9 +5164,9 @@ internal class MutatedSubscriptionTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewAmountDiscountTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewAmountDiscountTest.kt index 41ff51be5..c93ed9f39 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewAmountDiscountTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewAmountDiscountTest.kt @@ -22,9 +22,9 @@ internal class NewAmountDiscountTest { .addAppliesToPriceId("price_2") .currency("currency") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + NewAmountDiscount.Filter.builder() + .field(NewAmountDiscount.Filter.Field.PRICE_ID) + .operator(NewAmountDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -41,9 +41,9 @@ internal class NewAmountDiscountTest { assertThat(newAmountDiscount.currency()).isEqualTo("currency") assertThat(newAmountDiscount.filters()) .containsExactly( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + NewAmountDiscount.Filter.builder() + .field(NewAmountDiscount.Filter.Field.PRICE_ID) + .operator(NewAmountDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -65,9 +65,9 @@ internal class NewAmountDiscountTest { .addAppliesToPriceId("price_2") .currency("currency") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + NewAmountDiscount.Filter.builder() + .field(NewAmountDiscount.Filter.Field.PRICE_ID) + .operator(NewAmountDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewMaximumTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewMaximumTest.kt index 712322afe..a16ed798d 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewMaximumTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewMaximumTest.kt @@ -22,9 +22,9 @@ internal class NewMaximumTest { .addAppliesToPriceId("price_2") .currency("currency") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + NewMaximum.Filter.builder() + .field(NewMaximum.Filter.Field.PRICE_ID) + .operator(NewMaximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -40,9 +40,9 @@ internal class NewMaximumTest { assertThat(newMaximum.currency()).isEqualTo("currency") assertThat(newMaximum.filters()) .containsExactly( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + NewMaximum.Filter.builder() + .field(NewMaximum.Filter.Field.PRICE_ID) + .operator(NewMaximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -64,9 +64,9 @@ internal class NewMaximumTest { .addAppliesToPriceId("price_2") .currency("currency") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + NewMaximum.Filter.builder() + .field(NewMaximum.Filter.Field.PRICE_ID) + .operator(NewMaximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewMinimumTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewMinimumTest.kt index 83f59818d..573a860dd 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewMinimumTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewMinimumTest.kt @@ -23,9 +23,9 @@ internal class NewMinimumTest { .addAppliesToPriceId("price_2") .currency("currency") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + NewMinimum.Filter.builder() + .field(NewMinimum.Filter.Field.PRICE_ID) + .operator(NewMinimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -42,9 +42,9 @@ internal class NewMinimumTest { assertThat(newMinimum.currency()).isEqualTo("currency") assertThat(newMinimum.filters()) .containsExactly( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + NewMinimum.Filter.builder() + .field(NewMinimum.Filter.Field.PRICE_ID) + .operator(NewMinimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -67,9 +67,9 @@ internal class NewMinimumTest { .addAppliesToPriceId("price_2") .currency("currency") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + NewMinimum.Filter.builder() + .field(NewMinimum.Filter.Field.PRICE_ID) + .operator(NewMinimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPercentageDiscountTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPercentageDiscountTest.kt index ed131c8dd..7ba4d8dcb 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPercentageDiscountTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPercentageDiscountTest.kt @@ -22,9 +22,9 @@ internal class NewPercentageDiscountTest { .addAppliesToPriceId("price_2") .currency("currency") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + NewPercentageDiscount.Filter.builder() + .field(NewPercentageDiscount.Filter.Field.PRICE_ID) + .operator(NewPercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -42,9 +42,9 @@ internal class NewPercentageDiscountTest { assertThat(newPercentageDiscount.currency()).isEqualTo("currency") assertThat(newPercentageDiscount.filters()) .containsExactly( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + NewPercentageDiscount.Filter.builder() + .field(NewPercentageDiscount.Filter.Field.PRICE_ID) + .operator(NewPercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -67,9 +67,9 @@ internal class NewPercentageDiscountTest { .addAppliesToPriceId("price_2") .currency("currency") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + NewPercentageDiscount.Filter.builder() + .field(NewPercentageDiscount.Filter.Field.PRICE_ID) + .operator(NewPercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewUsageDiscountTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewUsageDiscountTest.kt index 9e3756157..1d60c49a2 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewUsageDiscountTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewUsageDiscountTest.kt @@ -22,9 +22,9 @@ internal class NewUsageDiscountTest { .addAppliesToPriceId("price_2") .currency("currency") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + NewUsageDiscount.Filter.builder() + .field(NewUsageDiscount.Filter.Field.PRICE_ID) + .operator(NewUsageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -41,9 +41,9 @@ internal class NewUsageDiscountTest { assertThat(newUsageDiscount.currency()).isEqualTo("currency") assertThat(newUsageDiscount.filters()) .containsExactly( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + NewUsageDiscount.Filter.builder() + .field(NewUsageDiscount.Filter.Field.PRICE_ID) + .operator(NewUsageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -65,9 +65,9 @@ internal class NewUsageDiscountTest { .addAppliesToPriceId("price_2") .currency("currency") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + NewUsageDiscount.Filter.builder() + .field(NewUsageDiscount.Filter.Field.PRICE_ID) + .operator(NewUsageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PerPriceCostTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PerPriceCostTest.kt index b1d2cd01c..b7b01dc8f 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PerPriceCostTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PerPriceCostTest.kt @@ -28,9 +28,9 @@ internal class PerPriceCostTest { .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Price.Unit.CompositePriceFilter.builder() + .field(Price.Unit.CompositePriceFilter.Field.PRICE_ID) + .operator(Price.Unit.CompositePriceFilter.Operator.INCLUDES) .addValue("string") .build() ) @@ -59,9 +59,9 @@ internal class PerPriceCostTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -81,9 +81,9 @@ internal class PerPriceCostTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -100,9 +100,9 @@ internal class PerPriceCostTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -144,9 +144,9 @@ internal class PerPriceCostTest { .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Price.Unit.CompositePriceFilter.builder() + .field(Price.Unit.CompositePriceFilter.Field.PRICE_ID) + .operator(Price.Unit.CompositePriceFilter.Operator.INCLUDES) .addValue("string") .build() ) @@ -175,9 +175,9 @@ internal class PerPriceCostTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -197,9 +197,9 @@ internal class PerPriceCostTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -216,9 +216,9 @@ internal class PerPriceCostTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -264,9 +264,9 @@ internal class PerPriceCostTest { .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Price.Unit.CompositePriceFilter.builder() + .field(Price.Unit.CompositePriceFilter.Field.PRICE_ID) + .operator(Price.Unit.CompositePriceFilter.Operator.INCLUDES) .addValue("string") .build() ) @@ -295,9 +295,9 @@ internal class PerPriceCostTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -317,9 +317,9 @@ internal class PerPriceCostTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -336,9 +336,9 @@ internal class PerPriceCostTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PercentageDiscountIntervalTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PercentageDiscountIntervalTest.kt index 68e6bacc1..35dc5a244 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PercentageDiscountIntervalTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PercentageDiscountIntervalTest.kt @@ -18,9 +18,9 @@ internal class PercentageDiscountIntervalTest { .discountType(PercentageDiscountInterval.DiscountType.PERCENTAGE) .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscountInterval.Filter.builder() + .field(PercentageDiscountInterval.Filter.Field.PRICE_ID) + .operator(PercentageDiscountInterval.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -35,9 +35,9 @@ internal class PercentageDiscountIntervalTest { .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) assertThat(percentageDiscountInterval.filters()) .containsExactly( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscountInterval.Filter.builder() + .field(PercentageDiscountInterval.Filter.Field.PRICE_ID) + .operator(PercentageDiscountInterval.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -55,9 +55,9 @@ internal class PercentageDiscountIntervalTest { .discountType(PercentageDiscountInterval.DiscountType.PERCENTAGE) .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscountInterval.Filter.builder() + .field(PercentageDiscountInterval.Filter.Field.PRICE_ID) + .operator(PercentageDiscountInterval.Filter.Operator.INCLUDES) .addValue("string") .build() ) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PercentageDiscountTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PercentageDiscountTest.kt index bbd801afd..eb2a72463 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PercentageDiscountTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PercentageDiscountTest.kt @@ -18,9 +18,9 @@ internal class PercentageDiscountTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -34,9 +34,9 @@ internal class PercentageDiscountTest { .containsExactly("h74gfhdjvn7ujokd", "7hfgtgjnbvc3ujkl") assertThat(percentageDiscount.filters()) .containsExactly( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -53,9 +53,9 @@ internal class PercentageDiscountTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanCreateParamsTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanCreateParamsTest.kt index a10615880..513f93689 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanCreateParamsTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanCreateParamsTest.kt @@ -93,9 +93,9 @@ internal class PlanCreateParamsTest { .addAppliesToPriceId("price_2") .currency("currency") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + NewPercentageDiscount.Filter.builder() + .field(NewPercentageDiscount.Filter.Field.PRICE_ID) + .operator(NewPercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -214,9 +214,9 @@ internal class PlanCreateParamsTest { .addAppliesToPriceId("price_2") .currency("currency") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + NewPercentageDiscount.Filter.builder() + .field(NewPercentageDiscount.Filter.Field.PRICE_ID) + .operator(NewPercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -332,9 +332,9 @@ internal class PlanCreateParamsTest { .addAppliesToPriceId("price_2") .currency("currency") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + NewPercentageDiscount.Filter.builder() + .field(NewPercentageDiscount.Filter.Field.PRICE_ID) + .operator(NewPercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanListPageResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanListPageResponseTest.kt index 7e8669f24..3b82b2aa9 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanListPageResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanListPageResponseTest.kt @@ -26,9 +26,14 @@ internal class PlanListPageResponseTest { ) .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PlanPhaseUsageDiscountAdjustment.Filter.builder() + .field( + PlanPhaseUsageDiscountAdjustment.Filter.Field.PRICE_ID + ) + .operator( + PlanPhaseUsageDiscountAdjustment.Filter.Operator + .INCLUDES + ) .addValue("string") .build() ) @@ -58,9 +63,9 @@ internal class PlanListPageResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -73,9 +78,9 @@ internal class PlanListPageResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -92,9 +97,9 @@ internal class PlanListPageResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -115,9 +120,11 @@ internal class PlanListPageResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator( + PercentageDiscount.Filter.Operator.INCLUDES + ) .addValue("string") .build() ) @@ -130,9 +137,9 @@ internal class PlanListPageResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -144,9 +151,9 @@ internal class PlanListPageResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -171,9 +178,9 @@ internal class PlanListPageResponseTest { .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Price.Unit.CompositePriceFilter.builder() + .field(Price.Unit.CompositePriceFilter.Field.PRICE_ID) + .operator(Price.Unit.CompositePriceFilter.Operator.INCLUDES) .addValue("string") .build() ) @@ -204,9 +211,11 @@ internal class PlanListPageResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator( + PercentageDiscount.Filter.Operator.INCLUDES + ) .addValue("string") .build() ) @@ -226,9 +235,9 @@ internal class PlanListPageResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -245,9 +254,9 @@ internal class PlanListPageResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -302,9 +311,11 @@ internal class PlanListPageResponseTest { ) .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PlanPhaseUsageDiscountAdjustment.Filter.builder() + .field(PlanPhaseUsageDiscountAdjustment.Filter.Field.PRICE_ID) + .operator( + PlanPhaseUsageDiscountAdjustment.Filter.Operator.INCLUDES + ) .addValue("string") .build() ) @@ -334,9 +345,9 @@ internal class PlanListPageResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -349,9 +360,9 @@ internal class PlanListPageResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -368,9 +379,9 @@ internal class PlanListPageResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -391,9 +402,9 @@ internal class PlanListPageResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -406,9 +417,9 @@ internal class PlanListPageResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -420,9 +431,9 @@ internal class PlanListPageResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -447,9 +458,9 @@ internal class PlanListPageResponseTest { .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Price.Unit.CompositePriceFilter.builder() + .field(Price.Unit.CompositePriceFilter.Field.PRICE_ID) + .operator(Price.Unit.CompositePriceFilter.Operator.INCLUDES) .addValue("string") .build() ) @@ -478,9 +489,9 @@ internal class PlanListPageResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -500,9 +511,9 @@ internal class PlanListPageResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -519,9 +530,9 @@ internal class PlanListPageResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -579,9 +590,14 @@ internal class PlanListPageResponseTest { ) .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PlanPhaseUsageDiscountAdjustment.Filter.builder() + .field( + PlanPhaseUsageDiscountAdjustment.Filter.Field.PRICE_ID + ) + .operator( + PlanPhaseUsageDiscountAdjustment.Filter.Operator + .INCLUDES + ) .addValue("string") .build() ) @@ -611,9 +627,9 @@ internal class PlanListPageResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -626,9 +642,9 @@ internal class PlanListPageResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -645,9 +661,9 @@ internal class PlanListPageResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -668,9 +684,11 @@ internal class PlanListPageResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator( + PercentageDiscount.Filter.Operator.INCLUDES + ) .addValue("string") .build() ) @@ -683,9 +701,9 @@ internal class PlanListPageResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -697,9 +715,9 @@ internal class PlanListPageResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -724,9 +742,9 @@ internal class PlanListPageResponseTest { .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Price.Unit.CompositePriceFilter.builder() + .field(Price.Unit.CompositePriceFilter.Field.PRICE_ID) + .operator(Price.Unit.CompositePriceFilter.Operator.INCLUDES) .addValue("string") .build() ) @@ -757,9 +775,11 @@ internal class PlanListPageResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator( + PercentageDiscount.Filter.Operator.INCLUDES + ) .addValue("string") .build() ) @@ -779,9 +799,9 @@ internal class PlanListPageResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -798,9 +818,9 @@ internal class PlanListPageResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanPhaseAmountDiscountAdjustmentTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanPhaseAmountDiscountAdjustmentTest.kt index c517b6dc4..08189a45e 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanPhaseAmountDiscountAdjustmentTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanPhaseAmountDiscountAdjustmentTest.kt @@ -18,9 +18,9 @@ internal class PlanPhaseAmountDiscountAdjustmentTest { .amountDiscount("amount_discount") .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PlanPhaseAmountDiscountAdjustment.Filter.builder() + .field(PlanPhaseAmountDiscountAdjustment.Filter.Field.PRICE_ID) + .operator(PlanPhaseAmountDiscountAdjustment.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -37,9 +37,9 @@ internal class PlanPhaseAmountDiscountAdjustmentTest { assertThat(planPhaseAmountDiscountAdjustment.appliesToPriceIds()).containsExactly("string") assertThat(planPhaseAmountDiscountAdjustment.filters()) .containsExactly( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PlanPhaseAmountDiscountAdjustment.Filter.builder() + .field(PlanPhaseAmountDiscountAdjustment.Filter.Field.PRICE_ID) + .operator(PlanPhaseAmountDiscountAdjustment.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -60,9 +60,9 @@ internal class PlanPhaseAmountDiscountAdjustmentTest { .amountDiscount("amount_discount") .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PlanPhaseAmountDiscountAdjustment.Filter.builder() + .field(PlanPhaseAmountDiscountAdjustment.Filter.Field.PRICE_ID) + .operator(PlanPhaseAmountDiscountAdjustment.Filter.Operator.INCLUDES) .addValue("string") .build() ) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanPhaseMaximumAdjustmentTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanPhaseMaximumAdjustmentTest.kt index 207be4844..4208f22f1 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanPhaseMaximumAdjustmentTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanPhaseMaximumAdjustmentTest.kt @@ -17,9 +17,9 @@ internal class PlanPhaseMaximumAdjustmentTest { .adjustmentType(PlanPhaseMaximumAdjustment.AdjustmentType.MAXIMUM) .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PlanPhaseMaximumAdjustment.Filter.builder() + .field(PlanPhaseMaximumAdjustment.Filter.Field.PRICE_ID) + .operator(PlanPhaseMaximumAdjustment.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -36,9 +36,9 @@ internal class PlanPhaseMaximumAdjustmentTest { assertThat(planPhaseMaximumAdjustment.appliesToPriceIds()).containsExactly("string") assertThat(planPhaseMaximumAdjustment.filters()) .containsExactly( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PlanPhaseMaximumAdjustment.Filter.builder() + .field(PlanPhaseMaximumAdjustment.Filter.Field.PRICE_ID) + .operator(PlanPhaseMaximumAdjustment.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -59,9 +59,9 @@ internal class PlanPhaseMaximumAdjustmentTest { .adjustmentType(PlanPhaseMaximumAdjustment.AdjustmentType.MAXIMUM) .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PlanPhaseMaximumAdjustment.Filter.builder() + .field(PlanPhaseMaximumAdjustment.Filter.Field.PRICE_ID) + .operator(PlanPhaseMaximumAdjustment.Filter.Operator.INCLUDES) .addValue("string") .build() ) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanPhaseMinimumAdjustmentTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanPhaseMinimumAdjustmentTest.kt index 7e8b11db1..b6e6f1e84 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanPhaseMinimumAdjustmentTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanPhaseMinimumAdjustmentTest.kt @@ -17,9 +17,9 @@ internal class PlanPhaseMinimumAdjustmentTest { .adjustmentType(PlanPhaseMinimumAdjustment.AdjustmentType.MINIMUM) .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PlanPhaseMinimumAdjustment.Filter.builder() + .field(PlanPhaseMinimumAdjustment.Filter.Field.PRICE_ID) + .operator(PlanPhaseMinimumAdjustment.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -37,9 +37,9 @@ internal class PlanPhaseMinimumAdjustmentTest { assertThat(planPhaseMinimumAdjustment.appliesToPriceIds()).containsExactly("string") assertThat(planPhaseMinimumAdjustment.filters()) .containsExactly( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PlanPhaseMinimumAdjustment.Filter.builder() + .field(PlanPhaseMinimumAdjustment.Filter.Field.PRICE_ID) + .operator(PlanPhaseMinimumAdjustment.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -61,9 +61,9 @@ internal class PlanPhaseMinimumAdjustmentTest { .adjustmentType(PlanPhaseMinimumAdjustment.AdjustmentType.MINIMUM) .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PlanPhaseMinimumAdjustment.Filter.builder() + .field(PlanPhaseMinimumAdjustment.Filter.Field.PRICE_ID) + .operator(PlanPhaseMinimumAdjustment.Filter.Operator.INCLUDES) .addValue("string") .build() ) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanPhasePercentageDiscountAdjustmentTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanPhasePercentageDiscountAdjustmentTest.kt index c8700e346..6d2e00adc 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanPhasePercentageDiscountAdjustmentTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanPhasePercentageDiscountAdjustmentTest.kt @@ -19,9 +19,9 @@ internal class PlanPhasePercentageDiscountAdjustmentTest { ) .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PlanPhasePercentageDiscountAdjustment.Filter.builder() + .field(PlanPhasePercentageDiscountAdjustment.Filter.Field.PRICE_ID) + .operator(PlanPhasePercentageDiscountAdjustment.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -39,9 +39,9 @@ internal class PlanPhasePercentageDiscountAdjustmentTest { .containsExactly("string") assertThat(planPhasePercentageDiscountAdjustment.filters()) .containsExactly( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PlanPhasePercentageDiscountAdjustment.Filter.builder() + .field(PlanPhasePercentageDiscountAdjustment.Filter.Field.PRICE_ID) + .operator(PlanPhasePercentageDiscountAdjustment.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -64,9 +64,9 @@ internal class PlanPhasePercentageDiscountAdjustmentTest { ) .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PlanPhasePercentageDiscountAdjustment.Filter.builder() + .field(PlanPhasePercentageDiscountAdjustment.Filter.Field.PRICE_ID) + .operator(PlanPhasePercentageDiscountAdjustment.Filter.Operator.INCLUDES) .addValue("string") .build() ) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanPhaseUsageDiscountAdjustmentTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanPhaseUsageDiscountAdjustmentTest.kt index 45fa2142c..b317ab87d 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanPhaseUsageDiscountAdjustmentTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanPhaseUsageDiscountAdjustmentTest.kt @@ -17,9 +17,9 @@ internal class PlanPhaseUsageDiscountAdjustmentTest { .adjustmentType(PlanPhaseUsageDiscountAdjustment.AdjustmentType.USAGE_DISCOUNT) .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PlanPhaseUsageDiscountAdjustment.Filter.builder() + .field(PlanPhaseUsageDiscountAdjustment.Filter.Field.PRICE_ID) + .operator(PlanPhaseUsageDiscountAdjustment.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -36,9 +36,9 @@ internal class PlanPhaseUsageDiscountAdjustmentTest { assertThat(planPhaseUsageDiscountAdjustment.appliesToPriceIds()).containsExactly("string") assertThat(planPhaseUsageDiscountAdjustment.filters()) .containsExactly( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PlanPhaseUsageDiscountAdjustment.Filter.builder() + .field(PlanPhaseUsageDiscountAdjustment.Filter.Field.PRICE_ID) + .operator(PlanPhaseUsageDiscountAdjustment.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -59,9 +59,9 @@ internal class PlanPhaseUsageDiscountAdjustmentTest { .adjustmentType(PlanPhaseUsageDiscountAdjustment.AdjustmentType.USAGE_DISCOUNT) .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PlanPhaseUsageDiscountAdjustment.Filter.builder() + .field(PlanPhaseUsageDiscountAdjustment.Filter.Field.PRICE_ID) + .operator(PlanPhaseUsageDiscountAdjustment.Filter.Operator.INCLUDES) .addValue("string") .build() ) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanTest.kt index 06c2a540e..a0607a557 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanTest.kt @@ -24,9 +24,9 @@ internal class PlanTest { ) .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PlanPhaseUsageDiscountAdjustment.Filter.builder() + .field(PlanPhaseUsageDiscountAdjustment.Filter.Field.PRICE_ID) + .operator(PlanPhaseUsageDiscountAdjustment.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -56,9 +56,9 @@ internal class PlanTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -71,9 +71,9 @@ internal class PlanTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -90,9 +90,9 @@ internal class PlanTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -113,9 +113,9 @@ internal class PlanTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -128,9 +128,9 @@ internal class PlanTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -142,9 +142,9 @@ internal class PlanTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -169,9 +169,9 @@ internal class PlanTest { .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Price.Unit.CompositePriceFilter.builder() + .field(Price.Unit.CompositePriceFilter.Field.PRICE_ID) + .operator(Price.Unit.CompositePriceFilter.Operator.INCLUDES) .addValue("string") .build() ) @@ -200,9 +200,9 @@ internal class PlanTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -222,9 +222,9 @@ internal class PlanTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -241,9 +241,9 @@ internal class PlanTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -292,9 +292,9 @@ internal class PlanTest { ) .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PlanPhaseUsageDiscountAdjustment.Filter.builder() + .field(PlanPhaseUsageDiscountAdjustment.Filter.Field.PRICE_ID) + .operator(PlanPhaseUsageDiscountAdjustment.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -328,9 +328,9 @@ internal class PlanTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -345,9 +345,9 @@ internal class PlanTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -366,9 +366,9 @@ internal class PlanTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -390,9 +390,9 @@ internal class PlanTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -405,9 +405,9 @@ internal class PlanTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -419,9 +419,9 @@ internal class PlanTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -448,9 +448,9 @@ internal class PlanTest { .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Price.Unit.CompositePriceFilter.builder() + .field(Price.Unit.CompositePriceFilter.Field.PRICE_ID) + .operator(Price.Unit.CompositePriceFilter.Operator.INCLUDES) .addValue("string") .build() ) @@ -479,9 +479,9 @@ internal class PlanTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -501,9 +501,9 @@ internal class PlanTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -520,9 +520,9 @@ internal class PlanTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -577,9 +577,9 @@ internal class PlanTest { ) .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PlanPhaseUsageDiscountAdjustment.Filter.builder() + .field(PlanPhaseUsageDiscountAdjustment.Filter.Field.PRICE_ID) + .operator(PlanPhaseUsageDiscountAdjustment.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -609,9 +609,9 @@ internal class PlanTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -624,9 +624,9 @@ internal class PlanTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -643,9 +643,9 @@ internal class PlanTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -666,9 +666,9 @@ internal class PlanTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -681,9 +681,9 @@ internal class PlanTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -695,9 +695,9 @@ internal class PlanTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -722,9 +722,9 @@ internal class PlanTest { .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Price.Unit.CompositePriceFilter.builder() + .field(Price.Unit.CompositePriceFilter.Field.PRICE_ID) + .operator(Price.Unit.CompositePriceFilter.Operator.INCLUDES) .addValue("string") .build() ) @@ -753,9 +753,9 @@ internal class PlanTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -775,9 +775,9 @@ internal class PlanTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -794,9 +794,9 @@ internal class PlanTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanVersionTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanVersionTest.kt index 8ec46f075..37a962bad 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanVersionTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanVersionTest.kt @@ -23,9 +23,9 @@ internal class PlanVersionTest { ) .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PlanPhaseUsageDiscountAdjustment.Filter.builder() + .field(PlanPhaseUsageDiscountAdjustment.Filter.Field.PRICE_ID) + .operator(PlanPhaseUsageDiscountAdjustment.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -60,9 +60,9 @@ internal class PlanVersionTest { .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Price.Unit.CompositePriceFilter.builder() + .field(Price.Unit.CompositePriceFilter.Field.PRICE_ID) + .operator(Price.Unit.CompositePriceFilter.Operator.INCLUDES) .addValue("string") .build() ) @@ -91,9 +91,9 @@ internal class PlanVersionTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -113,9 +113,9 @@ internal class PlanVersionTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -132,9 +132,9 @@ internal class PlanVersionTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -168,9 +168,9 @@ internal class PlanVersionTest { ) .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PlanPhaseUsageDiscountAdjustment.Filter.builder() + .field(PlanPhaseUsageDiscountAdjustment.Filter.Field.PRICE_ID) + .operator(PlanPhaseUsageDiscountAdjustment.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -210,9 +210,9 @@ internal class PlanVersionTest { .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Price.Unit.CompositePriceFilter.builder() + .field(Price.Unit.CompositePriceFilter.Field.PRICE_ID) + .operator(Price.Unit.CompositePriceFilter.Operator.INCLUDES) .addValue("string") .build() ) @@ -241,9 +241,9 @@ internal class PlanVersionTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -263,9 +263,9 @@ internal class PlanVersionTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -282,9 +282,9 @@ internal class PlanVersionTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -322,9 +322,9 @@ internal class PlanVersionTest { ) .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PlanPhaseUsageDiscountAdjustment.Filter.builder() + .field(PlanPhaseUsageDiscountAdjustment.Filter.Field.PRICE_ID) + .operator(PlanPhaseUsageDiscountAdjustment.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -359,9 +359,9 @@ internal class PlanVersionTest { .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Price.Unit.CompositePriceFilter.builder() + .field(Price.Unit.CompositePriceFilter.Field.PRICE_ID) + .operator(Price.Unit.CompositePriceFilter.Operator.INCLUDES) .addValue("string") .build() ) @@ -390,9 +390,9 @@ internal class PlanVersionTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -412,9 +412,9 @@ internal class PlanVersionTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -431,9 +431,9 @@ internal class PlanVersionTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceIntervalTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceIntervalTest.kt index cbb5d6234..46cf26a01 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceIntervalTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceIntervalTest.kt @@ -41,9 +41,9 @@ internal class PriceIntervalTest { .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Price.Unit.CompositePriceFilter.builder() + .field(Price.Unit.CompositePriceFilter.Field.PRICE_ID) + .operator(Price.Unit.CompositePriceFilter.Operator.INCLUDES) .addValue("string") .build() ) @@ -72,9 +72,9 @@ internal class PriceIntervalTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -94,9 +94,9 @@ internal class PriceIntervalTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -113,9 +113,9 @@ internal class PriceIntervalTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -172,9 +172,9 @@ internal class PriceIntervalTest { .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Price.Unit.CompositePriceFilter.builder() + .field(Price.Unit.CompositePriceFilter.Field.PRICE_ID) + .operator(Price.Unit.CompositePriceFilter.Operator.INCLUDES) .addValue("string") .build() ) @@ -203,9 +203,9 @@ internal class PriceIntervalTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -225,9 +225,9 @@ internal class PriceIntervalTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -244,9 +244,9 @@ internal class PriceIntervalTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -304,9 +304,9 @@ internal class PriceIntervalTest { .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Price.Unit.CompositePriceFilter.builder() + .field(Price.Unit.CompositePriceFilter.Field.PRICE_ID) + .operator(Price.Unit.CompositePriceFilter.Operator.INCLUDES) .addValue("string") .build() ) @@ -335,9 +335,9 @@ internal class PriceIntervalTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -357,9 +357,9 @@ internal class PriceIntervalTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -376,9 +376,9 @@ internal class PriceIntervalTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceListPageResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceListPageResponseTest.kt index 70fec704d..f3b1e36fb 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceListPageResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceListPageResponseTest.kt @@ -28,9 +28,9 @@ internal class PriceListPageResponseTest { .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Price.Unit.CompositePriceFilter.builder() + .field(Price.Unit.CompositePriceFilter.Field.PRICE_ID) + .operator(Price.Unit.CompositePriceFilter.Operator.INCLUDES) .addValue("string") .build() ) @@ -59,9 +59,9 @@ internal class PriceListPageResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -81,9 +81,9 @@ internal class PriceListPageResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -100,9 +100,9 @@ internal class PriceListPageResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -143,9 +143,9 @@ internal class PriceListPageResponseTest { .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Price.Unit.CompositePriceFilter.builder() + .field(Price.Unit.CompositePriceFilter.Field.PRICE_ID) + .operator(Price.Unit.CompositePriceFilter.Operator.INCLUDES) .addValue("string") .build() ) @@ -174,9 +174,9 @@ internal class PriceListPageResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -196,9 +196,9 @@ internal class PriceListPageResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -215,9 +215,9 @@ internal class PriceListPageResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -261,9 +261,9 @@ internal class PriceListPageResponseTest { .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Price.Unit.CompositePriceFilter.builder() + .field(Price.Unit.CompositePriceFilter.Field.PRICE_ID) + .operator(Price.Unit.CompositePriceFilter.Operator.INCLUDES) .addValue("string") .build() ) @@ -292,9 +292,9 @@ internal class PriceListPageResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -314,9 +314,9 @@ internal class PriceListPageResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -333,9 +333,9 @@ internal class PriceListPageResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceTest.kt index 42a8033cb..bead3aa0e 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceTest.kt @@ -30,9 +30,9 @@ internal class PriceTest { .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Price.Unit.CompositePriceFilter.builder() + .field(Price.Unit.CompositePriceFilter.Field.PRICE_ID) + .operator(Price.Unit.CompositePriceFilter.Operator.INCLUDES) .addValue("string") .build() ) @@ -61,9 +61,9 @@ internal class PriceTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -83,9 +83,9 @@ internal class PriceTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -102,9 +102,9 @@ internal class PriceTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -176,9 +176,9 @@ internal class PriceTest { .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Price.Unit.CompositePriceFilter.builder() + .field(Price.Unit.CompositePriceFilter.Field.PRICE_ID) + .operator(Price.Unit.CompositePriceFilter.Operator.INCLUDES) .addValue("string") .build() ) @@ -207,9 +207,9 @@ internal class PriceTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -229,9 +229,9 @@ internal class PriceTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -248,9 +248,9 @@ internal class PriceTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -293,9 +293,9 @@ internal class PriceTest { .billingMode(Price.Tiered.BillingMode.IN_ADVANCE) .cadence(Price.Tiered.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Price.Tiered.CompositePriceFilter.builder() + .field(Price.Tiered.CompositePriceFilter.Field.PRICE_ID) + .operator(Price.Tiered.CompositePriceFilter.Operator.INCLUDES) .addValue("string") .build() ) @@ -324,9 +324,9 @@ internal class PriceTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -346,9 +346,9 @@ internal class PriceTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -365,9 +365,9 @@ internal class PriceTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -449,9 +449,9 @@ internal class PriceTest { .billingMode(Price.Tiered.BillingMode.IN_ADVANCE) .cadence(Price.Tiered.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Price.Tiered.CompositePriceFilter.builder() + .field(Price.Tiered.CompositePriceFilter.Field.PRICE_ID) + .operator(Price.Tiered.CompositePriceFilter.Operator.INCLUDES) .addValue("string") .build() ) @@ -480,9 +480,9 @@ internal class PriceTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -502,9 +502,9 @@ internal class PriceTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -521,9 +521,9 @@ internal class PriceTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -583,9 +583,9 @@ internal class PriceTest { ) .cadence(Price.Bulk.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Price.Bulk.CompositePriceFilter.builder() + .field(Price.Bulk.CompositePriceFilter.Field.PRICE_ID) + .operator(Price.Bulk.CompositePriceFilter.Operator.INCLUDES) .addValue("string") .build() ) @@ -614,9 +614,9 @@ internal class PriceTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -636,9 +636,9 @@ internal class PriceTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -655,9 +655,9 @@ internal class PriceTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -738,9 +738,9 @@ internal class PriceTest { ) .cadence(Price.Bulk.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Price.Bulk.CompositePriceFilter.builder() + .field(Price.Bulk.CompositePriceFilter.Field.PRICE_ID) + .operator(Price.Bulk.CompositePriceFilter.Operator.INCLUDES) .addValue("string") .build() ) @@ -769,9 +769,9 @@ internal class PriceTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -791,9 +791,9 @@ internal class PriceTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -810,9 +810,9 @@ internal class PriceTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -876,9 +876,9 @@ internal class PriceTest { ) .cadence(Price.BulkWithFilters.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Price.BulkWithFilters.CompositePriceFilter.builder() + .field(Price.BulkWithFilters.CompositePriceFilter.Field.PRICE_ID) + .operator(Price.BulkWithFilters.CompositePriceFilter.Operator.INCLUDES) .addValue("string") .build() ) @@ -907,9 +907,9 @@ internal class PriceTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -929,9 +929,9 @@ internal class PriceTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -948,9 +948,9 @@ internal class PriceTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -1043,9 +1043,9 @@ internal class PriceTest { ) .cadence(Price.BulkWithFilters.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Price.BulkWithFilters.CompositePriceFilter.builder() + .field(Price.BulkWithFilters.CompositePriceFilter.Field.PRICE_ID) + .operator(Price.BulkWithFilters.CompositePriceFilter.Operator.INCLUDES) .addValue("string") .build() ) @@ -1074,9 +1074,9 @@ internal class PriceTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -1096,9 +1096,9 @@ internal class PriceTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -1115,9 +1115,9 @@ internal class PriceTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -1159,9 +1159,9 @@ internal class PriceTest { .billingMode(Price.Package.BillingMode.IN_ADVANCE) .cadence(Price.Package.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Price.Package.CompositePriceFilter.builder() + .field(Price.Package.CompositePriceFilter.Field.PRICE_ID) + .operator(Price.Package.CompositePriceFilter.Operator.INCLUDES) .addValue("string") .build() ) @@ -1190,9 +1190,9 @@ internal class PriceTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -1212,9 +1212,9 @@ internal class PriceTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -1231,9 +1231,9 @@ internal class PriceTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -1307,9 +1307,9 @@ internal class PriceTest { .billingMode(Price.Package.BillingMode.IN_ADVANCE) .cadence(Price.Package.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Price.Package.CompositePriceFilter.builder() + .field(Price.Package.CompositePriceFilter.Field.PRICE_ID) + .operator(Price.Package.CompositePriceFilter.Operator.INCLUDES) .addValue("string") .build() ) @@ -1338,9 +1338,9 @@ internal class PriceTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -1360,9 +1360,9 @@ internal class PriceTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -1379,9 +1379,9 @@ internal class PriceTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -1429,9 +1429,9 @@ internal class PriceTest { .billingMode(Price.Matrix.BillingMode.IN_ADVANCE) .cadence(Price.Matrix.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Price.Matrix.CompositePriceFilter.builder() + .field(Price.Matrix.CompositePriceFilter.Field.PRICE_ID) + .operator(Price.Matrix.CompositePriceFilter.Operator.INCLUDES) .addValue("string") .build() ) @@ -1460,9 +1460,9 @@ internal class PriceTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -1494,9 +1494,9 @@ internal class PriceTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -1513,9 +1513,9 @@ internal class PriceTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -1586,9 +1586,9 @@ internal class PriceTest { .billingMode(Price.Matrix.BillingMode.IN_ADVANCE) .cadence(Price.Matrix.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Price.Matrix.CompositePriceFilter.builder() + .field(Price.Matrix.CompositePriceFilter.Field.PRICE_ID) + .operator(Price.Matrix.CompositePriceFilter.Operator.INCLUDES) .addValue("string") .build() ) @@ -1617,9 +1617,9 @@ internal class PriceTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -1651,9 +1651,9 @@ internal class PriceTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -1670,9 +1670,9 @@ internal class PriceTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -1714,9 +1714,9 @@ internal class PriceTest { .billingMode(Price.ThresholdTotalAmount.BillingMode.IN_ADVANCE) .cadence(Price.ThresholdTotalAmount.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Price.ThresholdTotalAmount.CompositePriceFilter.builder() + .field(Price.ThresholdTotalAmount.CompositePriceFilter.Field.PRICE_ID) + .operator(Price.ThresholdTotalAmount.CompositePriceFilter.Operator.INCLUDES) .addValue("string") .build() ) @@ -1745,9 +1745,9 @@ internal class PriceTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -1767,9 +1767,9 @@ internal class PriceTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -1786,9 +1786,9 @@ internal class PriceTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -1878,9 +1878,11 @@ internal class PriceTest { .billingMode(Price.ThresholdTotalAmount.BillingMode.IN_ADVANCE) .cadence(Price.ThresholdTotalAmount.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Price.ThresholdTotalAmount.CompositePriceFilter.builder() + .field(Price.ThresholdTotalAmount.CompositePriceFilter.Field.PRICE_ID) + .operator( + Price.ThresholdTotalAmount.CompositePriceFilter.Operator.INCLUDES + ) .addValue("string") .build() ) @@ -1909,9 +1911,9 @@ internal class PriceTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -1931,9 +1933,9 @@ internal class PriceTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -1950,9 +1952,9 @@ internal class PriceTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -2015,9 +2017,9 @@ internal class PriceTest { .billingMode(Price.TieredPackage.BillingMode.IN_ADVANCE) .cadence(Price.TieredPackage.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Price.TieredPackage.CompositePriceFilter.builder() + .field(Price.TieredPackage.CompositePriceFilter.Field.PRICE_ID) + .operator(Price.TieredPackage.CompositePriceFilter.Operator.INCLUDES) .addValue("string") .build() ) @@ -2046,9 +2048,9 @@ internal class PriceTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -2068,9 +2070,9 @@ internal class PriceTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -2087,9 +2089,9 @@ internal class PriceTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -2177,9 +2179,9 @@ internal class PriceTest { .billingMode(Price.TieredPackage.BillingMode.IN_ADVANCE) .cadence(Price.TieredPackage.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Price.TieredPackage.CompositePriceFilter.builder() + .field(Price.TieredPackage.CompositePriceFilter.Field.PRICE_ID) + .operator(Price.TieredPackage.CompositePriceFilter.Operator.INCLUDES) .addValue("string") .build() ) @@ -2208,9 +2210,9 @@ internal class PriceTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -2230,9 +2232,9 @@ internal class PriceTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -2249,9 +2251,9 @@ internal class PriceTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -2310,9 +2312,9 @@ internal class PriceTest { .billingMode(Price.TieredWithMinimum.BillingMode.IN_ADVANCE) .cadence(Price.TieredWithMinimum.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Price.TieredWithMinimum.CompositePriceFilter.builder() + .field(Price.TieredWithMinimum.CompositePriceFilter.Field.PRICE_ID) + .operator(Price.TieredWithMinimum.CompositePriceFilter.Operator.INCLUDES) .addValue("string") .build() ) @@ -2341,9 +2343,9 @@ internal class PriceTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -2363,9 +2365,9 @@ internal class PriceTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -2382,9 +2384,9 @@ internal class PriceTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -2475,9 +2477,11 @@ internal class PriceTest { .billingMode(Price.TieredWithMinimum.BillingMode.IN_ADVANCE) .cadence(Price.TieredWithMinimum.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Price.TieredWithMinimum.CompositePriceFilter.builder() + .field(Price.TieredWithMinimum.CompositePriceFilter.Field.PRICE_ID) + .operator( + Price.TieredWithMinimum.CompositePriceFilter.Operator.INCLUDES + ) .addValue("string") .build() ) @@ -2506,9 +2510,9 @@ internal class PriceTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -2528,9 +2532,9 @@ internal class PriceTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -2547,9 +2551,9 @@ internal class PriceTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -2611,9 +2615,9 @@ internal class PriceTest { .billingMode(Price.GroupedTiered.BillingMode.IN_ADVANCE) .cadence(Price.GroupedTiered.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Price.GroupedTiered.CompositePriceFilter.builder() + .field(Price.GroupedTiered.CompositePriceFilter.Field.PRICE_ID) + .operator(Price.GroupedTiered.CompositePriceFilter.Operator.INCLUDES) .addValue("string") .build() ) @@ -2642,9 +2646,9 @@ internal class PriceTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -2681,9 +2685,9 @@ internal class PriceTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -2700,9 +2704,9 @@ internal class PriceTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -2773,9 +2777,9 @@ internal class PriceTest { .billingMode(Price.GroupedTiered.BillingMode.IN_ADVANCE) .cadence(Price.GroupedTiered.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Price.GroupedTiered.CompositePriceFilter.builder() + .field(Price.GroupedTiered.CompositePriceFilter.Field.PRICE_ID) + .operator(Price.GroupedTiered.CompositePriceFilter.Operator.INCLUDES) .addValue("string") .build() ) @@ -2804,9 +2808,9 @@ internal class PriceTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -2843,9 +2847,9 @@ internal class PriceTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -2862,9 +2866,9 @@ internal class PriceTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -2906,9 +2910,11 @@ internal class PriceTest { .billingMode(Price.TieredPackageWithMinimum.BillingMode.IN_ADVANCE) .cadence(Price.TieredPackageWithMinimum.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Price.TieredPackageWithMinimum.CompositePriceFilter.builder() + .field(Price.TieredPackageWithMinimum.CompositePriceFilter.Field.PRICE_ID) + .operator( + Price.TieredPackageWithMinimum.CompositePriceFilter.Operator.INCLUDES + ) .addValue("string") .build() ) @@ -2937,9 +2943,9 @@ internal class PriceTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -2959,9 +2965,9 @@ internal class PriceTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -2978,9 +2984,9 @@ internal class PriceTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -3072,9 +3078,14 @@ internal class PriceTest { .billingMode(Price.TieredPackageWithMinimum.BillingMode.IN_ADVANCE) .cadence(Price.TieredPackageWithMinimum.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Price.TieredPackageWithMinimum.CompositePriceFilter.builder() + .field( + Price.TieredPackageWithMinimum.CompositePriceFilter.Field.PRICE_ID + ) + .operator( + Price.TieredPackageWithMinimum.CompositePriceFilter.Operator + .INCLUDES + ) .addValue("string") .build() ) @@ -3103,9 +3114,9 @@ internal class PriceTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -3125,9 +3136,9 @@ internal class PriceTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -3144,9 +3155,9 @@ internal class PriceTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -3209,9 +3220,11 @@ internal class PriceTest { .billingMode(Price.PackageWithAllocation.BillingMode.IN_ADVANCE) .cadence(Price.PackageWithAllocation.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Price.PackageWithAllocation.CompositePriceFilter.builder() + .field(Price.PackageWithAllocation.CompositePriceFilter.Field.PRICE_ID) + .operator( + Price.PackageWithAllocation.CompositePriceFilter.Operator.INCLUDES + ) .addValue("string") .build() ) @@ -3240,9 +3253,9 @@ internal class PriceTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -3262,9 +3275,9 @@ internal class PriceTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -3281,9 +3294,9 @@ internal class PriceTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -3361,9 +3374,11 @@ internal class PriceTest { .billingMode(Price.PackageWithAllocation.BillingMode.IN_ADVANCE) .cadence(Price.PackageWithAllocation.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Price.PackageWithAllocation.CompositePriceFilter.builder() + .field(Price.PackageWithAllocation.CompositePriceFilter.Field.PRICE_ID) + .operator( + Price.PackageWithAllocation.CompositePriceFilter.Operator.INCLUDES + ) .addValue("string") .build() ) @@ -3392,9 +3407,9 @@ internal class PriceTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -3414,9 +3429,9 @@ internal class PriceTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -3433,9 +3448,9 @@ internal class PriceTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -3484,9 +3499,9 @@ internal class PriceTest { .billingMode(Price.UnitWithPercent.BillingMode.IN_ADVANCE) .cadence(Price.UnitWithPercent.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Price.UnitWithPercent.CompositePriceFilter.builder() + .field(Price.UnitWithPercent.CompositePriceFilter.Field.PRICE_ID) + .operator(Price.UnitWithPercent.CompositePriceFilter.Operator.INCLUDES) .addValue("string") .build() ) @@ -3515,9 +3530,9 @@ internal class PriceTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -3537,9 +3552,9 @@ internal class PriceTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -3556,9 +3571,9 @@ internal class PriceTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -3635,9 +3650,9 @@ internal class PriceTest { .billingMode(Price.UnitWithPercent.BillingMode.IN_ADVANCE) .cadence(Price.UnitWithPercent.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Price.UnitWithPercent.CompositePriceFilter.builder() + .field(Price.UnitWithPercent.CompositePriceFilter.Field.PRICE_ID) + .operator(Price.UnitWithPercent.CompositePriceFilter.Operator.INCLUDES) .addValue("string") .build() ) @@ -3666,9 +3681,9 @@ internal class PriceTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -3688,9 +3703,9 @@ internal class PriceTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -3707,9 +3722,9 @@ internal class PriceTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -3757,9 +3772,9 @@ internal class PriceTest { .billingMode(Price.MatrixWithAllocation.BillingMode.IN_ADVANCE) .cadence(Price.MatrixWithAllocation.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Price.MatrixWithAllocation.CompositePriceFilter.builder() + .field(Price.MatrixWithAllocation.CompositePriceFilter.Field.PRICE_ID) + .operator(Price.MatrixWithAllocation.CompositePriceFilter.Operator.INCLUDES) .addValue("string") .build() ) @@ -3788,9 +3803,9 @@ internal class PriceTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -3823,9 +3838,9 @@ internal class PriceTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -3842,9 +3857,9 @@ internal class PriceTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -3915,9 +3930,11 @@ internal class PriceTest { .billingMode(Price.MatrixWithAllocation.BillingMode.IN_ADVANCE) .cadence(Price.MatrixWithAllocation.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Price.MatrixWithAllocation.CompositePriceFilter.builder() + .field(Price.MatrixWithAllocation.CompositePriceFilter.Field.PRICE_ID) + .operator( + Price.MatrixWithAllocation.CompositePriceFilter.Operator.INCLUDES + ) .addValue("string") .build() ) @@ -3946,9 +3963,9 @@ internal class PriceTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -3981,9 +3998,9 @@ internal class PriceTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -4000,9 +4017,9 @@ internal class PriceTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -4044,9 +4061,9 @@ internal class PriceTest { .billingMode(Price.TieredWithProration.BillingMode.IN_ADVANCE) .cadence(Price.TieredWithProration.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Price.TieredWithProration.CompositePriceFilter.builder() + .field(Price.TieredWithProration.CompositePriceFilter.Field.PRICE_ID) + .operator(Price.TieredWithProration.CompositePriceFilter.Operator.INCLUDES) .addValue("string") .build() ) @@ -4075,9 +4092,9 @@ internal class PriceTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -4097,9 +4114,9 @@ internal class PriceTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -4116,9 +4133,9 @@ internal class PriceTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -4199,9 +4216,11 @@ internal class PriceTest { .billingMode(Price.TieredWithProration.BillingMode.IN_ADVANCE) .cadence(Price.TieredWithProration.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Price.TieredWithProration.CompositePriceFilter.builder() + .field(Price.TieredWithProration.CompositePriceFilter.Field.PRICE_ID) + .operator( + Price.TieredWithProration.CompositePriceFilter.Operator.INCLUDES + ) .addValue("string") .build() ) @@ -4230,9 +4249,9 @@ internal class PriceTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -4252,9 +4271,9 @@ internal class PriceTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -4271,9 +4290,9 @@ internal class PriceTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -4325,9 +4344,9 @@ internal class PriceTest { .billingMode(Price.UnitWithProration.BillingMode.IN_ADVANCE) .cadence(Price.UnitWithProration.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Price.UnitWithProration.CompositePriceFilter.builder() + .field(Price.UnitWithProration.CompositePriceFilter.Field.PRICE_ID) + .operator(Price.UnitWithProration.CompositePriceFilter.Operator.INCLUDES) .addValue("string") .build() ) @@ -4356,9 +4375,9 @@ internal class PriceTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -4378,9 +4397,9 @@ internal class PriceTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -4397,9 +4416,9 @@ internal class PriceTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -4475,9 +4494,11 @@ internal class PriceTest { .billingMode(Price.UnitWithProration.BillingMode.IN_ADVANCE) .cadence(Price.UnitWithProration.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Price.UnitWithProration.CompositePriceFilter.builder() + .field(Price.UnitWithProration.CompositePriceFilter.Field.PRICE_ID) + .operator( + Price.UnitWithProration.CompositePriceFilter.Operator.INCLUDES + ) .addValue("string") .build() ) @@ -4506,9 +4527,9 @@ internal class PriceTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -4528,9 +4549,9 @@ internal class PriceTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -4547,9 +4568,9 @@ internal class PriceTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -4596,9 +4617,9 @@ internal class PriceTest { .billingMode(Price.GroupedAllocation.BillingMode.IN_ADVANCE) .cadence(Price.GroupedAllocation.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Price.GroupedAllocation.CompositePriceFilter.builder() + .field(Price.GroupedAllocation.CompositePriceFilter.Field.PRICE_ID) + .operator(Price.GroupedAllocation.CompositePriceFilter.Operator.INCLUDES) .addValue("string") .build() ) @@ -4627,9 +4648,9 @@ internal class PriceTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -4656,9 +4677,9 @@ internal class PriceTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -4675,9 +4696,9 @@ internal class PriceTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -4748,9 +4769,11 @@ internal class PriceTest { .billingMode(Price.GroupedAllocation.BillingMode.IN_ADVANCE) .cadence(Price.GroupedAllocation.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Price.GroupedAllocation.CompositePriceFilter.builder() + .field(Price.GroupedAllocation.CompositePriceFilter.Field.PRICE_ID) + .operator( + Price.GroupedAllocation.CompositePriceFilter.Operator.INCLUDES + ) .addValue("string") .build() ) @@ -4779,9 +4802,9 @@ internal class PriceTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -4808,9 +4831,9 @@ internal class PriceTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -4827,9 +4850,9 @@ internal class PriceTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -4887,9 +4910,9 @@ internal class PriceTest { ) .cadence(Price.BulkWithProration.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Price.BulkWithProration.CompositePriceFilter.builder() + .field(Price.BulkWithProration.CompositePriceFilter.Field.PRICE_ID) + .operator(Price.BulkWithProration.CompositePriceFilter.Operator.INCLUDES) .addValue("string") .build() ) @@ -4918,9 +4941,9 @@ internal class PriceTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -4940,9 +4963,9 @@ internal class PriceTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -4959,9 +4982,9 @@ internal class PriceTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -5048,9 +5071,11 @@ internal class PriceTest { ) .cadence(Price.BulkWithProration.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Price.BulkWithProration.CompositePriceFilter.builder() + .field(Price.BulkWithProration.CompositePriceFilter.Field.PRICE_ID) + .operator( + Price.BulkWithProration.CompositePriceFilter.Operator.INCLUDES + ) .addValue("string") .build() ) @@ -5079,9 +5104,9 @@ internal class PriceTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -5101,9 +5126,9 @@ internal class PriceTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -5120,9 +5145,9 @@ internal class PriceTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -5164,9 +5189,11 @@ internal class PriceTest { .billingMode(Price.GroupedWithProratedMinimum.BillingMode.IN_ADVANCE) .cadence(Price.GroupedWithProratedMinimum.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Price.GroupedWithProratedMinimum.CompositePriceFilter.builder() + .field(Price.GroupedWithProratedMinimum.CompositePriceFilter.Field.PRICE_ID) + .operator( + Price.GroupedWithProratedMinimum.CompositePriceFilter.Operator.INCLUDES + ) .addValue("string") .build() ) @@ -5195,9 +5222,9 @@ internal class PriceTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -5224,9 +5251,9 @@ internal class PriceTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -5243,9 +5270,9 @@ internal class PriceTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -5316,9 +5343,14 @@ internal class PriceTest { .billingMode(Price.GroupedWithProratedMinimum.BillingMode.IN_ADVANCE) .cadence(Price.GroupedWithProratedMinimum.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Price.GroupedWithProratedMinimum.CompositePriceFilter.builder() + .field( + Price.GroupedWithProratedMinimum.CompositePriceFilter.Field.PRICE_ID + ) + .operator( + Price.GroupedWithProratedMinimum.CompositePriceFilter.Operator + .INCLUDES + ) .addValue("string") .build() ) @@ -5347,9 +5379,9 @@ internal class PriceTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -5376,9 +5408,9 @@ internal class PriceTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -5395,9 +5427,9 @@ internal class PriceTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -5439,9 +5471,11 @@ internal class PriceTest { .billingMode(Price.GroupedWithMeteredMinimum.BillingMode.IN_ADVANCE) .cadence(Price.GroupedWithMeteredMinimum.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Price.GroupedWithMeteredMinimum.CompositePriceFilter.builder() + .field(Price.GroupedWithMeteredMinimum.CompositePriceFilter.Field.PRICE_ID) + .operator( + Price.GroupedWithMeteredMinimum.CompositePriceFilter.Operator.INCLUDES + ) .addValue("string") .build() ) @@ -5470,9 +5504,9 @@ internal class PriceTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -5516,9 +5550,9 @@ internal class PriceTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -5535,9 +5569,9 @@ internal class PriceTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -5608,9 +5642,14 @@ internal class PriceTest { .billingMode(Price.GroupedWithMeteredMinimum.BillingMode.IN_ADVANCE) .cadence(Price.GroupedWithMeteredMinimum.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Price.GroupedWithMeteredMinimum.CompositePriceFilter.builder() + .field( + Price.GroupedWithMeteredMinimum.CompositePriceFilter.Field.PRICE_ID + ) + .operator( + Price.GroupedWithMeteredMinimum.CompositePriceFilter.Operator + .INCLUDES + ) .addValue("string") .build() ) @@ -5639,9 +5678,9 @@ internal class PriceTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -5685,9 +5724,9 @@ internal class PriceTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -5704,9 +5743,9 @@ internal class PriceTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -5748,9 +5787,13 @@ internal class PriceTest { .billingMode(Price.GroupedWithMinMaxThresholds.BillingMode.IN_ADVANCE) .cadence(Price.GroupedWithMinMaxThresholds.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Price.GroupedWithMinMaxThresholds.CompositePriceFilter.builder() + .field( + Price.GroupedWithMinMaxThresholds.CompositePriceFilter.Field.PRICE_ID + ) + .operator( + Price.GroupedWithMinMaxThresholds.CompositePriceFilter.Operator.INCLUDES + ) .addValue("string") .build() ) @@ -5779,9 +5822,9 @@ internal class PriceTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -5809,9 +5852,9 @@ internal class PriceTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -5828,9 +5871,9 @@ internal class PriceTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -5901,9 +5944,15 @@ internal class PriceTest { .billingMode(Price.GroupedWithMinMaxThresholds.BillingMode.IN_ADVANCE) .cadence(Price.GroupedWithMinMaxThresholds.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Price.GroupedWithMinMaxThresholds.CompositePriceFilter.builder() + .field( + Price.GroupedWithMinMaxThresholds.CompositePriceFilter.Field + .PRICE_ID + ) + .operator( + Price.GroupedWithMinMaxThresholds.CompositePriceFilter.Operator + .INCLUDES + ) .addValue("string") .build() ) @@ -5932,9 +5981,9 @@ internal class PriceTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -5963,9 +6012,9 @@ internal class PriceTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -5982,9 +6031,9 @@ internal class PriceTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -6026,9 +6075,11 @@ internal class PriceTest { .billingMode(Price.MatrixWithDisplayName.BillingMode.IN_ADVANCE) .cadence(Price.MatrixWithDisplayName.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Price.MatrixWithDisplayName.CompositePriceFilter.builder() + .field(Price.MatrixWithDisplayName.CompositePriceFilter.Field.PRICE_ID) + .operator( + Price.MatrixWithDisplayName.CompositePriceFilter.Operator.INCLUDES + ) .addValue("string") .build() ) @@ -6057,9 +6108,9 @@ internal class PriceTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -6092,9 +6143,9 @@ internal class PriceTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -6111,9 +6162,9 @@ internal class PriceTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -6184,9 +6235,11 @@ internal class PriceTest { .billingMode(Price.MatrixWithDisplayName.BillingMode.IN_ADVANCE) .cadence(Price.MatrixWithDisplayName.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Price.MatrixWithDisplayName.CompositePriceFilter.builder() + .field(Price.MatrixWithDisplayName.CompositePriceFilter.Field.PRICE_ID) + .operator( + Price.MatrixWithDisplayName.CompositePriceFilter.Operator.INCLUDES + ) .addValue("string") .build() ) @@ -6215,9 +6268,9 @@ internal class PriceTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -6250,9 +6303,9 @@ internal class PriceTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -6269,9 +6322,9 @@ internal class PriceTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -6313,9 +6366,9 @@ internal class PriceTest { .billingMode(Price.GroupedTieredPackage.BillingMode.IN_ADVANCE) .cadence(Price.GroupedTieredPackage.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Price.GroupedTieredPackage.CompositePriceFilter.builder() + .field(Price.GroupedTieredPackage.CompositePriceFilter.Field.PRICE_ID) + .operator(Price.GroupedTieredPackage.CompositePriceFilter.Operator.INCLUDES) .addValue("string") .build() ) @@ -6344,9 +6397,9 @@ internal class PriceTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -6384,9 +6437,9 @@ internal class PriceTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -6403,9 +6456,9 @@ internal class PriceTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -6476,9 +6529,11 @@ internal class PriceTest { .billingMode(Price.GroupedTieredPackage.BillingMode.IN_ADVANCE) .cadence(Price.GroupedTieredPackage.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Price.GroupedTieredPackage.CompositePriceFilter.builder() + .field(Price.GroupedTieredPackage.CompositePriceFilter.Field.PRICE_ID) + .operator( + Price.GroupedTieredPackage.CompositePriceFilter.Operator.INCLUDES + ) .addValue("string") .build() ) @@ -6507,9 +6562,9 @@ internal class PriceTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -6547,9 +6602,9 @@ internal class PriceTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -6566,9 +6621,9 @@ internal class PriceTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -6610,9 +6665,11 @@ internal class PriceTest { .billingMode(Price.MaxGroupTieredPackage.BillingMode.IN_ADVANCE) .cadence(Price.MaxGroupTieredPackage.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Price.MaxGroupTieredPackage.CompositePriceFilter.builder() + .field(Price.MaxGroupTieredPackage.CompositePriceFilter.Field.PRICE_ID) + .operator( + Price.MaxGroupTieredPackage.CompositePriceFilter.Operator.INCLUDES + ) .addValue("string") .build() ) @@ -6641,9 +6698,9 @@ internal class PriceTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -6681,9 +6738,9 @@ internal class PriceTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -6700,9 +6757,9 @@ internal class PriceTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -6773,9 +6830,11 @@ internal class PriceTest { .billingMode(Price.MaxGroupTieredPackage.BillingMode.IN_ADVANCE) .cadence(Price.MaxGroupTieredPackage.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Price.MaxGroupTieredPackage.CompositePriceFilter.builder() + .field(Price.MaxGroupTieredPackage.CompositePriceFilter.Field.PRICE_ID) + .operator( + Price.MaxGroupTieredPackage.CompositePriceFilter.Operator.INCLUDES + ) .addValue("string") .build() ) @@ -6804,9 +6863,9 @@ internal class PriceTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -6846,9 +6905,9 @@ internal class PriceTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -6865,9 +6924,9 @@ internal class PriceTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -6909,9 +6968,14 @@ internal class PriceTest { .billingMode(Price.ScalableMatrixWithUnitPricing.BillingMode.IN_ADVANCE) .cadence(Price.ScalableMatrixWithUnitPricing.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Price.ScalableMatrixWithUnitPricing.CompositePriceFilter.builder() + .field( + Price.ScalableMatrixWithUnitPricing.CompositePriceFilter.Field.PRICE_ID + ) + .operator( + Price.ScalableMatrixWithUnitPricing.CompositePriceFilter.Operator + .INCLUDES + ) .addValue("string") .build() ) @@ -6940,9 +7004,9 @@ internal class PriceTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -6962,9 +7026,9 @@ internal class PriceTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -6981,9 +7045,9 @@ internal class PriceTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -7072,9 +7136,15 @@ internal class PriceTest { .billingMode(Price.ScalableMatrixWithUnitPricing.BillingMode.IN_ADVANCE) .cadence(Price.ScalableMatrixWithUnitPricing.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Price.ScalableMatrixWithUnitPricing.CompositePriceFilter.builder() + .field( + Price.ScalableMatrixWithUnitPricing.CompositePriceFilter.Field + .PRICE_ID + ) + .operator( + Price.ScalableMatrixWithUnitPricing.CompositePriceFilter.Operator + .INCLUDES + ) .addValue("string") .build() ) @@ -7103,9 +7173,9 @@ internal class PriceTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -7125,9 +7195,9 @@ internal class PriceTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -7144,9 +7214,9 @@ internal class PriceTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -7207,9 +7277,15 @@ internal class PriceTest { .billingMode(Price.ScalableMatrixWithTieredPricing.BillingMode.IN_ADVANCE) .cadence(Price.ScalableMatrixWithTieredPricing.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Price.ScalableMatrixWithTieredPricing.CompositePriceFilter.builder() + .field( + Price.ScalableMatrixWithTieredPricing.CompositePriceFilter.Field + .PRICE_ID + ) + .operator( + Price.ScalableMatrixWithTieredPricing.CompositePriceFilter.Operator + .INCLUDES + ) .addValue("string") .build() ) @@ -7238,9 +7314,9 @@ internal class PriceTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -7260,9 +7336,9 @@ internal class PriceTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -7279,9 +7355,9 @@ internal class PriceTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -7388,9 +7464,15 @@ internal class PriceTest { .billingMode(Price.ScalableMatrixWithTieredPricing.BillingMode.IN_ADVANCE) .cadence(Price.ScalableMatrixWithTieredPricing.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Price.ScalableMatrixWithTieredPricing.CompositePriceFilter.builder() + .field( + Price.ScalableMatrixWithTieredPricing.CompositePriceFilter.Field + .PRICE_ID + ) + .operator( + Price.ScalableMatrixWithTieredPricing.CompositePriceFilter.Operator + .INCLUDES + ) .addValue("string") .build() ) @@ -7419,9 +7501,9 @@ internal class PriceTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -7441,9 +7523,9 @@ internal class PriceTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -7460,9 +7542,9 @@ internal class PriceTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -7539,9 +7621,11 @@ internal class PriceTest { .billingMode(Price.CumulativeGroupedBulk.BillingMode.IN_ADVANCE) .cadence(Price.CumulativeGroupedBulk.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Price.CumulativeGroupedBulk.CompositePriceFilter.builder() + .field(Price.CumulativeGroupedBulk.CompositePriceFilter.Field.PRICE_ID) + .operator( + Price.CumulativeGroupedBulk.CompositePriceFilter.Operator.INCLUDES + ) .addValue("string") .build() ) @@ -7583,9 +7667,9 @@ internal class PriceTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -7605,9 +7689,9 @@ internal class PriceTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -7624,9 +7708,9 @@ internal class PriceTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -7697,9 +7781,11 @@ internal class PriceTest { .billingMode(Price.CumulativeGroupedBulk.BillingMode.IN_ADVANCE) .cadence(Price.CumulativeGroupedBulk.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Price.CumulativeGroupedBulk.CompositePriceFilter.builder() + .field(Price.CumulativeGroupedBulk.CompositePriceFilter.Field.PRICE_ID) + .operator( + Price.CumulativeGroupedBulk.CompositePriceFilter.Operator.INCLUDES + ) .addValue("string") .build() ) @@ -7742,9 +7828,9 @@ internal class PriceTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -7764,9 +7850,9 @@ internal class PriceTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -7783,9 +7869,9 @@ internal class PriceTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -7827,9 +7913,9 @@ internal class PriceTest { .billingMode(Price.Minimum.BillingMode.IN_ADVANCE) .cadence(Price.Minimum.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Price.Minimum.CompositePriceFilter.builder() + .field(Price.Minimum.CompositePriceFilter.Field.PRICE_ID) + .operator(Price.Minimum.CompositePriceFilter.Operator.INCLUDES) .addValue("string") .build() ) @@ -7858,9 +7944,9 @@ internal class PriceTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -7880,9 +7966,9 @@ internal class PriceTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -7899,9 +7985,9 @@ internal class PriceTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -7978,9 +8064,9 @@ internal class PriceTest { .billingMode(Price.Minimum.BillingMode.IN_ADVANCE) .cadence(Price.Minimum.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Price.Minimum.CompositePriceFilter.builder() + .field(Price.Minimum.CompositePriceFilter.Field.PRICE_ID) + .operator(Price.Minimum.CompositePriceFilter.Operator.INCLUDES) .addValue("string") .build() ) @@ -8009,9 +8095,9 @@ internal class PriceTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -8031,9 +8117,9 @@ internal class PriceTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -8050,9 +8136,9 @@ internal class PriceTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -8100,9 +8186,9 @@ internal class PriceTest { .billingMode(Price.Percent.BillingMode.IN_ADVANCE) .cadence(Price.Percent.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Price.Percent.CompositePriceFilter.builder() + .field(Price.Percent.CompositePriceFilter.Field.PRICE_ID) + .operator(Price.Percent.CompositePriceFilter.Operator.INCLUDES) .addValue("string") .build() ) @@ -8131,9 +8217,9 @@ internal class PriceTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -8153,9 +8239,9 @@ internal class PriceTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -8172,9 +8258,9 @@ internal class PriceTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -8246,9 +8332,9 @@ internal class PriceTest { .billingMode(Price.Percent.BillingMode.IN_ADVANCE) .cadence(Price.Percent.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Price.Percent.CompositePriceFilter.builder() + .field(Price.Percent.CompositePriceFilter.Field.PRICE_ID) + .operator(Price.Percent.CompositePriceFilter.Operator.INCLUDES) .addValue("string") .build() ) @@ -8277,9 +8363,9 @@ internal class PriceTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -8299,9 +8385,9 @@ internal class PriceTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -8318,9 +8404,9 @@ internal class PriceTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -8363,9 +8449,9 @@ internal class PriceTest { .billingMode(Price.EventOutput.BillingMode.IN_ADVANCE) .cadence(Price.EventOutput.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Price.EventOutput.CompositePriceFilter.builder() + .field(Price.EventOutput.CompositePriceFilter.Field.PRICE_ID) + .operator(Price.EventOutput.CompositePriceFilter.Operator.INCLUDES) .addValue("string") .build() ) @@ -8394,9 +8480,9 @@ internal class PriceTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -8406,6 +8492,7 @@ internal class PriceTest { .eventOutputConfig( Price.EventOutput.EventOutputConfig.builder() .unitRatingKey("x") + .defaultUnitRate("default_unit_rate") .groupingKey("grouping_key") .build() ) @@ -8422,9 +8509,9 @@ internal class PriceTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -8441,9 +8528,9 @@ internal class PriceTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -8514,9 +8601,9 @@ internal class PriceTest { .billingMode(Price.EventOutput.BillingMode.IN_ADVANCE) .cadence(Price.EventOutput.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Price.EventOutput.CompositePriceFilter.builder() + .field(Price.EventOutput.CompositePriceFilter.Field.PRICE_ID) + .operator(Price.EventOutput.CompositePriceFilter.Operator.INCLUDES) .addValue("string") .build() ) @@ -8545,9 +8632,9 @@ internal class PriceTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -8557,6 +8644,7 @@ internal class PriceTest { .eventOutputConfig( Price.EventOutput.EventOutputConfig.builder() .unitRatingKey("x") + .defaultUnitRate("default_unit_rate") .groupingKey("grouping_key") .build() ) @@ -8573,9 +8661,9 @@ internal class PriceTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -8592,9 +8680,9 @@ internal class PriceTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeApplyResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeApplyResponseTest.kt index dd1b414f1..2f7d74045 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeApplyResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeApplyResponseTest.kt @@ -34,9 +34,15 @@ internal class SubscriptionChangeApplyResponseTest { ) .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PlanPhaseUsageDiscountAdjustment.Filter.builder() + .field( + PlanPhaseUsageDiscountAdjustment.Filter.Field + .PRICE_ID + ) + .operator( + PlanPhaseUsageDiscountAdjustment.Filter.Operator + .INCLUDES + ) .addValue("string") .build() ) @@ -164,9 +170,9 @@ internal class SubscriptionChangeApplyResponseTest { .discountType(AmountDiscountInterval.DiscountType.AMOUNT) .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + AmountDiscountInterval.Filter.builder() + .field(AmountDiscountInterval.Filter.Field.PRICE_ID) + .operator(AmountDiscountInterval.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -188,9 +194,9 @@ internal class SubscriptionChangeApplyResponseTest { .addAppliesToPriceIntervalId("string") .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + MaximumInterval.Filter.builder() + .field(MaximumInterval.Filter.Field.PRICE_ID) + .operator(MaximumInterval.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -208,9 +214,9 @@ internal class SubscriptionChangeApplyResponseTest { .addAppliesToPriceIntervalId("string") .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + MinimumInterval.Filter.builder() + .field(MinimumInterval.Filter.Field.PRICE_ID) + .operator(MinimumInterval.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -235,9 +241,15 @@ internal class SubscriptionChangeApplyResponseTest { ) .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PlanPhaseUsageDiscountAdjustment.Filter.builder() + .field( + PlanPhaseUsageDiscountAdjustment.Filter.Field + .PRICE_ID + ) + .operator( + PlanPhaseUsageDiscountAdjustment.Filter.Operator + .INCLUDES + ) .addValue("string") .build() ) @@ -267,9 +279,11 @@ internal class SubscriptionChangeApplyResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator( + PercentageDiscount.Filter.Operator.INCLUDES + ) .addValue("string") .build() ) @@ -282,9 +296,9 @@ internal class SubscriptionChangeApplyResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -301,9 +315,9 @@ internal class SubscriptionChangeApplyResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -326,10 +340,13 @@ internal class SubscriptionChangeApplyResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) + PercentageDiscount.Filter.builder() + .field( + PercentageDiscount.Filter.Field.PRICE_ID + ) .operator( - TransformPriceFilter.Operator.INCLUDES + PercentageDiscount.Filter.Operator + .INCLUDES ) .addValue("string") .build() @@ -343,11 +360,9 @@ internal class SubscriptionChangeApplyResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -359,11 +374,9 @@ internal class SubscriptionChangeApplyResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -392,9 +405,14 @@ internal class SubscriptionChangeApplyResponseTest { .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Price.Unit.CompositePriceFilter.builder() + .field( + Price.Unit.CompositePriceFilter.Field.PRICE_ID + ) + .operator( + Price.Unit.CompositePriceFilter.Operator + .INCLUDES + ) .addValue("string") .build() ) @@ -429,10 +447,13 @@ internal class SubscriptionChangeApplyResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) + PercentageDiscount.Filter.builder() + .field( + PercentageDiscount.Filter.Field.PRICE_ID + ) .operator( - TransformPriceFilter.Operator.INCLUDES + PercentageDiscount.Filter.Operator + .INCLUDES ) .addValue("string") .build() @@ -455,11 +476,9 @@ internal class SubscriptionChangeApplyResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -479,11 +498,9 @@ internal class SubscriptionChangeApplyResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -563,9 +580,14 @@ internal class SubscriptionChangeApplyResponseTest { .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Price.Unit.CompositePriceFilter.builder() + .field( + Price.Unit.CompositePriceFilter.Field.PRICE_ID + ) + .operator( + Price.Unit.CompositePriceFilter.Operator + .INCLUDES + ) .addValue("string") .build() ) @@ -600,10 +622,13 @@ internal class SubscriptionChangeApplyResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) + PercentageDiscount.Filter.builder() + .field( + PercentageDiscount.Filter.Field.PRICE_ID + ) .operator( - TransformPriceFilter.Operator.INCLUDES + PercentageDiscount.Filter.Operator + .INCLUDES ) .addValue("string") .build() @@ -626,11 +651,9 @@ internal class SubscriptionChangeApplyResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -650,11 +673,9 @@ internal class SubscriptionChangeApplyResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -901,10 +922,13 @@ internal class SubscriptionChangeApplyResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) + PercentageDiscount.Filter.builder() + .field( + PercentageDiscount.Filter.Field.PRICE_ID + ) .operator( - TransformPriceFilter.Operator.INCLUDES + PercentageDiscount.Filter.Operator + .INCLUDES ) .addValue("string") .build() @@ -950,13 +974,18 @@ internal class SubscriptionChangeApplyResponseTest { .amount("amount") .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() + MonetaryUsageDiscountAdjustment.Filter + .builder() .field( - TransformPriceFilter.Field + MonetaryUsageDiscountAdjustment + .Filter + .Field .PRICE_ID ) .operator( - TransformPriceFilter.Operator + MonetaryUsageDiscountAdjustment + .Filter + .Operator .INCLUDES ) .addValue("string") @@ -982,13 +1011,14 @@ internal class SubscriptionChangeApplyResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() + PercentageDiscount.Filter.builder() .field( - TransformPriceFilter.Field + PercentageDiscount.Filter.Field .PRICE_ID ) .operator( - TransformPriceFilter.Operator + PercentageDiscount.Filter + .Operator .INCLUDES ) .addValue("string") @@ -1008,14 +1038,12 @@ internal class SubscriptionChangeApplyResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() + Maximum.Filter.builder() .field( - TransformPriceFilter.Field - .PRICE_ID + Maximum.Filter.Field.PRICE_ID ) .operator( - TransformPriceFilter.Operator - .INCLUDES + Maximum.Filter.Operator.INCLUDES ) .addValue("string") .build() @@ -1028,14 +1056,12 @@ internal class SubscriptionChangeApplyResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() + Minimum.Filter.builder() .field( - TransformPriceFilter.Field - .PRICE_ID + Minimum.Filter.Field.PRICE_ID ) .operator( - TransformPriceFilter.Operator - .INCLUDES + Minimum.Filter.Operator.INCLUDES ) .addValue("string") .build() @@ -1069,13 +1095,16 @@ internal class SubscriptionChangeApplyResponseTest { ) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() + Price.Unit.CompositePriceFilter + .builder() .field( - TransformPriceFilter.Field + Price.Unit.CompositePriceFilter + .Field .PRICE_ID ) .operator( - TransformPriceFilter.Operator + Price.Unit.CompositePriceFilter + .Operator .INCLUDES ) .addValue("string") @@ -1123,14 +1152,17 @@ internal class SubscriptionChangeApplyResponseTest { "7hfgtgjnbvc3ujkl" ) .addFilter( - TransformPriceFilter.builder() + PercentageDiscount.Filter + .builder() .field( - TransformPriceFilter + PercentageDiscount + .Filter .Field .PRICE_ID ) .operator( - TransformPriceFilter + PercentageDiscount + .Filter .Operator .INCLUDES ) @@ -1162,15 +1194,13 @@ internal class SubscriptionChangeApplyResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() + Maximum.Filter.builder() .field( - TransformPriceFilter - .Field + Maximum.Filter.Field .PRICE_ID ) .operator( - TransformPriceFilter - .Operator + Maximum.Filter.Operator .INCLUDES ) .addValue("string") @@ -1192,15 +1222,13 @@ internal class SubscriptionChangeApplyResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() + Minimum.Filter.builder() .field( - TransformPriceFilter - .Field + Minimum.Filter.Field .PRICE_ID ) .operator( - TransformPriceFilter - .Operator + Minimum.Filter.Operator .INCLUDES ) .addValue("string") @@ -1270,11 +1298,9 @@ internal class SubscriptionChangeApplyResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -1296,11 +1322,9 @@ internal class SubscriptionChangeApplyResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -1561,10 +1585,13 @@ internal class SubscriptionChangeApplyResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) + PercentageDiscount.Filter.builder() + .field( + PercentageDiscount.Filter.Field.PRICE_ID + ) .operator( - TransformPriceFilter.Operator.INCLUDES + PercentageDiscount.Filter.Operator + .INCLUDES ) .addValue("string") .build() @@ -1604,13 +1631,18 @@ internal class SubscriptionChangeApplyResponseTest { .amount("amount") .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() + MonetaryUsageDiscountAdjustment.Filter + .builder() .field( - TransformPriceFilter.Field + MonetaryUsageDiscountAdjustment + .Filter + .Field .PRICE_ID ) .operator( - TransformPriceFilter.Operator + MonetaryUsageDiscountAdjustment + .Filter + .Operator .INCLUDES ) .addValue("string") @@ -1636,13 +1668,14 @@ internal class SubscriptionChangeApplyResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() + PercentageDiscount.Filter.builder() .field( - TransformPriceFilter.Field + PercentageDiscount.Filter.Field .PRICE_ID ) .operator( - TransformPriceFilter.Operator + PercentageDiscount.Filter + .Operator .INCLUDES ) .addValue("string") @@ -1662,14 +1695,12 @@ internal class SubscriptionChangeApplyResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() + Maximum.Filter.builder() .field( - TransformPriceFilter.Field - .PRICE_ID + Maximum.Filter.Field.PRICE_ID ) .operator( - TransformPriceFilter.Operator - .INCLUDES + Maximum.Filter.Operator.INCLUDES ) .addValue("string") .build() @@ -1682,14 +1713,12 @@ internal class SubscriptionChangeApplyResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() + Minimum.Filter.builder() .field( - TransformPriceFilter.Field - .PRICE_ID + Minimum.Filter.Field.PRICE_ID ) .operator( - TransformPriceFilter.Operator - .INCLUDES + Minimum.Filter.Operator.INCLUDES ) .addValue("string") .build() @@ -1723,13 +1752,16 @@ internal class SubscriptionChangeApplyResponseTest { ) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() + Price.Unit.CompositePriceFilter + .builder() .field( - TransformPriceFilter.Field + Price.Unit.CompositePriceFilter + .Field .PRICE_ID ) .operator( - TransformPriceFilter.Operator + Price.Unit.CompositePriceFilter + .Operator .INCLUDES ) .addValue("string") @@ -1777,14 +1809,17 @@ internal class SubscriptionChangeApplyResponseTest { "7hfgtgjnbvc3ujkl" ) .addFilter( - TransformPriceFilter.builder() + PercentageDiscount.Filter + .builder() .field( - TransformPriceFilter + PercentageDiscount + .Filter .Field .PRICE_ID ) .operator( - TransformPriceFilter + PercentageDiscount + .Filter .Operator .INCLUDES ) @@ -1816,15 +1851,13 @@ internal class SubscriptionChangeApplyResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() + Maximum.Filter.builder() .field( - TransformPriceFilter - .Field + Maximum.Filter.Field .PRICE_ID ) .operator( - TransformPriceFilter - .Operator + Maximum.Filter.Operator .INCLUDES ) .addValue("string") @@ -1846,15 +1879,13 @@ internal class SubscriptionChangeApplyResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() + Minimum.Filter.builder() .field( - TransformPriceFilter - .Field + Minimum.Filter.Field .PRICE_ID ) .operator( - TransformPriceFilter - .Operator + Minimum.Filter.Operator .INCLUDES ) .addValue("string") @@ -1924,11 +1955,9 @@ internal class SubscriptionChangeApplyResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -1949,11 +1978,9 @@ internal class SubscriptionChangeApplyResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -2043,9 +2070,15 @@ internal class SubscriptionChangeApplyResponseTest { ) .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PlanPhaseUsageDiscountAdjustment.Filter.builder() + .field( + PlanPhaseUsageDiscountAdjustment.Filter.Field + .PRICE_ID + ) + .operator( + PlanPhaseUsageDiscountAdjustment.Filter.Operator + .INCLUDES + ) .addValue("string") .build() ) @@ -2165,9 +2198,9 @@ internal class SubscriptionChangeApplyResponseTest { .discountType(AmountDiscountInterval.DiscountType.AMOUNT) .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + AmountDiscountInterval.Filter.builder() + .field(AmountDiscountInterval.Filter.Field.PRICE_ID) + .operator(AmountDiscountInterval.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -2189,9 +2222,9 @@ internal class SubscriptionChangeApplyResponseTest { .addAppliesToPriceIntervalId("string") .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + MaximumInterval.Filter.builder() + .field(MaximumInterval.Filter.Field.PRICE_ID) + .operator(MaximumInterval.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -2209,9 +2242,9 @@ internal class SubscriptionChangeApplyResponseTest { .addAppliesToPriceIntervalId("string") .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + MinimumInterval.Filter.builder() + .field(MinimumInterval.Filter.Field.PRICE_ID) + .operator(MinimumInterval.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -2236,9 +2269,15 @@ internal class SubscriptionChangeApplyResponseTest { ) .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PlanPhaseUsageDiscountAdjustment.Filter.builder() + .field( + PlanPhaseUsageDiscountAdjustment.Filter.Field + .PRICE_ID + ) + .operator( + PlanPhaseUsageDiscountAdjustment.Filter.Operator + .INCLUDES + ) .addValue("string") .build() ) @@ -2268,9 +2307,9 @@ internal class SubscriptionChangeApplyResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -2283,9 +2322,9 @@ internal class SubscriptionChangeApplyResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -2302,9 +2341,9 @@ internal class SubscriptionChangeApplyResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -2327,10 +2366,10 @@ internal class SubscriptionChangeApplyResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) .operator( - TransformPriceFilter.Operator.INCLUDES + PercentageDiscount.Filter.Operator.INCLUDES ) .addValue("string") .build() @@ -2344,11 +2383,9 @@ internal class SubscriptionChangeApplyResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -2360,11 +2397,9 @@ internal class SubscriptionChangeApplyResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -2391,9 +2426,11 @@ internal class SubscriptionChangeApplyResponseTest { .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Price.Unit.CompositePriceFilter.builder() + .field(Price.Unit.CompositePriceFilter.Field.PRICE_ID) + .operator( + Price.Unit.CompositePriceFilter.Operator.INCLUDES + ) .addValue("string") .build() ) @@ -2426,10 +2463,10 @@ internal class SubscriptionChangeApplyResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) .operator( - TransformPriceFilter.Operator.INCLUDES + PercentageDiscount.Filter.Operator.INCLUDES ) .addValue("string") .build() @@ -2452,11 +2489,9 @@ internal class SubscriptionChangeApplyResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -2473,11 +2508,9 @@ internal class SubscriptionChangeApplyResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -2551,9 +2584,11 @@ internal class SubscriptionChangeApplyResponseTest { .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Price.Unit.CompositePriceFilter.builder() + .field(Price.Unit.CompositePriceFilter.Field.PRICE_ID) + .operator( + Price.Unit.CompositePriceFilter.Operator.INCLUDES + ) .addValue("string") .build() ) @@ -2586,10 +2621,10 @@ internal class SubscriptionChangeApplyResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) .operator( - TransformPriceFilter.Operator.INCLUDES + PercentageDiscount.Filter.Operator.INCLUDES ) .addValue("string") .build() @@ -2612,11 +2647,9 @@ internal class SubscriptionChangeApplyResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -2633,11 +2666,9 @@ internal class SubscriptionChangeApplyResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -2869,10 +2900,10 @@ internal class SubscriptionChangeApplyResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) .operator( - TransformPriceFilter.Operator.INCLUDES + PercentageDiscount.Filter.Operator.INCLUDES ) .addValue("string") .build() @@ -2913,12 +2944,18 @@ internal class SubscriptionChangeApplyResponseTest { .amount("amount") .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() + MonetaryUsageDiscountAdjustment.Filter + .builder() .field( - TransformPriceFilter.Field.PRICE_ID + MonetaryUsageDiscountAdjustment + .Filter + .Field + .PRICE_ID ) .operator( - TransformPriceFilter.Operator + MonetaryUsageDiscountAdjustment + .Filter + .Operator .INCLUDES ) .addValue("string") @@ -2941,12 +2978,13 @@ internal class SubscriptionChangeApplyResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() + PercentageDiscount.Filter.builder() .field( - TransformPriceFilter.Field.PRICE_ID + PercentageDiscount.Filter.Field + .PRICE_ID ) .operator( - TransformPriceFilter.Operator + PercentageDiscount.Filter.Operator .INCLUDES ) .addValue("string") @@ -2964,13 +3002,10 @@ internal class SubscriptionChangeApplyResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field( - TransformPriceFilter.Field.PRICE_ID - ) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) .operator( - TransformPriceFilter.Operator - .INCLUDES + Maximum.Filter.Operator.INCLUDES ) .addValue("string") .build() @@ -2983,13 +3018,10 @@ internal class SubscriptionChangeApplyResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field( - TransformPriceFilter.Field.PRICE_ID - ) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) .operator( - TransformPriceFilter.Operator - .INCLUDES + Minimum.Filter.Operator.INCLUDES ) .addValue("string") .build() @@ -3021,12 +3053,15 @@ internal class SubscriptionChangeApplyResponseTest { .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() + Price.Unit.CompositePriceFilter.builder() .field( - TransformPriceFilter.Field.PRICE_ID + Price.Unit.CompositePriceFilter + .Field + .PRICE_ID ) .operator( - TransformPriceFilter.Operator + Price.Unit.CompositePriceFilter + .Operator .INCLUDES ) .addValue("string") @@ -3070,13 +3105,14 @@ internal class SubscriptionChangeApplyResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() + PercentageDiscount.Filter.builder() .field( - TransformPriceFilter.Field + PercentageDiscount.Filter + .Field .PRICE_ID ) .operator( - TransformPriceFilter + PercentageDiscount.Filter .Operator .INCLUDES ) @@ -3108,14 +3144,13 @@ internal class SubscriptionChangeApplyResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() + Maximum.Filter.builder() .field( - TransformPriceFilter.Field + Maximum.Filter.Field .PRICE_ID ) .operator( - TransformPriceFilter - .Operator + Maximum.Filter.Operator .INCLUDES ) .addValue("string") @@ -3137,14 +3172,13 @@ internal class SubscriptionChangeApplyResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() + Minimum.Filter.builder() .field( - TransformPriceFilter.Field + Minimum.Filter.Field .PRICE_ID ) .operator( - TransformPriceFilter - .Operator + Minimum.Filter.Operator .INCLUDES ) .addValue("string") @@ -3212,11 +3246,9 @@ internal class SubscriptionChangeApplyResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -3235,11 +3267,9 @@ internal class SubscriptionChangeApplyResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -3481,10 +3511,10 @@ internal class SubscriptionChangeApplyResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) .operator( - TransformPriceFilter.Operator.INCLUDES + PercentageDiscount.Filter.Operator.INCLUDES ) .addValue("string") .build() @@ -3520,12 +3550,18 @@ internal class SubscriptionChangeApplyResponseTest { .amount("amount") .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() + MonetaryUsageDiscountAdjustment.Filter + .builder() .field( - TransformPriceFilter.Field.PRICE_ID + MonetaryUsageDiscountAdjustment + .Filter + .Field + .PRICE_ID ) .operator( - TransformPriceFilter.Operator + MonetaryUsageDiscountAdjustment + .Filter + .Operator .INCLUDES ) .addValue("string") @@ -3548,12 +3584,13 @@ internal class SubscriptionChangeApplyResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() + PercentageDiscount.Filter.builder() .field( - TransformPriceFilter.Field.PRICE_ID + PercentageDiscount.Filter.Field + .PRICE_ID ) .operator( - TransformPriceFilter.Operator + PercentageDiscount.Filter.Operator .INCLUDES ) .addValue("string") @@ -3571,13 +3608,10 @@ internal class SubscriptionChangeApplyResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field( - TransformPriceFilter.Field.PRICE_ID - ) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) .operator( - TransformPriceFilter.Operator - .INCLUDES + Maximum.Filter.Operator.INCLUDES ) .addValue("string") .build() @@ -3590,13 +3624,10 @@ internal class SubscriptionChangeApplyResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field( - TransformPriceFilter.Field.PRICE_ID - ) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) .operator( - TransformPriceFilter.Operator - .INCLUDES + Minimum.Filter.Operator.INCLUDES ) .addValue("string") .build() @@ -3628,12 +3659,15 @@ internal class SubscriptionChangeApplyResponseTest { .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() + Price.Unit.CompositePriceFilter.builder() .field( - TransformPriceFilter.Field.PRICE_ID + Price.Unit.CompositePriceFilter + .Field + .PRICE_ID ) .operator( - TransformPriceFilter.Operator + Price.Unit.CompositePriceFilter + .Operator .INCLUDES ) .addValue("string") @@ -3677,13 +3711,14 @@ internal class SubscriptionChangeApplyResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() + PercentageDiscount.Filter.builder() .field( - TransformPriceFilter.Field + PercentageDiscount.Filter + .Field .PRICE_ID ) .operator( - TransformPriceFilter + PercentageDiscount.Filter .Operator .INCLUDES ) @@ -3715,14 +3750,13 @@ internal class SubscriptionChangeApplyResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() + Maximum.Filter.builder() .field( - TransformPriceFilter.Field + Maximum.Filter.Field .PRICE_ID ) .operator( - TransformPriceFilter - .Operator + Maximum.Filter.Operator .INCLUDES ) .addValue("string") @@ -3744,14 +3778,13 @@ internal class SubscriptionChangeApplyResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() + Minimum.Filter.builder() .field( - TransformPriceFilter.Field + Minimum.Filter.Field .PRICE_ID ) .operator( - TransformPriceFilter - .Operator + Minimum.Filter.Operator .INCLUDES ) .addValue("string") @@ -3819,11 +3852,9 @@ internal class SubscriptionChangeApplyResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -3841,11 +3872,9 @@ internal class SubscriptionChangeApplyResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -3937,9 +3966,15 @@ internal class SubscriptionChangeApplyResponseTest { ) .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PlanPhaseUsageDiscountAdjustment.Filter.builder() + .field( + PlanPhaseUsageDiscountAdjustment.Filter.Field + .PRICE_ID + ) + .operator( + PlanPhaseUsageDiscountAdjustment.Filter.Operator + .INCLUDES + ) .addValue("string") .build() ) @@ -4067,9 +4102,9 @@ internal class SubscriptionChangeApplyResponseTest { .discountType(AmountDiscountInterval.DiscountType.AMOUNT) .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + AmountDiscountInterval.Filter.builder() + .field(AmountDiscountInterval.Filter.Field.PRICE_ID) + .operator(AmountDiscountInterval.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -4091,9 +4126,9 @@ internal class SubscriptionChangeApplyResponseTest { .addAppliesToPriceIntervalId("string") .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + MaximumInterval.Filter.builder() + .field(MaximumInterval.Filter.Field.PRICE_ID) + .operator(MaximumInterval.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -4111,9 +4146,9 @@ internal class SubscriptionChangeApplyResponseTest { .addAppliesToPriceIntervalId("string") .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + MinimumInterval.Filter.builder() + .field(MinimumInterval.Filter.Field.PRICE_ID) + .operator(MinimumInterval.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -4138,9 +4173,15 @@ internal class SubscriptionChangeApplyResponseTest { ) .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PlanPhaseUsageDiscountAdjustment.Filter.builder() + .field( + PlanPhaseUsageDiscountAdjustment.Filter.Field + .PRICE_ID + ) + .operator( + PlanPhaseUsageDiscountAdjustment.Filter.Operator + .INCLUDES + ) .addValue("string") .build() ) @@ -4170,9 +4211,11 @@ internal class SubscriptionChangeApplyResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator( + PercentageDiscount.Filter.Operator.INCLUDES + ) .addValue("string") .build() ) @@ -4185,9 +4228,9 @@ internal class SubscriptionChangeApplyResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -4204,9 +4247,9 @@ internal class SubscriptionChangeApplyResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -4229,10 +4272,13 @@ internal class SubscriptionChangeApplyResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) + PercentageDiscount.Filter.builder() + .field( + PercentageDiscount.Filter.Field.PRICE_ID + ) .operator( - TransformPriceFilter.Operator.INCLUDES + PercentageDiscount.Filter.Operator + .INCLUDES ) .addValue("string") .build() @@ -4246,11 +4292,9 @@ internal class SubscriptionChangeApplyResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -4262,11 +4306,9 @@ internal class SubscriptionChangeApplyResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -4295,9 +4337,14 @@ internal class SubscriptionChangeApplyResponseTest { .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Price.Unit.CompositePriceFilter.builder() + .field( + Price.Unit.CompositePriceFilter.Field.PRICE_ID + ) + .operator( + Price.Unit.CompositePriceFilter.Operator + .INCLUDES + ) .addValue("string") .build() ) @@ -4332,10 +4379,13 @@ internal class SubscriptionChangeApplyResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) + PercentageDiscount.Filter.builder() + .field( + PercentageDiscount.Filter.Field.PRICE_ID + ) .operator( - TransformPriceFilter.Operator.INCLUDES + PercentageDiscount.Filter.Operator + .INCLUDES ) .addValue("string") .build() @@ -4358,11 +4408,9 @@ internal class SubscriptionChangeApplyResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -4382,11 +4430,9 @@ internal class SubscriptionChangeApplyResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -4466,9 +4512,14 @@ internal class SubscriptionChangeApplyResponseTest { .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Price.Unit.CompositePriceFilter.builder() + .field( + Price.Unit.CompositePriceFilter.Field.PRICE_ID + ) + .operator( + Price.Unit.CompositePriceFilter.Operator + .INCLUDES + ) .addValue("string") .build() ) @@ -4503,10 +4554,13 @@ internal class SubscriptionChangeApplyResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) + PercentageDiscount.Filter.builder() + .field( + PercentageDiscount.Filter.Field.PRICE_ID + ) .operator( - TransformPriceFilter.Operator.INCLUDES + PercentageDiscount.Filter.Operator + .INCLUDES ) .addValue("string") .build() @@ -4529,11 +4583,9 @@ internal class SubscriptionChangeApplyResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -4553,11 +4605,9 @@ internal class SubscriptionChangeApplyResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -4804,10 +4854,13 @@ internal class SubscriptionChangeApplyResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) + PercentageDiscount.Filter.builder() + .field( + PercentageDiscount.Filter.Field.PRICE_ID + ) .operator( - TransformPriceFilter.Operator.INCLUDES + PercentageDiscount.Filter.Operator + .INCLUDES ) .addValue("string") .build() @@ -4853,13 +4906,18 @@ internal class SubscriptionChangeApplyResponseTest { .amount("amount") .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() + MonetaryUsageDiscountAdjustment.Filter + .builder() .field( - TransformPriceFilter.Field + MonetaryUsageDiscountAdjustment + .Filter + .Field .PRICE_ID ) .operator( - TransformPriceFilter.Operator + MonetaryUsageDiscountAdjustment + .Filter + .Operator .INCLUDES ) .addValue("string") @@ -4885,13 +4943,14 @@ internal class SubscriptionChangeApplyResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() + PercentageDiscount.Filter.builder() .field( - TransformPriceFilter.Field + PercentageDiscount.Filter.Field .PRICE_ID ) .operator( - TransformPriceFilter.Operator + PercentageDiscount.Filter + .Operator .INCLUDES ) .addValue("string") @@ -4911,14 +4970,12 @@ internal class SubscriptionChangeApplyResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() + Maximum.Filter.builder() .field( - TransformPriceFilter.Field - .PRICE_ID + Maximum.Filter.Field.PRICE_ID ) .operator( - TransformPriceFilter.Operator - .INCLUDES + Maximum.Filter.Operator.INCLUDES ) .addValue("string") .build() @@ -4931,14 +4988,12 @@ internal class SubscriptionChangeApplyResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() + Minimum.Filter.builder() .field( - TransformPriceFilter.Field - .PRICE_ID + Minimum.Filter.Field.PRICE_ID ) .operator( - TransformPriceFilter.Operator - .INCLUDES + Minimum.Filter.Operator.INCLUDES ) .addValue("string") .build() @@ -4972,13 +5027,16 @@ internal class SubscriptionChangeApplyResponseTest { ) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() + Price.Unit.CompositePriceFilter + .builder() .field( - TransformPriceFilter.Field + Price.Unit.CompositePriceFilter + .Field .PRICE_ID ) .operator( - TransformPriceFilter.Operator + Price.Unit.CompositePriceFilter + .Operator .INCLUDES ) .addValue("string") @@ -5026,14 +5084,17 @@ internal class SubscriptionChangeApplyResponseTest { "7hfgtgjnbvc3ujkl" ) .addFilter( - TransformPriceFilter.builder() + PercentageDiscount.Filter + .builder() .field( - TransformPriceFilter + PercentageDiscount + .Filter .Field .PRICE_ID ) .operator( - TransformPriceFilter + PercentageDiscount + .Filter .Operator .INCLUDES ) @@ -5065,15 +5126,13 @@ internal class SubscriptionChangeApplyResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() + Maximum.Filter.builder() .field( - TransformPriceFilter - .Field + Maximum.Filter.Field .PRICE_ID ) .operator( - TransformPriceFilter - .Operator + Maximum.Filter.Operator .INCLUDES ) .addValue("string") @@ -5095,15 +5154,13 @@ internal class SubscriptionChangeApplyResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() + Minimum.Filter.builder() .field( - TransformPriceFilter - .Field + Minimum.Filter.Field .PRICE_ID ) .operator( - TransformPriceFilter - .Operator + Minimum.Filter.Operator .INCLUDES ) .addValue("string") @@ -5173,11 +5230,9 @@ internal class SubscriptionChangeApplyResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -5199,11 +5254,9 @@ internal class SubscriptionChangeApplyResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -5464,10 +5517,13 @@ internal class SubscriptionChangeApplyResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) + PercentageDiscount.Filter.builder() + .field( + PercentageDiscount.Filter.Field.PRICE_ID + ) .operator( - TransformPriceFilter.Operator.INCLUDES + PercentageDiscount.Filter.Operator + .INCLUDES ) .addValue("string") .build() @@ -5507,13 +5563,18 @@ internal class SubscriptionChangeApplyResponseTest { .amount("amount") .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() + MonetaryUsageDiscountAdjustment.Filter + .builder() .field( - TransformPriceFilter.Field + MonetaryUsageDiscountAdjustment + .Filter + .Field .PRICE_ID ) .operator( - TransformPriceFilter.Operator + MonetaryUsageDiscountAdjustment + .Filter + .Operator .INCLUDES ) .addValue("string") @@ -5539,13 +5600,14 @@ internal class SubscriptionChangeApplyResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() + PercentageDiscount.Filter.builder() .field( - TransformPriceFilter.Field + PercentageDiscount.Filter.Field .PRICE_ID ) .operator( - TransformPriceFilter.Operator + PercentageDiscount.Filter + .Operator .INCLUDES ) .addValue("string") @@ -5565,14 +5627,12 @@ internal class SubscriptionChangeApplyResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() + Maximum.Filter.builder() .field( - TransformPriceFilter.Field - .PRICE_ID + Maximum.Filter.Field.PRICE_ID ) .operator( - TransformPriceFilter.Operator - .INCLUDES + Maximum.Filter.Operator.INCLUDES ) .addValue("string") .build() @@ -5585,14 +5645,12 @@ internal class SubscriptionChangeApplyResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() + Minimum.Filter.builder() .field( - TransformPriceFilter.Field - .PRICE_ID + Minimum.Filter.Field.PRICE_ID ) .operator( - TransformPriceFilter.Operator - .INCLUDES + Minimum.Filter.Operator.INCLUDES ) .addValue("string") .build() @@ -5626,13 +5684,16 @@ internal class SubscriptionChangeApplyResponseTest { ) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() + Price.Unit.CompositePriceFilter + .builder() .field( - TransformPriceFilter.Field + Price.Unit.CompositePriceFilter + .Field .PRICE_ID ) .operator( - TransformPriceFilter.Operator + Price.Unit.CompositePriceFilter + .Operator .INCLUDES ) .addValue("string") @@ -5680,14 +5741,17 @@ internal class SubscriptionChangeApplyResponseTest { "7hfgtgjnbvc3ujkl" ) .addFilter( - TransformPriceFilter.builder() + PercentageDiscount.Filter + .builder() .field( - TransformPriceFilter + PercentageDiscount + .Filter .Field .PRICE_ID ) .operator( - TransformPriceFilter + PercentageDiscount + .Filter .Operator .INCLUDES ) @@ -5719,15 +5783,13 @@ internal class SubscriptionChangeApplyResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() + Maximum.Filter.builder() .field( - TransformPriceFilter - .Field + Maximum.Filter.Field .PRICE_ID ) .operator( - TransformPriceFilter - .Operator + Maximum.Filter.Operator .INCLUDES ) .addValue("string") @@ -5749,15 +5811,13 @@ internal class SubscriptionChangeApplyResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() + Minimum.Filter.builder() .field( - TransformPriceFilter - .Field + Minimum.Filter.Field .PRICE_ID ) .operator( - TransformPriceFilter - .Operator + Minimum.Filter.Operator .INCLUDES ) .addValue("string") @@ -5827,11 +5887,9 @@ internal class SubscriptionChangeApplyResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -5852,11 +5910,9 @@ internal class SubscriptionChangeApplyResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeCancelResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeCancelResponseTest.kt index 0870f8c8a..695838c40 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeCancelResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeCancelResponseTest.kt @@ -34,9 +34,15 @@ internal class SubscriptionChangeCancelResponseTest { ) .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PlanPhaseUsageDiscountAdjustment.Filter.builder() + .field( + PlanPhaseUsageDiscountAdjustment.Filter.Field + .PRICE_ID + ) + .operator( + PlanPhaseUsageDiscountAdjustment.Filter.Operator + .INCLUDES + ) .addValue("string") .build() ) @@ -164,9 +170,9 @@ internal class SubscriptionChangeCancelResponseTest { .discountType(AmountDiscountInterval.DiscountType.AMOUNT) .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + AmountDiscountInterval.Filter.builder() + .field(AmountDiscountInterval.Filter.Field.PRICE_ID) + .operator(AmountDiscountInterval.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -188,9 +194,9 @@ internal class SubscriptionChangeCancelResponseTest { .addAppliesToPriceIntervalId("string") .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + MaximumInterval.Filter.builder() + .field(MaximumInterval.Filter.Field.PRICE_ID) + .operator(MaximumInterval.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -208,9 +214,9 @@ internal class SubscriptionChangeCancelResponseTest { .addAppliesToPriceIntervalId("string") .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + MinimumInterval.Filter.builder() + .field(MinimumInterval.Filter.Field.PRICE_ID) + .operator(MinimumInterval.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -235,9 +241,15 @@ internal class SubscriptionChangeCancelResponseTest { ) .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PlanPhaseUsageDiscountAdjustment.Filter.builder() + .field( + PlanPhaseUsageDiscountAdjustment.Filter.Field + .PRICE_ID + ) + .operator( + PlanPhaseUsageDiscountAdjustment.Filter.Operator + .INCLUDES + ) .addValue("string") .build() ) @@ -267,9 +279,11 @@ internal class SubscriptionChangeCancelResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator( + PercentageDiscount.Filter.Operator.INCLUDES + ) .addValue("string") .build() ) @@ -282,9 +296,9 @@ internal class SubscriptionChangeCancelResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -301,9 +315,9 @@ internal class SubscriptionChangeCancelResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -326,10 +340,13 @@ internal class SubscriptionChangeCancelResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) + PercentageDiscount.Filter.builder() + .field( + PercentageDiscount.Filter.Field.PRICE_ID + ) .operator( - TransformPriceFilter.Operator.INCLUDES + PercentageDiscount.Filter.Operator + .INCLUDES ) .addValue("string") .build() @@ -343,11 +360,9 @@ internal class SubscriptionChangeCancelResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -359,11 +374,9 @@ internal class SubscriptionChangeCancelResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -392,9 +405,14 @@ internal class SubscriptionChangeCancelResponseTest { .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Price.Unit.CompositePriceFilter.builder() + .field( + Price.Unit.CompositePriceFilter.Field.PRICE_ID + ) + .operator( + Price.Unit.CompositePriceFilter.Operator + .INCLUDES + ) .addValue("string") .build() ) @@ -429,10 +447,13 @@ internal class SubscriptionChangeCancelResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) + PercentageDiscount.Filter.builder() + .field( + PercentageDiscount.Filter.Field.PRICE_ID + ) .operator( - TransformPriceFilter.Operator.INCLUDES + PercentageDiscount.Filter.Operator + .INCLUDES ) .addValue("string") .build() @@ -455,11 +476,9 @@ internal class SubscriptionChangeCancelResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -479,11 +498,9 @@ internal class SubscriptionChangeCancelResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -563,9 +580,14 @@ internal class SubscriptionChangeCancelResponseTest { .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Price.Unit.CompositePriceFilter.builder() + .field( + Price.Unit.CompositePriceFilter.Field.PRICE_ID + ) + .operator( + Price.Unit.CompositePriceFilter.Operator + .INCLUDES + ) .addValue("string") .build() ) @@ -600,10 +622,13 @@ internal class SubscriptionChangeCancelResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) + PercentageDiscount.Filter.builder() + .field( + PercentageDiscount.Filter.Field.PRICE_ID + ) .operator( - TransformPriceFilter.Operator.INCLUDES + PercentageDiscount.Filter.Operator + .INCLUDES ) .addValue("string") .build() @@ -626,11 +651,9 @@ internal class SubscriptionChangeCancelResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -650,11 +673,9 @@ internal class SubscriptionChangeCancelResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -901,10 +922,13 @@ internal class SubscriptionChangeCancelResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) + PercentageDiscount.Filter.builder() + .field( + PercentageDiscount.Filter.Field.PRICE_ID + ) .operator( - TransformPriceFilter.Operator.INCLUDES + PercentageDiscount.Filter.Operator + .INCLUDES ) .addValue("string") .build() @@ -950,13 +974,18 @@ internal class SubscriptionChangeCancelResponseTest { .amount("amount") .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() + MonetaryUsageDiscountAdjustment.Filter + .builder() .field( - TransformPriceFilter.Field + MonetaryUsageDiscountAdjustment + .Filter + .Field .PRICE_ID ) .operator( - TransformPriceFilter.Operator + MonetaryUsageDiscountAdjustment + .Filter + .Operator .INCLUDES ) .addValue("string") @@ -982,13 +1011,14 @@ internal class SubscriptionChangeCancelResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() + PercentageDiscount.Filter.builder() .field( - TransformPriceFilter.Field + PercentageDiscount.Filter.Field .PRICE_ID ) .operator( - TransformPriceFilter.Operator + PercentageDiscount.Filter + .Operator .INCLUDES ) .addValue("string") @@ -1008,14 +1038,12 @@ internal class SubscriptionChangeCancelResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() + Maximum.Filter.builder() .field( - TransformPriceFilter.Field - .PRICE_ID + Maximum.Filter.Field.PRICE_ID ) .operator( - TransformPriceFilter.Operator - .INCLUDES + Maximum.Filter.Operator.INCLUDES ) .addValue("string") .build() @@ -1028,14 +1056,12 @@ internal class SubscriptionChangeCancelResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() + Minimum.Filter.builder() .field( - TransformPriceFilter.Field - .PRICE_ID + Minimum.Filter.Field.PRICE_ID ) .operator( - TransformPriceFilter.Operator - .INCLUDES + Minimum.Filter.Operator.INCLUDES ) .addValue("string") .build() @@ -1069,13 +1095,16 @@ internal class SubscriptionChangeCancelResponseTest { ) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() + Price.Unit.CompositePriceFilter + .builder() .field( - TransformPriceFilter.Field + Price.Unit.CompositePriceFilter + .Field .PRICE_ID ) .operator( - TransformPriceFilter.Operator + Price.Unit.CompositePriceFilter + .Operator .INCLUDES ) .addValue("string") @@ -1123,14 +1152,17 @@ internal class SubscriptionChangeCancelResponseTest { "7hfgtgjnbvc3ujkl" ) .addFilter( - TransformPriceFilter.builder() + PercentageDiscount.Filter + .builder() .field( - TransformPriceFilter + PercentageDiscount + .Filter .Field .PRICE_ID ) .operator( - TransformPriceFilter + PercentageDiscount + .Filter .Operator .INCLUDES ) @@ -1162,15 +1194,13 @@ internal class SubscriptionChangeCancelResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() + Maximum.Filter.builder() .field( - TransformPriceFilter - .Field + Maximum.Filter.Field .PRICE_ID ) .operator( - TransformPriceFilter - .Operator + Maximum.Filter.Operator .INCLUDES ) .addValue("string") @@ -1192,15 +1222,13 @@ internal class SubscriptionChangeCancelResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() + Minimum.Filter.builder() .field( - TransformPriceFilter - .Field + Minimum.Filter.Field .PRICE_ID ) .operator( - TransformPriceFilter - .Operator + Minimum.Filter.Operator .INCLUDES ) .addValue("string") @@ -1270,11 +1298,9 @@ internal class SubscriptionChangeCancelResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -1296,11 +1322,9 @@ internal class SubscriptionChangeCancelResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -1561,10 +1585,13 @@ internal class SubscriptionChangeCancelResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) + PercentageDiscount.Filter.builder() + .field( + PercentageDiscount.Filter.Field.PRICE_ID + ) .operator( - TransformPriceFilter.Operator.INCLUDES + PercentageDiscount.Filter.Operator + .INCLUDES ) .addValue("string") .build() @@ -1604,13 +1631,18 @@ internal class SubscriptionChangeCancelResponseTest { .amount("amount") .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() + MonetaryUsageDiscountAdjustment.Filter + .builder() .field( - TransformPriceFilter.Field + MonetaryUsageDiscountAdjustment + .Filter + .Field .PRICE_ID ) .operator( - TransformPriceFilter.Operator + MonetaryUsageDiscountAdjustment + .Filter + .Operator .INCLUDES ) .addValue("string") @@ -1636,13 +1668,14 @@ internal class SubscriptionChangeCancelResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() + PercentageDiscount.Filter.builder() .field( - TransformPriceFilter.Field + PercentageDiscount.Filter.Field .PRICE_ID ) .operator( - TransformPriceFilter.Operator + PercentageDiscount.Filter + .Operator .INCLUDES ) .addValue("string") @@ -1662,14 +1695,12 @@ internal class SubscriptionChangeCancelResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() + Maximum.Filter.builder() .field( - TransformPriceFilter.Field - .PRICE_ID + Maximum.Filter.Field.PRICE_ID ) .operator( - TransformPriceFilter.Operator - .INCLUDES + Maximum.Filter.Operator.INCLUDES ) .addValue("string") .build() @@ -1682,14 +1713,12 @@ internal class SubscriptionChangeCancelResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() + Minimum.Filter.builder() .field( - TransformPriceFilter.Field - .PRICE_ID + Minimum.Filter.Field.PRICE_ID ) .operator( - TransformPriceFilter.Operator - .INCLUDES + Minimum.Filter.Operator.INCLUDES ) .addValue("string") .build() @@ -1723,13 +1752,16 @@ internal class SubscriptionChangeCancelResponseTest { ) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() + Price.Unit.CompositePriceFilter + .builder() .field( - TransformPriceFilter.Field + Price.Unit.CompositePriceFilter + .Field .PRICE_ID ) .operator( - TransformPriceFilter.Operator + Price.Unit.CompositePriceFilter + .Operator .INCLUDES ) .addValue("string") @@ -1777,14 +1809,17 @@ internal class SubscriptionChangeCancelResponseTest { "7hfgtgjnbvc3ujkl" ) .addFilter( - TransformPriceFilter.builder() + PercentageDiscount.Filter + .builder() .field( - TransformPriceFilter + PercentageDiscount + .Filter .Field .PRICE_ID ) .operator( - TransformPriceFilter + PercentageDiscount + .Filter .Operator .INCLUDES ) @@ -1816,15 +1851,13 @@ internal class SubscriptionChangeCancelResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() + Maximum.Filter.builder() .field( - TransformPriceFilter - .Field + Maximum.Filter.Field .PRICE_ID ) .operator( - TransformPriceFilter - .Operator + Maximum.Filter.Operator .INCLUDES ) .addValue("string") @@ -1846,15 +1879,13 @@ internal class SubscriptionChangeCancelResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() + Minimum.Filter.builder() .field( - TransformPriceFilter - .Field + Minimum.Filter.Field .PRICE_ID ) .operator( - TransformPriceFilter - .Operator + Minimum.Filter.Operator .INCLUDES ) .addValue("string") @@ -1924,11 +1955,9 @@ internal class SubscriptionChangeCancelResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -1949,11 +1978,9 @@ internal class SubscriptionChangeCancelResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -2043,9 +2070,15 @@ internal class SubscriptionChangeCancelResponseTest { ) .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PlanPhaseUsageDiscountAdjustment.Filter.builder() + .field( + PlanPhaseUsageDiscountAdjustment.Filter.Field + .PRICE_ID + ) + .operator( + PlanPhaseUsageDiscountAdjustment.Filter.Operator + .INCLUDES + ) .addValue("string") .build() ) @@ -2165,9 +2198,9 @@ internal class SubscriptionChangeCancelResponseTest { .discountType(AmountDiscountInterval.DiscountType.AMOUNT) .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + AmountDiscountInterval.Filter.builder() + .field(AmountDiscountInterval.Filter.Field.PRICE_ID) + .operator(AmountDiscountInterval.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -2189,9 +2222,9 @@ internal class SubscriptionChangeCancelResponseTest { .addAppliesToPriceIntervalId("string") .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + MaximumInterval.Filter.builder() + .field(MaximumInterval.Filter.Field.PRICE_ID) + .operator(MaximumInterval.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -2209,9 +2242,9 @@ internal class SubscriptionChangeCancelResponseTest { .addAppliesToPriceIntervalId("string") .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + MinimumInterval.Filter.builder() + .field(MinimumInterval.Filter.Field.PRICE_ID) + .operator(MinimumInterval.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -2236,9 +2269,15 @@ internal class SubscriptionChangeCancelResponseTest { ) .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PlanPhaseUsageDiscountAdjustment.Filter.builder() + .field( + PlanPhaseUsageDiscountAdjustment.Filter.Field + .PRICE_ID + ) + .operator( + PlanPhaseUsageDiscountAdjustment.Filter.Operator + .INCLUDES + ) .addValue("string") .build() ) @@ -2268,9 +2307,9 @@ internal class SubscriptionChangeCancelResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -2283,9 +2322,9 @@ internal class SubscriptionChangeCancelResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -2302,9 +2341,9 @@ internal class SubscriptionChangeCancelResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -2327,10 +2366,10 @@ internal class SubscriptionChangeCancelResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) .operator( - TransformPriceFilter.Operator.INCLUDES + PercentageDiscount.Filter.Operator.INCLUDES ) .addValue("string") .build() @@ -2344,11 +2383,9 @@ internal class SubscriptionChangeCancelResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -2360,11 +2397,9 @@ internal class SubscriptionChangeCancelResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -2391,9 +2426,11 @@ internal class SubscriptionChangeCancelResponseTest { .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Price.Unit.CompositePriceFilter.builder() + .field(Price.Unit.CompositePriceFilter.Field.PRICE_ID) + .operator( + Price.Unit.CompositePriceFilter.Operator.INCLUDES + ) .addValue("string") .build() ) @@ -2426,10 +2463,10 @@ internal class SubscriptionChangeCancelResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) .operator( - TransformPriceFilter.Operator.INCLUDES + PercentageDiscount.Filter.Operator.INCLUDES ) .addValue("string") .build() @@ -2452,11 +2489,9 @@ internal class SubscriptionChangeCancelResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -2473,11 +2508,9 @@ internal class SubscriptionChangeCancelResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -2551,9 +2584,11 @@ internal class SubscriptionChangeCancelResponseTest { .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Price.Unit.CompositePriceFilter.builder() + .field(Price.Unit.CompositePriceFilter.Field.PRICE_ID) + .operator( + Price.Unit.CompositePriceFilter.Operator.INCLUDES + ) .addValue("string") .build() ) @@ -2586,10 +2621,10 @@ internal class SubscriptionChangeCancelResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) .operator( - TransformPriceFilter.Operator.INCLUDES + PercentageDiscount.Filter.Operator.INCLUDES ) .addValue("string") .build() @@ -2612,11 +2647,9 @@ internal class SubscriptionChangeCancelResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -2633,11 +2666,9 @@ internal class SubscriptionChangeCancelResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -2869,10 +2900,10 @@ internal class SubscriptionChangeCancelResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) .operator( - TransformPriceFilter.Operator.INCLUDES + PercentageDiscount.Filter.Operator.INCLUDES ) .addValue("string") .build() @@ -2913,12 +2944,18 @@ internal class SubscriptionChangeCancelResponseTest { .amount("amount") .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() + MonetaryUsageDiscountAdjustment.Filter + .builder() .field( - TransformPriceFilter.Field.PRICE_ID + MonetaryUsageDiscountAdjustment + .Filter + .Field + .PRICE_ID ) .operator( - TransformPriceFilter.Operator + MonetaryUsageDiscountAdjustment + .Filter + .Operator .INCLUDES ) .addValue("string") @@ -2941,12 +2978,13 @@ internal class SubscriptionChangeCancelResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() + PercentageDiscount.Filter.builder() .field( - TransformPriceFilter.Field.PRICE_ID + PercentageDiscount.Filter.Field + .PRICE_ID ) .operator( - TransformPriceFilter.Operator + PercentageDiscount.Filter.Operator .INCLUDES ) .addValue("string") @@ -2964,13 +3002,10 @@ internal class SubscriptionChangeCancelResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field( - TransformPriceFilter.Field.PRICE_ID - ) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) .operator( - TransformPriceFilter.Operator - .INCLUDES + Maximum.Filter.Operator.INCLUDES ) .addValue("string") .build() @@ -2983,13 +3018,10 @@ internal class SubscriptionChangeCancelResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field( - TransformPriceFilter.Field.PRICE_ID - ) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) .operator( - TransformPriceFilter.Operator - .INCLUDES + Minimum.Filter.Operator.INCLUDES ) .addValue("string") .build() @@ -3021,12 +3053,15 @@ internal class SubscriptionChangeCancelResponseTest { .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() + Price.Unit.CompositePriceFilter.builder() .field( - TransformPriceFilter.Field.PRICE_ID + Price.Unit.CompositePriceFilter + .Field + .PRICE_ID ) .operator( - TransformPriceFilter.Operator + Price.Unit.CompositePriceFilter + .Operator .INCLUDES ) .addValue("string") @@ -3070,13 +3105,14 @@ internal class SubscriptionChangeCancelResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() + PercentageDiscount.Filter.builder() .field( - TransformPriceFilter.Field + PercentageDiscount.Filter + .Field .PRICE_ID ) .operator( - TransformPriceFilter + PercentageDiscount.Filter .Operator .INCLUDES ) @@ -3108,14 +3144,13 @@ internal class SubscriptionChangeCancelResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() + Maximum.Filter.builder() .field( - TransformPriceFilter.Field + Maximum.Filter.Field .PRICE_ID ) .operator( - TransformPriceFilter - .Operator + Maximum.Filter.Operator .INCLUDES ) .addValue("string") @@ -3137,14 +3172,13 @@ internal class SubscriptionChangeCancelResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() + Minimum.Filter.builder() .field( - TransformPriceFilter.Field + Minimum.Filter.Field .PRICE_ID ) .operator( - TransformPriceFilter - .Operator + Minimum.Filter.Operator .INCLUDES ) .addValue("string") @@ -3212,11 +3246,9 @@ internal class SubscriptionChangeCancelResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -3235,11 +3267,9 @@ internal class SubscriptionChangeCancelResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -3481,10 +3511,10 @@ internal class SubscriptionChangeCancelResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) .operator( - TransformPriceFilter.Operator.INCLUDES + PercentageDiscount.Filter.Operator.INCLUDES ) .addValue("string") .build() @@ -3520,12 +3550,18 @@ internal class SubscriptionChangeCancelResponseTest { .amount("amount") .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() + MonetaryUsageDiscountAdjustment.Filter + .builder() .field( - TransformPriceFilter.Field.PRICE_ID + MonetaryUsageDiscountAdjustment + .Filter + .Field + .PRICE_ID ) .operator( - TransformPriceFilter.Operator + MonetaryUsageDiscountAdjustment + .Filter + .Operator .INCLUDES ) .addValue("string") @@ -3548,12 +3584,13 @@ internal class SubscriptionChangeCancelResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() + PercentageDiscount.Filter.builder() .field( - TransformPriceFilter.Field.PRICE_ID + PercentageDiscount.Filter.Field + .PRICE_ID ) .operator( - TransformPriceFilter.Operator + PercentageDiscount.Filter.Operator .INCLUDES ) .addValue("string") @@ -3571,13 +3608,10 @@ internal class SubscriptionChangeCancelResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field( - TransformPriceFilter.Field.PRICE_ID - ) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) .operator( - TransformPriceFilter.Operator - .INCLUDES + Maximum.Filter.Operator.INCLUDES ) .addValue("string") .build() @@ -3590,13 +3624,10 @@ internal class SubscriptionChangeCancelResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field( - TransformPriceFilter.Field.PRICE_ID - ) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) .operator( - TransformPriceFilter.Operator - .INCLUDES + Minimum.Filter.Operator.INCLUDES ) .addValue("string") .build() @@ -3628,12 +3659,15 @@ internal class SubscriptionChangeCancelResponseTest { .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() + Price.Unit.CompositePriceFilter.builder() .field( - TransformPriceFilter.Field.PRICE_ID + Price.Unit.CompositePriceFilter + .Field + .PRICE_ID ) .operator( - TransformPriceFilter.Operator + Price.Unit.CompositePriceFilter + .Operator .INCLUDES ) .addValue("string") @@ -3677,13 +3711,14 @@ internal class SubscriptionChangeCancelResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() + PercentageDiscount.Filter.builder() .field( - TransformPriceFilter.Field + PercentageDiscount.Filter + .Field .PRICE_ID ) .operator( - TransformPriceFilter + PercentageDiscount.Filter .Operator .INCLUDES ) @@ -3715,14 +3750,13 @@ internal class SubscriptionChangeCancelResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() + Maximum.Filter.builder() .field( - TransformPriceFilter.Field + Maximum.Filter.Field .PRICE_ID ) .operator( - TransformPriceFilter - .Operator + Maximum.Filter.Operator .INCLUDES ) .addValue("string") @@ -3744,14 +3778,13 @@ internal class SubscriptionChangeCancelResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() + Minimum.Filter.builder() .field( - TransformPriceFilter.Field + Minimum.Filter.Field .PRICE_ID ) .operator( - TransformPriceFilter - .Operator + Minimum.Filter.Operator .INCLUDES ) .addValue("string") @@ -3819,11 +3852,9 @@ internal class SubscriptionChangeCancelResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -3841,11 +3872,9 @@ internal class SubscriptionChangeCancelResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -3937,9 +3966,15 @@ internal class SubscriptionChangeCancelResponseTest { ) .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PlanPhaseUsageDiscountAdjustment.Filter.builder() + .field( + PlanPhaseUsageDiscountAdjustment.Filter.Field + .PRICE_ID + ) + .operator( + PlanPhaseUsageDiscountAdjustment.Filter.Operator + .INCLUDES + ) .addValue("string") .build() ) @@ -4067,9 +4102,9 @@ internal class SubscriptionChangeCancelResponseTest { .discountType(AmountDiscountInterval.DiscountType.AMOUNT) .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + AmountDiscountInterval.Filter.builder() + .field(AmountDiscountInterval.Filter.Field.PRICE_ID) + .operator(AmountDiscountInterval.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -4091,9 +4126,9 @@ internal class SubscriptionChangeCancelResponseTest { .addAppliesToPriceIntervalId("string") .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + MaximumInterval.Filter.builder() + .field(MaximumInterval.Filter.Field.PRICE_ID) + .operator(MaximumInterval.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -4111,9 +4146,9 @@ internal class SubscriptionChangeCancelResponseTest { .addAppliesToPriceIntervalId("string") .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + MinimumInterval.Filter.builder() + .field(MinimumInterval.Filter.Field.PRICE_ID) + .operator(MinimumInterval.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -4138,9 +4173,15 @@ internal class SubscriptionChangeCancelResponseTest { ) .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PlanPhaseUsageDiscountAdjustment.Filter.builder() + .field( + PlanPhaseUsageDiscountAdjustment.Filter.Field + .PRICE_ID + ) + .operator( + PlanPhaseUsageDiscountAdjustment.Filter.Operator + .INCLUDES + ) .addValue("string") .build() ) @@ -4170,9 +4211,11 @@ internal class SubscriptionChangeCancelResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator( + PercentageDiscount.Filter.Operator.INCLUDES + ) .addValue("string") .build() ) @@ -4185,9 +4228,9 @@ internal class SubscriptionChangeCancelResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -4204,9 +4247,9 @@ internal class SubscriptionChangeCancelResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -4229,10 +4272,13 @@ internal class SubscriptionChangeCancelResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) + PercentageDiscount.Filter.builder() + .field( + PercentageDiscount.Filter.Field.PRICE_ID + ) .operator( - TransformPriceFilter.Operator.INCLUDES + PercentageDiscount.Filter.Operator + .INCLUDES ) .addValue("string") .build() @@ -4246,11 +4292,9 @@ internal class SubscriptionChangeCancelResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -4262,11 +4306,9 @@ internal class SubscriptionChangeCancelResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -4295,9 +4337,14 @@ internal class SubscriptionChangeCancelResponseTest { .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Price.Unit.CompositePriceFilter.builder() + .field( + Price.Unit.CompositePriceFilter.Field.PRICE_ID + ) + .operator( + Price.Unit.CompositePriceFilter.Operator + .INCLUDES + ) .addValue("string") .build() ) @@ -4332,10 +4379,13 @@ internal class SubscriptionChangeCancelResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) + PercentageDiscount.Filter.builder() + .field( + PercentageDiscount.Filter.Field.PRICE_ID + ) .operator( - TransformPriceFilter.Operator.INCLUDES + PercentageDiscount.Filter.Operator + .INCLUDES ) .addValue("string") .build() @@ -4358,11 +4408,9 @@ internal class SubscriptionChangeCancelResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -4382,11 +4430,9 @@ internal class SubscriptionChangeCancelResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -4466,9 +4512,14 @@ internal class SubscriptionChangeCancelResponseTest { .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Price.Unit.CompositePriceFilter.builder() + .field( + Price.Unit.CompositePriceFilter.Field.PRICE_ID + ) + .operator( + Price.Unit.CompositePriceFilter.Operator + .INCLUDES + ) .addValue("string") .build() ) @@ -4503,10 +4554,13 @@ internal class SubscriptionChangeCancelResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) + PercentageDiscount.Filter.builder() + .field( + PercentageDiscount.Filter.Field.PRICE_ID + ) .operator( - TransformPriceFilter.Operator.INCLUDES + PercentageDiscount.Filter.Operator + .INCLUDES ) .addValue("string") .build() @@ -4529,11 +4583,9 @@ internal class SubscriptionChangeCancelResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -4553,11 +4605,9 @@ internal class SubscriptionChangeCancelResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -4804,10 +4854,13 @@ internal class SubscriptionChangeCancelResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) + PercentageDiscount.Filter.builder() + .field( + PercentageDiscount.Filter.Field.PRICE_ID + ) .operator( - TransformPriceFilter.Operator.INCLUDES + PercentageDiscount.Filter.Operator + .INCLUDES ) .addValue("string") .build() @@ -4853,13 +4906,18 @@ internal class SubscriptionChangeCancelResponseTest { .amount("amount") .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() + MonetaryUsageDiscountAdjustment.Filter + .builder() .field( - TransformPriceFilter.Field + MonetaryUsageDiscountAdjustment + .Filter + .Field .PRICE_ID ) .operator( - TransformPriceFilter.Operator + MonetaryUsageDiscountAdjustment + .Filter + .Operator .INCLUDES ) .addValue("string") @@ -4885,13 +4943,14 @@ internal class SubscriptionChangeCancelResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() + PercentageDiscount.Filter.builder() .field( - TransformPriceFilter.Field + PercentageDiscount.Filter.Field .PRICE_ID ) .operator( - TransformPriceFilter.Operator + PercentageDiscount.Filter + .Operator .INCLUDES ) .addValue("string") @@ -4911,14 +4970,12 @@ internal class SubscriptionChangeCancelResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() + Maximum.Filter.builder() .field( - TransformPriceFilter.Field - .PRICE_ID + Maximum.Filter.Field.PRICE_ID ) .operator( - TransformPriceFilter.Operator - .INCLUDES + Maximum.Filter.Operator.INCLUDES ) .addValue("string") .build() @@ -4931,14 +4988,12 @@ internal class SubscriptionChangeCancelResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() + Minimum.Filter.builder() .field( - TransformPriceFilter.Field - .PRICE_ID + Minimum.Filter.Field.PRICE_ID ) .operator( - TransformPriceFilter.Operator - .INCLUDES + Minimum.Filter.Operator.INCLUDES ) .addValue("string") .build() @@ -4972,13 +5027,16 @@ internal class SubscriptionChangeCancelResponseTest { ) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() + Price.Unit.CompositePriceFilter + .builder() .field( - TransformPriceFilter.Field + Price.Unit.CompositePriceFilter + .Field .PRICE_ID ) .operator( - TransformPriceFilter.Operator + Price.Unit.CompositePriceFilter + .Operator .INCLUDES ) .addValue("string") @@ -5026,14 +5084,17 @@ internal class SubscriptionChangeCancelResponseTest { "7hfgtgjnbvc3ujkl" ) .addFilter( - TransformPriceFilter.builder() + PercentageDiscount.Filter + .builder() .field( - TransformPriceFilter + PercentageDiscount + .Filter .Field .PRICE_ID ) .operator( - TransformPriceFilter + PercentageDiscount + .Filter .Operator .INCLUDES ) @@ -5065,15 +5126,13 @@ internal class SubscriptionChangeCancelResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() + Maximum.Filter.builder() .field( - TransformPriceFilter - .Field + Maximum.Filter.Field .PRICE_ID ) .operator( - TransformPriceFilter - .Operator + Maximum.Filter.Operator .INCLUDES ) .addValue("string") @@ -5095,15 +5154,13 @@ internal class SubscriptionChangeCancelResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() + Minimum.Filter.builder() .field( - TransformPriceFilter - .Field + Minimum.Filter.Field .PRICE_ID ) .operator( - TransformPriceFilter - .Operator + Minimum.Filter.Operator .INCLUDES ) .addValue("string") @@ -5173,11 +5230,9 @@ internal class SubscriptionChangeCancelResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -5199,11 +5254,9 @@ internal class SubscriptionChangeCancelResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -5464,10 +5517,13 @@ internal class SubscriptionChangeCancelResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) + PercentageDiscount.Filter.builder() + .field( + PercentageDiscount.Filter.Field.PRICE_ID + ) .operator( - TransformPriceFilter.Operator.INCLUDES + PercentageDiscount.Filter.Operator + .INCLUDES ) .addValue("string") .build() @@ -5507,13 +5563,18 @@ internal class SubscriptionChangeCancelResponseTest { .amount("amount") .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() + MonetaryUsageDiscountAdjustment.Filter + .builder() .field( - TransformPriceFilter.Field + MonetaryUsageDiscountAdjustment + .Filter + .Field .PRICE_ID ) .operator( - TransformPriceFilter.Operator + MonetaryUsageDiscountAdjustment + .Filter + .Operator .INCLUDES ) .addValue("string") @@ -5539,13 +5600,14 @@ internal class SubscriptionChangeCancelResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() + PercentageDiscount.Filter.builder() .field( - TransformPriceFilter.Field + PercentageDiscount.Filter.Field .PRICE_ID ) .operator( - TransformPriceFilter.Operator + PercentageDiscount.Filter + .Operator .INCLUDES ) .addValue("string") @@ -5565,14 +5627,12 @@ internal class SubscriptionChangeCancelResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() + Maximum.Filter.builder() .field( - TransformPriceFilter.Field - .PRICE_ID + Maximum.Filter.Field.PRICE_ID ) .operator( - TransformPriceFilter.Operator - .INCLUDES + Maximum.Filter.Operator.INCLUDES ) .addValue("string") .build() @@ -5585,14 +5645,12 @@ internal class SubscriptionChangeCancelResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() + Minimum.Filter.builder() .field( - TransformPriceFilter.Field - .PRICE_ID + Minimum.Filter.Field.PRICE_ID ) .operator( - TransformPriceFilter.Operator - .INCLUDES + Minimum.Filter.Operator.INCLUDES ) .addValue("string") .build() @@ -5626,13 +5684,16 @@ internal class SubscriptionChangeCancelResponseTest { ) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() + Price.Unit.CompositePriceFilter + .builder() .field( - TransformPriceFilter.Field + Price.Unit.CompositePriceFilter + .Field .PRICE_ID ) .operator( - TransformPriceFilter.Operator + Price.Unit.CompositePriceFilter + .Operator .INCLUDES ) .addValue("string") @@ -5680,14 +5741,17 @@ internal class SubscriptionChangeCancelResponseTest { "7hfgtgjnbvc3ujkl" ) .addFilter( - TransformPriceFilter.builder() + PercentageDiscount.Filter + .builder() .field( - TransformPriceFilter + PercentageDiscount + .Filter .Field .PRICE_ID ) .operator( - TransformPriceFilter + PercentageDiscount + .Filter .Operator .INCLUDES ) @@ -5719,15 +5783,13 @@ internal class SubscriptionChangeCancelResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() + Maximum.Filter.builder() .field( - TransformPriceFilter - .Field + Maximum.Filter.Field .PRICE_ID ) .operator( - TransformPriceFilter - .Operator + Maximum.Filter.Operator .INCLUDES ) .addValue("string") @@ -5749,15 +5811,13 @@ internal class SubscriptionChangeCancelResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() + Minimum.Filter.builder() .field( - TransformPriceFilter - .Field + Minimum.Filter.Field .PRICE_ID ) .operator( - TransformPriceFilter - .Operator + Minimum.Filter.Operator .INCLUDES ) .addValue("string") @@ -5827,11 +5887,9 @@ internal class SubscriptionChangeCancelResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -5852,11 +5910,9 @@ internal class SubscriptionChangeCancelResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeRetrieveResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeRetrieveResponseTest.kt index b25a4a4f8..3fc962215 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeRetrieveResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeRetrieveResponseTest.kt @@ -34,9 +34,15 @@ internal class SubscriptionChangeRetrieveResponseTest { ) .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PlanPhaseUsageDiscountAdjustment.Filter.builder() + .field( + PlanPhaseUsageDiscountAdjustment.Filter.Field + .PRICE_ID + ) + .operator( + PlanPhaseUsageDiscountAdjustment.Filter.Operator + .INCLUDES + ) .addValue("string") .build() ) @@ -164,9 +170,9 @@ internal class SubscriptionChangeRetrieveResponseTest { .discountType(AmountDiscountInterval.DiscountType.AMOUNT) .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + AmountDiscountInterval.Filter.builder() + .field(AmountDiscountInterval.Filter.Field.PRICE_ID) + .operator(AmountDiscountInterval.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -188,9 +194,9 @@ internal class SubscriptionChangeRetrieveResponseTest { .addAppliesToPriceIntervalId("string") .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + MaximumInterval.Filter.builder() + .field(MaximumInterval.Filter.Field.PRICE_ID) + .operator(MaximumInterval.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -208,9 +214,9 @@ internal class SubscriptionChangeRetrieveResponseTest { .addAppliesToPriceIntervalId("string") .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + MinimumInterval.Filter.builder() + .field(MinimumInterval.Filter.Field.PRICE_ID) + .operator(MinimumInterval.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -235,9 +241,15 @@ internal class SubscriptionChangeRetrieveResponseTest { ) .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PlanPhaseUsageDiscountAdjustment.Filter.builder() + .field( + PlanPhaseUsageDiscountAdjustment.Filter.Field + .PRICE_ID + ) + .operator( + PlanPhaseUsageDiscountAdjustment.Filter.Operator + .INCLUDES + ) .addValue("string") .build() ) @@ -267,9 +279,11 @@ internal class SubscriptionChangeRetrieveResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator( + PercentageDiscount.Filter.Operator.INCLUDES + ) .addValue("string") .build() ) @@ -282,9 +296,9 @@ internal class SubscriptionChangeRetrieveResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -301,9 +315,9 @@ internal class SubscriptionChangeRetrieveResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -326,10 +340,13 @@ internal class SubscriptionChangeRetrieveResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) + PercentageDiscount.Filter.builder() + .field( + PercentageDiscount.Filter.Field.PRICE_ID + ) .operator( - TransformPriceFilter.Operator.INCLUDES + PercentageDiscount.Filter.Operator + .INCLUDES ) .addValue("string") .build() @@ -343,11 +360,9 @@ internal class SubscriptionChangeRetrieveResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -359,11 +374,9 @@ internal class SubscriptionChangeRetrieveResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -392,9 +405,14 @@ internal class SubscriptionChangeRetrieveResponseTest { .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Price.Unit.CompositePriceFilter.builder() + .field( + Price.Unit.CompositePriceFilter.Field.PRICE_ID + ) + .operator( + Price.Unit.CompositePriceFilter.Operator + .INCLUDES + ) .addValue("string") .build() ) @@ -429,10 +447,13 @@ internal class SubscriptionChangeRetrieveResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) + PercentageDiscount.Filter.builder() + .field( + PercentageDiscount.Filter.Field.PRICE_ID + ) .operator( - TransformPriceFilter.Operator.INCLUDES + PercentageDiscount.Filter.Operator + .INCLUDES ) .addValue("string") .build() @@ -455,11 +476,9 @@ internal class SubscriptionChangeRetrieveResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -479,11 +498,9 @@ internal class SubscriptionChangeRetrieveResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -563,9 +580,14 @@ internal class SubscriptionChangeRetrieveResponseTest { .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Price.Unit.CompositePriceFilter.builder() + .field( + Price.Unit.CompositePriceFilter.Field.PRICE_ID + ) + .operator( + Price.Unit.CompositePriceFilter.Operator + .INCLUDES + ) .addValue("string") .build() ) @@ -600,10 +622,13 @@ internal class SubscriptionChangeRetrieveResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) + PercentageDiscount.Filter.builder() + .field( + PercentageDiscount.Filter.Field.PRICE_ID + ) .operator( - TransformPriceFilter.Operator.INCLUDES + PercentageDiscount.Filter.Operator + .INCLUDES ) .addValue("string") .build() @@ -626,11 +651,9 @@ internal class SubscriptionChangeRetrieveResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -650,11 +673,9 @@ internal class SubscriptionChangeRetrieveResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -901,10 +922,13 @@ internal class SubscriptionChangeRetrieveResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) + PercentageDiscount.Filter.builder() + .field( + PercentageDiscount.Filter.Field.PRICE_ID + ) .operator( - TransformPriceFilter.Operator.INCLUDES + PercentageDiscount.Filter.Operator + .INCLUDES ) .addValue("string") .build() @@ -950,13 +974,18 @@ internal class SubscriptionChangeRetrieveResponseTest { .amount("amount") .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() + MonetaryUsageDiscountAdjustment.Filter + .builder() .field( - TransformPriceFilter.Field + MonetaryUsageDiscountAdjustment + .Filter + .Field .PRICE_ID ) .operator( - TransformPriceFilter.Operator + MonetaryUsageDiscountAdjustment + .Filter + .Operator .INCLUDES ) .addValue("string") @@ -982,13 +1011,14 @@ internal class SubscriptionChangeRetrieveResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() + PercentageDiscount.Filter.builder() .field( - TransformPriceFilter.Field + PercentageDiscount.Filter.Field .PRICE_ID ) .operator( - TransformPriceFilter.Operator + PercentageDiscount.Filter + .Operator .INCLUDES ) .addValue("string") @@ -1008,14 +1038,12 @@ internal class SubscriptionChangeRetrieveResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() + Maximum.Filter.builder() .field( - TransformPriceFilter.Field - .PRICE_ID + Maximum.Filter.Field.PRICE_ID ) .operator( - TransformPriceFilter.Operator - .INCLUDES + Maximum.Filter.Operator.INCLUDES ) .addValue("string") .build() @@ -1028,14 +1056,12 @@ internal class SubscriptionChangeRetrieveResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() + Minimum.Filter.builder() .field( - TransformPriceFilter.Field - .PRICE_ID + Minimum.Filter.Field.PRICE_ID ) .operator( - TransformPriceFilter.Operator - .INCLUDES + Minimum.Filter.Operator.INCLUDES ) .addValue("string") .build() @@ -1069,13 +1095,16 @@ internal class SubscriptionChangeRetrieveResponseTest { ) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() + Price.Unit.CompositePriceFilter + .builder() .field( - TransformPriceFilter.Field + Price.Unit.CompositePriceFilter + .Field .PRICE_ID ) .operator( - TransformPriceFilter.Operator + Price.Unit.CompositePriceFilter + .Operator .INCLUDES ) .addValue("string") @@ -1123,14 +1152,17 @@ internal class SubscriptionChangeRetrieveResponseTest { "7hfgtgjnbvc3ujkl" ) .addFilter( - TransformPriceFilter.builder() + PercentageDiscount.Filter + .builder() .field( - TransformPriceFilter + PercentageDiscount + .Filter .Field .PRICE_ID ) .operator( - TransformPriceFilter + PercentageDiscount + .Filter .Operator .INCLUDES ) @@ -1162,15 +1194,13 @@ internal class SubscriptionChangeRetrieveResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() + Maximum.Filter.builder() .field( - TransformPriceFilter - .Field + Maximum.Filter.Field .PRICE_ID ) .operator( - TransformPriceFilter - .Operator + Maximum.Filter.Operator .INCLUDES ) .addValue("string") @@ -1192,15 +1222,13 @@ internal class SubscriptionChangeRetrieveResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() + Minimum.Filter.builder() .field( - TransformPriceFilter - .Field + Minimum.Filter.Field .PRICE_ID ) .operator( - TransformPriceFilter - .Operator + Minimum.Filter.Operator .INCLUDES ) .addValue("string") @@ -1270,11 +1298,9 @@ internal class SubscriptionChangeRetrieveResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -1296,11 +1322,9 @@ internal class SubscriptionChangeRetrieveResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -1561,10 +1585,13 @@ internal class SubscriptionChangeRetrieveResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) + PercentageDiscount.Filter.builder() + .field( + PercentageDiscount.Filter.Field.PRICE_ID + ) .operator( - TransformPriceFilter.Operator.INCLUDES + PercentageDiscount.Filter.Operator + .INCLUDES ) .addValue("string") .build() @@ -1604,13 +1631,18 @@ internal class SubscriptionChangeRetrieveResponseTest { .amount("amount") .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() + MonetaryUsageDiscountAdjustment.Filter + .builder() .field( - TransformPriceFilter.Field + MonetaryUsageDiscountAdjustment + .Filter + .Field .PRICE_ID ) .operator( - TransformPriceFilter.Operator + MonetaryUsageDiscountAdjustment + .Filter + .Operator .INCLUDES ) .addValue("string") @@ -1636,13 +1668,14 @@ internal class SubscriptionChangeRetrieveResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() + PercentageDiscount.Filter.builder() .field( - TransformPriceFilter.Field + PercentageDiscount.Filter.Field .PRICE_ID ) .operator( - TransformPriceFilter.Operator + PercentageDiscount.Filter + .Operator .INCLUDES ) .addValue("string") @@ -1662,14 +1695,12 @@ internal class SubscriptionChangeRetrieveResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() + Maximum.Filter.builder() .field( - TransformPriceFilter.Field - .PRICE_ID + Maximum.Filter.Field.PRICE_ID ) .operator( - TransformPriceFilter.Operator - .INCLUDES + Maximum.Filter.Operator.INCLUDES ) .addValue("string") .build() @@ -1682,14 +1713,12 @@ internal class SubscriptionChangeRetrieveResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() + Minimum.Filter.builder() .field( - TransformPriceFilter.Field - .PRICE_ID + Minimum.Filter.Field.PRICE_ID ) .operator( - TransformPriceFilter.Operator - .INCLUDES + Minimum.Filter.Operator.INCLUDES ) .addValue("string") .build() @@ -1723,13 +1752,16 @@ internal class SubscriptionChangeRetrieveResponseTest { ) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() + Price.Unit.CompositePriceFilter + .builder() .field( - TransformPriceFilter.Field + Price.Unit.CompositePriceFilter + .Field .PRICE_ID ) .operator( - TransformPriceFilter.Operator + Price.Unit.CompositePriceFilter + .Operator .INCLUDES ) .addValue("string") @@ -1777,14 +1809,17 @@ internal class SubscriptionChangeRetrieveResponseTest { "7hfgtgjnbvc3ujkl" ) .addFilter( - TransformPriceFilter.builder() + PercentageDiscount.Filter + .builder() .field( - TransformPriceFilter + PercentageDiscount + .Filter .Field .PRICE_ID ) .operator( - TransformPriceFilter + PercentageDiscount + .Filter .Operator .INCLUDES ) @@ -1816,15 +1851,13 @@ internal class SubscriptionChangeRetrieveResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() + Maximum.Filter.builder() .field( - TransformPriceFilter - .Field + Maximum.Filter.Field .PRICE_ID ) .operator( - TransformPriceFilter - .Operator + Maximum.Filter.Operator .INCLUDES ) .addValue("string") @@ -1846,15 +1879,13 @@ internal class SubscriptionChangeRetrieveResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() + Minimum.Filter.builder() .field( - TransformPriceFilter - .Field + Minimum.Filter.Field .PRICE_ID ) .operator( - TransformPriceFilter - .Operator + Minimum.Filter.Operator .INCLUDES ) .addValue("string") @@ -1924,11 +1955,9 @@ internal class SubscriptionChangeRetrieveResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -1949,11 +1978,9 @@ internal class SubscriptionChangeRetrieveResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -2043,9 +2070,15 @@ internal class SubscriptionChangeRetrieveResponseTest { ) .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PlanPhaseUsageDiscountAdjustment.Filter.builder() + .field( + PlanPhaseUsageDiscountAdjustment.Filter.Field + .PRICE_ID + ) + .operator( + PlanPhaseUsageDiscountAdjustment.Filter.Operator + .INCLUDES + ) .addValue("string") .build() ) @@ -2165,9 +2198,9 @@ internal class SubscriptionChangeRetrieveResponseTest { .discountType(AmountDiscountInterval.DiscountType.AMOUNT) .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + AmountDiscountInterval.Filter.builder() + .field(AmountDiscountInterval.Filter.Field.PRICE_ID) + .operator(AmountDiscountInterval.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -2189,9 +2222,9 @@ internal class SubscriptionChangeRetrieveResponseTest { .addAppliesToPriceIntervalId("string") .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + MaximumInterval.Filter.builder() + .field(MaximumInterval.Filter.Field.PRICE_ID) + .operator(MaximumInterval.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -2209,9 +2242,9 @@ internal class SubscriptionChangeRetrieveResponseTest { .addAppliesToPriceIntervalId("string") .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + MinimumInterval.Filter.builder() + .field(MinimumInterval.Filter.Field.PRICE_ID) + .operator(MinimumInterval.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -2236,9 +2269,15 @@ internal class SubscriptionChangeRetrieveResponseTest { ) .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PlanPhaseUsageDiscountAdjustment.Filter.builder() + .field( + PlanPhaseUsageDiscountAdjustment.Filter.Field + .PRICE_ID + ) + .operator( + PlanPhaseUsageDiscountAdjustment.Filter.Operator + .INCLUDES + ) .addValue("string") .build() ) @@ -2268,9 +2307,9 @@ internal class SubscriptionChangeRetrieveResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -2283,9 +2322,9 @@ internal class SubscriptionChangeRetrieveResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -2302,9 +2341,9 @@ internal class SubscriptionChangeRetrieveResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -2327,10 +2366,10 @@ internal class SubscriptionChangeRetrieveResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) .operator( - TransformPriceFilter.Operator.INCLUDES + PercentageDiscount.Filter.Operator.INCLUDES ) .addValue("string") .build() @@ -2344,11 +2383,9 @@ internal class SubscriptionChangeRetrieveResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -2360,11 +2397,9 @@ internal class SubscriptionChangeRetrieveResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -2391,9 +2426,11 @@ internal class SubscriptionChangeRetrieveResponseTest { .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Price.Unit.CompositePriceFilter.builder() + .field(Price.Unit.CompositePriceFilter.Field.PRICE_ID) + .operator( + Price.Unit.CompositePriceFilter.Operator.INCLUDES + ) .addValue("string") .build() ) @@ -2426,10 +2463,10 @@ internal class SubscriptionChangeRetrieveResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) .operator( - TransformPriceFilter.Operator.INCLUDES + PercentageDiscount.Filter.Operator.INCLUDES ) .addValue("string") .build() @@ -2452,11 +2489,9 @@ internal class SubscriptionChangeRetrieveResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -2473,11 +2508,9 @@ internal class SubscriptionChangeRetrieveResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -2551,9 +2584,11 @@ internal class SubscriptionChangeRetrieveResponseTest { .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Price.Unit.CompositePriceFilter.builder() + .field(Price.Unit.CompositePriceFilter.Field.PRICE_ID) + .operator( + Price.Unit.CompositePriceFilter.Operator.INCLUDES + ) .addValue("string") .build() ) @@ -2586,10 +2621,10 @@ internal class SubscriptionChangeRetrieveResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) .operator( - TransformPriceFilter.Operator.INCLUDES + PercentageDiscount.Filter.Operator.INCLUDES ) .addValue("string") .build() @@ -2612,11 +2647,9 @@ internal class SubscriptionChangeRetrieveResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -2633,11 +2666,9 @@ internal class SubscriptionChangeRetrieveResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -2869,10 +2900,10 @@ internal class SubscriptionChangeRetrieveResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) .operator( - TransformPriceFilter.Operator.INCLUDES + PercentageDiscount.Filter.Operator.INCLUDES ) .addValue("string") .build() @@ -2913,12 +2944,18 @@ internal class SubscriptionChangeRetrieveResponseTest { .amount("amount") .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() + MonetaryUsageDiscountAdjustment.Filter + .builder() .field( - TransformPriceFilter.Field.PRICE_ID + MonetaryUsageDiscountAdjustment + .Filter + .Field + .PRICE_ID ) .operator( - TransformPriceFilter.Operator + MonetaryUsageDiscountAdjustment + .Filter + .Operator .INCLUDES ) .addValue("string") @@ -2941,12 +2978,13 @@ internal class SubscriptionChangeRetrieveResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() + PercentageDiscount.Filter.builder() .field( - TransformPriceFilter.Field.PRICE_ID + PercentageDiscount.Filter.Field + .PRICE_ID ) .operator( - TransformPriceFilter.Operator + PercentageDiscount.Filter.Operator .INCLUDES ) .addValue("string") @@ -2964,13 +3002,10 @@ internal class SubscriptionChangeRetrieveResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field( - TransformPriceFilter.Field.PRICE_ID - ) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) .operator( - TransformPriceFilter.Operator - .INCLUDES + Maximum.Filter.Operator.INCLUDES ) .addValue("string") .build() @@ -2983,13 +3018,10 @@ internal class SubscriptionChangeRetrieveResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field( - TransformPriceFilter.Field.PRICE_ID - ) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) .operator( - TransformPriceFilter.Operator - .INCLUDES + Minimum.Filter.Operator.INCLUDES ) .addValue("string") .build() @@ -3021,12 +3053,15 @@ internal class SubscriptionChangeRetrieveResponseTest { .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() + Price.Unit.CompositePriceFilter.builder() .field( - TransformPriceFilter.Field.PRICE_ID + Price.Unit.CompositePriceFilter + .Field + .PRICE_ID ) .operator( - TransformPriceFilter.Operator + Price.Unit.CompositePriceFilter + .Operator .INCLUDES ) .addValue("string") @@ -3070,13 +3105,14 @@ internal class SubscriptionChangeRetrieveResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() + PercentageDiscount.Filter.builder() .field( - TransformPriceFilter.Field + PercentageDiscount.Filter + .Field .PRICE_ID ) .operator( - TransformPriceFilter + PercentageDiscount.Filter .Operator .INCLUDES ) @@ -3108,14 +3144,13 @@ internal class SubscriptionChangeRetrieveResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() + Maximum.Filter.builder() .field( - TransformPriceFilter.Field + Maximum.Filter.Field .PRICE_ID ) .operator( - TransformPriceFilter - .Operator + Maximum.Filter.Operator .INCLUDES ) .addValue("string") @@ -3137,14 +3172,13 @@ internal class SubscriptionChangeRetrieveResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() + Minimum.Filter.builder() .field( - TransformPriceFilter.Field + Minimum.Filter.Field .PRICE_ID ) .operator( - TransformPriceFilter - .Operator + Minimum.Filter.Operator .INCLUDES ) .addValue("string") @@ -3212,11 +3246,9 @@ internal class SubscriptionChangeRetrieveResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -3235,11 +3267,9 @@ internal class SubscriptionChangeRetrieveResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -3481,10 +3511,10 @@ internal class SubscriptionChangeRetrieveResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) .operator( - TransformPriceFilter.Operator.INCLUDES + PercentageDiscount.Filter.Operator.INCLUDES ) .addValue("string") .build() @@ -3520,12 +3550,18 @@ internal class SubscriptionChangeRetrieveResponseTest { .amount("amount") .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() + MonetaryUsageDiscountAdjustment.Filter + .builder() .field( - TransformPriceFilter.Field.PRICE_ID + MonetaryUsageDiscountAdjustment + .Filter + .Field + .PRICE_ID ) .operator( - TransformPriceFilter.Operator + MonetaryUsageDiscountAdjustment + .Filter + .Operator .INCLUDES ) .addValue("string") @@ -3548,12 +3584,13 @@ internal class SubscriptionChangeRetrieveResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() + PercentageDiscount.Filter.builder() .field( - TransformPriceFilter.Field.PRICE_ID + PercentageDiscount.Filter.Field + .PRICE_ID ) .operator( - TransformPriceFilter.Operator + PercentageDiscount.Filter.Operator .INCLUDES ) .addValue("string") @@ -3571,13 +3608,10 @@ internal class SubscriptionChangeRetrieveResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field( - TransformPriceFilter.Field.PRICE_ID - ) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) .operator( - TransformPriceFilter.Operator - .INCLUDES + Maximum.Filter.Operator.INCLUDES ) .addValue("string") .build() @@ -3590,13 +3624,10 @@ internal class SubscriptionChangeRetrieveResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field( - TransformPriceFilter.Field.PRICE_ID - ) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) .operator( - TransformPriceFilter.Operator - .INCLUDES + Minimum.Filter.Operator.INCLUDES ) .addValue("string") .build() @@ -3628,12 +3659,15 @@ internal class SubscriptionChangeRetrieveResponseTest { .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() + Price.Unit.CompositePriceFilter.builder() .field( - TransformPriceFilter.Field.PRICE_ID + Price.Unit.CompositePriceFilter + .Field + .PRICE_ID ) .operator( - TransformPriceFilter.Operator + Price.Unit.CompositePriceFilter + .Operator .INCLUDES ) .addValue("string") @@ -3677,13 +3711,14 @@ internal class SubscriptionChangeRetrieveResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() + PercentageDiscount.Filter.builder() .field( - TransformPriceFilter.Field + PercentageDiscount.Filter + .Field .PRICE_ID ) .operator( - TransformPriceFilter + PercentageDiscount.Filter .Operator .INCLUDES ) @@ -3715,14 +3750,13 @@ internal class SubscriptionChangeRetrieveResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() + Maximum.Filter.builder() .field( - TransformPriceFilter.Field + Maximum.Filter.Field .PRICE_ID ) .operator( - TransformPriceFilter - .Operator + Maximum.Filter.Operator .INCLUDES ) .addValue("string") @@ -3744,14 +3778,13 @@ internal class SubscriptionChangeRetrieveResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() + Minimum.Filter.builder() .field( - TransformPriceFilter.Field + Minimum.Filter.Field .PRICE_ID ) .operator( - TransformPriceFilter - .Operator + Minimum.Filter.Operator .INCLUDES ) .addValue("string") @@ -3819,11 +3852,9 @@ internal class SubscriptionChangeRetrieveResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -3841,11 +3872,9 @@ internal class SubscriptionChangeRetrieveResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -3937,9 +3966,15 @@ internal class SubscriptionChangeRetrieveResponseTest { ) .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PlanPhaseUsageDiscountAdjustment.Filter.builder() + .field( + PlanPhaseUsageDiscountAdjustment.Filter.Field + .PRICE_ID + ) + .operator( + PlanPhaseUsageDiscountAdjustment.Filter.Operator + .INCLUDES + ) .addValue("string") .build() ) @@ -4067,9 +4102,9 @@ internal class SubscriptionChangeRetrieveResponseTest { .discountType(AmountDiscountInterval.DiscountType.AMOUNT) .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + AmountDiscountInterval.Filter.builder() + .field(AmountDiscountInterval.Filter.Field.PRICE_ID) + .operator(AmountDiscountInterval.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -4091,9 +4126,9 @@ internal class SubscriptionChangeRetrieveResponseTest { .addAppliesToPriceIntervalId("string") .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + MaximumInterval.Filter.builder() + .field(MaximumInterval.Filter.Field.PRICE_ID) + .operator(MaximumInterval.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -4111,9 +4146,9 @@ internal class SubscriptionChangeRetrieveResponseTest { .addAppliesToPriceIntervalId("string") .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + MinimumInterval.Filter.builder() + .field(MinimumInterval.Filter.Field.PRICE_ID) + .operator(MinimumInterval.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -4138,9 +4173,15 @@ internal class SubscriptionChangeRetrieveResponseTest { ) .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PlanPhaseUsageDiscountAdjustment.Filter.builder() + .field( + PlanPhaseUsageDiscountAdjustment.Filter.Field + .PRICE_ID + ) + .operator( + PlanPhaseUsageDiscountAdjustment.Filter.Operator + .INCLUDES + ) .addValue("string") .build() ) @@ -4170,9 +4211,11 @@ internal class SubscriptionChangeRetrieveResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator( + PercentageDiscount.Filter.Operator.INCLUDES + ) .addValue("string") .build() ) @@ -4185,9 +4228,9 @@ internal class SubscriptionChangeRetrieveResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -4204,9 +4247,9 @@ internal class SubscriptionChangeRetrieveResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -4229,10 +4272,13 @@ internal class SubscriptionChangeRetrieveResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) + PercentageDiscount.Filter.builder() + .field( + PercentageDiscount.Filter.Field.PRICE_ID + ) .operator( - TransformPriceFilter.Operator.INCLUDES + PercentageDiscount.Filter.Operator + .INCLUDES ) .addValue("string") .build() @@ -4246,11 +4292,9 @@ internal class SubscriptionChangeRetrieveResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -4262,11 +4306,9 @@ internal class SubscriptionChangeRetrieveResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -4295,9 +4337,14 @@ internal class SubscriptionChangeRetrieveResponseTest { .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Price.Unit.CompositePriceFilter.builder() + .field( + Price.Unit.CompositePriceFilter.Field.PRICE_ID + ) + .operator( + Price.Unit.CompositePriceFilter.Operator + .INCLUDES + ) .addValue("string") .build() ) @@ -4332,10 +4379,13 @@ internal class SubscriptionChangeRetrieveResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) + PercentageDiscount.Filter.builder() + .field( + PercentageDiscount.Filter.Field.PRICE_ID + ) .operator( - TransformPriceFilter.Operator.INCLUDES + PercentageDiscount.Filter.Operator + .INCLUDES ) .addValue("string") .build() @@ -4358,11 +4408,9 @@ internal class SubscriptionChangeRetrieveResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -4382,11 +4430,9 @@ internal class SubscriptionChangeRetrieveResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -4466,9 +4512,14 @@ internal class SubscriptionChangeRetrieveResponseTest { .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Price.Unit.CompositePriceFilter.builder() + .field( + Price.Unit.CompositePriceFilter.Field.PRICE_ID + ) + .operator( + Price.Unit.CompositePriceFilter.Operator + .INCLUDES + ) .addValue("string") .build() ) @@ -4503,10 +4554,13 @@ internal class SubscriptionChangeRetrieveResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) + PercentageDiscount.Filter.builder() + .field( + PercentageDiscount.Filter.Field.PRICE_ID + ) .operator( - TransformPriceFilter.Operator.INCLUDES + PercentageDiscount.Filter.Operator + .INCLUDES ) .addValue("string") .build() @@ -4529,11 +4583,9 @@ internal class SubscriptionChangeRetrieveResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -4553,11 +4605,9 @@ internal class SubscriptionChangeRetrieveResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -4804,10 +4854,13 @@ internal class SubscriptionChangeRetrieveResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) + PercentageDiscount.Filter.builder() + .field( + PercentageDiscount.Filter.Field.PRICE_ID + ) .operator( - TransformPriceFilter.Operator.INCLUDES + PercentageDiscount.Filter.Operator + .INCLUDES ) .addValue("string") .build() @@ -4853,13 +4906,18 @@ internal class SubscriptionChangeRetrieveResponseTest { .amount("amount") .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() + MonetaryUsageDiscountAdjustment.Filter + .builder() .field( - TransformPriceFilter.Field + MonetaryUsageDiscountAdjustment + .Filter + .Field .PRICE_ID ) .operator( - TransformPriceFilter.Operator + MonetaryUsageDiscountAdjustment + .Filter + .Operator .INCLUDES ) .addValue("string") @@ -4885,13 +4943,14 @@ internal class SubscriptionChangeRetrieveResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() + PercentageDiscount.Filter.builder() .field( - TransformPriceFilter.Field + PercentageDiscount.Filter.Field .PRICE_ID ) .operator( - TransformPriceFilter.Operator + PercentageDiscount.Filter + .Operator .INCLUDES ) .addValue("string") @@ -4911,14 +4970,12 @@ internal class SubscriptionChangeRetrieveResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() + Maximum.Filter.builder() .field( - TransformPriceFilter.Field - .PRICE_ID + Maximum.Filter.Field.PRICE_ID ) .operator( - TransformPriceFilter.Operator - .INCLUDES + Maximum.Filter.Operator.INCLUDES ) .addValue("string") .build() @@ -4931,14 +4988,12 @@ internal class SubscriptionChangeRetrieveResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() + Minimum.Filter.builder() .field( - TransformPriceFilter.Field - .PRICE_ID + Minimum.Filter.Field.PRICE_ID ) .operator( - TransformPriceFilter.Operator - .INCLUDES + Minimum.Filter.Operator.INCLUDES ) .addValue("string") .build() @@ -4972,13 +5027,16 @@ internal class SubscriptionChangeRetrieveResponseTest { ) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() + Price.Unit.CompositePriceFilter + .builder() .field( - TransformPriceFilter.Field + Price.Unit.CompositePriceFilter + .Field .PRICE_ID ) .operator( - TransformPriceFilter.Operator + Price.Unit.CompositePriceFilter + .Operator .INCLUDES ) .addValue("string") @@ -5026,14 +5084,17 @@ internal class SubscriptionChangeRetrieveResponseTest { "7hfgtgjnbvc3ujkl" ) .addFilter( - TransformPriceFilter.builder() + PercentageDiscount.Filter + .builder() .field( - TransformPriceFilter + PercentageDiscount + .Filter .Field .PRICE_ID ) .operator( - TransformPriceFilter + PercentageDiscount + .Filter .Operator .INCLUDES ) @@ -5065,15 +5126,13 @@ internal class SubscriptionChangeRetrieveResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() + Maximum.Filter.builder() .field( - TransformPriceFilter - .Field + Maximum.Filter.Field .PRICE_ID ) .operator( - TransformPriceFilter - .Operator + Maximum.Filter.Operator .INCLUDES ) .addValue("string") @@ -5095,15 +5154,13 @@ internal class SubscriptionChangeRetrieveResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() + Minimum.Filter.builder() .field( - TransformPriceFilter - .Field + Minimum.Filter.Field .PRICE_ID ) .operator( - TransformPriceFilter - .Operator + Minimum.Filter.Operator .INCLUDES ) .addValue("string") @@ -5173,11 +5230,9 @@ internal class SubscriptionChangeRetrieveResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -5199,11 +5254,9 @@ internal class SubscriptionChangeRetrieveResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -5464,10 +5517,13 @@ internal class SubscriptionChangeRetrieveResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) + PercentageDiscount.Filter.builder() + .field( + PercentageDiscount.Filter.Field.PRICE_ID + ) .operator( - TransformPriceFilter.Operator.INCLUDES + PercentageDiscount.Filter.Operator + .INCLUDES ) .addValue("string") .build() @@ -5507,13 +5563,18 @@ internal class SubscriptionChangeRetrieveResponseTest { .amount("amount") .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() + MonetaryUsageDiscountAdjustment.Filter + .builder() .field( - TransformPriceFilter.Field + MonetaryUsageDiscountAdjustment + .Filter + .Field .PRICE_ID ) .operator( - TransformPriceFilter.Operator + MonetaryUsageDiscountAdjustment + .Filter + .Operator .INCLUDES ) .addValue("string") @@ -5539,13 +5600,14 @@ internal class SubscriptionChangeRetrieveResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() + PercentageDiscount.Filter.builder() .field( - TransformPriceFilter.Field + PercentageDiscount.Filter.Field .PRICE_ID ) .operator( - TransformPriceFilter.Operator + PercentageDiscount.Filter + .Operator .INCLUDES ) .addValue("string") @@ -5565,14 +5627,12 @@ internal class SubscriptionChangeRetrieveResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() + Maximum.Filter.builder() .field( - TransformPriceFilter.Field - .PRICE_ID + Maximum.Filter.Field.PRICE_ID ) .operator( - TransformPriceFilter.Operator - .INCLUDES + Maximum.Filter.Operator.INCLUDES ) .addValue("string") .build() @@ -5585,14 +5645,12 @@ internal class SubscriptionChangeRetrieveResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() + Minimum.Filter.builder() .field( - TransformPriceFilter.Field - .PRICE_ID + Minimum.Filter.Field.PRICE_ID ) .operator( - TransformPriceFilter.Operator - .INCLUDES + Minimum.Filter.Operator.INCLUDES ) .addValue("string") .build() @@ -5626,13 +5684,16 @@ internal class SubscriptionChangeRetrieveResponseTest { ) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() + Price.Unit.CompositePriceFilter + .builder() .field( - TransformPriceFilter.Field + Price.Unit.CompositePriceFilter + .Field .PRICE_ID ) .operator( - TransformPriceFilter.Operator + Price.Unit.CompositePriceFilter + .Operator .INCLUDES ) .addValue("string") @@ -5680,14 +5741,17 @@ internal class SubscriptionChangeRetrieveResponseTest { "7hfgtgjnbvc3ujkl" ) .addFilter( - TransformPriceFilter.builder() + PercentageDiscount.Filter + .builder() .field( - TransformPriceFilter + PercentageDiscount + .Filter .Field .PRICE_ID ) .operator( - TransformPriceFilter + PercentageDiscount + .Filter .Operator .INCLUDES ) @@ -5719,15 +5783,13 @@ internal class SubscriptionChangeRetrieveResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() + Maximum.Filter.builder() .field( - TransformPriceFilter - .Field + Maximum.Filter.Field .PRICE_ID ) .operator( - TransformPriceFilter - .Operator + Maximum.Filter.Operator .INCLUDES ) .addValue("string") @@ -5749,15 +5811,13 @@ internal class SubscriptionChangeRetrieveResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() + Minimum.Filter.builder() .field( - TransformPriceFilter - .Field + Minimum.Filter.Field .PRICE_ID ) .operator( - TransformPriceFilter - .Operator + Minimum.Filter.Operator .INCLUDES ) .addValue("string") @@ -5827,11 +5887,9 @@ internal class SubscriptionChangeRetrieveResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -5852,11 +5910,9 @@ internal class SubscriptionChangeRetrieveResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionCreateParamsTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionCreateParamsTest.kt index d3bc4d6d3..d5d17446b 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionCreateParamsTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionCreateParamsTest.kt @@ -27,9 +27,9 @@ internal class SubscriptionCreateParamsTest { .addAppliesToPriceId("price_2") .currency("currency") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + NewPercentageDiscount.Filter.builder() + .field(NewPercentageDiscount.Filter.Field.PRICE_ID) + .operator(NewPercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -177,9 +177,9 @@ internal class SubscriptionCreateParamsTest { .addAppliesToPriceId("price_2") .currency("currency") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + NewPercentageDiscount.Filter.builder() + .field(NewPercentageDiscount.Filter.Field.PRICE_ID) + .operator(NewPercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -293,9 +293,9 @@ internal class SubscriptionCreateParamsTest { .addAppliesToPriceId("price_2") .currency("currency") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + NewPercentageDiscount.Filter.builder() + .field(NewPercentageDiscount.Filter.Field.PRICE_ID) + .operator(NewPercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -445,9 +445,9 @@ internal class SubscriptionCreateParamsTest { .addAppliesToPriceId("price_2") .currency("currency") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + NewPercentageDiscount.Filter.builder() + .field(NewPercentageDiscount.Filter.Field.PRICE_ID) + .operator(NewPercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -561,9 +561,9 @@ internal class SubscriptionCreateParamsTest { .addAppliesToPriceId("price_2") .currency("currency") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + NewPercentageDiscount.Filter.builder() + .field(NewPercentageDiscount.Filter.Field.PRICE_ID) + .operator(NewPercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -717,9 +717,9 @@ internal class SubscriptionCreateParamsTest { .addAppliesToPriceId("price_2") .currency("currency") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + NewPercentageDiscount.Filter.builder() + .field(NewPercentageDiscount.Filter.Field.PRICE_ID) + .operator(NewPercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionFetchCostsResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionFetchCostsResponseTest.kt index 26f07d4c0..19e7d5af8 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionFetchCostsResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionFetchCostsResponseTest.kt @@ -36,9 +36,14 @@ internal class SubscriptionFetchCostsResponseTest { .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Price.Unit.CompositePriceFilter.builder() + .field( + Price.Unit.CompositePriceFilter.Field.PRICE_ID + ) + .operator( + Price.Unit.CompositePriceFilter.Operator + .INCLUDES + ) .addValue("string") .build() ) @@ -73,10 +78,13 @@ internal class SubscriptionFetchCostsResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) + PercentageDiscount.Filter.builder() + .field( + PercentageDiscount.Filter.Field.PRICE_ID + ) .operator( - TransformPriceFilter.Operator.INCLUDES + PercentageDiscount.Filter.Operator + .INCLUDES ) .addValue("string") .build() @@ -99,11 +107,9 @@ internal class SubscriptionFetchCostsResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -123,11 +129,9 @@ internal class SubscriptionFetchCostsResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -186,9 +190,11 @@ internal class SubscriptionFetchCostsResponseTest { .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Price.Unit.CompositePriceFilter.builder() + .field(Price.Unit.CompositePriceFilter.Field.PRICE_ID) + .operator( + Price.Unit.CompositePriceFilter.Operator.INCLUDES + ) .addValue("string") .build() ) @@ -221,10 +227,10 @@ internal class SubscriptionFetchCostsResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) .operator( - TransformPriceFilter.Operator.INCLUDES + PercentageDiscount.Filter.Operator.INCLUDES ) .addValue("string") .build() @@ -247,11 +253,9 @@ internal class SubscriptionFetchCostsResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -268,11 +272,9 @@ internal class SubscriptionFetchCostsResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -335,9 +337,14 @@ internal class SubscriptionFetchCostsResponseTest { .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Price.Unit.CompositePriceFilter.builder() + .field( + Price.Unit.CompositePriceFilter.Field.PRICE_ID + ) + .operator( + Price.Unit.CompositePriceFilter.Operator + .INCLUDES + ) .addValue("string") .build() ) @@ -372,10 +379,13 @@ internal class SubscriptionFetchCostsResponseTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) + PercentageDiscount.Filter.builder() + .field( + PercentageDiscount.Filter.Field.PRICE_ID + ) .operator( - TransformPriceFilter.Operator.INCLUDES + PercentageDiscount.Filter.Operator + .INCLUDES ) .addValue("string") .build() @@ -398,11 +408,9 @@ internal class SubscriptionFetchCostsResponseTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -422,11 +430,9 @@ internal class SubscriptionFetchCostsResponseTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsParamsTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsParamsTest.kt index 4e49452d1..7e863cd19 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsParamsTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsParamsTest.kt @@ -107,9 +107,9 @@ internal class SubscriptionPriceIntervalsParamsTest { .addAppliesToPriceId("price_2") .currency("currency") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + NewPercentageDiscount.Filter.builder() + .field(NewPercentageDiscount.Filter.Field.PRICE_ID) + .operator(NewPercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -260,9 +260,9 @@ internal class SubscriptionPriceIntervalsParamsTest { .addAppliesToPriceId("price_2") .currency("currency") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + NewPercentageDiscount.Filter.builder() + .field(NewPercentageDiscount.Filter.Field.PRICE_ID) + .operator(NewPercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -399,9 +399,9 @@ internal class SubscriptionPriceIntervalsParamsTest { .addAppliesToPriceId("price_2") .currency("currency") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + NewPercentageDiscount.Filter.builder() + .field(NewPercentageDiscount.Filter.Field.PRICE_ID) + .operator(NewPercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionSchedulePlanChangeParamsTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionSchedulePlanChangeParamsTest.kt index 31bd5b8f7..73627955e 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionSchedulePlanChangeParamsTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionSchedulePlanChangeParamsTest.kt @@ -29,9 +29,9 @@ internal class SubscriptionSchedulePlanChangeParamsTest { .addAppliesToPriceId("price_2") .currency("currency") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + NewPercentageDiscount.Filter.builder() + .field(NewPercentageDiscount.Filter.Field.PRICE_ID) + .operator(NewPercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -170,9 +170,9 @@ internal class SubscriptionSchedulePlanChangeParamsTest { .addAppliesToPriceId("price_2") .currency("currency") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + NewPercentageDiscount.Filter.builder() + .field(NewPercentageDiscount.Filter.Field.PRICE_ID) + .operator(NewPercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -300,9 +300,9 @@ internal class SubscriptionSchedulePlanChangeParamsTest { .addAppliesToPriceId("price_2") .currency("currency") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + NewPercentageDiscount.Filter.builder() + .field(NewPercentageDiscount.Filter.Field.PRICE_ID) + .operator(NewPercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -443,9 +443,9 @@ internal class SubscriptionSchedulePlanChangeParamsTest { .addAppliesToPriceId("price_2") .currency("currency") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + NewPercentageDiscount.Filter.builder() + .field(NewPercentageDiscount.Filter.Field.PRICE_ID) + .operator(NewPercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -560,9 +560,9 @@ internal class SubscriptionSchedulePlanChangeParamsTest { .addAppliesToPriceId("price_2") .currency("currency") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + NewPercentageDiscount.Filter.builder() + .field(NewPercentageDiscount.Filter.Field.PRICE_ID) + .operator(NewPercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -703,9 +703,9 @@ internal class SubscriptionSchedulePlanChangeParamsTest { .addAppliesToPriceId("price_2") .currency("currency") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + NewPercentageDiscount.Filter.builder() + .field(NewPercentageDiscount.Filter.Field.PRICE_ID) + .operator(NewPercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionTest.kt index fadd92e9b..667ed170b 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionTest.kt @@ -28,9 +28,14 @@ internal class SubscriptionTest { ) .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PlanPhaseUsageDiscountAdjustment.Filter.builder() + .field( + PlanPhaseUsageDiscountAdjustment.Filter.Field.PRICE_ID + ) + .operator( + PlanPhaseUsageDiscountAdjustment.Filter.Operator + .INCLUDES + ) .addValue("string") .build() ) @@ -149,9 +154,9 @@ internal class SubscriptionTest { .discountType(AmountDiscountInterval.DiscountType.AMOUNT) .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + AmountDiscountInterval.Filter.builder() + .field(AmountDiscountInterval.Filter.Field.PRICE_ID) + .operator(AmountDiscountInterval.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -173,9 +178,9 @@ internal class SubscriptionTest { .addAppliesToPriceIntervalId("string") .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + MaximumInterval.Filter.builder() + .field(MaximumInterval.Filter.Field.PRICE_ID) + .operator(MaximumInterval.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -193,9 +198,9 @@ internal class SubscriptionTest { .addAppliesToPriceIntervalId("string") .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + MinimumInterval.Filter.builder() + .field(MinimumInterval.Filter.Field.PRICE_ID) + .operator(MinimumInterval.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -217,9 +222,14 @@ internal class SubscriptionTest { ) .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PlanPhaseUsageDiscountAdjustment.Filter.builder() + .field( + PlanPhaseUsageDiscountAdjustment.Filter.Field.PRICE_ID + ) + .operator( + PlanPhaseUsageDiscountAdjustment.Filter.Operator + .INCLUDES + ) .addValue("string") .build() ) @@ -249,9 +259,9 @@ internal class SubscriptionTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -264,9 +274,9 @@ internal class SubscriptionTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -283,9 +293,9 @@ internal class SubscriptionTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -306,9 +316,11 @@ internal class SubscriptionTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator( + PercentageDiscount.Filter.Operator.INCLUDES + ) .addValue("string") .build() ) @@ -321,9 +333,9 @@ internal class SubscriptionTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -335,9 +347,9 @@ internal class SubscriptionTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -362,9 +374,9 @@ internal class SubscriptionTest { .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Price.Unit.CompositePriceFilter.builder() + .field(Price.Unit.CompositePriceFilter.Field.PRICE_ID) + .operator(Price.Unit.CompositePriceFilter.Operator.INCLUDES) .addValue("string") .build() ) @@ -395,9 +407,11 @@ internal class SubscriptionTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator( + PercentageDiscount.Filter.Operator.INCLUDES + ) .addValue("string") .build() ) @@ -417,9 +431,9 @@ internal class SubscriptionTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -436,9 +450,9 @@ internal class SubscriptionTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -508,9 +522,9 @@ internal class SubscriptionTest { .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Price.Unit.CompositePriceFilter.builder() + .field(Price.Unit.CompositePriceFilter.Field.PRICE_ID) + .operator(Price.Unit.CompositePriceFilter.Operator.INCLUDES) .addValue("string") .build() ) @@ -541,9 +555,11 @@ internal class SubscriptionTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator( + PercentageDiscount.Filter.Operator.INCLUDES + ) .addValue("string") .build() ) @@ -563,9 +579,9 @@ internal class SubscriptionTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -582,9 +598,9 @@ internal class SubscriptionTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -639,9 +655,11 @@ internal class SubscriptionTest { ) .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PlanPhaseUsageDiscountAdjustment.Filter.builder() + .field(PlanPhaseUsageDiscountAdjustment.Filter.Field.PRICE_ID) + .operator( + PlanPhaseUsageDiscountAdjustment.Filter.Operator.INCLUDES + ) .addValue("string") .build() ) @@ -764,9 +782,9 @@ internal class SubscriptionTest { .discountType(AmountDiscountInterval.DiscountType.AMOUNT) .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + AmountDiscountInterval.Filter.builder() + .field(AmountDiscountInterval.Filter.Field.PRICE_ID) + .operator(AmountDiscountInterval.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -792,9 +810,9 @@ internal class SubscriptionTest { .addAppliesToPriceIntervalId("string") .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + MaximumInterval.Filter.builder() + .field(MaximumInterval.Filter.Field.PRICE_ID) + .operator(MaximumInterval.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -814,9 +832,9 @@ internal class SubscriptionTest { .addAppliesToPriceIntervalId("string") .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + MinimumInterval.Filter.builder() + .field(MinimumInterval.Filter.Field.PRICE_ID) + .operator(MinimumInterval.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -840,9 +858,11 @@ internal class SubscriptionTest { ) .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PlanPhaseUsageDiscountAdjustment.Filter.builder() + .field(PlanPhaseUsageDiscountAdjustment.Filter.Field.PRICE_ID) + .operator( + PlanPhaseUsageDiscountAdjustment.Filter.Operator.INCLUDES + ) .addValue("string") .build() ) @@ -872,9 +892,9 @@ internal class SubscriptionTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -887,9 +907,9 @@ internal class SubscriptionTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -906,9 +926,9 @@ internal class SubscriptionTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -929,9 +949,9 @@ internal class SubscriptionTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -944,9 +964,9 @@ internal class SubscriptionTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -958,9 +978,9 @@ internal class SubscriptionTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -985,9 +1005,9 @@ internal class SubscriptionTest { .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Price.Unit.CompositePriceFilter.builder() + .field(Price.Unit.CompositePriceFilter.Field.PRICE_ID) + .operator(Price.Unit.CompositePriceFilter.Operator.INCLUDES) .addValue("string") .build() ) @@ -1016,9 +1036,9 @@ internal class SubscriptionTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -1038,9 +1058,9 @@ internal class SubscriptionTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -1057,9 +1077,9 @@ internal class SubscriptionTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -1126,9 +1146,9 @@ internal class SubscriptionTest { .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Price.Unit.CompositePriceFilter.builder() + .field(Price.Unit.CompositePriceFilter.Field.PRICE_ID) + .operator(Price.Unit.CompositePriceFilter.Operator.INCLUDES) .addValue("string") .build() ) @@ -1157,9 +1177,9 @@ internal class SubscriptionTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -1179,9 +1199,9 @@ internal class SubscriptionTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -1198,9 +1218,9 @@ internal class SubscriptionTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -1262,9 +1282,14 @@ internal class SubscriptionTest { ) .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PlanPhaseUsageDiscountAdjustment.Filter.builder() + .field( + PlanPhaseUsageDiscountAdjustment.Filter.Field.PRICE_ID + ) + .operator( + PlanPhaseUsageDiscountAdjustment.Filter.Operator + .INCLUDES + ) .addValue("string") .build() ) @@ -1383,9 +1408,9 @@ internal class SubscriptionTest { .discountType(AmountDiscountInterval.DiscountType.AMOUNT) .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + AmountDiscountInterval.Filter.builder() + .field(AmountDiscountInterval.Filter.Field.PRICE_ID) + .operator(AmountDiscountInterval.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -1407,9 +1432,9 @@ internal class SubscriptionTest { .addAppliesToPriceIntervalId("string") .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + MaximumInterval.Filter.builder() + .field(MaximumInterval.Filter.Field.PRICE_ID) + .operator(MaximumInterval.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -1427,9 +1452,9 @@ internal class SubscriptionTest { .addAppliesToPriceIntervalId("string") .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + MinimumInterval.Filter.builder() + .field(MinimumInterval.Filter.Field.PRICE_ID) + .operator(MinimumInterval.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -1451,9 +1476,14 @@ internal class SubscriptionTest { ) .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PlanPhaseUsageDiscountAdjustment.Filter.builder() + .field( + PlanPhaseUsageDiscountAdjustment.Filter.Field.PRICE_ID + ) + .operator( + PlanPhaseUsageDiscountAdjustment.Filter.Operator + .INCLUDES + ) .addValue("string") .build() ) @@ -1483,9 +1513,9 @@ internal class SubscriptionTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -1498,9 +1528,9 @@ internal class SubscriptionTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -1517,9 +1547,9 @@ internal class SubscriptionTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -1540,9 +1570,11 @@ internal class SubscriptionTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator( + PercentageDiscount.Filter.Operator.INCLUDES + ) .addValue("string") .build() ) @@ -1555,9 +1587,9 @@ internal class SubscriptionTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -1569,9 +1601,9 @@ internal class SubscriptionTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -1596,9 +1628,9 @@ internal class SubscriptionTest { .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Price.Unit.CompositePriceFilter.builder() + .field(Price.Unit.CompositePriceFilter.Field.PRICE_ID) + .operator(Price.Unit.CompositePriceFilter.Operator.INCLUDES) .addValue("string") .build() ) @@ -1629,9 +1661,11 @@ internal class SubscriptionTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator( + PercentageDiscount.Filter.Operator.INCLUDES + ) .addValue("string") .build() ) @@ -1651,9 +1685,9 @@ internal class SubscriptionTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -1670,9 +1704,9 @@ internal class SubscriptionTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -1742,9 +1776,9 @@ internal class SubscriptionTest { .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Price.Unit.CompositePriceFilter.builder() + .field(Price.Unit.CompositePriceFilter.Field.PRICE_ID) + .operator(Price.Unit.CompositePriceFilter.Operator.INCLUDES) .addValue("string") .build() ) @@ -1775,9 +1809,11 @@ internal class SubscriptionTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator( + PercentageDiscount.Filter.Operator.INCLUDES + ) .addValue("string") .build() ) @@ -1797,9 +1833,9 @@ internal class SubscriptionTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -1816,9 +1852,9 @@ internal class SubscriptionTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionsTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionsTest.kt index 5616656c5..ca5b345ec 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionsTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionsTest.kt @@ -31,9 +31,15 @@ internal class SubscriptionsTest { ) .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PlanPhaseUsageDiscountAdjustment.Filter.builder() + .field( + PlanPhaseUsageDiscountAdjustment.Filter.Field + .PRICE_ID + ) + .operator( + PlanPhaseUsageDiscountAdjustment.Filter.Operator + .INCLUDES + ) .addValue("string") .build() ) @@ -161,9 +167,9 @@ internal class SubscriptionsTest { .discountType(AmountDiscountInterval.DiscountType.AMOUNT) .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + AmountDiscountInterval.Filter.builder() + .field(AmountDiscountInterval.Filter.Field.PRICE_ID) + .operator(AmountDiscountInterval.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -185,9 +191,9 @@ internal class SubscriptionsTest { .addAppliesToPriceIntervalId("string") .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + MaximumInterval.Filter.builder() + .field(MaximumInterval.Filter.Field.PRICE_ID) + .operator(MaximumInterval.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -205,9 +211,9 @@ internal class SubscriptionsTest { .addAppliesToPriceIntervalId("string") .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + MinimumInterval.Filter.builder() + .field(MinimumInterval.Filter.Field.PRICE_ID) + .operator(MinimumInterval.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -232,9 +238,15 @@ internal class SubscriptionsTest { ) .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PlanPhaseUsageDiscountAdjustment.Filter.builder() + .field( + PlanPhaseUsageDiscountAdjustment.Filter.Field + .PRICE_ID + ) + .operator( + PlanPhaseUsageDiscountAdjustment.Filter.Operator + .INCLUDES + ) .addValue("string") .build() ) @@ -264,9 +276,11 @@ internal class SubscriptionsTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator( + PercentageDiscount.Filter.Operator.INCLUDES + ) .addValue("string") .build() ) @@ -279,9 +293,9 @@ internal class SubscriptionsTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -298,9 +312,9 @@ internal class SubscriptionsTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -323,10 +337,13 @@ internal class SubscriptionsTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) + PercentageDiscount.Filter.builder() + .field( + PercentageDiscount.Filter.Field.PRICE_ID + ) .operator( - TransformPriceFilter.Operator.INCLUDES + PercentageDiscount.Filter.Operator + .INCLUDES ) .addValue("string") .build() @@ -340,11 +357,9 @@ internal class SubscriptionsTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -356,11 +371,9 @@ internal class SubscriptionsTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -389,9 +402,14 @@ internal class SubscriptionsTest { .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Price.Unit.CompositePriceFilter.builder() + .field( + Price.Unit.CompositePriceFilter.Field.PRICE_ID + ) + .operator( + Price.Unit.CompositePriceFilter.Operator + .INCLUDES + ) .addValue("string") .build() ) @@ -426,10 +444,13 @@ internal class SubscriptionsTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) + PercentageDiscount.Filter.builder() + .field( + PercentageDiscount.Filter.Field.PRICE_ID + ) .operator( - TransformPriceFilter.Operator.INCLUDES + PercentageDiscount.Filter.Operator + .INCLUDES ) .addValue("string") .build() @@ -452,11 +473,9 @@ internal class SubscriptionsTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -476,11 +495,9 @@ internal class SubscriptionsTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -560,9 +577,14 @@ internal class SubscriptionsTest { .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Price.Unit.CompositePriceFilter.builder() + .field( + Price.Unit.CompositePriceFilter.Field.PRICE_ID + ) + .operator( + Price.Unit.CompositePriceFilter.Operator + .INCLUDES + ) .addValue("string") .build() ) @@ -597,10 +619,13 @@ internal class SubscriptionsTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) + PercentageDiscount.Filter.builder() + .field( + PercentageDiscount.Filter.Field.PRICE_ID + ) .operator( - TransformPriceFilter.Operator.INCLUDES + PercentageDiscount.Filter.Operator + .INCLUDES ) .addValue("string") .build() @@ -623,11 +648,9 @@ internal class SubscriptionsTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -647,11 +670,9 @@ internal class SubscriptionsTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -718,9 +739,15 @@ internal class SubscriptionsTest { ) .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PlanPhaseUsageDiscountAdjustment.Filter.builder() + .field( + PlanPhaseUsageDiscountAdjustment.Filter.Field + .PRICE_ID + ) + .operator( + PlanPhaseUsageDiscountAdjustment.Filter.Operator + .INCLUDES + ) .addValue("string") .build() ) @@ -840,9 +867,9 @@ internal class SubscriptionsTest { .discountType(AmountDiscountInterval.DiscountType.AMOUNT) .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + AmountDiscountInterval.Filter.builder() + .field(AmountDiscountInterval.Filter.Field.PRICE_ID) + .operator(AmountDiscountInterval.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -864,9 +891,9 @@ internal class SubscriptionsTest { .addAppliesToPriceIntervalId("string") .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + MaximumInterval.Filter.builder() + .field(MaximumInterval.Filter.Field.PRICE_ID) + .operator(MaximumInterval.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -884,9 +911,9 @@ internal class SubscriptionsTest { .addAppliesToPriceIntervalId("string") .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + MinimumInterval.Filter.builder() + .field(MinimumInterval.Filter.Field.PRICE_ID) + .operator(MinimumInterval.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -911,9 +938,15 @@ internal class SubscriptionsTest { ) .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PlanPhaseUsageDiscountAdjustment.Filter.builder() + .field( + PlanPhaseUsageDiscountAdjustment.Filter.Field + .PRICE_ID + ) + .operator( + PlanPhaseUsageDiscountAdjustment.Filter.Operator + .INCLUDES + ) .addValue("string") .build() ) @@ -943,9 +976,9 @@ internal class SubscriptionsTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -958,9 +991,9 @@ internal class SubscriptionsTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -977,9 +1010,9 @@ internal class SubscriptionsTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -1002,10 +1035,10 @@ internal class SubscriptionsTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) .operator( - TransformPriceFilter.Operator.INCLUDES + PercentageDiscount.Filter.Operator.INCLUDES ) .addValue("string") .build() @@ -1019,11 +1052,9 @@ internal class SubscriptionsTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -1035,11 +1066,9 @@ internal class SubscriptionsTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -1066,9 +1095,11 @@ internal class SubscriptionsTest { .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Price.Unit.CompositePriceFilter.builder() + .field(Price.Unit.CompositePriceFilter.Field.PRICE_ID) + .operator( + Price.Unit.CompositePriceFilter.Operator.INCLUDES + ) .addValue("string") .build() ) @@ -1101,10 +1132,10 @@ internal class SubscriptionsTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) .operator( - TransformPriceFilter.Operator.INCLUDES + PercentageDiscount.Filter.Operator.INCLUDES ) .addValue("string") .build() @@ -1127,11 +1158,9 @@ internal class SubscriptionsTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -1148,11 +1177,9 @@ internal class SubscriptionsTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -1226,9 +1253,11 @@ internal class SubscriptionsTest { .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Price.Unit.CompositePriceFilter.builder() + .field(Price.Unit.CompositePriceFilter.Field.PRICE_ID) + .operator( + Price.Unit.CompositePriceFilter.Operator.INCLUDES + ) .addValue("string") .build() ) @@ -1261,10 +1290,10 @@ internal class SubscriptionsTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) .operator( - TransformPriceFilter.Operator.INCLUDES + PercentageDiscount.Filter.Operator.INCLUDES ) .addValue("string") .build() @@ -1287,11 +1316,9 @@ internal class SubscriptionsTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -1308,11 +1335,9 @@ internal class SubscriptionsTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -1380,9 +1405,15 @@ internal class SubscriptionsTest { ) .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PlanPhaseUsageDiscountAdjustment.Filter.builder() + .field( + PlanPhaseUsageDiscountAdjustment.Filter.Field + .PRICE_ID + ) + .operator( + PlanPhaseUsageDiscountAdjustment.Filter.Operator + .INCLUDES + ) .addValue("string") .build() ) @@ -1510,9 +1541,9 @@ internal class SubscriptionsTest { .discountType(AmountDiscountInterval.DiscountType.AMOUNT) .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + AmountDiscountInterval.Filter.builder() + .field(AmountDiscountInterval.Filter.Field.PRICE_ID) + .operator(AmountDiscountInterval.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -1534,9 +1565,9 @@ internal class SubscriptionsTest { .addAppliesToPriceIntervalId("string") .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + MaximumInterval.Filter.builder() + .field(MaximumInterval.Filter.Field.PRICE_ID) + .operator(MaximumInterval.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -1554,9 +1585,9 @@ internal class SubscriptionsTest { .addAppliesToPriceIntervalId("string") .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + MinimumInterval.Filter.builder() + .field(MinimumInterval.Filter.Field.PRICE_ID) + .operator(MinimumInterval.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -1581,9 +1612,15 @@ internal class SubscriptionsTest { ) .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PlanPhaseUsageDiscountAdjustment.Filter.builder() + .field( + PlanPhaseUsageDiscountAdjustment.Filter.Field + .PRICE_ID + ) + .operator( + PlanPhaseUsageDiscountAdjustment.Filter.Operator + .INCLUDES + ) .addValue("string") .build() ) @@ -1613,9 +1650,11 @@ internal class SubscriptionsTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator( + PercentageDiscount.Filter.Operator.INCLUDES + ) .addValue("string") .build() ) @@ -1628,9 +1667,9 @@ internal class SubscriptionsTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -1647,9 +1686,9 @@ internal class SubscriptionsTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -1672,10 +1711,13 @@ internal class SubscriptionsTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) + PercentageDiscount.Filter.builder() + .field( + PercentageDiscount.Filter.Field.PRICE_ID + ) .operator( - TransformPriceFilter.Operator.INCLUDES + PercentageDiscount.Filter.Operator + .INCLUDES ) .addValue("string") .build() @@ -1689,11 +1731,9 @@ internal class SubscriptionsTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -1705,11 +1745,9 @@ internal class SubscriptionsTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -1738,9 +1776,14 @@ internal class SubscriptionsTest { .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Price.Unit.CompositePriceFilter.builder() + .field( + Price.Unit.CompositePriceFilter.Field.PRICE_ID + ) + .operator( + Price.Unit.CompositePriceFilter.Operator + .INCLUDES + ) .addValue("string") .build() ) @@ -1775,10 +1818,13 @@ internal class SubscriptionsTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) + PercentageDiscount.Filter.builder() + .field( + PercentageDiscount.Filter.Field.PRICE_ID + ) .operator( - TransformPriceFilter.Operator.INCLUDES + PercentageDiscount.Filter.Operator + .INCLUDES ) .addValue("string") .build() @@ -1801,11 +1847,9 @@ internal class SubscriptionsTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -1825,11 +1869,9 @@ internal class SubscriptionsTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -1909,9 +1951,14 @@ internal class SubscriptionsTest { .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .cadence(Price.Unit.Cadence.ONE_TIME) .addCompositePriceFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + Price.Unit.CompositePriceFilter.builder() + .field( + Price.Unit.CompositePriceFilter.Field.PRICE_ID + ) + .operator( + Price.Unit.CompositePriceFilter.Operator + .INCLUDES + ) .addValue("string") .build() ) @@ -1946,10 +1993,13 @@ internal class SubscriptionsTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) + PercentageDiscount.Filter.builder() + .field( + PercentageDiscount.Filter.Field.PRICE_ID + ) .operator( - TransformPriceFilter.Operator.INCLUDES + PercentageDiscount.Filter.Operator + .INCLUDES ) .addValue("string") .build() @@ -1972,11 +2022,9 @@ internal class SubscriptionsTest { Maximum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -1996,11 +2044,9 @@ internal class SubscriptionsTest { Minimum.builder() .addAppliesToPriceId("string") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator( - TransformPriceFilter.Operator.INCLUDES - ) + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) .addValue("string") .build() ) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/TransformPriceFilterTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/TransformPriceFilterTest.kt deleted file mode 100644 index 7fa1c6b87..000000000 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/TransformPriceFilterTest.kt +++ /dev/null @@ -1,45 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.withorb.api.models - -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.withorb.api.core.jsonMapper -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class TransformPriceFilterTest { - - @Test - fun create() { - val transformPriceFilter = - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) - .addValue("string") - .build() - - assertThat(transformPriceFilter.field()).isEqualTo(TransformPriceFilter.Field.PRICE_ID) - assertThat(transformPriceFilter.operator()) - .isEqualTo(TransformPriceFilter.Operator.INCLUDES) - assertThat(transformPriceFilter.values()).containsExactly("string") - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val transformPriceFilter = - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) - .addValue("string") - .build() - - val roundtrippedTransformPriceFilter = - jsonMapper.readValue( - jsonMapper.writeValueAsString(transformPriceFilter), - jacksonTypeRef(), - ) - - assertThat(roundtrippedTransformPriceFilter).isEqualTo(transformPriceFilter) - } -} diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/TrialDiscountTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/TrialDiscountTest.kt index 0cb107735..45b8bf898 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/TrialDiscountTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/TrialDiscountTest.kt @@ -17,9 +17,9 @@ internal class TrialDiscountTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + TrialDiscount.Filter.builder() + .field(TrialDiscount.Filter.Field.PRICE_ID) + .operator(TrialDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -33,9 +33,9 @@ internal class TrialDiscountTest { .containsExactly("h74gfhdjvn7ujokd", "7hfgtgjnbvc3ujkl") assertThat(trialDiscount.filters()) .containsExactly( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + TrialDiscount.Filter.builder() + .field(TrialDiscount.Filter.Field.PRICE_ID) + .operator(TrialDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -53,9 +53,9 @@ internal class TrialDiscountTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + TrialDiscount.Filter.builder() + .field(TrialDiscount.Filter.Field.PRICE_ID) + .operator(TrialDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/UsageDiscountIntervalTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/UsageDiscountIntervalTest.kt index 04f875ed2..034352cb0 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/UsageDiscountIntervalTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/UsageDiscountIntervalTest.kt @@ -18,9 +18,9 @@ internal class UsageDiscountIntervalTest { .discountType(UsageDiscountInterval.DiscountType.USAGE) .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + UsageDiscountInterval.Filter.builder() + .field(UsageDiscountInterval.Filter.Field.PRICE_ID) + .operator(UsageDiscountInterval.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -35,9 +35,9 @@ internal class UsageDiscountIntervalTest { .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) assertThat(usageDiscountInterval.filters()) .containsExactly( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + UsageDiscountInterval.Filter.builder() + .field(UsageDiscountInterval.Filter.Field.PRICE_ID) + .operator(UsageDiscountInterval.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -55,9 +55,9 @@ internal class UsageDiscountIntervalTest { .discountType(UsageDiscountInterval.DiscountType.USAGE) .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + UsageDiscountInterval.Filter.builder() + .field(UsageDiscountInterval.Filter.Field.PRICE_ID) + .operator(UsageDiscountInterval.Filter.Operator.INCLUDES) .addValue("string") .build() ) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/UsageDiscountTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/UsageDiscountTest.kt index 4b464a977..deda61052 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/UsageDiscountTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/UsageDiscountTest.kt @@ -18,9 +18,9 @@ internal class UsageDiscountTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + UsageDiscount.Filter.builder() + .field(UsageDiscount.Filter.Field.PRICE_ID) + .operator(UsageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -33,9 +33,9 @@ internal class UsageDiscountTest { .containsExactly("h74gfhdjvn7ujokd", "7hfgtgjnbvc3ujkl") assertThat(usageDiscount.filters()) .containsExactly( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + UsageDiscount.Filter.builder() + .field(UsageDiscount.Filter.Field.PRICE_ID) + .operator(UsageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) @@ -52,9 +52,9 @@ internal class UsageDiscountTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + UsageDiscount.Filter.builder() + .field(UsageDiscount.Filter.Field.PRICE_ID) + .operator(UsageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/VoidInitiatedLedgerEntryTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/VoidInitiatedLedgerEntryTest.kt index 9077e8275..4cd12168c 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/VoidInitiatedLedgerEntryTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/VoidInitiatedLedgerEntryTest.kt @@ -21,6 +21,13 @@ internal class VoidInitiatedLedgerEntryTest { .creditBlock( AffectedBlock.builder() .id("id") + .addBlockFilter( + AffectedBlock.BlockFilter.builder() + .field(AffectedBlock.BlockFilter.Field.PRICE_ID) + .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() @@ -56,6 +63,13 @@ internal class VoidInitiatedLedgerEntryTest { .isEqualTo( AffectedBlock.builder() .id("id") + .addBlockFilter( + AffectedBlock.BlockFilter.builder() + .field(AffectedBlock.BlockFilter.Field.PRICE_ID) + .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() @@ -99,6 +113,13 @@ internal class VoidInitiatedLedgerEntryTest { .creditBlock( AffectedBlock.builder() .id("id") + .addBlockFilter( + AffectedBlock.BlockFilter.builder() + .field(AffectedBlock.BlockFilter.Field.PRICE_ID) + .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/VoidLedgerEntryTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/VoidLedgerEntryTest.kt index 4077cfb55..22771a63b 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/VoidLedgerEntryTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/VoidLedgerEntryTest.kt @@ -21,6 +21,13 @@ internal class VoidLedgerEntryTest { .creditBlock( AffectedBlock.builder() .id("id") + .addBlockFilter( + AffectedBlock.BlockFilter.builder() + .field(AffectedBlock.BlockFilter.Field.PRICE_ID) + .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() @@ -55,6 +62,13 @@ internal class VoidLedgerEntryTest { .isEqualTo( AffectedBlock.builder() .id("id") + .addBlockFilter( + AffectedBlock.BlockFilter.builder() + .field(AffectedBlock.BlockFilter.Field.PRICE_ID) + .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() @@ -94,6 +108,13 @@ internal class VoidLedgerEntryTest { .creditBlock( AffectedBlock.builder() .id("id") + .addBlockFilter( + AffectedBlock.BlockFilter.builder() + .field(AffectedBlock.BlockFilter.Field.PRICE_ID) + .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/BetaServiceAsyncTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/BetaServiceAsyncTest.kt index d0753d065..648310b19 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/BetaServiceAsyncTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/BetaServiceAsyncTest.kt @@ -15,7 +15,6 @@ import com.withorb.api.models.NewBillingCycleConfiguration import com.withorb.api.models.NewDimensionalPriceConfiguration import com.withorb.api.models.NewPercentageDiscount import com.withorb.api.models.NewPlanUnitPrice -import com.withorb.api.models.TransformPriceFilter import com.withorb.api.models.UnitConfig import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -52,9 +51,11 @@ internal class BetaServiceAsyncTest { .addAppliesToPriceId("price_2") .currency("currency") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + NewPercentageDiscount.Filter.builder() + .field(NewPercentageDiscount.Filter.Field.PRICE_ID) + .operator( + NewPercentageDiscount.Filter.Operator.INCLUDES + ) .addValue("string") .build() ) @@ -165,9 +166,11 @@ internal class BetaServiceAsyncTest { .addAppliesToPriceId("price_2") .currency("currency") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + NewPercentageDiscount.Filter.builder() + .field(NewPercentageDiscount.Filter.Field.PRICE_ID) + .operator( + NewPercentageDiscount.Filter.Operator.INCLUDES + ) .addValue("string") .build() ) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/InvoiceServiceAsyncTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/InvoiceServiceAsyncTest.kt index 6a2b53fda..f91a2deed 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/InvoiceServiceAsyncTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/InvoiceServiceAsyncTest.kt @@ -11,7 +11,6 @@ import com.withorb.api.models.InvoiceIssueParams import com.withorb.api.models.InvoiceMarkPaidParams import com.withorb.api.models.InvoiceUpdateParams import com.withorb.api.models.PercentageDiscount -import com.withorb.api.models.TransformPriceFilter import com.withorb.api.models.UnitConfig import java.time.LocalDate import java.time.OffsetDateTime @@ -54,9 +53,9 @@ internal class InvoiceServiceAsyncTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/PlanServiceAsyncTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/PlanServiceAsyncTest.kt index f3e9737d4..37bd03ebb 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/PlanServiceAsyncTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/PlanServiceAsyncTest.kt @@ -14,7 +14,6 @@ import com.withorb.api.models.NewPercentageDiscount import com.withorb.api.models.NewPlanUnitPrice import com.withorb.api.models.PlanCreateParams import com.withorb.api.models.PlanUpdateParams -import com.withorb.api.models.TransformPriceFilter import com.withorb.api.models.UnitConfig import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -124,9 +123,11 @@ internal class PlanServiceAsyncTest { .addAppliesToPriceId("price_2") .currency("currency") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + NewPercentageDiscount.Filter.builder() + .field(NewPercentageDiscount.Filter.Field.PRICE_ID) + .operator( + NewPercentageDiscount.Filter.Operator.INCLUDES + ) .addValue("string") .build() ) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/SubscriptionServiceAsyncTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/SubscriptionServiceAsyncTest.kt index 4c51566b2..f97e3cc1a 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/SubscriptionServiceAsyncTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/SubscriptionServiceAsyncTest.kt @@ -27,7 +27,6 @@ import com.withorb.api.models.SubscriptionUnscheduleFixedFeeQuantityUpdatesParam import com.withorb.api.models.SubscriptionUpdateFixedFeeQuantityParams import com.withorb.api.models.SubscriptionUpdateParams import com.withorb.api.models.SubscriptionUpdateTrialParams -import com.withorb.api.models.TransformPriceFilter import com.withorb.api.models.UnitConfig import java.time.LocalDate import java.time.OffsetDateTime @@ -65,9 +64,11 @@ internal class SubscriptionServiceAsyncTest { .addAppliesToPriceId("price_2") .currency("currency") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + NewPercentageDiscount.Filter.builder() + .field(NewPercentageDiscount.Filter.Field.PRICE_ID) + .operator( + NewPercentageDiscount.Filter.Operator.INCLUDES + ) .addValue("string") .build() ) @@ -223,9 +224,11 @@ internal class SubscriptionServiceAsyncTest { .addAppliesToPriceId("price_2") .currency("currency") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + NewPercentageDiscount.Filter.builder() + .field(NewPercentageDiscount.Filter.Field.PRICE_ID) + .operator( + NewPercentageDiscount.Filter.Operator.INCLUDES + ) .addValue("string") .build() ) @@ -593,9 +596,11 @@ internal class SubscriptionServiceAsyncTest { .addAppliesToPriceId("price_2") .currency("currency") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + NewPercentageDiscount.Filter.builder() + .field(NewPercentageDiscount.Filter.Field.PRICE_ID) + .operator( + NewPercentageDiscount.Filter.Operator.INCLUDES + ) .addValue("string") .build() ) @@ -691,9 +696,11 @@ internal class SubscriptionServiceAsyncTest { .addAppliesToPriceId("price_2") .currency("currency") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + NewPercentageDiscount.Filter.builder() + .field(NewPercentageDiscount.Filter.Field.PRICE_ID) + .operator( + NewPercentageDiscount.Filter.Operator.INCLUDES + ) .addValue("string") .build() ) @@ -840,9 +847,11 @@ internal class SubscriptionServiceAsyncTest { .addAppliesToPriceId("price_2") .currency("currency") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + NewPercentageDiscount.Filter.builder() + .field(NewPercentageDiscount.Filter.Field.PRICE_ID) + .operator( + NewPercentageDiscount.Filter.Operator.INCLUDES + ) .addValue("string") .build() ) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/beta/ExternalPlanIdServiceAsyncTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/beta/ExternalPlanIdServiceAsyncTest.kt index 2b99ad625..96c9b1e02 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/beta/ExternalPlanIdServiceAsyncTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/beta/ExternalPlanIdServiceAsyncTest.kt @@ -15,7 +15,6 @@ import com.withorb.api.models.NewBillingCycleConfiguration import com.withorb.api.models.NewDimensionalPriceConfiguration import com.withorb.api.models.NewPercentageDiscount import com.withorb.api.models.NewPlanUnitPrice -import com.withorb.api.models.TransformPriceFilter import com.withorb.api.models.UnitConfig import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -52,9 +51,11 @@ internal class ExternalPlanIdServiceAsyncTest { .addAppliesToPriceId("price_2") .currency("currency") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + NewPercentageDiscount.Filter.builder() + .field(NewPercentageDiscount.Filter.Field.PRICE_ID) + .operator( + NewPercentageDiscount.Filter.Operator.INCLUDES + ) .addValue("string") .build() ) @@ -165,9 +166,11 @@ internal class ExternalPlanIdServiceAsyncTest { .addAppliesToPriceId("price_2") .currency("currency") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + NewPercentageDiscount.Filter.builder() + .field(NewPercentageDiscount.Filter.Field.PRICE_ID) + .operator( + NewPercentageDiscount.Filter.Operator.INCLUDES + ) .addValue("string") .build() ) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/BetaServiceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/BetaServiceTest.kt index 24e977345..32479a087 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/BetaServiceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/BetaServiceTest.kt @@ -15,7 +15,6 @@ import com.withorb.api.models.NewBillingCycleConfiguration import com.withorb.api.models.NewDimensionalPriceConfiguration import com.withorb.api.models.NewPercentageDiscount import com.withorb.api.models.NewPlanUnitPrice -import com.withorb.api.models.TransformPriceFilter import com.withorb.api.models.UnitConfig import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -52,9 +51,11 @@ internal class BetaServiceTest { .addAppliesToPriceId("price_2") .currency("currency") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + NewPercentageDiscount.Filter.builder() + .field(NewPercentageDiscount.Filter.Field.PRICE_ID) + .operator( + NewPercentageDiscount.Filter.Operator.INCLUDES + ) .addValue("string") .build() ) @@ -165,9 +166,11 @@ internal class BetaServiceTest { .addAppliesToPriceId("price_2") .currency("currency") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + NewPercentageDiscount.Filter.builder() + .field(NewPercentageDiscount.Filter.Field.PRICE_ID) + .operator( + NewPercentageDiscount.Filter.Operator.INCLUDES + ) .addValue("string") .build() ) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/InvoiceServiceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/InvoiceServiceTest.kt index 367768764..5f272b94d 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/InvoiceServiceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/InvoiceServiceTest.kt @@ -11,7 +11,6 @@ import com.withorb.api.models.InvoiceIssueParams import com.withorb.api.models.InvoiceMarkPaidParams import com.withorb.api.models.InvoiceUpdateParams import com.withorb.api.models.PercentageDiscount -import com.withorb.api.models.TransformPriceFilter import com.withorb.api.models.UnitConfig import java.time.LocalDate import java.time.OffsetDateTime @@ -54,9 +53,9 @@ internal class InvoiceServiceTest { .addAppliesToPriceId("h74gfhdjvn7ujokd") .addAppliesToPriceId("7hfgtgjnbvc3ujkl") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) .addValue("string") .build() ) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/PlanServiceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/PlanServiceTest.kt index b3af60641..7be0ff5b4 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/PlanServiceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/PlanServiceTest.kt @@ -14,7 +14,6 @@ import com.withorb.api.models.NewPercentageDiscount import com.withorb.api.models.NewPlanUnitPrice import com.withorb.api.models.PlanCreateParams import com.withorb.api.models.PlanUpdateParams -import com.withorb.api.models.TransformPriceFilter import com.withorb.api.models.UnitConfig import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -124,9 +123,11 @@ internal class PlanServiceTest { .addAppliesToPriceId("price_2") .currency("currency") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + NewPercentageDiscount.Filter.builder() + .field(NewPercentageDiscount.Filter.Field.PRICE_ID) + .operator( + NewPercentageDiscount.Filter.Operator.INCLUDES + ) .addValue("string") .build() ) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/SubscriptionServiceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/SubscriptionServiceTest.kt index 2d6d063a8..4841f3498 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/SubscriptionServiceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/SubscriptionServiceTest.kt @@ -27,7 +27,6 @@ import com.withorb.api.models.SubscriptionUnscheduleFixedFeeQuantityUpdatesParam import com.withorb.api.models.SubscriptionUpdateFixedFeeQuantityParams import com.withorb.api.models.SubscriptionUpdateParams import com.withorb.api.models.SubscriptionUpdateTrialParams -import com.withorb.api.models.TransformPriceFilter import com.withorb.api.models.UnitConfig import java.time.LocalDate import java.time.OffsetDateTime @@ -65,9 +64,11 @@ internal class SubscriptionServiceTest { .addAppliesToPriceId("price_2") .currency("currency") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + NewPercentageDiscount.Filter.builder() + .field(NewPercentageDiscount.Filter.Field.PRICE_ID) + .operator( + NewPercentageDiscount.Filter.Operator.INCLUDES + ) .addValue("string") .build() ) @@ -223,9 +224,11 @@ internal class SubscriptionServiceTest { .addAppliesToPriceId("price_2") .currency("currency") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + NewPercentageDiscount.Filter.builder() + .field(NewPercentageDiscount.Filter.Field.PRICE_ID) + .operator( + NewPercentageDiscount.Filter.Operator.INCLUDES + ) .addValue("string") .build() ) @@ -593,9 +596,11 @@ internal class SubscriptionServiceTest { .addAppliesToPriceId("price_2") .currency("currency") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + NewPercentageDiscount.Filter.builder() + .field(NewPercentageDiscount.Filter.Field.PRICE_ID) + .operator( + NewPercentageDiscount.Filter.Operator.INCLUDES + ) .addValue("string") .build() ) @@ -691,9 +696,11 @@ internal class SubscriptionServiceTest { .addAppliesToPriceId("price_2") .currency("currency") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + NewPercentageDiscount.Filter.builder() + .field(NewPercentageDiscount.Filter.Field.PRICE_ID) + .operator( + NewPercentageDiscount.Filter.Operator.INCLUDES + ) .addValue("string") .build() ) @@ -840,9 +847,11 @@ internal class SubscriptionServiceTest { .addAppliesToPriceId("price_2") .currency("currency") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + NewPercentageDiscount.Filter.builder() + .field(NewPercentageDiscount.Filter.Field.PRICE_ID) + .operator( + NewPercentageDiscount.Filter.Operator.INCLUDES + ) .addValue("string") .build() ) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/beta/ExternalPlanIdServiceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/beta/ExternalPlanIdServiceTest.kt index f8208215c..92952a194 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/beta/ExternalPlanIdServiceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/beta/ExternalPlanIdServiceTest.kt @@ -15,7 +15,6 @@ import com.withorb.api.models.NewBillingCycleConfiguration import com.withorb.api.models.NewDimensionalPriceConfiguration import com.withorb.api.models.NewPercentageDiscount import com.withorb.api.models.NewPlanUnitPrice -import com.withorb.api.models.TransformPriceFilter import com.withorb.api.models.UnitConfig import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -52,9 +51,11 @@ internal class ExternalPlanIdServiceTest { .addAppliesToPriceId("price_2") .currency("currency") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + NewPercentageDiscount.Filter.builder() + .field(NewPercentageDiscount.Filter.Field.PRICE_ID) + .operator( + NewPercentageDiscount.Filter.Operator.INCLUDES + ) .addValue("string") .build() ) @@ -165,9 +166,11 @@ internal class ExternalPlanIdServiceTest { .addAppliesToPriceId("price_2") .currency("currency") .addFilter( - TransformPriceFilter.builder() - .field(TransformPriceFilter.Field.PRICE_ID) - .operator(TransformPriceFilter.Operator.INCLUDES) + NewPercentageDiscount.Filter.builder() + .field(NewPercentageDiscount.Filter.Field.PRICE_ID) + .operator( + NewPercentageDiscount.Filter.Operator.INCLUDES + ) .addValue("string") .build() ) From f6987c9fd19277bfdb124bf896a74584ae69090b Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 23 Oct 2025 16:33:28 +0000 Subject: [PATCH 35/68] feat(api): api update --- .stats.yml | 4 +- .../models/SubscriptionChangeApplyParams.kt | 267 +++++++++++++++++- .../SubscriptionChangeApplyParamsTest.kt | 10 + .../SubscriptionChangeServiceAsyncTest.kt | 4 + .../blocking/SubscriptionChangeServiceTest.kt | 4 + 5 files changed, 283 insertions(+), 6 deletions(-) diff --git a/.stats.yml b/.stats.yml index 320998e13..f2277cfc2 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 118 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-828c91953d2351040fdd4d90a3d9eafd09f9d240c4f6ce0441b7a10c06c1c722.yml -openapi_spec_hash: c82bc88563f80f600e59e22014d4cec4 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-cbce25283cb9c3282e03e08b7ee81395436af7d0eb480ffcbab307b5bf1c92a0.yml +openapi_spec_hash: c286edf46db95dee05eb6f180ac24ab0 config_hash: 1f73a949b649ecfe6ec68ba1bb459dc2 diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionChangeApplyParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionChangeApplyParams.kt index 7f169e4d0..3fd39e573 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionChangeApplyParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionChangeApplyParams.kt @@ -14,6 +14,7 @@ import com.withorb.api.core.Params import com.withorb.api.core.http.Headers import com.withorb.api.core.http.QueryParams import com.withorb.api.errors.OrbInvalidDataException +import java.time.LocalDate import java.util.Collections import java.util.Objects @@ -49,6 +50,32 @@ private constructor( */ fun markAsPaid(): Boolean? = body.markAsPaid() + /** + * An optional external ID to associate with the payment. Only applicable when mark_as_paid is + * true. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun paymentExternalId(): String? = body.paymentExternalId() + + /** + * Optional notes about the payment. Only applicable when mark_as_paid is true. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun paymentNotes(): String? = body.paymentNotes() + + /** + * A date string to specify the date the payment was received. Only applicable when mark_as_paid + * is true. If not provided, defaults to the current date. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun paymentReceivedDate(): LocalDate? = body.paymentReceivedDate() + /** * Amount already collected to apply to the customer's balance. If mark_as_paid is also * provided, credit the difference to the customer's balance. @@ -72,6 +99,29 @@ private constructor( */ fun _markAsPaid(): JsonField = body._markAsPaid() + /** + * Returns the raw JSON value of [paymentExternalId]. + * + * Unlike [paymentExternalId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + fun _paymentExternalId(): JsonField = body._paymentExternalId() + + /** + * Returns the raw JSON value of [paymentNotes]. + * + * Unlike [paymentNotes], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _paymentNotes(): JsonField = body._paymentNotes() + + /** + * Returns the raw JSON value of [paymentReceivedDate]. + * + * Unlike [paymentReceivedDate], this method doesn't throw if the JSON field has an unexpected + * type. + */ + fun _paymentReceivedDate(): JsonField = body._paymentReceivedDate() + /** * Returns the raw JSON value of [previouslyCollectedAmount]. * @@ -127,7 +177,10 @@ private constructor( * Otherwise, it's more convenient to use the top-level setters instead: * - [description] * - [markAsPaid] - * - [previouslyCollectedAmount] + * - [paymentExternalId] + * - [paymentNotes] + * - [paymentReceivedDate] + * - etc. */ fun body(body: Body) = apply { this.body = body.toBuilder() } @@ -165,6 +218,58 @@ private constructor( */ fun markAsPaid(markAsPaid: JsonField) = apply { body.markAsPaid(markAsPaid) } + /** + * An optional external ID to associate with the payment. Only applicable when mark_as_paid + * is true. + */ + fun paymentExternalId(paymentExternalId: String?) = apply { + body.paymentExternalId(paymentExternalId) + } + + /** + * Sets [Builder.paymentExternalId] to an arbitrary JSON value. + * + * You should usually call [Builder.paymentExternalId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun paymentExternalId(paymentExternalId: JsonField) = apply { + body.paymentExternalId(paymentExternalId) + } + + /** Optional notes about the payment. Only applicable when mark_as_paid is true. */ + fun paymentNotes(paymentNotes: String?) = apply { body.paymentNotes(paymentNotes) } + + /** + * Sets [Builder.paymentNotes] to an arbitrary JSON value. + * + * You should usually call [Builder.paymentNotes] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun paymentNotes(paymentNotes: JsonField) = apply { + body.paymentNotes(paymentNotes) + } + + /** + * A date string to specify the date the payment was received. Only applicable when + * mark_as_paid is true. If not provided, defaults to the current date. + */ + fun paymentReceivedDate(paymentReceivedDate: LocalDate?) = apply { + body.paymentReceivedDate(paymentReceivedDate) + } + + /** + * Sets [Builder.paymentReceivedDate] to an arbitrary JSON value. + * + * You should usually call [Builder.paymentReceivedDate] with a well-typed [LocalDate] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun paymentReceivedDate(paymentReceivedDate: JsonField) = apply { + body.paymentReceivedDate(paymentReceivedDate) + } + /** * Amount already collected to apply to the customer's balance. If mark_as_paid is also * provided, credit the difference to the customer's balance. @@ -332,6 +437,9 @@ private constructor( private constructor( private val description: JsonField, private val markAsPaid: JsonField, + private val paymentExternalId: JsonField, + private val paymentNotes: JsonField, + private val paymentReceivedDate: JsonField, private val previouslyCollectedAmount: JsonField, private val additionalProperties: MutableMap, ) { @@ -344,10 +452,27 @@ private constructor( @JsonProperty("mark_as_paid") @ExcludeMissing markAsPaid: JsonField = JsonMissing.of(), + @JsonProperty("payment_external_id") + @ExcludeMissing + paymentExternalId: JsonField = JsonMissing.of(), + @JsonProperty("payment_notes") + @ExcludeMissing + paymentNotes: JsonField = JsonMissing.of(), + @JsonProperty("payment_received_date") + @ExcludeMissing + paymentReceivedDate: JsonField = JsonMissing.of(), @JsonProperty("previously_collected_amount") @ExcludeMissing previouslyCollectedAmount: JsonField = JsonMissing.of(), - ) : this(description, markAsPaid, previouslyCollectedAmount, mutableMapOf()) + ) : this( + description, + markAsPaid, + paymentExternalId, + paymentNotes, + paymentReceivedDate, + previouslyCollectedAmount, + mutableMapOf(), + ) /** * Description to apply to the balance transaction representing this credit. @@ -366,6 +491,33 @@ private constructor( */ fun markAsPaid(): Boolean? = markAsPaid.getNullable("mark_as_paid") + /** + * An optional external ID to associate with the payment. Only applicable when mark_as_paid + * is true. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun paymentExternalId(): String? = paymentExternalId.getNullable("payment_external_id") + + /** + * Optional notes about the payment. Only applicable when mark_as_paid is true. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun paymentNotes(): String? = paymentNotes.getNullable("payment_notes") + + /** + * A date string to specify the date the payment was received. Only applicable when + * mark_as_paid is true. If not provided, defaults to the current date. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun paymentReceivedDate(): LocalDate? = + paymentReceivedDate.getNullable("payment_received_date") + /** * Amount already collected to apply to the customer's balance. If mark_as_paid is also * provided, credit the difference to the customer's balance. @@ -394,6 +546,36 @@ private constructor( @ExcludeMissing fun _markAsPaid(): JsonField = markAsPaid + /** + * Returns the raw JSON value of [paymentExternalId]. + * + * Unlike [paymentExternalId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("payment_external_id") + @ExcludeMissing + fun _paymentExternalId(): JsonField = paymentExternalId + + /** + * Returns the raw JSON value of [paymentNotes]. + * + * Unlike [paymentNotes], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("payment_notes") + @ExcludeMissing + fun _paymentNotes(): JsonField = paymentNotes + + /** + * Returns the raw JSON value of [paymentReceivedDate]. + * + * Unlike [paymentReceivedDate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("payment_received_date") + @ExcludeMissing + fun _paymentReceivedDate(): JsonField = paymentReceivedDate + /** * Returns the raw JSON value of [previouslyCollectedAmount]. * @@ -427,12 +609,18 @@ private constructor( private var description: JsonField = JsonMissing.of() private var markAsPaid: JsonField = JsonMissing.of() + private var paymentExternalId: JsonField = JsonMissing.of() + private var paymentNotes: JsonField = JsonMissing.of() + private var paymentReceivedDate: JsonField = JsonMissing.of() private var previouslyCollectedAmount: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() internal fun from(body: Body) = apply { description = body.description markAsPaid = body.markAsPaid + paymentExternalId = body.paymentExternalId + paymentNotes = body.paymentNotes + paymentReceivedDate = body.paymentReceivedDate previouslyCollectedAmount = body.previouslyCollectedAmount additionalProperties = body.additionalProperties.toMutableMap() } @@ -473,6 +661,57 @@ private constructor( */ fun markAsPaid(markAsPaid: JsonField) = apply { this.markAsPaid = markAsPaid } + /** + * An optional external ID to associate with the payment. Only applicable when + * mark_as_paid is true. + */ + fun paymentExternalId(paymentExternalId: String?) = + paymentExternalId(JsonField.ofNullable(paymentExternalId)) + + /** + * Sets [Builder.paymentExternalId] to an arbitrary JSON value. + * + * You should usually call [Builder.paymentExternalId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun paymentExternalId(paymentExternalId: JsonField) = apply { + this.paymentExternalId = paymentExternalId + } + + /** Optional notes about the payment. Only applicable when mark_as_paid is true. */ + fun paymentNotes(paymentNotes: String?) = + paymentNotes(JsonField.ofNullable(paymentNotes)) + + /** + * Sets [Builder.paymentNotes] to an arbitrary JSON value. + * + * You should usually call [Builder.paymentNotes] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun paymentNotes(paymentNotes: JsonField) = apply { + this.paymentNotes = paymentNotes + } + + /** + * A date string to specify the date the payment was received. Only applicable when + * mark_as_paid is true. If not provided, defaults to the current date. + */ + fun paymentReceivedDate(paymentReceivedDate: LocalDate?) = + paymentReceivedDate(JsonField.ofNullable(paymentReceivedDate)) + + /** + * Sets [Builder.paymentReceivedDate] to an arbitrary JSON value. + * + * You should usually call [Builder.paymentReceivedDate] with a well-typed [LocalDate] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun paymentReceivedDate(paymentReceivedDate: JsonField) = apply { + this.paymentReceivedDate = paymentReceivedDate + } + /** * Amount already collected to apply to the customer's balance. If mark_as_paid is also * provided, credit the difference to the customer's balance. @@ -519,6 +758,9 @@ private constructor( Body( description, markAsPaid, + paymentExternalId, + paymentNotes, + paymentReceivedDate, previouslyCollectedAmount, additionalProperties.toMutableMap(), ) @@ -533,6 +775,9 @@ private constructor( description() markAsPaid() + paymentExternalId() + paymentNotes() + paymentReceivedDate() previouslyCollectedAmount() validated = true } @@ -554,6 +799,9 @@ private constructor( internal fun validity(): Int = (if (description.asKnown() == null) 0 else 1) + (if (markAsPaid.asKnown() == null) 0 else 1) + + (if (paymentExternalId.asKnown() == null) 0 else 1) + + (if (paymentNotes.asKnown() == null) 0 else 1) + + (if (paymentReceivedDate.asKnown() == null) 0 else 1) + (if (previouslyCollectedAmount.asKnown() == null) 0 else 1) override fun equals(other: Any?): Boolean { @@ -564,18 +812,29 @@ private constructor( return other is Body && description == other.description && markAsPaid == other.markAsPaid && + paymentExternalId == other.paymentExternalId && + paymentNotes == other.paymentNotes && + paymentReceivedDate == other.paymentReceivedDate && previouslyCollectedAmount == other.previouslyCollectedAmount && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(description, markAsPaid, previouslyCollectedAmount, additionalProperties) + Objects.hash( + description, + markAsPaid, + paymentExternalId, + paymentNotes, + paymentReceivedDate, + previouslyCollectedAmount, + additionalProperties, + ) } override fun hashCode(): Int = hashCode override fun toString() = - "Body{description=$description, markAsPaid=$markAsPaid, previouslyCollectedAmount=$previouslyCollectedAmount, additionalProperties=$additionalProperties}" + "Body{description=$description, markAsPaid=$markAsPaid, paymentExternalId=$paymentExternalId, paymentNotes=$paymentNotes, paymentReceivedDate=$paymentReceivedDate, previouslyCollectedAmount=$previouslyCollectedAmount, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeApplyParamsTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeApplyParamsTest.kt index b7c625c41..aa16826a5 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeApplyParamsTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeApplyParamsTest.kt @@ -2,6 +2,7 @@ package com.withorb.api.models +import java.time.LocalDate import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -13,6 +14,9 @@ internal class SubscriptionChangeApplyParamsTest { .subscriptionChangeId("subscription_change_id") .description("description") .markAsPaid(true) + .paymentExternalId("payment_external_id") + .paymentNotes("payment_notes") + .paymentReceivedDate(LocalDate.parse("2019-12-27")) .previouslyCollectedAmount("previously_collected_amount") .build() } @@ -36,6 +40,9 @@ internal class SubscriptionChangeApplyParamsTest { .subscriptionChangeId("subscription_change_id") .description("description") .markAsPaid(true) + .paymentExternalId("payment_external_id") + .paymentNotes("payment_notes") + .paymentReceivedDate(LocalDate.parse("2019-12-27")) .previouslyCollectedAmount("previously_collected_amount") .build() @@ -43,6 +50,9 @@ internal class SubscriptionChangeApplyParamsTest { assertThat(body.description()).isEqualTo("description") assertThat(body.markAsPaid()).isEqualTo(true) + assertThat(body.paymentExternalId()).isEqualTo("payment_external_id") + assertThat(body.paymentNotes()).isEqualTo("payment_notes") + assertThat(body.paymentReceivedDate()).isEqualTo(LocalDate.parse("2019-12-27")) assertThat(body.previouslyCollectedAmount()).isEqualTo("previously_collected_amount") } diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/SubscriptionChangeServiceAsyncTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/SubscriptionChangeServiceAsyncTest.kt index bdb2c1555..d7e9db8bd 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/SubscriptionChangeServiceAsyncTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/SubscriptionChangeServiceAsyncTest.kt @@ -5,6 +5,7 @@ package com.withorb.api.services.async import com.withorb.api.TestServerExtension import com.withorb.api.client.okhttp.OrbOkHttpClientAsync import com.withorb.api.models.SubscriptionChangeApplyParams +import java.time.LocalDate import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -40,6 +41,9 @@ internal class SubscriptionChangeServiceAsyncTest { .subscriptionChangeId("subscription_change_id") .description("description") .markAsPaid(true) + .paymentExternalId("payment_external_id") + .paymentNotes("payment_notes") + .paymentReceivedDate(LocalDate.parse("2019-12-27")) .previouslyCollectedAmount("previously_collected_amount") .build() ) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/SubscriptionChangeServiceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/SubscriptionChangeServiceTest.kt index e4ab8a931..eabf12d7f 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/SubscriptionChangeServiceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/SubscriptionChangeServiceTest.kt @@ -5,6 +5,7 @@ package com.withorb.api.services.blocking import com.withorb.api.TestServerExtension import com.withorb.api.client.okhttp.OrbOkHttpClient import com.withorb.api.models.SubscriptionChangeApplyParams +import java.time.LocalDate import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -40,6 +41,9 @@ internal class SubscriptionChangeServiceTest { .subscriptionChangeId("subscription_change_id") .description("description") .markAsPaid(true) + .paymentExternalId("payment_external_id") + .paymentNotes("payment_notes") + .paymentReceivedDate(LocalDate.parse("2019-12-27")) .previouslyCollectedAmount("previously_collected_amount") .build() ) From 85206bc244ea073698c273fdcd724d74d71d6955 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 27 Oct 2025 15:10:28 +0000 Subject: [PATCH 36/68] codegen metadata --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index f2277cfc2..2f18f221e 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 118 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-cbce25283cb9c3282e03e08b7ee81395436af7d0eb480ffcbab307b5bf1c92a0.yml openapi_spec_hash: c286edf46db95dee05eb6f180ac24ab0 -config_hash: 1f73a949b649ecfe6ec68ba1bb459dc2 +config_hash: 6a1af7b3574f6d4ae6d0e56091445b7d From 1e5d30b9b478a27e62b06ed5c1547fb009fa6e83 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 27 Oct 2025 15:46:02 +0000 Subject: [PATCH 37/68] codegen metadata --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 2f18f221e..4594d63a2 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 118 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-cbce25283cb9c3282e03e08b7ee81395436af7d0eb480ffcbab307b5bf1c92a0.yml openapi_spec_hash: c286edf46db95dee05eb6f180ac24ab0 -config_hash: 6a1af7b3574f6d4ae6d0e56091445b7d +config_hash: dd4343ce95871032ef6e0735a4ca038c From 42c2d10e801b46d82791cb26511cc237c5a9614a Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 29 Oct 2025 17:33:40 +0000 Subject: [PATCH 38/68] feat(api): api update --- .stats.yml | 4 +- .../com/withorb/api/models/AffectedBlock.kt | 127 ++-- .../com/withorb/api/models/Allocation.kt | 585 +++++++++++++++++- .../kotlin/com/withorb/api/models/Customer.kt | 59 +- .../api/models/CustomerCreateParams.kt | 388 +++++++++++- .../CustomerUpdateByExternalIdParams.kt | 494 ++++++++++++++- .../api/models/CustomerUpdateParams.kt | 494 ++++++++++++++- .../api/models/NewAvalaraTaxConfiguration.kt | 67 +- .../api/models/NewSphereConfiguration.kt | 66 +- .../api/models/NewTaxJarConfiguration.kt | 66 +- .../withorb/api/models/AffectedBlockTest.kt | 32 +- .../withorb/api/models/AggregatedCostTest.kt | 21 + .../com/withorb/api/models/AllocationTest.kt | 22 + .../api/models/AmendmentLedgerEntryTest.kt | 30 +- .../ChangedSubscriptionResourcesTest.kt | 50 ++ .../CreditBlockExpiryLedgerEntryTest.kt | 30 +- ...ustomerCostListByExternalIdResponseTest.kt | 25 + .../models/CustomerCostListResponseTest.kt | 25 + .../api/models/CustomerCreateParamsTest.kt | 3 + ...dgerCreateEntryByExternalIdResponseTest.kt | 158 ++--- ...omerCreditLedgerCreateEntryResponseTest.kt | 158 ++--- ...tLedgerListByExternalIdPageResponseTest.kt | 66 +- ...reditLedgerListByExternalIdResponseTest.kt | 158 ++--- ...ustomerCreditLedgerListPageResponseTest.kt | 66 +- .../CustomerCreditLedgerListResponseTest.kt | 158 ++--- .../models/CustomerListPageResponseTest.kt | 3 + .../com/withorb/api/models/CustomerTest.kt | 3 + .../CustomerUpdateByExternalIdParamsTest.kt | 6 + .../api/models/CustomerUpdateParamsTest.kt | 6 + .../api/models/DecrementLedgerEntryTest.kt | 30 +- .../models/ExpirationChangeLedgerEntryTest.kt | 30 +- .../api/models/IncrementLedgerEntryTest.kt | 55 +- .../InvoiceFetchUpcomingResponseTest.kt | 21 + .../InvoiceLineItemCreateResponseTest.kt | 21 + .../api/models/InvoiceListPageResponseTest.kt | 25 + .../com/withorb/api/models/InvoiceTest.kt | 21 + .../api/models/MutatedSubscriptionTest.kt | 111 ++++ .../models/NewAvalaraTaxConfigurationTest.kt | 3 + .../api/models/NewSphereConfigurationTest.kt | 3 + .../api/models/NewTaxJarConfigurationTest.kt | 3 + .../withorb/api/models/PerPriceCostTest.kt | 21 + .../api/models/PlanListPageResponseTest.kt | 21 + .../kotlin/com/withorb/api/models/PlanTest.kt | 21 + .../com/withorb/api/models/PlanVersionTest.kt | 21 + .../withorb/api/models/PriceIntervalTest.kt | 21 + .../api/models/PriceListPageResponseTest.kt | 21 + .../com/withorb/api/models/PriceTest.kt | 420 +++++++++++++ .../SubscriptionChangeApplyResponseTest.kt | 135 ++++ .../SubscriptionChangeCancelResponseTest.kt | 135 ++++ .../SubscriptionChangeRetrieveResponseTest.kt | 135 ++++ .../SubscriptionFetchCostsResponseTest.kt | 25 + .../withorb/api/models/SubscriptionTest.kt | 45 ++ .../withorb/api/models/SubscriptionsTest.kt | 53 ++ .../models/VoidInitiatedLedgerEntryTest.kt | 30 +- .../withorb/api/models/VoidLedgerEntryTest.kt | 30 +- .../withorb/api/services/ErrorHandlingTest.kt | 17 + .../withorb/api/services/ServiceParamsTest.kt | 1 + .../async/CustomerServiceAsyncTest.kt | 5 + .../services/blocking/CustomerServiceTest.kt | 5 + 59 files changed, 4319 insertions(+), 536 deletions(-) diff --git a/.stats.yml b/.stats.yml index 4594d63a2..33d3b4693 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 118 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-cbce25283cb9c3282e03e08b7ee81395436af7d0eb480ffcbab307b5bf1c92a0.yml -openapi_spec_hash: c286edf46db95dee05eb6f180ac24ab0 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-ef726ad139fa29757029206ee08150434fc6c52005fec6d42c7d2bcd3aa7ab47.yml +openapi_spec_hash: e622beb7c26f9b0dd641bd5c92735a5b config_hash: dd4343ce95871032ef6e0735a4ca038c diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/AffectedBlock.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/AffectedBlock.kt index f07da4471..61d4b9b19 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/AffectedBlock.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/AffectedBlock.kt @@ -23,8 +23,8 @@ class AffectedBlock @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, - private val blockFilters: JsonField>, private val expiryDate: JsonField, + private val filters: JsonField>, private val perUnitCostBasis: JsonField, private val additionalProperties: MutableMap, ) { @@ -32,16 +32,16 @@ private constructor( @JsonCreator private constructor( @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), - @JsonProperty("block_filters") - @ExcludeMissing - blockFilters: JsonField> = JsonMissing.of(), @JsonProperty("expiry_date") @ExcludeMissing expiryDate: JsonField = JsonMissing.of(), + @JsonProperty("filters") + @ExcludeMissing + filters: JsonField> = JsonMissing.of(), @JsonProperty("per_unit_cost_basis") @ExcludeMissing perUnitCostBasis: JsonField = JsonMissing.of(), - ) : this(id, blockFilters, expiryDate, perUnitCostBasis, mutableMapOf()) + ) : this(id, expiryDate, filters, perUnitCostBasis, mutableMapOf()) /** * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly @@ -53,13 +53,13 @@ private constructor( * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server * responded with an unexpected value). */ - fun blockFilters(): List? = blockFilters.getNullable("block_filters") + fun expiryDate(): OffsetDateTime? = expiryDate.getNullable("expiry_date") /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). */ - fun expiryDate(): OffsetDateTime? = expiryDate.getNullable("expiry_date") + fun filters(): List = filters.getRequired("filters") /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server @@ -74,15 +74,6 @@ private constructor( */ @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - /** - * Returns the raw JSON value of [blockFilters]. - * - * Unlike [blockFilters], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("block_filters") - @ExcludeMissing - fun _blockFilters(): JsonField> = blockFilters - /** * Returns the raw JSON value of [expiryDate]. * @@ -92,6 +83,13 @@ private constructor( @ExcludeMissing fun _expiryDate(): JsonField = expiryDate + /** + * Returns the raw JSON value of [filters]. + * + * Unlike [filters], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("filters") @ExcludeMissing fun _filters(): JsonField> = filters + /** * Returns the raw JSON value of [perUnitCostBasis]. * @@ -122,8 +120,8 @@ private constructor( * The following fields are required: * ```kotlin * .id() - * .blockFilters() * .expiryDate() + * .filters() * .perUnitCostBasis() * ``` */ @@ -134,15 +132,15 @@ private constructor( class Builder internal constructor() { private var id: JsonField? = null - private var blockFilters: JsonField>? = null private var expiryDate: JsonField? = null + private var filters: JsonField>? = null private var perUnitCostBasis: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(affectedBlock: AffectedBlock) = apply { id = affectedBlock.id - blockFilters = affectedBlock.blockFilters.map { it.toMutableList() } expiryDate = affectedBlock.expiryDate + filters = affectedBlock.filters.map { it.toMutableList() } perUnitCostBasis = affectedBlock.perUnitCostBasis additionalProperties = affectedBlock.additionalProperties.toMutableMap() } @@ -157,43 +155,42 @@ private constructor( */ fun id(id: JsonField) = apply { this.id = id } - fun blockFilters(blockFilters: List?) = - blockFilters(JsonField.ofNullable(blockFilters)) + fun expiryDate(expiryDate: OffsetDateTime?) = expiryDate(JsonField.ofNullable(expiryDate)) /** - * Sets [Builder.blockFilters] to an arbitrary JSON value. + * Sets [Builder.expiryDate] to an arbitrary JSON value. * - * You should usually call [Builder.blockFilters] with a well-typed `List` - * value instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. + * You should usually call [Builder.expiryDate] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun blockFilters(blockFilters: JsonField>) = apply { - this.blockFilters = blockFilters.map { it.toMutableList() } + fun expiryDate(expiryDate: JsonField) = apply { + this.expiryDate = expiryDate } + fun filters(filters: List) = filters(JsonField.of(filters)) + /** - * Adds a single [BlockFilter] to [blockFilters]. + * Sets [Builder.filters] to an arbitrary JSON value. * - * @throws IllegalStateException if the field was previously set to a non-list. + * You should usually call [Builder.filters] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. */ - fun addBlockFilter(blockFilter: BlockFilter) = apply { - blockFilters = - (blockFilters ?: JsonField.of(mutableListOf())).also { - checkKnown("blockFilters", it).add(blockFilter) - } + fun filters(filters: JsonField>) = apply { + this.filters = filters.map { it.toMutableList() } } - fun expiryDate(expiryDate: OffsetDateTime?) = expiryDate(JsonField.ofNullable(expiryDate)) - /** - * Sets [Builder.expiryDate] to an arbitrary JSON value. + * Adds a single [Filter] to [filters]. * - * You should usually call [Builder.expiryDate] with a well-typed [OffsetDateTime] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. + * @throws IllegalStateException if the field was previously set to a non-list. */ - fun expiryDate(expiryDate: JsonField) = apply { - this.expiryDate = expiryDate + fun addFilter(filter: Filter) = apply { + filters = + (filters ?: JsonField.of(mutableListOf())).also { + checkKnown("filters", it).add(filter) + } } fun perUnitCostBasis(perUnitCostBasis: String?) = @@ -237,8 +234,8 @@ private constructor( * The following fields are required: * ```kotlin * .id() - * .blockFilters() * .expiryDate() + * .filters() * .perUnitCostBasis() * ``` * @@ -247,8 +244,8 @@ private constructor( fun build(): AffectedBlock = AffectedBlock( checkRequired("id", id), - checkRequired("blockFilters", blockFilters).map { it.toImmutable() }, checkRequired("expiryDate", expiryDate), + checkRequired("filters", filters).map { it.toImmutable() }, checkRequired("perUnitCostBasis", perUnitCostBasis), additionalProperties.toMutableMap(), ) @@ -262,8 +259,8 @@ private constructor( } id() - blockFilters()?.forEach { it.validate() } expiryDate() + filters().forEach { it.validate() } perUnitCostBasis() validated = true } @@ -283,11 +280,11 @@ private constructor( */ internal fun validity(): Int = (if (id.asKnown() == null) 0 else 1) + - (blockFilters.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + (if (expiryDate.asKnown() == null) 0 else 1) + + (filters.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + (if (perUnitCostBasis.asKnown() == null) 0 else 1) - class BlockFilter + class Filter @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val field: JsonField, @@ -367,7 +364,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [BlockFilter]. + * Returns a mutable builder for constructing an instance of [Filter]. * * The following fields are required: * ```kotlin @@ -379,7 +376,7 @@ private constructor( fun builder() = Builder() } - /** A builder for [BlockFilter]. */ + /** A builder for [Filter]. */ class Builder internal constructor() { private var field: JsonField? = null @@ -387,11 +384,11 @@ private constructor( private var values: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(blockFilter: BlockFilter) = apply { - field = blockFilter.field - operator = blockFilter.operator - values = blockFilter.values.map { it.toMutableList() } - additionalProperties = blockFilter.additionalProperties.toMutableMap() + internal fun from(filter: Filter) = apply { + field = filter.field + operator = filter.operator + values = filter.values.map { it.toMutableList() } + additionalProperties = filter.additionalProperties.toMutableMap() } /** The property of the price to filter on. */ @@ -464,7 +461,7 @@ private constructor( } /** - * Returns an immutable instance of [BlockFilter]. + * Returns an immutable instance of [Filter]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -477,8 +474,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): BlockFilter = - BlockFilter( + fun build(): Filter = + Filter( checkRequired("field", field), checkRequired("operator", operator), checkRequired("values", values).map { it.toImmutable() }, @@ -488,7 +485,7 @@ private constructor( private var validated: Boolean = false - fun validate(): BlockFilter = apply { + fun validate(): Filter = apply { if (validated) { return@apply } @@ -798,7 +795,7 @@ private constructor( return true } - return other is BlockFilter && + return other is Filter && field == other.field && operator == other.operator && values == other.values && @@ -812,7 +809,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "BlockFilter{field=$field, operator=$operator, values=$values, additionalProperties=$additionalProperties}" + "Filter{field=$field, operator=$operator, values=$values, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { @@ -822,18 +819,18 @@ private constructor( return other is AffectedBlock && id == other.id && - blockFilters == other.blockFilters && expiryDate == other.expiryDate && + filters == other.filters && perUnitCostBasis == other.perUnitCostBasis && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(id, blockFilters, expiryDate, perUnitCostBasis, additionalProperties) + Objects.hash(id, expiryDate, filters, perUnitCostBasis, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "AffectedBlock{id=$id, blockFilters=$blockFilters, expiryDate=$expiryDate, perUnitCostBasis=$perUnitCostBasis, additionalProperties=$additionalProperties}" + "AffectedBlock{id=$id, expiryDate=$expiryDate, filters=$filters, perUnitCostBasis=$perUnitCostBasis, additionalProperties=$additionalProperties}" } diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Allocation.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Allocation.kt index 066f0ba1c..ae54b8ec3 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Allocation.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Allocation.kt @@ -6,11 +6,14 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty +import com.withorb.api.core.Enum import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue +import com.withorb.api.core.checkKnown import com.withorb.api.core.checkRequired +import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import java.util.Collections import java.util.Objects @@ -21,6 +24,7 @@ private constructor( private val allowsRollover: JsonField, private val currency: JsonField, private val customExpiration: JsonField, + private val filters: JsonField>, private val additionalProperties: MutableMap, ) { @@ -33,7 +37,8 @@ private constructor( @JsonProperty("custom_expiration") @ExcludeMissing customExpiration: JsonField = JsonMissing.of(), - ) : this(allowsRollover, currency, customExpiration, mutableMapOf()) + @JsonProperty("filters") @ExcludeMissing filters: JsonField> = JsonMissing.of(), + ) : this(allowsRollover, currency, customExpiration, filters, mutableMapOf()) /** * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly @@ -53,6 +58,12 @@ private constructor( */ fun customExpiration(): CustomExpiration? = customExpiration.getNullable("custom_expiration") + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun filters(): List? = filters.getNullable("filters") + /** * Returns the raw JSON value of [allowsRollover]. * @@ -79,6 +90,13 @@ private constructor( @ExcludeMissing fun _customExpiration(): JsonField = customExpiration + /** + * Returns the raw JSON value of [filters]. + * + * Unlike [filters], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("filters") @ExcludeMissing fun _filters(): JsonField> = filters + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -112,12 +130,14 @@ private constructor( private var allowsRollover: JsonField? = null private var currency: JsonField? = null private var customExpiration: JsonField? = null + private var filters: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(allocation: Allocation) = apply { allowsRollover = allocation.allowsRollover currency = allocation.currency customExpiration = allocation.customExpiration + filters = allocation.filters.map { it.toMutableList() } additionalProperties = allocation.additionalProperties.toMutableMap() } @@ -158,6 +178,31 @@ private constructor( this.customExpiration = customExpiration } + fun filters(filters: List) = filters(JsonField.of(filters)) + + /** + * Sets [Builder.filters] to an arbitrary JSON value. + * + * You should usually call [Builder.filters] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun filters(filters: JsonField>) = apply { + this.filters = filters.map { it.toMutableList() } + } + + /** + * Adds a single [Filter] to [filters]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addFilter(filter: Filter) = apply { + filters = + (filters ?: JsonField.of(mutableListOf())).also { + checkKnown("filters", it).add(filter) + } + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -196,6 +241,7 @@ private constructor( checkRequired("allowsRollover", allowsRollover), checkRequired("currency", currency), checkRequired("customExpiration", customExpiration), + (filters ?: JsonMissing.of()).map { it.toImmutable() }, additionalProperties.toMutableMap(), ) } @@ -210,6 +256,7 @@ private constructor( allowsRollover() currency() customExpiration()?.validate() + filters()?.forEach { it.validate() } validated = true } @@ -229,7 +276,536 @@ private constructor( internal fun validity(): Int = (if (allowsRollover.asKnown() == null) 0 else 1) + (if (currency.asKnown() == null) 0 else 1) + - (customExpiration.asKnown()?.validity() ?: 0) + (customExpiration.asKnown()?.validity() ?: 0) + + (filters.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + class Filter + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val field: JsonField, + private val operator: JsonField, + private val values: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("field") @ExcludeMissing field: JsonField = JsonMissing.of(), + @JsonProperty("operator") + @ExcludeMissing + operator: JsonField = JsonMissing.of(), + @JsonProperty("values") + @ExcludeMissing + values: JsonField> = JsonMissing.of(), + ) : this(field, operator, values, mutableMapOf()) + + /** + * The property of the price to filter on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun field(): Field = field.getRequired("field") + + /** + * Should prices that match the filter be included or excluded. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun operator(): Operator = operator.getRequired("operator") + + /** + * The IDs or values that match this filter. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun values(): List = values.getRequired("values") + + /** + * Returns the raw JSON value of [field]. + * + * Unlike [field], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("field") @ExcludeMissing fun _field(): JsonField = field + + /** + * Returns the raw JSON value of [operator]. + * + * Unlike [operator], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("operator") @ExcludeMissing fun _operator(): JsonField = operator + + /** + * Returns the raw JSON value of [values]. + * + * Unlike [values], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("values") @ExcludeMissing fun _values(): JsonField> = values + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Filter]. + * + * The following fields are required: + * ```kotlin + * .field() + * .operator() + * .values() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Filter]. */ + class Builder internal constructor() { + + private var field: JsonField? = null + private var operator: JsonField? = null + private var values: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(filter: Filter) = apply { + field = filter.field + operator = filter.operator + values = filter.values.map { it.toMutableList() } + additionalProperties = filter.additionalProperties.toMutableMap() + } + + /** The property of the price to filter on. */ + fun field(field: Field) = field(JsonField.of(field)) + + /** + * Sets [Builder.field] to an arbitrary JSON value. + * + * You should usually call [Builder.field] with a well-typed [Field] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun field(field: JsonField) = apply { this.field = field } + + /** Should prices that match the filter be included or excluded. */ + fun operator(operator: Operator) = operator(JsonField.of(operator)) + + /** + * Sets [Builder.operator] to an arbitrary JSON value. + * + * You should usually call [Builder.operator] with a well-typed [Operator] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun operator(operator: JsonField) = apply { this.operator = operator } + + /** The IDs or values that match this filter. */ + fun values(values: List) = values(JsonField.of(values)) + + /** + * Sets [Builder.values] to an arbitrary JSON value. + * + * You should usually call [Builder.values] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun values(values: JsonField>) = apply { + this.values = values.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [values]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addValue(value: String) = apply { + values = + (values ?: JsonField.of(mutableListOf())).also { + checkKnown("values", it).add(value) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Filter]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .field() + * .operator() + * .values() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Filter = + Filter( + checkRequired("field", field), + checkRequired("operator", operator), + checkRequired("values", values).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Filter = apply { + if (validated) { + return@apply + } + + field().validate() + operator().validate() + values() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (field.asKnown()?.validity() ?: 0) + + (operator.asKnown()?.validity() ?: 0) + + (values.asKnown()?.size ?: 0) + + /** The property of the price to filter on. */ + class Field @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val PRICE_ID = of("price_id") + + val ITEM_ID = of("item_id") + + val PRICE_TYPE = of("price_type") + + val CURRENCY = of("currency") + + val PRICING_UNIT_ID = of("pricing_unit_id") + + fun of(value: String) = Field(JsonField.of(value)) + } + + /** An enum containing [Field]'s known values. */ + enum class Known { + PRICE_ID, + ITEM_ID, + PRICE_TYPE, + CURRENCY, + PRICING_UNIT_ID, + } + + /** + * An enum containing [Field]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Field] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + PRICE_ID, + ITEM_ID, + PRICE_TYPE, + CURRENCY, + PRICING_UNIT_ID, + /** + * An enum member indicating that [Field] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + PRICE_ID -> Value.PRICE_ID + ITEM_ID -> Value.ITEM_ID + PRICE_TYPE -> Value.PRICE_TYPE + CURRENCY -> Value.CURRENCY + PRICING_UNIT_ID -> Value.PRICING_UNIT_ID + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + PRICE_ID -> Known.PRICE_ID + ITEM_ID -> Known.ITEM_ID + PRICE_TYPE -> Known.PRICE_TYPE + CURRENCY -> Known.CURRENCY + PRICING_UNIT_ID -> Known.PRICING_UNIT_ID + else -> throw OrbInvalidDataException("Unknown Field: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Field = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Field && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Should prices that match the filter be included or excluded. */ + class Operator @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val INCLUDES = of("includes") + + val EXCLUDES = of("excludes") + + fun of(value: String) = Operator(JsonField.of(value)) + } + + /** An enum containing [Operator]'s known values. */ + enum class Known { + INCLUDES, + EXCLUDES, + } + + /** + * An enum containing [Operator]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Operator] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + INCLUDES, + EXCLUDES, + /** + * An enum member indicating that [Operator] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + INCLUDES -> Value.INCLUDES + EXCLUDES -> Value.EXCLUDES + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + INCLUDES -> Known.INCLUDES + EXCLUDES -> Known.EXCLUDES + else -> throw OrbInvalidDataException("Unknown Operator: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Operator = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Operator && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Filter && + field == other.field && + operator == other.operator && + values == other.values && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(field, operator, values, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Filter{field=$field, operator=$operator, values=$values, additionalProperties=$additionalProperties}" + } override fun equals(other: Any?): Boolean { if (this === other) { @@ -240,15 +816,16 @@ private constructor( allowsRollover == other.allowsRollover && currency == other.currency && customExpiration == other.customExpiration && + filters == other.filters && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(allowsRollover, currency, customExpiration, additionalProperties) + Objects.hash(allowsRollover, currency, customExpiration, filters, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "Allocation{allowsRollover=$allowsRollover, currency=$currency, customExpiration=$customExpiration, additionalProperties=$additionalProperties}" + "Allocation{allowsRollover=$allowsRollover, currency=$currency, customExpiration=$customExpiration, filters=$filters, additionalProperties=$additionalProperties}" } diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Customer.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Customer.kt index 90d1497ae..ad2ed594c 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Customer.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Customer.kt @@ -62,6 +62,7 @@ private constructor( private val taxId: JsonField, private val timezone: JsonField, private val accountingSyncConfiguration: JsonField, + private val automaticTaxEnabled: JsonField, private val reportingConfiguration: JsonField, private val additionalProperties: MutableMap, ) { @@ -116,6 +117,9 @@ private constructor( @JsonProperty("accounting_sync_configuration") @ExcludeMissing accountingSyncConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("automatic_tax_enabled") + @ExcludeMissing + automaticTaxEnabled: JsonField = JsonMissing.of(), @JsonProperty("reporting_configuration") @ExcludeMissing reportingConfiguration: JsonField = JsonMissing.of(), @@ -142,6 +146,7 @@ private constructor( taxId, timezone, accountingSyncConfiguration, + automaticTaxEnabled, reportingConfiguration, mutableMapOf(), ) @@ -455,6 +460,15 @@ private constructor( fun accountingSyncConfiguration(): AccountingSyncConfiguration? = accountingSyncConfiguration.getNullable("accounting_sync_configuration") + /** + * Whether automatic tax calculation is enabled for this customer. This field is nullable for + * backwards compatibility but will always return a boolean value. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun automaticTaxEnabled(): Boolean? = automaticTaxEnabled.getNullable("automatic_tax_enabled") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server * responded with an unexpected value). @@ -646,6 +660,16 @@ private constructor( fun _accountingSyncConfiguration(): JsonField = accountingSyncConfiguration + /** + * Returns the raw JSON value of [automaticTaxEnabled]. + * + * Unlike [automaticTaxEnabled], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("automatic_tax_enabled") + @ExcludeMissing + fun _automaticTaxEnabled(): JsonField = automaticTaxEnabled + /** * Returns the raw JSON value of [reportingConfiguration]. * @@ -727,6 +751,7 @@ private constructor( private var timezone: JsonField? = null private var accountingSyncConfiguration: JsonField = JsonMissing.of() + private var automaticTaxEnabled: JsonField = JsonMissing.of() private var reportingConfiguration: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -753,6 +778,7 @@ private constructor( taxId = customer.taxId timezone = customer.timezone accountingSyncConfiguration = customer.accountingSyncConfiguration + automaticTaxEnabled = customer.automaticTaxEnabled reportingConfiguration = customer.reportingConfiguration additionalProperties = customer.additionalProperties.toMutableMap() } @@ -1230,6 +1256,32 @@ private constructor( accountingSyncConfiguration: JsonField ) = apply { this.accountingSyncConfiguration = accountingSyncConfiguration } + /** + * Whether automatic tax calculation is enabled for this customer. This field is nullable + * for backwards compatibility but will always return a boolean value. + */ + fun automaticTaxEnabled(automaticTaxEnabled: Boolean?) = + automaticTaxEnabled(JsonField.ofNullable(automaticTaxEnabled)) + + /** + * Alias for [Builder.automaticTaxEnabled]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun automaticTaxEnabled(automaticTaxEnabled: Boolean) = + automaticTaxEnabled(automaticTaxEnabled as Boolean?) + + /** + * Sets [Builder.automaticTaxEnabled] to an arbitrary JSON value. + * + * You should usually call [Builder.automaticTaxEnabled] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun automaticTaxEnabled(automaticTaxEnabled: JsonField) = apply { + this.automaticTaxEnabled = automaticTaxEnabled + } + fun reportingConfiguration(reportingConfiguration: ReportingConfiguration?) = reportingConfiguration(JsonField.ofNullable(reportingConfiguration)) @@ -1320,6 +1372,7 @@ private constructor( checkRequired("taxId", taxId), checkRequired("timezone", timezone), accountingSyncConfiguration, + automaticTaxEnabled, reportingConfiguration, additionalProperties.toMutableMap(), ) @@ -1354,6 +1407,7 @@ private constructor( taxId()?.validate() timezone() accountingSyncConfiguration()?.validate() + automaticTaxEnabled() reportingConfiguration()?.validate() validated = true } @@ -1394,6 +1448,7 @@ private constructor( (taxId.asKnown()?.validity() ?: 0) + (if (timezone.asKnown() == null) 0 else 1) + (accountingSyncConfiguration.asKnown()?.validity() ?: 0) + + (if (automaticTaxEnabled.asKnown() == null) 0 else 1) + (reportingConfiguration.asKnown()?.validity() ?: 0) /** The hierarchical relationships for this customer. */ @@ -2607,6 +2662,7 @@ private constructor( taxId == other.taxId && timezone == other.timezone && accountingSyncConfiguration == other.accountingSyncConfiguration && + automaticTaxEnabled == other.automaticTaxEnabled && reportingConfiguration == other.reportingConfiguration && additionalProperties == other.additionalProperties } @@ -2635,6 +2691,7 @@ private constructor( taxId, timezone, accountingSyncConfiguration, + automaticTaxEnabled, reportingConfiguration, additionalProperties, ) @@ -2643,5 +2700,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Customer{id=$id, additionalEmails=$additionalEmails, autoCollection=$autoCollection, autoIssuance=$autoIssuance, balance=$balance, billingAddress=$billingAddress, createdAt=$createdAt, currency=$currency, email=$email, emailDelivery=$emailDelivery, exemptFromAutomatedTax=$exemptFromAutomatedTax, externalCustomerId=$externalCustomerId, hierarchy=$hierarchy, metadata=$metadata, name=$name, paymentProvider=$paymentProvider, paymentProviderId=$paymentProviderId, portalUrl=$portalUrl, shippingAddress=$shippingAddress, taxId=$taxId, timezone=$timezone, accountingSyncConfiguration=$accountingSyncConfiguration, reportingConfiguration=$reportingConfiguration, additionalProperties=$additionalProperties}" + "Customer{id=$id, additionalEmails=$additionalEmails, autoCollection=$autoCollection, autoIssuance=$autoIssuance, balance=$balance, billingAddress=$billingAddress, createdAt=$createdAt, currency=$currency, email=$email, emailDelivery=$emailDelivery, exemptFromAutomatedTax=$exemptFromAutomatedTax, externalCustomerId=$externalCustomerId, hierarchy=$hierarchy, metadata=$metadata, name=$name, paymentProvider=$paymentProvider, paymentProviderId=$paymentProviderId, portalUrl=$portalUrl, shippingAddress=$shippingAddress, taxId=$taxId, timezone=$timezone, accountingSyncConfiguration=$accountingSyncConfiguration, automaticTaxEnabled=$automaticTaxEnabled, reportingConfiguration=$reportingConfiguration, additionalProperties=$additionalProperties}" } diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreateParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreateParams.kt index b716b3821..a2111869b 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreateParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreateParams.kt @@ -916,6 +916,21 @@ private constructor( body.numeralTaxConfiguration(taxExempt) } + /** Alias for calling [taxConfiguration] with `TaxConfiguration.ofAnrok(anrok)`. */ + fun taxConfiguration(anrok: TaxConfiguration.Anrok) = apply { body.taxConfiguration(anrok) } + + /** + * Alias for calling [taxConfiguration] with the following: + * ```kotlin + * TaxConfiguration.Anrok.builder() + * .taxExempt(taxExempt) + * .build() + * ``` + */ + fun anrokTaxConfiguration(taxExempt: Boolean) = apply { + body.anrokTaxConfiguration(taxExempt) + } + /** * Tax IDs are commonly required to be displayed on customer invoices, which are added to * the headers of invoices. @@ -2265,6 +2280,21 @@ private constructor( fun numeralTaxConfiguration(taxExempt: Boolean) = taxConfiguration(TaxConfiguration.Numeral.builder().taxExempt(taxExempt).build()) + /** Alias for calling [taxConfiguration] with `TaxConfiguration.ofAnrok(anrok)`. */ + fun taxConfiguration(anrok: TaxConfiguration.Anrok) = + taxConfiguration(TaxConfiguration.ofAnrok(anrok)) + + /** + * Alias for calling [taxConfiguration] with the following: + * ```kotlin + * TaxConfiguration.Anrok.builder() + * .taxExempt(taxExempt) + * .build() + * ``` + */ + fun anrokTaxConfiguration(taxExempt: Boolean) = + taxConfiguration(TaxConfiguration.Anrok.builder().taxExempt(taxExempt).build()) + /** * Tax IDs are commonly required to be displayed on customer invoices, which are added * to the headers of invoices. @@ -2877,6 +2907,7 @@ private constructor( private val taxjar: NewTaxJarConfiguration? = null, private val sphere: NewSphereConfiguration? = null, private val numeral: Numeral? = null, + private val anrok: Anrok? = null, private val _json: JsonValue? = null, ) { @@ -2888,6 +2919,8 @@ private constructor( fun numeral(): Numeral? = numeral + fun anrok(): Anrok? = anrok + fun isAvalara(): Boolean = avalara != null fun isTaxjar(): Boolean = taxjar != null @@ -2896,6 +2929,8 @@ private constructor( fun isNumeral(): Boolean = numeral != null + fun isAnrok(): Boolean = anrok != null + fun asAvalara(): NewAvalaraTaxConfiguration = avalara.getOrThrow("avalara") fun asTaxjar(): NewTaxJarConfiguration = taxjar.getOrThrow("taxjar") @@ -2904,6 +2939,8 @@ private constructor( fun asNumeral(): Numeral = numeral.getOrThrow("numeral") + fun asAnrok(): Anrok = anrok.getOrThrow("anrok") + fun _json(): JsonValue? = _json fun accept(visitor: Visitor): T = @@ -2912,6 +2949,7 @@ private constructor( taxjar != null -> visitor.visitTaxjar(taxjar) sphere != null -> visitor.visitSphere(sphere) numeral != null -> visitor.visitNumeral(numeral) + anrok != null -> visitor.visitAnrok(anrok) else -> visitor.unknown(_json) } @@ -2939,6 +2977,10 @@ private constructor( override fun visitNumeral(numeral: Numeral) { numeral.validate() } + + override fun visitAnrok(anrok: Anrok) { + anrok.validate() + } } ) validated = true @@ -2970,6 +3012,8 @@ private constructor( override fun visitNumeral(numeral: Numeral) = numeral.validity() + override fun visitAnrok(anrok: Anrok) = anrok.validity() + override fun unknown(json: JsonValue?) = 0 } ) @@ -2983,10 +3027,11 @@ private constructor( avalara == other.avalara && taxjar == other.taxjar && sphere == other.sphere && - numeral == other.numeral + numeral == other.numeral && + anrok == other.anrok } - override fun hashCode(): Int = Objects.hash(avalara, taxjar, sphere, numeral) + override fun hashCode(): Int = Objects.hash(avalara, taxjar, sphere, numeral, anrok) override fun toString(): String = when { @@ -2994,6 +3039,7 @@ private constructor( taxjar != null -> "TaxConfiguration{taxjar=$taxjar}" sphere != null -> "TaxConfiguration{sphere=$sphere}" numeral != null -> "TaxConfiguration{numeral=$numeral}" + anrok != null -> "TaxConfiguration{anrok=$anrok}" _json != null -> "TaxConfiguration{_unknown=$_json}" else -> throw IllegalStateException("Invalid TaxConfiguration") } @@ -3007,6 +3053,8 @@ private constructor( fun ofSphere(sphere: NewSphereConfiguration) = TaxConfiguration(sphere = sphere) fun ofNumeral(numeral: Numeral) = TaxConfiguration(numeral = numeral) + + fun ofAnrok(anrok: Anrok) = TaxConfiguration(anrok = anrok) } /** @@ -3023,6 +3071,8 @@ private constructor( fun visitNumeral(numeral: Numeral): T + fun visitAnrok(anrok: Anrok): T + /** * Maps an unknown variant of [TaxConfiguration] to a value of type [T]. * @@ -3065,6 +3115,11 @@ private constructor( TaxConfiguration(numeral = it, _json = json) } ?: TaxConfiguration(_json = json) } + "anrok" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + TaxConfiguration(anrok = it, _json = json) + } ?: TaxConfiguration(_json = json) + } } return TaxConfiguration(_json = json) @@ -3083,6 +3138,7 @@ private constructor( value.taxjar != null -> generator.writeObject(value.taxjar) value.sphere != null -> generator.writeObject(value.sphere) value.numeral != null -> generator.writeObject(value.numeral) + value.anrok != null -> generator.writeObject(value.anrok) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid TaxConfiguration") } @@ -3094,6 +3150,7 @@ private constructor( private constructor( private val taxExempt: JsonField, private val taxProvider: JsonValue, + private val automaticTaxEnabled: JsonField, private val additionalProperties: MutableMap, ) { @@ -3105,7 +3162,10 @@ private constructor( @JsonProperty("tax_provider") @ExcludeMissing taxProvider: JsonValue = JsonMissing.of(), - ) : this(taxExempt, taxProvider, mutableMapOf()) + @JsonProperty("automatic_tax_enabled") + @ExcludeMissing + automaticTaxEnabled: JsonField = JsonMissing.of(), + ) : this(taxExempt, taxProvider, automaticTaxEnabled, mutableMapOf()) /** * @throws OrbInvalidDataException if the JSON field has an unexpected type or is @@ -3127,6 +3187,16 @@ private constructor( @ExcludeMissing fun _taxProvider(): JsonValue = taxProvider + /** + * Whether to automatically calculate tax for this customer. When null, inherits from + * account-level setting. When true or false, overrides the account setting. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun automaticTaxEnabled(): Boolean? = + automaticTaxEnabled.getNullable("automatic_tax_enabled") + /** * Returns the raw JSON value of [taxExempt]. * @@ -3137,6 +3207,16 @@ private constructor( @ExcludeMissing fun _taxExempt(): JsonField = taxExempt + /** + * Returns the raw JSON value of [automaticTaxEnabled]. + * + * Unlike [automaticTaxEnabled], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("automatic_tax_enabled") + @ExcludeMissing + fun _automaticTaxEnabled(): JsonField = automaticTaxEnabled + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -3167,11 +3247,13 @@ private constructor( private var taxExempt: JsonField? = null private var taxProvider: JsonValue = JsonValue.from("numeral") + private var automaticTaxEnabled: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() internal fun from(numeral: Numeral) = apply { taxExempt = numeral.taxExempt taxProvider = numeral.taxProvider + automaticTaxEnabled = numeral.automaticTaxEnabled additionalProperties = numeral.additionalProperties.toMutableMap() } @@ -3200,6 +3282,32 @@ private constructor( */ fun taxProvider(taxProvider: JsonValue) = apply { this.taxProvider = taxProvider } + /** + * Whether to automatically calculate tax for this customer. When null, inherits + * from account-level setting. When true or false, overrides the account setting. + */ + fun automaticTaxEnabled(automaticTaxEnabled: Boolean?) = + automaticTaxEnabled(JsonField.ofNullable(automaticTaxEnabled)) + + /** + * Alias for [Builder.automaticTaxEnabled]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun automaticTaxEnabled(automaticTaxEnabled: Boolean) = + automaticTaxEnabled(automaticTaxEnabled as Boolean?) + + /** + * Sets [Builder.automaticTaxEnabled] to an arbitrary JSON value. + * + * You should usually call [Builder.automaticTaxEnabled] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun automaticTaxEnabled(automaticTaxEnabled: JsonField) = apply { + this.automaticTaxEnabled = automaticTaxEnabled + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -3238,6 +3346,7 @@ private constructor( Numeral( checkRequired("taxExempt", taxExempt), taxProvider, + automaticTaxEnabled, additionalProperties.toMutableMap(), ) } @@ -3255,6 +3364,7 @@ private constructor( throw OrbInvalidDataException("'taxProvider' is invalid, received $it") } } + automaticTaxEnabled() validated = true } @@ -3274,7 +3384,8 @@ private constructor( */ internal fun validity(): Int = (if (taxExempt.asKnown() == null) 0 else 1) + - taxProvider.let { if (it == JsonValue.from("numeral")) 1 else 0 } + taxProvider.let { if (it == JsonValue.from("numeral")) 1 else 0 } + + (if (automaticTaxEnabled.asKnown() == null) 0 else 1) override fun equals(other: Any?): Boolean { if (this === other) { @@ -3284,17 +3395,282 @@ private constructor( return other is Numeral && taxExempt == other.taxExempt && taxProvider == other.taxProvider && + automaticTaxEnabled == other.automaticTaxEnabled && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(taxExempt, taxProvider, automaticTaxEnabled, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Numeral{taxExempt=$taxExempt, taxProvider=$taxProvider, automaticTaxEnabled=$automaticTaxEnabled, additionalProperties=$additionalProperties}" + } + + class Anrok + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val taxExempt: JsonField, + private val taxProvider: JsonValue, + private val automaticTaxEnabled: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("tax_exempt") + @ExcludeMissing + taxExempt: JsonField = JsonMissing.of(), + @JsonProperty("tax_provider") + @ExcludeMissing + taxProvider: JsonValue = JsonMissing.of(), + @JsonProperty("automatic_tax_enabled") + @ExcludeMissing + automaticTaxEnabled: JsonField = JsonMissing.of(), + ) : this(taxExempt, taxProvider, automaticTaxEnabled, mutableMapOf()) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun taxExempt(): Boolean = taxExempt.getRequired("tax_exempt") + + /** + * Expected to always return the following: + * ```kotlin + * JsonValue.from("anrok") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("tax_provider") + @ExcludeMissing + fun _taxProvider(): JsonValue = taxProvider + + /** + * Whether to automatically calculate tax for this customer. When null, inherits from + * account-level setting. When true or false, overrides the account setting. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun automaticTaxEnabled(): Boolean? = + automaticTaxEnabled.getNullable("automatic_tax_enabled") + + /** + * Returns the raw JSON value of [taxExempt]. + * + * Unlike [taxExempt], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tax_exempt") + @ExcludeMissing + fun _taxExempt(): JsonField = taxExempt + + /** + * Returns the raw JSON value of [automaticTaxEnabled]. + * + * Unlike [automaticTaxEnabled], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("automatic_tax_enabled") + @ExcludeMissing + fun _automaticTaxEnabled(): JsonField = automaticTaxEnabled + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Anrok]. + * + * The following fields are required: + * ```kotlin + * .taxExempt() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Anrok]. */ + class Builder internal constructor() { + + private var taxExempt: JsonField? = null + private var taxProvider: JsonValue = JsonValue.from("anrok") + private var automaticTaxEnabled: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(anrok: Anrok) = apply { + taxExempt = anrok.taxExempt + taxProvider = anrok.taxProvider + automaticTaxEnabled = anrok.automaticTaxEnabled + additionalProperties = anrok.additionalProperties.toMutableMap() + } + + fun taxExempt(taxExempt: Boolean) = taxExempt(JsonField.of(taxExempt)) + + /** + * Sets [Builder.taxExempt] to an arbitrary JSON value. + * + * You should usually call [Builder.taxExempt] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun taxExempt(taxExempt: JsonField) = apply { this.taxExempt = taxExempt } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```kotlin + * JsonValue.from("anrok") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun taxProvider(taxProvider: JsonValue) = apply { this.taxProvider = taxProvider } + + /** + * Whether to automatically calculate tax for this customer. When null, inherits + * from account-level setting. When true or false, overrides the account setting. + */ + fun automaticTaxEnabled(automaticTaxEnabled: Boolean?) = + automaticTaxEnabled(JsonField.ofNullable(automaticTaxEnabled)) + + /** + * Alias for [Builder.automaticTaxEnabled]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun automaticTaxEnabled(automaticTaxEnabled: Boolean) = + automaticTaxEnabled(automaticTaxEnabled as Boolean?) + + /** + * Sets [Builder.automaticTaxEnabled] to an arbitrary JSON value. + * + * You should usually call [Builder.automaticTaxEnabled] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun automaticTaxEnabled(automaticTaxEnabled: JsonField) = apply { + this.automaticTaxEnabled = automaticTaxEnabled + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Anrok]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .taxExempt() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Anrok = + Anrok( + checkRequired("taxExempt", taxExempt), + taxProvider, + automaticTaxEnabled, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Anrok = apply { + if (validated) { + return@apply + } + + taxExempt() + _taxProvider().let { + if (it != JsonValue.from("anrok")) { + throw OrbInvalidDataException("'taxProvider' is invalid, received $it") + } + } + automaticTaxEnabled() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (taxExempt.asKnown() == null) 0 else 1) + + taxProvider.let { if (it == JsonValue.from("anrok")) 1 else 0 } + + (if (automaticTaxEnabled.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Anrok && + taxExempt == other.taxExempt && + taxProvider == other.taxProvider && + automaticTaxEnabled == other.automaticTaxEnabled && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(taxExempt, taxProvider, additionalProperties) + Objects.hash(taxExempt, taxProvider, automaticTaxEnabled, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "Numeral{taxExempt=$taxExempt, taxProvider=$taxProvider, additionalProperties=$additionalProperties}" + "Anrok{taxExempt=$taxExempt, taxProvider=$taxProvider, automaticTaxEnabled=$automaticTaxEnabled, additionalProperties=$additionalProperties}" } } diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerUpdateByExternalIdParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerUpdateByExternalIdParams.kt index c66f03d3a..1e02cd18b 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerUpdateByExternalIdParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerUpdateByExternalIdParams.kt @@ -84,6 +84,15 @@ private constructor( */ fun autoIssuance(): Boolean? = body.autoIssuance() + /** + * Whether automatic tax calculation is enabled for this customer. When null, inherits from + * account-level setting. When true or false, overrides the account setting. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun automaticTaxEnabled(): Boolean? = body.automaticTaxEnabled() + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server * responded with an unexpected value). @@ -370,6 +379,14 @@ private constructor( */ fun _autoIssuance(): JsonField = body._autoIssuance() + /** + * Returns the raw JSON value of [automaticTaxEnabled]. + * + * Unlike [automaticTaxEnabled], this method doesn't throw if the JSON field has an unexpected + * type. + */ + fun _automaticTaxEnabled(): JsonField = body._automaticTaxEnabled() + /** * Returns the raw JSON value of [billingAddress]. * @@ -522,7 +539,7 @@ private constructor( * - [additionalEmails] * - [autoCollection] * - [autoIssuance] - * - [billingAddress] + * - [automaticTaxEnabled] * - etc. */ fun body(body: Body) = apply { this.body = body.toBuilder() } @@ -622,6 +639,33 @@ private constructor( body.autoIssuance(autoIssuance) } + /** + * Whether automatic tax calculation is enabled for this customer. When null, inherits from + * account-level setting. When true or false, overrides the account setting. + */ + fun automaticTaxEnabled(automaticTaxEnabled: Boolean?) = apply { + body.automaticTaxEnabled(automaticTaxEnabled) + } + + /** + * Alias for [Builder.automaticTaxEnabled]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun automaticTaxEnabled(automaticTaxEnabled: Boolean) = + automaticTaxEnabled(automaticTaxEnabled as Boolean?) + + /** + * Sets [Builder.automaticTaxEnabled] to an arbitrary JSON value. + * + * You should usually call [Builder.automaticTaxEnabled] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun automaticTaxEnabled(automaticTaxEnabled: JsonField) = apply { + body.automaticTaxEnabled(automaticTaxEnabled) + } + fun billingAddress(billingAddress: AddressInput?) = apply { body.billingAddress(billingAddress) } @@ -902,6 +946,21 @@ private constructor( body.numeralTaxConfiguration(taxExempt) } + /** Alias for calling [taxConfiguration] with `TaxConfiguration.ofAnrok(anrok)`. */ + fun taxConfiguration(anrok: TaxConfiguration.Anrok) = apply { body.taxConfiguration(anrok) } + + /** + * Alias for calling [taxConfiguration] with the following: + * ```kotlin + * TaxConfiguration.Anrok.builder() + * .taxExempt(taxExempt) + * .build() + * ``` + */ + fun anrokTaxConfiguration(taxExempt: Boolean) = apply { + body.anrokTaxConfiguration(taxExempt) + } + /** * Tax IDs are commonly required to be displayed on customer invoices, which are added to * the headers of invoices. @@ -1208,6 +1267,7 @@ private constructor( private val additionalEmails: JsonField>, private val autoCollection: JsonField, private val autoIssuance: JsonField, + private val automaticTaxEnabled: JsonField, private val billingAddress: JsonField, private val currency: JsonField, private val email: JsonField, @@ -1240,6 +1300,9 @@ private constructor( @JsonProperty("auto_issuance") @ExcludeMissing autoIssuance: JsonField = JsonMissing.of(), + @JsonProperty("automatic_tax_enabled") + @ExcludeMissing + automaticTaxEnabled: JsonField = JsonMissing.of(), @JsonProperty("billing_address") @ExcludeMissing billingAddress: JsonField = JsonMissing.of(), @@ -1283,6 +1346,7 @@ private constructor( additionalEmails, autoCollection, autoIssuance, + automaticTaxEnabled, billingAddress, currency, email, @@ -1338,6 +1402,16 @@ private constructor( */ fun autoIssuance(): Boolean? = autoIssuance.getNullable("auto_issuance") + /** + * Whether automatic tax calculation is enabled for this customer. When null, inherits from + * account-level setting. When true or false, overrides the account setting. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun automaticTaxEnabled(): Boolean? = + automaticTaxEnabled.getNullable("automatic_tax_enabled") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -1636,6 +1710,16 @@ private constructor( @ExcludeMissing fun _autoIssuance(): JsonField = autoIssuance + /** + * Returns the raw JSON value of [automaticTaxEnabled]. + * + * Unlike [automaticTaxEnabled], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("automatic_tax_enabled") + @ExcludeMissing + fun _automaticTaxEnabled(): JsonField = automaticTaxEnabled + /** * Returns the raw JSON value of [billingAddress]. * @@ -1786,6 +1870,7 @@ private constructor( private var additionalEmails: JsonField>? = null private var autoCollection: JsonField = JsonMissing.of() private var autoIssuance: JsonField = JsonMissing.of() + private var automaticTaxEnabled: JsonField = JsonMissing.of() private var billingAddress: JsonField = JsonMissing.of() private var currency: JsonField = JsonMissing.of() private var email: JsonField = JsonMissing.of() @@ -1808,6 +1893,7 @@ private constructor( additionalEmails = body.additionalEmails.map { it.toMutableList() } autoCollection = body.autoCollection autoIssuance = body.autoIssuance + automaticTaxEnabled = body.automaticTaxEnabled billingAddress = body.billingAddress currency = body.currency email = body.email @@ -1924,6 +2010,32 @@ private constructor( this.autoIssuance = autoIssuance } + /** + * Whether automatic tax calculation is enabled for this customer. When null, inherits + * from account-level setting. When true or false, overrides the account setting. + */ + fun automaticTaxEnabled(automaticTaxEnabled: Boolean?) = + automaticTaxEnabled(JsonField.ofNullable(automaticTaxEnabled)) + + /** + * Alias for [Builder.automaticTaxEnabled]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun automaticTaxEnabled(automaticTaxEnabled: Boolean) = + automaticTaxEnabled(automaticTaxEnabled as Boolean?) + + /** + * Sets [Builder.automaticTaxEnabled] to an arbitrary JSON value. + * + * You should usually call [Builder.automaticTaxEnabled] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun automaticTaxEnabled(automaticTaxEnabled: JsonField) = apply { + this.automaticTaxEnabled = automaticTaxEnabled + } + fun billingAddress(billingAddress: AddressInput?) = billingAddress(JsonField.ofNullable(billingAddress)) @@ -2209,6 +2321,21 @@ private constructor( fun numeralTaxConfiguration(taxExempt: Boolean) = taxConfiguration(TaxConfiguration.Numeral.builder().taxExempt(taxExempt).build()) + /** Alias for calling [taxConfiguration] with `TaxConfiguration.ofAnrok(anrok)`. */ + fun taxConfiguration(anrok: TaxConfiguration.Anrok) = + taxConfiguration(TaxConfiguration.ofAnrok(anrok)) + + /** + * Alias for calling [taxConfiguration] with the following: + * ```kotlin + * TaxConfiguration.Anrok.builder() + * .taxExempt(taxExempt) + * .build() + * ``` + */ + fun anrokTaxConfiguration(taxExempt: Boolean) = + taxConfiguration(TaxConfiguration.Anrok.builder().taxExempt(taxExempt).build()) + /** * Tax IDs are commonly required to be displayed on customer invoices, which are added * to the headers of invoices. @@ -2395,6 +2522,7 @@ private constructor( (additionalEmails ?: JsonMissing.of()).map { it.toImmutable() }, autoCollection, autoIssuance, + automaticTaxEnabled, billingAddress, currency, email, @@ -2424,6 +2552,7 @@ private constructor( additionalEmails() autoCollection() autoIssuance() + automaticTaxEnabled() billingAddress()?.validate() currency() email() @@ -2460,6 +2589,7 @@ private constructor( (additionalEmails.asKnown()?.size ?: 0) + (if (autoCollection.asKnown() == null) 0 else 1) + (if (autoIssuance.asKnown() == null) 0 else 1) + + (if (automaticTaxEnabled.asKnown() == null) 0 else 1) + (billingAddress.asKnown()?.validity() ?: 0) + (if (currency.asKnown() == null) 0 else 1) + (if (email.asKnown() == null) 0 else 1) + @@ -2485,6 +2615,7 @@ private constructor( additionalEmails == other.additionalEmails && autoCollection == other.autoCollection && autoIssuance == other.autoIssuance && + automaticTaxEnabled == other.automaticTaxEnabled && billingAddress == other.billingAddress && currency == other.currency && email == other.email && @@ -2508,6 +2639,7 @@ private constructor( additionalEmails, autoCollection, autoIssuance, + automaticTaxEnabled, billingAddress, currency, email, @@ -2529,7 +2661,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Body{accountingSyncConfiguration=$accountingSyncConfiguration, additionalEmails=$additionalEmails, autoCollection=$autoCollection, autoIssuance=$autoIssuance, billingAddress=$billingAddress, currency=$currency, email=$email, emailDelivery=$emailDelivery, externalCustomerId=$externalCustomerId, hierarchy=$hierarchy, metadata=$metadata, name=$name, paymentProvider=$paymentProvider, paymentProviderId=$paymentProviderId, reportingConfiguration=$reportingConfiguration, shippingAddress=$shippingAddress, taxConfiguration=$taxConfiguration, taxId=$taxId, additionalProperties=$additionalProperties}" + "Body{accountingSyncConfiguration=$accountingSyncConfiguration, additionalEmails=$additionalEmails, autoCollection=$autoCollection, autoIssuance=$autoIssuance, automaticTaxEnabled=$automaticTaxEnabled, billingAddress=$billingAddress, currency=$currency, email=$email, emailDelivery=$emailDelivery, externalCustomerId=$externalCustomerId, hierarchy=$hierarchy, metadata=$metadata, name=$name, paymentProvider=$paymentProvider, paymentProviderId=$paymentProviderId, reportingConfiguration=$reportingConfiguration, shippingAddress=$shippingAddress, taxConfiguration=$taxConfiguration, taxId=$taxId, additionalProperties=$additionalProperties}" } /** @@ -2795,6 +2927,7 @@ private constructor( private val taxjar: NewTaxJarConfiguration? = null, private val sphere: NewSphereConfiguration? = null, private val numeral: Numeral? = null, + private val anrok: Anrok? = null, private val _json: JsonValue? = null, ) { @@ -2806,6 +2939,8 @@ private constructor( fun numeral(): Numeral? = numeral + fun anrok(): Anrok? = anrok + fun isAvalara(): Boolean = avalara != null fun isTaxjar(): Boolean = taxjar != null @@ -2814,6 +2949,8 @@ private constructor( fun isNumeral(): Boolean = numeral != null + fun isAnrok(): Boolean = anrok != null + fun asAvalara(): NewAvalaraTaxConfiguration = avalara.getOrThrow("avalara") fun asTaxjar(): NewTaxJarConfiguration = taxjar.getOrThrow("taxjar") @@ -2822,6 +2959,8 @@ private constructor( fun asNumeral(): Numeral = numeral.getOrThrow("numeral") + fun asAnrok(): Anrok = anrok.getOrThrow("anrok") + fun _json(): JsonValue? = _json fun accept(visitor: Visitor): T = @@ -2830,6 +2969,7 @@ private constructor( taxjar != null -> visitor.visitTaxjar(taxjar) sphere != null -> visitor.visitSphere(sphere) numeral != null -> visitor.visitNumeral(numeral) + anrok != null -> visitor.visitAnrok(anrok) else -> visitor.unknown(_json) } @@ -2857,6 +2997,10 @@ private constructor( override fun visitNumeral(numeral: Numeral) { numeral.validate() } + + override fun visitAnrok(anrok: Anrok) { + anrok.validate() + } } ) validated = true @@ -2888,6 +3032,8 @@ private constructor( override fun visitNumeral(numeral: Numeral) = numeral.validity() + override fun visitAnrok(anrok: Anrok) = anrok.validity() + override fun unknown(json: JsonValue?) = 0 } ) @@ -2901,10 +3047,11 @@ private constructor( avalara == other.avalara && taxjar == other.taxjar && sphere == other.sphere && - numeral == other.numeral + numeral == other.numeral && + anrok == other.anrok } - override fun hashCode(): Int = Objects.hash(avalara, taxjar, sphere, numeral) + override fun hashCode(): Int = Objects.hash(avalara, taxjar, sphere, numeral, anrok) override fun toString(): String = when { @@ -2912,6 +3059,7 @@ private constructor( taxjar != null -> "TaxConfiguration{taxjar=$taxjar}" sphere != null -> "TaxConfiguration{sphere=$sphere}" numeral != null -> "TaxConfiguration{numeral=$numeral}" + anrok != null -> "TaxConfiguration{anrok=$anrok}" _json != null -> "TaxConfiguration{_unknown=$_json}" else -> throw IllegalStateException("Invalid TaxConfiguration") } @@ -2925,6 +3073,8 @@ private constructor( fun ofSphere(sphere: NewSphereConfiguration) = TaxConfiguration(sphere = sphere) fun ofNumeral(numeral: Numeral) = TaxConfiguration(numeral = numeral) + + fun ofAnrok(anrok: Anrok) = TaxConfiguration(anrok = anrok) } /** @@ -2941,6 +3091,8 @@ private constructor( fun visitNumeral(numeral: Numeral): T + fun visitAnrok(anrok: Anrok): T + /** * Maps an unknown variant of [TaxConfiguration] to a value of type [T]. * @@ -2983,6 +3135,11 @@ private constructor( TaxConfiguration(numeral = it, _json = json) } ?: TaxConfiguration(_json = json) } + "anrok" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + TaxConfiguration(anrok = it, _json = json) + } ?: TaxConfiguration(_json = json) + } } return TaxConfiguration(_json = json) @@ -3001,6 +3158,7 @@ private constructor( value.taxjar != null -> generator.writeObject(value.taxjar) value.sphere != null -> generator.writeObject(value.sphere) value.numeral != null -> generator.writeObject(value.numeral) + value.anrok != null -> generator.writeObject(value.anrok) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid TaxConfiguration") } @@ -3012,6 +3170,7 @@ private constructor( private constructor( private val taxExempt: JsonField, private val taxProvider: JsonValue, + private val automaticTaxEnabled: JsonField, private val additionalProperties: MutableMap, ) { @@ -3023,7 +3182,10 @@ private constructor( @JsonProperty("tax_provider") @ExcludeMissing taxProvider: JsonValue = JsonMissing.of(), - ) : this(taxExempt, taxProvider, mutableMapOf()) + @JsonProperty("automatic_tax_enabled") + @ExcludeMissing + automaticTaxEnabled: JsonField = JsonMissing.of(), + ) : this(taxExempt, taxProvider, automaticTaxEnabled, mutableMapOf()) /** * @throws OrbInvalidDataException if the JSON field has an unexpected type or is @@ -3045,6 +3207,16 @@ private constructor( @ExcludeMissing fun _taxProvider(): JsonValue = taxProvider + /** + * Whether to automatically calculate tax for this customer. When null, inherits from + * account-level setting. When true or false, overrides the account setting. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun automaticTaxEnabled(): Boolean? = + automaticTaxEnabled.getNullable("automatic_tax_enabled") + /** * Returns the raw JSON value of [taxExempt]. * @@ -3055,6 +3227,16 @@ private constructor( @ExcludeMissing fun _taxExempt(): JsonField = taxExempt + /** + * Returns the raw JSON value of [automaticTaxEnabled]. + * + * Unlike [automaticTaxEnabled], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("automatic_tax_enabled") + @ExcludeMissing + fun _automaticTaxEnabled(): JsonField = automaticTaxEnabled + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -3085,11 +3267,13 @@ private constructor( private var taxExempt: JsonField? = null private var taxProvider: JsonValue = JsonValue.from("numeral") + private var automaticTaxEnabled: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() internal fun from(numeral: Numeral) = apply { taxExempt = numeral.taxExempt taxProvider = numeral.taxProvider + automaticTaxEnabled = numeral.automaticTaxEnabled additionalProperties = numeral.additionalProperties.toMutableMap() } @@ -3118,6 +3302,32 @@ private constructor( */ fun taxProvider(taxProvider: JsonValue) = apply { this.taxProvider = taxProvider } + /** + * Whether to automatically calculate tax for this customer. When null, inherits + * from account-level setting. When true or false, overrides the account setting. + */ + fun automaticTaxEnabled(automaticTaxEnabled: Boolean?) = + automaticTaxEnabled(JsonField.ofNullable(automaticTaxEnabled)) + + /** + * Alias for [Builder.automaticTaxEnabled]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun automaticTaxEnabled(automaticTaxEnabled: Boolean) = + automaticTaxEnabled(automaticTaxEnabled as Boolean?) + + /** + * Sets [Builder.automaticTaxEnabled] to an arbitrary JSON value. + * + * You should usually call [Builder.automaticTaxEnabled] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun automaticTaxEnabled(automaticTaxEnabled: JsonField) = apply { + this.automaticTaxEnabled = automaticTaxEnabled + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -3156,6 +3366,7 @@ private constructor( Numeral( checkRequired("taxExempt", taxExempt), taxProvider, + automaticTaxEnabled, additionalProperties.toMutableMap(), ) } @@ -3173,6 +3384,7 @@ private constructor( throw OrbInvalidDataException("'taxProvider' is invalid, received $it") } } + automaticTaxEnabled() validated = true } @@ -3192,7 +3404,8 @@ private constructor( */ internal fun validity(): Int = (if (taxExempt.asKnown() == null) 0 else 1) + - taxProvider.let { if (it == JsonValue.from("numeral")) 1 else 0 } + taxProvider.let { if (it == JsonValue.from("numeral")) 1 else 0 } + + (if (automaticTaxEnabled.asKnown() == null) 0 else 1) override fun equals(other: Any?): Boolean { if (this === other) { @@ -3202,17 +3415,282 @@ private constructor( return other is Numeral && taxExempt == other.taxExempt && taxProvider == other.taxProvider && + automaticTaxEnabled == other.automaticTaxEnabled && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(taxExempt, taxProvider, automaticTaxEnabled, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Numeral{taxExempt=$taxExempt, taxProvider=$taxProvider, automaticTaxEnabled=$automaticTaxEnabled, additionalProperties=$additionalProperties}" + } + + class Anrok + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val taxExempt: JsonField, + private val taxProvider: JsonValue, + private val automaticTaxEnabled: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("tax_exempt") + @ExcludeMissing + taxExempt: JsonField = JsonMissing.of(), + @JsonProperty("tax_provider") + @ExcludeMissing + taxProvider: JsonValue = JsonMissing.of(), + @JsonProperty("automatic_tax_enabled") + @ExcludeMissing + automaticTaxEnabled: JsonField = JsonMissing.of(), + ) : this(taxExempt, taxProvider, automaticTaxEnabled, mutableMapOf()) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun taxExempt(): Boolean = taxExempt.getRequired("tax_exempt") + + /** + * Expected to always return the following: + * ```kotlin + * JsonValue.from("anrok") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("tax_provider") + @ExcludeMissing + fun _taxProvider(): JsonValue = taxProvider + + /** + * Whether to automatically calculate tax for this customer. When null, inherits from + * account-level setting. When true or false, overrides the account setting. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun automaticTaxEnabled(): Boolean? = + automaticTaxEnabled.getNullable("automatic_tax_enabled") + + /** + * Returns the raw JSON value of [taxExempt]. + * + * Unlike [taxExempt], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tax_exempt") + @ExcludeMissing + fun _taxExempt(): JsonField = taxExempt + + /** + * Returns the raw JSON value of [automaticTaxEnabled]. + * + * Unlike [automaticTaxEnabled], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("automatic_tax_enabled") + @ExcludeMissing + fun _automaticTaxEnabled(): JsonField = automaticTaxEnabled + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Anrok]. + * + * The following fields are required: + * ```kotlin + * .taxExempt() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Anrok]. */ + class Builder internal constructor() { + + private var taxExempt: JsonField? = null + private var taxProvider: JsonValue = JsonValue.from("anrok") + private var automaticTaxEnabled: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(anrok: Anrok) = apply { + taxExempt = anrok.taxExempt + taxProvider = anrok.taxProvider + automaticTaxEnabled = anrok.automaticTaxEnabled + additionalProperties = anrok.additionalProperties.toMutableMap() + } + + fun taxExempt(taxExempt: Boolean) = taxExempt(JsonField.of(taxExempt)) + + /** + * Sets [Builder.taxExempt] to an arbitrary JSON value. + * + * You should usually call [Builder.taxExempt] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun taxExempt(taxExempt: JsonField) = apply { this.taxExempt = taxExempt } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```kotlin + * JsonValue.from("anrok") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun taxProvider(taxProvider: JsonValue) = apply { this.taxProvider = taxProvider } + + /** + * Whether to automatically calculate tax for this customer. When null, inherits + * from account-level setting. When true or false, overrides the account setting. + */ + fun automaticTaxEnabled(automaticTaxEnabled: Boolean?) = + automaticTaxEnabled(JsonField.ofNullable(automaticTaxEnabled)) + + /** + * Alias for [Builder.automaticTaxEnabled]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun automaticTaxEnabled(automaticTaxEnabled: Boolean) = + automaticTaxEnabled(automaticTaxEnabled as Boolean?) + + /** + * Sets [Builder.automaticTaxEnabled] to an arbitrary JSON value. + * + * You should usually call [Builder.automaticTaxEnabled] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun automaticTaxEnabled(automaticTaxEnabled: JsonField) = apply { + this.automaticTaxEnabled = automaticTaxEnabled + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Anrok]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .taxExempt() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Anrok = + Anrok( + checkRequired("taxExempt", taxExempt), + taxProvider, + automaticTaxEnabled, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Anrok = apply { + if (validated) { + return@apply + } + + taxExempt() + _taxProvider().let { + if (it != JsonValue.from("anrok")) { + throw OrbInvalidDataException("'taxProvider' is invalid, received $it") + } + } + automaticTaxEnabled() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (taxExempt.asKnown() == null) 0 else 1) + + taxProvider.let { if (it == JsonValue.from("anrok")) 1 else 0 } + + (if (automaticTaxEnabled.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Anrok && + taxExempt == other.taxExempt && + taxProvider == other.taxProvider && + automaticTaxEnabled == other.automaticTaxEnabled && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(taxExempt, taxProvider, additionalProperties) + Objects.hash(taxExempt, taxProvider, automaticTaxEnabled, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "Numeral{taxExempt=$taxExempt, taxProvider=$taxProvider, additionalProperties=$additionalProperties}" + "Anrok{taxExempt=$taxExempt, taxProvider=$taxProvider, automaticTaxEnabled=$automaticTaxEnabled, additionalProperties=$additionalProperties}" } } diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerUpdateParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerUpdateParams.kt index 9030dabd2..9f69eb47c 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerUpdateParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerUpdateParams.kt @@ -85,6 +85,15 @@ private constructor( */ fun autoIssuance(): Boolean? = body.autoIssuance() + /** + * Whether automatic tax calculation is enabled for this customer. When null, inherits from + * account-level setting. When true or false, overrides the account setting. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun automaticTaxEnabled(): Boolean? = body.automaticTaxEnabled() + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server * responded with an unexpected value). @@ -371,6 +380,14 @@ private constructor( */ fun _autoIssuance(): JsonField = body._autoIssuance() + /** + * Returns the raw JSON value of [automaticTaxEnabled]. + * + * Unlike [automaticTaxEnabled], this method doesn't throw if the JSON field has an unexpected + * type. + */ + fun _automaticTaxEnabled(): JsonField = body._automaticTaxEnabled() + /** * Returns the raw JSON value of [billingAddress]. * @@ -518,7 +535,7 @@ private constructor( * - [additionalEmails] * - [autoCollection] * - [autoIssuance] - * - [billingAddress] + * - [automaticTaxEnabled] * - etc. */ fun body(body: Body) = apply { this.body = body.toBuilder() } @@ -618,6 +635,33 @@ private constructor( body.autoIssuance(autoIssuance) } + /** + * Whether automatic tax calculation is enabled for this customer. When null, inherits from + * account-level setting. When true or false, overrides the account setting. + */ + fun automaticTaxEnabled(automaticTaxEnabled: Boolean?) = apply { + body.automaticTaxEnabled(automaticTaxEnabled) + } + + /** + * Alias for [Builder.automaticTaxEnabled]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun automaticTaxEnabled(automaticTaxEnabled: Boolean) = + automaticTaxEnabled(automaticTaxEnabled as Boolean?) + + /** + * Sets [Builder.automaticTaxEnabled] to an arbitrary JSON value. + * + * You should usually call [Builder.automaticTaxEnabled] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun automaticTaxEnabled(automaticTaxEnabled: JsonField) = apply { + body.automaticTaxEnabled(automaticTaxEnabled) + } + fun billingAddress(billingAddress: AddressInput?) = apply { body.billingAddress(billingAddress) } @@ -898,6 +942,21 @@ private constructor( body.numeralTaxConfiguration(taxExempt) } + /** Alias for calling [taxConfiguration] with `TaxConfiguration.ofAnrok(anrok)`. */ + fun taxConfiguration(anrok: TaxConfiguration.Anrok) = apply { body.taxConfiguration(anrok) } + + /** + * Alias for calling [taxConfiguration] with the following: + * ```kotlin + * TaxConfiguration.Anrok.builder() + * .taxExempt(taxExempt) + * .build() + * ``` + */ + fun anrokTaxConfiguration(taxExempt: Boolean) = apply { + body.anrokTaxConfiguration(taxExempt) + } + /** * Tax IDs are commonly required to be displayed on customer invoices, which are added to * the headers of invoices. @@ -1204,6 +1263,7 @@ private constructor( private val additionalEmails: JsonField>, private val autoCollection: JsonField, private val autoIssuance: JsonField, + private val automaticTaxEnabled: JsonField, private val billingAddress: JsonField, private val currency: JsonField, private val email: JsonField, @@ -1236,6 +1296,9 @@ private constructor( @JsonProperty("auto_issuance") @ExcludeMissing autoIssuance: JsonField = JsonMissing.of(), + @JsonProperty("automatic_tax_enabled") + @ExcludeMissing + automaticTaxEnabled: JsonField = JsonMissing.of(), @JsonProperty("billing_address") @ExcludeMissing billingAddress: JsonField = JsonMissing.of(), @@ -1279,6 +1342,7 @@ private constructor( additionalEmails, autoCollection, autoIssuance, + automaticTaxEnabled, billingAddress, currency, email, @@ -1334,6 +1398,16 @@ private constructor( */ fun autoIssuance(): Boolean? = autoIssuance.getNullable("auto_issuance") + /** + * Whether automatic tax calculation is enabled for this customer. When null, inherits from + * account-level setting. When true or false, overrides the account setting. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun automaticTaxEnabled(): Boolean? = + automaticTaxEnabled.getNullable("automatic_tax_enabled") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -1632,6 +1706,16 @@ private constructor( @ExcludeMissing fun _autoIssuance(): JsonField = autoIssuance + /** + * Returns the raw JSON value of [automaticTaxEnabled]. + * + * Unlike [automaticTaxEnabled], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("automatic_tax_enabled") + @ExcludeMissing + fun _automaticTaxEnabled(): JsonField = automaticTaxEnabled + /** * Returns the raw JSON value of [billingAddress]. * @@ -1782,6 +1866,7 @@ private constructor( private var additionalEmails: JsonField>? = null private var autoCollection: JsonField = JsonMissing.of() private var autoIssuance: JsonField = JsonMissing.of() + private var automaticTaxEnabled: JsonField = JsonMissing.of() private var billingAddress: JsonField = JsonMissing.of() private var currency: JsonField = JsonMissing.of() private var email: JsonField = JsonMissing.of() @@ -1804,6 +1889,7 @@ private constructor( additionalEmails = body.additionalEmails.map { it.toMutableList() } autoCollection = body.autoCollection autoIssuance = body.autoIssuance + automaticTaxEnabled = body.automaticTaxEnabled billingAddress = body.billingAddress currency = body.currency email = body.email @@ -1920,6 +2006,32 @@ private constructor( this.autoIssuance = autoIssuance } + /** + * Whether automatic tax calculation is enabled for this customer. When null, inherits + * from account-level setting. When true or false, overrides the account setting. + */ + fun automaticTaxEnabled(automaticTaxEnabled: Boolean?) = + automaticTaxEnabled(JsonField.ofNullable(automaticTaxEnabled)) + + /** + * Alias for [Builder.automaticTaxEnabled]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun automaticTaxEnabled(automaticTaxEnabled: Boolean) = + automaticTaxEnabled(automaticTaxEnabled as Boolean?) + + /** + * Sets [Builder.automaticTaxEnabled] to an arbitrary JSON value. + * + * You should usually call [Builder.automaticTaxEnabled] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun automaticTaxEnabled(automaticTaxEnabled: JsonField) = apply { + this.automaticTaxEnabled = automaticTaxEnabled + } + fun billingAddress(billingAddress: AddressInput?) = billingAddress(JsonField.ofNullable(billingAddress)) @@ -2205,6 +2317,21 @@ private constructor( fun numeralTaxConfiguration(taxExempt: Boolean) = taxConfiguration(TaxConfiguration.Numeral.builder().taxExempt(taxExempt).build()) + /** Alias for calling [taxConfiguration] with `TaxConfiguration.ofAnrok(anrok)`. */ + fun taxConfiguration(anrok: TaxConfiguration.Anrok) = + taxConfiguration(TaxConfiguration.ofAnrok(anrok)) + + /** + * Alias for calling [taxConfiguration] with the following: + * ```kotlin + * TaxConfiguration.Anrok.builder() + * .taxExempt(taxExempt) + * .build() + * ``` + */ + fun anrokTaxConfiguration(taxExempt: Boolean) = + taxConfiguration(TaxConfiguration.Anrok.builder().taxExempt(taxExempt).build()) + /** * Tax IDs are commonly required to be displayed on customer invoices, which are added * to the headers of invoices. @@ -2391,6 +2518,7 @@ private constructor( (additionalEmails ?: JsonMissing.of()).map { it.toImmutable() }, autoCollection, autoIssuance, + automaticTaxEnabled, billingAddress, currency, email, @@ -2420,6 +2548,7 @@ private constructor( additionalEmails() autoCollection() autoIssuance() + automaticTaxEnabled() billingAddress()?.validate() currency() email() @@ -2456,6 +2585,7 @@ private constructor( (additionalEmails.asKnown()?.size ?: 0) + (if (autoCollection.asKnown() == null) 0 else 1) + (if (autoIssuance.asKnown() == null) 0 else 1) + + (if (automaticTaxEnabled.asKnown() == null) 0 else 1) + (billingAddress.asKnown()?.validity() ?: 0) + (if (currency.asKnown() == null) 0 else 1) + (if (email.asKnown() == null) 0 else 1) + @@ -2481,6 +2611,7 @@ private constructor( additionalEmails == other.additionalEmails && autoCollection == other.autoCollection && autoIssuance == other.autoIssuance && + automaticTaxEnabled == other.automaticTaxEnabled && billingAddress == other.billingAddress && currency == other.currency && email == other.email && @@ -2504,6 +2635,7 @@ private constructor( additionalEmails, autoCollection, autoIssuance, + automaticTaxEnabled, billingAddress, currency, email, @@ -2525,7 +2657,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Body{accountingSyncConfiguration=$accountingSyncConfiguration, additionalEmails=$additionalEmails, autoCollection=$autoCollection, autoIssuance=$autoIssuance, billingAddress=$billingAddress, currency=$currency, email=$email, emailDelivery=$emailDelivery, externalCustomerId=$externalCustomerId, hierarchy=$hierarchy, metadata=$metadata, name=$name, paymentProvider=$paymentProvider, paymentProviderId=$paymentProviderId, reportingConfiguration=$reportingConfiguration, shippingAddress=$shippingAddress, taxConfiguration=$taxConfiguration, taxId=$taxId, additionalProperties=$additionalProperties}" + "Body{accountingSyncConfiguration=$accountingSyncConfiguration, additionalEmails=$additionalEmails, autoCollection=$autoCollection, autoIssuance=$autoIssuance, automaticTaxEnabled=$automaticTaxEnabled, billingAddress=$billingAddress, currency=$currency, email=$email, emailDelivery=$emailDelivery, externalCustomerId=$externalCustomerId, hierarchy=$hierarchy, metadata=$metadata, name=$name, paymentProvider=$paymentProvider, paymentProviderId=$paymentProviderId, reportingConfiguration=$reportingConfiguration, shippingAddress=$shippingAddress, taxConfiguration=$taxConfiguration, taxId=$taxId, additionalProperties=$additionalProperties}" } /** @@ -2791,6 +2923,7 @@ private constructor( private val taxjar: NewTaxJarConfiguration? = null, private val sphere: NewSphereConfiguration? = null, private val numeral: Numeral? = null, + private val anrok: Anrok? = null, private val _json: JsonValue? = null, ) { @@ -2802,6 +2935,8 @@ private constructor( fun numeral(): Numeral? = numeral + fun anrok(): Anrok? = anrok + fun isAvalara(): Boolean = avalara != null fun isTaxjar(): Boolean = taxjar != null @@ -2810,6 +2945,8 @@ private constructor( fun isNumeral(): Boolean = numeral != null + fun isAnrok(): Boolean = anrok != null + fun asAvalara(): NewAvalaraTaxConfiguration = avalara.getOrThrow("avalara") fun asTaxjar(): NewTaxJarConfiguration = taxjar.getOrThrow("taxjar") @@ -2818,6 +2955,8 @@ private constructor( fun asNumeral(): Numeral = numeral.getOrThrow("numeral") + fun asAnrok(): Anrok = anrok.getOrThrow("anrok") + fun _json(): JsonValue? = _json fun accept(visitor: Visitor): T = @@ -2826,6 +2965,7 @@ private constructor( taxjar != null -> visitor.visitTaxjar(taxjar) sphere != null -> visitor.visitSphere(sphere) numeral != null -> visitor.visitNumeral(numeral) + anrok != null -> visitor.visitAnrok(anrok) else -> visitor.unknown(_json) } @@ -2853,6 +2993,10 @@ private constructor( override fun visitNumeral(numeral: Numeral) { numeral.validate() } + + override fun visitAnrok(anrok: Anrok) { + anrok.validate() + } } ) validated = true @@ -2884,6 +3028,8 @@ private constructor( override fun visitNumeral(numeral: Numeral) = numeral.validity() + override fun visitAnrok(anrok: Anrok) = anrok.validity() + override fun unknown(json: JsonValue?) = 0 } ) @@ -2897,10 +3043,11 @@ private constructor( avalara == other.avalara && taxjar == other.taxjar && sphere == other.sphere && - numeral == other.numeral + numeral == other.numeral && + anrok == other.anrok } - override fun hashCode(): Int = Objects.hash(avalara, taxjar, sphere, numeral) + override fun hashCode(): Int = Objects.hash(avalara, taxjar, sphere, numeral, anrok) override fun toString(): String = when { @@ -2908,6 +3055,7 @@ private constructor( taxjar != null -> "TaxConfiguration{taxjar=$taxjar}" sphere != null -> "TaxConfiguration{sphere=$sphere}" numeral != null -> "TaxConfiguration{numeral=$numeral}" + anrok != null -> "TaxConfiguration{anrok=$anrok}" _json != null -> "TaxConfiguration{_unknown=$_json}" else -> throw IllegalStateException("Invalid TaxConfiguration") } @@ -2921,6 +3069,8 @@ private constructor( fun ofSphere(sphere: NewSphereConfiguration) = TaxConfiguration(sphere = sphere) fun ofNumeral(numeral: Numeral) = TaxConfiguration(numeral = numeral) + + fun ofAnrok(anrok: Anrok) = TaxConfiguration(anrok = anrok) } /** @@ -2937,6 +3087,8 @@ private constructor( fun visitNumeral(numeral: Numeral): T + fun visitAnrok(anrok: Anrok): T + /** * Maps an unknown variant of [TaxConfiguration] to a value of type [T]. * @@ -2979,6 +3131,11 @@ private constructor( TaxConfiguration(numeral = it, _json = json) } ?: TaxConfiguration(_json = json) } + "anrok" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + TaxConfiguration(anrok = it, _json = json) + } ?: TaxConfiguration(_json = json) + } } return TaxConfiguration(_json = json) @@ -2997,6 +3154,7 @@ private constructor( value.taxjar != null -> generator.writeObject(value.taxjar) value.sphere != null -> generator.writeObject(value.sphere) value.numeral != null -> generator.writeObject(value.numeral) + value.anrok != null -> generator.writeObject(value.anrok) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid TaxConfiguration") } @@ -3008,6 +3166,7 @@ private constructor( private constructor( private val taxExempt: JsonField, private val taxProvider: JsonValue, + private val automaticTaxEnabled: JsonField, private val additionalProperties: MutableMap, ) { @@ -3019,7 +3178,10 @@ private constructor( @JsonProperty("tax_provider") @ExcludeMissing taxProvider: JsonValue = JsonMissing.of(), - ) : this(taxExempt, taxProvider, mutableMapOf()) + @JsonProperty("automatic_tax_enabled") + @ExcludeMissing + automaticTaxEnabled: JsonField = JsonMissing.of(), + ) : this(taxExempt, taxProvider, automaticTaxEnabled, mutableMapOf()) /** * @throws OrbInvalidDataException if the JSON field has an unexpected type or is @@ -3041,6 +3203,16 @@ private constructor( @ExcludeMissing fun _taxProvider(): JsonValue = taxProvider + /** + * Whether to automatically calculate tax for this customer. When null, inherits from + * account-level setting. When true or false, overrides the account setting. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun automaticTaxEnabled(): Boolean? = + automaticTaxEnabled.getNullable("automatic_tax_enabled") + /** * Returns the raw JSON value of [taxExempt]. * @@ -3051,6 +3223,16 @@ private constructor( @ExcludeMissing fun _taxExempt(): JsonField = taxExempt + /** + * Returns the raw JSON value of [automaticTaxEnabled]. + * + * Unlike [automaticTaxEnabled], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("automatic_tax_enabled") + @ExcludeMissing + fun _automaticTaxEnabled(): JsonField = automaticTaxEnabled + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -3081,11 +3263,13 @@ private constructor( private var taxExempt: JsonField? = null private var taxProvider: JsonValue = JsonValue.from("numeral") + private var automaticTaxEnabled: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() internal fun from(numeral: Numeral) = apply { taxExempt = numeral.taxExempt taxProvider = numeral.taxProvider + automaticTaxEnabled = numeral.automaticTaxEnabled additionalProperties = numeral.additionalProperties.toMutableMap() } @@ -3114,6 +3298,32 @@ private constructor( */ fun taxProvider(taxProvider: JsonValue) = apply { this.taxProvider = taxProvider } + /** + * Whether to automatically calculate tax for this customer. When null, inherits + * from account-level setting. When true or false, overrides the account setting. + */ + fun automaticTaxEnabled(automaticTaxEnabled: Boolean?) = + automaticTaxEnabled(JsonField.ofNullable(automaticTaxEnabled)) + + /** + * Alias for [Builder.automaticTaxEnabled]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun automaticTaxEnabled(automaticTaxEnabled: Boolean) = + automaticTaxEnabled(automaticTaxEnabled as Boolean?) + + /** + * Sets [Builder.automaticTaxEnabled] to an arbitrary JSON value. + * + * You should usually call [Builder.automaticTaxEnabled] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun automaticTaxEnabled(automaticTaxEnabled: JsonField) = apply { + this.automaticTaxEnabled = automaticTaxEnabled + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -3152,6 +3362,7 @@ private constructor( Numeral( checkRequired("taxExempt", taxExempt), taxProvider, + automaticTaxEnabled, additionalProperties.toMutableMap(), ) } @@ -3169,6 +3380,7 @@ private constructor( throw OrbInvalidDataException("'taxProvider' is invalid, received $it") } } + automaticTaxEnabled() validated = true } @@ -3188,7 +3400,8 @@ private constructor( */ internal fun validity(): Int = (if (taxExempt.asKnown() == null) 0 else 1) + - taxProvider.let { if (it == JsonValue.from("numeral")) 1 else 0 } + taxProvider.let { if (it == JsonValue.from("numeral")) 1 else 0 } + + (if (automaticTaxEnabled.asKnown() == null) 0 else 1) override fun equals(other: Any?): Boolean { if (this === other) { @@ -3198,17 +3411,282 @@ private constructor( return other is Numeral && taxExempt == other.taxExempt && taxProvider == other.taxProvider && + automaticTaxEnabled == other.automaticTaxEnabled && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(taxExempt, taxProvider, automaticTaxEnabled, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Numeral{taxExempt=$taxExempt, taxProvider=$taxProvider, automaticTaxEnabled=$automaticTaxEnabled, additionalProperties=$additionalProperties}" + } + + class Anrok + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val taxExempt: JsonField, + private val taxProvider: JsonValue, + private val automaticTaxEnabled: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("tax_exempt") + @ExcludeMissing + taxExempt: JsonField = JsonMissing.of(), + @JsonProperty("tax_provider") + @ExcludeMissing + taxProvider: JsonValue = JsonMissing.of(), + @JsonProperty("automatic_tax_enabled") + @ExcludeMissing + automaticTaxEnabled: JsonField = JsonMissing.of(), + ) : this(taxExempt, taxProvider, automaticTaxEnabled, mutableMapOf()) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun taxExempt(): Boolean = taxExempt.getRequired("tax_exempt") + + /** + * Expected to always return the following: + * ```kotlin + * JsonValue.from("anrok") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("tax_provider") + @ExcludeMissing + fun _taxProvider(): JsonValue = taxProvider + + /** + * Whether to automatically calculate tax for this customer. When null, inherits from + * account-level setting. When true or false, overrides the account setting. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun automaticTaxEnabled(): Boolean? = + automaticTaxEnabled.getNullable("automatic_tax_enabled") + + /** + * Returns the raw JSON value of [taxExempt]. + * + * Unlike [taxExempt], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tax_exempt") + @ExcludeMissing + fun _taxExempt(): JsonField = taxExempt + + /** + * Returns the raw JSON value of [automaticTaxEnabled]. + * + * Unlike [automaticTaxEnabled], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("automatic_tax_enabled") + @ExcludeMissing + fun _automaticTaxEnabled(): JsonField = automaticTaxEnabled + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Anrok]. + * + * The following fields are required: + * ```kotlin + * .taxExempt() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Anrok]. */ + class Builder internal constructor() { + + private var taxExempt: JsonField? = null + private var taxProvider: JsonValue = JsonValue.from("anrok") + private var automaticTaxEnabled: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(anrok: Anrok) = apply { + taxExempt = anrok.taxExempt + taxProvider = anrok.taxProvider + automaticTaxEnabled = anrok.automaticTaxEnabled + additionalProperties = anrok.additionalProperties.toMutableMap() + } + + fun taxExempt(taxExempt: Boolean) = taxExempt(JsonField.of(taxExempt)) + + /** + * Sets [Builder.taxExempt] to an arbitrary JSON value. + * + * You should usually call [Builder.taxExempt] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun taxExempt(taxExempt: JsonField) = apply { this.taxExempt = taxExempt } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```kotlin + * JsonValue.from("anrok") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun taxProvider(taxProvider: JsonValue) = apply { this.taxProvider = taxProvider } + + /** + * Whether to automatically calculate tax for this customer. When null, inherits + * from account-level setting. When true or false, overrides the account setting. + */ + fun automaticTaxEnabled(automaticTaxEnabled: Boolean?) = + automaticTaxEnabled(JsonField.ofNullable(automaticTaxEnabled)) + + /** + * Alias for [Builder.automaticTaxEnabled]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun automaticTaxEnabled(automaticTaxEnabled: Boolean) = + automaticTaxEnabled(automaticTaxEnabled as Boolean?) + + /** + * Sets [Builder.automaticTaxEnabled] to an arbitrary JSON value. + * + * You should usually call [Builder.automaticTaxEnabled] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun automaticTaxEnabled(automaticTaxEnabled: JsonField) = apply { + this.automaticTaxEnabled = automaticTaxEnabled + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Anrok]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .taxExempt() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Anrok = + Anrok( + checkRequired("taxExempt", taxExempt), + taxProvider, + automaticTaxEnabled, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Anrok = apply { + if (validated) { + return@apply + } + + taxExempt() + _taxProvider().let { + if (it != JsonValue.from("anrok")) { + throw OrbInvalidDataException("'taxProvider' is invalid, received $it") + } + } + automaticTaxEnabled() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (taxExempt.asKnown() == null) 0 else 1) + + taxProvider.let { if (it == JsonValue.from("anrok")) 1 else 0 } + + (if (automaticTaxEnabled.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Anrok && + taxExempt == other.taxExempt && + taxProvider == other.taxProvider && + automaticTaxEnabled == other.automaticTaxEnabled && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(taxExempt, taxProvider, additionalProperties) + Objects.hash(taxExempt, taxProvider, automaticTaxEnabled, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "Numeral{taxExempt=$taxExempt, taxProvider=$taxProvider, additionalProperties=$additionalProperties}" + "Anrok{taxExempt=$taxExempt, taxProvider=$taxProvider, automaticTaxEnabled=$automaticTaxEnabled, additionalProperties=$additionalProperties}" } } diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewAvalaraTaxConfiguration.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewAvalaraTaxConfiguration.kt index 709d9b883..0397c6ff6 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewAvalaraTaxConfiguration.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewAvalaraTaxConfiguration.kt @@ -21,6 +21,7 @@ class NewAvalaraTaxConfiguration private constructor( private val taxExempt: JsonField, private val taxProvider: JsonField, + private val automaticTaxEnabled: JsonField, private val taxExemptionCode: JsonField, private val additionalProperties: MutableMap, ) { @@ -33,10 +34,13 @@ private constructor( @JsonProperty("tax_provider") @ExcludeMissing taxProvider: JsonField = JsonMissing.of(), + @JsonProperty("automatic_tax_enabled") + @ExcludeMissing + automaticTaxEnabled: JsonField = JsonMissing.of(), @JsonProperty("tax_exemption_code") @ExcludeMissing taxExemptionCode: JsonField = JsonMissing.of(), - ) : this(taxExempt, taxProvider, taxExemptionCode, mutableMapOf()) + ) : this(taxExempt, taxProvider, automaticTaxEnabled, taxExemptionCode, mutableMapOf()) /** * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly @@ -50,6 +54,15 @@ private constructor( */ fun taxProvider(): TaxProvider = taxProvider.getRequired("tax_provider") + /** + * Whether to automatically calculate tax for this customer. When null, inherits from + * account-level setting. When true or false, overrides the account setting. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun automaticTaxEnabled(): Boolean? = automaticTaxEnabled.getNullable("automatic_tax_enabled") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server * responded with an unexpected value). @@ -72,6 +85,16 @@ private constructor( @ExcludeMissing fun _taxProvider(): JsonField = taxProvider + /** + * Returns the raw JSON value of [automaticTaxEnabled]. + * + * Unlike [automaticTaxEnabled], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("automatic_tax_enabled") + @ExcludeMissing + fun _automaticTaxEnabled(): JsonField = automaticTaxEnabled + /** * Returns the raw JSON value of [taxExemptionCode]. * @@ -113,12 +136,14 @@ private constructor( private var taxExempt: JsonField? = null private var taxProvider: JsonField? = null + private var automaticTaxEnabled: JsonField = JsonMissing.of() private var taxExemptionCode: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() internal fun from(newAvalaraTaxConfiguration: NewAvalaraTaxConfiguration) = apply { taxExempt = newAvalaraTaxConfiguration.taxExempt taxProvider = newAvalaraTaxConfiguration.taxProvider + automaticTaxEnabled = newAvalaraTaxConfiguration.automaticTaxEnabled taxExemptionCode = newAvalaraTaxConfiguration.taxExemptionCode additionalProperties = newAvalaraTaxConfiguration.additionalProperties.toMutableMap() } @@ -147,6 +172,32 @@ private constructor( this.taxProvider = taxProvider } + /** + * Whether to automatically calculate tax for this customer. When null, inherits from + * account-level setting. When true or false, overrides the account setting. + */ + fun automaticTaxEnabled(automaticTaxEnabled: Boolean?) = + automaticTaxEnabled(JsonField.ofNullable(automaticTaxEnabled)) + + /** + * Alias for [Builder.automaticTaxEnabled]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun automaticTaxEnabled(automaticTaxEnabled: Boolean) = + automaticTaxEnabled(automaticTaxEnabled as Boolean?) + + /** + * Sets [Builder.automaticTaxEnabled] to an arbitrary JSON value. + * + * You should usually call [Builder.automaticTaxEnabled] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun automaticTaxEnabled(automaticTaxEnabled: JsonField) = apply { + this.automaticTaxEnabled = automaticTaxEnabled + } + fun taxExemptionCode(taxExemptionCode: String?) = taxExemptionCode(JsonField.ofNullable(taxExemptionCode)) @@ -197,6 +248,7 @@ private constructor( NewAvalaraTaxConfiguration( checkRequired("taxExempt", taxExempt), checkRequired("taxProvider", taxProvider), + automaticTaxEnabled, taxExemptionCode, additionalProperties.toMutableMap(), ) @@ -211,6 +263,7 @@ private constructor( taxExempt() taxProvider().validate() + automaticTaxEnabled() taxExemptionCode() validated = true } @@ -231,6 +284,7 @@ private constructor( internal fun validity(): Int = (if (taxExempt.asKnown() == null) 0 else 1) + (taxProvider.asKnown()?.validity() ?: 0) + + (if (automaticTaxEnabled.asKnown() == null) 0 else 1) + (if (taxExemptionCode.asKnown() == null) 0 else 1) class TaxProvider @JsonCreator private constructor(private val value: JsonField) : @@ -362,16 +416,23 @@ private constructor( return other is NewAvalaraTaxConfiguration && taxExempt == other.taxExempt && taxProvider == other.taxProvider && + automaticTaxEnabled == other.automaticTaxEnabled && taxExemptionCode == other.taxExemptionCode && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(taxExempt, taxProvider, taxExemptionCode, additionalProperties) + Objects.hash( + taxExempt, + taxProvider, + automaticTaxEnabled, + taxExemptionCode, + additionalProperties, + ) } override fun hashCode(): Int = hashCode override fun toString() = - "NewAvalaraTaxConfiguration{taxExempt=$taxExempt, taxProvider=$taxProvider, taxExemptionCode=$taxExemptionCode, additionalProperties=$additionalProperties}" + "NewAvalaraTaxConfiguration{taxExempt=$taxExempt, taxProvider=$taxProvider, automaticTaxEnabled=$automaticTaxEnabled, taxExemptionCode=$taxExemptionCode, additionalProperties=$additionalProperties}" } diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSphereConfiguration.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSphereConfiguration.kt index 15865457e..deedc3f48 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSphereConfiguration.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSphereConfiguration.kt @@ -21,6 +21,7 @@ class NewSphereConfiguration private constructor( private val taxExempt: JsonField, private val taxProvider: JsonField, + private val automaticTaxEnabled: JsonField, private val additionalProperties: MutableMap, ) { @@ -32,7 +33,10 @@ private constructor( @JsonProperty("tax_provider") @ExcludeMissing taxProvider: JsonField = JsonMissing.of(), - ) : this(taxExempt, taxProvider, mutableMapOf()) + @JsonProperty("automatic_tax_enabled") + @ExcludeMissing + automaticTaxEnabled: JsonField = JsonMissing.of(), + ) : this(taxExempt, taxProvider, automaticTaxEnabled, mutableMapOf()) /** * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly @@ -46,6 +50,15 @@ private constructor( */ fun taxProvider(): TaxProvider = taxProvider.getRequired("tax_provider") + /** + * Whether to automatically calculate tax for this customer. When null, inherits from + * account-level setting. When true or false, overrides the account setting. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun automaticTaxEnabled(): Boolean? = automaticTaxEnabled.getNullable("automatic_tax_enabled") + /** * Returns the raw JSON value of [taxExempt]. * @@ -62,6 +75,16 @@ private constructor( @ExcludeMissing fun _taxProvider(): JsonField = taxProvider + /** + * Returns the raw JSON value of [automaticTaxEnabled]. + * + * Unlike [automaticTaxEnabled], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("automatic_tax_enabled") + @ExcludeMissing + fun _automaticTaxEnabled(): JsonField = automaticTaxEnabled + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -93,11 +116,13 @@ private constructor( private var taxExempt: JsonField? = null private var taxProvider: JsonField? = null + private var automaticTaxEnabled: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() internal fun from(newSphereConfiguration: NewSphereConfiguration) = apply { taxExempt = newSphereConfiguration.taxExempt taxProvider = newSphereConfiguration.taxProvider + automaticTaxEnabled = newSphereConfiguration.automaticTaxEnabled additionalProperties = newSphereConfiguration.additionalProperties.toMutableMap() } @@ -125,6 +150,32 @@ private constructor( this.taxProvider = taxProvider } + /** + * Whether to automatically calculate tax for this customer. When null, inherits from + * account-level setting. When true or false, overrides the account setting. + */ + fun automaticTaxEnabled(automaticTaxEnabled: Boolean?) = + automaticTaxEnabled(JsonField.ofNullable(automaticTaxEnabled)) + + /** + * Alias for [Builder.automaticTaxEnabled]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun automaticTaxEnabled(automaticTaxEnabled: Boolean) = + automaticTaxEnabled(automaticTaxEnabled as Boolean?) + + /** + * Sets [Builder.automaticTaxEnabled] to an arbitrary JSON value. + * + * You should usually call [Builder.automaticTaxEnabled] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun automaticTaxEnabled(automaticTaxEnabled: JsonField) = apply { + this.automaticTaxEnabled = automaticTaxEnabled + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -161,6 +212,7 @@ private constructor( NewSphereConfiguration( checkRequired("taxExempt", taxExempt), checkRequired("taxProvider", taxProvider), + automaticTaxEnabled, additionalProperties.toMutableMap(), ) } @@ -174,6 +226,7 @@ private constructor( taxExempt() taxProvider().validate() + automaticTaxEnabled() validated = true } @@ -191,7 +244,9 @@ private constructor( * Used for best match union deserialization. */ internal fun validity(): Int = - (if (taxExempt.asKnown() == null) 0 else 1) + (taxProvider.asKnown()?.validity() ?: 0) + (if (taxExempt.asKnown() == null) 0 else 1) + + (taxProvider.asKnown()?.validity() ?: 0) + + (if (automaticTaxEnabled.asKnown() == null) 0 else 1) class TaxProvider @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -322,13 +377,16 @@ private constructor( return other is NewSphereConfiguration && taxExempt == other.taxExempt && taxProvider == other.taxProvider && + automaticTaxEnabled == other.automaticTaxEnabled && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(taxExempt, taxProvider, additionalProperties) } + private val hashCode: Int by lazy { + Objects.hash(taxExempt, taxProvider, automaticTaxEnabled, additionalProperties) + } override fun hashCode(): Int = hashCode override fun toString() = - "NewSphereConfiguration{taxExempt=$taxExempt, taxProvider=$taxProvider, additionalProperties=$additionalProperties}" + "NewSphereConfiguration{taxExempt=$taxExempt, taxProvider=$taxProvider, automaticTaxEnabled=$automaticTaxEnabled, additionalProperties=$additionalProperties}" } diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewTaxJarConfiguration.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewTaxJarConfiguration.kt index fd91ad0bc..ca782cabd 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewTaxJarConfiguration.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewTaxJarConfiguration.kt @@ -21,6 +21,7 @@ class NewTaxJarConfiguration private constructor( private val taxExempt: JsonField, private val taxProvider: JsonField, + private val automaticTaxEnabled: JsonField, private val additionalProperties: MutableMap, ) { @@ -32,7 +33,10 @@ private constructor( @JsonProperty("tax_provider") @ExcludeMissing taxProvider: JsonField = JsonMissing.of(), - ) : this(taxExempt, taxProvider, mutableMapOf()) + @JsonProperty("automatic_tax_enabled") + @ExcludeMissing + automaticTaxEnabled: JsonField = JsonMissing.of(), + ) : this(taxExempt, taxProvider, automaticTaxEnabled, mutableMapOf()) /** * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly @@ -46,6 +50,15 @@ private constructor( */ fun taxProvider(): TaxProvider = taxProvider.getRequired("tax_provider") + /** + * Whether to automatically calculate tax for this customer. When null, inherits from + * account-level setting. When true or false, overrides the account setting. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun automaticTaxEnabled(): Boolean? = automaticTaxEnabled.getNullable("automatic_tax_enabled") + /** * Returns the raw JSON value of [taxExempt]. * @@ -62,6 +75,16 @@ private constructor( @ExcludeMissing fun _taxProvider(): JsonField = taxProvider + /** + * Returns the raw JSON value of [automaticTaxEnabled]. + * + * Unlike [automaticTaxEnabled], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("automatic_tax_enabled") + @ExcludeMissing + fun _automaticTaxEnabled(): JsonField = automaticTaxEnabled + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -93,11 +116,13 @@ private constructor( private var taxExempt: JsonField? = null private var taxProvider: JsonField? = null + private var automaticTaxEnabled: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() internal fun from(newTaxJarConfiguration: NewTaxJarConfiguration) = apply { taxExempt = newTaxJarConfiguration.taxExempt taxProvider = newTaxJarConfiguration.taxProvider + automaticTaxEnabled = newTaxJarConfiguration.automaticTaxEnabled additionalProperties = newTaxJarConfiguration.additionalProperties.toMutableMap() } @@ -125,6 +150,32 @@ private constructor( this.taxProvider = taxProvider } + /** + * Whether to automatically calculate tax for this customer. When null, inherits from + * account-level setting. When true or false, overrides the account setting. + */ + fun automaticTaxEnabled(automaticTaxEnabled: Boolean?) = + automaticTaxEnabled(JsonField.ofNullable(automaticTaxEnabled)) + + /** + * Alias for [Builder.automaticTaxEnabled]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun automaticTaxEnabled(automaticTaxEnabled: Boolean) = + automaticTaxEnabled(automaticTaxEnabled as Boolean?) + + /** + * Sets [Builder.automaticTaxEnabled] to an arbitrary JSON value. + * + * You should usually call [Builder.automaticTaxEnabled] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun automaticTaxEnabled(automaticTaxEnabled: JsonField) = apply { + this.automaticTaxEnabled = automaticTaxEnabled + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -161,6 +212,7 @@ private constructor( NewTaxJarConfiguration( checkRequired("taxExempt", taxExempt), checkRequired("taxProvider", taxProvider), + automaticTaxEnabled, additionalProperties.toMutableMap(), ) } @@ -174,6 +226,7 @@ private constructor( taxExempt() taxProvider().validate() + automaticTaxEnabled() validated = true } @@ -191,7 +244,9 @@ private constructor( * Used for best match union deserialization. */ internal fun validity(): Int = - (if (taxExempt.asKnown() == null) 0 else 1) + (taxProvider.asKnown()?.validity() ?: 0) + (if (taxExempt.asKnown() == null) 0 else 1) + + (taxProvider.asKnown()?.validity() ?: 0) + + (if (automaticTaxEnabled.asKnown() == null) 0 else 1) class TaxProvider @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -322,13 +377,16 @@ private constructor( return other is NewTaxJarConfiguration && taxExempt == other.taxExempt && taxProvider == other.taxProvider && + automaticTaxEnabled == other.automaticTaxEnabled && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(taxExempt, taxProvider, additionalProperties) } + private val hashCode: Int by lazy { + Objects.hash(taxExempt, taxProvider, automaticTaxEnabled, additionalProperties) + } override fun hashCode(): Int = hashCode override fun toString() = - "NewTaxJarConfiguration{taxExempt=$taxExempt, taxProvider=$taxProvider, additionalProperties=$additionalProperties}" + "NewTaxJarConfiguration{taxExempt=$taxExempt, taxProvider=$taxProvider, automaticTaxEnabled=$automaticTaxEnabled, additionalProperties=$additionalProperties}" } diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/AffectedBlockTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/AffectedBlockTest.kt index 3299fbed0..72ea64455 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/AffectedBlockTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/AffectedBlockTest.kt @@ -15,28 +15,28 @@ internal class AffectedBlockTest { val affectedBlock = AffectedBlock.builder() .id("id") - .addBlockFilter( - AffectedBlock.BlockFilter.builder() - .field(AffectedBlock.BlockFilter.Field.PRICE_ID) - .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addFilter( + AffectedBlock.Filter.builder() + .field(AffectedBlock.Filter.Field.PRICE_ID) + .operator(AffectedBlock.Filter.Operator.INCLUDES) .addValue("string") .build() ) - .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() assertThat(affectedBlock.id()).isEqualTo("id") - assertThat(affectedBlock.blockFilters()) + assertThat(affectedBlock.expiryDate()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(affectedBlock.filters()) .containsExactly( - AffectedBlock.BlockFilter.builder() - .field(AffectedBlock.BlockFilter.Field.PRICE_ID) - .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + AffectedBlock.Filter.builder() + .field(AffectedBlock.Filter.Field.PRICE_ID) + .operator(AffectedBlock.Filter.Operator.INCLUDES) .addValue("string") .build() ) - assertThat(affectedBlock.expiryDate()) - .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) assertThat(affectedBlock.perUnitCostBasis()).isEqualTo("per_unit_cost_basis") } @@ -46,14 +46,14 @@ internal class AffectedBlockTest { val affectedBlock = AffectedBlock.builder() .id("id") - .addBlockFilter( - AffectedBlock.BlockFilter.builder() - .field(AffectedBlock.BlockFilter.Field.PRICE_ID) - .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addFilter( + AffectedBlock.Filter.builder() + .field(AffectedBlock.Filter.Field.PRICE_ID) + .operator(AffectedBlock.Filter.Operator.INCLUDES) .addValue("string") .build() ) - .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/AggregatedCostTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/AggregatedCostTest.kt index 6d18a70c1..01f2674e2 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/AggregatedCostTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/AggregatedCostTest.kt @@ -53,6 +53,13 @@ internal class AggregatedCostTest { .durationUnit(CustomExpiration.DurationUnit.DAY) .build() ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator(Allocation.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .currency("currency") @@ -178,6 +185,13 @@ internal class AggregatedCostTest { .durationUnit(CustomExpiration.DurationUnit.DAY) .build() ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator(Allocation.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .currency("currency") @@ -309,6 +323,13 @@ internal class AggregatedCostTest { .durationUnit(CustomExpiration.DurationUnit.DAY) .build() ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator(Allocation.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .currency("currency") diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/AllocationTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/AllocationTest.kt index cdfd4fd9f..4af9f1f77 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/AllocationTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/AllocationTest.kt @@ -21,6 +21,13 @@ internal class AllocationTest { .durationUnit(CustomExpiration.DurationUnit.DAY) .build() ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator(Allocation.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() assertThat(allocation.allowsRollover()).isEqualTo(true) @@ -32,6 +39,14 @@ internal class AllocationTest { .durationUnit(CustomExpiration.DurationUnit.DAY) .build() ) + assertThat(allocation.filters()) + .containsExactly( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator(Allocation.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) } @Test @@ -47,6 +62,13 @@ internal class AllocationTest { .durationUnit(CustomExpiration.DurationUnit.DAY) .build() ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator(Allocation.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() val roundtrippedAllocation = diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/AmendmentLedgerEntryTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/AmendmentLedgerEntryTest.kt index 021be10d6..bc610d8e2 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/AmendmentLedgerEntryTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/AmendmentLedgerEntryTest.kt @@ -21,14 +21,14 @@ internal class AmendmentLedgerEntryTest { .creditBlock( AffectedBlock.builder() .id("id") - .addBlockFilter( - AffectedBlock.BlockFilter.builder() - .field(AffectedBlock.BlockFilter.Field.PRICE_ID) - .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addFilter( + AffectedBlock.Filter.builder() + .field(AffectedBlock.Filter.Field.PRICE_ID) + .operator(AffectedBlock.Filter.Operator.INCLUDES) .addValue("string") .build() ) - .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -60,14 +60,14 @@ internal class AmendmentLedgerEntryTest { .isEqualTo( AffectedBlock.builder() .id("id") - .addBlockFilter( - AffectedBlock.BlockFilter.builder() - .field(AffectedBlock.BlockFilter.Field.PRICE_ID) - .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addFilter( + AffectedBlock.Filter.builder() + .field(AffectedBlock.Filter.Field.PRICE_ID) + .operator(AffectedBlock.Filter.Operator.INCLUDES) .addValue("string") .build() ) - .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -106,14 +106,14 @@ internal class AmendmentLedgerEntryTest { .creditBlock( AffectedBlock.builder() .id("id") - .addBlockFilter( - AffectedBlock.BlockFilter.builder() - .field(AffectedBlock.BlockFilter.Field.PRICE_ID) - .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addFilter( + AffectedBlock.Filter.builder() + .field(AffectedBlock.Filter.Field.PRICE_ID) + .operator(AffectedBlock.Filter.Operator.INCLUDES) .addValue("string") .build() ) - .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() ) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/ChangedSubscriptionResourcesTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/ChangedSubscriptionResourcesTest.kt index 4e461862c..8e615b244 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/ChangedSubscriptionResourcesTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/ChangedSubscriptionResourcesTest.kt @@ -339,6 +339,15 @@ internal class ChangedSubscriptionResourcesTest { ) .build() ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator( + Allocation.Filter.Operator.INCLUDES + ) + .addValue("string") + .build() + ) .build() ) .currency("currency") @@ -848,6 +857,15 @@ internal class ChangedSubscriptionResourcesTest { ) .build() ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator( + Allocation.Filter.Operator.INCLUDES + ) + .addValue("string") + .build() + ) .build() ) .currency("currency") @@ -1356,6 +1374,13 @@ internal class ChangedSubscriptionResourcesTest { .durationUnit(CustomExpiration.DurationUnit.DAY) .build() ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator(Allocation.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .currency("currency") @@ -1844,6 +1869,13 @@ internal class ChangedSubscriptionResourcesTest { .durationUnit(CustomExpiration.DurationUnit.DAY) .build() ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator(Allocation.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .currency("currency") @@ -2360,6 +2392,15 @@ internal class ChangedSubscriptionResourcesTest { ) .build() ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator( + Allocation.Filter.Operator.INCLUDES + ) + .addValue("string") + .build() + ) .build() ) .currency("currency") @@ -2869,6 +2910,15 @@ internal class ChangedSubscriptionResourcesTest { ) .build() ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator( + Allocation.Filter.Operator.INCLUDES + ) + .addValue("string") + .build() + ) .build() ) .currency("currency") diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CreditBlockExpiryLedgerEntryTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CreditBlockExpiryLedgerEntryTest.kt index 6518d1403..4a015a24f 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CreditBlockExpiryLedgerEntryTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CreditBlockExpiryLedgerEntryTest.kt @@ -21,14 +21,14 @@ internal class CreditBlockExpiryLedgerEntryTest { .creditBlock( AffectedBlock.builder() .id("id") - .addBlockFilter( - AffectedBlock.BlockFilter.builder() - .field(AffectedBlock.BlockFilter.Field.PRICE_ID) - .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addFilter( + AffectedBlock.Filter.builder() + .field(AffectedBlock.Filter.Field.PRICE_ID) + .operator(AffectedBlock.Filter.Operator.INCLUDES) .addValue("string") .build() ) - .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -60,14 +60,14 @@ internal class CreditBlockExpiryLedgerEntryTest { .isEqualTo( AffectedBlock.builder() .id("id") - .addBlockFilter( - AffectedBlock.BlockFilter.builder() - .field(AffectedBlock.BlockFilter.Field.PRICE_ID) - .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addFilter( + AffectedBlock.Filter.builder() + .field(AffectedBlock.Filter.Field.PRICE_ID) + .operator(AffectedBlock.Filter.Operator.INCLUDES) .addValue("string") .build() ) - .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -106,14 +106,14 @@ internal class CreditBlockExpiryLedgerEntryTest { .creditBlock( AffectedBlock.builder() .id("id") - .addBlockFilter( - AffectedBlock.BlockFilter.builder() - .field(AffectedBlock.BlockFilter.Field.PRICE_ID) - .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addFilter( + AffectedBlock.Filter.builder() + .field(AffectedBlock.Filter.Field.PRICE_ID) + .operator(AffectedBlock.Filter.Operator.INCLUDES) .addValue("string") .build() ) - .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() ) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCostListByExternalIdResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCostListByExternalIdResponseTest.kt index cfc4a85c5..dabd954a2 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCostListByExternalIdResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCostListByExternalIdResponseTest.kt @@ -66,6 +66,15 @@ internal class CustomerCostListByExternalIdResponseTest { ) .build() ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator( + Allocation.Filter.Operator.INCLUDES + ) + .addValue("string") + .build() + ) .build() ) .currency("currency") @@ -215,6 +224,13 @@ internal class CustomerCostListByExternalIdResponseTest { .durationUnit(CustomExpiration.DurationUnit.DAY) .build() ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator(Allocation.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .currency("currency") @@ -367,6 +383,15 @@ internal class CustomerCostListByExternalIdResponseTest { ) .build() ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator( + Allocation.Filter.Operator.INCLUDES + ) + .addValue("string") + .build() + ) .build() ) .currency("currency") diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCostListResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCostListResponseTest.kt index 515ae5de8..2e50ce013 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCostListResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCostListResponseTest.kt @@ -66,6 +66,15 @@ internal class CustomerCostListResponseTest { ) .build() ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator( + Allocation.Filter.Operator.INCLUDES + ) + .addValue("string") + .build() + ) .build() ) .currency("currency") @@ -215,6 +224,13 @@ internal class CustomerCostListResponseTest { .durationUnit(CustomExpiration.DurationUnit.DAY) .build() ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator(Allocation.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .currency("currency") @@ -367,6 +383,15 @@ internal class CustomerCostListResponseTest { ) .build() ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator( + Allocation.Filter.Operator.INCLUDES + ) + .addValue("string") + .build() + ) .build() ) .currency("currency") diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreateParamsTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreateParamsTest.kt index 21299ff7e..8ec9d01ab 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreateParamsTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreateParamsTest.kt @@ -68,6 +68,7 @@ internal class CustomerCreateParamsTest { NewAvalaraTaxConfiguration.builder() .taxExempt(true) .taxProvider(NewAvalaraTaxConfiguration.TaxProvider.AVALARA) + .automaticTaxEnabled(true) .taxExemptionCode("tax_exemption_code") .build() ) @@ -143,6 +144,7 @@ internal class CustomerCreateParamsTest { NewAvalaraTaxConfiguration.builder() .taxExempt(true) .taxProvider(NewAvalaraTaxConfiguration.TaxProvider.AVALARA) + .automaticTaxEnabled(true) .taxExemptionCode("tax_exemption_code") .build() ) @@ -224,6 +226,7 @@ internal class CustomerCreateParamsTest { NewAvalaraTaxConfiguration.builder() .taxExempt(true) .taxProvider(NewAvalaraTaxConfiguration.TaxProvider.AVALARA) + .automaticTaxEnabled(true) .taxExemptionCode("tax_exemption_code") .build() ) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdResponseTest.kt index 2aa483067..c2dc22055 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdResponseTest.kt @@ -25,14 +25,14 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdResponseTest { .creditBlock( AffectedBlock.builder() .id("id") - .addBlockFilter( - AffectedBlock.BlockFilter.builder() - .field(AffectedBlock.BlockFilter.Field.PRICE_ID) - .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addFilter( + AffectedBlock.Filter.builder() + .field(AffectedBlock.Filter.Field.PRICE_ID) + .operator(AffectedBlock.Filter.Operator.INCLUDES) .addValue("string") .build() ) - .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -280,6 +280,15 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdResponseTest { ) .build() ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator( + Allocation.Filter.Operator.INCLUDES + ) + .addValue("string") + .build() + ) .build() ) .currency("currency") @@ -500,14 +509,14 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdResponseTest { .creditBlock( AffectedBlock.builder() .id("id") - .addBlockFilter( - AffectedBlock.BlockFilter.builder() - .field(AffectedBlock.BlockFilter.Field.PRICE_ID) - .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addFilter( + AffectedBlock.Filter.builder() + .field(AffectedBlock.Filter.Field.PRICE_ID) + .operator(AffectedBlock.Filter.Operator.INCLUDES) .addValue("string") .build() ) - .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -761,6 +770,15 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdResponseTest { ) .build() ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator( + Allocation.Filter.Operator.INCLUDES + ) + .addValue("string") + .build() + ) .build() ) .currency("currency") @@ -986,14 +1004,14 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdResponseTest { .creditBlock( AffectedBlock.builder() .id("id") - .addBlockFilter( - AffectedBlock.BlockFilter.builder() - .field(AffectedBlock.BlockFilter.Field.PRICE_ID) - .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addFilter( + AffectedBlock.Filter.builder() + .field(AffectedBlock.Filter.Field.PRICE_ID) + .operator(AffectedBlock.Filter.Operator.INCLUDES) .addValue("string") .build() ) - .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -1045,14 +1063,14 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdResponseTest { .creditBlock( AffectedBlock.builder() .id("id") - .addBlockFilter( - AffectedBlock.BlockFilter.builder() - .field(AffectedBlock.BlockFilter.Field.PRICE_ID) - .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addFilter( + AffectedBlock.Filter.builder() + .field(AffectedBlock.Filter.Field.PRICE_ID) + .operator(AffectedBlock.Filter.Operator.INCLUDES) .addValue("string") .build() ) - .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -1100,14 +1118,14 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdResponseTest { .creditBlock( AffectedBlock.builder() .id("id") - .addBlockFilter( - AffectedBlock.BlockFilter.builder() - .field(AffectedBlock.BlockFilter.Field.PRICE_ID) - .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addFilter( + AffectedBlock.Filter.builder() + .field(AffectedBlock.Filter.Field.PRICE_ID) + .operator(AffectedBlock.Filter.Operator.INCLUDES) .addValue("string") .build() ) - .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -1157,14 +1175,14 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdResponseTest { .creditBlock( AffectedBlock.builder() .id("id") - .addBlockFilter( - AffectedBlock.BlockFilter.builder() - .field(AffectedBlock.BlockFilter.Field.PRICE_ID) - .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addFilter( + AffectedBlock.Filter.builder() + .field(AffectedBlock.Filter.Field.PRICE_ID) + .operator(AffectedBlock.Filter.Operator.INCLUDES) .addValue("string") .build() ) - .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -1210,14 +1228,14 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdResponseTest { .creditBlock( AffectedBlock.builder() .id("id") - .addBlockFilter( - AffectedBlock.BlockFilter.builder() - .field(AffectedBlock.BlockFilter.Field.PRICE_ID) - .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addFilter( + AffectedBlock.Filter.builder() + .field(AffectedBlock.Filter.Field.PRICE_ID) + .operator(AffectedBlock.Filter.Operator.INCLUDES) .addValue("string") .build() ) - .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -1268,14 +1286,14 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdResponseTest { .creditBlock( AffectedBlock.builder() .id("id") - .addBlockFilter( - AffectedBlock.BlockFilter.builder() - .field(AffectedBlock.BlockFilter.Field.PRICE_ID) - .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addFilter( + AffectedBlock.Filter.builder() + .field(AffectedBlock.Filter.Field.PRICE_ID) + .operator(AffectedBlock.Filter.Operator.INCLUDES) .addValue("string") .build() ) - .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -1320,14 +1338,14 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdResponseTest { .creditBlock( AffectedBlock.builder() .id("id") - .addBlockFilter( - AffectedBlock.BlockFilter.builder() - .field(AffectedBlock.BlockFilter.Field.PRICE_ID) - .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addFilter( + AffectedBlock.Filter.builder() + .field(AffectedBlock.Filter.Field.PRICE_ID) + .operator(AffectedBlock.Filter.Operator.INCLUDES) .addValue("string") .build() ) - .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -1377,14 +1395,14 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdResponseTest { .creditBlock( AffectedBlock.builder() .id("id") - .addBlockFilter( - AffectedBlock.BlockFilter.builder() - .field(AffectedBlock.BlockFilter.Field.PRICE_ID) - .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addFilter( + AffectedBlock.Filter.builder() + .field(AffectedBlock.Filter.Field.PRICE_ID) + .operator(AffectedBlock.Filter.Operator.INCLUDES) .addValue("string") .build() ) - .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -1431,14 +1449,14 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdResponseTest { .creditBlock( AffectedBlock.builder() .id("id") - .addBlockFilter( - AffectedBlock.BlockFilter.builder() - .field(AffectedBlock.BlockFilter.Field.PRICE_ID) - .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addFilter( + AffectedBlock.Filter.builder() + .field(AffectedBlock.Filter.Field.PRICE_ID) + .operator(AffectedBlock.Filter.Operator.INCLUDES) .addValue("string") .build() ) - .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -1490,14 +1508,14 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdResponseTest { .creditBlock( AffectedBlock.builder() .id("id") - .addBlockFilter( - AffectedBlock.BlockFilter.builder() - .field(AffectedBlock.BlockFilter.Field.PRICE_ID) - .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addFilter( + AffectedBlock.Filter.builder() + .field(AffectedBlock.Filter.Field.PRICE_ID) + .operator(AffectedBlock.Filter.Operator.INCLUDES) .addValue("string") .build() ) - .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -1545,14 +1563,14 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdResponseTest { .creditBlock( AffectedBlock.builder() .id("id") - .addBlockFilter( - AffectedBlock.BlockFilter.builder() - .field(AffectedBlock.BlockFilter.Field.PRICE_ID) - .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addFilter( + AffectedBlock.Filter.builder() + .field(AffectedBlock.Filter.Field.PRICE_ID) + .operator(AffectedBlock.Filter.Operator.INCLUDES) .addValue("string") .build() ) - .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -1601,14 +1619,14 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdResponseTest { .creditBlock( AffectedBlock.builder() .id("id") - .addBlockFilter( - AffectedBlock.BlockFilter.builder() - .field(AffectedBlock.BlockFilter.Field.PRICE_ID) - .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addFilter( + AffectedBlock.Filter.builder() + .field(AffectedBlock.Filter.Field.PRICE_ID) + .operator(AffectedBlock.Filter.Operator.INCLUDES) .addValue("string") .build() ) - .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() ) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryResponseTest.kt index 41bb72d62..66a81f4c0 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryResponseTest.kt @@ -25,14 +25,14 @@ internal class CustomerCreditLedgerCreateEntryResponseTest { .creditBlock( AffectedBlock.builder() .id("id") - .addBlockFilter( - AffectedBlock.BlockFilter.builder() - .field(AffectedBlock.BlockFilter.Field.PRICE_ID) - .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addFilter( + AffectedBlock.Filter.builder() + .field(AffectedBlock.Filter.Field.PRICE_ID) + .operator(AffectedBlock.Filter.Operator.INCLUDES) .addValue("string") .build() ) - .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -280,6 +280,15 @@ internal class CustomerCreditLedgerCreateEntryResponseTest { ) .build() ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator( + Allocation.Filter.Operator.INCLUDES + ) + .addValue("string") + .build() + ) .build() ) .currency("currency") @@ -499,14 +508,14 @@ internal class CustomerCreditLedgerCreateEntryResponseTest { .creditBlock( AffectedBlock.builder() .id("id") - .addBlockFilter( - AffectedBlock.BlockFilter.builder() - .field(AffectedBlock.BlockFilter.Field.PRICE_ID) - .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addFilter( + AffectedBlock.Filter.builder() + .field(AffectedBlock.Filter.Field.PRICE_ID) + .operator(AffectedBlock.Filter.Operator.INCLUDES) .addValue("string") .build() ) - .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -760,6 +769,15 @@ internal class CustomerCreditLedgerCreateEntryResponseTest { ) .build() ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator( + Allocation.Filter.Operator.INCLUDES + ) + .addValue("string") + .build() + ) .build() ) .currency("currency") @@ -985,14 +1003,14 @@ internal class CustomerCreditLedgerCreateEntryResponseTest { .creditBlock( AffectedBlock.builder() .id("id") - .addBlockFilter( - AffectedBlock.BlockFilter.builder() - .field(AffectedBlock.BlockFilter.Field.PRICE_ID) - .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addFilter( + AffectedBlock.Filter.builder() + .field(AffectedBlock.Filter.Field.PRICE_ID) + .operator(AffectedBlock.Filter.Operator.INCLUDES) .addValue("string") .build() ) - .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -1043,14 +1061,14 @@ internal class CustomerCreditLedgerCreateEntryResponseTest { .creditBlock( AffectedBlock.builder() .id("id") - .addBlockFilter( - AffectedBlock.BlockFilter.builder() - .field(AffectedBlock.BlockFilter.Field.PRICE_ID) - .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addFilter( + AffectedBlock.Filter.builder() + .field(AffectedBlock.Filter.Field.PRICE_ID) + .operator(AffectedBlock.Filter.Operator.INCLUDES) .addValue("string") .build() ) - .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -1098,14 +1116,14 @@ internal class CustomerCreditLedgerCreateEntryResponseTest { .creditBlock( AffectedBlock.builder() .id("id") - .addBlockFilter( - AffectedBlock.BlockFilter.builder() - .field(AffectedBlock.BlockFilter.Field.PRICE_ID) - .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addFilter( + AffectedBlock.Filter.builder() + .field(AffectedBlock.Filter.Field.PRICE_ID) + .operator(AffectedBlock.Filter.Operator.INCLUDES) .addValue("string") .build() ) - .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -1155,14 +1173,14 @@ internal class CustomerCreditLedgerCreateEntryResponseTest { .creditBlock( AffectedBlock.builder() .id("id") - .addBlockFilter( - AffectedBlock.BlockFilter.builder() - .field(AffectedBlock.BlockFilter.Field.PRICE_ID) - .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addFilter( + AffectedBlock.Filter.builder() + .field(AffectedBlock.Filter.Field.PRICE_ID) + .operator(AffectedBlock.Filter.Operator.INCLUDES) .addValue("string") .build() ) - .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -1208,14 +1226,14 @@ internal class CustomerCreditLedgerCreateEntryResponseTest { .creditBlock( AffectedBlock.builder() .id("id") - .addBlockFilter( - AffectedBlock.BlockFilter.builder() - .field(AffectedBlock.BlockFilter.Field.PRICE_ID) - .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addFilter( + AffectedBlock.Filter.builder() + .field(AffectedBlock.Filter.Field.PRICE_ID) + .operator(AffectedBlock.Filter.Operator.INCLUDES) .addValue("string") .build() ) - .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -1264,14 +1282,14 @@ internal class CustomerCreditLedgerCreateEntryResponseTest { .creditBlock( AffectedBlock.builder() .id("id") - .addBlockFilter( - AffectedBlock.BlockFilter.builder() - .field(AffectedBlock.BlockFilter.Field.PRICE_ID) - .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addFilter( + AffectedBlock.Filter.builder() + .field(AffectedBlock.Filter.Field.PRICE_ID) + .operator(AffectedBlock.Filter.Operator.INCLUDES) .addValue("string") .build() ) - .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -1316,14 +1334,14 @@ internal class CustomerCreditLedgerCreateEntryResponseTest { .creditBlock( AffectedBlock.builder() .id("id") - .addBlockFilter( - AffectedBlock.BlockFilter.builder() - .field(AffectedBlock.BlockFilter.Field.PRICE_ID) - .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addFilter( + AffectedBlock.Filter.builder() + .field(AffectedBlock.Filter.Field.PRICE_ID) + .operator(AffectedBlock.Filter.Operator.INCLUDES) .addValue("string") .build() ) - .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -1373,14 +1391,14 @@ internal class CustomerCreditLedgerCreateEntryResponseTest { .creditBlock( AffectedBlock.builder() .id("id") - .addBlockFilter( - AffectedBlock.BlockFilter.builder() - .field(AffectedBlock.BlockFilter.Field.PRICE_ID) - .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addFilter( + AffectedBlock.Filter.builder() + .field(AffectedBlock.Filter.Field.PRICE_ID) + .operator(AffectedBlock.Filter.Operator.INCLUDES) .addValue("string") .build() ) - .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -1427,14 +1445,14 @@ internal class CustomerCreditLedgerCreateEntryResponseTest { .creditBlock( AffectedBlock.builder() .id("id") - .addBlockFilter( - AffectedBlock.BlockFilter.builder() - .field(AffectedBlock.BlockFilter.Field.PRICE_ID) - .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addFilter( + AffectedBlock.Filter.builder() + .field(AffectedBlock.Filter.Field.PRICE_ID) + .operator(AffectedBlock.Filter.Operator.INCLUDES) .addValue("string") .build() ) - .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -1485,14 +1503,14 @@ internal class CustomerCreditLedgerCreateEntryResponseTest { .creditBlock( AffectedBlock.builder() .id("id") - .addBlockFilter( - AffectedBlock.BlockFilter.builder() - .field(AffectedBlock.BlockFilter.Field.PRICE_ID) - .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addFilter( + AffectedBlock.Filter.builder() + .field(AffectedBlock.Filter.Field.PRICE_ID) + .operator(AffectedBlock.Filter.Operator.INCLUDES) .addValue("string") .build() ) - .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -1540,14 +1558,14 @@ internal class CustomerCreditLedgerCreateEntryResponseTest { .creditBlock( AffectedBlock.builder() .id("id") - .addBlockFilter( - AffectedBlock.BlockFilter.builder() - .field(AffectedBlock.BlockFilter.Field.PRICE_ID) - .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addFilter( + AffectedBlock.Filter.builder() + .field(AffectedBlock.Filter.Field.PRICE_ID) + .operator(AffectedBlock.Filter.Operator.INCLUDES) .addValue("string") .build() ) - .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -1595,14 +1613,14 @@ internal class CustomerCreditLedgerCreateEntryResponseTest { .creditBlock( AffectedBlock.builder() .id("id") - .addBlockFilter( - AffectedBlock.BlockFilter.builder() - .field(AffectedBlock.BlockFilter.Field.PRICE_ID) - .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addFilter( + AffectedBlock.Filter.builder() + .field(AffectedBlock.Filter.Field.PRICE_ID) + .operator(AffectedBlock.Filter.Operator.INCLUDES) .addValue("string") .build() ) - .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() ) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdPageResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdPageResponseTest.kt index 3f6ff44c1..8157460a8 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdPageResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdPageResponseTest.kt @@ -23,14 +23,14 @@ internal class CustomerCreditLedgerListByExternalIdPageResponseTest { .creditBlock( AffectedBlock.builder() .id("id") - .addBlockFilter( - AffectedBlock.BlockFilter.builder() - .field(AffectedBlock.BlockFilter.Field.PRICE_ID) - .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addFilter( + AffectedBlock.Filter.builder() + .field(AffectedBlock.Filter.Field.PRICE_ID) + .operator(AffectedBlock.Filter.Operator.INCLUDES) .addValue("string") .build() ) - .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -299,6 +299,18 @@ internal class CustomerCreditLedgerListByExternalIdPageResponseTest { ) .build() ) + .addFilter( + Allocation.Filter.builder() + .field( + Allocation.Filter.Field.PRICE_ID + ) + .operator( + Allocation.Filter.Operator + .INCLUDES + ) + .addValue("string") + .build() + ) .build() ) .currency("currency") @@ -531,14 +543,14 @@ internal class CustomerCreditLedgerListByExternalIdPageResponseTest { .creditBlock( AffectedBlock.builder() .id("id") - .addBlockFilter( - AffectedBlock.BlockFilter.builder() - .field(AffectedBlock.BlockFilter.Field.PRICE_ID) - .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addFilter( + AffectedBlock.Filter.builder() + .field(AffectedBlock.Filter.Field.PRICE_ID) + .operator(AffectedBlock.Filter.Operator.INCLUDES) .addValue("string") .build() ) - .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -807,6 +819,18 @@ internal class CustomerCreditLedgerListByExternalIdPageResponseTest { ) .build() ) + .addFilter( + Allocation.Filter.builder() + .field( + Allocation.Filter.Field.PRICE_ID + ) + .operator( + Allocation.Filter.Operator + .INCLUDES + ) + .addValue("string") + .build() + ) .build() ) .currency("currency") @@ -1042,14 +1066,14 @@ internal class CustomerCreditLedgerListByExternalIdPageResponseTest { .creditBlock( AffectedBlock.builder() .id("id") - .addBlockFilter( - AffectedBlock.BlockFilter.builder() - .field(AffectedBlock.BlockFilter.Field.PRICE_ID) - .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addFilter( + AffectedBlock.Filter.builder() + .field(AffectedBlock.Filter.Field.PRICE_ID) + .operator(AffectedBlock.Filter.Operator.INCLUDES) .addValue("string") .build() ) - .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -1318,6 +1342,18 @@ internal class CustomerCreditLedgerListByExternalIdPageResponseTest { ) .build() ) + .addFilter( + Allocation.Filter.builder() + .field( + Allocation.Filter.Field.PRICE_ID + ) + .operator( + Allocation.Filter.Operator + .INCLUDES + ) + .addValue("string") + .build() + ) .build() ) .currency("currency") diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdResponseTest.kt index 3e4db0590..247d50bd9 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdResponseTest.kt @@ -25,14 +25,14 @@ internal class CustomerCreditLedgerListByExternalIdResponseTest { .creditBlock( AffectedBlock.builder() .id("id") - .addBlockFilter( - AffectedBlock.BlockFilter.builder() - .field(AffectedBlock.BlockFilter.Field.PRICE_ID) - .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addFilter( + AffectedBlock.Filter.builder() + .field(AffectedBlock.Filter.Field.PRICE_ID) + .operator(AffectedBlock.Filter.Operator.INCLUDES) .addValue("string") .build() ) - .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -280,6 +280,15 @@ internal class CustomerCreditLedgerListByExternalIdResponseTest { ) .build() ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator( + Allocation.Filter.Operator.INCLUDES + ) + .addValue("string") + .build() + ) .build() ) .currency("currency") @@ -499,14 +508,14 @@ internal class CustomerCreditLedgerListByExternalIdResponseTest { .creditBlock( AffectedBlock.builder() .id("id") - .addBlockFilter( - AffectedBlock.BlockFilter.builder() - .field(AffectedBlock.BlockFilter.Field.PRICE_ID) - .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addFilter( + AffectedBlock.Filter.builder() + .field(AffectedBlock.Filter.Field.PRICE_ID) + .operator(AffectedBlock.Filter.Operator.INCLUDES) .addValue("string") .build() ) - .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -760,6 +769,15 @@ internal class CustomerCreditLedgerListByExternalIdResponseTest { ) .build() ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator( + Allocation.Filter.Operator.INCLUDES + ) + .addValue("string") + .build() + ) .build() ) .currency("currency") @@ -985,14 +1003,14 @@ internal class CustomerCreditLedgerListByExternalIdResponseTest { .creditBlock( AffectedBlock.builder() .id("id") - .addBlockFilter( - AffectedBlock.BlockFilter.builder() - .field(AffectedBlock.BlockFilter.Field.PRICE_ID) - .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addFilter( + AffectedBlock.Filter.builder() + .field(AffectedBlock.Filter.Field.PRICE_ID) + .operator(AffectedBlock.Filter.Operator.INCLUDES) .addValue("string") .build() ) - .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -1043,14 +1061,14 @@ internal class CustomerCreditLedgerListByExternalIdResponseTest { .creditBlock( AffectedBlock.builder() .id("id") - .addBlockFilter( - AffectedBlock.BlockFilter.builder() - .field(AffectedBlock.BlockFilter.Field.PRICE_ID) - .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addFilter( + AffectedBlock.Filter.builder() + .field(AffectedBlock.Filter.Field.PRICE_ID) + .operator(AffectedBlock.Filter.Operator.INCLUDES) .addValue("string") .build() ) - .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -1098,14 +1116,14 @@ internal class CustomerCreditLedgerListByExternalIdResponseTest { .creditBlock( AffectedBlock.builder() .id("id") - .addBlockFilter( - AffectedBlock.BlockFilter.builder() - .field(AffectedBlock.BlockFilter.Field.PRICE_ID) - .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addFilter( + AffectedBlock.Filter.builder() + .field(AffectedBlock.Filter.Field.PRICE_ID) + .operator(AffectedBlock.Filter.Operator.INCLUDES) .addValue("string") .build() ) - .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -1155,14 +1173,14 @@ internal class CustomerCreditLedgerListByExternalIdResponseTest { .creditBlock( AffectedBlock.builder() .id("id") - .addBlockFilter( - AffectedBlock.BlockFilter.builder() - .field(AffectedBlock.BlockFilter.Field.PRICE_ID) - .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addFilter( + AffectedBlock.Filter.builder() + .field(AffectedBlock.Filter.Field.PRICE_ID) + .operator(AffectedBlock.Filter.Operator.INCLUDES) .addValue("string") .build() ) - .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -1208,14 +1226,14 @@ internal class CustomerCreditLedgerListByExternalIdResponseTest { .creditBlock( AffectedBlock.builder() .id("id") - .addBlockFilter( - AffectedBlock.BlockFilter.builder() - .field(AffectedBlock.BlockFilter.Field.PRICE_ID) - .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addFilter( + AffectedBlock.Filter.builder() + .field(AffectedBlock.Filter.Field.PRICE_ID) + .operator(AffectedBlock.Filter.Operator.INCLUDES) .addValue("string") .build() ) - .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -1264,14 +1282,14 @@ internal class CustomerCreditLedgerListByExternalIdResponseTest { .creditBlock( AffectedBlock.builder() .id("id") - .addBlockFilter( - AffectedBlock.BlockFilter.builder() - .field(AffectedBlock.BlockFilter.Field.PRICE_ID) - .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addFilter( + AffectedBlock.Filter.builder() + .field(AffectedBlock.Filter.Field.PRICE_ID) + .operator(AffectedBlock.Filter.Operator.INCLUDES) .addValue("string") .build() ) - .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -1316,14 +1334,14 @@ internal class CustomerCreditLedgerListByExternalIdResponseTest { .creditBlock( AffectedBlock.builder() .id("id") - .addBlockFilter( - AffectedBlock.BlockFilter.builder() - .field(AffectedBlock.BlockFilter.Field.PRICE_ID) - .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addFilter( + AffectedBlock.Filter.builder() + .field(AffectedBlock.Filter.Field.PRICE_ID) + .operator(AffectedBlock.Filter.Operator.INCLUDES) .addValue("string") .build() ) - .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -1373,14 +1391,14 @@ internal class CustomerCreditLedgerListByExternalIdResponseTest { .creditBlock( AffectedBlock.builder() .id("id") - .addBlockFilter( - AffectedBlock.BlockFilter.builder() - .field(AffectedBlock.BlockFilter.Field.PRICE_ID) - .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addFilter( + AffectedBlock.Filter.builder() + .field(AffectedBlock.Filter.Field.PRICE_ID) + .operator(AffectedBlock.Filter.Operator.INCLUDES) .addValue("string") .build() ) - .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -1427,14 +1445,14 @@ internal class CustomerCreditLedgerListByExternalIdResponseTest { .creditBlock( AffectedBlock.builder() .id("id") - .addBlockFilter( - AffectedBlock.BlockFilter.builder() - .field(AffectedBlock.BlockFilter.Field.PRICE_ID) - .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addFilter( + AffectedBlock.Filter.builder() + .field(AffectedBlock.Filter.Field.PRICE_ID) + .operator(AffectedBlock.Filter.Operator.INCLUDES) .addValue("string") .build() ) - .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -1486,14 +1504,14 @@ internal class CustomerCreditLedgerListByExternalIdResponseTest { .creditBlock( AffectedBlock.builder() .id("id") - .addBlockFilter( - AffectedBlock.BlockFilter.builder() - .field(AffectedBlock.BlockFilter.Field.PRICE_ID) - .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addFilter( + AffectedBlock.Filter.builder() + .field(AffectedBlock.Filter.Field.PRICE_ID) + .operator(AffectedBlock.Filter.Operator.INCLUDES) .addValue("string") .build() ) - .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -1541,14 +1559,14 @@ internal class CustomerCreditLedgerListByExternalIdResponseTest { .creditBlock( AffectedBlock.builder() .id("id") - .addBlockFilter( - AffectedBlock.BlockFilter.builder() - .field(AffectedBlock.BlockFilter.Field.PRICE_ID) - .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addFilter( + AffectedBlock.Filter.builder() + .field(AffectedBlock.Filter.Field.PRICE_ID) + .operator(AffectedBlock.Filter.Operator.INCLUDES) .addValue("string") .build() ) - .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -1596,14 +1614,14 @@ internal class CustomerCreditLedgerListByExternalIdResponseTest { .creditBlock( AffectedBlock.builder() .id("id") - .addBlockFilter( - AffectedBlock.BlockFilter.builder() - .field(AffectedBlock.BlockFilter.Field.PRICE_ID) - .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addFilter( + AffectedBlock.Filter.builder() + .field(AffectedBlock.Filter.Field.PRICE_ID) + .operator(AffectedBlock.Filter.Operator.INCLUDES) .addValue("string") .build() ) - .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() ) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListPageResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListPageResponseTest.kt index bc73ba6d9..2d96a1ce3 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListPageResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListPageResponseTest.kt @@ -23,14 +23,14 @@ internal class CustomerCreditLedgerListPageResponseTest { .creditBlock( AffectedBlock.builder() .id("id") - .addBlockFilter( - AffectedBlock.BlockFilter.builder() - .field(AffectedBlock.BlockFilter.Field.PRICE_ID) - .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addFilter( + AffectedBlock.Filter.builder() + .field(AffectedBlock.Filter.Field.PRICE_ID) + .operator(AffectedBlock.Filter.Operator.INCLUDES) .addValue("string") .build() ) - .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -299,6 +299,18 @@ internal class CustomerCreditLedgerListPageResponseTest { ) .build() ) + .addFilter( + Allocation.Filter.builder() + .field( + Allocation.Filter.Field.PRICE_ID + ) + .operator( + Allocation.Filter.Operator + .INCLUDES + ) + .addValue("string") + .build() + ) .build() ) .currency("currency") @@ -531,14 +543,14 @@ internal class CustomerCreditLedgerListPageResponseTest { .creditBlock( AffectedBlock.builder() .id("id") - .addBlockFilter( - AffectedBlock.BlockFilter.builder() - .field(AffectedBlock.BlockFilter.Field.PRICE_ID) - .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addFilter( + AffectedBlock.Filter.builder() + .field(AffectedBlock.Filter.Field.PRICE_ID) + .operator(AffectedBlock.Filter.Operator.INCLUDES) .addValue("string") .build() ) - .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -807,6 +819,18 @@ internal class CustomerCreditLedgerListPageResponseTest { ) .build() ) + .addFilter( + Allocation.Filter.builder() + .field( + Allocation.Filter.Field.PRICE_ID + ) + .operator( + Allocation.Filter.Operator + .INCLUDES + ) + .addValue("string") + .build() + ) .build() ) .currency("currency") @@ -1042,14 +1066,14 @@ internal class CustomerCreditLedgerListPageResponseTest { .creditBlock( AffectedBlock.builder() .id("id") - .addBlockFilter( - AffectedBlock.BlockFilter.builder() - .field(AffectedBlock.BlockFilter.Field.PRICE_ID) - .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addFilter( + AffectedBlock.Filter.builder() + .field(AffectedBlock.Filter.Field.PRICE_ID) + .operator(AffectedBlock.Filter.Operator.INCLUDES) .addValue("string") .build() ) - .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -1318,6 +1342,18 @@ internal class CustomerCreditLedgerListPageResponseTest { ) .build() ) + .addFilter( + Allocation.Filter.builder() + .field( + Allocation.Filter.Field.PRICE_ID + ) + .operator( + Allocation.Filter.Operator + .INCLUDES + ) + .addValue("string") + .build() + ) .build() ) .currency("currency") diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListResponseTest.kt index b9accfb05..a7728344f 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListResponseTest.kt @@ -25,14 +25,14 @@ internal class CustomerCreditLedgerListResponseTest { .creditBlock( AffectedBlock.builder() .id("id") - .addBlockFilter( - AffectedBlock.BlockFilter.builder() - .field(AffectedBlock.BlockFilter.Field.PRICE_ID) - .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addFilter( + AffectedBlock.Filter.builder() + .field(AffectedBlock.Filter.Field.PRICE_ID) + .operator(AffectedBlock.Filter.Operator.INCLUDES) .addValue("string") .build() ) - .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -280,6 +280,15 @@ internal class CustomerCreditLedgerListResponseTest { ) .build() ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator( + Allocation.Filter.Operator.INCLUDES + ) + .addValue("string") + .build() + ) .build() ) .currency("currency") @@ -499,14 +508,14 @@ internal class CustomerCreditLedgerListResponseTest { .creditBlock( AffectedBlock.builder() .id("id") - .addBlockFilter( - AffectedBlock.BlockFilter.builder() - .field(AffectedBlock.BlockFilter.Field.PRICE_ID) - .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addFilter( + AffectedBlock.Filter.builder() + .field(AffectedBlock.Filter.Field.PRICE_ID) + .operator(AffectedBlock.Filter.Operator.INCLUDES) .addValue("string") .build() ) - .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -760,6 +769,15 @@ internal class CustomerCreditLedgerListResponseTest { ) .build() ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator( + Allocation.Filter.Operator.INCLUDES + ) + .addValue("string") + .build() + ) .build() ) .currency("currency") @@ -985,14 +1003,14 @@ internal class CustomerCreditLedgerListResponseTest { .creditBlock( AffectedBlock.builder() .id("id") - .addBlockFilter( - AffectedBlock.BlockFilter.builder() - .field(AffectedBlock.BlockFilter.Field.PRICE_ID) - .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addFilter( + AffectedBlock.Filter.builder() + .field(AffectedBlock.Filter.Field.PRICE_ID) + .operator(AffectedBlock.Filter.Operator.INCLUDES) .addValue("string") .build() ) - .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -1043,14 +1061,14 @@ internal class CustomerCreditLedgerListResponseTest { .creditBlock( AffectedBlock.builder() .id("id") - .addBlockFilter( - AffectedBlock.BlockFilter.builder() - .field(AffectedBlock.BlockFilter.Field.PRICE_ID) - .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addFilter( + AffectedBlock.Filter.builder() + .field(AffectedBlock.Filter.Field.PRICE_ID) + .operator(AffectedBlock.Filter.Operator.INCLUDES) .addValue("string") .build() ) - .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -1098,14 +1116,14 @@ internal class CustomerCreditLedgerListResponseTest { .creditBlock( AffectedBlock.builder() .id("id") - .addBlockFilter( - AffectedBlock.BlockFilter.builder() - .field(AffectedBlock.BlockFilter.Field.PRICE_ID) - .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addFilter( + AffectedBlock.Filter.builder() + .field(AffectedBlock.Filter.Field.PRICE_ID) + .operator(AffectedBlock.Filter.Operator.INCLUDES) .addValue("string") .build() ) - .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -1154,14 +1172,14 @@ internal class CustomerCreditLedgerListResponseTest { .creditBlock( AffectedBlock.builder() .id("id") - .addBlockFilter( - AffectedBlock.BlockFilter.builder() - .field(AffectedBlock.BlockFilter.Field.PRICE_ID) - .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addFilter( + AffectedBlock.Filter.builder() + .field(AffectedBlock.Filter.Field.PRICE_ID) + .operator(AffectedBlock.Filter.Operator.INCLUDES) .addValue("string") .build() ) - .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -1207,14 +1225,14 @@ internal class CustomerCreditLedgerListResponseTest { .creditBlock( AffectedBlock.builder() .id("id") - .addBlockFilter( - AffectedBlock.BlockFilter.builder() - .field(AffectedBlock.BlockFilter.Field.PRICE_ID) - .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addFilter( + AffectedBlock.Filter.builder() + .field(AffectedBlock.Filter.Field.PRICE_ID) + .operator(AffectedBlock.Filter.Operator.INCLUDES) .addValue("string") .build() ) - .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -1263,14 +1281,14 @@ internal class CustomerCreditLedgerListResponseTest { .creditBlock( AffectedBlock.builder() .id("id") - .addBlockFilter( - AffectedBlock.BlockFilter.builder() - .field(AffectedBlock.BlockFilter.Field.PRICE_ID) - .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addFilter( + AffectedBlock.Filter.builder() + .field(AffectedBlock.Filter.Field.PRICE_ID) + .operator(AffectedBlock.Filter.Operator.INCLUDES) .addValue("string") .build() ) - .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -1315,14 +1333,14 @@ internal class CustomerCreditLedgerListResponseTest { .creditBlock( AffectedBlock.builder() .id("id") - .addBlockFilter( - AffectedBlock.BlockFilter.builder() - .field(AffectedBlock.BlockFilter.Field.PRICE_ID) - .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addFilter( + AffectedBlock.Filter.builder() + .field(AffectedBlock.Filter.Field.PRICE_ID) + .operator(AffectedBlock.Filter.Operator.INCLUDES) .addValue("string") .build() ) - .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -1371,14 +1389,14 @@ internal class CustomerCreditLedgerListResponseTest { .creditBlock( AffectedBlock.builder() .id("id") - .addBlockFilter( - AffectedBlock.BlockFilter.builder() - .field(AffectedBlock.BlockFilter.Field.PRICE_ID) - .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addFilter( + AffectedBlock.Filter.builder() + .field(AffectedBlock.Filter.Field.PRICE_ID) + .operator(AffectedBlock.Filter.Operator.INCLUDES) .addValue("string") .build() ) - .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -1425,14 +1443,14 @@ internal class CustomerCreditLedgerListResponseTest { .creditBlock( AffectedBlock.builder() .id("id") - .addBlockFilter( - AffectedBlock.BlockFilter.builder() - .field(AffectedBlock.BlockFilter.Field.PRICE_ID) - .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addFilter( + AffectedBlock.Filter.builder() + .field(AffectedBlock.Filter.Field.PRICE_ID) + .operator(AffectedBlock.Filter.Operator.INCLUDES) .addValue("string") .build() ) - .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -1483,14 +1501,14 @@ internal class CustomerCreditLedgerListResponseTest { .creditBlock( AffectedBlock.builder() .id("id") - .addBlockFilter( - AffectedBlock.BlockFilter.builder() - .field(AffectedBlock.BlockFilter.Field.PRICE_ID) - .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addFilter( + AffectedBlock.Filter.builder() + .field(AffectedBlock.Filter.Field.PRICE_ID) + .operator(AffectedBlock.Filter.Operator.INCLUDES) .addValue("string") .build() ) - .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -1538,14 +1556,14 @@ internal class CustomerCreditLedgerListResponseTest { .creditBlock( AffectedBlock.builder() .id("id") - .addBlockFilter( - AffectedBlock.BlockFilter.builder() - .field(AffectedBlock.BlockFilter.Field.PRICE_ID) - .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addFilter( + AffectedBlock.Filter.builder() + .field(AffectedBlock.Filter.Field.PRICE_ID) + .operator(AffectedBlock.Filter.Operator.INCLUDES) .addValue("string") .build() ) - .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -1593,14 +1611,14 @@ internal class CustomerCreditLedgerListResponseTest { .creditBlock( AffectedBlock.builder() .id("id") - .addBlockFilter( - AffectedBlock.BlockFilter.builder() - .field(AffectedBlock.BlockFilter.Field.PRICE_ID) - .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addFilter( + AffectedBlock.Filter.builder() + .field(AffectedBlock.Filter.Field.PRICE_ID) + .operator(AffectedBlock.Filter.Operator.INCLUDES) .addValue("string") .build() ) - .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() ) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerListPageResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerListPageResponseTest.kt index 3d264a891..1546ebd25 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerListPageResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerListPageResponseTest.kt @@ -97,6 +97,7 @@ internal class CustomerListPageResponseTest { .excluded(true) .build() ) + .automaticTaxEnabled(true) .reportingConfiguration( Customer.ReportingConfiguration.builder().exempt(true).build() ) @@ -189,6 +190,7 @@ internal class CustomerListPageResponseTest { .excluded(true) .build() ) + .automaticTaxEnabled(true) .reportingConfiguration( Customer.ReportingConfiguration.builder().exempt(true).build() ) @@ -285,6 +287,7 @@ internal class CustomerListPageResponseTest { .excluded(true) .build() ) + .automaticTaxEnabled(true) .reportingConfiguration( Customer.ReportingConfiguration.builder().exempt(true).build() ) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerTest.kt index e51f3ab3a..48275498a 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerTest.kt @@ -94,6 +94,7 @@ internal class CustomerTest { .excluded(true) .build() ) + .automaticTaxEnabled(true) .reportingConfiguration( Customer.ReportingConfiguration.builder().exempt(true).build() ) @@ -183,6 +184,7 @@ internal class CustomerTest { .excluded(true) .build() ) + assertThat(customer.automaticTaxEnabled()).isEqualTo(true) assertThat(customer.reportingConfiguration()) .isEqualTo(Customer.ReportingConfiguration.builder().exempt(true).build()) } @@ -271,6 +273,7 @@ internal class CustomerTest { .excluded(true) .build() ) + .automaticTaxEnabled(true) .reportingConfiguration( Customer.ReportingConfiguration.builder().exempt(true).build() ) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerUpdateByExternalIdParamsTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerUpdateByExternalIdParamsTest.kt index 05579b6f9..4717c6118 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerUpdateByExternalIdParamsTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerUpdateByExternalIdParamsTest.kt @@ -26,6 +26,7 @@ internal class CustomerUpdateByExternalIdParamsTest { .addAdditionalEmail("string") .autoCollection(true) .autoIssuance(true) + .automaticTaxEnabled(true) .billingAddress( AddressInput.builder() .city("city") @@ -69,6 +70,7 @@ internal class CustomerUpdateByExternalIdParamsTest { NewAvalaraTaxConfiguration.builder() .taxExempt(true) .taxProvider(NewAvalaraTaxConfiguration.TaxProvider.AVALARA) + .automaticTaxEnabled(true) .taxExemptionCode("tax_exemption_code") .build() ) @@ -110,6 +112,7 @@ internal class CustomerUpdateByExternalIdParamsTest { .addAdditionalEmail("string") .autoCollection(true) .autoIssuance(true) + .automaticTaxEnabled(true) .billingAddress( AddressInput.builder() .city("city") @@ -153,6 +156,7 @@ internal class CustomerUpdateByExternalIdParamsTest { NewAvalaraTaxConfiguration.builder() .taxExempt(true) .taxProvider(NewAvalaraTaxConfiguration.TaxProvider.AVALARA) + .automaticTaxEnabled(true) .taxExemptionCode("tax_exemption_code") .build() ) @@ -182,6 +186,7 @@ internal class CustomerUpdateByExternalIdParamsTest { assertThat(body.additionalEmails()).containsExactly("string") assertThat(body.autoCollection()).isEqualTo(true) assertThat(body.autoIssuance()).isEqualTo(true) + assertThat(body.automaticTaxEnabled()).isEqualTo(true) assertThat(body.billingAddress()) .isEqualTo( AddressInput.builder() @@ -233,6 +238,7 @@ internal class CustomerUpdateByExternalIdParamsTest { NewAvalaraTaxConfiguration.builder() .taxExempt(true) .taxProvider(NewAvalaraTaxConfiguration.TaxProvider.AVALARA) + .automaticTaxEnabled(true) .taxExemptionCode("tax_exemption_code") .build() ) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerUpdateParamsTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerUpdateParamsTest.kt index adb92b9d2..d4535efd2 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerUpdateParamsTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerUpdateParamsTest.kt @@ -26,6 +26,7 @@ internal class CustomerUpdateParamsTest { .addAdditionalEmail("string") .autoCollection(true) .autoIssuance(true) + .automaticTaxEnabled(true) .billingAddress( AddressInput.builder() .city("city") @@ -69,6 +70,7 @@ internal class CustomerUpdateParamsTest { NewAvalaraTaxConfiguration.builder() .taxExempt(true) .taxProvider(NewAvalaraTaxConfiguration.TaxProvider.AVALARA) + .automaticTaxEnabled(true) .taxExemptionCode("tax_exemption_code") .build() ) @@ -110,6 +112,7 @@ internal class CustomerUpdateParamsTest { .addAdditionalEmail("string") .autoCollection(true) .autoIssuance(true) + .automaticTaxEnabled(true) .billingAddress( AddressInput.builder() .city("city") @@ -153,6 +156,7 @@ internal class CustomerUpdateParamsTest { NewAvalaraTaxConfiguration.builder() .taxExempt(true) .taxProvider(NewAvalaraTaxConfiguration.TaxProvider.AVALARA) + .automaticTaxEnabled(true) .taxExemptionCode("tax_exemption_code") .build() ) @@ -182,6 +186,7 @@ internal class CustomerUpdateParamsTest { assertThat(body.additionalEmails()).containsExactly("string") assertThat(body.autoCollection()).isEqualTo(true) assertThat(body.autoIssuance()).isEqualTo(true) + assertThat(body.automaticTaxEnabled()).isEqualTo(true) assertThat(body.billingAddress()) .isEqualTo( AddressInput.builder() @@ -233,6 +238,7 @@ internal class CustomerUpdateParamsTest { NewAvalaraTaxConfiguration.builder() .taxExempt(true) .taxProvider(NewAvalaraTaxConfiguration.TaxProvider.AVALARA) + .automaticTaxEnabled(true) .taxExemptionCode("tax_exemption_code") .build() ) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/DecrementLedgerEntryTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/DecrementLedgerEntryTest.kt index 10e23562f..64e63d76f 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/DecrementLedgerEntryTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/DecrementLedgerEntryTest.kt @@ -21,14 +21,14 @@ internal class DecrementLedgerEntryTest { .creditBlock( AffectedBlock.builder() .id("id") - .addBlockFilter( - AffectedBlock.BlockFilter.builder() - .field(AffectedBlock.BlockFilter.Field.PRICE_ID) - .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addFilter( + AffectedBlock.Filter.builder() + .field(AffectedBlock.Filter.Field.PRICE_ID) + .operator(AffectedBlock.Filter.Operator.INCLUDES) .addValue("string") .build() ) - .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -63,14 +63,14 @@ internal class DecrementLedgerEntryTest { .isEqualTo( AffectedBlock.builder() .id("id") - .addBlockFilter( - AffectedBlock.BlockFilter.builder() - .field(AffectedBlock.BlockFilter.Field.PRICE_ID) - .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addFilter( + AffectedBlock.Filter.builder() + .field(AffectedBlock.Filter.Field.PRICE_ID) + .operator(AffectedBlock.Filter.Operator.INCLUDES) .addValue("string") .build() ) - .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -112,14 +112,14 @@ internal class DecrementLedgerEntryTest { .creditBlock( AffectedBlock.builder() .id("id") - .addBlockFilter( - AffectedBlock.BlockFilter.builder() - .field(AffectedBlock.BlockFilter.Field.PRICE_ID) - .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addFilter( + AffectedBlock.Filter.builder() + .field(AffectedBlock.Filter.Field.PRICE_ID) + .operator(AffectedBlock.Filter.Operator.INCLUDES) .addValue("string") .build() ) - .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() ) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/ExpirationChangeLedgerEntryTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/ExpirationChangeLedgerEntryTest.kt index 2aacd3628..052d1aef2 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/ExpirationChangeLedgerEntryTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/ExpirationChangeLedgerEntryTest.kt @@ -21,14 +21,14 @@ internal class ExpirationChangeLedgerEntryTest { .creditBlock( AffectedBlock.builder() .id("id") - .addBlockFilter( - AffectedBlock.BlockFilter.builder() - .field(AffectedBlock.BlockFilter.Field.PRICE_ID) - .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addFilter( + AffectedBlock.Filter.builder() + .field(AffectedBlock.Filter.Field.PRICE_ID) + .operator(AffectedBlock.Filter.Operator.INCLUDES) .addValue("string") .build() ) - .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -61,14 +61,14 @@ internal class ExpirationChangeLedgerEntryTest { .isEqualTo( AffectedBlock.builder() .id("id") - .addBlockFilter( - AffectedBlock.BlockFilter.builder() - .field(AffectedBlock.BlockFilter.Field.PRICE_ID) - .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addFilter( + AffectedBlock.Filter.builder() + .field(AffectedBlock.Filter.Field.PRICE_ID) + .operator(AffectedBlock.Filter.Operator.INCLUDES) .addValue("string") .build() ) - .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -109,14 +109,14 @@ internal class ExpirationChangeLedgerEntryTest { .creditBlock( AffectedBlock.builder() .id("id") - .addBlockFilter( - AffectedBlock.BlockFilter.builder() - .field(AffectedBlock.BlockFilter.Field.PRICE_ID) - .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addFilter( + AffectedBlock.Filter.builder() + .field(AffectedBlock.Filter.Field.PRICE_ID) + .operator(AffectedBlock.Filter.Operator.INCLUDES) .addValue("string") .build() ) - .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() ) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/IncrementLedgerEntryTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/IncrementLedgerEntryTest.kt index 163cdfa7f..ae20501cf 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/IncrementLedgerEntryTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/IncrementLedgerEntryTest.kt @@ -21,14 +21,14 @@ internal class IncrementLedgerEntryTest { .creditBlock( AffectedBlock.builder() .id("id") - .addBlockFilter( - AffectedBlock.BlockFilter.builder() - .field(AffectedBlock.BlockFilter.Field.PRICE_ID) - .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addFilter( + AffectedBlock.Filter.builder() + .field(AffectedBlock.Filter.Field.PRICE_ID) + .operator(AffectedBlock.Filter.Operator.INCLUDES) .addValue("string") .build() ) - .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -276,6 +276,15 @@ internal class IncrementLedgerEntryTest { ) .build() ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator( + Allocation.Filter.Operator.INCLUDES + ) + .addValue("string") + .build() + ) .build() ) .currency("currency") @@ -479,14 +488,14 @@ internal class IncrementLedgerEntryTest { .isEqualTo( AffectedBlock.builder() .id("id") - .addBlockFilter( - AffectedBlock.BlockFilter.builder() - .field(AffectedBlock.BlockFilter.Field.PRICE_ID) - .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addFilter( + AffectedBlock.Filter.builder() + .field(AffectedBlock.Filter.Field.PRICE_ID) + .operator(AffectedBlock.Filter.Operator.INCLUDES) .addValue("string") .build() ) - .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -726,6 +735,13 @@ internal class IncrementLedgerEntryTest { .durationUnit(CustomExpiration.DurationUnit.DAY) .build() ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator(Allocation.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .currency("currency") @@ -924,14 +940,14 @@ internal class IncrementLedgerEntryTest { .creditBlock( AffectedBlock.builder() .id("id") - .addBlockFilter( - AffectedBlock.BlockFilter.builder() - .field(AffectedBlock.BlockFilter.Field.PRICE_ID) - .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addFilter( + AffectedBlock.Filter.builder() + .field(AffectedBlock.Filter.Field.PRICE_ID) + .operator(AffectedBlock.Filter.Operator.INCLUDES) .addValue("string") .build() ) - .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -1179,6 +1195,15 @@ internal class IncrementLedgerEntryTest { ) .build() ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator( + Allocation.Filter.Operator.INCLUDES + ) + .addValue("string") + .build() + ) .build() ) .currency("currency") diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceFetchUpcomingResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceFetchUpcomingResponseTest.kt index 69e84e4d4..34c4ac2af 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceFetchUpcomingResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceFetchUpcomingResponseTest.kt @@ -221,6 +221,13 @@ internal class InvoiceFetchUpcomingResponseTest { .durationUnit(CustomExpiration.DurationUnit.DAY) .build() ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator(Allocation.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .currency("currency") @@ -621,6 +628,13 @@ internal class InvoiceFetchUpcomingResponseTest { .durationUnit(CustomExpiration.DurationUnit.DAY) .build() ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator(Allocation.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .currency("currency") @@ -1023,6 +1037,13 @@ internal class InvoiceFetchUpcomingResponseTest { .durationUnit(CustomExpiration.DurationUnit.DAY) .build() ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator(Allocation.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .currency("currency") diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceLineItemCreateResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceLineItemCreateResponseTest.kt index befb00bb3..4f9f42aba 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceLineItemCreateResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceLineItemCreateResponseTest.kt @@ -123,6 +123,13 @@ internal class InvoiceLineItemCreateResponseTest { .durationUnit(CustomExpiration.DurationUnit.DAY) .build() ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator(Allocation.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .currency("currency") @@ -342,6 +349,13 @@ internal class InvoiceLineItemCreateResponseTest { .durationUnit(CustomExpiration.DurationUnit.DAY) .build() ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator(Allocation.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .currency("currency") @@ -561,6 +575,13 @@ internal class InvoiceLineItemCreateResponseTest { .durationUnit(CustomExpiration.DurationUnit.DAY) .build() ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator(Allocation.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .currency("currency") diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceListPageResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceListPageResponseTest.kt index 6c2cc0be2..4bc2f7bd9 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceListPageResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceListPageResponseTest.kt @@ -241,6 +241,15 @@ internal class InvoiceListPageResponseTest { ) .build() ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator( + Allocation.Filter.Operator.INCLUDES + ) + .addValue("string") + .build() + ) .build() ) .currency("currency") @@ -653,6 +662,13 @@ internal class InvoiceListPageResponseTest { .durationUnit(CustomExpiration.DurationUnit.DAY) .build() ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator(Allocation.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .currency("currency") @@ -1073,6 +1089,15 @@ internal class InvoiceListPageResponseTest { ) .build() ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator( + Allocation.Filter.Operator.INCLUDES + ) + .addValue("string") + .build() + ) .build() ) .currency("currency") diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceTest.kt index 093722ab5..a76a00d1f 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceTest.kt @@ -217,6 +217,13 @@ internal class InvoiceTest { .durationUnit(CustomExpiration.DurationUnit.DAY) .build() ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator(Allocation.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .currency("currency") @@ -608,6 +615,13 @@ internal class InvoiceTest { .durationUnit(CustomExpiration.DurationUnit.DAY) .build() ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator(Allocation.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .currency("currency") @@ -999,6 +1013,13 @@ internal class InvoiceTest { .durationUnit(CustomExpiration.DurationUnit.DAY) .build() ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator(Allocation.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .currency("currency") diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/MutatedSubscriptionTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/MutatedSubscriptionTest.kt index 203cef795..4d456f184 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/MutatedSubscriptionTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/MutatedSubscriptionTest.kt @@ -141,6 +141,7 @@ internal class MutatedSubscriptionTest { .excluded(true) .build() ) + .automaticTaxEnabled(true) .reportingConfiguration( Customer.ReportingConfiguration.builder().exempt(true).build() ) @@ -397,6 +398,13 @@ internal class MutatedSubscriptionTest { .durationUnit(CustomExpiration.DurationUnit.DAY) .build() ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator(Allocation.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .currency("currency") @@ -545,6 +553,13 @@ internal class MutatedSubscriptionTest { .durationUnit(CustomExpiration.DurationUnit.DAY) .build() ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator(Allocation.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .currency("currency") @@ -993,6 +1008,18 @@ internal class MutatedSubscriptionTest { ) .build() ) + .addFilter( + Allocation.Filter.builder() + .field( + Allocation.Filter.Field.PRICE_ID + ) + .operator( + Allocation.Filter.Operator + .INCLUDES + ) + .addValue("string") + .build() + ) .build() ) .currency("currency") @@ -1550,6 +1577,18 @@ internal class MutatedSubscriptionTest { ) .build() ) + .addFilter( + Allocation.Filter.builder() + .field( + Allocation.Filter.Field.PRICE_ID + ) + .operator( + Allocation.Filter.Operator + .INCLUDES + ) + .addValue("string") + .build() + ) .build() ) .currency("currency") @@ -1895,6 +1934,7 @@ internal class MutatedSubscriptionTest { .excluded(true) .build() ) + .automaticTaxEnabled(true) .reportingConfiguration( Customer.ReportingConfiguration.builder().exempt(true).build() ) @@ -2154,6 +2194,13 @@ internal class MutatedSubscriptionTest { .durationUnit(CustomExpiration.DurationUnit.DAY) .build() ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator(Allocation.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .currency("currency") @@ -2295,6 +2342,13 @@ internal class MutatedSubscriptionTest { .durationUnit(CustomExpiration.DurationUnit.DAY) .build() ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator(Allocation.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .currency("currency") @@ -2727,6 +2781,15 @@ internal class MutatedSubscriptionTest { ) .build() ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator( + Allocation.Filter.Operator.INCLUDES + ) + .addValue("string") + .build() + ) .build() ) .currency("currency") @@ -3253,6 +3316,15 @@ internal class MutatedSubscriptionTest { ) .build() ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator( + Allocation.Filter.Operator.INCLUDES + ) + .addValue("string") + .build() + ) .build() ) .currency("currency") @@ -3590,6 +3662,7 @@ internal class MutatedSubscriptionTest { .excluded(true) .build() ) + .automaticTaxEnabled(true) .reportingConfiguration( Customer.ReportingConfiguration.builder().exempt(true).build() ) @@ -3846,6 +3919,13 @@ internal class MutatedSubscriptionTest { .durationUnit(CustomExpiration.DurationUnit.DAY) .build() ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator(Allocation.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .currency("currency") @@ -3994,6 +4074,13 @@ internal class MutatedSubscriptionTest { .durationUnit(CustomExpiration.DurationUnit.DAY) .build() ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator(Allocation.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .currency("currency") @@ -4442,6 +4529,18 @@ internal class MutatedSubscriptionTest { ) .build() ) + .addFilter( + Allocation.Filter.builder() + .field( + Allocation.Filter.Field.PRICE_ID + ) + .operator( + Allocation.Filter.Operator + .INCLUDES + ) + .addValue("string") + .build() + ) .build() ) .currency("currency") @@ -4999,6 +5098,18 @@ internal class MutatedSubscriptionTest { ) .build() ) + .addFilter( + Allocation.Filter.builder() + .field( + Allocation.Filter.Field.PRICE_ID + ) + .operator( + Allocation.Filter.Operator + .INCLUDES + ) + .addValue("string") + .build() + ) .build() ) .currency("currency") diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewAvalaraTaxConfigurationTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewAvalaraTaxConfigurationTest.kt index 58b62648d..6a60f8e06 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewAvalaraTaxConfigurationTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewAvalaraTaxConfigurationTest.kt @@ -15,12 +15,14 @@ internal class NewAvalaraTaxConfigurationTest { NewAvalaraTaxConfiguration.builder() .taxExempt(true) .taxProvider(NewAvalaraTaxConfiguration.TaxProvider.AVALARA) + .automaticTaxEnabled(true) .taxExemptionCode("tax_exemption_code") .build() assertThat(newAvalaraTaxConfiguration.taxExempt()).isEqualTo(true) assertThat(newAvalaraTaxConfiguration.taxProvider()) .isEqualTo(NewAvalaraTaxConfiguration.TaxProvider.AVALARA) + assertThat(newAvalaraTaxConfiguration.automaticTaxEnabled()).isEqualTo(true) assertThat(newAvalaraTaxConfiguration.taxExemptionCode()).isEqualTo("tax_exemption_code") } @@ -31,6 +33,7 @@ internal class NewAvalaraTaxConfigurationTest { NewAvalaraTaxConfiguration.builder() .taxExempt(true) .taxProvider(NewAvalaraTaxConfiguration.TaxProvider.AVALARA) + .automaticTaxEnabled(true) .taxExemptionCode("tax_exemption_code") .build() diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSphereConfigurationTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSphereConfigurationTest.kt index 49be8be28..de461f3e0 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSphereConfigurationTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSphereConfigurationTest.kt @@ -15,11 +15,13 @@ internal class NewSphereConfigurationTest { NewSphereConfiguration.builder() .taxExempt(true) .taxProvider(NewSphereConfiguration.TaxProvider.SPHERE) + .automaticTaxEnabled(true) .build() assertThat(newSphereConfiguration.taxExempt()).isEqualTo(true) assertThat(newSphereConfiguration.taxProvider()) .isEqualTo(NewSphereConfiguration.TaxProvider.SPHERE) + assertThat(newSphereConfiguration.automaticTaxEnabled()).isEqualTo(true) } @Test @@ -29,6 +31,7 @@ internal class NewSphereConfigurationTest { NewSphereConfiguration.builder() .taxExempt(true) .taxProvider(NewSphereConfiguration.TaxProvider.SPHERE) + .automaticTaxEnabled(true) .build() val roundtrippedNewSphereConfiguration = diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewTaxJarConfigurationTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewTaxJarConfigurationTest.kt index fb36e0bf7..e3014ff4c 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewTaxJarConfigurationTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewTaxJarConfigurationTest.kt @@ -15,11 +15,13 @@ internal class NewTaxJarConfigurationTest { NewTaxJarConfiguration.builder() .taxExempt(true) .taxProvider(NewTaxJarConfiguration.TaxProvider.TAXJAR) + .automaticTaxEnabled(true) .build() assertThat(newTaxJarConfiguration.taxExempt()).isEqualTo(true) assertThat(newTaxJarConfiguration.taxProvider()) .isEqualTo(NewTaxJarConfiguration.TaxProvider.TAXJAR) + assertThat(newTaxJarConfiguration.automaticTaxEnabled()).isEqualTo(true) } @Test @@ -29,6 +31,7 @@ internal class NewTaxJarConfigurationTest { NewTaxJarConfiguration.builder() .taxExempt(true) .taxProvider(NewTaxJarConfiguration.TaxProvider.TAXJAR) + .automaticTaxEnabled(true) .build() val roundtrippedNewTaxJarConfiguration = diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PerPriceCostTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PerPriceCostTest.kt index b7b01dc8f..65d21e290 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PerPriceCostTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PerPriceCostTest.kt @@ -49,6 +49,13 @@ internal class PerPriceCostTest { .durationUnit(CustomExpiration.DurationUnit.DAY) .build() ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator(Allocation.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .currency("currency") @@ -165,6 +172,13 @@ internal class PerPriceCostTest { .durationUnit(CustomExpiration.DurationUnit.DAY) .build() ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator(Allocation.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .currency("currency") @@ -285,6 +299,13 @@ internal class PerPriceCostTest { .durationUnit(CustomExpiration.DurationUnit.DAY) .build() ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator(Allocation.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .currency("currency") diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanListPageResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanListPageResponseTest.kt index 3b82b2aa9..0ec9f5f51 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanListPageResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanListPageResponseTest.kt @@ -201,6 +201,13 @@ internal class PlanListPageResponseTest { .durationUnit(CustomExpiration.DurationUnit.DAY) .build() ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator(Allocation.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .currency("currency") @@ -479,6 +486,13 @@ internal class PlanListPageResponseTest { .durationUnit(CustomExpiration.DurationUnit.DAY) .build() ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator(Allocation.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .currency("currency") @@ -765,6 +779,13 @@ internal class PlanListPageResponseTest { .durationUnit(CustomExpiration.DurationUnit.DAY) .build() ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator(Allocation.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .currency("currency") diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanTest.kt index a0607a557..e4b6d5ff8 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanTest.kt @@ -190,6 +190,13 @@ internal class PlanTest { .durationUnit(CustomExpiration.DurationUnit.DAY) .build() ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator(Allocation.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .currency("currency") @@ -469,6 +476,13 @@ internal class PlanTest { .durationUnit(CustomExpiration.DurationUnit.DAY) .build() ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator(Allocation.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .currency("currency") @@ -743,6 +757,13 @@ internal class PlanTest { .durationUnit(CustomExpiration.DurationUnit.DAY) .build() ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator(Allocation.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .currency("currency") diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanVersionTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanVersionTest.kt index 37a962bad..23e05198a 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanVersionTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanVersionTest.kt @@ -81,6 +81,13 @@ internal class PlanVersionTest { .durationUnit(CustomExpiration.DurationUnit.DAY) .build() ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator(Allocation.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .currency("currency") @@ -231,6 +238,13 @@ internal class PlanVersionTest { .durationUnit(CustomExpiration.DurationUnit.DAY) .build() ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator(Allocation.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .currency("currency") @@ -380,6 +394,13 @@ internal class PlanVersionTest { .durationUnit(CustomExpiration.DurationUnit.DAY) .build() ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator(Allocation.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .currency("currency") diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceIntervalTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceIntervalTest.kt index 46cf26a01..b0f216719 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceIntervalTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceIntervalTest.kt @@ -62,6 +62,13 @@ internal class PriceIntervalTest { .durationUnit(CustomExpiration.DurationUnit.DAY) .build() ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator(Allocation.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .currency("currency") @@ -193,6 +200,13 @@ internal class PriceIntervalTest { .durationUnit(CustomExpiration.DurationUnit.DAY) .build() ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator(Allocation.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .currency("currency") @@ -325,6 +339,13 @@ internal class PriceIntervalTest { .durationUnit(CustomExpiration.DurationUnit.DAY) .build() ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator(Allocation.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .currency("currency") diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceListPageResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceListPageResponseTest.kt index f3b1e36fb..1fb65073a 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceListPageResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceListPageResponseTest.kt @@ -49,6 +49,13 @@ internal class PriceListPageResponseTest { .durationUnit(CustomExpiration.DurationUnit.DAY) .build() ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator(Allocation.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .currency("currency") @@ -164,6 +171,13 @@ internal class PriceListPageResponseTest { .durationUnit(CustomExpiration.DurationUnit.DAY) .build() ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator(Allocation.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .currency("currency") @@ -282,6 +296,13 @@ internal class PriceListPageResponseTest { .durationUnit(CustomExpiration.DurationUnit.DAY) .build() ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator(Allocation.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .currency("currency") diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceTest.kt index bead3aa0e..096384bc4 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceTest.kt @@ -51,6 +51,13 @@ internal class PriceTest { .durationUnit(CustomExpiration.DurationUnit.DAY) .build() ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator(Allocation.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .currency("currency") @@ -197,6 +204,13 @@ internal class PriceTest { .durationUnit(CustomExpiration.DurationUnit.DAY) .build() ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator(Allocation.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .currency("currency") @@ -314,6 +328,13 @@ internal class PriceTest { .durationUnit(CustomExpiration.DurationUnit.DAY) .build() ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator(Allocation.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .currency("currency") @@ -470,6 +491,13 @@ internal class PriceTest { .durationUnit(CustomExpiration.DurationUnit.DAY) .build() ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator(Allocation.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .currency("currency") @@ -604,6 +632,13 @@ internal class PriceTest { .durationUnit(CustomExpiration.DurationUnit.DAY) .build() ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator(Allocation.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .currency("currency") @@ -759,6 +794,13 @@ internal class PriceTest { .durationUnit(CustomExpiration.DurationUnit.DAY) .build() ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator(Allocation.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .currency("currency") @@ -897,6 +939,13 @@ internal class PriceTest { .durationUnit(CustomExpiration.DurationUnit.DAY) .build() ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator(Allocation.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .currency("currency") @@ -1064,6 +1113,13 @@ internal class PriceTest { .durationUnit(CustomExpiration.DurationUnit.DAY) .build() ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator(Allocation.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .currency("currency") @@ -1180,6 +1236,13 @@ internal class PriceTest { .durationUnit(CustomExpiration.DurationUnit.DAY) .build() ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator(Allocation.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .currency("currency") @@ -1328,6 +1391,13 @@ internal class PriceTest { .durationUnit(CustomExpiration.DurationUnit.DAY) .build() ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator(Allocation.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .currency("currency") @@ -1450,6 +1520,13 @@ internal class PriceTest { .durationUnit(CustomExpiration.DurationUnit.DAY) .build() ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator(Allocation.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .currency("currency") @@ -1607,6 +1684,13 @@ internal class PriceTest { .durationUnit(CustomExpiration.DurationUnit.DAY) .build() ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator(Allocation.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .currency("currency") @@ -1735,6 +1819,13 @@ internal class PriceTest { .durationUnit(CustomExpiration.DurationUnit.DAY) .build() ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator(Allocation.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .currency("currency") @@ -1901,6 +1992,13 @@ internal class PriceTest { .durationUnit(CustomExpiration.DurationUnit.DAY) .build() ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator(Allocation.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .currency("currency") @@ -2038,6 +2136,13 @@ internal class PriceTest { .durationUnit(CustomExpiration.DurationUnit.DAY) .build() ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator(Allocation.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .currency("currency") @@ -2200,6 +2305,13 @@ internal class PriceTest { .durationUnit(CustomExpiration.DurationUnit.DAY) .build() ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator(Allocation.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .currency("currency") @@ -2333,6 +2445,13 @@ internal class PriceTest { .durationUnit(CustomExpiration.DurationUnit.DAY) .build() ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator(Allocation.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .currency("currency") @@ -2500,6 +2619,13 @@ internal class PriceTest { .durationUnit(CustomExpiration.DurationUnit.DAY) .build() ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator(Allocation.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .currency("currency") @@ -2636,6 +2762,13 @@ internal class PriceTest { .durationUnit(CustomExpiration.DurationUnit.DAY) .build() ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator(Allocation.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .currency("currency") @@ -2798,6 +2931,13 @@ internal class PriceTest { .durationUnit(CustomExpiration.DurationUnit.DAY) .build() ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator(Allocation.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .currency("currency") @@ -2933,6 +3073,13 @@ internal class PriceTest { .durationUnit(CustomExpiration.DurationUnit.DAY) .build() ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator(Allocation.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .currency("currency") @@ -3104,6 +3251,13 @@ internal class PriceTest { .durationUnit(CustomExpiration.DurationUnit.DAY) .build() ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator(Allocation.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .currency("currency") @@ -3243,6 +3397,13 @@ internal class PriceTest { .durationUnit(CustomExpiration.DurationUnit.DAY) .build() ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator(Allocation.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .currency("currency") @@ -3397,6 +3558,13 @@ internal class PriceTest { .durationUnit(CustomExpiration.DurationUnit.DAY) .build() ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator(Allocation.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .currency("currency") @@ -3520,6 +3688,13 @@ internal class PriceTest { .durationUnit(CustomExpiration.DurationUnit.DAY) .build() ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator(Allocation.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .currency("currency") @@ -3671,6 +3846,13 @@ internal class PriceTest { .durationUnit(CustomExpiration.DurationUnit.DAY) .build() ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator(Allocation.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .currency("currency") @@ -3793,6 +3975,13 @@ internal class PriceTest { .durationUnit(CustomExpiration.DurationUnit.DAY) .build() ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator(Allocation.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .currency("currency") @@ -3953,6 +4142,13 @@ internal class PriceTest { .durationUnit(CustomExpiration.DurationUnit.DAY) .build() ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator(Allocation.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .currency("currency") @@ -4082,6 +4278,13 @@ internal class PriceTest { .durationUnit(CustomExpiration.DurationUnit.DAY) .build() ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator(Allocation.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .currency("currency") @@ -4239,6 +4442,13 @@ internal class PriceTest { .durationUnit(CustomExpiration.DurationUnit.DAY) .build() ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator(Allocation.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .currency("currency") @@ -4365,6 +4575,13 @@ internal class PriceTest { .durationUnit(CustomExpiration.DurationUnit.DAY) .build() ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator(Allocation.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .currency("currency") @@ -4517,6 +4734,13 @@ internal class PriceTest { .durationUnit(CustomExpiration.DurationUnit.DAY) .build() ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator(Allocation.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .currency("currency") @@ -4638,6 +4862,13 @@ internal class PriceTest { .durationUnit(CustomExpiration.DurationUnit.DAY) .build() ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator(Allocation.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .currency("currency") @@ -4792,6 +5023,13 @@ internal class PriceTest { .durationUnit(CustomExpiration.DurationUnit.DAY) .build() ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator(Allocation.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .currency("currency") @@ -4931,6 +5169,13 @@ internal class PriceTest { .durationUnit(CustomExpiration.DurationUnit.DAY) .build() ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator(Allocation.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .currency("currency") @@ -5094,6 +5339,13 @@ internal class PriceTest { .durationUnit(CustomExpiration.DurationUnit.DAY) .build() ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator(Allocation.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .currency("currency") @@ -5212,6 +5464,13 @@ internal class PriceTest { .durationUnit(CustomExpiration.DurationUnit.DAY) .build() ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator(Allocation.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .currency("currency") @@ -5369,6 +5628,13 @@ internal class PriceTest { .durationUnit(CustomExpiration.DurationUnit.DAY) .build() ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator(Allocation.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .currency("currency") @@ -5494,6 +5760,13 @@ internal class PriceTest { .durationUnit(CustomExpiration.DurationUnit.DAY) .build() ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator(Allocation.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .currency("currency") @@ -5668,6 +5941,13 @@ internal class PriceTest { .durationUnit(CustomExpiration.DurationUnit.DAY) .build() ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator(Allocation.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .currency("currency") @@ -5812,6 +6092,13 @@ internal class PriceTest { .durationUnit(CustomExpiration.DurationUnit.DAY) .build() ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator(Allocation.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .currency("currency") @@ -5971,6 +6258,13 @@ internal class PriceTest { .durationUnit(CustomExpiration.DurationUnit.DAY) .build() ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator(Allocation.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .currency("currency") @@ -6098,6 +6392,13 @@ internal class PriceTest { .durationUnit(CustomExpiration.DurationUnit.DAY) .build() ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator(Allocation.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .currency("currency") @@ -6258,6 +6559,13 @@ internal class PriceTest { .durationUnit(CustomExpiration.DurationUnit.DAY) .build() ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator(Allocation.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .currency("currency") @@ -6387,6 +6695,13 @@ internal class PriceTest { .durationUnit(CustomExpiration.DurationUnit.DAY) .build() ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator(Allocation.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .currency("currency") @@ -6552,6 +6867,13 @@ internal class PriceTest { .durationUnit(CustomExpiration.DurationUnit.DAY) .build() ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator(Allocation.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .currency("currency") @@ -6688,6 +7010,13 @@ internal class PriceTest { .durationUnit(CustomExpiration.DurationUnit.DAY) .build() ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator(Allocation.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .currency("currency") @@ -6853,6 +7182,13 @@ internal class PriceTest { .durationUnit(CustomExpiration.DurationUnit.DAY) .build() ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator(Allocation.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .currency("currency") @@ -6994,6 +7330,13 @@ internal class PriceTest { .durationUnit(CustomExpiration.DurationUnit.DAY) .build() ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator(Allocation.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .currency("currency") @@ -7163,6 +7506,13 @@ internal class PriceTest { .durationUnit(CustomExpiration.DurationUnit.DAY) .build() ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator(Allocation.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .currency("currency") @@ -7304,6 +7654,13 @@ internal class PriceTest { .durationUnit(CustomExpiration.DurationUnit.DAY) .build() ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator(Allocation.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .currency("currency") @@ -7491,6 +7848,13 @@ internal class PriceTest { .durationUnit(CustomExpiration.DurationUnit.DAY) .build() ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator(Allocation.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .currency("currency") @@ -7644,6 +8008,13 @@ internal class PriceTest { .durationUnit(CustomExpiration.DurationUnit.DAY) .build() ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator(Allocation.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .cumulativeGroupedBulkConfig( @@ -7804,6 +8175,13 @@ internal class PriceTest { .durationUnit(CustomExpiration.DurationUnit.DAY) .build() ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator(Allocation.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .cumulativeGroupedBulkConfig( @@ -7934,6 +8312,13 @@ internal class PriceTest { .durationUnit(CustomExpiration.DurationUnit.DAY) .build() ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator(Allocation.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .currency("currency") @@ -8085,6 +8470,13 @@ internal class PriceTest { .durationUnit(CustomExpiration.DurationUnit.DAY) .build() ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator(Allocation.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .currency("currency") @@ -8207,6 +8599,13 @@ internal class PriceTest { .durationUnit(CustomExpiration.DurationUnit.DAY) .build() ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator(Allocation.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .currency("currency") @@ -8353,6 +8752,13 @@ internal class PriceTest { .durationUnit(CustomExpiration.DurationUnit.DAY) .build() ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator(Allocation.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .currency("currency") @@ -8470,6 +8876,13 @@ internal class PriceTest { .durationUnit(CustomExpiration.DurationUnit.DAY) .build() ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator(Allocation.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .currency("currency") @@ -8622,6 +9035,13 @@ internal class PriceTest { .durationUnit(CustomExpiration.DurationUnit.DAY) .build() ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator(Allocation.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .currency("currency") diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeApplyResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeApplyResponseTest.kt index 2f7d74045..c3f232454 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeApplyResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeApplyResponseTest.kt @@ -157,6 +157,7 @@ internal class SubscriptionChangeApplyResponseTest { .excluded(true) .build() ) + .automaticTaxEnabled(true) .reportingConfiguration( Customer.ReportingConfiguration.builder().exempt(true).build() ) @@ -435,6 +436,15 @@ internal class SubscriptionChangeApplyResponseTest { ) .build() ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator( + Allocation.Filter.Operator.INCLUDES + ) + .addValue("string") + .build() + ) .build() ) .currency("currency") @@ -610,6 +620,15 @@ internal class SubscriptionChangeApplyResponseTest { ) .build() ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator( + Allocation.Filter.Operator.INCLUDES + ) + .addValue("string") + .build() + ) .build() ) .currency("currency") @@ -1135,6 +1154,20 @@ internal class SubscriptionChangeApplyResponseTest { ) .build() ) + .addFilter( + Allocation.Filter.builder() + .field( + Allocation.Filter.Field + .PRICE_ID + ) + .operator( + Allocation.Filter + .Operator + .INCLUDES + ) + .addValue("string") + .build() + ) .build() ) .currency("currency") @@ -1792,6 +1825,20 @@ internal class SubscriptionChangeApplyResponseTest { ) .build() ) + .addFilter( + Allocation.Filter.builder() + .field( + Allocation.Filter.Field + .PRICE_ID + ) + .operator( + Allocation.Filter + .Operator + .INCLUDES + ) + .addValue("string") + .build() + ) .build() ) .currency("currency") @@ -2185,6 +2232,7 @@ internal class SubscriptionChangeApplyResponseTest { .excluded(true) .build() ) + .automaticTaxEnabled(true) .reportingConfiguration( Customer.ReportingConfiguration.builder().exempt(true).build() ) @@ -2451,6 +2499,13 @@ internal class SubscriptionChangeApplyResponseTest { .durationUnit(CustomExpiration.DurationUnit.DAY) .build() ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator(Allocation.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .currency("currency") @@ -2609,6 +2664,13 @@ internal class SubscriptionChangeApplyResponseTest { .durationUnit(CustomExpiration.DurationUnit.DAY) .build() ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator(Allocation.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .currency("currency") @@ -3092,6 +3154,19 @@ internal class SubscriptionChangeApplyResponseTest { ) .build() ) + .addFilter( + Allocation.Filter.builder() + .field( + Allocation.Filter.Field + .PRICE_ID + ) + .operator( + Allocation.Filter.Operator + .INCLUDES + ) + .addValue("string") + .build() + ) .build() ) .currency("currency") @@ -3698,6 +3773,19 @@ internal class SubscriptionChangeApplyResponseTest { ) .build() ) + .addFilter( + Allocation.Filter.builder() + .field( + Allocation.Filter.Field + .PRICE_ID + ) + .operator( + Allocation.Filter.Operator + .INCLUDES + ) + .addValue("string") + .build() + ) .build() ) .currency("currency") @@ -4089,6 +4177,7 @@ internal class SubscriptionChangeApplyResponseTest { .excluded(true) .build() ) + .automaticTaxEnabled(true) .reportingConfiguration( Customer.ReportingConfiguration.builder().exempt(true).build() ) @@ -4367,6 +4456,15 @@ internal class SubscriptionChangeApplyResponseTest { ) .build() ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator( + Allocation.Filter.Operator.INCLUDES + ) + .addValue("string") + .build() + ) .build() ) .currency("currency") @@ -4542,6 +4640,15 @@ internal class SubscriptionChangeApplyResponseTest { ) .build() ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator( + Allocation.Filter.Operator.INCLUDES + ) + .addValue("string") + .build() + ) .build() ) .currency("currency") @@ -5067,6 +5174,20 @@ internal class SubscriptionChangeApplyResponseTest { ) .build() ) + .addFilter( + Allocation.Filter.builder() + .field( + Allocation.Filter.Field + .PRICE_ID + ) + .operator( + Allocation.Filter + .Operator + .INCLUDES + ) + .addValue("string") + .build() + ) .build() ) .currency("currency") @@ -5724,6 +5845,20 @@ internal class SubscriptionChangeApplyResponseTest { ) .build() ) + .addFilter( + Allocation.Filter.builder() + .field( + Allocation.Filter.Field + .PRICE_ID + ) + .operator( + Allocation.Filter + .Operator + .INCLUDES + ) + .addValue("string") + .build() + ) .build() ) .currency("currency") diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeCancelResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeCancelResponseTest.kt index 695838c40..a131f96da 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeCancelResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeCancelResponseTest.kt @@ -157,6 +157,7 @@ internal class SubscriptionChangeCancelResponseTest { .excluded(true) .build() ) + .automaticTaxEnabled(true) .reportingConfiguration( Customer.ReportingConfiguration.builder().exempt(true).build() ) @@ -435,6 +436,15 @@ internal class SubscriptionChangeCancelResponseTest { ) .build() ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator( + Allocation.Filter.Operator.INCLUDES + ) + .addValue("string") + .build() + ) .build() ) .currency("currency") @@ -610,6 +620,15 @@ internal class SubscriptionChangeCancelResponseTest { ) .build() ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator( + Allocation.Filter.Operator.INCLUDES + ) + .addValue("string") + .build() + ) .build() ) .currency("currency") @@ -1135,6 +1154,20 @@ internal class SubscriptionChangeCancelResponseTest { ) .build() ) + .addFilter( + Allocation.Filter.builder() + .field( + Allocation.Filter.Field + .PRICE_ID + ) + .operator( + Allocation.Filter + .Operator + .INCLUDES + ) + .addValue("string") + .build() + ) .build() ) .currency("currency") @@ -1792,6 +1825,20 @@ internal class SubscriptionChangeCancelResponseTest { ) .build() ) + .addFilter( + Allocation.Filter.builder() + .field( + Allocation.Filter.Field + .PRICE_ID + ) + .operator( + Allocation.Filter + .Operator + .INCLUDES + ) + .addValue("string") + .build() + ) .build() ) .currency("currency") @@ -2185,6 +2232,7 @@ internal class SubscriptionChangeCancelResponseTest { .excluded(true) .build() ) + .automaticTaxEnabled(true) .reportingConfiguration( Customer.ReportingConfiguration.builder().exempt(true).build() ) @@ -2451,6 +2499,13 @@ internal class SubscriptionChangeCancelResponseTest { .durationUnit(CustomExpiration.DurationUnit.DAY) .build() ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator(Allocation.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .currency("currency") @@ -2609,6 +2664,13 @@ internal class SubscriptionChangeCancelResponseTest { .durationUnit(CustomExpiration.DurationUnit.DAY) .build() ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator(Allocation.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .currency("currency") @@ -3092,6 +3154,19 @@ internal class SubscriptionChangeCancelResponseTest { ) .build() ) + .addFilter( + Allocation.Filter.builder() + .field( + Allocation.Filter.Field + .PRICE_ID + ) + .operator( + Allocation.Filter.Operator + .INCLUDES + ) + .addValue("string") + .build() + ) .build() ) .currency("currency") @@ -3698,6 +3773,19 @@ internal class SubscriptionChangeCancelResponseTest { ) .build() ) + .addFilter( + Allocation.Filter.builder() + .field( + Allocation.Filter.Field + .PRICE_ID + ) + .operator( + Allocation.Filter.Operator + .INCLUDES + ) + .addValue("string") + .build() + ) .build() ) .currency("currency") @@ -4089,6 +4177,7 @@ internal class SubscriptionChangeCancelResponseTest { .excluded(true) .build() ) + .automaticTaxEnabled(true) .reportingConfiguration( Customer.ReportingConfiguration.builder().exempt(true).build() ) @@ -4367,6 +4456,15 @@ internal class SubscriptionChangeCancelResponseTest { ) .build() ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator( + Allocation.Filter.Operator.INCLUDES + ) + .addValue("string") + .build() + ) .build() ) .currency("currency") @@ -4542,6 +4640,15 @@ internal class SubscriptionChangeCancelResponseTest { ) .build() ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator( + Allocation.Filter.Operator.INCLUDES + ) + .addValue("string") + .build() + ) .build() ) .currency("currency") @@ -5067,6 +5174,20 @@ internal class SubscriptionChangeCancelResponseTest { ) .build() ) + .addFilter( + Allocation.Filter.builder() + .field( + Allocation.Filter.Field + .PRICE_ID + ) + .operator( + Allocation.Filter + .Operator + .INCLUDES + ) + .addValue("string") + .build() + ) .build() ) .currency("currency") @@ -5724,6 +5845,20 @@ internal class SubscriptionChangeCancelResponseTest { ) .build() ) + .addFilter( + Allocation.Filter.builder() + .field( + Allocation.Filter.Field + .PRICE_ID + ) + .operator( + Allocation.Filter + .Operator + .INCLUDES + ) + .addValue("string") + .build() + ) .build() ) .currency("currency") diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeRetrieveResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeRetrieveResponseTest.kt index 3fc962215..c7892bd94 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeRetrieveResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeRetrieveResponseTest.kt @@ -157,6 +157,7 @@ internal class SubscriptionChangeRetrieveResponseTest { .excluded(true) .build() ) + .automaticTaxEnabled(true) .reportingConfiguration( Customer.ReportingConfiguration.builder().exempt(true).build() ) @@ -435,6 +436,15 @@ internal class SubscriptionChangeRetrieveResponseTest { ) .build() ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator( + Allocation.Filter.Operator.INCLUDES + ) + .addValue("string") + .build() + ) .build() ) .currency("currency") @@ -610,6 +620,15 @@ internal class SubscriptionChangeRetrieveResponseTest { ) .build() ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator( + Allocation.Filter.Operator.INCLUDES + ) + .addValue("string") + .build() + ) .build() ) .currency("currency") @@ -1135,6 +1154,20 @@ internal class SubscriptionChangeRetrieveResponseTest { ) .build() ) + .addFilter( + Allocation.Filter.builder() + .field( + Allocation.Filter.Field + .PRICE_ID + ) + .operator( + Allocation.Filter + .Operator + .INCLUDES + ) + .addValue("string") + .build() + ) .build() ) .currency("currency") @@ -1792,6 +1825,20 @@ internal class SubscriptionChangeRetrieveResponseTest { ) .build() ) + .addFilter( + Allocation.Filter.builder() + .field( + Allocation.Filter.Field + .PRICE_ID + ) + .operator( + Allocation.Filter + .Operator + .INCLUDES + ) + .addValue("string") + .build() + ) .build() ) .currency("currency") @@ -2185,6 +2232,7 @@ internal class SubscriptionChangeRetrieveResponseTest { .excluded(true) .build() ) + .automaticTaxEnabled(true) .reportingConfiguration( Customer.ReportingConfiguration.builder().exempt(true).build() ) @@ -2451,6 +2499,13 @@ internal class SubscriptionChangeRetrieveResponseTest { .durationUnit(CustomExpiration.DurationUnit.DAY) .build() ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator(Allocation.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .currency("currency") @@ -2609,6 +2664,13 @@ internal class SubscriptionChangeRetrieveResponseTest { .durationUnit(CustomExpiration.DurationUnit.DAY) .build() ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator(Allocation.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .currency("currency") @@ -3092,6 +3154,19 @@ internal class SubscriptionChangeRetrieveResponseTest { ) .build() ) + .addFilter( + Allocation.Filter.builder() + .field( + Allocation.Filter.Field + .PRICE_ID + ) + .operator( + Allocation.Filter.Operator + .INCLUDES + ) + .addValue("string") + .build() + ) .build() ) .currency("currency") @@ -3698,6 +3773,19 @@ internal class SubscriptionChangeRetrieveResponseTest { ) .build() ) + .addFilter( + Allocation.Filter.builder() + .field( + Allocation.Filter.Field + .PRICE_ID + ) + .operator( + Allocation.Filter.Operator + .INCLUDES + ) + .addValue("string") + .build() + ) .build() ) .currency("currency") @@ -4089,6 +4177,7 @@ internal class SubscriptionChangeRetrieveResponseTest { .excluded(true) .build() ) + .automaticTaxEnabled(true) .reportingConfiguration( Customer.ReportingConfiguration.builder().exempt(true).build() ) @@ -4367,6 +4456,15 @@ internal class SubscriptionChangeRetrieveResponseTest { ) .build() ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator( + Allocation.Filter.Operator.INCLUDES + ) + .addValue("string") + .build() + ) .build() ) .currency("currency") @@ -4542,6 +4640,15 @@ internal class SubscriptionChangeRetrieveResponseTest { ) .build() ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator( + Allocation.Filter.Operator.INCLUDES + ) + .addValue("string") + .build() + ) .build() ) .currency("currency") @@ -5067,6 +5174,20 @@ internal class SubscriptionChangeRetrieveResponseTest { ) .build() ) + .addFilter( + Allocation.Filter.builder() + .field( + Allocation.Filter.Field + .PRICE_ID + ) + .operator( + Allocation.Filter + .Operator + .INCLUDES + ) + .addValue("string") + .build() + ) .build() ) .currency("currency") @@ -5724,6 +5845,20 @@ internal class SubscriptionChangeRetrieveResponseTest { ) .build() ) + .addFilter( + Allocation.Filter.builder() + .field( + Allocation.Filter.Field + .PRICE_ID + ) + .operator( + Allocation.Filter + .Operator + .INCLUDES + ) + .addValue("string") + .build() + ) .build() ) .currency("currency") diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionFetchCostsResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionFetchCostsResponseTest.kt index 19e7d5af8..418914e3a 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionFetchCostsResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionFetchCostsResponseTest.kt @@ -66,6 +66,15 @@ internal class SubscriptionFetchCostsResponseTest { ) .build() ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator( + Allocation.Filter.Operator.INCLUDES + ) + .addValue("string") + .build() + ) .build() ) .currency("currency") @@ -215,6 +224,13 @@ internal class SubscriptionFetchCostsResponseTest { .durationUnit(CustomExpiration.DurationUnit.DAY) .build() ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator(Allocation.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .currency("currency") @@ -367,6 +383,15 @@ internal class SubscriptionFetchCostsResponseTest { ) .build() ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator( + Allocation.Filter.Operator.INCLUDES + ) + .addValue("string") + .build() + ) .build() ) .currency("currency") diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionTest.kt index 667ed170b..73abfc7bd 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionTest.kt @@ -141,6 +141,7 @@ internal class SubscriptionTest { .excluded(true) .build() ) + .automaticTaxEnabled(true) .reportingConfiguration( Customer.ReportingConfiguration.builder().exempt(true).build() ) @@ -397,6 +398,13 @@ internal class SubscriptionTest { .durationUnit(CustomExpiration.DurationUnit.DAY) .build() ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator(Allocation.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .currency("currency") @@ -545,6 +553,13 @@ internal class SubscriptionTest { .durationUnit(CustomExpiration.DurationUnit.DAY) .build() ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator(Allocation.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .currency("currency") @@ -767,6 +782,7 @@ internal class SubscriptionTest { .excluded(true) .build() ) + .automaticTaxEnabled(true) .reportingConfiguration( Customer.ReportingConfiguration.builder().exempt(true).build() ) @@ -1026,6 +1042,13 @@ internal class SubscriptionTest { .durationUnit(CustomExpiration.DurationUnit.DAY) .build() ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator(Allocation.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .currency("currency") @@ -1167,6 +1190,13 @@ internal class SubscriptionTest { .durationUnit(CustomExpiration.DurationUnit.DAY) .build() ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator(Allocation.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .currency("currency") @@ -1395,6 +1425,7 @@ internal class SubscriptionTest { .excluded(true) .build() ) + .automaticTaxEnabled(true) .reportingConfiguration( Customer.ReportingConfiguration.builder().exempt(true).build() ) @@ -1651,6 +1682,13 @@ internal class SubscriptionTest { .durationUnit(CustomExpiration.DurationUnit.DAY) .build() ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator(Allocation.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .currency("currency") @@ -1799,6 +1837,13 @@ internal class SubscriptionTest { .durationUnit(CustomExpiration.DurationUnit.DAY) .build() ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator(Allocation.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .currency("currency") diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionsTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionsTest.kt index ca5b345ec..1c102584d 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionsTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionsTest.kt @@ -154,6 +154,7 @@ internal class SubscriptionsTest { .excluded(true) .build() ) + .automaticTaxEnabled(true) .reportingConfiguration( Customer.ReportingConfiguration.builder().exempt(true).build() ) @@ -432,6 +433,15 @@ internal class SubscriptionsTest { ) .build() ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator( + Allocation.Filter.Operator.INCLUDES + ) + .addValue("string") + .build() + ) .build() ) .currency("currency") @@ -607,6 +617,15 @@ internal class SubscriptionsTest { ) .build() ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator( + Allocation.Filter.Operator.INCLUDES + ) + .addValue("string") + .build() + ) .build() ) .currency("currency") @@ -854,6 +873,7 @@ internal class SubscriptionsTest { .excluded(true) .build() ) + .automaticTaxEnabled(true) .reportingConfiguration( Customer.ReportingConfiguration.builder().exempt(true).build() ) @@ -1120,6 +1140,13 @@ internal class SubscriptionsTest { .durationUnit(CustomExpiration.DurationUnit.DAY) .build() ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator(Allocation.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .currency("currency") @@ -1278,6 +1305,13 @@ internal class SubscriptionsTest { .durationUnit(CustomExpiration.DurationUnit.DAY) .build() ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator(Allocation.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .currency("currency") @@ -1528,6 +1562,7 @@ internal class SubscriptionsTest { .excluded(true) .build() ) + .automaticTaxEnabled(true) .reportingConfiguration( Customer.ReportingConfiguration.builder().exempt(true).build() ) @@ -1806,6 +1841,15 @@ internal class SubscriptionsTest { ) .build() ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator( + Allocation.Filter.Operator.INCLUDES + ) + .addValue("string") + .build() + ) .build() ) .currency("currency") @@ -1981,6 +2025,15 @@ internal class SubscriptionsTest { ) .build() ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator( + Allocation.Filter.Operator.INCLUDES + ) + .addValue("string") + .build() + ) .build() ) .currency("currency") diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/VoidInitiatedLedgerEntryTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/VoidInitiatedLedgerEntryTest.kt index 4cd12168c..c3fb9e8e9 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/VoidInitiatedLedgerEntryTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/VoidInitiatedLedgerEntryTest.kt @@ -21,14 +21,14 @@ internal class VoidInitiatedLedgerEntryTest { .creditBlock( AffectedBlock.builder() .id("id") - .addBlockFilter( - AffectedBlock.BlockFilter.builder() - .field(AffectedBlock.BlockFilter.Field.PRICE_ID) - .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addFilter( + AffectedBlock.Filter.builder() + .field(AffectedBlock.Filter.Field.PRICE_ID) + .operator(AffectedBlock.Filter.Operator.INCLUDES) .addValue("string") .build() ) - .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -63,14 +63,14 @@ internal class VoidInitiatedLedgerEntryTest { .isEqualTo( AffectedBlock.builder() .id("id") - .addBlockFilter( - AffectedBlock.BlockFilter.builder() - .field(AffectedBlock.BlockFilter.Field.PRICE_ID) - .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addFilter( + AffectedBlock.Filter.builder() + .field(AffectedBlock.Filter.Field.PRICE_ID) + .operator(AffectedBlock.Filter.Operator.INCLUDES) .addValue("string") .build() ) - .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -113,14 +113,14 @@ internal class VoidInitiatedLedgerEntryTest { .creditBlock( AffectedBlock.builder() .id("id") - .addBlockFilter( - AffectedBlock.BlockFilter.builder() - .field(AffectedBlock.BlockFilter.Field.PRICE_ID) - .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addFilter( + AffectedBlock.Filter.builder() + .field(AffectedBlock.Filter.Field.PRICE_ID) + .operator(AffectedBlock.Filter.Operator.INCLUDES) .addValue("string") .build() ) - .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() ) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/VoidLedgerEntryTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/VoidLedgerEntryTest.kt index 22771a63b..a6e83d0a1 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/VoidLedgerEntryTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/VoidLedgerEntryTest.kt @@ -21,14 +21,14 @@ internal class VoidLedgerEntryTest { .creditBlock( AffectedBlock.builder() .id("id") - .addBlockFilter( - AffectedBlock.BlockFilter.builder() - .field(AffectedBlock.BlockFilter.Field.PRICE_ID) - .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addFilter( + AffectedBlock.Filter.builder() + .field(AffectedBlock.Filter.Field.PRICE_ID) + .operator(AffectedBlock.Filter.Operator.INCLUDES) .addValue("string") .build() ) - .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -62,14 +62,14 @@ internal class VoidLedgerEntryTest { .isEqualTo( AffectedBlock.builder() .id("id") - .addBlockFilter( - AffectedBlock.BlockFilter.builder() - .field(AffectedBlock.BlockFilter.Field.PRICE_ID) - .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addFilter( + AffectedBlock.Filter.builder() + .field(AffectedBlock.Filter.Field.PRICE_ID) + .operator(AffectedBlock.Filter.Operator.INCLUDES) .addValue("string") .build() ) - .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -108,14 +108,14 @@ internal class VoidLedgerEntryTest { .creditBlock( AffectedBlock.builder() .id("id") - .addBlockFilter( - AffectedBlock.BlockFilter.builder() - .field(AffectedBlock.BlockFilter.Field.PRICE_ID) - .operator(AffectedBlock.BlockFilter.Operator.INCLUDES) + .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addFilter( + AffectedBlock.Filter.builder() + .field(AffectedBlock.Filter.Field.PRICE_ID) + .operator(AffectedBlock.Filter.Operator.INCLUDES) .addValue("string") .build() ) - .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") .build() ) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/ErrorHandlingTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/ErrorHandlingTest.kt index eb972aae9..cf76a00d2 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/ErrorHandlingTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/ErrorHandlingTest.kt @@ -138,6 +138,7 @@ internal class ErrorHandlingTest { NewAvalaraTaxConfiguration.builder() .taxExempt(true) .taxProvider(NewAvalaraTaxConfiguration.TaxProvider.AVALARA) + .automaticTaxEnabled(true) .taxExemptionCode("tax_exemption_code") .build() ) @@ -231,6 +232,7 @@ internal class ErrorHandlingTest { NewAvalaraTaxConfiguration.builder() .taxExempt(true) .taxProvider(NewAvalaraTaxConfiguration.TaxProvider.AVALARA) + .automaticTaxEnabled(true) .taxExemptionCode("tax_exemption_code") .build() ) @@ -324,6 +326,7 @@ internal class ErrorHandlingTest { NewAvalaraTaxConfiguration.builder() .taxExempt(true) .taxProvider(NewAvalaraTaxConfiguration.TaxProvider.AVALARA) + .automaticTaxEnabled(true) .taxExemptionCode("tax_exemption_code") .build() ) @@ -417,6 +420,7 @@ internal class ErrorHandlingTest { NewAvalaraTaxConfiguration.builder() .taxExempt(true) .taxProvider(NewAvalaraTaxConfiguration.TaxProvider.AVALARA) + .automaticTaxEnabled(true) .taxExemptionCode("tax_exemption_code") .build() ) @@ -510,6 +514,7 @@ internal class ErrorHandlingTest { NewAvalaraTaxConfiguration.builder() .taxExempt(true) .taxProvider(NewAvalaraTaxConfiguration.TaxProvider.AVALARA) + .automaticTaxEnabled(true) .taxExemptionCode("tax_exemption_code") .build() ) @@ -603,6 +608,7 @@ internal class ErrorHandlingTest { NewAvalaraTaxConfiguration.builder() .taxExempt(true) .taxProvider(NewAvalaraTaxConfiguration.TaxProvider.AVALARA) + .automaticTaxEnabled(true) .taxExemptionCode("tax_exemption_code") .build() ) @@ -696,6 +702,7 @@ internal class ErrorHandlingTest { NewAvalaraTaxConfiguration.builder() .taxExempt(true) .taxProvider(NewAvalaraTaxConfiguration.TaxProvider.AVALARA) + .automaticTaxEnabled(true) .taxExemptionCode("tax_exemption_code") .build() ) @@ -789,6 +796,7 @@ internal class ErrorHandlingTest { NewAvalaraTaxConfiguration.builder() .taxExempt(true) .taxProvider(NewAvalaraTaxConfiguration.TaxProvider.AVALARA) + .automaticTaxEnabled(true) .taxExemptionCode("tax_exemption_code") .build() ) @@ -882,6 +890,7 @@ internal class ErrorHandlingTest { NewAvalaraTaxConfiguration.builder() .taxExempt(true) .taxProvider(NewAvalaraTaxConfiguration.TaxProvider.AVALARA) + .automaticTaxEnabled(true) .taxExemptionCode("tax_exemption_code") .build() ) @@ -975,6 +984,7 @@ internal class ErrorHandlingTest { NewAvalaraTaxConfiguration.builder() .taxExempt(true) .taxProvider(NewAvalaraTaxConfiguration.TaxProvider.AVALARA) + .automaticTaxEnabled(true) .taxExemptionCode("tax_exemption_code") .build() ) @@ -1068,6 +1078,7 @@ internal class ErrorHandlingTest { NewAvalaraTaxConfiguration.builder() .taxExempt(true) .taxProvider(NewAvalaraTaxConfiguration.TaxProvider.AVALARA) + .automaticTaxEnabled(true) .taxExemptionCode("tax_exemption_code") .build() ) @@ -1161,6 +1172,7 @@ internal class ErrorHandlingTest { NewAvalaraTaxConfiguration.builder() .taxExempt(true) .taxProvider(NewAvalaraTaxConfiguration.TaxProvider.AVALARA) + .automaticTaxEnabled(true) .taxExemptionCode("tax_exemption_code") .build() ) @@ -1254,6 +1266,7 @@ internal class ErrorHandlingTest { NewAvalaraTaxConfiguration.builder() .taxExempt(true) .taxProvider(NewAvalaraTaxConfiguration.TaxProvider.AVALARA) + .automaticTaxEnabled(true) .taxExemptionCode("tax_exemption_code") .build() ) @@ -1347,6 +1360,7 @@ internal class ErrorHandlingTest { NewAvalaraTaxConfiguration.builder() .taxExempt(true) .taxProvider(NewAvalaraTaxConfiguration.TaxProvider.AVALARA) + .automaticTaxEnabled(true) .taxExemptionCode("tax_exemption_code") .build() ) @@ -1440,6 +1454,7 @@ internal class ErrorHandlingTest { NewAvalaraTaxConfiguration.builder() .taxExempt(true) .taxProvider(NewAvalaraTaxConfiguration.TaxProvider.AVALARA) + .automaticTaxEnabled(true) .taxExemptionCode("tax_exemption_code") .build() ) @@ -1533,6 +1548,7 @@ internal class ErrorHandlingTest { NewAvalaraTaxConfiguration.builder() .taxExempt(true) .taxProvider(NewAvalaraTaxConfiguration.TaxProvider.AVALARA) + .automaticTaxEnabled(true) .taxExemptionCode("tax_exemption_code") .build() ) @@ -1624,6 +1640,7 @@ internal class ErrorHandlingTest { NewAvalaraTaxConfiguration.builder() .taxExempt(true) .taxProvider(NewAvalaraTaxConfiguration.TaxProvider.AVALARA) + .automaticTaxEnabled(true) .taxExemptionCode("tax_exemption_code") .build() ) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/ServiceParamsTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/ServiceParamsTest.kt index a331a786f..b2299454b 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/ServiceParamsTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/ServiceParamsTest.kt @@ -106,6 +106,7 @@ internal class ServiceParamsTest { NewAvalaraTaxConfiguration.builder() .taxExempt(true) .taxProvider(NewAvalaraTaxConfiguration.TaxProvider.AVALARA) + .automaticTaxEnabled(true) .taxExemptionCode("tax_exemption_code") .build() ) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/CustomerServiceAsyncTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/CustomerServiceAsyncTest.kt index bc800155a..99f3b6429 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/CustomerServiceAsyncTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/CustomerServiceAsyncTest.kt @@ -92,6 +92,7 @@ internal class CustomerServiceAsyncTest { NewAvalaraTaxConfiguration.builder() .taxExempt(true) .taxProvider(NewAvalaraTaxConfiguration.TaxProvider.AVALARA) + .automaticTaxEnabled(true) .taxExemptionCode("tax_exemption_code") .build() ) @@ -136,6 +137,7 @@ internal class CustomerServiceAsyncTest { .addAdditionalEmail("string") .autoCollection(true) .autoIssuance(true) + .automaticTaxEnabled(true) .billingAddress( AddressInput.builder() .city("city") @@ -181,6 +183,7 @@ internal class CustomerServiceAsyncTest { NewAvalaraTaxConfiguration.builder() .taxExempt(true) .taxProvider(NewAvalaraTaxConfiguration.TaxProvider.AVALARA) + .automaticTaxEnabled(true) .taxExemptionCode("tax_exemption_code") .build() ) @@ -304,6 +307,7 @@ internal class CustomerServiceAsyncTest { .addAdditionalEmail("string") .autoCollection(true) .autoIssuance(true) + .automaticTaxEnabled(true) .billingAddress( AddressInput.builder() .city("city") @@ -349,6 +353,7 @@ internal class CustomerServiceAsyncTest { NewAvalaraTaxConfiguration.builder() .taxExempt(true) .taxProvider(NewAvalaraTaxConfiguration.TaxProvider.AVALARA) + .automaticTaxEnabled(true) .taxExemptionCode("tax_exemption_code") .build() ) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/CustomerServiceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/CustomerServiceTest.kt index 8838c4b68..9d900c96f 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/CustomerServiceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/CustomerServiceTest.kt @@ -92,6 +92,7 @@ internal class CustomerServiceTest { NewAvalaraTaxConfiguration.builder() .taxExempt(true) .taxProvider(NewAvalaraTaxConfiguration.TaxProvider.AVALARA) + .automaticTaxEnabled(true) .taxExemptionCode("tax_exemption_code") .build() ) @@ -136,6 +137,7 @@ internal class CustomerServiceTest { .addAdditionalEmail("string") .autoCollection(true) .autoIssuance(true) + .automaticTaxEnabled(true) .billingAddress( AddressInput.builder() .city("city") @@ -181,6 +183,7 @@ internal class CustomerServiceTest { NewAvalaraTaxConfiguration.builder() .taxExempt(true) .taxProvider(NewAvalaraTaxConfiguration.TaxProvider.AVALARA) + .automaticTaxEnabled(true) .taxExemptionCode("tax_exemption_code") .build() ) @@ -302,6 +305,7 @@ internal class CustomerServiceTest { .addAdditionalEmail("string") .autoCollection(true) .autoIssuance(true) + .automaticTaxEnabled(true) .billingAddress( AddressInput.builder() .city("city") @@ -347,6 +351,7 @@ internal class CustomerServiceTest { NewAvalaraTaxConfiguration.builder() .taxExempt(true) .taxProvider(NewAvalaraTaxConfiguration.TaxProvider.AVALARA) + .automaticTaxEnabled(true) .taxExemptionCode("tax_exemption_code") .build() ) From 83ad00cb56d547e695b01e7e02e923247856f3c8 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 30 Oct 2025 22:33:22 +0000 Subject: [PATCH 39/68] feat(api): api update --- .stats.yml | 4 +- .../withorb/api/models/InvoiceUpdateParams.kt | 273 +++++++++++++++++- .../api/services/async/InvoiceServiceAsync.kt | 11 +- .../api/services/blocking/InvoiceService.kt | 11 +- .../api/models/InvoiceUpdateParamsTest.kt | 4 + .../services/async/InvoiceServiceAsyncTest.kt | 1 + .../services/blocking/InvoiceServiceTest.kt | 1 + 7 files changed, 284 insertions(+), 21 deletions(-) diff --git a/.stats.yml b/.stats.yml index 33d3b4693..49f0b44f3 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 118 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-ef726ad139fa29757029206ee08150434fc6c52005fec6d42c7d2bcd3aa7ab47.yml -openapi_spec_hash: e622beb7c26f9b0dd641bd5c92735a5b +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-faf1f7c723d2762f09e9690ef2ceda58cb0a6ddacf1a79c3754871b90e7db0dc.yml +openapi_spec_hash: 22269f85fae1ec920bdb0b32435a7aa8 config_hash: dd4343ce95871032ef6e0735a4ca038c diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceUpdateParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceUpdateParams.kt index 5a3a8db24..9406557a7 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceUpdateParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceUpdateParams.kt @@ -32,12 +32,13 @@ import java.util.Collections import java.util.Objects /** - * This endpoint allows you to update the `metadata`, `net_terms`, and `due_date` properties on an - * invoice. If you pass null for the metadata value, it will clear any existing metadata for that - * invoice. + * This endpoint allows you to update the `metadata`, `net_terms`, `due_date`, and `invoice_date` + * properties on an invoice. If you pass null for the metadata value, it will clear any existing + * metadata for that invoice. * - * `metadata` can be modified regardless of invoice state. `net_terms` and `due_date` can only be - * modified if the invoice is in a `draft` state. + * `metadata` can be modified regardless of invoice state. `net_terms`, `due_date`, and + * `invoice_date` can only be modified if the invoice is in a `draft` state. `invoice_date` can only + * be modified for non-subscription invoices. */ class InvoiceUpdateParams private constructor( @@ -58,6 +59,14 @@ private constructor( */ fun dueDate(): DueDate? = body.dueDate() + /** + * The date of the invoice. Can only be modified for one-off draft invoices. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun invoiceDate(): InvoiceDate? = body.invoiceDate() + /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to @@ -87,6 +96,13 @@ private constructor( */ fun _dueDate(): JsonField = body._dueDate() + /** + * Returns the raw JSON value of [invoiceDate]. + * + * Unlike [invoiceDate], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _invoiceDate(): JsonField = body._invoiceDate() + /** * Returns the raw JSON value of [metadata]. * @@ -142,6 +158,7 @@ private constructor( * This is generally only useful if you are already constructing the body separately. * Otherwise, it's more convenient to use the top-level setters instead: * - [dueDate] + * - [invoiceDate] * - [metadata] * - [netTerms] */ @@ -167,6 +184,26 @@ private constructor( /** Alias for calling [dueDate] with `DueDate.ofDateTime(dateTime)`. */ fun dueDate(dateTime: OffsetDateTime) = apply { body.dueDate(dateTime) } + /** The date of the invoice. Can only be modified for one-off draft invoices. */ + fun invoiceDate(invoiceDate: InvoiceDate?) = apply { body.invoiceDate(invoiceDate) } + + /** + * Sets [Builder.invoiceDate] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceDate] with a well-typed [InvoiceDate] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun invoiceDate(invoiceDate: JsonField) = apply { + body.invoiceDate(invoiceDate) + } + + /** Alias for calling [invoiceDate] with `InvoiceDate.ofDate(date)`. */ + fun invoiceDate(date: LocalDate) = apply { body.invoiceDate(date) } + + /** Alias for calling [invoiceDate] with `InvoiceDate.ofDateTime(dateTime)`. */ + fun invoiceDate(dateTime: OffsetDateTime) = apply { body.invoiceDate(dateTime) } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -354,6 +391,7 @@ private constructor( @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val dueDate: JsonField, + private val invoiceDate: JsonField, private val metadata: JsonField, private val netTerms: JsonField, private val additionalProperties: MutableMap, @@ -364,11 +402,14 @@ private constructor( @JsonProperty("due_date") @ExcludeMissing dueDate: JsonField = JsonMissing.of(), + @JsonProperty("invoice_date") + @ExcludeMissing + invoiceDate: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("net_terms") @ExcludeMissing netTerms: JsonField = JsonMissing.of(), - ) : this(dueDate, metadata, netTerms, mutableMapOf()) + ) : this(dueDate, invoiceDate, metadata, netTerms, mutableMapOf()) /** * An optional custom due date for the invoice. If not set, the due date will be calculated @@ -379,6 +420,14 @@ private constructor( */ fun dueDate(): DueDate? = dueDate.getNullable("due_date") + /** + * The date of the invoice. Can only be modified for one-off draft invoices. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun invoiceDate(): InvoiceDate? = invoiceDate.getNullable("invoice_date") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -408,6 +457,15 @@ private constructor( */ @JsonProperty("due_date") @ExcludeMissing fun _dueDate(): JsonField = dueDate + /** + * Returns the raw JSON value of [invoiceDate]. + * + * Unlike [invoiceDate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("invoice_date") + @ExcludeMissing + fun _invoiceDate(): JsonField = invoiceDate + /** * Returns the raw JSON value of [metadata]. * @@ -444,12 +502,14 @@ private constructor( class Builder internal constructor() { private var dueDate: JsonField = JsonMissing.of() + private var invoiceDate: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var netTerms: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() internal fun from(body: Body) = apply { dueDate = body.dueDate + invoiceDate = body.invoiceDate metadata = body.metadata netTerms = body.netTerms additionalProperties = body.additionalProperties.toMutableMap() @@ -476,6 +536,28 @@ private constructor( /** Alias for calling [dueDate] with `DueDate.ofDateTime(dateTime)`. */ fun dueDate(dateTime: OffsetDateTime) = dueDate(DueDate.ofDateTime(dateTime)) + /** The date of the invoice. Can only be modified for one-off draft invoices. */ + fun invoiceDate(invoiceDate: InvoiceDate?) = + invoiceDate(JsonField.ofNullable(invoiceDate)) + + /** + * Sets [Builder.invoiceDate] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceDate] with a well-typed [InvoiceDate] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun invoiceDate(invoiceDate: JsonField) = apply { + this.invoiceDate = invoiceDate + } + + /** Alias for calling [invoiceDate] with `InvoiceDate.ofDate(date)`. */ + fun invoiceDate(date: LocalDate) = invoiceDate(InvoiceDate.ofDate(date)) + + /** Alias for calling [invoiceDate] with `InvoiceDate.ofDateTime(dateTime)`. */ + fun invoiceDate(dateTime: OffsetDateTime) = + invoiceDate(InvoiceDate.ofDateTime(dateTime)) + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by @@ -542,7 +624,7 @@ private constructor( * Further updates to this [Builder] will not mutate the returned instance. */ fun build(): Body = - Body(dueDate, metadata, netTerms, additionalProperties.toMutableMap()) + Body(dueDate, invoiceDate, metadata, netTerms, additionalProperties.toMutableMap()) } private var validated: Boolean = false @@ -553,6 +635,7 @@ private constructor( } dueDate()?.validate() + invoiceDate()?.validate() metadata()?.validate() netTerms() validated = true @@ -574,6 +657,7 @@ private constructor( */ internal fun validity(): Int = (dueDate.asKnown()?.validity() ?: 0) + + (invoiceDate.asKnown()?.validity() ?: 0) + (metadata.asKnown()?.validity() ?: 0) + (if (netTerms.asKnown() == null) 0 else 1) @@ -584,19 +668,20 @@ private constructor( return other is Body && dueDate == other.dueDate && + invoiceDate == other.invoiceDate && metadata == other.metadata && netTerms == other.netTerms && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(dueDate, metadata, netTerms, additionalProperties) + Objects.hash(dueDate, invoiceDate, metadata, netTerms, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "Body{dueDate=$dueDate, metadata=$metadata, netTerms=$netTerms, additionalProperties=$additionalProperties}" + "Body{dueDate=$dueDate, invoiceDate=$invoiceDate, metadata=$metadata, netTerms=$netTerms, additionalProperties=$additionalProperties}" } /** @@ -771,6 +856,176 @@ private constructor( } } + /** The date of the invoice. Can only be modified for one-off draft invoices. */ + @JsonDeserialize(using = InvoiceDate.Deserializer::class) + @JsonSerialize(using = InvoiceDate.Serializer::class) + class InvoiceDate + private constructor( + private val date: LocalDate? = null, + private val dateTime: OffsetDateTime? = null, + private val _json: JsonValue? = null, + ) { + + fun date(): LocalDate? = date + + fun dateTime(): OffsetDateTime? = dateTime + + fun isDate(): Boolean = date != null + + fun isDateTime(): Boolean = dateTime != null + + fun asDate(): LocalDate = date.getOrThrow("date") + + fun asDateTime(): OffsetDateTime = dateTime.getOrThrow("dateTime") + + fun _json(): JsonValue? = _json + + fun accept(visitor: Visitor): T = + when { + date != null -> visitor.visitDate(date) + dateTime != null -> visitor.visitDateTime(dateTime) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): InvoiceDate = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitDate(date: LocalDate) {} + + override fun visitDateTime(dateTime: OffsetDateTime) {} + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitDate(date: LocalDate) = 1 + + override fun visitDateTime(dateTime: OffsetDateTime) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is InvoiceDate && date == other.date && dateTime == other.dateTime + } + + override fun hashCode(): Int = Objects.hash(date, dateTime) + + override fun toString(): String = + when { + date != null -> "InvoiceDate{date=$date}" + dateTime != null -> "InvoiceDate{dateTime=$dateTime}" + _json != null -> "InvoiceDate{_unknown=$_json}" + else -> throw IllegalStateException("Invalid InvoiceDate") + } + + companion object { + + fun ofDate(date: LocalDate) = InvoiceDate(date = date) + + fun ofDateTime(dateTime: OffsetDateTime) = InvoiceDate(dateTime = dateTime) + } + + /** + * An interface that defines how to map each variant of [InvoiceDate] to a value of type + * [T]. + */ + interface Visitor { + + fun visitDate(date: LocalDate): T + + fun visitDateTime(dateTime: OffsetDateTime): T + + /** + * Maps an unknown variant of [InvoiceDate] to a value of type [T]. + * + * An instance of [InvoiceDate] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the SDK + * is unaware of. + * + * @throws OrbInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw OrbInvalidDataException("Unknown InvoiceDate: $json") + } + } + + internal class Deserializer : BaseDeserializer(InvoiceDate::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): InvoiceDate { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + InvoiceDate(date = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + InvoiceDate(dateTime = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with + // all the possible variants (e.g. deserializing from object). + 0 -> InvoiceDate(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely + // valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(InvoiceDate::class) { + + override fun serialize( + value: InvoiceDate, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.date != null -> generator.writeObject(value.date) + value.dateTime != null -> generator.writeObject(value.dateTime) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid InvoiceDate") + } + } + } + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/InvoiceServiceAsync.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/InvoiceServiceAsync.kt index 540570c01..0dabda5b3 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/InvoiceServiceAsync.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/InvoiceServiceAsync.kt @@ -40,12 +40,13 @@ interface InvoiceServiceAsync { ): Invoice /** - * This endpoint allows you to update the `metadata`, `net_terms`, and `due_date` properties on - * an invoice. If you pass null for the metadata value, it will clear any existing metadata for - * that invoice. + * This endpoint allows you to update the `metadata`, `net_terms`, `due_date`, and + * `invoice_date` properties on an invoice. If you pass null for the metadata value, it will + * clear any existing metadata for that invoice. * - * `metadata` can be modified regardless of invoice state. `net_terms` and `due_date` can only - * be modified if the invoice is in a `draft` state. + * `metadata` can be modified regardless of invoice state. `net_terms`, `due_date`, and + * `invoice_date` can only be modified if the invoice is in a `draft` state. `invoice_date` can + * only be modified for non-subscription invoices. */ suspend fun update( invoiceId: String, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/InvoiceService.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/InvoiceService.kt index 3b87c944a..2aecb22c4 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/InvoiceService.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/InvoiceService.kt @@ -40,12 +40,13 @@ interface InvoiceService { ): Invoice /** - * This endpoint allows you to update the `metadata`, `net_terms`, and `due_date` properties on - * an invoice. If you pass null for the metadata value, it will clear any existing metadata for - * that invoice. + * This endpoint allows you to update the `metadata`, `net_terms`, `due_date`, and + * `invoice_date` properties on an invoice. If you pass null for the metadata value, it will + * clear any existing metadata for that invoice. * - * `metadata` can be modified regardless of invoice state. `net_terms` and `due_date` can only - * be modified if the invoice is in a `draft` state. + * `metadata` can be modified regardless of invoice state. `net_terms`, `due_date`, and + * `invoice_date` can only be modified if the invoice is in a `draft` state. `invoice_date` can + * only be modified for non-subscription invoices. */ fun update( invoiceId: String, diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceUpdateParamsTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceUpdateParamsTest.kt index 39d7a3b19..4578f5f69 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceUpdateParamsTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceUpdateParamsTest.kt @@ -14,6 +14,7 @@ internal class InvoiceUpdateParamsTest { InvoiceUpdateParams.builder() .invoiceId("invoice_id") .dueDate(LocalDate.parse("2023-09-22")) + .invoiceDate(LocalDate.parse("2023-09-22")) .metadata( InvoiceUpdateParams.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -38,6 +39,7 @@ internal class InvoiceUpdateParamsTest { InvoiceUpdateParams.builder() .invoiceId("invoice_id") .dueDate(LocalDate.parse("2023-09-22")) + .invoiceDate(LocalDate.parse("2023-09-22")) .metadata( InvoiceUpdateParams.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -50,6 +52,8 @@ internal class InvoiceUpdateParamsTest { assertThat(body.dueDate()) .isEqualTo(InvoiceUpdateParams.DueDate.ofDate(LocalDate.parse("2023-09-22"))) + assertThat(body.invoiceDate()) + .isEqualTo(InvoiceUpdateParams.InvoiceDate.ofDate(LocalDate.parse("2023-09-22"))) assertThat(body.metadata()) .isEqualTo( InvoiceUpdateParams.Metadata.builder() diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/InvoiceServiceAsyncTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/InvoiceServiceAsyncTest.kt index f91a2deed..76b24447f 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/InvoiceServiceAsyncTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/InvoiceServiceAsyncTest.kt @@ -92,6 +92,7 @@ internal class InvoiceServiceAsyncTest { InvoiceUpdateParams.builder() .invoiceId("invoice_id") .dueDate(LocalDate.parse("2023-09-22")) + .invoiceDate(LocalDate.parse("2023-09-22")) .metadata( InvoiceUpdateParams.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/InvoiceServiceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/InvoiceServiceTest.kt index 5f272b94d..2bd5cc219 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/InvoiceServiceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/InvoiceServiceTest.kt @@ -92,6 +92,7 @@ internal class InvoiceServiceTest { InvoiceUpdateParams.builder() .invoiceId("invoice_id") .dueDate(LocalDate.parse("2023-09-22")) + .invoiceDate(LocalDate.parse("2023-09-22")) .metadata( InvoiceUpdateParams.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) From a1a92f48d35131e22f8e4e9ce51f6a31c8445277 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 31 Oct 2025 02:33:29 +0000 Subject: [PATCH 40/68] feat(api): api update --- .stats.yml | 4 +- .../CustomerCreditListByExternalIdResponse.kt | 584 +++++++++++++++++- .../api/models/CustomerCreditListResponse.kt | 584 +++++++++++++++++- ...rCreditListByExternalIdPageResponseTest.kt | 27 + ...tomerCreditListByExternalIdResponseTest.kt | 22 + .../CustomerCreditListPageResponseTest.kt | 21 + .../models/CustomerCreditListResponseTest.kt | 22 + 7 files changed, 1260 insertions(+), 4 deletions(-) diff --git a/.stats.yml b/.stats.yml index 49f0b44f3..3fc5d44cc 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 118 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-faf1f7c723d2762f09e9690ef2ceda58cb0a6ddacf1a79c3754871b90e7db0dc.yml -openapi_spec_hash: 22269f85fae1ec920bdb0b32435a7aa8 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-79664fa0b4ea00c978ae2516087d0ee591b0ef92ca8db29557a0424bde520e10.yml +openapi_spec_hash: 1ff6eee9184312a3a0fd21eb589132f9 config_hash: dd4343ce95871032ef6e0735a4ca038c diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdResponse.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdResponse.kt index 12d7b7cc2..3d9c4278a 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdResponse.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdResponse.kt @@ -11,7 +11,9 @@ import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue +import com.withorb.api.core.checkKnown import com.withorb.api.core.checkRequired +import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import java.time.OffsetDateTime import java.util.Collections @@ -24,6 +26,7 @@ private constructor( private val balance: JsonField, private val effectiveDate: JsonField, private val expiryDate: JsonField, + private val filters: JsonField>, private val maximumInitialBalance: JsonField, private val perUnitCostBasis: JsonField, private val status: JsonField, @@ -40,6 +43,9 @@ private constructor( @JsonProperty("expiry_date") @ExcludeMissing expiryDate: JsonField = JsonMissing.of(), + @JsonProperty("filters") + @ExcludeMissing + filters: JsonField> = JsonMissing.of(), @JsonProperty("maximum_initial_balance") @ExcludeMissing maximumInitialBalance: JsonField = JsonMissing.of(), @@ -52,6 +58,7 @@ private constructor( balance, effectiveDate, expiryDate, + filters, maximumInitialBalance, perUnitCostBasis, status, @@ -82,6 +89,12 @@ private constructor( */ fun expiryDate(): OffsetDateTime? = expiryDate.getNullable("expiry_date") + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun filters(): List = filters.getRequired("filters") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server * responded with an unexpected value). @@ -133,6 +146,13 @@ private constructor( @ExcludeMissing fun _expiryDate(): JsonField = expiryDate + /** + * Returns the raw JSON value of [filters]. + * + * Unlike [filters], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("filters") @ExcludeMissing fun _filters(): JsonField> = filters + /** * Returns the raw JSON value of [maximumInitialBalance]. * @@ -184,6 +204,7 @@ private constructor( * .balance() * .effectiveDate() * .expiryDate() + * .filters() * .maximumInitialBalance() * .perUnitCostBasis() * .status() @@ -199,6 +220,7 @@ private constructor( private var balance: JsonField? = null private var effectiveDate: JsonField? = null private var expiryDate: JsonField? = null + private var filters: JsonField>? = null private var maximumInitialBalance: JsonField? = null private var perUnitCostBasis: JsonField? = null private var status: JsonField? = null @@ -211,6 +233,7 @@ private constructor( balance = customerCreditListByExternalIdResponse.balance effectiveDate = customerCreditListByExternalIdResponse.effectiveDate expiryDate = customerCreditListByExternalIdResponse.expiryDate + filters = customerCreditListByExternalIdResponse.filters.map { it.toMutableList() } maximumInitialBalance = customerCreditListByExternalIdResponse.maximumInitialBalance perUnitCostBasis = customerCreditListByExternalIdResponse.perUnitCostBasis status = customerCreditListByExternalIdResponse.status @@ -265,6 +288,31 @@ private constructor( this.expiryDate = expiryDate } + fun filters(filters: List) = filters(JsonField.of(filters)) + + /** + * Sets [Builder.filters] to an arbitrary JSON value. + * + * You should usually call [Builder.filters] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun filters(filters: JsonField>) = apply { + this.filters = filters.map { it.toMutableList() } + } + + /** + * Adds a single [Filter] to [filters]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addFilter(filter: Filter) = apply { + filters = + (filters ?: JsonField.of(mutableListOf())).also { + checkKnown("filters", it).add(filter) + } + } + fun maximumInitialBalance(maximumInitialBalance: Double?) = maximumInitialBalance(JsonField.ofNullable(maximumInitialBalance)) @@ -341,6 +389,7 @@ private constructor( * .balance() * .effectiveDate() * .expiryDate() + * .filters() * .maximumInitialBalance() * .perUnitCostBasis() * .status() @@ -354,6 +403,7 @@ private constructor( checkRequired("balance", balance), checkRequired("effectiveDate", effectiveDate), checkRequired("expiryDate", expiryDate), + checkRequired("filters", filters).map { it.toImmutable() }, checkRequired("maximumInitialBalance", maximumInitialBalance), checkRequired("perUnitCostBasis", perUnitCostBasis), checkRequired("status", status), @@ -372,6 +422,7 @@ private constructor( balance() effectiveDate() expiryDate() + filters().forEach { it.validate() } maximumInitialBalance() perUnitCostBasis() status().validate() @@ -396,10 +447,539 @@ private constructor( (if (balance.asKnown() == null) 0 else 1) + (if (effectiveDate.asKnown() == null) 0 else 1) + (if (expiryDate.asKnown() == null) 0 else 1) + + (filters.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + (if (maximumInitialBalance.asKnown() == null) 0 else 1) + (if (perUnitCostBasis.asKnown() == null) 0 else 1) + (status.asKnown()?.validity() ?: 0) + class Filter + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val field: JsonField, + private val operator: JsonField, + private val values: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("field") @ExcludeMissing field: JsonField = JsonMissing.of(), + @JsonProperty("operator") + @ExcludeMissing + operator: JsonField = JsonMissing.of(), + @JsonProperty("values") + @ExcludeMissing + values: JsonField> = JsonMissing.of(), + ) : this(field, operator, values, mutableMapOf()) + + /** + * The property of the price to filter on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun field(): Field = field.getRequired("field") + + /** + * Should prices that match the filter be included or excluded. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun operator(): Operator = operator.getRequired("operator") + + /** + * The IDs or values that match this filter. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun values(): List = values.getRequired("values") + + /** + * Returns the raw JSON value of [field]. + * + * Unlike [field], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("field") @ExcludeMissing fun _field(): JsonField = field + + /** + * Returns the raw JSON value of [operator]. + * + * Unlike [operator], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("operator") @ExcludeMissing fun _operator(): JsonField = operator + + /** + * Returns the raw JSON value of [values]. + * + * Unlike [values], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("values") @ExcludeMissing fun _values(): JsonField> = values + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Filter]. + * + * The following fields are required: + * ```kotlin + * .field() + * .operator() + * .values() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Filter]. */ + class Builder internal constructor() { + + private var field: JsonField? = null + private var operator: JsonField? = null + private var values: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(filter: Filter) = apply { + field = filter.field + operator = filter.operator + values = filter.values.map { it.toMutableList() } + additionalProperties = filter.additionalProperties.toMutableMap() + } + + /** The property of the price to filter on. */ + fun field(field: Field) = field(JsonField.of(field)) + + /** + * Sets [Builder.field] to an arbitrary JSON value. + * + * You should usually call [Builder.field] with a well-typed [Field] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun field(field: JsonField) = apply { this.field = field } + + /** Should prices that match the filter be included or excluded. */ + fun operator(operator: Operator) = operator(JsonField.of(operator)) + + /** + * Sets [Builder.operator] to an arbitrary JSON value. + * + * You should usually call [Builder.operator] with a well-typed [Operator] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun operator(operator: JsonField) = apply { this.operator = operator } + + /** The IDs or values that match this filter. */ + fun values(values: List) = values(JsonField.of(values)) + + /** + * Sets [Builder.values] to an arbitrary JSON value. + * + * You should usually call [Builder.values] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun values(values: JsonField>) = apply { + this.values = values.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [values]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addValue(value: String) = apply { + values = + (values ?: JsonField.of(mutableListOf())).also { + checkKnown("values", it).add(value) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Filter]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .field() + * .operator() + * .values() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Filter = + Filter( + checkRequired("field", field), + checkRequired("operator", operator), + checkRequired("values", values).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Filter = apply { + if (validated) { + return@apply + } + + field().validate() + operator().validate() + values() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (field.asKnown()?.validity() ?: 0) + + (operator.asKnown()?.validity() ?: 0) + + (values.asKnown()?.size ?: 0) + + /** The property of the price to filter on. */ + class Field @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val PRICE_ID = of("price_id") + + val ITEM_ID = of("item_id") + + val PRICE_TYPE = of("price_type") + + val CURRENCY = of("currency") + + val PRICING_UNIT_ID = of("pricing_unit_id") + + fun of(value: String) = Field(JsonField.of(value)) + } + + /** An enum containing [Field]'s known values. */ + enum class Known { + PRICE_ID, + ITEM_ID, + PRICE_TYPE, + CURRENCY, + PRICING_UNIT_ID, + } + + /** + * An enum containing [Field]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Field] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + PRICE_ID, + ITEM_ID, + PRICE_TYPE, + CURRENCY, + PRICING_UNIT_ID, + /** + * An enum member indicating that [Field] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + PRICE_ID -> Value.PRICE_ID + ITEM_ID -> Value.ITEM_ID + PRICE_TYPE -> Value.PRICE_TYPE + CURRENCY -> Value.CURRENCY + PRICING_UNIT_ID -> Value.PRICING_UNIT_ID + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + PRICE_ID -> Known.PRICE_ID + ITEM_ID -> Known.ITEM_ID + PRICE_TYPE -> Known.PRICE_TYPE + CURRENCY -> Known.CURRENCY + PRICING_UNIT_ID -> Known.PRICING_UNIT_ID + else -> throw OrbInvalidDataException("Unknown Field: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Field = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Field && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Should prices that match the filter be included or excluded. */ + class Operator @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val INCLUDES = of("includes") + + val EXCLUDES = of("excludes") + + fun of(value: String) = Operator(JsonField.of(value)) + } + + /** An enum containing [Operator]'s known values. */ + enum class Known { + INCLUDES, + EXCLUDES, + } + + /** + * An enum containing [Operator]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Operator] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + INCLUDES, + EXCLUDES, + /** + * An enum member indicating that [Operator] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + INCLUDES -> Value.INCLUDES + EXCLUDES -> Value.EXCLUDES + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + INCLUDES -> Known.INCLUDES + EXCLUDES -> Known.EXCLUDES + else -> throw OrbInvalidDataException("Unknown Operator: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Operator = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Operator && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Filter && + field == other.field && + operator == other.operator && + values == other.values && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(field, operator, values, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Filter{field=$field, operator=$operator, values=$values, additionalProperties=$additionalProperties}" + } + class Status @JsonCreator private constructor(private val value: JsonField) : Enum { /** @@ -534,6 +1114,7 @@ private constructor( balance == other.balance && effectiveDate == other.effectiveDate && expiryDate == other.expiryDate && + filters == other.filters && maximumInitialBalance == other.maximumInitialBalance && perUnitCostBasis == other.perUnitCostBasis && status == other.status && @@ -546,6 +1127,7 @@ private constructor( balance, effectiveDate, expiryDate, + filters, maximumInitialBalance, perUnitCostBasis, status, @@ -556,5 +1138,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "CustomerCreditListByExternalIdResponse{id=$id, balance=$balance, effectiveDate=$effectiveDate, expiryDate=$expiryDate, maximumInitialBalance=$maximumInitialBalance, perUnitCostBasis=$perUnitCostBasis, status=$status, additionalProperties=$additionalProperties}" + "CustomerCreditListByExternalIdResponse{id=$id, balance=$balance, effectiveDate=$effectiveDate, expiryDate=$expiryDate, filters=$filters, maximumInitialBalance=$maximumInitialBalance, perUnitCostBasis=$perUnitCostBasis, status=$status, additionalProperties=$additionalProperties}" } diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListResponse.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListResponse.kt index 12fcc9a07..7c186b91c 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListResponse.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListResponse.kt @@ -11,7 +11,9 @@ import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue +import com.withorb.api.core.checkKnown import com.withorb.api.core.checkRequired +import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import java.time.OffsetDateTime import java.util.Collections @@ -24,6 +26,7 @@ private constructor( private val balance: JsonField, private val effectiveDate: JsonField, private val expiryDate: JsonField, + private val filters: JsonField>, private val maximumInitialBalance: JsonField, private val perUnitCostBasis: JsonField, private val status: JsonField, @@ -40,6 +43,9 @@ private constructor( @JsonProperty("expiry_date") @ExcludeMissing expiryDate: JsonField = JsonMissing.of(), + @JsonProperty("filters") + @ExcludeMissing + filters: JsonField> = JsonMissing.of(), @JsonProperty("maximum_initial_balance") @ExcludeMissing maximumInitialBalance: JsonField = JsonMissing.of(), @@ -52,6 +58,7 @@ private constructor( balance, effectiveDate, expiryDate, + filters, maximumInitialBalance, perUnitCostBasis, status, @@ -82,6 +89,12 @@ private constructor( */ fun expiryDate(): OffsetDateTime? = expiryDate.getNullable("expiry_date") + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun filters(): List = filters.getRequired("filters") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server * responded with an unexpected value). @@ -133,6 +146,13 @@ private constructor( @ExcludeMissing fun _expiryDate(): JsonField = expiryDate + /** + * Returns the raw JSON value of [filters]. + * + * Unlike [filters], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("filters") @ExcludeMissing fun _filters(): JsonField> = filters + /** * Returns the raw JSON value of [maximumInitialBalance]. * @@ -183,6 +203,7 @@ private constructor( * .balance() * .effectiveDate() * .expiryDate() + * .filters() * .maximumInitialBalance() * .perUnitCostBasis() * .status() @@ -198,6 +219,7 @@ private constructor( private var balance: JsonField? = null private var effectiveDate: JsonField? = null private var expiryDate: JsonField? = null + private var filters: JsonField>? = null private var maximumInitialBalance: JsonField? = null private var perUnitCostBasis: JsonField? = null private var status: JsonField? = null @@ -208,6 +230,7 @@ private constructor( balance = customerCreditListResponse.balance effectiveDate = customerCreditListResponse.effectiveDate expiryDate = customerCreditListResponse.expiryDate + filters = customerCreditListResponse.filters.map { it.toMutableList() } maximumInitialBalance = customerCreditListResponse.maximumInitialBalance perUnitCostBasis = customerCreditListResponse.perUnitCostBasis status = customerCreditListResponse.status @@ -261,6 +284,31 @@ private constructor( this.expiryDate = expiryDate } + fun filters(filters: List) = filters(JsonField.of(filters)) + + /** + * Sets [Builder.filters] to an arbitrary JSON value. + * + * You should usually call [Builder.filters] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun filters(filters: JsonField>) = apply { + this.filters = filters.map { it.toMutableList() } + } + + /** + * Adds a single [Filter] to [filters]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addFilter(filter: Filter) = apply { + filters = + (filters ?: JsonField.of(mutableListOf())).also { + checkKnown("filters", it).add(filter) + } + } + fun maximumInitialBalance(maximumInitialBalance: Double?) = maximumInitialBalance(JsonField.ofNullable(maximumInitialBalance)) @@ -337,6 +385,7 @@ private constructor( * .balance() * .effectiveDate() * .expiryDate() + * .filters() * .maximumInitialBalance() * .perUnitCostBasis() * .status() @@ -350,6 +399,7 @@ private constructor( checkRequired("balance", balance), checkRequired("effectiveDate", effectiveDate), checkRequired("expiryDate", expiryDate), + checkRequired("filters", filters).map { it.toImmutable() }, checkRequired("maximumInitialBalance", maximumInitialBalance), checkRequired("perUnitCostBasis", perUnitCostBasis), checkRequired("status", status), @@ -368,6 +418,7 @@ private constructor( balance() effectiveDate() expiryDate() + filters().forEach { it.validate() } maximumInitialBalance() perUnitCostBasis() status().validate() @@ -392,10 +443,539 @@ private constructor( (if (balance.asKnown() == null) 0 else 1) + (if (effectiveDate.asKnown() == null) 0 else 1) + (if (expiryDate.asKnown() == null) 0 else 1) + + (filters.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + (if (maximumInitialBalance.asKnown() == null) 0 else 1) + (if (perUnitCostBasis.asKnown() == null) 0 else 1) + (status.asKnown()?.validity() ?: 0) + class Filter + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val field: JsonField, + private val operator: JsonField, + private val values: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("field") @ExcludeMissing field: JsonField = JsonMissing.of(), + @JsonProperty("operator") + @ExcludeMissing + operator: JsonField = JsonMissing.of(), + @JsonProperty("values") + @ExcludeMissing + values: JsonField> = JsonMissing.of(), + ) : this(field, operator, values, mutableMapOf()) + + /** + * The property of the price to filter on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun field(): Field = field.getRequired("field") + + /** + * Should prices that match the filter be included or excluded. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun operator(): Operator = operator.getRequired("operator") + + /** + * The IDs or values that match this filter. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun values(): List = values.getRequired("values") + + /** + * Returns the raw JSON value of [field]. + * + * Unlike [field], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("field") @ExcludeMissing fun _field(): JsonField = field + + /** + * Returns the raw JSON value of [operator]. + * + * Unlike [operator], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("operator") @ExcludeMissing fun _operator(): JsonField = operator + + /** + * Returns the raw JSON value of [values]. + * + * Unlike [values], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("values") @ExcludeMissing fun _values(): JsonField> = values + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Filter]. + * + * The following fields are required: + * ```kotlin + * .field() + * .operator() + * .values() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Filter]. */ + class Builder internal constructor() { + + private var field: JsonField? = null + private var operator: JsonField? = null + private var values: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(filter: Filter) = apply { + field = filter.field + operator = filter.operator + values = filter.values.map { it.toMutableList() } + additionalProperties = filter.additionalProperties.toMutableMap() + } + + /** The property of the price to filter on. */ + fun field(field: Field) = field(JsonField.of(field)) + + /** + * Sets [Builder.field] to an arbitrary JSON value. + * + * You should usually call [Builder.field] with a well-typed [Field] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun field(field: JsonField) = apply { this.field = field } + + /** Should prices that match the filter be included or excluded. */ + fun operator(operator: Operator) = operator(JsonField.of(operator)) + + /** + * Sets [Builder.operator] to an arbitrary JSON value. + * + * You should usually call [Builder.operator] with a well-typed [Operator] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun operator(operator: JsonField) = apply { this.operator = operator } + + /** The IDs or values that match this filter. */ + fun values(values: List) = values(JsonField.of(values)) + + /** + * Sets [Builder.values] to an arbitrary JSON value. + * + * You should usually call [Builder.values] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun values(values: JsonField>) = apply { + this.values = values.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [values]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addValue(value: String) = apply { + values = + (values ?: JsonField.of(mutableListOf())).also { + checkKnown("values", it).add(value) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Filter]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .field() + * .operator() + * .values() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Filter = + Filter( + checkRequired("field", field), + checkRequired("operator", operator), + checkRequired("values", values).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Filter = apply { + if (validated) { + return@apply + } + + field().validate() + operator().validate() + values() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (field.asKnown()?.validity() ?: 0) + + (operator.asKnown()?.validity() ?: 0) + + (values.asKnown()?.size ?: 0) + + /** The property of the price to filter on. */ + class Field @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val PRICE_ID = of("price_id") + + val ITEM_ID = of("item_id") + + val PRICE_TYPE = of("price_type") + + val CURRENCY = of("currency") + + val PRICING_UNIT_ID = of("pricing_unit_id") + + fun of(value: String) = Field(JsonField.of(value)) + } + + /** An enum containing [Field]'s known values. */ + enum class Known { + PRICE_ID, + ITEM_ID, + PRICE_TYPE, + CURRENCY, + PRICING_UNIT_ID, + } + + /** + * An enum containing [Field]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Field] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + PRICE_ID, + ITEM_ID, + PRICE_TYPE, + CURRENCY, + PRICING_UNIT_ID, + /** + * An enum member indicating that [Field] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + PRICE_ID -> Value.PRICE_ID + ITEM_ID -> Value.ITEM_ID + PRICE_TYPE -> Value.PRICE_TYPE + CURRENCY -> Value.CURRENCY + PRICING_UNIT_ID -> Value.PRICING_UNIT_ID + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + PRICE_ID -> Known.PRICE_ID + ITEM_ID -> Known.ITEM_ID + PRICE_TYPE -> Known.PRICE_TYPE + CURRENCY -> Known.CURRENCY + PRICING_UNIT_ID -> Known.PRICING_UNIT_ID + else -> throw OrbInvalidDataException("Unknown Field: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Field = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Field && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Should prices that match the filter be included or excluded. */ + class Operator @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val INCLUDES = of("includes") + + val EXCLUDES = of("excludes") + + fun of(value: String) = Operator(JsonField.of(value)) + } + + /** An enum containing [Operator]'s known values. */ + enum class Known { + INCLUDES, + EXCLUDES, + } + + /** + * An enum containing [Operator]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Operator] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + INCLUDES, + EXCLUDES, + /** + * An enum member indicating that [Operator] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + INCLUDES -> Value.INCLUDES + EXCLUDES -> Value.EXCLUDES + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + INCLUDES -> Known.INCLUDES + EXCLUDES -> Known.EXCLUDES + else -> throw OrbInvalidDataException("Unknown Operator: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Operator = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Operator && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Filter && + field == other.field && + operator == other.operator && + values == other.values && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(field, operator, values, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Filter{field=$field, operator=$operator, values=$values, additionalProperties=$additionalProperties}" + } + class Status @JsonCreator private constructor(private val value: JsonField) : Enum { /** @@ -530,6 +1110,7 @@ private constructor( balance == other.balance && effectiveDate == other.effectiveDate && expiryDate == other.expiryDate && + filters == other.filters && maximumInitialBalance == other.maximumInitialBalance && perUnitCostBasis == other.perUnitCostBasis && status == other.status && @@ -542,6 +1123,7 @@ private constructor( balance, effectiveDate, expiryDate, + filters, maximumInitialBalance, perUnitCostBasis, status, @@ -552,5 +1134,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "CustomerCreditListResponse{id=$id, balance=$balance, effectiveDate=$effectiveDate, expiryDate=$expiryDate, maximumInitialBalance=$maximumInitialBalance, perUnitCostBasis=$perUnitCostBasis, status=$status, additionalProperties=$additionalProperties}" + "CustomerCreditListResponse{id=$id, balance=$balance, effectiveDate=$effectiveDate, expiryDate=$expiryDate, filters=$filters, maximumInitialBalance=$maximumInitialBalance, perUnitCostBasis=$perUnitCostBasis, status=$status, additionalProperties=$additionalProperties}" } diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdPageResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdPageResponseTest.kt index d9fcc1804..37b6dbddc 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdPageResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdPageResponseTest.kt @@ -20,6 +20,15 @@ internal class CustomerCreditListByExternalIdPageResponseTest { .balance(0.0) .effectiveDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addFilter( + CustomerCreditListByExternalIdResponse.Filter.builder() + .field(CustomerCreditListByExternalIdResponse.Filter.Field.PRICE_ID) + .operator( + CustomerCreditListByExternalIdResponse.Filter.Operator.INCLUDES + ) + .addValue("string") + .build() + ) .maximumInitialBalance(0.0) .perUnitCostBasis("per_unit_cost_basis") .status(CustomerCreditListByExternalIdResponse.Status.ACTIVE) @@ -37,6 +46,15 @@ internal class CustomerCreditListByExternalIdPageResponseTest { .balance(0.0) .effectiveDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addFilter( + CustomerCreditListByExternalIdResponse.Filter.builder() + .field(CustomerCreditListByExternalIdResponse.Filter.Field.PRICE_ID) + .operator( + CustomerCreditListByExternalIdResponse.Filter.Operator.INCLUDES + ) + .addValue("string") + .build() + ) .maximumInitialBalance(0.0) .perUnitCostBasis("per_unit_cost_basis") .status(CustomerCreditListByExternalIdResponse.Status.ACTIVE) @@ -57,6 +75,15 @@ internal class CustomerCreditListByExternalIdPageResponseTest { .balance(0.0) .effectiveDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addFilter( + CustomerCreditListByExternalIdResponse.Filter.builder() + .field(CustomerCreditListByExternalIdResponse.Filter.Field.PRICE_ID) + .operator( + CustomerCreditListByExternalIdResponse.Filter.Operator.INCLUDES + ) + .addValue("string") + .build() + ) .maximumInitialBalance(0.0) .perUnitCostBasis("per_unit_cost_basis") .status(CustomerCreditListByExternalIdResponse.Status.ACTIVE) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdResponseTest.kt index 10131bce3..ac2db752f 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdResponseTest.kt @@ -18,6 +18,13 @@ internal class CustomerCreditListByExternalIdResponseTest { .balance(0.0) .effectiveDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addFilter( + CustomerCreditListByExternalIdResponse.Filter.builder() + .field(CustomerCreditListByExternalIdResponse.Filter.Field.PRICE_ID) + .operator(CustomerCreditListByExternalIdResponse.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .maximumInitialBalance(0.0) .perUnitCostBasis("per_unit_cost_basis") .status(CustomerCreditListByExternalIdResponse.Status.ACTIVE) @@ -29,6 +36,14 @@ internal class CustomerCreditListByExternalIdResponseTest { .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) assertThat(customerCreditListByExternalIdResponse.expiryDate()) .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(customerCreditListByExternalIdResponse.filters()) + .containsExactly( + CustomerCreditListByExternalIdResponse.Filter.builder() + .field(CustomerCreditListByExternalIdResponse.Filter.Field.PRICE_ID) + .operator(CustomerCreditListByExternalIdResponse.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) assertThat(customerCreditListByExternalIdResponse.maximumInitialBalance()).isEqualTo(0.0) assertThat(customerCreditListByExternalIdResponse.perUnitCostBasis()) .isEqualTo("per_unit_cost_basis") @@ -45,6 +60,13 @@ internal class CustomerCreditListByExternalIdResponseTest { .balance(0.0) .effectiveDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addFilter( + CustomerCreditListByExternalIdResponse.Filter.builder() + .field(CustomerCreditListByExternalIdResponse.Filter.Field.PRICE_ID) + .operator(CustomerCreditListByExternalIdResponse.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .maximumInitialBalance(0.0) .perUnitCostBasis("per_unit_cost_basis") .status(CustomerCreditListByExternalIdResponse.Status.ACTIVE) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditListPageResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditListPageResponseTest.kt index 3d5abe3f9..b0dc2cda2 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditListPageResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditListPageResponseTest.kt @@ -20,6 +20,13 @@ internal class CustomerCreditListPageResponseTest { .balance(0.0) .effectiveDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addFilter( + CustomerCreditListResponse.Filter.builder() + .field(CustomerCreditListResponse.Filter.Field.PRICE_ID) + .operator(CustomerCreditListResponse.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .maximumInitialBalance(0.0) .perUnitCostBasis("per_unit_cost_basis") .status(CustomerCreditListResponse.Status.ACTIVE) @@ -37,6 +44,13 @@ internal class CustomerCreditListPageResponseTest { .balance(0.0) .effectiveDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addFilter( + CustomerCreditListResponse.Filter.builder() + .field(CustomerCreditListResponse.Filter.Field.PRICE_ID) + .operator(CustomerCreditListResponse.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .maximumInitialBalance(0.0) .perUnitCostBasis("per_unit_cost_basis") .status(CustomerCreditListResponse.Status.ACTIVE) @@ -57,6 +71,13 @@ internal class CustomerCreditListPageResponseTest { .balance(0.0) .effectiveDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addFilter( + CustomerCreditListResponse.Filter.builder() + .field(CustomerCreditListResponse.Filter.Field.PRICE_ID) + .operator(CustomerCreditListResponse.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .maximumInitialBalance(0.0) .perUnitCostBasis("per_unit_cost_basis") .status(CustomerCreditListResponse.Status.ACTIVE) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditListResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditListResponseTest.kt index daabed930..1a32845e7 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditListResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditListResponseTest.kt @@ -18,6 +18,13 @@ internal class CustomerCreditListResponseTest { .balance(0.0) .effectiveDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addFilter( + CustomerCreditListResponse.Filter.builder() + .field(CustomerCreditListResponse.Filter.Field.PRICE_ID) + .operator(CustomerCreditListResponse.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .maximumInitialBalance(0.0) .perUnitCostBasis("per_unit_cost_basis") .status(CustomerCreditListResponse.Status.ACTIVE) @@ -29,6 +36,14 @@ internal class CustomerCreditListResponseTest { .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) assertThat(customerCreditListResponse.expiryDate()) .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(customerCreditListResponse.filters()) + .containsExactly( + CustomerCreditListResponse.Filter.builder() + .field(CustomerCreditListResponse.Filter.Field.PRICE_ID) + .operator(CustomerCreditListResponse.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) assertThat(customerCreditListResponse.maximumInitialBalance()).isEqualTo(0.0) assertThat(customerCreditListResponse.perUnitCostBasis()).isEqualTo("per_unit_cost_basis") assertThat(customerCreditListResponse.status()) @@ -44,6 +59,13 @@ internal class CustomerCreditListResponseTest { .balance(0.0) .effectiveDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addFilter( + CustomerCreditListResponse.Filter.builder() + .field(CustomerCreditListResponse.Filter.Field.PRICE_ID) + .operator(CustomerCreditListResponse.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .maximumInitialBalance(0.0) .perUnitCostBasis("per_unit_cost_basis") .status(CustomerCreditListResponse.Status.ACTIVE) From 680265b0add2f0c05eee02f1410cda5d14bd758b Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 31 Oct 2025 23:33:14 +0000 Subject: [PATCH 41/68] feat(api): api update --- .stats.yml | 4 +- ...editLedgerCreateEntryByExternalIdParams.kt | 593 +++++++++++++++++- .../CustomerCreditLedgerCreateEntryParams.kt | 593 +++++++++++++++++- .../withorb/api/models/NewAllocationPrice.kt | 571 ++++++++++++++++- .../models/BetaCreatePlanVersionParamsTest.kt | 42 ++ ...ternalPlanIdCreatePlanVersionParamsTest.kt | 42 ++ ...LedgerCreateEntryByExternalIdParamsTest.kt | 54 ++ ...stomerCreditLedgerCreateEntryParamsTest.kt | 43 ++ .../api/models/NewAllocationPriceTest.kt | 22 + .../api/models/PlanCreateParamsTest.kt | 21 + .../models/SubscriptionCreateParamsTest.kt | 42 ++ .../SubscriptionPriceIntervalsParamsTest.kt | 21 + ...ubscriptionSchedulePlanChangeParamsTest.kt | 42 ++ .../services/async/BetaServiceAsyncTest.kt | 14 + .../services/async/PlanServiceAsyncTest.kt | 7 + .../async/SubscriptionServiceAsyncTest.kt | 35 ++ .../beta/ExternalPlanIdServiceAsyncTest.kt | 14 + .../credits/LedgerServiceAsyncTest.kt | 37 ++ .../api/services/blocking/BetaServiceTest.kt | 14 + .../api/services/blocking/PlanServiceTest.kt | 7 + .../blocking/SubscriptionServiceTest.kt | 35 ++ .../beta/ExternalPlanIdServiceTest.kt | 14 + .../customers/credits/LedgerServiceTest.kt | 37 ++ 23 files changed, 2297 insertions(+), 7 deletions(-) diff --git a/.stats.yml b/.stats.yml index 3fc5d44cc..626045326 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 118 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-79664fa0b4ea00c978ae2516087d0ee591b0ef92ca8db29557a0424bde520e10.yml -openapi_spec_hash: 1ff6eee9184312a3a0fd21eb589132f9 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-d1abf71a1a70a43bdcc4da7104dabcbd67aa7e2d3e6cf21e33f50904b6997bb2.yml +openapi_spec_hash: 28b0b31a997588cf3692458889321e1b config_hash: dd4343ce95871032ef6e0735a4ca038c diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdParams.kt index 29dbfdcf7..653254463 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdParams.kt @@ -22,6 +22,7 @@ import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.Params import com.withorb.api.core.allMaxBy +import com.withorb.api.core.checkKnown import com.withorb.api.core.checkRequired import com.withorb.api.core.getOrThrow import com.withorb.api.core.http.Headers @@ -623,6 +624,7 @@ private constructor( private val description: JsonField, private val effectiveDate: JsonField, private val expiryDate: JsonField, + private val filters: JsonField>, private val invoiceSettings: JsonField, private val metadata: JsonField, private val perUnitCostBasis: JsonField, @@ -647,6 +649,9 @@ private constructor( @JsonProperty("expiry_date") @ExcludeMissing expiryDate: JsonField = JsonMissing.of(), + @JsonProperty("filters") + @ExcludeMissing + filters: JsonField> = JsonMissing.of(), @JsonProperty("invoice_settings") @ExcludeMissing invoiceSettings: JsonField = JsonMissing.of(), @@ -663,6 +668,7 @@ private constructor( description, effectiveDate, expiryDate, + filters, invoiceSettings, metadata, perUnitCostBasis, @@ -726,6 +732,15 @@ private constructor( */ fun expiryDate(): OffsetDateTime? = expiryDate.getNullable("expiry_date") + /** + * Optional filter to specify which items this credit block applies to. If not + * specified, the block will apply to all items for the pricing unit. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun filters(): List? = filters.getNullable("filters") + /** * Passing `invoice_settings` automatically generates an invoice for the newly added * credits. If `invoice_settings` is passed, you must specify per_unit_cost_basis, as @@ -801,6 +816,15 @@ private constructor( @ExcludeMissing fun _expiryDate(): JsonField = expiryDate + /** + * Returns the raw JSON value of [filters]. + * + * Unlike [filters], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("filters") + @ExcludeMissing + fun _filters(): JsonField> = filters + /** * Returns the raw JSON value of [invoiceSettings]. * @@ -865,6 +889,7 @@ private constructor( private var description: JsonField = JsonMissing.of() private var effectiveDate: JsonField = JsonMissing.of() private var expiryDate: JsonField = JsonMissing.of() + private var filters: JsonField>? = null private var invoiceSettings: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var perUnitCostBasis: JsonField = JsonMissing.of() @@ -877,6 +902,7 @@ private constructor( description = increment.description effectiveDate = increment.effectiveDate expiryDate = increment.expiryDate + filters = increment.filters.map { it.toMutableList() } invoiceSettings = increment.invoiceSettings metadata = increment.metadata perUnitCostBasis = increment.perUnitCostBasis @@ -979,6 +1005,35 @@ private constructor( this.expiryDate = expiryDate } + /** + * Optional filter to specify which items this credit block applies to. If not + * specified, the block will apply to all items for the pricing unit. + */ + fun filters(filters: List?) = filters(JsonField.ofNullable(filters)) + + /** + * Sets [Builder.filters] to an arbitrary JSON value. + * + * You should usually call [Builder.filters] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun filters(filters: JsonField>) = apply { + this.filters = filters.map { it.toMutableList() } + } + + /** + * Adds a single [Filter] to [filters]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addFilter(filter: Filter) = apply { + filters = + (filters ?: JsonField.of(mutableListOf())).also { + checkKnown("filters", it).add(filter) + } + } + /** * Passing `invoice_settings` automatically generates an invoice for the newly added * credits. If `invoice_settings` is passed, you must specify per_unit_cost_basis, @@ -1074,6 +1129,7 @@ private constructor( description, effectiveDate, expiryDate, + (filters ?: JsonMissing.of()).map { it.toImmutable() }, invoiceSettings, metadata, perUnitCostBasis, @@ -1098,6 +1154,7 @@ private constructor( description() effectiveDate() expiryDate() + filters()?.forEach { it.validate() } invoiceSettings()?.validate() metadata()?.validate() perUnitCostBasis() @@ -1125,10 +1182,542 @@ private constructor( (if (description.asKnown() == null) 0 else 1) + (if (effectiveDate.asKnown() == null) 0 else 1) + (if (expiryDate.asKnown() == null) 0 else 1) + + (filters.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + (invoiceSettings.asKnown()?.validity() ?: 0) + (metadata.asKnown()?.validity() ?: 0) + (if (perUnitCostBasis.asKnown() == null) 0 else 1) + /** A PriceFilter that only allows item_id field for block filters. */ + class Filter + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val field: JsonField, + private val operator: JsonField, + private val values: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("field") + @ExcludeMissing + field: JsonField = JsonMissing.of(), + @JsonProperty("operator") + @ExcludeMissing + operator: JsonField = JsonMissing.of(), + @JsonProperty("values") + @ExcludeMissing + values: JsonField> = JsonMissing.of(), + ) : this(field, operator, values, mutableMapOf()) + + /** + * The property of the price the block applies to. Only item_id is supported. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun field(): Field = field.getRequired("field") + + /** + * Should prices that match the filter be included or excluded. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun operator(): Operator = operator.getRequired("operator") + + /** + * The IDs or values that match this filter. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun values(): List = values.getRequired("values") + + /** + * Returns the raw JSON value of [field]. + * + * Unlike [field], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("field") @ExcludeMissing fun _field(): JsonField = field + + /** + * Returns the raw JSON value of [operator]. + * + * Unlike [operator], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("operator") + @ExcludeMissing + fun _operator(): JsonField = operator + + /** + * Returns the raw JSON value of [values]. + * + * Unlike [values], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("values") + @ExcludeMissing + fun _values(): JsonField> = values + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Filter]. + * + * The following fields are required: + * ```kotlin + * .field() + * .operator() + * .values() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Filter]. */ + class Builder internal constructor() { + + private var field: JsonField? = null + private var operator: JsonField? = null + private var values: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(filter: Filter) = apply { + field = filter.field + operator = filter.operator + values = filter.values.map { it.toMutableList() } + additionalProperties = filter.additionalProperties.toMutableMap() + } + + /** + * The property of the price the block applies to. Only item_id is supported. + */ + fun field(field: Field) = field(JsonField.of(field)) + + /** + * Sets [Builder.field] to an arbitrary JSON value. + * + * You should usually call [Builder.field] with a well-typed [Field] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun field(field: JsonField) = apply { this.field = field } + + /** Should prices that match the filter be included or excluded. */ + fun operator(operator: Operator) = operator(JsonField.of(operator)) + + /** + * Sets [Builder.operator] to an arbitrary JSON value. + * + * You should usually call [Builder.operator] with a well-typed [Operator] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun operator(operator: JsonField) = apply { this.operator = operator } + + /** The IDs or values that match this filter. */ + fun values(values: List) = values(JsonField.of(values)) + + /** + * Sets [Builder.values] to an arbitrary JSON value. + * + * You should usually call [Builder.values] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun values(values: JsonField>) = apply { + this.values = values.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [values]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addValue(value: String) = apply { + values = + (values ?: JsonField.of(mutableListOf())).also { + checkKnown("values", it).add(value) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Filter]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .field() + * .operator() + * .values() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Filter = + Filter( + checkRequired("field", field), + checkRequired("operator", operator), + checkRequired("values", values).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Filter = apply { + if (validated) { + return@apply + } + + field().validate() + operator().validate() + values() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (field.asKnown()?.validity() ?: 0) + + (operator.asKnown()?.validity() ?: 0) + + (values.asKnown()?.size ?: 0) + + /** The property of the price the block applies to. Only item_id is supported. */ + class Field @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ITEM_ID = of("item_id") + + fun of(value: String) = Field(JsonField.of(value)) + } + + /** An enum containing [Field]'s known values. */ + enum class Known { + ITEM_ID + } + + /** + * An enum containing [Field]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Field] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ITEM_ID, + /** + * An enum member indicating that [Field] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ITEM_ID -> Value.ITEM_ID + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ITEM_ID -> Known.ITEM_ID + else -> throw OrbInvalidDataException("Unknown Field: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Field = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Field && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Should prices that match the filter be included or excluded. */ + class Operator + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val INCLUDES = of("includes") + + val EXCLUDES = of("excludes") + + fun of(value: String) = Operator(JsonField.of(value)) + } + + /** An enum containing [Operator]'s known values. */ + enum class Known { + INCLUDES, + EXCLUDES, + } + + /** + * An enum containing [Operator]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [Operator] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + INCLUDES, + EXCLUDES, + /** + * An enum member indicating that [Operator] was instantiated with an + * unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + INCLUDES -> Value.INCLUDES + EXCLUDES -> Value.EXCLUDES + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + INCLUDES -> Known.INCLUDES + EXCLUDES -> Known.EXCLUDES + else -> throw OrbInvalidDataException("Unknown Operator: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Operator = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Operator && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Filter && + field == other.field && + operator == other.operator && + values == other.values && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(field, operator, values, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Filter{field=$field, operator=$operator, values=$values, additionalProperties=$additionalProperties}" + } + /** * Passing `invoice_settings` automatically generates an invoice for the newly added * credits. If `invoice_settings` is passed, you must specify per_unit_cost_basis, as @@ -2106,6 +2695,7 @@ private constructor( description == other.description && effectiveDate == other.effectiveDate && expiryDate == other.expiryDate && + filters == other.filters && invoiceSettings == other.invoiceSettings && metadata == other.metadata && perUnitCostBasis == other.perUnitCostBasis && @@ -2120,6 +2710,7 @@ private constructor( description, effectiveDate, expiryDate, + filters, invoiceSettings, metadata, perUnitCostBasis, @@ -2130,7 +2721,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Increment{amount=$amount, entryType=$entryType, currency=$currency, description=$description, effectiveDate=$effectiveDate, expiryDate=$expiryDate, invoiceSettings=$invoiceSettings, metadata=$metadata, perUnitCostBasis=$perUnitCostBasis, additionalProperties=$additionalProperties}" + "Increment{amount=$amount, entryType=$entryType, currency=$currency, description=$description, effectiveDate=$effectiveDate, expiryDate=$expiryDate, filters=$filters, invoiceSettings=$invoiceSettings, metadata=$metadata, perUnitCostBasis=$perUnitCostBasis, additionalProperties=$additionalProperties}" } class Decrement diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryParams.kt index 09d015c07..e86958399 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryParams.kt @@ -22,6 +22,7 @@ import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.Params import com.withorb.api.core.allMaxBy +import com.withorb.api.core.checkKnown import com.withorb.api.core.checkRequired import com.withorb.api.core.getOrThrow import com.withorb.api.core.http.Headers @@ -618,6 +619,7 @@ private constructor( private val description: JsonField, private val effectiveDate: JsonField, private val expiryDate: JsonField, + private val filters: JsonField>, private val invoiceSettings: JsonField, private val metadata: JsonField, private val perUnitCostBasis: JsonField, @@ -642,6 +644,9 @@ private constructor( @JsonProperty("expiry_date") @ExcludeMissing expiryDate: JsonField = JsonMissing.of(), + @JsonProperty("filters") + @ExcludeMissing + filters: JsonField> = JsonMissing.of(), @JsonProperty("invoice_settings") @ExcludeMissing invoiceSettings: JsonField = JsonMissing.of(), @@ -658,6 +663,7 @@ private constructor( description, effectiveDate, expiryDate, + filters, invoiceSettings, metadata, perUnitCostBasis, @@ -721,6 +727,15 @@ private constructor( */ fun expiryDate(): OffsetDateTime? = expiryDate.getNullable("expiry_date") + /** + * Optional filter to specify which items this credit block applies to. If not + * specified, the block will apply to all items for the pricing unit. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun filters(): List? = filters.getNullable("filters") + /** * Passing `invoice_settings` automatically generates an invoice for the newly added * credits. If `invoice_settings` is passed, you must specify per_unit_cost_basis, as @@ -796,6 +811,15 @@ private constructor( @ExcludeMissing fun _expiryDate(): JsonField = expiryDate + /** + * Returns the raw JSON value of [filters]. + * + * Unlike [filters], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("filters") + @ExcludeMissing + fun _filters(): JsonField> = filters + /** * Returns the raw JSON value of [invoiceSettings]. * @@ -860,6 +884,7 @@ private constructor( private var description: JsonField = JsonMissing.of() private var effectiveDate: JsonField = JsonMissing.of() private var expiryDate: JsonField = JsonMissing.of() + private var filters: JsonField>? = null private var invoiceSettings: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var perUnitCostBasis: JsonField = JsonMissing.of() @@ -872,6 +897,7 @@ private constructor( description = increment.description effectiveDate = increment.effectiveDate expiryDate = increment.expiryDate + filters = increment.filters.map { it.toMutableList() } invoiceSettings = increment.invoiceSettings metadata = increment.metadata perUnitCostBasis = increment.perUnitCostBasis @@ -974,6 +1000,35 @@ private constructor( this.expiryDate = expiryDate } + /** + * Optional filter to specify which items this credit block applies to. If not + * specified, the block will apply to all items for the pricing unit. + */ + fun filters(filters: List?) = filters(JsonField.ofNullable(filters)) + + /** + * Sets [Builder.filters] to an arbitrary JSON value. + * + * You should usually call [Builder.filters] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun filters(filters: JsonField>) = apply { + this.filters = filters.map { it.toMutableList() } + } + + /** + * Adds a single [Filter] to [filters]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addFilter(filter: Filter) = apply { + filters = + (filters ?: JsonField.of(mutableListOf())).also { + checkKnown("filters", it).add(filter) + } + } + /** * Passing `invoice_settings` automatically generates an invoice for the newly added * credits. If `invoice_settings` is passed, you must specify per_unit_cost_basis, @@ -1069,6 +1124,7 @@ private constructor( description, effectiveDate, expiryDate, + (filters ?: JsonMissing.of()).map { it.toImmutable() }, invoiceSettings, metadata, perUnitCostBasis, @@ -1093,6 +1149,7 @@ private constructor( description() effectiveDate() expiryDate() + filters()?.forEach { it.validate() } invoiceSettings()?.validate() metadata()?.validate() perUnitCostBasis() @@ -1120,10 +1177,542 @@ private constructor( (if (description.asKnown() == null) 0 else 1) + (if (effectiveDate.asKnown() == null) 0 else 1) + (if (expiryDate.asKnown() == null) 0 else 1) + + (filters.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + (invoiceSettings.asKnown()?.validity() ?: 0) + (metadata.asKnown()?.validity() ?: 0) + (if (perUnitCostBasis.asKnown() == null) 0 else 1) + /** A PriceFilter that only allows item_id field for block filters. */ + class Filter + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val field: JsonField, + private val operator: JsonField, + private val values: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("field") + @ExcludeMissing + field: JsonField = JsonMissing.of(), + @JsonProperty("operator") + @ExcludeMissing + operator: JsonField = JsonMissing.of(), + @JsonProperty("values") + @ExcludeMissing + values: JsonField> = JsonMissing.of(), + ) : this(field, operator, values, mutableMapOf()) + + /** + * The property of the price the block applies to. Only item_id is supported. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun field(): Field = field.getRequired("field") + + /** + * Should prices that match the filter be included or excluded. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun operator(): Operator = operator.getRequired("operator") + + /** + * The IDs or values that match this filter. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun values(): List = values.getRequired("values") + + /** + * Returns the raw JSON value of [field]. + * + * Unlike [field], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("field") @ExcludeMissing fun _field(): JsonField = field + + /** + * Returns the raw JSON value of [operator]. + * + * Unlike [operator], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("operator") + @ExcludeMissing + fun _operator(): JsonField = operator + + /** + * Returns the raw JSON value of [values]. + * + * Unlike [values], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("values") + @ExcludeMissing + fun _values(): JsonField> = values + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Filter]. + * + * The following fields are required: + * ```kotlin + * .field() + * .operator() + * .values() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Filter]. */ + class Builder internal constructor() { + + private var field: JsonField? = null + private var operator: JsonField? = null + private var values: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(filter: Filter) = apply { + field = filter.field + operator = filter.operator + values = filter.values.map { it.toMutableList() } + additionalProperties = filter.additionalProperties.toMutableMap() + } + + /** + * The property of the price the block applies to. Only item_id is supported. + */ + fun field(field: Field) = field(JsonField.of(field)) + + /** + * Sets [Builder.field] to an arbitrary JSON value. + * + * You should usually call [Builder.field] with a well-typed [Field] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun field(field: JsonField) = apply { this.field = field } + + /** Should prices that match the filter be included or excluded. */ + fun operator(operator: Operator) = operator(JsonField.of(operator)) + + /** + * Sets [Builder.operator] to an arbitrary JSON value. + * + * You should usually call [Builder.operator] with a well-typed [Operator] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun operator(operator: JsonField) = apply { this.operator = operator } + + /** The IDs or values that match this filter. */ + fun values(values: List) = values(JsonField.of(values)) + + /** + * Sets [Builder.values] to an arbitrary JSON value. + * + * You should usually call [Builder.values] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun values(values: JsonField>) = apply { + this.values = values.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [values]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addValue(value: String) = apply { + values = + (values ?: JsonField.of(mutableListOf())).also { + checkKnown("values", it).add(value) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Filter]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .field() + * .operator() + * .values() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Filter = + Filter( + checkRequired("field", field), + checkRequired("operator", operator), + checkRequired("values", values).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Filter = apply { + if (validated) { + return@apply + } + + field().validate() + operator().validate() + values() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (field.asKnown()?.validity() ?: 0) + + (operator.asKnown()?.validity() ?: 0) + + (values.asKnown()?.size ?: 0) + + /** The property of the price the block applies to. Only item_id is supported. */ + class Field @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ITEM_ID = of("item_id") + + fun of(value: String) = Field(JsonField.of(value)) + } + + /** An enum containing [Field]'s known values. */ + enum class Known { + ITEM_ID + } + + /** + * An enum containing [Field]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Field] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ITEM_ID, + /** + * An enum member indicating that [Field] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ITEM_ID -> Value.ITEM_ID + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ITEM_ID -> Known.ITEM_ID + else -> throw OrbInvalidDataException("Unknown Field: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Field = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Field && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Should prices that match the filter be included or excluded. */ + class Operator + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val INCLUDES = of("includes") + + val EXCLUDES = of("excludes") + + fun of(value: String) = Operator(JsonField.of(value)) + } + + /** An enum containing [Operator]'s known values. */ + enum class Known { + INCLUDES, + EXCLUDES, + } + + /** + * An enum containing [Operator]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [Operator] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + INCLUDES, + EXCLUDES, + /** + * An enum member indicating that [Operator] was instantiated with an + * unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + INCLUDES -> Value.INCLUDES + EXCLUDES -> Value.EXCLUDES + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + INCLUDES -> Known.INCLUDES + EXCLUDES -> Known.EXCLUDES + else -> throw OrbInvalidDataException("Unknown Operator: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Operator = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Operator && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Filter && + field == other.field && + operator == other.operator && + values == other.values && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(field, operator, values, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Filter{field=$field, operator=$operator, values=$values, additionalProperties=$additionalProperties}" + } + /** * Passing `invoice_settings` automatically generates an invoice for the newly added * credits. If `invoice_settings` is passed, you must specify per_unit_cost_basis, as @@ -2101,6 +2690,7 @@ private constructor( description == other.description && effectiveDate == other.effectiveDate && expiryDate == other.expiryDate && + filters == other.filters && invoiceSettings == other.invoiceSettings && metadata == other.metadata && perUnitCostBasis == other.perUnitCostBasis && @@ -2115,6 +2705,7 @@ private constructor( description, effectiveDate, expiryDate, + filters, invoiceSettings, metadata, perUnitCostBasis, @@ -2125,7 +2716,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Increment{amount=$amount, entryType=$entryType, currency=$currency, description=$description, effectiveDate=$effectiveDate, expiryDate=$expiryDate, invoiceSettings=$invoiceSettings, metadata=$metadata, perUnitCostBasis=$perUnitCostBasis, additionalProperties=$additionalProperties}" + "Increment{amount=$amount, entryType=$entryType, currency=$currency, description=$description, effectiveDate=$effectiveDate, expiryDate=$expiryDate, filters=$filters, invoiceSettings=$invoiceSettings, metadata=$metadata, perUnitCostBasis=$perUnitCostBasis, additionalProperties=$additionalProperties}" } class Decrement diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewAllocationPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewAllocationPrice.kt index 18c13df03..e7652a3d6 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewAllocationPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewAllocationPrice.kt @@ -11,7 +11,9 @@ import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue +import com.withorb.api.core.checkKnown import com.withorb.api.core.checkRequired +import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import java.util.Collections import java.util.Objects @@ -24,6 +26,7 @@ private constructor( private val currency: JsonField, private val customExpiration: JsonField, private val expiresAtEndOfCadence: JsonField, + private val filters: JsonField>, private val additionalProperties: MutableMap, ) { @@ -38,7 +41,16 @@ private constructor( @JsonProperty("expires_at_end_of_cadence") @ExcludeMissing expiresAtEndOfCadence: JsonField = JsonMissing.of(), - ) : this(amount, cadence, currency, customExpiration, expiresAtEndOfCadence, mutableMapOf()) + @JsonProperty("filters") @ExcludeMissing filters: JsonField> = JsonMissing.of(), + ) : this( + amount, + cadence, + currency, + customExpiration, + expiresAtEndOfCadence, + filters, + mutableMapOf(), + ) /** * An amount of the currency to allocate to the customer at the specified cadence. @@ -82,6 +94,14 @@ private constructor( fun expiresAtEndOfCadence(): Boolean? = expiresAtEndOfCadence.getNullable("expires_at_end_of_cadence") + /** + * The filters that determine which items the allocation applies to. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun filters(): List? = filters.getNullable("filters") + /** * Returns the raw JSON value of [amount]. * @@ -123,6 +143,13 @@ private constructor( @ExcludeMissing fun _expiresAtEndOfCadence(): JsonField = expiresAtEndOfCadence + /** + * Returns the raw JSON value of [filters]. + * + * Unlike [filters], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("filters") @ExcludeMissing fun _filters(): JsonField> = filters + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -158,6 +185,7 @@ private constructor( private var currency: JsonField? = null private var customExpiration: JsonField = JsonMissing.of() private var expiresAtEndOfCadence: JsonField = JsonMissing.of() + private var filters: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(newAllocationPrice: NewAllocationPrice) = apply { @@ -166,6 +194,7 @@ private constructor( currency = newAllocationPrice.currency customExpiration = newAllocationPrice.customExpiration expiresAtEndOfCadence = newAllocationPrice.expiresAtEndOfCadence + filters = newAllocationPrice.filters.map { it.toMutableList() } additionalProperties = newAllocationPrice.additionalProperties.toMutableMap() } @@ -246,6 +275,32 @@ private constructor( this.expiresAtEndOfCadence = expiresAtEndOfCadence } + /** The filters that determine which items the allocation applies to. */ + fun filters(filters: List?) = filters(JsonField.ofNullable(filters)) + + /** + * Sets [Builder.filters] to an arbitrary JSON value. + * + * You should usually call [Builder.filters] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun filters(filters: JsonField>) = apply { + this.filters = filters.map { it.toMutableList() } + } + + /** + * Adds a single [Filter] to [filters]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addFilter(filter: Filter) = apply { + filters = + (filters ?: JsonField.of(mutableListOf())).also { + checkKnown("filters", it).add(filter) + } + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -286,6 +341,7 @@ private constructor( checkRequired("currency", currency), customExpiration, expiresAtEndOfCadence, + (filters ?: JsonMissing.of()).map { it.toImmutable() }, additionalProperties.toMutableMap(), ) } @@ -302,6 +358,7 @@ private constructor( currency() customExpiration()?.validate() expiresAtEndOfCadence() + filters()?.forEach { it.validate() } validated = true } @@ -323,7 +380,8 @@ private constructor( (cadence.asKnown()?.validity() ?: 0) + (if (currency.asKnown() == null) 0 else 1) + (customExpiration.asKnown()?.validity() ?: 0) + - (if (expiresAtEndOfCadence.asKnown() == null) 0 else 1) + (if (expiresAtEndOfCadence.asKnown() == null) 0 else 1) + + (filters.asKnown()?.sumOf { it.validity().toInt() } ?: 0) /** The cadence at which to allocate the amount to the customer. */ class Cadence @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -468,6 +526,511 @@ private constructor( override fun toString() = value.toString() } + /** A PriceFilter that only allows item_id field for block filters. */ + class Filter + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val field: JsonField, + private val operator: JsonField, + private val values: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("field") @ExcludeMissing field: JsonField = JsonMissing.of(), + @JsonProperty("operator") + @ExcludeMissing + operator: JsonField = JsonMissing.of(), + @JsonProperty("values") + @ExcludeMissing + values: JsonField> = JsonMissing.of(), + ) : this(field, operator, values, mutableMapOf()) + + /** + * The property of the price the block applies to. Only item_id is supported. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun field(): Field = field.getRequired("field") + + /** + * Should prices that match the filter be included or excluded. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun operator(): Operator = operator.getRequired("operator") + + /** + * The IDs or values that match this filter. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun values(): List = values.getRequired("values") + + /** + * Returns the raw JSON value of [field]. + * + * Unlike [field], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("field") @ExcludeMissing fun _field(): JsonField = field + + /** + * Returns the raw JSON value of [operator]. + * + * Unlike [operator], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("operator") @ExcludeMissing fun _operator(): JsonField = operator + + /** + * Returns the raw JSON value of [values]. + * + * Unlike [values], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("values") @ExcludeMissing fun _values(): JsonField> = values + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Filter]. + * + * The following fields are required: + * ```kotlin + * .field() + * .operator() + * .values() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Filter]. */ + class Builder internal constructor() { + + private var field: JsonField? = null + private var operator: JsonField? = null + private var values: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(filter: Filter) = apply { + field = filter.field + operator = filter.operator + values = filter.values.map { it.toMutableList() } + additionalProperties = filter.additionalProperties.toMutableMap() + } + + /** The property of the price the block applies to. Only item_id is supported. */ + fun field(field: Field) = field(JsonField.of(field)) + + /** + * Sets [Builder.field] to an arbitrary JSON value. + * + * You should usually call [Builder.field] with a well-typed [Field] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun field(field: JsonField) = apply { this.field = field } + + /** Should prices that match the filter be included or excluded. */ + fun operator(operator: Operator) = operator(JsonField.of(operator)) + + /** + * Sets [Builder.operator] to an arbitrary JSON value. + * + * You should usually call [Builder.operator] with a well-typed [Operator] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun operator(operator: JsonField) = apply { this.operator = operator } + + /** The IDs or values that match this filter. */ + fun values(values: List) = values(JsonField.of(values)) + + /** + * Sets [Builder.values] to an arbitrary JSON value. + * + * You should usually call [Builder.values] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun values(values: JsonField>) = apply { + this.values = values.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [values]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addValue(value: String) = apply { + values = + (values ?: JsonField.of(mutableListOf())).also { + checkKnown("values", it).add(value) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Filter]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .field() + * .operator() + * .values() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Filter = + Filter( + checkRequired("field", field), + checkRequired("operator", operator), + checkRequired("values", values).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Filter = apply { + if (validated) { + return@apply + } + + field().validate() + operator().validate() + values() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (field.asKnown()?.validity() ?: 0) + + (operator.asKnown()?.validity() ?: 0) + + (values.asKnown()?.size ?: 0) + + /** The property of the price the block applies to. Only item_id is supported. */ + class Field @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val ITEM_ID = of("item_id") + + fun of(value: String) = Field(JsonField.of(value)) + } + + /** An enum containing [Field]'s known values. */ + enum class Known { + ITEM_ID + } + + /** + * An enum containing [Field]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Field] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ITEM_ID, + /** + * An enum member indicating that [Field] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ITEM_ID -> Value.ITEM_ID + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + ITEM_ID -> Known.ITEM_ID + else -> throw OrbInvalidDataException("Unknown Field: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Field = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Field && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Should prices that match the filter be included or excluded. */ + class Operator @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val INCLUDES = of("includes") + + val EXCLUDES = of("excludes") + + fun of(value: String) = Operator(JsonField.of(value)) + } + + /** An enum containing [Operator]'s known values. */ + enum class Known { + INCLUDES, + EXCLUDES, + } + + /** + * An enum containing [Operator]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Operator] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + INCLUDES, + EXCLUDES, + /** + * An enum member indicating that [Operator] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + INCLUDES -> Value.INCLUDES + EXCLUDES -> Value.EXCLUDES + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + INCLUDES -> Known.INCLUDES + EXCLUDES -> Known.EXCLUDES + else -> throw OrbInvalidDataException("Unknown Operator: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Operator = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Operator && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Filter && + field == other.field && + operator == other.operator && + values == other.values && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(field, operator, values, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Filter{field=$field, operator=$operator, values=$values, additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -479,6 +1042,7 @@ private constructor( currency == other.currency && customExpiration == other.customExpiration && expiresAtEndOfCadence == other.expiresAtEndOfCadence && + filters == other.filters && additionalProperties == other.additionalProperties } @@ -489,6 +1053,7 @@ private constructor( currency, customExpiration, expiresAtEndOfCadence, + filters, additionalProperties, ) } @@ -496,5 +1061,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewAllocationPrice{amount=$amount, cadence=$cadence, currency=$currency, customExpiration=$customExpiration, expiresAtEndOfCadence=$expiresAtEndOfCadence, additionalProperties=$additionalProperties}" + "NewAllocationPrice{amount=$amount, cadence=$cadence, currency=$currency, customExpiration=$customExpiration, expiresAtEndOfCadence=$expiresAtEndOfCadence, filters=$filters, additionalProperties=$additionalProperties}" } diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/BetaCreatePlanVersionParamsTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/BetaCreatePlanVersionParamsTest.kt index e6acde520..3dbe50042 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/BetaCreatePlanVersionParamsTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/BetaCreatePlanVersionParamsTest.kt @@ -55,6 +55,13 @@ internal class BetaCreatePlanVersionParamsTest { .build() ) .expiresAtEndOfCadence(true) + .addFilter( + NewAllocationPrice.Filter.builder() + .field(NewAllocationPrice.Filter.Field.ITEM_ID) + .operator(NewAllocationPrice.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .planPhaseOrder(0L) @@ -162,6 +169,13 @@ internal class BetaCreatePlanVersionParamsTest { .build() ) .expiresAtEndOfCadence(true) + .addFilter( + NewAllocationPrice.Filter.builder() + .field(NewAllocationPrice.Filter.Field.ITEM_ID) + .operator(NewAllocationPrice.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .planPhaseOrder(0L) @@ -274,6 +288,13 @@ internal class BetaCreatePlanVersionParamsTest { .build() ) .expiresAtEndOfCadence(true) + .addFilter( + NewAllocationPrice.Filter.builder() + .field(NewAllocationPrice.Filter.Field.ITEM_ID) + .operator(NewAllocationPrice.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .planPhaseOrder(0L) @@ -383,6 +404,13 @@ internal class BetaCreatePlanVersionParamsTest { .build() ) .expiresAtEndOfCadence(true) + .addFilter( + NewAllocationPrice.Filter.builder() + .field(NewAllocationPrice.Filter.Field.ITEM_ID) + .operator(NewAllocationPrice.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .planPhaseOrder(0L) @@ -486,6 +514,13 @@ internal class BetaCreatePlanVersionParamsTest { .build() ) .expiresAtEndOfCadence(true) + .addFilter( + NewAllocationPrice.Filter.builder() + .field(NewAllocationPrice.Filter.Field.ITEM_ID) + .operator(NewAllocationPrice.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .planPhaseOrder(0L) @@ -597,6 +632,13 @@ internal class BetaCreatePlanVersionParamsTest { .build() ) .expiresAtEndOfCadence(true) + .addFilter( + NewAllocationPrice.Filter.builder() + .field(NewAllocationPrice.Filter.Field.ITEM_ID) + .operator(NewAllocationPrice.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .planPhaseOrder(0L) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/BetaExternalPlanIdCreatePlanVersionParamsTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/BetaExternalPlanIdCreatePlanVersionParamsTest.kt index 6f438cc15..4dbf59c0e 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/BetaExternalPlanIdCreatePlanVersionParamsTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/BetaExternalPlanIdCreatePlanVersionParamsTest.kt @@ -55,6 +55,13 @@ internal class BetaExternalPlanIdCreatePlanVersionParamsTest { .build() ) .expiresAtEndOfCadence(true) + .addFilter( + NewAllocationPrice.Filter.builder() + .field(NewAllocationPrice.Filter.Field.ITEM_ID) + .operator(NewAllocationPrice.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .planPhaseOrder(0L) @@ -162,6 +169,13 @@ internal class BetaExternalPlanIdCreatePlanVersionParamsTest { .build() ) .expiresAtEndOfCadence(true) + .addFilter( + NewAllocationPrice.Filter.builder() + .field(NewAllocationPrice.Filter.Field.ITEM_ID) + .operator(NewAllocationPrice.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .planPhaseOrder(0L) @@ -278,6 +292,13 @@ internal class BetaExternalPlanIdCreatePlanVersionParamsTest { .build() ) .expiresAtEndOfCadence(true) + .addFilter( + NewAllocationPrice.Filter.builder() + .field(NewAllocationPrice.Filter.Field.ITEM_ID) + .operator(NewAllocationPrice.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .planPhaseOrder(0L) @@ -387,6 +408,13 @@ internal class BetaExternalPlanIdCreatePlanVersionParamsTest { .build() ) .expiresAtEndOfCadence(true) + .addFilter( + NewAllocationPrice.Filter.builder() + .field(NewAllocationPrice.Filter.Field.ITEM_ID) + .operator(NewAllocationPrice.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .planPhaseOrder(0L) @@ -490,6 +518,13 @@ internal class BetaExternalPlanIdCreatePlanVersionParamsTest { .build() ) .expiresAtEndOfCadence(true) + .addFilter( + NewAllocationPrice.Filter.builder() + .field(NewAllocationPrice.Filter.Field.ITEM_ID) + .operator(NewAllocationPrice.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .planPhaseOrder(0L) @@ -601,6 +636,13 @@ internal class BetaExternalPlanIdCreatePlanVersionParamsTest { .build() ) .expiresAtEndOfCadence(true) + .addFilter( + NewAllocationPrice.Filter.builder() + .field(NewAllocationPrice.Filter.Field.ITEM_ID) + .operator(NewAllocationPrice.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .planPhaseOrder(0L) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdParamsTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdParamsTest.kt index 7bbe52742..b3e0fc5c6 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdParamsTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdParamsTest.kt @@ -21,6 +21,24 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdParamsTest { .description("description") .effectiveDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addFilter( + CustomerCreditLedgerCreateEntryByExternalIdParams.Body.Increment.Filter + .builder() + .field( + CustomerCreditLedgerCreateEntryByExternalIdParams.Body.Increment + .Filter + .Field + .ITEM_ID + ) + .operator( + CustomerCreditLedgerCreateEntryByExternalIdParams.Body.Increment + .Filter + .Operator + .INCLUDES + ) + .addValue("string") + .build() + ) .invoiceSettings( CustomerCreditLedgerCreateEntryByExternalIdParams.Body.Increment .InvoiceSettings @@ -71,6 +89,24 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdParamsTest { .description("description") .effectiveDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addFilter( + CustomerCreditLedgerCreateEntryByExternalIdParams.Body.Increment.Filter + .builder() + .field( + CustomerCreditLedgerCreateEntryByExternalIdParams.Body.Increment + .Filter + .Field + .ITEM_ID + ) + .operator( + CustomerCreditLedgerCreateEntryByExternalIdParams.Body.Increment + .Filter + .Operator + .INCLUDES + ) + .addValue("string") + .build() + ) .invoiceSettings( CustomerCreditLedgerCreateEntryByExternalIdParams.Body.Increment .InvoiceSettings @@ -107,6 +143,24 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdParamsTest { .description("description") .effectiveDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addFilter( + CustomerCreditLedgerCreateEntryByExternalIdParams.Body.Increment.Filter + .builder() + .field( + CustomerCreditLedgerCreateEntryByExternalIdParams.Body.Increment + .Filter + .Field + .ITEM_ID + ) + .operator( + CustomerCreditLedgerCreateEntryByExternalIdParams.Body.Increment + .Filter + .Operator + .INCLUDES + ) + .addValue("string") + .build() + ) .invoiceSettings( CustomerCreditLedgerCreateEntryByExternalIdParams.Body.Increment .InvoiceSettings diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryParamsTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryParamsTest.kt index f9478f7e6..0c2fa0a85 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryParamsTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryParamsTest.kt @@ -21,6 +21,19 @@ internal class CustomerCreditLedgerCreateEntryParamsTest { .description("description") .effectiveDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addFilter( + CustomerCreditLedgerCreateEntryParams.Body.Increment.Filter.builder() + .field( + CustomerCreditLedgerCreateEntryParams.Body.Increment.Filter.Field + .ITEM_ID + ) + .operator( + CustomerCreditLedgerCreateEntryParams.Body.Increment.Filter.Operator + .INCLUDES + ) + .addValue("string") + .build() + ) .invoiceSettings( CustomerCreditLedgerCreateEntryParams.Body.Increment.InvoiceSettings .builder() @@ -69,6 +82,21 @@ internal class CustomerCreditLedgerCreateEntryParamsTest { .description("description") .effectiveDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addFilter( + CustomerCreditLedgerCreateEntryParams.Body.Increment.Filter.builder() + .field( + CustomerCreditLedgerCreateEntryParams.Body.Increment.Filter + .Field + .ITEM_ID + ) + .operator( + CustomerCreditLedgerCreateEntryParams.Body.Increment.Filter + .Operator + .INCLUDES + ) + .addValue("string") + .build() + ) .invoiceSettings( CustomerCreditLedgerCreateEntryParams.Body.Increment.InvoiceSettings .builder() @@ -102,6 +130,21 @@ internal class CustomerCreditLedgerCreateEntryParamsTest { .description("description") .effectiveDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addFilter( + CustomerCreditLedgerCreateEntryParams.Body.Increment.Filter.builder() + .field( + CustomerCreditLedgerCreateEntryParams.Body.Increment.Filter + .Field + .ITEM_ID + ) + .operator( + CustomerCreditLedgerCreateEntryParams.Body.Increment.Filter + .Operator + .INCLUDES + ) + .addValue("string") + .build() + ) .invoiceSettings( CustomerCreditLedgerCreateEntryParams.Body.Increment.InvoiceSettings .builder() diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewAllocationPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewAllocationPriceTest.kt index 56b70a58f..79d602095 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewAllocationPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewAllocationPriceTest.kt @@ -23,6 +23,13 @@ internal class NewAllocationPriceTest { .build() ) .expiresAtEndOfCadence(true) + .addFilter( + NewAllocationPrice.Filter.builder() + .field(NewAllocationPrice.Filter.Field.ITEM_ID) + .operator(NewAllocationPrice.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() assertThat(newAllocationPrice.amount()).isEqualTo("10.00") @@ -36,6 +43,14 @@ internal class NewAllocationPriceTest { .build() ) assertThat(newAllocationPrice.expiresAtEndOfCadence()).isEqualTo(true) + assertThat(newAllocationPrice.filters()) + .containsExactly( + NewAllocationPrice.Filter.builder() + .field(NewAllocationPrice.Filter.Field.ITEM_ID) + .operator(NewAllocationPrice.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) } @Test @@ -53,6 +68,13 @@ internal class NewAllocationPriceTest { .build() ) .expiresAtEndOfCadence(true) + .addFilter( + NewAllocationPrice.Filter.builder() + .field(NewAllocationPrice.Filter.Field.ITEM_ID) + .operator(NewAllocationPrice.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() val roundtrippedNewAllocationPrice = diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanCreateParamsTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanCreateParamsTest.kt index 513f93689..94359c89b 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanCreateParamsTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanCreateParamsTest.kt @@ -27,6 +27,13 @@ internal class PlanCreateParamsTest { .build() ) .expiresAtEndOfCadence(true) + .addFilter( + NewAllocationPrice.Filter.builder() + .field(NewAllocationPrice.Filter.Field.ITEM_ID) + .operator(NewAllocationPrice.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .planPhaseOrder(0L) @@ -146,6 +153,13 @@ internal class PlanCreateParamsTest { .build() ) .expiresAtEndOfCadence(true) + .addFilter( + NewAllocationPrice.Filter.builder() + .field(NewAllocationPrice.Filter.Field.ITEM_ID) + .operator(NewAllocationPrice.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .planPhaseOrder(0L) @@ -265,6 +279,13 @@ internal class PlanCreateParamsTest { .build() ) .expiresAtEndOfCadence(true) + .addFilter( + NewAllocationPrice.Filter.builder() + .field(NewAllocationPrice.Filter.Field.ITEM_ID) + .operator(NewAllocationPrice.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .planPhaseOrder(0L) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionCreateParamsTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionCreateParamsTest.kt index d5d17446b..1d0825138 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionCreateParamsTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionCreateParamsTest.kt @@ -56,6 +56,13 @@ internal class SubscriptionCreateParamsTest { .build() ) .expiresAtEndOfCadence(true) + .addFilter( + NewAllocationPrice.Filter.builder() + .field(NewAllocationPrice.Filter.Field.ITEM_ID) + .operator(NewAllocationPrice.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .addDiscount( @@ -205,6 +212,13 @@ internal class SubscriptionCreateParamsTest { .build() ) .expiresAtEndOfCadence(true) + .addFilter( + NewAllocationPrice.Filter.builder() + .field(NewAllocationPrice.Filter.Field.ITEM_ID) + .operator(NewAllocationPrice.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .addDiscount( @@ -322,6 +336,13 @@ internal class SubscriptionCreateParamsTest { .build() ) .expiresAtEndOfCadence(true) + .addFilter( + NewAllocationPrice.Filter.builder() + .field(NewAllocationPrice.Filter.Field.ITEM_ID) + .operator(NewAllocationPrice.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .addDiscount( @@ -473,6 +494,13 @@ internal class SubscriptionCreateParamsTest { .build() ) .expiresAtEndOfCadence(true) + .addFilter( + NewAllocationPrice.Filter.builder() + .field(NewAllocationPrice.Filter.Field.ITEM_ID) + .operator(NewAllocationPrice.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .addDiscount( @@ -591,6 +619,13 @@ internal class SubscriptionCreateParamsTest { .build() ) .expiresAtEndOfCadence(true) + .addFilter( + NewAllocationPrice.Filter.builder() + .field(NewAllocationPrice.Filter.Field.ITEM_ID) + .operator(NewAllocationPrice.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .addDiscount( @@ -746,6 +781,13 @@ internal class SubscriptionCreateParamsTest { .build() ) .expiresAtEndOfCadence(true) + .addFilter( + NewAllocationPrice.Filter.builder() + .field(NewAllocationPrice.Filter.Field.ITEM_ID) + .operator(NewAllocationPrice.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .addDiscount( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsParamsTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsParamsTest.kt index 7e863cd19..503aa3c29 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsParamsTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsParamsTest.kt @@ -28,6 +28,13 @@ internal class SubscriptionPriceIntervalsParamsTest { .build() ) .expiresAtEndOfCadence(true) + .addFilter( + NewAllocationPrice.Filter.builder() + .field(NewAllocationPrice.Filter.Field.ITEM_ID) + .operator(NewAllocationPrice.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .addAmountDiscount(0.0) @@ -178,6 +185,13 @@ internal class SubscriptionPriceIntervalsParamsTest { .build() ) .expiresAtEndOfCadence(true) + .addFilter( + NewAllocationPrice.Filter.builder() + .field(NewAllocationPrice.Filter.Field.ITEM_ID) + .operator(NewAllocationPrice.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .addAmountDiscount(0.0) @@ -319,6 +333,13 @@ internal class SubscriptionPriceIntervalsParamsTest { .build() ) .expiresAtEndOfCadence(true) + .addFilter( + NewAllocationPrice.Filter.builder() + .field(NewAllocationPrice.Filter.Field.ITEM_ID) + .operator(NewAllocationPrice.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .addAmountDiscount(0.0) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionSchedulePlanChangeParamsTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionSchedulePlanChangeParamsTest.kt index 73627955e..4f20c056b 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionSchedulePlanChangeParamsTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionSchedulePlanChangeParamsTest.kt @@ -58,6 +58,13 @@ internal class SubscriptionSchedulePlanChangeParamsTest { .build() ) .expiresAtEndOfCadence(true) + .addFilter( + NewAllocationPrice.Filter.builder() + .field(NewAllocationPrice.Filter.Field.ITEM_ID) + .operator(NewAllocationPrice.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .addDiscount( @@ -198,6 +205,13 @@ internal class SubscriptionSchedulePlanChangeParamsTest { .build() ) .expiresAtEndOfCadence(true) + .addFilter( + NewAllocationPrice.Filter.builder() + .field(NewAllocationPrice.Filter.Field.ITEM_ID) + .operator(NewAllocationPrice.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .addDiscount( @@ -329,6 +343,13 @@ internal class SubscriptionSchedulePlanChangeParamsTest { .build() ) .expiresAtEndOfCadence(true) + .addFilter( + NewAllocationPrice.Filter.builder() + .field(NewAllocationPrice.Filter.Field.ITEM_ID) + .operator(NewAllocationPrice.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .addDiscount( @@ -471,6 +492,13 @@ internal class SubscriptionSchedulePlanChangeParamsTest { .build() ) .expiresAtEndOfCadence(true) + .addFilter( + NewAllocationPrice.Filter.builder() + .field(NewAllocationPrice.Filter.Field.ITEM_ID) + .operator(NewAllocationPrice.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .addDiscount( @@ -590,6 +618,13 @@ internal class SubscriptionSchedulePlanChangeParamsTest { .build() ) .expiresAtEndOfCadence(true) + .addFilter( + NewAllocationPrice.Filter.builder() + .field(NewAllocationPrice.Filter.Field.ITEM_ID) + .operator(NewAllocationPrice.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .addDiscount( @@ -732,6 +767,13 @@ internal class SubscriptionSchedulePlanChangeParamsTest { .build() ) .expiresAtEndOfCadence(true) + .addFilter( + NewAllocationPrice.Filter.builder() + .field(NewAllocationPrice.Filter.Field.ITEM_ID) + .operator(NewAllocationPrice.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .addDiscount( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/BetaServiceAsyncTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/BetaServiceAsyncTest.kt index 648310b19..3d268cc3d 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/BetaServiceAsyncTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/BetaServiceAsyncTest.kt @@ -80,6 +80,13 @@ internal class BetaServiceAsyncTest { .build() ) .expiresAtEndOfCadence(true) + .addFilter( + NewAllocationPrice.Filter.builder() + .field(NewAllocationPrice.Filter.Field.ITEM_ID) + .operator(NewAllocationPrice.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .planPhaseOrder(0L) @@ -197,6 +204,13 @@ internal class BetaServiceAsyncTest { .build() ) .expiresAtEndOfCadence(true) + .addFilter( + NewAllocationPrice.Filter.builder() + .field(NewAllocationPrice.Filter.Field.ITEM_ID) + .operator(NewAllocationPrice.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .planPhaseOrder(0L) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/PlanServiceAsyncTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/PlanServiceAsyncTest.kt index 37bd03ebb..988695a6e 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/PlanServiceAsyncTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/PlanServiceAsyncTest.kt @@ -49,6 +49,13 @@ internal class PlanServiceAsyncTest { .build() ) .expiresAtEndOfCadence(true) + .addFilter( + NewAllocationPrice.Filter.builder() + .field(NewAllocationPrice.Filter.Field.ITEM_ID) + .operator(NewAllocationPrice.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .planPhaseOrder(0L) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/SubscriptionServiceAsyncTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/SubscriptionServiceAsyncTest.kt index f97e3cc1a..7255e063d 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/SubscriptionServiceAsyncTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/SubscriptionServiceAsyncTest.kt @@ -95,6 +95,13 @@ internal class SubscriptionServiceAsyncTest { .build() ) .expiresAtEndOfCadence(true) + .addFilter( + NewAllocationPrice.Filter.builder() + .field(NewAllocationPrice.Filter.Field.ITEM_ID) + .operator(NewAllocationPrice.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .addDiscount( @@ -254,6 +261,13 @@ internal class SubscriptionServiceAsyncTest { .build() ) .expiresAtEndOfCadence(true) + .addFilter( + NewAllocationPrice.Filter.builder() + .field(NewAllocationPrice.Filter.Field.ITEM_ID) + .operator(NewAllocationPrice.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .addDiscount( @@ -508,6 +522,13 @@ internal class SubscriptionServiceAsyncTest { .build() ) .expiresAtEndOfCadence(true) + .addFilter( + NewAllocationPrice.Filter.builder() + .field(NewAllocationPrice.Filter.Field.ITEM_ID) + .operator(NewAllocationPrice.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .addAmountDiscount(0.0) @@ -727,6 +748,13 @@ internal class SubscriptionServiceAsyncTest { .build() ) .expiresAtEndOfCadence(true) + .addFilter( + NewAllocationPrice.Filter.builder() + .field(NewAllocationPrice.Filter.Field.ITEM_ID) + .operator(NewAllocationPrice.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .addDiscount( @@ -877,6 +905,13 @@ internal class SubscriptionServiceAsyncTest { .build() ) .expiresAtEndOfCadence(true) + .addFilter( + NewAllocationPrice.Filter.builder() + .field(NewAllocationPrice.Filter.Field.ITEM_ID) + .operator(NewAllocationPrice.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .addDiscount( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/beta/ExternalPlanIdServiceAsyncTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/beta/ExternalPlanIdServiceAsyncTest.kt index 96c9b1e02..1a4adb3d5 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/beta/ExternalPlanIdServiceAsyncTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/beta/ExternalPlanIdServiceAsyncTest.kt @@ -80,6 +80,13 @@ internal class ExternalPlanIdServiceAsyncTest { .build() ) .expiresAtEndOfCadence(true) + .addFilter( + NewAllocationPrice.Filter.builder() + .field(NewAllocationPrice.Filter.Field.ITEM_ID) + .operator(NewAllocationPrice.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .planPhaseOrder(0L) @@ -197,6 +204,13 @@ internal class ExternalPlanIdServiceAsyncTest { .build() ) .expiresAtEndOfCadence(true) + .addFilter( + NewAllocationPrice.Filter.builder() + .field(NewAllocationPrice.Filter.Field.ITEM_ID) + .operator(NewAllocationPrice.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .planPhaseOrder(0L) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/customers/credits/LedgerServiceAsyncTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/customers/credits/LedgerServiceAsyncTest.kt index cccdbbab9..e52cff0ca 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/customers/credits/LedgerServiceAsyncTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/customers/credits/LedgerServiceAsyncTest.kt @@ -49,6 +49,22 @@ internal class LedgerServiceAsyncTest { .description("description") .effectiveDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addFilter( + CustomerCreditLedgerCreateEntryParams.Body.Increment.Filter + .builder() + .field( + CustomerCreditLedgerCreateEntryParams.Body.Increment.Filter + .Field + .ITEM_ID + ) + .operator( + CustomerCreditLedgerCreateEntryParams.Body.Increment.Filter + .Operator + .INCLUDES + ) + .addValue("string") + .build() + ) .invoiceSettings( CustomerCreditLedgerCreateEntryParams.Body.Increment.InvoiceSettings .builder() @@ -96,6 +112,27 @@ internal class LedgerServiceAsyncTest { .description("description") .effectiveDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addFilter( + CustomerCreditLedgerCreateEntryByExternalIdParams.Body.Increment + .Filter + .builder() + .field( + CustomerCreditLedgerCreateEntryByExternalIdParams.Body + .Increment + .Filter + .Field + .ITEM_ID + ) + .operator( + CustomerCreditLedgerCreateEntryByExternalIdParams.Body + .Increment + .Filter + .Operator + .INCLUDES + ) + .addValue("string") + .build() + ) .invoiceSettings( CustomerCreditLedgerCreateEntryByExternalIdParams.Body.Increment .InvoiceSettings diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/BetaServiceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/BetaServiceTest.kt index 32479a087..10e306996 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/BetaServiceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/BetaServiceTest.kt @@ -80,6 +80,13 @@ internal class BetaServiceTest { .build() ) .expiresAtEndOfCadence(true) + .addFilter( + NewAllocationPrice.Filter.builder() + .field(NewAllocationPrice.Filter.Field.ITEM_ID) + .operator(NewAllocationPrice.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .planPhaseOrder(0L) @@ -197,6 +204,13 @@ internal class BetaServiceTest { .build() ) .expiresAtEndOfCadence(true) + .addFilter( + NewAllocationPrice.Filter.builder() + .field(NewAllocationPrice.Filter.Field.ITEM_ID) + .operator(NewAllocationPrice.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .planPhaseOrder(0L) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/PlanServiceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/PlanServiceTest.kt index 7be0ff5b4..288061184 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/PlanServiceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/PlanServiceTest.kt @@ -49,6 +49,13 @@ internal class PlanServiceTest { .build() ) .expiresAtEndOfCadence(true) + .addFilter( + NewAllocationPrice.Filter.builder() + .field(NewAllocationPrice.Filter.Field.ITEM_ID) + .operator(NewAllocationPrice.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .planPhaseOrder(0L) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/SubscriptionServiceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/SubscriptionServiceTest.kt index 4841f3498..f966f7aef 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/SubscriptionServiceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/SubscriptionServiceTest.kt @@ -95,6 +95,13 @@ internal class SubscriptionServiceTest { .build() ) .expiresAtEndOfCadence(true) + .addFilter( + NewAllocationPrice.Filter.builder() + .field(NewAllocationPrice.Filter.Field.ITEM_ID) + .operator(NewAllocationPrice.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .addDiscount( @@ -254,6 +261,13 @@ internal class SubscriptionServiceTest { .build() ) .expiresAtEndOfCadence(true) + .addFilter( + NewAllocationPrice.Filter.builder() + .field(NewAllocationPrice.Filter.Field.ITEM_ID) + .operator(NewAllocationPrice.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .addDiscount( @@ -508,6 +522,13 @@ internal class SubscriptionServiceTest { .build() ) .expiresAtEndOfCadence(true) + .addFilter( + NewAllocationPrice.Filter.builder() + .field(NewAllocationPrice.Filter.Field.ITEM_ID) + .operator(NewAllocationPrice.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .addAmountDiscount(0.0) @@ -727,6 +748,13 @@ internal class SubscriptionServiceTest { .build() ) .expiresAtEndOfCadence(true) + .addFilter( + NewAllocationPrice.Filter.builder() + .field(NewAllocationPrice.Filter.Field.ITEM_ID) + .operator(NewAllocationPrice.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .addDiscount( @@ -877,6 +905,13 @@ internal class SubscriptionServiceTest { .build() ) .expiresAtEndOfCadence(true) + .addFilter( + NewAllocationPrice.Filter.builder() + .field(NewAllocationPrice.Filter.Field.ITEM_ID) + .operator(NewAllocationPrice.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .addDiscount( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/beta/ExternalPlanIdServiceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/beta/ExternalPlanIdServiceTest.kt index 92952a194..f34269f51 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/beta/ExternalPlanIdServiceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/beta/ExternalPlanIdServiceTest.kt @@ -80,6 +80,13 @@ internal class ExternalPlanIdServiceTest { .build() ) .expiresAtEndOfCadence(true) + .addFilter( + NewAllocationPrice.Filter.builder() + .field(NewAllocationPrice.Filter.Field.ITEM_ID) + .operator(NewAllocationPrice.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .planPhaseOrder(0L) @@ -197,6 +204,13 @@ internal class ExternalPlanIdServiceTest { .build() ) .expiresAtEndOfCadence(true) + .addFilter( + NewAllocationPrice.Filter.builder() + .field(NewAllocationPrice.Filter.Field.ITEM_ID) + .operator(NewAllocationPrice.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) .build() ) .planPhaseOrder(0L) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/customers/credits/LedgerServiceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/customers/credits/LedgerServiceTest.kt index a72a537a1..8e93c1e14 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/customers/credits/LedgerServiceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/customers/credits/LedgerServiceTest.kt @@ -49,6 +49,22 @@ internal class LedgerServiceTest { .description("description") .effectiveDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addFilter( + CustomerCreditLedgerCreateEntryParams.Body.Increment.Filter + .builder() + .field( + CustomerCreditLedgerCreateEntryParams.Body.Increment.Filter + .Field + .ITEM_ID + ) + .operator( + CustomerCreditLedgerCreateEntryParams.Body.Increment.Filter + .Operator + .INCLUDES + ) + .addValue("string") + .build() + ) .invoiceSettings( CustomerCreditLedgerCreateEntryParams.Body.Increment.InvoiceSettings .builder() @@ -96,6 +112,27 @@ internal class LedgerServiceTest { .description("description") .effectiveDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addFilter( + CustomerCreditLedgerCreateEntryByExternalIdParams.Body.Increment + .Filter + .builder() + .field( + CustomerCreditLedgerCreateEntryByExternalIdParams.Body + .Increment + .Filter + .Field + .ITEM_ID + ) + .operator( + CustomerCreditLedgerCreateEntryByExternalIdParams.Body + .Increment + .Filter + .Operator + .INCLUDES + ) + .addValue("string") + .build() + ) .invoiceSettings( CustomerCreditLedgerCreateEntryByExternalIdParams.Body.Increment .InvoiceSettings From 9c2441e3488e02d6e3f130dbbc1e1a9c821ac15d Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 3 Nov 2025 22:33:40 +0000 Subject: [PATCH 42/68] feat(api): api update --- .stats.yml | 4 +- ...etaExternalPlanIdFetchPlanVersionParams.kt | 3 - ...ternalPlanIdSetDefaultPlanVersionParams.kt | 7 +- .../api/models/BetaFetchPlanVersionParams.kt | 3 - .../models/BetaSetDefaultPlanVersionParams.kt | 7 +- ...editLedgerCreateEntryByExternalIdParams.kt | 124 +++++++++--------- .../CustomerCreditLedgerCreateEntryParams.kt | 124 +++++++++--------- .../api/services/async/BetaServiceAsync.kt | 10 +- .../async/beta/ExternalPlanIdServiceAsync.kt | 10 +- .../api/services/blocking/BetaService.kt | 10 +- .../blocking/beta/ExternalPlanIdService.kt | 10 +- ...LedgerCreateEntryByExternalIdParamsTest.kt | 6 +- ...stomerCreditLedgerCreateEntryParamsTest.kt | 6 +- .../credits/LedgerServiceAsyncTest.kt | 4 +- .../customers/credits/LedgerServiceTest.kt | 4 +- 15 files changed, 140 insertions(+), 192 deletions(-) diff --git a/.stats.yml b/.stats.yml index 626045326..5f8609e8c 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 118 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-d1abf71a1a70a43bdcc4da7104dabcbd67aa7e2d3e6cf21e33f50904b6997bb2.yml -openapi_spec_hash: 28b0b31a997588cf3692458889321e1b +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-d74790c0b5540235e8387ccad7b806c11bcbb968fbdf99ea7dfbfc004bceb9dc.yml +openapi_spec_hash: eae212fa0114d8c3b4293c35f6ed7f7f config_hash: dd4343ce95871032ef6e0735a4ca038c diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BetaExternalPlanIdFetchPlanVersionParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BetaExternalPlanIdFetchPlanVersionParams.kt index fd405f5f1..e9a4d057d 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BetaExternalPlanIdFetchPlanVersionParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BetaExternalPlanIdFetchPlanVersionParams.kt @@ -9,9 +9,6 @@ import com.withorb.api.core.http.QueryParams import java.util.Objects /** - * This API endpoint is in beta and its interface may change. It is recommended for use only in test - * mode. - * * This endpoint is used to fetch a plan version. It returns the phases, prices, and adjustments * present on this version of the plan. */ diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BetaExternalPlanIdSetDefaultPlanVersionParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BetaExternalPlanIdSetDefaultPlanVersionParams.kt index 22035a2a6..5ffa0a908 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BetaExternalPlanIdSetDefaultPlanVersionParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BetaExternalPlanIdSetDefaultPlanVersionParams.kt @@ -18,12 +18,7 @@ import com.withorb.api.errors.OrbInvalidDataException import java.util.Collections import java.util.Objects -/** - * This API endpoint is in beta and its interface may change. It is recommended for use only in test - * mode. - * - * This endpoint allows setting the default version of a plan. - */ +/** This endpoint allows setting the default version of a plan. */ class BetaExternalPlanIdSetDefaultPlanVersionParams private constructor( private val externalPlanId: String?, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BetaFetchPlanVersionParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BetaFetchPlanVersionParams.kt index 1fbe3ca70..e5c5fd6a5 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BetaFetchPlanVersionParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BetaFetchPlanVersionParams.kt @@ -9,9 +9,6 @@ import com.withorb.api.core.http.QueryParams import java.util.Objects /** - * This API endpoint is in beta and its interface may change. It is recommended for use only in test - * mode. - * * This endpoint is used to fetch a plan version. It returns the phases, prices, and adjustments * present on this version of the plan. */ diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BetaSetDefaultPlanVersionParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BetaSetDefaultPlanVersionParams.kt index 414351332..c57ebe2d0 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BetaSetDefaultPlanVersionParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BetaSetDefaultPlanVersionParams.kt @@ -18,12 +18,7 @@ import com.withorb.api.errors.OrbInvalidDataException import java.util.Collections import java.util.Objects -/** - * This API endpoint is in beta and its interface may change. It is recommended for use only in test - * mode. - * - * This endpoint allows setting the default version of a plan. - */ +/** This endpoint allows setting the default version of a plan. */ class BetaSetDefaultPlanVersionParams private constructor( private val planId: String?, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdParams.kt index 653254463..5ce49bf71 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdParams.kt @@ -1727,11 +1727,11 @@ private constructor( @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val autoCollection: JsonField, - private val netTerms: JsonField, private val customDueDate: JsonField, private val invoiceDate: JsonField, private val itemId: JsonField, private val memo: JsonField, + private val netTerms: JsonField, private val requireSuccessfulPayment: JsonField, private val additionalProperties: MutableMap, ) { @@ -1741,9 +1741,6 @@ private constructor( @JsonProperty("auto_collection") @ExcludeMissing autoCollection: JsonField = JsonMissing.of(), - @JsonProperty("net_terms") - @ExcludeMissing - netTerms: JsonField = JsonMissing.of(), @JsonProperty("custom_due_date") @ExcludeMissing customDueDate: JsonField = JsonMissing.of(), @@ -1756,16 +1753,19 @@ private constructor( @JsonProperty("memo") @ExcludeMissing memo: JsonField = JsonMissing.of(), + @JsonProperty("net_terms") + @ExcludeMissing + netTerms: JsonField = JsonMissing.of(), @JsonProperty("require_successful_payment") @ExcludeMissing requireSuccessfulPayment: JsonField = JsonMissing.of(), ) : this( autoCollection, - netTerms, customDueDate, invoiceDate, itemId, memo, + netTerms, requireSuccessfulPayment, mutableMapOf(), ) @@ -1780,18 +1780,6 @@ private constructor( */ fun autoCollection(): Boolean = autoCollection.getRequired("auto_collection") - /** - * The net terms determines the due date of the invoice. Due date is calculated - * based on the invoice or issuance date, depending on the account's configured due - * date calculation method. A value of '0' here represents that the invoice is due - * on issue, whereas a value of '30' represents that the customer has 30 days to pay - * the invoice. Do not set this field if you want to set a custom due date. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun netTerms(): Long? = netTerms.getNullable("net_terms") - /** * An optional custom due date for the invoice. If not set, the due date will be * calculated based on the `net_terms` value. @@ -1828,6 +1816,18 @@ private constructor( */ fun memo(): String? = memo.getNullable("memo") + /** + * The net terms determines the due date of the invoice. Due date is calculated + * based on the invoice or issuance date, depending on the account's configured due + * date calculation method. A value of '0' here represents that the invoice is due + * on issue, whereas a value of '30' represents that the customer has 30 days to pay + * the invoice. Do not set this field if you want to set a custom due date. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun netTerms(): Long? = netTerms.getNullable("net_terms") + /** * If true, the new credit block will require that the corresponding invoice is paid * before it can be drawn down from. @@ -1848,16 +1848,6 @@ private constructor( @ExcludeMissing fun _autoCollection(): JsonField = autoCollection - /** - * Returns the raw JSON value of [netTerms]. - * - * Unlike [netTerms], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("net_terms") - @ExcludeMissing - fun _netTerms(): JsonField = netTerms - /** * Returns the raw JSON value of [customDueDate]. * @@ -1894,6 +1884,16 @@ private constructor( */ @JsonProperty("memo") @ExcludeMissing fun _memo(): JsonField = memo + /** + * Returns the raw JSON value of [netTerms]. + * + * Unlike [netTerms], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("net_terms") + @ExcludeMissing + fun _netTerms(): JsonField = netTerms + /** * Returns the raw JSON value of [requireSuccessfulPayment]. * @@ -1924,7 +1924,6 @@ private constructor( * The following fields are required: * ```kotlin * .autoCollection() - * .netTerms() * ``` */ fun builder() = Builder() @@ -1934,21 +1933,21 @@ private constructor( class Builder internal constructor() { private var autoCollection: JsonField? = null - private var netTerms: JsonField? = null private var customDueDate: JsonField = JsonMissing.of() private var invoiceDate: JsonField = JsonMissing.of() private var itemId: JsonField = JsonMissing.of() private var memo: JsonField = JsonMissing.of() + private var netTerms: JsonField = JsonMissing.of() private var requireSuccessfulPayment: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() internal fun from(invoiceSettings: InvoiceSettings) = apply { autoCollection = invoiceSettings.autoCollection - netTerms = invoiceSettings.netTerms customDueDate = invoiceSettings.customDueDate invoiceDate = invoiceSettings.invoiceDate itemId = invoiceSettings.itemId memo = invoiceSettings.memo + netTerms = invoiceSettings.netTerms requireSuccessfulPayment = invoiceSettings.requireSuccessfulPayment additionalProperties = invoiceSettings.additionalProperties.toMutableMap() } @@ -1971,32 +1970,6 @@ private constructor( this.autoCollection = autoCollection } - /** - * The net terms determines the due date of the invoice. Due date is calculated - * based on the invoice or issuance date, depending on the account's configured - * due date calculation method. A value of '0' here represents that the invoice - * is due on issue, whereas a value of '30' represents that the customer has 30 - * days to pay the invoice. Do not set this field if you want to set a custom - * due date. - */ - fun netTerms(netTerms: Long?) = netTerms(JsonField.ofNullable(netTerms)) - - /** - * Alias for [Builder.netTerms]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun netTerms(netTerms: Long) = netTerms(netTerms as Long?) - - /** - * Sets [Builder.netTerms] to an arbitrary JSON value. - * - * You should usually call [Builder.netTerms] with a well-typed [Long] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun netTerms(netTerms: JsonField) = apply { this.netTerms = netTerms } - /** * An optional custom due date for the invoice. If not set, the due date will be * calculated based on the `net_terms` value. @@ -2077,6 +2050,32 @@ private constructor( */ fun memo(memo: JsonField) = apply { this.memo = memo } + /** + * The net terms determines the due date of the invoice. Due date is calculated + * based on the invoice or issuance date, depending on the account's configured + * due date calculation method. A value of '0' here represents that the invoice + * is due on issue, whereas a value of '30' represents that the customer has 30 + * days to pay the invoice. Do not set this field if you want to set a custom + * due date. + */ + fun netTerms(netTerms: Long?) = netTerms(JsonField.ofNullable(netTerms)) + + /** + * Alias for [Builder.netTerms]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun netTerms(netTerms: Long) = netTerms(netTerms as Long?) + + /** + * Sets [Builder.netTerms] to an arbitrary JSON value. + * + * You should usually call [Builder.netTerms] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun netTerms(netTerms: JsonField) = apply { this.netTerms = netTerms } + /** * If true, the new credit block will require that the corresponding invoice is * paid before it can be drawn down from. @@ -2126,7 +2125,6 @@ private constructor( * The following fields are required: * ```kotlin * .autoCollection() - * .netTerms() * ``` * * @throws IllegalStateException if any required field is unset. @@ -2134,11 +2132,11 @@ private constructor( fun build(): InvoiceSettings = InvoiceSettings( checkRequired("autoCollection", autoCollection), - checkRequired("netTerms", netTerms), customDueDate, invoiceDate, itemId, memo, + netTerms, requireSuccessfulPayment, additionalProperties.toMutableMap(), ) @@ -2152,11 +2150,11 @@ private constructor( } autoCollection() - netTerms() customDueDate()?.validate() invoiceDate()?.validate() itemId() memo() + netTerms() requireSuccessfulPayment() validated = true } @@ -2177,11 +2175,11 @@ private constructor( */ internal fun validity(): Int = (if (autoCollection.asKnown() == null) 0 else 1) + - (if (netTerms.asKnown() == null) 0 else 1) + (customDueDate.asKnown()?.validity() ?: 0) + (invoiceDate.asKnown()?.validity() ?: 0) + (if (itemId.asKnown() == null) 0 else 1) + (if (memo.asKnown() == null) 0 else 1) + + (if (netTerms.asKnown() == null) 0 else 1) + (if (requireSuccessfulPayment.asKnown() == null) 0 else 1) /** @@ -2548,11 +2546,11 @@ private constructor( return other is InvoiceSettings && autoCollection == other.autoCollection && - netTerms == other.netTerms && customDueDate == other.customDueDate && invoiceDate == other.invoiceDate && itemId == other.itemId && memo == other.memo && + netTerms == other.netTerms && requireSuccessfulPayment == other.requireSuccessfulPayment && additionalProperties == other.additionalProperties } @@ -2560,11 +2558,11 @@ private constructor( private val hashCode: Int by lazy { Objects.hash( autoCollection, - netTerms, customDueDate, invoiceDate, itemId, memo, + netTerms, requireSuccessfulPayment, additionalProperties, ) @@ -2573,7 +2571,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "InvoiceSettings{autoCollection=$autoCollection, netTerms=$netTerms, customDueDate=$customDueDate, invoiceDate=$invoiceDate, itemId=$itemId, memo=$memo, requireSuccessfulPayment=$requireSuccessfulPayment, additionalProperties=$additionalProperties}" + "InvoiceSettings{autoCollection=$autoCollection, customDueDate=$customDueDate, invoiceDate=$invoiceDate, itemId=$itemId, memo=$memo, netTerms=$netTerms, requireSuccessfulPayment=$requireSuccessfulPayment, additionalProperties=$additionalProperties}" } /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryParams.kt index e86958399..448633936 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryParams.kt @@ -1722,11 +1722,11 @@ private constructor( @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val autoCollection: JsonField, - private val netTerms: JsonField, private val customDueDate: JsonField, private val invoiceDate: JsonField, private val itemId: JsonField, private val memo: JsonField, + private val netTerms: JsonField, private val requireSuccessfulPayment: JsonField, private val additionalProperties: MutableMap, ) { @@ -1736,9 +1736,6 @@ private constructor( @JsonProperty("auto_collection") @ExcludeMissing autoCollection: JsonField = JsonMissing.of(), - @JsonProperty("net_terms") - @ExcludeMissing - netTerms: JsonField = JsonMissing.of(), @JsonProperty("custom_due_date") @ExcludeMissing customDueDate: JsonField = JsonMissing.of(), @@ -1751,16 +1748,19 @@ private constructor( @JsonProperty("memo") @ExcludeMissing memo: JsonField = JsonMissing.of(), + @JsonProperty("net_terms") + @ExcludeMissing + netTerms: JsonField = JsonMissing.of(), @JsonProperty("require_successful_payment") @ExcludeMissing requireSuccessfulPayment: JsonField = JsonMissing.of(), ) : this( autoCollection, - netTerms, customDueDate, invoiceDate, itemId, memo, + netTerms, requireSuccessfulPayment, mutableMapOf(), ) @@ -1775,18 +1775,6 @@ private constructor( */ fun autoCollection(): Boolean = autoCollection.getRequired("auto_collection") - /** - * The net terms determines the due date of the invoice. Due date is calculated - * based on the invoice or issuance date, depending on the account's configured due - * date calculation method. A value of '0' here represents that the invoice is due - * on issue, whereas a value of '30' represents that the customer has 30 days to pay - * the invoice. Do not set this field if you want to set a custom due date. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun netTerms(): Long? = netTerms.getNullable("net_terms") - /** * An optional custom due date for the invoice. If not set, the due date will be * calculated based on the `net_terms` value. @@ -1823,6 +1811,18 @@ private constructor( */ fun memo(): String? = memo.getNullable("memo") + /** + * The net terms determines the due date of the invoice. Due date is calculated + * based on the invoice or issuance date, depending on the account's configured due + * date calculation method. A value of '0' here represents that the invoice is due + * on issue, whereas a value of '30' represents that the customer has 30 days to pay + * the invoice. Do not set this field if you want to set a custom due date. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun netTerms(): Long? = netTerms.getNullable("net_terms") + /** * If true, the new credit block will require that the corresponding invoice is paid * before it can be drawn down from. @@ -1843,16 +1843,6 @@ private constructor( @ExcludeMissing fun _autoCollection(): JsonField = autoCollection - /** - * Returns the raw JSON value of [netTerms]. - * - * Unlike [netTerms], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("net_terms") - @ExcludeMissing - fun _netTerms(): JsonField = netTerms - /** * Returns the raw JSON value of [customDueDate]. * @@ -1889,6 +1879,16 @@ private constructor( */ @JsonProperty("memo") @ExcludeMissing fun _memo(): JsonField = memo + /** + * Returns the raw JSON value of [netTerms]. + * + * Unlike [netTerms], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("net_terms") + @ExcludeMissing + fun _netTerms(): JsonField = netTerms + /** * Returns the raw JSON value of [requireSuccessfulPayment]. * @@ -1919,7 +1919,6 @@ private constructor( * The following fields are required: * ```kotlin * .autoCollection() - * .netTerms() * ``` */ fun builder() = Builder() @@ -1929,21 +1928,21 @@ private constructor( class Builder internal constructor() { private var autoCollection: JsonField? = null - private var netTerms: JsonField? = null private var customDueDate: JsonField = JsonMissing.of() private var invoiceDate: JsonField = JsonMissing.of() private var itemId: JsonField = JsonMissing.of() private var memo: JsonField = JsonMissing.of() + private var netTerms: JsonField = JsonMissing.of() private var requireSuccessfulPayment: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() internal fun from(invoiceSettings: InvoiceSettings) = apply { autoCollection = invoiceSettings.autoCollection - netTerms = invoiceSettings.netTerms customDueDate = invoiceSettings.customDueDate invoiceDate = invoiceSettings.invoiceDate itemId = invoiceSettings.itemId memo = invoiceSettings.memo + netTerms = invoiceSettings.netTerms requireSuccessfulPayment = invoiceSettings.requireSuccessfulPayment additionalProperties = invoiceSettings.additionalProperties.toMutableMap() } @@ -1966,32 +1965,6 @@ private constructor( this.autoCollection = autoCollection } - /** - * The net terms determines the due date of the invoice. Due date is calculated - * based on the invoice or issuance date, depending on the account's configured - * due date calculation method. A value of '0' here represents that the invoice - * is due on issue, whereas a value of '30' represents that the customer has 30 - * days to pay the invoice. Do not set this field if you want to set a custom - * due date. - */ - fun netTerms(netTerms: Long?) = netTerms(JsonField.ofNullable(netTerms)) - - /** - * Alias for [Builder.netTerms]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun netTerms(netTerms: Long) = netTerms(netTerms as Long?) - - /** - * Sets [Builder.netTerms] to an arbitrary JSON value. - * - * You should usually call [Builder.netTerms] with a well-typed [Long] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun netTerms(netTerms: JsonField) = apply { this.netTerms = netTerms } - /** * An optional custom due date for the invoice. If not set, the due date will be * calculated based on the `net_terms` value. @@ -2072,6 +2045,32 @@ private constructor( */ fun memo(memo: JsonField) = apply { this.memo = memo } + /** + * The net terms determines the due date of the invoice. Due date is calculated + * based on the invoice or issuance date, depending on the account's configured + * due date calculation method. A value of '0' here represents that the invoice + * is due on issue, whereas a value of '30' represents that the customer has 30 + * days to pay the invoice. Do not set this field if you want to set a custom + * due date. + */ + fun netTerms(netTerms: Long?) = netTerms(JsonField.ofNullable(netTerms)) + + /** + * Alias for [Builder.netTerms]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun netTerms(netTerms: Long) = netTerms(netTerms as Long?) + + /** + * Sets [Builder.netTerms] to an arbitrary JSON value. + * + * You should usually call [Builder.netTerms] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun netTerms(netTerms: JsonField) = apply { this.netTerms = netTerms } + /** * If true, the new credit block will require that the corresponding invoice is * paid before it can be drawn down from. @@ -2121,7 +2120,6 @@ private constructor( * The following fields are required: * ```kotlin * .autoCollection() - * .netTerms() * ``` * * @throws IllegalStateException if any required field is unset. @@ -2129,11 +2127,11 @@ private constructor( fun build(): InvoiceSettings = InvoiceSettings( checkRequired("autoCollection", autoCollection), - checkRequired("netTerms", netTerms), customDueDate, invoiceDate, itemId, memo, + netTerms, requireSuccessfulPayment, additionalProperties.toMutableMap(), ) @@ -2147,11 +2145,11 @@ private constructor( } autoCollection() - netTerms() customDueDate()?.validate() invoiceDate()?.validate() itemId() memo() + netTerms() requireSuccessfulPayment() validated = true } @@ -2172,11 +2170,11 @@ private constructor( */ internal fun validity(): Int = (if (autoCollection.asKnown() == null) 0 else 1) + - (if (netTerms.asKnown() == null) 0 else 1) + (customDueDate.asKnown()?.validity() ?: 0) + (invoiceDate.asKnown()?.validity() ?: 0) + (if (itemId.asKnown() == null) 0 else 1) + (if (memo.asKnown() == null) 0 else 1) + + (if (netTerms.asKnown() == null) 0 else 1) + (if (requireSuccessfulPayment.asKnown() == null) 0 else 1) /** @@ -2543,11 +2541,11 @@ private constructor( return other is InvoiceSettings && autoCollection == other.autoCollection && - netTerms == other.netTerms && customDueDate == other.customDueDate && invoiceDate == other.invoiceDate && itemId == other.itemId && memo == other.memo && + netTerms == other.netTerms && requireSuccessfulPayment == other.requireSuccessfulPayment && additionalProperties == other.additionalProperties } @@ -2555,11 +2553,11 @@ private constructor( private val hashCode: Int by lazy { Objects.hash( autoCollection, - netTerms, customDueDate, invoiceDate, itemId, memo, + netTerms, requireSuccessfulPayment, additionalProperties, ) @@ -2568,7 +2566,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "InvoiceSettings{autoCollection=$autoCollection, netTerms=$netTerms, customDueDate=$customDueDate, invoiceDate=$invoiceDate, itemId=$itemId, memo=$memo, requireSuccessfulPayment=$requireSuccessfulPayment, additionalProperties=$additionalProperties}" + "InvoiceSettings{autoCollection=$autoCollection, customDueDate=$customDueDate, invoiceDate=$invoiceDate, itemId=$itemId, memo=$memo, netTerms=$netTerms, requireSuccessfulPayment=$requireSuccessfulPayment, additionalProperties=$additionalProperties}" } /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/BetaServiceAsync.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/BetaServiceAsync.kt index 81216af06..e7bbc4072 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/BetaServiceAsync.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/BetaServiceAsync.kt @@ -43,9 +43,6 @@ interface BetaServiceAsync { ): PlanVersion /** - * This API endpoint is in beta and its interface may change. It is recommended for use only in - * test mode. - * * This endpoint is used to fetch a plan version. It returns the phases, prices, and adjustments * present on this version of the plan. */ @@ -61,12 +58,7 @@ interface BetaServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): PlanVersion - /** - * This API endpoint is in beta and its interface may change. It is recommended for use only in - * test mode. - * - * This endpoint allows setting the default version of a plan. - */ + /** This endpoint allows setting the default version of a plan. */ suspend fun setDefaultPlanVersion( planId: String, params: BetaSetDefaultPlanVersionParams, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/beta/ExternalPlanIdServiceAsync.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/beta/ExternalPlanIdServiceAsync.kt index cdac8d707..c8a502ad8 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/beta/ExternalPlanIdServiceAsync.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/beta/ExternalPlanIdServiceAsync.kt @@ -41,9 +41,6 @@ interface ExternalPlanIdServiceAsync { ): PlanVersion /** - * This API endpoint is in beta and its interface may change. It is recommended for use only in - * test mode. - * * This endpoint is used to fetch a plan version. It returns the phases, prices, and adjustments * present on this version of the plan. */ @@ -59,12 +56,7 @@ interface ExternalPlanIdServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): PlanVersion - /** - * This API endpoint is in beta and its interface may change. It is recommended for use only in - * test mode. - * - * This endpoint allows setting the default version of a plan. - */ + /** This endpoint allows setting the default version of a plan. */ suspend fun setDefaultPlanVersion( externalPlanId: String, params: BetaExternalPlanIdSetDefaultPlanVersionParams, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/BetaService.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/BetaService.kt index 24d7a0440..81f7b22c4 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/BetaService.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/BetaService.kt @@ -43,9 +43,6 @@ interface BetaService { ): PlanVersion /** - * This API endpoint is in beta and its interface may change. It is recommended for use only in - * test mode. - * * This endpoint is used to fetch a plan version. It returns the phases, prices, and adjustments * present on this version of the plan. */ @@ -61,12 +58,7 @@ interface BetaService { requestOptions: RequestOptions = RequestOptions.none(), ): PlanVersion - /** - * This API endpoint is in beta and its interface may change. It is recommended for use only in - * test mode. - * - * This endpoint allows setting the default version of a plan. - */ + /** This endpoint allows setting the default version of a plan. */ fun setDefaultPlanVersion( planId: String, params: BetaSetDefaultPlanVersionParams, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/beta/ExternalPlanIdService.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/beta/ExternalPlanIdService.kt index a2eb8639f..85ce049dc 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/beta/ExternalPlanIdService.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/beta/ExternalPlanIdService.kt @@ -41,9 +41,6 @@ interface ExternalPlanIdService { ): PlanVersion /** - * This API endpoint is in beta and its interface may change. It is recommended for use only in - * test mode. - * * This endpoint is used to fetch a plan version. It returns the phases, prices, and adjustments * present on this version of the plan. */ @@ -59,12 +56,7 @@ interface ExternalPlanIdService { requestOptions: RequestOptions = RequestOptions.none(), ): PlanVersion - /** - * This API endpoint is in beta and its interface may change. It is recommended for use only in - * test mode. - * - * This endpoint allows setting the default version of a plan. - */ + /** This endpoint allows setting the default version of a plan. */ fun setDefaultPlanVersion( externalPlanId: String, params: BetaExternalPlanIdSetDefaultPlanVersionParams, diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdParamsTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdParamsTest.kt index b3e0fc5c6..8d29cb30a 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdParamsTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdParamsTest.kt @@ -44,11 +44,11 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdParamsTest { .InvoiceSettings .builder() .autoCollection(true) - .netTerms(0L) .customDueDate(LocalDate.parse("2019-12-27")) .invoiceDate(LocalDate.parse("2019-12-27")) .itemId("item_id") .memo("memo") + .netTerms(0L) .requireSuccessfulPayment(true) .build() ) @@ -112,11 +112,11 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdParamsTest { .InvoiceSettings .builder() .autoCollection(true) - .netTerms(0L) .customDueDate(LocalDate.parse("2019-12-27")) .invoiceDate(LocalDate.parse("2019-12-27")) .itemId("item_id") .memo("memo") + .netTerms(0L) .requireSuccessfulPayment(true) .build() ) @@ -166,11 +166,11 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdParamsTest { .InvoiceSettings .builder() .autoCollection(true) - .netTerms(0L) .customDueDate(LocalDate.parse("2019-12-27")) .invoiceDate(LocalDate.parse("2019-12-27")) .itemId("item_id") .memo("memo") + .netTerms(0L) .requireSuccessfulPayment(true) .build() ) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryParamsTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryParamsTest.kt index 0c2fa0a85..0cf4b256e 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryParamsTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryParamsTest.kt @@ -38,11 +38,11 @@ internal class CustomerCreditLedgerCreateEntryParamsTest { CustomerCreditLedgerCreateEntryParams.Body.Increment.InvoiceSettings .builder() .autoCollection(true) - .netTerms(0L) .customDueDate(LocalDate.parse("2019-12-27")) .invoiceDate(LocalDate.parse("2019-12-27")) .itemId("item_id") .memo("memo") + .netTerms(0L) .requireSuccessfulPayment(true) .build() ) @@ -101,11 +101,11 @@ internal class CustomerCreditLedgerCreateEntryParamsTest { CustomerCreditLedgerCreateEntryParams.Body.Increment.InvoiceSettings .builder() .autoCollection(true) - .netTerms(0L) .customDueDate(LocalDate.parse("2019-12-27")) .invoiceDate(LocalDate.parse("2019-12-27")) .itemId("item_id") .memo("memo") + .netTerms(0L) .requireSuccessfulPayment(true) .build() ) @@ -149,11 +149,11 @@ internal class CustomerCreditLedgerCreateEntryParamsTest { CustomerCreditLedgerCreateEntryParams.Body.Increment.InvoiceSettings .builder() .autoCollection(true) - .netTerms(0L) .customDueDate(LocalDate.parse("2019-12-27")) .invoiceDate(LocalDate.parse("2019-12-27")) .itemId("item_id") .memo("memo") + .netTerms(0L) .requireSuccessfulPayment(true) .build() ) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/customers/credits/LedgerServiceAsyncTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/customers/credits/LedgerServiceAsyncTest.kt index e52cff0ca..3b240a991 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/customers/credits/LedgerServiceAsyncTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/customers/credits/LedgerServiceAsyncTest.kt @@ -69,11 +69,11 @@ internal class LedgerServiceAsyncTest { CustomerCreditLedgerCreateEntryParams.Body.Increment.InvoiceSettings .builder() .autoCollection(true) - .netTerms(0L) .customDueDate(LocalDate.parse("2019-12-27")) .invoiceDate(LocalDate.parse("2019-12-27")) .itemId("item_id") .memo("memo") + .netTerms(0L) .requireSuccessfulPayment(true) .build() ) @@ -138,11 +138,11 @@ internal class LedgerServiceAsyncTest { .InvoiceSettings .builder() .autoCollection(true) - .netTerms(0L) .customDueDate(LocalDate.parse("2019-12-27")) .invoiceDate(LocalDate.parse("2019-12-27")) .itemId("item_id") .memo("memo") + .netTerms(0L) .requireSuccessfulPayment(true) .build() ) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/customers/credits/LedgerServiceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/customers/credits/LedgerServiceTest.kt index 8e93c1e14..3db03f154 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/customers/credits/LedgerServiceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/customers/credits/LedgerServiceTest.kt @@ -69,11 +69,11 @@ internal class LedgerServiceTest { CustomerCreditLedgerCreateEntryParams.Body.Increment.InvoiceSettings .builder() .autoCollection(true) - .netTerms(0L) .customDueDate(LocalDate.parse("2019-12-27")) .invoiceDate(LocalDate.parse("2019-12-27")) .itemId("item_id") .memo("memo") + .netTerms(0L) .requireSuccessfulPayment(true) .build() ) @@ -138,11 +138,11 @@ internal class LedgerServiceTest { .InvoiceSettings .builder() .autoCollection(true) - .netTerms(0L) .customDueDate(LocalDate.parse("2019-12-27")) .invoiceDate(LocalDate.parse("2019-12-27")) .itemId("item_id") .memo("memo") + .netTerms(0L) .requireSuccessfulPayment(true) .build() ) From fd821005e293869c0199d3d5261f3a806df74e41 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 4 Nov 2025 03:33:28 +0000 Subject: [PATCH 43/68] feat(api): api update --- .stats.yml | 4 +- .../CustomerUpdateByExternalIdParams.kt | 106 +----------------- .../api/models/CustomerUpdateParams.kt | 106 +----------------- .../CustomerUpdateByExternalIdParamsTest.kt | 3 - .../api/models/CustomerUpdateParamsTest.kt | 3 - .../async/CustomerServiceAsyncTest.kt | 2 - .../services/blocking/CustomerServiceTest.kt | 2 - 7 files changed, 6 insertions(+), 220 deletions(-) diff --git a/.stats.yml b/.stats.yml index 5f8609e8c..467b7cc35 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 118 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-d74790c0b5540235e8387ccad7b806c11bcbb968fbdf99ea7dfbfc004bceb9dc.yml -openapi_spec_hash: eae212fa0114d8c3b4293c35f6ed7f7f +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-5b9152241ebdd0d2f3fd536784f33721d24a5c4a59e75cab366a3dcb36552d3d.yml +openapi_spec_hash: b40061d10bbe1ebab8998bddd1827cf8 config_hash: dd4343ce95871032ef6e0735a4ca038c diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerUpdateByExternalIdParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerUpdateByExternalIdParams.kt index 1e02cd18b..ea70c1c7a 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerUpdateByExternalIdParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerUpdateByExternalIdParams.kt @@ -84,15 +84,6 @@ private constructor( */ fun autoIssuance(): Boolean? = body.autoIssuance() - /** - * Whether automatic tax calculation is enabled for this customer. When null, inherits from - * account-level setting. When true or false, overrides the account setting. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - fun automaticTaxEnabled(): Boolean? = body.automaticTaxEnabled() - /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server * responded with an unexpected value). @@ -379,14 +370,6 @@ private constructor( */ fun _autoIssuance(): JsonField = body._autoIssuance() - /** - * Returns the raw JSON value of [automaticTaxEnabled]. - * - * Unlike [automaticTaxEnabled], this method doesn't throw if the JSON field has an unexpected - * type. - */ - fun _automaticTaxEnabled(): JsonField = body._automaticTaxEnabled() - /** * Returns the raw JSON value of [billingAddress]. * @@ -539,7 +522,7 @@ private constructor( * - [additionalEmails] * - [autoCollection] * - [autoIssuance] - * - [automaticTaxEnabled] + * - [billingAddress] * - etc. */ fun body(body: Body) = apply { this.body = body.toBuilder() } @@ -639,33 +622,6 @@ private constructor( body.autoIssuance(autoIssuance) } - /** - * Whether automatic tax calculation is enabled for this customer. When null, inherits from - * account-level setting. When true or false, overrides the account setting. - */ - fun automaticTaxEnabled(automaticTaxEnabled: Boolean?) = apply { - body.automaticTaxEnabled(automaticTaxEnabled) - } - - /** - * Alias for [Builder.automaticTaxEnabled]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun automaticTaxEnabled(automaticTaxEnabled: Boolean) = - automaticTaxEnabled(automaticTaxEnabled as Boolean?) - - /** - * Sets [Builder.automaticTaxEnabled] to an arbitrary JSON value. - * - * You should usually call [Builder.automaticTaxEnabled] with a well-typed [Boolean] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun automaticTaxEnabled(automaticTaxEnabled: JsonField) = apply { - body.automaticTaxEnabled(automaticTaxEnabled) - } - fun billingAddress(billingAddress: AddressInput?) = apply { body.billingAddress(billingAddress) } @@ -1267,7 +1223,6 @@ private constructor( private val additionalEmails: JsonField>, private val autoCollection: JsonField, private val autoIssuance: JsonField, - private val automaticTaxEnabled: JsonField, private val billingAddress: JsonField, private val currency: JsonField, private val email: JsonField, @@ -1300,9 +1255,6 @@ private constructor( @JsonProperty("auto_issuance") @ExcludeMissing autoIssuance: JsonField = JsonMissing.of(), - @JsonProperty("automatic_tax_enabled") - @ExcludeMissing - automaticTaxEnabled: JsonField = JsonMissing.of(), @JsonProperty("billing_address") @ExcludeMissing billingAddress: JsonField = JsonMissing.of(), @@ -1346,7 +1298,6 @@ private constructor( additionalEmails, autoCollection, autoIssuance, - automaticTaxEnabled, billingAddress, currency, email, @@ -1402,16 +1353,6 @@ private constructor( */ fun autoIssuance(): Boolean? = autoIssuance.getNullable("auto_issuance") - /** - * Whether automatic tax calculation is enabled for this customer. When null, inherits from - * account-level setting. When true or false, overrides the account setting. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun automaticTaxEnabled(): Boolean? = - automaticTaxEnabled.getNullable("automatic_tax_enabled") - /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -1710,16 +1651,6 @@ private constructor( @ExcludeMissing fun _autoIssuance(): JsonField = autoIssuance - /** - * Returns the raw JSON value of [automaticTaxEnabled]. - * - * Unlike [automaticTaxEnabled], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("automatic_tax_enabled") - @ExcludeMissing - fun _automaticTaxEnabled(): JsonField = automaticTaxEnabled - /** * Returns the raw JSON value of [billingAddress]. * @@ -1870,7 +1801,6 @@ private constructor( private var additionalEmails: JsonField>? = null private var autoCollection: JsonField = JsonMissing.of() private var autoIssuance: JsonField = JsonMissing.of() - private var automaticTaxEnabled: JsonField = JsonMissing.of() private var billingAddress: JsonField = JsonMissing.of() private var currency: JsonField = JsonMissing.of() private var email: JsonField = JsonMissing.of() @@ -1893,7 +1823,6 @@ private constructor( additionalEmails = body.additionalEmails.map { it.toMutableList() } autoCollection = body.autoCollection autoIssuance = body.autoIssuance - automaticTaxEnabled = body.automaticTaxEnabled billingAddress = body.billingAddress currency = body.currency email = body.email @@ -2010,32 +1939,6 @@ private constructor( this.autoIssuance = autoIssuance } - /** - * Whether automatic tax calculation is enabled for this customer. When null, inherits - * from account-level setting. When true or false, overrides the account setting. - */ - fun automaticTaxEnabled(automaticTaxEnabled: Boolean?) = - automaticTaxEnabled(JsonField.ofNullable(automaticTaxEnabled)) - - /** - * Alias for [Builder.automaticTaxEnabled]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun automaticTaxEnabled(automaticTaxEnabled: Boolean) = - automaticTaxEnabled(automaticTaxEnabled as Boolean?) - - /** - * Sets [Builder.automaticTaxEnabled] to an arbitrary JSON value. - * - * You should usually call [Builder.automaticTaxEnabled] with a well-typed [Boolean] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun automaticTaxEnabled(automaticTaxEnabled: JsonField) = apply { - this.automaticTaxEnabled = automaticTaxEnabled - } - fun billingAddress(billingAddress: AddressInput?) = billingAddress(JsonField.ofNullable(billingAddress)) @@ -2522,7 +2425,6 @@ private constructor( (additionalEmails ?: JsonMissing.of()).map { it.toImmutable() }, autoCollection, autoIssuance, - automaticTaxEnabled, billingAddress, currency, email, @@ -2552,7 +2454,6 @@ private constructor( additionalEmails() autoCollection() autoIssuance() - automaticTaxEnabled() billingAddress()?.validate() currency() email() @@ -2589,7 +2490,6 @@ private constructor( (additionalEmails.asKnown()?.size ?: 0) + (if (autoCollection.asKnown() == null) 0 else 1) + (if (autoIssuance.asKnown() == null) 0 else 1) + - (if (automaticTaxEnabled.asKnown() == null) 0 else 1) + (billingAddress.asKnown()?.validity() ?: 0) + (if (currency.asKnown() == null) 0 else 1) + (if (email.asKnown() == null) 0 else 1) + @@ -2615,7 +2515,6 @@ private constructor( additionalEmails == other.additionalEmails && autoCollection == other.autoCollection && autoIssuance == other.autoIssuance && - automaticTaxEnabled == other.automaticTaxEnabled && billingAddress == other.billingAddress && currency == other.currency && email == other.email && @@ -2639,7 +2538,6 @@ private constructor( additionalEmails, autoCollection, autoIssuance, - automaticTaxEnabled, billingAddress, currency, email, @@ -2661,7 +2559,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Body{accountingSyncConfiguration=$accountingSyncConfiguration, additionalEmails=$additionalEmails, autoCollection=$autoCollection, autoIssuance=$autoIssuance, automaticTaxEnabled=$automaticTaxEnabled, billingAddress=$billingAddress, currency=$currency, email=$email, emailDelivery=$emailDelivery, externalCustomerId=$externalCustomerId, hierarchy=$hierarchy, metadata=$metadata, name=$name, paymentProvider=$paymentProvider, paymentProviderId=$paymentProviderId, reportingConfiguration=$reportingConfiguration, shippingAddress=$shippingAddress, taxConfiguration=$taxConfiguration, taxId=$taxId, additionalProperties=$additionalProperties}" + "Body{accountingSyncConfiguration=$accountingSyncConfiguration, additionalEmails=$additionalEmails, autoCollection=$autoCollection, autoIssuance=$autoIssuance, billingAddress=$billingAddress, currency=$currency, email=$email, emailDelivery=$emailDelivery, externalCustomerId=$externalCustomerId, hierarchy=$hierarchy, metadata=$metadata, name=$name, paymentProvider=$paymentProvider, paymentProviderId=$paymentProviderId, reportingConfiguration=$reportingConfiguration, shippingAddress=$shippingAddress, taxConfiguration=$taxConfiguration, taxId=$taxId, additionalProperties=$additionalProperties}" } /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerUpdateParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerUpdateParams.kt index 9f69eb47c..049e94cf3 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerUpdateParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerUpdateParams.kt @@ -85,15 +85,6 @@ private constructor( */ fun autoIssuance(): Boolean? = body.autoIssuance() - /** - * Whether automatic tax calculation is enabled for this customer. When null, inherits from - * account-level setting. When true or false, overrides the account setting. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - fun automaticTaxEnabled(): Boolean? = body.automaticTaxEnabled() - /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server * responded with an unexpected value). @@ -380,14 +371,6 @@ private constructor( */ fun _autoIssuance(): JsonField = body._autoIssuance() - /** - * Returns the raw JSON value of [automaticTaxEnabled]. - * - * Unlike [automaticTaxEnabled], this method doesn't throw if the JSON field has an unexpected - * type. - */ - fun _automaticTaxEnabled(): JsonField = body._automaticTaxEnabled() - /** * Returns the raw JSON value of [billingAddress]. * @@ -535,7 +518,7 @@ private constructor( * - [additionalEmails] * - [autoCollection] * - [autoIssuance] - * - [automaticTaxEnabled] + * - [billingAddress] * - etc. */ fun body(body: Body) = apply { this.body = body.toBuilder() } @@ -635,33 +618,6 @@ private constructor( body.autoIssuance(autoIssuance) } - /** - * Whether automatic tax calculation is enabled for this customer. When null, inherits from - * account-level setting. When true or false, overrides the account setting. - */ - fun automaticTaxEnabled(automaticTaxEnabled: Boolean?) = apply { - body.automaticTaxEnabled(automaticTaxEnabled) - } - - /** - * Alias for [Builder.automaticTaxEnabled]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun automaticTaxEnabled(automaticTaxEnabled: Boolean) = - automaticTaxEnabled(automaticTaxEnabled as Boolean?) - - /** - * Sets [Builder.automaticTaxEnabled] to an arbitrary JSON value. - * - * You should usually call [Builder.automaticTaxEnabled] with a well-typed [Boolean] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun automaticTaxEnabled(automaticTaxEnabled: JsonField) = apply { - body.automaticTaxEnabled(automaticTaxEnabled) - } - fun billingAddress(billingAddress: AddressInput?) = apply { body.billingAddress(billingAddress) } @@ -1263,7 +1219,6 @@ private constructor( private val additionalEmails: JsonField>, private val autoCollection: JsonField, private val autoIssuance: JsonField, - private val automaticTaxEnabled: JsonField, private val billingAddress: JsonField, private val currency: JsonField, private val email: JsonField, @@ -1296,9 +1251,6 @@ private constructor( @JsonProperty("auto_issuance") @ExcludeMissing autoIssuance: JsonField = JsonMissing.of(), - @JsonProperty("automatic_tax_enabled") - @ExcludeMissing - automaticTaxEnabled: JsonField = JsonMissing.of(), @JsonProperty("billing_address") @ExcludeMissing billingAddress: JsonField = JsonMissing.of(), @@ -1342,7 +1294,6 @@ private constructor( additionalEmails, autoCollection, autoIssuance, - automaticTaxEnabled, billingAddress, currency, email, @@ -1398,16 +1349,6 @@ private constructor( */ fun autoIssuance(): Boolean? = autoIssuance.getNullable("auto_issuance") - /** - * Whether automatic tax calculation is enabled for this customer. When null, inherits from - * account-level setting. When true or false, overrides the account setting. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun automaticTaxEnabled(): Boolean? = - automaticTaxEnabled.getNullable("automatic_tax_enabled") - /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -1706,16 +1647,6 @@ private constructor( @ExcludeMissing fun _autoIssuance(): JsonField = autoIssuance - /** - * Returns the raw JSON value of [automaticTaxEnabled]. - * - * Unlike [automaticTaxEnabled], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("automatic_tax_enabled") - @ExcludeMissing - fun _automaticTaxEnabled(): JsonField = automaticTaxEnabled - /** * Returns the raw JSON value of [billingAddress]. * @@ -1866,7 +1797,6 @@ private constructor( private var additionalEmails: JsonField>? = null private var autoCollection: JsonField = JsonMissing.of() private var autoIssuance: JsonField = JsonMissing.of() - private var automaticTaxEnabled: JsonField = JsonMissing.of() private var billingAddress: JsonField = JsonMissing.of() private var currency: JsonField = JsonMissing.of() private var email: JsonField = JsonMissing.of() @@ -1889,7 +1819,6 @@ private constructor( additionalEmails = body.additionalEmails.map { it.toMutableList() } autoCollection = body.autoCollection autoIssuance = body.autoIssuance - automaticTaxEnabled = body.automaticTaxEnabled billingAddress = body.billingAddress currency = body.currency email = body.email @@ -2006,32 +1935,6 @@ private constructor( this.autoIssuance = autoIssuance } - /** - * Whether automatic tax calculation is enabled for this customer. When null, inherits - * from account-level setting. When true or false, overrides the account setting. - */ - fun automaticTaxEnabled(automaticTaxEnabled: Boolean?) = - automaticTaxEnabled(JsonField.ofNullable(automaticTaxEnabled)) - - /** - * Alias for [Builder.automaticTaxEnabled]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun automaticTaxEnabled(automaticTaxEnabled: Boolean) = - automaticTaxEnabled(automaticTaxEnabled as Boolean?) - - /** - * Sets [Builder.automaticTaxEnabled] to an arbitrary JSON value. - * - * You should usually call [Builder.automaticTaxEnabled] with a well-typed [Boolean] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun automaticTaxEnabled(automaticTaxEnabled: JsonField) = apply { - this.automaticTaxEnabled = automaticTaxEnabled - } - fun billingAddress(billingAddress: AddressInput?) = billingAddress(JsonField.ofNullable(billingAddress)) @@ -2518,7 +2421,6 @@ private constructor( (additionalEmails ?: JsonMissing.of()).map { it.toImmutable() }, autoCollection, autoIssuance, - automaticTaxEnabled, billingAddress, currency, email, @@ -2548,7 +2450,6 @@ private constructor( additionalEmails() autoCollection() autoIssuance() - automaticTaxEnabled() billingAddress()?.validate() currency() email() @@ -2585,7 +2486,6 @@ private constructor( (additionalEmails.asKnown()?.size ?: 0) + (if (autoCollection.asKnown() == null) 0 else 1) + (if (autoIssuance.asKnown() == null) 0 else 1) + - (if (automaticTaxEnabled.asKnown() == null) 0 else 1) + (billingAddress.asKnown()?.validity() ?: 0) + (if (currency.asKnown() == null) 0 else 1) + (if (email.asKnown() == null) 0 else 1) + @@ -2611,7 +2511,6 @@ private constructor( additionalEmails == other.additionalEmails && autoCollection == other.autoCollection && autoIssuance == other.autoIssuance && - automaticTaxEnabled == other.automaticTaxEnabled && billingAddress == other.billingAddress && currency == other.currency && email == other.email && @@ -2635,7 +2534,6 @@ private constructor( additionalEmails, autoCollection, autoIssuance, - automaticTaxEnabled, billingAddress, currency, email, @@ -2657,7 +2555,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Body{accountingSyncConfiguration=$accountingSyncConfiguration, additionalEmails=$additionalEmails, autoCollection=$autoCollection, autoIssuance=$autoIssuance, automaticTaxEnabled=$automaticTaxEnabled, billingAddress=$billingAddress, currency=$currency, email=$email, emailDelivery=$emailDelivery, externalCustomerId=$externalCustomerId, hierarchy=$hierarchy, metadata=$metadata, name=$name, paymentProvider=$paymentProvider, paymentProviderId=$paymentProviderId, reportingConfiguration=$reportingConfiguration, shippingAddress=$shippingAddress, taxConfiguration=$taxConfiguration, taxId=$taxId, additionalProperties=$additionalProperties}" + "Body{accountingSyncConfiguration=$accountingSyncConfiguration, additionalEmails=$additionalEmails, autoCollection=$autoCollection, autoIssuance=$autoIssuance, billingAddress=$billingAddress, currency=$currency, email=$email, emailDelivery=$emailDelivery, externalCustomerId=$externalCustomerId, hierarchy=$hierarchy, metadata=$metadata, name=$name, paymentProvider=$paymentProvider, paymentProviderId=$paymentProviderId, reportingConfiguration=$reportingConfiguration, shippingAddress=$shippingAddress, taxConfiguration=$taxConfiguration, taxId=$taxId, additionalProperties=$additionalProperties}" } /** diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerUpdateByExternalIdParamsTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerUpdateByExternalIdParamsTest.kt index 4717c6118..ea5e02b39 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerUpdateByExternalIdParamsTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerUpdateByExternalIdParamsTest.kt @@ -26,7 +26,6 @@ internal class CustomerUpdateByExternalIdParamsTest { .addAdditionalEmail("string") .autoCollection(true) .autoIssuance(true) - .automaticTaxEnabled(true) .billingAddress( AddressInput.builder() .city("city") @@ -112,7 +111,6 @@ internal class CustomerUpdateByExternalIdParamsTest { .addAdditionalEmail("string") .autoCollection(true) .autoIssuance(true) - .automaticTaxEnabled(true) .billingAddress( AddressInput.builder() .city("city") @@ -186,7 +184,6 @@ internal class CustomerUpdateByExternalIdParamsTest { assertThat(body.additionalEmails()).containsExactly("string") assertThat(body.autoCollection()).isEqualTo(true) assertThat(body.autoIssuance()).isEqualTo(true) - assertThat(body.automaticTaxEnabled()).isEqualTo(true) assertThat(body.billingAddress()) .isEqualTo( AddressInput.builder() diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerUpdateParamsTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerUpdateParamsTest.kt index d4535efd2..0084366db 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerUpdateParamsTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerUpdateParamsTest.kt @@ -26,7 +26,6 @@ internal class CustomerUpdateParamsTest { .addAdditionalEmail("string") .autoCollection(true) .autoIssuance(true) - .automaticTaxEnabled(true) .billingAddress( AddressInput.builder() .city("city") @@ -112,7 +111,6 @@ internal class CustomerUpdateParamsTest { .addAdditionalEmail("string") .autoCollection(true) .autoIssuance(true) - .automaticTaxEnabled(true) .billingAddress( AddressInput.builder() .city("city") @@ -186,7 +184,6 @@ internal class CustomerUpdateParamsTest { assertThat(body.additionalEmails()).containsExactly("string") assertThat(body.autoCollection()).isEqualTo(true) assertThat(body.autoIssuance()).isEqualTo(true) - assertThat(body.automaticTaxEnabled()).isEqualTo(true) assertThat(body.billingAddress()) .isEqualTo( AddressInput.builder() diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/CustomerServiceAsyncTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/CustomerServiceAsyncTest.kt index 99f3b6429..353c230ad 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/CustomerServiceAsyncTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/CustomerServiceAsyncTest.kt @@ -137,7 +137,6 @@ internal class CustomerServiceAsyncTest { .addAdditionalEmail("string") .autoCollection(true) .autoIssuance(true) - .automaticTaxEnabled(true) .billingAddress( AddressInput.builder() .city("city") @@ -307,7 +306,6 @@ internal class CustomerServiceAsyncTest { .addAdditionalEmail("string") .autoCollection(true) .autoIssuance(true) - .automaticTaxEnabled(true) .billingAddress( AddressInput.builder() .city("city") diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/CustomerServiceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/CustomerServiceTest.kt index 9d900c96f..c5362e091 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/CustomerServiceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/CustomerServiceTest.kt @@ -137,7 +137,6 @@ internal class CustomerServiceTest { .addAdditionalEmail("string") .autoCollection(true) .autoIssuance(true) - .automaticTaxEnabled(true) .billingAddress( AddressInput.builder() .city("city") @@ -305,7 +304,6 @@ internal class CustomerServiceTest { .addAdditionalEmail("string") .autoCollection(true) .autoIssuance(true) - .automaticTaxEnabled(true) .billingAddress( AddressInput.builder() .city("city") From 914623ae6f05e8ea28761331aba3b36676f10a99 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 5 Nov 2025 22:26:53 +0000 Subject: [PATCH 44/68] feat(api): api update --- .stats.yml | 4 +- .../com/withorb/api/models/PriceInterval.kt | 52 +++++- .../SubscriptionPriceIntervalsParams.kt | 168 +++++++++++++++++- .../com/withorb/api/models/TieredConfig.kt | 46 ++++- .../com/withorb/api/models/UnitConfig.kt | 50 +++++- .../withorb/api/models/AggregatedCostTest.kt | 21 ++- .../models/BetaCreatePlanVersionParamsTest.kt | 42 ++++- ...ternalPlanIdCreatePlanVersionParamsTest.kt | 42 ++++- .../ChangedSubscriptionResourcesTest.kt | 30 +++- ...ustomerCostListByExternalIdResponseTest.kt | 15 +- .../models/CustomerCostListResponseTest.kt | 15 +- ...dgerCreateEntryByExternalIdResponseTest.kt | 6 +- ...omerCreditLedgerCreateEntryResponseTest.kt | 6 +- ...tLedgerListByExternalIdPageResponseTest.kt | 3 + ...reditLedgerListByExternalIdResponseTest.kt | 6 +- ...ustomerCreditLedgerListPageResponseTest.kt | 3 + .../CustomerCreditLedgerListResponseTest.kt | 6 +- .../api/models/IncrementLedgerEntryTest.kt | 15 +- .../api/models/InvoiceCreateParamsTest.kt | 12 +- .../InvoiceFetchUpcomingResponseTest.kt | 21 ++- .../InvoiceLineItemCreateResponseTest.kt | 12 +- .../api/models/InvoiceListPageResponseTest.kt | 15 +- .../com/withorb/api/models/InvoiceTest.kt | 21 ++- .../api/models/MutatedSubscriptionTest.kt | 51 +++++- .../api/models/NewFloatingTieredPriceTest.kt | 3 + .../api/models/NewFloatingUnitPriceTest.kt | 6 +- .../api/models/NewPlanTieredPriceTest.kt | 3 + .../api/models/NewPlanUnitPriceTest.kt | 6 +- .../models/NewSubscriptionTieredPriceTest.kt | 3 + .../models/NewSubscriptionUnitPriceTest.kt | 6 +- .../withorb/api/models/PerPriceCostTest.kt | 12 +- .../api/models/PlanCreateParamsTest.kt | 21 ++- .../api/models/PlanListPageResponseTest.kt | 21 ++- .../kotlin/com/withorb/api/models/PlanTest.kt | 12 +- .../com/withorb/api/models/PlanVersionTest.kt | 12 +- .../api/models/PriceCreateParamsTest.kt | 12 +- .../models/PriceEvaluateMultipleParamsTest.kt | 21 ++- .../PriceEvaluatePreviewEventsParamsTest.kt | 21 ++- .../withorb/api/models/PriceIntervalTest.kt | 15 +- .../api/models/PriceListPageResponseTest.kt | 12 +- .../com/withorb/api/models/PriceTest.kt | 8 +- .../SubscriptionChangeApplyResponseTest.kt | 39 +++- .../SubscriptionChangeCancelResponseTest.kt | 39 +++- .../SubscriptionChangeRetrieveResponseTest.kt | 39 +++- .../models/SubscriptionCreateParamsTest.kt | 42 ++++- .../SubscriptionFetchCostsResponseTest.kt | 15 +- .../SubscriptionPriceIntervalsParamsTest.kt | 27 ++- ...ubscriptionSchedulePlanChangeParamsTest.kt | 42 ++++- .../withorb/api/models/SubscriptionTest.kt | 45 ++++- .../withorb/api/models/SubscriptionsTest.kt | 33 +++- .../withorb/api/models/TieredConfigTest.kt | 3 + .../com/withorb/api/models/UnitConfigTest.kt | 5 +- .../services/async/BetaServiceAsyncTest.kt | 10 +- .../services/async/InvoiceServiceAsyncTest.kt | 7 +- .../services/async/PlanServiceAsyncTest.kt | 5 +- .../services/async/PriceServiceAsyncTest.kt | 17 +- .../async/SubscriptionServiceAsyncTest.kt | 27 ++- .../beta/ExternalPlanIdServiceAsyncTest.kt | 10 +- .../api/services/blocking/BetaServiceTest.kt | 10 +- .../services/blocking/InvoiceServiceTest.kt | 7 +- .../api/services/blocking/PlanServiceTest.kt | 5 +- .../api/services/blocking/PriceServiceTest.kt | 17 +- .../blocking/SubscriptionServiceTest.kt | 27 ++- .../beta/ExternalPlanIdServiceTest.kt | 10 +- 64 files changed, 1146 insertions(+), 191 deletions(-) diff --git a/.stats.yml b/.stats.yml index 467b7cc35..5d845f554 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 118 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-5b9152241ebdd0d2f3fd536784f33721d24a5c4a59e75cab366a3dcb36552d3d.yml -openapi_spec_hash: b40061d10bbe1ebab8998bddd1827cf8 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-f2b97a2c3e41f618dc8955ed325092320ff2170a7d7a9a26a31dc235c969b657.yml +openapi_spec_hash: 64548564dc8ce80ef3ad38fc8cb56b30 config_hash: dd4343ce95871032ef6e0735a4ca038c diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceInterval.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceInterval.kt index 8a59b1aaa..da8d4959e 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceInterval.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceInterval.kt @@ -27,6 +27,7 @@ class PriceInterval private constructor( private val id: JsonField, private val billingCycleDay: JsonField, + private val canDeferBilling: JsonField, private val currentBillingPeriodEndDate: JsonField, private val currentBillingPeriodStartDate: JsonField, private val endDate: JsonField, @@ -44,6 +45,9 @@ private constructor( @JsonProperty("billing_cycle_day") @ExcludeMissing billingCycleDay: JsonField = JsonMissing.of(), + @JsonProperty("can_defer_billing") + @ExcludeMissing + canDeferBilling: JsonField = JsonMissing.of(), @JsonProperty("current_billing_period_end_date") @ExcludeMissing currentBillingPeriodEndDate: JsonField = JsonMissing.of(), @@ -67,6 +71,7 @@ private constructor( ) : this( id, billingCycleDay, + canDeferBilling, currentBillingPeriodEndDate, currentBillingPeriodStartDate, endDate, @@ -92,6 +97,15 @@ private constructor( */ fun billingCycleDay(): Long = billingCycleDay.getRequired("billing_cycle_day") + /** + * For in-arrears prices. If true, and the price interval ends mid-cycle, the final line item + * will be deferred to the next scheduled invoice instead of being billed mid-cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun canDeferBilling(): Boolean = canDeferBilling.getRequired("can_defer_billing") + /** * The end of the current billing period. This is an exclusive timestamp, such that the instant * returned is exactly the end of the billing period. Set to null if this price interval is not @@ -191,6 +205,15 @@ private constructor( @ExcludeMissing fun _billingCycleDay(): JsonField = billingCycleDay + /** + * Returns the raw JSON value of [canDeferBilling]. + * + * Unlike [canDeferBilling], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("can_defer_billing") + @ExcludeMissing + fun _canDeferBilling(): JsonField = canDeferBilling + /** * Returns the raw JSON value of [currentBillingPeriodEndDate]. * @@ -283,6 +306,7 @@ private constructor( * ```kotlin * .id() * .billingCycleDay() + * .canDeferBilling() * .currentBillingPeriodEndDate() * .currentBillingPeriodStartDate() * .endDate() @@ -301,6 +325,7 @@ private constructor( private var id: JsonField? = null private var billingCycleDay: JsonField? = null + private var canDeferBilling: JsonField? = null private var currentBillingPeriodEndDate: JsonField? = null private var currentBillingPeriodStartDate: JsonField? = null private var endDate: JsonField? = null @@ -316,6 +341,7 @@ private constructor( internal fun from(priceInterval: PriceInterval) = apply { id = priceInterval.id billingCycleDay = priceInterval.billingCycleDay + canDeferBilling = priceInterval.canDeferBilling currentBillingPeriodEndDate = priceInterval.currentBillingPeriodEndDate currentBillingPeriodStartDate = priceInterval.currentBillingPeriodStartDate endDate = priceInterval.endDate @@ -352,6 +378,24 @@ private constructor( this.billingCycleDay = billingCycleDay } + /** + * For in-arrears prices. If true, and the price interval ends mid-cycle, the final line + * item will be deferred to the next scheduled invoice instead of being billed mid-cycle. + */ + fun canDeferBilling(canDeferBilling: Boolean) = + canDeferBilling(JsonField.of(canDeferBilling)) + + /** + * Sets [Builder.canDeferBilling] to an arbitrary JSON value. + * + * You should usually call [Builder.canDeferBilling] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun canDeferBilling(canDeferBilling: JsonField) = apply { + this.canDeferBilling = canDeferBilling + } + /** * The end of the current billing period. This is an exclusive timestamp, such that the * instant returned is exactly the end of the billing period. Set to null if this price @@ -684,6 +728,7 @@ private constructor( * ```kotlin * .id() * .billingCycleDay() + * .canDeferBilling() * .currentBillingPeriodEndDate() * .currentBillingPeriodStartDate() * .endDate() @@ -700,6 +745,7 @@ private constructor( PriceInterval( checkRequired("id", id), checkRequired("billingCycleDay", billingCycleDay), + checkRequired("canDeferBilling", canDeferBilling), checkRequired("currentBillingPeriodEndDate", currentBillingPeriodEndDate), checkRequired("currentBillingPeriodStartDate", currentBillingPeriodStartDate), checkRequired("endDate", endDate), @@ -723,6 +769,7 @@ private constructor( id() billingCycleDay() + canDeferBilling() currentBillingPeriodEndDate() currentBillingPeriodStartDate() endDate() @@ -750,6 +797,7 @@ private constructor( internal fun validity(): Int = (if (id.asKnown() == null) 0 else 1) + (if (billingCycleDay.asKnown() == null) 0 else 1) + + (if (canDeferBilling.asKnown() == null) 0 else 1) + (if (currentBillingPeriodEndDate.asKnown() == null) 0 else 1) + (if (currentBillingPeriodStartDate.asKnown() == null) 0 else 1) + (if (endDate.asKnown() == null) 0 else 1) + @@ -767,6 +815,7 @@ private constructor( return other is PriceInterval && id == other.id && billingCycleDay == other.billingCycleDay && + canDeferBilling == other.canDeferBilling && currentBillingPeriodEndDate == other.currentBillingPeriodEndDate && currentBillingPeriodStartDate == other.currentBillingPeriodStartDate && endDate == other.endDate && @@ -782,6 +831,7 @@ private constructor( Objects.hash( id, billingCycleDay, + canDeferBilling, currentBillingPeriodEndDate, currentBillingPeriodStartDate, endDate, @@ -797,5 +847,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "PriceInterval{id=$id, billingCycleDay=$billingCycleDay, currentBillingPeriodEndDate=$currentBillingPeriodEndDate, currentBillingPeriodStartDate=$currentBillingPeriodStartDate, endDate=$endDate, filter=$filter, fixedFeeQuantityTransitions=$fixedFeeQuantityTransitions, price=$price, startDate=$startDate, usageCustomerIds=$usageCustomerIds, additionalProperties=$additionalProperties}" + "PriceInterval{id=$id, billingCycleDay=$billingCycleDay, canDeferBilling=$canDeferBilling, currentBillingPeriodEndDate=$currentBillingPeriodEndDate, currentBillingPeriodStartDate=$currentBillingPeriodStartDate, endDate=$endDate, filter=$filter, fixedFeeQuantityTransitions=$fixedFeeQuantityTransitions, price=$price, startDate=$startDate, usageCustomerIds=$usageCustomerIds, additionalProperties=$additionalProperties}" } diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsParams.kt index 7dd24c6e7..113bc1ef8 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsParams.kt @@ -133,6 +133,16 @@ private constructor( */ fun allowInvoiceCreditOrVoid(): Boolean? = body.allowInvoiceCreditOrVoid() + /** + * If true, ending an in-arrears price interval mid-cycle will defer billing the final line + * itemuntil the next scheduled invoice. If false, it will be billed on its end date. If not + * provided, behaviorwill follow account default. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun canDeferBilling(): Boolean? = body.canDeferBilling() + /** * A list of price intervals to edit on the subscription. * @@ -171,6 +181,13 @@ private constructor( */ fun _allowInvoiceCreditOrVoid(): JsonField = body._allowInvoiceCreditOrVoid() + /** + * Returns the raw JSON value of [canDeferBilling]. + * + * Unlike [canDeferBilling], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _canDeferBilling(): JsonField = body._canDeferBilling() + /** * Returns the raw JSON value of [edit]. * @@ -233,8 +250,8 @@ private constructor( * - [add] * - [addAdjustments] * - [allowInvoiceCreditOrVoid] + * - [canDeferBilling] * - [edit] - * - [editAdjustments] * - etc. */ fun body(body: Body) = apply { this.body = body.toBuilder() } @@ -310,6 +327,33 @@ private constructor( body.allowInvoiceCreditOrVoid(allowInvoiceCreditOrVoid) } + /** + * If true, ending an in-arrears price interval mid-cycle will defer billing the final line + * itemuntil the next scheduled invoice. If false, it will be billed on its end date. If not + * provided, behaviorwill follow account default. + */ + fun canDeferBilling(canDeferBilling: Boolean?) = apply { + body.canDeferBilling(canDeferBilling) + } + + /** + * Alias for [Builder.canDeferBilling]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun canDeferBilling(canDeferBilling: Boolean) = canDeferBilling(canDeferBilling as Boolean?) + + /** + * Sets [Builder.canDeferBilling] to an arbitrary JSON value. + * + * You should usually call [Builder.canDeferBilling] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun canDeferBilling(canDeferBilling: JsonField) = apply { + body.canDeferBilling(canDeferBilling) + } + /** A list of price intervals to edit on the subscription. */ fun edit(edit: List) = apply { body.edit(edit) } @@ -502,6 +546,7 @@ private constructor( private val add: JsonField>, private val addAdjustments: JsonField>, private val allowInvoiceCreditOrVoid: JsonField, + private val canDeferBilling: JsonField, private val edit: JsonField>, private val editAdjustments: JsonField>, private val additionalProperties: MutableMap, @@ -516,6 +561,9 @@ private constructor( @JsonProperty("allow_invoice_credit_or_void") @ExcludeMissing allowInvoiceCreditOrVoid: JsonField = JsonMissing.of(), + @JsonProperty("can_defer_billing") + @ExcludeMissing + canDeferBilling: JsonField = JsonMissing.of(), @JsonProperty("edit") @ExcludeMissing edit: JsonField> = JsonMissing.of(), @JsonProperty("edit_adjustments") @ExcludeMissing @@ -524,6 +572,7 @@ private constructor( add, addAdjustments, allowInvoiceCreditOrVoid, + canDeferBilling, edit, editAdjustments, mutableMapOf(), @@ -556,6 +605,16 @@ private constructor( fun allowInvoiceCreditOrVoid(): Boolean? = allowInvoiceCreditOrVoid.getNullable("allow_invoice_credit_or_void") + /** + * If true, ending an in-arrears price interval mid-cycle will defer billing the final line + * itemuntil the next scheduled invoice. If false, it will be billed on its end date. If not + * provided, behaviorwill follow account default. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun canDeferBilling(): Boolean? = canDeferBilling.getNullable("can_defer_billing") + /** * A list of price intervals to edit on the subscription. * @@ -600,6 +659,16 @@ private constructor( @ExcludeMissing fun _allowInvoiceCreditOrVoid(): JsonField = allowInvoiceCreditOrVoid + /** + * Returns the raw JSON value of [canDeferBilling]. + * + * Unlike [canDeferBilling], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("can_defer_billing") + @ExcludeMissing + fun _canDeferBilling(): JsonField = canDeferBilling + /** * Returns the raw JSON value of [edit]. * @@ -641,6 +710,7 @@ private constructor( private var add: JsonField>? = null private var addAdjustments: JsonField>? = null private var allowInvoiceCreditOrVoid: JsonField = JsonMissing.of() + private var canDeferBilling: JsonField = JsonMissing.of() private var edit: JsonField>? = null private var editAdjustments: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -649,6 +719,7 @@ private constructor( add = body.add.map { it.toMutableList() } addAdjustments = body.addAdjustments.map { it.toMutableList() } allowInvoiceCreditOrVoid = body.allowInvoiceCreditOrVoid + canDeferBilling = body.canDeferBilling edit = body.edit.map { it.toMutableList() } editAdjustments = body.editAdjustments.map { it.toMutableList() } additionalProperties = body.additionalProperties.toMutableMap() @@ -732,6 +803,33 @@ private constructor( this.allowInvoiceCreditOrVoid = allowInvoiceCreditOrVoid } + /** + * If true, ending an in-arrears price interval mid-cycle will defer billing the final + * line itemuntil the next scheduled invoice. If false, it will be billed on its end + * date. If not provided, behaviorwill follow account default. + */ + fun canDeferBilling(canDeferBilling: Boolean?) = + canDeferBilling(JsonField.ofNullable(canDeferBilling)) + + /** + * Alias for [Builder.canDeferBilling]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun canDeferBilling(canDeferBilling: Boolean) = + canDeferBilling(canDeferBilling as Boolean?) + + /** + * Sets [Builder.canDeferBilling] to an arbitrary JSON value. + * + * You should usually call [Builder.canDeferBilling] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun canDeferBilling(canDeferBilling: JsonField) = apply { + this.canDeferBilling = canDeferBilling + } + /** A list of price intervals to edit on the subscription. */ fun edit(edit: List) = edit(JsonField.of(edit)) @@ -814,6 +912,7 @@ private constructor( (add ?: JsonMissing.of()).map { it.toImmutable() }, (addAdjustments ?: JsonMissing.of()).map { it.toImmutable() }, allowInvoiceCreditOrVoid, + canDeferBilling, (edit ?: JsonMissing.of()).map { it.toImmutable() }, (editAdjustments ?: JsonMissing.of()).map { it.toImmutable() }, additionalProperties.toMutableMap(), @@ -830,6 +929,7 @@ private constructor( add()?.forEach { it.validate() } addAdjustments()?.forEach { it.validate() } allowInvoiceCreditOrVoid() + canDeferBilling() edit()?.forEach { it.validate() } editAdjustments()?.forEach { it.validate() } validated = true @@ -853,6 +953,7 @@ private constructor( (add.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + (addAdjustments.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + (if (allowInvoiceCreditOrVoid.asKnown() == null) 0 else 1) + + (if (canDeferBilling.asKnown() == null) 0 else 1) + (edit.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + (editAdjustments.asKnown()?.sumOf { it.validity().toInt() } ?: 0) @@ -865,6 +966,7 @@ private constructor( add == other.add && addAdjustments == other.addAdjustments && allowInvoiceCreditOrVoid == other.allowInvoiceCreditOrVoid && + canDeferBilling == other.canDeferBilling && edit == other.edit && editAdjustments == other.editAdjustments && additionalProperties == other.additionalProperties @@ -875,6 +977,7 @@ private constructor( add, addAdjustments, allowInvoiceCreditOrVoid, + canDeferBilling, edit, editAdjustments, additionalProperties, @@ -884,7 +987,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Body{add=$add, addAdjustments=$addAdjustments, allowInvoiceCreditOrVoid=$allowInvoiceCreditOrVoid, edit=$edit, editAdjustments=$editAdjustments, additionalProperties=$additionalProperties}" + "Body{add=$add, addAdjustments=$addAdjustments, allowInvoiceCreditOrVoid=$allowInvoiceCreditOrVoid, canDeferBilling=$canDeferBilling, edit=$edit, editAdjustments=$editAdjustments, additionalProperties=$additionalProperties}" } class Add @@ -12233,6 +12336,7 @@ private constructor( private constructor( private val priceIntervalId: JsonField, private val billingCycleDay: JsonField, + private val canDeferBilling: JsonField, private val endDate: JsonField, private val filter: JsonField, private val fixedFeeQuantityTransitions: JsonField>, @@ -12249,6 +12353,9 @@ private constructor( @JsonProperty("billing_cycle_day") @ExcludeMissing billingCycleDay: JsonField = JsonMissing.of(), + @JsonProperty("can_defer_billing") + @ExcludeMissing + canDeferBilling: JsonField = JsonMissing.of(), @JsonProperty("end_date") @ExcludeMissing endDate: JsonField = JsonMissing.of(), @@ -12266,6 +12373,7 @@ private constructor( ) : this( priceIntervalId, billingCycleDay, + canDeferBilling, endDate, filter, fixedFeeQuantityTransitions, @@ -12292,6 +12400,16 @@ private constructor( */ fun billingCycleDay(): Long? = billingCycleDay.getNullable("billing_cycle_day") + /** + * If true, ending an in-arrears price interval mid-cycle will defer billing the final line + * itemuntil the next scheduled invoice. If false, it will be billed on its end date. If not + * provided, behaviorwill follow account default. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun canDeferBilling(): Boolean? = canDeferBilling.getNullable("can_defer_billing") + /** * The updated end date of this price interval. If not specified, the end date will not be * updated. @@ -12362,6 +12480,16 @@ private constructor( @ExcludeMissing fun _billingCycleDay(): JsonField = billingCycleDay + /** + * Returns the raw JSON value of [canDeferBilling]. + * + * Unlike [canDeferBilling], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("can_defer_billing") + @ExcludeMissing + fun _canDeferBilling(): JsonField = canDeferBilling + /** * Returns the raw JSON value of [endDate]. * @@ -12436,6 +12564,7 @@ private constructor( private var priceIntervalId: JsonField? = null private var billingCycleDay: JsonField = JsonMissing.of() + private var canDeferBilling: JsonField = JsonMissing.of() private var endDate: JsonField = JsonMissing.of() private var filter: JsonField = JsonMissing.of() private var fixedFeeQuantityTransitions: @@ -12448,6 +12577,7 @@ private constructor( internal fun from(edit: Edit) = apply { priceIntervalId = edit.priceIntervalId billingCycleDay = edit.billingCycleDay + canDeferBilling = edit.canDeferBilling endDate = edit.endDate filter = edit.filter fixedFeeQuantityTransitions = @@ -12498,6 +12628,33 @@ private constructor( this.billingCycleDay = billingCycleDay } + /** + * If true, ending an in-arrears price interval mid-cycle will defer billing the final + * line itemuntil the next scheduled invoice. If false, it will be billed on its end + * date. If not provided, behaviorwill follow account default. + */ + fun canDeferBilling(canDeferBilling: Boolean?) = + canDeferBilling(JsonField.ofNullable(canDeferBilling)) + + /** + * Alias for [Builder.canDeferBilling]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun canDeferBilling(canDeferBilling: Boolean) = + canDeferBilling(canDeferBilling as Boolean?) + + /** + * Sets [Builder.canDeferBilling] to an arbitrary JSON value. + * + * You should usually call [Builder.canDeferBilling] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun canDeferBilling(canDeferBilling: JsonField) = apply { + this.canDeferBilling = canDeferBilling + } + /** * The updated end date of this price interval. If not specified, the end date will not * be updated. @@ -12671,6 +12828,7 @@ private constructor( Edit( checkRequired("priceIntervalId", priceIntervalId), billingCycleDay, + canDeferBilling, endDate, filter, (fixedFeeQuantityTransitions ?: JsonMissing.of()).map { it.toImmutable() }, @@ -12689,6 +12847,7 @@ private constructor( priceIntervalId() billingCycleDay() + canDeferBilling() endDate()?.validate() filter() fixedFeeQuantityTransitions()?.forEach { it.validate() } @@ -12714,6 +12873,7 @@ private constructor( internal fun validity(): Int = (if (priceIntervalId.asKnown() == null) 0 else 1) + (if (billingCycleDay.asKnown() == null) 0 else 1) + + (if (canDeferBilling.asKnown() == null) 0 else 1) + (endDate.asKnown()?.validity() ?: 0) + (if (filter.asKnown() == null) 0 else 1) + (fixedFeeQuantityTransitions.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + @@ -13314,6 +13474,7 @@ private constructor( return other is Edit && priceIntervalId == other.priceIntervalId && billingCycleDay == other.billingCycleDay && + canDeferBilling == other.canDeferBilling && endDate == other.endDate && filter == other.filter && fixedFeeQuantityTransitions == other.fixedFeeQuantityTransitions && @@ -13326,6 +13487,7 @@ private constructor( Objects.hash( priceIntervalId, billingCycleDay, + canDeferBilling, endDate, filter, fixedFeeQuantityTransitions, @@ -13338,7 +13500,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Edit{priceIntervalId=$priceIntervalId, billingCycleDay=$billingCycleDay, endDate=$endDate, filter=$filter, fixedFeeQuantityTransitions=$fixedFeeQuantityTransitions, startDate=$startDate, usageCustomerIds=$usageCustomerIds, additionalProperties=$additionalProperties}" + "Edit{priceIntervalId=$priceIntervalId, billingCycleDay=$billingCycleDay, canDeferBilling=$canDeferBilling, endDate=$endDate, filter=$filter, fixedFeeQuantityTransitions=$fixedFeeQuantityTransitions, startDate=$startDate, usageCustomerIds=$usageCustomerIds, additionalProperties=$additionalProperties}" } class EditAdjustment diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/TieredConfig.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/TieredConfig.kt index 083335ed1..6d1f3fe74 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/TieredConfig.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/TieredConfig.kt @@ -22,13 +22,15 @@ class TieredConfig @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val tiers: JsonField>, + private val prorated: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("tiers") @ExcludeMissing tiers: JsonField> = JsonMissing.of() - ) : this(tiers, mutableMapOf()) + @JsonProperty("tiers") @ExcludeMissing tiers: JsonField> = JsonMissing.of(), + @JsonProperty("prorated") @ExcludeMissing prorated: JsonField = JsonMissing.of(), + ) : this(tiers, prorated, mutableMapOf()) /** * Tiers for rating based on total usage quantities into the specified tier @@ -38,6 +40,14 @@ private constructor( */ fun tiers(): List = tiers.getRequired("tiers") + /** + * If true, subtotals from this price are prorated based on the service period + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun prorated(): Boolean? = prorated.getNullable("prorated") + /** * Returns the raw JSON value of [tiers]. * @@ -45,6 +55,13 @@ private constructor( */ @JsonProperty("tiers") @ExcludeMissing fun _tiers(): JsonField> = tiers + /** + * Returns the raw JSON value of [prorated]. + * + * Unlike [prorated], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("prorated") @ExcludeMissing fun _prorated(): JsonField = prorated + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -74,10 +91,12 @@ private constructor( class Builder internal constructor() { private var tiers: JsonField>? = null + private var prorated: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() internal fun from(tieredConfig: TieredConfig) = apply { tiers = tieredConfig.tiers.map { it.toMutableList() } + prorated = tieredConfig.prorated additionalProperties = tieredConfig.additionalProperties.toMutableMap() } @@ -105,6 +124,18 @@ private constructor( (tiers ?: JsonField.of(mutableListOf())).also { checkKnown("tiers", it).add(tier) } } + /** If true, subtotals from this price are prorated based on the service period */ + fun prorated(prorated: Boolean) = prorated(JsonField.of(prorated)) + + /** + * Sets [Builder.prorated] to an arbitrary JSON value. + * + * You should usually call [Builder.prorated] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun prorated(prorated: JsonField) = apply { this.prorated = prorated } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -139,6 +170,7 @@ private constructor( fun build(): TieredConfig = TieredConfig( checkRequired("tiers", tiers).map { it.toImmutable() }, + prorated, additionalProperties.toMutableMap(), ) } @@ -151,6 +183,7 @@ private constructor( } tiers().forEach { it.validate() } + prorated() validated = true } @@ -167,7 +200,9 @@ private constructor( * * Used for best match union deserialization. */ - internal fun validity(): Int = (tiers.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + internal fun validity(): Int = + (tiers.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + (if (prorated.asKnown() == null) 0 else 1) override fun equals(other: Any?): Boolean { if (this === other) { @@ -176,13 +211,14 @@ private constructor( return other is TieredConfig && tiers == other.tiers && + prorated == other.prorated && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(tiers, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(tiers, prorated, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "TieredConfig{tiers=$tiers, additionalProperties=$additionalProperties}" + "TieredConfig{tiers=$tiers, prorated=$prorated, additionalProperties=$additionalProperties}" } diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/UnitConfig.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/UnitConfig.kt index f0863274a..bdcb64b01 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/UnitConfig.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/UnitConfig.kt @@ -20,6 +20,7 @@ class UnitConfig @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val unitAmount: JsonField, + private val prorated: JsonField, private val additionalProperties: MutableMap, ) { @@ -27,8 +28,9 @@ private constructor( private constructor( @JsonProperty("unit_amount") @ExcludeMissing - unitAmount: JsonField = JsonMissing.of() - ) : this(unitAmount, mutableMapOf()) + unitAmount: JsonField = JsonMissing.of(), + @JsonProperty("prorated") @ExcludeMissing prorated: JsonField = JsonMissing.of(), + ) : this(unitAmount, prorated, mutableMapOf()) /** * Rate per unit of usage @@ -38,6 +40,14 @@ private constructor( */ fun unitAmount(): String = unitAmount.getRequired("unit_amount") + /** + * If true, subtotals from this price are prorated based on the service period + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun prorated(): Boolean? = prorated.getNullable("prorated") + /** * Returns the raw JSON value of [unitAmount]. * @@ -45,6 +55,13 @@ private constructor( */ @JsonProperty("unit_amount") @ExcludeMissing fun _unitAmount(): JsonField = unitAmount + /** + * Returns the raw JSON value of [prorated]. + * + * Unlike [prorated], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("prorated") @ExcludeMissing fun _prorated(): JsonField = prorated + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -74,10 +91,12 @@ private constructor( class Builder internal constructor() { private var unitAmount: JsonField? = null + private var prorated: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() internal fun from(unitConfig: UnitConfig) = apply { unitAmount = unitConfig.unitAmount + prorated = unitConfig.prorated additionalProperties = unitConfig.additionalProperties.toMutableMap() } @@ -93,6 +112,18 @@ private constructor( */ fun unitAmount(unitAmount: JsonField) = apply { this.unitAmount = unitAmount } + /** If true, subtotals from this price are prorated based on the service period */ + fun prorated(prorated: Boolean) = prorated(JsonField.of(prorated)) + + /** + * Sets [Builder.prorated] to an arbitrary JSON value. + * + * You should usually call [Builder.prorated] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun prorated(prorated: JsonField) = apply { this.prorated = prorated } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -125,7 +156,11 @@ private constructor( * @throws IllegalStateException if any required field is unset. */ fun build(): UnitConfig = - UnitConfig(checkRequired("unitAmount", unitAmount), additionalProperties.toMutableMap()) + UnitConfig( + checkRequired("unitAmount", unitAmount), + prorated, + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false @@ -136,6 +171,7 @@ private constructor( } unitAmount() + prorated() validated = true } @@ -152,7 +188,8 @@ private constructor( * * Used for best match union deserialization. */ - internal fun validity(): Int = (if (unitAmount.asKnown() == null) 0 else 1) + internal fun validity(): Int = + (if (unitAmount.asKnown() == null) 0 else 1) + (if (prorated.asKnown() == null) 0 else 1) override fun equals(other: Any?): Boolean { if (this === other) { @@ -161,13 +198,14 @@ private constructor( return other is UnitConfig && unitAmount == other.unitAmount && + prorated == other.prorated && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(unitAmount, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(unitAmount, prorated, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "UnitConfig{unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + "UnitConfig{unitAmount=$unitAmount, prorated=$prorated, additionalProperties=$additionalProperties}" } diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/AggregatedCostTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/AggregatedCostTest.kt index 01f2674e2..2ade8104e 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/AggregatedCostTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/AggregatedCostTest.kt @@ -127,7 +127,12 @@ internal class AggregatedCostTest { .planPhaseOrder(0L) .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() + ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") @@ -257,7 +262,12 @@ internal class AggregatedCostTest { .planPhaseOrder(0L) .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() + ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") @@ -397,7 +407,12 @@ internal class AggregatedCostTest { .planPhaseOrder(0L) .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() + ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/BetaCreatePlanVersionParamsTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/BetaCreatePlanVersionParamsTest.kt index 3dbe50042..34890c76b 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/BetaCreatePlanVersionParamsTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/BetaCreatePlanVersionParamsTest.kt @@ -71,7 +71,12 @@ internal class BetaCreatePlanVersionParamsTest { .itemId("item_id") .modelType(NewPlanUnitPrice.ModelType.UNIT) .name("Annual fee") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() + ) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( @@ -185,7 +190,12 @@ internal class BetaCreatePlanVersionParamsTest { .itemId("item_id") .modelType(NewPlanUnitPrice.ModelType.UNIT) .name("Annual fee") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() + ) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( @@ -304,7 +314,12 @@ internal class BetaCreatePlanVersionParamsTest { .itemId("item_id") .modelType(NewPlanUnitPrice.ModelType.UNIT) .name("Annual fee") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() + ) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( @@ -420,7 +435,12 @@ internal class BetaCreatePlanVersionParamsTest { .itemId("item_id") .modelType(NewPlanUnitPrice.ModelType.UNIT) .name("Annual fee") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() + ) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( @@ -530,7 +550,12 @@ internal class BetaCreatePlanVersionParamsTest { .itemId("item_id") .modelType(NewPlanUnitPrice.ModelType.UNIT) .name("Annual fee") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() + ) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( @@ -648,7 +673,12 @@ internal class BetaCreatePlanVersionParamsTest { .itemId("item_id") .modelType(NewPlanUnitPrice.ModelType.UNIT) .name("Annual fee") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() + ) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/BetaExternalPlanIdCreatePlanVersionParamsTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/BetaExternalPlanIdCreatePlanVersionParamsTest.kt index 4dbf59c0e..c00941bb8 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/BetaExternalPlanIdCreatePlanVersionParamsTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/BetaExternalPlanIdCreatePlanVersionParamsTest.kt @@ -71,7 +71,12 @@ internal class BetaExternalPlanIdCreatePlanVersionParamsTest { .itemId("item_id") .modelType(NewPlanUnitPrice.ModelType.UNIT) .name("Annual fee") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() + ) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( @@ -185,7 +190,12 @@ internal class BetaExternalPlanIdCreatePlanVersionParamsTest { .itemId("item_id") .modelType(NewPlanUnitPrice.ModelType.UNIT) .name("Annual fee") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() + ) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( @@ -308,7 +318,12 @@ internal class BetaExternalPlanIdCreatePlanVersionParamsTest { .itemId("item_id") .modelType(NewPlanUnitPrice.ModelType.UNIT) .name("Annual fee") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() + ) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( @@ -424,7 +439,12 @@ internal class BetaExternalPlanIdCreatePlanVersionParamsTest { .itemId("item_id") .modelType(NewPlanUnitPrice.ModelType.UNIT) .name("Annual fee") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() + ) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( @@ -534,7 +554,12 @@ internal class BetaExternalPlanIdCreatePlanVersionParamsTest { .itemId("item_id") .modelType(NewPlanUnitPrice.ModelType.UNIT) .name("Annual fee") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() + ) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( @@ -652,7 +677,12 @@ internal class BetaExternalPlanIdCreatePlanVersionParamsTest { .itemId("item_id") .modelType(NewPlanUnitPrice.ModelType.UNIT) .name("Annual fee") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() + ) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/ChangedSubscriptionResourcesTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/ChangedSubscriptionResourcesTest.kt index 8e615b244..8007460df 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/ChangedSubscriptionResourcesTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/ChangedSubscriptionResourcesTest.kt @@ -426,7 +426,10 @@ internal class ChangedSubscriptionResourcesTest { .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( - UnitConfig.builder().unitAmount("unit_amount").build() + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -944,7 +947,10 @@ internal class ChangedSubscriptionResourcesTest { .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( - UnitConfig.builder().unitAmount("unit_amount").build() + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -1453,7 +1459,10 @@ internal class ChangedSubscriptionResourcesTest { .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( - UnitConfig.builder().unitAmount("unit_amount").build() + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -1948,7 +1957,10 @@ internal class ChangedSubscriptionResourcesTest { .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( - UnitConfig.builder().unitAmount("unit_amount").build() + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -2479,7 +2491,10 @@ internal class ChangedSubscriptionResourcesTest { .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( - UnitConfig.builder().unitAmount("unit_amount").build() + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -2997,7 +3012,10 @@ internal class ChangedSubscriptionResourcesTest { .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( - UnitConfig.builder().unitAmount("unit_amount").build() + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCostListByExternalIdResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCostListByExternalIdResponseTest.kt index dabd954a2..3dec1a32b 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCostListByExternalIdResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCostListByExternalIdResponseTest.kt @@ -153,7 +153,10 @@ internal class CustomerCostListByExternalIdResponseTest { .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( - UnitConfig.builder().unitAmount("unit_amount").build() + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -303,7 +306,10 @@ internal class CustomerCostListByExternalIdResponseTest { .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( - UnitConfig.builder().unitAmount("unit_amount").build() + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -470,7 +476,10 @@ internal class CustomerCostListByExternalIdResponseTest { .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( - UnitConfig.builder().unitAmount("unit_amount").build() + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCostListResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCostListResponseTest.kt index 2e50ce013..2d1b3196a 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCostListResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCostListResponseTest.kt @@ -153,7 +153,10 @@ internal class CustomerCostListResponseTest { .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( - UnitConfig.builder().unitAmount("unit_amount").build() + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -303,7 +306,10 @@ internal class CustomerCostListResponseTest { .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( - UnitConfig.builder().unitAmount("unit_amount").build() + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -470,7 +476,10 @@ internal class CustomerCostListResponseTest { .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( - UnitConfig.builder().unitAmount("unit_amount").build() + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdResponseTest.kt index c2dc22055..6126c3b36 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdResponseTest.kt @@ -367,7 +367,10 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdResponseTest { .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( - UnitConfig.builder().unitAmount("unit_amount").build() + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -864,6 +867,7 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdResponseTest { .unitConfig( UnitConfig.builder() .unitAmount("unit_amount") + .prorated(true) .build() ) .dimensionalPriceConfiguration( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryResponseTest.kt index 66a81f4c0..23efbb9bc 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryResponseTest.kt @@ -367,7 +367,10 @@ internal class CustomerCreditLedgerCreateEntryResponseTest { .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( - UnitConfig.builder().unitAmount("unit_amount").build() + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -863,6 +866,7 @@ internal class CustomerCreditLedgerCreateEntryResponseTest { .unitConfig( UnitConfig.builder() .unitAmount("unit_amount") + .prorated(true) .build() ) .dimensionalPriceConfiguration( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdPageResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdPageResponseTest.kt index 8157460a8..4025b73e4 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdPageResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdPageResponseTest.kt @@ -405,6 +405,7 @@ internal class CustomerCreditLedgerListByExternalIdPageResponseTest { .unitConfig( UnitConfig.builder() .unitAmount("unit_amount") + .prorated(true) .build() ) .dimensionalPriceConfiguration( @@ -925,6 +926,7 @@ internal class CustomerCreditLedgerListByExternalIdPageResponseTest { .unitConfig( UnitConfig.builder() .unitAmount("unit_amount") + .prorated(true) .build() ) .dimensionalPriceConfiguration( @@ -1448,6 +1450,7 @@ internal class CustomerCreditLedgerListByExternalIdPageResponseTest { .unitConfig( UnitConfig.builder() .unitAmount("unit_amount") + .prorated(true) .build() ) .dimensionalPriceConfiguration( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdResponseTest.kt index 247d50bd9..962aa0fb4 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdResponseTest.kt @@ -367,7 +367,10 @@ internal class CustomerCreditLedgerListByExternalIdResponseTest { .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( - UnitConfig.builder().unitAmount("unit_amount").build() + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -863,6 +866,7 @@ internal class CustomerCreditLedgerListByExternalIdResponseTest { .unitConfig( UnitConfig.builder() .unitAmount("unit_amount") + .prorated(true) .build() ) .dimensionalPriceConfiguration( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListPageResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListPageResponseTest.kt index 2d96a1ce3..15074c7b4 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListPageResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListPageResponseTest.kt @@ -405,6 +405,7 @@ internal class CustomerCreditLedgerListPageResponseTest { .unitConfig( UnitConfig.builder() .unitAmount("unit_amount") + .prorated(true) .build() ) .dimensionalPriceConfiguration( @@ -925,6 +926,7 @@ internal class CustomerCreditLedgerListPageResponseTest { .unitConfig( UnitConfig.builder() .unitAmount("unit_amount") + .prorated(true) .build() ) .dimensionalPriceConfiguration( @@ -1448,6 +1450,7 @@ internal class CustomerCreditLedgerListPageResponseTest { .unitConfig( UnitConfig.builder() .unitAmount("unit_amount") + .prorated(true) .build() ) .dimensionalPriceConfiguration( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListResponseTest.kt index a7728344f..ba8b35e85 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListResponseTest.kt @@ -367,7 +367,10 @@ internal class CustomerCreditLedgerListResponseTest { .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( - UnitConfig.builder().unitAmount("unit_amount").build() + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -863,6 +866,7 @@ internal class CustomerCreditLedgerListResponseTest { .unitConfig( UnitConfig.builder() .unitAmount("unit_amount") + .prorated(true) .build() ) .dimensionalPriceConfiguration( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/IncrementLedgerEntryTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/IncrementLedgerEntryTest.kt index ae20501cf..a1faa6b9e 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/IncrementLedgerEntryTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/IncrementLedgerEntryTest.kt @@ -363,7 +363,10 @@ internal class IncrementLedgerEntryTest { .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( - UnitConfig.builder().unitAmount("unit_amount").build() + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -814,7 +817,10 @@ internal class IncrementLedgerEntryTest { .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( - UnitConfig.builder().unitAmount("unit_amount").build() + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -1282,7 +1288,10 @@ internal class IncrementLedgerEntryTest { .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( - UnitConfig.builder().unitAmount("unit_amount").build() + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceCreateParamsTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceCreateParamsTest.kt index b00c638da..94c7f4107 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceCreateParamsTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceCreateParamsTest.kt @@ -23,7 +23,9 @@ internal class InvoiceCreateParamsTest { .name("Line Item Name") .quantity(1.0) .startDate(LocalDate.parse("2023-09-22")) - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder().unitAmount("unit_amount").prorated(true).build() + ) .build() ) .customerId("4khy3nwzktxv7") @@ -70,7 +72,9 @@ internal class InvoiceCreateParamsTest { .name("Line Item Name") .quantity(1.0) .startDate(LocalDate.parse("2023-09-22")) - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder().unitAmount("unit_amount").prorated(true).build() + ) .build() ) .customerId("4khy3nwzktxv7") @@ -115,7 +119,9 @@ internal class InvoiceCreateParamsTest { .name("Line Item Name") .quantity(1.0) .startDate(LocalDate.parse("2023-09-22")) - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder().unitAmount("unit_amount").prorated(true).build() + ) .build() ) assertThat(body.customerId()).isEqualTo("4khy3nwzktxv7") diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceFetchUpcomingResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceFetchUpcomingResponseTest.kt index 34c4ac2af..2762dced0 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceFetchUpcomingResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceFetchUpcomingResponseTest.kt @@ -295,7 +295,12 @@ internal class InvoiceFetchUpcomingResponseTest { .planPhaseOrder(0L) .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() + ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") @@ -700,7 +705,12 @@ internal class InvoiceFetchUpcomingResponseTest { .planPhaseOrder(0L) .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() + ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") @@ -1111,7 +1121,12 @@ internal class InvoiceFetchUpcomingResponseTest { .planPhaseOrder(0L) .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() + ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceLineItemCreateResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceLineItemCreateResponseTest.kt index 4f9f42aba..cac65e6b0 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceLineItemCreateResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceLineItemCreateResponseTest.kt @@ -195,7 +195,9 @@ internal class InvoiceLineItemCreateResponseTest { .planPhaseOrder(0L) .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder().unitAmount("unit_amount").prorated(true).build() + ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") @@ -421,7 +423,9 @@ internal class InvoiceLineItemCreateResponseTest { .planPhaseOrder(0L) .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder().unitAmount("unit_amount").prorated(true).build() + ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") @@ -647,7 +651,9 @@ internal class InvoiceLineItemCreateResponseTest { .planPhaseOrder(0L) .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder().unitAmount("unit_amount").prorated(true).build() + ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceListPageResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceListPageResponseTest.kt index 4bc2f7bd9..855bc2ef7 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceListPageResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceListPageResponseTest.kt @@ -328,7 +328,10 @@ internal class InvoiceListPageResponseTest { .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( - UnitConfig.builder().unitAmount("unit_amount").build() + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -741,7 +744,10 @@ internal class InvoiceListPageResponseTest { .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( - UnitConfig.builder().unitAmount("unit_amount").build() + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -1176,7 +1182,10 @@ internal class InvoiceListPageResponseTest { .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( - UnitConfig.builder().unitAmount("unit_amount").build() + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceTest.kt index a76a00d1f..7f6631f86 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceTest.kt @@ -291,7 +291,12 @@ internal class InvoiceTest { .planPhaseOrder(0L) .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() + ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") @@ -687,7 +692,12 @@ internal class InvoiceTest { .planPhaseOrder(0L) .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() + ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") @@ -1087,7 +1097,12 @@ internal class InvoiceTest { .planPhaseOrder(0L) .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() + ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/MutatedSubscriptionTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/MutatedSubscriptionTest.kt index 4d456f184..ec7940de0 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/MutatedSubscriptionTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/MutatedSubscriptionTest.kt @@ -472,7 +472,12 @@ internal class MutatedSubscriptionTest { .planPhaseOrder(0L) .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() + ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") @@ -502,6 +507,7 @@ internal class MutatedSubscriptionTest { PriceInterval.builder() .id("id") .billingCycleDay(0L) + .canDeferBilling(true) .currentBillingPeriodEndDate( OffsetDateTime.parse("2019-12-27T18:11:19.117Z") ) @@ -627,7 +633,12 @@ internal class MutatedSubscriptionTest { .planPhaseOrder(0L) .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() + ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") @@ -1114,6 +1125,7 @@ internal class MutatedSubscriptionTest { .unitConfig( UnitConfig.builder() .unitAmount("unit_amount") + .prorated(true) .build() ) .dimensionalPriceConfiguration( @@ -1683,6 +1695,7 @@ internal class MutatedSubscriptionTest { .unitConfig( UnitConfig.builder() .unitAmount("unit_amount") + .prorated(true) .build() ) .dimensionalPriceConfiguration( @@ -2266,7 +2279,12 @@ internal class MutatedSubscriptionTest { .planPhaseOrder(0L) .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() + ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") @@ -2297,6 +2315,7 @@ internal class MutatedSubscriptionTest { PriceInterval.builder() .id("id") .billingCycleDay(0L) + .canDeferBilling(true) .currentBillingPeriodEndDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .currentBillingPeriodStartDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) @@ -2414,7 +2433,12 @@ internal class MutatedSubscriptionTest { .planPhaseOrder(0L) .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() + ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") @@ -2875,6 +2899,7 @@ internal class MutatedSubscriptionTest { .unitConfig( UnitConfig.builder() .unitAmount("unit_amount") + .prorated(true) .build() ) .dimensionalPriceConfiguration( @@ -3410,6 +3435,7 @@ internal class MutatedSubscriptionTest { .unitConfig( UnitConfig.builder() .unitAmount("unit_amount") + .prorated(true) .build() ) .dimensionalPriceConfiguration( @@ -3993,7 +4019,12 @@ internal class MutatedSubscriptionTest { .planPhaseOrder(0L) .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() + ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") @@ -4023,6 +4054,7 @@ internal class MutatedSubscriptionTest { PriceInterval.builder() .id("id") .billingCycleDay(0L) + .canDeferBilling(true) .currentBillingPeriodEndDate( OffsetDateTime.parse("2019-12-27T18:11:19.117Z") ) @@ -4148,7 +4180,12 @@ internal class MutatedSubscriptionTest { .planPhaseOrder(0L) .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() + ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") @@ -4635,6 +4672,7 @@ internal class MutatedSubscriptionTest { .unitConfig( UnitConfig.builder() .unitAmount("unit_amount") + .prorated(true) .build() ) .dimensionalPriceConfiguration( @@ -5204,6 +5242,7 @@ internal class MutatedSubscriptionTest { .unitConfig( UnitConfig.builder() .unitAmount("unit_amount") + .prorated(true) .build() ) .dimensionalPriceConfiguration( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingTieredPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingTieredPriceTest.kt index 7f537d1c5..0b1ad1505 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingTieredPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingTieredPriceTest.kt @@ -28,6 +28,7 @@ internal class NewFloatingTieredPriceTest { .lastUnit(0.0) .build() ) + .prorated(true) .build() ) .billableMetricId("billable_metric_id") @@ -82,6 +83,7 @@ internal class NewFloatingTieredPriceTest { .lastUnit(0.0) .build() ) + .prorated(true) .build() ) assertThat(newFloatingTieredPrice.billableMetricId()).isEqualTo("billable_metric_id") @@ -150,6 +152,7 @@ internal class NewFloatingTieredPriceTest { .lastUnit(0.0) .build() ) + .prorated(true) .build() ) .billableMetricId("billable_metric_id") diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingUnitPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingUnitPriceTest.kt index e5ecea168..a74d263b9 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingUnitPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingUnitPriceTest.kt @@ -19,7 +19,7 @@ internal class NewFloatingUnitPriceTest { .itemId("item_id") .modelType(NewFloatingUnitPrice.ModelType.UNIT) .name("Annual fee") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig(UnitConfig.builder().unitAmount("unit_amount").prorated(true).build()) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( @@ -61,7 +61,7 @@ internal class NewFloatingUnitPriceTest { assertThat(newFloatingUnitPrice.modelType()).isEqualTo(NewFloatingUnitPrice.ModelType.UNIT) assertThat(newFloatingUnitPrice.name()).isEqualTo("Annual fee") assertThat(newFloatingUnitPrice.unitConfig()) - .isEqualTo(UnitConfig.builder().unitAmount("unit_amount").build()) + .isEqualTo(UnitConfig.builder().unitAmount("unit_amount").prorated(true).build()) assertThat(newFloatingUnitPrice.billableMetricId()).isEqualTo("billable_metric_id") assertThat(newFloatingUnitPrice.billedInAdvance()).isEqualTo(true) assertThat(newFloatingUnitPrice.billingCycleConfiguration()) @@ -119,7 +119,7 @@ internal class NewFloatingUnitPriceTest { .itemId("item_id") .modelType(NewFloatingUnitPrice.ModelType.UNIT) .name("Annual fee") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig(UnitConfig.builder().unitAmount("unit_amount").prorated(true).build()) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanTieredPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanTieredPriceTest.kt index f734797fc..df536eea4 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanTieredPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanTieredPriceTest.kt @@ -27,6 +27,7 @@ internal class NewPlanTieredPriceTest { .lastUnit(0.0) .build() ) + .prorated(true) .build() ) .billableMetricId("billable_metric_id") @@ -80,6 +81,7 @@ internal class NewPlanTieredPriceTest { .lastUnit(0.0) .build() ) + .prorated(true) .build() ) assertThat(newPlanTieredPrice.billableMetricId()).isEqualTo("billable_metric_id") @@ -149,6 +151,7 @@ internal class NewPlanTieredPriceTest { .lastUnit(0.0) .build() ) + .prorated(true) .build() ) .billableMetricId("billable_metric_id") diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanUnitPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanUnitPriceTest.kt index ba6443d6a..65af2ecd7 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanUnitPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanUnitPriceTest.kt @@ -18,7 +18,7 @@ internal class NewPlanUnitPriceTest { .itemId("item_id") .modelType(NewPlanUnitPrice.ModelType.UNIT) .name("Annual fee") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig(UnitConfig.builder().unitAmount("unit_amount").prorated(true).build()) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( @@ -61,7 +61,7 @@ internal class NewPlanUnitPriceTest { assertThat(newPlanUnitPrice.modelType()).isEqualTo(NewPlanUnitPrice.ModelType.UNIT) assertThat(newPlanUnitPrice.name()).isEqualTo("Annual fee") assertThat(newPlanUnitPrice.unitConfig()) - .isEqualTo(UnitConfig.builder().unitAmount("unit_amount").build()) + .isEqualTo(UnitConfig.builder().unitAmount("unit_amount").prorated(true).build()) assertThat(newPlanUnitPrice.billableMetricId()).isEqualTo("billable_metric_id") assertThat(newPlanUnitPrice.billedInAdvance()).isEqualTo(true) assertThat(newPlanUnitPrice.billingCycleConfiguration()) @@ -120,7 +120,7 @@ internal class NewPlanUnitPriceTest { .itemId("item_id") .modelType(NewPlanUnitPrice.ModelType.UNIT) .name("Annual fee") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig(UnitConfig.builder().unitAmount("unit_amount").prorated(true).build()) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionTieredPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionTieredPriceTest.kt index 0228c35ea..497d65f80 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionTieredPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionTieredPriceTest.kt @@ -27,6 +27,7 @@ internal class NewSubscriptionTieredPriceTest { .lastUnit(0.0) .build() ) + .prorated(true) .build() ) .billableMetricId("billable_metric_id") @@ -82,6 +83,7 @@ internal class NewSubscriptionTieredPriceTest { .lastUnit(0.0) .build() ) + .prorated(true) .build() ) assertThat(newSubscriptionTieredPrice.billableMetricId()).isEqualTo("billable_metric_id") @@ -151,6 +153,7 @@ internal class NewSubscriptionTieredPriceTest { .lastUnit(0.0) .build() ) + .prorated(true) .build() ) .billableMetricId("billable_metric_id") diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionUnitPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionUnitPriceTest.kt index 8d1121afc..7a25fc48f 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionUnitPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionUnitPriceTest.kt @@ -18,7 +18,7 @@ internal class NewSubscriptionUnitPriceTest { .itemId("item_id") .modelType(NewSubscriptionUnitPrice.ModelType.UNIT) .name("Annual fee") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig(UnitConfig.builder().unitAmount("unit_amount").prorated(true).build()) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( @@ -63,7 +63,7 @@ internal class NewSubscriptionUnitPriceTest { .isEqualTo(NewSubscriptionUnitPrice.ModelType.UNIT) assertThat(newSubscriptionUnitPrice.name()).isEqualTo("Annual fee") assertThat(newSubscriptionUnitPrice.unitConfig()) - .isEqualTo(UnitConfig.builder().unitAmount("unit_amount").build()) + .isEqualTo(UnitConfig.builder().unitAmount("unit_amount").prorated(true).build()) assertThat(newSubscriptionUnitPrice.billableMetricId()).isEqualTo("billable_metric_id") assertThat(newSubscriptionUnitPrice.billedInAdvance()).isEqualTo(true) assertThat(newSubscriptionUnitPrice.billingCycleConfiguration()) @@ -122,7 +122,7 @@ internal class NewSubscriptionUnitPriceTest { .itemId("item_id") .modelType(NewSubscriptionUnitPrice.ModelType.UNIT) .name("Annual fee") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig(UnitConfig.builder().unitAmount("unit_amount").prorated(true).build()) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PerPriceCostTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PerPriceCostTest.kt index 65d21e290..d3664707c 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PerPriceCostTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PerPriceCostTest.kt @@ -121,7 +121,9 @@ internal class PerPriceCostTest { .planPhaseOrder(0L) .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder().unitAmount("unit_amount").prorated(true).build() + ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") @@ -244,7 +246,9 @@ internal class PerPriceCostTest { .planPhaseOrder(0L) .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder().unitAmount("unit_amount").prorated(true).build() + ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") @@ -371,7 +375,9 @@ internal class PerPriceCostTest { .planPhaseOrder(0L) .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder().unitAmount("unit_amount").prorated(true).build() + ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanCreateParamsTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanCreateParamsTest.kt index 94359c89b..c4911f2e6 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanCreateParamsTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanCreateParamsTest.kt @@ -43,7 +43,12 @@ internal class PlanCreateParamsTest { .itemId("item_id") .modelType(NewPlanUnitPrice.ModelType.UNIT) .name("Annual fee") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() + ) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( @@ -169,7 +174,12 @@ internal class PlanCreateParamsTest { .itemId("item_id") .modelType(NewPlanUnitPrice.ModelType.UNIT) .name("Annual fee") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() + ) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( @@ -295,7 +305,12 @@ internal class PlanCreateParamsTest { .itemId("item_id") .modelType(NewPlanUnitPrice.ModelType.UNIT) .name("Annual fee") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() + ) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanListPageResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanListPageResponseTest.kt index 0ec9f5f51..5c0b98e12 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanListPageResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanListPageResponseTest.kt @@ -275,7 +275,12 @@ internal class PlanListPageResponseTest { .planPhaseOrder(0L) .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() + ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") @@ -558,7 +563,12 @@ internal class PlanListPageResponseTest { .planPhaseOrder(0L) .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() + ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") @@ -853,7 +863,12 @@ internal class PlanListPageResponseTest { .planPhaseOrder(0L) .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() + ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanTest.kt index e4b6d5ff8..72b2e70fa 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanTest.kt @@ -262,7 +262,9 @@ internal class PlanTest { .planPhaseOrder(0L) .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder().unitAmount("unit_amount").prorated(true).build() + ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") @@ -548,7 +550,9 @@ internal class PlanTest { .planPhaseOrder(0L) .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder().unitAmount("unit_amount").prorated(true).build() + ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") @@ -829,7 +833,9 @@ internal class PlanTest { .planPhaseOrder(0L) .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder().unitAmount("unit_amount").prorated(true).build() + ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanVersionTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanVersionTest.kt index 23e05198a..222a2f141 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanVersionTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanVersionTest.kt @@ -153,7 +153,9 @@ internal class PlanVersionTest { .planPhaseOrder(0L) .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder().unitAmount("unit_amount").prorated(true).build() + ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") @@ -310,7 +312,9 @@ internal class PlanVersionTest { .planPhaseOrder(0L) .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder().unitAmount("unit_amount").prorated(true).build() + ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") @@ -466,7 +470,9 @@ internal class PlanVersionTest { .planPhaseOrder(0L) .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder().unitAmount("unit_amount").prorated(true).build() + ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceCreateParamsTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceCreateParamsTest.kt index 8b457c08d..4f4e9b97c 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceCreateParamsTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceCreateParamsTest.kt @@ -18,7 +18,9 @@ internal class PriceCreateParamsTest { .itemId("item_id") .modelType(NewFloatingUnitPrice.ModelType.UNIT) .name("Annual fee") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder().unitAmount("unit_amount").prorated(true).build() + ) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( @@ -68,7 +70,9 @@ internal class PriceCreateParamsTest { .itemId("item_id") .modelType(NewFloatingUnitPrice.ModelType.UNIT) .name("Annual fee") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder().unitAmount("unit_amount").prorated(true).build() + ) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( @@ -119,7 +123,9 @@ internal class PriceCreateParamsTest { .itemId("item_id") .modelType(NewFloatingUnitPrice.ModelType.UNIT) .name("Annual fee") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder().unitAmount("unit_amount").prorated(true).build() + ) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceEvaluateMultipleParamsTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceEvaluateMultipleParamsTest.kt index 0b559e17e..34d0427ab 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceEvaluateMultipleParamsTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceEvaluateMultipleParamsTest.kt @@ -28,7 +28,12 @@ internal class PriceEvaluateMultipleParamsTest { .itemId("item_id") .modelType(NewFloatingUnitPrice.ModelType.UNIT) .name("Annual fee") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() + ) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( @@ -92,7 +97,12 @@ internal class PriceEvaluateMultipleParamsTest { .itemId("item_id") .modelType(NewFloatingUnitPrice.ModelType.UNIT) .name("Annual fee") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() + ) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( @@ -157,7 +167,12 @@ internal class PriceEvaluateMultipleParamsTest { .itemId("item_id") .modelType(NewFloatingUnitPrice.ModelType.UNIT) .name("Annual fee") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() + ) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceEvaluatePreviewEventsParamsTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceEvaluatePreviewEventsParamsTest.kt index 0dff1be2a..dd34c6175 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceEvaluatePreviewEventsParamsTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceEvaluatePreviewEventsParamsTest.kt @@ -41,7 +41,12 @@ internal class PriceEvaluatePreviewEventsParamsTest { .itemId("item_id") .modelType(NewFloatingUnitPrice.ModelType.UNIT) .name("Annual fee") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() + ) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( @@ -118,7 +123,12 @@ internal class PriceEvaluatePreviewEventsParamsTest { .itemId("item_id") .modelType(NewFloatingUnitPrice.ModelType.UNIT) .name("Annual fee") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() + ) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( @@ -197,7 +207,12 @@ internal class PriceEvaluatePreviewEventsParamsTest { .itemId("item_id") .modelType(NewFloatingUnitPrice.ModelType.UNIT) .name("Annual fee") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() + ) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceIntervalTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceIntervalTest.kt index b0f216719..0c04a3e0e 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceIntervalTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceIntervalTest.kt @@ -17,6 +17,7 @@ internal class PriceIntervalTest { PriceInterval.builder() .id("id") .billingCycleDay(0L) + .canDeferBilling(true) .currentBillingPeriodEndDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .currentBillingPeriodStartDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) @@ -134,7 +135,9 @@ internal class PriceIntervalTest { .planPhaseOrder(0L) .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder().unitAmount("unit_amount").prorated(true).build() + ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") @@ -149,6 +152,7 @@ internal class PriceIntervalTest { assertThat(priceInterval.id()).isEqualTo("id") assertThat(priceInterval.billingCycleDay()).isEqualTo(0L) + assertThat(priceInterval.canDeferBilling()).isEqualTo(true) assertThat(priceInterval.currentBillingPeriodEndDate()) .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) assertThat(priceInterval.currentBillingPeriodStartDate()) @@ -272,7 +276,9 @@ internal class PriceIntervalTest { .planPhaseOrder(0L) .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder().unitAmount("unit_amount").prorated(true).build() + ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") @@ -294,6 +300,7 @@ internal class PriceIntervalTest { PriceInterval.builder() .id("id") .billingCycleDay(0L) + .canDeferBilling(true) .currentBillingPeriodEndDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .currentBillingPeriodStartDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) @@ -411,7 +418,9 @@ internal class PriceIntervalTest { .planPhaseOrder(0L) .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder().unitAmount("unit_amount").prorated(true).build() + ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceListPageResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceListPageResponseTest.kt index 1fb65073a..d88dcc50a 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceListPageResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceListPageResponseTest.kt @@ -121,7 +121,9 @@ internal class PriceListPageResponseTest { .planPhaseOrder(0L) .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder().unitAmount("unit_amount").prorated(true).build() + ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") @@ -243,7 +245,9 @@ internal class PriceListPageResponseTest { .planPhaseOrder(0L) .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder().unitAmount("unit_amount").prorated(true).build() + ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") @@ -368,7 +372,9 @@ internal class PriceListPageResponseTest { .planPhaseOrder(0L) .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder().unitAmount("unit_amount").prorated(true).build() + ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceTest.kt index 096384bc4..cae5086b5 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceTest.kt @@ -123,7 +123,7 @@ internal class PriceTest { .planPhaseOrder(0L) .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig(UnitConfig.builder().unitAmount("unit_amount").prorated(true).build()) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") @@ -276,7 +276,9 @@ internal class PriceTest { .planPhaseOrder(0L) .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder().unitAmount("unit_amount").prorated(true).build() + ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") @@ -409,6 +411,7 @@ internal class PriceTest { .lastUnit(0.0) .build() ) + .prorated(true) .build() ) .dimensionalPriceConfiguration( @@ -572,6 +575,7 @@ internal class PriceTest { .lastUnit(0.0) .build() ) + .prorated(true) .build() ) .dimensionalPriceConfiguration( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeApplyResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeApplyResponseTest.kt index c3f232454..0370d784a 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeApplyResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeApplyResponseTest.kt @@ -523,7 +523,10 @@ internal class SubscriptionChangeApplyResponseTest { .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( - UnitConfig.builder().unitAmount("unit_amount").build() + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -556,6 +559,7 @@ internal class SubscriptionChangeApplyResponseTest { PriceInterval.builder() .id("id") .billingCycleDay(0L) + .canDeferBilling(true) .currentBillingPeriodEndDate( OffsetDateTime.parse("2019-12-27T18:11:19.117Z") ) @@ -707,7 +711,10 @@ internal class SubscriptionChangeApplyResponseTest { .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( - UnitConfig.builder().unitAmount("unit_amount").build() + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -1278,6 +1285,7 @@ internal class SubscriptionChangeApplyResponseTest { .unitConfig( UnitConfig.builder() .unitAmount("unit_amount") + .prorated(true) .build() ) .dimensionalPriceConfiguration( @@ -1949,6 +1957,7 @@ internal class SubscriptionChangeApplyResponseTest { .unitConfig( UnitConfig.builder() .unitAmount("unit_amount") + .prorated(true) .build() ) .dimensionalPriceConfiguration( @@ -2578,7 +2587,10 @@ internal class SubscriptionChangeApplyResponseTest { .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( - UnitConfig.builder().unitAmount("unit_amount").build() + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -2609,6 +2621,7 @@ internal class SubscriptionChangeApplyResponseTest { PriceInterval.builder() .id("id") .billingCycleDay(0L) + .canDeferBilling(true) .currentBillingPeriodEndDate( OffsetDateTime.parse("2019-12-27T18:11:19.117Z") ) @@ -2743,7 +2756,10 @@ internal class SubscriptionChangeApplyResponseTest { .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( - UnitConfig.builder().unitAmount("unit_amount").build() + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -3270,6 +3286,7 @@ internal class SubscriptionChangeApplyResponseTest { .unitConfig( UnitConfig.builder() .unitAmount("unit_amount") + .prorated(true) .build() ) .dimensionalPriceConfiguration( @@ -3889,6 +3906,7 @@ internal class SubscriptionChangeApplyResponseTest { .unitConfig( UnitConfig.builder() .unitAmount("unit_amount") + .prorated(true) .build() ) .dimensionalPriceConfiguration( @@ -4543,7 +4561,10 @@ internal class SubscriptionChangeApplyResponseTest { .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( - UnitConfig.builder().unitAmount("unit_amount").build() + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -4576,6 +4597,7 @@ internal class SubscriptionChangeApplyResponseTest { PriceInterval.builder() .id("id") .billingCycleDay(0L) + .canDeferBilling(true) .currentBillingPeriodEndDate( OffsetDateTime.parse("2019-12-27T18:11:19.117Z") ) @@ -4727,7 +4749,10 @@ internal class SubscriptionChangeApplyResponseTest { .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( - UnitConfig.builder().unitAmount("unit_amount").build() + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -5298,6 +5323,7 @@ internal class SubscriptionChangeApplyResponseTest { .unitConfig( UnitConfig.builder() .unitAmount("unit_amount") + .prorated(true) .build() ) .dimensionalPriceConfiguration( @@ -5969,6 +5995,7 @@ internal class SubscriptionChangeApplyResponseTest { .unitConfig( UnitConfig.builder() .unitAmount("unit_amount") + .prorated(true) .build() ) .dimensionalPriceConfiguration( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeCancelResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeCancelResponseTest.kt index a131f96da..46fe8e38f 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeCancelResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeCancelResponseTest.kt @@ -523,7 +523,10 @@ internal class SubscriptionChangeCancelResponseTest { .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( - UnitConfig.builder().unitAmount("unit_amount").build() + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -556,6 +559,7 @@ internal class SubscriptionChangeCancelResponseTest { PriceInterval.builder() .id("id") .billingCycleDay(0L) + .canDeferBilling(true) .currentBillingPeriodEndDate( OffsetDateTime.parse("2019-12-27T18:11:19.117Z") ) @@ -707,7 +711,10 @@ internal class SubscriptionChangeCancelResponseTest { .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( - UnitConfig.builder().unitAmount("unit_amount").build() + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -1278,6 +1285,7 @@ internal class SubscriptionChangeCancelResponseTest { .unitConfig( UnitConfig.builder() .unitAmount("unit_amount") + .prorated(true) .build() ) .dimensionalPriceConfiguration( @@ -1949,6 +1957,7 @@ internal class SubscriptionChangeCancelResponseTest { .unitConfig( UnitConfig.builder() .unitAmount("unit_amount") + .prorated(true) .build() ) .dimensionalPriceConfiguration( @@ -2578,7 +2587,10 @@ internal class SubscriptionChangeCancelResponseTest { .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( - UnitConfig.builder().unitAmount("unit_amount").build() + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -2609,6 +2621,7 @@ internal class SubscriptionChangeCancelResponseTest { PriceInterval.builder() .id("id") .billingCycleDay(0L) + .canDeferBilling(true) .currentBillingPeriodEndDate( OffsetDateTime.parse("2019-12-27T18:11:19.117Z") ) @@ -2743,7 +2756,10 @@ internal class SubscriptionChangeCancelResponseTest { .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( - UnitConfig.builder().unitAmount("unit_amount").build() + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -3270,6 +3286,7 @@ internal class SubscriptionChangeCancelResponseTest { .unitConfig( UnitConfig.builder() .unitAmount("unit_amount") + .prorated(true) .build() ) .dimensionalPriceConfiguration( @@ -3889,6 +3906,7 @@ internal class SubscriptionChangeCancelResponseTest { .unitConfig( UnitConfig.builder() .unitAmount("unit_amount") + .prorated(true) .build() ) .dimensionalPriceConfiguration( @@ -4543,7 +4561,10 @@ internal class SubscriptionChangeCancelResponseTest { .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( - UnitConfig.builder().unitAmount("unit_amount").build() + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -4576,6 +4597,7 @@ internal class SubscriptionChangeCancelResponseTest { PriceInterval.builder() .id("id") .billingCycleDay(0L) + .canDeferBilling(true) .currentBillingPeriodEndDate( OffsetDateTime.parse("2019-12-27T18:11:19.117Z") ) @@ -4727,7 +4749,10 @@ internal class SubscriptionChangeCancelResponseTest { .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( - UnitConfig.builder().unitAmount("unit_amount").build() + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -5298,6 +5323,7 @@ internal class SubscriptionChangeCancelResponseTest { .unitConfig( UnitConfig.builder() .unitAmount("unit_amount") + .prorated(true) .build() ) .dimensionalPriceConfiguration( @@ -5969,6 +5995,7 @@ internal class SubscriptionChangeCancelResponseTest { .unitConfig( UnitConfig.builder() .unitAmount("unit_amount") + .prorated(true) .build() ) .dimensionalPriceConfiguration( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeRetrieveResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeRetrieveResponseTest.kt index c7892bd94..cc4446562 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeRetrieveResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeRetrieveResponseTest.kt @@ -523,7 +523,10 @@ internal class SubscriptionChangeRetrieveResponseTest { .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( - UnitConfig.builder().unitAmount("unit_amount").build() + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -556,6 +559,7 @@ internal class SubscriptionChangeRetrieveResponseTest { PriceInterval.builder() .id("id") .billingCycleDay(0L) + .canDeferBilling(true) .currentBillingPeriodEndDate( OffsetDateTime.parse("2019-12-27T18:11:19.117Z") ) @@ -707,7 +711,10 @@ internal class SubscriptionChangeRetrieveResponseTest { .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( - UnitConfig.builder().unitAmount("unit_amount").build() + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -1278,6 +1285,7 @@ internal class SubscriptionChangeRetrieveResponseTest { .unitConfig( UnitConfig.builder() .unitAmount("unit_amount") + .prorated(true) .build() ) .dimensionalPriceConfiguration( @@ -1949,6 +1957,7 @@ internal class SubscriptionChangeRetrieveResponseTest { .unitConfig( UnitConfig.builder() .unitAmount("unit_amount") + .prorated(true) .build() ) .dimensionalPriceConfiguration( @@ -2578,7 +2587,10 @@ internal class SubscriptionChangeRetrieveResponseTest { .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( - UnitConfig.builder().unitAmount("unit_amount").build() + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -2609,6 +2621,7 @@ internal class SubscriptionChangeRetrieveResponseTest { PriceInterval.builder() .id("id") .billingCycleDay(0L) + .canDeferBilling(true) .currentBillingPeriodEndDate( OffsetDateTime.parse("2019-12-27T18:11:19.117Z") ) @@ -2743,7 +2756,10 @@ internal class SubscriptionChangeRetrieveResponseTest { .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( - UnitConfig.builder().unitAmount("unit_amount").build() + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -3270,6 +3286,7 @@ internal class SubscriptionChangeRetrieveResponseTest { .unitConfig( UnitConfig.builder() .unitAmount("unit_amount") + .prorated(true) .build() ) .dimensionalPriceConfiguration( @@ -3889,6 +3906,7 @@ internal class SubscriptionChangeRetrieveResponseTest { .unitConfig( UnitConfig.builder() .unitAmount("unit_amount") + .prorated(true) .build() ) .dimensionalPriceConfiguration( @@ -4543,7 +4561,10 @@ internal class SubscriptionChangeRetrieveResponseTest { .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( - UnitConfig.builder().unitAmount("unit_amount").build() + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -4576,6 +4597,7 @@ internal class SubscriptionChangeRetrieveResponseTest { PriceInterval.builder() .id("id") .billingCycleDay(0L) + .canDeferBilling(true) .currentBillingPeriodEndDate( OffsetDateTime.parse("2019-12-27T18:11:19.117Z") ) @@ -4727,7 +4749,10 @@ internal class SubscriptionChangeRetrieveResponseTest { .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( - UnitConfig.builder().unitAmount("unit_amount").build() + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -5298,6 +5323,7 @@ internal class SubscriptionChangeRetrieveResponseTest { .unitConfig( UnitConfig.builder() .unitAmount("unit_amount") + .prorated(true) .build() ) .dimensionalPriceConfiguration( @@ -5969,6 +5995,7 @@ internal class SubscriptionChangeRetrieveResponseTest { .unitConfig( UnitConfig.builder() .unitAmount("unit_amount") + .prorated(true) .build() ) .dimensionalPriceConfiguration( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionCreateParamsTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionCreateParamsTest.kt index 1d0825138..9275ae991 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionCreateParamsTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionCreateParamsTest.kt @@ -84,7 +84,12 @@ internal class SubscriptionCreateParamsTest { .itemId("item_id") .modelType(NewSubscriptionUnitPrice.ModelType.UNIT) .name("Annual fee") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() + ) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( @@ -239,7 +244,12 @@ internal class SubscriptionCreateParamsTest { .itemId("item_id") .modelType(NewSubscriptionUnitPrice.ModelType.UNIT) .name("Annual fee") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() + ) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( @@ -364,7 +374,12 @@ internal class SubscriptionCreateParamsTest { .itemId("item_id") .modelType(NewSubscriptionUnitPrice.ModelType.UNIT) .name("Annual fee") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() + ) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( @@ -521,7 +536,12 @@ internal class SubscriptionCreateParamsTest { .itemId("item_id") .modelType(NewSubscriptionUnitPrice.ModelType.UNIT) .name("Annual fee") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() + ) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( @@ -647,7 +667,12 @@ internal class SubscriptionCreateParamsTest { .itemId("item_id") .modelType(NewSubscriptionUnitPrice.ModelType.UNIT) .name("Annual fee") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() + ) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( @@ -808,7 +833,12 @@ internal class SubscriptionCreateParamsTest { .itemId("item_id") .modelType(NewSubscriptionUnitPrice.ModelType.UNIT) .name("Annual fee") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() + ) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionFetchCostsResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionFetchCostsResponseTest.kt index 418914e3a..b21d17b34 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionFetchCostsResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionFetchCostsResponseTest.kt @@ -153,7 +153,10 @@ internal class SubscriptionFetchCostsResponseTest { .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( - UnitConfig.builder().unitAmount("unit_amount").build() + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -303,7 +306,10 @@ internal class SubscriptionFetchCostsResponseTest { .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( - UnitConfig.builder().unitAmount("unit_amount").build() + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -470,7 +476,10 @@ internal class SubscriptionFetchCostsResponseTest { .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( - UnitConfig.builder().unitAmount("unit_amount").build() + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsParamsTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsParamsTest.kt index 503aa3c29..a87c4534d 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsParamsTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsParamsTest.kt @@ -56,7 +56,12 @@ internal class SubscriptionPriceIntervalsParamsTest { .itemId("item_id") .modelType(NewFloatingUnitPrice.ModelType.UNIT) .name("Annual fee") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() + ) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( @@ -129,10 +134,12 @@ internal class SubscriptionPriceIntervalsParamsTest { .build() ) .allowInvoiceCreditOrVoid(true) + .canDeferBilling(true) .addEdit( SubscriptionPriceIntervalsParams.Edit.builder() .priceIntervalId("sdfs6wdjvn7ujokd") .billingCycleDay(0L) + .canDeferBilling(true) .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .filter("my_property > 100 AND my_other_property = 'bar'") .addFixedFeeQuantityTransition( @@ -214,7 +221,12 @@ internal class SubscriptionPriceIntervalsParamsTest { .itemId("item_id") .modelType(NewFloatingUnitPrice.ModelType.UNIT) .name("Annual fee") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() + ) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( @@ -289,10 +301,12 @@ internal class SubscriptionPriceIntervalsParamsTest { .build() ) .allowInvoiceCreditOrVoid(true) + .canDeferBilling(true) .addEdit( SubscriptionPriceIntervalsParams.Edit.builder() .priceIntervalId("sdfs6wdjvn7ujokd") .billingCycleDay(0L) + .canDeferBilling(true) .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .filter("my_property > 100 AND my_other_property = 'bar'") .addFixedFeeQuantityTransition( @@ -361,7 +375,12 @@ internal class SubscriptionPriceIntervalsParamsTest { .itemId("item_id") .modelType(NewFloatingUnitPrice.ModelType.UNIT) .name("Annual fee") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() + ) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( @@ -435,11 +454,13 @@ internal class SubscriptionPriceIntervalsParamsTest { .build() ) assertThat(body.allowInvoiceCreditOrVoid()).isEqualTo(true) + assertThat(body.canDeferBilling()).isEqualTo(true) assertThat(body.edit()) .containsExactly( SubscriptionPriceIntervalsParams.Edit.builder() .priceIntervalId("sdfs6wdjvn7ujokd") .billingCycleDay(0L) + .canDeferBilling(true) .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .filter("my_property > 100 AND my_other_property = 'bar'") .addFixedFeeQuantityTransition( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionSchedulePlanChangeParamsTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionSchedulePlanChangeParamsTest.kt index 4f20c056b..853f72cd5 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionSchedulePlanChangeParamsTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionSchedulePlanChangeParamsTest.kt @@ -86,7 +86,12 @@ internal class SubscriptionSchedulePlanChangeParamsTest { .itemId("item_id") .modelType(NewSubscriptionUnitPrice.ModelType.UNIT) .name("Annual fee") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() + ) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( @@ -232,7 +237,12 @@ internal class SubscriptionSchedulePlanChangeParamsTest { .itemId("item_id") .modelType(NewSubscriptionUnitPrice.ModelType.UNIT) .name("Annual fee") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() + ) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( @@ -371,7 +381,12 @@ internal class SubscriptionSchedulePlanChangeParamsTest { .itemId("item_id") .modelType(NewSubscriptionUnitPrice.ModelType.UNIT) .name("Annual fee") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() + ) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( @@ -519,7 +534,12 @@ internal class SubscriptionSchedulePlanChangeParamsTest { .itemId("item_id") .modelType(NewSubscriptionUnitPrice.ModelType.UNIT) .name("Annual fee") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() + ) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( @@ -646,7 +666,12 @@ internal class SubscriptionSchedulePlanChangeParamsTest { .itemId("item_id") .modelType(NewSubscriptionUnitPrice.ModelType.UNIT) .name("Annual fee") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() + ) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( @@ -794,7 +819,12 @@ internal class SubscriptionSchedulePlanChangeParamsTest { .itemId("item_id") .modelType(NewSubscriptionUnitPrice.ModelType.UNIT) .name("Annual fee") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() + ) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionTest.kt index 73abfc7bd..5167feda3 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionTest.kt @@ -472,7 +472,12 @@ internal class SubscriptionTest { .planPhaseOrder(0L) .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() + ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") @@ -502,6 +507,7 @@ internal class SubscriptionTest { PriceInterval.builder() .id("id") .billingCycleDay(0L) + .canDeferBilling(true) .currentBillingPeriodEndDate( OffsetDateTime.parse("2019-12-27T18:11:19.117Z") ) @@ -627,7 +633,12 @@ internal class SubscriptionTest { .planPhaseOrder(0L) .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() + ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") @@ -1114,7 +1125,12 @@ internal class SubscriptionTest { .planPhaseOrder(0L) .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() + ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") @@ -1145,6 +1161,7 @@ internal class SubscriptionTest { PriceInterval.builder() .id("id") .billingCycleDay(0L) + .canDeferBilling(true) .currentBillingPeriodEndDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .currentBillingPeriodStartDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) @@ -1262,7 +1279,12 @@ internal class SubscriptionTest { .planPhaseOrder(0L) .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() + ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") @@ -1756,7 +1778,12 @@ internal class SubscriptionTest { .planPhaseOrder(0L) .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() + ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") @@ -1786,6 +1813,7 @@ internal class SubscriptionTest { PriceInterval.builder() .id("id") .billingCycleDay(0L) + .canDeferBilling(true) .currentBillingPeriodEndDate( OffsetDateTime.parse("2019-12-27T18:11:19.117Z") ) @@ -1911,7 +1939,12 @@ internal class SubscriptionTest { .planPhaseOrder(0L) .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() + ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionsTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionsTest.kt index 1c102584d..064e7e885 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionsTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionsTest.kt @@ -520,7 +520,10 @@ internal class SubscriptionsTest { .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( - UnitConfig.builder().unitAmount("unit_amount").build() + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -553,6 +556,7 @@ internal class SubscriptionsTest { PriceInterval.builder() .id("id") .billingCycleDay(0L) + .canDeferBilling(true) .currentBillingPeriodEndDate( OffsetDateTime.parse("2019-12-27T18:11:19.117Z") ) @@ -704,7 +708,10 @@ internal class SubscriptionsTest { .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( - UnitConfig.builder().unitAmount("unit_amount").build() + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -1219,7 +1226,10 @@ internal class SubscriptionsTest { .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( - UnitConfig.builder().unitAmount("unit_amount").build() + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -1250,6 +1260,7 @@ internal class SubscriptionsTest { PriceInterval.builder() .id("id") .billingCycleDay(0L) + .canDeferBilling(true) .currentBillingPeriodEndDate( OffsetDateTime.parse("2019-12-27T18:11:19.117Z") ) @@ -1384,7 +1395,10 @@ internal class SubscriptionsTest { .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( - UnitConfig.builder().unitAmount("unit_amount").build() + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -1928,7 +1942,10 @@ internal class SubscriptionsTest { .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( - UnitConfig.builder().unitAmount("unit_amount").build() + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -1961,6 +1978,7 @@ internal class SubscriptionsTest { PriceInterval.builder() .id("id") .billingCycleDay(0L) + .canDeferBilling(true) .currentBillingPeriodEndDate( OffsetDateTime.parse("2019-12-27T18:11:19.117Z") ) @@ -2112,7 +2130,10 @@ internal class SubscriptionsTest { .priceType(Price.Unit.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( - UnitConfig.builder().unitAmount("unit_amount").build() + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/TieredConfigTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/TieredConfigTest.kt index af1c382c5..05a8b5cdc 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/TieredConfigTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/TieredConfigTest.kt @@ -16,12 +16,14 @@ internal class TieredConfigTest { .addTier( Tier.builder().firstUnit(0.0).unitAmount("unit_amount").lastUnit(0.0).build() ) + .prorated(true) .build() assertThat(tieredConfig.tiers()) .containsExactly( Tier.builder().firstUnit(0.0).unitAmount("unit_amount").lastUnit(0.0).build() ) + assertThat(tieredConfig.prorated()).isEqualTo(true) } @Test @@ -32,6 +34,7 @@ internal class TieredConfigTest { .addTier( Tier.builder().firstUnit(0.0).unitAmount("unit_amount").lastUnit(0.0).build() ) + .prorated(true) .build() val roundtrippedTieredConfig = diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/UnitConfigTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/UnitConfigTest.kt index 98fcacade..c8d05de67 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/UnitConfigTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/UnitConfigTest.kt @@ -11,15 +11,16 @@ internal class UnitConfigTest { @Test fun create() { - val unitConfig = UnitConfig.builder().unitAmount("unit_amount").build() + val unitConfig = UnitConfig.builder().unitAmount("unit_amount").prorated(true).build() assertThat(unitConfig.unitAmount()).isEqualTo("unit_amount") + assertThat(unitConfig.prorated()).isEqualTo(true) } @Test fun roundtrip() { val jsonMapper = jsonMapper() - val unitConfig = UnitConfig.builder().unitAmount("unit_amount").build() + val unitConfig = UnitConfig.builder().unitAmount("unit_amount").prorated(true).build() val roundtrippedUnitConfig = jsonMapper.readValue( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/BetaServiceAsyncTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/BetaServiceAsyncTest.kt index 3d268cc3d..e123b7fe9 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/BetaServiceAsyncTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/BetaServiceAsyncTest.kt @@ -97,7 +97,10 @@ internal class BetaServiceAsyncTest { .modelType(NewPlanUnitPrice.ModelType.UNIT) .name("Annual fee") .unitConfig( - UnitConfig.builder().unitAmount("unit_amount").build() + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() ) .billableMetricId("billable_metric_id") .billedInAdvance(true) @@ -221,7 +224,10 @@ internal class BetaServiceAsyncTest { .modelType(NewPlanUnitPrice.ModelType.UNIT) .name("Annual fee") .unitConfig( - UnitConfig.builder().unitAmount("unit_amount").build() + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() ) .billableMetricId("billable_metric_id") .billedInAdvance(true) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/InvoiceServiceAsyncTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/InvoiceServiceAsyncTest.kt index 76b24447f..d6737cdcf 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/InvoiceServiceAsyncTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/InvoiceServiceAsyncTest.kt @@ -42,7 +42,12 @@ internal class InvoiceServiceAsyncTest { .name("Line Item Name") .quantity(1.0) .startDate(LocalDate.parse("2023-09-22")) - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() + ) .build() ) .customerId("4khy3nwzktxv7") diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/PlanServiceAsyncTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/PlanServiceAsyncTest.kt index 988695a6e..b857734dd 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/PlanServiceAsyncTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/PlanServiceAsyncTest.kt @@ -66,7 +66,10 @@ internal class PlanServiceAsyncTest { .modelType(NewPlanUnitPrice.ModelType.UNIT) .name("Annual fee") .unitConfig( - UnitConfig.builder().unitAmount("unit_amount").build() + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() ) .billableMetricId("billable_metric_id") .billedInAdvance(true) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/PriceServiceAsyncTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/PriceServiceAsyncTest.kt index 5fa67c856..a0a6e8614 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/PriceServiceAsyncTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/PriceServiceAsyncTest.kt @@ -41,7 +41,12 @@ internal class PriceServiceAsyncTest { .itemId("item_id") .modelType(NewFloatingUnitPrice.ModelType.UNIT) .name("Annual fee") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() + ) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( @@ -179,7 +184,10 @@ internal class PriceServiceAsyncTest { .modelType(NewFloatingUnitPrice.ModelType.UNIT) .name("Annual fee") .unitConfig( - UnitConfig.builder().unitAmount("unit_amount").build() + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() ) .billableMetricId("billable_metric_id") .billedInAdvance(true) @@ -277,7 +285,10 @@ internal class PriceServiceAsyncTest { .modelType(NewFloatingUnitPrice.ModelType.UNIT) .name("Annual fee") .unitConfig( - UnitConfig.builder().unitAmount("unit_amount").build() + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() ) .billableMetricId("billable_metric_id") .billedInAdvance(true) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/SubscriptionServiceAsyncTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/SubscriptionServiceAsyncTest.kt index 7255e063d..7c2cf5a38 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/SubscriptionServiceAsyncTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/SubscriptionServiceAsyncTest.kt @@ -124,7 +124,10 @@ internal class SubscriptionServiceAsyncTest { .modelType(NewSubscriptionUnitPrice.ModelType.UNIT) .name("Annual fee") .unitConfig( - UnitConfig.builder().unitAmount("unit_amount").build() + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() ) .billableMetricId("billable_metric_id") .billedInAdvance(true) @@ -289,7 +292,10 @@ internal class SubscriptionServiceAsyncTest { .modelType(NewSubscriptionUnitPrice.ModelType.UNIT) .name("Annual fee") .unitConfig( - UnitConfig.builder().unitAmount("unit_amount").build() + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() ) .billableMetricId("billable_metric_id") .billedInAdvance(true) @@ -552,7 +558,10 @@ internal class SubscriptionServiceAsyncTest { .modelType(NewFloatingUnitPrice.ModelType.UNIT) .name("Annual fee") .unitConfig( - UnitConfig.builder().unitAmount("unit_amount").build() + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() ) .billableMetricId("billable_metric_id") .billedInAdvance(true) @@ -634,10 +643,12 @@ internal class SubscriptionServiceAsyncTest { .build() ) .allowInvoiceCreditOrVoid(true) + .canDeferBilling(true) .addEdit( SubscriptionPriceIntervalsParams.Edit.builder() .priceIntervalId("sdfs6wdjvn7ujokd") .billingCycleDay(0L) + .canDeferBilling(true) .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .filter("my_property > 100 AND my_other_property = 'bar'") .addFixedFeeQuantityTransition( @@ -777,7 +788,10 @@ internal class SubscriptionServiceAsyncTest { .modelType(NewSubscriptionUnitPrice.ModelType.UNIT) .name("Annual fee") .unitConfig( - UnitConfig.builder().unitAmount("unit_amount").build() + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() ) .billableMetricId("billable_metric_id") .billedInAdvance(true) @@ -933,7 +947,10 @@ internal class SubscriptionServiceAsyncTest { .modelType(NewSubscriptionUnitPrice.ModelType.UNIT) .name("Annual fee") .unitConfig( - UnitConfig.builder().unitAmount("unit_amount").build() + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() ) .billableMetricId("billable_metric_id") .billedInAdvance(true) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/beta/ExternalPlanIdServiceAsyncTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/beta/ExternalPlanIdServiceAsyncTest.kt index 1a4adb3d5..6379d8c84 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/beta/ExternalPlanIdServiceAsyncTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/beta/ExternalPlanIdServiceAsyncTest.kt @@ -97,7 +97,10 @@ internal class ExternalPlanIdServiceAsyncTest { .modelType(NewPlanUnitPrice.ModelType.UNIT) .name("Annual fee") .unitConfig( - UnitConfig.builder().unitAmount("unit_amount").build() + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() ) .billableMetricId("billable_metric_id") .billedInAdvance(true) @@ -221,7 +224,10 @@ internal class ExternalPlanIdServiceAsyncTest { .modelType(NewPlanUnitPrice.ModelType.UNIT) .name("Annual fee") .unitConfig( - UnitConfig.builder().unitAmount("unit_amount").build() + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() ) .billableMetricId("billable_metric_id") .billedInAdvance(true) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/BetaServiceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/BetaServiceTest.kt index 10e306996..ed4936928 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/BetaServiceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/BetaServiceTest.kt @@ -97,7 +97,10 @@ internal class BetaServiceTest { .modelType(NewPlanUnitPrice.ModelType.UNIT) .name("Annual fee") .unitConfig( - UnitConfig.builder().unitAmount("unit_amount").build() + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() ) .billableMetricId("billable_metric_id") .billedInAdvance(true) @@ -221,7 +224,10 @@ internal class BetaServiceTest { .modelType(NewPlanUnitPrice.ModelType.UNIT) .name("Annual fee") .unitConfig( - UnitConfig.builder().unitAmount("unit_amount").build() + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() ) .billableMetricId("billable_metric_id") .billedInAdvance(true) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/InvoiceServiceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/InvoiceServiceTest.kt index 2bd5cc219..e7277f0a1 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/InvoiceServiceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/InvoiceServiceTest.kt @@ -42,7 +42,12 @@ internal class InvoiceServiceTest { .name("Line Item Name") .quantity(1.0) .startDate(LocalDate.parse("2023-09-22")) - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() + ) .build() ) .customerId("4khy3nwzktxv7") diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/PlanServiceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/PlanServiceTest.kt index 288061184..52aa27660 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/PlanServiceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/PlanServiceTest.kt @@ -66,7 +66,10 @@ internal class PlanServiceTest { .modelType(NewPlanUnitPrice.ModelType.UNIT) .name("Annual fee") .unitConfig( - UnitConfig.builder().unitAmount("unit_amount").build() + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() ) .billableMetricId("billable_metric_id") .billedInAdvance(true) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/PriceServiceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/PriceServiceTest.kt index e11ed1229..de3c5a9ae 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/PriceServiceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/PriceServiceTest.kt @@ -41,7 +41,12 @@ internal class PriceServiceTest { .itemId("item_id") .modelType(NewFloatingUnitPrice.ModelType.UNIT) .name("Annual fee") - .unitConfig(UnitConfig.builder().unitAmount("unit_amount").build()) + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() + ) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( @@ -179,7 +184,10 @@ internal class PriceServiceTest { .modelType(NewFloatingUnitPrice.ModelType.UNIT) .name("Annual fee") .unitConfig( - UnitConfig.builder().unitAmount("unit_amount").build() + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() ) .billableMetricId("billable_metric_id") .billedInAdvance(true) @@ -277,7 +285,10 @@ internal class PriceServiceTest { .modelType(NewFloatingUnitPrice.ModelType.UNIT) .name("Annual fee") .unitConfig( - UnitConfig.builder().unitAmount("unit_amount").build() + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() ) .billableMetricId("billable_metric_id") .billedInAdvance(true) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/SubscriptionServiceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/SubscriptionServiceTest.kt index f966f7aef..e6d49a28f 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/SubscriptionServiceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/SubscriptionServiceTest.kt @@ -124,7 +124,10 @@ internal class SubscriptionServiceTest { .modelType(NewSubscriptionUnitPrice.ModelType.UNIT) .name("Annual fee") .unitConfig( - UnitConfig.builder().unitAmount("unit_amount").build() + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() ) .billableMetricId("billable_metric_id") .billedInAdvance(true) @@ -289,7 +292,10 @@ internal class SubscriptionServiceTest { .modelType(NewSubscriptionUnitPrice.ModelType.UNIT) .name("Annual fee") .unitConfig( - UnitConfig.builder().unitAmount("unit_amount").build() + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() ) .billableMetricId("billable_metric_id") .billedInAdvance(true) @@ -552,7 +558,10 @@ internal class SubscriptionServiceTest { .modelType(NewFloatingUnitPrice.ModelType.UNIT) .name("Annual fee") .unitConfig( - UnitConfig.builder().unitAmount("unit_amount").build() + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() ) .billableMetricId("billable_metric_id") .billedInAdvance(true) @@ -634,10 +643,12 @@ internal class SubscriptionServiceTest { .build() ) .allowInvoiceCreditOrVoid(true) + .canDeferBilling(true) .addEdit( SubscriptionPriceIntervalsParams.Edit.builder() .priceIntervalId("sdfs6wdjvn7ujokd") .billingCycleDay(0L) + .canDeferBilling(true) .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .filter("my_property > 100 AND my_other_property = 'bar'") .addFixedFeeQuantityTransition( @@ -777,7 +788,10 @@ internal class SubscriptionServiceTest { .modelType(NewSubscriptionUnitPrice.ModelType.UNIT) .name("Annual fee") .unitConfig( - UnitConfig.builder().unitAmount("unit_amount").build() + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() ) .billableMetricId("billable_metric_id") .billedInAdvance(true) @@ -933,7 +947,10 @@ internal class SubscriptionServiceTest { .modelType(NewSubscriptionUnitPrice.ModelType.UNIT) .name("Annual fee") .unitConfig( - UnitConfig.builder().unitAmount("unit_amount").build() + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() ) .billableMetricId("billable_metric_id") .billedInAdvance(true) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/beta/ExternalPlanIdServiceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/beta/ExternalPlanIdServiceTest.kt index f34269f51..65722e624 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/beta/ExternalPlanIdServiceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/beta/ExternalPlanIdServiceTest.kt @@ -97,7 +97,10 @@ internal class ExternalPlanIdServiceTest { .modelType(NewPlanUnitPrice.ModelType.UNIT) .name("Annual fee") .unitConfig( - UnitConfig.builder().unitAmount("unit_amount").build() + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() ) .billableMetricId("billable_metric_id") .billedInAdvance(true) @@ -221,7 +224,10 @@ internal class ExternalPlanIdServiceTest { .modelType(NewPlanUnitPrice.ModelType.UNIT) .name("Annual fee") .unitConfig( - UnitConfig.builder().unitAmount("unit_amount").build() + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() ) .billableMetricId("billable_metric_id") .billedInAdvance(true) From 25c6f8c58010e5c2dd909f8161c8fee5465f2847 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 4 Dec 2025 16:41:22 +0000 Subject: [PATCH 45/68] fix(schema): Rename unit price type to avoid naming conflict --- .stats.yml | 4 +- .../models/ChangedSubscriptionResources.kt | 2 +- .../kotlin/com/withorb/api/models/Invoice.kt | 2 +- .../models/InvoiceFetchUpcomingResponse.kt | 2 +- .../models/InvoiceLineItemCreateResponse.kt | 2 +- .../com/withorb/api/models/PerPriceCost.kt | 2 +- .../kotlin/com/withorb/api/models/Plan.kt | 2 +- .../com/withorb/api/models/PlanVersion.kt | 2 +- .../kotlin/com/withorb/api/models/Price.kt | 96 ++++---- .../com/withorb/api/models/PriceInterval.kt | 2 +- .../api/models/PriceListPageResponse.kt | 2 +- .../withorb/api/models/AggregatedCostTest.kt | 54 +++-- .../ChangedSubscriptionResourcesTest.kt | 106 ++++---- ...ustomerCostListByExternalIdResponseTest.kt | 53 ++-- .../models/CustomerCostListResponseTest.kt | 53 ++-- ...dgerCreateEntryByExternalIdResponseTest.kt | 34 +-- ...omerCreditLedgerCreateEntryResponseTest.kt | 34 +-- ...tLedgerListByExternalIdPageResponseTest.kt | 54 +++-- ...reditLedgerListByExternalIdResponseTest.kt | 34 +-- ...ustomerCreditLedgerListPageResponseTest.kt | 54 +++-- .../CustomerCreditLedgerListResponseTest.kt | 34 +-- .../api/models/IncrementLedgerEntryTest.kt | 53 ++-- .../InvoiceFetchUpcomingResponseTest.kt | 54 +++-- .../InvoiceLineItemCreateResponseTest.kt | 48 ++-- .../api/models/InvoiceListPageResponseTest.kt | 53 ++-- .../com/withorb/api/models/InvoiceTest.kt | 54 +++-- .../api/models/MutatedSubscriptionTest.kt | 214 ++++++++-------- .../withorb/api/models/PerPriceCostTest.kt | 48 ++-- .../api/models/PlanListPageResponseTest.kt | 54 +++-- .../kotlin/com/withorb/api/models/PlanTest.kt | 48 ++-- .../com/withorb/api/models/PlanVersionTest.kt | 48 ++-- .../withorb/api/models/PriceIntervalTest.kt | 48 ++-- .../api/models/PriceListPageResponseTest.kt | 48 ++-- .../com/withorb/api/models/PriceTest.kt | 32 +-- .../SubscriptionChangeApplyResponseTest.kt | 228 ++++++++++-------- .../SubscriptionChangeCancelResponseTest.kt | 228 ++++++++++-------- .../SubscriptionChangeRetrieveResponseTest.kt | 228 ++++++++++-------- .../SubscriptionFetchCostsResponseTest.kt | 53 ++-- .../withorb/api/models/SubscriptionTest.kt | 108 +++++---- .../withorb/api/models/SubscriptionsTest.kt | 106 ++++---- 40 files changed, 1306 insertions(+), 1075 deletions(-) diff --git a/.stats.yml b/.stats.yml index 5d845f554..544834a4c 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 118 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-f2b97a2c3e41f618dc8955ed325092320ff2170a7d7a9a26a31dc235c969b657.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-56d9f85a45eb4dfc07c2994617e1c98554d6dd748245fa4deeb706fe959c14bb.yml openapi_spec_hash: 64548564dc8ce80ef3ad38fc8cb56b30 -config_hash: dd4343ce95871032ef6e0735a4ca038c +config_hash: e6db17547fe854b1c240407cf4c6dc9e diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/ChangedSubscriptionResources.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/ChangedSubscriptionResources.kt index d985b2be3..f0d36843c 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/ChangedSubscriptionResources.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/ChangedSubscriptionResources.kt @@ -5406,7 +5406,7 @@ private constructor( fun price(price: JsonField) = apply { this.price = price } /** Alias for calling [price] with `Price.ofUnit(unit)`. */ - fun price(unit: Price.Unit) = price(Price.ofUnit(unit)) + fun price(unit: Price.UnitPrice) = price(Price.ofUnit(unit)) /** Alias for calling [price] with `Price.ofTiered(tiered)`. */ fun price(tiered: Price.Tiered) = price(Price.ofTiered(tiered)) diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Invoice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Invoice.kt index 03c0901e9..326d69e14 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Invoice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Invoice.kt @@ -4900,7 +4900,7 @@ private constructor( fun price(price: JsonField) = apply { this.price = price } /** Alias for calling [price] with `Price.ofUnit(unit)`. */ - fun price(unit: Price.Unit) = price(Price.ofUnit(unit)) + fun price(unit: Price.UnitPrice) = price(Price.ofUnit(unit)) /** Alias for calling [price] with `Price.ofTiered(tiered)`. */ fun price(tiered: Price.Tiered) = price(Price.ofTiered(tiered)) diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceFetchUpcomingResponse.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceFetchUpcomingResponse.kt index 13b8f1aac..ef41c5d33 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceFetchUpcomingResponse.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceFetchUpcomingResponse.kt @@ -4894,7 +4894,7 @@ private constructor( fun price(price: JsonField) = apply { this.price = price } /** Alias for calling [price] with `Price.ofUnit(unit)`. */ - fun price(unit: Price.Unit) = price(Price.ofUnit(unit)) + fun price(unit: Price.UnitPrice) = price(Price.ofUnit(unit)) /** Alias for calling [price] with `Price.ofTiered(tiered)`. */ fun price(tiered: Price.Tiered) = price(Price.ofTiered(tiered)) diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceLineItemCreateResponse.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceLineItemCreateResponse.kt index a6e49d057..c8c24c15a 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceLineItemCreateResponse.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceLineItemCreateResponse.kt @@ -953,7 +953,7 @@ private constructor( fun price(price: JsonField) = apply { this.price = price } /** Alias for calling [price] with `Price.ofUnit(unit)`. */ - fun price(unit: Price.Unit) = price(Price.ofUnit(unit)) + fun price(unit: Price.UnitPrice) = price(Price.ofUnit(unit)) /** Alias for calling [price] with `Price.ofTiered(tiered)`. */ fun price(tiered: Price.Tiered) = price(Price.ofTiered(tiered)) diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PerPriceCost.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PerPriceCost.kt index 4cf1c59af..3b76ba194 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PerPriceCost.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PerPriceCost.kt @@ -169,7 +169,7 @@ private constructor( fun price(price: JsonField) = apply { this.price = price } /** Alias for calling [price] with `Price.ofUnit(unit)`. */ - fun price(unit: Price.Unit) = price(Price.ofUnit(unit)) + fun price(unit: Price.UnitPrice) = price(Price.ofUnit(unit)) /** Alias for calling [price] with `Price.ofTiered(tiered)`. */ fun price(tiered: Price.Tiered) = price(Price.ofTiered(tiered)) diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Plan.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Plan.kt index 4017d393f..bd3aae981 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Plan.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Plan.kt @@ -1044,7 +1044,7 @@ private constructor( } /** Alias for calling [addPrice] with `Price.ofUnit(unit)`. */ - fun addPrice(unit: Price.Unit) = addPrice(Price.ofUnit(unit)) + fun addPrice(unit: Price.UnitPrice) = addPrice(Price.ofUnit(unit)) /** Alias for calling [addPrice] with `Price.ofTiered(tiered)`. */ fun addPrice(tiered: Price.Tiered) = addPrice(Price.ofTiered(tiered)) diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanVersion.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanVersion.kt index 6a441361c..4959e4b7a 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanVersion.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanVersion.kt @@ -302,7 +302,7 @@ private constructor( } /** Alias for calling [addPrice] with `Price.ofUnit(unit)`. */ - fun addPrice(unit: Price.Unit) = addPrice(Price.ofUnit(unit)) + fun addPrice(unit: Price.UnitPrice) = addPrice(Price.ofUnit(unit)) /** Alias for calling [addPrice] with `Price.ofTiered(tiered)`. */ fun addPrice(tiered: Price.Tiered) = addPrice(Price.ofTiered(tiered)) diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Price.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Price.kt index 5c87d0849..d5f120e56 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Price.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Price.kt @@ -46,7 +46,7 @@ import kotlin.Unit as KUnit @JsonSerialize(using = Price.Serializer::class) class Price private constructor( - private val unit: Unit? = null, + private val unit: UnitPrice? = null, private val tiered: Tiered? = null, private val bulk: Bulk? = null, private val bulkWithFilters: BulkWithFilters? = null, @@ -79,7 +79,7 @@ private constructor( private val _json: JsonValue? = null, ) { - fun unit(): Unit? = unit + fun unit(): UnitPrice? = unit fun tiered(): Tiered? = tiered @@ -201,7 +201,7 @@ private constructor( fun isEventOutput(): Boolean = eventOutput != null - fun asUnit(): Unit = unit.getOrThrow("unit") + fun asUnit(): UnitPrice = unit.getOrThrow("unit") fun asTiered(): Tiered = tiered.getOrThrow("tiered") @@ -330,8 +330,8 @@ private constructor( } accept( - object : Visitor { - override fun visitUnit(unit: Unit) { + object : Visitor { + override fun visitUnit(unit: UnitPrice) { unit.validate() } @@ -491,7 +491,7 @@ private constructor( internal fun validity(): Int = accept( object : Visitor { - override fun visitUnit(unit: Unit) = unit.validity() + override fun visitUnit(unit: UnitPrice) = unit.validity() override fun visitTiered(tiered: Tiered) = tiered.validity() @@ -703,7 +703,7 @@ private constructor( companion object { - fun ofUnit(unit: Unit) = Price(unit = unit) + fun ofUnit(unit: UnitPrice) = Price(unit = unit) fun ofTiered(tiered: Tiered) = Price(tiered = tiered) @@ -790,7 +790,7 @@ private constructor( /** An interface that defines how to map each variant of [Price] to a value of type [T]. */ interface Visitor { - fun visitUnit(unit: Unit): T + fun visitUnit(unit: UnitPrice): T fun visitTiered(tiered: Tiered): T @@ -880,7 +880,7 @@ private constructor( when (modelType) { "unit" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { + return tryDeserialize(node, jacksonTypeRef())?.let { Price(unit = it, _json = json) } ?: Price(_json = json) } @@ -1093,7 +1093,7 @@ private constructor( } } - class Unit + class UnitPrice @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, @@ -1694,7 +1694,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [Unit]. + * Returns a mutable builder for constructing an instance of [UnitPrice]. * * The following fields are required: * ```kotlin @@ -1729,7 +1729,7 @@ private constructor( fun builder() = Builder() } - /** A builder for [Unit]. */ + /** A builder for [UnitPrice]. */ class Builder internal constructor() { private var id: JsonField? = null @@ -1763,36 +1763,36 @@ private constructor( JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(unit: Unit) = apply { - id = unit.id - billableMetric = unit.billableMetric - billingCycleConfiguration = unit.billingCycleConfiguration - billingMode = unit.billingMode - cadence = unit.cadence - compositePriceFilters = unit.compositePriceFilters.map { it.toMutableList() } - conversionRate = unit.conversionRate - conversionRateConfig = unit.conversionRateConfig - createdAt = unit.createdAt - creditAllocation = unit.creditAllocation - currency = unit.currency - discount = unit.discount - externalPriceId = unit.externalPriceId - fixedPriceQuantity = unit.fixedPriceQuantity - invoicingCycleConfiguration = unit.invoicingCycleConfiguration - item = unit.item - maximum = unit.maximum - maximumAmount = unit.maximumAmount - metadata = unit.metadata - minimum = unit.minimum - minimumAmount = unit.minimumAmount - modelType = unit.modelType - name = unit.name - planPhaseOrder = unit.planPhaseOrder - priceType = unit.priceType - replacesPriceId = unit.replacesPriceId - unitConfig = unit.unitConfig - dimensionalPriceConfiguration = unit.dimensionalPriceConfiguration - additionalProperties = unit.additionalProperties.toMutableMap() + internal fun from(unitPrice: UnitPrice) = apply { + id = unitPrice.id + billableMetric = unitPrice.billableMetric + billingCycleConfiguration = unitPrice.billingCycleConfiguration + billingMode = unitPrice.billingMode + cadence = unitPrice.cadence + compositePriceFilters = unitPrice.compositePriceFilters.map { it.toMutableList() } + conversionRate = unitPrice.conversionRate + conversionRateConfig = unitPrice.conversionRateConfig + createdAt = unitPrice.createdAt + creditAllocation = unitPrice.creditAllocation + currency = unitPrice.currency + discount = unitPrice.discount + externalPriceId = unitPrice.externalPriceId + fixedPriceQuantity = unitPrice.fixedPriceQuantity + invoicingCycleConfiguration = unitPrice.invoicingCycleConfiguration + item = unitPrice.item + maximum = unitPrice.maximum + maximumAmount = unitPrice.maximumAmount + metadata = unitPrice.metadata + minimum = unitPrice.minimum + minimumAmount = unitPrice.minimumAmount + modelType = unitPrice.modelType + name = unitPrice.name + planPhaseOrder = unitPrice.planPhaseOrder + priceType = unitPrice.priceType + replacesPriceId = unitPrice.replacesPriceId + unitConfig = unitPrice.unitConfig + dimensionalPriceConfiguration = unitPrice.dimensionalPriceConfiguration + additionalProperties = unitPrice.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) @@ -2355,7 +2355,7 @@ private constructor( } /** - * Returns an immutable instance of [Unit]. + * Returns an immutable instance of [UnitPrice]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -2391,8 +2391,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): Unit = - Unit( + fun build(): UnitPrice = + UnitPrice( checkRequired("id", id), checkRequired("billableMetric", billableMetric), checkRequired("billingCycleConfiguration", billingCycleConfiguration), @@ -2429,7 +2429,7 @@ private constructor( private var validated: Boolean = false - fun validate(): Unit = apply { + fun validate(): UnitPrice = apply { if (validated) { return@apply } @@ -3579,7 +3579,7 @@ private constructor( return true } - return other is Unit && + return other is UnitPrice && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && @@ -3648,7 +3648,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Unit{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, unitConfig=$unitConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "UnitPrice{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, unitConfig=$unitConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" } class Tiered diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceInterval.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceInterval.kt index da8d4959e..5bd083669 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceInterval.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceInterval.kt @@ -520,7 +520,7 @@ private constructor( fun price(price: JsonField) = apply { this.price = price } /** Alias for calling [price] with `Price.ofUnit(unit)`. */ - fun price(unit: Price.Unit) = price(Price.ofUnit(unit)) + fun price(unit: Price.UnitPrice) = price(Price.ofUnit(unit)) /** Alias for calling [price] with `Price.ofTiered(tiered)`. */ fun price(tiered: Price.Tiered) = price(Price.ofTiered(tiered)) diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceListPageResponse.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceListPageResponse.kt index fb46b3a20..f85e61110 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceListPageResponse.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceListPageResponse.kt @@ -128,7 +128,7 @@ private constructor( } /** Alias for calling [addData] with `Price.ofUnit(unit)`. */ - fun addData(unit: Price.Unit) = addData(Price.ofUnit(unit)) + fun addData(unit: Price.UnitPrice) = addData(Price.ofUnit(unit)) /** Alias for calling [addData] with `Price.ofTiered(tiered)`. */ fun addData(tiered: Price.Tiered) = addData(Price.ofTiered(tiered)) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/AggregatedCostTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/AggregatedCostTest.kt index 2ade8104e..49e22110c 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/AggregatedCostTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/AggregatedCostTest.kt @@ -18,7 +18,7 @@ internal class AggregatedCostTest { .addPerPriceCost( PerPriceCost.builder() .price( - Price.Unit.builder() + Price.UnitPrice.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -27,12 +27,14 @@ internal class AggregatedCostTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .billingMode(Price.Unit.BillingMode.IN_ADVANCE) - .cadence(Price.Unit.Cadence.ONE_TIME) + .billingMode(Price.UnitPrice.BillingMode.IN_ADVANCE) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) .addCompositePriceFilter( - Price.Unit.CompositePriceFilter.builder() - .field(Price.Unit.CompositePriceFilter.Field.PRICE_ID) - .operator(Price.Unit.CompositePriceFilter.Operator.INCLUDES) + Price.UnitPrice.CompositePriceFilter.builder() + .field(Price.UnitPrice.CompositePriceFilter.Field.PRICE_ID) + .operator( + Price.UnitPrice.CompositePriceFilter.Operator.INCLUDES + ) .addValue("string") .build() ) @@ -105,7 +107,7 @@ internal class AggregatedCostTest { ) .maximumAmount("maximum_amount") .metadata( - Price.Unit.Metadata.builder() + Price.UnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -125,7 +127,7 @@ internal class AggregatedCostTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.Unit.PriceType.USAGE_PRICE) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( UnitConfig.builder() @@ -157,7 +159,7 @@ internal class AggregatedCostTest { .containsExactly( PerPriceCost.builder() .price( - Price.Unit.builder() + Price.UnitPrice.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -166,12 +168,14 @@ internal class AggregatedCostTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .billingMode(Price.Unit.BillingMode.IN_ADVANCE) - .cadence(Price.Unit.Cadence.ONE_TIME) + .billingMode(Price.UnitPrice.BillingMode.IN_ADVANCE) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) .addCompositePriceFilter( - Price.Unit.CompositePriceFilter.builder() - .field(Price.Unit.CompositePriceFilter.Field.PRICE_ID) - .operator(Price.Unit.CompositePriceFilter.Operator.INCLUDES) + Price.UnitPrice.CompositePriceFilter.builder() + .field(Price.UnitPrice.CompositePriceFilter.Field.PRICE_ID) + .operator( + Price.UnitPrice.CompositePriceFilter.Operator.INCLUDES + ) .addValue("string") .build() ) @@ -240,7 +244,7 @@ internal class AggregatedCostTest { ) .maximumAmount("maximum_amount") .metadata( - Price.Unit.Metadata.builder() + Price.UnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -260,7 +264,7 @@ internal class AggregatedCostTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.Unit.PriceType.USAGE_PRICE) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( UnitConfig.builder() @@ -298,7 +302,7 @@ internal class AggregatedCostTest { .addPerPriceCost( PerPriceCost.builder() .price( - Price.Unit.builder() + Price.UnitPrice.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -307,12 +311,14 @@ internal class AggregatedCostTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .billingMode(Price.Unit.BillingMode.IN_ADVANCE) - .cadence(Price.Unit.Cadence.ONE_TIME) + .billingMode(Price.UnitPrice.BillingMode.IN_ADVANCE) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) .addCompositePriceFilter( - Price.Unit.CompositePriceFilter.builder() - .field(Price.Unit.CompositePriceFilter.Field.PRICE_ID) - .operator(Price.Unit.CompositePriceFilter.Operator.INCLUDES) + Price.UnitPrice.CompositePriceFilter.builder() + .field(Price.UnitPrice.CompositePriceFilter.Field.PRICE_ID) + .operator( + Price.UnitPrice.CompositePriceFilter.Operator.INCLUDES + ) .addValue("string") .build() ) @@ -385,7 +391,7 @@ internal class AggregatedCostTest { ) .maximumAmount("maximum_amount") .metadata( - Price.Unit.Metadata.builder() + Price.UnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -405,7 +411,7 @@ internal class AggregatedCostTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.Unit.PriceType.USAGE_PRICE) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( UnitConfig.builder() diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/ChangedSubscriptionResourcesTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/ChangedSubscriptionResourcesTest.kt index 8007460df..73aef23e1 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/ChangedSubscriptionResourcesTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/ChangedSubscriptionResourcesTest.kt @@ -293,7 +293,7 @@ internal class ChangedSubscriptionResourcesTest { .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( - Price.Unit.builder() + Price.UnitPrice.builder() .id("id") .billableMetric( BillableMetricTiny.builder().id("id").build() @@ -306,15 +306,16 @@ internal class ChangedSubscriptionResourcesTest { ) .build() ) - .billingMode(Price.Unit.BillingMode.IN_ADVANCE) - .cadence(Price.Unit.Cadence.ONE_TIME) + .billingMode(Price.UnitPrice.BillingMode.IN_ADVANCE) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) .addCompositePriceFilter( - Price.Unit.CompositePriceFilter.builder() + Price.UnitPrice.CompositePriceFilter.builder() .field( - Price.Unit.CompositePriceFilter.Field.PRICE_ID + Price.UnitPrice.CompositePriceFilter.Field + .PRICE_ID ) .operator( - Price.Unit.CompositePriceFilter.Operator + Price.UnitPrice.CompositePriceFilter.Operator .INCLUDES ) .addValue("string") @@ -400,7 +401,7 @@ internal class ChangedSubscriptionResourcesTest { ) .maximumAmount("maximum_amount") .metadata( - Price.Unit.Metadata.builder() + Price.UnitPrice.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -423,7 +424,7 @@ internal class ChangedSubscriptionResourcesTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.Unit.PriceType.USAGE_PRICE) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( UnitConfig.builder() @@ -814,7 +815,7 @@ internal class ChangedSubscriptionResourcesTest { .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( - Price.Unit.builder() + Price.UnitPrice.builder() .id("id") .billableMetric( BillableMetricTiny.builder().id("id").build() @@ -827,15 +828,16 @@ internal class ChangedSubscriptionResourcesTest { ) .build() ) - .billingMode(Price.Unit.BillingMode.IN_ADVANCE) - .cadence(Price.Unit.Cadence.ONE_TIME) + .billingMode(Price.UnitPrice.BillingMode.IN_ADVANCE) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) .addCompositePriceFilter( - Price.Unit.CompositePriceFilter.builder() + Price.UnitPrice.CompositePriceFilter.builder() .field( - Price.Unit.CompositePriceFilter.Field.PRICE_ID + Price.UnitPrice.CompositePriceFilter.Field + .PRICE_ID ) .operator( - Price.Unit.CompositePriceFilter.Operator + Price.UnitPrice.CompositePriceFilter.Operator .INCLUDES ) .addValue("string") @@ -921,7 +923,7 @@ internal class ChangedSubscriptionResourcesTest { ) .maximumAmount("maximum_amount") .metadata( - Price.Unit.Metadata.builder() + Price.UnitPrice.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -944,7 +946,7 @@ internal class ChangedSubscriptionResourcesTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.Unit.PriceType.USAGE_PRICE) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( UnitConfig.builder() @@ -1341,7 +1343,7 @@ internal class ChangedSubscriptionResourcesTest { .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( - Price.Unit.builder() + Price.UnitPrice.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -1352,13 +1354,16 @@ internal class ChangedSubscriptionResourcesTest { ) .build() ) - .billingMode(Price.Unit.BillingMode.IN_ADVANCE) - .cadence(Price.Unit.Cadence.ONE_TIME) + .billingMode(Price.UnitPrice.BillingMode.IN_ADVANCE) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) .addCompositePriceFilter( - Price.Unit.CompositePriceFilter.builder() - .field(Price.Unit.CompositePriceFilter.Field.PRICE_ID) + Price.UnitPrice.CompositePriceFilter.builder() + .field( + Price.UnitPrice.CompositePriceFilter.Field.PRICE_ID + ) .operator( - Price.Unit.CompositePriceFilter.Operator.INCLUDES + Price.UnitPrice.CompositePriceFilter.Operator + .INCLUDES ) .addValue("string") .build() @@ -1436,7 +1441,7 @@ internal class ChangedSubscriptionResourcesTest { ) .maximumAmount("maximum_amount") .metadata( - Price.Unit.Metadata.builder() + Price.UnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -1456,7 +1461,7 @@ internal class ChangedSubscriptionResourcesTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.Unit.PriceType.USAGE_PRICE) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( UnitConfig.builder() @@ -1839,7 +1844,7 @@ internal class ChangedSubscriptionResourcesTest { .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( - Price.Unit.builder() + Price.UnitPrice.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -1850,13 +1855,16 @@ internal class ChangedSubscriptionResourcesTest { ) .build() ) - .billingMode(Price.Unit.BillingMode.IN_ADVANCE) - .cadence(Price.Unit.Cadence.ONE_TIME) + .billingMode(Price.UnitPrice.BillingMode.IN_ADVANCE) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) .addCompositePriceFilter( - Price.Unit.CompositePriceFilter.builder() - .field(Price.Unit.CompositePriceFilter.Field.PRICE_ID) + Price.UnitPrice.CompositePriceFilter.builder() + .field( + Price.UnitPrice.CompositePriceFilter.Field.PRICE_ID + ) .operator( - Price.Unit.CompositePriceFilter.Operator.INCLUDES + Price.UnitPrice.CompositePriceFilter.Operator + .INCLUDES ) .addValue("string") .build() @@ -1934,7 +1942,7 @@ internal class ChangedSubscriptionResourcesTest { ) .maximumAmount("maximum_amount") .metadata( - Price.Unit.Metadata.builder() + Price.UnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -1954,7 +1962,7 @@ internal class ChangedSubscriptionResourcesTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.Unit.PriceType.USAGE_PRICE) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( UnitConfig.builder() @@ -2358,7 +2366,7 @@ internal class ChangedSubscriptionResourcesTest { .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( - Price.Unit.builder() + Price.UnitPrice.builder() .id("id") .billableMetric( BillableMetricTiny.builder().id("id").build() @@ -2371,15 +2379,16 @@ internal class ChangedSubscriptionResourcesTest { ) .build() ) - .billingMode(Price.Unit.BillingMode.IN_ADVANCE) - .cadence(Price.Unit.Cadence.ONE_TIME) + .billingMode(Price.UnitPrice.BillingMode.IN_ADVANCE) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) .addCompositePriceFilter( - Price.Unit.CompositePriceFilter.builder() + Price.UnitPrice.CompositePriceFilter.builder() .field( - Price.Unit.CompositePriceFilter.Field.PRICE_ID + Price.UnitPrice.CompositePriceFilter.Field + .PRICE_ID ) .operator( - Price.Unit.CompositePriceFilter.Operator + Price.UnitPrice.CompositePriceFilter.Operator .INCLUDES ) .addValue("string") @@ -2465,7 +2474,7 @@ internal class ChangedSubscriptionResourcesTest { ) .maximumAmount("maximum_amount") .metadata( - Price.Unit.Metadata.builder() + Price.UnitPrice.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -2488,7 +2497,7 @@ internal class ChangedSubscriptionResourcesTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.Unit.PriceType.USAGE_PRICE) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( UnitConfig.builder() @@ -2879,7 +2888,7 @@ internal class ChangedSubscriptionResourcesTest { .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( - Price.Unit.builder() + Price.UnitPrice.builder() .id("id") .billableMetric( BillableMetricTiny.builder().id("id").build() @@ -2892,15 +2901,16 @@ internal class ChangedSubscriptionResourcesTest { ) .build() ) - .billingMode(Price.Unit.BillingMode.IN_ADVANCE) - .cadence(Price.Unit.Cadence.ONE_TIME) + .billingMode(Price.UnitPrice.BillingMode.IN_ADVANCE) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) .addCompositePriceFilter( - Price.Unit.CompositePriceFilter.builder() + Price.UnitPrice.CompositePriceFilter.builder() .field( - Price.Unit.CompositePriceFilter.Field.PRICE_ID + Price.UnitPrice.CompositePriceFilter.Field + .PRICE_ID ) .operator( - Price.Unit.CompositePriceFilter.Operator + Price.UnitPrice.CompositePriceFilter.Operator .INCLUDES ) .addValue("string") @@ -2986,7 +2996,7 @@ internal class ChangedSubscriptionResourcesTest { ) .maximumAmount("maximum_amount") .metadata( - Price.Unit.Metadata.builder() + Price.UnitPrice.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -3009,7 +3019,7 @@ internal class ChangedSubscriptionResourcesTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.Unit.PriceType.USAGE_PRICE) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( UnitConfig.builder() diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCostListByExternalIdResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCostListByExternalIdResponseTest.kt index 3dec1a32b..390cc855b 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCostListByExternalIdResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCostListByExternalIdResponseTest.kt @@ -20,7 +20,7 @@ internal class CustomerCostListByExternalIdResponseTest { .addPerPriceCost( PerPriceCost.builder() .price( - Price.Unit.builder() + Price.UnitPrice.builder() .id("id") .billableMetric( BillableMetricTiny.builder().id("id").build() @@ -33,15 +33,16 @@ internal class CustomerCostListByExternalIdResponseTest { ) .build() ) - .billingMode(Price.Unit.BillingMode.IN_ADVANCE) - .cadence(Price.Unit.Cadence.ONE_TIME) + .billingMode(Price.UnitPrice.BillingMode.IN_ADVANCE) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) .addCompositePriceFilter( - Price.Unit.CompositePriceFilter.builder() + Price.UnitPrice.CompositePriceFilter.builder() .field( - Price.Unit.CompositePriceFilter.Field.PRICE_ID + Price.UnitPrice.CompositePriceFilter.Field + .PRICE_ID ) .operator( - Price.Unit.CompositePriceFilter.Operator + Price.UnitPrice.CompositePriceFilter.Operator .INCLUDES ) .addValue("string") @@ -127,7 +128,7 @@ internal class CustomerCostListByExternalIdResponseTest { ) .maximumAmount("maximum_amount") .metadata( - Price.Unit.Metadata.builder() + Price.UnitPrice.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -150,7 +151,7 @@ internal class CustomerCostListByExternalIdResponseTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.Unit.PriceType.USAGE_PRICE) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( UnitConfig.builder() @@ -188,7 +189,7 @@ internal class CustomerCostListByExternalIdResponseTest { .addPerPriceCost( PerPriceCost.builder() .price( - Price.Unit.builder() + Price.UnitPrice.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -199,13 +200,16 @@ internal class CustomerCostListByExternalIdResponseTest { ) .build() ) - .billingMode(Price.Unit.BillingMode.IN_ADVANCE) - .cadence(Price.Unit.Cadence.ONE_TIME) + .billingMode(Price.UnitPrice.BillingMode.IN_ADVANCE) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) .addCompositePriceFilter( - Price.Unit.CompositePriceFilter.builder() - .field(Price.Unit.CompositePriceFilter.Field.PRICE_ID) + Price.UnitPrice.CompositePriceFilter.builder() + .field( + Price.UnitPrice.CompositePriceFilter.Field.PRICE_ID + ) .operator( - Price.Unit.CompositePriceFilter.Operator.INCLUDES + Price.UnitPrice.CompositePriceFilter.Operator + .INCLUDES ) .addValue("string") .build() @@ -283,7 +287,7 @@ internal class CustomerCostListByExternalIdResponseTest { ) .maximumAmount("maximum_amount") .metadata( - Price.Unit.Metadata.builder() + Price.UnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -303,7 +307,7 @@ internal class CustomerCostListByExternalIdResponseTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.Unit.PriceType.USAGE_PRICE) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( UnitConfig.builder() @@ -343,7 +347,7 @@ internal class CustomerCostListByExternalIdResponseTest { .addPerPriceCost( PerPriceCost.builder() .price( - Price.Unit.builder() + Price.UnitPrice.builder() .id("id") .billableMetric( BillableMetricTiny.builder().id("id").build() @@ -356,15 +360,16 @@ internal class CustomerCostListByExternalIdResponseTest { ) .build() ) - .billingMode(Price.Unit.BillingMode.IN_ADVANCE) - .cadence(Price.Unit.Cadence.ONE_TIME) + .billingMode(Price.UnitPrice.BillingMode.IN_ADVANCE) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) .addCompositePriceFilter( - Price.Unit.CompositePriceFilter.builder() + Price.UnitPrice.CompositePriceFilter.builder() .field( - Price.Unit.CompositePriceFilter.Field.PRICE_ID + Price.UnitPrice.CompositePriceFilter.Field + .PRICE_ID ) .operator( - Price.Unit.CompositePriceFilter.Operator + Price.UnitPrice.CompositePriceFilter.Operator .INCLUDES ) .addValue("string") @@ -450,7 +455,7 @@ internal class CustomerCostListByExternalIdResponseTest { ) .maximumAmount("maximum_amount") .metadata( - Price.Unit.Metadata.builder() + Price.UnitPrice.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -473,7 +478,7 @@ internal class CustomerCostListByExternalIdResponseTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.Unit.PriceType.USAGE_PRICE) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( UnitConfig.builder() diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCostListResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCostListResponseTest.kt index 2d1b3196a..c27926b62 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCostListResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCostListResponseTest.kt @@ -20,7 +20,7 @@ internal class CustomerCostListResponseTest { .addPerPriceCost( PerPriceCost.builder() .price( - Price.Unit.builder() + Price.UnitPrice.builder() .id("id") .billableMetric( BillableMetricTiny.builder().id("id").build() @@ -33,15 +33,16 @@ internal class CustomerCostListResponseTest { ) .build() ) - .billingMode(Price.Unit.BillingMode.IN_ADVANCE) - .cadence(Price.Unit.Cadence.ONE_TIME) + .billingMode(Price.UnitPrice.BillingMode.IN_ADVANCE) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) .addCompositePriceFilter( - Price.Unit.CompositePriceFilter.builder() + Price.UnitPrice.CompositePriceFilter.builder() .field( - Price.Unit.CompositePriceFilter.Field.PRICE_ID + Price.UnitPrice.CompositePriceFilter.Field + .PRICE_ID ) .operator( - Price.Unit.CompositePriceFilter.Operator + Price.UnitPrice.CompositePriceFilter.Operator .INCLUDES ) .addValue("string") @@ -127,7 +128,7 @@ internal class CustomerCostListResponseTest { ) .maximumAmount("maximum_amount") .metadata( - Price.Unit.Metadata.builder() + Price.UnitPrice.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -150,7 +151,7 @@ internal class CustomerCostListResponseTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.Unit.PriceType.USAGE_PRICE) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( UnitConfig.builder() @@ -188,7 +189,7 @@ internal class CustomerCostListResponseTest { .addPerPriceCost( PerPriceCost.builder() .price( - Price.Unit.builder() + Price.UnitPrice.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -199,13 +200,16 @@ internal class CustomerCostListResponseTest { ) .build() ) - .billingMode(Price.Unit.BillingMode.IN_ADVANCE) - .cadence(Price.Unit.Cadence.ONE_TIME) + .billingMode(Price.UnitPrice.BillingMode.IN_ADVANCE) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) .addCompositePriceFilter( - Price.Unit.CompositePriceFilter.builder() - .field(Price.Unit.CompositePriceFilter.Field.PRICE_ID) + Price.UnitPrice.CompositePriceFilter.builder() + .field( + Price.UnitPrice.CompositePriceFilter.Field.PRICE_ID + ) .operator( - Price.Unit.CompositePriceFilter.Operator.INCLUDES + Price.UnitPrice.CompositePriceFilter.Operator + .INCLUDES ) .addValue("string") .build() @@ -283,7 +287,7 @@ internal class CustomerCostListResponseTest { ) .maximumAmount("maximum_amount") .metadata( - Price.Unit.Metadata.builder() + Price.UnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -303,7 +307,7 @@ internal class CustomerCostListResponseTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.Unit.PriceType.USAGE_PRICE) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( UnitConfig.builder() @@ -343,7 +347,7 @@ internal class CustomerCostListResponseTest { .addPerPriceCost( PerPriceCost.builder() .price( - Price.Unit.builder() + Price.UnitPrice.builder() .id("id") .billableMetric( BillableMetricTiny.builder().id("id").build() @@ -356,15 +360,16 @@ internal class CustomerCostListResponseTest { ) .build() ) - .billingMode(Price.Unit.BillingMode.IN_ADVANCE) - .cadence(Price.Unit.Cadence.ONE_TIME) + .billingMode(Price.UnitPrice.BillingMode.IN_ADVANCE) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) .addCompositePriceFilter( - Price.Unit.CompositePriceFilter.builder() + Price.UnitPrice.CompositePriceFilter.builder() .field( - Price.Unit.CompositePriceFilter.Field.PRICE_ID + Price.UnitPrice.CompositePriceFilter.Field + .PRICE_ID ) .operator( - Price.Unit.CompositePriceFilter.Operator + Price.UnitPrice.CompositePriceFilter.Operator .INCLUDES ) .addValue("string") @@ -450,7 +455,7 @@ internal class CustomerCostListResponseTest { ) .maximumAmount("maximum_amount") .metadata( - Price.Unit.Metadata.builder() + Price.UnitPrice.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -473,7 +478,7 @@ internal class CustomerCostListResponseTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.Unit.PriceType.USAGE_PRICE) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( UnitConfig.builder() diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdResponseTest.kt index 6126c3b36..1a2eabf87 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdResponseTest.kt @@ -234,7 +234,7 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdResponseTest { .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( - Price.Unit.builder() + Price.UnitPrice.builder() .id("id") .billableMetric( BillableMetricTiny.builder().id("id").build() @@ -247,15 +247,16 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdResponseTest { ) .build() ) - .billingMode(Price.Unit.BillingMode.IN_ADVANCE) - .cadence(Price.Unit.Cadence.ONE_TIME) + .billingMode(Price.UnitPrice.BillingMode.IN_ADVANCE) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) .addCompositePriceFilter( - Price.Unit.CompositePriceFilter.builder() + Price.UnitPrice.CompositePriceFilter.builder() .field( - Price.Unit.CompositePriceFilter.Field.PRICE_ID + Price.UnitPrice.CompositePriceFilter.Field + .PRICE_ID ) .operator( - Price.Unit.CompositePriceFilter.Operator + Price.UnitPrice.CompositePriceFilter.Operator .INCLUDES ) .addValue("string") @@ -341,7 +342,7 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdResponseTest { ) .maximumAmount("maximum_amount") .metadata( - Price.Unit.Metadata.builder() + Price.UnitPrice.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -364,7 +365,7 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdResponseTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.Unit.PriceType.USAGE_PRICE) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( UnitConfig.builder() @@ -724,7 +725,7 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdResponseTest { .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( - Price.Unit.builder() + Price.UnitPrice.builder() .id("id") .billableMetric( BillableMetricTiny.builder().id("id").build() @@ -737,16 +738,17 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdResponseTest { ) .build() ) - .billingMode(Price.Unit.BillingMode.IN_ADVANCE) - .cadence(Price.Unit.Cadence.ONE_TIME) + .billingMode(Price.UnitPrice.BillingMode.IN_ADVANCE) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) .addCompositePriceFilter( - Price.Unit.CompositePriceFilter.builder() + Price.UnitPrice.CompositePriceFilter.builder() .field( - Price.Unit.CompositePriceFilter.Field + Price.UnitPrice.CompositePriceFilter.Field .PRICE_ID ) .operator( - Price.Unit.CompositePriceFilter.Operator + Price.UnitPrice.CompositePriceFilter + .Operator .INCLUDES ) .addValue("string") @@ -837,7 +839,7 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdResponseTest { ) .maximumAmount("maximum_amount") .metadata( - Price.Unit.Metadata.builder() + Price.UnitPrice.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -862,7 +864,7 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdResponseTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.Unit.PriceType.USAGE_PRICE) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( UnitConfig.builder() diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryResponseTest.kt index 23efbb9bc..5436b5219 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryResponseTest.kt @@ -234,7 +234,7 @@ internal class CustomerCreditLedgerCreateEntryResponseTest { .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( - Price.Unit.builder() + Price.UnitPrice.builder() .id("id") .billableMetric( BillableMetricTiny.builder().id("id").build() @@ -247,15 +247,16 @@ internal class CustomerCreditLedgerCreateEntryResponseTest { ) .build() ) - .billingMode(Price.Unit.BillingMode.IN_ADVANCE) - .cadence(Price.Unit.Cadence.ONE_TIME) + .billingMode(Price.UnitPrice.BillingMode.IN_ADVANCE) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) .addCompositePriceFilter( - Price.Unit.CompositePriceFilter.builder() + Price.UnitPrice.CompositePriceFilter.builder() .field( - Price.Unit.CompositePriceFilter.Field.PRICE_ID + Price.UnitPrice.CompositePriceFilter.Field + .PRICE_ID ) .operator( - Price.Unit.CompositePriceFilter.Operator + Price.UnitPrice.CompositePriceFilter.Operator .INCLUDES ) .addValue("string") @@ -341,7 +342,7 @@ internal class CustomerCreditLedgerCreateEntryResponseTest { ) .maximumAmount("maximum_amount") .metadata( - Price.Unit.Metadata.builder() + Price.UnitPrice.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -364,7 +365,7 @@ internal class CustomerCreditLedgerCreateEntryResponseTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.Unit.PriceType.USAGE_PRICE) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( UnitConfig.builder() @@ -723,7 +724,7 @@ internal class CustomerCreditLedgerCreateEntryResponseTest { .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( - Price.Unit.builder() + Price.UnitPrice.builder() .id("id") .billableMetric( BillableMetricTiny.builder().id("id").build() @@ -736,16 +737,17 @@ internal class CustomerCreditLedgerCreateEntryResponseTest { ) .build() ) - .billingMode(Price.Unit.BillingMode.IN_ADVANCE) - .cadence(Price.Unit.Cadence.ONE_TIME) + .billingMode(Price.UnitPrice.BillingMode.IN_ADVANCE) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) .addCompositePriceFilter( - Price.Unit.CompositePriceFilter.builder() + Price.UnitPrice.CompositePriceFilter.builder() .field( - Price.Unit.CompositePriceFilter.Field + Price.UnitPrice.CompositePriceFilter.Field .PRICE_ID ) .operator( - Price.Unit.CompositePriceFilter.Operator + Price.UnitPrice.CompositePriceFilter + .Operator .INCLUDES ) .addValue("string") @@ -836,7 +838,7 @@ internal class CustomerCreditLedgerCreateEntryResponseTest { ) .maximumAmount("maximum_amount") .metadata( - Price.Unit.Metadata.builder() + Price.UnitPrice.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -861,7 +863,7 @@ internal class CustomerCreditLedgerCreateEntryResponseTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.Unit.PriceType.USAGE_PRICE) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( UnitConfig.builder() diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdPageResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdPageResponseTest.kt index 4025b73e4..3934a5aee 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdPageResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdPageResponseTest.kt @@ -248,7 +248,7 @@ internal class CustomerCreditLedgerListByExternalIdPageResponseTest { .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( - Price.Unit.builder() + Price.UnitPrice.builder() .id("id") .billableMetric( BillableMetricTiny.builder().id("id").build() @@ -262,16 +262,18 @@ internal class CustomerCreditLedgerListByExternalIdPageResponseTest { ) .build() ) - .billingMode(Price.Unit.BillingMode.IN_ADVANCE) - .cadence(Price.Unit.Cadence.ONE_TIME) + .billingMode(Price.UnitPrice.BillingMode.IN_ADVANCE) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) .addCompositePriceFilter( - Price.Unit.CompositePriceFilter.builder() + Price.UnitPrice.CompositePriceFilter.builder() .field( - Price.Unit.CompositePriceFilter.Field + Price.UnitPrice.CompositePriceFilter + .Field .PRICE_ID ) .operator( - Price.Unit.CompositePriceFilter.Operator + Price.UnitPrice.CompositePriceFilter + .Operator .INCLUDES ) .addValue("string") @@ -373,7 +375,7 @@ internal class CustomerCreditLedgerListByExternalIdPageResponseTest { ) .maximumAmount("maximum_amount") .metadata( - Price.Unit.Metadata.builder() + Price.UnitPrice.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -400,7 +402,7 @@ internal class CustomerCreditLedgerListByExternalIdPageResponseTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.Unit.PriceType.USAGE_PRICE) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( UnitConfig.builder() @@ -769,7 +771,7 @@ internal class CustomerCreditLedgerListByExternalIdPageResponseTest { .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( - Price.Unit.builder() + Price.UnitPrice.builder() .id("id") .billableMetric( BillableMetricTiny.builder().id("id").build() @@ -783,16 +785,18 @@ internal class CustomerCreditLedgerListByExternalIdPageResponseTest { ) .build() ) - .billingMode(Price.Unit.BillingMode.IN_ADVANCE) - .cadence(Price.Unit.Cadence.ONE_TIME) + .billingMode(Price.UnitPrice.BillingMode.IN_ADVANCE) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) .addCompositePriceFilter( - Price.Unit.CompositePriceFilter.builder() + Price.UnitPrice.CompositePriceFilter.builder() .field( - Price.Unit.CompositePriceFilter.Field + Price.UnitPrice.CompositePriceFilter + .Field .PRICE_ID ) .operator( - Price.Unit.CompositePriceFilter.Operator + Price.UnitPrice.CompositePriceFilter + .Operator .INCLUDES ) .addValue("string") @@ -894,7 +898,7 @@ internal class CustomerCreditLedgerListByExternalIdPageResponseTest { ) .maximumAmount("maximum_amount") .metadata( - Price.Unit.Metadata.builder() + Price.UnitPrice.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -921,7 +925,7 @@ internal class CustomerCreditLedgerListByExternalIdPageResponseTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.Unit.PriceType.USAGE_PRICE) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( UnitConfig.builder() @@ -1293,7 +1297,7 @@ internal class CustomerCreditLedgerListByExternalIdPageResponseTest { .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( - Price.Unit.builder() + Price.UnitPrice.builder() .id("id") .billableMetric( BillableMetricTiny.builder().id("id").build() @@ -1307,16 +1311,18 @@ internal class CustomerCreditLedgerListByExternalIdPageResponseTest { ) .build() ) - .billingMode(Price.Unit.BillingMode.IN_ADVANCE) - .cadence(Price.Unit.Cadence.ONE_TIME) + .billingMode(Price.UnitPrice.BillingMode.IN_ADVANCE) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) .addCompositePriceFilter( - Price.Unit.CompositePriceFilter.builder() + Price.UnitPrice.CompositePriceFilter.builder() .field( - Price.Unit.CompositePriceFilter.Field + Price.UnitPrice.CompositePriceFilter + .Field .PRICE_ID ) .operator( - Price.Unit.CompositePriceFilter.Operator + Price.UnitPrice.CompositePriceFilter + .Operator .INCLUDES ) .addValue("string") @@ -1418,7 +1424,7 @@ internal class CustomerCreditLedgerListByExternalIdPageResponseTest { ) .maximumAmount("maximum_amount") .metadata( - Price.Unit.Metadata.builder() + Price.UnitPrice.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -1445,7 +1451,7 @@ internal class CustomerCreditLedgerListByExternalIdPageResponseTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.Unit.PriceType.USAGE_PRICE) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( UnitConfig.builder() diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdResponseTest.kt index 962aa0fb4..a27f40c54 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdResponseTest.kt @@ -234,7 +234,7 @@ internal class CustomerCreditLedgerListByExternalIdResponseTest { .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( - Price.Unit.builder() + Price.UnitPrice.builder() .id("id") .billableMetric( BillableMetricTiny.builder().id("id").build() @@ -247,15 +247,16 @@ internal class CustomerCreditLedgerListByExternalIdResponseTest { ) .build() ) - .billingMode(Price.Unit.BillingMode.IN_ADVANCE) - .cadence(Price.Unit.Cadence.ONE_TIME) + .billingMode(Price.UnitPrice.BillingMode.IN_ADVANCE) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) .addCompositePriceFilter( - Price.Unit.CompositePriceFilter.builder() + Price.UnitPrice.CompositePriceFilter.builder() .field( - Price.Unit.CompositePriceFilter.Field.PRICE_ID + Price.UnitPrice.CompositePriceFilter.Field + .PRICE_ID ) .operator( - Price.Unit.CompositePriceFilter.Operator + Price.UnitPrice.CompositePriceFilter.Operator .INCLUDES ) .addValue("string") @@ -341,7 +342,7 @@ internal class CustomerCreditLedgerListByExternalIdResponseTest { ) .maximumAmount("maximum_amount") .metadata( - Price.Unit.Metadata.builder() + Price.UnitPrice.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -364,7 +365,7 @@ internal class CustomerCreditLedgerListByExternalIdResponseTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.Unit.PriceType.USAGE_PRICE) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( UnitConfig.builder() @@ -723,7 +724,7 @@ internal class CustomerCreditLedgerListByExternalIdResponseTest { .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( - Price.Unit.builder() + Price.UnitPrice.builder() .id("id") .billableMetric( BillableMetricTiny.builder().id("id").build() @@ -736,16 +737,17 @@ internal class CustomerCreditLedgerListByExternalIdResponseTest { ) .build() ) - .billingMode(Price.Unit.BillingMode.IN_ADVANCE) - .cadence(Price.Unit.Cadence.ONE_TIME) + .billingMode(Price.UnitPrice.BillingMode.IN_ADVANCE) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) .addCompositePriceFilter( - Price.Unit.CompositePriceFilter.builder() + Price.UnitPrice.CompositePriceFilter.builder() .field( - Price.Unit.CompositePriceFilter.Field + Price.UnitPrice.CompositePriceFilter.Field .PRICE_ID ) .operator( - Price.Unit.CompositePriceFilter.Operator + Price.UnitPrice.CompositePriceFilter + .Operator .INCLUDES ) .addValue("string") @@ -836,7 +838,7 @@ internal class CustomerCreditLedgerListByExternalIdResponseTest { ) .maximumAmount("maximum_amount") .metadata( - Price.Unit.Metadata.builder() + Price.UnitPrice.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -861,7 +863,7 @@ internal class CustomerCreditLedgerListByExternalIdResponseTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.Unit.PriceType.USAGE_PRICE) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( UnitConfig.builder() diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListPageResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListPageResponseTest.kt index 15074c7b4..2b66b4b0e 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListPageResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListPageResponseTest.kt @@ -248,7 +248,7 @@ internal class CustomerCreditLedgerListPageResponseTest { .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( - Price.Unit.builder() + Price.UnitPrice.builder() .id("id") .billableMetric( BillableMetricTiny.builder().id("id").build() @@ -262,16 +262,18 @@ internal class CustomerCreditLedgerListPageResponseTest { ) .build() ) - .billingMode(Price.Unit.BillingMode.IN_ADVANCE) - .cadence(Price.Unit.Cadence.ONE_TIME) + .billingMode(Price.UnitPrice.BillingMode.IN_ADVANCE) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) .addCompositePriceFilter( - Price.Unit.CompositePriceFilter.builder() + Price.UnitPrice.CompositePriceFilter.builder() .field( - Price.Unit.CompositePriceFilter.Field + Price.UnitPrice.CompositePriceFilter + .Field .PRICE_ID ) .operator( - Price.Unit.CompositePriceFilter.Operator + Price.UnitPrice.CompositePriceFilter + .Operator .INCLUDES ) .addValue("string") @@ -373,7 +375,7 @@ internal class CustomerCreditLedgerListPageResponseTest { ) .maximumAmount("maximum_amount") .metadata( - Price.Unit.Metadata.builder() + Price.UnitPrice.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -400,7 +402,7 @@ internal class CustomerCreditLedgerListPageResponseTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.Unit.PriceType.USAGE_PRICE) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( UnitConfig.builder() @@ -769,7 +771,7 @@ internal class CustomerCreditLedgerListPageResponseTest { .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( - Price.Unit.builder() + Price.UnitPrice.builder() .id("id") .billableMetric( BillableMetricTiny.builder().id("id").build() @@ -783,16 +785,18 @@ internal class CustomerCreditLedgerListPageResponseTest { ) .build() ) - .billingMode(Price.Unit.BillingMode.IN_ADVANCE) - .cadence(Price.Unit.Cadence.ONE_TIME) + .billingMode(Price.UnitPrice.BillingMode.IN_ADVANCE) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) .addCompositePriceFilter( - Price.Unit.CompositePriceFilter.builder() + Price.UnitPrice.CompositePriceFilter.builder() .field( - Price.Unit.CompositePriceFilter.Field + Price.UnitPrice.CompositePriceFilter + .Field .PRICE_ID ) .operator( - Price.Unit.CompositePriceFilter.Operator + Price.UnitPrice.CompositePriceFilter + .Operator .INCLUDES ) .addValue("string") @@ -894,7 +898,7 @@ internal class CustomerCreditLedgerListPageResponseTest { ) .maximumAmount("maximum_amount") .metadata( - Price.Unit.Metadata.builder() + Price.UnitPrice.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -921,7 +925,7 @@ internal class CustomerCreditLedgerListPageResponseTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.Unit.PriceType.USAGE_PRICE) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( UnitConfig.builder() @@ -1293,7 +1297,7 @@ internal class CustomerCreditLedgerListPageResponseTest { .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( - Price.Unit.builder() + Price.UnitPrice.builder() .id("id") .billableMetric( BillableMetricTiny.builder().id("id").build() @@ -1307,16 +1311,18 @@ internal class CustomerCreditLedgerListPageResponseTest { ) .build() ) - .billingMode(Price.Unit.BillingMode.IN_ADVANCE) - .cadence(Price.Unit.Cadence.ONE_TIME) + .billingMode(Price.UnitPrice.BillingMode.IN_ADVANCE) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) .addCompositePriceFilter( - Price.Unit.CompositePriceFilter.builder() + Price.UnitPrice.CompositePriceFilter.builder() .field( - Price.Unit.CompositePriceFilter.Field + Price.UnitPrice.CompositePriceFilter + .Field .PRICE_ID ) .operator( - Price.Unit.CompositePriceFilter.Operator + Price.UnitPrice.CompositePriceFilter + .Operator .INCLUDES ) .addValue("string") @@ -1418,7 +1424,7 @@ internal class CustomerCreditLedgerListPageResponseTest { ) .maximumAmount("maximum_amount") .metadata( - Price.Unit.Metadata.builder() + Price.UnitPrice.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -1445,7 +1451,7 @@ internal class CustomerCreditLedgerListPageResponseTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.Unit.PriceType.USAGE_PRICE) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( UnitConfig.builder() diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListResponseTest.kt index ba8b35e85..a7096026a 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListResponseTest.kt @@ -234,7 +234,7 @@ internal class CustomerCreditLedgerListResponseTest { .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( - Price.Unit.builder() + Price.UnitPrice.builder() .id("id") .billableMetric( BillableMetricTiny.builder().id("id").build() @@ -247,15 +247,16 @@ internal class CustomerCreditLedgerListResponseTest { ) .build() ) - .billingMode(Price.Unit.BillingMode.IN_ADVANCE) - .cadence(Price.Unit.Cadence.ONE_TIME) + .billingMode(Price.UnitPrice.BillingMode.IN_ADVANCE) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) .addCompositePriceFilter( - Price.Unit.CompositePriceFilter.builder() + Price.UnitPrice.CompositePriceFilter.builder() .field( - Price.Unit.CompositePriceFilter.Field.PRICE_ID + Price.UnitPrice.CompositePriceFilter.Field + .PRICE_ID ) .operator( - Price.Unit.CompositePriceFilter.Operator + Price.UnitPrice.CompositePriceFilter.Operator .INCLUDES ) .addValue("string") @@ -341,7 +342,7 @@ internal class CustomerCreditLedgerListResponseTest { ) .maximumAmount("maximum_amount") .metadata( - Price.Unit.Metadata.builder() + Price.UnitPrice.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -364,7 +365,7 @@ internal class CustomerCreditLedgerListResponseTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.Unit.PriceType.USAGE_PRICE) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( UnitConfig.builder() @@ -723,7 +724,7 @@ internal class CustomerCreditLedgerListResponseTest { .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( - Price.Unit.builder() + Price.UnitPrice.builder() .id("id") .billableMetric( BillableMetricTiny.builder().id("id").build() @@ -736,16 +737,17 @@ internal class CustomerCreditLedgerListResponseTest { ) .build() ) - .billingMode(Price.Unit.BillingMode.IN_ADVANCE) - .cadence(Price.Unit.Cadence.ONE_TIME) + .billingMode(Price.UnitPrice.BillingMode.IN_ADVANCE) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) .addCompositePriceFilter( - Price.Unit.CompositePriceFilter.builder() + Price.UnitPrice.CompositePriceFilter.builder() .field( - Price.Unit.CompositePriceFilter.Field + Price.UnitPrice.CompositePriceFilter.Field .PRICE_ID ) .operator( - Price.Unit.CompositePriceFilter.Operator + Price.UnitPrice.CompositePriceFilter + .Operator .INCLUDES ) .addValue("string") @@ -836,7 +838,7 @@ internal class CustomerCreditLedgerListResponseTest { ) .maximumAmount("maximum_amount") .metadata( - Price.Unit.Metadata.builder() + Price.UnitPrice.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -861,7 +863,7 @@ internal class CustomerCreditLedgerListResponseTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.Unit.PriceType.USAGE_PRICE) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( UnitConfig.builder() diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/IncrementLedgerEntryTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/IncrementLedgerEntryTest.kt index a1faa6b9e..aa5bb71a2 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/IncrementLedgerEntryTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/IncrementLedgerEntryTest.kt @@ -230,7 +230,7 @@ internal class IncrementLedgerEntryTest { .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( - Price.Unit.builder() + Price.UnitPrice.builder() .id("id") .billableMetric( BillableMetricTiny.builder().id("id").build() @@ -243,15 +243,16 @@ internal class IncrementLedgerEntryTest { ) .build() ) - .billingMode(Price.Unit.BillingMode.IN_ADVANCE) - .cadence(Price.Unit.Cadence.ONE_TIME) + .billingMode(Price.UnitPrice.BillingMode.IN_ADVANCE) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) .addCompositePriceFilter( - Price.Unit.CompositePriceFilter.builder() + Price.UnitPrice.CompositePriceFilter.builder() .field( - Price.Unit.CompositePriceFilter.Field.PRICE_ID + Price.UnitPrice.CompositePriceFilter.Field + .PRICE_ID ) .operator( - Price.Unit.CompositePriceFilter.Operator + Price.UnitPrice.CompositePriceFilter.Operator .INCLUDES ) .addValue("string") @@ -337,7 +338,7 @@ internal class IncrementLedgerEntryTest { ) .maximumAmount("maximum_amount") .metadata( - Price.Unit.Metadata.builder() + Price.UnitPrice.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -360,7 +361,7 @@ internal class IncrementLedgerEntryTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.Unit.PriceType.USAGE_PRICE) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( UnitConfig.builder() @@ -699,7 +700,7 @@ internal class IncrementLedgerEntryTest { .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( - Price.Unit.builder() + Price.UnitPrice.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -710,13 +711,16 @@ internal class IncrementLedgerEntryTest { ) .build() ) - .billingMode(Price.Unit.BillingMode.IN_ADVANCE) - .cadence(Price.Unit.Cadence.ONE_TIME) + .billingMode(Price.UnitPrice.BillingMode.IN_ADVANCE) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) .addCompositePriceFilter( - Price.Unit.CompositePriceFilter.builder() - .field(Price.Unit.CompositePriceFilter.Field.PRICE_ID) + Price.UnitPrice.CompositePriceFilter.builder() + .field( + Price.UnitPrice.CompositePriceFilter.Field.PRICE_ID + ) .operator( - Price.Unit.CompositePriceFilter.Operator.INCLUDES + Price.UnitPrice.CompositePriceFilter.Operator + .INCLUDES ) .addValue("string") .build() @@ -794,7 +798,7 @@ internal class IncrementLedgerEntryTest { ) .maximumAmount("maximum_amount") .metadata( - Price.Unit.Metadata.builder() + Price.UnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -814,7 +818,7 @@ internal class IncrementLedgerEntryTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.Unit.PriceType.USAGE_PRICE) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( UnitConfig.builder() @@ -1155,7 +1159,7 @@ internal class IncrementLedgerEntryTest { .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( - Price.Unit.builder() + Price.UnitPrice.builder() .id("id") .billableMetric( BillableMetricTiny.builder().id("id").build() @@ -1168,15 +1172,16 @@ internal class IncrementLedgerEntryTest { ) .build() ) - .billingMode(Price.Unit.BillingMode.IN_ADVANCE) - .cadence(Price.Unit.Cadence.ONE_TIME) + .billingMode(Price.UnitPrice.BillingMode.IN_ADVANCE) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) .addCompositePriceFilter( - Price.Unit.CompositePriceFilter.builder() + Price.UnitPrice.CompositePriceFilter.builder() .field( - Price.Unit.CompositePriceFilter.Field.PRICE_ID + Price.UnitPrice.CompositePriceFilter.Field + .PRICE_ID ) .operator( - Price.Unit.CompositePriceFilter.Operator + Price.UnitPrice.CompositePriceFilter.Operator .INCLUDES ) .addValue("string") @@ -1262,7 +1267,7 @@ internal class IncrementLedgerEntryTest { ) .maximumAmount("maximum_amount") .metadata( - Price.Unit.Metadata.builder() + Price.UnitPrice.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -1285,7 +1290,7 @@ internal class IncrementLedgerEntryTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.Unit.PriceType.USAGE_PRICE) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( UnitConfig.builder() diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceFetchUpcomingResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceFetchUpcomingResponseTest.kt index 2762dced0..ba347a75e 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceFetchUpcomingResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceFetchUpcomingResponseTest.kt @@ -186,7 +186,7 @@ internal class InvoiceFetchUpcomingResponseTest { .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( - Price.Unit.builder() + Price.UnitPrice.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -195,12 +195,14 @@ internal class InvoiceFetchUpcomingResponseTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .billingMode(Price.Unit.BillingMode.IN_ADVANCE) - .cadence(Price.Unit.Cadence.ONE_TIME) + .billingMode(Price.UnitPrice.BillingMode.IN_ADVANCE) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) .addCompositePriceFilter( - Price.Unit.CompositePriceFilter.builder() - .field(Price.Unit.CompositePriceFilter.Field.PRICE_ID) - .operator(Price.Unit.CompositePriceFilter.Operator.INCLUDES) + Price.UnitPrice.CompositePriceFilter.builder() + .field(Price.UnitPrice.CompositePriceFilter.Field.PRICE_ID) + .operator( + Price.UnitPrice.CompositePriceFilter.Operator.INCLUDES + ) .addValue("string") .build() ) @@ -273,7 +275,7 @@ internal class InvoiceFetchUpcomingResponseTest { ) .maximumAmount("maximum_amount") .metadata( - Price.Unit.Metadata.builder() + Price.UnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -293,7 +295,7 @@ internal class InvoiceFetchUpcomingResponseTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.Unit.PriceType.USAGE_PRICE) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( UnitConfig.builder() @@ -600,7 +602,7 @@ internal class InvoiceFetchUpcomingResponseTest { .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( - Price.Unit.builder() + Price.UnitPrice.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -609,12 +611,14 @@ internal class InvoiceFetchUpcomingResponseTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .billingMode(Price.Unit.BillingMode.IN_ADVANCE) - .cadence(Price.Unit.Cadence.ONE_TIME) + .billingMode(Price.UnitPrice.BillingMode.IN_ADVANCE) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) .addCompositePriceFilter( - Price.Unit.CompositePriceFilter.builder() - .field(Price.Unit.CompositePriceFilter.Field.PRICE_ID) - .operator(Price.Unit.CompositePriceFilter.Operator.INCLUDES) + Price.UnitPrice.CompositePriceFilter.builder() + .field(Price.UnitPrice.CompositePriceFilter.Field.PRICE_ID) + .operator( + Price.UnitPrice.CompositePriceFilter.Operator.INCLUDES + ) .addValue("string") .build() ) @@ -683,7 +687,7 @@ internal class InvoiceFetchUpcomingResponseTest { ) .maximumAmount("maximum_amount") .metadata( - Price.Unit.Metadata.builder() + Price.UnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -703,7 +707,7 @@ internal class InvoiceFetchUpcomingResponseTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.Unit.PriceType.USAGE_PRICE) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( UnitConfig.builder() @@ -1012,7 +1016,7 @@ internal class InvoiceFetchUpcomingResponseTest { .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( - Price.Unit.builder() + Price.UnitPrice.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -1021,12 +1025,14 @@ internal class InvoiceFetchUpcomingResponseTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .billingMode(Price.Unit.BillingMode.IN_ADVANCE) - .cadence(Price.Unit.Cadence.ONE_TIME) + .billingMode(Price.UnitPrice.BillingMode.IN_ADVANCE) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) .addCompositePriceFilter( - Price.Unit.CompositePriceFilter.builder() - .field(Price.Unit.CompositePriceFilter.Field.PRICE_ID) - .operator(Price.Unit.CompositePriceFilter.Operator.INCLUDES) + Price.UnitPrice.CompositePriceFilter.builder() + .field(Price.UnitPrice.CompositePriceFilter.Field.PRICE_ID) + .operator( + Price.UnitPrice.CompositePriceFilter.Operator.INCLUDES + ) .addValue("string") .build() ) @@ -1099,7 +1105,7 @@ internal class InvoiceFetchUpcomingResponseTest { ) .maximumAmount("maximum_amount") .metadata( - Price.Unit.Metadata.builder() + Price.UnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -1119,7 +1125,7 @@ internal class InvoiceFetchUpcomingResponseTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.Unit.PriceType.USAGE_PRICE) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( UnitConfig.builder() diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceLineItemCreateResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceLineItemCreateResponseTest.kt index cac65e6b0..033f332e2 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceLineItemCreateResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceLineItemCreateResponseTest.kt @@ -90,7 +90,7 @@ internal class InvoiceLineItemCreateResponseTest { .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( - Price.Unit.builder() + Price.UnitPrice.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -99,12 +99,12 @@ internal class InvoiceLineItemCreateResponseTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .billingMode(Price.Unit.BillingMode.IN_ADVANCE) - .cadence(Price.Unit.Cadence.ONE_TIME) + .billingMode(Price.UnitPrice.BillingMode.IN_ADVANCE) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) .addCompositePriceFilter( - Price.Unit.CompositePriceFilter.builder() - .field(Price.Unit.CompositePriceFilter.Field.PRICE_ID) - .operator(Price.Unit.CompositePriceFilter.Operator.INCLUDES) + Price.UnitPrice.CompositePriceFilter.builder() + .field(Price.UnitPrice.CompositePriceFilter.Field.PRICE_ID) + .operator(Price.UnitPrice.CompositePriceFilter.Operator.INCLUDES) .addValue("string") .build() ) @@ -173,7 +173,7 @@ internal class InvoiceLineItemCreateResponseTest { ) .maximumAmount("maximum_amount") .metadata( - Price.Unit.Metadata.builder() + Price.UnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -193,7 +193,7 @@ internal class InvoiceLineItemCreateResponseTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.Unit.PriceType.USAGE_PRICE) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( UnitConfig.builder().unitAmount("unit_amount").prorated(true).build() @@ -318,7 +318,7 @@ internal class InvoiceLineItemCreateResponseTest { assertThat(invoiceLineItemCreateResponse.price()) .isEqualTo( Price.ofUnit( - Price.Unit.builder() + Price.UnitPrice.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -327,12 +327,12 @@ internal class InvoiceLineItemCreateResponseTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .billingMode(Price.Unit.BillingMode.IN_ADVANCE) - .cadence(Price.Unit.Cadence.ONE_TIME) + .billingMode(Price.UnitPrice.BillingMode.IN_ADVANCE) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) .addCompositePriceFilter( - Price.Unit.CompositePriceFilter.builder() - .field(Price.Unit.CompositePriceFilter.Field.PRICE_ID) - .operator(Price.Unit.CompositePriceFilter.Operator.INCLUDES) + Price.UnitPrice.CompositePriceFilter.builder() + .field(Price.UnitPrice.CompositePriceFilter.Field.PRICE_ID) + .operator(Price.UnitPrice.CompositePriceFilter.Operator.INCLUDES) .addValue("string") .build() ) @@ -401,7 +401,7 @@ internal class InvoiceLineItemCreateResponseTest { ) .maximumAmount("maximum_amount") .metadata( - Price.Unit.Metadata.builder() + Price.UnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -421,7 +421,7 @@ internal class InvoiceLineItemCreateResponseTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.Unit.PriceType.USAGE_PRICE) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( UnitConfig.builder().unitAmount("unit_amount").prorated(true).build() @@ -546,7 +546,7 @@ internal class InvoiceLineItemCreateResponseTest { .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( - Price.Unit.builder() + Price.UnitPrice.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -555,12 +555,12 @@ internal class InvoiceLineItemCreateResponseTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .billingMode(Price.Unit.BillingMode.IN_ADVANCE) - .cadence(Price.Unit.Cadence.ONE_TIME) + .billingMode(Price.UnitPrice.BillingMode.IN_ADVANCE) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) .addCompositePriceFilter( - Price.Unit.CompositePriceFilter.builder() - .field(Price.Unit.CompositePriceFilter.Field.PRICE_ID) - .operator(Price.Unit.CompositePriceFilter.Operator.INCLUDES) + Price.UnitPrice.CompositePriceFilter.builder() + .field(Price.UnitPrice.CompositePriceFilter.Field.PRICE_ID) + .operator(Price.UnitPrice.CompositePriceFilter.Operator.INCLUDES) .addValue("string") .build() ) @@ -629,7 +629,7 @@ internal class InvoiceLineItemCreateResponseTest { ) .maximumAmount("maximum_amount") .metadata( - Price.Unit.Metadata.builder() + Price.UnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -649,7 +649,7 @@ internal class InvoiceLineItemCreateResponseTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.Unit.PriceType.USAGE_PRICE) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( UnitConfig.builder().unitAmount("unit_amount").prorated(true).build() diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceListPageResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceListPageResponseTest.kt index 855bc2ef7..27770db19 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceListPageResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceListPageResponseTest.kt @@ -195,7 +195,7 @@ internal class InvoiceListPageResponseTest { .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( - Price.Unit.builder() + Price.UnitPrice.builder() .id("id") .billableMetric( BillableMetricTiny.builder().id("id").build() @@ -208,15 +208,16 @@ internal class InvoiceListPageResponseTest { ) .build() ) - .billingMode(Price.Unit.BillingMode.IN_ADVANCE) - .cadence(Price.Unit.Cadence.ONE_TIME) + .billingMode(Price.UnitPrice.BillingMode.IN_ADVANCE) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) .addCompositePriceFilter( - Price.Unit.CompositePriceFilter.builder() + Price.UnitPrice.CompositePriceFilter.builder() .field( - Price.Unit.CompositePriceFilter.Field.PRICE_ID + Price.UnitPrice.CompositePriceFilter.Field + .PRICE_ID ) .operator( - Price.Unit.CompositePriceFilter.Operator + Price.UnitPrice.CompositePriceFilter.Operator .INCLUDES ) .addValue("string") @@ -302,7 +303,7 @@ internal class InvoiceListPageResponseTest { ) .maximumAmount("maximum_amount") .metadata( - Price.Unit.Metadata.builder() + Price.UnitPrice.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -325,7 +326,7 @@ internal class InvoiceListPageResponseTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.Unit.PriceType.USAGE_PRICE) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( UnitConfig.builder() @@ -626,7 +627,7 @@ internal class InvoiceListPageResponseTest { .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( - Price.Unit.builder() + Price.UnitPrice.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -637,13 +638,16 @@ internal class InvoiceListPageResponseTest { ) .build() ) - .billingMode(Price.Unit.BillingMode.IN_ADVANCE) - .cadence(Price.Unit.Cadence.ONE_TIME) + .billingMode(Price.UnitPrice.BillingMode.IN_ADVANCE) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) .addCompositePriceFilter( - Price.Unit.CompositePriceFilter.builder() - .field(Price.Unit.CompositePriceFilter.Field.PRICE_ID) + Price.UnitPrice.CompositePriceFilter.builder() + .field( + Price.UnitPrice.CompositePriceFilter.Field.PRICE_ID + ) .operator( - Price.Unit.CompositePriceFilter.Operator.INCLUDES + Price.UnitPrice.CompositePriceFilter.Operator + .INCLUDES ) .addValue("string") .build() @@ -721,7 +725,7 @@ internal class InvoiceListPageResponseTest { ) .maximumAmount("maximum_amount") .metadata( - Price.Unit.Metadata.builder() + Price.UnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -741,7 +745,7 @@ internal class InvoiceListPageResponseTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.Unit.PriceType.USAGE_PRICE) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( UnitConfig.builder() @@ -1049,7 +1053,7 @@ internal class InvoiceListPageResponseTest { .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( - Price.Unit.builder() + Price.UnitPrice.builder() .id("id") .billableMetric( BillableMetricTiny.builder().id("id").build() @@ -1062,15 +1066,16 @@ internal class InvoiceListPageResponseTest { ) .build() ) - .billingMode(Price.Unit.BillingMode.IN_ADVANCE) - .cadence(Price.Unit.Cadence.ONE_TIME) + .billingMode(Price.UnitPrice.BillingMode.IN_ADVANCE) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) .addCompositePriceFilter( - Price.Unit.CompositePriceFilter.builder() + Price.UnitPrice.CompositePriceFilter.builder() .field( - Price.Unit.CompositePriceFilter.Field.PRICE_ID + Price.UnitPrice.CompositePriceFilter.Field + .PRICE_ID ) .operator( - Price.Unit.CompositePriceFilter.Operator + Price.UnitPrice.CompositePriceFilter.Operator .INCLUDES ) .addValue("string") @@ -1156,7 +1161,7 @@ internal class InvoiceListPageResponseTest { ) .maximumAmount("maximum_amount") .metadata( - Price.Unit.Metadata.builder() + Price.UnitPrice.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -1179,7 +1184,7 @@ internal class InvoiceListPageResponseTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.Unit.PriceType.USAGE_PRICE) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( UnitConfig.builder() diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceTest.kt index 7f6631f86..bd4ea401a 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceTest.kt @@ -182,7 +182,7 @@ internal class InvoiceTest { .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( - Price.Unit.builder() + Price.UnitPrice.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -191,12 +191,14 @@ internal class InvoiceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .billingMode(Price.Unit.BillingMode.IN_ADVANCE) - .cadence(Price.Unit.Cadence.ONE_TIME) + .billingMode(Price.UnitPrice.BillingMode.IN_ADVANCE) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) .addCompositePriceFilter( - Price.Unit.CompositePriceFilter.builder() - .field(Price.Unit.CompositePriceFilter.Field.PRICE_ID) - .operator(Price.Unit.CompositePriceFilter.Operator.INCLUDES) + Price.UnitPrice.CompositePriceFilter.builder() + .field(Price.UnitPrice.CompositePriceFilter.Field.PRICE_ID) + .operator( + Price.UnitPrice.CompositePriceFilter.Operator.INCLUDES + ) .addValue("string") .build() ) @@ -269,7 +271,7 @@ internal class InvoiceTest { ) .maximumAmount("maximum_amount") .metadata( - Price.Unit.Metadata.builder() + Price.UnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -289,7 +291,7 @@ internal class InvoiceTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.Unit.PriceType.USAGE_PRICE) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( UnitConfig.builder() @@ -587,7 +589,7 @@ internal class InvoiceTest { .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( - Price.Unit.builder() + Price.UnitPrice.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -596,12 +598,14 @@ internal class InvoiceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .billingMode(Price.Unit.BillingMode.IN_ADVANCE) - .cadence(Price.Unit.Cadence.ONE_TIME) + .billingMode(Price.UnitPrice.BillingMode.IN_ADVANCE) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) .addCompositePriceFilter( - Price.Unit.CompositePriceFilter.builder() - .field(Price.Unit.CompositePriceFilter.Field.PRICE_ID) - .operator(Price.Unit.CompositePriceFilter.Operator.INCLUDES) + Price.UnitPrice.CompositePriceFilter.builder() + .field(Price.UnitPrice.CompositePriceFilter.Field.PRICE_ID) + .operator( + Price.UnitPrice.CompositePriceFilter.Operator.INCLUDES + ) .addValue("string") .build() ) @@ -670,7 +674,7 @@ internal class InvoiceTest { ) .maximumAmount("maximum_amount") .metadata( - Price.Unit.Metadata.builder() + Price.UnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -690,7 +694,7 @@ internal class InvoiceTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.Unit.PriceType.USAGE_PRICE) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( UnitConfig.builder() @@ -988,7 +992,7 @@ internal class InvoiceTest { .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( - Price.Unit.builder() + Price.UnitPrice.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -997,12 +1001,14 @@ internal class InvoiceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .billingMode(Price.Unit.BillingMode.IN_ADVANCE) - .cadence(Price.Unit.Cadence.ONE_TIME) + .billingMode(Price.UnitPrice.BillingMode.IN_ADVANCE) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) .addCompositePriceFilter( - Price.Unit.CompositePriceFilter.builder() - .field(Price.Unit.CompositePriceFilter.Field.PRICE_ID) - .operator(Price.Unit.CompositePriceFilter.Operator.INCLUDES) + Price.UnitPrice.CompositePriceFilter.builder() + .field(Price.UnitPrice.CompositePriceFilter.Field.PRICE_ID) + .operator( + Price.UnitPrice.CompositePriceFilter.Operator.INCLUDES + ) .addValue("string") .build() ) @@ -1075,7 +1081,7 @@ internal class InvoiceTest { ) .maximumAmount("maximum_amount") .metadata( - Price.Unit.Metadata.builder() + Price.UnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -1095,7 +1101,7 @@ internal class InvoiceTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.Unit.PriceType.USAGE_PRICE) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( UnitConfig.builder() diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/MutatedSubscriptionTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/MutatedSubscriptionTest.kt index ec7940de0..91d1cb14f 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/MutatedSubscriptionTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/MutatedSubscriptionTest.kt @@ -363,7 +363,7 @@ internal class MutatedSubscriptionTest { .build() ) .addPrice( - Price.Unit.builder() + Price.UnitPrice.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -372,12 +372,14 @@ internal class MutatedSubscriptionTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .billingMode(Price.Unit.BillingMode.IN_ADVANCE) - .cadence(Price.Unit.Cadence.ONE_TIME) + .billingMode(Price.UnitPrice.BillingMode.IN_ADVANCE) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) .addCompositePriceFilter( - Price.Unit.CompositePriceFilter.builder() - .field(Price.Unit.CompositePriceFilter.Field.PRICE_ID) - .operator(Price.Unit.CompositePriceFilter.Operator.INCLUDES) + Price.UnitPrice.CompositePriceFilter.builder() + .field(Price.UnitPrice.CompositePriceFilter.Field.PRICE_ID) + .operator( + Price.UnitPrice.CompositePriceFilter.Operator.INCLUDES + ) .addValue("string") .build() ) @@ -450,7 +452,7 @@ internal class MutatedSubscriptionTest { ) .maximumAmount("maximum_amount") .metadata( - Price.Unit.Metadata.builder() + Price.UnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -470,7 +472,7 @@ internal class MutatedSubscriptionTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.Unit.PriceType.USAGE_PRICE) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( UnitConfig.builder() @@ -524,7 +526,7 @@ internal class MutatedSubscriptionTest { .build() ) .price( - Price.Unit.builder() + Price.UnitPrice.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -533,12 +535,14 @@ internal class MutatedSubscriptionTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .billingMode(Price.Unit.BillingMode.IN_ADVANCE) - .cadence(Price.Unit.Cadence.ONE_TIME) + .billingMode(Price.UnitPrice.BillingMode.IN_ADVANCE) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) .addCompositePriceFilter( - Price.Unit.CompositePriceFilter.builder() - .field(Price.Unit.CompositePriceFilter.Field.PRICE_ID) - .operator(Price.Unit.CompositePriceFilter.Operator.INCLUDES) + Price.UnitPrice.CompositePriceFilter.builder() + .field(Price.UnitPrice.CompositePriceFilter.Field.PRICE_ID) + .operator( + Price.UnitPrice.CompositePriceFilter.Operator.INCLUDES + ) .addValue("string") .build() ) @@ -611,7 +615,7 @@ internal class MutatedSubscriptionTest { ) .maximumAmount("maximum_amount") .metadata( - Price.Unit.Metadata.builder() + Price.UnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -631,7 +635,7 @@ internal class MutatedSubscriptionTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.Unit.PriceType.USAGE_PRICE) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( UnitConfig.builder() @@ -968,7 +972,7 @@ internal class MutatedSubscriptionTest { .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( - Price.Unit.builder() + Price.UnitPrice.builder() .id("id") .billableMetric( BillableMetricTiny.builder().id("id").build() @@ -982,16 +986,18 @@ internal class MutatedSubscriptionTest { ) .build() ) - .billingMode(Price.Unit.BillingMode.IN_ADVANCE) - .cadence(Price.Unit.Cadence.ONE_TIME) + .billingMode(Price.UnitPrice.BillingMode.IN_ADVANCE) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) .addCompositePriceFilter( - Price.Unit.CompositePriceFilter.builder() + Price.UnitPrice.CompositePriceFilter.builder() .field( - Price.Unit.CompositePriceFilter.Field + Price.UnitPrice.CompositePriceFilter + .Field .PRICE_ID ) .operator( - Price.Unit.CompositePriceFilter.Operator + Price.UnitPrice.CompositePriceFilter + .Operator .INCLUDES ) .addValue("string") @@ -1093,7 +1099,7 @@ internal class MutatedSubscriptionTest { ) .maximumAmount("maximum_amount") .metadata( - Price.Unit.Metadata.builder() + Price.UnitPrice.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -1120,7 +1126,7 @@ internal class MutatedSubscriptionTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.Unit.PriceType.USAGE_PRICE) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( UnitConfig.builder() @@ -1538,7 +1544,7 @@ internal class MutatedSubscriptionTest { .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( - Price.Unit.builder() + Price.UnitPrice.builder() .id("id") .billableMetric( BillableMetricTiny.builder().id("id").build() @@ -1552,16 +1558,18 @@ internal class MutatedSubscriptionTest { ) .build() ) - .billingMode(Price.Unit.BillingMode.IN_ADVANCE) - .cadence(Price.Unit.Cadence.ONE_TIME) + .billingMode(Price.UnitPrice.BillingMode.IN_ADVANCE) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) .addCompositePriceFilter( - Price.Unit.CompositePriceFilter.builder() + Price.UnitPrice.CompositePriceFilter.builder() .field( - Price.Unit.CompositePriceFilter.Field + Price.UnitPrice.CompositePriceFilter + .Field .PRICE_ID ) .operator( - Price.Unit.CompositePriceFilter.Operator + Price.UnitPrice.CompositePriceFilter + .Operator .INCLUDES ) .addValue("string") @@ -1663,7 +1671,7 @@ internal class MutatedSubscriptionTest { ) .maximumAmount("maximum_amount") .metadata( - Price.Unit.Metadata.builder() + Price.UnitPrice.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -1690,7 +1698,7 @@ internal class MutatedSubscriptionTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.Unit.PriceType.USAGE_PRICE) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( UnitConfig.builder() @@ -2174,7 +2182,7 @@ internal class MutatedSubscriptionTest { .build() ) .addPrice( - Price.Unit.builder() + Price.UnitPrice.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -2183,12 +2191,14 @@ internal class MutatedSubscriptionTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .billingMode(Price.Unit.BillingMode.IN_ADVANCE) - .cadence(Price.Unit.Cadence.ONE_TIME) + .billingMode(Price.UnitPrice.BillingMode.IN_ADVANCE) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) .addCompositePriceFilter( - Price.Unit.CompositePriceFilter.builder() - .field(Price.Unit.CompositePriceFilter.Field.PRICE_ID) - .operator(Price.Unit.CompositePriceFilter.Operator.INCLUDES) + Price.UnitPrice.CompositePriceFilter.builder() + .field(Price.UnitPrice.CompositePriceFilter.Field.PRICE_ID) + .operator( + Price.UnitPrice.CompositePriceFilter.Operator.INCLUDES + ) .addValue("string") .build() ) @@ -2257,7 +2267,7 @@ internal class MutatedSubscriptionTest { ) .maximumAmount("maximum_amount") .metadata( - Price.Unit.Metadata.builder() + Price.UnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -2277,7 +2287,7 @@ internal class MutatedSubscriptionTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.Unit.PriceType.USAGE_PRICE) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( UnitConfig.builder() @@ -2328,7 +2338,7 @@ internal class MutatedSubscriptionTest { .build() ) .price( - Price.Unit.builder() + Price.UnitPrice.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -2337,12 +2347,14 @@ internal class MutatedSubscriptionTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .billingMode(Price.Unit.BillingMode.IN_ADVANCE) - .cadence(Price.Unit.Cadence.ONE_TIME) + .billingMode(Price.UnitPrice.BillingMode.IN_ADVANCE) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) .addCompositePriceFilter( - Price.Unit.CompositePriceFilter.builder() - .field(Price.Unit.CompositePriceFilter.Field.PRICE_ID) - .operator(Price.Unit.CompositePriceFilter.Operator.INCLUDES) + Price.UnitPrice.CompositePriceFilter.builder() + .field(Price.UnitPrice.CompositePriceFilter.Field.PRICE_ID) + .operator( + Price.UnitPrice.CompositePriceFilter.Operator.INCLUDES + ) .addValue("string") .build() ) @@ -2411,7 +2423,7 @@ internal class MutatedSubscriptionTest { ) .maximumAmount("maximum_amount") .metadata( - Price.Unit.Metadata.builder() + Price.UnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -2431,7 +2443,7 @@ internal class MutatedSubscriptionTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.Unit.PriceType.USAGE_PRICE) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( UnitConfig.builder() @@ -2756,7 +2768,7 @@ internal class MutatedSubscriptionTest { .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( - Price.Unit.builder() + Price.UnitPrice.builder() .id("id") .billableMetric( BillableMetricTiny.builder().id("id").build() @@ -2769,16 +2781,17 @@ internal class MutatedSubscriptionTest { ) .build() ) - .billingMode(Price.Unit.BillingMode.IN_ADVANCE) - .cadence(Price.Unit.Cadence.ONE_TIME) + .billingMode(Price.UnitPrice.BillingMode.IN_ADVANCE) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) .addCompositePriceFilter( - Price.Unit.CompositePriceFilter.builder() + Price.UnitPrice.CompositePriceFilter.builder() .field( - Price.Unit.CompositePriceFilter.Field + Price.UnitPrice.CompositePriceFilter.Field .PRICE_ID ) .operator( - Price.Unit.CompositePriceFilter.Operator + Price.UnitPrice.CompositePriceFilter + .Operator .INCLUDES ) .addValue("string") @@ -2869,7 +2882,7 @@ internal class MutatedSubscriptionTest { ) .maximumAmount("maximum_amount") .metadata( - Price.Unit.Metadata.builder() + Price.UnitPrice.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -2894,7 +2907,7 @@ internal class MutatedSubscriptionTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.Unit.PriceType.USAGE_PRICE) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( UnitConfig.builder() @@ -3292,7 +3305,7 @@ internal class MutatedSubscriptionTest { .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( - Price.Unit.builder() + Price.UnitPrice.builder() .id("id") .billableMetric( BillableMetricTiny.builder().id("id").build() @@ -3305,16 +3318,17 @@ internal class MutatedSubscriptionTest { ) .build() ) - .billingMode(Price.Unit.BillingMode.IN_ADVANCE) - .cadence(Price.Unit.Cadence.ONE_TIME) + .billingMode(Price.UnitPrice.BillingMode.IN_ADVANCE) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) .addCompositePriceFilter( - Price.Unit.CompositePriceFilter.builder() + Price.UnitPrice.CompositePriceFilter.builder() .field( - Price.Unit.CompositePriceFilter.Field + Price.UnitPrice.CompositePriceFilter.Field .PRICE_ID ) .operator( - Price.Unit.CompositePriceFilter.Operator + Price.UnitPrice.CompositePriceFilter + .Operator .INCLUDES ) .addValue("string") @@ -3405,7 +3419,7 @@ internal class MutatedSubscriptionTest { ) .maximumAmount("maximum_amount") .metadata( - Price.Unit.Metadata.builder() + Price.UnitPrice.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -3430,7 +3444,7 @@ internal class MutatedSubscriptionTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.Unit.PriceType.USAGE_PRICE) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( UnitConfig.builder() @@ -3910,7 +3924,7 @@ internal class MutatedSubscriptionTest { .build() ) .addPrice( - Price.Unit.builder() + Price.UnitPrice.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -3919,12 +3933,14 @@ internal class MutatedSubscriptionTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .billingMode(Price.Unit.BillingMode.IN_ADVANCE) - .cadence(Price.Unit.Cadence.ONE_TIME) + .billingMode(Price.UnitPrice.BillingMode.IN_ADVANCE) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) .addCompositePriceFilter( - Price.Unit.CompositePriceFilter.builder() - .field(Price.Unit.CompositePriceFilter.Field.PRICE_ID) - .operator(Price.Unit.CompositePriceFilter.Operator.INCLUDES) + Price.UnitPrice.CompositePriceFilter.builder() + .field(Price.UnitPrice.CompositePriceFilter.Field.PRICE_ID) + .operator( + Price.UnitPrice.CompositePriceFilter.Operator.INCLUDES + ) .addValue("string") .build() ) @@ -3997,7 +4013,7 @@ internal class MutatedSubscriptionTest { ) .maximumAmount("maximum_amount") .metadata( - Price.Unit.Metadata.builder() + Price.UnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -4017,7 +4033,7 @@ internal class MutatedSubscriptionTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.Unit.PriceType.USAGE_PRICE) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( UnitConfig.builder() @@ -4071,7 +4087,7 @@ internal class MutatedSubscriptionTest { .build() ) .price( - Price.Unit.builder() + Price.UnitPrice.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -4080,12 +4096,14 @@ internal class MutatedSubscriptionTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .billingMode(Price.Unit.BillingMode.IN_ADVANCE) - .cadence(Price.Unit.Cadence.ONE_TIME) + .billingMode(Price.UnitPrice.BillingMode.IN_ADVANCE) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) .addCompositePriceFilter( - Price.Unit.CompositePriceFilter.builder() - .field(Price.Unit.CompositePriceFilter.Field.PRICE_ID) - .operator(Price.Unit.CompositePriceFilter.Operator.INCLUDES) + Price.UnitPrice.CompositePriceFilter.builder() + .field(Price.UnitPrice.CompositePriceFilter.Field.PRICE_ID) + .operator( + Price.UnitPrice.CompositePriceFilter.Operator.INCLUDES + ) .addValue("string") .build() ) @@ -4158,7 +4176,7 @@ internal class MutatedSubscriptionTest { ) .maximumAmount("maximum_amount") .metadata( - Price.Unit.Metadata.builder() + Price.UnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -4178,7 +4196,7 @@ internal class MutatedSubscriptionTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.Unit.PriceType.USAGE_PRICE) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( UnitConfig.builder() @@ -4515,7 +4533,7 @@ internal class MutatedSubscriptionTest { .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( - Price.Unit.builder() + Price.UnitPrice.builder() .id("id") .billableMetric( BillableMetricTiny.builder().id("id").build() @@ -4529,16 +4547,18 @@ internal class MutatedSubscriptionTest { ) .build() ) - .billingMode(Price.Unit.BillingMode.IN_ADVANCE) - .cadence(Price.Unit.Cadence.ONE_TIME) + .billingMode(Price.UnitPrice.BillingMode.IN_ADVANCE) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) .addCompositePriceFilter( - Price.Unit.CompositePriceFilter.builder() + Price.UnitPrice.CompositePriceFilter.builder() .field( - Price.Unit.CompositePriceFilter.Field + Price.UnitPrice.CompositePriceFilter + .Field .PRICE_ID ) .operator( - Price.Unit.CompositePriceFilter.Operator + Price.UnitPrice.CompositePriceFilter + .Operator .INCLUDES ) .addValue("string") @@ -4640,7 +4660,7 @@ internal class MutatedSubscriptionTest { ) .maximumAmount("maximum_amount") .metadata( - Price.Unit.Metadata.builder() + Price.UnitPrice.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -4667,7 +4687,7 @@ internal class MutatedSubscriptionTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.Unit.PriceType.USAGE_PRICE) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( UnitConfig.builder() @@ -5085,7 +5105,7 @@ internal class MutatedSubscriptionTest { .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( - Price.Unit.builder() + Price.UnitPrice.builder() .id("id") .billableMetric( BillableMetricTiny.builder().id("id").build() @@ -5099,16 +5119,18 @@ internal class MutatedSubscriptionTest { ) .build() ) - .billingMode(Price.Unit.BillingMode.IN_ADVANCE) - .cadence(Price.Unit.Cadence.ONE_TIME) + .billingMode(Price.UnitPrice.BillingMode.IN_ADVANCE) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) .addCompositePriceFilter( - Price.Unit.CompositePriceFilter.builder() + Price.UnitPrice.CompositePriceFilter.builder() .field( - Price.Unit.CompositePriceFilter.Field + Price.UnitPrice.CompositePriceFilter + .Field .PRICE_ID ) .operator( - Price.Unit.CompositePriceFilter.Operator + Price.UnitPrice.CompositePriceFilter + .Operator .INCLUDES ) .addValue("string") @@ -5210,7 +5232,7 @@ internal class MutatedSubscriptionTest { ) .maximumAmount("maximum_amount") .metadata( - Price.Unit.Metadata.builder() + Price.UnitPrice.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -5237,7 +5259,7 @@ internal class MutatedSubscriptionTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.Unit.PriceType.USAGE_PRICE) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( UnitConfig.builder() diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PerPriceCostTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PerPriceCostTest.kt index d3664707c..43dbfd2a7 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PerPriceCostTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PerPriceCostTest.kt @@ -16,7 +16,7 @@ internal class PerPriceCostTest { val perPriceCost = PerPriceCost.builder() .price( - Price.Unit.builder() + Price.UnitPrice.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -25,12 +25,12 @@ internal class PerPriceCostTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .billingMode(Price.Unit.BillingMode.IN_ADVANCE) - .cadence(Price.Unit.Cadence.ONE_TIME) + .billingMode(Price.UnitPrice.BillingMode.IN_ADVANCE) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) .addCompositePriceFilter( - Price.Unit.CompositePriceFilter.builder() - .field(Price.Unit.CompositePriceFilter.Field.PRICE_ID) - .operator(Price.Unit.CompositePriceFilter.Operator.INCLUDES) + Price.UnitPrice.CompositePriceFilter.builder() + .field(Price.UnitPrice.CompositePriceFilter.Field.PRICE_ID) + .operator(Price.UnitPrice.CompositePriceFilter.Operator.INCLUDES) .addValue("string") .build() ) @@ -99,7 +99,7 @@ internal class PerPriceCostTest { ) .maximumAmount("maximum_amount") .metadata( - Price.Unit.Metadata.builder() + Price.UnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -119,7 +119,7 @@ internal class PerPriceCostTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.Unit.PriceType.USAGE_PRICE) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( UnitConfig.builder().unitAmount("unit_amount").prorated(true).build() @@ -141,7 +141,7 @@ internal class PerPriceCostTest { assertThat(perPriceCost.price()) .isEqualTo( Price.ofUnit( - Price.Unit.builder() + Price.UnitPrice.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -150,12 +150,12 @@ internal class PerPriceCostTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .billingMode(Price.Unit.BillingMode.IN_ADVANCE) - .cadence(Price.Unit.Cadence.ONE_TIME) + .billingMode(Price.UnitPrice.BillingMode.IN_ADVANCE) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) .addCompositePriceFilter( - Price.Unit.CompositePriceFilter.builder() - .field(Price.Unit.CompositePriceFilter.Field.PRICE_ID) - .operator(Price.Unit.CompositePriceFilter.Operator.INCLUDES) + Price.UnitPrice.CompositePriceFilter.builder() + .field(Price.UnitPrice.CompositePriceFilter.Field.PRICE_ID) + .operator(Price.UnitPrice.CompositePriceFilter.Operator.INCLUDES) .addValue("string") .build() ) @@ -224,7 +224,7 @@ internal class PerPriceCostTest { ) .maximumAmount("maximum_amount") .metadata( - Price.Unit.Metadata.builder() + Price.UnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -244,7 +244,7 @@ internal class PerPriceCostTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.Unit.PriceType.USAGE_PRICE) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( UnitConfig.builder().unitAmount("unit_amount").prorated(true).build() @@ -270,7 +270,7 @@ internal class PerPriceCostTest { val perPriceCost = PerPriceCost.builder() .price( - Price.Unit.builder() + Price.UnitPrice.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -279,12 +279,12 @@ internal class PerPriceCostTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .billingMode(Price.Unit.BillingMode.IN_ADVANCE) - .cadence(Price.Unit.Cadence.ONE_TIME) + .billingMode(Price.UnitPrice.BillingMode.IN_ADVANCE) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) .addCompositePriceFilter( - Price.Unit.CompositePriceFilter.builder() - .field(Price.Unit.CompositePriceFilter.Field.PRICE_ID) - .operator(Price.Unit.CompositePriceFilter.Operator.INCLUDES) + Price.UnitPrice.CompositePriceFilter.builder() + .field(Price.UnitPrice.CompositePriceFilter.Field.PRICE_ID) + .operator(Price.UnitPrice.CompositePriceFilter.Operator.INCLUDES) .addValue("string") .build() ) @@ -353,7 +353,7 @@ internal class PerPriceCostTest { ) .maximumAmount("maximum_amount") .metadata( - Price.Unit.Metadata.builder() + Price.UnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -373,7 +373,7 @@ internal class PerPriceCostTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.Unit.PriceType.USAGE_PRICE) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( UnitConfig.builder().unitAmount("unit_amount").prorated(true).build() diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanListPageResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanListPageResponseTest.kt index 5c0b98e12..f88092a24 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanListPageResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanListPageResponseTest.kt @@ -166,7 +166,7 @@ internal class PlanListPageResponseTest { .build() ) .addPrice( - Price.Unit.builder() + Price.UnitPrice.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -175,12 +175,14 @@ internal class PlanListPageResponseTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .billingMode(Price.Unit.BillingMode.IN_ADVANCE) - .cadence(Price.Unit.Cadence.ONE_TIME) + .billingMode(Price.UnitPrice.BillingMode.IN_ADVANCE) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) .addCompositePriceFilter( - Price.Unit.CompositePriceFilter.builder() - .field(Price.Unit.CompositePriceFilter.Field.PRICE_ID) - .operator(Price.Unit.CompositePriceFilter.Operator.INCLUDES) + Price.UnitPrice.CompositePriceFilter.builder() + .field(Price.UnitPrice.CompositePriceFilter.Field.PRICE_ID) + .operator( + Price.UnitPrice.CompositePriceFilter.Operator.INCLUDES + ) .addValue("string") .build() ) @@ -253,7 +255,7 @@ internal class PlanListPageResponseTest { ) .maximumAmount("maximum_amount") .metadata( - Price.Unit.Metadata.builder() + Price.UnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -273,7 +275,7 @@ internal class PlanListPageResponseTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.Unit.PriceType.USAGE_PRICE) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( UnitConfig.builder() @@ -458,7 +460,7 @@ internal class PlanListPageResponseTest { .build() ) .addPrice( - Price.Unit.builder() + Price.UnitPrice.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -467,12 +469,14 @@ internal class PlanListPageResponseTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .billingMode(Price.Unit.BillingMode.IN_ADVANCE) - .cadence(Price.Unit.Cadence.ONE_TIME) + .billingMode(Price.UnitPrice.BillingMode.IN_ADVANCE) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) .addCompositePriceFilter( - Price.Unit.CompositePriceFilter.builder() - .field(Price.Unit.CompositePriceFilter.Field.PRICE_ID) - .operator(Price.Unit.CompositePriceFilter.Operator.INCLUDES) + Price.UnitPrice.CompositePriceFilter.builder() + .field(Price.UnitPrice.CompositePriceFilter.Field.PRICE_ID) + .operator( + Price.UnitPrice.CompositePriceFilter.Operator.INCLUDES + ) .addValue("string") .build() ) @@ -541,7 +545,7 @@ internal class PlanListPageResponseTest { ) .maximumAmount("maximum_amount") .metadata( - Price.Unit.Metadata.builder() + Price.UnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -561,7 +565,7 @@ internal class PlanListPageResponseTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.Unit.PriceType.USAGE_PRICE) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( UnitConfig.builder() @@ -754,7 +758,7 @@ internal class PlanListPageResponseTest { .build() ) .addPrice( - Price.Unit.builder() + Price.UnitPrice.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -763,12 +767,14 @@ internal class PlanListPageResponseTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .billingMode(Price.Unit.BillingMode.IN_ADVANCE) - .cadence(Price.Unit.Cadence.ONE_TIME) + .billingMode(Price.UnitPrice.BillingMode.IN_ADVANCE) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) .addCompositePriceFilter( - Price.Unit.CompositePriceFilter.builder() - .field(Price.Unit.CompositePriceFilter.Field.PRICE_ID) - .operator(Price.Unit.CompositePriceFilter.Operator.INCLUDES) + Price.UnitPrice.CompositePriceFilter.builder() + .field(Price.UnitPrice.CompositePriceFilter.Field.PRICE_ID) + .operator( + Price.UnitPrice.CompositePriceFilter.Operator.INCLUDES + ) .addValue("string") .build() ) @@ -841,7 +847,7 @@ internal class PlanListPageResponseTest { ) .maximumAmount("maximum_amount") .metadata( - Price.Unit.Metadata.builder() + Price.UnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -861,7 +867,7 @@ internal class PlanListPageResponseTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.Unit.PriceType.USAGE_PRICE) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( UnitConfig.builder() diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanTest.kt index 72b2e70fa..b62525d63 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanTest.kt @@ -157,7 +157,7 @@ internal class PlanTest { .build() ) .addPrice( - Price.Unit.builder() + Price.UnitPrice.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -166,12 +166,12 @@ internal class PlanTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .billingMode(Price.Unit.BillingMode.IN_ADVANCE) - .cadence(Price.Unit.Cadence.ONE_TIME) + .billingMode(Price.UnitPrice.BillingMode.IN_ADVANCE) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) .addCompositePriceFilter( - Price.Unit.CompositePriceFilter.builder() - .field(Price.Unit.CompositePriceFilter.Field.PRICE_ID) - .operator(Price.Unit.CompositePriceFilter.Operator.INCLUDES) + Price.UnitPrice.CompositePriceFilter.builder() + .field(Price.UnitPrice.CompositePriceFilter.Field.PRICE_ID) + .operator(Price.UnitPrice.CompositePriceFilter.Operator.INCLUDES) .addValue("string") .build() ) @@ -240,7 +240,7 @@ internal class PlanTest { ) .maximumAmount("maximum_amount") .metadata( - Price.Unit.Metadata.builder() + Price.UnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -260,7 +260,7 @@ internal class PlanTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.Unit.PriceType.USAGE_PRICE) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( UnitConfig.builder().unitAmount("unit_amount").prorated(true).build() @@ -445,7 +445,7 @@ internal class PlanTest { assertThat(plan.prices()) .containsExactly( Price.ofUnit( - Price.Unit.builder() + Price.UnitPrice.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -454,12 +454,12 @@ internal class PlanTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .billingMode(Price.Unit.BillingMode.IN_ADVANCE) - .cadence(Price.Unit.Cadence.ONE_TIME) + .billingMode(Price.UnitPrice.BillingMode.IN_ADVANCE) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) .addCompositePriceFilter( - Price.Unit.CompositePriceFilter.builder() - .field(Price.Unit.CompositePriceFilter.Field.PRICE_ID) - .operator(Price.Unit.CompositePriceFilter.Operator.INCLUDES) + Price.UnitPrice.CompositePriceFilter.builder() + .field(Price.UnitPrice.CompositePriceFilter.Field.PRICE_ID) + .operator(Price.UnitPrice.CompositePriceFilter.Operator.INCLUDES) .addValue("string") .build() ) @@ -528,7 +528,7 @@ internal class PlanTest { ) .maximumAmount("maximum_amount") .metadata( - Price.Unit.Metadata.builder() + Price.UnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -548,7 +548,7 @@ internal class PlanTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.Unit.PriceType.USAGE_PRICE) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( UnitConfig.builder().unitAmount("unit_amount").prorated(true).build() @@ -728,7 +728,7 @@ internal class PlanTest { .build() ) .addPrice( - Price.Unit.builder() + Price.UnitPrice.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -737,12 +737,12 @@ internal class PlanTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .billingMode(Price.Unit.BillingMode.IN_ADVANCE) - .cadence(Price.Unit.Cadence.ONE_TIME) + .billingMode(Price.UnitPrice.BillingMode.IN_ADVANCE) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) .addCompositePriceFilter( - Price.Unit.CompositePriceFilter.builder() - .field(Price.Unit.CompositePriceFilter.Field.PRICE_ID) - .operator(Price.Unit.CompositePriceFilter.Operator.INCLUDES) + Price.UnitPrice.CompositePriceFilter.builder() + .field(Price.UnitPrice.CompositePriceFilter.Field.PRICE_ID) + .operator(Price.UnitPrice.CompositePriceFilter.Operator.INCLUDES) .addValue("string") .build() ) @@ -811,7 +811,7 @@ internal class PlanTest { ) .maximumAmount("maximum_amount") .metadata( - Price.Unit.Metadata.builder() + Price.UnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -831,7 +831,7 @@ internal class PlanTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.Unit.PriceType.USAGE_PRICE) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( UnitConfig.builder().unitAmount("unit_amount").prorated(true).build() diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanVersionTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanVersionTest.kt index 222a2f141..9598f0122 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanVersionTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanVersionTest.kt @@ -48,7 +48,7 @@ internal class PlanVersionTest { .build() ) .addPrice( - Price.Unit.builder() + Price.UnitPrice.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -57,12 +57,12 @@ internal class PlanVersionTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .billingMode(Price.Unit.BillingMode.IN_ADVANCE) - .cadence(Price.Unit.Cadence.ONE_TIME) + .billingMode(Price.UnitPrice.BillingMode.IN_ADVANCE) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) .addCompositePriceFilter( - Price.Unit.CompositePriceFilter.builder() - .field(Price.Unit.CompositePriceFilter.Field.PRICE_ID) - .operator(Price.Unit.CompositePriceFilter.Operator.INCLUDES) + Price.UnitPrice.CompositePriceFilter.builder() + .field(Price.UnitPrice.CompositePriceFilter.Field.PRICE_ID) + .operator(Price.UnitPrice.CompositePriceFilter.Operator.INCLUDES) .addValue("string") .build() ) @@ -131,7 +131,7 @@ internal class PlanVersionTest { ) .maximumAmount("maximum_amount") .metadata( - Price.Unit.Metadata.builder() + Price.UnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -151,7 +151,7 @@ internal class PlanVersionTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.Unit.PriceType.USAGE_PRICE) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( UnitConfig.builder().unitAmount("unit_amount").prorated(true).build() @@ -207,7 +207,7 @@ internal class PlanVersionTest { assertThat(planVersion.prices()) .containsExactly( Price.ofUnit( - Price.Unit.builder() + Price.UnitPrice.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -216,12 +216,12 @@ internal class PlanVersionTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .billingMode(Price.Unit.BillingMode.IN_ADVANCE) - .cadence(Price.Unit.Cadence.ONE_TIME) + .billingMode(Price.UnitPrice.BillingMode.IN_ADVANCE) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) .addCompositePriceFilter( - Price.Unit.CompositePriceFilter.builder() - .field(Price.Unit.CompositePriceFilter.Field.PRICE_ID) - .operator(Price.Unit.CompositePriceFilter.Operator.INCLUDES) + Price.UnitPrice.CompositePriceFilter.builder() + .field(Price.UnitPrice.CompositePriceFilter.Field.PRICE_ID) + .operator(Price.UnitPrice.CompositePriceFilter.Operator.INCLUDES) .addValue("string") .build() ) @@ -290,7 +290,7 @@ internal class PlanVersionTest { ) .maximumAmount("maximum_amount") .metadata( - Price.Unit.Metadata.builder() + Price.UnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -310,7 +310,7 @@ internal class PlanVersionTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.Unit.PriceType.USAGE_PRICE) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( UnitConfig.builder().unitAmount("unit_amount").prorated(true).build() @@ -365,7 +365,7 @@ internal class PlanVersionTest { .build() ) .addPrice( - Price.Unit.builder() + Price.UnitPrice.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -374,12 +374,12 @@ internal class PlanVersionTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .billingMode(Price.Unit.BillingMode.IN_ADVANCE) - .cadence(Price.Unit.Cadence.ONE_TIME) + .billingMode(Price.UnitPrice.BillingMode.IN_ADVANCE) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) .addCompositePriceFilter( - Price.Unit.CompositePriceFilter.builder() - .field(Price.Unit.CompositePriceFilter.Field.PRICE_ID) - .operator(Price.Unit.CompositePriceFilter.Operator.INCLUDES) + Price.UnitPrice.CompositePriceFilter.builder() + .field(Price.UnitPrice.CompositePriceFilter.Field.PRICE_ID) + .operator(Price.UnitPrice.CompositePriceFilter.Operator.INCLUDES) .addValue("string") .build() ) @@ -448,7 +448,7 @@ internal class PlanVersionTest { ) .maximumAmount("maximum_amount") .metadata( - Price.Unit.Metadata.builder() + Price.UnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -468,7 +468,7 @@ internal class PlanVersionTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.Unit.PriceType.USAGE_PRICE) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( UnitConfig.builder().unitAmount("unit_amount").prorated(true).build() diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceIntervalTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceIntervalTest.kt index 0c04a3e0e..9beca844c 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceIntervalTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceIntervalTest.kt @@ -30,7 +30,7 @@ internal class PriceIntervalTest { .build() ) .price( - Price.Unit.builder() + Price.UnitPrice.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -39,12 +39,12 @@ internal class PriceIntervalTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .billingMode(Price.Unit.BillingMode.IN_ADVANCE) - .cadence(Price.Unit.Cadence.ONE_TIME) + .billingMode(Price.UnitPrice.BillingMode.IN_ADVANCE) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) .addCompositePriceFilter( - Price.Unit.CompositePriceFilter.builder() - .field(Price.Unit.CompositePriceFilter.Field.PRICE_ID) - .operator(Price.Unit.CompositePriceFilter.Operator.INCLUDES) + Price.UnitPrice.CompositePriceFilter.builder() + .field(Price.UnitPrice.CompositePriceFilter.Field.PRICE_ID) + .operator(Price.UnitPrice.CompositePriceFilter.Operator.INCLUDES) .addValue("string") .build() ) @@ -113,7 +113,7 @@ internal class PriceIntervalTest { ) .maximumAmount("maximum_amount") .metadata( - Price.Unit.Metadata.builder() + Price.UnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -133,7 +133,7 @@ internal class PriceIntervalTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.Unit.PriceType.USAGE_PRICE) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( UnitConfig.builder().unitAmount("unit_amount").prorated(true).build() @@ -171,7 +171,7 @@ internal class PriceIntervalTest { assertThat(priceInterval.price()) .isEqualTo( Price.ofUnit( - Price.Unit.builder() + Price.UnitPrice.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -180,12 +180,12 @@ internal class PriceIntervalTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .billingMode(Price.Unit.BillingMode.IN_ADVANCE) - .cadence(Price.Unit.Cadence.ONE_TIME) + .billingMode(Price.UnitPrice.BillingMode.IN_ADVANCE) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) .addCompositePriceFilter( - Price.Unit.CompositePriceFilter.builder() - .field(Price.Unit.CompositePriceFilter.Field.PRICE_ID) - .operator(Price.Unit.CompositePriceFilter.Operator.INCLUDES) + Price.UnitPrice.CompositePriceFilter.builder() + .field(Price.UnitPrice.CompositePriceFilter.Field.PRICE_ID) + .operator(Price.UnitPrice.CompositePriceFilter.Operator.INCLUDES) .addValue("string") .build() ) @@ -254,7 +254,7 @@ internal class PriceIntervalTest { ) .maximumAmount("maximum_amount") .metadata( - Price.Unit.Metadata.builder() + Price.UnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -274,7 +274,7 @@ internal class PriceIntervalTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.Unit.PriceType.USAGE_PRICE) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( UnitConfig.builder().unitAmount("unit_amount").prorated(true).build() @@ -313,7 +313,7 @@ internal class PriceIntervalTest { .build() ) .price( - Price.Unit.builder() + Price.UnitPrice.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -322,12 +322,12 @@ internal class PriceIntervalTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .billingMode(Price.Unit.BillingMode.IN_ADVANCE) - .cadence(Price.Unit.Cadence.ONE_TIME) + .billingMode(Price.UnitPrice.BillingMode.IN_ADVANCE) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) .addCompositePriceFilter( - Price.Unit.CompositePriceFilter.builder() - .field(Price.Unit.CompositePriceFilter.Field.PRICE_ID) - .operator(Price.Unit.CompositePriceFilter.Operator.INCLUDES) + Price.UnitPrice.CompositePriceFilter.builder() + .field(Price.UnitPrice.CompositePriceFilter.Field.PRICE_ID) + .operator(Price.UnitPrice.CompositePriceFilter.Operator.INCLUDES) .addValue("string") .build() ) @@ -396,7 +396,7 @@ internal class PriceIntervalTest { ) .maximumAmount("maximum_amount") .metadata( - Price.Unit.Metadata.builder() + Price.UnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -416,7 +416,7 @@ internal class PriceIntervalTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.Unit.PriceType.USAGE_PRICE) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( UnitConfig.builder().unitAmount("unit_amount").prorated(true).build() diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceListPageResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceListPageResponseTest.kt index d88dcc50a..adcd2fae7 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceListPageResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceListPageResponseTest.kt @@ -16,7 +16,7 @@ internal class PriceListPageResponseTest { val priceListPageResponse = PriceListPageResponse.builder() .addData( - Price.Unit.builder() + Price.UnitPrice.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -25,12 +25,12 @@ internal class PriceListPageResponseTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .billingMode(Price.Unit.BillingMode.IN_ADVANCE) - .cadence(Price.Unit.Cadence.ONE_TIME) + .billingMode(Price.UnitPrice.BillingMode.IN_ADVANCE) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) .addCompositePriceFilter( - Price.Unit.CompositePriceFilter.builder() - .field(Price.Unit.CompositePriceFilter.Field.PRICE_ID) - .operator(Price.Unit.CompositePriceFilter.Operator.INCLUDES) + Price.UnitPrice.CompositePriceFilter.builder() + .field(Price.UnitPrice.CompositePriceFilter.Field.PRICE_ID) + .operator(Price.UnitPrice.CompositePriceFilter.Operator.INCLUDES) .addValue("string") .build() ) @@ -99,7 +99,7 @@ internal class PriceListPageResponseTest { ) .maximumAmount("maximum_amount") .metadata( - Price.Unit.Metadata.builder() + Price.UnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -119,7 +119,7 @@ internal class PriceListPageResponseTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.Unit.PriceType.USAGE_PRICE) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( UnitConfig.builder().unitAmount("unit_amount").prorated(true).build() @@ -140,7 +140,7 @@ internal class PriceListPageResponseTest { assertThat(priceListPageResponse.data()) .containsExactly( Price.ofUnit( - Price.Unit.builder() + Price.UnitPrice.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -149,12 +149,12 @@ internal class PriceListPageResponseTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .billingMode(Price.Unit.BillingMode.IN_ADVANCE) - .cadence(Price.Unit.Cadence.ONE_TIME) + .billingMode(Price.UnitPrice.BillingMode.IN_ADVANCE) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) .addCompositePriceFilter( - Price.Unit.CompositePriceFilter.builder() - .field(Price.Unit.CompositePriceFilter.Field.PRICE_ID) - .operator(Price.Unit.CompositePriceFilter.Operator.INCLUDES) + Price.UnitPrice.CompositePriceFilter.builder() + .field(Price.UnitPrice.CompositePriceFilter.Field.PRICE_ID) + .operator(Price.UnitPrice.CompositePriceFilter.Operator.INCLUDES) .addValue("string") .build() ) @@ -223,7 +223,7 @@ internal class PriceListPageResponseTest { ) .maximumAmount("maximum_amount") .metadata( - Price.Unit.Metadata.builder() + Price.UnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -243,7 +243,7 @@ internal class PriceListPageResponseTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.Unit.PriceType.USAGE_PRICE) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( UnitConfig.builder().unitAmount("unit_amount").prorated(true).build() @@ -267,7 +267,7 @@ internal class PriceListPageResponseTest { val priceListPageResponse = PriceListPageResponse.builder() .addData( - Price.Unit.builder() + Price.UnitPrice.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -276,12 +276,12 @@ internal class PriceListPageResponseTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .billingMode(Price.Unit.BillingMode.IN_ADVANCE) - .cadence(Price.Unit.Cadence.ONE_TIME) + .billingMode(Price.UnitPrice.BillingMode.IN_ADVANCE) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) .addCompositePriceFilter( - Price.Unit.CompositePriceFilter.builder() - .field(Price.Unit.CompositePriceFilter.Field.PRICE_ID) - .operator(Price.Unit.CompositePriceFilter.Operator.INCLUDES) + Price.UnitPrice.CompositePriceFilter.builder() + .field(Price.UnitPrice.CompositePriceFilter.Field.PRICE_ID) + .operator(Price.UnitPrice.CompositePriceFilter.Operator.INCLUDES) .addValue("string") .build() ) @@ -350,7 +350,7 @@ internal class PriceListPageResponseTest { ) .maximumAmount("maximum_amount") .metadata( - Price.Unit.Metadata.builder() + Price.UnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -370,7 +370,7 @@ internal class PriceListPageResponseTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.Unit.PriceType.USAGE_PRICE) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( UnitConfig.builder().unitAmount("unit_amount").prorated(true).build() diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceTest.kt index cae5086b5..d35194549 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceTest.kt @@ -18,7 +18,7 @@ internal class PriceTest { @Test fun ofUnit() { val unit = - Price.Unit.builder() + Price.UnitPrice.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -27,12 +27,12 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .billingMode(Price.Unit.BillingMode.IN_ADVANCE) - .cadence(Price.Unit.Cadence.ONE_TIME) + .billingMode(Price.UnitPrice.BillingMode.IN_ADVANCE) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) .addCompositePriceFilter( - Price.Unit.CompositePriceFilter.builder() - .field(Price.Unit.CompositePriceFilter.Field.PRICE_ID) - .operator(Price.Unit.CompositePriceFilter.Operator.INCLUDES) + Price.UnitPrice.CompositePriceFilter.builder() + .field(Price.UnitPrice.CompositePriceFilter.Field.PRICE_ID) + .operator(Price.UnitPrice.CompositePriceFilter.Operator.INCLUDES) .addValue("string") .build() ) @@ -101,7 +101,7 @@ internal class PriceTest { ) .maximumAmount("maximum_amount") .metadata( - Price.Unit.Metadata.builder() + Price.UnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -121,7 +121,7 @@ internal class PriceTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.Unit.PriceType.USAGE_PRICE) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig(UnitConfig.builder().unitAmount("unit_amount").prorated(true).build()) .dimensionalPriceConfiguration( @@ -171,7 +171,7 @@ internal class PriceTest { val jsonMapper = jsonMapper() val price = Price.ofUnit( - Price.Unit.builder() + Price.UnitPrice.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -180,12 +180,12 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .billingMode(Price.Unit.BillingMode.IN_ADVANCE) - .cadence(Price.Unit.Cadence.ONE_TIME) + .billingMode(Price.UnitPrice.BillingMode.IN_ADVANCE) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) .addCompositePriceFilter( - Price.Unit.CompositePriceFilter.builder() - .field(Price.Unit.CompositePriceFilter.Field.PRICE_ID) - .operator(Price.Unit.CompositePriceFilter.Operator.INCLUDES) + Price.UnitPrice.CompositePriceFilter.builder() + .field(Price.UnitPrice.CompositePriceFilter.Field.PRICE_ID) + .operator(Price.UnitPrice.CompositePriceFilter.Operator.INCLUDES) .addValue("string") .build() ) @@ -254,7 +254,7 @@ internal class PriceTest { ) .maximumAmount("maximum_amount") .metadata( - Price.Unit.Metadata.builder() + Price.UnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -274,7 +274,7 @@ internal class PriceTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.Unit.PriceType.USAGE_PRICE) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( UnitConfig.builder().unitAmount("unit_amount").prorated(true).build() diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeApplyResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeApplyResponseTest.kt index 0370d784a..81d6567dd 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeApplyResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeApplyResponseTest.kt @@ -390,7 +390,7 @@ internal class SubscriptionChangeApplyResponseTest { .build() ) .addPrice( - Price.Unit.builder() + Price.UnitPrice.builder() .id("id") .billableMetric( BillableMetricTiny.builder().id("id").build() @@ -403,15 +403,16 @@ internal class SubscriptionChangeApplyResponseTest { ) .build() ) - .billingMode(Price.Unit.BillingMode.IN_ADVANCE) - .cadence(Price.Unit.Cadence.ONE_TIME) + .billingMode(Price.UnitPrice.BillingMode.IN_ADVANCE) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) .addCompositePriceFilter( - Price.Unit.CompositePriceFilter.builder() + Price.UnitPrice.CompositePriceFilter.builder() .field( - Price.Unit.CompositePriceFilter.Field.PRICE_ID + Price.UnitPrice.CompositePriceFilter.Field + .PRICE_ID ) .operator( - Price.Unit.CompositePriceFilter.Operator + Price.UnitPrice.CompositePriceFilter.Operator .INCLUDES ) .addValue("string") @@ -497,7 +498,7 @@ internal class SubscriptionChangeApplyResponseTest { ) .maximumAmount("maximum_amount") .metadata( - Price.Unit.Metadata.builder() + Price.UnitPrice.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -520,7 +521,7 @@ internal class SubscriptionChangeApplyResponseTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.Unit.PriceType.USAGE_PRICE) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( UnitConfig.builder() @@ -578,7 +579,7 @@ internal class SubscriptionChangeApplyResponseTest { .build() ) .price( - Price.Unit.builder() + Price.UnitPrice.builder() .id("id") .billableMetric( BillableMetricTiny.builder().id("id").build() @@ -591,15 +592,16 @@ internal class SubscriptionChangeApplyResponseTest { ) .build() ) - .billingMode(Price.Unit.BillingMode.IN_ADVANCE) - .cadence(Price.Unit.Cadence.ONE_TIME) + .billingMode(Price.UnitPrice.BillingMode.IN_ADVANCE) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) .addCompositePriceFilter( - Price.Unit.CompositePriceFilter.builder() + Price.UnitPrice.CompositePriceFilter.builder() .field( - Price.Unit.CompositePriceFilter.Field.PRICE_ID + Price.UnitPrice.CompositePriceFilter.Field + .PRICE_ID ) .operator( - Price.Unit.CompositePriceFilter.Operator + Price.UnitPrice.CompositePriceFilter.Operator .INCLUDES ) .addValue("string") @@ -685,7 +687,7 @@ internal class SubscriptionChangeApplyResponseTest { ) .maximumAmount("maximum_amount") .metadata( - Price.Unit.Metadata.builder() + Price.UnitPrice.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -708,7 +710,7 @@ internal class SubscriptionChangeApplyResponseTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.Unit.PriceType.USAGE_PRICE) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( UnitConfig.builder() @@ -1099,7 +1101,7 @@ internal class SubscriptionChangeApplyResponseTest { .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( - Price.Unit.builder() + Price.UnitPrice.builder() .id("id") .billableMetric( BillableMetricTiny.builder() @@ -1117,19 +1119,21 @@ internal class SubscriptionChangeApplyResponseTest { .build() ) .billingMode( - Price.Unit.BillingMode.IN_ADVANCE + Price.UnitPrice.BillingMode.IN_ADVANCE ) - .cadence(Price.Unit.Cadence.ONE_TIME) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) .addCompositePriceFilter( - Price.Unit.CompositePriceFilter + Price.UnitPrice.CompositePriceFilter .builder() .field( - Price.Unit.CompositePriceFilter + Price.UnitPrice + .CompositePriceFilter .Field .PRICE_ID ) .operator( - Price.Unit.CompositePriceFilter + Price.UnitPrice + .CompositePriceFilter .Operator .INCLUDES ) @@ -1251,7 +1255,7 @@ internal class SubscriptionChangeApplyResponseTest { ) .maximumAmount("maximum_amount") .metadata( - Price.Unit.Metadata.builder() + Price.UnitPrice.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -1280,7 +1284,9 @@ internal class SubscriptionChangeApplyResponseTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.Unit.PriceType.USAGE_PRICE) + .priceType( + Price.UnitPrice.PriceType.USAGE_PRICE + ) .replacesPriceId("replaces_price_id") .unitConfig( UnitConfig.builder() @@ -1771,7 +1777,7 @@ internal class SubscriptionChangeApplyResponseTest { .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( - Price.Unit.builder() + Price.UnitPrice.builder() .id("id") .billableMetric( BillableMetricTiny.builder() @@ -1789,19 +1795,21 @@ internal class SubscriptionChangeApplyResponseTest { .build() ) .billingMode( - Price.Unit.BillingMode.IN_ADVANCE + Price.UnitPrice.BillingMode.IN_ADVANCE ) - .cadence(Price.Unit.Cadence.ONE_TIME) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) .addCompositePriceFilter( - Price.Unit.CompositePriceFilter + Price.UnitPrice.CompositePriceFilter .builder() .field( - Price.Unit.CompositePriceFilter + Price.UnitPrice + .CompositePriceFilter .Field .PRICE_ID ) .operator( - Price.Unit.CompositePriceFilter + Price.UnitPrice + .CompositePriceFilter .Operator .INCLUDES ) @@ -1923,7 +1931,7 @@ internal class SubscriptionChangeApplyResponseTest { ) .maximumAmount("maximum_amount") .metadata( - Price.Unit.Metadata.builder() + Price.UnitPrice.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -1952,7 +1960,9 @@ internal class SubscriptionChangeApplyResponseTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.Unit.PriceType.USAGE_PRICE) + .priceType( + Price.UnitPrice.PriceType.USAGE_PRICE + ) .replacesPriceId("replaces_price_id") .unitConfig( UnitConfig.builder() @@ -2469,7 +2479,7 @@ internal class SubscriptionChangeApplyResponseTest { .build() ) .addPrice( - Price.Unit.builder() + Price.UnitPrice.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -2480,13 +2490,16 @@ internal class SubscriptionChangeApplyResponseTest { ) .build() ) - .billingMode(Price.Unit.BillingMode.IN_ADVANCE) - .cadence(Price.Unit.Cadence.ONE_TIME) + .billingMode(Price.UnitPrice.BillingMode.IN_ADVANCE) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) .addCompositePriceFilter( - Price.Unit.CompositePriceFilter.builder() - .field(Price.Unit.CompositePriceFilter.Field.PRICE_ID) + Price.UnitPrice.CompositePriceFilter.builder() + .field( + Price.UnitPrice.CompositePriceFilter.Field.PRICE_ID + ) .operator( - Price.Unit.CompositePriceFilter.Operator.INCLUDES + Price.UnitPrice.CompositePriceFilter.Operator + .INCLUDES ) .addValue("string") .build() @@ -2564,7 +2577,7 @@ internal class SubscriptionChangeApplyResponseTest { ) .maximumAmount("maximum_amount") .metadata( - Price.Unit.Metadata.builder() + Price.UnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -2584,7 +2597,7 @@ internal class SubscriptionChangeApplyResponseTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.Unit.PriceType.USAGE_PRICE) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( UnitConfig.builder() @@ -2638,7 +2651,7 @@ internal class SubscriptionChangeApplyResponseTest { .build() ) .price( - Price.Unit.builder() + Price.UnitPrice.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -2649,13 +2662,16 @@ internal class SubscriptionChangeApplyResponseTest { ) .build() ) - .billingMode(Price.Unit.BillingMode.IN_ADVANCE) - .cadence(Price.Unit.Cadence.ONE_TIME) + .billingMode(Price.UnitPrice.BillingMode.IN_ADVANCE) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) .addCompositePriceFilter( - Price.Unit.CompositePriceFilter.builder() - .field(Price.Unit.CompositePriceFilter.Field.PRICE_ID) + Price.UnitPrice.CompositePriceFilter.builder() + .field( + Price.UnitPrice.CompositePriceFilter.Field.PRICE_ID + ) .operator( - Price.Unit.CompositePriceFilter.Operator.INCLUDES + Price.UnitPrice.CompositePriceFilter.Operator + .INCLUDES ) .addValue("string") .build() @@ -2733,7 +2749,7 @@ internal class SubscriptionChangeApplyResponseTest { ) .maximumAmount("maximum_amount") .metadata( - Price.Unit.Metadata.builder() + Price.UnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -2753,7 +2769,7 @@ internal class SubscriptionChangeApplyResponseTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.Unit.PriceType.USAGE_PRICE) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( UnitConfig.builder() @@ -3111,7 +3127,7 @@ internal class SubscriptionChangeApplyResponseTest { .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( - Price.Unit.builder() + Price.UnitPrice.builder() .id("id") .billableMetric( BillableMetricTiny.builder() @@ -3128,17 +3144,20 @@ internal class SubscriptionChangeApplyResponseTest { ) .build() ) - .billingMode(Price.Unit.BillingMode.IN_ADVANCE) - .cadence(Price.Unit.Cadence.ONE_TIME) + .billingMode( + Price.UnitPrice.BillingMode.IN_ADVANCE + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) .addCompositePriceFilter( - Price.Unit.CompositePriceFilter.builder() + Price.UnitPrice.CompositePriceFilter + .builder() .field( - Price.Unit.CompositePriceFilter + Price.UnitPrice.CompositePriceFilter .Field .PRICE_ID ) .operator( - Price.Unit.CompositePriceFilter + Price.UnitPrice.CompositePriceFilter .Operator .INCLUDES ) @@ -3252,7 +3271,7 @@ internal class SubscriptionChangeApplyResponseTest { ) .maximumAmount("maximum_amount") .metadata( - Price.Unit.Metadata.builder() + Price.UnitPrice.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -3281,7 +3300,9 @@ internal class SubscriptionChangeApplyResponseTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.Unit.PriceType.USAGE_PRICE) + .priceType( + Price.UnitPrice.PriceType.USAGE_PRICE + ) .replacesPriceId("replaces_price_id") .unitConfig( UnitConfig.builder() @@ -3731,7 +3752,7 @@ internal class SubscriptionChangeApplyResponseTest { .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( - Price.Unit.builder() + Price.UnitPrice.builder() .id("id") .billableMetric( BillableMetricTiny.builder() @@ -3748,17 +3769,20 @@ internal class SubscriptionChangeApplyResponseTest { ) .build() ) - .billingMode(Price.Unit.BillingMode.IN_ADVANCE) - .cadence(Price.Unit.Cadence.ONE_TIME) + .billingMode( + Price.UnitPrice.BillingMode.IN_ADVANCE + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) .addCompositePriceFilter( - Price.Unit.CompositePriceFilter.builder() + Price.UnitPrice.CompositePriceFilter + .builder() .field( - Price.Unit.CompositePriceFilter + Price.UnitPrice.CompositePriceFilter .Field .PRICE_ID ) .operator( - Price.Unit.CompositePriceFilter + Price.UnitPrice.CompositePriceFilter .Operator .INCLUDES ) @@ -3872,7 +3896,7 @@ internal class SubscriptionChangeApplyResponseTest { ) .maximumAmount("maximum_amount") .metadata( - Price.Unit.Metadata.builder() + Price.UnitPrice.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -3901,7 +3925,9 @@ internal class SubscriptionChangeApplyResponseTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.Unit.PriceType.USAGE_PRICE) + .priceType( + Price.UnitPrice.PriceType.USAGE_PRICE + ) .replacesPriceId("replaces_price_id") .unitConfig( UnitConfig.builder() @@ -4428,7 +4454,7 @@ internal class SubscriptionChangeApplyResponseTest { .build() ) .addPrice( - Price.Unit.builder() + Price.UnitPrice.builder() .id("id") .billableMetric( BillableMetricTiny.builder().id("id").build() @@ -4441,15 +4467,16 @@ internal class SubscriptionChangeApplyResponseTest { ) .build() ) - .billingMode(Price.Unit.BillingMode.IN_ADVANCE) - .cadence(Price.Unit.Cadence.ONE_TIME) + .billingMode(Price.UnitPrice.BillingMode.IN_ADVANCE) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) .addCompositePriceFilter( - Price.Unit.CompositePriceFilter.builder() + Price.UnitPrice.CompositePriceFilter.builder() .field( - Price.Unit.CompositePriceFilter.Field.PRICE_ID + Price.UnitPrice.CompositePriceFilter.Field + .PRICE_ID ) .operator( - Price.Unit.CompositePriceFilter.Operator + Price.UnitPrice.CompositePriceFilter.Operator .INCLUDES ) .addValue("string") @@ -4535,7 +4562,7 @@ internal class SubscriptionChangeApplyResponseTest { ) .maximumAmount("maximum_amount") .metadata( - Price.Unit.Metadata.builder() + Price.UnitPrice.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -4558,7 +4585,7 @@ internal class SubscriptionChangeApplyResponseTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.Unit.PriceType.USAGE_PRICE) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( UnitConfig.builder() @@ -4616,7 +4643,7 @@ internal class SubscriptionChangeApplyResponseTest { .build() ) .price( - Price.Unit.builder() + Price.UnitPrice.builder() .id("id") .billableMetric( BillableMetricTiny.builder().id("id").build() @@ -4629,15 +4656,16 @@ internal class SubscriptionChangeApplyResponseTest { ) .build() ) - .billingMode(Price.Unit.BillingMode.IN_ADVANCE) - .cadence(Price.Unit.Cadence.ONE_TIME) + .billingMode(Price.UnitPrice.BillingMode.IN_ADVANCE) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) .addCompositePriceFilter( - Price.Unit.CompositePriceFilter.builder() + Price.UnitPrice.CompositePriceFilter.builder() .field( - Price.Unit.CompositePriceFilter.Field.PRICE_ID + Price.UnitPrice.CompositePriceFilter.Field + .PRICE_ID ) .operator( - Price.Unit.CompositePriceFilter.Operator + Price.UnitPrice.CompositePriceFilter.Operator .INCLUDES ) .addValue("string") @@ -4723,7 +4751,7 @@ internal class SubscriptionChangeApplyResponseTest { ) .maximumAmount("maximum_amount") .metadata( - Price.Unit.Metadata.builder() + Price.UnitPrice.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -4746,7 +4774,7 @@ internal class SubscriptionChangeApplyResponseTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.Unit.PriceType.USAGE_PRICE) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( UnitConfig.builder() @@ -5137,7 +5165,7 @@ internal class SubscriptionChangeApplyResponseTest { .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( - Price.Unit.builder() + Price.UnitPrice.builder() .id("id") .billableMetric( BillableMetricTiny.builder() @@ -5155,19 +5183,21 @@ internal class SubscriptionChangeApplyResponseTest { .build() ) .billingMode( - Price.Unit.BillingMode.IN_ADVANCE + Price.UnitPrice.BillingMode.IN_ADVANCE ) - .cadence(Price.Unit.Cadence.ONE_TIME) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) .addCompositePriceFilter( - Price.Unit.CompositePriceFilter + Price.UnitPrice.CompositePriceFilter .builder() .field( - Price.Unit.CompositePriceFilter + Price.UnitPrice + .CompositePriceFilter .Field .PRICE_ID ) .operator( - Price.Unit.CompositePriceFilter + Price.UnitPrice + .CompositePriceFilter .Operator .INCLUDES ) @@ -5289,7 +5319,7 @@ internal class SubscriptionChangeApplyResponseTest { ) .maximumAmount("maximum_amount") .metadata( - Price.Unit.Metadata.builder() + Price.UnitPrice.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -5318,7 +5348,9 @@ internal class SubscriptionChangeApplyResponseTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.Unit.PriceType.USAGE_PRICE) + .priceType( + Price.UnitPrice.PriceType.USAGE_PRICE + ) .replacesPriceId("replaces_price_id") .unitConfig( UnitConfig.builder() @@ -5809,7 +5841,7 @@ internal class SubscriptionChangeApplyResponseTest { .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( - Price.Unit.builder() + Price.UnitPrice.builder() .id("id") .billableMetric( BillableMetricTiny.builder() @@ -5827,19 +5859,21 @@ internal class SubscriptionChangeApplyResponseTest { .build() ) .billingMode( - Price.Unit.BillingMode.IN_ADVANCE + Price.UnitPrice.BillingMode.IN_ADVANCE ) - .cadence(Price.Unit.Cadence.ONE_TIME) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) .addCompositePriceFilter( - Price.Unit.CompositePriceFilter + Price.UnitPrice.CompositePriceFilter .builder() .field( - Price.Unit.CompositePriceFilter + Price.UnitPrice + .CompositePriceFilter .Field .PRICE_ID ) .operator( - Price.Unit.CompositePriceFilter + Price.UnitPrice + .CompositePriceFilter .Operator .INCLUDES ) @@ -5961,7 +5995,7 @@ internal class SubscriptionChangeApplyResponseTest { ) .maximumAmount("maximum_amount") .metadata( - Price.Unit.Metadata.builder() + Price.UnitPrice.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -5990,7 +6024,9 @@ internal class SubscriptionChangeApplyResponseTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.Unit.PriceType.USAGE_PRICE) + .priceType( + Price.UnitPrice.PriceType.USAGE_PRICE + ) .replacesPriceId("replaces_price_id") .unitConfig( UnitConfig.builder() diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeCancelResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeCancelResponseTest.kt index 46fe8e38f..050557ecd 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeCancelResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeCancelResponseTest.kt @@ -390,7 +390,7 @@ internal class SubscriptionChangeCancelResponseTest { .build() ) .addPrice( - Price.Unit.builder() + Price.UnitPrice.builder() .id("id") .billableMetric( BillableMetricTiny.builder().id("id").build() @@ -403,15 +403,16 @@ internal class SubscriptionChangeCancelResponseTest { ) .build() ) - .billingMode(Price.Unit.BillingMode.IN_ADVANCE) - .cadence(Price.Unit.Cadence.ONE_TIME) + .billingMode(Price.UnitPrice.BillingMode.IN_ADVANCE) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) .addCompositePriceFilter( - Price.Unit.CompositePriceFilter.builder() + Price.UnitPrice.CompositePriceFilter.builder() .field( - Price.Unit.CompositePriceFilter.Field.PRICE_ID + Price.UnitPrice.CompositePriceFilter.Field + .PRICE_ID ) .operator( - Price.Unit.CompositePriceFilter.Operator + Price.UnitPrice.CompositePriceFilter.Operator .INCLUDES ) .addValue("string") @@ -497,7 +498,7 @@ internal class SubscriptionChangeCancelResponseTest { ) .maximumAmount("maximum_amount") .metadata( - Price.Unit.Metadata.builder() + Price.UnitPrice.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -520,7 +521,7 @@ internal class SubscriptionChangeCancelResponseTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.Unit.PriceType.USAGE_PRICE) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( UnitConfig.builder() @@ -578,7 +579,7 @@ internal class SubscriptionChangeCancelResponseTest { .build() ) .price( - Price.Unit.builder() + Price.UnitPrice.builder() .id("id") .billableMetric( BillableMetricTiny.builder().id("id").build() @@ -591,15 +592,16 @@ internal class SubscriptionChangeCancelResponseTest { ) .build() ) - .billingMode(Price.Unit.BillingMode.IN_ADVANCE) - .cadence(Price.Unit.Cadence.ONE_TIME) + .billingMode(Price.UnitPrice.BillingMode.IN_ADVANCE) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) .addCompositePriceFilter( - Price.Unit.CompositePriceFilter.builder() + Price.UnitPrice.CompositePriceFilter.builder() .field( - Price.Unit.CompositePriceFilter.Field.PRICE_ID + Price.UnitPrice.CompositePriceFilter.Field + .PRICE_ID ) .operator( - Price.Unit.CompositePriceFilter.Operator + Price.UnitPrice.CompositePriceFilter.Operator .INCLUDES ) .addValue("string") @@ -685,7 +687,7 @@ internal class SubscriptionChangeCancelResponseTest { ) .maximumAmount("maximum_amount") .metadata( - Price.Unit.Metadata.builder() + Price.UnitPrice.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -708,7 +710,7 @@ internal class SubscriptionChangeCancelResponseTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.Unit.PriceType.USAGE_PRICE) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( UnitConfig.builder() @@ -1099,7 +1101,7 @@ internal class SubscriptionChangeCancelResponseTest { .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( - Price.Unit.builder() + Price.UnitPrice.builder() .id("id") .billableMetric( BillableMetricTiny.builder() @@ -1117,19 +1119,21 @@ internal class SubscriptionChangeCancelResponseTest { .build() ) .billingMode( - Price.Unit.BillingMode.IN_ADVANCE + Price.UnitPrice.BillingMode.IN_ADVANCE ) - .cadence(Price.Unit.Cadence.ONE_TIME) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) .addCompositePriceFilter( - Price.Unit.CompositePriceFilter + Price.UnitPrice.CompositePriceFilter .builder() .field( - Price.Unit.CompositePriceFilter + Price.UnitPrice + .CompositePriceFilter .Field .PRICE_ID ) .operator( - Price.Unit.CompositePriceFilter + Price.UnitPrice + .CompositePriceFilter .Operator .INCLUDES ) @@ -1251,7 +1255,7 @@ internal class SubscriptionChangeCancelResponseTest { ) .maximumAmount("maximum_amount") .metadata( - Price.Unit.Metadata.builder() + Price.UnitPrice.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -1280,7 +1284,9 @@ internal class SubscriptionChangeCancelResponseTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.Unit.PriceType.USAGE_PRICE) + .priceType( + Price.UnitPrice.PriceType.USAGE_PRICE + ) .replacesPriceId("replaces_price_id") .unitConfig( UnitConfig.builder() @@ -1771,7 +1777,7 @@ internal class SubscriptionChangeCancelResponseTest { .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( - Price.Unit.builder() + Price.UnitPrice.builder() .id("id") .billableMetric( BillableMetricTiny.builder() @@ -1789,19 +1795,21 @@ internal class SubscriptionChangeCancelResponseTest { .build() ) .billingMode( - Price.Unit.BillingMode.IN_ADVANCE + Price.UnitPrice.BillingMode.IN_ADVANCE ) - .cadence(Price.Unit.Cadence.ONE_TIME) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) .addCompositePriceFilter( - Price.Unit.CompositePriceFilter + Price.UnitPrice.CompositePriceFilter .builder() .field( - Price.Unit.CompositePriceFilter + Price.UnitPrice + .CompositePriceFilter .Field .PRICE_ID ) .operator( - Price.Unit.CompositePriceFilter + Price.UnitPrice + .CompositePriceFilter .Operator .INCLUDES ) @@ -1923,7 +1931,7 @@ internal class SubscriptionChangeCancelResponseTest { ) .maximumAmount("maximum_amount") .metadata( - Price.Unit.Metadata.builder() + Price.UnitPrice.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -1952,7 +1960,9 @@ internal class SubscriptionChangeCancelResponseTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.Unit.PriceType.USAGE_PRICE) + .priceType( + Price.UnitPrice.PriceType.USAGE_PRICE + ) .replacesPriceId("replaces_price_id") .unitConfig( UnitConfig.builder() @@ -2469,7 +2479,7 @@ internal class SubscriptionChangeCancelResponseTest { .build() ) .addPrice( - Price.Unit.builder() + Price.UnitPrice.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -2480,13 +2490,16 @@ internal class SubscriptionChangeCancelResponseTest { ) .build() ) - .billingMode(Price.Unit.BillingMode.IN_ADVANCE) - .cadence(Price.Unit.Cadence.ONE_TIME) + .billingMode(Price.UnitPrice.BillingMode.IN_ADVANCE) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) .addCompositePriceFilter( - Price.Unit.CompositePriceFilter.builder() - .field(Price.Unit.CompositePriceFilter.Field.PRICE_ID) + Price.UnitPrice.CompositePriceFilter.builder() + .field( + Price.UnitPrice.CompositePriceFilter.Field.PRICE_ID + ) .operator( - Price.Unit.CompositePriceFilter.Operator.INCLUDES + Price.UnitPrice.CompositePriceFilter.Operator + .INCLUDES ) .addValue("string") .build() @@ -2564,7 +2577,7 @@ internal class SubscriptionChangeCancelResponseTest { ) .maximumAmount("maximum_amount") .metadata( - Price.Unit.Metadata.builder() + Price.UnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -2584,7 +2597,7 @@ internal class SubscriptionChangeCancelResponseTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.Unit.PriceType.USAGE_PRICE) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( UnitConfig.builder() @@ -2638,7 +2651,7 @@ internal class SubscriptionChangeCancelResponseTest { .build() ) .price( - Price.Unit.builder() + Price.UnitPrice.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -2649,13 +2662,16 @@ internal class SubscriptionChangeCancelResponseTest { ) .build() ) - .billingMode(Price.Unit.BillingMode.IN_ADVANCE) - .cadence(Price.Unit.Cadence.ONE_TIME) + .billingMode(Price.UnitPrice.BillingMode.IN_ADVANCE) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) .addCompositePriceFilter( - Price.Unit.CompositePriceFilter.builder() - .field(Price.Unit.CompositePriceFilter.Field.PRICE_ID) + Price.UnitPrice.CompositePriceFilter.builder() + .field( + Price.UnitPrice.CompositePriceFilter.Field.PRICE_ID + ) .operator( - Price.Unit.CompositePriceFilter.Operator.INCLUDES + Price.UnitPrice.CompositePriceFilter.Operator + .INCLUDES ) .addValue("string") .build() @@ -2733,7 +2749,7 @@ internal class SubscriptionChangeCancelResponseTest { ) .maximumAmount("maximum_amount") .metadata( - Price.Unit.Metadata.builder() + Price.UnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -2753,7 +2769,7 @@ internal class SubscriptionChangeCancelResponseTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.Unit.PriceType.USAGE_PRICE) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( UnitConfig.builder() @@ -3111,7 +3127,7 @@ internal class SubscriptionChangeCancelResponseTest { .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( - Price.Unit.builder() + Price.UnitPrice.builder() .id("id") .billableMetric( BillableMetricTiny.builder() @@ -3128,17 +3144,20 @@ internal class SubscriptionChangeCancelResponseTest { ) .build() ) - .billingMode(Price.Unit.BillingMode.IN_ADVANCE) - .cadence(Price.Unit.Cadence.ONE_TIME) + .billingMode( + Price.UnitPrice.BillingMode.IN_ADVANCE + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) .addCompositePriceFilter( - Price.Unit.CompositePriceFilter.builder() + Price.UnitPrice.CompositePriceFilter + .builder() .field( - Price.Unit.CompositePriceFilter + Price.UnitPrice.CompositePriceFilter .Field .PRICE_ID ) .operator( - Price.Unit.CompositePriceFilter + Price.UnitPrice.CompositePriceFilter .Operator .INCLUDES ) @@ -3252,7 +3271,7 @@ internal class SubscriptionChangeCancelResponseTest { ) .maximumAmount("maximum_amount") .metadata( - Price.Unit.Metadata.builder() + Price.UnitPrice.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -3281,7 +3300,9 @@ internal class SubscriptionChangeCancelResponseTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.Unit.PriceType.USAGE_PRICE) + .priceType( + Price.UnitPrice.PriceType.USAGE_PRICE + ) .replacesPriceId("replaces_price_id") .unitConfig( UnitConfig.builder() @@ -3731,7 +3752,7 @@ internal class SubscriptionChangeCancelResponseTest { .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( - Price.Unit.builder() + Price.UnitPrice.builder() .id("id") .billableMetric( BillableMetricTiny.builder() @@ -3748,17 +3769,20 @@ internal class SubscriptionChangeCancelResponseTest { ) .build() ) - .billingMode(Price.Unit.BillingMode.IN_ADVANCE) - .cadence(Price.Unit.Cadence.ONE_TIME) + .billingMode( + Price.UnitPrice.BillingMode.IN_ADVANCE + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) .addCompositePriceFilter( - Price.Unit.CompositePriceFilter.builder() + Price.UnitPrice.CompositePriceFilter + .builder() .field( - Price.Unit.CompositePriceFilter + Price.UnitPrice.CompositePriceFilter .Field .PRICE_ID ) .operator( - Price.Unit.CompositePriceFilter + Price.UnitPrice.CompositePriceFilter .Operator .INCLUDES ) @@ -3872,7 +3896,7 @@ internal class SubscriptionChangeCancelResponseTest { ) .maximumAmount("maximum_amount") .metadata( - Price.Unit.Metadata.builder() + Price.UnitPrice.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -3901,7 +3925,9 @@ internal class SubscriptionChangeCancelResponseTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.Unit.PriceType.USAGE_PRICE) + .priceType( + Price.UnitPrice.PriceType.USAGE_PRICE + ) .replacesPriceId("replaces_price_id") .unitConfig( UnitConfig.builder() @@ -4428,7 +4454,7 @@ internal class SubscriptionChangeCancelResponseTest { .build() ) .addPrice( - Price.Unit.builder() + Price.UnitPrice.builder() .id("id") .billableMetric( BillableMetricTiny.builder().id("id").build() @@ -4441,15 +4467,16 @@ internal class SubscriptionChangeCancelResponseTest { ) .build() ) - .billingMode(Price.Unit.BillingMode.IN_ADVANCE) - .cadence(Price.Unit.Cadence.ONE_TIME) + .billingMode(Price.UnitPrice.BillingMode.IN_ADVANCE) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) .addCompositePriceFilter( - Price.Unit.CompositePriceFilter.builder() + Price.UnitPrice.CompositePriceFilter.builder() .field( - Price.Unit.CompositePriceFilter.Field.PRICE_ID + Price.UnitPrice.CompositePriceFilter.Field + .PRICE_ID ) .operator( - Price.Unit.CompositePriceFilter.Operator + Price.UnitPrice.CompositePriceFilter.Operator .INCLUDES ) .addValue("string") @@ -4535,7 +4562,7 @@ internal class SubscriptionChangeCancelResponseTest { ) .maximumAmount("maximum_amount") .metadata( - Price.Unit.Metadata.builder() + Price.UnitPrice.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -4558,7 +4585,7 @@ internal class SubscriptionChangeCancelResponseTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.Unit.PriceType.USAGE_PRICE) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( UnitConfig.builder() @@ -4616,7 +4643,7 @@ internal class SubscriptionChangeCancelResponseTest { .build() ) .price( - Price.Unit.builder() + Price.UnitPrice.builder() .id("id") .billableMetric( BillableMetricTiny.builder().id("id").build() @@ -4629,15 +4656,16 @@ internal class SubscriptionChangeCancelResponseTest { ) .build() ) - .billingMode(Price.Unit.BillingMode.IN_ADVANCE) - .cadence(Price.Unit.Cadence.ONE_TIME) + .billingMode(Price.UnitPrice.BillingMode.IN_ADVANCE) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) .addCompositePriceFilter( - Price.Unit.CompositePriceFilter.builder() + Price.UnitPrice.CompositePriceFilter.builder() .field( - Price.Unit.CompositePriceFilter.Field.PRICE_ID + Price.UnitPrice.CompositePriceFilter.Field + .PRICE_ID ) .operator( - Price.Unit.CompositePriceFilter.Operator + Price.UnitPrice.CompositePriceFilter.Operator .INCLUDES ) .addValue("string") @@ -4723,7 +4751,7 @@ internal class SubscriptionChangeCancelResponseTest { ) .maximumAmount("maximum_amount") .metadata( - Price.Unit.Metadata.builder() + Price.UnitPrice.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -4746,7 +4774,7 @@ internal class SubscriptionChangeCancelResponseTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.Unit.PriceType.USAGE_PRICE) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( UnitConfig.builder() @@ -5137,7 +5165,7 @@ internal class SubscriptionChangeCancelResponseTest { .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( - Price.Unit.builder() + Price.UnitPrice.builder() .id("id") .billableMetric( BillableMetricTiny.builder() @@ -5155,19 +5183,21 @@ internal class SubscriptionChangeCancelResponseTest { .build() ) .billingMode( - Price.Unit.BillingMode.IN_ADVANCE + Price.UnitPrice.BillingMode.IN_ADVANCE ) - .cadence(Price.Unit.Cadence.ONE_TIME) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) .addCompositePriceFilter( - Price.Unit.CompositePriceFilter + Price.UnitPrice.CompositePriceFilter .builder() .field( - Price.Unit.CompositePriceFilter + Price.UnitPrice + .CompositePriceFilter .Field .PRICE_ID ) .operator( - Price.Unit.CompositePriceFilter + Price.UnitPrice + .CompositePriceFilter .Operator .INCLUDES ) @@ -5289,7 +5319,7 @@ internal class SubscriptionChangeCancelResponseTest { ) .maximumAmount("maximum_amount") .metadata( - Price.Unit.Metadata.builder() + Price.UnitPrice.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -5318,7 +5348,9 @@ internal class SubscriptionChangeCancelResponseTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.Unit.PriceType.USAGE_PRICE) + .priceType( + Price.UnitPrice.PriceType.USAGE_PRICE + ) .replacesPriceId("replaces_price_id") .unitConfig( UnitConfig.builder() @@ -5809,7 +5841,7 @@ internal class SubscriptionChangeCancelResponseTest { .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( - Price.Unit.builder() + Price.UnitPrice.builder() .id("id") .billableMetric( BillableMetricTiny.builder() @@ -5827,19 +5859,21 @@ internal class SubscriptionChangeCancelResponseTest { .build() ) .billingMode( - Price.Unit.BillingMode.IN_ADVANCE + Price.UnitPrice.BillingMode.IN_ADVANCE ) - .cadence(Price.Unit.Cadence.ONE_TIME) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) .addCompositePriceFilter( - Price.Unit.CompositePriceFilter + Price.UnitPrice.CompositePriceFilter .builder() .field( - Price.Unit.CompositePriceFilter + Price.UnitPrice + .CompositePriceFilter .Field .PRICE_ID ) .operator( - Price.Unit.CompositePriceFilter + Price.UnitPrice + .CompositePriceFilter .Operator .INCLUDES ) @@ -5961,7 +5995,7 @@ internal class SubscriptionChangeCancelResponseTest { ) .maximumAmount("maximum_amount") .metadata( - Price.Unit.Metadata.builder() + Price.UnitPrice.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -5990,7 +6024,9 @@ internal class SubscriptionChangeCancelResponseTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.Unit.PriceType.USAGE_PRICE) + .priceType( + Price.UnitPrice.PriceType.USAGE_PRICE + ) .replacesPriceId("replaces_price_id") .unitConfig( UnitConfig.builder() diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeRetrieveResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeRetrieveResponseTest.kt index cc4446562..40335e534 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeRetrieveResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeRetrieveResponseTest.kt @@ -390,7 +390,7 @@ internal class SubscriptionChangeRetrieveResponseTest { .build() ) .addPrice( - Price.Unit.builder() + Price.UnitPrice.builder() .id("id") .billableMetric( BillableMetricTiny.builder().id("id").build() @@ -403,15 +403,16 @@ internal class SubscriptionChangeRetrieveResponseTest { ) .build() ) - .billingMode(Price.Unit.BillingMode.IN_ADVANCE) - .cadence(Price.Unit.Cadence.ONE_TIME) + .billingMode(Price.UnitPrice.BillingMode.IN_ADVANCE) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) .addCompositePriceFilter( - Price.Unit.CompositePriceFilter.builder() + Price.UnitPrice.CompositePriceFilter.builder() .field( - Price.Unit.CompositePriceFilter.Field.PRICE_ID + Price.UnitPrice.CompositePriceFilter.Field + .PRICE_ID ) .operator( - Price.Unit.CompositePriceFilter.Operator + Price.UnitPrice.CompositePriceFilter.Operator .INCLUDES ) .addValue("string") @@ -497,7 +498,7 @@ internal class SubscriptionChangeRetrieveResponseTest { ) .maximumAmount("maximum_amount") .metadata( - Price.Unit.Metadata.builder() + Price.UnitPrice.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -520,7 +521,7 @@ internal class SubscriptionChangeRetrieveResponseTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.Unit.PriceType.USAGE_PRICE) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( UnitConfig.builder() @@ -578,7 +579,7 @@ internal class SubscriptionChangeRetrieveResponseTest { .build() ) .price( - Price.Unit.builder() + Price.UnitPrice.builder() .id("id") .billableMetric( BillableMetricTiny.builder().id("id").build() @@ -591,15 +592,16 @@ internal class SubscriptionChangeRetrieveResponseTest { ) .build() ) - .billingMode(Price.Unit.BillingMode.IN_ADVANCE) - .cadence(Price.Unit.Cadence.ONE_TIME) + .billingMode(Price.UnitPrice.BillingMode.IN_ADVANCE) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) .addCompositePriceFilter( - Price.Unit.CompositePriceFilter.builder() + Price.UnitPrice.CompositePriceFilter.builder() .field( - Price.Unit.CompositePriceFilter.Field.PRICE_ID + Price.UnitPrice.CompositePriceFilter.Field + .PRICE_ID ) .operator( - Price.Unit.CompositePriceFilter.Operator + Price.UnitPrice.CompositePriceFilter.Operator .INCLUDES ) .addValue("string") @@ -685,7 +687,7 @@ internal class SubscriptionChangeRetrieveResponseTest { ) .maximumAmount("maximum_amount") .metadata( - Price.Unit.Metadata.builder() + Price.UnitPrice.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -708,7 +710,7 @@ internal class SubscriptionChangeRetrieveResponseTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.Unit.PriceType.USAGE_PRICE) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( UnitConfig.builder() @@ -1099,7 +1101,7 @@ internal class SubscriptionChangeRetrieveResponseTest { .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( - Price.Unit.builder() + Price.UnitPrice.builder() .id("id") .billableMetric( BillableMetricTiny.builder() @@ -1117,19 +1119,21 @@ internal class SubscriptionChangeRetrieveResponseTest { .build() ) .billingMode( - Price.Unit.BillingMode.IN_ADVANCE + Price.UnitPrice.BillingMode.IN_ADVANCE ) - .cadence(Price.Unit.Cadence.ONE_TIME) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) .addCompositePriceFilter( - Price.Unit.CompositePriceFilter + Price.UnitPrice.CompositePriceFilter .builder() .field( - Price.Unit.CompositePriceFilter + Price.UnitPrice + .CompositePriceFilter .Field .PRICE_ID ) .operator( - Price.Unit.CompositePriceFilter + Price.UnitPrice + .CompositePriceFilter .Operator .INCLUDES ) @@ -1251,7 +1255,7 @@ internal class SubscriptionChangeRetrieveResponseTest { ) .maximumAmount("maximum_amount") .metadata( - Price.Unit.Metadata.builder() + Price.UnitPrice.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -1280,7 +1284,9 @@ internal class SubscriptionChangeRetrieveResponseTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.Unit.PriceType.USAGE_PRICE) + .priceType( + Price.UnitPrice.PriceType.USAGE_PRICE + ) .replacesPriceId("replaces_price_id") .unitConfig( UnitConfig.builder() @@ -1771,7 +1777,7 @@ internal class SubscriptionChangeRetrieveResponseTest { .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( - Price.Unit.builder() + Price.UnitPrice.builder() .id("id") .billableMetric( BillableMetricTiny.builder() @@ -1789,19 +1795,21 @@ internal class SubscriptionChangeRetrieveResponseTest { .build() ) .billingMode( - Price.Unit.BillingMode.IN_ADVANCE + Price.UnitPrice.BillingMode.IN_ADVANCE ) - .cadence(Price.Unit.Cadence.ONE_TIME) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) .addCompositePriceFilter( - Price.Unit.CompositePriceFilter + Price.UnitPrice.CompositePriceFilter .builder() .field( - Price.Unit.CompositePriceFilter + Price.UnitPrice + .CompositePriceFilter .Field .PRICE_ID ) .operator( - Price.Unit.CompositePriceFilter + Price.UnitPrice + .CompositePriceFilter .Operator .INCLUDES ) @@ -1923,7 +1931,7 @@ internal class SubscriptionChangeRetrieveResponseTest { ) .maximumAmount("maximum_amount") .metadata( - Price.Unit.Metadata.builder() + Price.UnitPrice.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -1952,7 +1960,9 @@ internal class SubscriptionChangeRetrieveResponseTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.Unit.PriceType.USAGE_PRICE) + .priceType( + Price.UnitPrice.PriceType.USAGE_PRICE + ) .replacesPriceId("replaces_price_id") .unitConfig( UnitConfig.builder() @@ -2469,7 +2479,7 @@ internal class SubscriptionChangeRetrieveResponseTest { .build() ) .addPrice( - Price.Unit.builder() + Price.UnitPrice.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -2480,13 +2490,16 @@ internal class SubscriptionChangeRetrieveResponseTest { ) .build() ) - .billingMode(Price.Unit.BillingMode.IN_ADVANCE) - .cadence(Price.Unit.Cadence.ONE_TIME) + .billingMode(Price.UnitPrice.BillingMode.IN_ADVANCE) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) .addCompositePriceFilter( - Price.Unit.CompositePriceFilter.builder() - .field(Price.Unit.CompositePriceFilter.Field.PRICE_ID) + Price.UnitPrice.CompositePriceFilter.builder() + .field( + Price.UnitPrice.CompositePriceFilter.Field.PRICE_ID + ) .operator( - Price.Unit.CompositePriceFilter.Operator.INCLUDES + Price.UnitPrice.CompositePriceFilter.Operator + .INCLUDES ) .addValue("string") .build() @@ -2564,7 +2577,7 @@ internal class SubscriptionChangeRetrieveResponseTest { ) .maximumAmount("maximum_amount") .metadata( - Price.Unit.Metadata.builder() + Price.UnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -2584,7 +2597,7 @@ internal class SubscriptionChangeRetrieveResponseTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.Unit.PriceType.USAGE_PRICE) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( UnitConfig.builder() @@ -2638,7 +2651,7 @@ internal class SubscriptionChangeRetrieveResponseTest { .build() ) .price( - Price.Unit.builder() + Price.UnitPrice.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -2649,13 +2662,16 @@ internal class SubscriptionChangeRetrieveResponseTest { ) .build() ) - .billingMode(Price.Unit.BillingMode.IN_ADVANCE) - .cadence(Price.Unit.Cadence.ONE_TIME) + .billingMode(Price.UnitPrice.BillingMode.IN_ADVANCE) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) .addCompositePriceFilter( - Price.Unit.CompositePriceFilter.builder() - .field(Price.Unit.CompositePriceFilter.Field.PRICE_ID) + Price.UnitPrice.CompositePriceFilter.builder() + .field( + Price.UnitPrice.CompositePriceFilter.Field.PRICE_ID + ) .operator( - Price.Unit.CompositePriceFilter.Operator.INCLUDES + Price.UnitPrice.CompositePriceFilter.Operator + .INCLUDES ) .addValue("string") .build() @@ -2733,7 +2749,7 @@ internal class SubscriptionChangeRetrieveResponseTest { ) .maximumAmount("maximum_amount") .metadata( - Price.Unit.Metadata.builder() + Price.UnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -2753,7 +2769,7 @@ internal class SubscriptionChangeRetrieveResponseTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.Unit.PriceType.USAGE_PRICE) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( UnitConfig.builder() @@ -3111,7 +3127,7 @@ internal class SubscriptionChangeRetrieveResponseTest { .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( - Price.Unit.builder() + Price.UnitPrice.builder() .id("id") .billableMetric( BillableMetricTiny.builder() @@ -3128,17 +3144,20 @@ internal class SubscriptionChangeRetrieveResponseTest { ) .build() ) - .billingMode(Price.Unit.BillingMode.IN_ADVANCE) - .cadence(Price.Unit.Cadence.ONE_TIME) + .billingMode( + Price.UnitPrice.BillingMode.IN_ADVANCE + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) .addCompositePriceFilter( - Price.Unit.CompositePriceFilter.builder() + Price.UnitPrice.CompositePriceFilter + .builder() .field( - Price.Unit.CompositePriceFilter + Price.UnitPrice.CompositePriceFilter .Field .PRICE_ID ) .operator( - Price.Unit.CompositePriceFilter + Price.UnitPrice.CompositePriceFilter .Operator .INCLUDES ) @@ -3252,7 +3271,7 @@ internal class SubscriptionChangeRetrieveResponseTest { ) .maximumAmount("maximum_amount") .metadata( - Price.Unit.Metadata.builder() + Price.UnitPrice.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -3281,7 +3300,9 @@ internal class SubscriptionChangeRetrieveResponseTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.Unit.PriceType.USAGE_PRICE) + .priceType( + Price.UnitPrice.PriceType.USAGE_PRICE + ) .replacesPriceId("replaces_price_id") .unitConfig( UnitConfig.builder() @@ -3731,7 +3752,7 @@ internal class SubscriptionChangeRetrieveResponseTest { .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( - Price.Unit.builder() + Price.UnitPrice.builder() .id("id") .billableMetric( BillableMetricTiny.builder() @@ -3748,17 +3769,20 @@ internal class SubscriptionChangeRetrieveResponseTest { ) .build() ) - .billingMode(Price.Unit.BillingMode.IN_ADVANCE) - .cadence(Price.Unit.Cadence.ONE_TIME) + .billingMode( + Price.UnitPrice.BillingMode.IN_ADVANCE + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) .addCompositePriceFilter( - Price.Unit.CompositePriceFilter.builder() + Price.UnitPrice.CompositePriceFilter + .builder() .field( - Price.Unit.CompositePriceFilter + Price.UnitPrice.CompositePriceFilter .Field .PRICE_ID ) .operator( - Price.Unit.CompositePriceFilter + Price.UnitPrice.CompositePriceFilter .Operator .INCLUDES ) @@ -3872,7 +3896,7 @@ internal class SubscriptionChangeRetrieveResponseTest { ) .maximumAmount("maximum_amount") .metadata( - Price.Unit.Metadata.builder() + Price.UnitPrice.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -3901,7 +3925,9 @@ internal class SubscriptionChangeRetrieveResponseTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.Unit.PriceType.USAGE_PRICE) + .priceType( + Price.UnitPrice.PriceType.USAGE_PRICE + ) .replacesPriceId("replaces_price_id") .unitConfig( UnitConfig.builder() @@ -4428,7 +4454,7 @@ internal class SubscriptionChangeRetrieveResponseTest { .build() ) .addPrice( - Price.Unit.builder() + Price.UnitPrice.builder() .id("id") .billableMetric( BillableMetricTiny.builder().id("id").build() @@ -4441,15 +4467,16 @@ internal class SubscriptionChangeRetrieveResponseTest { ) .build() ) - .billingMode(Price.Unit.BillingMode.IN_ADVANCE) - .cadence(Price.Unit.Cadence.ONE_TIME) + .billingMode(Price.UnitPrice.BillingMode.IN_ADVANCE) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) .addCompositePriceFilter( - Price.Unit.CompositePriceFilter.builder() + Price.UnitPrice.CompositePriceFilter.builder() .field( - Price.Unit.CompositePriceFilter.Field.PRICE_ID + Price.UnitPrice.CompositePriceFilter.Field + .PRICE_ID ) .operator( - Price.Unit.CompositePriceFilter.Operator + Price.UnitPrice.CompositePriceFilter.Operator .INCLUDES ) .addValue("string") @@ -4535,7 +4562,7 @@ internal class SubscriptionChangeRetrieveResponseTest { ) .maximumAmount("maximum_amount") .metadata( - Price.Unit.Metadata.builder() + Price.UnitPrice.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -4558,7 +4585,7 @@ internal class SubscriptionChangeRetrieveResponseTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.Unit.PriceType.USAGE_PRICE) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( UnitConfig.builder() @@ -4616,7 +4643,7 @@ internal class SubscriptionChangeRetrieveResponseTest { .build() ) .price( - Price.Unit.builder() + Price.UnitPrice.builder() .id("id") .billableMetric( BillableMetricTiny.builder().id("id").build() @@ -4629,15 +4656,16 @@ internal class SubscriptionChangeRetrieveResponseTest { ) .build() ) - .billingMode(Price.Unit.BillingMode.IN_ADVANCE) - .cadence(Price.Unit.Cadence.ONE_TIME) + .billingMode(Price.UnitPrice.BillingMode.IN_ADVANCE) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) .addCompositePriceFilter( - Price.Unit.CompositePriceFilter.builder() + Price.UnitPrice.CompositePriceFilter.builder() .field( - Price.Unit.CompositePriceFilter.Field.PRICE_ID + Price.UnitPrice.CompositePriceFilter.Field + .PRICE_ID ) .operator( - Price.Unit.CompositePriceFilter.Operator + Price.UnitPrice.CompositePriceFilter.Operator .INCLUDES ) .addValue("string") @@ -4723,7 +4751,7 @@ internal class SubscriptionChangeRetrieveResponseTest { ) .maximumAmount("maximum_amount") .metadata( - Price.Unit.Metadata.builder() + Price.UnitPrice.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -4746,7 +4774,7 @@ internal class SubscriptionChangeRetrieveResponseTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.Unit.PriceType.USAGE_PRICE) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( UnitConfig.builder() @@ -5137,7 +5165,7 @@ internal class SubscriptionChangeRetrieveResponseTest { .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( - Price.Unit.builder() + Price.UnitPrice.builder() .id("id") .billableMetric( BillableMetricTiny.builder() @@ -5155,19 +5183,21 @@ internal class SubscriptionChangeRetrieveResponseTest { .build() ) .billingMode( - Price.Unit.BillingMode.IN_ADVANCE + Price.UnitPrice.BillingMode.IN_ADVANCE ) - .cadence(Price.Unit.Cadence.ONE_TIME) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) .addCompositePriceFilter( - Price.Unit.CompositePriceFilter + Price.UnitPrice.CompositePriceFilter .builder() .field( - Price.Unit.CompositePriceFilter + Price.UnitPrice + .CompositePriceFilter .Field .PRICE_ID ) .operator( - Price.Unit.CompositePriceFilter + Price.UnitPrice + .CompositePriceFilter .Operator .INCLUDES ) @@ -5289,7 +5319,7 @@ internal class SubscriptionChangeRetrieveResponseTest { ) .maximumAmount("maximum_amount") .metadata( - Price.Unit.Metadata.builder() + Price.UnitPrice.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -5318,7 +5348,9 @@ internal class SubscriptionChangeRetrieveResponseTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.Unit.PriceType.USAGE_PRICE) + .priceType( + Price.UnitPrice.PriceType.USAGE_PRICE + ) .replacesPriceId("replaces_price_id") .unitConfig( UnitConfig.builder() @@ -5809,7 +5841,7 @@ internal class SubscriptionChangeRetrieveResponseTest { .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( - Price.Unit.builder() + Price.UnitPrice.builder() .id("id") .billableMetric( BillableMetricTiny.builder() @@ -5827,19 +5859,21 @@ internal class SubscriptionChangeRetrieveResponseTest { .build() ) .billingMode( - Price.Unit.BillingMode.IN_ADVANCE + Price.UnitPrice.BillingMode.IN_ADVANCE ) - .cadence(Price.Unit.Cadence.ONE_TIME) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) .addCompositePriceFilter( - Price.Unit.CompositePriceFilter + Price.UnitPrice.CompositePriceFilter .builder() .field( - Price.Unit.CompositePriceFilter + Price.UnitPrice + .CompositePriceFilter .Field .PRICE_ID ) .operator( - Price.Unit.CompositePriceFilter + Price.UnitPrice + .CompositePriceFilter .Operator .INCLUDES ) @@ -5961,7 +5995,7 @@ internal class SubscriptionChangeRetrieveResponseTest { ) .maximumAmount("maximum_amount") .metadata( - Price.Unit.Metadata.builder() + Price.UnitPrice.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -5990,7 +6024,9 @@ internal class SubscriptionChangeRetrieveResponseTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.Unit.PriceType.USAGE_PRICE) + .priceType( + Price.UnitPrice.PriceType.USAGE_PRICE + ) .replacesPriceId("replaces_price_id") .unitConfig( UnitConfig.builder() diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionFetchCostsResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionFetchCostsResponseTest.kt index b21d17b34..0ae21fa3e 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionFetchCostsResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionFetchCostsResponseTest.kt @@ -20,7 +20,7 @@ internal class SubscriptionFetchCostsResponseTest { .addPerPriceCost( PerPriceCost.builder() .price( - Price.Unit.builder() + Price.UnitPrice.builder() .id("id") .billableMetric( BillableMetricTiny.builder().id("id").build() @@ -33,15 +33,16 @@ internal class SubscriptionFetchCostsResponseTest { ) .build() ) - .billingMode(Price.Unit.BillingMode.IN_ADVANCE) - .cadence(Price.Unit.Cadence.ONE_TIME) + .billingMode(Price.UnitPrice.BillingMode.IN_ADVANCE) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) .addCompositePriceFilter( - Price.Unit.CompositePriceFilter.builder() + Price.UnitPrice.CompositePriceFilter.builder() .field( - Price.Unit.CompositePriceFilter.Field.PRICE_ID + Price.UnitPrice.CompositePriceFilter.Field + .PRICE_ID ) .operator( - Price.Unit.CompositePriceFilter.Operator + Price.UnitPrice.CompositePriceFilter.Operator .INCLUDES ) .addValue("string") @@ -127,7 +128,7 @@ internal class SubscriptionFetchCostsResponseTest { ) .maximumAmount("maximum_amount") .metadata( - Price.Unit.Metadata.builder() + Price.UnitPrice.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -150,7 +151,7 @@ internal class SubscriptionFetchCostsResponseTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.Unit.PriceType.USAGE_PRICE) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( UnitConfig.builder() @@ -188,7 +189,7 @@ internal class SubscriptionFetchCostsResponseTest { .addPerPriceCost( PerPriceCost.builder() .price( - Price.Unit.builder() + Price.UnitPrice.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -199,13 +200,16 @@ internal class SubscriptionFetchCostsResponseTest { ) .build() ) - .billingMode(Price.Unit.BillingMode.IN_ADVANCE) - .cadence(Price.Unit.Cadence.ONE_TIME) + .billingMode(Price.UnitPrice.BillingMode.IN_ADVANCE) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) .addCompositePriceFilter( - Price.Unit.CompositePriceFilter.builder() - .field(Price.Unit.CompositePriceFilter.Field.PRICE_ID) + Price.UnitPrice.CompositePriceFilter.builder() + .field( + Price.UnitPrice.CompositePriceFilter.Field.PRICE_ID + ) .operator( - Price.Unit.CompositePriceFilter.Operator.INCLUDES + Price.UnitPrice.CompositePriceFilter.Operator + .INCLUDES ) .addValue("string") .build() @@ -283,7 +287,7 @@ internal class SubscriptionFetchCostsResponseTest { ) .maximumAmount("maximum_amount") .metadata( - Price.Unit.Metadata.builder() + Price.UnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -303,7 +307,7 @@ internal class SubscriptionFetchCostsResponseTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.Unit.PriceType.USAGE_PRICE) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( UnitConfig.builder() @@ -343,7 +347,7 @@ internal class SubscriptionFetchCostsResponseTest { .addPerPriceCost( PerPriceCost.builder() .price( - Price.Unit.builder() + Price.UnitPrice.builder() .id("id") .billableMetric( BillableMetricTiny.builder().id("id").build() @@ -356,15 +360,16 @@ internal class SubscriptionFetchCostsResponseTest { ) .build() ) - .billingMode(Price.Unit.BillingMode.IN_ADVANCE) - .cadence(Price.Unit.Cadence.ONE_TIME) + .billingMode(Price.UnitPrice.BillingMode.IN_ADVANCE) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) .addCompositePriceFilter( - Price.Unit.CompositePriceFilter.builder() + Price.UnitPrice.CompositePriceFilter.builder() .field( - Price.Unit.CompositePriceFilter.Field.PRICE_ID + Price.UnitPrice.CompositePriceFilter.Field + .PRICE_ID ) .operator( - Price.Unit.CompositePriceFilter.Operator + Price.UnitPrice.CompositePriceFilter.Operator .INCLUDES ) .addValue("string") @@ -450,7 +455,7 @@ internal class SubscriptionFetchCostsResponseTest { ) .maximumAmount("maximum_amount") .metadata( - Price.Unit.Metadata.builder() + Price.UnitPrice.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -473,7 +478,7 @@ internal class SubscriptionFetchCostsResponseTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.Unit.PriceType.USAGE_PRICE) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( UnitConfig.builder() diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionTest.kt index 5167feda3..1b17aae96 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionTest.kt @@ -363,7 +363,7 @@ internal class SubscriptionTest { .build() ) .addPrice( - Price.Unit.builder() + Price.UnitPrice.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -372,12 +372,14 @@ internal class SubscriptionTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .billingMode(Price.Unit.BillingMode.IN_ADVANCE) - .cadence(Price.Unit.Cadence.ONE_TIME) + .billingMode(Price.UnitPrice.BillingMode.IN_ADVANCE) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) .addCompositePriceFilter( - Price.Unit.CompositePriceFilter.builder() - .field(Price.Unit.CompositePriceFilter.Field.PRICE_ID) - .operator(Price.Unit.CompositePriceFilter.Operator.INCLUDES) + Price.UnitPrice.CompositePriceFilter.builder() + .field(Price.UnitPrice.CompositePriceFilter.Field.PRICE_ID) + .operator( + Price.UnitPrice.CompositePriceFilter.Operator.INCLUDES + ) .addValue("string") .build() ) @@ -450,7 +452,7 @@ internal class SubscriptionTest { ) .maximumAmount("maximum_amount") .metadata( - Price.Unit.Metadata.builder() + Price.UnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -470,7 +472,7 @@ internal class SubscriptionTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.Unit.PriceType.USAGE_PRICE) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( UnitConfig.builder() @@ -524,7 +526,7 @@ internal class SubscriptionTest { .build() ) .price( - Price.Unit.builder() + Price.UnitPrice.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -533,12 +535,14 @@ internal class SubscriptionTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .billingMode(Price.Unit.BillingMode.IN_ADVANCE) - .cadence(Price.Unit.Cadence.ONE_TIME) + .billingMode(Price.UnitPrice.BillingMode.IN_ADVANCE) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) .addCompositePriceFilter( - Price.Unit.CompositePriceFilter.builder() - .field(Price.Unit.CompositePriceFilter.Field.PRICE_ID) - .operator(Price.Unit.CompositePriceFilter.Operator.INCLUDES) + Price.UnitPrice.CompositePriceFilter.builder() + .field(Price.UnitPrice.CompositePriceFilter.Field.PRICE_ID) + .operator( + Price.UnitPrice.CompositePriceFilter.Operator.INCLUDES + ) .addValue("string") .build() ) @@ -611,7 +615,7 @@ internal class SubscriptionTest { ) .maximumAmount("maximum_amount") .metadata( - Price.Unit.Metadata.builder() + Price.UnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -631,7 +635,7 @@ internal class SubscriptionTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.Unit.PriceType.USAGE_PRICE) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( UnitConfig.builder() @@ -1020,7 +1024,7 @@ internal class SubscriptionTest { .build() ) .addPrice( - Price.Unit.builder() + Price.UnitPrice.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -1029,12 +1033,14 @@ internal class SubscriptionTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .billingMode(Price.Unit.BillingMode.IN_ADVANCE) - .cadence(Price.Unit.Cadence.ONE_TIME) + .billingMode(Price.UnitPrice.BillingMode.IN_ADVANCE) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) .addCompositePriceFilter( - Price.Unit.CompositePriceFilter.builder() - .field(Price.Unit.CompositePriceFilter.Field.PRICE_ID) - .operator(Price.Unit.CompositePriceFilter.Operator.INCLUDES) + Price.UnitPrice.CompositePriceFilter.builder() + .field(Price.UnitPrice.CompositePriceFilter.Field.PRICE_ID) + .operator( + Price.UnitPrice.CompositePriceFilter.Operator.INCLUDES + ) .addValue("string") .build() ) @@ -1103,7 +1109,7 @@ internal class SubscriptionTest { ) .maximumAmount("maximum_amount") .metadata( - Price.Unit.Metadata.builder() + Price.UnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -1123,7 +1129,7 @@ internal class SubscriptionTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.Unit.PriceType.USAGE_PRICE) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( UnitConfig.builder() @@ -1174,7 +1180,7 @@ internal class SubscriptionTest { .build() ) .price( - Price.Unit.builder() + Price.UnitPrice.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -1183,12 +1189,14 @@ internal class SubscriptionTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .billingMode(Price.Unit.BillingMode.IN_ADVANCE) - .cadence(Price.Unit.Cadence.ONE_TIME) + .billingMode(Price.UnitPrice.BillingMode.IN_ADVANCE) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) .addCompositePriceFilter( - Price.Unit.CompositePriceFilter.builder() - .field(Price.Unit.CompositePriceFilter.Field.PRICE_ID) - .operator(Price.Unit.CompositePriceFilter.Operator.INCLUDES) + Price.UnitPrice.CompositePriceFilter.builder() + .field(Price.UnitPrice.CompositePriceFilter.Field.PRICE_ID) + .operator( + Price.UnitPrice.CompositePriceFilter.Operator.INCLUDES + ) .addValue("string") .build() ) @@ -1257,7 +1265,7 @@ internal class SubscriptionTest { ) .maximumAmount("maximum_amount") .metadata( - Price.Unit.Metadata.builder() + Price.UnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -1277,7 +1285,7 @@ internal class SubscriptionTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.Unit.PriceType.USAGE_PRICE) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( UnitConfig.builder() @@ -1669,7 +1677,7 @@ internal class SubscriptionTest { .build() ) .addPrice( - Price.Unit.builder() + Price.UnitPrice.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -1678,12 +1686,14 @@ internal class SubscriptionTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .billingMode(Price.Unit.BillingMode.IN_ADVANCE) - .cadence(Price.Unit.Cadence.ONE_TIME) + .billingMode(Price.UnitPrice.BillingMode.IN_ADVANCE) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) .addCompositePriceFilter( - Price.Unit.CompositePriceFilter.builder() - .field(Price.Unit.CompositePriceFilter.Field.PRICE_ID) - .operator(Price.Unit.CompositePriceFilter.Operator.INCLUDES) + Price.UnitPrice.CompositePriceFilter.builder() + .field(Price.UnitPrice.CompositePriceFilter.Field.PRICE_ID) + .operator( + Price.UnitPrice.CompositePriceFilter.Operator.INCLUDES + ) .addValue("string") .build() ) @@ -1756,7 +1766,7 @@ internal class SubscriptionTest { ) .maximumAmount("maximum_amount") .metadata( - Price.Unit.Metadata.builder() + Price.UnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -1776,7 +1786,7 @@ internal class SubscriptionTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.Unit.PriceType.USAGE_PRICE) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( UnitConfig.builder() @@ -1830,7 +1840,7 @@ internal class SubscriptionTest { .build() ) .price( - Price.Unit.builder() + Price.UnitPrice.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -1839,12 +1849,14 @@ internal class SubscriptionTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .billingMode(Price.Unit.BillingMode.IN_ADVANCE) - .cadence(Price.Unit.Cadence.ONE_TIME) + .billingMode(Price.UnitPrice.BillingMode.IN_ADVANCE) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) .addCompositePriceFilter( - Price.Unit.CompositePriceFilter.builder() - .field(Price.Unit.CompositePriceFilter.Field.PRICE_ID) - .operator(Price.Unit.CompositePriceFilter.Operator.INCLUDES) + Price.UnitPrice.CompositePriceFilter.builder() + .field(Price.UnitPrice.CompositePriceFilter.Field.PRICE_ID) + .operator( + Price.UnitPrice.CompositePriceFilter.Operator.INCLUDES + ) .addValue("string") .build() ) @@ -1917,7 +1929,7 @@ internal class SubscriptionTest { ) .maximumAmount("maximum_amount") .metadata( - Price.Unit.Metadata.builder() + Price.UnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -1937,7 +1949,7 @@ internal class SubscriptionTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.Unit.PriceType.USAGE_PRICE) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( UnitConfig.builder() diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionsTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionsTest.kt index 064e7e885..2970d8eb5 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionsTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionsTest.kt @@ -387,7 +387,7 @@ internal class SubscriptionsTest { .build() ) .addPrice( - Price.Unit.builder() + Price.UnitPrice.builder() .id("id") .billableMetric( BillableMetricTiny.builder().id("id").build() @@ -400,15 +400,16 @@ internal class SubscriptionsTest { ) .build() ) - .billingMode(Price.Unit.BillingMode.IN_ADVANCE) - .cadence(Price.Unit.Cadence.ONE_TIME) + .billingMode(Price.UnitPrice.BillingMode.IN_ADVANCE) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) .addCompositePriceFilter( - Price.Unit.CompositePriceFilter.builder() + Price.UnitPrice.CompositePriceFilter.builder() .field( - Price.Unit.CompositePriceFilter.Field.PRICE_ID + Price.UnitPrice.CompositePriceFilter.Field + .PRICE_ID ) .operator( - Price.Unit.CompositePriceFilter.Operator + Price.UnitPrice.CompositePriceFilter.Operator .INCLUDES ) .addValue("string") @@ -494,7 +495,7 @@ internal class SubscriptionsTest { ) .maximumAmount("maximum_amount") .metadata( - Price.Unit.Metadata.builder() + Price.UnitPrice.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -517,7 +518,7 @@ internal class SubscriptionsTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.Unit.PriceType.USAGE_PRICE) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( UnitConfig.builder() @@ -575,7 +576,7 @@ internal class SubscriptionsTest { .build() ) .price( - Price.Unit.builder() + Price.UnitPrice.builder() .id("id") .billableMetric( BillableMetricTiny.builder().id("id").build() @@ -588,15 +589,16 @@ internal class SubscriptionsTest { ) .build() ) - .billingMode(Price.Unit.BillingMode.IN_ADVANCE) - .cadence(Price.Unit.Cadence.ONE_TIME) + .billingMode(Price.UnitPrice.BillingMode.IN_ADVANCE) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) .addCompositePriceFilter( - Price.Unit.CompositePriceFilter.builder() + Price.UnitPrice.CompositePriceFilter.builder() .field( - Price.Unit.CompositePriceFilter.Field.PRICE_ID + Price.UnitPrice.CompositePriceFilter.Field + .PRICE_ID ) .operator( - Price.Unit.CompositePriceFilter.Operator + Price.UnitPrice.CompositePriceFilter.Operator .INCLUDES ) .addValue("string") @@ -682,7 +684,7 @@ internal class SubscriptionsTest { ) .maximumAmount("maximum_amount") .metadata( - Price.Unit.Metadata.builder() + Price.UnitPrice.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -705,7 +707,7 @@ internal class SubscriptionsTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.Unit.PriceType.USAGE_PRICE) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( UnitConfig.builder() @@ -1108,7 +1110,7 @@ internal class SubscriptionsTest { .build() ) .addPrice( - Price.Unit.builder() + Price.UnitPrice.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -1119,13 +1121,16 @@ internal class SubscriptionsTest { ) .build() ) - .billingMode(Price.Unit.BillingMode.IN_ADVANCE) - .cadence(Price.Unit.Cadence.ONE_TIME) + .billingMode(Price.UnitPrice.BillingMode.IN_ADVANCE) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) .addCompositePriceFilter( - Price.Unit.CompositePriceFilter.builder() - .field(Price.Unit.CompositePriceFilter.Field.PRICE_ID) + Price.UnitPrice.CompositePriceFilter.builder() + .field( + Price.UnitPrice.CompositePriceFilter.Field.PRICE_ID + ) .operator( - Price.Unit.CompositePriceFilter.Operator.INCLUDES + Price.UnitPrice.CompositePriceFilter.Operator + .INCLUDES ) .addValue("string") .build() @@ -1203,7 +1208,7 @@ internal class SubscriptionsTest { ) .maximumAmount("maximum_amount") .metadata( - Price.Unit.Metadata.builder() + Price.UnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -1223,7 +1228,7 @@ internal class SubscriptionsTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.Unit.PriceType.USAGE_PRICE) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( UnitConfig.builder() @@ -1277,7 +1282,7 @@ internal class SubscriptionsTest { .build() ) .price( - Price.Unit.builder() + Price.UnitPrice.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -1288,13 +1293,16 @@ internal class SubscriptionsTest { ) .build() ) - .billingMode(Price.Unit.BillingMode.IN_ADVANCE) - .cadence(Price.Unit.Cadence.ONE_TIME) + .billingMode(Price.UnitPrice.BillingMode.IN_ADVANCE) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) .addCompositePriceFilter( - Price.Unit.CompositePriceFilter.builder() - .field(Price.Unit.CompositePriceFilter.Field.PRICE_ID) + Price.UnitPrice.CompositePriceFilter.builder() + .field( + Price.UnitPrice.CompositePriceFilter.Field.PRICE_ID + ) .operator( - Price.Unit.CompositePriceFilter.Operator.INCLUDES + Price.UnitPrice.CompositePriceFilter.Operator + .INCLUDES ) .addValue("string") .build() @@ -1372,7 +1380,7 @@ internal class SubscriptionsTest { ) .maximumAmount("maximum_amount") .metadata( - Price.Unit.Metadata.builder() + Price.UnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -1392,7 +1400,7 @@ internal class SubscriptionsTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.Unit.PriceType.USAGE_PRICE) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( UnitConfig.builder() @@ -1809,7 +1817,7 @@ internal class SubscriptionsTest { .build() ) .addPrice( - Price.Unit.builder() + Price.UnitPrice.builder() .id("id") .billableMetric( BillableMetricTiny.builder().id("id").build() @@ -1822,15 +1830,16 @@ internal class SubscriptionsTest { ) .build() ) - .billingMode(Price.Unit.BillingMode.IN_ADVANCE) - .cadence(Price.Unit.Cadence.ONE_TIME) + .billingMode(Price.UnitPrice.BillingMode.IN_ADVANCE) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) .addCompositePriceFilter( - Price.Unit.CompositePriceFilter.builder() + Price.UnitPrice.CompositePriceFilter.builder() .field( - Price.Unit.CompositePriceFilter.Field.PRICE_ID + Price.UnitPrice.CompositePriceFilter.Field + .PRICE_ID ) .operator( - Price.Unit.CompositePriceFilter.Operator + Price.UnitPrice.CompositePriceFilter.Operator .INCLUDES ) .addValue("string") @@ -1916,7 +1925,7 @@ internal class SubscriptionsTest { ) .maximumAmount("maximum_amount") .metadata( - Price.Unit.Metadata.builder() + Price.UnitPrice.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -1939,7 +1948,7 @@ internal class SubscriptionsTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.Unit.PriceType.USAGE_PRICE) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( UnitConfig.builder() @@ -1997,7 +2006,7 @@ internal class SubscriptionsTest { .build() ) .price( - Price.Unit.builder() + Price.UnitPrice.builder() .id("id") .billableMetric( BillableMetricTiny.builder().id("id").build() @@ -2010,15 +2019,16 @@ internal class SubscriptionsTest { ) .build() ) - .billingMode(Price.Unit.BillingMode.IN_ADVANCE) - .cadence(Price.Unit.Cadence.ONE_TIME) + .billingMode(Price.UnitPrice.BillingMode.IN_ADVANCE) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) .addCompositePriceFilter( - Price.Unit.CompositePriceFilter.builder() + Price.UnitPrice.CompositePriceFilter.builder() .field( - Price.Unit.CompositePriceFilter.Field.PRICE_ID + Price.UnitPrice.CompositePriceFilter.Field + .PRICE_ID ) .operator( - Price.Unit.CompositePriceFilter.Operator + Price.UnitPrice.CompositePriceFilter.Operator .INCLUDES ) .addValue("string") @@ -2104,7 +2114,7 @@ internal class SubscriptionsTest { ) .maximumAmount("maximum_amount") .metadata( - Price.Unit.Metadata.builder() + Price.UnitPrice.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -2127,7 +2137,7 @@ internal class SubscriptionsTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.Unit.PriceType.USAGE_PRICE) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .unitConfig( UnitConfig.builder() From 99993b17f65917b21e1f87b14699f5ac5cb63e1e Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 7 Nov 2025 00:27:59 +0000 Subject: [PATCH 46/68] feat(api): api update --- .stats.yml | 4 +-- .../CustomerCreditListByExternalIdResponse.kt | 33 +++---------------- .../api/models/CustomerCreditListResponse.kt | 33 +++---------------- .../api/models/EventBackfillCreateParams.kt | 3 ++ .../async/events/BackfillServiceAsync.kt | 3 ++ .../blocking/events/BackfillService.kt | 3 ++ ...rCreditListByExternalIdPageResponseTest.kt | 6 ++-- ...tomerCreditListByExternalIdResponseTest.kt | 6 ++-- .../CustomerCreditListPageResponseTest.kt | 6 ++-- .../models/CustomerCreditListResponseTest.kt | 6 ++-- 10 files changed, 33 insertions(+), 70 deletions(-) diff --git a/.stats.yml b/.stats.yml index 544834a4c..ac446c34d 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 118 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-56d9f85a45eb4dfc07c2994617e1c98554d6dd748245fa4deeb706fe959c14bb.yml -openapi_spec_hash: 64548564dc8ce80ef3ad38fc8cb56b30 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-672b562b91c2e644498b93b1940f8866576a6734a81346b324ed5792e9276bf3.yml +openapi_spec_hash: 3c1a3cc113493afd824bdc6773a202bb config_hash: e6db17547fe854b1c240407cf4c6dc9e diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdResponse.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdResponse.kt index 3d9c4278a..0ff7dc002 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdResponse.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdResponse.kt @@ -452,6 +452,7 @@ private constructor( (if (perUnitCostBasis.asKnown() == null) 0 else 1) + (status.asKnown()?.validity() ?: 0) + /** A PriceFilter that only allows item_id field for block filters. */ class Filter @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( @@ -473,7 +474,7 @@ private constructor( ) : this(field, operator, values, mutableMapOf()) /** - * The property of the price to filter on. + * The property of the price the block applies to. Only item_id is supported. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). @@ -559,7 +560,7 @@ private constructor( additionalProperties = filter.additionalProperties.toMutableMap() } - /** The property of the price to filter on. */ + /** The property of the price the block applies to. Only item_id is supported. */ fun field(field: Field) = field(JsonField.of(field)) /** @@ -683,7 +684,7 @@ private constructor( (operator.asKnown()?.validity() ?: 0) + (values.asKnown()?.size ?: 0) - /** The property of the price to filter on. */ + /** The property of the price the block applies to. Only item_id is supported. */ class Field @JsonCreator private constructor(private val value: JsonField) : Enum { /** @@ -698,26 +699,14 @@ private constructor( companion object { - val PRICE_ID = of("price_id") - val ITEM_ID = of("item_id") - val PRICE_TYPE = of("price_type") - - val CURRENCY = of("currency") - - val PRICING_UNIT_ID = of("pricing_unit_id") - fun of(value: String) = Field(JsonField.of(value)) } /** An enum containing [Field]'s known values. */ enum class Known { - PRICE_ID, - ITEM_ID, - PRICE_TYPE, - CURRENCY, - PRICING_UNIT_ID, + ITEM_ID } /** @@ -730,11 +719,7 @@ private constructor( * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { - PRICE_ID, ITEM_ID, - PRICE_TYPE, - CURRENCY, - PRICING_UNIT_ID, /** * An enum member indicating that [Field] was instantiated with an unknown value. */ @@ -750,11 +735,7 @@ private constructor( */ fun value(): Value = when (this) { - PRICE_ID -> Value.PRICE_ID ITEM_ID -> Value.ITEM_ID - PRICE_TYPE -> Value.PRICE_TYPE - CURRENCY -> Value.CURRENCY - PRICING_UNIT_ID -> Value.PRICING_UNIT_ID else -> Value._UNKNOWN } @@ -769,11 +750,7 @@ private constructor( */ fun known(): Known = when (this) { - PRICE_ID -> Known.PRICE_ID ITEM_ID -> Known.ITEM_ID - PRICE_TYPE -> Known.PRICE_TYPE - CURRENCY -> Known.CURRENCY - PRICING_UNIT_ID -> Known.PRICING_UNIT_ID else -> throw OrbInvalidDataException("Unknown Field: $value") } diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListResponse.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListResponse.kt index 7c186b91c..3f0ddaa3b 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListResponse.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListResponse.kt @@ -448,6 +448,7 @@ private constructor( (if (perUnitCostBasis.asKnown() == null) 0 else 1) + (status.asKnown()?.validity() ?: 0) + /** A PriceFilter that only allows item_id field for block filters. */ class Filter @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( @@ -469,7 +470,7 @@ private constructor( ) : this(field, operator, values, mutableMapOf()) /** - * The property of the price to filter on. + * The property of the price the block applies to. Only item_id is supported. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). @@ -555,7 +556,7 @@ private constructor( additionalProperties = filter.additionalProperties.toMutableMap() } - /** The property of the price to filter on. */ + /** The property of the price the block applies to. Only item_id is supported. */ fun field(field: Field) = field(JsonField.of(field)) /** @@ -679,7 +680,7 @@ private constructor( (operator.asKnown()?.validity() ?: 0) + (values.asKnown()?.size ?: 0) - /** The property of the price to filter on. */ + /** The property of the price the block applies to. Only item_id is supported. */ class Field @JsonCreator private constructor(private val value: JsonField) : Enum { /** @@ -694,26 +695,14 @@ private constructor( companion object { - val PRICE_ID = of("price_id") - val ITEM_ID = of("item_id") - val PRICE_TYPE = of("price_type") - - val CURRENCY = of("currency") - - val PRICING_UNIT_ID = of("pricing_unit_id") - fun of(value: String) = Field(JsonField.of(value)) } /** An enum containing [Field]'s known values. */ enum class Known { - PRICE_ID, - ITEM_ID, - PRICE_TYPE, - CURRENCY, - PRICING_UNIT_ID, + ITEM_ID } /** @@ -726,11 +715,7 @@ private constructor( * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { - PRICE_ID, ITEM_ID, - PRICE_TYPE, - CURRENCY, - PRICING_UNIT_ID, /** * An enum member indicating that [Field] was instantiated with an unknown value. */ @@ -746,11 +731,7 @@ private constructor( */ fun value(): Value = when (this) { - PRICE_ID -> Value.PRICE_ID ITEM_ID -> Value.ITEM_ID - PRICE_TYPE -> Value.PRICE_TYPE - CURRENCY -> Value.CURRENCY - PRICING_UNIT_ID -> Value.PRICING_UNIT_ID else -> Value._UNKNOWN } @@ -765,11 +746,7 @@ private constructor( */ fun known(): Known = when (this) { - PRICE_ID -> Known.PRICE_ID ITEM_ID -> Known.ITEM_ID - PRICE_TYPE -> Known.PRICE_TYPE - CURRENCY -> Known.CURRENCY - PRICING_UNIT_ID -> Known.PRICING_UNIT_ID else -> throw OrbInvalidDataException("Unknown Field: $value") } diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventBackfillCreateParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventBackfillCreateParams.kt index f09382e8e..aa0e14457 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventBackfillCreateParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventBackfillCreateParams.kt @@ -48,6 +48,9 @@ import java.util.Objects * [computed properties](/extensibility/advanced-metrics#computed-properties). The expressiveness of * computed properties allows you to deprecate existing events based on both a period of time and * specific property values. + * + * You may not have multiple backfills in a pending or pending_revert state with overlapping + * timeframes. */ class EventBackfillCreateParams private constructor( diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/events/BackfillServiceAsync.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/events/BackfillServiceAsync.kt index 2c0aa9a3b..23c302c3f 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/events/BackfillServiceAsync.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/events/BackfillServiceAsync.kt @@ -60,6 +60,9 @@ interface BackfillServiceAsync { * [computed properties](/extensibility/advanced-metrics#computed-properties). The * expressiveness of computed properties allows you to deprecate existing events based on both a * period of time and specific property values. + * + * You may not have multiple backfills in a pending or pending_revert state with overlapping + * timeframes. */ suspend fun create( params: EventBackfillCreateParams, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/events/BackfillService.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/events/BackfillService.kt index 5d450b198..20e067321 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/events/BackfillService.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/events/BackfillService.kt @@ -60,6 +60,9 @@ interface BackfillService { * [computed properties](/extensibility/advanced-metrics#computed-properties). The * expressiveness of computed properties allows you to deprecate existing events based on both a * period of time and specific property values. + * + * You may not have multiple backfills in a pending or pending_revert state with overlapping + * timeframes. */ fun create( params: EventBackfillCreateParams, diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdPageResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdPageResponseTest.kt index 37b6dbddc..add48b6d5 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdPageResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdPageResponseTest.kt @@ -22,7 +22,7 @@ internal class CustomerCreditListByExternalIdPageResponseTest { .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addFilter( CustomerCreditListByExternalIdResponse.Filter.builder() - .field(CustomerCreditListByExternalIdResponse.Filter.Field.PRICE_ID) + .field(CustomerCreditListByExternalIdResponse.Filter.Field.ITEM_ID) .operator( CustomerCreditListByExternalIdResponse.Filter.Operator.INCLUDES ) @@ -48,7 +48,7 @@ internal class CustomerCreditListByExternalIdPageResponseTest { .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addFilter( CustomerCreditListByExternalIdResponse.Filter.builder() - .field(CustomerCreditListByExternalIdResponse.Filter.Field.PRICE_ID) + .field(CustomerCreditListByExternalIdResponse.Filter.Field.ITEM_ID) .operator( CustomerCreditListByExternalIdResponse.Filter.Operator.INCLUDES ) @@ -77,7 +77,7 @@ internal class CustomerCreditListByExternalIdPageResponseTest { .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addFilter( CustomerCreditListByExternalIdResponse.Filter.builder() - .field(CustomerCreditListByExternalIdResponse.Filter.Field.PRICE_ID) + .field(CustomerCreditListByExternalIdResponse.Filter.Field.ITEM_ID) .operator( CustomerCreditListByExternalIdResponse.Filter.Operator.INCLUDES ) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdResponseTest.kt index ac2db752f..dc3c6207c 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdResponseTest.kt @@ -20,7 +20,7 @@ internal class CustomerCreditListByExternalIdResponseTest { .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addFilter( CustomerCreditListByExternalIdResponse.Filter.builder() - .field(CustomerCreditListByExternalIdResponse.Filter.Field.PRICE_ID) + .field(CustomerCreditListByExternalIdResponse.Filter.Field.ITEM_ID) .operator(CustomerCreditListByExternalIdResponse.Filter.Operator.INCLUDES) .addValue("string") .build() @@ -39,7 +39,7 @@ internal class CustomerCreditListByExternalIdResponseTest { assertThat(customerCreditListByExternalIdResponse.filters()) .containsExactly( CustomerCreditListByExternalIdResponse.Filter.builder() - .field(CustomerCreditListByExternalIdResponse.Filter.Field.PRICE_ID) + .field(CustomerCreditListByExternalIdResponse.Filter.Field.ITEM_ID) .operator(CustomerCreditListByExternalIdResponse.Filter.Operator.INCLUDES) .addValue("string") .build() @@ -62,7 +62,7 @@ internal class CustomerCreditListByExternalIdResponseTest { .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addFilter( CustomerCreditListByExternalIdResponse.Filter.builder() - .field(CustomerCreditListByExternalIdResponse.Filter.Field.PRICE_ID) + .field(CustomerCreditListByExternalIdResponse.Filter.Field.ITEM_ID) .operator(CustomerCreditListByExternalIdResponse.Filter.Operator.INCLUDES) .addValue("string") .build() diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditListPageResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditListPageResponseTest.kt index b0dc2cda2..86c3c5fce 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditListPageResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditListPageResponseTest.kt @@ -22,7 +22,7 @@ internal class CustomerCreditListPageResponseTest { .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addFilter( CustomerCreditListResponse.Filter.builder() - .field(CustomerCreditListResponse.Filter.Field.PRICE_ID) + .field(CustomerCreditListResponse.Filter.Field.ITEM_ID) .operator(CustomerCreditListResponse.Filter.Operator.INCLUDES) .addValue("string") .build() @@ -46,7 +46,7 @@ internal class CustomerCreditListPageResponseTest { .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addFilter( CustomerCreditListResponse.Filter.builder() - .field(CustomerCreditListResponse.Filter.Field.PRICE_ID) + .field(CustomerCreditListResponse.Filter.Field.ITEM_ID) .operator(CustomerCreditListResponse.Filter.Operator.INCLUDES) .addValue("string") .build() @@ -73,7 +73,7 @@ internal class CustomerCreditListPageResponseTest { .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addFilter( CustomerCreditListResponse.Filter.builder() - .field(CustomerCreditListResponse.Filter.Field.PRICE_ID) + .field(CustomerCreditListResponse.Filter.Field.ITEM_ID) .operator(CustomerCreditListResponse.Filter.Operator.INCLUDES) .addValue("string") .build() diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditListResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditListResponseTest.kt index 1a32845e7..25792b1ee 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditListResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditListResponseTest.kt @@ -20,7 +20,7 @@ internal class CustomerCreditListResponseTest { .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addFilter( CustomerCreditListResponse.Filter.builder() - .field(CustomerCreditListResponse.Filter.Field.PRICE_ID) + .field(CustomerCreditListResponse.Filter.Field.ITEM_ID) .operator(CustomerCreditListResponse.Filter.Operator.INCLUDES) .addValue("string") .build() @@ -39,7 +39,7 @@ internal class CustomerCreditListResponseTest { assertThat(customerCreditListResponse.filters()) .containsExactly( CustomerCreditListResponse.Filter.builder() - .field(CustomerCreditListResponse.Filter.Field.PRICE_ID) + .field(CustomerCreditListResponse.Filter.Field.ITEM_ID) .operator(CustomerCreditListResponse.Filter.Operator.INCLUDES) .addValue("string") .build() @@ -61,7 +61,7 @@ internal class CustomerCreditListResponseTest { .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addFilter( CustomerCreditListResponse.Filter.builder() - .field(CustomerCreditListResponse.Filter.Field.PRICE_ID) + .field(CustomerCreditListResponse.Filter.Field.ITEM_ID) .operator(CustomerCreditListResponse.Filter.Operator.INCLUDES) .addValue("string") .build() From 2eb59cfcbe3b452746ef31a5f7c89f43276cffe5 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 7 Nov 2025 22:27:48 +0000 Subject: [PATCH 47/68] feat(api): api update --- .stats.yml | 4 +- .../api/models/CustomerCreateParams.kt | 326 +++++++++++++++++- .../CustomerUpdateByExternalIdParams.kt | 326 +++++++++++++++++- .../api/models/CustomerUpdateParams.kt | 326 +++++++++++++++++- 4 files changed, 974 insertions(+), 8 deletions(-) diff --git a/.stats.yml b/.stats.yml index ac446c34d..a477a2c51 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 118 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-672b562b91c2e644498b93b1940f8866576a6734a81346b324ed5792e9276bf3.yml -openapi_spec_hash: 3c1a3cc113493afd824bdc6773a202bb +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-145c6652d32a05c9305e4674643e2aa7d559073e48dc252d6c3c0fe802ce7ec6.yml +openapi_spec_hash: 6bbbbe1687099b69faee47fda12bf82c config_hash: e6db17547fe854b1c240407cf4c6dc9e diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreateParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreateParams.kt index a2111869b..fa14687fb 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreateParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreateParams.kt @@ -931,6 +931,23 @@ private constructor( body.anrokTaxConfiguration(taxExempt) } + /** Alias for calling [taxConfiguration] with `TaxConfiguration.ofStripe(stripe)`. */ + fun taxConfiguration(stripe: TaxConfiguration.Stripe) = apply { + body.taxConfiguration(stripe) + } + + /** + * Alias for calling [taxConfiguration] with the following: + * ```kotlin + * TaxConfiguration.Stripe.builder() + * .taxExempt(taxExempt) + * .build() + * ``` + */ + fun stripeTaxConfiguration(taxExempt: Boolean) = apply { + body.stripeTaxConfiguration(taxExempt) + } + /** * Tax IDs are commonly required to be displayed on customer invoices, which are added to * the headers of invoices. @@ -2295,6 +2312,21 @@ private constructor( fun anrokTaxConfiguration(taxExempt: Boolean) = taxConfiguration(TaxConfiguration.Anrok.builder().taxExempt(taxExempt).build()) + /** Alias for calling [taxConfiguration] with `TaxConfiguration.ofStripe(stripe)`. */ + fun taxConfiguration(stripe: TaxConfiguration.Stripe) = + taxConfiguration(TaxConfiguration.ofStripe(stripe)) + + /** + * Alias for calling [taxConfiguration] with the following: + * ```kotlin + * TaxConfiguration.Stripe.builder() + * .taxExempt(taxExempt) + * .build() + * ``` + */ + fun stripeTaxConfiguration(taxExempt: Boolean) = + taxConfiguration(TaxConfiguration.Stripe.builder().taxExempt(taxExempt).build()) + /** * Tax IDs are commonly required to be displayed on customer invoices, which are added * to the headers of invoices. @@ -2908,6 +2940,7 @@ private constructor( private val sphere: NewSphereConfiguration? = null, private val numeral: Numeral? = null, private val anrok: Anrok? = null, + private val stripe: Stripe? = null, private val _json: JsonValue? = null, ) { @@ -2921,6 +2954,8 @@ private constructor( fun anrok(): Anrok? = anrok + fun stripe(): Stripe? = stripe + fun isAvalara(): Boolean = avalara != null fun isTaxjar(): Boolean = taxjar != null @@ -2931,6 +2966,8 @@ private constructor( fun isAnrok(): Boolean = anrok != null + fun isStripe(): Boolean = stripe != null + fun asAvalara(): NewAvalaraTaxConfiguration = avalara.getOrThrow("avalara") fun asTaxjar(): NewTaxJarConfiguration = taxjar.getOrThrow("taxjar") @@ -2941,6 +2978,8 @@ private constructor( fun asAnrok(): Anrok = anrok.getOrThrow("anrok") + fun asStripe(): Stripe = stripe.getOrThrow("stripe") + fun _json(): JsonValue? = _json fun accept(visitor: Visitor): T = @@ -2950,6 +2989,7 @@ private constructor( sphere != null -> visitor.visitSphere(sphere) numeral != null -> visitor.visitNumeral(numeral) anrok != null -> visitor.visitAnrok(anrok) + stripe != null -> visitor.visitStripe(stripe) else -> visitor.unknown(_json) } @@ -2981,6 +3021,10 @@ private constructor( override fun visitAnrok(anrok: Anrok) { anrok.validate() } + + override fun visitStripe(stripe: Stripe) { + stripe.validate() + } } ) validated = true @@ -3014,6 +3058,8 @@ private constructor( override fun visitAnrok(anrok: Anrok) = anrok.validity() + override fun visitStripe(stripe: Stripe) = stripe.validity() + override fun unknown(json: JsonValue?) = 0 } ) @@ -3028,10 +3074,11 @@ private constructor( taxjar == other.taxjar && sphere == other.sphere && numeral == other.numeral && - anrok == other.anrok + anrok == other.anrok && + stripe == other.stripe } - override fun hashCode(): Int = Objects.hash(avalara, taxjar, sphere, numeral, anrok) + override fun hashCode(): Int = Objects.hash(avalara, taxjar, sphere, numeral, anrok, stripe) override fun toString(): String = when { @@ -3040,6 +3087,7 @@ private constructor( sphere != null -> "TaxConfiguration{sphere=$sphere}" numeral != null -> "TaxConfiguration{numeral=$numeral}" anrok != null -> "TaxConfiguration{anrok=$anrok}" + stripe != null -> "TaxConfiguration{stripe=$stripe}" _json != null -> "TaxConfiguration{_unknown=$_json}" else -> throw IllegalStateException("Invalid TaxConfiguration") } @@ -3055,6 +3103,8 @@ private constructor( fun ofNumeral(numeral: Numeral) = TaxConfiguration(numeral = numeral) fun ofAnrok(anrok: Anrok) = TaxConfiguration(anrok = anrok) + + fun ofStripe(stripe: Stripe) = TaxConfiguration(stripe = stripe) } /** @@ -3073,6 +3123,8 @@ private constructor( fun visitAnrok(anrok: Anrok): T + fun visitStripe(stripe: Stripe): T + /** * Maps an unknown variant of [TaxConfiguration] to a value of type [T]. * @@ -3120,6 +3172,11 @@ private constructor( TaxConfiguration(anrok = it, _json = json) } ?: TaxConfiguration(_json = json) } + "stripe" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + TaxConfiguration(stripe = it, _json = json) + } ?: TaxConfiguration(_json = json) + } } return TaxConfiguration(_json = json) @@ -3139,6 +3196,7 @@ private constructor( value.sphere != null -> generator.writeObject(value.sphere) value.numeral != null -> generator.writeObject(value.numeral) value.anrok != null -> generator.writeObject(value.anrok) + value.stripe != null -> generator.writeObject(value.stripe) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid TaxConfiguration") } @@ -3672,6 +3730,270 @@ private constructor( override fun toString() = "Anrok{taxExempt=$taxExempt, taxProvider=$taxProvider, automaticTaxEnabled=$automaticTaxEnabled, additionalProperties=$additionalProperties}" } + + class Stripe + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val taxExempt: JsonField, + private val taxProvider: JsonValue, + private val automaticTaxEnabled: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("tax_exempt") + @ExcludeMissing + taxExempt: JsonField = JsonMissing.of(), + @JsonProperty("tax_provider") + @ExcludeMissing + taxProvider: JsonValue = JsonMissing.of(), + @JsonProperty("automatic_tax_enabled") + @ExcludeMissing + automaticTaxEnabled: JsonField = JsonMissing.of(), + ) : this(taxExempt, taxProvider, automaticTaxEnabled, mutableMapOf()) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun taxExempt(): Boolean = taxExempt.getRequired("tax_exempt") + + /** + * Expected to always return the following: + * ```kotlin + * JsonValue.from("stripe") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("tax_provider") + @ExcludeMissing + fun _taxProvider(): JsonValue = taxProvider + + /** + * Whether to automatically calculate tax for this customer. When null, inherits from + * account-level setting. When true or false, overrides the account setting. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun automaticTaxEnabled(): Boolean? = + automaticTaxEnabled.getNullable("automatic_tax_enabled") + + /** + * Returns the raw JSON value of [taxExempt]. + * + * Unlike [taxExempt], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tax_exempt") + @ExcludeMissing + fun _taxExempt(): JsonField = taxExempt + + /** + * Returns the raw JSON value of [automaticTaxEnabled]. + * + * Unlike [automaticTaxEnabled], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("automatic_tax_enabled") + @ExcludeMissing + fun _automaticTaxEnabled(): JsonField = automaticTaxEnabled + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Stripe]. + * + * The following fields are required: + * ```kotlin + * .taxExempt() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Stripe]. */ + class Builder internal constructor() { + + private var taxExempt: JsonField? = null + private var taxProvider: JsonValue = JsonValue.from("stripe") + private var automaticTaxEnabled: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(stripe: Stripe) = apply { + taxExempt = stripe.taxExempt + taxProvider = stripe.taxProvider + automaticTaxEnabled = stripe.automaticTaxEnabled + additionalProperties = stripe.additionalProperties.toMutableMap() + } + + fun taxExempt(taxExempt: Boolean) = taxExempt(JsonField.of(taxExempt)) + + /** + * Sets [Builder.taxExempt] to an arbitrary JSON value. + * + * You should usually call [Builder.taxExempt] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun taxExempt(taxExempt: JsonField) = apply { this.taxExempt = taxExempt } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```kotlin + * JsonValue.from("stripe") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun taxProvider(taxProvider: JsonValue) = apply { this.taxProvider = taxProvider } + + /** + * Whether to automatically calculate tax for this customer. When null, inherits + * from account-level setting. When true or false, overrides the account setting. + */ + fun automaticTaxEnabled(automaticTaxEnabled: Boolean?) = + automaticTaxEnabled(JsonField.ofNullable(automaticTaxEnabled)) + + /** + * Alias for [Builder.automaticTaxEnabled]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun automaticTaxEnabled(automaticTaxEnabled: Boolean) = + automaticTaxEnabled(automaticTaxEnabled as Boolean?) + + /** + * Sets [Builder.automaticTaxEnabled] to an arbitrary JSON value. + * + * You should usually call [Builder.automaticTaxEnabled] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun automaticTaxEnabled(automaticTaxEnabled: JsonField) = apply { + this.automaticTaxEnabled = automaticTaxEnabled + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Stripe]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .taxExempt() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Stripe = + Stripe( + checkRequired("taxExempt", taxExempt), + taxProvider, + automaticTaxEnabled, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Stripe = apply { + if (validated) { + return@apply + } + + taxExempt() + _taxProvider().let { + if (it != JsonValue.from("stripe")) { + throw OrbInvalidDataException("'taxProvider' is invalid, received $it") + } + } + automaticTaxEnabled() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (taxExempt.asKnown() == null) 0 else 1) + + taxProvider.let { if (it == JsonValue.from("stripe")) 1 else 0 } + + (if (automaticTaxEnabled.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Stripe && + taxExempt == other.taxExempt && + taxProvider == other.taxProvider && + automaticTaxEnabled == other.automaticTaxEnabled && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(taxExempt, taxProvider, automaticTaxEnabled, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Stripe{taxExempt=$taxExempt, taxProvider=$taxProvider, automaticTaxEnabled=$automaticTaxEnabled, additionalProperties=$additionalProperties}" + } } override fun equals(other: Any?): Boolean { diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerUpdateByExternalIdParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerUpdateByExternalIdParams.kt index ea70c1c7a..45dd51cca 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerUpdateByExternalIdParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerUpdateByExternalIdParams.kt @@ -917,6 +917,23 @@ private constructor( body.anrokTaxConfiguration(taxExempt) } + /** Alias for calling [taxConfiguration] with `TaxConfiguration.ofStripe(stripe)`. */ + fun taxConfiguration(stripe: TaxConfiguration.Stripe) = apply { + body.taxConfiguration(stripe) + } + + /** + * Alias for calling [taxConfiguration] with the following: + * ```kotlin + * TaxConfiguration.Stripe.builder() + * .taxExempt(taxExempt) + * .build() + * ``` + */ + fun stripeTaxConfiguration(taxExempt: Boolean) = apply { + body.stripeTaxConfiguration(taxExempt) + } + /** * Tax IDs are commonly required to be displayed on customer invoices, which are added to * the headers of invoices. @@ -2239,6 +2256,21 @@ private constructor( fun anrokTaxConfiguration(taxExempt: Boolean) = taxConfiguration(TaxConfiguration.Anrok.builder().taxExempt(taxExempt).build()) + /** Alias for calling [taxConfiguration] with `TaxConfiguration.ofStripe(stripe)`. */ + fun taxConfiguration(stripe: TaxConfiguration.Stripe) = + taxConfiguration(TaxConfiguration.ofStripe(stripe)) + + /** + * Alias for calling [taxConfiguration] with the following: + * ```kotlin + * TaxConfiguration.Stripe.builder() + * .taxExempt(taxExempt) + * .build() + * ``` + */ + fun stripeTaxConfiguration(taxExempt: Boolean) = + taxConfiguration(TaxConfiguration.Stripe.builder().taxExempt(taxExempt).build()) + /** * Tax IDs are commonly required to be displayed on customer invoices, which are added * to the headers of invoices. @@ -2826,6 +2858,7 @@ private constructor( private val sphere: NewSphereConfiguration? = null, private val numeral: Numeral? = null, private val anrok: Anrok? = null, + private val stripe: Stripe? = null, private val _json: JsonValue? = null, ) { @@ -2839,6 +2872,8 @@ private constructor( fun anrok(): Anrok? = anrok + fun stripe(): Stripe? = stripe + fun isAvalara(): Boolean = avalara != null fun isTaxjar(): Boolean = taxjar != null @@ -2849,6 +2884,8 @@ private constructor( fun isAnrok(): Boolean = anrok != null + fun isStripe(): Boolean = stripe != null + fun asAvalara(): NewAvalaraTaxConfiguration = avalara.getOrThrow("avalara") fun asTaxjar(): NewTaxJarConfiguration = taxjar.getOrThrow("taxjar") @@ -2859,6 +2896,8 @@ private constructor( fun asAnrok(): Anrok = anrok.getOrThrow("anrok") + fun asStripe(): Stripe = stripe.getOrThrow("stripe") + fun _json(): JsonValue? = _json fun accept(visitor: Visitor): T = @@ -2868,6 +2907,7 @@ private constructor( sphere != null -> visitor.visitSphere(sphere) numeral != null -> visitor.visitNumeral(numeral) anrok != null -> visitor.visitAnrok(anrok) + stripe != null -> visitor.visitStripe(stripe) else -> visitor.unknown(_json) } @@ -2899,6 +2939,10 @@ private constructor( override fun visitAnrok(anrok: Anrok) { anrok.validate() } + + override fun visitStripe(stripe: Stripe) { + stripe.validate() + } } ) validated = true @@ -2932,6 +2976,8 @@ private constructor( override fun visitAnrok(anrok: Anrok) = anrok.validity() + override fun visitStripe(stripe: Stripe) = stripe.validity() + override fun unknown(json: JsonValue?) = 0 } ) @@ -2946,10 +2992,11 @@ private constructor( taxjar == other.taxjar && sphere == other.sphere && numeral == other.numeral && - anrok == other.anrok + anrok == other.anrok && + stripe == other.stripe } - override fun hashCode(): Int = Objects.hash(avalara, taxjar, sphere, numeral, anrok) + override fun hashCode(): Int = Objects.hash(avalara, taxjar, sphere, numeral, anrok, stripe) override fun toString(): String = when { @@ -2958,6 +3005,7 @@ private constructor( sphere != null -> "TaxConfiguration{sphere=$sphere}" numeral != null -> "TaxConfiguration{numeral=$numeral}" anrok != null -> "TaxConfiguration{anrok=$anrok}" + stripe != null -> "TaxConfiguration{stripe=$stripe}" _json != null -> "TaxConfiguration{_unknown=$_json}" else -> throw IllegalStateException("Invalid TaxConfiguration") } @@ -2973,6 +3021,8 @@ private constructor( fun ofNumeral(numeral: Numeral) = TaxConfiguration(numeral = numeral) fun ofAnrok(anrok: Anrok) = TaxConfiguration(anrok = anrok) + + fun ofStripe(stripe: Stripe) = TaxConfiguration(stripe = stripe) } /** @@ -2991,6 +3041,8 @@ private constructor( fun visitAnrok(anrok: Anrok): T + fun visitStripe(stripe: Stripe): T + /** * Maps an unknown variant of [TaxConfiguration] to a value of type [T]. * @@ -3038,6 +3090,11 @@ private constructor( TaxConfiguration(anrok = it, _json = json) } ?: TaxConfiguration(_json = json) } + "stripe" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + TaxConfiguration(stripe = it, _json = json) + } ?: TaxConfiguration(_json = json) + } } return TaxConfiguration(_json = json) @@ -3057,6 +3114,7 @@ private constructor( value.sphere != null -> generator.writeObject(value.sphere) value.numeral != null -> generator.writeObject(value.numeral) value.anrok != null -> generator.writeObject(value.anrok) + value.stripe != null -> generator.writeObject(value.stripe) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid TaxConfiguration") } @@ -3590,6 +3648,270 @@ private constructor( override fun toString() = "Anrok{taxExempt=$taxExempt, taxProvider=$taxProvider, automaticTaxEnabled=$automaticTaxEnabled, additionalProperties=$additionalProperties}" } + + class Stripe + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val taxExempt: JsonField, + private val taxProvider: JsonValue, + private val automaticTaxEnabled: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("tax_exempt") + @ExcludeMissing + taxExempt: JsonField = JsonMissing.of(), + @JsonProperty("tax_provider") + @ExcludeMissing + taxProvider: JsonValue = JsonMissing.of(), + @JsonProperty("automatic_tax_enabled") + @ExcludeMissing + automaticTaxEnabled: JsonField = JsonMissing.of(), + ) : this(taxExempt, taxProvider, automaticTaxEnabled, mutableMapOf()) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun taxExempt(): Boolean = taxExempt.getRequired("tax_exempt") + + /** + * Expected to always return the following: + * ```kotlin + * JsonValue.from("stripe") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("tax_provider") + @ExcludeMissing + fun _taxProvider(): JsonValue = taxProvider + + /** + * Whether to automatically calculate tax for this customer. When null, inherits from + * account-level setting. When true or false, overrides the account setting. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun automaticTaxEnabled(): Boolean? = + automaticTaxEnabled.getNullable("automatic_tax_enabled") + + /** + * Returns the raw JSON value of [taxExempt]. + * + * Unlike [taxExempt], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tax_exempt") + @ExcludeMissing + fun _taxExempt(): JsonField = taxExempt + + /** + * Returns the raw JSON value of [automaticTaxEnabled]. + * + * Unlike [automaticTaxEnabled], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("automatic_tax_enabled") + @ExcludeMissing + fun _automaticTaxEnabled(): JsonField = automaticTaxEnabled + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Stripe]. + * + * The following fields are required: + * ```kotlin + * .taxExempt() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Stripe]. */ + class Builder internal constructor() { + + private var taxExempt: JsonField? = null + private var taxProvider: JsonValue = JsonValue.from("stripe") + private var automaticTaxEnabled: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(stripe: Stripe) = apply { + taxExempt = stripe.taxExempt + taxProvider = stripe.taxProvider + automaticTaxEnabled = stripe.automaticTaxEnabled + additionalProperties = stripe.additionalProperties.toMutableMap() + } + + fun taxExempt(taxExempt: Boolean) = taxExempt(JsonField.of(taxExempt)) + + /** + * Sets [Builder.taxExempt] to an arbitrary JSON value. + * + * You should usually call [Builder.taxExempt] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun taxExempt(taxExempt: JsonField) = apply { this.taxExempt = taxExempt } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```kotlin + * JsonValue.from("stripe") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun taxProvider(taxProvider: JsonValue) = apply { this.taxProvider = taxProvider } + + /** + * Whether to automatically calculate tax for this customer. When null, inherits + * from account-level setting. When true or false, overrides the account setting. + */ + fun automaticTaxEnabled(automaticTaxEnabled: Boolean?) = + automaticTaxEnabled(JsonField.ofNullable(automaticTaxEnabled)) + + /** + * Alias for [Builder.automaticTaxEnabled]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun automaticTaxEnabled(automaticTaxEnabled: Boolean) = + automaticTaxEnabled(automaticTaxEnabled as Boolean?) + + /** + * Sets [Builder.automaticTaxEnabled] to an arbitrary JSON value. + * + * You should usually call [Builder.automaticTaxEnabled] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun automaticTaxEnabled(automaticTaxEnabled: JsonField) = apply { + this.automaticTaxEnabled = automaticTaxEnabled + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Stripe]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .taxExempt() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Stripe = + Stripe( + checkRequired("taxExempt", taxExempt), + taxProvider, + automaticTaxEnabled, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Stripe = apply { + if (validated) { + return@apply + } + + taxExempt() + _taxProvider().let { + if (it != JsonValue.from("stripe")) { + throw OrbInvalidDataException("'taxProvider' is invalid, received $it") + } + } + automaticTaxEnabled() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (taxExempt.asKnown() == null) 0 else 1) + + taxProvider.let { if (it == JsonValue.from("stripe")) 1 else 0 } + + (if (automaticTaxEnabled.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Stripe && + taxExempt == other.taxExempt && + taxProvider == other.taxProvider && + automaticTaxEnabled == other.automaticTaxEnabled && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(taxExempt, taxProvider, automaticTaxEnabled, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Stripe{taxExempt=$taxExempt, taxProvider=$taxProvider, automaticTaxEnabled=$automaticTaxEnabled, additionalProperties=$additionalProperties}" + } } override fun equals(other: Any?): Boolean { diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerUpdateParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerUpdateParams.kt index 049e94cf3..2ed59bfba 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerUpdateParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerUpdateParams.kt @@ -913,6 +913,23 @@ private constructor( body.anrokTaxConfiguration(taxExempt) } + /** Alias for calling [taxConfiguration] with `TaxConfiguration.ofStripe(stripe)`. */ + fun taxConfiguration(stripe: TaxConfiguration.Stripe) = apply { + body.taxConfiguration(stripe) + } + + /** + * Alias for calling [taxConfiguration] with the following: + * ```kotlin + * TaxConfiguration.Stripe.builder() + * .taxExempt(taxExempt) + * .build() + * ``` + */ + fun stripeTaxConfiguration(taxExempt: Boolean) = apply { + body.stripeTaxConfiguration(taxExempt) + } + /** * Tax IDs are commonly required to be displayed on customer invoices, which are added to * the headers of invoices. @@ -2235,6 +2252,21 @@ private constructor( fun anrokTaxConfiguration(taxExempt: Boolean) = taxConfiguration(TaxConfiguration.Anrok.builder().taxExempt(taxExempt).build()) + /** Alias for calling [taxConfiguration] with `TaxConfiguration.ofStripe(stripe)`. */ + fun taxConfiguration(stripe: TaxConfiguration.Stripe) = + taxConfiguration(TaxConfiguration.ofStripe(stripe)) + + /** + * Alias for calling [taxConfiguration] with the following: + * ```kotlin + * TaxConfiguration.Stripe.builder() + * .taxExempt(taxExempt) + * .build() + * ``` + */ + fun stripeTaxConfiguration(taxExempt: Boolean) = + taxConfiguration(TaxConfiguration.Stripe.builder().taxExempt(taxExempt).build()) + /** * Tax IDs are commonly required to be displayed on customer invoices, which are added * to the headers of invoices. @@ -2822,6 +2854,7 @@ private constructor( private val sphere: NewSphereConfiguration? = null, private val numeral: Numeral? = null, private val anrok: Anrok? = null, + private val stripe: Stripe? = null, private val _json: JsonValue? = null, ) { @@ -2835,6 +2868,8 @@ private constructor( fun anrok(): Anrok? = anrok + fun stripe(): Stripe? = stripe + fun isAvalara(): Boolean = avalara != null fun isTaxjar(): Boolean = taxjar != null @@ -2845,6 +2880,8 @@ private constructor( fun isAnrok(): Boolean = anrok != null + fun isStripe(): Boolean = stripe != null + fun asAvalara(): NewAvalaraTaxConfiguration = avalara.getOrThrow("avalara") fun asTaxjar(): NewTaxJarConfiguration = taxjar.getOrThrow("taxjar") @@ -2855,6 +2892,8 @@ private constructor( fun asAnrok(): Anrok = anrok.getOrThrow("anrok") + fun asStripe(): Stripe = stripe.getOrThrow("stripe") + fun _json(): JsonValue? = _json fun accept(visitor: Visitor): T = @@ -2864,6 +2903,7 @@ private constructor( sphere != null -> visitor.visitSphere(sphere) numeral != null -> visitor.visitNumeral(numeral) anrok != null -> visitor.visitAnrok(anrok) + stripe != null -> visitor.visitStripe(stripe) else -> visitor.unknown(_json) } @@ -2895,6 +2935,10 @@ private constructor( override fun visitAnrok(anrok: Anrok) { anrok.validate() } + + override fun visitStripe(stripe: Stripe) { + stripe.validate() + } } ) validated = true @@ -2928,6 +2972,8 @@ private constructor( override fun visitAnrok(anrok: Anrok) = anrok.validity() + override fun visitStripe(stripe: Stripe) = stripe.validity() + override fun unknown(json: JsonValue?) = 0 } ) @@ -2942,10 +2988,11 @@ private constructor( taxjar == other.taxjar && sphere == other.sphere && numeral == other.numeral && - anrok == other.anrok + anrok == other.anrok && + stripe == other.stripe } - override fun hashCode(): Int = Objects.hash(avalara, taxjar, sphere, numeral, anrok) + override fun hashCode(): Int = Objects.hash(avalara, taxjar, sphere, numeral, anrok, stripe) override fun toString(): String = when { @@ -2954,6 +3001,7 @@ private constructor( sphere != null -> "TaxConfiguration{sphere=$sphere}" numeral != null -> "TaxConfiguration{numeral=$numeral}" anrok != null -> "TaxConfiguration{anrok=$anrok}" + stripe != null -> "TaxConfiguration{stripe=$stripe}" _json != null -> "TaxConfiguration{_unknown=$_json}" else -> throw IllegalStateException("Invalid TaxConfiguration") } @@ -2969,6 +3017,8 @@ private constructor( fun ofNumeral(numeral: Numeral) = TaxConfiguration(numeral = numeral) fun ofAnrok(anrok: Anrok) = TaxConfiguration(anrok = anrok) + + fun ofStripe(stripe: Stripe) = TaxConfiguration(stripe = stripe) } /** @@ -2987,6 +3037,8 @@ private constructor( fun visitAnrok(anrok: Anrok): T + fun visitStripe(stripe: Stripe): T + /** * Maps an unknown variant of [TaxConfiguration] to a value of type [T]. * @@ -3034,6 +3086,11 @@ private constructor( TaxConfiguration(anrok = it, _json = json) } ?: TaxConfiguration(_json = json) } + "stripe" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + TaxConfiguration(stripe = it, _json = json) + } ?: TaxConfiguration(_json = json) + } } return TaxConfiguration(_json = json) @@ -3053,6 +3110,7 @@ private constructor( value.sphere != null -> generator.writeObject(value.sphere) value.numeral != null -> generator.writeObject(value.numeral) value.anrok != null -> generator.writeObject(value.anrok) + value.stripe != null -> generator.writeObject(value.stripe) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid TaxConfiguration") } @@ -3586,6 +3644,270 @@ private constructor( override fun toString() = "Anrok{taxExempt=$taxExempt, taxProvider=$taxProvider, automaticTaxEnabled=$automaticTaxEnabled, additionalProperties=$additionalProperties}" } + + class Stripe + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val taxExempt: JsonField, + private val taxProvider: JsonValue, + private val automaticTaxEnabled: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("tax_exempt") + @ExcludeMissing + taxExempt: JsonField = JsonMissing.of(), + @JsonProperty("tax_provider") + @ExcludeMissing + taxProvider: JsonValue = JsonMissing.of(), + @JsonProperty("automatic_tax_enabled") + @ExcludeMissing + automaticTaxEnabled: JsonField = JsonMissing.of(), + ) : this(taxExempt, taxProvider, automaticTaxEnabled, mutableMapOf()) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun taxExempt(): Boolean = taxExempt.getRequired("tax_exempt") + + /** + * Expected to always return the following: + * ```kotlin + * JsonValue.from("stripe") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("tax_provider") + @ExcludeMissing + fun _taxProvider(): JsonValue = taxProvider + + /** + * Whether to automatically calculate tax for this customer. When null, inherits from + * account-level setting. When true or false, overrides the account setting. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun automaticTaxEnabled(): Boolean? = + automaticTaxEnabled.getNullable("automatic_tax_enabled") + + /** + * Returns the raw JSON value of [taxExempt]. + * + * Unlike [taxExempt], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tax_exempt") + @ExcludeMissing + fun _taxExempt(): JsonField = taxExempt + + /** + * Returns the raw JSON value of [automaticTaxEnabled]. + * + * Unlike [automaticTaxEnabled], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("automatic_tax_enabled") + @ExcludeMissing + fun _automaticTaxEnabled(): JsonField = automaticTaxEnabled + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Stripe]. + * + * The following fields are required: + * ```kotlin + * .taxExempt() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Stripe]. */ + class Builder internal constructor() { + + private var taxExempt: JsonField? = null + private var taxProvider: JsonValue = JsonValue.from("stripe") + private var automaticTaxEnabled: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(stripe: Stripe) = apply { + taxExempt = stripe.taxExempt + taxProvider = stripe.taxProvider + automaticTaxEnabled = stripe.automaticTaxEnabled + additionalProperties = stripe.additionalProperties.toMutableMap() + } + + fun taxExempt(taxExempt: Boolean) = taxExempt(JsonField.of(taxExempt)) + + /** + * Sets [Builder.taxExempt] to an arbitrary JSON value. + * + * You should usually call [Builder.taxExempt] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun taxExempt(taxExempt: JsonField) = apply { this.taxExempt = taxExempt } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```kotlin + * JsonValue.from("stripe") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun taxProvider(taxProvider: JsonValue) = apply { this.taxProvider = taxProvider } + + /** + * Whether to automatically calculate tax for this customer. When null, inherits + * from account-level setting. When true or false, overrides the account setting. + */ + fun automaticTaxEnabled(automaticTaxEnabled: Boolean?) = + automaticTaxEnabled(JsonField.ofNullable(automaticTaxEnabled)) + + /** + * Alias for [Builder.automaticTaxEnabled]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun automaticTaxEnabled(automaticTaxEnabled: Boolean) = + automaticTaxEnabled(automaticTaxEnabled as Boolean?) + + /** + * Sets [Builder.automaticTaxEnabled] to an arbitrary JSON value. + * + * You should usually call [Builder.automaticTaxEnabled] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun automaticTaxEnabled(automaticTaxEnabled: JsonField) = apply { + this.automaticTaxEnabled = automaticTaxEnabled + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Stripe]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .taxExempt() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Stripe = + Stripe( + checkRequired("taxExempt", taxExempt), + taxProvider, + automaticTaxEnabled, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Stripe = apply { + if (validated) { + return@apply + } + + taxExempt() + _taxProvider().let { + if (it != JsonValue.from("stripe")) { + throw OrbInvalidDataException("'taxProvider' is invalid, received $it") + } + } + automaticTaxEnabled() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (taxExempt.asKnown() == null) 0 else 1) + + taxProvider.let { if (it == JsonValue.from("stripe")) 1 else 0 } + + (if (automaticTaxEnabled.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Stripe && + taxExempt == other.taxExempt && + taxProvider == other.taxProvider && + automaticTaxEnabled == other.automaticTaxEnabled && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(taxExempt, taxProvider, automaticTaxEnabled, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Stripe{taxExempt=$taxExempt, taxProvider=$taxProvider, automaticTaxEnabled=$automaticTaxEnabled, additionalProperties=$additionalProperties}" + } } override fun equals(other: Any?): Boolean { From bdc7d3aa262fe9d79e9ce81dbc79b4ad7ac748eb Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 13 Nov 2025 06:46:45 +0000 Subject: [PATCH 48/68] fix(client): multi-value header serialization --- .../kotlin/com/withorb/api/client/okhttp/OkHttpClient.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/orb-kotlin-client-okhttp/src/main/kotlin/com/withorb/api/client/okhttp/OkHttpClient.kt b/orb-kotlin-client-okhttp/src/main/kotlin/com/withorb/api/client/okhttp/OkHttpClient.kt index e11a7c94e..093faa347 100644 --- a/orb-kotlin-client-okhttp/src/main/kotlin/com/withorb/api/client/okhttp/OkHttpClient.kt +++ b/orb-kotlin-client-okhttp/src/main/kotlin/com/withorb/api/client/okhttp/OkHttpClient.kt @@ -117,19 +117,19 @@ class OkHttpClient private constructor(private val okHttpClient: okhttp3.OkHttpC val builder = Request.Builder().url(toUrl()).method(method.name, body) headers.names().forEach { name -> - headers.values(name).forEach { builder.header(name, it) } + headers.values(name).forEach { builder.addHeader(name, it) } } if ( !headers.names().contains("X-Stainless-Read-Timeout") && client.readTimeoutMillis != 0 ) { - builder.header( + builder.addHeader( "X-Stainless-Read-Timeout", Duration.ofMillis(client.readTimeoutMillis.toLong()).seconds.toString(), ) } if (!headers.names().contains("X-Stainless-Timeout") && client.callTimeoutMillis != 0) { - builder.header( + builder.addHeader( "X-Stainless-Timeout", Duration.ofMillis(client.callTimeoutMillis.toLong()).seconds.toString(), ) From 0f366e8c6196b679186999278cb93686eda3c6a9 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 13 Nov 2025 22:27:44 +0000 Subject: [PATCH 49/68] feat(api): api update --- .stats.yml | 4 +- .../models/ChangedSubscriptionResources.kt | 314 +-------------- .../kotlin/com/withorb/api/models/Invoice.kt | 309 +-------------- .../models/InvoiceFetchUpcomingResponse.kt | 309 +-------------- .../models/InvoiceLineItemCreateResponse.kt | 302 +-------------- .../ChangedSubscriptionResourcesTest.kt | 272 ------------- ...dgerCreateEntryByExternalIdResponseTest.kt | 94 ----- ...omerCreditLedgerCreateEntryResponseTest.kt | 94 ----- ...tLedgerListByExternalIdPageResponseTest.kt | 153 -------- ...reditLedgerListByExternalIdResponseTest.kt | 94 ----- ...ustomerCreditLedgerListPageResponseTest.kt | 153 -------- .../CustomerCreditLedgerListResponseTest.kt | 94 ----- .../api/models/IncrementLedgerEntryTest.kt | 136 ------- .../InvoiceFetchUpcomingResponseTest.kt | 132 ------- .../InvoiceLineItemCreateResponseTest.kt | 137 ------- .../api/models/InvoiceListPageResponseTest.kt | 136 ------- .../com/withorb/api/models/InvoiceTest.kt | 132 ------- .../api/models/MutatedSubscriptionTest.kt | 300 --------------- .../SubscriptionChangeApplyResponseTest.kt | 360 ------------------ .../SubscriptionChangeCancelResponseTest.kt | 360 ------------------ .../SubscriptionChangeRetrieveResponseTest.kt | 360 ------------------ 21 files changed, 6 insertions(+), 4239 deletions(-) diff --git a/.stats.yml b/.stats.yml index a477a2c51..107688d5a 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 118 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-145c6652d32a05c9305e4674643e2aa7d559073e48dc252d6c3c0fe802ce7ec6.yml -openapi_spec_hash: 6bbbbe1687099b69faee47fda12bf82c +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-9e751a2aefff382af949380b5979a80cb02743eca1583cf5146325fb400ba87f.yml +openapi_spec_hash: 219a1008f47d3293f64f1baebe2d6eb5 config_hash: e6db17547fe854b1c240407cf4c6dc9e diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/ChangedSubscriptionResources.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/ChangedSubscriptionResources.kt index f0d36843c..f061ffb3a 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/ChangedSubscriptionResources.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/ChangedSubscriptionResources.kt @@ -4429,14 +4429,9 @@ private constructor( private val adjustments: JsonField>, private val amount: JsonField, private val creditsApplied: JsonField, - private val discount: JsonField, private val endDate: JsonField, private val filter: JsonField, private val grouping: JsonField, - private val maximum: JsonField, - private val maximumAmount: JsonField, - private val minimum: JsonField, - private val minimumAmount: JsonField, private val name: JsonField, private val partiallyInvoicedAmount: JsonField, private val price: JsonField, @@ -4464,9 +4459,6 @@ private constructor( @JsonProperty("credits_applied") @ExcludeMissing creditsApplied: JsonField = JsonMissing.of(), - @JsonProperty("discount") - @ExcludeMissing - discount: JsonField = JsonMissing.of(), @JsonProperty("end_date") @ExcludeMissing endDate: JsonField = JsonMissing.of(), @@ -4476,18 +4468,6 @@ private constructor( @JsonProperty("grouping") @ExcludeMissing grouping: JsonField = JsonMissing.of(), - @JsonProperty("maximum") - @ExcludeMissing - maximum: JsonField = JsonMissing.of(), - @JsonProperty("maximum_amount") - @ExcludeMissing - maximumAmount: JsonField = JsonMissing.of(), - @JsonProperty("minimum") - @ExcludeMissing - minimum: JsonField = JsonMissing.of(), - @JsonProperty("minimum_amount") - @ExcludeMissing - minimumAmount: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @JsonProperty("partially_invoiced_amount") @ExcludeMissing @@ -4517,14 +4497,9 @@ private constructor( adjustments, amount, creditsApplied, - discount, endDate, filter, grouping, - maximum, - maximumAmount, - minimum, - minimumAmount, name, partiallyInvoicedAmount, price, @@ -4586,14 +4561,6 @@ private constructor( */ fun creditsApplied(): String = creditsApplied.getRequired("credits_applied") - /** - * This field is deprecated in favor of `adjustments` - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - @Deprecated("deprecated") fun discount(): Discount? = discount.getNullable("discount") - /** * The end date of the range of time applied for this line item's price. * @@ -4621,40 +4588,6 @@ private constructor( */ fun grouping(): String? = grouping.getNullable("grouping") - /** - * This field is deprecated in favor of `adjustments`. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - @Deprecated("deprecated") fun maximum(): Maximum? = maximum.getNullable("maximum") - - /** - * This field is deprecated in favor of `adjustments`. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - @Deprecated("deprecated") - fun maximumAmount(): String? = maximumAmount.getNullable("maximum_amount") - - /** - * This field is deprecated in favor of `adjustments`. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - @Deprecated("deprecated") fun minimum(): Minimum? = minimum.getNullable("minimum") - - /** - * This field is deprecated in favor of `adjustments`. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - @Deprecated("deprecated") - fun minimumAmount(): String? = minimumAmount.getNullable("minimum_amount") - /** * The name of the price associated with this line item. * @@ -4792,17 +4725,6 @@ private constructor( @ExcludeMissing fun _creditsApplied(): JsonField = creditsApplied - /** - * Returns the raw JSON value of [discount]. - * - * Unlike [discount], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @Deprecated("deprecated") - @JsonProperty("discount") - @ExcludeMissing - fun _discount(): JsonField = discount - /** * Returns the raw JSON value of [endDate]. * @@ -4827,48 +4749,6 @@ private constructor( */ @JsonProperty("grouping") @ExcludeMissing fun _grouping(): JsonField = grouping - /** - * Returns the raw JSON value of [maximum]. - * - * Unlike [maximum], this method doesn't throw if the JSON field has an unexpected type. - */ - @Deprecated("deprecated") - @JsonProperty("maximum") - @ExcludeMissing - fun _maximum(): JsonField = maximum - - /** - * Returns the raw JSON value of [maximumAmount]. - * - * Unlike [maximumAmount], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @Deprecated("deprecated") - @JsonProperty("maximum_amount") - @ExcludeMissing - fun _maximumAmount(): JsonField = maximumAmount - - /** - * Returns the raw JSON value of [minimum]. - * - * Unlike [minimum], this method doesn't throw if the JSON field has an unexpected type. - */ - @Deprecated("deprecated") - @JsonProperty("minimum") - @ExcludeMissing - fun _minimum(): JsonField = minimum - - /** - * Returns the raw JSON value of [minimumAmount]. - * - * Unlike [minimumAmount], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @Deprecated("deprecated") - @JsonProperty("minimum_amount") - @ExcludeMissing - fun _minimumAmount(): JsonField = minimumAmount - /** * Returns the raw JSON value of [name]. * @@ -4973,14 +4853,9 @@ private constructor( * .adjustments() * .amount() * .creditsApplied() - * .discount() * .endDate() * .filter() * .grouping() - * .maximum() - * .maximumAmount() - * .minimum() - * .minimumAmount() * .name() * .partiallyInvoicedAmount() * .price() @@ -5003,14 +4878,9 @@ private constructor( private var adjustments: JsonField>? = null private var amount: JsonField? = null private var creditsApplied: JsonField? = null - private var discount: JsonField? = null private var endDate: JsonField? = null private var filter: JsonField? = null private var grouping: JsonField? = null - private var maximum: JsonField? = null - private var maximumAmount: JsonField? = null - private var minimum: JsonField? = null - private var minimumAmount: JsonField? = null private var name: JsonField? = null private var partiallyInvoicedAmount: JsonField? = null private var price: JsonField? = null @@ -5028,14 +4898,9 @@ private constructor( adjustments = lineItem.adjustments.map { it.toMutableList() } amount = lineItem.amount creditsApplied = lineItem.creditsApplied - discount = lineItem.discount endDate = lineItem.endDate filter = lineItem.filter grouping = lineItem.grouping - maximum = lineItem.maximum - maximumAmount = lineItem.maximumAmount - minimum = lineItem.minimum - minimumAmount = lineItem.minimumAmount name = lineItem.name partiallyInvoicedAmount = lineItem.partiallyInvoicedAmount price = lineItem.price @@ -5168,91 +5033,6 @@ private constructor( this.creditsApplied = creditsApplied } - /** This field is deprecated in favor of `adjustments` */ - @Deprecated("deprecated") - fun discount(discount: Discount?) = discount(JsonField.ofNullable(discount)) - - /** - * Sets [Builder.discount] to an arbitrary JSON value. - * - * You should usually call [Builder.discount] with a well-typed [Discount] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - @Deprecated("deprecated") - fun discount(discount: JsonField) = apply { this.discount = discount } - - /** Alias for calling [discount] with `Discount.ofPercentage(percentage)`. */ - @Deprecated("deprecated") - fun discount(percentage: PercentageDiscount) = - discount(Discount.ofPercentage(percentage)) - - /** - * Alias for calling [discount] with the following: - * ```kotlin - * PercentageDiscount.builder() - * .discountType(PercentageDiscount.DiscountType.PERCENTAGE) - * .percentageDiscount(percentageDiscount) - * .build() - * ``` - */ - @Deprecated("deprecated") - fun percentageDiscount(percentageDiscount: Double) = - discount( - PercentageDiscount.builder() - .discountType(PercentageDiscount.DiscountType.PERCENTAGE) - .percentageDiscount(percentageDiscount) - .build() - ) - - /** Alias for calling [discount] with `Discount.ofTrial(trial)`. */ - @Deprecated("deprecated") - fun discount(trial: TrialDiscount) = discount(Discount.ofTrial(trial)) - - /** Alias for calling [discount] with `Discount.ofUsage(usage)`. */ - @Deprecated("deprecated") - fun discount(usage: UsageDiscount) = discount(Discount.ofUsage(usage)) - - /** - * Alias for calling [discount] with the following: - * ```kotlin - * UsageDiscount.builder() - * .discountType(UsageDiscount.DiscountType.USAGE) - * .usageDiscount(usageDiscount) - * .build() - * ``` - */ - @Deprecated("deprecated") - fun usageDiscount(usageDiscount: Double) = - discount( - UsageDiscount.builder() - .discountType(UsageDiscount.DiscountType.USAGE) - .usageDiscount(usageDiscount) - .build() - ) - - /** Alias for calling [discount] with `Discount.ofAmount(amount)`. */ - @Deprecated("deprecated") - fun discount(amount: AmountDiscount) = discount(Discount.ofAmount(amount)) - - /** - * Alias for calling [discount] with the following: - * ```kotlin - * AmountDiscount.builder() - * .discountType(AmountDiscount.DiscountType.AMOUNT) - * .amountDiscount(amountDiscount) - * .build() - * ``` - */ - @Deprecated("deprecated") - fun amountDiscount(amountDiscount: String) = - discount( - AmountDiscount.builder() - .discountType(AmountDiscount.DiscountType.AMOUNT) - .amountDiscount(amountDiscount) - .build() - ) - /** The end date of the range of time applied for this line item's price. */ fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) @@ -5293,68 +5073,6 @@ private constructor( */ fun grouping(grouping: JsonField) = apply { this.grouping = grouping } - /** This field is deprecated in favor of `adjustments`. */ - @Deprecated("deprecated") - fun maximum(maximum: Maximum?) = maximum(JsonField.ofNullable(maximum)) - - /** - * Sets [Builder.maximum] to an arbitrary JSON value. - * - * You should usually call [Builder.maximum] with a well-typed [Maximum] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - @Deprecated("deprecated") - fun maximum(maximum: JsonField) = apply { this.maximum = maximum } - - /** This field is deprecated in favor of `adjustments`. */ - @Deprecated("deprecated") - fun maximumAmount(maximumAmount: String?) = - maximumAmount(JsonField.ofNullable(maximumAmount)) - - /** - * Sets [Builder.maximumAmount] to an arbitrary JSON value. - * - * You should usually call [Builder.maximumAmount] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - @Deprecated("deprecated") - fun maximumAmount(maximumAmount: JsonField) = apply { - this.maximumAmount = maximumAmount - } - - /** This field is deprecated in favor of `adjustments`. */ - @Deprecated("deprecated") - fun minimum(minimum: Minimum?) = minimum(JsonField.ofNullable(minimum)) - - /** - * Sets [Builder.minimum] to an arbitrary JSON value. - * - * You should usually call [Builder.minimum] with a well-typed [Minimum] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - @Deprecated("deprecated") - fun minimum(minimum: JsonField) = apply { this.minimum = minimum } - - /** This field is deprecated in favor of `adjustments`. */ - @Deprecated("deprecated") - fun minimumAmount(minimumAmount: String?) = - minimumAmount(JsonField.ofNullable(minimumAmount)) - - /** - * Sets [Builder.minimumAmount] to an arbitrary JSON value. - * - * You should usually call [Builder.minimumAmount] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - @Deprecated("deprecated") - fun minimumAmount(minimumAmount: JsonField) = apply { - this.minimumAmount = minimumAmount - } - /** The name of the price associated with this line item. */ fun name(name: String) = name(JsonField.of(name)) @@ -5738,14 +5456,9 @@ private constructor( * .adjustments() * .amount() * .creditsApplied() - * .discount() * .endDate() * .filter() * .grouping() - * .maximum() - * .maximumAmount() - * .minimum() - * .minimumAmount() * .name() * .partiallyInvoicedAmount() * .price() @@ -5766,14 +5479,9 @@ private constructor( checkRequired("adjustments", adjustments).map { it.toImmutable() }, checkRequired("amount", amount), checkRequired("creditsApplied", creditsApplied), - checkRequired("discount", discount), checkRequired("endDate", endDate), checkRequired("filter", filter), checkRequired("grouping", grouping), - checkRequired("maximum", maximum), - checkRequired("maximumAmount", maximumAmount), - checkRequired("minimum", minimum), - checkRequired("minimumAmount", minimumAmount), checkRequired("name", name), checkRequired("partiallyInvoicedAmount", partiallyInvoicedAmount), checkRequired("price", price), @@ -5801,14 +5509,9 @@ private constructor( adjustments().forEach { it.validate() } amount() creditsApplied() - discount()?.validate() endDate() filter() grouping() - maximum()?.validate() - maximumAmount() - minimum()?.validate() - minimumAmount() name() partiallyInvoicedAmount() price().validate() @@ -5841,14 +5544,9 @@ private constructor( (adjustments.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + (if (amount.asKnown() == null) 0 else 1) + (if (creditsApplied.asKnown() == null) 0 else 1) + - (discount.asKnown()?.validity() ?: 0) + (if (endDate.asKnown() == null) 0 else 1) + (if (filter.asKnown() == null) 0 else 1) + (if (grouping.asKnown() == null) 0 else 1) + - (maximum.asKnown()?.validity() ?: 0) + - (if (maximumAmount.asKnown() == null) 0 else 1) + - (minimum.asKnown()?.validity() ?: 0) + - (if (minimumAmount.asKnown() == null) 0 else 1) + (if (name.asKnown() == null) 0 else 1) + (if (partiallyInvoicedAmount.asKnown() == null) 0 else 1) + (price.asKnown()?.validity() ?: 0) + @@ -6362,14 +6060,9 @@ private constructor( adjustments == other.adjustments && amount == other.amount && creditsApplied == other.creditsApplied && - discount == other.discount && endDate == other.endDate && filter == other.filter && grouping == other.grouping && - maximum == other.maximum && - maximumAmount == other.maximumAmount && - minimum == other.minimum && - minimumAmount == other.minimumAmount && name == other.name && partiallyInvoicedAmount == other.partiallyInvoicedAmount && price == other.price && @@ -6389,14 +6082,9 @@ private constructor( adjustments, amount, creditsApplied, - discount, endDate, filter, grouping, - maximum, - maximumAmount, - minimum, - minimumAmount, name, partiallyInvoicedAmount, price, @@ -6413,7 +6101,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "LineItem{id=$id, adjustedSubtotal=$adjustedSubtotal, adjustments=$adjustments, amount=$amount, creditsApplied=$creditsApplied, discount=$discount, endDate=$endDate, filter=$filter, grouping=$grouping, maximum=$maximum, maximumAmount=$maximumAmount, minimum=$minimum, minimumAmount=$minimumAmount, name=$name, partiallyInvoicedAmount=$partiallyInvoicedAmount, price=$price, quantity=$quantity, startDate=$startDate, subLineItems=$subLineItems, subtotal=$subtotal, taxAmounts=$taxAmounts, usageCustomerIds=$usageCustomerIds, additionalProperties=$additionalProperties}" + "LineItem{id=$id, adjustedSubtotal=$adjustedSubtotal, adjustments=$adjustments, amount=$amount, creditsApplied=$creditsApplied, endDate=$endDate, filter=$filter, grouping=$grouping, name=$name, partiallyInvoicedAmount=$partiallyInvoicedAmount, price=$price, quantity=$quantity, startDate=$startDate, subLineItems=$subLineItems, subtotal=$subtotal, taxAmounts=$taxAmounts, usageCustomerIds=$usageCustomerIds, additionalProperties=$additionalProperties}" } /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Invoice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Invoice.kt index 326d69e14..81fe72244 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Invoice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Invoice.kt @@ -3956,14 +3956,9 @@ private constructor( private val adjustments: JsonField>, private val amount: JsonField, private val creditsApplied: JsonField, - private val discount: JsonField, private val endDate: JsonField, private val filter: JsonField, private val grouping: JsonField, - private val maximum: JsonField, - private val maximumAmount: JsonField, - private val minimum: JsonField, - private val minimumAmount: JsonField, private val name: JsonField, private val partiallyInvoicedAmount: JsonField, private val price: JsonField, @@ -3989,9 +3984,6 @@ private constructor( @JsonProperty("credits_applied") @ExcludeMissing creditsApplied: JsonField = JsonMissing.of(), - @JsonProperty("discount") - @ExcludeMissing - discount: JsonField = JsonMissing.of(), @JsonProperty("end_date") @ExcludeMissing endDate: JsonField = JsonMissing.of(), @@ -3999,14 +3991,6 @@ private constructor( @JsonProperty("grouping") @ExcludeMissing grouping: JsonField = JsonMissing.of(), - @JsonProperty("maximum") @ExcludeMissing maximum: JsonField = JsonMissing.of(), - @JsonProperty("maximum_amount") - @ExcludeMissing - maximumAmount: JsonField = JsonMissing.of(), - @JsonProperty("minimum") @ExcludeMissing minimum: JsonField = JsonMissing.of(), - @JsonProperty("minimum_amount") - @ExcludeMissing - minimumAmount: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @JsonProperty("partially_invoiced_amount") @ExcludeMissing @@ -4036,14 +4020,9 @@ private constructor( adjustments, amount, creditsApplied, - discount, endDate, filter, grouping, - maximum, - maximumAmount, - minimum, - minimumAmount, name, partiallyInvoicedAmount, price, @@ -4100,14 +4079,6 @@ private constructor( */ fun creditsApplied(): String = creditsApplied.getRequired("credits_applied") - /** - * This field is deprecated in favor of `adjustments` - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - @Deprecated("deprecated") fun discount(): Discount? = discount.getNullable("discount") - /** * The end date of the range of time applied for this line item's price. * @@ -4134,40 +4105,6 @@ private constructor( */ fun grouping(): String? = grouping.getNullable("grouping") - /** - * This field is deprecated in favor of `adjustments`. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - @Deprecated("deprecated") fun maximum(): Maximum? = maximum.getNullable("maximum") - - /** - * This field is deprecated in favor of `adjustments`. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - @Deprecated("deprecated") - fun maximumAmount(): String? = maximumAmount.getNullable("maximum_amount") - - /** - * This field is deprecated in favor of `adjustments`. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - @Deprecated("deprecated") fun minimum(): Minimum? = minimum.getNullable("minimum") - - /** - * This field is deprecated in favor of `adjustments`. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - @Deprecated("deprecated") - fun minimumAmount(): String? = minimumAmount.getNullable("minimum_amount") - /** * The name of the price associated with this line item. * @@ -4295,16 +4232,6 @@ private constructor( @ExcludeMissing fun _creditsApplied(): JsonField = creditsApplied - /** - * Returns the raw JSON value of [discount]. - * - * Unlike [discount], this method doesn't throw if the JSON field has an unexpected type. - */ - @Deprecated("deprecated") - @JsonProperty("discount") - @ExcludeMissing - fun _discount(): JsonField = discount - /** * Returns the raw JSON value of [endDate]. * @@ -4328,48 +4255,6 @@ private constructor( */ @JsonProperty("grouping") @ExcludeMissing fun _grouping(): JsonField = grouping - /** - * Returns the raw JSON value of [maximum]. - * - * Unlike [maximum], this method doesn't throw if the JSON field has an unexpected type. - */ - @Deprecated("deprecated") - @JsonProperty("maximum") - @ExcludeMissing - fun _maximum(): JsonField = maximum - - /** - * Returns the raw JSON value of [maximumAmount]. - * - * Unlike [maximumAmount], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @Deprecated("deprecated") - @JsonProperty("maximum_amount") - @ExcludeMissing - fun _maximumAmount(): JsonField = maximumAmount - - /** - * Returns the raw JSON value of [minimum]. - * - * Unlike [minimum], this method doesn't throw if the JSON field has an unexpected type. - */ - @Deprecated("deprecated") - @JsonProperty("minimum") - @ExcludeMissing - fun _minimum(): JsonField = minimum - - /** - * Returns the raw JSON value of [minimumAmount]. - * - * Unlike [minimumAmount], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @Deprecated("deprecated") - @JsonProperty("minimum_amount") - @ExcludeMissing - fun _minimumAmount(): JsonField = minimumAmount - /** * Returns the raw JSON value of [name]. * @@ -4470,14 +4355,9 @@ private constructor( * .adjustments() * .amount() * .creditsApplied() - * .discount() * .endDate() * .filter() * .grouping() - * .maximum() - * .maximumAmount() - * .minimum() - * .minimumAmount() * .name() * .partiallyInvoicedAmount() * .price() @@ -4500,14 +4380,9 @@ private constructor( private var adjustments: JsonField>? = null private var amount: JsonField? = null private var creditsApplied: JsonField? = null - private var discount: JsonField? = null private var endDate: JsonField? = null private var filter: JsonField? = null private var grouping: JsonField? = null - private var maximum: JsonField? = null - private var maximumAmount: JsonField? = null - private var minimum: JsonField? = null - private var minimumAmount: JsonField? = null private var name: JsonField? = null private var partiallyInvoicedAmount: JsonField? = null private var price: JsonField? = null @@ -4525,14 +4400,9 @@ private constructor( adjustments = lineItem.adjustments.map { it.toMutableList() } amount = lineItem.amount creditsApplied = lineItem.creditsApplied - discount = lineItem.discount endDate = lineItem.endDate filter = lineItem.filter grouping = lineItem.grouping - maximum = lineItem.maximum - maximumAmount = lineItem.maximumAmount - minimum = lineItem.minimum - minimumAmount = lineItem.minimumAmount name = lineItem.name partiallyInvoicedAmount = lineItem.partiallyInvoicedAmount price = lineItem.price @@ -4662,91 +4532,6 @@ private constructor( this.creditsApplied = creditsApplied } - /** This field is deprecated in favor of `adjustments` */ - @Deprecated("deprecated") - fun discount(discount: Discount?) = discount(JsonField.ofNullable(discount)) - - /** - * Sets [Builder.discount] to an arbitrary JSON value. - * - * You should usually call [Builder.discount] with a well-typed [Discount] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - @Deprecated("deprecated") - fun discount(discount: JsonField) = apply { this.discount = discount } - - /** Alias for calling [discount] with `Discount.ofPercentage(percentage)`. */ - @Deprecated("deprecated") - fun discount(percentage: PercentageDiscount) = - discount(Discount.ofPercentage(percentage)) - - /** - * Alias for calling [discount] with the following: - * ```kotlin - * PercentageDiscount.builder() - * .discountType(PercentageDiscount.DiscountType.PERCENTAGE) - * .percentageDiscount(percentageDiscount) - * .build() - * ``` - */ - @Deprecated("deprecated") - fun percentageDiscount(percentageDiscount: Double) = - discount( - PercentageDiscount.builder() - .discountType(PercentageDiscount.DiscountType.PERCENTAGE) - .percentageDiscount(percentageDiscount) - .build() - ) - - /** Alias for calling [discount] with `Discount.ofTrial(trial)`. */ - @Deprecated("deprecated") - fun discount(trial: TrialDiscount) = discount(Discount.ofTrial(trial)) - - /** Alias for calling [discount] with `Discount.ofUsage(usage)`. */ - @Deprecated("deprecated") - fun discount(usage: UsageDiscount) = discount(Discount.ofUsage(usage)) - - /** - * Alias for calling [discount] with the following: - * ```kotlin - * UsageDiscount.builder() - * .discountType(UsageDiscount.DiscountType.USAGE) - * .usageDiscount(usageDiscount) - * .build() - * ``` - */ - @Deprecated("deprecated") - fun usageDiscount(usageDiscount: Double) = - discount( - UsageDiscount.builder() - .discountType(UsageDiscount.DiscountType.USAGE) - .usageDiscount(usageDiscount) - .build() - ) - - /** Alias for calling [discount] with `Discount.ofAmount(amount)`. */ - @Deprecated("deprecated") - fun discount(amount: AmountDiscount) = discount(Discount.ofAmount(amount)) - - /** - * Alias for calling [discount] with the following: - * ```kotlin - * AmountDiscount.builder() - * .discountType(AmountDiscount.DiscountType.AMOUNT) - * .amountDiscount(amountDiscount) - * .build() - * ``` - */ - @Deprecated("deprecated") - fun amountDiscount(amountDiscount: String) = - discount( - AmountDiscount.builder() - .discountType(AmountDiscount.DiscountType.AMOUNT) - .amountDiscount(amountDiscount) - .build() - ) - /** The end date of the range of time applied for this line item's price. */ fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) @@ -4787,68 +4572,6 @@ private constructor( */ fun grouping(grouping: JsonField) = apply { this.grouping = grouping } - /** This field is deprecated in favor of `adjustments`. */ - @Deprecated("deprecated") - fun maximum(maximum: Maximum?) = maximum(JsonField.ofNullable(maximum)) - - /** - * Sets [Builder.maximum] to an arbitrary JSON value. - * - * You should usually call [Builder.maximum] with a well-typed [Maximum] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - @Deprecated("deprecated") - fun maximum(maximum: JsonField) = apply { this.maximum = maximum } - - /** This field is deprecated in favor of `adjustments`. */ - @Deprecated("deprecated") - fun maximumAmount(maximumAmount: String?) = - maximumAmount(JsonField.ofNullable(maximumAmount)) - - /** - * Sets [Builder.maximumAmount] to an arbitrary JSON value. - * - * You should usually call [Builder.maximumAmount] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - @Deprecated("deprecated") - fun maximumAmount(maximumAmount: JsonField) = apply { - this.maximumAmount = maximumAmount - } - - /** This field is deprecated in favor of `adjustments`. */ - @Deprecated("deprecated") - fun minimum(minimum: Minimum?) = minimum(JsonField.ofNullable(minimum)) - - /** - * Sets [Builder.minimum] to an arbitrary JSON value. - * - * You should usually call [Builder.minimum] with a well-typed [Minimum] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - @Deprecated("deprecated") - fun minimum(minimum: JsonField) = apply { this.minimum = minimum } - - /** This field is deprecated in favor of `adjustments`. */ - @Deprecated("deprecated") - fun minimumAmount(minimumAmount: String?) = - minimumAmount(JsonField.ofNullable(minimumAmount)) - - /** - * Sets [Builder.minimumAmount] to an arbitrary JSON value. - * - * You should usually call [Builder.minimumAmount] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - @Deprecated("deprecated") - fun minimumAmount(minimumAmount: JsonField) = apply { - this.minimumAmount = minimumAmount - } - /** The name of the price associated with this line item. */ fun name(name: String) = name(JsonField.of(name)) @@ -5214,14 +4937,9 @@ private constructor( * .adjustments() * .amount() * .creditsApplied() - * .discount() * .endDate() * .filter() * .grouping() - * .maximum() - * .maximumAmount() - * .minimum() - * .minimumAmount() * .name() * .partiallyInvoicedAmount() * .price() @@ -5242,14 +4960,9 @@ private constructor( checkRequired("adjustments", adjustments).map { it.toImmutable() }, checkRequired("amount", amount), checkRequired("creditsApplied", creditsApplied), - checkRequired("discount", discount), checkRequired("endDate", endDate), checkRequired("filter", filter), checkRequired("grouping", grouping), - checkRequired("maximum", maximum), - checkRequired("maximumAmount", maximumAmount), - checkRequired("minimum", minimum), - checkRequired("minimumAmount", minimumAmount), checkRequired("name", name), checkRequired("partiallyInvoicedAmount", partiallyInvoicedAmount), checkRequired("price", price), @@ -5275,14 +4988,9 @@ private constructor( adjustments().forEach { it.validate() } amount() creditsApplied() - discount()?.validate() endDate() filter() grouping() - maximum()?.validate() - maximumAmount() - minimum()?.validate() - minimumAmount() name() partiallyInvoicedAmount() price().validate() @@ -5315,14 +5023,9 @@ private constructor( (adjustments.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + (if (amount.asKnown() == null) 0 else 1) + (if (creditsApplied.asKnown() == null) 0 else 1) + - (discount.asKnown()?.validity() ?: 0) + (if (endDate.asKnown() == null) 0 else 1) + (if (filter.asKnown() == null) 0 else 1) + (if (grouping.asKnown() == null) 0 else 1) + - (maximum.asKnown()?.validity() ?: 0) + - (if (maximumAmount.asKnown() == null) 0 else 1) + - (minimum.asKnown()?.validity() ?: 0) + - (if (minimumAmount.asKnown() == null) 0 else 1) + (if (name.asKnown() == null) 0 else 1) + (if (partiallyInvoicedAmount.asKnown() == null) 0 else 1) + (price.asKnown()?.validity() ?: 0) + @@ -5819,14 +5522,9 @@ private constructor( adjustments == other.adjustments && amount == other.amount && creditsApplied == other.creditsApplied && - discount == other.discount && endDate == other.endDate && filter == other.filter && grouping == other.grouping && - maximum == other.maximum && - maximumAmount == other.maximumAmount && - minimum == other.minimum && - minimumAmount == other.minimumAmount && name == other.name && partiallyInvoicedAmount == other.partiallyInvoicedAmount && price == other.price && @@ -5846,14 +5544,9 @@ private constructor( adjustments, amount, creditsApplied, - discount, endDate, filter, grouping, - maximum, - maximumAmount, - minimum, - minimumAmount, name, partiallyInvoicedAmount, price, @@ -5870,7 +5563,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "LineItem{id=$id, adjustedSubtotal=$adjustedSubtotal, adjustments=$adjustments, amount=$amount, creditsApplied=$creditsApplied, discount=$discount, endDate=$endDate, filter=$filter, grouping=$grouping, maximum=$maximum, maximumAmount=$maximumAmount, minimum=$minimum, minimumAmount=$minimumAmount, name=$name, partiallyInvoicedAmount=$partiallyInvoicedAmount, price=$price, quantity=$quantity, startDate=$startDate, subLineItems=$subLineItems, subtotal=$subtotal, taxAmounts=$taxAmounts, usageCustomerIds=$usageCustomerIds, additionalProperties=$additionalProperties}" + "LineItem{id=$id, adjustedSubtotal=$adjustedSubtotal, adjustments=$adjustments, amount=$amount, creditsApplied=$creditsApplied, endDate=$endDate, filter=$filter, grouping=$grouping, name=$name, partiallyInvoicedAmount=$partiallyInvoicedAmount, price=$price, quantity=$quantity, startDate=$startDate, subLineItems=$subLineItems, subtotal=$subtotal, taxAmounts=$taxAmounts, usageCustomerIds=$usageCustomerIds, additionalProperties=$additionalProperties}" } /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceFetchUpcomingResponse.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceFetchUpcomingResponse.kt index ef41c5d33..dd4898800 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceFetchUpcomingResponse.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceFetchUpcomingResponse.kt @@ -3950,14 +3950,9 @@ private constructor( private val adjustments: JsonField>, private val amount: JsonField, private val creditsApplied: JsonField, - private val discount: JsonField, private val endDate: JsonField, private val filter: JsonField, private val grouping: JsonField, - private val maximum: JsonField, - private val maximumAmount: JsonField, - private val minimum: JsonField, - private val minimumAmount: JsonField, private val name: JsonField, private val partiallyInvoicedAmount: JsonField, private val price: JsonField, @@ -3983,9 +3978,6 @@ private constructor( @JsonProperty("credits_applied") @ExcludeMissing creditsApplied: JsonField = JsonMissing.of(), - @JsonProperty("discount") - @ExcludeMissing - discount: JsonField = JsonMissing.of(), @JsonProperty("end_date") @ExcludeMissing endDate: JsonField = JsonMissing.of(), @@ -3993,14 +3985,6 @@ private constructor( @JsonProperty("grouping") @ExcludeMissing grouping: JsonField = JsonMissing.of(), - @JsonProperty("maximum") @ExcludeMissing maximum: JsonField = JsonMissing.of(), - @JsonProperty("maximum_amount") - @ExcludeMissing - maximumAmount: JsonField = JsonMissing.of(), - @JsonProperty("minimum") @ExcludeMissing minimum: JsonField = JsonMissing.of(), - @JsonProperty("minimum_amount") - @ExcludeMissing - minimumAmount: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @JsonProperty("partially_invoiced_amount") @ExcludeMissing @@ -4030,14 +4014,9 @@ private constructor( adjustments, amount, creditsApplied, - discount, endDate, filter, grouping, - maximum, - maximumAmount, - minimum, - minimumAmount, name, partiallyInvoicedAmount, price, @@ -4094,14 +4073,6 @@ private constructor( */ fun creditsApplied(): String = creditsApplied.getRequired("credits_applied") - /** - * This field is deprecated in favor of `adjustments` - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - @Deprecated("deprecated") fun discount(): Discount? = discount.getNullable("discount") - /** * The end date of the range of time applied for this line item's price. * @@ -4128,40 +4099,6 @@ private constructor( */ fun grouping(): String? = grouping.getNullable("grouping") - /** - * This field is deprecated in favor of `adjustments`. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - @Deprecated("deprecated") fun maximum(): Maximum? = maximum.getNullable("maximum") - - /** - * This field is deprecated in favor of `adjustments`. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - @Deprecated("deprecated") - fun maximumAmount(): String? = maximumAmount.getNullable("maximum_amount") - - /** - * This field is deprecated in favor of `adjustments`. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - @Deprecated("deprecated") fun minimum(): Minimum? = minimum.getNullable("minimum") - - /** - * This field is deprecated in favor of `adjustments`. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - @Deprecated("deprecated") - fun minimumAmount(): String? = minimumAmount.getNullable("minimum_amount") - /** * The name of the price associated with this line item. * @@ -4289,16 +4226,6 @@ private constructor( @ExcludeMissing fun _creditsApplied(): JsonField = creditsApplied - /** - * Returns the raw JSON value of [discount]. - * - * Unlike [discount], this method doesn't throw if the JSON field has an unexpected type. - */ - @Deprecated("deprecated") - @JsonProperty("discount") - @ExcludeMissing - fun _discount(): JsonField = discount - /** * Returns the raw JSON value of [endDate]. * @@ -4322,48 +4249,6 @@ private constructor( */ @JsonProperty("grouping") @ExcludeMissing fun _grouping(): JsonField = grouping - /** - * Returns the raw JSON value of [maximum]. - * - * Unlike [maximum], this method doesn't throw if the JSON field has an unexpected type. - */ - @Deprecated("deprecated") - @JsonProperty("maximum") - @ExcludeMissing - fun _maximum(): JsonField = maximum - - /** - * Returns the raw JSON value of [maximumAmount]. - * - * Unlike [maximumAmount], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @Deprecated("deprecated") - @JsonProperty("maximum_amount") - @ExcludeMissing - fun _maximumAmount(): JsonField = maximumAmount - - /** - * Returns the raw JSON value of [minimum]. - * - * Unlike [minimum], this method doesn't throw if the JSON field has an unexpected type. - */ - @Deprecated("deprecated") - @JsonProperty("minimum") - @ExcludeMissing - fun _minimum(): JsonField = minimum - - /** - * Returns the raw JSON value of [minimumAmount]. - * - * Unlike [minimumAmount], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @Deprecated("deprecated") - @JsonProperty("minimum_amount") - @ExcludeMissing - fun _minimumAmount(): JsonField = minimumAmount - /** * Returns the raw JSON value of [name]. * @@ -4464,14 +4349,9 @@ private constructor( * .adjustments() * .amount() * .creditsApplied() - * .discount() * .endDate() * .filter() * .grouping() - * .maximum() - * .maximumAmount() - * .minimum() - * .minimumAmount() * .name() * .partiallyInvoicedAmount() * .price() @@ -4494,14 +4374,9 @@ private constructor( private var adjustments: JsonField>? = null private var amount: JsonField? = null private var creditsApplied: JsonField? = null - private var discount: JsonField? = null private var endDate: JsonField? = null private var filter: JsonField? = null private var grouping: JsonField? = null - private var maximum: JsonField? = null - private var maximumAmount: JsonField? = null - private var minimum: JsonField? = null - private var minimumAmount: JsonField? = null private var name: JsonField? = null private var partiallyInvoicedAmount: JsonField? = null private var price: JsonField? = null @@ -4519,14 +4394,9 @@ private constructor( adjustments = lineItem.adjustments.map { it.toMutableList() } amount = lineItem.amount creditsApplied = lineItem.creditsApplied - discount = lineItem.discount endDate = lineItem.endDate filter = lineItem.filter grouping = lineItem.grouping - maximum = lineItem.maximum - maximumAmount = lineItem.maximumAmount - minimum = lineItem.minimum - minimumAmount = lineItem.minimumAmount name = lineItem.name partiallyInvoicedAmount = lineItem.partiallyInvoicedAmount price = lineItem.price @@ -4656,91 +4526,6 @@ private constructor( this.creditsApplied = creditsApplied } - /** This field is deprecated in favor of `adjustments` */ - @Deprecated("deprecated") - fun discount(discount: Discount?) = discount(JsonField.ofNullable(discount)) - - /** - * Sets [Builder.discount] to an arbitrary JSON value. - * - * You should usually call [Builder.discount] with a well-typed [Discount] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - @Deprecated("deprecated") - fun discount(discount: JsonField) = apply { this.discount = discount } - - /** Alias for calling [discount] with `Discount.ofPercentage(percentage)`. */ - @Deprecated("deprecated") - fun discount(percentage: PercentageDiscount) = - discount(Discount.ofPercentage(percentage)) - - /** - * Alias for calling [discount] with the following: - * ```kotlin - * PercentageDiscount.builder() - * .discountType(PercentageDiscount.DiscountType.PERCENTAGE) - * .percentageDiscount(percentageDiscount) - * .build() - * ``` - */ - @Deprecated("deprecated") - fun percentageDiscount(percentageDiscount: Double) = - discount( - PercentageDiscount.builder() - .discountType(PercentageDiscount.DiscountType.PERCENTAGE) - .percentageDiscount(percentageDiscount) - .build() - ) - - /** Alias for calling [discount] with `Discount.ofTrial(trial)`. */ - @Deprecated("deprecated") - fun discount(trial: TrialDiscount) = discount(Discount.ofTrial(trial)) - - /** Alias for calling [discount] with `Discount.ofUsage(usage)`. */ - @Deprecated("deprecated") - fun discount(usage: UsageDiscount) = discount(Discount.ofUsage(usage)) - - /** - * Alias for calling [discount] with the following: - * ```kotlin - * UsageDiscount.builder() - * .discountType(UsageDiscount.DiscountType.USAGE) - * .usageDiscount(usageDiscount) - * .build() - * ``` - */ - @Deprecated("deprecated") - fun usageDiscount(usageDiscount: Double) = - discount( - UsageDiscount.builder() - .discountType(UsageDiscount.DiscountType.USAGE) - .usageDiscount(usageDiscount) - .build() - ) - - /** Alias for calling [discount] with `Discount.ofAmount(amount)`. */ - @Deprecated("deprecated") - fun discount(amount: AmountDiscount) = discount(Discount.ofAmount(amount)) - - /** - * Alias for calling [discount] with the following: - * ```kotlin - * AmountDiscount.builder() - * .discountType(AmountDiscount.DiscountType.AMOUNT) - * .amountDiscount(amountDiscount) - * .build() - * ``` - */ - @Deprecated("deprecated") - fun amountDiscount(amountDiscount: String) = - discount( - AmountDiscount.builder() - .discountType(AmountDiscount.DiscountType.AMOUNT) - .amountDiscount(amountDiscount) - .build() - ) - /** The end date of the range of time applied for this line item's price. */ fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) @@ -4781,68 +4566,6 @@ private constructor( */ fun grouping(grouping: JsonField) = apply { this.grouping = grouping } - /** This field is deprecated in favor of `adjustments`. */ - @Deprecated("deprecated") - fun maximum(maximum: Maximum?) = maximum(JsonField.ofNullable(maximum)) - - /** - * Sets [Builder.maximum] to an arbitrary JSON value. - * - * You should usually call [Builder.maximum] with a well-typed [Maximum] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - @Deprecated("deprecated") - fun maximum(maximum: JsonField) = apply { this.maximum = maximum } - - /** This field is deprecated in favor of `adjustments`. */ - @Deprecated("deprecated") - fun maximumAmount(maximumAmount: String?) = - maximumAmount(JsonField.ofNullable(maximumAmount)) - - /** - * Sets [Builder.maximumAmount] to an arbitrary JSON value. - * - * You should usually call [Builder.maximumAmount] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - @Deprecated("deprecated") - fun maximumAmount(maximumAmount: JsonField) = apply { - this.maximumAmount = maximumAmount - } - - /** This field is deprecated in favor of `adjustments`. */ - @Deprecated("deprecated") - fun minimum(minimum: Minimum?) = minimum(JsonField.ofNullable(minimum)) - - /** - * Sets [Builder.minimum] to an arbitrary JSON value. - * - * You should usually call [Builder.minimum] with a well-typed [Minimum] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - @Deprecated("deprecated") - fun minimum(minimum: JsonField) = apply { this.minimum = minimum } - - /** This field is deprecated in favor of `adjustments`. */ - @Deprecated("deprecated") - fun minimumAmount(minimumAmount: String?) = - minimumAmount(JsonField.ofNullable(minimumAmount)) - - /** - * Sets [Builder.minimumAmount] to an arbitrary JSON value. - * - * You should usually call [Builder.minimumAmount] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - @Deprecated("deprecated") - fun minimumAmount(minimumAmount: JsonField) = apply { - this.minimumAmount = minimumAmount - } - /** The name of the price associated with this line item. */ fun name(name: String) = name(JsonField.of(name)) @@ -5208,14 +4931,9 @@ private constructor( * .adjustments() * .amount() * .creditsApplied() - * .discount() * .endDate() * .filter() * .grouping() - * .maximum() - * .maximumAmount() - * .minimum() - * .minimumAmount() * .name() * .partiallyInvoicedAmount() * .price() @@ -5236,14 +4954,9 @@ private constructor( checkRequired("adjustments", adjustments).map { it.toImmutable() }, checkRequired("amount", amount), checkRequired("creditsApplied", creditsApplied), - checkRequired("discount", discount), checkRequired("endDate", endDate), checkRequired("filter", filter), checkRequired("grouping", grouping), - checkRequired("maximum", maximum), - checkRequired("maximumAmount", maximumAmount), - checkRequired("minimum", minimum), - checkRequired("minimumAmount", minimumAmount), checkRequired("name", name), checkRequired("partiallyInvoicedAmount", partiallyInvoicedAmount), checkRequired("price", price), @@ -5269,14 +4982,9 @@ private constructor( adjustments().forEach { it.validate() } amount() creditsApplied() - discount()?.validate() endDate() filter() grouping() - maximum()?.validate() - maximumAmount() - minimum()?.validate() - minimumAmount() name() partiallyInvoicedAmount() price().validate() @@ -5309,14 +5017,9 @@ private constructor( (adjustments.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + (if (amount.asKnown() == null) 0 else 1) + (if (creditsApplied.asKnown() == null) 0 else 1) + - (discount.asKnown()?.validity() ?: 0) + (if (endDate.asKnown() == null) 0 else 1) + (if (filter.asKnown() == null) 0 else 1) + (if (grouping.asKnown() == null) 0 else 1) + - (maximum.asKnown()?.validity() ?: 0) + - (if (maximumAmount.asKnown() == null) 0 else 1) + - (minimum.asKnown()?.validity() ?: 0) + - (if (minimumAmount.asKnown() == null) 0 else 1) + (if (name.asKnown() == null) 0 else 1) + (if (partiallyInvoicedAmount.asKnown() == null) 0 else 1) + (price.asKnown()?.validity() ?: 0) + @@ -5813,14 +5516,9 @@ private constructor( adjustments == other.adjustments && amount == other.amount && creditsApplied == other.creditsApplied && - discount == other.discount && endDate == other.endDate && filter == other.filter && grouping == other.grouping && - maximum == other.maximum && - maximumAmount == other.maximumAmount && - minimum == other.minimum && - minimumAmount == other.minimumAmount && name == other.name && partiallyInvoicedAmount == other.partiallyInvoicedAmount && price == other.price && @@ -5840,14 +5538,9 @@ private constructor( adjustments, amount, creditsApplied, - discount, endDate, filter, grouping, - maximum, - maximumAmount, - minimum, - minimumAmount, name, partiallyInvoicedAmount, price, @@ -5864,7 +5557,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "LineItem{id=$id, adjustedSubtotal=$adjustedSubtotal, adjustments=$adjustments, amount=$amount, creditsApplied=$creditsApplied, discount=$discount, endDate=$endDate, filter=$filter, grouping=$grouping, maximum=$maximum, maximumAmount=$maximumAmount, minimum=$minimum, minimumAmount=$minimumAmount, name=$name, partiallyInvoicedAmount=$partiallyInvoicedAmount, price=$price, quantity=$quantity, startDate=$startDate, subLineItems=$subLineItems, subtotal=$subtotal, taxAmounts=$taxAmounts, usageCustomerIds=$usageCustomerIds, additionalProperties=$additionalProperties}" + "LineItem{id=$id, adjustedSubtotal=$adjustedSubtotal, adjustments=$adjustments, amount=$amount, creditsApplied=$creditsApplied, endDate=$endDate, filter=$filter, grouping=$grouping, name=$name, partiallyInvoicedAmount=$partiallyInvoicedAmount, price=$price, quantity=$quantity, startDate=$startDate, subLineItems=$subLineItems, subtotal=$subtotal, taxAmounts=$taxAmounts, usageCustomerIds=$usageCustomerIds, additionalProperties=$additionalProperties}" } /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceLineItemCreateResponse.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceLineItemCreateResponse.kt index c8c24c15a..04d8ceaaf 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceLineItemCreateResponse.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceLineItemCreateResponse.kt @@ -36,14 +36,9 @@ private constructor( private val adjustments: JsonField>, private val amount: JsonField, private val creditsApplied: JsonField, - private val discount: JsonField, private val endDate: JsonField, private val filter: JsonField, private val grouping: JsonField, - private val maximum: JsonField, - private val maximumAmount: JsonField, - private val minimum: JsonField, - private val minimumAmount: JsonField, private val name: JsonField, private val partiallyInvoicedAmount: JsonField, private val price: JsonField, @@ -69,20 +64,11 @@ private constructor( @JsonProperty("credits_applied") @ExcludeMissing creditsApplied: JsonField = JsonMissing.of(), - @JsonProperty("discount") @ExcludeMissing discount: JsonField = JsonMissing.of(), @JsonProperty("end_date") @ExcludeMissing endDate: JsonField = JsonMissing.of(), @JsonProperty("filter") @ExcludeMissing filter: JsonField = JsonMissing.of(), @JsonProperty("grouping") @ExcludeMissing grouping: JsonField = JsonMissing.of(), - @JsonProperty("maximum") @ExcludeMissing maximum: JsonField = JsonMissing.of(), - @JsonProperty("maximum_amount") - @ExcludeMissing - maximumAmount: JsonField = JsonMissing.of(), - @JsonProperty("minimum") @ExcludeMissing minimum: JsonField = JsonMissing.of(), - @JsonProperty("minimum_amount") - @ExcludeMissing - minimumAmount: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @JsonProperty("partially_invoiced_amount") @ExcludeMissing @@ -108,14 +94,9 @@ private constructor( adjustments, amount, creditsApplied, - discount, endDate, filter, grouping, - maximum, - maximumAmount, - minimum, - minimumAmount, name, partiallyInvoicedAmount, price, @@ -172,14 +153,6 @@ private constructor( */ fun creditsApplied(): String = creditsApplied.getRequired("credits_applied") - /** - * This field is deprecated in favor of `adjustments` - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - @Deprecated("deprecated") fun discount(): Discount? = discount.getNullable("discount") - /** * The end date of the range of time applied for this line item's price. * @@ -206,40 +179,6 @@ private constructor( */ fun grouping(): String? = grouping.getNullable("grouping") - /** - * This field is deprecated in favor of `adjustments`. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - @Deprecated("deprecated") fun maximum(): Maximum? = maximum.getNullable("maximum") - - /** - * This field is deprecated in favor of `adjustments`. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - @Deprecated("deprecated") - fun maximumAmount(): String? = maximumAmount.getNullable("maximum_amount") - - /** - * This field is deprecated in favor of `adjustments`. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - @Deprecated("deprecated") fun minimum(): Minimum? = minimum.getNullable("minimum") - - /** - * This field is deprecated in favor of `adjustments`. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - @Deprecated("deprecated") - fun minimumAmount(): String? = minimumAmount.getNullable("minimum_amount") - /** * The name of the price associated with this line item. * @@ -365,16 +304,6 @@ private constructor( @ExcludeMissing fun _creditsApplied(): JsonField = creditsApplied - /** - * Returns the raw JSON value of [discount]. - * - * Unlike [discount], this method doesn't throw if the JSON field has an unexpected type. - */ - @Deprecated("deprecated") - @JsonProperty("discount") - @ExcludeMissing - fun _discount(): JsonField = discount - /** * Returns the raw JSON value of [endDate]. * @@ -396,46 +325,6 @@ private constructor( */ @JsonProperty("grouping") @ExcludeMissing fun _grouping(): JsonField = grouping - /** - * Returns the raw JSON value of [maximum]. - * - * Unlike [maximum], this method doesn't throw if the JSON field has an unexpected type. - */ - @Deprecated("deprecated") - @JsonProperty("maximum") - @ExcludeMissing - fun _maximum(): JsonField = maximum - - /** - * Returns the raw JSON value of [maximumAmount]. - * - * Unlike [maximumAmount], this method doesn't throw if the JSON field has an unexpected type. - */ - @Deprecated("deprecated") - @JsonProperty("maximum_amount") - @ExcludeMissing - fun _maximumAmount(): JsonField = maximumAmount - - /** - * Returns the raw JSON value of [minimum]. - * - * Unlike [minimum], this method doesn't throw if the JSON field has an unexpected type. - */ - @Deprecated("deprecated") - @JsonProperty("minimum") - @ExcludeMissing - fun _minimum(): JsonField = minimum - - /** - * Returns the raw JSON value of [minimumAmount]. - * - * Unlike [minimumAmount], this method doesn't throw if the JSON field has an unexpected type. - */ - @Deprecated("deprecated") - @JsonProperty("minimum_amount") - @ExcludeMissing - fun _minimumAmount(): JsonField = minimumAmount - /** * Returns the raw JSON value of [name]. * @@ -536,14 +425,9 @@ private constructor( * .adjustments() * .amount() * .creditsApplied() - * .discount() * .endDate() * .filter() * .grouping() - * .maximum() - * .maximumAmount() - * .minimum() - * .minimumAmount() * .name() * .partiallyInvoicedAmount() * .price() @@ -566,14 +450,9 @@ private constructor( private var adjustments: JsonField>? = null private var amount: JsonField? = null private var creditsApplied: JsonField? = null - private var discount: JsonField? = null private var endDate: JsonField? = null private var filter: JsonField? = null private var grouping: JsonField? = null - private var maximum: JsonField? = null - private var maximumAmount: JsonField? = null - private var minimum: JsonField? = null - private var minimumAmount: JsonField? = null private var name: JsonField? = null private var partiallyInvoicedAmount: JsonField? = null private var price: JsonField? = null @@ -591,14 +470,9 @@ private constructor( adjustments = invoiceLineItemCreateResponse.adjustments.map { it.toMutableList() } amount = invoiceLineItemCreateResponse.amount creditsApplied = invoiceLineItemCreateResponse.creditsApplied - discount = invoiceLineItemCreateResponse.discount endDate = invoiceLineItemCreateResponse.endDate filter = invoiceLineItemCreateResponse.filter grouping = invoiceLineItemCreateResponse.grouping - maximum = invoiceLineItemCreateResponse.maximum - maximumAmount = invoiceLineItemCreateResponse.maximumAmount - minimum = invoiceLineItemCreateResponse.minimum - minimumAmount = invoiceLineItemCreateResponse.minimumAmount name = invoiceLineItemCreateResponse.name partiallyInvoicedAmount = invoiceLineItemCreateResponse.partiallyInvoicedAmount price = invoiceLineItemCreateResponse.price @@ -722,90 +596,6 @@ private constructor( this.creditsApplied = creditsApplied } - /** This field is deprecated in favor of `adjustments` */ - @Deprecated("deprecated") - fun discount(discount: Discount?) = discount(JsonField.ofNullable(discount)) - - /** - * Sets [Builder.discount] to an arbitrary JSON value. - * - * You should usually call [Builder.discount] with a well-typed [Discount] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - @Deprecated("deprecated") - fun discount(discount: JsonField) = apply { this.discount = discount } - - /** Alias for calling [discount] with `Discount.ofPercentage(percentage)`. */ - @Deprecated("deprecated") - fun discount(percentage: PercentageDiscount) = discount(Discount.ofPercentage(percentage)) - - /** - * Alias for calling [discount] with the following: - * ```kotlin - * PercentageDiscount.builder() - * .discountType(PercentageDiscount.DiscountType.PERCENTAGE) - * .percentageDiscount(percentageDiscount) - * .build() - * ``` - */ - @Deprecated("deprecated") - fun percentageDiscount(percentageDiscount: Double) = - discount( - PercentageDiscount.builder() - .discountType(PercentageDiscount.DiscountType.PERCENTAGE) - .percentageDiscount(percentageDiscount) - .build() - ) - - /** Alias for calling [discount] with `Discount.ofTrial(trial)`. */ - @Deprecated("deprecated") - fun discount(trial: TrialDiscount) = discount(Discount.ofTrial(trial)) - - /** Alias for calling [discount] with `Discount.ofUsage(usage)`. */ - @Deprecated("deprecated") - fun discount(usage: UsageDiscount) = discount(Discount.ofUsage(usage)) - - /** - * Alias for calling [discount] with the following: - * ```kotlin - * UsageDiscount.builder() - * .discountType(UsageDiscount.DiscountType.USAGE) - * .usageDiscount(usageDiscount) - * .build() - * ``` - */ - @Deprecated("deprecated") - fun usageDiscount(usageDiscount: Double) = - discount( - UsageDiscount.builder() - .discountType(UsageDiscount.DiscountType.USAGE) - .usageDiscount(usageDiscount) - .build() - ) - - /** Alias for calling [discount] with `Discount.ofAmount(amount)`. */ - @Deprecated("deprecated") - fun discount(amount: AmountDiscount) = discount(Discount.ofAmount(amount)) - - /** - * Alias for calling [discount] with the following: - * ```kotlin - * AmountDiscount.builder() - * .discountType(AmountDiscount.DiscountType.AMOUNT) - * .amountDiscount(amountDiscount) - * .build() - * ``` - */ - @Deprecated("deprecated") - fun amountDiscount(amountDiscount: String) = - discount( - AmountDiscount.builder() - .discountType(AmountDiscount.DiscountType.AMOUNT) - .amountDiscount(amountDiscount) - .build() - ) - /** The end date of the range of time applied for this line item's price. */ fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) @@ -844,66 +634,6 @@ private constructor( */ fun grouping(grouping: JsonField) = apply { this.grouping = grouping } - /** This field is deprecated in favor of `adjustments`. */ - @Deprecated("deprecated") - fun maximum(maximum: Maximum?) = maximum(JsonField.ofNullable(maximum)) - - /** - * Sets [Builder.maximum] to an arbitrary JSON value. - * - * You should usually call [Builder.maximum] with a well-typed [Maximum] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - @Deprecated("deprecated") - fun maximum(maximum: JsonField) = apply { this.maximum = maximum } - - /** This field is deprecated in favor of `adjustments`. */ - @Deprecated("deprecated") - fun maximumAmount(maximumAmount: String?) = - maximumAmount(JsonField.ofNullable(maximumAmount)) - - /** - * Sets [Builder.maximumAmount] to an arbitrary JSON value. - * - * You should usually call [Builder.maximumAmount] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - @Deprecated("deprecated") - fun maximumAmount(maximumAmount: JsonField) = apply { - this.maximumAmount = maximumAmount - } - - /** This field is deprecated in favor of `adjustments`. */ - @Deprecated("deprecated") - fun minimum(minimum: Minimum?) = minimum(JsonField.ofNullable(minimum)) - - /** - * Sets [Builder.minimum] to an arbitrary JSON value. - * - * You should usually call [Builder.minimum] with a well-typed [Minimum] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - @Deprecated("deprecated") - fun minimum(minimum: JsonField) = apply { this.minimum = minimum } - - /** This field is deprecated in favor of `adjustments`. */ - @Deprecated("deprecated") - fun minimumAmount(minimumAmount: String?) = - minimumAmount(JsonField.ofNullable(minimumAmount)) - - /** - * Sets [Builder.minimumAmount] to an arbitrary JSON value. - * - * You should usually call [Builder.minimumAmount] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - @Deprecated("deprecated") - fun minimumAmount(minimumAmount: JsonField) = apply { - this.minimumAmount = minimumAmount - } - /** The name of the price associated with this line item. */ fun name(name: String) = name(JsonField.of(name)) @@ -1247,14 +977,9 @@ private constructor( * .adjustments() * .amount() * .creditsApplied() - * .discount() * .endDate() * .filter() * .grouping() - * .maximum() - * .maximumAmount() - * .minimum() - * .minimumAmount() * .name() * .partiallyInvoicedAmount() * .price() @@ -1275,14 +1000,9 @@ private constructor( checkRequired("adjustments", adjustments).map { it.toImmutable() }, checkRequired("amount", amount), checkRequired("creditsApplied", creditsApplied), - checkRequired("discount", discount), checkRequired("endDate", endDate), checkRequired("filter", filter), checkRequired("grouping", grouping), - checkRequired("maximum", maximum), - checkRequired("maximumAmount", maximumAmount), - checkRequired("minimum", minimum), - checkRequired("minimumAmount", minimumAmount), checkRequired("name", name), checkRequired("partiallyInvoicedAmount", partiallyInvoicedAmount), checkRequired("price", price), @@ -1308,14 +1028,9 @@ private constructor( adjustments().forEach { it.validate() } amount() creditsApplied() - discount()?.validate() endDate() filter() grouping() - maximum()?.validate() - maximumAmount() - minimum()?.validate() - minimumAmount() name() partiallyInvoicedAmount() price().validate() @@ -1347,14 +1062,9 @@ private constructor( (adjustments.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + (if (amount.asKnown() == null) 0 else 1) + (if (creditsApplied.asKnown() == null) 0 else 1) + - (discount.asKnown()?.validity() ?: 0) + (if (endDate.asKnown() == null) 0 else 1) + (if (filter.asKnown() == null) 0 else 1) + (if (grouping.asKnown() == null) 0 else 1) + - (maximum.asKnown()?.validity() ?: 0) + - (if (maximumAmount.asKnown() == null) 0 else 1) + - (minimum.asKnown()?.validity() ?: 0) + - (if (minimumAmount.asKnown() == null) 0 else 1) + (if (name.asKnown() == null) 0 else 1) + (if (partiallyInvoicedAmount.asKnown() == null) 0 else 1) + (price.asKnown()?.validity() ?: 0) + @@ -1846,14 +1556,9 @@ private constructor( adjustments == other.adjustments && amount == other.amount && creditsApplied == other.creditsApplied && - discount == other.discount && endDate == other.endDate && filter == other.filter && grouping == other.grouping && - maximum == other.maximum && - maximumAmount == other.maximumAmount && - minimum == other.minimum && - minimumAmount == other.minimumAmount && name == other.name && partiallyInvoicedAmount == other.partiallyInvoicedAmount && price == other.price && @@ -1873,14 +1578,9 @@ private constructor( adjustments, amount, creditsApplied, - discount, endDate, filter, grouping, - maximum, - maximumAmount, - minimum, - minimumAmount, name, partiallyInvoicedAmount, price, @@ -1897,5 +1597,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "InvoiceLineItemCreateResponse{id=$id, adjustedSubtotal=$adjustedSubtotal, adjustments=$adjustments, amount=$amount, creditsApplied=$creditsApplied, discount=$discount, endDate=$endDate, filter=$filter, grouping=$grouping, maximum=$maximum, maximumAmount=$maximumAmount, minimum=$minimum, minimumAmount=$minimumAmount, name=$name, partiallyInvoicedAmount=$partiallyInvoicedAmount, price=$price, quantity=$quantity, startDate=$startDate, subLineItems=$subLineItems, subtotal=$subtotal, taxAmounts=$taxAmounts, usageCustomerIds=$usageCustomerIds, additionalProperties=$additionalProperties}" + "InvoiceLineItemCreateResponse{id=$id, adjustedSubtotal=$adjustedSubtotal, adjustments=$adjustments, amount=$amount, creditsApplied=$creditsApplied, endDate=$endDate, filter=$filter, grouping=$grouping, name=$name, partiallyInvoicedAmount=$partiallyInvoicedAmount, price=$price, quantity=$quantity, startDate=$startDate, subLineItems=$subLineItems, subtotal=$subtotal, taxAmounts=$taxAmounts, usageCustomerIds=$usageCustomerIds, additionalProperties=$additionalProperties}" } diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/ChangedSubscriptionResourcesTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/ChangedSubscriptionResourcesTest.kt index 73aef23e1..a013bd44b 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/ChangedSubscriptionResourcesTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/ChangedSubscriptionResourcesTest.kt @@ -241,55 +241,9 @@ internal class ChangedSubscriptionResourcesTest { ) .amount("7.00") .creditsApplied("6.00") - .discount( - PercentageDiscount.builder() - .discountType(PercentageDiscount.DiscountType.PERCENTAGE) - .percentageDiscount(0.15) - .addAppliesToPriceId("h74gfhdjvn7ujokd") - .addAppliesToPriceId("7hfgtgjnbvc3ujkl") - .addFilter( - PercentageDiscount.Filter.builder() - .field(PercentageDiscount.Filter.Field.PRICE_ID) - .operator( - PercentageDiscount.Filter.Operator.INCLUDES - ) - .addValue("string") - .build() - ) - .reason("reason") - .build() - ) .endDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) .filter("filter") .grouping("grouping") - .maximum( - Maximum.builder() - .addAppliesToPriceId("string") - .addFilter( - Maximum.Filter.builder() - .field(Maximum.Filter.Field.PRICE_ID) - .operator(Maximum.Filter.Operator.INCLUDES) - .addValue("string") - .build() - ) - .maximumAmount("maximum_amount") - .build() - ) - .maximumAmount("maximum_amount") - .minimum( - Minimum.builder() - .addAppliesToPriceId("string") - .addFilter( - Minimum.Filter.builder() - .field(Minimum.Filter.Field.PRICE_ID) - .operator(Minimum.Filter.Operator.INCLUDES) - .addValue("string") - .build() - ) - .minimumAmount("minimum_amount") - .build() - ) - .minimumAmount("minimum_amount") .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( @@ -763,55 +717,9 @@ internal class ChangedSubscriptionResourcesTest { ) .amount("7.00") .creditsApplied("6.00") - .discount( - PercentageDiscount.builder() - .discountType(PercentageDiscount.DiscountType.PERCENTAGE) - .percentageDiscount(0.15) - .addAppliesToPriceId("h74gfhdjvn7ujokd") - .addAppliesToPriceId("7hfgtgjnbvc3ujkl") - .addFilter( - PercentageDiscount.Filter.builder() - .field(PercentageDiscount.Filter.Field.PRICE_ID) - .operator( - PercentageDiscount.Filter.Operator.INCLUDES - ) - .addValue("string") - .build() - ) - .reason("reason") - .build() - ) .endDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) .filter("filter") .grouping("grouping") - .maximum( - Maximum.builder() - .addAppliesToPriceId("string") - .addFilter( - Maximum.Filter.builder() - .field(Maximum.Filter.Field.PRICE_ID) - .operator(Maximum.Filter.Operator.INCLUDES) - .addValue("string") - .build() - ) - .maximumAmount("maximum_amount") - .build() - ) - .maximumAmount("maximum_amount") - .minimum( - Minimum.builder() - .addAppliesToPriceId("string") - .addFilter( - Minimum.Filter.builder() - .field(Minimum.Filter.Field.PRICE_ID) - .operator(Minimum.Filter.Operator.INCLUDES) - .addValue("string") - .build() - ) - .minimumAmount("minimum_amount") - .build() - ) - .minimumAmount("minimum_amount") .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( @@ -1293,53 +1201,9 @@ internal class ChangedSubscriptionResourcesTest { ) .amount("7.00") .creditsApplied("6.00") - .discount( - PercentageDiscount.builder() - .discountType(PercentageDiscount.DiscountType.PERCENTAGE) - .percentageDiscount(0.15) - .addAppliesToPriceId("h74gfhdjvn7ujokd") - .addAppliesToPriceId("7hfgtgjnbvc3ujkl") - .addFilter( - PercentageDiscount.Filter.builder() - .field(PercentageDiscount.Filter.Field.PRICE_ID) - .operator(PercentageDiscount.Filter.Operator.INCLUDES) - .addValue("string") - .build() - ) - .reason("reason") - .build() - ) .endDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) .filter("filter") .grouping("grouping") - .maximum( - Maximum.builder() - .addAppliesToPriceId("string") - .addFilter( - Maximum.Filter.builder() - .field(Maximum.Filter.Field.PRICE_ID) - .operator(Maximum.Filter.Operator.INCLUDES) - .addValue("string") - .build() - ) - .maximumAmount("maximum_amount") - .build() - ) - .maximumAmount("maximum_amount") - .minimum( - Minimum.builder() - .addAppliesToPriceId("string") - .addFilter( - Minimum.Filter.builder() - .field(Minimum.Filter.Field.PRICE_ID) - .operator(Minimum.Filter.Operator.INCLUDES) - .addValue("string") - .build() - ) - .minimumAmount("minimum_amount") - .build() - ) - .minimumAmount("minimum_amount") .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( @@ -1794,53 +1658,9 @@ internal class ChangedSubscriptionResourcesTest { ) .amount("7.00") .creditsApplied("6.00") - .discount( - PercentageDiscount.builder() - .discountType(PercentageDiscount.DiscountType.PERCENTAGE) - .percentageDiscount(0.15) - .addAppliesToPriceId("h74gfhdjvn7ujokd") - .addAppliesToPriceId("7hfgtgjnbvc3ujkl") - .addFilter( - PercentageDiscount.Filter.builder() - .field(PercentageDiscount.Filter.Field.PRICE_ID) - .operator(PercentageDiscount.Filter.Operator.INCLUDES) - .addValue("string") - .build() - ) - .reason("reason") - .build() - ) .endDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) .filter("filter") .grouping("grouping") - .maximum( - Maximum.builder() - .addAppliesToPriceId("string") - .addFilter( - Maximum.Filter.builder() - .field(Maximum.Filter.Field.PRICE_ID) - .operator(Maximum.Filter.Operator.INCLUDES) - .addValue("string") - .build() - ) - .maximumAmount("maximum_amount") - .build() - ) - .maximumAmount("maximum_amount") - .minimum( - Minimum.builder() - .addAppliesToPriceId("string") - .addFilter( - Minimum.Filter.builder() - .field(Minimum.Filter.Field.PRICE_ID) - .operator(Minimum.Filter.Operator.INCLUDES) - .addValue("string") - .build() - ) - .minimumAmount("minimum_amount") - .build() - ) - .minimumAmount("minimum_amount") .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( @@ -2314,55 +2134,9 @@ internal class ChangedSubscriptionResourcesTest { ) .amount("7.00") .creditsApplied("6.00") - .discount( - PercentageDiscount.builder() - .discountType(PercentageDiscount.DiscountType.PERCENTAGE) - .percentageDiscount(0.15) - .addAppliesToPriceId("h74gfhdjvn7ujokd") - .addAppliesToPriceId("7hfgtgjnbvc3ujkl") - .addFilter( - PercentageDiscount.Filter.builder() - .field(PercentageDiscount.Filter.Field.PRICE_ID) - .operator( - PercentageDiscount.Filter.Operator.INCLUDES - ) - .addValue("string") - .build() - ) - .reason("reason") - .build() - ) .endDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) .filter("filter") .grouping("grouping") - .maximum( - Maximum.builder() - .addAppliesToPriceId("string") - .addFilter( - Maximum.Filter.builder() - .field(Maximum.Filter.Field.PRICE_ID) - .operator(Maximum.Filter.Operator.INCLUDES) - .addValue("string") - .build() - ) - .maximumAmount("maximum_amount") - .build() - ) - .maximumAmount("maximum_amount") - .minimum( - Minimum.builder() - .addAppliesToPriceId("string") - .addFilter( - Minimum.Filter.builder() - .field(Minimum.Filter.Field.PRICE_ID) - .operator(Minimum.Filter.Operator.INCLUDES) - .addValue("string") - .build() - ) - .minimumAmount("minimum_amount") - .build() - ) - .minimumAmount("minimum_amount") .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( @@ -2836,55 +2610,9 @@ internal class ChangedSubscriptionResourcesTest { ) .amount("7.00") .creditsApplied("6.00") - .discount( - PercentageDiscount.builder() - .discountType(PercentageDiscount.DiscountType.PERCENTAGE) - .percentageDiscount(0.15) - .addAppliesToPriceId("h74gfhdjvn7ujokd") - .addAppliesToPriceId("7hfgtgjnbvc3ujkl") - .addFilter( - PercentageDiscount.Filter.builder() - .field(PercentageDiscount.Filter.Field.PRICE_ID) - .operator( - PercentageDiscount.Filter.Operator.INCLUDES - ) - .addValue("string") - .build() - ) - .reason("reason") - .build() - ) .endDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) .filter("filter") .grouping("grouping") - .maximum( - Maximum.builder() - .addAppliesToPriceId("string") - .addFilter( - Maximum.Filter.builder() - .field(Maximum.Filter.Field.PRICE_ID) - .operator(Maximum.Filter.Operator.INCLUDES) - .addValue("string") - .build() - ) - .maximumAmount("maximum_amount") - .build() - ) - .maximumAmount("maximum_amount") - .minimum( - Minimum.builder() - .addAppliesToPriceId("string") - .addFilter( - Minimum.Filter.builder() - .field(Minimum.Filter.Field.PRICE_ID) - .operator(Minimum.Filter.Operator.INCLUDES) - .addValue("string") - .build() - ) - .minimumAmount("minimum_amount") - .build() - ) - .minimumAmount("minimum_amount") .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdResponseTest.kt index 1a2eabf87..3248e833b 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdResponseTest.kt @@ -182,55 +182,9 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdResponseTest { ) .amount("7.00") .creditsApplied("6.00") - .discount( - PercentageDiscount.builder() - .discountType(PercentageDiscount.DiscountType.PERCENTAGE) - .percentageDiscount(0.15) - .addAppliesToPriceId("h74gfhdjvn7ujokd") - .addAppliesToPriceId("7hfgtgjnbvc3ujkl") - .addFilter( - PercentageDiscount.Filter.builder() - .field(PercentageDiscount.Filter.Field.PRICE_ID) - .operator( - PercentageDiscount.Filter.Operator.INCLUDES - ) - .addValue("string") - .build() - ) - .reason("reason") - .build() - ) .endDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) .filter("filter") .grouping("grouping") - .maximum( - Maximum.builder() - .addAppliesToPriceId("string") - .addFilter( - Maximum.Filter.builder() - .field(Maximum.Filter.Field.PRICE_ID) - .operator(Maximum.Filter.Operator.INCLUDES) - .addValue("string") - .build() - ) - .maximumAmount("maximum_amount") - .build() - ) - .maximumAmount("maximum_amount") - .minimum( - Minimum.builder() - .addAppliesToPriceId("string") - .addFilter( - Minimum.Filter.builder() - .field(Minimum.Filter.Field.PRICE_ID) - .operator(Minimum.Filter.Operator.INCLUDES) - .addValue("string") - .build() - ) - .minimumAmount("minimum_amount") - .build() - ) - .minimumAmount("minimum_amount") .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( @@ -671,57 +625,9 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdResponseTest { ) .amount("7.00") .creditsApplied("6.00") - .discount( - PercentageDiscount.builder() - .discountType( - PercentageDiscount.DiscountType.PERCENTAGE - ) - .percentageDiscount(0.15) - .addAppliesToPriceId("h74gfhdjvn7ujokd") - .addAppliesToPriceId("7hfgtgjnbvc3ujkl") - .addFilter( - PercentageDiscount.Filter.builder() - .field(PercentageDiscount.Filter.Field.PRICE_ID) - .operator( - PercentageDiscount.Filter.Operator.INCLUDES - ) - .addValue("string") - .build() - ) - .reason("reason") - .build() - ) .endDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) .filter("filter") .grouping("grouping") - .maximum( - Maximum.builder() - .addAppliesToPriceId("string") - .addFilter( - Maximum.Filter.builder() - .field(Maximum.Filter.Field.PRICE_ID) - .operator(Maximum.Filter.Operator.INCLUDES) - .addValue("string") - .build() - ) - .maximumAmount("maximum_amount") - .build() - ) - .maximumAmount("maximum_amount") - .minimum( - Minimum.builder() - .addAppliesToPriceId("string") - .addFilter( - Minimum.Filter.builder() - .field(Minimum.Filter.Field.PRICE_ID) - .operator(Minimum.Filter.Operator.INCLUDES) - .addValue("string") - .build() - ) - .minimumAmount("minimum_amount") - .build() - ) - .minimumAmount("minimum_amount") .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryResponseTest.kt index 5436b5219..7a4064066 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryResponseTest.kt @@ -182,55 +182,9 @@ internal class CustomerCreditLedgerCreateEntryResponseTest { ) .amount("7.00") .creditsApplied("6.00") - .discount( - PercentageDiscount.builder() - .discountType(PercentageDiscount.DiscountType.PERCENTAGE) - .percentageDiscount(0.15) - .addAppliesToPriceId("h74gfhdjvn7ujokd") - .addAppliesToPriceId("7hfgtgjnbvc3ujkl") - .addFilter( - PercentageDiscount.Filter.builder() - .field(PercentageDiscount.Filter.Field.PRICE_ID) - .operator( - PercentageDiscount.Filter.Operator.INCLUDES - ) - .addValue("string") - .build() - ) - .reason("reason") - .build() - ) .endDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) .filter("filter") .grouping("grouping") - .maximum( - Maximum.builder() - .addAppliesToPriceId("string") - .addFilter( - Maximum.Filter.builder() - .field(Maximum.Filter.Field.PRICE_ID) - .operator(Maximum.Filter.Operator.INCLUDES) - .addValue("string") - .build() - ) - .maximumAmount("maximum_amount") - .build() - ) - .maximumAmount("maximum_amount") - .minimum( - Minimum.builder() - .addAppliesToPriceId("string") - .addFilter( - Minimum.Filter.builder() - .field(Minimum.Filter.Field.PRICE_ID) - .operator(Minimum.Filter.Operator.INCLUDES) - .addValue("string") - .build() - ) - .minimumAmount("minimum_amount") - .build() - ) - .minimumAmount("minimum_amount") .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( @@ -670,57 +624,9 @@ internal class CustomerCreditLedgerCreateEntryResponseTest { ) .amount("7.00") .creditsApplied("6.00") - .discount( - PercentageDiscount.builder() - .discountType( - PercentageDiscount.DiscountType.PERCENTAGE - ) - .percentageDiscount(0.15) - .addAppliesToPriceId("h74gfhdjvn7ujokd") - .addAppliesToPriceId("7hfgtgjnbvc3ujkl") - .addFilter( - PercentageDiscount.Filter.builder() - .field(PercentageDiscount.Filter.Field.PRICE_ID) - .operator( - PercentageDiscount.Filter.Operator.INCLUDES - ) - .addValue("string") - .build() - ) - .reason("reason") - .build() - ) .endDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) .filter("filter") .grouping("grouping") - .maximum( - Maximum.builder() - .addAppliesToPriceId("string") - .addFilter( - Maximum.Filter.builder() - .field(Maximum.Filter.Field.PRICE_ID) - .operator(Maximum.Filter.Operator.INCLUDES) - .addValue("string") - .build() - ) - .maximumAmount("maximum_amount") - .build() - ) - .maximumAmount("maximum_amount") - .minimum( - Minimum.builder() - .addAppliesToPriceId("string") - .addFilter( - Minimum.Filter.builder() - .field(Minimum.Filter.Field.PRICE_ID) - .operator(Minimum.Filter.Operator.INCLUDES) - .addValue("string") - .build() - ) - .minimumAmount("minimum_amount") - .build() - ) - .minimumAmount("minimum_amount") .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdPageResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdPageResponseTest.kt index 3934a5aee..02d6d0a49 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdPageResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdPageResponseTest.kt @@ -191,60 +191,9 @@ internal class CustomerCreditLedgerListByExternalIdPageResponseTest { ) .amount("7.00") .creditsApplied("6.00") - .discount( - PercentageDiscount.builder() - .discountType( - PercentageDiscount.DiscountType.PERCENTAGE - ) - .percentageDiscount(0.15) - .addAppliesToPriceId("h74gfhdjvn7ujokd") - .addAppliesToPriceId("7hfgtgjnbvc3ujkl") - .addFilter( - PercentageDiscount.Filter.builder() - .field( - PercentageDiscount.Filter.Field.PRICE_ID - ) - .operator( - PercentageDiscount.Filter.Operator - .INCLUDES - ) - .addValue("string") - .build() - ) - .reason("reason") - .build() - ) .endDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) .filter("filter") .grouping("grouping") - .maximum( - Maximum.builder() - .addAppliesToPriceId("string") - .addFilter( - Maximum.Filter.builder() - .field(Maximum.Filter.Field.PRICE_ID) - .operator(Maximum.Filter.Operator.INCLUDES) - .addValue("string") - .build() - ) - .maximumAmount("maximum_amount") - .build() - ) - .maximumAmount("maximum_amount") - .minimum( - Minimum.builder() - .addAppliesToPriceId("string") - .addFilter( - Minimum.Filter.builder() - .field(Minimum.Filter.Field.PRICE_ID) - .operator(Minimum.Filter.Operator.INCLUDES) - .addValue("string") - .build() - ) - .minimumAmount("minimum_amount") - .build() - ) - .minimumAmount("minimum_amount") .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( @@ -714,60 +663,9 @@ internal class CustomerCreditLedgerListByExternalIdPageResponseTest { ) .amount("7.00") .creditsApplied("6.00") - .discount( - PercentageDiscount.builder() - .discountType( - PercentageDiscount.DiscountType.PERCENTAGE - ) - .percentageDiscount(0.15) - .addAppliesToPriceId("h74gfhdjvn7ujokd") - .addAppliesToPriceId("7hfgtgjnbvc3ujkl") - .addFilter( - PercentageDiscount.Filter.builder() - .field( - PercentageDiscount.Filter.Field.PRICE_ID - ) - .operator( - PercentageDiscount.Filter.Operator - .INCLUDES - ) - .addValue("string") - .build() - ) - .reason("reason") - .build() - ) .endDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) .filter("filter") .grouping("grouping") - .maximum( - Maximum.builder() - .addAppliesToPriceId("string") - .addFilter( - Maximum.Filter.builder() - .field(Maximum.Filter.Field.PRICE_ID) - .operator(Maximum.Filter.Operator.INCLUDES) - .addValue("string") - .build() - ) - .maximumAmount("maximum_amount") - .build() - ) - .maximumAmount("maximum_amount") - .minimum( - Minimum.builder() - .addAppliesToPriceId("string") - .addFilter( - Minimum.Filter.builder() - .field(Minimum.Filter.Field.PRICE_ID) - .operator(Minimum.Filter.Operator.INCLUDES) - .addValue("string") - .build() - ) - .minimumAmount("minimum_amount") - .build() - ) - .minimumAmount("minimum_amount") .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( @@ -1240,60 +1138,9 @@ internal class CustomerCreditLedgerListByExternalIdPageResponseTest { ) .amount("7.00") .creditsApplied("6.00") - .discount( - PercentageDiscount.builder() - .discountType( - PercentageDiscount.DiscountType.PERCENTAGE - ) - .percentageDiscount(0.15) - .addAppliesToPriceId("h74gfhdjvn7ujokd") - .addAppliesToPriceId("7hfgtgjnbvc3ujkl") - .addFilter( - PercentageDiscount.Filter.builder() - .field( - PercentageDiscount.Filter.Field.PRICE_ID - ) - .operator( - PercentageDiscount.Filter.Operator - .INCLUDES - ) - .addValue("string") - .build() - ) - .reason("reason") - .build() - ) .endDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) .filter("filter") .grouping("grouping") - .maximum( - Maximum.builder() - .addAppliesToPriceId("string") - .addFilter( - Maximum.Filter.builder() - .field(Maximum.Filter.Field.PRICE_ID) - .operator(Maximum.Filter.Operator.INCLUDES) - .addValue("string") - .build() - ) - .maximumAmount("maximum_amount") - .build() - ) - .maximumAmount("maximum_amount") - .minimum( - Minimum.builder() - .addAppliesToPriceId("string") - .addFilter( - Minimum.Filter.builder() - .field(Minimum.Filter.Field.PRICE_ID) - .operator(Minimum.Filter.Operator.INCLUDES) - .addValue("string") - .build() - ) - .minimumAmount("minimum_amount") - .build() - ) - .minimumAmount("minimum_amount") .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdResponseTest.kt index a27f40c54..f4a670bc0 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdResponseTest.kt @@ -182,55 +182,9 @@ internal class CustomerCreditLedgerListByExternalIdResponseTest { ) .amount("7.00") .creditsApplied("6.00") - .discount( - PercentageDiscount.builder() - .discountType(PercentageDiscount.DiscountType.PERCENTAGE) - .percentageDiscount(0.15) - .addAppliesToPriceId("h74gfhdjvn7ujokd") - .addAppliesToPriceId("7hfgtgjnbvc3ujkl") - .addFilter( - PercentageDiscount.Filter.builder() - .field(PercentageDiscount.Filter.Field.PRICE_ID) - .operator( - PercentageDiscount.Filter.Operator.INCLUDES - ) - .addValue("string") - .build() - ) - .reason("reason") - .build() - ) .endDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) .filter("filter") .grouping("grouping") - .maximum( - Maximum.builder() - .addAppliesToPriceId("string") - .addFilter( - Maximum.Filter.builder() - .field(Maximum.Filter.Field.PRICE_ID) - .operator(Maximum.Filter.Operator.INCLUDES) - .addValue("string") - .build() - ) - .maximumAmount("maximum_amount") - .build() - ) - .maximumAmount("maximum_amount") - .minimum( - Minimum.builder() - .addAppliesToPriceId("string") - .addFilter( - Minimum.Filter.builder() - .field(Minimum.Filter.Field.PRICE_ID) - .operator(Minimum.Filter.Operator.INCLUDES) - .addValue("string") - .build() - ) - .minimumAmount("minimum_amount") - .build() - ) - .minimumAmount("minimum_amount") .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( @@ -670,57 +624,9 @@ internal class CustomerCreditLedgerListByExternalIdResponseTest { ) .amount("7.00") .creditsApplied("6.00") - .discount( - PercentageDiscount.builder() - .discountType( - PercentageDiscount.DiscountType.PERCENTAGE - ) - .percentageDiscount(0.15) - .addAppliesToPriceId("h74gfhdjvn7ujokd") - .addAppliesToPriceId("7hfgtgjnbvc3ujkl") - .addFilter( - PercentageDiscount.Filter.builder() - .field(PercentageDiscount.Filter.Field.PRICE_ID) - .operator( - PercentageDiscount.Filter.Operator.INCLUDES - ) - .addValue("string") - .build() - ) - .reason("reason") - .build() - ) .endDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) .filter("filter") .grouping("grouping") - .maximum( - Maximum.builder() - .addAppliesToPriceId("string") - .addFilter( - Maximum.Filter.builder() - .field(Maximum.Filter.Field.PRICE_ID) - .operator(Maximum.Filter.Operator.INCLUDES) - .addValue("string") - .build() - ) - .maximumAmount("maximum_amount") - .build() - ) - .maximumAmount("maximum_amount") - .minimum( - Minimum.builder() - .addAppliesToPriceId("string") - .addFilter( - Minimum.Filter.builder() - .field(Minimum.Filter.Field.PRICE_ID) - .operator(Minimum.Filter.Operator.INCLUDES) - .addValue("string") - .build() - ) - .minimumAmount("minimum_amount") - .build() - ) - .minimumAmount("minimum_amount") .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListPageResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListPageResponseTest.kt index 2b66b4b0e..d58df0af6 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListPageResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListPageResponseTest.kt @@ -191,60 +191,9 @@ internal class CustomerCreditLedgerListPageResponseTest { ) .amount("7.00") .creditsApplied("6.00") - .discount( - PercentageDiscount.builder() - .discountType( - PercentageDiscount.DiscountType.PERCENTAGE - ) - .percentageDiscount(0.15) - .addAppliesToPriceId("h74gfhdjvn7ujokd") - .addAppliesToPriceId("7hfgtgjnbvc3ujkl") - .addFilter( - PercentageDiscount.Filter.builder() - .field( - PercentageDiscount.Filter.Field.PRICE_ID - ) - .operator( - PercentageDiscount.Filter.Operator - .INCLUDES - ) - .addValue("string") - .build() - ) - .reason("reason") - .build() - ) .endDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) .filter("filter") .grouping("grouping") - .maximum( - Maximum.builder() - .addAppliesToPriceId("string") - .addFilter( - Maximum.Filter.builder() - .field(Maximum.Filter.Field.PRICE_ID) - .operator(Maximum.Filter.Operator.INCLUDES) - .addValue("string") - .build() - ) - .maximumAmount("maximum_amount") - .build() - ) - .maximumAmount("maximum_amount") - .minimum( - Minimum.builder() - .addAppliesToPriceId("string") - .addFilter( - Minimum.Filter.builder() - .field(Minimum.Filter.Field.PRICE_ID) - .operator(Minimum.Filter.Operator.INCLUDES) - .addValue("string") - .build() - ) - .minimumAmount("minimum_amount") - .build() - ) - .minimumAmount("minimum_amount") .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( @@ -714,60 +663,9 @@ internal class CustomerCreditLedgerListPageResponseTest { ) .amount("7.00") .creditsApplied("6.00") - .discount( - PercentageDiscount.builder() - .discountType( - PercentageDiscount.DiscountType.PERCENTAGE - ) - .percentageDiscount(0.15) - .addAppliesToPriceId("h74gfhdjvn7ujokd") - .addAppliesToPriceId("7hfgtgjnbvc3ujkl") - .addFilter( - PercentageDiscount.Filter.builder() - .field( - PercentageDiscount.Filter.Field.PRICE_ID - ) - .operator( - PercentageDiscount.Filter.Operator - .INCLUDES - ) - .addValue("string") - .build() - ) - .reason("reason") - .build() - ) .endDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) .filter("filter") .grouping("grouping") - .maximum( - Maximum.builder() - .addAppliesToPriceId("string") - .addFilter( - Maximum.Filter.builder() - .field(Maximum.Filter.Field.PRICE_ID) - .operator(Maximum.Filter.Operator.INCLUDES) - .addValue("string") - .build() - ) - .maximumAmount("maximum_amount") - .build() - ) - .maximumAmount("maximum_amount") - .minimum( - Minimum.builder() - .addAppliesToPriceId("string") - .addFilter( - Minimum.Filter.builder() - .field(Minimum.Filter.Field.PRICE_ID) - .operator(Minimum.Filter.Operator.INCLUDES) - .addValue("string") - .build() - ) - .minimumAmount("minimum_amount") - .build() - ) - .minimumAmount("minimum_amount") .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( @@ -1240,60 +1138,9 @@ internal class CustomerCreditLedgerListPageResponseTest { ) .amount("7.00") .creditsApplied("6.00") - .discount( - PercentageDiscount.builder() - .discountType( - PercentageDiscount.DiscountType.PERCENTAGE - ) - .percentageDiscount(0.15) - .addAppliesToPriceId("h74gfhdjvn7ujokd") - .addAppliesToPriceId("7hfgtgjnbvc3ujkl") - .addFilter( - PercentageDiscount.Filter.builder() - .field( - PercentageDiscount.Filter.Field.PRICE_ID - ) - .operator( - PercentageDiscount.Filter.Operator - .INCLUDES - ) - .addValue("string") - .build() - ) - .reason("reason") - .build() - ) .endDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) .filter("filter") .grouping("grouping") - .maximum( - Maximum.builder() - .addAppliesToPriceId("string") - .addFilter( - Maximum.Filter.builder() - .field(Maximum.Filter.Field.PRICE_ID) - .operator(Maximum.Filter.Operator.INCLUDES) - .addValue("string") - .build() - ) - .maximumAmount("maximum_amount") - .build() - ) - .maximumAmount("maximum_amount") - .minimum( - Minimum.builder() - .addAppliesToPriceId("string") - .addFilter( - Minimum.Filter.builder() - .field(Minimum.Filter.Field.PRICE_ID) - .operator(Minimum.Filter.Operator.INCLUDES) - .addValue("string") - .build() - ) - .minimumAmount("minimum_amount") - .build() - ) - .minimumAmount("minimum_amount") .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListResponseTest.kt index a7096026a..04143323e 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListResponseTest.kt @@ -182,55 +182,9 @@ internal class CustomerCreditLedgerListResponseTest { ) .amount("7.00") .creditsApplied("6.00") - .discount( - PercentageDiscount.builder() - .discountType(PercentageDiscount.DiscountType.PERCENTAGE) - .percentageDiscount(0.15) - .addAppliesToPriceId("h74gfhdjvn7ujokd") - .addAppliesToPriceId("7hfgtgjnbvc3ujkl") - .addFilter( - PercentageDiscount.Filter.builder() - .field(PercentageDiscount.Filter.Field.PRICE_ID) - .operator( - PercentageDiscount.Filter.Operator.INCLUDES - ) - .addValue("string") - .build() - ) - .reason("reason") - .build() - ) .endDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) .filter("filter") .grouping("grouping") - .maximum( - Maximum.builder() - .addAppliesToPriceId("string") - .addFilter( - Maximum.Filter.builder() - .field(Maximum.Filter.Field.PRICE_ID) - .operator(Maximum.Filter.Operator.INCLUDES) - .addValue("string") - .build() - ) - .maximumAmount("maximum_amount") - .build() - ) - .maximumAmount("maximum_amount") - .minimum( - Minimum.builder() - .addAppliesToPriceId("string") - .addFilter( - Minimum.Filter.builder() - .field(Minimum.Filter.Field.PRICE_ID) - .operator(Minimum.Filter.Operator.INCLUDES) - .addValue("string") - .build() - ) - .minimumAmount("minimum_amount") - .build() - ) - .minimumAmount("minimum_amount") .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( @@ -670,57 +624,9 @@ internal class CustomerCreditLedgerListResponseTest { ) .amount("7.00") .creditsApplied("6.00") - .discount( - PercentageDiscount.builder() - .discountType( - PercentageDiscount.DiscountType.PERCENTAGE - ) - .percentageDiscount(0.15) - .addAppliesToPriceId("h74gfhdjvn7ujokd") - .addAppliesToPriceId("7hfgtgjnbvc3ujkl") - .addFilter( - PercentageDiscount.Filter.builder() - .field(PercentageDiscount.Filter.Field.PRICE_ID) - .operator( - PercentageDiscount.Filter.Operator.INCLUDES - ) - .addValue("string") - .build() - ) - .reason("reason") - .build() - ) .endDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) .filter("filter") .grouping("grouping") - .maximum( - Maximum.builder() - .addAppliesToPriceId("string") - .addFilter( - Maximum.Filter.builder() - .field(Maximum.Filter.Field.PRICE_ID) - .operator(Maximum.Filter.Operator.INCLUDES) - .addValue("string") - .build() - ) - .maximumAmount("maximum_amount") - .build() - ) - .maximumAmount("maximum_amount") - .minimum( - Minimum.builder() - .addAppliesToPriceId("string") - .addFilter( - Minimum.Filter.builder() - .field(Minimum.Filter.Field.PRICE_ID) - .operator(Minimum.Filter.Operator.INCLUDES) - .addValue("string") - .build() - ) - .minimumAmount("minimum_amount") - .build() - ) - .minimumAmount("minimum_amount") .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/IncrementLedgerEntryTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/IncrementLedgerEntryTest.kt index aa5bb71a2..b5519405f 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/IncrementLedgerEntryTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/IncrementLedgerEntryTest.kt @@ -178,55 +178,9 @@ internal class IncrementLedgerEntryTest { ) .amount("7.00") .creditsApplied("6.00") - .discount( - PercentageDiscount.builder() - .discountType(PercentageDiscount.DiscountType.PERCENTAGE) - .percentageDiscount(0.15) - .addAppliesToPriceId("h74gfhdjvn7ujokd") - .addAppliesToPriceId("7hfgtgjnbvc3ujkl") - .addFilter( - PercentageDiscount.Filter.builder() - .field(PercentageDiscount.Filter.Field.PRICE_ID) - .operator( - PercentageDiscount.Filter.Operator.INCLUDES - ) - .addValue("string") - .build() - ) - .reason("reason") - .build() - ) .endDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) .filter("filter") .grouping("grouping") - .maximum( - Maximum.builder() - .addAppliesToPriceId("string") - .addFilter( - Maximum.Filter.builder() - .field(Maximum.Filter.Field.PRICE_ID) - .operator(Maximum.Filter.Operator.INCLUDES) - .addValue("string") - .build() - ) - .maximumAmount("maximum_amount") - .build() - ) - .maximumAmount("maximum_amount") - .minimum( - Minimum.builder() - .addAppliesToPriceId("string") - .addFilter( - Minimum.Filter.builder() - .field(Minimum.Filter.Field.PRICE_ID) - .operator(Minimum.Filter.Operator.INCLUDES) - .addValue("string") - .build() - ) - .minimumAmount("minimum_amount") - .build() - ) - .minimumAmount("minimum_amount") .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( @@ -650,53 +604,9 @@ internal class IncrementLedgerEntryTest { ) .amount("7.00") .creditsApplied("6.00") - .discount( - PercentageDiscount.builder() - .discountType(PercentageDiscount.DiscountType.PERCENTAGE) - .percentageDiscount(0.15) - .addAppliesToPriceId("h74gfhdjvn7ujokd") - .addAppliesToPriceId("7hfgtgjnbvc3ujkl") - .addFilter( - PercentageDiscount.Filter.builder() - .field(PercentageDiscount.Filter.Field.PRICE_ID) - .operator(PercentageDiscount.Filter.Operator.INCLUDES) - .addValue("string") - .build() - ) - .reason("reason") - .build() - ) .endDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) .filter("filter") .grouping("grouping") - .maximum( - Maximum.builder() - .addAppliesToPriceId("string") - .addFilter( - Maximum.Filter.builder() - .field(Maximum.Filter.Field.PRICE_ID) - .operator(Maximum.Filter.Operator.INCLUDES) - .addValue("string") - .build() - ) - .maximumAmount("maximum_amount") - .build() - ) - .maximumAmount("maximum_amount") - .minimum( - Minimum.builder() - .addAppliesToPriceId("string") - .addFilter( - Minimum.Filter.builder() - .field(Minimum.Filter.Field.PRICE_ID) - .operator(Minimum.Filter.Operator.INCLUDES) - .addValue("string") - .build() - ) - .minimumAmount("minimum_amount") - .build() - ) - .minimumAmount("minimum_amount") .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( @@ -1107,55 +1017,9 @@ internal class IncrementLedgerEntryTest { ) .amount("7.00") .creditsApplied("6.00") - .discount( - PercentageDiscount.builder() - .discountType(PercentageDiscount.DiscountType.PERCENTAGE) - .percentageDiscount(0.15) - .addAppliesToPriceId("h74gfhdjvn7ujokd") - .addAppliesToPriceId("7hfgtgjnbvc3ujkl") - .addFilter( - PercentageDiscount.Filter.builder() - .field(PercentageDiscount.Filter.Field.PRICE_ID) - .operator( - PercentageDiscount.Filter.Operator.INCLUDES - ) - .addValue("string") - .build() - ) - .reason("reason") - .build() - ) .endDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) .filter("filter") .grouping("grouping") - .maximum( - Maximum.builder() - .addAppliesToPriceId("string") - .addFilter( - Maximum.Filter.builder() - .field(Maximum.Filter.Field.PRICE_ID) - .operator(Maximum.Filter.Operator.INCLUDES) - .addValue("string") - .build() - ) - .maximumAmount("maximum_amount") - .build() - ) - .maximumAmount("maximum_amount") - .minimum( - Minimum.builder() - .addAppliesToPriceId("string") - .addFilter( - Minimum.Filter.builder() - .field(Minimum.Filter.Field.PRICE_ID) - .operator(Minimum.Filter.Operator.INCLUDES) - .addValue("string") - .build() - ) - .minimumAmount("minimum_amount") - .build() - ) - .minimumAmount("minimum_amount") .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceFetchUpcomingResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceFetchUpcomingResponseTest.kt index ba347a75e..c3b22d840 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceFetchUpcomingResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceFetchUpcomingResponseTest.kt @@ -136,53 +136,9 @@ internal class InvoiceFetchUpcomingResponseTest { ) .amount("7.00") .creditsApplied("6.00") - .discount( - PercentageDiscount.builder() - .discountType(PercentageDiscount.DiscountType.PERCENTAGE) - .percentageDiscount(0.15) - .addAppliesToPriceId("h74gfhdjvn7ujokd") - .addAppliesToPriceId("7hfgtgjnbvc3ujkl") - .addFilter( - PercentageDiscount.Filter.builder() - .field(PercentageDiscount.Filter.Field.PRICE_ID) - .operator(PercentageDiscount.Filter.Operator.INCLUDES) - .addValue("string") - .build() - ) - .reason("reason") - .build() - ) .endDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) .filter("filter") .grouping("grouping") - .maximum( - Maximum.builder() - .addAppliesToPriceId("string") - .addFilter( - Maximum.Filter.builder() - .field(Maximum.Filter.Field.PRICE_ID) - .operator(Maximum.Filter.Operator.INCLUDES) - .addValue("string") - .build() - ) - .maximumAmount("maximum_amount") - .build() - ) - .maximumAmount("maximum_amount") - .minimum( - Minimum.builder() - .addAppliesToPriceId("string") - .addFilter( - Minimum.Filter.builder() - .field(Minimum.Filter.Field.PRICE_ID) - .operator(Minimum.Filter.Operator.INCLUDES) - .addValue("string") - .build() - ) - .minimumAmount("minimum_amount") - .build() - ) - .minimumAmount("minimum_amount") .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( @@ -552,53 +508,9 @@ internal class InvoiceFetchUpcomingResponseTest { ) .amount("7.00") .creditsApplied("6.00") - .discount( - PercentageDiscount.builder() - .discountType(PercentageDiscount.DiscountType.PERCENTAGE) - .percentageDiscount(0.15) - .addAppliesToPriceId("h74gfhdjvn7ujokd") - .addAppliesToPriceId("7hfgtgjnbvc3ujkl") - .addFilter( - PercentageDiscount.Filter.builder() - .field(PercentageDiscount.Filter.Field.PRICE_ID) - .operator(PercentageDiscount.Filter.Operator.INCLUDES) - .addValue("string") - .build() - ) - .reason("reason") - .build() - ) .endDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) .filter("filter") .grouping("grouping") - .maximum( - Maximum.builder() - .addAppliesToPriceId("string") - .addFilter( - Maximum.Filter.builder() - .field(Maximum.Filter.Field.PRICE_ID) - .operator(Maximum.Filter.Operator.INCLUDES) - .addValue("string") - .build() - ) - .maximumAmount("maximum_amount") - .build() - ) - .maximumAmount("maximum_amount") - .minimum( - Minimum.builder() - .addAppliesToPriceId("string") - .addFilter( - Minimum.Filter.builder() - .field(Minimum.Filter.Field.PRICE_ID) - .operator(Minimum.Filter.Operator.INCLUDES) - .addValue("string") - .build() - ) - .minimumAmount("minimum_amount") - .build() - ) - .minimumAmount("minimum_amount") .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( @@ -966,53 +878,9 @@ internal class InvoiceFetchUpcomingResponseTest { ) .amount("7.00") .creditsApplied("6.00") - .discount( - PercentageDiscount.builder() - .discountType(PercentageDiscount.DiscountType.PERCENTAGE) - .percentageDiscount(0.15) - .addAppliesToPriceId("h74gfhdjvn7ujokd") - .addAppliesToPriceId("7hfgtgjnbvc3ujkl") - .addFilter( - PercentageDiscount.Filter.builder() - .field(PercentageDiscount.Filter.Field.PRICE_ID) - .operator(PercentageDiscount.Filter.Operator.INCLUDES) - .addValue("string") - .build() - ) - .reason("reason") - .build() - ) .endDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) .filter("filter") .grouping("grouping") - .maximum( - Maximum.builder() - .addAppliesToPriceId("string") - .addFilter( - Maximum.Filter.builder() - .field(Maximum.Filter.Field.PRICE_ID) - .operator(Maximum.Filter.Operator.INCLUDES) - .addValue("string") - .build() - ) - .maximumAmount("maximum_amount") - .build() - ) - .maximumAmount("maximum_amount") - .minimum( - Minimum.builder() - .addAppliesToPriceId("string") - .addFilter( - Minimum.Filter.builder() - .field(Minimum.Filter.Field.PRICE_ID) - .operator(Minimum.Filter.Operator.INCLUDES) - .addValue("string") - .build() - ) - .minimumAmount("minimum_amount") - .build() - ) - .minimumAmount("minimum_amount") .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceLineItemCreateResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceLineItemCreateResponseTest.kt index 033f332e2..4e23973a1 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceLineItemCreateResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceLineItemCreateResponseTest.kt @@ -40,53 +40,9 @@ internal class InvoiceLineItemCreateResponseTest { ) .amount("7.00") .creditsApplied("6.00") - .discount( - PercentageDiscount.builder() - .discountType(PercentageDiscount.DiscountType.PERCENTAGE) - .percentageDiscount(0.15) - .addAppliesToPriceId("h74gfhdjvn7ujokd") - .addAppliesToPriceId("7hfgtgjnbvc3ujkl") - .addFilter( - PercentageDiscount.Filter.builder() - .field(PercentageDiscount.Filter.Field.PRICE_ID) - .operator(PercentageDiscount.Filter.Operator.INCLUDES) - .addValue("string") - .build() - ) - .reason("reason") - .build() - ) .endDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) .filter("filter") .grouping("grouping") - .maximum( - Maximum.builder() - .addAppliesToPriceId("string") - .addFilter( - Maximum.Filter.builder() - .field(Maximum.Filter.Field.PRICE_ID) - .operator(Maximum.Filter.Operator.INCLUDES) - .addValue("string") - .build() - ) - .maximumAmount("maximum_amount") - .build() - ) - .maximumAmount("maximum_amount") - .minimum( - Minimum.builder() - .addAppliesToPriceId("string") - .addFilter( - Minimum.Filter.builder() - .field(Minimum.Filter.Field.PRICE_ID) - .operator(Minimum.Filter.Operator.INCLUDES) - .addValue("string") - .build() - ) - .minimumAmount("minimum_amount") - .build() - ) - .minimumAmount("minimum_amount") .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( @@ -260,59 +216,10 @@ internal class InvoiceLineItemCreateResponseTest { ) assertThat(invoiceLineItemCreateResponse.amount()).isEqualTo("7.00") assertThat(invoiceLineItemCreateResponse.creditsApplied()).isEqualTo("6.00") - assertThat(invoiceLineItemCreateResponse.discount()) - .isEqualTo( - Discount.ofPercentage( - PercentageDiscount.builder() - .discountType(PercentageDiscount.DiscountType.PERCENTAGE) - .percentageDiscount(0.15) - .addAppliesToPriceId("h74gfhdjvn7ujokd") - .addAppliesToPriceId("7hfgtgjnbvc3ujkl") - .addFilter( - PercentageDiscount.Filter.builder() - .field(PercentageDiscount.Filter.Field.PRICE_ID) - .operator(PercentageDiscount.Filter.Operator.INCLUDES) - .addValue("string") - .build() - ) - .reason("reason") - .build() - ) - ) assertThat(invoiceLineItemCreateResponse.endDate()) .isEqualTo(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) assertThat(invoiceLineItemCreateResponse.filter()).isEqualTo("filter") assertThat(invoiceLineItemCreateResponse.grouping()).isEqualTo("grouping") - assertThat(invoiceLineItemCreateResponse.maximum()) - .isEqualTo( - Maximum.builder() - .addAppliesToPriceId("string") - .addFilter( - Maximum.Filter.builder() - .field(Maximum.Filter.Field.PRICE_ID) - .operator(Maximum.Filter.Operator.INCLUDES) - .addValue("string") - .build() - ) - .maximumAmount("maximum_amount") - .build() - ) - assertThat(invoiceLineItemCreateResponse.maximumAmount()).isEqualTo("maximum_amount") - assertThat(invoiceLineItemCreateResponse.minimum()) - .isEqualTo( - Minimum.builder() - .addAppliesToPriceId("string") - .addFilter( - Minimum.Filter.builder() - .field(Minimum.Filter.Field.PRICE_ID) - .operator(Minimum.Filter.Operator.INCLUDES) - .addValue("string") - .build() - ) - .minimumAmount("minimum_amount") - .build() - ) - assertThat(invoiceLineItemCreateResponse.minimumAmount()).isEqualTo("minimum_amount") assertThat(invoiceLineItemCreateResponse.name()).isEqualTo("Fixed Fee") assertThat(invoiceLineItemCreateResponse.partiallyInvoicedAmount()).isEqualTo("4.00") assertThat(invoiceLineItemCreateResponse.price()) @@ -496,53 +403,9 @@ internal class InvoiceLineItemCreateResponseTest { ) .amount("7.00") .creditsApplied("6.00") - .discount( - PercentageDiscount.builder() - .discountType(PercentageDiscount.DiscountType.PERCENTAGE) - .percentageDiscount(0.15) - .addAppliesToPriceId("h74gfhdjvn7ujokd") - .addAppliesToPriceId("7hfgtgjnbvc3ujkl") - .addFilter( - PercentageDiscount.Filter.builder() - .field(PercentageDiscount.Filter.Field.PRICE_ID) - .operator(PercentageDiscount.Filter.Operator.INCLUDES) - .addValue("string") - .build() - ) - .reason("reason") - .build() - ) .endDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) .filter("filter") .grouping("grouping") - .maximum( - Maximum.builder() - .addAppliesToPriceId("string") - .addFilter( - Maximum.Filter.builder() - .field(Maximum.Filter.Field.PRICE_ID) - .operator(Maximum.Filter.Operator.INCLUDES) - .addValue("string") - .build() - ) - .maximumAmount("maximum_amount") - .build() - ) - .maximumAmount("maximum_amount") - .minimum( - Minimum.builder() - .addAppliesToPriceId("string") - .addFilter( - Minimum.Filter.builder() - .field(Minimum.Filter.Field.PRICE_ID) - .operator(Minimum.Filter.Operator.INCLUDES) - .addValue("string") - .build() - ) - .minimumAmount("minimum_amount") - .build() - ) - .minimumAmount("minimum_amount") .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceListPageResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceListPageResponseTest.kt index 27770db19..d29aa1314 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceListPageResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceListPageResponseTest.kt @@ -143,55 +143,9 @@ internal class InvoiceListPageResponseTest { ) .amount("7.00") .creditsApplied("6.00") - .discount( - PercentageDiscount.builder() - .discountType(PercentageDiscount.DiscountType.PERCENTAGE) - .percentageDiscount(0.15) - .addAppliesToPriceId("h74gfhdjvn7ujokd") - .addAppliesToPriceId("7hfgtgjnbvc3ujkl") - .addFilter( - PercentageDiscount.Filter.builder() - .field(PercentageDiscount.Filter.Field.PRICE_ID) - .operator( - PercentageDiscount.Filter.Operator.INCLUDES - ) - .addValue("string") - .build() - ) - .reason("reason") - .build() - ) .endDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) .filter("filter") .grouping("grouping") - .maximum( - Maximum.builder() - .addAppliesToPriceId("string") - .addFilter( - Maximum.Filter.builder() - .field(Maximum.Filter.Field.PRICE_ID) - .operator(Maximum.Filter.Operator.INCLUDES) - .addValue("string") - .build() - ) - .maximumAmount("maximum_amount") - .build() - ) - .maximumAmount("maximum_amount") - .minimum( - Minimum.builder() - .addAppliesToPriceId("string") - .addFilter( - Minimum.Filter.builder() - .field(Minimum.Filter.Field.PRICE_ID) - .operator(Minimum.Filter.Operator.INCLUDES) - .addValue("string") - .build() - ) - .minimumAmount("minimum_amount") - .build() - ) - .minimumAmount("minimum_amount") .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( @@ -577,53 +531,9 @@ internal class InvoiceListPageResponseTest { ) .amount("7.00") .creditsApplied("6.00") - .discount( - PercentageDiscount.builder() - .discountType(PercentageDiscount.DiscountType.PERCENTAGE) - .percentageDiscount(0.15) - .addAppliesToPriceId("h74gfhdjvn7ujokd") - .addAppliesToPriceId("7hfgtgjnbvc3ujkl") - .addFilter( - PercentageDiscount.Filter.builder() - .field(PercentageDiscount.Filter.Field.PRICE_ID) - .operator(PercentageDiscount.Filter.Operator.INCLUDES) - .addValue("string") - .build() - ) - .reason("reason") - .build() - ) .endDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) .filter("filter") .grouping("grouping") - .maximum( - Maximum.builder() - .addAppliesToPriceId("string") - .addFilter( - Maximum.Filter.builder() - .field(Maximum.Filter.Field.PRICE_ID) - .operator(Maximum.Filter.Operator.INCLUDES) - .addValue("string") - .build() - ) - .maximumAmount("maximum_amount") - .build() - ) - .maximumAmount("maximum_amount") - .minimum( - Minimum.builder() - .addAppliesToPriceId("string") - .addFilter( - Minimum.Filter.builder() - .field(Minimum.Filter.Field.PRICE_ID) - .operator(Minimum.Filter.Operator.INCLUDES) - .addValue("string") - .build() - ) - .minimumAmount("minimum_amount") - .build() - ) - .minimumAmount("minimum_amount") .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( @@ -1001,55 +911,9 @@ internal class InvoiceListPageResponseTest { ) .amount("7.00") .creditsApplied("6.00") - .discount( - PercentageDiscount.builder() - .discountType(PercentageDiscount.DiscountType.PERCENTAGE) - .percentageDiscount(0.15) - .addAppliesToPriceId("h74gfhdjvn7ujokd") - .addAppliesToPriceId("7hfgtgjnbvc3ujkl") - .addFilter( - PercentageDiscount.Filter.builder() - .field(PercentageDiscount.Filter.Field.PRICE_ID) - .operator( - PercentageDiscount.Filter.Operator.INCLUDES - ) - .addValue("string") - .build() - ) - .reason("reason") - .build() - ) .endDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) .filter("filter") .grouping("grouping") - .maximum( - Maximum.builder() - .addAppliesToPriceId("string") - .addFilter( - Maximum.Filter.builder() - .field(Maximum.Filter.Field.PRICE_ID) - .operator(Maximum.Filter.Operator.INCLUDES) - .addValue("string") - .build() - ) - .maximumAmount("maximum_amount") - .build() - ) - .maximumAmount("maximum_amount") - .minimum( - Minimum.builder() - .addAppliesToPriceId("string") - .addFilter( - Minimum.Filter.builder() - .field(Minimum.Filter.Field.PRICE_ID) - .operator(Minimum.Filter.Operator.INCLUDES) - .addValue("string") - .build() - ) - .minimumAmount("minimum_amount") - .build() - ) - .minimumAmount("minimum_amount") .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceTest.kt index bd4ea401a..3043b7df2 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceTest.kt @@ -132,53 +132,9 @@ internal class InvoiceTest { ) .amount("7.00") .creditsApplied("6.00") - .discount( - PercentageDiscount.builder() - .discountType(PercentageDiscount.DiscountType.PERCENTAGE) - .percentageDiscount(0.15) - .addAppliesToPriceId("h74gfhdjvn7ujokd") - .addAppliesToPriceId("7hfgtgjnbvc3ujkl") - .addFilter( - PercentageDiscount.Filter.builder() - .field(PercentageDiscount.Filter.Field.PRICE_ID) - .operator(PercentageDiscount.Filter.Operator.INCLUDES) - .addValue("string") - .build() - ) - .reason("reason") - .build() - ) .endDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) .filter("filter") .grouping("grouping") - .maximum( - Maximum.builder() - .addAppliesToPriceId("string") - .addFilter( - Maximum.Filter.builder() - .field(Maximum.Filter.Field.PRICE_ID) - .operator(Maximum.Filter.Operator.INCLUDES) - .addValue("string") - .build() - ) - .maximumAmount("maximum_amount") - .build() - ) - .maximumAmount("maximum_amount") - .minimum( - Minimum.builder() - .addAppliesToPriceId("string") - .addFilter( - Minimum.Filter.builder() - .field(Minimum.Filter.Field.PRICE_ID) - .operator(Minimum.Filter.Operator.INCLUDES) - .addValue("string") - .build() - ) - .minimumAmount("minimum_amount") - .build() - ) - .minimumAmount("minimum_amount") .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( @@ -539,53 +495,9 @@ internal class InvoiceTest { ) .amount("7.00") .creditsApplied("6.00") - .discount( - PercentageDiscount.builder() - .discountType(PercentageDiscount.DiscountType.PERCENTAGE) - .percentageDiscount(0.15) - .addAppliesToPriceId("h74gfhdjvn7ujokd") - .addAppliesToPriceId("7hfgtgjnbvc3ujkl") - .addFilter( - PercentageDiscount.Filter.builder() - .field(PercentageDiscount.Filter.Field.PRICE_ID) - .operator(PercentageDiscount.Filter.Operator.INCLUDES) - .addValue("string") - .build() - ) - .reason("reason") - .build() - ) .endDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) .filter("filter") .grouping("grouping") - .maximum( - Maximum.builder() - .addAppliesToPriceId("string") - .addFilter( - Maximum.Filter.builder() - .field(Maximum.Filter.Field.PRICE_ID) - .operator(Maximum.Filter.Operator.INCLUDES) - .addValue("string") - .build() - ) - .maximumAmount("maximum_amount") - .build() - ) - .maximumAmount("maximum_amount") - .minimum( - Minimum.builder() - .addAppliesToPriceId("string") - .addFilter( - Minimum.Filter.builder() - .field(Minimum.Filter.Field.PRICE_ID) - .operator(Minimum.Filter.Operator.INCLUDES) - .addValue("string") - .build() - ) - .minimumAmount("minimum_amount") - .build() - ) - .minimumAmount("minimum_amount") .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( @@ -942,53 +854,9 @@ internal class InvoiceTest { ) .amount("7.00") .creditsApplied("6.00") - .discount( - PercentageDiscount.builder() - .discountType(PercentageDiscount.DiscountType.PERCENTAGE) - .percentageDiscount(0.15) - .addAppliesToPriceId("h74gfhdjvn7ujokd") - .addAppliesToPriceId("7hfgtgjnbvc3ujkl") - .addFilter( - PercentageDiscount.Filter.builder() - .field(PercentageDiscount.Filter.Field.PRICE_ID) - .operator(PercentageDiscount.Filter.Operator.INCLUDES) - .addValue("string") - .build() - ) - .reason("reason") - .build() - ) .endDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) .filter("filter") .grouping("grouping") - .maximum( - Maximum.builder() - .addAppliesToPriceId("string") - .addFilter( - Maximum.Filter.builder() - .field(Maximum.Filter.Field.PRICE_ID) - .operator(Maximum.Filter.Operator.INCLUDES) - .addValue("string") - .build() - ) - .maximumAmount("maximum_amount") - .build() - ) - .maximumAmount("maximum_amount") - .minimum( - Minimum.builder() - .addAppliesToPriceId("string") - .addFilter( - Minimum.Filter.builder() - .field(Minimum.Filter.Field.PRICE_ID) - .operator(Minimum.Filter.Operator.INCLUDES) - .addValue("string") - .build() - ) - .minimumAmount("minimum_amount") - .build() - ) - .minimumAmount("minimum_amount") .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/MutatedSubscriptionTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/MutatedSubscriptionTest.kt index 91d1cb14f..b166f9486 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/MutatedSubscriptionTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/MutatedSubscriptionTest.kt @@ -915,60 +915,9 @@ internal class MutatedSubscriptionTest { ) .amount("7.00") .creditsApplied("6.00") - .discount( - PercentageDiscount.builder() - .discountType( - PercentageDiscount.DiscountType.PERCENTAGE - ) - .percentageDiscount(0.15) - .addAppliesToPriceId("h74gfhdjvn7ujokd") - .addAppliesToPriceId("7hfgtgjnbvc3ujkl") - .addFilter( - PercentageDiscount.Filter.builder() - .field( - PercentageDiscount.Filter.Field.PRICE_ID - ) - .operator( - PercentageDiscount.Filter.Operator - .INCLUDES - ) - .addValue("string") - .build() - ) - .reason("reason") - .build() - ) .endDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) .filter("filter") .grouping("grouping") - .maximum( - Maximum.builder() - .addAppliesToPriceId("string") - .addFilter( - Maximum.Filter.builder() - .field(Maximum.Filter.Field.PRICE_ID) - .operator(Maximum.Filter.Operator.INCLUDES) - .addValue("string") - .build() - ) - .maximumAmount("maximum_amount") - .build() - ) - .maximumAmount("maximum_amount") - .minimum( - Minimum.builder() - .addAppliesToPriceId("string") - .addFilter( - Minimum.Filter.builder() - .field(Minimum.Filter.Field.PRICE_ID) - .operator(Minimum.Filter.Operator.INCLUDES) - .addValue("string") - .build() - ) - .minimumAmount("minimum_amount") - .build() - ) - .minimumAmount("minimum_amount") .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( @@ -1487,60 +1436,9 @@ internal class MutatedSubscriptionTest { ) .amount("7.00") .creditsApplied("6.00") - .discount( - PercentageDiscount.builder() - .discountType( - PercentageDiscount.DiscountType.PERCENTAGE - ) - .percentageDiscount(0.15) - .addAppliesToPriceId("h74gfhdjvn7ujokd") - .addAppliesToPriceId("7hfgtgjnbvc3ujkl") - .addFilter( - PercentageDiscount.Filter.builder() - .field( - PercentageDiscount.Filter.Field.PRICE_ID - ) - .operator( - PercentageDiscount.Filter.Operator - .INCLUDES - ) - .addValue("string") - .build() - ) - .reason("reason") - .build() - ) .endDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) .filter("filter") .grouping("grouping") - .maximum( - Maximum.builder() - .addAppliesToPriceId("string") - .addFilter( - Maximum.Filter.builder() - .field(Maximum.Filter.Field.PRICE_ID) - .operator(Maximum.Filter.Operator.INCLUDES) - .addValue("string") - .build() - ) - .maximumAmount("maximum_amount") - .build() - ) - .maximumAmount("maximum_amount") - .minimum( - Minimum.builder() - .addAppliesToPriceId("string") - .addFilter( - Minimum.Filter.builder() - .field(Minimum.Filter.Field.PRICE_ID) - .operator(Minimum.Filter.Operator.INCLUDES) - .addValue("string") - .build() - ) - .minimumAmount("minimum_amount") - .build() - ) - .minimumAmount("minimum_amount") .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( @@ -2714,57 +2612,9 @@ internal class MutatedSubscriptionTest { ) .amount("7.00") .creditsApplied("6.00") - .discount( - PercentageDiscount.builder() - .discountType( - PercentageDiscount.DiscountType.PERCENTAGE - ) - .percentageDiscount(0.15) - .addAppliesToPriceId("h74gfhdjvn7ujokd") - .addAppliesToPriceId("7hfgtgjnbvc3ujkl") - .addFilter( - PercentageDiscount.Filter.builder() - .field(PercentageDiscount.Filter.Field.PRICE_ID) - .operator( - PercentageDiscount.Filter.Operator.INCLUDES - ) - .addValue("string") - .build() - ) - .reason("reason") - .build() - ) .endDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) .filter("filter") .grouping("grouping") - .maximum( - Maximum.builder() - .addAppliesToPriceId("string") - .addFilter( - Maximum.Filter.builder() - .field(Maximum.Filter.Field.PRICE_ID) - .operator(Maximum.Filter.Operator.INCLUDES) - .addValue("string") - .build() - ) - .maximumAmount("maximum_amount") - .build() - ) - .maximumAmount("maximum_amount") - .minimum( - Minimum.builder() - .addAppliesToPriceId("string") - .addFilter( - Minimum.Filter.builder() - .field(Minimum.Filter.Field.PRICE_ID) - .operator(Minimum.Filter.Operator.INCLUDES) - .addValue("string") - .build() - ) - .minimumAmount("minimum_amount") - .build() - ) - .minimumAmount("minimum_amount") .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( @@ -3251,57 +3101,9 @@ internal class MutatedSubscriptionTest { ) .amount("7.00") .creditsApplied("6.00") - .discount( - PercentageDiscount.builder() - .discountType( - PercentageDiscount.DiscountType.PERCENTAGE - ) - .percentageDiscount(0.15) - .addAppliesToPriceId("h74gfhdjvn7ujokd") - .addAppliesToPriceId("7hfgtgjnbvc3ujkl") - .addFilter( - PercentageDiscount.Filter.builder() - .field(PercentageDiscount.Filter.Field.PRICE_ID) - .operator( - PercentageDiscount.Filter.Operator.INCLUDES - ) - .addValue("string") - .build() - ) - .reason("reason") - .build() - ) .endDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) .filter("filter") .grouping("grouping") - .maximum( - Maximum.builder() - .addAppliesToPriceId("string") - .addFilter( - Maximum.Filter.builder() - .field(Maximum.Filter.Field.PRICE_ID) - .operator(Maximum.Filter.Operator.INCLUDES) - .addValue("string") - .build() - ) - .maximumAmount("maximum_amount") - .build() - ) - .maximumAmount("maximum_amount") - .minimum( - Minimum.builder() - .addAppliesToPriceId("string") - .addFilter( - Minimum.Filter.builder() - .field(Minimum.Filter.Field.PRICE_ID) - .operator(Minimum.Filter.Operator.INCLUDES) - .addValue("string") - .build() - ) - .minimumAmount("minimum_amount") - .build() - ) - .minimumAmount("minimum_amount") .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( @@ -4476,60 +4278,9 @@ internal class MutatedSubscriptionTest { ) .amount("7.00") .creditsApplied("6.00") - .discount( - PercentageDiscount.builder() - .discountType( - PercentageDiscount.DiscountType.PERCENTAGE - ) - .percentageDiscount(0.15) - .addAppliesToPriceId("h74gfhdjvn7ujokd") - .addAppliesToPriceId("7hfgtgjnbvc3ujkl") - .addFilter( - PercentageDiscount.Filter.builder() - .field( - PercentageDiscount.Filter.Field.PRICE_ID - ) - .operator( - PercentageDiscount.Filter.Operator - .INCLUDES - ) - .addValue("string") - .build() - ) - .reason("reason") - .build() - ) .endDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) .filter("filter") .grouping("grouping") - .maximum( - Maximum.builder() - .addAppliesToPriceId("string") - .addFilter( - Maximum.Filter.builder() - .field(Maximum.Filter.Field.PRICE_ID) - .operator(Maximum.Filter.Operator.INCLUDES) - .addValue("string") - .build() - ) - .maximumAmount("maximum_amount") - .build() - ) - .maximumAmount("maximum_amount") - .minimum( - Minimum.builder() - .addAppliesToPriceId("string") - .addFilter( - Minimum.Filter.builder() - .field(Minimum.Filter.Field.PRICE_ID) - .operator(Minimum.Filter.Operator.INCLUDES) - .addValue("string") - .build() - ) - .minimumAmount("minimum_amount") - .build() - ) - .minimumAmount("minimum_amount") .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( @@ -5048,60 +4799,9 @@ internal class MutatedSubscriptionTest { ) .amount("7.00") .creditsApplied("6.00") - .discount( - PercentageDiscount.builder() - .discountType( - PercentageDiscount.DiscountType.PERCENTAGE - ) - .percentageDiscount(0.15) - .addAppliesToPriceId("h74gfhdjvn7ujokd") - .addAppliesToPriceId("7hfgtgjnbvc3ujkl") - .addFilter( - PercentageDiscount.Filter.builder() - .field( - PercentageDiscount.Filter.Field.PRICE_ID - ) - .operator( - PercentageDiscount.Filter.Operator - .INCLUDES - ) - .addValue("string") - .build() - ) - .reason("reason") - .build() - ) .endDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) .filter("filter") .grouping("grouping") - .maximum( - Maximum.builder() - .addAppliesToPriceId("string") - .addFilter( - Maximum.Filter.builder() - .field(Maximum.Filter.Field.PRICE_ID) - .operator(Maximum.Filter.Operator.INCLUDES) - .addValue("string") - .build() - ) - .maximumAmount("maximum_amount") - .build() - ) - .maximumAmount("maximum_amount") - .minimum( - Minimum.builder() - .addAppliesToPriceId("string") - .addFilter( - Minimum.Filter.builder() - .field(Minimum.Filter.Field.PRICE_ID) - .operator(Minimum.Filter.Operator.INCLUDES) - .addValue("string") - .build() - ) - .minimumAmount("minimum_amount") - .build() - ) - .minimumAmount("minimum_amount") .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeApplyResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeApplyResponseTest.kt index 81d6567dd..e1e8abab4 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeApplyResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeApplyResponseTest.kt @@ -1029,32 +1029,6 @@ internal class SubscriptionChangeApplyResponseTest { ) .amount("7.00") .creditsApplied("6.00") - .discount( - PercentageDiscount.builder() - .discountType( - PercentageDiscount.DiscountType - .PERCENTAGE - ) - .percentageDiscount(0.15) - .addAppliesToPriceId("h74gfhdjvn7ujokd") - .addAppliesToPriceId("7hfgtgjnbvc3ujkl") - .addFilter( - PercentageDiscount.Filter.builder() - .field( - PercentageDiscount.Filter.Field - .PRICE_ID - ) - .operator( - PercentageDiscount.Filter - .Operator - .INCLUDES - ) - .addValue("string") - .build() - ) - .reason("reason") - .build() - ) .endDate( OffsetDateTime.parse( "2022-02-01T08:00:00+00:00" @@ -1062,42 +1036,6 @@ internal class SubscriptionChangeApplyResponseTest { ) .filter("filter") .grouping("grouping") - .maximum( - Maximum.builder() - .addAppliesToPriceId("string") - .addFilter( - Maximum.Filter.builder() - .field( - Maximum.Filter.Field.PRICE_ID - ) - .operator( - Maximum.Filter.Operator.INCLUDES - ) - .addValue("string") - .build() - ) - .maximumAmount("maximum_amount") - .build() - ) - .maximumAmount("maximum_amount") - .minimum( - Minimum.builder() - .addAppliesToPriceId("string") - .addFilter( - Minimum.Filter.builder() - .field( - Minimum.Filter.Field.PRICE_ID - ) - .operator( - Minimum.Filter.Operator.INCLUDES - ) - .addValue("string") - .build() - ) - .minimumAmount("minimum_amount") - .build() - ) - .minimumAmount("minimum_amount") .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( @@ -1705,32 +1643,6 @@ internal class SubscriptionChangeApplyResponseTest { ) .amount("7.00") .creditsApplied("6.00") - .discount( - PercentageDiscount.builder() - .discountType( - PercentageDiscount.DiscountType - .PERCENTAGE - ) - .percentageDiscount(0.15) - .addAppliesToPriceId("h74gfhdjvn7ujokd") - .addAppliesToPriceId("7hfgtgjnbvc3ujkl") - .addFilter( - PercentageDiscount.Filter.builder() - .field( - PercentageDiscount.Filter.Field - .PRICE_ID - ) - .operator( - PercentageDiscount.Filter - .Operator - .INCLUDES - ) - .addValue("string") - .build() - ) - .reason("reason") - .build() - ) .endDate( OffsetDateTime.parse( "2022-02-01T08:00:00+00:00" @@ -1738,42 +1650,6 @@ internal class SubscriptionChangeApplyResponseTest { ) .filter("filter") .grouping("grouping") - .maximum( - Maximum.builder() - .addAppliesToPriceId("string") - .addFilter( - Maximum.Filter.builder() - .field( - Maximum.Filter.Field.PRICE_ID - ) - .operator( - Maximum.Filter.Operator.INCLUDES - ) - .addValue("string") - .build() - ) - .maximumAmount("maximum_amount") - .build() - ) - .maximumAmount("maximum_amount") - .minimum( - Minimum.builder() - .addAppliesToPriceId("string") - .addFilter( - Minimum.Filter.builder() - .field( - Minimum.Filter.Field.PRICE_ID - ) - .operator( - Minimum.Filter.Operator.INCLUDES - ) - .addValue("string") - .build() - ) - .minimumAmount("minimum_amount") - .build() - ) - .minimumAmount("minimum_amount") .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( @@ -3063,67 +2939,11 @@ internal class SubscriptionChangeApplyResponseTest { ) .amount("7.00") .creditsApplied("6.00") - .discount( - PercentageDiscount.builder() - .discountType( - PercentageDiscount.DiscountType.PERCENTAGE - ) - .percentageDiscount(0.15) - .addAppliesToPriceId("h74gfhdjvn7ujokd") - .addAppliesToPriceId("7hfgtgjnbvc3ujkl") - .addFilter( - PercentageDiscount.Filter.builder() - .field( - PercentageDiscount.Filter.Field - .PRICE_ID - ) - .operator( - PercentageDiscount.Filter.Operator - .INCLUDES - ) - .addValue("string") - .build() - ) - .reason("reason") - .build() - ) .endDate( OffsetDateTime.parse("2022-02-01T08:00:00+00:00") ) .filter("filter") .grouping("grouping") - .maximum( - Maximum.builder() - .addAppliesToPriceId("string") - .addFilter( - Maximum.Filter.builder() - .field(Maximum.Filter.Field.PRICE_ID) - .operator( - Maximum.Filter.Operator.INCLUDES - ) - .addValue("string") - .build() - ) - .maximumAmount("maximum_amount") - .build() - ) - .maximumAmount("maximum_amount") - .minimum( - Minimum.builder() - .addAppliesToPriceId("string") - .addFilter( - Minimum.Filter.builder() - .field(Minimum.Filter.Field.PRICE_ID) - .operator( - Minimum.Filter.Operator.INCLUDES - ) - .addValue("string") - .build() - ) - .minimumAmount("minimum_amount") - .build() - ) - .minimumAmount("minimum_amount") .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( @@ -3688,67 +3508,11 @@ internal class SubscriptionChangeApplyResponseTest { ) .amount("7.00") .creditsApplied("6.00") - .discount( - PercentageDiscount.builder() - .discountType( - PercentageDiscount.DiscountType.PERCENTAGE - ) - .percentageDiscount(0.15) - .addAppliesToPriceId("h74gfhdjvn7ujokd") - .addAppliesToPriceId("7hfgtgjnbvc3ujkl") - .addFilter( - PercentageDiscount.Filter.builder() - .field( - PercentageDiscount.Filter.Field - .PRICE_ID - ) - .operator( - PercentageDiscount.Filter.Operator - .INCLUDES - ) - .addValue("string") - .build() - ) - .reason("reason") - .build() - ) .endDate( OffsetDateTime.parse("2022-02-01T08:00:00+00:00") ) .filter("filter") .grouping("grouping") - .maximum( - Maximum.builder() - .addAppliesToPriceId("string") - .addFilter( - Maximum.Filter.builder() - .field(Maximum.Filter.Field.PRICE_ID) - .operator( - Maximum.Filter.Operator.INCLUDES - ) - .addValue("string") - .build() - ) - .maximumAmount("maximum_amount") - .build() - ) - .maximumAmount("maximum_amount") - .minimum( - Minimum.builder() - .addAppliesToPriceId("string") - .addFilter( - Minimum.Filter.builder() - .field(Minimum.Filter.Field.PRICE_ID) - .operator( - Minimum.Filter.Operator.INCLUDES - ) - .addValue("string") - .build() - ) - .minimumAmount("minimum_amount") - .build() - ) - .minimumAmount("minimum_amount") .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( @@ -5093,32 +4857,6 @@ internal class SubscriptionChangeApplyResponseTest { ) .amount("7.00") .creditsApplied("6.00") - .discount( - PercentageDiscount.builder() - .discountType( - PercentageDiscount.DiscountType - .PERCENTAGE - ) - .percentageDiscount(0.15) - .addAppliesToPriceId("h74gfhdjvn7ujokd") - .addAppliesToPriceId("7hfgtgjnbvc3ujkl") - .addFilter( - PercentageDiscount.Filter.builder() - .field( - PercentageDiscount.Filter.Field - .PRICE_ID - ) - .operator( - PercentageDiscount.Filter - .Operator - .INCLUDES - ) - .addValue("string") - .build() - ) - .reason("reason") - .build() - ) .endDate( OffsetDateTime.parse( "2022-02-01T08:00:00+00:00" @@ -5126,42 +4864,6 @@ internal class SubscriptionChangeApplyResponseTest { ) .filter("filter") .grouping("grouping") - .maximum( - Maximum.builder() - .addAppliesToPriceId("string") - .addFilter( - Maximum.Filter.builder() - .field( - Maximum.Filter.Field.PRICE_ID - ) - .operator( - Maximum.Filter.Operator.INCLUDES - ) - .addValue("string") - .build() - ) - .maximumAmount("maximum_amount") - .build() - ) - .maximumAmount("maximum_amount") - .minimum( - Minimum.builder() - .addAppliesToPriceId("string") - .addFilter( - Minimum.Filter.builder() - .field( - Minimum.Filter.Field.PRICE_ID - ) - .operator( - Minimum.Filter.Operator.INCLUDES - ) - .addValue("string") - .build() - ) - .minimumAmount("minimum_amount") - .build() - ) - .minimumAmount("minimum_amount") .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( @@ -5769,32 +5471,6 @@ internal class SubscriptionChangeApplyResponseTest { ) .amount("7.00") .creditsApplied("6.00") - .discount( - PercentageDiscount.builder() - .discountType( - PercentageDiscount.DiscountType - .PERCENTAGE - ) - .percentageDiscount(0.15) - .addAppliesToPriceId("h74gfhdjvn7ujokd") - .addAppliesToPriceId("7hfgtgjnbvc3ujkl") - .addFilter( - PercentageDiscount.Filter.builder() - .field( - PercentageDiscount.Filter.Field - .PRICE_ID - ) - .operator( - PercentageDiscount.Filter - .Operator - .INCLUDES - ) - .addValue("string") - .build() - ) - .reason("reason") - .build() - ) .endDate( OffsetDateTime.parse( "2022-02-01T08:00:00+00:00" @@ -5802,42 +5478,6 @@ internal class SubscriptionChangeApplyResponseTest { ) .filter("filter") .grouping("grouping") - .maximum( - Maximum.builder() - .addAppliesToPriceId("string") - .addFilter( - Maximum.Filter.builder() - .field( - Maximum.Filter.Field.PRICE_ID - ) - .operator( - Maximum.Filter.Operator.INCLUDES - ) - .addValue("string") - .build() - ) - .maximumAmount("maximum_amount") - .build() - ) - .maximumAmount("maximum_amount") - .minimum( - Minimum.builder() - .addAppliesToPriceId("string") - .addFilter( - Minimum.Filter.builder() - .field( - Minimum.Filter.Field.PRICE_ID - ) - .operator( - Minimum.Filter.Operator.INCLUDES - ) - .addValue("string") - .build() - ) - .minimumAmount("minimum_amount") - .build() - ) - .minimumAmount("minimum_amount") .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeCancelResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeCancelResponseTest.kt index 050557ecd..260e42e39 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeCancelResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeCancelResponseTest.kt @@ -1029,32 +1029,6 @@ internal class SubscriptionChangeCancelResponseTest { ) .amount("7.00") .creditsApplied("6.00") - .discount( - PercentageDiscount.builder() - .discountType( - PercentageDiscount.DiscountType - .PERCENTAGE - ) - .percentageDiscount(0.15) - .addAppliesToPriceId("h74gfhdjvn7ujokd") - .addAppliesToPriceId("7hfgtgjnbvc3ujkl") - .addFilter( - PercentageDiscount.Filter.builder() - .field( - PercentageDiscount.Filter.Field - .PRICE_ID - ) - .operator( - PercentageDiscount.Filter - .Operator - .INCLUDES - ) - .addValue("string") - .build() - ) - .reason("reason") - .build() - ) .endDate( OffsetDateTime.parse( "2022-02-01T08:00:00+00:00" @@ -1062,42 +1036,6 @@ internal class SubscriptionChangeCancelResponseTest { ) .filter("filter") .grouping("grouping") - .maximum( - Maximum.builder() - .addAppliesToPriceId("string") - .addFilter( - Maximum.Filter.builder() - .field( - Maximum.Filter.Field.PRICE_ID - ) - .operator( - Maximum.Filter.Operator.INCLUDES - ) - .addValue("string") - .build() - ) - .maximumAmount("maximum_amount") - .build() - ) - .maximumAmount("maximum_amount") - .minimum( - Minimum.builder() - .addAppliesToPriceId("string") - .addFilter( - Minimum.Filter.builder() - .field( - Minimum.Filter.Field.PRICE_ID - ) - .operator( - Minimum.Filter.Operator.INCLUDES - ) - .addValue("string") - .build() - ) - .minimumAmount("minimum_amount") - .build() - ) - .minimumAmount("minimum_amount") .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( @@ -1705,32 +1643,6 @@ internal class SubscriptionChangeCancelResponseTest { ) .amount("7.00") .creditsApplied("6.00") - .discount( - PercentageDiscount.builder() - .discountType( - PercentageDiscount.DiscountType - .PERCENTAGE - ) - .percentageDiscount(0.15) - .addAppliesToPriceId("h74gfhdjvn7ujokd") - .addAppliesToPriceId("7hfgtgjnbvc3ujkl") - .addFilter( - PercentageDiscount.Filter.builder() - .field( - PercentageDiscount.Filter.Field - .PRICE_ID - ) - .operator( - PercentageDiscount.Filter - .Operator - .INCLUDES - ) - .addValue("string") - .build() - ) - .reason("reason") - .build() - ) .endDate( OffsetDateTime.parse( "2022-02-01T08:00:00+00:00" @@ -1738,42 +1650,6 @@ internal class SubscriptionChangeCancelResponseTest { ) .filter("filter") .grouping("grouping") - .maximum( - Maximum.builder() - .addAppliesToPriceId("string") - .addFilter( - Maximum.Filter.builder() - .field( - Maximum.Filter.Field.PRICE_ID - ) - .operator( - Maximum.Filter.Operator.INCLUDES - ) - .addValue("string") - .build() - ) - .maximumAmount("maximum_amount") - .build() - ) - .maximumAmount("maximum_amount") - .minimum( - Minimum.builder() - .addAppliesToPriceId("string") - .addFilter( - Minimum.Filter.builder() - .field( - Minimum.Filter.Field.PRICE_ID - ) - .operator( - Minimum.Filter.Operator.INCLUDES - ) - .addValue("string") - .build() - ) - .minimumAmount("minimum_amount") - .build() - ) - .minimumAmount("minimum_amount") .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( @@ -3063,67 +2939,11 @@ internal class SubscriptionChangeCancelResponseTest { ) .amount("7.00") .creditsApplied("6.00") - .discount( - PercentageDiscount.builder() - .discountType( - PercentageDiscount.DiscountType.PERCENTAGE - ) - .percentageDiscount(0.15) - .addAppliesToPriceId("h74gfhdjvn7ujokd") - .addAppliesToPriceId("7hfgtgjnbvc3ujkl") - .addFilter( - PercentageDiscount.Filter.builder() - .field( - PercentageDiscount.Filter.Field - .PRICE_ID - ) - .operator( - PercentageDiscount.Filter.Operator - .INCLUDES - ) - .addValue("string") - .build() - ) - .reason("reason") - .build() - ) .endDate( OffsetDateTime.parse("2022-02-01T08:00:00+00:00") ) .filter("filter") .grouping("grouping") - .maximum( - Maximum.builder() - .addAppliesToPriceId("string") - .addFilter( - Maximum.Filter.builder() - .field(Maximum.Filter.Field.PRICE_ID) - .operator( - Maximum.Filter.Operator.INCLUDES - ) - .addValue("string") - .build() - ) - .maximumAmount("maximum_amount") - .build() - ) - .maximumAmount("maximum_amount") - .minimum( - Minimum.builder() - .addAppliesToPriceId("string") - .addFilter( - Minimum.Filter.builder() - .field(Minimum.Filter.Field.PRICE_ID) - .operator( - Minimum.Filter.Operator.INCLUDES - ) - .addValue("string") - .build() - ) - .minimumAmount("minimum_amount") - .build() - ) - .minimumAmount("minimum_amount") .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( @@ -3688,67 +3508,11 @@ internal class SubscriptionChangeCancelResponseTest { ) .amount("7.00") .creditsApplied("6.00") - .discount( - PercentageDiscount.builder() - .discountType( - PercentageDiscount.DiscountType.PERCENTAGE - ) - .percentageDiscount(0.15) - .addAppliesToPriceId("h74gfhdjvn7ujokd") - .addAppliesToPriceId("7hfgtgjnbvc3ujkl") - .addFilter( - PercentageDiscount.Filter.builder() - .field( - PercentageDiscount.Filter.Field - .PRICE_ID - ) - .operator( - PercentageDiscount.Filter.Operator - .INCLUDES - ) - .addValue("string") - .build() - ) - .reason("reason") - .build() - ) .endDate( OffsetDateTime.parse("2022-02-01T08:00:00+00:00") ) .filter("filter") .grouping("grouping") - .maximum( - Maximum.builder() - .addAppliesToPriceId("string") - .addFilter( - Maximum.Filter.builder() - .field(Maximum.Filter.Field.PRICE_ID) - .operator( - Maximum.Filter.Operator.INCLUDES - ) - .addValue("string") - .build() - ) - .maximumAmount("maximum_amount") - .build() - ) - .maximumAmount("maximum_amount") - .minimum( - Minimum.builder() - .addAppliesToPriceId("string") - .addFilter( - Minimum.Filter.builder() - .field(Minimum.Filter.Field.PRICE_ID) - .operator( - Minimum.Filter.Operator.INCLUDES - ) - .addValue("string") - .build() - ) - .minimumAmount("minimum_amount") - .build() - ) - .minimumAmount("minimum_amount") .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( @@ -5093,32 +4857,6 @@ internal class SubscriptionChangeCancelResponseTest { ) .amount("7.00") .creditsApplied("6.00") - .discount( - PercentageDiscount.builder() - .discountType( - PercentageDiscount.DiscountType - .PERCENTAGE - ) - .percentageDiscount(0.15) - .addAppliesToPriceId("h74gfhdjvn7ujokd") - .addAppliesToPriceId("7hfgtgjnbvc3ujkl") - .addFilter( - PercentageDiscount.Filter.builder() - .field( - PercentageDiscount.Filter.Field - .PRICE_ID - ) - .operator( - PercentageDiscount.Filter - .Operator - .INCLUDES - ) - .addValue("string") - .build() - ) - .reason("reason") - .build() - ) .endDate( OffsetDateTime.parse( "2022-02-01T08:00:00+00:00" @@ -5126,42 +4864,6 @@ internal class SubscriptionChangeCancelResponseTest { ) .filter("filter") .grouping("grouping") - .maximum( - Maximum.builder() - .addAppliesToPriceId("string") - .addFilter( - Maximum.Filter.builder() - .field( - Maximum.Filter.Field.PRICE_ID - ) - .operator( - Maximum.Filter.Operator.INCLUDES - ) - .addValue("string") - .build() - ) - .maximumAmount("maximum_amount") - .build() - ) - .maximumAmount("maximum_amount") - .minimum( - Minimum.builder() - .addAppliesToPriceId("string") - .addFilter( - Minimum.Filter.builder() - .field( - Minimum.Filter.Field.PRICE_ID - ) - .operator( - Minimum.Filter.Operator.INCLUDES - ) - .addValue("string") - .build() - ) - .minimumAmount("minimum_amount") - .build() - ) - .minimumAmount("minimum_amount") .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( @@ -5769,32 +5471,6 @@ internal class SubscriptionChangeCancelResponseTest { ) .amount("7.00") .creditsApplied("6.00") - .discount( - PercentageDiscount.builder() - .discountType( - PercentageDiscount.DiscountType - .PERCENTAGE - ) - .percentageDiscount(0.15) - .addAppliesToPriceId("h74gfhdjvn7ujokd") - .addAppliesToPriceId("7hfgtgjnbvc3ujkl") - .addFilter( - PercentageDiscount.Filter.builder() - .field( - PercentageDiscount.Filter.Field - .PRICE_ID - ) - .operator( - PercentageDiscount.Filter - .Operator - .INCLUDES - ) - .addValue("string") - .build() - ) - .reason("reason") - .build() - ) .endDate( OffsetDateTime.parse( "2022-02-01T08:00:00+00:00" @@ -5802,42 +5478,6 @@ internal class SubscriptionChangeCancelResponseTest { ) .filter("filter") .grouping("grouping") - .maximum( - Maximum.builder() - .addAppliesToPriceId("string") - .addFilter( - Maximum.Filter.builder() - .field( - Maximum.Filter.Field.PRICE_ID - ) - .operator( - Maximum.Filter.Operator.INCLUDES - ) - .addValue("string") - .build() - ) - .maximumAmount("maximum_amount") - .build() - ) - .maximumAmount("maximum_amount") - .minimum( - Minimum.builder() - .addAppliesToPriceId("string") - .addFilter( - Minimum.Filter.builder() - .field( - Minimum.Filter.Field.PRICE_ID - ) - .operator( - Minimum.Filter.Operator.INCLUDES - ) - .addValue("string") - .build() - ) - .minimumAmount("minimum_amount") - .build() - ) - .minimumAmount("minimum_amount") .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeRetrieveResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeRetrieveResponseTest.kt index 40335e534..6d0c99ec2 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeRetrieveResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeRetrieveResponseTest.kt @@ -1029,32 +1029,6 @@ internal class SubscriptionChangeRetrieveResponseTest { ) .amount("7.00") .creditsApplied("6.00") - .discount( - PercentageDiscount.builder() - .discountType( - PercentageDiscount.DiscountType - .PERCENTAGE - ) - .percentageDiscount(0.15) - .addAppliesToPriceId("h74gfhdjvn7ujokd") - .addAppliesToPriceId("7hfgtgjnbvc3ujkl") - .addFilter( - PercentageDiscount.Filter.builder() - .field( - PercentageDiscount.Filter.Field - .PRICE_ID - ) - .operator( - PercentageDiscount.Filter - .Operator - .INCLUDES - ) - .addValue("string") - .build() - ) - .reason("reason") - .build() - ) .endDate( OffsetDateTime.parse( "2022-02-01T08:00:00+00:00" @@ -1062,42 +1036,6 @@ internal class SubscriptionChangeRetrieveResponseTest { ) .filter("filter") .grouping("grouping") - .maximum( - Maximum.builder() - .addAppliesToPriceId("string") - .addFilter( - Maximum.Filter.builder() - .field( - Maximum.Filter.Field.PRICE_ID - ) - .operator( - Maximum.Filter.Operator.INCLUDES - ) - .addValue("string") - .build() - ) - .maximumAmount("maximum_amount") - .build() - ) - .maximumAmount("maximum_amount") - .minimum( - Minimum.builder() - .addAppliesToPriceId("string") - .addFilter( - Minimum.Filter.builder() - .field( - Minimum.Filter.Field.PRICE_ID - ) - .operator( - Minimum.Filter.Operator.INCLUDES - ) - .addValue("string") - .build() - ) - .minimumAmount("minimum_amount") - .build() - ) - .minimumAmount("minimum_amount") .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( @@ -1705,32 +1643,6 @@ internal class SubscriptionChangeRetrieveResponseTest { ) .amount("7.00") .creditsApplied("6.00") - .discount( - PercentageDiscount.builder() - .discountType( - PercentageDiscount.DiscountType - .PERCENTAGE - ) - .percentageDiscount(0.15) - .addAppliesToPriceId("h74gfhdjvn7ujokd") - .addAppliesToPriceId("7hfgtgjnbvc3ujkl") - .addFilter( - PercentageDiscount.Filter.builder() - .field( - PercentageDiscount.Filter.Field - .PRICE_ID - ) - .operator( - PercentageDiscount.Filter - .Operator - .INCLUDES - ) - .addValue("string") - .build() - ) - .reason("reason") - .build() - ) .endDate( OffsetDateTime.parse( "2022-02-01T08:00:00+00:00" @@ -1738,42 +1650,6 @@ internal class SubscriptionChangeRetrieveResponseTest { ) .filter("filter") .grouping("grouping") - .maximum( - Maximum.builder() - .addAppliesToPriceId("string") - .addFilter( - Maximum.Filter.builder() - .field( - Maximum.Filter.Field.PRICE_ID - ) - .operator( - Maximum.Filter.Operator.INCLUDES - ) - .addValue("string") - .build() - ) - .maximumAmount("maximum_amount") - .build() - ) - .maximumAmount("maximum_amount") - .minimum( - Minimum.builder() - .addAppliesToPriceId("string") - .addFilter( - Minimum.Filter.builder() - .field( - Minimum.Filter.Field.PRICE_ID - ) - .operator( - Minimum.Filter.Operator.INCLUDES - ) - .addValue("string") - .build() - ) - .minimumAmount("minimum_amount") - .build() - ) - .minimumAmount("minimum_amount") .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( @@ -3063,67 +2939,11 @@ internal class SubscriptionChangeRetrieveResponseTest { ) .amount("7.00") .creditsApplied("6.00") - .discount( - PercentageDiscount.builder() - .discountType( - PercentageDiscount.DiscountType.PERCENTAGE - ) - .percentageDiscount(0.15) - .addAppliesToPriceId("h74gfhdjvn7ujokd") - .addAppliesToPriceId("7hfgtgjnbvc3ujkl") - .addFilter( - PercentageDiscount.Filter.builder() - .field( - PercentageDiscount.Filter.Field - .PRICE_ID - ) - .operator( - PercentageDiscount.Filter.Operator - .INCLUDES - ) - .addValue("string") - .build() - ) - .reason("reason") - .build() - ) .endDate( OffsetDateTime.parse("2022-02-01T08:00:00+00:00") ) .filter("filter") .grouping("grouping") - .maximum( - Maximum.builder() - .addAppliesToPriceId("string") - .addFilter( - Maximum.Filter.builder() - .field(Maximum.Filter.Field.PRICE_ID) - .operator( - Maximum.Filter.Operator.INCLUDES - ) - .addValue("string") - .build() - ) - .maximumAmount("maximum_amount") - .build() - ) - .maximumAmount("maximum_amount") - .minimum( - Minimum.builder() - .addAppliesToPriceId("string") - .addFilter( - Minimum.Filter.builder() - .field(Minimum.Filter.Field.PRICE_ID) - .operator( - Minimum.Filter.Operator.INCLUDES - ) - .addValue("string") - .build() - ) - .minimumAmount("minimum_amount") - .build() - ) - .minimumAmount("minimum_amount") .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( @@ -3688,67 +3508,11 @@ internal class SubscriptionChangeRetrieveResponseTest { ) .amount("7.00") .creditsApplied("6.00") - .discount( - PercentageDiscount.builder() - .discountType( - PercentageDiscount.DiscountType.PERCENTAGE - ) - .percentageDiscount(0.15) - .addAppliesToPriceId("h74gfhdjvn7ujokd") - .addAppliesToPriceId("7hfgtgjnbvc3ujkl") - .addFilter( - PercentageDiscount.Filter.builder() - .field( - PercentageDiscount.Filter.Field - .PRICE_ID - ) - .operator( - PercentageDiscount.Filter.Operator - .INCLUDES - ) - .addValue("string") - .build() - ) - .reason("reason") - .build() - ) .endDate( OffsetDateTime.parse("2022-02-01T08:00:00+00:00") ) .filter("filter") .grouping("grouping") - .maximum( - Maximum.builder() - .addAppliesToPriceId("string") - .addFilter( - Maximum.Filter.builder() - .field(Maximum.Filter.Field.PRICE_ID) - .operator( - Maximum.Filter.Operator.INCLUDES - ) - .addValue("string") - .build() - ) - .maximumAmount("maximum_amount") - .build() - ) - .maximumAmount("maximum_amount") - .minimum( - Minimum.builder() - .addAppliesToPriceId("string") - .addFilter( - Minimum.Filter.builder() - .field(Minimum.Filter.Field.PRICE_ID) - .operator( - Minimum.Filter.Operator.INCLUDES - ) - .addValue("string") - .build() - ) - .minimumAmount("minimum_amount") - .build() - ) - .minimumAmount("minimum_amount") .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( @@ -5093,32 +4857,6 @@ internal class SubscriptionChangeRetrieveResponseTest { ) .amount("7.00") .creditsApplied("6.00") - .discount( - PercentageDiscount.builder() - .discountType( - PercentageDiscount.DiscountType - .PERCENTAGE - ) - .percentageDiscount(0.15) - .addAppliesToPriceId("h74gfhdjvn7ujokd") - .addAppliesToPriceId("7hfgtgjnbvc3ujkl") - .addFilter( - PercentageDiscount.Filter.builder() - .field( - PercentageDiscount.Filter.Field - .PRICE_ID - ) - .operator( - PercentageDiscount.Filter - .Operator - .INCLUDES - ) - .addValue("string") - .build() - ) - .reason("reason") - .build() - ) .endDate( OffsetDateTime.parse( "2022-02-01T08:00:00+00:00" @@ -5126,42 +4864,6 @@ internal class SubscriptionChangeRetrieveResponseTest { ) .filter("filter") .grouping("grouping") - .maximum( - Maximum.builder() - .addAppliesToPriceId("string") - .addFilter( - Maximum.Filter.builder() - .field( - Maximum.Filter.Field.PRICE_ID - ) - .operator( - Maximum.Filter.Operator.INCLUDES - ) - .addValue("string") - .build() - ) - .maximumAmount("maximum_amount") - .build() - ) - .maximumAmount("maximum_amount") - .minimum( - Minimum.builder() - .addAppliesToPriceId("string") - .addFilter( - Minimum.Filter.builder() - .field( - Minimum.Filter.Field.PRICE_ID - ) - .operator( - Minimum.Filter.Operator.INCLUDES - ) - .addValue("string") - .build() - ) - .minimumAmount("minimum_amount") - .build() - ) - .minimumAmount("minimum_amount") .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( @@ -5769,32 +5471,6 @@ internal class SubscriptionChangeRetrieveResponseTest { ) .amount("7.00") .creditsApplied("6.00") - .discount( - PercentageDiscount.builder() - .discountType( - PercentageDiscount.DiscountType - .PERCENTAGE - ) - .percentageDiscount(0.15) - .addAppliesToPriceId("h74gfhdjvn7ujokd") - .addAppliesToPriceId("7hfgtgjnbvc3ujkl") - .addFilter( - PercentageDiscount.Filter.builder() - .field( - PercentageDiscount.Filter.Field - .PRICE_ID - ) - .operator( - PercentageDiscount.Filter - .Operator - .INCLUDES - ) - .addValue("string") - .build() - ) - .reason("reason") - .build() - ) .endDate( OffsetDateTime.parse( "2022-02-01T08:00:00+00:00" @@ -5802,42 +5478,6 @@ internal class SubscriptionChangeRetrieveResponseTest { ) .filter("filter") .grouping("grouping") - .maximum( - Maximum.builder() - .addAppliesToPriceId("string") - .addFilter( - Maximum.Filter.builder() - .field( - Maximum.Filter.Field.PRICE_ID - ) - .operator( - Maximum.Filter.Operator.INCLUDES - ) - .addValue("string") - .build() - ) - .maximumAmount("maximum_amount") - .build() - ) - .maximumAmount("maximum_amount") - .minimum( - Minimum.builder() - .addAppliesToPriceId("string") - .addFilter( - Minimum.Filter.builder() - .field( - Minimum.Filter.Field.PRICE_ID - ) - .operator( - Minimum.Filter.Operator.INCLUDES - ) - .addValue("string") - .build() - ) - .minimumAmount("minimum_amount") - .build() - ) - .minimumAmount("minimum_amount") .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( From af8a41f71ca341c4ca6362158c555810a217ec49 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Sun, 16 Nov 2025 02:27:22 +0000 Subject: [PATCH 50/68] feat(api): api update --- .stats.yml | 4 +- .../api/models/BetaCreatePlanVersionParams.kt | 10794 +++++++++----- ...taExternalPlanIdCreatePlanVersionParams.kt | 10794 +++++++++----- .../models/ChangedSubscriptionResources.kt | 7 + .../kotlin/com/withorb/api/models/Invoice.kt | 7 + .../models/InvoiceFetchUpcomingResponse.kt | 7 + .../models/InvoiceLineItemCreateResponse.kt | 7 + .../com/withorb/api/models/PerPriceCost.kt | 7 + .../kotlin/com/withorb/api/models/Plan.kt | 655 +- .../withorb/api/models/PlanCreateParams.kt | 1755 +++ .../com/withorb/api/models/PlanVersion.kt | 7 + .../kotlin/com/withorb/api/models/Price.kt | 3815 ++++- .../withorb/api/models/PriceCreateParams.kt | 1663 +++ .../api/models/PriceEvaluateMultipleParams.kt | 1705 +++ .../PriceEvaluatePreviewEventsParams.kt | 1705 +++ .../com/withorb/api/models/PriceInterval.kt | 7 + .../api/models/PriceListPageResponse.kt | 7 + .../api/models/SubscriptionCreateParams.kt | 11640 ++++++++++------ .../SubscriptionPriceIntervalsParams.kt | 1705 +++ .../SubscriptionSchedulePlanChangeParams.kt | 11346 +++++++++------ .../api/models/MutatedSubscriptionTest.kt | 48 +- .../api/models/PlanListPageResponseTest.kt | 48 +- .../kotlin/com/withorb/api/models/PlanTest.kt | 50 +- .../com/withorb/api/models/PriceTest.kt | 333 + .../SubscriptionChangeApplyResponseTest.kt | 48 +- .../SubscriptionChangeCancelResponseTest.kt | 48 +- .../SubscriptionChangeRetrieveResponseTest.kt | 48 +- .../withorb/api/models/SubscriptionTest.kt | 48 +- .../withorb/api/models/SubscriptionsTest.kt | 48 +- 29 files changed, 42129 insertions(+), 16227 deletions(-) diff --git a/.stats.yml b/.stats.yml index 107688d5a..30ac7b667 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 118 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-9e751a2aefff382af949380b5979a80cb02743eca1583cf5146325fb400ba87f.yml -openapi_spec_hash: 219a1008f47d3293f64f1baebe2d6eb5 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-947253d9be505473c1c2cb0193d2602fa6b017e221f482be3f4f374c6156b350.yml +openapi_spec_hash: 1b40d1a85b4b846a1c14634fbbc65da3 config_hash: e6db17547fe854b1c240407cf4c6dc9e diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BetaCreatePlanVersionParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BetaCreatePlanVersionParams.kt index 8d7025189..faf727254 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BetaCreatePlanVersionParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BetaCreatePlanVersionParams.kt @@ -1967,6 +1967,13 @@ private constructor( fun price(cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice) = price(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) + /** + * Alias for calling [price] with + * `Price.ofCumulativeGroupedAllocation(cumulativeGroupedAllocation)`. + */ + fun price(cumulativeGroupedAllocation: Price.CumulativeGroupedAllocation) = + price(Price.ofCumulativeGroupedAllocation(cumulativeGroupedAllocation)) + /** Alias for calling [price] with `Price.ofMinimum(minimum)`. */ fun price(minimum: NewPlanMinimumCompositePrice) = price(Price.ofMinimum(minimum)) @@ -2076,6 +2083,7 @@ private constructor( NewPlanScalableMatrixWithTieredPricingPrice? = null, private val cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice? = null, + private val cumulativeGroupedAllocation: CumulativeGroupedAllocation? = null, private val minimum: NewPlanMinimumCompositePrice? = null, private val percent: Percent? = null, private val eventOutput: EventOutput? = null, @@ -2142,6 +2150,9 @@ private constructor( fun cumulativeGroupedBulk(): NewPlanCumulativeGroupedBulkPrice? = cumulativeGroupedBulk + fun cumulativeGroupedAllocation(): CumulativeGroupedAllocation? = + cumulativeGroupedAllocation + fun minimum(): NewPlanMinimumCompositePrice? = minimum fun percent(): Percent? = percent @@ -2203,6 +2214,8 @@ private constructor( fun isCumulativeGroupedBulk(): Boolean = cumulativeGroupedBulk != null + fun isCumulativeGroupedAllocation(): Boolean = cumulativeGroupedAllocation != null + fun isMinimum(): Boolean = minimum != null fun isPercent(): Boolean = percent != null @@ -2284,6 +2297,9 @@ private constructor( fun asCumulativeGroupedBulk(): NewPlanCumulativeGroupedBulkPrice = cumulativeGroupedBulk.getOrThrow("cumulativeGroupedBulk") + fun asCumulativeGroupedAllocation(): CumulativeGroupedAllocation = + cumulativeGroupedAllocation.getOrThrow("cumulativeGroupedAllocation") + fun asMinimum(): NewPlanMinimumCompositePrice = minimum.getOrThrow("minimum") fun asPercent(): Percent = percent.getOrThrow("percent") @@ -2337,6 +2353,8 @@ private constructor( ) cumulativeGroupedBulk != null -> visitor.visitCumulativeGroupedBulk(cumulativeGroupedBulk) + cumulativeGroupedAllocation != null -> + visitor.visitCumulativeGroupedAllocation(cumulativeGroupedAllocation) minimum != null -> visitor.visitMinimum(minimum) percent != null -> visitor.visitPercent(percent) eventOutput != null -> visitor.visitEventOutput(eventOutput) @@ -2499,6 +2517,12 @@ private constructor( cumulativeGroupedBulk.validate() } + override fun visitCumulativeGroupedAllocation( + cumulativeGroupedAllocation: CumulativeGroupedAllocation + ) { + cumulativeGroupedAllocation.validate() + } + override fun visitMinimum(minimum: NewPlanMinimumCompositePrice) { minimum.validate() } @@ -2629,6 +2653,10 @@ private constructor( cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice ) = cumulativeGroupedBulk.validity() + override fun visitCumulativeGroupedAllocation( + cumulativeGroupedAllocation: CumulativeGroupedAllocation + ) = cumulativeGroupedAllocation.validity() + override fun visitMinimum(minimum: NewPlanMinimumCompositePrice) = minimum.validity() @@ -2674,6 +2702,7 @@ private constructor( scalableMatrixWithUnitPricing == other.scalableMatrixWithUnitPricing && scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && cumulativeGroupedBulk == other.cumulativeGroupedBulk && + cumulativeGroupedAllocation == other.cumulativeGroupedAllocation && minimum == other.minimum && percent == other.percent && eventOutput == other.eventOutput @@ -2708,6 +2737,7 @@ private constructor( scalableMatrixWithUnitPricing, scalableMatrixWithTieredPricing, cumulativeGroupedBulk, + cumulativeGroupedAllocation, minimum, percent, eventOutput, @@ -2755,6 +2785,8 @@ private constructor( "Price{scalableMatrixWithTieredPricing=$scalableMatrixWithTieredPricing}" cumulativeGroupedBulk != null -> "Price{cumulativeGroupedBulk=$cumulativeGroupedBulk}" + cumulativeGroupedAllocation != null -> + "Price{cumulativeGroupedAllocation=$cumulativeGroupedAllocation}" minimum != null -> "Price{minimum=$minimum}" percent != null -> "Price{percent=$percent}" eventOutput != null -> "Price{eventOutput=$eventOutput}" @@ -2850,6 +2882,10 @@ private constructor( cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice ) = Price(cumulativeGroupedBulk = cumulativeGroupedBulk) + fun ofCumulativeGroupedAllocation( + cumulativeGroupedAllocation: CumulativeGroupedAllocation + ) = Price(cumulativeGroupedAllocation = cumulativeGroupedAllocation) + fun ofMinimum(minimum: NewPlanMinimumCompositePrice) = Price(minimum = minimum) fun ofPercent(percent: Percent) = Price(percent = percent) @@ -2942,6 +2978,10 @@ private constructor( cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice ): T + fun visitCumulativeGroupedAllocation( + cumulativeGroupedAllocation: CumulativeGroupedAllocation + ): T + fun visitMinimum(minimum: NewPlanMinimumCompositePrice): T fun visitPercent(percent: Percent): T @@ -3158,6 +3198,14 @@ private constructor( ?.let { Price(cumulativeGroupedBulk = it, _json = json) } ?: Price(_json = json) } + "cumulative_grouped_allocation" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(cumulativeGroupedAllocation = it, _json = json) } + ?: Price(_json = json) + } "minimum" -> { return tryDeserialize( node, @@ -3236,6 +3284,8 @@ private constructor( generator.writeObject(value.scalableMatrixWithTieredPricing) value.cumulativeGroupedBulk != null -> generator.writeObject(value.cumulativeGroupedBulk) + value.cumulativeGroupedAllocation != null -> + generator.writeObject(value.cumulativeGroupedAllocation) value.minimum != null -> generator.writeObject(value.minimum) value.percent != null -> generator.writeObject(value.percent) value.eventOutput != null -> generator.writeObject(value.eventOutput) @@ -8747,14 +8797,15 @@ private constructor( "GroupedWithMinMaxThresholds{cadence=$cadence, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class Percent + class CumulativeGroupedAllocation @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, + private val cumulativeGroupedAllocationConfig: + JsonField, private val itemId: JsonField, private val modelType: JsonValue, private val name: JsonField, - private val percentConfig: JsonField, private val billableMetricId: JsonField, private val billedInAdvance: JsonField, private val billingCycleConfiguration: JsonField, @@ -8777,6 +8828,11 @@ private constructor( @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), + @JsonProperty("cumulative_grouped_allocation_config") + @ExcludeMissing + cumulativeGroupedAllocationConfig: + JsonField = + JsonMissing.of(), @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), @@ -8786,9 +8842,6 @@ private constructor( @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("percent_config") - @ExcludeMissing - percentConfig: JsonField = JsonMissing.of(), @JsonProperty("billable_metric_id") @ExcludeMissing billableMetricId: JsonField = JsonMissing.of(), @@ -8833,10 +8886,10 @@ private constructor( referenceId: JsonField = JsonMissing.of(), ) : this( cadence, + cumulativeGroupedAllocationConfig, itemId, modelType, name, - percentConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -8862,6 +8915,18 @@ private constructor( */ fun cadence(): Cadence = cadence.getRequired("cadence") + /** + * Configuration for cumulative_grouped_allocation pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cumulativeGroupedAllocationConfig(): CumulativeGroupedAllocationConfig = + cumulativeGroupedAllocationConfig.getRequired( + "cumulative_grouped_allocation_config" + ) + /** * The id of the item the price will be associated with. * @@ -8876,7 +8941,7 @@ private constructor( * * Expected to always return the following: * ```kotlin - * JsonValue.from("percent") + * JsonValue.from("cumulative_grouped_allocation") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -8893,15 +8958,6 @@ private constructor( */ fun name(): String = name.getRequired("name") - /** - * Configuration for percent pricing - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun percentConfig(): PercentConfig = percentConfig.getRequired("percent_config") - /** * The id of the billable metric for the price. Only needed if the price is * usage-based. @@ -9031,6 +9087,17 @@ private constructor( @ExcludeMissing fun _cadence(): JsonField = cadence + /** + * Returns the raw JSON value of [cumulativeGroupedAllocationConfig]. + * + * Unlike [cumulativeGroupedAllocationConfig], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("cumulative_grouped_allocation_config") + @ExcludeMissing + fun _cumulativeGroupedAllocationConfig(): + JsonField = cumulativeGroupedAllocationConfig + /** * Returns the raw JSON value of [itemId]. * @@ -9047,16 +9114,6 @@ private constructor( */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - /** - * Returns the raw JSON value of [percentConfig]. - * - * Unlike [percentConfig], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("percent_config") - @ExcludeMissing - fun _percentConfig(): JsonField = percentConfig - /** * Returns the raw JSON value of [billableMetricId]. * @@ -9205,27 +9262,31 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [Percent]. + * Returns a mutable builder for constructing an instance of + * [CumulativeGroupedAllocation]. * * The following fields are required: * ```kotlin * .cadence() + * .cumulativeGroupedAllocationConfig() * .itemId() * .name() - * .percentConfig() * ``` */ fun builder() = Builder() } - /** A builder for [Percent]. */ + /** A builder for [CumulativeGroupedAllocation]. */ class Builder internal constructor() { private var cadence: JsonField? = null + private var cumulativeGroupedAllocationConfig: + JsonField? = + null private var itemId: JsonField? = null - private var modelType: JsonValue = JsonValue.from("percent") + private var modelType: JsonValue = + JsonValue.from("cumulative_grouped_allocation") private var name: JsonField? = null - private var percentConfig: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() private var billingCycleConfiguration: JsonField = @@ -9247,27 +9308,33 @@ private constructor( private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(percent: Percent) = apply { - cadence = percent.cadence - itemId = percent.itemId - modelType = percent.modelType - name = percent.name - percentConfig = percent.percentConfig - billableMetricId = percent.billableMetricId - billedInAdvance = percent.billedInAdvance - billingCycleConfiguration = percent.billingCycleConfiguration - conversionRate = percent.conversionRate - conversionRateConfig = percent.conversionRateConfig - currency = percent.currency - dimensionalPriceConfiguration = percent.dimensionalPriceConfiguration - externalPriceId = percent.externalPriceId - fixedPriceQuantity = percent.fixedPriceQuantity - invoiceGroupingKey = percent.invoiceGroupingKey - invoicingCycleConfiguration = percent.invoicingCycleConfiguration - metadata = percent.metadata - referenceId = percent.referenceId - additionalProperties = percent.additionalProperties.toMutableMap() - } + internal fun from(cumulativeGroupedAllocation: CumulativeGroupedAllocation) = + apply { + cadence = cumulativeGroupedAllocation.cadence + cumulativeGroupedAllocationConfig = + cumulativeGroupedAllocation.cumulativeGroupedAllocationConfig + itemId = cumulativeGroupedAllocation.itemId + modelType = cumulativeGroupedAllocation.modelType + name = cumulativeGroupedAllocation.name + billableMetricId = cumulativeGroupedAllocation.billableMetricId + billedInAdvance = cumulativeGroupedAllocation.billedInAdvance + billingCycleConfiguration = + cumulativeGroupedAllocation.billingCycleConfiguration + conversionRate = cumulativeGroupedAllocation.conversionRate + conversionRateConfig = cumulativeGroupedAllocation.conversionRateConfig + currency = cumulativeGroupedAllocation.currency + dimensionalPriceConfiguration = + cumulativeGroupedAllocation.dimensionalPriceConfiguration + externalPriceId = cumulativeGroupedAllocation.externalPriceId + fixedPriceQuantity = cumulativeGroupedAllocation.fixedPriceQuantity + invoiceGroupingKey = cumulativeGroupedAllocation.invoiceGroupingKey + invoicingCycleConfiguration = + cumulativeGroupedAllocation.invoicingCycleConfiguration + metadata = cumulativeGroupedAllocation.metadata + referenceId = cumulativeGroupedAllocation.referenceId + additionalProperties = + cumulativeGroupedAllocation.additionalProperties.toMutableMap() + } /** The cadence to bill for this price on. */ fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) @@ -9281,6 +9348,29 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + /** Configuration for cumulative_grouped_allocation pricing */ + fun cumulativeGroupedAllocationConfig( + cumulativeGroupedAllocationConfig: CumulativeGroupedAllocationConfig + ) = + cumulativeGroupedAllocationConfig( + JsonField.of(cumulativeGroupedAllocationConfig) + ) + + /** + * Sets [Builder.cumulativeGroupedAllocationConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.cumulativeGroupedAllocationConfig] with a + * well-typed [CumulativeGroupedAllocationConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun cumulativeGroupedAllocationConfig( + cumulativeGroupedAllocationConfig: + JsonField + ) = apply { + this.cumulativeGroupedAllocationConfig = cumulativeGroupedAllocationConfig + } + /** The id of the item the price will be associated with. */ fun itemId(itemId: String) = itemId(JsonField.of(itemId)) @@ -9299,7 +9389,7 @@ private constructor( * It is usually unnecessary to call this method because the field defaults to * the following: * ```kotlin - * JsonValue.from("percent") + * JsonValue.from("cumulative_grouped_allocation") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -9319,21 +9409,6 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } - /** Configuration for percent pricing */ - fun percentConfig(percentConfig: PercentConfig) = - percentConfig(JsonField.of(percentConfig)) - - /** - * Sets [Builder.percentConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.percentConfig] with a well-typed - * [PercentConfig] value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. - */ - fun percentConfig(percentConfig: JsonField) = apply { - this.percentConfig = percentConfig - } - /** * The id of the billable metric for the price. Only needed if the price is * usage-based. @@ -9663,27 +9738,30 @@ private constructor( } /** - * Returns an immutable instance of [Percent]. + * Returns an immutable instance of [CumulativeGroupedAllocation]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```kotlin * .cadence() + * .cumulativeGroupedAllocationConfig() * .itemId() * .name() - * .percentConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): Percent = - Percent( + fun build(): CumulativeGroupedAllocation = + CumulativeGroupedAllocation( checkRequired("cadence", cadence), + checkRequired( + "cumulativeGroupedAllocationConfig", + cumulativeGroupedAllocationConfig, + ), checkRequired("itemId", itemId), modelType, checkRequired("name", name), - checkRequired("percentConfig", percentConfig), billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -9703,20 +9781,20 @@ private constructor( private var validated: Boolean = false - fun validate(): Percent = apply { + fun validate(): CumulativeGroupedAllocation = apply { if (validated) { return@apply } cadence().validate() + cumulativeGroupedAllocationConfig().validate() itemId() _modelType().let { - if (it != JsonValue.from("percent")) { + if (it != JsonValue.from("cumulative_grouped_allocation")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } name() - percentConfig().validate() billableMetricId() billedInAdvance() billingCycleConfiguration()?.validate() @@ -9749,10 +9827,12 @@ private constructor( */ internal fun validity(): Int = (cadence.asKnown()?.validity() ?: 0) + + (cumulativeGroupedAllocationConfig.asKnown()?.validity() ?: 0) + (if (itemId.asKnown() == null) 0 else 1) + - modelType.let { if (it == JsonValue.from("percent")) 1 else 0 } + + modelType.let { + if (it == JsonValue.from("cumulative_grouped_allocation")) 1 else 0 + } + (if (name.asKnown() == null) 0 else 1) + - (percentConfig.asKnown()?.validity() ?: 0) + (if (billableMetricId.asKnown() == null) 0 else 1) + (if (billedInAdvance.asKnown() == null) 0 else 1) + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + @@ -9924,39 +10004,115 @@ private constructor( override fun toString() = value.toString() } - /** Configuration for percent pricing */ - class PercentConfig + /** Configuration for cumulative_grouped_allocation pricing */ + class CumulativeGroupedAllocationConfig @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val percent: JsonField, + private val cumulativeAllocation: JsonField, + private val groupAllocation: JsonField, + private val groupingKey: JsonField, + private val unitAmount: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("percent") + @JsonProperty("cumulative_allocation") @ExcludeMissing - percent: JsonField = JsonMissing.of() - ) : this(percent, mutableMapOf()) + cumulativeAllocation: JsonField = JsonMissing.of(), + @JsonProperty("group_allocation") + @ExcludeMissing + groupAllocation: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this( + cumulativeAllocation, + groupAllocation, + groupingKey, + unitAmount, + mutableMapOf(), + ) /** - * What percent of the component subtotals to charge + * The overall allocation across all groups * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). */ - fun percent(): Double = percent.getRequired("percent") + fun cumulativeAllocation(): String = + cumulativeAllocation.getRequired("cumulative_allocation") /** - * Returns the raw JSON value of [percent]. + * The allocation per individual group * - * Unlike [percent], this method doesn't throw if the JSON field has an + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun groupAllocation(): String = groupAllocation.getRequired("group_allocation") + + /** + * The event property used to group usage before applying allocations + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The amount to charge for each unit outside of the allocation + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [cumulativeAllocation]. + * + * Unlike [cumulativeAllocation], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("cumulative_allocation") + @ExcludeMissing + fun _cumulativeAllocation(): JsonField = cumulativeAllocation + + /** + * Returns the raw JSON value of [groupAllocation]. + * + * Unlike [groupAllocation], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("percent") + @JsonProperty("group_allocation") @ExcludeMissing - fun _percent(): JsonField = percent + fun _groupAllocation(): JsonField = groupAllocation + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -9974,39 +10130,100 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [PercentConfig]. + * [CumulativeGroupedAllocationConfig]. * * The following fields are required: * ```kotlin - * .percent() + * .cumulativeAllocation() + * .groupAllocation() + * .groupingKey() + * .unitAmount() * ``` */ fun builder() = Builder() } - /** A builder for [PercentConfig]. */ + /** A builder for [CumulativeGroupedAllocationConfig]. */ class Builder internal constructor() { - private var percent: JsonField? = null + private var cumulativeAllocation: JsonField? = null + private var groupAllocation: JsonField? = null + private var groupingKey: JsonField? = null + private var unitAmount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(percentConfig: PercentConfig) = apply { - percent = percentConfig.percent - additionalProperties = percentConfig.additionalProperties.toMutableMap() + internal fun from( + cumulativeGroupedAllocationConfig: CumulativeGroupedAllocationConfig + ) = apply { + cumulativeAllocation = + cumulativeGroupedAllocationConfig.cumulativeAllocation + groupAllocation = cumulativeGroupedAllocationConfig.groupAllocation + groupingKey = cumulativeGroupedAllocationConfig.groupingKey + unitAmount = cumulativeGroupedAllocationConfig.unitAmount + additionalProperties = + cumulativeGroupedAllocationConfig.additionalProperties + .toMutableMap() } - /** What percent of the component subtotals to charge */ - fun percent(percent: Double) = percent(JsonField.of(percent)) + /** The overall allocation across all groups */ + fun cumulativeAllocation(cumulativeAllocation: String) = + cumulativeAllocation(JsonField.of(cumulativeAllocation)) /** - * Sets [Builder.percent] to an arbitrary JSON value. + * Sets [Builder.cumulativeAllocation] to an arbitrary JSON value. * - * You should usually call [Builder.percent] with a well-typed [Double] + * You should usually call [Builder.cumulativeAllocation] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun cumulativeAllocation(cumulativeAllocation: JsonField) = apply { + this.cumulativeAllocation = cumulativeAllocation + } + + /** The allocation per individual group */ + fun groupAllocation(groupAllocation: String) = + groupAllocation(JsonField.of(groupAllocation)) + + /** + * Sets [Builder.groupAllocation] to an arbitrary JSON value. + * + * You should usually call [Builder.groupAllocation] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun groupAllocation(groupAllocation: JsonField) = apply { + this.groupAllocation = groupAllocation + } + + /** The event property used to group usage before applying allocations */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] * value instead. This method is primarily for setting the field to an * undocumented or not yet supported value. */ - fun percent(percent: JsonField) = apply { this.percent = percent } + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The amount to charge for each unit outside of the allocation */ + fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } fun additionalProperties(additionalProperties: Map) = apply { @@ -10031,32 +10248,41 @@ private constructor( } /** - * Returns an immutable instance of [PercentConfig]. + * Returns an immutable instance of [CumulativeGroupedAllocationConfig]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```kotlin - * .percent() + * .cumulativeAllocation() + * .groupAllocation() + * .groupingKey() + * .unitAmount() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): PercentConfig = - PercentConfig( - checkRequired("percent", percent), + fun build(): CumulativeGroupedAllocationConfig = + CumulativeGroupedAllocationConfig( + checkRequired("cumulativeAllocation", cumulativeAllocation), + checkRequired("groupAllocation", groupAllocation), + checkRequired("groupingKey", groupingKey), + checkRequired("unitAmount", unitAmount), additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): PercentConfig = apply { + fun validate(): CumulativeGroupedAllocationConfig = apply { if (validated) { return@apply } - percent() + cumulativeAllocation() + groupAllocation() + groupingKey() + unitAmount() validated = true } @@ -10074,26 +10300,39 @@ private constructor( * * Used for best match union deserialization. */ - internal fun validity(): Int = (if (percent.asKnown() == null) 0 else 1) + internal fun validity(): Int = + (if (cumulativeAllocation.asKnown() == null) 0 else 1) + + (if (groupAllocation.asKnown() == null) 0 else 1) + + (if (groupingKey.asKnown() == null) 0 else 1) + + (if (unitAmount.asKnown() == null) 0 else 1) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is PercentConfig && - percent == other.percent && + return other is CumulativeGroupedAllocationConfig && + cumulativeAllocation == other.cumulativeAllocation && + groupAllocation == other.groupAllocation && + groupingKey == other.groupingKey && + unitAmount == other.unitAmount && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(percent, additionalProperties) + Objects.hash( + cumulativeAllocation, + groupAllocation, + groupingKey, + unitAmount, + additionalProperties, + ) } override fun hashCode(): Int = hashCode override fun toString() = - "PercentConfig{percent=$percent, additionalProperties=$additionalProperties}" + "CumulativeGroupedAllocationConfig{cumulativeAllocation=$cumulativeAllocation, groupAllocation=$groupAllocation, groupingKey=$groupingKey, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" } /** @@ -10210,12 +10449,13 @@ private constructor( return true } - return other is Percent && + return other is CumulativeGroupedAllocation && cadence == other.cadence && + cumulativeGroupedAllocationConfig == + other.cumulativeGroupedAllocationConfig && itemId == other.itemId && modelType == other.modelType && name == other.name && - percentConfig == other.percentConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && @@ -10235,10 +10475,10 @@ private constructor( private val hashCode: Int by lazy { Objects.hash( cadence, + cumulativeGroupedAllocationConfig, itemId, modelType, name, - percentConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -10259,17 +10499,17 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Percent{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, percentConfig=$percentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "CumulativeGroupedAllocation{cadence=$cadence, cumulativeGroupedAllocationConfig=$cumulativeGroupedAllocationConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class EventOutput + class Percent @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, - private val eventOutputConfig: JsonField, private val itemId: JsonField, private val modelType: JsonValue, private val name: JsonField, + private val percentConfig: JsonField, private val billableMetricId: JsonField, private val billedInAdvance: JsonField, private val billingCycleConfiguration: JsonField, @@ -10292,9 +10532,6 @@ private constructor( @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), - @JsonProperty("event_output_config") - @ExcludeMissing - eventOutputConfig: JsonField = JsonMissing.of(), @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), @@ -10304,6 +10541,9 @@ private constructor( @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("percent_config") + @ExcludeMissing + percentConfig: JsonField = JsonMissing.of(), @JsonProperty("billable_metric_id") @ExcludeMissing billableMetricId: JsonField = JsonMissing.of(), @@ -10348,10 +10588,10 @@ private constructor( referenceId: JsonField = JsonMissing.of(), ) : this( cadence, - eventOutputConfig, itemId, modelType, name, + percentConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -10377,16 +10617,6 @@ private constructor( */ fun cadence(): Cadence = cadence.getRequired("cadence") - /** - * Configuration for event_output pricing - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun eventOutputConfig(): EventOutputConfig = - eventOutputConfig.getRequired("event_output_config") - /** * The id of the item the price will be associated with. * @@ -10401,7 +10631,7 @@ private constructor( * * Expected to always return the following: * ```kotlin - * JsonValue.from("event_output") + * JsonValue.from("percent") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -10418,6 +10648,15 @@ private constructor( */ fun name(): String = name.getRequired("name") + /** + * Configuration for percent pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun percentConfig(): PercentConfig = percentConfig.getRequired("percent_config") + /** * The id of the billable metric for the price. Only needed if the price is * usage-based. @@ -10547,16 +10786,6 @@ private constructor( @ExcludeMissing fun _cadence(): JsonField = cadence - /** - * Returns the raw JSON value of [eventOutputConfig]. - * - * Unlike [eventOutputConfig], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("event_output_config") - @ExcludeMissing - fun _eventOutputConfig(): JsonField = eventOutputConfig - /** * Returns the raw JSON value of [itemId]. * @@ -10573,6 +10802,16 @@ private constructor( */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + /** + * Returns the raw JSON value of [percentConfig]. + * + * Unlike [percentConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("percent_config") + @ExcludeMissing + fun _percentConfig(): JsonField = percentConfig + /** * Returns the raw JSON value of [billableMetricId]. * @@ -10721,27 +10960,27 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [EventOutput]. + * Returns a mutable builder for constructing an instance of [Percent]. * * The following fields are required: * ```kotlin * .cadence() - * .eventOutputConfig() * .itemId() * .name() + * .percentConfig() * ``` */ fun builder() = Builder() } - /** A builder for [EventOutput]. */ + /** A builder for [Percent]. */ class Builder internal constructor() { private var cadence: JsonField? = null - private var eventOutputConfig: JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonValue = JsonValue.from("event_output") + private var modelType: JsonValue = JsonValue.from("percent") private var name: JsonField? = null + private var percentConfig: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() private var billingCycleConfiguration: JsonField = @@ -10763,26 +11002,26 @@ private constructor( private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(eventOutput: EventOutput) = apply { - cadence = eventOutput.cadence - eventOutputConfig = eventOutput.eventOutputConfig - itemId = eventOutput.itemId - modelType = eventOutput.modelType - name = eventOutput.name - billableMetricId = eventOutput.billableMetricId - billedInAdvance = eventOutput.billedInAdvance - billingCycleConfiguration = eventOutput.billingCycleConfiguration - conversionRate = eventOutput.conversionRate - conversionRateConfig = eventOutput.conversionRateConfig - currency = eventOutput.currency - dimensionalPriceConfiguration = eventOutput.dimensionalPriceConfiguration - externalPriceId = eventOutput.externalPriceId - fixedPriceQuantity = eventOutput.fixedPriceQuantity - invoiceGroupingKey = eventOutput.invoiceGroupingKey - invoicingCycleConfiguration = eventOutput.invoicingCycleConfiguration - metadata = eventOutput.metadata - referenceId = eventOutput.referenceId - additionalProperties = eventOutput.additionalProperties.toMutableMap() + internal fun from(percent: Percent) = apply { + cadence = percent.cadence + itemId = percent.itemId + modelType = percent.modelType + name = percent.name + percentConfig = percent.percentConfig + billableMetricId = percent.billableMetricId + billedInAdvance = percent.billedInAdvance + billingCycleConfiguration = percent.billingCycleConfiguration + conversionRate = percent.conversionRate + conversionRateConfig = percent.conversionRateConfig + currency = percent.currency + dimensionalPriceConfiguration = percent.dimensionalPriceConfiguration + externalPriceId = percent.externalPriceId + fixedPriceQuantity = percent.fixedPriceQuantity + invoiceGroupingKey = percent.invoiceGroupingKey + invoicingCycleConfiguration = percent.invoicingCycleConfiguration + metadata = percent.metadata + referenceId = percent.referenceId + additionalProperties = percent.additionalProperties.toMutableMap() } /** The cadence to bill for this price on. */ @@ -10797,21 +11036,6 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - /** Configuration for event_output pricing */ - fun eventOutputConfig(eventOutputConfig: EventOutputConfig) = - eventOutputConfig(JsonField.of(eventOutputConfig)) - - /** - * Sets [Builder.eventOutputConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.eventOutputConfig] with a well-typed - * [EventOutputConfig] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun eventOutputConfig(eventOutputConfig: JsonField) = apply { - this.eventOutputConfig = eventOutputConfig - } - /** The id of the item the price will be associated with. */ fun itemId(itemId: String) = itemId(JsonField.of(itemId)) @@ -10830,7 +11054,7 @@ private constructor( * It is usually unnecessary to call this method because the field defaults to * the following: * ```kotlin - * JsonValue.from("event_output") + * JsonValue.from("percent") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -10850,6 +11074,21 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } + /** Configuration for percent pricing */ + fun percentConfig(percentConfig: PercentConfig) = + percentConfig(JsonField.of(percentConfig)) + + /** + * Sets [Builder.percentConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.percentConfig] with a well-typed + * [PercentConfig] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun percentConfig(percentConfig: JsonField) = apply { + this.percentConfig = percentConfig + } + /** * The id of the billable metric for the price. Only needed if the price is * usage-based. @@ -11179,27 +11418,27 @@ private constructor( } /** - * Returns an immutable instance of [EventOutput]. + * Returns an immutable instance of [Percent]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```kotlin * .cadence() - * .eventOutputConfig() * .itemId() * .name() + * .percentConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): EventOutput = - EventOutput( + fun build(): Percent = + Percent( checkRequired("cadence", cadence), - checkRequired("eventOutputConfig", eventOutputConfig), checkRequired("itemId", itemId), modelType, checkRequired("name", name), + checkRequired("percentConfig", percentConfig), billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -11219,20 +11458,20 @@ private constructor( private var validated: Boolean = false - fun validate(): EventOutput = apply { + fun validate(): Percent = apply { if (validated) { return@apply } cadence().validate() - eventOutputConfig().validate() itemId() _modelType().let { - if (it != JsonValue.from("event_output")) { + if (it != JsonValue.from("percent")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } name() + percentConfig().validate() billableMetricId() billedInAdvance() billingCycleConfiguration()?.validate() @@ -11265,10 +11504,10 @@ private constructor( */ internal fun validity(): Int = (cadence.asKnown()?.validity() ?: 0) + - (eventOutputConfig.asKnown()?.validity() ?: 0) + (if (itemId.asKnown() == null) 0 else 1) + - modelType.let { if (it == JsonValue.from("event_output")) 1 else 0 } + + modelType.let { if (it == JsonValue.from("percent")) 1 else 0 } + (if (name.asKnown() == null) 0 else 1) + + (percentConfig.asKnown()?.validity() ?: 0) + (if (billableMetricId.asKnown() == null) 0 else 1) + (if (billedInAdvance.asKnown() == null) 0 else 1) + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + @@ -11440,87 +11679,39 @@ private constructor( override fun toString() = value.toString() } - /** Configuration for event_output pricing */ - class EventOutputConfig + /** Configuration for percent pricing */ + class PercentConfig @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val unitRatingKey: JsonField, - private val defaultUnitRate: JsonField, - private val groupingKey: JsonField, + private val percent: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("unit_rating_key") - @ExcludeMissing - unitRatingKey: JsonField = JsonMissing.of(), - @JsonProperty("default_unit_rate") - @ExcludeMissing - defaultUnitRate: JsonField = JsonMissing.of(), - @JsonProperty("grouping_key") + @JsonProperty("percent") @ExcludeMissing - groupingKey: JsonField = JsonMissing.of(), - ) : this(unitRatingKey, defaultUnitRate, groupingKey, mutableMapOf()) + percent: JsonField = JsonMissing.of() + ) : this(percent, mutableMapOf()) /** - * The key in the event data to extract the unit rate from. + * What percent of the component subtotals to charge * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). */ - fun unitRatingKey(): String = unitRatingKey.getRequired("unit_rating_key") - - /** - * If provided, this amount will be used as the unit rate when an event does not - * have a value for the `unit_rating_key`. If not provided, events missing a - * unit rate will be ignored. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun defaultUnitRate(): String? = - defaultUnitRate.getNullable("default_unit_rate") - - /** - * An optional key in the event data to group by (e.g., event ID). All events - * will also be grouped by their unit rate. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun groupingKey(): String? = groupingKey.getNullable("grouping_key") - - /** - * Returns the raw JSON value of [unitRatingKey]. - * - * Unlike [unitRatingKey], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("unit_rating_key") - @ExcludeMissing - fun _unitRatingKey(): JsonField = unitRatingKey - - /** - * Returns the raw JSON value of [defaultUnitRate]. - * - * Unlike [defaultUnitRate], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("default_unit_rate") - @ExcludeMissing - fun _defaultUnitRate(): JsonField = defaultUnitRate + fun percent(): Double = percent.getRequired("percent") /** - * Returns the raw JSON value of [groupingKey]. + * Returns the raw JSON value of [percent]. * - * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * Unlike [percent], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("grouping_key") + @JsonProperty("percent") @ExcludeMissing - fun _groupingKey(): JsonField = groupingKey + fun _percent(): JsonField = percent @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -11538,84 +11729,39 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [EventOutputConfig]. + * [PercentConfig]. * * The following fields are required: * ```kotlin - * .unitRatingKey() + * .percent() * ``` */ fun builder() = Builder() } - /** A builder for [EventOutputConfig]. */ + /** A builder for [PercentConfig]. */ class Builder internal constructor() { - private var unitRatingKey: JsonField? = null - private var defaultUnitRate: JsonField = JsonMissing.of() - private var groupingKey: JsonField = JsonMissing.of() + private var percent: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(eventOutputConfig: EventOutputConfig) = apply { - unitRatingKey = eventOutputConfig.unitRatingKey - defaultUnitRate = eventOutputConfig.defaultUnitRate - groupingKey = eventOutputConfig.groupingKey - additionalProperties = - eventOutputConfig.additionalProperties.toMutableMap() - } - - /** The key in the event data to extract the unit rate from. */ - fun unitRatingKey(unitRatingKey: String) = - unitRatingKey(JsonField.of(unitRatingKey)) - - /** - * Sets [Builder.unitRatingKey] to an arbitrary JSON value. - * - * You should usually call [Builder.unitRatingKey] with a well-typed - * [String] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun unitRatingKey(unitRatingKey: JsonField) = apply { - this.unitRatingKey = unitRatingKey - } - - /** - * If provided, this amount will be used as the unit rate when an event does - * not have a value for the `unit_rating_key`. If not provided, events - * missing a unit rate will be ignored. - */ - fun defaultUnitRate(defaultUnitRate: String?) = - defaultUnitRate(JsonField.ofNullable(defaultUnitRate)) - - /** - * Sets [Builder.defaultUnitRate] to an arbitrary JSON value. - * - * You should usually call [Builder.defaultUnitRate] with a well-typed - * [String] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun defaultUnitRate(defaultUnitRate: JsonField) = apply { - this.defaultUnitRate = defaultUnitRate + internal fun from(percentConfig: PercentConfig) = apply { + percent = percentConfig.percent + additionalProperties = percentConfig.additionalProperties.toMutableMap() } - /** - * An optional key in the event data to group by (e.g., event ID). All - * events will also be grouped by their unit rate. - */ - fun groupingKey(groupingKey: String?) = - groupingKey(JsonField.ofNullable(groupingKey)) + /** What percent of the component subtotals to charge */ + fun percent(percent: Double) = percent(JsonField.of(percent)) /** - * Sets [Builder.groupingKey] to an arbitrary JSON value. + * Sets [Builder.percent] to an arbitrary JSON value. * - * You should usually call [Builder.groupingKey] with a well-typed [String] + * You should usually call [Builder.percent] with a well-typed [Double] * value instead. This method is primarily for setting the field to an * undocumented or not yet supported value. */ - fun groupingKey(groupingKey: JsonField) = apply { - this.groupingKey = groupingKey - } + fun percent(percent: JsonField) = apply { this.percent = percent } fun additionalProperties(additionalProperties: Map) = apply { @@ -11640,36 +11786,32 @@ private constructor( } /** - * Returns an immutable instance of [EventOutputConfig]. + * Returns an immutable instance of [PercentConfig]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```kotlin - * .unitRatingKey() + * .percent() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): EventOutputConfig = - EventOutputConfig( - checkRequired("unitRatingKey", unitRatingKey), - defaultUnitRate, - groupingKey, + fun build(): PercentConfig = + PercentConfig( + checkRequired("percent", percent), additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): EventOutputConfig = apply { + fun validate(): PercentConfig = apply { if (validated) { return@apply } - unitRatingKey() - defaultUnitRate() - groupingKey() + percent() validated = true } @@ -11687,36 +11829,26 @@ private constructor( * * Used for best match union deserialization. */ - internal fun validity(): Int = - (if (unitRatingKey.asKnown() == null) 0 else 1) + - (if (defaultUnitRate.asKnown() == null) 0 else 1) + - (if (groupingKey.asKnown() == null) 0 else 1) + internal fun validity(): Int = (if (percent.asKnown() == null) 0 else 1) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is EventOutputConfig && - unitRatingKey == other.unitRatingKey && - defaultUnitRate == other.defaultUnitRate && - groupingKey == other.groupingKey && + return other is PercentConfig && + percent == other.percent && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash( - unitRatingKey, - defaultUnitRate, - groupingKey, - additionalProperties, - ) + Objects.hash(percent, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "EventOutputConfig{unitRatingKey=$unitRatingKey, defaultUnitRate=$defaultUnitRate, groupingKey=$groupingKey, additionalProperties=$additionalProperties}" + "PercentConfig{percent=$percent, additionalProperties=$additionalProperties}" } /** @@ -11833,12 +11965,12 @@ private constructor( return true } - return other is EventOutput && + return other is Percent && cadence == other.cadence && - eventOutputConfig == other.eventOutputConfig && itemId == other.itemId && modelType == other.modelType && name == other.name && + percentConfig == other.percentConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && @@ -11858,10 +11990,10 @@ private constructor( private val hashCode: Int by lazy { Objects.hash( cadence, - eventOutputConfig, itemId, modelType, name, + percentConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -11882,1051 +12014,1630 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "EventOutput{cadence=$cadence, eventOutputConfig=$eventOutputConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "Percent{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, percentConfig=$percentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + class EventOutput + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val eventOutputConfig: JsonField, + private val itemId: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { - return other is AddPrice && - allocationPrice == other.allocationPrice && - planPhaseOrder == other.planPhaseOrder && - price == other.price && - additionalProperties == other.additionalProperties - } + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("event_output_config") + @ExcludeMissing + eventOutputConfig: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + eventOutputConfig, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + mutableMapOf(), + ) - private val hashCode: Int by lazy { - Objects.hash(allocationPrice, planPhaseOrder, price, additionalProperties) - } + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") - override fun hashCode(): Int = hashCode + /** + * Configuration for event_output pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun eventOutputConfig(): EventOutputConfig = + eventOutputConfig.getRequired("event_output_config") - override fun toString() = - "AddPrice{allocationPrice=$allocationPrice, planPhaseOrder=$planPhaseOrder, price=$price, additionalProperties=$additionalProperties}" - } + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") - class RemoveAdjustment - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val adjustmentId: JsonField, - private val planPhaseOrder: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("adjustment_id") - @ExcludeMissing - adjustmentId: JsonField = JsonMissing.of(), - @JsonProperty("plan_phase_order") - @ExcludeMissing - planPhaseOrder: JsonField = JsonMissing.of(), - ) : this(adjustmentId, planPhaseOrder, mutableMapOf()) + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("event_output") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType - /** - * The id of the adjustment to remove from on the plan. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun adjustmentId(): String = adjustmentId.getRequired("adjustment_id") + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") - /** - * The phase to remove this adjustment from. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun planPhaseOrder(): Long? = planPhaseOrder.getNullable("plan_phase_order") + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = billableMetricId.getNullable("billable_metric_id") - /** - * Returns the raw JSON value of [adjustmentId]. - * - * Unlike [adjustmentId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("adjustment_id") - @ExcludeMissing - fun _adjustmentId(): JsonField = adjustmentId + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") - /** - * Returns the raw JSON value of [planPhaseOrder]. - * - * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("plan_phase_order") - @ExcludeMissing - fun _planPhaseOrder(): JsonField = planPhaseOrder + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") - fun toBuilder() = Builder().from(this) + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") - companion object { + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") - /** - * Returns a mutable builder for constructing an instance of [RemoveAdjustment]. - * - * The following fields are required: - * ```kotlin - * .adjustmentId() - * ``` - */ - fun builder() = Builder() - } + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") - /** A builder for [RemoveAdjustment]. */ - class Builder internal constructor() { + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") - private var adjustmentId: JsonField? = null - private var planPhaseOrder: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + invoiceGroupingKey.getNullable("invoice_grouping_key") - internal fun from(removeAdjustment: RemoveAdjustment) = apply { - adjustmentId = removeAdjustment.adjustmentId - planPhaseOrder = removeAdjustment.planPhaseOrder - additionalProperties = removeAdjustment.additionalProperties.toMutableMap() - } + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - /** The id of the adjustment to remove from on the plan. */ - fun adjustmentId(adjustmentId: String) = adjustmentId(JsonField.of(adjustmentId)) + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") - /** - * Sets [Builder.adjustmentId] to an arbitrary JSON value. - * - * You should usually call [Builder.adjustmentId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun adjustmentId(adjustmentId: JsonField) = apply { - this.adjustmentId = adjustmentId - } + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") - /** The phase to remove this adjustment from. */ - fun planPhaseOrder(planPhaseOrder: Long?) = - planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence - /** - * Alias for [Builder.planPhaseOrder]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + /** + * Returns the raw JSON value of [eventOutputConfig]. + * + * Unlike [eventOutputConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("event_output_config") + @ExcludeMissing + fun _eventOutputConfig(): JsonField = eventOutputConfig - /** - * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. - * - * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun planPhaseOrder(planPhaseOrder: JsonField) = apply { - this.planPhaseOrder = planPhaseOrder - } + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate - /** - * Returns an immutable instance of [RemoveAdjustment]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```kotlin - * .adjustmentId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): RemoveAdjustment = - RemoveAdjustment( - checkRequired("adjustmentId", adjustmentId), - planPhaseOrder, - additionalProperties.toMutableMap(), - ) - } + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig - private var validated: Boolean = false + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency - fun validate(): RemoveAdjustment = apply { - if (validated) { - return@apply - } + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration - adjustmentId() - planPhaseOrder() - validated = true - } + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (if (adjustmentId.asKnown() == null) 0 else 1) + - (if (planPhaseOrder.asKnown() == null) 0 else 1) + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration - return other is RemoveAdjustment && - adjustmentId == other.adjustmentId && - planPhaseOrder == other.planPhaseOrder && - additionalProperties == other.additionalProperties - } + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata - private val hashCode: Int by lazy { - Objects.hash(adjustmentId, planPhaseOrder, additionalProperties) - } + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId - override fun hashCode(): Int = hashCode + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - override fun toString() = - "RemoveAdjustment{adjustmentId=$adjustmentId, planPhaseOrder=$planPhaseOrder, additionalProperties=$additionalProperties}" - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - class RemovePrice - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val priceId: JsonField, - private val planPhaseOrder: JsonField, - private val additionalProperties: MutableMap, - ) { + fun toBuilder() = Builder().from(this) - @JsonCreator - private constructor( - @JsonProperty("price_id") @ExcludeMissing priceId: JsonField = JsonMissing.of(), - @JsonProperty("plan_phase_order") - @ExcludeMissing - planPhaseOrder: JsonField = JsonMissing.of(), - ) : this(priceId, planPhaseOrder, mutableMapOf()) + companion object { - /** - * The id of the price to remove from the plan. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun priceId(): String = priceId.getRequired("price_id") + /** + * Returns a mutable builder for constructing an instance of [EventOutput]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .eventOutputConfig() + * .itemId() + * .name() + * ``` + */ + fun builder() = Builder() + } - /** - * The phase to remove this price from. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun planPhaseOrder(): Long? = planPhaseOrder.getNullable("plan_phase_order") + /** A builder for [EventOutput]. */ + class Builder internal constructor() { - /** - * Returns the raw JSON value of [priceId]. - * - * Unlike [priceId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId + private var cadence: JsonField? = null + private var eventOutputConfig: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonValue = JsonValue.from("event_output") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - /** - * Returns the raw JSON value of [planPhaseOrder]. - * - * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("plan_phase_order") - @ExcludeMissing - fun _planPhaseOrder(): JsonField = planPhaseOrder + internal fun from(eventOutput: EventOutput) = apply { + cadence = eventOutput.cadence + eventOutputConfig = eventOutput.eventOutputConfig + itemId = eventOutput.itemId + modelType = eventOutput.modelType + name = eventOutput.name + billableMetricId = eventOutput.billableMetricId + billedInAdvance = eventOutput.billedInAdvance + billingCycleConfiguration = eventOutput.billingCycleConfiguration + conversionRate = eventOutput.conversionRate + conversionRateConfig = eventOutput.conversionRateConfig + currency = eventOutput.currency + dimensionalPriceConfiguration = eventOutput.dimensionalPriceConfiguration + externalPriceId = eventOutput.externalPriceId + fixedPriceQuantity = eventOutput.fixedPriceQuantity + invoiceGroupingKey = eventOutput.invoiceGroupingKey + invoicingCycleConfiguration = eventOutput.invoicingCycleConfiguration + metadata = eventOutput.metadata + referenceId = eventOutput.referenceId + additionalProperties = eventOutput.additionalProperties.toMutableMap() + } - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - fun toBuilder() = Builder().from(this) + /** Configuration for event_output pricing */ + fun eventOutputConfig(eventOutputConfig: EventOutputConfig) = + eventOutputConfig(JsonField.of(eventOutputConfig)) - companion object { + /** + * Sets [Builder.eventOutputConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.eventOutputConfig] with a well-typed + * [EventOutputConfig] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun eventOutputConfig(eventOutputConfig: JsonField) = apply { + this.eventOutputConfig = eventOutputConfig + } - /** - * Returns a mutable builder for constructing an instance of [RemovePrice]. - * - * The following fields are required: - * ```kotlin - * .priceId() - * ``` - */ - fun builder() = Builder() - } + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - /** A builder for [RemovePrice]. */ - class Builder internal constructor() { + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - private var priceId: JsonField? = null - private var planPhaseOrder: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("event_output") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } - internal fun from(removePrice: RemovePrice) = apply { - priceId = removePrice.priceId - planPhaseOrder = removePrice.planPhaseOrder - additionalProperties = removePrice.additionalProperties.toMutableMap() - } + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) - /** The id of the price to remove from the plan. */ - fun priceId(priceId: String) = priceId(JsonField.of(priceId)) + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } - /** - * Sets [Builder.priceId] to an arbitrary JSON value. - * - * You should usually call [Builder.priceId] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun priceId(priceId: JsonField) = apply { this.priceId = priceId } + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) - /** The phase to remove this price from. */ - fun planPhaseOrder(planPhaseOrder: Long?) = - planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } - /** - * Alias for [Builder.planPhaseOrder]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) - /** - * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. - * - * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun planPhaseOrder(planPhaseOrder: JsonField) = apply { - this.planPhaseOrder = planPhaseOrder - } + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) - /** - * Returns an immutable instance of [RemovePrice]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```kotlin - * .priceId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): RemovePrice = - RemovePrice( - checkRequired("priceId", priceId), - planPhaseOrder, - additionalProperties.toMutableMap(), - ) - } + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } - private var validated: Boolean = false + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) - fun validate(): RemovePrice = apply { - if (validated) { - return@apply - } + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } - priceId() - planPhaseOrder() - validated = true - } + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (if (priceId.asKnown() == null) 0 else 1) + - (if (planPhaseOrder.asKnown() == null) 0 else 1) + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) - return other is RemovePrice && - priceId == other.priceId && - planPhaseOrder == other.planPhaseOrder && - additionalProperties == other.additionalProperties - } + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) - private val hashCode: Int by lazy { - Objects.hash(priceId, planPhaseOrder, additionalProperties) - } + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } - override fun hashCode(): Int = hashCode + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) - override fun toString() = - "RemovePrice{priceId=$priceId, planPhaseOrder=$planPhaseOrder, additionalProperties=$additionalProperties}" - } + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } - class ReplaceAdjustment - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val adjustment: JsonField, - private val replacesAdjustmentId: JsonField, - private val planPhaseOrder: JsonField, - private val additionalProperties: MutableMap, - ) { + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) - @JsonCreator - private constructor( - @JsonProperty("adjustment") - @ExcludeMissing - adjustment: JsonField = JsonMissing.of(), - @JsonProperty("replaces_adjustment_id") - @ExcludeMissing - replacesAdjustmentId: JsonField = JsonMissing.of(), - @JsonProperty("plan_phase_order") - @ExcludeMissing - planPhaseOrder: JsonField = JsonMissing.of(), - ) : this(adjustment, replacesAdjustmentId, planPhaseOrder, mutableMapOf()) + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } - /** - * The definition of a new adjustment to create and add to the plan. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun adjustment(): Adjustment = adjustment.getRequired("adjustment") + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) - /** - * The id of the adjustment on the plan to replace in the plan. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun replacesAdjustmentId(): String = - replacesAdjustmentId.getRequired("replaces_adjustment_id") + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) - /** - * The phase to replace this adjustment from. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun planPhaseOrder(): Long? = planPhaseOrder.getNullable("plan_phase_order") + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } - /** - * Returns the raw JSON value of [adjustment]. - * - * Unlike [adjustment], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("adjustment") - @ExcludeMissing - fun _adjustment(): JsonField = adjustment + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) - /** - * Returns the raw JSON value of [replacesAdjustmentId]. - * - * Unlike [replacesAdjustmentId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("replaces_adjustment_id") - @ExcludeMissing - fun _replacesAdjustmentId(): JsonField = replacesAdjustmentId - - /** - * Returns the raw JSON value of [planPhaseOrder]. - * - * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("plan_phase_order") - @ExcludeMissing - fun _planPhaseOrder(): JsonField = planPhaseOrder + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - fun toBuilder() = Builder().from(this) + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - companion object { + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - /** - * Returns a mutable builder for constructing an instance of [ReplaceAdjustment]. - * - * The following fields are required: - * ```kotlin - * .adjustment() - * .replacesAdjustmentId() - * ``` - */ - fun builder() = Builder() - } + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) - /** A builder for [ReplaceAdjustment]. */ - class Builder internal constructor() { + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } - private var adjustment: JsonField? = null - private var replacesAdjustmentId: JsonField? = null - private var planPhaseOrder: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - internal fun from(replaceAdjustment: ReplaceAdjustment) = apply { - adjustment = replaceAdjustment.adjustment - replacesAdjustmentId = replaceAdjustment.replacesAdjustmentId - planPhaseOrder = replaceAdjustment.planPhaseOrder - additionalProperties = replaceAdjustment.additionalProperties.toMutableMap() - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** The definition of a new adjustment to create and add to the plan. */ - fun adjustment(adjustment: Adjustment) = adjustment(JsonField.of(adjustment)) + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - /** - * Sets [Builder.adjustment] to an arbitrary JSON value. - * - * You should usually call [Builder.adjustment] with a well-typed [Adjustment] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun adjustment(adjustment: JsonField) = apply { - this.adjustment = adjustment - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - /** - * Alias for calling [adjustment] with - * `Adjustment.ofPercentageDiscount(percentageDiscount)`. - */ - fun adjustment(percentageDiscount: NewPercentageDiscount) = - adjustment(Adjustment.ofPercentageDiscount(percentageDiscount)) + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - /** - * Alias for calling [adjustment] with the following: - * ```kotlin - * NewPercentageDiscount.builder() - * .adjustmentType(NewPercentageDiscount.AdjustmentType.PERCENTAGE_DISCOUNT) - * .percentageDiscount(percentageDiscount) - * .build() - * ``` - */ - fun percentageDiscountAdjustment(percentageDiscount: Double) = - adjustment( - NewPercentageDiscount.builder() - .adjustmentType(NewPercentageDiscount.AdjustmentType.PERCENTAGE_DISCOUNT) - .percentageDiscount(percentageDiscount) - .build() - ) + /** + * Returns an immutable instance of [EventOutput]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .eventOutputConfig() + * .itemId() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): EventOutput = + EventOutput( + checkRequired("cadence", cadence), + checkRequired("eventOutputConfig", eventOutputConfig), + checkRequired("itemId", itemId), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } - /** Alias for calling [adjustment] with `Adjustment.ofUsageDiscount(usageDiscount)`. */ - fun adjustment(usageDiscount: NewUsageDiscount) = - adjustment(Adjustment.ofUsageDiscount(usageDiscount)) + private var validated: Boolean = false - /** - * Alias for calling [adjustment] with the following: - * ```kotlin - * NewUsageDiscount.builder() - * .adjustmentType(NewUsageDiscount.AdjustmentType.USAGE_DISCOUNT) - * .usageDiscount(usageDiscount) - * .build() - * ``` - */ - fun usageDiscountAdjustment(usageDiscount: Double) = - adjustment( - NewUsageDiscount.builder() - .adjustmentType(NewUsageDiscount.AdjustmentType.USAGE_DISCOUNT) - .usageDiscount(usageDiscount) - .build() - ) + fun validate(): EventOutput = apply { + if (validated) { + return@apply + } - /** - * Alias for calling [adjustment] with `Adjustment.ofAmountDiscount(amountDiscount)`. - */ - fun adjustment(amountDiscount: NewAmountDiscount) = - adjustment(Adjustment.ofAmountDiscount(amountDiscount)) + cadence().validate() + eventOutputConfig().validate() + itemId() + _modelType().let { + if (it != JsonValue.from("event_output")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + metadata()?.validate() + referenceId() + validated = true + } - /** - * Alias for calling [adjustment] with the following: - * ```kotlin - * NewAmountDiscount.builder() - * .adjustmentType(NewAmountDiscount.AdjustmentType.AMOUNT_DISCOUNT) - * .amountDiscount(amountDiscount) - * .build() - * ``` - */ - fun amountDiscountAdjustment(amountDiscount: String) = - adjustment( - NewAmountDiscount.builder() - .adjustmentType(NewAmountDiscount.AdjustmentType.AMOUNT_DISCOUNT) - .amountDiscount(amountDiscount) - .build() - ) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - /** Alias for calling [adjustment] with `Adjustment.ofMinimum(minimum)`. */ - fun adjustment(minimum: NewMinimum) = adjustment(Adjustment.ofMinimum(minimum)) + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (eventOutputConfig.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + modelType.let { if (it == JsonValue.from("event_output")) 1 else 0 } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) - /** Alias for calling [adjustment] with `Adjustment.ofMaximum(maximum)`. */ - fun adjustment(maximum: NewMaximum) = adjustment(Adjustment.ofMaximum(maximum)) + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { - /** - * Alias for calling [adjustment] with the following: - * ```kotlin - * NewMaximum.builder() - * .adjustmentType(NewMaximum.AdjustmentType.MAXIMUM) - * .maximumAmount(maximumAmount) - * .build() - * ``` - */ - fun maximumAdjustment(maximumAmount: String) = - adjustment( - NewMaximum.builder() - .adjustmentType(NewMaximum.AdjustmentType.MAXIMUM) - .maximumAmount(maximumAmount) - .build() - ) + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value - /** The id of the adjustment on the plan to replace in the plan. */ - fun replacesAdjustmentId(replacesAdjustmentId: String) = - replacesAdjustmentId(JsonField.of(replacesAdjustmentId)) + companion object { - /** - * Sets [Builder.replacesAdjustmentId] to an arbitrary JSON value. - * - * You should usually call [Builder.replacesAdjustmentId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun replacesAdjustmentId(replacesAdjustmentId: JsonField) = apply { - this.replacesAdjustmentId = replacesAdjustmentId - } + val ANNUAL = of("annual") - /** The phase to replace this adjustment from. */ - fun planPhaseOrder(planPhaseOrder: Long?) = - planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + val SEMI_ANNUAL = of("semi_annual") - /** - * Alias for [Builder.planPhaseOrder]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + val MONTHLY = of("monthly") - /** - * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. - * - * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun planPhaseOrder(planPhaseOrder: JsonField) = apply { - this.planPhaseOrder = planPhaseOrder - } + val QUARTERLY = of("quarterly") - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + val ONE_TIME = of("one_time") - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + val CUSTOM = of("custom") - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun of(value: String) = Cadence(JsonField.of(value)) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } - /** - * Returns an immutable instance of [ReplaceAdjustment]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```kotlin - * .adjustment() - * .replacesAdjustmentId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): ReplaceAdjustment = - ReplaceAdjustment( - checkRequired("adjustment", adjustment), - checkRequired("replacesAdjustmentId", replacesAdjustmentId), - planPhaseOrder, - additionalProperties.toMutableMap(), - ) - } + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } - private var validated: Boolean = false + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } - fun validate(): ReplaceAdjustment = apply { - if (validated) { - return@apply - } + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") - adjustment().validate() - replacesAdjustmentId() - planPhaseOrder() - validated = true - } + private var validated: Boolean = false - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + fun validate(): Cadence = apply { + if (validated) { + return@apply + } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (adjustment.asKnown()?.validity() ?: 0) + - (if (replacesAdjustmentId.asKnown() == null) 0 else 1) + - (if (planPhaseOrder.asKnown() == null) 0 else 1) + known() + validated = true + } - /** The definition of a new adjustment to create and add to the plan. */ - @JsonDeserialize(using = Adjustment.Deserializer::class) - @JsonSerialize(using = Adjustment.Serializer::class) - class Adjustment - private constructor( - private val percentageDiscount: NewPercentageDiscount? = null, - private val usageDiscount: NewUsageDiscount? = null, - private val amountDiscount: NewAmountDiscount? = null, - private val minimum: NewMinimum? = null, - private val maximum: NewMaximum? = null, - private val _json: JsonValue? = null, - ) { + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - fun percentageDiscount(): NewPercentageDiscount? = percentageDiscount + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - fun usageDiscount(): NewUsageDiscount? = usageDiscount + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun amountDiscount(): NewAmountDiscount? = amountDiscount + return other is Cadence && value == other.value + } - fun minimum(): NewMinimum? = minimum + override fun hashCode() = value.hashCode() - fun maximum(): NewMaximum? = maximum + override fun toString() = value.toString() + } - fun isPercentageDiscount(): Boolean = percentageDiscount != null + /** Configuration for event_output pricing */ + class EventOutputConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val unitRatingKey: JsonField, + private val defaultUnitRate: JsonField, + private val groupingKey: JsonField, + private val additionalProperties: MutableMap, + ) { - fun isUsageDiscount(): Boolean = usageDiscount != null + @JsonCreator + private constructor( + @JsonProperty("unit_rating_key") + @ExcludeMissing + unitRatingKey: JsonField = JsonMissing.of(), + @JsonProperty("default_unit_rate") + @ExcludeMissing + defaultUnitRate: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + ) : this(unitRatingKey, defaultUnitRate, groupingKey, mutableMapOf()) - fun isAmountDiscount(): Boolean = amountDiscount != null + /** + * The key in the event data to extract the unit rate from. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun unitRatingKey(): String = unitRatingKey.getRequired("unit_rating_key") - fun isMinimum(): Boolean = minimum != null + /** + * If provided, this amount will be used as the unit rate when an event does not + * have a value for the `unit_rating_key`. If not provided, events missing a + * unit rate will be ignored. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun defaultUnitRate(): String? = + defaultUnitRate.getNullable("default_unit_rate") - fun isMaximum(): Boolean = maximum != null + /** + * An optional key in the event data to group by (e.g., event ID). All events + * will also be grouped by their unit rate. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun groupingKey(): String? = groupingKey.getNullable("grouping_key") - fun asPercentageDiscount(): NewPercentageDiscount = - percentageDiscount.getOrThrow("percentageDiscount") + /** + * Returns the raw JSON value of [unitRatingKey]. + * + * Unlike [unitRatingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_rating_key") + @ExcludeMissing + fun _unitRatingKey(): JsonField = unitRatingKey - fun asUsageDiscount(): NewUsageDiscount = usageDiscount.getOrThrow("usageDiscount") + /** + * Returns the raw JSON value of [defaultUnitRate]. + * + * Unlike [defaultUnitRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("default_unit_rate") + @ExcludeMissing + fun _defaultUnitRate(): JsonField = defaultUnitRate - fun asAmountDiscount(): NewAmountDiscount = amountDiscount.getOrThrow("amountDiscount") + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey - fun asMinimum(): NewMinimum = minimum.getOrThrow("minimum") + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - fun asMaximum(): NewMaximum = maximum.getOrThrow("maximum") + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - fun _json(): JsonValue? = _json + fun toBuilder() = Builder().from(this) - fun accept(visitor: Visitor): T = - when { - percentageDiscount != null -> - visitor.visitPercentageDiscount(percentageDiscount) - usageDiscount != null -> visitor.visitUsageDiscount(usageDiscount) - amountDiscount != null -> visitor.visitAmountDiscount(amountDiscount) - minimum != null -> visitor.visitMinimum(minimum) - maximum != null -> visitor.visitMaximum(maximum) - else -> visitor.unknown(_json) - } + companion object { - private var validated: Boolean = false + /** + * Returns a mutable builder for constructing an instance of + * [EventOutputConfig]. + * + * The following fields are required: + * ```kotlin + * .unitRatingKey() + * ``` + */ + fun builder() = Builder() + } - fun validate(): Adjustment = apply { - if (validated) { - return@apply - } + /** A builder for [EventOutputConfig]. */ + class Builder internal constructor() { - accept( - object : Visitor { - override fun visitPercentageDiscount( - percentageDiscount: NewPercentageDiscount - ) { - percentageDiscount.validate() - } + private var unitRatingKey: JsonField? = null + private var defaultUnitRate: JsonField = JsonMissing.of() + private var groupingKey: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() - override fun visitUsageDiscount(usageDiscount: NewUsageDiscount) { - usageDiscount.validate() + internal fun from(eventOutputConfig: EventOutputConfig) = apply { + unitRatingKey = eventOutputConfig.unitRatingKey + defaultUnitRate = eventOutputConfig.defaultUnitRate + groupingKey = eventOutputConfig.groupingKey + additionalProperties = + eventOutputConfig.additionalProperties.toMutableMap() } - override fun visitAmountDiscount(amountDiscount: NewAmountDiscount) { - amountDiscount.validate() - } + /** The key in the event data to extract the unit rate from. */ + fun unitRatingKey(unitRatingKey: String) = + unitRatingKey(JsonField.of(unitRatingKey)) - override fun visitMinimum(minimum: NewMinimum) { - minimum.validate() + /** + * Sets [Builder.unitRatingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.unitRatingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun unitRatingKey(unitRatingKey: JsonField) = apply { + this.unitRatingKey = unitRatingKey } - override fun visitMaximum(maximum: NewMaximum) { - maximum.validate() + /** + * If provided, this amount will be used as the unit rate when an event does + * not have a value for the `unit_rating_key`. If not provided, events + * missing a unit rate will be ignored. + */ + fun defaultUnitRate(defaultUnitRate: String?) = + defaultUnitRate(JsonField.ofNullable(defaultUnitRate)) + + /** + * Sets [Builder.defaultUnitRate] to an arbitrary JSON value. + * + * You should usually call [Builder.defaultUnitRate] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun defaultUnitRate(defaultUnitRate: JsonField) = apply { + this.defaultUnitRate = defaultUnitRate } - } - ) - validated = true - } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** + * An optional key in the event data to group by (e.g., event ID). All + * events will also be grouped by their unit rate. + */ + fun groupingKey(groupingKey: String?) = + groupingKey(JsonField.ofNullable(groupingKey)) - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitPercentageDiscount( - percentageDiscount: NewPercentageDiscount - ) = percentageDiscount.validity() + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } - override fun visitUsageDiscount(usageDiscount: NewUsageDiscount) = - usageDiscount.validity() + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - override fun visitAmountDiscount(amountDiscount: NewAmountDiscount) = - amountDiscount.validity() + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - override fun visitMinimum(minimum: NewMinimum) = minimum.validity() + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - override fun visitMaximum(maximum: NewMaximum) = maximum.validity() + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - override fun unknown(json: JsonValue?) = 0 + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [EventOutputConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .unitRatingKey() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): EventOutputConfig = + EventOutputConfig( + checkRequired("unitRatingKey", unitRatingKey), + defaultUnitRate, + groupingKey, + additionalProperties.toMutableMap(), + ) } - ) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + private var validated: Boolean = false - return other is Adjustment && - percentageDiscount == other.percentageDiscount && - usageDiscount == other.usageDiscount && - amountDiscount == other.amountDiscount && - minimum == other.minimum && - maximum == other.maximum - } + fun validate(): EventOutputConfig = apply { + if (validated) { + return@apply + } - override fun hashCode(): Int = - Objects.hash(percentageDiscount, usageDiscount, amountDiscount, minimum, maximum) + unitRatingKey() + defaultUnitRate() + groupingKey() + validated = true + } - override fun toString(): String = - when { - percentageDiscount != null -> - "Adjustment{percentageDiscount=$percentageDiscount}" - usageDiscount != null -> "Adjustment{usageDiscount=$usageDiscount}" - amountDiscount != null -> "Adjustment{amountDiscount=$amountDiscount}" - minimum != null -> "Adjustment{minimum=$minimum}" - maximum != null -> "Adjustment{maximum=$maximum}" - _json != null -> "Adjustment{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Adjustment") - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - companion object { + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (unitRatingKey.asKnown() == null) 0 else 1) + + (if (defaultUnitRate.asKnown() == null) 0 else 1) + + (if (groupingKey.asKnown() == null) 0 else 1) - fun ofPercentageDiscount(percentageDiscount: NewPercentageDiscount) = - Adjustment(percentageDiscount = percentageDiscount) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun ofUsageDiscount(usageDiscount: NewUsageDiscount) = - Adjustment(usageDiscount = usageDiscount) + return other is EventOutputConfig && + unitRatingKey == other.unitRatingKey && + defaultUnitRate == other.defaultUnitRate && + groupingKey == other.groupingKey && + additionalProperties == other.additionalProperties + } - fun ofAmountDiscount(amountDiscount: NewAmountDiscount) = - Adjustment(amountDiscount = amountDiscount) + private val hashCode: Int by lazy { + Objects.hash( + unitRatingKey, + defaultUnitRate, + groupingKey, + additionalProperties, + ) + } - fun ofMinimum(minimum: NewMinimum) = Adjustment(minimum = minimum) + override fun hashCode(): Int = hashCode - fun ofMaximum(maximum: NewMaximum) = Adjustment(maximum = maximum) - } + override fun toString() = + "EventOutputConfig{unitRatingKey=$unitRatingKey, defaultUnitRate=$defaultUnitRate, groupingKey=$groupingKey, additionalProperties=$additionalProperties}" + } - /** - * An interface that defines how to map each variant of [Adjustment] to a value of type - * [T]. - */ - interface Visitor { + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { - fun visitPercentageDiscount(percentageDiscount: NewPercentageDiscount): T + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties - fun visitUsageDiscount(usageDiscount: NewUsageDiscount): T + fun toBuilder() = Builder().from(this) - fun visitAmountDiscount(amountDiscount: NewAmountDiscount): T + companion object { - fun visitMinimum(minimum: NewMinimum): T + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } - fun visitMaximum(maximum: NewMaximum): T + /** A builder for [Metadata]. */ + class Builder internal constructor() { - /** - * Maps an unknown variant of [Adjustment] to a value of type [T]. - * - * An instance of [Adjustment] can contain an unknown variant if it was deserialized - * from data that doesn't match any known variant. For example, if the SDK is on an - * older version than the API, then the API may respond with new variants that the - * SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown Adjustment: $json") - } - } + private var additionalProperties: MutableMap = + mutableMapOf() - internal class Deserializer : BaseDeserializer(Adjustment::class) { + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } - override fun ObjectCodec.deserialize(node: JsonNode): Adjustment { - val json = JsonValue.fromJsonNode(node) - val adjustmentType = json.asObject()?.get("adjustment_type")?.asString() + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - when (adjustmentType) { - "percentage_discount" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Adjustment(percentageDiscount = it, _json = json) } - ?: Adjustment(_json = json) - } - "usage_discount" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(usageDiscount = it, _json = json) - } ?: Adjustment(_json = json) - } - "amount_discount" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(amountDiscount = it, _json = json) - } ?: Adjustment(_json = json) + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) } - "minimum" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(minimum = it, _json = json) - } ?: Adjustment(_json = json) + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) } - "maximum" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(maximum = it, _json = json) - } ?: Adjustment(_json = json) + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } - return Adjustment(_json = json) - } - } + private var validated: Boolean = false - internal class Serializer : BaseSerializer(Adjustment::class) { + fun validate(): Metadata = apply { + if (validated) { + return@apply + } - override fun serialize( - value: Adjustment, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.percentageDiscount != null -> - generator.writeObject(value.percentageDiscount) - value.usageDiscount != null -> generator.writeObject(value.usageDiscount) - value.amountDiscount != null -> generator.writeObject(value.amountDiscount) - value.minimum != null -> generator.writeObject(value.minimum) - value.maximum != null -> generator.writeObject(value.maximum) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Adjustment") + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } + + return other is EventOutput && + cadence == other.cadence && + eventOutputConfig == other.eventOutputConfig && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + eventOutputConfig, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties, + ) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "EventOutput{cadence=$cadence, eventOutputConfig=$eventOutputConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } } @@ -12935,65 +13646,51 @@ private constructor( return true } - return other is ReplaceAdjustment && - adjustment == other.adjustment && - replacesAdjustmentId == other.replacesAdjustmentId && + return other is AddPrice && + allocationPrice == other.allocationPrice && planPhaseOrder == other.planPhaseOrder && + price == other.price && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(adjustment, replacesAdjustmentId, planPhaseOrder, additionalProperties) + Objects.hash(allocationPrice, planPhaseOrder, price, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "ReplaceAdjustment{adjustment=$adjustment, replacesAdjustmentId=$replacesAdjustmentId, planPhaseOrder=$planPhaseOrder, additionalProperties=$additionalProperties}" + "AddPrice{allocationPrice=$allocationPrice, planPhaseOrder=$planPhaseOrder, price=$price, additionalProperties=$additionalProperties}" } - class ReplacePrice + class RemoveAdjustment @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val replacesPriceId: JsonField, - private val allocationPrice: JsonField, + private val adjustmentId: JsonField, private val planPhaseOrder: JsonField, - private val price: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("replaces_price_id") - @ExcludeMissing - replacesPriceId: JsonField = JsonMissing.of(), - @JsonProperty("allocation_price") + @JsonProperty("adjustment_id") @ExcludeMissing - allocationPrice: JsonField = JsonMissing.of(), + adjustmentId: JsonField = JsonMissing.of(), @JsonProperty("plan_phase_order") @ExcludeMissing planPhaseOrder: JsonField = JsonMissing.of(), - @JsonProperty("price") @ExcludeMissing price: JsonField = JsonMissing.of(), - ) : this(replacesPriceId, allocationPrice, planPhaseOrder, price, mutableMapOf()) + ) : this(adjustmentId, planPhaseOrder, mutableMapOf()) /** - * The id of the price on the plan to replace in the plan. + * The id of the adjustment to remove from on the plan. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ - fun replacesPriceId(): String = replacesPriceId.getRequired("replaces_price_id") - - /** - * The allocation price to add to the plan. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun allocationPrice(): NewAllocationPrice? = allocationPrice.getNullable("allocation_price") + fun adjustmentId(): String = adjustmentId.getRequired("adjustment_id") /** - * The phase to replace this price from. + * The phase to remove this adjustment from. * * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -13001,32 +13698,14 @@ private constructor( fun planPhaseOrder(): Long? = planPhaseOrder.getNullable("plan_phase_order") /** - * New plan price request body params. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun price(): Price? = price.getNullable("price") - - /** - * Returns the raw JSON value of [replacesPriceId]. - * - * Unlike [replacesPriceId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("replaces_price_id") - @ExcludeMissing - fun _replacesPriceId(): JsonField = replacesPriceId - - /** - * Returns the raw JSON value of [allocationPrice]. + * Returns the raw JSON value of [adjustmentId]. * - * Unlike [allocationPrice], this method doesn't throw if the JSON field has an unexpected + * Unlike [adjustmentId], this method doesn't throw if the JSON field has an unexpected * type. */ - @JsonProperty("allocation_price") + @JsonProperty("adjustment_id") @ExcludeMissing - fun _allocationPrice(): JsonField = allocationPrice + fun _adjustmentId(): JsonField = adjustmentId /** * Returns the raw JSON value of [planPhaseOrder]. @@ -13038,13 +13717,6 @@ private constructor( @ExcludeMissing fun _planPhaseOrder(): JsonField = planPhaseOrder - /** - * Returns the raw JSON value of [price]. - * - * Unlike [price], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("price") @ExcludeMissing fun _price(): JsonField = price - @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -13060,64 +13732,44 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [ReplacePrice]. + * Returns a mutable builder for constructing an instance of [RemoveAdjustment]. * * The following fields are required: * ```kotlin - * .replacesPriceId() + * .adjustmentId() * ``` */ fun builder() = Builder() } - /** A builder for [ReplacePrice]. */ + /** A builder for [RemoveAdjustment]. */ class Builder internal constructor() { - private var replacesPriceId: JsonField? = null - private var allocationPrice: JsonField = JsonMissing.of() + private var adjustmentId: JsonField? = null private var planPhaseOrder: JsonField = JsonMissing.of() - private var price: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(replacePrice: ReplacePrice) = apply { - replacesPriceId = replacePrice.replacesPriceId - allocationPrice = replacePrice.allocationPrice - planPhaseOrder = replacePrice.planPhaseOrder - price = replacePrice.price - additionalProperties = replacePrice.additionalProperties.toMutableMap() + internal fun from(removeAdjustment: RemoveAdjustment) = apply { + adjustmentId = removeAdjustment.adjustmentId + planPhaseOrder = removeAdjustment.planPhaseOrder + additionalProperties = removeAdjustment.additionalProperties.toMutableMap() } - /** The id of the price on the plan to replace in the plan. */ - fun replacesPriceId(replacesPriceId: String) = - replacesPriceId(JsonField.of(replacesPriceId)) + /** The id of the adjustment to remove from on the plan. */ + fun adjustmentId(adjustmentId: String) = adjustmentId(JsonField.of(adjustmentId)) /** - * Sets [Builder.replacesPriceId] to an arbitrary JSON value. + * Sets [Builder.adjustmentId] to an arbitrary JSON value. * - * You should usually call [Builder.replacesPriceId] with a well-typed [String] value + * You should usually call [Builder.adjustmentId] with a well-typed [String] value * instead. This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun replacesPriceId(replacesPriceId: JsonField) = apply { - this.replacesPriceId = replacesPriceId - } - - /** The allocation price to add to the plan. */ - fun allocationPrice(allocationPrice: NewAllocationPrice?) = - allocationPrice(JsonField.ofNullable(allocationPrice)) - - /** - * Sets [Builder.allocationPrice] to an arbitrary JSON value. - * - * You should usually call [Builder.allocationPrice] with a well-typed - * [NewAllocationPrice] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun allocationPrice(allocationPrice: JsonField) = apply { - this.allocationPrice = allocationPrice + fun adjustmentId(adjustmentId: JsonField) = apply { + this.adjustmentId = adjustmentId } - /** The phase to replace this price from. */ + /** The phase to remove this adjustment from. */ fun planPhaseOrder(planPhaseOrder: Long?) = planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) @@ -13139,221 +13791,54 @@ private constructor( this.planPhaseOrder = planPhaseOrder } - /** New plan price request body params. */ - fun price(price: Price?) = price(JsonField.ofNullable(price)) + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** - * Sets [Builder.price] to an arbitrary JSON value. - * - * You should usually call [Builder.price] with a well-typed [Price] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun price(price: JsonField) = apply { this.price = price } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** Alias for calling [price] with `Price.ofUnit(unit)`. */ - fun price(unit: NewPlanUnitPrice) = price(Price.ofUnit(unit)) + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - /** Alias for calling [price] with `Price.ofTiered(tiered)`. */ - fun price(tiered: NewPlanTieredPrice) = price(Price.ofTiered(tiered)) + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - /** Alias for calling [price] with `Price.ofBulk(bulk)`. */ - fun price(bulk: NewPlanBulkPrice) = price(Price.ofBulk(bulk)) - - /** Alias for calling [price] with `Price.ofBulkWithFilters(bulkWithFilters)`. */ - fun price(bulkWithFilters: Price.BulkWithFilters) = - price(Price.ofBulkWithFilters(bulkWithFilters)) - - /** Alias for calling [price] with `Price.ofPackage(package_)`. */ - fun price(package_: NewPlanPackagePrice) = price(Price.ofPackage(package_)) - - /** Alias for calling [price] with `Price.ofMatrix(matrix)`. */ - fun price(matrix: NewPlanMatrixPrice) = price(Price.ofMatrix(matrix)) - - /** - * Alias for calling [price] with `Price.ofThresholdTotalAmount(thresholdTotalAmount)`. - */ - fun price(thresholdTotalAmount: NewPlanThresholdTotalAmountPrice) = - price(Price.ofThresholdTotalAmount(thresholdTotalAmount)) - - /** Alias for calling [price] with `Price.ofTieredPackage(tieredPackage)`. */ - fun price(tieredPackage: NewPlanTieredPackagePrice) = - price(Price.ofTieredPackage(tieredPackage)) - - /** Alias for calling [price] with `Price.ofTieredWithMinimum(tieredWithMinimum)`. */ - fun price(tieredWithMinimum: NewPlanTieredWithMinimumPrice) = - price(Price.ofTieredWithMinimum(tieredWithMinimum)) - - /** Alias for calling [price] with `Price.ofGroupedTiered(groupedTiered)`. */ - fun price(groupedTiered: NewPlanGroupedTieredPrice) = - price(Price.ofGroupedTiered(groupedTiered)) - - /** - * Alias for calling [price] with - * `Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)`. - */ - fun price(tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice) = - price(Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)) - - /** - * Alias for calling [price] with - * `Price.ofPackageWithAllocation(packageWithAllocation)`. - */ - fun price(packageWithAllocation: NewPlanPackageWithAllocationPrice) = - price(Price.ofPackageWithAllocation(packageWithAllocation)) - - /** Alias for calling [price] with `Price.ofUnitWithPercent(unitWithPercent)`. */ - fun price(unitWithPercent: NewPlanUnitWithPercentPrice) = - price(Price.ofUnitWithPercent(unitWithPercent)) - - /** - * Alias for calling [price] with `Price.ofMatrixWithAllocation(matrixWithAllocation)`. - */ - fun price(matrixWithAllocation: NewPlanMatrixWithAllocationPrice) = - price(Price.ofMatrixWithAllocation(matrixWithAllocation)) - - /** - * Alias for calling [price] with `Price.ofTieredWithProration(tieredWithProration)`. - */ - fun price(tieredWithProration: Price.TieredWithProration) = - price(Price.ofTieredWithProration(tieredWithProration)) - - /** Alias for calling [price] with `Price.ofUnitWithProration(unitWithProration)`. */ - fun price(unitWithProration: NewPlanUnitWithProrationPrice) = - price(Price.ofUnitWithProration(unitWithProration)) - - /** Alias for calling [price] with `Price.ofGroupedAllocation(groupedAllocation)`. */ - fun price(groupedAllocation: NewPlanGroupedAllocationPrice) = - price(Price.ofGroupedAllocation(groupedAllocation)) - - /** Alias for calling [price] with `Price.ofBulkWithProration(bulkWithProration)`. */ - fun price(bulkWithProration: NewPlanBulkWithProrationPrice) = - price(Price.ofBulkWithProration(bulkWithProration)) - - /** - * Alias for calling [price] with - * `Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)`. - */ - fun price(groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice) = - price(Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)) - - /** - * Alias for calling [price] with - * `Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)`. - */ - fun price(groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice) = - price(Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)) - - /** - * Alias for calling [price] with - * `Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)`. - */ - fun price(groupedWithMinMaxThresholds: Price.GroupedWithMinMaxThresholds) = - price(Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)) - - /** - * Alias for calling [price] with - * `Price.ofMatrixWithDisplayName(matrixWithDisplayName)`. - */ - fun price(matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice) = - price(Price.ofMatrixWithDisplayName(matrixWithDisplayName)) - - /** - * Alias for calling [price] with `Price.ofGroupedTieredPackage(groupedTieredPackage)`. - */ - fun price(groupedTieredPackage: NewPlanGroupedTieredPackagePrice) = - price(Price.ofGroupedTieredPackage(groupedTieredPackage)) - - /** - * Alias for calling [price] with - * `Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)`. - */ - fun price(maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice) = - price(Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)) - - /** - * Alias for calling [price] with - * `Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)`. - */ - fun price(scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice) = - price(Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)) - - /** - * Alias for calling [price] with - * `Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)`. - */ - fun price( - scalableMatrixWithTieredPricing: NewPlanScalableMatrixWithTieredPricingPrice - ) = price(Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)) - - /** - * Alias for calling [price] with - * `Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)`. - */ - fun price(cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice) = - price(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) - - /** Alias for calling [price] with `Price.ofMinimum(minimum)`. */ - fun price(minimum: NewPlanMinimumCompositePrice) = price(Price.ofMinimum(minimum)) - - /** Alias for calling [price] with `Price.ofPercent(percent)`. */ - fun price(percent: Price.Percent) = price(Price.ofPercent(percent)) - - /** Alias for calling [price] with `Price.ofEventOutput(eventOutput)`. */ - fun price(eventOutput: Price.EventOutput) = price(Price.ofEventOutput(eventOutput)) - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } /** - * Returns an immutable instance of [ReplacePrice]. + * Returns an immutable instance of [RemoveAdjustment]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```kotlin - * .replacesPriceId() + * .adjustmentId() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): ReplacePrice = - ReplacePrice( - checkRequired("replacesPriceId", replacesPriceId), - allocationPrice, + fun build(): RemoveAdjustment = + RemoveAdjustment( + checkRequired("adjustmentId", adjustmentId), planPhaseOrder, - price, additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): ReplacePrice = apply { + fun validate(): RemoveAdjustment = apply { if (validated) { return@apply } - replacesPriceId() - allocationPrice()?.validate() + adjustmentId() planPhaseOrder() - price()?.validate() validated = true } @@ -13372,1223 +13857,4578 @@ private constructor( * Used for best match union deserialization. */ internal fun validity(): Int = - (if (replacesPriceId.asKnown() == null) 0 else 1) + - (allocationPrice.asKnown()?.validity() ?: 0) + - (if (planPhaseOrder.asKnown() == null) 0 else 1) + - (price.asKnown()?.validity() ?: 0) - - /** New plan price request body params. */ - @JsonDeserialize(using = Price.Deserializer::class) - @JsonSerialize(using = Price.Serializer::class) - class Price - private constructor( - private val unit: NewPlanUnitPrice? = null, - private val tiered: NewPlanTieredPrice? = null, - private val bulk: NewPlanBulkPrice? = null, - private val bulkWithFilters: BulkWithFilters? = null, - private val package_: NewPlanPackagePrice? = null, - private val matrix: NewPlanMatrixPrice? = null, - private val thresholdTotalAmount: NewPlanThresholdTotalAmountPrice? = null, - private val tieredPackage: NewPlanTieredPackagePrice? = null, - private val tieredWithMinimum: NewPlanTieredWithMinimumPrice? = null, - private val groupedTiered: NewPlanGroupedTieredPrice? = null, - private val tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice? = null, - private val packageWithAllocation: NewPlanPackageWithAllocationPrice? = null, - private val unitWithPercent: NewPlanUnitWithPercentPrice? = null, - private val matrixWithAllocation: NewPlanMatrixWithAllocationPrice? = null, - private val tieredWithProration: TieredWithProration? = null, - private val unitWithProration: NewPlanUnitWithProrationPrice? = null, - private val groupedAllocation: NewPlanGroupedAllocationPrice? = null, - private val bulkWithProration: NewPlanBulkWithProrationPrice? = null, - private val groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice? = null, - private val groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice? = null, - private val groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds? = null, - private val matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice? = null, - private val groupedTieredPackage: NewPlanGroupedTieredPackagePrice? = null, - private val maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice? = null, - private val scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice? = - null, - private val scalableMatrixWithTieredPricing: - NewPlanScalableMatrixWithTieredPricingPrice? = - null, - private val cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice? = null, - private val minimum: NewPlanMinimumCompositePrice? = null, - private val percent: Percent? = null, - private val eventOutput: EventOutput? = null, - private val _json: JsonValue? = null, - ) { + (if (adjustmentId.asKnown() == null) 0 else 1) + + (if (planPhaseOrder.asKnown() == null) 0 else 1) - fun unit(): NewPlanUnitPrice? = unit + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun tiered(): NewPlanTieredPrice? = tiered + return other is RemoveAdjustment && + adjustmentId == other.adjustmentId && + planPhaseOrder == other.planPhaseOrder && + additionalProperties == other.additionalProperties + } - fun bulk(): NewPlanBulkPrice? = bulk + private val hashCode: Int by lazy { + Objects.hash(adjustmentId, planPhaseOrder, additionalProperties) + } - fun bulkWithFilters(): BulkWithFilters? = bulkWithFilters + override fun hashCode(): Int = hashCode - fun package_(): NewPlanPackagePrice? = package_ + override fun toString() = + "RemoveAdjustment{adjustmentId=$adjustmentId, planPhaseOrder=$planPhaseOrder, additionalProperties=$additionalProperties}" + } - fun matrix(): NewPlanMatrixPrice? = matrix + class RemovePrice + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val priceId: JsonField, + private val planPhaseOrder: JsonField, + private val additionalProperties: MutableMap, + ) { - fun thresholdTotalAmount(): NewPlanThresholdTotalAmountPrice? = thresholdTotalAmount + @JsonCreator + private constructor( + @JsonProperty("price_id") @ExcludeMissing priceId: JsonField = JsonMissing.of(), + @JsonProperty("plan_phase_order") + @ExcludeMissing + planPhaseOrder: JsonField = JsonMissing.of(), + ) : this(priceId, planPhaseOrder, mutableMapOf()) - fun tieredPackage(): NewPlanTieredPackagePrice? = tieredPackage + /** + * The id of the price to remove from the plan. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun priceId(): String = priceId.getRequired("price_id") - fun tieredWithMinimum(): NewPlanTieredWithMinimumPrice? = tieredWithMinimum + /** + * The phase to remove this price from. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun planPhaseOrder(): Long? = planPhaseOrder.getNullable("plan_phase_order") - fun groupedTiered(): NewPlanGroupedTieredPrice? = groupedTiered + /** + * Returns the raw JSON value of [priceId]. + * + * Unlike [priceId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId - fun tieredPackageWithMinimum(): NewPlanTieredPackageWithMinimumPrice? = - tieredPackageWithMinimum + /** + * Returns the raw JSON value of [planPhaseOrder]. + * + * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder - fun packageWithAllocation(): NewPlanPackageWithAllocationPrice? = packageWithAllocation + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - fun unitWithPercent(): NewPlanUnitWithPercentPrice? = unitWithPercent + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - fun matrixWithAllocation(): NewPlanMatrixWithAllocationPrice? = matrixWithAllocation + fun toBuilder() = Builder().from(this) - fun tieredWithProration(): TieredWithProration? = tieredWithProration + companion object { - fun unitWithProration(): NewPlanUnitWithProrationPrice? = unitWithProration + /** + * Returns a mutable builder for constructing an instance of [RemovePrice]. + * + * The following fields are required: + * ```kotlin + * .priceId() + * ``` + */ + fun builder() = Builder() + } - fun groupedAllocation(): NewPlanGroupedAllocationPrice? = groupedAllocation + /** A builder for [RemovePrice]. */ + class Builder internal constructor() { - fun bulkWithProration(): NewPlanBulkWithProrationPrice? = bulkWithProration + private var priceId: JsonField? = null + private var planPhaseOrder: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - fun groupedWithProratedMinimum(): NewPlanGroupedWithProratedMinimumPrice? = - groupedWithProratedMinimum + internal fun from(removePrice: RemovePrice) = apply { + priceId = removePrice.priceId + planPhaseOrder = removePrice.planPhaseOrder + additionalProperties = removePrice.additionalProperties.toMutableMap() + } - fun groupedWithMeteredMinimum(): NewPlanGroupedWithMeteredMinimumPrice? = - groupedWithMeteredMinimum + /** The id of the price to remove from the plan. */ + fun priceId(priceId: String) = priceId(JsonField.of(priceId)) - fun groupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds? = - groupedWithMinMaxThresholds + /** + * Sets [Builder.priceId] to an arbitrary JSON value. + * + * You should usually call [Builder.priceId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun priceId(priceId: JsonField) = apply { this.priceId = priceId } - fun matrixWithDisplayName(): NewPlanMatrixWithDisplayNamePrice? = matrixWithDisplayName + /** The phase to remove this price from. */ + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) - fun groupedTieredPackage(): NewPlanGroupedTieredPackagePrice? = groupedTieredPackage + /** + * Alias for [Builder.planPhaseOrder]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) - fun maxGroupTieredPackage(): NewPlanMaxGroupTieredPackagePrice? = maxGroupTieredPackage + /** + * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. + * + * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun planPhaseOrder(planPhaseOrder: JsonField) = apply { + this.planPhaseOrder = planPhaseOrder + } - fun scalableMatrixWithUnitPricing(): NewPlanScalableMatrixWithUnitPricingPrice? = - scalableMatrixWithUnitPricing + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun scalableMatrixWithTieredPricing(): NewPlanScalableMatrixWithTieredPricingPrice? = - scalableMatrixWithTieredPricing + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun cumulativeGroupedBulk(): NewPlanCumulativeGroupedBulkPrice? = cumulativeGroupedBulk + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun minimum(): NewPlanMinimumCompositePrice? = minimum + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - fun percent(): Percent? = percent + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - fun eventOutput(): EventOutput? = eventOutput + /** + * Returns an immutable instance of [RemovePrice]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .priceId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): RemovePrice = + RemovePrice( + checkRequired("priceId", priceId), + planPhaseOrder, + additionalProperties.toMutableMap(), + ) + } - fun isUnit(): Boolean = unit != null + private var validated: Boolean = false - fun isTiered(): Boolean = tiered != null + fun validate(): RemovePrice = apply { + if (validated) { + return@apply + } - fun isBulk(): Boolean = bulk != null + priceId() + planPhaseOrder() + validated = true + } - fun isBulkWithFilters(): Boolean = bulkWithFilters != null + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - fun isPackage(): Boolean = package_ != null + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (priceId.asKnown() == null) 0 else 1) + + (if (planPhaseOrder.asKnown() == null) 0 else 1) - fun isMatrix(): Boolean = matrix != null + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun isThresholdTotalAmount(): Boolean = thresholdTotalAmount != null + return other is RemovePrice && + priceId == other.priceId && + planPhaseOrder == other.planPhaseOrder && + additionalProperties == other.additionalProperties + } - fun isTieredPackage(): Boolean = tieredPackage != null + private val hashCode: Int by lazy { + Objects.hash(priceId, planPhaseOrder, additionalProperties) + } - fun isTieredWithMinimum(): Boolean = tieredWithMinimum != null + override fun hashCode(): Int = hashCode - fun isGroupedTiered(): Boolean = groupedTiered != null + override fun toString() = + "RemovePrice{priceId=$priceId, planPhaseOrder=$planPhaseOrder, additionalProperties=$additionalProperties}" + } - fun isTieredPackageWithMinimum(): Boolean = tieredPackageWithMinimum != null + class ReplaceAdjustment + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val adjustment: JsonField, + private val replacesAdjustmentId: JsonField, + private val planPhaseOrder: JsonField, + private val additionalProperties: MutableMap, + ) { - fun isPackageWithAllocation(): Boolean = packageWithAllocation != null + @JsonCreator + private constructor( + @JsonProperty("adjustment") + @ExcludeMissing + adjustment: JsonField = JsonMissing.of(), + @JsonProperty("replaces_adjustment_id") + @ExcludeMissing + replacesAdjustmentId: JsonField = JsonMissing.of(), + @JsonProperty("plan_phase_order") + @ExcludeMissing + planPhaseOrder: JsonField = JsonMissing.of(), + ) : this(adjustment, replacesAdjustmentId, planPhaseOrder, mutableMapOf()) - fun isUnitWithPercent(): Boolean = unitWithPercent != null + /** + * The definition of a new adjustment to create and add to the plan. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun adjustment(): Adjustment = adjustment.getRequired("adjustment") - fun isMatrixWithAllocation(): Boolean = matrixWithAllocation != null + /** + * The id of the adjustment on the plan to replace in the plan. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun replacesAdjustmentId(): String = + replacesAdjustmentId.getRequired("replaces_adjustment_id") - fun isTieredWithProration(): Boolean = tieredWithProration != null + /** + * The phase to replace this adjustment from. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun planPhaseOrder(): Long? = planPhaseOrder.getNullable("plan_phase_order") - fun isUnitWithProration(): Boolean = unitWithProration != null - - fun isGroupedAllocation(): Boolean = groupedAllocation != null - - fun isBulkWithProration(): Boolean = bulkWithProration != null - - fun isGroupedWithProratedMinimum(): Boolean = groupedWithProratedMinimum != null - - fun isGroupedWithMeteredMinimum(): Boolean = groupedWithMeteredMinimum != null + /** + * Returns the raw JSON value of [adjustment]. + * + * Unlike [adjustment], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("adjustment") + @ExcludeMissing + fun _adjustment(): JsonField = adjustment - fun isGroupedWithMinMaxThresholds(): Boolean = groupedWithMinMaxThresholds != null + /** + * Returns the raw JSON value of [replacesAdjustmentId]. + * + * Unlike [replacesAdjustmentId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("replaces_adjustment_id") + @ExcludeMissing + fun _replacesAdjustmentId(): JsonField = replacesAdjustmentId - fun isMatrixWithDisplayName(): Boolean = matrixWithDisplayName != null + /** + * Returns the raw JSON value of [planPhaseOrder]. + * + * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder - fun isGroupedTieredPackage(): Boolean = groupedTieredPackage != null + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - fun isMaxGroupTieredPackage(): Boolean = maxGroupTieredPackage != null + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - fun isScalableMatrixWithUnitPricing(): Boolean = scalableMatrixWithUnitPricing != null + fun toBuilder() = Builder().from(this) - fun isScalableMatrixWithTieredPricing(): Boolean = - scalableMatrixWithTieredPricing != null + companion object { - fun isCumulativeGroupedBulk(): Boolean = cumulativeGroupedBulk != null + /** + * Returns a mutable builder for constructing an instance of [ReplaceAdjustment]. + * + * The following fields are required: + * ```kotlin + * .adjustment() + * .replacesAdjustmentId() + * ``` + */ + fun builder() = Builder() + } - fun isMinimum(): Boolean = minimum != null + /** A builder for [ReplaceAdjustment]. */ + class Builder internal constructor() { - fun isPercent(): Boolean = percent != null + private var adjustment: JsonField? = null + private var replacesAdjustmentId: JsonField? = null + private var planPhaseOrder: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - fun isEventOutput(): Boolean = eventOutput != null + internal fun from(replaceAdjustment: ReplaceAdjustment) = apply { + adjustment = replaceAdjustment.adjustment + replacesAdjustmentId = replaceAdjustment.replacesAdjustmentId + planPhaseOrder = replaceAdjustment.planPhaseOrder + additionalProperties = replaceAdjustment.additionalProperties.toMutableMap() + } - fun asUnit(): NewPlanUnitPrice = unit.getOrThrow("unit") + /** The definition of a new adjustment to create and add to the plan. */ + fun adjustment(adjustment: Adjustment) = adjustment(JsonField.of(adjustment)) - fun asTiered(): NewPlanTieredPrice = tiered.getOrThrow("tiered") + /** + * Sets [Builder.adjustment] to an arbitrary JSON value. + * + * You should usually call [Builder.adjustment] with a well-typed [Adjustment] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun adjustment(adjustment: JsonField) = apply { + this.adjustment = adjustment + } - fun asBulk(): NewPlanBulkPrice = bulk.getOrThrow("bulk") + /** + * Alias for calling [adjustment] with + * `Adjustment.ofPercentageDiscount(percentageDiscount)`. + */ + fun adjustment(percentageDiscount: NewPercentageDiscount) = + adjustment(Adjustment.ofPercentageDiscount(percentageDiscount)) - fun asBulkWithFilters(): BulkWithFilters = bulkWithFilters.getOrThrow("bulkWithFilters") + /** + * Alias for calling [adjustment] with the following: + * ```kotlin + * NewPercentageDiscount.builder() + * .adjustmentType(NewPercentageDiscount.AdjustmentType.PERCENTAGE_DISCOUNT) + * .percentageDiscount(percentageDiscount) + * .build() + * ``` + */ + fun percentageDiscountAdjustment(percentageDiscount: Double) = + adjustment( + NewPercentageDiscount.builder() + .adjustmentType(NewPercentageDiscount.AdjustmentType.PERCENTAGE_DISCOUNT) + .percentageDiscount(percentageDiscount) + .build() + ) - fun asPackage(): NewPlanPackagePrice = package_.getOrThrow("package_") + /** Alias for calling [adjustment] with `Adjustment.ofUsageDiscount(usageDiscount)`. */ + fun adjustment(usageDiscount: NewUsageDiscount) = + adjustment(Adjustment.ofUsageDiscount(usageDiscount)) - fun asMatrix(): NewPlanMatrixPrice = matrix.getOrThrow("matrix") + /** + * Alias for calling [adjustment] with the following: + * ```kotlin + * NewUsageDiscount.builder() + * .adjustmentType(NewUsageDiscount.AdjustmentType.USAGE_DISCOUNT) + * .usageDiscount(usageDiscount) + * .build() + * ``` + */ + fun usageDiscountAdjustment(usageDiscount: Double) = + adjustment( + NewUsageDiscount.builder() + .adjustmentType(NewUsageDiscount.AdjustmentType.USAGE_DISCOUNT) + .usageDiscount(usageDiscount) + .build() + ) - fun asThresholdTotalAmount(): NewPlanThresholdTotalAmountPrice = - thresholdTotalAmount.getOrThrow("thresholdTotalAmount") + /** + * Alias for calling [adjustment] with `Adjustment.ofAmountDiscount(amountDiscount)`. + */ + fun adjustment(amountDiscount: NewAmountDiscount) = + adjustment(Adjustment.ofAmountDiscount(amountDiscount)) - fun asTieredPackage(): NewPlanTieredPackagePrice = - tieredPackage.getOrThrow("tieredPackage") + /** + * Alias for calling [adjustment] with the following: + * ```kotlin + * NewAmountDiscount.builder() + * .adjustmentType(NewAmountDiscount.AdjustmentType.AMOUNT_DISCOUNT) + * .amountDiscount(amountDiscount) + * .build() + * ``` + */ + fun amountDiscountAdjustment(amountDiscount: String) = + adjustment( + NewAmountDiscount.builder() + .adjustmentType(NewAmountDiscount.AdjustmentType.AMOUNT_DISCOUNT) + .amountDiscount(amountDiscount) + .build() + ) - fun asTieredWithMinimum(): NewPlanTieredWithMinimumPrice = - tieredWithMinimum.getOrThrow("tieredWithMinimum") + /** Alias for calling [adjustment] with `Adjustment.ofMinimum(minimum)`. */ + fun adjustment(minimum: NewMinimum) = adjustment(Adjustment.ofMinimum(minimum)) - fun asGroupedTiered(): NewPlanGroupedTieredPrice = - groupedTiered.getOrThrow("groupedTiered") + /** Alias for calling [adjustment] with `Adjustment.ofMaximum(maximum)`. */ + fun adjustment(maximum: NewMaximum) = adjustment(Adjustment.ofMaximum(maximum)) - fun asTieredPackageWithMinimum(): NewPlanTieredPackageWithMinimumPrice = - tieredPackageWithMinimum.getOrThrow("tieredPackageWithMinimum") + /** + * Alias for calling [adjustment] with the following: + * ```kotlin + * NewMaximum.builder() + * .adjustmentType(NewMaximum.AdjustmentType.MAXIMUM) + * .maximumAmount(maximumAmount) + * .build() + * ``` + */ + fun maximumAdjustment(maximumAmount: String) = + adjustment( + NewMaximum.builder() + .adjustmentType(NewMaximum.AdjustmentType.MAXIMUM) + .maximumAmount(maximumAmount) + .build() + ) - fun asPackageWithAllocation(): NewPlanPackageWithAllocationPrice = - packageWithAllocation.getOrThrow("packageWithAllocation") + /** The id of the adjustment on the plan to replace in the plan. */ + fun replacesAdjustmentId(replacesAdjustmentId: String) = + replacesAdjustmentId(JsonField.of(replacesAdjustmentId)) - fun asUnitWithPercent(): NewPlanUnitWithPercentPrice = - unitWithPercent.getOrThrow("unitWithPercent") + /** + * Sets [Builder.replacesAdjustmentId] to an arbitrary JSON value. + * + * You should usually call [Builder.replacesAdjustmentId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun replacesAdjustmentId(replacesAdjustmentId: JsonField) = apply { + this.replacesAdjustmentId = replacesAdjustmentId + } - fun asMatrixWithAllocation(): NewPlanMatrixWithAllocationPrice = - matrixWithAllocation.getOrThrow("matrixWithAllocation") + /** The phase to replace this adjustment from. */ + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) - fun asTieredWithProration(): TieredWithProration = - tieredWithProration.getOrThrow("tieredWithProration") + /** + * Alias for [Builder.planPhaseOrder]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) - fun asUnitWithProration(): NewPlanUnitWithProrationPrice = - unitWithProration.getOrThrow("unitWithProration") + /** + * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. + * + * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun planPhaseOrder(planPhaseOrder: JsonField) = apply { + this.planPhaseOrder = planPhaseOrder + } - fun asGroupedAllocation(): NewPlanGroupedAllocationPrice = - groupedAllocation.getOrThrow("groupedAllocation") + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun asBulkWithProration(): NewPlanBulkWithProrationPrice = - bulkWithProration.getOrThrow("bulkWithProration") + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun asGroupedWithProratedMinimum(): NewPlanGroupedWithProratedMinimumPrice = - groupedWithProratedMinimum.getOrThrow("groupedWithProratedMinimum") + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun asGroupedWithMeteredMinimum(): NewPlanGroupedWithMeteredMinimumPrice = - groupedWithMeteredMinimum.getOrThrow("groupedWithMeteredMinimum") + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - fun asGroupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds = - groupedWithMinMaxThresholds.getOrThrow("groupedWithMinMaxThresholds") + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - fun asMatrixWithDisplayName(): NewPlanMatrixWithDisplayNamePrice = - matrixWithDisplayName.getOrThrow("matrixWithDisplayName") + /** + * Returns an immutable instance of [ReplaceAdjustment]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .adjustment() + * .replacesAdjustmentId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ReplaceAdjustment = + ReplaceAdjustment( + checkRequired("adjustment", adjustment), + checkRequired("replacesAdjustmentId", replacesAdjustmentId), + planPhaseOrder, + additionalProperties.toMutableMap(), + ) + } - fun asGroupedTieredPackage(): NewPlanGroupedTieredPackagePrice = - groupedTieredPackage.getOrThrow("groupedTieredPackage") + private var validated: Boolean = false - fun asMaxGroupTieredPackage(): NewPlanMaxGroupTieredPackagePrice = - maxGroupTieredPackage.getOrThrow("maxGroupTieredPackage") + fun validate(): ReplaceAdjustment = apply { + if (validated) { + return@apply + } - fun asScalableMatrixWithUnitPricing(): NewPlanScalableMatrixWithUnitPricingPrice = - scalableMatrixWithUnitPricing.getOrThrow("scalableMatrixWithUnitPricing") + adjustment().validate() + replacesAdjustmentId() + planPhaseOrder() + validated = true + } - fun asScalableMatrixWithTieredPricing(): NewPlanScalableMatrixWithTieredPricingPrice = - scalableMatrixWithTieredPricing.getOrThrow("scalableMatrixWithTieredPricing") + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - fun asCumulativeGroupedBulk(): NewPlanCumulativeGroupedBulkPrice = - cumulativeGroupedBulk.getOrThrow("cumulativeGroupedBulk") + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (adjustment.asKnown()?.validity() ?: 0) + + (if (replacesAdjustmentId.asKnown() == null) 0 else 1) + + (if (planPhaseOrder.asKnown() == null) 0 else 1) - fun asMinimum(): NewPlanMinimumCompositePrice = minimum.getOrThrow("minimum") + /** The definition of a new adjustment to create and add to the plan. */ + @JsonDeserialize(using = Adjustment.Deserializer::class) + @JsonSerialize(using = Adjustment.Serializer::class) + class Adjustment + private constructor( + private val percentageDiscount: NewPercentageDiscount? = null, + private val usageDiscount: NewUsageDiscount? = null, + private val amountDiscount: NewAmountDiscount? = null, + private val minimum: NewMinimum? = null, + private val maximum: NewMaximum? = null, + private val _json: JsonValue? = null, + ) { - fun asPercent(): Percent = percent.getOrThrow("percent") + fun percentageDiscount(): NewPercentageDiscount? = percentageDiscount - fun asEventOutput(): EventOutput = eventOutput.getOrThrow("eventOutput") + fun usageDiscount(): NewUsageDiscount? = usageDiscount + + fun amountDiscount(): NewAmountDiscount? = amountDiscount + + fun minimum(): NewMinimum? = minimum + + fun maximum(): NewMaximum? = maximum + + fun isPercentageDiscount(): Boolean = percentageDiscount != null + + fun isUsageDiscount(): Boolean = usageDiscount != null + + fun isAmountDiscount(): Boolean = amountDiscount != null + + fun isMinimum(): Boolean = minimum != null + + fun isMaximum(): Boolean = maximum != null + + fun asPercentageDiscount(): NewPercentageDiscount = + percentageDiscount.getOrThrow("percentageDiscount") + + fun asUsageDiscount(): NewUsageDiscount = usageDiscount.getOrThrow("usageDiscount") + + fun asAmountDiscount(): NewAmountDiscount = amountDiscount.getOrThrow("amountDiscount") + + fun asMinimum(): NewMinimum = minimum.getOrThrow("minimum") + + fun asMaximum(): NewMaximum = maximum.getOrThrow("maximum") fun _json(): JsonValue? = _json fun accept(visitor: Visitor): T = when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - bulk != null -> visitor.visitBulk(bulk) - bulkWithFilters != null -> visitor.visitBulkWithFilters(bulkWithFilters) - package_ != null -> visitor.visitPackage(package_) - matrix != null -> visitor.visitMatrix(matrix) - thresholdTotalAmount != null -> - visitor.visitThresholdTotalAmount(thresholdTotalAmount) - tieredPackage != null -> visitor.visitTieredPackage(tieredPackage) - tieredWithMinimum != null -> visitor.visitTieredWithMinimum(tieredWithMinimum) - groupedTiered != null -> visitor.visitGroupedTiered(groupedTiered) - tieredPackageWithMinimum != null -> - visitor.visitTieredPackageWithMinimum(tieredPackageWithMinimum) - packageWithAllocation != null -> - visitor.visitPackageWithAllocation(packageWithAllocation) - unitWithPercent != null -> visitor.visitUnitWithPercent(unitWithPercent) - matrixWithAllocation != null -> - visitor.visitMatrixWithAllocation(matrixWithAllocation) - tieredWithProration != null -> - visitor.visitTieredWithProration(tieredWithProration) - unitWithProration != null -> visitor.visitUnitWithProration(unitWithProration) - groupedAllocation != null -> visitor.visitGroupedAllocation(groupedAllocation) - bulkWithProration != null -> visitor.visitBulkWithProration(bulkWithProration) - groupedWithProratedMinimum != null -> - visitor.visitGroupedWithProratedMinimum(groupedWithProratedMinimum) - groupedWithMeteredMinimum != null -> - visitor.visitGroupedWithMeteredMinimum(groupedWithMeteredMinimum) - groupedWithMinMaxThresholds != null -> - visitor.visitGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds) - matrixWithDisplayName != null -> - visitor.visitMatrixWithDisplayName(matrixWithDisplayName) - groupedTieredPackage != null -> - visitor.visitGroupedTieredPackage(groupedTieredPackage) - maxGroupTieredPackage != null -> - visitor.visitMaxGroupTieredPackage(maxGroupTieredPackage) - scalableMatrixWithUnitPricing != null -> - visitor.visitScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing) - scalableMatrixWithTieredPricing != null -> - visitor.visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing - ) - cumulativeGroupedBulk != null -> - visitor.visitCumulativeGroupedBulk(cumulativeGroupedBulk) + percentageDiscount != null -> + visitor.visitPercentageDiscount(percentageDiscount) + usageDiscount != null -> visitor.visitUsageDiscount(usageDiscount) + amountDiscount != null -> visitor.visitAmountDiscount(amountDiscount) minimum != null -> visitor.visitMinimum(minimum) - percent != null -> visitor.visitPercent(percent) - eventOutput != null -> visitor.visitEventOutput(eventOutput) + maximum != null -> visitor.visitMaximum(maximum) else -> visitor.unknown(_json) } private var validated: Boolean = false - fun validate(): Price = apply { + fun validate(): Adjustment = apply { if (validated) { return@apply } accept( object : Visitor { - override fun visitUnit(unit: NewPlanUnitPrice) { - unit.validate() - } - - override fun visitTiered(tiered: NewPlanTieredPrice) { - tiered.validate() + override fun visitPercentageDiscount( + percentageDiscount: NewPercentageDiscount + ) { + percentageDiscount.validate() } - override fun visitBulk(bulk: NewPlanBulkPrice) { - bulk.validate() + override fun visitUsageDiscount(usageDiscount: NewUsageDiscount) { + usageDiscount.validate() } - override fun visitBulkWithFilters(bulkWithFilters: BulkWithFilters) { - bulkWithFilters.validate() + override fun visitAmountDiscount(amountDiscount: NewAmountDiscount) { + amountDiscount.validate() } - override fun visitPackage(package_: NewPlanPackagePrice) { - package_.validate() + override fun visitMinimum(minimum: NewMinimum) { + minimum.validate() } - override fun visitMatrix(matrix: NewPlanMatrixPrice) { - matrix.validate() + override fun visitMaximum(maximum: NewMaximum) { + maximum.validate() } + } + ) + validated = true + } - override fun visitThresholdTotalAmount( - thresholdTotalAmount: NewPlanThresholdTotalAmountPrice - ) { - thresholdTotalAmount.validate() - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - override fun visitTieredPackage(tieredPackage: NewPlanTieredPackagePrice) { - tieredPackage.validate() - } + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitPercentageDiscount( + percentageDiscount: NewPercentageDiscount + ) = percentageDiscount.validity() - override fun visitTieredWithMinimum( - tieredWithMinimum: NewPlanTieredWithMinimumPrice - ) { - tieredWithMinimum.validate() - } + override fun visitUsageDiscount(usageDiscount: NewUsageDiscount) = + usageDiscount.validity() - override fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) { - groupedTiered.validate() - } + override fun visitAmountDiscount(amountDiscount: NewAmountDiscount) = + amountDiscount.validity() - override fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice - ) { - tieredPackageWithMinimum.validate() - } + override fun visitMinimum(minimum: NewMinimum) = minimum.validity() - override fun visitPackageWithAllocation( - packageWithAllocation: NewPlanPackageWithAllocationPrice - ) { - packageWithAllocation.validate() - } + override fun visitMaximum(maximum: NewMaximum) = maximum.validity() - override fun visitUnitWithPercent( - unitWithPercent: NewPlanUnitWithPercentPrice - ) { - unitWithPercent.validate() - } + override fun unknown(json: JsonValue?) = 0 + } + ) - override fun visitMatrixWithAllocation( - matrixWithAllocation: NewPlanMatrixWithAllocationPrice - ) { - matrixWithAllocation.validate() - } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - override fun visitTieredWithProration( - tieredWithProration: TieredWithProration - ) { - tieredWithProration.validate() - } - - override fun visitUnitWithProration( - unitWithProration: NewPlanUnitWithProrationPrice - ) { - unitWithProration.validate() - } - - override fun visitGroupedAllocation( - groupedAllocation: NewPlanGroupedAllocationPrice - ) { - groupedAllocation.validate() - } - - override fun visitBulkWithProration( - bulkWithProration: NewPlanBulkWithProrationPrice - ) { - bulkWithProration.validate() - } - - override fun visitGroupedWithProratedMinimum( - groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice - ) { - groupedWithProratedMinimum.validate() - } - - override fun visitGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice - ) { - groupedWithMeteredMinimum.validate() - } - - override fun visitGroupedWithMinMaxThresholds( - groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds - ) { - groupedWithMinMaxThresholds.validate() - } - - override fun visitMatrixWithDisplayName( - matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice - ) { - matrixWithDisplayName.validate() - } + return other is Adjustment && + percentageDiscount == other.percentageDiscount && + usageDiscount == other.usageDiscount && + amountDiscount == other.amountDiscount && + minimum == other.minimum && + maximum == other.maximum + } - override fun visitGroupedTieredPackage( - groupedTieredPackage: NewPlanGroupedTieredPackagePrice - ) { - groupedTieredPackage.validate() - } + override fun hashCode(): Int = + Objects.hash(percentageDiscount, usageDiscount, amountDiscount, minimum, maximum) - override fun visitMaxGroupTieredPackage( - maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice - ) { - maxGroupTieredPackage.validate() - } + override fun toString(): String = + when { + percentageDiscount != null -> + "Adjustment{percentageDiscount=$percentageDiscount}" + usageDiscount != null -> "Adjustment{usageDiscount=$usageDiscount}" + amountDiscount != null -> "Adjustment{amountDiscount=$amountDiscount}" + minimum != null -> "Adjustment{minimum=$minimum}" + maximum != null -> "Adjustment{maximum=$maximum}" + _json != null -> "Adjustment{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Adjustment") + } - override fun visitScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice - ) { - scalableMatrixWithUnitPricing.validate() - } + companion object { - override fun visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: - NewPlanScalableMatrixWithTieredPricingPrice - ) { - scalableMatrixWithTieredPricing.validate() - } + fun ofPercentageDiscount(percentageDiscount: NewPercentageDiscount) = + Adjustment(percentageDiscount = percentageDiscount) - override fun visitCumulativeGroupedBulk( - cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice - ) { - cumulativeGroupedBulk.validate() - } + fun ofUsageDiscount(usageDiscount: NewUsageDiscount) = + Adjustment(usageDiscount = usageDiscount) - override fun visitMinimum(minimum: NewPlanMinimumCompositePrice) { - minimum.validate() - } + fun ofAmountDiscount(amountDiscount: NewAmountDiscount) = + Adjustment(amountDiscount = amountDiscount) - override fun visitPercent(percent: Percent) { - percent.validate() - } + fun ofMinimum(minimum: NewMinimum) = Adjustment(minimum = minimum) - override fun visitEventOutput(eventOutput: EventOutput) { - eventOutput.validate() - } - } - ) - validated = true + fun ofMaximum(maximum: NewMaximum) = Adjustment(maximum = maximum) } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. + * An interface that defines how to map each variant of [Adjustment] to a value of type + * [T]. */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: NewPlanUnitPrice) = unit.validity() + interface Visitor { - override fun visitTiered(tiered: NewPlanTieredPrice) = tiered.validity() + fun visitPercentageDiscount(percentageDiscount: NewPercentageDiscount): T - override fun visitBulk(bulk: NewPlanBulkPrice) = bulk.validity() + fun visitUsageDiscount(usageDiscount: NewUsageDiscount): T - override fun visitBulkWithFilters(bulkWithFilters: BulkWithFilters) = - bulkWithFilters.validity() + fun visitAmountDiscount(amountDiscount: NewAmountDiscount): T - override fun visitPackage(package_: NewPlanPackagePrice) = - package_.validity() + fun visitMinimum(minimum: NewMinimum): T - override fun visitMatrix(matrix: NewPlanMatrixPrice) = matrix.validity() + fun visitMaximum(maximum: NewMaximum): T - override fun visitThresholdTotalAmount( - thresholdTotalAmount: NewPlanThresholdTotalAmountPrice - ) = thresholdTotalAmount.validity() + /** + * Maps an unknown variant of [Adjustment] to a value of type [T]. + * + * An instance of [Adjustment] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the + * SDK is unaware of. + * + * @throws OrbInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw OrbInvalidDataException("Unknown Adjustment: $json") + } + } - override fun visitTieredPackage(tieredPackage: NewPlanTieredPackagePrice) = - tieredPackage.validity() + internal class Deserializer : BaseDeserializer(Adjustment::class) { - override fun visitTieredWithMinimum( - tieredWithMinimum: NewPlanTieredWithMinimumPrice - ) = tieredWithMinimum.validity() + override fun ObjectCodec.deserialize(node: JsonNode): Adjustment { + val json = JsonValue.fromJsonNode(node) + val adjustmentType = json.asObject()?.get("adjustment_type")?.asString() - override fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) = - groupedTiered.validity() + when (adjustmentType) { + "percentage_discount" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Adjustment(percentageDiscount = it, _json = json) } + ?: Adjustment(_json = json) + } + "usage_discount" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(usageDiscount = it, _json = json) + } ?: Adjustment(_json = json) + } + "amount_discount" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(amountDiscount = it, _json = json) + } ?: Adjustment(_json = json) + } + "minimum" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(minimum = it, _json = json) + } ?: Adjustment(_json = json) + } + "maximum" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(maximum = it, _json = json) + } ?: Adjustment(_json = json) + } + } - override fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice - ) = tieredPackageWithMinimum.validity() + return Adjustment(_json = json) + } + } - override fun visitPackageWithAllocation( - packageWithAllocation: NewPlanPackageWithAllocationPrice - ) = packageWithAllocation.validity() + internal class Serializer : BaseSerializer(Adjustment::class) { - override fun visitUnitWithPercent( - unitWithPercent: NewPlanUnitWithPercentPrice - ) = unitWithPercent.validity() + override fun serialize( + value: Adjustment, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.percentageDiscount != null -> + generator.writeObject(value.percentageDiscount) + value.usageDiscount != null -> generator.writeObject(value.usageDiscount) + value.amountDiscount != null -> generator.writeObject(value.amountDiscount) + value.minimum != null -> generator.writeObject(value.minimum) + value.maximum != null -> generator.writeObject(value.maximum) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Adjustment") + } + } + } + } - override fun visitMatrixWithAllocation( - matrixWithAllocation: NewPlanMatrixWithAllocationPrice - ) = matrixWithAllocation.validity() + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - override fun visitTieredWithProration( - tieredWithProration: TieredWithProration - ) = tieredWithProration.validity() + return other is ReplaceAdjustment && + adjustment == other.adjustment && + replacesAdjustmentId == other.replacesAdjustmentId && + planPhaseOrder == other.planPhaseOrder && + additionalProperties == other.additionalProperties + } - override fun visitUnitWithProration( - unitWithProration: NewPlanUnitWithProrationPrice - ) = unitWithProration.validity() + private val hashCode: Int by lazy { + Objects.hash(adjustment, replacesAdjustmentId, planPhaseOrder, additionalProperties) + } - override fun visitGroupedAllocation( - groupedAllocation: NewPlanGroupedAllocationPrice - ) = groupedAllocation.validity() + override fun hashCode(): Int = hashCode - override fun visitBulkWithProration( - bulkWithProration: NewPlanBulkWithProrationPrice - ) = bulkWithProration.validity() + override fun toString() = + "ReplaceAdjustment{adjustment=$adjustment, replacesAdjustmentId=$replacesAdjustmentId, planPhaseOrder=$planPhaseOrder, additionalProperties=$additionalProperties}" + } - override fun visitGroupedWithProratedMinimum( - groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice - ) = groupedWithProratedMinimum.validity() + class ReplacePrice + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val replacesPriceId: JsonField, + private val allocationPrice: JsonField, + private val planPhaseOrder: JsonField, + private val price: JsonField, + private val additionalProperties: MutableMap, + ) { - override fun visitGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice - ) = groupedWithMeteredMinimum.validity() + @JsonCreator + private constructor( + @JsonProperty("replaces_price_id") + @ExcludeMissing + replacesPriceId: JsonField = JsonMissing.of(), + @JsonProperty("allocation_price") + @ExcludeMissing + allocationPrice: JsonField = JsonMissing.of(), + @JsonProperty("plan_phase_order") + @ExcludeMissing + planPhaseOrder: JsonField = JsonMissing.of(), + @JsonProperty("price") @ExcludeMissing price: JsonField = JsonMissing.of(), + ) : this(replacesPriceId, allocationPrice, planPhaseOrder, price, mutableMapOf()) - override fun visitGroupedWithMinMaxThresholds( - groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds - ) = groupedWithMinMaxThresholds.validity() + /** + * The id of the price on the plan to replace in the plan. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun replacesPriceId(): String = replacesPriceId.getRequired("replaces_price_id") - override fun visitMatrixWithDisplayName( - matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice - ) = matrixWithDisplayName.validity() + /** + * The allocation price to add to the plan. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun allocationPrice(): NewAllocationPrice? = allocationPrice.getNullable("allocation_price") - override fun visitGroupedTieredPackage( - groupedTieredPackage: NewPlanGroupedTieredPackagePrice - ) = groupedTieredPackage.validity() + /** + * The phase to replace this price from. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun planPhaseOrder(): Long? = planPhaseOrder.getNullable("plan_phase_order") - override fun visitMaxGroupTieredPackage( - maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice - ) = maxGroupTieredPackage.validity() + /** + * New plan price request body params. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun price(): Price? = price.getNullable("price") - override fun visitScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice - ) = scalableMatrixWithUnitPricing.validity() + /** + * Returns the raw JSON value of [replacesPriceId]. + * + * Unlike [replacesPriceId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("replaces_price_id") + @ExcludeMissing + fun _replacesPriceId(): JsonField = replacesPriceId - override fun visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: - NewPlanScalableMatrixWithTieredPricingPrice - ) = scalableMatrixWithTieredPricing.validity() + /** + * Returns the raw JSON value of [allocationPrice]. + * + * Unlike [allocationPrice], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("allocation_price") + @ExcludeMissing + fun _allocationPrice(): JsonField = allocationPrice - override fun visitCumulativeGroupedBulk( - cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice - ) = cumulativeGroupedBulk.validity() + /** + * Returns the raw JSON value of [planPhaseOrder]. + * + * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder - override fun visitMinimum(minimum: NewPlanMinimumCompositePrice) = - minimum.validity() + /** + * Returns the raw JSON value of [price]. + * + * Unlike [price], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("price") @ExcludeMissing fun _price(): JsonField = price - override fun visitPercent(percent: Percent) = percent.validity() + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - override fun visitEventOutput(eventOutput: EventOutput) = - eventOutput.validity() + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - override fun unknown(json: JsonValue?) = 0 - } - ) + fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + companion object { - return other is Price && - unit == other.unit && - tiered == other.tiered && - bulk == other.bulk && - bulkWithFilters == other.bulkWithFilters && - package_ == other.package_ && - matrix == other.matrix && - thresholdTotalAmount == other.thresholdTotalAmount && - tieredPackage == other.tieredPackage && - tieredWithMinimum == other.tieredWithMinimum && - groupedTiered == other.groupedTiered && - tieredPackageWithMinimum == other.tieredPackageWithMinimum && - packageWithAllocation == other.packageWithAllocation && - unitWithPercent == other.unitWithPercent && - matrixWithAllocation == other.matrixWithAllocation && - tieredWithProration == other.tieredWithProration && - unitWithProration == other.unitWithProration && - groupedAllocation == other.groupedAllocation && - bulkWithProration == other.bulkWithProration && - groupedWithProratedMinimum == other.groupedWithProratedMinimum && - groupedWithMeteredMinimum == other.groupedWithMeteredMinimum && - groupedWithMinMaxThresholds == other.groupedWithMinMaxThresholds && - matrixWithDisplayName == other.matrixWithDisplayName && - groupedTieredPackage == other.groupedTieredPackage && - maxGroupTieredPackage == other.maxGroupTieredPackage && - scalableMatrixWithUnitPricing == other.scalableMatrixWithUnitPricing && - scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && - cumulativeGroupedBulk == other.cumulativeGroupedBulk && - minimum == other.minimum && - percent == other.percent && - eventOutput == other.eventOutput + /** + * Returns a mutable builder for constructing an instance of [ReplacePrice]. + * + * The following fields are required: + * ```kotlin + * .replacesPriceId() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [ReplacePrice]. */ + class Builder internal constructor() { + + private var replacesPriceId: JsonField? = null + private var allocationPrice: JsonField = JsonMissing.of() + private var planPhaseOrder: JsonField = JsonMissing.of() + private var price: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(replacePrice: ReplacePrice) = apply { + replacesPriceId = replacePrice.replacesPriceId + allocationPrice = replacePrice.allocationPrice + planPhaseOrder = replacePrice.planPhaseOrder + price = replacePrice.price + additionalProperties = replacePrice.additionalProperties.toMutableMap() } - override fun hashCode(): Int = - Objects.hash( - unit, - tiered, - bulk, - bulkWithFilters, - package_, - matrix, - thresholdTotalAmount, - tieredPackage, - tieredWithMinimum, - groupedTiered, - tieredPackageWithMinimum, - packageWithAllocation, - unitWithPercent, - matrixWithAllocation, - tieredWithProration, - unitWithProration, - groupedAllocation, - bulkWithProration, - groupedWithProratedMinimum, - groupedWithMeteredMinimum, - groupedWithMinMaxThresholds, - matrixWithDisplayName, - groupedTieredPackage, - maxGroupTieredPackage, - scalableMatrixWithUnitPricing, - scalableMatrixWithTieredPricing, - cumulativeGroupedBulk, - minimum, - percent, - eventOutput, - ) + /** The id of the price on the plan to replace in the plan. */ + fun replacesPriceId(replacesPriceId: String) = + replacesPriceId(JsonField.of(replacesPriceId)) - override fun toString(): String = - when { - unit != null -> "Price{unit=$unit}" - tiered != null -> "Price{tiered=$tiered}" - bulk != null -> "Price{bulk=$bulk}" - bulkWithFilters != null -> "Price{bulkWithFilters=$bulkWithFilters}" - package_ != null -> "Price{package_=$package_}" - matrix != null -> "Price{matrix=$matrix}" - thresholdTotalAmount != null -> - "Price{thresholdTotalAmount=$thresholdTotalAmount}" - tieredPackage != null -> "Price{tieredPackage=$tieredPackage}" - tieredWithMinimum != null -> "Price{tieredWithMinimum=$tieredWithMinimum}" - groupedTiered != null -> "Price{groupedTiered=$groupedTiered}" - tieredPackageWithMinimum != null -> - "Price{tieredPackageWithMinimum=$tieredPackageWithMinimum}" - packageWithAllocation != null -> - "Price{packageWithAllocation=$packageWithAllocation}" - unitWithPercent != null -> "Price{unitWithPercent=$unitWithPercent}" - matrixWithAllocation != null -> - "Price{matrixWithAllocation=$matrixWithAllocation}" - tieredWithProration != null -> "Price{tieredWithProration=$tieredWithProration}" - unitWithProration != null -> "Price{unitWithProration=$unitWithProration}" - groupedAllocation != null -> "Price{groupedAllocation=$groupedAllocation}" - bulkWithProration != null -> "Price{bulkWithProration=$bulkWithProration}" - groupedWithProratedMinimum != null -> - "Price{groupedWithProratedMinimum=$groupedWithProratedMinimum}" - groupedWithMeteredMinimum != null -> - "Price{groupedWithMeteredMinimum=$groupedWithMeteredMinimum}" - groupedWithMinMaxThresholds != null -> - "Price{groupedWithMinMaxThresholds=$groupedWithMinMaxThresholds}" - matrixWithDisplayName != null -> - "Price{matrixWithDisplayName=$matrixWithDisplayName}" - groupedTieredPackage != null -> - "Price{groupedTieredPackage=$groupedTieredPackage}" - maxGroupTieredPackage != null -> - "Price{maxGroupTieredPackage=$maxGroupTieredPackage}" - scalableMatrixWithUnitPricing != null -> - "Price{scalableMatrixWithUnitPricing=$scalableMatrixWithUnitPricing}" - scalableMatrixWithTieredPricing != null -> - "Price{scalableMatrixWithTieredPricing=$scalableMatrixWithTieredPricing}" - cumulativeGroupedBulk != null -> - "Price{cumulativeGroupedBulk=$cumulativeGroupedBulk}" - minimum != null -> "Price{minimum=$minimum}" - percent != null -> "Price{percent=$percent}" - eventOutput != null -> "Price{eventOutput=$eventOutput}" - _json != null -> "Price{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Price") - } - - companion object { + /** + * Sets [Builder.replacesPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.replacesPriceId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun replacesPriceId(replacesPriceId: JsonField) = apply { + this.replacesPriceId = replacesPriceId + } - fun ofUnit(unit: NewPlanUnitPrice) = Price(unit = unit) + /** The allocation price to add to the plan. */ + fun allocationPrice(allocationPrice: NewAllocationPrice?) = + allocationPrice(JsonField.ofNullable(allocationPrice)) - fun ofTiered(tiered: NewPlanTieredPrice) = Price(tiered = tiered) + /** + * Sets [Builder.allocationPrice] to an arbitrary JSON value. + * + * You should usually call [Builder.allocationPrice] with a well-typed + * [NewAllocationPrice] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun allocationPrice(allocationPrice: JsonField) = apply { + this.allocationPrice = allocationPrice + } - fun ofBulk(bulk: NewPlanBulkPrice) = Price(bulk = bulk) + /** The phase to replace this price from. */ + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) - fun ofBulkWithFilters(bulkWithFilters: BulkWithFilters) = - Price(bulkWithFilters = bulkWithFilters) + /** + * Alias for [Builder.planPhaseOrder]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) - fun ofPackage(package_: NewPlanPackagePrice) = Price(package_ = package_) + /** + * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. + * + * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun planPhaseOrder(planPhaseOrder: JsonField) = apply { + this.planPhaseOrder = planPhaseOrder + } - fun ofMatrix(matrix: NewPlanMatrixPrice) = Price(matrix = matrix) + /** New plan price request body params. */ + fun price(price: Price?) = price(JsonField.ofNullable(price)) - fun ofThresholdTotalAmount(thresholdTotalAmount: NewPlanThresholdTotalAmountPrice) = - Price(thresholdTotalAmount = thresholdTotalAmount) + /** + * Sets [Builder.price] to an arbitrary JSON value. + * + * You should usually call [Builder.price] with a well-typed [Price] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun price(price: JsonField) = apply { this.price = price } - fun ofTieredPackage(tieredPackage: NewPlanTieredPackagePrice) = - Price(tieredPackage = tieredPackage) + /** Alias for calling [price] with `Price.ofUnit(unit)`. */ + fun price(unit: NewPlanUnitPrice) = price(Price.ofUnit(unit)) - fun ofTieredWithMinimum(tieredWithMinimum: NewPlanTieredWithMinimumPrice) = - Price(tieredWithMinimum = tieredWithMinimum) + /** Alias for calling [price] with `Price.ofTiered(tiered)`. */ + fun price(tiered: NewPlanTieredPrice) = price(Price.ofTiered(tiered)) - fun ofGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) = - Price(groupedTiered = groupedTiered) + /** Alias for calling [price] with `Price.ofBulk(bulk)`. */ + fun price(bulk: NewPlanBulkPrice) = price(Price.ofBulk(bulk)) - fun ofTieredPackageWithMinimum( - tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice - ) = Price(tieredPackageWithMinimum = tieredPackageWithMinimum) + /** Alias for calling [price] with `Price.ofBulkWithFilters(bulkWithFilters)`. */ + fun price(bulkWithFilters: Price.BulkWithFilters) = + price(Price.ofBulkWithFilters(bulkWithFilters)) - fun ofPackageWithAllocation( - packageWithAllocation: NewPlanPackageWithAllocationPrice - ) = Price(packageWithAllocation = packageWithAllocation) + /** Alias for calling [price] with `Price.ofPackage(package_)`. */ + fun price(package_: NewPlanPackagePrice) = price(Price.ofPackage(package_)) - fun ofUnitWithPercent(unitWithPercent: NewPlanUnitWithPercentPrice) = - Price(unitWithPercent = unitWithPercent) + /** Alias for calling [price] with `Price.ofMatrix(matrix)`. */ + fun price(matrix: NewPlanMatrixPrice) = price(Price.ofMatrix(matrix)) - fun ofMatrixWithAllocation(matrixWithAllocation: NewPlanMatrixWithAllocationPrice) = - Price(matrixWithAllocation = matrixWithAllocation) + /** + * Alias for calling [price] with `Price.ofThresholdTotalAmount(thresholdTotalAmount)`. + */ + fun price(thresholdTotalAmount: NewPlanThresholdTotalAmountPrice) = + price(Price.ofThresholdTotalAmount(thresholdTotalAmount)) - fun ofTieredWithProration(tieredWithProration: TieredWithProration) = - Price(tieredWithProration = tieredWithProration) + /** Alias for calling [price] with `Price.ofTieredPackage(tieredPackage)`. */ + fun price(tieredPackage: NewPlanTieredPackagePrice) = + price(Price.ofTieredPackage(tieredPackage)) - fun ofUnitWithProration(unitWithProration: NewPlanUnitWithProrationPrice) = - Price(unitWithProration = unitWithProration) + /** Alias for calling [price] with `Price.ofTieredWithMinimum(tieredWithMinimum)`. */ + fun price(tieredWithMinimum: NewPlanTieredWithMinimumPrice) = + price(Price.ofTieredWithMinimum(tieredWithMinimum)) - fun ofGroupedAllocation(groupedAllocation: NewPlanGroupedAllocationPrice) = - Price(groupedAllocation = groupedAllocation) + /** Alias for calling [price] with `Price.ofGroupedTiered(groupedTiered)`. */ + fun price(groupedTiered: NewPlanGroupedTieredPrice) = + price(Price.ofGroupedTiered(groupedTiered)) - fun ofBulkWithProration(bulkWithProration: NewPlanBulkWithProrationPrice) = - Price(bulkWithProration = bulkWithProration) + /** + * Alias for calling [price] with + * `Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)`. + */ + fun price(tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice) = + price(Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)) - fun ofGroupedWithProratedMinimum( - groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice - ) = Price(groupedWithProratedMinimum = groupedWithProratedMinimum) + /** + * Alias for calling [price] with + * `Price.ofPackageWithAllocation(packageWithAllocation)`. + */ + fun price(packageWithAllocation: NewPlanPackageWithAllocationPrice) = + price(Price.ofPackageWithAllocation(packageWithAllocation)) - fun ofGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice - ) = Price(groupedWithMeteredMinimum = groupedWithMeteredMinimum) + /** Alias for calling [price] with `Price.ofUnitWithPercent(unitWithPercent)`. */ + fun price(unitWithPercent: NewPlanUnitWithPercentPrice) = + price(Price.ofUnitWithPercent(unitWithPercent)) - fun ofGroupedWithMinMaxThresholds( - groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds - ) = Price(groupedWithMinMaxThresholds = groupedWithMinMaxThresholds) + /** + * Alias for calling [price] with `Price.ofMatrixWithAllocation(matrixWithAllocation)`. + */ + fun price(matrixWithAllocation: NewPlanMatrixWithAllocationPrice) = + price(Price.ofMatrixWithAllocation(matrixWithAllocation)) - fun ofMatrixWithDisplayName( - matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice - ) = Price(matrixWithDisplayName = matrixWithDisplayName) + /** + * Alias for calling [price] with `Price.ofTieredWithProration(tieredWithProration)`. + */ + fun price(tieredWithProration: Price.TieredWithProration) = + price(Price.ofTieredWithProration(tieredWithProration)) - fun ofGroupedTieredPackage(groupedTieredPackage: NewPlanGroupedTieredPackagePrice) = - Price(groupedTieredPackage = groupedTieredPackage) + /** Alias for calling [price] with `Price.ofUnitWithProration(unitWithProration)`. */ + fun price(unitWithProration: NewPlanUnitWithProrationPrice) = + price(Price.ofUnitWithProration(unitWithProration)) - fun ofMaxGroupTieredPackage( - maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice - ) = Price(maxGroupTieredPackage = maxGroupTieredPackage) + /** Alias for calling [price] with `Price.ofGroupedAllocation(groupedAllocation)`. */ + fun price(groupedAllocation: NewPlanGroupedAllocationPrice) = + price(Price.ofGroupedAllocation(groupedAllocation)) - fun ofScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice - ) = Price(scalableMatrixWithUnitPricing = scalableMatrixWithUnitPricing) + /** Alias for calling [price] with `Price.ofBulkWithProration(bulkWithProration)`. */ + fun price(bulkWithProration: NewPlanBulkWithProrationPrice) = + price(Price.ofBulkWithProration(bulkWithProration)) - fun ofScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: NewPlanScalableMatrixWithTieredPricingPrice - ) = Price(scalableMatrixWithTieredPricing = scalableMatrixWithTieredPricing) + /** + * Alias for calling [price] with + * `Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)`. + */ + fun price(groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice) = + price(Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)) - fun ofCumulativeGroupedBulk( - cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice - ) = Price(cumulativeGroupedBulk = cumulativeGroupedBulk) + /** + * Alias for calling [price] with + * `Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)`. + */ + fun price(groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice) = + price(Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)) - fun ofMinimum(minimum: NewPlanMinimumCompositePrice) = Price(minimum = minimum) + /** + * Alias for calling [price] with + * `Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)`. + */ + fun price(groupedWithMinMaxThresholds: Price.GroupedWithMinMaxThresholds) = + price(Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)) - fun ofPercent(percent: Percent) = Price(percent = percent) + /** + * Alias for calling [price] with + * `Price.ofMatrixWithDisplayName(matrixWithDisplayName)`. + */ + fun price(matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice) = + price(Price.ofMatrixWithDisplayName(matrixWithDisplayName)) - fun ofEventOutput(eventOutput: EventOutput) = Price(eventOutput = eventOutput) - } + /** + * Alias for calling [price] with `Price.ofGroupedTieredPackage(groupedTieredPackage)`. + */ + fun price(groupedTieredPackage: NewPlanGroupedTieredPackagePrice) = + price(Price.ofGroupedTieredPackage(groupedTieredPackage)) /** - * An interface that defines how to map each variant of [Price] to a value of type [T]. + * Alias for calling [price] with + * `Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)`. */ - interface Visitor { + fun price(maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice) = + price(Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)) - fun visitUnit(unit: NewPlanUnitPrice): T + /** + * Alias for calling [price] with + * `Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)`. + */ + fun price(scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice) = + price(Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)) - fun visitTiered(tiered: NewPlanTieredPrice): T + /** + * Alias for calling [price] with + * `Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)`. + */ + fun price( + scalableMatrixWithTieredPricing: NewPlanScalableMatrixWithTieredPricingPrice + ) = price(Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)) - fun visitBulk(bulk: NewPlanBulkPrice): T + /** + * Alias for calling [price] with + * `Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)`. + */ + fun price(cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice) = + price(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) - fun visitBulkWithFilters(bulkWithFilters: BulkWithFilters): T + /** + * Alias for calling [price] with + * `Price.ofCumulativeGroupedAllocation(cumulativeGroupedAllocation)`. + */ + fun price(cumulativeGroupedAllocation: Price.CumulativeGroupedAllocation) = + price(Price.ofCumulativeGroupedAllocation(cumulativeGroupedAllocation)) - fun visitPackage(package_: NewPlanPackagePrice): T + /** Alias for calling [price] with `Price.ofMinimum(minimum)`. */ + fun price(minimum: NewPlanMinimumCompositePrice) = price(Price.ofMinimum(minimum)) - fun visitMatrix(matrix: NewPlanMatrixPrice): T + /** Alias for calling [price] with `Price.ofPercent(percent)`. */ + fun price(percent: Price.Percent) = price(Price.ofPercent(percent)) - fun visitThresholdTotalAmount( - thresholdTotalAmount: NewPlanThresholdTotalAmountPrice - ): T + /** Alias for calling [price] with `Price.ofEventOutput(eventOutput)`. */ + fun price(eventOutput: Price.EventOutput) = price(Price.ofEventOutput(eventOutput)) - fun visitTieredPackage(tieredPackage: NewPlanTieredPackagePrice): T + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun visitTieredWithMinimum(tieredWithMinimum: NewPlanTieredWithMinimumPrice): T + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice): T + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice - ): T + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - fun visitPackageWithAllocation( - packageWithAllocation: NewPlanPackageWithAllocationPrice - ): T + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - fun visitUnitWithPercent(unitWithPercent: NewPlanUnitWithPercentPrice): T + /** + * Returns an immutable instance of [ReplacePrice]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .replacesPriceId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ReplacePrice = + ReplacePrice( + checkRequired("replacesPriceId", replacesPriceId), + allocationPrice, + planPhaseOrder, + price, + additionalProperties.toMutableMap(), + ) + } - fun visitMatrixWithAllocation( - matrixWithAllocation: NewPlanMatrixWithAllocationPrice - ): T + private var validated: Boolean = false - fun visitTieredWithProration(tieredWithProration: TieredWithProration): T + fun validate(): ReplacePrice = apply { + if (validated) { + return@apply + } - fun visitUnitWithProration(unitWithProration: NewPlanUnitWithProrationPrice): T + replacesPriceId() + allocationPrice()?.validate() + planPhaseOrder() + price()?.validate() + validated = true + } - fun visitGroupedAllocation(groupedAllocation: NewPlanGroupedAllocationPrice): T + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - fun visitBulkWithProration(bulkWithProration: NewPlanBulkWithProrationPrice): T + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (replacesPriceId.asKnown() == null) 0 else 1) + + (allocationPrice.asKnown()?.validity() ?: 0) + + (if (planPhaseOrder.asKnown() == null) 0 else 1) + + (price.asKnown()?.validity() ?: 0) - fun visitGroupedWithProratedMinimum( - groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice - ): T + /** New plan price request body params. */ + @JsonDeserialize(using = Price.Deserializer::class) + @JsonSerialize(using = Price.Serializer::class) + class Price + private constructor( + private val unit: NewPlanUnitPrice? = null, + private val tiered: NewPlanTieredPrice? = null, + private val bulk: NewPlanBulkPrice? = null, + private val bulkWithFilters: BulkWithFilters? = null, + private val package_: NewPlanPackagePrice? = null, + private val matrix: NewPlanMatrixPrice? = null, + private val thresholdTotalAmount: NewPlanThresholdTotalAmountPrice? = null, + private val tieredPackage: NewPlanTieredPackagePrice? = null, + private val tieredWithMinimum: NewPlanTieredWithMinimumPrice? = null, + private val groupedTiered: NewPlanGroupedTieredPrice? = null, + private val tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice? = null, + private val packageWithAllocation: NewPlanPackageWithAllocationPrice? = null, + private val unitWithPercent: NewPlanUnitWithPercentPrice? = null, + private val matrixWithAllocation: NewPlanMatrixWithAllocationPrice? = null, + private val tieredWithProration: TieredWithProration? = null, + private val unitWithProration: NewPlanUnitWithProrationPrice? = null, + private val groupedAllocation: NewPlanGroupedAllocationPrice? = null, + private val bulkWithProration: NewPlanBulkWithProrationPrice? = null, + private val groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice? = null, + private val groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice? = null, + private val groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds? = null, + private val matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice? = null, + private val groupedTieredPackage: NewPlanGroupedTieredPackagePrice? = null, + private val maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice? = null, + private val scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice? = + null, + private val scalableMatrixWithTieredPricing: + NewPlanScalableMatrixWithTieredPricingPrice? = + null, + private val cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice? = null, + private val cumulativeGroupedAllocation: CumulativeGroupedAllocation? = null, + private val minimum: NewPlanMinimumCompositePrice? = null, + private val percent: Percent? = null, + private val eventOutput: EventOutput? = null, + private val _json: JsonValue? = null, + ) { - fun visitGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice - ): T + fun unit(): NewPlanUnitPrice? = unit - fun visitGroupedWithMinMaxThresholds( - groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds - ): T + fun tiered(): NewPlanTieredPrice? = tiered - fun visitMatrixWithDisplayName( - matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice - ): T + fun bulk(): NewPlanBulkPrice? = bulk - fun visitGroupedTieredPackage( - groupedTieredPackage: NewPlanGroupedTieredPackagePrice - ): T + fun bulkWithFilters(): BulkWithFilters? = bulkWithFilters - fun visitMaxGroupTieredPackage( - maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice - ): T + fun package_(): NewPlanPackagePrice? = package_ - fun visitScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice - ): T + fun matrix(): NewPlanMatrixPrice? = matrix - fun visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: NewPlanScalableMatrixWithTieredPricingPrice - ): T + fun thresholdTotalAmount(): NewPlanThresholdTotalAmountPrice? = thresholdTotalAmount - fun visitCumulativeGroupedBulk( - cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice - ): T + fun tieredPackage(): NewPlanTieredPackagePrice? = tieredPackage - fun visitMinimum(minimum: NewPlanMinimumCompositePrice): T + fun tieredWithMinimum(): NewPlanTieredWithMinimumPrice? = tieredWithMinimum - fun visitPercent(percent: Percent): T + fun groupedTiered(): NewPlanGroupedTieredPrice? = groupedTiered - fun visitEventOutput(eventOutput: EventOutput): T + fun tieredPackageWithMinimum(): NewPlanTieredPackageWithMinimumPrice? = + tieredPackageWithMinimum - /** - * Maps an unknown variant of [Price] to a value of type [T]. - * - * An instance of [Price] can contain an unknown variant if it was deserialized from - * data that doesn't match any known variant. For example, if the SDK is on an older - * version than the API, then the API may respond with new variants that the SDK is - * unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown Price: $json") - } - } + fun packageWithAllocation(): NewPlanPackageWithAllocationPrice? = packageWithAllocation - internal class Deserializer : BaseDeserializer(Price::class) { + fun unitWithPercent(): NewPlanUnitWithPercentPrice? = unitWithPercent - override fun ObjectCodec.deserialize(node: JsonNode): Price { - val json = JsonValue.fromJsonNode(node) - val modelType = json.asObject()?.get("model_type")?.asString() + fun matrixWithAllocation(): NewPlanMatrixWithAllocationPrice? = matrixWithAllocation - when (modelType) { - "unit" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(unit = it, _json = json) - } ?: Price(_json = json) - } - "tiered" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(tiered = it, _json = json) - } ?: Price(_json = json) - } - "bulk" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(bulk = it, _json = json) - } ?: Price(_json = json) - } - "bulk_with_filters" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(bulkWithFilters = it, _json = json) - } ?: Price(_json = json) - } - "package" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(package_ = it, _json = json) } ?: Price(_json = json) - } - "matrix" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(matrix = it, _json = json) - } ?: Price(_json = json) - } - "threshold_total_amount" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(thresholdTotalAmount = it, _json = json) } - ?: Price(_json = json) - } - "tiered_package" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(tieredPackage = it, _json = json) } - ?: Price(_json = json) - } - "tiered_with_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(tieredWithMinimum = it, _json = json) } - ?: Price(_json = json) - } - "grouped_tiered" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(groupedTiered = it, _json = json) } - ?: Price(_json = json) - } - "tiered_package_with_minimum" -> { + fun tieredWithProration(): TieredWithProration? = tieredWithProration + + fun unitWithProration(): NewPlanUnitWithProrationPrice? = unitWithProration + + fun groupedAllocation(): NewPlanGroupedAllocationPrice? = groupedAllocation + + fun bulkWithProration(): NewPlanBulkWithProrationPrice? = bulkWithProration + + fun groupedWithProratedMinimum(): NewPlanGroupedWithProratedMinimumPrice? = + groupedWithProratedMinimum + + fun groupedWithMeteredMinimum(): NewPlanGroupedWithMeteredMinimumPrice? = + groupedWithMeteredMinimum + + fun groupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds? = + groupedWithMinMaxThresholds + + fun matrixWithDisplayName(): NewPlanMatrixWithDisplayNamePrice? = matrixWithDisplayName + + fun groupedTieredPackage(): NewPlanGroupedTieredPackagePrice? = groupedTieredPackage + + fun maxGroupTieredPackage(): NewPlanMaxGroupTieredPackagePrice? = maxGroupTieredPackage + + fun scalableMatrixWithUnitPricing(): NewPlanScalableMatrixWithUnitPricingPrice? = + scalableMatrixWithUnitPricing + + fun scalableMatrixWithTieredPricing(): NewPlanScalableMatrixWithTieredPricingPrice? = + scalableMatrixWithTieredPricing + + fun cumulativeGroupedBulk(): NewPlanCumulativeGroupedBulkPrice? = cumulativeGroupedBulk + + fun cumulativeGroupedAllocation(): CumulativeGroupedAllocation? = + cumulativeGroupedAllocation + + fun minimum(): NewPlanMinimumCompositePrice? = minimum + + fun percent(): Percent? = percent + + fun eventOutput(): EventOutput? = eventOutput + + fun isUnit(): Boolean = unit != null + + fun isTiered(): Boolean = tiered != null + + fun isBulk(): Boolean = bulk != null + + fun isBulkWithFilters(): Boolean = bulkWithFilters != null + + fun isPackage(): Boolean = package_ != null + + fun isMatrix(): Boolean = matrix != null + + fun isThresholdTotalAmount(): Boolean = thresholdTotalAmount != null + + fun isTieredPackage(): Boolean = tieredPackage != null + + fun isTieredWithMinimum(): Boolean = tieredWithMinimum != null + + fun isGroupedTiered(): Boolean = groupedTiered != null + + fun isTieredPackageWithMinimum(): Boolean = tieredPackageWithMinimum != null + + fun isPackageWithAllocation(): Boolean = packageWithAllocation != null + + fun isUnitWithPercent(): Boolean = unitWithPercent != null + + fun isMatrixWithAllocation(): Boolean = matrixWithAllocation != null + + fun isTieredWithProration(): Boolean = tieredWithProration != null + + fun isUnitWithProration(): Boolean = unitWithProration != null + + fun isGroupedAllocation(): Boolean = groupedAllocation != null + + fun isBulkWithProration(): Boolean = bulkWithProration != null + + fun isGroupedWithProratedMinimum(): Boolean = groupedWithProratedMinimum != null + + fun isGroupedWithMeteredMinimum(): Boolean = groupedWithMeteredMinimum != null + + fun isGroupedWithMinMaxThresholds(): Boolean = groupedWithMinMaxThresholds != null + + fun isMatrixWithDisplayName(): Boolean = matrixWithDisplayName != null + + fun isGroupedTieredPackage(): Boolean = groupedTieredPackage != null + + fun isMaxGroupTieredPackage(): Boolean = maxGroupTieredPackage != null + + fun isScalableMatrixWithUnitPricing(): Boolean = scalableMatrixWithUnitPricing != null + + fun isScalableMatrixWithTieredPricing(): Boolean = + scalableMatrixWithTieredPricing != null + + fun isCumulativeGroupedBulk(): Boolean = cumulativeGroupedBulk != null + + fun isCumulativeGroupedAllocation(): Boolean = cumulativeGroupedAllocation != null + + fun isMinimum(): Boolean = minimum != null + + fun isPercent(): Boolean = percent != null + + fun isEventOutput(): Boolean = eventOutput != null + + fun asUnit(): NewPlanUnitPrice = unit.getOrThrow("unit") + + fun asTiered(): NewPlanTieredPrice = tiered.getOrThrow("tiered") + + fun asBulk(): NewPlanBulkPrice = bulk.getOrThrow("bulk") + + fun asBulkWithFilters(): BulkWithFilters = bulkWithFilters.getOrThrow("bulkWithFilters") + + fun asPackage(): NewPlanPackagePrice = package_.getOrThrow("package_") + + fun asMatrix(): NewPlanMatrixPrice = matrix.getOrThrow("matrix") + + fun asThresholdTotalAmount(): NewPlanThresholdTotalAmountPrice = + thresholdTotalAmount.getOrThrow("thresholdTotalAmount") + + fun asTieredPackage(): NewPlanTieredPackagePrice = + tieredPackage.getOrThrow("tieredPackage") + + fun asTieredWithMinimum(): NewPlanTieredWithMinimumPrice = + tieredWithMinimum.getOrThrow("tieredWithMinimum") + + fun asGroupedTiered(): NewPlanGroupedTieredPrice = + groupedTiered.getOrThrow("groupedTiered") + + fun asTieredPackageWithMinimum(): NewPlanTieredPackageWithMinimumPrice = + tieredPackageWithMinimum.getOrThrow("tieredPackageWithMinimum") + + fun asPackageWithAllocation(): NewPlanPackageWithAllocationPrice = + packageWithAllocation.getOrThrow("packageWithAllocation") + + fun asUnitWithPercent(): NewPlanUnitWithPercentPrice = + unitWithPercent.getOrThrow("unitWithPercent") + + fun asMatrixWithAllocation(): NewPlanMatrixWithAllocationPrice = + matrixWithAllocation.getOrThrow("matrixWithAllocation") + + fun asTieredWithProration(): TieredWithProration = + tieredWithProration.getOrThrow("tieredWithProration") + + fun asUnitWithProration(): NewPlanUnitWithProrationPrice = + unitWithProration.getOrThrow("unitWithProration") + + fun asGroupedAllocation(): NewPlanGroupedAllocationPrice = + groupedAllocation.getOrThrow("groupedAllocation") + + fun asBulkWithProration(): NewPlanBulkWithProrationPrice = + bulkWithProration.getOrThrow("bulkWithProration") + + fun asGroupedWithProratedMinimum(): NewPlanGroupedWithProratedMinimumPrice = + groupedWithProratedMinimum.getOrThrow("groupedWithProratedMinimum") + + fun asGroupedWithMeteredMinimum(): NewPlanGroupedWithMeteredMinimumPrice = + groupedWithMeteredMinimum.getOrThrow("groupedWithMeteredMinimum") + + fun asGroupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds = + groupedWithMinMaxThresholds.getOrThrow("groupedWithMinMaxThresholds") + + fun asMatrixWithDisplayName(): NewPlanMatrixWithDisplayNamePrice = + matrixWithDisplayName.getOrThrow("matrixWithDisplayName") + + fun asGroupedTieredPackage(): NewPlanGroupedTieredPackagePrice = + groupedTieredPackage.getOrThrow("groupedTieredPackage") + + fun asMaxGroupTieredPackage(): NewPlanMaxGroupTieredPackagePrice = + maxGroupTieredPackage.getOrThrow("maxGroupTieredPackage") + + fun asScalableMatrixWithUnitPricing(): NewPlanScalableMatrixWithUnitPricingPrice = + scalableMatrixWithUnitPricing.getOrThrow("scalableMatrixWithUnitPricing") + + fun asScalableMatrixWithTieredPricing(): NewPlanScalableMatrixWithTieredPricingPrice = + scalableMatrixWithTieredPricing.getOrThrow("scalableMatrixWithTieredPricing") + + fun asCumulativeGroupedBulk(): NewPlanCumulativeGroupedBulkPrice = + cumulativeGroupedBulk.getOrThrow("cumulativeGroupedBulk") + + fun asCumulativeGroupedAllocation(): CumulativeGroupedAllocation = + cumulativeGroupedAllocation.getOrThrow("cumulativeGroupedAllocation") + + fun asMinimum(): NewPlanMinimumCompositePrice = minimum.getOrThrow("minimum") + + fun asPercent(): Percent = percent.getOrThrow("percent") + + fun asEventOutput(): EventOutput = eventOutput.getOrThrow("eventOutput") + + fun _json(): JsonValue? = _json + + fun accept(visitor: Visitor): T = + when { + unit != null -> visitor.visitUnit(unit) + tiered != null -> visitor.visitTiered(tiered) + bulk != null -> visitor.visitBulk(bulk) + bulkWithFilters != null -> visitor.visitBulkWithFilters(bulkWithFilters) + package_ != null -> visitor.visitPackage(package_) + matrix != null -> visitor.visitMatrix(matrix) + thresholdTotalAmount != null -> + visitor.visitThresholdTotalAmount(thresholdTotalAmount) + tieredPackage != null -> visitor.visitTieredPackage(tieredPackage) + tieredWithMinimum != null -> visitor.visitTieredWithMinimum(tieredWithMinimum) + groupedTiered != null -> visitor.visitGroupedTiered(groupedTiered) + tieredPackageWithMinimum != null -> + visitor.visitTieredPackageWithMinimum(tieredPackageWithMinimum) + packageWithAllocation != null -> + visitor.visitPackageWithAllocation(packageWithAllocation) + unitWithPercent != null -> visitor.visitUnitWithPercent(unitWithPercent) + matrixWithAllocation != null -> + visitor.visitMatrixWithAllocation(matrixWithAllocation) + tieredWithProration != null -> + visitor.visitTieredWithProration(tieredWithProration) + unitWithProration != null -> visitor.visitUnitWithProration(unitWithProration) + groupedAllocation != null -> visitor.visitGroupedAllocation(groupedAllocation) + bulkWithProration != null -> visitor.visitBulkWithProration(bulkWithProration) + groupedWithProratedMinimum != null -> + visitor.visitGroupedWithProratedMinimum(groupedWithProratedMinimum) + groupedWithMeteredMinimum != null -> + visitor.visitGroupedWithMeteredMinimum(groupedWithMeteredMinimum) + groupedWithMinMaxThresholds != null -> + visitor.visitGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds) + matrixWithDisplayName != null -> + visitor.visitMatrixWithDisplayName(matrixWithDisplayName) + groupedTieredPackage != null -> + visitor.visitGroupedTieredPackage(groupedTieredPackage) + maxGroupTieredPackage != null -> + visitor.visitMaxGroupTieredPackage(maxGroupTieredPackage) + scalableMatrixWithUnitPricing != null -> + visitor.visitScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing) + scalableMatrixWithTieredPricing != null -> + visitor.visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing + ) + cumulativeGroupedBulk != null -> + visitor.visitCumulativeGroupedBulk(cumulativeGroupedBulk) + cumulativeGroupedAllocation != null -> + visitor.visitCumulativeGroupedAllocation(cumulativeGroupedAllocation) + minimum != null -> visitor.visitMinimum(minimum) + percent != null -> visitor.visitPercent(percent) + eventOutput != null -> visitor.visitEventOutput(eventOutput) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Price = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitUnit(unit: NewPlanUnitPrice) { + unit.validate() + } + + override fun visitTiered(tiered: NewPlanTieredPrice) { + tiered.validate() + } + + override fun visitBulk(bulk: NewPlanBulkPrice) { + bulk.validate() + } + + override fun visitBulkWithFilters(bulkWithFilters: BulkWithFilters) { + bulkWithFilters.validate() + } + + override fun visitPackage(package_: NewPlanPackagePrice) { + package_.validate() + } + + override fun visitMatrix(matrix: NewPlanMatrixPrice) { + matrix.validate() + } + + override fun visitThresholdTotalAmount( + thresholdTotalAmount: NewPlanThresholdTotalAmountPrice + ) { + thresholdTotalAmount.validate() + } + + override fun visitTieredPackage(tieredPackage: NewPlanTieredPackagePrice) { + tieredPackage.validate() + } + + override fun visitTieredWithMinimum( + tieredWithMinimum: NewPlanTieredWithMinimumPrice + ) { + tieredWithMinimum.validate() + } + + override fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) { + groupedTiered.validate() + } + + override fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice + ) { + tieredPackageWithMinimum.validate() + } + + override fun visitPackageWithAllocation( + packageWithAllocation: NewPlanPackageWithAllocationPrice + ) { + packageWithAllocation.validate() + } + + override fun visitUnitWithPercent( + unitWithPercent: NewPlanUnitWithPercentPrice + ) { + unitWithPercent.validate() + } + + override fun visitMatrixWithAllocation( + matrixWithAllocation: NewPlanMatrixWithAllocationPrice + ) { + matrixWithAllocation.validate() + } + + override fun visitTieredWithProration( + tieredWithProration: TieredWithProration + ) { + tieredWithProration.validate() + } + + override fun visitUnitWithProration( + unitWithProration: NewPlanUnitWithProrationPrice + ) { + unitWithProration.validate() + } + + override fun visitGroupedAllocation( + groupedAllocation: NewPlanGroupedAllocationPrice + ) { + groupedAllocation.validate() + } + + override fun visitBulkWithProration( + bulkWithProration: NewPlanBulkWithProrationPrice + ) { + bulkWithProration.validate() + } + + override fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice + ) { + groupedWithProratedMinimum.validate() + } + + override fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice + ) { + groupedWithMeteredMinimum.validate() + } + + override fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) { + groupedWithMinMaxThresholds.validate() + } + + override fun visitMatrixWithDisplayName( + matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice + ) { + matrixWithDisplayName.validate() + } + + override fun visitGroupedTieredPackage( + groupedTieredPackage: NewPlanGroupedTieredPackagePrice + ) { + groupedTieredPackage.validate() + } + + override fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice + ) { + maxGroupTieredPackage.validate() + } + + override fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice + ) { + scalableMatrixWithUnitPricing.validate() + } + + override fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: + NewPlanScalableMatrixWithTieredPricingPrice + ) { + scalableMatrixWithTieredPricing.validate() + } + + override fun visitCumulativeGroupedBulk( + cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice + ) { + cumulativeGroupedBulk.validate() + } + + override fun visitCumulativeGroupedAllocation( + cumulativeGroupedAllocation: CumulativeGroupedAllocation + ) { + cumulativeGroupedAllocation.validate() + } + + override fun visitMinimum(minimum: NewPlanMinimumCompositePrice) { + minimum.validate() + } + + override fun visitPercent(percent: Percent) { + percent.validate() + } + + override fun visitEventOutput(eventOutput: EventOutput) { + eventOutput.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitUnit(unit: NewPlanUnitPrice) = unit.validity() + + override fun visitTiered(tiered: NewPlanTieredPrice) = tiered.validity() + + override fun visitBulk(bulk: NewPlanBulkPrice) = bulk.validity() + + override fun visitBulkWithFilters(bulkWithFilters: BulkWithFilters) = + bulkWithFilters.validity() + + override fun visitPackage(package_: NewPlanPackagePrice) = + package_.validity() + + override fun visitMatrix(matrix: NewPlanMatrixPrice) = matrix.validity() + + override fun visitThresholdTotalAmount( + thresholdTotalAmount: NewPlanThresholdTotalAmountPrice + ) = thresholdTotalAmount.validity() + + override fun visitTieredPackage(tieredPackage: NewPlanTieredPackagePrice) = + tieredPackage.validity() + + override fun visitTieredWithMinimum( + tieredWithMinimum: NewPlanTieredWithMinimumPrice + ) = tieredWithMinimum.validity() + + override fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) = + groupedTiered.validity() + + override fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice + ) = tieredPackageWithMinimum.validity() + + override fun visitPackageWithAllocation( + packageWithAllocation: NewPlanPackageWithAllocationPrice + ) = packageWithAllocation.validity() + + override fun visitUnitWithPercent( + unitWithPercent: NewPlanUnitWithPercentPrice + ) = unitWithPercent.validity() + + override fun visitMatrixWithAllocation( + matrixWithAllocation: NewPlanMatrixWithAllocationPrice + ) = matrixWithAllocation.validity() + + override fun visitTieredWithProration( + tieredWithProration: TieredWithProration + ) = tieredWithProration.validity() + + override fun visitUnitWithProration( + unitWithProration: NewPlanUnitWithProrationPrice + ) = unitWithProration.validity() + + override fun visitGroupedAllocation( + groupedAllocation: NewPlanGroupedAllocationPrice + ) = groupedAllocation.validity() + + override fun visitBulkWithProration( + bulkWithProration: NewPlanBulkWithProrationPrice + ) = bulkWithProration.validity() + + override fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice + ) = groupedWithProratedMinimum.validity() + + override fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice + ) = groupedWithMeteredMinimum.validity() + + override fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) = groupedWithMinMaxThresholds.validity() + + override fun visitMatrixWithDisplayName( + matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice + ) = matrixWithDisplayName.validity() + + override fun visitGroupedTieredPackage( + groupedTieredPackage: NewPlanGroupedTieredPackagePrice + ) = groupedTieredPackage.validity() + + override fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice + ) = maxGroupTieredPackage.validity() + + override fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice + ) = scalableMatrixWithUnitPricing.validity() + + override fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: + NewPlanScalableMatrixWithTieredPricingPrice + ) = scalableMatrixWithTieredPricing.validity() + + override fun visitCumulativeGroupedBulk( + cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice + ) = cumulativeGroupedBulk.validity() + + override fun visitCumulativeGroupedAllocation( + cumulativeGroupedAllocation: CumulativeGroupedAllocation + ) = cumulativeGroupedAllocation.validity() + + override fun visitMinimum(minimum: NewPlanMinimumCompositePrice) = + minimum.validity() + + override fun visitPercent(percent: Percent) = percent.validity() + + override fun visitEventOutput(eventOutput: EventOutput) = + eventOutput.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Price && + unit == other.unit && + tiered == other.tiered && + bulk == other.bulk && + bulkWithFilters == other.bulkWithFilters && + package_ == other.package_ && + matrix == other.matrix && + thresholdTotalAmount == other.thresholdTotalAmount && + tieredPackage == other.tieredPackage && + tieredWithMinimum == other.tieredWithMinimum && + groupedTiered == other.groupedTiered && + tieredPackageWithMinimum == other.tieredPackageWithMinimum && + packageWithAllocation == other.packageWithAllocation && + unitWithPercent == other.unitWithPercent && + matrixWithAllocation == other.matrixWithAllocation && + tieredWithProration == other.tieredWithProration && + unitWithProration == other.unitWithProration && + groupedAllocation == other.groupedAllocation && + bulkWithProration == other.bulkWithProration && + groupedWithProratedMinimum == other.groupedWithProratedMinimum && + groupedWithMeteredMinimum == other.groupedWithMeteredMinimum && + groupedWithMinMaxThresholds == other.groupedWithMinMaxThresholds && + matrixWithDisplayName == other.matrixWithDisplayName && + groupedTieredPackage == other.groupedTieredPackage && + maxGroupTieredPackage == other.maxGroupTieredPackage && + scalableMatrixWithUnitPricing == other.scalableMatrixWithUnitPricing && + scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && + cumulativeGroupedBulk == other.cumulativeGroupedBulk && + cumulativeGroupedAllocation == other.cumulativeGroupedAllocation && + minimum == other.minimum && + percent == other.percent && + eventOutput == other.eventOutput + } + + override fun hashCode(): Int = + Objects.hash( + unit, + tiered, + bulk, + bulkWithFilters, + package_, + matrix, + thresholdTotalAmount, + tieredPackage, + tieredWithMinimum, + groupedTiered, + tieredPackageWithMinimum, + packageWithAllocation, + unitWithPercent, + matrixWithAllocation, + tieredWithProration, + unitWithProration, + groupedAllocation, + bulkWithProration, + groupedWithProratedMinimum, + groupedWithMeteredMinimum, + groupedWithMinMaxThresholds, + matrixWithDisplayName, + groupedTieredPackage, + maxGroupTieredPackage, + scalableMatrixWithUnitPricing, + scalableMatrixWithTieredPricing, + cumulativeGroupedBulk, + cumulativeGroupedAllocation, + minimum, + percent, + eventOutput, + ) + + override fun toString(): String = + when { + unit != null -> "Price{unit=$unit}" + tiered != null -> "Price{tiered=$tiered}" + bulk != null -> "Price{bulk=$bulk}" + bulkWithFilters != null -> "Price{bulkWithFilters=$bulkWithFilters}" + package_ != null -> "Price{package_=$package_}" + matrix != null -> "Price{matrix=$matrix}" + thresholdTotalAmount != null -> + "Price{thresholdTotalAmount=$thresholdTotalAmount}" + tieredPackage != null -> "Price{tieredPackage=$tieredPackage}" + tieredWithMinimum != null -> "Price{tieredWithMinimum=$tieredWithMinimum}" + groupedTiered != null -> "Price{groupedTiered=$groupedTiered}" + tieredPackageWithMinimum != null -> + "Price{tieredPackageWithMinimum=$tieredPackageWithMinimum}" + packageWithAllocation != null -> + "Price{packageWithAllocation=$packageWithAllocation}" + unitWithPercent != null -> "Price{unitWithPercent=$unitWithPercent}" + matrixWithAllocation != null -> + "Price{matrixWithAllocation=$matrixWithAllocation}" + tieredWithProration != null -> "Price{tieredWithProration=$tieredWithProration}" + unitWithProration != null -> "Price{unitWithProration=$unitWithProration}" + groupedAllocation != null -> "Price{groupedAllocation=$groupedAllocation}" + bulkWithProration != null -> "Price{bulkWithProration=$bulkWithProration}" + groupedWithProratedMinimum != null -> + "Price{groupedWithProratedMinimum=$groupedWithProratedMinimum}" + groupedWithMeteredMinimum != null -> + "Price{groupedWithMeteredMinimum=$groupedWithMeteredMinimum}" + groupedWithMinMaxThresholds != null -> + "Price{groupedWithMinMaxThresholds=$groupedWithMinMaxThresholds}" + matrixWithDisplayName != null -> + "Price{matrixWithDisplayName=$matrixWithDisplayName}" + groupedTieredPackage != null -> + "Price{groupedTieredPackage=$groupedTieredPackage}" + maxGroupTieredPackage != null -> + "Price{maxGroupTieredPackage=$maxGroupTieredPackage}" + scalableMatrixWithUnitPricing != null -> + "Price{scalableMatrixWithUnitPricing=$scalableMatrixWithUnitPricing}" + scalableMatrixWithTieredPricing != null -> + "Price{scalableMatrixWithTieredPricing=$scalableMatrixWithTieredPricing}" + cumulativeGroupedBulk != null -> + "Price{cumulativeGroupedBulk=$cumulativeGroupedBulk}" + cumulativeGroupedAllocation != null -> + "Price{cumulativeGroupedAllocation=$cumulativeGroupedAllocation}" + minimum != null -> "Price{minimum=$minimum}" + percent != null -> "Price{percent=$percent}" + eventOutput != null -> "Price{eventOutput=$eventOutput}" + _json != null -> "Price{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Price") + } + + companion object { + + fun ofUnit(unit: NewPlanUnitPrice) = Price(unit = unit) + + fun ofTiered(tiered: NewPlanTieredPrice) = Price(tiered = tiered) + + fun ofBulk(bulk: NewPlanBulkPrice) = Price(bulk = bulk) + + fun ofBulkWithFilters(bulkWithFilters: BulkWithFilters) = + Price(bulkWithFilters = bulkWithFilters) + + fun ofPackage(package_: NewPlanPackagePrice) = Price(package_ = package_) + + fun ofMatrix(matrix: NewPlanMatrixPrice) = Price(matrix = matrix) + + fun ofThresholdTotalAmount(thresholdTotalAmount: NewPlanThresholdTotalAmountPrice) = + Price(thresholdTotalAmount = thresholdTotalAmount) + + fun ofTieredPackage(tieredPackage: NewPlanTieredPackagePrice) = + Price(tieredPackage = tieredPackage) + + fun ofTieredWithMinimum(tieredWithMinimum: NewPlanTieredWithMinimumPrice) = + Price(tieredWithMinimum = tieredWithMinimum) + + fun ofGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) = + Price(groupedTiered = groupedTiered) + + fun ofTieredPackageWithMinimum( + tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice + ) = Price(tieredPackageWithMinimum = tieredPackageWithMinimum) + + fun ofPackageWithAllocation( + packageWithAllocation: NewPlanPackageWithAllocationPrice + ) = Price(packageWithAllocation = packageWithAllocation) + + fun ofUnitWithPercent(unitWithPercent: NewPlanUnitWithPercentPrice) = + Price(unitWithPercent = unitWithPercent) + + fun ofMatrixWithAllocation(matrixWithAllocation: NewPlanMatrixWithAllocationPrice) = + Price(matrixWithAllocation = matrixWithAllocation) + + fun ofTieredWithProration(tieredWithProration: TieredWithProration) = + Price(tieredWithProration = tieredWithProration) + + fun ofUnitWithProration(unitWithProration: NewPlanUnitWithProrationPrice) = + Price(unitWithProration = unitWithProration) + + fun ofGroupedAllocation(groupedAllocation: NewPlanGroupedAllocationPrice) = + Price(groupedAllocation = groupedAllocation) + + fun ofBulkWithProration(bulkWithProration: NewPlanBulkWithProrationPrice) = + Price(bulkWithProration = bulkWithProration) + + fun ofGroupedWithProratedMinimum( + groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice + ) = Price(groupedWithProratedMinimum = groupedWithProratedMinimum) + + fun ofGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice + ) = Price(groupedWithMeteredMinimum = groupedWithMeteredMinimum) + + fun ofGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) = Price(groupedWithMinMaxThresholds = groupedWithMinMaxThresholds) + + fun ofMatrixWithDisplayName( + matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice + ) = Price(matrixWithDisplayName = matrixWithDisplayName) + + fun ofGroupedTieredPackage(groupedTieredPackage: NewPlanGroupedTieredPackagePrice) = + Price(groupedTieredPackage = groupedTieredPackage) + + fun ofMaxGroupTieredPackage( + maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice + ) = Price(maxGroupTieredPackage = maxGroupTieredPackage) + + fun ofScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice + ) = Price(scalableMatrixWithUnitPricing = scalableMatrixWithUnitPricing) + + fun ofScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: NewPlanScalableMatrixWithTieredPricingPrice + ) = Price(scalableMatrixWithTieredPricing = scalableMatrixWithTieredPricing) + + fun ofCumulativeGroupedBulk( + cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice + ) = Price(cumulativeGroupedBulk = cumulativeGroupedBulk) + + fun ofCumulativeGroupedAllocation( + cumulativeGroupedAllocation: CumulativeGroupedAllocation + ) = Price(cumulativeGroupedAllocation = cumulativeGroupedAllocation) + + fun ofMinimum(minimum: NewPlanMinimumCompositePrice) = Price(minimum = minimum) + + fun ofPercent(percent: Percent) = Price(percent = percent) + + fun ofEventOutput(eventOutput: EventOutput) = Price(eventOutput = eventOutput) + } + + /** + * An interface that defines how to map each variant of [Price] to a value of type [T]. + */ + interface Visitor { + + fun visitUnit(unit: NewPlanUnitPrice): T + + fun visitTiered(tiered: NewPlanTieredPrice): T + + fun visitBulk(bulk: NewPlanBulkPrice): T + + fun visitBulkWithFilters(bulkWithFilters: BulkWithFilters): T + + fun visitPackage(package_: NewPlanPackagePrice): T + + fun visitMatrix(matrix: NewPlanMatrixPrice): T + + fun visitThresholdTotalAmount( + thresholdTotalAmount: NewPlanThresholdTotalAmountPrice + ): T + + fun visitTieredPackage(tieredPackage: NewPlanTieredPackagePrice): T + + fun visitTieredWithMinimum(tieredWithMinimum: NewPlanTieredWithMinimumPrice): T + + fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice): T + + fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice + ): T + + fun visitPackageWithAllocation( + packageWithAllocation: NewPlanPackageWithAllocationPrice + ): T + + fun visitUnitWithPercent(unitWithPercent: NewPlanUnitWithPercentPrice): T + + fun visitMatrixWithAllocation( + matrixWithAllocation: NewPlanMatrixWithAllocationPrice + ): T + + fun visitTieredWithProration(tieredWithProration: TieredWithProration): T + + fun visitUnitWithProration(unitWithProration: NewPlanUnitWithProrationPrice): T + + fun visitGroupedAllocation(groupedAllocation: NewPlanGroupedAllocationPrice): T + + fun visitBulkWithProration(bulkWithProration: NewPlanBulkWithProrationPrice): T + + fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice + ): T + + fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice + ): T + + fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ): T + + fun visitMatrixWithDisplayName( + matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice + ): T + + fun visitGroupedTieredPackage( + groupedTieredPackage: NewPlanGroupedTieredPackagePrice + ): T + + fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice + ): T + + fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice + ): T + + fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: NewPlanScalableMatrixWithTieredPricingPrice + ): T + + fun visitCumulativeGroupedBulk( + cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice + ): T + + fun visitCumulativeGroupedAllocation( + cumulativeGroupedAllocation: CumulativeGroupedAllocation + ): T + + fun visitMinimum(minimum: NewPlanMinimumCompositePrice): T + + fun visitPercent(percent: Percent): T + + fun visitEventOutput(eventOutput: EventOutput): T + + /** + * Maps an unknown variant of [Price] to a value of type [T]. + * + * An instance of [Price] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is + * unaware of. + * + * @throws OrbInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw OrbInvalidDataException("Unknown Price: $json") + } + } + + internal class Deserializer : BaseDeserializer(Price::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Price { + val json = JsonValue.fromJsonNode(node) + val modelType = json.asObject()?.get("model_type")?.asString() + + when (modelType) { + "unit" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(unit = it, _json = json) + } ?: Price(_json = json) + } + "tiered" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(tiered = it, _json = json) + } ?: Price(_json = json) + } + "bulk" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(bulk = it, _json = json) + } ?: Price(_json = json) + } + "bulk_with_filters" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(bulkWithFilters = it, _json = json) + } ?: Price(_json = json) + } + "package" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(package_ = it, _json = json) } ?: Price(_json = json) + } + "matrix" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(matrix = it, _json = json) + } ?: Price(_json = json) + } + "threshold_total_amount" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(thresholdTotalAmount = it, _json = json) } + ?: Price(_json = json) + } + "tiered_package" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(tieredPackage = it, _json = json) } + ?: Price(_json = json) + } + "tiered_with_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(tieredWithMinimum = it, _json = json) } + ?: Price(_json = json) + } + "grouped_tiered" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(groupedTiered = it, _json = json) } + ?: Price(_json = json) + } + "tiered_package_with_minimum" -> { return tryDeserialize( node, jacksonTypeRef(), ) - ?.let { Price(tieredPackageWithMinimum = it, _json = json) } - ?: Price(_json = json) + ?.let { Price(tieredPackageWithMinimum = it, _json = json) } + ?: Price(_json = json) + } + "package_with_allocation" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(packageWithAllocation = it, _json = json) } + ?: Price(_json = json) + } + "unit_with_percent" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(unitWithPercent = it, _json = json) } + ?: Price(_json = json) + } + "matrix_with_allocation" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(matrixWithAllocation = it, _json = json) } + ?: Price(_json = json) + } + "tiered_with_proration" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(tieredWithProration = it, _json = json) } + ?: Price(_json = json) + } + "unit_with_proration" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(unitWithProration = it, _json = json) } + ?: Price(_json = json) + } + "grouped_allocation" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedAllocation = it, _json = json) } + ?: Price(_json = json) + } + "bulk_with_proration" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(bulkWithProration = it, _json = json) } + ?: Price(_json = json) + } + "grouped_with_prorated_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedWithProratedMinimum = it, _json = json) } + ?: Price(_json = json) + } + "grouped_with_metered_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedWithMeteredMinimum = it, _json = json) } + ?: Price(_json = json) + } + "grouped_with_min_max_thresholds" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedWithMinMaxThresholds = it, _json = json) } + ?: Price(_json = json) + } + "matrix_with_display_name" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(matrixWithDisplayName = it, _json = json) } + ?: Price(_json = json) + } + "grouped_tiered_package" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedTieredPackage = it, _json = json) } + ?: Price(_json = json) + } + "max_group_tiered_package" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(maxGroupTieredPackage = it, _json = json) } + ?: Price(_json = json) + } + "scalable_matrix_with_unit_pricing" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(scalableMatrixWithUnitPricing = it, _json = json) } + ?: Price(_json = json) + } + "scalable_matrix_with_tiered_pricing" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(scalableMatrixWithTieredPricing = it, _json = json) } + ?: Price(_json = json) + } + "cumulative_grouped_bulk" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(cumulativeGroupedBulk = it, _json = json) } + ?: Price(_json = json) + } + "cumulative_grouped_allocation" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(cumulativeGroupedAllocation = it, _json = json) } + ?: Price(_json = json) + } + "minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(minimum = it, _json = json) } ?: Price(_json = json) + } + "percent" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(percent = it, _json = json) + } ?: Price(_json = json) + } + "event_output" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(eventOutput = it, _json = json) + } ?: Price(_json = json) + } + } + + return Price(_json = json) + } + } + + internal class Serializer : BaseSerializer(Price::class) { + + override fun serialize( + value: Price, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.unit != null -> generator.writeObject(value.unit) + value.tiered != null -> generator.writeObject(value.tiered) + value.bulk != null -> generator.writeObject(value.bulk) + value.bulkWithFilters != null -> + generator.writeObject(value.bulkWithFilters) + value.package_ != null -> generator.writeObject(value.package_) + value.matrix != null -> generator.writeObject(value.matrix) + value.thresholdTotalAmount != null -> + generator.writeObject(value.thresholdTotalAmount) + value.tieredPackage != null -> generator.writeObject(value.tieredPackage) + value.tieredWithMinimum != null -> + generator.writeObject(value.tieredWithMinimum) + value.groupedTiered != null -> generator.writeObject(value.groupedTiered) + value.tieredPackageWithMinimum != null -> + generator.writeObject(value.tieredPackageWithMinimum) + value.packageWithAllocation != null -> + generator.writeObject(value.packageWithAllocation) + value.unitWithPercent != null -> + generator.writeObject(value.unitWithPercent) + value.matrixWithAllocation != null -> + generator.writeObject(value.matrixWithAllocation) + value.tieredWithProration != null -> + generator.writeObject(value.tieredWithProration) + value.unitWithProration != null -> + generator.writeObject(value.unitWithProration) + value.groupedAllocation != null -> + generator.writeObject(value.groupedAllocation) + value.bulkWithProration != null -> + generator.writeObject(value.bulkWithProration) + value.groupedWithProratedMinimum != null -> + generator.writeObject(value.groupedWithProratedMinimum) + value.groupedWithMeteredMinimum != null -> + generator.writeObject(value.groupedWithMeteredMinimum) + value.groupedWithMinMaxThresholds != null -> + generator.writeObject(value.groupedWithMinMaxThresholds) + value.matrixWithDisplayName != null -> + generator.writeObject(value.matrixWithDisplayName) + value.groupedTieredPackage != null -> + generator.writeObject(value.groupedTieredPackage) + value.maxGroupTieredPackage != null -> + generator.writeObject(value.maxGroupTieredPackage) + value.scalableMatrixWithUnitPricing != null -> + generator.writeObject(value.scalableMatrixWithUnitPricing) + value.scalableMatrixWithTieredPricing != null -> + generator.writeObject(value.scalableMatrixWithTieredPricing) + value.cumulativeGroupedBulk != null -> + generator.writeObject(value.cumulativeGroupedBulk) + value.cumulativeGroupedAllocation != null -> + generator.writeObject(value.cumulativeGroupedAllocation) + value.minimum != null -> generator.writeObject(value.minimum) + value.percent != null -> generator.writeObject(value.percent) + value.eventOutput != null -> generator.writeObject(value.eventOutput) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Price") + } + } + } + + class BulkWithFilters + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val bulkWithFiltersConfig: JsonField, + private val cadence: JsonField, + private val itemId: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("bulk_with_filters_config") + @ExcludeMissing + bulkWithFiltersConfig: JsonField = JsonMissing.of(), + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + bulkWithFiltersConfig, + cadence, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * Configuration for bulk_with_filters pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun bulkWithFiltersConfig(): BulkWithFiltersConfig = + bulkWithFiltersConfig.getRequired("bulk_with_filters_config") + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("bulk_with_filters") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = billableMetricId.getNullable("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + invoiceGroupingKey.getNullable("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [bulkWithFiltersConfig]. + * + * Unlike [bulkWithFiltersConfig], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("bulk_with_filters_config") + @ExcludeMissing + fun _bulkWithFiltersConfig(): JsonField = + bulkWithFiltersConfig + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [BulkWithFilters]. + * + * The following fields are required: + * ```kotlin + * .bulkWithFiltersConfig() + * .cadence() + * .itemId() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [BulkWithFilters]. */ + class Builder internal constructor() { + + private var bulkWithFiltersConfig: JsonField? = null + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonValue = JsonValue.from("bulk_with_filters") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(bulkWithFilters: BulkWithFilters) = apply { + bulkWithFiltersConfig = bulkWithFilters.bulkWithFiltersConfig + cadence = bulkWithFilters.cadence + itemId = bulkWithFilters.itemId + modelType = bulkWithFilters.modelType + name = bulkWithFilters.name + billableMetricId = bulkWithFilters.billableMetricId + billedInAdvance = bulkWithFilters.billedInAdvance + billingCycleConfiguration = bulkWithFilters.billingCycleConfiguration + conversionRate = bulkWithFilters.conversionRate + conversionRateConfig = bulkWithFilters.conversionRateConfig + currency = bulkWithFilters.currency + dimensionalPriceConfiguration = + bulkWithFilters.dimensionalPriceConfiguration + externalPriceId = bulkWithFilters.externalPriceId + fixedPriceQuantity = bulkWithFilters.fixedPriceQuantity + invoiceGroupingKey = bulkWithFilters.invoiceGroupingKey + invoicingCycleConfiguration = bulkWithFilters.invoicingCycleConfiguration + metadata = bulkWithFilters.metadata + referenceId = bulkWithFilters.referenceId + additionalProperties = bulkWithFilters.additionalProperties.toMutableMap() + } + + /** Configuration for bulk_with_filters pricing */ + fun bulkWithFiltersConfig(bulkWithFiltersConfig: BulkWithFiltersConfig) = + bulkWithFiltersConfig(JsonField.of(bulkWithFiltersConfig)) + + /** + * Sets [Builder.bulkWithFiltersConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.bulkWithFiltersConfig] with a well-typed + * [BulkWithFiltersConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun bulkWithFiltersConfig( + bulkWithFiltersConfig: JsonField + ) = apply { this.bulkWithFiltersConfig = bulkWithFiltersConfig } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("bulk_with_filters") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BulkWithFilters]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .bulkWithFiltersConfig() + * .cadence() + * .itemId() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BulkWithFilters = + BulkWithFilters( + checkRequired("bulkWithFiltersConfig", bulkWithFiltersConfig), + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): BulkWithFilters = apply { + if (validated) { + return@apply + } + + bulkWithFiltersConfig().validate() + cadence().validate() + itemId() + _modelType().let { + if (it != JsonValue.from("bulk_with_filters")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (bulkWithFiltersConfig.asKnown()?.validity() ?: 0) + + (cadence.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + modelType.let { if (it == JsonValue.from("bulk_with_filters")) 1 else 0 } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** Configuration for bulk_with_filters pricing */ + class BulkWithFiltersConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val filters: JsonField>, + private val tiers: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("filters") + @ExcludeMissing + filters: JsonField> = JsonMissing.of(), + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of(), + ) : this(filters, tiers, mutableMapOf()) + + /** + * Property filters to apply (all must match) + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun filters(): List = filters.getRequired("filters") + + /** + * Bulk tiers for rating based on total usage volume + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun tiers(): List = tiers.getRequired("tiers") + + /** + * Returns the raw JSON value of [filters]. + * + * Unlike [filters], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("filters") + @ExcludeMissing + fun _filters(): JsonField> = filters + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [BulkWithFiltersConfig]. + * + * The following fields are required: + * ```kotlin + * .filters() + * .tiers() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [BulkWithFiltersConfig]. */ + class Builder internal constructor() { + + private var filters: JsonField>? = null + private var tiers: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(bulkWithFiltersConfig: BulkWithFiltersConfig) = apply { + filters = bulkWithFiltersConfig.filters.map { it.toMutableList() } + tiers = bulkWithFiltersConfig.tiers.map { it.toMutableList() } + additionalProperties = + bulkWithFiltersConfig.additionalProperties.toMutableMap() + } + + /** Property filters to apply (all must match) */ + fun filters(filters: List) = filters(JsonField.of(filters)) + + /** + * Sets [Builder.filters] to an arbitrary JSON value. + * + * You should usually call [Builder.filters] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun filters(filters: JsonField>) = apply { + this.filters = filters.map { it.toMutableList() } + } + + /** + * Adds a single [Filter] to [filters]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addFilter(filter: Filter) = apply { + filters = + (filters ?: JsonField.of(mutableListOf())).also { + checkKnown("filters", it).add(filter) + } + } + + /** Bulk tiers for rating based on total usage volume */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BulkWithFiltersConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .filters() + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BulkWithFiltersConfig = + BulkWithFiltersConfig( + checkRequired("filters", filters).map { it.toImmutable() }, + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): BulkWithFiltersConfig = apply { + if (validated) { + return@apply + } + + filters().forEach { it.validate() } + tiers().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (filters.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + (tiers.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single property filter */ + class Filter + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val propertyKey: JsonField, + private val propertyValue: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("property_key") + @ExcludeMissing + propertyKey: JsonField = JsonMissing.of(), + @JsonProperty("property_value") + @ExcludeMissing + propertyValue: JsonField = JsonMissing.of(), + ) : this(propertyKey, propertyValue, mutableMapOf()) + + /** + * Event property key to filter on + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun propertyKey(): String = propertyKey.getRequired("property_key") + + /** + * Event property value to match + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun propertyValue(): String = propertyValue.getRequired("property_value") + + /** + * Returns the raw JSON value of [propertyKey]. + * + * Unlike [propertyKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("property_key") + @ExcludeMissing + fun _propertyKey(): JsonField = propertyKey + + /** + * Returns the raw JSON value of [propertyValue]. + * + * Unlike [propertyValue], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("property_value") + @ExcludeMissing + fun _propertyValue(): JsonField = propertyValue + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) } - "package_with_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Filter]. + * + * The following fields are required: + * ```kotlin + * .propertyKey() + * .propertyValue() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Filter]. */ + class Builder internal constructor() { + + private var propertyKey: JsonField? = null + private var propertyValue: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(filter: Filter) = apply { + propertyKey = filter.propertyKey + propertyValue = filter.propertyValue + additionalProperties = filter.additionalProperties.toMutableMap() + } + + /** Event property key to filter on */ + fun propertyKey(propertyKey: String) = + propertyKey(JsonField.of(propertyKey)) + + /** + * Sets [Builder.propertyKey] to an arbitrary JSON value. + * + * You should usually call [Builder.propertyKey] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun propertyKey(propertyKey: JsonField) = apply { + this.propertyKey = propertyKey + } + + /** Event property value to match */ + fun propertyValue(propertyValue: String) = + propertyValue(JsonField.of(propertyValue)) + + /** + * Sets [Builder.propertyValue] to an arbitrary JSON value. + * + * You should usually call [Builder.propertyValue] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun propertyValue(propertyValue: JsonField) = apply { + this.propertyValue = propertyValue + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Filter]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```kotlin + * .propertyKey() + * .propertyValue() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Filter = + Filter( + checkRequired("propertyKey", propertyKey), + checkRequired("propertyValue", propertyValue), + additionalProperties.toMutableMap(), ) - ?.let { Price(packageWithAllocation = it, _json = json) } - ?: Price(_json = json) } - "unit_with_percent" -> { - return tryDeserialize( - node, - jacksonTypeRef(), + + private var validated: Boolean = false + + fun validate(): Filter = apply { + if (validated) { + return@apply + } + + propertyKey() + propertyValue() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (propertyKey.asKnown() == null) 0 else 1) + + (if (propertyValue.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Filter && + propertyKey == other.propertyKey && + propertyValue == other.propertyValue && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(propertyKey, propertyValue, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Filter{propertyKey=$propertyKey, propertyValue=$propertyValue, additionalProperties=$additionalProperties}" + } + + /** Configuration for a single bulk pricing tier */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val unitAmount: JsonField, + private val tierLowerBound: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + ) : this(unitAmount, tierLowerBound, mutableMapOf()) + + /** + * Amount per unit + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * The lower bound for this tier + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun tierLowerBound(): String? = + tierLowerBound.getNullable("tier_lower_bound") + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Tier]. + * + * The following fields are required: + * ```kotlin + * .unitAmount() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var unitAmount: JsonField? = null + private var tierLowerBound: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(tier: Tier) = apply { + unitAmount = tier.unitAmount + tierLowerBound = tier.tierLowerBound + additionalProperties = tier.additionalProperties.toMutableMap() + } + + /** Amount per unit */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + /** The lower bound for this tier */ + fun tierLowerBound(tierLowerBound: String?) = + tierLowerBound(JsonField.ofNullable(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```kotlin + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("unitAmount", unitAmount), + tierLowerBound, + additionalProperties.toMutableMap(), ) - ?.let { Price(unitWithPercent = it, _json = json) } - ?: Price(_json = json) } - "matrix_with_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(matrixWithAllocation = it, _json = json) } - ?: Price(_json = json) + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + unitAmount() + tierLowerBound() + validated = true } - "tiered_with_proration" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(tieredWithProration = it, _json = json) } - ?: Price(_json = json) + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (unitAmount.asKnown() == null) 0 else 1) + + (if (tierLowerBound.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + unitAmount == other.unitAmount && + tierLowerBound == other.tierLowerBound && + additionalProperties == other.additionalProperties } - "unit_with_proration" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(unitWithProration = it, _json = json) } - ?: Price(_json = json) + + private val hashCode: Int by lazy { + Objects.hash(unitAmount, tierLowerBound, additionalProperties) } - "grouped_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedAllocation = it, _json = json) } - ?: Price(_json = json) + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{unitAmount=$unitAmount, tierLowerBound=$tierLowerBound, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - "bulk_with_proration" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(bulkWithProration = it, _json = json) } - ?: Price(_json = json) + + return other is BulkWithFiltersConfig && + filters == other.filters && + tiers == other.tiers && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(filters, tiers, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BulkWithFiltersConfig{filters=$filters, tiers=$tiers, additionalProperties=$additionalProperties}" + } + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN } - "grouped_with_prorated_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedWithProratedMinimum = it, _json = json) } - ?: Price(_json = json) + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") } - "grouped_with_metered_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedWithMeteredMinimum = it, _json = json) } - ?: Price(_json = json) + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply } - "grouped_with_min_max_thresholds" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedWithMinMaxThresholds = it, _json = json) } - ?: Price(_json = json) + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false } - "matrix_with_display_name" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(matrixWithDisplayName = it, _json = json) } - ?: Price(_json = json) + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - "grouped_tiered_package" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedTieredPackage = it, _json = json) } - ?: Price(_json = json) + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() } - "max_group_tiered_package" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(maxGroupTieredPackage = it, _json = json) } - ?: Price(_json = json) + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) } - "scalable_matrix_with_unit_pricing" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(scalableMatrixWithUnitPricing = it, _json = json) } - ?: Price(_json = json) + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) } - "scalable_matrix_with_tiered_pricing" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(scalableMatrixWithTieredPricing = it, _json = json) } - ?: Price(_json = json) + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) } - "cumulative_grouped_bulk" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(cumulativeGroupedBulk = it, _json = json) } - ?: Price(_json = json) + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply } - "minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(minimum = it, _json = json) } ?: Price(_json = json) + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false } - "percent" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(percent = it, _json = json) - } ?: Price(_json = json) + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() } - "event_output" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(eventOutput = it, _json = json) - } ?: Price(_json = json) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - return Price(_json = json) + return other is BulkWithFilters && + bulkWithFiltersConfig == other.bulkWithFiltersConfig && + cadence == other.cadence && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties } - } - - internal class Serializer : BaseSerializer(Price::class) { - override fun serialize( - value: Price, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unit != null -> generator.writeObject(value.unit) - value.tiered != null -> generator.writeObject(value.tiered) - value.bulk != null -> generator.writeObject(value.bulk) - value.bulkWithFilters != null -> - generator.writeObject(value.bulkWithFilters) - value.package_ != null -> generator.writeObject(value.package_) - value.matrix != null -> generator.writeObject(value.matrix) - value.thresholdTotalAmount != null -> - generator.writeObject(value.thresholdTotalAmount) - value.tieredPackage != null -> generator.writeObject(value.tieredPackage) - value.tieredWithMinimum != null -> - generator.writeObject(value.tieredWithMinimum) - value.groupedTiered != null -> generator.writeObject(value.groupedTiered) - value.tieredPackageWithMinimum != null -> - generator.writeObject(value.tieredPackageWithMinimum) - value.packageWithAllocation != null -> - generator.writeObject(value.packageWithAllocation) - value.unitWithPercent != null -> - generator.writeObject(value.unitWithPercent) - value.matrixWithAllocation != null -> - generator.writeObject(value.matrixWithAllocation) - value.tieredWithProration != null -> - generator.writeObject(value.tieredWithProration) - value.unitWithProration != null -> - generator.writeObject(value.unitWithProration) - value.groupedAllocation != null -> - generator.writeObject(value.groupedAllocation) - value.bulkWithProration != null -> - generator.writeObject(value.bulkWithProration) - value.groupedWithProratedMinimum != null -> - generator.writeObject(value.groupedWithProratedMinimum) - value.groupedWithMeteredMinimum != null -> - generator.writeObject(value.groupedWithMeteredMinimum) - value.groupedWithMinMaxThresholds != null -> - generator.writeObject(value.groupedWithMinMaxThresholds) - value.matrixWithDisplayName != null -> - generator.writeObject(value.matrixWithDisplayName) - value.groupedTieredPackage != null -> - generator.writeObject(value.groupedTieredPackage) - value.maxGroupTieredPackage != null -> - generator.writeObject(value.maxGroupTieredPackage) - value.scalableMatrixWithUnitPricing != null -> - generator.writeObject(value.scalableMatrixWithUnitPricing) - value.scalableMatrixWithTieredPricing != null -> - generator.writeObject(value.scalableMatrixWithTieredPricing) - value.cumulativeGroupedBulk != null -> - generator.writeObject(value.cumulativeGroupedBulk) - value.minimum != null -> generator.writeObject(value.minimum) - value.percent != null -> generator.writeObject(value.percent) - value.eventOutput != null -> generator.writeObject(value.eventOutput) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Price") - } + private val hashCode: Int by lazy { + Objects.hash( + bulkWithFiltersConfig, + cadence, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties, + ) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BulkWithFilters{bulkWithFiltersConfig=$bulkWithFiltersConfig, cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class BulkWithFilters + class TieredWithProration @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val bulkWithFiltersConfig: JsonField, private val cadence: JsonField, private val itemId: JsonField, private val modelType: JsonValue, private val name: JsonField, + private val tieredWithProrationConfig: JsonField, private val billableMetricId: JsonField, private val billedInAdvance: JsonField, private val billingCycleConfiguration: JsonField, @@ -14608,9 +18448,6 @@ private constructor( @JsonCreator private constructor( - @JsonProperty("bulk_with_filters_config") - @ExcludeMissing - bulkWithFiltersConfig: JsonField = JsonMissing.of(), @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), @@ -14623,6 +18460,10 @@ private constructor( @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("tiered_with_proration_config") + @ExcludeMissing + tieredWithProrationConfig: JsonField = + JsonMissing.of(), @JsonProperty("billable_metric_id") @ExcludeMissing billableMetricId: JsonField = JsonMissing.of(), @@ -14666,11 +18507,11 @@ private constructor( @ExcludeMissing referenceId: JsonField = JsonMissing.of(), ) : this( - bulkWithFiltersConfig, cadence, itemId, modelType, name, + tieredWithProrationConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -14687,16 +18528,6 @@ private constructor( mutableMapOf(), ) - /** - * Configuration for bulk_with_filters pricing - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun bulkWithFiltersConfig(): BulkWithFiltersConfig = - bulkWithFiltersConfig.getRequired("bulk_with_filters_config") - /** * The cadence to bill for this price on. * @@ -14720,7 +18551,7 @@ private constructor( * * Expected to always return the following: * ```kotlin - * JsonValue.from("bulk_with_filters") + * JsonValue.from("tiered_with_proration") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -14737,6 +18568,16 @@ private constructor( */ fun name(): String = name.getRequired("name") + /** + * Configuration for tiered_with_proration pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun tieredWithProrationConfig(): TieredWithProrationConfig = + tieredWithProrationConfig.getRequired("tiered_with_proration_config") + /** * The id of the billable metric for the price. Only needed if the price is * usage-based. @@ -14856,17 +18697,6 @@ private constructor( */ fun referenceId(): String? = referenceId.getNullable("reference_id") - /** - * Returns the raw JSON value of [bulkWithFiltersConfig]. - * - * Unlike [bulkWithFiltersConfig], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("bulk_with_filters_config") - @ExcludeMissing - fun _bulkWithFiltersConfig(): JsonField = - bulkWithFiltersConfig - /** * Returns the raw JSON value of [cadence]. * @@ -14893,6 +18723,17 @@ private constructor( */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + /** + * Returns the raw JSON value of [tieredWithProrationConfig]. + * + * Unlike [tieredWithProrationConfig], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("tiered_with_proration_config") + @ExcludeMissing + fun _tieredWithProrationConfig(): JsonField = + tieredWithProrationConfig + /** * Returns the raw JSON value of [billableMetricId]. * @@ -15041,27 +18882,29 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [BulkWithFilters]. + * Returns a mutable builder for constructing an instance of + * [TieredWithProration]. * * The following fields are required: * ```kotlin - * .bulkWithFiltersConfig() * .cadence() * .itemId() * .name() + * .tieredWithProrationConfig() * ``` */ fun builder() = Builder() } - /** A builder for [BulkWithFilters]. */ + /** A builder for [TieredWithProration]. */ class Builder internal constructor() { - private var bulkWithFiltersConfig: JsonField? = null private var cadence: JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonValue = JsonValue.from("bulk_with_filters") + private var modelType: JsonValue = JsonValue.from("tiered_with_proration") private var name: JsonField? = null + private var tieredWithProrationConfig: JsonField? = + null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() private var billingCycleConfiguration: JsonField = @@ -15083,44 +18926,31 @@ private constructor( private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(bulkWithFilters: BulkWithFilters) = apply { - bulkWithFiltersConfig = bulkWithFilters.bulkWithFiltersConfig - cadence = bulkWithFilters.cadence - itemId = bulkWithFilters.itemId - modelType = bulkWithFilters.modelType - name = bulkWithFilters.name - billableMetricId = bulkWithFilters.billableMetricId - billedInAdvance = bulkWithFilters.billedInAdvance - billingCycleConfiguration = bulkWithFilters.billingCycleConfiguration - conversionRate = bulkWithFilters.conversionRate - conversionRateConfig = bulkWithFilters.conversionRateConfig - currency = bulkWithFilters.currency + internal fun from(tieredWithProration: TieredWithProration) = apply { + cadence = tieredWithProration.cadence + itemId = tieredWithProration.itemId + modelType = tieredWithProration.modelType + name = tieredWithProration.name + tieredWithProrationConfig = tieredWithProration.tieredWithProrationConfig + billableMetricId = tieredWithProration.billableMetricId + billedInAdvance = tieredWithProration.billedInAdvance + billingCycleConfiguration = tieredWithProration.billingCycleConfiguration + conversionRate = tieredWithProration.conversionRate + conversionRateConfig = tieredWithProration.conversionRateConfig + currency = tieredWithProration.currency dimensionalPriceConfiguration = - bulkWithFilters.dimensionalPriceConfiguration - externalPriceId = bulkWithFilters.externalPriceId - fixedPriceQuantity = bulkWithFilters.fixedPriceQuantity - invoiceGroupingKey = bulkWithFilters.invoiceGroupingKey - invoicingCycleConfiguration = bulkWithFilters.invoicingCycleConfiguration - metadata = bulkWithFilters.metadata - referenceId = bulkWithFilters.referenceId - additionalProperties = bulkWithFilters.additionalProperties.toMutableMap() + tieredWithProration.dimensionalPriceConfiguration + externalPriceId = tieredWithProration.externalPriceId + fixedPriceQuantity = tieredWithProration.fixedPriceQuantity + invoiceGroupingKey = tieredWithProration.invoiceGroupingKey + invoicingCycleConfiguration = + tieredWithProration.invoicingCycleConfiguration + metadata = tieredWithProration.metadata + referenceId = tieredWithProration.referenceId + additionalProperties = + tieredWithProration.additionalProperties.toMutableMap() } - /** Configuration for bulk_with_filters pricing */ - fun bulkWithFiltersConfig(bulkWithFiltersConfig: BulkWithFiltersConfig) = - bulkWithFiltersConfig(JsonField.of(bulkWithFiltersConfig)) - - /** - * Sets [Builder.bulkWithFiltersConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.bulkWithFiltersConfig] with a well-typed - * [BulkWithFiltersConfig] value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun bulkWithFiltersConfig( - bulkWithFiltersConfig: JsonField - ) = apply { this.bulkWithFiltersConfig = bulkWithFiltersConfig } - /** The cadence to bill for this price on. */ fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) @@ -15151,7 +18981,7 @@ private constructor( * It is usually unnecessary to call this method because the field defaults to * the following: * ```kotlin - * JsonValue.from("bulk_with_filters") + * JsonValue.from("tiered_with_proration") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -15165,11 +18995,27 @@ private constructor( /** * Sets [Builder.name] to an arbitrary JSON value. * - * You should usually call [Builder.name] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for tiered_with_proration pricing */ + fun tieredWithProrationConfig( + tieredWithProrationConfig: TieredWithProrationConfig + ) = tieredWithProrationConfig(JsonField.of(tieredWithProrationConfig)) + + /** + * Sets [Builder.tieredWithProrationConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.tieredWithProrationConfig] with a well-typed + * [TieredWithProrationConfig] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. */ - fun name(name: JsonField) = apply { this.name = name } + fun tieredWithProrationConfig( + tieredWithProrationConfig: JsonField + ) = apply { this.tieredWithProrationConfig = tieredWithProrationConfig } /** * The id of the billable metric for the price. Only needed if the price is @@ -15500,27 +19346,27 @@ private constructor( } /** - * Returns an immutable instance of [BulkWithFilters]. + * Returns an immutable instance of [TieredWithProration]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```kotlin - * .bulkWithFiltersConfig() * .cadence() * .itemId() * .name() + * .tieredWithProrationConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): BulkWithFilters = - BulkWithFilters( - checkRequired("bulkWithFiltersConfig", bulkWithFiltersConfig), + fun build(): TieredWithProration = + TieredWithProration( checkRequired("cadence", cadence), checkRequired("itemId", itemId), modelType, checkRequired("name", name), + checkRequired("tieredWithProrationConfig", tieredWithProrationConfig), billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -15540,20 +19386,20 @@ private constructor( private var validated: Boolean = false - fun validate(): BulkWithFilters = apply { + fun validate(): TieredWithProration = apply { if (validated) { return@apply } - bulkWithFiltersConfig().validate() cadence().validate() itemId() _modelType().let { - if (it != JsonValue.from("bulk_with_filters")) { + if (it != JsonValue.from("tiered_with_proration")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } name() + tieredWithProrationConfig().validate() billableMetricId() billedInAdvance() billingCycleConfiguration()?.validate() @@ -15585,11 +19431,13 @@ private constructor( * Used for best match union deserialization. */ internal fun validity(): Int = - (bulkWithFiltersConfig.asKnown()?.validity() ?: 0) + - (cadence.asKnown()?.validity() ?: 0) + + (cadence.asKnown()?.validity() ?: 0) + (if (itemId.asKnown() == null) 0 else 1) + - modelType.let { if (it == JsonValue.from("bulk_with_filters")) 1 else 0 } + + modelType.let { + if (it == JsonValue.from("tiered_with_proration")) 1 else 0 + } + (if (name.asKnown() == null) 0 else 1) + + (tieredWithProrationConfig.asKnown()?.validity() ?: 0) + (if (billableMetricId.asKnown() == null) 0 else 1) + (if (billedInAdvance.asKnown() == null) 0 else 1) + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + @@ -15604,36 +19452,181 @@ private constructor( (metadata.asKnown()?.validity() ?: 0) + (if (referenceId.asKnown() == null) 0 else 1) - /** Configuration for bulk_with_filters pricing */ - class BulkWithFiltersConfig + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Configuration for tiered_with_proration pricing */ + class TieredWithProrationConfig @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val filters: JsonField>, private val tiers: JsonField>, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("filters") - @ExcludeMissing - filters: JsonField> = JsonMissing.of(), @JsonProperty("tiers") @ExcludeMissing - tiers: JsonField> = JsonMissing.of(), - ) : this(filters, tiers, mutableMapOf()) - - /** - * Property filters to apply (all must match) - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun filters(): List = filters.getRequired("filters") + tiers: JsonField> = JsonMissing.of() + ) : this(tiers, mutableMapOf()) /** - * Bulk tiers for rating based on total usage volume + * Tiers for rating based on total usage quantities into the specified tier with + * proration * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an @@ -15641,16 +19634,6 @@ private constructor( */ fun tiers(): List = tiers.getRequired("tiers") - /** - * Returns the raw JSON value of [filters]. - * - * Unlike [filters], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("filters") - @ExcludeMissing - fun _filters(): JsonField> = filters - /** * Returns the raw JSON value of [tiers]. * @@ -15677,60 +19660,34 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [BulkWithFiltersConfig]. + * [TieredWithProrationConfig]. * * The following fields are required: * ```kotlin - * .filters() * .tiers() * ``` */ fun builder() = Builder() } - /** A builder for [BulkWithFiltersConfig]. */ + /** A builder for [TieredWithProrationConfig]. */ class Builder internal constructor() { - private var filters: JsonField>? = null private var tiers: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(bulkWithFiltersConfig: BulkWithFiltersConfig) = apply { - filters = bulkWithFiltersConfig.filters.map { it.toMutableList() } - tiers = bulkWithFiltersConfig.tiers.map { it.toMutableList() } - additionalProperties = - bulkWithFiltersConfig.additionalProperties.toMutableMap() - } - - /** Property filters to apply (all must match) */ - fun filters(filters: List) = filters(JsonField.of(filters)) - - /** - * Sets [Builder.filters] to an arbitrary JSON value. - * - * You should usually call [Builder.filters] with a well-typed - * `List` value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun filters(filters: JsonField>) = apply { - this.filters = filters.map { it.toMutableList() } - } + internal fun from(tieredWithProrationConfig: TieredWithProrationConfig) = + apply { + tiers = tieredWithProrationConfig.tiers.map { it.toMutableList() } + additionalProperties = + tieredWithProrationConfig.additionalProperties.toMutableMap() + } /** - * Adds a single [Filter] to [filters]. - * - * @throws IllegalStateException if the field was previously set to a - * non-list. + * Tiers for rating based on total usage quantities into the specified tier + * with proration */ - fun addFilter(filter: Filter) = apply { - filters = - (filters ?: JsonField.of(mutableListOf())).also { - checkKnown("filters", it).add(filter) - } - } - - /** Bulk tiers for rating based on total usage volume */ fun tiers(tiers: List) = tiers(JsonField.of(tiers)) /** @@ -15780,21 +19737,19 @@ private constructor( } /** - * Returns an immutable instance of [BulkWithFiltersConfig]. + * Returns an immutable instance of [TieredWithProrationConfig]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```kotlin - * .filters() * .tiers() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): BulkWithFiltersConfig = - BulkWithFiltersConfig( - checkRequired("filters", filters).map { it.toImmutable() }, + fun build(): TieredWithProrationConfig = + TieredWithProrationConfig( checkRequired("tiers", tiers).map { it.toImmutable() }, additionalProperties.toMutableMap(), ) @@ -15802,12 +19757,11 @@ private constructor( private var validated: Boolean = false - fun validate(): BulkWithFiltersConfig = apply { + fun validate(): TieredWithProrationConfig = apply { if (validated) { return@apply } - filters().forEach { it.validate() } tiers().forEach { it.validate() } validated = true } @@ -15822,254 +19776,41 @@ private constructor( /** * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (filters.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + - (tiers.asKnown()?.sumOf { it.validity().toInt() } ?: 0) - - /** Configuration for a single property filter */ - class Filter - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val propertyKey: JsonField, - private val propertyValue: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("property_key") - @ExcludeMissing - propertyKey: JsonField = JsonMissing.of(), - @JsonProperty("property_value") - @ExcludeMissing - propertyValue: JsonField = JsonMissing.of(), - ) : this(propertyKey, propertyValue, mutableMapOf()) - - /** - * Event property key to filter on - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type - * or is unexpectedly missing or null (e.g. if the server responded with - * an unexpected value). - */ - fun propertyKey(): String = propertyKey.getRequired("property_key") - - /** - * Event property value to match - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type - * or is unexpectedly missing or null (e.g. if the server responded with - * an unexpected value). - */ - fun propertyValue(): String = propertyValue.getRequired("property_value") - - /** - * Returns the raw JSON value of [propertyKey]. - * - * Unlike [propertyKey], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("property_key") - @ExcludeMissing - fun _propertyKey(): JsonField = propertyKey - - /** - * Returns the raw JSON value of [propertyValue]. - * - * Unlike [propertyValue], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("property_value") - @ExcludeMissing - fun _propertyValue(): JsonField = propertyValue - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [Filter]. - * - * The following fields are required: - * ```kotlin - * .propertyKey() - * .propertyValue() - * ``` - */ - fun builder() = Builder() - } - - /** A builder for [Filter]. */ - class Builder internal constructor() { - - private var propertyKey: JsonField? = null - private var propertyValue: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - internal fun from(filter: Filter) = apply { - propertyKey = filter.propertyKey - propertyValue = filter.propertyValue - additionalProperties = filter.additionalProperties.toMutableMap() - } - - /** Event property key to filter on */ - fun propertyKey(propertyKey: String) = - propertyKey(JsonField.of(propertyKey)) - - /** - * Sets [Builder.propertyKey] to an arbitrary JSON value. - * - * You should usually call [Builder.propertyKey] with a well-typed - * [String] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun propertyKey(propertyKey: JsonField) = apply { - this.propertyKey = propertyKey - } - - /** Event property value to match */ - fun propertyValue(propertyValue: String) = - propertyValue(JsonField.of(propertyValue)) - - /** - * Sets [Builder.propertyValue] to an arbitrary JSON value. - * - * You should usually call [Builder.propertyValue] with a well-typed - * [String] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun propertyValue(propertyValue: JsonField) = apply { - this.propertyValue = propertyValue - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Filter]. - * - * Further updates to this [Builder] will not mutate the returned - * instance. - * - * The following fields are required: - * ```kotlin - * .propertyKey() - * .propertyValue() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Filter = - Filter( - checkRequired("propertyKey", propertyKey), - checkRequired("propertyValue", propertyValue), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Filter = apply { - if (validated) { - return@apply - } - - propertyKey() - propertyValue() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this - * object recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (if (propertyKey.asKnown() == null) 0 else 1) + - (if (propertyValue.asKnown() == null) 0 else 1) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Filter && - propertyKey == other.propertyKey && - propertyValue == other.propertyValue && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(propertyKey, propertyValue, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Filter{propertyKey=$propertyKey, propertyValue=$propertyValue, additionalProperties=$additionalProperties}" - } + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (tiers.asKnown()?.sumOf { it.validity().toInt() } ?: 0) - /** Configuration for a single bulk pricing tier */ + /** Configuration for a single tiered with proration tier */ class Tier @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val unitAmount: JsonField, private val tierLowerBound: JsonField, + private val unitAmount: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("unit_amount") - @ExcludeMissing - unitAmount: JsonField = JsonMissing.of(), @JsonProperty("tier_lower_bound") @ExcludeMissing tierLowerBound: JsonField = JsonMissing.of(), - ) : this(unitAmount, tierLowerBound, mutableMapOf()) + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(tierLowerBound, unitAmount, mutableMapOf()) + + /** + * Inclusive tier starting value + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun tierLowerBound(): String = + tierLowerBound.getRequired("tier_lower_bound") /** * Amount per unit @@ -16081,13 +19822,14 @@ private constructor( fun unitAmount(): String = unitAmount.getRequired("unit_amount") /** - * The lower bound for this tier + * Returns the raw JSON value of [tierLowerBound]. * - * @throws OrbInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. */ - fun tierLowerBound(): String? = - tierLowerBound.getNullable("tier_lower_bound") + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound /** * Returns the raw JSON value of [unitAmount]. @@ -16099,16 +19841,6 @@ private constructor( @ExcludeMissing fun _unitAmount(): JsonField = unitAmount - /** - * Returns the raw JSON value of [tierLowerBound]. - * - * Unlike [tierLowerBound], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("tier_lower_bound") - @ExcludeMissing - fun _tierLowerBound(): JsonField = tierLowerBound - @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -16128,6 +19860,7 @@ private constructor( * * The following fields are required: * ```kotlin + * .tierLowerBound() * .unitAmount() * ``` */ @@ -16137,45 +19870,45 @@ private constructor( /** A builder for [Tier]. */ class Builder internal constructor() { + private var tierLowerBound: JsonField? = null private var unitAmount: JsonField? = null - private var tierLowerBound: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() internal fun from(tier: Tier) = apply { - unitAmount = tier.unitAmount tierLowerBound = tier.tierLowerBound + unitAmount = tier.unitAmount additionalProperties = tier.additionalProperties.toMutableMap() } - /** Amount per unit */ - fun unitAmount(unitAmount: String) = - unitAmount(JsonField.of(unitAmount)) + /** Inclusive tier starting value */ + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) /** - * Sets [Builder.unitAmount] to an arbitrary JSON value. + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. * - * You should usually call [Builder.unitAmount] with a well-typed + * You should usually call [Builder.tierLowerBound] with a well-typed * [String] value instead. This method is primarily for setting the * field to an undocumented or not yet supported value. */ - fun unitAmount(unitAmount: JsonField) = apply { - this.unitAmount = unitAmount + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound } - /** The lower bound for this tier */ - fun tierLowerBound(tierLowerBound: String?) = - tierLowerBound(JsonField.ofNullable(tierLowerBound)) + /** Amount per unit */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) /** - * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * Sets [Builder.unitAmount] to an arbitrary JSON value. * - * You should usually call [Builder.tierLowerBound] with a well-typed + * You should usually call [Builder.unitAmount] with a well-typed * [String] value instead. This method is primarily for setting the * field to an undocumented or not yet supported value. */ - fun tierLowerBound(tierLowerBound: JsonField) = apply { - this.tierLowerBound = tierLowerBound + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount } fun additionalProperties(additionalProperties: Map) = @@ -16201,253 +19934,94 @@ private constructor( } /** - * Returns an immutable instance of [Tier]. - * - * Further updates to this [Builder] will not mutate the returned - * instance. - * - * The following fields are required: - * ```kotlin - * .unitAmount() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Tier = - Tier( - checkRequired("unitAmount", unitAmount), - tierLowerBound, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Tier = apply { - if (validated) { - return@apply - } - - unitAmount() - tierLowerBound() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this - * object recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (if (unitAmount.asKnown() == null) 0 else 1) + - (if (tierLowerBound.asKnown() == null) 0 else 1) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Tier && - unitAmount == other.unitAmount && - tierLowerBound == other.tierLowerBound && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(unitAmount, tierLowerBound, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Tier{unitAmount=$unitAmount, tierLowerBound=$tierLowerBound, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is BulkWithFiltersConfig && - filters == other.filters && - tiers == other.tiers && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(filters, tiers, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BulkWithFiltersConfig{filters=$filters, tiers=$tiers, additionalProperties=$additionalProperties}" - } - - /** The cadence to bill for this price on. */ - class Cadence - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - val ANNUAL = of("annual") - - val SEMI_ANNUAL = of("semi_annual") - - val MONTHLY = of("monthly") - - val QUARTERLY = of("quarterly") - - val ONE_TIME = of("one_time") - - val CUSTOM = of("custom") - - fun of(value: String) = Cadence(JsonField.of(value)) - } - - /** An enum containing [Cadence]'s known values. */ - enum class Known { - ANNUAL, - SEMI_ANNUAL, - MONTHLY, - QUARTERLY, - ONE_TIME, - CUSTOM, - } - - /** - * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Cadence] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - ANNUAL, - SEMI_ANNUAL, - MONTHLY, - QUARTERLY, - ONE_TIME, - CUSTOM, - /** - * An enum member indicating that [Cadence] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - ANNUAL -> Value.ANNUAL - SEMI_ANNUAL -> Value.SEMI_ANNUAL - MONTHLY -> Value.MONTHLY - QUARTERLY -> Value.QUARTERLY - ONE_TIME -> Value.ONE_TIME - CUSTOM -> Value.CUSTOM - else -> Value._UNKNOWN + * Returns an immutable instance of [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```kotlin + * .tierLowerBound() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("tierLowerBound", tierLowerBound), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) } - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - ANNUAL -> Known.ANNUAL - SEMI_ANNUAL -> Known.SEMI_ANNUAL - MONTHLY -> Known.MONTHLY - QUARTERLY -> Known.QUARTERLY - ONE_TIME -> Known.ONE_TIME - CUSTOM -> Known.CUSTOM - else -> throw OrbInvalidDataException("Unknown Cadence: $value") + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + tierLowerBound() + unitAmount() + validated = true } - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString() - ?: throw OrbInvalidDataException("Value is not a String") + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - private var validated: Boolean = false + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (tierLowerBound.asKnown() == null) 0 else 1) + + (if (unitAmount.asKnown() == null) 0 else 1) - fun validate(): Cadence = apply { - if (validated) { - return@apply - } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - known() - validated = true - } + return other is Tier && + tierLowerBound == other.tierLowerBound && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false + private val hashCode: Int by lazy { + Objects.hash(tierLowerBound, unitAmount, additionalProperties) } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is Cadence && value == other.value + return other is TieredWithProrationConfig && + tiers == other.tiers && + additionalProperties == other.additionalProperties } - override fun hashCode() = value.hashCode() + private val hashCode: Int by lazy { Objects.hash(tiers, additionalProperties) } - override fun toString() = value.toString() + override fun hashCode(): Int = hashCode + + override fun toString() = + "TieredWithProrationConfig{tiers=$tiers, additionalProperties=$additionalProperties}" } /** @@ -16564,12 +20138,12 @@ private constructor( return true } - return other is BulkWithFilters && - bulkWithFiltersConfig == other.bulkWithFiltersConfig && + return other is TieredWithProration && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && + tieredWithProrationConfig == other.tieredWithProrationConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && @@ -16588,11 +20162,11 @@ private constructor( private val hashCode: Int by lazy { Objects.hash( - bulkWithFiltersConfig, cadence, itemId, modelType, name, + tieredWithProrationConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -16613,17 +20187,18 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "BulkWithFilters{bulkWithFiltersConfig=$bulkWithFiltersConfig, cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "TieredWithProration{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredWithProrationConfig=$tieredWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class TieredWithProration + class GroupedWithMinMaxThresholds @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, + private val groupedWithMinMaxThresholdsConfig: + JsonField, private val itemId: JsonField, private val modelType: JsonValue, private val name: JsonField, - private val tieredWithProrationConfig: JsonField, private val billableMetricId: JsonField, private val billedInAdvance: JsonField, private val billingCycleConfiguration: JsonField, @@ -16646,6 +20221,11 @@ private constructor( @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), + @JsonProperty("grouped_with_min_max_thresholds_config") + @ExcludeMissing + groupedWithMinMaxThresholdsConfig: + JsonField = + JsonMissing.of(), @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), @@ -16655,10 +20235,6 @@ private constructor( @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("tiered_with_proration_config") - @ExcludeMissing - tieredWithProrationConfig: JsonField = - JsonMissing.of(), @JsonProperty("billable_metric_id") @ExcludeMissing billableMetricId: JsonField = JsonMissing.of(), @@ -16703,10 +20279,10 @@ private constructor( referenceId: JsonField = JsonMissing.of(), ) : this( cadence, + groupedWithMinMaxThresholdsConfig, itemId, modelType, name, - tieredWithProrationConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -16732,6 +20308,18 @@ private constructor( */ fun cadence(): Cadence = cadence.getRequired("cadence") + /** + * Configuration for grouped_with_min_max_thresholds pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupedWithMinMaxThresholdsConfig(): GroupedWithMinMaxThresholdsConfig = + groupedWithMinMaxThresholdsConfig.getRequired( + "grouped_with_min_max_thresholds_config" + ) + /** * The id of the item the price will be associated with. * @@ -16746,7 +20334,7 @@ private constructor( * * Expected to always return the following: * ```kotlin - * JsonValue.from("tiered_with_proration") + * JsonValue.from("grouped_with_min_max_thresholds") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -16763,16 +20351,6 @@ private constructor( */ fun name(): String = name.getRequired("name") - /** - * Configuration for tiered_with_proration pricing - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun tieredWithProrationConfig(): TieredWithProrationConfig = - tieredWithProrationConfig.getRequired("tiered_with_proration_config") - /** * The id of the billable metric for the price. Only needed if the price is * usage-based. @@ -16902,6 +20480,17 @@ private constructor( @ExcludeMissing fun _cadence(): JsonField = cadence + /** + * Returns the raw JSON value of [groupedWithMinMaxThresholdsConfig]. + * + * Unlike [groupedWithMinMaxThresholdsConfig], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("grouped_with_min_max_thresholds_config") + @ExcludeMissing + fun _groupedWithMinMaxThresholdsConfig(): + JsonField = groupedWithMinMaxThresholdsConfig + /** * Returns the raw JSON value of [itemId]. * @@ -16918,17 +20507,6 @@ private constructor( */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - /** - * Returns the raw JSON value of [tieredWithProrationConfig]. - * - * Unlike [tieredWithProrationConfig], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("tiered_with_proration_config") - @ExcludeMissing - fun _tieredWithProrationConfig(): JsonField = - tieredWithProrationConfig - /** * Returns the raw JSON value of [billableMetricId]. * @@ -17078,28 +20656,30 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [TieredWithProration]. + * [GroupedWithMinMaxThresholds]. * * The following fields are required: * ```kotlin * .cadence() + * .groupedWithMinMaxThresholdsConfig() * .itemId() * .name() - * .tieredWithProrationConfig() * ``` */ fun builder() = Builder() } - /** A builder for [TieredWithProration]. */ + /** A builder for [GroupedWithMinMaxThresholds]. */ class Builder internal constructor() { private var cadence: JsonField? = null + private var groupedWithMinMaxThresholdsConfig: + JsonField? = + null private var itemId: JsonField? = null - private var modelType: JsonValue = JsonValue.from("tiered_with_proration") + private var modelType: JsonValue = + JsonValue.from("grouped_with_min_max_thresholds") private var name: JsonField? = null - private var tieredWithProrationConfig: JsonField? = - null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() private var billingCycleConfiguration: JsonField = @@ -17121,30 +20701,33 @@ private constructor( private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(tieredWithProration: TieredWithProration) = apply { - cadence = tieredWithProration.cadence - itemId = tieredWithProration.itemId - modelType = tieredWithProration.modelType - name = tieredWithProration.name - tieredWithProrationConfig = tieredWithProration.tieredWithProrationConfig - billableMetricId = tieredWithProration.billableMetricId - billedInAdvance = tieredWithProration.billedInAdvance - billingCycleConfiguration = tieredWithProration.billingCycleConfiguration - conversionRate = tieredWithProration.conversionRate - conversionRateConfig = tieredWithProration.conversionRateConfig - currency = tieredWithProration.currency - dimensionalPriceConfiguration = - tieredWithProration.dimensionalPriceConfiguration - externalPriceId = tieredWithProration.externalPriceId - fixedPriceQuantity = tieredWithProration.fixedPriceQuantity - invoiceGroupingKey = tieredWithProration.invoiceGroupingKey - invoicingCycleConfiguration = - tieredWithProration.invoicingCycleConfiguration - metadata = tieredWithProration.metadata - referenceId = tieredWithProration.referenceId - additionalProperties = - tieredWithProration.additionalProperties.toMutableMap() - } + internal fun from(groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds) = + apply { + cadence = groupedWithMinMaxThresholds.cadence + groupedWithMinMaxThresholdsConfig = + groupedWithMinMaxThresholds.groupedWithMinMaxThresholdsConfig + itemId = groupedWithMinMaxThresholds.itemId + modelType = groupedWithMinMaxThresholds.modelType + name = groupedWithMinMaxThresholds.name + billableMetricId = groupedWithMinMaxThresholds.billableMetricId + billedInAdvance = groupedWithMinMaxThresholds.billedInAdvance + billingCycleConfiguration = + groupedWithMinMaxThresholds.billingCycleConfiguration + conversionRate = groupedWithMinMaxThresholds.conversionRate + conversionRateConfig = groupedWithMinMaxThresholds.conversionRateConfig + currency = groupedWithMinMaxThresholds.currency + dimensionalPriceConfiguration = + groupedWithMinMaxThresholds.dimensionalPriceConfiguration + externalPriceId = groupedWithMinMaxThresholds.externalPriceId + fixedPriceQuantity = groupedWithMinMaxThresholds.fixedPriceQuantity + invoiceGroupingKey = groupedWithMinMaxThresholds.invoiceGroupingKey + invoicingCycleConfiguration = + groupedWithMinMaxThresholds.invoicingCycleConfiguration + metadata = groupedWithMinMaxThresholds.metadata + referenceId = groupedWithMinMaxThresholds.referenceId + additionalProperties = + groupedWithMinMaxThresholds.additionalProperties.toMutableMap() + } /** The cadence to bill for this price on. */ fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) @@ -17158,6 +20741,29 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + /** Configuration for grouped_with_min_max_thresholds pricing */ + fun groupedWithMinMaxThresholdsConfig( + groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + ) = + groupedWithMinMaxThresholdsConfig( + JsonField.of(groupedWithMinMaxThresholdsConfig) + ) + + /** + * Sets [Builder.groupedWithMinMaxThresholdsConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.groupedWithMinMaxThresholdsConfig] with a + * well-typed [GroupedWithMinMaxThresholdsConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun groupedWithMinMaxThresholdsConfig( + groupedWithMinMaxThresholdsConfig: + JsonField + ) = apply { + this.groupedWithMinMaxThresholdsConfig = groupedWithMinMaxThresholdsConfig + } + /** The id of the item the price will be associated with. */ fun itemId(itemId: String) = itemId(JsonField.of(itemId)) @@ -17176,7 +20782,7 @@ private constructor( * It is usually unnecessary to call this method because the field defaults to * the following: * ```kotlin - * JsonValue.from("tiered_with_proration") + * JsonValue.from("grouped_with_min_max_thresholds") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -17196,22 +20802,6 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } - /** Configuration for tiered_with_proration pricing */ - fun tieredWithProrationConfig( - tieredWithProrationConfig: TieredWithProrationConfig - ) = tieredWithProrationConfig(JsonField.of(tieredWithProrationConfig)) - - /** - * Sets [Builder.tieredWithProrationConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.tieredWithProrationConfig] with a well-typed - * [TieredWithProrationConfig] value instead. This method is primarily for - * setting the field to an undocumented or not yet supported value. - */ - fun tieredWithProrationConfig( - tieredWithProrationConfig: JsonField - ) = apply { this.tieredWithProrationConfig = tieredWithProrationConfig } - /** * The id of the billable metric for the price. Only needed if the price is * usage-based. @@ -17541,27 +21131,30 @@ private constructor( } /** - * Returns an immutable instance of [TieredWithProration]. + * Returns an immutable instance of [GroupedWithMinMaxThresholds]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```kotlin * .cadence() + * .groupedWithMinMaxThresholdsConfig() * .itemId() * .name() - * .tieredWithProrationConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): TieredWithProration = - TieredWithProration( + fun build(): GroupedWithMinMaxThresholds = + GroupedWithMinMaxThresholds( checkRequired("cadence", cadence), + checkRequired( + "groupedWithMinMaxThresholdsConfig", + groupedWithMinMaxThresholdsConfig, + ), checkRequired("itemId", itemId), modelType, checkRequired("name", name), - checkRequired("tieredWithProrationConfig", tieredWithProrationConfig), billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -17581,20 +21174,20 @@ private constructor( private var validated: Boolean = false - fun validate(): TieredWithProration = apply { + fun validate(): GroupedWithMinMaxThresholds = apply { if (validated) { return@apply } cadence().validate() + groupedWithMinMaxThresholdsConfig().validate() itemId() _modelType().let { - if (it != JsonValue.from("tiered_with_proration")) { + if (it != JsonValue.from("grouped_with_min_max_thresholds")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } name() - tieredWithProrationConfig().validate() billableMetricId() billedInAdvance() billingCycleConfiguration()?.validate() @@ -17627,12 +21220,12 @@ private constructor( */ internal fun validity(): Int = (cadence.asKnown()?.validity() ?: 0) + + (groupedWithMinMaxThresholdsConfig.asKnown()?.validity() ?: 0) + (if (itemId.asKnown() == null) 0 else 1) + modelType.let { - if (it == JsonValue.from("tiered_with_proration")) 1 else 0 + if (it == JsonValue.from("grouped_with_min_max_thresholds")) 1 else 0 } + (if (name.asKnown() == null) 0 else 1) + - (tieredWithProrationConfig.asKnown()?.validity() ?: 0) + (if (billableMetricId.asKnown() == null) 0 else 1) + (if (billedInAdvance.asKnown() == null) 0 else 1) + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + @@ -17804,40 +21397,108 @@ private constructor( override fun toString() = value.toString() } - /** Configuration for tiered_with_proration pricing */ - class TieredWithProrationConfig + /** Configuration for grouped_with_min_max_thresholds pricing */ + class GroupedWithMinMaxThresholdsConfig @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val tiers: JsonField>, + private val groupingKey: JsonField, + private val maximumCharge: JsonField, + private val minimumCharge: JsonField, + private val perUnitRate: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("tiers") + @JsonProperty("grouping_key") @ExcludeMissing - tiers: JsonField> = JsonMissing.of() - ) : this(tiers, mutableMapOf()) + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("maximum_charge") + @ExcludeMissing + maximumCharge: JsonField = JsonMissing.of(), + @JsonProperty("minimum_charge") + @ExcludeMissing + minimumCharge: JsonField = JsonMissing.of(), + @JsonProperty("per_unit_rate") + @ExcludeMissing + perUnitRate: JsonField = JsonMissing.of(), + ) : this(groupingKey, maximumCharge, minimumCharge, perUnitRate, mutableMapOf()) /** - * Tiers for rating based on total usage quantities into the specified tier with - * proration + * The event property used to group before applying thresholds * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). */ - fun tiers(): List = tiers.getRequired("tiers") + fun groupingKey(): String = groupingKey.getRequired("grouping_key") /** - * Returns the raw JSON value of [tiers]. + * The maximum amount to charge each group * - * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected - * type. + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). */ - @JsonProperty("tiers") + fun maximumCharge(): String = maximumCharge.getRequired("maximum_charge") + + /** + * The minimum amount to charge each group, regardless of usage + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun minimumCharge(): String = minimumCharge.getRequired("minimum_charge") + + /** + * The base price charged per group + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun perUnitRate(): String = perUnitRate.getRequired("per_unit_rate") + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") @ExcludeMissing - fun _tiers(): JsonField> = tiers + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [maximumCharge]. + * + * Unlike [maximumCharge], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("maximum_charge") + @ExcludeMissing + fun _maximumCharge(): JsonField = maximumCharge + + /** + * Returns the raw JSON value of [minimumCharge]. + * + * Unlike [minimumCharge], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("minimum_charge") + @ExcludeMissing + fun _minimumCharge(): JsonField = minimumCharge + + /** + * Returns the raw JSON value of [perUnitRate]. + * + * Unlike [perUnitRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("per_unit_rate") + @ExcludeMissing + fun _perUnitRate(): JsonField = perUnitRate @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -17855,58 +21516,99 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [TieredWithProrationConfig]. + * [GroupedWithMinMaxThresholdsConfig]. * * The following fields are required: * ```kotlin - * .tiers() + * .groupingKey() + * .maximumCharge() + * .minimumCharge() + * .perUnitRate() * ``` */ fun builder() = Builder() } - /** A builder for [TieredWithProrationConfig]. */ + /** A builder for [GroupedWithMinMaxThresholdsConfig]. */ class Builder internal constructor() { - private var tiers: JsonField>? = null + private var groupingKey: JsonField? = null + private var maximumCharge: JsonField? = null + private var minimumCharge: JsonField? = null + private var perUnitRate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(tieredWithProrationConfig: TieredWithProrationConfig) = - apply { - tiers = tieredWithProrationConfig.tiers.map { it.toMutableList() } - additionalProperties = - tieredWithProrationConfig.additionalProperties.toMutableMap() - } + internal fun from( + groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + ) = apply { + groupingKey = groupedWithMinMaxThresholdsConfig.groupingKey + maximumCharge = groupedWithMinMaxThresholdsConfig.maximumCharge + minimumCharge = groupedWithMinMaxThresholdsConfig.minimumCharge + perUnitRate = groupedWithMinMaxThresholdsConfig.perUnitRate + additionalProperties = + groupedWithMinMaxThresholdsConfig.additionalProperties + .toMutableMap() + } - /** - * Tiers for rating based on total usage quantities into the specified tier - * with proration - */ - fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + /** The event property used to group before applying thresholds */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) /** - * Sets [Builder.tiers] to an arbitrary JSON value. + * Sets [Builder.groupingKey] to an arbitrary JSON value. * - * You should usually call [Builder.tiers] with a well-typed `List` + * You should usually call [Builder.groupingKey] with a well-typed [String] * value instead. This method is primarily for setting the field to an * undocumented or not yet supported value. */ - fun tiers(tiers: JsonField>) = apply { - this.tiers = tiers.map { it.toMutableList() } + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey } + /** The maximum amount to charge each group */ + fun maximumCharge(maximumCharge: String) = + maximumCharge(JsonField.of(maximumCharge)) + /** - * Adds a single [Tier] to [tiers]. + * Sets [Builder.maximumCharge] to an arbitrary JSON value. * - * @throws IllegalStateException if the field was previously set to a - * non-list. + * You should usually call [Builder.maximumCharge] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. */ - fun addTier(tier: Tier) = apply { - tiers = - (tiers ?: JsonField.of(mutableListOf())).also { - checkKnown("tiers", it).add(tier) - } + fun maximumCharge(maximumCharge: JsonField) = apply { + this.maximumCharge = maximumCharge + } + + /** The minimum amount to charge each group, regardless of usage */ + fun minimumCharge(minimumCharge: String) = + minimumCharge(JsonField.of(minimumCharge)) + + /** + * Sets [Builder.minimumCharge] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumCharge] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun minimumCharge(minimumCharge: JsonField) = apply { + this.minimumCharge = minimumCharge + } + + /** The base price charged per group */ + fun perUnitRate(perUnitRate: String) = + perUnitRate(JsonField.of(perUnitRate)) + + /** + * Sets [Builder.perUnitRate] to an arbitrary JSON value. + * + * You should usually call [Builder.perUnitRate] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun perUnitRate(perUnitRate: JsonField) = apply { + this.perUnitRate = perUnitRate } fun additionalProperties(additionalProperties: Map) = @@ -17932,291 +21634,91 @@ private constructor( } /** - * Returns an immutable instance of [TieredWithProrationConfig]. + * Returns an immutable instance of [GroupedWithMinMaxThresholdsConfig]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```kotlin - * .tiers() + * .groupingKey() + * .maximumCharge() + * .minimumCharge() + * .perUnitRate() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): TieredWithProrationConfig = - TieredWithProrationConfig( - checkRequired("tiers", tiers).map { it.toImmutable() }, + fun build(): GroupedWithMinMaxThresholdsConfig = + GroupedWithMinMaxThresholdsConfig( + checkRequired("groupingKey", groupingKey), + checkRequired("maximumCharge", maximumCharge), + checkRequired("minimumCharge", minimumCharge), + checkRequired("perUnitRate", perUnitRate), additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): TieredWithProrationConfig = apply { + fun validate(): GroupedWithMinMaxThresholdsConfig = apply { if (validated) { return@apply } - tiers().forEach { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (tiers.asKnown()?.sumOf { it.validity().toInt() } ?: 0) - - /** Configuration for a single tiered with proration tier */ - class Tier - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val tierLowerBound: JsonField, - private val unitAmount: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("tier_lower_bound") - @ExcludeMissing - tierLowerBound: JsonField = JsonMissing.of(), - @JsonProperty("unit_amount") - @ExcludeMissing - unitAmount: JsonField = JsonMissing.of(), - ) : this(tierLowerBound, unitAmount, mutableMapOf()) - - /** - * Inclusive tier starting value - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type - * or is unexpectedly missing or null (e.g. if the server responded with - * an unexpected value). - */ - fun tierLowerBound(): String = - tierLowerBound.getRequired("tier_lower_bound") - - /** - * Amount per unit - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type - * or is unexpectedly missing or null (e.g. if the server responded with - * an unexpected value). - */ - fun unitAmount(): String = unitAmount.getRequired("unit_amount") - - /** - * Returns the raw JSON value of [tierLowerBound]. - * - * Unlike [tierLowerBound], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("tier_lower_bound") - @ExcludeMissing - fun _tierLowerBound(): JsonField = tierLowerBound - - /** - * Returns the raw JSON value of [unitAmount]. - * - * Unlike [unitAmount], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("unit_amount") - @ExcludeMissing - fun _unitAmount(): JsonField = unitAmount - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [Tier]. - * - * The following fields are required: - * ```kotlin - * .tierLowerBound() - * .unitAmount() - * ``` - */ - fun builder() = Builder() - } - - /** A builder for [Tier]. */ - class Builder internal constructor() { - - private var tierLowerBound: JsonField? = null - private var unitAmount: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - internal fun from(tier: Tier) = apply { - tierLowerBound = tier.tierLowerBound - unitAmount = tier.unitAmount - additionalProperties = tier.additionalProperties.toMutableMap() - } - - /** Inclusive tier starting value */ - fun tierLowerBound(tierLowerBound: String) = - tierLowerBound(JsonField.of(tierLowerBound)) - - /** - * Sets [Builder.tierLowerBound] to an arbitrary JSON value. - * - * You should usually call [Builder.tierLowerBound] with a well-typed - * [String] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun tierLowerBound(tierLowerBound: JsonField) = apply { - this.tierLowerBound = tierLowerBound - } - - /** Amount per unit */ - fun unitAmount(unitAmount: String) = - unitAmount(JsonField.of(unitAmount)) - - /** - * Sets [Builder.unitAmount] to an arbitrary JSON value. - * - * You should usually call [Builder.unitAmount] with a well-typed - * [String] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun unitAmount(unitAmount: JsonField) = apply { - this.unitAmount = unitAmount - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Tier]. - * - * Further updates to this [Builder] will not mutate the returned - * instance. - * - * The following fields are required: - * ```kotlin - * .tierLowerBound() - * .unitAmount() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Tier = - Tier( - checkRequired("tierLowerBound", tierLowerBound), - checkRequired("unitAmount", unitAmount), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Tier = apply { - if (validated) { - return@apply - } - - tierLowerBound() - unitAmount() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this - * object recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (if (tierLowerBound.asKnown() == null) 0 else 1) + - (if (unitAmount.asKnown() == null) 0 else 1) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Tier && - tierLowerBound == other.tierLowerBound && - unitAmount == other.unitAmount && - additionalProperties == other.additionalProperties - } + groupingKey() + maximumCharge() + minimumCharge() + perUnitRate() + validated = true + } - private val hashCode: Int by lazy { - Objects.hash(tierLowerBound, unitAmount, additionalProperties) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false } - override fun hashCode(): Int = hashCode - - override fun toString() = - "Tier{tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" - } + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (groupingKey.asKnown() == null) 0 else 1) + + (if (maximumCharge.asKnown() == null) 0 else 1) + + (if (minimumCharge.asKnown() == null) 0 else 1) + + (if (perUnitRate.asKnown() == null) 0 else 1) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is TieredWithProrationConfig && - tiers == other.tiers && + return other is GroupedWithMinMaxThresholdsConfig && + groupingKey == other.groupingKey && + maximumCharge == other.maximumCharge && + minimumCharge == other.minimumCharge && + perUnitRate == other.perUnitRate && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(tiers, additionalProperties) } + private val hashCode: Int by lazy { + Objects.hash( + groupingKey, + maximumCharge, + minimumCharge, + perUnitRate, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode override fun toString() = - "TieredWithProrationConfig{tiers=$tiers, additionalProperties=$additionalProperties}" + "GroupedWithMinMaxThresholdsConfig{groupingKey=$groupingKey, maximumCharge=$maximumCharge, minimumCharge=$minimumCharge, perUnitRate=$perUnitRate, additionalProperties=$additionalProperties}" } /** @@ -18333,12 +21835,13 @@ private constructor( return true } - return other is TieredWithProration && + return other is GroupedWithMinMaxThresholds && cadence == other.cadence && + groupedWithMinMaxThresholdsConfig == + other.groupedWithMinMaxThresholdsConfig && itemId == other.itemId && modelType == other.modelType && name == other.name && - tieredWithProrationConfig == other.tieredWithProrationConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && @@ -18358,10 +21861,10 @@ private constructor( private val hashCode: Int by lazy { Objects.hash( cadence, + groupedWithMinMaxThresholdsConfig, itemId, modelType, name, - tieredWithProrationConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -18382,15 +21885,15 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "TieredWithProration{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredWithProrationConfig=$tieredWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "GroupedWithMinMaxThresholds{cadence=$cadence, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class GroupedWithMinMaxThresholds + class CumulativeGroupedAllocation @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, - private val groupedWithMinMaxThresholdsConfig: - JsonField, + private val cumulativeGroupedAllocationConfig: + JsonField, private val itemId: JsonField, private val modelType: JsonValue, private val name: JsonField, @@ -18416,10 +21919,10 @@ private constructor( @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), - @JsonProperty("grouped_with_min_max_thresholds_config") + @JsonProperty("cumulative_grouped_allocation_config") @ExcludeMissing - groupedWithMinMaxThresholdsConfig: - JsonField = + cumulativeGroupedAllocationConfig: + JsonField = JsonMissing.of(), @JsonProperty("item_id") @ExcludeMissing @@ -18474,7 +21977,7 @@ private constructor( referenceId: JsonField = JsonMissing.of(), ) : this( cadence, - groupedWithMinMaxThresholdsConfig, + cumulativeGroupedAllocationConfig, itemId, modelType, name, @@ -18504,15 +22007,15 @@ private constructor( fun cadence(): Cadence = cadence.getRequired("cadence") /** - * Configuration for grouped_with_min_max_thresholds pricing + * Configuration for cumulative_grouped_allocation pricing * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected * value). */ - fun groupedWithMinMaxThresholdsConfig(): GroupedWithMinMaxThresholdsConfig = - groupedWithMinMaxThresholdsConfig.getRequired( - "grouped_with_min_max_thresholds_config" + fun cumulativeGroupedAllocationConfig(): CumulativeGroupedAllocationConfig = + cumulativeGroupedAllocationConfig.getRequired( + "cumulative_grouped_allocation_config" ) /** @@ -18529,7 +22032,7 @@ private constructor( * * Expected to always return the following: * ```kotlin - * JsonValue.from("grouped_with_min_max_thresholds") + * JsonValue.from("cumulative_grouped_allocation") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -18676,15 +22179,15 @@ private constructor( fun _cadence(): JsonField = cadence /** - * Returns the raw JSON value of [groupedWithMinMaxThresholdsConfig]. + * Returns the raw JSON value of [cumulativeGroupedAllocationConfig]. * - * Unlike [groupedWithMinMaxThresholdsConfig], this method doesn't throw if the JSON + * Unlike [cumulativeGroupedAllocationConfig], this method doesn't throw if the JSON * field has an unexpected type. */ - @JsonProperty("grouped_with_min_max_thresholds_config") + @JsonProperty("cumulative_grouped_allocation_config") @ExcludeMissing - fun _groupedWithMinMaxThresholdsConfig(): - JsonField = groupedWithMinMaxThresholdsConfig + fun _cumulativeGroupedAllocationConfig(): + JsonField = cumulativeGroupedAllocationConfig /** * Returns the raw JSON value of [itemId]. @@ -18851,12 +22354,12 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [GroupedWithMinMaxThresholds]. + * [CumulativeGroupedAllocation]. * * The following fields are required: * ```kotlin * .cadence() - * .groupedWithMinMaxThresholdsConfig() + * .cumulativeGroupedAllocationConfig() * .itemId() * .name() * ``` @@ -18864,16 +22367,16 @@ private constructor( fun builder() = Builder() } - /** A builder for [GroupedWithMinMaxThresholds]. */ + /** A builder for [CumulativeGroupedAllocation]. */ class Builder internal constructor() { private var cadence: JsonField? = null - private var groupedWithMinMaxThresholdsConfig: - JsonField? = + private var cumulativeGroupedAllocationConfig: + JsonField? = null private var itemId: JsonField? = null private var modelType: JsonValue = - JsonValue.from("grouped_with_min_max_thresholds") + JsonValue.from("cumulative_grouped_allocation") private var name: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() @@ -18896,32 +22399,32 @@ private constructor( private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds) = + internal fun from(cumulativeGroupedAllocation: CumulativeGroupedAllocation) = apply { - cadence = groupedWithMinMaxThresholds.cadence - groupedWithMinMaxThresholdsConfig = - groupedWithMinMaxThresholds.groupedWithMinMaxThresholdsConfig - itemId = groupedWithMinMaxThresholds.itemId - modelType = groupedWithMinMaxThresholds.modelType - name = groupedWithMinMaxThresholds.name - billableMetricId = groupedWithMinMaxThresholds.billableMetricId - billedInAdvance = groupedWithMinMaxThresholds.billedInAdvance + cadence = cumulativeGroupedAllocation.cadence + cumulativeGroupedAllocationConfig = + cumulativeGroupedAllocation.cumulativeGroupedAllocationConfig + itemId = cumulativeGroupedAllocation.itemId + modelType = cumulativeGroupedAllocation.modelType + name = cumulativeGroupedAllocation.name + billableMetricId = cumulativeGroupedAllocation.billableMetricId + billedInAdvance = cumulativeGroupedAllocation.billedInAdvance billingCycleConfiguration = - groupedWithMinMaxThresholds.billingCycleConfiguration - conversionRate = groupedWithMinMaxThresholds.conversionRate - conversionRateConfig = groupedWithMinMaxThresholds.conversionRateConfig - currency = groupedWithMinMaxThresholds.currency + cumulativeGroupedAllocation.billingCycleConfiguration + conversionRate = cumulativeGroupedAllocation.conversionRate + conversionRateConfig = cumulativeGroupedAllocation.conversionRateConfig + currency = cumulativeGroupedAllocation.currency dimensionalPriceConfiguration = - groupedWithMinMaxThresholds.dimensionalPriceConfiguration - externalPriceId = groupedWithMinMaxThresholds.externalPriceId - fixedPriceQuantity = groupedWithMinMaxThresholds.fixedPriceQuantity - invoiceGroupingKey = groupedWithMinMaxThresholds.invoiceGroupingKey + cumulativeGroupedAllocation.dimensionalPriceConfiguration + externalPriceId = cumulativeGroupedAllocation.externalPriceId + fixedPriceQuantity = cumulativeGroupedAllocation.fixedPriceQuantity + invoiceGroupingKey = cumulativeGroupedAllocation.invoiceGroupingKey invoicingCycleConfiguration = - groupedWithMinMaxThresholds.invoicingCycleConfiguration - metadata = groupedWithMinMaxThresholds.metadata - referenceId = groupedWithMinMaxThresholds.referenceId + cumulativeGroupedAllocation.invoicingCycleConfiguration + metadata = cumulativeGroupedAllocation.metadata + referenceId = cumulativeGroupedAllocation.referenceId additionalProperties = - groupedWithMinMaxThresholds.additionalProperties.toMutableMap() + cumulativeGroupedAllocation.additionalProperties.toMutableMap() } /** The cadence to bill for this price on. */ @@ -18936,27 +22439,27 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - /** Configuration for grouped_with_min_max_thresholds pricing */ - fun groupedWithMinMaxThresholdsConfig( - groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + /** Configuration for cumulative_grouped_allocation pricing */ + fun cumulativeGroupedAllocationConfig( + cumulativeGroupedAllocationConfig: CumulativeGroupedAllocationConfig ) = - groupedWithMinMaxThresholdsConfig( - JsonField.of(groupedWithMinMaxThresholdsConfig) + cumulativeGroupedAllocationConfig( + JsonField.of(cumulativeGroupedAllocationConfig) ) /** - * Sets [Builder.groupedWithMinMaxThresholdsConfig] to an arbitrary JSON value. + * Sets [Builder.cumulativeGroupedAllocationConfig] to an arbitrary JSON value. * - * You should usually call [Builder.groupedWithMinMaxThresholdsConfig] with a - * well-typed [GroupedWithMinMaxThresholdsConfig] value instead. This method is + * You should usually call [Builder.cumulativeGroupedAllocationConfig] with a + * well-typed [CumulativeGroupedAllocationConfig] value instead. This method is * primarily for setting the field to an undocumented or not yet supported * value. */ - fun groupedWithMinMaxThresholdsConfig( - groupedWithMinMaxThresholdsConfig: - JsonField + fun cumulativeGroupedAllocationConfig( + cumulativeGroupedAllocationConfig: + JsonField ) = apply { - this.groupedWithMinMaxThresholdsConfig = groupedWithMinMaxThresholdsConfig + this.cumulativeGroupedAllocationConfig = cumulativeGroupedAllocationConfig } /** The id of the item the price will be associated with. */ @@ -18977,7 +22480,7 @@ private constructor( * It is usually unnecessary to call this method because the field defaults to * the following: * ```kotlin - * JsonValue.from("grouped_with_min_max_thresholds") + * JsonValue.from("cumulative_grouped_allocation") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -19326,26 +22829,26 @@ private constructor( } /** - * Returns an immutable instance of [GroupedWithMinMaxThresholds]. + * Returns an immutable instance of [CumulativeGroupedAllocation]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```kotlin * .cadence() - * .groupedWithMinMaxThresholdsConfig() + * .cumulativeGroupedAllocationConfig() * .itemId() * .name() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): GroupedWithMinMaxThresholds = - GroupedWithMinMaxThresholds( + fun build(): CumulativeGroupedAllocation = + CumulativeGroupedAllocation( checkRequired("cadence", cadence), checkRequired( - "groupedWithMinMaxThresholdsConfig", - groupedWithMinMaxThresholdsConfig, + "cumulativeGroupedAllocationConfig", + cumulativeGroupedAllocationConfig, ), checkRequired("itemId", itemId), modelType, @@ -19369,16 +22872,16 @@ private constructor( private var validated: Boolean = false - fun validate(): GroupedWithMinMaxThresholds = apply { + fun validate(): CumulativeGroupedAllocation = apply { if (validated) { return@apply } cadence().validate() - groupedWithMinMaxThresholdsConfig().validate() + cumulativeGroupedAllocationConfig().validate() itemId() _modelType().let { - if (it != JsonValue.from("grouped_with_min_max_thresholds")) { + if (it != JsonValue.from("cumulative_grouped_allocation")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } @@ -19415,10 +22918,10 @@ private constructor( */ internal fun validity(): Int = (cadence.asKnown()?.validity() ?: 0) + - (groupedWithMinMaxThresholdsConfig.asKnown()?.validity() ?: 0) + + (cumulativeGroupedAllocationConfig.asKnown()?.validity() ?: 0) + (if (itemId.asKnown() == null) 0 else 1) + modelType.let { - if (it == JsonValue.from("grouped_with_min_max_thresholds")) 1 else 0 + if (it == JsonValue.from("cumulative_grouped_allocation")) 1 else 0 } + (if (name.asKnown() == null) 0 else 1) + (if (billableMetricId.asKnown() == null) 0 else 1) + @@ -19592,108 +23095,115 @@ private constructor( override fun toString() = value.toString() } - /** Configuration for grouped_with_min_max_thresholds pricing */ - class GroupedWithMinMaxThresholdsConfig + /** Configuration for cumulative_grouped_allocation pricing */ + class CumulativeGroupedAllocationConfig @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( + private val cumulativeAllocation: JsonField, + private val groupAllocation: JsonField, private val groupingKey: JsonField, - private val maximumCharge: JsonField, - private val minimumCharge: JsonField, - private val perUnitRate: JsonField, + private val unitAmount: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("grouping_key") + @JsonProperty("cumulative_allocation") @ExcludeMissing - groupingKey: JsonField = JsonMissing.of(), - @JsonProperty("maximum_charge") + cumulativeAllocation: JsonField = JsonMissing.of(), + @JsonProperty("group_allocation") @ExcludeMissing - maximumCharge: JsonField = JsonMissing.of(), - @JsonProperty("minimum_charge") + groupAllocation: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") @ExcludeMissing - minimumCharge: JsonField = JsonMissing.of(), - @JsonProperty("per_unit_rate") + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") @ExcludeMissing - perUnitRate: JsonField = JsonMissing.of(), - ) : this(groupingKey, maximumCharge, minimumCharge, perUnitRate, mutableMapOf()) + unitAmount: JsonField = JsonMissing.of(), + ) : this( + cumulativeAllocation, + groupAllocation, + groupingKey, + unitAmount, + mutableMapOf(), + ) /** - * The event property used to group before applying thresholds + * The overall allocation across all groups * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). */ - fun groupingKey(): String = groupingKey.getRequired("grouping_key") + fun cumulativeAllocation(): String = + cumulativeAllocation.getRequired("cumulative_allocation") /** - * The maximum amount to charge each group + * The allocation per individual group * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). */ - fun maximumCharge(): String = maximumCharge.getRequired("maximum_charge") + fun groupAllocation(): String = groupAllocation.getRequired("group_allocation") /** - * The minimum amount to charge each group, regardless of usage + * The event property used to group usage before applying allocations * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). */ - fun minimumCharge(): String = minimumCharge.getRequired("minimum_charge") + fun groupingKey(): String = groupingKey.getRequired("grouping_key") /** - * The base price charged per group + * The amount to charge for each unit outside of the allocation * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). */ - fun perUnitRate(): String = perUnitRate.getRequired("per_unit_rate") + fun unitAmount(): String = unitAmount.getRequired("unit_amount") /** - * Returns the raw JSON value of [groupingKey]. + * Returns the raw JSON value of [cumulativeAllocation]. * - * Unlike [groupingKey], this method doesn't throw if the JSON field has an - * unexpected type. + * Unlike [cumulativeAllocation], this method doesn't throw if the JSON field + * has an unexpected type. */ - @JsonProperty("grouping_key") + @JsonProperty("cumulative_allocation") @ExcludeMissing - fun _groupingKey(): JsonField = groupingKey + fun _cumulativeAllocation(): JsonField = cumulativeAllocation /** - * Returns the raw JSON value of [maximumCharge]. + * Returns the raw JSON value of [groupAllocation]. * - * Unlike [maximumCharge], this method doesn't throw if the JSON field has an + * Unlike [groupAllocation], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("maximum_charge") + @JsonProperty("group_allocation") @ExcludeMissing - fun _maximumCharge(): JsonField = maximumCharge + fun _groupAllocation(): JsonField = groupAllocation /** - * Returns the raw JSON value of [minimumCharge]. + * Returns the raw JSON value of [groupingKey]. * - * Unlike [minimumCharge], this method doesn't throw if the JSON field has an + * Unlike [groupingKey], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("minimum_charge") + @JsonProperty("grouping_key") @ExcludeMissing - fun _minimumCharge(): JsonField = minimumCharge + fun _groupingKey(): JsonField = groupingKey /** - * Returns the raw JSON value of [perUnitRate]. + * Returns the raw JSON value of [unitAmount]. * - * Unlike [perUnitRate], this method doesn't throw if the JSON field has an + * Unlike [unitAmount], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("per_unit_rate") + @JsonProperty("unit_amount") @ExcludeMissing - fun _perUnitRate(): JsonField = perUnitRate + fun _unitAmount(): JsonField = unitAmount @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -19711,99 +23221,99 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [GroupedWithMinMaxThresholdsConfig]. + * [CumulativeGroupedAllocationConfig]. * * The following fields are required: * ```kotlin + * .cumulativeAllocation() + * .groupAllocation() * .groupingKey() - * .maximumCharge() - * .minimumCharge() - * .perUnitRate() + * .unitAmount() * ``` */ fun builder() = Builder() } - /** A builder for [GroupedWithMinMaxThresholdsConfig]. */ + /** A builder for [CumulativeGroupedAllocationConfig]. */ class Builder internal constructor() { + private var cumulativeAllocation: JsonField? = null + private var groupAllocation: JsonField? = null private var groupingKey: JsonField? = null - private var maximumCharge: JsonField? = null - private var minimumCharge: JsonField? = null - private var perUnitRate: JsonField? = null + private var unitAmount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from( - groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + cumulativeGroupedAllocationConfig: CumulativeGroupedAllocationConfig ) = apply { - groupingKey = groupedWithMinMaxThresholdsConfig.groupingKey - maximumCharge = groupedWithMinMaxThresholdsConfig.maximumCharge - minimumCharge = groupedWithMinMaxThresholdsConfig.minimumCharge - perUnitRate = groupedWithMinMaxThresholdsConfig.perUnitRate + cumulativeAllocation = + cumulativeGroupedAllocationConfig.cumulativeAllocation + groupAllocation = cumulativeGroupedAllocationConfig.groupAllocation + groupingKey = cumulativeGroupedAllocationConfig.groupingKey + unitAmount = cumulativeGroupedAllocationConfig.unitAmount additionalProperties = - groupedWithMinMaxThresholdsConfig.additionalProperties + cumulativeGroupedAllocationConfig.additionalProperties .toMutableMap() } - /** The event property used to group before applying thresholds */ - fun groupingKey(groupingKey: String) = - groupingKey(JsonField.of(groupingKey)) + /** The overall allocation across all groups */ + fun cumulativeAllocation(cumulativeAllocation: String) = + cumulativeAllocation(JsonField.of(cumulativeAllocation)) /** - * Sets [Builder.groupingKey] to an arbitrary JSON value. + * Sets [Builder.cumulativeAllocation] to an arbitrary JSON value. * - * You should usually call [Builder.groupingKey] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. + * You should usually call [Builder.cumulativeAllocation] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. */ - fun groupingKey(groupingKey: JsonField) = apply { - this.groupingKey = groupingKey + fun cumulativeAllocation(cumulativeAllocation: JsonField) = apply { + this.cumulativeAllocation = cumulativeAllocation } - /** The maximum amount to charge each group */ - fun maximumCharge(maximumCharge: String) = - maximumCharge(JsonField.of(maximumCharge)) + /** The allocation per individual group */ + fun groupAllocation(groupAllocation: String) = + groupAllocation(JsonField.of(groupAllocation)) /** - * Sets [Builder.maximumCharge] to an arbitrary JSON value. + * Sets [Builder.groupAllocation] to an arbitrary JSON value. * - * You should usually call [Builder.maximumCharge] with a well-typed + * You should usually call [Builder.groupAllocation] with a well-typed * [String] value instead. This method is primarily for setting the field to * an undocumented or not yet supported value. */ - fun maximumCharge(maximumCharge: JsonField) = apply { - this.maximumCharge = maximumCharge + fun groupAllocation(groupAllocation: JsonField) = apply { + this.groupAllocation = groupAllocation } - /** The minimum amount to charge each group, regardless of usage */ - fun minimumCharge(minimumCharge: String) = - minimumCharge(JsonField.of(minimumCharge)) + /** The event property used to group usage before applying allocations */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) /** - * Sets [Builder.minimumCharge] to an arbitrary JSON value. + * Sets [Builder.groupingKey] to an arbitrary JSON value. * - * You should usually call [Builder.minimumCharge] with a well-typed - * [String] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. */ - fun minimumCharge(minimumCharge: JsonField) = apply { - this.minimumCharge = minimumCharge + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey } - /** The base price charged per group */ - fun perUnitRate(perUnitRate: String) = - perUnitRate(JsonField.of(perUnitRate)) + /** The amount to charge for each unit outside of the allocation */ + fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) /** - * Sets [Builder.perUnitRate] to an arbitrary JSON value. + * Sets [Builder.unitAmount] to an arbitrary JSON value. * - * You should usually call [Builder.perUnitRate] with a well-typed [String] + * You should usually call [Builder.unitAmount] with a well-typed [String] * value instead. This method is primarily for setting the field to an * undocumented or not yet supported value. */ - fun perUnitRate(perUnitRate: JsonField) = apply { - this.perUnitRate = perUnitRate + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount } fun additionalProperties(additionalProperties: Map) = @@ -19829,41 +23339,41 @@ private constructor( } /** - * Returns an immutable instance of [GroupedWithMinMaxThresholdsConfig]. + * Returns an immutable instance of [CumulativeGroupedAllocationConfig]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```kotlin + * .cumulativeAllocation() + * .groupAllocation() * .groupingKey() - * .maximumCharge() - * .minimumCharge() - * .perUnitRate() + * .unitAmount() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): GroupedWithMinMaxThresholdsConfig = - GroupedWithMinMaxThresholdsConfig( + fun build(): CumulativeGroupedAllocationConfig = + CumulativeGroupedAllocationConfig( + checkRequired("cumulativeAllocation", cumulativeAllocation), + checkRequired("groupAllocation", groupAllocation), checkRequired("groupingKey", groupingKey), - checkRequired("maximumCharge", maximumCharge), - checkRequired("minimumCharge", minimumCharge), - checkRequired("perUnitRate", perUnitRate), + checkRequired("unitAmount", unitAmount), additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): GroupedWithMinMaxThresholdsConfig = apply { + fun validate(): CumulativeGroupedAllocationConfig = apply { if (validated) { return@apply } + cumulativeAllocation() + groupAllocation() groupingKey() - maximumCharge() - minimumCharge() - perUnitRate() + unitAmount() validated = true } @@ -19882,30 +23392,30 @@ private constructor( * Used for best match union deserialization. */ internal fun validity(): Int = - (if (groupingKey.asKnown() == null) 0 else 1) + - (if (maximumCharge.asKnown() == null) 0 else 1) + - (if (minimumCharge.asKnown() == null) 0 else 1) + - (if (perUnitRate.asKnown() == null) 0 else 1) + (if (cumulativeAllocation.asKnown() == null) 0 else 1) + + (if (groupAllocation.asKnown() == null) 0 else 1) + + (if (groupingKey.asKnown() == null) 0 else 1) + + (if (unitAmount.asKnown() == null) 0 else 1) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is GroupedWithMinMaxThresholdsConfig && + return other is CumulativeGroupedAllocationConfig && + cumulativeAllocation == other.cumulativeAllocation && + groupAllocation == other.groupAllocation && groupingKey == other.groupingKey && - maximumCharge == other.maximumCharge && - minimumCharge == other.minimumCharge && - perUnitRate == other.perUnitRate && + unitAmount == other.unitAmount && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { Objects.hash( + cumulativeAllocation, + groupAllocation, groupingKey, - maximumCharge, - minimumCharge, - perUnitRate, + unitAmount, additionalProperties, ) } @@ -19913,7 +23423,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "GroupedWithMinMaxThresholdsConfig{groupingKey=$groupingKey, maximumCharge=$maximumCharge, minimumCharge=$minimumCharge, perUnitRate=$perUnitRate, additionalProperties=$additionalProperties}" + "CumulativeGroupedAllocationConfig{cumulativeAllocation=$cumulativeAllocation, groupAllocation=$groupAllocation, groupingKey=$groupingKey, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" } /** @@ -20030,10 +23540,10 @@ private constructor( return true } - return other is GroupedWithMinMaxThresholds && + return other is CumulativeGroupedAllocation && cadence == other.cadence && - groupedWithMinMaxThresholdsConfig == - other.groupedWithMinMaxThresholdsConfig && + cumulativeGroupedAllocationConfig == + other.cumulativeGroupedAllocationConfig && itemId == other.itemId && modelType == other.modelType && name == other.name && @@ -20056,7 +23566,7 @@ private constructor( private val hashCode: Int by lazy { Objects.hash( cadence, - groupedWithMinMaxThresholdsConfig, + cumulativeGroupedAllocationConfig, itemId, modelType, name, @@ -20080,7 +23590,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "GroupedWithMinMaxThresholds{cadence=$cadence, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "CumulativeGroupedAllocation{cadence=$cadence, cumulativeGroupedAllocationConfig=$cumulativeGroupedAllocationConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } class Percent diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BetaExternalPlanIdCreatePlanVersionParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BetaExternalPlanIdCreatePlanVersionParams.kt index ad81ac0aa..460e9ff52 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BetaExternalPlanIdCreatePlanVersionParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BetaExternalPlanIdCreatePlanVersionParams.kt @@ -1972,6 +1972,13 @@ private constructor( fun price(cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice) = price(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) + /** + * Alias for calling [price] with + * `Price.ofCumulativeGroupedAllocation(cumulativeGroupedAllocation)`. + */ + fun price(cumulativeGroupedAllocation: Price.CumulativeGroupedAllocation) = + price(Price.ofCumulativeGroupedAllocation(cumulativeGroupedAllocation)) + /** Alias for calling [price] with `Price.ofMinimum(minimum)`. */ fun price(minimum: NewPlanMinimumCompositePrice) = price(Price.ofMinimum(minimum)) @@ -2081,6 +2088,7 @@ private constructor( NewPlanScalableMatrixWithTieredPricingPrice? = null, private val cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice? = null, + private val cumulativeGroupedAllocation: CumulativeGroupedAllocation? = null, private val minimum: NewPlanMinimumCompositePrice? = null, private val percent: Percent? = null, private val eventOutput: EventOutput? = null, @@ -2147,6 +2155,9 @@ private constructor( fun cumulativeGroupedBulk(): NewPlanCumulativeGroupedBulkPrice? = cumulativeGroupedBulk + fun cumulativeGroupedAllocation(): CumulativeGroupedAllocation? = + cumulativeGroupedAllocation + fun minimum(): NewPlanMinimumCompositePrice? = minimum fun percent(): Percent? = percent @@ -2208,6 +2219,8 @@ private constructor( fun isCumulativeGroupedBulk(): Boolean = cumulativeGroupedBulk != null + fun isCumulativeGroupedAllocation(): Boolean = cumulativeGroupedAllocation != null + fun isMinimum(): Boolean = minimum != null fun isPercent(): Boolean = percent != null @@ -2289,6 +2302,9 @@ private constructor( fun asCumulativeGroupedBulk(): NewPlanCumulativeGroupedBulkPrice = cumulativeGroupedBulk.getOrThrow("cumulativeGroupedBulk") + fun asCumulativeGroupedAllocation(): CumulativeGroupedAllocation = + cumulativeGroupedAllocation.getOrThrow("cumulativeGroupedAllocation") + fun asMinimum(): NewPlanMinimumCompositePrice = minimum.getOrThrow("minimum") fun asPercent(): Percent = percent.getOrThrow("percent") @@ -2342,6 +2358,8 @@ private constructor( ) cumulativeGroupedBulk != null -> visitor.visitCumulativeGroupedBulk(cumulativeGroupedBulk) + cumulativeGroupedAllocation != null -> + visitor.visitCumulativeGroupedAllocation(cumulativeGroupedAllocation) minimum != null -> visitor.visitMinimum(minimum) percent != null -> visitor.visitPercent(percent) eventOutput != null -> visitor.visitEventOutput(eventOutput) @@ -2504,6 +2522,12 @@ private constructor( cumulativeGroupedBulk.validate() } + override fun visitCumulativeGroupedAllocation( + cumulativeGroupedAllocation: CumulativeGroupedAllocation + ) { + cumulativeGroupedAllocation.validate() + } + override fun visitMinimum(minimum: NewPlanMinimumCompositePrice) { minimum.validate() } @@ -2634,6 +2658,10 @@ private constructor( cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice ) = cumulativeGroupedBulk.validity() + override fun visitCumulativeGroupedAllocation( + cumulativeGroupedAllocation: CumulativeGroupedAllocation + ) = cumulativeGroupedAllocation.validity() + override fun visitMinimum(minimum: NewPlanMinimumCompositePrice) = minimum.validity() @@ -2679,6 +2707,7 @@ private constructor( scalableMatrixWithUnitPricing == other.scalableMatrixWithUnitPricing && scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && cumulativeGroupedBulk == other.cumulativeGroupedBulk && + cumulativeGroupedAllocation == other.cumulativeGroupedAllocation && minimum == other.minimum && percent == other.percent && eventOutput == other.eventOutput @@ -2713,6 +2742,7 @@ private constructor( scalableMatrixWithUnitPricing, scalableMatrixWithTieredPricing, cumulativeGroupedBulk, + cumulativeGroupedAllocation, minimum, percent, eventOutput, @@ -2760,6 +2790,8 @@ private constructor( "Price{scalableMatrixWithTieredPricing=$scalableMatrixWithTieredPricing}" cumulativeGroupedBulk != null -> "Price{cumulativeGroupedBulk=$cumulativeGroupedBulk}" + cumulativeGroupedAllocation != null -> + "Price{cumulativeGroupedAllocation=$cumulativeGroupedAllocation}" minimum != null -> "Price{minimum=$minimum}" percent != null -> "Price{percent=$percent}" eventOutput != null -> "Price{eventOutput=$eventOutput}" @@ -2855,6 +2887,10 @@ private constructor( cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice ) = Price(cumulativeGroupedBulk = cumulativeGroupedBulk) + fun ofCumulativeGroupedAllocation( + cumulativeGroupedAllocation: CumulativeGroupedAllocation + ) = Price(cumulativeGroupedAllocation = cumulativeGroupedAllocation) + fun ofMinimum(minimum: NewPlanMinimumCompositePrice) = Price(minimum = minimum) fun ofPercent(percent: Percent) = Price(percent = percent) @@ -2947,6 +2983,10 @@ private constructor( cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice ): T + fun visitCumulativeGroupedAllocation( + cumulativeGroupedAllocation: CumulativeGroupedAllocation + ): T + fun visitMinimum(minimum: NewPlanMinimumCompositePrice): T fun visitPercent(percent: Percent): T @@ -3163,6 +3203,14 @@ private constructor( ?.let { Price(cumulativeGroupedBulk = it, _json = json) } ?: Price(_json = json) } + "cumulative_grouped_allocation" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(cumulativeGroupedAllocation = it, _json = json) } + ?: Price(_json = json) + } "minimum" -> { return tryDeserialize( node, @@ -3241,6 +3289,8 @@ private constructor( generator.writeObject(value.scalableMatrixWithTieredPricing) value.cumulativeGroupedBulk != null -> generator.writeObject(value.cumulativeGroupedBulk) + value.cumulativeGroupedAllocation != null -> + generator.writeObject(value.cumulativeGroupedAllocation) value.minimum != null -> generator.writeObject(value.minimum) value.percent != null -> generator.writeObject(value.percent) value.eventOutput != null -> generator.writeObject(value.eventOutput) @@ -8752,14 +8802,15 @@ private constructor( "GroupedWithMinMaxThresholds{cadence=$cadence, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class Percent + class CumulativeGroupedAllocation @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, + private val cumulativeGroupedAllocationConfig: + JsonField, private val itemId: JsonField, private val modelType: JsonValue, private val name: JsonField, - private val percentConfig: JsonField, private val billableMetricId: JsonField, private val billedInAdvance: JsonField, private val billingCycleConfiguration: JsonField, @@ -8782,6 +8833,11 @@ private constructor( @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), + @JsonProperty("cumulative_grouped_allocation_config") + @ExcludeMissing + cumulativeGroupedAllocationConfig: + JsonField = + JsonMissing.of(), @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), @@ -8791,9 +8847,6 @@ private constructor( @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("percent_config") - @ExcludeMissing - percentConfig: JsonField = JsonMissing.of(), @JsonProperty("billable_metric_id") @ExcludeMissing billableMetricId: JsonField = JsonMissing.of(), @@ -8838,10 +8891,10 @@ private constructor( referenceId: JsonField = JsonMissing.of(), ) : this( cadence, + cumulativeGroupedAllocationConfig, itemId, modelType, name, - percentConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -8867,6 +8920,18 @@ private constructor( */ fun cadence(): Cadence = cadence.getRequired("cadence") + /** + * Configuration for cumulative_grouped_allocation pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cumulativeGroupedAllocationConfig(): CumulativeGroupedAllocationConfig = + cumulativeGroupedAllocationConfig.getRequired( + "cumulative_grouped_allocation_config" + ) + /** * The id of the item the price will be associated with. * @@ -8881,7 +8946,7 @@ private constructor( * * Expected to always return the following: * ```kotlin - * JsonValue.from("percent") + * JsonValue.from("cumulative_grouped_allocation") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -8898,15 +8963,6 @@ private constructor( */ fun name(): String = name.getRequired("name") - /** - * Configuration for percent pricing - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun percentConfig(): PercentConfig = percentConfig.getRequired("percent_config") - /** * The id of the billable metric for the price. Only needed if the price is * usage-based. @@ -9036,6 +9092,17 @@ private constructor( @ExcludeMissing fun _cadence(): JsonField = cadence + /** + * Returns the raw JSON value of [cumulativeGroupedAllocationConfig]. + * + * Unlike [cumulativeGroupedAllocationConfig], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("cumulative_grouped_allocation_config") + @ExcludeMissing + fun _cumulativeGroupedAllocationConfig(): + JsonField = cumulativeGroupedAllocationConfig + /** * Returns the raw JSON value of [itemId]. * @@ -9052,16 +9119,6 @@ private constructor( */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - /** - * Returns the raw JSON value of [percentConfig]. - * - * Unlike [percentConfig], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("percent_config") - @ExcludeMissing - fun _percentConfig(): JsonField = percentConfig - /** * Returns the raw JSON value of [billableMetricId]. * @@ -9210,27 +9267,31 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [Percent]. + * Returns a mutable builder for constructing an instance of + * [CumulativeGroupedAllocation]. * * The following fields are required: * ```kotlin * .cadence() + * .cumulativeGroupedAllocationConfig() * .itemId() * .name() - * .percentConfig() * ``` */ fun builder() = Builder() } - /** A builder for [Percent]. */ + /** A builder for [CumulativeGroupedAllocation]. */ class Builder internal constructor() { private var cadence: JsonField? = null + private var cumulativeGroupedAllocationConfig: + JsonField? = + null private var itemId: JsonField? = null - private var modelType: JsonValue = JsonValue.from("percent") + private var modelType: JsonValue = + JsonValue.from("cumulative_grouped_allocation") private var name: JsonField? = null - private var percentConfig: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() private var billingCycleConfiguration: JsonField = @@ -9252,27 +9313,33 @@ private constructor( private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(percent: Percent) = apply { - cadence = percent.cadence - itemId = percent.itemId - modelType = percent.modelType - name = percent.name - percentConfig = percent.percentConfig - billableMetricId = percent.billableMetricId - billedInAdvance = percent.billedInAdvance - billingCycleConfiguration = percent.billingCycleConfiguration - conversionRate = percent.conversionRate - conversionRateConfig = percent.conversionRateConfig - currency = percent.currency - dimensionalPriceConfiguration = percent.dimensionalPriceConfiguration - externalPriceId = percent.externalPriceId - fixedPriceQuantity = percent.fixedPriceQuantity - invoiceGroupingKey = percent.invoiceGroupingKey - invoicingCycleConfiguration = percent.invoicingCycleConfiguration - metadata = percent.metadata - referenceId = percent.referenceId - additionalProperties = percent.additionalProperties.toMutableMap() - } + internal fun from(cumulativeGroupedAllocation: CumulativeGroupedAllocation) = + apply { + cadence = cumulativeGroupedAllocation.cadence + cumulativeGroupedAllocationConfig = + cumulativeGroupedAllocation.cumulativeGroupedAllocationConfig + itemId = cumulativeGroupedAllocation.itemId + modelType = cumulativeGroupedAllocation.modelType + name = cumulativeGroupedAllocation.name + billableMetricId = cumulativeGroupedAllocation.billableMetricId + billedInAdvance = cumulativeGroupedAllocation.billedInAdvance + billingCycleConfiguration = + cumulativeGroupedAllocation.billingCycleConfiguration + conversionRate = cumulativeGroupedAllocation.conversionRate + conversionRateConfig = cumulativeGroupedAllocation.conversionRateConfig + currency = cumulativeGroupedAllocation.currency + dimensionalPriceConfiguration = + cumulativeGroupedAllocation.dimensionalPriceConfiguration + externalPriceId = cumulativeGroupedAllocation.externalPriceId + fixedPriceQuantity = cumulativeGroupedAllocation.fixedPriceQuantity + invoiceGroupingKey = cumulativeGroupedAllocation.invoiceGroupingKey + invoicingCycleConfiguration = + cumulativeGroupedAllocation.invoicingCycleConfiguration + metadata = cumulativeGroupedAllocation.metadata + referenceId = cumulativeGroupedAllocation.referenceId + additionalProperties = + cumulativeGroupedAllocation.additionalProperties.toMutableMap() + } /** The cadence to bill for this price on. */ fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) @@ -9286,6 +9353,29 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + /** Configuration for cumulative_grouped_allocation pricing */ + fun cumulativeGroupedAllocationConfig( + cumulativeGroupedAllocationConfig: CumulativeGroupedAllocationConfig + ) = + cumulativeGroupedAllocationConfig( + JsonField.of(cumulativeGroupedAllocationConfig) + ) + + /** + * Sets [Builder.cumulativeGroupedAllocationConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.cumulativeGroupedAllocationConfig] with a + * well-typed [CumulativeGroupedAllocationConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun cumulativeGroupedAllocationConfig( + cumulativeGroupedAllocationConfig: + JsonField + ) = apply { + this.cumulativeGroupedAllocationConfig = cumulativeGroupedAllocationConfig + } + /** The id of the item the price will be associated with. */ fun itemId(itemId: String) = itemId(JsonField.of(itemId)) @@ -9304,7 +9394,7 @@ private constructor( * It is usually unnecessary to call this method because the field defaults to * the following: * ```kotlin - * JsonValue.from("percent") + * JsonValue.from("cumulative_grouped_allocation") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -9324,21 +9414,6 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } - /** Configuration for percent pricing */ - fun percentConfig(percentConfig: PercentConfig) = - percentConfig(JsonField.of(percentConfig)) - - /** - * Sets [Builder.percentConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.percentConfig] with a well-typed - * [PercentConfig] value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. - */ - fun percentConfig(percentConfig: JsonField) = apply { - this.percentConfig = percentConfig - } - /** * The id of the billable metric for the price. Only needed if the price is * usage-based. @@ -9668,27 +9743,30 @@ private constructor( } /** - * Returns an immutable instance of [Percent]. + * Returns an immutable instance of [CumulativeGroupedAllocation]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```kotlin * .cadence() + * .cumulativeGroupedAllocationConfig() * .itemId() * .name() - * .percentConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): Percent = - Percent( + fun build(): CumulativeGroupedAllocation = + CumulativeGroupedAllocation( checkRequired("cadence", cadence), + checkRequired( + "cumulativeGroupedAllocationConfig", + cumulativeGroupedAllocationConfig, + ), checkRequired("itemId", itemId), modelType, checkRequired("name", name), - checkRequired("percentConfig", percentConfig), billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -9708,20 +9786,20 @@ private constructor( private var validated: Boolean = false - fun validate(): Percent = apply { + fun validate(): CumulativeGroupedAllocation = apply { if (validated) { return@apply } cadence().validate() + cumulativeGroupedAllocationConfig().validate() itemId() _modelType().let { - if (it != JsonValue.from("percent")) { + if (it != JsonValue.from("cumulative_grouped_allocation")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } name() - percentConfig().validate() billableMetricId() billedInAdvance() billingCycleConfiguration()?.validate() @@ -9754,10 +9832,12 @@ private constructor( */ internal fun validity(): Int = (cadence.asKnown()?.validity() ?: 0) + + (cumulativeGroupedAllocationConfig.asKnown()?.validity() ?: 0) + (if (itemId.asKnown() == null) 0 else 1) + - modelType.let { if (it == JsonValue.from("percent")) 1 else 0 } + + modelType.let { + if (it == JsonValue.from("cumulative_grouped_allocation")) 1 else 0 + } + (if (name.asKnown() == null) 0 else 1) + - (percentConfig.asKnown()?.validity() ?: 0) + (if (billableMetricId.asKnown() == null) 0 else 1) + (if (billedInAdvance.asKnown() == null) 0 else 1) + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + @@ -9929,39 +10009,115 @@ private constructor( override fun toString() = value.toString() } - /** Configuration for percent pricing */ - class PercentConfig + /** Configuration for cumulative_grouped_allocation pricing */ + class CumulativeGroupedAllocationConfig @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val percent: JsonField, + private val cumulativeAllocation: JsonField, + private val groupAllocation: JsonField, + private val groupingKey: JsonField, + private val unitAmount: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("percent") + @JsonProperty("cumulative_allocation") @ExcludeMissing - percent: JsonField = JsonMissing.of() - ) : this(percent, mutableMapOf()) + cumulativeAllocation: JsonField = JsonMissing.of(), + @JsonProperty("group_allocation") + @ExcludeMissing + groupAllocation: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this( + cumulativeAllocation, + groupAllocation, + groupingKey, + unitAmount, + mutableMapOf(), + ) /** - * What percent of the component subtotals to charge + * The overall allocation across all groups * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). */ - fun percent(): Double = percent.getRequired("percent") + fun cumulativeAllocation(): String = + cumulativeAllocation.getRequired("cumulative_allocation") /** - * Returns the raw JSON value of [percent]. + * The allocation per individual group * - * Unlike [percent], this method doesn't throw if the JSON field has an + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun groupAllocation(): String = groupAllocation.getRequired("group_allocation") + + /** + * The event property used to group usage before applying allocations + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The amount to charge for each unit outside of the allocation + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [cumulativeAllocation]. + * + * Unlike [cumulativeAllocation], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("cumulative_allocation") + @ExcludeMissing + fun _cumulativeAllocation(): JsonField = cumulativeAllocation + + /** + * Returns the raw JSON value of [groupAllocation]. + * + * Unlike [groupAllocation], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("percent") + @JsonProperty("group_allocation") @ExcludeMissing - fun _percent(): JsonField = percent + fun _groupAllocation(): JsonField = groupAllocation + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -9979,39 +10135,100 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [PercentConfig]. + * [CumulativeGroupedAllocationConfig]. * * The following fields are required: * ```kotlin - * .percent() + * .cumulativeAllocation() + * .groupAllocation() + * .groupingKey() + * .unitAmount() * ``` */ fun builder() = Builder() } - /** A builder for [PercentConfig]. */ + /** A builder for [CumulativeGroupedAllocationConfig]. */ class Builder internal constructor() { - private var percent: JsonField? = null + private var cumulativeAllocation: JsonField? = null + private var groupAllocation: JsonField? = null + private var groupingKey: JsonField? = null + private var unitAmount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(percentConfig: PercentConfig) = apply { - percent = percentConfig.percent - additionalProperties = percentConfig.additionalProperties.toMutableMap() + internal fun from( + cumulativeGroupedAllocationConfig: CumulativeGroupedAllocationConfig + ) = apply { + cumulativeAllocation = + cumulativeGroupedAllocationConfig.cumulativeAllocation + groupAllocation = cumulativeGroupedAllocationConfig.groupAllocation + groupingKey = cumulativeGroupedAllocationConfig.groupingKey + unitAmount = cumulativeGroupedAllocationConfig.unitAmount + additionalProperties = + cumulativeGroupedAllocationConfig.additionalProperties + .toMutableMap() } - /** What percent of the component subtotals to charge */ - fun percent(percent: Double) = percent(JsonField.of(percent)) + /** The overall allocation across all groups */ + fun cumulativeAllocation(cumulativeAllocation: String) = + cumulativeAllocation(JsonField.of(cumulativeAllocation)) /** - * Sets [Builder.percent] to an arbitrary JSON value. + * Sets [Builder.cumulativeAllocation] to an arbitrary JSON value. * - * You should usually call [Builder.percent] with a well-typed [Double] + * You should usually call [Builder.cumulativeAllocation] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun cumulativeAllocation(cumulativeAllocation: JsonField) = apply { + this.cumulativeAllocation = cumulativeAllocation + } + + /** The allocation per individual group */ + fun groupAllocation(groupAllocation: String) = + groupAllocation(JsonField.of(groupAllocation)) + + /** + * Sets [Builder.groupAllocation] to an arbitrary JSON value. + * + * You should usually call [Builder.groupAllocation] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun groupAllocation(groupAllocation: JsonField) = apply { + this.groupAllocation = groupAllocation + } + + /** The event property used to group usage before applying allocations */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] * value instead. This method is primarily for setting the field to an * undocumented or not yet supported value. */ - fun percent(percent: JsonField) = apply { this.percent = percent } + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The amount to charge for each unit outside of the allocation */ + fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } fun additionalProperties(additionalProperties: Map) = apply { @@ -10036,32 +10253,41 @@ private constructor( } /** - * Returns an immutable instance of [PercentConfig]. + * Returns an immutable instance of [CumulativeGroupedAllocationConfig]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```kotlin - * .percent() + * .cumulativeAllocation() + * .groupAllocation() + * .groupingKey() + * .unitAmount() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): PercentConfig = - PercentConfig( - checkRequired("percent", percent), + fun build(): CumulativeGroupedAllocationConfig = + CumulativeGroupedAllocationConfig( + checkRequired("cumulativeAllocation", cumulativeAllocation), + checkRequired("groupAllocation", groupAllocation), + checkRequired("groupingKey", groupingKey), + checkRequired("unitAmount", unitAmount), additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): PercentConfig = apply { + fun validate(): CumulativeGroupedAllocationConfig = apply { if (validated) { return@apply } - percent() + cumulativeAllocation() + groupAllocation() + groupingKey() + unitAmount() validated = true } @@ -10079,26 +10305,39 @@ private constructor( * * Used for best match union deserialization. */ - internal fun validity(): Int = (if (percent.asKnown() == null) 0 else 1) + internal fun validity(): Int = + (if (cumulativeAllocation.asKnown() == null) 0 else 1) + + (if (groupAllocation.asKnown() == null) 0 else 1) + + (if (groupingKey.asKnown() == null) 0 else 1) + + (if (unitAmount.asKnown() == null) 0 else 1) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is PercentConfig && - percent == other.percent && + return other is CumulativeGroupedAllocationConfig && + cumulativeAllocation == other.cumulativeAllocation && + groupAllocation == other.groupAllocation && + groupingKey == other.groupingKey && + unitAmount == other.unitAmount && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(percent, additionalProperties) + Objects.hash( + cumulativeAllocation, + groupAllocation, + groupingKey, + unitAmount, + additionalProperties, + ) } override fun hashCode(): Int = hashCode override fun toString() = - "PercentConfig{percent=$percent, additionalProperties=$additionalProperties}" + "CumulativeGroupedAllocationConfig{cumulativeAllocation=$cumulativeAllocation, groupAllocation=$groupAllocation, groupingKey=$groupingKey, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" } /** @@ -10215,12 +10454,13 @@ private constructor( return true } - return other is Percent && + return other is CumulativeGroupedAllocation && cadence == other.cadence && + cumulativeGroupedAllocationConfig == + other.cumulativeGroupedAllocationConfig && itemId == other.itemId && modelType == other.modelType && name == other.name && - percentConfig == other.percentConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && @@ -10240,10 +10480,10 @@ private constructor( private val hashCode: Int by lazy { Objects.hash( cadence, + cumulativeGroupedAllocationConfig, itemId, modelType, name, - percentConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -10264,17 +10504,17 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Percent{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, percentConfig=$percentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "CumulativeGroupedAllocation{cadence=$cadence, cumulativeGroupedAllocationConfig=$cumulativeGroupedAllocationConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class EventOutput + class Percent @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, - private val eventOutputConfig: JsonField, private val itemId: JsonField, private val modelType: JsonValue, private val name: JsonField, + private val percentConfig: JsonField, private val billableMetricId: JsonField, private val billedInAdvance: JsonField, private val billingCycleConfiguration: JsonField, @@ -10297,9 +10537,6 @@ private constructor( @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), - @JsonProperty("event_output_config") - @ExcludeMissing - eventOutputConfig: JsonField = JsonMissing.of(), @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), @@ -10309,6 +10546,9 @@ private constructor( @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("percent_config") + @ExcludeMissing + percentConfig: JsonField = JsonMissing.of(), @JsonProperty("billable_metric_id") @ExcludeMissing billableMetricId: JsonField = JsonMissing.of(), @@ -10353,10 +10593,10 @@ private constructor( referenceId: JsonField = JsonMissing.of(), ) : this( cadence, - eventOutputConfig, itemId, modelType, name, + percentConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -10382,16 +10622,6 @@ private constructor( */ fun cadence(): Cadence = cadence.getRequired("cadence") - /** - * Configuration for event_output pricing - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun eventOutputConfig(): EventOutputConfig = - eventOutputConfig.getRequired("event_output_config") - /** * The id of the item the price will be associated with. * @@ -10406,7 +10636,7 @@ private constructor( * * Expected to always return the following: * ```kotlin - * JsonValue.from("event_output") + * JsonValue.from("percent") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -10423,6 +10653,15 @@ private constructor( */ fun name(): String = name.getRequired("name") + /** + * Configuration for percent pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun percentConfig(): PercentConfig = percentConfig.getRequired("percent_config") + /** * The id of the billable metric for the price. Only needed if the price is * usage-based. @@ -10552,16 +10791,6 @@ private constructor( @ExcludeMissing fun _cadence(): JsonField = cadence - /** - * Returns the raw JSON value of [eventOutputConfig]. - * - * Unlike [eventOutputConfig], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("event_output_config") - @ExcludeMissing - fun _eventOutputConfig(): JsonField = eventOutputConfig - /** * Returns the raw JSON value of [itemId]. * @@ -10578,6 +10807,16 @@ private constructor( */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + /** + * Returns the raw JSON value of [percentConfig]. + * + * Unlike [percentConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("percent_config") + @ExcludeMissing + fun _percentConfig(): JsonField = percentConfig + /** * Returns the raw JSON value of [billableMetricId]. * @@ -10726,27 +10965,27 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [EventOutput]. + * Returns a mutable builder for constructing an instance of [Percent]. * * The following fields are required: * ```kotlin * .cadence() - * .eventOutputConfig() * .itemId() * .name() + * .percentConfig() * ``` */ fun builder() = Builder() } - /** A builder for [EventOutput]. */ + /** A builder for [Percent]. */ class Builder internal constructor() { private var cadence: JsonField? = null - private var eventOutputConfig: JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonValue = JsonValue.from("event_output") + private var modelType: JsonValue = JsonValue.from("percent") private var name: JsonField? = null + private var percentConfig: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() private var billingCycleConfiguration: JsonField = @@ -10768,26 +11007,26 @@ private constructor( private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(eventOutput: EventOutput) = apply { - cadence = eventOutput.cadence - eventOutputConfig = eventOutput.eventOutputConfig - itemId = eventOutput.itemId - modelType = eventOutput.modelType - name = eventOutput.name - billableMetricId = eventOutput.billableMetricId - billedInAdvance = eventOutput.billedInAdvance - billingCycleConfiguration = eventOutput.billingCycleConfiguration - conversionRate = eventOutput.conversionRate - conversionRateConfig = eventOutput.conversionRateConfig - currency = eventOutput.currency - dimensionalPriceConfiguration = eventOutput.dimensionalPriceConfiguration - externalPriceId = eventOutput.externalPriceId - fixedPriceQuantity = eventOutput.fixedPriceQuantity - invoiceGroupingKey = eventOutput.invoiceGroupingKey - invoicingCycleConfiguration = eventOutput.invoicingCycleConfiguration - metadata = eventOutput.metadata - referenceId = eventOutput.referenceId - additionalProperties = eventOutput.additionalProperties.toMutableMap() + internal fun from(percent: Percent) = apply { + cadence = percent.cadence + itemId = percent.itemId + modelType = percent.modelType + name = percent.name + percentConfig = percent.percentConfig + billableMetricId = percent.billableMetricId + billedInAdvance = percent.billedInAdvance + billingCycleConfiguration = percent.billingCycleConfiguration + conversionRate = percent.conversionRate + conversionRateConfig = percent.conversionRateConfig + currency = percent.currency + dimensionalPriceConfiguration = percent.dimensionalPriceConfiguration + externalPriceId = percent.externalPriceId + fixedPriceQuantity = percent.fixedPriceQuantity + invoiceGroupingKey = percent.invoiceGroupingKey + invoicingCycleConfiguration = percent.invoicingCycleConfiguration + metadata = percent.metadata + referenceId = percent.referenceId + additionalProperties = percent.additionalProperties.toMutableMap() } /** The cadence to bill for this price on. */ @@ -10802,21 +11041,6 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - /** Configuration for event_output pricing */ - fun eventOutputConfig(eventOutputConfig: EventOutputConfig) = - eventOutputConfig(JsonField.of(eventOutputConfig)) - - /** - * Sets [Builder.eventOutputConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.eventOutputConfig] with a well-typed - * [EventOutputConfig] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun eventOutputConfig(eventOutputConfig: JsonField) = apply { - this.eventOutputConfig = eventOutputConfig - } - /** The id of the item the price will be associated with. */ fun itemId(itemId: String) = itemId(JsonField.of(itemId)) @@ -10835,7 +11059,7 @@ private constructor( * It is usually unnecessary to call this method because the field defaults to * the following: * ```kotlin - * JsonValue.from("event_output") + * JsonValue.from("percent") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -10855,6 +11079,21 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } + /** Configuration for percent pricing */ + fun percentConfig(percentConfig: PercentConfig) = + percentConfig(JsonField.of(percentConfig)) + + /** + * Sets [Builder.percentConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.percentConfig] with a well-typed + * [PercentConfig] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun percentConfig(percentConfig: JsonField) = apply { + this.percentConfig = percentConfig + } + /** * The id of the billable metric for the price. Only needed if the price is * usage-based. @@ -11184,27 +11423,27 @@ private constructor( } /** - * Returns an immutable instance of [EventOutput]. + * Returns an immutable instance of [Percent]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```kotlin * .cadence() - * .eventOutputConfig() * .itemId() * .name() + * .percentConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): EventOutput = - EventOutput( + fun build(): Percent = + Percent( checkRequired("cadence", cadence), - checkRequired("eventOutputConfig", eventOutputConfig), checkRequired("itemId", itemId), modelType, checkRequired("name", name), + checkRequired("percentConfig", percentConfig), billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -11224,20 +11463,20 @@ private constructor( private var validated: Boolean = false - fun validate(): EventOutput = apply { + fun validate(): Percent = apply { if (validated) { return@apply } cadence().validate() - eventOutputConfig().validate() itemId() _modelType().let { - if (it != JsonValue.from("event_output")) { + if (it != JsonValue.from("percent")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } name() + percentConfig().validate() billableMetricId() billedInAdvance() billingCycleConfiguration()?.validate() @@ -11270,10 +11509,10 @@ private constructor( */ internal fun validity(): Int = (cadence.asKnown()?.validity() ?: 0) + - (eventOutputConfig.asKnown()?.validity() ?: 0) + (if (itemId.asKnown() == null) 0 else 1) + - modelType.let { if (it == JsonValue.from("event_output")) 1 else 0 } + + modelType.let { if (it == JsonValue.from("percent")) 1 else 0 } + (if (name.asKnown() == null) 0 else 1) + + (percentConfig.asKnown()?.validity() ?: 0) + (if (billableMetricId.asKnown() == null) 0 else 1) + (if (billedInAdvance.asKnown() == null) 0 else 1) + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + @@ -11445,87 +11684,39 @@ private constructor( override fun toString() = value.toString() } - /** Configuration for event_output pricing */ - class EventOutputConfig + /** Configuration for percent pricing */ + class PercentConfig @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val unitRatingKey: JsonField, - private val defaultUnitRate: JsonField, - private val groupingKey: JsonField, + private val percent: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("unit_rating_key") - @ExcludeMissing - unitRatingKey: JsonField = JsonMissing.of(), - @JsonProperty("default_unit_rate") - @ExcludeMissing - defaultUnitRate: JsonField = JsonMissing.of(), - @JsonProperty("grouping_key") + @JsonProperty("percent") @ExcludeMissing - groupingKey: JsonField = JsonMissing.of(), - ) : this(unitRatingKey, defaultUnitRate, groupingKey, mutableMapOf()) + percent: JsonField = JsonMissing.of() + ) : this(percent, mutableMapOf()) /** - * The key in the event data to extract the unit rate from. + * What percent of the component subtotals to charge * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). */ - fun unitRatingKey(): String = unitRatingKey.getRequired("unit_rating_key") - - /** - * If provided, this amount will be used as the unit rate when an event does not - * have a value for the `unit_rating_key`. If not provided, events missing a - * unit rate will be ignored. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun defaultUnitRate(): String? = - defaultUnitRate.getNullable("default_unit_rate") - - /** - * An optional key in the event data to group by (e.g., event ID). All events - * will also be grouped by their unit rate. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun groupingKey(): String? = groupingKey.getNullable("grouping_key") - - /** - * Returns the raw JSON value of [unitRatingKey]. - * - * Unlike [unitRatingKey], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("unit_rating_key") - @ExcludeMissing - fun _unitRatingKey(): JsonField = unitRatingKey - - /** - * Returns the raw JSON value of [defaultUnitRate]. - * - * Unlike [defaultUnitRate], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("default_unit_rate") - @ExcludeMissing - fun _defaultUnitRate(): JsonField = defaultUnitRate + fun percent(): Double = percent.getRequired("percent") /** - * Returns the raw JSON value of [groupingKey]. + * Returns the raw JSON value of [percent]. * - * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * Unlike [percent], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("grouping_key") + @JsonProperty("percent") @ExcludeMissing - fun _groupingKey(): JsonField = groupingKey + fun _percent(): JsonField = percent @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -11543,84 +11734,39 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [EventOutputConfig]. + * [PercentConfig]. * * The following fields are required: * ```kotlin - * .unitRatingKey() + * .percent() * ``` */ fun builder() = Builder() } - /** A builder for [EventOutputConfig]. */ + /** A builder for [PercentConfig]. */ class Builder internal constructor() { - private var unitRatingKey: JsonField? = null - private var defaultUnitRate: JsonField = JsonMissing.of() - private var groupingKey: JsonField = JsonMissing.of() + private var percent: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(eventOutputConfig: EventOutputConfig) = apply { - unitRatingKey = eventOutputConfig.unitRatingKey - defaultUnitRate = eventOutputConfig.defaultUnitRate - groupingKey = eventOutputConfig.groupingKey - additionalProperties = - eventOutputConfig.additionalProperties.toMutableMap() - } - - /** The key in the event data to extract the unit rate from. */ - fun unitRatingKey(unitRatingKey: String) = - unitRatingKey(JsonField.of(unitRatingKey)) - - /** - * Sets [Builder.unitRatingKey] to an arbitrary JSON value. - * - * You should usually call [Builder.unitRatingKey] with a well-typed - * [String] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun unitRatingKey(unitRatingKey: JsonField) = apply { - this.unitRatingKey = unitRatingKey - } - - /** - * If provided, this amount will be used as the unit rate when an event does - * not have a value for the `unit_rating_key`. If not provided, events - * missing a unit rate will be ignored. - */ - fun defaultUnitRate(defaultUnitRate: String?) = - defaultUnitRate(JsonField.ofNullable(defaultUnitRate)) - - /** - * Sets [Builder.defaultUnitRate] to an arbitrary JSON value. - * - * You should usually call [Builder.defaultUnitRate] with a well-typed - * [String] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun defaultUnitRate(defaultUnitRate: JsonField) = apply { - this.defaultUnitRate = defaultUnitRate + internal fun from(percentConfig: PercentConfig) = apply { + percent = percentConfig.percent + additionalProperties = percentConfig.additionalProperties.toMutableMap() } - /** - * An optional key in the event data to group by (e.g., event ID). All - * events will also be grouped by their unit rate. - */ - fun groupingKey(groupingKey: String?) = - groupingKey(JsonField.ofNullable(groupingKey)) + /** What percent of the component subtotals to charge */ + fun percent(percent: Double) = percent(JsonField.of(percent)) /** - * Sets [Builder.groupingKey] to an arbitrary JSON value. + * Sets [Builder.percent] to an arbitrary JSON value. * - * You should usually call [Builder.groupingKey] with a well-typed [String] + * You should usually call [Builder.percent] with a well-typed [Double] * value instead. This method is primarily for setting the field to an * undocumented or not yet supported value. */ - fun groupingKey(groupingKey: JsonField) = apply { - this.groupingKey = groupingKey - } + fun percent(percent: JsonField) = apply { this.percent = percent } fun additionalProperties(additionalProperties: Map) = apply { @@ -11645,36 +11791,32 @@ private constructor( } /** - * Returns an immutable instance of [EventOutputConfig]. + * Returns an immutable instance of [PercentConfig]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```kotlin - * .unitRatingKey() + * .percent() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): EventOutputConfig = - EventOutputConfig( - checkRequired("unitRatingKey", unitRatingKey), - defaultUnitRate, - groupingKey, + fun build(): PercentConfig = + PercentConfig( + checkRequired("percent", percent), additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): EventOutputConfig = apply { + fun validate(): PercentConfig = apply { if (validated) { return@apply } - unitRatingKey() - defaultUnitRate() - groupingKey() + percent() validated = true } @@ -11692,36 +11834,26 @@ private constructor( * * Used for best match union deserialization. */ - internal fun validity(): Int = - (if (unitRatingKey.asKnown() == null) 0 else 1) + - (if (defaultUnitRate.asKnown() == null) 0 else 1) + - (if (groupingKey.asKnown() == null) 0 else 1) + internal fun validity(): Int = (if (percent.asKnown() == null) 0 else 1) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is EventOutputConfig && - unitRatingKey == other.unitRatingKey && - defaultUnitRate == other.defaultUnitRate && - groupingKey == other.groupingKey && + return other is PercentConfig && + percent == other.percent && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash( - unitRatingKey, - defaultUnitRate, - groupingKey, - additionalProperties, - ) + Objects.hash(percent, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "EventOutputConfig{unitRatingKey=$unitRatingKey, defaultUnitRate=$defaultUnitRate, groupingKey=$groupingKey, additionalProperties=$additionalProperties}" + "PercentConfig{percent=$percent, additionalProperties=$additionalProperties}" } /** @@ -11838,12 +11970,12 @@ private constructor( return true } - return other is EventOutput && + return other is Percent && cadence == other.cadence && - eventOutputConfig == other.eventOutputConfig && itemId == other.itemId && modelType == other.modelType && name == other.name && + percentConfig == other.percentConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && @@ -11863,10 +11995,10 @@ private constructor( private val hashCode: Int by lazy { Objects.hash( cadence, - eventOutputConfig, itemId, modelType, name, + percentConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -11887,1051 +12019,1630 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "EventOutput{cadence=$cadence, eventOutputConfig=$eventOutputConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "Percent{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, percentConfig=$percentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + class EventOutput + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val eventOutputConfig: JsonField, + private val itemId: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { - return other is AddPrice && - allocationPrice == other.allocationPrice && - planPhaseOrder == other.planPhaseOrder && - price == other.price && - additionalProperties == other.additionalProperties - } + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("event_output_config") + @ExcludeMissing + eventOutputConfig: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + eventOutputConfig, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + mutableMapOf(), + ) - private val hashCode: Int by lazy { - Objects.hash(allocationPrice, planPhaseOrder, price, additionalProperties) - } + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") - override fun hashCode(): Int = hashCode + /** + * Configuration for event_output pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun eventOutputConfig(): EventOutputConfig = + eventOutputConfig.getRequired("event_output_config") - override fun toString() = - "AddPrice{allocationPrice=$allocationPrice, planPhaseOrder=$planPhaseOrder, price=$price, additionalProperties=$additionalProperties}" - } + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") - class RemoveAdjustment - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val adjustmentId: JsonField, - private val planPhaseOrder: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("adjustment_id") - @ExcludeMissing - adjustmentId: JsonField = JsonMissing.of(), - @JsonProperty("plan_phase_order") - @ExcludeMissing - planPhaseOrder: JsonField = JsonMissing.of(), - ) : this(adjustmentId, planPhaseOrder, mutableMapOf()) + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("event_output") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType - /** - * The id of the adjustment to remove from on the plan. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun adjustmentId(): String = adjustmentId.getRequired("adjustment_id") + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") - /** - * The phase to remove this adjustment from. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun planPhaseOrder(): Long? = planPhaseOrder.getNullable("plan_phase_order") + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = billableMetricId.getNullable("billable_metric_id") - /** - * Returns the raw JSON value of [adjustmentId]. - * - * Unlike [adjustmentId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("adjustment_id") - @ExcludeMissing - fun _adjustmentId(): JsonField = adjustmentId + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") - /** - * Returns the raw JSON value of [planPhaseOrder]. - * - * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("plan_phase_order") - @ExcludeMissing - fun _planPhaseOrder(): JsonField = planPhaseOrder + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") - fun toBuilder() = Builder().from(this) + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") - companion object { + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") - /** - * Returns a mutable builder for constructing an instance of [RemoveAdjustment]. - * - * The following fields are required: - * ```kotlin - * .adjustmentId() - * ``` - */ - fun builder() = Builder() - } + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") - /** A builder for [RemoveAdjustment]. */ - class Builder internal constructor() { + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") - private var adjustmentId: JsonField? = null - private var planPhaseOrder: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + invoiceGroupingKey.getNullable("invoice_grouping_key") - internal fun from(removeAdjustment: RemoveAdjustment) = apply { - adjustmentId = removeAdjustment.adjustmentId - planPhaseOrder = removeAdjustment.planPhaseOrder - additionalProperties = removeAdjustment.additionalProperties.toMutableMap() - } + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - /** The id of the adjustment to remove from on the plan. */ - fun adjustmentId(adjustmentId: String) = adjustmentId(JsonField.of(adjustmentId)) + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") - /** - * Sets [Builder.adjustmentId] to an arbitrary JSON value. - * - * You should usually call [Builder.adjustmentId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun adjustmentId(adjustmentId: JsonField) = apply { - this.adjustmentId = adjustmentId - } + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") - /** The phase to remove this adjustment from. */ - fun planPhaseOrder(planPhaseOrder: Long?) = - planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence - /** - * Alias for [Builder.planPhaseOrder]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + /** + * Returns the raw JSON value of [eventOutputConfig]. + * + * Unlike [eventOutputConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("event_output_config") + @ExcludeMissing + fun _eventOutputConfig(): JsonField = eventOutputConfig - /** - * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. - * - * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun planPhaseOrder(planPhaseOrder: JsonField) = apply { - this.planPhaseOrder = planPhaseOrder - } + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate - /** - * Returns an immutable instance of [RemoveAdjustment]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```kotlin - * .adjustmentId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): RemoveAdjustment = - RemoveAdjustment( - checkRequired("adjustmentId", adjustmentId), - planPhaseOrder, - additionalProperties.toMutableMap(), - ) - } + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig - private var validated: Boolean = false + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency - fun validate(): RemoveAdjustment = apply { - if (validated) { - return@apply - } + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration - adjustmentId() - planPhaseOrder() - validated = true - } + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (if (adjustmentId.asKnown() == null) 0 else 1) + - (if (planPhaseOrder.asKnown() == null) 0 else 1) + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration - return other is RemoveAdjustment && - adjustmentId == other.adjustmentId && - planPhaseOrder == other.planPhaseOrder && - additionalProperties == other.additionalProperties - } + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata - private val hashCode: Int by lazy { - Objects.hash(adjustmentId, planPhaseOrder, additionalProperties) - } + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId - override fun hashCode(): Int = hashCode + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - override fun toString() = - "RemoveAdjustment{adjustmentId=$adjustmentId, planPhaseOrder=$planPhaseOrder, additionalProperties=$additionalProperties}" - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - class RemovePrice - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val priceId: JsonField, - private val planPhaseOrder: JsonField, - private val additionalProperties: MutableMap, - ) { + fun toBuilder() = Builder().from(this) - @JsonCreator - private constructor( - @JsonProperty("price_id") @ExcludeMissing priceId: JsonField = JsonMissing.of(), - @JsonProperty("plan_phase_order") - @ExcludeMissing - planPhaseOrder: JsonField = JsonMissing.of(), - ) : this(priceId, planPhaseOrder, mutableMapOf()) + companion object { - /** - * The id of the price to remove from the plan. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun priceId(): String = priceId.getRequired("price_id") + /** + * Returns a mutable builder for constructing an instance of [EventOutput]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .eventOutputConfig() + * .itemId() + * .name() + * ``` + */ + fun builder() = Builder() + } - /** - * The phase to remove this price from. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun planPhaseOrder(): Long? = planPhaseOrder.getNullable("plan_phase_order") + /** A builder for [EventOutput]. */ + class Builder internal constructor() { - /** - * Returns the raw JSON value of [priceId]. - * - * Unlike [priceId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId + private var cadence: JsonField? = null + private var eventOutputConfig: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonValue = JsonValue.from("event_output") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - /** - * Returns the raw JSON value of [planPhaseOrder]. - * - * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("plan_phase_order") - @ExcludeMissing - fun _planPhaseOrder(): JsonField = planPhaseOrder + internal fun from(eventOutput: EventOutput) = apply { + cadence = eventOutput.cadence + eventOutputConfig = eventOutput.eventOutputConfig + itemId = eventOutput.itemId + modelType = eventOutput.modelType + name = eventOutput.name + billableMetricId = eventOutput.billableMetricId + billedInAdvance = eventOutput.billedInAdvance + billingCycleConfiguration = eventOutput.billingCycleConfiguration + conversionRate = eventOutput.conversionRate + conversionRateConfig = eventOutput.conversionRateConfig + currency = eventOutput.currency + dimensionalPriceConfiguration = eventOutput.dimensionalPriceConfiguration + externalPriceId = eventOutput.externalPriceId + fixedPriceQuantity = eventOutput.fixedPriceQuantity + invoiceGroupingKey = eventOutput.invoiceGroupingKey + invoicingCycleConfiguration = eventOutput.invoicingCycleConfiguration + metadata = eventOutput.metadata + referenceId = eventOutput.referenceId + additionalProperties = eventOutput.additionalProperties.toMutableMap() + } - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - fun toBuilder() = Builder().from(this) + /** Configuration for event_output pricing */ + fun eventOutputConfig(eventOutputConfig: EventOutputConfig) = + eventOutputConfig(JsonField.of(eventOutputConfig)) - companion object { + /** + * Sets [Builder.eventOutputConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.eventOutputConfig] with a well-typed + * [EventOutputConfig] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun eventOutputConfig(eventOutputConfig: JsonField) = apply { + this.eventOutputConfig = eventOutputConfig + } - /** - * Returns a mutable builder for constructing an instance of [RemovePrice]. - * - * The following fields are required: - * ```kotlin - * .priceId() - * ``` - */ - fun builder() = Builder() - } + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - /** A builder for [RemovePrice]. */ - class Builder internal constructor() { + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - private var priceId: JsonField? = null - private var planPhaseOrder: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("event_output") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } - internal fun from(removePrice: RemovePrice) = apply { - priceId = removePrice.priceId - planPhaseOrder = removePrice.planPhaseOrder - additionalProperties = removePrice.additionalProperties.toMutableMap() - } + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) - /** The id of the price to remove from the plan. */ - fun priceId(priceId: String) = priceId(JsonField.of(priceId)) + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } - /** - * Sets [Builder.priceId] to an arbitrary JSON value. - * - * You should usually call [Builder.priceId] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun priceId(priceId: JsonField) = apply { this.priceId = priceId } + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) - /** The phase to remove this price from. */ - fun planPhaseOrder(planPhaseOrder: Long?) = - planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } - /** - * Alias for [Builder.planPhaseOrder]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) - /** - * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. - * - * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun planPhaseOrder(planPhaseOrder: JsonField) = apply { - this.planPhaseOrder = planPhaseOrder - } + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) - /** - * Returns an immutable instance of [RemovePrice]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```kotlin - * .priceId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): RemovePrice = - RemovePrice( - checkRequired("priceId", priceId), - planPhaseOrder, - additionalProperties.toMutableMap(), - ) - } + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } - private var validated: Boolean = false + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) - fun validate(): RemovePrice = apply { - if (validated) { - return@apply - } + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } - priceId() - planPhaseOrder() - validated = true - } + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (if (priceId.asKnown() == null) 0 else 1) + - (if (planPhaseOrder.asKnown() == null) 0 else 1) + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) - return other is RemovePrice && - priceId == other.priceId && - planPhaseOrder == other.planPhaseOrder && - additionalProperties == other.additionalProperties - } + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) - private val hashCode: Int by lazy { - Objects.hash(priceId, planPhaseOrder, additionalProperties) - } + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } - override fun hashCode(): Int = hashCode + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) - override fun toString() = - "RemovePrice{priceId=$priceId, planPhaseOrder=$planPhaseOrder, additionalProperties=$additionalProperties}" - } + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } - class ReplaceAdjustment - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val adjustment: JsonField, - private val replacesAdjustmentId: JsonField, - private val planPhaseOrder: JsonField, - private val additionalProperties: MutableMap, - ) { + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) - @JsonCreator - private constructor( - @JsonProperty("adjustment") - @ExcludeMissing - adjustment: JsonField = JsonMissing.of(), - @JsonProperty("replaces_adjustment_id") - @ExcludeMissing - replacesAdjustmentId: JsonField = JsonMissing.of(), - @JsonProperty("plan_phase_order") - @ExcludeMissing - planPhaseOrder: JsonField = JsonMissing.of(), - ) : this(adjustment, replacesAdjustmentId, planPhaseOrder, mutableMapOf()) + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } - /** - * The definition of a new adjustment to create and add to the plan. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun adjustment(): Adjustment = adjustment.getRequired("adjustment") + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) - /** - * The id of the adjustment on the plan to replace in the plan. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun replacesAdjustmentId(): String = - replacesAdjustmentId.getRequired("replaces_adjustment_id") + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) - /** - * The phase to replace this adjustment from. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun planPhaseOrder(): Long? = planPhaseOrder.getNullable("plan_phase_order") + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } - /** - * Returns the raw JSON value of [adjustment]. - * - * Unlike [adjustment], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("adjustment") - @ExcludeMissing - fun _adjustment(): JsonField = adjustment + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) - /** - * Returns the raw JSON value of [replacesAdjustmentId]. - * - * Unlike [replacesAdjustmentId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("replaces_adjustment_id") - @ExcludeMissing - fun _replacesAdjustmentId(): JsonField = replacesAdjustmentId - - /** - * Returns the raw JSON value of [planPhaseOrder]. - * - * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("plan_phase_order") - @ExcludeMissing - fun _planPhaseOrder(): JsonField = planPhaseOrder + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - fun toBuilder() = Builder().from(this) + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - companion object { + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - /** - * Returns a mutable builder for constructing an instance of [ReplaceAdjustment]. - * - * The following fields are required: - * ```kotlin - * .adjustment() - * .replacesAdjustmentId() - * ``` - */ - fun builder() = Builder() - } + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) - /** A builder for [ReplaceAdjustment]. */ - class Builder internal constructor() { + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } - private var adjustment: JsonField? = null - private var replacesAdjustmentId: JsonField? = null - private var planPhaseOrder: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - internal fun from(replaceAdjustment: ReplaceAdjustment) = apply { - adjustment = replaceAdjustment.adjustment - replacesAdjustmentId = replaceAdjustment.replacesAdjustmentId - planPhaseOrder = replaceAdjustment.planPhaseOrder - additionalProperties = replaceAdjustment.additionalProperties.toMutableMap() - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** The definition of a new adjustment to create and add to the plan. */ - fun adjustment(adjustment: Adjustment) = adjustment(JsonField.of(adjustment)) + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - /** - * Sets [Builder.adjustment] to an arbitrary JSON value. - * - * You should usually call [Builder.adjustment] with a well-typed [Adjustment] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun adjustment(adjustment: JsonField) = apply { - this.adjustment = adjustment - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - /** - * Alias for calling [adjustment] with - * `Adjustment.ofPercentageDiscount(percentageDiscount)`. - */ - fun adjustment(percentageDiscount: NewPercentageDiscount) = - adjustment(Adjustment.ofPercentageDiscount(percentageDiscount)) + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - /** - * Alias for calling [adjustment] with the following: - * ```kotlin - * NewPercentageDiscount.builder() - * .adjustmentType(NewPercentageDiscount.AdjustmentType.PERCENTAGE_DISCOUNT) - * .percentageDiscount(percentageDiscount) - * .build() - * ``` - */ - fun percentageDiscountAdjustment(percentageDiscount: Double) = - adjustment( - NewPercentageDiscount.builder() - .adjustmentType(NewPercentageDiscount.AdjustmentType.PERCENTAGE_DISCOUNT) - .percentageDiscount(percentageDiscount) - .build() - ) + /** + * Returns an immutable instance of [EventOutput]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .eventOutputConfig() + * .itemId() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): EventOutput = + EventOutput( + checkRequired("cadence", cadence), + checkRequired("eventOutputConfig", eventOutputConfig), + checkRequired("itemId", itemId), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } - /** Alias for calling [adjustment] with `Adjustment.ofUsageDiscount(usageDiscount)`. */ - fun adjustment(usageDiscount: NewUsageDiscount) = - adjustment(Adjustment.ofUsageDiscount(usageDiscount)) + private var validated: Boolean = false - /** - * Alias for calling [adjustment] with the following: - * ```kotlin - * NewUsageDiscount.builder() - * .adjustmentType(NewUsageDiscount.AdjustmentType.USAGE_DISCOUNT) - * .usageDiscount(usageDiscount) - * .build() - * ``` - */ - fun usageDiscountAdjustment(usageDiscount: Double) = - adjustment( - NewUsageDiscount.builder() - .adjustmentType(NewUsageDiscount.AdjustmentType.USAGE_DISCOUNT) - .usageDiscount(usageDiscount) - .build() - ) + fun validate(): EventOutput = apply { + if (validated) { + return@apply + } - /** - * Alias for calling [adjustment] with `Adjustment.ofAmountDiscount(amountDiscount)`. - */ - fun adjustment(amountDiscount: NewAmountDiscount) = - adjustment(Adjustment.ofAmountDiscount(amountDiscount)) + cadence().validate() + eventOutputConfig().validate() + itemId() + _modelType().let { + if (it != JsonValue.from("event_output")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + metadata()?.validate() + referenceId() + validated = true + } - /** - * Alias for calling [adjustment] with the following: - * ```kotlin - * NewAmountDiscount.builder() - * .adjustmentType(NewAmountDiscount.AdjustmentType.AMOUNT_DISCOUNT) - * .amountDiscount(amountDiscount) - * .build() - * ``` - */ - fun amountDiscountAdjustment(amountDiscount: String) = - adjustment( - NewAmountDiscount.builder() - .adjustmentType(NewAmountDiscount.AdjustmentType.AMOUNT_DISCOUNT) - .amountDiscount(amountDiscount) - .build() - ) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - /** Alias for calling [adjustment] with `Adjustment.ofMinimum(minimum)`. */ - fun adjustment(minimum: NewMinimum) = adjustment(Adjustment.ofMinimum(minimum)) + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (eventOutputConfig.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + modelType.let { if (it == JsonValue.from("event_output")) 1 else 0 } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) - /** Alias for calling [adjustment] with `Adjustment.ofMaximum(maximum)`. */ - fun adjustment(maximum: NewMaximum) = adjustment(Adjustment.ofMaximum(maximum)) + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { - /** - * Alias for calling [adjustment] with the following: - * ```kotlin - * NewMaximum.builder() - * .adjustmentType(NewMaximum.AdjustmentType.MAXIMUM) - * .maximumAmount(maximumAmount) - * .build() - * ``` - */ - fun maximumAdjustment(maximumAmount: String) = - adjustment( - NewMaximum.builder() - .adjustmentType(NewMaximum.AdjustmentType.MAXIMUM) - .maximumAmount(maximumAmount) - .build() - ) + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value - /** The id of the adjustment on the plan to replace in the plan. */ - fun replacesAdjustmentId(replacesAdjustmentId: String) = - replacesAdjustmentId(JsonField.of(replacesAdjustmentId)) + companion object { - /** - * Sets [Builder.replacesAdjustmentId] to an arbitrary JSON value. - * - * You should usually call [Builder.replacesAdjustmentId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun replacesAdjustmentId(replacesAdjustmentId: JsonField) = apply { - this.replacesAdjustmentId = replacesAdjustmentId - } + val ANNUAL = of("annual") - /** The phase to replace this adjustment from. */ - fun planPhaseOrder(planPhaseOrder: Long?) = - planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + val SEMI_ANNUAL = of("semi_annual") - /** - * Alias for [Builder.planPhaseOrder]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + val MONTHLY = of("monthly") - /** - * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. - * - * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun planPhaseOrder(planPhaseOrder: JsonField) = apply { - this.planPhaseOrder = planPhaseOrder - } + val QUARTERLY = of("quarterly") - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + val ONE_TIME = of("one_time") - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + val CUSTOM = of("custom") - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun of(value: String) = Cadence(JsonField.of(value)) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } - /** - * Returns an immutable instance of [ReplaceAdjustment]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```kotlin - * .adjustment() - * .replacesAdjustmentId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): ReplaceAdjustment = - ReplaceAdjustment( - checkRequired("adjustment", adjustment), - checkRequired("replacesAdjustmentId", replacesAdjustmentId), - planPhaseOrder, - additionalProperties.toMutableMap(), - ) - } + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } - private var validated: Boolean = false + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } - fun validate(): ReplaceAdjustment = apply { - if (validated) { - return@apply - } + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") - adjustment().validate() - replacesAdjustmentId() - planPhaseOrder() - validated = true - } + private var validated: Boolean = false - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + fun validate(): Cadence = apply { + if (validated) { + return@apply + } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (adjustment.asKnown()?.validity() ?: 0) + - (if (replacesAdjustmentId.asKnown() == null) 0 else 1) + - (if (planPhaseOrder.asKnown() == null) 0 else 1) + known() + validated = true + } - /** The definition of a new adjustment to create and add to the plan. */ - @JsonDeserialize(using = Adjustment.Deserializer::class) - @JsonSerialize(using = Adjustment.Serializer::class) - class Adjustment - private constructor( - private val percentageDiscount: NewPercentageDiscount? = null, - private val usageDiscount: NewUsageDiscount? = null, - private val amountDiscount: NewAmountDiscount? = null, - private val minimum: NewMinimum? = null, - private val maximum: NewMaximum? = null, - private val _json: JsonValue? = null, - ) { + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - fun percentageDiscount(): NewPercentageDiscount? = percentageDiscount + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - fun usageDiscount(): NewUsageDiscount? = usageDiscount + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun amountDiscount(): NewAmountDiscount? = amountDiscount + return other is Cadence && value == other.value + } - fun minimum(): NewMinimum? = minimum + override fun hashCode() = value.hashCode() - fun maximum(): NewMaximum? = maximum + override fun toString() = value.toString() + } - fun isPercentageDiscount(): Boolean = percentageDiscount != null + /** Configuration for event_output pricing */ + class EventOutputConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val unitRatingKey: JsonField, + private val defaultUnitRate: JsonField, + private val groupingKey: JsonField, + private val additionalProperties: MutableMap, + ) { - fun isUsageDiscount(): Boolean = usageDiscount != null + @JsonCreator + private constructor( + @JsonProperty("unit_rating_key") + @ExcludeMissing + unitRatingKey: JsonField = JsonMissing.of(), + @JsonProperty("default_unit_rate") + @ExcludeMissing + defaultUnitRate: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + ) : this(unitRatingKey, defaultUnitRate, groupingKey, mutableMapOf()) - fun isAmountDiscount(): Boolean = amountDiscount != null + /** + * The key in the event data to extract the unit rate from. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun unitRatingKey(): String = unitRatingKey.getRequired("unit_rating_key") - fun isMinimum(): Boolean = minimum != null + /** + * If provided, this amount will be used as the unit rate when an event does not + * have a value for the `unit_rating_key`. If not provided, events missing a + * unit rate will be ignored. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun defaultUnitRate(): String? = + defaultUnitRate.getNullable("default_unit_rate") - fun isMaximum(): Boolean = maximum != null + /** + * An optional key in the event data to group by (e.g., event ID). All events + * will also be grouped by their unit rate. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun groupingKey(): String? = groupingKey.getNullable("grouping_key") - fun asPercentageDiscount(): NewPercentageDiscount = - percentageDiscount.getOrThrow("percentageDiscount") + /** + * Returns the raw JSON value of [unitRatingKey]. + * + * Unlike [unitRatingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_rating_key") + @ExcludeMissing + fun _unitRatingKey(): JsonField = unitRatingKey - fun asUsageDiscount(): NewUsageDiscount = usageDiscount.getOrThrow("usageDiscount") + /** + * Returns the raw JSON value of [defaultUnitRate]. + * + * Unlike [defaultUnitRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("default_unit_rate") + @ExcludeMissing + fun _defaultUnitRate(): JsonField = defaultUnitRate - fun asAmountDiscount(): NewAmountDiscount = amountDiscount.getOrThrow("amountDiscount") + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey - fun asMinimum(): NewMinimum = minimum.getOrThrow("minimum") + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - fun asMaximum(): NewMaximum = maximum.getOrThrow("maximum") + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - fun _json(): JsonValue? = _json + fun toBuilder() = Builder().from(this) - fun accept(visitor: Visitor): T = - when { - percentageDiscount != null -> - visitor.visitPercentageDiscount(percentageDiscount) - usageDiscount != null -> visitor.visitUsageDiscount(usageDiscount) - amountDiscount != null -> visitor.visitAmountDiscount(amountDiscount) - minimum != null -> visitor.visitMinimum(minimum) - maximum != null -> visitor.visitMaximum(maximum) - else -> visitor.unknown(_json) - } + companion object { - private var validated: Boolean = false + /** + * Returns a mutable builder for constructing an instance of + * [EventOutputConfig]. + * + * The following fields are required: + * ```kotlin + * .unitRatingKey() + * ``` + */ + fun builder() = Builder() + } - fun validate(): Adjustment = apply { - if (validated) { - return@apply - } + /** A builder for [EventOutputConfig]. */ + class Builder internal constructor() { - accept( - object : Visitor { - override fun visitPercentageDiscount( - percentageDiscount: NewPercentageDiscount - ) { - percentageDiscount.validate() - } + private var unitRatingKey: JsonField? = null + private var defaultUnitRate: JsonField = JsonMissing.of() + private var groupingKey: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() - override fun visitUsageDiscount(usageDiscount: NewUsageDiscount) { - usageDiscount.validate() + internal fun from(eventOutputConfig: EventOutputConfig) = apply { + unitRatingKey = eventOutputConfig.unitRatingKey + defaultUnitRate = eventOutputConfig.defaultUnitRate + groupingKey = eventOutputConfig.groupingKey + additionalProperties = + eventOutputConfig.additionalProperties.toMutableMap() } - override fun visitAmountDiscount(amountDiscount: NewAmountDiscount) { - amountDiscount.validate() - } + /** The key in the event data to extract the unit rate from. */ + fun unitRatingKey(unitRatingKey: String) = + unitRatingKey(JsonField.of(unitRatingKey)) - override fun visitMinimum(minimum: NewMinimum) { - minimum.validate() + /** + * Sets [Builder.unitRatingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.unitRatingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun unitRatingKey(unitRatingKey: JsonField) = apply { + this.unitRatingKey = unitRatingKey } - override fun visitMaximum(maximum: NewMaximum) { - maximum.validate() + /** + * If provided, this amount will be used as the unit rate when an event does + * not have a value for the `unit_rating_key`. If not provided, events + * missing a unit rate will be ignored. + */ + fun defaultUnitRate(defaultUnitRate: String?) = + defaultUnitRate(JsonField.ofNullable(defaultUnitRate)) + + /** + * Sets [Builder.defaultUnitRate] to an arbitrary JSON value. + * + * You should usually call [Builder.defaultUnitRate] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun defaultUnitRate(defaultUnitRate: JsonField) = apply { + this.defaultUnitRate = defaultUnitRate } - } - ) - validated = true - } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** + * An optional key in the event data to group by (e.g., event ID). All + * events will also be grouped by their unit rate. + */ + fun groupingKey(groupingKey: String?) = + groupingKey(JsonField.ofNullable(groupingKey)) - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitPercentageDiscount( - percentageDiscount: NewPercentageDiscount - ) = percentageDiscount.validity() + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } - override fun visitUsageDiscount(usageDiscount: NewUsageDiscount) = - usageDiscount.validity() + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - override fun visitAmountDiscount(amountDiscount: NewAmountDiscount) = - amountDiscount.validity() + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - override fun visitMinimum(minimum: NewMinimum) = minimum.validity() + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - override fun visitMaximum(maximum: NewMaximum) = maximum.validity() + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - override fun unknown(json: JsonValue?) = 0 + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [EventOutputConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .unitRatingKey() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): EventOutputConfig = + EventOutputConfig( + checkRequired("unitRatingKey", unitRatingKey), + defaultUnitRate, + groupingKey, + additionalProperties.toMutableMap(), + ) } - ) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + private var validated: Boolean = false - return other is Adjustment && - percentageDiscount == other.percentageDiscount && - usageDiscount == other.usageDiscount && - amountDiscount == other.amountDiscount && - minimum == other.minimum && - maximum == other.maximum - } + fun validate(): EventOutputConfig = apply { + if (validated) { + return@apply + } - override fun hashCode(): Int = - Objects.hash(percentageDiscount, usageDiscount, amountDiscount, minimum, maximum) + unitRatingKey() + defaultUnitRate() + groupingKey() + validated = true + } - override fun toString(): String = - when { - percentageDiscount != null -> - "Adjustment{percentageDiscount=$percentageDiscount}" - usageDiscount != null -> "Adjustment{usageDiscount=$usageDiscount}" - amountDiscount != null -> "Adjustment{amountDiscount=$amountDiscount}" - minimum != null -> "Adjustment{minimum=$minimum}" - maximum != null -> "Adjustment{maximum=$maximum}" - _json != null -> "Adjustment{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Adjustment") - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - companion object { + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (unitRatingKey.asKnown() == null) 0 else 1) + + (if (defaultUnitRate.asKnown() == null) 0 else 1) + + (if (groupingKey.asKnown() == null) 0 else 1) - fun ofPercentageDiscount(percentageDiscount: NewPercentageDiscount) = - Adjustment(percentageDiscount = percentageDiscount) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun ofUsageDiscount(usageDiscount: NewUsageDiscount) = - Adjustment(usageDiscount = usageDiscount) + return other is EventOutputConfig && + unitRatingKey == other.unitRatingKey && + defaultUnitRate == other.defaultUnitRate && + groupingKey == other.groupingKey && + additionalProperties == other.additionalProperties + } - fun ofAmountDiscount(amountDiscount: NewAmountDiscount) = - Adjustment(amountDiscount = amountDiscount) + private val hashCode: Int by lazy { + Objects.hash( + unitRatingKey, + defaultUnitRate, + groupingKey, + additionalProperties, + ) + } - fun ofMinimum(minimum: NewMinimum) = Adjustment(minimum = minimum) + override fun hashCode(): Int = hashCode - fun ofMaximum(maximum: NewMaximum) = Adjustment(maximum = maximum) - } + override fun toString() = + "EventOutputConfig{unitRatingKey=$unitRatingKey, defaultUnitRate=$defaultUnitRate, groupingKey=$groupingKey, additionalProperties=$additionalProperties}" + } - /** - * An interface that defines how to map each variant of [Adjustment] to a value of type - * [T]. - */ - interface Visitor { + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { - fun visitPercentageDiscount(percentageDiscount: NewPercentageDiscount): T + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties - fun visitUsageDiscount(usageDiscount: NewUsageDiscount): T + fun toBuilder() = Builder().from(this) - fun visitAmountDiscount(amountDiscount: NewAmountDiscount): T + companion object { - fun visitMinimum(minimum: NewMinimum): T + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } - fun visitMaximum(maximum: NewMaximum): T + /** A builder for [Metadata]. */ + class Builder internal constructor() { - /** - * Maps an unknown variant of [Adjustment] to a value of type [T]. - * - * An instance of [Adjustment] can contain an unknown variant if it was deserialized - * from data that doesn't match any known variant. For example, if the SDK is on an - * older version than the API, then the API may respond with new variants that the - * SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown Adjustment: $json") - } - } + private var additionalProperties: MutableMap = + mutableMapOf() - internal class Deserializer : BaseDeserializer(Adjustment::class) { + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } - override fun ObjectCodec.deserialize(node: JsonNode): Adjustment { - val json = JsonValue.fromJsonNode(node) - val adjustmentType = json.asObject()?.get("adjustment_type")?.asString() + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - when (adjustmentType) { - "percentage_discount" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Adjustment(percentageDiscount = it, _json = json) } - ?: Adjustment(_json = json) - } - "usage_discount" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(usageDiscount = it, _json = json) - } ?: Adjustment(_json = json) - } - "amount_discount" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(amountDiscount = it, _json = json) - } ?: Adjustment(_json = json) + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) } - "minimum" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(minimum = it, _json = json) - } ?: Adjustment(_json = json) + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) } - "maximum" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(maximum = it, _json = json) - } ?: Adjustment(_json = json) + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } - return Adjustment(_json = json) - } - } + private var validated: Boolean = false - internal class Serializer : BaseSerializer(Adjustment::class) { + fun validate(): Metadata = apply { + if (validated) { + return@apply + } - override fun serialize( - value: Adjustment, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.percentageDiscount != null -> - generator.writeObject(value.percentageDiscount) - value.usageDiscount != null -> generator.writeObject(value.usageDiscount) - value.amountDiscount != null -> generator.writeObject(value.amountDiscount) - value.minimum != null -> generator.writeObject(value.minimum) - value.maximum != null -> generator.writeObject(value.maximum) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Adjustment") + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } + + return other is EventOutput && + cadence == other.cadence && + eventOutputConfig == other.eventOutputConfig && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + eventOutputConfig, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties, + ) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "EventOutput{cadence=$cadence, eventOutputConfig=$eventOutputConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } } @@ -12940,65 +13651,51 @@ private constructor( return true } - return other is ReplaceAdjustment && - adjustment == other.adjustment && - replacesAdjustmentId == other.replacesAdjustmentId && + return other is AddPrice && + allocationPrice == other.allocationPrice && planPhaseOrder == other.planPhaseOrder && + price == other.price && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(adjustment, replacesAdjustmentId, planPhaseOrder, additionalProperties) + Objects.hash(allocationPrice, planPhaseOrder, price, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "ReplaceAdjustment{adjustment=$adjustment, replacesAdjustmentId=$replacesAdjustmentId, planPhaseOrder=$planPhaseOrder, additionalProperties=$additionalProperties}" + "AddPrice{allocationPrice=$allocationPrice, planPhaseOrder=$planPhaseOrder, price=$price, additionalProperties=$additionalProperties}" } - class ReplacePrice + class RemoveAdjustment @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val replacesPriceId: JsonField, - private val allocationPrice: JsonField, + private val adjustmentId: JsonField, private val planPhaseOrder: JsonField, - private val price: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("replaces_price_id") - @ExcludeMissing - replacesPriceId: JsonField = JsonMissing.of(), - @JsonProperty("allocation_price") + @JsonProperty("adjustment_id") @ExcludeMissing - allocationPrice: JsonField = JsonMissing.of(), + adjustmentId: JsonField = JsonMissing.of(), @JsonProperty("plan_phase_order") @ExcludeMissing planPhaseOrder: JsonField = JsonMissing.of(), - @JsonProperty("price") @ExcludeMissing price: JsonField = JsonMissing.of(), - ) : this(replacesPriceId, allocationPrice, planPhaseOrder, price, mutableMapOf()) + ) : this(adjustmentId, planPhaseOrder, mutableMapOf()) /** - * The id of the price on the plan to replace in the plan. + * The id of the adjustment to remove from on the plan. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ - fun replacesPriceId(): String = replacesPriceId.getRequired("replaces_price_id") - - /** - * The allocation price to add to the plan. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun allocationPrice(): NewAllocationPrice? = allocationPrice.getNullable("allocation_price") + fun adjustmentId(): String = adjustmentId.getRequired("adjustment_id") /** - * The phase to replace this price from. + * The phase to remove this adjustment from. * * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -13006,32 +13703,14 @@ private constructor( fun planPhaseOrder(): Long? = planPhaseOrder.getNullable("plan_phase_order") /** - * New plan price request body params. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun price(): Price? = price.getNullable("price") - - /** - * Returns the raw JSON value of [replacesPriceId]. - * - * Unlike [replacesPriceId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("replaces_price_id") - @ExcludeMissing - fun _replacesPriceId(): JsonField = replacesPriceId - - /** - * Returns the raw JSON value of [allocationPrice]. + * Returns the raw JSON value of [adjustmentId]. * - * Unlike [allocationPrice], this method doesn't throw if the JSON field has an unexpected + * Unlike [adjustmentId], this method doesn't throw if the JSON field has an unexpected * type. */ - @JsonProperty("allocation_price") + @JsonProperty("adjustment_id") @ExcludeMissing - fun _allocationPrice(): JsonField = allocationPrice + fun _adjustmentId(): JsonField = adjustmentId /** * Returns the raw JSON value of [planPhaseOrder]. @@ -13043,13 +13722,6 @@ private constructor( @ExcludeMissing fun _planPhaseOrder(): JsonField = planPhaseOrder - /** - * Returns the raw JSON value of [price]. - * - * Unlike [price], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("price") @ExcludeMissing fun _price(): JsonField = price - @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -13065,64 +13737,44 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [ReplacePrice]. + * Returns a mutable builder for constructing an instance of [RemoveAdjustment]. * * The following fields are required: * ```kotlin - * .replacesPriceId() + * .adjustmentId() * ``` */ fun builder() = Builder() } - /** A builder for [ReplacePrice]. */ + /** A builder for [RemoveAdjustment]. */ class Builder internal constructor() { - private var replacesPriceId: JsonField? = null - private var allocationPrice: JsonField = JsonMissing.of() + private var adjustmentId: JsonField? = null private var planPhaseOrder: JsonField = JsonMissing.of() - private var price: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(replacePrice: ReplacePrice) = apply { - replacesPriceId = replacePrice.replacesPriceId - allocationPrice = replacePrice.allocationPrice - planPhaseOrder = replacePrice.planPhaseOrder - price = replacePrice.price - additionalProperties = replacePrice.additionalProperties.toMutableMap() + internal fun from(removeAdjustment: RemoveAdjustment) = apply { + adjustmentId = removeAdjustment.adjustmentId + planPhaseOrder = removeAdjustment.planPhaseOrder + additionalProperties = removeAdjustment.additionalProperties.toMutableMap() } - /** The id of the price on the plan to replace in the plan. */ - fun replacesPriceId(replacesPriceId: String) = - replacesPriceId(JsonField.of(replacesPriceId)) + /** The id of the adjustment to remove from on the plan. */ + fun adjustmentId(adjustmentId: String) = adjustmentId(JsonField.of(adjustmentId)) /** - * Sets [Builder.replacesPriceId] to an arbitrary JSON value. + * Sets [Builder.adjustmentId] to an arbitrary JSON value. * - * You should usually call [Builder.replacesPriceId] with a well-typed [String] value + * You should usually call [Builder.adjustmentId] with a well-typed [String] value * instead. This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun replacesPriceId(replacesPriceId: JsonField) = apply { - this.replacesPriceId = replacesPriceId - } - - /** The allocation price to add to the plan. */ - fun allocationPrice(allocationPrice: NewAllocationPrice?) = - allocationPrice(JsonField.ofNullable(allocationPrice)) - - /** - * Sets [Builder.allocationPrice] to an arbitrary JSON value. - * - * You should usually call [Builder.allocationPrice] with a well-typed - * [NewAllocationPrice] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun allocationPrice(allocationPrice: JsonField) = apply { - this.allocationPrice = allocationPrice + fun adjustmentId(adjustmentId: JsonField) = apply { + this.adjustmentId = adjustmentId } - /** The phase to replace this price from. */ + /** The phase to remove this adjustment from. */ fun planPhaseOrder(planPhaseOrder: Long?) = planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) @@ -13144,221 +13796,54 @@ private constructor( this.planPhaseOrder = planPhaseOrder } - /** New plan price request body params. */ - fun price(price: Price?) = price(JsonField.ofNullable(price)) + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** - * Sets [Builder.price] to an arbitrary JSON value. - * - * You should usually call [Builder.price] with a well-typed [Price] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun price(price: JsonField) = apply { this.price = price } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** Alias for calling [price] with `Price.ofUnit(unit)`. */ - fun price(unit: NewPlanUnitPrice) = price(Price.ofUnit(unit)) + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - /** Alias for calling [price] with `Price.ofTiered(tiered)`. */ - fun price(tiered: NewPlanTieredPrice) = price(Price.ofTiered(tiered)) + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - /** Alias for calling [price] with `Price.ofBulk(bulk)`. */ - fun price(bulk: NewPlanBulkPrice) = price(Price.ofBulk(bulk)) - - /** Alias for calling [price] with `Price.ofBulkWithFilters(bulkWithFilters)`. */ - fun price(bulkWithFilters: Price.BulkWithFilters) = - price(Price.ofBulkWithFilters(bulkWithFilters)) - - /** Alias for calling [price] with `Price.ofPackage(package_)`. */ - fun price(package_: NewPlanPackagePrice) = price(Price.ofPackage(package_)) - - /** Alias for calling [price] with `Price.ofMatrix(matrix)`. */ - fun price(matrix: NewPlanMatrixPrice) = price(Price.ofMatrix(matrix)) - - /** - * Alias for calling [price] with `Price.ofThresholdTotalAmount(thresholdTotalAmount)`. - */ - fun price(thresholdTotalAmount: NewPlanThresholdTotalAmountPrice) = - price(Price.ofThresholdTotalAmount(thresholdTotalAmount)) - - /** Alias for calling [price] with `Price.ofTieredPackage(tieredPackage)`. */ - fun price(tieredPackage: NewPlanTieredPackagePrice) = - price(Price.ofTieredPackage(tieredPackage)) - - /** Alias for calling [price] with `Price.ofTieredWithMinimum(tieredWithMinimum)`. */ - fun price(tieredWithMinimum: NewPlanTieredWithMinimumPrice) = - price(Price.ofTieredWithMinimum(tieredWithMinimum)) - - /** Alias for calling [price] with `Price.ofGroupedTiered(groupedTiered)`. */ - fun price(groupedTiered: NewPlanGroupedTieredPrice) = - price(Price.ofGroupedTiered(groupedTiered)) - - /** - * Alias for calling [price] with - * `Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)`. - */ - fun price(tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice) = - price(Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)) - - /** - * Alias for calling [price] with - * `Price.ofPackageWithAllocation(packageWithAllocation)`. - */ - fun price(packageWithAllocation: NewPlanPackageWithAllocationPrice) = - price(Price.ofPackageWithAllocation(packageWithAllocation)) - - /** Alias for calling [price] with `Price.ofUnitWithPercent(unitWithPercent)`. */ - fun price(unitWithPercent: NewPlanUnitWithPercentPrice) = - price(Price.ofUnitWithPercent(unitWithPercent)) - - /** - * Alias for calling [price] with `Price.ofMatrixWithAllocation(matrixWithAllocation)`. - */ - fun price(matrixWithAllocation: NewPlanMatrixWithAllocationPrice) = - price(Price.ofMatrixWithAllocation(matrixWithAllocation)) - - /** - * Alias for calling [price] with `Price.ofTieredWithProration(tieredWithProration)`. - */ - fun price(tieredWithProration: Price.TieredWithProration) = - price(Price.ofTieredWithProration(tieredWithProration)) - - /** Alias for calling [price] with `Price.ofUnitWithProration(unitWithProration)`. */ - fun price(unitWithProration: NewPlanUnitWithProrationPrice) = - price(Price.ofUnitWithProration(unitWithProration)) - - /** Alias for calling [price] with `Price.ofGroupedAllocation(groupedAllocation)`. */ - fun price(groupedAllocation: NewPlanGroupedAllocationPrice) = - price(Price.ofGroupedAllocation(groupedAllocation)) - - /** Alias for calling [price] with `Price.ofBulkWithProration(bulkWithProration)`. */ - fun price(bulkWithProration: NewPlanBulkWithProrationPrice) = - price(Price.ofBulkWithProration(bulkWithProration)) - - /** - * Alias for calling [price] with - * `Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)`. - */ - fun price(groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice) = - price(Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)) - - /** - * Alias for calling [price] with - * `Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)`. - */ - fun price(groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice) = - price(Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)) - - /** - * Alias for calling [price] with - * `Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)`. - */ - fun price(groupedWithMinMaxThresholds: Price.GroupedWithMinMaxThresholds) = - price(Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)) - - /** - * Alias for calling [price] with - * `Price.ofMatrixWithDisplayName(matrixWithDisplayName)`. - */ - fun price(matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice) = - price(Price.ofMatrixWithDisplayName(matrixWithDisplayName)) - - /** - * Alias for calling [price] with `Price.ofGroupedTieredPackage(groupedTieredPackage)`. - */ - fun price(groupedTieredPackage: NewPlanGroupedTieredPackagePrice) = - price(Price.ofGroupedTieredPackage(groupedTieredPackage)) - - /** - * Alias for calling [price] with - * `Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)`. - */ - fun price(maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice) = - price(Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)) - - /** - * Alias for calling [price] with - * `Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)`. - */ - fun price(scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice) = - price(Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)) - - /** - * Alias for calling [price] with - * `Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)`. - */ - fun price( - scalableMatrixWithTieredPricing: NewPlanScalableMatrixWithTieredPricingPrice - ) = price(Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)) - - /** - * Alias for calling [price] with - * `Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)`. - */ - fun price(cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice) = - price(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) - - /** Alias for calling [price] with `Price.ofMinimum(minimum)`. */ - fun price(minimum: NewPlanMinimumCompositePrice) = price(Price.ofMinimum(minimum)) - - /** Alias for calling [price] with `Price.ofPercent(percent)`. */ - fun price(percent: Price.Percent) = price(Price.ofPercent(percent)) - - /** Alias for calling [price] with `Price.ofEventOutput(eventOutput)`. */ - fun price(eventOutput: Price.EventOutput) = price(Price.ofEventOutput(eventOutput)) - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } /** - * Returns an immutable instance of [ReplacePrice]. + * Returns an immutable instance of [RemoveAdjustment]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```kotlin - * .replacesPriceId() + * .adjustmentId() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): ReplacePrice = - ReplacePrice( - checkRequired("replacesPriceId", replacesPriceId), - allocationPrice, + fun build(): RemoveAdjustment = + RemoveAdjustment( + checkRequired("adjustmentId", adjustmentId), planPhaseOrder, - price, additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): ReplacePrice = apply { + fun validate(): RemoveAdjustment = apply { if (validated) { return@apply } - replacesPriceId() - allocationPrice()?.validate() + adjustmentId() planPhaseOrder() - price()?.validate() validated = true } @@ -13377,1223 +13862,4578 @@ private constructor( * Used for best match union deserialization. */ internal fun validity(): Int = - (if (replacesPriceId.asKnown() == null) 0 else 1) + - (allocationPrice.asKnown()?.validity() ?: 0) + - (if (planPhaseOrder.asKnown() == null) 0 else 1) + - (price.asKnown()?.validity() ?: 0) - - /** New plan price request body params. */ - @JsonDeserialize(using = Price.Deserializer::class) - @JsonSerialize(using = Price.Serializer::class) - class Price - private constructor( - private val unit: NewPlanUnitPrice? = null, - private val tiered: NewPlanTieredPrice? = null, - private val bulk: NewPlanBulkPrice? = null, - private val bulkWithFilters: BulkWithFilters? = null, - private val package_: NewPlanPackagePrice? = null, - private val matrix: NewPlanMatrixPrice? = null, - private val thresholdTotalAmount: NewPlanThresholdTotalAmountPrice? = null, - private val tieredPackage: NewPlanTieredPackagePrice? = null, - private val tieredWithMinimum: NewPlanTieredWithMinimumPrice? = null, - private val groupedTiered: NewPlanGroupedTieredPrice? = null, - private val tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice? = null, - private val packageWithAllocation: NewPlanPackageWithAllocationPrice? = null, - private val unitWithPercent: NewPlanUnitWithPercentPrice? = null, - private val matrixWithAllocation: NewPlanMatrixWithAllocationPrice? = null, - private val tieredWithProration: TieredWithProration? = null, - private val unitWithProration: NewPlanUnitWithProrationPrice? = null, - private val groupedAllocation: NewPlanGroupedAllocationPrice? = null, - private val bulkWithProration: NewPlanBulkWithProrationPrice? = null, - private val groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice? = null, - private val groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice? = null, - private val groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds? = null, - private val matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice? = null, - private val groupedTieredPackage: NewPlanGroupedTieredPackagePrice? = null, - private val maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice? = null, - private val scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice? = - null, - private val scalableMatrixWithTieredPricing: - NewPlanScalableMatrixWithTieredPricingPrice? = - null, - private val cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice? = null, - private val minimum: NewPlanMinimumCompositePrice? = null, - private val percent: Percent? = null, - private val eventOutput: EventOutput? = null, - private val _json: JsonValue? = null, - ) { + (if (adjustmentId.asKnown() == null) 0 else 1) + + (if (planPhaseOrder.asKnown() == null) 0 else 1) - fun unit(): NewPlanUnitPrice? = unit + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun tiered(): NewPlanTieredPrice? = tiered + return other is RemoveAdjustment && + adjustmentId == other.adjustmentId && + planPhaseOrder == other.planPhaseOrder && + additionalProperties == other.additionalProperties + } - fun bulk(): NewPlanBulkPrice? = bulk + private val hashCode: Int by lazy { + Objects.hash(adjustmentId, planPhaseOrder, additionalProperties) + } - fun bulkWithFilters(): BulkWithFilters? = bulkWithFilters + override fun hashCode(): Int = hashCode - fun package_(): NewPlanPackagePrice? = package_ + override fun toString() = + "RemoveAdjustment{adjustmentId=$adjustmentId, planPhaseOrder=$planPhaseOrder, additionalProperties=$additionalProperties}" + } - fun matrix(): NewPlanMatrixPrice? = matrix + class RemovePrice + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val priceId: JsonField, + private val planPhaseOrder: JsonField, + private val additionalProperties: MutableMap, + ) { - fun thresholdTotalAmount(): NewPlanThresholdTotalAmountPrice? = thresholdTotalAmount + @JsonCreator + private constructor( + @JsonProperty("price_id") @ExcludeMissing priceId: JsonField = JsonMissing.of(), + @JsonProperty("plan_phase_order") + @ExcludeMissing + planPhaseOrder: JsonField = JsonMissing.of(), + ) : this(priceId, planPhaseOrder, mutableMapOf()) - fun tieredPackage(): NewPlanTieredPackagePrice? = tieredPackage + /** + * The id of the price to remove from the plan. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun priceId(): String = priceId.getRequired("price_id") - fun tieredWithMinimum(): NewPlanTieredWithMinimumPrice? = tieredWithMinimum + /** + * The phase to remove this price from. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun planPhaseOrder(): Long? = planPhaseOrder.getNullable("plan_phase_order") - fun groupedTiered(): NewPlanGroupedTieredPrice? = groupedTiered + /** + * Returns the raw JSON value of [priceId]. + * + * Unlike [priceId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId - fun tieredPackageWithMinimum(): NewPlanTieredPackageWithMinimumPrice? = - tieredPackageWithMinimum + /** + * Returns the raw JSON value of [planPhaseOrder]. + * + * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder - fun packageWithAllocation(): NewPlanPackageWithAllocationPrice? = packageWithAllocation + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - fun unitWithPercent(): NewPlanUnitWithPercentPrice? = unitWithPercent + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - fun matrixWithAllocation(): NewPlanMatrixWithAllocationPrice? = matrixWithAllocation + fun toBuilder() = Builder().from(this) - fun tieredWithProration(): TieredWithProration? = tieredWithProration + companion object { - fun unitWithProration(): NewPlanUnitWithProrationPrice? = unitWithProration + /** + * Returns a mutable builder for constructing an instance of [RemovePrice]. + * + * The following fields are required: + * ```kotlin + * .priceId() + * ``` + */ + fun builder() = Builder() + } - fun groupedAllocation(): NewPlanGroupedAllocationPrice? = groupedAllocation + /** A builder for [RemovePrice]. */ + class Builder internal constructor() { - fun bulkWithProration(): NewPlanBulkWithProrationPrice? = bulkWithProration + private var priceId: JsonField? = null + private var planPhaseOrder: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - fun groupedWithProratedMinimum(): NewPlanGroupedWithProratedMinimumPrice? = - groupedWithProratedMinimum + internal fun from(removePrice: RemovePrice) = apply { + priceId = removePrice.priceId + planPhaseOrder = removePrice.planPhaseOrder + additionalProperties = removePrice.additionalProperties.toMutableMap() + } - fun groupedWithMeteredMinimum(): NewPlanGroupedWithMeteredMinimumPrice? = - groupedWithMeteredMinimum + /** The id of the price to remove from the plan. */ + fun priceId(priceId: String) = priceId(JsonField.of(priceId)) - fun groupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds? = - groupedWithMinMaxThresholds + /** + * Sets [Builder.priceId] to an arbitrary JSON value. + * + * You should usually call [Builder.priceId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun priceId(priceId: JsonField) = apply { this.priceId = priceId } - fun matrixWithDisplayName(): NewPlanMatrixWithDisplayNamePrice? = matrixWithDisplayName + /** The phase to remove this price from. */ + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) - fun groupedTieredPackage(): NewPlanGroupedTieredPackagePrice? = groupedTieredPackage + /** + * Alias for [Builder.planPhaseOrder]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) - fun maxGroupTieredPackage(): NewPlanMaxGroupTieredPackagePrice? = maxGroupTieredPackage + /** + * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. + * + * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun planPhaseOrder(planPhaseOrder: JsonField) = apply { + this.planPhaseOrder = planPhaseOrder + } - fun scalableMatrixWithUnitPricing(): NewPlanScalableMatrixWithUnitPricingPrice? = - scalableMatrixWithUnitPricing + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun scalableMatrixWithTieredPricing(): NewPlanScalableMatrixWithTieredPricingPrice? = - scalableMatrixWithTieredPricing + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun cumulativeGroupedBulk(): NewPlanCumulativeGroupedBulkPrice? = cumulativeGroupedBulk + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun minimum(): NewPlanMinimumCompositePrice? = minimum + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - fun percent(): Percent? = percent + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - fun eventOutput(): EventOutput? = eventOutput + /** + * Returns an immutable instance of [RemovePrice]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .priceId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): RemovePrice = + RemovePrice( + checkRequired("priceId", priceId), + planPhaseOrder, + additionalProperties.toMutableMap(), + ) + } - fun isUnit(): Boolean = unit != null + private var validated: Boolean = false - fun isTiered(): Boolean = tiered != null + fun validate(): RemovePrice = apply { + if (validated) { + return@apply + } - fun isBulk(): Boolean = bulk != null + priceId() + planPhaseOrder() + validated = true + } - fun isBulkWithFilters(): Boolean = bulkWithFilters != null + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - fun isPackage(): Boolean = package_ != null + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (priceId.asKnown() == null) 0 else 1) + + (if (planPhaseOrder.asKnown() == null) 0 else 1) - fun isMatrix(): Boolean = matrix != null + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun isThresholdTotalAmount(): Boolean = thresholdTotalAmount != null + return other is RemovePrice && + priceId == other.priceId && + planPhaseOrder == other.planPhaseOrder && + additionalProperties == other.additionalProperties + } - fun isTieredPackage(): Boolean = tieredPackage != null + private val hashCode: Int by lazy { + Objects.hash(priceId, planPhaseOrder, additionalProperties) + } - fun isTieredWithMinimum(): Boolean = tieredWithMinimum != null + override fun hashCode(): Int = hashCode - fun isGroupedTiered(): Boolean = groupedTiered != null + override fun toString() = + "RemovePrice{priceId=$priceId, planPhaseOrder=$planPhaseOrder, additionalProperties=$additionalProperties}" + } - fun isTieredPackageWithMinimum(): Boolean = tieredPackageWithMinimum != null + class ReplaceAdjustment + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val adjustment: JsonField, + private val replacesAdjustmentId: JsonField, + private val planPhaseOrder: JsonField, + private val additionalProperties: MutableMap, + ) { - fun isPackageWithAllocation(): Boolean = packageWithAllocation != null + @JsonCreator + private constructor( + @JsonProperty("adjustment") + @ExcludeMissing + adjustment: JsonField = JsonMissing.of(), + @JsonProperty("replaces_adjustment_id") + @ExcludeMissing + replacesAdjustmentId: JsonField = JsonMissing.of(), + @JsonProperty("plan_phase_order") + @ExcludeMissing + planPhaseOrder: JsonField = JsonMissing.of(), + ) : this(adjustment, replacesAdjustmentId, planPhaseOrder, mutableMapOf()) - fun isUnitWithPercent(): Boolean = unitWithPercent != null + /** + * The definition of a new adjustment to create and add to the plan. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun adjustment(): Adjustment = adjustment.getRequired("adjustment") - fun isMatrixWithAllocation(): Boolean = matrixWithAllocation != null + /** + * The id of the adjustment on the plan to replace in the plan. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun replacesAdjustmentId(): String = + replacesAdjustmentId.getRequired("replaces_adjustment_id") - fun isTieredWithProration(): Boolean = tieredWithProration != null + /** + * The phase to replace this adjustment from. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun planPhaseOrder(): Long? = planPhaseOrder.getNullable("plan_phase_order") - fun isUnitWithProration(): Boolean = unitWithProration != null - - fun isGroupedAllocation(): Boolean = groupedAllocation != null - - fun isBulkWithProration(): Boolean = bulkWithProration != null - - fun isGroupedWithProratedMinimum(): Boolean = groupedWithProratedMinimum != null - - fun isGroupedWithMeteredMinimum(): Boolean = groupedWithMeteredMinimum != null + /** + * Returns the raw JSON value of [adjustment]. + * + * Unlike [adjustment], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("adjustment") + @ExcludeMissing + fun _adjustment(): JsonField = adjustment - fun isGroupedWithMinMaxThresholds(): Boolean = groupedWithMinMaxThresholds != null + /** + * Returns the raw JSON value of [replacesAdjustmentId]. + * + * Unlike [replacesAdjustmentId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("replaces_adjustment_id") + @ExcludeMissing + fun _replacesAdjustmentId(): JsonField = replacesAdjustmentId - fun isMatrixWithDisplayName(): Boolean = matrixWithDisplayName != null + /** + * Returns the raw JSON value of [planPhaseOrder]. + * + * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder - fun isGroupedTieredPackage(): Boolean = groupedTieredPackage != null + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - fun isMaxGroupTieredPackage(): Boolean = maxGroupTieredPackage != null + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - fun isScalableMatrixWithUnitPricing(): Boolean = scalableMatrixWithUnitPricing != null + fun toBuilder() = Builder().from(this) - fun isScalableMatrixWithTieredPricing(): Boolean = - scalableMatrixWithTieredPricing != null + companion object { - fun isCumulativeGroupedBulk(): Boolean = cumulativeGroupedBulk != null + /** + * Returns a mutable builder for constructing an instance of [ReplaceAdjustment]. + * + * The following fields are required: + * ```kotlin + * .adjustment() + * .replacesAdjustmentId() + * ``` + */ + fun builder() = Builder() + } - fun isMinimum(): Boolean = minimum != null + /** A builder for [ReplaceAdjustment]. */ + class Builder internal constructor() { - fun isPercent(): Boolean = percent != null + private var adjustment: JsonField? = null + private var replacesAdjustmentId: JsonField? = null + private var planPhaseOrder: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - fun isEventOutput(): Boolean = eventOutput != null + internal fun from(replaceAdjustment: ReplaceAdjustment) = apply { + adjustment = replaceAdjustment.adjustment + replacesAdjustmentId = replaceAdjustment.replacesAdjustmentId + planPhaseOrder = replaceAdjustment.planPhaseOrder + additionalProperties = replaceAdjustment.additionalProperties.toMutableMap() + } - fun asUnit(): NewPlanUnitPrice = unit.getOrThrow("unit") + /** The definition of a new adjustment to create and add to the plan. */ + fun adjustment(adjustment: Adjustment) = adjustment(JsonField.of(adjustment)) - fun asTiered(): NewPlanTieredPrice = tiered.getOrThrow("tiered") + /** + * Sets [Builder.adjustment] to an arbitrary JSON value. + * + * You should usually call [Builder.adjustment] with a well-typed [Adjustment] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun adjustment(adjustment: JsonField) = apply { + this.adjustment = adjustment + } - fun asBulk(): NewPlanBulkPrice = bulk.getOrThrow("bulk") + /** + * Alias for calling [adjustment] with + * `Adjustment.ofPercentageDiscount(percentageDiscount)`. + */ + fun adjustment(percentageDiscount: NewPercentageDiscount) = + adjustment(Adjustment.ofPercentageDiscount(percentageDiscount)) - fun asBulkWithFilters(): BulkWithFilters = bulkWithFilters.getOrThrow("bulkWithFilters") + /** + * Alias for calling [adjustment] with the following: + * ```kotlin + * NewPercentageDiscount.builder() + * .adjustmentType(NewPercentageDiscount.AdjustmentType.PERCENTAGE_DISCOUNT) + * .percentageDiscount(percentageDiscount) + * .build() + * ``` + */ + fun percentageDiscountAdjustment(percentageDiscount: Double) = + adjustment( + NewPercentageDiscount.builder() + .adjustmentType(NewPercentageDiscount.AdjustmentType.PERCENTAGE_DISCOUNT) + .percentageDiscount(percentageDiscount) + .build() + ) - fun asPackage(): NewPlanPackagePrice = package_.getOrThrow("package_") + /** Alias for calling [adjustment] with `Adjustment.ofUsageDiscount(usageDiscount)`. */ + fun adjustment(usageDiscount: NewUsageDiscount) = + adjustment(Adjustment.ofUsageDiscount(usageDiscount)) - fun asMatrix(): NewPlanMatrixPrice = matrix.getOrThrow("matrix") + /** + * Alias for calling [adjustment] with the following: + * ```kotlin + * NewUsageDiscount.builder() + * .adjustmentType(NewUsageDiscount.AdjustmentType.USAGE_DISCOUNT) + * .usageDiscount(usageDiscount) + * .build() + * ``` + */ + fun usageDiscountAdjustment(usageDiscount: Double) = + adjustment( + NewUsageDiscount.builder() + .adjustmentType(NewUsageDiscount.AdjustmentType.USAGE_DISCOUNT) + .usageDiscount(usageDiscount) + .build() + ) - fun asThresholdTotalAmount(): NewPlanThresholdTotalAmountPrice = - thresholdTotalAmount.getOrThrow("thresholdTotalAmount") + /** + * Alias for calling [adjustment] with `Adjustment.ofAmountDiscount(amountDiscount)`. + */ + fun adjustment(amountDiscount: NewAmountDiscount) = + adjustment(Adjustment.ofAmountDiscount(amountDiscount)) - fun asTieredPackage(): NewPlanTieredPackagePrice = - tieredPackage.getOrThrow("tieredPackage") + /** + * Alias for calling [adjustment] with the following: + * ```kotlin + * NewAmountDiscount.builder() + * .adjustmentType(NewAmountDiscount.AdjustmentType.AMOUNT_DISCOUNT) + * .amountDiscount(amountDiscount) + * .build() + * ``` + */ + fun amountDiscountAdjustment(amountDiscount: String) = + adjustment( + NewAmountDiscount.builder() + .adjustmentType(NewAmountDiscount.AdjustmentType.AMOUNT_DISCOUNT) + .amountDiscount(amountDiscount) + .build() + ) - fun asTieredWithMinimum(): NewPlanTieredWithMinimumPrice = - tieredWithMinimum.getOrThrow("tieredWithMinimum") + /** Alias for calling [adjustment] with `Adjustment.ofMinimum(minimum)`. */ + fun adjustment(minimum: NewMinimum) = adjustment(Adjustment.ofMinimum(minimum)) - fun asGroupedTiered(): NewPlanGroupedTieredPrice = - groupedTiered.getOrThrow("groupedTiered") + /** Alias for calling [adjustment] with `Adjustment.ofMaximum(maximum)`. */ + fun adjustment(maximum: NewMaximum) = adjustment(Adjustment.ofMaximum(maximum)) - fun asTieredPackageWithMinimum(): NewPlanTieredPackageWithMinimumPrice = - tieredPackageWithMinimum.getOrThrow("tieredPackageWithMinimum") + /** + * Alias for calling [adjustment] with the following: + * ```kotlin + * NewMaximum.builder() + * .adjustmentType(NewMaximum.AdjustmentType.MAXIMUM) + * .maximumAmount(maximumAmount) + * .build() + * ``` + */ + fun maximumAdjustment(maximumAmount: String) = + adjustment( + NewMaximum.builder() + .adjustmentType(NewMaximum.AdjustmentType.MAXIMUM) + .maximumAmount(maximumAmount) + .build() + ) - fun asPackageWithAllocation(): NewPlanPackageWithAllocationPrice = - packageWithAllocation.getOrThrow("packageWithAllocation") + /** The id of the adjustment on the plan to replace in the plan. */ + fun replacesAdjustmentId(replacesAdjustmentId: String) = + replacesAdjustmentId(JsonField.of(replacesAdjustmentId)) - fun asUnitWithPercent(): NewPlanUnitWithPercentPrice = - unitWithPercent.getOrThrow("unitWithPercent") + /** + * Sets [Builder.replacesAdjustmentId] to an arbitrary JSON value. + * + * You should usually call [Builder.replacesAdjustmentId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun replacesAdjustmentId(replacesAdjustmentId: JsonField) = apply { + this.replacesAdjustmentId = replacesAdjustmentId + } - fun asMatrixWithAllocation(): NewPlanMatrixWithAllocationPrice = - matrixWithAllocation.getOrThrow("matrixWithAllocation") + /** The phase to replace this adjustment from. */ + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) - fun asTieredWithProration(): TieredWithProration = - tieredWithProration.getOrThrow("tieredWithProration") + /** + * Alias for [Builder.planPhaseOrder]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) - fun asUnitWithProration(): NewPlanUnitWithProrationPrice = - unitWithProration.getOrThrow("unitWithProration") + /** + * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. + * + * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun planPhaseOrder(planPhaseOrder: JsonField) = apply { + this.planPhaseOrder = planPhaseOrder + } - fun asGroupedAllocation(): NewPlanGroupedAllocationPrice = - groupedAllocation.getOrThrow("groupedAllocation") + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun asBulkWithProration(): NewPlanBulkWithProrationPrice = - bulkWithProration.getOrThrow("bulkWithProration") + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun asGroupedWithProratedMinimum(): NewPlanGroupedWithProratedMinimumPrice = - groupedWithProratedMinimum.getOrThrow("groupedWithProratedMinimum") + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun asGroupedWithMeteredMinimum(): NewPlanGroupedWithMeteredMinimumPrice = - groupedWithMeteredMinimum.getOrThrow("groupedWithMeteredMinimum") + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - fun asGroupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds = - groupedWithMinMaxThresholds.getOrThrow("groupedWithMinMaxThresholds") + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - fun asMatrixWithDisplayName(): NewPlanMatrixWithDisplayNamePrice = - matrixWithDisplayName.getOrThrow("matrixWithDisplayName") + /** + * Returns an immutable instance of [ReplaceAdjustment]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .adjustment() + * .replacesAdjustmentId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ReplaceAdjustment = + ReplaceAdjustment( + checkRequired("adjustment", adjustment), + checkRequired("replacesAdjustmentId", replacesAdjustmentId), + planPhaseOrder, + additionalProperties.toMutableMap(), + ) + } - fun asGroupedTieredPackage(): NewPlanGroupedTieredPackagePrice = - groupedTieredPackage.getOrThrow("groupedTieredPackage") + private var validated: Boolean = false - fun asMaxGroupTieredPackage(): NewPlanMaxGroupTieredPackagePrice = - maxGroupTieredPackage.getOrThrow("maxGroupTieredPackage") + fun validate(): ReplaceAdjustment = apply { + if (validated) { + return@apply + } - fun asScalableMatrixWithUnitPricing(): NewPlanScalableMatrixWithUnitPricingPrice = - scalableMatrixWithUnitPricing.getOrThrow("scalableMatrixWithUnitPricing") + adjustment().validate() + replacesAdjustmentId() + planPhaseOrder() + validated = true + } - fun asScalableMatrixWithTieredPricing(): NewPlanScalableMatrixWithTieredPricingPrice = - scalableMatrixWithTieredPricing.getOrThrow("scalableMatrixWithTieredPricing") + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - fun asCumulativeGroupedBulk(): NewPlanCumulativeGroupedBulkPrice = - cumulativeGroupedBulk.getOrThrow("cumulativeGroupedBulk") + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (adjustment.asKnown()?.validity() ?: 0) + + (if (replacesAdjustmentId.asKnown() == null) 0 else 1) + + (if (planPhaseOrder.asKnown() == null) 0 else 1) - fun asMinimum(): NewPlanMinimumCompositePrice = minimum.getOrThrow("minimum") + /** The definition of a new adjustment to create and add to the plan. */ + @JsonDeserialize(using = Adjustment.Deserializer::class) + @JsonSerialize(using = Adjustment.Serializer::class) + class Adjustment + private constructor( + private val percentageDiscount: NewPercentageDiscount? = null, + private val usageDiscount: NewUsageDiscount? = null, + private val amountDiscount: NewAmountDiscount? = null, + private val minimum: NewMinimum? = null, + private val maximum: NewMaximum? = null, + private val _json: JsonValue? = null, + ) { - fun asPercent(): Percent = percent.getOrThrow("percent") + fun percentageDiscount(): NewPercentageDiscount? = percentageDiscount - fun asEventOutput(): EventOutput = eventOutput.getOrThrow("eventOutput") + fun usageDiscount(): NewUsageDiscount? = usageDiscount + + fun amountDiscount(): NewAmountDiscount? = amountDiscount + + fun minimum(): NewMinimum? = minimum + + fun maximum(): NewMaximum? = maximum + + fun isPercentageDiscount(): Boolean = percentageDiscount != null + + fun isUsageDiscount(): Boolean = usageDiscount != null + + fun isAmountDiscount(): Boolean = amountDiscount != null + + fun isMinimum(): Boolean = minimum != null + + fun isMaximum(): Boolean = maximum != null + + fun asPercentageDiscount(): NewPercentageDiscount = + percentageDiscount.getOrThrow("percentageDiscount") + + fun asUsageDiscount(): NewUsageDiscount = usageDiscount.getOrThrow("usageDiscount") + + fun asAmountDiscount(): NewAmountDiscount = amountDiscount.getOrThrow("amountDiscount") + + fun asMinimum(): NewMinimum = minimum.getOrThrow("minimum") + + fun asMaximum(): NewMaximum = maximum.getOrThrow("maximum") fun _json(): JsonValue? = _json fun accept(visitor: Visitor): T = when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - bulk != null -> visitor.visitBulk(bulk) - bulkWithFilters != null -> visitor.visitBulkWithFilters(bulkWithFilters) - package_ != null -> visitor.visitPackage(package_) - matrix != null -> visitor.visitMatrix(matrix) - thresholdTotalAmount != null -> - visitor.visitThresholdTotalAmount(thresholdTotalAmount) - tieredPackage != null -> visitor.visitTieredPackage(tieredPackage) - tieredWithMinimum != null -> visitor.visitTieredWithMinimum(tieredWithMinimum) - groupedTiered != null -> visitor.visitGroupedTiered(groupedTiered) - tieredPackageWithMinimum != null -> - visitor.visitTieredPackageWithMinimum(tieredPackageWithMinimum) - packageWithAllocation != null -> - visitor.visitPackageWithAllocation(packageWithAllocation) - unitWithPercent != null -> visitor.visitUnitWithPercent(unitWithPercent) - matrixWithAllocation != null -> - visitor.visitMatrixWithAllocation(matrixWithAllocation) - tieredWithProration != null -> - visitor.visitTieredWithProration(tieredWithProration) - unitWithProration != null -> visitor.visitUnitWithProration(unitWithProration) - groupedAllocation != null -> visitor.visitGroupedAllocation(groupedAllocation) - bulkWithProration != null -> visitor.visitBulkWithProration(bulkWithProration) - groupedWithProratedMinimum != null -> - visitor.visitGroupedWithProratedMinimum(groupedWithProratedMinimum) - groupedWithMeteredMinimum != null -> - visitor.visitGroupedWithMeteredMinimum(groupedWithMeteredMinimum) - groupedWithMinMaxThresholds != null -> - visitor.visitGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds) - matrixWithDisplayName != null -> - visitor.visitMatrixWithDisplayName(matrixWithDisplayName) - groupedTieredPackage != null -> - visitor.visitGroupedTieredPackage(groupedTieredPackage) - maxGroupTieredPackage != null -> - visitor.visitMaxGroupTieredPackage(maxGroupTieredPackage) - scalableMatrixWithUnitPricing != null -> - visitor.visitScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing) - scalableMatrixWithTieredPricing != null -> - visitor.visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing - ) - cumulativeGroupedBulk != null -> - visitor.visitCumulativeGroupedBulk(cumulativeGroupedBulk) + percentageDiscount != null -> + visitor.visitPercentageDiscount(percentageDiscount) + usageDiscount != null -> visitor.visitUsageDiscount(usageDiscount) + amountDiscount != null -> visitor.visitAmountDiscount(amountDiscount) minimum != null -> visitor.visitMinimum(minimum) - percent != null -> visitor.visitPercent(percent) - eventOutput != null -> visitor.visitEventOutput(eventOutput) + maximum != null -> visitor.visitMaximum(maximum) else -> visitor.unknown(_json) } private var validated: Boolean = false - fun validate(): Price = apply { + fun validate(): Adjustment = apply { if (validated) { return@apply } accept( object : Visitor { - override fun visitUnit(unit: NewPlanUnitPrice) { - unit.validate() - } - - override fun visitTiered(tiered: NewPlanTieredPrice) { - tiered.validate() + override fun visitPercentageDiscount( + percentageDiscount: NewPercentageDiscount + ) { + percentageDiscount.validate() } - override fun visitBulk(bulk: NewPlanBulkPrice) { - bulk.validate() + override fun visitUsageDiscount(usageDiscount: NewUsageDiscount) { + usageDiscount.validate() } - override fun visitBulkWithFilters(bulkWithFilters: BulkWithFilters) { - bulkWithFilters.validate() + override fun visitAmountDiscount(amountDiscount: NewAmountDiscount) { + amountDiscount.validate() } - override fun visitPackage(package_: NewPlanPackagePrice) { - package_.validate() + override fun visitMinimum(minimum: NewMinimum) { + minimum.validate() } - override fun visitMatrix(matrix: NewPlanMatrixPrice) { - matrix.validate() + override fun visitMaximum(maximum: NewMaximum) { + maximum.validate() } + } + ) + validated = true + } - override fun visitThresholdTotalAmount( - thresholdTotalAmount: NewPlanThresholdTotalAmountPrice - ) { - thresholdTotalAmount.validate() - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - override fun visitTieredPackage(tieredPackage: NewPlanTieredPackagePrice) { - tieredPackage.validate() - } + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitPercentageDiscount( + percentageDiscount: NewPercentageDiscount + ) = percentageDiscount.validity() - override fun visitTieredWithMinimum( - tieredWithMinimum: NewPlanTieredWithMinimumPrice - ) { - tieredWithMinimum.validate() - } + override fun visitUsageDiscount(usageDiscount: NewUsageDiscount) = + usageDiscount.validity() - override fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) { - groupedTiered.validate() - } + override fun visitAmountDiscount(amountDiscount: NewAmountDiscount) = + amountDiscount.validity() - override fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice - ) { - tieredPackageWithMinimum.validate() - } + override fun visitMinimum(minimum: NewMinimum) = minimum.validity() - override fun visitPackageWithAllocation( - packageWithAllocation: NewPlanPackageWithAllocationPrice - ) { - packageWithAllocation.validate() - } + override fun visitMaximum(maximum: NewMaximum) = maximum.validity() - override fun visitUnitWithPercent( - unitWithPercent: NewPlanUnitWithPercentPrice - ) { - unitWithPercent.validate() - } + override fun unknown(json: JsonValue?) = 0 + } + ) - override fun visitMatrixWithAllocation( - matrixWithAllocation: NewPlanMatrixWithAllocationPrice - ) { - matrixWithAllocation.validate() - } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - override fun visitTieredWithProration( - tieredWithProration: TieredWithProration - ) { - tieredWithProration.validate() - } - - override fun visitUnitWithProration( - unitWithProration: NewPlanUnitWithProrationPrice - ) { - unitWithProration.validate() - } - - override fun visitGroupedAllocation( - groupedAllocation: NewPlanGroupedAllocationPrice - ) { - groupedAllocation.validate() - } - - override fun visitBulkWithProration( - bulkWithProration: NewPlanBulkWithProrationPrice - ) { - bulkWithProration.validate() - } - - override fun visitGroupedWithProratedMinimum( - groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice - ) { - groupedWithProratedMinimum.validate() - } - - override fun visitGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice - ) { - groupedWithMeteredMinimum.validate() - } - - override fun visitGroupedWithMinMaxThresholds( - groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds - ) { - groupedWithMinMaxThresholds.validate() - } - - override fun visitMatrixWithDisplayName( - matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice - ) { - matrixWithDisplayName.validate() - } + return other is Adjustment && + percentageDiscount == other.percentageDiscount && + usageDiscount == other.usageDiscount && + amountDiscount == other.amountDiscount && + minimum == other.minimum && + maximum == other.maximum + } - override fun visitGroupedTieredPackage( - groupedTieredPackage: NewPlanGroupedTieredPackagePrice - ) { - groupedTieredPackage.validate() - } + override fun hashCode(): Int = + Objects.hash(percentageDiscount, usageDiscount, amountDiscount, minimum, maximum) - override fun visitMaxGroupTieredPackage( - maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice - ) { - maxGroupTieredPackage.validate() - } + override fun toString(): String = + when { + percentageDiscount != null -> + "Adjustment{percentageDiscount=$percentageDiscount}" + usageDiscount != null -> "Adjustment{usageDiscount=$usageDiscount}" + amountDiscount != null -> "Adjustment{amountDiscount=$amountDiscount}" + minimum != null -> "Adjustment{minimum=$minimum}" + maximum != null -> "Adjustment{maximum=$maximum}" + _json != null -> "Adjustment{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Adjustment") + } - override fun visitScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice - ) { - scalableMatrixWithUnitPricing.validate() - } + companion object { - override fun visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: - NewPlanScalableMatrixWithTieredPricingPrice - ) { - scalableMatrixWithTieredPricing.validate() - } + fun ofPercentageDiscount(percentageDiscount: NewPercentageDiscount) = + Adjustment(percentageDiscount = percentageDiscount) - override fun visitCumulativeGroupedBulk( - cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice - ) { - cumulativeGroupedBulk.validate() - } + fun ofUsageDiscount(usageDiscount: NewUsageDiscount) = + Adjustment(usageDiscount = usageDiscount) - override fun visitMinimum(minimum: NewPlanMinimumCompositePrice) { - minimum.validate() - } + fun ofAmountDiscount(amountDiscount: NewAmountDiscount) = + Adjustment(amountDiscount = amountDiscount) - override fun visitPercent(percent: Percent) { - percent.validate() - } + fun ofMinimum(minimum: NewMinimum) = Adjustment(minimum = minimum) - override fun visitEventOutput(eventOutput: EventOutput) { - eventOutput.validate() - } - } - ) - validated = true + fun ofMaximum(maximum: NewMaximum) = Adjustment(maximum = maximum) } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. + * An interface that defines how to map each variant of [Adjustment] to a value of type + * [T]. */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: NewPlanUnitPrice) = unit.validity() + interface Visitor { - override fun visitTiered(tiered: NewPlanTieredPrice) = tiered.validity() + fun visitPercentageDiscount(percentageDiscount: NewPercentageDiscount): T - override fun visitBulk(bulk: NewPlanBulkPrice) = bulk.validity() + fun visitUsageDiscount(usageDiscount: NewUsageDiscount): T - override fun visitBulkWithFilters(bulkWithFilters: BulkWithFilters) = - bulkWithFilters.validity() + fun visitAmountDiscount(amountDiscount: NewAmountDiscount): T - override fun visitPackage(package_: NewPlanPackagePrice) = - package_.validity() + fun visitMinimum(minimum: NewMinimum): T - override fun visitMatrix(matrix: NewPlanMatrixPrice) = matrix.validity() + fun visitMaximum(maximum: NewMaximum): T - override fun visitThresholdTotalAmount( - thresholdTotalAmount: NewPlanThresholdTotalAmountPrice - ) = thresholdTotalAmount.validity() + /** + * Maps an unknown variant of [Adjustment] to a value of type [T]. + * + * An instance of [Adjustment] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the + * SDK is unaware of. + * + * @throws OrbInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw OrbInvalidDataException("Unknown Adjustment: $json") + } + } - override fun visitTieredPackage(tieredPackage: NewPlanTieredPackagePrice) = - tieredPackage.validity() + internal class Deserializer : BaseDeserializer(Adjustment::class) { - override fun visitTieredWithMinimum( - tieredWithMinimum: NewPlanTieredWithMinimumPrice - ) = tieredWithMinimum.validity() + override fun ObjectCodec.deserialize(node: JsonNode): Adjustment { + val json = JsonValue.fromJsonNode(node) + val adjustmentType = json.asObject()?.get("adjustment_type")?.asString() - override fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) = - groupedTiered.validity() + when (adjustmentType) { + "percentage_discount" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Adjustment(percentageDiscount = it, _json = json) } + ?: Adjustment(_json = json) + } + "usage_discount" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(usageDiscount = it, _json = json) + } ?: Adjustment(_json = json) + } + "amount_discount" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(amountDiscount = it, _json = json) + } ?: Adjustment(_json = json) + } + "minimum" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(minimum = it, _json = json) + } ?: Adjustment(_json = json) + } + "maximum" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(maximum = it, _json = json) + } ?: Adjustment(_json = json) + } + } - override fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice - ) = tieredPackageWithMinimum.validity() + return Adjustment(_json = json) + } + } - override fun visitPackageWithAllocation( - packageWithAllocation: NewPlanPackageWithAllocationPrice - ) = packageWithAllocation.validity() + internal class Serializer : BaseSerializer(Adjustment::class) { - override fun visitUnitWithPercent( - unitWithPercent: NewPlanUnitWithPercentPrice - ) = unitWithPercent.validity() + override fun serialize( + value: Adjustment, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.percentageDiscount != null -> + generator.writeObject(value.percentageDiscount) + value.usageDiscount != null -> generator.writeObject(value.usageDiscount) + value.amountDiscount != null -> generator.writeObject(value.amountDiscount) + value.minimum != null -> generator.writeObject(value.minimum) + value.maximum != null -> generator.writeObject(value.maximum) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Adjustment") + } + } + } + } - override fun visitMatrixWithAllocation( - matrixWithAllocation: NewPlanMatrixWithAllocationPrice - ) = matrixWithAllocation.validity() + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - override fun visitTieredWithProration( - tieredWithProration: TieredWithProration - ) = tieredWithProration.validity() + return other is ReplaceAdjustment && + adjustment == other.adjustment && + replacesAdjustmentId == other.replacesAdjustmentId && + planPhaseOrder == other.planPhaseOrder && + additionalProperties == other.additionalProperties + } - override fun visitUnitWithProration( - unitWithProration: NewPlanUnitWithProrationPrice - ) = unitWithProration.validity() + private val hashCode: Int by lazy { + Objects.hash(adjustment, replacesAdjustmentId, planPhaseOrder, additionalProperties) + } - override fun visitGroupedAllocation( - groupedAllocation: NewPlanGroupedAllocationPrice - ) = groupedAllocation.validity() + override fun hashCode(): Int = hashCode - override fun visitBulkWithProration( - bulkWithProration: NewPlanBulkWithProrationPrice - ) = bulkWithProration.validity() + override fun toString() = + "ReplaceAdjustment{adjustment=$adjustment, replacesAdjustmentId=$replacesAdjustmentId, planPhaseOrder=$planPhaseOrder, additionalProperties=$additionalProperties}" + } - override fun visitGroupedWithProratedMinimum( - groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice - ) = groupedWithProratedMinimum.validity() + class ReplacePrice + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val replacesPriceId: JsonField, + private val allocationPrice: JsonField, + private val planPhaseOrder: JsonField, + private val price: JsonField, + private val additionalProperties: MutableMap, + ) { - override fun visitGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice - ) = groupedWithMeteredMinimum.validity() + @JsonCreator + private constructor( + @JsonProperty("replaces_price_id") + @ExcludeMissing + replacesPriceId: JsonField = JsonMissing.of(), + @JsonProperty("allocation_price") + @ExcludeMissing + allocationPrice: JsonField = JsonMissing.of(), + @JsonProperty("plan_phase_order") + @ExcludeMissing + planPhaseOrder: JsonField = JsonMissing.of(), + @JsonProperty("price") @ExcludeMissing price: JsonField = JsonMissing.of(), + ) : this(replacesPriceId, allocationPrice, planPhaseOrder, price, mutableMapOf()) - override fun visitGroupedWithMinMaxThresholds( - groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds - ) = groupedWithMinMaxThresholds.validity() + /** + * The id of the price on the plan to replace in the plan. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun replacesPriceId(): String = replacesPriceId.getRequired("replaces_price_id") - override fun visitMatrixWithDisplayName( - matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice - ) = matrixWithDisplayName.validity() + /** + * The allocation price to add to the plan. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun allocationPrice(): NewAllocationPrice? = allocationPrice.getNullable("allocation_price") - override fun visitGroupedTieredPackage( - groupedTieredPackage: NewPlanGroupedTieredPackagePrice - ) = groupedTieredPackage.validity() + /** + * The phase to replace this price from. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun planPhaseOrder(): Long? = planPhaseOrder.getNullable("plan_phase_order") - override fun visitMaxGroupTieredPackage( - maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice - ) = maxGroupTieredPackage.validity() + /** + * New plan price request body params. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun price(): Price? = price.getNullable("price") - override fun visitScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice - ) = scalableMatrixWithUnitPricing.validity() + /** + * Returns the raw JSON value of [replacesPriceId]. + * + * Unlike [replacesPriceId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("replaces_price_id") + @ExcludeMissing + fun _replacesPriceId(): JsonField = replacesPriceId - override fun visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: - NewPlanScalableMatrixWithTieredPricingPrice - ) = scalableMatrixWithTieredPricing.validity() + /** + * Returns the raw JSON value of [allocationPrice]. + * + * Unlike [allocationPrice], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("allocation_price") + @ExcludeMissing + fun _allocationPrice(): JsonField = allocationPrice - override fun visitCumulativeGroupedBulk( - cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice - ) = cumulativeGroupedBulk.validity() + /** + * Returns the raw JSON value of [planPhaseOrder]. + * + * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder - override fun visitMinimum(minimum: NewPlanMinimumCompositePrice) = - minimum.validity() + /** + * Returns the raw JSON value of [price]. + * + * Unlike [price], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("price") @ExcludeMissing fun _price(): JsonField = price - override fun visitPercent(percent: Percent) = percent.validity() + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - override fun visitEventOutput(eventOutput: EventOutput) = - eventOutput.validity() + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - override fun unknown(json: JsonValue?) = 0 - } - ) + fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + companion object { - return other is Price && - unit == other.unit && - tiered == other.tiered && - bulk == other.bulk && - bulkWithFilters == other.bulkWithFilters && - package_ == other.package_ && - matrix == other.matrix && - thresholdTotalAmount == other.thresholdTotalAmount && - tieredPackage == other.tieredPackage && - tieredWithMinimum == other.tieredWithMinimum && - groupedTiered == other.groupedTiered && - tieredPackageWithMinimum == other.tieredPackageWithMinimum && - packageWithAllocation == other.packageWithAllocation && - unitWithPercent == other.unitWithPercent && - matrixWithAllocation == other.matrixWithAllocation && - tieredWithProration == other.tieredWithProration && - unitWithProration == other.unitWithProration && - groupedAllocation == other.groupedAllocation && - bulkWithProration == other.bulkWithProration && - groupedWithProratedMinimum == other.groupedWithProratedMinimum && - groupedWithMeteredMinimum == other.groupedWithMeteredMinimum && - groupedWithMinMaxThresholds == other.groupedWithMinMaxThresholds && - matrixWithDisplayName == other.matrixWithDisplayName && - groupedTieredPackage == other.groupedTieredPackage && - maxGroupTieredPackage == other.maxGroupTieredPackage && - scalableMatrixWithUnitPricing == other.scalableMatrixWithUnitPricing && - scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && - cumulativeGroupedBulk == other.cumulativeGroupedBulk && - minimum == other.minimum && - percent == other.percent && - eventOutput == other.eventOutput + /** + * Returns a mutable builder for constructing an instance of [ReplacePrice]. + * + * The following fields are required: + * ```kotlin + * .replacesPriceId() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [ReplacePrice]. */ + class Builder internal constructor() { + + private var replacesPriceId: JsonField? = null + private var allocationPrice: JsonField = JsonMissing.of() + private var planPhaseOrder: JsonField = JsonMissing.of() + private var price: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(replacePrice: ReplacePrice) = apply { + replacesPriceId = replacePrice.replacesPriceId + allocationPrice = replacePrice.allocationPrice + planPhaseOrder = replacePrice.planPhaseOrder + price = replacePrice.price + additionalProperties = replacePrice.additionalProperties.toMutableMap() } - override fun hashCode(): Int = - Objects.hash( - unit, - tiered, - bulk, - bulkWithFilters, - package_, - matrix, - thresholdTotalAmount, - tieredPackage, - tieredWithMinimum, - groupedTiered, - tieredPackageWithMinimum, - packageWithAllocation, - unitWithPercent, - matrixWithAllocation, - tieredWithProration, - unitWithProration, - groupedAllocation, - bulkWithProration, - groupedWithProratedMinimum, - groupedWithMeteredMinimum, - groupedWithMinMaxThresholds, - matrixWithDisplayName, - groupedTieredPackage, - maxGroupTieredPackage, - scalableMatrixWithUnitPricing, - scalableMatrixWithTieredPricing, - cumulativeGroupedBulk, - minimum, - percent, - eventOutput, - ) + /** The id of the price on the plan to replace in the plan. */ + fun replacesPriceId(replacesPriceId: String) = + replacesPriceId(JsonField.of(replacesPriceId)) - override fun toString(): String = - when { - unit != null -> "Price{unit=$unit}" - tiered != null -> "Price{tiered=$tiered}" - bulk != null -> "Price{bulk=$bulk}" - bulkWithFilters != null -> "Price{bulkWithFilters=$bulkWithFilters}" - package_ != null -> "Price{package_=$package_}" - matrix != null -> "Price{matrix=$matrix}" - thresholdTotalAmount != null -> - "Price{thresholdTotalAmount=$thresholdTotalAmount}" - tieredPackage != null -> "Price{tieredPackage=$tieredPackage}" - tieredWithMinimum != null -> "Price{tieredWithMinimum=$tieredWithMinimum}" - groupedTiered != null -> "Price{groupedTiered=$groupedTiered}" - tieredPackageWithMinimum != null -> - "Price{tieredPackageWithMinimum=$tieredPackageWithMinimum}" - packageWithAllocation != null -> - "Price{packageWithAllocation=$packageWithAllocation}" - unitWithPercent != null -> "Price{unitWithPercent=$unitWithPercent}" - matrixWithAllocation != null -> - "Price{matrixWithAllocation=$matrixWithAllocation}" - tieredWithProration != null -> "Price{tieredWithProration=$tieredWithProration}" - unitWithProration != null -> "Price{unitWithProration=$unitWithProration}" - groupedAllocation != null -> "Price{groupedAllocation=$groupedAllocation}" - bulkWithProration != null -> "Price{bulkWithProration=$bulkWithProration}" - groupedWithProratedMinimum != null -> - "Price{groupedWithProratedMinimum=$groupedWithProratedMinimum}" - groupedWithMeteredMinimum != null -> - "Price{groupedWithMeteredMinimum=$groupedWithMeteredMinimum}" - groupedWithMinMaxThresholds != null -> - "Price{groupedWithMinMaxThresholds=$groupedWithMinMaxThresholds}" - matrixWithDisplayName != null -> - "Price{matrixWithDisplayName=$matrixWithDisplayName}" - groupedTieredPackage != null -> - "Price{groupedTieredPackage=$groupedTieredPackage}" - maxGroupTieredPackage != null -> - "Price{maxGroupTieredPackage=$maxGroupTieredPackage}" - scalableMatrixWithUnitPricing != null -> - "Price{scalableMatrixWithUnitPricing=$scalableMatrixWithUnitPricing}" - scalableMatrixWithTieredPricing != null -> - "Price{scalableMatrixWithTieredPricing=$scalableMatrixWithTieredPricing}" - cumulativeGroupedBulk != null -> - "Price{cumulativeGroupedBulk=$cumulativeGroupedBulk}" - minimum != null -> "Price{minimum=$minimum}" - percent != null -> "Price{percent=$percent}" - eventOutput != null -> "Price{eventOutput=$eventOutput}" - _json != null -> "Price{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Price") - } - - companion object { + /** + * Sets [Builder.replacesPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.replacesPriceId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun replacesPriceId(replacesPriceId: JsonField) = apply { + this.replacesPriceId = replacesPriceId + } - fun ofUnit(unit: NewPlanUnitPrice) = Price(unit = unit) + /** The allocation price to add to the plan. */ + fun allocationPrice(allocationPrice: NewAllocationPrice?) = + allocationPrice(JsonField.ofNullable(allocationPrice)) - fun ofTiered(tiered: NewPlanTieredPrice) = Price(tiered = tiered) + /** + * Sets [Builder.allocationPrice] to an arbitrary JSON value. + * + * You should usually call [Builder.allocationPrice] with a well-typed + * [NewAllocationPrice] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun allocationPrice(allocationPrice: JsonField) = apply { + this.allocationPrice = allocationPrice + } - fun ofBulk(bulk: NewPlanBulkPrice) = Price(bulk = bulk) + /** The phase to replace this price from. */ + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) - fun ofBulkWithFilters(bulkWithFilters: BulkWithFilters) = - Price(bulkWithFilters = bulkWithFilters) + /** + * Alias for [Builder.planPhaseOrder]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) - fun ofPackage(package_: NewPlanPackagePrice) = Price(package_ = package_) + /** + * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. + * + * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun planPhaseOrder(planPhaseOrder: JsonField) = apply { + this.planPhaseOrder = planPhaseOrder + } - fun ofMatrix(matrix: NewPlanMatrixPrice) = Price(matrix = matrix) + /** New plan price request body params. */ + fun price(price: Price?) = price(JsonField.ofNullable(price)) - fun ofThresholdTotalAmount(thresholdTotalAmount: NewPlanThresholdTotalAmountPrice) = - Price(thresholdTotalAmount = thresholdTotalAmount) + /** + * Sets [Builder.price] to an arbitrary JSON value. + * + * You should usually call [Builder.price] with a well-typed [Price] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun price(price: JsonField) = apply { this.price = price } - fun ofTieredPackage(tieredPackage: NewPlanTieredPackagePrice) = - Price(tieredPackage = tieredPackage) + /** Alias for calling [price] with `Price.ofUnit(unit)`. */ + fun price(unit: NewPlanUnitPrice) = price(Price.ofUnit(unit)) - fun ofTieredWithMinimum(tieredWithMinimum: NewPlanTieredWithMinimumPrice) = - Price(tieredWithMinimum = tieredWithMinimum) + /** Alias for calling [price] with `Price.ofTiered(tiered)`. */ + fun price(tiered: NewPlanTieredPrice) = price(Price.ofTiered(tiered)) - fun ofGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) = - Price(groupedTiered = groupedTiered) + /** Alias for calling [price] with `Price.ofBulk(bulk)`. */ + fun price(bulk: NewPlanBulkPrice) = price(Price.ofBulk(bulk)) - fun ofTieredPackageWithMinimum( - tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice - ) = Price(tieredPackageWithMinimum = tieredPackageWithMinimum) + /** Alias for calling [price] with `Price.ofBulkWithFilters(bulkWithFilters)`. */ + fun price(bulkWithFilters: Price.BulkWithFilters) = + price(Price.ofBulkWithFilters(bulkWithFilters)) - fun ofPackageWithAllocation( - packageWithAllocation: NewPlanPackageWithAllocationPrice - ) = Price(packageWithAllocation = packageWithAllocation) + /** Alias for calling [price] with `Price.ofPackage(package_)`. */ + fun price(package_: NewPlanPackagePrice) = price(Price.ofPackage(package_)) - fun ofUnitWithPercent(unitWithPercent: NewPlanUnitWithPercentPrice) = - Price(unitWithPercent = unitWithPercent) + /** Alias for calling [price] with `Price.ofMatrix(matrix)`. */ + fun price(matrix: NewPlanMatrixPrice) = price(Price.ofMatrix(matrix)) - fun ofMatrixWithAllocation(matrixWithAllocation: NewPlanMatrixWithAllocationPrice) = - Price(matrixWithAllocation = matrixWithAllocation) + /** + * Alias for calling [price] with `Price.ofThresholdTotalAmount(thresholdTotalAmount)`. + */ + fun price(thresholdTotalAmount: NewPlanThresholdTotalAmountPrice) = + price(Price.ofThresholdTotalAmount(thresholdTotalAmount)) - fun ofTieredWithProration(tieredWithProration: TieredWithProration) = - Price(tieredWithProration = tieredWithProration) + /** Alias for calling [price] with `Price.ofTieredPackage(tieredPackage)`. */ + fun price(tieredPackage: NewPlanTieredPackagePrice) = + price(Price.ofTieredPackage(tieredPackage)) - fun ofUnitWithProration(unitWithProration: NewPlanUnitWithProrationPrice) = - Price(unitWithProration = unitWithProration) + /** Alias for calling [price] with `Price.ofTieredWithMinimum(tieredWithMinimum)`. */ + fun price(tieredWithMinimum: NewPlanTieredWithMinimumPrice) = + price(Price.ofTieredWithMinimum(tieredWithMinimum)) - fun ofGroupedAllocation(groupedAllocation: NewPlanGroupedAllocationPrice) = - Price(groupedAllocation = groupedAllocation) + /** Alias for calling [price] with `Price.ofGroupedTiered(groupedTiered)`. */ + fun price(groupedTiered: NewPlanGroupedTieredPrice) = + price(Price.ofGroupedTiered(groupedTiered)) - fun ofBulkWithProration(bulkWithProration: NewPlanBulkWithProrationPrice) = - Price(bulkWithProration = bulkWithProration) + /** + * Alias for calling [price] with + * `Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)`. + */ + fun price(tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice) = + price(Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)) - fun ofGroupedWithProratedMinimum( - groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice - ) = Price(groupedWithProratedMinimum = groupedWithProratedMinimum) + /** + * Alias for calling [price] with + * `Price.ofPackageWithAllocation(packageWithAllocation)`. + */ + fun price(packageWithAllocation: NewPlanPackageWithAllocationPrice) = + price(Price.ofPackageWithAllocation(packageWithAllocation)) - fun ofGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice - ) = Price(groupedWithMeteredMinimum = groupedWithMeteredMinimum) + /** Alias for calling [price] with `Price.ofUnitWithPercent(unitWithPercent)`. */ + fun price(unitWithPercent: NewPlanUnitWithPercentPrice) = + price(Price.ofUnitWithPercent(unitWithPercent)) - fun ofGroupedWithMinMaxThresholds( - groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds - ) = Price(groupedWithMinMaxThresholds = groupedWithMinMaxThresholds) + /** + * Alias for calling [price] with `Price.ofMatrixWithAllocation(matrixWithAllocation)`. + */ + fun price(matrixWithAllocation: NewPlanMatrixWithAllocationPrice) = + price(Price.ofMatrixWithAllocation(matrixWithAllocation)) - fun ofMatrixWithDisplayName( - matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice - ) = Price(matrixWithDisplayName = matrixWithDisplayName) + /** + * Alias for calling [price] with `Price.ofTieredWithProration(tieredWithProration)`. + */ + fun price(tieredWithProration: Price.TieredWithProration) = + price(Price.ofTieredWithProration(tieredWithProration)) - fun ofGroupedTieredPackage(groupedTieredPackage: NewPlanGroupedTieredPackagePrice) = - Price(groupedTieredPackage = groupedTieredPackage) + /** Alias for calling [price] with `Price.ofUnitWithProration(unitWithProration)`. */ + fun price(unitWithProration: NewPlanUnitWithProrationPrice) = + price(Price.ofUnitWithProration(unitWithProration)) - fun ofMaxGroupTieredPackage( - maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice - ) = Price(maxGroupTieredPackage = maxGroupTieredPackage) + /** Alias for calling [price] with `Price.ofGroupedAllocation(groupedAllocation)`. */ + fun price(groupedAllocation: NewPlanGroupedAllocationPrice) = + price(Price.ofGroupedAllocation(groupedAllocation)) - fun ofScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice - ) = Price(scalableMatrixWithUnitPricing = scalableMatrixWithUnitPricing) + /** Alias for calling [price] with `Price.ofBulkWithProration(bulkWithProration)`. */ + fun price(bulkWithProration: NewPlanBulkWithProrationPrice) = + price(Price.ofBulkWithProration(bulkWithProration)) - fun ofScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: NewPlanScalableMatrixWithTieredPricingPrice - ) = Price(scalableMatrixWithTieredPricing = scalableMatrixWithTieredPricing) + /** + * Alias for calling [price] with + * `Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)`. + */ + fun price(groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice) = + price(Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)) - fun ofCumulativeGroupedBulk( - cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice - ) = Price(cumulativeGroupedBulk = cumulativeGroupedBulk) + /** + * Alias for calling [price] with + * `Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)`. + */ + fun price(groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice) = + price(Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)) - fun ofMinimum(minimum: NewPlanMinimumCompositePrice) = Price(minimum = minimum) + /** + * Alias for calling [price] with + * `Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)`. + */ + fun price(groupedWithMinMaxThresholds: Price.GroupedWithMinMaxThresholds) = + price(Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)) - fun ofPercent(percent: Percent) = Price(percent = percent) + /** + * Alias for calling [price] with + * `Price.ofMatrixWithDisplayName(matrixWithDisplayName)`. + */ + fun price(matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice) = + price(Price.ofMatrixWithDisplayName(matrixWithDisplayName)) - fun ofEventOutput(eventOutput: EventOutput) = Price(eventOutput = eventOutput) - } + /** + * Alias for calling [price] with `Price.ofGroupedTieredPackage(groupedTieredPackage)`. + */ + fun price(groupedTieredPackage: NewPlanGroupedTieredPackagePrice) = + price(Price.ofGroupedTieredPackage(groupedTieredPackage)) /** - * An interface that defines how to map each variant of [Price] to a value of type [T]. + * Alias for calling [price] with + * `Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)`. */ - interface Visitor { + fun price(maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice) = + price(Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)) - fun visitUnit(unit: NewPlanUnitPrice): T + /** + * Alias for calling [price] with + * `Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)`. + */ + fun price(scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice) = + price(Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)) - fun visitTiered(tiered: NewPlanTieredPrice): T + /** + * Alias for calling [price] with + * `Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)`. + */ + fun price( + scalableMatrixWithTieredPricing: NewPlanScalableMatrixWithTieredPricingPrice + ) = price(Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)) - fun visitBulk(bulk: NewPlanBulkPrice): T + /** + * Alias for calling [price] with + * `Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)`. + */ + fun price(cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice) = + price(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) - fun visitBulkWithFilters(bulkWithFilters: BulkWithFilters): T + /** + * Alias for calling [price] with + * `Price.ofCumulativeGroupedAllocation(cumulativeGroupedAllocation)`. + */ + fun price(cumulativeGroupedAllocation: Price.CumulativeGroupedAllocation) = + price(Price.ofCumulativeGroupedAllocation(cumulativeGroupedAllocation)) - fun visitPackage(package_: NewPlanPackagePrice): T + /** Alias for calling [price] with `Price.ofMinimum(minimum)`. */ + fun price(minimum: NewPlanMinimumCompositePrice) = price(Price.ofMinimum(minimum)) - fun visitMatrix(matrix: NewPlanMatrixPrice): T + /** Alias for calling [price] with `Price.ofPercent(percent)`. */ + fun price(percent: Price.Percent) = price(Price.ofPercent(percent)) - fun visitThresholdTotalAmount( - thresholdTotalAmount: NewPlanThresholdTotalAmountPrice - ): T + /** Alias for calling [price] with `Price.ofEventOutput(eventOutput)`. */ + fun price(eventOutput: Price.EventOutput) = price(Price.ofEventOutput(eventOutput)) - fun visitTieredPackage(tieredPackage: NewPlanTieredPackagePrice): T + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun visitTieredWithMinimum(tieredWithMinimum: NewPlanTieredWithMinimumPrice): T + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice): T + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice - ): T + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - fun visitPackageWithAllocation( - packageWithAllocation: NewPlanPackageWithAllocationPrice - ): T + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - fun visitUnitWithPercent(unitWithPercent: NewPlanUnitWithPercentPrice): T + /** + * Returns an immutable instance of [ReplacePrice]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .replacesPriceId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ReplacePrice = + ReplacePrice( + checkRequired("replacesPriceId", replacesPriceId), + allocationPrice, + planPhaseOrder, + price, + additionalProperties.toMutableMap(), + ) + } - fun visitMatrixWithAllocation( - matrixWithAllocation: NewPlanMatrixWithAllocationPrice - ): T + private var validated: Boolean = false - fun visitTieredWithProration(tieredWithProration: TieredWithProration): T + fun validate(): ReplacePrice = apply { + if (validated) { + return@apply + } - fun visitUnitWithProration(unitWithProration: NewPlanUnitWithProrationPrice): T + replacesPriceId() + allocationPrice()?.validate() + planPhaseOrder() + price()?.validate() + validated = true + } - fun visitGroupedAllocation(groupedAllocation: NewPlanGroupedAllocationPrice): T + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - fun visitBulkWithProration(bulkWithProration: NewPlanBulkWithProrationPrice): T + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (replacesPriceId.asKnown() == null) 0 else 1) + + (allocationPrice.asKnown()?.validity() ?: 0) + + (if (planPhaseOrder.asKnown() == null) 0 else 1) + + (price.asKnown()?.validity() ?: 0) - fun visitGroupedWithProratedMinimum( - groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice - ): T + /** New plan price request body params. */ + @JsonDeserialize(using = Price.Deserializer::class) + @JsonSerialize(using = Price.Serializer::class) + class Price + private constructor( + private val unit: NewPlanUnitPrice? = null, + private val tiered: NewPlanTieredPrice? = null, + private val bulk: NewPlanBulkPrice? = null, + private val bulkWithFilters: BulkWithFilters? = null, + private val package_: NewPlanPackagePrice? = null, + private val matrix: NewPlanMatrixPrice? = null, + private val thresholdTotalAmount: NewPlanThresholdTotalAmountPrice? = null, + private val tieredPackage: NewPlanTieredPackagePrice? = null, + private val tieredWithMinimum: NewPlanTieredWithMinimumPrice? = null, + private val groupedTiered: NewPlanGroupedTieredPrice? = null, + private val tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice? = null, + private val packageWithAllocation: NewPlanPackageWithAllocationPrice? = null, + private val unitWithPercent: NewPlanUnitWithPercentPrice? = null, + private val matrixWithAllocation: NewPlanMatrixWithAllocationPrice? = null, + private val tieredWithProration: TieredWithProration? = null, + private val unitWithProration: NewPlanUnitWithProrationPrice? = null, + private val groupedAllocation: NewPlanGroupedAllocationPrice? = null, + private val bulkWithProration: NewPlanBulkWithProrationPrice? = null, + private val groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice? = null, + private val groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice? = null, + private val groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds? = null, + private val matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice? = null, + private val groupedTieredPackage: NewPlanGroupedTieredPackagePrice? = null, + private val maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice? = null, + private val scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice? = + null, + private val scalableMatrixWithTieredPricing: + NewPlanScalableMatrixWithTieredPricingPrice? = + null, + private val cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice? = null, + private val cumulativeGroupedAllocation: CumulativeGroupedAllocation? = null, + private val minimum: NewPlanMinimumCompositePrice? = null, + private val percent: Percent? = null, + private val eventOutput: EventOutput? = null, + private val _json: JsonValue? = null, + ) { - fun visitGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice - ): T + fun unit(): NewPlanUnitPrice? = unit - fun visitGroupedWithMinMaxThresholds( - groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds - ): T + fun tiered(): NewPlanTieredPrice? = tiered - fun visitMatrixWithDisplayName( - matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice - ): T + fun bulk(): NewPlanBulkPrice? = bulk - fun visitGroupedTieredPackage( - groupedTieredPackage: NewPlanGroupedTieredPackagePrice - ): T + fun bulkWithFilters(): BulkWithFilters? = bulkWithFilters - fun visitMaxGroupTieredPackage( - maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice - ): T + fun package_(): NewPlanPackagePrice? = package_ - fun visitScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice - ): T + fun matrix(): NewPlanMatrixPrice? = matrix - fun visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: NewPlanScalableMatrixWithTieredPricingPrice - ): T + fun thresholdTotalAmount(): NewPlanThresholdTotalAmountPrice? = thresholdTotalAmount - fun visitCumulativeGroupedBulk( - cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice - ): T + fun tieredPackage(): NewPlanTieredPackagePrice? = tieredPackage - fun visitMinimum(minimum: NewPlanMinimumCompositePrice): T + fun tieredWithMinimum(): NewPlanTieredWithMinimumPrice? = tieredWithMinimum - fun visitPercent(percent: Percent): T + fun groupedTiered(): NewPlanGroupedTieredPrice? = groupedTiered - fun visitEventOutput(eventOutput: EventOutput): T + fun tieredPackageWithMinimum(): NewPlanTieredPackageWithMinimumPrice? = + tieredPackageWithMinimum - /** - * Maps an unknown variant of [Price] to a value of type [T]. - * - * An instance of [Price] can contain an unknown variant if it was deserialized from - * data that doesn't match any known variant. For example, if the SDK is on an older - * version than the API, then the API may respond with new variants that the SDK is - * unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown Price: $json") - } - } + fun packageWithAllocation(): NewPlanPackageWithAllocationPrice? = packageWithAllocation - internal class Deserializer : BaseDeserializer(Price::class) { + fun unitWithPercent(): NewPlanUnitWithPercentPrice? = unitWithPercent - override fun ObjectCodec.deserialize(node: JsonNode): Price { - val json = JsonValue.fromJsonNode(node) - val modelType = json.asObject()?.get("model_type")?.asString() + fun matrixWithAllocation(): NewPlanMatrixWithAllocationPrice? = matrixWithAllocation - when (modelType) { - "unit" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(unit = it, _json = json) - } ?: Price(_json = json) - } - "tiered" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(tiered = it, _json = json) - } ?: Price(_json = json) - } - "bulk" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(bulk = it, _json = json) - } ?: Price(_json = json) - } - "bulk_with_filters" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(bulkWithFilters = it, _json = json) - } ?: Price(_json = json) - } - "package" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(package_ = it, _json = json) } ?: Price(_json = json) - } - "matrix" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(matrix = it, _json = json) - } ?: Price(_json = json) - } - "threshold_total_amount" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(thresholdTotalAmount = it, _json = json) } - ?: Price(_json = json) - } - "tiered_package" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(tieredPackage = it, _json = json) } - ?: Price(_json = json) - } - "tiered_with_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(tieredWithMinimum = it, _json = json) } - ?: Price(_json = json) - } - "grouped_tiered" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(groupedTiered = it, _json = json) } - ?: Price(_json = json) - } - "tiered_package_with_minimum" -> { + fun tieredWithProration(): TieredWithProration? = tieredWithProration + + fun unitWithProration(): NewPlanUnitWithProrationPrice? = unitWithProration + + fun groupedAllocation(): NewPlanGroupedAllocationPrice? = groupedAllocation + + fun bulkWithProration(): NewPlanBulkWithProrationPrice? = bulkWithProration + + fun groupedWithProratedMinimum(): NewPlanGroupedWithProratedMinimumPrice? = + groupedWithProratedMinimum + + fun groupedWithMeteredMinimum(): NewPlanGroupedWithMeteredMinimumPrice? = + groupedWithMeteredMinimum + + fun groupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds? = + groupedWithMinMaxThresholds + + fun matrixWithDisplayName(): NewPlanMatrixWithDisplayNamePrice? = matrixWithDisplayName + + fun groupedTieredPackage(): NewPlanGroupedTieredPackagePrice? = groupedTieredPackage + + fun maxGroupTieredPackage(): NewPlanMaxGroupTieredPackagePrice? = maxGroupTieredPackage + + fun scalableMatrixWithUnitPricing(): NewPlanScalableMatrixWithUnitPricingPrice? = + scalableMatrixWithUnitPricing + + fun scalableMatrixWithTieredPricing(): NewPlanScalableMatrixWithTieredPricingPrice? = + scalableMatrixWithTieredPricing + + fun cumulativeGroupedBulk(): NewPlanCumulativeGroupedBulkPrice? = cumulativeGroupedBulk + + fun cumulativeGroupedAllocation(): CumulativeGroupedAllocation? = + cumulativeGroupedAllocation + + fun minimum(): NewPlanMinimumCompositePrice? = minimum + + fun percent(): Percent? = percent + + fun eventOutput(): EventOutput? = eventOutput + + fun isUnit(): Boolean = unit != null + + fun isTiered(): Boolean = tiered != null + + fun isBulk(): Boolean = bulk != null + + fun isBulkWithFilters(): Boolean = bulkWithFilters != null + + fun isPackage(): Boolean = package_ != null + + fun isMatrix(): Boolean = matrix != null + + fun isThresholdTotalAmount(): Boolean = thresholdTotalAmount != null + + fun isTieredPackage(): Boolean = tieredPackage != null + + fun isTieredWithMinimum(): Boolean = tieredWithMinimum != null + + fun isGroupedTiered(): Boolean = groupedTiered != null + + fun isTieredPackageWithMinimum(): Boolean = tieredPackageWithMinimum != null + + fun isPackageWithAllocation(): Boolean = packageWithAllocation != null + + fun isUnitWithPercent(): Boolean = unitWithPercent != null + + fun isMatrixWithAllocation(): Boolean = matrixWithAllocation != null + + fun isTieredWithProration(): Boolean = tieredWithProration != null + + fun isUnitWithProration(): Boolean = unitWithProration != null + + fun isGroupedAllocation(): Boolean = groupedAllocation != null + + fun isBulkWithProration(): Boolean = bulkWithProration != null + + fun isGroupedWithProratedMinimum(): Boolean = groupedWithProratedMinimum != null + + fun isGroupedWithMeteredMinimum(): Boolean = groupedWithMeteredMinimum != null + + fun isGroupedWithMinMaxThresholds(): Boolean = groupedWithMinMaxThresholds != null + + fun isMatrixWithDisplayName(): Boolean = matrixWithDisplayName != null + + fun isGroupedTieredPackage(): Boolean = groupedTieredPackage != null + + fun isMaxGroupTieredPackage(): Boolean = maxGroupTieredPackage != null + + fun isScalableMatrixWithUnitPricing(): Boolean = scalableMatrixWithUnitPricing != null + + fun isScalableMatrixWithTieredPricing(): Boolean = + scalableMatrixWithTieredPricing != null + + fun isCumulativeGroupedBulk(): Boolean = cumulativeGroupedBulk != null + + fun isCumulativeGroupedAllocation(): Boolean = cumulativeGroupedAllocation != null + + fun isMinimum(): Boolean = minimum != null + + fun isPercent(): Boolean = percent != null + + fun isEventOutput(): Boolean = eventOutput != null + + fun asUnit(): NewPlanUnitPrice = unit.getOrThrow("unit") + + fun asTiered(): NewPlanTieredPrice = tiered.getOrThrow("tiered") + + fun asBulk(): NewPlanBulkPrice = bulk.getOrThrow("bulk") + + fun asBulkWithFilters(): BulkWithFilters = bulkWithFilters.getOrThrow("bulkWithFilters") + + fun asPackage(): NewPlanPackagePrice = package_.getOrThrow("package_") + + fun asMatrix(): NewPlanMatrixPrice = matrix.getOrThrow("matrix") + + fun asThresholdTotalAmount(): NewPlanThresholdTotalAmountPrice = + thresholdTotalAmount.getOrThrow("thresholdTotalAmount") + + fun asTieredPackage(): NewPlanTieredPackagePrice = + tieredPackage.getOrThrow("tieredPackage") + + fun asTieredWithMinimum(): NewPlanTieredWithMinimumPrice = + tieredWithMinimum.getOrThrow("tieredWithMinimum") + + fun asGroupedTiered(): NewPlanGroupedTieredPrice = + groupedTiered.getOrThrow("groupedTiered") + + fun asTieredPackageWithMinimum(): NewPlanTieredPackageWithMinimumPrice = + tieredPackageWithMinimum.getOrThrow("tieredPackageWithMinimum") + + fun asPackageWithAllocation(): NewPlanPackageWithAllocationPrice = + packageWithAllocation.getOrThrow("packageWithAllocation") + + fun asUnitWithPercent(): NewPlanUnitWithPercentPrice = + unitWithPercent.getOrThrow("unitWithPercent") + + fun asMatrixWithAllocation(): NewPlanMatrixWithAllocationPrice = + matrixWithAllocation.getOrThrow("matrixWithAllocation") + + fun asTieredWithProration(): TieredWithProration = + tieredWithProration.getOrThrow("tieredWithProration") + + fun asUnitWithProration(): NewPlanUnitWithProrationPrice = + unitWithProration.getOrThrow("unitWithProration") + + fun asGroupedAllocation(): NewPlanGroupedAllocationPrice = + groupedAllocation.getOrThrow("groupedAllocation") + + fun asBulkWithProration(): NewPlanBulkWithProrationPrice = + bulkWithProration.getOrThrow("bulkWithProration") + + fun asGroupedWithProratedMinimum(): NewPlanGroupedWithProratedMinimumPrice = + groupedWithProratedMinimum.getOrThrow("groupedWithProratedMinimum") + + fun asGroupedWithMeteredMinimum(): NewPlanGroupedWithMeteredMinimumPrice = + groupedWithMeteredMinimum.getOrThrow("groupedWithMeteredMinimum") + + fun asGroupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds = + groupedWithMinMaxThresholds.getOrThrow("groupedWithMinMaxThresholds") + + fun asMatrixWithDisplayName(): NewPlanMatrixWithDisplayNamePrice = + matrixWithDisplayName.getOrThrow("matrixWithDisplayName") + + fun asGroupedTieredPackage(): NewPlanGroupedTieredPackagePrice = + groupedTieredPackage.getOrThrow("groupedTieredPackage") + + fun asMaxGroupTieredPackage(): NewPlanMaxGroupTieredPackagePrice = + maxGroupTieredPackage.getOrThrow("maxGroupTieredPackage") + + fun asScalableMatrixWithUnitPricing(): NewPlanScalableMatrixWithUnitPricingPrice = + scalableMatrixWithUnitPricing.getOrThrow("scalableMatrixWithUnitPricing") + + fun asScalableMatrixWithTieredPricing(): NewPlanScalableMatrixWithTieredPricingPrice = + scalableMatrixWithTieredPricing.getOrThrow("scalableMatrixWithTieredPricing") + + fun asCumulativeGroupedBulk(): NewPlanCumulativeGroupedBulkPrice = + cumulativeGroupedBulk.getOrThrow("cumulativeGroupedBulk") + + fun asCumulativeGroupedAllocation(): CumulativeGroupedAllocation = + cumulativeGroupedAllocation.getOrThrow("cumulativeGroupedAllocation") + + fun asMinimum(): NewPlanMinimumCompositePrice = minimum.getOrThrow("minimum") + + fun asPercent(): Percent = percent.getOrThrow("percent") + + fun asEventOutput(): EventOutput = eventOutput.getOrThrow("eventOutput") + + fun _json(): JsonValue? = _json + + fun accept(visitor: Visitor): T = + when { + unit != null -> visitor.visitUnit(unit) + tiered != null -> visitor.visitTiered(tiered) + bulk != null -> visitor.visitBulk(bulk) + bulkWithFilters != null -> visitor.visitBulkWithFilters(bulkWithFilters) + package_ != null -> visitor.visitPackage(package_) + matrix != null -> visitor.visitMatrix(matrix) + thresholdTotalAmount != null -> + visitor.visitThresholdTotalAmount(thresholdTotalAmount) + tieredPackage != null -> visitor.visitTieredPackage(tieredPackage) + tieredWithMinimum != null -> visitor.visitTieredWithMinimum(tieredWithMinimum) + groupedTiered != null -> visitor.visitGroupedTiered(groupedTiered) + tieredPackageWithMinimum != null -> + visitor.visitTieredPackageWithMinimum(tieredPackageWithMinimum) + packageWithAllocation != null -> + visitor.visitPackageWithAllocation(packageWithAllocation) + unitWithPercent != null -> visitor.visitUnitWithPercent(unitWithPercent) + matrixWithAllocation != null -> + visitor.visitMatrixWithAllocation(matrixWithAllocation) + tieredWithProration != null -> + visitor.visitTieredWithProration(tieredWithProration) + unitWithProration != null -> visitor.visitUnitWithProration(unitWithProration) + groupedAllocation != null -> visitor.visitGroupedAllocation(groupedAllocation) + bulkWithProration != null -> visitor.visitBulkWithProration(bulkWithProration) + groupedWithProratedMinimum != null -> + visitor.visitGroupedWithProratedMinimum(groupedWithProratedMinimum) + groupedWithMeteredMinimum != null -> + visitor.visitGroupedWithMeteredMinimum(groupedWithMeteredMinimum) + groupedWithMinMaxThresholds != null -> + visitor.visitGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds) + matrixWithDisplayName != null -> + visitor.visitMatrixWithDisplayName(matrixWithDisplayName) + groupedTieredPackage != null -> + visitor.visitGroupedTieredPackage(groupedTieredPackage) + maxGroupTieredPackage != null -> + visitor.visitMaxGroupTieredPackage(maxGroupTieredPackage) + scalableMatrixWithUnitPricing != null -> + visitor.visitScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing) + scalableMatrixWithTieredPricing != null -> + visitor.visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing + ) + cumulativeGroupedBulk != null -> + visitor.visitCumulativeGroupedBulk(cumulativeGroupedBulk) + cumulativeGroupedAllocation != null -> + visitor.visitCumulativeGroupedAllocation(cumulativeGroupedAllocation) + minimum != null -> visitor.visitMinimum(minimum) + percent != null -> visitor.visitPercent(percent) + eventOutput != null -> visitor.visitEventOutput(eventOutput) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Price = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitUnit(unit: NewPlanUnitPrice) { + unit.validate() + } + + override fun visitTiered(tiered: NewPlanTieredPrice) { + tiered.validate() + } + + override fun visitBulk(bulk: NewPlanBulkPrice) { + bulk.validate() + } + + override fun visitBulkWithFilters(bulkWithFilters: BulkWithFilters) { + bulkWithFilters.validate() + } + + override fun visitPackage(package_: NewPlanPackagePrice) { + package_.validate() + } + + override fun visitMatrix(matrix: NewPlanMatrixPrice) { + matrix.validate() + } + + override fun visitThresholdTotalAmount( + thresholdTotalAmount: NewPlanThresholdTotalAmountPrice + ) { + thresholdTotalAmount.validate() + } + + override fun visitTieredPackage(tieredPackage: NewPlanTieredPackagePrice) { + tieredPackage.validate() + } + + override fun visitTieredWithMinimum( + tieredWithMinimum: NewPlanTieredWithMinimumPrice + ) { + tieredWithMinimum.validate() + } + + override fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) { + groupedTiered.validate() + } + + override fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice + ) { + tieredPackageWithMinimum.validate() + } + + override fun visitPackageWithAllocation( + packageWithAllocation: NewPlanPackageWithAllocationPrice + ) { + packageWithAllocation.validate() + } + + override fun visitUnitWithPercent( + unitWithPercent: NewPlanUnitWithPercentPrice + ) { + unitWithPercent.validate() + } + + override fun visitMatrixWithAllocation( + matrixWithAllocation: NewPlanMatrixWithAllocationPrice + ) { + matrixWithAllocation.validate() + } + + override fun visitTieredWithProration( + tieredWithProration: TieredWithProration + ) { + tieredWithProration.validate() + } + + override fun visitUnitWithProration( + unitWithProration: NewPlanUnitWithProrationPrice + ) { + unitWithProration.validate() + } + + override fun visitGroupedAllocation( + groupedAllocation: NewPlanGroupedAllocationPrice + ) { + groupedAllocation.validate() + } + + override fun visitBulkWithProration( + bulkWithProration: NewPlanBulkWithProrationPrice + ) { + bulkWithProration.validate() + } + + override fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice + ) { + groupedWithProratedMinimum.validate() + } + + override fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice + ) { + groupedWithMeteredMinimum.validate() + } + + override fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) { + groupedWithMinMaxThresholds.validate() + } + + override fun visitMatrixWithDisplayName( + matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice + ) { + matrixWithDisplayName.validate() + } + + override fun visitGroupedTieredPackage( + groupedTieredPackage: NewPlanGroupedTieredPackagePrice + ) { + groupedTieredPackage.validate() + } + + override fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice + ) { + maxGroupTieredPackage.validate() + } + + override fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice + ) { + scalableMatrixWithUnitPricing.validate() + } + + override fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: + NewPlanScalableMatrixWithTieredPricingPrice + ) { + scalableMatrixWithTieredPricing.validate() + } + + override fun visitCumulativeGroupedBulk( + cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice + ) { + cumulativeGroupedBulk.validate() + } + + override fun visitCumulativeGroupedAllocation( + cumulativeGroupedAllocation: CumulativeGroupedAllocation + ) { + cumulativeGroupedAllocation.validate() + } + + override fun visitMinimum(minimum: NewPlanMinimumCompositePrice) { + minimum.validate() + } + + override fun visitPercent(percent: Percent) { + percent.validate() + } + + override fun visitEventOutput(eventOutput: EventOutput) { + eventOutput.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitUnit(unit: NewPlanUnitPrice) = unit.validity() + + override fun visitTiered(tiered: NewPlanTieredPrice) = tiered.validity() + + override fun visitBulk(bulk: NewPlanBulkPrice) = bulk.validity() + + override fun visitBulkWithFilters(bulkWithFilters: BulkWithFilters) = + bulkWithFilters.validity() + + override fun visitPackage(package_: NewPlanPackagePrice) = + package_.validity() + + override fun visitMatrix(matrix: NewPlanMatrixPrice) = matrix.validity() + + override fun visitThresholdTotalAmount( + thresholdTotalAmount: NewPlanThresholdTotalAmountPrice + ) = thresholdTotalAmount.validity() + + override fun visitTieredPackage(tieredPackage: NewPlanTieredPackagePrice) = + tieredPackage.validity() + + override fun visitTieredWithMinimum( + tieredWithMinimum: NewPlanTieredWithMinimumPrice + ) = tieredWithMinimum.validity() + + override fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) = + groupedTiered.validity() + + override fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice + ) = tieredPackageWithMinimum.validity() + + override fun visitPackageWithAllocation( + packageWithAllocation: NewPlanPackageWithAllocationPrice + ) = packageWithAllocation.validity() + + override fun visitUnitWithPercent( + unitWithPercent: NewPlanUnitWithPercentPrice + ) = unitWithPercent.validity() + + override fun visitMatrixWithAllocation( + matrixWithAllocation: NewPlanMatrixWithAllocationPrice + ) = matrixWithAllocation.validity() + + override fun visitTieredWithProration( + tieredWithProration: TieredWithProration + ) = tieredWithProration.validity() + + override fun visitUnitWithProration( + unitWithProration: NewPlanUnitWithProrationPrice + ) = unitWithProration.validity() + + override fun visitGroupedAllocation( + groupedAllocation: NewPlanGroupedAllocationPrice + ) = groupedAllocation.validity() + + override fun visitBulkWithProration( + bulkWithProration: NewPlanBulkWithProrationPrice + ) = bulkWithProration.validity() + + override fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice + ) = groupedWithProratedMinimum.validity() + + override fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice + ) = groupedWithMeteredMinimum.validity() + + override fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) = groupedWithMinMaxThresholds.validity() + + override fun visitMatrixWithDisplayName( + matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice + ) = matrixWithDisplayName.validity() + + override fun visitGroupedTieredPackage( + groupedTieredPackage: NewPlanGroupedTieredPackagePrice + ) = groupedTieredPackage.validity() + + override fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice + ) = maxGroupTieredPackage.validity() + + override fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice + ) = scalableMatrixWithUnitPricing.validity() + + override fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: + NewPlanScalableMatrixWithTieredPricingPrice + ) = scalableMatrixWithTieredPricing.validity() + + override fun visitCumulativeGroupedBulk( + cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice + ) = cumulativeGroupedBulk.validity() + + override fun visitCumulativeGroupedAllocation( + cumulativeGroupedAllocation: CumulativeGroupedAllocation + ) = cumulativeGroupedAllocation.validity() + + override fun visitMinimum(minimum: NewPlanMinimumCompositePrice) = + minimum.validity() + + override fun visitPercent(percent: Percent) = percent.validity() + + override fun visitEventOutput(eventOutput: EventOutput) = + eventOutput.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Price && + unit == other.unit && + tiered == other.tiered && + bulk == other.bulk && + bulkWithFilters == other.bulkWithFilters && + package_ == other.package_ && + matrix == other.matrix && + thresholdTotalAmount == other.thresholdTotalAmount && + tieredPackage == other.tieredPackage && + tieredWithMinimum == other.tieredWithMinimum && + groupedTiered == other.groupedTiered && + tieredPackageWithMinimum == other.tieredPackageWithMinimum && + packageWithAllocation == other.packageWithAllocation && + unitWithPercent == other.unitWithPercent && + matrixWithAllocation == other.matrixWithAllocation && + tieredWithProration == other.tieredWithProration && + unitWithProration == other.unitWithProration && + groupedAllocation == other.groupedAllocation && + bulkWithProration == other.bulkWithProration && + groupedWithProratedMinimum == other.groupedWithProratedMinimum && + groupedWithMeteredMinimum == other.groupedWithMeteredMinimum && + groupedWithMinMaxThresholds == other.groupedWithMinMaxThresholds && + matrixWithDisplayName == other.matrixWithDisplayName && + groupedTieredPackage == other.groupedTieredPackage && + maxGroupTieredPackage == other.maxGroupTieredPackage && + scalableMatrixWithUnitPricing == other.scalableMatrixWithUnitPricing && + scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && + cumulativeGroupedBulk == other.cumulativeGroupedBulk && + cumulativeGroupedAllocation == other.cumulativeGroupedAllocation && + minimum == other.minimum && + percent == other.percent && + eventOutput == other.eventOutput + } + + override fun hashCode(): Int = + Objects.hash( + unit, + tiered, + bulk, + bulkWithFilters, + package_, + matrix, + thresholdTotalAmount, + tieredPackage, + tieredWithMinimum, + groupedTiered, + tieredPackageWithMinimum, + packageWithAllocation, + unitWithPercent, + matrixWithAllocation, + tieredWithProration, + unitWithProration, + groupedAllocation, + bulkWithProration, + groupedWithProratedMinimum, + groupedWithMeteredMinimum, + groupedWithMinMaxThresholds, + matrixWithDisplayName, + groupedTieredPackage, + maxGroupTieredPackage, + scalableMatrixWithUnitPricing, + scalableMatrixWithTieredPricing, + cumulativeGroupedBulk, + cumulativeGroupedAllocation, + minimum, + percent, + eventOutput, + ) + + override fun toString(): String = + when { + unit != null -> "Price{unit=$unit}" + tiered != null -> "Price{tiered=$tiered}" + bulk != null -> "Price{bulk=$bulk}" + bulkWithFilters != null -> "Price{bulkWithFilters=$bulkWithFilters}" + package_ != null -> "Price{package_=$package_}" + matrix != null -> "Price{matrix=$matrix}" + thresholdTotalAmount != null -> + "Price{thresholdTotalAmount=$thresholdTotalAmount}" + tieredPackage != null -> "Price{tieredPackage=$tieredPackage}" + tieredWithMinimum != null -> "Price{tieredWithMinimum=$tieredWithMinimum}" + groupedTiered != null -> "Price{groupedTiered=$groupedTiered}" + tieredPackageWithMinimum != null -> + "Price{tieredPackageWithMinimum=$tieredPackageWithMinimum}" + packageWithAllocation != null -> + "Price{packageWithAllocation=$packageWithAllocation}" + unitWithPercent != null -> "Price{unitWithPercent=$unitWithPercent}" + matrixWithAllocation != null -> + "Price{matrixWithAllocation=$matrixWithAllocation}" + tieredWithProration != null -> "Price{tieredWithProration=$tieredWithProration}" + unitWithProration != null -> "Price{unitWithProration=$unitWithProration}" + groupedAllocation != null -> "Price{groupedAllocation=$groupedAllocation}" + bulkWithProration != null -> "Price{bulkWithProration=$bulkWithProration}" + groupedWithProratedMinimum != null -> + "Price{groupedWithProratedMinimum=$groupedWithProratedMinimum}" + groupedWithMeteredMinimum != null -> + "Price{groupedWithMeteredMinimum=$groupedWithMeteredMinimum}" + groupedWithMinMaxThresholds != null -> + "Price{groupedWithMinMaxThresholds=$groupedWithMinMaxThresholds}" + matrixWithDisplayName != null -> + "Price{matrixWithDisplayName=$matrixWithDisplayName}" + groupedTieredPackage != null -> + "Price{groupedTieredPackage=$groupedTieredPackage}" + maxGroupTieredPackage != null -> + "Price{maxGroupTieredPackage=$maxGroupTieredPackage}" + scalableMatrixWithUnitPricing != null -> + "Price{scalableMatrixWithUnitPricing=$scalableMatrixWithUnitPricing}" + scalableMatrixWithTieredPricing != null -> + "Price{scalableMatrixWithTieredPricing=$scalableMatrixWithTieredPricing}" + cumulativeGroupedBulk != null -> + "Price{cumulativeGroupedBulk=$cumulativeGroupedBulk}" + cumulativeGroupedAllocation != null -> + "Price{cumulativeGroupedAllocation=$cumulativeGroupedAllocation}" + minimum != null -> "Price{minimum=$minimum}" + percent != null -> "Price{percent=$percent}" + eventOutput != null -> "Price{eventOutput=$eventOutput}" + _json != null -> "Price{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Price") + } + + companion object { + + fun ofUnit(unit: NewPlanUnitPrice) = Price(unit = unit) + + fun ofTiered(tiered: NewPlanTieredPrice) = Price(tiered = tiered) + + fun ofBulk(bulk: NewPlanBulkPrice) = Price(bulk = bulk) + + fun ofBulkWithFilters(bulkWithFilters: BulkWithFilters) = + Price(bulkWithFilters = bulkWithFilters) + + fun ofPackage(package_: NewPlanPackagePrice) = Price(package_ = package_) + + fun ofMatrix(matrix: NewPlanMatrixPrice) = Price(matrix = matrix) + + fun ofThresholdTotalAmount(thresholdTotalAmount: NewPlanThresholdTotalAmountPrice) = + Price(thresholdTotalAmount = thresholdTotalAmount) + + fun ofTieredPackage(tieredPackage: NewPlanTieredPackagePrice) = + Price(tieredPackage = tieredPackage) + + fun ofTieredWithMinimum(tieredWithMinimum: NewPlanTieredWithMinimumPrice) = + Price(tieredWithMinimum = tieredWithMinimum) + + fun ofGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) = + Price(groupedTiered = groupedTiered) + + fun ofTieredPackageWithMinimum( + tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice + ) = Price(tieredPackageWithMinimum = tieredPackageWithMinimum) + + fun ofPackageWithAllocation( + packageWithAllocation: NewPlanPackageWithAllocationPrice + ) = Price(packageWithAllocation = packageWithAllocation) + + fun ofUnitWithPercent(unitWithPercent: NewPlanUnitWithPercentPrice) = + Price(unitWithPercent = unitWithPercent) + + fun ofMatrixWithAllocation(matrixWithAllocation: NewPlanMatrixWithAllocationPrice) = + Price(matrixWithAllocation = matrixWithAllocation) + + fun ofTieredWithProration(tieredWithProration: TieredWithProration) = + Price(tieredWithProration = tieredWithProration) + + fun ofUnitWithProration(unitWithProration: NewPlanUnitWithProrationPrice) = + Price(unitWithProration = unitWithProration) + + fun ofGroupedAllocation(groupedAllocation: NewPlanGroupedAllocationPrice) = + Price(groupedAllocation = groupedAllocation) + + fun ofBulkWithProration(bulkWithProration: NewPlanBulkWithProrationPrice) = + Price(bulkWithProration = bulkWithProration) + + fun ofGroupedWithProratedMinimum( + groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice + ) = Price(groupedWithProratedMinimum = groupedWithProratedMinimum) + + fun ofGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice + ) = Price(groupedWithMeteredMinimum = groupedWithMeteredMinimum) + + fun ofGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) = Price(groupedWithMinMaxThresholds = groupedWithMinMaxThresholds) + + fun ofMatrixWithDisplayName( + matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice + ) = Price(matrixWithDisplayName = matrixWithDisplayName) + + fun ofGroupedTieredPackage(groupedTieredPackage: NewPlanGroupedTieredPackagePrice) = + Price(groupedTieredPackage = groupedTieredPackage) + + fun ofMaxGroupTieredPackage( + maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice + ) = Price(maxGroupTieredPackage = maxGroupTieredPackage) + + fun ofScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice + ) = Price(scalableMatrixWithUnitPricing = scalableMatrixWithUnitPricing) + + fun ofScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: NewPlanScalableMatrixWithTieredPricingPrice + ) = Price(scalableMatrixWithTieredPricing = scalableMatrixWithTieredPricing) + + fun ofCumulativeGroupedBulk( + cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice + ) = Price(cumulativeGroupedBulk = cumulativeGroupedBulk) + + fun ofCumulativeGroupedAllocation( + cumulativeGroupedAllocation: CumulativeGroupedAllocation + ) = Price(cumulativeGroupedAllocation = cumulativeGroupedAllocation) + + fun ofMinimum(minimum: NewPlanMinimumCompositePrice) = Price(minimum = minimum) + + fun ofPercent(percent: Percent) = Price(percent = percent) + + fun ofEventOutput(eventOutput: EventOutput) = Price(eventOutput = eventOutput) + } + + /** + * An interface that defines how to map each variant of [Price] to a value of type [T]. + */ + interface Visitor { + + fun visitUnit(unit: NewPlanUnitPrice): T + + fun visitTiered(tiered: NewPlanTieredPrice): T + + fun visitBulk(bulk: NewPlanBulkPrice): T + + fun visitBulkWithFilters(bulkWithFilters: BulkWithFilters): T + + fun visitPackage(package_: NewPlanPackagePrice): T + + fun visitMatrix(matrix: NewPlanMatrixPrice): T + + fun visitThresholdTotalAmount( + thresholdTotalAmount: NewPlanThresholdTotalAmountPrice + ): T + + fun visitTieredPackage(tieredPackage: NewPlanTieredPackagePrice): T + + fun visitTieredWithMinimum(tieredWithMinimum: NewPlanTieredWithMinimumPrice): T + + fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice): T + + fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice + ): T + + fun visitPackageWithAllocation( + packageWithAllocation: NewPlanPackageWithAllocationPrice + ): T + + fun visitUnitWithPercent(unitWithPercent: NewPlanUnitWithPercentPrice): T + + fun visitMatrixWithAllocation( + matrixWithAllocation: NewPlanMatrixWithAllocationPrice + ): T + + fun visitTieredWithProration(tieredWithProration: TieredWithProration): T + + fun visitUnitWithProration(unitWithProration: NewPlanUnitWithProrationPrice): T + + fun visitGroupedAllocation(groupedAllocation: NewPlanGroupedAllocationPrice): T + + fun visitBulkWithProration(bulkWithProration: NewPlanBulkWithProrationPrice): T + + fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice + ): T + + fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice + ): T + + fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ): T + + fun visitMatrixWithDisplayName( + matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice + ): T + + fun visitGroupedTieredPackage( + groupedTieredPackage: NewPlanGroupedTieredPackagePrice + ): T + + fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice + ): T + + fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice + ): T + + fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: NewPlanScalableMatrixWithTieredPricingPrice + ): T + + fun visitCumulativeGroupedBulk( + cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice + ): T + + fun visitCumulativeGroupedAllocation( + cumulativeGroupedAllocation: CumulativeGroupedAllocation + ): T + + fun visitMinimum(minimum: NewPlanMinimumCompositePrice): T + + fun visitPercent(percent: Percent): T + + fun visitEventOutput(eventOutput: EventOutput): T + + /** + * Maps an unknown variant of [Price] to a value of type [T]. + * + * An instance of [Price] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is + * unaware of. + * + * @throws OrbInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw OrbInvalidDataException("Unknown Price: $json") + } + } + + internal class Deserializer : BaseDeserializer(Price::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Price { + val json = JsonValue.fromJsonNode(node) + val modelType = json.asObject()?.get("model_type")?.asString() + + when (modelType) { + "unit" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(unit = it, _json = json) + } ?: Price(_json = json) + } + "tiered" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(tiered = it, _json = json) + } ?: Price(_json = json) + } + "bulk" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(bulk = it, _json = json) + } ?: Price(_json = json) + } + "bulk_with_filters" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(bulkWithFilters = it, _json = json) + } ?: Price(_json = json) + } + "package" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(package_ = it, _json = json) } ?: Price(_json = json) + } + "matrix" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(matrix = it, _json = json) + } ?: Price(_json = json) + } + "threshold_total_amount" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(thresholdTotalAmount = it, _json = json) } + ?: Price(_json = json) + } + "tiered_package" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(tieredPackage = it, _json = json) } + ?: Price(_json = json) + } + "tiered_with_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(tieredWithMinimum = it, _json = json) } + ?: Price(_json = json) + } + "grouped_tiered" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(groupedTiered = it, _json = json) } + ?: Price(_json = json) + } + "tiered_package_with_minimum" -> { return tryDeserialize( node, jacksonTypeRef(), ) - ?.let { Price(tieredPackageWithMinimum = it, _json = json) } - ?: Price(_json = json) + ?.let { Price(tieredPackageWithMinimum = it, _json = json) } + ?: Price(_json = json) + } + "package_with_allocation" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(packageWithAllocation = it, _json = json) } + ?: Price(_json = json) + } + "unit_with_percent" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(unitWithPercent = it, _json = json) } + ?: Price(_json = json) + } + "matrix_with_allocation" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(matrixWithAllocation = it, _json = json) } + ?: Price(_json = json) + } + "tiered_with_proration" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(tieredWithProration = it, _json = json) } + ?: Price(_json = json) + } + "unit_with_proration" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(unitWithProration = it, _json = json) } + ?: Price(_json = json) + } + "grouped_allocation" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedAllocation = it, _json = json) } + ?: Price(_json = json) + } + "bulk_with_proration" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(bulkWithProration = it, _json = json) } + ?: Price(_json = json) + } + "grouped_with_prorated_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedWithProratedMinimum = it, _json = json) } + ?: Price(_json = json) + } + "grouped_with_metered_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedWithMeteredMinimum = it, _json = json) } + ?: Price(_json = json) + } + "grouped_with_min_max_thresholds" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedWithMinMaxThresholds = it, _json = json) } + ?: Price(_json = json) + } + "matrix_with_display_name" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(matrixWithDisplayName = it, _json = json) } + ?: Price(_json = json) + } + "grouped_tiered_package" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedTieredPackage = it, _json = json) } + ?: Price(_json = json) + } + "max_group_tiered_package" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(maxGroupTieredPackage = it, _json = json) } + ?: Price(_json = json) + } + "scalable_matrix_with_unit_pricing" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(scalableMatrixWithUnitPricing = it, _json = json) } + ?: Price(_json = json) + } + "scalable_matrix_with_tiered_pricing" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(scalableMatrixWithTieredPricing = it, _json = json) } + ?: Price(_json = json) + } + "cumulative_grouped_bulk" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(cumulativeGroupedBulk = it, _json = json) } + ?: Price(_json = json) + } + "cumulative_grouped_allocation" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(cumulativeGroupedAllocation = it, _json = json) } + ?: Price(_json = json) + } + "minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(minimum = it, _json = json) } ?: Price(_json = json) + } + "percent" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(percent = it, _json = json) + } ?: Price(_json = json) + } + "event_output" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(eventOutput = it, _json = json) + } ?: Price(_json = json) + } + } + + return Price(_json = json) + } + } + + internal class Serializer : BaseSerializer(Price::class) { + + override fun serialize( + value: Price, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.unit != null -> generator.writeObject(value.unit) + value.tiered != null -> generator.writeObject(value.tiered) + value.bulk != null -> generator.writeObject(value.bulk) + value.bulkWithFilters != null -> + generator.writeObject(value.bulkWithFilters) + value.package_ != null -> generator.writeObject(value.package_) + value.matrix != null -> generator.writeObject(value.matrix) + value.thresholdTotalAmount != null -> + generator.writeObject(value.thresholdTotalAmount) + value.tieredPackage != null -> generator.writeObject(value.tieredPackage) + value.tieredWithMinimum != null -> + generator.writeObject(value.tieredWithMinimum) + value.groupedTiered != null -> generator.writeObject(value.groupedTiered) + value.tieredPackageWithMinimum != null -> + generator.writeObject(value.tieredPackageWithMinimum) + value.packageWithAllocation != null -> + generator.writeObject(value.packageWithAllocation) + value.unitWithPercent != null -> + generator.writeObject(value.unitWithPercent) + value.matrixWithAllocation != null -> + generator.writeObject(value.matrixWithAllocation) + value.tieredWithProration != null -> + generator.writeObject(value.tieredWithProration) + value.unitWithProration != null -> + generator.writeObject(value.unitWithProration) + value.groupedAllocation != null -> + generator.writeObject(value.groupedAllocation) + value.bulkWithProration != null -> + generator.writeObject(value.bulkWithProration) + value.groupedWithProratedMinimum != null -> + generator.writeObject(value.groupedWithProratedMinimum) + value.groupedWithMeteredMinimum != null -> + generator.writeObject(value.groupedWithMeteredMinimum) + value.groupedWithMinMaxThresholds != null -> + generator.writeObject(value.groupedWithMinMaxThresholds) + value.matrixWithDisplayName != null -> + generator.writeObject(value.matrixWithDisplayName) + value.groupedTieredPackage != null -> + generator.writeObject(value.groupedTieredPackage) + value.maxGroupTieredPackage != null -> + generator.writeObject(value.maxGroupTieredPackage) + value.scalableMatrixWithUnitPricing != null -> + generator.writeObject(value.scalableMatrixWithUnitPricing) + value.scalableMatrixWithTieredPricing != null -> + generator.writeObject(value.scalableMatrixWithTieredPricing) + value.cumulativeGroupedBulk != null -> + generator.writeObject(value.cumulativeGroupedBulk) + value.cumulativeGroupedAllocation != null -> + generator.writeObject(value.cumulativeGroupedAllocation) + value.minimum != null -> generator.writeObject(value.minimum) + value.percent != null -> generator.writeObject(value.percent) + value.eventOutput != null -> generator.writeObject(value.eventOutput) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Price") + } + } + } + + class BulkWithFilters + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val bulkWithFiltersConfig: JsonField, + private val cadence: JsonField, + private val itemId: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("bulk_with_filters_config") + @ExcludeMissing + bulkWithFiltersConfig: JsonField = JsonMissing.of(), + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + bulkWithFiltersConfig, + cadence, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * Configuration for bulk_with_filters pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun bulkWithFiltersConfig(): BulkWithFiltersConfig = + bulkWithFiltersConfig.getRequired("bulk_with_filters_config") + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("bulk_with_filters") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = billableMetricId.getNullable("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + invoiceGroupingKey.getNullable("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [bulkWithFiltersConfig]. + * + * Unlike [bulkWithFiltersConfig], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("bulk_with_filters_config") + @ExcludeMissing + fun _bulkWithFiltersConfig(): JsonField = + bulkWithFiltersConfig + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [BulkWithFilters]. + * + * The following fields are required: + * ```kotlin + * .bulkWithFiltersConfig() + * .cadence() + * .itemId() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [BulkWithFilters]. */ + class Builder internal constructor() { + + private var bulkWithFiltersConfig: JsonField? = null + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonValue = JsonValue.from("bulk_with_filters") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(bulkWithFilters: BulkWithFilters) = apply { + bulkWithFiltersConfig = bulkWithFilters.bulkWithFiltersConfig + cadence = bulkWithFilters.cadence + itemId = bulkWithFilters.itemId + modelType = bulkWithFilters.modelType + name = bulkWithFilters.name + billableMetricId = bulkWithFilters.billableMetricId + billedInAdvance = bulkWithFilters.billedInAdvance + billingCycleConfiguration = bulkWithFilters.billingCycleConfiguration + conversionRate = bulkWithFilters.conversionRate + conversionRateConfig = bulkWithFilters.conversionRateConfig + currency = bulkWithFilters.currency + dimensionalPriceConfiguration = + bulkWithFilters.dimensionalPriceConfiguration + externalPriceId = bulkWithFilters.externalPriceId + fixedPriceQuantity = bulkWithFilters.fixedPriceQuantity + invoiceGroupingKey = bulkWithFilters.invoiceGroupingKey + invoicingCycleConfiguration = bulkWithFilters.invoicingCycleConfiguration + metadata = bulkWithFilters.metadata + referenceId = bulkWithFilters.referenceId + additionalProperties = bulkWithFilters.additionalProperties.toMutableMap() + } + + /** Configuration for bulk_with_filters pricing */ + fun bulkWithFiltersConfig(bulkWithFiltersConfig: BulkWithFiltersConfig) = + bulkWithFiltersConfig(JsonField.of(bulkWithFiltersConfig)) + + /** + * Sets [Builder.bulkWithFiltersConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.bulkWithFiltersConfig] with a well-typed + * [BulkWithFiltersConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun bulkWithFiltersConfig( + bulkWithFiltersConfig: JsonField + ) = apply { this.bulkWithFiltersConfig = bulkWithFiltersConfig } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("bulk_with_filters") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BulkWithFilters]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .bulkWithFiltersConfig() + * .cadence() + * .itemId() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BulkWithFilters = + BulkWithFilters( + checkRequired("bulkWithFiltersConfig", bulkWithFiltersConfig), + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): BulkWithFilters = apply { + if (validated) { + return@apply + } + + bulkWithFiltersConfig().validate() + cadence().validate() + itemId() + _modelType().let { + if (it != JsonValue.from("bulk_with_filters")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (bulkWithFiltersConfig.asKnown()?.validity() ?: 0) + + (cadence.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + modelType.let { if (it == JsonValue.from("bulk_with_filters")) 1 else 0 } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** Configuration for bulk_with_filters pricing */ + class BulkWithFiltersConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val filters: JsonField>, + private val tiers: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("filters") + @ExcludeMissing + filters: JsonField> = JsonMissing.of(), + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of(), + ) : this(filters, tiers, mutableMapOf()) + + /** + * Property filters to apply (all must match) + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun filters(): List = filters.getRequired("filters") + + /** + * Bulk tiers for rating based on total usage volume + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun tiers(): List = tiers.getRequired("tiers") + + /** + * Returns the raw JSON value of [filters]. + * + * Unlike [filters], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("filters") + @ExcludeMissing + fun _filters(): JsonField> = filters + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [BulkWithFiltersConfig]. + * + * The following fields are required: + * ```kotlin + * .filters() + * .tiers() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [BulkWithFiltersConfig]. */ + class Builder internal constructor() { + + private var filters: JsonField>? = null + private var tiers: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(bulkWithFiltersConfig: BulkWithFiltersConfig) = apply { + filters = bulkWithFiltersConfig.filters.map { it.toMutableList() } + tiers = bulkWithFiltersConfig.tiers.map { it.toMutableList() } + additionalProperties = + bulkWithFiltersConfig.additionalProperties.toMutableMap() + } + + /** Property filters to apply (all must match) */ + fun filters(filters: List) = filters(JsonField.of(filters)) + + /** + * Sets [Builder.filters] to an arbitrary JSON value. + * + * You should usually call [Builder.filters] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun filters(filters: JsonField>) = apply { + this.filters = filters.map { it.toMutableList() } + } + + /** + * Adds a single [Filter] to [filters]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addFilter(filter: Filter) = apply { + filters = + (filters ?: JsonField.of(mutableListOf())).also { + checkKnown("filters", it).add(filter) + } + } + + /** Bulk tiers for rating based on total usage volume */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BulkWithFiltersConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .filters() + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BulkWithFiltersConfig = + BulkWithFiltersConfig( + checkRequired("filters", filters).map { it.toImmutable() }, + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): BulkWithFiltersConfig = apply { + if (validated) { + return@apply + } + + filters().forEach { it.validate() } + tiers().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (filters.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + (tiers.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single property filter */ + class Filter + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val propertyKey: JsonField, + private val propertyValue: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("property_key") + @ExcludeMissing + propertyKey: JsonField = JsonMissing.of(), + @JsonProperty("property_value") + @ExcludeMissing + propertyValue: JsonField = JsonMissing.of(), + ) : this(propertyKey, propertyValue, mutableMapOf()) + + /** + * Event property key to filter on + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun propertyKey(): String = propertyKey.getRequired("property_key") + + /** + * Event property value to match + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun propertyValue(): String = propertyValue.getRequired("property_value") + + /** + * Returns the raw JSON value of [propertyKey]. + * + * Unlike [propertyKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("property_key") + @ExcludeMissing + fun _propertyKey(): JsonField = propertyKey + + /** + * Returns the raw JSON value of [propertyValue]. + * + * Unlike [propertyValue], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("property_value") + @ExcludeMissing + fun _propertyValue(): JsonField = propertyValue + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) } - "package_with_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Filter]. + * + * The following fields are required: + * ```kotlin + * .propertyKey() + * .propertyValue() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Filter]. */ + class Builder internal constructor() { + + private var propertyKey: JsonField? = null + private var propertyValue: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(filter: Filter) = apply { + propertyKey = filter.propertyKey + propertyValue = filter.propertyValue + additionalProperties = filter.additionalProperties.toMutableMap() + } + + /** Event property key to filter on */ + fun propertyKey(propertyKey: String) = + propertyKey(JsonField.of(propertyKey)) + + /** + * Sets [Builder.propertyKey] to an arbitrary JSON value. + * + * You should usually call [Builder.propertyKey] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun propertyKey(propertyKey: JsonField) = apply { + this.propertyKey = propertyKey + } + + /** Event property value to match */ + fun propertyValue(propertyValue: String) = + propertyValue(JsonField.of(propertyValue)) + + /** + * Sets [Builder.propertyValue] to an arbitrary JSON value. + * + * You should usually call [Builder.propertyValue] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun propertyValue(propertyValue: JsonField) = apply { + this.propertyValue = propertyValue + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Filter]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```kotlin + * .propertyKey() + * .propertyValue() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Filter = + Filter( + checkRequired("propertyKey", propertyKey), + checkRequired("propertyValue", propertyValue), + additionalProperties.toMutableMap(), ) - ?.let { Price(packageWithAllocation = it, _json = json) } - ?: Price(_json = json) } - "unit_with_percent" -> { - return tryDeserialize( - node, - jacksonTypeRef(), + + private var validated: Boolean = false + + fun validate(): Filter = apply { + if (validated) { + return@apply + } + + propertyKey() + propertyValue() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (propertyKey.asKnown() == null) 0 else 1) + + (if (propertyValue.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Filter && + propertyKey == other.propertyKey && + propertyValue == other.propertyValue && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(propertyKey, propertyValue, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Filter{propertyKey=$propertyKey, propertyValue=$propertyValue, additionalProperties=$additionalProperties}" + } + + /** Configuration for a single bulk pricing tier */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val unitAmount: JsonField, + private val tierLowerBound: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + ) : this(unitAmount, tierLowerBound, mutableMapOf()) + + /** + * Amount per unit + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * The lower bound for this tier + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun tierLowerBound(): String? = + tierLowerBound.getNullable("tier_lower_bound") + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Tier]. + * + * The following fields are required: + * ```kotlin + * .unitAmount() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var unitAmount: JsonField? = null + private var tierLowerBound: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(tier: Tier) = apply { + unitAmount = tier.unitAmount + tierLowerBound = tier.tierLowerBound + additionalProperties = tier.additionalProperties.toMutableMap() + } + + /** Amount per unit */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + /** The lower bound for this tier */ + fun tierLowerBound(tierLowerBound: String?) = + tierLowerBound(JsonField.ofNullable(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```kotlin + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("unitAmount", unitAmount), + tierLowerBound, + additionalProperties.toMutableMap(), ) - ?.let { Price(unitWithPercent = it, _json = json) } - ?: Price(_json = json) } - "matrix_with_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(matrixWithAllocation = it, _json = json) } - ?: Price(_json = json) + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + unitAmount() + tierLowerBound() + validated = true } - "tiered_with_proration" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(tieredWithProration = it, _json = json) } - ?: Price(_json = json) + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (unitAmount.asKnown() == null) 0 else 1) + + (if (tierLowerBound.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + unitAmount == other.unitAmount && + tierLowerBound == other.tierLowerBound && + additionalProperties == other.additionalProperties } - "unit_with_proration" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(unitWithProration = it, _json = json) } - ?: Price(_json = json) + + private val hashCode: Int by lazy { + Objects.hash(unitAmount, tierLowerBound, additionalProperties) } - "grouped_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedAllocation = it, _json = json) } - ?: Price(_json = json) + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{unitAmount=$unitAmount, tierLowerBound=$tierLowerBound, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - "bulk_with_proration" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(bulkWithProration = it, _json = json) } - ?: Price(_json = json) + + return other is BulkWithFiltersConfig && + filters == other.filters && + tiers == other.tiers && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(filters, tiers, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BulkWithFiltersConfig{filters=$filters, tiers=$tiers, additionalProperties=$additionalProperties}" + } + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN } - "grouped_with_prorated_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedWithProratedMinimum = it, _json = json) } - ?: Price(_json = json) + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") } - "grouped_with_metered_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedWithMeteredMinimum = it, _json = json) } - ?: Price(_json = json) + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply } - "grouped_with_min_max_thresholds" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedWithMinMaxThresholds = it, _json = json) } - ?: Price(_json = json) + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false } - "matrix_with_display_name" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(matrixWithDisplayName = it, _json = json) } - ?: Price(_json = json) + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - "grouped_tiered_package" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedTieredPackage = it, _json = json) } - ?: Price(_json = json) + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() } - "max_group_tiered_package" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(maxGroupTieredPackage = it, _json = json) } - ?: Price(_json = json) + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) } - "scalable_matrix_with_unit_pricing" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(scalableMatrixWithUnitPricing = it, _json = json) } - ?: Price(_json = json) + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) } - "scalable_matrix_with_tiered_pricing" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(scalableMatrixWithTieredPricing = it, _json = json) } - ?: Price(_json = json) + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) } - "cumulative_grouped_bulk" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(cumulativeGroupedBulk = it, _json = json) } - ?: Price(_json = json) + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply } - "minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(minimum = it, _json = json) } ?: Price(_json = json) + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false } - "percent" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(percent = it, _json = json) - } ?: Price(_json = json) + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() } - "event_output" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(eventOutput = it, _json = json) - } ?: Price(_json = json) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - return Price(_json = json) + return other is BulkWithFilters && + bulkWithFiltersConfig == other.bulkWithFiltersConfig && + cadence == other.cadence && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties } - } - - internal class Serializer : BaseSerializer(Price::class) { - override fun serialize( - value: Price, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unit != null -> generator.writeObject(value.unit) - value.tiered != null -> generator.writeObject(value.tiered) - value.bulk != null -> generator.writeObject(value.bulk) - value.bulkWithFilters != null -> - generator.writeObject(value.bulkWithFilters) - value.package_ != null -> generator.writeObject(value.package_) - value.matrix != null -> generator.writeObject(value.matrix) - value.thresholdTotalAmount != null -> - generator.writeObject(value.thresholdTotalAmount) - value.tieredPackage != null -> generator.writeObject(value.tieredPackage) - value.tieredWithMinimum != null -> - generator.writeObject(value.tieredWithMinimum) - value.groupedTiered != null -> generator.writeObject(value.groupedTiered) - value.tieredPackageWithMinimum != null -> - generator.writeObject(value.tieredPackageWithMinimum) - value.packageWithAllocation != null -> - generator.writeObject(value.packageWithAllocation) - value.unitWithPercent != null -> - generator.writeObject(value.unitWithPercent) - value.matrixWithAllocation != null -> - generator.writeObject(value.matrixWithAllocation) - value.tieredWithProration != null -> - generator.writeObject(value.tieredWithProration) - value.unitWithProration != null -> - generator.writeObject(value.unitWithProration) - value.groupedAllocation != null -> - generator.writeObject(value.groupedAllocation) - value.bulkWithProration != null -> - generator.writeObject(value.bulkWithProration) - value.groupedWithProratedMinimum != null -> - generator.writeObject(value.groupedWithProratedMinimum) - value.groupedWithMeteredMinimum != null -> - generator.writeObject(value.groupedWithMeteredMinimum) - value.groupedWithMinMaxThresholds != null -> - generator.writeObject(value.groupedWithMinMaxThresholds) - value.matrixWithDisplayName != null -> - generator.writeObject(value.matrixWithDisplayName) - value.groupedTieredPackage != null -> - generator.writeObject(value.groupedTieredPackage) - value.maxGroupTieredPackage != null -> - generator.writeObject(value.maxGroupTieredPackage) - value.scalableMatrixWithUnitPricing != null -> - generator.writeObject(value.scalableMatrixWithUnitPricing) - value.scalableMatrixWithTieredPricing != null -> - generator.writeObject(value.scalableMatrixWithTieredPricing) - value.cumulativeGroupedBulk != null -> - generator.writeObject(value.cumulativeGroupedBulk) - value.minimum != null -> generator.writeObject(value.minimum) - value.percent != null -> generator.writeObject(value.percent) - value.eventOutput != null -> generator.writeObject(value.eventOutput) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Price") - } + private val hashCode: Int by lazy { + Objects.hash( + bulkWithFiltersConfig, + cadence, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties, + ) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BulkWithFilters{bulkWithFiltersConfig=$bulkWithFiltersConfig, cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class BulkWithFilters + class TieredWithProration @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val bulkWithFiltersConfig: JsonField, private val cadence: JsonField, private val itemId: JsonField, private val modelType: JsonValue, private val name: JsonField, + private val tieredWithProrationConfig: JsonField, private val billableMetricId: JsonField, private val billedInAdvance: JsonField, private val billingCycleConfiguration: JsonField, @@ -14613,9 +18453,6 @@ private constructor( @JsonCreator private constructor( - @JsonProperty("bulk_with_filters_config") - @ExcludeMissing - bulkWithFiltersConfig: JsonField = JsonMissing.of(), @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), @@ -14628,6 +18465,10 @@ private constructor( @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("tiered_with_proration_config") + @ExcludeMissing + tieredWithProrationConfig: JsonField = + JsonMissing.of(), @JsonProperty("billable_metric_id") @ExcludeMissing billableMetricId: JsonField = JsonMissing.of(), @@ -14671,11 +18512,11 @@ private constructor( @ExcludeMissing referenceId: JsonField = JsonMissing.of(), ) : this( - bulkWithFiltersConfig, cadence, itemId, modelType, name, + tieredWithProrationConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -14692,16 +18533,6 @@ private constructor( mutableMapOf(), ) - /** - * Configuration for bulk_with_filters pricing - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun bulkWithFiltersConfig(): BulkWithFiltersConfig = - bulkWithFiltersConfig.getRequired("bulk_with_filters_config") - /** * The cadence to bill for this price on. * @@ -14725,7 +18556,7 @@ private constructor( * * Expected to always return the following: * ```kotlin - * JsonValue.from("bulk_with_filters") + * JsonValue.from("tiered_with_proration") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -14742,6 +18573,16 @@ private constructor( */ fun name(): String = name.getRequired("name") + /** + * Configuration for tiered_with_proration pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun tieredWithProrationConfig(): TieredWithProrationConfig = + tieredWithProrationConfig.getRequired("tiered_with_proration_config") + /** * The id of the billable metric for the price. Only needed if the price is * usage-based. @@ -14861,17 +18702,6 @@ private constructor( */ fun referenceId(): String? = referenceId.getNullable("reference_id") - /** - * Returns the raw JSON value of [bulkWithFiltersConfig]. - * - * Unlike [bulkWithFiltersConfig], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("bulk_with_filters_config") - @ExcludeMissing - fun _bulkWithFiltersConfig(): JsonField = - bulkWithFiltersConfig - /** * Returns the raw JSON value of [cadence]. * @@ -14898,6 +18728,17 @@ private constructor( */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + /** + * Returns the raw JSON value of [tieredWithProrationConfig]. + * + * Unlike [tieredWithProrationConfig], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("tiered_with_proration_config") + @ExcludeMissing + fun _tieredWithProrationConfig(): JsonField = + tieredWithProrationConfig + /** * Returns the raw JSON value of [billableMetricId]. * @@ -15046,27 +18887,29 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [BulkWithFilters]. + * Returns a mutable builder for constructing an instance of + * [TieredWithProration]. * * The following fields are required: * ```kotlin - * .bulkWithFiltersConfig() * .cadence() * .itemId() * .name() + * .tieredWithProrationConfig() * ``` */ fun builder() = Builder() } - /** A builder for [BulkWithFilters]. */ + /** A builder for [TieredWithProration]. */ class Builder internal constructor() { - private var bulkWithFiltersConfig: JsonField? = null private var cadence: JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonValue = JsonValue.from("bulk_with_filters") + private var modelType: JsonValue = JsonValue.from("tiered_with_proration") private var name: JsonField? = null + private var tieredWithProrationConfig: JsonField? = + null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() private var billingCycleConfiguration: JsonField = @@ -15088,44 +18931,31 @@ private constructor( private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(bulkWithFilters: BulkWithFilters) = apply { - bulkWithFiltersConfig = bulkWithFilters.bulkWithFiltersConfig - cadence = bulkWithFilters.cadence - itemId = bulkWithFilters.itemId - modelType = bulkWithFilters.modelType - name = bulkWithFilters.name - billableMetricId = bulkWithFilters.billableMetricId - billedInAdvance = bulkWithFilters.billedInAdvance - billingCycleConfiguration = bulkWithFilters.billingCycleConfiguration - conversionRate = bulkWithFilters.conversionRate - conversionRateConfig = bulkWithFilters.conversionRateConfig - currency = bulkWithFilters.currency + internal fun from(tieredWithProration: TieredWithProration) = apply { + cadence = tieredWithProration.cadence + itemId = tieredWithProration.itemId + modelType = tieredWithProration.modelType + name = tieredWithProration.name + tieredWithProrationConfig = tieredWithProration.tieredWithProrationConfig + billableMetricId = tieredWithProration.billableMetricId + billedInAdvance = tieredWithProration.billedInAdvance + billingCycleConfiguration = tieredWithProration.billingCycleConfiguration + conversionRate = tieredWithProration.conversionRate + conversionRateConfig = tieredWithProration.conversionRateConfig + currency = tieredWithProration.currency dimensionalPriceConfiguration = - bulkWithFilters.dimensionalPriceConfiguration - externalPriceId = bulkWithFilters.externalPriceId - fixedPriceQuantity = bulkWithFilters.fixedPriceQuantity - invoiceGroupingKey = bulkWithFilters.invoiceGroupingKey - invoicingCycleConfiguration = bulkWithFilters.invoicingCycleConfiguration - metadata = bulkWithFilters.metadata - referenceId = bulkWithFilters.referenceId - additionalProperties = bulkWithFilters.additionalProperties.toMutableMap() + tieredWithProration.dimensionalPriceConfiguration + externalPriceId = tieredWithProration.externalPriceId + fixedPriceQuantity = tieredWithProration.fixedPriceQuantity + invoiceGroupingKey = tieredWithProration.invoiceGroupingKey + invoicingCycleConfiguration = + tieredWithProration.invoicingCycleConfiguration + metadata = tieredWithProration.metadata + referenceId = tieredWithProration.referenceId + additionalProperties = + tieredWithProration.additionalProperties.toMutableMap() } - /** Configuration for bulk_with_filters pricing */ - fun bulkWithFiltersConfig(bulkWithFiltersConfig: BulkWithFiltersConfig) = - bulkWithFiltersConfig(JsonField.of(bulkWithFiltersConfig)) - - /** - * Sets [Builder.bulkWithFiltersConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.bulkWithFiltersConfig] with a well-typed - * [BulkWithFiltersConfig] value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun bulkWithFiltersConfig( - bulkWithFiltersConfig: JsonField - ) = apply { this.bulkWithFiltersConfig = bulkWithFiltersConfig } - /** The cadence to bill for this price on. */ fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) @@ -15156,7 +18986,7 @@ private constructor( * It is usually unnecessary to call this method because the field defaults to * the following: * ```kotlin - * JsonValue.from("bulk_with_filters") + * JsonValue.from("tiered_with_proration") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -15170,11 +19000,27 @@ private constructor( /** * Sets [Builder.name] to an arbitrary JSON value. * - * You should usually call [Builder.name] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for tiered_with_proration pricing */ + fun tieredWithProrationConfig( + tieredWithProrationConfig: TieredWithProrationConfig + ) = tieredWithProrationConfig(JsonField.of(tieredWithProrationConfig)) + + /** + * Sets [Builder.tieredWithProrationConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.tieredWithProrationConfig] with a well-typed + * [TieredWithProrationConfig] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. */ - fun name(name: JsonField) = apply { this.name = name } + fun tieredWithProrationConfig( + tieredWithProrationConfig: JsonField + ) = apply { this.tieredWithProrationConfig = tieredWithProrationConfig } /** * The id of the billable metric for the price. Only needed if the price is @@ -15505,27 +19351,27 @@ private constructor( } /** - * Returns an immutable instance of [BulkWithFilters]. + * Returns an immutable instance of [TieredWithProration]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```kotlin - * .bulkWithFiltersConfig() * .cadence() * .itemId() * .name() + * .tieredWithProrationConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): BulkWithFilters = - BulkWithFilters( - checkRequired("bulkWithFiltersConfig", bulkWithFiltersConfig), + fun build(): TieredWithProration = + TieredWithProration( checkRequired("cadence", cadence), checkRequired("itemId", itemId), modelType, checkRequired("name", name), + checkRequired("tieredWithProrationConfig", tieredWithProrationConfig), billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -15545,20 +19391,20 @@ private constructor( private var validated: Boolean = false - fun validate(): BulkWithFilters = apply { + fun validate(): TieredWithProration = apply { if (validated) { return@apply } - bulkWithFiltersConfig().validate() cadence().validate() itemId() _modelType().let { - if (it != JsonValue.from("bulk_with_filters")) { + if (it != JsonValue.from("tiered_with_proration")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } name() + tieredWithProrationConfig().validate() billableMetricId() billedInAdvance() billingCycleConfiguration()?.validate() @@ -15590,11 +19436,13 @@ private constructor( * Used for best match union deserialization. */ internal fun validity(): Int = - (bulkWithFiltersConfig.asKnown()?.validity() ?: 0) + - (cadence.asKnown()?.validity() ?: 0) + + (cadence.asKnown()?.validity() ?: 0) + (if (itemId.asKnown() == null) 0 else 1) + - modelType.let { if (it == JsonValue.from("bulk_with_filters")) 1 else 0 } + + modelType.let { + if (it == JsonValue.from("tiered_with_proration")) 1 else 0 + } + (if (name.asKnown() == null) 0 else 1) + + (tieredWithProrationConfig.asKnown()?.validity() ?: 0) + (if (billableMetricId.asKnown() == null) 0 else 1) + (if (billedInAdvance.asKnown() == null) 0 else 1) + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + @@ -15609,36 +19457,181 @@ private constructor( (metadata.asKnown()?.validity() ?: 0) + (if (referenceId.asKnown() == null) 0 else 1) - /** Configuration for bulk_with_filters pricing */ - class BulkWithFiltersConfig + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Configuration for tiered_with_proration pricing */ + class TieredWithProrationConfig @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val filters: JsonField>, private val tiers: JsonField>, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("filters") - @ExcludeMissing - filters: JsonField> = JsonMissing.of(), @JsonProperty("tiers") @ExcludeMissing - tiers: JsonField> = JsonMissing.of(), - ) : this(filters, tiers, mutableMapOf()) - - /** - * Property filters to apply (all must match) - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun filters(): List = filters.getRequired("filters") + tiers: JsonField> = JsonMissing.of() + ) : this(tiers, mutableMapOf()) /** - * Bulk tiers for rating based on total usage volume + * Tiers for rating based on total usage quantities into the specified tier with + * proration * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an @@ -15646,16 +19639,6 @@ private constructor( */ fun tiers(): List = tiers.getRequired("tiers") - /** - * Returns the raw JSON value of [filters]. - * - * Unlike [filters], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("filters") - @ExcludeMissing - fun _filters(): JsonField> = filters - /** * Returns the raw JSON value of [tiers]. * @@ -15682,60 +19665,34 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [BulkWithFiltersConfig]. + * [TieredWithProrationConfig]. * * The following fields are required: * ```kotlin - * .filters() * .tiers() * ``` */ fun builder() = Builder() } - /** A builder for [BulkWithFiltersConfig]. */ + /** A builder for [TieredWithProrationConfig]. */ class Builder internal constructor() { - private var filters: JsonField>? = null private var tiers: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(bulkWithFiltersConfig: BulkWithFiltersConfig) = apply { - filters = bulkWithFiltersConfig.filters.map { it.toMutableList() } - tiers = bulkWithFiltersConfig.tiers.map { it.toMutableList() } - additionalProperties = - bulkWithFiltersConfig.additionalProperties.toMutableMap() - } - - /** Property filters to apply (all must match) */ - fun filters(filters: List) = filters(JsonField.of(filters)) - - /** - * Sets [Builder.filters] to an arbitrary JSON value. - * - * You should usually call [Builder.filters] with a well-typed - * `List` value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun filters(filters: JsonField>) = apply { - this.filters = filters.map { it.toMutableList() } - } + internal fun from(tieredWithProrationConfig: TieredWithProrationConfig) = + apply { + tiers = tieredWithProrationConfig.tiers.map { it.toMutableList() } + additionalProperties = + tieredWithProrationConfig.additionalProperties.toMutableMap() + } /** - * Adds a single [Filter] to [filters]. - * - * @throws IllegalStateException if the field was previously set to a - * non-list. + * Tiers for rating based on total usage quantities into the specified tier + * with proration */ - fun addFilter(filter: Filter) = apply { - filters = - (filters ?: JsonField.of(mutableListOf())).also { - checkKnown("filters", it).add(filter) - } - } - - /** Bulk tiers for rating based on total usage volume */ fun tiers(tiers: List) = tiers(JsonField.of(tiers)) /** @@ -15785,21 +19742,19 @@ private constructor( } /** - * Returns an immutable instance of [BulkWithFiltersConfig]. + * Returns an immutable instance of [TieredWithProrationConfig]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```kotlin - * .filters() * .tiers() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): BulkWithFiltersConfig = - BulkWithFiltersConfig( - checkRequired("filters", filters).map { it.toImmutable() }, + fun build(): TieredWithProrationConfig = + TieredWithProrationConfig( checkRequired("tiers", tiers).map { it.toImmutable() }, additionalProperties.toMutableMap(), ) @@ -15807,12 +19762,11 @@ private constructor( private var validated: Boolean = false - fun validate(): BulkWithFiltersConfig = apply { + fun validate(): TieredWithProrationConfig = apply { if (validated) { return@apply } - filters().forEach { it.validate() } tiers().forEach { it.validate() } validated = true } @@ -15827,254 +19781,41 @@ private constructor( /** * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (filters.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + - (tiers.asKnown()?.sumOf { it.validity().toInt() } ?: 0) - - /** Configuration for a single property filter */ - class Filter - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val propertyKey: JsonField, - private val propertyValue: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("property_key") - @ExcludeMissing - propertyKey: JsonField = JsonMissing.of(), - @JsonProperty("property_value") - @ExcludeMissing - propertyValue: JsonField = JsonMissing.of(), - ) : this(propertyKey, propertyValue, mutableMapOf()) - - /** - * Event property key to filter on - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type - * or is unexpectedly missing or null (e.g. if the server responded with - * an unexpected value). - */ - fun propertyKey(): String = propertyKey.getRequired("property_key") - - /** - * Event property value to match - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type - * or is unexpectedly missing or null (e.g. if the server responded with - * an unexpected value). - */ - fun propertyValue(): String = propertyValue.getRequired("property_value") - - /** - * Returns the raw JSON value of [propertyKey]. - * - * Unlike [propertyKey], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("property_key") - @ExcludeMissing - fun _propertyKey(): JsonField = propertyKey - - /** - * Returns the raw JSON value of [propertyValue]. - * - * Unlike [propertyValue], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("property_value") - @ExcludeMissing - fun _propertyValue(): JsonField = propertyValue - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [Filter]. - * - * The following fields are required: - * ```kotlin - * .propertyKey() - * .propertyValue() - * ``` - */ - fun builder() = Builder() - } - - /** A builder for [Filter]. */ - class Builder internal constructor() { - - private var propertyKey: JsonField? = null - private var propertyValue: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - internal fun from(filter: Filter) = apply { - propertyKey = filter.propertyKey - propertyValue = filter.propertyValue - additionalProperties = filter.additionalProperties.toMutableMap() - } - - /** Event property key to filter on */ - fun propertyKey(propertyKey: String) = - propertyKey(JsonField.of(propertyKey)) - - /** - * Sets [Builder.propertyKey] to an arbitrary JSON value. - * - * You should usually call [Builder.propertyKey] with a well-typed - * [String] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun propertyKey(propertyKey: JsonField) = apply { - this.propertyKey = propertyKey - } - - /** Event property value to match */ - fun propertyValue(propertyValue: String) = - propertyValue(JsonField.of(propertyValue)) - - /** - * Sets [Builder.propertyValue] to an arbitrary JSON value. - * - * You should usually call [Builder.propertyValue] with a well-typed - * [String] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun propertyValue(propertyValue: JsonField) = apply { - this.propertyValue = propertyValue - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Filter]. - * - * Further updates to this [Builder] will not mutate the returned - * instance. - * - * The following fields are required: - * ```kotlin - * .propertyKey() - * .propertyValue() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Filter = - Filter( - checkRequired("propertyKey", propertyKey), - checkRequired("propertyValue", propertyValue), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Filter = apply { - if (validated) { - return@apply - } - - propertyKey() - propertyValue() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this - * object recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (if (propertyKey.asKnown() == null) 0 else 1) + - (if (propertyValue.asKnown() == null) 0 else 1) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Filter && - propertyKey == other.propertyKey && - propertyValue == other.propertyValue && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(propertyKey, propertyValue, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Filter{propertyKey=$propertyKey, propertyValue=$propertyValue, additionalProperties=$additionalProperties}" - } + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (tiers.asKnown()?.sumOf { it.validity().toInt() } ?: 0) - /** Configuration for a single bulk pricing tier */ + /** Configuration for a single tiered with proration tier */ class Tier @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val unitAmount: JsonField, private val tierLowerBound: JsonField, + private val unitAmount: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("unit_amount") - @ExcludeMissing - unitAmount: JsonField = JsonMissing.of(), @JsonProperty("tier_lower_bound") @ExcludeMissing tierLowerBound: JsonField = JsonMissing.of(), - ) : this(unitAmount, tierLowerBound, mutableMapOf()) + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(tierLowerBound, unitAmount, mutableMapOf()) + + /** + * Inclusive tier starting value + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun tierLowerBound(): String = + tierLowerBound.getRequired("tier_lower_bound") /** * Amount per unit @@ -16086,13 +19827,14 @@ private constructor( fun unitAmount(): String = unitAmount.getRequired("unit_amount") /** - * The lower bound for this tier + * Returns the raw JSON value of [tierLowerBound]. * - * @throws OrbInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. */ - fun tierLowerBound(): String? = - tierLowerBound.getNullable("tier_lower_bound") + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound /** * Returns the raw JSON value of [unitAmount]. @@ -16104,16 +19846,6 @@ private constructor( @ExcludeMissing fun _unitAmount(): JsonField = unitAmount - /** - * Returns the raw JSON value of [tierLowerBound]. - * - * Unlike [tierLowerBound], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("tier_lower_bound") - @ExcludeMissing - fun _tierLowerBound(): JsonField = tierLowerBound - @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -16133,6 +19865,7 @@ private constructor( * * The following fields are required: * ```kotlin + * .tierLowerBound() * .unitAmount() * ``` */ @@ -16142,45 +19875,45 @@ private constructor( /** A builder for [Tier]. */ class Builder internal constructor() { + private var tierLowerBound: JsonField? = null private var unitAmount: JsonField? = null - private var tierLowerBound: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() internal fun from(tier: Tier) = apply { - unitAmount = tier.unitAmount tierLowerBound = tier.tierLowerBound + unitAmount = tier.unitAmount additionalProperties = tier.additionalProperties.toMutableMap() } - /** Amount per unit */ - fun unitAmount(unitAmount: String) = - unitAmount(JsonField.of(unitAmount)) + /** Inclusive tier starting value */ + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) /** - * Sets [Builder.unitAmount] to an arbitrary JSON value. + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. * - * You should usually call [Builder.unitAmount] with a well-typed + * You should usually call [Builder.tierLowerBound] with a well-typed * [String] value instead. This method is primarily for setting the * field to an undocumented or not yet supported value. */ - fun unitAmount(unitAmount: JsonField) = apply { - this.unitAmount = unitAmount + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound } - /** The lower bound for this tier */ - fun tierLowerBound(tierLowerBound: String?) = - tierLowerBound(JsonField.ofNullable(tierLowerBound)) + /** Amount per unit */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) /** - * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * Sets [Builder.unitAmount] to an arbitrary JSON value. * - * You should usually call [Builder.tierLowerBound] with a well-typed + * You should usually call [Builder.unitAmount] with a well-typed * [String] value instead. This method is primarily for setting the * field to an undocumented or not yet supported value. */ - fun tierLowerBound(tierLowerBound: JsonField) = apply { - this.tierLowerBound = tierLowerBound + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount } fun additionalProperties(additionalProperties: Map) = @@ -16206,253 +19939,94 @@ private constructor( } /** - * Returns an immutable instance of [Tier]. - * - * Further updates to this [Builder] will not mutate the returned - * instance. - * - * The following fields are required: - * ```kotlin - * .unitAmount() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Tier = - Tier( - checkRequired("unitAmount", unitAmount), - tierLowerBound, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Tier = apply { - if (validated) { - return@apply - } - - unitAmount() - tierLowerBound() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this - * object recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (if (unitAmount.asKnown() == null) 0 else 1) + - (if (tierLowerBound.asKnown() == null) 0 else 1) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Tier && - unitAmount == other.unitAmount && - tierLowerBound == other.tierLowerBound && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(unitAmount, tierLowerBound, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Tier{unitAmount=$unitAmount, tierLowerBound=$tierLowerBound, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is BulkWithFiltersConfig && - filters == other.filters && - tiers == other.tiers && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(filters, tiers, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BulkWithFiltersConfig{filters=$filters, tiers=$tiers, additionalProperties=$additionalProperties}" - } - - /** The cadence to bill for this price on. */ - class Cadence - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - val ANNUAL = of("annual") - - val SEMI_ANNUAL = of("semi_annual") - - val MONTHLY = of("monthly") - - val QUARTERLY = of("quarterly") - - val ONE_TIME = of("one_time") - - val CUSTOM = of("custom") - - fun of(value: String) = Cadence(JsonField.of(value)) - } - - /** An enum containing [Cadence]'s known values. */ - enum class Known { - ANNUAL, - SEMI_ANNUAL, - MONTHLY, - QUARTERLY, - ONE_TIME, - CUSTOM, - } - - /** - * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Cadence] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - ANNUAL, - SEMI_ANNUAL, - MONTHLY, - QUARTERLY, - ONE_TIME, - CUSTOM, - /** - * An enum member indicating that [Cadence] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - ANNUAL -> Value.ANNUAL - SEMI_ANNUAL -> Value.SEMI_ANNUAL - MONTHLY -> Value.MONTHLY - QUARTERLY -> Value.QUARTERLY - ONE_TIME -> Value.ONE_TIME - CUSTOM -> Value.CUSTOM - else -> Value._UNKNOWN + * Returns an immutable instance of [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```kotlin + * .tierLowerBound() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("tierLowerBound", tierLowerBound), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) } - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - ANNUAL -> Known.ANNUAL - SEMI_ANNUAL -> Known.SEMI_ANNUAL - MONTHLY -> Known.MONTHLY - QUARTERLY -> Known.QUARTERLY - ONE_TIME -> Known.ONE_TIME - CUSTOM -> Known.CUSTOM - else -> throw OrbInvalidDataException("Unknown Cadence: $value") + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + tierLowerBound() + unitAmount() + validated = true } - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString() - ?: throw OrbInvalidDataException("Value is not a String") + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - private var validated: Boolean = false + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (tierLowerBound.asKnown() == null) 0 else 1) + + (if (unitAmount.asKnown() == null) 0 else 1) - fun validate(): Cadence = apply { - if (validated) { - return@apply - } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - known() - validated = true - } + return other is Tier && + tierLowerBound == other.tierLowerBound && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false + private val hashCode: Int by lazy { + Objects.hash(tierLowerBound, unitAmount, additionalProperties) } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is Cadence && value == other.value + return other is TieredWithProrationConfig && + tiers == other.tiers && + additionalProperties == other.additionalProperties } - override fun hashCode() = value.hashCode() + private val hashCode: Int by lazy { Objects.hash(tiers, additionalProperties) } - override fun toString() = value.toString() + override fun hashCode(): Int = hashCode + + override fun toString() = + "TieredWithProrationConfig{tiers=$tiers, additionalProperties=$additionalProperties}" } /** @@ -16569,12 +20143,12 @@ private constructor( return true } - return other is BulkWithFilters && - bulkWithFiltersConfig == other.bulkWithFiltersConfig && + return other is TieredWithProration && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && + tieredWithProrationConfig == other.tieredWithProrationConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && @@ -16593,11 +20167,11 @@ private constructor( private val hashCode: Int by lazy { Objects.hash( - bulkWithFiltersConfig, cadence, itemId, modelType, name, + tieredWithProrationConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -16618,17 +20192,18 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "BulkWithFilters{bulkWithFiltersConfig=$bulkWithFiltersConfig, cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "TieredWithProration{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredWithProrationConfig=$tieredWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class TieredWithProration + class GroupedWithMinMaxThresholds @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, + private val groupedWithMinMaxThresholdsConfig: + JsonField, private val itemId: JsonField, private val modelType: JsonValue, private val name: JsonField, - private val tieredWithProrationConfig: JsonField, private val billableMetricId: JsonField, private val billedInAdvance: JsonField, private val billingCycleConfiguration: JsonField, @@ -16651,6 +20226,11 @@ private constructor( @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), + @JsonProperty("grouped_with_min_max_thresholds_config") + @ExcludeMissing + groupedWithMinMaxThresholdsConfig: + JsonField = + JsonMissing.of(), @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), @@ -16660,10 +20240,6 @@ private constructor( @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("tiered_with_proration_config") - @ExcludeMissing - tieredWithProrationConfig: JsonField = - JsonMissing.of(), @JsonProperty("billable_metric_id") @ExcludeMissing billableMetricId: JsonField = JsonMissing.of(), @@ -16708,10 +20284,10 @@ private constructor( referenceId: JsonField = JsonMissing.of(), ) : this( cadence, + groupedWithMinMaxThresholdsConfig, itemId, modelType, name, - tieredWithProrationConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -16737,6 +20313,18 @@ private constructor( */ fun cadence(): Cadence = cadence.getRequired("cadence") + /** + * Configuration for grouped_with_min_max_thresholds pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupedWithMinMaxThresholdsConfig(): GroupedWithMinMaxThresholdsConfig = + groupedWithMinMaxThresholdsConfig.getRequired( + "grouped_with_min_max_thresholds_config" + ) + /** * The id of the item the price will be associated with. * @@ -16751,7 +20339,7 @@ private constructor( * * Expected to always return the following: * ```kotlin - * JsonValue.from("tiered_with_proration") + * JsonValue.from("grouped_with_min_max_thresholds") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -16768,16 +20356,6 @@ private constructor( */ fun name(): String = name.getRequired("name") - /** - * Configuration for tiered_with_proration pricing - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun tieredWithProrationConfig(): TieredWithProrationConfig = - tieredWithProrationConfig.getRequired("tiered_with_proration_config") - /** * The id of the billable metric for the price. Only needed if the price is * usage-based. @@ -16907,6 +20485,17 @@ private constructor( @ExcludeMissing fun _cadence(): JsonField = cadence + /** + * Returns the raw JSON value of [groupedWithMinMaxThresholdsConfig]. + * + * Unlike [groupedWithMinMaxThresholdsConfig], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("grouped_with_min_max_thresholds_config") + @ExcludeMissing + fun _groupedWithMinMaxThresholdsConfig(): + JsonField = groupedWithMinMaxThresholdsConfig + /** * Returns the raw JSON value of [itemId]. * @@ -16923,17 +20512,6 @@ private constructor( */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - /** - * Returns the raw JSON value of [tieredWithProrationConfig]. - * - * Unlike [tieredWithProrationConfig], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("tiered_with_proration_config") - @ExcludeMissing - fun _tieredWithProrationConfig(): JsonField = - tieredWithProrationConfig - /** * Returns the raw JSON value of [billableMetricId]. * @@ -17083,28 +20661,30 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [TieredWithProration]. + * [GroupedWithMinMaxThresholds]. * * The following fields are required: * ```kotlin * .cadence() + * .groupedWithMinMaxThresholdsConfig() * .itemId() * .name() - * .tieredWithProrationConfig() * ``` */ fun builder() = Builder() } - /** A builder for [TieredWithProration]. */ + /** A builder for [GroupedWithMinMaxThresholds]. */ class Builder internal constructor() { private var cadence: JsonField? = null + private var groupedWithMinMaxThresholdsConfig: + JsonField? = + null private var itemId: JsonField? = null - private var modelType: JsonValue = JsonValue.from("tiered_with_proration") + private var modelType: JsonValue = + JsonValue.from("grouped_with_min_max_thresholds") private var name: JsonField? = null - private var tieredWithProrationConfig: JsonField? = - null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() private var billingCycleConfiguration: JsonField = @@ -17126,30 +20706,33 @@ private constructor( private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(tieredWithProration: TieredWithProration) = apply { - cadence = tieredWithProration.cadence - itemId = tieredWithProration.itemId - modelType = tieredWithProration.modelType - name = tieredWithProration.name - tieredWithProrationConfig = tieredWithProration.tieredWithProrationConfig - billableMetricId = tieredWithProration.billableMetricId - billedInAdvance = tieredWithProration.billedInAdvance - billingCycleConfiguration = tieredWithProration.billingCycleConfiguration - conversionRate = tieredWithProration.conversionRate - conversionRateConfig = tieredWithProration.conversionRateConfig - currency = tieredWithProration.currency - dimensionalPriceConfiguration = - tieredWithProration.dimensionalPriceConfiguration - externalPriceId = tieredWithProration.externalPriceId - fixedPriceQuantity = tieredWithProration.fixedPriceQuantity - invoiceGroupingKey = tieredWithProration.invoiceGroupingKey - invoicingCycleConfiguration = - tieredWithProration.invoicingCycleConfiguration - metadata = tieredWithProration.metadata - referenceId = tieredWithProration.referenceId - additionalProperties = - tieredWithProration.additionalProperties.toMutableMap() - } + internal fun from(groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds) = + apply { + cadence = groupedWithMinMaxThresholds.cadence + groupedWithMinMaxThresholdsConfig = + groupedWithMinMaxThresholds.groupedWithMinMaxThresholdsConfig + itemId = groupedWithMinMaxThresholds.itemId + modelType = groupedWithMinMaxThresholds.modelType + name = groupedWithMinMaxThresholds.name + billableMetricId = groupedWithMinMaxThresholds.billableMetricId + billedInAdvance = groupedWithMinMaxThresholds.billedInAdvance + billingCycleConfiguration = + groupedWithMinMaxThresholds.billingCycleConfiguration + conversionRate = groupedWithMinMaxThresholds.conversionRate + conversionRateConfig = groupedWithMinMaxThresholds.conversionRateConfig + currency = groupedWithMinMaxThresholds.currency + dimensionalPriceConfiguration = + groupedWithMinMaxThresholds.dimensionalPriceConfiguration + externalPriceId = groupedWithMinMaxThresholds.externalPriceId + fixedPriceQuantity = groupedWithMinMaxThresholds.fixedPriceQuantity + invoiceGroupingKey = groupedWithMinMaxThresholds.invoiceGroupingKey + invoicingCycleConfiguration = + groupedWithMinMaxThresholds.invoicingCycleConfiguration + metadata = groupedWithMinMaxThresholds.metadata + referenceId = groupedWithMinMaxThresholds.referenceId + additionalProperties = + groupedWithMinMaxThresholds.additionalProperties.toMutableMap() + } /** The cadence to bill for this price on. */ fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) @@ -17163,6 +20746,29 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + /** Configuration for grouped_with_min_max_thresholds pricing */ + fun groupedWithMinMaxThresholdsConfig( + groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + ) = + groupedWithMinMaxThresholdsConfig( + JsonField.of(groupedWithMinMaxThresholdsConfig) + ) + + /** + * Sets [Builder.groupedWithMinMaxThresholdsConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.groupedWithMinMaxThresholdsConfig] with a + * well-typed [GroupedWithMinMaxThresholdsConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun groupedWithMinMaxThresholdsConfig( + groupedWithMinMaxThresholdsConfig: + JsonField + ) = apply { + this.groupedWithMinMaxThresholdsConfig = groupedWithMinMaxThresholdsConfig + } + /** The id of the item the price will be associated with. */ fun itemId(itemId: String) = itemId(JsonField.of(itemId)) @@ -17181,7 +20787,7 @@ private constructor( * It is usually unnecessary to call this method because the field defaults to * the following: * ```kotlin - * JsonValue.from("tiered_with_proration") + * JsonValue.from("grouped_with_min_max_thresholds") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -17201,22 +20807,6 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } - /** Configuration for tiered_with_proration pricing */ - fun tieredWithProrationConfig( - tieredWithProrationConfig: TieredWithProrationConfig - ) = tieredWithProrationConfig(JsonField.of(tieredWithProrationConfig)) - - /** - * Sets [Builder.tieredWithProrationConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.tieredWithProrationConfig] with a well-typed - * [TieredWithProrationConfig] value instead. This method is primarily for - * setting the field to an undocumented or not yet supported value. - */ - fun tieredWithProrationConfig( - tieredWithProrationConfig: JsonField - ) = apply { this.tieredWithProrationConfig = tieredWithProrationConfig } - /** * The id of the billable metric for the price. Only needed if the price is * usage-based. @@ -17546,27 +21136,30 @@ private constructor( } /** - * Returns an immutable instance of [TieredWithProration]. + * Returns an immutable instance of [GroupedWithMinMaxThresholds]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```kotlin * .cadence() + * .groupedWithMinMaxThresholdsConfig() * .itemId() * .name() - * .tieredWithProrationConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): TieredWithProration = - TieredWithProration( + fun build(): GroupedWithMinMaxThresholds = + GroupedWithMinMaxThresholds( checkRequired("cadence", cadence), + checkRequired( + "groupedWithMinMaxThresholdsConfig", + groupedWithMinMaxThresholdsConfig, + ), checkRequired("itemId", itemId), modelType, checkRequired("name", name), - checkRequired("tieredWithProrationConfig", tieredWithProrationConfig), billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -17586,20 +21179,20 @@ private constructor( private var validated: Boolean = false - fun validate(): TieredWithProration = apply { + fun validate(): GroupedWithMinMaxThresholds = apply { if (validated) { return@apply } cadence().validate() + groupedWithMinMaxThresholdsConfig().validate() itemId() _modelType().let { - if (it != JsonValue.from("tiered_with_proration")) { + if (it != JsonValue.from("grouped_with_min_max_thresholds")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } name() - tieredWithProrationConfig().validate() billableMetricId() billedInAdvance() billingCycleConfiguration()?.validate() @@ -17632,12 +21225,12 @@ private constructor( */ internal fun validity(): Int = (cadence.asKnown()?.validity() ?: 0) + + (groupedWithMinMaxThresholdsConfig.asKnown()?.validity() ?: 0) + (if (itemId.asKnown() == null) 0 else 1) + modelType.let { - if (it == JsonValue.from("tiered_with_proration")) 1 else 0 + if (it == JsonValue.from("grouped_with_min_max_thresholds")) 1 else 0 } + (if (name.asKnown() == null) 0 else 1) + - (tieredWithProrationConfig.asKnown()?.validity() ?: 0) + (if (billableMetricId.asKnown() == null) 0 else 1) + (if (billedInAdvance.asKnown() == null) 0 else 1) + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + @@ -17809,40 +21402,108 @@ private constructor( override fun toString() = value.toString() } - /** Configuration for tiered_with_proration pricing */ - class TieredWithProrationConfig + /** Configuration for grouped_with_min_max_thresholds pricing */ + class GroupedWithMinMaxThresholdsConfig @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val tiers: JsonField>, + private val groupingKey: JsonField, + private val maximumCharge: JsonField, + private val minimumCharge: JsonField, + private val perUnitRate: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("tiers") + @JsonProperty("grouping_key") @ExcludeMissing - tiers: JsonField> = JsonMissing.of() - ) : this(tiers, mutableMapOf()) + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("maximum_charge") + @ExcludeMissing + maximumCharge: JsonField = JsonMissing.of(), + @JsonProperty("minimum_charge") + @ExcludeMissing + minimumCharge: JsonField = JsonMissing.of(), + @JsonProperty("per_unit_rate") + @ExcludeMissing + perUnitRate: JsonField = JsonMissing.of(), + ) : this(groupingKey, maximumCharge, minimumCharge, perUnitRate, mutableMapOf()) /** - * Tiers for rating based on total usage quantities into the specified tier with - * proration + * The event property used to group before applying thresholds * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). */ - fun tiers(): List = tiers.getRequired("tiers") + fun groupingKey(): String = groupingKey.getRequired("grouping_key") /** - * Returns the raw JSON value of [tiers]. + * The maximum amount to charge each group * - * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected - * type. + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). */ - @JsonProperty("tiers") + fun maximumCharge(): String = maximumCharge.getRequired("maximum_charge") + + /** + * The minimum amount to charge each group, regardless of usage + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun minimumCharge(): String = minimumCharge.getRequired("minimum_charge") + + /** + * The base price charged per group + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun perUnitRate(): String = perUnitRate.getRequired("per_unit_rate") + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") @ExcludeMissing - fun _tiers(): JsonField> = tiers + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [maximumCharge]. + * + * Unlike [maximumCharge], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("maximum_charge") + @ExcludeMissing + fun _maximumCharge(): JsonField = maximumCharge + + /** + * Returns the raw JSON value of [minimumCharge]. + * + * Unlike [minimumCharge], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("minimum_charge") + @ExcludeMissing + fun _minimumCharge(): JsonField = minimumCharge + + /** + * Returns the raw JSON value of [perUnitRate]. + * + * Unlike [perUnitRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("per_unit_rate") + @ExcludeMissing + fun _perUnitRate(): JsonField = perUnitRate @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -17860,58 +21521,99 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [TieredWithProrationConfig]. + * [GroupedWithMinMaxThresholdsConfig]. * * The following fields are required: * ```kotlin - * .tiers() + * .groupingKey() + * .maximumCharge() + * .minimumCharge() + * .perUnitRate() * ``` */ fun builder() = Builder() } - /** A builder for [TieredWithProrationConfig]. */ + /** A builder for [GroupedWithMinMaxThresholdsConfig]. */ class Builder internal constructor() { - private var tiers: JsonField>? = null + private var groupingKey: JsonField? = null + private var maximumCharge: JsonField? = null + private var minimumCharge: JsonField? = null + private var perUnitRate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(tieredWithProrationConfig: TieredWithProrationConfig) = - apply { - tiers = tieredWithProrationConfig.tiers.map { it.toMutableList() } - additionalProperties = - tieredWithProrationConfig.additionalProperties.toMutableMap() - } + internal fun from( + groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + ) = apply { + groupingKey = groupedWithMinMaxThresholdsConfig.groupingKey + maximumCharge = groupedWithMinMaxThresholdsConfig.maximumCharge + minimumCharge = groupedWithMinMaxThresholdsConfig.minimumCharge + perUnitRate = groupedWithMinMaxThresholdsConfig.perUnitRate + additionalProperties = + groupedWithMinMaxThresholdsConfig.additionalProperties + .toMutableMap() + } - /** - * Tiers for rating based on total usage quantities into the specified tier - * with proration - */ - fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + /** The event property used to group before applying thresholds */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) /** - * Sets [Builder.tiers] to an arbitrary JSON value. + * Sets [Builder.groupingKey] to an arbitrary JSON value. * - * You should usually call [Builder.tiers] with a well-typed `List` + * You should usually call [Builder.groupingKey] with a well-typed [String] * value instead. This method is primarily for setting the field to an * undocumented or not yet supported value. */ - fun tiers(tiers: JsonField>) = apply { - this.tiers = tiers.map { it.toMutableList() } + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey } + /** The maximum amount to charge each group */ + fun maximumCharge(maximumCharge: String) = + maximumCharge(JsonField.of(maximumCharge)) + /** - * Adds a single [Tier] to [tiers]. + * Sets [Builder.maximumCharge] to an arbitrary JSON value. * - * @throws IllegalStateException if the field was previously set to a - * non-list. + * You should usually call [Builder.maximumCharge] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. */ - fun addTier(tier: Tier) = apply { - tiers = - (tiers ?: JsonField.of(mutableListOf())).also { - checkKnown("tiers", it).add(tier) - } + fun maximumCharge(maximumCharge: JsonField) = apply { + this.maximumCharge = maximumCharge + } + + /** The minimum amount to charge each group, regardless of usage */ + fun minimumCharge(minimumCharge: String) = + minimumCharge(JsonField.of(minimumCharge)) + + /** + * Sets [Builder.minimumCharge] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumCharge] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun minimumCharge(minimumCharge: JsonField) = apply { + this.minimumCharge = minimumCharge + } + + /** The base price charged per group */ + fun perUnitRate(perUnitRate: String) = + perUnitRate(JsonField.of(perUnitRate)) + + /** + * Sets [Builder.perUnitRate] to an arbitrary JSON value. + * + * You should usually call [Builder.perUnitRate] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun perUnitRate(perUnitRate: JsonField) = apply { + this.perUnitRate = perUnitRate } fun additionalProperties(additionalProperties: Map) = @@ -17937,291 +21639,91 @@ private constructor( } /** - * Returns an immutable instance of [TieredWithProrationConfig]. + * Returns an immutable instance of [GroupedWithMinMaxThresholdsConfig]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```kotlin - * .tiers() + * .groupingKey() + * .maximumCharge() + * .minimumCharge() + * .perUnitRate() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): TieredWithProrationConfig = - TieredWithProrationConfig( - checkRequired("tiers", tiers).map { it.toImmutable() }, + fun build(): GroupedWithMinMaxThresholdsConfig = + GroupedWithMinMaxThresholdsConfig( + checkRequired("groupingKey", groupingKey), + checkRequired("maximumCharge", maximumCharge), + checkRequired("minimumCharge", minimumCharge), + checkRequired("perUnitRate", perUnitRate), additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): TieredWithProrationConfig = apply { + fun validate(): GroupedWithMinMaxThresholdsConfig = apply { if (validated) { return@apply } - tiers().forEach { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (tiers.asKnown()?.sumOf { it.validity().toInt() } ?: 0) - - /** Configuration for a single tiered with proration tier */ - class Tier - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val tierLowerBound: JsonField, - private val unitAmount: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("tier_lower_bound") - @ExcludeMissing - tierLowerBound: JsonField = JsonMissing.of(), - @JsonProperty("unit_amount") - @ExcludeMissing - unitAmount: JsonField = JsonMissing.of(), - ) : this(tierLowerBound, unitAmount, mutableMapOf()) - - /** - * Inclusive tier starting value - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type - * or is unexpectedly missing or null (e.g. if the server responded with - * an unexpected value). - */ - fun tierLowerBound(): String = - tierLowerBound.getRequired("tier_lower_bound") - - /** - * Amount per unit - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type - * or is unexpectedly missing or null (e.g. if the server responded with - * an unexpected value). - */ - fun unitAmount(): String = unitAmount.getRequired("unit_amount") - - /** - * Returns the raw JSON value of [tierLowerBound]. - * - * Unlike [tierLowerBound], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("tier_lower_bound") - @ExcludeMissing - fun _tierLowerBound(): JsonField = tierLowerBound - - /** - * Returns the raw JSON value of [unitAmount]. - * - * Unlike [unitAmount], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("unit_amount") - @ExcludeMissing - fun _unitAmount(): JsonField = unitAmount - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [Tier]. - * - * The following fields are required: - * ```kotlin - * .tierLowerBound() - * .unitAmount() - * ``` - */ - fun builder() = Builder() - } - - /** A builder for [Tier]. */ - class Builder internal constructor() { - - private var tierLowerBound: JsonField? = null - private var unitAmount: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - internal fun from(tier: Tier) = apply { - tierLowerBound = tier.tierLowerBound - unitAmount = tier.unitAmount - additionalProperties = tier.additionalProperties.toMutableMap() - } - - /** Inclusive tier starting value */ - fun tierLowerBound(tierLowerBound: String) = - tierLowerBound(JsonField.of(tierLowerBound)) - - /** - * Sets [Builder.tierLowerBound] to an arbitrary JSON value. - * - * You should usually call [Builder.tierLowerBound] with a well-typed - * [String] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun tierLowerBound(tierLowerBound: JsonField) = apply { - this.tierLowerBound = tierLowerBound - } - - /** Amount per unit */ - fun unitAmount(unitAmount: String) = - unitAmount(JsonField.of(unitAmount)) - - /** - * Sets [Builder.unitAmount] to an arbitrary JSON value. - * - * You should usually call [Builder.unitAmount] with a well-typed - * [String] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun unitAmount(unitAmount: JsonField) = apply { - this.unitAmount = unitAmount - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Tier]. - * - * Further updates to this [Builder] will not mutate the returned - * instance. - * - * The following fields are required: - * ```kotlin - * .tierLowerBound() - * .unitAmount() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Tier = - Tier( - checkRequired("tierLowerBound", tierLowerBound), - checkRequired("unitAmount", unitAmount), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Tier = apply { - if (validated) { - return@apply - } - - tierLowerBound() - unitAmount() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this - * object recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (if (tierLowerBound.asKnown() == null) 0 else 1) + - (if (unitAmount.asKnown() == null) 0 else 1) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Tier && - tierLowerBound == other.tierLowerBound && - unitAmount == other.unitAmount && - additionalProperties == other.additionalProperties - } + groupingKey() + maximumCharge() + minimumCharge() + perUnitRate() + validated = true + } - private val hashCode: Int by lazy { - Objects.hash(tierLowerBound, unitAmount, additionalProperties) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false } - override fun hashCode(): Int = hashCode - - override fun toString() = - "Tier{tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" - } + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (groupingKey.asKnown() == null) 0 else 1) + + (if (maximumCharge.asKnown() == null) 0 else 1) + + (if (minimumCharge.asKnown() == null) 0 else 1) + + (if (perUnitRate.asKnown() == null) 0 else 1) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is TieredWithProrationConfig && - tiers == other.tiers && + return other is GroupedWithMinMaxThresholdsConfig && + groupingKey == other.groupingKey && + maximumCharge == other.maximumCharge && + minimumCharge == other.minimumCharge && + perUnitRate == other.perUnitRate && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(tiers, additionalProperties) } + private val hashCode: Int by lazy { + Objects.hash( + groupingKey, + maximumCharge, + minimumCharge, + perUnitRate, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode override fun toString() = - "TieredWithProrationConfig{tiers=$tiers, additionalProperties=$additionalProperties}" + "GroupedWithMinMaxThresholdsConfig{groupingKey=$groupingKey, maximumCharge=$maximumCharge, minimumCharge=$minimumCharge, perUnitRate=$perUnitRate, additionalProperties=$additionalProperties}" } /** @@ -18338,12 +21840,13 @@ private constructor( return true } - return other is TieredWithProration && + return other is GroupedWithMinMaxThresholds && cadence == other.cadence && + groupedWithMinMaxThresholdsConfig == + other.groupedWithMinMaxThresholdsConfig && itemId == other.itemId && modelType == other.modelType && name == other.name && - tieredWithProrationConfig == other.tieredWithProrationConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && @@ -18363,10 +21866,10 @@ private constructor( private val hashCode: Int by lazy { Objects.hash( cadence, + groupedWithMinMaxThresholdsConfig, itemId, modelType, name, - tieredWithProrationConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -18387,15 +21890,15 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "TieredWithProration{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredWithProrationConfig=$tieredWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "GroupedWithMinMaxThresholds{cadence=$cadence, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class GroupedWithMinMaxThresholds + class CumulativeGroupedAllocation @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, - private val groupedWithMinMaxThresholdsConfig: - JsonField, + private val cumulativeGroupedAllocationConfig: + JsonField, private val itemId: JsonField, private val modelType: JsonValue, private val name: JsonField, @@ -18421,10 +21924,10 @@ private constructor( @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), - @JsonProperty("grouped_with_min_max_thresholds_config") + @JsonProperty("cumulative_grouped_allocation_config") @ExcludeMissing - groupedWithMinMaxThresholdsConfig: - JsonField = + cumulativeGroupedAllocationConfig: + JsonField = JsonMissing.of(), @JsonProperty("item_id") @ExcludeMissing @@ -18479,7 +21982,7 @@ private constructor( referenceId: JsonField = JsonMissing.of(), ) : this( cadence, - groupedWithMinMaxThresholdsConfig, + cumulativeGroupedAllocationConfig, itemId, modelType, name, @@ -18509,15 +22012,15 @@ private constructor( fun cadence(): Cadence = cadence.getRequired("cadence") /** - * Configuration for grouped_with_min_max_thresholds pricing + * Configuration for cumulative_grouped_allocation pricing * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected * value). */ - fun groupedWithMinMaxThresholdsConfig(): GroupedWithMinMaxThresholdsConfig = - groupedWithMinMaxThresholdsConfig.getRequired( - "grouped_with_min_max_thresholds_config" + fun cumulativeGroupedAllocationConfig(): CumulativeGroupedAllocationConfig = + cumulativeGroupedAllocationConfig.getRequired( + "cumulative_grouped_allocation_config" ) /** @@ -18534,7 +22037,7 @@ private constructor( * * Expected to always return the following: * ```kotlin - * JsonValue.from("grouped_with_min_max_thresholds") + * JsonValue.from("cumulative_grouped_allocation") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -18681,15 +22184,15 @@ private constructor( fun _cadence(): JsonField = cadence /** - * Returns the raw JSON value of [groupedWithMinMaxThresholdsConfig]. + * Returns the raw JSON value of [cumulativeGroupedAllocationConfig]. * - * Unlike [groupedWithMinMaxThresholdsConfig], this method doesn't throw if the JSON + * Unlike [cumulativeGroupedAllocationConfig], this method doesn't throw if the JSON * field has an unexpected type. */ - @JsonProperty("grouped_with_min_max_thresholds_config") + @JsonProperty("cumulative_grouped_allocation_config") @ExcludeMissing - fun _groupedWithMinMaxThresholdsConfig(): - JsonField = groupedWithMinMaxThresholdsConfig + fun _cumulativeGroupedAllocationConfig(): + JsonField = cumulativeGroupedAllocationConfig /** * Returns the raw JSON value of [itemId]. @@ -18856,12 +22359,12 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [GroupedWithMinMaxThresholds]. + * [CumulativeGroupedAllocation]. * * The following fields are required: * ```kotlin * .cadence() - * .groupedWithMinMaxThresholdsConfig() + * .cumulativeGroupedAllocationConfig() * .itemId() * .name() * ``` @@ -18869,16 +22372,16 @@ private constructor( fun builder() = Builder() } - /** A builder for [GroupedWithMinMaxThresholds]. */ + /** A builder for [CumulativeGroupedAllocation]. */ class Builder internal constructor() { private var cadence: JsonField? = null - private var groupedWithMinMaxThresholdsConfig: - JsonField? = + private var cumulativeGroupedAllocationConfig: + JsonField? = null private var itemId: JsonField? = null private var modelType: JsonValue = - JsonValue.from("grouped_with_min_max_thresholds") + JsonValue.from("cumulative_grouped_allocation") private var name: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() @@ -18901,32 +22404,32 @@ private constructor( private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds) = + internal fun from(cumulativeGroupedAllocation: CumulativeGroupedAllocation) = apply { - cadence = groupedWithMinMaxThresholds.cadence - groupedWithMinMaxThresholdsConfig = - groupedWithMinMaxThresholds.groupedWithMinMaxThresholdsConfig - itemId = groupedWithMinMaxThresholds.itemId - modelType = groupedWithMinMaxThresholds.modelType - name = groupedWithMinMaxThresholds.name - billableMetricId = groupedWithMinMaxThresholds.billableMetricId - billedInAdvance = groupedWithMinMaxThresholds.billedInAdvance + cadence = cumulativeGroupedAllocation.cadence + cumulativeGroupedAllocationConfig = + cumulativeGroupedAllocation.cumulativeGroupedAllocationConfig + itemId = cumulativeGroupedAllocation.itemId + modelType = cumulativeGroupedAllocation.modelType + name = cumulativeGroupedAllocation.name + billableMetricId = cumulativeGroupedAllocation.billableMetricId + billedInAdvance = cumulativeGroupedAllocation.billedInAdvance billingCycleConfiguration = - groupedWithMinMaxThresholds.billingCycleConfiguration - conversionRate = groupedWithMinMaxThresholds.conversionRate - conversionRateConfig = groupedWithMinMaxThresholds.conversionRateConfig - currency = groupedWithMinMaxThresholds.currency + cumulativeGroupedAllocation.billingCycleConfiguration + conversionRate = cumulativeGroupedAllocation.conversionRate + conversionRateConfig = cumulativeGroupedAllocation.conversionRateConfig + currency = cumulativeGroupedAllocation.currency dimensionalPriceConfiguration = - groupedWithMinMaxThresholds.dimensionalPriceConfiguration - externalPriceId = groupedWithMinMaxThresholds.externalPriceId - fixedPriceQuantity = groupedWithMinMaxThresholds.fixedPriceQuantity - invoiceGroupingKey = groupedWithMinMaxThresholds.invoiceGroupingKey + cumulativeGroupedAllocation.dimensionalPriceConfiguration + externalPriceId = cumulativeGroupedAllocation.externalPriceId + fixedPriceQuantity = cumulativeGroupedAllocation.fixedPriceQuantity + invoiceGroupingKey = cumulativeGroupedAllocation.invoiceGroupingKey invoicingCycleConfiguration = - groupedWithMinMaxThresholds.invoicingCycleConfiguration - metadata = groupedWithMinMaxThresholds.metadata - referenceId = groupedWithMinMaxThresholds.referenceId + cumulativeGroupedAllocation.invoicingCycleConfiguration + metadata = cumulativeGroupedAllocation.metadata + referenceId = cumulativeGroupedAllocation.referenceId additionalProperties = - groupedWithMinMaxThresholds.additionalProperties.toMutableMap() + cumulativeGroupedAllocation.additionalProperties.toMutableMap() } /** The cadence to bill for this price on. */ @@ -18941,27 +22444,27 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - /** Configuration for grouped_with_min_max_thresholds pricing */ - fun groupedWithMinMaxThresholdsConfig( - groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + /** Configuration for cumulative_grouped_allocation pricing */ + fun cumulativeGroupedAllocationConfig( + cumulativeGroupedAllocationConfig: CumulativeGroupedAllocationConfig ) = - groupedWithMinMaxThresholdsConfig( - JsonField.of(groupedWithMinMaxThresholdsConfig) + cumulativeGroupedAllocationConfig( + JsonField.of(cumulativeGroupedAllocationConfig) ) /** - * Sets [Builder.groupedWithMinMaxThresholdsConfig] to an arbitrary JSON value. + * Sets [Builder.cumulativeGroupedAllocationConfig] to an arbitrary JSON value. * - * You should usually call [Builder.groupedWithMinMaxThresholdsConfig] with a - * well-typed [GroupedWithMinMaxThresholdsConfig] value instead. This method is + * You should usually call [Builder.cumulativeGroupedAllocationConfig] with a + * well-typed [CumulativeGroupedAllocationConfig] value instead. This method is * primarily for setting the field to an undocumented or not yet supported * value. */ - fun groupedWithMinMaxThresholdsConfig( - groupedWithMinMaxThresholdsConfig: - JsonField + fun cumulativeGroupedAllocationConfig( + cumulativeGroupedAllocationConfig: + JsonField ) = apply { - this.groupedWithMinMaxThresholdsConfig = groupedWithMinMaxThresholdsConfig + this.cumulativeGroupedAllocationConfig = cumulativeGroupedAllocationConfig } /** The id of the item the price will be associated with. */ @@ -18982,7 +22485,7 @@ private constructor( * It is usually unnecessary to call this method because the field defaults to * the following: * ```kotlin - * JsonValue.from("grouped_with_min_max_thresholds") + * JsonValue.from("cumulative_grouped_allocation") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -19331,26 +22834,26 @@ private constructor( } /** - * Returns an immutable instance of [GroupedWithMinMaxThresholds]. + * Returns an immutable instance of [CumulativeGroupedAllocation]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```kotlin * .cadence() - * .groupedWithMinMaxThresholdsConfig() + * .cumulativeGroupedAllocationConfig() * .itemId() * .name() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): GroupedWithMinMaxThresholds = - GroupedWithMinMaxThresholds( + fun build(): CumulativeGroupedAllocation = + CumulativeGroupedAllocation( checkRequired("cadence", cadence), checkRequired( - "groupedWithMinMaxThresholdsConfig", - groupedWithMinMaxThresholdsConfig, + "cumulativeGroupedAllocationConfig", + cumulativeGroupedAllocationConfig, ), checkRequired("itemId", itemId), modelType, @@ -19374,16 +22877,16 @@ private constructor( private var validated: Boolean = false - fun validate(): GroupedWithMinMaxThresholds = apply { + fun validate(): CumulativeGroupedAllocation = apply { if (validated) { return@apply } cadence().validate() - groupedWithMinMaxThresholdsConfig().validate() + cumulativeGroupedAllocationConfig().validate() itemId() _modelType().let { - if (it != JsonValue.from("grouped_with_min_max_thresholds")) { + if (it != JsonValue.from("cumulative_grouped_allocation")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } @@ -19420,10 +22923,10 @@ private constructor( */ internal fun validity(): Int = (cadence.asKnown()?.validity() ?: 0) + - (groupedWithMinMaxThresholdsConfig.asKnown()?.validity() ?: 0) + + (cumulativeGroupedAllocationConfig.asKnown()?.validity() ?: 0) + (if (itemId.asKnown() == null) 0 else 1) + modelType.let { - if (it == JsonValue.from("grouped_with_min_max_thresholds")) 1 else 0 + if (it == JsonValue.from("cumulative_grouped_allocation")) 1 else 0 } + (if (name.asKnown() == null) 0 else 1) + (if (billableMetricId.asKnown() == null) 0 else 1) + @@ -19597,108 +23100,115 @@ private constructor( override fun toString() = value.toString() } - /** Configuration for grouped_with_min_max_thresholds pricing */ - class GroupedWithMinMaxThresholdsConfig + /** Configuration for cumulative_grouped_allocation pricing */ + class CumulativeGroupedAllocationConfig @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( + private val cumulativeAllocation: JsonField, + private val groupAllocation: JsonField, private val groupingKey: JsonField, - private val maximumCharge: JsonField, - private val minimumCharge: JsonField, - private val perUnitRate: JsonField, + private val unitAmount: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("grouping_key") + @JsonProperty("cumulative_allocation") @ExcludeMissing - groupingKey: JsonField = JsonMissing.of(), - @JsonProperty("maximum_charge") + cumulativeAllocation: JsonField = JsonMissing.of(), + @JsonProperty("group_allocation") @ExcludeMissing - maximumCharge: JsonField = JsonMissing.of(), - @JsonProperty("minimum_charge") + groupAllocation: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") @ExcludeMissing - minimumCharge: JsonField = JsonMissing.of(), - @JsonProperty("per_unit_rate") + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") @ExcludeMissing - perUnitRate: JsonField = JsonMissing.of(), - ) : this(groupingKey, maximumCharge, minimumCharge, perUnitRate, mutableMapOf()) + unitAmount: JsonField = JsonMissing.of(), + ) : this( + cumulativeAllocation, + groupAllocation, + groupingKey, + unitAmount, + mutableMapOf(), + ) /** - * The event property used to group before applying thresholds + * The overall allocation across all groups * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). */ - fun groupingKey(): String = groupingKey.getRequired("grouping_key") + fun cumulativeAllocation(): String = + cumulativeAllocation.getRequired("cumulative_allocation") /** - * The maximum amount to charge each group + * The allocation per individual group * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). */ - fun maximumCharge(): String = maximumCharge.getRequired("maximum_charge") + fun groupAllocation(): String = groupAllocation.getRequired("group_allocation") /** - * The minimum amount to charge each group, regardless of usage + * The event property used to group usage before applying allocations * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). */ - fun minimumCharge(): String = minimumCharge.getRequired("minimum_charge") + fun groupingKey(): String = groupingKey.getRequired("grouping_key") /** - * The base price charged per group + * The amount to charge for each unit outside of the allocation * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). */ - fun perUnitRate(): String = perUnitRate.getRequired("per_unit_rate") + fun unitAmount(): String = unitAmount.getRequired("unit_amount") /** - * Returns the raw JSON value of [groupingKey]. + * Returns the raw JSON value of [cumulativeAllocation]. * - * Unlike [groupingKey], this method doesn't throw if the JSON field has an - * unexpected type. + * Unlike [cumulativeAllocation], this method doesn't throw if the JSON field + * has an unexpected type. */ - @JsonProperty("grouping_key") + @JsonProperty("cumulative_allocation") @ExcludeMissing - fun _groupingKey(): JsonField = groupingKey + fun _cumulativeAllocation(): JsonField = cumulativeAllocation /** - * Returns the raw JSON value of [maximumCharge]. + * Returns the raw JSON value of [groupAllocation]. * - * Unlike [maximumCharge], this method doesn't throw if the JSON field has an + * Unlike [groupAllocation], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("maximum_charge") + @JsonProperty("group_allocation") @ExcludeMissing - fun _maximumCharge(): JsonField = maximumCharge + fun _groupAllocation(): JsonField = groupAllocation /** - * Returns the raw JSON value of [minimumCharge]. + * Returns the raw JSON value of [groupingKey]. * - * Unlike [minimumCharge], this method doesn't throw if the JSON field has an + * Unlike [groupingKey], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("minimum_charge") + @JsonProperty("grouping_key") @ExcludeMissing - fun _minimumCharge(): JsonField = minimumCharge + fun _groupingKey(): JsonField = groupingKey /** - * Returns the raw JSON value of [perUnitRate]. + * Returns the raw JSON value of [unitAmount]. * - * Unlike [perUnitRate], this method doesn't throw if the JSON field has an + * Unlike [unitAmount], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("per_unit_rate") + @JsonProperty("unit_amount") @ExcludeMissing - fun _perUnitRate(): JsonField = perUnitRate + fun _unitAmount(): JsonField = unitAmount @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -19716,99 +23226,99 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [GroupedWithMinMaxThresholdsConfig]. + * [CumulativeGroupedAllocationConfig]. * * The following fields are required: * ```kotlin + * .cumulativeAllocation() + * .groupAllocation() * .groupingKey() - * .maximumCharge() - * .minimumCharge() - * .perUnitRate() + * .unitAmount() * ``` */ fun builder() = Builder() } - /** A builder for [GroupedWithMinMaxThresholdsConfig]. */ + /** A builder for [CumulativeGroupedAllocationConfig]. */ class Builder internal constructor() { + private var cumulativeAllocation: JsonField? = null + private var groupAllocation: JsonField? = null private var groupingKey: JsonField? = null - private var maximumCharge: JsonField? = null - private var minimumCharge: JsonField? = null - private var perUnitRate: JsonField? = null + private var unitAmount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from( - groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + cumulativeGroupedAllocationConfig: CumulativeGroupedAllocationConfig ) = apply { - groupingKey = groupedWithMinMaxThresholdsConfig.groupingKey - maximumCharge = groupedWithMinMaxThresholdsConfig.maximumCharge - minimumCharge = groupedWithMinMaxThresholdsConfig.minimumCharge - perUnitRate = groupedWithMinMaxThresholdsConfig.perUnitRate + cumulativeAllocation = + cumulativeGroupedAllocationConfig.cumulativeAllocation + groupAllocation = cumulativeGroupedAllocationConfig.groupAllocation + groupingKey = cumulativeGroupedAllocationConfig.groupingKey + unitAmount = cumulativeGroupedAllocationConfig.unitAmount additionalProperties = - groupedWithMinMaxThresholdsConfig.additionalProperties + cumulativeGroupedAllocationConfig.additionalProperties .toMutableMap() } - /** The event property used to group before applying thresholds */ - fun groupingKey(groupingKey: String) = - groupingKey(JsonField.of(groupingKey)) + /** The overall allocation across all groups */ + fun cumulativeAllocation(cumulativeAllocation: String) = + cumulativeAllocation(JsonField.of(cumulativeAllocation)) /** - * Sets [Builder.groupingKey] to an arbitrary JSON value. + * Sets [Builder.cumulativeAllocation] to an arbitrary JSON value. * - * You should usually call [Builder.groupingKey] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. + * You should usually call [Builder.cumulativeAllocation] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. */ - fun groupingKey(groupingKey: JsonField) = apply { - this.groupingKey = groupingKey + fun cumulativeAllocation(cumulativeAllocation: JsonField) = apply { + this.cumulativeAllocation = cumulativeAllocation } - /** The maximum amount to charge each group */ - fun maximumCharge(maximumCharge: String) = - maximumCharge(JsonField.of(maximumCharge)) + /** The allocation per individual group */ + fun groupAllocation(groupAllocation: String) = + groupAllocation(JsonField.of(groupAllocation)) /** - * Sets [Builder.maximumCharge] to an arbitrary JSON value. + * Sets [Builder.groupAllocation] to an arbitrary JSON value. * - * You should usually call [Builder.maximumCharge] with a well-typed + * You should usually call [Builder.groupAllocation] with a well-typed * [String] value instead. This method is primarily for setting the field to * an undocumented or not yet supported value. */ - fun maximumCharge(maximumCharge: JsonField) = apply { - this.maximumCharge = maximumCharge + fun groupAllocation(groupAllocation: JsonField) = apply { + this.groupAllocation = groupAllocation } - /** The minimum amount to charge each group, regardless of usage */ - fun minimumCharge(minimumCharge: String) = - minimumCharge(JsonField.of(minimumCharge)) + /** The event property used to group usage before applying allocations */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) /** - * Sets [Builder.minimumCharge] to an arbitrary JSON value. + * Sets [Builder.groupingKey] to an arbitrary JSON value. * - * You should usually call [Builder.minimumCharge] with a well-typed - * [String] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. */ - fun minimumCharge(minimumCharge: JsonField) = apply { - this.minimumCharge = minimumCharge + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey } - /** The base price charged per group */ - fun perUnitRate(perUnitRate: String) = - perUnitRate(JsonField.of(perUnitRate)) + /** The amount to charge for each unit outside of the allocation */ + fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) /** - * Sets [Builder.perUnitRate] to an arbitrary JSON value. + * Sets [Builder.unitAmount] to an arbitrary JSON value. * - * You should usually call [Builder.perUnitRate] with a well-typed [String] + * You should usually call [Builder.unitAmount] with a well-typed [String] * value instead. This method is primarily for setting the field to an * undocumented or not yet supported value. */ - fun perUnitRate(perUnitRate: JsonField) = apply { - this.perUnitRate = perUnitRate + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount } fun additionalProperties(additionalProperties: Map) = @@ -19834,41 +23344,41 @@ private constructor( } /** - * Returns an immutable instance of [GroupedWithMinMaxThresholdsConfig]. + * Returns an immutable instance of [CumulativeGroupedAllocationConfig]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```kotlin + * .cumulativeAllocation() + * .groupAllocation() * .groupingKey() - * .maximumCharge() - * .minimumCharge() - * .perUnitRate() + * .unitAmount() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): GroupedWithMinMaxThresholdsConfig = - GroupedWithMinMaxThresholdsConfig( + fun build(): CumulativeGroupedAllocationConfig = + CumulativeGroupedAllocationConfig( + checkRequired("cumulativeAllocation", cumulativeAllocation), + checkRequired("groupAllocation", groupAllocation), checkRequired("groupingKey", groupingKey), - checkRequired("maximumCharge", maximumCharge), - checkRequired("minimumCharge", minimumCharge), - checkRequired("perUnitRate", perUnitRate), + checkRequired("unitAmount", unitAmount), additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): GroupedWithMinMaxThresholdsConfig = apply { + fun validate(): CumulativeGroupedAllocationConfig = apply { if (validated) { return@apply } + cumulativeAllocation() + groupAllocation() groupingKey() - maximumCharge() - minimumCharge() - perUnitRate() + unitAmount() validated = true } @@ -19887,30 +23397,30 @@ private constructor( * Used for best match union deserialization. */ internal fun validity(): Int = - (if (groupingKey.asKnown() == null) 0 else 1) + - (if (maximumCharge.asKnown() == null) 0 else 1) + - (if (minimumCharge.asKnown() == null) 0 else 1) + - (if (perUnitRate.asKnown() == null) 0 else 1) + (if (cumulativeAllocation.asKnown() == null) 0 else 1) + + (if (groupAllocation.asKnown() == null) 0 else 1) + + (if (groupingKey.asKnown() == null) 0 else 1) + + (if (unitAmount.asKnown() == null) 0 else 1) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is GroupedWithMinMaxThresholdsConfig && + return other is CumulativeGroupedAllocationConfig && + cumulativeAllocation == other.cumulativeAllocation && + groupAllocation == other.groupAllocation && groupingKey == other.groupingKey && - maximumCharge == other.maximumCharge && - minimumCharge == other.minimumCharge && - perUnitRate == other.perUnitRate && + unitAmount == other.unitAmount && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { Objects.hash( + cumulativeAllocation, + groupAllocation, groupingKey, - maximumCharge, - minimumCharge, - perUnitRate, + unitAmount, additionalProperties, ) } @@ -19918,7 +23428,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "GroupedWithMinMaxThresholdsConfig{groupingKey=$groupingKey, maximumCharge=$maximumCharge, minimumCharge=$minimumCharge, perUnitRate=$perUnitRate, additionalProperties=$additionalProperties}" + "CumulativeGroupedAllocationConfig{cumulativeAllocation=$cumulativeAllocation, groupAllocation=$groupAllocation, groupingKey=$groupingKey, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" } /** @@ -20035,10 +23545,10 @@ private constructor( return true } - return other is GroupedWithMinMaxThresholds && + return other is CumulativeGroupedAllocation && cadence == other.cadence && - groupedWithMinMaxThresholdsConfig == - other.groupedWithMinMaxThresholdsConfig && + cumulativeGroupedAllocationConfig == + other.cumulativeGroupedAllocationConfig && itemId == other.itemId && modelType == other.modelType && name == other.name && @@ -20061,7 +23571,7 @@ private constructor( private val hashCode: Int by lazy { Objects.hash( cadence, - groupedWithMinMaxThresholdsConfig, + cumulativeGroupedAllocationConfig, itemId, modelType, name, @@ -20085,7 +23595,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "GroupedWithMinMaxThresholds{cadence=$cadence, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "CumulativeGroupedAllocation{cadence=$cadence, cumulativeGroupedAllocationConfig=$cumulativeGroupedAllocationConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } class Percent diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/ChangedSubscriptionResources.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/ChangedSubscriptionResources.kt index f061ffb3a..d819c13d7 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/ChangedSubscriptionResources.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/ChangedSubscriptionResources.kt @@ -5276,6 +5276,13 @@ private constructor( fun price(cumulativeGroupedBulk: Price.CumulativeGroupedBulk) = price(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) + /** + * Alias for calling [price] with + * `Price.ofCumulativeGroupedAllocation(cumulativeGroupedAllocation)`. + */ + fun price(cumulativeGroupedAllocation: Price.CumulativeGroupedAllocation) = + price(Price.ofCumulativeGroupedAllocation(cumulativeGroupedAllocation)) + /** Alias for calling [price] with `Price.ofMinimum(minimum)`. */ fun price(minimum: Price.Minimum) = price(Price.ofMinimum(minimum)) diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Invoice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Invoice.kt index 81fe72244..d5799d974 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Invoice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Invoice.kt @@ -4763,6 +4763,13 @@ private constructor( fun price(cumulativeGroupedBulk: Price.CumulativeGroupedBulk) = price(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) + /** + * Alias for calling [price] with + * `Price.ofCumulativeGroupedAllocation(cumulativeGroupedAllocation)`. + */ + fun price(cumulativeGroupedAllocation: Price.CumulativeGroupedAllocation) = + price(Price.ofCumulativeGroupedAllocation(cumulativeGroupedAllocation)) + /** Alias for calling [price] with `Price.ofMinimum(minimum)`. */ fun price(minimum: Price.Minimum) = price(Price.ofMinimum(minimum)) diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceFetchUpcomingResponse.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceFetchUpcomingResponse.kt index dd4898800..ed4908c15 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceFetchUpcomingResponse.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceFetchUpcomingResponse.kt @@ -4757,6 +4757,13 @@ private constructor( fun price(cumulativeGroupedBulk: Price.CumulativeGroupedBulk) = price(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) + /** + * Alias for calling [price] with + * `Price.ofCumulativeGroupedAllocation(cumulativeGroupedAllocation)`. + */ + fun price(cumulativeGroupedAllocation: Price.CumulativeGroupedAllocation) = + price(Price.ofCumulativeGroupedAllocation(cumulativeGroupedAllocation)) + /** Alias for calling [price] with `Price.ofMinimum(minimum)`. */ fun price(minimum: Price.Minimum) = price(Price.ofMinimum(minimum)) diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceLineItemCreateResponse.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceLineItemCreateResponse.kt index 04d8ceaaf..de451d952 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceLineItemCreateResponse.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceLineItemCreateResponse.kt @@ -809,6 +809,13 @@ private constructor( fun price(cumulativeGroupedBulk: Price.CumulativeGroupedBulk) = price(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) + /** + * Alias for calling [price] with + * `Price.ofCumulativeGroupedAllocation(cumulativeGroupedAllocation)`. + */ + fun price(cumulativeGroupedAllocation: Price.CumulativeGroupedAllocation) = + price(Price.ofCumulativeGroupedAllocation(cumulativeGroupedAllocation)) + /** Alias for calling [price] with `Price.ofMinimum(minimum)`. */ fun price(minimum: Price.Minimum) = price(Price.ofMinimum(minimum)) diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PerPriceCost.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PerPriceCost.kt index 3b76ba194..bb91d35d3 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PerPriceCost.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PerPriceCost.kt @@ -295,6 +295,13 @@ private constructor( fun price(cumulativeGroupedBulk: Price.CumulativeGroupedBulk) = price(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) + /** + * Alias for calling [price] with + * `Price.ofCumulativeGroupedAllocation(cumulativeGroupedAllocation)`. + */ + fun price(cumulativeGroupedAllocation: Price.CumulativeGroupedAllocation) = + price(Price.ofCumulativeGroupedAllocation(cumulativeGroupedAllocation)) + /** Alias for calling [price] with `Price.ofMinimum(minimum)`. */ fun price(minimum: Price.Minimum) = price(Price.ofMinimum(minimum)) diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Plan.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Plan.kt index bd3aae981..8663ebdef 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Plan.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Plan.kt @@ -39,8 +39,6 @@ class Plan private constructor( private val id: JsonField, private val adjustments: JsonField>, - private val basePlan: JsonField, - private val basePlanId: JsonField, private val createdAt: JsonField, private val currency: JsonField, private val defaultInvoiceMemo: JsonField, @@ -61,6 +59,8 @@ private constructor( private val status: JsonField, private val trialConfig: JsonField, private val version: JsonField, + private val basePlan: JsonField, + private val basePlanId: JsonField, private val additionalProperties: MutableMap, ) { @@ -70,10 +70,6 @@ private constructor( @JsonProperty("adjustments") @ExcludeMissing adjustments: JsonField> = JsonMissing.of(), - @JsonProperty("base_plan") @ExcludeMissing basePlan: JsonField = JsonMissing.of(), - @JsonProperty("base_plan_id") - @ExcludeMissing - basePlanId: JsonField = JsonMissing.of(), @JsonProperty("created_at") @ExcludeMissing createdAt: JsonField = JsonMissing.of(), @@ -112,11 +108,13 @@ private constructor( @ExcludeMissing trialConfig: JsonField = JsonMissing.of(), @JsonProperty("version") @ExcludeMissing version: JsonField = JsonMissing.of(), + @JsonProperty("base_plan") @ExcludeMissing basePlan: JsonField = JsonMissing.of(), + @JsonProperty("base_plan_id") + @ExcludeMissing + basePlanId: JsonField = JsonMissing.of(), ) : this( id, adjustments, - basePlan, - basePlanId, createdAt, currency, defaultInvoiceMemo, @@ -137,6 +135,8 @@ private constructor( status, trialConfig, version, + basePlan, + basePlanId, mutableMapOf(), ) @@ -155,21 +155,6 @@ private constructor( */ fun adjustments(): List = adjustments.getRequired("adjustments") - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - fun basePlan(): BasePlan? = basePlan.getNullable("base_plan") - - /** - * The parent plan id if the given plan was created by overriding one or more of the parent's - * prices - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - fun basePlanId(): String? = basePlanId.getNullable("base_plan_id") - /** * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). @@ -315,6 +300,21 @@ private constructor( */ fun version(): Long = version.getRequired("version") + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun basePlan(): BasePlan? = basePlan.getNullable("base_plan") + + /** + * The parent plan id if the given plan was created by overriding one or more of the parent's + * prices + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun basePlanId(): String? = basePlanId.getNullable("base_plan_id") + /** * Returns the raw JSON value of [id]. * @@ -331,20 +331,6 @@ private constructor( @ExcludeMissing fun _adjustments(): JsonField> = adjustments - /** - * Returns the raw JSON value of [basePlan]. - * - * Unlike [basePlan], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("base_plan") @ExcludeMissing fun _basePlan(): JsonField = basePlan - - /** - * Returns the raw JSON value of [basePlanId]. - * - * Unlike [basePlanId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("base_plan_id") @ExcludeMissing fun _basePlanId(): JsonField = basePlanId - /** * Returns the raw JSON value of [createdAt]. * @@ -517,6 +503,20 @@ private constructor( */ @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version + /** + * Returns the raw JSON value of [basePlan]. + * + * Unlike [basePlan], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("base_plan") @ExcludeMissing fun _basePlan(): JsonField = basePlan + + /** + * Returns the raw JSON value of [basePlanId]. + * + * Unlike [basePlanId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("base_plan_id") @ExcludeMissing fun _basePlanId(): JsonField = basePlanId + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -538,8 +538,6 @@ private constructor( * ```kotlin * .id() * .adjustments() - * .basePlan() - * .basePlanId() * .createdAt() * .currency() * .defaultInvoiceMemo() @@ -570,8 +568,6 @@ private constructor( private var id: JsonField? = null private var adjustments: JsonField>? = null - private var basePlan: JsonField? = null - private var basePlanId: JsonField? = null private var createdAt: JsonField? = null private var currency: JsonField? = null private var defaultInvoiceMemo: JsonField? = null @@ -592,13 +588,13 @@ private constructor( private var status: JsonField? = null private var trialConfig: JsonField? = null private var version: JsonField? = null + private var basePlan: JsonField = JsonMissing.of() + private var basePlanId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() internal fun from(plan: Plan) = apply { id = plan.id adjustments = plan.adjustments.map { it.toMutableList() } - basePlan = plan.basePlan - basePlanId = plan.basePlanId createdAt = plan.createdAt currency = plan.currency defaultInvoiceMemo = plan.defaultInvoiceMemo @@ -619,6 +615,8 @@ private constructor( status = plan.status trialConfig = plan.trialConfig version = plan.version + basePlan = plan.basePlan + basePlanId = plan.basePlanId additionalProperties = plan.additionalProperties.toMutableMap() } @@ -684,32 +682,6 @@ private constructor( fun addAdjustment(maximum: PlanPhaseMaximumAdjustment) = addAdjustment(Adjustment.ofMaximum(maximum)) - fun basePlan(basePlan: BasePlan?) = basePlan(JsonField.ofNullable(basePlan)) - - /** - * Sets [Builder.basePlan] to an arbitrary JSON value. - * - * You should usually call [Builder.basePlan] with a well-typed [BasePlan] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun basePlan(basePlan: JsonField) = apply { this.basePlan = basePlan } - - /** - * The parent plan id if the given plan was created by overriding one or more of the - * parent's prices - */ - fun basePlanId(basePlanId: String?) = basePlanId(JsonField.ofNullable(basePlanId)) - - /** - * Sets [Builder.basePlanId] to an arbitrary JSON value. - * - * You should usually call [Builder.basePlanId] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun basePlanId(basePlanId: JsonField) = apply { this.basePlanId = basePlanId } - fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) /** @@ -1178,6 +1150,13 @@ private constructor( fun addPrice(cumulativeGroupedBulk: Price.CumulativeGroupedBulk) = addPrice(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) + /** + * Alias for calling [addPrice] with + * `Price.ofCumulativeGroupedAllocation(cumulativeGroupedAllocation)`. + */ + fun addPrice(cumulativeGroupedAllocation: Price.CumulativeGroupedAllocation) = + addPrice(Price.ofCumulativeGroupedAllocation(cumulativeGroupedAllocation)) + /** Alias for calling [addPrice] with `Price.ofMinimum(minimum)`. */ fun addPrice(minimum: Price.Minimum) = addPrice(Price.ofMinimum(minimum)) @@ -1230,6 +1209,32 @@ private constructor( */ fun version(version: JsonField) = apply { this.version = version } + fun basePlan(basePlan: BasePlan?) = basePlan(JsonField.ofNullable(basePlan)) + + /** + * Sets [Builder.basePlan] to an arbitrary JSON value. + * + * You should usually call [Builder.basePlan] with a well-typed [BasePlan] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun basePlan(basePlan: JsonField) = apply { this.basePlan = basePlan } + + /** + * The parent plan id if the given plan was created by overriding one or more of the + * parent's prices + */ + fun basePlanId(basePlanId: String?) = basePlanId(JsonField.ofNullable(basePlanId)) + + /** + * Sets [Builder.basePlanId] to an arbitrary JSON value. + * + * You should usually call [Builder.basePlanId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun basePlanId(basePlanId: JsonField) = apply { this.basePlanId = basePlanId } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -1258,8 +1263,6 @@ private constructor( * ```kotlin * .id() * .adjustments() - * .basePlan() - * .basePlanId() * .createdAt() * .currency() * .defaultInvoiceMemo() @@ -1288,8 +1291,6 @@ private constructor( Plan( checkRequired("id", id), checkRequired("adjustments", adjustments).map { it.toImmutable() }, - checkRequired("basePlan", basePlan), - checkRequired("basePlanId", basePlanId), checkRequired("createdAt", createdAt), checkRequired("currency", currency), checkRequired("defaultInvoiceMemo", defaultInvoiceMemo), @@ -1310,6 +1311,8 @@ private constructor( checkRequired("status", status), checkRequired("trialConfig", trialConfig), checkRequired("version", version), + basePlan, + basePlanId, additionalProperties.toMutableMap(), ) } @@ -1323,8 +1326,6 @@ private constructor( id() adjustments().forEach { it.validate() } - basePlan()?.validate() - basePlanId() createdAt() currency() defaultInvoiceMemo() @@ -1345,6 +1346,8 @@ private constructor( status().validate() trialConfig().validate() version() + basePlan()?.validate() + basePlanId() validated = true } @@ -1364,8 +1367,6 @@ private constructor( internal fun validity(): Int = (if (id.asKnown() == null) 0 else 1) + (adjustments.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + - (basePlan.asKnown()?.validity() ?: 0) + - (if (basePlanId.asKnown() == null) 0 else 1) + (if (createdAt.asKnown() == null) 0 else 1) + (if (currency.asKnown() == null) 0 else 1) + (if (defaultInvoiceMemo.asKnown() == null) 0 else 1) + @@ -1385,7 +1386,9 @@ private constructor( (product.asKnown()?.validity() ?: 0) + (status.asKnown()?.validity() ?: 0) + (trialConfig.asKnown()?.validity() ?: 0) + - (if (version.asKnown() == null) 0 else 1) + (if (version.asKnown() == null) 0 else 1) + + (basePlan.asKnown()?.validity() ?: 0) + + (if (basePlanId.asKnown() == null) 0 else 1) @JsonDeserialize(using = Adjustment.Deserializer::class) @JsonSerialize(using = Adjustment.Serializer::class) @@ -1665,249 +1668,6 @@ private constructor( } } - class BasePlan - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val id: JsonField, - private val externalPlanId: JsonField, - private val name: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), - @JsonProperty("external_plan_id") - @ExcludeMissing - externalPlanId: JsonField = JsonMissing.of(), - @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - ) : this(id, externalPlanId, name, mutableMapOf()) - - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun id(): String? = id.getNullable("id") - - /** - * An optional user-defined ID for this plan resource, used throughout the system as an - * alias for this Plan. Use this field to identify a plan by an existing identifier in your - * system. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun externalPlanId(): String? = externalPlanId.getNullable("external_plan_id") - - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun name(): String? = name.getNullable("name") - - /** - * Returns the raw JSON value of [id]. - * - * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - /** - * Returns the raw JSON value of [externalPlanId]. - * - * Unlike [externalPlanId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("external_plan_id") - @ExcludeMissing - fun _externalPlanId(): JsonField = externalPlanId - - /** - * Returns the raw JSON value of [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [BasePlan]. - * - * The following fields are required: - * ```kotlin - * .id() - * .externalPlanId() - * .name() - * ``` - */ - fun builder() = Builder() - } - - /** A builder for [BasePlan]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var externalPlanId: JsonField? = null - private var name: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(basePlan: BasePlan) = apply { - id = basePlan.id - externalPlanId = basePlan.externalPlanId - name = basePlan.name - additionalProperties = basePlan.additionalProperties.toMutableMap() - } - - fun id(id: String?) = id(JsonField.ofNullable(id)) - - /** - * Sets [Builder.id] to an arbitrary JSON value. - * - * You should usually call [Builder.id] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun id(id: JsonField) = apply { this.id = id } - - /** - * An optional user-defined ID for this plan resource, used throughout the system as an - * alias for this Plan. Use this field to identify a plan by an existing identifier in - * your system. - */ - fun externalPlanId(externalPlanId: String?) = - externalPlanId(JsonField.ofNullable(externalPlanId)) - - /** - * Sets [Builder.externalPlanId] to an arbitrary JSON value. - * - * You should usually call [Builder.externalPlanId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun externalPlanId(externalPlanId: JsonField) = apply { - this.externalPlanId = externalPlanId - } - - fun name(name: String?) = name(JsonField.ofNullable(name)) - - /** - * Sets [Builder.name] to an arbitrary JSON value. - * - * You should usually call [Builder.name] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun name(name: JsonField) = apply { this.name = name } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [BasePlan]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```kotlin - * .id() - * .externalPlanId() - * .name() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): BasePlan = - BasePlan( - checkRequired("id", id), - checkRequired("externalPlanId", externalPlanId), - checkRequired("name", name), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): BasePlan = apply { - if (validated) { - return@apply - } - - id() - externalPlanId() - name() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (if (id.asKnown() == null) 0 else 1) + - (if (externalPlanId.asKnown() == null) 0 else 1) + - (if (name.asKnown() == null) 0 else 1) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is BasePlan && - id == other.id && - externalPlanId == other.externalPlanId && - name == other.name && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(id, externalPlanId, name, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BasePlan{id=$id, externalPlanId=$externalPlanId, name=$name, additionalProperties=$additionalProperties}" - } - /** * User specified key-value pairs for the resource. If not present, this defaults to an empty * dictionary. Individual keys can be removed by setting the value to `null`, and the entire @@ -3491,6 +3251,249 @@ private constructor( "TrialConfig{trialPeriod=$trialPeriod, trialPeriodUnit=$trialPeriodUnit, additionalProperties=$additionalProperties}" } + class BasePlan + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val externalPlanId: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("external_plan_id") + @ExcludeMissing + externalPlanId: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(id, externalPlanId, name, mutableMapOf()) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun id(): String? = id.getNullable("id") + + /** + * An optional user-defined ID for this plan resource, used throughout the system as an + * alias for this Plan. Use this field to identify a plan by an existing identifier in your + * system. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun externalPlanId(): String? = externalPlanId.getNullable("external_plan_id") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun name(): String? = name.getNullable("name") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [externalPlanId]. + * + * Unlike [externalPlanId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("external_plan_id") + @ExcludeMissing + fun _externalPlanId(): JsonField = externalPlanId + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [BasePlan]. + * + * The following fields are required: + * ```kotlin + * .id() + * .externalPlanId() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [BasePlan]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var externalPlanId: JsonField? = null + private var name: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(basePlan: BasePlan) = apply { + id = basePlan.id + externalPlanId = basePlan.externalPlanId + name = basePlan.name + additionalProperties = basePlan.additionalProperties.toMutableMap() + } + + fun id(id: String?) = id(JsonField.ofNullable(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun id(id: JsonField) = apply { this.id = id } + + /** + * An optional user-defined ID for this plan resource, used throughout the system as an + * alias for this Plan. Use this field to identify a plan by an existing identifier in + * your system. + */ + fun externalPlanId(externalPlanId: String?) = + externalPlanId(JsonField.ofNullable(externalPlanId)) + + /** + * Sets [Builder.externalPlanId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPlanId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun externalPlanId(externalPlanId: JsonField) = apply { + this.externalPlanId = externalPlanId + } + + fun name(name: String?) = name(JsonField.ofNullable(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BasePlan]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .id() + * .externalPlanId() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BasePlan = + BasePlan( + checkRequired("id", id), + checkRequired("externalPlanId", externalPlanId), + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): BasePlan = apply { + if (validated) { + return@apply + } + + id() + externalPlanId() + name() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (id.asKnown() == null) 0 else 1) + + (if (externalPlanId.asKnown() == null) 0 else 1) + + (if (name.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BasePlan && + id == other.id && + externalPlanId == other.externalPlanId && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, externalPlanId, name, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BasePlan{id=$id, externalPlanId=$externalPlanId, name=$name, additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -3499,8 +3502,6 @@ private constructor( return other is Plan && id == other.id && adjustments == other.adjustments && - basePlan == other.basePlan && - basePlanId == other.basePlanId && createdAt == other.createdAt && currency == other.currency && defaultInvoiceMemo == other.defaultInvoiceMemo && @@ -3521,6 +3522,8 @@ private constructor( status == other.status && trialConfig == other.trialConfig && version == other.version && + basePlan == other.basePlan && + basePlanId == other.basePlanId && additionalProperties == other.additionalProperties } @@ -3528,8 +3531,6 @@ private constructor( Objects.hash( id, adjustments, - basePlan, - basePlanId, createdAt, currency, defaultInvoiceMemo, @@ -3550,6 +3551,8 @@ private constructor( status, trialConfig, version, + basePlan, + basePlanId, additionalProperties, ) } @@ -3557,5 +3560,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Plan{id=$id, adjustments=$adjustments, basePlan=$basePlan, basePlanId=$basePlanId, createdAt=$createdAt, currency=$currency, defaultInvoiceMemo=$defaultInvoiceMemo, description=$description, discount=$discount, externalPlanId=$externalPlanId, invoicingCurrency=$invoicingCurrency, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, name=$name, netTerms=$netTerms, planPhases=$planPhases, prices=$prices, product=$product, status=$status, trialConfig=$trialConfig, version=$version, additionalProperties=$additionalProperties}" + "Plan{id=$id, adjustments=$adjustments, createdAt=$createdAt, currency=$currency, defaultInvoiceMemo=$defaultInvoiceMemo, description=$description, discount=$discount, externalPlanId=$externalPlanId, invoicingCurrency=$invoicingCurrency, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, name=$name, netTerms=$netTerms, planPhases=$planPhases, prices=$prices, product=$product, status=$status, trialConfig=$trialConfig, version=$version, basePlan=$basePlan, basePlanId=$basePlanId, additionalProperties=$additionalProperties}" } diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanCreateParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanCreateParams.kt index 1cea98d1f..47704fef5 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanCreateParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanCreateParams.kt @@ -1469,6 +1469,13 @@ private constructor( fun price(cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice) = price(InnerPrice.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) + /** + * Alias for calling [price] with + * `InnerPrice.ofCumulativeGroupedAllocation(cumulativeGroupedAllocation)`. + */ + fun price(cumulativeGroupedAllocation: InnerPrice.CumulativeGroupedAllocation) = + price(InnerPrice.ofCumulativeGroupedAllocation(cumulativeGroupedAllocation)) + /** Alias for calling [price] with `InnerPrice.ofMinimum(minimum)`. */ fun price(minimum: NewPlanMinimumCompositePrice) = price(InnerPrice.ofMinimum(minimum)) @@ -1574,6 +1581,7 @@ private constructor( NewPlanScalableMatrixWithTieredPricingPrice? = null, private val cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice? = null, + private val cumulativeGroupedAllocation: CumulativeGroupedAllocation? = null, private val minimum: NewPlanMinimumCompositePrice? = null, private val percent: Percent? = null, private val eventOutput: EventOutput? = null, @@ -1640,6 +1648,9 @@ private constructor( fun cumulativeGroupedBulk(): NewPlanCumulativeGroupedBulkPrice? = cumulativeGroupedBulk + fun cumulativeGroupedAllocation(): CumulativeGroupedAllocation? = + cumulativeGroupedAllocation + fun minimum(): NewPlanMinimumCompositePrice? = minimum fun percent(): Percent? = percent @@ -1701,6 +1712,8 @@ private constructor( fun isCumulativeGroupedBulk(): Boolean = cumulativeGroupedBulk != null + fun isCumulativeGroupedAllocation(): Boolean = cumulativeGroupedAllocation != null + fun isMinimum(): Boolean = minimum != null fun isPercent(): Boolean = percent != null @@ -1782,6 +1795,9 @@ private constructor( fun asCumulativeGroupedBulk(): NewPlanCumulativeGroupedBulkPrice = cumulativeGroupedBulk.getOrThrow("cumulativeGroupedBulk") + fun asCumulativeGroupedAllocation(): CumulativeGroupedAllocation = + cumulativeGroupedAllocation.getOrThrow("cumulativeGroupedAllocation") + fun asMinimum(): NewPlanMinimumCompositePrice = minimum.getOrThrow("minimum") fun asPercent(): Percent = percent.getOrThrow("percent") @@ -1835,6 +1851,8 @@ private constructor( ) cumulativeGroupedBulk != null -> visitor.visitCumulativeGroupedBulk(cumulativeGroupedBulk) + cumulativeGroupedAllocation != null -> + visitor.visitCumulativeGroupedAllocation(cumulativeGroupedAllocation) minimum != null -> visitor.visitMinimum(minimum) percent != null -> visitor.visitPercent(percent) eventOutput != null -> visitor.visitEventOutput(eventOutput) @@ -1997,6 +2015,12 @@ private constructor( cumulativeGroupedBulk.validate() } + override fun visitCumulativeGroupedAllocation( + cumulativeGroupedAllocation: CumulativeGroupedAllocation + ) { + cumulativeGroupedAllocation.validate() + } + override fun visitMinimum(minimum: NewPlanMinimumCompositePrice) { minimum.validate() } @@ -2127,6 +2151,10 @@ private constructor( cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice ) = cumulativeGroupedBulk.validity() + override fun visitCumulativeGroupedAllocation( + cumulativeGroupedAllocation: CumulativeGroupedAllocation + ) = cumulativeGroupedAllocation.validity() + override fun visitMinimum(minimum: NewPlanMinimumCompositePrice) = minimum.validity() @@ -2172,6 +2200,7 @@ private constructor( scalableMatrixWithUnitPricing == other.scalableMatrixWithUnitPricing && scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && cumulativeGroupedBulk == other.cumulativeGroupedBulk && + cumulativeGroupedAllocation == other.cumulativeGroupedAllocation && minimum == other.minimum && percent == other.percent && eventOutput == other.eventOutput @@ -2206,6 +2235,7 @@ private constructor( scalableMatrixWithUnitPricing, scalableMatrixWithTieredPricing, cumulativeGroupedBulk, + cumulativeGroupedAllocation, minimum, percent, eventOutput, @@ -2254,6 +2284,8 @@ private constructor( "InnerPrice{scalableMatrixWithTieredPricing=$scalableMatrixWithTieredPricing}" cumulativeGroupedBulk != null -> "InnerPrice{cumulativeGroupedBulk=$cumulativeGroupedBulk}" + cumulativeGroupedAllocation != null -> + "InnerPrice{cumulativeGroupedAllocation=$cumulativeGroupedAllocation}" minimum != null -> "InnerPrice{minimum=$minimum}" percent != null -> "InnerPrice{percent=$percent}" eventOutput != null -> "InnerPrice{eventOutput=$eventOutput}" @@ -2349,6 +2381,10 @@ private constructor( cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice ) = InnerPrice(cumulativeGroupedBulk = cumulativeGroupedBulk) + fun ofCumulativeGroupedAllocation( + cumulativeGroupedAllocation: CumulativeGroupedAllocation + ) = InnerPrice(cumulativeGroupedAllocation = cumulativeGroupedAllocation) + fun ofMinimum(minimum: NewPlanMinimumCompositePrice) = InnerPrice(minimum = minimum) fun ofPercent(percent: Percent) = InnerPrice(percent = percent) @@ -2442,6 +2478,10 @@ private constructor( cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice ): T + fun visitCumulativeGroupedAllocation( + cumulativeGroupedAllocation: CumulativeGroupedAllocation + ): T + fun visitMinimum(minimum: NewPlanMinimumCompositePrice): T fun visitPercent(percent: Percent): T @@ -2661,6 +2701,14 @@ private constructor( ?.let { InnerPrice(cumulativeGroupedBulk = it, _json = json) } ?: InnerPrice(_json = json) } + "cumulative_grouped_allocation" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { InnerPrice(cumulativeGroupedAllocation = it, _json = json) } + ?: InnerPrice(_json = json) + } "minimum" -> { return tryDeserialize( node, @@ -2740,6 +2788,8 @@ private constructor( generator.writeObject(value.scalableMatrixWithTieredPricing) value.cumulativeGroupedBulk != null -> generator.writeObject(value.cumulativeGroupedBulk) + value.cumulativeGroupedAllocation != null -> + generator.writeObject(value.cumulativeGroupedAllocation) value.minimum != null -> generator.writeObject(value.minimum) value.percent != null -> generator.writeObject(value.percent) value.eventOutput != null -> generator.writeObject(value.eventOutput) @@ -8251,6 +8301,1711 @@ private constructor( "GroupedWithMinMaxThresholds{cadence=$cadence, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } + class CumulativeGroupedAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val cumulativeGroupedAllocationConfig: + JsonField, + private val itemId: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("cumulative_grouped_allocation_config") + @ExcludeMissing + cumulativeGroupedAllocationConfig: + JsonField = + JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + cumulativeGroupedAllocationConfig, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * Configuration for cumulative_grouped_allocation pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cumulativeGroupedAllocationConfig(): CumulativeGroupedAllocationConfig = + cumulativeGroupedAllocationConfig.getRequired( + "cumulative_grouped_allocation_config" + ) + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("cumulative_grouped_allocation") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = billableMetricId.getNullable("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + invoiceGroupingKey.getNullable("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [cumulativeGroupedAllocationConfig]. + * + * Unlike [cumulativeGroupedAllocationConfig], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("cumulative_grouped_allocation_config") + @ExcludeMissing + fun _cumulativeGroupedAllocationConfig(): + JsonField = cumulativeGroupedAllocationConfig + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [CumulativeGroupedAllocation]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .cumulativeGroupedAllocationConfig() + * .itemId() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [CumulativeGroupedAllocation]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var cumulativeGroupedAllocationConfig: + JsonField? = + null + private var itemId: JsonField? = null + private var modelType: JsonValue = + JsonValue.from("cumulative_grouped_allocation") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(cumulativeGroupedAllocation: CumulativeGroupedAllocation) = + apply { + cadence = cumulativeGroupedAllocation.cadence + cumulativeGroupedAllocationConfig = + cumulativeGroupedAllocation.cumulativeGroupedAllocationConfig + itemId = cumulativeGroupedAllocation.itemId + modelType = cumulativeGroupedAllocation.modelType + name = cumulativeGroupedAllocation.name + billableMetricId = cumulativeGroupedAllocation.billableMetricId + billedInAdvance = cumulativeGroupedAllocation.billedInAdvance + billingCycleConfiguration = + cumulativeGroupedAllocation.billingCycleConfiguration + conversionRate = cumulativeGroupedAllocation.conversionRate + conversionRateConfig = cumulativeGroupedAllocation.conversionRateConfig + currency = cumulativeGroupedAllocation.currency + dimensionalPriceConfiguration = + cumulativeGroupedAllocation.dimensionalPriceConfiguration + externalPriceId = cumulativeGroupedAllocation.externalPriceId + fixedPriceQuantity = cumulativeGroupedAllocation.fixedPriceQuantity + invoiceGroupingKey = cumulativeGroupedAllocation.invoiceGroupingKey + invoicingCycleConfiguration = + cumulativeGroupedAllocation.invoicingCycleConfiguration + metadata = cumulativeGroupedAllocation.metadata + referenceId = cumulativeGroupedAllocation.referenceId + additionalProperties = + cumulativeGroupedAllocation.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** Configuration for cumulative_grouped_allocation pricing */ + fun cumulativeGroupedAllocationConfig( + cumulativeGroupedAllocationConfig: CumulativeGroupedAllocationConfig + ) = + cumulativeGroupedAllocationConfig( + JsonField.of(cumulativeGroupedAllocationConfig) + ) + + /** + * Sets [Builder.cumulativeGroupedAllocationConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.cumulativeGroupedAllocationConfig] with a + * well-typed [CumulativeGroupedAllocationConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun cumulativeGroupedAllocationConfig( + cumulativeGroupedAllocationConfig: + JsonField + ) = apply { + this.cumulativeGroupedAllocationConfig = cumulativeGroupedAllocationConfig + } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("cumulative_grouped_allocation") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CumulativeGroupedAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .cumulativeGroupedAllocationConfig() + * .itemId() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CumulativeGroupedAllocation = + CumulativeGroupedAllocation( + checkRequired("cadence", cadence), + checkRequired( + "cumulativeGroupedAllocationConfig", + cumulativeGroupedAllocationConfig, + ), + checkRequired("itemId", itemId), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CumulativeGroupedAllocation = apply { + if (validated) { + return@apply + } + + cadence().validate() + cumulativeGroupedAllocationConfig().validate() + itemId() + _modelType().let { + if (it != JsonValue.from("cumulative_grouped_allocation")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (cumulativeGroupedAllocationConfig.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + modelType.let { + if (it == JsonValue.from("cumulative_grouped_allocation")) 1 else 0 + } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Configuration for cumulative_grouped_allocation pricing */ + class CumulativeGroupedAllocationConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cumulativeAllocation: JsonField, + private val groupAllocation: JsonField, + private val groupingKey: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cumulative_allocation") + @ExcludeMissing + cumulativeAllocation: JsonField = JsonMissing.of(), + @JsonProperty("group_allocation") + @ExcludeMissing + groupAllocation: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this( + cumulativeAllocation, + groupAllocation, + groupingKey, + unitAmount, + mutableMapOf(), + ) + + /** + * The overall allocation across all groups + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun cumulativeAllocation(): String = + cumulativeAllocation.getRequired("cumulative_allocation") + + /** + * The allocation per individual group + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun groupAllocation(): String = groupAllocation.getRequired("group_allocation") + + /** + * The event property used to group usage before applying allocations + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The amount to charge for each unit outside of the allocation + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [cumulativeAllocation]. + * + * Unlike [cumulativeAllocation], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("cumulative_allocation") + @ExcludeMissing + fun _cumulativeAllocation(): JsonField = cumulativeAllocation + + /** + * Returns the raw JSON value of [groupAllocation]. + * + * Unlike [groupAllocation], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("group_allocation") + @ExcludeMissing + fun _groupAllocation(): JsonField = groupAllocation + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [CumulativeGroupedAllocationConfig]. + * + * The following fields are required: + * ```kotlin + * .cumulativeAllocation() + * .groupAllocation() + * .groupingKey() + * .unitAmount() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [CumulativeGroupedAllocationConfig]. */ + class Builder internal constructor() { + + private var cumulativeAllocation: JsonField? = null + private var groupAllocation: JsonField? = null + private var groupingKey: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from( + cumulativeGroupedAllocationConfig: CumulativeGroupedAllocationConfig + ) = apply { + cumulativeAllocation = + cumulativeGroupedAllocationConfig.cumulativeAllocation + groupAllocation = cumulativeGroupedAllocationConfig.groupAllocation + groupingKey = cumulativeGroupedAllocationConfig.groupingKey + unitAmount = cumulativeGroupedAllocationConfig.unitAmount + additionalProperties = + cumulativeGroupedAllocationConfig.additionalProperties + .toMutableMap() + } + + /** The overall allocation across all groups */ + fun cumulativeAllocation(cumulativeAllocation: String) = + cumulativeAllocation(JsonField.of(cumulativeAllocation)) + + /** + * Sets [Builder.cumulativeAllocation] to an arbitrary JSON value. + * + * You should usually call [Builder.cumulativeAllocation] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun cumulativeAllocation(cumulativeAllocation: JsonField) = apply { + this.cumulativeAllocation = cumulativeAllocation + } + + /** The allocation per individual group */ + fun groupAllocation(groupAllocation: String) = + groupAllocation(JsonField.of(groupAllocation)) + + /** + * Sets [Builder.groupAllocation] to an arbitrary JSON value. + * + * You should usually call [Builder.groupAllocation] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun groupAllocation(groupAllocation: JsonField) = apply { + this.groupAllocation = groupAllocation + } + + /** The event property used to group usage before applying allocations */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The amount to charge for each unit outside of the allocation */ + fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CumulativeGroupedAllocationConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cumulativeAllocation() + * .groupAllocation() + * .groupingKey() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CumulativeGroupedAllocationConfig = + CumulativeGroupedAllocationConfig( + checkRequired("cumulativeAllocation", cumulativeAllocation), + checkRequired("groupAllocation", groupAllocation), + checkRequired("groupingKey", groupingKey), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CumulativeGroupedAllocationConfig = apply { + if (validated) { + return@apply + } + + cumulativeAllocation() + groupAllocation() + groupingKey() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (cumulativeAllocation.asKnown() == null) 0 else 1) + + (if (groupAllocation.asKnown() == null) 0 else 1) + + (if (groupingKey.asKnown() == null) 0 else 1) + + (if (unitAmount.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CumulativeGroupedAllocationConfig && + cumulativeAllocation == other.cumulativeAllocation && + groupAllocation == other.groupAllocation && + groupingKey == other.groupingKey && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cumulativeAllocation, + groupAllocation, + groupingKey, + unitAmount, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CumulativeGroupedAllocationConfig{cumulativeAllocation=$cumulativeAllocation, groupAllocation=$groupAllocation, groupingKey=$groupingKey, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CumulativeGroupedAllocation && + cadence == other.cadence && + cumulativeGroupedAllocationConfig == + other.cumulativeGroupedAllocationConfig && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + cumulativeGroupedAllocationConfig, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CumulativeGroupedAllocation{cadence=$cadence, cumulativeGroupedAllocationConfig=$cumulativeGroupedAllocationConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + class Percent @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanVersion.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanVersion.kt index 4959e4b7a..2e714d649 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanVersion.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanVersion.kt @@ -436,6 +436,13 @@ private constructor( fun addPrice(cumulativeGroupedBulk: Price.CumulativeGroupedBulk) = addPrice(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) + /** + * Alias for calling [addPrice] with + * `Price.ofCumulativeGroupedAllocation(cumulativeGroupedAllocation)`. + */ + fun addPrice(cumulativeGroupedAllocation: Price.CumulativeGroupedAllocation) = + addPrice(Price.ofCumulativeGroupedAllocation(cumulativeGroupedAllocation)) + /** Alias for calling [addPrice] with `Price.ofMinimum(minimum)`. */ fun addPrice(minimum: Price.Minimum) = addPrice(Price.ofMinimum(minimum)) diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Price.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Price.kt index d5f120e56..3ea2981c3 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Price.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Price.kt @@ -73,6 +73,7 @@ private constructor( private val scalableMatrixWithUnitPricing: ScalableMatrixWithUnitPricing? = null, private val scalableMatrixWithTieredPricing: ScalableMatrixWithTieredPricing? = null, private val cumulativeGroupedBulk: CumulativeGroupedBulk? = null, + private val cumulativeGroupedAllocation: CumulativeGroupedAllocation? = null, private val minimum: Minimum? = null, private val percent: Percent? = null, private val eventOutput: EventOutput? = null, @@ -135,6 +136,8 @@ private constructor( fun cumulativeGroupedBulk(): CumulativeGroupedBulk? = cumulativeGroupedBulk + fun cumulativeGroupedAllocation(): CumulativeGroupedAllocation? = cumulativeGroupedAllocation + fun minimum(): Minimum? = minimum fun percent(): Percent? = percent @@ -195,6 +198,8 @@ private constructor( fun isCumulativeGroupedBulk(): Boolean = cumulativeGroupedBulk != null + fun isCumulativeGroupedAllocation(): Boolean = cumulativeGroupedAllocation != null + fun isMinimum(): Boolean = minimum != null fun isPercent(): Boolean = percent != null @@ -269,6 +274,9 @@ private constructor( fun asCumulativeGroupedBulk(): CumulativeGroupedBulk = cumulativeGroupedBulk.getOrThrow("cumulativeGroupedBulk") + fun asCumulativeGroupedAllocation(): CumulativeGroupedAllocation = + cumulativeGroupedAllocation.getOrThrow("cumulativeGroupedAllocation") + fun asMinimum(): Minimum = minimum.getOrThrow("minimum") fun asPercent(): Percent = percent.getOrThrow("percent") @@ -316,6 +324,8 @@ private constructor( visitor.visitScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing) cumulativeGroupedBulk != null -> visitor.visitCumulativeGroupedBulk(cumulativeGroupedBulk) + cumulativeGroupedAllocation != null -> + visitor.visitCumulativeGroupedAllocation(cumulativeGroupedAllocation) minimum != null -> visitor.visitMinimum(minimum) percent != null -> visitor.visitPercent(percent) eventOutput != null -> visitor.visitEventOutput(eventOutput) @@ -459,6 +469,12 @@ private constructor( cumulativeGroupedBulk.validate() } + override fun visitCumulativeGroupedAllocation( + cumulativeGroupedAllocation: CumulativeGroupedAllocation + ) { + cumulativeGroupedAllocation.validate() + } + override fun visitMinimum(minimum: Minimum) { minimum.validate() } @@ -577,6 +593,10 @@ private constructor( cumulativeGroupedBulk: CumulativeGroupedBulk ) = cumulativeGroupedBulk.validity() + override fun visitCumulativeGroupedAllocation( + cumulativeGroupedAllocation: CumulativeGroupedAllocation + ) = cumulativeGroupedAllocation.validity() + override fun visitMinimum(minimum: Minimum) = minimum.validity() override fun visitPercent(percent: Percent) = percent.validity() @@ -620,6 +640,7 @@ private constructor( scalableMatrixWithUnitPricing == other.scalableMatrixWithUnitPricing && scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && cumulativeGroupedBulk == other.cumulativeGroupedBulk && + cumulativeGroupedAllocation == other.cumulativeGroupedAllocation && minimum == other.minimum && percent == other.percent && eventOutput == other.eventOutput @@ -654,6 +675,7 @@ private constructor( scalableMatrixWithUnitPricing, scalableMatrixWithTieredPricing, cumulativeGroupedBulk, + cumulativeGroupedAllocation, minimum, percent, eventOutput, @@ -694,6 +716,8 @@ private constructor( scalableMatrixWithTieredPricing != null -> "Price{scalableMatrixWithTieredPricing=$scalableMatrixWithTieredPricing}" cumulativeGroupedBulk != null -> "Price{cumulativeGroupedBulk=$cumulativeGroupedBulk}" + cumulativeGroupedAllocation != null -> + "Price{cumulativeGroupedAllocation=$cumulativeGroupedAllocation}" minimum != null -> "Price{minimum=$minimum}" percent != null -> "Price{percent=$percent}" eventOutput != null -> "Price{eventOutput=$eventOutput}" @@ -780,6 +804,10 @@ private constructor( fun ofCumulativeGroupedBulk(cumulativeGroupedBulk: CumulativeGroupedBulk) = Price(cumulativeGroupedBulk = cumulativeGroupedBulk) + fun ofCumulativeGroupedAllocation( + cumulativeGroupedAllocation: CumulativeGroupedAllocation + ) = Price(cumulativeGroupedAllocation = cumulativeGroupedAllocation) + fun ofMinimum(minimum: Minimum) = Price(minimum = minimum) fun ofPercent(percent: Percent) = Price(percent = percent) @@ -852,6 +880,10 @@ private constructor( fun visitCumulativeGroupedBulk(cumulativeGroupedBulk: CumulativeGroupedBulk): T + fun visitCumulativeGroupedAllocation( + cumulativeGroupedAllocation: CumulativeGroupedAllocation + ): T + fun visitMinimum(minimum: Minimum): T fun visitPercent(percent: Percent): T @@ -1014,6 +1046,11 @@ private constructor( Price(cumulativeGroupedBulk = it, _json = json) } ?: Price(_json = json) } + "cumulative_grouped_allocation" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(cumulativeGroupedAllocation = it, _json = json) } + ?: Price(_json = json) + } "minimum" -> { return tryDeserialize(node, jacksonTypeRef())?.let { Price(minimum = it, _json = json) @@ -1084,6 +1121,8 @@ private constructor( generator.writeObject(value.scalableMatrixWithTieredPricing) value.cumulativeGroupedBulk != null -> generator.writeObject(value.cumulativeGroupedBulk) + value.cumulativeGroupedAllocation != null -> + generator.writeObject(value.cumulativeGroupedAllocation) value.minimum != null -> generator.writeObject(value.minimum) value.percent != null -> generator.writeObject(value.percent) value.eventOutput != null -> generator.writeObject(value.eventOutput) @@ -76876,20 +76915,2843 @@ private constructor( } /** - * Returns an immutable instance of [Tier]. + * Returns an immutable instance of [Tier]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .tierLowerBound() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("tierLowerBound", tierLowerBound), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + tierLowerBound() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (tierLowerBound.asKnown() == null) 0 else 1) + + (if (unitAmount.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + tierLowerBound == other.tierLowerBound && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(tierLowerBound, unitAmount, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ScalableMatrixWithTieredPricingConfig && + firstDimension == other.firstDimension && + matrixScalingFactors == other.matrixScalingFactors && + tiers == other.tiers && + secondDimension == other.secondDimension && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + firstDimension, + matrixScalingFactors, + tiers, + secondDimension, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ScalableMatrixWithTieredPricingConfig{firstDimension=$firstDimension, matrixScalingFactors=$matrixScalingFactors, tiers=$tiers, secondDimension=$secondDimension, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ScalableMatrixWithTieredPricing && + id == other.id && + billableMetric == other.billableMetric && + billingCycleConfiguration == other.billingCycleConfiguration && + billingMode == other.billingMode && + cadence == other.cadence && + compositePriceFilters == other.compositePriceFilters && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + createdAt == other.createdAt && + creditAllocation == other.creditAllocation && + currency == other.currency && + discount == other.discount && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + item == other.item && + maximum == other.maximum && + maximumAmount == other.maximumAmount && + metadata == other.metadata && + minimum == other.minimum && + minimumAmount == other.minimumAmount && + modelType == other.modelType && + name == other.name && + planPhaseOrder == other.planPhaseOrder && + priceType == other.priceType && + replacesPriceId == other.replacesPriceId && + scalableMatrixWithTieredPricingConfig == + other.scalableMatrixWithTieredPricingConfig && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + billableMetric, + billingCycleConfiguration, + billingMode, + cadence, + compositePriceFilters, + conversionRate, + conversionRateConfig, + createdAt, + creditAllocation, + currency, + discount, + externalPriceId, + fixedPriceQuantity, + invoicingCycleConfiguration, + item, + maximum, + maximumAmount, + metadata, + minimum, + minimumAmount, + modelType, + name, + planPhaseOrder, + priceType, + replacesPriceId, + scalableMatrixWithTieredPricingConfig, + dimensionalPriceConfiguration, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ScalableMatrixWithTieredPricing{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, scalableMatrixWithTieredPricingConfig=$scalableMatrixWithTieredPricingConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + } + + class CumulativeGroupedBulk + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val billableMetric: JsonField, + private val billingCycleConfiguration: JsonField, + private val billingMode: JsonField, + private val cadence: JsonField, + private val compositePriceFilters: JsonField>, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val createdAt: JsonField, + private val creditAllocation: JsonField, + private val cumulativeGroupedBulkConfig: JsonField, + private val currency: JsonField, + private val discount: JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val item: JsonField, + private val maximum: JsonField, + private val maximumAmount: JsonField, + private val metadata: JsonField, + private val minimum: JsonField, + private val minimumAmount: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val planPhaseOrder: JsonField, + private val priceType: JsonField, + private val replacesPriceId: JsonField, + private val dimensionalPriceConfiguration: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric") + @ExcludeMissing + billableMetric: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("billing_mode") + @ExcludeMissing + billingMode: JsonField = JsonMissing.of(), + @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), + @JsonProperty("composite_price_filters") + @ExcludeMissing + compositePriceFilters: JsonField> = JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + createdAt: JsonField = JsonMissing.of(), + @JsonProperty("credit_allocation") + @ExcludeMissing + creditAllocation: JsonField = JsonMissing.of(), + @JsonProperty("cumulative_grouped_bulk_config") + @ExcludeMissing + cumulativeGroupedBulkConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("discount") + @ExcludeMissing + discount: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("item") @ExcludeMissing item: JsonField = JsonMissing.of(), + @JsonProperty("maximum") @ExcludeMissing maximum: JsonField = JsonMissing.of(), + @JsonProperty("maximum_amount") + @ExcludeMissing + maximumAmount: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("minimum") @ExcludeMissing minimum: JsonField = JsonMissing.of(), + @JsonProperty("minimum_amount") + @ExcludeMissing + minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("model_type") @ExcludeMissing modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("plan_phase_order") + @ExcludeMissing + planPhaseOrder: JsonField = JsonMissing.of(), + @JsonProperty("price_type") + @ExcludeMissing + priceType: JsonField = JsonMissing.of(), + @JsonProperty("replaces_price_id") + @ExcludeMissing + replacesPriceId: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + ) : this( + id, + billableMetric, + billingCycleConfiguration, + billingMode, + cadence, + compositePriceFilters, + conversionRate, + conversionRateConfig, + createdAt, + creditAllocation, + cumulativeGroupedBulkConfig, + currency, + discount, + externalPriceId, + fixedPriceQuantity, + invoicingCycleConfiguration, + item, + maximum, + maximumAmount, + metadata, + minimum, + minimumAmount, + modelType, + name, + planPhaseOrder, + priceType, + replacesPriceId, + dimensionalPriceConfiguration, + mutableMapOf(), + ) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun billableMetric(): BillableMetricTiny? = billableMetric.getNullable("billable_metric") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): BillingCycleConfiguration = + billingCycleConfiguration.getRequired("billing_cycle_configuration") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun billingMode(): BillingMode = billingMode.getRequired("billing_mode") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun compositePriceFilters(): List? = + compositePriceFilters.getNullable("composite_price_filters") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun creditAllocation(): Allocation? = creditAllocation.getNullable("credit_allocation") + + /** + * Configuration for cumulative_grouped_bulk pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun cumulativeGroupedBulkConfig(): CumulativeGroupedBulkConfig = + cumulativeGroupedBulkConfig.getRequired("cumulative_grouped_bulk_config") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + @Deprecated("deprecated") fun discount(): Discount? = discount.getNullable("discount") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): BillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * A minimal representation of an Item containing only the essential identifying + * information. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun item(): ItemSlim = item.getRequired("item") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + @Deprecated("deprecated") fun maximum(): Maximum? = maximum.getNullable("maximum") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + @Deprecated("deprecated") + fun maximumAmount(): String? = maximumAmount.getNullable("maximum_amount") + + /** + * User specified key-value pairs for the resource. If not present, this defaults to an + * empty dictionary. Individual keys can be removed by setting the value to `null`, and the + * entire metadata mapping can be cleared by setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun metadata(): Metadata = metadata.getRequired("metadata") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + @Deprecated("deprecated") fun minimum(): Minimum? = minimum.getNullable("minimum") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + @Deprecated("deprecated") + fun minimumAmount(): String? = minimumAmount.getNullable("minimum_amount") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("cumulative_grouped_bulk") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun name(): String = name.getRequired("name") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun planPhaseOrder(): Long? = planPhaseOrder.getNullable("plan_phase_order") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun priceType(): PriceType = priceType.getRequired("price_type") + + /** + * The price id this price replaces. This price will take the place of the replaced price in + * plan version migrations. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun replacesPriceId(): String? = replacesPriceId.getNullable("replaces_price_id") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): DimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [billableMetric]. + * + * Unlike [billableMetric], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("billable_metric") + @ExcludeMissing + fun _billableMetric(): JsonField = billableMetric + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [billingMode]. + * + * Unlike [billingMode], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("billing_mode") + @ExcludeMissing + fun _billingMode(): JsonField = billingMode + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [compositePriceFilters]. + * + * Unlike [compositePriceFilters], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("composite_price_filters") + @ExcludeMissing + fun _compositePriceFilters(): JsonField> = compositePriceFilters + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [createdAt]. + * + * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt + + /** + * Returns the raw JSON value of [creditAllocation]. + * + * Unlike [creditAllocation], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("credit_allocation") + @ExcludeMissing + fun _creditAllocation(): JsonField = creditAllocation + + /** + * Returns the raw JSON value of [cumulativeGroupedBulkConfig]. + * + * Unlike [cumulativeGroupedBulkConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("cumulative_grouped_bulk_config") + @ExcludeMissing + fun _cumulativeGroupedBulkConfig(): JsonField = + cumulativeGroupedBulkConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [discount]. + * + * Unlike [discount], this method doesn't throw if the JSON field has an unexpected type. + */ + @Deprecated("deprecated") + @JsonProperty("discount") + @ExcludeMissing + fun _discount(): JsonField = discount + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [item]. + * + * Unlike [item], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("item") @ExcludeMissing fun _item(): JsonField = item + + /** + * Returns the raw JSON value of [maximum]. + * + * Unlike [maximum], this method doesn't throw if the JSON field has an unexpected type. + */ + @Deprecated("deprecated") + @JsonProperty("maximum") + @ExcludeMissing + fun _maximum(): JsonField = maximum + + /** + * Returns the raw JSON value of [maximumAmount]. + * + * Unlike [maximumAmount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @Deprecated("deprecated") + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [minimum]. + * + * Unlike [minimum], this method doesn't throw if the JSON field has an unexpected type. + */ + @Deprecated("deprecated") + @JsonProperty("minimum") + @ExcludeMissing + fun _minimum(): JsonField = minimum + + /** + * Returns the raw JSON value of [minimumAmount]. + * + * Unlike [minimumAmount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @Deprecated("deprecated") + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [planPhaseOrder]. + * + * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder + + /** + * Returns the raw JSON value of [priceType]. + * + * Unlike [priceType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("price_type") + @ExcludeMissing + fun _priceType(): JsonField = priceType + + /** + * Returns the raw JSON value of [replacesPriceId]. + * + * Unlike [replacesPriceId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("replaces_price_id") + @ExcludeMissing + fun _replacesPriceId(): JsonField = replacesPriceId + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [CumulativeGroupedBulk]. + * + * The following fields are required: + * ```kotlin + * .id() + * .billableMetric() + * .billingCycleConfiguration() + * .billingMode() + * .cadence() + * .compositePriceFilters() + * .conversionRate() + * .conversionRateConfig() + * .createdAt() + * .creditAllocation() + * .cumulativeGroupedBulkConfig() + * .currency() + * .discount() + * .externalPriceId() + * .fixedPriceQuantity() + * .invoicingCycleConfiguration() + * .item() + * .maximum() + * .maximumAmount() + * .metadata() + * .minimum() + * .minimumAmount() + * .name() + * .planPhaseOrder() + * .priceType() + * .replacesPriceId() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [CumulativeGroupedBulk]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var billableMetric: JsonField? = null + private var billingCycleConfiguration: JsonField? = null + private var billingMode: JsonField? = null + private var cadence: JsonField? = null + private var compositePriceFilters: JsonField>? = null + private var conversionRate: JsonField? = null + private var conversionRateConfig: JsonField? = null + private var createdAt: JsonField? = null + private var creditAllocation: JsonField? = null + private var cumulativeGroupedBulkConfig: JsonField? = null + private var currency: JsonField? = null + private var discount: JsonField? = null + private var externalPriceId: JsonField? = null + private var fixedPriceQuantity: JsonField? = null + private var invoicingCycleConfiguration: JsonField? = null + private var item: JsonField? = null + private var maximum: JsonField? = null + private var maximumAmount: JsonField? = null + private var metadata: JsonField? = null + private var minimum: JsonField? = null + private var minimumAmount: JsonField? = null + private var modelType: JsonValue = JsonValue.from("cumulative_grouped_bulk") + private var name: JsonField? = null + private var planPhaseOrder: JsonField? = null + private var priceType: JsonField? = null + private var replacesPriceId: JsonField? = null + private var dimensionalPriceConfiguration: JsonField = + JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(cumulativeGroupedBulk: CumulativeGroupedBulk) = apply { + id = cumulativeGroupedBulk.id + billableMetric = cumulativeGroupedBulk.billableMetric + billingCycleConfiguration = cumulativeGroupedBulk.billingCycleConfiguration + billingMode = cumulativeGroupedBulk.billingMode + cadence = cumulativeGroupedBulk.cadence + compositePriceFilters = + cumulativeGroupedBulk.compositePriceFilters.map { it.toMutableList() } + conversionRate = cumulativeGroupedBulk.conversionRate + conversionRateConfig = cumulativeGroupedBulk.conversionRateConfig + createdAt = cumulativeGroupedBulk.createdAt + creditAllocation = cumulativeGroupedBulk.creditAllocation + cumulativeGroupedBulkConfig = cumulativeGroupedBulk.cumulativeGroupedBulkConfig + currency = cumulativeGroupedBulk.currency + discount = cumulativeGroupedBulk.discount + externalPriceId = cumulativeGroupedBulk.externalPriceId + fixedPriceQuantity = cumulativeGroupedBulk.fixedPriceQuantity + invoicingCycleConfiguration = cumulativeGroupedBulk.invoicingCycleConfiguration + item = cumulativeGroupedBulk.item + maximum = cumulativeGroupedBulk.maximum + maximumAmount = cumulativeGroupedBulk.maximumAmount + metadata = cumulativeGroupedBulk.metadata + minimum = cumulativeGroupedBulk.minimum + minimumAmount = cumulativeGroupedBulk.minimumAmount + modelType = cumulativeGroupedBulk.modelType + name = cumulativeGroupedBulk.name + planPhaseOrder = cumulativeGroupedBulk.planPhaseOrder + priceType = cumulativeGroupedBulk.priceType + replacesPriceId = cumulativeGroupedBulk.replacesPriceId + dimensionalPriceConfiguration = cumulativeGroupedBulk.dimensionalPriceConfiguration + additionalProperties = cumulativeGroupedBulk.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun id(id: JsonField) = apply { this.id = id } + + fun billableMetric(billableMetric: BillableMetricTiny?) = + billableMetric(JsonField.ofNullable(billableMetric)) + + /** + * Sets [Builder.billableMetric] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetric] with a well-typed + * [BillableMetricTiny] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun billableMetric(billableMetric: JsonField) = apply { + this.billableMetric = billableMetric + } + + fun billingCycleConfiguration(billingCycleConfiguration: BillingCycleConfiguration) = + billingCycleConfiguration(JsonField.of(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [BillingCycleConfiguration] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + fun billingMode(billingMode: BillingMode) = billingMode(JsonField.of(billingMode)) + + /** + * Sets [Builder.billingMode] to an arbitrary JSON value. + * + * You should usually call [Builder.billingMode] with a well-typed [BillingMode] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun billingMode(billingMode: JsonField) = apply { + this.billingMode = billingMode + } + + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + fun compositePriceFilters(compositePriceFilters: List?) = + compositePriceFilters(JsonField.ofNullable(compositePriceFilters)) + + /** + * Sets [Builder.compositePriceFilters] to an arbitrary JSON value. + * + * You should usually call [Builder.compositePriceFilters] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun compositePriceFilters( + compositePriceFilters: JsonField> + ) = apply { + this.compositePriceFilters = compositePriceFilters.map { it.toMutableList() } + } + + /** + * Adds a single [CompositePriceFilter] to [compositePriceFilters]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addCompositePriceFilter(compositePriceFilter: CompositePriceFilter) = apply { + compositePriceFilters = + (compositePriceFilters ?: JsonField.of(mutableListOf())).also { + checkKnown("compositePriceFilters", it).add(compositePriceFilter) + } + } + + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun conversionRateConfig(conversionRateConfig: JsonField) = + apply { + this.conversionRateConfig = conversionRateConfig + } + + /** + * Alias for calling [conversionRateConfig] with `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + .tieredConfig(tieredConfig) + .build() + ) + + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + + /** + * Sets [Builder.createdAt] to an arbitrary JSON value. + * + * You should usually call [Builder.createdAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun createdAt(createdAt: JsonField) = apply { + this.createdAt = createdAt + } + + fun creditAllocation(creditAllocation: Allocation?) = + creditAllocation(JsonField.ofNullable(creditAllocation)) + + /** + * Sets [Builder.creditAllocation] to an arbitrary JSON value. + * + * You should usually call [Builder.creditAllocation] with a well-typed [Allocation] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun creditAllocation(creditAllocation: JsonField) = apply { + this.creditAllocation = creditAllocation + } + + /** Configuration for cumulative_grouped_bulk pricing */ + fun cumulativeGroupedBulkConfig( + cumulativeGroupedBulkConfig: CumulativeGroupedBulkConfig + ) = cumulativeGroupedBulkConfig(JsonField.of(cumulativeGroupedBulkConfig)) + + /** + * Sets [Builder.cumulativeGroupedBulkConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.cumulativeGroupedBulkConfig] with a well-typed + * [CumulativeGroupedBulkConfig] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun cumulativeGroupedBulkConfig( + cumulativeGroupedBulkConfig: JsonField + ) = apply { this.cumulativeGroupedBulkConfig = cumulativeGroupedBulkConfig } + + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + @Deprecated("deprecated") + fun discount(discount: Discount?) = discount(JsonField.ofNullable(discount)) + + /** + * Sets [Builder.discount] to an arbitrary JSON value. + * + * You should usually call [Builder.discount] with a well-typed [Discount] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + @Deprecated("deprecated") + fun discount(discount: JsonField) = apply { this.discount = discount } + + /** Alias for calling [discount] with `Discount.ofPercentage(percentage)`. */ + @Deprecated("deprecated") + fun discount(percentage: PercentageDiscount) = + discount(Discount.ofPercentage(percentage)) + + /** + * Alias for calling [discount] with the following: + * ```kotlin + * PercentageDiscount.builder() + * .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + * .percentageDiscount(percentageDiscount) + * .build() + * ``` + */ + @Deprecated("deprecated") + fun percentageDiscount(percentageDiscount: Double) = + discount( + PercentageDiscount.builder() + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(percentageDiscount) + .build() + ) + + /** Alias for calling [discount] with `Discount.ofTrial(trial)`. */ + @Deprecated("deprecated") + fun discount(trial: TrialDiscount) = discount(Discount.ofTrial(trial)) + + /** Alias for calling [discount] with `Discount.ofUsage(usage)`. */ + @Deprecated("deprecated") + fun discount(usage: UsageDiscount) = discount(Discount.ofUsage(usage)) + + /** + * Alias for calling [discount] with the following: + * ```kotlin + * UsageDiscount.builder() + * .discountType(UsageDiscount.DiscountType.USAGE) + * .usageDiscount(usageDiscount) + * .build() + * ``` + */ + @Deprecated("deprecated") + fun usageDiscount(usageDiscount: Double) = + discount( + UsageDiscount.builder() + .discountType(UsageDiscount.DiscountType.USAGE) + .usageDiscount(usageDiscount) + .build() + ) + + /** Alias for calling [discount] with `Discount.ofAmount(amount)`. */ + @Deprecated("deprecated") + fun discount(amount: AmountDiscount) = discount(Discount.ofAmount(amount)) + + /** + * Alias for calling [discount] with the following: + * ```kotlin + * AmountDiscount.builder() + * .discountType(AmountDiscount.DiscountType.AMOUNT) + * .amountDiscount(amountDiscount) + * .build() + * ``` + */ + @Deprecated("deprecated") + fun amountDiscount(amountDiscount: String) = + discount( + AmountDiscount.builder() + .discountType(AmountDiscount.DiscountType.AMOUNT) + .amountDiscount(amountDiscount) + .build() + ) + + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: BillingCycleConfiguration? + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a well-typed + * [BillingCycleConfiguration] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** + * A minimal representation of an Item containing only the essential identifying + * information. + */ + fun item(item: ItemSlim) = item(JsonField.of(item)) + + /** + * Sets [Builder.item] to an arbitrary JSON value. + * + * You should usually call [Builder.item] with a well-typed [ItemSlim] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun item(item: JsonField) = apply { this.item = item } + + @Deprecated("deprecated") + fun maximum(maximum: Maximum?) = maximum(JsonField.ofNullable(maximum)) + + /** + * Sets [Builder.maximum] to an arbitrary JSON value. + * + * You should usually call [Builder.maximum] with a well-typed [Maximum] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + @Deprecated("deprecated") + fun maximum(maximum: JsonField) = apply { this.maximum = maximum } + + @Deprecated("deprecated") + fun maximumAmount(maximumAmount: String?) = + maximumAmount(JsonField.ofNullable(maximumAmount)) + + /** + * Sets [Builder.maximumAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.maximumAmount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + @Deprecated("deprecated") + fun maximumAmount(maximumAmount: JsonField) = apply { + this.maximumAmount = maximumAmount + } + + /** + * User specified key-value pairs for the resource. If not present, this defaults to an + * empty dictionary. Individual keys can be removed by setting the value to `null`, and + * the entire metadata mapping can be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + @Deprecated("deprecated") + fun minimum(minimum: Minimum?) = minimum(JsonField.ofNullable(minimum)) + + /** + * Sets [Builder.minimum] to an arbitrary JSON value. + * + * You should usually call [Builder.minimum] with a well-typed [Minimum] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + @Deprecated("deprecated") + fun minimum(minimum: JsonField) = apply { this.minimum = minimum } + + @Deprecated("deprecated") + fun minimumAmount(minimumAmount: String?) = + minimumAmount(JsonField.ofNullable(minimumAmount)) + + /** + * Sets [Builder.minimumAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumAmount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + @Deprecated("deprecated") + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```kotlin + * JsonValue.from("cumulative_grouped_bulk") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + + /** + * Alias for [Builder.planPhaseOrder]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + + /** + * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. + * + * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun planPhaseOrder(planPhaseOrder: JsonField) = apply { + this.planPhaseOrder = planPhaseOrder + } + + fun priceType(priceType: PriceType) = priceType(JsonField.of(priceType)) + + /** + * Sets [Builder.priceType] to an arbitrary JSON value. + * + * You should usually call [Builder.priceType] with a well-typed [PriceType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun priceType(priceType: JsonField) = apply { this.priceType = priceType } + + /** + * The price id this price replaces. This price will take the place of the replaced + * price in plan version migrations. + */ + fun replacesPriceId(replacesPriceId: String?) = + replacesPriceId(JsonField.ofNullable(replacesPriceId)) + + /** + * Sets [Builder.replacesPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.replacesPriceId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun replacesPriceId(replacesPriceId: JsonField) = apply { + this.replacesPriceId = replacesPriceId + } + + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: DimensionalPriceConfiguration? + ) = dimensionalPriceConfiguration(JsonField.ofNullable(dimensionalPriceConfiguration)) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a well-typed + * [DimensionalPriceConfiguration] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CumulativeGroupedBulk]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .id() + * .billableMetric() + * .billingCycleConfiguration() + * .billingMode() + * .cadence() + * .compositePriceFilters() + * .conversionRate() + * .conversionRateConfig() + * .createdAt() + * .creditAllocation() + * .cumulativeGroupedBulkConfig() + * .currency() + * .discount() + * .externalPriceId() + * .fixedPriceQuantity() + * .invoicingCycleConfiguration() + * .item() + * .maximum() + * .maximumAmount() + * .metadata() + * .minimum() + * .minimumAmount() + * .name() + * .planPhaseOrder() + * .priceType() + * .replacesPriceId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CumulativeGroupedBulk = + CumulativeGroupedBulk( + checkRequired("id", id), + checkRequired("billableMetric", billableMetric), + checkRequired("billingCycleConfiguration", billingCycleConfiguration), + checkRequired("billingMode", billingMode), + checkRequired("cadence", cadence), + checkRequired("compositePriceFilters", compositePriceFilters).map { + it.toImmutable() + }, + checkRequired("conversionRate", conversionRate), + checkRequired("conversionRateConfig", conversionRateConfig), + checkRequired("createdAt", createdAt), + checkRequired("creditAllocation", creditAllocation), + checkRequired("cumulativeGroupedBulkConfig", cumulativeGroupedBulkConfig), + checkRequired("currency", currency), + checkRequired("discount", discount), + checkRequired("externalPriceId", externalPriceId), + checkRequired("fixedPriceQuantity", fixedPriceQuantity), + checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), + checkRequired("item", item), + checkRequired("maximum", maximum), + checkRequired("maximumAmount", maximumAmount), + checkRequired("metadata", metadata), + checkRequired("minimum", minimum), + checkRequired("minimumAmount", minimumAmount), + modelType, + checkRequired("name", name), + checkRequired("planPhaseOrder", planPhaseOrder), + checkRequired("priceType", priceType), + checkRequired("replacesPriceId", replacesPriceId), + dimensionalPriceConfiguration, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CumulativeGroupedBulk = apply { + if (validated) { + return@apply + } + + id() + billableMetric()?.validate() + billingCycleConfiguration().validate() + billingMode().validate() + cadence().validate() + compositePriceFilters()?.forEach { it.validate() } + conversionRate() + conversionRateConfig()?.validate() + createdAt() + creditAllocation()?.validate() + cumulativeGroupedBulkConfig().validate() + currency() + discount()?.validate() + externalPriceId() + fixedPriceQuantity() + invoicingCycleConfiguration()?.validate() + item().validate() + maximum()?.validate() + maximumAmount() + metadata().validate() + minimum()?.validate() + minimumAmount() + _modelType().let { + if (it != JsonValue.from("cumulative_grouped_bulk")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + planPhaseOrder() + priceType().validate() + replacesPriceId() + dimensionalPriceConfiguration()?.validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (id.asKnown() == null) 0 else 1) + + (billableMetric.asKnown()?.validity() ?: 0) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (billingMode.asKnown()?.validity() ?: 0) + + (cadence.asKnown()?.validity() ?: 0) + + (compositePriceFilters.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (createdAt.asKnown() == null) 0 else 1) + + (creditAllocation.asKnown()?.validity() ?: 0) + + (cumulativeGroupedBulkConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (discount.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (item.asKnown()?.validity() ?: 0) + + (maximum.asKnown()?.validity() ?: 0) + + (if (maximumAmount.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (minimum.asKnown()?.validity() ?: 0) + + (if (minimumAmount.asKnown() == null) 0 else 1) + + modelType.let { if (it == JsonValue.from("cumulative_grouped_bulk")) 1 else 0 } + + (if (name.asKnown() == null) 0 else 1) + + (if (planPhaseOrder.asKnown() == null) 0 else 1) + + (priceType.asKnown()?.validity() ?: 0) + + (if (replacesPriceId.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + class BillingMode @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val IN_ADVANCE = of("in_advance") + + val IN_ARREAR = of("in_arrear") + + fun of(value: String) = BillingMode(JsonField.of(value)) + } + + /** An enum containing [BillingMode]'s known values. */ + enum class Known { + IN_ADVANCE, + IN_ARREAR, + } + + /** + * An enum containing [BillingMode]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [BillingMode] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + IN_ADVANCE, + IN_ARREAR, + /** + * An enum member indicating that [BillingMode] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + IN_ADVANCE -> Value.IN_ADVANCE + IN_ARREAR -> Value.IN_ARREAR + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + IN_ADVANCE -> Known.IN_ADVANCE + IN_ARREAR -> Known.IN_ARREAR + else -> throw OrbInvalidDataException("Unknown BillingMode: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): BillingMode = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BillingMode && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class Cadence @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val ONE_TIME = of("one_time") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val SEMI_ANNUAL = of("semi_annual") + + val ANNUAL = of("annual") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ONE_TIME, + MONTHLY, + QUARTERLY, + SEMI_ANNUAL, + ANNUAL, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ONE_TIME, + MONTHLY, + QUARTERLY, + SEMI_ANNUAL, + ANNUAL, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ONE_TIME -> Value.ONE_TIME + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + SEMI_ANNUAL -> Value.SEMI_ANNUAL + ANNUAL -> Value.ANNUAL + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + ONE_TIME -> Known.ONE_TIME + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + SEMI_ANNUAL -> Known.SEMI_ANNUAL + ANNUAL -> Known.ANNUAL + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class CompositePriceFilter + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val field: JsonField, + private val operator: JsonField, + private val values: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("field") @ExcludeMissing field: JsonField = JsonMissing.of(), + @JsonProperty("operator") + @ExcludeMissing + operator: JsonField = JsonMissing.of(), + @JsonProperty("values") + @ExcludeMissing + values: JsonField> = JsonMissing.of(), + ) : this(field, operator, values, mutableMapOf()) + + /** + * The property of the price to filter on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun field(): Field = field.getRequired("field") + + /** + * Should prices that match the filter be included or excluded. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun operator(): Operator = operator.getRequired("operator") + + /** + * The IDs or values that match this filter. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun values(): List = values.getRequired("values") + + /** + * Returns the raw JSON value of [field]. + * + * Unlike [field], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("field") @ExcludeMissing fun _field(): JsonField = field + + /** + * Returns the raw JSON value of [operator]. + * + * Unlike [operator], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("operator") + @ExcludeMissing + fun _operator(): JsonField = operator + + /** + * Returns the raw JSON value of [values]. + * + * Unlike [values], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("values") @ExcludeMissing fun _values(): JsonField> = values + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [CompositePriceFilter]. + * + * The following fields are required: + * ```kotlin + * .field() + * .operator() + * .values() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [CompositePriceFilter]. */ + class Builder internal constructor() { + + private var field: JsonField? = null + private var operator: JsonField? = null + private var values: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(compositePriceFilter: CompositePriceFilter) = apply { + field = compositePriceFilter.field + operator = compositePriceFilter.operator + values = compositePriceFilter.values.map { it.toMutableList() } + additionalProperties = compositePriceFilter.additionalProperties.toMutableMap() + } + + /** The property of the price to filter on. */ + fun field(field: Field) = field(JsonField.of(field)) + + /** + * Sets [Builder.field] to an arbitrary JSON value. + * + * You should usually call [Builder.field] with a well-typed [Field] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun field(field: JsonField) = apply { this.field = field } + + /** Should prices that match the filter be included or excluded. */ + fun operator(operator: Operator) = operator(JsonField.of(operator)) + + /** + * Sets [Builder.operator] to an arbitrary JSON value. + * + * You should usually call [Builder.operator] with a well-typed [Operator] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun operator(operator: JsonField) = apply { this.operator = operator } + + /** The IDs or values that match this filter. */ + fun values(values: List) = values(JsonField.of(values)) + + /** + * Sets [Builder.values] to an arbitrary JSON value. + * + * You should usually call [Builder.values] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun values(values: JsonField>) = apply { + this.values = values.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [values]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addValue(value: String) = apply { + values = + (values ?: JsonField.of(mutableListOf())).also { + checkKnown("values", it).add(value) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CompositePriceFilter]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .field() + * .operator() + * .values() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CompositePriceFilter = + CompositePriceFilter( + checkRequired("field", field), + checkRequired("operator", operator), + checkRequired("values", values).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CompositePriceFilter = apply { + if (validated) { + return@apply + } + + field().validate() + operator().validate() + values() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (field.asKnown()?.validity() ?: 0) + + (operator.asKnown()?.validity() ?: 0) + + (values.asKnown()?.size ?: 0) + + /** The property of the price to filter on. */ + class Field @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val PRICE_ID = of("price_id") + + val ITEM_ID = of("item_id") + + val PRICE_TYPE = of("price_type") + + val CURRENCY = of("currency") + + val PRICING_UNIT_ID = of("pricing_unit_id") + + fun of(value: String) = Field(JsonField.of(value)) + } + + /** An enum containing [Field]'s known values. */ + enum class Known { + PRICE_ID, + ITEM_ID, + PRICE_TYPE, + CURRENCY, + PRICING_UNIT_ID, + } + + /** + * An enum containing [Field]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Field] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + PRICE_ID, + ITEM_ID, + PRICE_TYPE, + CURRENCY, + PRICING_UNIT_ID, + /** + * An enum member indicating that [Field] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + PRICE_ID -> Value.PRICE_ID + ITEM_ID -> Value.ITEM_ID + PRICE_TYPE -> Value.PRICE_TYPE + CURRENCY -> Value.CURRENCY + PRICING_UNIT_ID -> Value.PRICING_UNIT_ID + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + PRICE_ID -> Known.PRICE_ID + ITEM_ID -> Known.ITEM_ID + PRICE_TYPE -> Known.PRICE_TYPE + CURRENCY -> Known.CURRENCY + PRICING_UNIT_ID -> Known.PRICING_UNIT_ID + else -> throw OrbInvalidDataException("Unknown Field: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Field = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Field && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Should prices that match the filter be included or excluded. */ + class Operator @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val INCLUDES = of("includes") + + val EXCLUDES = of("excludes") + + fun of(value: String) = Operator(JsonField.of(value)) + } + + /** An enum containing [Operator]'s known values. */ + enum class Known { + INCLUDES, + EXCLUDES, + } + + /** + * An enum containing [Operator]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Operator] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + INCLUDES, + EXCLUDES, + /** + * An enum member indicating that [Operator] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + INCLUDES -> Value.INCLUDES + EXCLUDES -> Value.EXCLUDES + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + INCLUDES -> Known.INCLUDES + EXCLUDES -> Known.EXCLUDES + else -> throw OrbInvalidDataException("Unknown Operator: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Operator = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Operator && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CompositePriceFilter && + field == other.field && + operator == other.operator && + values == other.values && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(field, operator, values, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CompositePriceFilter{field=$field, operator=$operator, values=$values, additionalProperties=$additionalProperties}" + } + + /** Configuration for cumulative_grouped_bulk pricing */ + class CumulativeGroupedBulkConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val dimensionValues: JsonField>, + private val group: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("dimension_values") + @ExcludeMissing + dimensionValues: JsonField> = JsonMissing.of(), + @JsonProperty("group") @ExcludeMissing group: JsonField = JsonMissing.of(), + ) : this(dimensionValues, group, mutableMapOf()) + + /** + * Each tier lower bound must have the same group of values. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun dimensionValues(): List = + dimensionValues.getRequired("dimension_values") + + /** + * Grouping key name + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun group(): String = group.getRequired("group") + + /** + * Returns the raw JSON value of [dimensionValues]. + * + * Unlike [dimensionValues], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("dimension_values") + @ExcludeMissing + fun _dimensionValues(): JsonField> = dimensionValues + + /** + * Returns the raw JSON value of [group]. + * + * Unlike [group], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("group") @ExcludeMissing fun _group(): JsonField = group + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [CumulativeGroupedBulkConfig]. + * + * The following fields are required: + * ```kotlin + * .dimensionValues() + * .group() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [CumulativeGroupedBulkConfig]. */ + class Builder internal constructor() { + + private var dimensionValues: JsonField>? = null + private var group: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(cumulativeGroupedBulkConfig: CumulativeGroupedBulkConfig) = + apply { + dimensionValues = + cumulativeGroupedBulkConfig.dimensionValues.map { it.toMutableList() } + group = cumulativeGroupedBulkConfig.group + additionalProperties = + cumulativeGroupedBulkConfig.additionalProperties.toMutableMap() + } + + /** Each tier lower bound must have the same group of values. */ + fun dimensionValues(dimensionValues: List) = + dimensionValues(JsonField.of(dimensionValues)) + + /** + * Sets [Builder.dimensionValues] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionValues] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun dimensionValues(dimensionValues: JsonField>) = apply { + this.dimensionValues = dimensionValues.map { it.toMutableList() } + } + + /** + * Adds a single [DimensionValue] to [dimensionValues]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addDimensionValue(dimensionValue: DimensionValue) = apply { + dimensionValues = + (dimensionValues ?: JsonField.of(mutableListOf())).also { + checkKnown("dimensionValues", it).add(dimensionValue) + } + } + + /** Grouping key name */ + fun group(group: String) = group(JsonField.of(group)) + + /** + * Sets [Builder.group] to an arbitrary JSON value. + * + * You should usually call [Builder.group] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun group(group: JsonField) = apply { this.group = group } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CumulativeGroupedBulkConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .dimensionValues() + * .group() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CumulativeGroupedBulkConfig = + CumulativeGroupedBulkConfig( + checkRequired("dimensionValues", dimensionValues).map { it.toImmutable() }, + checkRequired("group", group), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CumulativeGroupedBulkConfig = apply { + if (validated) { + return@apply + } + + dimensionValues().forEach { it.validate() } + group() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (dimensionValues.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + (if (group.asKnown() == null) 0 else 1) + + /** Configuration for a dimension value entry */ + class DimensionValue + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val groupingKey: JsonField, + private val tierLowerBound: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(groupingKey, tierLowerBound, unitAmount, mutableMapOf()) + + /** + * Grouping key value + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * Tier lower bound + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun tierLowerBound(): String = tierLowerBound.getRequired("tier_lower_bound") + + /** + * Unit amount for this combination + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [DimensionValue]. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .tierLowerBound() + * .unitAmount() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [DimensionValue]. */ + class Builder internal constructor() { + + private var groupingKey: JsonField? = null + private var tierLowerBound: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(dimensionValue: DimensionValue) = apply { + groupingKey = dimensionValue.groupingKey + tierLowerBound = dimensionValue.tierLowerBound + unitAmount = dimensionValue.unitAmount + additionalProperties = dimensionValue.additionalProperties.toMutableMap() + } + + /** Grouping key value */ + fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** Tier lower bound */ + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + /** Unit amount for this combination */ + fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [DimensionValue]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```kotlin + * .groupingKey() * .tierLowerBound() * .unitAmount() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): Tier = - Tier( + fun build(): DimensionValue = + DimensionValue( + checkRequired("groupingKey", groupingKey), checkRequired("tierLowerBound", tierLowerBound), checkRequired("unitAmount", unitAmount), additionalProperties.toMutableMap(), @@ -76898,11 +79760,12 @@ private constructor( private var validated: Boolean = false - fun validate(): Tier = apply { + fun validate(): DimensionValue = apply { if (validated) { return@apply } + groupingKey() tierLowerBound() unitAmount() validated = true @@ -76923,7 +79786,8 @@ private constructor( * Used for best match union deserialization. */ internal fun validity(): Int = - (if (tierLowerBound.asKnown() == null) 0 else 1) + + (if (groupingKey.asKnown() == null) 0 else 1) + + (if (tierLowerBound.asKnown() == null) 0 else 1) + (if (unitAmount.asKnown() == null) 0 else 1) override fun equals(other: Any?): Boolean { @@ -76931,20 +79795,21 @@ private constructor( return true } - return other is Tier && + return other is DimensionValue && + groupingKey == other.groupingKey && tierLowerBound == other.tierLowerBound && unitAmount == other.unitAmount && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(tierLowerBound, unitAmount, additionalProperties) + Objects.hash(groupingKey, tierLowerBound, unitAmount, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "Tier{tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + "DimensionValue{groupingKey=$groupingKey, tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { @@ -76952,28 +79817,260 @@ private constructor( return true } - return other is ScalableMatrixWithTieredPricingConfig && - firstDimension == other.firstDimension && - matrixScalingFactors == other.matrixScalingFactors && - tiers == other.tiers && - secondDimension == other.secondDimension && + return other is CumulativeGroupedBulkConfig && + dimensionValues == other.dimensionValues && + group == other.group && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash( - firstDimension, - matrixScalingFactors, - tiers, - secondDimension, - additionalProperties, - ) + Objects.hash(dimensionValues, group, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "ScalableMatrixWithTieredPricingConfig{firstDimension=$firstDimension, matrixScalingFactors=$matrixScalingFactors, tiers=$tiers, secondDimension=$secondDimension, additionalProperties=$additionalProperties}" + "CumulativeGroupedBulkConfig{dimensionValues=$dimensionValues, group=$group, additionalProperties=$additionalProperties}" + } + + /** + * User specified key-value pairs for the resource. If not present, this defaults to an + * empty dictionary. Individual keys can be removed by setting the value to `null`, and the + * entire metadata mapping can be cleared by setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + class PriceType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val USAGE_PRICE = of("usage_price") + + val FIXED_PRICE = of("fixed_price") + + val COMPOSITE_PRICE = of("composite_price") + + fun of(value: String) = PriceType(JsonField.of(value)) + } + + /** An enum containing [PriceType]'s known values. */ + enum class Known { + USAGE_PRICE, + FIXED_PRICE, + COMPOSITE_PRICE, + } + + /** + * An enum containing [PriceType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [PriceType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + USAGE_PRICE, + FIXED_PRICE, + COMPOSITE_PRICE, + /** + * An enum member indicating that [PriceType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + USAGE_PRICE -> Value.USAGE_PRICE + FIXED_PRICE -> Value.FIXED_PRICE + COMPOSITE_PRICE -> Value.COMPOSITE_PRICE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + USAGE_PRICE -> Known.USAGE_PRICE + FIXED_PRICE -> Known.FIXED_PRICE + COMPOSITE_PRICE -> Known.COMPOSITE_PRICE + else -> throw OrbInvalidDataException("Unknown PriceType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): PriceType = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PriceType && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() } override fun equals(other: Any?): Boolean { @@ -76981,7 +80078,7 @@ private constructor( return true } - return other is ScalableMatrixWithTieredPricing && + return other is CumulativeGroupedBulk && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && @@ -76992,6 +80089,7 @@ private constructor( conversionRateConfig == other.conversionRateConfig && createdAt == other.createdAt && creditAllocation == other.creditAllocation && + cumulativeGroupedBulkConfig == other.cumulativeGroupedBulkConfig && currency == other.currency && discount == other.discount && externalPriceId == other.externalPriceId && @@ -77008,8 +80106,6 @@ private constructor( planPhaseOrder == other.planPhaseOrder && priceType == other.priceType && replacesPriceId == other.replacesPriceId && - scalableMatrixWithTieredPricingConfig == - other.scalableMatrixWithTieredPricingConfig && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties } @@ -77026,6 +80122,7 @@ private constructor( conversionRateConfig, createdAt, creditAllocation, + cumulativeGroupedBulkConfig, currency, discount, externalPriceId, @@ -77042,7 +80139,6 @@ private constructor( planPhaseOrder, priceType, replacesPriceId, - scalableMatrixWithTieredPricingConfig, dimensionalPriceConfiguration, additionalProperties, ) @@ -77051,10 +80147,10 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "ScalableMatrixWithTieredPricing{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, scalableMatrixWithTieredPricingConfig=$scalableMatrixWithTieredPricingConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "CumulativeGroupedBulk{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, cumulativeGroupedBulkConfig=$cumulativeGroupedBulkConfig, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" } - class CumulativeGroupedBulk + class CumulativeGroupedAllocation @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, @@ -77067,7 +80163,7 @@ private constructor( private val conversionRateConfig: JsonField, private val createdAt: JsonField, private val creditAllocation: JsonField, - private val cumulativeGroupedBulkConfig: JsonField, + private val cumulativeGroupedAllocationConfig: JsonField, private val currency: JsonField, private val discount: JsonField, private val externalPriceId: JsonField, @@ -77116,9 +80212,10 @@ private constructor( @JsonProperty("credit_allocation") @ExcludeMissing creditAllocation: JsonField = JsonMissing.of(), - @JsonProperty("cumulative_grouped_bulk_config") + @JsonProperty("cumulative_grouped_allocation_config") @ExcludeMissing - cumulativeGroupedBulkConfig: JsonField = JsonMissing.of(), + cumulativeGroupedAllocationConfig: JsonField = + JsonMissing.of(), @JsonProperty("currency") @ExcludeMissing currency: JsonField = JsonMissing.of(), @@ -77172,7 +80269,7 @@ private constructor( conversionRateConfig, createdAt, creditAllocation, - cumulativeGroupedBulkConfig, + cumulativeGroupedAllocationConfig, currency, discount, externalPriceId, @@ -77257,13 +80354,13 @@ private constructor( fun creditAllocation(): Allocation? = creditAllocation.getNullable("credit_allocation") /** - * Configuration for cumulative_grouped_bulk pricing + * Configuration for cumulative_grouped_allocation pricing * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ - fun cumulativeGroupedBulkConfig(): CumulativeGroupedBulkConfig = - cumulativeGroupedBulkConfig.getRequired("cumulative_grouped_bulk_config") + fun cumulativeGroupedAllocationConfig(): CumulativeGroupedAllocationConfig = + cumulativeGroupedAllocationConfig.getRequired("cumulative_grouped_allocation_config") /** * @throws OrbInvalidDataException if the JSON field has an unexpected type or is @@ -77346,7 +80443,7 @@ private constructor( * * Expected to always return the following: * ```kotlin - * JsonValue.from("cumulative_grouped_bulk") + * JsonValue.from("cumulative_grouped_allocation") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -77482,15 +80579,15 @@ private constructor( fun _creditAllocation(): JsonField = creditAllocation /** - * Returns the raw JSON value of [cumulativeGroupedBulkConfig]. + * Returns the raw JSON value of [cumulativeGroupedAllocationConfig]. * - * Unlike [cumulativeGroupedBulkConfig], this method doesn't throw if the JSON field has an - * unexpected type. + * Unlike [cumulativeGroupedAllocationConfig], this method doesn't throw if the JSON field + * has an unexpected type. */ - @JsonProperty("cumulative_grouped_bulk_config") + @JsonProperty("cumulative_grouped_allocation_config") @ExcludeMissing - fun _cumulativeGroupedBulkConfig(): JsonField = - cumulativeGroupedBulkConfig + fun _cumulativeGroupedAllocationConfig(): JsonField = + cumulativeGroupedAllocationConfig /** * Returns the raw JSON value of [currency]. @@ -77658,7 +80755,8 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [CumulativeGroupedBulk]. + * Returns a mutable builder for constructing an instance of + * [CumulativeGroupedAllocation]. * * The following fields are required: * ```kotlin @@ -77672,7 +80770,7 @@ private constructor( * .conversionRateConfig() * .createdAt() * .creditAllocation() - * .cumulativeGroupedBulkConfig() + * .cumulativeGroupedAllocationConfig() * .currency() * .discount() * .externalPriceId() @@ -77693,7 +80791,7 @@ private constructor( fun builder() = Builder() } - /** A builder for [CumulativeGroupedBulk]. */ + /** A builder for [CumulativeGroupedAllocation]. */ class Builder internal constructor() { private var id: JsonField? = null @@ -77706,7 +80804,9 @@ private constructor( private var conversionRateConfig: JsonField? = null private var createdAt: JsonField? = null private var creditAllocation: JsonField? = null - private var cumulativeGroupedBulkConfig: JsonField? = null + private var cumulativeGroupedAllocationConfig: + JsonField? = + null private var currency: JsonField? = null private var discount: JsonField? = null private var externalPriceId: JsonField? = null @@ -77718,7 +80818,7 @@ private constructor( private var metadata: JsonField? = null private var minimum: JsonField? = null private var minimumAmount: JsonField? = null - private var modelType: JsonValue = JsonValue.from("cumulative_grouped_bulk") + private var modelType: JsonValue = JsonValue.from("cumulative_grouped_allocation") private var name: JsonField? = null private var planPhaseOrder: JsonField? = null private var priceType: JsonField? = null @@ -77727,37 +80827,41 @@ private constructor( JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(cumulativeGroupedBulk: CumulativeGroupedBulk) = apply { - id = cumulativeGroupedBulk.id - billableMetric = cumulativeGroupedBulk.billableMetric - billingCycleConfiguration = cumulativeGroupedBulk.billingCycleConfiguration - billingMode = cumulativeGroupedBulk.billingMode - cadence = cumulativeGroupedBulk.cadence + internal fun from(cumulativeGroupedAllocation: CumulativeGroupedAllocation) = apply { + id = cumulativeGroupedAllocation.id + billableMetric = cumulativeGroupedAllocation.billableMetric + billingCycleConfiguration = cumulativeGroupedAllocation.billingCycleConfiguration + billingMode = cumulativeGroupedAllocation.billingMode + cadence = cumulativeGroupedAllocation.cadence compositePriceFilters = - cumulativeGroupedBulk.compositePriceFilters.map { it.toMutableList() } - conversionRate = cumulativeGroupedBulk.conversionRate - conversionRateConfig = cumulativeGroupedBulk.conversionRateConfig - createdAt = cumulativeGroupedBulk.createdAt - creditAllocation = cumulativeGroupedBulk.creditAllocation - cumulativeGroupedBulkConfig = cumulativeGroupedBulk.cumulativeGroupedBulkConfig - currency = cumulativeGroupedBulk.currency - discount = cumulativeGroupedBulk.discount - externalPriceId = cumulativeGroupedBulk.externalPriceId - fixedPriceQuantity = cumulativeGroupedBulk.fixedPriceQuantity - invoicingCycleConfiguration = cumulativeGroupedBulk.invoicingCycleConfiguration - item = cumulativeGroupedBulk.item - maximum = cumulativeGroupedBulk.maximum - maximumAmount = cumulativeGroupedBulk.maximumAmount - metadata = cumulativeGroupedBulk.metadata - minimum = cumulativeGroupedBulk.minimum - minimumAmount = cumulativeGroupedBulk.minimumAmount - modelType = cumulativeGroupedBulk.modelType - name = cumulativeGroupedBulk.name - planPhaseOrder = cumulativeGroupedBulk.planPhaseOrder - priceType = cumulativeGroupedBulk.priceType - replacesPriceId = cumulativeGroupedBulk.replacesPriceId - dimensionalPriceConfiguration = cumulativeGroupedBulk.dimensionalPriceConfiguration - additionalProperties = cumulativeGroupedBulk.additionalProperties.toMutableMap() + cumulativeGroupedAllocation.compositePriceFilters.map { it.toMutableList() } + conversionRate = cumulativeGroupedAllocation.conversionRate + conversionRateConfig = cumulativeGroupedAllocation.conversionRateConfig + createdAt = cumulativeGroupedAllocation.createdAt + creditAllocation = cumulativeGroupedAllocation.creditAllocation + cumulativeGroupedAllocationConfig = + cumulativeGroupedAllocation.cumulativeGroupedAllocationConfig + currency = cumulativeGroupedAllocation.currency + discount = cumulativeGroupedAllocation.discount + externalPriceId = cumulativeGroupedAllocation.externalPriceId + fixedPriceQuantity = cumulativeGroupedAllocation.fixedPriceQuantity + invoicingCycleConfiguration = + cumulativeGroupedAllocation.invoicingCycleConfiguration + item = cumulativeGroupedAllocation.item + maximum = cumulativeGroupedAllocation.maximum + maximumAmount = cumulativeGroupedAllocation.maximumAmount + metadata = cumulativeGroupedAllocation.metadata + minimum = cumulativeGroupedAllocation.minimum + minimumAmount = cumulativeGroupedAllocation.minimumAmount + modelType = cumulativeGroupedAllocation.modelType + name = cumulativeGroupedAllocation.name + planPhaseOrder = cumulativeGroupedAllocation.planPhaseOrder + priceType = cumulativeGroupedAllocation.priceType + replacesPriceId = cumulativeGroupedAllocation.replacesPriceId + dimensionalPriceConfiguration = + cumulativeGroupedAllocation.dimensionalPriceConfiguration + additionalProperties = + cumulativeGroupedAllocation.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) @@ -77961,21 +81065,21 @@ private constructor( this.creditAllocation = creditAllocation } - /** Configuration for cumulative_grouped_bulk pricing */ - fun cumulativeGroupedBulkConfig( - cumulativeGroupedBulkConfig: CumulativeGroupedBulkConfig - ) = cumulativeGroupedBulkConfig(JsonField.of(cumulativeGroupedBulkConfig)) + /** Configuration for cumulative_grouped_allocation pricing */ + fun cumulativeGroupedAllocationConfig( + cumulativeGroupedAllocationConfig: CumulativeGroupedAllocationConfig + ) = cumulativeGroupedAllocationConfig(JsonField.of(cumulativeGroupedAllocationConfig)) /** - * Sets [Builder.cumulativeGroupedBulkConfig] to an arbitrary JSON value. + * Sets [Builder.cumulativeGroupedAllocationConfig] to an arbitrary JSON value. * - * You should usually call [Builder.cumulativeGroupedBulkConfig] with a well-typed - * [CumulativeGroupedBulkConfig] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * You should usually call [Builder.cumulativeGroupedAllocationConfig] with a well-typed + * [CumulativeGroupedAllocationConfig] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. */ - fun cumulativeGroupedBulkConfig( - cumulativeGroupedBulkConfig: JsonField - ) = apply { this.cumulativeGroupedBulkConfig = cumulativeGroupedBulkConfig } + fun cumulativeGroupedAllocationConfig( + cumulativeGroupedAllocationConfig: JsonField + ) = apply { this.cumulativeGroupedAllocationConfig = cumulativeGroupedAllocationConfig } fun currency(currency: String) = currency(JsonField.of(currency)) @@ -78218,7 +81322,7 @@ private constructor( * It is usually unnecessary to call this method because the field defaults to the * following: * ```kotlin - * JsonValue.from("cumulative_grouped_bulk") + * JsonValue.from("cumulative_grouped_allocation") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -78322,7 +81426,7 @@ private constructor( } /** - * Returns an immutable instance of [CumulativeGroupedBulk]. + * Returns an immutable instance of [CumulativeGroupedAllocation]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -78338,7 +81442,7 @@ private constructor( * .conversionRateConfig() * .createdAt() * .creditAllocation() - * .cumulativeGroupedBulkConfig() + * .cumulativeGroupedAllocationConfig() * .currency() * .discount() * .externalPriceId() @@ -78358,8 +81462,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): CumulativeGroupedBulk = - CumulativeGroupedBulk( + fun build(): CumulativeGroupedAllocation = + CumulativeGroupedAllocation( checkRequired("id", id), checkRequired("billableMetric", billableMetric), checkRequired("billingCycleConfiguration", billingCycleConfiguration), @@ -78372,7 +81476,10 @@ private constructor( checkRequired("conversionRateConfig", conversionRateConfig), checkRequired("createdAt", createdAt), checkRequired("creditAllocation", creditAllocation), - checkRequired("cumulativeGroupedBulkConfig", cumulativeGroupedBulkConfig), + checkRequired( + "cumulativeGroupedAllocationConfig", + cumulativeGroupedAllocationConfig, + ), checkRequired("currency", currency), checkRequired("discount", discount), checkRequired("externalPriceId", externalPriceId), @@ -78396,7 +81503,7 @@ private constructor( private var validated: Boolean = false - fun validate(): CumulativeGroupedBulk = apply { + fun validate(): CumulativeGroupedAllocation = apply { if (validated) { return@apply } @@ -78411,7 +81518,7 @@ private constructor( conversionRateConfig()?.validate() createdAt() creditAllocation()?.validate() - cumulativeGroupedBulkConfig().validate() + cumulativeGroupedAllocationConfig().validate() currency() discount()?.validate() externalPriceId() @@ -78424,7 +81531,7 @@ private constructor( minimum()?.validate() minimumAmount() _modelType().let { - if (it != JsonValue.from("cumulative_grouped_bulk")) { + if (it != JsonValue.from("cumulative_grouped_allocation")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } @@ -78461,7 +81568,7 @@ private constructor( (conversionRateConfig.asKnown()?.validity() ?: 0) + (if (createdAt.asKnown() == null) 0 else 1) + (creditAllocation.asKnown()?.validity() ?: 0) + - (cumulativeGroupedBulkConfig.asKnown()?.validity() ?: 0) + + (cumulativeGroupedAllocationConfig.asKnown()?.validity() ?: 0) + (if (currency.asKnown() == null) 0 else 1) + (discount.asKnown()?.validity() ?: 0) + (if (externalPriceId.asKnown() == null) 0 else 1) + @@ -78473,7 +81580,9 @@ private constructor( (metadata.asKnown()?.validity() ?: 0) + (minimum.asKnown()?.validity() ?: 0) + (if (minimumAmount.asKnown() == null) 0 else 1) + - modelType.let { if (it == JsonValue.from("cumulative_grouped_bulk")) 1 else 0 } + + modelType.let { + if (it == JsonValue.from("cumulative_grouped_allocation")) 1 else 0 + } + (if (name.asKnown() == null) 0 else 1) + (if (planPhaseOrder.asKnown() == null) 0 else 1) + (priceType.asKnown()?.validity() ?: 0) + @@ -79301,58 +82410,109 @@ private constructor( "CompositePriceFilter{field=$field, operator=$operator, values=$values, additionalProperties=$additionalProperties}" } - /** Configuration for cumulative_grouped_bulk pricing */ - class CumulativeGroupedBulkConfig + /** Configuration for cumulative_grouped_allocation pricing */ + class CumulativeGroupedAllocationConfig @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val dimensionValues: JsonField>, - private val group: JsonField, + private val cumulativeAllocation: JsonField, + private val groupAllocation: JsonField, + private val groupingKey: JsonField, + private val unitAmount: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("dimension_values") + @JsonProperty("cumulative_allocation") @ExcludeMissing - dimensionValues: JsonField> = JsonMissing.of(), - @JsonProperty("group") @ExcludeMissing group: JsonField = JsonMissing.of(), - ) : this(dimensionValues, group, mutableMapOf()) + cumulativeAllocation: JsonField = JsonMissing.of(), + @JsonProperty("group_allocation") + @ExcludeMissing + groupAllocation: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(cumulativeAllocation, groupAllocation, groupingKey, unitAmount, mutableMapOf()) /** - * Each tier lower bound must have the same group of values. + * The overall allocation across all groups * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected * value). */ - fun dimensionValues(): List = - dimensionValues.getRequired("dimension_values") + fun cumulativeAllocation(): String = + cumulativeAllocation.getRequired("cumulative_allocation") /** - * Grouping key name + * The allocation per individual group * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected * value). */ - fun group(): String = group.getRequired("group") + fun groupAllocation(): String = groupAllocation.getRequired("group_allocation") /** - * Returns the raw JSON value of [dimensionValues]. + * The event property used to group usage before applying allocations * - * Unlike [dimensionValues], this method doesn't throw if the JSON field has an + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The amount to charge for each unit outside of the allocation + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [cumulativeAllocation]. + * + * Unlike [cumulativeAllocation], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("dimension_values") + @JsonProperty("cumulative_allocation") @ExcludeMissing - fun _dimensionValues(): JsonField> = dimensionValues + fun _cumulativeAllocation(): JsonField = cumulativeAllocation /** - * Returns the raw JSON value of [group]. + * Returns the raw JSON value of [groupAllocation]. * - * Unlike [group], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [groupAllocation], this method doesn't throw if the JSON field has an + * unexpected type. */ - @JsonProperty("group") @ExcludeMissing fun _group(): JsonField = group + @JsonProperty("group_allocation") + @ExcludeMissing + fun _groupAllocation(): JsonField = groupAllocation + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -79370,71 +82530,96 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [CumulativeGroupedBulkConfig]. + * [CumulativeGroupedAllocationConfig]. * * The following fields are required: * ```kotlin - * .dimensionValues() - * .group() + * .cumulativeAllocation() + * .groupAllocation() + * .groupingKey() + * .unitAmount() * ``` */ fun builder() = Builder() } - /** A builder for [CumulativeGroupedBulkConfig]. */ + /** A builder for [CumulativeGroupedAllocationConfig]. */ class Builder internal constructor() { - private var dimensionValues: JsonField>? = null - private var group: JsonField? = null + private var cumulativeAllocation: JsonField? = null + private var groupAllocation: JsonField? = null + private var groupingKey: JsonField? = null + private var unitAmount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(cumulativeGroupedBulkConfig: CumulativeGroupedBulkConfig) = - apply { - dimensionValues = - cumulativeGroupedBulkConfig.dimensionValues.map { it.toMutableList() } - group = cumulativeGroupedBulkConfig.group - additionalProperties = - cumulativeGroupedBulkConfig.additionalProperties.toMutableMap() - } + internal fun from( + cumulativeGroupedAllocationConfig: CumulativeGroupedAllocationConfig + ) = apply { + cumulativeAllocation = cumulativeGroupedAllocationConfig.cumulativeAllocation + groupAllocation = cumulativeGroupedAllocationConfig.groupAllocation + groupingKey = cumulativeGroupedAllocationConfig.groupingKey + unitAmount = cumulativeGroupedAllocationConfig.unitAmount + additionalProperties = + cumulativeGroupedAllocationConfig.additionalProperties.toMutableMap() + } - /** Each tier lower bound must have the same group of values. */ - fun dimensionValues(dimensionValues: List) = - dimensionValues(JsonField.of(dimensionValues)) + /** The overall allocation across all groups */ + fun cumulativeAllocation(cumulativeAllocation: String) = + cumulativeAllocation(JsonField.of(cumulativeAllocation)) /** - * Sets [Builder.dimensionValues] to an arbitrary JSON value. + * Sets [Builder.cumulativeAllocation] to an arbitrary JSON value. * - * You should usually call [Builder.dimensionValues] with a well-typed - * `List` value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * You should usually call [Builder.cumulativeAllocation] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. */ - fun dimensionValues(dimensionValues: JsonField>) = apply { - this.dimensionValues = dimensionValues.map { it.toMutableList() } + fun cumulativeAllocation(cumulativeAllocation: JsonField) = apply { + this.cumulativeAllocation = cumulativeAllocation } + /** The allocation per individual group */ + fun groupAllocation(groupAllocation: String) = + groupAllocation(JsonField.of(groupAllocation)) + /** - * Adds a single [DimensionValue] to [dimensionValues]. + * Sets [Builder.groupAllocation] to an arbitrary JSON value. * - * @throws IllegalStateException if the field was previously set to a non-list. + * You should usually call [Builder.groupAllocation] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. */ - fun addDimensionValue(dimensionValue: DimensionValue) = apply { - dimensionValues = - (dimensionValues ?: JsonField.of(mutableListOf())).also { - checkKnown("dimensionValues", it).add(dimensionValue) - } + fun groupAllocation(groupAllocation: JsonField) = apply { + this.groupAllocation = groupAllocation } - /** Grouping key name */ - fun group(group: String) = group(JsonField.of(group)) + /** The event property used to group usage before applying allocations */ + fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) /** - * Sets [Builder.group] to an arbitrary JSON value. + * Sets [Builder.groupingKey] to an arbitrary JSON value. * - * You should usually call [Builder.group] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. + * You should usually call [Builder.groupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. */ - fun group(group: JsonField) = apply { this.group = group } + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The amount to charge for each unit outside of the allocation */ + fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -79459,35 +82644,41 @@ private constructor( } /** - * Returns an immutable instance of [CumulativeGroupedBulkConfig]. + * Returns an immutable instance of [CumulativeGroupedAllocationConfig]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```kotlin - * .dimensionValues() - * .group() + * .cumulativeAllocation() + * .groupAllocation() + * .groupingKey() + * .unitAmount() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): CumulativeGroupedBulkConfig = - CumulativeGroupedBulkConfig( - checkRequired("dimensionValues", dimensionValues).map { it.toImmutable() }, - checkRequired("group", group), + fun build(): CumulativeGroupedAllocationConfig = + CumulativeGroupedAllocationConfig( + checkRequired("cumulativeAllocation", cumulativeAllocation), + checkRequired("groupAllocation", groupAllocation), + checkRequired("groupingKey", groupingKey), + checkRequired("unitAmount", unitAmount), additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): CumulativeGroupedBulkConfig = apply { + fun validate(): CumulativeGroupedAllocationConfig = apply { if (validated) { return@apply } - dimensionValues().forEach { it.validate() } - group() + cumulativeAllocation() + groupAllocation() + groupingKey() + unitAmount() validated = true } @@ -79506,292 +82697,38 @@ private constructor( * Used for best match union deserialization. */ internal fun validity(): Int = - (dimensionValues.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + - (if (group.asKnown() == null) 0 else 1) - - /** Configuration for a dimension value entry */ - class DimensionValue - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val groupingKey: JsonField, - private val tierLowerBound: JsonField, - private val unitAmount: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("grouping_key") - @ExcludeMissing - groupingKey: JsonField = JsonMissing.of(), - @JsonProperty("tier_lower_bound") - @ExcludeMissing - tierLowerBound: JsonField = JsonMissing.of(), - @JsonProperty("unit_amount") - @ExcludeMissing - unitAmount: JsonField = JsonMissing.of(), - ) : this(groupingKey, tierLowerBound, unitAmount, mutableMapOf()) - - /** - * Grouping key value - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun groupingKey(): String = groupingKey.getRequired("grouping_key") - - /** - * Tier lower bound - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun tierLowerBound(): String = tierLowerBound.getRequired("tier_lower_bound") - - /** - * Unit amount for this combination - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun unitAmount(): String = unitAmount.getRequired("unit_amount") - - /** - * Returns the raw JSON value of [groupingKey]. - * - * Unlike [groupingKey], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("grouping_key") - @ExcludeMissing - fun _groupingKey(): JsonField = groupingKey - - /** - * Returns the raw JSON value of [tierLowerBound]. - * - * Unlike [tierLowerBound], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("tier_lower_bound") - @ExcludeMissing - fun _tierLowerBound(): JsonField = tierLowerBound - - /** - * Returns the raw JSON value of [unitAmount]. - * - * Unlike [unitAmount], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("unit_amount") - @ExcludeMissing - fun _unitAmount(): JsonField = unitAmount - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [DimensionValue]. - * - * The following fields are required: - * ```kotlin - * .groupingKey() - * .tierLowerBound() - * .unitAmount() - * ``` - */ - fun builder() = Builder() - } - - /** A builder for [DimensionValue]. */ - class Builder internal constructor() { - - private var groupingKey: JsonField? = null - private var tierLowerBound: JsonField? = null - private var unitAmount: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(dimensionValue: DimensionValue) = apply { - groupingKey = dimensionValue.groupingKey - tierLowerBound = dimensionValue.tierLowerBound - unitAmount = dimensionValue.unitAmount - additionalProperties = dimensionValue.additionalProperties.toMutableMap() - } - - /** Grouping key value */ - fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) - - /** - * Sets [Builder.groupingKey] to an arbitrary JSON value. - * - * You should usually call [Builder.groupingKey] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun groupingKey(groupingKey: JsonField) = apply { - this.groupingKey = groupingKey - } - - /** Tier lower bound */ - fun tierLowerBound(tierLowerBound: String) = - tierLowerBound(JsonField.of(tierLowerBound)) - - /** - * Sets [Builder.tierLowerBound] to an arbitrary JSON value. - * - * You should usually call [Builder.tierLowerBound] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun tierLowerBound(tierLowerBound: JsonField) = apply { - this.tierLowerBound = tierLowerBound - } - - /** Unit amount for this combination */ - fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) - - /** - * Sets [Builder.unitAmount] to an arbitrary JSON value. - * - * You should usually call [Builder.unitAmount] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun unitAmount(unitAmount: JsonField) = apply { - this.unitAmount = unitAmount - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [DimensionValue]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```kotlin - * .groupingKey() - * .tierLowerBound() - * .unitAmount() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): DimensionValue = - DimensionValue( - checkRequired("groupingKey", groupingKey), - checkRequired("tierLowerBound", tierLowerBound), - checkRequired("unitAmount", unitAmount), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): DimensionValue = apply { - if (validated) { - return@apply - } - - groupingKey() - tierLowerBound() - unitAmount() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = + (if (cumulativeAllocation.asKnown() == null) 0 else 1) + + (if (groupAllocation.asKnown() == null) 0 else 1) + (if (groupingKey.asKnown() == null) 0 else 1) + - (if (tierLowerBound.asKnown() == null) 0 else 1) + - (if (unitAmount.asKnown() == null) 0 else 1) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is DimensionValue && - groupingKey == other.groupingKey && - tierLowerBound == other.tierLowerBound && - unitAmount == other.unitAmount && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(groupingKey, tierLowerBound, unitAmount, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "DimensionValue{groupingKey=$groupingKey, tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" - } + (if (unitAmount.asKnown() == null) 0 else 1) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is CumulativeGroupedBulkConfig && - dimensionValues == other.dimensionValues && - group == other.group && + return other is CumulativeGroupedAllocationConfig && + cumulativeAllocation == other.cumulativeAllocation && + groupAllocation == other.groupAllocation && + groupingKey == other.groupingKey && + unitAmount == other.unitAmount && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(dimensionValues, group, additionalProperties) + Objects.hash( + cumulativeAllocation, + groupAllocation, + groupingKey, + unitAmount, + additionalProperties, + ) } override fun hashCode(): Int = hashCode override fun toString() = - "CumulativeGroupedBulkConfig{dimensionValues=$dimensionValues, group=$group, additionalProperties=$additionalProperties}" + "CumulativeGroupedAllocationConfig{cumulativeAllocation=$cumulativeAllocation, groupAllocation=$groupAllocation, groupingKey=$groupingKey, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" } /** @@ -80039,7 +82976,7 @@ private constructor( return true } - return other is CumulativeGroupedBulk && + return other is CumulativeGroupedAllocation && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && @@ -80050,7 +82987,7 @@ private constructor( conversionRateConfig == other.conversionRateConfig && createdAt == other.createdAt && creditAllocation == other.creditAllocation && - cumulativeGroupedBulkConfig == other.cumulativeGroupedBulkConfig && + cumulativeGroupedAllocationConfig == other.cumulativeGroupedAllocationConfig && currency == other.currency && discount == other.discount && externalPriceId == other.externalPriceId && @@ -80083,7 +83020,7 @@ private constructor( conversionRateConfig, createdAt, creditAllocation, - cumulativeGroupedBulkConfig, + cumulativeGroupedAllocationConfig, currency, discount, externalPriceId, @@ -80108,7 +83045,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "CumulativeGroupedBulk{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, cumulativeGroupedBulkConfig=$cumulativeGroupedBulkConfig, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "CumulativeGroupedAllocation{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, cumulativeGroupedAllocationConfig=$cumulativeGroupedAllocationConfig, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" } class Minimum diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceCreateParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceCreateParams.kt index 5262e7247..7f2d53df8 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceCreateParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceCreateParams.kt @@ -211,6 +211,13 @@ private constructor( fun body(cumulativeGroupedBulk: NewFloatingCumulativeGroupedBulkPrice) = body(Body.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) + /** + * Alias for calling [body] with + * `Body.ofCumulativeGroupedAllocation(cumulativeGroupedAllocation)`. + */ + fun body(cumulativeGroupedAllocation: Body.CumulativeGroupedAllocation) = + body(Body.ofCumulativeGroupedAllocation(cumulativeGroupedAllocation)) + /** Alias for calling [body] with `Body.ofMinimum(minimum)`. */ fun body(minimum: NewFloatingMinimumCompositePrice) = body(Body.ofMinimum(minimum)) @@ -379,6 +386,7 @@ private constructor( NewFloatingScalableMatrixWithTieredPricingPrice? = null, private val cumulativeGroupedBulk: NewFloatingCumulativeGroupedBulkPrice? = null, + private val cumulativeGroupedAllocation: CumulativeGroupedAllocation? = null, private val minimum: NewFloatingMinimumCompositePrice? = null, private val percent: Percent? = null, private val eventOutput: EventOutput? = null, @@ -445,6 +453,9 @@ private constructor( fun cumulativeGroupedBulk(): NewFloatingCumulativeGroupedBulkPrice? = cumulativeGroupedBulk + fun cumulativeGroupedAllocation(): CumulativeGroupedAllocation? = + cumulativeGroupedAllocation + fun minimum(): NewFloatingMinimumCompositePrice? = minimum fun percent(): Percent? = percent @@ -505,6 +516,8 @@ private constructor( fun isCumulativeGroupedBulk(): Boolean = cumulativeGroupedBulk != null + fun isCumulativeGroupedAllocation(): Boolean = cumulativeGroupedAllocation != null + fun isMinimum(): Boolean = minimum != null fun isPercent(): Boolean = percent != null @@ -586,6 +599,9 @@ private constructor( fun asCumulativeGroupedBulk(): NewFloatingCumulativeGroupedBulkPrice = cumulativeGroupedBulk.getOrThrow("cumulativeGroupedBulk") + fun asCumulativeGroupedAllocation(): CumulativeGroupedAllocation = + cumulativeGroupedAllocation.getOrThrow("cumulativeGroupedAllocation") + fun asMinimum(): NewFloatingMinimumCompositePrice = minimum.getOrThrow("minimum") fun asPercent(): Percent = percent.getOrThrow("percent") @@ -636,6 +652,8 @@ private constructor( visitor.visitScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing) cumulativeGroupedBulk != null -> visitor.visitCumulativeGroupedBulk(cumulativeGroupedBulk) + cumulativeGroupedAllocation != null -> + visitor.visitCumulativeGroupedAllocation(cumulativeGroupedAllocation) minimum != null -> visitor.visitMinimum(minimum) percent != null -> visitor.visitPercent(percent) eventOutput != null -> visitor.visitEventOutput(eventOutput) @@ -798,6 +816,12 @@ private constructor( cumulativeGroupedBulk.validate() } + override fun visitCumulativeGroupedAllocation( + cumulativeGroupedAllocation: CumulativeGroupedAllocation + ) { + cumulativeGroupedAllocation.validate() + } + override fun visitMinimum(minimum: NewFloatingMinimumCompositePrice) { minimum.validate() } @@ -928,6 +952,10 @@ private constructor( cumulativeGroupedBulk: NewFloatingCumulativeGroupedBulkPrice ) = cumulativeGroupedBulk.validity() + override fun visitCumulativeGroupedAllocation( + cumulativeGroupedAllocation: CumulativeGroupedAllocation + ) = cumulativeGroupedAllocation.validity() + override fun visitMinimum(minimum: NewFloatingMinimumCompositePrice) = minimum.validity() @@ -972,6 +1000,7 @@ private constructor( scalableMatrixWithUnitPricing == other.scalableMatrixWithUnitPricing && scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && cumulativeGroupedBulk == other.cumulativeGroupedBulk && + cumulativeGroupedAllocation == other.cumulativeGroupedAllocation && minimum == other.minimum && percent == other.percent && eventOutput == other.eventOutput @@ -1006,6 +1035,7 @@ private constructor( scalableMatrixWithUnitPricing, scalableMatrixWithTieredPricing, cumulativeGroupedBulk, + cumulativeGroupedAllocation, minimum, percent, eventOutput, @@ -1050,6 +1080,8 @@ private constructor( "Body{scalableMatrixWithTieredPricing=$scalableMatrixWithTieredPricing}" cumulativeGroupedBulk != null -> "Body{cumulativeGroupedBulk=$cumulativeGroupedBulk}" + cumulativeGroupedAllocation != null -> + "Body{cumulativeGroupedAllocation=$cumulativeGroupedAllocation}" minimum != null -> "Body{minimum=$minimum}" percent != null -> "Body{percent=$percent}" eventOutput != null -> "Body{eventOutput=$eventOutput}" @@ -1145,6 +1177,10 @@ private constructor( cumulativeGroupedBulk: NewFloatingCumulativeGroupedBulkPrice ) = Body(cumulativeGroupedBulk = cumulativeGroupedBulk) + fun ofCumulativeGroupedAllocation( + cumulativeGroupedAllocation: CumulativeGroupedAllocation + ) = Body(cumulativeGroupedAllocation = cumulativeGroupedAllocation) + fun ofMinimum(minimum: NewFloatingMinimumCompositePrice) = Body(minimum = minimum) fun ofPercent(percent: Percent) = Body(percent = percent) @@ -1237,6 +1273,10 @@ private constructor( cumulativeGroupedBulk: NewFloatingCumulativeGroupedBulkPrice ): T + fun visitCumulativeGroupedAllocation( + cumulativeGroupedAllocation: CumulativeGroupedAllocation + ): T + fun visitMinimum(minimum: NewFloatingMinimumCompositePrice): T fun visitPercent(percent: Percent): T @@ -1449,6 +1489,11 @@ private constructor( ?.let { Body(cumulativeGroupedBulk = it, _json = json) } ?: Body(_json = json) } + "cumulative_grouped_allocation" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Body(cumulativeGroupedAllocation = it, _json = json) } + ?: Body(_json = json) + } "minimum" -> { return tryDeserialize( node, @@ -1525,6 +1570,8 @@ private constructor( generator.writeObject(value.scalableMatrixWithTieredPricing) value.cumulativeGroupedBulk != null -> generator.writeObject(value.cumulativeGroupedBulk) + value.cumulativeGroupedAllocation != null -> + generator.writeObject(value.cumulativeGroupedAllocation) value.minimum != null -> generator.writeObject(value.minimum) value.percent != null -> generator.writeObject(value.percent) value.eventOutput != null -> generator.writeObject(value.eventOutput) @@ -5086,6 +5133,1622 @@ private constructor( "GroupedWithMinMaxThresholds{cadence=$cadence, currency=$currency, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" } + class CumulativeGroupedAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val cumulativeGroupedAllocationConfig: + JsonField, + private val currency: JsonField, + private val itemId: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val dimensionalPriceConfiguration: JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val metadata: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("cumulative_grouped_allocation_config") + @ExcludeMissing + cumulativeGroupedAllocationConfig: JsonField = + JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") @ExcludeMissing modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + ) : this( + cadence, + cumulativeGroupedAllocationConfig, + currency, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * Configuration for cumulative_grouped_allocation pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cumulativeGroupedAllocationConfig(): CumulativeGroupedAllocationConfig = + cumulativeGroupedAllocationConfig.getRequired( + "cumulative_grouped_allocation_config" + ) + + /** + * An ISO 4217 currency string for which this price is billed in. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("cumulative_grouped_allocation") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun billableMetricId(): String? = billableMetricId.getNullable("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + invoiceGroupingKey.getNullable("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [cumulativeGroupedAllocationConfig]. + * + * Unlike [cumulativeGroupedAllocationConfig], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("cumulative_grouped_allocation_config") + @ExcludeMissing + fun _cumulativeGroupedAllocationConfig(): JsonField = + cumulativeGroupedAllocationConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [CumulativeGroupedAllocation]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .cumulativeGroupedAllocationConfig() + * .currency() + * .itemId() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [CumulativeGroupedAllocation]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var cumulativeGroupedAllocationConfig: + JsonField? = + null + private var currency: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonValue = JsonValue.from("cumulative_grouped_allocation") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(cumulativeGroupedAllocation: CumulativeGroupedAllocation) = + apply { + cadence = cumulativeGroupedAllocation.cadence + cumulativeGroupedAllocationConfig = + cumulativeGroupedAllocation.cumulativeGroupedAllocationConfig + currency = cumulativeGroupedAllocation.currency + itemId = cumulativeGroupedAllocation.itemId + modelType = cumulativeGroupedAllocation.modelType + name = cumulativeGroupedAllocation.name + billableMetricId = cumulativeGroupedAllocation.billableMetricId + billedInAdvance = cumulativeGroupedAllocation.billedInAdvance + billingCycleConfiguration = + cumulativeGroupedAllocation.billingCycleConfiguration + conversionRate = cumulativeGroupedAllocation.conversionRate + conversionRateConfig = cumulativeGroupedAllocation.conversionRateConfig + dimensionalPriceConfiguration = + cumulativeGroupedAllocation.dimensionalPriceConfiguration + externalPriceId = cumulativeGroupedAllocation.externalPriceId + fixedPriceQuantity = cumulativeGroupedAllocation.fixedPriceQuantity + invoiceGroupingKey = cumulativeGroupedAllocation.invoiceGroupingKey + invoicingCycleConfiguration = + cumulativeGroupedAllocation.invoicingCycleConfiguration + metadata = cumulativeGroupedAllocation.metadata + additionalProperties = + cumulativeGroupedAllocation.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** Configuration for cumulative_grouped_allocation pricing */ + fun cumulativeGroupedAllocationConfig( + cumulativeGroupedAllocationConfig: CumulativeGroupedAllocationConfig + ) = + cumulativeGroupedAllocationConfig( + JsonField.of(cumulativeGroupedAllocationConfig) + ) + + /** + * Sets [Builder.cumulativeGroupedAllocationConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.cumulativeGroupedAllocationConfig] with a + * well-typed [CumulativeGroupedAllocationConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported value. + */ + fun cumulativeGroupedAllocationConfig( + cumulativeGroupedAllocationConfig: JsonField + ) = apply { + this.cumulativeGroupedAllocationConfig = cumulativeGroupedAllocationConfig + } + + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```kotlin + * JsonValue.from("cumulative_grouped_allocation") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun conversionRateConfig(conversionRateConfig: JsonField) = + apply { + this.conversionRateConfig = conversionRateConfig + } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a well-typed + * [NewDimensionalPriceConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CumulativeGroupedAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .cumulativeGroupedAllocationConfig() + * .currency() + * .itemId() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CumulativeGroupedAllocation = + CumulativeGroupedAllocation( + checkRequired("cadence", cadence), + checkRequired( + "cumulativeGroupedAllocationConfig", + cumulativeGroupedAllocationConfig, + ), + checkRequired("currency", currency), + checkRequired("itemId", itemId), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CumulativeGroupedAllocation = apply { + if (validated) { + return@apply + } + + cadence().validate() + cumulativeGroupedAllocationConfig().validate() + currency() + itemId() + _modelType().let { + if (it != JsonValue.from("cumulative_grouped_allocation")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + metadata()?.validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (cumulativeGroupedAllocationConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (if (itemId.asKnown() == null) 0 else 1) + + modelType.let { + if (it == JsonValue.from("cumulative_grouped_allocation")) 1 else 0 + } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (metadata.asKnown()?.validity() ?: 0) + + /** The cadence to bill for this price on. */ + class Cadence @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Configuration for cumulative_grouped_allocation pricing */ + class CumulativeGroupedAllocationConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cumulativeAllocation: JsonField, + private val groupAllocation: JsonField, + private val groupingKey: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cumulative_allocation") + @ExcludeMissing + cumulativeAllocation: JsonField = JsonMissing.of(), + @JsonProperty("group_allocation") + @ExcludeMissing + groupAllocation: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this( + cumulativeAllocation, + groupAllocation, + groupingKey, + unitAmount, + mutableMapOf(), + ) + + /** + * The overall allocation across all groups + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cumulativeAllocation(): String = + cumulativeAllocation.getRequired("cumulative_allocation") + + /** + * The allocation per individual group + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupAllocation(): String = groupAllocation.getRequired("group_allocation") + + /** + * The event property used to group usage before applying allocations + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The amount to charge for each unit outside of the allocation + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [cumulativeAllocation]. + * + * Unlike [cumulativeAllocation], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("cumulative_allocation") + @ExcludeMissing + fun _cumulativeAllocation(): JsonField = cumulativeAllocation + + /** + * Returns the raw JSON value of [groupAllocation]. + * + * Unlike [groupAllocation], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("group_allocation") + @ExcludeMissing + fun _groupAllocation(): JsonField = groupAllocation + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [CumulativeGroupedAllocationConfig]. + * + * The following fields are required: + * ```kotlin + * .cumulativeAllocation() + * .groupAllocation() + * .groupingKey() + * .unitAmount() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [CumulativeGroupedAllocationConfig]. */ + class Builder internal constructor() { + + private var cumulativeAllocation: JsonField? = null + private var groupAllocation: JsonField? = null + private var groupingKey: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from( + cumulativeGroupedAllocationConfig: CumulativeGroupedAllocationConfig + ) = apply { + cumulativeAllocation = + cumulativeGroupedAllocationConfig.cumulativeAllocation + groupAllocation = cumulativeGroupedAllocationConfig.groupAllocation + groupingKey = cumulativeGroupedAllocationConfig.groupingKey + unitAmount = cumulativeGroupedAllocationConfig.unitAmount + additionalProperties = + cumulativeGroupedAllocationConfig.additionalProperties.toMutableMap() + } + + /** The overall allocation across all groups */ + fun cumulativeAllocation(cumulativeAllocation: String) = + cumulativeAllocation(JsonField.of(cumulativeAllocation)) + + /** + * Sets [Builder.cumulativeAllocation] to an arbitrary JSON value. + * + * You should usually call [Builder.cumulativeAllocation] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun cumulativeAllocation(cumulativeAllocation: JsonField) = apply { + this.cumulativeAllocation = cumulativeAllocation + } + + /** The allocation per individual group */ + fun groupAllocation(groupAllocation: String) = + groupAllocation(JsonField.of(groupAllocation)) + + /** + * Sets [Builder.groupAllocation] to an arbitrary JSON value. + * + * You should usually call [Builder.groupAllocation] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupAllocation(groupAllocation: JsonField) = apply { + this.groupAllocation = groupAllocation + } + + /** The event property used to group usage before applying allocations */ + fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The amount to charge for each unit outside of the allocation */ + fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CumulativeGroupedAllocationConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cumulativeAllocation() + * .groupAllocation() + * .groupingKey() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CumulativeGroupedAllocationConfig = + CumulativeGroupedAllocationConfig( + checkRequired("cumulativeAllocation", cumulativeAllocation), + checkRequired("groupAllocation", groupAllocation), + checkRequired("groupingKey", groupingKey), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CumulativeGroupedAllocationConfig = apply { + if (validated) { + return@apply + } + + cumulativeAllocation() + groupAllocation() + groupingKey() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (cumulativeAllocation.asKnown() == null) 0 else 1) + + (if (groupAllocation.asKnown() == null) 0 else 1) + + (if (groupingKey.asKnown() == null) 0 else 1) + + (if (unitAmount.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CumulativeGroupedAllocationConfig && + cumulativeAllocation == other.cumulativeAllocation && + groupAllocation == other.groupAllocation && + groupingKey == other.groupingKey && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cumulativeAllocation, + groupAllocation, + groupingKey, + unitAmount, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CumulativeGroupedAllocationConfig{cumulativeAllocation=$cumulativeAllocation, groupAllocation=$groupAllocation, groupingKey=$groupingKey, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CumulativeGroupedAllocation && + cadence == other.cadence && + cumulativeGroupedAllocationConfig == other.cumulativeGroupedAllocationConfig && + currency == other.currency && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + cumulativeGroupedAllocationConfig, + currency, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CumulativeGroupedAllocation{cadence=$cadence, cumulativeGroupedAllocationConfig=$cumulativeGroupedAllocationConfig, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + } + class Percent @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceEvaluateMultipleParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceEvaluateMultipleParams.kt index e4c93aeb4..b8cdeb8e2 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceEvaluateMultipleParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceEvaluateMultipleParams.kt @@ -1146,6 +1146,13 @@ private constructor( fun price(cumulativeGroupedBulk: NewFloatingCumulativeGroupedBulkPrice) = price(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) + /** + * Alias for calling [price] with + * `Price.ofCumulativeGroupedAllocation(cumulativeGroupedAllocation)`. + */ + fun price(cumulativeGroupedAllocation: Price.CumulativeGroupedAllocation) = + price(Price.ofCumulativeGroupedAllocation(cumulativeGroupedAllocation)) + /** Alias for calling [price] with `Price.ofMinimum(minimum)`. */ fun price(minimum: NewFloatingMinimumCompositePrice) = price(Price.ofMinimum(minimum)) @@ -1276,6 +1283,7 @@ private constructor( NewFloatingScalableMatrixWithTieredPricingPrice? = null, private val cumulativeGroupedBulk: NewFloatingCumulativeGroupedBulkPrice? = null, + private val cumulativeGroupedAllocation: CumulativeGroupedAllocation? = null, private val minimum: NewFloatingMinimumCompositePrice? = null, private val percent: Percent? = null, private val eventOutput: EventOutput? = null, @@ -1346,6 +1354,9 @@ private constructor( fun cumulativeGroupedBulk(): NewFloatingCumulativeGroupedBulkPrice? = cumulativeGroupedBulk + fun cumulativeGroupedAllocation(): CumulativeGroupedAllocation? = + cumulativeGroupedAllocation + fun minimum(): NewFloatingMinimumCompositePrice? = minimum fun percent(): Percent? = percent @@ -1407,6 +1418,8 @@ private constructor( fun isCumulativeGroupedBulk(): Boolean = cumulativeGroupedBulk != null + fun isCumulativeGroupedAllocation(): Boolean = cumulativeGroupedAllocation != null + fun isMinimum(): Boolean = minimum != null fun isPercent(): Boolean = percent != null @@ -1489,6 +1502,9 @@ private constructor( fun asCumulativeGroupedBulk(): NewFloatingCumulativeGroupedBulkPrice = cumulativeGroupedBulk.getOrThrow("cumulativeGroupedBulk") + fun asCumulativeGroupedAllocation(): CumulativeGroupedAllocation = + cumulativeGroupedAllocation.getOrThrow("cumulativeGroupedAllocation") + fun asMinimum(): NewFloatingMinimumCompositePrice = minimum.getOrThrow("minimum") fun asPercent(): Percent = percent.getOrThrow("percent") @@ -1542,6 +1558,8 @@ private constructor( ) cumulativeGroupedBulk != null -> visitor.visitCumulativeGroupedBulk(cumulativeGroupedBulk) + cumulativeGroupedAllocation != null -> + visitor.visitCumulativeGroupedAllocation(cumulativeGroupedAllocation) minimum != null -> visitor.visitMinimum(minimum) percent != null -> visitor.visitPercent(percent) eventOutput != null -> visitor.visitEventOutput(eventOutput) @@ -1709,6 +1727,12 @@ private constructor( cumulativeGroupedBulk.validate() } + override fun visitCumulativeGroupedAllocation( + cumulativeGroupedAllocation: CumulativeGroupedAllocation + ) { + cumulativeGroupedAllocation.validate() + } + override fun visitMinimum(minimum: NewFloatingMinimumCompositePrice) { minimum.validate() } @@ -1842,6 +1866,10 @@ private constructor( cumulativeGroupedBulk: NewFloatingCumulativeGroupedBulkPrice ) = cumulativeGroupedBulk.validity() + override fun visitCumulativeGroupedAllocation( + cumulativeGroupedAllocation: CumulativeGroupedAllocation + ) = cumulativeGroupedAllocation.validity() + override fun visitMinimum(minimum: NewFloatingMinimumCompositePrice) = minimum.validity() @@ -1887,6 +1915,7 @@ private constructor( scalableMatrixWithUnitPricing == other.scalableMatrixWithUnitPricing && scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && cumulativeGroupedBulk == other.cumulativeGroupedBulk && + cumulativeGroupedAllocation == other.cumulativeGroupedAllocation && minimum == other.minimum && percent == other.percent && eventOutput == other.eventOutput @@ -1921,6 +1950,7 @@ private constructor( scalableMatrixWithUnitPricing, scalableMatrixWithTieredPricing, cumulativeGroupedBulk, + cumulativeGroupedAllocation, minimum, percent, eventOutput, @@ -1968,6 +1998,8 @@ private constructor( "Price{scalableMatrixWithTieredPricing=$scalableMatrixWithTieredPricing}" cumulativeGroupedBulk != null -> "Price{cumulativeGroupedBulk=$cumulativeGroupedBulk}" + cumulativeGroupedAllocation != null -> + "Price{cumulativeGroupedAllocation=$cumulativeGroupedAllocation}" minimum != null -> "Price{minimum=$minimum}" percent != null -> "Price{percent=$percent}" eventOutput != null -> "Price{eventOutput=$eventOutput}" @@ -2067,6 +2099,10 @@ private constructor( cumulativeGroupedBulk: NewFloatingCumulativeGroupedBulkPrice ) = Price(cumulativeGroupedBulk = cumulativeGroupedBulk) + fun ofCumulativeGroupedAllocation( + cumulativeGroupedAllocation: CumulativeGroupedAllocation + ) = Price(cumulativeGroupedAllocation = cumulativeGroupedAllocation) + fun ofMinimum(minimum: NewFloatingMinimumCompositePrice) = Price(minimum = minimum) fun ofPercent(percent: Percent) = Price(percent = percent) @@ -2161,6 +2197,10 @@ private constructor( cumulativeGroupedBulk: NewFloatingCumulativeGroupedBulkPrice ): T + fun visitCumulativeGroupedAllocation( + cumulativeGroupedAllocation: CumulativeGroupedAllocation + ): T + fun visitMinimum(minimum: NewFloatingMinimumCompositePrice): T fun visitPercent(percent: Percent): T @@ -2384,6 +2424,14 @@ private constructor( ?.let { Price(cumulativeGroupedBulk = it, _json = json) } ?: Price(_json = json) } + "cumulative_grouped_allocation" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(cumulativeGroupedAllocation = it, _json = json) } + ?: Price(_json = json) + } "minimum" -> { return tryDeserialize( node, @@ -2462,6 +2510,8 @@ private constructor( generator.writeObject(value.scalableMatrixWithTieredPricing) value.cumulativeGroupedBulk != null -> generator.writeObject(value.cumulativeGroupedBulk) + value.cumulativeGroupedAllocation != null -> + generator.writeObject(value.cumulativeGroupedAllocation) value.minimum != null -> generator.writeObject(value.minimum) value.percent != null -> generator.writeObject(value.percent) value.eventOutput != null -> generator.writeObject(value.eventOutput) @@ -6104,6 +6154,1661 @@ private constructor( "GroupedWithMinMaxThresholds{cadence=$cadence, currency=$currency, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" } + class CumulativeGroupedAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val cumulativeGroupedAllocationConfig: + JsonField, + private val currency: JsonField, + private val itemId: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val metadata: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("cumulative_grouped_allocation_config") + @ExcludeMissing + cumulativeGroupedAllocationConfig: + JsonField = + JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + ) : this( + cadence, + cumulativeGroupedAllocationConfig, + currency, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * Configuration for cumulative_grouped_allocation pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cumulativeGroupedAllocationConfig(): CumulativeGroupedAllocationConfig = + cumulativeGroupedAllocationConfig.getRequired( + "cumulative_grouped_allocation_config" + ) + + /** + * An ISO 4217 currency string for which this price is billed in. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("cumulative_grouped_allocation") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = billableMetricId.getNullable("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + invoiceGroupingKey.getNullable("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [cumulativeGroupedAllocationConfig]. + * + * Unlike [cumulativeGroupedAllocationConfig], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("cumulative_grouped_allocation_config") + @ExcludeMissing + fun _cumulativeGroupedAllocationConfig(): + JsonField = cumulativeGroupedAllocationConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [CumulativeGroupedAllocation]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .cumulativeGroupedAllocationConfig() + * .currency() + * .itemId() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [CumulativeGroupedAllocation]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var cumulativeGroupedAllocationConfig: + JsonField? = + null + private var currency: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonValue = + JsonValue.from("cumulative_grouped_allocation") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(cumulativeGroupedAllocation: CumulativeGroupedAllocation) = + apply { + cadence = cumulativeGroupedAllocation.cadence + cumulativeGroupedAllocationConfig = + cumulativeGroupedAllocation.cumulativeGroupedAllocationConfig + currency = cumulativeGroupedAllocation.currency + itemId = cumulativeGroupedAllocation.itemId + modelType = cumulativeGroupedAllocation.modelType + name = cumulativeGroupedAllocation.name + billableMetricId = cumulativeGroupedAllocation.billableMetricId + billedInAdvance = cumulativeGroupedAllocation.billedInAdvance + billingCycleConfiguration = + cumulativeGroupedAllocation.billingCycleConfiguration + conversionRate = cumulativeGroupedAllocation.conversionRate + conversionRateConfig = cumulativeGroupedAllocation.conversionRateConfig + dimensionalPriceConfiguration = + cumulativeGroupedAllocation.dimensionalPriceConfiguration + externalPriceId = cumulativeGroupedAllocation.externalPriceId + fixedPriceQuantity = cumulativeGroupedAllocation.fixedPriceQuantity + invoiceGroupingKey = cumulativeGroupedAllocation.invoiceGroupingKey + invoicingCycleConfiguration = + cumulativeGroupedAllocation.invoicingCycleConfiguration + metadata = cumulativeGroupedAllocation.metadata + additionalProperties = + cumulativeGroupedAllocation.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** Configuration for cumulative_grouped_allocation pricing */ + fun cumulativeGroupedAllocationConfig( + cumulativeGroupedAllocationConfig: CumulativeGroupedAllocationConfig + ) = + cumulativeGroupedAllocationConfig( + JsonField.of(cumulativeGroupedAllocationConfig) + ) + + /** + * Sets [Builder.cumulativeGroupedAllocationConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.cumulativeGroupedAllocationConfig] with a + * well-typed [CumulativeGroupedAllocationConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun cumulativeGroupedAllocationConfig( + cumulativeGroupedAllocationConfig: + JsonField + ) = apply { + this.cumulativeGroupedAllocationConfig = cumulativeGroupedAllocationConfig + } + + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("cumulative_grouped_allocation") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CumulativeGroupedAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .cumulativeGroupedAllocationConfig() + * .currency() + * .itemId() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CumulativeGroupedAllocation = + CumulativeGroupedAllocation( + checkRequired("cadence", cadence), + checkRequired( + "cumulativeGroupedAllocationConfig", + cumulativeGroupedAllocationConfig, + ), + checkRequired("currency", currency), + checkRequired("itemId", itemId), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CumulativeGroupedAllocation = apply { + if (validated) { + return@apply + } + + cadence().validate() + cumulativeGroupedAllocationConfig().validate() + currency() + itemId() + _modelType().let { + if (it != JsonValue.from("cumulative_grouped_allocation")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + metadata()?.validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (cumulativeGroupedAllocationConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (if (itemId.asKnown() == null) 0 else 1) + + modelType.let { + if (it == JsonValue.from("cumulative_grouped_allocation")) 1 else 0 + } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (metadata.asKnown()?.validity() ?: 0) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Configuration for cumulative_grouped_allocation pricing */ + class CumulativeGroupedAllocationConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cumulativeAllocation: JsonField, + private val groupAllocation: JsonField, + private val groupingKey: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cumulative_allocation") + @ExcludeMissing + cumulativeAllocation: JsonField = JsonMissing.of(), + @JsonProperty("group_allocation") + @ExcludeMissing + groupAllocation: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this( + cumulativeAllocation, + groupAllocation, + groupingKey, + unitAmount, + mutableMapOf(), + ) + + /** + * The overall allocation across all groups + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun cumulativeAllocation(): String = + cumulativeAllocation.getRequired("cumulative_allocation") + + /** + * The allocation per individual group + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun groupAllocation(): String = groupAllocation.getRequired("group_allocation") + + /** + * The event property used to group usage before applying allocations + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The amount to charge for each unit outside of the allocation + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [cumulativeAllocation]. + * + * Unlike [cumulativeAllocation], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("cumulative_allocation") + @ExcludeMissing + fun _cumulativeAllocation(): JsonField = cumulativeAllocation + + /** + * Returns the raw JSON value of [groupAllocation]. + * + * Unlike [groupAllocation], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("group_allocation") + @ExcludeMissing + fun _groupAllocation(): JsonField = groupAllocation + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [CumulativeGroupedAllocationConfig]. + * + * The following fields are required: + * ```kotlin + * .cumulativeAllocation() + * .groupAllocation() + * .groupingKey() + * .unitAmount() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [CumulativeGroupedAllocationConfig]. */ + class Builder internal constructor() { + + private var cumulativeAllocation: JsonField? = null + private var groupAllocation: JsonField? = null + private var groupingKey: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from( + cumulativeGroupedAllocationConfig: CumulativeGroupedAllocationConfig + ) = apply { + cumulativeAllocation = + cumulativeGroupedAllocationConfig.cumulativeAllocation + groupAllocation = cumulativeGroupedAllocationConfig.groupAllocation + groupingKey = cumulativeGroupedAllocationConfig.groupingKey + unitAmount = cumulativeGroupedAllocationConfig.unitAmount + additionalProperties = + cumulativeGroupedAllocationConfig.additionalProperties + .toMutableMap() + } + + /** The overall allocation across all groups */ + fun cumulativeAllocation(cumulativeAllocation: String) = + cumulativeAllocation(JsonField.of(cumulativeAllocation)) + + /** + * Sets [Builder.cumulativeAllocation] to an arbitrary JSON value. + * + * You should usually call [Builder.cumulativeAllocation] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun cumulativeAllocation(cumulativeAllocation: JsonField) = apply { + this.cumulativeAllocation = cumulativeAllocation + } + + /** The allocation per individual group */ + fun groupAllocation(groupAllocation: String) = + groupAllocation(JsonField.of(groupAllocation)) + + /** + * Sets [Builder.groupAllocation] to an arbitrary JSON value. + * + * You should usually call [Builder.groupAllocation] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun groupAllocation(groupAllocation: JsonField) = apply { + this.groupAllocation = groupAllocation + } + + /** The event property used to group usage before applying allocations */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The amount to charge for each unit outside of the allocation */ + fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CumulativeGroupedAllocationConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cumulativeAllocation() + * .groupAllocation() + * .groupingKey() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CumulativeGroupedAllocationConfig = + CumulativeGroupedAllocationConfig( + checkRequired("cumulativeAllocation", cumulativeAllocation), + checkRequired("groupAllocation", groupAllocation), + checkRequired("groupingKey", groupingKey), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CumulativeGroupedAllocationConfig = apply { + if (validated) { + return@apply + } + + cumulativeAllocation() + groupAllocation() + groupingKey() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (cumulativeAllocation.asKnown() == null) 0 else 1) + + (if (groupAllocation.asKnown() == null) 0 else 1) + + (if (groupingKey.asKnown() == null) 0 else 1) + + (if (unitAmount.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CumulativeGroupedAllocationConfig && + cumulativeAllocation == other.cumulativeAllocation && + groupAllocation == other.groupAllocation && + groupingKey == other.groupingKey && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cumulativeAllocation, + groupAllocation, + groupingKey, + unitAmount, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CumulativeGroupedAllocationConfig{cumulativeAllocation=$cumulativeAllocation, groupAllocation=$groupAllocation, groupingKey=$groupingKey, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CumulativeGroupedAllocation && + cadence == other.cadence && + cumulativeGroupedAllocationConfig == + other.cumulativeGroupedAllocationConfig && + currency == other.currency && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + cumulativeGroupedAllocationConfig, + currency, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CumulativeGroupedAllocation{cadence=$cadence, cumulativeGroupedAllocationConfig=$cumulativeGroupedAllocationConfig, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + } + class Percent @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceEvaluatePreviewEventsParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceEvaluatePreviewEventsParams.kt index d4b0b5a00..363446549 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceEvaluatePreviewEventsParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceEvaluatePreviewEventsParams.kt @@ -1681,6 +1681,13 @@ private constructor( fun price(cumulativeGroupedBulk: NewFloatingCumulativeGroupedBulkPrice) = price(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) + /** + * Alias for calling [price] with + * `Price.ofCumulativeGroupedAllocation(cumulativeGroupedAllocation)`. + */ + fun price(cumulativeGroupedAllocation: Price.CumulativeGroupedAllocation) = + price(Price.ofCumulativeGroupedAllocation(cumulativeGroupedAllocation)) + /** Alias for calling [price] with `Price.ofMinimum(minimum)`. */ fun price(minimum: NewFloatingMinimumCompositePrice) = price(Price.ofMinimum(minimum)) @@ -1811,6 +1818,7 @@ private constructor( NewFloatingScalableMatrixWithTieredPricingPrice? = null, private val cumulativeGroupedBulk: NewFloatingCumulativeGroupedBulkPrice? = null, + private val cumulativeGroupedAllocation: CumulativeGroupedAllocation? = null, private val minimum: NewFloatingMinimumCompositePrice? = null, private val percent: Percent? = null, private val eventOutput: EventOutput? = null, @@ -1881,6 +1889,9 @@ private constructor( fun cumulativeGroupedBulk(): NewFloatingCumulativeGroupedBulkPrice? = cumulativeGroupedBulk + fun cumulativeGroupedAllocation(): CumulativeGroupedAllocation? = + cumulativeGroupedAllocation + fun minimum(): NewFloatingMinimumCompositePrice? = minimum fun percent(): Percent? = percent @@ -1942,6 +1953,8 @@ private constructor( fun isCumulativeGroupedBulk(): Boolean = cumulativeGroupedBulk != null + fun isCumulativeGroupedAllocation(): Boolean = cumulativeGroupedAllocation != null + fun isMinimum(): Boolean = minimum != null fun isPercent(): Boolean = percent != null @@ -2024,6 +2037,9 @@ private constructor( fun asCumulativeGroupedBulk(): NewFloatingCumulativeGroupedBulkPrice = cumulativeGroupedBulk.getOrThrow("cumulativeGroupedBulk") + fun asCumulativeGroupedAllocation(): CumulativeGroupedAllocation = + cumulativeGroupedAllocation.getOrThrow("cumulativeGroupedAllocation") + fun asMinimum(): NewFloatingMinimumCompositePrice = minimum.getOrThrow("minimum") fun asPercent(): Percent = percent.getOrThrow("percent") @@ -2077,6 +2093,8 @@ private constructor( ) cumulativeGroupedBulk != null -> visitor.visitCumulativeGroupedBulk(cumulativeGroupedBulk) + cumulativeGroupedAllocation != null -> + visitor.visitCumulativeGroupedAllocation(cumulativeGroupedAllocation) minimum != null -> visitor.visitMinimum(minimum) percent != null -> visitor.visitPercent(percent) eventOutput != null -> visitor.visitEventOutput(eventOutput) @@ -2244,6 +2262,12 @@ private constructor( cumulativeGroupedBulk.validate() } + override fun visitCumulativeGroupedAllocation( + cumulativeGroupedAllocation: CumulativeGroupedAllocation + ) { + cumulativeGroupedAllocation.validate() + } + override fun visitMinimum(minimum: NewFloatingMinimumCompositePrice) { minimum.validate() } @@ -2377,6 +2401,10 @@ private constructor( cumulativeGroupedBulk: NewFloatingCumulativeGroupedBulkPrice ) = cumulativeGroupedBulk.validity() + override fun visitCumulativeGroupedAllocation( + cumulativeGroupedAllocation: CumulativeGroupedAllocation + ) = cumulativeGroupedAllocation.validity() + override fun visitMinimum(minimum: NewFloatingMinimumCompositePrice) = minimum.validity() @@ -2422,6 +2450,7 @@ private constructor( scalableMatrixWithUnitPricing == other.scalableMatrixWithUnitPricing && scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && cumulativeGroupedBulk == other.cumulativeGroupedBulk && + cumulativeGroupedAllocation == other.cumulativeGroupedAllocation && minimum == other.minimum && percent == other.percent && eventOutput == other.eventOutput @@ -2456,6 +2485,7 @@ private constructor( scalableMatrixWithUnitPricing, scalableMatrixWithTieredPricing, cumulativeGroupedBulk, + cumulativeGroupedAllocation, minimum, percent, eventOutput, @@ -2503,6 +2533,8 @@ private constructor( "Price{scalableMatrixWithTieredPricing=$scalableMatrixWithTieredPricing}" cumulativeGroupedBulk != null -> "Price{cumulativeGroupedBulk=$cumulativeGroupedBulk}" + cumulativeGroupedAllocation != null -> + "Price{cumulativeGroupedAllocation=$cumulativeGroupedAllocation}" minimum != null -> "Price{minimum=$minimum}" percent != null -> "Price{percent=$percent}" eventOutput != null -> "Price{eventOutput=$eventOutput}" @@ -2602,6 +2634,10 @@ private constructor( cumulativeGroupedBulk: NewFloatingCumulativeGroupedBulkPrice ) = Price(cumulativeGroupedBulk = cumulativeGroupedBulk) + fun ofCumulativeGroupedAllocation( + cumulativeGroupedAllocation: CumulativeGroupedAllocation + ) = Price(cumulativeGroupedAllocation = cumulativeGroupedAllocation) + fun ofMinimum(minimum: NewFloatingMinimumCompositePrice) = Price(minimum = minimum) fun ofPercent(percent: Percent) = Price(percent = percent) @@ -2696,6 +2732,10 @@ private constructor( cumulativeGroupedBulk: NewFloatingCumulativeGroupedBulkPrice ): T + fun visitCumulativeGroupedAllocation( + cumulativeGroupedAllocation: CumulativeGroupedAllocation + ): T + fun visitMinimum(minimum: NewFloatingMinimumCompositePrice): T fun visitPercent(percent: Percent): T @@ -2919,6 +2959,14 @@ private constructor( ?.let { Price(cumulativeGroupedBulk = it, _json = json) } ?: Price(_json = json) } + "cumulative_grouped_allocation" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(cumulativeGroupedAllocation = it, _json = json) } + ?: Price(_json = json) + } "minimum" -> { return tryDeserialize( node, @@ -2997,6 +3045,8 @@ private constructor( generator.writeObject(value.scalableMatrixWithTieredPricing) value.cumulativeGroupedBulk != null -> generator.writeObject(value.cumulativeGroupedBulk) + value.cumulativeGroupedAllocation != null -> + generator.writeObject(value.cumulativeGroupedAllocation) value.minimum != null -> generator.writeObject(value.minimum) value.percent != null -> generator.writeObject(value.percent) value.eventOutput != null -> generator.writeObject(value.eventOutput) @@ -6639,6 +6689,1661 @@ private constructor( "GroupedWithMinMaxThresholds{cadence=$cadence, currency=$currency, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" } + class CumulativeGroupedAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val cumulativeGroupedAllocationConfig: + JsonField, + private val currency: JsonField, + private val itemId: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val metadata: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("cumulative_grouped_allocation_config") + @ExcludeMissing + cumulativeGroupedAllocationConfig: + JsonField = + JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + ) : this( + cadence, + cumulativeGroupedAllocationConfig, + currency, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * Configuration for cumulative_grouped_allocation pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cumulativeGroupedAllocationConfig(): CumulativeGroupedAllocationConfig = + cumulativeGroupedAllocationConfig.getRequired( + "cumulative_grouped_allocation_config" + ) + + /** + * An ISO 4217 currency string for which this price is billed in. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("cumulative_grouped_allocation") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = billableMetricId.getNullable("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + invoiceGroupingKey.getNullable("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [cumulativeGroupedAllocationConfig]. + * + * Unlike [cumulativeGroupedAllocationConfig], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("cumulative_grouped_allocation_config") + @ExcludeMissing + fun _cumulativeGroupedAllocationConfig(): + JsonField = cumulativeGroupedAllocationConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [CumulativeGroupedAllocation]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .cumulativeGroupedAllocationConfig() + * .currency() + * .itemId() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [CumulativeGroupedAllocation]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var cumulativeGroupedAllocationConfig: + JsonField? = + null + private var currency: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonValue = + JsonValue.from("cumulative_grouped_allocation") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(cumulativeGroupedAllocation: CumulativeGroupedAllocation) = + apply { + cadence = cumulativeGroupedAllocation.cadence + cumulativeGroupedAllocationConfig = + cumulativeGroupedAllocation.cumulativeGroupedAllocationConfig + currency = cumulativeGroupedAllocation.currency + itemId = cumulativeGroupedAllocation.itemId + modelType = cumulativeGroupedAllocation.modelType + name = cumulativeGroupedAllocation.name + billableMetricId = cumulativeGroupedAllocation.billableMetricId + billedInAdvance = cumulativeGroupedAllocation.billedInAdvance + billingCycleConfiguration = + cumulativeGroupedAllocation.billingCycleConfiguration + conversionRate = cumulativeGroupedAllocation.conversionRate + conversionRateConfig = cumulativeGroupedAllocation.conversionRateConfig + dimensionalPriceConfiguration = + cumulativeGroupedAllocation.dimensionalPriceConfiguration + externalPriceId = cumulativeGroupedAllocation.externalPriceId + fixedPriceQuantity = cumulativeGroupedAllocation.fixedPriceQuantity + invoiceGroupingKey = cumulativeGroupedAllocation.invoiceGroupingKey + invoicingCycleConfiguration = + cumulativeGroupedAllocation.invoicingCycleConfiguration + metadata = cumulativeGroupedAllocation.metadata + additionalProperties = + cumulativeGroupedAllocation.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** Configuration for cumulative_grouped_allocation pricing */ + fun cumulativeGroupedAllocationConfig( + cumulativeGroupedAllocationConfig: CumulativeGroupedAllocationConfig + ) = + cumulativeGroupedAllocationConfig( + JsonField.of(cumulativeGroupedAllocationConfig) + ) + + /** + * Sets [Builder.cumulativeGroupedAllocationConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.cumulativeGroupedAllocationConfig] with a + * well-typed [CumulativeGroupedAllocationConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun cumulativeGroupedAllocationConfig( + cumulativeGroupedAllocationConfig: + JsonField + ) = apply { + this.cumulativeGroupedAllocationConfig = cumulativeGroupedAllocationConfig + } + + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("cumulative_grouped_allocation") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CumulativeGroupedAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .cumulativeGroupedAllocationConfig() + * .currency() + * .itemId() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CumulativeGroupedAllocation = + CumulativeGroupedAllocation( + checkRequired("cadence", cadence), + checkRequired( + "cumulativeGroupedAllocationConfig", + cumulativeGroupedAllocationConfig, + ), + checkRequired("currency", currency), + checkRequired("itemId", itemId), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CumulativeGroupedAllocation = apply { + if (validated) { + return@apply + } + + cadence().validate() + cumulativeGroupedAllocationConfig().validate() + currency() + itemId() + _modelType().let { + if (it != JsonValue.from("cumulative_grouped_allocation")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + metadata()?.validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (cumulativeGroupedAllocationConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (if (itemId.asKnown() == null) 0 else 1) + + modelType.let { + if (it == JsonValue.from("cumulative_grouped_allocation")) 1 else 0 + } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (metadata.asKnown()?.validity() ?: 0) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Configuration for cumulative_grouped_allocation pricing */ + class CumulativeGroupedAllocationConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cumulativeAllocation: JsonField, + private val groupAllocation: JsonField, + private val groupingKey: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cumulative_allocation") + @ExcludeMissing + cumulativeAllocation: JsonField = JsonMissing.of(), + @JsonProperty("group_allocation") + @ExcludeMissing + groupAllocation: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this( + cumulativeAllocation, + groupAllocation, + groupingKey, + unitAmount, + mutableMapOf(), + ) + + /** + * The overall allocation across all groups + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun cumulativeAllocation(): String = + cumulativeAllocation.getRequired("cumulative_allocation") + + /** + * The allocation per individual group + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun groupAllocation(): String = groupAllocation.getRequired("group_allocation") + + /** + * The event property used to group usage before applying allocations + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The amount to charge for each unit outside of the allocation + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [cumulativeAllocation]. + * + * Unlike [cumulativeAllocation], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("cumulative_allocation") + @ExcludeMissing + fun _cumulativeAllocation(): JsonField = cumulativeAllocation + + /** + * Returns the raw JSON value of [groupAllocation]. + * + * Unlike [groupAllocation], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("group_allocation") + @ExcludeMissing + fun _groupAllocation(): JsonField = groupAllocation + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [CumulativeGroupedAllocationConfig]. + * + * The following fields are required: + * ```kotlin + * .cumulativeAllocation() + * .groupAllocation() + * .groupingKey() + * .unitAmount() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [CumulativeGroupedAllocationConfig]. */ + class Builder internal constructor() { + + private var cumulativeAllocation: JsonField? = null + private var groupAllocation: JsonField? = null + private var groupingKey: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from( + cumulativeGroupedAllocationConfig: CumulativeGroupedAllocationConfig + ) = apply { + cumulativeAllocation = + cumulativeGroupedAllocationConfig.cumulativeAllocation + groupAllocation = cumulativeGroupedAllocationConfig.groupAllocation + groupingKey = cumulativeGroupedAllocationConfig.groupingKey + unitAmount = cumulativeGroupedAllocationConfig.unitAmount + additionalProperties = + cumulativeGroupedAllocationConfig.additionalProperties + .toMutableMap() + } + + /** The overall allocation across all groups */ + fun cumulativeAllocation(cumulativeAllocation: String) = + cumulativeAllocation(JsonField.of(cumulativeAllocation)) + + /** + * Sets [Builder.cumulativeAllocation] to an arbitrary JSON value. + * + * You should usually call [Builder.cumulativeAllocation] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun cumulativeAllocation(cumulativeAllocation: JsonField) = apply { + this.cumulativeAllocation = cumulativeAllocation + } + + /** The allocation per individual group */ + fun groupAllocation(groupAllocation: String) = + groupAllocation(JsonField.of(groupAllocation)) + + /** + * Sets [Builder.groupAllocation] to an arbitrary JSON value. + * + * You should usually call [Builder.groupAllocation] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun groupAllocation(groupAllocation: JsonField) = apply { + this.groupAllocation = groupAllocation + } + + /** The event property used to group usage before applying allocations */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The amount to charge for each unit outside of the allocation */ + fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CumulativeGroupedAllocationConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cumulativeAllocation() + * .groupAllocation() + * .groupingKey() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CumulativeGroupedAllocationConfig = + CumulativeGroupedAllocationConfig( + checkRequired("cumulativeAllocation", cumulativeAllocation), + checkRequired("groupAllocation", groupAllocation), + checkRequired("groupingKey", groupingKey), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CumulativeGroupedAllocationConfig = apply { + if (validated) { + return@apply + } + + cumulativeAllocation() + groupAllocation() + groupingKey() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (cumulativeAllocation.asKnown() == null) 0 else 1) + + (if (groupAllocation.asKnown() == null) 0 else 1) + + (if (groupingKey.asKnown() == null) 0 else 1) + + (if (unitAmount.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CumulativeGroupedAllocationConfig && + cumulativeAllocation == other.cumulativeAllocation && + groupAllocation == other.groupAllocation && + groupingKey == other.groupingKey && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cumulativeAllocation, + groupAllocation, + groupingKey, + unitAmount, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CumulativeGroupedAllocationConfig{cumulativeAllocation=$cumulativeAllocation, groupAllocation=$groupAllocation, groupingKey=$groupingKey, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CumulativeGroupedAllocation && + cadence == other.cadence && + cumulativeGroupedAllocationConfig == + other.cumulativeGroupedAllocationConfig && + currency == other.currency && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + cumulativeGroupedAllocationConfig, + currency, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CumulativeGroupedAllocation{cadence=$cadence, cumulativeGroupedAllocationConfig=$cumulativeGroupedAllocationConfig, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + } + class Percent @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceInterval.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceInterval.kt index 5bd083669..5f1bbada0 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceInterval.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceInterval.kt @@ -646,6 +646,13 @@ private constructor( fun price(cumulativeGroupedBulk: Price.CumulativeGroupedBulk) = price(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) + /** + * Alias for calling [price] with + * `Price.ofCumulativeGroupedAllocation(cumulativeGroupedAllocation)`. + */ + fun price(cumulativeGroupedAllocation: Price.CumulativeGroupedAllocation) = + price(Price.ofCumulativeGroupedAllocation(cumulativeGroupedAllocation)) + /** Alias for calling [price] with `Price.ofMinimum(minimum)`. */ fun price(minimum: Price.Minimum) = price(Price.ofMinimum(minimum)) diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceListPageResponse.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceListPageResponse.kt index f85e61110..f957c0dad 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceListPageResponse.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceListPageResponse.kt @@ -262,6 +262,13 @@ private constructor( fun addData(cumulativeGroupedBulk: Price.CumulativeGroupedBulk) = addData(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) + /** + * Alias for calling [addData] with + * `Price.ofCumulativeGroupedAllocation(cumulativeGroupedAllocation)`. + */ + fun addData(cumulativeGroupedAllocation: Price.CumulativeGroupedAllocation) = + addData(Price.ofCumulativeGroupedAllocation(cumulativeGroupedAllocation)) + /** Alias for calling [addData] with `Price.ofMinimum(minimum)`. */ fun addData(minimum: Price.Minimum) = addData(Price.ofMinimum(minimum)) diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionCreateParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionCreateParams.kt index 064558142..8fa72f75c 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionCreateParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionCreateParams.kt @@ -4698,6 +4698,13 @@ private constructor( fun price(cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice) = price(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) + /** + * Alias for calling [price] with + * `Price.ofCumulativeGroupedAllocation(cumulativeGroupedAllocation)`. + */ + fun price(cumulativeGroupedAllocation: Price.CumulativeGroupedAllocation) = + price(Price.ofCumulativeGroupedAllocation(cumulativeGroupedAllocation)) + /** Alias for calling [price] with `Price.ofMinimum(minimum)`. */ fun price(minimum: NewSubscriptionMinimumCompositePrice) = price(Price.ofMinimum(minimum)) @@ -4864,6 +4871,7 @@ private constructor( NewSubscriptionScalableMatrixWithTieredPricingPrice? = null, private val cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice? = null, + private val cumulativeGroupedAllocation: CumulativeGroupedAllocation? = null, private val minimum: NewSubscriptionMinimumCompositePrice? = null, private val percent: Percent? = null, private val eventOutput: EventOutput? = null, @@ -4938,6 +4946,9 @@ private constructor( fun cumulativeGroupedBulk(): NewSubscriptionCumulativeGroupedBulkPrice? = cumulativeGroupedBulk + fun cumulativeGroupedAllocation(): CumulativeGroupedAllocation? = + cumulativeGroupedAllocation + fun minimum(): NewSubscriptionMinimumCompositePrice? = minimum fun percent(): Percent? = percent @@ -4999,6 +5010,8 @@ private constructor( fun isCumulativeGroupedBulk(): Boolean = cumulativeGroupedBulk != null + fun isCumulativeGroupedAllocation(): Boolean = cumulativeGroupedAllocation != null + fun isMinimum(): Boolean = minimum != null fun isPercent(): Boolean = percent != null @@ -5082,6 +5095,9 @@ private constructor( fun asCumulativeGroupedBulk(): NewSubscriptionCumulativeGroupedBulkPrice = cumulativeGroupedBulk.getOrThrow("cumulativeGroupedBulk") + fun asCumulativeGroupedAllocation(): CumulativeGroupedAllocation = + cumulativeGroupedAllocation.getOrThrow("cumulativeGroupedAllocation") + fun asMinimum(): NewSubscriptionMinimumCompositePrice = minimum.getOrThrow("minimum") fun asPercent(): Percent = percent.getOrThrow("percent") @@ -5135,6 +5151,8 @@ private constructor( ) cumulativeGroupedBulk != null -> visitor.visitCumulativeGroupedBulk(cumulativeGroupedBulk) + cumulativeGroupedAllocation != null -> + visitor.visitCumulativeGroupedAllocation(cumulativeGroupedAllocation) minimum != null -> visitor.visitMinimum(minimum) percent != null -> visitor.visitPercent(percent) eventOutput != null -> visitor.visitEventOutput(eventOutput) @@ -5303,6 +5321,12 @@ private constructor( cumulativeGroupedBulk.validate() } + override fun visitCumulativeGroupedAllocation( + cumulativeGroupedAllocation: CumulativeGroupedAllocation + ) { + cumulativeGroupedAllocation.validate() + } + override fun visitMinimum(minimum: NewSubscriptionMinimumCompositePrice) { minimum.validate() } @@ -5439,6 +5463,10 @@ private constructor( cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice ) = cumulativeGroupedBulk.validity() + override fun visitCumulativeGroupedAllocation( + cumulativeGroupedAllocation: CumulativeGroupedAllocation + ) = cumulativeGroupedAllocation.validity() + override fun visitMinimum(minimum: NewSubscriptionMinimumCompositePrice) = minimum.validity() @@ -5484,6 +5512,7 @@ private constructor( scalableMatrixWithUnitPricing == other.scalableMatrixWithUnitPricing && scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && cumulativeGroupedBulk == other.cumulativeGroupedBulk && + cumulativeGroupedAllocation == other.cumulativeGroupedAllocation && minimum == other.minimum && percent == other.percent && eventOutput == other.eventOutput @@ -5518,6 +5547,7 @@ private constructor( scalableMatrixWithUnitPricing, scalableMatrixWithTieredPricing, cumulativeGroupedBulk, + cumulativeGroupedAllocation, minimum, percent, eventOutput, @@ -5565,6 +5595,8 @@ private constructor( "Price{scalableMatrixWithTieredPricing=$scalableMatrixWithTieredPricing}" cumulativeGroupedBulk != null -> "Price{cumulativeGroupedBulk=$cumulativeGroupedBulk}" + cumulativeGroupedAllocation != null -> + "Price{cumulativeGroupedAllocation=$cumulativeGroupedAllocation}" minimum != null -> "Price{minimum=$minimum}" percent != null -> "Price{percent=$percent}" eventOutput != null -> "Price{eventOutput=$eventOutput}" @@ -5664,6 +5696,10 @@ private constructor( cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice ) = Price(cumulativeGroupedBulk = cumulativeGroupedBulk) + fun ofCumulativeGroupedAllocation( + cumulativeGroupedAllocation: CumulativeGroupedAllocation + ) = Price(cumulativeGroupedAllocation = cumulativeGroupedAllocation) + fun ofMinimum(minimum: NewSubscriptionMinimumCompositePrice) = Price(minimum = minimum) @@ -5766,6 +5802,10 @@ private constructor( cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice ): T + fun visitCumulativeGroupedAllocation( + cumulativeGroupedAllocation: CumulativeGroupedAllocation + ): T + fun visitMinimum(minimum: NewSubscriptionMinimumCompositePrice): T fun visitPercent(percent: Percent): T @@ -5997,6 +6037,14 @@ private constructor( ?.let { Price(cumulativeGroupedBulk = it, _json = json) } ?: Price(_json = json) } + "cumulative_grouped_allocation" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(cumulativeGroupedAllocation = it, _json = json) } + ?: Price(_json = json) + } "minimum" -> { return tryDeserialize( node, @@ -6075,6 +6123,8 @@ private constructor( generator.writeObject(value.scalableMatrixWithTieredPricing) value.cumulativeGroupedBulk != null -> generator.writeObject(value.cumulativeGroupedBulk) + value.cumulativeGroupedAllocation != null -> + generator.writeObject(value.cumulativeGroupedAllocation) value.minimum != null -> generator.writeObject(value.minimum) value.percent != null -> generator.writeObject(value.percent) value.eventOutput != null -> generator.writeObject(value.eventOutput) @@ -11586,14 +11636,15 @@ private constructor( "GroupedWithMinMaxThresholds{cadence=$cadence, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class Percent + class CumulativeGroupedAllocation @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, + private val cumulativeGroupedAllocationConfig: + JsonField, private val itemId: JsonField, private val modelType: JsonValue, private val name: JsonField, - private val percentConfig: JsonField, private val billableMetricId: JsonField, private val billedInAdvance: JsonField, private val billingCycleConfiguration: JsonField, @@ -11616,6 +11667,11 @@ private constructor( @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), + @JsonProperty("cumulative_grouped_allocation_config") + @ExcludeMissing + cumulativeGroupedAllocationConfig: + JsonField = + JsonMissing.of(), @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), @@ -11625,9 +11681,6 @@ private constructor( @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("percent_config") - @ExcludeMissing - percentConfig: JsonField = JsonMissing.of(), @JsonProperty("billable_metric_id") @ExcludeMissing billableMetricId: JsonField = JsonMissing.of(), @@ -11672,10 +11725,10 @@ private constructor( referenceId: JsonField = JsonMissing.of(), ) : this( cadence, + cumulativeGroupedAllocationConfig, itemId, modelType, name, - percentConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -11701,6 +11754,18 @@ private constructor( */ fun cadence(): Cadence = cadence.getRequired("cadence") + /** + * Configuration for cumulative_grouped_allocation pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cumulativeGroupedAllocationConfig(): CumulativeGroupedAllocationConfig = + cumulativeGroupedAllocationConfig.getRequired( + "cumulative_grouped_allocation_config" + ) + /** * The id of the item the price will be associated with. * @@ -11715,7 +11780,7 @@ private constructor( * * Expected to always return the following: * ```kotlin - * JsonValue.from("percent") + * JsonValue.from("cumulative_grouped_allocation") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -11732,15 +11797,6 @@ private constructor( */ fun name(): String = name.getRequired("name") - /** - * Configuration for percent pricing - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun percentConfig(): PercentConfig = percentConfig.getRequired("percent_config") - /** * The id of the billable metric for the price. Only needed if the price is * usage-based. @@ -11870,6 +11926,17 @@ private constructor( @ExcludeMissing fun _cadence(): JsonField = cadence + /** + * Returns the raw JSON value of [cumulativeGroupedAllocationConfig]. + * + * Unlike [cumulativeGroupedAllocationConfig], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("cumulative_grouped_allocation_config") + @ExcludeMissing + fun _cumulativeGroupedAllocationConfig(): + JsonField = cumulativeGroupedAllocationConfig + /** * Returns the raw JSON value of [itemId]. * @@ -11886,16 +11953,6 @@ private constructor( */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - /** - * Returns the raw JSON value of [percentConfig]. - * - * Unlike [percentConfig], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("percent_config") - @ExcludeMissing - fun _percentConfig(): JsonField = percentConfig - /** * Returns the raw JSON value of [billableMetricId]. * @@ -12044,27 +12101,31 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [Percent]. + * Returns a mutable builder for constructing an instance of + * [CumulativeGroupedAllocation]. * * The following fields are required: * ```kotlin * .cadence() + * .cumulativeGroupedAllocationConfig() * .itemId() * .name() - * .percentConfig() * ``` */ fun builder() = Builder() } - /** A builder for [Percent]. */ + /** A builder for [CumulativeGroupedAllocation]. */ class Builder internal constructor() { private var cadence: JsonField? = null + private var cumulativeGroupedAllocationConfig: + JsonField? = + null private var itemId: JsonField? = null - private var modelType: JsonValue = JsonValue.from("percent") + private var modelType: JsonValue = + JsonValue.from("cumulative_grouped_allocation") private var name: JsonField? = null - private var percentConfig: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() private var billingCycleConfiguration: JsonField = @@ -12086,27 +12147,33 @@ private constructor( private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(percent: Percent) = apply { - cadence = percent.cadence - itemId = percent.itemId - modelType = percent.modelType - name = percent.name - percentConfig = percent.percentConfig - billableMetricId = percent.billableMetricId - billedInAdvance = percent.billedInAdvance - billingCycleConfiguration = percent.billingCycleConfiguration - conversionRate = percent.conversionRate - conversionRateConfig = percent.conversionRateConfig - currency = percent.currency - dimensionalPriceConfiguration = percent.dimensionalPriceConfiguration - externalPriceId = percent.externalPriceId - fixedPriceQuantity = percent.fixedPriceQuantity - invoiceGroupingKey = percent.invoiceGroupingKey - invoicingCycleConfiguration = percent.invoicingCycleConfiguration - metadata = percent.metadata - referenceId = percent.referenceId - additionalProperties = percent.additionalProperties.toMutableMap() - } + internal fun from(cumulativeGroupedAllocation: CumulativeGroupedAllocation) = + apply { + cadence = cumulativeGroupedAllocation.cadence + cumulativeGroupedAllocationConfig = + cumulativeGroupedAllocation.cumulativeGroupedAllocationConfig + itemId = cumulativeGroupedAllocation.itemId + modelType = cumulativeGroupedAllocation.modelType + name = cumulativeGroupedAllocation.name + billableMetricId = cumulativeGroupedAllocation.billableMetricId + billedInAdvance = cumulativeGroupedAllocation.billedInAdvance + billingCycleConfiguration = + cumulativeGroupedAllocation.billingCycleConfiguration + conversionRate = cumulativeGroupedAllocation.conversionRate + conversionRateConfig = cumulativeGroupedAllocation.conversionRateConfig + currency = cumulativeGroupedAllocation.currency + dimensionalPriceConfiguration = + cumulativeGroupedAllocation.dimensionalPriceConfiguration + externalPriceId = cumulativeGroupedAllocation.externalPriceId + fixedPriceQuantity = cumulativeGroupedAllocation.fixedPriceQuantity + invoiceGroupingKey = cumulativeGroupedAllocation.invoiceGroupingKey + invoicingCycleConfiguration = + cumulativeGroupedAllocation.invoicingCycleConfiguration + metadata = cumulativeGroupedAllocation.metadata + referenceId = cumulativeGroupedAllocation.referenceId + additionalProperties = + cumulativeGroupedAllocation.additionalProperties.toMutableMap() + } /** The cadence to bill for this price on. */ fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) @@ -12120,6 +12187,29 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + /** Configuration for cumulative_grouped_allocation pricing */ + fun cumulativeGroupedAllocationConfig( + cumulativeGroupedAllocationConfig: CumulativeGroupedAllocationConfig + ) = + cumulativeGroupedAllocationConfig( + JsonField.of(cumulativeGroupedAllocationConfig) + ) + + /** + * Sets [Builder.cumulativeGroupedAllocationConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.cumulativeGroupedAllocationConfig] with a + * well-typed [CumulativeGroupedAllocationConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun cumulativeGroupedAllocationConfig( + cumulativeGroupedAllocationConfig: + JsonField + ) = apply { + this.cumulativeGroupedAllocationConfig = cumulativeGroupedAllocationConfig + } + /** The id of the item the price will be associated with. */ fun itemId(itemId: String) = itemId(JsonField.of(itemId)) @@ -12138,7 +12228,7 @@ private constructor( * It is usually unnecessary to call this method because the field defaults to * the following: * ```kotlin - * JsonValue.from("percent") + * JsonValue.from("cumulative_grouped_allocation") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -12158,21 +12248,6 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } - /** Configuration for percent pricing */ - fun percentConfig(percentConfig: PercentConfig) = - percentConfig(JsonField.of(percentConfig)) - - /** - * Sets [Builder.percentConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.percentConfig] with a well-typed - * [PercentConfig] value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. - */ - fun percentConfig(percentConfig: JsonField) = apply { - this.percentConfig = percentConfig - } - /** * The id of the billable metric for the price. Only needed if the price is * usage-based. @@ -12502,27 +12577,30 @@ private constructor( } /** - * Returns an immutable instance of [Percent]. + * Returns an immutable instance of [CumulativeGroupedAllocation]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```kotlin * .cadence() + * .cumulativeGroupedAllocationConfig() * .itemId() * .name() - * .percentConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): Percent = - Percent( + fun build(): CumulativeGroupedAllocation = + CumulativeGroupedAllocation( checkRequired("cadence", cadence), + checkRequired( + "cumulativeGroupedAllocationConfig", + cumulativeGroupedAllocationConfig, + ), checkRequired("itemId", itemId), modelType, checkRequired("name", name), - checkRequired("percentConfig", percentConfig), billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -12542,20 +12620,20 @@ private constructor( private var validated: Boolean = false - fun validate(): Percent = apply { + fun validate(): CumulativeGroupedAllocation = apply { if (validated) { return@apply } cadence().validate() + cumulativeGroupedAllocationConfig().validate() itemId() _modelType().let { - if (it != JsonValue.from("percent")) { + if (it != JsonValue.from("cumulative_grouped_allocation")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } name() - percentConfig().validate() billableMetricId() billedInAdvance() billingCycleConfiguration()?.validate() @@ -12588,10 +12666,12 @@ private constructor( */ internal fun validity(): Int = (cadence.asKnown()?.validity() ?: 0) + + (cumulativeGroupedAllocationConfig.asKnown()?.validity() ?: 0) + (if (itemId.asKnown() == null) 0 else 1) + - modelType.let { if (it == JsonValue.from("percent")) 1 else 0 } + + modelType.let { + if (it == JsonValue.from("cumulative_grouped_allocation")) 1 else 0 + } + (if (name.asKnown() == null) 0 else 1) + - (percentConfig.asKnown()?.validity() ?: 0) + (if (billableMetricId.asKnown() == null) 0 else 1) + (if (billedInAdvance.asKnown() == null) 0 else 1) + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + @@ -12763,39 +12843,115 @@ private constructor( override fun toString() = value.toString() } - /** Configuration for percent pricing */ - class PercentConfig + /** Configuration for cumulative_grouped_allocation pricing */ + class CumulativeGroupedAllocationConfig @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val percent: JsonField, + private val cumulativeAllocation: JsonField, + private val groupAllocation: JsonField, + private val groupingKey: JsonField, + private val unitAmount: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("percent") + @JsonProperty("cumulative_allocation") @ExcludeMissing - percent: JsonField = JsonMissing.of() - ) : this(percent, mutableMapOf()) + cumulativeAllocation: JsonField = JsonMissing.of(), + @JsonProperty("group_allocation") + @ExcludeMissing + groupAllocation: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this( + cumulativeAllocation, + groupAllocation, + groupingKey, + unitAmount, + mutableMapOf(), + ) /** - * What percent of the component subtotals to charge + * The overall allocation across all groups * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). */ - fun percent(): Double = percent.getRequired("percent") + fun cumulativeAllocation(): String = + cumulativeAllocation.getRequired("cumulative_allocation") /** - * Returns the raw JSON value of [percent]. + * The allocation per individual group * - * Unlike [percent], this method doesn't throw if the JSON field has an + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun groupAllocation(): String = groupAllocation.getRequired("group_allocation") + + /** + * The event property used to group usage before applying allocations + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The amount to charge for each unit outside of the allocation + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [cumulativeAllocation]. + * + * Unlike [cumulativeAllocation], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("cumulative_allocation") + @ExcludeMissing + fun _cumulativeAllocation(): JsonField = cumulativeAllocation + + /** + * Returns the raw JSON value of [groupAllocation]. + * + * Unlike [groupAllocation], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("percent") + @JsonProperty("group_allocation") @ExcludeMissing - fun _percent(): JsonField = percent + fun _groupAllocation(): JsonField = groupAllocation + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -12813,39 +12969,100 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [PercentConfig]. + * [CumulativeGroupedAllocationConfig]. * * The following fields are required: * ```kotlin - * .percent() + * .cumulativeAllocation() + * .groupAllocation() + * .groupingKey() + * .unitAmount() * ``` */ fun builder() = Builder() } - /** A builder for [PercentConfig]. */ + /** A builder for [CumulativeGroupedAllocationConfig]. */ class Builder internal constructor() { - private var percent: JsonField? = null + private var cumulativeAllocation: JsonField? = null + private var groupAllocation: JsonField? = null + private var groupingKey: JsonField? = null + private var unitAmount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(percentConfig: PercentConfig) = apply { - percent = percentConfig.percent - additionalProperties = percentConfig.additionalProperties.toMutableMap() + internal fun from( + cumulativeGroupedAllocationConfig: CumulativeGroupedAllocationConfig + ) = apply { + cumulativeAllocation = + cumulativeGroupedAllocationConfig.cumulativeAllocation + groupAllocation = cumulativeGroupedAllocationConfig.groupAllocation + groupingKey = cumulativeGroupedAllocationConfig.groupingKey + unitAmount = cumulativeGroupedAllocationConfig.unitAmount + additionalProperties = + cumulativeGroupedAllocationConfig.additionalProperties + .toMutableMap() } - /** What percent of the component subtotals to charge */ - fun percent(percent: Double) = percent(JsonField.of(percent)) + /** The overall allocation across all groups */ + fun cumulativeAllocation(cumulativeAllocation: String) = + cumulativeAllocation(JsonField.of(cumulativeAllocation)) /** - * Sets [Builder.percent] to an arbitrary JSON value. + * Sets [Builder.cumulativeAllocation] to an arbitrary JSON value. * - * You should usually call [Builder.percent] with a well-typed [Double] + * You should usually call [Builder.cumulativeAllocation] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun cumulativeAllocation(cumulativeAllocation: JsonField) = apply { + this.cumulativeAllocation = cumulativeAllocation + } + + /** The allocation per individual group */ + fun groupAllocation(groupAllocation: String) = + groupAllocation(JsonField.of(groupAllocation)) + + /** + * Sets [Builder.groupAllocation] to an arbitrary JSON value. + * + * You should usually call [Builder.groupAllocation] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun groupAllocation(groupAllocation: JsonField) = apply { + this.groupAllocation = groupAllocation + } + + /** The event property used to group usage before applying allocations */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] * value instead. This method is primarily for setting the field to an * undocumented or not yet supported value. */ - fun percent(percent: JsonField) = apply { this.percent = percent } + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The amount to charge for each unit outside of the allocation */ + fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } fun additionalProperties(additionalProperties: Map) = apply { @@ -12870,32 +13087,41 @@ private constructor( } /** - * Returns an immutable instance of [PercentConfig]. + * Returns an immutable instance of [CumulativeGroupedAllocationConfig]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```kotlin - * .percent() + * .cumulativeAllocation() + * .groupAllocation() + * .groupingKey() + * .unitAmount() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): PercentConfig = - PercentConfig( - checkRequired("percent", percent), + fun build(): CumulativeGroupedAllocationConfig = + CumulativeGroupedAllocationConfig( + checkRequired("cumulativeAllocation", cumulativeAllocation), + checkRequired("groupAllocation", groupAllocation), + checkRequired("groupingKey", groupingKey), + checkRequired("unitAmount", unitAmount), additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): PercentConfig = apply { + fun validate(): CumulativeGroupedAllocationConfig = apply { if (validated) { return@apply } - percent() + cumulativeAllocation() + groupAllocation() + groupingKey() + unitAmount() validated = true } @@ -12913,26 +13139,39 @@ private constructor( * * Used for best match union deserialization. */ - internal fun validity(): Int = (if (percent.asKnown() == null) 0 else 1) + internal fun validity(): Int = + (if (cumulativeAllocation.asKnown() == null) 0 else 1) + + (if (groupAllocation.asKnown() == null) 0 else 1) + + (if (groupingKey.asKnown() == null) 0 else 1) + + (if (unitAmount.asKnown() == null) 0 else 1) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is PercentConfig && - percent == other.percent && + return other is CumulativeGroupedAllocationConfig && + cumulativeAllocation == other.cumulativeAllocation && + groupAllocation == other.groupAllocation && + groupingKey == other.groupingKey && + unitAmount == other.unitAmount && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(percent, additionalProperties) + Objects.hash( + cumulativeAllocation, + groupAllocation, + groupingKey, + unitAmount, + additionalProperties, + ) } override fun hashCode(): Int = hashCode override fun toString() = - "PercentConfig{percent=$percent, additionalProperties=$additionalProperties}" + "CumulativeGroupedAllocationConfig{cumulativeAllocation=$cumulativeAllocation, groupAllocation=$groupAllocation, groupingKey=$groupingKey, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" } /** @@ -13049,12 +13288,13 @@ private constructor( return true } - return other is Percent && + return other is CumulativeGroupedAllocation && cadence == other.cadence && + cumulativeGroupedAllocationConfig == + other.cumulativeGroupedAllocationConfig && itemId == other.itemId && modelType == other.modelType && name == other.name && - percentConfig == other.percentConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && @@ -13074,10 +13314,10 @@ private constructor( private val hashCode: Int by lazy { Objects.hash( cadence, + cumulativeGroupedAllocationConfig, itemId, modelType, name, - percentConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -13098,17 +13338,17 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Percent{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, percentConfig=$percentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "CumulativeGroupedAllocation{cadence=$cadence, cumulativeGroupedAllocationConfig=$cumulativeGroupedAllocationConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class EventOutput + class Percent @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, - private val eventOutputConfig: JsonField, private val itemId: JsonField, private val modelType: JsonValue, private val name: JsonField, + private val percentConfig: JsonField, private val billableMetricId: JsonField, private val billedInAdvance: JsonField, private val billingCycleConfiguration: JsonField, @@ -13131,9 +13371,6 @@ private constructor( @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), - @JsonProperty("event_output_config") - @ExcludeMissing - eventOutputConfig: JsonField = JsonMissing.of(), @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), @@ -13143,6 +13380,9 @@ private constructor( @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("percent_config") + @ExcludeMissing + percentConfig: JsonField = JsonMissing.of(), @JsonProperty("billable_metric_id") @ExcludeMissing billableMetricId: JsonField = JsonMissing.of(), @@ -13187,10 +13427,10 @@ private constructor( referenceId: JsonField = JsonMissing.of(), ) : this( cadence, - eventOutputConfig, itemId, modelType, name, + percentConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -13216,16 +13456,6 @@ private constructor( */ fun cadence(): Cadence = cadence.getRequired("cadence") - /** - * Configuration for event_output pricing - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun eventOutputConfig(): EventOutputConfig = - eventOutputConfig.getRequired("event_output_config") - /** * The id of the item the price will be associated with. * @@ -13240,7 +13470,7 @@ private constructor( * * Expected to always return the following: * ```kotlin - * JsonValue.from("event_output") + * JsonValue.from("percent") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -13257,6 +13487,15 @@ private constructor( */ fun name(): String = name.getRequired("name") + /** + * Configuration for percent pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun percentConfig(): PercentConfig = percentConfig.getRequired("percent_config") + /** * The id of the billable metric for the price. Only needed if the price is * usage-based. @@ -13386,16 +13625,6 @@ private constructor( @ExcludeMissing fun _cadence(): JsonField = cadence - /** - * Returns the raw JSON value of [eventOutputConfig]. - * - * Unlike [eventOutputConfig], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("event_output_config") - @ExcludeMissing - fun _eventOutputConfig(): JsonField = eventOutputConfig - /** * Returns the raw JSON value of [itemId]. * @@ -13412,6 +13641,16 @@ private constructor( */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + /** + * Returns the raw JSON value of [percentConfig]. + * + * Unlike [percentConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("percent_config") + @ExcludeMissing + fun _percentConfig(): JsonField = percentConfig + /** * Returns the raw JSON value of [billableMetricId]. * @@ -13560,27 +13799,27 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [EventOutput]. + * Returns a mutable builder for constructing an instance of [Percent]. * * The following fields are required: * ```kotlin * .cadence() - * .eventOutputConfig() * .itemId() * .name() + * .percentConfig() * ``` */ fun builder() = Builder() } - /** A builder for [EventOutput]. */ + /** A builder for [Percent]. */ class Builder internal constructor() { private var cadence: JsonField? = null - private var eventOutputConfig: JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonValue = JsonValue.from("event_output") + private var modelType: JsonValue = JsonValue.from("percent") private var name: JsonField? = null + private var percentConfig: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() private var billingCycleConfiguration: JsonField = @@ -13602,26 +13841,26 @@ private constructor( private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(eventOutput: EventOutput) = apply { - cadence = eventOutput.cadence - eventOutputConfig = eventOutput.eventOutputConfig - itemId = eventOutput.itemId - modelType = eventOutput.modelType - name = eventOutput.name - billableMetricId = eventOutput.billableMetricId - billedInAdvance = eventOutput.billedInAdvance - billingCycleConfiguration = eventOutput.billingCycleConfiguration - conversionRate = eventOutput.conversionRate - conversionRateConfig = eventOutput.conversionRateConfig - currency = eventOutput.currency - dimensionalPriceConfiguration = eventOutput.dimensionalPriceConfiguration - externalPriceId = eventOutput.externalPriceId - fixedPriceQuantity = eventOutput.fixedPriceQuantity - invoiceGroupingKey = eventOutput.invoiceGroupingKey - invoicingCycleConfiguration = eventOutput.invoicingCycleConfiguration - metadata = eventOutput.metadata - referenceId = eventOutput.referenceId - additionalProperties = eventOutput.additionalProperties.toMutableMap() + internal fun from(percent: Percent) = apply { + cadence = percent.cadence + itemId = percent.itemId + modelType = percent.modelType + name = percent.name + percentConfig = percent.percentConfig + billableMetricId = percent.billableMetricId + billedInAdvance = percent.billedInAdvance + billingCycleConfiguration = percent.billingCycleConfiguration + conversionRate = percent.conversionRate + conversionRateConfig = percent.conversionRateConfig + currency = percent.currency + dimensionalPriceConfiguration = percent.dimensionalPriceConfiguration + externalPriceId = percent.externalPriceId + fixedPriceQuantity = percent.fixedPriceQuantity + invoiceGroupingKey = percent.invoiceGroupingKey + invoicingCycleConfiguration = percent.invoicingCycleConfiguration + metadata = percent.metadata + referenceId = percent.referenceId + additionalProperties = percent.additionalProperties.toMutableMap() } /** The cadence to bill for this price on. */ @@ -13636,21 +13875,6 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - /** Configuration for event_output pricing */ - fun eventOutputConfig(eventOutputConfig: EventOutputConfig) = - eventOutputConfig(JsonField.of(eventOutputConfig)) - - /** - * Sets [Builder.eventOutputConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.eventOutputConfig] with a well-typed - * [EventOutputConfig] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun eventOutputConfig(eventOutputConfig: JsonField) = apply { - this.eventOutputConfig = eventOutputConfig - } - /** The id of the item the price will be associated with. */ fun itemId(itemId: String) = itemId(JsonField.of(itemId)) @@ -13669,7 +13893,7 @@ private constructor( * It is usually unnecessary to call this method because the field defaults to * the following: * ```kotlin - * JsonValue.from("event_output") + * JsonValue.from("percent") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -13689,6 +13913,21 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } + /** Configuration for percent pricing */ + fun percentConfig(percentConfig: PercentConfig) = + percentConfig(JsonField.of(percentConfig)) + + /** + * Sets [Builder.percentConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.percentConfig] with a well-typed + * [PercentConfig] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun percentConfig(percentConfig: JsonField) = apply { + this.percentConfig = percentConfig + } + /** * The id of the billable metric for the price. Only needed if the price is * usage-based. @@ -14018,27 +14257,27 @@ private constructor( } /** - * Returns an immutable instance of [EventOutput]. + * Returns an immutable instance of [Percent]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```kotlin * .cadence() - * .eventOutputConfig() * .itemId() * .name() + * .percentConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): EventOutput = - EventOutput( + fun build(): Percent = + Percent( checkRequired("cadence", cadence), - checkRequired("eventOutputConfig", eventOutputConfig), checkRequired("itemId", itemId), modelType, checkRequired("name", name), + checkRequired("percentConfig", percentConfig), billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -14058,20 +14297,20 @@ private constructor( private var validated: Boolean = false - fun validate(): EventOutput = apply { + fun validate(): Percent = apply { if (validated) { return@apply } cadence().validate() - eventOutputConfig().validate() itemId() _modelType().let { - if (it != JsonValue.from("event_output")) { + if (it != JsonValue.from("percent")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } name() + percentConfig().validate() billableMetricId() billedInAdvance() billingCycleConfiguration()?.validate() @@ -14104,10 +14343,10 @@ private constructor( */ internal fun validity(): Int = (cadence.asKnown()?.validity() ?: 0) + - (eventOutputConfig.asKnown()?.validity() ?: 0) + (if (itemId.asKnown() == null) 0 else 1) + - modelType.let { if (it == JsonValue.from("event_output")) 1 else 0 } + + modelType.let { if (it == JsonValue.from("percent")) 1 else 0 } + (if (name.asKnown() == null) 0 else 1) + + (percentConfig.asKnown()?.validity() ?: 0) + (if (billableMetricId.asKnown() == null) 0 else 1) + (if (billedInAdvance.asKnown() == null) 0 else 1) + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + @@ -14279,87 +14518,39 @@ private constructor( override fun toString() = value.toString() } - /** Configuration for event_output pricing */ - class EventOutputConfig + /** Configuration for percent pricing */ + class PercentConfig @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val unitRatingKey: JsonField, - private val defaultUnitRate: JsonField, - private val groupingKey: JsonField, + private val percent: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("unit_rating_key") - @ExcludeMissing - unitRatingKey: JsonField = JsonMissing.of(), - @JsonProperty("default_unit_rate") - @ExcludeMissing - defaultUnitRate: JsonField = JsonMissing.of(), - @JsonProperty("grouping_key") + @JsonProperty("percent") @ExcludeMissing - groupingKey: JsonField = JsonMissing.of(), - ) : this(unitRatingKey, defaultUnitRate, groupingKey, mutableMapOf()) + percent: JsonField = JsonMissing.of() + ) : this(percent, mutableMapOf()) /** - * The key in the event data to extract the unit rate from. + * What percent of the component subtotals to charge * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). */ - fun unitRatingKey(): String = unitRatingKey.getRequired("unit_rating_key") - - /** - * If provided, this amount will be used as the unit rate when an event does not - * have a value for the `unit_rating_key`. If not provided, events missing a - * unit rate will be ignored. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun defaultUnitRate(): String? = - defaultUnitRate.getNullable("default_unit_rate") - - /** - * An optional key in the event data to group by (e.g., event ID). All events - * will also be grouped by their unit rate. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun groupingKey(): String? = groupingKey.getNullable("grouping_key") - - /** - * Returns the raw JSON value of [unitRatingKey]. - * - * Unlike [unitRatingKey], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("unit_rating_key") - @ExcludeMissing - fun _unitRatingKey(): JsonField = unitRatingKey - - /** - * Returns the raw JSON value of [defaultUnitRate]. - * - * Unlike [defaultUnitRate], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("default_unit_rate") - @ExcludeMissing - fun _defaultUnitRate(): JsonField = defaultUnitRate + fun percent(): Double = percent.getRequired("percent") /** - * Returns the raw JSON value of [groupingKey]. + * Returns the raw JSON value of [percent]. * - * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * Unlike [percent], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("grouping_key") + @JsonProperty("percent") @ExcludeMissing - fun _groupingKey(): JsonField = groupingKey + fun _percent(): JsonField = percent @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -14377,84 +14568,39 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [EventOutputConfig]. + * [PercentConfig]. * * The following fields are required: * ```kotlin - * .unitRatingKey() + * .percent() * ``` */ fun builder() = Builder() } - /** A builder for [EventOutputConfig]. */ + /** A builder for [PercentConfig]. */ class Builder internal constructor() { - private var unitRatingKey: JsonField? = null - private var defaultUnitRate: JsonField = JsonMissing.of() - private var groupingKey: JsonField = JsonMissing.of() + private var percent: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(eventOutputConfig: EventOutputConfig) = apply { - unitRatingKey = eventOutputConfig.unitRatingKey - defaultUnitRate = eventOutputConfig.defaultUnitRate - groupingKey = eventOutputConfig.groupingKey - additionalProperties = - eventOutputConfig.additionalProperties.toMutableMap() - } - - /** The key in the event data to extract the unit rate from. */ - fun unitRatingKey(unitRatingKey: String) = - unitRatingKey(JsonField.of(unitRatingKey)) - - /** - * Sets [Builder.unitRatingKey] to an arbitrary JSON value. - * - * You should usually call [Builder.unitRatingKey] with a well-typed - * [String] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun unitRatingKey(unitRatingKey: JsonField) = apply { - this.unitRatingKey = unitRatingKey - } - - /** - * If provided, this amount will be used as the unit rate when an event does - * not have a value for the `unit_rating_key`. If not provided, events - * missing a unit rate will be ignored. - */ - fun defaultUnitRate(defaultUnitRate: String?) = - defaultUnitRate(JsonField.ofNullable(defaultUnitRate)) - - /** - * Sets [Builder.defaultUnitRate] to an arbitrary JSON value. - * - * You should usually call [Builder.defaultUnitRate] with a well-typed - * [String] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun defaultUnitRate(defaultUnitRate: JsonField) = apply { - this.defaultUnitRate = defaultUnitRate + internal fun from(percentConfig: PercentConfig) = apply { + percent = percentConfig.percent + additionalProperties = percentConfig.additionalProperties.toMutableMap() } - /** - * An optional key in the event data to group by (e.g., event ID). All - * events will also be grouped by their unit rate. - */ - fun groupingKey(groupingKey: String?) = - groupingKey(JsonField.ofNullable(groupingKey)) + /** What percent of the component subtotals to charge */ + fun percent(percent: Double) = percent(JsonField.of(percent)) /** - * Sets [Builder.groupingKey] to an arbitrary JSON value. + * Sets [Builder.percent] to an arbitrary JSON value. * - * You should usually call [Builder.groupingKey] with a well-typed [String] + * You should usually call [Builder.percent] with a well-typed [Double] * value instead. This method is primarily for setting the field to an * undocumented or not yet supported value. */ - fun groupingKey(groupingKey: JsonField) = apply { - this.groupingKey = groupingKey - } + fun percent(percent: JsonField) = apply { this.percent = percent } fun additionalProperties(additionalProperties: Map) = apply { @@ -14479,36 +14625,32 @@ private constructor( } /** - * Returns an immutable instance of [EventOutputConfig]. + * Returns an immutable instance of [PercentConfig]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```kotlin - * .unitRatingKey() + * .percent() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): EventOutputConfig = - EventOutputConfig( - checkRequired("unitRatingKey", unitRatingKey), - defaultUnitRate, - groupingKey, + fun build(): PercentConfig = + PercentConfig( + checkRequired("percent", percent), additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): EventOutputConfig = apply { + fun validate(): PercentConfig = apply { if (validated) { return@apply } - unitRatingKey() - defaultUnitRate() - groupingKey() + percent() validated = true } @@ -14526,36 +14668,26 @@ private constructor( * * Used for best match union deserialization. */ - internal fun validity(): Int = - (if (unitRatingKey.asKnown() == null) 0 else 1) + - (if (defaultUnitRate.asKnown() == null) 0 else 1) + - (if (groupingKey.asKnown() == null) 0 else 1) + internal fun validity(): Int = (if (percent.asKnown() == null) 0 else 1) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is EventOutputConfig && - unitRatingKey == other.unitRatingKey && - defaultUnitRate == other.defaultUnitRate && - groupingKey == other.groupingKey && + return other is PercentConfig && + percent == other.percent && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash( - unitRatingKey, - defaultUnitRate, - groupingKey, - additionalProperties, - ) + Objects.hash(percent, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "EventOutputConfig{unitRatingKey=$unitRatingKey, defaultUnitRate=$defaultUnitRate, groupingKey=$groupingKey, additionalProperties=$additionalProperties}" + "PercentConfig{percent=$percent, additionalProperties=$additionalProperties}" } /** @@ -14672,12 +14804,12 @@ private constructor( return true } - return other is EventOutput && + return other is Percent && cadence == other.cadence && - eventOutputConfig == other.eventOutputConfig && itemId == other.itemId && modelType == other.modelType && name == other.name && + percentConfig == other.percentConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && @@ -14697,10 +14829,10 @@ private constructor( private val hashCode: Int by lazy { Objects.hash( cadence, - eventOutputConfig, itemId, modelType, name, + percentConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -14721,1181 +14853,1630 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "EventOutput{cadence=$cadence, eventOutputConfig=$eventOutputConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + "Percent{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, percentConfig=$percentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - return other is AddPrice && - allocationPrice == other.allocationPrice && - discounts == other.discounts && - endDate == other.endDate && - externalPriceId == other.externalPriceId && - maximumAmount == other.maximumAmount && - minimumAmount == other.minimumAmount && - planPhaseOrder == other.planPhaseOrder && - price == other.price && - priceId == other.priceId && - startDate == other.startDate && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - allocationPrice, - discounts, - endDate, - externalPriceId, - maximumAmount, - minimumAmount, - planPhaseOrder, - price, - priceId, - startDate, - additionalProperties, - ) - } + class EventOutput + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val eventOutputConfig: JsonField, + private val itemId: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { - override fun hashCode(): Int = hashCode + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("event_output_config") + @ExcludeMissing + eventOutputConfig: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + eventOutputConfig, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + mutableMapOf(), + ) - override fun toString() = - "AddPrice{allocationPrice=$allocationPrice, discounts=$discounts, endDate=$endDate, externalPriceId=$externalPriceId, maximumAmount=$maximumAmount, minimumAmount=$minimumAmount, planPhaseOrder=$planPhaseOrder, price=$price, priceId=$priceId, startDate=$startDate, additionalProperties=$additionalProperties}" - } + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") - @Deprecated("deprecated") - class ExternalMarketplace - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API may respond with new members that the SDK is - * unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { + /** + * Configuration for event_output pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun eventOutputConfig(): EventOutputConfig = + eventOutputConfig.getRequired("event_output_config") - val GOOGLE = of("google") + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") - val AWS = of("aws") + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("event_output") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType - val AZURE = of("azure") + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") - fun of(value: String) = ExternalMarketplace(JsonField.of(value)) - } + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = billableMetricId.getNullable("billable_metric_id") - /** An enum containing [ExternalMarketplace]'s known values. */ - enum class Known { - GOOGLE, - AWS, - AZURE, - } + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") - /** - * An enum containing [ExternalMarketplace]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [ExternalMarketplace] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if the - * SDK is on an older version than the API, then the API may respond with new members that - * the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - GOOGLE, - AWS, - AZURE, - /** - * An enum member indicating that [ExternalMarketplace] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") - /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you want - * to throw for the unknown case. - */ - fun value(): Value = - when (this) { - GOOGLE -> Value.GOOGLE - AWS -> Value.AWS - AZURE -> Value.AZURE - else -> Value._UNKNOWN - } + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and don't - * want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known member. - */ - fun known(): Known = - when (this) { - GOOGLE -> Known.GOOGLE - AWS -> Known.AWS - AZURE -> Known.AZURE - else -> throw OrbInvalidDataException("Unknown ExternalMarketplace: $value") - } + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the expected - * primitive type. - */ - fun asString(): String = - _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") - private var validated: Boolean = false + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") - fun validate(): ExternalMarketplace = apply { - if (validated) { - return@apply - } + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") - known() - validated = true - } + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + invoiceGroupingKey.getNullable("invoice_grouping_key") - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") - return other is ExternalMarketplace && value == other.value - } + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by setting - * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to - * `null`. - */ - class Metadata - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { + /** + * Returns the raw JSON value of [eventOutputConfig]. + * + * Unlike [eventOutputConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("event_output_config") + @ExcludeMissing + fun _eventOutputConfig(): JsonField = eventOutputConfig - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - fun toBuilder() = Builder().from(this) + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - companion object { + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId - /** Returns a mutable builder for constructing an instance of [Metadata]. */ - fun builder() = Builder() - } + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance - /** A builder for [Metadata]. */ - class Builder internal constructor() { + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration - private var additionalProperties: MutableMap = mutableMapOf() + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate - internal fun from(metadata: Metadata) = apply { - additionalProperties = metadata.additionalProperties.toMutableMap() - } + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - /** - * Returns an immutable instance of [Metadata]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration - private var validated: Boolean = false + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata - fun validate(): Metadata = apply { - if (validated) { - return@apply - } + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId - validated = true - } + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + companion object { - return other is Metadata && additionalProperties == other.additionalProperties - } + /** + * Returns a mutable builder for constructing an instance of [EventOutput]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .eventOutputConfig() + * .itemId() + * .name() + * ``` + */ + fun builder() = Builder() + } - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /** A builder for [EventOutput]. */ + class Builder internal constructor() { - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } + private var cadence: JsonField? = null + private var eventOutputConfig: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonValue = JsonValue.from("event_output") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - class RemoveAdjustment - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val adjustmentId: JsonField, - private val additionalProperties: MutableMap, - ) { + internal fun from(eventOutput: EventOutput) = apply { + cadence = eventOutput.cadence + eventOutputConfig = eventOutput.eventOutputConfig + itemId = eventOutput.itemId + modelType = eventOutput.modelType + name = eventOutput.name + billableMetricId = eventOutput.billableMetricId + billedInAdvance = eventOutput.billedInAdvance + billingCycleConfiguration = eventOutput.billingCycleConfiguration + conversionRate = eventOutput.conversionRate + conversionRateConfig = eventOutput.conversionRateConfig + currency = eventOutput.currency + dimensionalPriceConfiguration = eventOutput.dimensionalPriceConfiguration + externalPriceId = eventOutput.externalPriceId + fixedPriceQuantity = eventOutput.fixedPriceQuantity + invoiceGroupingKey = eventOutput.invoiceGroupingKey + invoicingCycleConfiguration = eventOutput.invoicingCycleConfiguration + metadata = eventOutput.metadata + referenceId = eventOutput.referenceId + additionalProperties = eventOutput.additionalProperties.toMutableMap() + } - @JsonCreator - private constructor( - @JsonProperty("adjustment_id") - @ExcludeMissing - adjustmentId: JsonField = JsonMissing.of() - ) : this(adjustmentId, mutableMapOf()) + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - /** - * The id of the adjustment to remove on the subscription. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun adjustmentId(): String = adjustmentId.getRequired("adjustment_id") + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - /** - * Returns the raw JSON value of [adjustmentId]. - * - * Unlike [adjustmentId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("adjustment_id") - @ExcludeMissing - fun _adjustmentId(): JsonField = adjustmentId + /** Configuration for event_output pricing */ + fun eventOutputConfig(eventOutputConfig: EventOutputConfig) = + eventOutputConfig(JsonField.of(eventOutputConfig)) - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** + * Sets [Builder.eventOutputConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.eventOutputConfig] with a well-typed + * [EventOutputConfig] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun eventOutputConfig(eventOutputConfig: JsonField) = apply { + this.eventOutputConfig = eventOutputConfig + } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - fun toBuilder() = Builder().from(this) + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - companion object { + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("event_output") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } - /** - * Returns a mutable builder for constructing an instance of [RemoveAdjustment]. - * - * The following fields are required: - * ```kotlin - * .adjustmentId() - * ``` - */ - fun builder() = Builder() - } + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) - /** A builder for [RemoveAdjustment]. */ - class Builder internal constructor() { + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } - private var adjustmentId: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) - internal fun from(removeAdjustment: RemoveAdjustment) = apply { - adjustmentId = removeAdjustment.adjustmentId - additionalProperties = removeAdjustment.additionalProperties.toMutableMap() - } + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } - /** The id of the adjustment to remove on the subscription. */ - fun adjustmentId(adjustmentId: String) = adjustmentId(JsonField.of(adjustmentId)) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) - /** - * Sets [Builder.adjustmentId] to an arbitrary JSON value. - * - * You should usually call [Builder.adjustmentId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun adjustmentId(adjustmentId: JsonField) = apply { - this.adjustmentId = adjustmentId - } + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) - /** - * Returns an immutable instance of [RemoveAdjustment]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```kotlin - * .adjustmentId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): RemoveAdjustment = - RemoveAdjustment( - checkRequired("adjustmentId", adjustmentId), - additionalProperties.toMutableMap(), - ) - } + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } - private var validated: Boolean = false + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) - fun validate(): RemoveAdjustment = apply { - if (validated) { - return@apply - } + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } - adjustmentId() - validated = true - } + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = (if (adjustmentId.asKnown() == null) 0 else 1) + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) - return other is RemoveAdjustment && - adjustmentId == other.adjustmentId && - additionalProperties == other.additionalProperties - } + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) - private val hashCode: Int by lazy { Objects.hash(adjustmentId, additionalProperties) } + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } - override fun hashCode(): Int = hashCode + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) - override fun toString() = - "RemoveAdjustment{adjustmentId=$adjustmentId, additionalProperties=$additionalProperties}" - } + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } - class RemovePrice - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val externalPriceId: JsonField, - private val priceId: JsonField, - private val additionalProperties: MutableMap, - ) { + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) - @JsonCreator - private constructor( - @JsonProperty("external_price_id") - @ExcludeMissing - externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("price_id") @ExcludeMissing priceId: JsonField = JsonMissing.of(), - ) : this(externalPriceId, priceId, mutableMapOf()) + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } - /** - * The external price id of the price to remove on the subscription. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) - /** - * The id of the price to remove on the subscription. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun priceId(): String? = priceId.getNullable("price_id") + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) - /** - * Returns the raw JSON value of [externalPriceId]. - * - * Unlike [externalPriceId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } - /** - * Returns the raw JSON value of [priceId]. - * - * Unlike [priceId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) - fun toBuilder() = Builder().from(this) + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - companion object { + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - /** Returns a mutable builder for constructing an instance of [RemovePrice]. */ - fun builder() = Builder() - } + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - /** A builder for [RemovePrice]. */ - class Builder internal constructor() { + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) - private var externalPriceId: JsonField = JsonMissing.of() - private var priceId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } - internal fun from(removePrice: RemovePrice) = apply { - externalPriceId = removePrice.externalPriceId - priceId = removePrice.priceId - additionalProperties = removePrice.additionalProperties.toMutableMap() - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** The external price id of the price to remove on the subscription. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * Sets [Builder.externalPriceId] to an arbitrary JSON value. - * - * You should usually call [Builder.externalPriceId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun externalPriceId(externalPriceId: JsonField) = apply { - this.externalPriceId = externalPriceId - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - /** The id of the price to remove on the subscription. */ - fun priceId(priceId: String?) = priceId(JsonField.ofNullable(priceId)) + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - /** - * Sets [Builder.priceId] to an arbitrary JSON value. - * - * You should usually call [Builder.priceId] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun priceId(priceId: JsonField) = apply { this.priceId = priceId } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * Returns an immutable instance of [EventOutput]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .eventOutputConfig() + * .itemId() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): EventOutput = + EventOutput( + checkRequired("cadence", cadence), + checkRequired("eventOutputConfig", eventOutputConfig), + checkRequired("itemId", itemId), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + private var validated: Boolean = false - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun validate(): EventOutput = apply { + if (validated) { + return@apply + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + cadence().validate() + eventOutputConfig().validate() + itemId() + _modelType().let { + if (it != JsonValue.from("event_output")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + metadata()?.validate() + referenceId() + validated = true + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - /** - * Returns an immutable instance of [RemovePrice]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): RemovePrice = - RemovePrice(externalPriceId, priceId, additionalProperties.toMutableMap()) - } + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (eventOutputConfig.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + modelType.let { if (it == JsonValue.from("event_output")) 1 else 0 } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) - private var validated: Boolean = false + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { - fun validate(): RemovePrice = apply { - if (validated) { - return@apply - } + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value - externalPriceId() - priceId() - validated = true - } + companion object { - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (if (externalPriceId.asKnown() == null) 0 else 1) + - (if (priceId.asKnown() == null) 0 else 1) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + val ANNUAL = of("annual") - return other is RemovePrice && - externalPriceId == other.externalPriceId && - priceId == other.priceId && - additionalProperties == other.additionalProperties - } + val SEMI_ANNUAL = of("semi_annual") - private val hashCode: Int by lazy { - Objects.hash(externalPriceId, priceId, additionalProperties) - } + val MONTHLY = of("monthly") - override fun hashCode(): Int = hashCode + val QUARTERLY = of("quarterly") - override fun toString() = - "RemovePrice{externalPriceId=$externalPriceId, priceId=$priceId, additionalProperties=$additionalProperties}" - } + val ONE_TIME = of("one_time") - class ReplaceAdjustment - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val adjustment: JsonField, - private val replacesAdjustmentId: JsonField, - private val additionalProperties: MutableMap, - ) { + val CUSTOM = of("custom") - @JsonCreator - private constructor( - @JsonProperty("adjustment") - @ExcludeMissing - adjustment: JsonField = JsonMissing.of(), - @JsonProperty("replaces_adjustment_id") - @ExcludeMissing - replacesAdjustmentId: JsonField = JsonMissing.of(), - ) : this(adjustment, replacesAdjustmentId, mutableMapOf()) + fun of(value: String) = Cadence(JsonField.of(value)) + } - /** - * The definition of a new adjustment to create and add to the subscription. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun adjustment(): Adjustment = adjustment.getRequired("adjustment") + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } - /** - * The id of the adjustment on the plan to replace in the subscription. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun replacesAdjustmentId(): String = - replacesAdjustmentId.getRequired("replaces_adjustment_id") + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } - /** - * Returns the raw JSON value of [adjustment]. - * - * Unlike [adjustment], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("adjustment") - @ExcludeMissing - fun _adjustment(): JsonField = adjustment + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } - /** - * Returns the raw JSON value of [replacesAdjustmentId]. - * - * Unlike [replacesAdjustmentId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("replaces_adjustment_id") - @ExcludeMissing - fun _replacesAdjustmentId(): JsonField = replacesAdjustmentId + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + private var validated: Boolean = false - fun toBuilder() = Builder().from(this) + fun validate(): Cadence = apply { + if (validated) { + return@apply + } - companion object { + known() + validated = true + } - /** - * Returns a mutable builder for constructing an instance of [ReplaceAdjustment]. - * - * The following fields are required: - * ```kotlin - * .adjustment() - * .replacesAdjustmentId() - * ``` - */ - fun builder() = Builder() - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - /** A builder for [ReplaceAdjustment]. */ - class Builder internal constructor() { + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - private var adjustment: JsonField? = null - private var replacesAdjustmentId: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - internal fun from(replaceAdjustment: ReplaceAdjustment) = apply { - adjustment = replaceAdjustment.adjustment - replacesAdjustmentId = replaceAdjustment.replacesAdjustmentId - additionalProperties = replaceAdjustment.additionalProperties.toMutableMap() - } + return other is Cadence && value == other.value + } - /** The definition of a new adjustment to create and add to the subscription. */ - fun adjustment(adjustment: Adjustment) = adjustment(JsonField.of(adjustment)) + override fun hashCode() = value.hashCode() - /** - * Sets [Builder.adjustment] to an arbitrary JSON value. - * - * You should usually call [Builder.adjustment] with a well-typed [Adjustment] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun adjustment(adjustment: JsonField) = apply { - this.adjustment = adjustment - } + override fun toString() = value.toString() + } - /** - * Alias for calling [adjustment] with - * `Adjustment.ofPercentageDiscount(percentageDiscount)`. - */ - fun adjustment(percentageDiscount: NewPercentageDiscount) = - adjustment(Adjustment.ofPercentageDiscount(percentageDiscount)) + /** Configuration for event_output pricing */ + class EventOutputConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val unitRatingKey: JsonField, + private val defaultUnitRate: JsonField, + private val groupingKey: JsonField, + private val additionalProperties: MutableMap, + ) { - /** - * Alias for calling [adjustment] with the following: - * ```kotlin - * NewPercentageDiscount.builder() - * .adjustmentType(NewPercentageDiscount.AdjustmentType.PERCENTAGE_DISCOUNT) - * .percentageDiscount(percentageDiscount) - * .build() - * ``` - */ - fun percentageDiscountAdjustment(percentageDiscount: Double) = - adjustment( - NewPercentageDiscount.builder() - .adjustmentType(NewPercentageDiscount.AdjustmentType.PERCENTAGE_DISCOUNT) - .percentageDiscount(percentageDiscount) - .build() - ) - - /** Alias for calling [adjustment] with `Adjustment.ofUsageDiscount(usageDiscount)`. */ - fun adjustment(usageDiscount: NewUsageDiscount) = - adjustment(Adjustment.ofUsageDiscount(usageDiscount)) + @JsonCreator + private constructor( + @JsonProperty("unit_rating_key") + @ExcludeMissing + unitRatingKey: JsonField = JsonMissing.of(), + @JsonProperty("default_unit_rate") + @ExcludeMissing + defaultUnitRate: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + ) : this(unitRatingKey, defaultUnitRate, groupingKey, mutableMapOf()) - /** - * Alias for calling [adjustment] with the following: - * ```kotlin - * NewUsageDiscount.builder() - * .adjustmentType(NewUsageDiscount.AdjustmentType.USAGE_DISCOUNT) - * .usageDiscount(usageDiscount) - * .build() - * ``` - */ - fun usageDiscountAdjustment(usageDiscount: Double) = - adjustment( - NewUsageDiscount.builder() - .adjustmentType(NewUsageDiscount.AdjustmentType.USAGE_DISCOUNT) - .usageDiscount(usageDiscount) - .build() - ) + /** + * The key in the event data to extract the unit rate from. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun unitRatingKey(): String = unitRatingKey.getRequired("unit_rating_key") - /** - * Alias for calling [adjustment] with `Adjustment.ofAmountDiscount(amountDiscount)`. - */ - fun adjustment(amountDiscount: NewAmountDiscount) = - adjustment(Adjustment.ofAmountDiscount(amountDiscount)) + /** + * If provided, this amount will be used as the unit rate when an event does not + * have a value for the `unit_rating_key`. If not provided, events missing a + * unit rate will be ignored. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun defaultUnitRate(): String? = + defaultUnitRate.getNullable("default_unit_rate") - /** - * Alias for calling [adjustment] with the following: - * ```kotlin - * NewAmountDiscount.builder() - * .adjustmentType(NewAmountDiscount.AdjustmentType.AMOUNT_DISCOUNT) - * .amountDiscount(amountDiscount) - * .build() - * ``` - */ - fun amountDiscountAdjustment(amountDiscount: String) = - adjustment( - NewAmountDiscount.builder() - .adjustmentType(NewAmountDiscount.AdjustmentType.AMOUNT_DISCOUNT) - .amountDiscount(amountDiscount) - .build() - ) + /** + * An optional key in the event data to group by (e.g., event ID). All events + * will also be grouped by their unit rate. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun groupingKey(): String? = groupingKey.getNullable("grouping_key") - /** Alias for calling [adjustment] with `Adjustment.ofMinimum(minimum)`. */ - fun adjustment(minimum: NewMinimum) = adjustment(Adjustment.ofMinimum(minimum)) + /** + * Returns the raw JSON value of [unitRatingKey]. + * + * Unlike [unitRatingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_rating_key") + @ExcludeMissing + fun _unitRatingKey(): JsonField = unitRatingKey - /** Alias for calling [adjustment] with `Adjustment.ofMaximum(maximum)`. */ - fun adjustment(maximum: NewMaximum) = adjustment(Adjustment.ofMaximum(maximum)) + /** + * Returns the raw JSON value of [defaultUnitRate]. + * + * Unlike [defaultUnitRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("default_unit_rate") + @ExcludeMissing + fun _defaultUnitRate(): JsonField = defaultUnitRate - /** - * Alias for calling [adjustment] with the following: - * ```kotlin - * NewMaximum.builder() - * .adjustmentType(NewMaximum.AdjustmentType.MAXIMUM) - * .maximumAmount(maximumAmount) - * .build() - * ``` - */ - fun maximumAdjustment(maximumAmount: String) = - adjustment( - NewMaximum.builder() - .adjustmentType(NewMaximum.AdjustmentType.MAXIMUM) - .maximumAmount(maximumAmount) - .build() - ) + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey - /** The id of the adjustment on the plan to replace in the subscription. */ - fun replacesAdjustmentId(replacesAdjustmentId: String) = - replacesAdjustmentId(JsonField.of(replacesAdjustmentId)) + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - /** - * Sets [Builder.replacesAdjustmentId] to an arbitrary JSON value. - * - * You should usually call [Builder.replacesAdjustmentId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun replacesAdjustmentId(replacesAdjustmentId: JsonField) = apply { - this.replacesAdjustmentId = replacesAdjustmentId - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun toBuilder() = Builder().from(this) - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + companion object { - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + /** + * Returns a mutable builder for constructing an instance of + * [EventOutputConfig]. + * + * The following fields are required: + * ```kotlin + * .unitRatingKey() + * ``` + */ + fun builder() = Builder() + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + /** A builder for [EventOutputConfig]. */ + class Builder internal constructor() { - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + private var unitRatingKey: JsonField? = null + private var defaultUnitRate: JsonField = JsonMissing.of() + private var groupingKey: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() - /** - * Returns an immutable instance of [ReplaceAdjustment]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```kotlin - * .adjustment() - * .replacesAdjustmentId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): ReplaceAdjustment = - ReplaceAdjustment( - checkRequired("adjustment", adjustment), - checkRequired("replacesAdjustmentId", replacesAdjustmentId), - additionalProperties.toMutableMap(), - ) - } + internal fun from(eventOutputConfig: EventOutputConfig) = apply { + unitRatingKey = eventOutputConfig.unitRatingKey + defaultUnitRate = eventOutputConfig.defaultUnitRate + groupingKey = eventOutputConfig.groupingKey + additionalProperties = + eventOutputConfig.additionalProperties.toMutableMap() + } - private var validated: Boolean = false + /** The key in the event data to extract the unit rate from. */ + fun unitRatingKey(unitRatingKey: String) = + unitRatingKey(JsonField.of(unitRatingKey)) - fun validate(): ReplaceAdjustment = apply { - if (validated) { - return@apply - } + /** + * Sets [Builder.unitRatingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.unitRatingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun unitRatingKey(unitRatingKey: JsonField) = apply { + this.unitRatingKey = unitRatingKey + } - adjustment().validate() - replacesAdjustmentId() - validated = true - } + /** + * If provided, this amount will be used as the unit rate when an event does + * not have a value for the `unit_rating_key`. If not provided, events + * missing a unit rate will be ignored. + */ + fun defaultUnitRate(defaultUnitRate: String?) = + defaultUnitRate(JsonField.ofNullable(defaultUnitRate)) - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (adjustment.asKnown()?.validity() ?: 0) + - (if (replacesAdjustmentId.asKnown() == null) 0 else 1) + /** + * Sets [Builder.defaultUnitRate] to an arbitrary JSON value. + * + * You should usually call [Builder.defaultUnitRate] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun defaultUnitRate(defaultUnitRate: JsonField) = apply { + this.defaultUnitRate = defaultUnitRate + } - /** The definition of a new adjustment to create and add to the subscription. */ - @JsonDeserialize(using = Adjustment.Deserializer::class) - @JsonSerialize(using = Adjustment.Serializer::class) - class Adjustment - private constructor( - private val percentageDiscount: NewPercentageDiscount? = null, - private val usageDiscount: NewUsageDiscount? = null, - private val amountDiscount: NewAmountDiscount? = null, - private val minimum: NewMinimum? = null, - private val maximum: NewMaximum? = null, - private val _json: JsonValue? = null, - ) { + /** + * An optional key in the event data to group by (e.g., event ID). All + * events will also be grouped by their unit rate. + */ + fun groupingKey(groupingKey: String?) = + groupingKey(JsonField.ofNullable(groupingKey)) - fun percentageDiscount(): NewPercentageDiscount? = percentageDiscount + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } - fun usageDiscount(): NewUsageDiscount? = usageDiscount + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun amountDiscount(): NewAmountDiscount? = amountDiscount + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun minimum(): NewMinimum? = minimum + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun maximum(): NewMaximum? = maximum + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun isPercentageDiscount(): Boolean = percentageDiscount != null + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - fun isUsageDiscount(): Boolean = usageDiscount != null + /** + * Returns an immutable instance of [EventOutputConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .unitRatingKey() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): EventOutputConfig = + EventOutputConfig( + checkRequired("unitRatingKey", unitRatingKey), + defaultUnitRate, + groupingKey, + additionalProperties.toMutableMap(), + ) + } - fun isAmountDiscount(): Boolean = amountDiscount != null + private var validated: Boolean = false - fun isMinimum(): Boolean = minimum != null + fun validate(): EventOutputConfig = apply { + if (validated) { + return@apply + } - fun isMaximum(): Boolean = maximum != null + unitRatingKey() + defaultUnitRate() + groupingKey() + validated = true + } - fun asPercentageDiscount(): NewPercentageDiscount = - percentageDiscount.getOrThrow("percentageDiscount") + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - fun asUsageDiscount(): NewUsageDiscount = usageDiscount.getOrThrow("usageDiscount") + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (unitRatingKey.asKnown() == null) 0 else 1) + + (if (defaultUnitRate.asKnown() == null) 0 else 1) + + (if (groupingKey.asKnown() == null) 0 else 1) - fun asAmountDiscount(): NewAmountDiscount = amountDiscount.getOrThrow("amountDiscount") + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun asMinimum(): NewMinimum = minimum.getOrThrow("minimum") + return other is EventOutputConfig && + unitRatingKey == other.unitRatingKey && + defaultUnitRate == other.defaultUnitRate && + groupingKey == other.groupingKey && + additionalProperties == other.additionalProperties + } - fun asMaximum(): NewMaximum = maximum.getOrThrow("maximum") + private val hashCode: Int by lazy { + Objects.hash( + unitRatingKey, + defaultUnitRate, + groupingKey, + additionalProperties, + ) + } - fun _json(): JsonValue? = _json + override fun hashCode(): Int = hashCode - fun accept(visitor: Visitor): T = - when { - percentageDiscount != null -> - visitor.visitPercentageDiscount(percentageDiscount) - usageDiscount != null -> visitor.visitUsageDiscount(usageDiscount) - amountDiscount != null -> visitor.visitAmountDiscount(amountDiscount) - minimum != null -> visitor.visitMinimum(minimum) - maximum != null -> visitor.visitMaximum(maximum) - else -> visitor.unknown(_json) + override fun toString() = + "EventOutputConfig{unitRatingKey=$unitRatingKey, defaultUnitRate=$defaultUnitRate, groupingKey=$groupingKey, additionalProperties=$additionalProperties}" } - private var validated: Boolean = false + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { - fun validate(): Adjustment = apply { - if (validated) { - return@apply - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties - accept( - object : Visitor { - override fun visitPercentageDiscount( - percentageDiscount: NewPercentageDiscount - ) { - percentageDiscount.validate() - } + fun toBuilder() = Builder().from(this) - override fun visitUsageDiscount(usageDiscount: NewUsageDiscount) { - usageDiscount.validate() - } + companion object { - override fun visitAmountDiscount(amountDiscount: NewAmountDiscount) { - amountDiscount.validate() - } + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } - override fun visitMinimum(minimum: NewMinimum) { - minimum.validate() - } + /** A builder for [Metadata]. */ + class Builder internal constructor() { - override fun visitMaximum(maximum: NewMaximum) { - maximum.validate() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() } - } - ) - validated = true - } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitPercentageDiscount( - percentageDiscount: NewPercentageDiscount - ) = percentageDiscount.validity() + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - override fun visitUsageDiscount(usageDiscount: NewUsageDiscount) = - usageDiscount.validity() + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - override fun visitAmountDiscount(amountDiscount: NewAmountDiscount) = - amountDiscount.validity() + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - override fun visitMinimum(minimum: NewMinimum) = minimum.validity() + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - override fun visitMaximum(maximum: NewMaximum) = maximum.validity() - - override fun unknown(json: JsonValue?) = 0 + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Adjustment && - percentageDiscount == other.percentageDiscount && - usageDiscount == other.usageDiscount && - amountDiscount == other.amountDiscount && - minimum == other.minimum && - maximum == other.maximum - } - - override fun hashCode(): Int = - Objects.hash(percentageDiscount, usageDiscount, amountDiscount, minimum, maximum) - - override fun toString(): String = - when { - percentageDiscount != null -> - "Adjustment{percentageDiscount=$percentageDiscount}" - usageDiscount != null -> "Adjustment{usageDiscount=$usageDiscount}" - amountDiscount != null -> "Adjustment{amountDiscount=$amountDiscount}" - minimum != null -> "Adjustment{minimum=$minimum}" - maximum != null -> "Adjustment{maximum=$maximum}" - _json != null -> "Adjustment{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Adjustment") - } - - companion object { - fun ofPercentageDiscount(percentageDiscount: NewPercentageDiscount) = - Adjustment(percentageDiscount = percentageDiscount) - - fun ofUsageDiscount(usageDiscount: NewUsageDiscount) = - Adjustment(usageDiscount = usageDiscount) - - fun ofAmountDiscount(amountDiscount: NewAmountDiscount) = - Adjustment(amountDiscount = amountDiscount) + private var validated: Boolean = false - fun ofMinimum(minimum: NewMinimum) = Adjustment(minimum = minimum) + fun validate(): Metadata = apply { + if (validated) { + return@apply + } - fun ofMaximum(maximum: NewMaximum) = Adjustment(maximum = maximum) - } + validated = true + } - /** - * An interface that defines how to map each variant of [Adjustment] to a value of type - * [T]. - */ - interface Visitor { + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - fun visitPercentageDiscount(percentageDiscount: NewPercentageDiscount): T + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } - fun visitUsageDiscount(usageDiscount: NewUsageDiscount): T + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun visitAmountDiscount(amountDiscount: NewAmountDiscount): T + return other is Metadata && + additionalProperties == other.additionalProperties + } - fun visitMinimum(minimum: NewMinimum): T + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - fun visitMaximum(maximum: NewMaximum): T + override fun hashCode(): Int = hashCode - /** - * Maps an unknown variant of [Adjustment] to a value of type [T]. - * - * An instance of [Adjustment] can contain an unknown variant if it was deserialized - * from data that doesn't match any known variant. For example, if the SDK is on an - * older version than the API, then the API may respond with new variants that the - * SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown Adjustment: $json") + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" } - } - - internal class Deserializer : BaseDeserializer(Adjustment::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): Adjustment { - val json = JsonValue.fromJsonNode(node) - val adjustmentType = json.asObject()?.get("adjustment_type")?.asString() - when (adjustmentType) { - "percentage_discount" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Adjustment(percentageDiscount = it, _json = json) } - ?: Adjustment(_json = json) - } - "usage_discount" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(usageDiscount = it, _json = json) - } ?: Adjustment(_json = json) - } - "amount_discount" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(amountDiscount = it, _json = json) - } ?: Adjustment(_json = json) - } - "minimum" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(minimum = it, _json = json) - } ?: Adjustment(_json = json) - } - "maximum" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(maximum = it, _json = json) - } ?: Adjustment(_json = json) - } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - return Adjustment(_json = json) + return other is EventOutput && + cadence == other.cadence && + eventOutputConfig == other.eventOutputConfig && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties } - } - - internal class Serializer : BaseSerializer(Adjustment::class) { - override fun serialize( - value: Adjustment, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.percentageDiscount != null -> - generator.writeObject(value.percentageDiscount) - value.usageDiscount != null -> generator.writeObject(value.usageDiscount) - value.amountDiscount != null -> generator.writeObject(value.amountDiscount) - value.minimum != null -> generator.writeObject(value.minimum) - value.maximum != null -> generator.writeObject(value.maximum) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Adjustment") - } + private val hashCode: Int by lazy { + Objects.hash( + cadence, + eventOutputConfig, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties, + ) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "EventOutput{cadence=$cadence, eventOutputConfig=$eventOutputConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } } @@ -15904,608 +16485,361 @@ private constructor( return true } - return other is ReplaceAdjustment && - adjustment == other.adjustment && - replacesAdjustmentId == other.replacesAdjustmentId && + return other is AddPrice && + allocationPrice == other.allocationPrice && + discounts == other.discounts && + endDate == other.endDate && + externalPriceId == other.externalPriceId && + maximumAmount == other.maximumAmount && + minimumAmount == other.minimumAmount && + planPhaseOrder == other.planPhaseOrder && + price == other.price && + priceId == other.priceId && + startDate == other.startDate && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(adjustment, replacesAdjustmentId, additionalProperties) + Objects.hash( + allocationPrice, + discounts, + endDate, + externalPriceId, + maximumAmount, + minimumAmount, + planPhaseOrder, + price, + priceId, + startDate, + additionalProperties, + ) } override fun hashCode(): Int = hashCode override fun toString() = - "ReplaceAdjustment{adjustment=$adjustment, replacesAdjustmentId=$replacesAdjustmentId, additionalProperties=$additionalProperties}" + "AddPrice{allocationPrice=$allocationPrice, discounts=$discounts, endDate=$endDate, externalPriceId=$externalPriceId, maximumAmount=$maximumAmount, minimumAmount=$minimumAmount, planPhaseOrder=$planPhaseOrder, price=$price, priceId=$priceId, startDate=$startDate, additionalProperties=$additionalProperties}" } - class ReplacePrice - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val replacesPriceId: JsonField, - private val allocationPrice: JsonField, - private val discounts: JsonField>, - private val externalPriceId: JsonField, - private val fixedPriceQuantity: JsonField, - private val maximumAmount: JsonField, - private val minimumAmount: JsonField, - private val price: JsonField, - private val priceId: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("replaces_price_id") - @ExcludeMissing - replacesPriceId: JsonField = JsonMissing.of(), - @JsonProperty("allocation_price") - @ExcludeMissing - allocationPrice: JsonField = JsonMissing.of(), - @JsonProperty("discounts") - @ExcludeMissing - discounts: JsonField> = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("maximum_amount") - @ExcludeMissing - maximumAmount: JsonField = JsonMissing.of(), - @JsonProperty("minimum_amount") - @ExcludeMissing - minimumAmount: JsonField = JsonMissing.of(), - @JsonProperty("price") @ExcludeMissing price: JsonField = JsonMissing.of(), - @JsonProperty("price_id") @ExcludeMissing priceId: JsonField = JsonMissing.of(), - ) : this( - replacesPriceId, - allocationPrice, - discounts, - externalPriceId, - fixedPriceQuantity, - maximumAmount, - minimumAmount, - price, - priceId, - mutableMapOf(), - ) + @Deprecated("deprecated") + class ExternalMarketplace + @JsonCreator + private constructor(private val value: JsonField) : Enum { /** - * The id of the price on the plan to replace in the subscription. + * Returns this class instance's raw value. * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. */ - fun replacesPriceId(): String = replacesPriceId.getRequired("replaces_price_id") + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - /** - * The definition of a new allocation price to create and add to the subscription. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun allocationPrice(): NewAllocationPrice? = allocationPrice.getNullable("allocation_price") + companion object { - /** - * [DEPRECATED] Use add_adjustments instead. The subscription's discounts for the - * replacement price. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - @Deprecated("deprecated") - fun discounts(): List? = discounts.getNullable("discounts") + val GOOGLE = of("google") - /** - * The external price id of the price to add to the subscription. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + val AWS = of("aws") - /** - * The new quantity of the price, if the price is a fixed price. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun fixedPriceQuantity(): Double? = fixedPriceQuantity.getNullable("fixed_price_quantity") + val AZURE = of("azure") - /** - * [DEPRECATED] Use add_adjustments instead. The subscription's maximum amount for the - * replacement price. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - @Deprecated("deprecated") - fun maximumAmount(): String? = maximumAmount.getNullable("maximum_amount") + fun of(value: String) = ExternalMarketplace(JsonField.of(value)) + } - /** - * [DEPRECATED] Use add_adjustments instead. The subscription's minimum amount for the - * replacement price. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - @Deprecated("deprecated") - fun minimumAmount(): String? = minimumAmount.getNullable("minimum_amount") + /** An enum containing [ExternalMarketplace]'s known values. */ + enum class Known { + GOOGLE, + AWS, + AZURE, + } /** - * New subscription price request body params. + * An enum containing [ExternalMarketplace]'s known values, as well as an [_UNKNOWN] member. * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). + * An instance of [ExternalMarketplace] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. */ - fun price(): Price? = price.getNullable("price") + enum class Value { + GOOGLE, + AWS, + AZURE, + /** + * An enum member indicating that [ExternalMarketplace] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } /** - * The id of the price to add to the subscription. + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. */ - fun priceId(): String? = priceId.getNullable("price_id") + fun value(): Value = + when (this) { + GOOGLE -> Value.GOOGLE + AWS -> Value.AWS + AZURE -> Value.AZURE + else -> Value._UNKNOWN + } /** - * Returns the raw JSON value of [replacesPriceId]. + * Returns an enum member corresponding to this class instance's value. * - * Unlike [replacesPriceId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("replaces_price_id") - @ExcludeMissing - fun _replacesPriceId(): JsonField = replacesPriceId - - /** - * Returns the raw JSON value of [allocationPrice]. + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. * - * Unlike [allocationPrice], this method doesn't throw if the JSON field has an unexpected - * type. + * @throws OrbInvalidDataException if this class instance's value is a not a known member. */ - @JsonProperty("allocation_price") - @ExcludeMissing - fun _allocationPrice(): JsonField = allocationPrice + fun known(): Known = + when (this) { + GOOGLE -> Known.GOOGLE + AWS -> Known.AWS + AZURE -> Known.AZURE + else -> throw OrbInvalidDataException("Unknown ExternalMarketplace: $value") + } /** - * Returns the raw JSON value of [discounts]. + * Returns this class instance's primitive wire representation. * - * Unlike [discounts], this method doesn't throw if the JSON field has an unexpected type. - */ - @Deprecated("deprecated") - @JsonProperty("discounts") - @ExcludeMissing - fun _discounts(): JsonField> = discounts - - /** - * Returns the raw JSON value of [externalPriceId]. + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. * - * Unlike [externalPriceId], this method doesn't throw if the JSON field has an unexpected - * type. + * @throws OrbInvalidDataException if this class instance's value does not have the expected + * primitive type. */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") - /** - * Returns the raw JSON value of [fixedPriceQuantity]. - * - * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + private var validated: Boolean = false - /** - * Returns the raw JSON value of [maximumAmount]. - * - * Unlike [maximumAmount], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @Deprecated("deprecated") - @JsonProperty("maximum_amount") - @ExcludeMissing - fun _maximumAmount(): JsonField = maximumAmount + fun validate(): ExternalMarketplace = apply { + if (validated) { + return@apply + } - /** - * Returns the raw JSON value of [minimumAmount]. - * - * Unlike [minimumAmount], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @Deprecated("deprecated") - @JsonProperty("minimum_amount") - @ExcludeMissing - fun _minimumAmount(): JsonField = minimumAmount + known() + validated = true + } - /** - * Returns the raw JSON value of [price]. - * - * Unlike [price], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("price") @ExcludeMissing fun _price(): JsonField = price + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } /** - * Returns the raw JSON value of [priceId]. + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * Unlike [priceId], this method doesn't throw if the JSON field has an unexpected type. + * Used for best match union deserialization. */ - @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ExternalMarketplace && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by setting + * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to + * `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties fun toBuilder() = Builder().from(this) companion object { - /** - * Returns a mutable builder for constructing an instance of [ReplacePrice]. - * - * The following fields are required: - * ```kotlin - * .replacesPriceId() - * ``` - */ + /** Returns a mutable builder for constructing an instance of [Metadata]. */ fun builder() = Builder() } - /** A builder for [ReplacePrice]. */ + /** A builder for [Metadata]. */ class Builder internal constructor() { - private var replacesPriceId: JsonField? = null - private var allocationPrice: JsonField = JsonMissing.of() - private var discounts: JsonField>? = null - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var maximumAmount: JsonField = JsonMissing.of() - private var minimumAmount: JsonField = JsonMissing.of() - private var price: JsonField = JsonMissing.of() - private var priceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(replacePrice: ReplacePrice) = apply { - replacesPriceId = replacePrice.replacesPriceId - allocationPrice = replacePrice.allocationPrice - discounts = replacePrice.discounts.map { it.toMutableList() } - externalPriceId = replacePrice.externalPriceId - fixedPriceQuantity = replacePrice.fixedPriceQuantity - maximumAmount = replacePrice.maximumAmount - minimumAmount = replacePrice.minimumAmount - price = replacePrice.price - priceId = replacePrice.priceId - additionalProperties = replacePrice.additionalProperties.toMutableMap() + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() } - /** The id of the price on the plan to replace in the subscription. */ - fun replacesPriceId(replacesPriceId: String) = - replacesPriceId(JsonField.of(replacesPriceId)) - - /** - * Sets [Builder.replacesPriceId] to an arbitrary JSON value. - * - * You should usually call [Builder.replacesPriceId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun replacesPriceId(replacesPriceId: JsonField) = apply { - this.replacesPriceId = replacesPriceId + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) } - /** The definition of a new allocation price to create and add to the subscription. */ - fun allocationPrice(allocationPrice: NewAllocationPrice?) = - allocationPrice(JsonField.ofNullable(allocationPrice)) + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * Sets [Builder.allocationPrice] to an arbitrary JSON value. - * - * You should usually call [Builder.allocationPrice] with a well-typed - * [NewAllocationPrice] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun allocationPrice(allocationPrice: JsonField) = apply { - this.allocationPrice = allocationPrice + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) } - /** - * [DEPRECATED] Use add_adjustments instead. The subscription's discounts for the - * replacement price. - */ - @Deprecated("deprecated") - fun discounts(discounts: List?) = - discounts(JsonField.ofNullable(discounts)) + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - /** - * Sets [Builder.discounts] to an arbitrary JSON value. - * - * You should usually call [Builder.discounts] with a well-typed - * `List` value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - @Deprecated("deprecated") - fun discounts(discounts: JsonField>) = apply { - this.discounts = discounts.map { it.toMutableList() } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) } /** - * Adds a single [DiscountOverride] to [discounts]. + * Returns an immutable instance of [Metadata]. * - * @throws IllegalStateException if the field was previously set to a non-list. + * Further updates to this [Builder] will not mutate the returned instance. */ - @Deprecated("deprecated") - fun addDiscount(discount: DiscountOverride) = apply { - discounts = - (discounts ?: JsonField.of(mutableListOf())).also { - checkKnown("discounts", it).add(discount) - } - } + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } - /** The external price id of the price to add to the subscription. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) + private var validated: Boolean = false - /** - * Sets [Builder.externalPriceId] to an arbitrary JSON value. - * - * You should usually call [Builder.externalPriceId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun externalPriceId(externalPriceId: JsonField) = apply { - this.externalPriceId = externalPriceId + fun validate(): Metadata = apply { + if (validated) { + return@apply } - /** The new quantity of the price, if the price is a fixed price. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = - fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) - - /** - * Alias for [Builder.fixedPriceQuantity]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) + validated = true + } - /** - * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. - * - * You should usually call [Builder.fixedPriceQuantity] with a well-typed [Double] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { - this.fixedPriceQuantity = fixedPriceQuantity + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false } - /** - * [DEPRECATED] Use add_adjustments instead. The subscription's maximum amount for the - * replacement price. - */ - @Deprecated("deprecated") - fun maximumAmount(maximumAmount: String?) = - maximumAmount(JsonField.ofNullable(maximumAmount)) + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } - /** - * Sets [Builder.maximumAmount] to an arbitrary JSON value. - * - * You should usually call [Builder.maximumAmount] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - @Deprecated("deprecated") - fun maximumAmount(maximumAmount: JsonField) = apply { - this.maximumAmount = maximumAmount + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - /** - * [DEPRECATED] Use add_adjustments instead. The subscription's minimum amount for the - * replacement price. - */ - @Deprecated("deprecated") - fun minimumAmount(minimumAmount: String?) = - minimumAmount(JsonField.ofNullable(minimumAmount)) - - /** - * Sets [Builder.minimumAmount] to an arbitrary JSON value. - * - * You should usually call [Builder.minimumAmount] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - @Deprecated("deprecated") - fun minimumAmount(minimumAmount: JsonField) = apply { - this.minimumAmount = minimumAmount - } + return other is Metadata && additionalProperties == other.additionalProperties + } - /** New subscription price request body params. */ - fun price(price: Price?) = price(JsonField.ofNullable(price)) + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /** - * Sets [Builder.price] to an arbitrary JSON value. - * - * You should usually call [Builder.price] with a well-typed [Price] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun price(price: JsonField) = apply { this.price = price } + override fun hashCode(): Int = hashCode - /** Alias for calling [price] with `Price.ofUnit(unit)`. */ - fun price(unit: NewSubscriptionUnitPrice) = price(Price.ofUnit(unit)) + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } - /** Alias for calling [price] with `Price.ofTiered(tiered)`. */ - fun price(tiered: NewSubscriptionTieredPrice) = price(Price.ofTiered(tiered)) + class RemoveAdjustment + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val adjustmentId: JsonField, + private val additionalProperties: MutableMap, + ) { - /** Alias for calling [price] with `Price.ofBulk(bulk)`. */ - fun price(bulk: NewSubscriptionBulkPrice) = price(Price.ofBulk(bulk)) + @JsonCreator + private constructor( + @JsonProperty("adjustment_id") + @ExcludeMissing + adjustmentId: JsonField = JsonMissing.of() + ) : this(adjustmentId, mutableMapOf()) - /** Alias for calling [price] with `Price.ofBulkWithFilters(bulkWithFilters)`. */ - fun price(bulkWithFilters: Price.BulkWithFilters) = - price(Price.ofBulkWithFilters(bulkWithFilters)) - - /** Alias for calling [price] with `Price.ofPackage(package_)`. */ - fun price(package_: NewSubscriptionPackagePrice) = price(Price.ofPackage(package_)) - - /** Alias for calling [price] with `Price.ofMatrix(matrix)`. */ - fun price(matrix: NewSubscriptionMatrixPrice) = price(Price.ofMatrix(matrix)) - - /** - * Alias for calling [price] with `Price.ofThresholdTotalAmount(thresholdTotalAmount)`. - */ - fun price(thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice) = - price(Price.ofThresholdTotalAmount(thresholdTotalAmount)) - - /** Alias for calling [price] with `Price.ofTieredPackage(tieredPackage)`. */ - fun price(tieredPackage: NewSubscriptionTieredPackagePrice) = - price(Price.ofTieredPackage(tieredPackage)) - - /** Alias for calling [price] with `Price.ofTieredWithMinimum(tieredWithMinimum)`. */ - fun price(tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice) = - price(Price.ofTieredWithMinimum(tieredWithMinimum)) - - /** Alias for calling [price] with `Price.ofGroupedTiered(groupedTiered)`. */ - fun price(groupedTiered: NewSubscriptionGroupedTieredPrice) = - price(Price.ofGroupedTiered(groupedTiered)) - - /** - * Alias for calling [price] with - * `Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)`. - */ - fun price(tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice) = - price(Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)) - - /** - * Alias for calling [price] with - * `Price.ofPackageWithAllocation(packageWithAllocation)`. - */ - fun price(packageWithAllocation: NewSubscriptionPackageWithAllocationPrice) = - price(Price.ofPackageWithAllocation(packageWithAllocation)) - - /** Alias for calling [price] with `Price.ofUnitWithPercent(unitWithPercent)`. */ - fun price(unitWithPercent: NewSubscriptionUnitWithPercentPrice) = - price(Price.ofUnitWithPercent(unitWithPercent)) - - /** - * Alias for calling [price] with `Price.ofMatrixWithAllocation(matrixWithAllocation)`. - */ - fun price(matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice) = - price(Price.ofMatrixWithAllocation(matrixWithAllocation)) - - /** - * Alias for calling [price] with `Price.ofTieredWithProration(tieredWithProration)`. - */ - fun price(tieredWithProration: Price.TieredWithProration) = - price(Price.ofTieredWithProration(tieredWithProration)) - - /** Alias for calling [price] with `Price.ofUnitWithProration(unitWithProration)`. */ - fun price(unitWithProration: NewSubscriptionUnitWithProrationPrice) = - price(Price.ofUnitWithProration(unitWithProration)) - - /** Alias for calling [price] with `Price.ofGroupedAllocation(groupedAllocation)`. */ - fun price(groupedAllocation: NewSubscriptionGroupedAllocationPrice) = - price(Price.ofGroupedAllocation(groupedAllocation)) - - /** Alias for calling [price] with `Price.ofBulkWithProration(bulkWithProration)`. */ - fun price(bulkWithProration: NewSubscriptionBulkWithProrationPrice) = - price(Price.ofBulkWithProration(bulkWithProration)) - - /** - * Alias for calling [price] with - * `Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)`. - */ - fun price(groupedWithProratedMinimum: NewSubscriptionGroupedWithProratedMinimumPrice) = - price(Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)) - - /** - * Alias for calling [price] with - * `Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)`. - */ - fun price(groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice) = - price(Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)) - - /** - * Alias for calling [price] with - * `Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)`. - */ - fun price(groupedWithMinMaxThresholds: Price.GroupedWithMinMaxThresholds) = - price(Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)) + /** + * The id of the adjustment to remove on the subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun adjustmentId(): String = adjustmentId.getRequired("adjustment_id") - /** - * Alias for calling [price] with - * `Price.ofMatrixWithDisplayName(matrixWithDisplayName)`. - */ - fun price(matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice) = - price(Price.ofMatrixWithDisplayName(matrixWithDisplayName)) + /** + * Returns the raw JSON value of [adjustmentId]. + * + * Unlike [adjustmentId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("adjustment_id") + @ExcludeMissing + fun _adjustmentId(): JsonField = adjustmentId - /** - * Alias for calling [price] with `Price.ofGroupedTieredPackage(groupedTieredPackage)`. - */ - fun price(groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice) = - price(Price.ofGroupedTieredPackage(groupedTieredPackage)) + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - /** - * Alias for calling [price] with - * `Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)`. - */ - fun price(maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice) = - price(Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)) + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - /** - * Alias for calling [price] with - * `Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)`. - */ - fun price( - scalableMatrixWithUnitPricing: NewSubscriptionScalableMatrixWithUnitPricingPrice - ) = price(Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)) + fun toBuilder() = Builder().from(this) - /** - * Alias for calling [price] with - * `Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)`. - */ - fun price( - scalableMatrixWithTieredPricing: NewSubscriptionScalableMatrixWithTieredPricingPrice - ) = price(Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)) + companion object { /** - * Alias for calling [price] with - * `Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)`. + * Returns a mutable builder for constructing an instance of [RemoveAdjustment]. + * + * The following fields are required: + * ```kotlin + * .adjustmentId() + * ``` */ - fun price(cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice) = - price(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) + fun builder() = Builder() + } - /** Alias for calling [price] with `Price.ofMinimum(minimum)`. */ - fun price(minimum: NewSubscriptionMinimumCompositePrice) = - price(Price.ofMinimum(minimum)) + /** A builder for [RemoveAdjustment]. */ + class Builder internal constructor() { - /** Alias for calling [price] with `Price.ofPercent(percent)`. */ - fun price(percent: Price.Percent) = price(Price.ofPercent(percent)) + private var adjustmentId: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() - /** Alias for calling [price] with `Price.ofEventOutput(eventOutput)`. */ - fun price(eventOutput: Price.EventOutput) = price(Price.ofEventOutput(eventOutput)) + internal fun from(removeAdjustment: RemoveAdjustment) = apply { + adjustmentId = removeAdjustment.adjustmentId + additionalProperties = removeAdjustment.additionalProperties.toMutableMap() + } - /** The id of the price to add to the subscription. */ - fun priceId(priceId: String?) = priceId(JsonField.ofNullable(priceId)) + /** The id of the adjustment to remove on the subscription. */ + fun adjustmentId(adjustmentId: String) = adjustmentId(JsonField.of(adjustmentId)) /** - * Sets [Builder.priceId] to an arbitrary JSON value. + * Sets [Builder.adjustmentId] to an arbitrary JSON value. * - * You should usually call [Builder.priceId] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet + * You should usually call [Builder.adjustmentId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun priceId(priceId: JsonField) = apply { this.priceId = priceId } + fun adjustmentId(adjustmentId: JsonField) = apply { + this.adjustmentId = adjustmentId + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -16527,48 +16861,32 @@ private constructor( } /** - * Returns an immutable instance of [ReplacePrice]. + * Returns an immutable instance of [RemoveAdjustment]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```kotlin - * .replacesPriceId() + * .adjustmentId() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): ReplacePrice = - ReplacePrice( - checkRequired("replacesPriceId", replacesPriceId), - allocationPrice, - (discounts ?: JsonMissing.of()).map { it.toImmutable() }, - externalPriceId, - fixedPriceQuantity, - maximumAmount, - minimumAmount, - price, - priceId, + fun build(): RemoveAdjustment = + RemoveAdjustment( + checkRequired("adjustmentId", adjustmentId), additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): ReplacePrice = apply { + fun validate(): RemoveAdjustment = apply { if (validated) { return@apply } - replacesPriceId() - allocationPrice()?.validate() - discounts()?.forEach { it.validate() } - externalPriceId() - fixedPriceQuantity() - maximumAmount() - minimumAmount() - price()?.validate() - priceId() + adjustmentId() validated = true } @@ -16586,1285 +16904,4807 @@ private constructor( * * Used for best match union deserialization. */ - internal fun validity(): Int = - (if (replacesPriceId.asKnown() == null) 0 else 1) + - (allocationPrice.asKnown()?.validity() ?: 0) + - (discounts.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + - (if (externalPriceId.asKnown() == null) 0 else 1) + - (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + - (if (maximumAmount.asKnown() == null) 0 else 1) + - (if (minimumAmount.asKnown() == null) 0 else 1) + - (price.asKnown()?.validity() ?: 0) + - (if (priceId.asKnown() == null) 0 else 1) + internal fun validity(): Int = (if (adjustmentId.asKnown() == null) 0 else 1) - /** New subscription price request body params. */ - @JsonDeserialize(using = Price.Deserializer::class) - @JsonSerialize(using = Price.Serializer::class) - class Price - private constructor( - private val unit: NewSubscriptionUnitPrice? = null, - private val tiered: NewSubscriptionTieredPrice? = null, - private val bulk: NewSubscriptionBulkPrice? = null, - private val bulkWithFilters: BulkWithFilters? = null, - private val package_: NewSubscriptionPackagePrice? = null, - private val matrix: NewSubscriptionMatrixPrice? = null, - private val thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice? = null, - private val tieredPackage: NewSubscriptionTieredPackagePrice? = null, - private val tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice? = null, - private val groupedTiered: NewSubscriptionGroupedTieredPrice? = null, - private val tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice? = - null, - private val packageWithAllocation: NewSubscriptionPackageWithAllocationPrice? = null, - private val unitWithPercent: NewSubscriptionUnitWithPercentPrice? = null, - private val matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice? = null, - private val tieredWithProration: TieredWithProration? = null, - private val unitWithProration: NewSubscriptionUnitWithProrationPrice? = null, - private val groupedAllocation: NewSubscriptionGroupedAllocationPrice? = null, - private val bulkWithProration: NewSubscriptionBulkWithProrationPrice? = null, - private val groupedWithProratedMinimum: - NewSubscriptionGroupedWithProratedMinimumPrice? = - null, - private val groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice? = - null, - private val groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds? = null, - private val matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice? = null, - private val groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice? = null, - private val maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice? = null, - private val scalableMatrixWithUnitPricing: - NewSubscriptionScalableMatrixWithUnitPricingPrice? = - null, - private val scalableMatrixWithTieredPricing: - NewSubscriptionScalableMatrixWithTieredPricingPrice? = - null, - private val cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice? = null, - private val minimum: NewSubscriptionMinimumCompositePrice? = null, - private val percent: Percent? = null, - private val eventOutput: EventOutput? = null, - private val _json: JsonValue? = null, - ) { - - fun unit(): NewSubscriptionUnitPrice? = unit - - fun tiered(): NewSubscriptionTieredPrice? = tiered + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun bulk(): NewSubscriptionBulkPrice? = bulk + return other is RemoveAdjustment && + adjustmentId == other.adjustmentId && + additionalProperties == other.additionalProperties + } - fun bulkWithFilters(): BulkWithFilters? = bulkWithFilters + private val hashCode: Int by lazy { Objects.hash(adjustmentId, additionalProperties) } - fun package_(): NewSubscriptionPackagePrice? = package_ + override fun hashCode(): Int = hashCode - fun matrix(): NewSubscriptionMatrixPrice? = matrix + override fun toString() = + "RemoveAdjustment{adjustmentId=$adjustmentId, additionalProperties=$additionalProperties}" + } - fun thresholdTotalAmount(): NewSubscriptionThresholdTotalAmountPrice? = - thresholdTotalAmount + class RemovePrice + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val externalPriceId: JsonField, + private val priceId: JsonField, + private val additionalProperties: MutableMap, + ) { - fun tieredPackage(): NewSubscriptionTieredPackagePrice? = tieredPackage + @JsonCreator + private constructor( + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("price_id") @ExcludeMissing priceId: JsonField = JsonMissing.of(), + ) : this(externalPriceId, priceId, mutableMapOf()) - fun tieredWithMinimum(): NewSubscriptionTieredWithMinimumPrice? = tieredWithMinimum + /** + * The external price id of the price to remove on the subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") - fun groupedTiered(): NewSubscriptionGroupedTieredPrice? = groupedTiered + /** + * The id of the price to remove on the subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun priceId(): String? = priceId.getNullable("price_id") - fun tieredPackageWithMinimum(): NewSubscriptionTieredPackageWithMinimumPrice? = - tieredPackageWithMinimum + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId - fun packageWithAllocation(): NewSubscriptionPackageWithAllocationPrice? = - packageWithAllocation + /** + * Returns the raw JSON value of [priceId]. + * + * Unlike [priceId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId - fun unitWithPercent(): NewSubscriptionUnitWithPercentPrice? = unitWithPercent + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - fun matrixWithAllocation(): NewSubscriptionMatrixWithAllocationPrice? = - matrixWithAllocation + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - fun tieredWithProration(): TieredWithProration? = tieredWithProration + fun toBuilder() = Builder().from(this) - fun unitWithProration(): NewSubscriptionUnitWithProrationPrice? = unitWithProration + companion object { - fun groupedAllocation(): NewSubscriptionGroupedAllocationPrice? = groupedAllocation + /** Returns a mutable builder for constructing an instance of [RemovePrice]. */ + fun builder() = Builder() + } - fun bulkWithProration(): NewSubscriptionBulkWithProrationPrice? = bulkWithProration + /** A builder for [RemovePrice]. */ + class Builder internal constructor() { - fun groupedWithProratedMinimum(): NewSubscriptionGroupedWithProratedMinimumPrice? = - groupedWithProratedMinimum + private var externalPriceId: JsonField = JsonMissing.of() + private var priceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - fun groupedWithMeteredMinimum(): NewSubscriptionGroupedWithMeteredMinimumPrice? = - groupedWithMeteredMinimum + internal fun from(removePrice: RemovePrice) = apply { + externalPriceId = removePrice.externalPriceId + priceId = removePrice.priceId + additionalProperties = removePrice.additionalProperties.toMutableMap() + } - fun groupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds? = - groupedWithMinMaxThresholds + /** The external price id of the price to remove on the subscription. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) - fun matrixWithDisplayName(): NewSubscriptionMatrixWithDisplayNamePrice? = - matrixWithDisplayName + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } - fun groupedTieredPackage(): NewSubscriptionGroupedTieredPackagePrice? = - groupedTieredPackage + /** The id of the price to remove on the subscription. */ + fun priceId(priceId: String?) = priceId(JsonField.ofNullable(priceId)) - fun maxGroupTieredPackage(): NewSubscriptionMaxGroupTieredPackagePrice? = - maxGroupTieredPackage + /** + * Sets [Builder.priceId] to an arbitrary JSON value. + * + * You should usually call [Builder.priceId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun priceId(priceId: JsonField) = apply { this.priceId = priceId } - fun scalableMatrixWithUnitPricing(): - NewSubscriptionScalableMatrixWithUnitPricingPrice? = scalableMatrixWithUnitPricing + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun scalableMatrixWithTieredPricing(): - NewSubscriptionScalableMatrixWithTieredPricingPrice? = - scalableMatrixWithTieredPricing + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun cumulativeGroupedBulk(): NewSubscriptionCumulativeGroupedBulkPrice? = - cumulativeGroupedBulk + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun minimum(): NewSubscriptionMinimumCompositePrice? = minimum + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - fun percent(): Percent? = percent + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - fun eventOutput(): EventOutput? = eventOutput + /** + * Returns an immutable instance of [RemovePrice]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): RemovePrice = + RemovePrice(externalPriceId, priceId, additionalProperties.toMutableMap()) + } - fun isUnit(): Boolean = unit != null + private var validated: Boolean = false - fun isTiered(): Boolean = tiered != null + fun validate(): RemovePrice = apply { + if (validated) { + return@apply + } - fun isBulk(): Boolean = bulk != null + externalPriceId() + priceId() + validated = true + } - fun isBulkWithFilters(): Boolean = bulkWithFilters != null + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - fun isPackage(): Boolean = package_ != null + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (priceId.asKnown() == null) 0 else 1) - fun isMatrix(): Boolean = matrix != null + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun isThresholdTotalAmount(): Boolean = thresholdTotalAmount != null + return other is RemovePrice && + externalPriceId == other.externalPriceId && + priceId == other.priceId && + additionalProperties == other.additionalProperties + } - fun isTieredPackage(): Boolean = tieredPackage != null + private val hashCode: Int by lazy { + Objects.hash(externalPriceId, priceId, additionalProperties) + } - fun isTieredWithMinimum(): Boolean = tieredWithMinimum != null + override fun hashCode(): Int = hashCode - fun isGroupedTiered(): Boolean = groupedTiered != null + override fun toString() = + "RemovePrice{externalPriceId=$externalPriceId, priceId=$priceId, additionalProperties=$additionalProperties}" + } - fun isTieredPackageWithMinimum(): Boolean = tieredPackageWithMinimum != null + class ReplaceAdjustment + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val adjustment: JsonField, + private val replacesAdjustmentId: JsonField, + private val additionalProperties: MutableMap, + ) { - fun isPackageWithAllocation(): Boolean = packageWithAllocation != null + @JsonCreator + private constructor( + @JsonProperty("adjustment") + @ExcludeMissing + adjustment: JsonField = JsonMissing.of(), + @JsonProperty("replaces_adjustment_id") + @ExcludeMissing + replacesAdjustmentId: JsonField = JsonMissing.of(), + ) : this(adjustment, replacesAdjustmentId, mutableMapOf()) - fun isUnitWithPercent(): Boolean = unitWithPercent != null - - fun isMatrixWithAllocation(): Boolean = matrixWithAllocation != null + /** + * The definition of a new adjustment to create and add to the subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun adjustment(): Adjustment = adjustment.getRequired("adjustment") - fun isTieredWithProration(): Boolean = tieredWithProration != null + /** + * The id of the adjustment on the plan to replace in the subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun replacesAdjustmentId(): String = + replacesAdjustmentId.getRequired("replaces_adjustment_id") - fun isUnitWithProration(): Boolean = unitWithProration != null + /** + * Returns the raw JSON value of [adjustment]. + * + * Unlike [adjustment], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("adjustment") + @ExcludeMissing + fun _adjustment(): JsonField = adjustment - fun isGroupedAllocation(): Boolean = groupedAllocation != null + /** + * Returns the raw JSON value of [replacesAdjustmentId]. + * + * Unlike [replacesAdjustmentId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("replaces_adjustment_id") + @ExcludeMissing + fun _replacesAdjustmentId(): JsonField = replacesAdjustmentId - fun isBulkWithProration(): Boolean = bulkWithProration != null + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - fun isGroupedWithProratedMinimum(): Boolean = groupedWithProratedMinimum != null + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - fun isGroupedWithMeteredMinimum(): Boolean = groupedWithMeteredMinimum != null + fun toBuilder() = Builder().from(this) - fun isGroupedWithMinMaxThresholds(): Boolean = groupedWithMinMaxThresholds != null + companion object { - fun isMatrixWithDisplayName(): Boolean = matrixWithDisplayName != null + /** + * Returns a mutable builder for constructing an instance of [ReplaceAdjustment]. + * + * The following fields are required: + * ```kotlin + * .adjustment() + * .replacesAdjustmentId() + * ``` + */ + fun builder() = Builder() + } - fun isGroupedTieredPackage(): Boolean = groupedTieredPackage != null + /** A builder for [ReplaceAdjustment]. */ + class Builder internal constructor() { - fun isMaxGroupTieredPackage(): Boolean = maxGroupTieredPackage != null + private var adjustment: JsonField? = null + private var replacesAdjustmentId: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() - fun isScalableMatrixWithUnitPricing(): Boolean = scalableMatrixWithUnitPricing != null + internal fun from(replaceAdjustment: ReplaceAdjustment) = apply { + adjustment = replaceAdjustment.adjustment + replacesAdjustmentId = replaceAdjustment.replacesAdjustmentId + additionalProperties = replaceAdjustment.additionalProperties.toMutableMap() + } - fun isScalableMatrixWithTieredPricing(): Boolean = - scalableMatrixWithTieredPricing != null + /** The definition of a new adjustment to create and add to the subscription. */ + fun adjustment(adjustment: Adjustment) = adjustment(JsonField.of(adjustment)) - fun isCumulativeGroupedBulk(): Boolean = cumulativeGroupedBulk != null + /** + * Sets [Builder.adjustment] to an arbitrary JSON value. + * + * You should usually call [Builder.adjustment] with a well-typed [Adjustment] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun adjustment(adjustment: JsonField) = apply { + this.adjustment = adjustment + } - fun isMinimum(): Boolean = minimum != null + /** + * Alias for calling [adjustment] with + * `Adjustment.ofPercentageDiscount(percentageDiscount)`. + */ + fun adjustment(percentageDiscount: NewPercentageDiscount) = + adjustment(Adjustment.ofPercentageDiscount(percentageDiscount)) - fun isPercent(): Boolean = percent != null + /** + * Alias for calling [adjustment] with the following: + * ```kotlin + * NewPercentageDiscount.builder() + * .adjustmentType(NewPercentageDiscount.AdjustmentType.PERCENTAGE_DISCOUNT) + * .percentageDiscount(percentageDiscount) + * .build() + * ``` + */ + fun percentageDiscountAdjustment(percentageDiscount: Double) = + adjustment( + NewPercentageDiscount.builder() + .adjustmentType(NewPercentageDiscount.AdjustmentType.PERCENTAGE_DISCOUNT) + .percentageDiscount(percentageDiscount) + .build() + ) - fun isEventOutput(): Boolean = eventOutput != null + /** Alias for calling [adjustment] with `Adjustment.ofUsageDiscount(usageDiscount)`. */ + fun adjustment(usageDiscount: NewUsageDiscount) = + adjustment(Adjustment.ofUsageDiscount(usageDiscount)) - fun asUnit(): NewSubscriptionUnitPrice = unit.getOrThrow("unit") + /** + * Alias for calling [adjustment] with the following: + * ```kotlin + * NewUsageDiscount.builder() + * .adjustmentType(NewUsageDiscount.AdjustmentType.USAGE_DISCOUNT) + * .usageDiscount(usageDiscount) + * .build() + * ``` + */ + fun usageDiscountAdjustment(usageDiscount: Double) = + adjustment( + NewUsageDiscount.builder() + .adjustmentType(NewUsageDiscount.AdjustmentType.USAGE_DISCOUNT) + .usageDiscount(usageDiscount) + .build() + ) - fun asTiered(): NewSubscriptionTieredPrice = tiered.getOrThrow("tiered") + /** + * Alias for calling [adjustment] with `Adjustment.ofAmountDiscount(amountDiscount)`. + */ + fun adjustment(amountDiscount: NewAmountDiscount) = + adjustment(Adjustment.ofAmountDiscount(amountDiscount)) - fun asBulk(): NewSubscriptionBulkPrice = bulk.getOrThrow("bulk") + /** + * Alias for calling [adjustment] with the following: + * ```kotlin + * NewAmountDiscount.builder() + * .adjustmentType(NewAmountDiscount.AdjustmentType.AMOUNT_DISCOUNT) + * .amountDiscount(amountDiscount) + * .build() + * ``` + */ + fun amountDiscountAdjustment(amountDiscount: String) = + adjustment( + NewAmountDiscount.builder() + .adjustmentType(NewAmountDiscount.AdjustmentType.AMOUNT_DISCOUNT) + .amountDiscount(amountDiscount) + .build() + ) - fun asBulkWithFilters(): BulkWithFilters = bulkWithFilters.getOrThrow("bulkWithFilters") + /** Alias for calling [adjustment] with `Adjustment.ofMinimum(minimum)`. */ + fun adjustment(minimum: NewMinimum) = adjustment(Adjustment.ofMinimum(minimum)) - fun asPackage(): NewSubscriptionPackagePrice = package_.getOrThrow("package_") + /** Alias for calling [adjustment] with `Adjustment.ofMaximum(maximum)`. */ + fun adjustment(maximum: NewMaximum) = adjustment(Adjustment.ofMaximum(maximum)) - fun asMatrix(): NewSubscriptionMatrixPrice = matrix.getOrThrow("matrix") + /** + * Alias for calling [adjustment] with the following: + * ```kotlin + * NewMaximum.builder() + * .adjustmentType(NewMaximum.AdjustmentType.MAXIMUM) + * .maximumAmount(maximumAmount) + * .build() + * ``` + */ + fun maximumAdjustment(maximumAmount: String) = + adjustment( + NewMaximum.builder() + .adjustmentType(NewMaximum.AdjustmentType.MAXIMUM) + .maximumAmount(maximumAmount) + .build() + ) - fun asThresholdTotalAmount(): NewSubscriptionThresholdTotalAmountPrice = - thresholdTotalAmount.getOrThrow("thresholdTotalAmount") + /** The id of the adjustment on the plan to replace in the subscription. */ + fun replacesAdjustmentId(replacesAdjustmentId: String) = + replacesAdjustmentId(JsonField.of(replacesAdjustmentId)) - fun asTieredPackage(): NewSubscriptionTieredPackagePrice = - tieredPackage.getOrThrow("tieredPackage") + /** + * Sets [Builder.replacesAdjustmentId] to an arbitrary JSON value. + * + * You should usually call [Builder.replacesAdjustmentId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun replacesAdjustmentId(replacesAdjustmentId: JsonField) = apply { + this.replacesAdjustmentId = replacesAdjustmentId + } - fun asTieredWithMinimum(): NewSubscriptionTieredWithMinimumPrice = - tieredWithMinimum.getOrThrow("tieredWithMinimum") + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun asGroupedTiered(): NewSubscriptionGroupedTieredPrice = - groupedTiered.getOrThrow("groupedTiered") + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun asTieredPackageWithMinimum(): NewSubscriptionTieredPackageWithMinimumPrice = - tieredPackageWithMinimum.getOrThrow("tieredPackageWithMinimum") + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun asPackageWithAllocation(): NewSubscriptionPackageWithAllocationPrice = - packageWithAllocation.getOrThrow("packageWithAllocation") + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - fun asUnitWithPercent(): NewSubscriptionUnitWithPercentPrice = - unitWithPercent.getOrThrow("unitWithPercent") + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - fun asMatrixWithAllocation(): NewSubscriptionMatrixWithAllocationPrice = - matrixWithAllocation.getOrThrow("matrixWithAllocation") + /** + * Returns an immutable instance of [ReplaceAdjustment]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .adjustment() + * .replacesAdjustmentId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ReplaceAdjustment = + ReplaceAdjustment( + checkRequired("adjustment", adjustment), + checkRequired("replacesAdjustmentId", replacesAdjustmentId), + additionalProperties.toMutableMap(), + ) + } - fun asTieredWithProration(): TieredWithProration = - tieredWithProration.getOrThrow("tieredWithProration") + private var validated: Boolean = false - fun asUnitWithProration(): NewSubscriptionUnitWithProrationPrice = - unitWithProration.getOrThrow("unitWithProration") + fun validate(): ReplaceAdjustment = apply { + if (validated) { + return@apply + } - fun asGroupedAllocation(): NewSubscriptionGroupedAllocationPrice = - groupedAllocation.getOrThrow("groupedAllocation") + adjustment().validate() + replacesAdjustmentId() + validated = true + } - fun asBulkWithProration(): NewSubscriptionBulkWithProrationPrice = - bulkWithProration.getOrThrow("bulkWithProration") + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - fun asGroupedWithProratedMinimum(): NewSubscriptionGroupedWithProratedMinimumPrice = - groupedWithProratedMinimum.getOrThrow("groupedWithProratedMinimum") + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (adjustment.asKnown()?.validity() ?: 0) + + (if (replacesAdjustmentId.asKnown() == null) 0 else 1) - fun asGroupedWithMeteredMinimum(): NewSubscriptionGroupedWithMeteredMinimumPrice = - groupedWithMeteredMinimum.getOrThrow("groupedWithMeteredMinimum") + /** The definition of a new adjustment to create and add to the subscription. */ + @JsonDeserialize(using = Adjustment.Deserializer::class) + @JsonSerialize(using = Adjustment.Serializer::class) + class Adjustment + private constructor( + private val percentageDiscount: NewPercentageDiscount? = null, + private val usageDiscount: NewUsageDiscount? = null, + private val amountDiscount: NewAmountDiscount? = null, + private val minimum: NewMinimum? = null, + private val maximum: NewMaximum? = null, + private val _json: JsonValue? = null, + ) { - fun asGroupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds = - groupedWithMinMaxThresholds.getOrThrow("groupedWithMinMaxThresholds") + fun percentageDiscount(): NewPercentageDiscount? = percentageDiscount - fun asMatrixWithDisplayName(): NewSubscriptionMatrixWithDisplayNamePrice = - matrixWithDisplayName.getOrThrow("matrixWithDisplayName") + fun usageDiscount(): NewUsageDiscount? = usageDiscount - fun asGroupedTieredPackage(): NewSubscriptionGroupedTieredPackagePrice = - groupedTieredPackage.getOrThrow("groupedTieredPackage") + fun amountDiscount(): NewAmountDiscount? = amountDiscount - fun asMaxGroupTieredPackage(): NewSubscriptionMaxGroupTieredPackagePrice = - maxGroupTieredPackage.getOrThrow("maxGroupTieredPackage") + fun minimum(): NewMinimum? = minimum - fun asScalableMatrixWithUnitPricing(): - NewSubscriptionScalableMatrixWithUnitPricingPrice = - scalableMatrixWithUnitPricing.getOrThrow("scalableMatrixWithUnitPricing") + fun maximum(): NewMaximum? = maximum - fun asScalableMatrixWithTieredPricing(): - NewSubscriptionScalableMatrixWithTieredPricingPrice = - scalableMatrixWithTieredPricing.getOrThrow("scalableMatrixWithTieredPricing") + fun isPercentageDiscount(): Boolean = percentageDiscount != null - fun asCumulativeGroupedBulk(): NewSubscriptionCumulativeGroupedBulkPrice = - cumulativeGroupedBulk.getOrThrow("cumulativeGroupedBulk") + fun isUsageDiscount(): Boolean = usageDiscount != null - fun asMinimum(): NewSubscriptionMinimumCompositePrice = minimum.getOrThrow("minimum") + fun isAmountDiscount(): Boolean = amountDiscount != null - fun asPercent(): Percent = percent.getOrThrow("percent") + fun isMinimum(): Boolean = minimum != null - fun asEventOutput(): EventOutput = eventOutput.getOrThrow("eventOutput") + fun isMaximum(): Boolean = maximum != null + + fun asPercentageDiscount(): NewPercentageDiscount = + percentageDiscount.getOrThrow("percentageDiscount") + + fun asUsageDiscount(): NewUsageDiscount = usageDiscount.getOrThrow("usageDiscount") + + fun asAmountDiscount(): NewAmountDiscount = amountDiscount.getOrThrow("amountDiscount") + + fun asMinimum(): NewMinimum = minimum.getOrThrow("minimum") + + fun asMaximum(): NewMaximum = maximum.getOrThrow("maximum") fun _json(): JsonValue? = _json fun accept(visitor: Visitor): T = when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - bulk != null -> visitor.visitBulk(bulk) - bulkWithFilters != null -> visitor.visitBulkWithFilters(bulkWithFilters) - package_ != null -> visitor.visitPackage(package_) - matrix != null -> visitor.visitMatrix(matrix) - thresholdTotalAmount != null -> - visitor.visitThresholdTotalAmount(thresholdTotalAmount) - tieredPackage != null -> visitor.visitTieredPackage(tieredPackage) - tieredWithMinimum != null -> visitor.visitTieredWithMinimum(tieredWithMinimum) - groupedTiered != null -> visitor.visitGroupedTiered(groupedTiered) - tieredPackageWithMinimum != null -> - visitor.visitTieredPackageWithMinimum(tieredPackageWithMinimum) - packageWithAllocation != null -> - visitor.visitPackageWithAllocation(packageWithAllocation) - unitWithPercent != null -> visitor.visitUnitWithPercent(unitWithPercent) - matrixWithAllocation != null -> - visitor.visitMatrixWithAllocation(matrixWithAllocation) - tieredWithProration != null -> - visitor.visitTieredWithProration(tieredWithProration) - unitWithProration != null -> visitor.visitUnitWithProration(unitWithProration) - groupedAllocation != null -> visitor.visitGroupedAllocation(groupedAllocation) - bulkWithProration != null -> visitor.visitBulkWithProration(bulkWithProration) - groupedWithProratedMinimum != null -> - visitor.visitGroupedWithProratedMinimum(groupedWithProratedMinimum) - groupedWithMeteredMinimum != null -> - visitor.visitGroupedWithMeteredMinimum(groupedWithMeteredMinimum) - groupedWithMinMaxThresholds != null -> - visitor.visitGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds) - matrixWithDisplayName != null -> - visitor.visitMatrixWithDisplayName(matrixWithDisplayName) - groupedTieredPackage != null -> - visitor.visitGroupedTieredPackage(groupedTieredPackage) - maxGroupTieredPackage != null -> - visitor.visitMaxGroupTieredPackage(maxGroupTieredPackage) - scalableMatrixWithUnitPricing != null -> - visitor.visitScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing) - scalableMatrixWithTieredPricing != null -> - visitor.visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing - ) - cumulativeGroupedBulk != null -> - visitor.visitCumulativeGroupedBulk(cumulativeGroupedBulk) + percentageDiscount != null -> + visitor.visitPercentageDiscount(percentageDiscount) + usageDiscount != null -> visitor.visitUsageDiscount(usageDiscount) + amountDiscount != null -> visitor.visitAmountDiscount(amountDiscount) minimum != null -> visitor.visitMinimum(minimum) - percent != null -> visitor.visitPercent(percent) - eventOutput != null -> visitor.visitEventOutput(eventOutput) + maximum != null -> visitor.visitMaximum(maximum) else -> visitor.unknown(_json) } private var validated: Boolean = false - fun validate(): Price = apply { + fun validate(): Adjustment = apply { if (validated) { return@apply } accept( object : Visitor { - override fun visitUnit(unit: NewSubscriptionUnitPrice) { - unit.validate() - } - - override fun visitTiered(tiered: NewSubscriptionTieredPrice) { - tiered.validate() + override fun visitPercentageDiscount( + percentageDiscount: NewPercentageDiscount + ) { + percentageDiscount.validate() } - override fun visitBulk(bulk: NewSubscriptionBulkPrice) { - bulk.validate() + override fun visitUsageDiscount(usageDiscount: NewUsageDiscount) { + usageDiscount.validate() } - override fun visitBulkWithFilters(bulkWithFilters: BulkWithFilters) { - bulkWithFilters.validate() + override fun visitAmountDiscount(amountDiscount: NewAmountDiscount) { + amountDiscount.validate() } - override fun visitPackage(package_: NewSubscriptionPackagePrice) { - package_.validate() + override fun visitMinimum(minimum: NewMinimum) { + minimum.validate() } - override fun visitMatrix(matrix: NewSubscriptionMatrixPrice) { - matrix.validate() + override fun visitMaximum(maximum: NewMaximum) { + maximum.validate() } + } + ) + validated = true + } - override fun visitThresholdTotalAmount( - thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice - ) { - thresholdTotalAmount.validate() - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - override fun visitTieredPackage( - tieredPackage: NewSubscriptionTieredPackagePrice - ) { - tieredPackage.validate() - } + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitPercentageDiscount( + percentageDiscount: NewPercentageDiscount + ) = percentageDiscount.validity() - override fun visitTieredWithMinimum( - tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice - ) { - tieredWithMinimum.validate() - } + override fun visitUsageDiscount(usageDiscount: NewUsageDiscount) = + usageDiscount.validity() - override fun visitGroupedTiered( - groupedTiered: NewSubscriptionGroupedTieredPrice - ) { - groupedTiered.validate() - } + override fun visitAmountDiscount(amountDiscount: NewAmountDiscount) = + amountDiscount.validity() - override fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice - ) { - tieredPackageWithMinimum.validate() - } + override fun visitMinimum(minimum: NewMinimum) = minimum.validity() - override fun visitPackageWithAllocation( - packageWithAllocation: NewSubscriptionPackageWithAllocationPrice - ) { - packageWithAllocation.validate() - } + override fun visitMaximum(maximum: NewMaximum) = maximum.validity() - override fun visitUnitWithPercent( - unitWithPercent: NewSubscriptionUnitWithPercentPrice - ) { - unitWithPercent.validate() - } + override fun unknown(json: JsonValue?) = 0 + } + ) - override fun visitMatrixWithAllocation( - matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice - ) { - matrixWithAllocation.validate() - } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - override fun visitTieredWithProration( - tieredWithProration: TieredWithProration - ) { - tieredWithProration.validate() - } + return other is Adjustment && + percentageDiscount == other.percentageDiscount && + usageDiscount == other.usageDiscount && + amountDiscount == other.amountDiscount && + minimum == other.minimum && + maximum == other.maximum + } - override fun visitUnitWithProration( - unitWithProration: NewSubscriptionUnitWithProrationPrice - ) { - unitWithProration.validate() - } + override fun hashCode(): Int = + Objects.hash(percentageDiscount, usageDiscount, amountDiscount, minimum, maximum) - override fun visitGroupedAllocation( - groupedAllocation: NewSubscriptionGroupedAllocationPrice - ) { - groupedAllocation.validate() - } - - override fun visitBulkWithProration( - bulkWithProration: NewSubscriptionBulkWithProrationPrice - ) { - bulkWithProration.validate() - } - - override fun visitGroupedWithProratedMinimum( - groupedWithProratedMinimum: - NewSubscriptionGroupedWithProratedMinimumPrice - ) { - groupedWithProratedMinimum.validate() - } - - override fun visitGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice - ) { - groupedWithMeteredMinimum.validate() - } - - override fun visitGroupedWithMinMaxThresholds( - groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds - ) { - groupedWithMinMaxThresholds.validate() - } - - override fun visitMatrixWithDisplayName( - matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice - ) { - matrixWithDisplayName.validate() - } - - override fun visitGroupedTieredPackage( - groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice - ) { - groupedTieredPackage.validate() - } - - override fun visitMaxGroupTieredPackage( - maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice - ) { - maxGroupTieredPackage.validate() - } + override fun toString(): String = + when { + percentageDiscount != null -> + "Adjustment{percentageDiscount=$percentageDiscount}" + usageDiscount != null -> "Adjustment{usageDiscount=$usageDiscount}" + amountDiscount != null -> "Adjustment{amountDiscount=$amountDiscount}" + minimum != null -> "Adjustment{minimum=$minimum}" + maximum != null -> "Adjustment{maximum=$maximum}" + _json != null -> "Adjustment{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Adjustment") + } - override fun visitScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: - NewSubscriptionScalableMatrixWithUnitPricingPrice - ) { - scalableMatrixWithUnitPricing.validate() - } + companion object { - override fun visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: - NewSubscriptionScalableMatrixWithTieredPricingPrice - ) { - scalableMatrixWithTieredPricing.validate() - } + fun ofPercentageDiscount(percentageDiscount: NewPercentageDiscount) = + Adjustment(percentageDiscount = percentageDiscount) - override fun visitCumulativeGroupedBulk( - cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice - ) { - cumulativeGroupedBulk.validate() - } + fun ofUsageDiscount(usageDiscount: NewUsageDiscount) = + Adjustment(usageDiscount = usageDiscount) - override fun visitMinimum(minimum: NewSubscriptionMinimumCompositePrice) { - minimum.validate() - } + fun ofAmountDiscount(amountDiscount: NewAmountDiscount) = + Adjustment(amountDiscount = amountDiscount) - override fun visitPercent(percent: Percent) { - percent.validate() - } + fun ofMinimum(minimum: NewMinimum) = Adjustment(minimum = minimum) - override fun visitEventOutput(eventOutput: EventOutput) { - eventOutput.validate() - } - } - ) - validated = true + fun ofMaximum(maximum: NewMaximum) = Adjustment(maximum = maximum) } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. + * An interface that defines how to map each variant of [Adjustment] to a value of type + * [T]. */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: NewSubscriptionUnitPrice) = unit.validity() - - override fun visitTiered(tiered: NewSubscriptionTieredPrice) = - tiered.validity() - - override fun visitBulk(bulk: NewSubscriptionBulkPrice) = bulk.validity() + interface Visitor { - override fun visitBulkWithFilters(bulkWithFilters: BulkWithFilters) = - bulkWithFilters.validity() + fun visitPercentageDiscount(percentageDiscount: NewPercentageDiscount): T - override fun visitPackage(package_: NewSubscriptionPackagePrice) = - package_.validity() + fun visitUsageDiscount(usageDiscount: NewUsageDiscount): T - override fun visitMatrix(matrix: NewSubscriptionMatrixPrice) = - matrix.validity() + fun visitAmountDiscount(amountDiscount: NewAmountDiscount): T - override fun visitThresholdTotalAmount( - thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice - ) = thresholdTotalAmount.validity() + fun visitMinimum(minimum: NewMinimum): T - override fun visitTieredPackage( - tieredPackage: NewSubscriptionTieredPackagePrice - ) = tieredPackage.validity() + fun visitMaximum(maximum: NewMaximum): T - override fun visitTieredWithMinimum( - tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice - ) = tieredWithMinimum.validity() + /** + * Maps an unknown variant of [Adjustment] to a value of type [T]. + * + * An instance of [Adjustment] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the + * SDK is unaware of. + * + * @throws OrbInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw OrbInvalidDataException("Unknown Adjustment: $json") + } + } - override fun visitGroupedTiered( - groupedTiered: NewSubscriptionGroupedTieredPrice - ) = groupedTiered.validity() + internal class Deserializer : BaseDeserializer(Adjustment::class) { - override fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice - ) = tieredPackageWithMinimum.validity() + override fun ObjectCodec.deserialize(node: JsonNode): Adjustment { + val json = JsonValue.fromJsonNode(node) + val adjustmentType = json.asObject()?.get("adjustment_type")?.asString() - override fun visitPackageWithAllocation( - packageWithAllocation: NewSubscriptionPackageWithAllocationPrice - ) = packageWithAllocation.validity() + when (adjustmentType) { + "percentage_discount" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Adjustment(percentageDiscount = it, _json = json) } + ?: Adjustment(_json = json) + } + "usage_discount" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(usageDiscount = it, _json = json) + } ?: Adjustment(_json = json) + } + "amount_discount" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(amountDiscount = it, _json = json) + } ?: Adjustment(_json = json) + } + "minimum" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(minimum = it, _json = json) + } ?: Adjustment(_json = json) + } + "maximum" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(maximum = it, _json = json) + } ?: Adjustment(_json = json) + } + } - override fun visitUnitWithPercent( - unitWithPercent: NewSubscriptionUnitWithPercentPrice - ) = unitWithPercent.validity() + return Adjustment(_json = json) + } + } - override fun visitMatrixWithAllocation( - matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice - ) = matrixWithAllocation.validity() + internal class Serializer : BaseSerializer(Adjustment::class) { - override fun visitTieredWithProration( - tieredWithProration: TieredWithProration - ) = tieredWithProration.validity() + override fun serialize( + value: Adjustment, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.percentageDiscount != null -> + generator.writeObject(value.percentageDiscount) + value.usageDiscount != null -> generator.writeObject(value.usageDiscount) + value.amountDiscount != null -> generator.writeObject(value.amountDiscount) + value.minimum != null -> generator.writeObject(value.minimum) + value.maximum != null -> generator.writeObject(value.maximum) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Adjustment") + } + } + } + } - override fun visitUnitWithProration( - unitWithProration: NewSubscriptionUnitWithProrationPrice - ) = unitWithProration.validity() + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - override fun visitGroupedAllocation( - groupedAllocation: NewSubscriptionGroupedAllocationPrice - ) = groupedAllocation.validity() + return other is ReplaceAdjustment && + adjustment == other.adjustment && + replacesAdjustmentId == other.replacesAdjustmentId && + additionalProperties == other.additionalProperties + } - override fun visitBulkWithProration( - bulkWithProration: NewSubscriptionBulkWithProrationPrice - ) = bulkWithProration.validity() + private val hashCode: Int by lazy { + Objects.hash(adjustment, replacesAdjustmentId, additionalProperties) + } - override fun visitGroupedWithProratedMinimum( - groupedWithProratedMinimum: - NewSubscriptionGroupedWithProratedMinimumPrice - ) = groupedWithProratedMinimum.validity() + override fun hashCode(): Int = hashCode - override fun visitGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice - ) = groupedWithMeteredMinimum.validity() + override fun toString() = + "ReplaceAdjustment{adjustment=$adjustment, replacesAdjustmentId=$replacesAdjustmentId, additionalProperties=$additionalProperties}" + } - override fun visitGroupedWithMinMaxThresholds( - groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds - ) = groupedWithMinMaxThresholds.validity() + class ReplacePrice + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val replacesPriceId: JsonField, + private val allocationPrice: JsonField, + private val discounts: JsonField>, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val maximumAmount: JsonField, + private val minimumAmount: JsonField, + private val price: JsonField, + private val priceId: JsonField, + private val additionalProperties: MutableMap, + ) { - override fun visitMatrixWithDisplayName( - matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice - ) = matrixWithDisplayName.validity() + @JsonCreator + private constructor( + @JsonProperty("replaces_price_id") + @ExcludeMissing + replacesPriceId: JsonField = JsonMissing.of(), + @JsonProperty("allocation_price") + @ExcludeMissing + allocationPrice: JsonField = JsonMissing.of(), + @JsonProperty("discounts") + @ExcludeMissing + discounts: JsonField> = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("maximum_amount") + @ExcludeMissing + maximumAmount: JsonField = JsonMissing.of(), + @JsonProperty("minimum_amount") + @ExcludeMissing + minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("price") @ExcludeMissing price: JsonField = JsonMissing.of(), + @JsonProperty("price_id") @ExcludeMissing priceId: JsonField = JsonMissing.of(), + ) : this( + replacesPriceId, + allocationPrice, + discounts, + externalPriceId, + fixedPriceQuantity, + maximumAmount, + minimumAmount, + price, + priceId, + mutableMapOf(), + ) - override fun visitGroupedTieredPackage( - groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice - ) = groupedTieredPackage.validity() + /** + * The id of the price on the plan to replace in the subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun replacesPriceId(): String = replacesPriceId.getRequired("replaces_price_id") - override fun visitMaxGroupTieredPackage( - maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice - ) = maxGroupTieredPackage.validity() + /** + * The definition of a new allocation price to create and add to the subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun allocationPrice(): NewAllocationPrice? = allocationPrice.getNullable("allocation_price") - override fun visitScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: - NewSubscriptionScalableMatrixWithUnitPricingPrice - ) = scalableMatrixWithUnitPricing.validity() + /** + * [DEPRECATED] Use add_adjustments instead. The subscription's discounts for the + * replacement price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + @Deprecated("deprecated") + fun discounts(): List? = discounts.getNullable("discounts") - override fun visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: - NewSubscriptionScalableMatrixWithTieredPricingPrice - ) = scalableMatrixWithTieredPricing.validity() + /** + * The external price id of the price to add to the subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") - override fun visitCumulativeGroupedBulk( - cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice - ) = cumulativeGroupedBulk.validity() + /** + * The new quantity of the price, if the price is a fixed price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = fixedPriceQuantity.getNullable("fixed_price_quantity") - override fun visitMinimum(minimum: NewSubscriptionMinimumCompositePrice) = - minimum.validity() + /** + * [DEPRECATED] Use add_adjustments instead. The subscription's maximum amount for the + * replacement price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + @Deprecated("deprecated") + fun maximumAmount(): String? = maximumAmount.getNullable("maximum_amount") - override fun visitPercent(percent: Percent) = percent.validity() + /** + * [DEPRECATED] Use add_adjustments instead. The subscription's minimum amount for the + * replacement price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + @Deprecated("deprecated") + fun minimumAmount(): String? = minimumAmount.getNullable("minimum_amount") - override fun visitEventOutput(eventOutput: EventOutput) = - eventOutput.validity() + /** + * New subscription price request body params. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun price(): Price? = price.getNullable("price") - override fun unknown(json: JsonValue?) = 0 - } - ) + /** + * The id of the price to add to the subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun priceId(): String? = priceId.getNullable("price_id") - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * Returns the raw JSON value of [replacesPriceId]. + * + * Unlike [replacesPriceId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("replaces_price_id") + @ExcludeMissing + fun _replacesPriceId(): JsonField = replacesPriceId - return other is Price && - unit == other.unit && - tiered == other.tiered && - bulk == other.bulk && - bulkWithFilters == other.bulkWithFilters && - package_ == other.package_ && - matrix == other.matrix && - thresholdTotalAmount == other.thresholdTotalAmount && - tieredPackage == other.tieredPackage && - tieredWithMinimum == other.tieredWithMinimum && - groupedTiered == other.groupedTiered && - tieredPackageWithMinimum == other.tieredPackageWithMinimum && - packageWithAllocation == other.packageWithAllocation && - unitWithPercent == other.unitWithPercent && - matrixWithAllocation == other.matrixWithAllocation && - tieredWithProration == other.tieredWithProration && - unitWithProration == other.unitWithProration && - groupedAllocation == other.groupedAllocation && - bulkWithProration == other.bulkWithProration && - groupedWithProratedMinimum == other.groupedWithProratedMinimum && - groupedWithMeteredMinimum == other.groupedWithMeteredMinimum && - groupedWithMinMaxThresholds == other.groupedWithMinMaxThresholds && - matrixWithDisplayName == other.matrixWithDisplayName && - groupedTieredPackage == other.groupedTieredPackage && - maxGroupTieredPackage == other.maxGroupTieredPackage && - scalableMatrixWithUnitPricing == other.scalableMatrixWithUnitPricing && - scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && - cumulativeGroupedBulk == other.cumulativeGroupedBulk && - minimum == other.minimum && - percent == other.percent && - eventOutput == other.eventOutput - } + /** + * Returns the raw JSON value of [allocationPrice]. + * + * Unlike [allocationPrice], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("allocation_price") + @ExcludeMissing + fun _allocationPrice(): JsonField = allocationPrice - override fun hashCode(): Int = - Objects.hash( - unit, - tiered, - bulk, - bulkWithFilters, - package_, - matrix, - thresholdTotalAmount, - tieredPackage, - tieredWithMinimum, - groupedTiered, - tieredPackageWithMinimum, - packageWithAllocation, - unitWithPercent, - matrixWithAllocation, - tieredWithProration, - unitWithProration, - groupedAllocation, - bulkWithProration, - groupedWithProratedMinimum, - groupedWithMeteredMinimum, - groupedWithMinMaxThresholds, - matrixWithDisplayName, - groupedTieredPackage, - maxGroupTieredPackage, - scalableMatrixWithUnitPricing, - scalableMatrixWithTieredPricing, - cumulativeGroupedBulk, - minimum, - percent, - eventOutput, - ) + /** + * Returns the raw JSON value of [discounts]. + * + * Unlike [discounts], this method doesn't throw if the JSON field has an unexpected type. + */ + @Deprecated("deprecated") + @JsonProperty("discounts") + @ExcludeMissing + fun _discounts(): JsonField> = discounts - override fun toString(): String = - when { - unit != null -> "Price{unit=$unit}" - tiered != null -> "Price{tiered=$tiered}" - bulk != null -> "Price{bulk=$bulk}" - bulkWithFilters != null -> "Price{bulkWithFilters=$bulkWithFilters}" - package_ != null -> "Price{package_=$package_}" - matrix != null -> "Price{matrix=$matrix}" - thresholdTotalAmount != null -> - "Price{thresholdTotalAmount=$thresholdTotalAmount}" - tieredPackage != null -> "Price{tieredPackage=$tieredPackage}" - tieredWithMinimum != null -> "Price{tieredWithMinimum=$tieredWithMinimum}" - groupedTiered != null -> "Price{groupedTiered=$groupedTiered}" - tieredPackageWithMinimum != null -> - "Price{tieredPackageWithMinimum=$tieredPackageWithMinimum}" - packageWithAllocation != null -> - "Price{packageWithAllocation=$packageWithAllocation}" - unitWithPercent != null -> "Price{unitWithPercent=$unitWithPercent}" - matrixWithAllocation != null -> - "Price{matrixWithAllocation=$matrixWithAllocation}" - tieredWithProration != null -> "Price{tieredWithProration=$tieredWithProration}" - unitWithProration != null -> "Price{unitWithProration=$unitWithProration}" - groupedAllocation != null -> "Price{groupedAllocation=$groupedAllocation}" - bulkWithProration != null -> "Price{bulkWithProration=$bulkWithProration}" - groupedWithProratedMinimum != null -> - "Price{groupedWithProratedMinimum=$groupedWithProratedMinimum}" - groupedWithMeteredMinimum != null -> - "Price{groupedWithMeteredMinimum=$groupedWithMeteredMinimum}" - groupedWithMinMaxThresholds != null -> - "Price{groupedWithMinMaxThresholds=$groupedWithMinMaxThresholds}" - matrixWithDisplayName != null -> - "Price{matrixWithDisplayName=$matrixWithDisplayName}" - groupedTieredPackage != null -> - "Price{groupedTieredPackage=$groupedTieredPackage}" - maxGroupTieredPackage != null -> - "Price{maxGroupTieredPackage=$maxGroupTieredPackage}" - scalableMatrixWithUnitPricing != null -> - "Price{scalableMatrixWithUnitPricing=$scalableMatrixWithUnitPricing}" - scalableMatrixWithTieredPricing != null -> - "Price{scalableMatrixWithTieredPricing=$scalableMatrixWithTieredPricing}" - cumulativeGroupedBulk != null -> - "Price{cumulativeGroupedBulk=$cumulativeGroupedBulk}" - minimum != null -> "Price{minimum=$minimum}" - percent != null -> "Price{percent=$percent}" - eventOutput != null -> "Price{eventOutput=$eventOutput}" - _json != null -> "Price{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Price") - } - - companion object { + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId - fun ofUnit(unit: NewSubscriptionUnitPrice) = Price(unit = unit) + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - fun ofTiered(tiered: NewSubscriptionTieredPrice) = Price(tiered = tiered) + /** + * Returns the raw JSON value of [maximumAmount]. + * + * Unlike [maximumAmount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @Deprecated("deprecated") + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount - fun ofBulk(bulk: NewSubscriptionBulkPrice) = Price(bulk = bulk) + /** + * Returns the raw JSON value of [minimumAmount]. + * + * Unlike [minimumAmount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @Deprecated("deprecated") + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount - fun ofBulkWithFilters(bulkWithFilters: BulkWithFilters) = - Price(bulkWithFilters = bulkWithFilters) + /** + * Returns the raw JSON value of [price]. + * + * Unlike [price], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("price") @ExcludeMissing fun _price(): JsonField = price - fun ofPackage(package_: NewSubscriptionPackagePrice) = Price(package_ = package_) + /** + * Returns the raw JSON value of [priceId]. + * + * Unlike [priceId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId - fun ofMatrix(matrix: NewSubscriptionMatrixPrice) = Price(matrix = matrix) + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - fun ofThresholdTotalAmount( - thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice - ) = Price(thresholdTotalAmount = thresholdTotalAmount) + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - fun ofTieredPackage(tieredPackage: NewSubscriptionTieredPackagePrice) = - Price(tieredPackage = tieredPackage) + fun toBuilder() = Builder().from(this) - fun ofTieredWithMinimum(tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice) = - Price(tieredWithMinimum = tieredWithMinimum) + companion object { - fun ofGroupedTiered(groupedTiered: NewSubscriptionGroupedTieredPrice) = - Price(groupedTiered = groupedTiered) + /** + * Returns a mutable builder for constructing an instance of [ReplacePrice]. + * + * The following fields are required: + * ```kotlin + * .replacesPriceId() + * ``` + */ + fun builder() = Builder() + } - fun ofTieredPackageWithMinimum( - tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice - ) = Price(tieredPackageWithMinimum = tieredPackageWithMinimum) + /** A builder for [ReplacePrice]. */ + class Builder internal constructor() { - fun ofPackageWithAllocation( - packageWithAllocation: NewSubscriptionPackageWithAllocationPrice - ) = Price(packageWithAllocation = packageWithAllocation) + private var replacesPriceId: JsonField? = null + private var allocationPrice: JsonField = JsonMissing.of() + private var discounts: JsonField>? = null + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var maximumAmount: JsonField = JsonMissing.of() + private var minimumAmount: JsonField = JsonMissing.of() + private var price: JsonField = JsonMissing.of() + private var priceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - fun ofUnitWithPercent(unitWithPercent: NewSubscriptionUnitWithPercentPrice) = - Price(unitWithPercent = unitWithPercent) + internal fun from(replacePrice: ReplacePrice) = apply { + replacesPriceId = replacePrice.replacesPriceId + allocationPrice = replacePrice.allocationPrice + discounts = replacePrice.discounts.map { it.toMutableList() } + externalPriceId = replacePrice.externalPriceId + fixedPriceQuantity = replacePrice.fixedPriceQuantity + maximumAmount = replacePrice.maximumAmount + minimumAmount = replacePrice.minimumAmount + price = replacePrice.price + priceId = replacePrice.priceId + additionalProperties = replacePrice.additionalProperties.toMutableMap() + } - fun ofMatrixWithAllocation( - matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice - ) = Price(matrixWithAllocation = matrixWithAllocation) + /** The id of the price on the plan to replace in the subscription. */ + fun replacesPriceId(replacesPriceId: String) = + replacesPriceId(JsonField.of(replacesPriceId)) - fun ofTieredWithProration(tieredWithProration: TieredWithProration) = - Price(tieredWithProration = tieredWithProration) + /** + * Sets [Builder.replacesPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.replacesPriceId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun replacesPriceId(replacesPriceId: JsonField) = apply { + this.replacesPriceId = replacesPriceId + } - fun ofUnitWithProration(unitWithProration: NewSubscriptionUnitWithProrationPrice) = - Price(unitWithProration = unitWithProration) + /** The definition of a new allocation price to create and add to the subscription. */ + fun allocationPrice(allocationPrice: NewAllocationPrice?) = + allocationPrice(JsonField.ofNullable(allocationPrice)) - fun ofGroupedAllocation(groupedAllocation: NewSubscriptionGroupedAllocationPrice) = - Price(groupedAllocation = groupedAllocation) + /** + * Sets [Builder.allocationPrice] to an arbitrary JSON value. + * + * You should usually call [Builder.allocationPrice] with a well-typed + * [NewAllocationPrice] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun allocationPrice(allocationPrice: JsonField) = apply { + this.allocationPrice = allocationPrice + } - fun ofBulkWithProration(bulkWithProration: NewSubscriptionBulkWithProrationPrice) = - Price(bulkWithProration = bulkWithProration) + /** + * [DEPRECATED] Use add_adjustments instead. The subscription's discounts for the + * replacement price. + */ + @Deprecated("deprecated") + fun discounts(discounts: List?) = + discounts(JsonField.ofNullable(discounts)) - fun ofGroupedWithProratedMinimum( - groupedWithProratedMinimum: NewSubscriptionGroupedWithProratedMinimumPrice - ) = Price(groupedWithProratedMinimum = groupedWithProratedMinimum) + /** + * Sets [Builder.discounts] to an arbitrary JSON value. + * + * You should usually call [Builder.discounts] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + @Deprecated("deprecated") + fun discounts(discounts: JsonField>) = apply { + this.discounts = discounts.map { it.toMutableList() } + } - fun ofGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice - ) = Price(groupedWithMeteredMinimum = groupedWithMeteredMinimum) + /** + * Adds a single [DiscountOverride] to [discounts]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + @Deprecated("deprecated") + fun addDiscount(discount: DiscountOverride) = apply { + discounts = + (discounts ?: JsonField.of(mutableListOf())).also { + checkKnown("discounts", it).add(discount) + } + } - fun ofGroupedWithMinMaxThresholds( - groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds - ) = Price(groupedWithMinMaxThresholds = groupedWithMinMaxThresholds) + /** The external price id of the price to add to the subscription. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) - fun ofMatrixWithDisplayName( - matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice - ) = Price(matrixWithDisplayName = matrixWithDisplayName) + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } - fun ofGroupedTieredPackage( - groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice - ) = Price(groupedTieredPackage = groupedTieredPackage) + /** The new quantity of the price, if the price is a fixed price. */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) - fun ofMaxGroupTieredPackage( - maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice - ) = Price(maxGroupTieredPackage = maxGroupTieredPackage) - - fun ofScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: NewSubscriptionScalableMatrixWithUnitPricingPrice - ) = Price(scalableMatrixWithUnitPricing = scalableMatrixWithUnitPricing) - - fun ofScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: - NewSubscriptionScalableMatrixWithTieredPricingPrice - ) = Price(scalableMatrixWithTieredPricing = scalableMatrixWithTieredPricing) - - fun ofCumulativeGroupedBulk( - cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice - ) = Price(cumulativeGroupedBulk = cumulativeGroupedBulk) + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) - fun ofMinimum(minimum: NewSubscriptionMinimumCompositePrice) = - Price(minimum = minimum) + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } - fun ofPercent(percent: Percent) = Price(percent = percent) + /** + * [DEPRECATED] Use add_adjustments instead. The subscription's maximum amount for the + * replacement price. + */ + @Deprecated("deprecated") + fun maximumAmount(maximumAmount: String?) = + maximumAmount(JsonField.ofNullable(maximumAmount)) - fun ofEventOutput(eventOutput: EventOutput) = Price(eventOutput = eventOutput) + /** + * Sets [Builder.maximumAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.maximumAmount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + @Deprecated("deprecated") + fun maximumAmount(maximumAmount: JsonField) = apply { + this.maximumAmount = maximumAmount } /** - * An interface that defines how to map each variant of [Price] to a value of type [T]. + * [DEPRECATED] Use add_adjustments instead. The subscription's minimum amount for the + * replacement price. */ - interface Visitor { - - fun visitUnit(unit: NewSubscriptionUnitPrice): T + @Deprecated("deprecated") + fun minimumAmount(minimumAmount: String?) = + minimumAmount(JsonField.ofNullable(minimumAmount)) - fun visitTiered(tiered: NewSubscriptionTieredPrice): T + /** + * Sets [Builder.minimumAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumAmount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + @Deprecated("deprecated") + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount + } - fun visitBulk(bulk: NewSubscriptionBulkPrice): T + /** New subscription price request body params. */ + fun price(price: Price?) = price(JsonField.ofNullable(price)) - fun visitBulkWithFilters(bulkWithFilters: BulkWithFilters): T + /** + * Sets [Builder.price] to an arbitrary JSON value. + * + * You should usually call [Builder.price] with a well-typed [Price] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun price(price: JsonField) = apply { this.price = price } - fun visitPackage(package_: NewSubscriptionPackagePrice): T + /** Alias for calling [price] with `Price.ofUnit(unit)`. */ + fun price(unit: NewSubscriptionUnitPrice) = price(Price.ofUnit(unit)) - fun visitMatrix(matrix: NewSubscriptionMatrixPrice): T + /** Alias for calling [price] with `Price.ofTiered(tiered)`. */ + fun price(tiered: NewSubscriptionTieredPrice) = price(Price.ofTiered(tiered)) - fun visitThresholdTotalAmount( - thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice - ): T + /** Alias for calling [price] with `Price.ofBulk(bulk)`. */ + fun price(bulk: NewSubscriptionBulkPrice) = price(Price.ofBulk(bulk)) - fun visitTieredPackage(tieredPackage: NewSubscriptionTieredPackagePrice): T + /** Alias for calling [price] with `Price.ofBulkWithFilters(bulkWithFilters)`. */ + fun price(bulkWithFilters: Price.BulkWithFilters) = + price(Price.ofBulkWithFilters(bulkWithFilters)) - fun visitTieredWithMinimum( - tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice - ): T + /** Alias for calling [price] with `Price.ofPackage(package_)`. */ + fun price(package_: NewSubscriptionPackagePrice) = price(Price.ofPackage(package_)) - fun visitGroupedTiered(groupedTiered: NewSubscriptionGroupedTieredPrice): T + /** Alias for calling [price] with `Price.ofMatrix(matrix)`. */ + fun price(matrix: NewSubscriptionMatrixPrice) = price(Price.ofMatrix(matrix)) - fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice - ): T + /** + * Alias for calling [price] with `Price.ofThresholdTotalAmount(thresholdTotalAmount)`. + */ + fun price(thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice) = + price(Price.ofThresholdTotalAmount(thresholdTotalAmount)) - fun visitPackageWithAllocation( - packageWithAllocation: NewSubscriptionPackageWithAllocationPrice - ): T + /** Alias for calling [price] with `Price.ofTieredPackage(tieredPackage)`. */ + fun price(tieredPackage: NewSubscriptionTieredPackagePrice) = + price(Price.ofTieredPackage(tieredPackage)) - fun visitUnitWithPercent(unitWithPercent: NewSubscriptionUnitWithPercentPrice): T + /** Alias for calling [price] with `Price.ofTieredWithMinimum(tieredWithMinimum)`. */ + fun price(tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice) = + price(Price.ofTieredWithMinimum(tieredWithMinimum)) - fun visitMatrixWithAllocation( - matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice - ): T + /** Alias for calling [price] with `Price.ofGroupedTiered(groupedTiered)`. */ + fun price(groupedTiered: NewSubscriptionGroupedTieredPrice) = + price(Price.ofGroupedTiered(groupedTiered)) - fun visitTieredWithProration(tieredWithProration: TieredWithProration): T + /** + * Alias for calling [price] with + * `Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)`. + */ + fun price(tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice) = + price(Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)) - fun visitUnitWithProration( - unitWithProration: NewSubscriptionUnitWithProrationPrice - ): T + /** + * Alias for calling [price] with + * `Price.ofPackageWithAllocation(packageWithAllocation)`. + */ + fun price(packageWithAllocation: NewSubscriptionPackageWithAllocationPrice) = + price(Price.ofPackageWithAllocation(packageWithAllocation)) - fun visitGroupedAllocation( - groupedAllocation: NewSubscriptionGroupedAllocationPrice - ): T + /** Alias for calling [price] with `Price.ofUnitWithPercent(unitWithPercent)`. */ + fun price(unitWithPercent: NewSubscriptionUnitWithPercentPrice) = + price(Price.ofUnitWithPercent(unitWithPercent)) - fun visitBulkWithProration( - bulkWithProration: NewSubscriptionBulkWithProrationPrice - ): T + /** + * Alias for calling [price] with `Price.ofMatrixWithAllocation(matrixWithAllocation)`. + */ + fun price(matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice) = + price(Price.ofMatrixWithAllocation(matrixWithAllocation)) - fun visitGroupedWithProratedMinimum( - groupedWithProratedMinimum: NewSubscriptionGroupedWithProratedMinimumPrice - ): T + /** + * Alias for calling [price] with `Price.ofTieredWithProration(tieredWithProration)`. + */ + fun price(tieredWithProration: Price.TieredWithProration) = + price(Price.ofTieredWithProration(tieredWithProration)) - fun visitGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice - ): T + /** Alias for calling [price] with `Price.ofUnitWithProration(unitWithProration)`. */ + fun price(unitWithProration: NewSubscriptionUnitWithProrationPrice) = + price(Price.ofUnitWithProration(unitWithProration)) - fun visitGroupedWithMinMaxThresholds( - groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds - ): T + /** Alias for calling [price] with `Price.ofGroupedAllocation(groupedAllocation)`. */ + fun price(groupedAllocation: NewSubscriptionGroupedAllocationPrice) = + price(Price.ofGroupedAllocation(groupedAllocation)) - fun visitMatrixWithDisplayName( - matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice - ): T + /** Alias for calling [price] with `Price.ofBulkWithProration(bulkWithProration)`. */ + fun price(bulkWithProration: NewSubscriptionBulkWithProrationPrice) = + price(Price.ofBulkWithProration(bulkWithProration)) - fun visitGroupedTieredPackage( - groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice - ): T + /** + * Alias for calling [price] with + * `Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)`. + */ + fun price(groupedWithProratedMinimum: NewSubscriptionGroupedWithProratedMinimumPrice) = + price(Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)) - fun visitMaxGroupTieredPackage( - maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice - ): T + /** + * Alias for calling [price] with + * `Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)`. + */ + fun price(groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice) = + price(Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)) - fun visitScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: NewSubscriptionScalableMatrixWithUnitPricingPrice - ): T + /** + * Alias for calling [price] with + * `Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)`. + */ + fun price(groupedWithMinMaxThresholds: Price.GroupedWithMinMaxThresholds) = + price(Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)) - fun visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: - NewSubscriptionScalableMatrixWithTieredPricingPrice - ): T + /** + * Alias for calling [price] with + * `Price.ofMatrixWithDisplayName(matrixWithDisplayName)`. + */ + fun price(matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice) = + price(Price.ofMatrixWithDisplayName(matrixWithDisplayName)) - fun visitCumulativeGroupedBulk( - cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice - ): T + /** + * Alias for calling [price] with `Price.ofGroupedTieredPackage(groupedTieredPackage)`. + */ + fun price(groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice) = + price(Price.ofGroupedTieredPackage(groupedTieredPackage)) - fun visitMinimum(minimum: NewSubscriptionMinimumCompositePrice): T + /** + * Alias for calling [price] with + * `Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)`. + */ + fun price(maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice) = + price(Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)) - fun visitPercent(percent: Percent): T + /** + * Alias for calling [price] with + * `Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)`. + */ + fun price( + scalableMatrixWithUnitPricing: NewSubscriptionScalableMatrixWithUnitPricingPrice + ) = price(Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)) - fun visitEventOutput(eventOutput: EventOutput): T + /** + * Alias for calling [price] with + * `Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)`. + */ + fun price( + scalableMatrixWithTieredPricing: NewSubscriptionScalableMatrixWithTieredPricingPrice + ) = price(Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)) - /** - * Maps an unknown variant of [Price] to a value of type [T]. - * - * An instance of [Price] can contain an unknown variant if it was deserialized from - * data that doesn't match any known variant. For example, if the SDK is on an older - * version than the API, then the API may respond with new variants that the SDK is - * unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown Price: $json") - } + /** + * Alias for calling [price] with + * `Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)`. + */ + fun price(cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice) = + price(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) + + /** + * Alias for calling [price] with + * `Price.ofCumulativeGroupedAllocation(cumulativeGroupedAllocation)`. + */ + fun price(cumulativeGroupedAllocation: Price.CumulativeGroupedAllocation) = + price(Price.ofCumulativeGroupedAllocation(cumulativeGroupedAllocation)) + + /** Alias for calling [price] with `Price.ofMinimum(minimum)`. */ + fun price(minimum: NewSubscriptionMinimumCompositePrice) = + price(Price.ofMinimum(minimum)) + + /** Alias for calling [price] with `Price.ofPercent(percent)`. */ + fun price(percent: Price.Percent) = price(Price.ofPercent(percent)) + + /** Alias for calling [price] with `Price.ofEventOutput(eventOutput)`. */ + fun price(eventOutput: Price.EventOutput) = price(Price.ofEventOutput(eventOutput)) + + /** The id of the price to add to the subscription. */ + fun priceId(priceId: String?) = priceId(JsonField.ofNullable(priceId)) + + /** + * Sets [Builder.priceId] to an arbitrary JSON value. + * + * You should usually call [Builder.priceId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun priceId(priceId: JsonField) = apply { this.priceId = priceId } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ReplacePrice]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .replacesPriceId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ReplacePrice = + ReplacePrice( + checkRequired("replacesPriceId", replacesPriceId), + allocationPrice, + (discounts ?: JsonMissing.of()).map { it.toImmutable() }, + externalPriceId, + fixedPriceQuantity, + maximumAmount, + minimumAmount, + price, + priceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ReplacePrice = apply { + if (validated) { + return@apply + } + + replacesPriceId() + allocationPrice()?.validate() + discounts()?.forEach { it.validate() } + externalPriceId() + fixedPriceQuantity() + maximumAmount() + minimumAmount() + price()?.validate() + priceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false } - internal class Deserializer : BaseDeserializer(Price::class) { + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (replacesPriceId.asKnown() == null) 0 else 1) + + (allocationPrice.asKnown()?.validity() ?: 0) + + (discounts.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (maximumAmount.asKnown() == null) 0 else 1) + + (if (minimumAmount.asKnown() == null) 0 else 1) + + (price.asKnown()?.validity() ?: 0) + + (if (priceId.asKnown() == null) 0 else 1) + + /** New subscription price request body params. */ + @JsonDeserialize(using = Price.Deserializer::class) + @JsonSerialize(using = Price.Serializer::class) + class Price + private constructor( + private val unit: NewSubscriptionUnitPrice? = null, + private val tiered: NewSubscriptionTieredPrice? = null, + private val bulk: NewSubscriptionBulkPrice? = null, + private val bulkWithFilters: BulkWithFilters? = null, + private val package_: NewSubscriptionPackagePrice? = null, + private val matrix: NewSubscriptionMatrixPrice? = null, + private val thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice? = null, + private val tieredPackage: NewSubscriptionTieredPackagePrice? = null, + private val tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice? = null, + private val groupedTiered: NewSubscriptionGroupedTieredPrice? = null, + private val tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice? = + null, + private val packageWithAllocation: NewSubscriptionPackageWithAllocationPrice? = null, + private val unitWithPercent: NewSubscriptionUnitWithPercentPrice? = null, + private val matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice? = null, + private val tieredWithProration: TieredWithProration? = null, + private val unitWithProration: NewSubscriptionUnitWithProrationPrice? = null, + private val groupedAllocation: NewSubscriptionGroupedAllocationPrice? = null, + private val bulkWithProration: NewSubscriptionBulkWithProrationPrice? = null, + private val groupedWithProratedMinimum: + NewSubscriptionGroupedWithProratedMinimumPrice? = + null, + private val groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice? = + null, + private val groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds? = null, + private val matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice? = null, + private val groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice? = null, + private val maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice? = null, + private val scalableMatrixWithUnitPricing: + NewSubscriptionScalableMatrixWithUnitPricingPrice? = + null, + private val scalableMatrixWithTieredPricing: + NewSubscriptionScalableMatrixWithTieredPricingPrice? = + null, + private val cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice? = null, + private val cumulativeGroupedAllocation: CumulativeGroupedAllocation? = null, + private val minimum: NewSubscriptionMinimumCompositePrice? = null, + private val percent: Percent? = null, + private val eventOutput: EventOutput? = null, + private val _json: JsonValue? = null, + ) { + + fun unit(): NewSubscriptionUnitPrice? = unit + + fun tiered(): NewSubscriptionTieredPrice? = tiered + + fun bulk(): NewSubscriptionBulkPrice? = bulk + + fun bulkWithFilters(): BulkWithFilters? = bulkWithFilters + + fun package_(): NewSubscriptionPackagePrice? = package_ + + fun matrix(): NewSubscriptionMatrixPrice? = matrix + + fun thresholdTotalAmount(): NewSubscriptionThresholdTotalAmountPrice? = + thresholdTotalAmount + + fun tieredPackage(): NewSubscriptionTieredPackagePrice? = tieredPackage + + fun tieredWithMinimum(): NewSubscriptionTieredWithMinimumPrice? = tieredWithMinimum + + fun groupedTiered(): NewSubscriptionGroupedTieredPrice? = groupedTiered + + fun tieredPackageWithMinimum(): NewSubscriptionTieredPackageWithMinimumPrice? = + tieredPackageWithMinimum + + fun packageWithAllocation(): NewSubscriptionPackageWithAllocationPrice? = + packageWithAllocation + + fun unitWithPercent(): NewSubscriptionUnitWithPercentPrice? = unitWithPercent + + fun matrixWithAllocation(): NewSubscriptionMatrixWithAllocationPrice? = + matrixWithAllocation + + fun tieredWithProration(): TieredWithProration? = tieredWithProration + + fun unitWithProration(): NewSubscriptionUnitWithProrationPrice? = unitWithProration + + fun groupedAllocation(): NewSubscriptionGroupedAllocationPrice? = groupedAllocation + + fun bulkWithProration(): NewSubscriptionBulkWithProrationPrice? = bulkWithProration + + fun groupedWithProratedMinimum(): NewSubscriptionGroupedWithProratedMinimumPrice? = + groupedWithProratedMinimum + + fun groupedWithMeteredMinimum(): NewSubscriptionGroupedWithMeteredMinimumPrice? = + groupedWithMeteredMinimum + + fun groupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds? = + groupedWithMinMaxThresholds + + fun matrixWithDisplayName(): NewSubscriptionMatrixWithDisplayNamePrice? = + matrixWithDisplayName + + fun groupedTieredPackage(): NewSubscriptionGroupedTieredPackagePrice? = + groupedTieredPackage + + fun maxGroupTieredPackage(): NewSubscriptionMaxGroupTieredPackagePrice? = + maxGroupTieredPackage + + fun scalableMatrixWithUnitPricing(): + NewSubscriptionScalableMatrixWithUnitPricingPrice? = scalableMatrixWithUnitPricing + + fun scalableMatrixWithTieredPricing(): + NewSubscriptionScalableMatrixWithTieredPricingPrice? = + scalableMatrixWithTieredPricing + + fun cumulativeGroupedBulk(): NewSubscriptionCumulativeGroupedBulkPrice? = + cumulativeGroupedBulk + + fun cumulativeGroupedAllocation(): CumulativeGroupedAllocation? = + cumulativeGroupedAllocation + + fun minimum(): NewSubscriptionMinimumCompositePrice? = minimum + + fun percent(): Percent? = percent + + fun eventOutput(): EventOutput? = eventOutput + + fun isUnit(): Boolean = unit != null + + fun isTiered(): Boolean = tiered != null + + fun isBulk(): Boolean = bulk != null + + fun isBulkWithFilters(): Boolean = bulkWithFilters != null + + fun isPackage(): Boolean = package_ != null + + fun isMatrix(): Boolean = matrix != null + + fun isThresholdTotalAmount(): Boolean = thresholdTotalAmount != null + + fun isTieredPackage(): Boolean = tieredPackage != null + + fun isTieredWithMinimum(): Boolean = tieredWithMinimum != null + + fun isGroupedTiered(): Boolean = groupedTiered != null + + fun isTieredPackageWithMinimum(): Boolean = tieredPackageWithMinimum != null + + fun isPackageWithAllocation(): Boolean = packageWithAllocation != null + + fun isUnitWithPercent(): Boolean = unitWithPercent != null + + fun isMatrixWithAllocation(): Boolean = matrixWithAllocation != null + + fun isTieredWithProration(): Boolean = tieredWithProration != null + + fun isUnitWithProration(): Boolean = unitWithProration != null + + fun isGroupedAllocation(): Boolean = groupedAllocation != null + + fun isBulkWithProration(): Boolean = bulkWithProration != null + + fun isGroupedWithProratedMinimum(): Boolean = groupedWithProratedMinimum != null + + fun isGroupedWithMeteredMinimum(): Boolean = groupedWithMeteredMinimum != null + + fun isGroupedWithMinMaxThresholds(): Boolean = groupedWithMinMaxThresholds != null + + fun isMatrixWithDisplayName(): Boolean = matrixWithDisplayName != null + + fun isGroupedTieredPackage(): Boolean = groupedTieredPackage != null + + fun isMaxGroupTieredPackage(): Boolean = maxGroupTieredPackage != null + + fun isScalableMatrixWithUnitPricing(): Boolean = scalableMatrixWithUnitPricing != null + + fun isScalableMatrixWithTieredPricing(): Boolean = + scalableMatrixWithTieredPricing != null + + fun isCumulativeGroupedBulk(): Boolean = cumulativeGroupedBulk != null + + fun isCumulativeGroupedAllocation(): Boolean = cumulativeGroupedAllocation != null + + fun isMinimum(): Boolean = minimum != null + + fun isPercent(): Boolean = percent != null + + fun isEventOutput(): Boolean = eventOutput != null + + fun asUnit(): NewSubscriptionUnitPrice = unit.getOrThrow("unit") + + fun asTiered(): NewSubscriptionTieredPrice = tiered.getOrThrow("tiered") + + fun asBulk(): NewSubscriptionBulkPrice = bulk.getOrThrow("bulk") + + fun asBulkWithFilters(): BulkWithFilters = bulkWithFilters.getOrThrow("bulkWithFilters") + + fun asPackage(): NewSubscriptionPackagePrice = package_.getOrThrow("package_") + + fun asMatrix(): NewSubscriptionMatrixPrice = matrix.getOrThrow("matrix") + + fun asThresholdTotalAmount(): NewSubscriptionThresholdTotalAmountPrice = + thresholdTotalAmount.getOrThrow("thresholdTotalAmount") + + fun asTieredPackage(): NewSubscriptionTieredPackagePrice = + tieredPackage.getOrThrow("tieredPackage") + + fun asTieredWithMinimum(): NewSubscriptionTieredWithMinimumPrice = + tieredWithMinimum.getOrThrow("tieredWithMinimum") + + fun asGroupedTiered(): NewSubscriptionGroupedTieredPrice = + groupedTiered.getOrThrow("groupedTiered") + + fun asTieredPackageWithMinimum(): NewSubscriptionTieredPackageWithMinimumPrice = + tieredPackageWithMinimum.getOrThrow("tieredPackageWithMinimum") + + fun asPackageWithAllocation(): NewSubscriptionPackageWithAllocationPrice = + packageWithAllocation.getOrThrow("packageWithAllocation") + + fun asUnitWithPercent(): NewSubscriptionUnitWithPercentPrice = + unitWithPercent.getOrThrow("unitWithPercent") + + fun asMatrixWithAllocation(): NewSubscriptionMatrixWithAllocationPrice = + matrixWithAllocation.getOrThrow("matrixWithAllocation") + + fun asTieredWithProration(): TieredWithProration = + tieredWithProration.getOrThrow("tieredWithProration") + + fun asUnitWithProration(): NewSubscriptionUnitWithProrationPrice = + unitWithProration.getOrThrow("unitWithProration") + + fun asGroupedAllocation(): NewSubscriptionGroupedAllocationPrice = + groupedAllocation.getOrThrow("groupedAllocation") + + fun asBulkWithProration(): NewSubscriptionBulkWithProrationPrice = + bulkWithProration.getOrThrow("bulkWithProration") + + fun asGroupedWithProratedMinimum(): NewSubscriptionGroupedWithProratedMinimumPrice = + groupedWithProratedMinimum.getOrThrow("groupedWithProratedMinimum") + + fun asGroupedWithMeteredMinimum(): NewSubscriptionGroupedWithMeteredMinimumPrice = + groupedWithMeteredMinimum.getOrThrow("groupedWithMeteredMinimum") + + fun asGroupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds = + groupedWithMinMaxThresholds.getOrThrow("groupedWithMinMaxThresholds") + + fun asMatrixWithDisplayName(): NewSubscriptionMatrixWithDisplayNamePrice = + matrixWithDisplayName.getOrThrow("matrixWithDisplayName") + + fun asGroupedTieredPackage(): NewSubscriptionGroupedTieredPackagePrice = + groupedTieredPackage.getOrThrow("groupedTieredPackage") + + fun asMaxGroupTieredPackage(): NewSubscriptionMaxGroupTieredPackagePrice = + maxGroupTieredPackage.getOrThrow("maxGroupTieredPackage") + + fun asScalableMatrixWithUnitPricing(): + NewSubscriptionScalableMatrixWithUnitPricingPrice = + scalableMatrixWithUnitPricing.getOrThrow("scalableMatrixWithUnitPricing") + + fun asScalableMatrixWithTieredPricing(): + NewSubscriptionScalableMatrixWithTieredPricingPrice = + scalableMatrixWithTieredPricing.getOrThrow("scalableMatrixWithTieredPricing") + + fun asCumulativeGroupedBulk(): NewSubscriptionCumulativeGroupedBulkPrice = + cumulativeGroupedBulk.getOrThrow("cumulativeGroupedBulk") + + fun asCumulativeGroupedAllocation(): CumulativeGroupedAllocation = + cumulativeGroupedAllocation.getOrThrow("cumulativeGroupedAllocation") + + fun asMinimum(): NewSubscriptionMinimumCompositePrice = minimum.getOrThrow("minimum") + + fun asPercent(): Percent = percent.getOrThrow("percent") + + fun asEventOutput(): EventOutput = eventOutput.getOrThrow("eventOutput") + + fun _json(): JsonValue? = _json + + fun accept(visitor: Visitor): T = + when { + unit != null -> visitor.visitUnit(unit) + tiered != null -> visitor.visitTiered(tiered) + bulk != null -> visitor.visitBulk(bulk) + bulkWithFilters != null -> visitor.visitBulkWithFilters(bulkWithFilters) + package_ != null -> visitor.visitPackage(package_) + matrix != null -> visitor.visitMatrix(matrix) + thresholdTotalAmount != null -> + visitor.visitThresholdTotalAmount(thresholdTotalAmount) + tieredPackage != null -> visitor.visitTieredPackage(tieredPackage) + tieredWithMinimum != null -> visitor.visitTieredWithMinimum(tieredWithMinimum) + groupedTiered != null -> visitor.visitGroupedTiered(groupedTiered) + tieredPackageWithMinimum != null -> + visitor.visitTieredPackageWithMinimum(tieredPackageWithMinimum) + packageWithAllocation != null -> + visitor.visitPackageWithAllocation(packageWithAllocation) + unitWithPercent != null -> visitor.visitUnitWithPercent(unitWithPercent) + matrixWithAllocation != null -> + visitor.visitMatrixWithAllocation(matrixWithAllocation) + tieredWithProration != null -> + visitor.visitTieredWithProration(tieredWithProration) + unitWithProration != null -> visitor.visitUnitWithProration(unitWithProration) + groupedAllocation != null -> visitor.visitGroupedAllocation(groupedAllocation) + bulkWithProration != null -> visitor.visitBulkWithProration(bulkWithProration) + groupedWithProratedMinimum != null -> + visitor.visitGroupedWithProratedMinimum(groupedWithProratedMinimum) + groupedWithMeteredMinimum != null -> + visitor.visitGroupedWithMeteredMinimum(groupedWithMeteredMinimum) + groupedWithMinMaxThresholds != null -> + visitor.visitGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds) + matrixWithDisplayName != null -> + visitor.visitMatrixWithDisplayName(matrixWithDisplayName) + groupedTieredPackage != null -> + visitor.visitGroupedTieredPackage(groupedTieredPackage) + maxGroupTieredPackage != null -> + visitor.visitMaxGroupTieredPackage(maxGroupTieredPackage) + scalableMatrixWithUnitPricing != null -> + visitor.visitScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing) + scalableMatrixWithTieredPricing != null -> + visitor.visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing + ) + cumulativeGroupedBulk != null -> + visitor.visitCumulativeGroupedBulk(cumulativeGroupedBulk) + cumulativeGroupedAllocation != null -> + visitor.visitCumulativeGroupedAllocation(cumulativeGroupedAllocation) + minimum != null -> visitor.visitMinimum(minimum) + percent != null -> visitor.visitPercent(percent) + eventOutput != null -> visitor.visitEventOutput(eventOutput) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Price = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitUnit(unit: NewSubscriptionUnitPrice) { + unit.validate() + } + + override fun visitTiered(tiered: NewSubscriptionTieredPrice) { + tiered.validate() + } + + override fun visitBulk(bulk: NewSubscriptionBulkPrice) { + bulk.validate() + } + + override fun visitBulkWithFilters(bulkWithFilters: BulkWithFilters) { + bulkWithFilters.validate() + } + + override fun visitPackage(package_: NewSubscriptionPackagePrice) { + package_.validate() + } + + override fun visitMatrix(matrix: NewSubscriptionMatrixPrice) { + matrix.validate() + } + + override fun visitThresholdTotalAmount( + thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice + ) { + thresholdTotalAmount.validate() + } + + override fun visitTieredPackage( + tieredPackage: NewSubscriptionTieredPackagePrice + ) { + tieredPackage.validate() + } + + override fun visitTieredWithMinimum( + tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice + ) { + tieredWithMinimum.validate() + } + + override fun visitGroupedTiered( + groupedTiered: NewSubscriptionGroupedTieredPrice + ) { + groupedTiered.validate() + } + + override fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice + ) { + tieredPackageWithMinimum.validate() + } + + override fun visitPackageWithAllocation( + packageWithAllocation: NewSubscriptionPackageWithAllocationPrice + ) { + packageWithAllocation.validate() + } + + override fun visitUnitWithPercent( + unitWithPercent: NewSubscriptionUnitWithPercentPrice + ) { + unitWithPercent.validate() + } + + override fun visitMatrixWithAllocation( + matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice + ) { + matrixWithAllocation.validate() + } + + override fun visitTieredWithProration( + tieredWithProration: TieredWithProration + ) { + tieredWithProration.validate() + } + + override fun visitUnitWithProration( + unitWithProration: NewSubscriptionUnitWithProrationPrice + ) { + unitWithProration.validate() + } + + override fun visitGroupedAllocation( + groupedAllocation: NewSubscriptionGroupedAllocationPrice + ) { + groupedAllocation.validate() + } + + override fun visitBulkWithProration( + bulkWithProration: NewSubscriptionBulkWithProrationPrice + ) { + bulkWithProration.validate() + } + + override fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: + NewSubscriptionGroupedWithProratedMinimumPrice + ) { + groupedWithProratedMinimum.validate() + } + + override fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice + ) { + groupedWithMeteredMinimum.validate() + } + + override fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) { + groupedWithMinMaxThresholds.validate() + } + + override fun visitMatrixWithDisplayName( + matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice + ) { + matrixWithDisplayName.validate() + } + + override fun visitGroupedTieredPackage( + groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice + ) { + groupedTieredPackage.validate() + } + + override fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice + ) { + maxGroupTieredPackage.validate() + } + + override fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: + NewSubscriptionScalableMatrixWithUnitPricingPrice + ) { + scalableMatrixWithUnitPricing.validate() + } + + override fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: + NewSubscriptionScalableMatrixWithTieredPricingPrice + ) { + scalableMatrixWithTieredPricing.validate() + } + + override fun visitCumulativeGroupedBulk( + cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice + ) { + cumulativeGroupedBulk.validate() + } + + override fun visitCumulativeGroupedAllocation( + cumulativeGroupedAllocation: CumulativeGroupedAllocation + ) { + cumulativeGroupedAllocation.validate() + } + + override fun visitMinimum(minimum: NewSubscriptionMinimumCompositePrice) { + minimum.validate() + } + + override fun visitPercent(percent: Percent) { + percent.validate() + } + + override fun visitEventOutput(eventOutput: EventOutput) { + eventOutput.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitUnit(unit: NewSubscriptionUnitPrice) = unit.validity() + + override fun visitTiered(tiered: NewSubscriptionTieredPrice) = + tiered.validity() + + override fun visitBulk(bulk: NewSubscriptionBulkPrice) = bulk.validity() + + override fun visitBulkWithFilters(bulkWithFilters: BulkWithFilters) = + bulkWithFilters.validity() + + override fun visitPackage(package_: NewSubscriptionPackagePrice) = + package_.validity() + + override fun visitMatrix(matrix: NewSubscriptionMatrixPrice) = + matrix.validity() + + override fun visitThresholdTotalAmount( + thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice + ) = thresholdTotalAmount.validity() + + override fun visitTieredPackage( + tieredPackage: NewSubscriptionTieredPackagePrice + ) = tieredPackage.validity() + + override fun visitTieredWithMinimum( + tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice + ) = tieredWithMinimum.validity() + + override fun visitGroupedTiered( + groupedTiered: NewSubscriptionGroupedTieredPrice + ) = groupedTiered.validity() + + override fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice + ) = tieredPackageWithMinimum.validity() + + override fun visitPackageWithAllocation( + packageWithAllocation: NewSubscriptionPackageWithAllocationPrice + ) = packageWithAllocation.validity() + + override fun visitUnitWithPercent( + unitWithPercent: NewSubscriptionUnitWithPercentPrice + ) = unitWithPercent.validity() + + override fun visitMatrixWithAllocation( + matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice + ) = matrixWithAllocation.validity() + + override fun visitTieredWithProration( + tieredWithProration: TieredWithProration + ) = tieredWithProration.validity() + + override fun visitUnitWithProration( + unitWithProration: NewSubscriptionUnitWithProrationPrice + ) = unitWithProration.validity() + + override fun visitGroupedAllocation( + groupedAllocation: NewSubscriptionGroupedAllocationPrice + ) = groupedAllocation.validity() + + override fun visitBulkWithProration( + bulkWithProration: NewSubscriptionBulkWithProrationPrice + ) = bulkWithProration.validity() + + override fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: + NewSubscriptionGroupedWithProratedMinimumPrice + ) = groupedWithProratedMinimum.validity() + + override fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice + ) = groupedWithMeteredMinimum.validity() + + override fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) = groupedWithMinMaxThresholds.validity() + + override fun visitMatrixWithDisplayName( + matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice + ) = matrixWithDisplayName.validity() + + override fun visitGroupedTieredPackage( + groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice + ) = groupedTieredPackage.validity() + + override fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice + ) = maxGroupTieredPackage.validity() + + override fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: + NewSubscriptionScalableMatrixWithUnitPricingPrice + ) = scalableMatrixWithUnitPricing.validity() + + override fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: + NewSubscriptionScalableMatrixWithTieredPricingPrice + ) = scalableMatrixWithTieredPricing.validity() + + override fun visitCumulativeGroupedBulk( + cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice + ) = cumulativeGroupedBulk.validity() + + override fun visitCumulativeGroupedAllocation( + cumulativeGroupedAllocation: CumulativeGroupedAllocation + ) = cumulativeGroupedAllocation.validity() + + override fun visitMinimum(minimum: NewSubscriptionMinimumCompositePrice) = + minimum.validity() + + override fun visitPercent(percent: Percent) = percent.validity() + + override fun visitEventOutput(eventOutput: EventOutput) = + eventOutput.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Price && + unit == other.unit && + tiered == other.tiered && + bulk == other.bulk && + bulkWithFilters == other.bulkWithFilters && + package_ == other.package_ && + matrix == other.matrix && + thresholdTotalAmount == other.thresholdTotalAmount && + tieredPackage == other.tieredPackage && + tieredWithMinimum == other.tieredWithMinimum && + groupedTiered == other.groupedTiered && + tieredPackageWithMinimum == other.tieredPackageWithMinimum && + packageWithAllocation == other.packageWithAllocation && + unitWithPercent == other.unitWithPercent && + matrixWithAllocation == other.matrixWithAllocation && + tieredWithProration == other.tieredWithProration && + unitWithProration == other.unitWithProration && + groupedAllocation == other.groupedAllocation && + bulkWithProration == other.bulkWithProration && + groupedWithProratedMinimum == other.groupedWithProratedMinimum && + groupedWithMeteredMinimum == other.groupedWithMeteredMinimum && + groupedWithMinMaxThresholds == other.groupedWithMinMaxThresholds && + matrixWithDisplayName == other.matrixWithDisplayName && + groupedTieredPackage == other.groupedTieredPackage && + maxGroupTieredPackage == other.maxGroupTieredPackage && + scalableMatrixWithUnitPricing == other.scalableMatrixWithUnitPricing && + scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && + cumulativeGroupedBulk == other.cumulativeGroupedBulk && + cumulativeGroupedAllocation == other.cumulativeGroupedAllocation && + minimum == other.minimum && + percent == other.percent && + eventOutput == other.eventOutput + } + + override fun hashCode(): Int = + Objects.hash( + unit, + tiered, + bulk, + bulkWithFilters, + package_, + matrix, + thresholdTotalAmount, + tieredPackage, + tieredWithMinimum, + groupedTiered, + tieredPackageWithMinimum, + packageWithAllocation, + unitWithPercent, + matrixWithAllocation, + tieredWithProration, + unitWithProration, + groupedAllocation, + bulkWithProration, + groupedWithProratedMinimum, + groupedWithMeteredMinimum, + groupedWithMinMaxThresholds, + matrixWithDisplayName, + groupedTieredPackage, + maxGroupTieredPackage, + scalableMatrixWithUnitPricing, + scalableMatrixWithTieredPricing, + cumulativeGroupedBulk, + cumulativeGroupedAllocation, + minimum, + percent, + eventOutput, + ) + + override fun toString(): String = + when { + unit != null -> "Price{unit=$unit}" + tiered != null -> "Price{tiered=$tiered}" + bulk != null -> "Price{bulk=$bulk}" + bulkWithFilters != null -> "Price{bulkWithFilters=$bulkWithFilters}" + package_ != null -> "Price{package_=$package_}" + matrix != null -> "Price{matrix=$matrix}" + thresholdTotalAmount != null -> + "Price{thresholdTotalAmount=$thresholdTotalAmount}" + tieredPackage != null -> "Price{tieredPackage=$tieredPackage}" + tieredWithMinimum != null -> "Price{tieredWithMinimum=$tieredWithMinimum}" + groupedTiered != null -> "Price{groupedTiered=$groupedTiered}" + tieredPackageWithMinimum != null -> + "Price{tieredPackageWithMinimum=$tieredPackageWithMinimum}" + packageWithAllocation != null -> + "Price{packageWithAllocation=$packageWithAllocation}" + unitWithPercent != null -> "Price{unitWithPercent=$unitWithPercent}" + matrixWithAllocation != null -> + "Price{matrixWithAllocation=$matrixWithAllocation}" + tieredWithProration != null -> "Price{tieredWithProration=$tieredWithProration}" + unitWithProration != null -> "Price{unitWithProration=$unitWithProration}" + groupedAllocation != null -> "Price{groupedAllocation=$groupedAllocation}" + bulkWithProration != null -> "Price{bulkWithProration=$bulkWithProration}" + groupedWithProratedMinimum != null -> + "Price{groupedWithProratedMinimum=$groupedWithProratedMinimum}" + groupedWithMeteredMinimum != null -> + "Price{groupedWithMeteredMinimum=$groupedWithMeteredMinimum}" + groupedWithMinMaxThresholds != null -> + "Price{groupedWithMinMaxThresholds=$groupedWithMinMaxThresholds}" + matrixWithDisplayName != null -> + "Price{matrixWithDisplayName=$matrixWithDisplayName}" + groupedTieredPackage != null -> + "Price{groupedTieredPackage=$groupedTieredPackage}" + maxGroupTieredPackage != null -> + "Price{maxGroupTieredPackage=$maxGroupTieredPackage}" + scalableMatrixWithUnitPricing != null -> + "Price{scalableMatrixWithUnitPricing=$scalableMatrixWithUnitPricing}" + scalableMatrixWithTieredPricing != null -> + "Price{scalableMatrixWithTieredPricing=$scalableMatrixWithTieredPricing}" + cumulativeGroupedBulk != null -> + "Price{cumulativeGroupedBulk=$cumulativeGroupedBulk}" + cumulativeGroupedAllocation != null -> + "Price{cumulativeGroupedAllocation=$cumulativeGroupedAllocation}" + minimum != null -> "Price{minimum=$minimum}" + percent != null -> "Price{percent=$percent}" + eventOutput != null -> "Price{eventOutput=$eventOutput}" + _json != null -> "Price{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Price") + } + + companion object { + + fun ofUnit(unit: NewSubscriptionUnitPrice) = Price(unit = unit) + + fun ofTiered(tiered: NewSubscriptionTieredPrice) = Price(tiered = tiered) + + fun ofBulk(bulk: NewSubscriptionBulkPrice) = Price(bulk = bulk) + + fun ofBulkWithFilters(bulkWithFilters: BulkWithFilters) = + Price(bulkWithFilters = bulkWithFilters) + + fun ofPackage(package_: NewSubscriptionPackagePrice) = Price(package_ = package_) + + fun ofMatrix(matrix: NewSubscriptionMatrixPrice) = Price(matrix = matrix) + + fun ofThresholdTotalAmount( + thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice + ) = Price(thresholdTotalAmount = thresholdTotalAmount) + + fun ofTieredPackage(tieredPackage: NewSubscriptionTieredPackagePrice) = + Price(tieredPackage = tieredPackage) + + fun ofTieredWithMinimum(tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice) = + Price(tieredWithMinimum = tieredWithMinimum) + + fun ofGroupedTiered(groupedTiered: NewSubscriptionGroupedTieredPrice) = + Price(groupedTiered = groupedTiered) + + fun ofTieredPackageWithMinimum( + tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice + ) = Price(tieredPackageWithMinimum = tieredPackageWithMinimum) + + fun ofPackageWithAllocation( + packageWithAllocation: NewSubscriptionPackageWithAllocationPrice + ) = Price(packageWithAllocation = packageWithAllocation) + + fun ofUnitWithPercent(unitWithPercent: NewSubscriptionUnitWithPercentPrice) = + Price(unitWithPercent = unitWithPercent) + + fun ofMatrixWithAllocation( + matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice + ) = Price(matrixWithAllocation = matrixWithAllocation) + + fun ofTieredWithProration(tieredWithProration: TieredWithProration) = + Price(tieredWithProration = tieredWithProration) + + fun ofUnitWithProration(unitWithProration: NewSubscriptionUnitWithProrationPrice) = + Price(unitWithProration = unitWithProration) + + fun ofGroupedAllocation(groupedAllocation: NewSubscriptionGroupedAllocationPrice) = + Price(groupedAllocation = groupedAllocation) + + fun ofBulkWithProration(bulkWithProration: NewSubscriptionBulkWithProrationPrice) = + Price(bulkWithProration = bulkWithProration) + + fun ofGroupedWithProratedMinimum( + groupedWithProratedMinimum: NewSubscriptionGroupedWithProratedMinimumPrice + ) = Price(groupedWithProratedMinimum = groupedWithProratedMinimum) + + fun ofGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice + ) = Price(groupedWithMeteredMinimum = groupedWithMeteredMinimum) + + fun ofGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) = Price(groupedWithMinMaxThresholds = groupedWithMinMaxThresholds) + + fun ofMatrixWithDisplayName( + matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice + ) = Price(matrixWithDisplayName = matrixWithDisplayName) + + fun ofGroupedTieredPackage( + groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice + ) = Price(groupedTieredPackage = groupedTieredPackage) + + fun ofMaxGroupTieredPackage( + maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice + ) = Price(maxGroupTieredPackage = maxGroupTieredPackage) + + fun ofScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: NewSubscriptionScalableMatrixWithUnitPricingPrice + ) = Price(scalableMatrixWithUnitPricing = scalableMatrixWithUnitPricing) + + fun ofScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: + NewSubscriptionScalableMatrixWithTieredPricingPrice + ) = Price(scalableMatrixWithTieredPricing = scalableMatrixWithTieredPricing) + + fun ofCumulativeGroupedBulk( + cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice + ) = Price(cumulativeGroupedBulk = cumulativeGroupedBulk) + + fun ofCumulativeGroupedAllocation( + cumulativeGroupedAllocation: CumulativeGroupedAllocation + ) = Price(cumulativeGroupedAllocation = cumulativeGroupedAllocation) + + fun ofMinimum(minimum: NewSubscriptionMinimumCompositePrice) = + Price(minimum = minimum) + + fun ofPercent(percent: Percent) = Price(percent = percent) + + fun ofEventOutput(eventOutput: EventOutput) = Price(eventOutput = eventOutput) + } + + /** + * An interface that defines how to map each variant of [Price] to a value of type [T]. + */ + interface Visitor { + + fun visitUnit(unit: NewSubscriptionUnitPrice): T + + fun visitTiered(tiered: NewSubscriptionTieredPrice): T + + fun visitBulk(bulk: NewSubscriptionBulkPrice): T + + fun visitBulkWithFilters(bulkWithFilters: BulkWithFilters): T + + fun visitPackage(package_: NewSubscriptionPackagePrice): T + + fun visitMatrix(matrix: NewSubscriptionMatrixPrice): T + + fun visitThresholdTotalAmount( + thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice + ): T + + fun visitTieredPackage(tieredPackage: NewSubscriptionTieredPackagePrice): T + + fun visitTieredWithMinimum( + tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice + ): T + + fun visitGroupedTiered(groupedTiered: NewSubscriptionGroupedTieredPrice): T + + fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice + ): T + + fun visitPackageWithAllocation( + packageWithAllocation: NewSubscriptionPackageWithAllocationPrice + ): T + + fun visitUnitWithPercent(unitWithPercent: NewSubscriptionUnitWithPercentPrice): T + + fun visitMatrixWithAllocation( + matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice + ): T + + fun visitTieredWithProration(tieredWithProration: TieredWithProration): T + + fun visitUnitWithProration( + unitWithProration: NewSubscriptionUnitWithProrationPrice + ): T + + fun visitGroupedAllocation( + groupedAllocation: NewSubscriptionGroupedAllocationPrice + ): T + + fun visitBulkWithProration( + bulkWithProration: NewSubscriptionBulkWithProrationPrice + ): T + + fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: NewSubscriptionGroupedWithProratedMinimumPrice + ): T + + fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice + ): T + + fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ): T + + fun visitMatrixWithDisplayName( + matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice + ): T + + fun visitGroupedTieredPackage( + groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice + ): T + + fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice + ): T + + fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: NewSubscriptionScalableMatrixWithUnitPricingPrice + ): T + + fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: + NewSubscriptionScalableMatrixWithTieredPricingPrice + ): T + + fun visitCumulativeGroupedBulk( + cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice + ): T + + fun visitCumulativeGroupedAllocation( + cumulativeGroupedAllocation: CumulativeGroupedAllocation + ): T + + fun visitMinimum(minimum: NewSubscriptionMinimumCompositePrice): T + + fun visitPercent(percent: Percent): T + + fun visitEventOutput(eventOutput: EventOutput): T + + /** + * Maps an unknown variant of [Price] to a value of type [T]. + * + * An instance of [Price] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is + * unaware of. + * + * @throws OrbInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw OrbInvalidDataException("Unknown Price: $json") + } + } + + internal class Deserializer : BaseDeserializer(Price::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Price { + val json = JsonValue.fromJsonNode(node) + val modelType = json.asObject()?.get("model_type")?.asString() + + when (modelType) { + "unit" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(unit = it, _json = json) } ?: Price(_json = json) + } + "tiered" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(tiered = it, _json = json) } ?: Price(_json = json) + } + "bulk" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(bulk = it, _json = json) } ?: Price(_json = json) + } + "bulk_with_filters" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(bulkWithFilters = it, _json = json) + } ?: Price(_json = json) + } + "package" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(package_ = it, _json = json) } ?: Price(_json = json) + } + "matrix" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(matrix = it, _json = json) } ?: Price(_json = json) + } + "threshold_total_amount" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(thresholdTotalAmount = it, _json = json) } + ?: Price(_json = json) + } + "tiered_package" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(tieredPackage = it, _json = json) } + ?: Price(_json = json) + } + "tiered_with_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(tieredWithMinimum = it, _json = json) } + ?: Price(_json = json) + } + "grouped_tiered" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedTiered = it, _json = json) } + ?: Price(_json = json) + } + "tiered_package_with_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(tieredPackageWithMinimum = it, _json = json) } + ?: Price(_json = json) + } + "package_with_allocation" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(packageWithAllocation = it, _json = json) } + ?: Price(_json = json) + } + "unit_with_percent" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(unitWithPercent = it, _json = json) } + ?: Price(_json = json) + } + "matrix_with_allocation" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(matrixWithAllocation = it, _json = json) } + ?: Price(_json = json) + } + "tiered_with_proration" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(tieredWithProration = it, _json = json) } + ?: Price(_json = json) + } + "unit_with_proration" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(unitWithProration = it, _json = json) } + ?: Price(_json = json) + } + "grouped_allocation" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedAllocation = it, _json = json) } + ?: Price(_json = json) + } + "bulk_with_proration" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(bulkWithProration = it, _json = json) } + ?: Price(_json = json) + } + "grouped_with_prorated_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedWithProratedMinimum = it, _json = json) } + ?: Price(_json = json) + } + "grouped_with_metered_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedWithMeteredMinimum = it, _json = json) } + ?: Price(_json = json) + } + "grouped_with_min_max_thresholds" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedWithMinMaxThresholds = it, _json = json) } + ?: Price(_json = json) + } + "matrix_with_display_name" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(matrixWithDisplayName = it, _json = json) } + ?: Price(_json = json) + } + "grouped_tiered_package" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedTieredPackage = it, _json = json) } + ?: Price(_json = json) + } + "max_group_tiered_package" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(maxGroupTieredPackage = it, _json = json) } + ?: Price(_json = json) + } + "scalable_matrix_with_unit_pricing" -> { + return tryDeserialize( + node, + jacksonTypeRef< + NewSubscriptionScalableMatrixWithUnitPricingPrice + >(), + ) + ?.let { Price(scalableMatrixWithUnitPricing = it, _json = json) } + ?: Price(_json = json) + } + "scalable_matrix_with_tiered_pricing" -> { + return tryDeserialize( + node, + jacksonTypeRef< + NewSubscriptionScalableMatrixWithTieredPricingPrice + >(), + ) + ?.let { Price(scalableMatrixWithTieredPricing = it, _json = json) } + ?: Price(_json = json) + } + "cumulative_grouped_bulk" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(cumulativeGroupedBulk = it, _json = json) } + ?: Price(_json = json) + } + "cumulative_grouped_allocation" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(cumulativeGroupedAllocation = it, _json = json) } + ?: Price(_json = json) + } + "minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(minimum = it, _json = json) } ?: Price(_json = json) + } + "percent" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(percent = it, _json = json) + } ?: Price(_json = json) + } + "event_output" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(eventOutput = it, _json = json) + } ?: Price(_json = json) + } + } + + return Price(_json = json) + } + } + + internal class Serializer : BaseSerializer(Price::class) { + + override fun serialize( + value: Price, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.unit != null -> generator.writeObject(value.unit) + value.tiered != null -> generator.writeObject(value.tiered) + value.bulk != null -> generator.writeObject(value.bulk) + value.bulkWithFilters != null -> + generator.writeObject(value.bulkWithFilters) + value.package_ != null -> generator.writeObject(value.package_) + value.matrix != null -> generator.writeObject(value.matrix) + value.thresholdTotalAmount != null -> + generator.writeObject(value.thresholdTotalAmount) + value.tieredPackage != null -> generator.writeObject(value.tieredPackage) + value.tieredWithMinimum != null -> + generator.writeObject(value.tieredWithMinimum) + value.groupedTiered != null -> generator.writeObject(value.groupedTiered) + value.tieredPackageWithMinimum != null -> + generator.writeObject(value.tieredPackageWithMinimum) + value.packageWithAllocation != null -> + generator.writeObject(value.packageWithAllocation) + value.unitWithPercent != null -> + generator.writeObject(value.unitWithPercent) + value.matrixWithAllocation != null -> + generator.writeObject(value.matrixWithAllocation) + value.tieredWithProration != null -> + generator.writeObject(value.tieredWithProration) + value.unitWithProration != null -> + generator.writeObject(value.unitWithProration) + value.groupedAllocation != null -> + generator.writeObject(value.groupedAllocation) + value.bulkWithProration != null -> + generator.writeObject(value.bulkWithProration) + value.groupedWithProratedMinimum != null -> + generator.writeObject(value.groupedWithProratedMinimum) + value.groupedWithMeteredMinimum != null -> + generator.writeObject(value.groupedWithMeteredMinimum) + value.groupedWithMinMaxThresholds != null -> + generator.writeObject(value.groupedWithMinMaxThresholds) + value.matrixWithDisplayName != null -> + generator.writeObject(value.matrixWithDisplayName) + value.groupedTieredPackage != null -> + generator.writeObject(value.groupedTieredPackage) + value.maxGroupTieredPackage != null -> + generator.writeObject(value.maxGroupTieredPackage) + value.scalableMatrixWithUnitPricing != null -> + generator.writeObject(value.scalableMatrixWithUnitPricing) + value.scalableMatrixWithTieredPricing != null -> + generator.writeObject(value.scalableMatrixWithTieredPricing) + value.cumulativeGroupedBulk != null -> + generator.writeObject(value.cumulativeGroupedBulk) + value.cumulativeGroupedAllocation != null -> + generator.writeObject(value.cumulativeGroupedAllocation) + value.minimum != null -> generator.writeObject(value.minimum) + value.percent != null -> generator.writeObject(value.percent) + value.eventOutput != null -> generator.writeObject(value.eventOutput) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Price") + } + } + } + + class BulkWithFilters + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val bulkWithFiltersConfig: JsonField, + private val cadence: JsonField, + private val itemId: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("bulk_with_filters_config") + @ExcludeMissing + bulkWithFiltersConfig: JsonField = JsonMissing.of(), + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + bulkWithFiltersConfig, + cadence, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * Configuration for bulk_with_filters pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun bulkWithFiltersConfig(): BulkWithFiltersConfig = + bulkWithFiltersConfig.getRequired("bulk_with_filters_config") + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("bulk_with_filters") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = billableMetricId.getNullable("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + invoiceGroupingKey.getNullable("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [bulkWithFiltersConfig]. + * + * Unlike [bulkWithFiltersConfig], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("bulk_with_filters_config") + @ExcludeMissing + fun _bulkWithFiltersConfig(): JsonField = + bulkWithFiltersConfig + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [BulkWithFilters]. + * + * The following fields are required: + * ```kotlin + * .bulkWithFiltersConfig() + * .cadence() + * .itemId() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [BulkWithFilters]. */ + class Builder internal constructor() { + + private var bulkWithFiltersConfig: JsonField? = null + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonValue = JsonValue.from("bulk_with_filters") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(bulkWithFilters: BulkWithFilters) = apply { + bulkWithFiltersConfig = bulkWithFilters.bulkWithFiltersConfig + cadence = bulkWithFilters.cadence + itemId = bulkWithFilters.itemId + modelType = bulkWithFilters.modelType + name = bulkWithFilters.name + billableMetricId = bulkWithFilters.billableMetricId + billedInAdvance = bulkWithFilters.billedInAdvance + billingCycleConfiguration = bulkWithFilters.billingCycleConfiguration + conversionRate = bulkWithFilters.conversionRate + conversionRateConfig = bulkWithFilters.conversionRateConfig + currency = bulkWithFilters.currency + dimensionalPriceConfiguration = + bulkWithFilters.dimensionalPriceConfiguration + externalPriceId = bulkWithFilters.externalPriceId + fixedPriceQuantity = bulkWithFilters.fixedPriceQuantity + invoiceGroupingKey = bulkWithFilters.invoiceGroupingKey + invoicingCycleConfiguration = bulkWithFilters.invoicingCycleConfiguration + metadata = bulkWithFilters.metadata + referenceId = bulkWithFilters.referenceId + additionalProperties = bulkWithFilters.additionalProperties.toMutableMap() + } + + /** Configuration for bulk_with_filters pricing */ + fun bulkWithFiltersConfig(bulkWithFiltersConfig: BulkWithFiltersConfig) = + bulkWithFiltersConfig(JsonField.of(bulkWithFiltersConfig)) + + /** + * Sets [Builder.bulkWithFiltersConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.bulkWithFiltersConfig] with a well-typed + * [BulkWithFiltersConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun bulkWithFiltersConfig( + bulkWithFiltersConfig: JsonField + ) = apply { this.bulkWithFiltersConfig = bulkWithFiltersConfig } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("bulk_with_filters") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BulkWithFilters]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .bulkWithFiltersConfig() + * .cadence() + * .itemId() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BulkWithFilters = + BulkWithFilters( + checkRequired("bulkWithFiltersConfig", bulkWithFiltersConfig), + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): BulkWithFilters = apply { + if (validated) { + return@apply + } + + bulkWithFiltersConfig().validate() + cadence().validate() + itemId() + _modelType().let { + if (it != JsonValue.from("bulk_with_filters")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (bulkWithFiltersConfig.asKnown()?.validity() ?: 0) + + (cadence.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + modelType.let { if (it == JsonValue.from("bulk_with_filters")) 1 else 0 } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** Configuration for bulk_with_filters pricing */ + class BulkWithFiltersConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val filters: JsonField>, + private val tiers: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("filters") + @ExcludeMissing + filters: JsonField> = JsonMissing.of(), + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of(), + ) : this(filters, tiers, mutableMapOf()) + + /** + * Property filters to apply (all must match) + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun filters(): List = filters.getRequired("filters") + + /** + * Bulk tiers for rating based on total usage volume + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun tiers(): List = tiers.getRequired("tiers") + + /** + * Returns the raw JSON value of [filters]. + * + * Unlike [filters], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("filters") + @ExcludeMissing + fun _filters(): JsonField> = filters + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [BulkWithFiltersConfig]. + * + * The following fields are required: + * ```kotlin + * .filters() + * .tiers() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [BulkWithFiltersConfig]. */ + class Builder internal constructor() { + + private var filters: JsonField>? = null + private var tiers: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(bulkWithFiltersConfig: BulkWithFiltersConfig) = apply { + filters = bulkWithFiltersConfig.filters.map { it.toMutableList() } + tiers = bulkWithFiltersConfig.tiers.map { it.toMutableList() } + additionalProperties = + bulkWithFiltersConfig.additionalProperties.toMutableMap() + } + + /** Property filters to apply (all must match) */ + fun filters(filters: List) = filters(JsonField.of(filters)) + + /** + * Sets [Builder.filters] to an arbitrary JSON value. + * + * You should usually call [Builder.filters] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun filters(filters: JsonField>) = apply { + this.filters = filters.map { it.toMutableList() } + } + + /** + * Adds a single [Filter] to [filters]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addFilter(filter: Filter) = apply { + filters = + (filters ?: JsonField.of(mutableListOf())).also { + checkKnown("filters", it).add(filter) + } + } + + /** Bulk tiers for rating based on total usage volume */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BulkWithFiltersConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .filters() + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BulkWithFiltersConfig = + BulkWithFiltersConfig( + checkRequired("filters", filters).map { it.toImmutable() }, + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): BulkWithFiltersConfig = apply { + if (validated) { + return@apply + } + + filters().forEach { it.validate() } + tiers().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (filters.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + (tiers.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single property filter */ + class Filter + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val propertyKey: JsonField, + private val propertyValue: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("property_key") + @ExcludeMissing + propertyKey: JsonField = JsonMissing.of(), + @JsonProperty("property_value") + @ExcludeMissing + propertyValue: JsonField = JsonMissing.of(), + ) : this(propertyKey, propertyValue, mutableMapOf()) + + /** + * Event property key to filter on + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun propertyKey(): String = propertyKey.getRequired("property_key") + + /** + * Event property value to match + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun propertyValue(): String = propertyValue.getRequired("property_value") + + /** + * Returns the raw JSON value of [propertyKey]. + * + * Unlike [propertyKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("property_key") + @ExcludeMissing + fun _propertyKey(): JsonField = propertyKey + + /** + * Returns the raw JSON value of [propertyValue]. + * + * Unlike [propertyValue], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("property_value") + @ExcludeMissing + fun _propertyValue(): JsonField = propertyValue + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Filter]. + * + * The following fields are required: + * ```kotlin + * .propertyKey() + * .propertyValue() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Filter]. */ + class Builder internal constructor() { + + private var propertyKey: JsonField? = null + private var propertyValue: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(filter: Filter) = apply { + propertyKey = filter.propertyKey + propertyValue = filter.propertyValue + additionalProperties = filter.additionalProperties.toMutableMap() + } + + /** Event property key to filter on */ + fun propertyKey(propertyKey: String) = + propertyKey(JsonField.of(propertyKey)) + + /** + * Sets [Builder.propertyKey] to an arbitrary JSON value. + * + * You should usually call [Builder.propertyKey] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun propertyKey(propertyKey: JsonField) = apply { + this.propertyKey = propertyKey + } + + /** Event property value to match */ + fun propertyValue(propertyValue: String) = + propertyValue(JsonField.of(propertyValue)) + + /** + * Sets [Builder.propertyValue] to an arbitrary JSON value. + * + * You should usually call [Builder.propertyValue] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun propertyValue(propertyValue: JsonField) = apply { + this.propertyValue = propertyValue + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - override fun ObjectCodec.deserialize(node: JsonNode): Price { - val json = JsonValue.fromJsonNode(node) - val modelType = json.asObject()?.get("model_type")?.asString() + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - when (modelType) { - "unit" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(unit = it, _json = json) } ?: Price(_json = json) - } - "tiered" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(tiered = it, _json = json) } ?: Price(_json = json) - } - "bulk" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(bulk = it, _json = json) } ?: Price(_json = json) - } - "bulk_with_filters" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(bulkWithFilters = it, _json = json) - } ?: Price(_json = json) - } - "package" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(package_ = it, _json = json) } ?: Price(_json = json) - } - "matrix" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(matrix = it, _json = json) } ?: Price(_json = json) - } - "threshold_total_amount" -> { - return tryDeserialize( - node, - jacksonTypeRef(), + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Filter]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```kotlin + * .propertyKey() + * .propertyValue() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Filter = + Filter( + checkRequired("propertyKey", propertyKey), + checkRequired("propertyValue", propertyValue), + additionalProperties.toMutableMap(), ) - ?.let { Price(thresholdTotalAmount = it, _json = json) } - ?: Price(_json = json) } - "tiered_package" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(tieredPackage = it, _json = json) } - ?: Price(_json = json) + + private var validated: Boolean = false + + fun validate(): Filter = apply { + if (validated) { + return@apply + } + + propertyKey() + propertyValue() + validated = true } - "tiered_with_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(tieredWithMinimum = it, _json = json) } - ?: Price(_json = json) + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (propertyKey.asKnown() == null) 0 else 1) + + (if (propertyValue.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Filter && + propertyKey == other.propertyKey && + propertyValue == other.propertyValue && + additionalProperties == other.additionalProperties } - "grouped_tiered" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedTiered = it, _json = json) } - ?: Price(_json = json) + + private val hashCode: Int by lazy { + Objects.hash(propertyKey, propertyValue, additionalProperties) } - "tiered_package_with_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(tieredPackageWithMinimum = it, _json = json) } - ?: Price(_json = json) + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Filter{propertyKey=$propertyKey, propertyValue=$propertyValue, additionalProperties=$additionalProperties}" + } + + /** Configuration for a single bulk pricing tier */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val unitAmount: JsonField, + private val tierLowerBound: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + ) : this(unitAmount, tierLowerBound, mutableMapOf()) + + /** + * Amount per unit + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * The lower bound for this tier + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun tierLowerBound(): String? = + tierLowerBound.getNullable("tier_lower_bound") + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) } - "package_with_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(packageWithAllocation = it, _json = json) } - ?: Price(_json = json) + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Tier]. + * + * The following fields are required: + * ```kotlin + * .unitAmount() + * ``` + */ + fun builder() = Builder() } - "unit_with_percent" -> { - return tryDeserialize( - node, - jacksonTypeRef(), + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var unitAmount: JsonField? = null + private var tierLowerBound: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(tier: Tier) = apply { + unitAmount = tier.unitAmount + tierLowerBound = tier.tierLowerBound + additionalProperties = tier.additionalProperties.toMutableMap() + } + + /** Amount per unit */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + /** The lower bound for this tier */ + fun tierLowerBound(tierLowerBound: String?) = + tierLowerBound(JsonField.ofNullable(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```kotlin + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("unitAmount", unitAmount), + tierLowerBound, + additionalProperties.toMutableMap(), ) - ?.let { Price(unitWithPercent = it, _json = json) } - ?: Price(_json = json) } - "matrix_with_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(matrixWithAllocation = it, _json = json) } - ?: Price(_json = json) + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + unitAmount() + tierLowerBound() + validated = true } - "tiered_with_proration" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(tieredWithProration = it, _json = json) } - ?: Price(_json = json) + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (unitAmount.asKnown() == null) 0 else 1) + + (if (tierLowerBound.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + unitAmount == other.unitAmount && + tierLowerBound == other.tierLowerBound && + additionalProperties == other.additionalProperties } - "unit_with_proration" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(unitWithProration = it, _json = json) } - ?: Price(_json = json) + + private val hashCode: Int by lazy { + Objects.hash(unitAmount, tierLowerBound, additionalProperties) } - "grouped_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedAllocation = it, _json = json) } - ?: Price(_json = json) + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{unitAmount=$unitAmount, tierLowerBound=$tierLowerBound, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - "bulk_with_proration" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(bulkWithProration = it, _json = json) } - ?: Price(_json = json) + + return other is BulkWithFiltersConfig && + filters == other.filters && + tiers == other.tiers && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(filters, tiers, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BulkWithFiltersConfig{filters=$filters, tiers=$tiers, additionalProperties=$additionalProperties}" + } + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN } - "grouped_with_prorated_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedWithProratedMinimum = it, _json = json) } - ?: Price(_json = json) + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") } - "grouped_with_metered_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedWithMeteredMinimum = it, _json = json) } - ?: Price(_json = json) + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply } - "grouped_with_min_max_thresholds" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedWithMinMaxThresholds = it, _json = json) } - ?: Price(_json = json) + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false } - "matrix_with_display_name" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(matrixWithDisplayName = it, _json = json) } - ?: Price(_json = json) + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - "grouped_tiered_package" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedTieredPackage = it, _json = json) } - ?: Price(_json = json) + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() } - "max_group_tiered_package" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(maxGroupTieredPackage = it, _json = json) } - ?: Price(_json = json) + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) } - "scalable_matrix_with_unit_pricing" -> { - return tryDeserialize( - node, - jacksonTypeRef< - NewSubscriptionScalableMatrixWithUnitPricingPrice - >(), - ) - ?.let { Price(scalableMatrixWithUnitPricing = it, _json = json) } - ?: Price(_json = json) + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) } - "scalable_matrix_with_tiered_pricing" -> { - return tryDeserialize( - node, - jacksonTypeRef< - NewSubscriptionScalableMatrixWithTieredPricingPrice - >(), - ) - ?.let { Price(scalableMatrixWithTieredPricing = it, _json = json) } - ?: Price(_json = json) + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) } - "cumulative_grouped_bulk" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(cumulativeGroupedBulk = it, _json = json) } - ?: Price(_json = json) + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply } - "minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(minimum = it, _json = json) } ?: Price(_json = json) + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false } - "percent" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(percent = it, _json = json) - } ?: Price(_json = json) + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() } - "event_output" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(eventOutput = it, _json = json) - } ?: Price(_json = json) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - return Price(_json = json) + return other is BulkWithFilters && + bulkWithFiltersConfig == other.bulkWithFiltersConfig && + cadence == other.cadence && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties } - } - - internal class Serializer : BaseSerializer(Price::class) { - override fun serialize( - value: Price, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unit != null -> generator.writeObject(value.unit) - value.tiered != null -> generator.writeObject(value.tiered) - value.bulk != null -> generator.writeObject(value.bulk) - value.bulkWithFilters != null -> - generator.writeObject(value.bulkWithFilters) - value.package_ != null -> generator.writeObject(value.package_) - value.matrix != null -> generator.writeObject(value.matrix) - value.thresholdTotalAmount != null -> - generator.writeObject(value.thresholdTotalAmount) - value.tieredPackage != null -> generator.writeObject(value.tieredPackage) - value.tieredWithMinimum != null -> - generator.writeObject(value.tieredWithMinimum) - value.groupedTiered != null -> generator.writeObject(value.groupedTiered) - value.tieredPackageWithMinimum != null -> - generator.writeObject(value.tieredPackageWithMinimum) - value.packageWithAllocation != null -> - generator.writeObject(value.packageWithAllocation) - value.unitWithPercent != null -> - generator.writeObject(value.unitWithPercent) - value.matrixWithAllocation != null -> - generator.writeObject(value.matrixWithAllocation) - value.tieredWithProration != null -> - generator.writeObject(value.tieredWithProration) - value.unitWithProration != null -> - generator.writeObject(value.unitWithProration) - value.groupedAllocation != null -> - generator.writeObject(value.groupedAllocation) - value.bulkWithProration != null -> - generator.writeObject(value.bulkWithProration) - value.groupedWithProratedMinimum != null -> - generator.writeObject(value.groupedWithProratedMinimum) - value.groupedWithMeteredMinimum != null -> - generator.writeObject(value.groupedWithMeteredMinimum) - value.groupedWithMinMaxThresholds != null -> - generator.writeObject(value.groupedWithMinMaxThresholds) - value.matrixWithDisplayName != null -> - generator.writeObject(value.matrixWithDisplayName) - value.groupedTieredPackage != null -> - generator.writeObject(value.groupedTieredPackage) - value.maxGroupTieredPackage != null -> - generator.writeObject(value.maxGroupTieredPackage) - value.scalableMatrixWithUnitPricing != null -> - generator.writeObject(value.scalableMatrixWithUnitPricing) - value.scalableMatrixWithTieredPricing != null -> - generator.writeObject(value.scalableMatrixWithTieredPricing) - value.cumulativeGroupedBulk != null -> - generator.writeObject(value.cumulativeGroupedBulk) - value.minimum != null -> generator.writeObject(value.minimum) - value.percent != null -> generator.writeObject(value.percent) - value.eventOutput != null -> generator.writeObject(value.eventOutput) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Price") - } + private val hashCode: Int by lazy { + Objects.hash( + bulkWithFiltersConfig, + cadence, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties, + ) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BulkWithFilters{bulkWithFiltersConfig=$bulkWithFiltersConfig, cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class BulkWithFilters + class TieredWithProration @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val bulkWithFiltersConfig: JsonField, private val cadence: JsonField, private val itemId: JsonField, private val modelType: JsonValue, private val name: JsonField, + private val tieredWithProrationConfig: JsonField, private val billableMetricId: JsonField, private val billedInAdvance: JsonField, private val billingCycleConfiguration: JsonField, @@ -17884,9 +21724,6 @@ private constructor( @JsonCreator private constructor( - @JsonProperty("bulk_with_filters_config") - @ExcludeMissing - bulkWithFiltersConfig: JsonField = JsonMissing.of(), @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), @@ -17899,6 +21736,10 @@ private constructor( @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("tiered_with_proration_config") + @ExcludeMissing + tieredWithProrationConfig: JsonField = + JsonMissing.of(), @JsonProperty("billable_metric_id") @ExcludeMissing billableMetricId: JsonField = JsonMissing.of(), @@ -17942,11 +21783,11 @@ private constructor( @ExcludeMissing referenceId: JsonField = JsonMissing.of(), ) : this( - bulkWithFiltersConfig, cadence, itemId, modelType, name, + tieredWithProrationConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -17963,16 +21804,6 @@ private constructor( mutableMapOf(), ) - /** - * Configuration for bulk_with_filters pricing - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun bulkWithFiltersConfig(): BulkWithFiltersConfig = - bulkWithFiltersConfig.getRequired("bulk_with_filters_config") - /** * The cadence to bill for this price on. * @@ -17996,7 +21827,7 @@ private constructor( * * Expected to always return the following: * ```kotlin - * JsonValue.from("bulk_with_filters") + * JsonValue.from("tiered_with_proration") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -18013,6 +21844,16 @@ private constructor( */ fun name(): String = name.getRequired("name") + /** + * Configuration for tiered_with_proration pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun tieredWithProrationConfig(): TieredWithProrationConfig = + tieredWithProrationConfig.getRequired("tiered_with_proration_config") + /** * The id of the billable metric for the price. Only needed if the price is * usage-based. @@ -18132,17 +21973,6 @@ private constructor( */ fun referenceId(): String? = referenceId.getNullable("reference_id") - /** - * Returns the raw JSON value of [bulkWithFiltersConfig]. - * - * Unlike [bulkWithFiltersConfig], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("bulk_with_filters_config") - @ExcludeMissing - fun _bulkWithFiltersConfig(): JsonField = - bulkWithFiltersConfig - /** * Returns the raw JSON value of [cadence]. * @@ -18169,6 +21999,17 @@ private constructor( */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + /** + * Returns the raw JSON value of [tieredWithProrationConfig]. + * + * Unlike [tieredWithProrationConfig], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("tiered_with_proration_config") + @ExcludeMissing + fun _tieredWithProrationConfig(): JsonField = + tieredWithProrationConfig + /** * Returns the raw JSON value of [billableMetricId]. * @@ -18317,27 +22158,29 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [BulkWithFilters]. + * Returns a mutable builder for constructing an instance of + * [TieredWithProration]. * * The following fields are required: * ```kotlin - * .bulkWithFiltersConfig() * .cadence() * .itemId() * .name() + * .tieredWithProrationConfig() * ``` */ fun builder() = Builder() } - /** A builder for [BulkWithFilters]. */ + /** A builder for [TieredWithProration]. */ class Builder internal constructor() { - private var bulkWithFiltersConfig: JsonField? = null private var cadence: JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonValue = JsonValue.from("bulk_with_filters") + private var modelType: JsonValue = JsonValue.from("tiered_with_proration") private var name: JsonField? = null + private var tieredWithProrationConfig: JsonField? = + null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() private var billingCycleConfiguration: JsonField = @@ -18359,44 +22202,31 @@ private constructor( private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(bulkWithFilters: BulkWithFilters) = apply { - bulkWithFiltersConfig = bulkWithFilters.bulkWithFiltersConfig - cadence = bulkWithFilters.cadence - itemId = bulkWithFilters.itemId - modelType = bulkWithFilters.modelType - name = bulkWithFilters.name - billableMetricId = bulkWithFilters.billableMetricId - billedInAdvance = bulkWithFilters.billedInAdvance - billingCycleConfiguration = bulkWithFilters.billingCycleConfiguration - conversionRate = bulkWithFilters.conversionRate - conversionRateConfig = bulkWithFilters.conversionRateConfig - currency = bulkWithFilters.currency + internal fun from(tieredWithProration: TieredWithProration) = apply { + cadence = tieredWithProration.cadence + itemId = tieredWithProration.itemId + modelType = tieredWithProration.modelType + name = tieredWithProration.name + tieredWithProrationConfig = tieredWithProration.tieredWithProrationConfig + billableMetricId = tieredWithProration.billableMetricId + billedInAdvance = tieredWithProration.billedInAdvance + billingCycleConfiguration = tieredWithProration.billingCycleConfiguration + conversionRate = tieredWithProration.conversionRate + conversionRateConfig = tieredWithProration.conversionRateConfig + currency = tieredWithProration.currency dimensionalPriceConfiguration = - bulkWithFilters.dimensionalPriceConfiguration - externalPriceId = bulkWithFilters.externalPriceId - fixedPriceQuantity = bulkWithFilters.fixedPriceQuantity - invoiceGroupingKey = bulkWithFilters.invoiceGroupingKey - invoicingCycleConfiguration = bulkWithFilters.invoicingCycleConfiguration - metadata = bulkWithFilters.metadata - referenceId = bulkWithFilters.referenceId - additionalProperties = bulkWithFilters.additionalProperties.toMutableMap() + tieredWithProration.dimensionalPriceConfiguration + externalPriceId = tieredWithProration.externalPriceId + fixedPriceQuantity = tieredWithProration.fixedPriceQuantity + invoiceGroupingKey = tieredWithProration.invoiceGroupingKey + invoicingCycleConfiguration = + tieredWithProration.invoicingCycleConfiguration + metadata = tieredWithProration.metadata + referenceId = tieredWithProration.referenceId + additionalProperties = + tieredWithProration.additionalProperties.toMutableMap() } - /** Configuration for bulk_with_filters pricing */ - fun bulkWithFiltersConfig(bulkWithFiltersConfig: BulkWithFiltersConfig) = - bulkWithFiltersConfig(JsonField.of(bulkWithFiltersConfig)) - - /** - * Sets [Builder.bulkWithFiltersConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.bulkWithFiltersConfig] with a well-typed - * [BulkWithFiltersConfig] value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun bulkWithFiltersConfig( - bulkWithFiltersConfig: JsonField - ) = apply { this.bulkWithFiltersConfig = bulkWithFiltersConfig } - /** The cadence to bill for this price on. */ fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) @@ -18427,7 +22257,7 @@ private constructor( * It is usually unnecessary to call this method because the field defaults to * the following: * ```kotlin - * JsonValue.from("bulk_with_filters") + * JsonValue.from("tiered_with_proration") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -18441,11 +22271,27 @@ private constructor( /** * Sets [Builder.name] to an arbitrary JSON value. * - * You should usually call [Builder.name] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for tiered_with_proration pricing */ + fun tieredWithProrationConfig( + tieredWithProrationConfig: TieredWithProrationConfig + ) = tieredWithProrationConfig(JsonField.of(tieredWithProrationConfig)) + + /** + * Sets [Builder.tieredWithProrationConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.tieredWithProrationConfig] with a well-typed + * [TieredWithProrationConfig] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. */ - fun name(name: JsonField) = apply { this.name = name } + fun tieredWithProrationConfig( + tieredWithProrationConfig: JsonField + ) = apply { this.tieredWithProrationConfig = tieredWithProrationConfig } /** * The id of the billable metric for the price. Only needed if the price is @@ -18776,27 +22622,27 @@ private constructor( } /** - * Returns an immutable instance of [BulkWithFilters]. + * Returns an immutable instance of [TieredWithProration]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```kotlin - * .bulkWithFiltersConfig() * .cadence() * .itemId() * .name() + * .tieredWithProrationConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): BulkWithFilters = - BulkWithFilters( - checkRequired("bulkWithFiltersConfig", bulkWithFiltersConfig), + fun build(): TieredWithProration = + TieredWithProration( checkRequired("cadence", cadence), checkRequired("itemId", itemId), modelType, checkRequired("name", name), + checkRequired("tieredWithProrationConfig", tieredWithProrationConfig), billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -18816,20 +22662,20 @@ private constructor( private var validated: Boolean = false - fun validate(): BulkWithFilters = apply { + fun validate(): TieredWithProration = apply { if (validated) { return@apply } - bulkWithFiltersConfig().validate() cadence().validate() itemId() _modelType().let { - if (it != JsonValue.from("bulk_with_filters")) { + if (it != JsonValue.from("tiered_with_proration")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } name() + tieredWithProrationConfig().validate() billableMetricId() billedInAdvance() billingCycleConfiguration()?.validate() @@ -18861,11 +22707,13 @@ private constructor( * Used for best match union deserialization. */ internal fun validity(): Int = - (bulkWithFiltersConfig.asKnown()?.validity() ?: 0) + - (cadence.asKnown()?.validity() ?: 0) + + (cadence.asKnown()?.validity() ?: 0) + (if (itemId.asKnown() == null) 0 else 1) + - modelType.let { if (it == JsonValue.from("bulk_with_filters")) 1 else 0 } + + modelType.let { + if (it == JsonValue.from("tiered_with_proration")) 1 else 0 + } + (if (name.asKnown() == null) 0 else 1) + + (tieredWithProrationConfig.asKnown()?.validity() ?: 0) + (if (billableMetricId.asKnown() == null) 0 else 1) + (if (billedInAdvance.asKnown() == null) 0 else 1) + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + @@ -18880,36 +22728,181 @@ private constructor( (metadata.asKnown()?.validity() ?: 0) + (if (referenceId.asKnown() == null) 0 else 1) - /** Configuration for bulk_with_filters pricing */ - class BulkWithFiltersConfig + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Configuration for tiered_with_proration pricing */ + class TieredWithProrationConfig @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val filters: JsonField>, private val tiers: JsonField>, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("filters") - @ExcludeMissing - filters: JsonField> = JsonMissing.of(), @JsonProperty("tiers") @ExcludeMissing - tiers: JsonField> = JsonMissing.of(), - ) : this(filters, tiers, mutableMapOf()) - - /** - * Property filters to apply (all must match) - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun filters(): List = filters.getRequired("filters") + tiers: JsonField> = JsonMissing.of() + ) : this(tiers, mutableMapOf()) /** - * Bulk tiers for rating based on total usage volume + * Tiers for rating based on total usage quantities into the specified tier with + * proration * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an @@ -18917,16 +22910,6 @@ private constructor( */ fun tiers(): List = tiers.getRequired("tiers") - /** - * Returns the raw JSON value of [filters]. - * - * Unlike [filters], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("filters") - @ExcludeMissing - fun _filters(): JsonField> = filters - /** * Returns the raw JSON value of [tiers]. * @@ -18953,60 +22936,34 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [BulkWithFiltersConfig]. + * [TieredWithProrationConfig]. * * The following fields are required: * ```kotlin - * .filters() * .tiers() * ``` */ fun builder() = Builder() } - /** A builder for [BulkWithFiltersConfig]. */ + /** A builder for [TieredWithProrationConfig]. */ class Builder internal constructor() { - private var filters: JsonField>? = null private var tiers: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(bulkWithFiltersConfig: BulkWithFiltersConfig) = apply { - filters = bulkWithFiltersConfig.filters.map { it.toMutableList() } - tiers = bulkWithFiltersConfig.tiers.map { it.toMutableList() } - additionalProperties = - bulkWithFiltersConfig.additionalProperties.toMutableMap() - } - - /** Property filters to apply (all must match) */ - fun filters(filters: List) = filters(JsonField.of(filters)) - - /** - * Sets [Builder.filters] to an arbitrary JSON value. - * - * You should usually call [Builder.filters] with a well-typed - * `List` value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun filters(filters: JsonField>) = apply { - this.filters = filters.map { it.toMutableList() } - } + internal fun from(tieredWithProrationConfig: TieredWithProrationConfig) = + apply { + tiers = tieredWithProrationConfig.tiers.map { it.toMutableList() } + additionalProperties = + tieredWithProrationConfig.additionalProperties.toMutableMap() + } /** - * Adds a single [Filter] to [filters]. - * - * @throws IllegalStateException if the field was previously set to a - * non-list. + * Tiers for rating based on total usage quantities into the specified tier + * with proration */ - fun addFilter(filter: Filter) = apply { - filters = - (filters ?: JsonField.of(mutableListOf())).also { - checkKnown("filters", it).add(filter) - } - } - - /** Bulk tiers for rating based on total usage volume */ fun tiers(tiers: List) = tiers(JsonField.of(tiers)) /** @@ -19056,21 +23013,19 @@ private constructor( } /** - * Returns an immutable instance of [BulkWithFiltersConfig]. + * Returns an immutable instance of [TieredWithProrationConfig]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```kotlin - * .filters() * .tiers() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): BulkWithFiltersConfig = - BulkWithFiltersConfig( - checkRequired("filters", filters).map { it.toImmutable() }, + fun build(): TieredWithProrationConfig = + TieredWithProrationConfig( checkRequired("tiers", tiers).map { it.toImmutable() }, additionalProperties.toMutableMap(), ) @@ -19078,12 +23033,11 @@ private constructor( private var validated: Boolean = false - fun validate(): BulkWithFiltersConfig = apply { + fun validate(): TieredWithProrationConfig = apply { if (validated) { return@apply } - filters().forEach { it.validate() } tiers().forEach { it.validate() } validated = true } @@ -19098,254 +23052,41 @@ private constructor( /** * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (filters.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + - (tiers.asKnown()?.sumOf { it.validity().toInt() } ?: 0) - - /** Configuration for a single property filter */ - class Filter - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val propertyKey: JsonField, - private val propertyValue: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("property_key") - @ExcludeMissing - propertyKey: JsonField = JsonMissing.of(), - @JsonProperty("property_value") - @ExcludeMissing - propertyValue: JsonField = JsonMissing.of(), - ) : this(propertyKey, propertyValue, mutableMapOf()) - - /** - * Event property key to filter on - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type - * or is unexpectedly missing or null (e.g. if the server responded with - * an unexpected value). - */ - fun propertyKey(): String = propertyKey.getRequired("property_key") - - /** - * Event property value to match - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type - * or is unexpectedly missing or null (e.g. if the server responded with - * an unexpected value). - */ - fun propertyValue(): String = propertyValue.getRequired("property_value") - - /** - * Returns the raw JSON value of [propertyKey]. - * - * Unlike [propertyKey], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("property_key") - @ExcludeMissing - fun _propertyKey(): JsonField = propertyKey - - /** - * Returns the raw JSON value of [propertyValue]. - * - * Unlike [propertyValue], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("property_value") - @ExcludeMissing - fun _propertyValue(): JsonField = propertyValue - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [Filter]. - * - * The following fields are required: - * ```kotlin - * .propertyKey() - * .propertyValue() - * ``` - */ - fun builder() = Builder() - } - - /** A builder for [Filter]. */ - class Builder internal constructor() { - - private var propertyKey: JsonField? = null - private var propertyValue: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - internal fun from(filter: Filter) = apply { - propertyKey = filter.propertyKey - propertyValue = filter.propertyValue - additionalProperties = filter.additionalProperties.toMutableMap() - } - - /** Event property key to filter on */ - fun propertyKey(propertyKey: String) = - propertyKey(JsonField.of(propertyKey)) - - /** - * Sets [Builder.propertyKey] to an arbitrary JSON value. - * - * You should usually call [Builder.propertyKey] with a well-typed - * [String] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun propertyKey(propertyKey: JsonField) = apply { - this.propertyKey = propertyKey - } - - /** Event property value to match */ - fun propertyValue(propertyValue: String) = - propertyValue(JsonField.of(propertyValue)) - - /** - * Sets [Builder.propertyValue] to an arbitrary JSON value. - * - * You should usually call [Builder.propertyValue] with a well-typed - * [String] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun propertyValue(propertyValue: JsonField) = apply { - this.propertyValue = propertyValue - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Filter]. - * - * Further updates to this [Builder] will not mutate the returned - * instance. - * - * The following fields are required: - * ```kotlin - * .propertyKey() - * .propertyValue() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Filter = - Filter( - checkRequired("propertyKey", propertyKey), - checkRequired("propertyValue", propertyValue), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Filter = apply { - if (validated) { - return@apply - } - - propertyKey() - propertyValue() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this - * object recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (if (propertyKey.asKnown() == null) 0 else 1) + - (if (propertyValue.asKnown() == null) 0 else 1) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Filter && - propertyKey == other.propertyKey && - propertyValue == other.propertyValue && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(propertyKey, propertyValue, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Filter{propertyKey=$propertyKey, propertyValue=$propertyValue, additionalProperties=$additionalProperties}" - } + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (tiers.asKnown()?.sumOf { it.validity().toInt() } ?: 0) - /** Configuration for a single bulk pricing tier */ + /** Configuration for a single tiered with proration tier */ class Tier @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val unitAmount: JsonField, private val tierLowerBound: JsonField, + private val unitAmount: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("unit_amount") - @ExcludeMissing - unitAmount: JsonField = JsonMissing.of(), @JsonProperty("tier_lower_bound") @ExcludeMissing tierLowerBound: JsonField = JsonMissing.of(), - ) : this(unitAmount, tierLowerBound, mutableMapOf()) + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(tierLowerBound, unitAmount, mutableMapOf()) + + /** + * Inclusive tier starting value + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun tierLowerBound(): String = + tierLowerBound.getRequired("tier_lower_bound") /** * Amount per unit @@ -19357,13 +23098,14 @@ private constructor( fun unitAmount(): String = unitAmount.getRequired("unit_amount") /** - * The lower bound for this tier + * Returns the raw JSON value of [tierLowerBound]. * - * @throws OrbInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. */ - fun tierLowerBound(): String? = - tierLowerBound.getNullable("tier_lower_bound") + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound /** * Returns the raw JSON value of [unitAmount]. @@ -19375,16 +23117,6 @@ private constructor( @ExcludeMissing fun _unitAmount(): JsonField = unitAmount - /** - * Returns the raw JSON value of [tierLowerBound]. - * - * Unlike [tierLowerBound], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("tier_lower_bound") - @ExcludeMissing - fun _tierLowerBound(): JsonField = tierLowerBound - @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -19404,6 +23136,7 @@ private constructor( * * The following fields are required: * ```kotlin + * .tierLowerBound() * .unitAmount() * ``` */ @@ -19413,45 +23146,45 @@ private constructor( /** A builder for [Tier]. */ class Builder internal constructor() { + private var tierLowerBound: JsonField? = null private var unitAmount: JsonField? = null - private var tierLowerBound: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() internal fun from(tier: Tier) = apply { - unitAmount = tier.unitAmount tierLowerBound = tier.tierLowerBound + unitAmount = tier.unitAmount additionalProperties = tier.additionalProperties.toMutableMap() } - /** Amount per unit */ - fun unitAmount(unitAmount: String) = - unitAmount(JsonField.of(unitAmount)) + /** Inclusive tier starting value */ + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) /** - * Sets [Builder.unitAmount] to an arbitrary JSON value. + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. * - * You should usually call [Builder.unitAmount] with a well-typed + * You should usually call [Builder.tierLowerBound] with a well-typed * [String] value instead. This method is primarily for setting the * field to an undocumented or not yet supported value. */ - fun unitAmount(unitAmount: JsonField) = apply { - this.unitAmount = unitAmount + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound } - /** The lower bound for this tier */ - fun tierLowerBound(tierLowerBound: String?) = - tierLowerBound(JsonField.ofNullable(tierLowerBound)) + /** Amount per unit */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) /** - * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * Sets [Builder.unitAmount] to an arbitrary JSON value. * - * You should usually call [Builder.tierLowerBound] with a well-typed + * You should usually call [Builder.unitAmount] with a well-typed * [String] value instead. This method is primarily for setting the * field to an undocumented or not yet supported value. */ - fun tierLowerBound(tierLowerBound: JsonField) = apply { - this.tierLowerBound = tierLowerBound + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount } fun additionalProperties(additionalProperties: Map) = @@ -19477,253 +23210,94 @@ private constructor( } /** - * Returns an immutable instance of [Tier]. - * - * Further updates to this [Builder] will not mutate the returned - * instance. - * - * The following fields are required: - * ```kotlin - * .unitAmount() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Tier = - Tier( - checkRequired("unitAmount", unitAmount), - tierLowerBound, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Tier = apply { - if (validated) { - return@apply - } - - unitAmount() - tierLowerBound() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this - * object recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (if (unitAmount.asKnown() == null) 0 else 1) + - (if (tierLowerBound.asKnown() == null) 0 else 1) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Tier && - unitAmount == other.unitAmount && - tierLowerBound == other.tierLowerBound && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(unitAmount, tierLowerBound, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Tier{unitAmount=$unitAmount, tierLowerBound=$tierLowerBound, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is BulkWithFiltersConfig && - filters == other.filters && - tiers == other.tiers && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(filters, tiers, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BulkWithFiltersConfig{filters=$filters, tiers=$tiers, additionalProperties=$additionalProperties}" - } - - /** The cadence to bill for this price on. */ - class Cadence - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - val ANNUAL = of("annual") - - val SEMI_ANNUAL = of("semi_annual") - - val MONTHLY = of("monthly") - - val QUARTERLY = of("quarterly") - - val ONE_TIME = of("one_time") - - val CUSTOM = of("custom") - - fun of(value: String) = Cadence(JsonField.of(value)) - } - - /** An enum containing [Cadence]'s known values. */ - enum class Known { - ANNUAL, - SEMI_ANNUAL, - MONTHLY, - QUARTERLY, - ONE_TIME, - CUSTOM, - } - - /** - * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Cadence] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - ANNUAL, - SEMI_ANNUAL, - MONTHLY, - QUARTERLY, - ONE_TIME, - CUSTOM, - /** - * An enum member indicating that [Cadence] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - ANNUAL -> Value.ANNUAL - SEMI_ANNUAL -> Value.SEMI_ANNUAL - MONTHLY -> Value.MONTHLY - QUARTERLY -> Value.QUARTERLY - ONE_TIME -> Value.ONE_TIME - CUSTOM -> Value.CUSTOM - else -> Value._UNKNOWN + * Returns an immutable instance of [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```kotlin + * .tierLowerBound() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("tierLowerBound", tierLowerBound), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) } - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - ANNUAL -> Known.ANNUAL - SEMI_ANNUAL -> Known.SEMI_ANNUAL - MONTHLY -> Known.MONTHLY - QUARTERLY -> Known.QUARTERLY - ONE_TIME -> Known.ONE_TIME - CUSTOM -> Known.CUSTOM - else -> throw OrbInvalidDataException("Unknown Cadence: $value") + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + tierLowerBound() + unitAmount() + validated = true } - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString() - ?: throw OrbInvalidDataException("Value is not a String") + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - private var validated: Boolean = false + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (tierLowerBound.asKnown() == null) 0 else 1) + + (if (unitAmount.asKnown() == null) 0 else 1) - fun validate(): Cadence = apply { - if (validated) { - return@apply - } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - known() - validated = true - } + return other is Tier && + tierLowerBound == other.tierLowerBound && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false + private val hashCode: Int by lazy { + Objects.hash(tierLowerBound, unitAmount, additionalProperties) } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is Cadence && value == other.value + return other is TieredWithProrationConfig && + tiers == other.tiers && + additionalProperties == other.additionalProperties } - override fun hashCode() = value.hashCode() + private val hashCode: Int by lazy { Objects.hash(tiers, additionalProperties) } - override fun toString() = value.toString() + override fun hashCode(): Int = hashCode + + override fun toString() = + "TieredWithProrationConfig{tiers=$tiers, additionalProperties=$additionalProperties}" } /** @@ -19840,12 +23414,12 @@ private constructor( return true } - return other is BulkWithFilters && - bulkWithFiltersConfig == other.bulkWithFiltersConfig && + return other is TieredWithProration && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && + tieredWithProrationConfig == other.tieredWithProrationConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && @@ -19864,11 +23438,11 @@ private constructor( private val hashCode: Int by lazy { Objects.hash( - bulkWithFiltersConfig, cadence, itemId, modelType, name, + tieredWithProrationConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -19889,17 +23463,18 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "BulkWithFilters{bulkWithFiltersConfig=$bulkWithFiltersConfig, cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "TieredWithProration{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredWithProrationConfig=$tieredWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class TieredWithProration + class GroupedWithMinMaxThresholds @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, + private val groupedWithMinMaxThresholdsConfig: + JsonField, private val itemId: JsonField, private val modelType: JsonValue, private val name: JsonField, - private val tieredWithProrationConfig: JsonField, private val billableMetricId: JsonField, private val billedInAdvance: JsonField, private val billingCycleConfiguration: JsonField, @@ -19922,6 +23497,11 @@ private constructor( @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), + @JsonProperty("grouped_with_min_max_thresholds_config") + @ExcludeMissing + groupedWithMinMaxThresholdsConfig: + JsonField = + JsonMissing.of(), @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), @@ -19931,10 +23511,6 @@ private constructor( @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("tiered_with_proration_config") - @ExcludeMissing - tieredWithProrationConfig: JsonField = - JsonMissing.of(), @JsonProperty("billable_metric_id") @ExcludeMissing billableMetricId: JsonField = JsonMissing.of(), @@ -19979,10 +23555,10 @@ private constructor( referenceId: JsonField = JsonMissing.of(), ) : this( cadence, + groupedWithMinMaxThresholdsConfig, itemId, modelType, name, - tieredWithProrationConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -20008,6 +23584,18 @@ private constructor( */ fun cadence(): Cadence = cadence.getRequired("cadence") + /** + * Configuration for grouped_with_min_max_thresholds pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupedWithMinMaxThresholdsConfig(): GroupedWithMinMaxThresholdsConfig = + groupedWithMinMaxThresholdsConfig.getRequired( + "grouped_with_min_max_thresholds_config" + ) + /** * The id of the item the price will be associated with. * @@ -20022,7 +23610,7 @@ private constructor( * * Expected to always return the following: * ```kotlin - * JsonValue.from("tiered_with_proration") + * JsonValue.from("grouped_with_min_max_thresholds") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -20039,16 +23627,6 @@ private constructor( */ fun name(): String = name.getRequired("name") - /** - * Configuration for tiered_with_proration pricing - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun tieredWithProrationConfig(): TieredWithProrationConfig = - tieredWithProrationConfig.getRequired("tiered_with_proration_config") - /** * The id of the billable metric for the price. Only needed if the price is * usage-based. @@ -20178,6 +23756,17 @@ private constructor( @ExcludeMissing fun _cadence(): JsonField = cadence + /** + * Returns the raw JSON value of [groupedWithMinMaxThresholdsConfig]. + * + * Unlike [groupedWithMinMaxThresholdsConfig], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("grouped_with_min_max_thresholds_config") + @ExcludeMissing + fun _groupedWithMinMaxThresholdsConfig(): + JsonField = groupedWithMinMaxThresholdsConfig + /** * Returns the raw JSON value of [itemId]. * @@ -20194,17 +23783,6 @@ private constructor( */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - /** - * Returns the raw JSON value of [tieredWithProrationConfig]. - * - * Unlike [tieredWithProrationConfig], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("tiered_with_proration_config") - @ExcludeMissing - fun _tieredWithProrationConfig(): JsonField = - tieredWithProrationConfig - /** * Returns the raw JSON value of [billableMetricId]. * @@ -20354,28 +23932,30 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [TieredWithProration]. + * [GroupedWithMinMaxThresholds]. * * The following fields are required: * ```kotlin * .cadence() + * .groupedWithMinMaxThresholdsConfig() * .itemId() * .name() - * .tieredWithProrationConfig() * ``` */ fun builder() = Builder() } - /** A builder for [TieredWithProration]. */ + /** A builder for [GroupedWithMinMaxThresholds]. */ class Builder internal constructor() { private var cadence: JsonField? = null + private var groupedWithMinMaxThresholdsConfig: + JsonField? = + null private var itemId: JsonField? = null - private var modelType: JsonValue = JsonValue.from("tiered_with_proration") + private var modelType: JsonValue = + JsonValue.from("grouped_with_min_max_thresholds") private var name: JsonField? = null - private var tieredWithProrationConfig: JsonField? = - null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() private var billingCycleConfiguration: JsonField = @@ -20397,30 +23977,33 @@ private constructor( private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(tieredWithProration: TieredWithProration) = apply { - cadence = tieredWithProration.cadence - itemId = tieredWithProration.itemId - modelType = tieredWithProration.modelType - name = tieredWithProration.name - tieredWithProrationConfig = tieredWithProration.tieredWithProrationConfig - billableMetricId = tieredWithProration.billableMetricId - billedInAdvance = tieredWithProration.billedInAdvance - billingCycleConfiguration = tieredWithProration.billingCycleConfiguration - conversionRate = tieredWithProration.conversionRate - conversionRateConfig = tieredWithProration.conversionRateConfig - currency = tieredWithProration.currency - dimensionalPriceConfiguration = - tieredWithProration.dimensionalPriceConfiguration - externalPriceId = tieredWithProration.externalPriceId - fixedPriceQuantity = tieredWithProration.fixedPriceQuantity - invoiceGroupingKey = tieredWithProration.invoiceGroupingKey - invoicingCycleConfiguration = - tieredWithProration.invoicingCycleConfiguration - metadata = tieredWithProration.metadata - referenceId = tieredWithProration.referenceId - additionalProperties = - tieredWithProration.additionalProperties.toMutableMap() - } + internal fun from(groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds) = + apply { + cadence = groupedWithMinMaxThresholds.cadence + groupedWithMinMaxThresholdsConfig = + groupedWithMinMaxThresholds.groupedWithMinMaxThresholdsConfig + itemId = groupedWithMinMaxThresholds.itemId + modelType = groupedWithMinMaxThresholds.modelType + name = groupedWithMinMaxThresholds.name + billableMetricId = groupedWithMinMaxThresholds.billableMetricId + billedInAdvance = groupedWithMinMaxThresholds.billedInAdvance + billingCycleConfiguration = + groupedWithMinMaxThresholds.billingCycleConfiguration + conversionRate = groupedWithMinMaxThresholds.conversionRate + conversionRateConfig = groupedWithMinMaxThresholds.conversionRateConfig + currency = groupedWithMinMaxThresholds.currency + dimensionalPriceConfiguration = + groupedWithMinMaxThresholds.dimensionalPriceConfiguration + externalPriceId = groupedWithMinMaxThresholds.externalPriceId + fixedPriceQuantity = groupedWithMinMaxThresholds.fixedPriceQuantity + invoiceGroupingKey = groupedWithMinMaxThresholds.invoiceGroupingKey + invoicingCycleConfiguration = + groupedWithMinMaxThresholds.invoicingCycleConfiguration + metadata = groupedWithMinMaxThresholds.metadata + referenceId = groupedWithMinMaxThresholds.referenceId + additionalProperties = + groupedWithMinMaxThresholds.additionalProperties.toMutableMap() + } /** The cadence to bill for this price on. */ fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) @@ -20434,6 +24017,29 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + /** Configuration for grouped_with_min_max_thresholds pricing */ + fun groupedWithMinMaxThresholdsConfig( + groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + ) = + groupedWithMinMaxThresholdsConfig( + JsonField.of(groupedWithMinMaxThresholdsConfig) + ) + + /** + * Sets [Builder.groupedWithMinMaxThresholdsConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.groupedWithMinMaxThresholdsConfig] with a + * well-typed [GroupedWithMinMaxThresholdsConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun groupedWithMinMaxThresholdsConfig( + groupedWithMinMaxThresholdsConfig: + JsonField + ) = apply { + this.groupedWithMinMaxThresholdsConfig = groupedWithMinMaxThresholdsConfig + } + /** The id of the item the price will be associated with. */ fun itemId(itemId: String) = itemId(JsonField.of(itemId)) @@ -20452,7 +24058,7 @@ private constructor( * It is usually unnecessary to call this method because the field defaults to * the following: * ```kotlin - * JsonValue.from("tiered_with_proration") + * JsonValue.from("grouped_with_min_max_thresholds") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -20472,22 +24078,6 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } - /** Configuration for tiered_with_proration pricing */ - fun tieredWithProrationConfig( - tieredWithProrationConfig: TieredWithProrationConfig - ) = tieredWithProrationConfig(JsonField.of(tieredWithProrationConfig)) - - /** - * Sets [Builder.tieredWithProrationConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.tieredWithProrationConfig] with a well-typed - * [TieredWithProrationConfig] value instead. This method is primarily for - * setting the field to an undocumented or not yet supported value. - */ - fun tieredWithProrationConfig( - tieredWithProrationConfig: JsonField - ) = apply { this.tieredWithProrationConfig = tieredWithProrationConfig } - /** * The id of the billable metric for the price. Only needed if the price is * usage-based. @@ -20817,27 +24407,30 @@ private constructor( } /** - * Returns an immutable instance of [TieredWithProration]. + * Returns an immutable instance of [GroupedWithMinMaxThresholds]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```kotlin * .cadence() + * .groupedWithMinMaxThresholdsConfig() * .itemId() * .name() - * .tieredWithProrationConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): TieredWithProration = - TieredWithProration( + fun build(): GroupedWithMinMaxThresholds = + GroupedWithMinMaxThresholds( checkRequired("cadence", cadence), + checkRequired( + "groupedWithMinMaxThresholdsConfig", + groupedWithMinMaxThresholdsConfig, + ), checkRequired("itemId", itemId), modelType, checkRequired("name", name), - checkRequired("tieredWithProrationConfig", tieredWithProrationConfig), billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -20857,20 +24450,20 @@ private constructor( private var validated: Boolean = false - fun validate(): TieredWithProration = apply { + fun validate(): GroupedWithMinMaxThresholds = apply { if (validated) { return@apply } cadence().validate() + groupedWithMinMaxThresholdsConfig().validate() itemId() _modelType().let { - if (it != JsonValue.from("tiered_with_proration")) { + if (it != JsonValue.from("grouped_with_min_max_thresholds")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } name() - tieredWithProrationConfig().validate() billableMetricId() billedInAdvance() billingCycleConfiguration()?.validate() @@ -20903,12 +24496,12 @@ private constructor( */ internal fun validity(): Int = (cadence.asKnown()?.validity() ?: 0) + + (groupedWithMinMaxThresholdsConfig.asKnown()?.validity() ?: 0) + (if (itemId.asKnown() == null) 0 else 1) + modelType.let { - if (it == JsonValue.from("tiered_with_proration")) 1 else 0 + if (it == JsonValue.from("grouped_with_min_max_thresholds")) 1 else 0 } + (if (name.asKnown() == null) 0 else 1) + - (tieredWithProrationConfig.asKnown()?.validity() ?: 0) + (if (billableMetricId.asKnown() == null) 0 else 1) + (if (billedInAdvance.asKnown() == null) 0 else 1) + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + @@ -21080,40 +24673,108 @@ private constructor( override fun toString() = value.toString() } - /** Configuration for tiered_with_proration pricing */ - class TieredWithProrationConfig + /** Configuration for grouped_with_min_max_thresholds pricing */ + class GroupedWithMinMaxThresholdsConfig @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val tiers: JsonField>, + private val groupingKey: JsonField, + private val maximumCharge: JsonField, + private val minimumCharge: JsonField, + private val perUnitRate: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("tiers") + @JsonProperty("grouping_key") @ExcludeMissing - tiers: JsonField> = JsonMissing.of() - ) : this(tiers, mutableMapOf()) + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("maximum_charge") + @ExcludeMissing + maximumCharge: JsonField = JsonMissing.of(), + @JsonProperty("minimum_charge") + @ExcludeMissing + minimumCharge: JsonField = JsonMissing.of(), + @JsonProperty("per_unit_rate") + @ExcludeMissing + perUnitRate: JsonField = JsonMissing.of(), + ) : this(groupingKey, maximumCharge, minimumCharge, perUnitRate, mutableMapOf()) /** - * Tiers for rating based on total usage quantities into the specified tier with - * proration + * The event property used to group before applying thresholds * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). */ - fun tiers(): List = tiers.getRequired("tiers") + fun groupingKey(): String = groupingKey.getRequired("grouping_key") /** - * Returns the raw JSON value of [tiers]. + * The maximum amount to charge each group * - * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected - * type. + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). */ - @JsonProperty("tiers") + fun maximumCharge(): String = maximumCharge.getRequired("maximum_charge") + + /** + * The minimum amount to charge each group, regardless of usage + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun minimumCharge(): String = minimumCharge.getRequired("minimum_charge") + + /** + * The base price charged per group + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun perUnitRate(): String = perUnitRate.getRequired("per_unit_rate") + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") @ExcludeMissing - fun _tiers(): JsonField> = tiers + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [maximumCharge]. + * + * Unlike [maximumCharge], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("maximum_charge") + @ExcludeMissing + fun _maximumCharge(): JsonField = maximumCharge + + /** + * Returns the raw JSON value of [minimumCharge]. + * + * Unlike [minimumCharge], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("minimum_charge") + @ExcludeMissing + fun _minimumCharge(): JsonField = minimumCharge + + /** + * Returns the raw JSON value of [perUnitRate]. + * + * Unlike [perUnitRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("per_unit_rate") + @ExcludeMissing + fun _perUnitRate(): JsonField = perUnitRate @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -21131,58 +24792,99 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [TieredWithProrationConfig]. + * [GroupedWithMinMaxThresholdsConfig]. * * The following fields are required: * ```kotlin - * .tiers() + * .groupingKey() + * .maximumCharge() + * .minimumCharge() + * .perUnitRate() * ``` */ fun builder() = Builder() } - /** A builder for [TieredWithProrationConfig]. */ + /** A builder for [GroupedWithMinMaxThresholdsConfig]. */ class Builder internal constructor() { - private var tiers: JsonField>? = null + private var groupingKey: JsonField? = null + private var maximumCharge: JsonField? = null + private var minimumCharge: JsonField? = null + private var perUnitRate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(tieredWithProrationConfig: TieredWithProrationConfig) = - apply { - tiers = tieredWithProrationConfig.tiers.map { it.toMutableList() } - additionalProperties = - tieredWithProrationConfig.additionalProperties.toMutableMap() - } + internal fun from( + groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + ) = apply { + groupingKey = groupedWithMinMaxThresholdsConfig.groupingKey + maximumCharge = groupedWithMinMaxThresholdsConfig.maximumCharge + minimumCharge = groupedWithMinMaxThresholdsConfig.minimumCharge + perUnitRate = groupedWithMinMaxThresholdsConfig.perUnitRate + additionalProperties = + groupedWithMinMaxThresholdsConfig.additionalProperties + .toMutableMap() + } - /** - * Tiers for rating based on total usage quantities into the specified tier - * with proration - */ - fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + /** The event property used to group before applying thresholds */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) /** - * Sets [Builder.tiers] to an arbitrary JSON value. + * Sets [Builder.groupingKey] to an arbitrary JSON value. * - * You should usually call [Builder.tiers] with a well-typed `List` + * You should usually call [Builder.groupingKey] with a well-typed [String] * value instead. This method is primarily for setting the field to an * undocumented or not yet supported value. */ - fun tiers(tiers: JsonField>) = apply { - this.tiers = tiers.map { it.toMutableList() } + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey } + /** The maximum amount to charge each group */ + fun maximumCharge(maximumCharge: String) = + maximumCharge(JsonField.of(maximumCharge)) + /** - * Adds a single [Tier] to [tiers]. + * Sets [Builder.maximumCharge] to an arbitrary JSON value. * - * @throws IllegalStateException if the field was previously set to a - * non-list. + * You should usually call [Builder.maximumCharge] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. */ - fun addTier(tier: Tier) = apply { - tiers = - (tiers ?: JsonField.of(mutableListOf())).also { - checkKnown("tiers", it).add(tier) - } + fun maximumCharge(maximumCharge: JsonField) = apply { + this.maximumCharge = maximumCharge + } + + /** The minimum amount to charge each group, regardless of usage */ + fun minimumCharge(minimumCharge: String) = + minimumCharge(JsonField.of(minimumCharge)) + + /** + * Sets [Builder.minimumCharge] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumCharge] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun minimumCharge(minimumCharge: JsonField) = apply { + this.minimumCharge = minimumCharge + } + + /** The base price charged per group */ + fun perUnitRate(perUnitRate: String) = + perUnitRate(JsonField.of(perUnitRate)) + + /** + * Sets [Builder.perUnitRate] to an arbitrary JSON value. + * + * You should usually call [Builder.perUnitRate] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun perUnitRate(perUnitRate: JsonField) = apply { + this.perUnitRate = perUnitRate } fun additionalProperties(additionalProperties: Map) = @@ -21208,291 +24910,91 @@ private constructor( } /** - * Returns an immutable instance of [TieredWithProrationConfig]. + * Returns an immutable instance of [GroupedWithMinMaxThresholdsConfig]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```kotlin - * .tiers() + * .groupingKey() + * .maximumCharge() + * .minimumCharge() + * .perUnitRate() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): TieredWithProrationConfig = - TieredWithProrationConfig( - checkRequired("tiers", tiers).map { it.toImmutable() }, + fun build(): GroupedWithMinMaxThresholdsConfig = + GroupedWithMinMaxThresholdsConfig( + checkRequired("groupingKey", groupingKey), + checkRequired("maximumCharge", maximumCharge), + checkRequired("minimumCharge", minimumCharge), + checkRequired("perUnitRate", perUnitRate), additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): TieredWithProrationConfig = apply { + fun validate(): GroupedWithMinMaxThresholdsConfig = apply { if (validated) { return@apply } - tiers().forEach { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (tiers.asKnown()?.sumOf { it.validity().toInt() } ?: 0) - - /** Configuration for a single tiered with proration tier */ - class Tier - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val tierLowerBound: JsonField, - private val unitAmount: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("tier_lower_bound") - @ExcludeMissing - tierLowerBound: JsonField = JsonMissing.of(), - @JsonProperty("unit_amount") - @ExcludeMissing - unitAmount: JsonField = JsonMissing.of(), - ) : this(tierLowerBound, unitAmount, mutableMapOf()) - - /** - * Inclusive tier starting value - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type - * or is unexpectedly missing or null (e.g. if the server responded with - * an unexpected value). - */ - fun tierLowerBound(): String = - tierLowerBound.getRequired("tier_lower_bound") - - /** - * Amount per unit - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type - * or is unexpectedly missing or null (e.g. if the server responded with - * an unexpected value). - */ - fun unitAmount(): String = unitAmount.getRequired("unit_amount") - - /** - * Returns the raw JSON value of [tierLowerBound]. - * - * Unlike [tierLowerBound], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("tier_lower_bound") - @ExcludeMissing - fun _tierLowerBound(): JsonField = tierLowerBound - - /** - * Returns the raw JSON value of [unitAmount]. - * - * Unlike [unitAmount], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("unit_amount") - @ExcludeMissing - fun _unitAmount(): JsonField = unitAmount - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [Tier]. - * - * The following fields are required: - * ```kotlin - * .tierLowerBound() - * .unitAmount() - * ``` - */ - fun builder() = Builder() - } - - /** A builder for [Tier]. */ - class Builder internal constructor() { - - private var tierLowerBound: JsonField? = null - private var unitAmount: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - internal fun from(tier: Tier) = apply { - tierLowerBound = tier.tierLowerBound - unitAmount = tier.unitAmount - additionalProperties = tier.additionalProperties.toMutableMap() - } - - /** Inclusive tier starting value */ - fun tierLowerBound(tierLowerBound: String) = - tierLowerBound(JsonField.of(tierLowerBound)) - - /** - * Sets [Builder.tierLowerBound] to an arbitrary JSON value. - * - * You should usually call [Builder.tierLowerBound] with a well-typed - * [String] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun tierLowerBound(tierLowerBound: JsonField) = apply { - this.tierLowerBound = tierLowerBound - } - - /** Amount per unit */ - fun unitAmount(unitAmount: String) = - unitAmount(JsonField.of(unitAmount)) - - /** - * Sets [Builder.unitAmount] to an arbitrary JSON value. - * - * You should usually call [Builder.unitAmount] with a well-typed - * [String] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun unitAmount(unitAmount: JsonField) = apply { - this.unitAmount = unitAmount - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Tier]. - * - * Further updates to this [Builder] will not mutate the returned - * instance. - * - * The following fields are required: - * ```kotlin - * .tierLowerBound() - * .unitAmount() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Tier = - Tier( - checkRequired("tierLowerBound", tierLowerBound), - checkRequired("unitAmount", unitAmount), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Tier = apply { - if (validated) { - return@apply - } - - tierLowerBound() - unitAmount() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this - * object recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (if (tierLowerBound.asKnown() == null) 0 else 1) + - (if (unitAmount.asKnown() == null) 0 else 1) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Tier && - tierLowerBound == other.tierLowerBound && - unitAmount == other.unitAmount && - additionalProperties == other.additionalProperties - } + groupingKey() + maximumCharge() + minimumCharge() + perUnitRate() + validated = true + } - private val hashCode: Int by lazy { - Objects.hash(tierLowerBound, unitAmount, additionalProperties) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false } - override fun hashCode(): Int = hashCode - - override fun toString() = - "Tier{tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" - } + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (groupingKey.asKnown() == null) 0 else 1) + + (if (maximumCharge.asKnown() == null) 0 else 1) + + (if (minimumCharge.asKnown() == null) 0 else 1) + + (if (perUnitRate.asKnown() == null) 0 else 1) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is TieredWithProrationConfig && - tiers == other.tiers && + return other is GroupedWithMinMaxThresholdsConfig && + groupingKey == other.groupingKey && + maximumCharge == other.maximumCharge && + minimumCharge == other.minimumCharge && + perUnitRate == other.perUnitRate && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(tiers, additionalProperties) } + private val hashCode: Int by lazy { + Objects.hash( + groupingKey, + maximumCharge, + minimumCharge, + perUnitRate, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode override fun toString() = - "TieredWithProrationConfig{tiers=$tiers, additionalProperties=$additionalProperties}" + "GroupedWithMinMaxThresholdsConfig{groupingKey=$groupingKey, maximumCharge=$maximumCharge, minimumCharge=$minimumCharge, perUnitRate=$perUnitRate, additionalProperties=$additionalProperties}" } /** @@ -21609,12 +25111,13 @@ private constructor( return true } - return other is TieredWithProration && + return other is GroupedWithMinMaxThresholds && cadence == other.cadence && + groupedWithMinMaxThresholdsConfig == + other.groupedWithMinMaxThresholdsConfig && itemId == other.itemId && modelType == other.modelType && name == other.name && - tieredWithProrationConfig == other.tieredWithProrationConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && @@ -21634,10 +25137,10 @@ private constructor( private val hashCode: Int by lazy { Objects.hash( cadence, + groupedWithMinMaxThresholdsConfig, itemId, modelType, name, - tieredWithProrationConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -21658,15 +25161,15 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "TieredWithProration{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredWithProrationConfig=$tieredWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "GroupedWithMinMaxThresholds{cadence=$cadence, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class GroupedWithMinMaxThresholds + class CumulativeGroupedAllocation @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, - private val groupedWithMinMaxThresholdsConfig: - JsonField, + private val cumulativeGroupedAllocationConfig: + JsonField, private val itemId: JsonField, private val modelType: JsonValue, private val name: JsonField, @@ -21692,10 +25195,10 @@ private constructor( @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), - @JsonProperty("grouped_with_min_max_thresholds_config") + @JsonProperty("cumulative_grouped_allocation_config") @ExcludeMissing - groupedWithMinMaxThresholdsConfig: - JsonField = + cumulativeGroupedAllocationConfig: + JsonField = JsonMissing.of(), @JsonProperty("item_id") @ExcludeMissing @@ -21750,7 +25253,7 @@ private constructor( referenceId: JsonField = JsonMissing.of(), ) : this( cadence, - groupedWithMinMaxThresholdsConfig, + cumulativeGroupedAllocationConfig, itemId, modelType, name, @@ -21780,15 +25283,15 @@ private constructor( fun cadence(): Cadence = cadence.getRequired("cadence") /** - * Configuration for grouped_with_min_max_thresholds pricing + * Configuration for cumulative_grouped_allocation pricing * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected * value). */ - fun groupedWithMinMaxThresholdsConfig(): GroupedWithMinMaxThresholdsConfig = - groupedWithMinMaxThresholdsConfig.getRequired( - "grouped_with_min_max_thresholds_config" + fun cumulativeGroupedAllocationConfig(): CumulativeGroupedAllocationConfig = + cumulativeGroupedAllocationConfig.getRequired( + "cumulative_grouped_allocation_config" ) /** @@ -21805,7 +25308,7 @@ private constructor( * * Expected to always return the following: * ```kotlin - * JsonValue.from("grouped_with_min_max_thresholds") + * JsonValue.from("cumulative_grouped_allocation") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -21952,15 +25455,15 @@ private constructor( fun _cadence(): JsonField = cadence /** - * Returns the raw JSON value of [groupedWithMinMaxThresholdsConfig]. + * Returns the raw JSON value of [cumulativeGroupedAllocationConfig]. * - * Unlike [groupedWithMinMaxThresholdsConfig], this method doesn't throw if the JSON + * Unlike [cumulativeGroupedAllocationConfig], this method doesn't throw if the JSON * field has an unexpected type. */ - @JsonProperty("grouped_with_min_max_thresholds_config") + @JsonProperty("cumulative_grouped_allocation_config") @ExcludeMissing - fun _groupedWithMinMaxThresholdsConfig(): - JsonField = groupedWithMinMaxThresholdsConfig + fun _cumulativeGroupedAllocationConfig(): + JsonField = cumulativeGroupedAllocationConfig /** * Returns the raw JSON value of [itemId]. @@ -22127,12 +25630,12 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [GroupedWithMinMaxThresholds]. + * [CumulativeGroupedAllocation]. * * The following fields are required: * ```kotlin * .cadence() - * .groupedWithMinMaxThresholdsConfig() + * .cumulativeGroupedAllocationConfig() * .itemId() * .name() * ``` @@ -22140,16 +25643,16 @@ private constructor( fun builder() = Builder() } - /** A builder for [GroupedWithMinMaxThresholds]. */ + /** A builder for [CumulativeGroupedAllocation]. */ class Builder internal constructor() { private var cadence: JsonField? = null - private var groupedWithMinMaxThresholdsConfig: - JsonField? = + private var cumulativeGroupedAllocationConfig: + JsonField? = null private var itemId: JsonField? = null private var modelType: JsonValue = - JsonValue.from("grouped_with_min_max_thresholds") + JsonValue.from("cumulative_grouped_allocation") private var name: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() @@ -22172,32 +25675,32 @@ private constructor( private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds) = + internal fun from(cumulativeGroupedAllocation: CumulativeGroupedAllocation) = apply { - cadence = groupedWithMinMaxThresholds.cadence - groupedWithMinMaxThresholdsConfig = - groupedWithMinMaxThresholds.groupedWithMinMaxThresholdsConfig - itemId = groupedWithMinMaxThresholds.itemId - modelType = groupedWithMinMaxThresholds.modelType - name = groupedWithMinMaxThresholds.name - billableMetricId = groupedWithMinMaxThresholds.billableMetricId - billedInAdvance = groupedWithMinMaxThresholds.billedInAdvance + cadence = cumulativeGroupedAllocation.cadence + cumulativeGroupedAllocationConfig = + cumulativeGroupedAllocation.cumulativeGroupedAllocationConfig + itemId = cumulativeGroupedAllocation.itemId + modelType = cumulativeGroupedAllocation.modelType + name = cumulativeGroupedAllocation.name + billableMetricId = cumulativeGroupedAllocation.billableMetricId + billedInAdvance = cumulativeGroupedAllocation.billedInAdvance billingCycleConfiguration = - groupedWithMinMaxThresholds.billingCycleConfiguration - conversionRate = groupedWithMinMaxThresholds.conversionRate - conversionRateConfig = groupedWithMinMaxThresholds.conversionRateConfig - currency = groupedWithMinMaxThresholds.currency + cumulativeGroupedAllocation.billingCycleConfiguration + conversionRate = cumulativeGroupedAllocation.conversionRate + conversionRateConfig = cumulativeGroupedAllocation.conversionRateConfig + currency = cumulativeGroupedAllocation.currency dimensionalPriceConfiguration = - groupedWithMinMaxThresholds.dimensionalPriceConfiguration - externalPriceId = groupedWithMinMaxThresholds.externalPriceId - fixedPriceQuantity = groupedWithMinMaxThresholds.fixedPriceQuantity - invoiceGroupingKey = groupedWithMinMaxThresholds.invoiceGroupingKey + cumulativeGroupedAllocation.dimensionalPriceConfiguration + externalPriceId = cumulativeGroupedAllocation.externalPriceId + fixedPriceQuantity = cumulativeGroupedAllocation.fixedPriceQuantity + invoiceGroupingKey = cumulativeGroupedAllocation.invoiceGroupingKey invoicingCycleConfiguration = - groupedWithMinMaxThresholds.invoicingCycleConfiguration - metadata = groupedWithMinMaxThresholds.metadata - referenceId = groupedWithMinMaxThresholds.referenceId + cumulativeGroupedAllocation.invoicingCycleConfiguration + metadata = cumulativeGroupedAllocation.metadata + referenceId = cumulativeGroupedAllocation.referenceId additionalProperties = - groupedWithMinMaxThresholds.additionalProperties.toMutableMap() + cumulativeGroupedAllocation.additionalProperties.toMutableMap() } /** The cadence to bill for this price on. */ @@ -22212,27 +25715,27 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - /** Configuration for grouped_with_min_max_thresholds pricing */ - fun groupedWithMinMaxThresholdsConfig( - groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + /** Configuration for cumulative_grouped_allocation pricing */ + fun cumulativeGroupedAllocationConfig( + cumulativeGroupedAllocationConfig: CumulativeGroupedAllocationConfig ) = - groupedWithMinMaxThresholdsConfig( - JsonField.of(groupedWithMinMaxThresholdsConfig) + cumulativeGroupedAllocationConfig( + JsonField.of(cumulativeGroupedAllocationConfig) ) /** - * Sets [Builder.groupedWithMinMaxThresholdsConfig] to an arbitrary JSON value. + * Sets [Builder.cumulativeGroupedAllocationConfig] to an arbitrary JSON value. * - * You should usually call [Builder.groupedWithMinMaxThresholdsConfig] with a - * well-typed [GroupedWithMinMaxThresholdsConfig] value instead. This method is + * You should usually call [Builder.cumulativeGroupedAllocationConfig] with a + * well-typed [CumulativeGroupedAllocationConfig] value instead. This method is * primarily for setting the field to an undocumented or not yet supported * value. */ - fun groupedWithMinMaxThresholdsConfig( - groupedWithMinMaxThresholdsConfig: - JsonField + fun cumulativeGroupedAllocationConfig( + cumulativeGroupedAllocationConfig: + JsonField ) = apply { - this.groupedWithMinMaxThresholdsConfig = groupedWithMinMaxThresholdsConfig + this.cumulativeGroupedAllocationConfig = cumulativeGroupedAllocationConfig } /** The id of the item the price will be associated with. */ @@ -22253,7 +25756,7 @@ private constructor( * It is usually unnecessary to call this method because the field defaults to * the following: * ```kotlin - * JsonValue.from("grouped_with_min_max_thresholds") + * JsonValue.from("cumulative_grouped_allocation") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -22602,26 +26105,26 @@ private constructor( } /** - * Returns an immutable instance of [GroupedWithMinMaxThresholds]. + * Returns an immutable instance of [CumulativeGroupedAllocation]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```kotlin * .cadence() - * .groupedWithMinMaxThresholdsConfig() + * .cumulativeGroupedAllocationConfig() * .itemId() * .name() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): GroupedWithMinMaxThresholds = - GroupedWithMinMaxThresholds( + fun build(): CumulativeGroupedAllocation = + CumulativeGroupedAllocation( checkRequired("cadence", cadence), checkRequired( - "groupedWithMinMaxThresholdsConfig", - groupedWithMinMaxThresholdsConfig, + "cumulativeGroupedAllocationConfig", + cumulativeGroupedAllocationConfig, ), checkRequired("itemId", itemId), modelType, @@ -22645,16 +26148,16 @@ private constructor( private var validated: Boolean = false - fun validate(): GroupedWithMinMaxThresholds = apply { + fun validate(): CumulativeGroupedAllocation = apply { if (validated) { return@apply } cadence().validate() - groupedWithMinMaxThresholdsConfig().validate() + cumulativeGroupedAllocationConfig().validate() itemId() _modelType().let { - if (it != JsonValue.from("grouped_with_min_max_thresholds")) { + if (it != JsonValue.from("cumulative_grouped_allocation")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } @@ -22691,10 +26194,10 @@ private constructor( */ internal fun validity(): Int = (cadence.asKnown()?.validity() ?: 0) + - (groupedWithMinMaxThresholdsConfig.asKnown()?.validity() ?: 0) + + (cumulativeGroupedAllocationConfig.asKnown()?.validity() ?: 0) + (if (itemId.asKnown() == null) 0 else 1) + modelType.let { - if (it == JsonValue.from("grouped_with_min_max_thresholds")) 1 else 0 + if (it == JsonValue.from("cumulative_grouped_allocation")) 1 else 0 } + (if (name.asKnown() == null) 0 else 1) + (if (billableMetricId.asKnown() == null) 0 else 1) + @@ -22868,108 +26371,115 @@ private constructor( override fun toString() = value.toString() } - /** Configuration for grouped_with_min_max_thresholds pricing */ - class GroupedWithMinMaxThresholdsConfig + /** Configuration for cumulative_grouped_allocation pricing */ + class CumulativeGroupedAllocationConfig @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( + private val cumulativeAllocation: JsonField, + private val groupAllocation: JsonField, private val groupingKey: JsonField, - private val maximumCharge: JsonField, - private val minimumCharge: JsonField, - private val perUnitRate: JsonField, + private val unitAmount: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("grouping_key") + @JsonProperty("cumulative_allocation") @ExcludeMissing - groupingKey: JsonField = JsonMissing.of(), - @JsonProperty("maximum_charge") + cumulativeAllocation: JsonField = JsonMissing.of(), + @JsonProperty("group_allocation") @ExcludeMissing - maximumCharge: JsonField = JsonMissing.of(), - @JsonProperty("minimum_charge") + groupAllocation: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") @ExcludeMissing - minimumCharge: JsonField = JsonMissing.of(), - @JsonProperty("per_unit_rate") + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") @ExcludeMissing - perUnitRate: JsonField = JsonMissing.of(), - ) : this(groupingKey, maximumCharge, minimumCharge, perUnitRate, mutableMapOf()) + unitAmount: JsonField = JsonMissing.of(), + ) : this( + cumulativeAllocation, + groupAllocation, + groupingKey, + unitAmount, + mutableMapOf(), + ) /** - * The event property used to group before applying thresholds + * The overall allocation across all groups * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). */ - fun groupingKey(): String = groupingKey.getRequired("grouping_key") + fun cumulativeAllocation(): String = + cumulativeAllocation.getRequired("cumulative_allocation") /** - * The maximum amount to charge each group + * The allocation per individual group * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). */ - fun maximumCharge(): String = maximumCharge.getRequired("maximum_charge") + fun groupAllocation(): String = groupAllocation.getRequired("group_allocation") /** - * The minimum amount to charge each group, regardless of usage + * The event property used to group usage before applying allocations * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). */ - fun minimumCharge(): String = minimumCharge.getRequired("minimum_charge") + fun groupingKey(): String = groupingKey.getRequired("grouping_key") /** - * The base price charged per group + * The amount to charge for each unit outside of the allocation * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). */ - fun perUnitRate(): String = perUnitRate.getRequired("per_unit_rate") + fun unitAmount(): String = unitAmount.getRequired("unit_amount") /** - * Returns the raw JSON value of [groupingKey]. + * Returns the raw JSON value of [cumulativeAllocation]. * - * Unlike [groupingKey], this method doesn't throw if the JSON field has an - * unexpected type. + * Unlike [cumulativeAllocation], this method doesn't throw if the JSON field + * has an unexpected type. */ - @JsonProperty("grouping_key") + @JsonProperty("cumulative_allocation") @ExcludeMissing - fun _groupingKey(): JsonField = groupingKey + fun _cumulativeAllocation(): JsonField = cumulativeAllocation /** - * Returns the raw JSON value of [maximumCharge]. + * Returns the raw JSON value of [groupAllocation]. * - * Unlike [maximumCharge], this method doesn't throw if the JSON field has an + * Unlike [groupAllocation], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("maximum_charge") + @JsonProperty("group_allocation") @ExcludeMissing - fun _maximumCharge(): JsonField = maximumCharge + fun _groupAllocation(): JsonField = groupAllocation /** - * Returns the raw JSON value of [minimumCharge]. + * Returns the raw JSON value of [groupingKey]. * - * Unlike [minimumCharge], this method doesn't throw if the JSON field has an + * Unlike [groupingKey], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("minimum_charge") + @JsonProperty("grouping_key") @ExcludeMissing - fun _minimumCharge(): JsonField = minimumCharge + fun _groupingKey(): JsonField = groupingKey /** - * Returns the raw JSON value of [perUnitRate]. + * Returns the raw JSON value of [unitAmount]. * - * Unlike [perUnitRate], this method doesn't throw if the JSON field has an + * Unlike [unitAmount], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("per_unit_rate") + @JsonProperty("unit_amount") @ExcludeMissing - fun _perUnitRate(): JsonField = perUnitRate + fun _unitAmount(): JsonField = unitAmount @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -22987,99 +26497,99 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [GroupedWithMinMaxThresholdsConfig]. + * [CumulativeGroupedAllocationConfig]. * * The following fields are required: * ```kotlin + * .cumulativeAllocation() + * .groupAllocation() * .groupingKey() - * .maximumCharge() - * .minimumCharge() - * .perUnitRate() + * .unitAmount() * ``` */ fun builder() = Builder() } - /** A builder for [GroupedWithMinMaxThresholdsConfig]. */ + /** A builder for [CumulativeGroupedAllocationConfig]. */ class Builder internal constructor() { + private var cumulativeAllocation: JsonField? = null + private var groupAllocation: JsonField? = null private var groupingKey: JsonField? = null - private var maximumCharge: JsonField? = null - private var minimumCharge: JsonField? = null - private var perUnitRate: JsonField? = null + private var unitAmount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from( - groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + cumulativeGroupedAllocationConfig: CumulativeGroupedAllocationConfig ) = apply { - groupingKey = groupedWithMinMaxThresholdsConfig.groupingKey - maximumCharge = groupedWithMinMaxThresholdsConfig.maximumCharge - minimumCharge = groupedWithMinMaxThresholdsConfig.minimumCharge - perUnitRate = groupedWithMinMaxThresholdsConfig.perUnitRate + cumulativeAllocation = + cumulativeGroupedAllocationConfig.cumulativeAllocation + groupAllocation = cumulativeGroupedAllocationConfig.groupAllocation + groupingKey = cumulativeGroupedAllocationConfig.groupingKey + unitAmount = cumulativeGroupedAllocationConfig.unitAmount additionalProperties = - groupedWithMinMaxThresholdsConfig.additionalProperties + cumulativeGroupedAllocationConfig.additionalProperties .toMutableMap() } - /** The event property used to group before applying thresholds */ - fun groupingKey(groupingKey: String) = - groupingKey(JsonField.of(groupingKey)) + /** The overall allocation across all groups */ + fun cumulativeAllocation(cumulativeAllocation: String) = + cumulativeAllocation(JsonField.of(cumulativeAllocation)) /** - * Sets [Builder.groupingKey] to an arbitrary JSON value. + * Sets [Builder.cumulativeAllocation] to an arbitrary JSON value. * - * You should usually call [Builder.groupingKey] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. + * You should usually call [Builder.cumulativeAllocation] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. */ - fun groupingKey(groupingKey: JsonField) = apply { - this.groupingKey = groupingKey + fun cumulativeAllocation(cumulativeAllocation: JsonField) = apply { + this.cumulativeAllocation = cumulativeAllocation } - /** The maximum amount to charge each group */ - fun maximumCharge(maximumCharge: String) = - maximumCharge(JsonField.of(maximumCharge)) + /** The allocation per individual group */ + fun groupAllocation(groupAllocation: String) = + groupAllocation(JsonField.of(groupAllocation)) /** - * Sets [Builder.maximumCharge] to an arbitrary JSON value. + * Sets [Builder.groupAllocation] to an arbitrary JSON value. * - * You should usually call [Builder.maximumCharge] with a well-typed + * You should usually call [Builder.groupAllocation] with a well-typed * [String] value instead. This method is primarily for setting the field to * an undocumented or not yet supported value. */ - fun maximumCharge(maximumCharge: JsonField) = apply { - this.maximumCharge = maximumCharge + fun groupAllocation(groupAllocation: JsonField) = apply { + this.groupAllocation = groupAllocation } - /** The minimum amount to charge each group, regardless of usage */ - fun minimumCharge(minimumCharge: String) = - minimumCharge(JsonField.of(minimumCharge)) + /** The event property used to group usage before applying allocations */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) /** - * Sets [Builder.minimumCharge] to an arbitrary JSON value. + * Sets [Builder.groupingKey] to an arbitrary JSON value. * - * You should usually call [Builder.minimumCharge] with a well-typed - * [String] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. */ - fun minimumCharge(minimumCharge: JsonField) = apply { - this.minimumCharge = minimumCharge + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey } - /** The base price charged per group */ - fun perUnitRate(perUnitRate: String) = - perUnitRate(JsonField.of(perUnitRate)) + /** The amount to charge for each unit outside of the allocation */ + fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) /** - * Sets [Builder.perUnitRate] to an arbitrary JSON value. + * Sets [Builder.unitAmount] to an arbitrary JSON value. * - * You should usually call [Builder.perUnitRate] with a well-typed [String] + * You should usually call [Builder.unitAmount] with a well-typed [String] * value instead. This method is primarily for setting the field to an * undocumented or not yet supported value. */ - fun perUnitRate(perUnitRate: JsonField) = apply { - this.perUnitRate = perUnitRate + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount } fun additionalProperties(additionalProperties: Map) = @@ -23105,41 +26615,41 @@ private constructor( } /** - * Returns an immutable instance of [GroupedWithMinMaxThresholdsConfig]. + * Returns an immutable instance of [CumulativeGroupedAllocationConfig]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```kotlin + * .cumulativeAllocation() + * .groupAllocation() * .groupingKey() - * .maximumCharge() - * .minimumCharge() - * .perUnitRate() + * .unitAmount() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): GroupedWithMinMaxThresholdsConfig = - GroupedWithMinMaxThresholdsConfig( + fun build(): CumulativeGroupedAllocationConfig = + CumulativeGroupedAllocationConfig( + checkRequired("cumulativeAllocation", cumulativeAllocation), + checkRequired("groupAllocation", groupAllocation), checkRequired("groupingKey", groupingKey), - checkRequired("maximumCharge", maximumCharge), - checkRequired("minimumCharge", minimumCharge), - checkRequired("perUnitRate", perUnitRate), + checkRequired("unitAmount", unitAmount), additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): GroupedWithMinMaxThresholdsConfig = apply { + fun validate(): CumulativeGroupedAllocationConfig = apply { if (validated) { return@apply } + cumulativeAllocation() + groupAllocation() groupingKey() - maximumCharge() - minimumCharge() - perUnitRate() + unitAmount() validated = true } @@ -23158,30 +26668,30 @@ private constructor( * Used for best match union deserialization. */ internal fun validity(): Int = - (if (groupingKey.asKnown() == null) 0 else 1) + - (if (maximumCharge.asKnown() == null) 0 else 1) + - (if (minimumCharge.asKnown() == null) 0 else 1) + - (if (perUnitRate.asKnown() == null) 0 else 1) + (if (cumulativeAllocation.asKnown() == null) 0 else 1) + + (if (groupAllocation.asKnown() == null) 0 else 1) + + (if (groupingKey.asKnown() == null) 0 else 1) + + (if (unitAmount.asKnown() == null) 0 else 1) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is GroupedWithMinMaxThresholdsConfig && + return other is CumulativeGroupedAllocationConfig && + cumulativeAllocation == other.cumulativeAllocation && + groupAllocation == other.groupAllocation && groupingKey == other.groupingKey && - maximumCharge == other.maximumCharge && - minimumCharge == other.minimumCharge && - perUnitRate == other.perUnitRate && + unitAmount == other.unitAmount && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { Objects.hash( + cumulativeAllocation, + groupAllocation, groupingKey, - maximumCharge, - minimumCharge, - perUnitRate, + unitAmount, additionalProperties, ) } @@ -23189,7 +26699,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "GroupedWithMinMaxThresholdsConfig{groupingKey=$groupingKey, maximumCharge=$maximumCharge, minimumCharge=$minimumCharge, perUnitRate=$perUnitRate, additionalProperties=$additionalProperties}" + "CumulativeGroupedAllocationConfig{cumulativeAllocation=$cumulativeAllocation, groupAllocation=$groupAllocation, groupingKey=$groupingKey, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" } /** @@ -23306,10 +26816,10 @@ private constructor( return true } - return other is GroupedWithMinMaxThresholds && + return other is CumulativeGroupedAllocation && cadence == other.cadence && - groupedWithMinMaxThresholdsConfig == - other.groupedWithMinMaxThresholdsConfig && + cumulativeGroupedAllocationConfig == + other.cumulativeGroupedAllocationConfig && itemId == other.itemId && modelType == other.modelType && name == other.name && @@ -23332,7 +26842,7 @@ private constructor( private val hashCode: Int by lazy { Objects.hash( cadence, - groupedWithMinMaxThresholdsConfig, + cumulativeGroupedAllocationConfig, itemId, modelType, name, @@ -23356,7 +26866,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "GroupedWithMinMaxThresholds{cadence=$cadence, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "CumulativeGroupedAllocation{cadence=$cadence, cumulativeGroupedAllocationConfig=$cumulativeGroupedAllocationConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } class Percent diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsParams.kt index 113bc1ef8..a894a4ebc 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsParams.kt @@ -1738,6 +1738,13 @@ private constructor( fun price(cumulativeGroupedBulk: NewFloatingCumulativeGroupedBulkPrice) = price(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) + /** + * Alias for calling [price] with + * `Price.ofCumulativeGroupedAllocation(cumulativeGroupedAllocation)`. + */ + fun price(cumulativeGroupedAllocation: Price.CumulativeGroupedAllocation) = + price(Price.ofCumulativeGroupedAllocation(cumulativeGroupedAllocation)) + /** Alias for calling [price] with `Price.ofMinimum(minimum)`. */ fun price(minimum: NewFloatingMinimumCompositePrice) = price(Price.ofMinimum(minimum)) @@ -3367,6 +3374,7 @@ private constructor( NewFloatingScalableMatrixWithTieredPricingPrice? = null, private val cumulativeGroupedBulk: NewFloatingCumulativeGroupedBulkPrice? = null, + private val cumulativeGroupedAllocation: CumulativeGroupedAllocation? = null, private val minimum: NewFloatingMinimumCompositePrice? = null, private val percent: Percent? = null, private val eventOutput: EventOutput? = null, @@ -3437,6 +3445,9 @@ private constructor( fun cumulativeGroupedBulk(): NewFloatingCumulativeGroupedBulkPrice? = cumulativeGroupedBulk + fun cumulativeGroupedAllocation(): CumulativeGroupedAllocation? = + cumulativeGroupedAllocation + fun minimum(): NewFloatingMinimumCompositePrice? = minimum fun percent(): Percent? = percent @@ -3498,6 +3509,8 @@ private constructor( fun isCumulativeGroupedBulk(): Boolean = cumulativeGroupedBulk != null + fun isCumulativeGroupedAllocation(): Boolean = cumulativeGroupedAllocation != null + fun isMinimum(): Boolean = minimum != null fun isPercent(): Boolean = percent != null @@ -3580,6 +3593,9 @@ private constructor( fun asCumulativeGroupedBulk(): NewFloatingCumulativeGroupedBulkPrice = cumulativeGroupedBulk.getOrThrow("cumulativeGroupedBulk") + fun asCumulativeGroupedAllocation(): CumulativeGroupedAllocation = + cumulativeGroupedAllocation.getOrThrow("cumulativeGroupedAllocation") + fun asMinimum(): NewFloatingMinimumCompositePrice = minimum.getOrThrow("minimum") fun asPercent(): Percent = percent.getOrThrow("percent") @@ -3633,6 +3649,8 @@ private constructor( ) cumulativeGroupedBulk != null -> visitor.visitCumulativeGroupedBulk(cumulativeGroupedBulk) + cumulativeGroupedAllocation != null -> + visitor.visitCumulativeGroupedAllocation(cumulativeGroupedAllocation) minimum != null -> visitor.visitMinimum(minimum) percent != null -> visitor.visitPercent(percent) eventOutput != null -> visitor.visitEventOutput(eventOutput) @@ -3800,6 +3818,12 @@ private constructor( cumulativeGroupedBulk.validate() } + override fun visitCumulativeGroupedAllocation( + cumulativeGroupedAllocation: CumulativeGroupedAllocation + ) { + cumulativeGroupedAllocation.validate() + } + override fun visitMinimum(minimum: NewFloatingMinimumCompositePrice) { minimum.validate() } @@ -3933,6 +3957,10 @@ private constructor( cumulativeGroupedBulk: NewFloatingCumulativeGroupedBulkPrice ) = cumulativeGroupedBulk.validity() + override fun visitCumulativeGroupedAllocation( + cumulativeGroupedAllocation: CumulativeGroupedAllocation + ) = cumulativeGroupedAllocation.validity() + override fun visitMinimum(minimum: NewFloatingMinimumCompositePrice) = minimum.validity() @@ -3978,6 +4006,7 @@ private constructor( scalableMatrixWithUnitPricing == other.scalableMatrixWithUnitPricing && scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && cumulativeGroupedBulk == other.cumulativeGroupedBulk && + cumulativeGroupedAllocation == other.cumulativeGroupedAllocation && minimum == other.minimum && percent == other.percent && eventOutput == other.eventOutput @@ -4012,6 +4041,7 @@ private constructor( scalableMatrixWithUnitPricing, scalableMatrixWithTieredPricing, cumulativeGroupedBulk, + cumulativeGroupedAllocation, minimum, percent, eventOutput, @@ -4059,6 +4089,8 @@ private constructor( "Price{scalableMatrixWithTieredPricing=$scalableMatrixWithTieredPricing}" cumulativeGroupedBulk != null -> "Price{cumulativeGroupedBulk=$cumulativeGroupedBulk}" + cumulativeGroupedAllocation != null -> + "Price{cumulativeGroupedAllocation=$cumulativeGroupedAllocation}" minimum != null -> "Price{minimum=$minimum}" percent != null -> "Price{percent=$percent}" eventOutput != null -> "Price{eventOutput=$eventOutput}" @@ -4158,6 +4190,10 @@ private constructor( cumulativeGroupedBulk: NewFloatingCumulativeGroupedBulkPrice ) = Price(cumulativeGroupedBulk = cumulativeGroupedBulk) + fun ofCumulativeGroupedAllocation( + cumulativeGroupedAllocation: CumulativeGroupedAllocation + ) = Price(cumulativeGroupedAllocation = cumulativeGroupedAllocation) + fun ofMinimum(minimum: NewFloatingMinimumCompositePrice) = Price(minimum = minimum) fun ofPercent(percent: Percent) = Price(percent = percent) @@ -4252,6 +4288,10 @@ private constructor( cumulativeGroupedBulk: NewFloatingCumulativeGroupedBulkPrice ): T + fun visitCumulativeGroupedAllocation( + cumulativeGroupedAllocation: CumulativeGroupedAllocation + ): T + fun visitMinimum(minimum: NewFloatingMinimumCompositePrice): T fun visitPercent(percent: Percent): T @@ -4475,6 +4515,14 @@ private constructor( ?.let { Price(cumulativeGroupedBulk = it, _json = json) } ?: Price(_json = json) } + "cumulative_grouped_allocation" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(cumulativeGroupedAllocation = it, _json = json) } + ?: Price(_json = json) + } "minimum" -> { return tryDeserialize( node, @@ -4553,6 +4601,8 @@ private constructor( generator.writeObject(value.scalableMatrixWithTieredPricing) value.cumulativeGroupedBulk != null -> generator.writeObject(value.cumulativeGroupedBulk) + value.cumulativeGroupedAllocation != null -> + generator.writeObject(value.cumulativeGroupedAllocation) value.minimum != null -> generator.writeObject(value.minimum) value.percent != null -> generator.writeObject(value.percent) value.eventOutput != null -> generator.writeObject(value.eventOutput) @@ -8195,6 +8245,1661 @@ private constructor( "GroupedWithMinMaxThresholds{cadence=$cadence, currency=$currency, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" } + class CumulativeGroupedAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val cumulativeGroupedAllocationConfig: + JsonField, + private val currency: JsonField, + private val itemId: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val metadata: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("cumulative_grouped_allocation_config") + @ExcludeMissing + cumulativeGroupedAllocationConfig: + JsonField = + JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + ) : this( + cadence, + cumulativeGroupedAllocationConfig, + currency, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * Configuration for cumulative_grouped_allocation pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cumulativeGroupedAllocationConfig(): CumulativeGroupedAllocationConfig = + cumulativeGroupedAllocationConfig.getRequired( + "cumulative_grouped_allocation_config" + ) + + /** + * An ISO 4217 currency string for which this price is billed in. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("cumulative_grouped_allocation") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = billableMetricId.getNullable("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + invoiceGroupingKey.getNullable("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [cumulativeGroupedAllocationConfig]. + * + * Unlike [cumulativeGroupedAllocationConfig], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("cumulative_grouped_allocation_config") + @ExcludeMissing + fun _cumulativeGroupedAllocationConfig(): + JsonField = cumulativeGroupedAllocationConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [CumulativeGroupedAllocation]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .cumulativeGroupedAllocationConfig() + * .currency() + * .itemId() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [CumulativeGroupedAllocation]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var cumulativeGroupedAllocationConfig: + JsonField? = + null + private var currency: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonValue = + JsonValue.from("cumulative_grouped_allocation") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(cumulativeGroupedAllocation: CumulativeGroupedAllocation) = + apply { + cadence = cumulativeGroupedAllocation.cadence + cumulativeGroupedAllocationConfig = + cumulativeGroupedAllocation.cumulativeGroupedAllocationConfig + currency = cumulativeGroupedAllocation.currency + itemId = cumulativeGroupedAllocation.itemId + modelType = cumulativeGroupedAllocation.modelType + name = cumulativeGroupedAllocation.name + billableMetricId = cumulativeGroupedAllocation.billableMetricId + billedInAdvance = cumulativeGroupedAllocation.billedInAdvance + billingCycleConfiguration = + cumulativeGroupedAllocation.billingCycleConfiguration + conversionRate = cumulativeGroupedAllocation.conversionRate + conversionRateConfig = cumulativeGroupedAllocation.conversionRateConfig + dimensionalPriceConfiguration = + cumulativeGroupedAllocation.dimensionalPriceConfiguration + externalPriceId = cumulativeGroupedAllocation.externalPriceId + fixedPriceQuantity = cumulativeGroupedAllocation.fixedPriceQuantity + invoiceGroupingKey = cumulativeGroupedAllocation.invoiceGroupingKey + invoicingCycleConfiguration = + cumulativeGroupedAllocation.invoicingCycleConfiguration + metadata = cumulativeGroupedAllocation.metadata + additionalProperties = + cumulativeGroupedAllocation.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** Configuration for cumulative_grouped_allocation pricing */ + fun cumulativeGroupedAllocationConfig( + cumulativeGroupedAllocationConfig: CumulativeGroupedAllocationConfig + ) = + cumulativeGroupedAllocationConfig( + JsonField.of(cumulativeGroupedAllocationConfig) + ) + + /** + * Sets [Builder.cumulativeGroupedAllocationConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.cumulativeGroupedAllocationConfig] with a + * well-typed [CumulativeGroupedAllocationConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun cumulativeGroupedAllocationConfig( + cumulativeGroupedAllocationConfig: + JsonField + ) = apply { + this.cumulativeGroupedAllocationConfig = cumulativeGroupedAllocationConfig + } + + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("cumulative_grouped_allocation") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CumulativeGroupedAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .cumulativeGroupedAllocationConfig() + * .currency() + * .itemId() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CumulativeGroupedAllocation = + CumulativeGroupedAllocation( + checkRequired("cadence", cadence), + checkRequired( + "cumulativeGroupedAllocationConfig", + cumulativeGroupedAllocationConfig, + ), + checkRequired("currency", currency), + checkRequired("itemId", itemId), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CumulativeGroupedAllocation = apply { + if (validated) { + return@apply + } + + cadence().validate() + cumulativeGroupedAllocationConfig().validate() + currency() + itemId() + _modelType().let { + if (it != JsonValue.from("cumulative_grouped_allocation")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + metadata()?.validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (cumulativeGroupedAllocationConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (if (itemId.asKnown() == null) 0 else 1) + + modelType.let { + if (it == JsonValue.from("cumulative_grouped_allocation")) 1 else 0 + } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (metadata.asKnown()?.validity() ?: 0) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Configuration for cumulative_grouped_allocation pricing */ + class CumulativeGroupedAllocationConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cumulativeAllocation: JsonField, + private val groupAllocation: JsonField, + private val groupingKey: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cumulative_allocation") + @ExcludeMissing + cumulativeAllocation: JsonField = JsonMissing.of(), + @JsonProperty("group_allocation") + @ExcludeMissing + groupAllocation: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this( + cumulativeAllocation, + groupAllocation, + groupingKey, + unitAmount, + mutableMapOf(), + ) + + /** + * The overall allocation across all groups + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun cumulativeAllocation(): String = + cumulativeAllocation.getRequired("cumulative_allocation") + + /** + * The allocation per individual group + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun groupAllocation(): String = groupAllocation.getRequired("group_allocation") + + /** + * The event property used to group usage before applying allocations + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The amount to charge for each unit outside of the allocation + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [cumulativeAllocation]. + * + * Unlike [cumulativeAllocation], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("cumulative_allocation") + @ExcludeMissing + fun _cumulativeAllocation(): JsonField = cumulativeAllocation + + /** + * Returns the raw JSON value of [groupAllocation]. + * + * Unlike [groupAllocation], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("group_allocation") + @ExcludeMissing + fun _groupAllocation(): JsonField = groupAllocation + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [CumulativeGroupedAllocationConfig]. + * + * The following fields are required: + * ```kotlin + * .cumulativeAllocation() + * .groupAllocation() + * .groupingKey() + * .unitAmount() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [CumulativeGroupedAllocationConfig]. */ + class Builder internal constructor() { + + private var cumulativeAllocation: JsonField? = null + private var groupAllocation: JsonField? = null + private var groupingKey: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from( + cumulativeGroupedAllocationConfig: CumulativeGroupedAllocationConfig + ) = apply { + cumulativeAllocation = + cumulativeGroupedAllocationConfig.cumulativeAllocation + groupAllocation = cumulativeGroupedAllocationConfig.groupAllocation + groupingKey = cumulativeGroupedAllocationConfig.groupingKey + unitAmount = cumulativeGroupedAllocationConfig.unitAmount + additionalProperties = + cumulativeGroupedAllocationConfig.additionalProperties + .toMutableMap() + } + + /** The overall allocation across all groups */ + fun cumulativeAllocation(cumulativeAllocation: String) = + cumulativeAllocation(JsonField.of(cumulativeAllocation)) + + /** + * Sets [Builder.cumulativeAllocation] to an arbitrary JSON value. + * + * You should usually call [Builder.cumulativeAllocation] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun cumulativeAllocation(cumulativeAllocation: JsonField) = apply { + this.cumulativeAllocation = cumulativeAllocation + } + + /** The allocation per individual group */ + fun groupAllocation(groupAllocation: String) = + groupAllocation(JsonField.of(groupAllocation)) + + /** + * Sets [Builder.groupAllocation] to an arbitrary JSON value. + * + * You should usually call [Builder.groupAllocation] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun groupAllocation(groupAllocation: JsonField) = apply { + this.groupAllocation = groupAllocation + } + + /** The event property used to group usage before applying allocations */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The amount to charge for each unit outside of the allocation */ + fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CumulativeGroupedAllocationConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cumulativeAllocation() + * .groupAllocation() + * .groupingKey() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CumulativeGroupedAllocationConfig = + CumulativeGroupedAllocationConfig( + checkRequired("cumulativeAllocation", cumulativeAllocation), + checkRequired("groupAllocation", groupAllocation), + checkRequired("groupingKey", groupingKey), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CumulativeGroupedAllocationConfig = apply { + if (validated) { + return@apply + } + + cumulativeAllocation() + groupAllocation() + groupingKey() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (cumulativeAllocation.asKnown() == null) 0 else 1) + + (if (groupAllocation.asKnown() == null) 0 else 1) + + (if (groupingKey.asKnown() == null) 0 else 1) + + (if (unitAmount.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CumulativeGroupedAllocationConfig && + cumulativeAllocation == other.cumulativeAllocation && + groupAllocation == other.groupAllocation && + groupingKey == other.groupingKey && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cumulativeAllocation, + groupAllocation, + groupingKey, + unitAmount, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CumulativeGroupedAllocationConfig{cumulativeAllocation=$cumulativeAllocation, groupAllocation=$groupAllocation, groupingKey=$groupingKey, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CumulativeGroupedAllocation && + cadence == other.cadence && + cumulativeGroupedAllocationConfig == + other.cumulativeGroupedAllocationConfig && + currency == other.currency && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + cumulativeGroupedAllocationConfig, + currency, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CumulativeGroupedAllocation{cadence=$cadence, cumulativeGroupedAllocationConfig=$cumulativeGroupedAllocationConfig, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + } + class Percent @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionSchedulePlanChangeParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionSchedulePlanChangeParams.kt index 650591840..7a6b91c32 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionSchedulePlanChangeParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionSchedulePlanChangeParams.kt @@ -4356,6 +4356,13 @@ private constructor( fun price(cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice) = price(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) + /** + * Alias for calling [price] with + * `Price.ofCumulativeGroupedAllocation(cumulativeGroupedAllocation)`. + */ + fun price(cumulativeGroupedAllocation: Price.CumulativeGroupedAllocation) = + price(Price.ofCumulativeGroupedAllocation(cumulativeGroupedAllocation)) + /** Alias for calling [price] with `Price.ofMinimum(minimum)`. */ fun price(minimum: NewSubscriptionMinimumCompositePrice) = price(Price.ofMinimum(minimum)) @@ -4522,6 +4529,7 @@ private constructor( NewSubscriptionScalableMatrixWithTieredPricingPrice? = null, private val cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice? = null, + private val cumulativeGroupedAllocation: CumulativeGroupedAllocation? = null, private val minimum: NewSubscriptionMinimumCompositePrice? = null, private val percent: Percent? = null, private val eventOutput: EventOutput? = null, @@ -4596,6 +4604,9 @@ private constructor( fun cumulativeGroupedBulk(): NewSubscriptionCumulativeGroupedBulkPrice? = cumulativeGroupedBulk + fun cumulativeGroupedAllocation(): CumulativeGroupedAllocation? = + cumulativeGroupedAllocation + fun minimum(): NewSubscriptionMinimumCompositePrice? = minimum fun percent(): Percent? = percent @@ -4657,6 +4668,8 @@ private constructor( fun isCumulativeGroupedBulk(): Boolean = cumulativeGroupedBulk != null + fun isCumulativeGroupedAllocation(): Boolean = cumulativeGroupedAllocation != null + fun isMinimum(): Boolean = minimum != null fun isPercent(): Boolean = percent != null @@ -4740,6 +4753,9 @@ private constructor( fun asCumulativeGroupedBulk(): NewSubscriptionCumulativeGroupedBulkPrice = cumulativeGroupedBulk.getOrThrow("cumulativeGroupedBulk") + fun asCumulativeGroupedAllocation(): CumulativeGroupedAllocation = + cumulativeGroupedAllocation.getOrThrow("cumulativeGroupedAllocation") + fun asMinimum(): NewSubscriptionMinimumCompositePrice = minimum.getOrThrow("minimum") fun asPercent(): Percent = percent.getOrThrow("percent") @@ -4793,6 +4809,8 @@ private constructor( ) cumulativeGroupedBulk != null -> visitor.visitCumulativeGroupedBulk(cumulativeGroupedBulk) + cumulativeGroupedAllocation != null -> + visitor.visitCumulativeGroupedAllocation(cumulativeGroupedAllocation) minimum != null -> visitor.visitMinimum(minimum) percent != null -> visitor.visitPercent(percent) eventOutput != null -> visitor.visitEventOutput(eventOutput) @@ -4961,6 +4979,12 @@ private constructor( cumulativeGroupedBulk.validate() } + override fun visitCumulativeGroupedAllocation( + cumulativeGroupedAllocation: CumulativeGroupedAllocation + ) { + cumulativeGroupedAllocation.validate() + } + override fun visitMinimum(minimum: NewSubscriptionMinimumCompositePrice) { minimum.validate() } @@ -5097,6 +5121,10 @@ private constructor( cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice ) = cumulativeGroupedBulk.validity() + override fun visitCumulativeGroupedAllocation( + cumulativeGroupedAllocation: CumulativeGroupedAllocation + ) = cumulativeGroupedAllocation.validity() + override fun visitMinimum(minimum: NewSubscriptionMinimumCompositePrice) = minimum.validity() @@ -5142,6 +5170,7 @@ private constructor( scalableMatrixWithUnitPricing == other.scalableMatrixWithUnitPricing && scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && cumulativeGroupedBulk == other.cumulativeGroupedBulk && + cumulativeGroupedAllocation == other.cumulativeGroupedAllocation && minimum == other.minimum && percent == other.percent && eventOutput == other.eventOutput @@ -5176,6 +5205,7 @@ private constructor( scalableMatrixWithUnitPricing, scalableMatrixWithTieredPricing, cumulativeGroupedBulk, + cumulativeGroupedAllocation, minimum, percent, eventOutput, @@ -5223,6 +5253,8 @@ private constructor( "Price{scalableMatrixWithTieredPricing=$scalableMatrixWithTieredPricing}" cumulativeGroupedBulk != null -> "Price{cumulativeGroupedBulk=$cumulativeGroupedBulk}" + cumulativeGroupedAllocation != null -> + "Price{cumulativeGroupedAllocation=$cumulativeGroupedAllocation}" minimum != null -> "Price{minimum=$minimum}" percent != null -> "Price{percent=$percent}" eventOutput != null -> "Price{eventOutput=$eventOutput}" @@ -5322,6 +5354,10 @@ private constructor( cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice ) = Price(cumulativeGroupedBulk = cumulativeGroupedBulk) + fun ofCumulativeGroupedAllocation( + cumulativeGroupedAllocation: CumulativeGroupedAllocation + ) = Price(cumulativeGroupedAllocation = cumulativeGroupedAllocation) + fun ofMinimum(minimum: NewSubscriptionMinimumCompositePrice) = Price(minimum = minimum) @@ -5424,6 +5460,10 @@ private constructor( cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice ): T + fun visitCumulativeGroupedAllocation( + cumulativeGroupedAllocation: CumulativeGroupedAllocation + ): T + fun visitMinimum(minimum: NewSubscriptionMinimumCompositePrice): T fun visitPercent(percent: Percent): T @@ -5655,6 +5695,14 @@ private constructor( ?.let { Price(cumulativeGroupedBulk = it, _json = json) } ?: Price(_json = json) } + "cumulative_grouped_allocation" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(cumulativeGroupedAllocation = it, _json = json) } + ?: Price(_json = json) + } "minimum" -> { return tryDeserialize( node, @@ -5733,6 +5781,8 @@ private constructor( generator.writeObject(value.scalableMatrixWithTieredPricing) value.cumulativeGroupedBulk != null -> generator.writeObject(value.cumulativeGroupedBulk) + value.cumulativeGroupedAllocation != null -> + generator.writeObject(value.cumulativeGroupedAllocation) value.minimum != null -> generator.writeObject(value.minimum) value.percent != null -> generator.writeObject(value.percent) value.eventOutput != null -> generator.writeObject(value.eventOutput) @@ -11244,14 +11294,15 @@ private constructor( "GroupedWithMinMaxThresholds{cadence=$cadence, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class Percent + class CumulativeGroupedAllocation @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, + private val cumulativeGroupedAllocationConfig: + JsonField, private val itemId: JsonField, private val modelType: JsonValue, private val name: JsonField, - private val percentConfig: JsonField, private val billableMetricId: JsonField, private val billedInAdvance: JsonField, private val billingCycleConfiguration: JsonField, @@ -11274,6 +11325,11 @@ private constructor( @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), + @JsonProperty("cumulative_grouped_allocation_config") + @ExcludeMissing + cumulativeGroupedAllocationConfig: + JsonField = + JsonMissing.of(), @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), @@ -11283,9 +11339,6 @@ private constructor( @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("percent_config") - @ExcludeMissing - percentConfig: JsonField = JsonMissing.of(), @JsonProperty("billable_metric_id") @ExcludeMissing billableMetricId: JsonField = JsonMissing.of(), @@ -11330,10 +11383,10 @@ private constructor( referenceId: JsonField = JsonMissing.of(), ) : this( cadence, + cumulativeGroupedAllocationConfig, itemId, modelType, name, - percentConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -11359,6 +11412,18 @@ private constructor( */ fun cadence(): Cadence = cadence.getRequired("cadence") + /** + * Configuration for cumulative_grouped_allocation pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cumulativeGroupedAllocationConfig(): CumulativeGroupedAllocationConfig = + cumulativeGroupedAllocationConfig.getRequired( + "cumulative_grouped_allocation_config" + ) + /** * The id of the item the price will be associated with. * @@ -11373,7 +11438,7 @@ private constructor( * * Expected to always return the following: * ```kotlin - * JsonValue.from("percent") + * JsonValue.from("cumulative_grouped_allocation") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -11390,15 +11455,6 @@ private constructor( */ fun name(): String = name.getRequired("name") - /** - * Configuration for percent pricing - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun percentConfig(): PercentConfig = percentConfig.getRequired("percent_config") - /** * The id of the billable metric for the price. Only needed if the price is * usage-based. @@ -11528,6 +11584,17 @@ private constructor( @ExcludeMissing fun _cadence(): JsonField = cadence + /** + * Returns the raw JSON value of [cumulativeGroupedAllocationConfig]. + * + * Unlike [cumulativeGroupedAllocationConfig], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("cumulative_grouped_allocation_config") + @ExcludeMissing + fun _cumulativeGroupedAllocationConfig(): + JsonField = cumulativeGroupedAllocationConfig + /** * Returns the raw JSON value of [itemId]. * @@ -11544,16 +11611,6 @@ private constructor( */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - /** - * Returns the raw JSON value of [percentConfig]. - * - * Unlike [percentConfig], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("percent_config") - @ExcludeMissing - fun _percentConfig(): JsonField = percentConfig - /** * Returns the raw JSON value of [billableMetricId]. * @@ -11702,27 +11759,31 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [Percent]. + * Returns a mutable builder for constructing an instance of + * [CumulativeGroupedAllocation]. * * The following fields are required: * ```kotlin * .cadence() + * .cumulativeGroupedAllocationConfig() * .itemId() * .name() - * .percentConfig() * ``` */ fun builder() = Builder() } - /** A builder for [Percent]. */ + /** A builder for [CumulativeGroupedAllocation]. */ class Builder internal constructor() { private var cadence: JsonField? = null + private var cumulativeGroupedAllocationConfig: + JsonField? = + null private var itemId: JsonField? = null - private var modelType: JsonValue = JsonValue.from("percent") + private var modelType: JsonValue = + JsonValue.from("cumulative_grouped_allocation") private var name: JsonField? = null - private var percentConfig: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() private var billingCycleConfiguration: JsonField = @@ -11744,27 +11805,33 @@ private constructor( private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(percent: Percent) = apply { - cadence = percent.cadence - itemId = percent.itemId - modelType = percent.modelType - name = percent.name - percentConfig = percent.percentConfig - billableMetricId = percent.billableMetricId - billedInAdvance = percent.billedInAdvance - billingCycleConfiguration = percent.billingCycleConfiguration - conversionRate = percent.conversionRate - conversionRateConfig = percent.conversionRateConfig - currency = percent.currency - dimensionalPriceConfiguration = percent.dimensionalPriceConfiguration - externalPriceId = percent.externalPriceId - fixedPriceQuantity = percent.fixedPriceQuantity - invoiceGroupingKey = percent.invoiceGroupingKey - invoicingCycleConfiguration = percent.invoicingCycleConfiguration - metadata = percent.metadata - referenceId = percent.referenceId - additionalProperties = percent.additionalProperties.toMutableMap() - } + internal fun from(cumulativeGroupedAllocation: CumulativeGroupedAllocation) = + apply { + cadence = cumulativeGroupedAllocation.cadence + cumulativeGroupedAllocationConfig = + cumulativeGroupedAllocation.cumulativeGroupedAllocationConfig + itemId = cumulativeGroupedAllocation.itemId + modelType = cumulativeGroupedAllocation.modelType + name = cumulativeGroupedAllocation.name + billableMetricId = cumulativeGroupedAllocation.billableMetricId + billedInAdvance = cumulativeGroupedAllocation.billedInAdvance + billingCycleConfiguration = + cumulativeGroupedAllocation.billingCycleConfiguration + conversionRate = cumulativeGroupedAllocation.conversionRate + conversionRateConfig = cumulativeGroupedAllocation.conversionRateConfig + currency = cumulativeGroupedAllocation.currency + dimensionalPriceConfiguration = + cumulativeGroupedAllocation.dimensionalPriceConfiguration + externalPriceId = cumulativeGroupedAllocation.externalPriceId + fixedPriceQuantity = cumulativeGroupedAllocation.fixedPriceQuantity + invoiceGroupingKey = cumulativeGroupedAllocation.invoiceGroupingKey + invoicingCycleConfiguration = + cumulativeGroupedAllocation.invoicingCycleConfiguration + metadata = cumulativeGroupedAllocation.metadata + referenceId = cumulativeGroupedAllocation.referenceId + additionalProperties = + cumulativeGroupedAllocation.additionalProperties.toMutableMap() + } /** The cadence to bill for this price on. */ fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) @@ -11778,6 +11845,29 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + /** Configuration for cumulative_grouped_allocation pricing */ + fun cumulativeGroupedAllocationConfig( + cumulativeGroupedAllocationConfig: CumulativeGroupedAllocationConfig + ) = + cumulativeGroupedAllocationConfig( + JsonField.of(cumulativeGroupedAllocationConfig) + ) + + /** + * Sets [Builder.cumulativeGroupedAllocationConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.cumulativeGroupedAllocationConfig] with a + * well-typed [CumulativeGroupedAllocationConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun cumulativeGroupedAllocationConfig( + cumulativeGroupedAllocationConfig: + JsonField + ) = apply { + this.cumulativeGroupedAllocationConfig = cumulativeGroupedAllocationConfig + } + /** The id of the item the price will be associated with. */ fun itemId(itemId: String) = itemId(JsonField.of(itemId)) @@ -11796,7 +11886,7 @@ private constructor( * It is usually unnecessary to call this method because the field defaults to * the following: * ```kotlin - * JsonValue.from("percent") + * JsonValue.from("cumulative_grouped_allocation") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -11816,21 +11906,6 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } - /** Configuration for percent pricing */ - fun percentConfig(percentConfig: PercentConfig) = - percentConfig(JsonField.of(percentConfig)) - - /** - * Sets [Builder.percentConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.percentConfig] with a well-typed - * [PercentConfig] value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. - */ - fun percentConfig(percentConfig: JsonField) = apply { - this.percentConfig = percentConfig - } - /** * The id of the billable metric for the price. Only needed if the price is * usage-based. @@ -12160,27 +12235,30 @@ private constructor( } /** - * Returns an immutable instance of [Percent]. + * Returns an immutable instance of [CumulativeGroupedAllocation]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```kotlin * .cadence() + * .cumulativeGroupedAllocationConfig() * .itemId() * .name() - * .percentConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): Percent = - Percent( + fun build(): CumulativeGroupedAllocation = + CumulativeGroupedAllocation( checkRequired("cadence", cadence), + checkRequired( + "cumulativeGroupedAllocationConfig", + cumulativeGroupedAllocationConfig, + ), checkRequired("itemId", itemId), modelType, checkRequired("name", name), - checkRequired("percentConfig", percentConfig), billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -12200,20 +12278,20 @@ private constructor( private var validated: Boolean = false - fun validate(): Percent = apply { + fun validate(): CumulativeGroupedAllocation = apply { if (validated) { return@apply } cadence().validate() + cumulativeGroupedAllocationConfig().validate() itemId() _modelType().let { - if (it != JsonValue.from("percent")) { + if (it != JsonValue.from("cumulative_grouped_allocation")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } name() - percentConfig().validate() billableMetricId() billedInAdvance() billingCycleConfiguration()?.validate() @@ -12246,10 +12324,12 @@ private constructor( */ internal fun validity(): Int = (cadence.asKnown()?.validity() ?: 0) + + (cumulativeGroupedAllocationConfig.asKnown()?.validity() ?: 0) + (if (itemId.asKnown() == null) 0 else 1) + - modelType.let { if (it == JsonValue.from("percent")) 1 else 0 } + + modelType.let { + if (it == JsonValue.from("cumulative_grouped_allocation")) 1 else 0 + } + (if (name.asKnown() == null) 0 else 1) + - (percentConfig.asKnown()?.validity() ?: 0) + (if (billableMetricId.asKnown() == null) 0 else 1) + (if (billedInAdvance.asKnown() == null) 0 else 1) + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + @@ -12421,39 +12501,115 @@ private constructor( override fun toString() = value.toString() } - /** Configuration for percent pricing */ - class PercentConfig + /** Configuration for cumulative_grouped_allocation pricing */ + class CumulativeGroupedAllocationConfig @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val percent: JsonField, + private val cumulativeAllocation: JsonField, + private val groupAllocation: JsonField, + private val groupingKey: JsonField, + private val unitAmount: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("percent") + @JsonProperty("cumulative_allocation") @ExcludeMissing - percent: JsonField = JsonMissing.of() - ) : this(percent, mutableMapOf()) + cumulativeAllocation: JsonField = JsonMissing.of(), + @JsonProperty("group_allocation") + @ExcludeMissing + groupAllocation: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this( + cumulativeAllocation, + groupAllocation, + groupingKey, + unitAmount, + mutableMapOf(), + ) /** - * What percent of the component subtotals to charge + * The overall allocation across all groups * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). */ - fun percent(): Double = percent.getRequired("percent") + fun cumulativeAllocation(): String = + cumulativeAllocation.getRequired("cumulative_allocation") /** - * Returns the raw JSON value of [percent]. + * The allocation per individual group * - * Unlike [percent], this method doesn't throw if the JSON field has an + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun groupAllocation(): String = groupAllocation.getRequired("group_allocation") + + /** + * The event property used to group usage before applying allocations + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The amount to charge for each unit outside of the allocation + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [cumulativeAllocation]. + * + * Unlike [cumulativeAllocation], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("cumulative_allocation") + @ExcludeMissing + fun _cumulativeAllocation(): JsonField = cumulativeAllocation + + /** + * Returns the raw JSON value of [groupAllocation]. + * + * Unlike [groupAllocation], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("percent") + @JsonProperty("group_allocation") @ExcludeMissing - fun _percent(): JsonField = percent + fun _groupAllocation(): JsonField = groupAllocation + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -12471,39 +12627,100 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [PercentConfig]. + * [CumulativeGroupedAllocationConfig]. * * The following fields are required: * ```kotlin - * .percent() + * .cumulativeAllocation() + * .groupAllocation() + * .groupingKey() + * .unitAmount() * ``` */ fun builder() = Builder() } - /** A builder for [PercentConfig]. */ + /** A builder for [CumulativeGroupedAllocationConfig]. */ class Builder internal constructor() { - private var percent: JsonField? = null + private var cumulativeAllocation: JsonField? = null + private var groupAllocation: JsonField? = null + private var groupingKey: JsonField? = null + private var unitAmount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(percentConfig: PercentConfig) = apply { - percent = percentConfig.percent - additionalProperties = percentConfig.additionalProperties.toMutableMap() + internal fun from( + cumulativeGroupedAllocationConfig: CumulativeGroupedAllocationConfig + ) = apply { + cumulativeAllocation = + cumulativeGroupedAllocationConfig.cumulativeAllocation + groupAllocation = cumulativeGroupedAllocationConfig.groupAllocation + groupingKey = cumulativeGroupedAllocationConfig.groupingKey + unitAmount = cumulativeGroupedAllocationConfig.unitAmount + additionalProperties = + cumulativeGroupedAllocationConfig.additionalProperties + .toMutableMap() } - /** What percent of the component subtotals to charge */ - fun percent(percent: Double) = percent(JsonField.of(percent)) + /** The overall allocation across all groups */ + fun cumulativeAllocation(cumulativeAllocation: String) = + cumulativeAllocation(JsonField.of(cumulativeAllocation)) /** - * Sets [Builder.percent] to an arbitrary JSON value. + * Sets [Builder.cumulativeAllocation] to an arbitrary JSON value. * - * You should usually call [Builder.percent] with a well-typed [Double] + * You should usually call [Builder.cumulativeAllocation] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun cumulativeAllocation(cumulativeAllocation: JsonField) = apply { + this.cumulativeAllocation = cumulativeAllocation + } + + /** The allocation per individual group */ + fun groupAllocation(groupAllocation: String) = + groupAllocation(JsonField.of(groupAllocation)) + + /** + * Sets [Builder.groupAllocation] to an arbitrary JSON value. + * + * You should usually call [Builder.groupAllocation] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun groupAllocation(groupAllocation: JsonField) = apply { + this.groupAllocation = groupAllocation + } + + /** The event property used to group usage before applying allocations */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] * value instead. This method is primarily for setting the field to an * undocumented or not yet supported value. */ - fun percent(percent: JsonField) = apply { this.percent = percent } + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The amount to charge for each unit outside of the allocation */ + fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } fun additionalProperties(additionalProperties: Map) = apply { @@ -12528,32 +12745,41 @@ private constructor( } /** - * Returns an immutable instance of [PercentConfig]. + * Returns an immutable instance of [CumulativeGroupedAllocationConfig]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```kotlin - * .percent() + * .cumulativeAllocation() + * .groupAllocation() + * .groupingKey() + * .unitAmount() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): PercentConfig = - PercentConfig( - checkRequired("percent", percent), + fun build(): CumulativeGroupedAllocationConfig = + CumulativeGroupedAllocationConfig( + checkRequired("cumulativeAllocation", cumulativeAllocation), + checkRequired("groupAllocation", groupAllocation), + checkRequired("groupingKey", groupingKey), + checkRequired("unitAmount", unitAmount), additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): PercentConfig = apply { + fun validate(): CumulativeGroupedAllocationConfig = apply { if (validated) { return@apply } - percent() + cumulativeAllocation() + groupAllocation() + groupingKey() + unitAmount() validated = true } @@ -12571,26 +12797,39 @@ private constructor( * * Used for best match union deserialization. */ - internal fun validity(): Int = (if (percent.asKnown() == null) 0 else 1) + internal fun validity(): Int = + (if (cumulativeAllocation.asKnown() == null) 0 else 1) + + (if (groupAllocation.asKnown() == null) 0 else 1) + + (if (groupingKey.asKnown() == null) 0 else 1) + + (if (unitAmount.asKnown() == null) 0 else 1) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is PercentConfig && - percent == other.percent && + return other is CumulativeGroupedAllocationConfig && + cumulativeAllocation == other.cumulativeAllocation && + groupAllocation == other.groupAllocation && + groupingKey == other.groupingKey && + unitAmount == other.unitAmount && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(percent, additionalProperties) + Objects.hash( + cumulativeAllocation, + groupAllocation, + groupingKey, + unitAmount, + additionalProperties, + ) } override fun hashCode(): Int = hashCode override fun toString() = - "PercentConfig{percent=$percent, additionalProperties=$additionalProperties}" + "CumulativeGroupedAllocationConfig{cumulativeAllocation=$cumulativeAllocation, groupAllocation=$groupAllocation, groupingKey=$groupingKey, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" } /** @@ -12707,12 +12946,13 @@ private constructor( return true } - return other is Percent && + return other is CumulativeGroupedAllocation && cadence == other.cadence && + cumulativeGroupedAllocationConfig == + other.cumulativeGroupedAllocationConfig && itemId == other.itemId && modelType == other.modelType && name == other.name && - percentConfig == other.percentConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && @@ -12732,10 +12972,10 @@ private constructor( private val hashCode: Int by lazy { Objects.hash( cadence, + cumulativeGroupedAllocationConfig, itemId, modelType, name, - percentConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -12756,17 +12996,17 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Percent{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, percentConfig=$percentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "CumulativeGroupedAllocation{cadence=$cadence, cumulativeGroupedAllocationConfig=$cumulativeGroupedAllocationConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class EventOutput + class Percent @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, - private val eventOutputConfig: JsonField, private val itemId: JsonField, private val modelType: JsonValue, private val name: JsonField, + private val percentConfig: JsonField, private val billableMetricId: JsonField, private val billedInAdvance: JsonField, private val billingCycleConfiguration: JsonField, @@ -12789,9 +13029,6 @@ private constructor( @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), - @JsonProperty("event_output_config") - @ExcludeMissing - eventOutputConfig: JsonField = JsonMissing.of(), @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), @@ -12801,6 +13038,9 @@ private constructor( @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("percent_config") + @ExcludeMissing + percentConfig: JsonField = JsonMissing.of(), @JsonProperty("billable_metric_id") @ExcludeMissing billableMetricId: JsonField = JsonMissing.of(), @@ -12845,10 +13085,10 @@ private constructor( referenceId: JsonField = JsonMissing.of(), ) : this( cadence, - eventOutputConfig, itemId, modelType, name, + percentConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -12874,16 +13114,6 @@ private constructor( */ fun cadence(): Cadence = cadence.getRequired("cadence") - /** - * Configuration for event_output pricing - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun eventOutputConfig(): EventOutputConfig = - eventOutputConfig.getRequired("event_output_config") - /** * The id of the item the price will be associated with. * @@ -12898,7 +13128,7 @@ private constructor( * * Expected to always return the following: * ```kotlin - * JsonValue.from("event_output") + * JsonValue.from("percent") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -12915,6 +13145,15 @@ private constructor( */ fun name(): String = name.getRequired("name") + /** + * Configuration for percent pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun percentConfig(): PercentConfig = percentConfig.getRequired("percent_config") + /** * The id of the billable metric for the price. Only needed if the price is * usage-based. @@ -13044,16 +13283,6 @@ private constructor( @ExcludeMissing fun _cadence(): JsonField = cadence - /** - * Returns the raw JSON value of [eventOutputConfig]. - * - * Unlike [eventOutputConfig], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("event_output_config") - @ExcludeMissing - fun _eventOutputConfig(): JsonField = eventOutputConfig - /** * Returns the raw JSON value of [itemId]. * @@ -13070,6 +13299,16 @@ private constructor( */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + /** + * Returns the raw JSON value of [percentConfig]. + * + * Unlike [percentConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("percent_config") + @ExcludeMissing + fun _percentConfig(): JsonField = percentConfig + /** * Returns the raw JSON value of [billableMetricId]. * @@ -13218,27 +13457,27 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [EventOutput]. + * Returns a mutable builder for constructing an instance of [Percent]. * * The following fields are required: * ```kotlin * .cadence() - * .eventOutputConfig() * .itemId() * .name() + * .percentConfig() * ``` */ fun builder() = Builder() } - /** A builder for [EventOutput]. */ + /** A builder for [Percent]. */ class Builder internal constructor() { private var cadence: JsonField? = null - private var eventOutputConfig: JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonValue = JsonValue.from("event_output") + private var modelType: JsonValue = JsonValue.from("percent") private var name: JsonField? = null + private var percentConfig: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() private var billingCycleConfiguration: JsonField = @@ -13260,26 +13499,26 @@ private constructor( private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(eventOutput: EventOutput) = apply { - cadence = eventOutput.cadence - eventOutputConfig = eventOutput.eventOutputConfig - itemId = eventOutput.itemId - modelType = eventOutput.modelType - name = eventOutput.name - billableMetricId = eventOutput.billableMetricId - billedInAdvance = eventOutput.billedInAdvance - billingCycleConfiguration = eventOutput.billingCycleConfiguration - conversionRate = eventOutput.conversionRate - conversionRateConfig = eventOutput.conversionRateConfig - currency = eventOutput.currency - dimensionalPriceConfiguration = eventOutput.dimensionalPriceConfiguration - externalPriceId = eventOutput.externalPriceId - fixedPriceQuantity = eventOutput.fixedPriceQuantity - invoiceGroupingKey = eventOutput.invoiceGroupingKey - invoicingCycleConfiguration = eventOutput.invoicingCycleConfiguration - metadata = eventOutput.metadata - referenceId = eventOutput.referenceId - additionalProperties = eventOutput.additionalProperties.toMutableMap() + internal fun from(percent: Percent) = apply { + cadence = percent.cadence + itemId = percent.itemId + modelType = percent.modelType + name = percent.name + percentConfig = percent.percentConfig + billableMetricId = percent.billableMetricId + billedInAdvance = percent.billedInAdvance + billingCycleConfiguration = percent.billingCycleConfiguration + conversionRate = percent.conversionRate + conversionRateConfig = percent.conversionRateConfig + currency = percent.currency + dimensionalPriceConfiguration = percent.dimensionalPriceConfiguration + externalPriceId = percent.externalPriceId + fixedPriceQuantity = percent.fixedPriceQuantity + invoiceGroupingKey = percent.invoiceGroupingKey + invoicingCycleConfiguration = percent.invoicingCycleConfiguration + metadata = percent.metadata + referenceId = percent.referenceId + additionalProperties = percent.additionalProperties.toMutableMap() } /** The cadence to bill for this price on. */ @@ -13294,21 +13533,6 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - /** Configuration for event_output pricing */ - fun eventOutputConfig(eventOutputConfig: EventOutputConfig) = - eventOutputConfig(JsonField.of(eventOutputConfig)) - - /** - * Sets [Builder.eventOutputConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.eventOutputConfig] with a well-typed - * [EventOutputConfig] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun eventOutputConfig(eventOutputConfig: JsonField) = apply { - this.eventOutputConfig = eventOutputConfig - } - /** The id of the item the price will be associated with. */ fun itemId(itemId: String) = itemId(JsonField.of(itemId)) @@ -13327,7 +13551,7 @@ private constructor( * It is usually unnecessary to call this method because the field defaults to * the following: * ```kotlin - * JsonValue.from("event_output") + * JsonValue.from("percent") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -13347,6 +13571,21 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } + /** Configuration for percent pricing */ + fun percentConfig(percentConfig: PercentConfig) = + percentConfig(JsonField.of(percentConfig)) + + /** + * Sets [Builder.percentConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.percentConfig] with a well-typed + * [PercentConfig] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun percentConfig(percentConfig: JsonField) = apply { + this.percentConfig = percentConfig + } + /** * The id of the billable metric for the price. Only needed if the price is * usage-based. @@ -13676,27 +13915,27 @@ private constructor( } /** - * Returns an immutable instance of [EventOutput]. + * Returns an immutable instance of [Percent]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```kotlin * .cadence() - * .eventOutputConfig() * .itemId() * .name() + * .percentConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): EventOutput = - EventOutput( + fun build(): Percent = + Percent( checkRequired("cadence", cadence), - checkRequired("eventOutputConfig", eventOutputConfig), checkRequired("itemId", itemId), modelType, checkRequired("name", name), + checkRequired("percentConfig", percentConfig), billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -13716,20 +13955,20 @@ private constructor( private var validated: Boolean = false - fun validate(): EventOutput = apply { + fun validate(): Percent = apply { if (validated) { return@apply } cadence().validate() - eventOutputConfig().validate() itemId() _modelType().let { - if (it != JsonValue.from("event_output")) { + if (it != JsonValue.from("percent")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } name() + percentConfig().validate() billableMetricId() billedInAdvance() billingCycleConfiguration()?.validate() @@ -13762,10 +14001,10 @@ private constructor( */ internal fun validity(): Int = (cadence.asKnown()?.validity() ?: 0) + - (eventOutputConfig.asKnown()?.validity() ?: 0) + (if (itemId.asKnown() == null) 0 else 1) + - modelType.let { if (it == JsonValue.from("event_output")) 1 else 0 } + + modelType.let { if (it == JsonValue.from("percent")) 1 else 0 } + (if (name.asKnown() == null) 0 else 1) + + (percentConfig.asKnown()?.validity() ?: 0) + (if (billableMetricId.asKnown() == null) 0 else 1) + (if (billedInAdvance.asKnown() == null) 0 else 1) + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + @@ -13937,87 +14176,39 @@ private constructor( override fun toString() = value.toString() } - /** Configuration for event_output pricing */ - class EventOutputConfig + /** Configuration for percent pricing */ + class PercentConfig @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val unitRatingKey: JsonField, - private val defaultUnitRate: JsonField, - private val groupingKey: JsonField, + private val percent: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("unit_rating_key") - @ExcludeMissing - unitRatingKey: JsonField = JsonMissing.of(), - @JsonProperty("default_unit_rate") - @ExcludeMissing - defaultUnitRate: JsonField = JsonMissing.of(), - @JsonProperty("grouping_key") + @JsonProperty("percent") @ExcludeMissing - groupingKey: JsonField = JsonMissing.of(), - ) : this(unitRatingKey, defaultUnitRate, groupingKey, mutableMapOf()) + percent: JsonField = JsonMissing.of() + ) : this(percent, mutableMapOf()) /** - * The key in the event data to extract the unit rate from. + * What percent of the component subtotals to charge * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). */ - fun unitRatingKey(): String = unitRatingKey.getRequired("unit_rating_key") - - /** - * If provided, this amount will be used as the unit rate when an event does not - * have a value for the `unit_rating_key`. If not provided, events missing a - * unit rate will be ignored. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun defaultUnitRate(): String? = - defaultUnitRate.getNullable("default_unit_rate") - - /** - * An optional key in the event data to group by (e.g., event ID). All events - * will also be grouped by their unit rate. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun groupingKey(): String? = groupingKey.getNullable("grouping_key") - - /** - * Returns the raw JSON value of [unitRatingKey]. - * - * Unlike [unitRatingKey], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("unit_rating_key") - @ExcludeMissing - fun _unitRatingKey(): JsonField = unitRatingKey - - /** - * Returns the raw JSON value of [defaultUnitRate]. - * - * Unlike [defaultUnitRate], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("default_unit_rate") - @ExcludeMissing - fun _defaultUnitRate(): JsonField = defaultUnitRate + fun percent(): Double = percent.getRequired("percent") /** - * Returns the raw JSON value of [groupingKey]. + * Returns the raw JSON value of [percent]. * - * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * Unlike [percent], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("grouping_key") + @JsonProperty("percent") @ExcludeMissing - fun _groupingKey(): JsonField = groupingKey + fun _percent(): JsonField = percent @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -14035,84 +14226,39 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [EventOutputConfig]. + * [PercentConfig]. * * The following fields are required: * ```kotlin - * .unitRatingKey() + * .percent() * ``` */ fun builder() = Builder() } - /** A builder for [EventOutputConfig]. */ + /** A builder for [PercentConfig]. */ class Builder internal constructor() { - private var unitRatingKey: JsonField? = null - private var defaultUnitRate: JsonField = JsonMissing.of() - private var groupingKey: JsonField = JsonMissing.of() + private var percent: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(eventOutputConfig: EventOutputConfig) = apply { - unitRatingKey = eventOutputConfig.unitRatingKey - defaultUnitRate = eventOutputConfig.defaultUnitRate - groupingKey = eventOutputConfig.groupingKey - additionalProperties = - eventOutputConfig.additionalProperties.toMutableMap() - } - - /** The key in the event data to extract the unit rate from. */ - fun unitRatingKey(unitRatingKey: String) = - unitRatingKey(JsonField.of(unitRatingKey)) - - /** - * Sets [Builder.unitRatingKey] to an arbitrary JSON value. - * - * You should usually call [Builder.unitRatingKey] with a well-typed - * [String] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun unitRatingKey(unitRatingKey: JsonField) = apply { - this.unitRatingKey = unitRatingKey - } - - /** - * If provided, this amount will be used as the unit rate when an event does - * not have a value for the `unit_rating_key`. If not provided, events - * missing a unit rate will be ignored. - */ - fun defaultUnitRate(defaultUnitRate: String?) = - defaultUnitRate(JsonField.ofNullable(defaultUnitRate)) - - /** - * Sets [Builder.defaultUnitRate] to an arbitrary JSON value. - * - * You should usually call [Builder.defaultUnitRate] with a well-typed - * [String] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun defaultUnitRate(defaultUnitRate: JsonField) = apply { - this.defaultUnitRate = defaultUnitRate + internal fun from(percentConfig: PercentConfig) = apply { + percent = percentConfig.percent + additionalProperties = percentConfig.additionalProperties.toMutableMap() } - /** - * An optional key in the event data to group by (e.g., event ID). All - * events will also be grouped by their unit rate. - */ - fun groupingKey(groupingKey: String?) = - groupingKey(JsonField.ofNullable(groupingKey)) + /** What percent of the component subtotals to charge */ + fun percent(percent: Double) = percent(JsonField.of(percent)) /** - * Sets [Builder.groupingKey] to an arbitrary JSON value. + * Sets [Builder.percent] to an arbitrary JSON value. * - * You should usually call [Builder.groupingKey] with a well-typed [String] + * You should usually call [Builder.percent] with a well-typed [Double] * value instead. This method is primarily for setting the field to an * undocumented or not yet supported value. */ - fun groupingKey(groupingKey: JsonField) = apply { - this.groupingKey = groupingKey - } + fun percent(percent: JsonField) = apply { this.percent = percent } fun additionalProperties(additionalProperties: Map) = apply { @@ -14137,36 +14283,32 @@ private constructor( } /** - * Returns an immutable instance of [EventOutputConfig]. + * Returns an immutable instance of [PercentConfig]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```kotlin - * .unitRatingKey() + * .percent() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): EventOutputConfig = - EventOutputConfig( - checkRequired("unitRatingKey", unitRatingKey), - defaultUnitRate, - groupingKey, + fun build(): PercentConfig = + PercentConfig( + checkRequired("percent", percent), additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): EventOutputConfig = apply { + fun validate(): PercentConfig = apply { if (validated) { return@apply } - unitRatingKey() - defaultUnitRate() - groupingKey() + percent() validated = true } @@ -14184,36 +14326,26 @@ private constructor( * * Used for best match union deserialization. */ - internal fun validity(): Int = - (if (unitRatingKey.asKnown() == null) 0 else 1) + - (if (defaultUnitRate.asKnown() == null) 0 else 1) + - (if (groupingKey.asKnown() == null) 0 else 1) + internal fun validity(): Int = (if (percent.asKnown() == null) 0 else 1) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is EventOutputConfig && - unitRatingKey == other.unitRatingKey && - defaultUnitRate == other.defaultUnitRate && - groupingKey == other.groupingKey && + return other is PercentConfig && + percent == other.percent && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash( - unitRatingKey, - defaultUnitRate, - groupingKey, - additionalProperties, - ) + Objects.hash(percent, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "EventOutputConfig{unitRatingKey=$unitRatingKey, defaultUnitRate=$defaultUnitRate, groupingKey=$groupingKey, additionalProperties=$additionalProperties}" + "PercentConfig{percent=$percent, additionalProperties=$additionalProperties}" } /** @@ -14330,12 +14462,12 @@ private constructor( return true } - return other is EventOutput && + return other is Percent && cadence == other.cadence && - eventOutputConfig == other.eventOutputConfig && itemId == other.itemId && modelType == other.modelType && name == other.name && + percentConfig == other.percentConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && @@ -14355,10 +14487,10 @@ private constructor( private val hashCode: Int by lazy { Objects.hash( cadence, - eventOutputConfig, itemId, modelType, name, + percentConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -14379,1083 +14511,1630 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "EventOutput{cadence=$cadence, eventOutputConfig=$eventOutputConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + "Percent{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, percentConfig=$percentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - return other is AddPrice && - allocationPrice == other.allocationPrice && - discounts == other.discounts && - endDate == other.endDate && - externalPriceId == other.externalPriceId && - maximumAmount == other.maximumAmount && - minimumAmount == other.minimumAmount && - planPhaseOrder == other.planPhaseOrder && - price == other.price && - priceId == other.priceId && - startDate == other.startDate && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - allocationPrice, - discounts, - endDate, - externalPriceId, - maximumAmount, - minimumAmount, - planPhaseOrder, - price, - priceId, - startDate, - additionalProperties, - ) - } + class EventOutput + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val eventOutputConfig: JsonField, + private val itemId: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { - override fun hashCode(): Int = hashCode + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("event_output_config") + @ExcludeMissing + eventOutputConfig: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + eventOutputConfig, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + mutableMapOf(), + ) - override fun toString() = - "AddPrice{allocationPrice=$allocationPrice, discounts=$discounts, endDate=$endDate, externalPriceId=$externalPriceId, maximumAmount=$maximumAmount, minimumAmount=$minimumAmount, planPhaseOrder=$planPhaseOrder, price=$price, priceId=$priceId, startDate=$startDate, additionalProperties=$additionalProperties}" - } + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") - /** - * Reset billing periods to be aligned with the plan change's effective date or start of the - * month. Defaults to `unchanged` which keeps subscription's existing billing cycle alignment. - */ - class BillingCycleAlignment - @JsonCreator - private constructor(private val value: JsonField) : Enum { + /** + * Configuration for event_output pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun eventOutputConfig(): EventOutputConfig = + eventOutputConfig.getRequired("event_output_config") - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API may respond with new members that the SDK is - * unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") - companion object { + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("event_output") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType - val UNCHANGED = of("unchanged") + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") - val PLAN_CHANGE_DATE = of("plan_change_date") + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = billableMetricId.getNullable("billable_metric_id") - val START_OF_MONTH = of("start_of_month") + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") - fun of(value: String) = BillingCycleAlignment(JsonField.of(value)) - } + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") - /** An enum containing [BillingCycleAlignment]'s known values. */ - enum class Known { - UNCHANGED, - PLAN_CHANGE_DATE, - START_OF_MONTH, - } + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") - /** - * An enum containing [BillingCycleAlignment]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [BillingCycleAlignment] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if the - * SDK is on an older version than the API, then the API may respond with new members that - * the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - UNCHANGED, - PLAN_CHANGE_DATE, - START_OF_MONTH, - /** - * An enum member indicating that [BillingCycleAlignment] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") - /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you want - * to throw for the unknown case. - */ - fun value(): Value = - when (this) { - UNCHANGED -> Value.UNCHANGED - PLAN_CHANGE_DATE -> Value.PLAN_CHANGE_DATE - START_OF_MONTH -> Value.START_OF_MONTH - else -> Value._UNKNOWN - } + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and don't - * want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known member. - */ - fun known(): Known = - when (this) { - UNCHANGED -> Known.UNCHANGED - PLAN_CHANGE_DATE -> Known.PLAN_CHANGE_DATE - START_OF_MONTH -> Known.START_OF_MONTH - else -> throw OrbInvalidDataException("Unknown BillingCycleAlignment: $value") - } + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the expected - * primitive type. - */ - fun asString(): String = - _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") - private var validated: Boolean = false + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") - fun validate(): BillingCycleAlignment = apply { - if (validated) { - return@apply - } + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + invoiceGroupingKey.getNullable("invoice_grouping_key") - known() - validated = true - } + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is BillingCycleAlignment && value == other.value - } - - override fun hashCode() = value.hashCode() + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence - override fun toString() = value.toString() - } + /** + * Returns the raw JSON value of [eventOutputConfig]. + * + * Unlike [eventOutputConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("event_output_config") + @ExcludeMissing + fun _eventOutputConfig(): JsonField = eventOutputConfig - class RemoveAdjustment - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val adjustmentId: JsonField, - private val additionalProperties: MutableMap, - ) { + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - @JsonCreator - private constructor( - @JsonProperty("adjustment_id") - @ExcludeMissing - adjustmentId: JsonField = JsonMissing.of() - ) : this(adjustmentId, mutableMapOf()) + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - /** - * The id of the adjustment to remove on the subscription. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun adjustmentId(): String = adjustmentId.getRequired("adjustment_id") + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId - /** - * Returns the raw JSON value of [adjustmentId]. - * - * Unlike [adjustmentId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("adjustment_id") - @ExcludeMissing - fun _adjustmentId(): JsonField = adjustmentId + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate - fun toBuilder() = Builder().from(this) + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig - companion object { + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency - /** - * Returns a mutable builder for constructing an instance of [RemoveAdjustment]. - * - * The following fields are required: - * ```kotlin - * .adjustmentId() - * ``` - */ - fun builder() = Builder() - } + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration - /** A builder for [RemoveAdjustment]. */ - class Builder internal constructor() { + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId - private var adjustmentId: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - internal fun from(removeAdjustment: RemoveAdjustment) = apply { - adjustmentId = removeAdjustment.adjustmentId - additionalProperties = removeAdjustment.additionalProperties.toMutableMap() - } + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - /** The id of the adjustment to remove on the subscription. */ - fun adjustmentId(adjustmentId: String) = adjustmentId(JsonField.of(adjustmentId)) + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration - /** - * Sets [Builder.adjustmentId] to an arbitrary JSON value. - * - * You should usually call [Builder.adjustmentId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun adjustmentId(adjustmentId: JsonField) = apply { - this.adjustmentId = adjustmentId - } + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun toBuilder() = Builder().from(this) - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + companion object { - /** - * Returns an immutable instance of [RemoveAdjustment]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```kotlin - * .adjustmentId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): RemoveAdjustment = - RemoveAdjustment( - checkRequired("adjustmentId", adjustmentId), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false + /** + * Returns a mutable builder for constructing an instance of [EventOutput]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .eventOutputConfig() + * .itemId() + * .name() + * ``` + */ + fun builder() = Builder() + } - fun validate(): RemoveAdjustment = apply { - if (validated) { - return@apply - } + /** A builder for [EventOutput]. */ + class Builder internal constructor() { - adjustmentId() - validated = true - } + private var cadence: JsonField? = null + private var eventOutputConfig: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonValue = JsonValue.from("event_output") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + internal fun from(eventOutput: EventOutput) = apply { + cadence = eventOutput.cadence + eventOutputConfig = eventOutput.eventOutputConfig + itemId = eventOutput.itemId + modelType = eventOutput.modelType + name = eventOutput.name + billableMetricId = eventOutput.billableMetricId + billedInAdvance = eventOutput.billedInAdvance + billingCycleConfiguration = eventOutput.billingCycleConfiguration + conversionRate = eventOutput.conversionRate + conversionRateConfig = eventOutput.conversionRateConfig + currency = eventOutput.currency + dimensionalPriceConfiguration = eventOutput.dimensionalPriceConfiguration + externalPriceId = eventOutput.externalPriceId + fixedPriceQuantity = eventOutput.fixedPriceQuantity + invoiceGroupingKey = eventOutput.invoiceGroupingKey + invoicingCycleConfiguration = eventOutput.invoicingCycleConfiguration + metadata = eventOutput.metadata + referenceId = eventOutput.referenceId + additionalProperties = eventOutput.additionalProperties.toMutableMap() + } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = (if (adjustmentId.asKnown() == null) 0 else 1) + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - return other is RemoveAdjustment && - adjustmentId == other.adjustmentId && - additionalProperties == other.additionalProperties - } + /** Configuration for event_output pricing */ + fun eventOutputConfig(eventOutputConfig: EventOutputConfig) = + eventOutputConfig(JsonField.of(eventOutputConfig)) - private val hashCode: Int by lazy { Objects.hash(adjustmentId, additionalProperties) } + /** + * Sets [Builder.eventOutputConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.eventOutputConfig] with a well-typed + * [EventOutputConfig] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun eventOutputConfig(eventOutputConfig: JsonField) = apply { + this.eventOutputConfig = eventOutputConfig + } - override fun hashCode(): Int = hashCode + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - override fun toString() = - "RemoveAdjustment{adjustmentId=$adjustmentId, additionalProperties=$additionalProperties}" - } + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - class RemovePrice - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val externalPriceId: JsonField, - private val priceId: JsonField, - private val additionalProperties: MutableMap, - ) { + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("event_output") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } - @JsonCreator - private constructor( - @JsonProperty("external_price_id") - @ExcludeMissing - externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("price_id") @ExcludeMissing priceId: JsonField = JsonMissing.of(), - ) : this(externalPriceId, priceId, mutableMapOf()) + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) - /** - * The external price id of the price to remove on the subscription. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } - /** - * The id of the price to remove on the subscription. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun priceId(): String? = priceId.getNullable("price_id") + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) - /** - * Returns the raw JSON value of [externalPriceId]. - * - * Unlike [externalPriceId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } - /** - * Returns the raw JSON value of [priceId]. - * - * Unlike [priceId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } - fun toBuilder() = Builder().from(this) - - companion object { + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - /** Returns a mutable builder for constructing an instance of [RemovePrice]. */ - fun builder() = Builder() - } + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } - /** A builder for [RemovePrice]. */ - class Builder internal constructor() { + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) - private var externalPriceId: JsonField = JsonMissing.of() - private var priceId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) - internal fun from(removePrice: RemovePrice) = apply { - externalPriceId = removePrice.externalPriceId - priceId = removePrice.priceId - additionalProperties = removePrice.additionalProperties.toMutableMap() - } + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } - /** The external price id of the price to remove on the subscription. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) - /** - * Sets [Builder.externalPriceId] to an arbitrary JSON value. - * - * You should usually call [Builder.externalPriceId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun externalPriceId(externalPriceId: JsonField) = apply { - this.externalPriceId = externalPriceId - } + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } - /** The id of the price to remove on the subscription. */ - fun priceId(priceId: String?) = priceId(JsonField.ofNullable(priceId)) + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) - /** - * Sets [Builder.priceId] to an arbitrary JSON value. - * - * You should usually call [Builder.priceId] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun priceId(priceId: JsonField) = apply { this.priceId = priceId } + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) - /** - * Returns an immutable instance of [RemovePrice]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): RemovePrice = - RemovePrice(externalPriceId, priceId, additionalProperties.toMutableMap()) - } + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } - private var validated: Boolean = false + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) - fun validate(): RemovePrice = apply { - if (validated) { - return@apply - } + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } - externalPriceId() - priceId() - validated = true - } + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (if (externalPriceId.asKnown() == null) 0 else 1) + - (if (priceId.asKnown() == null) 0 else 1) + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is RemovePrice && - externalPriceId == other.externalPriceId && - priceId == other.priceId && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(externalPriceId, priceId, additionalProperties) - } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) - override fun hashCode(): Int = hashCode + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } - override fun toString() = - "RemovePrice{externalPriceId=$externalPriceId, priceId=$priceId, additionalProperties=$additionalProperties}" - } + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) - class ReplaceAdjustment - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val adjustment: JsonField, - private val replacesAdjustmentId: JsonField, - private val additionalProperties: MutableMap, - ) { + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - @JsonCreator - private constructor( - @JsonProperty("adjustment") - @ExcludeMissing - adjustment: JsonField = JsonMissing.of(), - @JsonProperty("replaces_adjustment_id") - @ExcludeMissing - replacesAdjustmentId: JsonField = JsonMissing.of(), - ) : this(adjustment, replacesAdjustmentId, mutableMapOf()) + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - /** - * The definition of a new adjustment to create and add to the subscription. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun adjustment(): Adjustment = adjustment.getRequired("adjustment") + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - /** - * The id of the adjustment on the plan to replace in the subscription. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun replacesAdjustmentId(): String = - replacesAdjustmentId.getRequired("replaces_adjustment_id") + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) - /** - * Returns the raw JSON value of [adjustment]. - * - * Unlike [adjustment], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("adjustment") - @ExcludeMissing - fun _adjustment(): JsonField = adjustment + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } - /** - * Returns the raw JSON value of [replacesAdjustmentId]. - * - * Unlike [replacesAdjustmentId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("replaces_adjustment_id") - @ExcludeMissing - fun _replacesAdjustmentId(): JsonField = replacesAdjustmentId + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun toBuilder() = Builder().from(this) + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - companion object { + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - /** - * Returns a mutable builder for constructing an instance of [ReplaceAdjustment]. - * - * The following fields are required: - * ```kotlin - * .adjustment() - * .replacesAdjustmentId() - * ``` - */ - fun builder() = Builder() - } + /** + * Returns an immutable instance of [EventOutput]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .eventOutputConfig() + * .itemId() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): EventOutput = + EventOutput( + checkRequired("cadence", cadence), + checkRequired("eventOutputConfig", eventOutputConfig), + checkRequired("itemId", itemId), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } - /** A builder for [ReplaceAdjustment]. */ - class Builder internal constructor() { + private var validated: Boolean = false - private var adjustment: JsonField? = null - private var replacesAdjustmentId: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() + fun validate(): EventOutput = apply { + if (validated) { + return@apply + } - internal fun from(replaceAdjustment: ReplaceAdjustment) = apply { - adjustment = replaceAdjustment.adjustment - replacesAdjustmentId = replaceAdjustment.replacesAdjustmentId - additionalProperties = replaceAdjustment.additionalProperties.toMutableMap() - } + cadence().validate() + eventOutputConfig().validate() + itemId() + _modelType().let { + if (it != JsonValue.from("event_output")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + metadata()?.validate() + referenceId() + validated = true + } - /** The definition of a new adjustment to create and add to the subscription. */ - fun adjustment(adjustment: Adjustment) = adjustment(JsonField.of(adjustment)) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - /** - * Sets [Builder.adjustment] to an arbitrary JSON value. - * - * You should usually call [Builder.adjustment] with a well-typed [Adjustment] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun adjustment(adjustment: JsonField) = apply { - this.adjustment = adjustment - } + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (eventOutputConfig.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + modelType.let { if (it == JsonValue.from("event_output")) 1 else 0 } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) - /** - * Alias for calling [adjustment] with - * `Adjustment.ofPercentageDiscount(percentageDiscount)`. - */ - fun adjustment(percentageDiscount: NewPercentageDiscount) = - adjustment(Adjustment.ofPercentageDiscount(percentageDiscount)) + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { - /** - * Alias for calling [adjustment] with the following: - * ```kotlin - * NewPercentageDiscount.builder() - * .adjustmentType(NewPercentageDiscount.AdjustmentType.PERCENTAGE_DISCOUNT) - * .percentageDiscount(percentageDiscount) - * .build() - * ``` - */ - fun percentageDiscountAdjustment(percentageDiscount: Double) = - adjustment( - NewPercentageDiscount.builder() - .adjustmentType(NewPercentageDiscount.AdjustmentType.PERCENTAGE_DISCOUNT) - .percentageDiscount(percentageDiscount) - .build() - ) + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value - /** Alias for calling [adjustment] with `Adjustment.ofUsageDiscount(usageDiscount)`. */ - fun adjustment(usageDiscount: NewUsageDiscount) = - adjustment(Adjustment.ofUsageDiscount(usageDiscount)) + companion object { - /** - * Alias for calling [adjustment] with the following: - * ```kotlin - * NewUsageDiscount.builder() - * .adjustmentType(NewUsageDiscount.AdjustmentType.USAGE_DISCOUNT) - * .usageDiscount(usageDiscount) - * .build() - * ``` - */ - fun usageDiscountAdjustment(usageDiscount: Double) = - adjustment( - NewUsageDiscount.builder() - .adjustmentType(NewUsageDiscount.AdjustmentType.USAGE_DISCOUNT) - .usageDiscount(usageDiscount) - .build() - ) + val ANNUAL = of("annual") - /** - * Alias for calling [adjustment] with `Adjustment.ofAmountDiscount(amountDiscount)`. - */ - fun adjustment(amountDiscount: NewAmountDiscount) = - adjustment(Adjustment.ofAmountDiscount(amountDiscount)) + val SEMI_ANNUAL = of("semi_annual") - /** - * Alias for calling [adjustment] with the following: - * ```kotlin - * NewAmountDiscount.builder() - * .adjustmentType(NewAmountDiscount.AdjustmentType.AMOUNT_DISCOUNT) - * .amountDiscount(amountDiscount) - * .build() - * ``` - */ - fun amountDiscountAdjustment(amountDiscount: String) = - adjustment( - NewAmountDiscount.builder() - .adjustmentType(NewAmountDiscount.AdjustmentType.AMOUNT_DISCOUNT) - .amountDiscount(amountDiscount) - .build() - ) + val MONTHLY = of("monthly") - /** Alias for calling [adjustment] with `Adjustment.ofMinimum(minimum)`. */ - fun adjustment(minimum: NewMinimum) = adjustment(Adjustment.ofMinimum(minimum)) + val QUARTERLY = of("quarterly") - /** Alias for calling [adjustment] with `Adjustment.ofMaximum(maximum)`. */ - fun adjustment(maximum: NewMaximum) = adjustment(Adjustment.ofMaximum(maximum)) + val ONE_TIME = of("one_time") - /** - * Alias for calling [adjustment] with the following: - * ```kotlin - * NewMaximum.builder() - * .adjustmentType(NewMaximum.AdjustmentType.MAXIMUM) - * .maximumAmount(maximumAmount) - * .build() - * ``` - */ - fun maximumAdjustment(maximumAmount: String) = - adjustment( - NewMaximum.builder() - .adjustmentType(NewMaximum.AdjustmentType.MAXIMUM) - .maximumAmount(maximumAmount) - .build() - ) + val CUSTOM = of("custom") - /** The id of the adjustment on the plan to replace in the subscription. */ - fun replacesAdjustmentId(replacesAdjustmentId: String) = - replacesAdjustmentId(JsonField.of(replacesAdjustmentId)) + fun of(value: String) = Cadence(JsonField.of(value)) + } - /** - * Sets [Builder.replacesAdjustmentId] to an arbitrary JSON value. - * - * You should usually call [Builder.replacesAdjustmentId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun replacesAdjustmentId(replacesAdjustmentId: JsonField) = apply { - this.replacesAdjustmentId = replacesAdjustmentId - } + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + private var validated: Boolean = false - /** - * Returns an immutable instance of [ReplaceAdjustment]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```kotlin - * .adjustment() - * .replacesAdjustmentId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): ReplaceAdjustment = - ReplaceAdjustment( - checkRequired("adjustment", adjustment), - checkRequired("replacesAdjustmentId", replacesAdjustmentId), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): ReplaceAdjustment = apply { - if (validated) { - return@apply - } - - adjustment().validate() - replacesAdjustmentId() - validated = true - } + fun validate(): Cadence = apply { + if (validated) { + return@apply + } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + known() + validated = true + } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (adjustment.asKnown()?.validity() ?: 0) + - (if (replacesAdjustmentId.asKnown() == null) 0 else 1) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - /** The definition of a new adjustment to create and add to the subscription. */ - @JsonDeserialize(using = Adjustment.Deserializer::class) - @JsonSerialize(using = Adjustment.Serializer::class) - class Adjustment - private constructor( - private val percentageDiscount: NewPercentageDiscount? = null, - private val usageDiscount: NewUsageDiscount? = null, - private val amountDiscount: NewAmountDiscount? = null, - private val minimum: NewMinimum? = null, - private val maximum: NewMaximum? = null, - private val _json: JsonValue? = null, - ) { + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - fun percentageDiscount(): NewPercentageDiscount? = percentageDiscount + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun usageDiscount(): NewUsageDiscount? = usageDiscount + return other is Cadence && value == other.value + } - fun amountDiscount(): NewAmountDiscount? = amountDiscount + override fun hashCode() = value.hashCode() - fun minimum(): NewMinimum? = minimum + override fun toString() = value.toString() + } - fun maximum(): NewMaximum? = maximum + /** Configuration for event_output pricing */ + class EventOutputConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val unitRatingKey: JsonField, + private val defaultUnitRate: JsonField, + private val groupingKey: JsonField, + private val additionalProperties: MutableMap, + ) { - fun isPercentageDiscount(): Boolean = percentageDiscount != null + @JsonCreator + private constructor( + @JsonProperty("unit_rating_key") + @ExcludeMissing + unitRatingKey: JsonField = JsonMissing.of(), + @JsonProperty("default_unit_rate") + @ExcludeMissing + defaultUnitRate: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + ) : this(unitRatingKey, defaultUnitRate, groupingKey, mutableMapOf()) - fun isUsageDiscount(): Boolean = usageDiscount != null + /** + * The key in the event data to extract the unit rate from. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun unitRatingKey(): String = unitRatingKey.getRequired("unit_rating_key") - fun isAmountDiscount(): Boolean = amountDiscount != null + /** + * If provided, this amount will be used as the unit rate when an event does not + * have a value for the `unit_rating_key`. If not provided, events missing a + * unit rate will be ignored. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun defaultUnitRate(): String? = + defaultUnitRate.getNullable("default_unit_rate") - fun isMinimum(): Boolean = minimum != null + /** + * An optional key in the event data to group by (e.g., event ID). All events + * will also be grouped by their unit rate. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun groupingKey(): String? = groupingKey.getNullable("grouping_key") - fun isMaximum(): Boolean = maximum != null + /** + * Returns the raw JSON value of [unitRatingKey]. + * + * Unlike [unitRatingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_rating_key") + @ExcludeMissing + fun _unitRatingKey(): JsonField = unitRatingKey - fun asPercentageDiscount(): NewPercentageDiscount = - percentageDiscount.getOrThrow("percentageDiscount") + /** + * Returns the raw JSON value of [defaultUnitRate]. + * + * Unlike [defaultUnitRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("default_unit_rate") + @ExcludeMissing + fun _defaultUnitRate(): JsonField = defaultUnitRate - fun asUsageDiscount(): NewUsageDiscount = usageDiscount.getOrThrow("usageDiscount") + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey - fun asAmountDiscount(): NewAmountDiscount = amountDiscount.getOrThrow("amountDiscount") + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - fun asMinimum(): NewMinimum = minimum.getOrThrow("minimum") + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - fun asMaximum(): NewMaximum = maximum.getOrThrow("maximum") + fun toBuilder() = Builder().from(this) - fun _json(): JsonValue? = _json + companion object { - fun accept(visitor: Visitor): T = - when { - percentageDiscount != null -> - visitor.visitPercentageDiscount(percentageDiscount) - usageDiscount != null -> visitor.visitUsageDiscount(usageDiscount) - amountDiscount != null -> visitor.visitAmountDiscount(amountDiscount) - minimum != null -> visitor.visitMinimum(minimum) - maximum != null -> visitor.visitMaximum(maximum) - else -> visitor.unknown(_json) - } + /** + * Returns a mutable builder for constructing an instance of + * [EventOutputConfig]. + * + * The following fields are required: + * ```kotlin + * .unitRatingKey() + * ``` + */ + fun builder() = Builder() + } - private var validated: Boolean = false + /** A builder for [EventOutputConfig]. */ + class Builder internal constructor() { - fun validate(): Adjustment = apply { - if (validated) { - return@apply - } + private var unitRatingKey: JsonField? = null + private var defaultUnitRate: JsonField = JsonMissing.of() + private var groupingKey: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() - accept( - object : Visitor { - override fun visitPercentageDiscount( - percentageDiscount: NewPercentageDiscount - ) { - percentageDiscount.validate() + internal fun from(eventOutputConfig: EventOutputConfig) = apply { + unitRatingKey = eventOutputConfig.unitRatingKey + defaultUnitRate = eventOutputConfig.defaultUnitRate + groupingKey = eventOutputConfig.groupingKey + additionalProperties = + eventOutputConfig.additionalProperties.toMutableMap() } - override fun visitUsageDiscount(usageDiscount: NewUsageDiscount) { - usageDiscount.validate() - } + /** The key in the event data to extract the unit rate from. */ + fun unitRatingKey(unitRatingKey: String) = + unitRatingKey(JsonField.of(unitRatingKey)) - override fun visitAmountDiscount(amountDiscount: NewAmountDiscount) { - amountDiscount.validate() + /** + * Sets [Builder.unitRatingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.unitRatingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun unitRatingKey(unitRatingKey: JsonField) = apply { + this.unitRatingKey = unitRatingKey } - override fun visitMinimum(minimum: NewMinimum) { - minimum.validate() - } + /** + * If provided, this amount will be used as the unit rate when an event does + * not have a value for the `unit_rating_key`. If not provided, events + * missing a unit rate will be ignored. + */ + fun defaultUnitRate(defaultUnitRate: String?) = + defaultUnitRate(JsonField.ofNullable(defaultUnitRate)) - override fun visitMaximum(maximum: NewMaximum) { - maximum.validate() - } - } - ) - validated = true - } + /** + * Sets [Builder.defaultUnitRate] to an arbitrary JSON value. + * + * You should usually call [Builder.defaultUnitRate] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun defaultUnitRate(defaultUnitRate: JsonField) = apply { + this.defaultUnitRate = defaultUnitRate + } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** + * An optional key in the event data to group by (e.g., event ID). All + * events will also be grouped by their unit rate. + */ + fun groupingKey(groupingKey: String?) = + groupingKey(JsonField.ofNullable(groupingKey)) - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitPercentageDiscount( - percentageDiscount: NewPercentageDiscount - ) = percentageDiscount.validity() + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } - override fun visitUsageDiscount(usageDiscount: NewUsageDiscount) = - usageDiscount.validity() + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - override fun visitAmountDiscount(amountDiscount: NewAmountDiscount) = - amountDiscount.validity() + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - override fun visitMinimum(minimum: NewMinimum) = minimum.validity() + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - override fun visitMaximum(maximum: NewMaximum) = maximum.validity() + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - override fun unknown(json: JsonValue?) = 0 + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [EventOutputConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .unitRatingKey() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): EventOutputConfig = + EventOutputConfig( + checkRequired("unitRatingKey", unitRatingKey), + defaultUnitRate, + groupingKey, + additionalProperties.toMutableMap(), + ) } - ) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + private var validated: Boolean = false - return other is Adjustment && - percentageDiscount == other.percentageDiscount && - usageDiscount == other.usageDiscount && - amountDiscount == other.amountDiscount && - minimum == other.minimum && - maximum == other.maximum - } + fun validate(): EventOutputConfig = apply { + if (validated) { + return@apply + } - override fun hashCode(): Int = - Objects.hash(percentageDiscount, usageDiscount, amountDiscount, minimum, maximum) + unitRatingKey() + defaultUnitRate() + groupingKey() + validated = true + } - override fun toString(): String = - when { - percentageDiscount != null -> - "Adjustment{percentageDiscount=$percentageDiscount}" - usageDiscount != null -> "Adjustment{usageDiscount=$usageDiscount}" - amountDiscount != null -> "Adjustment{amountDiscount=$amountDiscount}" - minimum != null -> "Adjustment{minimum=$minimum}" - maximum != null -> "Adjustment{maximum=$maximum}" - _json != null -> "Adjustment{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Adjustment") - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - companion object { + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (unitRatingKey.asKnown() == null) 0 else 1) + + (if (defaultUnitRate.asKnown() == null) 0 else 1) + + (if (groupingKey.asKnown() == null) 0 else 1) - fun ofPercentageDiscount(percentageDiscount: NewPercentageDiscount) = - Adjustment(percentageDiscount = percentageDiscount) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun ofUsageDiscount(usageDiscount: NewUsageDiscount) = - Adjustment(usageDiscount = usageDiscount) + return other is EventOutputConfig && + unitRatingKey == other.unitRatingKey && + defaultUnitRate == other.defaultUnitRate && + groupingKey == other.groupingKey && + additionalProperties == other.additionalProperties + } - fun ofAmountDiscount(amountDiscount: NewAmountDiscount) = - Adjustment(amountDiscount = amountDiscount) + private val hashCode: Int by lazy { + Objects.hash( + unitRatingKey, + defaultUnitRate, + groupingKey, + additionalProperties, + ) + } - fun ofMinimum(minimum: NewMinimum) = Adjustment(minimum = minimum) + override fun hashCode(): Int = hashCode - fun ofMaximum(maximum: NewMaximum) = Adjustment(maximum = maximum) - } + override fun toString() = + "EventOutputConfig{unitRatingKey=$unitRatingKey, defaultUnitRate=$defaultUnitRate, groupingKey=$groupingKey, additionalProperties=$additionalProperties}" + } - /** - * An interface that defines how to map each variant of [Adjustment] to a value of type - * [T]. - */ - interface Visitor { + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { - fun visitPercentageDiscount(percentageDiscount: NewPercentageDiscount): T + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties - fun visitUsageDiscount(usageDiscount: NewUsageDiscount): T + fun toBuilder() = Builder().from(this) - fun visitAmountDiscount(amountDiscount: NewAmountDiscount): T + companion object { - fun visitMinimum(minimum: NewMinimum): T + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } - fun visitMaximum(maximum: NewMaximum): T + /** A builder for [Metadata]. */ + class Builder internal constructor() { - /** - * Maps an unknown variant of [Adjustment] to a value of type [T]. - * - * An instance of [Adjustment] can contain an unknown variant if it was deserialized - * from data that doesn't match any known variant. For example, if the SDK is on an - * older version than the API, then the API may respond with new variants that the - * SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown Adjustment: $json") - } - } + private var additionalProperties: MutableMap = + mutableMapOf() - internal class Deserializer : BaseDeserializer(Adjustment::class) { + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } - override fun ObjectCodec.deserialize(node: JsonNode): Adjustment { - val json = JsonValue.fromJsonNode(node) - val adjustmentType = json.asObject()?.get("adjustment_type")?.asString() + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - when (adjustmentType) { - "percentage_discount" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Adjustment(percentageDiscount = it, _json = json) } - ?: Adjustment(_json = json) + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) } - "usage_discount" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(usageDiscount = it, _json = json) - } ?: Adjustment(_json = json) + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) } - "amount_discount" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(amountDiscount = it, _json = json) - } ?: Adjustment(_json = json) + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) } - "minimum" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(minimum = it, _json = json) - } ?: Adjustment(_json = json) + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply } - "maximum" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(maximum = it, _json = json) - } ?: Adjustment(_json = json) + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } + + return other is Metadata && + additionalProperties == other.additionalProperties } - return Adjustment(_json = json) - } - } + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - internal class Serializer : BaseSerializer(Adjustment::class) { + override fun hashCode(): Int = hashCode - override fun serialize( - value: Adjustment, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.percentageDiscount != null -> - generator.writeObject(value.percentageDiscount) - value.usageDiscount != null -> generator.writeObject(value.usageDiscount) - value.amountDiscount != null -> generator.writeObject(value.amountDiscount) - value.minimum != null -> generator.writeObject(value.minimum) - value.maximum != null -> generator.writeObject(value.maximum) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Adjustment") + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } + + return other is EventOutput && + cadence == other.cadence && + eventOutputConfig == other.eventOutputConfig && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + eventOutputConfig, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties, + ) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "EventOutput{cadence=$cadence, eventOutputConfig=$eventOutputConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } } @@ -15464,238 +16143,213 @@ private constructor( return true } - return other is ReplaceAdjustment && - adjustment == other.adjustment && - replacesAdjustmentId == other.replacesAdjustmentId && + return other is AddPrice && + allocationPrice == other.allocationPrice && + discounts == other.discounts && + endDate == other.endDate && + externalPriceId == other.externalPriceId && + maximumAmount == other.maximumAmount && + minimumAmount == other.minimumAmount && + planPhaseOrder == other.planPhaseOrder && + price == other.price && + priceId == other.priceId && + startDate == other.startDate && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(adjustment, replacesAdjustmentId, additionalProperties) + Objects.hash( + allocationPrice, + discounts, + endDate, + externalPriceId, + maximumAmount, + minimumAmount, + planPhaseOrder, + price, + priceId, + startDate, + additionalProperties, + ) } override fun hashCode(): Int = hashCode override fun toString() = - "ReplaceAdjustment{adjustment=$adjustment, replacesAdjustmentId=$replacesAdjustmentId, additionalProperties=$additionalProperties}" + "AddPrice{allocationPrice=$allocationPrice, discounts=$discounts, endDate=$endDate, externalPriceId=$externalPriceId, maximumAmount=$maximumAmount, minimumAmount=$minimumAmount, planPhaseOrder=$planPhaseOrder, price=$price, priceId=$priceId, startDate=$startDate, additionalProperties=$additionalProperties}" } - class ReplacePrice - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val replacesPriceId: JsonField, - private val allocationPrice: JsonField, - private val discounts: JsonField>, - private val externalPriceId: JsonField, - private val fixedPriceQuantity: JsonField, - private val maximumAmount: JsonField, - private val minimumAmount: JsonField, - private val price: JsonField, - private val priceId: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("replaces_price_id") - @ExcludeMissing - replacesPriceId: JsonField = JsonMissing.of(), - @JsonProperty("allocation_price") - @ExcludeMissing - allocationPrice: JsonField = JsonMissing.of(), - @JsonProperty("discounts") - @ExcludeMissing - discounts: JsonField> = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("maximum_amount") - @ExcludeMissing - maximumAmount: JsonField = JsonMissing.of(), - @JsonProperty("minimum_amount") - @ExcludeMissing - minimumAmount: JsonField = JsonMissing.of(), - @JsonProperty("price") @ExcludeMissing price: JsonField = JsonMissing.of(), - @JsonProperty("price_id") @ExcludeMissing priceId: JsonField = JsonMissing.of(), - ) : this( - replacesPriceId, - allocationPrice, - discounts, - externalPriceId, - fixedPriceQuantity, - maximumAmount, - minimumAmount, - price, - priceId, - mutableMapOf(), - ) + /** + * Reset billing periods to be aligned with the plan change's effective date or start of the + * month. Defaults to `unchanged` which keeps subscription's existing billing cycle alignment. + */ + class BillingCycleAlignment + @JsonCreator + private constructor(private val value: JsonField) : Enum { /** - * The id of the price on the plan to replace in the subscription. + * Returns this class instance's raw value. * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. */ - fun replacesPriceId(): String = replacesPriceId.getRequired("replaces_price_id") + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - /** - * The definition of a new allocation price to create and add to the subscription. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun allocationPrice(): NewAllocationPrice? = allocationPrice.getNullable("allocation_price") + companion object { - /** - * [DEPRECATED] Use add_adjustments instead. The subscription's discounts for the - * replacement price. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - @Deprecated("deprecated") - fun discounts(): List? = discounts.getNullable("discounts") + val UNCHANGED = of("unchanged") - /** - * The external price id of the price to add to the subscription. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + val PLAN_CHANGE_DATE = of("plan_change_date") - /** - * The new quantity of the price, if the price is a fixed price. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun fixedPriceQuantity(): Double? = fixedPriceQuantity.getNullable("fixed_price_quantity") + val START_OF_MONTH = of("start_of_month") - /** - * [DEPRECATED] Use add_adjustments instead. The subscription's maximum amount for the - * replacement price. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - @Deprecated("deprecated") - fun maximumAmount(): String? = maximumAmount.getNullable("maximum_amount") + fun of(value: String) = BillingCycleAlignment(JsonField.of(value)) + } - /** - * [DEPRECATED] Use add_adjustments instead. The subscription's minimum amount for the - * replacement price. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - @Deprecated("deprecated") - fun minimumAmount(): String? = minimumAmount.getNullable("minimum_amount") + /** An enum containing [BillingCycleAlignment]'s known values. */ + enum class Known { + UNCHANGED, + PLAN_CHANGE_DATE, + START_OF_MONTH, + } /** - * New subscription price request body params. + * An enum containing [BillingCycleAlignment]'s known values, as well as an [_UNKNOWN] + * member. * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). + * An instance of [BillingCycleAlignment] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. */ - fun price(): Price? = price.getNullable("price") + enum class Value { + UNCHANGED, + PLAN_CHANGE_DATE, + START_OF_MONTH, + /** + * An enum member indicating that [BillingCycleAlignment] was instantiated with an + * unknown value. + */ + _UNKNOWN, + } /** - * The id of the price to add to the subscription. + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. */ - fun priceId(): String? = priceId.getNullable("price_id") + fun value(): Value = + when (this) { + UNCHANGED -> Value.UNCHANGED + PLAN_CHANGE_DATE -> Value.PLAN_CHANGE_DATE + START_OF_MONTH -> Value.START_OF_MONTH + else -> Value._UNKNOWN + } /** - * Returns the raw JSON value of [replacesPriceId]. + * Returns an enum member corresponding to this class instance's value. * - * Unlike [replacesPriceId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("replaces_price_id") - @ExcludeMissing - fun _replacesPriceId(): JsonField = replacesPriceId - - /** - * Returns the raw JSON value of [allocationPrice]. + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. * - * Unlike [allocationPrice], this method doesn't throw if the JSON field has an unexpected - * type. + * @throws OrbInvalidDataException if this class instance's value is a not a known member. */ - @JsonProperty("allocation_price") - @ExcludeMissing - fun _allocationPrice(): JsonField = allocationPrice + fun known(): Known = + when (this) { + UNCHANGED -> Known.UNCHANGED + PLAN_CHANGE_DATE -> Known.PLAN_CHANGE_DATE + START_OF_MONTH -> Known.START_OF_MONTH + else -> throw OrbInvalidDataException("Unknown BillingCycleAlignment: $value") + } /** - * Returns the raw JSON value of [discounts]. + * Returns this class instance's primitive wire representation. * - * Unlike [discounts], this method doesn't throw if the JSON field has an unexpected type. - */ - @Deprecated("deprecated") - @JsonProperty("discounts") - @ExcludeMissing - fun _discounts(): JsonField> = discounts - - /** - * Returns the raw JSON value of [externalPriceId]. + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. * - * Unlike [externalPriceId], this method doesn't throw if the JSON field has an unexpected - * type. + * @throws OrbInvalidDataException if this class instance's value does not have the expected + * primitive type. */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") - /** - * Returns the raw JSON value of [fixedPriceQuantity]. - * - * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + private var validated: Boolean = false - /** - * Returns the raw JSON value of [maximumAmount]. - * - * Unlike [maximumAmount], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @Deprecated("deprecated") - @JsonProperty("maximum_amount") - @ExcludeMissing - fun _maximumAmount(): JsonField = maximumAmount + fun validate(): BillingCycleAlignment = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } /** - * Returns the raw JSON value of [minimumAmount]. + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * Unlike [minimumAmount], this method doesn't throw if the JSON field has an unexpected - * type. + * Used for best match union deserialization. */ - @Deprecated("deprecated") - @JsonProperty("minimum_amount") - @ExcludeMissing - fun _minimumAmount(): JsonField = minimumAmount + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BillingCycleAlignment && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class RemoveAdjustment + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val adjustmentId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("adjustment_id") + @ExcludeMissing + adjustmentId: JsonField = JsonMissing.of() + ) : this(adjustmentId, mutableMapOf()) /** - * Returns the raw JSON value of [price]. + * The id of the adjustment to remove on the subscription. * - * Unlike [price], this method doesn't throw if the JSON field has an unexpected type. + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ - @JsonProperty("price") @ExcludeMissing fun _price(): JsonField = price + fun adjustmentId(): String = adjustmentId.getRequired("adjustment_id") /** - * Returns the raw JSON value of [priceId]. + * Returns the raw JSON value of [adjustmentId]. * - * Unlike [priceId], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [adjustmentId], this method doesn't throw if the JSON field has an unexpected + * type. */ - @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId + @JsonProperty("adjustment_id") + @ExcludeMissing + fun _adjustmentId(): JsonField = adjustmentId @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -15712,107 +16366,205 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [ReplacePrice]. + * Returns a mutable builder for constructing an instance of [RemoveAdjustment]. * * The following fields are required: * ```kotlin - * .replacesPriceId() + * .adjustmentId() * ``` */ fun builder() = Builder() } - /** A builder for [ReplacePrice]. */ + /** A builder for [RemoveAdjustment]. */ class Builder internal constructor() { - private var replacesPriceId: JsonField? = null - private var allocationPrice: JsonField = JsonMissing.of() - private var discounts: JsonField>? = null - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var maximumAmount: JsonField = JsonMissing.of() - private var minimumAmount: JsonField = JsonMissing.of() - private var price: JsonField = JsonMissing.of() - private var priceId: JsonField = JsonMissing.of() + private var adjustmentId: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(replacePrice: ReplacePrice) = apply { - replacesPriceId = replacePrice.replacesPriceId - allocationPrice = replacePrice.allocationPrice - discounts = replacePrice.discounts.map { it.toMutableList() } - externalPriceId = replacePrice.externalPriceId - fixedPriceQuantity = replacePrice.fixedPriceQuantity - maximumAmount = replacePrice.maximumAmount - minimumAmount = replacePrice.minimumAmount - price = replacePrice.price - priceId = replacePrice.priceId - additionalProperties = replacePrice.additionalProperties.toMutableMap() + internal fun from(removeAdjustment: RemoveAdjustment) = apply { + adjustmentId = removeAdjustment.adjustmentId + additionalProperties = removeAdjustment.additionalProperties.toMutableMap() } - /** The id of the price on the plan to replace in the subscription. */ - fun replacesPriceId(replacesPriceId: String) = - replacesPriceId(JsonField.of(replacesPriceId)) + /** The id of the adjustment to remove on the subscription. */ + fun adjustmentId(adjustmentId: String) = adjustmentId(JsonField.of(adjustmentId)) /** - * Sets [Builder.replacesPriceId] to an arbitrary JSON value. + * Sets [Builder.adjustmentId] to an arbitrary JSON value. * - * You should usually call [Builder.replacesPriceId] with a well-typed [String] value + * You should usually call [Builder.adjustmentId] with a well-typed [String] value * instead. This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun replacesPriceId(replacesPriceId: JsonField) = apply { - this.replacesPriceId = replacesPriceId + fun adjustmentId(adjustmentId: JsonField) = apply { + this.adjustmentId = adjustmentId } - /** The definition of a new allocation price to create and add to the subscription. */ - fun allocationPrice(allocationPrice: NewAllocationPrice?) = - allocationPrice(JsonField.ofNullable(allocationPrice)) - - /** - * Sets [Builder.allocationPrice] to an arbitrary JSON value. - * - * You should usually call [Builder.allocationPrice] with a well-typed - * [NewAllocationPrice] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun allocationPrice(allocationPrice: JsonField) = apply { - this.allocationPrice = allocationPrice + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) } - /** - * [DEPRECATED] Use add_adjustments instead. The subscription's discounts for the - * replacement price. - */ - @Deprecated("deprecated") - fun discounts(discounts: List?) = - discounts(JsonField.ofNullable(discounts)) + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * Sets [Builder.discounts] to an arbitrary JSON value. - * - * You should usually call [Builder.discounts] with a well-typed - * `List` value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - @Deprecated("deprecated") - fun discounts(discounts: JsonField>) = apply { - this.discounts = discounts.map { it.toMutableList() } + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) } /** - * Adds a single [DiscountOverride] to [discounts]. + * Returns an immutable instance of [RemoveAdjustment]. * - * @throws IllegalStateException if the field was previously set to a non-list. + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .adjustmentId() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ - @Deprecated("deprecated") - fun addDiscount(discount: DiscountOverride) = apply { - discounts = - (discounts ?: JsonField.of(mutableListOf())).also { - checkKnown("discounts", it).add(discount) - } + fun build(): RemoveAdjustment = + RemoveAdjustment( + checkRequired("adjustmentId", adjustmentId), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): RemoveAdjustment = apply { + if (validated) { + return@apply } - /** The external price id of the price to add to the subscription. */ + adjustmentId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = (if (adjustmentId.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RemoveAdjustment && + adjustmentId == other.adjustmentId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(adjustmentId, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "RemoveAdjustment{adjustmentId=$adjustmentId, additionalProperties=$additionalProperties}" + } + + class RemovePrice + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val externalPriceId: JsonField, + private val priceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("price_id") @ExcludeMissing priceId: JsonField = JsonMissing.of(), + ) : this(externalPriceId, priceId, mutableMapOf()) + + /** + * The external price id of the price to remove on the subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * The id of the price to remove on the subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun priceId(): String? = priceId.getNullable("price_id") + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [priceId]. + * + * Unlike [priceId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [RemovePrice]. */ + fun builder() = Builder() + } + + /** A builder for [RemovePrice]. */ + class Builder internal constructor() { + + private var externalPriceId: JsonField = JsonMissing.of() + private var priceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(removePrice: RemovePrice) = apply { + externalPriceId = removePrice.externalPriceId + priceId = removePrice.priceId + additionalProperties = removePrice.additionalProperties.toMutableMap() + } + + /** The external price id of the price to remove on the subscription. */ fun externalPriceId(externalPriceId: String?) = externalPriceId(JsonField.ofNullable(externalPriceId)) @@ -15827,245 +16579,309 @@ private constructor( this.externalPriceId = externalPriceId } - /** The new quantity of the price, if the price is a fixed price. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = - fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) - - /** - * Alias for [Builder.fixedPriceQuantity]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) + /** The id of the price to remove on the subscription. */ + fun priceId(priceId: String?) = priceId(JsonField.ofNullable(priceId)) /** - * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * Sets [Builder.priceId] to an arbitrary JSON value. * - * You should usually call [Builder.fixedPriceQuantity] with a well-typed [Double] value - * instead. This method is primarily for setting the field to an undocumented or not yet + * You should usually call [Builder.priceId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { - this.fixedPriceQuantity = fixedPriceQuantity + fun priceId(priceId: JsonField) = apply { this.priceId = priceId } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) } - /** - * [DEPRECATED] Use add_adjustments instead. The subscription's maximum amount for the - * replacement price. - */ - @Deprecated("deprecated") - fun maximumAmount(maximumAmount: String?) = - maximumAmount(JsonField.ofNullable(maximumAmount)) + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * Sets [Builder.maximumAmount] to an arbitrary JSON value. - * - * You should usually call [Builder.maximumAmount] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - @Deprecated("deprecated") - fun maximumAmount(maximumAmount: JsonField) = apply { - this.maximumAmount = maximumAmount + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) } - /** - * [DEPRECATED] Use add_adjustments instead. The subscription's minimum amount for the - * replacement price. - */ - @Deprecated("deprecated") - fun minimumAmount(minimumAmount: String?) = - minimumAmount(JsonField.ofNullable(minimumAmount)) + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } /** - * Sets [Builder.minimumAmount] to an arbitrary JSON value. + * Returns an immutable instance of [RemovePrice]. * - * You should usually call [Builder.minimumAmount] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. + * Further updates to this [Builder] will not mutate the returned instance. */ - @Deprecated("deprecated") - fun minimumAmount(minimumAmount: JsonField) = apply { - this.minimumAmount = minimumAmount - } + fun build(): RemovePrice = + RemovePrice(externalPriceId, priceId, additionalProperties.toMutableMap()) + } - /** New subscription price request body params. */ - fun price(price: Price?) = price(JsonField.ofNullable(price)) + private var validated: Boolean = false - /** - * Sets [Builder.price] to an arbitrary JSON value. - * - * You should usually call [Builder.price] with a well-typed [Price] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun price(price: JsonField) = apply { this.price = price } + fun validate(): RemovePrice = apply { + if (validated) { + return@apply + } - /** Alias for calling [price] with `Price.ofUnit(unit)`. */ - fun price(unit: NewSubscriptionUnitPrice) = price(Price.ofUnit(unit)) + externalPriceId() + priceId() + validated = true + } - /** Alias for calling [price] with `Price.ofTiered(tiered)`. */ - fun price(tiered: NewSubscriptionTieredPrice) = price(Price.ofTiered(tiered)) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - /** Alias for calling [price] with `Price.ofBulk(bulk)`. */ - fun price(bulk: NewSubscriptionBulkPrice) = price(Price.ofBulk(bulk)) + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (priceId.asKnown() == null) 0 else 1) - /** Alias for calling [price] with `Price.ofBulkWithFilters(bulkWithFilters)`. */ - fun price(bulkWithFilters: Price.BulkWithFilters) = - price(Price.ofBulkWithFilters(bulkWithFilters)) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** Alias for calling [price] with `Price.ofPackage(package_)`. */ - fun price(package_: NewSubscriptionPackagePrice) = price(Price.ofPackage(package_)) + return other is RemovePrice && + externalPriceId == other.externalPriceId && + priceId == other.priceId && + additionalProperties == other.additionalProperties + } - /** Alias for calling [price] with `Price.ofMatrix(matrix)`. */ - fun price(matrix: NewSubscriptionMatrixPrice) = price(Price.ofMatrix(matrix)) + private val hashCode: Int by lazy { + Objects.hash(externalPriceId, priceId, additionalProperties) + } - /** - * Alias for calling [price] with `Price.ofThresholdTotalAmount(thresholdTotalAmount)`. - */ - fun price(thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice) = - price(Price.ofThresholdTotalAmount(thresholdTotalAmount)) + override fun hashCode(): Int = hashCode - /** Alias for calling [price] with `Price.ofTieredPackage(tieredPackage)`. */ - fun price(tieredPackage: NewSubscriptionTieredPackagePrice) = - price(Price.ofTieredPackage(tieredPackage)) + override fun toString() = + "RemovePrice{externalPriceId=$externalPriceId, priceId=$priceId, additionalProperties=$additionalProperties}" + } - /** Alias for calling [price] with `Price.ofTieredWithMinimum(tieredWithMinimum)`. */ - fun price(tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice) = - price(Price.ofTieredWithMinimum(tieredWithMinimum)) + class ReplaceAdjustment + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val adjustment: JsonField, + private val replacesAdjustmentId: JsonField, + private val additionalProperties: MutableMap, + ) { - /** Alias for calling [price] with `Price.ofGroupedTiered(groupedTiered)`. */ - fun price(groupedTiered: NewSubscriptionGroupedTieredPrice) = - price(Price.ofGroupedTiered(groupedTiered)) + @JsonCreator + private constructor( + @JsonProperty("adjustment") + @ExcludeMissing + adjustment: JsonField = JsonMissing.of(), + @JsonProperty("replaces_adjustment_id") + @ExcludeMissing + replacesAdjustmentId: JsonField = JsonMissing.of(), + ) : this(adjustment, replacesAdjustmentId, mutableMapOf()) - /** - * Alias for calling [price] with - * `Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)`. - */ - fun price(tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice) = - price(Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)) + /** + * The definition of a new adjustment to create and add to the subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun adjustment(): Adjustment = adjustment.getRequired("adjustment") - /** - * Alias for calling [price] with - * `Price.ofPackageWithAllocation(packageWithAllocation)`. - */ - fun price(packageWithAllocation: NewSubscriptionPackageWithAllocationPrice) = - price(Price.ofPackageWithAllocation(packageWithAllocation)) + /** + * The id of the adjustment on the plan to replace in the subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun replacesAdjustmentId(): String = + replacesAdjustmentId.getRequired("replaces_adjustment_id") - /** Alias for calling [price] with `Price.ofUnitWithPercent(unitWithPercent)`. */ - fun price(unitWithPercent: NewSubscriptionUnitWithPercentPrice) = - price(Price.ofUnitWithPercent(unitWithPercent)) + /** + * Returns the raw JSON value of [adjustment]. + * + * Unlike [adjustment], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("adjustment") + @ExcludeMissing + fun _adjustment(): JsonField = adjustment - /** - * Alias for calling [price] with `Price.ofMatrixWithAllocation(matrixWithAllocation)`. - */ - fun price(matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice) = - price(Price.ofMatrixWithAllocation(matrixWithAllocation)) + /** + * Returns the raw JSON value of [replacesAdjustmentId]. + * + * Unlike [replacesAdjustmentId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("replaces_adjustment_id") + @ExcludeMissing + fun _replacesAdjustmentId(): JsonField = replacesAdjustmentId - /** - * Alias for calling [price] with `Price.ofTieredWithProration(tieredWithProration)`. - */ - fun price(tieredWithProration: Price.TieredWithProration) = - price(Price.ofTieredWithProration(tieredWithProration)) + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - /** Alias for calling [price] with `Price.ofUnitWithProration(unitWithProration)`. */ - fun price(unitWithProration: NewSubscriptionUnitWithProrationPrice) = - price(Price.ofUnitWithProration(unitWithProration)) + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - /** Alias for calling [price] with `Price.ofGroupedAllocation(groupedAllocation)`. */ - fun price(groupedAllocation: NewSubscriptionGroupedAllocationPrice) = - price(Price.ofGroupedAllocation(groupedAllocation)) + fun toBuilder() = Builder().from(this) - /** Alias for calling [price] with `Price.ofBulkWithProration(bulkWithProration)`. */ - fun price(bulkWithProration: NewSubscriptionBulkWithProrationPrice) = - price(Price.ofBulkWithProration(bulkWithProration)) + companion object { /** - * Alias for calling [price] with - * `Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)`. + * Returns a mutable builder for constructing an instance of [ReplaceAdjustment]. + * + * The following fields are required: + * ```kotlin + * .adjustment() + * .replacesAdjustmentId() + * ``` */ - fun price(groupedWithProratedMinimum: NewSubscriptionGroupedWithProratedMinimumPrice) = - price(Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)) + fun builder() = Builder() + } - /** - * Alias for calling [price] with - * `Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)`. - */ - fun price(groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice) = - price(Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)) + /** A builder for [ReplaceAdjustment]. */ + class Builder internal constructor() { - /** - * Alias for calling [price] with - * `Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)`. - */ - fun price(groupedWithMinMaxThresholds: Price.GroupedWithMinMaxThresholds) = - price(Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)) + private var adjustment: JsonField? = null + private var replacesAdjustmentId: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() - /** - * Alias for calling [price] with - * `Price.ofMatrixWithDisplayName(matrixWithDisplayName)`. - */ - fun price(matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice) = - price(Price.ofMatrixWithDisplayName(matrixWithDisplayName)) + internal fun from(replaceAdjustment: ReplaceAdjustment) = apply { + adjustment = replaceAdjustment.adjustment + replacesAdjustmentId = replaceAdjustment.replacesAdjustmentId + additionalProperties = replaceAdjustment.additionalProperties.toMutableMap() + } - /** - * Alias for calling [price] with `Price.ofGroupedTieredPackage(groupedTieredPackage)`. - */ - fun price(groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice) = - price(Price.ofGroupedTieredPackage(groupedTieredPackage)) + /** The definition of a new adjustment to create and add to the subscription. */ + fun adjustment(adjustment: Adjustment) = adjustment(JsonField.of(adjustment)) /** - * Alias for calling [price] with - * `Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)`. + * Sets [Builder.adjustment] to an arbitrary JSON value. + * + * You should usually call [Builder.adjustment] with a well-typed [Adjustment] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun price(maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice) = - price(Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)) + fun adjustment(adjustment: JsonField) = apply { + this.adjustment = adjustment + } /** - * Alias for calling [price] with - * `Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)`. + * Alias for calling [adjustment] with + * `Adjustment.ofPercentageDiscount(percentageDiscount)`. */ - fun price( - scalableMatrixWithUnitPricing: NewSubscriptionScalableMatrixWithUnitPricingPrice - ) = price(Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)) + fun adjustment(percentageDiscount: NewPercentageDiscount) = + adjustment(Adjustment.ofPercentageDiscount(percentageDiscount)) /** - * Alias for calling [price] with - * `Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)`. + * Alias for calling [adjustment] with the following: + * ```kotlin + * NewPercentageDiscount.builder() + * .adjustmentType(NewPercentageDiscount.AdjustmentType.PERCENTAGE_DISCOUNT) + * .percentageDiscount(percentageDiscount) + * .build() + * ``` */ - fun price( - scalableMatrixWithTieredPricing: NewSubscriptionScalableMatrixWithTieredPricingPrice - ) = price(Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)) + fun percentageDiscountAdjustment(percentageDiscount: Double) = + adjustment( + NewPercentageDiscount.builder() + .adjustmentType(NewPercentageDiscount.AdjustmentType.PERCENTAGE_DISCOUNT) + .percentageDiscount(percentageDiscount) + .build() + ) + + /** Alias for calling [adjustment] with `Adjustment.ofUsageDiscount(usageDiscount)`. */ + fun adjustment(usageDiscount: NewUsageDiscount) = + adjustment(Adjustment.ofUsageDiscount(usageDiscount)) /** - * Alias for calling [price] with - * `Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)`. + * Alias for calling [adjustment] with the following: + * ```kotlin + * NewUsageDiscount.builder() + * .adjustmentType(NewUsageDiscount.AdjustmentType.USAGE_DISCOUNT) + * .usageDiscount(usageDiscount) + * .build() + * ``` */ - fun price(cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice) = - price(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) + fun usageDiscountAdjustment(usageDiscount: Double) = + adjustment( + NewUsageDiscount.builder() + .adjustmentType(NewUsageDiscount.AdjustmentType.USAGE_DISCOUNT) + .usageDiscount(usageDiscount) + .build() + ) - /** Alias for calling [price] with `Price.ofMinimum(minimum)`. */ - fun price(minimum: NewSubscriptionMinimumCompositePrice) = - price(Price.ofMinimum(minimum)) + /** + * Alias for calling [adjustment] with `Adjustment.ofAmountDiscount(amountDiscount)`. + */ + fun adjustment(amountDiscount: NewAmountDiscount) = + adjustment(Adjustment.ofAmountDiscount(amountDiscount)) - /** Alias for calling [price] with `Price.ofPercent(percent)`. */ - fun price(percent: Price.Percent) = price(Price.ofPercent(percent)) + /** + * Alias for calling [adjustment] with the following: + * ```kotlin + * NewAmountDiscount.builder() + * .adjustmentType(NewAmountDiscount.AdjustmentType.AMOUNT_DISCOUNT) + * .amountDiscount(amountDiscount) + * .build() + * ``` + */ + fun amountDiscountAdjustment(amountDiscount: String) = + adjustment( + NewAmountDiscount.builder() + .adjustmentType(NewAmountDiscount.AdjustmentType.AMOUNT_DISCOUNT) + .amountDiscount(amountDiscount) + .build() + ) - /** Alias for calling [price] with `Price.ofEventOutput(eventOutput)`. */ - fun price(eventOutput: Price.EventOutput) = price(Price.ofEventOutput(eventOutput)) + /** Alias for calling [adjustment] with `Adjustment.ofMinimum(minimum)`. */ + fun adjustment(minimum: NewMinimum) = adjustment(Adjustment.ofMinimum(minimum)) - /** The id of the price to add to the subscription. */ - fun priceId(priceId: String?) = priceId(JsonField.ofNullable(priceId)) + /** Alias for calling [adjustment] with `Adjustment.ofMaximum(maximum)`. */ + fun adjustment(maximum: NewMaximum) = adjustment(Adjustment.ofMaximum(maximum)) /** - * Sets [Builder.priceId] to an arbitrary JSON value. + * Alias for calling [adjustment] with the following: + * ```kotlin + * NewMaximum.builder() + * .adjustmentType(NewMaximum.AdjustmentType.MAXIMUM) + * .maximumAmount(maximumAmount) + * .build() + * ``` + */ + fun maximumAdjustment(maximumAmount: String) = + adjustment( + NewMaximum.builder() + .adjustmentType(NewMaximum.AdjustmentType.MAXIMUM) + .maximumAmount(maximumAmount) + .build() + ) + + /** The id of the adjustment on the plan to replace in the subscription. */ + fun replacesAdjustmentId(replacesAdjustmentId: String) = + replacesAdjustmentId(JsonField.of(replacesAdjustmentId)) + + /** + * Sets [Builder.replacesAdjustmentId] to an arbitrary JSON value. * - * You should usually call [Builder.priceId] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. + * You should usually call [Builder.replacesAdjustmentId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. */ - fun priceId(priceId: JsonField) = apply { this.priceId = priceId } + fun replacesAdjustmentId(replacesAdjustmentId: JsonField) = apply { + this.replacesAdjustmentId = replacesAdjustmentId + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -16087,48 +16903,35 @@ private constructor( } /** - * Returns an immutable instance of [ReplacePrice]. + * Returns an immutable instance of [ReplaceAdjustment]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```kotlin - * .replacesPriceId() + * .adjustment() + * .replacesAdjustmentId() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): ReplacePrice = - ReplacePrice( - checkRequired("replacesPriceId", replacesPriceId), - allocationPrice, - (discounts ?: JsonMissing.of()).map { it.toImmutable() }, - externalPriceId, - fixedPriceQuantity, - maximumAmount, - minimumAmount, - price, - priceId, + fun build(): ReplaceAdjustment = + ReplaceAdjustment( + checkRequired("adjustment", adjustment), + checkRequired("replacesAdjustmentId", replacesAdjustmentId), additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): ReplacePrice = apply { + fun validate(): ReplaceAdjustment = apply { if (validated) { return@apply } - replacesPriceId() - allocationPrice()?.validate() - discounts()?.forEach { it.validate() } - externalPriceId() - fixedPriceQuantity() - maximumAmount() - minimumAmount() - price()?.validate() - priceId() + adjustment().validate() + replacesAdjustmentId() validated = true } @@ -16147,1284 +16950,4321 @@ private constructor( * Used for best match union deserialization. */ internal fun validity(): Int = - (if (replacesPriceId.asKnown() == null) 0 else 1) + - (allocationPrice.asKnown()?.validity() ?: 0) + - (discounts.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + - (if (externalPriceId.asKnown() == null) 0 else 1) + - (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + - (if (maximumAmount.asKnown() == null) 0 else 1) + - (if (minimumAmount.asKnown() == null) 0 else 1) + - (price.asKnown()?.validity() ?: 0) + - (if (priceId.asKnown() == null) 0 else 1) + (adjustment.asKnown()?.validity() ?: 0) + + (if (replacesAdjustmentId.asKnown() == null) 0 else 1) - /** New subscription price request body params. */ - @JsonDeserialize(using = Price.Deserializer::class) - @JsonSerialize(using = Price.Serializer::class) - class Price + /** The definition of a new adjustment to create and add to the subscription. */ + @JsonDeserialize(using = Adjustment.Deserializer::class) + @JsonSerialize(using = Adjustment.Serializer::class) + class Adjustment private constructor( - private val unit: NewSubscriptionUnitPrice? = null, - private val tiered: NewSubscriptionTieredPrice? = null, - private val bulk: NewSubscriptionBulkPrice? = null, - private val bulkWithFilters: BulkWithFilters? = null, - private val package_: NewSubscriptionPackagePrice? = null, - private val matrix: NewSubscriptionMatrixPrice? = null, - private val thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice? = null, - private val tieredPackage: NewSubscriptionTieredPackagePrice? = null, - private val tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice? = null, - private val groupedTiered: NewSubscriptionGroupedTieredPrice? = null, - private val tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice? = - null, - private val packageWithAllocation: NewSubscriptionPackageWithAllocationPrice? = null, - private val unitWithPercent: NewSubscriptionUnitWithPercentPrice? = null, - private val matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice? = null, - private val tieredWithProration: TieredWithProration? = null, - private val unitWithProration: NewSubscriptionUnitWithProrationPrice? = null, - private val groupedAllocation: NewSubscriptionGroupedAllocationPrice? = null, - private val bulkWithProration: NewSubscriptionBulkWithProrationPrice? = null, - private val groupedWithProratedMinimum: - NewSubscriptionGroupedWithProratedMinimumPrice? = - null, - private val groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice? = - null, - private val groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds? = null, - private val matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice? = null, - private val groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice? = null, - private val maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice? = null, - private val scalableMatrixWithUnitPricing: - NewSubscriptionScalableMatrixWithUnitPricingPrice? = - null, - private val scalableMatrixWithTieredPricing: - NewSubscriptionScalableMatrixWithTieredPricingPrice? = - null, - private val cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice? = null, - private val minimum: NewSubscriptionMinimumCompositePrice? = null, - private val percent: Percent? = null, - private val eventOutput: EventOutput? = null, + private val percentageDiscount: NewPercentageDiscount? = null, + private val usageDiscount: NewUsageDiscount? = null, + private val amountDiscount: NewAmountDiscount? = null, + private val minimum: NewMinimum? = null, + private val maximum: NewMaximum? = null, private val _json: JsonValue? = null, ) { - fun unit(): NewSubscriptionUnitPrice? = unit + fun percentageDiscount(): NewPercentageDiscount? = percentageDiscount - fun tiered(): NewSubscriptionTieredPrice? = tiered + fun usageDiscount(): NewUsageDiscount? = usageDiscount - fun bulk(): NewSubscriptionBulkPrice? = bulk + fun amountDiscount(): NewAmountDiscount? = amountDiscount - fun bulkWithFilters(): BulkWithFilters? = bulkWithFilters + fun minimum(): NewMinimum? = minimum - fun package_(): NewSubscriptionPackagePrice? = package_ + fun maximum(): NewMaximum? = maximum - fun matrix(): NewSubscriptionMatrixPrice? = matrix + fun isPercentageDiscount(): Boolean = percentageDiscount != null - fun thresholdTotalAmount(): NewSubscriptionThresholdTotalAmountPrice? = - thresholdTotalAmount + fun isUsageDiscount(): Boolean = usageDiscount != null - fun tieredPackage(): NewSubscriptionTieredPackagePrice? = tieredPackage + fun isAmountDiscount(): Boolean = amountDiscount != null - fun tieredWithMinimum(): NewSubscriptionTieredWithMinimumPrice? = tieredWithMinimum + fun isMinimum(): Boolean = minimum != null - fun groupedTiered(): NewSubscriptionGroupedTieredPrice? = groupedTiered + fun isMaximum(): Boolean = maximum != null - fun tieredPackageWithMinimum(): NewSubscriptionTieredPackageWithMinimumPrice? = - tieredPackageWithMinimum + fun asPercentageDiscount(): NewPercentageDiscount = + percentageDiscount.getOrThrow("percentageDiscount") - fun packageWithAllocation(): NewSubscriptionPackageWithAllocationPrice? = - packageWithAllocation + fun asUsageDiscount(): NewUsageDiscount = usageDiscount.getOrThrow("usageDiscount") - fun unitWithPercent(): NewSubscriptionUnitWithPercentPrice? = unitWithPercent + fun asAmountDiscount(): NewAmountDiscount = amountDiscount.getOrThrow("amountDiscount") - fun matrixWithAllocation(): NewSubscriptionMatrixWithAllocationPrice? = - matrixWithAllocation + fun asMinimum(): NewMinimum = minimum.getOrThrow("minimum") - fun tieredWithProration(): TieredWithProration? = tieredWithProration + fun asMaximum(): NewMaximum = maximum.getOrThrow("maximum") - fun unitWithProration(): NewSubscriptionUnitWithProrationPrice? = unitWithProration + fun _json(): JsonValue? = _json - fun groupedAllocation(): NewSubscriptionGroupedAllocationPrice? = groupedAllocation + fun accept(visitor: Visitor): T = + when { + percentageDiscount != null -> + visitor.visitPercentageDiscount(percentageDiscount) + usageDiscount != null -> visitor.visitUsageDiscount(usageDiscount) + amountDiscount != null -> visitor.visitAmountDiscount(amountDiscount) + minimum != null -> visitor.visitMinimum(minimum) + maximum != null -> visitor.visitMaximum(maximum) + else -> visitor.unknown(_json) + } - fun bulkWithProration(): NewSubscriptionBulkWithProrationPrice? = bulkWithProration + private var validated: Boolean = false - fun groupedWithProratedMinimum(): NewSubscriptionGroupedWithProratedMinimumPrice? = - groupedWithProratedMinimum + fun validate(): Adjustment = apply { + if (validated) { + return@apply + } - fun groupedWithMeteredMinimum(): NewSubscriptionGroupedWithMeteredMinimumPrice? = - groupedWithMeteredMinimum + accept( + object : Visitor { + override fun visitPercentageDiscount( + percentageDiscount: NewPercentageDiscount + ) { + percentageDiscount.validate() + } - fun groupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds? = - groupedWithMinMaxThresholds - - fun matrixWithDisplayName(): NewSubscriptionMatrixWithDisplayNamePrice? = - matrixWithDisplayName - - fun groupedTieredPackage(): NewSubscriptionGroupedTieredPackagePrice? = - groupedTieredPackage - - fun maxGroupTieredPackage(): NewSubscriptionMaxGroupTieredPackagePrice? = - maxGroupTieredPackage - - fun scalableMatrixWithUnitPricing(): - NewSubscriptionScalableMatrixWithUnitPricingPrice? = scalableMatrixWithUnitPricing - - fun scalableMatrixWithTieredPricing(): - NewSubscriptionScalableMatrixWithTieredPricingPrice? = - scalableMatrixWithTieredPricing - - fun cumulativeGroupedBulk(): NewSubscriptionCumulativeGroupedBulkPrice? = - cumulativeGroupedBulk - - fun minimum(): NewSubscriptionMinimumCompositePrice? = minimum - - fun percent(): Percent? = percent - - fun eventOutput(): EventOutput? = eventOutput + override fun visitUsageDiscount(usageDiscount: NewUsageDiscount) { + usageDiscount.validate() + } - fun isUnit(): Boolean = unit != null + override fun visitAmountDiscount(amountDiscount: NewAmountDiscount) { + amountDiscount.validate() + } - fun isTiered(): Boolean = tiered != null + override fun visitMinimum(minimum: NewMinimum) { + minimum.validate() + } - fun isBulk(): Boolean = bulk != null + override fun visitMaximum(maximum: NewMaximum) { + maximum.validate() + } + } + ) + validated = true + } - fun isBulkWithFilters(): Boolean = bulkWithFilters != null + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - fun isPackage(): Boolean = package_ != null + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitPercentageDiscount( + percentageDiscount: NewPercentageDiscount + ) = percentageDiscount.validity() - fun isMatrix(): Boolean = matrix != null + override fun visitUsageDiscount(usageDiscount: NewUsageDiscount) = + usageDiscount.validity() - fun isThresholdTotalAmount(): Boolean = thresholdTotalAmount != null + override fun visitAmountDiscount(amountDiscount: NewAmountDiscount) = + amountDiscount.validity() - fun isTieredPackage(): Boolean = tieredPackage != null + override fun visitMinimum(minimum: NewMinimum) = minimum.validity() - fun isTieredWithMinimum(): Boolean = tieredWithMinimum != null + override fun visitMaximum(maximum: NewMaximum) = maximum.validity() - fun isGroupedTiered(): Boolean = groupedTiered != null + override fun unknown(json: JsonValue?) = 0 + } + ) - fun isTieredPackageWithMinimum(): Boolean = tieredPackageWithMinimum != null + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun isPackageWithAllocation(): Boolean = packageWithAllocation != null + return other is Adjustment && + percentageDiscount == other.percentageDiscount && + usageDiscount == other.usageDiscount && + amountDiscount == other.amountDiscount && + minimum == other.minimum && + maximum == other.maximum + } - fun isUnitWithPercent(): Boolean = unitWithPercent != null + override fun hashCode(): Int = + Objects.hash(percentageDiscount, usageDiscount, amountDiscount, minimum, maximum) - fun isMatrixWithAllocation(): Boolean = matrixWithAllocation != null + override fun toString(): String = + when { + percentageDiscount != null -> + "Adjustment{percentageDiscount=$percentageDiscount}" + usageDiscount != null -> "Adjustment{usageDiscount=$usageDiscount}" + amountDiscount != null -> "Adjustment{amountDiscount=$amountDiscount}" + minimum != null -> "Adjustment{minimum=$minimum}" + maximum != null -> "Adjustment{maximum=$maximum}" + _json != null -> "Adjustment{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Adjustment") + } - fun isTieredWithProration(): Boolean = tieredWithProration != null + companion object { - fun isUnitWithProration(): Boolean = unitWithProration != null + fun ofPercentageDiscount(percentageDiscount: NewPercentageDiscount) = + Adjustment(percentageDiscount = percentageDiscount) - fun isGroupedAllocation(): Boolean = groupedAllocation != null + fun ofUsageDiscount(usageDiscount: NewUsageDiscount) = + Adjustment(usageDiscount = usageDiscount) - fun isBulkWithProration(): Boolean = bulkWithProration != null + fun ofAmountDiscount(amountDiscount: NewAmountDiscount) = + Adjustment(amountDiscount = amountDiscount) - fun isGroupedWithProratedMinimum(): Boolean = groupedWithProratedMinimum != null + fun ofMinimum(minimum: NewMinimum) = Adjustment(minimum = minimum) - fun isGroupedWithMeteredMinimum(): Boolean = groupedWithMeteredMinimum != null + fun ofMaximum(maximum: NewMaximum) = Adjustment(maximum = maximum) + } - fun isGroupedWithMinMaxThresholds(): Boolean = groupedWithMinMaxThresholds != null + /** + * An interface that defines how to map each variant of [Adjustment] to a value of type + * [T]. + */ + interface Visitor { - fun isMatrixWithDisplayName(): Boolean = matrixWithDisplayName != null + fun visitPercentageDiscount(percentageDiscount: NewPercentageDiscount): T - fun isGroupedTieredPackage(): Boolean = groupedTieredPackage != null + fun visitUsageDiscount(usageDiscount: NewUsageDiscount): T - fun isMaxGroupTieredPackage(): Boolean = maxGroupTieredPackage != null + fun visitAmountDiscount(amountDiscount: NewAmountDiscount): T - fun isScalableMatrixWithUnitPricing(): Boolean = scalableMatrixWithUnitPricing != null + fun visitMinimum(minimum: NewMinimum): T - fun isScalableMatrixWithTieredPricing(): Boolean = - scalableMatrixWithTieredPricing != null + fun visitMaximum(maximum: NewMaximum): T - fun isCumulativeGroupedBulk(): Boolean = cumulativeGroupedBulk != null + /** + * Maps an unknown variant of [Adjustment] to a value of type [T]. + * + * An instance of [Adjustment] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the + * SDK is unaware of. + * + * @throws OrbInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw OrbInvalidDataException("Unknown Adjustment: $json") + } + } - fun isMinimum(): Boolean = minimum != null + internal class Deserializer : BaseDeserializer(Adjustment::class) { - fun isPercent(): Boolean = percent != null + override fun ObjectCodec.deserialize(node: JsonNode): Adjustment { + val json = JsonValue.fromJsonNode(node) + val adjustmentType = json.asObject()?.get("adjustment_type")?.asString() - fun isEventOutput(): Boolean = eventOutput != null + when (adjustmentType) { + "percentage_discount" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Adjustment(percentageDiscount = it, _json = json) } + ?: Adjustment(_json = json) + } + "usage_discount" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(usageDiscount = it, _json = json) + } ?: Adjustment(_json = json) + } + "amount_discount" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(amountDiscount = it, _json = json) + } ?: Adjustment(_json = json) + } + "minimum" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(minimum = it, _json = json) + } ?: Adjustment(_json = json) + } + "maximum" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(maximum = it, _json = json) + } ?: Adjustment(_json = json) + } + } - fun asUnit(): NewSubscriptionUnitPrice = unit.getOrThrow("unit") + return Adjustment(_json = json) + } + } - fun asTiered(): NewSubscriptionTieredPrice = tiered.getOrThrow("tiered") + internal class Serializer : BaseSerializer(Adjustment::class) { - fun asBulk(): NewSubscriptionBulkPrice = bulk.getOrThrow("bulk") + override fun serialize( + value: Adjustment, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.percentageDiscount != null -> + generator.writeObject(value.percentageDiscount) + value.usageDiscount != null -> generator.writeObject(value.usageDiscount) + value.amountDiscount != null -> generator.writeObject(value.amountDiscount) + value.minimum != null -> generator.writeObject(value.minimum) + value.maximum != null -> generator.writeObject(value.maximum) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Adjustment") + } + } + } + } - fun asBulkWithFilters(): BulkWithFilters = bulkWithFilters.getOrThrow("bulkWithFilters") + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun asPackage(): NewSubscriptionPackagePrice = package_.getOrThrow("package_") + return other is ReplaceAdjustment && + adjustment == other.adjustment && + replacesAdjustmentId == other.replacesAdjustmentId && + additionalProperties == other.additionalProperties + } - fun asMatrix(): NewSubscriptionMatrixPrice = matrix.getOrThrow("matrix") + private val hashCode: Int by lazy { + Objects.hash(adjustment, replacesAdjustmentId, additionalProperties) + } - fun asThresholdTotalAmount(): NewSubscriptionThresholdTotalAmountPrice = - thresholdTotalAmount.getOrThrow("thresholdTotalAmount") + override fun hashCode(): Int = hashCode - fun asTieredPackage(): NewSubscriptionTieredPackagePrice = - tieredPackage.getOrThrow("tieredPackage") + override fun toString() = + "ReplaceAdjustment{adjustment=$adjustment, replacesAdjustmentId=$replacesAdjustmentId, additionalProperties=$additionalProperties}" + } - fun asTieredWithMinimum(): NewSubscriptionTieredWithMinimumPrice = - tieredWithMinimum.getOrThrow("tieredWithMinimum") + class ReplacePrice + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val replacesPriceId: JsonField, + private val allocationPrice: JsonField, + private val discounts: JsonField>, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val maximumAmount: JsonField, + private val minimumAmount: JsonField, + private val price: JsonField, + private val priceId: JsonField, + private val additionalProperties: MutableMap, + ) { - fun asGroupedTiered(): NewSubscriptionGroupedTieredPrice = - groupedTiered.getOrThrow("groupedTiered") + @JsonCreator + private constructor( + @JsonProperty("replaces_price_id") + @ExcludeMissing + replacesPriceId: JsonField = JsonMissing.of(), + @JsonProperty("allocation_price") + @ExcludeMissing + allocationPrice: JsonField = JsonMissing.of(), + @JsonProperty("discounts") + @ExcludeMissing + discounts: JsonField> = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("maximum_amount") + @ExcludeMissing + maximumAmount: JsonField = JsonMissing.of(), + @JsonProperty("minimum_amount") + @ExcludeMissing + minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("price") @ExcludeMissing price: JsonField = JsonMissing.of(), + @JsonProperty("price_id") @ExcludeMissing priceId: JsonField = JsonMissing.of(), + ) : this( + replacesPriceId, + allocationPrice, + discounts, + externalPriceId, + fixedPriceQuantity, + maximumAmount, + minimumAmount, + price, + priceId, + mutableMapOf(), + ) - fun asTieredPackageWithMinimum(): NewSubscriptionTieredPackageWithMinimumPrice = - tieredPackageWithMinimum.getOrThrow("tieredPackageWithMinimum") + /** + * The id of the price on the plan to replace in the subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun replacesPriceId(): String = replacesPriceId.getRequired("replaces_price_id") - fun asPackageWithAllocation(): NewSubscriptionPackageWithAllocationPrice = - packageWithAllocation.getOrThrow("packageWithAllocation") + /** + * The definition of a new allocation price to create and add to the subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun allocationPrice(): NewAllocationPrice? = allocationPrice.getNullable("allocation_price") - fun asUnitWithPercent(): NewSubscriptionUnitWithPercentPrice = - unitWithPercent.getOrThrow("unitWithPercent") + /** + * [DEPRECATED] Use add_adjustments instead. The subscription's discounts for the + * replacement price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + @Deprecated("deprecated") + fun discounts(): List? = discounts.getNullable("discounts") - fun asMatrixWithAllocation(): NewSubscriptionMatrixWithAllocationPrice = - matrixWithAllocation.getOrThrow("matrixWithAllocation") + /** + * The external price id of the price to add to the subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") - fun asTieredWithProration(): TieredWithProration = - tieredWithProration.getOrThrow("tieredWithProration") + /** + * The new quantity of the price, if the price is a fixed price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = fixedPriceQuantity.getNullable("fixed_price_quantity") - fun asUnitWithProration(): NewSubscriptionUnitWithProrationPrice = - unitWithProration.getOrThrow("unitWithProration") + /** + * [DEPRECATED] Use add_adjustments instead. The subscription's maximum amount for the + * replacement price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + @Deprecated("deprecated") + fun maximumAmount(): String? = maximumAmount.getNullable("maximum_amount") - fun asGroupedAllocation(): NewSubscriptionGroupedAllocationPrice = - groupedAllocation.getOrThrow("groupedAllocation") + /** + * [DEPRECATED] Use add_adjustments instead. The subscription's minimum amount for the + * replacement price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + @Deprecated("deprecated") + fun minimumAmount(): String? = minimumAmount.getNullable("minimum_amount") - fun asBulkWithProration(): NewSubscriptionBulkWithProrationPrice = - bulkWithProration.getOrThrow("bulkWithProration") + /** + * New subscription price request body params. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun price(): Price? = price.getNullable("price") - fun asGroupedWithProratedMinimum(): NewSubscriptionGroupedWithProratedMinimumPrice = - groupedWithProratedMinimum.getOrThrow("groupedWithProratedMinimum") + /** + * The id of the price to add to the subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun priceId(): String? = priceId.getNullable("price_id") - fun asGroupedWithMeteredMinimum(): NewSubscriptionGroupedWithMeteredMinimumPrice = - groupedWithMeteredMinimum.getOrThrow("groupedWithMeteredMinimum") + /** + * Returns the raw JSON value of [replacesPriceId]. + * + * Unlike [replacesPriceId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("replaces_price_id") + @ExcludeMissing + fun _replacesPriceId(): JsonField = replacesPriceId - fun asGroupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds = - groupedWithMinMaxThresholds.getOrThrow("groupedWithMinMaxThresholds") + /** + * Returns the raw JSON value of [allocationPrice]. + * + * Unlike [allocationPrice], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("allocation_price") + @ExcludeMissing + fun _allocationPrice(): JsonField = allocationPrice - fun asMatrixWithDisplayName(): NewSubscriptionMatrixWithDisplayNamePrice = - matrixWithDisplayName.getOrThrow("matrixWithDisplayName") + /** + * Returns the raw JSON value of [discounts]. + * + * Unlike [discounts], this method doesn't throw if the JSON field has an unexpected type. + */ + @Deprecated("deprecated") + @JsonProperty("discounts") + @ExcludeMissing + fun _discounts(): JsonField> = discounts - fun asGroupedTieredPackage(): NewSubscriptionGroupedTieredPackagePrice = - groupedTieredPackage.getOrThrow("groupedTieredPackage") + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId - fun asMaxGroupTieredPackage(): NewSubscriptionMaxGroupTieredPackagePrice = - maxGroupTieredPackage.getOrThrow("maxGroupTieredPackage") + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - fun asScalableMatrixWithUnitPricing(): - NewSubscriptionScalableMatrixWithUnitPricingPrice = - scalableMatrixWithUnitPricing.getOrThrow("scalableMatrixWithUnitPricing") + /** + * Returns the raw JSON value of [maximumAmount]. + * + * Unlike [maximumAmount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @Deprecated("deprecated") + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount - fun asScalableMatrixWithTieredPricing(): - NewSubscriptionScalableMatrixWithTieredPricingPrice = - scalableMatrixWithTieredPricing.getOrThrow("scalableMatrixWithTieredPricing") + /** + * Returns the raw JSON value of [minimumAmount]. + * + * Unlike [minimumAmount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @Deprecated("deprecated") + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount - fun asCumulativeGroupedBulk(): NewSubscriptionCumulativeGroupedBulkPrice = - cumulativeGroupedBulk.getOrThrow("cumulativeGroupedBulk") + /** + * Returns the raw JSON value of [price]. + * + * Unlike [price], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("price") @ExcludeMissing fun _price(): JsonField = price - fun asMinimum(): NewSubscriptionMinimumCompositePrice = minimum.getOrThrow("minimum") + /** + * Returns the raw JSON value of [priceId]. + * + * Unlike [priceId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId - fun asPercent(): Percent = percent.getOrThrow("percent") + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - fun asEventOutput(): EventOutput = eventOutput.getOrThrow("eventOutput") + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - fun _json(): JsonValue? = _json + fun toBuilder() = Builder().from(this) - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - bulk != null -> visitor.visitBulk(bulk) - bulkWithFilters != null -> visitor.visitBulkWithFilters(bulkWithFilters) - package_ != null -> visitor.visitPackage(package_) - matrix != null -> visitor.visitMatrix(matrix) - thresholdTotalAmount != null -> - visitor.visitThresholdTotalAmount(thresholdTotalAmount) - tieredPackage != null -> visitor.visitTieredPackage(tieredPackage) - tieredWithMinimum != null -> visitor.visitTieredWithMinimum(tieredWithMinimum) - groupedTiered != null -> visitor.visitGroupedTiered(groupedTiered) - tieredPackageWithMinimum != null -> - visitor.visitTieredPackageWithMinimum(tieredPackageWithMinimum) - packageWithAllocation != null -> - visitor.visitPackageWithAllocation(packageWithAllocation) - unitWithPercent != null -> visitor.visitUnitWithPercent(unitWithPercent) - matrixWithAllocation != null -> - visitor.visitMatrixWithAllocation(matrixWithAllocation) - tieredWithProration != null -> - visitor.visitTieredWithProration(tieredWithProration) - unitWithProration != null -> visitor.visitUnitWithProration(unitWithProration) - groupedAllocation != null -> visitor.visitGroupedAllocation(groupedAllocation) - bulkWithProration != null -> visitor.visitBulkWithProration(bulkWithProration) - groupedWithProratedMinimum != null -> - visitor.visitGroupedWithProratedMinimum(groupedWithProratedMinimum) - groupedWithMeteredMinimum != null -> - visitor.visitGroupedWithMeteredMinimum(groupedWithMeteredMinimum) - groupedWithMinMaxThresholds != null -> - visitor.visitGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds) - matrixWithDisplayName != null -> - visitor.visitMatrixWithDisplayName(matrixWithDisplayName) - groupedTieredPackage != null -> - visitor.visitGroupedTieredPackage(groupedTieredPackage) - maxGroupTieredPackage != null -> - visitor.visitMaxGroupTieredPackage(maxGroupTieredPackage) - scalableMatrixWithUnitPricing != null -> - visitor.visitScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing) - scalableMatrixWithTieredPricing != null -> - visitor.visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing - ) - cumulativeGroupedBulk != null -> - visitor.visitCumulativeGroupedBulk(cumulativeGroupedBulk) - minimum != null -> visitor.visitMinimum(minimum) - percent != null -> visitor.visitPercent(percent) - eventOutput != null -> visitor.visitEventOutput(eventOutput) - else -> visitor.unknown(_json) - } + companion object { - private var validated: Boolean = false + /** + * Returns a mutable builder for constructing an instance of [ReplacePrice]. + * + * The following fields are required: + * ```kotlin + * .replacesPriceId() + * ``` + */ + fun builder() = Builder() + } - fun validate(): Price = apply { - if (validated) { - return@apply - } + /** A builder for [ReplacePrice]. */ + class Builder internal constructor() { - accept( - object : Visitor { - override fun visitUnit(unit: NewSubscriptionUnitPrice) { - unit.validate() - } + private var replacesPriceId: JsonField? = null + private var allocationPrice: JsonField = JsonMissing.of() + private var discounts: JsonField>? = null + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var maximumAmount: JsonField = JsonMissing.of() + private var minimumAmount: JsonField = JsonMissing.of() + private var price: JsonField = JsonMissing.of() + private var priceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - override fun visitTiered(tiered: NewSubscriptionTieredPrice) { - tiered.validate() - } + internal fun from(replacePrice: ReplacePrice) = apply { + replacesPriceId = replacePrice.replacesPriceId + allocationPrice = replacePrice.allocationPrice + discounts = replacePrice.discounts.map { it.toMutableList() } + externalPriceId = replacePrice.externalPriceId + fixedPriceQuantity = replacePrice.fixedPriceQuantity + maximumAmount = replacePrice.maximumAmount + minimumAmount = replacePrice.minimumAmount + price = replacePrice.price + priceId = replacePrice.priceId + additionalProperties = replacePrice.additionalProperties.toMutableMap() + } - override fun visitBulk(bulk: NewSubscriptionBulkPrice) { - bulk.validate() - } + /** The id of the price on the plan to replace in the subscription. */ + fun replacesPriceId(replacesPriceId: String) = + replacesPriceId(JsonField.of(replacesPriceId)) - override fun visitBulkWithFilters(bulkWithFilters: BulkWithFilters) { - bulkWithFilters.validate() - } + /** + * Sets [Builder.replacesPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.replacesPriceId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun replacesPriceId(replacesPriceId: JsonField) = apply { + this.replacesPriceId = replacesPriceId + } - override fun visitPackage(package_: NewSubscriptionPackagePrice) { - package_.validate() - } + /** The definition of a new allocation price to create and add to the subscription. */ + fun allocationPrice(allocationPrice: NewAllocationPrice?) = + allocationPrice(JsonField.ofNullable(allocationPrice)) - override fun visitMatrix(matrix: NewSubscriptionMatrixPrice) { - matrix.validate() - } + /** + * Sets [Builder.allocationPrice] to an arbitrary JSON value. + * + * You should usually call [Builder.allocationPrice] with a well-typed + * [NewAllocationPrice] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun allocationPrice(allocationPrice: JsonField) = apply { + this.allocationPrice = allocationPrice + } - override fun visitThresholdTotalAmount( - thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice - ) { - thresholdTotalAmount.validate() - } + /** + * [DEPRECATED] Use add_adjustments instead. The subscription's discounts for the + * replacement price. + */ + @Deprecated("deprecated") + fun discounts(discounts: List?) = + discounts(JsonField.ofNullable(discounts)) - override fun visitTieredPackage( - tieredPackage: NewSubscriptionTieredPackagePrice - ) { - tieredPackage.validate() - } + /** + * Sets [Builder.discounts] to an arbitrary JSON value. + * + * You should usually call [Builder.discounts] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + @Deprecated("deprecated") + fun discounts(discounts: JsonField>) = apply { + this.discounts = discounts.map { it.toMutableList() } + } - override fun visitTieredWithMinimum( - tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice - ) { - tieredWithMinimum.validate() - } + /** + * Adds a single [DiscountOverride] to [discounts]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + @Deprecated("deprecated") + fun addDiscount(discount: DiscountOverride) = apply { + discounts = + (discounts ?: JsonField.of(mutableListOf())).also { + checkKnown("discounts", it).add(discount) + } + } - override fun visitGroupedTiered( - groupedTiered: NewSubscriptionGroupedTieredPrice - ) { - groupedTiered.validate() - } + /** The external price id of the price to add to the subscription. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) - override fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice - ) { - tieredPackageWithMinimum.validate() - } + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } - override fun visitPackageWithAllocation( - packageWithAllocation: NewSubscriptionPackageWithAllocationPrice - ) { - packageWithAllocation.validate() - } + /** The new quantity of the price, if the price is a fixed price. */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) - override fun visitUnitWithPercent( - unitWithPercent: NewSubscriptionUnitWithPercentPrice - ) { - unitWithPercent.validate() - } + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) - override fun visitMatrixWithAllocation( - matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice - ) { - matrixWithAllocation.validate() - } + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } - override fun visitTieredWithProration( - tieredWithProration: TieredWithProration - ) { - tieredWithProration.validate() - } + /** + * [DEPRECATED] Use add_adjustments instead. The subscription's maximum amount for the + * replacement price. + */ + @Deprecated("deprecated") + fun maximumAmount(maximumAmount: String?) = + maximumAmount(JsonField.ofNullable(maximumAmount)) - override fun visitUnitWithProration( - unitWithProration: NewSubscriptionUnitWithProrationPrice - ) { - unitWithProration.validate() - } + /** + * Sets [Builder.maximumAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.maximumAmount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + @Deprecated("deprecated") + fun maximumAmount(maximumAmount: JsonField) = apply { + this.maximumAmount = maximumAmount + } - override fun visitGroupedAllocation( - groupedAllocation: NewSubscriptionGroupedAllocationPrice - ) { - groupedAllocation.validate() - } + /** + * [DEPRECATED] Use add_adjustments instead. The subscription's minimum amount for the + * replacement price. + */ + @Deprecated("deprecated") + fun minimumAmount(minimumAmount: String?) = + minimumAmount(JsonField.ofNullable(minimumAmount)) - override fun visitBulkWithProration( - bulkWithProration: NewSubscriptionBulkWithProrationPrice - ) { - bulkWithProration.validate() - } + /** + * Sets [Builder.minimumAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumAmount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + @Deprecated("deprecated") + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount + } - override fun visitGroupedWithProratedMinimum( - groupedWithProratedMinimum: - NewSubscriptionGroupedWithProratedMinimumPrice - ) { - groupedWithProratedMinimum.validate() - } + /** New subscription price request body params. */ + fun price(price: Price?) = price(JsonField.ofNullable(price)) - override fun visitGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice - ) { - groupedWithMeteredMinimum.validate() - } + /** + * Sets [Builder.price] to an arbitrary JSON value. + * + * You should usually call [Builder.price] with a well-typed [Price] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun price(price: JsonField) = apply { this.price = price } - override fun visitGroupedWithMinMaxThresholds( - groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds - ) { - groupedWithMinMaxThresholds.validate() - } + /** Alias for calling [price] with `Price.ofUnit(unit)`. */ + fun price(unit: NewSubscriptionUnitPrice) = price(Price.ofUnit(unit)) - override fun visitMatrixWithDisplayName( - matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice - ) { - matrixWithDisplayName.validate() - } + /** Alias for calling [price] with `Price.ofTiered(tiered)`. */ + fun price(tiered: NewSubscriptionTieredPrice) = price(Price.ofTiered(tiered)) - override fun visitGroupedTieredPackage( - groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice - ) { - groupedTieredPackage.validate() - } + /** Alias for calling [price] with `Price.ofBulk(bulk)`. */ + fun price(bulk: NewSubscriptionBulkPrice) = price(Price.ofBulk(bulk)) - override fun visitMaxGroupTieredPackage( - maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice - ) { - maxGroupTieredPackage.validate() - } + /** Alias for calling [price] with `Price.ofBulkWithFilters(bulkWithFilters)`. */ + fun price(bulkWithFilters: Price.BulkWithFilters) = + price(Price.ofBulkWithFilters(bulkWithFilters)) - override fun visitScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: - NewSubscriptionScalableMatrixWithUnitPricingPrice - ) { - scalableMatrixWithUnitPricing.validate() - } + /** Alias for calling [price] with `Price.ofPackage(package_)`. */ + fun price(package_: NewSubscriptionPackagePrice) = price(Price.ofPackage(package_)) - override fun visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: - NewSubscriptionScalableMatrixWithTieredPricingPrice - ) { - scalableMatrixWithTieredPricing.validate() - } + /** Alias for calling [price] with `Price.ofMatrix(matrix)`. */ + fun price(matrix: NewSubscriptionMatrixPrice) = price(Price.ofMatrix(matrix)) - override fun visitCumulativeGroupedBulk( - cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice - ) { - cumulativeGroupedBulk.validate() - } + /** + * Alias for calling [price] with `Price.ofThresholdTotalAmount(thresholdTotalAmount)`. + */ + fun price(thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice) = + price(Price.ofThresholdTotalAmount(thresholdTotalAmount)) - override fun visitMinimum(minimum: NewSubscriptionMinimumCompositePrice) { - minimum.validate() - } + /** Alias for calling [price] with `Price.ofTieredPackage(tieredPackage)`. */ + fun price(tieredPackage: NewSubscriptionTieredPackagePrice) = + price(Price.ofTieredPackage(tieredPackage)) - override fun visitPercent(percent: Percent) { - percent.validate() - } + /** Alias for calling [price] with `Price.ofTieredWithMinimum(tieredWithMinimum)`. */ + fun price(tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice) = + price(Price.ofTieredWithMinimum(tieredWithMinimum)) - override fun visitEventOutput(eventOutput: EventOutput) { - eventOutput.validate() - } - } - ) - validated = true - } + /** Alias for calling [price] with `Price.ofGroupedTiered(groupedTiered)`. */ + fun price(groupedTiered: NewSubscriptionGroupedTieredPrice) = + price(Price.ofGroupedTiered(groupedTiered)) - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** + * Alias for calling [price] with + * `Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)`. + */ + fun price(tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice) = + price(Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)) /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. + * Alias for calling [price] with + * `Price.ofPackageWithAllocation(packageWithAllocation)`. */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: NewSubscriptionUnitPrice) = unit.validity() + fun price(packageWithAllocation: NewSubscriptionPackageWithAllocationPrice) = + price(Price.ofPackageWithAllocation(packageWithAllocation)) - override fun visitTiered(tiered: NewSubscriptionTieredPrice) = - tiered.validity() + /** Alias for calling [price] with `Price.ofUnitWithPercent(unitWithPercent)`. */ + fun price(unitWithPercent: NewSubscriptionUnitWithPercentPrice) = + price(Price.ofUnitWithPercent(unitWithPercent)) - override fun visitBulk(bulk: NewSubscriptionBulkPrice) = bulk.validity() + /** + * Alias for calling [price] with `Price.ofMatrixWithAllocation(matrixWithAllocation)`. + */ + fun price(matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice) = + price(Price.ofMatrixWithAllocation(matrixWithAllocation)) - override fun visitBulkWithFilters(bulkWithFilters: BulkWithFilters) = - bulkWithFilters.validity() + /** + * Alias for calling [price] with `Price.ofTieredWithProration(tieredWithProration)`. + */ + fun price(tieredWithProration: Price.TieredWithProration) = + price(Price.ofTieredWithProration(tieredWithProration)) - override fun visitPackage(package_: NewSubscriptionPackagePrice) = - package_.validity() + /** Alias for calling [price] with `Price.ofUnitWithProration(unitWithProration)`. */ + fun price(unitWithProration: NewSubscriptionUnitWithProrationPrice) = + price(Price.ofUnitWithProration(unitWithProration)) - override fun visitMatrix(matrix: NewSubscriptionMatrixPrice) = - matrix.validity() + /** Alias for calling [price] with `Price.ofGroupedAllocation(groupedAllocation)`. */ + fun price(groupedAllocation: NewSubscriptionGroupedAllocationPrice) = + price(Price.ofGroupedAllocation(groupedAllocation)) - override fun visitThresholdTotalAmount( - thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice - ) = thresholdTotalAmount.validity() + /** Alias for calling [price] with `Price.ofBulkWithProration(bulkWithProration)`. */ + fun price(bulkWithProration: NewSubscriptionBulkWithProrationPrice) = + price(Price.ofBulkWithProration(bulkWithProration)) - override fun visitTieredPackage( - tieredPackage: NewSubscriptionTieredPackagePrice - ) = tieredPackage.validity() + /** + * Alias for calling [price] with + * `Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)`. + */ + fun price(groupedWithProratedMinimum: NewSubscriptionGroupedWithProratedMinimumPrice) = + price(Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)) - override fun visitTieredWithMinimum( - tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice - ) = tieredWithMinimum.validity() + /** + * Alias for calling [price] with + * `Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)`. + */ + fun price(groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice) = + price(Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)) - override fun visitGroupedTiered( - groupedTiered: NewSubscriptionGroupedTieredPrice - ) = groupedTiered.validity() + /** + * Alias for calling [price] with + * `Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)`. + */ + fun price(groupedWithMinMaxThresholds: Price.GroupedWithMinMaxThresholds) = + price(Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)) - override fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice - ) = tieredPackageWithMinimum.validity() + /** + * Alias for calling [price] with + * `Price.ofMatrixWithDisplayName(matrixWithDisplayName)`. + */ + fun price(matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice) = + price(Price.ofMatrixWithDisplayName(matrixWithDisplayName)) - override fun visitPackageWithAllocation( - packageWithAllocation: NewSubscriptionPackageWithAllocationPrice - ) = packageWithAllocation.validity() + /** + * Alias for calling [price] with `Price.ofGroupedTieredPackage(groupedTieredPackage)`. + */ + fun price(groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice) = + price(Price.ofGroupedTieredPackage(groupedTieredPackage)) - override fun visitUnitWithPercent( - unitWithPercent: NewSubscriptionUnitWithPercentPrice - ) = unitWithPercent.validity() + /** + * Alias for calling [price] with + * `Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)`. + */ + fun price(maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice) = + price(Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)) - override fun visitMatrixWithAllocation( - matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice - ) = matrixWithAllocation.validity() + /** + * Alias for calling [price] with + * `Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)`. + */ + fun price( + scalableMatrixWithUnitPricing: NewSubscriptionScalableMatrixWithUnitPricingPrice + ) = price(Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)) - override fun visitTieredWithProration( - tieredWithProration: TieredWithProration - ) = tieredWithProration.validity() + /** + * Alias for calling [price] with + * `Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)`. + */ + fun price( + scalableMatrixWithTieredPricing: NewSubscriptionScalableMatrixWithTieredPricingPrice + ) = price(Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)) - override fun visitUnitWithProration( - unitWithProration: NewSubscriptionUnitWithProrationPrice - ) = unitWithProration.validity() + /** + * Alias for calling [price] with + * `Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)`. + */ + fun price(cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice) = + price(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) - override fun visitGroupedAllocation( - groupedAllocation: NewSubscriptionGroupedAllocationPrice - ) = groupedAllocation.validity() - - override fun visitBulkWithProration( - bulkWithProration: NewSubscriptionBulkWithProrationPrice - ) = bulkWithProration.validity() - - override fun visitGroupedWithProratedMinimum( - groupedWithProratedMinimum: - NewSubscriptionGroupedWithProratedMinimumPrice - ) = groupedWithProratedMinimum.validity() - - override fun visitGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice - ) = groupedWithMeteredMinimum.validity() - - override fun visitGroupedWithMinMaxThresholds( - groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds - ) = groupedWithMinMaxThresholds.validity() - - override fun visitMatrixWithDisplayName( - matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice - ) = matrixWithDisplayName.validity() - - override fun visitGroupedTieredPackage( - groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice - ) = groupedTieredPackage.validity() + /** + * Alias for calling [price] with + * `Price.ofCumulativeGroupedAllocation(cumulativeGroupedAllocation)`. + */ + fun price(cumulativeGroupedAllocation: Price.CumulativeGroupedAllocation) = + price(Price.ofCumulativeGroupedAllocation(cumulativeGroupedAllocation)) - override fun visitMaxGroupTieredPackage( - maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice - ) = maxGroupTieredPackage.validity() + /** Alias for calling [price] with `Price.ofMinimum(minimum)`. */ + fun price(minimum: NewSubscriptionMinimumCompositePrice) = + price(Price.ofMinimum(minimum)) - override fun visitScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: - NewSubscriptionScalableMatrixWithUnitPricingPrice - ) = scalableMatrixWithUnitPricing.validity() + /** Alias for calling [price] with `Price.ofPercent(percent)`. */ + fun price(percent: Price.Percent) = price(Price.ofPercent(percent)) - override fun visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: - NewSubscriptionScalableMatrixWithTieredPricingPrice - ) = scalableMatrixWithTieredPricing.validity() + /** Alias for calling [price] with `Price.ofEventOutput(eventOutput)`. */ + fun price(eventOutput: Price.EventOutput) = price(Price.ofEventOutput(eventOutput)) - override fun visitCumulativeGroupedBulk( - cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice - ) = cumulativeGroupedBulk.validity() + /** The id of the price to add to the subscription. */ + fun priceId(priceId: String?) = priceId(JsonField.ofNullable(priceId)) - override fun visitMinimum(minimum: NewSubscriptionMinimumCompositePrice) = - minimum.validity() + /** + * Sets [Builder.priceId] to an arbitrary JSON value. + * + * You should usually call [Builder.priceId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun priceId(priceId: JsonField) = apply { this.priceId = priceId } - override fun visitPercent(percent: Percent) = percent.validity() + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - override fun visitEventOutput(eventOutput: EventOutput) = - eventOutput.validity() + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - override fun unknown(json: JsonValue?) = 0 - } - ) + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - return other is Price && - unit == other.unit && - tiered == other.tiered && - bulk == other.bulk && - bulkWithFilters == other.bulkWithFilters && - package_ == other.package_ && - matrix == other.matrix && - thresholdTotalAmount == other.thresholdTotalAmount && - tieredPackage == other.tieredPackage && - tieredWithMinimum == other.tieredWithMinimum && - groupedTiered == other.groupedTiered && - tieredPackageWithMinimum == other.tieredPackageWithMinimum && - packageWithAllocation == other.packageWithAllocation && - unitWithPercent == other.unitWithPercent && - matrixWithAllocation == other.matrixWithAllocation && - tieredWithProration == other.tieredWithProration && - unitWithProration == other.unitWithProration && - groupedAllocation == other.groupedAllocation && - bulkWithProration == other.bulkWithProration && - groupedWithProratedMinimum == other.groupedWithProratedMinimum && - groupedWithMeteredMinimum == other.groupedWithMeteredMinimum && - groupedWithMinMaxThresholds == other.groupedWithMinMaxThresholds && - matrixWithDisplayName == other.matrixWithDisplayName && - groupedTieredPackage == other.groupedTieredPackage && - maxGroupTieredPackage == other.maxGroupTieredPackage && - scalableMatrixWithUnitPricing == other.scalableMatrixWithUnitPricing && - scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && - cumulativeGroupedBulk == other.cumulativeGroupedBulk && - minimum == other.minimum && - percent == other.percent && - eventOutput == other.eventOutput + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) } - override fun hashCode(): Int = - Objects.hash( - unit, - tiered, - bulk, - bulkWithFilters, - package_, - matrix, - thresholdTotalAmount, - tieredPackage, - tieredWithMinimum, - groupedTiered, - tieredPackageWithMinimum, - packageWithAllocation, - unitWithPercent, - matrixWithAllocation, - tieredWithProration, - unitWithProration, - groupedAllocation, - bulkWithProration, - groupedWithProratedMinimum, - groupedWithMeteredMinimum, - groupedWithMinMaxThresholds, - matrixWithDisplayName, - groupedTieredPackage, - maxGroupTieredPackage, - scalableMatrixWithUnitPricing, - scalableMatrixWithTieredPricing, - cumulativeGroupedBulk, - minimum, - percent, - eventOutput, + /** + * Returns an immutable instance of [ReplacePrice]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .replacesPriceId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ReplacePrice = + ReplacePrice( + checkRequired("replacesPriceId", replacesPriceId), + allocationPrice, + (discounts ?: JsonMissing.of()).map { it.toImmutable() }, + externalPriceId, + fixedPriceQuantity, + maximumAmount, + minimumAmount, + price, + priceId, + additionalProperties.toMutableMap(), ) + } - override fun toString(): String = - when { - unit != null -> "Price{unit=$unit}" - tiered != null -> "Price{tiered=$tiered}" - bulk != null -> "Price{bulk=$bulk}" - bulkWithFilters != null -> "Price{bulkWithFilters=$bulkWithFilters}" - package_ != null -> "Price{package_=$package_}" - matrix != null -> "Price{matrix=$matrix}" - thresholdTotalAmount != null -> - "Price{thresholdTotalAmount=$thresholdTotalAmount}" - tieredPackage != null -> "Price{tieredPackage=$tieredPackage}" - tieredWithMinimum != null -> "Price{tieredWithMinimum=$tieredWithMinimum}" - groupedTiered != null -> "Price{groupedTiered=$groupedTiered}" - tieredPackageWithMinimum != null -> - "Price{tieredPackageWithMinimum=$tieredPackageWithMinimum}" - packageWithAllocation != null -> - "Price{packageWithAllocation=$packageWithAllocation}" - unitWithPercent != null -> "Price{unitWithPercent=$unitWithPercent}" - matrixWithAllocation != null -> - "Price{matrixWithAllocation=$matrixWithAllocation}" - tieredWithProration != null -> "Price{tieredWithProration=$tieredWithProration}" - unitWithProration != null -> "Price{unitWithProration=$unitWithProration}" - groupedAllocation != null -> "Price{groupedAllocation=$groupedAllocation}" - bulkWithProration != null -> "Price{bulkWithProration=$bulkWithProration}" - groupedWithProratedMinimum != null -> - "Price{groupedWithProratedMinimum=$groupedWithProratedMinimum}" - groupedWithMeteredMinimum != null -> - "Price{groupedWithMeteredMinimum=$groupedWithMeteredMinimum}" - groupedWithMinMaxThresholds != null -> - "Price{groupedWithMinMaxThresholds=$groupedWithMinMaxThresholds}" - matrixWithDisplayName != null -> - "Price{matrixWithDisplayName=$matrixWithDisplayName}" - groupedTieredPackage != null -> - "Price{groupedTieredPackage=$groupedTieredPackage}" - maxGroupTieredPackage != null -> - "Price{maxGroupTieredPackage=$maxGroupTieredPackage}" - scalableMatrixWithUnitPricing != null -> - "Price{scalableMatrixWithUnitPricing=$scalableMatrixWithUnitPricing}" - scalableMatrixWithTieredPricing != null -> - "Price{scalableMatrixWithTieredPricing=$scalableMatrixWithTieredPricing}" - cumulativeGroupedBulk != null -> - "Price{cumulativeGroupedBulk=$cumulativeGroupedBulk}" - minimum != null -> "Price{minimum=$minimum}" - percent != null -> "Price{percent=$percent}" - eventOutput != null -> "Price{eventOutput=$eventOutput}" - _json != null -> "Price{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Price") - } - - companion object { - - fun ofUnit(unit: NewSubscriptionUnitPrice) = Price(unit = unit) - - fun ofTiered(tiered: NewSubscriptionTieredPrice) = Price(tiered = tiered) + private var validated: Boolean = false - fun ofBulk(bulk: NewSubscriptionBulkPrice) = Price(bulk = bulk) + fun validate(): ReplacePrice = apply { + if (validated) { + return@apply + } - fun ofBulkWithFilters(bulkWithFilters: BulkWithFilters) = - Price(bulkWithFilters = bulkWithFilters) + replacesPriceId() + allocationPrice()?.validate() + discounts()?.forEach { it.validate() } + externalPriceId() + fixedPriceQuantity() + maximumAmount() + minimumAmount() + price()?.validate() + priceId() + validated = true + } - fun ofPackage(package_: NewSubscriptionPackagePrice) = Price(package_ = package_) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - fun ofMatrix(matrix: NewSubscriptionMatrixPrice) = Price(matrix = matrix) + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (replacesPriceId.asKnown() == null) 0 else 1) + + (allocationPrice.asKnown()?.validity() ?: 0) + + (discounts.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (maximumAmount.asKnown() == null) 0 else 1) + + (if (minimumAmount.asKnown() == null) 0 else 1) + + (price.asKnown()?.validity() ?: 0) + + (if (priceId.asKnown() == null) 0 else 1) - fun ofThresholdTotalAmount( - thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice - ) = Price(thresholdTotalAmount = thresholdTotalAmount) + /** New subscription price request body params. */ + @JsonDeserialize(using = Price.Deserializer::class) + @JsonSerialize(using = Price.Serializer::class) + class Price + private constructor( + private val unit: NewSubscriptionUnitPrice? = null, + private val tiered: NewSubscriptionTieredPrice? = null, + private val bulk: NewSubscriptionBulkPrice? = null, + private val bulkWithFilters: BulkWithFilters? = null, + private val package_: NewSubscriptionPackagePrice? = null, + private val matrix: NewSubscriptionMatrixPrice? = null, + private val thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice? = null, + private val tieredPackage: NewSubscriptionTieredPackagePrice? = null, + private val tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice? = null, + private val groupedTiered: NewSubscriptionGroupedTieredPrice? = null, + private val tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice? = + null, + private val packageWithAllocation: NewSubscriptionPackageWithAllocationPrice? = null, + private val unitWithPercent: NewSubscriptionUnitWithPercentPrice? = null, + private val matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice? = null, + private val tieredWithProration: TieredWithProration? = null, + private val unitWithProration: NewSubscriptionUnitWithProrationPrice? = null, + private val groupedAllocation: NewSubscriptionGroupedAllocationPrice? = null, + private val bulkWithProration: NewSubscriptionBulkWithProrationPrice? = null, + private val groupedWithProratedMinimum: + NewSubscriptionGroupedWithProratedMinimumPrice? = + null, + private val groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice? = + null, + private val groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds? = null, + private val matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice? = null, + private val groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice? = null, + private val maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice? = null, + private val scalableMatrixWithUnitPricing: + NewSubscriptionScalableMatrixWithUnitPricingPrice? = + null, + private val scalableMatrixWithTieredPricing: + NewSubscriptionScalableMatrixWithTieredPricingPrice? = + null, + private val cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice? = null, + private val cumulativeGroupedAllocation: CumulativeGroupedAllocation? = null, + private val minimum: NewSubscriptionMinimumCompositePrice? = null, + private val percent: Percent? = null, + private val eventOutput: EventOutput? = null, + private val _json: JsonValue? = null, + ) { - fun ofTieredPackage(tieredPackage: NewSubscriptionTieredPackagePrice) = - Price(tieredPackage = tieredPackage) + fun unit(): NewSubscriptionUnitPrice? = unit - fun ofTieredWithMinimum(tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice) = - Price(tieredWithMinimum = tieredWithMinimum) + fun tiered(): NewSubscriptionTieredPrice? = tiered - fun ofGroupedTiered(groupedTiered: NewSubscriptionGroupedTieredPrice) = - Price(groupedTiered = groupedTiered) + fun bulk(): NewSubscriptionBulkPrice? = bulk - fun ofTieredPackageWithMinimum( - tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice - ) = Price(tieredPackageWithMinimum = tieredPackageWithMinimum) + fun bulkWithFilters(): BulkWithFilters? = bulkWithFilters - fun ofPackageWithAllocation( - packageWithAllocation: NewSubscriptionPackageWithAllocationPrice - ) = Price(packageWithAllocation = packageWithAllocation) + fun package_(): NewSubscriptionPackagePrice? = package_ - fun ofUnitWithPercent(unitWithPercent: NewSubscriptionUnitWithPercentPrice) = - Price(unitWithPercent = unitWithPercent) + fun matrix(): NewSubscriptionMatrixPrice? = matrix - fun ofMatrixWithAllocation( - matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice - ) = Price(matrixWithAllocation = matrixWithAllocation) + fun thresholdTotalAmount(): NewSubscriptionThresholdTotalAmountPrice? = + thresholdTotalAmount - fun ofTieredWithProration(tieredWithProration: TieredWithProration) = - Price(tieredWithProration = tieredWithProration) + fun tieredPackage(): NewSubscriptionTieredPackagePrice? = tieredPackage - fun ofUnitWithProration(unitWithProration: NewSubscriptionUnitWithProrationPrice) = - Price(unitWithProration = unitWithProration) + fun tieredWithMinimum(): NewSubscriptionTieredWithMinimumPrice? = tieredWithMinimum - fun ofGroupedAllocation(groupedAllocation: NewSubscriptionGroupedAllocationPrice) = - Price(groupedAllocation = groupedAllocation) + fun groupedTiered(): NewSubscriptionGroupedTieredPrice? = groupedTiered - fun ofBulkWithProration(bulkWithProration: NewSubscriptionBulkWithProrationPrice) = - Price(bulkWithProration = bulkWithProration) + fun tieredPackageWithMinimum(): NewSubscriptionTieredPackageWithMinimumPrice? = + tieredPackageWithMinimum - fun ofGroupedWithProratedMinimum( - groupedWithProratedMinimum: NewSubscriptionGroupedWithProratedMinimumPrice - ) = Price(groupedWithProratedMinimum = groupedWithProratedMinimum) + fun packageWithAllocation(): NewSubscriptionPackageWithAllocationPrice? = + packageWithAllocation - fun ofGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice - ) = Price(groupedWithMeteredMinimum = groupedWithMeteredMinimum) + fun unitWithPercent(): NewSubscriptionUnitWithPercentPrice? = unitWithPercent - fun ofGroupedWithMinMaxThresholds( - groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds - ) = Price(groupedWithMinMaxThresholds = groupedWithMinMaxThresholds) + fun matrixWithAllocation(): NewSubscriptionMatrixWithAllocationPrice? = + matrixWithAllocation - fun ofMatrixWithDisplayName( - matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice - ) = Price(matrixWithDisplayName = matrixWithDisplayName) + fun tieredWithProration(): TieredWithProration? = tieredWithProration - fun ofGroupedTieredPackage( - groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice - ) = Price(groupedTieredPackage = groupedTieredPackage) + fun unitWithProration(): NewSubscriptionUnitWithProrationPrice? = unitWithProration - fun ofMaxGroupTieredPackage( - maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice - ) = Price(maxGroupTieredPackage = maxGroupTieredPackage) + fun groupedAllocation(): NewSubscriptionGroupedAllocationPrice? = groupedAllocation - fun ofScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: NewSubscriptionScalableMatrixWithUnitPricingPrice - ) = Price(scalableMatrixWithUnitPricing = scalableMatrixWithUnitPricing) + fun bulkWithProration(): NewSubscriptionBulkWithProrationPrice? = bulkWithProration - fun ofScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: - NewSubscriptionScalableMatrixWithTieredPricingPrice - ) = Price(scalableMatrixWithTieredPricing = scalableMatrixWithTieredPricing) + fun groupedWithProratedMinimum(): NewSubscriptionGroupedWithProratedMinimumPrice? = + groupedWithProratedMinimum - fun ofCumulativeGroupedBulk( - cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice - ) = Price(cumulativeGroupedBulk = cumulativeGroupedBulk) + fun groupedWithMeteredMinimum(): NewSubscriptionGroupedWithMeteredMinimumPrice? = + groupedWithMeteredMinimum - fun ofMinimum(minimum: NewSubscriptionMinimumCompositePrice) = - Price(minimum = minimum) + fun groupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds? = + groupedWithMinMaxThresholds - fun ofPercent(percent: Percent) = Price(percent = percent) + fun matrixWithDisplayName(): NewSubscriptionMatrixWithDisplayNamePrice? = + matrixWithDisplayName - fun ofEventOutput(eventOutput: EventOutput) = Price(eventOutput = eventOutput) - } + fun groupedTieredPackage(): NewSubscriptionGroupedTieredPackagePrice? = + groupedTieredPackage - /** - * An interface that defines how to map each variant of [Price] to a value of type [T]. - */ - interface Visitor { + fun maxGroupTieredPackage(): NewSubscriptionMaxGroupTieredPackagePrice? = + maxGroupTieredPackage - fun visitUnit(unit: NewSubscriptionUnitPrice): T + fun scalableMatrixWithUnitPricing(): + NewSubscriptionScalableMatrixWithUnitPricingPrice? = scalableMatrixWithUnitPricing - fun visitTiered(tiered: NewSubscriptionTieredPrice): T + fun scalableMatrixWithTieredPricing(): + NewSubscriptionScalableMatrixWithTieredPricingPrice? = + scalableMatrixWithTieredPricing - fun visitBulk(bulk: NewSubscriptionBulkPrice): T + fun cumulativeGroupedBulk(): NewSubscriptionCumulativeGroupedBulkPrice? = + cumulativeGroupedBulk - fun visitBulkWithFilters(bulkWithFilters: BulkWithFilters): T + fun cumulativeGroupedAllocation(): CumulativeGroupedAllocation? = + cumulativeGroupedAllocation - fun visitPackage(package_: NewSubscriptionPackagePrice): T + fun minimum(): NewSubscriptionMinimumCompositePrice? = minimum - fun visitMatrix(matrix: NewSubscriptionMatrixPrice): T + fun percent(): Percent? = percent - fun visitThresholdTotalAmount( - thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice - ): T + fun eventOutput(): EventOutput? = eventOutput - fun visitTieredPackage(tieredPackage: NewSubscriptionTieredPackagePrice): T + fun isUnit(): Boolean = unit != null - fun visitTieredWithMinimum( - tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice - ): T + fun isTiered(): Boolean = tiered != null - fun visitGroupedTiered(groupedTiered: NewSubscriptionGroupedTieredPrice): T + fun isBulk(): Boolean = bulk != null - fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice - ): T + fun isBulkWithFilters(): Boolean = bulkWithFilters != null - fun visitPackageWithAllocation( - packageWithAllocation: NewSubscriptionPackageWithAllocationPrice - ): T + fun isPackage(): Boolean = package_ != null - fun visitUnitWithPercent(unitWithPercent: NewSubscriptionUnitWithPercentPrice): T + fun isMatrix(): Boolean = matrix != null - fun visitMatrixWithAllocation( - matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice - ): T + fun isThresholdTotalAmount(): Boolean = thresholdTotalAmount != null - fun visitTieredWithProration(tieredWithProration: TieredWithProration): T + fun isTieredPackage(): Boolean = tieredPackage != null - fun visitUnitWithProration( - unitWithProration: NewSubscriptionUnitWithProrationPrice - ): T + fun isTieredWithMinimum(): Boolean = tieredWithMinimum != null - fun visitGroupedAllocation( - groupedAllocation: NewSubscriptionGroupedAllocationPrice - ): T + fun isGroupedTiered(): Boolean = groupedTiered != null - fun visitBulkWithProration( - bulkWithProration: NewSubscriptionBulkWithProrationPrice - ): T + fun isTieredPackageWithMinimum(): Boolean = tieredPackageWithMinimum != null - fun visitGroupedWithProratedMinimum( - groupedWithProratedMinimum: NewSubscriptionGroupedWithProratedMinimumPrice - ): T + fun isPackageWithAllocation(): Boolean = packageWithAllocation != null - fun visitGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice - ): T + fun isUnitWithPercent(): Boolean = unitWithPercent != null - fun visitGroupedWithMinMaxThresholds( - groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds - ): T + fun isMatrixWithAllocation(): Boolean = matrixWithAllocation != null - fun visitMatrixWithDisplayName( - matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice - ): T + fun isTieredWithProration(): Boolean = tieredWithProration != null - fun visitGroupedTieredPackage( - groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice - ): T + fun isUnitWithProration(): Boolean = unitWithProration != null - fun visitMaxGroupTieredPackage( - maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice - ): T + fun isGroupedAllocation(): Boolean = groupedAllocation != null - fun visitScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: NewSubscriptionScalableMatrixWithUnitPricingPrice - ): T + fun isBulkWithProration(): Boolean = bulkWithProration != null - fun visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: - NewSubscriptionScalableMatrixWithTieredPricingPrice - ): T + fun isGroupedWithProratedMinimum(): Boolean = groupedWithProratedMinimum != null - fun visitCumulativeGroupedBulk( - cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice - ): T + fun isGroupedWithMeteredMinimum(): Boolean = groupedWithMeteredMinimum != null - fun visitMinimum(minimum: NewSubscriptionMinimumCompositePrice): T + fun isGroupedWithMinMaxThresholds(): Boolean = groupedWithMinMaxThresholds != null - fun visitPercent(percent: Percent): T + fun isMatrixWithDisplayName(): Boolean = matrixWithDisplayName != null - fun visitEventOutput(eventOutput: EventOutput): T + fun isGroupedTieredPackage(): Boolean = groupedTieredPackage != null - /** - * Maps an unknown variant of [Price] to a value of type [T]. - * - * An instance of [Price] can contain an unknown variant if it was deserialized from - * data that doesn't match any known variant. For example, if the SDK is on an older - * version than the API, then the API may respond with new variants that the SDK is - * unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown Price: $json") + fun isMaxGroupTieredPackage(): Boolean = maxGroupTieredPackage != null + + fun isScalableMatrixWithUnitPricing(): Boolean = scalableMatrixWithUnitPricing != null + + fun isScalableMatrixWithTieredPricing(): Boolean = + scalableMatrixWithTieredPricing != null + + fun isCumulativeGroupedBulk(): Boolean = cumulativeGroupedBulk != null + + fun isCumulativeGroupedAllocation(): Boolean = cumulativeGroupedAllocation != null + + fun isMinimum(): Boolean = minimum != null + + fun isPercent(): Boolean = percent != null + + fun isEventOutput(): Boolean = eventOutput != null + + fun asUnit(): NewSubscriptionUnitPrice = unit.getOrThrow("unit") + + fun asTiered(): NewSubscriptionTieredPrice = tiered.getOrThrow("tiered") + + fun asBulk(): NewSubscriptionBulkPrice = bulk.getOrThrow("bulk") + + fun asBulkWithFilters(): BulkWithFilters = bulkWithFilters.getOrThrow("bulkWithFilters") + + fun asPackage(): NewSubscriptionPackagePrice = package_.getOrThrow("package_") + + fun asMatrix(): NewSubscriptionMatrixPrice = matrix.getOrThrow("matrix") + + fun asThresholdTotalAmount(): NewSubscriptionThresholdTotalAmountPrice = + thresholdTotalAmount.getOrThrow("thresholdTotalAmount") + + fun asTieredPackage(): NewSubscriptionTieredPackagePrice = + tieredPackage.getOrThrow("tieredPackage") + + fun asTieredWithMinimum(): NewSubscriptionTieredWithMinimumPrice = + tieredWithMinimum.getOrThrow("tieredWithMinimum") + + fun asGroupedTiered(): NewSubscriptionGroupedTieredPrice = + groupedTiered.getOrThrow("groupedTiered") + + fun asTieredPackageWithMinimum(): NewSubscriptionTieredPackageWithMinimumPrice = + tieredPackageWithMinimum.getOrThrow("tieredPackageWithMinimum") + + fun asPackageWithAllocation(): NewSubscriptionPackageWithAllocationPrice = + packageWithAllocation.getOrThrow("packageWithAllocation") + + fun asUnitWithPercent(): NewSubscriptionUnitWithPercentPrice = + unitWithPercent.getOrThrow("unitWithPercent") + + fun asMatrixWithAllocation(): NewSubscriptionMatrixWithAllocationPrice = + matrixWithAllocation.getOrThrow("matrixWithAllocation") + + fun asTieredWithProration(): TieredWithProration = + tieredWithProration.getOrThrow("tieredWithProration") + + fun asUnitWithProration(): NewSubscriptionUnitWithProrationPrice = + unitWithProration.getOrThrow("unitWithProration") + + fun asGroupedAllocation(): NewSubscriptionGroupedAllocationPrice = + groupedAllocation.getOrThrow("groupedAllocation") + + fun asBulkWithProration(): NewSubscriptionBulkWithProrationPrice = + bulkWithProration.getOrThrow("bulkWithProration") + + fun asGroupedWithProratedMinimum(): NewSubscriptionGroupedWithProratedMinimumPrice = + groupedWithProratedMinimum.getOrThrow("groupedWithProratedMinimum") + + fun asGroupedWithMeteredMinimum(): NewSubscriptionGroupedWithMeteredMinimumPrice = + groupedWithMeteredMinimum.getOrThrow("groupedWithMeteredMinimum") + + fun asGroupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds = + groupedWithMinMaxThresholds.getOrThrow("groupedWithMinMaxThresholds") + + fun asMatrixWithDisplayName(): NewSubscriptionMatrixWithDisplayNamePrice = + matrixWithDisplayName.getOrThrow("matrixWithDisplayName") + + fun asGroupedTieredPackage(): NewSubscriptionGroupedTieredPackagePrice = + groupedTieredPackage.getOrThrow("groupedTieredPackage") + + fun asMaxGroupTieredPackage(): NewSubscriptionMaxGroupTieredPackagePrice = + maxGroupTieredPackage.getOrThrow("maxGroupTieredPackage") + + fun asScalableMatrixWithUnitPricing(): + NewSubscriptionScalableMatrixWithUnitPricingPrice = + scalableMatrixWithUnitPricing.getOrThrow("scalableMatrixWithUnitPricing") + + fun asScalableMatrixWithTieredPricing(): + NewSubscriptionScalableMatrixWithTieredPricingPrice = + scalableMatrixWithTieredPricing.getOrThrow("scalableMatrixWithTieredPricing") + + fun asCumulativeGroupedBulk(): NewSubscriptionCumulativeGroupedBulkPrice = + cumulativeGroupedBulk.getOrThrow("cumulativeGroupedBulk") + + fun asCumulativeGroupedAllocation(): CumulativeGroupedAllocation = + cumulativeGroupedAllocation.getOrThrow("cumulativeGroupedAllocation") + + fun asMinimum(): NewSubscriptionMinimumCompositePrice = minimum.getOrThrow("minimum") + + fun asPercent(): Percent = percent.getOrThrow("percent") + + fun asEventOutput(): EventOutput = eventOutput.getOrThrow("eventOutput") + + fun _json(): JsonValue? = _json + + fun accept(visitor: Visitor): T = + when { + unit != null -> visitor.visitUnit(unit) + tiered != null -> visitor.visitTiered(tiered) + bulk != null -> visitor.visitBulk(bulk) + bulkWithFilters != null -> visitor.visitBulkWithFilters(bulkWithFilters) + package_ != null -> visitor.visitPackage(package_) + matrix != null -> visitor.visitMatrix(matrix) + thresholdTotalAmount != null -> + visitor.visitThresholdTotalAmount(thresholdTotalAmount) + tieredPackage != null -> visitor.visitTieredPackage(tieredPackage) + tieredWithMinimum != null -> visitor.visitTieredWithMinimum(tieredWithMinimum) + groupedTiered != null -> visitor.visitGroupedTiered(groupedTiered) + tieredPackageWithMinimum != null -> + visitor.visitTieredPackageWithMinimum(tieredPackageWithMinimum) + packageWithAllocation != null -> + visitor.visitPackageWithAllocation(packageWithAllocation) + unitWithPercent != null -> visitor.visitUnitWithPercent(unitWithPercent) + matrixWithAllocation != null -> + visitor.visitMatrixWithAllocation(matrixWithAllocation) + tieredWithProration != null -> + visitor.visitTieredWithProration(tieredWithProration) + unitWithProration != null -> visitor.visitUnitWithProration(unitWithProration) + groupedAllocation != null -> visitor.visitGroupedAllocation(groupedAllocation) + bulkWithProration != null -> visitor.visitBulkWithProration(bulkWithProration) + groupedWithProratedMinimum != null -> + visitor.visitGroupedWithProratedMinimum(groupedWithProratedMinimum) + groupedWithMeteredMinimum != null -> + visitor.visitGroupedWithMeteredMinimum(groupedWithMeteredMinimum) + groupedWithMinMaxThresholds != null -> + visitor.visitGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds) + matrixWithDisplayName != null -> + visitor.visitMatrixWithDisplayName(matrixWithDisplayName) + groupedTieredPackage != null -> + visitor.visitGroupedTieredPackage(groupedTieredPackage) + maxGroupTieredPackage != null -> + visitor.visitMaxGroupTieredPackage(maxGroupTieredPackage) + scalableMatrixWithUnitPricing != null -> + visitor.visitScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing) + scalableMatrixWithTieredPricing != null -> + visitor.visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing + ) + cumulativeGroupedBulk != null -> + visitor.visitCumulativeGroupedBulk(cumulativeGroupedBulk) + cumulativeGroupedAllocation != null -> + visitor.visitCumulativeGroupedAllocation(cumulativeGroupedAllocation) + minimum != null -> visitor.visitMinimum(minimum) + percent != null -> visitor.visitPercent(percent) + eventOutput != null -> visitor.visitEventOutput(eventOutput) + else -> visitor.unknown(_json) } - } - internal class Deserializer : BaseDeserializer(Price::class) { + private var validated: Boolean = false - override fun ObjectCodec.deserialize(node: JsonNode): Price { - val json = JsonValue.fromJsonNode(node) - val modelType = json.asObject()?.get("model_type")?.asString() + fun validate(): Price = apply { + if (validated) { + return@apply + } - when (modelType) { - "unit" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(unit = it, _json = json) } ?: Price(_json = json) - } - "tiered" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(tiered = it, _json = json) } ?: Price(_json = json) + accept( + object : Visitor { + override fun visitUnit(unit: NewSubscriptionUnitPrice) { + unit.validate() } - "bulk" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(bulk = it, _json = json) } ?: Price(_json = json) + + override fun visitTiered(tiered: NewSubscriptionTieredPrice) { + tiered.validate() } - "bulk_with_filters" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(bulkWithFilters = it, _json = json) - } ?: Price(_json = json) + + override fun visitBulk(bulk: NewSubscriptionBulkPrice) { + bulk.validate() } - "package" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(package_ = it, _json = json) } ?: Price(_json = json) + + override fun visitBulkWithFilters(bulkWithFilters: BulkWithFilters) { + bulkWithFilters.validate() } - "matrix" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(matrix = it, _json = json) } ?: Price(_json = json) + + override fun visitPackage(package_: NewSubscriptionPackagePrice) { + package_.validate() } - "threshold_total_amount" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(thresholdTotalAmount = it, _json = json) } - ?: Price(_json = json) + + override fun visitMatrix(matrix: NewSubscriptionMatrixPrice) { + matrix.validate() } - "tiered_package" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(tieredPackage = it, _json = json) } - ?: Price(_json = json) + + override fun visitThresholdTotalAmount( + thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice + ) { + thresholdTotalAmount.validate() } - "tiered_with_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(tieredWithMinimum = it, _json = json) } - ?: Price(_json = json) + + override fun visitTieredPackage( + tieredPackage: NewSubscriptionTieredPackagePrice + ) { + tieredPackage.validate() } - "grouped_tiered" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedTiered = it, _json = json) } - ?: Price(_json = json) + + override fun visitTieredWithMinimum( + tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice + ) { + tieredWithMinimum.validate() } - "tiered_package_with_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(tieredPackageWithMinimum = it, _json = json) } - ?: Price(_json = json) + + override fun visitGroupedTiered( + groupedTiered: NewSubscriptionGroupedTieredPrice + ) { + groupedTiered.validate() } - "package_with_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(packageWithAllocation = it, _json = json) } - ?: Price(_json = json) + + override fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice + ) { + tieredPackageWithMinimum.validate() } - "unit_with_percent" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(unitWithPercent = it, _json = json) } - ?: Price(_json = json) + + override fun visitPackageWithAllocation( + packageWithAllocation: NewSubscriptionPackageWithAllocationPrice + ) { + packageWithAllocation.validate() } - "matrix_with_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(matrixWithAllocation = it, _json = json) } - ?: Price(_json = json) + + override fun visitUnitWithPercent( + unitWithPercent: NewSubscriptionUnitWithPercentPrice + ) { + unitWithPercent.validate() } - "tiered_with_proration" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(tieredWithProration = it, _json = json) } - ?: Price(_json = json) + + override fun visitMatrixWithAllocation( + matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice + ) { + matrixWithAllocation.validate() } - "unit_with_proration" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(unitWithProration = it, _json = json) } - ?: Price(_json = json) + + override fun visitTieredWithProration( + tieredWithProration: TieredWithProration + ) { + tieredWithProration.validate() } - "grouped_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedAllocation = it, _json = json) } - ?: Price(_json = json) + + override fun visitUnitWithProration( + unitWithProration: NewSubscriptionUnitWithProrationPrice + ) { + unitWithProration.validate() } - "bulk_with_proration" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(bulkWithProration = it, _json = json) } - ?: Price(_json = json) + + override fun visitGroupedAllocation( + groupedAllocation: NewSubscriptionGroupedAllocationPrice + ) { + groupedAllocation.validate() + } + + override fun visitBulkWithProration( + bulkWithProration: NewSubscriptionBulkWithProrationPrice + ) { + bulkWithProration.validate() + } + + override fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: + NewSubscriptionGroupedWithProratedMinimumPrice + ) { + groupedWithProratedMinimum.validate() + } + + override fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice + ) { + groupedWithMeteredMinimum.validate() + } + + override fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) { + groupedWithMinMaxThresholds.validate() + } + + override fun visitMatrixWithDisplayName( + matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice + ) { + matrixWithDisplayName.validate() + } + + override fun visitGroupedTieredPackage( + groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice + ) { + groupedTieredPackage.validate() + } + + override fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice + ) { + maxGroupTieredPackage.validate() + } + + override fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: + NewSubscriptionScalableMatrixWithUnitPricingPrice + ) { + scalableMatrixWithUnitPricing.validate() + } + + override fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: + NewSubscriptionScalableMatrixWithTieredPricingPrice + ) { + scalableMatrixWithTieredPricing.validate() + } + + override fun visitCumulativeGroupedBulk( + cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice + ) { + cumulativeGroupedBulk.validate() + } + + override fun visitCumulativeGroupedAllocation( + cumulativeGroupedAllocation: CumulativeGroupedAllocation + ) { + cumulativeGroupedAllocation.validate() + } + + override fun visitMinimum(minimum: NewSubscriptionMinimumCompositePrice) { + minimum.validate() + } + + override fun visitPercent(percent: Percent) { + percent.validate() + } + + override fun visitEventOutput(eventOutput: EventOutput) { + eventOutput.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitUnit(unit: NewSubscriptionUnitPrice) = unit.validity() + + override fun visitTiered(tiered: NewSubscriptionTieredPrice) = + tiered.validity() + + override fun visitBulk(bulk: NewSubscriptionBulkPrice) = bulk.validity() + + override fun visitBulkWithFilters(bulkWithFilters: BulkWithFilters) = + bulkWithFilters.validity() + + override fun visitPackage(package_: NewSubscriptionPackagePrice) = + package_.validity() + + override fun visitMatrix(matrix: NewSubscriptionMatrixPrice) = + matrix.validity() + + override fun visitThresholdTotalAmount( + thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice + ) = thresholdTotalAmount.validity() + + override fun visitTieredPackage( + tieredPackage: NewSubscriptionTieredPackagePrice + ) = tieredPackage.validity() + + override fun visitTieredWithMinimum( + tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice + ) = tieredWithMinimum.validity() + + override fun visitGroupedTiered( + groupedTiered: NewSubscriptionGroupedTieredPrice + ) = groupedTiered.validity() + + override fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice + ) = tieredPackageWithMinimum.validity() + + override fun visitPackageWithAllocation( + packageWithAllocation: NewSubscriptionPackageWithAllocationPrice + ) = packageWithAllocation.validity() + + override fun visitUnitWithPercent( + unitWithPercent: NewSubscriptionUnitWithPercentPrice + ) = unitWithPercent.validity() + + override fun visitMatrixWithAllocation( + matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice + ) = matrixWithAllocation.validity() + + override fun visitTieredWithProration( + tieredWithProration: TieredWithProration + ) = tieredWithProration.validity() + + override fun visitUnitWithProration( + unitWithProration: NewSubscriptionUnitWithProrationPrice + ) = unitWithProration.validity() + + override fun visitGroupedAllocation( + groupedAllocation: NewSubscriptionGroupedAllocationPrice + ) = groupedAllocation.validity() + + override fun visitBulkWithProration( + bulkWithProration: NewSubscriptionBulkWithProrationPrice + ) = bulkWithProration.validity() + + override fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: + NewSubscriptionGroupedWithProratedMinimumPrice + ) = groupedWithProratedMinimum.validity() + + override fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice + ) = groupedWithMeteredMinimum.validity() + + override fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) = groupedWithMinMaxThresholds.validity() + + override fun visitMatrixWithDisplayName( + matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice + ) = matrixWithDisplayName.validity() + + override fun visitGroupedTieredPackage( + groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice + ) = groupedTieredPackage.validity() + + override fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice + ) = maxGroupTieredPackage.validity() + + override fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: + NewSubscriptionScalableMatrixWithUnitPricingPrice + ) = scalableMatrixWithUnitPricing.validity() + + override fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: + NewSubscriptionScalableMatrixWithTieredPricingPrice + ) = scalableMatrixWithTieredPricing.validity() + + override fun visitCumulativeGroupedBulk( + cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice + ) = cumulativeGroupedBulk.validity() + + override fun visitCumulativeGroupedAllocation( + cumulativeGroupedAllocation: CumulativeGroupedAllocation + ) = cumulativeGroupedAllocation.validity() + + override fun visitMinimum(minimum: NewSubscriptionMinimumCompositePrice) = + minimum.validity() + + override fun visitPercent(percent: Percent) = percent.validity() + + override fun visitEventOutput(eventOutput: EventOutput) = + eventOutput.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Price && + unit == other.unit && + tiered == other.tiered && + bulk == other.bulk && + bulkWithFilters == other.bulkWithFilters && + package_ == other.package_ && + matrix == other.matrix && + thresholdTotalAmount == other.thresholdTotalAmount && + tieredPackage == other.tieredPackage && + tieredWithMinimum == other.tieredWithMinimum && + groupedTiered == other.groupedTiered && + tieredPackageWithMinimum == other.tieredPackageWithMinimum && + packageWithAllocation == other.packageWithAllocation && + unitWithPercent == other.unitWithPercent && + matrixWithAllocation == other.matrixWithAllocation && + tieredWithProration == other.tieredWithProration && + unitWithProration == other.unitWithProration && + groupedAllocation == other.groupedAllocation && + bulkWithProration == other.bulkWithProration && + groupedWithProratedMinimum == other.groupedWithProratedMinimum && + groupedWithMeteredMinimum == other.groupedWithMeteredMinimum && + groupedWithMinMaxThresholds == other.groupedWithMinMaxThresholds && + matrixWithDisplayName == other.matrixWithDisplayName && + groupedTieredPackage == other.groupedTieredPackage && + maxGroupTieredPackage == other.maxGroupTieredPackage && + scalableMatrixWithUnitPricing == other.scalableMatrixWithUnitPricing && + scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && + cumulativeGroupedBulk == other.cumulativeGroupedBulk && + cumulativeGroupedAllocation == other.cumulativeGroupedAllocation && + minimum == other.minimum && + percent == other.percent && + eventOutput == other.eventOutput + } + + override fun hashCode(): Int = + Objects.hash( + unit, + tiered, + bulk, + bulkWithFilters, + package_, + matrix, + thresholdTotalAmount, + tieredPackage, + tieredWithMinimum, + groupedTiered, + tieredPackageWithMinimum, + packageWithAllocation, + unitWithPercent, + matrixWithAllocation, + tieredWithProration, + unitWithProration, + groupedAllocation, + bulkWithProration, + groupedWithProratedMinimum, + groupedWithMeteredMinimum, + groupedWithMinMaxThresholds, + matrixWithDisplayName, + groupedTieredPackage, + maxGroupTieredPackage, + scalableMatrixWithUnitPricing, + scalableMatrixWithTieredPricing, + cumulativeGroupedBulk, + cumulativeGroupedAllocation, + minimum, + percent, + eventOutput, + ) + + override fun toString(): String = + when { + unit != null -> "Price{unit=$unit}" + tiered != null -> "Price{tiered=$tiered}" + bulk != null -> "Price{bulk=$bulk}" + bulkWithFilters != null -> "Price{bulkWithFilters=$bulkWithFilters}" + package_ != null -> "Price{package_=$package_}" + matrix != null -> "Price{matrix=$matrix}" + thresholdTotalAmount != null -> + "Price{thresholdTotalAmount=$thresholdTotalAmount}" + tieredPackage != null -> "Price{tieredPackage=$tieredPackage}" + tieredWithMinimum != null -> "Price{tieredWithMinimum=$tieredWithMinimum}" + groupedTiered != null -> "Price{groupedTiered=$groupedTiered}" + tieredPackageWithMinimum != null -> + "Price{tieredPackageWithMinimum=$tieredPackageWithMinimum}" + packageWithAllocation != null -> + "Price{packageWithAllocation=$packageWithAllocation}" + unitWithPercent != null -> "Price{unitWithPercent=$unitWithPercent}" + matrixWithAllocation != null -> + "Price{matrixWithAllocation=$matrixWithAllocation}" + tieredWithProration != null -> "Price{tieredWithProration=$tieredWithProration}" + unitWithProration != null -> "Price{unitWithProration=$unitWithProration}" + groupedAllocation != null -> "Price{groupedAllocation=$groupedAllocation}" + bulkWithProration != null -> "Price{bulkWithProration=$bulkWithProration}" + groupedWithProratedMinimum != null -> + "Price{groupedWithProratedMinimum=$groupedWithProratedMinimum}" + groupedWithMeteredMinimum != null -> + "Price{groupedWithMeteredMinimum=$groupedWithMeteredMinimum}" + groupedWithMinMaxThresholds != null -> + "Price{groupedWithMinMaxThresholds=$groupedWithMinMaxThresholds}" + matrixWithDisplayName != null -> + "Price{matrixWithDisplayName=$matrixWithDisplayName}" + groupedTieredPackage != null -> + "Price{groupedTieredPackage=$groupedTieredPackage}" + maxGroupTieredPackage != null -> + "Price{maxGroupTieredPackage=$maxGroupTieredPackage}" + scalableMatrixWithUnitPricing != null -> + "Price{scalableMatrixWithUnitPricing=$scalableMatrixWithUnitPricing}" + scalableMatrixWithTieredPricing != null -> + "Price{scalableMatrixWithTieredPricing=$scalableMatrixWithTieredPricing}" + cumulativeGroupedBulk != null -> + "Price{cumulativeGroupedBulk=$cumulativeGroupedBulk}" + cumulativeGroupedAllocation != null -> + "Price{cumulativeGroupedAllocation=$cumulativeGroupedAllocation}" + minimum != null -> "Price{minimum=$minimum}" + percent != null -> "Price{percent=$percent}" + eventOutput != null -> "Price{eventOutput=$eventOutput}" + _json != null -> "Price{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Price") + } + + companion object { + + fun ofUnit(unit: NewSubscriptionUnitPrice) = Price(unit = unit) + + fun ofTiered(tiered: NewSubscriptionTieredPrice) = Price(tiered = tiered) + + fun ofBulk(bulk: NewSubscriptionBulkPrice) = Price(bulk = bulk) + + fun ofBulkWithFilters(bulkWithFilters: BulkWithFilters) = + Price(bulkWithFilters = bulkWithFilters) + + fun ofPackage(package_: NewSubscriptionPackagePrice) = Price(package_ = package_) + + fun ofMatrix(matrix: NewSubscriptionMatrixPrice) = Price(matrix = matrix) + + fun ofThresholdTotalAmount( + thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice + ) = Price(thresholdTotalAmount = thresholdTotalAmount) + + fun ofTieredPackage(tieredPackage: NewSubscriptionTieredPackagePrice) = + Price(tieredPackage = tieredPackage) + + fun ofTieredWithMinimum(tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice) = + Price(tieredWithMinimum = tieredWithMinimum) + + fun ofGroupedTiered(groupedTiered: NewSubscriptionGroupedTieredPrice) = + Price(groupedTiered = groupedTiered) + + fun ofTieredPackageWithMinimum( + tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice + ) = Price(tieredPackageWithMinimum = tieredPackageWithMinimum) + + fun ofPackageWithAllocation( + packageWithAllocation: NewSubscriptionPackageWithAllocationPrice + ) = Price(packageWithAllocation = packageWithAllocation) + + fun ofUnitWithPercent(unitWithPercent: NewSubscriptionUnitWithPercentPrice) = + Price(unitWithPercent = unitWithPercent) + + fun ofMatrixWithAllocation( + matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice + ) = Price(matrixWithAllocation = matrixWithAllocation) + + fun ofTieredWithProration(tieredWithProration: TieredWithProration) = + Price(tieredWithProration = tieredWithProration) + + fun ofUnitWithProration(unitWithProration: NewSubscriptionUnitWithProrationPrice) = + Price(unitWithProration = unitWithProration) + + fun ofGroupedAllocation(groupedAllocation: NewSubscriptionGroupedAllocationPrice) = + Price(groupedAllocation = groupedAllocation) + + fun ofBulkWithProration(bulkWithProration: NewSubscriptionBulkWithProrationPrice) = + Price(bulkWithProration = bulkWithProration) + + fun ofGroupedWithProratedMinimum( + groupedWithProratedMinimum: NewSubscriptionGroupedWithProratedMinimumPrice + ) = Price(groupedWithProratedMinimum = groupedWithProratedMinimum) + + fun ofGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice + ) = Price(groupedWithMeteredMinimum = groupedWithMeteredMinimum) + + fun ofGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) = Price(groupedWithMinMaxThresholds = groupedWithMinMaxThresholds) + + fun ofMatrixWithDisplayName( + matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice + ) = Price(matrixWithDisplayName = matrixWithDisplayName) + + fun ofGroupedTieredPackage( + groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice + ) = Price(groupedTieredPackage = groupedTieredPackage) + + fun ofMaxGroupTieredPackage( + maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice + ) = Price(maxGroupTieredPackage = maxGroupTieredPackage) + + fun ofScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: NewSubscriptionScalableMatrixWithUnitPricingPrice + ) = Price(scalableMatrixWithUnitPricing = scalableMatrixWithUnitPricing) + + fun ofScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: + NewSubscriptionScalableMatrixWithTieredPricingPrice + ) = Price(scalableMatrixWithTieredPricing = scalableMatrixWithTieredPricing) + + fun ofCumulativeGroupedBulk( + cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice + ) = Price(cumulativeGroupedBulk = cumulativeGroupedBulk) + + fun ofCumulativeGroupedAllocation( + cumulativeGroupedAllocation: CumulativeGroupedAllocation + ) = Price(cumulativeGroupedAllocation = cumulativeGroupedAllocation) + + fun ofMinimum(minimum: NewSubscriptionMinimumCompositePrice) = + Price(minimum = minimum) + + fun ofPercent(percent: Percent) = Price(percent = percent) + + fun ofEventOutput(eventOutput: EventOutput) = Price(eventOutput = eventOutput) + } + + /** + * An interface that defines how to map each variant of [Price] to a value of type [T]. + */ + interface Visitor { + + fun visitUnit(unit: NewSubscriptionUnitPrice): T + + fun visitTiered(tiered: NewSubscriptionTieredPrice): T + + fun visitBulk(bulk: NewSubscriptionBulkPrice): T + + fun visitBulkWithFilters(bulkWithFilters: BulkWithFilters): T + + fun visitPackage(package_: NewSubscriptionPackagePrice): T + + fun visitMatrix(matrix: NewSubscriptionMatrixPrice): T + + fun visitThresholdTotalAmount( + thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice + ): T + + fun visitTieredPackage(tieredPackage: NewSubscriptionTieredPackagePrice): T + + fun visitTieredWithMinimum( + tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice + ): T + + fun visitGroupedTiered(groupedTiered: NewSubscriptionGroupedTieredPrice): T + + fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice + ): T + + fun visitPackageWithAllocation( + packageWithAllocation: NewSubscriptionPackageWithAllocationPrice + ): T + + fun visitUnitWithPercent(unitWithPercent: NewSubscriptionUnitWithPercentPrice): T + + fun visitMatrixWithAllocation( + matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice + ): T + + fun visitTieredWithProration(tieredWithProration: TieredWithProration): T + + fun visitUnitWithProration( + unitWithProration: NewSubscriptionUnitWithProrationPrice + ): T + + fun visitGroupedAllocation( + groupedAllocation: NewSubscriptionGroupedAllocationPrice + ): T + + fun visitBulkWithProration( + bulkWithProration: NewSubscriptionBulkWithProrationPrice + ): T + + fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: NewSubscriptionGroupedWithProratedMinimumPrice + ): T + + fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice + ): T + + fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ): T + + fun visitMatrixWithDisplayName( + matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice + ): T + + fun visitGroupedTieredPackage( + groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice + ): T + + fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice + ): T + + fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: NewSubscriptionScalableMatrixWithUnitPricingPrice + ): T + + fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: + NewSubscriptionScalableMatrixWithTieredPricingPrice + ): T + + fun visitCumulativeGroupedBulk( + cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice + ): T + + fun visitCumulativeGroupedAllocation( + cumulativeGroupedAllocation: CumulativeGroupedAllocation + ): T + + fun visitMinimum(minimum: NewSubscriptionMinimumCompositePrice): T + + fun visitPercent(percent: Percent): T + + fun visitEventOutput(eventOutput: EventOutput): T + + /** + * Maps an unknown variant of [Price] to a value of type [T]. + * + * An instance of [Price] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is + * unaware of. + * + * @throws OrbInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw OrbInvalidDataException("Unknown Price: $json") + } + } + + internal class Deserializer : BaseDeserializer(Price::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Price { + val json = JsonValue.fromJsonNode(node) + val modelType = json.asObject()?.get("model_type")?.asString() + + when (modelType) { + "unit" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(unit = it, _json = json) } ?: Price(_json = json) + } + "tiered" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(tiered = it, _json = json) } ?: Price(_json = json) + } + "bulk" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(bulk = it, _json = json) } ?: Price(_json = json) + } + "bulk_with_filters" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(bulkWithFilters = it, _json = json) + } ?: Price(_json = json) + } + "package" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(package_ = it, _json = json) } ?: Price(_json = json) + } + "matrix" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(matrix = it, _json = json) } ?: Price(_json = json) + } + "threshold_total_amount" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(thresholdTotalAmount = it, _json = json) } + ?: Price(_json = json) + } + "tiered_package" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(tieredPackage = it, _json = json) } + ?: Price(_json = json) + } + "tiered_with_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(tieredWithMinimum = it, _json = json) } + ?: Price(_json = json) + } + "grouped_tiered" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedTiered = it, _json = json) } + ?: Price(_json = json) + } + "tiered_package_with_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(tieredPackageWithMinimum = it, _json = json) } + ?: Price(_json = json) + } + "package_with_allocation" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(packageWithAllocation = it, _json = json) } + ?: Price(_json = json) + } + "unit_with_percent" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(unitWithPercent = it, _json = json) } + ?: Price(_json = json) + } + "matrix_with_allocation" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(matrixWithAllocation = it, _json = json) } + ?: Price(_json = json) + } + "tiered_with_proration" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(tieredWithProration = it, _json = json) } + ?: Price(_json = json) + } + "unit_with_proration" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(unitWithProration = it, _json = json) } + ?: Price(_json = json) + } + "grouped_allocation" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedAllocation = it, _json = json) } + ?: Price(_json = json) + } + "bulk_with_proration" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(bulkWithProration = it, _json = json) } + ?: Price(_json = json) + } + "grouped_with_prorated_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedWithProratedMinimum = it, _json = json) } + ?: Price(_json = json) + } + "grouped_with_metered_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedWithMeteredMinimum = it, _json = json) } + ?: Price(_json = json) + } + "grouped_with_min_max_thresholds" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedWithMinMaxThresholds = it, _json = json) } + ?: Price(_json = json) + } + "matrix_with_display_name" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(matrixWithDisplayName = it, _json = json) } + ?: Price(_json = json) + } + "grouped_tiered_package" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedTieredPackage = it, _json = json) } + ?: Price(_json = json) + } + "max_group_tiered_package" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(maxGroupTieredPackage = it, _json = json) } + ?: Price(_json = json) + } + "scalable_matrix_with_unit_pricing" -> { + return tryDeserialize( + node, + jacksonTypeRef< + NewSubscriptionScalableMatrixWithUnitPricingPrice + >(), + ) + ?.let { Price(scalableMatrixWithUnitPricing = it, _json = json) } + ?: Price(_json = json) + } + "scalable_matrix_with_tiered_pricing" -> { + return tryDeserialize( + node, + jacksonTypeRef< + NewSubscriptionScalableMatrixWithTieredPricingPrice + >(), + ) + ?.let { Price(scalableMatrixWithTieredPricing = it, _json = json) } + ?: Price(_json = json) + } + "cumulative_grouped_bulk" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(cumulativeGroupedBulk = it, _json = json) } + ?: Price(_json = json) + } + "cumulative_grouped_allocation" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(cumulativeGroupedAllocation = it, _json = json) } + ?: Price(_json = json) + } + "minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(minimum = it, _json = json) } ?: Price(_json = json) + } + "percent" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(percent = it, _json = json) + } ?: Price(_json = json) + } + "event_output" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(eventOutput = it, _json = json) + } ?: Price(_json = json) + } + } + + return Price(_json = json) + } + } + + internal class Serializer : BaseSerializer(Price::class) { + + override fun serialize( + value: Price, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.unit != null -> generator.writeObject(value.unit) + value.tiered != null -> generator.writeObject(value.tiered) + value.bulk != null -> generator.writeObject(value.bulk) + value.bulkWithFilters != null -> + generator.writeObject(value.bulkWithFilters) + value.package_ != null -> generator.writeObject(value.package_) + value.matrix != null -> generator.writeObject(value.matrix) + value.thresholdTotalAmount != null -> + generator.writeObject(value.thresholdTotalAmount) + value.tieredPackage != null -> generator.writeObject(value.tieredPackage) + value.tieredWithMinimum != null -> + generator.writeObject(value.tieredWithMinimum) + value.groupedTiered != null -> generator.writeObject(value.groupedTiered) + value.tieredPackageWithMinimum != null -> + generator.writeObject(value.tieredPackageWithMinimum) + value.packageWithAllocation != null -> + generator.writeObject(value.packageWithAllocation) + value.unitWithPercent != null -> + generator.writeObject(value.unitWithPercent) + value.matrixWithAllocation != null -> + generator.writeObject(value.matrixWithAllocation) + value.tieredWithProration != null -> + generator.writeObject(value.tieredWithProration) + value.unitWithProration != null -> + generator.writeObject(value.unitWithProration) + value.groupedAllocation != null -> + generator.writeObject(value.groupedAllocation) + value.bulkWithProration != null -> + generator.writeObject(value.bulkWithProration) + value.groupedWithProratedMinimum != null -> + generator.writeObject(value.groupedWithProratedMinimum) + value.groupedWithMeteredMinimum != null -> + generator.writeObject(value.groupedWithMeteredMinimum) + value.groupedWithMinMaxThresholds != null -> + generator.writeObject(value.groupedWithMinMaxThresholds) + value.matrixWithDisplayName != null -> + generator.writeObject(value.matrixWithDisplayName) + value.groupedTieredPackage != null -> + generator.writeObject(value.groupedTieredPackage) + value.maxGroupTieredPackage != null -> + generator.writeObject(value.maxGroupTieredPackage) + value.scalableMatrixWithUnitPricing != null -> + generator.writeObject(value.scalableMatrixWithUnitPricing) + value.scalableMatrixWithTieredPricing != null -> + generator.writeObject(value.scalableMatrixWithTieredPricing) + value.cumulativeGroupedBulk != null -> + generator.writeObject(value.cumulativeGroupedBulk) + value.cumulativeGroupedAllocation != null -> + generator.writeObject(value.cumulativeGroupedAllocation) + value.minimum != null -> generator.writeObject(value.minimum) + value.percent != null -> generator.writeObject(value.percent) + value.eventOutput != null -> generator.writeObject(value.eventOutput) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Price") + } + } + } + + class BulkWithFilters + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val bulkWithFiltersConfig: JsonField, + private val cadence: JsonField, + private val itemId: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("bulk_with_filters_config") + @ExcludeMissing + bulkWithFiltersConfig: JsonField = JsonMissing.of(), + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + bulkWithFiltersConfig, + cadence, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * Configuration for bulk_with_filters pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun bulkWithFiltersConfig(): BulkWithFiltersConfig = + bulkWithFiltersConfig.getRequired("bulk_with_filters_config") + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("bulk_with_filters") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = billableMetricId.getNullable("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + invoiceGroupingKey.getNullable("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [bulkWithFiltersConfig]. + * + * Unlike [bulkWithFiltersConfig], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("bulk_with_filters_config") + @ExcludeMissing + fun _bulkWithFiltersConfig(): JsonField = + bulkWithFiltersConfig + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [BulkWithFilters]. + * + * The following fields are required: + * ```kotlin + * .bulkWithFiltersConfig() + * .cadence() + * .itemId() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [BulkWithFilters]. */ + class Builder internal constructor() { + + private var bulkWithFiltersConfig: JsonField? = null + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonValue = JsonValue.from("bulk_with_filters") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(bulkWithFilters: BulkWithFilters) = apply { + bulkWithFiltersConfig = bulkWithFilters.bulkWithFiltersConfig + cadence = bulkWithFilters.cadence + itemId = bulkWithFilters.itemId + modelType = bulkWithFilters.modelType + name = bulkWithFilters.name + billableMetricId = bulkWithFilters.billableMetricId + billedInAdvance = bulkWithFilters.billedInAdvance + billingCycleConfiguration = bulkWithFilters.billingCycleConfiguration + conversionRate = bulkWithFilters.conversionRate + conversionRateConfig = bulkWithFilters.conversionRateConfig + currency = bulkWithFilters.currency + dimensionalPriceConfiguration = + bulkWithFilters.dimensionalPriceConfiguration + externalPriceId = bulkWithFilters.externalPriceId + fixedPriceQuantity = bulkWithFilters.fixedPriceQuantity + invoiceGroupingKey = bulkWithFilters.invoiceGroupingKey + invoicingCycleConfiguration = bulkWithFilters.invoicingCycleConfiguration + metadata = bulkWithFilters.metadata + referenceId = bulkWithFilters.referenceId + additionalProperties = bulkWithFilters.additionalProperties.toMutableMap() + } + + /** Configuration for bulk_with_filters pricing */ + fun bulkWithFiltersConfig(bulkWithFiltersConfig: BulkWithFiltersConfig) = + bulkWithFiltersConfig(JsonField.of(bulkWithFiltersConfig)) + + /** + * Sets [Builder.bulkWithFiltersConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.bulkWithFiltersConfig] with a well-typed + * [BulkWithFiltersConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun bulkWithFiltersConfig( + bulkWithFiltersConfig: JsonField + ) = apply { this.bulkWithFiltersConfig = bulkWithFiltersConfig } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("bulk_with_filters") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BulkWithFilters]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .bulkWithFiltersConfig() + * .cadence() + * .itemId() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BulkWithFilters = + BulkWithFilters( + checkRequired("bulkWithFiltersConfig", bulkWithFiltersConfig), + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): BulkWithFilters = apply { + if (validated) { + return@apply + } + + bulkWithFiltersConfig().validate() + cadence().validate() + itemId() + _modelType().let { + if (it != JsonValue.from("bulk_with_filters")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (bulkWithFiltersConfig.asKnown()?.validity() ?: 0) + + (cadence.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + modelType.let { if (it == JsonValue.from("bulk_with_filters")) 1 else 0 } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** Configuration for bulk_with_filters pricing */ + class BulkWithFiltersConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val filters: JsonField>, + private val tiers: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("filters") + @ExcludeMissing + filters: JsonField> = JsonMissing.of(), + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of(), + ) : this(filters, tiers, mutableMapOf()) + + /** + * Property filters to apply (all must match) + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun filters(): List = filters.getRequired("filters") + + /** + * Bulk tiers for rating based on total usage volume + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun tiers(): List = tiers.getRequired("tiers") + + /** + * Returns the raw JSON value of [filters]. + * + * Unlike [filters], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("filters") + @ExcludeMissing + fun _filters(): JsonField> = filters + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [BulkWithFiltersConfig]. + * + * The following fields are required: + * ```kotlin + * .filters() + * .tiers() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [BulkWithFiltersConfig]. */ + class Builder internal constructor() { + + private var filters: JsonField>? = null + private var tiers: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(bulkWithFiltersConfig: BulkWithFiltersConfig) = apply { + filters = bulkWithFiltersConfig.filters.map { it.toMutableList() } + tiers = bulkWithFiltersConfig.tiers.map { it.toMutableList() } + additionalProperties = + bulkWithFiltersConfig.additionalProperties.toMutableMap() + } + + /** Property filters to apply (all must match) */ + fun filters(filters: List) = filters(JsonField.of(filters)) + + /** + * Sets [Builder.filters] to an arbitrary JSON value. + * + * You should usually call [Builder.filters] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun filters(filters: JsonField>) = apply { + this.filters = filters.map { it.toMutableList() } + } + + /** + * Adds a single [Filter] to [filters]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addFilter(filter: Filter) = apply { + filters = + (filters ?: JsonField.of(mutableListOf())).also { + checkKnown("filters", it).add(filter) + } + } + + /** Bulk tiers for rating based on total usage volume */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BulkWithFiltersConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .filters() + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BulkWithFiltersConfig = + BulkWithFiltersConfig( + checkRequired("filters", filters).map { it.toImmutable() }, + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): BulkWithFiltersConfig = apply { + if (validated) { + return@apply + } + + filters().forEach { it.validate() } + tiers().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (filters.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + (tiers.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single property filter */ + class Filter + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val propertyKey: JsonField, + private val propertyValue: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("property_key") + @ExcludeMissing + propertyKey: JsonField = JsonMissing.of(), + @JsonProperty("property_value") + @ExcludeMissing + propertyValue: JsonField = JsonMissing.of(), + ) : this(propertyKey, propertyValue, mutableMapOf()) + + /** + * Event property key to filter on + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun propertyKey(): String = propertyKey.getRequired("property_key") + + /** + * Event property value to match + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun propertyValue(): String = propertyValue.getRequired("property_value") + + /** + * Returns the raw JSON value of [propertyKey]. + * + * Unlike [propertyKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("property_key") + @ExcludeMissing + fun _propertyKey(): JsonField = propertyKey + + /** + * Returns the raw JSON value of [propertyValue]. + * + * Unlike [propertyValue], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("property_value") + @ExcludeMissing + fun _propertyValue(): JsonField = propertyValue + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Filter]. + * + * The following fields are required: + * ```kotlin + * .propertyKey() + * .propertyValue() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Filter]. */ + class Builder internal constructor() { + + private var propertyKey: JsonField? = null + private var propertyValue: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(filter: Filter) = apply { + propertyKey = filter.propertyKey + propertyValue = filter.propertyValue + additionalProperties = filter.additionalProperties.toMutableMap() + } + + /** Event property key to filter on */ + fun propertyKey(propertyKey: String) = + propertyKey(JsonField.of(propertyKey)) + + /** + * Sets [Builder.propertyKey] to an arbitrary JSON value. + * + * You should usually call [Builder.propertyKey] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun propertyKey(propertyKey: JsonField) = apply { + this.propertyKey = propertyKey + } + + /** Event property value to match */ + fun propertyValue(propertyValue: String) = + propertyValue(JsonField.of(propertyValue)) + + /** + * Sets [Builder.propertyValue] to an arbitrary JSON value. + * + * You should usually call [Builder.propertyValue] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun propertyValue(propertyValue: JsonField) = apply { + this.propertyValue = propertyValue + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Filter]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```kotlin + * .propertyKey() + * .propertyValue() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Filter = + Filter( + checkRequired("propertyKey", propertyKey), + checkRequired("propertyValue", propertyValue), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Filter = apply { + if (validated) { + return@apply + } + + propertyKey() + propertyValue() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (propertyKey.asKnown() == null) 0 else 1) + + (if (propertyValue.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Filter && + propertyKey == other.propertyKey && + propertyValue == other.propertyValue && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(propertyKey, propertyValue, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Filter{propertyKey=$propertyKey, propertyValue=$propertyValue, additionalProperties=$additionalProperties}" + } + + /** Configuration for a single bulk pricing tier */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val unitAmount: JsonField, + private val tierLowerBound: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + ) : this(unitAmount, tierLowerBound, mutableMapOf()) + + /** + * Amount per unit + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * The lower bound for this tier + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun tierLowerBound(): String? = + tierLowerBound.getNullable("tier_lower_bound") + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Tier]. + * + * The following fields are required: + * ```kotlin + * .unitAmount() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var unitAmount: JsonField? = null + private var tierLowerBound: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(tier: Tier) = apply { + unitAmount = tier.unitAmount + tierLowerBound = tier.tierLowerBound + additionalProperties = tier.additionalProperties.toMutableMap() + } + + /** Amount per unit */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + /** The lower bound for this tier */ + fun tierLowerBound(tierLowerBound: String?) = + tierLowerBound(JsonField.ofNullable(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```kotlin + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("unitAmount", unitAmount), + tierLowerBound, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + unitAmount() + tierLowerBound() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (unitAmount.asKnown() == null) 0 else 1) + + (if (tierLowerBound.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + unitAmount == other.unitAmount && + tierLowerBound == other.tierLowerBound && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(unitAmount, tierLowerBound, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{unitAmount=$unitAmount, tierLowerBound=$tierLowerBound, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BulkWithFiltersConfig && + filters == other.filters && + tiers == other.tiers && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(filters, tiers, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BulkWithFiltersConfig{filters=$filters, tiers=$tiers, additionalProperties=$additionalProperties}" + } + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN } - "grouped_with_prorated_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedWithProratedMinimum = it, _json = json) } - ?: Price(_json = json) + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") } - "grouped_with_metered_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedWithMeteredMinimum = it, _json = json) } - ?: Price(_json = json) + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply } - "grouped_with_min_max_thresholds" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedWithMinMaxThresholds = it, _json = json) } - ?: Price(_json = json) + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false } - "matrix_with_display_name" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(matrixWithDisplayName = it, _json = json) } - ?: Price(_json = json) + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - "grouped_tiered_package" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedTieredPackage = it, _json = json) } - ?: Price(_json = json) + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() } - "max_group_tiered_package" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(maxGroupTieredPackage = it, _json = json) } - ?: Price(_json = json) + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) } - "scalable_matrix_with_unit_pricing" -> { - return tryDeserialize( - node, - jacksonTypeRef< - NewSubscriptionScalableMatrixWithUnitPricingPrice - >(), - ) - ?.let { Price(scalableMatrixWithUnitPricing = it, _json = json) } - ?: Price(_json = json) + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) } - "scalable_matrix_with_tiered_pricing" -> { - return tryDeserialize( - node, - jacksonTypeRef< - NewSubscriptionScalableMatrixWithTieredPricingPrice - >(), - ) - ?.let { Price(scalableMatrixWithTieredPricing = it, _json = json) } - ?: Price(_json = json) + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) } - "cumulative_grouped_bulk" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(cumulativeGroupedBulk = it, _json = json) } - ?: Price(_json = json) + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply } - "minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(minimum = it, _json = json) } ?: Price(_json = json) + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false } - "percent" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(percent = it, _json = json) - } ?: Price(_json = json) + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() } - "event_output" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(eventOutput = it, _json = json) - } ?: Price(_json = json) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - return Price(_json = json) + return other is BulkWithFilters && + bulkWithFiltersConfig == other.bulkWithFiltersConfig && + cadence == other.cadence && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties } - } - - internal class Serializer : BaseSerializer(Price::class) { - override fun serialize( - value: Price, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unit != null -> generator.writeObject(value.unit) - value.tiered != null -> generator.writeObject(value.tiered) - value.bulk != null -> generator.writeObject(value.bulk) - value.bulkWithFilters != null -> - generator.writeObject(value.bulkWithFilters) - value.package_ != null -> generator.writeObject(value.package_) - value.matrix != null -> generator.writeObject(value.matrix) - value.thresholdTotalAmount != null -> - generator.writeObject(value.thresholdTotalAmount) - value.tieredPackage != null -> generator.writeObject(value.tieredPackage) - value.tieredWithMinimum != null -> - generator.writeObject(value.tieredWithMinimum) - value.groupedTiered != null -> generator.writeObject(value.groupedTiered) - value.tieredPackageWithMinimum != null -> - generator.writeObject(value.tieredPackageWithMinimum) - value.packageWithAllocation != null -> - generator.writeObject(value.packageWithAllocation) - value.unitWithPercent != null -> - generator.writeObject(value.unitWithPercent) - value.matrixWithAllocation != null -> - generator.writeObject(value.matrixWithAllocation) - value.tieredWithProration != null -> - generator.writeObject(value.tieredWithProration) - value.unitWithProration != null -> - generator.writeObject(value.unitWithProration) - value.groupedAllocation != null -> - generator.writeObject(value.groupedAllocation) - value.bulkWithProration != null -> - generator.writeObject(value.bulkWithProration) - value.groupedWithProratedMinimum != null -> - generator.writeObject(value.groupedWithProratedMinimum) - value.groupedWithMeteredMinimum != null -> - generator.writeObject(value.groupedWithMeteredMinimum) - value.groupedWithMinMaxThresholds != null -> - generator.writeObject(value.groupedWithMinMaxThresholds) - value.matrixWithDisplayName != null -> - generator.writeObject(value.matrixWithDisplayName) - value.groupedTieredPackage != null -> - generator.writeObject(value.groupedTieredPackage) - value.maxGroupTieredPackage != null -> - generator.writeObject(value.maxGroupTieredPackage) - value.scalableMatrixWithUnitPricing != null -> - generator.writeObject(value.scalableMatrixWithUnitPricing) - value.scalableMatrixWithTieredPricing != null -> - generator.writeObject(value.scalableMatrixWithTieredPricing) - value.cumulativeGroupedBulk != null -> - generator.writeObject(value.cumulativeGroupedBulk) - value.minimum != null -> generator.writeObject(value.minimum) - value.percent != null -> generator.writeObject(value.percent) - value.eventOutput != null -> generator.writeObject(value.eventOutput) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Price") - } + private val hashCode: Int by lazy { + Objects.hash( + bulkWithFiltersConfig, + cadence, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties, + ) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BulkWithFilters{bulkWithFiltersConfig=$bulkWithFiltersConfig, cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class BulkWithFilters + class TieredWithProration @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val bulkWithFiltersConfig: JsonField, private val cadence: JsonField, private val itemId: JsonField, private val modelType: JsonValue, private val name: JsonField, + private val tieredWithProrationConfig: JsonField, private val billableMetricId: JsonField, private val billedInAdvance: JsonField, private val billingCycleConfiguration: JsonField, @@ -17444,9 +21284,6 @@ private constructor( @JsonCreator private constructor( - @JsonProperty("bulk_with_filters_config") - @ExcludeMissing - bulkWithFiltersConfig: JsonField = JsonMissing.of(), @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), @@ -17459,6 +21296,10 @@ private constructor( @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("tiered_with_proration_config") + @ExcludeMissing + tieredWithProrationConfig: JsonField = + JsonMissing.of(), @JsonProperty("billable_metric_id") @ExcludeMissing billableMetricId: JsonField = JsonMissing.of(), @@ -17502,11 +21343,11 @@ private constructor( @ExcludeMissing referenceId: JsonField = JsonMissing.of(), ) : this( - bulkWithFiltersConfig, cadence, itemId, modelType, name, + tieredWithProrationConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -17523,16 +21364,6 @@ private constructor( mutableMapOf(), ) - /** - * Configuration for bulk_with_filters pricing - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun bulkWithFiltersConfig(): BulkWithFiltersConfig = - bulkWithFiltersConfig.getRequired("bulk_with_filters_config") - /** * The cadence to bill for this price on. * @@ -17556,7 +21387,7 @@ private constructor( * * Expected to always return the following: * ```kotlin - * JsonValue.from("bulk_with_filters") + * JsonValue.from("tiered_with_proration") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -17573,6 +21404,16 @@ private constructor( */ fun name(): String = name.getRequired("name") + /** + * Configuration for tiered_with_proration pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun tieredWithProrationConfig(): TieredWithProrationConfig = + tieredWithProrationConfig.getRequired("tiered_with_proration_config") + /** * The id of the billable metric for the price. Only needed if the price is * usage-based. @@ -17692,17 +21533,6 @@ private constructor( */ fun referenceId(): String? = referenceId.getNullable("reference_id") - /** - * Returns the raw JSON value of [bulkWithFiltersConfig]. - * - * Unlike [bulkWithFiltersConfig], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("bulk_with_filters_config") - @ExcludeMissing - fun _bulkWithFiltersConfig(): JsonField = - bulkWithFiltersConfig - /** * Returns the raw JSON value of [cadence]. * @@ -17729,6 +21559,17 @@ private constructor( */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + /** + * Returns the raw JSON value of [tieredWithProrationConfig]. + * + * Unlike [tieredWithProrationConfig], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("tiered_with_proration_config") + @ExcludeMissing + fun _tieredWithProrationConfig(): JsonField = + tieredWithProrationConfig + /** * Returns the raw JSON value of [billableMetricId]. * @@ -17877,27 +21718,29 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [BulkWithFilters]. + * Returns a mutable builder for constructing an instance of + * [TieredWithProration]. * * The following fields are required: * ```kotlin - * .bulkWithFiltersConfig() * .cadence() * .itemId() * .name() + * .tieredWithProrationConfig() * ``` */ fun builder() = Builder() } - /** A builder for [BulkWithFilters]. */ + /** A builder for [TieredWithProration]. */ class Builder internal constructor() { - private var bulkWithFiltersConfig: JsonField? = null private var cadence: JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonValue = JsonValue.from("bulk_with_filters") + private var modelType: JsonValue = JsonValue.from("tiered_with_proration") private var name: JsonField? = null + private var tieredWithProrationConfig: JsonField? = + null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() private var billingCycleConfiguration: JsonField = @@ -17919,44 +21762,31 @@ private constructor( private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(bulkWithFilters: BulkWithFilters) = apply { - bulkWithFiltersConfig = bulkWithFilters.bulkWithFiltersConfig - cadence = bulkWithFilters.cadence - itemId = bulkWithFilters.itemId - modelType = bulkWithFilters.modelType - name = bulkWithFilters.name - billableMetricId = bulkWithFilters.billableMetricId - billedInAdvance = bulkWithFilters.billedInAdvance - billingCycleConfiguration = bulkWithFilters.billingCycleConfiguration - conversionRate = bulkWithFilters.conversionRate - conversionRateConfig = bulkWithFilters.conversionRateConfig - currency = bulkWithFilters.currency + internal fun from(tieredWithProration: TieredWithProration) = apply { + cadence = tieredWithProration.cadence + itemId = tieredWithProration.itemId + modelType = tieredWithProration.modelType + name = tieredWithProration.name + tieredWithProrationConfig = tieredWithProration.tieredWithProrationConfig + billableMetricId = tieredWithProration.billableMetricId + billedInAdvance = tieredWithProration.billedInAdvance + billingCycleConfiguration = tieredWithProration.billingCycleConfiguration + conversionRate = tieredWithProration.conversionRate + conversionRateConfig = tieredWithProration.conversionRateConfig + currency = tieredWithProration.currency dimensionalPriceConfiguration = - bulkWithFilters.dimensionalPriceConfiguration - externalPriceId = bulkWithFilters.externalPriceId - fixedPriceQuantity = bulkWithFilters.fixedPriceQuantity - invoiceGroupingKey = bulkWithFilters.invoiceGroupingKey - invoicingCycleConfiguration = bulkWithFilters.invoicingCycleConfiguration - metadata = bulkWithFilters.metadata - referenceId = bulkWithFilters.referenceId - additionalProperties = bulkWithFilters.additionalProperties.toMutableMap() + tieredWithProration.dimensionalPriceConfiguration + externalPriceId = tieredWithProration.externalPriceId + fixedPriceQuantity = tieredWithProration.fixedPriceQuantity + invoiceGroupingKey = tieredWithProration.invoiceGroupingKey + invoicingCycleConfiguration = + tieredWithProration.invoicingCycleConfiguration + metadata = tieredWithProration.metadata + referenceId = tieredWithProration.referenceId + additionalProperties = + tieredWithProration.additionalProperties.toMutableMap() } - /** Configuration for bulk_with_filters pricing */ - fun bulkWithFiltersConfig(bulkWithFiltersConfig: BulkWithFiltersConfig) = - bulkWithFiltersConfig(JsonField.of(bulkWithFiltersConfig)) - - /** - * Sets [Builder.bulkWithFiltersConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.bulkWithFiltersConfig] with a well-typed - * [BulkWithFiltersConfig] value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun bulkWithFiltersConfig( - bulkWithFiltersConfig: JsonField - ) = apply { this.bulkWithFiltersConfig = bulkWithFiltersConfig } - /** The cadence to bill for this price on. */ fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) @@ -17987,7 +21817,7 @@ private constructor( * It is usually unnecessary to call this method because the field defaults to * the following: * ```kotlin - * JsonValue.from("bulk_with_filters") + * JsonValue.from("tiered_with_proration") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -18001,11 +21831,27 @@ private constructor( /** * Sets [Builder.name] to an arbitrary JSON value. * - * You should usually call [Builder.name] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for tiered_with_proration pricing */ + fun tieredWithProrationConfig( + tieredWithProrationConfig: TieredWithProrationConfig + ) = tieredWithProrationConfig(JsonField.of(tieredWithProrationConfig)) + + /** + * Sets [Builder.tieredWithProrationConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.tieredWithProrationConfig] with a well-typed + * [TieredWithProrationConfig] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. */ - fun name(name: JsonField) = apply { this.name = name } + fun tieredWithProrationConfig( + tieredWithProrationConfig: JsonField + ) = apply { this.tieredWithProrationConfig = tieredWithProrationConfig } /** * The id of the billable metric for the price. Only needed if the price is @@ -18336,27 +22182,27 @@ private constructor( } /** - * Returns an immutable instance of [BulkWithFilters]. + * Returns an immutable instance of [TieredWithProration]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```kotlin - * .bulkWithFiltersConfig() * .cadence() * .itemId() * .name() + * .tieredWithProrationConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): BulkWithFilters = - BulkWithFilters( - checkRequired("bulkWithFiltersConfig", bulkWithFiltersConfig), + fun build(): TieredWithProration = + TieredWithProration( checkRequired("cadence", cadence), checkRequired("itemId", itemId), modelType, checkRequired("name", name), + checkRequired("tieredWithProrationConfig", tieredWithProrationConfig), billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -18376,20 +22222,20 @@ private constructor( private var validated: Boolean = false - fun validate(): BulkWithFilters = apply { + fun validate(): TieredWithProration = apply { if (validated) { return@apply } - bulkWithFiltersConfig().validate() cadence().validate() itemId() _modelType().let { - if (it != JsonValue.from("bulk_with_filters")) { + if (it != JsonValue.from("tiered_with_proration")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } name() + tieredWithProrationConfig().validate() billableMetricId() billedInAdvance() billingCycleConfiguration()?.validate() @@ -18421,11 +22267,13 @@ private constructor( * Used for best match union deserialization. */ internal fun validity(): Int = - (bulkWithFiltersConfig.asKnown()?.validity() ?: 0) + - (cadence.asKnown()?.validity() ?: 0) + + (cadence.asKnown()?.validity() ?: 0) + (if (itemId.asKnown() == null) 0 else 1) + - modelType.let { if (it == JsonValue.from("bulk_with_filters")) 1 else 0 } + + modelType.let { + if (it == JsonValue.from("tiered_with_proration")) 1 else 0 + } + (if (name.asKnown() == null) 0 else 1) + + (tieredWithProrationConfig.asKnown()?.validity() ?: 0) + (if (billableMetricId.asKnown() == null) 0 else 1) + (if (billedInAdvance.asKnown() == null) 0 else 1) + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + @@ -18440,36 +22288,181 @@ private constructor( (metadata.asKnown()?.validity() ?: 0) + (if (referenceId.asKnown() == null) 0 else 1) - /** Configuration for bulk_with_filters pricing */ - class BulkWithFiltersConfig + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Configuration for tiered_with_proration pricing */ + class TieredWithProrationConfig @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val filters: JsonField>, private val tiers: JsonField>, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("filters") - @ExcludeMissing - filters: JsonField> = JsonMissing.of(), @JsonProperty("tiers") @ExcludeMissing - tiers: JsonField> = JsonMissing.of(), - ) : this(filters, tiers, mutableMapOf()) - - /** - * Property filters to apply (all must match) - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun filters(): List = filters.getRequired("filters") + tiers: JsonField> = JsonMissing.of() + ) : this(tiers, mutableMapOf()) /** - * Bulk tiers for rating based on total usage volume + * Tiers for rating based on total usage quantities into the specified tier with + * proration * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an @@ -18477,16 +22470,6 @@ private constructor( */ fun tiers(): List = tiers.getRequired("tiers") - /** - * Returns the raw JSON value of [filters]. - * - * Unlike [filters], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("filters") - @ExcludeMissing - fun _filters(): JsonField> = filters - /** * Returns the raw JSON value of [tiers]. * @@ -18513,60 +22496,34 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [BulkWithFiltersConfig]. + * [TieredWithProrationConfig]. * * The following fields are required: * ```kotlin - * .filters() * .tiers() * ``` */ fun builder() = Builder() } - /** A builder for [BulkWithFiltersConfig]. */ + /** A builder for [TieredWithProrationConfig]. */ class Builder internal constructor() { - private var filters: JsonField>? = null private var tiers: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(bulkWithFiltersConfig: BulkWithFiltersConfig) = apply { - filters = bulkWithFiltersConfig.filters.map { it.toMutableList() } - tiers = bulkWithFiltersConfig.tiers.map { it.toMutableList() } - additionalProperties = - bulkWithFiltersConfig.additionalProperties.toMutableMap() - } - - /** Property filters to apply (all must match) */ - fun filters(filters: List) = filters(JsonField.of(filters)) - - /** - * Sets [Builder.filters] to an arbitrary JSON value. - * - * You should usually call [Builder.filters] with a well-typed - * `List` value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun filters(filters: JsonField>) = apply { - this.filters = filters.map { it.toMutableList() } - } + internal fun from(tieredWithProrationConfig: TieredWithProrationConfig) = + apply { + tiers = tieredWithProrationConfig.tiers.map { it.toMutableList() } + additionalProperties = + tieredWithProrationConfig.additionalProperties.toMutableMap() + } /** - * Adds a single [Filter] to [filters]. - * - * @throws IllegalStateException if the field was previously set to a - * non-list. + * Tiers for rating based on total usage quantities into the specified tier + * with proration */ - fun addFilter(filter: Filter) = apply { - filters = - (filters ?: JsonField.of(mutableListOf())).also { - checkKnown("filters", it).add(filter) - } - } - - /** Bulk tiers for rating based on total usage volume */ fun tiers(tiers: List) = tiers(JsonField.of(tiers)) /** @@ -18616,21 +22573,19 @@ private constructor( } /** - * Returns an immutable instance of [BulkWithFiltersConfig]. + * Returns an immutable instance of [TieredWithProrationConfig]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```kotlin - * .filters() * .tiers() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): BulkWithFiltersConfig = - BulkWithFiltersConfig( - checkRequired("filters", filters).map { it.toImmutable() }, + fun build(): TieredWithProrationConfig = + TieredWithProrationConfig( checkRequired("tiers", tiers).map { it.toImmutable() }, additionalProperties.toMutableMap(), ) @@ -18638,12 +22593,11 @@ private constructor( private var validated: Boolean = false - fun validate(): BulkWithFiltersConfig = apply { + fun validate(): TieredWithProrationConfig = apply { if (validated) { return@apply } - filters().forEach { it.validate() } tiers().forEach { it.validate() } validated = true } @@ -18658,254 +22612,41 @@ private constructor( /** * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (filters.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + - (tiers.asKnown()?.sumOf { it.validity().toInt() } ?: 0) - - /** Configuration for a single property filter */ - class Filter - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val propertyKey: JsonField, - private val propertyValue: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("property_key") - @ExcludeMissing - propertyKey: JsonField = JsonMissing.of(), - @JsonProperty("property_value") - @ExcludeMissing - propertyValue: JsonField = JsonMissing.of(), - ) : this(propertyKey, propertyValue, mutableMapOf()) - - /** - * Event property key to filter on - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type - * or is unexpectedly missing or null (e.g. if the server responded with - * an unexpected value). - */ - fun propertyKey(): String = propertyKey.getRequired("property_key") - - /** - * Event property value to match - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type - * or is unexpectedly missing or null (e.g. if the server responded with - * an unexpected value). - */ - fun propertyValue(): String = propertyValue.getRequired("property_value") - - /** - * Returns the raw JSON value of [propertyKey]. - * - * Unlike [propertyKey], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("property_key") - @ExcludeMissing - fun _propertyKey(): JsonField = propertyKey - - /** - * Returns the raw JSON value of [propertyValue]. - * - * Unlike [propertyValue], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("property_value") - @ExcludeMissing - fun _propertyValue(): JsonField = propertyValue - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [Filter]. - * - * The following fields are required: - * ```kotlin - * .propertyKey() - * .propertyValue() - * ``` - */ - fun builder() = Builder() - } - - /** A builder for [Filter]. */ - class Builder internal constructor() { - - private var propertyKey: JsonField? = null - private var propertyValue: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - internal fun from(filter: Filter) = apply { - propertyKey = filter.propertyKey - propertyValue = filter.propertyValue - additionalProperties = filter.additionalProperties.toMutableMap() - } - - /** Event property key to filter on */ - fun propertyKey(propertyKey: String) = - propertyKey(JsonField.of(propertyKey)) - - /** - * Sets [Builder.propertyKey] to an arbitrary JSON value. - * - * You should usually call [Builder.propertyKey] with a well-typed - * [String] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun propertyKey(propertyKey: JsonField) = apply { - this.propertyKey = propertyKey - } - - /** Event property value to match */ - fun propertyValue(propertyValue: String) = - propertyValue(JsonField.of(propertyValue)) - - /** - * Sets [Builder.propertyValue] to an arbitrary JSON value. - * - * You should usually call [Builder.propertyValue] with a well-typed - * [String] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun propertyValue(propertyValue: JsonField) = apply { - this.propertyValue = propertyValue - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Filter]. - * - * Further updates to this [Builder] will not mutate the returned - * instance. - * - * The following fields are required: - * ```kotlin - * .propertyKey() - * .propertyValue() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Filter = - Filter( - checkRequired("propertyKey", propertyKey), - checkRequired("propertyValue", propertyValue), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Filter = apply { - if (validated) { - return@apply - } - - propertyKey() - propertyValue() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this - * object recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (if (propertyKey.asKnown() == null) 0 else 1) + - (if (propertyValue.asKnown() == null) 0 else 1) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Filter && - propertyKey == other.propertyKey && - propertyValue == other.propertyValue && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(propertyKey, propertyValue, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Filter{propertyKey=$propertyKey, propertyValue=$propertyValue, additionalProperties=$additionalProperties}" - } + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (tiers.asKnown()?.sumOf { it.validity().toInt() } ?: 0) - /** Configuration for a single bulk pricing tier */ + /** Configuration for a single tiered with proration tier */ class Tier @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val unitAmount: JsonField, private val tierLowerBound: JsonField, + private val unitAmount: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("unit_amount") - @ExcludeMissing - unitAmount: JsonField = JsonMissing.of(), @JsonProperty("tier_lower_bound") @ExcludeMissing tierLowerBound: JsonField = JsonMissing.of(), - ) : this(unitAmount, tierLowerBound, mutableMapOf()) + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(tierLowerBound, unitAmount, mutableMapOf()) + + /** + * Inclusive tier starting value + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun tierLowerBound(): String = + tierLowerBound.getRequired("tier_lower_bound") /** * Amount per unit @@ -18917,13 +22658,14 @@ private constructor( fun unitAmount(): String = unitAmount.getRequired("unit_amount") /** - * The lower bound for this tier + * Returns the raw JSON value of [tierLowerBound]. * - * @throws OrbInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. */ - fun tierLowerBound(): String? = - tierLowerBound.getNullable("tier_lower_bound") + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound /** * Returns the raw JSON value of [unitAmount]. @@ -18935,16 +22677,6 @@ private constructor( @ExcludeMissing fun _unitAmount(): JsonField = unitAmount - /** - * Returns the raw JSON value of [tierLowerBound]. - * - * Unlike [tierLowerBound], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("tier_lower_bound") - @ExcludeMissing - fun _tierLowerBound(): JsonField = tierLowerBound - @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -18964,6 +22696,7 @@ private constructor( * * The following fields are required: * ```kotlin + * .tierLowerBound() * .unitAmount() * ``` */ @@ -18973,45 +22706,45 @@ private constructor( /** A builder for [Tier]. */ class Builder internal constructor() { + private var tierLowerBound: JsonField? = null private var unitAmount: JsonField? = null - private var tierLowerBound: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() internal fun from(tier: Tier) = apply { - unitAmount = tier.unitAmount tierLowerBound = tier.tierLowerBound + unitAmount = tier.unitAmount additionalProperties = tier.additionalProperties.toMutableMap() } - /** Amount per unit */ - fun unitAmount(unitAmount: String) = - unitAmount(JsonField.of(unitAmount)) + /** Inclusive tier starting value */ + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) /** - * Sets [Builder.unitAmount] to an arbitrary JSON value. + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. * - * You should usually call [Builder.unitAmount] with a well-typed + * You should usually call [Builder.tierLowerBound] with a well-typed * [String] value instead. This method is primarily for setting the * field to an undocumented or not yet supported value. */ - fun unitAmount(unitAmount: JsonField) = apply { - this.unitAmount = unitAmount + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound } - /** The lower bound for this tier */ - fun tierLowerBound(tierLowerBound: String?) = - tierLowerBound(JsonField.ofNullable(tierLowerBound)) + /** Amount per unit */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) /** - * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * Sets [Builder.unitAmount] to an arbitrary JSON value. * - * You should usually call [Builder.tierLowerBound] with a well-typed + * You should usually call [Builder.unitAmount] with a well-typed * [String] value instead. This method is primarily for setting the * field to an undocumented or not yet supported value. */ - fun tierLowerBound(tierLowerBound: JsonField) = apply { - this.tierLowerBound = tierLowerBound + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount } fun additionalProperties(additionalProperties: Map) = @@ -19037,253 +22770,94 @@ private constructor( } /** - * Returns an immutable instance of [Tier]. - * - * Further updates to this [Builder] will not mutate the returned - * instance. - * - * The following fields are required: - * ```kotlin - * .unitAmount() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Tier = - Tier( - checkRequired("unitAmount", unitAmount), - tierLowerBound, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Tier = apply { - if (validated) { - return@apply - } - - unitAmount() - tierLowerBound() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this - * object recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (if (unitAmount.asKnown() == null) 0 else 1) + - (if (tierLowerBound.asKnown() == null) 0 else 1) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Tier && - unitAmount == other.unitAmount && - tierLowerBound == other.tierLowerBound && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(unitAmount, tierLowerBound, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Tier{unitAmount=$unitAmount, tierLowerBound=$tierLowerBound, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is BulkWithFiltersConfig && - filters == other.filters && - tiers == other.tiers && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(filters, tiers, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BulkWithFiltersConfig{filters=$filters, tiers=$tiers, additionalProperties=$additionalProperties}" - } - - /** The cadence to bill for this price on. */ - class Cadence - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - val ANNUAL = of("annual") - - val SEMI_ANNUAL = of("semi_annual") - - val MONTHLY = of("monthly") - - val QUARTERLY = of("quarterly") - - val ONE_TIME = of("one_time") - - val CUSTOM = of("custom") - - fun of(value: String) = Cadence(JsonField.of(value)) - } - - /** An enum containing [Cadence]'s known values. */ - enum class Known { - ANNUAL, - SEMI_ANNUAL, - MONTHLY, - QUARTERLY, - ONE_TIME, - CUSTOM, - } - - /** - * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Cadence] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - ANNUAL, - SEMI_ANNUAL, - MONTHLY, - QUARTERLY, - ONE_TIME, - CUSTOM, - /** - * An enum member indicating that [Cadence] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - ANNUAL -> Value.ANNUAL - SEMI_ANNUAL -> Value.SEMI_ANNUAL - MONTHLY -> Value.MONTHLY - QUARTERLY -> Value.QUARTERLY - ONE_TIME -> Value.ONE_TIME - CUSTOM -> Value.CUSTOM - else -> Value._UNKNOWN + * Returns an immutable instance of [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```kotlin + * .tierLowerBound() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("tierLowerBound", tierLowerBound), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) } - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - ANNUAL -> Known.ANNUAL - SEMI_ANNUAL -> Known.SEMI_ANNUAL - MONTHLY -> Known.MONTHLY - QUARTERLY -> Known.QUARTERLY - ONE_TIME -> Known.ONE_TIME - CUSTOM -> Known.CUSTOM - else -> throw OrbInvalidDataException("Unknown Cadence: $value") + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + tierLowerBound() + unitAmount() + validated = true } - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString() - ?: throw OrbInvalidDataException("Value is not a String") + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - private var validated: Boolean = false + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (tierLowerBound.asKnown() == null) 0 else 1) + + (if (unitAmount.asKnown() == null) 0 else 1) - fun validate(): Cadence = apply { - if (validated) { - return@apply - } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - known() - validated = true - } + return other is Tier && + tierLowerBound == other.tierLowerBound && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false + private val hashCode: Int by lazy { + Objects.hash(tierLowerBound, unitAmount, additionalProperties) } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is Cadence && value == other.value + return other is TieredWithProrationConfig && + tiers == other.tiers && + additionalProperties == other.additionalProperties } - override fun hashCode() = value.hashCode() + private val hashCode: Int by lazy { Objects.hash(tiers, additionalProperties) } - override fun toString() = value.toString() + override fun hashCode(): Int = hashCode + + override fun toString() = + "TieredWithProrationConfig{tiers=$tiers, additionalProperties=$additionalProperties}" } /** @@ -19400,12 +22974,12 @@ private constructor( return true } - return other is BulkWithFilters && - bulkWithFiltersConfig == other.bulkWithFiltersConfig && + return other is TieredWithProration && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && + tieredWithProrationConfig == other.tieredWithProrationConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && @@ -19424,11 +22998,11 @@ private constructor( private val hashCode: Int by lazy { Objects.hash( - bulkWithFiltersConfig, cadence, itemId, modelType, name, + tieredWithProrationConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -19449,17 +23023,18 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "BulkWithFilters{bulkWithFiltersConfig=$bulkWithFiltersConfig, cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "TieredWithProration{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredWithProrationConfig=$tieredWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class TieredWithProration + class GroupedWithMinMaxThresholds @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, + private val groupedWithMinMaxThresholdsConfig: + JsonField, private val itemId: JsonField, private val modelType: JsonValue, private val name: JsonField, - private val tieredWithProrationConfig: JsonField, private val billableMetricId: JsonField, private val billedInAdvance: JsonField, private val billingCycleConfiguration: JsonField, @@ -19482,6 +23057,11 @@ private constructor( @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), + @JsonProperty("grouped_with_min_max_thresholds_config") + @ExcludeMissing + groupedWithMinMaxThresholdsConfig: + JsonField = + JsonMissing.of(), @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), @@ -19491,10 +23071,6 @@ private constructor( @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("tiered_with_proration_config") - @ExcludeMissing - tieredWithProrationConfig: JsonField = - JsonMissing.of(), @JsonProperty("billable_metric_id") @ExcludeMissing billableMetricId: JsonField = JsonMissing.of(), @@ -19539,10 +23115,10 @@ private constructor( referenceId: JsonField = JsonMissing.of(), ) : this( cadence, + groupedWithMinMaxThresholdsConfig, itemId, modelType, name, - tieredWithProrationConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -19568,6 +23144,18 @@ private constructor( */ fun cadence(): Cadence = cadence.getRequired("cadence") + /** + * Configuration for grouped_with_min_max_thresholds pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupedWithMinMaxThresholdsConfig(): GroupedWithMinMaxThresholdsConfig = + groupedWithMinMaxThresholdsConfig.getRequired( + "grouped_with_min_max_thresholds_config" + ) + /** * The id of the item the price will be associated with. * @@ -19582,7 +23170,7 @@ private constructor( * * Expected to always return the following: * ```kotlin - * JsonValue.from("tiered_with_proration") + * JsonValue.from("grouped_with_min_max_thresholds") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -19599,16 +23187,6 @@ private constructor( */ fun name(): String = name.getRequired("name") - /** - * Configuration for tiered_with_proration pricing - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun tieredWithProrationConfig(): TieredWithProrationConfig = - tieredWithProrationConfig.getRequired("tiered_with_proration_config") - /** * The id of the billable metric for the price. Only needed if the price is * usage-based. @@ -19738,6 +23316,17 @@ private constructor( @ExcludeMissing fun _cadence(): JsonField = cadence + /** + * Returns the raw JSON value of [groupedWithMinMaxThresholdsConfig]. + * + * Unlike [groupedWithMinMaxThresholdsConfig], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("grouped_with_min_max_thresholds_config") + @ExcludeMissing + fun _groupedWithMinMaxThresholdsConfig(): + JsonField = groupedWithMinMaxThresholdsConfig + /** * Returns the raw JSON value of [itemId]. * @@ -19754,17 +23343,6 @@ private constructor( */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - /** - * Returns the raw JSON value of [tieredWithProrationConfig]. - * - * Unlike [tieredWithProrationConfig], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("tiered_with_proration_config") - @ExcludeMissing - fun _tieredWithProrationConfig(): JsonField = - tieredWithProrationConfig - /** * Returns the raw JSON value of [billableMetricId]. * @@ -19914,28 +23492,30 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [TieredWithProration]. + * [GroupedWithMinMaxThresholds]. * * The following fields are required: * ```kotlin * .cadence() + * .groupedWithMinMaxThresholdsConfig() * .itemId() * .name() - * .tieredWithProrationConfig() * ``` */ fun builder() = Builder() } - /** A builder for [TieredWithProration]. */ + /** A builder for [GroupedWithMinMaxThresholds]. */ class Builder internal constructor() { private var cadence: JsonField? = null + private var groupedWithMinMaxThresholdsConfig: + JsonField? = + null private var itemId: JsonField? = null - private var modelType: JsonValue = JsonValue.from("tiered_with_proration") + private var modelType: JsonValue = + JsonValue.from("grouped_with_min_max_thresholds") private var name: JsonField? = null - private var tieredWithProrationConfig: JsonField? = - null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() private var billingCycleConfiguration: JsonField = @@ -19957,30 +23537,33 @@ private constructor( private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(tieredWithProration: TieredWithProration) = apply { - cadence = tieredWithProration.cadence - itemId = tieredWithProration.itemId - modelType = tieredWithProration.modelType - name = tieredWithProration.name - tieredWithProrationConfig = tieredWithProration.tieredWithProrationConfig - billableMetricId = tieredWithProration.billableMetricId - billedInAdvance = tieredWithProration.billedInAdvance - billingCycleConfiguration = tieredWithProration.billingCycleConfiguration - conversionRate = tieredWithProration.conversionRate - conversionRateConfig = tieredWithProration.conversionRateConfig - currency = tieredWithProration.currency - dimensionalPriceConfiguration = - tieredWithProration.dimensionalPriceConfiguration - externalPriceId = tieredWithProration.externalPriceId - fixedPriceQuantity = tieredWithProration.fixedPriceQuantity - invoiceGroupingKey = tieredWithProration.invoiceGroupingKey - invoicingCycleConfiguration = - tieredWithProration.invoicingCycleConfiguration - metadata = tieredWithProration.metadata - referenceId = tieredWithProration.referenceId - additionalProperties = - tieredWithProration.additionalProperties.toMutableMap() - } + internal fun from(groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds) = + apply { + cadence = groupedWithMinMaxThresholds.cadence + groupedWithMinMaxThresholdsConfig = + groupedWithMinMaxThresholds.groupedWithMinMaxThresholdsConfig + itemId = groupedWithMinMaxThresholds.itemId + modelType = groupedWithMinMaxThresholds.modelType + name = groupedWithMinMaxThresholds.name + billableMetricId = groupedWithMinMaxThresholds.billableMetricId + billedInAdvance = groupedWithMinMaxThresholds.billedInAdvance + billingCycleConfiguration = + groupedWithMinMaxThresholds.billingCycleConfiguration + conversionRate = groupedWithMinMaxThresholds.conversionRate + conversionRateConfig = groupedWithMinMaxThresholds.conversionRateConfig + currency = groupedWithMinMaxThresholds.currency + dimensionalPriceConfiguration = + groupedWithMinMaxThresholds.dimensionalPriceConfiguration + externalPriceId = groupedWithMinMaxThresholds.externalPriceId + fixedPriceQuantity = groupedWithMinMaxThresholds.fixedPriceQuantity + invoiceGroupingKey = groupedWithMinMaxThresholds.invoiceGroupingKey + invoicingCycleConfiguration = + groupedWithMinMaxThresholds.invoicingCycleConfiguration + metadata = groupedWithMinMaxThresholds.metadata + referenceId = groupedWithMinMaxThresholds.referenceId + additionalProperties = + groupedWithMinMaxThresholds.additionalProperties.toMutableMap() + } /** The cadence to bill for this price on. */ fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) @@ -19994,6 +23577,29 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + /** Configuration for grouped_with_min_max_thresholds pricing */ + fun groupedWithMinMaxThresholdsConfig( + groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + ) = + groupedWithMinMaxThresholdsConfig( + JsonField.of(groupedWithMinMaxThresholdsConfig) + ) + + /** + * Sets [Builder.groupedWithMinMaxThresholdsConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.groupedWithMinMaxThresholdsConfig] with a + * well-typed [GroupedWithMinMaxThresholdsConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun groupedWithMinMaxThresholdsConfig( + groupedWithMinMaxThresholdsConfig: + JsonField + ) = apply { + this.groupedWithMinMaxThresholdsConfig = groupedWithMinMaxThresholdsConfig + } + /** The id of the item the price will be associated with. */ fun itemId(itemId: String) = itemId(JsonField.of(itemId)) @@ -20012,7 +23618,7 @@ private constructor( * It is usually unnecessary to call this method because the field defaults to * the following: * ```kotlin - * JsonValue.from("tiered_with_proration") + * JsonValue.from("grouped_with_min_max_thresholds") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -20032,22 +23638,6 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } - /** Configuration for tiered_with_proration pricing */ - fun tieredWithProrationConfig( - tieredWithProrationConfig: TieredWithProrationConfig - ) = tieredWithProrationConfig(JsonField.of(tieredWithProrationConfig)) - - /** - * Sets [Builder.tieredWithProrationConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.tieredWithProrationConfig] with a well-typed - * [TieredWithProrationConfig] value instead. This method is primarily for - * setting the field to an undocumented or not yet supported value. - */ - fun tieredWithProrationConfig( - tieredWithProrationConfig: JsonField - ) = apply { this.tieredWithProrationConfig = tieredWithProrationConfig } - /** * The id of the billable metric for the price. Only needed if the price is * usage-based. @@ -20377,27 +23967,30 @@ private constructor( } /** - * Returns an immutable instance of [TieredWithProration]. + * Returns an immutable instance of [GroupedWithMinMaxThresholds]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```kotlin * .cadence() + * .groupedWithMinMaxThresholdsConfig() * .itemId() * .name() - * .tieredWithProrationConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): TieredWithProration = - TieredWithProration( + fun build(): GroupedWithMinMaxThresholds = + GroupedWithMinMaxThresholds( checkRequired("cadence", cadence), + checkRequired( + "groupedWithMinMaxThresholdsConfig", + groupedWithMinMaxThresholdsConfig, + ), checkRequired("itemId", itemId), modelType, checkRequired("name", name), - checkRequired("tieredWithProrationConfig", tieredWithProrationConfig), billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -20417,20 +24010,20 @@ private constructor( private var validated: Boolean = false - fun validate(): TieredWithProration = apply { + fun validate(): GroupedWithMinMaxThresholds = apply { if (validated) { return@apply } cadence().validate() + groupedWithMinMaxThresholdsConfig().validate() itemId() _modelType().let { - if (it != JsonValue.from("tiered_with_proration")) { + if (it != JsonValue.from("grouped_with_min_max_thresholds")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } name() - tieredWithProrationConfig().validate() billableMetricId() billedInAdvance() billingCycleConfiguration()?.validate() @@ -20463,12 +24056,12 @@ private constructor( */ internal fun validity(): Int = (cadence.asKnown()?.validity() ?: 0) + + (groupedWithMinMaxThresholdsConfig.asKnown()?.validity() ?: 0) + (if (itemId.asKnown() == null) 0 else 1) + modelType.let { - if (it == JsonValue.from("tiered_with_proration")) 1 else 0 + if (it == JsonValue.from("grouped_with_min_max_thresholds")) 1 else 0 } + (if (name.asKnown() == null) 0 else 1) + - (tieredWithProrationConfig.asKnown()?.validity() ?: 0) + (if (billableMetricId.asKnown() == null) 0 else 1) + (if (billedInAdvance.asKnown() == null) 0 else 1) + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + @@ -20640,40 +24233,108 @@ private constructor( override fun toString() = value.toString() } - /** Configuration for tiered_with_proration pricing */ - class TieredWithProrationConfig + /** Configuration for grouped_with_min_max_thresholds pricing */ + class GroupedWithMinMaxThresholdsConfig @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val tiers: JsonField>, + private val groupingKey: JsonField, + private val maximumCharge: JsonField, + private val minimumCharge: JsonField, + private val perUnitRate: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("tiers") + @JsonProperty("grouping_key") @ExcludeMissing - tiers: JsonField> = JsonMissing.of() - ) : this(tiers, mutableMapOf()) + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("maximum_charge") + @ExcludeMissing + maximumCharge: JsonField = JsonMissing.of(), + @JsonProperty("minimum_charge") + @ExcludeMissing + minimumCharge: JsonField = JsonMissing.of(), + @JsonProperty("per_unit_rate") + @ExcludeMissing + perUnitRate: JsonField = JsonMissing.of(), + ) : this(groupingKey, maximumCharge, minimumCharge, perUnitRate, mutableMapOf()) /** - * Tiers for rating based on total usage quantities into the specified tier with - * proration + * The event property used to group before applying thresholds * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). */ - fun tiers(): List = tiers.getRequired("tiers") + fun groupingKey(): String = groupingKey.getRequired("grouping_key") /** - * Returns the raw JSON value of [tiers]. + * The maximum amount to charge each group * - * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected - * type. + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). */ - @JsonProperty("tiers") + fun maximumCharge(): String = maximumCharge.getRequired("maximum_charge") + + /** + * The minimum amount to charge each group, regardless of usage + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun minimumCharge(): String = minimumCharge.getRequired("minimum_charge") + + /** + * The base price charged per group + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun perUnitRate(): String = perUnitRate.getRequired("per_unit_rate") + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") @ExcludeMissing - fun _tiers(): JsonField> = tiers + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [maximumCharge]. + * + * Unlike [maximumCharge], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("maximum_charge") + @ExcludeMissing + fun _maximumCharge(): JsonField = maximumCharge + + /** + * Returns the raw JSON value of [minimumCharge]. + * + * Unlike [minimumCharge], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("minimum_charge") + @ExcludeMissing + fun _minimumCharge(): JsonField = minimumCharge + + /** + * Returns the raw JSON value of [perUnitRate]. + * + * Unlike [perUnitRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("per_unit_rate") + @ExcludeMissing + fun _perUnitRate(): JsonField = perUnitRate @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -20691,58 +24352,99 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [TieredWithProrationConfig]. + * [GroupedWithMinMaxThresholdsConfig]. * * The following fields are required: * ```kotlin - * .tiers() + * .groupingKey() + * .maximumCharge() + * .minimumCharge() + * .perUnitRate() * ``` */ fun builder() = Builder() } - /** A builder for [TieredWithProrationConfig]. */ + /** A builder for [GroupedWithMinMaxThresholdsConfig]. */ class Builder internal constructor() { - private var tiers: JsonField>? = null + private var groupingKey: JsonField? = null + private var maximumCharge: JsonField? = null + private var minimumCharge: JsonField? = null + private var perUnitRate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(tieredWithProrationConfig: TieredWithProrationConfig) = - apply { - tiers = tieredWithProrationConfig.tiers.map { it.toMutableList() } - additionalProperties = - tieredWithProrationConfig.additionalProperties.toMutableMap() - } + internal fun from( + groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + ) = apply { + groupingKey = groupedWithMinMaxThresholdsConfig.groupingKey + maximumCharge = groupedWithMinMaxThresholdsConfig.maximumCharge + minimumCharge = groupedWithMinMaxThresholdsConfig.minimumCharge + perUnitRate = groupedWithMinMaxThresholdsConfig.perUnitRate + additionalProperties = + groupedWithMinMaxThresholdsConfig.additionalProperties + .toMutableMap() + } - /** - * Tiers for rating based on total usage quantities into the specified tier - * with proration - */ - fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + /** The event property used to group before applying thresholds */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) /** - * Sets [Builder.tiers] to an arbitrary JSON value. + * Sets [Builder.groupingKey] to an arbitrary JSON value. * - * You should usually call [Builder.tiers] with a well-typed `List` + * You should usually call [Builder.groupingKey] with a well-typed [String] * value instead. This method is primarily for setting the field to an * undocumented or not yet supported value. */ - fun tiers(tiers: JsonField>) = apply { - this.tiers = tiers.map { it.toMutableList() } + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey } + /** The maximum amount to charge each group */ + fun maximumCharge(maximumCharge: String) = + maximumCharge(JsonField.of(maximumCharge)) + /** - * Adds a single [Tier] to [tiers]. + * Sets [Builder.maximumCharge] to an arbitrary JSON value. * - * @throws IllegalStateException if the field was previously set to a - * non-list. + * You should usually call [Builder.maximumCharge] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. */ - fun addTier(tier: Tier) = apply { - tiers = - (tiers ?: JsonField.of(mutableListOf())).also { - checkKnown("tiers", it).add(tier) - } + fun maximumCharge(maximumCharge: JsonField) = apply { + this.maximumCharge = maximumCharge + } + + /** The minimum amount to charge each group, regardless of usage */ + fun minimumCharge(minimumCharge: String) = + minimumCharge(JsonField.of(minimumCharge)) + + /** + * Sets [Builder.minimumCharge] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumCharge] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun minimumCharge(minimumCharge: JsonField) = apply { + this.minimumCharge = minimumCharge + } + + /** The base price charged per group */ + fun perUnitRate(perUnitRate: String) = + perUnitRate(JsonField.of(perUnitRate)) + + /** + * Sets [Builder.perUnitRate] to an arbitrary JSON value. + * + * You should usually call [Builder.perUnitRate] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun perUnitRate(perUnitRate: JsonField) = apply { + this.perUnitRate = perUnitRate } fun additionalProperties(additionalProperties: Map) = @@ -20768,291 +24470,91 @@ private constructor( } /** - * Returns an immutable instance of [TieredWithProrationConfig]. + * Returns an immutable instance of [GroupedWithMinMaxThresholdsConfig]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```kotlin - * .tiers() + * .groupingKey() + * .maximumCharge() + * .minimumCharge() + * .perUnitRate() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): TieredWithProrationConfig = - TieredWithProrationConfig( - checkRequired("tiers", tiers).map { it.toImmutable() }, + fun build(): GroupedWithMinMaxThresholdsConfig = + GroupedWithMinMaxThresholdsConfig( + checkRequired("groupingKey", groupingKey), + checkRequired("maximumCharge", maximumCharge), + checkRequired("minimumCharge", minimumCharge), + checkRequired("perUnitRate", perUnitRate), additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): TieredWithProrationConfig = apply { + fun validate(): GroupedWithMinMaxThresholdsConfig = apply { if (validated) { return@apply } - tiers().forEach { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (tiers.asKnown()?.sumOf { it.validity().toInt() } ?: 0) - - /** Configuration for a single tiered with proration tier */ - class Tier - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val tierLowerBound: JsonField, - private val unitAmount: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("tier_lower_bound") - @ExcludeMissing - tierLowerBound: JsonField = JsonMissing.of(), - @JsonProperty("unit_amount") - @ExcludeMissing - unitAmount: JsonField = JsonMissing.of(), - ) : this(tierLowerBound, unitAmount, mutableMapOf()) - - /** - * Inclusive tier starting value - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type - * or is unexpectedly missing or null (e.g. if the server responded with - * an unexpected value). - */ - fun tierLowerBound(): String = - tierLowerBound.getRequired("tier_lower_bound") - - /** - * Amount per unit - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type - * or is unexpectedly missing or null (e.g. if the server responded with - * an unexpected value). - */ - fun unitAmount(): String = unitAmount.getRequired("unit_amount") - - /** - * Returns the raw JSON value of [tierLowerBound]. - * - * Unlike [tierLowerBound], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("tier_lower_bound") - @ExcludeMissing - fun _tierLowerBound(): JsonField = tierLowerBound - - /** - * Returns the raw JSON value of [unitAmount]. - * - * Unlike [unitAmount], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("unit_amount") - @ExcludeMissing - fun _unitAmount(): JsonField = unitAmount - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [Tier]. - * - * The following fields are required: - * ```kotlin - * .tierLowerBound() - * .unitAmount() - * ``` - */ - fun builder() = Builder() - } - - /** A builder for [Tier]. */ - class Builder internal constructor() { - - private var tierLowerBound: JsonField? = null - private var unitAmount: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - internal fun from(tier: Tier) = apply { - tierLowerBound = tier.tierLowerBound - unitAmount = tier.unitAmount - additionalProperties = tier.additionalProperties.toMutableMap() - } - - /** Inclusive tier starting value */ - fun tierLowerBound(tierLowerBound: String) = - tierLowerBound(JsonField.of(tierLowerBound)) - - /** - * Sets [Builder.tierLowerBound] to an arbitrary JSON value. - * - * You should usually call [Builder.tierLowerBound] with a well-typed - * [String] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun tierLowerBound(tierLowerBound: JsonField) = apply { - this.tierLowerBound = tierLowerBound - } - - /** Amount per unit */ - fun unitAmount(unitAmount: String) = - unitAmount(JsonField.of(unitAmount)) - - /** - * Sets [Builder.unitAmount] to an arbitrary JSON value. - * - * You should usually call [Builder.unitAmount] with a well-typed - * [String] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun unitAmount(unitAmount: JsonField) = apply { - this.unitAmount = unitAmount - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Tier]. - * - * Further updates to this [Builder] will not mutate the returned - * instance. - * - * The following fields are required: - * ```kotlin - * .tierLowerBound() - * .unitAmount() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Tier = - Tier( - checkRequired("tierLowerBound", tierLowerBound), - checkRequired("unitAmount", unitAmount), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Tier = apply { - if (validated) { - return@apply - } - - tierLowerBound() - unitAmount() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this - * object recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (if (tierLowerBound.asKnown() == null) 0 else 1) + - (if (unitAmount.asKnown() == null) 0 else 1) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Tier && - tierLowerBound == other.tierLowerBound && - unitAmount == other.unitAmount && - additionalProperties == other.additionalProperties - } + groupingKey() + maximumCharge() + minimumCharge() + perUnitRate() + validated = true + } - private val hashCode: Int by lazy { - Objects.hash(tierLowerBound, unitAmount, additionalProperties) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false } - override fun hashCode(): Int = hashCode - - override fun toString() = - "Tier{tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" - } + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (groupingKey.asKnown() == null) 0 else 1) + + (if (maximumCharge.asKnown() == null) 0 else 1) + + (if (minimumCharge.asKnown() == null) 0 else 1) + + (if (perUnitRate.asKnown() == null) 0 else 1) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is TieredWithProrationConfig && - tiers == other.tiers && + return other is GroupedWithMinMaxThresholdsConfig && + groupingKey == other.groupingKey && + maximumCharge == other.maximumCharge && + minimumCharge == other.minimumCharge && + perUnitRate == other.perUnitRate && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(tiers, additionalProperties) } + private val hashCode: Int by lazy { + Objects.hash( + groupingKey, + maximumCharge, + minimumCharge, + perUnitRate, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode override fun toString() = - "TieredWithProrationConfig{tiers=$tiers, additionalProperties=$additionalProperties}" + "GroupedWithMinMaxThresholdsConfig{groupingKey=$groupingKey, maximumCharge=$maximumCharge, minimumCharge=$minimumCharge, perUnitRate=$perUnitRate, additionalProperties=$additionalProperties}" } /** @@ -21169,12 +24671,13 @@ private constructor( return true } - return other is TieredWithProration && + return other is GroupedWithMinMaxThresholds && cadence == other.cadence && + groupedWithMinMaxThresholdsConfig == + other.groupedWithMinMaxThresholdsConfig && itemId == other.itemId && modelType == other.modelType && name == other.name && - tieredWithProrationConfig == other.tieredWithProrationConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && @@ -21194,10 +24697,10 @@ private constructor( private val hashCode: Int by lazy { Objects.hash( cadence, + groupedWithMinMaxThresholdsConfig, itemId, modelType, name, - tieredWithProrationConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -21218,15 +24721,15 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "TieredWithProration{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredWithProrationConfig=$tieredWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "GroupedWithMinMaxThresholds{cadence=$cadence, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class GroupedWithMinMaxThresholds + class CumulativeGroupedAllocation @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, - private val groupedWithMinMaxThresholdsConfig: - JsonField, + private val cumulativeGroupedAllocationConfig: + JsonField, private val itemId: JsonField, private val modelType: JsonValue, private val name: JsonField, @@ -21252,10 +24755,10 @@ private constructor( @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), - @JsonProperty("grouped_with_min_max_thresholds_config") + @JsonProperty("cumulative_grouped_allocation_config") @ExcludeMissing - groupedWithMinMaxThresholdsConfig: - JsonField = + cumulativeGroupedAllocationConfig: + JsonField = JsonMissing.of(), @JsonProperty("item_id") @ExcludeMissing @@ -21310,7 +24813,7 @@ private constructor( referenceId: JsonField = JsonMissing.of(), ) : this( cadence, - groupedWithMinMaxThresholdsConfig, + cumulativeGroupedAllocationConfig, itemId, modelType, name, @@ -21340,15 +24843,15 @@ private constructor( fun cadence(): Cadence = cadence.getRequired("cadence") /** - * Configuration for grouped_with_min_max_thresholds pricing + * Configuration for cumulative_grouped_allocation pricing * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected * value). */ - fun groupedWithMinMaxThresholdsConfig(): GroupedWithMinMaxThresholdsConfig = - groupedWithMinMaxThresholdsConfig.getRequired( - "grouped_with_min_max_thresholds_config" + fun cumulativeGroupedAllocationConfig(): CumulativeGroupedAllocationConfig = + cumulativeGroupedAllocationConfig.getRequired( + "cumulative_grouped_allocation_config" ) /** @@ -21365,7 +24868,7 @@ private constructor( * * Expected to always return the following: * ```kotlin - * JsonValue.from("grouped_with_min_max_thresholds") + * JsonValue.from("cumulative_grouped_allocation") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -21512,15 +25015,15 @@ private constructor( fun _cadence(): JsonField = cadence /** - * Returns the raw JSON value of [groupedWithMinMaxThresholdsConfig]. + * Returns the raw JSON value of [cumulativeGroupedAllocationConfig]. * - * Unlike [groupedWithMinMaxThresholdsConfig], this method doesn't throw if the JSON + * Unlike [cumulativeGroupedAllocationConfig], this method doesn't throw if the JSON * field has an unexpected type. */ - @JsonProperty("grouped_with_min_max_thresholds_config") + @JsonProperty("cumulative_grouped_allocation_config") @ExcludeMissing - fun _groupedWithMinMaxThresholdsConfig(): - JsonField = groupedWithMinMaxThresholdsConfig + fun _cumulativeGroupedAllocationConfig(): + JsonField = cumulativeGroupedAllocationConfig /** * Returns the raw JSON value of [itemId]. @@ -21687,12 +25190,12 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [GroupedWithMinMaxThresholds]. + * [CumulativeGroupedAllocation]. * * The following fields are required: * ```kotlin * .cadence() - * .groupedWithMinMaxThresholdsConfig() + * .cumulativeGroupedAllocationConfig() * .itemId() * .name() * ``` @@ -21700,16 +25203,16 @@ private constructor( fun builder() = Builder() } - /** A builder for [GroupedWithMinMaxThresholds]. */ + /** A builder for [CumulativeGroupedAllocation]. */ class Builder internal constructor() { private var cadence: JsonField? = null - private var groupedWithMinMaxThresholdsConfig: - JsonField? = + private var cumulativeGroupedAllocationConfig: + JsonField? = null private var itemId: JsonField? = null private var modelType: JsonValue = - JsonValue.from("grouped_with_min_max_thresholds") + JsonValue.from("cumulative_grouped_allocation") private var name: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() @@ -21732,32 +25235,32 @@ private constructor( private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds) = + internal fun from(cumulativeGroupedAllocation: CumulativeGroupedAllocation) = apply { - cadence = groupedWithMinMaxThresholds.cadence - groupedWithMinMaxThresholdsConfig = - groupedWithMinMaxThresholds.groupedWithMinMaxThresholdsConfig - itemId = groupedWithMinMaxThresholds.itemId - modelType = groupedWithMinMaxThresholds.modelType - name = groupedWithMinMaxThresholds.name - billableMetricId = groupedWithMinMaxThresholds.billableMetricId - billedInAdvance = groupedWithMinMaxThresholds.billedInAdvance + cadence = cumulativeGroupedAllocation.cadence + cumulativeGroupedAllocationConfig = + cumulativeGroupedAllocation.cumulativeGroupedAllocationConfig + itemId = cumulativeGroupedAllocation.itemId + modelType = cumulativeGroupedAllocation.modelType + name = cumulativeGroupedAllocation.name + billableMetricId = cumulativeGroupedAllocation.billableMetricId + billedInAdvance = cumulativeGroupedAllocation.billedInAdvance billingCycleConfiguration = - groupedWithMinMaxThresholds.billingCycleConfiguration - conversionRate = groupedWithMinMaxThresholds.conversionRate - conversionRateConfig = groupedWithMinMaxThresholds.conversionRateConfig - currency = groupedWithMinMaxThresholds.currency + cumulativeGroupedAllocation.billingCycleConfiguration + conversionRate = cumulativeGroupedAllocation.conversionRate + conversionRateConfig = cumulativeGroupedAllocation.conversionRateConfig + currency = cumulativeGroupedAllocation.currency dimensionalPriceConfiguration = - groupedWithMinMaxThresholds.dimensionalPriceConfiguration - externalPriceId = groupedWithMinMaxThresholds.externalPriceId - fixedPriceQuantity = groupedWithMinMaxThresholds.fixedPriceQuantity - invoiceGroupingKey = groupedWithMinMaxThresholds.invoiceGroupingKey + cumulativeGroupedAllocation.dimensionalPriceConfiguration + externalPriceId = cumulativeGroupedAllocation.externalPriceId + fixedPriceQuantity = cumulativeGroupedAllocation.fixedPriceQuantity + invoiceGroupingKey = cumulativeGroupedAllocation.invoiceGroupingKey invoicingCycleConfiguration = - groupedWithMinMaxThresholds.invoicingCycleConfiguration - metadata = groupedWithMinMaxThresholds.metadata - referenceId = groupedWithMinMaxThresholds.referenceId + cumulativeGroupedAllocation.invoicingCycleConfiguration + metadata = cumulativeGroupedAllocation.metadata + referenceId = cumulativeGroupedAllocation.referenceId additionalProperties = - groupedWithMinMaxThresholds.additionalProperties.toMutableMap() + cumulativeGroupedAllocation.additionalProperties.toMutableMap() } /** The cadence to bill for this price on. */ @@ -21772,27 +25275,27 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - /** Configuration for grouped_with_min_max_thresholds pricing */ - fun groupedWithMinMaxThresholdsConfig( - groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + /** Configuration for cumulative_grouped_allocation pricing */ + fun cumulativeGroupedAllocationConfig( + cumulativeGroupedAllocationConfig: CumulativeGroupedAllocationConfig ) = - groupedWithMinMaxThresholdsConfig( - JsonField.of(groupedWithMinMaxThresholdsConfig) + cumulativeGroupedAllocationConfig( + JsonField.of(cumulativeGroupedAllocationConfig) ) /** - * Sets [Builder.groupedWithMinMaxThresholdsConfig] to an arbitrary JSON value. + * Sets [Builder.cumulativeGroupedAllocationConfig] to an arbitrary JSON value. * - * You should usually call [Builder.groupedWithMinMaxThresholdsConfig] with a - * well-typed [GroupedWithMinMaxThresholdsConfig] value instead. This method is + * You should usually call [Builder.cumulativeGroupedAllocationConfig] with a + * well-typed [CumulativeGroupedAllocationConfig] value instead. This method is * primarily for setting the field to an undocumented or not yet supported * value. */ - fun groupedWithMinMaxThresholdsConfig( - groupedWithMinMaxThresholdsConfig: - JsonField + fun cumulativeGroupedAllocationConfig( + cumulativeGroupedAllocationConfig: + JsonField ) = apply { - this.groupedWithMinMaxThresholdsConfig = groupedWithMinMaxThresholdsConfig + this.cumulativeGroupedAllocationConfig = cumulativeGroupedAllocationConfig } /** The id of the item the price will be associated with. */ @@ -21813,7 +25316,7 @@ private constructor( * It is usually unnecessary to call this method because the field defaults to * the following: * ```kotlin - * JsonValue.from("grouped_with_min_max_thresholds") + * JsonValue.from("cumulative_grouped_allocation") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -22162,26 +25665,26 @@ private constructor( } /** - * Returns an immutable instance of [GroupedWithMinMaxThresholds]. + * Returns an immutable instance of [CumulativeGroupedAllocation]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```kotlin * .cadence() - * .groupedWithMinMaxThresholdsConfig() + * .cumulativeGroupedAllocationConfig() * .itemId() * .name() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): GroupedWithMinMaxThresholds = - GroupedWithMinMaxThresholds( + fun build(): CumulativeGroupedAllocation = + CumulativeGroupedAllocation( checkRequired("cadence", cadence), checkRequired( - "groupedWithMinMaxThresholdsConfig", - groupedWithMinMaxThresholdsConfig, + "cumulativeGroupedAllocationConfig", + cumulativeGroupedAllocationConfig, ), checkRequired("itemId", itemId), modelType, @@ -22205,16 +25708,16 @@ private constructor( private var validated: Boolean = false - fun validate(): GroupedWithMinMaxThresholds = apply { + fun validate(): CumulativeGroupedAllocation = apply { if (validated) { return@apply } cadence().validate() - groupedWithMinMaxThresholdsConfig().validate() + cumulativeGroupedAllocationConfig().validate() itemId() _modelType().let { - if (it != JsonValue.from("grouped_with_min_max_thresholds")) { + if (it != JsonValue.from("cumulative_grouped_allocation")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } @@ -22251,10 +25754,10 @@ private constructor( */ internal fun validity(): Int = (cadence.asKnown()?.validity() ?: 0) + - (groupedWithMinMaxThresholdsConfig.asKnown()?.validity() ?: 0) + + (cumulativeGroupedAllocationConfig.asKnown()?.validity() ?: 0) + (if (itemId.asKnown() == null) 0 else 1) + modelType.let { - if (it == JsonValue.from("grouped_with_min_max_thresholds")) 1 else 0 + if (it == JsonValue.from("cumulative_grouped_allocation")) 1 else 0 } + (if (name.asKnown() == null) 0 else 1) + (if (billableMetricId.asKnown() == null) 0 else 1) + @@ -22428,108 +25931,115 @@ private constructor( override fun toString() = value.toString() } - /** Configuration for grouped_with_min_max_thresholds pricing */ - class GroupedWithMinMaxThresholdsConfig + /** Configuration for cumulative_grouped_allocation pricing */ + class CumulativeGroupedAllocationConfig @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( + private val cumulativeAllocation: JsonField, + private val groupAllocation: JsonField, private val groupingKey: JsonField, - private val maximumCharge: JsonField, - private val minimumCharge: JsonField, - private val perUnitRate: JsonField, + private val unitAmount: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("grouping_key") + @JsonProperty("cumulative_allocation") @ExcludeMissing - groupingKey: JsonField = JsonMissing.of(), - @JsonProperty("maximum_charge") + cumulativeAllocation: JsonField = JsonMissing.of(), + @JsonProperty("group_allocation") @ExcludeMissing - maximumCharge: JsonField = JsonMissing.of(), - @JsonProperty("minimum_charge") + groupAllocation: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") @ExcludeMissing - minimumCharge: JsonField = JsonMissing.of(), - @JsonProperty("per_unit_rate") + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") @ExcludeMissing - perUnitRate: JsonField = JsonMissing.of(), - ) : this(groupingKey, maximumCharge, minimumCharge, perUnitRate, mutableMapOf()) + unitAmount: JsonField = JsonMissing.of(), + ) : this( + cumulativeAllocation, + groupAllocation, + groupingKey, + unitAmount, + mutableMapOf(), + ) /** - * The event property used to group before applying thresholds + * The overall allocation across all groups * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). */ - fun groupingKey(): String = groupingKey.getRequired("grouping_key") + fun cumulativeAllocation(): String = + cumulativeAllocation.getRequired("cumulative_allocation") /** - * The maximum amount to charge each group + * The allocation per individual group * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). */ - fun maximumCharge(): String = maximumCharge.getRequired("maximum_charge") + fun groupAllocation(): String = groupAllocation.getRequired("group_allocation") /** - * The minimum amount to charge each group, regardless of usage + * The event property used to group usage before applying allocations * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). */ - fun minimumCharge(): String = minimumCharge.getRequired("minimum_charge") + fun groupingKey(): String = groupingKey.getRequired("grouping_key") /** - * The base price charged per group + * The amount to charge for each unit outside of the allocation * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). */ - fun perUnitRate(): String = perUnitRate.getRequired("per_unit_rate") + fun unitAmount(): String = unitAmount.getRequired("unit_amount") /** - * Returns the raw JSON value of [groupingKey]. + * Returns the raw JSON value of [cumulativeAllocation]. * - * Unlike [groupingKey], this method doesn't throw if the JSON field has an - * unexpected type. + * Unlike [cumulativeAllocation], this method doesn't throw if the JSON field + * has an unexpected type. */ - @JsonProperty("grouping_key") + @JsonProperty("cumulative_allocation") @ExcludeMissing - fun _groupingKey(): JsonField = groupingKey + fun _cumulativeAllocation(): JsonField = cumulativeAllocation /** - * Returns the raw JSON value of [maximumCharge]. + * Returns the raw JSON value of [groupAllocation]. * - * Unlike [maximumCharge], this method doesn't throw if the JSON field has an + * Unlike [groupAllocation], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("maximum_charge") + @JsonProperty("group_allocation") @ExcludeMissing - fun _maximumCharge(): JsonField = maximumCharge + fun _groupAllocation(): JsonField = groupAllocation /** - * Returns the raw JSON value of [minimumCharge]. + * Returns the raw JSON value of [groupingKey]. * - * Unlike [minimumCharge], this method doesn't throw if the JSON field has an + * Unlike [groupingKey], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("minimum_charge") + @JsonProperty("grouping_key") @ExcludeMissing - fun _minimumCharge(): JsonField = minimumCharge + fun _groupingKey(): JsonField = groupingKey /** - * Returns the raw JSON value of [perUnitRate]. + * Returns the raw JSON value of [unitAmount]. * - * Unlike [perUnitRate], this method doesn't throw if the JSON field has an + * Unlike [unitAmount], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("per_unit_rate") + @JsonProperty("unit_amount") @ExcludeMissing - fun _perUnitRate(): JsonField = perUnitRate + fun _unitAmount(): JsonField = unitAmount @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -22547,99 +26057,99 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [GroupedWithMinMaxThresholdsConfig]. + * [CumulativeGroupedAllocationConfig]. * * The following fields are required: * ```kotlin + * .cumulativeAllocation() + * .groupAllocation() * .groupingKey() - * .maximumCharge() - * .minimumCharge() - * .perUnitRate() + * .unitAmount() * ``` */ fun builder() = Builder() } - /** A builder for [GroupedWithMinMaxThresholdsConfig]. */ + /** A builder for [CumulativeGroupedAllocationConfig]. */ class Builder internal constructor() { + private var cumulativeAllocation: JsonField? = null + private var groupAllocation: JsonField? = null private var groupingKey: JsonField? = null - private var maximumCharge: JsonField? = null - private var minimumCharge: JsonField? = null - private var perUnitRate: JsonField? = null + private var unitAmount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from( - groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + cumulativeGroupedAllocationConfig: CumulativeGroupedAllocationConfig ) = apply { - groupingKey = groupedWithMinMaxThresholdsConfig.groupingKey - maximumCharge = groupedWithMinMaxThresholdsConfig.maximumCharge - minimumCharge = groupedWithMinMaxThresholdsConfig.minimumCharge - perUnitRate = groupedWithMinMaxThresholdsConfig.perUnitRate + cumulativeAllocation = + cumulativeGroupedAllocationConfig.cumulativeAllocation + groupAllocation = cumulativeGroupedAllocationConfig.groupAllocation + groupingKey = cumulativeGroupedAllocationConfig.groupingKey + unitAmount = cumulativeGroupedAllocationConfig.unitAmount additionalProperties = - groupedWithMinMaxThresholdsConfig.additionalProperties + cumulativeGroupedAllocationConfig.additionalProperties .toMutableMap() } - /** The event property used to group before applying thresholds */ - fun groupingKey(groupingKey: String) = - groupingKey(JsonField.of(groupingKey)) + /** The overall allocation across all groups */ + fun cumulativeAllocation(cumulativeAllocation: String) = + cumulativeAllocation(JsonField.of(cumulativeAllocation)) /** - * Sets [Builder.groupingKey] to an arbitrary JSON value. + * Sets [Builder.cumulativeAllocation] to an arbitrary JSON value. * - * You should usually call [Builder.groupingKey] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. + * You should usually call [Builder.cumulativeAllocation] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. */ - fun groupingKey(groupingKey: JsonField) = apply { - this.groupingKey = groupingKey + fun cumulativeAllocation(cumulativeAllocation: JsonField) = apply { + this.cumulativeAllocation = cumulativeAllocation } - /** The maximum amount to charge each group */ - fun maximumCharge(maximumCharge: String) = - maximumCharge(JsonField.of(maximumCharge)) + /** The allocation per individual group */ + fun groupAllocation(groupAllocation: String) = + groupAllocation(JsonField.of(groupAllocation)) /** - * Sets [Builder.maximumCharge] to an arbitrary JSON value. + * Sets [Builder.groupAllocation] to an arbitrary JSON value. * - * You should usually call [Builder.maximumCharge] with a well-typed + * You should usually call [Builder.groupAllocation] with a well-typed * [String] value instead. This method is primarily for setting the field to * an undocumented or not yet supported value. */ - fun maximumCharge(maximumCharge: JsonField) = apply { - this.maximumCharge = maximumCharge + fun groupAllocation(groupAllocation: JsonField) = apply { + this.groupAllocation = groupAllocation } - /** The minimum amount to charge each group, regardless of usage */ - fun minimumCharge(minimumCharge: String) = - minimumCharge(JsonField.of(minimumCharge)) + /** The event property used to group usage before applying allocations */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) /** - * Sets [Builder.minimumCharge] to an arbitrary JSON value. + * Sets [Builder.groupingKey] to an arbitrary JSON value. * - * You should usually call [Builder.minimumCharge] with a well-typed - * [String] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. */ - fun minimumCharge(minimumCharge: JsonField) = apply { - this.minimumCharge = minimumCharge + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey } - /** The base price charged per group */ - fun perUnitRate(perUnitRate: String) = - perUnitRate(JsonField.of(perUnitRate)) + /** The amount to charge for each unit outside of the allocation */ + fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) /** - * Sets [Builder.perUnitRate] to an arbitrary JSON value. + * Sets [Builder.unitAmount] to an arbitrary JSON value. * - * You should usually call [Builder.perUnitRate] with a well-typed [String] + * You should usually call [Builder.unitAmount] with a well-typed [String] * value instead. This method is primarily for setting the field to an * undocumented or not yet supported value. */ - fun perUnitRate(perUnitRate: JsonField) = apply { - this.perUnitRate = perUnitRate + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount } fun additionalProperties(additionalProperties: Map) = @@ -22665,41 +26175,41 @@ private constructor( } /** - * Returns an immutable instance of [GroupedWithMinMaxThresholdsConfig]. + * Returns an immutable instance of [CumulativeGroupedAllocationConfig]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```kotlin + * .cumulativeAllocation() + * .groupAllocation() * .groupingKey() - * .maximumCharge() - * .minimumCharge() - * .perUnitRate() + * .unitAmount() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): GroupedWithMinMaxThresholdsConfig = - GroupedWithMinMaxThresholdsConfig( + fun build(): CumulativeGroupedAllocationConfig = + CumulativeGroupedAllocationConfig( + checkRequired("cumulativeAllocation", cumulativeAllocation), + checkRequired("groupAllocation", groupAllocation), checkRequired("groupingKey", groupingKey), - checkRequired("maximumCharge", maximumCharge), - checkRequired("minimumCharge", minimumCharge), - checkRequired("perUnitRate", perUnitRate), + checkRequired("unitAmount", unitAmount), additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): GroupedWithMinMaxThresholdsConfig = apply { + fun validate(): CumulativeGroupedAllocationConfig = apply { if (validated) { return@apply } + cumulativeAllocation() + groupAllocation() groupingKey() - maximumCharge() - minimumCharge() - perUnitRate() + unitAmount() validated = true } @@ -22718,30 +26228,30 @@ private constructor( * Used for best match union deserialization. */ internal fun validity(): Int = - (if (groupingKey.asKnown() == null) 0 else 1) + - (if (maximumCharge.asKnown() == null) 0 else 1) + - (if (minimumCharge.asKnown() == null) 0 else 1) + - (if (perUnitRate.asKnown() == null) 0 else 1) + (if (cumulativeAllocation.asKnown() == null) 0 else 1) + + (if (groupAllocation.asKnown() == null) 0 else 1) + + (if (groupingKey.asKnown() == null) 0 else 1) + + (if (unitAmount.asKnown() == null) 0 else 1) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is GroupedWithMinMaxThresholdsConfig && + return other is CumulativeGroupedAllocationConfig && + cumulativeAllocation == other.cumulativeAllocation && + groupAllocation == other.groupAllocation && groupingKey == other.groupingKey && - maximumCharge == other.maximumCharge && - minimumCharge == other.minimumCharge && - perUnitRate == other.perUnitRate && + unitAmount == other.unitAmount && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { Objects.hash( + cumulativeAllocation, + groupAllocation, groupingKey, - maximumCharge, - minimumCharge, - perUnitRate, + unitAmount, additionalProperties, ) } @@ -22749,7 +26259,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "GroupedWithMinMaxThresholdsConfig{groupingKey=$groupingKey, maximumCharge=$maximumCharge, minimumCharge=$minimumCharge, perUnitRate=$perUnitRate, additionalProperties=$additionalProperties}" + "CumulativeGroupedAllocationConfig{cumulativeAllocation=$cumulativeAllocation, groupAllocation=$groupAllocation, groupingKey=$groupingKey, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" } /** @@ -22866,10 +26376,10 @@ private constructor( return true } - return other is GroupedWithMinMaxThresholds && + return other is CumulativeGroupedAllocation && cadence == other.cadence && - groupedWithMinMaxThresholdsConfig == - other.groupedWithMinMaxThresholdsConfig && + cumulativeGroupedAllocationConfig == + other.cumulativeGroupedAllocationConfig && itemId == other.itemId && modelType == other.modelType && name == other.name && @@ -22892,7 +26402,7 @@ private constructor( private val hashCode: Int by lazy { Objects.hash( cadence, - groupedWithMinMaxThresholdsConfig, + cumulativeGroupedAllocationConfig, itemId, modelType, name, @@ -22916,7 +26426,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "GroupedWithMinMaxThresholds{cadence=$cadence, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "CumulativeGroupedAllocation{cadence=$cadence, cumulativeGroupedAllocationConfig=$cumulativeGroupedAllocationConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } class Percent diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/MutatedSubscriptionTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/MutatedSubscriptionTest.kt index b166f9486..8426d3f31 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/MutatedSubscriptionTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/MutatedSubscriptionTest.kt @@ -241,14 +241,6 @@ internal class MutatedSubscriptionTest { .usageDiscount(0.0) .build() ) - .basePlan( - Plan.BasePlan.builder() - .id("m2t5akQeh2obwxeU") - .externalPlanId("m2t5akQeh2obwxeU") - .name("Example plan") - .build() - ) - .basePlanId("base_plan_id") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .currency("currency") .defaultInvoiceMemo("default_invoice_memo") @@ -503,6 +495,14 @@ internal class MutatedSubscriptionTest { .build() ) .version(0L) + .basePlan( + Plan.BasePlan.builder() + .id("m2t5akQeh2obwxeU") + .externalPlanId("m2t5akQeh2obwxeU") + .name("Example plan") + .build() + ) + .basePlanId("base_plan_id") .build() ) .addPriceInterval( @@ -1960,14 +1960,6 @@ internal class MutatedSubscriptionTest { .usageDiscount(0.0) .build() ) - .basePlan( - Plan.BasePlan.builder() - .id("m2t5akQeh2obwxeU") - .externalPlanId("m2t5akQeh2obwxeU") - .name("Example plan") - .build() - ) - .basePlanId("base_plan_id") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .currency("currency") .defaultInvoiceMemo("default_invoice_memo") @@ -2216,6 +2208,14 @@ internal class MutatedSubscriptionTest { .build() ) .version(0L) + .basePlan( + Plan.BasePlan.builder() + .id("m2t5akQeh2obwxeU") + .externalPlanId("m2t5akQeh2obwxeU") + .name("Example plan") + .build() + ) + .basePlanId("base_plan_id") .build() ) assertThat(mutatedSubscription.priceIntervals()) @@ -3604,14 +3604,6 @@ internal class MutatedSubscriptionTest { .usageDiscount(0.0) .build() ) - .basePlan( - Plan.BasePlan.builder() - .id("m2t5akQeh2obwxeU") - .externalPlanId("m2t5akQeh2obwxeU") - .name("Example plan") - .build() - ) - .basePlanId("base_plan_id") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .currency("currency") .defaultInvoiceMemo("default_invoice_memo") @@ -3866,6 +3858,14 @@ internal class MutatedSubscriptionTest { .build() ) .version(0L) + .basePlan( + Plan.BasePlan.builder() + .id("m2t5akQeh2obwxeU") + .externalPlanId("m2t5akQeh2obwxeU") + .name("Example plan") + .build() + ) + .basePlanId("base_plan_id") .build() ) .addPriceInterval( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanListPageResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanListPageResponseTest.kt index f88092a24..c7638e398 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanListPageResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanListPageResponseTest.kt @@ -44,14 +44,6 @@ internal class PlanListPageResponseTest { .usageDiscount(0.0) .build() ) - .basePlan( - Plan.BasePlan.builder() - .id("m2t5akQeh2obwxeU") - .externalPlanId("m2t5akQeh2obwxeU") - .name("Example plan") - .build() - ) - .basePlanId("base_plan_id") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .currency("currency") .defaultInvoiceMemo("default_invoice_memo") @@ -306,6 +298,14 @@ internal class PlanListPageResponseTest { .build() ) .version(0L) + .basePlan( + Plan.BasePlan.builder() + .id("m2t5akQeh2obwxeU") + .externalPlanId("m2t5akQeh2obwxeU") + .name("Example plan") + .build() + ) + .basePlanId("base_plan_id") .build() ) .paginationMetadata( @@ -340,14 +340,6 @@ internal class PlanListPageResponseTest { .usageDiscount(0.0) .build() ) - .basePlan( - Plan.BasePlan.builder() - .id("m2t5akQeh2obwxeU") - .externalPlanId("m2t5akQeh2obwxeU") - .name("Example plan") - .build() - ) - .basePlanId("base_plan_id") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .currency("currency") .defaultInvoiceMemo("default_invoice_memo") @@ -596,6 +588,14 @@ internal class PlanListPageResponseTest { .build() ) .version(0L) + .basePlan( + Plan.BasePlan.builder() + .id("m2t5akQeh2obwxeU") + .externalPlanId("m2t5akQeh2obwxeU") + .name("Example plan") + .build() + ) + .basePlanId("base_plan_id") .build() ) assertThat(planListPageResponse.paginationMetadata()) @@ -636,14 +636,6 @@ internal class PlanListPageResponseTest { .usageDiscount(0.0) .build() ) - .basePlan( - Plan.BasePlan.builder() - .id("m2t5akQeh2obwxeU") - .externalPlanId("m2t5akQeh2obwxeU") - .name("Example plan") - .build() - ) - .basePlanId("base_plan_id") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .currency("currency") .defaultInvoiceMemo("default_invoice_memo") @@ -898,6 +890,14 @@ internal class PlanListPageResponseTest { .build() ) .version(0L) + .basePlan( + Plan.BasePlan.builder() + .id("m2t5akQeh2obwxeU") + .externalPlanId("m2t5akQeh2obwxeU") + .name("Example plan") + .build() + ) + .basePlanId("base_plan_id") .build() ) .paginationMetadata( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanTest.kt index b62525d63..07ec83581 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanTest.kt @@ -37,14 +37,6 @@ internal class PlanTest { .usageDiscount(0.0) .build() ) - .basePlan( - Plan.BasePlan.builder() - .id("m2t5akQeh2obwxeU") - .externalPlanId("m2t5akQeh2obwxeU") - .name("Example plan") - .build() - ) - .basePlanId("base_plan_id") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .currency("currency") .defaultInvoiceMemo("default_invoice_memo") @@ -288,6 +280,14 @@ internal class PlanTest { .build() ) .version(0L) + .basePlan( + Plan.BasePlan.builder() + .id("m2t5akQeh2obwxeU") + .externalPlanId("m2t5akQeh2obwxeU") + .name("Example plan") + .build() + ) + .basePlanId("base_plan_id") .build() assertThat(plan.id()).isEqualTo("id") @@ -315,15 +315,6 @@ internal class PlanTest { .build() ) ) - assertThat(plan.basePlan()) - .isEqualTo( - Plan.BasePlan.builder() - .id("m2t5akQeh2obwxeU") - .externalPlanId("m2t5akQeh2obwxeU") - .name("Example plan") - .build() - ) - assertThat(plan.basePlanId()).isEqualTo("base_plan_id") assertThat(plan.createdAt()).isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) assertThat(plan.currency()).isEqualTo("currency") assertThat(plan.defaultInvoiceMemo()).isEqualTo("default_invoice_memo") @@ -579,6 +570,15 @@ internal class PlanTest { .build() ) assertThat(plan.version()).isEqualTo(0L) + assertThat(plan.basePlan()) + .isEqualTo( + Plan.BasePlan.builder() + .id("m2t5akQeh2obwxeU") + .externalPlanId("m2t5akQeh2obwxeU") + .name("Example plan") + .build() + ) + assertThat(plan.basePlanId()).isEqualTo("base_plan_id") } @Test @@ -608,14 +608,6 @@ internal class PlanTest { .usageDiscount(0.0) .build() ) - .basePlan( - Plan.BasePlan.builder() - .id("m2t5akQeh2obwxeU") - .externalPlanId("m2t5akQeh2obwxeU") - .name("Example plan") - .build() - ) - .basePlanId("base_plan_id") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .currency("currency") .defaultInvoiceMemo("default_invoice_memo") @@ -859,6 +851,14 @@ internal class PlanTest { .build() ) .version(0L) + .basePlan( + Plan.BasePlan.builder() + .id("m2t5akQeh2obwxeU") + .externalPlanId("m2t5akQeh2obwxeU") + .name("Example plan") + .build() + ) + .basePlanId("base_plan_id") .build() val roundtrippedPlan = diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceTest.kt index d35194549..97ef7c46c 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceTest.kt @@ -161,6 +161,7 @@ internal class PriceTest { assertThat(price.scalableMatrixWithUnitPricing()).isNull() assertThat(price.scalableMatrixWithTieredPricing()).isNull() assertThat(price.cumulativeGroupedBulk()).isNull() + assertThat(price.cumulativeGroupedAllocation()).isNull() assertThat(price.minimum()).isNull() assertThat(price.percent()).isNull() assertThat(price.eventOutput()).isNull() @@ -451,6 +452,7 @@ internal class PriceTest { assertThat(price.scalableMatrixWithUnitPricing()).isNull() assertThat(price.scalableMatrixWithTieredPricing()).isNull() assertThat(price.cumulativeGroupedBulk()).isNull() + assertThat(price.cumulativeGroupedAllocation()).isNull() assertThat(price.minimum()).isNull() assertThat(price.percent()).isNull() assertThat(price.eventOutput()).isNull() @@ -745,6 +747,7 @@ internal class PriceTest { assertThat(price.scalableMatrixWithUnitPricing()).isNull() assertThat(price.scalableMatrixWithTieredPricing()).isNull() assertThat(price.cumulativeGroupedBulk()).isNull() + assertThat(price.cumulativeGroupedAllocation()).isNull() assertThat(price.minimum()).isNull() assertThat(price.percent()).isNull() assertThat(price.eventOutput()).isNull() @@ -1052,6 +1055,7 @@ internal class PriceTest { assertThat(price.scalableMatrixWithUnitPricing()).isNull() assertThat(price.scalableMatrixWithTieredPricing()).isNull() assertThat(price.cumulativeGroupedBulk()).isNull() + assertThat(price.cumulativeGroupedAllocation()).isNull() assertThat(price.minimum()).isNull() assertThat(price.percent()).isNull() assertThat(price.eventOutput()).isNull() @@ -1352,6 +1356,7 @@ internal class PriceTest { assertThat(price.scalableMatrixWithUnitPricing()).isNull() assertThat(price.scalableMatrixWithTieredPricing()).isNull() assertThat(price.cumulativeGroupedBulk()).isNull() + assertThat(price.cumulativeGroupedAllocation()).isNull() assertThat(price.minimum()).isNull() assertThat(price.percent()).isNull() assertThat(price.eventOutput()).isNull() @@ -1645,6 +1650,7 @@ internal class PriceTest { assertThat(price.scalableMatrixWithUnitPricing()).isNull() assertThat(price.scalableMatrixWithTieredPricing()).isNull() assertThat(price.cumulativeGroupedBulk()).isNull() + assertThat(price.cumulativeGroupedAllocation()).isNull() assertThat(price.minimum()).isNull() assertThat(price.percent()).isNull() assertThat(price.eventOutput()).isNull() @@ -1951,6 +1957,7 @@ internal class PriceTest { assertThat(price.scalableMatrixWithUnitPricing()).isNull() assertThat(price.scalableMatrixWithTieredPricing()).isNull() assertThat(price.cumulativeGroupedBulk()).isNull() + assertThat(price.cumulativeGroupedAllocation()).isNull() assertThat(price.minimum()).isNull() assertThat(price.percent()).isNull() assertThat(price.eventOutput()).isNull() @@ -2266,6 +2273,7 @@ internal class PriceTest { assertThat(price.scalableMatrixWithUnitPricing()).isNull() assertThat(price.scalableMatrixWithTieredPricing()).isNull() assertThat(price.cumulativeGroupedBulk()).isNull() + assertThat(price.cumulativeGroupedAllocation()).isNull() assertThat(price.minimum()).isNull() assertThat(price.percent()).isNull() assertThat(price.eventOutput()).isNull() @@ -2578,6 +2586,7 @@ internal class PriceTest { assertThat(price.scalableMatrixWithUnitPricing()).isNull() assertThat(price.scalableMatrixWithTieredPricing()).isNull() assertThat(price.cumulativeGroupedBulk()).isNull() + assertThat(price.cumulativeGroupedAllocation()).isNull() assertThat(price.minimum()).isNull() assertThat(price.percent()).isNull() assertThat(price.eventOutput()).isNull() @@ -2892,6 +2901,7 @@ internal class PriceTest { assertThat(price.scalableMatrixWithUnitPricing()).isNull() assertThat(price.scalableMatrixWithTieredPricing()).isNull() assertThat(price.cumulativeGroupedBulk()).isNull() + assertThat(price.cumulativeGroupedAllocation()).isNull() assertThat(price.minimum()).isNull() assertThat(price.percent()).isNull() assertThat(price.eventOutput()).isNull() @@ -3207,6 +3217,7 @@ internal class PriceTest { assertThat(price.scalableMatrixWithUnitPricing()).isNull() assertThat(price.scalableMatrixWithTieredPricing()).isNull() assertThat(price.cumulativeGroupedBulk()).isNull() + assertThat(price.cumulativeGroupedAllocation()).isNull() assertThat(price.minimum()).isNull() assertThat(price.percent()).isNull() assertThat(price.eventOutput()).isNull() @@ -3517,6 +3528,7 @@ internal class PriceTest { assertThat(price.scalableMatrixWithUnitPricing()).isNull() assertThat(price.scalableMatrixWithTieredPricing()).isNull() assertThat(price.cumulativeGroupedBulk()).isNull() + assertThat(price.cumulativeGroupedAllocation()).isNull() assertThat(price.minimum()).isNull() assertThat(price.percent()).isNull() assertThat(price.eventOutput()).isNull() @@ -3807,6 +3819,7 @@ internal class PriceTest { assertThat(price.scalableMatrixWithUnitPricing()).isNull() assertThat(price.scalableMatrixWithTieredPricing()).isNull() assertThat(price.cumulativeGroupedBulk()).isNull() + assertThat(price.cumulativeGroupedAllocation()).isNull() assertThat(price.minimum()).isNull() assertThat(price.percent()).isNull() assertThat(price.eventOutput()).isNull() @@ -4101,6 +4114,7 @@ internal class PriceTest { assertThat(price.scalableMatrixWithUnitPricing()).isNull() assertThat(price.scalableMatrixWithTieredPricing()).isNull() assertThat(price.cumulativeGroupedBulk()).isNull() + assertThat(price.cumulativeGroupedAllocation()).isNull() assertThat(price.minimum()).isNull() assertThat(price.percent()).isNull() assertThat(price.eventOutput()).isNull() @@ -4401,6 +4415,7 @@ internal class PriceTest { assertThat(price.scalableMatrixWithUnitPricing()).isNull() assertThat(price.scalableMatrixWithTieredPricing()).isNull() assertThat(price.cumulativeGroupedBulk()).isNull() + assertThat(price.cumulativeGroupedAllocation()).isNull() assertThat(price.minimum()).isNull() assertThat(price.percent()).isNull() assertThat(price.eventOutput()).isNull() @@ -4693,6 +4708,7 @@ internal class PriceTest { assertThat(price.scalableMatrixWithUnitPricing()).isNull() assertThat(price.scalableMatrixWithTieredPricing()).isNull() assertThat(price.cumulativeGroupedBulk()).isNull() + assertThat(price.cumulativeGroupedAllocation()).isNull() assertThat(price.minimum()).isNull() assertThat(price.percent()).isNull() assertThat(price.eventOutput()).isNull() @@ -4982,6 +4998,7 @@ internal class PriceTest { assertThat(price.scalableMatrixWithUnitPricing()).isNull() assertThat(price.scalableMatrixWithTieredPricing()).isNull() assertThat(price.cumulativeGroupedBulk()).isNull() + assertThat(price.cumulativeGroupedAllocation()).isNull() assertThat(price.minimum()).isNull() assertThat(price.percent()).isNull() assertThat(price.eventOutput()).isNull() @@ -5282,6 +5299,7 @@ internal class PriceTest { assertThat(price.scalableMatrixWithUnitPricing()).isNull() assertThat(price.scalableMatrixWithTieredPricing()).isNull() assertThat(price.cumulativeGroupedBulk()).isNull() + assertThat(price.cumulativeGroupedAllocation()).isNull() assertThat(price.minimum()).isNull() assertThat(price.percent()).isNull() assertThat(price.eventOutput()).isNull() @@ -5584,6 +5602,7 @@ internal class PriceTest { assertThat(price.scalableMatrixWithUnitPricing()).isNull() assertThat(price.scalableMatrixWithTieredPricing()).isNull() assertThat(price.cumulativeGroupedBulk()).isNull() + assertThat(price.cumulativeGroupedAllocation()).isNull() assertThat(price.minimum()).isNull() assertThat(price.percent()).isNull() assertThat(price.eventOutput()).isNull() @@ -5897,6 +5916,7 @@ internal class PriceTest { assertThat(price.scalableMatrixWithUnitPricing()).isNull() assertThat(price.scalableMatrixWithTieredPricing()).isNull() assertThat(price.cumulativeGroupedBulk()).isNull() + assertThat(price.cumulativeGroupedAllocation()).isNull() assertThat(price.minimum()).isNull() assertThat(price.percent()).isNull() assertThat(price.eventOutput()).isNull() @@ -6213,6 +6233,7 @@ internal class PriceTest { assertThat(price.scalableMatrixWithUnitPricing()).isNull() assertThat(price.scalableMatrixWithTieredPricing()).isNull() assertThat(price.cumulativeGroupedBulk()).isNull() + assertThat(price.cumulativeGroupedAllocation()).isNull() assertThat(price.minimum()).isNull() assertThat(price.percent()).isNull() assertThat(price.eventOutput()).isNull() @@ -6518,6 +6539,7 @@ internal class PriceTest { assertThat(price.scalableMatrixWithUnitPricing()).isNull() assertThat(price.scalableMatrixWithTieredPricing()).isNull() assertThat(price.cumulativeGroupedBulk()).isNull() + assertThat(price.cumulativeGroupedAllocation()).isNull() assertThat(price.minimum()).isNull() assertThat(price.percent()).isNull() assertThat(price.eventOutput()).isNull() @@ -6826,6 +6848,7 @@ internal class PriceTest { assertThat(price.scalableMatrixWithUnitPricing()).isNull() assertThat(price.scalableMatrixWithTieredPricing()).isNull() assertThat(price.cumulativeGroupedBulk()).isNull() + assertThat(price.cumulativeGroupedAllocation()).isNull() assertThat(price.minimum()).isNull() assertThat(price.percent()).isNull() assertThat(price.eventOutput()).isNull() @@ -7141,6 +7164,7 @@ internal class PriceTest { assertThat(price.scalableMatrixWithUnitPricing()).isNull() assertThat(price.scalableMatrixWithTieredPricing()).isNull() assertThat(price.cumulativeGroupedBulk()).isNull() + assertThat(price.cumulativeGroupedAllocation()).isNull() assertThat(price.minimum()).isNull() assertThat(price.percent()).isNull() assertThat(price.eventOutput()).isNull() @@ -7461,6 +7485,7 @@ internal class PriceTest { assertThat(price.scalableMatrixWithUnitPricing()).isEqualTo(scalableMatrixWithUnitPricing) assertThat(price.scalableMatrixWithTieredPricing()).isNull() assertThat(price.cumulativeGroupedBulk()).isNull() + assertThat(price.cumulativeGroupedAllocation()).isNull() assertThat(price.minimum()).isNull() assertThat(price.percent()).isNull() assertThat(price.eventOutput()).isNull() @@ -7803,6 +7828,7 @@ internal class PriceTest { assertThat(price.scalableMatrixWithTieredPricing()) .isEqualTo(scalableMatrixWithTieredPricing) assertThat(price.cumulativeGroupedBulk()).isNull() + assertThat(price.cumulativeGroupedAllocation()).isNull() assertThat(price.minimum()).isNull() assertThat(price.percent()).isNull() assertThat(price.eventOutput()).isNull() @@ -8134,6 +8160,7 @@ internal class PriceTest { assertThat(price.scalableMatrixWithUnitPricing()).isNull() assertThat(price.scalableMatrixWithTieredPricing()).isNull() assertThat(price.cumulativeGroupedBulk()).isEqualTo(cumulativeGroupedBulk) + assertThat(price.cumulativeGroupedAllocation()).isNull() assertThat(price.minimum()).isNull() assertThat(price.percent()).isNull() assertThat(price.eventOutput()).isNull() @@ -8280,6 +8307,309 @@ internal class PriceTest { assertThat(roundtrippedPrice).isEqualTo(price) } + @Test + fun ofCumulativeGroupedAllocation() { + val cumulativeGroupedAllocation = + Price.CumulativeGroupedAllocation.builder() + .id("id") + .billableMetric(BillableMetricTiny.builder().id("id").build()) + .billingCycleConfiguration( + BillingCycleConfiguration.builder() + .duration(0L) + .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) + .build() + ) + .billingMode(Price.CumulativeGroupedAllocation.BillingMode.IN_ADVANCE) + .cadence(Price.CumulativeGroupedAllocation.Cadence.ONE_TIME) + .addCompositePriceFilter( + Price.CumulativeGroupedAllocation.CompositePriceFilter.builder() + .field( + Price.CumulativeGroupedAllocation.CompositePriceFilter.Field.PRICE_ID + ) + .operator( + Price.CumulativeGroupedAllocation.CompositePriceFilter.Operator.INCLUDES + ) + .addValue("string") + .build() + ) + .conversionRate(0.0) + .unitConversionRateConfig( + ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() + ) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditAllocation( + Allocation.builder() + .allowsRollover(true) + .currency("currency") + .customExpiration( + CustomExpiration.builder() + .duration(0L) + .durationUnit(CustomExpiration.DurationUnit.DAY) + .build() + ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator(Allocation.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) + .build() + ) + .cumulativeGroupedAllocationConfig( + Price.CumulativeGroupedAllocation.CumulativeGroupedAllocationConfig.builder() + .cumulativeAllocation("cumulative_allocation") + .groupAllocation("group_allocation") + .groupingKey("x") + .unitAmount("unit_amount") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .addFilter( + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + BillingCycleConfiguration.builder() + .duration(0L) + .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) + .build() + ) + .item(ItemSlim.builder().id("id").name("name").build()) + .maximum( + Maximum.builder() + .addAppliesToPriceId("string") + .addFilter( + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.CumulativeGroupedAllocation.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Minimum.builder() + .addAppliesToPriceId("string") + .addFilter( + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("name") + .planPhaseOrder(0L) + .priceType(Price.CumulativeGroupedAllocation.PriceType.USAGE_PRICE) + .replacesPriceId("replaces_price_id") + .dimensionalPriceConfiguration( + DimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .build() + ) + .build() + + val price = Price.ofCumulativeGroupedAllocation(cumulativeGroupedAllocation) + + assertThat(price.unit()).isNull() + assertThat(price.tiered()).isNull() + assertThat(price.bulk()).isNull() + assertThat(price.bulkWithFilters()).isNull() + assertThat(price.package_()).isNull() + assertThat(price.matrix()).isNull() + assertThat(price.thresholdTotalAmount()).isNull() + assertThat(price.tieredPackage()).isNull() + assertThat(price.tieredWithMinimum()).isNull() + assertThat(price.groupedTiered()).isNull() + assertThat(price.tieredPackageWithMinimum()).isNull() + assertThat(price.packageWithAllocation()).isNull() + assertThat(price.unitWithPercent()).isNull() + assertThat(price.matrixWithAllocation()).isNull() + assertThat(price.tieredWithProration()).isNull() + assertThat(price.unitWithProration()).isNull() + assertThat(price.groupedAllocation()).isNull() + assertThat(price.bulkWithProration()).isNull() + assertThat(price.groupedWithProratedMinimum()).isNull() + assertThat(price.groupedWithMeteredMinimum()).isNull() + assertThat(price.groupedWithMinMaxThresholds()).isNull() + assertThat(price.matrixWithDisplayName()).isNull() + assertThat(price.groupedTieredPackage()).isNull() + assertThat(price.maxGroupTieredPackage()).isNull() + assertThat(price.scalableMatrixWithUnitPricing()).isNull() + assertThat(price.scalableMatrixWithTieredPricing()).isNull() + assertThat(price.cumulativeGroupedBulk()).isNull() + assertThat(price.cumulativeGroupedAllocation()).isEqualTo(cumulativeGroupedAllocation) + assertThat(price.minimum()).isNull() + assertThat(price.percent()).isNull() + assertThat(price.eventOutput()).isNull() + } + + @Test + fun ofCumulativeGroupedAllocationRoundtrip() { + val jsonMapper = jsonMapper() + val price = + Price.ofCumulativeGroupedAllocation( + Price.CumulativeGroupedAllocation.builder() + .id("id") + .billableMetric(BillableMetricTiny.builder().id("id").build()) + .billingCycleConfiguration( + BillingCycleConfiguration.builder() + .duration(0L) + .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) + .build() + ) + .billingMode(Price.CumulativeGroupedAllocation.BillingMode.IN_ADVANCE) + .cadence(Price.CumulativeGroupedAllocation.Cadence.ONE_TIME) + .addCompositePriceFilter( + Price.CumulativeGroupedAllocation.CompositePriceFilter.builder() + .field( + Price.CumulativeGroupedAllocation.CompositePriceFilter.Field + .PRICE_ID + ) + .operator( + Price.CumulativeGroupedAllocation.CompositePriceFilter.Operator + .INCLUDES + ) + .addValue("string") + .build() + ) + .conversionRate(0.0) + .unitConversionRateConfig( + ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() + ) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditAllocation( + Allocation.builder() + .allowsRollover(true) + .currency("currency") + .customExpiration( + CustomExpiration.builder() + .duration(0L) + .durationUnit(CustomExpiration.DurationUnit.DAY) + .build() + ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator(Allocation.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) + .build() + ) + .cumulativeGroupedAllocationConfig( + Price.CumulativeGroupedAllocation.CumulativeGroupedAllocationConfig + .builder() + .cumulativeAllocation("cumulative_allocation") + .groupAllocation("group_allocation") + .groupingKey("x") + .unitAmount("unit_amount") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .addFilter( + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + BillingCycleConfiguration.builder() + .duration(0L) + .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) + .build() + ) + .item(ItemSlim.builder().id("id").name("name").build()) + .maximum( + Maximum.builder() + .addAppliesToPriceId("string") + .addFilter( + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.CumulativeGroupedAllocation.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Minimum.builder() + .addAppliesToPriceId("string") + .addFilter( + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("name") + .planPhaseOrder(0L) + .priceType(Price.CumulativeGroupedAllocation.PriceType.USAGE_PRICE) + .replacesPriceId("replaces_price_id") + .dimensionalPriceConfiguration( + DimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .build() + ) + .build() + ) + + val roundtrippedPrice = + jsonMapper.readValue(jsonMapper.writeValueAsString(price), jacksonTypeRef()) + + assertThat(roundtrippedPrice).isEqualTo(price) + } + @Test fun ofMinimum() { val minimum = @@ -8431,6 +8761,7 @@ internal class PriceTest { assertThat(price.scalableMatrixWithUnitPricing()).isNull() assertThat(price.scalableMatrixWithTieredPricing()).isNull() assertThat(price.cumulativeGroupedBulk()).isNull() + assertThat(price.cumulativeGroupedAllocation()).isNull() assertThat(price.minimum()).isEqualTo(minimum) assertThat(price.percent()).isNull() assertThat(price.eventOutput()).isNull() @@ -8713,6 +9044,7 @@ internal class PriceTest { assertThat(price.scalableMatrixWithUnitPricing()).isNull() assertThat(price.scalableMatrixWithTieredPricing()).isNull() assertThat(price.cumulativeGroupedBulk()).isNull() + assertThat(price.cumulativeGroupedAllocation()).isNull() assertThat(price.minimum()).isNull() assertThat(price.percent()).isEqualTo(percent) assertThat(price.eventOutput()).isNull() @@ -8996,6 +9328,7 @@ internal class PriceTest { assertThat(price.scalableMatrixWithUnitPricing()).isNull() assertThat(price.scalableMatrixWithTieredPricing()).isNull() assertThat(price.cumulativeGroupedBulk()).isNull() + assertThat(price.cumulativeGroupedAllocation()).isNull() assertThat(price.minimum()).isNull() assertThat(price.percent()).isNull() assertThat(price.eventOutput()).isEqualTo(eventOutput) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeApplyResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeApplyResponseTest.kt index e1e8abab4..92af93215 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeApplyResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeApplyResponseTest.kt @@ -261,14 +261,6 @@ internal class SubscriptionChangeApplyResponseTest { .usageDiscount(0.0) .build() ) - .basePlan( - Plan.BasePlan.builder() - .id("m2t5akQeh2obwxeU") - .externalPlanId("m2t5akQeh2obwxeU") - .name("Example plan") - .build() - ) - .basePlanId("base_plan_id") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .currency("currency") .defaultInvoiceMemo("default_invoice_memo") @@ -554,6 +546,14 @@ internal class SubscriptionChangeApplyResponseTest { .build() ) .version(0L) + .basePlan( + Plan.BasePlan.builder() + .id("m2t5akQeh2obwxeU") + .externalPlanId("m2t5akQeh2obwxeU") + .name("Example plan") + .build() + ) + .basePlanId("base_plan_id") .build() ) .addPriceInterval( @@ -2231,14 +2231,6 @@ internal class SubscriptionChangeApplyResponseTest { .usageDiscount(0.0) .build() ) - .basePlan( - Plan.BasePlan.builder() - .id("m2t5akQeh2obwxeU") - .externalPlanId("m2t5akQeh2obwxeU") - .name("Example plan") - .build() - ) - .basePlanId("base_plan_id") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .currency("currency") .defaultInvoiceMemo("default_invoice_memo") @@ -2504,6 +2496,14 @@ internal class SubscriptionChangeApplyResponseTest { .build() ) .version(0L) + .basePlan( + Plan.BasePlan.builder() + .id("m2t5akQeh2obwxeU") + .externalPlanId("m2t5akQeh2obwxeU") + .name("Example plan") + .build() + ) + .basePlanId("base_plan_id") .build() ) .addPriceInterval( @@ -4089,14 +4089,6 @@ internal class SubscriptionChangeApplyResponseTest { .usageDiscount(0.0) .build() ) - .basePlan( - Plan.BasePlan.builder() - .id("m2t5akQeh2obwxeU") - .externalPlanId("m2t5akQeh2obwxeU") - .name("Example plan") - .build() - ) - .basePlanId("base_plan_id") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .currency("currency") .defaultInvoiceMemo("default_invoice_memo") @@ -4382,6 +4374,14 @@ internal class SubscriptionChangeApplyResponseTest { .build() ) .version(0L) + .basePlan( + Plan.BasePlan.builder() + .id("m2t5akQeh2obwxeU") + .externalPlanId("m2t5akQeh2obwxeU") + .name("Example plan") + .build() + ) + .basePlanId("base_plan_id") .build() ) .addPriceInterval( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeCancelResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeCancelResponseTest.kt index 260e42e39..e6183683c 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeCancelResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeCancelResponseTest.kt @@ -261,14 +261,6 @@ internal class SubscriptionChangeCancelResponseTest { .usageDiscount(0.0) .build() ) - .basePlan( - Plan.BasePlan.builder() - .id("m2t5akQeh2obwxeU") - .externalPlanId("m2t5akQeh2obwxeU") - .name("Example plan") - .build() - ) - .basePlanId("base_plan_id") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .currency("currency") .defaultInvoiceMemo("default_invoice_memo") @@ -554,6 +546,14 @@ internal class SubscriptionChangeCancelResponseTest { .build() ) .version(0L) + .basePlan( + Plan.BasePlan.builder() + .id("m2t5akQeh2obwxeU") + .externalPlanId("m2t5akQeh2obwxeU") + .name("Example plan") + .build() + ) + .basePlanId("base_plan_id") .build() ) .addPriceInterval( @@ -2231,14 +2231,6 @@ internal class SubscriptionChangeCancelResponseTest { .usageDiscount(0.0) .build() ) - .basePlan( - Plan.BasePlan.builder() - .id("m2t5akQeh2obwxeU") - .externalPlanId("m2t5akQeh2obwxeU") - .name("Example plan") - .build() - ) - .basePlanId("base_plan_id") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .currency("currency") .defaultInvoiceMemo("default_invoice_memo") @@ -2504,6 +2496,14 @@ internal class SubscriptionChangeCancelResponseTest { .build() ) .version(0L) + .basePlan( + Plan.BasePlan.builder() + .id("m2t5akQeh2obwxeU") + .externalPlanId("m2t5akQeh2obwxeU") + .name("Example plan") + .build() + ) + .basePlanId("base_plan_id") .build() ) .addPriceInterval( @@ -4089,14 +4089,6 @@ internal class SubscriptionChangeCancelResponseTest { .usageDiscount(0.0) .build() ) - .basePlan( - Plan.BasePlan.builder() - .id("m2t5akQeh2obwxeU") - .externalPlanId("m2t5akQeh2obwxeU") - .name("Example plan") - .build() - ) - .basePlanId("base_plan_id") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .currency("currency") .defaultInvoiceMemo("default_invoice_memo") @@ -4382,6 +4374,14 @@ internal class SubscriptionChangeCancelResponseTest { .build() ) .version(0L) + .basePlan( + Plan.BasePlan.builder() + .id("m2t5akQeh2obwxeU") + .externalPlanId("m2t5akQeh2obwxeU") + .name("Example plan") + .build() + ) + .basePlanId("base_plan_id") .build() ) .addPriceInterval( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeRetrieveResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeRetrieveResponseTest.kt index 6d0c99ec2..1b095fa74 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeRetrieveResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeRetrieveResponseTest.kt @@ -261,14 +261,6 @@ internal class SubscriptionChangeRetrieveResponseTest { .usageDiscount(0.0) .build() ) - .basePlan( - Plan.BasePlan.builder() - .id("m2t5akQeh2obwxeU") - .externalPlanId("m2t5akQeh2obwxeU") - .name("Example plan") - .build() - ) - .basePlanId("base_plan_id") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .currency("currency") .defaultInvoiceMemo("default_invoice_memo") @@ -554,6 +546,14 @@ internal class SubscriptionChangeRetrieveResponseTest { .build() ) .version(0L) + .basePlan( + Plan.BasePlan.builder() + .id("m2t5akQeh2obwxeU") + .externalPlanId("m2t5akQeh2obwxeU") + .name("Example plan") + .build() + ) + .basePlanId("base_plan_id") .build() ) .addPriceInterval( @@ -2231,14 +2231,6 @@ internal class SubscriptionChangeRetrieveResponseTest { .usageDiscount(0.0) .build() ) - .basePlan( - Plan.BasePlan.builder() - .id("m2t5akQeh2obwxeU") - .externalPlanId("m2t5akQeh2obwxeU") - .name("Example plan") - .build() - ) - .basePlanId("base_plan_id") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .currency("currency") .defaultInvoiceMemo("default_invoice_memo") @@ -2504,6 +2496,14 @@ internal class SubscriptionChangeRetrieveResponseTest { .build() ) .version(0L) + .basePlan( + Plan.BasePlan.builder() + .id("m2t5akQeh2obwxeU") + .externalPlanId("m2t5akQeh2obwxeU") + .name("Example plan") + .build() + ) + .basePlanId("base_plan_id") .build() ) .addPriceInterval( @@ -4089,14 +4089,6 @@ internal class SubscriptionChangeRetrieveResponseTest { .usageDiscount(0.0) .build() ) - .basePlan( - Plan.BasePlan.builder() - .id("m2t5akQeh2obwxeU") - .externalPlanId("m2t5akQeh2obwxeU") - .name("Example plan") - .build() - ) - .basePlanId("base_plan_id") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .currency("currency") .defaultInvoiceMemo("default_invoice_memo") @@ -4382,6 +4374,14 @@ internal class SubscriptionChangeRetrieveResponseTest { .build() ) .version(0L) + .basePlan( + Plan.BasePlan.builder() + .id("m2t5akQeh2obwxeU") + .externalPlanId("m2t5akQeh2obwxeU") + .name("Example plan") + .build() + ) + .basePlanId("base_plan_id") .build() ) .addPriceInterval( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionTest.kt index 1b17aae96..015bf6dd6 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionTest.kt @@ -241,14 +241,6 @@ internal class SubscriptionTest { .usageDiscount(0.0) .build() ) - .basePlan( - Plan.BasePlan.builder() - .id("m2t5akQeh2obwxeU") - .externalPlanId("m2t5akQeh2obwxeU") - .name("Example plan") - .build() - ) - .basePlanId("base_plan_id") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .currency("currency") .defaultInvoiceMemo("default_invoice_memo") @@ -503,6 +495,14 @@ internal class SubscriptionTest { .build() ) .version(0L) + .basePlan( + Plan.BasePlan.builder() + .id("m2t5akQeh2obwxeU") + .externalPlanId("m2t5akQeh2obwxeU") + .name("Example plan") + .build() + ) + .basePlanId("base_plan_id") .build() ) .addPriceInterval( @@ -904,14 +904,6 @@ internal class SubscriptionTest { .usageDiscount(0.0) .build() ) - .basePlan( - Plan.BasePlan.builder() - .id("m2t5akQeh2obwxeU") - .externalPlanId("m2t5akQeh2obwxeU") - .name("Example plan") - .build() - ) - .basePlanId("base_plan_id") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .currency("currency") .defaultInvoiceMemo("default_invoice_memo") @@ -1160,6 +1152,14 @@ internal class SubscriptionTest { .build() ) .version(0L) + .basePlan( + Plan.BasePlan.builder() + .id("m2t5akQeh2obwxeU") + .externalPlanId("m2t5akQeh2obwxeU") + .name("Example plan") + .build() + ) + .basePlanId("base_plan_id") .build() ) assertThat(subscription.priceIntervals()) @@ -1555,14 +1555,6 @@ internal class SubscriptionTest { .usageDiscount(0.0) .build() ) - .basePlan( - Plan.BasePlan.builder() - .id("m2t5akQeh2obwxeU") - .externalPlanId("m2t5akQeh2obwxeU") - .name("Example plan") - .build() - ) - .basePlanId("base_plan_id") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .currency("currency") .defaultInvoiceMemo("default_invoice_memo") @@ -1817,6 +1809,14 @@ internal class SubscriptionTest { .build() ) .version(0L) + .basePlan( + Plan.BasePlan.builder() + .id("m2t5akQeh2obwxeU") + .externalPlanId("m2t5akQeh2obwxeU") + .name("Example plan") + .build() + ) + .basePlanId("base_plan_id") .build() ) .addPriceInterval( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionsTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionsTest.kt index 2970d8eb5..7ec1eabad 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionsTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionsTest.kt @@ -258,14 +258,6 @@ internal class SubscriptionsTest { .usageDiscount(0.0) .build() ) - .basePlan( - Plan.BasePlan.builder() - .id("m2t5akQeh2obwxeU") - .externalPlanId("m2t5akQeh2obwxeU") - .name("Example plan") - .build() - ) - .basePlanId("base_plan_id") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .currency("currency") .defaultInvoiceMemo("default_invoice_memo") @@ -551,6 +543,14 @@ internal class SubscriptionsTest { .build() ) .version(0L) + .basePlan( + Plan.BasePlan.builder() + .id("m2t5akQeh2obwxeU") + .externalPlanId("m2t5akQeh2obwxeU") + .name("Example plan") + .build() + ) + .basePlanId("base_plan_id") .build() ) .addPriceInterval( @@ -986,14 +986,6 @@ internal class SubscriptionsTest { .usageDiscount(0.0) .build() ) - .basePlan( - Plan.BasePlan.builder() - .id("m2t5akQeh2obwxeU") - .externalPlanId("m2t5akQeh2obwxeU") - .name("Example plan") - .build() - ) - .basePlanId("base_plan_id") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .currency("currency") .defaultInvoiceMemo("default_invoice_memo") @@ -1259,6 +1251,14 @@ internal class SubscriptionsTest { .build() ) .version(0L) + .basePlan( + Plan.BasePlan.builder() + .id("m2t5akQeh2obwxeU") + .externalPlanId("m2t5akQeh2obwxeU") + .name("Example plan") + .build() + ) + .basePlanId("base_plan_id") .build() ) .addPriceInterval( @@ -1688,14 +1688,6 @@ internal class SubscriptionsTest { .usageDiscount(0.0) .build() ) - .basePlan( - Plan.BasePlan.builder() - .id("m2t5akQeh2obwxeU") - .externalPlanId("m2t5akQeh2obwxeU") - .name("Example plan") - .build() - ) - .basePlanId("base_plan_id") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .currency("currency") .defaultInvoiceMemo("default_invoice_memo") @@ -1981,6 +1973,14 @@ internal class SubscriptionsTest { .build() ) .version(0L) + .basePlan( + Plan.BasePlan.builder() + .id("m2t5akQeh2obwxeU") + .externalPlanId("m2t5akQeh2obwxeU") + .name("Example plan") + .build() + ) + .basePlanId("base_plan_id") .build() ) .addPriceInterval( From 74b29eac5934c4d52380859df2df42a5c6b8db46 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Sun, 16 Nov 2025 04:27:16 +0000 Subject: [PATCH 51/68] feat(api): api update --- .stats.yml | 4 +- .../kotlin/com/withorb/api/models/Plan.kt | 648 +++++++++--------- .../api/models/MutatedSubscriptionTest.kt | 48 +- .../api/models/PlanListPageResponseTest.kt | 48 +- .../kotlin/com/withorb/api/models/PlanTest.kt | 50 +- .../SubscriptionChangeApplyResponseTest.kt | 48 +- .../SubscriptionChangeCancelResponseTest.kt | 48 +- .../SubscriptionChangeRetrieveResponseTest.kt | 48 +- .../withorb/api/models/SubscriptionTest.kt | 48 +- .../withorb/api/models/SubscriptionsTest.kt | 48 +- 10 files changed, 521 insertions(+), 517 deletions(-) diff --git a/.stats.yml b/.stats.yml index 30ac7b667..3cb33be6a 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 118 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-947253d9be505473c1c2cb0193d2602fa6b017e221f482be3f4f374c6156b350.yml -openapi_spec_hash: 1b40d1a85b4b846a1c14634fbbc65da3 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-4ad3b44ca7f484243d8706b6aa7f4498fc5bf2b37fadf3da0a06d657e482c08f.yml +openapi_spec_hash: 9ead1a2aae36be1086c627c3636064ea config_hash: e6db17547fe854b1c240407cf4c6dc9e diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Plan.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Plan.kt index 8663ebdef..33da624f2 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Plan.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Plan.kt @@ -39,6 +39,8 @@ class Plan private constructor( private val id: JsonField, private val adjustments: JsonField>, + private val basePlan: JsonField, + private val basePlanId: JsonField, private val createdAt: JsonField, private val currency: JsonField, private val defaultInvoiceMemo: JsonField, @@ -59,8 +61,6 @@ private constructor( private val status: JsonField, private val trialConfig: JsonField, private val version: JsonField, - private val basePlan: JsonField, - private val basePlanId: JsonField, private val additionalProperties: MutableMap, ) { @@ -70,6 +70,10 @@ private constructor( @JsonProperty("adjustments") @ExcludeMissing adjustments: JsonField> = JsonMissing.of(), + @JsonProperty("base_plan") @ExcludeMissing basePlan: JsonField = JsonMissing.of(), + @JsonProperty("base_plan_id") + @ExcludeMissing + basePlanId: JsonField = JsonMissing.of(), @JsonProperty("created_at") @ExcludeMissing createdAt: JsonField = JsonMissing.of(), @@ -108,13 +112,11 @@ private constructor( @ExcludeMissing trialConfig: JsonField = JsonMissing.of(), @JsonProperty("version") @ExcludeMissing version: JsonField = JsonMissing.of(), - @JsonProperty("base_plan") @ExcludeMissing basePlan: JsonField = JsonMissing.of(), - @JsonProperty("base_plan_id") - @ExcludeMissing - basePlanId: JsonField = JsonMissing.of(), ) : this( id, adjustments, + basePlan, + basePlanId, createdAt, currency, defaultInvoiceMemo, @@ -135,8 +137,6 @@ private constructor( status, trialConfig, version, - basePlan, - basePlanId, mutableMapOf(), ) @@ -155,6 +155,21 @@ private constructor( */ fun adjustments(): List = adjustments.getRequired("adjustments") + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun basePlan(): BasePlan? = basePlan.getNullable("base_plan") + + /** + * The parent plan id if the given plan was created by overriding one or more of the parent's + * prices + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun basePlanId(): String? = basePlanId.getNullable("base_plan_id") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). @@ -300,21 +315,6 @@ private constructor( */ fun version(): Long = version.getRequired("version") - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - fun basePlan(): BasePlan? = basePlan.getNullable("base_plan") - - /** - * The parent plan id if the given plan was created by overriding one or more of the parent's - * prices - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - fun basePlanId(): String? = basePlanId.getNullable("base_plan_id") - /** * Returns the raw JSON value of [id]. * @@ -331,6 +331,20 @@ private constructor( @ExcludeMissing fun _adjustments(): JsonField> = adjustments + /** + * Returns the raw JSON value of [basePlan]. + * + * Unlike [basePlan], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("base_plan") @ExcludeMissing fun _basePlan(): JsonField = basePlan + + /** + * Returns the raw JSON value of [basePlanId]. + * + * Unlike [basePlanId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("base_plan_id") @ExcludeMissing fun _basePlanId(): JsonField = basePlanId + /** * Returns the raw JSON value of [createdAt]. * @@ -503,20 +517,6 @@ private constructor( */ @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version - /** - * Returns the raw JSON value of [basePlan]. - * - * Unlike [basePlan], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("base_plan") @ExcludeMissing fun _basePlan(): JsonField = basePlan - - /** - * Returns the raw JSON value of [basePlanId]. - * - * Unlike [basePlanId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("base_plan_id") @ExcludeMissing fun _basePlanId(): JsonField = basePlanId - @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -538,6 +538,8 @@ private constructor( * ```kotlin * .id() * .adjustments() + * .basePlan() + * .basePlanId() * .createdAt() * .currency() * .defaultInvoiceMemo() @@ -568,6 +570,8 @@ private constructor( private var id: JsonField? = null private var adjustments: JsonField>? = null + private var basePlan: JsonField? = null + private var basePlanId: JsonField? = null private var createdAt: JsonField? = null private var currency: JsonField? = null private var defaultInvoiceMemo: JsonField? = null @@ -588,13 +592,13 @@ private constructor( private var status: JsonField? = null private var trialConfig: JsonField? = null private var version: JsonField? = null - private var basePlan: JsonField = JsonMissing.of() - private var basePlanId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() internal fun from(plan: Plan) = apply { id = plan.id adjustments = plan.adjustments.map { it.toMutableList() } + basePlan = plan.basePlan + basePlanId = plan.basePlanId createdAt = plan.createdAt currency = plan.currency defaultInvoiceMemo = plan.defaultInvoiceMemo @@ -615,8 +619,6 @@ private constructor( status = plan.status trialConfig = plan.trialConfig version = plan.version - basePlan = plan.basePlan - basePlanId = plan.basePlanId additionalProperties = plan.additionalProperties.toMutableMap() } @@ -682,6 +684,32 @@ private constructor( fun addAdjustment(maximum: PlanPhaseMaximumAdjustment) = addAdjustment(Adjustment.ofMaximum(maximum)) + fun basePlan(basePlan: BasePlan?) = basePlan(JsonField.ofNullable(basePlan)) + + /** + * Sets [Builder.basePlan] to an arbitrary JSON value. + * + * You should usually call [Builder.basePlan] with a well-typed [BasePlan] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun basePlan(basePlan: JsonField) = apply { this.basePlan = basePlan } + + /** + * The parent plan id if the given plan was created by overriding one or more of the + * parent's prices + */ + fun basePlanId(basePlanId: String?) = basePlanId(JsonField.ofNullable(basePlanId)) + + /** + * Sets [Builder.basePlanId] to an arbitrary JSON value. + * + * You should usually call [Builder.basePlanId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun basePlanId(basePlanId: JsonField) = apply { this.basePlanId = basePlanId } + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) /** @@ -1209,32 +1237,6 @@ private constructor( */ fun version(version: JsonField) = apply { this.version = version } - fun basePlan(basePlan: BasePlan?) = basePlan(JsonField.ofNullable(basePlan)) - - /** - * Sets [Builder.basePlan] to an arbitrary JSON value. - * - * You should usually call [Builder.basePlan] with a well-typed [BasePlan] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun basePlan(basePlan: JsonField) = apply { this.basePlan = basePlan } - - /** - * The parent plan id if the given plan was created by overriding one or more of the - * parent's prices - */ - fun basePlanId(basePlanId: String?) = basePlanId(JsonField.ofNullable(basePlanId)) - - /** - * Sets [Builder.basePlanId] to an arbitrary JSON value. - * - * You should usually call [Builder.basePlanId] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun basePlanId(basePlanId: JsonField) = apply { this.basePlanId = basePlanId } - fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -1263,6 +1265,8 @@ private constructor( * ```kotlin * .id() * .adjustments() + * .basePlan() + * .basePlanId() * .createdAt() * .currency() * .defaultInvoiceMemo() @@ -1291,6 +1295,8 @@ private constructor( Plan( checkRequired("id", id), checkRequired("adjustments", adjustments).map { it.toImmutable() }, + checkRequired("basePlan", basePlan), + checkRequired("basePlanId", basePlanId), checkRequired("createdAt", createdAt), checkRequired("currency", currency), checkRequired("defaultInvoiceMemo", defaultInvoiceMemo), @@ -1311,8 +1317,6 @@ private constructor( checkRequired("status", status), checkRequired("trialConfig", trialConfig), checkRequired("version", version), - basePlan, - basePlanId, additionalProperties.toMutableMap(), ) } @@ -1326,6 +1330,8 @@ private constructor( id() adjustments().forEach { it.validate() } + basePlan()?.validate() + basePlanId() createdAt() currency() defaultInvoiceMemo() @@ -1346,8 +1352,6 @@ private constructor( status().validate() trialConfig().validate() version() - basePlan()?.validate() - basePlanId() validated = true } @@ -1367,6 +1371,8 @@ private constructor( internal fun validity(): Int = (if (id.asKnown() == null) 0 else 1) + (adjustments.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + (basePlan.asKnown()?.validity() ?: 0) + + (if (basePlanId.asKnown() == null) 0 else 1) + (if (createdAt.asKnown() == null) 0 else 1) + (if (currency.asKnown() == null) 0 else 1) + (if (defaultInvoiceMemo.asKnown() == null) 0 else 1) + @@ -1386,9 +1392,7 @@ private constructor( (product.asKnown()?.validity() ?: 0) + (status.asKnown()?.validity() ?: 0) + (trialConfig.asKnown()?.validity() ?: 0) + - (if (version.asKnown() == null) 0 else 1) + - (basePlan.asKnown()?.validity() ?: 0) + - (if (basePlanId.asKnown() == null) 0 else 1) + (if (version.asKnown() == null) 0 else 1) @JsonDeserialize(using = Adjustment.Deserializer::class) @JsonSerialize(using = Adjustment.Serializer::class) @@ -1668,6 +1672,249 @@ private constructor( } } + class BasePlan + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val externalPlanId: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("external_plan_id") + @ExcludeMissing + externalPlanId: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(id, externalPlanId, name, mutableMapOf()) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun id(): String? = id.getNullable("id") + + /** + * An optional user-defined ID for this plan resource, used throughout the system as an + * alias for this Plan. Use this field to identify a plan by an existing identifier in your + * system. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun externalPlanId(): String? = externalPlanId.getNullable("external_plan_id") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun name(): String? = name.getNullable("name") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [externalPlanId]. + * + * Unlike [externalPlanId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("external_plan_id") + @ExcludeMissing + fun _externalPlanId(): JsonField = externalPlanId + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [BasePlan]. + * + * The following fields are required: + * ```kotlin + * .id() + * .externalPlanId() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [BasePlan]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var externalPlanId: JsonField? = null + private var name: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(basePlan: BasePlan) = apply { + id = basePlan.id + externalPlanId = basePlan.externalPlanId + name = basePlan.name + additionalProperties = basePlan.additionalProperties.toMutableMap() + } + + fun id(id: String?) = id(JsonField.ofNullable(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun id(id: JsonField) = apply { this.id = id } + + /** + * An optional user-defined ID for this plan resource, used throughout the system as an + * alias for this Plan. Use this field to identify a plan by an existing identifier in + * your system. + */ + fun externalPlanId(externalPlanId: String?) = + externalPlanId(JsonField.ofNullable(externalPlanId)) + + /** + * Sets [Builder.externalPlanId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPlanId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun externalPlanId(externalPlanId: JsonField) = apply { + this.externalPlanId = externalPlanId + } + + fun name(name: String?) = name(JsonField.ofNullable(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BasePlan]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .id() + * .externalPlanId() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BasePlan = + BasePlan( + checkRequired("id", id), + checkRequired("externalPlanId", externalPlanId), + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): BasePlan = apply { + if (validated) { + return@apply + } + + id() + externalPlanId() + name() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (id.asKnown() == null) 0 else 1) + + (if (externalPlanId.asKnown() == null) 0 else 1) + + (if (name.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BasePlan && + id == other.id && + externalPlanId == other.externalPlanId && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, externalPlanId, name, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BasePlan{id=$id, externalPlanId=$externalPlanId, name=$name, additionalProperties=$additionalProperties}" + } + /** * User specified key-value pairs for the resource. If not present, this defaults to an empty * dictionary. Individual keys can be removed by setting the value to `null`, and the entire @@ -3251,249 +3498,6 @@ private constructor( "TrialConfig{trialPeriod=$trialPeriod, trialPeriodUnit=$trialPeriodUnit, additionalProperties=$additionalProperties}" } - class BasePlan - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val id: JsonField, - private val externalPlanId: JsonField, - private val name: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), - @JsonProperty("external_plan_id") - @ExcludeMissing - externalPlanId: JsonField = JsonMissing.of(), - @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - ) : this(id, externalPlanId, name, mutableMapOf()) - - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun id(): String? = id.getNullable("id") - - /** - * An optional user-defined ID for this plan resource, used throughout the system as an - * alias for this Plan. Use this field to identify a plan by an existing identifier in your - * system. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun externalPlanId(): String? = externalPlanId.getNullable("external_plan_id") - - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun name(): String? = name.getNullable("name") - - /** - * Returns the raw JSON value of [id]. - * - * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - /** - * Returns the raw JSON value of [externalPlanId]. - * - * Unlike [externalPlanId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("external_plan_id") - @ExcludeMissing - fun _externalPlanId(): JsonField = externalPlanId - - /** - * Returns the raw JSON value of [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [BasePlan]. - * - * The following fields are required: - * ```kotlin - * .id() - * .externalPlanId() - * .name() - * ``` - */ - fun builder() = Builder() - } - - /** A builder for [BasePlan]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var externalPlanId: JsonField? = null - private var name: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(basePlan: BasePlan) = apply { - id = basePlan.id - externalPlanId = basePlan.externalPlanId - name = basePlan.name - additionalProperties = basePlan.additionalProperties.toMutableMap() - } - - fun id(id: String?) = id(JsonField.ofNullable(id)) - - /** - * Sets [Builder.id] to an arbitrary JSON value. - * - * You should usually call [Builder.id] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun id(id: JsonField) = apply { this.id = id } - - /** - * An optional user-defined ID for this plan resource, used throughout the system as an - * alias for this Plan. Use this field to identify a plan by an existing identifier in - * your system. - */ - fun externalPlanId(externalPlanId: String?) = - externalPlanId(JsonField.ofNullable(externalPlanId)) - - /** - * Sets [Builder.externalPlanId] to an arbitrary JSON value. - * - * You should usually call [Builder.externalPlanId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun externalPlanId(externalPlanId: JsonField) = apply { - this.externalPlanId = externalPlanId - } - - fun name(name: String?) = name(JsonField.ofNullable(name)) - - /** - * Sets [Builder.name] to an arbitrary JSON value. - * - * You should usually call [Builder.name] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun name(name: JsonField) = apply { this.name = name } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [BasePlan]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```kotlin - * .id() - * .externalPlanId() - * .name() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): BasePlan = - BasePlan( - checkRequired("id", id), - checkRequired("externalPlanId", externalPlanId), - checkRequired("name", name), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): BasePlan = apply { - if (validated) { - return@apply - } - - id() - externalPlanId() - name() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (if (id.asKnown() == null) 0 else 1) + - (if (externalPlanId.asKnown() == null) 0 else 1) + - (if (name.asKnown() == null) 0 else 1) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is BasePlan && - id == other.id && - externalPlanId == other.externalPlanId && - name == other.name && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(id, externalPlanId, name, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BasePlan{id=$id, externalPlanId=$externalPlanId, name=$name, additionalProperties=$additionalProperties}" - } - override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -3502,6 +3506,8 @@ private constructor( return other is Plan && id == other.id && adjustments == other.adjustments && + basePlan == other.basePlan && + basePlanId == other.basePlanId && createdAt == other.createdAt && currency == other.currency && defaultInvoiceMemo == other.defaultInvoiceMemo && @@ -3522,8 +3528,6 @@ private constructor( status == other.status && trialConfig == other.trialConfig && version == other.version && - basePlan == other.basePlan && - basePlanId == other.basePlanId && additionalProperties == other.additionalProperties } @@ -3531,6 +3535,8 @@ private constructor( Objects.hash( id, adjustments, + basePlan, + basePlanId, createdAt, currency, defaultInvoiceMemo, @@ -3551,8 +3557,6 @@ private constructor( status, trialConfig, version, - basePlan, - basePlanId, additionalProperties, ) } @@ -3560,5 +3564,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Plan{id=$id, adjustments=$adjustments, createdAt=$createdAt, currency=$currency, defaultInvoiceMemo=$defaultInvoiceMemo, description=$description, discount=$discount, externalPlanId=$externalPlanId, invoicingCurrency=$invoicingCurrency, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, name=$name, netTerms=$netTerms, planPhases=$planPhases, prices=$prices, product=$product, status=$status, trialConfig=$trialConfig, version=$version, basePlan=$basePlan, basePlanId=$basePlanId, additionalProperties=$additionalProperties}" + "Plan{id=$id, adjustments=$adjustments, basePlan=$basePlan, basePlanId=$basePlanId, createdAt=$createdAt, currency=$currency, defaultInvoiceMemo=$defaultInvoiceMemo, description=$description, discount=$discount, externalPlanId=$externalPlanId, invoicingCurrency=$invoicingCurrency, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, name=$name, netTerms=$netTerms, planPhases=$planPhases, prices=$prices, product=$product, status=$status, trialConfig=$trialConfig, version=$version, additionalProperties=$additionalProperties}" } diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/MutatedSubscriptionTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/MutatedSubscriptionTest.kt index 8426d3f31..b166f9486 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/MutatedSubscriptionTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/MutatedSubscriptionTest.kt @@ -241,6 +241,14 @@ internal class MutatedSubscriptionTest { .usageDiscount(0.0) .build() ) + .basePlan( + Plan.BasePlan.builder() + .id("m2t5akQeh2obwxeU") + .externalPlanId("m2t5akQeh2obwxeU") + .name("Example plan") + .build() + ) + .basePlanId("base_plan_id") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .currency("currency") .defaultInvoiceMemo("default_invoice_memo") @@ -495,14 +503,6 @@ internal class MutatedSubscriptionTest { .build() ) .version(0L) - .basePlan( - Plan.BasePlan.builder() - .id("m2t5akQeh2obwxeU") - .externalPlanId("m2t5akQeh2obwxeU") - .name("Example plan") - .build() - ) - .basePlanId("base_plan_id") .build() ) .addPriceInterval( @@ -1960,6 +1960,14 @@ internal class MutatedSubscriptionTest { .usageDiscount(0.0) .build() ) + .basePlan( + Plan.BasePlan.builder() + .id("m2t5akQeh2obwxeU") + .externalPlanId("m2t5akQeh2obwxeU") + .name("Example plan") + .build() + ) + .basePlanId("base_plan_id") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .currency("currency") .defaultInvoiceMemo("default_invoice_memo") @@ -2208,14 +2216,6 @@ internal class MutatedSubscriptionTest { .build() ) .version(0L) - .basePlan( - Plan.BasePlan.builder() - .id("m2t5akQeh2obwxeU") - .externalPlanId("m2t5akQeh2obwxeU") - .name("Example plan") - .build() - ) - .basePlanId("base_plan_id") .build() ) assertThat(mutatedSubscription.priceIntervals()) @@ -3604,6 +3604,14 @@ internal class MutatedSubscriptionTest { .usageDiscount(0.0) .build() ) + .basePlan( + Plan.BasePlan.builder() + .id("m2t5akQeh2obwxeU") + .externalPlanId("m2t5akQeh2obwxeU") + .name("Example plan") + .build() + ) + .basePlanId("base_plan_id") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .currency("currency") .defaultInvoiceMemo("default_invoice_memo") @@ -3858,14 +3866,6 @@ internal class MutatedSubscriptionTest { .build() ) .version(0L) - .basePlan( - Plan.BasePlan.builder() - .id("m2t5akQeh2obwxeU") - .externalPlanId("m2t5akQeh2obwxeU") - .name("Example plan") - .build() - ) - .basePlanId("base_plan_id") .build() ) .addPriceInterval( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanListPageResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanListPageResponseTest.kt index c7638e398..f88092a24 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanListPageResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanListPageResponseTest.kt @@ -44,6 +44,14 @@ internal class PlanListPageResponseTest { .usageDiscount(0.0) .build() ) + .basePlan( + Plan.BasePlan.builder() + .id("m2t5akQeh2obwxeU") + .externalPlanId("m2t5akQeh2obwxeU") + .name("Example plan") + .build() + ) + .basePlanId("base_plan_id") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .currency("currency") .defaultInvoiceMemo("default_invoice_memo") @@ -298,14 +306,6 @@ internal class PlanListPageResponseTest { .build() ) .version(0L) - .basePlan( - Plan.BasePlan.builder() - .id("m2t5akQeh2obwxeU") - .externalPlanId("m2t5akQeh2obwxeU") - .name("Example plan") - .build() - ) - .basePlanId("base_plan_id") .build() ) .paginationMetadata( @@ -340,6 +340,14 @@ internal class PlanListPageResponseTest { .usageDiscount(0.0) .build() ) + .basePlan( + Plan.BasePlan.builder() + .id("m2t5akQeh2obwxeU") + .externalPlanId("m2t5akQeh2obwxeU") + .name("Example plan") + .build() + ) + .basePlanId("base_plan_id") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .currency("currency") .defaultInvoiceMemo("default_invoice_memo") @@ -588,14 +596,6 @@ internal class PlanListPageResponseTest { .build() ) .version(0L) - .basePlan( - Plan.BasePlan.builder() - .id("m2t5akQeh2obwxeU") - .externalPlanId("m2t5akQeh2obwxeU") - .name("Example plan") - .build() - ) - .basePlanId("base_plan_id") .build() ) assertThat(planListPageResponse.paginationMetadata()) @@ -636,6 +636,14 @@ internal class PlanListPageResponseTest { .usageDiscount(0.0) .build() ) + .basePlan( + Plan.BasePlan.builder() + .id("m2t5akQeh2obwxeU") + .externalPlanId("m2t5akQeh2obwxeU") + .name("Example plan") + .build() + ) + .basePlanId("base_plan_id") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .currency("currency") .defaultInvoiceMemo("default_invoice_memo") @@ -890,14 +898,6 @@ internal class PlanListPageResponseTest { .build() ) .version(0L) - .basePlan( - Plan.BasePlan.builder() - .id("m2t5akQeh2obwxeU") - .externalPlanId("m2t5akQeh2obwxeU") - .name("Example plan") - .build() - ) - .basePlanId("base_plan_id") .build() ) .paginationMetadata( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanTest.kt index 07ec83581..b62525d63 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanTest.kt @@ -37,6 +37,14 @@ internal class PlanTest { .usageDiscount(0.0) .build() ) + .basePlan( + Plan.BasePlan.builder() + .id("m2t5akQeh2obwxeU") + .externalPlanId("m2t5akQeh2obwxeU") + .name("Example plan") + .build() + ) + .basePlanId("base_plan_id") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .currency("currency") .defaultInvoiceMemo("default_invoice_memo") @@ -280,14 +288,6 @@ internal class PlanTest { .build() ) .version(0L) - .basePlan( - Plan.BasePlan.builder() - .id("m2t5akQeh2obwxeU") - .externalPlanId("m2t5akQeh2obwxeU") - .name("Example plan") - .build() - ) - .basePlanId("base_plan_id") .build() assertThat(plan.id()).isEqualTo("id") @@ -315,6 +315,15 @@ internal class PlanTest { .build() ) ) + assertThat(plan.basePlan()) + .isEqualTo( + Plan.BasePlan.builder() + .id("m2t5akQeh2obwxeU") + .externalPlanId("m2t5akQeh2obwxeU") + .name("Example plan") + .build() + ) + assertThat(plan.basePlanId()).isEqualTo("base_plan_id") assertThat(plan.createdAt()).isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) assertThat(plan.currency()).isEqualTo("currency") assertThat(plan.defaultInvoiceMemo()).isEqualTo("default_invoice_memo") @@ -570,15 +579,6 @@ internal class PlanTest { .build() ) assertThat(plan.version()).isEqualTo(0L) - assertThat(plan.basePlan()) - .isEqualTo( - Plan.BasePlan.builder() - .id("m2t5akQeh2obwxeU") - .externalPlanId("m2t5akQeh2obwxeU") - .name("Example plan") - .build() - ) - assertThat(plan.basePlanId()).isEqualTo("base_plan_id") } @Test @@ -608,6 +608,14 @@ internal class PlanTest { .usageDiscount(0.0) .build() ) + .basePlan( + Plan.BasePlan.builder() + .id("m2t5akQeh2obwxeU") + .externalPlanId("m2t5akQeh2obwxeU") + .name("Example plan") + .build() + ) + .basePlanId("base_plan_id") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .currency("currency") .defaultInvoiceMemo("default_invoice_memo") @@ -851,14 +859,6 @@ internal class PlanTest { .build() ) .version(0L) - .basePlan( - Plan.BasePlan.builder() - .id("m2t5akQeh2obwxeU") - .externalPlanId("m2t5akQeh2obwxeU") - .name("Example plan") - .build() - ) - .basePlanId("base_plan_id") .build() val roundtrippedPlan = diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeApplyResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeApplyResponseTest.kt index 92af93215..e1e8abab4 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeApplyResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeApplyResponseTest.kt @@ -261,6 +261,14 @@ internal class SubscriptionChangeApplyResponseTest { .usageDiscount(0.0) .build() ) + .basePlan( + Plan.BasePlan.builder() + .id("m2t5akQeh2obwxeU") + .externalPlanId("m2t5akQeh2obwxeU") + .name("Example plan") + .build() + ) + .basePlanId("base_plan_id") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .currency("currency") .defaultInvoiceMemo("default_invoice_memo") @@ -546,14 +554,6 @@ internal class SubscriptionChangeApplyResponseTest { .build() ) .version(0L) - .basePlan( - Plan.BasePlan.builder() - .id("m2t5akQeh2obwxeU") - .externalPlanId("m2t5akQeh2obwxeU") - .name("Example plan") - .build() - ) - .basePlanId("base_plan_id") .build() ) .addPriceInterval( @@ -2231,6 +2231,14 @@ internal class SubscriptionChangeApplyResponseTest { .usageDiscount(0.0) .build() ) + .basePlan( + Plan.BasePlan.builder() + .id("m2t5akQeh2obwxeU") + .externalPlanId("m2t5akQeh2obwxeU") + .name("Example plan") + .build() + ) + .basePlanId("base_plan_id") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .currency("currency") .defaultInvoiceMemo("default_invoice_memo") @@ -2496,14 +2504,6 @@ internal class SubscriptionChangeApplyResponseTest { .build() ) .version(0L) - .basePlan( - Plan.BasePlan.builder() - .id("m2t5akQeh2obwxeU") - .externalPlanId("m2t5akQeh2obwxeU") - .name("Example plan") - .build() - ) - .basePlanId("base_plan_id") .build() ) .addPriceInterval( @@ -4089,6 +4089,14 @@ internal class SubscriptionChangeApplyResponseTest { .usageDiscount(0.0) .build() ) + .basePlan( + Plan.BasePlan.builder() + .id("m2t5akQeh2obwxeU") + .externalPlanId("m2t5akQeh2obwxeU") + .name("Example plan") + .build() + ) + .basePlanId("base_plan_id") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .currency("currency") .defaultInvoiceMemo("default_invoice_memo") @@ -4374,14 +4382,6 @@ internal class SubscriptionChangeApplyResponseTest { .build() ) .version(0L) - .basePlan( - Plan.BasePlan.builder() - .id("m2t5akQeh2obwxeU") - .externalPlanId("m2t5akQeh2obwxeU") - .name("Example plan") - .build() - ) - .basePlanId("base_plan_id") .build() ) .addPriceInterval( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeCancelResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeCancelResponseTest.kt index e6183683c..260e42e39 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeCancelResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeCancelResponseTest.kt @@ -261,6 +261,14 @@ internal class SubscriptionChangeCancelResponseTest { .usageDiscount(0.0) .build() ) + .basePlan( + Plan.BasePlan.builder() + .id("m2t5akQeh2obwxeU") + .externalPlanId("m2t5akQeh2obwxeU") + .name("Example plan") + .build() + ) + .basePlanId("base_plan_id") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .currency("currency") .defaultInvoiceMemo("default_invoice_memo") @@ -546,14 +554,6 @@ internal class SubscriptionChangeCancelResponseTest { .build() ) .version(0L) - .basePlan( - Plan.BasePlan.builder() - .id("m2t5akQeh2obwxeU") - .externalPlanId("m2t5akQeh2obwxeU") - .name("Example plan") - .build() - ) - .basePlanId("base_plan_id") .build() ) .addPriceInterval( @@ -2231,6 +2231,14 @@ internal class SubscriptionChangeCancelResponseTest { .usageDiscount(0.0) .build() ) + .basePlan( + Plan.BasePlan.builder() + .id("m2t5akQeh2obwxeU") + .externalPlanId("m2t5akQeh2obwxeU") + .name("Example plan") + .build() + ) + .basePlanId("base_plan_id") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .currency("currency") .defaultInvoiceMemo("default_invoice_memo") @@ -2496,14 +2504,6 @@ internal class SubscriptionChangeCancelResponseTest { .build() ) .version(0L) - .basePlan( - Plan.BasePlan.builder() - .id("m2t5akQeh2obwxeU") - .externalPlanId("m2t5akQeh2obwxeU") - .name("Example plan") - .build() - ) - .basePlanId("base_plan_id") .build() ) .addPriceInterval( @@ -4089,6 +4089,14 @@ internal class SubscriptionChangeCancelResponseTest { .usageDiscount(0.0) .build() ) + .basePlan( + Plan.BasePlan.builder() + .id("m2t5akQeh2obwxeU") + .externalPlanId("m2t5akQeh2obwxeU") + .name("Example plan") + .build() + ) + .basePlanId("base_plan_id") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .currency("currency") .defaultInvoiceMemo("default_invoice_memo") @@ -4374,14 +4382,6 @@ internal class SubscriptionChangeCancelResponseTest { .build() ) .version(0L) - .basePlan( - Plan.BasePlan.builder() - .id("m2t5akQeh2obwxeU") - .externalPlanId("m2t5akQeh2obwxeU") - .name("Example plan") - .build() - ) - .basePlanId("base_plan_id") .build() ) .addPriceInterval( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeRetrieveResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeRetrieveResponseTest.kt index 1b095fa74..6d0c99ec2 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeRetrieveResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeRetrieveResponseTest.kt @@ -261,6 +261,14 @@ internal class SubscriptionChangeRetrieveResponseTest { .usageDiscount(0.0) .build() ) + .basePlan( + Plan.BasePlan.builder() + .id("m2t5akQeh2obwxeU") + .externalPlanId("m2t5akQeh2obwxeU") + .name("Example plan") + .build() + ) + .basePlanId("base_plan_id") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .currency("currency") .defaultInvoiceMemo("default_invoice_memo") @@ -546,14 +554,6 @@ internal class SubscriptionChangeRetrieveResponseTest { .build() ) .version(0L) - .basePlan( - Plan.BasePlan.builder() - .id("m2t5akQeh2obwxeU") - .externalPlanId("m2t5akQeh2obwxeU") - .name("Example plan") - .build() - ) - .basePlanId("base_plan_id") .build() ) .addPriceInterval( @@ -2231,6 +2231,14 @@ internal class SubscriptionChangeRetrieveResponseTest { .usageDiscount(0.0) .build() ) + .basePlan( + Plan.BasePlan.builder() + .id("m2t5akQeh2obwxeU") + .externalPlanId("m2t5akQeh2obwxeU") + .name("Example plan") + .build() + ) + .basePlanId("base_plan_id") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .currency("currency") .defaultInvoiceMemo("default_invoice_memo") @@ -2496,14 +2504,6 @@ internal class SubscriptionChangeRetrieveResponseTest { .build() ) .version(0L) - .basePlan( - Plan.BasePlan.builder() - .id("m2t5akQeh2obwxeU") - .externalPlanId("m2t5akQeh2obwxeU") - .name("Example plan") - .build() - ) - .basePlanId("base_plan_id") .build() ) .addPriceInterval( @@ -4089,6 +4089,14 @@ internal class SubscriptionChangeRetrieveResponseTest { .usageDiscount(0.0) .build() ) + .basePlan( + Plan.BasePlan.builder() + .id("m2t5akQeh2obwxeU") + .externalPlanId("m2t5akQeh2obwxeU") + .name("Example plan") + .build() + ) + .basePlanId("base_plan_id") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .currency("currency") .defaultInvoiceMemo("default_invoice_memo") @@ -4374,14 +4382,6 @@ internal class SubscriptionChangeRetrieveResponseTest { .build() ) .version(0L) - .basePlan( - Plan.BasePlan.builder() - .id("m2t5akQeh2obwxeU") - .externalPlanId("m2t5akQeh2obwxeU") - .name("Example plan") - .build() - ) - .basePlanId("base_plan_id") .build() ) .addPriceInterval( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionTest.kt index 015bf6dd6..1b17aae96 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionTest.kt @@ -241,6 +241,14 @@ internal class SubscriptionTest { .usageDiscount(0.0) .build() ) + .basePlan( + Plan.BasePlan.builder() + .id("m2t5akQeh2obwxeU") + .externalPlanId("m2t5akQeh2obwxeU") + .name("Example plan") + .build() + ) + .basePlanId("base_plan_id") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .currency("currency") .defaultInvoiceMemo("default_invoice_memo") @@ -495,14 +503,6 @@ internal class SubscriptionTest { .build() ) .version(0L) - .basePlan( - Plan.BasePlan.builder() - .id("m2t5akQeh2obwxeU") - .externalPlanId("m2t5akQeh2obwxeU") - .name("Example plan") - .build() - ) - .basePlanId("base_plan_id") .build() ) .addPriceInterval( @@ -904,6 +904,14 @@ internal class SubscriptionTest { .usageDiscount(0.0) .build() ) + .basePlan( + Plan.BasePlan.builder() + .id("m2t5akQeh2obwxeU") + .externalPlanId("m2t5akQeh2obwxeU") + .name("Example plan") + .build() + ) + .basePlanId("base_plan_id") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .currency("currency") .defaultInvoiceMemo("default_invoice_memo") @@ -1152,14 +1160,6 @@ internal class SubscriptionTest { .build() ) .version(0L) - .basePlan( - Plan.BasePlan.builder() - .id("m2t5akQeh2obwxeU") - .externalPlanId("m2t5akQeh2obwxeU") - .name("Example plan") - .build() - ) - .basePlanId("base_plan_id") .build() ) assertThat(subscription.priceIntervals()) @@ -1555,6 +1555,14 @@ internal class SubscriptionTest { .usageDiscount(0.0) .build() ) + .basePlan( + Plan.BasePlan.builder() + .id("m2t5akQeh2obwxeU") + .externalPlanId("m2t5akQeh2obwxeU") + .name("Example plan") + .build() + ) + .basePlanId("base_plan_id") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .currency("currency") .defaultInvoiceMemo("default_invoice_memo") @@ -1809,14 +1817,6 @@ internal class SubscriptionTest { .build() ) .version(0L) - .basePlan( - Plan.BasePlan.builder() - .id("m2t5akQeh2obwxeU") - .externalPlanId("m2t5akQeh2obwxeU") - .name("Example plan") - .build() - ) - .basePlanId("base_plan_id") .build() ) .addPriceInterval( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionsTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionsTest.kt index 7ec1eabad..2970d8eb5 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionsTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionsTest.kt @@ -258,6 +258,14 @@ internal class SubscriptionsTest { .usageDiscount(0.0) .build() ) + .basePlan( + Plan.BasePlan.builder() + .id("m2t5akQeh2obwxeU") + .externalPlanId("m2t5akQeh2obwxeU") + .name("Example plan") + .build() + ) + .basePlanId("base_plan_id") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .currency("currency") .defaultInvoiceMemo("default_invoice_memo") @@ -543,14 +551,6 @@ internal class SubscriptionsTest { .build() ) .version(0L) - .basePlan( - Plan.BasePlan.builder() - .id("m2t5akQeh2obwxeU") - .externalPlanId("m2t5akQeh2obwxeU") - .name("Example plan") - .build() - ) - .basePlanId("base_plan_id") .build() ) .addPriceInterval( @@ -986,6 +986,14 @@ internal class SubscriptionsTest { .usageDiscount(0.0) .build() ) + .basePlan( + Plan.BasePlan.builder() + .id("m2t5akQeh2obwxeU") + .externalPlanId("m2t5akQeh2obwxeU") + .name("Example plan") + .build() + ) + .basePlanId("base_plan_id") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .currency("currency") .defaultInvoiceMemo("default_invoice_memo") @@ -1251,14 +1259,6 @@ internal class SubscriptionsTest { .build() ) .version(0L) - .basePlan( - Plan.BasePlan.builder() - .id("m2t5akQeh2obwxeU") - .externalPlanId("m2t5akQeh2obwxeU") - .name("Example plan") - .build() - ) - .basePlanId("base_plan_id") .build() ) .addPriceInterval( @@ -1688,6 +1688,14 @@ internal class SubscriptionsTest { .usageDiscount(0.0) .build() ) + .basePlan( + Plan.BasePlan.builder() + .id("m2t5akQeh2obwxeU") + .externalPlanId("m2t5akQeh2obwxeU") + .name("Example plan") + .build() + ) + .basePlanId("base_plan_id") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .currency("currency") .defaultInvoiceMemo("default_invoice_memo") @@ -1973,14 +1981,6 @@ internal class SubscriptionsTest { .build() ) .version(0L) - .basePlan( - Plan.BasePlan.builder() - .id("m2t5akQeh2obwxeU") - .externalPlanId("m2t5akQeh2obwxeU") - .name("Example plan") - .build() - ) - .basePlanId("base_plan_id") .build() ) .addPriceInterval( From cfe2c8868aead2144f69f0b04e304de948adbf8d Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 18 Nov 2025 09:27:38 +0000 Subject: [PATCH 52/68] feat(api): api update --- .stats.yml | 4 +- .../kotlin/com/withorb/api/models/Plan.kt | 38 +++++++++++++++---- .../SubscriptionPriceIntervalsParams.kt | 8 ++-- 3 files changed, 36 insertions(+), 14 deletions(-) diff --git a/.stats.yml b/.stats.yml index 3cb33be6a..9e11ba24b 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 118 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-4ad3b44ca7f484243d8706b6aa7f4498fc5bf2b37fadf3da0a06d657e482c08f.yml -openapi_spec_hash: 9ead1a2aae36be1086c627c3636064ea +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-e639b12e0daebce74f42d1f31f675bda4287b9c749dd7d4620a1e96a83343ec4.yml +openapi_spec_hash: 51eb3d47b25e299de670b2d52f5e9017 config_hash: e6db17547fe854b1c240407cf4c6dc9e diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Plan.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Plan.kt index 33da624f2..84130f377 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Plan.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Plan.kt @@ -156,19 +156,22 @@ private constructor( fun adjustments(): List = adjustments.getRequired("adjustments") /** + * Legacy field representing the parent plan if the current plan is a 'child plan', overriding + * prices from the parent. + * * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server * responded with an unexpected value). */ - fun basePlan(): BasePlan? = basePlan.getNullable("base_plan") + @Deprecated("deprecated") fun basePlan(): BasePlan? = basePlan.getNullable("base_plan") /** - * The parent plan id if the given plan was created by overriding one or more of the parent's - * prices + * Legacy field representing the parent plan ID if the current plan is a 'child plan', + * overriding prices from the parent. * * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server * responded with an unexpected value). */ - fun basePlanId(): String? = basePlanId.getNullable("base_plan_id") + @Deprecated("deprecated") fun basePlanId(): String? = basePlanId.getNullable("base_plan_id") /** * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly @@ -336,14 +339,20 @@ private constructor( * * Unlike [basePlan], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("base_plan") @ExcludeMissing fun _basePlan(): JsonField = basePlan + @Deprecated("deprecated") + @JsonProperty("base_plan") + @ExcludeMissing + fun _basePlan(): JsonField = basePlan /** * Returns the raw JSON value of [basePlanId]. * * Unlike [basePlanId], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("base_plan_id") @ExcludeMissing fun _basePlanId(): JsonField = basePlanId + @Deprecated("deprecated") + @JsonProperty("base_plan_id") + @ExcludeMissing + fun _basePlanId(): JsonField = basePlanId /** * Returns the raw JSON value of [createdAt]. @@ -684,6 +693,11 @@ private constructor( fun addAdjustment(maximum: PlanPhaseMaximumAdjustment) = addAdjustment(Adjustment.ofMaximum(maximum)) + /** + * Legacy field representing the parent plan if the current plan is a 'child plan', + * overriding prices from the parent. + */ + @Deprecated("deprecated") fun basePlan(basePlan: BasePlan?) = basePlan(JsonField.ofNullable(basePlan)) /** @@ -693,12 +707,14 @@ private constructor( * This method is primarily for setting the field to an undocumented or not yet supported * value. */ + @Deprecated("deprecated") fun basePlan(basePlan: JsonField) = apply { this.basePlan = basePlan } /** - * The parent plan id if the given plan was created by overriding one or more of the - * parent's prices + * Legacy field representing the parent plan ID if the current plan is a 'child plan', + * overriding prices from the parent. */ + @Deprecated("deprecated") fun basePlanId(basePlanId: String?) = basePlanId(JsonField.ofNullable(basePlanId)) /** @@ -708,6 +724,7 @@ private constructor( * This method is primarily for setting the field to an undocumented or not yet supported * value. */ + @Deprecated("deprecated") fun basePlanId(basePlanId: JsonField) = apply { this.basePlanId = basePlanId } fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) @@ -1672,6 +1689,11 @@ private constructor( } } + /** + * Legacy field representing the parent plan if the current plan is a 'child plan', overriding + * prices from the parent. + */ + @Deprecated("deprecated") class BasePlan @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsParams.kt index a894a4ebc..5f8b50541 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsParams.kt @@ -14107,8 +14107,8 @@ private constructor( /** * If true, ending an in-arrears price interval mid-cycle will defer billing the final line - * itemuntil the next scheduled invoice. If false, it will be billed on its end date. If not - * provided, behaviorwill follow account default. + * item until the next scheduled invoice. If false, it will be billed on its end date. If + * not provided, behavior will follow account default. * * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -14335,8 +14335,8 @@ private constructor( /** * If true, ending an in-arrears price interval mid-cycle will defer billing the final - * line itemuntil the next scheduled invoice. If false, it will be billed on its end - * date. If not provided, behaviorwill follow account default. + * line item until the next scheduled invoice. If false, it will be billed on its end + * date. If not provided, behavior will follow account default. */ fun canDeferBilling(canDeferBilling: Boolean?) = canDeferBilling(JsonField.ofNullable(canDeferBilling)) From 9d7a717dafcfffa7210792d75cafe27861ce697d Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 24 Nov 2025 23:27:32 +0000 Subject: [PATCH 53/68] codegen metadata --- .stats.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.stats.yml b/.stats.yml index 9e11ba24b..79fa89e05 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 118 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-e639b12e0daebce74f42d1f31f675bda4287b9c749dd7d4620a1e96a83343ec4.yml -openapi_spec_hash: 51eb3d47b25e299de670b2d52f5e9017 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-36e32afb76082ffbe12a71342ed5b855b9ae83d8c5bcd225fe23915c308b39e7.yml +openapi_spec_hash: 035e0bb6141d78b4aed031303585940c config_hash: e6db17547fe854b1c240407cf4c6dc9e From bbe220c8813cd6a5c491da043f0b39cffe06edca Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 25 Nov 2025 21:29:39 +0000 Subject: [PATCH 54/68] feat(api): api update --- .stats.yml | 4 +- .../withorb/api/models/NewAllocationPrice.kt | 100 +++++++++++++++++- .../SubscriptionPriceIntervalsParams.kt | 86 +++++++++++---- .../models/BetaCreatePlanVersionParamsTest.kt | 12 +++ ...ternalPlanIdCreatePlanVersionParamsTest.kt | 12 +++ .../api/models/NewAllocationPriceTest.kt | 6 ++ .../api/models/PlanCreateParamsTest.kt | 6 ++ .../models/SubscriptionCreateParamsTest.kt | 12 +++ .../SubscriptionPriceIntervalsParamsTest.kt | 9 ++ ...ubscriptionSchedulePlanChangeParamsTest.kt | 12 +++ .../services/async/BetaServiceAsyncTest.kt | 4 + .../services/async/PlanServiceAsyncTest.kt | 2 + .../async/SubscriptionServiceAsyncTest.kt | 11 ++ .../beta/ExternalPlanIdServiceAsyncTest.kt | 4 + .../api/services/blocking/BetaServiceTest.kt | 4 + .../api/services/blocking/PlanServiceTest.kt | 2 + .../blocking/SubscriptionServiceTest.kt | 11 ++ .../beta/ExternalPlanIdServiceTest.kt | 4 + 18 files changed, 278 insertions(+), 23 deletions(-) diff --git a/.stats.yml b/.stats.yml index 79fa89e05..9629af670 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 118 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-36e32afb76082ffbe12a71342ed5b855b9ae83d8c5bcd225fe23915c308b39e7.yml -openapi_spec_hash: 035e0bb6141d78b4aed031303585940c +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-0ab0946487d1ee971683d894554494d9940010403874c0be724ffc3a82d696db.yml +openapi_spec_hash: 66b792328a4faee3c7659185accc3f0e config_hash: e6db17547fe854b1c240407cf4c6dc9e diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewAllocationPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewAllocationPrice.kt index e7652a3d6..17669e69c 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewAllocationPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewAllocationPrice.kt @@ -27,6 +27,8 @@ private constructor( private val customExpiration: JsonField, private val expiresAtEndOfCadence: JsonField, private val filters: JsonField>, + private val itemId: JsonField, + private val perUnitCostBasis: JsonField, private val additionalProperties: MutableMap, ) { @@ -41,7 +43,13 @@ private constructor( @JsonProperty("expires_at_end_of_cadence") @ExcludeMissing expiresAtEndOfCadence: JsonField = JsonMissing.of(), - @JsonProperty("filters") @ExcludeMissing filters: JsonField> = JsonMissing.of(), + @JsonProperty("filters") + @ExcludeMissing + filters: JsonField> = JsonMissing.of(), + @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), + @JsonProperty("per_unit_cost_basis") + @ExcludeMissing + perUnitCostBasis: JsonField = JsonMissing.of(), ) : this( amount, cadence, @@ -49,6 +57,8 @@ private constructor( customExpiration, expiresAtEndOfCadence, filters, + itemId, + perUnitCostBasis, mutableMapOf(), ) @@ -102,6 +112,25 @@ private constructor( */ fun filters(): List? = filters.getNullable("filters") + /** + * The item ID that line items representing charges for this allocation will be associated with. + * If not provided, the default allocation item for the currency will be used (e.g. 'Included + * Allocation (USD)'). + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun itemId(): String? = itemId.getNullable("item_id") + + /** + * The (per-unit) cost basis of each created block. If non-zero, a customer will be invoiced + * according to the quantity and per unit cost basis specified for the allocation each cadence. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun perUnitCostBasis(): String? = perUnitCostBasis.getNullable("per_unit_cost_basis") + /** * Returns the raw JSON value of [amount]. * @@ -150,6 +179,23 @@ private constructor( */ @JsonProperty("filters") @ExcludeMissing fun _filters(): JsonField> = filters + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [perUnitCostBasis]. + * + * Unlike [perUnitCostBasis], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("per_unit_cost_basis") + @ExcludeMissing + fun _perUnitCostBasis(): JsonField = perUnitCostBasis + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -186,6 +232,8 @@ private constructor( private var customExpiration: JsonField = JsonMissing.of() private var expiresAtEndOfCadence: JsonField = JsonMissing.of() private var filters: JsonField>? = null + private var itemId: JsonField = JsonMissing.of() + private var perUnitCostBasis: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() internal fun from(newAllocationPrice: NewAllocationPrice) = apply { @@ -195,6 +243,8 @@ private constructor( customExpiration = newAllocationPrice.customExpiration expiresAtEndOfCadence = newAllocationPrice.expiresAtEndOfCadence filters = newAllocationPrice.filters.map { it.toMutableList() } + itemId = newAllocationPrice.itemId + perUnitCostBasis = newAllocationPrice.perUnitCostBasis additionalProperties = newAllocationPrice.additionalProperties.toMutableMap() } @@ -301,6 +351,40 @@ private constructor( } } + /** + * The item ID that line items representing charges for this allocation will be associated + * with. If not provided, the default allocation item for the currency will be used (e.g. + * 'Included Allocation (USD)'). + */ + fun itemId(itemId: String?) = itemId(JsonField.ofNullable(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * The (per-unit) cost basis of each created block. If non-zero, a customer will be invoiced + * according to the quantity and per unit cost basis specified for the allocation each + * cadence. + */ + fun perUnitCostBasis(perUnitCostBasis: String) = + perUnitCostBasis(JsonField.of(perUnitCostBasis)) + + /** + * Sets [Builder.perUnitCostBasis] to an arbitrary JSON value. + * + * You should usually call [Builder.perUnitCostBasis] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun perUnitCostBasis(perUnitCostBasis: JsonField) = apply { + this.perUnitCostBasis = perUnitCostBasis + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -342,6 +426,8 @@ private constructor( customExpiration, expiresAtEndOfCadence, (filters ?: JsonMissing.of()).map { it.toImmutable() }, + itemId, + perUnitCostBasis, additionalProperties.toMutableMap(), ) } @@ -359,6 +445,8 @@ private constructor( customExpiration()?.validate() expiresAtEndOfCadence() filters()?.forEach { it.validate() } + itemId() + perUnitCostBasis() validated = true } @@ -381,7 +469,9 @@ private constructor( (if (currency.asKnown() == null) 0 else 1) + (customExpiration.asKnown()?.validity() ?: 0) + (if (expiresAtEndOfCadence.asKnown() == null) 0 else 1) + - (filters.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + (filters.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + (if (perUnitCostBasis.asKnown() == null) 0 else 1) /** The cadence at which to allocate the amount to the customer. */ class Cadence @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -1043,6 +1133,8 @@ private constructor( customExpiration == other.customExpiration && expiresAtEndOfCadence == other.expiresAtEndOfCadence && filters == other.filters && + itemId == other.itemId && + perUnitCostBasis == other.perUnitCostBasis && additionalProperties == other.additionalProperties } @@ -1054,6 +1146,8 @@ private constructor( customExpiration, expiresAtEndOfCadence, filters, + itemId, + perUnitCostBasis, additionalProperties, ) } @@ -1061,5 +1155,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewAllocationPrice{amount=$amount, cadence=$cadence, currency=$currency, customExpiration=$customExpiration, expiresAtEndOfCadence=$expiresAtEndOfCadence, filters=$filters, additionalProperties=$additionalProperties}" + "NewAllocationPrice{amount=$amount, cadence=$cadence, currency=$currency, customExpiration=$customExpiration, expiresAtEndOfCadence=$expiresAtEndOfCadence, filters=$filters, itemId=$itemId, perUnitCostBasis=$perUnitCostBasis, additionalProperties=$additionalProperties}" } diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsParams.kt index 5f8b50541..862b3a1ef 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsParams.kt @@ -134,9 +134,7 @@ private constructor( fun allowInvoiceCreditOrVoid(): Boolean? = body.allowInvoiceCreditOrVoid() /** - * If true, ending an in-arrears price interval mid-cycle will defer billing the final line - * itemuntil the next scheduled invoice. If false, it will be billed on its end date. If not - * provided, behaviorwill follow account default. + * If set, the default value to use for added/edited price intervals with an end_date set. * * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server * responded with an unexpected value). @@ -328,9 +326,7 @@ private constructor( } /** - * If true, ending an in-arrears price interval mid-cycle will defer billing the final line - * itemuntil the next scheduled invoice. If false, it will be billed on its end date. If not - * provided, behaviorwill follow account default. + * If set, the default value to use for added/edited price intervals with an end_date set. */ fun canDeferBilling(canDeferBilling: Boolean?) = apply { body.canDeferBilling(canDeferBilling) @@ -606,9 +602,7 @@ private constructor( allowInvoiceCreditOrVoid.getNullable("allow_invoice_credit_or_void") /** - * If true, ending an in-arrears price interval mid-cycle will defer billing the final line - * itemuntil the next scheduled invoice. If false, it will be billed on its end date. If not - * provided, behaviorwill follow account default. + * If set, the default value to use for added/edited price intervals with an end_date set. * * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -804,9 +798,8 @@ private constructor( } /** - * If true, ending an in-arrears price interval mid-cycle will defer billing the final - * line itemuntil the next scheduled invoice. If false, it will be billed on its end - * date. If not provided, behaviorwill follow account default. + * If set, the default value to use for added/edited price intervals with an end_date + * set. */ fun canDeferBilling(canDeferBilling: Boolean?) = canDeferBilling(JsonField.ofNullable(canDeferBilling)) @@ -995,6 +988,7 @@ private constructor( private constructor( private val startDate: JsonField, private val allocationPrice: JsonField, + private val canDeferBilling: JsonField, private val discounts: JsonField>, private val endDate: JsonField, private val externalPriceId: JsonField, @@ -1016,6 +1010,9 @@ private constructor( @JsonProperty("allocation_price") @ExcludeMissing allocationPrice: JsonField = JsonMissing.of(), + @JsonProperty("can_defer_billing") + @ExcludeMissing + canDeferBilling: JsonField = JsonMissing.of(), @JsonProperty("discounts") @ExcludeMissing discounts: JsonField> = JsonMissing.of(), @@ -1044,6 +1041,7 @@ private constructor( ) : this( startDate, allocationPrice, + canDeferBilling, discounts, endDate, externalPriceId, @@ -1074,6 +1072,15 @@ private constructor( */ fun allocationPrice(): NewAllocationPrice? = allocationPrice.getNullable("allocation_price") + /** + * If true, an in-arrears price interval ending mid-cycle will defer billing the final line + * item until the next scheduled invoice. If false, it will be billed on its end date. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun canDeferBilling(): Boolean? = canDeferBilling.getNullable("can_defer_billing") + /** * A list of discounts to initialize on the price interval. * @@ -1183,6 +1190,16 @@ private constructor( @ExcludeMissing fun _allocationPrice(): JsonField = allocationPrice + /** + * Returns the raw JSON value of [canDeferBilling]. + * + * Unlike [canDeferBilling], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("can_defer_billing") + @ExcludeMissing + fun _canDeferBilling(): JsonField = canDeferBilling + /** * Returns the raw JSON value of [discounts]. * @@ -1301,6 +1318,7 @@ private constructor( private var startDate: JsonField? = null private var allocationPrice: JsonField = JsonMissing.of() + private var canDeferBilling: JsonField = JsonMissing.of() private var discounts: JsonField>? = null private var endDate: JsonField = JsonMissing.of() private var externalPriceId: JsonField = JsonMissing.of() @@ -1318,6 +1336,7 @@ private constructor( internal fun from(add: Add) = apply { startDate = add.startDate allocationPrice = add.allocationPrice + canDeferBilling = add.canDeferBilling discounts = add.discounts.map { it.toMutableList() } endDate = add.endDate externalPriceId = add.externalPriceId @@ -1372,6 +1391,33 @@ private constructor( this.allocationPrice = allocationPrice } + /** + * If true, an in-arrears price interval ending mid-cycle will defer billing the final + * line item until the next scheduled invoice. If false, it will be billed on its end + * date. + */ + fun canDeferBilling(canDeferBilling: Boolean?) = + canDeferBilling(JsonField.ofNullable(canDeferBilling)) + + /** + * Alias for [Builder.canDeferBilling]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun canDeferBilling(canDeferBilling: Boolean) = + canDeferBilling(canDeferBilling as Boolean?) + + /** + * Sets [Builder.canDeferBilling] to an arbitrary JSON value. + * + * You should usually call [Builder.canDeferBilling] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun canDeferBilling(canDeferBilling: JsonField) = apply { + this.canDeferBilling = canDeferBilling + } + /** A list of discounts to initialize on the price interval. */ fun discounts(discounts: List?) = discounts(JsonField.ofNullable(discounts)) @@ -1835,6 +1881,7 @@ private constructor( Add( checkRequired("startDate", startDate), allocationPrice, + canDeferBilling, (discounts ?: JsonMissing.of()).map { it.toImmutable() }, endDate, externalPriceId, @@ -1858,6 +1905,7 @@ private constructor( startDate().validate() allocationPrice()?.validate() + canDeferBilling() discounts()?.forEach { it.validate() } endDate()?.validate() externalPriceId() @@ -1888,6 +1936,7 @@ private constructor( internal fun validity(): Int = (startDate.asKnown()?.validity() ?: 0) + (allocationPrice.asKnown()?.validity() ?: 0) + + (if (canDeferBilling.asKnown() == null) 0 else 1) + (discounts.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + (endDate.asKnown()?.validity() ?: 0) + (if (externalPriceId.asKnown() == null) 0 else 1) + @@ -12947,6 +12996,7 @@ private constructor( return other is Add && startDate == other.startDate && allocationPrice == other.allocationPrice && + canDeferBilling == other.canDeferBilling && discounts == other.discounts && endDate == other.endDate && externalPriceId == other.externalPriceId && @@ -12964,6 +13014,7 @@ private constructor( Objects.hash( startDate, allocationPrice, + canDeferBilling, discounts, endDate, externalPriceId, @@ -12981,7 +13032,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Add{startDate=$startDate, allocationPrice=$allocationPrice, discounts=$discounts, endDate=$endDate, externalPriceId=$externalPriceId, filter=$filter, fixedFeeQuantityTransitions=$fixedFeeQuantityTransitions, maximumAmount=$maximumAmount, minimumAmount=$minimumAmount, price=$price, priceId=$priceId, usageCustomerIds=$usageCustomerIds, additionalProperties=$additionalProperties}" + "Add{startDate=$startDate, allocationPrice=$allocationPrice, canDeferBilling=$canDeferBilling, discounts=$discounts, endDate=$endDate, externalPriceId=$externalPriceId, filter=$filter, fixedFeeQuantityTransitions=$fixedFeeQuantityTransitions, maximumAmount=$maximumAmount, minimumAmount=$minimumAmount, price=$price, priceId=$priceId, usageCustomerIds=$usageCustomerIds, additionalProperties=$additionalProperties}" } class AddAdjustment @@ -14106,9 +14157,8 @@ private constructor( fun billingCycleDay(): Long? = billingCycleDay.getNullable("billing_cycle_day") /** - * If true, ending an in-arrears price interval mid-cycle will defer billing the final line - * item until the next scheduled invoice. If false, it will be billed on its end date. If - * not provided, behavior will follow account default. + * If true, an in-arrears price interval ending mid-cycle will defer billing the final line + * item until the next scheduled invoice. If false, it will be billed on its end date. * * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -14334,9 +14384,9 @@ private constructor( } /** - * If true, ending an in-arrears price interval mid-cycle will defer billing the final + * If true, an in-arrears price interval ending mid-cycle will defer billing the final * line item until the next scheduled invoice. If false, it will be billed on its end - * date. If not provided, behavior will follow account default. + * date. */ fun canDeferBilling(canDeferBilling: Boolean?) = canDeferBilling(JsonField.ofNullable(canDeferBilling)) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/BetaCreatePlanVersionParamsTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/BetaCreatePlanVersionParamsTest.kt index 34890c76b..459c41e11 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/BetaCreatePlanVersionParamsTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/BetaCreatePlanVersionParamsTest.kt @@ -62,6 +62,8 @@ internal class BetaCreatePlanVersionParamsTest { .addValue("string") .build() ) + .itemId("item_id") + .perUnitCostBasis("per_unit_cost_basis") .build() ) .planPhaseOrder(0L) @@ -181,6 +183,8 @@ internal class BetaCreatePlanVersionParamsTest { .addValue("string") .build() ) + .itemId("item_id") + .perUnitCostBasis("per_unit_cost_basis") .build() ) .planPhaseOrder(0L) @@ -305,6 +309,8 @@ internal class BetaCreatePlanVersionParamsTest { .addValue("string") .build() ) + .itemId("item_id") + .perUnitCostBasis("per_unit_cost_basis") .build() ) .planPhaseOrder(0L) @@ -426,6 +432,8 @@ internal class BetaCreatePlanVersionParamsTest { .addValue("string") .build() ) + .itemId("item_id") + .perUnitCostBasis("per_unit_cost_basis") .build() ) .planPhaseOrder(0L) @@ -541,6 +549,8 @@ internal class BetaCreatePlanVersionParamsTest { .addValue("string") .build() ) + .itemId("item_id") + .perUnitCostBasis("per_unit_cost_basis") .build() ) .planPhaseOrder(0L) @@ -664,6 +674,8 @@ internal class BetaCreatePlanVersionParamsTest { .addValue("string") .build() ) + .itemId("item_id") + .perUnitCostBasis("per_unit_cost_basis") .build() ) .planPhaseOrder(0L) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/BetaExternalPlanIdCreatePlanVersionParamsTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/BetaExternalPlanIdCreatePlanVersionParamsTest.kt index c00941bb8..22acc6b4a 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/BetaExternalPlanIdCreatePlanVersionParamsTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/BetaExternalPlanIdCreatePlanVersionParamsTest.kt @@ -62,6 +62,8 @@ internal class BetaExternalPlanIdCreatePlanVersionParamsTest { .addValue("string") .build() ) + .itemId("item_id") + .perUnitCostBasis("per_unit_cost_basis") .build() ) .planPhaseOrder(0L) @@ -181,6 +183,8 @@ internal class BetaExternalPlanIdCreatePlanVersionParamsTest { .addValue("string") .build() ) + .itemId("item_id") + .perUnitCostBasis("per_unit_cost_basis") .build() ) .planPhaseOrder(0L) @@ -309,6 +313,8 @@ internal class BetaExternalPlanIdCreatePlanVersionParamsTest { .addValue("string") .build() ) + .itemId("item_id") + .perUnitCostBasis("per_unit_cost_basis") .build() ) .planPhaseOrder(0L) @@ -430,6 +436,8 @@ internal class BetaExternalPlanIdCreatePlanVersionParamsTest { .addValue("string") .build() ) + .itemId("item_id") + .perUnitCostBasis("per_unit_cost_basis") .build() ) .planPhaseOrder(0L) @@ -545,6 +553,8 @@ internal class BetaExternalPlanIdCreatePlanVersionParamsTest { .addValue("string") .build() ) + .itemId("item_id") + .perUnitCostBasis("per_unit_cost_basis") .build() ) .planPhaseOrder(0L) @@ -668,6 +678,8 @@ internal class BetaExternalPlanIdCreatePlanVersionParamsTest { .addValue("string") .build() ) + .itemId("item_id") + .perUnitCostBasis("per_unit_cost_basis") .build() ) .planPhaseOrder(0L) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewAllocationPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewAllocationPriceTest.kt index 79d602095..a03182267 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewAllocationPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewAllocationPriceTest.kt @@ -30,6 +30,8 @@ internal class NewAllocationPriceTest { .addValue("string") .build() ) + .itemId("item_id") + .perUnitCostBasis("per_unit_cost_basis") .build() assertThat(newAllocationPrice.amount()).isEqualTo("10.00") @@ -51,6 +53,8 @@ internal class NewAllocationPriceTest { .addValue("string") .build() ) + assertThat(newAllocationPrice.itemId()).isEqualTo("item_id") + assertThat(newAllocationPrice.perUnitCostBasis()).isEqualTo("per_unit_cost_basis") } @Test @@ -75,6 +79,8 @@ internal class NewAllocationPriceTest { .addValue("string") .build() ) + .itemId("item_id") + .perUnitCostBasis("per_unit_cost_basis") .build() val roundtrippedNewAllocationPrice = diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanCreateParamsTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanCreateParamsTest.kt index c4911f2e6..236bd88d4 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanCreateParamsTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanCreateParamsTest.kt @@ -34,6 +34,8 @@ internal class PlanCreateParamsTest { .addValue("string") .build() ) + .itemId("item_id") + .perUnitCostBasis("per_unit_cost_basis") .build() ) .planPhaseOrder(0L) @@ -165,6 +167,8 @@ internal class PlanCreateParamsTest { .addValue("string") .build() ) + .itemId("item_id") + .perUnitCostBasis("per_unit_cost_basis") .build() ) .planPhaseOrder(0L) @@ -296,6 +300,8 @@ internal class PlanCreateParamsTest { .addValue("string") .build() ) + .itemId("item_id") + .perUnitCostBasis("per_unit_cost_basis") .build() ) .planPhaseOrder(0L) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionCreateParamsTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionCreateParamsTest.kt index 9275ae991..79ba16c55 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionCreateParamsTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionCreateParamsTest.kt @@ -63,6 +63,8 @@ internal class SubscriptionCreateParamsTest { .addValue("string") .build() ) + .itemId("item_id") + .perUnitCostBasis("per_unit_cost_basis") .build() ) .addDiscount( @@ -224,6 +226,8 @@ internal class SubscriptionCreateParamsTest { .addValue("string") .build() ) + .itemId("item_id") + .perUnitCostBasis("per_unit_cost_basis") .build() ) .addDiscount( @@ -353,6 +357,8 @@ internal class SubscriptionCreateParamsTest { .addValue("string") .build() ) + .itemId("item_id") + .perUnitCostBasis("per_unit_cost_basis") .build() ) .addDiscount( @@ -516,6 +522,8 @@ internal class SubscriptionCreateParamsTest { .addValue("string") .build() ) + .itemId("item_id") + .perUnitCostBasis("per_unit_cost_basis") .build() ) .addDiscount( @@ -646,6 +654,8 @@ internal class SubscriptionCreateParamsTest { .addValue("string") .build() ) + .itemId("item_id") + .perUnitCostBasis("per_unit_cost_basis") .build() ) .addDiscount( @@ -813,6 +823,8 @@ internal class SubscriptionCreateParamsTest { .addValue("string") .build() ) + .itemId("item_id") + .perUnitCostBasis("per_unit_cost_basis") .build() ) .addDiscount( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsParamsTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsParamsTest.kt index a87c4534d..9ddb51e3d 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsParamsTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsParamsTest.kt @@ -35,8 +35,11 @@ internal class SubscriptionPriceIntervalsParamsTest { .addValue("string") .build() ) + .itemId("item_id") + .perUnitCostBasis("per_unit_cost_basis") .build() ) + .canDeferBilling(true) .addAmountDiscount(0.0) .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .externalPriceId("external_price_id") @@ -199,8 +202,11 @@ internal class SubscriptionPriceIntervalsParamsTest { .addValue("string") .build() ) + .itemId("item_id") + .perUnitCostBasis("per_unit_cost_basis") .build() ) + .canDeferBilling(true) .addAmountDiscount(0.0) .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .externalPriceId("external_price_id") @@ -354,8 +360,11 @@ internal class SubscriptionPriceIntervalsParamsTest { .addValue("string") .build() ) + .itemId("item_id") + .perUnitCostBasis("per_unit_cost_basis") .build() ) + .canDeferBilling(true) .addAmountDiscount(0.0) .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .externalPriceId("external_price_id") diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionSchedulePlanChangeParamsTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionSchedulePlanChangeParamsTest.kt index 853f72cd5..83dd5bb9b 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionSchedulePlanChangeParamsTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionSchedulePlanChangeParamsTest.kt @@ -65,6 +65,8 @@ internal class SubscriptionSchedulePlanChangeParamsTest { .addValue("string") .build() ) + .itemId("item_id") + .perUnitCostBasis("per_unit_cost_basis") .build() ) .addDiscount( @@ -217,6 +219,8 @@ internal class SubscriptionSchedulePlanChangeParamsTest { .addValue("string") .build() ) + .itemId("item_id") + .perUnitCostBasis("per_unit_cost_basis") .build() ) .addDiscount( @@ -360,6 +364,8 @@ internal class SubscriptionSchedulePlanChangeParamsTest { .addValue("string") .build() ) + .itemId("item_id") + .perUnitCostBasis("per_unit_cost_basis") .build() ) .addDiscount( @@ -514,6 +520,8 @@ internal class SubscriptionSchedulePlanChangeParamsTest { .addValue("string") .build() ) + .itemId("item_id") + .perUnitCostBasis("per_unit_cost_basis") .build() ) .addDiscount( @@ -645,6 +653,8 @@ internal class SubscriptionSchedulePlanChangeParamsTest { .addValue("string") .build() ) + .itemId("item_id") + .perUnitCostBasis("per_unit_cost_basis") .build() ) .addDiscount( @@ -799,6 +809,8 @@ internal class SubscriptionSchedulePlanChangeParamsTest { .addValue("string") .build() ) + .itemId("item_id") + .perUnitCostBasis("per_unit_cost_basis") .build() ) .addDiscount( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/BetaServiceAsyncTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/BetaServiceAsyncTest.kt index e123b7fe9..32d02018b 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/BetaServiceAsyncTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/BetaServiceAsyncTest.kt @@ -87,6 +87,8 @@ internal class BetaServiceAsyncTest { .addValue("string") .build() ) + .itemId("item_id") + .perUnitCostBasis("per_unit_cost_basis") .build() ) .planPhaseOrder(0L) @@ -214,6 +216,8 @@ internal class BetaServiceAsyncTest { .addValue("string") .build() ) + .itemId("item_id") + .perUnitCostBasis("per_unit_cost_basis") .build() ) .planPhaseOrder(0L) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/PlanServiceAsyncTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/PlanServiceAsyncTest.kt index b857734dd..e64d85947 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/PlanServiceAsyncTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/PlanServiceAsyncTest.kt @@ -56,6 +56,8 @@ internal class PlanServiceAsyncTest { .addValue("string") .build() ) + .itemId("item_id") + .perUnitCostBasis("per_unit_cost_basis") .build() ) .planPhaseOrder(0L) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/SubscriptionServiceAsyncTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/SubscriptionServiceAsyncTest.kt index 7c2cf5a38..933aced72 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/SubscriptionServiceAsyncTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/SubscriptionServiceAsyncTest.kt @@ -102,6 +102,8 @@ internal class SubscriptionServiceAsyncTest { .addValue("string") .build() ) + .itemId("item_id") + .perUnitCostBasis("per_unit_cost_basis") .build() ) .addDiscount( @@ -271,6 +273,8 @@ internal class SubscriptionServiceAsyncTest { .addValue("string") .build() ) + .itemId("item_id") + .perUnitCostBasis("per_unit_cost_basis") .build() ) .addDiscount( @@ -535,8 +539,11 @@ internal class SubscriptionServiceAsyncTest { .addValue("string") .build() ) + .itemId("item_id") + .perUnitCostBasis("per_unit_cost_basis") .build() ) + .canDeferBilling(true) .addAmountDiscount(0.0) .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .externalPriceId("external_price_id") @@ -766,6 +773,8 @@ internal class SubscriptionServiceAsyncTest { .addValue("string") .build() ) + .itemId("item_id") + .perUnitCostBasis("per_unit_cost_basis") .build() ) .addDiscount( @@ -926,6 +935,8 @@ internal class SubscriptionServiceAsyncTest { .addValue("string") .build() ) + .itemId("item_id") + .perUnitCostBasis("per_unit_cost_basis") .build() ) .addDiscount( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/beta/ExternalPlanIdServiceAsyncTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/beta/ExternalPlanIdServiceAsyncTest.kt index 6379d8c84..9f444c1fb 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/beta/ExternalPlanIdServiceAsyncTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/beta/ExternalPlanIdServiceAsyncTest.kt @@ -87,6 +87,8 @@ internal class ExternalPlanIdServiceAsyncTest { .addValue("string") .build() ) + .itemId("item_id") + .perUnitCostBasis("per_unit_cost_basis") .build() ) .planPhaseOrder(0L) @@ -214,6 +216,8 @@ internal class ExternalPlanIdServiceAsyncTest { .addValue("string") .build() ) + .itemId("item_id") + .perUnitCostBasis("per_unit_cost_basis") .build() ) .planPhaseOrder(0L) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/BetaServiceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/BetaServiceTest.kt index ed4936928..7f538b370 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/BetaServiceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/BetaServiceTest.kt @@ -87,6 +87,8 @@ internal class BetaServiceTest { .addValue("string") .build() ) + .itemId("item_id") + .perUnitCostBasis("per_unit_cost_basis") .build() ) .planPhaseOrder(0L) @@ -214,6 +216,8 @@ internal class BetaServiceTest { .addValue("string") .build() ) + .itemId("item_id") + .perUnitCostBasis("per_unit_cost_basis") .build() ) .planPhaseOrder(0L) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/PlanServiceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/PlanServiceTest.kt index 52aa27660..62e6a8a4e 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/PlanServiceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/PlanServiceTest.kt @@ -56,6 +56,8 @@ internal class PlanServiceTest { .addValue("string") .build() ) + .itemId("item_id") + .perUnitCostBasis("per_unit_cost_basis") .build() ) .planPhaseOrder(0L) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/SubscriptionServiceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/SubscriptionServiceTest.kt index e6d49a28f..457bb6fcd 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/SubscriptionServiceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/SubscriptionServiceTest.kt @@ -102,6 +102,8 @@ internal class SubscriptionServiceTest { .addValue("string") .build() ) + .itemId("item_id") + .perUnitCostBasis("per_unit_cost_basis") .build() ) .addDiscount( @@ -271,6 +273,8 @@ internal class SubscriptionServiceTest { .addValue("string") .build() ) + .itemId("item_id") + .perUnitCostBasis("per_unit_cost_basis") .build() ) .addDiscount( @@ -535,8 +539,11 @@ internal class SubscriptionServiceTest { .addValue("string") .build() ) + .itemId("item_id") + .perUnitCostBasis("per_unit_cost_basis") .build() ) + .canDeferBilling(true) .addAmountDiscount(0.0) .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .externalPriceId("external_price_id") @@ -766,6 +773,8 @@ internal class SubscriptionServiceTest { .addValue("string") .build() ) + .itemId("item_id") + .perUnitCostBasis("per_unit_cost_basis") .build() ) .addDiscount( @@ -926,6 +935,8 @@ internal class SubscriptionServiceTest { .addValue("string") .build() ) + .itemId("item_id") + .perUnitCostBasis("per_unit_cost_basis") .build() ) .addDiscount( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/beta/ExternalPlanIdServiceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/beta/ExternalPlanIdServiceTest.kt index 65722e624..961704179 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/beta/ExternalPlanIdServiceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/beta/ExternalPlanIdServiceTest.kt @@ -87,6 +87,8 @@ internal class ExternalPlanIdServiceTest { .addValue("string") .build() ) + .itemId("item_id") + .perUnitCostBasis("per_unit_cost_basis") .build() ) .planPhaseOrder(0L) @@ -214,6 +216,8 @@ internal class ExternalPlanIdServiceTest { .addValue("string") .build() ) + .itemId("item_id") + .perUnitCostBasis("per_unit_cost_basis") .build() ) .planPhaseOrder(0L) From 012b348959220609a650011f38e967b55aa6c906 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 2 Dec 2025 00:26:25 +0000 Subject: [PATCH 55/68] feat(api): api update --- .stats.yml | 4 ++-- .../kotlin/com/withorb/api/models/SubscriptionCreateParams.kt | 3 +++ .../withorb/api/services/async/SubscriptionServiceAsync.kt | 3 +++ .../com/withorb/api/services/blocking/SubscriptionService.kt | 3 +++ 4 files changed, 11 insertions(+), 2 deletions(-) diff --git a/.stats.yml b/.stats.yml index 9629af670..b9f26ca49 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 118 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-0ab0946487d1ee971683d894554494d9940010403874c0be724ffc3a82d696db.yml -openapi_spec_hash: 66b792328a4faee3c7659185accc3f0e +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-033643979990e894363554df06218fabe4493feaa569a013dbdf9a72aa21c45f.yml +openapi_spec_hash: dd9d320ad178bafa06f1eac2977e2ca7 config_hash: e6db17547fe854b1c240407cf4c6dc9e diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionCreateParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionCreateParams.kt index 8fa72f75c..19616bd6d 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionCreateParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionCreateParams.kt @@ -261,6 +261,9 @@ import java.util.Objects * threshold billing, pass in an `invoicing_threshold`, which is specified in the subscription's * invoicing currency, when creating a subscription. E.g. pass in `10.00` to issue an invoice when * usage amounts hit \$10.00 for a subscription that invoices in USD. + * + * ## Limits + * By default, Orb limits the number of subscriptions per customer to 100. */ class SubscriptionCreateParams private constructor( diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/SubscriptionServiceAsync.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/SubscriptionServiceAsync.kt index fa7b3672d..70f4ff403 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/SubscriptionServiceAsync.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/SubscriptionServiceAsync.kt @@ -279,6 +279,9 @@ interface SubscriptionServiceAsync { * enable threshold billing, pass in an `invoicing_threshold`, which is specified in the * subscription's invoicing currency, when creating a subscription. E.g. pass in `10.00` to * issue an invoice when usage amounts hit \$10.00 for a subscription that invoices in USD. + * + * ## Limits + * By default, Orb limits the number of subscriptions per customer to 100. */ suspend fun create( params: SubscriptionCreateParams = SubscriptionCreateParams.none(), diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/SubscriptionService.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/SubscriptionService.kt index 69647eca8..85fe68e11 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/SubscriptionService.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/SubscriptionService.kt @@ -279,6 +279,9 @@ interface SubscriptionService { * enable threshold billing, pass in an `invoicing_threshold`, which is specified in the * subscription's invoicing currency, when creating a subscription. E.g. pass in `10.00` to * issue an invoice when usage amounts hit \$10.00 for a subscription that invoices in USD. + * + * ## Limits + * By default, Orb limits the number of subscriptions per customer to 100. */ fun create( params: SubscriptionCreateParams = SubscriptionCreateParams.none(), From 7e95cda57ad7eef980190010d8c68db1fb7f9eb3 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 2 Dec 2025 08:53:52 +0000 Subject: [PATCH 56/68] docs: remove `$` for better copy-pasteabality --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index a831d6dd1..fd129caff 100644 --- a/README.md +++ b/README.md @@ -295,13 +295,13 @@ The SDK uses the standard [OkHttp logging interceptor](https://github.com/square Enable logging by setting the `ORB_LOG` environment variable to `info`: ```sh -$ export ORB_LOG=info +export ORB_LOG=info ``` Or to `debug` for more verbose logging: ```sh -$ export ORB_LOG=debug +export ORB_LOG=debug ``` ## Webhook Verification From 68203a34d2c36b47aecb227b408452f65f4db572 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 3 Dec 2025 01:26:16 +0000 Subject: [PATCH 57/68] feat(api): api update --- .stats.yml | 4 +- .../kotlin/com/withorb/api/models/Customer.kt | 592 ++++++++++++++++- .../api/models/CustomerCreateParams.kt | 629 +++++++++++++++++- .../CustomerUpdateByExternalIdParams.kt | 629 +++++++++++++++++- .../api/models/CustomerUpdateParams.kt | 629 +++++++++++++++++- .../api/models/CustomerCreateParamsTest.kt | 43 ++ .../models/CustomerListPageResponseTest.kt | 41 ++ .../com/withorb/api/models/CustomerTest.kt | 39 ++ .../CustomerUpdateByExternalIdParamsTest.kt | 49 ++ .../api/models/CustomerUpdateParamsTest.kt | 43 ++ .../api/models/MutatedSubscriptionTest.kt | 41 ++ .../SubscriptionChangeApplyResponseTest.kt | 42 ++ .../SubscriptionChangeCancelResponseTest.kt | 42 ++ .../SubscriptionChangeRetrieveResponseTest.kt | 42 ++ .../withorb/api/models/SubscriptionTest.kt | 41 ++ .../withorb/api/models/SubscriptionsTest.kt | 42 ++ .../withorb/api/services/ErrorHandlingTest.kt | 272 ++++++++ .../withorb/api/services/ServiceParamsTest.kt | 14 + .../async/CustomerServiceAsyncTest.kt | 45 ++ .../services/blocking/CustomerServiceTest.kt | 45 ++ 20 files changed, 3318 insertions(+), 6 deletions(-) diff --git a/.stats.yml b/.stats.yml index b9f26ca49..8fee554bc 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 118 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-033643979990e894363554df06218fabe4493feaa569a013dbdf9a72aa21c45f.yml -openapi_spec_hash: dd9d320ad178bafa06f1eac2977e2ca7 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-7936e3f73bbe1d59d27fd7a8a226985927b38fdec1c936c77577381699fb6140.yml +openapi_spec_hash: 1d3f9ed5fbdb0e40d56d6acd9d1736e2 config_hash: e6db17547fe854b1c240407cf4c6dc9e diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Customer.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Customer.kt index ad2ed594c..f40c200ee 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Customer.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Customer.kt @@ -63,6 +63,7 @@ private constructor( private val timezone: JsonField, private val accountingSyncConfiguration: JsonField, private val automaticTaxEnabled: JsonField, + private val paymentConfiguration: JsonField, private val reportingConfiguration: JsonField, private val additionalProperties: MutableMap, ) { @@ -120,6 +121,9 @@ private constructor( @JsonProperty("automatic_tax_enabled") @ExcludeMissing automaticTaxEnabled: JsonField = JsonMissing.of(), + @JsonProperty("payment_configuration") + @ExcludeMissing + paymentConfiguration: JsonField = JsonMissing.of(), @JsonProperty("reporting_configuration") @ExcludeMissing reportingConfiguration: JsonField = JsonMissing.of(), @@ -147,6 +151,7 @@ private constructor( timezone, accountingSyncConfiguration, automaticTaxEnabled, + paymentConfiguration, reportingConfiguration, mutableMapOf(), ) @@ -469,6 +474,16 @@ private constructor( */ fun automaticTaxEnabled(): Boolean? = automaticTaxEnabled.getNullable("automatic_tax_enabled") + /** + * Payment configuration for the customer, applicable when using Orb Invoicing with a supported + * payment provider such as Stripe. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun paymentConfiguration(): PaymentConfiguration? = + paymentConfiguration.getNullable("payment_configuration") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server * responded with an unexpected value). @@ -670,6 +685,16 @@ private constructor( @ExcludeMissing fun _automaticTaxEnabled(): JsonField = automaticTaxEnabled + /** + * Returns the raw JSON value of [paymentConfiguration]. + * + * Unlike [paymentConfiguration], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("payment_configuration") + @ExcludeMissing + fun _paymentConfiguration(): JsonField = paymentConfiguration + /** * Returns the raw JSON value of [reportingConfiguration]. * @@ -752,6 +777,7 @@ private constructor( private var accountingSyncConfiguration: JsonField = JsonMissing.of() private var automaticTaxEnabled: JsonField = JsonMissing.of() + private var paymentConfiguration: JsonField = JsonMissing.of() private var reportingConfiguration: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -779,6 +805,7 @@ private constructor( timezone = customer.timezone accountingSyncConfiguration = customer.accountingSyncConfiguration automaticTaxEnabled = customer.automaticTaxEnabled + paymentConfiguration = customer.paymentConfiguration reportingConfiguration = customer.reportingConfiguration additionalProperties = customer.additionalProperties.toMutableMap() } @@ -1282,6 +1309,24 @@ private constructor( this.automaticTaxEnabled = automaticTaxEnabled } + /** + * Payment configuration for the customer, applicable when using Orb Invoicing with a + * supported payment provider such as Stripe. + */ + fun paymentConfiguration(paymentConfiguration: PaymentConfiguration?) = + paymentConfiguration(JsonField.ofNullable(paymentConfiguration)) + + /** + * Sets [Builder.paymentConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.paymentConfiguration] with a well-typed + * [PaymentConfiguration] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun paymentConfiguration(paymentConfiguration: JsonField) = apply { + this.paymentConfiguration = paymentConfiguration + } + fun reportingConfiguration(reportingConfiguration: ReportingConfiguration?) = reportingConfiguration(JsonField.ofNullable(reportingConfiguration)) @@ -1373,6 +1418,7 @@ private constructor( checkRequired("timezone", timezone), accountingSyncConfiguration, automaticTaxEnabled, + paymentConfiguration, reportingConfiguration, additionalProperties.toMutableMap(), ) @@ -1408,6 +1454,7 @@ private constructor( timezone() accountingSyncConfiguration()?.validate() automaticTaxEnabled() + paymentConfiguration()?.validate() reportingConfiguration()?.validate() validated = true } @@ -1449,6 +1496,7 @@ private constructor( (if (timezone.asKnown() == null) 0 else 1) + (accountingSyncConfiguration.asKnown()?.validity() ?: 0) + (if (automaticTaxEnabled.asKnown() == null) 0 else 1) + + (paymentConfiguration.asKnown()?.validity() ?: 0) + (reportingConfiguration.asKnown()?.validity() ?: 0) /** The hierarchical relationships for this customer. */ @@ -2479,6 +2527,546 @@ private constructor( "AccountingSyncConfiguration{accountingProviders=$accountingProviders, excluded=$excluded, additionalProperties=$additionalProperties}" } + /** + * Payment configuration for the customer, applicable when using Orb Invoicing with a supported + * payment provider such as Stripe. + */ + class PaymentConfiguration + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val paymentProviders: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("payment_providers") + @ExcludeMissing + paymentProviders: JsonField> = JsonMissing.of() + ) : this(paymentProviders, mutableMapOf()) + + /** + * Provider-specific payment configuration. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun paymentProviders(): List? = + paymentProviders.getNullable("payment_providers") + + /** + * Returns the raw JSON value of [paymentProviders]. + * + * Unlike [paymentProviders], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("payment_providers") + @ExcludeMissing + fun _paymentProviders(): JsonField> = paymentProviders + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [PaymentConfiguration]. */ + fun builder() = Builder() + } + + /** A builder for [PaymentConfiguration]. */ + class Builder internal constructor() { + + private var paymentProviders: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(paymentConfiguration: PaymentConfiguration) = apply { + paymentProviders = paymentConfiguration.paymentProviders.map { it.toMutableList() } + additionalProperties = paymentConfiguration.additionalProperties.toMutableMap() + } + + /** Provider-specific payment configuration. */ + fun paymentProviders(paymentProviders: List) = + paymentProviders(JsonField.of(paymentProviders)) + + /** + * Sets [Builder.paymentProviders] to an arbitrary JSON value. + * + * You should usually call [Builder.paymentProviders] with a well-typed + * `List` value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun paymentProviders(paymentProviders: JsonField>) = apply { + this.paymentProviders = paymentProviders.map { it.toMutableList() } + } + + /** + * Adds a single [PaymentProvider] to [paymentProviders]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addPaymentProvider(paymentProvider: PaymentProvider) = apply { + paymentProviders = + (paymentProviders ?: JsonField.of(mutableListOf())).also { + checkKnown("paymentProviders", it).add(paymentProvider) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [PaymentConfiguration]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): PaymentConfiguration = + PaymentConfiguration( + (paymentProviders ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): PaymentConfiguration = apply { + if (validated) { + return@apply + } + + paymentProviders()?.forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (paymentProviders.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + class PaymentProvider + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val providerType: JsonField, + private val excludedPaymentMethodTypes: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("provider_type") + @ExcludeMissing + providerType: JsonField = JsonMissing.of(), + @JsonProperty("excluded_payment_method_types") + @ExcludeMissing + excludedPaymentMethodTypes: JsonField> = JsonMissing.of(), + ) : this(providerType, excludedPaymentMethodTypes, mutableMapOf()) + + /** + * The payment provider to configure. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun providerType(): ProviderType = providerType.getRequired("provider_type") + + /** + * List of Stripe payment method types to exclude for this customer. Excluded payment + * methods will not be available for the customer to select during payment, and will not + * be used for auto-collection. If a customer's default payment method becomes excluded, + * Orb will attempt to use the next available compatible payment method for + * auto-collection. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun excludedPaymentMethodTypes(): List? = + excludedPaymentMethodTypes.getNullable("excluded_payment_method_types") + + /** + * Returns the raw JSON value of [providerType]. + * + * Unlike [providerType], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("provider_type") + @ExcludeMissing + fun _providerType(): JsonField = providerType + + /** + * Returns the raw JSON value of [excludedPaymentMethodTypes]. + * + * Unlike [excludedPaymentMethodTypes], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("excluded_payment_method_types") + @ExcludeMissing + fun _excludedPaymentMethodTypes(): JsonField> = excludedPaymentMethodTypes + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [PaymentProvider]. + * + * The following fields are required: + * ```kotlin + * .providerType() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [PaymentProvider]. */ + class Builder internal constructor() { + + private var providerType: JsonField? = null + private var excludedPaymentMethodTypes: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(paymentProvider: PaymentProvider) = apply { + providerType = paymentProvider.providerType + excludedPaymentMethodTypes = + paymentProvider.excludedPaymentMethodTypes.map { it.toMutableList() } + additionalProperties = paymentProvider.additionalProperties.toMutableMap() + } + + /** The payment provider to configure. */ + fun providerType(providerType: ProviderType) = + providerType(JsonField.of(providerType)) + + /** + * Sets [Builder.providerType] to an arbitrary JSON value. + * + * You should usually call [Builder.providerType] with a well-typed [ProviderType] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun providerType(providerType: JsonField) = apply { + this.providerType = providerType + } + + /** + * List of Stripe payment method types to exclude for this customer. Excluded + * payment methods will not be available for the customer to select during payment, + * and will not be used for auto-collection. If a customer's default payment method + * becomes excluded, Orb will attempt to use the next available compatible payment + * method for auto-collection. + */ + fun excludedPaymentMethodTypes(excludedPaymentMethodTypes: List) = + excludedPaymentMethodTypes(JsonField.of(excludedPaymentMethodTypes)) + + /** + * Sets [Builder.excludedPaymentMethodTypes] to an arbitrary JSON value. + * + * You should usually call [Builder.excludedPaymentMethodTypes] with a well-typed + * `List` value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun excludedPaymentMethodTypes( + excludedPaymentMethodTypes: JsonField> + ) = apply { + this.excludedPaymentMethodTypes = + excludedPaymentMethodTypes.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [excludedPaymentMethodTypes]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addExcludedPaymentMethodType(excludedPaymentMethodType: String) = apply { + excludedPaymentMethodTypes = + (excludedPaymentMethodTypes ?: JsonField.of(mutableListOf())).also { + checkKnown("excludedPaymentMethodTypes", it) + .add(excludedPaymentMethodType) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [PaymentProvider]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .providerType() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): PaymentProvider = + PaymentProvider( + checkRequired("providerType", providerType), + (excludedPaymentMethodTypes ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): PaymentProvider = apply { + if (validated) { + return@apply + } + + providerType().validate() + excludedPaymentMethodTypes() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (providerType.asKnown()?.validity() ?: 0) + + (excludedPaymentMethodTypes.asKnown()?.size ?: 0) + + /** The payment provider to configure. */ + class ProviderType + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val STRIPE = of("stripe") + + fun of(value: String) = ProviderType(JsonField.of(value)) + } + + /** An enum containing [ProviderType]'s known values. */ + enum class Known { + STRIPE + } + + /** + * An enum containing [ProviderType]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [ProviderType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + STRIPE, + /** + * An enum member indicating that [ProviderType] was instantiated with an + * unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + STRIPE -> Value.STRIPE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + STRIPE -> Known.STRIPE + else -> throw OrbInvalidDataException("Unknown ProviderType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): ProviderType = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ProviderType && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PaymentProvider && + providerType == other.providerType && + excludedPaymentMethodTypes == other.excludedPaymentMethodTypes && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(providerType, excludedPaymentMethodTypes, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "PaymentProvider{providerType=$providerType, excludedPaymentMethodTypes=$excludedPaymentMethodTypes, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PaymentConfiguration && + paymentProviders == other.paymentProviders && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(paymentProviders, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "PaymentConfiguration{paymentProviders=$paymentProviders, additionalProperties=$additionalProperties}" + } + class ReportingConfiguration @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( @@ -2663,6 +3251,7 @@ private constructor( timezone == other.timezone && accountingSyncConfiguration == other.accountingSyncConfiguration && automaticTaxEnabled == other.automaticTaxEnabled && + paymentConfiguration == other.paymentConfiguration && reportingConfiguration == other.reportingConfiguration && additionalProperties == other.additionalProperties } @@ -2692,6 +3281,7 @@ private constructor( timezone, accountingSyncConfiguration, automaticTaxEnabled, + paymentConfiguration, reportingConfiguration, additionalProperties, ) @@ -2700,5 +3290,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Customer{id=$id, additionalEmails=$additionalEmails, autoCollection=$autoCollection, autoIssuance=$autoIssuance, balance=$balance, billingAddress=$billingAddress, createdAt=$createdAt, currency=$currency, email=$email, emailDelivery=$emailDelivery, exemptFromAutomatedTax=$exemptFromAutomatedTax, externalCustomerId=$externalCustomerId, hierarchy=$hierarchy, metadata=$metadata, name=$name, paymentProvider=$paymentProvider, paymentProviderId=$paymentProviderId, portalUrl=$portalUrl, shippingAddress=$shippingAddress, taxId=$taxId, timezone=$timezone, accountingSyncConfiguration=$accountingSyncConfiguration, automaticTaxEnabled=$automaticTaxEnabled, reportingConfiguration=$reportingConfiguration, additionalProperties=$additionalProperties}" + "Customer{id=$id, additionalEmails=$additionalEmails, autoCollection=$autoCollection, autoIssuance=$autoIssuance, balance=$balance, billingAddress=$billingAddress, createdAt=$createdAt, currency=$currency, email=$email, emailDelivery=$emailDelivery, exemptFromAutomatedTax=$exemptFromAutomatedTax, externalCustomerId=$externalCustomerId, hierarchy=$hierarchy, metadata=$metadata, name=$name, paymentProvider=$paymentProvider, paymentProviderId=$paymentProviderId, portalUrl=$portalUrl, shippingAddress=$shippingAddress, taxId=$taxId, timezone=$timezone, accountingSyncConfiguration=$accountingSyncConfiguration, automaticTaxEnabled=$automaticTaxEnabled, paymentConfiguration=$paymentConfiguration, reportingConfiguration=$reportingConfiguration, additionalProperties=$additionalProperties}" } diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreateParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreateParams.kt index fa14687fb..38ba68cef 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreateParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreateParams.kt @@ -154,6 +154,15 @@ private constructor( */ fun metadata(): Metadata? = body.metadata() + /** + * Payment configuration for the customer, applicable when using Orb Invoicing with a supported + * payment provider such as Stripe. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun paymentConfiguration(): PaymentConfiguration? = body.paymentConfiguration() + /** * This is used for creating charges or invoices in an external system via Orb. When not in test * mode, the connection must first be configured in the Orb webapp. @@ -438,6 +447,14 @@ private constructor( */ fun _metadata(): JsonField = body._metadata() + /** + * Returns the raw JSON value of [paymentConfiguration]. + * + * Unlike [paymentConfiguration], this method doesn't throw if the JSON field has an unexpected + * type. + */ + fun _paymentConfiguration(): JsonField = body._paymentConfiguration() + /** * Returns the raw JSON value of [paymentProvider]. * @@ -761,6 +778,25 @@ private constructor( */ fun metadata(metadata: JsonField) = apply { body.metadata(metadata) } + /** + * Payment configuration for the customer, applicable when using Orb Invoicing with a + * supported payment provider such as Stripe. + */ + fun paymentConfiguration(paymentConfiguration: PaymentConfiguration?) = apply { + body.paymentConfiguration(paymentConfiguration) + } + + /** + * Sets [Builder.paymentConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.paymentConfiguration] with a well-typed + * [PaymentConfiguration] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun paymentConfiguration(paymentConfiguration: JsonField) = apply { + body.paymentConfiguration(paymentConfiguration) + } + /** * This is used for creating charges or invoices in an external system via Orb. When not in * test mode, the connection must first be configured in the Orb webapp. @@ -1278,6 +1314,7 @@ private constructor( private val externalCustomerId: JsonField, private val hierarchy: JsonField, private val metadata: JsonField, + private val paymentConfiguration: JsonField, private val paymentProvider: JsonField, private val paymentProviderId: JsonField, private val reportingConfiguration: JsonField, @@ -1323,6 +1360,9 @@ private constructor( @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), + @JsonProperty("payment_configuration") + @ExcludeMissing + paymentConfiguration: JsonField = JsonMissing.of(), @JsonProperty("payment_provider") @ExcludeMissing paymentProvider: JsonField = JsonMissing.of(), @@ -1355,6 +1395,7 @@ private constructor( externalCustomerId, hierarchy, metadata, + paymentConfiguration, paymentProvider, paymentProviderId, reportingConfiguration, @@ -1469,6 +1510,16 @@ private constructor( */ fun metadata(): Metadata? = metadata.getNullable("metadata") + /** + * Payment configuration for the customer, applicable when using Orb Invoicing with a + * supported payment provider such as Stripe. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun paymentConfiguration(): PaymentConfiguration? = + paymentConfiguration.getNullable("payment_configuration") + /** * This is used for creating charges or invoices in an external system via Orb. When not in * test mode, the connection must first be configured in the Orb webapp. @@ -1775,6 +1826,16 @@ private constructor( */ @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + /** + * Returns the raw JSON value of [paymentConfiguration]. + * + * Unlike [paymentConfiguration], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("payment_configuration") + @ExcludeMissing + fun _paymentConfiguration(): JsonField = paymentConfiguration + /** * Returns the raw JSON value of [paymentProvider]. * @@ -1881,6 +1942,7 @@ private constructor( private var externalCustomerId: JsonField = JsonMissing.of() private var hierarchy: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() + private var paymentConfiguration: JsonField = JsonMissing.of() private var paymentProvider: JsonField = JsonMissing.of() private var paymentProviderId: JsonField = JsonMissing.of() private var reportingConfiguration: JsonField = @@ -1904,6 +1966,7 @@ private constructor( externalCustomerId = body.externalCustomerId hierarchy = body.hierarchy metadata = body.metadata + paymentConfiguration = body.paymentConfiguration paymentProvider = body.paymentProvider paymentProviderId = body.paymentProviderId reportingConfiguration = body.reportingConfiguration @@ -2141,6 +2204,25 @@ private constructor( */ fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + /** + * Payment configuration for the customer, applicable when using Orb Invoicing with a + * supported payment provider such as Stripe. + */ + fun paymentConfiguration(paymentConfiguration: PaymentConfiguration?) = + paymentConfiguration(JsonField.ofNullable(paymentConfiguration)) + + /** + * Sets [Builder.paymentConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.paymentConfiguration] with a well-typed + * [PaymentConfiguration] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun paymentConfiguration(paymentConfiguration: JsonField) = + apply { + this.paymentConfiguration = paymentConfiguration + } + /** * This is used for creating charges or invoices in an external system via Orb. When not * in test mode, the connection must first be configured in the Orb webapp. @@ -2545,6 +2627,7 @@ private constructor( externalCustomerId, hierarchy, metadata, + paymentConfiguration, paymentProvider, paymentProviderId, reportingConfiguration, @@ -2575,6 +2658,7 @@ private constructor( externalCustomerId() hierarchy()?.validate() metadata()?.validate() + paymentConfiguration()?.validate() paymentProvider()?.validate() paymentProviderId() reportingConfiguration()?.validate() @@ -2612,6 +2696,7 @@ private constructor( (if (externalCustomerId.asKnown() == null) 0 else 1) + (hierarchy.asKnown()?.validity() ?: 0) + (metadata.asKnown()?.validity() ?: 0) + + (paymentConfiguration.asKnown()?.validity() ?: 0) + (paymentProvider.asKnown()?.validity() ?: 0) + (if (paymentProviderId.asKnown() == null) 0 else 1) + (reportingConfiguration.asKnown()?.validity() ?: 0) + @@ -2638,6 +2723,7 @@ private constructor( externalCustomerId == other.externalCustomerId && hierarchy == other.hierarchy && metadata == other.metadata && + paymentConfiguration == other.paymentConfiguration && paymentProvider == other.paymentProvider && paymentProviderId == other.paymentProviderId && reportingConfiguration == other.reportingConfiguration && @@ -2662,6 +2748,7 @@ private constructor( externalCustomerId, hierarchy, metadata, + paymentConfiguration, paymentProvider, paymentProviderId, reportingConfiguration, @@ -2676,7 +2763,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Body{email=$email, name=$name, accountingSyncConfiguration=$accountingSyncConfiguration, additionalEmails=$additionalEmails, autoCollection=$autoCollection, autoIssuance=$autoIssuance, billingAddress=$billingAddress, currency=$currency, emailDelivery=$emailDelivery, externalCustomerId=$externalCustomerId, hierarchy=$hierarchy, metadata=$metadata, paymentProvider=$paymentProvider, paymentProviderId=$paymentProviderId, reportingConfiguration=$reportingConfiguration, shippingAddress=$shippingAddress, taxConfiguration=$taxConfiguration, taxId=$taxId, timezone=$timezone, additionalProperties=$additionalProperties}" + "Body{email=$email, name=$name, accountingSyncConfiguration=$accountingSyncConfiguration, additionalEmails=$additionalEmails, autoCollection=$autoCollection, autoIssuance=$autoIssuance, billingAddress=$billingAddress, currency=$currency, emailDelivery=$emailDelivery, externalCustomerId=$externalCustomerId, hierarchy=$hierarchy, metadata=$metadata, paymentConfiguration=$paymentConfiguration, paymentProvider=$paymentProvider, paymentProviderId=$paymentProviderId, reportingConfiguration=$reportingConfiguration, shippingAddress=$shippingAddress, taxConfiguration=$taxConfiguration, taxId=$taxId, timezone=$timezone, additionalProperties=$additionalProperties}" } /** @@ -2781,6 +2868,546 @@ private constructor( override fun toString() = "Metadata{additionalProperties=$additionalProperties}" } + /** + * Payment configuration for the customer, applicable when using Orb Invoicing with a supported + * payment provider such as Stripe. + */ + class PaymentConfiguration + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val paymentProviders: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("payment_providers") + @ExcludeMissing + paymentProviders: JsonField> = JsonMissing.of() + ) : this(paymentProviders, mutableMapOf()) + + /** + * Provider-specific payment configuration. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun paymentProviders(): List? = + paymentProviders.getNullable("payment_providers") + + /** + * Returns the raw JSON value of [paymentProviders]. + * + * Unlike [paymentProviders], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("payment_providers") + @ExcludeMissing + fun _paymentProviders(): JsonField> = paymentProviders + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [PaymentConfiguration]. */ + fun builder() = Builder() + } + + /** A builder for [PaymentConfiguration]. */ + class Builder internal constructor() { + + private var paymentProviders: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(paymentConfiguration: PaymentConfiguration) = apply { + paymentProviders = paymentConfiguration.paymentProviders.map { it.toMutableList() } + additionalProperties = paymentConfiguration.additionalProperties.toMutableMap() + } + + /** Provider-specific payment configuration. */ + fun paymentProviders(paymentProviders: List) = + paymentProviders(JsonField.of(paymentProviders)) + + /** + * Sets [Builder.paymentProviders] to an arbitrary JSON value. + * + * You should usually call [Builder.paymentProviders] with a well-typed + * `List` value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun paymentProviders(paymentProviders: JsonField>) = apply { + this.paymentProviders = paymentProviders.map { it.toMutableList() } + } + + /** + * Adds a single [PaymentProvider] to [paymentProviders]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addPaymentProvider(paymentProvider: PaymentProvider) = apply { + paymentProviders = + (paymentProviders ?: JsonField.of(mutableListOf())).also { + checkKnown("paymentProviders", it).add(paymentProvider) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [PaymentConfiguration]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): PaymentConfiguration = + PaymentConfiguration( + (paymentProviders ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): PaymentConfiguration = apply { + if (validated) { + return@apply + } + + paymentProviders()?.forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (paymentProviders.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + class PaymentProvider + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val providerType: JsonField, + private val excludedPaymentMethodTypes: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("provider_type") + @ExcludeMissing + providerType: JsonField = JsonMissing.of(), + @JsonProperty("excluded_payment_method_types") + @ExcludeMissing + excludedPaymentMethodTypes: JsonField> = JsonMissing.of(), + ) : this(providerType, excludedPaymentMethodTypes, mutableMapOf()) + + /** + * The payment provider to configure. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun providerType(): ProviderType = providerType.getRequired("provider_type") + + /** + * List of Stripe payment method types to exclude for this customer. Excluded payment + * methods will not be available for the customer to select during payment, and will not + * be used for auto-collection. If a customer's default payment method becomes excluded, + * Orb will attempt to use the next available compatible payment method for + * auto-collection. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun excludedPaymentMethodTypes(): List? = + excludedPaymentMethodTypes.getNullable("excluded_payment_method_types") + + /** + * Returns the raw JSON value of [providerType]. + * + * Unlike [providerType], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("provider_type") + @ExcludeMissing + fun _providerType(): JsonField = providerType + + /** + * Returns the raw JSON value of [excludedPaymentMethodTypes]. + * + * Unlike [excludedPaymentMethodTypes], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("excluded_payment_method_types") + @ExcludeMissing + fun _excludedPaymentMethodTypes(): JsonField> = excludedPaymentMethodTypes + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [PaymentProvider]. + * + * The following fields are required: + * ```kotlin + * .providerType() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [PaymentProvider]. */ + class Builder internal constructor() { + + private var providerType: JsonField? = null + private var excludedPaymentMethodTypes: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(paymentProvider: PaymentProvider) = apply { + providerType = paymentProvider.providerType + excludedPaymentMethodTypes = + paymentProvider.excludedPaymentMethodTypes.map { it.toMutableList() } + additionalProperties = paymentProvider.additionalProperties.toMutableMap() + } + + /** The payment provider to configure. */ + fun providerType(providerType: ProviderType) = + providerType(JsonField.of(providerType)) + + /** + * Sets [Builder.providerType] to an arbitrary JSON value. + * + * You should usually call [Builder.providerType] with a well-typed [ProviderType] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun providerType(providerType: JsonField) = apply { + this.providerType = providerType + } + + /** + * List of Stripe payment method types to exclude for this customer. Excluded + * payment methods will not be available for the customer to select during payment, + * and will not be used for auto-collection. If a customer's default payment method + * becomes excluded, Orb will attempt to use the next available compatible payment + * method for auto-collection. + */ + fun excludedPaymentMethodTypes(excludedPaymentMethodTypes: List) = + excludedPaymentMethodTypes(JsonField.of(excludedPaymentMethodTypes)) + + /** + * Sets [Builder.excludedPaymentMethodTypes] to an arbitrary JSON value. + * + * You should usually call [Builder.excludedPaymentMethodTypes] with a well-typed + * `List` value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun excludedPaymentMethodTypes( + excludedPaymentMethodTypes: JsonField> + ) = apply { + this.excludedPaymentMethodTypes = + excludedPaymentMethodTypes.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [excludedPaymentMethodTypes]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addExcludedPaymentMethodType(excludedPaymentMethodType: String) = apply { + excludedPaymentMethodTypes = + (excludedPaymentMethodTypes ?: JsonField.of(mutableListOf())).also { + checkKnown("excludedPaymentMethodTypes", it) + .add(excludedPaymentMethodType) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [PaymentProvider]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .providerType() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): PaymentProvider = + PaymentProvider( + checkRequired("providerType", providerType), + (excludedPaymentMethodTypes ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): PaymentProvider = apply { + if (validated) { + return@apply + } + + providerType().validate() + excludedPaymentMethodTypes() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (providerType.asKnown()?.validity() ?: 0) + + (excludedPaymentMethodTypes.asKnown()?.size ?: 0) + + /** The payment provider to configure. */ + class ProviderType + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val STRIPE = of("stripe") + + fun of(value: String) = ProviderType(JsonField.of(value)) + } + + /** An enum containing [ProviderType]'s known values. */ + enum class Known { + STRIPE + } + + /** + * An enum containing [ProviderType]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [ProviderType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + STRIPE, + /** + * An enum member indicating that [ProviderType] was instantiated with an + * unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + STRIPE -> Value.STRIPE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + STRIPE -> Known.STRIPE + else -> throw OrbInvalidDataException("Unknown ProviderType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): ProviderType = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ProviderType && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PaymentProvider && + providerType == other.providerType && + excludedPaymentMethodTypes == other.excludedPaymentMethodTypes && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(providerType, excludedPaymentMethodTypes, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "PaymentProvider{providerType=$providerType, excludedPaymentMethodTypes=$excludedPaymentMethodTypes, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PaymentConfiguration && + paymentProviders == other.paymentProviders && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(paymentProviders, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "PaymentConfiguration{paymentProviders=$paymentProviders, additionalProperties=$additionalProperties}" + } + /** * This is used for creating charges or invoices in an external system via Orb. When not in test * mode, the connection must first be configured in the Orb webapp. diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerUpdateByExternalIdParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerUpdateByExternalIdParams.kt index 45dd51cca..068cf3bf2 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerUpdateByExternalIdParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerUpdateByExternalIdParams.kt @@ -150,6 +150,15 @@ private constructor( */ fun name(): String? = body.name() + /** + * Payment configuration for the customer, applicable when using Orb Invoicing with a supported + * payment provider such as Stripe. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun paymentConfiguration(): PaymentConfiguration? = body.paymentConfiguration() + /** * This is used for creating charges or invoices in an external system via Orb. When not in test * mode: @@ -427,6 +436,14 @@ private constructor( */ fun _name(): JsonField = body._name() + /** + * Returns the raw JSON value of [paymentConfiguration]. + * + * Unlike [paymentConfiguration], this method doesn't throw if the JSON field has an unexpected + * type. + */ + fun _paymentConfiguration(): JsonField = body._paymentConfiguration() + /** * Returns the raw JSON value of [paymentProvider]. * @@ -744,6 +761,25 @@ private constructor( */ fun name(name: JsonField) = apply { body.name(name) } + /** + * Payment configuration for the customer, applicable when using Orb Invoicing with a + * supported payment provider such as Stripe. + */ + fun paymentConfiguration(paymentConfiguration: PaymentConfiguration?) = apply { + body.paymentConfiguration(paymentConfiguration) + } + + /** + * Sets [Builder.paymentConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.paymentConfiguration] with a well-typed + * [PaymentConfiguration] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun paymentConfiguration(paymentConfiguration: JsonField) = apply { + body.paymentConfiguration(paymentConfiguration) + } + /** * This is used for creating charges or invoices in an external system via Orb. When not in * test mode: @@ -1248,6 +1284,7 @@ private constructor( private val hierarchy: JsonField, private val metadata: JsonField, private val name: JsonField, + private val paymentConfiguration: JsonField, private val paymentProvider: JsonField, private val paymentProviderId: JsonField, private val reportingConfiguration: JsonField, @@ -1292,6 +1329,9 @@ private constructor( @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("payment_configuration") + @ExcludeMissing + paymentConfiguration: JsonField = JsonMissing.of(), @JsonProperty("payment_provider") @ExcludeMissing paymentProvider: JsonField = JsonMissing.of(), @@ -1323,6 +1363,7 @@ private constructor( hierarchy, metadata, name, + paymentConfiguration, paymentProvider, paymentProviderId, reportingConfiguration, @@ -1436,6 +1477,16 @@ private constructor( */ fun name(): String? = name.getNullable("name") + /** + * Payment configuration for the customer, applicable when using Orb Invoicing with a + * supported payment provider such as Stripe. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun paymentConfiguration(): PaymentConfiguration? = + paymentConfiguration.getNullable("payment_configuration") + /** * This is used for creating charges or invoices in an external system via Orb. When not in * test mode: @@ -1735,6 +1786,16 @@ private constructor( */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + /** + * Returns the raw JSON value of [paymentConfiguration]. + * + * Unlike [paymentConfiguration], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("payment_configuration") + @ExcludeMissing + fun _paymentConfiguration(): JsonField = paymentConfiguration + /** * Returns the raw JSON value of [paymentProvider]. * @@ -1826,6 +1887,7 @@ private constructor( private var hierarchy: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var name: JsonField = JsonMissing.of() + private var paymentConfiguration: JsonField = JsonMissing.of() private var paymentProvider: JsonField = JsonMissing.of() private var paymentProviderId: JsonField = JsonMissing.of() private var reportingConfiguration: JsonField = @@ -1848,6 +1910,7 @@ private constructor( hierarchy = body.hierarchy metadata = body.metadata name = body.name + paymentConfiguration = body.paymentConfiguration paymentProvider = body.paymentProvider paymentProviderId = body.paymentProviderId reportingConfiguration = body.reportingConfiguration @@ -2081,6 +2144,25 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } + /** + * Payment configuration for the customer, applicable when using Orb Invoicing with a + * supported payment provider such as Stripe. + */ + fun paymentConfiguration(paymentConfiguration: PaymentConfiguration?) = + paymentConfiguration(JsonField.ofNullable(paymentConfiguration)) + + /** + * Sets [Builder.paymentConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.paymentConfiguration] with a well-typed + * [PaymentConfiguration] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun paymentConfiguration(paymentConfiguration: JsonField) = + apply { + this.paymentConfiguration = paymentConfiguration + } + /** * This is used for creating charges or invoices in an external system via Orb. When not * in test mode: @@ -2465,6 +2547,7 @@ private constructor( hierarchy, metadata, name, + paymentConfiguration, paymentProvider, paymentProviderId, reportingConfiguration, @@ -2494,6 +2577,7 @@ private constructor( hierarchy()?.validate() metadata()?.validate() name() + paymentConfiguration()?.validate() paymentProvider()?.validate() paymentProviderId() reportingConfiguration()?.validate() @@ -2530,6 +2614,7 @@ private constructor( (hierarchy.asKnown()?.validity() ?: 0) + (metadata.asKnown()?.validity() ?: 0) + (if (name.asKnown() == null) 0 else 1) + + (paymentConfiguration.asKnown()?.validity() ?: 0) + (paymentProvider.asKnown()?.validity() ?: 0) + (if (paymentProviderId.asKnown() == null) 0 else 1) + (reportingConfiguration.asKnown()?.validity() ?: 0) + @@ -2555,6 +2640,7 @@ private constructor( hierarchy == other.hierarchy && metadata == other.metadata && name == other.name && + paymentConfiguration == other.paymentConfiguration && paymentProvider == other.paymentProvider && paymentProviderId == other.paymentProviderId && reportingConfiguration == other.reportingConfiguration && @@ -2578,6 +2664,7 @@ private constructor( hierarchy, metadata, name, + paymentConfiguration, paymentProvider, paymentProviderId, reportingConfiguration, @@ -2591,7 +2678,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Body{accountingSyncConfiguration=$accountingSyncConfiguration, additionalEmails=$additionalEmails, autoCollection=$autoCollection, autoIssuance=$autoIssuance, billingAddress=$billingAddress, currency=$currency, email=$email, emailDelivery=$emailDelivery, externalCustomerId=$externalCustomerId, hierarchy=$hierarchy, metadata=$metadata, name=$name, paymentProvider=$paymentProvider, paymentProviderId=$paymentProviderId, reportingConfiguration=$reportingConfiguration, shippingAddress=$shippingAddress, taxConfiguration=$taxConfiguration, taxId=$taxId, additionalProperties=$additionalProperties}" + "Body{accountingSyncConfiguration=$accountingSyncConfiguration, additionalEmails=$additionalEmails, autoCollection=$autoCollection, autoIssuance=$autoIssuance, billingAddress=$billingAddress, currency=$currency, email=$email, emailDelivery=$emailDelivery, externalCustomerId=$externalCustomerId, hierarchy=$hierarchy, metadata=$metadata, name=$name, paymentConfiguration=$paymentConfiguration, paymentProvider=$paymentProvider, paymentProviderId=$paymentProviderId, reportingConfiguration=$reportingConfiguration, shippingAddress=$shippingAddress, taxConfiguration=$taxConfiguration, taxId=$taxId, additionalProperties=$additionalProperties}" } /** @@ -2696,6 +2783,546 @@ private constructor( override fun toString() = "Metadata{additionalProperties=$additionalProperties}" } + /** + * Payment configuration for the customer, applicable when using Orb Invoicing with a supported + * payment provider such as Stripe. + */ + class PaymentConfiguration + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val paymentProviders: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("payment_providers") + @ExcludeMissing + paymentProviders: JsonField> = JsonMissing.of() + ) : this(paymentProviders, mutableMapOf()) + + /** + * Provider-specific payment configuration. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun paymentProviders(): List? = + paymentProviders.getNullable("payment_providers") + + /** + * Returns the raw JSON value of [paymentProviders]. + * + * Unlike [paymentProviders], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("payment_providers") + @ExcludeMissing + fun _paymentProviders(): JsonField> = paymentProviders + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [PaymentConfiguration]. */ + fun builder() = Builder() + } + + /** A builder for [PaymentConfiguration]. */ + class Builder internal constructor() { + + private var paymentProviders: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(paymentConfiguration: PaymentConfiguration) = apply { + paymentProviders = paymentConfiguration.paymentProviders.map { it.toMutableList() } + additionalProperties = paymentConfiguration.additionalProperties.toMutableMap() + } + + /** Provider-specific payment configuration. */ + fun paymentProviders(paymentProviders: List) = + paymentProviders(JsonField.of(paymentProviders)) + + /** + * Sets [Builder.paymentProviders] to an arbitrary JSON value. + * + * You should usually call [Builder.paymentProviders] with a well-typed + * `List` value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun paymentProviders(paymentProviders: JsonField>) = apply { + this.paymentProviders = paymentProviders.map { it.toMutableList() } + } + + /** + * Adds a single [PaymentProvider] to [paymentProviders]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addPaymentProvider(paymentProvider: PaymentProvider) = apply { + paymentProviders = + (paymentProviders ?: JsonField.of(mutableListOf())).also { + checkKnown("paymentProviders", it).add(paymentProvider) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [PaymentConfiguration]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): PaymentConfiguration = + PaymentConfiguration( + (paymentProviders ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): PaymentConfiguration = apply { + if (validated) { + return@apply + } + + paymentProviders()?.forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (paymentProviders.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + class PaymentProvider + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val providerType: JsonField, + private val excludedPaymentMethodTypes: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("provider_type") + @ExcludeMissing + providerType: JsonField = JsonMissing.of(), + @JsonProperty("excluded_payment_method_types") + @ExcludeMissing + excludedPaymentMethodTypes: JsonField> = JsonMissing.of(), + ) : this(providerType, excludedPaymentMethodTypes, mutableMapOf()) + + /** + * The payment provider to configure. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun providerType(): ProviderType = providerType.getRequired("provider_type") + + /** + * List of Stripe payment method types to exclude for this customer. Excluded payment + * methods will not be available for the customer to select during payment, and will not + * be used for auto-collection. If a customer's default payment method becomes excluded, + * Orb will attempt to use the next available compatible payment method for + * auto-collection. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun excludedPaymentMethodTypes(): List? = + excludedPaymentMethodTypes.getNullable("excluded_payment_method_types") + + /** + * Returns the raw JSON value of [providerType]. + * + * Unlike [providerType], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("provider_type") + @ExcludeMissing + fun _providerType(): JsonField = providerType + + /** + * Returns the raw JSON value of [excludedPaymentMethodTypes]. + * + * Unlike [excludedPaymentMethodTypes], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("excluded_payment_method_types") + @ExcludeMissing + fun _excludedPaymentMethodTypes(): JsonField> = excludedPaymentMethodTypes + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [PaymentProvider]. + * + * The following fields are required: + * ```kotlin + * .providerType() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [PaymentProvider]. */ + class Builder internal constructor() { + + private var providerType: JsonField? = null + private var excludedPaymentMethodTypes: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(paymentProvider: PaymentProvider) = apply { + providerType = paymentProvider.providerType + excludedPaymentMethodTypes = + paymentProvider.excludedPaymentMethodTypes.map { it.toMutableList() } + additionalProperties = paymentProvider.additionalProperties.toMutableMap() + } + + /** The payment provider to configure. */ + fun providerType(providerType: ProviderType) = + providerType(JsonField.of(providerType)) + + /** + * Sets [Builder.providerType] to an arbitrary JSON value. + * + * You should usually call [Builder.providerType] with a well-typed [ProviderType] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun providerType(providerType: JsonField) = apply { + this.providerType = providerType + } + + /** + * List of Stripe payment method types to exclude for this customer. Excluded + * payment methods will not be available for the customer to select during payment, + * and will not be used for auto-collection. If a customer's default payment method + * becomes excluded, Orb will attempt to use the next available compatible payment + * method for auto-collection. + */ + fun excludedPaymentMethodTypes(excludedPaymentMethodTypes: List) = + excludedPaymentMethodTypes(JsonField.of(excludedPaymentMethodTypes)) + + /** + * Sets [Builder.excludedPaymentMethodTypes] to an arbitrary JSON value. + * + * You should usually call [Builder.excludedPaymentMethodTypes] with a well-typed + * `List` value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun excludedPaymentMethodTypes( + excludedPaymentMethodTypes: JsonField> + ) = apply { + this.excludedPaymentMethodTypes = + excludedPaymentMethodTypes.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [excludedPaymentMethodTypes]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addExcludedPaymentMethodType(excludedPaymentMethodType: String) = apply { + excludedPaymentMethodTypes = + (excludedPaymentMethodTypes ?: JsonField.of(mutableListOf())).also { + checkKnown("excludedPaymentMethodTypes", it) + .add(excludedPaymentMethodType) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [PaymentProvider]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .providerType() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): PaymentProvider = + PaymentProvider( + checkRequired("providerType", providerType), + (excludedPaymentMethodTypes ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): PaymentProvider = apply { + if (validated) { + return@apply + } + + providerType().validate() + excludedPaymentMethodTypes() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (providerType.asKnown()?.validity() ?: 0) + + (excludedPaymentMethodTypes.asKnown()?.size ?: 0) + + /** The payment provider to configure. */ + class ProviderType + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val STRIPE = of("stripe") + + fun of(value: String) = ProviderType(JsonField.of(value)) + } + + /** An enum containing [ProviderType]'s known values. */ + enum class Known { + STRIPE + } + + /** + * An enum containing [ProviderType]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [ProviderType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + STRIPE, + /** + * An enum member indicating that [ProviderType] was instantiated with an + * unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + STRIPE -> Value.STRIPE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + STRIPE -> Known.STRIPE + else -> throw OrbInvalidDataException("Unknown ProviderType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): ProviderType = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ProviderType && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PaymentProvider && + providerType == other.providerType && + excludedPaymentMethodTypes == other.excludedPaymentMethodTypes && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(providerType, excludedPaymentMethodTypes, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "PaymentProvider{providerType=$providerType, excludedPaymentMethodTypes=$excludedPaymentMethodTypes, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PaymentConfiguration && + paymentProviders == other.paymentProviders && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(paymentProviders, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "PaymentConfiguration{paymentProviders=$paymentProviders, additionalProperties=$additionalProperties}" + } + /** * This is used for creating charges or invoices in an external system via Orb. When not in test * mode: diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerUpdateParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerUpdateParams.kt index 2ed59bfba..cedbbdcc2 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerUpdateParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerUpdateParams.kt @@ -151,6 +151,15 @@ private constructor( */ fun name(): String? = body.name() + /** + * Payment configuration for the customer, applicable when using Orb Invoicing with a supported + * payment provider such as Stripe. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun paymentConfiguration(): PaymentConfiguration? = body.paymentConfiguration() + /** * This is used for creating charges or invoices in an external system via Orb. When not in test * mode: @@ -428,6 +437,14 @@ private constructor( */ fun _name(): JsonField = body._name() + /** + * Returns the raw JSON value of [paymentConfiguration]. + * + * Unlike [paymentConfiguration], this method doesn't throw if the JSON field has an unexpected + * type. + */ + fun _paymentConfiguration(): JsonField = body._paymentConfiguration() + /** * Returns the raw JSON value of [paymentProvider]. * @@ -740,6 +757,25 @@ private constructor( */ fun name(name: JsonField) = apply { body.name(name) } + /** + * Payment configuration for the customer, applicable when using Orb Invoicing with a + * supported payment provider such as Stripe. + */ + fun paymentConfiguration(paymentConfiguration: PaymentConfiguration?) = apply { + body.paymentConfiguration(paymentConfiguration) + } + + /** + * Sets [Builder.paymentConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.paymentConfiguration] with a well-typed + * [PaymentConfiguration] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun paymentConfiguration(paymentConfiguration: JsonField) = apply { + body.paymentConfiguration(paymentConfiguration) + } + /** * This is used for creating charges or invoices in an external system via Orb. When not in * test mode: @@ -1244,6 +1280,7 @@ private constructor( private val hierarchy: JsonField, private val metadata: JsonField, private val name: JsonField, + private val paymentConfiguration: JsonField, private val paymentProvider: JsonField, private val paymentProviderId: JsonField, private val reportingConfiguration: JsonField, @@ -1288,6 +1325,9 @@ private constructor( @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("payment_configuration") + @ExcludeMissing + paymentConfiguration: JsonField = JsonMissing.of(), @JsonProperty("payment_provider") @ExcludeMissing paymentProvider: JsonField = JsonMissing.of(), @@ -1319,6 +1359,7 @@ private constructor( hierarchy, metadata, name, + paymentConfiguration, paymentProvider, paymentProviderId, reportingConfiguration, @@ -1432,6 +1473,16 @@ private constructor( */ fun name(): String? = name.getNullable("name") + /** + * Payment configuration for the customer, applicable when using Orb Invoicing with a + * supported payment provider such as Stripe. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun paymentConfiguration(): PaymentConfiguration? = + paymentConfiguration.getNullable("payment_configuration") + /** * This is used for creating charges or invoices in an external system via Orb. When not in * test mode: @@ -1731,6 +1782,16 @@ private constructor( */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + /** + * Returns the raw JSON value of [paymentConfiguration]. + * + * Unlike [paymentConfiguration], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("payment_configuration") + @ExcludeMissing + fun _paymentConfiguration(): JsonField = paymentConfiguration + /** * Returns the raw JSON value of [paymentProvider]. * @@ -1822,6 +1883,7 @@ private constructor( private var hierarchy: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var name: JsonField = JsonMissing.of() + private var paymentConfiguration: JsonField = JsonMissing.of() private var paymentProvider: JsonField = JsonMissing.of() private var paymentProviderId: JsonField = JsonMissing.of() private var reportingConfiguration: JsonField = @@ -1844,6 +1906,7 @@ private constructor( hierarchy = body.hierarchy metadata = body.metadata name = body.name + paymentConfiguration = body.paymentConfiguration paymentProvider = body.paymentProvider paymentProviderId = body.paymentProviderId reportingConfiguration = body.reportingConfiguration @@ -2077,6 +2140,25 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } + /** + * Payment configuration for the customer, applicable when using Orb Invoicing with a + * supported payment provider such as Stripe. + */ + fun paymentConfiguration(paymentConfiguration: PaymentConfiguration?) = + paymentConfiguration(JsonField.ofNullable(paymentConfiguration)) + + /** + * Sets [Builder.paymentConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.paymentConfiguration] with a well-typed + * [PaymentConfiguration] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun paymentConfiguration(paymentConfiguration: JsonField) = + apply { + this.paymentConfiguration = paymentConfiguration + } + /** * This is used for creating charges or invoices in an external system via Orb. When not * in test mode: @@ -2461,6 +2543,7 @@ private constructor( hierarchy, metadata, name, + paymentConfiguration, paymentProvider, paymentProviderId, reportingConfiguration, @@ -2490,6 +2573,7 @@ private constructor( hierarchy()?.validate() metadata()?.validate() name() + paymentConfiguration()?.validate() paymentProvider()?.validate() paymentProviderId() reportingConfiguration()?.validate() @@ -2526,6 +2610,7 @@ private constructor( (hierarchy.asKnown()?.validity() ?: 0) + (metadata.asKnown()?.validity() ?: 0) + (if (name.asKnown() == null) 0 else 1) + + (paymentConfiguration.asKnown()?.validity() ?: 0) + (paymentProvider.asKnown()?.validity() ?: 0) + (if (paymentProviderId.asKnown() == null) 0 else 1) + (reportingConfiguration.asKnown()?.validity() ?: 0) + @@ -2551,6 +2636,7 @@ private constructor( hierarchy == other.hierarchy && metadata == other.metadata && name == other.name && + paymentConfiguration == other.paymentConfiguration && paymentProvider == other.paymentProvider && paymentProviderId == other.paymentProviderId && reportingConfiguration == other.reportingConfiguration && @@ -2574,6 +2660,7 @@ private constructor( hierarchy, metadata, name, + paymentConfiguration, paymentProvider, paymentProviderId, reportingConfiguration, @@ -2587,7 +2674,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Body{accountingSyncConfiguration=$accountingSyncConfiguration, additionalEmails=$additionalEmails, autoCollection=$autoCollection, autoIssuance=$autoIssuance, billingAddress=$billingAddress, currency=$currency, email=$email, emailDelivery=$emailDelivery, externalCustomerId=$externalCustomerId, hierarchy=$hierarchy, metadata=$metadata, name=$name, paymentProvider=$paymentProvider, paymentProviderId=$paymentProviderId, reportingConfiguration=$reportingConfiguration, shippingAddress=$shippingAddress, taxConfiguration=$taxConfiguration, taxId=$taxId, additionalProperties=$additionalProperties}" + "Body{accountingSyncConfiguration=$accountingSyncConfiguration, additionalEmails=$additionalEmails, autoCollection=$autoCollection, autoIssuance=$autoIssuance, billingAddress=$billingAddress, currency=$currency, email=$email, emailDelivery=$emailDelivery, externalCustomerId=$externalCustomerId, hierarchy=$hierarchy, metadata=$metadata, name=$name, paymentConfiguration=$paymentConfiguration, paymentProvider=$paymentProvider, paymentProviderId=$paymentProviderId, reportingConfiguration=$reportingConfiguration, shippingAddress=$shippingAddress, taxConfiguration=$taxConfiguration, taxId=$taxId, additionalProperties=$additionalProperties}" } /** @@ -2692,6 +2779,546 @@ private constructor( override fun toString() = "Metadata{additionalProperties=$additionalProperties}" } + /** + * Payment configuration for the customer, applicable when using Orb Invoicing with a supported + * payment provider such as Stripe. + */ + class PaymentConfiguration + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val paymentProviders: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("payment_providers") + @ExcludeMissing + paymentProviders: JsonField> = JsonMissing.of() + ) : this(paymentProviders, mutableMapOf()) + + /** + * Provider-specific payment configuration. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun paymentProviders(): List? = + paymentProviders.getNullable("payment_providers") + + /** + * Returns the raw JSON value of [paymentProviders]. + * + * Unlike [paymentProviders], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("payment_providers") + @ExcludeMissing + fun _paymentProviders(): JsonField> = paymentProviders + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [PaymentConfiguration]. */ + fun builder() = Builder() + } + + /** A builder for [PaymentConfiguration]. */ + class Builder internal constructor() { + + private var paymentProviders: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(paymentConfiguration: PaymentConfiguration) = apply { + paymentProviders = paymentConfiguration.paymentProviders.map { it.toMutableList() } + additionalProperties = paymentConfiguration.additionalProperties.toMutableMap() + } + + /** Provider-specific payment configuration. */ + fun paymentProviders(paymentProviders: List) = + paymentProviders(JsonField.of(paymentProviders)) + + /** + * Sets [Builder.paymentProviders] to an arbitrary JSON value. + * + * You should usually call [Builder.paymentProviders] with a well-typed + * `List` value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun paymentProviders(paymentProviders: JsonField>) = apply { + this.paymentProviders = paymentProviders.map { it.toMutableList() } + } + + /** + * Adds a single [PaymentProvider] to [paymentProviders]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addPaymentProvider(paymentProvider: PaymentProvider) = apply { + paymentProviders = + (paymentProviders ?: JsonField.of(mutableListOf())).also { + checkKnown("paymentProviders", it).add(paymentProvider) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [PaymentConfiguration]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): PaymentConfiguration = + PaymentConfiguration( + (paymentProviders ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): PaymentConfiguration = apply { + if (validated) { + return@apply + } + + paymentProviders()?.forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (paymentProviders.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + class PaymentProvider + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val providerType: JsonField, + private val excludedPaymentMethodTypes: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("provider_type") + @ExcludeMissing + providerType: JsonField = JsonMissing.of(), + @JsonProperty("excluded_payment_method_types") + @ExcludeMissing + excludedPaymentMethodTypes: JsonField> = JsonMissing.of(), + ) : this(providerType, excludedPaymentMethodTypes, mutableMapOf()) + + /** + * The payment provider to configure. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun providerType(): ProviderType = providerType.getRequired("provider_type") + + /** + * List of Stripe payment method types to exclude for this customer. Excluded payment + * methods will not be available for the customer to select during payment, and will not + * be used for auto-collection. If a customer's default payment method becomes excluded, + * Orb will attempt to use the next available compatible payment method for + * auto-collection. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun excludedPaymentMethodTypes(): List? = + excludedPaymentMethodTypes.getNullable("excluded_payment_method_types") + + /** + * Returns the raw JSON value of [providerType]. + * + * Unlike [providerType], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("provider_type") + @ExcludeMissing + fun _providerType(): JsonField = providerType + + /** + * Returns the raw JSON value of [excludedPaymentMethodTypes]. + * + * Unlike [excludedPaymentMethodTypes], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("excluded_payment_method_types") + @ExcludeMissing + fun _excludedPaymentMethodTypes(): JsonField> = excludedPaymentMethodTypes + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [PaymentProvider]. + * + * The following fields are required: + * ```kotlin + * .providerType() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [PaymentProvider]. */ + class Builder internal constructor() { + + private var providerType: JsonField? = null + private var excludedPaymentMethodTypes: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(paymentProvider: PaymentProvider) = apply { + providerType = paymentProvider.providerType + excludedPaymentMethodTypes = + paymentProvider.excludedPaymentMethodTypes.map { it.toMutableList() } + additionalProperties = paymentProvider.additionalProperties.toMutableMap() + } + + /** The payment provider to configure. */ + fun providerType(providerType: ProviderType) = + providerType(JsonField.of(providerType)) + + /** + * Sets [Builder.providerType] to an arbitrary JSON value. + * + * You should usually call [Builder.providerType] with a well-typed [ProviderType] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun providerType(providerType: JsonField) = apply { + this.providerType = providerType + } + + /** + * List of Stripe payment method types to exclude for this customer. Excluded + * payment methods will not be available for the customer to select during payment, + * and will not be used for auto-collection. If a customer's default payment method + * becomes excluded, Orb will attempt to use the next available compatible payment + * method for auto-collection. + */ + fun excludedPaymentMethodTypes(excludedPaymentMethodTypes: List) = + excludedPaymentMethodTypes(JsonField.of(excludedPaymentMethodTypes)) + + /** + * Sets [Builder.excludedPaymentMethodTypes] to an arbitrary JSON value. + * + * You should usually call [Builder.excludedPaymentMethodTypes] with a well-typed + * `List` value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun excludedPaymentMethodTypes( + excludedPaymentMethodTypes: JsonField> + ) = apply { + this.excludedPaymentMethodTypes = + excludedPaymentMethodTypes.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [excludedPaymentMethodTypes]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addExcludedPaymentMethodType(excludedPaymentMethodType: String) = apply { + excludedPaymentMethodTypes = + (excludedPaymentMethodTypes ?: JsonField.of(mutableListOf())).also { + checkKnown("excludedPaymentMethodTypes", it) + .add(excludedPaymentMethodType) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [PaymentProvider]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .providerType() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): PaymentProvider = + PaymentProvider( + checkRequired("providerType", providerType), + (excludedPaymentMethodTypes ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): PaymentProvider = apply { + if (validated) { + return@apply + } + + providerType().validate() + excludedPaymentMethodTypes() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (providerType.asKnown()?.validity() ?: 0) + + (excludedPaymentMethodTypes.asKnown()?.size ?: 0) + + /** The payment provider to configure. */ + class ProviderType + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val STRIPE = of("stripe") + + fun of(value: String) = ProviderType(JsonField.of(value)) + } + + /** An enum containing [ProviderType]'s known values. */ + enum class Known { + STRIPE + } + + /** + * An enum containing [ProviderType]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [ProviderType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + STRIPE, + /** + * An enum member indicating that [ProviderType] was instantiated with an + * unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + STRIPE -> Value.STRIPE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + STRIPE -> Known.STRIPE + else -> throw OrbInvalidDataException("Unknown ProviderType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): ProviderType = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ProviderType && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PaymentProvider && + providerType == other.providerType && + excludedPaymentMethodTypes == other.excludedPaymentMethodTypes && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(providerType, excludedPaymentMethodTypes, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "PaymentProvider{providerType=$providerType, excludedPaymentMethodTypes=$excludedPaymentMethodTypes, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PaymentConfiguration && + paymentProviders == other.paymentProviders && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(paymentProviders, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "PaymentConfiguration{paymentProviders=$paymentProviders, additionalProperties=$additionalProperties}" + } + /** * This is used for creating charges or invoices in an external system via Orb. When not in test * mode: diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreateParamsTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreateParamsTest.kt index 8ec9d01ab..cae6f5600 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreateParamsTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreateParamsTest.kt @@ -51,6 +51,20 @@ internal class CustomerCreateParamsTest { .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) + .paymentConfiguration( + CustomerCreateParams.PaymentConfiguration.builder() + .addPaymentProvider( + CustomerCreateParams.PaymentConfiguration.PaymentProvider.builder() + .providerType( + CustomerCreateParams.PaymentConfiguration.PaymentProvider + .ProviderType + .STRIPE + ) + .addExcludedPaymentMethodType("string") + .build() + ) + .build() + ) .paymentProvider(CustomerCreateParams.PaymentProvider.QUICKBOOKS) .paymentProviderId("payment_provider_id") .reportingConfiguration(NewReportingConfiguration.builder().exempt(true).build()) @@ -127,6 +141,20 @@ internal class CustomerCreateParamsTest { .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) + .paymentConfiguration( + CustomerCreateParams.PaymentConfiguration.builder() + .addPaymentProvider( + CustomerCreateParams.PaymentConfiguration.PaymentProvider.builder() + .providerType( + CustomerCreateParams.PaymentConfiguration.PaymentProvider + .ProviderType + .STRIPE + ) + .addExcludedPaymentMethodType("string") + .build() + ) + .build() + ) .paymentProvider(CustomerCreateParams.PaymentProvider.QUICKBOOKS) .paymentProviderId("payment_provider_id") .reportingConfiguration(NewReportingConfiguration.builder().exempt(true).build()) @@ -204,6 +232,21 @@ internal class CustomerCreateParamsTest { .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) + assertThat(body.paymentConfiguration()) + .isEqualTo( + CustomerCreateParams.PaymentConfiguration.builder() + .addPaymentProvider( + CustomerCreateParams.PaymentConfiguration.PaymentProvider.builder() + .providerType( + CustomerCreateParams.PaymentConfiguration.PaymentProvider + .ProviderType + .STRIPE + ) + .addExcludedPaymentMethodType("string") + .build() + ) + .build() + ) assertThat(body.paymentProvider()) .isEqualTo(CustomerCreateParams.PaymentProvider.QUICKBOOKS) assertThat(body.paymentProviderId()).isEqualTo("payment_provider_id") diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerListPageResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerListPageResponseTest.kt index 1546ebd25..94a0f1744 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerListPageResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerListPageResponseTest.kt @@ -98,6 +98,20 @@ internal class CustomerListPageResponseTest { .build() ) .automaticTaxEnabled(true) + .paymentConfiguration( + Customer.PaymentConfiguration.builder() + .addPaymentProvider( + Customer.PaymentConfiguration.PaymentProvider.builder() + .providerType( + Customer.PaymentConfiguration.PaymentProvider + .ProviderType + .STRIPE + ) + .addExcludedPaymentMethodType("string") + .build() + ) + .build() + ) .reportingConfiguration( Customer.ReportingConfiguration.builder().exempt(true).build() ) @@ -191,6 +205,19 @@ internal class CustomerListPageResponseTest { .build() ) .automaticTaxEnabled(true) + .paymentConfiguration( + Customer.PaymentConfiguration.builder() + .addPaymentProvider( + Customer.PaymentConfiguration.PaymentProvider.builder() + .providerType( + Customer.PaymentConfiguration.PaymentProvider.ProviderType + .STRIPE + ) + .addExcludedPaymentMethodType("string") + .build() + ) + .build() + ) .reportingConfiguration( Customer.ReportingConfiguration.builder().exempt(true).build() ) @@ -288,6 +315,20 @@ internal class CustomerListPageResponseTest { .build() ) .automaticTaxEnabled(true) + .paymentConfiguration( + Customer.PaymentConfiguration.builder() + .addPaymentProvider( + Customer.PaymentConfiguration.PaymentProvider.builder() + .providerType( + Customer.PaymentConfiguration.PaymentProvider + .ProviderType + .STRIPE + ) + .addExcludedPaymentMethodType("string") + .build() + ) + .build() + ) .reportingConfiguration( Customer.ReportingConfiguration.builder().exempt(true).build() ) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerTest.kt index 48275498a..2ec513af7 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerTest.kt @@ -95,6 +95,19 @@ internal class CustomerTest { .build() ) .automaticTaxEnabled(true) + .paymentConfiguration( + Customer.PaymentConfiguration.builder() + .addPaymentProvider( + Customer.PaymentConfiguration.PaymentProvider.builder() + .providerType( + Customer.PaymentConfiguration.PaymentProvider.ProviderType + .STRIPE + ) + .addExcludedPaymentMethodType("string") + .build() + ) + .build() + ) .reportingConfiguration( Customer.ReportingConfiguration.builder().exempt(true).build() ) @@ -185,6 +198,19 @@ internal class CustomerTest { .build() ) assertThat(customer.automaticTaxEnabled()).isEqualTo(true) + assertThat(customer.paymentConfiguration()) + .isEqualTo( + Customer.PaymentConfiguration.builder() + .addPaymentProvider( + Customer.PaymentConfiguration.PaymentProvider.builder() + .providerType( + Customer.PaymentConfiguration.PaymentProvider.ProviderType.STRIPE + ) + .addExcludedPaymentMethodType("string") + .build() + ) + .build() + ) assertThat(customer.reportingConfiguration()) .isEqualTo(Customer.ReportingConfiguration.builder().exempt(true).build()) } @@ -274,6 +300,19 @@ internal class CustomerTest { .build() ) .automaticTaxEnabled(true) + .paymentConfiguration( + Customer.PaymentConfiguration.builder() + .addPaymentProvider( + Customer.PaymentConfiguration.PaymentProvider.builder() + .providerType( + Customer.PaymentConfiguration.PaymentProvider.ProviderType + .STRIPE + ) + .addExcludedPaymentMethodType("string") + .build() + ) + .build() + ) .reportingConfiguration( Customer.ReportingConfiguration.builder().exempt(true).build() ) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerUpdateByExternalIdParamsTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerUpdateByExternalIdParamsTest.kt index ea5e02b39..8ad7c6acc 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerUpdateByExternalIdParamsTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerUpdateByExternalIdParamsTest.kt @@ -52,6 +52,22 @@ internal class CustomerUpdateByExternalIdParamsTest { .build() ) .name("name") + .paymentConfiguration( + CustomerUpdateByExternalIdParams.PaymentConfiguration.builder() + .addPaymentProvider( + CustomerUpdateByExternalIdParams.PaymentConfiguration.PaymentProvider + .builder() + .providerType( + CustomerUpdateByExternalIdParams.PaymentConfiguration + .PaymentProvider + .ProviderType + .STRIPE + ) + .addExcludedPaymentMethodType("string") + .build() + ) + .build() + ) .paymentProvider(CustomerUpdateByExternalIdParams.PaymentProvider.QUICKBOOKS) .paymentProviderId("payment_provider_id") .reportingConfiguration(NewReportingConfiguration.builder().exempt(true).build()) @@ -137,6 +153,22 @@ internal class CustomerUpdateByExternalIdParamsTest { .build() ) .name("name") + .paymentConfiguration( + CustomerUpdateByExternalIdParams.PaymentConfiguration.builder() + .addPaymentProvider( + CustomerUpdateByExternalIdParams.PaymentConfiguration.PaymentProvider + .builder() + .providerType( + CustomerUpdateByExternalIdParams.PaymentConfiguration + .PaymentProvider + .ProviderType + .STRIPE + ) + .addExcludedPaymentMethodType("string") + .build() + ) + .build() + ) .paymentProvider(CustomerUpdateByExternalIdParams.PaymentProvider.QUICKBOOKS) .paymentProviderId("payment_provider_id") .reportingConfiguration(NewReportingConfiguration.builder().exempt(true).build()) @@ -213,6 +245,23 @@ internal class CustomerUpdateByExternalIdParamsTest { .build() ) assertThat(body.name()).isEqualTo("name") + assertThat(body.paymentConfiguration()) + .isEqualTo( + CustomerUpdateByExternalIdParams.PaymentConfiguration.builder() + .addPaymentProvider( + CustomerUpdateByExternalIdParams.PaymentConfiguration.PaymentProvider + .builder() + .providerType( + CustomerUpdateByExternalIdParams.PaymentConfiguration + .PaymentProvider + .ProviderType + .STRIPE + ) + .addExcludedPaymentMethodType("string") + .build() + ) + .build() + ) assertThat(body.paymentProvider()) .isEqualTo(CustomerUpdateByExternalIdParams.PaymentProvider.QUICKBOOKS) assertThat(body.paymentProviderId()).isEqualTo("payment_provider_id") diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerUpdateParamsTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerUpdateParamsTest.kt index 0084366db..823e476a7 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerUpdateParamsTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerUpdateParamsTest.kt @@ -52,6 +52,20 @@ internal class CustomerUpdateParamsTest { .build() ) .name("name") + .paymentConfiguration( + CustomerUpdateParams.PaymentConfiguration.builder() + .addPaymentProvider( + CustomerUpdateParams.PaymentConfiguration.PaymentProvider.builder() + .providerType( + CustomerUpdateParams.PaymentConfiguration.PaymentProvider + .ProviderType + .STRIPE + ) + .addExcludedPaymentMethodType("string") + .build() + ) + .build() + ) .paymentProvider(CustomerUpdateParams.PaymentProvider.QUICKBOOKS) .paymentProviderId("payment_provider_id") .reportingConfiguration(NewReportingConfiguration.builder().exempt(true).build()) @@ -137,6 +151,20 @@ internal class CustomerUpdateParamsTest { .build() ) .name("name") + .paymentConfiguration( + CustomerUpdateParams.PaymentConfiguration.builder() + .addPaymentProvider( + CustomerUpdateParams.PaymentConfiguration.PaymentProvider.builder() + .providerType( + CustomerUpdateParams.PaymentConfiguration.PaymentProvider + .ProviderType + .STRIPE + ) + .addExcludedPaymentMethodType("string") + .build() + ) + .build() + ) .paymentProvider(CustomerUpdateParams.PaymentProvider.QUICKBOOKS) .paymentProviderId("payment_provider_id") .reportingConfiguration(NewReportingConfiguration.builder().exempt(true).build()) @@ -213,6 +241,21 @@ internal class CustomerUpdateParamsTest { .build() ) assertThat(body.name()).isEqualTo("name") + assertThat(body.paymentConfiguration()) + .isEqualTo( + CustomerUpdateParams.PaymentConfiguration.builder() + .addPaymentProvider( + CustomerUpdateParams.PaymentConfiguration.PaymentProvider.builder() + .providerType( + CustomerUpdateParams.PaymentConfiguration.PaymentProvider + .ProviderType + .STRIPE + ) + .addExcludedPaymentMethodType("string") + .build() + ) + .build() + ) assertThat(body.paymentProvider()) .isEqualTo(CustomerUpdateParams.PaymentProvider.QUICKBOOKS) assertThat(body.paymentProviderId()).isEqualTo("payment_provider_id") diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/MutatedSubscriptionTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/MutatedSubscriptionTest.kt index b166f9486..ecbe2b472 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/MutatedSubscriptionTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/MutatedSubscriptionTest.kt @@ -142,6 +142,20 @@ internal class MutatedSubscriptionTest { .build() ) .automaticTaxEnabled(true) + .paymentConfiguration( + Customer.PaymentConfiguration.builder() + .addPaymentProvider( + Customer.PaymentConfiguration.PaymentProvider.builder() + .providerType( + Customer.PaymentConfiguration.PaymentProvider + .ProviderType + .STRIPE + ) + .addExcludedPaymentMethodType("string") + .build() + ) + .build() + ) .reportingConfiguration( Customer.ReportingConfiguration.builder().exempt(true).build() ) @@ -1854,6 +1868,19 @@ internal class MutatedSubscriptionTest { .build() ) .automaticTaxEnabled(true) + .paymentConfiguration( + Customer.PaymentConfiguration.builder() + .addPaymentProvider( + Customer.PaymentConfiguration.PaymentProvider.builder() + .providerType( + Customer.PaymentConfiguration.PaymentProvider.ProviderType + .STRIPE + ) + .addExcludedPaymentMethodType("string") + .build() + ) + .build() + ) .reportingConfiguration( Customer.ReportingConfiguration.builder().exempt(true).build() ) @@ -3505,6 +3532,20 @@ internal class MutatedSubscriptionTest { .build() ) .automaticTaxEnabled(true) + .paymentConfiguration( + Customer.PaymentConfiguration.builder() + .addPaymentProvider( + Customer.PaymentConfiguration.PaymentProvider.builder() + .providerType( + Customer.PaymentConfiguration.PaymentProvider + .ProviderType + .STRIPE + ) + .addExcludedPaymentMethodType("string") + .build() + ) + .build() + ) .reportingConfiguration( Customer.ReportingConfiguration.builder().exempt(true).build() ) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeApplyResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeApplyResponseTest.kt index e1e8abab4..f0aa7dea5 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeApplyResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeApplyResponseTest.kt @@ -158,6 +158,20 @@ internal class SubscriptionChangeApplyResponseTest { .build() ) .automaticTaxEnabled(true) + .paymentConfiguration( + Customer.PaymentConfiguration.builder() + .addPaymentProvider( + Customer.PaymentConfiguration.PaymentProvider.builder() + .providerType( + Customer.PaymentConfiguration.PaymentProvider + .ProviderType + .STRIPE + ) + .addExcludedPaymentMethodType("string") + .build() + ) + .build() + ) .reportingConfiguration( Customer.ReportingConfiguration.builder().exempt(true).build() ) @@ -2128,6 +2142,20 @@ internal class SubscriptionChangeApplyResponseTest { .build() ) .automaticTaxEnabled(true) + .paymentConfiguration( + Customer.PaymentConfiguration.builder() + .addPaymentProvider( + Customer.PaymentConfiguration.PaymentProvider.builder() + .providerType( + Customer.PaymentConfiguration.PaymentProvider + .ProviderType + .STRIPE + ) + .addExcludedPaymentMethodType("string") + .build() + ) + .build() + ) .reportingConfiguration( Customer.ReportingConfiguration.builder().exempt(true).build() ) @@ -3986,6 +4014,20 @@ internal class SubscriptionChangeApplyResponseTest { .build() ) .automaticTaxEnabled(true) + .paymentConfiguration( + Customer.PaymentConfiguration.builder() + .addPaymentProvider( + Customer.PaymentConfiguration.PaymentProvider.builder() + .providerType( + Customer.PaymentConfiguration.PaymentProvider + .ProviderType + .STRIPE + ) + .addExcludedPaymentMethodType("string") + .build() + ) + .build() + ) .reportingConfiguration( Customer.ReportingConfiguration.builder().exempt(true).build() ) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeCancelResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeCancelResponseTest.kt index 260e42e39..53c6d48fe 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeCancelResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeCancelResponseTest.kt @@ -158,6 +158,20 @@ internal class SubscriptionChangeCancelResponseTest { .build() ) .automaticTaxEnabled(true) + .paymentConfiguration( + Customer.PaymentConfiguration.builder() + .addPaymentProvider( + Customer.PaymentConfiguration.PaymentProvider.builder() + .providerType( + Customer.PaymentConfiguration.PaymentProvider + .ProviderType + .STRIPE + ) + .addExcludedPaymentMethodType("string") + .build() + ) + .build() + ) .reportingConfiguration( Customer.ReportingConfiguration.builder().exempt(true).build() ) @@ -2128,6 +2142,20 @@ internal class SubscriptionChangeCancelResponseTest { .build() ) .automaticTaxEnabled(true) + .paymentConfiguration( + Customer.PaymentConfiguration.builder() + .addPaymentProvider( + Customer.PaymentConfiguration.PaymentProvider.builder() + .providerType( + Customer.PaymentConfiguration.PaymentProvider + .ProviderType + .STRIPE + ) + .addExcludedPaymentMethodType("string") + .build() + ) + .build() + ) .reportingConfiguration( Customer.ReportingConfiguration.builder().exempt(true).build() ) @@ -3986,6 +4014,20 @@ internal class SubscriptionChangeCancelResponseTest { .build() ) .automaticTaxEnabled(true) + .paymentConfiguration( + Customer.PaymentConfiguration.builder() + .addPaymentProvider( + Customer.PaymentConfiguration.PaymentProvider.builder() + .providerType( + Customer.PaymentConfiguration.PaymentProvider + .ProviderType + .STRIPE + ) + .addExcludedPaymentMethodType("string") + .build() + ) + .build() + ) .reportingConfiguration( Customer.ReportingConfiguration.builder().exempt(true).build() ) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeRetrieveResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeRetrieveResponseTest.kt index 6d0c99ec2..8f923553a 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeRetrieveResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeRetrieveResponseTest.kt @@ -158,6 +158,20 @@ internal class SubscriptionChangeRetrieveResponseTest { .build() ) .automaticTaxEnabled(true) + .paymentConfiguration( + Customer.PaymentConfiguration.builder() + .addPaymentProvider( + Customer.PaymentConfiguration.PaymentProvider.builder() + .providerType( + Customer.PaymentConfiguration.PaymentProvider + .ProviderType + .STRIPE + ) + .addExcludedPaymentMethodType("string") + .build() + ) + .build() + ) .reportingConfiguration( Customer.ReportingConfiguration.builder().exempt(true).build() ) @@ -2128,6 +2142,20 @@ internal class SubscriptionChangeRetrieveResponseTest { .build() ) .automaticTaxEnabled(true) + .paymentConfiguration( + Customer.PaymentConfiguration.builder() + .addPaymentProvider( + Customer.PaymentConfiguration.PaymentProvider.builder() + .providerType( + Customer.PaymentConfiguration.PaymentProvider + .ProviderType + .STRIPE + ) + .addExcludedPaymentMethodType("string") + .build() + ) + .build() + ) .reportingConfiguration( Customer.ReportingConfiguration.builder().exempt(true).build() ) @@ -3986,6 +4014,20 @@ internal class SubscriptionChangeRetrieveResponseTest { .build() ) .automaticTaxEnabled(true) + .paymentConfiguration( + Customer.PaymentConfiguration.builder() + .addPaymentProvider( + Customer.PaymentConfiguration.PaymentProvider.builder() + .providerType( + Customer.PaymentConfiguration.PaymentProvider + .ProviderType + .STRIPE + ) + .addExcludedPaymentMethodType("string") + .build() + ) + .build() + ) .reportingConfiguration( Customer.ReportingConfiguration.builder().exempt(true).build() ) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionTest.kt index 1b17aae96..29688caf6 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionTest.kt @@ -142,6 +142,20 @@ internal class SubscriptionTest { .build() ) .automaticTaxEnabled(true) + .paymentConfiguration( + Customer.PaymentConfiguration.builder() + .addPaymentProvider( + Customer.PaymentConfiguration.PaymentProvider.builder() + .providerType( + Customer.PaymentConfiguration.PaymentProvider + .ProviderType + .STRIPE + ) + .addExcludedPaymentMethodType("string") + .build() + ) + .build() + ) .reportingConfiguration( Customer.ReportingConfiguration.builder().exempt(true).build() ) @@ -798,6 +812,19 @@ internal class SubscriptionTest { .build() ) .automaticTaxEnabled(true) + .paymentConfiguration( + Customer.PaymentConfiguration.builder() + .addPaymentProvider( + Customer.PaymentConfiguration.PaymentProvider.builder() + .providerType( + Customer.PaymentConfiguration.PaymentProvider.ProviderType + .STRIPE + ) + .addExcludedPaymentMethodType("string") + .build() + ) + .build() + ) .reportingConfiguration( Customer.ReportingConfiguration.builder().exempt(true).build() ) @@ -1456,6 +1483,20 @@ internal class SubscriptionTest { .build() ) .automaticTaxEnabled(true) + .paymentConfiguration( + Customer.PaymentConfiguration.builder() + .addPaymentProvider( + Customer.PaymentConfiguration.PaymentProvider.builder() + .providerType( + Customer.PaymentConfiguration.PaymentProvider + .ProviderType + .STRIPE + ) + .addExcludedPaymentMethodType("string") + .build() + ) + .build() + ) .reportingConfiguration( Customer.ReportingConfiguration.builder().exempt(true).build() ) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionsTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionsTest.kt index 2970d8eb5..93ca1b208 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionsTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionsTest.kt @@ -155,6 +155,20 @@ internal class SubscriptionsTest { .build() ) .automaticTaxEnabled(true) + .paymentConfiguration( + Customer.PaymentConfiguration.builder() + .addPaymentProvider( + Customer.PaymentConfiguration.PaymentProvider.builder() + .providerType( + Customer.PaymentConfiguration.PaymentProvider + .ProviderType + .STRIPE + ) + .addExcludedPaymentMethodType("string") + .build() + ) + .build() + ) .reportingConfiguration( Customer.ReportingConfiguration.builder().exempt(true).build() ) @@ -883,6 +897,20 @@ internal class SubscriptionsTest { .build() ) .automaticTaxEnabled(true) + .paymentConfiguration( + Customer.PaymentConfiguration.builder() + .addPaymentProvider( + Customer.PaymentConfiguration.PaymentProvider.builder() + .providerType( + Customer.PaymentConfiguration.PaymentProvider + .ProviderType + .STRIPE + ) + .addExcludedPaymentMethodType("string") + .build() + ) + .build() + ) .reportingConfiguration( Customer.ReportingConfiguration.builder().exempt(true).build() ) @@ -1585,6 +1613,20 @@ internal class SubscriptionsTest { .build() ) .automaticTaxEnabled(true) + .paymentConfiguration( + Customer.PaymentConfiguration.builder() + .addPaymentProvider( + Customer.PaymentConfiguration.PaymentProvider.builder() + .providerType( + Customer.PaymentConfiguration.PaymentProvider + .ProviderType + .STRIPE + ) + .addExcludedPaymentMethodType("string") + .build() + ) + .build() + ) .reportingConfiguration( Customer.ReportingConfiguration.builder().exempt(true).build() ) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/ErrorHandlingTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/ErrorHandlingTest.kt index cf76a00d2..0de61a15a 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/ErrorHandlingTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/ErrorHandlingTest.kt @@ -119,6 +119,22 @@ internal class ErrorHandlingTest { .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) + .paymentConfiguration( + CustomerCreateParams.PaymentConfiguration.builder() + .addPaymentProvider( + CustomerCreateParams.PaymentConfiguration.PaymentProvider + .builder() + .providerType( + CustomerCreateParams.PaymentConfiguration + .PaymentProvider + .ProviderType + .STRIPE + ) + .addExcludedPaymentMethodType("string") + .build() + ) + .build() + ) .paymentProvider(CustomerCreateParams.PaymentProvider.QUICKBOOKS) .paymentProviderId("payment_provider_id") .reportingConfiguration( @@ -213,6 +229,22 @@ internal class ErrorHandlingTest { .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) + .paymentConfiguration( + CustomerCreateParams.PaymentConfiguration.builder() + .addPaymentProvider( + CustomerCreateParams.PaymentConfiguration.PaymentProvider + .builder() + .providerType( + CustomerCreateParams.PaymentConfiguration + .PaymentProvider + .ProviderType + .STRIPE + ) + .addExcludedPaymentMethodType("string") + .build() + ) + .build() + ) .paymentProvider(CustomerCreateParams.PaymentProvider.QUICKBOOKS) .paymentProviderId("payment_provider_id") .reportingConfiguration( @@ -307,6 +339,22 @@ internal class ErrorHandlingTest { .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) + .paymentConfiguration( + CustomerCreateParams.PaymentConfiguration.builder() + .addPaymentProvider( + CustomerCreateParams.PaymentConfiguration.PaymentProvider + .builder() + .providerType( + CustomerCreateParams.PaymentConfiguration + .PaymentProvider + .ProviderType + .STRIPE + ) + .addExcludedPaymentMethodType("string") + .build() + ) + .build() + ) .paymentProvider(CustomerCreateParams.PaymentProvider.QUICKBOOKS) .paymentProviderId("payment_provider_id") .reportingConfiguration( @@ -401,6 +449,22 @@ internal class ErrorHandlingTest { .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) + .paymentConfiguration( + CustomerCreateParams.PaymentConfiguration.builder() + .addPaymentProvider( + CustomerCreateParams.PaymentConfiguration.PaymentProvider + .builder() + .providerType( + CustomerCreateParams.PaymentConfiguration + .PaymentProvider + .ProviderType + .STRIPE + ) + .addExcludedPaymentMethodType("string") + .build() + ) + .build() + ) .paymentProvider(CustomerCreateParams.PaymentProvider.QUICKBOOKS) .paymentProviderId("payment_provider_id") .reportingConfiguration( @@ -495,6 +559,22 @@ internal class ErrorHandlingTest { .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) + .paymentConfiguration( + CustomerCreateParams.PaymentConfiguration.builder() + .addPaymentProvider( + CustomerCreateParams.PaymentConfiguration.PaymentProvider + .builder() + .providerType( + CustomerCreateParams.PaymentConfiguration + .PaymentProvider + .ProviderType + .STRIPE + ) + .addExcludedPaymentMethodType("string") + .build() + ) + .build() + ) .paymentProvider(CustomerCreateParams.PaymentProvider.QUICKBOOKS) .paymentProviderId("payment_provider_id") .reportingConfiguration( @@ -589,6 +669,22 @@ internal class ErrorHandlingTest { .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) + .paymentConfiguration( + CustomerCreateParams.PaymentConfiguration.builder() + .addPaymentProvider( + CustomerCreateParams.PaymentConfiguration.PaymentProvider + .builder() + .providerType( + CustomerCreateParams.PaymentConfiguration + .PaymentProvider + .ProviderType + .STRIPE + ) + .addExcludedPaymentMethodType("string") + .build() + ) + .build() + ) .paymentProvider(CustomerCreateParams.PaymentProvider.QUICKBOOKS) .paymentProviderId("payment_provider_id") .reportingConfiguration( @@ -683,6 +779,22 @@ internal class ErrorHandlingTest { .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) + .paymentConfiguration( + CustomerCreateParams.PaymentConfiguration.builder() + .addPaymentProvider( + CustomerCreateParams.PaymentConfiguration.PaymentProvider + .builder() + .providerType( + CustomerCreateParams.PaymentConfiguration + .PaymentProvider + .ProviderType + .STRIPE + ) + .addExcludedPaymentMethodType("string") + .build() + ) + .build() + ) .paymentProvider(CustomerCreateParams.PaymentProvider.QUICKBOOKS) .paymentProviderId("payment_provider_id") .reportingConfiguration( @@ -777,6 +889,22 @@ internal class ErrorHandlingTest { .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) + .paymentConfiguration( + CustomerCreateParams.PaymentConfiguration.builder() + .addPaymentProvider( + CustomerCreateParams.PaymentConfiguration.PaymentProvider + .builder() + .providerType( + CustomerCreateParams.PaymentConfiguration + .PaymentProvider + .ProviderType + .STRIPE + ) + .addExcludedPaymentMethodType("string") + .build() + ) + .build() + ) .paymentProvider(CustomerCreateParams.PaymentProvider.QUICKBOOKS) .paymentProviderId("payment_provider_id") .reportingConfiguration( @@ -871,6 +999,22 @@ internal class ErrorHandlingTest { .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) + .paymentConfiguration( + CustomerCreateParams.PaymentConfiguration.builder() + .addPaymentProvider( + CustomerCreateParams.PaymentConfiguration.PaymentProvider + .builder() + .providerType( + CustomerCreateParams.PaymentConfiguration + .PaymentProvider + .ProviderType + .STRIPE + ) + .addExcludedPaymentMethodType("string") + .build() + ) + .build() + ) .paymentProvider(CustomerCreateParams.PaymentProvider.QUICKBOOKS) .paymentProviderId("payment_provider_id") .reportingConfiguration( @@ -965,6 +1109,22 @@ internal class ErrorHandlingTest { .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) + .paymentConfiguration( + CustomerCreateParams.PaymentConfiguration.builder() + .addPaymentProvider( + CustomerCreateParams.PaymentConfiguration.PaymentProvider + .builder() + .providerType( + CustomerCreateParams.PaymentConfiguration + .PaymentProvider + .ProviderType + .STRIPE + ) + .addExcludedPaymentMethodType("string") + .build() + ) + .build() + ) .paymentProvider(CustomerCreateParams.PaymentProvider.QUICKBOOKS) .paymentProviderId("payment_provider_id") .reportingConfiguration( @@ -1059,6 +1219,22 @@ internal class ErrorHandlingTest { .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) + .paymentConfiguration( + CustomerCreateParams.PaymentConfiguration.builder() + .addPaymentProvider( + CustomerCreateParams.PaymentConfiguration.PaymentProvider + .builder() + .providerType( + CustomerCreateParams.PaymentConfiguration + .PaymentProvider + .ProviderType + .STRIPE + ) + .addExcludedPaymentMethodType("string") + .build() + ) + .build() + ) .paymentProvider(CustomerCreateParams.PaymentProvider.QUICKBOOKS) .paymentProviderId("payment_provider_id") .reportingConfiguration( @@ -1153,6 +1329,22 @@ internal class ErrorHandlingTest { .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) + .paymentConfiguration( + CustomerCreateParams.PaymentConfiguration.builder() + .addPaymentProvider( + CustomerCreateParams.PaymentConfiguration.PaymentProvider + .builder() + .providerType( + CustomerCreateParams.PaymentConfiguration + .PaymentProvider + .ProviderType + .STRIPE + ) + .addExcludedPaymentMethodType("string") + .build() + ) + .build() + ) .paymentProvider(CustomerCreateParams.PaymentProvider.QUICKBOOKS) .paymentProviderId("payment_provider_id") .reportingConfiguration( @@ -1247,6 +1439,22 @@ internal class ErrorHandlingTest { .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) + .paymentConfiguration( + CustomerCreateParams.PaymentConfiguration.builder() + .addPaymentProvider( + CustomerCreateParams.PaymentConfiguration.PaymentProvider + .builder() + .providerType( + CustomerCreateParams.PaymentConfiguration + .PaymentProvider + .ProviderType + .STRIPE + ) + .addExcludedPaymentMethodType("string") + .build() + ) + .build() + ) .paymentProvider(CustomerCreateParams.PaymentProvider.QUICKBOOKS) .paymentProviderId("payment_provider_id") .reportingConfiguration( @@ -1341,6 +1549,22 @@ internal class ErrorHandlingTest { .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) + .paymentConfiguration( + CustomerCreateParams.PaymentConfiguration.builder() + .addPaymentProvider( + CustomerCreateParams.PaymentConfiguration.PaymentProvider + .builder() + .providerType( + CustomerCreateParams.PaymentConfiguration + .PaymentProvider + .ProviderType + .STRIPE + ) + .addExcludedPaymentMethodType("string") + .build() + ) + .build() + ) .paymentProvider(CustomerCreateParams.PaymentProvider.QUICKBOOKS) .paymentProviderId("payment_provider_id") .reportingConfiguration( @@ -1435,6 +1659,22 @@ internal class ErrorHandlingTest { .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) + .paymentConfiguration( + CustomerCreateParams.PaymentConfiguration.builder() + .addPaymentProvider( + CustomerCreateParams.PaymentConfiguration.PaymentProvider + .builder() + .providerType( + CustomerCreateParams.PaymentConfiguration + .PaymentProvider + .ProviderType + .STRIPE + ) + .addExcludedPaymentMethodType("string") + .build() + ) + .build() + ) .paymentProvider(CustomerCreateParams.PaymentProvider.QUICKBOOKS) .paymentProviderId("payment_provider_id") .reportingConfiguration( @@ -1529,6 +1769,22 @@ internal class ErrorHandlingTest { .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) + .paymentConfiguration( + CustomerCreateParams.PaymentConfiguration.builder() + .addPaymentProvider( + CustomerCreateParams.PaymentConfiguration.PaymentProvider + .builder() + .providerType( + CustomerCreateParams.PaymentConfiguration + .PaymentProvider + .ProviderType + .STRIPE + ) + .addExcludedPaymentMethodType("string") + .build() + ) + .build() + ) .paymentProvider(CustomerCreateParams.PaymentProvider.QUICKBOOKS) .paymentProviderId("payment_provider_id") .reportingConfiguration( @@ -1621,6 +1877,22 @@ internal class ErrorHandlingTest { .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) + .paymentConfiguration( + CustomerCreateParams.PaymentConfiguration.builder() + .addPaymentProvider( + CustomerCreateParams.PaymentConfiguration.PaymentProvider + .builder() + .providerType( + CustomerCreateParams.PaymentConfiguration + .PaymentProvider + .ProviderType + .STRIPE + ) + .addExcludedPaymentMethodType("string") + .build() + ) + .build() + ) .paymentProvider(CustomerCreateParams.PaymentProvider.QUICKBOOKS) .paymentProviderId("payment_provider_id") .reportingConfiguration( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/ServiceParamsTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/ServiceParamsTest.kt index b2299454b..447c39875 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/ServiceParamsTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/ServiceParamsTest.kt @@ -89,6 +89,20 @@ internal class ServiceParamsTest { .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) + .paymentConfiguration( + CustomerCreateParams.PaymentConfiguration.builder() + .addPaymentProvider( + CustomerCreateParams.PaymentConfiguration.PaymentProvider.builder() + .providerType( + CustomerCreateParams.PaymentConfiguration.PaymentProvider + .ProviderType + .STRIPE + ) + .addExcludedPaymentMethodType("string") + .build() + ) + .build() + ) .paymentProvider(CustomerCreateParams.PaymentProvider.QUICKBOOKS) .paymentProviderId("payment_provider_id") .reportingConfiguration(NewReportingConfiguration.builder().exempt(true).build()) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/CustomerServiceAsyncTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/CustomerServiceAsyncTest.kt index 353c230ad..f7d254448 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/CustomerServiceAsyncTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/CustomerServiceAsyncTest.kt @@ -73,6 +73,20 @@ internal class CustomerServiceAsyncTest { .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) + .paymentConfiguration( + CustomerCreateParams.PaymentConfiguration.builder() + .addPaymentProvider( + CustomerCreateParams.PaymentConfiguration.PaymentProvider.builder() + .providerType( + CustomerCreateParams.PaymentConfiguration.PaymentProvider + .ProviderType + .STRIPE + ) + .addExcludedPaymentMethodType("string") + .build() + ) + .build() + ) .paymentProvider(CustomerCreateParams.PaymentProvider.QUICKBOOKS) .paymentProviderId("payment_provider_id") .reportingConfiguration( @@ -163,6 +177,20 @@ internal class CustomerServiceAsyncTest { .build() ) .name("name") + .paymentConfiguration( + CustomerUpdateParams.PaymentConfiguration.builder() + .addPaymentProvider( + CustomerUpdateParams.PaymentConfiguration.PaymentProvider.builder() + .providerType( + CustomerUpdateParams.PaymentConfiguration.PaymentProvider + .ProviderType + .STRIPE + ) + .addExcludedPaymentMethodType("string") + .build() + ) + .build() + ) .paymentProvider(CustomerUpdateParams.PaymentProvider.QUICKBOOKS) .paymentProviderId("payment_provider_id") .reportingConfiguration( @@ -332,6 +360,23 @@ internal class CustomerServiceAsyncTest { .build() ) .name("name") + .paymentConfiguration( + CustomerUpdateByExternalIdParams.PaymentConfiguration.builder() + .addPaymentProvider( + CustomerUpdateByExternalIdParams.PaymentConfiguration + .PaymentProvider + .builder() + .providerType( + CustomerUpdateByExternalIdParams.PaymentConfiguration + .PaymentProvider + .ProviderType + .STRIPE + ) + .addExcludedPaymentMethodType("string") + .build() + ) + .build() + ) .paymentProvider(CustomerUpdateByExternalIdParams.PaymentProvider.QUICKBOOKS) .paymentProviderId("payment_provider_id") .reportingConfiguration( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/CustomerServiceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/CustomerServiceTest.kt index c5362e091..30037704e 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/CustomerServiceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/CustomerServiceTest.kt @@ -73,6 +73,20 @@ internal class CustomerServiceTest { .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) + .paymentConfiguration( + CustomerCreateParams.PaymentConfiguration.builder() + .addPaymentProvider( + CustomerCreateParams.PaymentConfiguration.PaymentProvider.builder() + .providerType( + CustomerCreateParams.PaymentConfiguration.PaymentProvider + .ProviderType + .STRIPE + ) + .addExcludedPaymentMethodType("string") + .build() + ) + .build() + ) .paymentProvider(CustomerCreateParams.PaymentProvider.QUICKBOOKS) .paymentProviderId("payment_provider_id") .reportingConfiguration( @@ -163,6 +177,20 @@ internal class CustomerServiceTest { .build() ) .name("name") + .paymentConfiguration( + CustomerUpdateParams.PaymentConfiguration.builder() + .addPaymentProvider( + CustomerUpdateParams.PaymentConfiguration.PaymentProvider.builder() + .providerType( + CustomerUpdateParams.PaymentConfiguration.PaymentProvider + .ProviderType + .STRIPE + ) + .addExcludedPaymentMethodType("string") + .build() + ) + .build() + ) .paymentProvider(CustomerUpdateParams.PaymentProvider.QUICKBOOKS) .paymentProviderId("payment_provider_id") .reportingConfiguration( @@ -330,6 +358,23 @@ internal class CustomerServiceTest { .build() ) .name("name") + .paymentConfiguration( + CustomerUpdateByExternalIdParams.PaymentConfiguration.builder() + .addPaymentProvider( + CustomerUpdateByExternalIdParams.PaymentConfiguration + .PaymentProvider + .builder() + .providerType( + CustomerUpdateByExternalIdParams.PaymentConfiguration + .PaymentProvider + .ProviderType + .STRIPE + ) + .addExcludedPaymentMethodType("string") + .build() + ) + .build() + ) .paymentProvider(CustomerUpdateByExternalIdParams.PaymentProvider.QUICKBOOKS) .paymentProviderId("payment_provider_id") .reportingConfiguration( From 80b799e2e3da0dec3f6121d67af97675abc35785 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 4 Dec 2025 16:44:51 +0000 Subject: [PATCH 58/68] codegen metadata --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 8fee554bc..f7ecd1ab9 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 118 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-7936e3f73bbe1d59d27fd7a8a226985927b38fdec1c936c77577381699fb6140.yml openapi_spec_hash: 1d3f9ed5fbdb0e40d56d6acd9d1736e2 -config_hash: e6db17547fe854b1c240407cf4c6dc9e +config_hash: 895e36fb2d717958770fd4cf883f4b74 From e4e8d24b25879216965e7c55c5e23ab3bbbc69f8 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Sat, 6 Dec 2025 01:26:16 +0000 Subject: [PATCH 59/68] feat(api): api update --- .stats.yml | 4 +- .../models/SubscriptionChangeApplyResponse.kt | 228 +++++++++++++++++- .../SubscriptionChangeCancelResponse.kt | 228 +++++++++++++++++- .../SubscriptionChangeRetrieveResponse.kt | 228 +++++++++++++++++- .../SubscriptionChangeApplyResponseTest.kt | 17 ++ .../SubscriptionChangeCancelResponseTest.kt | 17 ++ .../SubscriptionChangeRetrieveResponseTest.kt | 17 ++ 7 files changed, 728 insertions(+), 11 deletions(-) diff --git a/.stats.yml b/.stats.yml index f7ecd1ab9..362210976 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 118 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-7936e3f73bbe1d59d27fd7a8a226985927b38fdec1c936c77577381699fb6140.yml -openapi_spec_hash: 1d3f9ed5fbdb0e40d56d6acd9d1736e2 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-03af7f658aed245cf7e230055de59fe92a78880f3719bf254ed9352bf89bad5e.yml +openapi_spec_hash: c4703d217c25e8c02c248caed9e2d3be config_hash: 895e36fb2d717958770fd4cf883f4b74 diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionChangeApplyResponse.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionChangeApplyResponse.kt index bf7eb5b3f..bd1d8273f 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionChangeApplyResponse.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionChangeApplyResponse.kt @@ -26,17 +26,25 @@ class SubscriptionChangeApplyResponse @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, + private val changeType: JsonField, private val expirationTime: JsonField, private val status: JsonField, private val subscription: JsonField, private val appliedAt: JsonField, + private val billingCycleAlignment: JsonField, private val cancelledAt: JsonField, + private val changeOption: JsonField, + private val effectiveDate: JsonField, + private val planId: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("change_type") + @ExcludeMissing + changeType: JsonField = JsonMissing.of(), @JsonProperty("expiration_time") @ExcludeMissing expirationTime: JsonField = JsonMissing.of(), @@ -47,10 +55,33 @@ private constructor( @JsonProperty("applied_at") @ExcludeMissing appliedAt: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_alignment") + @ExcludeMissing + billingCycleAlignment: JsonField = JsonMissing.of(), @JsonProperty("cancelled_at") @ExcludeMissing cancelledAt: JsonField = JsonMissing.of(), - ) : this(id, expirationTime, status, subscription, appliedAt, cancelledAt, mutableMapOf()) + @JsonProperty("change_option") + @ExcludeMissing + changeOption: JsonField = JsonMissing.of(), + @JsonProperty("effective_date") + @ExcludeMissing + effectiveDate: JsonField = JsonMissing.of(), + @JsonProperty("plan_id") @ExcludeMissing planId: JsonField = JsonMissing.of(), + ) : this( + id, + changeType, + expirationTime, + status, + subscription, + appliedAt, + billingCycleAlignment, + cancelledAt, + changeOption, + effectiveDate, + planId, + mutableMapOf(), + ) /** * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly @@ -58,6 +89,14 @@ private constructor( */ fun id(): String = id.getRequired("id") + /** + * The type of change (e.g., 'schedule_plan_change', 'create_subscription'). + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun changeType(): String = changeType.getRequired("change_type") + /** * Subscription change will be cancelled at this time and can no longer be applied. * @@ -86,6 +125,15 @@ private constructor( */ fun appliedAt(): OffsetDateTime? = appliedAt.getNullable("applied_at") + /** + * Billing cycle alignment for plan changes. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun billingCycleAlignment(): String? = + billingCycleAlignment.getNullable("billing_cycle_alignment") + /** * When this change was cancelled. * @@ -94,6 +142,31 @@ private constructor( */ fun cancelledAt(): OffsetDateTime? = cancelledAt.getNullable("cancelled_at") + /** + * How the change is scheduled (e.g., 'immediate', 'end_of_subscription_term', + * 'requested_date'). + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun changeOption(): String? = changeOption.getNullable("change_option") + + /** + * When this change will take effect. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun effectiveDate(): OffsetDateTime? = effectiveDate.getNullable("effective_date") + + /** + * The target plan ID for plan changes. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun planId(): String? = planId.getNullable("plan_id") + /** * Returns the raw JSON value of [id]. * @@ -101,6 +174,13 @@ private constructor( */ @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + /** + * Returns the raw JSON value of [changeType]. + * + * Unlike [changeType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("change_type") @ExcludeMissing fun _changeType(): JsonField = changeType + /** * Returns the raw JSON value of [expirationTime]. * @@ -135,6 +215,16 @@ private constructor( @ExcludeMissing fun _appliedAt(): JsonField = appliedAt + /** + * Returns the raw JSON value of [billingCycleAlignment]. + * + * Unlike [billingCycleAlignment], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("billing_cycle_alignment") + @ExcludeMissing + fun _billingCycleAlignment(): JsonField = billingCycleAlignment + /** * Returns the raw JSON value of [cancelledAt]. * @@ -144,6 +234,31 @@ private constructor( @ExcludeMissing fun _cancelledAt(): JsonField = cancelledAt + /** + * Returns the raw JSON value of [changeOption]. + * + * Unlike [changeOption], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("change_option") + @ExcludeMissing + fun _changeOption(): JsonField = changeOption + + /** + * Returns the raw JSON value of [effectiveDate]. + * + * Unlike [effectiveDate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("effective_date") + @ExcludeMissing + fun _effectiveDate(): JsonField = effectiveDate + + /** + * Returns the raw JSON value of [planId]. + * + * Unlike [planId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("plan_id") @ExcludeMissing fun _planId(): JsonField = planId + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -165,6 +280,7 @@ private constructor( * The following fields are required: * ```kotlin * .id() + * .changeType() * .expirationTime() * .status() * .subscription() @@ -177,21 +293,31 @@ private constructor( class Builder internal constructor() { private var id: JsonField? = null + private var changeType: JsonField? = null private var expirationTime: JsonField? = null private var status: JsonField? = null private var subscription: JsonField? = null private var appliedAt: JsonField = JsonMissing.of() + private var billingCycleAlignment: JsonField = JsonMissing.of() private var cancelledAt: JsonField = JsonMissing.of() + private var changeOption: JsonField = JsonMissing.of() + private var effectiveDate: JsonField = JsonMissing.of() + private var planId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() internal fun from(subscriptionChangeApplyResponse: SubscriptionChangeApplyResponse) = apply { id = subscriptionChangeApplyResponse.id + changeType = subscriptionChangeApplyResponse.changeType expirationTime = subscriptionChangeApplyResponse.expirationTime status = subscriptionChangeApplyResponse.status subscription = subscriptionChangeApplyResponse.subscription appliedAt = subscriptionChangeApplyResponse.appliedAt + billingCycleAlignment = subscriptionChangeApplyResponse.billingCycleAlignment cancelledAt = subscriptionChangeApplyResponse.cancelledAt + changeOption = subscriptionChangeApplyResponse.changeOption + effectiveDate = subscriptionChangeApplyResponse.effectiveDate + planId = subscriptionChangeApplyResponse.planId additionalProperties = subscriptionChangeApplyResponse.additionalProperties.toMutableMap() } @@ -206,6 +332,18 @@ private constructor( */ fun id(id: JsonField) = apply { this.id = id } + /** The type of change (e.g., 'schedule_plan_change', 'create_subscription'). */ + fun changeType(changeType: String) = changeType(JsonField.of(changeType)) + + /** + * Sets [Builder.changeType] to an arbitrary JSON value. + * + * You should usually call [Builder.changeType] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun changeType(changeType: JsonField) = apply { this.changeType = changeType } + /** Subscription change will be cancelled at this time and can no longer be applied. */ fun expirationTime(expirationTime: OffsetDateTime) = expirationTime(JsonField.of(expirationTime)) @@ -257,6 +395,21 @@ private constructor( */ fun appliedAt(appliedAt: JsonField) = apply { this.appliedAt = appliedAt } + /** Billing cycle alignment for plan changes. */ + fun billingCycleAlignment(billingCycleAlignment: String?) = + billingCycleAlignment(JsonField.ofNullable(billingCycleAlignment)) + + /** + * Sets [Builder.billingCycleAlignment] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleAlignment] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun billingCycleAlignment(billingCycleAlignment: JsonField) = apply { + this.billingCycleAlignment = billingCycleAlignment + } + /** When this change was cancelled. */ fun cancelledAt(cancelledAt: OffsetDateTime?) = cancelledAt(JsonField.ofNullable(cancelledAt)) @@ -272,6 +425,49 @@ private constructor( this.cancelledAt = cancelledAt } + /** + * How the change is scheduled (e.g., 'immediate', 'end_of_subscription_term', + * 'requested_date'). + */ + fun changeOption(changeOption: String?) = changeOption(JsonField.ofNullable(changeOption)) + + /** + * Sets [Builder.changeOption] to an arbitrary JSON value. + * + * You should usually call [Builder.changeOption] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun changeOption(changeOption: JsonField) = apply { + this.changeOption = changeOption + } + + /** When this change will take effect. */ + fun effectiveDate(effectiveDate: OffsetDateTime?) = + effectiveDate(JsonField.ofNullable(effectiveDate)) + + /** + * Sets [Builder.effectiveDate] to an arbitrary JSON value. + * + * You should usually call [Builder.effectiveDate] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun effectiveDate(effectiveDate: JsonField) = apply { + this.effectiveDate = effectiveDate + } + + /** The target plan ID for plan changes. */ + fun planId(planId: String?) = planId(JsonField.ofNullable(planId)) + + /** + * Sets [Builder.planId] to an arbitrary JSON value. + * + * You should usually call [Builder.planId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun planId(planId: JsonField) = apply { this.planId = planId } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -299,6 +495,7 @@ private constructor( * The following fields are required: * ```kotlin * .id() + * .changeType() * .expirationTime() * .status() * .subscription() @@ -309,11 +506,16 @@ private constructor( fun build(): SubscriptionChangeApplyResponse = SubscriptionChangeApplyResponse( checkRequired("id", id), + checkRequired("changeType", changeType), checkRequired("expirationTime", expirationTime), checkRequired("status", status), checkRequired("subscription", subscription), appliedAt, + billingCycleAlignment, cancelledAt, + changeOption, + effectiveDate, + planId, additionalProperties.toMutableMap(), ) } @@ -326,11 +528,16 @@ private constructor( } id() + changeType() expirationTime() status().validate() subscription()?.validate() appliedAt() + billingCycleAlignment() cancelledAt() + changeOption() + effectiveDate() + planId() validated = true } @@ -349,11 +556,16 @@ private constructor( */ internal fun validity(): Int = (if (id.asKnown() == null) 0 else 1) + + (if (changeType.asKnown() == null) 0 else 1) + (if (expirationTime.asKnown() == null) 0 else 1) + (status.asKnown()?.validity() ?: 0) + (subscription.asKnown()?.validity() ?: 0) + (if (appliedAt.asKnown() == null) 0 else 1) + - (if (cancelledAt.asKnown() == null) 0 else 1) + (if (billingCycleAlignment.asKnown() == null) 0 else 1) + + (if (cancelledAt.asKnown() == null) 0 else 1) + + (if (changeOption.asKnown() == null) 0 else 1) + + (if (effectiveDate.asKnown() == null) 0 else 1) + + (if (planId.asKnown() == null) 0 else 1) class Status @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -492,22 +704,32 @@ private constructor( return other is SubscriptionChangeApplyResponse && id == other.id && + changeType == other.changeType && expirationTime == other.expirationTime && status == other.status && subscription == other.subscription && appliedAt == other.appliedAt && + billingCycleAlignment == other.billingCycleAlignment && cancelledAt == other.cancelledAt && + changeOption == other.changeOption && + effectiveDate == other.effectiveDate && + planId == other.planId && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { Objects.hash( id, + changeType, expirationTime, status, subscription, appliedAt, + billingCycleAlignment, cancelledAt, + changeOption, + effectiveDate, + planId, additionalProperties, ) } @@ -515,5 +737,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "SubscriptionChangeApplyResponse{id=$id, expirationTime=$expirationTime, status=$status, subscription=$subscription, appliedAt=$appliedAt, cancelledAt=$cancelledAt, additionalProperties=$additionalProperties}" + "SubscriptionChangeApplyResponse{id=$id, changeType=$changeType, expirationTime=$expirationTime, status=$status, subscription=$subscription, appliedAt=$appliedAt, billingCycleAlignment=$billingCycleAlignment, cancelledAt=$cancelledAt, changeOption=$changeOption, effectiveDate=$effectiveDate, planId=$planId, additionalProperties=$additionalProperties}" } diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionChangeCancelResponse.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionChangeCancelResponse.kt index 87f4638eb..bcc8ee807 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionChangeCancelResponse.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionChangeCancelResponse.kt @@ -26,17 +26,25 @@ class SubscriptionChangeCancelResponse @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, + private val changeType: JsonField, private val expirationTime: JsonField, private val status: JsonField, private val subscription: JsonField, private val appliedAt: JsonField, + private val billingCycleAlignment: JsonField, private val cancelledAt: JsonField, + private val changeOption: JsonField, + private val effectiveDate: JsonField, + private val planId: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("change_type") + @ExcludeMissing + changeType: JsonField = JsonMissing.of(), @JsonProperty("expiration_time") @ExcludeMissing expirationTime: JsonField = JsonMissing.of(), @@ -47,10 +55,33 @@ private constructor( @JsonProperty("applied_at") @ExcludeMissing appliedAt: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_alignment") + @ExcludeMissing + billingCycleAlignment: JsonField = JsonMissing.of(), @JsonProperty("cancelled_at") @ExcludeMissing cancelledAt: JsonField = JsonMissing.of(), - ) : this(id, expirationTime, status, subscription, appliedAt, cancelledAt, mutableMapOf()) + @JsonProperty("change_option") + @ExcludeMissing + changeOption: JsonField = JsonMissing.of(), + @JsonProperty("effective_date") + @ExcludeMissing + effectiveDate: JsonField = JsonMissing.of(), + @JsonProperty("plan_id") @ExcludeMissing planId: JsonField = JsonMissing.of(), + ) : this( + id, + changeType, + expirationTime, + status, + subscription, + appliedAt, + billingCycleAlignment, + cancelledAt, + changeOption, + effectiveDate, + planId, + mutableMapOf(), + ) /** * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly @@ -58,6 +89,14 @@ private constructor( */ fun id(): String = id.getRequired("id") + /** + * The type of change (e.g., 'schedule_plan_change', 'create_subscription'). + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun changeType(): String = changeType.getRequired("change_type") + /** * Subscription change will be cancelled at this time and can no longer be applied. * @@ -86,6 +125,15 @@ private constructor( */ fun appliedAt(): OffsetDateTime? = appliedAt.getNullable("applied_at") + /** + * Billing cycle alignment for plan changes. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun billingCycleAlignment(): String? = + billingCycleAlignment.getNullable("billing_cycle_alignment") + /** * When this change was cancelled. * @@ -94,6 +142,31 @@ private constructor( */ fun cancelledAt(): OffsetDateTime? = cancelledAt.getNullable("cancelled_at") + /** + * How the change is scheduled (e.g., 'immediate', 'end_of_subscription_term', + * 'requested_date'). + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun changeOption(): String? = changeOption.getNullable("change_option") + + /** + * When this change will take effect. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun effectiveDate(): OffsetDateTime? = effectiveDate.getNullable("effective_date") + + /** + * The target plan ID for plan changes. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun planId(): String? = planId.getNullable("plan_id") + /** * Returns the raw JSON value of [id]. * @@ -101,6 +174,13 @@ private constructor( */ @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + /** + * Returns the raw JSON value of [changeType]. + * + * Unlike [changeType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("change_type") @ExcludeMissing fun _changeType(): JsonField = changeType + /** * Returns the raw JSON value of [expirationTime]. * @@ -135,6 +215,16 @@ private constructor( @ExcludeMissing fun _appliedAt(): JsonField = appliedAt + /** + * Returns the raw JSON value of [billingCycleAlignment]. + * + * Unlike [billingCycleAlignment], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("billing_cycle_alignment") + @ExcludeMissing + fun _billingCycleAlignment(): JsonField = billingCycleAlignment + /** * Returns the raw JSON value of [cancelledAt]. * @@ -144,6 +234,31 @@ private constructor( @ExcludeMissing fun _cancelledAt(): JsonField = cancelledAt + /** + * Returns the raw JSON value of [changeOption]. + * + * Unlike [changeOption], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("change_option") + @ExcludeMissing + fun _changeOption(): JsonField = changeOption + + /** + * Returns the raw JSON value of [effectiveDate]. + * + * Unlike [effectiveDate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("effective_date") + @ExcludeMissing + fun _effectiveDate(): JsonField = effectiveDate + + /** + * Returns the raw JSON value of [planId]. + * + * Unlike [planId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("plan_id") @ExcludeMissing fun _planId(): JsonField = planId + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -165,6 +280,7 @@ private constructor( * The following fields are required: * ```kotlin * .id() + * .changeType() * .expirationTime() * .status() * .subscription() @@ -177,21 +293,31 @@ private constructor( class Builder internal constructor() { private var id: JsonField? = null + private var changeType: JsonField? = null private var expirationTime: JsonField? = null private var status: JsonField? = null private var subscription: JsonField? = null private var appliedAt: JsonField = JsonMissing.of() + private var billingCycleAlignment: JsonField = JsonMissing.of() private var cancelledAt: JsonField = JsonMissing.of() + private var changeOption: JsonField = JsonMissing.of() + private var effectiveDate: JsonField = JsonMissing.of() + private var planId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() internal fun from(subscriptionChangeCancelResponse: SubscriptionChangeCancelResponse) = apply { id = subscriptionChangeCancelResponse.id + changeType = subscriptionChangeCancelResponse.changeType expirationTime = subscriptionChangeCancelResponse.expirationTime status = subscriptionChangeCancelResponse.status subscription = subscriptionChangeCancelResponse.subscription appliedAt = subscriptionChangeCancelResponse.appliedAt + billingCycleAlignment = subscriptionChangeCancelResponse.billingCycleAlignment cancelledAt = subscriptionChangeCancelResponse.cancelledAt + changeOption = subscriptionChangeCancelResponse.changeOption + effectiveDate = subscriptionChangeCancelResponse.effectiveDate + planId = subscriptionChangeCancelResponse.planId additionalProperties = subscriptionChangeCancelResponse.additionalProperties.toMutableMap() } @@ -206,6 +332,18 @@ private constructor( */ fun id(id: JsonField) = apply { this.id = id } + /** The type of change (e.g., 'schedule_plan_change', 'create_subscription'). */ + fun changeType(changeType: String) = changeType(JsonField.of(changeType)) + + /** + * Sets [Builder.changeType] to an arbitrary JSON value. + * + * You should usually call [Builder.changeType] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun changeType(changeType: JsonField) = apply { this.changeType = changeType } + /** Subscription change will be cancelled at this time and can no longer be applied. */ fun expirationTime(expirationTime: OffsetDateTime) = expirationTime(JsonField.of(expirationTime)) @@ -257,6 +395,21 @@ private constructor( */ fun appliedAt(appliedAt: JsonField) = apply { this.appliedAt = appliedAt } + /** Billing cycle alignment for plan changes. */ + fun billingCycleAlignment(billingCycleAlignment: String?) = + billingCycleAlignment(JsonField.ofNullable(billingCycleAlignment)) + + /** + * Sets [Builder.billingCycleAlignment] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleAlignment] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun billingCycleAlignment(billingCycleAlignment: JsonField) = apply { + this.billingCycleAlignment = billingCycleAlignment + } + /** When this change was cancelled. */ fun cancelledAt(cancelledAt: OffsetDateTime?) = cancelledAt(JsonField.ofNullable(cancelledAt)) @@ -272,6 +425,49 @@ private constructor( this.cancelledAt = cancelledAt } + /** + * How the change is scheduled (e.g., 'immediate', 'end_of_subscription_term', + * 'requested_date'). + */ + fun changeOption(changeOption: String?) = changeOption(JsonField.ofNullable(changeOption)) + + /** + * Sets [Builder.changeOption] to an arbitrary JSON value. + * + * You should usually call [Builder.changeOption] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun changeOption(changeOption: JsonField) = apply { + this.changeOption = changeOption + } + + /** When this change will take effect. */ + fun effectiveDate(effectiveDate: OffsetDateTime?) = + effectiveDate(JsonField.ofNullable(effectiveDate)) + + /** + * Sets [Builder.effectiveDate] to an arbitrary JSON value. + * + * You should usually call [Builder.effectiveDate] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun effectiveDate(effectiveDate: JsonField) = apply { + this.effectiveDate = effectiveDate + } + + /** The target plan ID for plan changes. */ + fun planId(planId: String?) = planId(JsonField.ofNullable(planId)) + + /** + * Sets [Builder.planId] to an arbitrary JSON value. + * + * You should usually call [Builder.planId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun planId(planId: JsonField) = apply { this.planId = planId } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -299,6 +495,7 @@ private constructor( * The following fields are required: * ```kotlin * .id() + * .changeType() * .expirationTime() * .status() * .subscription() @@ -309,11 +506,16 @@ private constructor( fun build(): SubscriptionChangeCancelResponse = SubscriptionChangeCancelResponse( checkRequired("id", id), + checkRequired("changeType", changeType), checkRequired("expirationTime", expirationTime), checkRequired("status", status), checkRequired("subscription", subscription), appliedAt, + billingCycleAlignment, cancelledAt, + changeOption, + effectiveDate, + planId, additionalProperties.toMutableMap(), ) } @@ -326,11 +528,16 @@ private constructor( } id() + changeType() expirationTime() status().validate() subscription()?.validate() appliedAt() + billingCycleAlignment() cancelledAt() + changeOption() + effectiveDate() + planId() validated = true } @@ -349,11 +556,16 @@ private constructor( */ internal fun validity(): Int = (if (id.asKnown() == null) 0 else 1) + + (if (changeType.asKnown() == null) 0 else 1) + (if (expirationTime.asKnown() == null) 0 else 1) + (status.asKnown()?.validity() ?: 0) + (subscription.asKnown()?.validity() ?: 0) + (if (appliedAt.asKnown() == null) 0 else 1) + - (if (cancelledAt.asKnown() == null) 0 else 1) + (if (billingCycleAlignment.asKnown() == null) 0 else 1) + + (if (cancelledAt.asKnown() == null) 0 else 1) + + (if (changeOption.asKnown() == null) 0 else 1) + + (if (effectiveDate.asKnown() == null) 0 else 1) + + (if (planId.asKnown() == null) 0 else 1) class Status @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -492,22 +704,32 @@ private constructor( return other is SubscriptionChangeCancelResponse && id == other.id && + changeType == other.changeType && expirationTime == other.expirationTime && status == other.status && subscription == other.subscription && appliedAt == other.appliedAt && + billingCycleAlignment == other.billingCycleAlignment && cancelledAt == other.cancelledAt && + changeOption == other.changeOption && + effectiveDate == other.effectiveDate && + planId == other.planId && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { Objects.hash( id, + changeType, expirationTime, status, subscription, appliedAt, + billingCycleAlignment, cancelledAt, + changeOption, + effectiveDate, + planId, additionalProperties, ) } @@ -515,5 +737,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "SubscriptionChangeCancelResponse{id=$id, expirationTime=$expirationTime, status=$status, subscription=$subscription, appliedAt=$appliedAt, cancelledAt=$cancelledAt, additionalProperties=$additionalProperties}" + "SubscriptionChangeCancelResponse{id=$id, changeType=$changeType, expirationTime=$expirationTime, status=$status, subscription=$subscription, appliedAt=$appliedAt, billingCycleAlignment=$billingCycleAlignment, cancelledAt=$cancelledAt, changeOption=$changeOption, effectiveDate=$effectiveDate, planId=$planId, additionalProperties=$additionalProperties}" } diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionChangeRetrieveResponse.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionChangeRetrieveResponse.kt index 4f75a7eb3..e6e297e23 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionChangeRetrieveResponse.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionChangeRetrieveResponse.kt @@ -26,17 +26,25 @@ class SubscriptionChangeRetrieveResponse @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, + private val changeType: JsonField, private val expirationTime: JsonField, private val status: JsonField, private val subscription: JsonField, private val appliedAt: JsonField, + private val billingCycleAlignment: JsonField, private val cancelledAt: JsonField, + private val changeOption: JsonField, + private val effectiveDate: JsonField, + private val planId: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("change_type") + @ExcludeMissing + changeType: JsonField = JsonMissing.of(), @JsonProperty("expiration_time") @ExcludeMissing expirationTime: JsonField = JsonMissing.of(), @@ -47,10 +55,33 @@ private constructor( @JsonProperty("applied_at") @ExcludeMissing appliedAt: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_alignment") + @ExcludeMissing + billingCycleAlignment: JsonField = JsonMissing.of(), @JsonProperty("cancelled_at") @ExcludeMissing cancelledAt: JsonField = JsonMissing.of(), - ) : this(id, expirationTime, status, subscription, appliedAt, cancelledAt, mutableMapOf()) + @JsonProperty("change_option") + @ExcludeMissing + changeOption: JsonField = JsonMissing.of(), + @JsonProperty("effective_date") + @ExcludeMissing + effectiveDate: JsonField = JsonMissing.of(), + @JsonProperty("plan_id") @ExcludeMissing planId: JsonField = JsonMissing.of(), + ) : this( + id, + changeType, + expirationTime, + status, + subscription, + appliedAt, + billingCycleAlignment, + cancelledAt, + changeOption, + effectiveDate, + planId, + mutableMapOf(), + ) /** * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly @@ -58,6 +89,14 @@ private constructor( */ fun id(): String = id.getRequired("id") + /** + * The type of change (e.g., 'schedule_plan_change', 'create_subscription'). + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun changeType(): String = changeType.getRequired("change_type") + /** * Subscription change will be cancelled at this time and can no longer be applied. * @@ -86,6 +125,15 @@ private constructor( */ fun appliedAt(): OffsetDateTime? = appliedAt.getNullable("applied_at") + /** + * Billing cycle alignment for plan changes. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun billingCycleAlignment(): String? = + billingCycleAlignment.getNullable("billing_cycle_alignment") + /** * When this change was cancelled. * @@ -94,6 +142,31 @@ private constructor( */ fun cancelledAt(): OffsetDateTime? = cancelledAt.getNullable("cancelled_at") + /** + * How the change is scheduled (e.g., 'immediate', 'end_of_subscription_term', + * 'requested_date'). + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun changeOption(): String? = changeOption.getNullable("change_option") + + /** + * When this change will take effect. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun effectiveDate(): OffsetDateTime? = effectiveDate.getNullable("effective_date") + + /** + * The target plan ID for plan changes. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun planId(): String? = planId.getNullable("plan_id") + /** * Returns the raw JSON value of [id]. * @@ -101,6 +174,13 @@ private constructor( */ @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + /** + * Returns the raw JSON value of [changeType]. + * + * Unlike [changeType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("change_type") @ExcludeMissing fun _changeType(): JsonField = changeType + /** * Returns the raw JSON value of [expirationTime]. * @@ -135,6 +215,16 @@ private constructor( @ExcludeMissing fun _appliedAt(): JsonField = appliedAt + /** + * Returns the raw JSON value of [billingCycleAlignment]. + * + * Unlike [billingCycleAlignment], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("billing_cycle_alignment") + @ExcludeMissing + fun _billingCycleAlignment(): JsonField = billingCycleAlignment + /** * Returns the raw JSON value of [cancelledAt]. * @@ -144,6 +234,31 @@ private constructor( @ExcludeMissing fun _cancelledAt(): JsonField = cancelledAt + /** + * Returns the raw JSON value of [changeOption]. + * + * Unlike [changeOption], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("change_option") + @ExcludeMissing + fun _changeOption(): JsonField = changeOption + + /** + * Returns the raw JSON value of [effectiveDate]. + * + * Unlike [effectiveDate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("effective_date") + @ExcludeMissing + fun _effectiveDate(): JsonField = effectiveDate + + /** + * Returns the raw JSON value of [planId]. + * + * Unlike [planId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("plan_id") @ExcludeMissing fun _planId(): JsonField = planId + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -165,6 +280,7 @@ private constructor( * The following fields are required: * ```kotlin * .id() + * .changeType() * .expirationTime() * .status() * .subscription() @@ -177,21 +293,31 @@ private constructor( class Builder internal constructor() { private var id: JsonField? = null + private var changeType: JsonField? = null private var expirationTime: JsonField? = null private var status: JsonField? = null private var subscription: JsonField? = null private var appliedAt: JsonField = JsonMissing.of() + private var billingCycleAlignment: JsonField = JsonMissing.of() private var cancelledAt: JsonField = JsonMissing.of() + private var changeOption: JsonField = JsonMissing.of() + private var effectiveDate: JsonField = JsonMissing.of() + private var planId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() internal fun from(subscriptionChangeRetrieveResponse: SubscriptionChangeRetrieveResponse) = apply { id = subscriptionChangeRetrieveResponse.id + changeType = subscriptionChangeRetrieveResponse.changeType expirationTime = subscriptionChangeRetrieveResponse.expirationTime status = subscriptionChangeRetrieveResponse.status subscription = subscriptionChangeRetrieveResponse.subscription appliedAt = subscriptionChangeRetrieveResponse.appliedAt + billingCycleAlignment = subscriptionChangeRetrieveResponse.billingCycleAlignment cancelledAt = subscriptionChangeRetrieveResponse.cancelledAt + changeOption = subscriptionChangeRetrieveResponse.changeOption + effectiveDate = subscriptionChangeRetrieveResponse.effectiveDate + planId = subscriptionChangeRetrieveResponse.planId additionalProperties = subscriptionChangeRetrieveResponse.additionalProperties.toMutableMap() } @@ -206,6 +332,18 @@ private constructor( */ fun id(id: JsonField) = apply { this.id = id } + /** The type of change (e.g., 'schedule_plan_change', 'create_subscription'). */ + fun changeType(changeType: String) = changeType(JsonField.of(changeType)) + + /** + * Sets [Builder.changeType] to an arbitrary JSON value. + * + * You should usually call [Builder.changeType] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun changeType(changeType: JsonField) = apply { this.changeType = changeType } + /** Subscription change will be cancelled at this time and can no longer be applied. */ fun expirationTime(expirationTime: OffsetDateTime) = expirationTime(JsonField.of(expirationTime)) @@ -257,6 +395,21 @@ private constructor( */ fun appliedAt(appliedAt: JsonField) = apply { this.appliedAt = appliedAt } + /** Billing cycle alignment for plan changes. */ + fun billingCycleAlignment(billingCycleAlignment: String?) = + billingCycleAlignment(JsonField.ofNullable(billingCycleAlignment)) + + /** + * Sets [Builder.billingCycleAlignment] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleAlignment] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun billingCycleAlignment(billingCycleAlignment: JsonField) = apply { + this.billingCycleAlignment = billingCycleAlignment + } + /** When this change was cancelled. */ fun cancelledAt(cancelledAt: OffsetDateTime?) = cancelledAt(JsonField.ofNullable(cancelledAt)) @@ -272,6 +425,49 @@ private constructor( this.cancelledAt = cancelledAt } + /** + * How the change is scheduled (e.g., 'immediate', 'end_of_subscription_term', + * 'requested_date'). + */ + fun changeOption(changeOption: String?) = changeOption(JsonField.ofNullable(changeOption)) + + /** + * Sets [Builder.changeOption] to an arbitrary JSON value. + * + * You should usually call [Builder.changeOption] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun changeOption(changeOption: JsonField) = apply { + this.changeOption = changeOption + } + + /** When this change will take effect. */ + fun effectiveDate(effectiveDate: OffsetDateTime?) = + effectiveDate(JsonField.ofNullable(effectiveDate)) + + /** + * Sets [Builder.effectiveDate] to an arbitrary JSON value. + * + * You should usually call [Builder.effectiveDate] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun effectiveDate(effectiveDate: JsonField) = apply { + this.effectiveDate = effectiveDate + } + + /** The target plan ID for plan changes. */ + fun planId(planId: String?) = planId(JsonField.ofNullable(planId)) + + /** + * Sets [Builder.planId] to an arbitrary JSON value. + * + * You should usually call [Builder.planId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun planId(planId: JsonField) = apply { this.planId = planId } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -299,6 +495,7 @@ private constructor( * The following fields are required: * ```kotlin * .id() + * .changeType() * .expirationTime() * .status() * .subscription() @@ -309,11 +506,16 @@ private constructor( fun build(): SubscriptionChangeRetrieveResponse = SubscriptionChangeRetrieveResponse( checkRequired("id", id), + checkRequired("changeType", changeType), checkRequired("expirationTime", expirationTime), checkRequired("status", status), checkRequired("subscription", subscription), appliedAt, + billingCycleAlignment, cancelledAt, + changeOption, + effectiveDate, + planId, additionalProperties.toMutableMap(), ) } @@ -326,11 +528,16 @@ private constructor( } id() + changeType() expirationTime() status().validate() subscription()?.validate() appliedAt() + billingCycleAlignment() cancelledAt() + changeOption() + effectiveDate() + planId() validated = true } @@ -349,11 +556,16 @@ private constructor( */ internal fun validity(): Int = (if (id.asKnown() == null) 0 else 1) + + (if (changeType.asKnown() == null) 0 else 1) + (if (expirationTime.asKnown() == null) 0 else 1) + (status.asKnown()?.validity() ?: 0) + (subscription.asKnown()?.validity() ?: 0) + (if (appliedAt.asKnown() == null) 0 else 1) + - (if (cancelledAt.asKnown() == null) 0 else 1) + (if (billingCycleAlignment.asKnown() == null) 0 else 1) + + (if (cancelledAt.asKnown() == null) 0 else 1) + + (if (changeOption.asKnown() == null) 0 else 1) + + (if (effectiveDate.asKnown() == null) 0 else 1) + + (if (planId.asKnown() == null) 0 else 1) class Status @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -492,22 +704,32 @@ private constructor( return other is SubscriptionChangeRetrieveResponse && id == other.id && + changeType == other.changeType && expirationTime == other.expirationTime && status == other.status && subscription == other.subscription && appliedAt == other.appliedAt && + billingCycleAlignment == other.billingCycleAlignment && cancelledAt == other.cancelledAt && + changeOption == other.changeOption && + effectiveDate == other.effectiveDate && + planId == other.planId && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { Objects.hash( id, + changeType, expirationTime, status, subscription, appliedAt, + billingCycleAlignment, cancelledAt, + changeOption, + effectiveDate, + planId, additionalProperties, ) } @@ -515,5 +737,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "SubscriptionChangeRetrieveResponse{id=$id, expirationTime=$expirationTime, status=$status, subscription=$subscription, appliedAt=$appliedAt, cancelledAt=$cancelledAt, additionalProperties=$additionalProperties}" + "SubscriptionChangeRetrieveResponse{id=$id, changeType=$changeType, expirationTime=$expirationTime, status=$status, subscription=$subscription, appliedAt=$appliedAt, billingCycleAlignment=$billingCycleAlignment, cancelledAt=$cancelledAt, changeOption=$changeOption, effectiveDate=$effectiveDate, planId=$planId, additionalProperties=$additionalProperties}" } diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeApplyResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeApplyResponseTest.kt index f0aa7dea5..e7bc57a31 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeApplyResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeApplyResponseTest.kt @@ -16,6 +16,7 @@ internal class SubscriptionChangeApplyResponseTest { val subscriptionChangeApplyResponse = SubscriptionChangeApplyResponse.builder() .id("id") + .changeType("change_type") .expirationTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .status(SubscriptionChangeApplyResponse.Status.PENDING) .subscription( @@ -2001,10 +2002,15 @@ internal class SubscriptionChangeApplyResponseTest { .build() ) .appliedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .billingCycleAlignment("billing_cycle_alignment") .cancelledAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .changeOption("change_option") + .effectiveDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .planId("plan_id") .build() assertThat(subscriptionChangeApplyResponse.id()).isEqualTo("id") + assertThat(subscriptionChangeApplyResponse.changeType()).isEqualTo("change_type") assertThat(subscriptionChangeApplyResponse.expirationTime()) .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) assertThat(subscriptionChangeApplyResponse.status()) @@ -3862,8 +3868,14 @@ internal class SubscriptionChangeApplyResponseTest { ) assertThat(subscriptionChangeApplyResponse.appliedAt()) .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(subscriptionChangeApplyResponse.billingCycleAlignment()) + .isEqualTo("billing_cycle_alignment") assertThat(subscriptionChangeApplyResponse.cancelledAt()) .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(subscriptionChangeApplyResponse.changeOption()).isEqualTo("change_option") + assertThat(subscriptionChangeApplyResponse.effectiveDate()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(subscriptionChangeApplyResponse.planId()).isEqualTo("plan_id") } @Test @@ -3872,6 +3884,7 @@ internal class SubscriptionChangeApplyResponseTest { val subscriptionChangeApplyResponse = SubscriptionChangeApplyResponse.builder() .id("id") + .changeType("change_type") .expirationTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .status(SubscriptionChangeApplyResponse.Status.PENDING) .subscription( @@ -5857,7 +5870,11 @@ internal class SubscriptionChangeApplyResponseTest { .build() ) .appliedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .billingCycleAlignment("billing_cycle_alignment") .cancelledAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .changeOption("change_option") + .effectiveDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .planId("plan_id") .build() val roundtrippedSubscriptionChangeApplyResponse = diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeCancelResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeCancelResponseTest.kt index 53c6d48fe..b80e094fe 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeCancelResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeCancelResponseTest.kt @@ -16,6 +16,7 @@ internal class SubscriptionChangeCancelResponseTest { val subscriptionChangeCancelResponse = SubscriptionChangeCancelResponse.builder() .id("id") + .changeType("change_type") .expirationTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .status(SubscriptionChangeCancelResponse.Status.PENDING) .subscription( @@ -2001,10 +2002,15 @@ internal class SubscriptionChangeCancelResponseTest { .build() ) .appliedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .billingCycleAlignment("billing_cycle_alignment") .cancelledAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .changeOption("change_option") + .effectiveDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .planId("plan_id") .build() assertThat(subscriptionChangeCancelResponse.id()).isEqualTo("id") + assertThat(subscriptionChangeCancelResponse.changeType()).isEqualTo("change_type") assertThat(subscriptionChangeCancelResponse.expirationTime()) .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) assertThat(subscriptionChangeCancelResponse.status()) @@ -3862,8 +3868,14 @@ internal class SubscriptionChangeCancelResponseTest { ) assertThat(subscriptionChangeCancelResponse.appliedAt()) .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(subscriptionChangeCancelResponse.billingCycleAlignment()) + .isEqualTo("billing_cycle_alignment") assertThat(subscriptionChangeCancelResponse.cancelledAt()) .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(subscriptionChangeCancelResponse.changeOption()).isEqualTo("change_option") + assertThat(subscriptionChangeCancelResponse.effectiveDate()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(subscriptionChangeCancelResponse.planId()).isEqualTo("plan_id") } @Test @@ -3872,6 +3884,7 @@ internal class SubscriptionChangeCancelResponseTest { val subscriptionChangeCancelResponse = SubscriptionChangeCancelResponse.builder() .id("id") + .changeType("change_type") .expirationTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .status(SubscriptionChangeCancelResponse.Status.PENDING) .subscription( @@ -5857,7 +5870,11 @@ internal class SubscriptionChangeCancelResponseTest { .build() ) .appliedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .billingCycleAlignment("billing_cycle_alignment") .cancelledAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .changeOption("change_option") + .effectiveDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .planId("plan_id") .build() val roundtrippedSubscriptionChangeCancelResponse = diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeRetrieveResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeRetrieveResponseTest.kt index 8f923553a..75089ebbb 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeRetrieveResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeRetrieveResponseTest.kt @@ -16,6 +16,7 @@ internal class SubscriptionChangeRetrieveResponseTest { val subscriptionChangeRetrieveResponse = SubscriptionChangeRetrieveResponse.builder() .id("id") + .changeType("change_type") .expirationTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .status(SubscriptionChangeRetrieveResponse.Status.PENDING) .subscription( @@ -2001,10 +2002,15 @@ internal class SubscriptionChangeRetrieveResponseTest { .build() ) .appliedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .billingCycleAlignment("billing_cycle_alignment") .cancelledAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .changeOption("change_option") + .effectiveDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .planId("plan_id") .build() assertThat(subscriptionChangeRetrieveResponse.id()).isEqualTo("id") + assertThat(subscriptionChangeRetrieveResponse.changeType()).isEqualTo("change_type") assertThat(subscriptionChangeRetrieveResponse.expirationTime()) .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) assertThat(subscriptionChangeRetrieveResponse.status()) @@ -3862,8 +3868,14 @@ internal class SubscriptionChangeRetrieveResponseTest { ) assertThat(subscriptionChangeRetrieveResponse.appliedAt()) .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(subscriptionChangeRetrieveResponse.billingCycleAlignment()) + .isEqualTo("billing_cycle_alignment") assertThat(subscriptionChangeRetrieveResponse.cancelledAt()) .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(subscriptionChangeRetrieveResponse.changeOption()).isEqualTo("change_option") + assertThat(subscriptionChangeRetrieveResponse.effectiveDate()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(subscriptionChangeRetrieveResponse.planId()).isEqualTo("plan_id") } @Test @@ -3872,6 +3884,7 @@ internal class SubscriptionChangeRetrieveResponseTest { val subscriptionChangeRetrieveResponse = SubscriptionChangeRetrieveResponse.builder() .id("id") + .changeType("change_type") .expirationTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .status(SubscriptionChangeRetrieveResponse.Status.PENDING) .subscription( @@ -5857,7 +5870,11 @@ internal class SubscriptionChangeRetrieveResponseTest { .build() ) .appliedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .billingCycleAlignment("billing_cycle_alignment") .cancelledAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .changeOption("change_option") + .effectiveDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .planId("plan_id") .build() val roundtrippedSubscriptionChangeRetrieveResponse = From 936fe660fab9ecefb656d1db54b3288ec14fb235 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 11 Dec 2025 20:04:51 +0000 Subject: [PATCH 60/68] chore(internal): codegen related update --- examples/.keep | 4 ---- 1 file changed, 4 deletions(-) delete mode 100644 examples/.keep diff --git a/examples/.keep b/examples/.keep deleted file mode 100644 index d8c73e937..000000000 --- a/examples/.keep +++ /dev/null @@ -1,4 +0,0 @@ -File generated from our OpenAPI spec by Stainless. - -This directory can be used to store example files demonstrating usage of this SDK. -It is ignored by Stainless code generation and its content (other than this keep file) won't be touched. \ No newline at end of file From 9afda8fb51c587df269768e38fdba2428d8f9dac Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 12 Dec 2025 22:26:57 +0000 Subject: [PATCH 61/68] codegen metadata --- .stats.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.stats.yml b/.stats.yml index 362210976..10f84eaa9 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 118 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-03af7f658aed245cf7e230055de59fe92a78880f3719bf254ed9352bf89bad5e.yml -openapi_spec_hash: c4703d217c25e8c02c248caed9e2d3be +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-59c57f1cbc067a477f6bf673882c28065e01418b86fcff390bba0d4438c58105.yml +openapi_spec_hash: 4da2681664f766985d1c20df40240cd9 config_hash: 895e36fb2d717958770fd4cf883f4b74 From b604e38e11b64d22569de6c59c7e40c02e048b9e Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 17 Dec 2025 15:09:09 +0000 Subject: [PATCH 62/68] chore(internal): codegen related update --- .DS_Store | Bin 0 -> 6162 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 .DS_Store diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..8d0676f575d2fd605b438b5300b0baa7d72a2d16 GIT binary patch literal 6162 zcmeHK!Ab)`41Lia3SN2?PxA}@!CJN_FT#F+idGS8mC_b}PW&W)!Iw-HwCkZaL0=$w zlbK9r_rY!^0BpLsJq0EJ##BdqyuUdN#Uoq?a*#7dq%z9|u5p7$+WSHD&lA4)1RYwO zEu)uuVt(J@DrJv(DBw|1ehygJm2E@RA3}oFLAMF>e zC@~-g{t*NIe<)PPCb4!2obgFF(F71j?z?at{RFY3-y~*>VRbWY?I0{STecZi6L38e z5F-Jx?@^4&U92X6<>{7vip3Lfy)cMkO@NFT5Cc0599Dngw}2V7|HgL0 Date: Wed, 17 Dec 2025 15:25:16 +0000 Subject: [PATCH 63/68] chore(internal): codegen related update --- .DS_Store | Bin 6162 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 .DS_Store diff --git a/.DS_Store b/.DS_Store deleted file mode 100644 index 8d0676f575d2fd605b438b5300b0baa7d72a2d16..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6162 zcmeHK!Ab)`41Lia3SN2?PxA}@!CJN_FT#F+idGS8mC_b}PW&W)!Iw-HwCkZaL0=$w zlbK9r_rY!^0BpLsJq0EJ##BdqyuUdN#Uoq?a*#7dq%z9|u5p7$+WSHD&lA4)1RYwO zEu)uuVt(J@DrJv(DBw|1ehygJm2E@RA3}oFLAMF>e zC@~-g{t*NIe<)PPCb4!2obgFF(F71j?z?at{RFY3-y~*>VRbWY?I0{STecZi6L38e z5F-Jx?@^4&U92X6<>{7vip3Lfy)cMkO@NFT5Cc0599Dngw}2V7|HgL0 Date: Wed, 17 Dec 2025 18:20:47 +0000 Subject: [PATCH 64/68] codegen metadata --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 10f84eaa9..b3a9d31c0 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 118 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-59c57f1cbc067a477f6bf673882c28065e01418b86fcff390bba0d4438c58105.yml openapi_spec_hash: 4da2681664f766985d1c20df40240cd9 -config_hash: 895e36fb2d717958770fd4cf883f4b74 +config_hash: 05c94c0e6dbeab2c9b554c2e0d6371a0 From 844eb52c3959f68a8c6230accf8e570edcd553e4 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 18 Dec 2025 10:58:54 +0000 Subject: [PATCH 65/68] chore(internal): codegen related update --- .DS_Store | Bin 0 -> 6162 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 .DS_Store diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..8d0676f575d2fd605b438b5300b0baa7d72a2d16 GIT binary patch literal 6162 zcmeHK!Ab)`41Lia3SN2?PxA}@!CJN_FT#F+idGS8mC_b}PW&W)!Iw-HwCkZaL0=$w zlbK9r_rY!^0BpLsJq0EJ##BdqyuUdN#Uoq?a*#7dq%z9|u5p7$+WSHD&lA4)1RYwO zEu)uuVt(J@DrJv(DBw|1ehygJm2E@RA3}oFLAMF>e zC@~-g{t*NIe<)PPCb4!2obgFF(F71j?z?at{RFY3-y~*>VRbWY?I0{STecZi6L38e z5F-Jx?@^4&U92X6<>{7vip3Lfy)cMkO@NFT5Cc0599Dngw}2V7|HgL0 Date: Thu, 18 Dec 2025 14:19:23 +0000 Subject: [PATCH 66/68] chore(internal): codegen related update --- .DS_Store | Bin 6162 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 .DS_Store diff --git a/.DS_Store b/.DS_Store deleted file mode 100644 index 8d0676f575d2fd605b438b5300b0baa7d72a2d16..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6162 zcmeHK!Ab)`41Lia3SN2?PxA}@!CJN_FT#F+idGS8mC_b}PW&W)!Iw-HwCkZaL0=$w zlbK9r_rY!^0BpLsJq0EJ##BdqyuUdN#Uoq?a*#7dq%z9|u5p7$+WSHD&lA4)1RYwO zEu)uuVt(J@DrJv(DBw|1ehygJm2E@RA3}oFLAMF>e zC@~-g{t*NIe<)PPCb4!2obgFF(F71j?z?at{RFY3-y~*>VRbWY?I0{STecZi6L38e z5F-Jx?@^4&U92X6<>{7vip3Lfy)cMkO@NFT5Cc0599Dngw}2V7|HgL0 Date: Sun, 28 Dec 2025 05:26:01 +0000 Subject: [PATCH 67/68] codegen metadata --- .stats.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.stats.yml b/.stats.yml index b3a9d31c0..427fe5b6a 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 118 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-59c57f1cbc067a477f6bf673882c28065e01418b86fcff390bba0d4438c58105.yml -openapi_spec_hash: 4da2681664f766985d1c20df40240cd9 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-647fcb5866bd752a09db1530acb79134f9cc729b2e00d9abecc0b60806183817.yml +openapi_spec_hash: 080cc78660e0a91499a46ef8bf0a3745 config_hash: 05c94c0e6dbeab2c9b554c2e0d6371a0 From abb9d66fed66e6b0faf8f92c8fafa70be8b1a898 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Sun, 28 Dec 2025 05:26:53 +0000 Subject: [PATCH 68/68] release: 1.12.0 --- .release-please-manifest.json | 2 +- CHANGELOG.md | 80 +++++++++++++++++++++++++++++++++++ README.md | 6 +-- build.gradle.kts | 2 +- 4 files changed, 85 insertions(+), 5 deletions(-) diff --git a/.release-please-manifest.json b/.release-please-manifest.json index caf148712..de0960aba 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "1.11.0" + ".": "1.12.0" } \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index c16efd4eb..a5699c324 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,85 @@ # Changelog +## 1.12.0 (2025-12-28) + +Full Changelog: [v1.11.0...v1.12.0](https://github.com/orbcorp/orb-kotlin/compare/v1.11.0...v1.12.0) + +### ⚠ BREAKING CHANGES + +* **api:** define shared model ConversionRateConfig + +### Features + +* add retryable exception ([6bf3387](https://github.com/orbcorp/orb-kotlin/commit/6bf3387e9efe151b2db48c51a454f4ac9abb03e1)) +* **api:** api update ([e4e8d24](https://github.com/orbcorp/orb-kotlin/commit/e4e8d24b25879216965e7c55c5e23ab3bbbc69f8)) +* **api:** api update ([68203a3](https://github.com/orbcorp/orb-kotlin/commit/68203a34d2c36b47aecb227b408452f65f4db572)) +* **api:** api update ([012b348](https://github.com/orbcorp/orb-kotlin/commit/012b348959220609a650011f38e967b55aa6c906)) +* **api:** api update ([bbe220c](https://github.com/orbcorp/orb-kotlin/commit/bbe220c8813cd6a5c491da043f0b39cffe06edca)) +* **api:** api update ([cfe2c88](https://github.com/orbcorp/orb-kotlin/commit/cfe2c8868aead2144f69f0b04e304de948adbf8d)) +* **api:** api update ([74b29ea](https://github.com/orbcorp/orb-kotlin/commit/74b29eac5934c4d52380859df2df42a5c6b8db46)) +* **api:** api update ([af8a41f](https://github.com/orbcorp/orb-kotlin/commit/af8a41f71ca341c4ca6362158c555810a217ec49)) +* **api:** api update ([0f366e8](https://github.com/orbcorp/orb-kotlin/commit/0f366e8c6196b679186999278cb93686eda3c6a9)) +* **api:** api update ([2eb59cf](https://github.com/orbcorp/orb-kotlin/commit/2eb59cfcbe3b452746ef31a5f7c89f43276cffe5)) +* **api:** api update ([99993b1](https://github.com/orbcorp/orb-kotlin/commit/99993b17f65917b21e1f87b14699f5ac5cb63e1e)) +* **api:** api update ([914623a](https://github.com/orbcorp/orb-kotlin/commit/914623ae6f05e8ea28761331aba3b36676f10a99)) +* **api:** api update ([fd82100](https://github.com/orbcorp/orb-kotlin/commit/fd821005e293869c0199d3d5261f3a806df74e41)) +* **api:** api update ([9c2441e](https://github.com/orbcorp/orb-kotlin/commit/9c2441e3488e02d6e3f130dbbc1e1a9c821ac15d)) +* **api:** api update ([680265b](https://github.com/orbcorp/orb-kotlin/commit/680265b0add2f0c05eee02f1410cda5d14bd758b)) +* **api:** api update ([a1a92f4](https://github.com/orbcorp/orb-kotlin/commit/a1a92f48d35131e22f8e4e9ce51f6a31c8445277)) +* **api:** api update ([83ad00c](https://github.com/orbcorp/orb-kotlin/commit/83ad00cb56d547e695b01e7e02e923247856f3c8)) +* **api:** api update ([42c2d10](https://github.com/orbcorp/orb-kotlin/commit/42c2d10e801b46d82791cb26511cc237c5a9614a)) +* **api:** api update ([f6987c9](https://github.com/orbcorp/orb-kotlin/commit/f6987c9fd19277bfdb124bf896a74584ae69090b)) +* **api:** api update ([a58f47b](https://github.com/orbcorp/orb-kotlin/commit/a58f47b9e018a45680b2819cbc6ff9945779573d)) +* **api:** api update ([0285f3a](https://github.com/orbcorp/orb-kotlin/commit/0285f3a1dd36ff49e345c862ac5dd8e714019df1)) +* **api:** api update ([6d42811](https://github.com/orbcorp/orb-kotlin/commit/6d42811246f63cd57f9c2b9917a291ba9ef5b6ae)) +* **api:** api update ([93761f0](https://github.com/orbcorp/orb-kotlin/commit/93761f0a10e3a553c7ca56701f746de784ee2516)) +* **api:** api update ([4c2a026](https://github.com/orbcorp/orb-kotlin/commit/4c2a026cdd5327b5d58a42f2ae81975b5a8b6821)) +* **api:** api update ([11cfcca](https://github.com/orbcorp/orb-kotlin/commit/11cfcca024a9abce1fbe8d3097c3d3aeb66eee34)) +* **api:** api update ([a9326c1](https://github.com/orbcorp/orb-kotlin/commit/a9326c1fc925f51377493ccb1d50cdbcd444df07)) +* **api:** api update ([c427776](https://github.com/orbcorp/orb-kotlin/commit/c427776d050d0cc71128bbd7c1f985bf70df342c)) +* **api:** api update ([c4c96c6](https://github.com/orbcorp/orb-kotlin/commit/c4c96c6e42c74985376828b8efe6d03e0dcb91b5)) +* **api:** api update ([a05fab4](https://github.com/orbcorp/orb-kotlin/commit/a05fab462983dba1d6c3755e1e1a65d24a527f60)) +* **api:** api update ([d631c4d](https://github.com/orbcorp/orb-kotlin/commit/d631c4dd6dbf3657a11731eebdb772ed770ad154)) +* **api:** api update ([f06d033](https://github.com/orbcorp/orb-kotlin/commit/f06d033e7331f839b77ae33d33b878be2c797e5f)) +* **api:** api update ([e2b7b1e](https://github.com/orbcorp/orb-kotlin/commit/e2b7b1ee8a2594a363552c3289326b63a87112ec)) +* **api:** api update ([a790d45](https://github.com/orbcorp/orb-kotlin/commit/a790d458789e5a7336dc8510510b593b0d36ce73)) +* **api:** api update ([ee76ab8](https://github.com/orbcorp/orb-kotlin/commit/ee76ab871131d964501afbc390d2ba11595003bd)) +* **api:** api update ([6180a95](https://github.com/orbcorp/orb-kotlin/commit/6180a95d21214a3bf90989d6a80e55cf2c066fc8)) +* **api:** api update ([d43255b](https://github.com/orbcorp/orb-kotlin/commit/d43255b2f3030d1575c1c88898e1e1be202a13b6)) +* **api:** define shared model ConversionRateConfig ([32b3512](https://github.com/orbcorp/orb-kotlin/commit/32b35124936f5fea58bf91d92313b242f0d56e97)) +* **client:** ensure compat with proguard ([a21fc50](https://github.com/orbcorp/orb-kotlin/commit/a21fc50739926011c56bb30b47999d83bf7462e1)) +* **client:** expose sleeper option ([1bc7983](https://github.com/orbcorp/orb-kotlin/commit/1bc798369b1883ba86b50ac4829ccb9f5331bca5)) +* extract minimum composite to type ([c89ade2](https://github.com/orbcorp/orb-kotlin/commit/c89ade2708c48dfd327c4260ab1afe01e051e8c9)) + + +### Bug Fixes + +* **ci:** use java-version 21 for publish step ([efc7891](https://github.com/orbcorp/orb-kotlin/commit/efc789114af507dd96e591c18696a07dffad9af6)) +* **client:** deserialization of empty objects ([d4ef4ac](https://github.com/orbcorp/orb-kotlin/commit/d4ef4acd10993041451835b56cf0d1ce4d145f71)) +* **client:** ensure single timer is created per client ([1bc7983](https://github.com/orbcorp/orb-kotlin/commit/1bc798369b1883ba86b50ac4829ccb9f5331bca5)) +* **client:** incorrect `getPackageVersion` impl ([1612dd1](https://github.com/orbcorp/orb-kotlin/commit/1612dd121630d64f7d0ba6cfad7807e38765eda3)) +* **client:** multi-value header serialization ([bdc7d3a](https://github.com/orbcorp/orb-kotlin/commit/bdc7d3aa262fe9d79e9ce81dbc79b4ad7ac748eb)) +* **client:** r8 support ([4d46e62](https://github.com/orbcorp/orb-kotlin/commit/4d46e6201e6bf0a1963f05e3982ecc97bcb9519c)) +* **schema:** Rename unit price type to avoid naming conflict ([25c6f8c](https://github.com/orbcorp/orb-kotlin/commit/25c6f8c58010e5c2dd909f8161c8fee5465f2847)) + + +### Chores + +* **internal:** bump ci test timeout ([c9b431a](https://github.com/orbcorp/orb-kotlin/commit/c9b431af1e09f27dd08de5d1b247b72f70d160ae)) +* **internal:** change some comment formatting ([537aba1](https://github.com/orbcorp/orb-kotlin/commit/537aba177c709243ce291115eb15e8c1fd0adfa4)) +* **internal:** codegen related update ([b0ad475](https://github.com/orbcorp/orb-kotlin/commit/b0ad475dd5023f009b7d8a9a111a1b09c2e9f433)) +* **internal:** codegen related update ([844eb52](https://github.com/orbcorp/orb-kotlin/commit/844eb52c3959f68a8c6230accf8e570edcd553e4)) +* **internal:** codegen related update ([3239df5](https://github.com/orbcorp/orb-kotlin/commit/3239df52ca72a667fccc76f7bdf4799644b8322b)) +* **internal:** codegen related update ([b604e38](https://github.com/orbcorp/orb-kotlin/commit/b604e38e11b64d22569de6c59c7e40c02e048b9e)) +* **internal:** codegen related update ([936fe66](https://github.com/orbcorp/orb-kotlin/commit/936fe660fab9ecefb656d1db54b3288ec14fb235)) +* **internal:** codegen related update ([d06f656](https://github.com/orbcorp/orb-kotlin/commit/d06f6564fcaeaf124295a7cc5db061e7092e4771)) +* **internal:** reduce proguard ci logging ([ba337ee](https://github.com/orbcorp/orb-kotlin/commit/ba337ee683dea8296441855e1c5583c86bfa7f04)) + + +### Documentation + +* remove `$` for better copy-pasteabality ([7e95cda](https://github.com/orbcorp/orb-kotlin/commit/7e95cda57ad7eef980190010d8c68db1fb7f9eb3)) + ## 1.11.0 (2025-07-26) Full Changelog: [v1.10.0...v1.11.0](https://github.com/orbcorp/orb-kotlin/compare/v1.10.0...v1.11.0) diff --git a/README.md b/README.md index fd129caff..5077e62fe 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ -[![Maven Central](https://img.shields.io/maven-central/v/com.withorb.api/orb-kotlin)](https://central.sonatype.com/artifact/com.withorb.api/orb-kotlin/1.11.0) +[![Maven Central](https://img.shields.io/maven-central/v/com.withorb.api/orb-kotlin)](https://central.sonatype.com/artifact/com.withorb.api/orb-kotlin/1.12.0) @@ -19,7 +19,7 @@ The REST API documentation can be found on [docs.withorb.com](https://docs.witho ### Gradle ```kotlin -implementation("com.withorb.api:orb-kotlin:1.11.0") +implementation("com.withorb.api:orb-kotlin:1.12.0") ``` ### Maven @@ -28,7 +28,7 @@ implementation("com.withorb.api:orb-kotlin:1.11.0") com.withorb.api orb-kotlin - 1.11.0 + 1.12.0 ``` diff --git a/build.gradle.kts b/build.gradle.kts index 81989492b..4fd74a10b 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,6 +1,6 @@ allprojects { group = "com.withorb.api" - version = "1.11.0" // x-release-please-version + version = "1.12.0" // x-release-please-version } subprojects {